pablof7z / highlighter-chrome-extension

Highlighter.com Chrome extension
5 stars 2 forks source link

Unable to use on Brave browser #2

Open DataN0strum opened 11 months ago

DataN0strum commented 11 months ago

When I install the extension on Brave, I see the little extension icon, but nothing happens when I click on it.

The "highlight" menu option is available when I right-click on selected text in the browser, but clicking on that does nothing either.

Highlighter Extension 0.2.1

Brave Version 1.57.57 Chromium: 116.0.5845.163 (Official Build) (arm64)

mandric commented 11 months ago

Does the web console provide any errors?

DataN0strum commented 11 months ago

Now I noticed that, if I have the "sidebar" open, then clicking on the Highlighter extension icon quickly opens up a window inside the sidebar saying "Enter your npub (to use with nsec bunker)", but it disappears again after a fraction of a second.

Not sure how to spot errors in the web console, can you provide instructions?

mandric commented 11 months ago

You should be able to right click into the extension side panel and choose inspect and it will bring up a console.

Screenshot 2023-09-20 at 4 10 03 PM

It may not be compatible with Brave even though the extension API should be very similar, since Brave is using Chromium. I am trying to figure out if it's a bug in the extension because it should be compatible with Brave. I am not the author of this extension, I am just a developer trying to learn about Nostr and help debug your issue nonetheless. I have written a few extensions for Chrome but never for Brave and it would be nice if the extension ran in Brave because that is also a good browser choice.

DataN0strum commented 11 months ago

As I mentioned, the panel only stays open for a fraction of a second when I click on the extension button, not enough time to click into it or even read it.

In fact, if I don't have a browser sidebar open, then nothing happens at all when I click on the extension button.

Only if I first open an empty sidebar beforehand by clicking "Show Sidebar" (see screenshot below), and then click on the extension button, the extension panel very briefly appears in the sidebar, and then the sidebar disappears, although the "Show Sidebar" button still appears activated - it then takes TWO clicks on that button to make the (empty) sidebar appear again

image

Does it work for you in Brave?

mandric commented 11 months ago

I just loaded the extension from a local build, the panel opens but there are errors.

Screenshot 2023-09-22 at 6 56 19 PM Screenshot 2023-09-22 at 6 58 06 PM

You might also try the errors button in the extensions settings page if the extension won't load at all. (chrome://extensions will redirect to brave://extensions)

Screenshot 2023-09-22 at 6 57 06 PM
mandric commented 11 months ago

Brave Version 1.58.131 Chromium: 117.0.5938.92 (Official Build) (×86_64)

mandric commented 11 months ago

Also just tried using the Release 0.1.0 zip from GitHub and pretty much the same thing.

DataN0strum commented 11 months ago

In the Extensions settings page, I do see an Errors button with the following error:

image
(()=>{var e={9018:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createCurve=t.getHash=void 0;const r=n(9932),i=n(4099),o=n(5240);function s(e){return{hash:e,hmac:(t,...n)=>(0,r.hmac)(e,t,(0,i.concatBytes)(...n)),randomBytes:i.randomBytes}}t.getHash=s,t.createCurve=function(e,t){const n=t=>(0,o.weierstrass)({...e,...s(t)});return Object.freeze({...n(t),create:n})}},4482:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateBasic=t.wNAF=void 0;const r=n(7031),i=n(3885),o=BigInt(0),s=BigInt(1);t.wNAF=function(e,t){const n=(e,t)=>{const n=t.negate();return e?n:t},r=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:n,unsafeLadder(t,n){let r=e.ZERO,i=t;for(;n>o;)n&s&&(r=r.add(i)),i=i.double(),n>>=s;return r},precomputeWindow(e,t){const{windows:n,windowSize:i}=r(t),o=[];let s=e,a=s;for(let e=0;e<n;e++){a=s,o.push(a);for(let e=1;e<i;e++)a=a.add(s),o.push(a);s=a.double()}return o},wNAF(t,i,o){const{windows:a,windowSize:c}=r(t);let u=e.ZERO,l=e.BASE;const h=BigInt(2**t-1),d=2**t,f=BigInt(t);for(let e=0;e<a;e++){const t=e*c;let r=Number(o&h);o>>=f,r>c&&(r-=d,o+=s);const a=t,p=t+Math.abs(r)-1,y=e%2!=0,g=r<0;0===r?l=l.add(n(y,i[a])):u=u.add(n(g,i[p]))}return{p:u,f:l}},wNAFCached(e,t,n,r){const i=e._WINDOW_SIZE||1;let o=t.get(e);return o||(o=this.precomputeWindow(e,i),1!==i&&t.set(e,r(o))),this.wNAF(i,o,n)}}},t.validateBasic=function(e){return(0,r.validateField)(e.Fp),(0,i.validateObject)(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,r.nLength)(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}},2086:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createHasher=t.isogenyMap=t.hash_to_field=t.expand_message_xof=t.expand_message_xmd=void 0;const r=n(7031),i=n(3885),o=i.bytesToNumberBE;function s(e,t){if(e<0||e>=1<<8*t)throw new Error(`bad I2OSP call: value=${e} length=${t}`);const n=Array.from({length:t}).fill(0);for(let r=t-1;r>=0;r--)n[r]=255&e,e>>>=8;return new Uint8Array(n)}function a(e,t){const n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e[r]^t[r];return n}function c(e){if(!(e instanceof Uint8Array))throw new Error("Uint8Array expected")}function u(e){if(!Number.isSafeInteger(e))throw new Error("number expected")}function l(e,t,n,r){c(e),c(t),u(n),t.length>255&&(t=r((0,i.concatBytes)((0,i.utf8ToBytes)("H2C-OVERSIZE-DST-"),t)));const{outputLen:o,blockLen:l}=r,h=Math.ceil(n/o);if(h>255)throw new Error("Invalid xmd length");const d=(0,i.concatBytes)(t,s(t.length,1)),f=s(0,l),p=s(n,2),y=new Array(h),g=r((0,i.concatBytes)(f,e,p,s(0,1),d));y[0]=r((0,i.concatBytes)(g,s(1,1),d));for(let e=1;e<=h;e++){const t=[a(g,y[e-1]),s(e+1,1),d];y[e]=r((0,i.concatBytes)(...t))}return(0,i.concatBytes)(...y).slice(0,n)}function h(e,t,n,r,o){if(c(e),c(t),u(n),t.length>255){const e=Math.ceil(2*r/8);t=o.create({dkLen:e}).update((0,i.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(t).digest()}if(n>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return o.create({dkLen:n}).update(e).update(s(n,2)).update(t).update(s(t.length,1)).digest()}function d(e,t,n){(0,i.validateObject)(n,{DST:"string",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:s,k:a,m:d,hash:f,expand:p,DST:y}=n;c(e),u(t);const g=function(e){if(e instanceof Uint8Array)return e;if("string"==typeof e)return(0,i.utf8ToBytes)(e);throw new Error("DST must be Uint8Array or string")}(y),b=s.toString(2).length,v=Math.ceil((b+a)/8),w=t*d*v;let m;if("xmd"===p)m=l(e,g,w,f);else if("xof"===p)m=h(e,g,w,a,f);else{if("_internal_pass"!==p)throw new Error('expand must be "xmd" or "xof"');m=e}const _=new Array(t);for(let e=0;e<t;e++){const t=new Array(d);for(let n=0;n<d;n++){const i=v*(n+e*d),a=m.subarray(i,i+v);t[n]=(0,r.mod)(o(a),s)}_[e]=t}return _}t.expand_message_xmd=l,t.expand_message_xof=h,t.hash_to_field=d,t.isogenyMap=function(e,t){const n=t.map((e=>Array.from(e).reverse()));return(t,r)=>{const[i,o,s,a]=n.map((n=>n.reduce(((n,r)=>e.add(e.mul(n,t),r)))));return t=e.div(i,o),r=e.mul(r,e.div(s,a)),{x:t,y:r}}},t.createHasher=function(e,t,n){if("function"!=typeof t)throw new Error("mapToCurve() must be defined");return{hashToCurve(r,i){const o=d(r,2,{...n,DST:n.DST,...i}),s=e.fromAffine(t(o[0])),a=e.fromAffine(t(o[1])),c=s.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(r,i){const o=d(r,1,{...n,DST:n.encodeDST,...i}),s=e.fromAffine(t(o[0])).clearCofactor();return s.assertValidity(),s}}}},7031:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hashToPrivateScalar=t.FpSqrtEven=t.FpSqrtOdd=t.Field=t.nLength=t.FpIsSquare=t.FpDiv=t.FpInvertBatch=t.FpPow=t.validateField=t.isNegativeLE=t.FpSqrt=t.tonelliShanks=t.invert=t.pow2=t.pow=t.mod=void 0;const r=n(3885),i=BigInt(0),o=BigInt(1),s=BigInt(2),a=BigInt(3),c=BigInt(4),u=BigInt(5),l=BigInt(8);function h(e,t){const n=e%t;return n>=i?n:t+n}function d(e,t,n){if(n<=i||t<i)throw new Error("Expected power/modulo > 0");if(n===o)return i;let r=o;for(;t>i;)t&o&&(r=r*e%n),e=e*e%n,t>>=o;return r}function f(e,t){if(e===i||t<=i)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=h(e,t),r=t,s=i,a=o,c=o,u=i;for(;n!==i;){const e=r/n,t=r%n,i=s-c*e,o=a-u*e;r=n,n=t,s=c,a=u,c=i,u=o}if(r!==o)throw new Error("invert: does not exist");return h(s,t)}function p(e){const t=(e-o)/s;let n,r,a;for(n=e-o,r=0;n%s===i;n/=s,r++);for(a=s;a<e&&d(a,t,e)!==e-o;a++);if(1===r){const t=(e+o)/c;return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}}const u=(n+o)/s;return function(e,i){if(e.pow(i,t)===e.neg(e.ONE))throw new Error("Cannot find square root");let s=r,c=e.pow(e.mul(e.ONE,a),n),l=e.pow(i,u),h=e.pow(i,n);for(;!e.eql(h,e.ONE);){if(e.eql(h,e.ZERO))return e.ZERO;let t=1;for(let n=e.sqr(h);t<s&&!e.eql(n,e.ONE);t++)n=e.sqr(n);const n=e.pow(c,o<<BigInt(s-t-1));c=e.sqr(n),l=e.mul(l,n),h=e.mul(h,c),s=t}return l}}function y(e){if(e%c===a){const t=(e+o)/c;return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}}if(e%l===u){const t=(e-u)/l;return function(e,n){const r=e.mul(n,s),i=e.pow(r,t),o=e.mul(n,i),a=e.mul(e.mul(o,s),i),c=e.mul(o,e.sub(a,e.ONE));if(!e.eql(e.sqr(c),n))throw new Error("Cannot find square root");return c}}return p(e)}BigInt(9),BigInt(16),t.mod=h,t.pow=d,t.pow2=function(e,t,n){let r=e;for(;t-- >i;)r*=r,r%=n;return r},t.invert=f,t.tonelliShanks=p,t.FpSqrt=y,t.isNegativeLE=(e,t)=>(h(e,t)&o)===o;const g=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function b(e,t,n){if(n<i)throw new Error("Expected power > 0");if(n===i)return e.ONE;if(n===o)return t;let r=e.ONE,s=t;for(;n>i;)n&o&&(r=e.mul(r,s)),s=e.sqr(s),n>>=o;return r}function v(e,t){const n=new Array(t.length),r=t.reduce(((t,r,i)=>e.is0(r)?t:(n[i]=t,e.mul(t,r))),e.ONE),i=e.inv(r);return t.reduceRight(((t,r,i)=>e.is0(r)?t:(n[i]=e.mul(t,n[i]),e.mul(t,r))),i),n}function w(e,t){const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}t.validateField=function(e){const t=g.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});return(0,r.validateObject)(e,t)},t.FpPow=b,t.FpInvertBatch=v,t.FpDiv=function(e,t,n){return e.mul(t,"bigint"==typeof n?f(n,e.ORDER):e.inv(n))},t.FpIsSquare=function(e){const t=(e.ORDER-o)/s;return n=>{const r=e.pow(n,t);return e.eql(r,e.ZERO)||e.eql(r,e.ONE)}},t.nLength=w,t.Field=function(e,t,n=!1,s={}){if(e<=i)throw new Error(`Expected Fp ORDER > 0, got ${e}`);const{nBitLength:a,nByteLength:c}=w(e,t);if(c>2048)throw new Error("Field lengths over 2048 bytes are not supported");const u=y(e),l=Object.freeze({ORDER:e,BITS:a,BYTES:c,MASK:(0,r.bitMask)(a),ZERO:i,ONE:o,create:t=>h(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return i<=t&&t<e},is0:e=>e===i,isOdd:e=>(e&o)===o,neg:t=>h(-t,e),eql:(e,t)=>e===t,sqr:t=>h(t*t,e),add:(t,n)=>h(t+n,e),sub:(t,n)=>h(t-n,e),mul:(t,n)=>h(t*n,e),pow:(e,t)=>b(l,e,t),div:(t,n)=>h(t*f(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>f(t,e),sqrt:s.sqrt||(e=>u(l,e)),invertBatch:e=>v(l,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?(0,r.numberToBytesLE)(e,c):(0,r.numberToBytesBE)(e,c),fromBytes:e=>{if(e.length!==c)throw new Error(`Fp.fromBytes: expected ${c}, got ${e.length}`);return n?(0,r.bytesToNumberLE)(e):(0,r.bytesToNumberBE)(e)}});return Object.freeze(l)},t.FpSqrtOdd=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const n=e.sqrt(t);return e.isOdd(n)?n:e.neg(n)},t.FpSqrtEven=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const n=e.sqrt(t);return e.isOdd(n)?e.neg(n):n},t.hashToPrivateScalar=function(e,t,n=!1){const i=(e=(0,r.ensureBytes)("privateHash",e)).length,s=w(t).nByteLength+8;if(s<24||i<s||i>1024)throw new Error(`hashToPrivateScalar: expected ${s}-1024 bytes of input, got ${i}`);return h(n?(0,r.bytesToNumberLE)(e):(0,r.bytesToNumberBE)(e),t-o)+o}},3885:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateObject=t.createHmacDrbg=t.bitMask=t.bitSet=t.bitGet=t.bitLen=t.utf8ToBytes=t.equalBytes=t.concatBytes=t.ensureBytes=t.numberToVarBytesBE=t.numberToBytesLE=t.numberToBytesBE=t.bytesToNumberLE=t.bytesToNumberBE=t.hexToBytes=t.hexToNumber=t.numberToHexUnpadded=t.bytesToHex=void 0;const n=BigInt(0),r=BigInt(1),i=BigInt(2),o=e=>e instanceof Uint8Array,s=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function a(e){if(!o(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=s[e[n]];return t}function c(e){const t=e.toString(16);return 1&t.length?`0${t}`:t}function u(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":`0x${e}`)}function l(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(t/2);for(let t=0;t<n.length;t++){const r=2*t,i=e.slice(r,r+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");n[t]=o}return n}function h(e,t){return l(e.toString(16).padStart(2*t,"0"))}function d(...e){const t=new Uint8Array(e.reduce(((e,t)=>e+t.length),0));let n=0;return e.forEach((e=>{if(!o(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length})),t}t.bytesToHex=a,t.numberToHexUnpadded=c,t.hexToNumber=u,t.hexToBytes=l,t.bytesToNumberBE=function(e){return u(a(e))},t.bytesToNumberLE=function(e){if(!o(e))throw new Error("Uint8Array expected");return u(a(Uint8Array.from(e).reverse()))},t.numberToBytesBE=h,t.numberToBytesLE=function(e,t){return h(e,t).reverse()},t.numberToVarBytesBE=function(e){return l(c(e))},t.ensureBytes=function(e,t,n){let r;if("string"==typeof t)try{r=l(t)}catch(n){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${n}`)}else{if(!o(t))throw new Error(`${e} must be hex string or Uint8Array`);r=Uint8Array.from(t)}const i=r.length;if("number"==typeof n&&i!==n)throw new Error(`${e} expected ${n} bytes, got ${i}`);return r},t.concatBytes=d,t.equalBytes=function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},t.utf8ToBytes=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))},t.bitLen=function(e){let t;for(t=0;e>n;e>>=r,t+=1);return t},t.bitGet=function(e,t){return e>>BigInt(t)&r},t.bitSet=(e,t,i)=>e|(i?r:n)<<BigInt(t),t.bitMask=e=>(i<<BigInt(e-1))-r;const f=e=>new Uint8Array(e),p=e=>Uint8Array.from(e);t.createHmacDrbg=function(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");let r=f(e),i=f(e),o=0;const s=()=>{r.fill(1),i.fill(0),o=0},a=(...e)=>n(i,r,...e),c=(e=f())=>{i=a(p([0]),e),r=a(),0!==e.length&&(i=a(p([1]),e),r=a())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){r=a();const t=r.slice();n.push(t),e+=r.length}return d(...n)};return(e,t)=>{let n;for(s(),c(e);!(n=t(u()));)c();return s(),n}};const y={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};t.validateObject=function(e,t,n={}){const r=(t,n,r)=>{const i=y[n];if("function"!=typeof i)throw new Error(`Invalid validator "${n}", expected function`);const o=e[t];if(!(r&&void 0===o||i(o,e)))throw new Error(`Invalid param ${String(t)}=${o} (${typeof o}), expected ${n}`)};for(const[e,n]of Object.entries(t))r(e,n,!1);for(const[e,t]of Object.entries(n))r(e,t,!0);return e}},5240:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mapToCurveSimpleSWU=t.SWUFpSqrtRatio=t.weierstrass=t.weierstrassPoints=t.DER=void 0;const r=n(7031),i=n(3885),o=n(3885),s=n(4482),{bytesToNumberBE:a,hexToBytes:c}=i;t.DER={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(e){const{Err:n}=t.DER;if(e.length<2||2!==e[0])throw new n("Invalid signature integer tag");const r=e[1],i=e.subarray(2,r+2);if(!r||i.length!==r)throw new n("Invalid signature integer: wrong length");if(128&i[0])throw new n("Invalid signature integer: negative");if(0===i[0]&&!(128&i[1]))throw new n("Invalid signature integer: unnecessary leading zero");return{d:a(i),l:e.subarray(r+2)}},toSig(e){const{Err:n}=t.DER,r="string"==typeof e?c(e):e;if(!(r instanceof Uint8Array))throw new Error("ui8a expected");let i=r.length;if(i<2||48!=r[0])throw new n("Invalid signature tag");if(r[1]!==i-2)throw new n("Invalid signature: incorrect length");const{d:o,l:s}=t.DER._parseInt(r.subarray(2)),{d:a,l:u}=t.DER._parseInt(s);if(u.length)throw new n("Invalid signature: left bytes after parsing");return{r:o,s:a}},hexFromSig(e){const t=e=>8&Number.parseInt(e[0],16)?"00"+e:e,n=e=>{const t=e.toString(16);return 1&t.length?`0${t}`:t},r=t(n(e.s)),i=t(n(e.r)),o=r.length/2,s=i.length/2,a=n(o),c=n(s);return`30${n(s+o+4)}02${c}${i}02${a}${r}`}};const u=BigInt(0),l=BigInt(1),h=BigInt(2),d=BigInt(3),f=BigInt(4);function p(e){const t=function(e){const t=(0,s.validateBasic)(e);i.validateObject(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:o}=t;if(n){if(!r.eql(o,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}(e),{Fp:n}=t,a=t.toBytes||((e,t,r)=>{const o=t.toAffine();return i.concatBytes(Uint8Array.from([4]),n.toBytes(o.x),n.toBytes(o.y))}),c=t.fromBytes||(e=>{const t=e.subarray(1);return{x:n.fromBytes(t.subarray(0,n.BYTES)),y:n.fromBytes(t.subarray(n.BYTES,2*n.BYTES))}});function h(e){const{a:r,b:i}=t,o=n.sqr(e),s=n.mul(o,e);return n.add(n.add(s,n.mul(e,r)),i)}if(!n.eql(n.sqr(t.Gy),h(t.Gx)))throw new Error("bad generator point: equation left != right");function f(e){return"bigint"==typeof e&&u<e&&e<t.n}function p(e){if(!f(e))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function y(e){const{allowedPrivateKeyLengths:n,nByteLength:s,wrapPrivateKey:a,n:c}=t;if(n&&"bigint"!=typeof e){if(e instanceof Uint8Array&&(e=i.bytesToHex(e)),"string"!=typeof e||!n.includes(e.length))throw new Error("Invalid key");e=e.padStart(2*s,"0")}let u;try{u="bigint"==typeof e?e:i.bytesToNumberBE((0,o.ensureBytes)("private key",e,s))}catch(t){throw new Error(`private key must be ${s} bytes, hex or bigint, not ${typeof e}`)}return a&&(u=r.mod(u,c)),p(u),u}const g=new Map;function b(e){if(!(e instanceof v))throw new Error("ProjectivePoint expected")}class v{constructor(e,t,r){if(this.px=e,this.py=t,this.pz=r,null==e||!n.isValid(e))throw new Error("x required");if(null==t||!n.isValid(t))throw new Error("y required");if(null==r||!n.isValid(r))throw new Error("z required")}static fromAffine(e){const{x:t,y:r}=e||{};if(!e||!n.isValid(t)||!n.isValid(r))throw new Error("invalid affine point");if(e instanceof v)throw new Error("projective point not allowed");const i=e=>n.eql(e,n.ZERO);return i(t)&&i(r)?v.ZERO:new v(t,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=n.invertBatch(e.map((e=>e.pz)));return e.map(((e,n)=>e.toAffine(t[n]))).map(v.fromAffine)}static fromHex(e){const t=v.fromAffine(c((0,o.ensureBytes)("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return v.BASE.multiply(y(e))}_setWindowSize(e){this._WINDOW_SIZE=e,g.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint)return;throw new Error("bad point: ZERO")}const{x:e,y:r}=this.toAffine();if(!n.isValid(e)||!n.isValid(r))throw new Error("bad point: x or y not FE");const i=n.sqr(r),o=h(e);if(!n.eql(i,o))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){b(e);const{px:t,py:r,pz:i}=this,{px:o,py:s,pz:a}=e,c=n.eql(n.mul(t,a),n.mul(o,i)),u=n.eql(n.mul(r,a),n.mul(s,i));return c&&u}negate(){return new v(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:r}=t,i=n.mul(r,d),{px:o,py:s,pz:a}=this;let c=n.ZERO,u=n.ZERO,l=n.ZERO,h=n.mul(o,o),f=n.mul(s,s),p=n.mul(a,a),y=n.mul(o,s);return y=n.add(y,y),l=n.mul(o,a),l=n.add(l,l),c=n.mul(e,l),u=n.mul(i,p),u=n.add(c,u),c=n.sub(f,u),u=n.add(f,u),u=n.mul(c,u),c=n.mul(y,c),l=n.mul(i,l),p=n.mul(e,p),y=n.sub(h,p),y=n.mul(e,y),y=n.add(y,l),l=n.add(h,h),h=n.add(l,h),h=n.add(h,p),h=n.mul(h,y),u=n.add(u,h),p=n.mul(s,a),p=n.add(p,p),h=n.mul(p,y),c=n.sub(c,h),l=n.mul(p,f),l=n.add(l,l),l=n.add(l,l),new v(c,u,l)}add(e){b(e);const{px:r,py:i,pz:o}=this,{px:s,py:a,pz:c}=e;let u=n.ZERO,l=n.ZERO,h=n.ZERO;const f=t.a,p=n.mul(t.b,d);let y=n.mul(r,s),g=n.mul(i,a),w=n.mul(o,c),m=n.add(r,i),_=n.add(s,a);m=n.mul(m,_),_=n.add(y,g),m=n.sub(m,_),_=n.add(r,o);let E=n.add(s,c);return _=n.mul(_,E),E=n.add(y,w),_=n.sub(_,E),E=n.add(i,o),u=n.add(a,c),E=n.mul(E,u),u=n.add(g,w),E=n.sub(E,u),h=n.mul(f,_),u=n.mul(p,w),h=n.add(u,h),u=n.sub(g,h),h=n.add(g,h),l=n.mul(u,h),g=n.add(y,y),g=n.add(g,y),w=n.mul(f,w),_=n.mul(p,_),g=n.add(g,w),w=n.sub(y,w),w=n.mul(f,w),_=n.add(_,w),y=n.mul(g,_),l=n.add(l,y),y=n.mul(E,_),u=n.mul(m,u),u=n.sub(u,y),y=n.mul(m,g),h=n.mul(E,h),h=n.add(h,y),new v(u,l,h)}subtract(e){return this.add(e.negate())}is0(){return this.equals(v.ZERO)}wNAF(e){return m.wNAFCached(this,g,e,(e=>{const t=n.invertBatch(e.map((e=>e.pz)));return e.map(((e,n)=>e.toAffine(t[n]))).map(v.fromAffine)}))}multiplyUnsafe(e){const r=v.ZERO;if(e===u)return r;if(p(e),e===l)return this;const{endo:i}=t;if(!i)return m.unsafeLadder(this,e);let{k1neg:o,k1:s,k2neg:a,k2:c}=i.splitScalar(e),h=r,d=r,f=this;for(;s>u||c>u;)s&l&&(h=h.add(f)),c&l&&(d=d.add(f)),f=f.double(),s>>=l,c>>=l;return o&&(h=h.negate()),a&&(d=d.negate()),d=new v(n.mul(d.px,i.beta),d.py,d.pz),h.add(d)}multiply(e){p(e);let r,i,o=e;const{endo:s}=t;if(s){const{k1neg:e,k1:t,k2neg:a,k2:c}=s.splitScalar(o);let{p:u,f:l}=this.wNAF(t),{p:h,f:d}=this.wNAF(c);u=m.constTimeNegate(e,u),h=m.constTimeNegate(a,h),h=new v(n.mul(h.px,s.beta),h.py,h.pz),r=u.add(h),i=l.add(d)}else{const{p:e,f:t}=this.wNAF(o);r=e,i=t}return v.normalizeZ([r,i])[0]}multiplyAndAddUnsafe(e,t,n){const r=v.BASE,i=(e,t)=>t!==u&&t!==l&&e.equals(r)?e.multiply(t):e.multiplyUnsafe(t),o=i(this,t).add(i(e,n));return o.is0()?void 0:o}toAffine(e){const{px:t,py:r,pz:i}=this,o=this.is0();null==e&&(e=o?n.ONE:n.inv(i));const s=n.mul(t,e),a=n.mul(r,e),c=n.mul(i,e);if(o)return{x:n.ZERO,y:n.ZERO};if(!n.eql(c,n.ONE))throw new Error("invZ was invalid");return{x:s,y:a}}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e===l)return!0;if(n)return n(v,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:n}=t;return e===l?this:n?n(v,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),a(v,this,e)}toHex(e=!0){return i.bytesToHex(this.toRawBytes(e))}}v.BASE=new v(t.Gx,t.Gy,n.ONE),v.ZERO=new v(n.ZERO,n.ONE,n.ZERO);const w=t.nBitLength,m=(0,s.wNAF)(v,t.endo?Math.ceil(w/2):w);return{CURVE:t,ProjectivePoint:v,normPrivateKeyToScalar:y,weierstrassEquation:h,isWithinCurveOrder:f}}function y(e,t){const n=e.ORDER;let r=u;for(let e=n-l;e%h===u;e/=h)r+=l;const i=r,o=h<<i-l-l,s=o*h,a=(n-l)/s,c=(a-l)/h,p=s-l,y=o,g=e.pow(t,a),b=e.pow(t,(a+l)/h);let v=(t,n)=>{let r=g,o=e.pow(n,p),s=e.sqr(o);s=e.mul(s,n);let a=e.mul(t,s);a=e.pow(a,c),a=e.mul(a,o),o=e.mul(a,n),s=e.mul(a,t);let u=e.mul(s,o);a=e.pow(u,y);let d=e.eql(a,e.ONE);o=e.mul(s,b),a=e.mul(u,r),s=e.cmov(o,s,d),u=e.cmov(a,u,d);for(let t=i;t>l;t--){let n=t-h;n=h<<n-l;let i=e.pow(u,n);const a=e.eql(i,e.ONE);o=e.mul(s,r),r=e.mul(r,r),i=e.mul(u,r),s=e.cmov(o,s,a),u=e.cmov(i,u,a)}return{isValid:d,value:s}};if(e.ORDER%f===d){const n=(e.ORDER-d)/f,r=e.sqrt(e.neg(t));v=(t,i)=>{let o=e.sqr(i);const s=e.mul(t,i);o=e.mul(o,s);let a=e.pow(o,n);a=e.mul(a,s);const c=e.mul(a,r),u=e.mul(e.sqr(a),i),l=e.eql(u,t);return{isValid:l,value:e.cmov(c,a,l)}}}return v}t.weierstrassPoints=p,t.weierstrass=function(e){const n=function(e){const t=(0,s.validateBasic)(e);return i.validateObject(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(e),{Fp:a,n:c}=n,h=a.BYTES+1,d=2*a.BYTES+1;function f(e){return r.mod(e,c)}function y(e){return r.invert(e,c)}const{ProjectivePoint:g,normPrivateKeyToScalar:b,weierstrassEquation:v,isWithinCurveOrder:w}=p({...n,toBytes(e,t,n){const r=t.toAffine(),o=a.toBytes(r.x),s=i.concatBytes;return n?s(Uint8Array.from([t.hasEvenY()?2:3]),o):s(Uint8Array.from([4]),o,a.toBytes(r.y))},fromBytes(e){const t=e.length,n=e[0],r=e.subarray(1);if(t!==h||2!==n&&3!==n){if(t===d&&4===n)return{x:a.fromBytes(r.subarray(0,a.BYTES)),y:a.fromBytes(r.subarray(a.BYTES,2*a.BYTES))};throw new Error(`Point of length ${t} was invalid. Expected ${h} compressed bytes or ${d} uncompressed bytes`)}{const e=i.bytesToNumberBE(r);if(!(u<(o=e)&&o<a.ORDER))throw new Error("Point is not on curve");const t=v(e);let s=a.sqrt(t);return 1==(1&n)!=((s&l)===l)&&(s=a.neg(s)),{x:e,y:s}}var o}}),m=e=>i.bytesToHex(i.numberToBytesBE(e,n.nByteLength));function _(e){return e>c>>l}const E=(e,t,n)=>i.bytesToNumberBE(e.slice(t,n));class k{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(e){const t=n.nByteLength;return e=(0,o.ensureBytes)("compactSignature",e,2*t),new k(E(e,0,t),E(e,t,2*t))}static fromDER(e){const{r:n,s:r}=t.DER.toSig((0,o.ensureBytes)("DER",e));return new k(n,r)}assertValidity(){if(!w(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!w(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(e){return new k(this.r,this.s,e)}recoverPublicKey(e){const{r:t,s:r,recovery:i}=this,s=C((0,o.ensureBytes)("msgHash",e));if(null==i||![0,1,2,3].includes(i))throw new Error("recovery id invalid");const c=2===i||3===i?t+n.n:t;if(c>=a.ORDER)throw new Error("recovery id 2 or 3 invalid");const u=0==(1&i)?"02":"03",l=g.fromHex(u+m(c)),h=y(c),d=f(-s*h),p=f(r*h),b=g.BASE.multiplyAndAddUnsafe(l,d,p);if(!b)throw new Error("point at infinify");return b.assertValidity(),b}hasHighS(){return _(this.s)}normalizeS(){return this.hasHighS()?new k(this.r,f(-this.s),this.recovery):this}toDERRawBytes(){return i.hexToBytes(this.toDERHex())}toDERHex(){return t.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return i.hexToBytes(this.toCompactHex())}toCompactHex(){return m(this.r)+m(this.s)}}const x={isValidPrivateKey(e){try{return b(e),!0}catch(e){return!1}},normPrivateKeyToScalar:b,randomPrivateKey:()=>{const e=n.randomBytes(a.BYTES+8),t=r.hashToPrivateScalar(e,c);return i.numberToBytesBE(t,n.nByteLength)},precompute:(e=8,t=g.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function S(e){const t=e instanceof Uint8Array,n="string"==typeof e,r=(t||n)&&e.length;return t?r===h||r===d:n?r===2*h||r===2*d:e instanceof g}const O=n.bits2int||function(e){const t=i.bytesToNumberBE(e),r=8*e.length-n.nBitLength;return r>0?t>>BigInt(r):t},C=n.bits2int_modN||function(e){return f(O(e))},A=i.bitMask(n.nBitLength);function T(e){if("bigint"!=typeof e)throw new Error("bigint expected");if(!(u<=e&&e<A))throw new Error(`bigint expected < 2^${n.nBitLength}`);return i.numberToBytesBE(e,n.nByteLength)}const B={lowS:n.lowS,prehash:!1},I={lowS:n.lowS,prehash:!1};return g.BASE._setWindowSize(8),{CURVE:n,getPublicKey:function(e,t=!0){return g.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,n=!0){if(S(e))throw new Error("first arg must be private key");if(!S(t))throw new Error("second arg must be public key");return g.fromHex(t).multiply(b(e)).toRawBytes(n)},sign:function(e,t,r=B){const{seed:s,k2sig:c}=function(e,t,r=B){if(["recovered","canonical"].some((e=>e in r)))throw new Error("sign() legacy options not supported");const{hash:s,randomBytes:c}=n;let{lowS:h,prehash:d,extraEntropy:p}=r;null==h&&(h=!0),e=(0,o.ensureBytes)("msgHash",e),d&&(e=(0,o.ensureBytes)("prehashed msgHash",s(e)));const v=C(e),m=b(t),E=[T(m),T(v)];if(null!=p){const e=!0===p?c(a.BYTES):p;E.push((0,o.ensureBytes)("extraEntropy",e,a.BYTES))}const x=i.concatBytes(...E),S=v;return{seed:x,k2sig:function(e){const t=O(e);if(!w(t))return;const n=y(t),r=g.BASE.multiply(t).toAffine(),i=f(r.x);if(i===u)return;const o=f(n*f(S+i*m));if(o===u)return;let s=(r.x===i?0:2)|Number(r.y&l),a=o;return h&&_(o)&&(a=function(e){return _(e)?f(-e):e}(o),s^=1),new k(i,a,s)}}}(e,t,r),h=n;return i.createHmacDrbg(h.hash.outputLen,h.nByteLength,h.hmac)(s,c)},verify:function(e,r,i,s=I){const a=e;if(r=(0,o.ensureBytes)("msgHash",r),i=(0,o.ensureBytes)("publicKey",i),"strict"in s)throw new Error("options.strict was renamed to lowS");const{lowS:c,prehash:u}=s;let l,h;try{if("string"==typeof a||a instanceof Uint8Array)try{l=k.fromDER(a)}catch(e){if(!(e instanceof t.DER.Err))throw e;l=k.fromCompact(a)}else{if("object"!=typeof a||"bigint"!=typeof a.r||"bigint"!=typeof a.s)throw new Error("PARSE");{const{r:e,s:t}=a;l=new k(e,t)}}h=g.fromHex(i)}catch(e){if("PARSE"===e.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(c&&l.hasHighS())return!1;u&&(r=n.hash(r));const{r:d,s:p}=l,b=C(r),v=y(p),w=f(b*v),m=f(d*v),_=g.BASE.multiplyAndAddUnsafe(h,w,m)?.toAffine();return!!_&&f(_.x)===d},ProjectivePoint:g,Signature:k,utils:x}},t.SWUFpSqrtRatio=y,t.mapToCurveSimpleSWU=function(e,t){if(r.validateField(e),!e.isValid(t.A)||!e.isValid(t.B)||!e.isValid(t.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const n=y(e,t.Z);if(!e.isOdd)throw new Error("Fp.isOdd is not implemented!");return r=>{let i,o,s,a,c,u,l,h;i=e.sqr(r),i=e.mul(i,t.Z),o=e.sqr(i),o=e.add(o,i),s=e.add(o,e.ONE),s=e.mul(s,t.B),a=e.cmov(t.Z,e.neg(o),!e.eql(o,e.ZERO)),a=e.mul(a,t.A),o=e.sqr(s),u=e.sqr(a),c=e.mul(u,t.A),o=e.add(o,c),o=e.mul(o,s),u=e.mul(u,a),c=e.mul(u,t.B),o=e.add(o,c),l=e.mul(i,s);const{isValid:d,value:f}=n(o,u);h=e.mul(i,r),h=e.mul(h,f),l=e.cmov(l,s,d),h=e.cmov(h,f,d);const p=e.isOdd(r)===e.isOdd(h);return h=e.cmov(e.neg(h),h,p),l=e.div(l,a),{x:l,y:h}}}},275:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.encodeToCurve=t.hashToCurve=t.schnorr=t.secp256k1=void 0;const r=n(1581),i=n(4099),o=n(7031),s=n(5240),a=n(3885),c=n(2086),u=n(9018),l=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),h=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),d=BigInt(1),f=BigInt(2),p=(e,t)=>(e+t/f)/t;function y(e){const t=l,n=BigInt(3),r=BigInt(6),i=BigInt(11),s=BigInt(22),a=BigInt(23),c=BigInt(44),u=BigInt(88),h=e*e*e%t,d=h*h*e%t,p=(0,o.pow2)(d,n,t)*d%t,y=(0,o.pow2)(p,n,t)*d%t,b=(0,o.pow2)(y,f,t)*h%t,v=(0,o.pow2)(b,i,t)*b%t,w=(0,o.pow2)(v,s,t)*v%t,m=(0,o.pow2)(w,c,t)*w%t,_=(0,o.pow2)(m,u,t)*m%t,E=(0,o.pow2)(_,c,t)*w%t,k=(0,o.pow2)(E,n,t)*d%t,x=(0,o.pow2)(k,a,t)*v%t,S=(0,o.pow2)(x,r,t)*h%t,O=(0,o.pow2)(S,f,t);if(!g.eql(g.sqr(O),e))throw new Error("Cannot find square root");return O}const g=(0,o.Field)(l,void 0,void 0,{sqrt:y});t.secp256k1=(0,u.createCurve)({a:BigInt(0),b:BigInt(7),Fp:g,n:h,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=h,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-d*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,a=BigInt("0x100000000000000000000000000000000"),c=p(s*e,t),u=p(-r*e,t);let l=(0,o.mod)(e-c*n-u*i,t),f=(0,o.mod)(-c*r-u*s,t);const y=l>a,g=f>a;if(y&&(l=t-l),g&&(f=t-f),l>a||f>a)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:y,k1:l,k2neg:g,k2:f}}}},r.sha256);const b=BigInt(0),v=e=>"bigint"==typeof e&&b<e&&e<l,w=e=>"bigint"==typeof e&&b<e&&e<h,m={};function _(e,...t){let n=m[e];if(void 0===n){const t=(0,r.sha256)(Uint8Array.from(e,(e=>e.charCodeAt(0))));n=(0,a.concatBytes)(t,t),m[e]=n}return(0,r.sha256)((0,a.concatBytes)(n,...t))}const E=e=>e.toRawBytes(!0).slice(1),k=e=>(0,a.numberToBytesBE)(e,32),x=e=>(0,o.mod)(e,l),S=e=>(0,o.mod)(e,h),O=t.secp256k1.ProjectivePoint,C=(e,t,n)=>O.BASE.multiplyAndAddUnsafe(e,t,n);function A(e){let n=t.secp256k1.utils.normPrivateKeyToScalar(e),r=O.fromPrivateKey(n);return{scalar:r.hasEvenY()?n:S(-n),bytes:E(r)}}function T(e){if(!v(e))throw new Error("bad x: need 0 < x < p");const t=x(e*e);let n=y(x(t*e+BigInt(7)));n%f!==b&&(n=x(-n));const r=new O(e,n,d);return r.assertValidity(),r}function B(...e){return S((0,a.bytesToNumberBE)(_("BIP0340/challenge",...e)))}function I(e,t,n){const r=(0,a.ensureBytes)("signature",e,64),i=(0,a.ensureBytes)("message",t),o=(0,a.ensureBytes)("publicKey",n,32);try{const e=T((0,a.bytesToNumberBE)(o)),t=(0,a.bytesToNumberBE)(r.subarray(0,32));if(!v(t))return!1;const n=(0,a.bytesToNumberBE)(r.subarray(32,64));if(!w(n))return!1;const s=B(k(t),E(e),i),c=C(e,n,S(-s));return!(!c||!c.hasEvenY()||c.toAffine().x!==t)}catch(e){return!1}}t.schnorr={getPublicKey:function(e){return A(e).bytes},sign:function(e,t,n=(0,i.randomBytes)(32)){const r=(0,a.ensureBytes)("message",e),{bytes:o,scalar:s}=A(t),c=(0,a.ensureBytes)("auxRand",n,32),u=k(s^(0,a.bytesToNumberBE)(_("BIP0340/aux",c))),l=_("BIP0340/nonce",u,o,r),h=S((0,a.bytesToNumberBE)(l));if(h===b)throw new Error("sign failed: k is zero");const{bytes:d,scalar:f}=A(h),p=B(d,o,r),y=new Uint8Array(64);if(y.set(d,0),y.set(k(S(f+p*s)),32),!I(y,r,o))throw new Error("sign: Invalid signature produced");return y},verify:I,utils:{randomPrivateKey:t.secp256k1.utils.randomPrivateKey,lift_x:T,pointToBytes:E,numberToBytesBE:a.numberToBytesBE,bytesToNumberBE:a.bytesToNumberBE,taggedHash:_,mod:o.mod}};const N=(()=>(0,c.isogenyMap)(g,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map((e=>e.map((e=>BigInt(e)))))))(),P=(()=>(0,s.mapToCurveSimpleSWU)(g,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:g.create(BigInt("-11"))}))(),R=(()=>(0,c.createHasher)(t.secp256k1.ProjectivePoint,(e=>{const{x:t,y:n}=P(g.create(e[0]));return N(t,n)}),{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:g.ORDER,m:1,k:128,expand:"xmd",hash:r.sha256}))();t.hashToCurve=R.hashToCurve,t.encodeToCurve=R.encodeToCurve},7636:(e,t)=>{"use strict";function n(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function r(e){if("boolean"!=typeof e)throw new Error(`Expected boolean, not ${e}`)}function i(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function o(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");n(e.outputLen),n(e.blockLen)}function s(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function a(e,t){i(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}Object.defineProperty(t,"__esModule",{value:!0}),t.output=t.exists=t.hash=t.bytes=t.bool=t.number=void 0,t.number=n,t.bool=r,t.bytes=i,t.hash=o,t.exists=s,t.output=a;const c={number:n,bool:r,bytes:i,hash:o,exists:s,output:a};t.default=c},8001:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SHA2=void 0;const r=n(7636),i=n(4099);class o extends i.Hash{constructor(e,t,n,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=(0,i.createView)(this.buffer)}update(e){r.default.exists(this);const{view:t,buffer:n,blockLen:o}=this,s=(e=(0,i.toBytes)(e)).length;for(let r=0;r<s;){const a=Math.min(o-this.pos,s-r);if(a!==o)n.set(e.subarray(r,r+a),this.pos),this.pos+=a,r+=a,this.pos===o&&(this.process(t,0),this.pos=0);else{const t=(0,i.createView)(e);for(;o<=s-r;r+=o)this.process(t,r)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){r.default.exists(this),r.default.output(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:o,isLE:s}=this;let{pos:a}=this;t[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>o-a&&(this.process(n,0),a=0);for(let e=a;e<o;e++)t[e]=0;!function(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const i=BigInt(32),o=BigInt(4294967295),s=Number(n>>i&o),a=Number(n&o),c=r?4:0,u=r?0:4;e.setUint32(t+c,s,r),e.setUint32(t+u,a,r)}(n,o-8,BigInt(8*this.length),s),this.process(n,0);const c=(0,i.createView)(e),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=u/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<l;e++)c.setUint32(4*e,h[e],s)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:i,destroyed:o,pos:s}=this;return e.length=r,e.pos=s,e.finished=i,e.destroyed=o,r%t&&e.buffer.set(n),e}}t.SHA2=o},3201:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.add=t.toBig=t.split=t.fromBig=void 0;const n=BigInt(2**32-1),r=BigInt(32);function i(e,t=!1){return t?{h:Number(e&n),l:Number(e>>r&n)}:{h:0|Number(e>>r&n),l:0|Number(e&n)}}function o(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let o=0;o<e.length;o++){const{h:s,l:a}=i(e[o],t);[n[o],r[o]]=[s,a]}return[n,r]}function s(e,t,n,r){const i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:0|i}}t.fromBig=i,t.split=o,t.toBig=(e,t)=>BigInt(e>>>0)<<r|BigInt(t>>>0),t.add=s;const a={fromBig:i,split:o,toBig:t.toBig,shrSH:(e,t,n)=>e>>>n,shrSL:(e,t,n)=>e<<32-n|t>>>n,rotrSH:(e,t,n)=>e>>>n|t<<32-n,rotrSL:(e,t,n)=>e<<32-n|t>>>n,rotrBH:(e,t,n)=>e<<64-n|t>>>n-32,rotrBL:(e,t,n)=>e>>>n-32|t<<64-n,rotr32H:(e,t)=>t,rotr32L:(e,t)=>e,rotlSH:(e,t,n)=>e<<n|t>>>32-n,rotlSL:(e,t,n)=>t<<n|e>>>32-n,rotlBH:(e,t,n)=>t<<n-32|e>>>64-n,rotlBL:(e,t,n)=>e<<n-32|t>>>64-n,add:s,add3L:(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),add3H:(e,t,n,r)=>t+n+r+(e/2**32|0)|0,add4L:(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),add4H:(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,add5H:(e,t,n,r,i,o)=>t+n+r+i+o+(e/2**32|0)|0,add5L:(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0)};t.default=a},5990:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.crypto=void 0,t.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0},9932:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hmac=t.HMAC=void 0;const r=n(7636),i=n(4099);class o extends i.Hash{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,r.default.hash(e);const n=(0,i.toBytes)(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(n.length>o?e.create().update(n).digest():n);for(let e=0;e<s.length;e++)s[e]^=54;this.iHash.update(s),this.oHash=e.create();for(let e=0;e<s.length;e++)s[e]^=106;this.oHash.update(s),s.fill(0)}update(e){return r.default.exists(this),this.iHash.update(e),this}digestInto(e){r.default.exists(this),r.default.bytes(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:o,outputLen:s}=this;return e.finished=r,e.destroyed=i,e.blockLen=o,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}t.HMAC=o,t.hmac=(e,t,n)=>new o(e,t).update(n).digest(),t.hmac.create=(e,t)=>new o(e,t)},1907:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pbkdf2Async=t.pbkdf2=void 0;const r=n(7636),i=n(9932),o=n(4099);function s(e,t,n,s){r.default.hash(e);const a=(0,o.checkOpts)({dkLen:32,asyncTick:10},s),{c,dkLen:u,asyncTick:l}=a;if(r.default.number(c),r.default.number(u),r.default.number(l),c<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const h=(0,o.toBytes)(t),d=(0,o.toBytes)(n),f=new Uint8Array(u),p=i.hmac.create(e,h),y=p._cloneInto().update(d);return{c,dkLen:u,asyncTick:l,DK:f,PRF:p,PRFSalt:y}}function a(e,t,n,r,i){return e.destroy(),t.destroy(),r&&r.destroy(),i.fill(0),n}t.pbkdf2=function(e,t,n,r){const{c:i,dkLen:c,DK:u,PRF:l,PRFSalt:h}=s(e,t,n,r);let d;const f=new Uint8Array(4),p=(0,o.createView)(f),y=new Uint8Array(l.outputLen);for(let e=1,t=0;t<c;e++,t+=l.outputLen){const n=u.subarray(t,t+l.outputLen);p.setInt32(0,e,!1),(d=h._cloneInto(d)).update(f).digestInto(y),n.set(y.subarray(0,n.length));for(let e=1;e<i;e++){l._cloneInto(d).update(y).digestInto(y);for(let e=0;e<n.length;e++)n[e]^=y[e]}}return a(l,h,u,d,y)},t.pbkdf2Async=async function(e,t,n,r){const{c:i,dkLen:c,asyncTick:u,DK:l,PRF:h,PRFSalt:d}=s(e,t,n,r);let f;const p=new Uint8Array(4),y=(0,o.createView)(p),g=new Uint8Array(h.outputLen);for(let e=1,t=0;t<c;e++,t+=h.outputLen){const n=l.subarray(t,t+h.outputLen);y.setInt32(0,e,!1),(f=d._cloneInto(f)).update(p).digestInto(g),n.set(g.subarray(0,n.length)),await(0,o.asyncLoop)(i-1,u,(e=>{h._cloneInto(f).update(g).digestInto(g);for(let e=0;e<n.length;e++)n[e]^=g[e]}))}return a(h,d,l,f,g)}},1447:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ripemd160=t.RIPEMD160=void 0;const r=n(8001),i=n(4099),o=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),s=Uint8Array.from({length:16},((e,t)=>t)),a=s.map((e=>(9*e+5)%16));let c=[s],u=[a];for(let e=0;e<4;e++)for(let t of[c,u])t.push(t[e].map((e=>o[e])));const l=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map((e=>new Uint8Array(e))),h=c.map(((e,t)=>e.map((e=>l[t][e])))),d=u.map(((e,t)=>e.map((e=>l[t][e])))),f=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),p=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]),y=(e,t)=>e<<t|e>>>32-t;function g(e,t,n,r){return 0===e?t^n^r:1===e?t&n|~t&r:2===e?(t|~n)^r:3===e?t&r|n&~r:t^(n|~r)}const b=new Uint32Array(16);class v extends r.SHA2{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:e,h1:t,h2:n,h3:r,h4:i}=this;return[e,t,n,r,i]}set(e,t,n,r,i){this.h0=0|e,this.h1=0|t,this.h2=0|n,this.h3=0|r,this.h4=0|i}process(e,t){for(let n=0;n<16;n++,t+=4)b[n]=e.getUint32(t,!0);let n=0|this.h0,r=n,i=0|this.h1,o=i,s=0|this.h2,a=s,l=0|this.h3,v=l,w=0|this.h4,m=w;for(let e=0;e<5;e++){const t=4-e,_=f[e],E=p[e],k=c[e],x=u[e],S=h[e],O=d[e];for(let t=0;t<16;t++){const r=y(n+g(e,i,s,l)+b[k[t]]+_,S[t])+w|0;n=w,w=l,l=0|y(s,10),s=i,i=r}for(let e=0;e<16;e++){const n=y(r+g(t,o,a,v)+b[x[e]]+E,O[e])+m|0;r=m,m=v,v=0|y(a,10),a=o,o=n}}this.set(this.h1+s+v|0,this.h2+l+m|0,this.h3+w+r|0,this.h4+n+o|0,this.h0+i+a|0)}roundClean(){b.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}t.RIPEMD160=v,t.ripemd160=(0,i.wrapConstructor)((()=>new v))},1581:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sha224=t.sha256=void 0;const r=n(8001),i=n(4099),o=(e,t,n)=>e&t^e&n^t&n,s=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]),a=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),c=new Uint32Array(64);class u extends r.SHA2{constructor(){super(64,32,8,!1),this.A=0|a[0],this.B=0|a[1],this.C=0|a[2],this.D=0|a[3],this.E=0|a[4],this.F=0|a[5],this.G=0|a[6],this.H=0|a[7]}get(){const{A:e,B:t,C:n,D:r,E:i,F:o,G:s,H:a}=this;return[e,t,n,r,i,o,s,a]}set(e,t,n,r,i,o,s,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)c[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=c[e-15],n=c[e-2],r=(0,i.rotr)(t,7)^(0,i.rotr)(t,18)^t>>>3,o=(0,i.rotr)(n,17)^(0,i.rotr)(n,19)^n>>>10;c[e]=o+c[e-7]+r+c[e-16]|0}let{A:n,B:r,C:a,D:u,E:l,F:h,G:d,H:f}=this;for(let e=0;e<64;e++){const t=f+((0,i.rotr)(l,6)^(0,i.rotr)(l,11)^(0,i.rotr)(l,25))+((p=l)&h^~p&d)+s[e]+c[e]|0,y=((0,i.rotr)(n,2)^(0,i.rotr)(n,13)^(0,i.rotr)(n,22))+o(n,r,a)|0;f=d,d=h,h=l,l=u+t|0,u=a,a=r,r=n,n=t+y|0}var p;n=n+this.A|0,r=r+this.B|0,a=a+this.C|0,u=u+this.D|0,l=l+this.E|0,h=h+this.F|0,d=d+this.G|0,f=f+this.H|0,this.set(n,r,a,u,l,h,d,f)}roundClean(){c.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class l extends u{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}}t.sha256=(0,i.wrapConstructor)((()=>new u)),t.sha224=(0,i.wrapConstructor)((()=>new l))},477:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sha384=t.sha512_256=t.sha512_224=t.sha512=t.SHA512=void 0;const r=n(8001),i=n(3201),o=n(4099),[s,a]=i.default.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((e=>BigInt(e)))),c=new Uint32Array(80),u=new Uint32Array(80);class l extends r.SHA2{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:o,Dh:s,Dl:a,Eh:c,El:u,Fh:l,Fl:h,Gh:d,Gl:f,Hh:p,Hl:y}=this;return[e,t,n,r,i,o,s,a,c,u,l,h,d,f,p,y]}set(e,t,n,r,i,o,s,a,c,u,l,h,d,f,p,y){this.Ah=0|e,this.Al=0|t,this.Bh=0|n,this.Bl=0|r,this.Ch=0|i,this.Cl=0|o,this.Dh=0|s,this.Dl=0|a,this.Eh=0|c,this.El=0|u,this.Fh=0|l,this.Fl=0|h,this.Gh=0|d,this.Gl=0|f,this.Hh=0|p,this.Hl=0|y}process(e,t){for(let n=0;n<16;n++,t+=4)c[n]=e.getUint32(t),u[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|c[e-15],n=0|u[e-15],r=i.default.rotrSH(t,n,1)^i.default.rotrSH(t,n,8)^i.default.shrSH(t,n,7),o=i.default.rotrSL(t,n,1)^i.default.rotrSL(t,n,8)^i.default.shrSL(t,n,7),s=0|c[e-2],a=0|u[e-2],l=i.default.rotrSH(s,a,19)^i.default.rotrBH(s,a,61)^i.default.shrSH(s,a,6),h=i.default.rotrSL(s,a,19)^i.default.rotrBL(s,a,61)^i.default.shrSL(s,a,6),d=i.default.add4L(o,h,u[e-7],u[e-16]),f=i.default.add4H(d,r,l,c[e-7],c[e-16]);c[e]=0|f,u[e]=0|d}let{Ah:n,Al:r,Bh:o,Bl:l,Ch:h,Cl:d,Dh:f,Dl:p,Eh:y,El:g,Fh:b,Fl:v,Gh:w,Gl:m,Hh:_,Hl:E}=this;for(let e=0;e<80;e++){const t=i.default.rotrSH(y,g,14)^i.default.rotrSH(y,g,18)^i.default.rotrBH(y,g,41),k=i.default.rotrSL(y,g,14)^i.default.rotrSL(y,g,18)^i.default.rotrBL(y,g,41),x=y&b^~y&w,S=g&v^~g&m,O=i.default.add5L(E,k,S,a[e],u[e]),C=i.default.add5H(O,_,t,x,s[e],c[e]),A=0|O,T=i.default.rotrSH(n,r,28)^i.default.rotrBH(n,r,34)^i.default.rotrBH(n,r,39),B=i.default.rotrSL(n,r,28)^i.default.rotrBL(n,r,34)^i.default.rotrBL(n,r,39),I=n&o^n&h^o&h,N=r&l^r&d^l&d;_=0|w,E=0|m,w=0|b,m=0|v,b=0|y,v=0|g,({h:y,l:g}=i.default.add(0|f,0|p,0|C,0|A)),f=0|h,p=0|d,h=0|o,d=0|l,o=0|n,l=0|r;const P=i.default.add3L(A,B,N);n=i.default.add3H(P,C,T,I),r=0|P}({h:n,l:r}=i.default.add(0|this.Ah,0|this.Al,0|n,0|r)),({h:o,l}=i.default.add(0|this.Bh,0|this.Bl,0|o,0|l)),({h,l:d}=i.default.add(0|this.Ch,0|this.Cl,0|h,0|d)),({h:f,l:p}=i.default.add(0|this.Dh,0|this.Dl,0|f,0|p)),({h:y,l:g}=i.default.add(0|this.Eh,0|this.El,0|y,0|g)),({h:b,l:v}=i.default.add(0|this.Fh,0|this.Fl,0|b,0|v)),({h:w,l:m}=i.default.add(0|this.Gh,0|this.Gl,0|w,0|m)),({h:_,l:E}=i.default.add(0|this.Hh,0|this.Hl,0|_,0|E)),this.set(n,r,o,l,h,d,f,p,y,g,b,v,w,m,_,E)}roundClean(){c.fill(0),u.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}t.SHA512=l;class h extends l{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}class d extends l{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}class f extends l{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}t.sha512=(0,o.wrapConstructor)((()=>new l)),t.sha512_224=(0,o.wrapConstructor)((()=>new h)),t.sha512_256=(0,o.wrapConstructor)((()=>new d)),t.sha384=(0,o.wrapConstructor)((()=>new f))},4099:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.randomBytes=t.wrapXOFConstructorWithOpts=t.wrapConstructorWithOpts=t.wrapConstructor=t.checkOpts=t.Hash=t.concatBytes=t.toBytes=t.utf8ToBytes=t.asyncLoop=t.nextTick=t.hexToBytes=t.bytesToHex=t.isLE=t.rotr=t.createView=t.u32=t.u8=void 0;const r=n(5990),i=e=>e instanceof Uint8Array;if(t.u8=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),t.u32=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),t.createView=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),t.rotr=(e,t)=>e<<32-t|e>>>t,t.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],!t.isLE)throw new Error("Non little-endian hardware is not supported");const o=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function s(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function a(e){if("string"==typeof e&&(e=s(e)),!i(e))throw new Error("expected Uint8Array, got "+typeof e);return e}t.bytesToHex=function(e){if(!i(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=o[e[n]];return t},t.hexToBytes=function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(t/2);for(let t=0;t<n.length;t++){const r=2*t,i=e.slice(r,r+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");n[t]=o}return n},t.nextTick=async()=>{},t.asyncLoop=async function(e,n,r){let i=Date.now();for(let o=0;o<e;o++){r(o);const e=Date.now()-i;e>=0&&e<n||(await(0,t.nextTick)(),i+=e)}},t.utf8ToBytes=s,t.toBytes=a,t.concatBytes=function(...e){const t=new Uint8Array(e.reduce(((e,t)=>e+t.length),0));let n=0;return e.forEach((e=>{if(!i(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length})),t},t.Hash=class{clone(){return this._cloneInto()}},t.checkOpts=function(e,t){if(void 0!==t&&("object"!=typeof t||(n=t,"[object Object]"!==Object.prototype.toString.call(n)||n.constructor!==Object)))throw new Error("Options should be object or undefined");var n;return Object.assign(e,t)},t.wrapConstructor=function(e){const t=t=>e().update(a(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t},t.wrapConstructorWithOpts=function(e){const t=(t,n)=>e(n).update(a(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t},t.wrapXOFConstructorWithOpts=function(e){const t=(t,n)=>e(n).update(a(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t},t.randomBytes=function(e=32){if(r.crypto&&"function"==typeof r.crypto.getRandomValues)return r.crypto.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}},9890:(e,t,n)=>{"use strict";var r,i=Object.create,o=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty,l=(e,t,n,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let i of a(t))u.call(e,i)||i===n||o(e,i,{get:()=>t[i],enumerable:!(r=s(t,i))||r.enumerable});return e},h=(e,t,n)=>(n=null!=e?i(c(e)):{},l(!t&&e&&e.__esModule?n:o(n,"default",{value:e,enumerable:!0}),e)),d={};((e,t)=>{for(var n in t)o(e,n,{get:t[n],enumerable:!0})})(d,{NDKArticle:()=>ne,NDKDVMJobResult:()=>oe,NDKDVMRequest:()=>re,NDKEvent:()=>X,NDKKind:()=>S,NDKList:()=>se,NDKNip07Signer:()=>ce,NDKNip46Backend:()=>ve,NDKNip46Signer:()=>we,NDKNostrRpc:()=>he,NDKPrivateKeySigner:()=>_e,NDKRelay:()=>P,NDKRelaySet:()=>L,NDKRelayStatus:()=>N,NDKSubscription:()=>M,NDKSubscriptionCacheUsage:()=>q,NDKSubscriptionGroup:()=>D,NDKTranscriptionDVM:()=>ie,NDKUser:()=>W,default:()=>xe,defaultOpts:()=>H,filterFromId:()=>U,mergeEvent:()=>V,mergeFilters:()=>F,relaysFromBech32:()=>K,zapInvoiceFromEvent:()=>ke}),e.exports=(r=d,l(o({},"__esModule",{value:!0}),r));var f=h(n(7820)),p=h(n(2337)),y=h(n(2337)),g=n(2643),b=n(1027),v=h(n(2337)),w=n(2643),m=["wss://nos.lol","wss://relay.nostr.band","wss://relay.f7z.io","wss://relay.damus.io","wss://nostr.mom","wss://no.str.cr"],_=class extends v.default{ndk;zappedEvent;zappedUser;constructor(e){super(),this.ndk=e.ndk,this.zappedEvent=e.zappedEvent,this.zappedUser=e.zappedUser||this.ndk.getUser({hexpubkey:this.zappedEvent.pubkey})}async getZapEndpoint(){let e,t,n,r;if(this.zappedEvent){const n=(await this.zappedEvent.getMatchingTags("zap"))[0];if(n)switch(n[2]){case"lud06":e=n[1];break;case"lud16":t=n[1];break;default:throw new Error(`Unknown zap tag ${n}`)}}if(!this.zappedUser||e||t||(this.zappedUser.profile||await this.zappedUser.fetchProfile(),e=(this.zappedUser.profile||{}).lud06,t=(this.zappedUser.profile||{}).lud16),t){const[e,r]=t.split("@");n=`https://${r}/.well-known/lnurlp/${e}`}else if(e){const{words:t}=b.bech32.decode(e,1e3),r=b.bech32.fromWords(t);n=new TextDecoder("utf-8").decode(r)}if(!n)throw new Error("No zap endpoint found");const i=await fetch(n),o=await i.json();return o?.allowsNostr&&(o?.nostrPubkey||o?.nostrPubKey)&&(r=o.callback),r}async createZapRequest(e,t,n,r){const i=await this.getZapEndpoint();if(!i)throw new Error("No zap endpoint found");if(!this.zappedEvent)throw new Error("No zapped event found");const o=w.nip57.makeZapRequest({profile:this.zappedUser.hexpubkey(),event:null,amount:e,comment:t||"",relays:r??this.relays()});if(this.zappedEvent){const e=this.zappedEvent.tagReference();e&&o.tags.push(e)}o.tags.push(["lnurl",i]);const s=new X(this.ndk,o);n&&(s.tags=s.tags.concat(n)),await s.sign();const a=await s.toNostrEvent(),c=await fetch(`${i}?`+new URLSearchParams({amount:e.toString(),nostr:JSON.stringify(a)}));return(await c.json()).pr}relays(){let e=[];return this.ndk?.pool?.relays&&(e=this.ndk.pool.urls()),e.length||(e=m),e}},E=n(2643);function k(){if(void 0===this.kind)throw new Error("Kind not set");return this.kind>=1e4&&this.kind<2e4}function x(){if(void 0===this.kind)throw new Error("Kind not set");return this.kind>=3e4&&this.kind<4e4}var S=(e=>(e[e.Metadata=0]="Metadata",e[e.Text=1]="Text",e[e.RecommendRelay=2]="RecommendRelay",e[e.Contacts=3]="Contacts",e[e.EncryptedDirectMessage=4]="EncryptedDirectMessage",e[e.EventDeletion=5]="EventDeletion",e[e.Repost=6]="Repost",e[e.Reaction=7]="Reaction",e[e.BadgeAward=8]="BadgeAward",e[e.GenericRepost=16]="GenericRepost",e[e.ChannelCreation=40]="ChannelCreation",e[e.ChannelMetadata=41]="ChannelMetadata",e[e.ChannelMessage=42]="ChannelMessage",e[e.ChannelHideMessage=43]="ChannelHideMessage",e[e.ChannelMuteUser=44]="ChannelMuteUser",e[e.Report=1984]="Report",e[e.ZapRequest=9734]="ZapRequest",e[e.Zap=9735]="Zap",e[e.Highlight=9802]="Highlight",e[e.MuteList=1e4]="MuteList",e[e.PinList=10001]="PinList",e[e.RelayList=10002]="RelayList",e[e.ClientAuth=22242]="ClientAuth",e[e.NostrConnect=24133]="NostrConnect",e[e.CategorizedPeopleList=3e4]="CategorizedPeopleList",e[e.CategorizedBookmarkList=30001]="CategorizedBookmarkList",e[e.CategorizedRelayList=30022]="CategorizedRelayList",e[e.ProfileBadge=30008]="ProfileBadge",e[e.BadgeDefinition=30009]="BadgeDefinition",e[e.MarketStall=30017]="MarketStall",e[e.MarketProduct=30018]="MarketProduct",e[e.Article=30023]="Article",e[e.AppSpecificData=30078]="AppSpecificData",e[e.CategorizedHighlightList=39802]="CategorizedHighlightList",e[e.DVMJobFeedback=65e3]="DVMJobFeedback",e[e.DVMJobResult=65001]="DVMJobResult",e[e.DVMJobRequestTranscription=65002]="DVMJobRequestTranscription",e))(S||{}),O=n(2643),C=h(n(2337)),A=n(2643),T=h(n(7820)),B=h(n(2337)),I=n(2643),N=(n(8e3),(e=>(e[e.CONNECTING=0]="CONNECTING",e[e.CONNECTED=1]="CONNECTED",e[e.DISCONNECTING=2]="DISCONNECTING",e[e.DISCONNECTED=3]="DISCONNECTED",e[e.RECONNECTING=4]="RECONNECTING",e[e.FLAPPING=5]="FLAPPING",e))(N||{})),P=class extends B.default{url;scores;relay;_status;connectedAt;_connectionStats={attempts:0,success:0,durations:[]};complaining=!1;debug;activeSubscriptions=new Set;constructor(e){super(),this.url=e,this.relay=(0,I.relayInit)(e),this.scores=new Map,this._status=3,this.debug=(0,T.default)(`ndk:relay:${e}`),this.relay.on("connect",(()=>{this.updateConnectionStats.connected(),this._status=1,this.emit("connect")})),this.relay.on("disconnect",(()=>{this.updateConnectionStats.disconnected(),1===this._status&&(this._status=3,this.handleReconnection()),this.emit("disconnect")})),this.relay.on("notice",(e=>this.handleNotice(e)))}isFlapping(){const e=this._connectionStats.durations;if(e.length<10)return!1;const t=e.reduce(((e,t)=>e+t),0)/e.length,n=e.map((e=>Math.pow(e-t,2))).reduce(((e,t)=>e+t),0)/e.length;return Math.sqrt(n)<1e3}handleReconnection(){this.isFlapping()&&(this.emit("flapping",this,this._connectionStats),this._status=5),this.connectedAt&&Date.now()-this.connectedAt<5e3?setTimeout((()=>this.connect()),6e4):this.connect()}get status(){return this._status}async connect(){try{this.updateConnectionStats.attempt(),this._status=0,await this.relay.connect()}catch(e){throw this.debug("Failed to connect",e),this._status=3,e}}disconnect(){this._status=2,this.relay.close()}async handleNotice(e){(e.includes("oo many")||e.includes("aximum"))&&(this.disconnect(),setTimeout((()=>this.connect()),2e3),this.debug(this.relay.url,"Relay complaining?",e)),this.emit("notice",this,e)}subscribe(e){const{filters:t}=e,n=this.relay.sub(t,{id:e.subId});this.debug(`Subscribed to ${JSON.stringify(t)}`),n.on("event",(t=>{const n=new X(void 0,t);n.relay=this,e.eventReceived(n,this)})),n.on("eose",(()=>{e.eoseReceived(this)}));const r=n.unsub;return n.unsub=()=>{this.debug(`Unsubscribing from ${JSON.stringify(t)}`),this.activeSubscriptions.delete(e),r()},this.activeSubscriptions.add(e),e.on("close",(()=>{this.activeSubscriptions.delete(e)})),n}async publish(e,t=2500){return 1===this.status?this.publishEvent(e,t):(this.once("connect",(()=>{this.publishEvent(e,t)})),!0)}async publishEvent(e,t){const n=await e.toNostrEvent(),r=this.relay.publish(n);let i;const o=new Promise(((t,n)=>{r.then((()=>{clearTimeout(i),this.emit("published",e),t(!0)})).catch((t=>{clearTimeout(i),this.debug("Publish failed",t,e.id),this.emit("publish:failed",e,t),n(t)}))}));if(!t)return o;const s=new Promise(((n,r)=>{i=setTimeout((()=>{this.debug("Publish timed out",e.rawEvent()),this.emit("publish:failed",e,"Timeout"),r(new Error("Publish operation timed out"))}),t)}));return Promise.race([o,s])}scoreSlowerEvent(e){}updateConnectionStats={connected:()=>{this._connectionStats.success++,this._connectionStats.connectedAt=Date.now()},disconnected:()=>{this._connectionStats.connectedAt&&(this._connectionStats.durations.push(Date.now()-this._connectionStats.connectedAt),this._connectionStats.durations.length>100&&this._connectionStats.durations.shift()),this._connectionStats.connectedAt=void 0},attempt:()=>{this._connectionStats.attempts++}};get connectionStats(){return this._connectionStats}tagReference(e){const t=["r",this.relay.url];return e&&t.push(e),t}},R=n(1581),j=n(4099),L=class{relays;debug;ndk;constructor(e,t){this.relays=e,this.ndk=t,this.debug=t.debug.extend("relayset")}addRelay(e){this.relays.add(e)}static fromRelayUrls(e,t){const n=new Set;for(const r of e){const e=t.pool.relays.get(r);e&&n.add(e)}return new L(new Set(n),t)}subscribeOnRelay(e,t){const n=e.subscribe(t);t.relaySubscriptions.set(e,n)}getId(){const e=Array.from(this.relays).map((e=>e.url)).sort().join(",");return(0,j.bytesToHex)((0,R.sha256)(e))}subscribe(e){const t=e.groupableId(),n=`${this.getId()}:${t}`;if(!t)return this.executeSubscription(e),e;const r=this.ndk.delayedSubscriptions.get(n);return r?r.push(e):(setTimeout((()=>{this.executeDelayedSubscription(n)}),e.opts.groupableDelay),this.ndk.delayedSubscriptions.set(n,[e])),e}executeDelayedSubscription(e){const t=this.ndk.delayedSubscriptions.get(e);this.ndk.delayedSubscriptions.delete(e),t&&(t.length>1?this.executeSubscriptions(t):this.executeSubscription(t[0]))}executeSubscriptions(e){const t=e[0].ndk,n=new D(t,e);this.executeSubscription(n)}executeSubscription(e){this.debug("subscribing",{filters:e.filters});for(const t of this.relays)if(1===t.status)this.subscribeOnRelay(t,e);else{const n=()=>{this.debug("new relay coming online for active subscription",{relay:t.url,filters:e.filters}),this.subscribeOnRelay(t,e)};t.once("connect",n),e.once("close",(()=>{t.removeListener("connect",n)}))}return e}async publish(e,t){const n=new Set,r=Array.from(this.relays).map((r=>new Promise((i=>{r.publish(e,t).then((()=>{n.add(r),i()})).catch((e=>{this.debug("error publishing to relay",{relay:r.url,err:e}),i()}))}))));if(await Promise.all(r),0===n.size)throw new Error("No relay was able to receive the event");return n}size(){return this.relays.size}},q=(e=>(e.ONLY_CACHE="ONLY_CACHE",e.CACHE_FIRST="CACHE_FIRST",e.PARALLEL="PARALLEL",e.ONLY_RELAY="ONLY_RELAY",e))(q||{}),H={closeOnEose:!0,cacheUsage:"CACHE_FIRST",groupable:!0,groupableDelay:100},M=class extends C.default{subId;filters;opts;relaySet;ndk;relaySubscriptions;debug;eventFirstSeen=new Map;eosesSeen=new Set;eventsPerRelay=new Map;constructor(e,t,n,r,i){if(super(),this.ndk=e,this.opts={...H,...n||{}},this.filters=t instanceof Array?t:[t],this.subId=i||n?.subId||function(e){const t=Object.keys(e)||[],n=[];for(const r of t)if("kinds"===r){const t=[r,e.kinds.join(",")];n.push(t.join(":"))}else n.push(r);return n.push(Math.floor(999999999*Math.random()).toString()),n.join("-")}(this.filters[0]),this.relaySet=r,this.relaySubscriptions=new Map,this.debug=e.debug.extend(`subscription:${this.subId}`),"ONLY_CACHE"===this.opts.cacheUsage&&!this.opts.closeOnEose)throw new Error("Cannot use cache-only options with a persistent subscription")}get filter(){return this.filters[0]}groupableId(){if(!this.opts?.groupable||this.filters.length>1)return null;const e=this.filters[0],t=(e.kinds?.length||0)>0,n=!e.since&&!e.until,r=!e.limit;if(t&&n&&r){let t=e.kinds.join(",");return t+=`-${Object.keys(e||{}).sort().join("-")}`,t}return null}shouldQueryCache(){return"ONLY_RELAY"!==this.opts?.cacheUsage}shouldQueryRelays(){return"ONLY_CACHE"!==this.opts?.cacheUsage}shouldWaitForCache(){return this.opts.closeOnEose&&!!this.ndk.cacheAdapter?.locking&&"PARALLEL"!==this.opts.cacheUsage}async start(){let e;this.shouldQueryCache()&&(e=this.startWithCache(),this.shouldWaitForCache()&&(await e,this.filter.ids&&function(e){const t=e.filter.ids;return!!t&&t.length===e.eventFirstSeen.size}(this)))?this.emit("eose",this):this.shouldQueryRelays()?this.startWithRelaySet():this.emit("eose",this)}stop(){this.relaySubscriptions.forEach((e=>e.unsub())),this.relaySubscriptions.clear(),this.emit("close",this)}async startWithCache(){if(this.ndk.cacheAdapter?.query){const e=this.ndk.cacheAdapter.query(this);this.ndk.cacheAdapter.locking&&await e}}startWithRelaySet(){this.relaySet||(this.relaySet=function(e,t){const n=new Set;return e.pool?.relays.forEach((t=>{t.complaining?e.debug(`Relay ${t.url} is complaining, not adding to set`):n.add(t)})),new L(n,e)}(this.ndk,this.filters[0])),this.relaySet&&this.relaySet.subscribe(this)}eventReceived(e,t,n=!1){if(!n&&t){let n=this.eventsPerRelay.get(t);if(n||(n=new Set,this.eventsPerRelay.set(t,n)),n.add(e.id),this.eventFirstSeen.has(e.id)){const n=Date.now()-(this.eventFirstSeen.get(e.id)||0);return t.scoreSlowerEvent(n),void this.emit("event:dup",e,t,n,this)}this.ndk.cacheAdapter&&this.ndk.cacheAdapter.setEvent(e,this.filters[0],t),this.eventFirstSeen.set(`${e.id}`,Date.now())}else this.eventFirstSeen.set(`${e.id}`,0);this.emit("event",e,t,this)}eoseTimeout;eoseReceived(e){this.opts?.closeOnEose&&(this.relaySubscriptions.get(e)?.unsub(),this.relaySubscriptions.delete(e),0===this.relaySubscriptions.size&&this.emit("close",this)),this.eosesSeen.add(e),this.eosesSeen.size===this.relaySet?.size()?this.emit("eose"):(this.eoseTimeout&&clearTimeout(this.eoseTimeout),this.eoseTimeout=setTimeout((()=>{this.emit("eose")}),500))}},D=class extends M{subscriptions;constructor(e,t){const n=e.debug.extend("subscription-group");super(e,F(t.map((e=>e.filters[0]))),t[0].opts,t[0].relaySet),this.subscriptions=t,n("merged filters",{count:t.length,mergedFilters:this.filters[0]}),this.on("event",this.forwardEvent),this.on("event:dup",this.forwardEventDup),this.on("eose",this.forwardEose),this.on("close",this.forwardClose)}isEventForSubscription(e,t){const{filters:n}=t;return!!n&&(0,A.matchFilter)(n[0],e.rawEvent())}forwardEvent(e,t){for(const n of this.subscriptions)this.isEventForSubscription(e,n)&&n.emit("event",e,t,n)}forwardEventDup(e,t,n){for(const r of this.subscriptions)this.isEventForSubscription(e,r)&&r.emit("event:dup",e,t,n,r)}forwardEose(){for(const e of this.subscriptions)e.emit("eose",e)}forwardClose(){for(const e of this.subscriptions)e.emit("close",e)}};function F(e){const t={};return e.forEach((e=>{Object.entries(e).forEach((([e,n])=>{Array.isArray(n)?void 0===t[e]?t[e]=[...n]:t[e]=Array.from(new Set([...t[e],...n])):t[e]=n}))})),t}function U(e){let t;try{switch(t=A.nip19.decode(e),t.type){case"nevent":return{ids:[t.data.id]};case"note":return{ids:[t.data]};case"naddr":return{authors:[t.data.pubkey],"#d":[t.data.identifier],kinds:[t.data.kind]}}}catch(e){}return{ids:[e]}}function K(e){try{const t=A.nip19.decode(e);if(["naddr","nevent"].includes(t?.type)){const e=t.data;if(e?.relays)return e.relays.map((e=>new P(e)))}}catch(e){}return[]}var z=n(2643);async function $(){if(!this.ndk)throw new Error("NDK not set");const e=await this.ndk.fetchEvents({kinds:[3],authors:[this.hexpubkey()]});if(e){const t=new Set;return e.forEach((e=>{e.tags.forEach((e=>{if("p"===e[0])try{const n=z.nip19.npubEncode(e[1]);t.add(n)}catch(e){}}))})),[...t].reduce(((e,t)=>{const n=new W({npub:t});return n.ndk=this.ndk,e.add(n),e}),new Set)}return new Set}function V(e,t){const n=JSON.parse(e.content);return Object.keys(n).forEach((e=>{switch(e){case"name":t.name=n.name;break;case"display_name":case"displayName":t.displayName=n.displayName||n.display_name;break;case"image":case"picture":t.image=n.image||n.picture;break;case"banner":t.banner=n.banner;break;case"bio":t.bio=n.bio;break;case"nip05":t.nip05=n.nip05;break;case"lud06":t.lud06=n.lud06;break;case"lud16":t.lud16=n.lud16;break;case"about":t.about=n.about;break;case"zapService":t.zapService=n.zapService;break;case"website":t.website=n.website;break;default:t[e]=n[e]}})),t}var W=class{ndk;profile;npub="";relayUrls=[];constructor(e){e.npub&&(this.npub=e.npub),e.hexpubkey&&(this.npub=O.nip19.npubEncode(e.hexpubkey)),e.relayUrls&&(this.relayUrls=e.relayUrls)}static async fromNip05(e){const t=await O.nip05.queryProfile(e);if(t)return new W({hexpubkey:t.pubkey,relayUrls:t.relays})}hexpubkey(){return O.nip19.decode(this.npub).data}async fetchProfile(e){if(!this.ndk)throw new Error("NDK not set");this.profile||(this.profile={});let t=null;return!e&&this.ndk.cacheAdapter&&this.ndk.cacheAdapter.locking&&(t=await this.ndk.fetchEvents({kinds:[0],authors:[this.hexpubkey()]},{cacheUsage:"ONLY_CACHE",closeOnEose:!0,groupable:!1}),e={cacheUsage:"ONLY_RELAY",closeOnEose:!0}),t&&0!==t.size||(t=await this.ndk.fetchEvents({kinds:[0],authors:[this.hexpubkey()]},e)),t&&Array.from(t).sort(((e,t)=>e.created_at-t.created_at)).forEach((e=>{try{this.profile=V(e,this.profile)}catch(e){}})),t}follows=$.bind(this);async relayList(){if(!this.ndk)throw new Error("NDK not set");return await this.ndk.fetchEvents({kinds:[10002],authors:[this.hexpubkey()]})||new Set}tagReference(){return["p",this.hexpubkey()]}async publish(){if(!this.ndk)throw new Error("No NDK instance found");this.ndk.assertSigner();const e=new X(this.ndk,{kind:0,content:JSON.stringify(this.profile)});await e.publish()}async follow(e,t){if(!this.ndk)throw new Error("No NDK instance found");if(this.ndk.assertSigner(),t||(t=await this.follows()),t.has(e))return!1;t.add(e);const n=new X(this.ndk,{kind:3});for(const e of t)n.tag(e);return await n.publish(),!0}};async function G(e,t){if(!t){if(!this.ndk)throw new Error("No signer available");await this.ndk.assertSigner(),t=this.ndk.signer}if(!e){const t=this.getMatchingTags("p");if(1!==t.length)throw new Error("No recipient could be determined and no explicit recipient was provided");(e=new W({hexpubkey:t[0][1]})).ndk=this.ndk}this.content=await t.encrypt(e,this.content)}async function Z(e,t){if(!t){if(!this.ndk)throw new Error("No signer available");await this.ndk.assertSigner(),t=this.ndk.signer}e||(e=this.author),this.content=await t.decrypt(e,this.content)}var J=n(2643);function Y(){return this.isParamReplaceable()?J.nip19.naddrEncode({kind:this.kind,pubkey:this.pubkey,identifier:this.replaceableDTag()}):J.nip19.noteEncode(this.tagId())}async function Q(e=!0,t){if(!t){if(!this.ndk)throw new Error("No NDK instance found");this.ndk.assertSigner(),t=this.ndk.signer}if(!t)throw new Error("No signer available");const n=await t.user(),r=new X(this.ndk,{kind:(i=this,1===i.kind?6:16),content:"",pubkey:n.hexpubkey()});var i;return r.tag(this),16===r.kind&&r.tags.push(["k",`${this.kind}`]),await r.sign(t),e&&await r.publish(),r}var X=class extends y.default{ndk;created_at;content="";tags=[];kind;id="";sig;pubkey="";relay;constructor(e,t){super(),this.ndk=e,this.created_at=t?.created_at,this.content=t?.content||"",this.tags=t?.tags||[],this.id=t?.id||"",this.sig=t?.sig,this.pubkey=t?.pubkey||"",this.kind=t?.kind}rawEvent(){return{created_at:this.created_at,content:this.content,tags:this.tags,kind:this.kind,pubkey:this.pubkey,id:this.id,sig:this.sig}}set author(e){this.pubkey=e.hexpubkey()}get author(){const e=new W({hexpubkey:this.pubkey});return e.ndk=this.ndk,e}tag(e,t){const n=e.tagReference();if(t&&n.push(t),this.tags.push(n),e instanceof X){const t=e.author;t&&this.pubkey!==t.hexpubkey()&&this.tag(t);for(const t of e.getMatchingTags("p"))t[1]!==this.pubkey&&(this.tags.find((e=>"p"===e[0]&&e[1]===t[1]))||this.tags.push(["p",t[1]]))}}async toNostrEvent(e){if(!e&&""===this.pubkey){const e=await(this.ndk?.signer?.user());this.pubkey=e?.hexpubkey()||""}this.created_at||(this.created_at=Math.floor(Date.now()/1e3));const t=this.rawEvent(),{content:n,tags:r}=this.generateTags();t.content=n||"",t.tags=r;try{this.id=(0,g.getEventHash)(t)}catch(e){}return this.id&&(t.id=this.id),this.sig&&(t.sig=this.sig),t}isReplaceable=k.bind(this);isParamReplaceable=x.bind(this);encode=Y.bind(this);encrypt=G.bind(this);decrypt=Z.bind(this);getMatchingTags(e){return this.tags.filter((t=>t[0]===e))}tagValue(e){const t=this.getMatchingTags(e);if(0!==t.length)return t[0][1]}removeTag(e){this.tags=this.tags.filter((t=>t[0]!==e))}async sign(e){e||(this.ndk?.assertSigner(),e=this.ndk.signer),await this.generateTags(),this.isReplaceable()&&(this.created_at=Math.floor(Date.now()/1e3));const t=await this.toNostrEvent();return this.sig=await e.sign(t),this.sig}async publish(e,t){if(this.sig||await this.sign(),!this.ndk)throw new Error("NDKEvent must be associated with an NDK instance to publish");return this.ndk.publish(this,e,t)}generateTags(){let e=[];const t=function(e,t=[]){return{content:e=e.replace(/(@|nostr:)(npub|nprofile|note|nevent)[a-zA-Z0-9]+/g,(e=>{try{const n=e.split(/(@|nostr:)/)[2],{type:r,data:i}=E.nip19.decode(n);let o;switch(r){case"npub":o=["p",i];break;case"nprofile":o=["p",i.pubkey];break;case"nevent":o=["e",i.id];break;case"note":o=["e",i];break;default:return e}return t.find((e=>e[0]===o[0]&&e[1]===o[1]))||t.push(o),`nostr:${n}`}catch(t){return e}})),tags:t}}(this.content,this.tags),n=t.content;if(e=t.tags,this.kind&&this.kind>=3e4&&this.kind<=4e4&&!this.getMatchingTags("d")[0]){const t=[...Array(16)].map((()=>Math.random().toString(36)[2])).join("");e.push(["d",t])}return{content:n||"",tags:e}}replaceableDTag(){if(this.kind&&this.kind>=3e4&&this.kind<=4e4){const e=this.getMatchingTags("d")[0];return e?e[1]:""}throw new Error("Event is not a parameterized replaceable event")}tagId(){if(this.kind&&this.kind>=3e4&&this.kind<=4e4){const e=this.replaceableDTag();return`${this.kind}:${this.pubkey}:${e}`}return this.id}tagReference(){return this.isParamReplaceable()?["a",this.tagId()]:["e",this.tagId()]}filter(){return this.isParamReplaceable()?{"#a":[this.tagId()]}:{"#e":[this.tagId()]}}async zap(e,t,n){if(!this.ndk)throw new Error("No NDK instance found");this.ndk.assertSigner();const r=new _({ndk:this.ndk,zappedEvent:this});return await r.createZapRequest(e,t,n)}async delete(e){if(!this.ndk)throw new Error("No NDK instance found");this.ndk.assertSigner();const t=new X(this.ndk,{kind:5,content:e||""});return t.tag(this),await t.publish(),t}repost=Q.bind(this)},ee=h(n(2337)),te=class extends ee.default{relays=new Map;debug;temporaryRelayTimers=new Map;constructor(e=[],t){super(),this.debug=t.debug.extend("pool");for(const t of e){const e=new P(t);this.addRelay(e,!1)}}useTemporaryRelay(e,t=6e5){const n=this.relays.has(e.url);n||this.addRelay(e);const r=this.temporaryRelayTimers.get(e.url);if(r&&clearTimeout(r),!n||r){const n=setTimeout((()=>{this.removeRelay(e.url)}),t);this.temporaryRelayTimers.set(e.url,n)}}addRelay(e,t=!0){const n=e.url;e.on("notice",((e,t)=>this.emit("notice",e,t))),e.on("connect",(()=>this.handleRelayConnect(n))),e.on("disconnect",(()=>this.emit("relay:disconnect",e))),e.on("flapping",(()=>this.handleFlapping(e))),this.relays.set(n,e),t&&e.connect()}removeRelay(e){const t=this.relays.get(e);if(t)return t.disconnect(),this.relays.delete(e),this.emit("relay:disconnect",t),!0;const n=this.temporaryRelayTimers.get(e);return n&&(clearTimeout(n),this.temporaryRelayTimers.delete(e)),!1}handleRelayConnect(e){this.debug(`Relay ${e} connected`),this.emit("relay:connect",this.relays.get(e)),this.stats().connected===this.relays.size&&this.emit("connect")}async connect(e){const t=[];this.debug(`Connecting to ${this.relays.size} relays${e?`, timeout ${e}...`:""}`);for(const n of this.relays.values())if(e){const r=new Promise(((t,n)=>{setTimeout((()=>n(`Timed out after ${e}ms`)),e)}));t.push(Promise.race([n.connect(),r]).catch((e=>{this.debug(`Failed to connect to relay ${n.url}: ${e}`)})))}else t.push(n.connect());e&&setTimeout((()=>{const e=this.stats().connected===this.relays.size,t=this.stats().connected>0;!e&&t&&this.emit("connect")}),e),await Promise.all(t)}handleFlapping(e){this.debug(`Relay ${e.url} is flapping`),this.relays.delete(e.url),this.emit("flapping",e)}size(){return this.relays.size}stats(){const e={total:0,connected:0,disconnected:0,connecting:0};for(const t of this.relays.values())e.total++,1===t.status?e.connected++:3===t.status?e.disconnected++:0===t.status&&e.connecting++;return e}connectedRelays(){return Array.from(this.relays.values()).filter((e=>1===e.status))}urls(){return Array.from(this.relays.keys())}},ne=class extends X{constructor(e,t){super(e,t),this.kind=30023}static from(e){return new ne(e.ndk,e.rawEvent())}get title(){return this.tagValue("title")}set title(e){e?this.tags.push(["title",e]):this.removeTag("title")}get published_at(){const e=this.tagValue("published_at");if(e)return parseInt(e)}set published_at(e){this.removeTag("published_at"),void 0!==e&&this.tags.push(["published_at",e.toString()])}generateTags(){return super.generateTags(),this.published_at||(this.published_at=this.created_at),super.generateTags()}get url(){return this.tagValue("url")}set url(e){e?this.tags.push(["url",e]):this.removeTag("url")}},re=class extends X{constructor(e,t){super(e,t),e&&this.tags.push(["relays",...e.pool.urls()])}static from(e){return new re(e.ndk,e.rawEvent())}createResult(e){const t=new oe(this.ndk,e);return t.jobRequest=this,t}set bid(e){void 0===e?this.removeTag("bid"):this.tags.push(["bid",e.toString()])}get bid(){const e=this.tagValue("bid");if(void 0!==e)return parseInt(e)}addInput(...e){this.tags.push(["i",...e])}addParam(...e){this.tags.push(["param",...e])}set output(e){void 0===e?this.removeTag("output"):("string"==typeof e&&(e=[e]),this.tags.push(["output",...e]))}get output(){const e=this.getMatchingTags("output")[0];return e?e.slice(1):void 0}},ie=class extends re{constructor(e,t){super(e,t),this.kind=65002}static from(e){return new ie(e.ndk,e.rawEvent())}get url(){const e=this.getMatchingTags("i");if(1===e.length)return e[0][1]}get title(){return this.tagValue("title")}set title(e){this.removeTag("title"),e&&this.tags.push(["title",e])}get image(){return this.tagValue("image")}set image(e){this.removeTag("image"),e&&this.tags.push(["image",e])}},oe=class extends X{constructor(e,t){super(e,t),this.kind=65001}static from(e){return new oe(e.ndk,e.rawEvent())}set result(e){this.content=void 0===e?"":e}get result(){if(""!==this.content)return this.content}set status(e){this.removeTag("status"),void 0!==e&&this.tags.push(["status",e])}get status(){return this.tagValue("status")}set jobRequest(e){this.removeTag("request"),e&&(this.tags.push(["request",JSON.stringify(e.rawEvent())]),this.tag(e))}get jobRequest(){const e=this.tagValue("request");if(void 0!==e)return new X(this.ndk,JSON.parse(e))}},se=class extends X{_encryptedTags;encryptedTagsLength;constructor(e,t){super(e,t),this.kind||(this.kind=30001)}static from(e){return new se(e.ndk,e.rawEvent())}get name(){return this.tagValue("name")??this.tagValue("d")}set name(e){if(this.removeTag("name"),!e)throw new Error("Name cannot be empty");this.tags.push(["name",e])}get description(){return this.tagValue("description")}set description(e){e?this.tags.push(["description",e]):this.removeTag("description")}isEncryptedTagsCacheValid(){return!(!this._encryptedTags||this.encryptedTagsLength!==this.content.length)}async encryptedTags(e=!0){if(e&&this.isEncryptedTagsCacheValid())return this._encryptedTags;if(!this.ndk)throw new Error("NDK instance not set");if(!this.ndk.signer)throw new Error("NDK signer not set");const t=await this.ndk.signer.user();try{if(this.content.length>0)try{const e=await this.ndk.signer.decrypt(t,this.content),n=JSON.parse(e);return n&&n[0]?(this.encryptedTagsLength=this.content.length,this._encryptedTags=n):(this.encryptedTagsLength=this.content.length,this._encryptedTags=[])}catch(e){console.log(`error decrypting ${this.content}`)}}catch(e){}return[]}validateTag(e){return!0}get items(){return this.tags.filter((e=>!["d","name","description"].includes(e[0])))}async addItem(e,t=void 0,n=!1){if(!this.ndk)throw new Error("NDK instance not set");if(!this.ndk.signer)throw new Error("NDK signer not set");let r;if(e instanceof X)r=e.tagReference();else if(e instanceof W)r=e.tagReference();else if(e instanceof P)r=e.tagReference();else{if(!Array.isArray(e))throw new Error("Invalid object type");r=e}if(t&&r.push(t),n){const e=await this.ndk.signer.user(),t=await this.encryptedTags();t.push(r),this._encryptedTags=t,this.encryptedTagsLength=this.content.length,this.content=JSON.stringify(t),await this.encrypt(e)}else this.tags.push(r);this.created_at=Math.floor(Date.now()/1e3),this.emit("change")}async removeItem(e,t){if(!this.ndk)throw new Error("NDK instance not set");if(!this.ndk.signer)throw new Error("NDK signer not set");if(t){const t=await this.ndk.signer.user(),n=await this.encryptedTags();n.splice(e,1),this._encryptedTags=n,this.encryptedTagsLength=this.content.length,this.content=JSON.stringify(n),await this.encrypt(t)}else this.tags.splice(e,1);return this.created_at=Math.floor(Date.now()/1e3),this.emit("change"),this}},ae=h(n(7820)),ce=class{_userPromise;nip04Queue=[];nip04Processing=!1;debug;constructor(){if(!window.nostr)throw new Error("NIP-07 extension not available");this.debug=(0,ae.default)("ndk:nip07")}async blockUntilReady(){const e=await(window.nostr?.getPublicKey());if(!e)throw new Error("User rejected access");return new W({hexpubkey:e})}async user(){return this._userPromise||(this._userPromise=this.blockUntilReady()),this._userPromise}async sign(e){if(!window.nostr)throw new Error("NIP-07 extension not available");return(await window.nostr.signEvent(e)).sig}async encrypt(e,t){if(!window.nostr)throw new Error("NIP-07 extension not available");const n=e.hexpubkey();return this.queueNip04("encrypt",n,t)}async decrypt(e,t){if(!window.nostr)throw new Error("NIP-07 extension not available");const n=e.hexpubkey();return this.queueNip04("decrypt",n,t)}async queueNip04(e,t,n){return new Promise(((r,i)=>{this.nip04Queue.push({type:e,counterpartyHexpubkey:t,value:n,resolve:r,reject:i}),this.nip04Processing||this.processNip04Queue()}))}async processNip04Queue(e,t=0){if(!e&&0===this.nip04Queue.length)return void(this.nip04Processing=!1);this.nip04Processing=!0;const{type:n,counterpartyHexpubkey:r,value:i,resolve:o,reject:s}=e||this.nip04Queue.shift();this.debug("Processing encryption queue item",{type:n,counterpartyHexpubkey:r,value:i});try{let e;e="encrypt"===n?await window.nostr.nip04.encrypt(r,i):await window.nostr.nip04.decrypt(r,i),o(e)}catch(o){if(o.message&&o.message.includes("call already executing")&&t<5)return this.debug("Retrying encryption queue item",{type:n,counterpartyHexpubkey:r,value:i,retries:t}),void setTimeout((()=>{this.processNip04Queue(e,t+1)}),50*t);s(o)}this.processNip04Queue()}},ue=n(2643),le=h(n(2337)),he=class extends le.default{ndk;signer;debug;constructor(e,t,n){super(),this.ndk=e,this.signer=t,this.debug=n.extend("rpc")}async subscribe(e){const t=this.ndk.subscribe(e,{closeOnEose:!1});return t.on("event",(async e=>{try{const t=await this.parseEvent(e);t.method?this.emit("request",t):this.emit(`response-${t.id}`,t)}catch(t){this.debug("error parsing event",t,e)}})),new Promise(((e,n)=>{t.on("eose",(()=>e(t)))}))}async parseEvent(e){const t=this.ndk.getUser({hexpubkey:e.pubkey});t.ndk=this.ndk;const n=await this.signer.decrypt(t,e.content),r=JSON.parse(n),{id:i,method:o,params:s,result:a,error:c}=r;return o?{id:i,pubkey:e.pubkey,method:o,params:s,event:e}:{id:i,result:a,error:c,event:e}}async sendResponse(e,t,n,r=24133,i){const o={id:e,result:n};i&&(o.error=i);const s=await this.signer.user(),a=this.ndk.getUser({hexpubkey:t}),c=new X(this.ndk,{kind:r,content:JSON.stringify(o),tags:[["p",t]],pubkey:s.hexpubkey()});c.content=await this.signer.encrypt(a,c.content),await c.sign(this.signer),await this.ndk.publish(c)}async sendRequest(e,t,n=[],r=24133,i){const o=Math.random().toString(36).substring(7),s=await this.signer.user(),a=this.ndk.getUser({hexpubkey:e}),c={id:o,method:t,params:n},u=new Promise((e=>{i&&this.once(`response-${o}`,i)})),l=new X(this.ndk,{kind:r,content:JSON.stringify(c),tags:[["p",e]],pubkey:s.hexpubkey()});return l.content=await this.signer.encrypt(a,l.content),await l.sign(this.signer),this.debug("sending request to",e),await this.ndk.publish(l),u}},de=class{async handle(e,t,n){const[r,i]=n,o=e.debug.extend("connect");if(o(`connection request from ${r}`),i&&e.applyToken&&(o("applying token"),await e.applyToken(r,i)),await e.pubkeyAllowed(r,"connect",i))return o(`connection request from ${r} allowed`),"ack";o(`connection request from ${r} rejected`)}},fe=class{async handle(e,t,n){const r=Object.keys(e.handlers);return JSON.stringify(r)}},pe=class{async handle(e,t,n){return e.localUser?.hexpubkey()}},ye=class{async handle(e,t,n){const[r,i]=n,o=new W({hexpubkey:r}),s=await e.decrypt(t,o,i);return JSON.stringify([s])}},ge=class{async handle(e,t,n){const[r,i]=n,o=new W({hexpubkey:r});return await e.encrypt(t,o,i)}},be=class{async handle(e,t,n){const r=await e.signEvent(t,n);if(r)return JSON.stringify(await r.toNostrEvent())}},ve=class{ndk;signer;localUser;debug;rpc;permitCallback;constructor(e,t,n){this.ndk=e,this.signer=new _e(t),this.debug=e.debug.extend("nip46:backend"),this.rpc=new he(e,this.signer,this.debug),this.permitCallback=n}async start(){this.localUser=await this.signer.user(),this.ndk.subscribe({kinds:[24133],"#p":[this.localUser.hexpubkey()]},{closeOnEose:!1}).on("event",(e=>this.handleIncomingEvent(e)))}handlers={connect:new de,sign_event:new be,nip04_encrypt:new ge,nip04_decrypt:new ye,get_public_key:new pe,describe:new fe};setStrategy(e,t){this.handlers[e]=t}async applyToken(e,t){throw new Error("connection token not supported")}async handleIncomingEvent(e){const{id:t,method:n,params:r}=await this.rpc.parseEvent(e),i=e.pubkey;let o;if(this.debug("incoming event",{id:t,method:n,params:r}),!(0,ue.verifySignature)(e.rawEvent()))return void this.debug("invalid signature",e.rawEvent());const s=this.handlers[n];if(s)try{o=await s.handle(this,i,r)}catch(e){this.debug("error handling event",e,{id:t,method:n,params:r}),this.rpc.sendResponse(t,i,"error",void 0,e.message)}else this.debug("unsupported method",{method:n,params:r});o?(this.debug(`sending response to ${i}`,o),this.rpc.sendResponse(t,i,o)):this.rpc.sendResponse(t,i,"error",void 0,"Not authorized")}async decrypt(e,t,n){if(await this.pubkeyAllowed(e,"decrypt",n))return await this.signer.decrypt(t,n);this.debug(`decrypt request from ${e} rejected`)}async encrypt(e,t,n){if(await this.pubkeyAllowed(e,"encrypt",n))return await this.signer.encrypt(t,n);this.debug(`encrypt request from ${e} rejected`)}async signEvent(e,t){const[n]=t;this.debug(`sign event request from ${e}`);const r=new X(this.ndk,JSON.parse(n));if(this.debug("event to sign",r.rawEvent()),await this.pubkeyAllowed(e,"sign_event",r))return this.debug(`sign event request from ${e} allowed`),await r.sign(this.signer),r;this.debug(`sign event request from ${e} rejected`)}async pubkeyAllowed(e,t,n){return this.permitCallback(e,t,n)}},we=class{ndk;remoteUser;remotePubkey;token;localSigner;rpc;debug;constructor(e,t,n){let r,i;if(t.includes("#")){const e=t.split("#");r=new W({npub:e[0]}).hexpubkey(),i=e[1]}else r=t.startsWith("npub")?new W({npub:t}).hexpubkey():t;this.ndk=e,this.remotePubkey=r,this.token=i,this.debug=e.debug.extend("nip46:signer"),this.remoteUser=new W({hexpubkey:r}),this.localSigner=n||_e.generate(),this.rpc=new he(e,this.localSigner,this.debug)}async user(){return this.remoteUser}async blockUntilReady(){const e=await this.localSigner.user(),t=this.ndk.getUser({npub:e.npub});return await this.rpc.subscribe({kinds:[24133],"#p":[e.hexpubkey()]}),new Promise(((n,r)=>{setTimeout((()=>{const i=[e.hexpubkey()];this.token&&i.push(this.token),this.rpc.sendRequest(this.remotePubkey,"connect",i,24133,(e=>{"ack"===e.result?n(t):r(e.error)}))}),100)}))}async encrypt(e,t){return this.debug("asking for encryption"),new Promise(((n,r)=>{this.rpc.sendRequest(this.remotePubkey,"nip04_encrypt",[e.hexpubkey(),t],24133,(e=>{e.error?r(e.error):n(e.result)}))}))}async decrypt(e,t){return this.debug("asking for decryption"),new Promise(((n,r)=>{this.rpc.sendRequest(this.remotePubkey,"nip04_decrypt",[e.hexpubkey(),t],24133,(e=>{if(e.error)r(e.error);else{const t=JSON.parse(e.result);n(t[0])}}))}))}async sign(e){return this.debug("asking for a signature"),new Promise(((t,n)=>{this.rpc.sendRequest(this.remotePubkey,"sign_event",[JSON.stringify(e)],24133,(e=>{if(this.debug("got a response",e),e.error)n(e.error);else{const n=JSON.parse(e.result);t(n.sig)}}))}))}},me=n(2643),_e=class{_user;privateKey;constructor(e){e&&(this.privateKey=e,this._user=new W({hexpubkey:(0,me.getPublicKey)(this.privateKey)}))}static generate(){const e=(0,me.generatePrivateKey)();return new _e(e)}async blockUntilReady(){if(!this._user)throw new Error("NDKUser not initialized");return this._user}async user(){return await this.blockUntilReady(),this._user}async sign(e){if(!this.privateKey)throw Error("Attempted to sign without a private key");return(0,me.getSignature)(e,this.privateKey)}async encrypt(e,t){if(!this.privateKey)throw Error("Attempted to encrypt without a private key");const n=e.hexpubkey();return await me.nip04.encrypt(this.privateKey,n,t)}async decrypt(e,t){if(!this.privateKey)throw Error("Attempted to decrypt without a private key");const n=e.hexpubkey();return await me.nip04.decrypt(this.privateKey,n,t)}},Ee=n(9695);function ke(e){const t=e.getMatchingTags("description")[0],n=e.getMatchingTags("bolt11")[0];let r,i;if(!t||!n||!n[1])return null;try{let e=t[1];if(e.startsWith("%")&&(e=decodeURIComponent(e)),""===e)return null;i=JSON.parse(e),r=(0,Ee.decode)(n[1])}catch(e){return null}const o=r.sections.find((e=>"amount"===e.name));if(!o)return null;const s=parseInt(o.value);if(!s)return null;const a=i.content,c=i.pubkey,u=e.getMatchingTags("p")[0][1];let l=e.getMatchingTags("e")[0];l||(l=e.getMatchingTags("a")[0]);const h=l?l[1]:void 0;return{id:e.id,zapper:e.pubkey,zappee:c,zapped:u,zappedEvent:h,amount:s,comment:a}}var xe=class extends p.default{pool;signer;cacheAdapter;debug;devWriteRelaySet;delayedSubscriptions;constructor(e={}){super(),this.debug=e.debug||(0,f.default)("ndk"),this.pool=new te(e.explicitRelayUrls||[],this),this.signer=e.signer,this.cacheAdapter=e.cacheAdapter,this.delayedSubscriptions=new Map,e.devWriteRelayUrls&&(this.devWriteRelaySet=L.fromRelayUrls(e.devWriteRelayUrls,this))}toJSON(){return{relayCount:this.pool.relays.size}.toString()}async connect(e){return this.debug("Connecting to relays",{timeoutMs:e}),this.pool.connect(e)}getUser(e){const t=new W(e);return t.ndk=this,t}subscribe(e,t,n,r=!0){const i=new M(this,e,t,n);if(n)for(const e of n.relays)this.pool.useTemporaryRelay(e);return r&&i.start(),i}async publish(e,t,n){return t||(t=this.devWriteRelaySet||function(e,t){const n=new Set;return e.pool?.relays.forEach((e=>n.add(e))),new L(n,e)}(this)),t.publish(e,n)}async fetchEvent(e,t,n){let r;if(!n&&"string"==typeof e){const t=K(e);t.length>0&&(n=function(e,t){const n=t.connectedRelays();if(!Array.from(e.relays).some((e=>n.map((e=>e.url)).includes(e.url))))for(const t of n)e.addRelay(t);if(0===n.length)for(const n of t.relays.values())e.addRelay(n);return e}(n=new L(new Set(t),this),this.pool))}if(r="string"==typeof e?U(e):e,!r)throw new Error(`Invalid filter: ${JSON.stringify(e)}`);return new Promise((e=>{const i=this.subscribe(r,{...t||{},closeOnEose:!0},n,!1);i.on("event",(t=>{t.ndk=this,e(t)})),i.on("eose",(()=>{e(null)})),i.start()}))}async fetchEvents(e,t,n){return new Promise((r=>{const i=new Map,o=this.subscribe(e,{...t||{},closeOnEose:!0},n,!1);o.on("event",(e=>{const t=i.get(e.tagId());var n,r;t&&(r=e,e=(n=t).created_at>r.created_at?n:r),e.ndk=this,i.set(e.tagId(),e)})),o.on("eose",(()=>{r(new Set(i.values()))})),o.start()}))}async assertSigner(){if(!this.signer)throw this.emit("signerRequired"),new Error("Signer required")}}},1027:(e,t)=>{"use strict";function n(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function r(...e){const t=(e,t)=>n=>e(t(n));return{encode:Array.from(e).reverse().reduce(((e,n)=>e?t(e,n.encode):n.encode),void 0),decode:e.reduce(((e,n)=>e?t(e,n.decode):n.decode),void 0)}}function i(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("alphabet.encode input should be an array of numbers");return t.map((t=>{if(n(t),t<0||t>=e.length)throw new 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 new Error("alphabet.decode input should be array of strings");return t.map((t=>{if("string"!=typeof t)throw new Error(`alphabet.decode: not string element=${t}`);const n=e.indexOf(t);if(-1===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n}))}}}function o(e=""){if("string"!=typeof e)throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("join.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`join.encode: non-string input=${e}`);return t.join(e)},decode:t=>{if("string"!=typeof t)throw new Error("join.decode input should be string");return t.split(e)}}}function s(e,t="="){if(n(e),"string"!=typeof t)throw new Error("padding chr should be string");return{encode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let e of n)if("string"!=typeof e)throw new Error(`padding.encode: non-string input=${e}`);for(;n.length*e%8;)n.push(t);return n},decode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let e of n)if("string"!=typeof e)throw new Error(`padding.decode: non-string input=${e}`);let r=n.length;if(r*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&n[r-1]===t;r--)if(!((r-1)*e%8))throw new Error("Invalid padding: string has too much padding");return n.slice(0,r)}}}function a(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function c(e,t,r){if(t<2)throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: wrong to=${r}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let i=0;const o=[],s=Array.from(e);for(s.forEach((e=>{if(n(e),e<0||e>=t)throw new Error(`Wrong integer: ${e}`)}));;){let e=0,n=!0;for(let o=i;o<s.length;o++){const a=s[o],c=t*e+a;if(!Number.isSafeInteger(c)||t*e/t!==e||c-a!=t*e)throw new Error("convertRadix: carry overflow");if(e=c%r,s[o]=Math.floor(c/r),!Number.isSafeInteger(s[o])||s[o]*r+e!==c)throw new Error("convertRadix: carry overflow");n&&(s[o]?n=!1:i=o)}if(o.push(e),n)break}for(let t=0;t<e.length-1&&0===e[t];t++)o.push(0);return o.reverse()}Object.defineProperty(t,"__esModule",{value:!0}),t.bytes=t.stringToBytes=t.str=t.bytesToString=t.hex=t.utf8=t.bech32m=t.bech32=t.base58check=t.base58xmr=t.base58xrp=t.base58flickr=t.base58=t.base64url=t.base64=t.base32crockford=t.base32hex=t.base32=t.base16=t.utils=t.assertNumber=void 0,t.assertNumber=n;const u=(e,t)=>t?u(t,e%t):e,l=(e,t)=>e+(t-u(e,t));function h(e,t,r,i){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(l(t,r)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${l(t,r)}`);let o=0,s=0;const a=2**r-1,c=[];for(const i of e){if(n(i),i>=2**t)throw new Error(`convertRadix2: invalid data word=${i} from=${t}`);if(o=o<<t|i,s+t>32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${t}`);for(s+=t;s>=r;s-=r)c.push((o>>s-r&a)>>>0);o&=2**s-1}if(o=o<<r-s&a,!i&&s>=t)throw new Error("Excess padding");if(!i&&o)throw new Error(`Non-zero padding: ${o}`);return i&&s>0&&c.push(o>>>0),c}function d(e){return n(e),{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return c(Array.from(t),256,e)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix.decode input should be array of strings");return Uint8Array.from(c(t,e,256))}}}function f(e,t=!1){if(n(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(l(8,e)>32||l(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!(n instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return h(Array.from(n),8,e,!t)},decode:n=>{if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(h(n,e,8,t))}}}function p(e){if("function"!=typeof e)throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch(e){}}}function y(e,t){if(n(e),"function"!=typeof t)throw new Error("checksum fn should be function");return{encode(n){if(!(n instanceof Uint8Array))throw new Error("checksum.encode: input should be Uint8Array");const r=t(n).slice(0,e),i=new Uint8Array(n.length+e);return i.set(n),i.set(r,n.length),i},decode(n){if(!(n instanceof Uint8Array))throw new Error("checksum.decode: input should be Uint8Array");const r=n.slice(0,-e),i=t(r).slice(0,e),o=n.slice(-e);for(let t=0;t<e;t++)if(i[t]!==o[t])throw new Error("Invalid checksum");return r}}}t.utils={alphabet:i,chain:r,checksum:y,radix:d,radix2:f,join:o,padding:s},t.base16=r(f(4),i("0123456789ABCDEF"),o("")),t.base32=r(f(5),i("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),s(5),o("")),t.base32hex=r(f(5),i("0123456789ABCDEFGHIJKLMNOPQRSTUV"),s(5),o("")),t.base32crockford=r(f(5),i("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),o(""),a((e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")))),t.base64=r(f(6),i("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),s(6),o("")),t.base64url=r(f(6),i("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),s(6),o(""));const g=e=>r(d(58),i(e),o(""));t.base58=g("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),t.base58flickr=g("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),t.base58xrp=g("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const b=[0,2,3,5,6,7,9,10,11];t.base58xmr={encode(e){let n="";for(let r=0;r<e.length;r+=8){const i=e.subarray(r,r+8);n+=t.base58.encode(i).padStart(b[i.length],"1")}return n},decode(e){let n=[];for(let r=0;r<e.length;r+=11){const i=e.slice(r,r+11),o=b.indexOf(i.length),s=t.base58.decode(i);for(let e=0;e<s.length-o;e++)if(0!==s[e])throw new Error("base58xmr: wrong padding");n=n.concat(Array.from(s.slice(s.length-o)))}return Uint8Array.from(n)}},t.base58check=e=>r(y(4,(t=>e(e(t)))),t.base58);const v=r(i("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),o("")),w=[996825010,642813549,513874426,1027748829,705979059];function m(e){const t=e>>25;let n=(33554431&e)<<5;for(let e=0;e<w.length;e++)1==(t>>e&1)&&(n^=w[e]);return n}function _(e,t,n=1){const r=e.length;let i=1;for(let t=0;t<r;t++){const n=e.charCodeAt(t);if(n<33||n>126)throw new Error(`Invalid prefix (${e})`);i=m(i)^n>>5}i=m(i);for(let t=0;t<r;t++)i=m(i)^31&e.charCodeAt(t);for(let e of t)i=m(i)^e;for(let e=0;e<6;e++)i=m(i);return i^=n,v.encode(h([i%2**30],30,5,!1))}function E(e){const t="bech32"===e?1:734539939,n=f(5),r=n.decode,i=n.encode,o=p(r);function s(e,n=90){if("string"!=typeof e)throw new Error("bech32.decode input should be string, not "+typeof e);if(e.length<8||!1!==n&&e.length>n)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);const r=e.toLowerCase();if(e!==r&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const i=(e=r).lastIndexOf("1");if(0===i||-1===i)throw new Error('Letter "1" must be present between prefix and data only');const o=e.slice(0,i),s=e.slice(i+1);if(s.length<6)throw new Error("Data must be at least 6 characters long");const a=v.decode(s).slice(0,-6),c=_(o,a,t);if(!s.endsWith(c))throw new Error(`Invalid checksum in ${e}: expected "${c}"`);return{prefix:o,words:a}}return{encode:function(e,n,r=90){if("string"!=typeof e)throw new Error("bech32.encode prefix should be string, not "+typeof e);if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof n);const i=e.length+7+n.length;if(!1!==r&&i>r)throw new TypeError(`Length ${i} exceeds limit ${r}`);return`${e=e.toLowerCase()}1${v.encode(n)}${_(e,n,t)}`},decode:s,decodeToBytes:function(e){const{prefix:t,words:n}=s(e,!1);return{prefix:t,words:n,bytes:r(n)}},decodeUnsafe:p(s),fromWords:r,fromWordsUnsafe:o,toWords:i}}t.bech32=E("bech32"),t.bech32m=E("bech32m"),t.utf8={encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)},t.hex=r(f(4),i("0123456789abcdef"),o(""),a((e=>{if("string"!=typeof e||e.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()})));const k={utf8:t.utf8,hex:t.hex,base16:t.base16,base32:t.base32,base64:t.base64,base64url:t.base64url,base58:t.base58,base58xmr:t.base58xmr},x=`Invalid encoding type. Available types: ${Object.keys(k).join(", ")}`;t.bytesToString=(e,t)=>{if("string"!=typeof e||!k.hasOwnProperty(e))throw new TypeError(x);if(!(t instanceof Uint8Array))throw new TypeError("bytesToString() expects Uint8Array");return k[e].encode(t)},t.str=t.bytesToString,t.stringToBytes=(e,t)=>{if(!k.hasOwnProperty(e))throw new TypeError(x);if("string"!=typeof t)throw new TypeError("stringToBytes() expects string");return k[e].decode(t)},t.bytes=t.stringToBytes},4002:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HDKey=t.HARDENED_OFFSET=void 0;const r=n(9932),i=n(1447),o=n(1581),s=n(477),a=n(7636),c=n(4099),u=n(275),l=n(7031),h=n(1027),d=u.secp256k1.ProjectivePoint,f=(0,h.base58check)(o.sha256);function p(e){return BigInt(`0x${(0,c.bytesToHex)(e)}`)}const y=(0,c.utf8ToBytes)("Bitcoin seed"),g={private:76066276,public:76067358};t.HARDENED_OFFSET=2147483648;const b=e=>{if(!Number.isSafeInteger(e)||e<0||e>2**32-1)throw new Error(`Invalid number=${e}. Should be from 0 to 2 ** 32 - 1`);const t=new Uint8Array(4);return(0,c.createView)(t).setUint32(0,e,!1),t};class v{get fingerprint(){if(!this.pubHash)throw new Error("No publicKey set!");return e=this.pubHash,(0,c.createView)(e).getUint32(0,!1);var e}get identifier(){return this.pubHash}get pubKeyHash(){return this.pubHash}get privateKey(){return this.privKeyBytes||null}get publicKey(){return this.pubKey||null}get privateExtendedKey(){const e=this.privateKey;if(!e)throw new Error("No private key");return f.encode(this.serialize(this.versions.private,(0,c.concatBytes)(new Uint8Array([0]),e)))}get publicExtendedKey(){if(!this.pubKey)throw new Error("No public key");return f.encode(this.serialize(this.versions.public,this.pubKey))}static fromMasterSeed(e,t=g){if((0,a.bytes)(e),8*e.length<128||8*e.length>512)throw new Error(`HDKey: wrong seed length=${e.length}. Should be between 128 and 512 bits; 256 bits is advised)`);const n=(0,r.hmac)(s.sha512,y,e);return new v({versions:t,chainCode:n.slice(32),privateKey:n.slice(0,32)})}static fromExtendedKey(e,t=g){const n=f.decode(e),r=(0,c.createView)(n),i=r.getUint32(0,!1),o={versions:t,depth:n[4],parentFingerprint:r.getUint32(5,!1),index:r.getUint32(9,!1),chainCode:n.slice(13,45)},s=n.slice(45),a=0===s[0];if(i!==t[a?"private":"public"])throw new Error("Version mismatch");return new v(a?{...o,privateKey:s.slice(1)}:{...o,publicKey:s})}static fromJSON(e){return v.fromExtendedKey(e.xpriv)}constructor(e){if(this.depth=0,this.index=0,this.chainCode=null,this.parentFingerprint=0,!e||"object"!=typeof e)throw new Error("HDKey.constructor must not be called directly");if(this.versions=e.versions||g,this.depth=e.depth||0,this.chainCode=e.chainCode,this.index=e.index||0,this.parentFingerprint=e.parentFingerprint||0,!this.depth&&(this.parentFingerprint||this.index))throw new Error("HDKey: zero depth with non-zero index/parent fingerprint");if(e.publicKey&&e.privateKey)throw new Error("HDKey: publicKey and privateKey at same time.");if(e.privateKey){if(!u.secp256k1.utils.isValidPrivateKey(e.privateKey))throw new Error("Invalid private key");this.privKey="bigint"==typeof e.privateKey?e.privateKey:p(e.privateKey),this.privKeyBytes=(t=this.privKey,(0,c.hexToBytes)(t.toString(16).padStart(64,"0"))),this.pubKey=u.secp256k1.getPublicKey(e.privateKey,!0)}else{if(!e.publicKey)throw new Error("HDKey: no public or private key provided");this.pubKey=d.fromHex(e.publicKey).toRawBytes(!0)}var t,n;this.pubHash=(n=this.pubKey,(0,i.ripemd160)((0,o.sha256)(n)))}derive(e){if(!/^[mM]'?/.test(e))throw new Error('Path must start with "m" or "M"');if(/^[mM]'?$/.test(e))return this;const n=e.replace(/^[mM]'?\//,"").split("/");let r=this;for(const e of n){const n=/^(\d+)('?)$/.exec(e);if(!n||3!==n.length)throw new Error(`Invalid child index: ${e}`);let i=+n[1];if(!Number.isSafeInteger(i)||i>=t.HARDENED_OFFSET)throw new Error("Invalid index");"'"===n[2]&&(i+=t.HARDENED_OFFSET),r=r.deriveChild(i)}return r}deriveChild(e){if(!this.pubKey||!this.chainCode)throw new Error("No publicKey or chainCode set");let n=b(e);if(e>=t.HARDENED_OFFSET){const e=this.privateKey;if(!e)throw new Error("Could not derive hardened child key");n=(0,c.concatBytes)(new Uint8Array([0]),e,n)}else n=(0,c.concatBytes)(this.pubKey,n);const i=(0,r.hmac)(s.sha512,this.chainCode,n),o=p(i.slice(0,32)),a=i.slice(32);if(!u.secp256k1.utils.isValidPrivateKey(o))throw new Error("Tweak bigger than curve order");const h={versions:this.versions,chainCode:a,depth:this.depth+1,parentFingerprint:this.fingerprint,index:e};try{if(this.privateKey){const e=(0,l.mod)(this.privKey+o,u.secp256k1.CURVE.n);if(!u.secp256k1.utils.isValidPrivateKey(e))throw new Error("The tweak was out of range or the resulted private key is invalid");h.privateKey=e}else{const e=d.fromHex(this.pubKey).add(d.fromPrivateKey(o));if(e.equals(d.ZERO))throw new Error("The tweak was equal to negative P, which made the result key invalid");h.publicKey=e.toRawBytes(!0)}return new v(h)}catch(t){return this.deriveChild(e+1)}}sign(e){if(!this.privateKey)throw new Error("No privateKey set!");return(0,a.bytes)(e,32),u.secp256k1.sign(e,this.privKey).toCompactRawBytes()}verify(e,t){if((0,a.bytes)(e,32),(0,a.bytes)(t,64),!this.publicKey)throw new Error("No publicKey set!");let n;try{n=u.secp256k1.Signature.fromCompact(t)}catch(e){return!1}return u.secp256k1.verify(n,e,this.publicKey)}wipePrivateData(){return this.privKey=void 0,this.privKeyBytes&&(this.privKeyBytes.fill(0),this.privKeyBytes=void 0),this}toJSON(){return{xpriv:this.privateExtendedKey,xpub:this.publicExtendedKey}}serialize(e,t){if(!this.chainCode)throw new Error("No chainCode set");return(0,a.bytes)(t,33),(0,c.concatBytes)(b(e),new Uint8Array([this.depth]),b(this.parentFingerprint),b(this.index),this.chainCode,t)}}t.HDKey=v},6812:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mnemonicToSeedSync=t.mnemonicToSeed=t.validateMnemonic=t.entropyToMnemonic=t.mnemonicToEntropy=t.generateMnemonic=void 0;const r=n(7636),i=n(1907),o=n(1581),s=n(477),a=n(4099),c=n(1027);function u(e){if("string"!=typeof e)throw new TypeError("Invalid mnemonic type: "+typeof e);return e.normalize("NFKD")}function l(e){const t=u(e),n=t.split(" ");if(![12,15,18,21,24].includes(n.length))throw new Error("Invalid mnemonic");return{nfkd:t,words:n}}function h(e){r.default.bytes(e,16,20,24,28,32)}t.generateMnemonic=function(e,t=128){if(r.default.number(t),t%32!=0||t>256)throw new TypeError("Invalid entropy");return y((0,a.randomBytes)(t/8),e)};const d=e=>{const t=8-e.length/4;return new Uint8Array([(0,o.sha256)(e)[0]>>t<<t])};function f(e){if(!Array.isArray(e)||2048!==e.length||"string"!=typeof e[0])throw new Error("Worlist: expected array of 2048 strings");return e.forEach((e=>{if("string"!=typeof e)throw new Error(`Wordlist: non-string element: ${e}`)})),c.utils.chain(c.utils.checksum(1,d),c.utils.radix2(11,!0),c.utils.alphabet(e))}function p(e,t){const{words:n}=l(e),r=f(t).decode(n);return h(r),r}function y(e,t){return h(e),f(t).encode(e).join((e=>"あいこくしん"===e[0])(t)?" ":" ")}t.mnemonicToEntropy=p,t.entropyToMnemonic=y,t.validateMnemonic=function(e,t){try{p(e,t)}catch(e){return!1}return!0};const g=e=>u(`mnemonic${e}`);t.mnemonicToSeed=function(e,t=""){return(0,i.pbkdf2Async)(s.sha512,l(e).nfkd,g(t),{c:2048,dkLen:64})},t.mnemonicToSeedSync=function(e,t=""){return(0,i.pbkdf2)(s.sha512,l(e).nfkd,g(t),{c:2048,dkLen:64})}},8859:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.wordlist=void 0,t.wordlist="abandon\nability\nable\nabout\nabove\nabsent\nabsorb\nabstract\nabsurd\nabuse\naccess\naccident\naccount\naccuse\nachieve\nacid\nacoustic\nacquire\nacross\nact\naction\nactor\nactress\nactual\nadapt\nadd\naddict\naddress\nadjust\nadmit\nadult\nadvance\nadvice\naerobic\naffair\nafford\nafraid\nagain\nage\nagent\nagree\nahead\naim\nair\nairport\naisle\nalarm\nalbum\nalcohol\nalert\nalien\nall\nalley\nallow\nalmost\nalone\nalpha\nalready\nalso\nalter\nalways\namateur\namazing\namong\namount\namused\nanalyst\nanchor\nancient\nanger\nangle\nangry\nanimal\nankle\nannounce\nannual\nanother\nanswer\nantenna\nantique\nanxiety\nany\napart\napology\nappear\napple\napprove\napril\narch\narctic\narea\narena\nargue\narm\narmed\narmor\narmy\naround\narrange\narrest\narrive\narrow\nart\nartefact\nartist\nartwork\nask\naspect\nassault\nasset\nassist\nassume\nasthma\nathlete\natom\nattack\nattend\nattitude\nattract\nauction\naudit\naugust\naunt\nauthor\nauto\nautumn\naverage\navocado\navoid\nawake\naware\naway\nawesome\nawful\nawkward\naxis\nbaby\nbachelor\nbacon\nbadge\nbag\nbalance\nbalcony\nball\nbamboo\nbanana\nbanner\nbar\nbarely\nbargain\nbarrel\nbase\nbasic\nbasket\nbattle\nbeach\nbean\nbeauty\nbecause\nbecome\nbeef\nbefore\nbegin\nbehave\nbehind\nbelieve\nbelow\nbelt\nbench\nbenefit\nbest\nbetray\nbetter\nbetween\nbeyond\nbicycle\nbid\nbike\nbind\nbiology\nbird\nbirth\nbitter\nblack\nblade\nblame\nblanket\nblast\nbleak\nbless\nblind\nblood\nblossom\nblouse\nblue\nblur\nblush\nboard\nboat\nbody\nboil\nbomb\nbone\nbonus\nbook\nboost\nborder\nboring\nborrow\nboss\nbottom\nbounce\nbox\nboy\nbracket\nbrain\nbrand\nbrass\nbrave\nbread\nbreeze\nbrick\nbridge\nbrief\nbright\nbring\nbrisk\nbroccoli\nbroken\nbronze\nbroom\nbrother\nbrown\nbrush\nbubble\nbuddy\nbudget\nbuffalo\nbuild\nbulb\nbulk\nbullet\nbundle\nbunker\nburden\nburger\nburst\nbus\nbusiness\nbusy\nbutter\nbuyer\nbuzz\ncabbage\ncabin\ncable\ncactus\ncage\ncake\ncall\ncalm\ncamera\ncamp\ncan\ncanal\ncancel\ncandy\ncannon\ncanoe\ncanvas\ncanyon\ncapable\ncapital\ncaptain\ncar\ncarbon\ncard\ncargo\ncarpet\ncarry\ncart\ncase\ncash\ncasino\ncastle\ncasual\ncat\ncatalog\ncatch\ncategory\ncattle\ncaught\ncause\ncaution\ncave\nceiling\ncelery\ncement\ncensus\ncentury\ncereal\ncertain\nchair\nchalk\nchampion\nchange\nchaos\nchapter\ncharge\nchase\nchat\ncheap\ncheck\ncheese\nchef\ncherry\nchest\nchicken\nchief\nchild\nchimney\nchoice\nchoose\nchronic\nchuckle\nchunk\nchurn\ncigar\ncinnamon\ncircle\ncitizen\ncity\ncivil\nclaim\nclap\nclarify\nclaw\nclay\nclean\nclerk\nclever\nclick\nclient\ncliff\nclimb\nclinic\nclip\nclock\nclog\nclose\ncloth\ncloud\nclown\nclub\nclump\ncluster\nclutch\ncoach\ncoast\ncoconut\ncode\ncoffee\ncoil\ncoin\ncollect\ncolor\ncolumn\ncombine\ncome\ncomfort\ncomic\ncommon\ncompany\nconcert\nconduct\nconfirm\ncongress\nconnect\nconsider\ncontrol\nconvince\ncook\ncool\ncopper\ncopy\ncoral\ncore\ncorn\ncorrect\ncost\ncotton\ncouch\ncountry\ncouple\ncourse\ncousin\ncover\ncoyote\ncrack\ncradle\ncraft\ncram\ncrane\ncrash\ncrater\ncrawl\ncrazy\ncream\ncredit\ncreek\ncrew\ncricket\ncrime\ncrisp\ncritic\ncrop\ncross\ncrouch\ncrowd\ncrucial\ncruel\ncruise\ncrumble\ncrunch\ncrush\ncry\ncrystal\ncube\nculture\ncup\ncupboard\ncurious\ncurrent\ncurtain\ncurve\ncushion\ncustom\ncute\ncycle\ndad\ndamage\ndamp\ndance\ndanger\ndaring\ndash\ndaughter\ndawn\nday\ndeal\ndebate\ndebris\ndecade\ndecember\ndecide\ndecline\ndecorate\ndecrease\ndeer\ndefense\ndefine\ndefy\ndegree\ndelay\ndeliver\ndemand\ndemise\ndenial\ndentist\ndeny\ndepart\ndepend\ndeposit\ndepth\ndeputy\nderive\ndescribe\ndesert\ndesign\ndesk\ndespair\ndestroy\ndetail\ndetect\ndevelop\ndevice\ndevote\ndiagram\ndial\ndiamond\ndiary\ndice\ndiesel\ndiet\ndiffer\ndigital\ndignity\ndilemma\ndinner\ndinosaur\ndirect\ndirt\ndisagree\ndiscover\ndisease\ndish\ndismiss\ndisorder\ndisplay\ndistance\ndivert\ndivide\ndivorce\ndizzy\ndoctor\ndocument\ndog\ndoll\ndolphin\ndomain\ndonate\ndonkey\ndonor\ndoor\ndose\ndouble\ndove\ndraft\ndragon\ndrama\ndrastic\ndraw\ndream\ndress\ndrift\ndrill\ndrink\ndrip\ndrive\ndrop\ndrum\ndry\nduck\ndumb\ndune\nduring\ndust\ndutch\nduty\ndwarf\ndynamic\neager\neagle\nearly\nearn\nearth\neasily\neast\neasy\necho\necology\neconomy\nedge\nedit\neducate\neffort\negg\neight\neither\nelbow\nelder\nelectric\nelegant\nelement\nelephant\nelevator\nelite\nelse\nembark\nembody\nembrace\nemerge\nemotion\nemploy\nempower\nempty\nenable\nenact\nend\nendless\nendorse\nenemy\nenergy\nenforce\nengage\nengine\nenhance\nenjoy\nenlist\nenough\nenrich\nenroll\nensure\nenter\nentire\nentry\nenvelope\nepisode\nequal\nequip\nera\nerase\nerode\nerosion\nerror\nerupt\nescape\nessay\nessence\nestate\neternal\nethics\nevidence\nevil\nevoke\nevolve\nexact\nexample\nexcess\nexchange\nexcite\nexclude\nexcuse\nexecute\nexercise\nexhaust\nexhibit\nexile\nexist\nexit\nexotic\nexpand\nexpect\nexpire\nexplain\nexpose\nexpress\nextend\nextra\neye\neyebrow\nfabric\nface\nfaculty\nfade\nfaint\nfaith\nfall\nfalse\nfame\nfamily\nfamous\nfan\nfancy\nfantasy\nfarm\nfashion\nfat\nfatal\nfather\nfatigue\nfault\nfavorite\nfeature\nfebruary\nfederal\nfee\nfeed\nfeel\nfemale\nfence\nfestival\nfetch\nfever\nfew\nfiber\nfiction\nfield\nfigure\nfile\nfilm\nfilter\nfinal\nfind\nfine\nfinger\nfinish\nfire\nfirm\nfirst\nfiscal\nfish\nfit\nfitness\nfix\nflag\nflame\nflash\nflat\nflavor\nflee\nflight\nflip\nfloat\nflock\nfloor\nflower\nfluid\nflush\nfly\nfoam\nfocus\nfog\nfoil\nfold\nfollow\nfood\nfoot\nforce\nforest\nforget\nfork\nfortune\nforum\nforward\nfossil\nfoster\nfound\nfox\nfragile\nframe\nfrequent\nfresh\nfriend\nfringe\nfrog\nfront\nfrost\nfrown\nfrozen\nfruit\nfuel\nfun\nfunny\nfurnace\nfury\nfuture\ngadget\ngain\ngalaxy\ngallery\ngame\ngap\ngarage\ngarbage\ngarden\ngarlic\ngarment\ngas\ngasp\ngate\ngather\ngauge\ngaze\ngeneral\ngenius\ngenre\ngentle\ngenuine\ngesture\nghost\ngiant\ngift\ngiggle\nginger\ngiraffe\ngirl\ngive\nglad\nglance\nglare\nglass\nglide\nglimpse\nglobe\ngloom\nglory\nglove\nglow\nglue\ngoat\ngoddess\ngold\ngood\ngoose\ngorilla\ngospel\ngossip\ngovern\ngown\ngrab\ngrace\ngrain\ngrant\ngrape\ngrass\ngravity\ngreat\ngreen\ngrid\ngrief\ngrit\ngrocery\ngroup\ngrow\ngrunt\nguard\nguess\nguide\nguilt\nguitar\ngun\ngym\nhabit\nhair\nhalf\nhammer\nhamster\nhand\nhappy\nharbor\nhard\nharsh\nharvest\nhat\nhave\nhawk\nhazard\nhead\nhealth\nheart\nheavy\nhedgehog\nheight\nhello\nhelmet\nhelp\nhen\nhero\nhidden\nhigh\nhill\nhint\nhip\nhire\nhistory\nhobby\nhockey\nhold\nhole\nholiday\nhollow\nhome\nhoney\nhood\nhope\nhorn\nhorror\nhorse\nhospital\nhost\nhotel\nhour\nhover\nhub\nhuge\nhuman\nhumble\nhumor\nhundred\nhungry\nhunt\nhurdle\nhurry\nhurt\nhusband\nhybrid\nice\nicon\nidea\nidentify\nidle\nignore\nill\nillegal\nillness\nimage\nimitate\nimmense\nimmune\nimpact\nimpose\nimprove\nimpulse\ninch\ninclude\nincome\nincrease\nindex\nindicate\nindoor\nindustry\ninfant\ninflict\ninform\ninhale\ninherit\ninitial\ninject\ninjury\ninmate\ninner\ninnocent\ninput\ninquiry\ninsane\ninsect\ninside\ninspire\ninstall\nintact\ninterest\ninto\ninvest\ninvite\ninvolve\niron\nisland\nisolate\nissue\nitem\nivory\njacket\njaguar\njar\njazz\njealous\njeans\njelly\njewel\njob\njoin\njoke\njourney\njoy\njudge\njuice\njump\njungle\njunior\njunk\njust\nkangaroo\nkeen\nkeep\nketchup\nkey\nkick\nkid\nkidney\nkind\nkingdom\nkiss\nkit\nkitchen\nkite\nkitten\nkiwi\nknee\nknife\nknock\nknow\nlab\nlabel\nlabor\nladder\nlady\nlake\nlamp\nlanguage\nlaptop\nlarge\nlater\nlatin\nlaugh\nlaundry\nlava\nlaw\nlawn\nlawsuit\nlayer\nlazy\nleader\nleaf\nlearn\nleave\nlecture\nleft\nleg\nlegal\nlegend\nleisure\nlemon\nlend\nlength\nlens\nleopard\nlesson\nletter\nlevel\nliar\nliberty\nlibrary\nlicense\nlife\nlift\nlight\nlike\nlimb\nlimit\nlink\nlion\nliquid\nlist\nlittle\nlive\nlizard\nload\nloan\nlobster\nlocal\nlock\nlogic\nlonely\nlong\nloop\nlottery\nloud\nlounge\nlove\nloyal\nlucky\nluggage\nlumber\nlunar\nlunch\nluxury\nlyrics\nmachine\nmad\nmagic\nmagnet\nmaid\nmail\nmain\nmajor\nmake\nmammal\nman\nmanage\nmandate\nmango\nmansion\nmanual\nmaple\nmarble\nmarch\nmargin\nmarine\nmarket\nmarriage\nmask\nmass\nmaster\nmatch\nmaterial\nmath\nmatrix\nmatter\nmaximum\nmaze\nmeadow\nmean\nmeasure\nmeat\nmechanic\nmedal\nmedia\nmelody\nmelt\nmember\nmemory\nmention\nmenu\nmercy\nmerge\nmerit\nmerry\nmesh\nmessage\nmetal\nmethod\nmiddle\nmidnight\nmilk\nmillion\nmimic\nmind\nminimum\nminor\nminute\nmiracle\nmirror\nmisery\nmiss\nmistake\nmix\nmixed\nmixture\nmobile\nmodel\nmodify\nmom\nmoment\nmonitor\nmonkey\nmonster\nmonth\nmoon\nmoral\nmore\nmorning\nmosquito\nmother\nmotion\nmotor\nmountain\nmouse\nmove\nmovie\nmuch\nmuffin\nmule\nmultiply\nmuscle\nmuseum\nmushroom\nmusic\nmust\nmutual\nmyself\nmystery\nmyth\nnaive\nname\nnapkin\nnarrow\nnasty\nnation\nnature\nnear\nneck\nneed\nnegative\nneglect\nneither\nnephew\nnerve\nnest\nnet\nnetwork\nneutral\nnever\nnews\nnext\nnice\nnight\nnoble\nnoise\nnominee\nnoodle\nnormal\nnorth\nnose\nnotable\nnote\nnothing\nnotice\nnovel\nnow\nnuclear\nnumber\nnurse\nnut\noak\nobey\nobject\noblige\nobscure\nobserve\nobtain\nobvious\noccur\nocean\noctober\nodor\noff\noffer\noffice\noften\noil\nokay\nold\nolive\nolympic\nomit\nonce\none\nonion\nonline\nonly\nopen\nopera\nopinion\noppose\noption\norange\norbit\norchard\norder\nordinary\norgan\norient\noriginal\norphan\nostrich\nother\noutdoor\nouter\noutput\noutside\noval\noven\nover\nown\nowner\noxygen\noyster\nozone\npact\npaddle\npage\npair\npalace\npalm\npanda\npanel\npanic\npanther\npaper\nparade\nparent\npark\nparrot\nparty\npass\npatch\npath\npatient\npatrol\npattern\npause\npave\npayment\npeace\npeanut\npear\npeasant\npelican\npen\npenalty\npencil\npeople\npepper\nperfect\npermit\nperson\npet\nphone\nphoto\nphrase\nphysical\npiano\npicnic\npicture\npiece\npig\npigeon\npill\npilot\npink\npioneer\npipe\npistol\npitch\npizza\nplace\nplanet\nplastic\nplate\nplay\nplease\npledge\npluck\nplug\nplunge\npoem\npoet\npoint\npolar\npole\npolice\npond\npony\npool\npopular\nportion\nposition\npossible\npost\npotato\npottery\npoverty\npowder\npower\npractice\npraise\npredict\nprefer\nprepare\npresent\npretty\nprevent\nprice\npride\nprimary\nprint\npriority\nprison\nprivate\nprize\nproblem\nprocess\nproduce\nprofit\nprogram\nproject\npromote\nproof\nproperty\nprosper\nprotect\nproud\nprovide\npublic\npudding\npull\npulp\npulse\npumpkin\npunch\npupil\npuppy\npurchase\npurity\npurpose\npurse\npush\nput\npuzzle\npyramid\nquality\nquantum\nquarter\nquestion\nquick\nquit\nquiz\nquote\nrabbit\nraccoon\nrace\nrack\nradar\nradio\nrail\nrain\nraise\nrally\nramp\nranch\nrandom\nrange\nrapid\nrare\nrate\nrather\nraven\nraw\nrazor\nready\nreal\nreason\nrebel\nrebuild\nrecall\nreceive\nrecipe\nrecord\nrecycle\nreduce\nreflect\nreform\nrefuse\nregion\nregret\nregular\nreject\nrelax\nrelease\nrelief\nrely\nremain\nremember\nremind\nremove\nrender\nrenew\nrent\nreopen\nrepair\nrepeat\nreplace\nreport\nrequire\nrescue\nresemble\nresist\nresource\nresponse\nresult\nretire\nretreat\nreturn\nreunion\nreveal\nreview\nreward\nrhythm\nrib\nribbon\nrice\nrich\nride\nridge\nrifle\nright\nrigid\nring\nriot\nripple\nrisk\nritual\nrival\nriver\nroad\nroast\nrobot\nrobust\nrocket\nromance\nroof\nrookie\nroom\nrose\nrotate\nrough\nround\nroute\nroyal\nrubber\nrude\nrug\nrule\nrun\nrunway\nrural\nsad\nsaddle\nsadness\nsafe\nsail\nsalad\nsalmon\nsalon\nsalt\nsalute\nsame\nsample\nsand\nsatisfy\nsatoshi\nsauce\nsausage\nsave\nsay\nscale\nscan\nscare\nscatter\nscene\nscheme\nschool\nscience\nscissors\nscorpion\nscout\nscrap\nscreen\nscript\nscrub\nsea\nsearch\nseason\nseat\nsecond\nsecret\nsection\nsecurity\nseed\nseek\nsegment\nselect\nsell\nseminar\nsenior\nsense\nsentence\nseries\nservice\nsession\nsettle\nsetup\nseven\nshadow\nshaft\nshallow\nshare\nshed\nshell\nsheriff\nshield\nshift\nshine\nship\nshiver\nshock\nshoe\nshoot\nshop\nshort\nshoulder\nshove\nshrimp\nshrug\nshuffle\nshy\nsibling\nsick\nside\nsiege\nsight\nsign\nsilent\nsilk\nsilly\nsilver\nsimilar\nsimple\nsince\nsing\nsiren\nsister\nsituate\nsix\nsize\nskate\nsketch\nski\nskill\nskin\nskirt\nskull\nslab\nslam\nsleep\nslender\nslice\nslide\nslight\nslim\nslogan\nslot\nslow\nslush\nsmall\nsmart\nsmile\nsmoke\nsmooth\nsnack\nsnake\nsnap\nsniff\nsnow\nsoap\nsoccer\nsocial\nsock\nsoda\nsoft\nsolar\nsoldier\nsolid\nsolution\nsolve\nsomeone\nsong\nsoon\nsorry\nsort\nsoul\nsound\nsoup\nsource\nsouth\nspace\nspare\nspatial\nspawn\nspeak\nspecial\nspeed\nspell\nspend\nsphere\nspice\nspider\nspike\nspin\nspirit\nsplit\nspoil\nsponsor\nspoon\nsport\nspot\nspray\nspread\nspring\nspy\nsquare\nsqueeze\nsquirrel\nstable\nstadium\nstaff\nstage\nstairs\nstamp\nstand\nstart\nstate\nstay\nsteak\nsteel\nstem\nstep\nstereo\nstick\nstill\nsting\nstock\nstomach\nstone\nstool\nstory\nstove\nstrategy\nstreet\nstrike\nstrong\nstruggle\nstudent\nstuff\nstumble\nstyle\nsubject\nsubmit\nsubway\nsuccess\nsuch\nsudden\nsuffer\nsugar\nsuggest\nsuit\nsummer\nsun\nsunny\nsunset\nsuper\nsupply\nsupreme\nsure\nsurface\nsurge\nsurprise\nsurround\nsurvey\nsuspect\nsustain\nswallow\nswamp\nswap\nswarm\nswear\nsweet\nswift\nswim\nswing\nswitch\nsword\nsymbol\nsymptom\nsyrup\nsystem\ntable\ntackle\ntag\ntail\ntalent\ntalk\ntank\ntape\ntarget\ntask\ntaste\ntattoo\ntaxi\nteach\nteam\ntell\nten\ntenant\ntennis\ntent\nterm\ntest\ntext\nthank\nthat\ntheme\nthen\ntheory\nthere\nthey\nthing\nthis\nthought\nthree\nthrive\nthrow\nthumb\nthunder\nticket\ntide\ntiger\ntilt\ntimber\ntime\ntiny\ntip\ntired\ntissue\ntitle\ntoast\ntobacco\ntoday\ntoddler\ntoe\ntogether\ntoilet\ntoken\ntomato\ntomorrow\ntone\ntongue\ntonight\ntool\ntooth\ntop\ntopic\ntopple\ntorch\ntornado\ntortoise\ntoss\ntotal\ntourist\ntoward\ntower\ntown\ntoy\ntrack\ntrade\ntraffic\ntragic\ntrain\ntransfer\ntrap\ntrash\ntravel\ntray\ntreat\ntree\ntrend\ntrial\ntribe\ntrick\ntrigger\ntrim\ntrip\ntrophy\ntrouble\ntruck\ntrue\ntruly\ntrumpet\ntrust\ntruth\ntry\ntube\ntuition\ntumble\ntuna\ntunnel\nturkey\nturn\nturtle\ntwelve\ntwenty\ntwice\ntwin\ntwist\ntwo\ntype\ntypical\nugly\numbrella\nunable\nunaware\nuncle\nuncover\nunder\nundo\nunfair\nunfold\nunhappy\nuniform\nunique\nunit\nuniverse\nunknown\nunlock\nuntil\nunusual\nunveil\nupdate\nupgrade\nuphold\nupon\nupper\nupset\nurban\nurge\nusage\nuse\nused\nuseful\nuseless\nusual\nutility\nvacant\nvacuum\nvague\nvalid\nvalley\nvalve\nvan\nvanish\nvapor\nvarious\nvast\nvault\nvehicle\nvelvet\nvendor\nventure\nvenue\nverb\nverify\nversion\nvery\nvessel\nveteran\nviable\nvibrant\nvicious\nvictory\nvideo\nview\nvillage\nvintage\nviolin\nvirtual\nvirus\nvisa\nvisit\nvisual\nvital\nvivid\nvocal\nvoice\nvoid\nvolcano\nvolume\nvote\nvoyage\nwage\nwagon\nwait\nwalk\nwall\nwalnut\nwant\nwarfare\nwarm\nwarrior\nwash\nwasp\nwaste\nwater\nwave\nway\nwealth\nweapon\nwear\nweasel\nweather\nweb\nwedding\nweekend\nweird\nwelcome\nwest\nwet\nwhale\nwhat\nwheat\nwheel\nwhen\nwhere\nwhip\nwhisper\nwide\nwidth\nwife\nwild\nwill\nwin\nwindow\nwine\nwing\nwink\nwinner\nwinter\nwire\nwisdom\nwise\nwish\nwitness\nwolf\nwoman\nwonder\nwood\nwool\nword\nwork\nworld\nworry\nworth\nwrap\nwreck\nwrestle\nwrist\nwrite\nwrong\nyard\nyear\nyellow\nyou\nyoung\nyouth\nzebra\nzero\nzone\nzoo".split("\n")},7820:(e,t,n)=>{t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(i=r))})),t.splice(i,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=n(8455)(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},8455:(e,t,n)=>{e.exports=function(e){function t(e){let n,i,o,s=null;function a(...e){if(!a.enabled)return;const r=a,i=Number(new Date),o=i-(n||i);r.diff=o,r.prev=n,r.curr=i,n=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,i)=>{if("%%"===n)return"%";s++;const o=t.formatters[i];if("function"==typeof o){const t=e[s];n=o.call(r,t),e.splice(s,1),s--}return n})),t.formatArgs.call(r,e),(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(i!==t.namespaces&&(i=t.namespaces,o=t.enabled(e)),o),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function i(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(i),...t.skips.map(i).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),i=r.length;for(n=0;n<i;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=n(4610),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((n=>{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t}},3126:e=>{var t=function(){if("object"==typeof self&&self)return self;if("object"==typeof window&&window)return window;throw new Error("Unable to resolve global `this`")};e.exports=function(){if(this)return this;if("object"==typeof globalThis&&globalThis)return globalThis;try{Object.defineProperty(Object.prototype,"__global__",{get:function(){return this},configurable:!0})}catch(e){return t()}try{return __global__||t()}finally{delete Object.prototype.__global__}}()},2337:e=>{"use strict";var t=Object.prototype.hasOwnProperty,n="~";function r(){}function i(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,r,o,s){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new i(r,o||e,s),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function a(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),a.prototype.eventNames=function(){var e,r,i=[];if(0===this._eventsCount)return i;for(r in e=this._events)t.call(e,r)&&i.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},a.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,o=r.length,s=new Array(o);i<o;i++)s[i]=r[i].fn;return s},a.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},a.prototype.emit=function(e,t,r,i,o,s){var a=n?n+e:e;if(!this._events[a])return!1;var c,u,l=this._events[a],h=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),h){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,r),!0;case 4:return l.fn.call(l.context,t,r,i),!0;case 5:return l.fn.call(l.context,t,r,i,o),!0;case 6:return l.fn.call(l.context,t,r,i,o,s),!0}for(u=1,c=new Array(h-1);u<h;u++)c[u-1]=arguments[u];l.fn.apply(l.context,c)}else{var d,f=l.length;for(u=0;u<f;u++)switch(l[u].once&&this.removeListener(e,l[u].fn,void 0,!0),h){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,t);break;case 3:l[u].fn.call(l[u].context,t,r);break;case 4:l[u].fn.call(l[u].context,t,r,i);break;default:if(!c)for(d=1,c=new Array(h-1);d<h;d++)c[d-1]=arguments[d];l[u].fn.apply(l[u].context,c)}}return!0},a.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},a.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},a.prototype.removeListener=function(e,t,r,i){var o=n?n+e:e;if(!this._events[o])return this;if(!t)return s(this,o),this;var a=this._events[o];if(a.fn)a.fn!==t||i&&!a.once||r&&a.context!==r||s(this,o);else{for(var c=0,u=[],l=a.length;c<l;c++)(a[c].fn!==t||i&&!a[c].once||r&&a[c].context!==r)&&u.push(a[c]);u.length?this._events[o]=1===u.length?u[0]:u:s(this,o)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&s(this,t)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,e.exports=a},9695:(e,t,n)=>{const{bech32:r,hex:i,utf8:o}=n(1027),s={bech32:"bc",pubKeyHash:0,scriptHash:5,validWitnessVersions:[0]},a={bech32:"tb",pubKeyHash:111,scriptHash:196,validWitnessVersions:[0]},c={bech32:"bcrt",pubKeyHash:111,scriptHash:196,validWitnessVersions:[0]},u={bech32:"sb",pubKeyHash:63,scriptHash:123,validWitnessVersions:[0]},l=["option_data_loss_protect","initial_routing_sync","option_upfront_shutdown_script","gossip_queries","var_onion_optin","gossip_queries_ex","option_static_remotekey","payment_secret","basic_mpp","option_support_large_channel"],h={m:BigInt(1e3),u:BigInt(1e6),n:BigInt(1e9),p:BigInt(1e12)},d=BigInt("2100000000000000000"),f=BigInt(1e11),p={payment_hash:1,payment_secret:16,description:13,payee:19,description_hash:23,expiry:6,min_final_cltv_expiry:24,fallback_address:9,route_hint:3,feature_bits:5,metadata:27},y={};for(let e=0,t=Object.keys(p);e<t.length;e++){const n=t[e],r=p[t[e]].toString();y[r]=n}const g={1:e=>i.encode(r.fromWordsUnsafe(e)),16:e=>i.encode(r.fromWordsUnsafe(e)),13:e=>o.encode(r.fromWordsUnsafe(e)),19:e=>i.encode(r.fromWordsUnsafe(e)),23:e=>i.encode(r.fromWordsUnsafe(e)),27:e=>i.encode(r.fromWordsUnsafe(e)),6:v,24:v,3:function(e){const t=[];let n,o,s,a,c,u=r.fromWordsUnsafe(e);for(;u.length>0;)n=i.encode(u.slice(0,33)),o=i.encode(u.slice(33,41)),s=parseInt(i.encode(u.slice(41,45)),16),a=parseInt(i.encode(u.slice(45,49)),16),c=parseInt(i.encode(u.slice(49,51)),16),u=u.slice(51),t.push({pubkey:n,short_channel_id:o,fee_base_msat:s,fee_proportional_millionths:a,cltv_expiry_delta:c});return t},5:function(e){const t=e.slice().reverse().map((e=>[!!(1&e),!!(2&e),!!(4&e),!!(8&e),!!(16&e)])).reduce(((e,t)=>e.concat(t)),[]);for(;t.length<2*l.length;)t.push(!1);const n={};l.forEach(((e,r)=>{let i;i=t[2*r]?"required":t[2*r+1]?"supported":"unsupported",n[e]=i}));const r=t.slice(2*l.length);return n.extra_bits={start_bit:2*l.length,bits:r,has_required:r.reduce(((e,t,n)=>n%2!=0?e||!1:e||t),!1)},n}};function b(e){return t=>({tagCode:parseInt(e),words:r.encode("unknown",t,Number.MAX_SAFE_INTEGER)})}function v(e){return e.reverse().reduce(((e,t,n)=>e+t*Math.pow(32,n)),0)}function w(e,t){let n,r;if(e.slice(-1).match(/^[munp]$/))n=e.slice(-1),r=e.slice(0,-1);else{if(e.slice(-1).match(/^[^munp0-9]$/))throw new Error("Not a valid multiplier for the amount");r=e}if(!r.match(/^\d+$/))throw new Error("Not a valid human readable amount");const i=BigInt(r),o=n?i*f/h[n]:i*f;if("p"===n&&i%BigInt(10)!==BigInt(0)||o>d)throw new Error("Amount is outside of valid range");return t?o.toString():o}e.exports={decode:function(e,t){if("string"!=typeof e)throw new Error("Lightning Payment Request must be string");if("ln"!==e.slice(0,2).toLowerCase())throw new Error("Not a proper lightning payment request");const n=[],o=r.decode(e,Number.MAX_SAFE_INTEGER);e=e.toLowerCase();const l=o.prefix;let h=o.words,d=e.slice(l.length+1),f=h.slice(-104);h=h.slice(0,-104);let m=l.match(/^ln(\S+?)(\d*)([a-zA-Z]?)$/);if(m&&!m[2]&&(m=l.match(/^ln(\S+)$/)),!m)throw new Error("Not a proper lightning payment request");n.push({name:"lightning_network",letters:"ln"});const _=m[1];let E;if(t){if(void 0===t.bech32||void 0===t.pubKeyHash||void 0===t.scriptHash||!Array.isArray(t.validWitnessVersions))throw new Error("Invalid network");E=t}else switch(_){case s.bech32:E=s;break;case a.bech32:E=a;break;case c.bech32:E=c;break;case u.bech32:E=u}if(!E||E.bech32!==_)throw new Error("Unknown coin bech32 prefix");n.push({name:"coin_network",letters:_,value:E});const k=m[2];let x;k?(x=w(k+m[3],!0),n.push({name:"amount",letters:m[2]+m[3],value:x})):x=null,n.push({name:"separator",letters:"1"});const S=v(h.slice(0,7));let O,C,A,T;for(h=h.slice(7),n.push({name:"timestamp",letters:d.slice(0,7),value:S}),d=d.slice(7);h.length>0;){const e=h[0].toString();O=y[e]||"unknown_tag",C=g[e]||b(e),h=h.slice(1),A=v(h.slice(0,2)),h=h.slice(2),T=h.slice(0,A),h=h.slice(A),n.push({name:O,tag:d[0],letters:d.slice(0,3+A),value:C(T)}),d=d.slice(3+A)}n.push({name:"signature",letters:d.slice(0,104),value:i.encode(r.fromWordsUnsafe(f))}),d=d.slice(104),n.push({name:"checksum",letters:d});let B={paymentRequest:e,sections:n,get expiry(){let e=n.find((e=>"expiry"===e.name));if(e)return I("timestamp")+e.value},get route_hints(){return n.filter((e=>"route_hint"===e.name)).map((e=>e.value))}};for(let e in p)"route_hint"!==e&&Object.defineProperty(B,e,{get:()=>I(e)});return B;function I(e){let t=n.find((t=>t.name===e));return t?t.value:void 0}},hrpToMillisat:w}},4610:e=>{var t=1e3,n=60*t,r=60*n,i=24*r;function o(e,t,n,r){var i=t>=1.5*n;return Math.round(e/n)+" "+r+(i?"s":"")}e.exports=function(e,s){s=s||{};var a,c,u=typeof e;if("string"===u&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var o=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(o){var s=parseFloat(o[1]);switch((o[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*s;case"weeks":case"week":case"w":return 6048e5*s;case"days":case"day":case"d":return s*i;case"hours":case"hour":case"hrs":case"hr":case"h":return s*r;case"minutes":case"minute":case"mins":case"min":case"m":return s*n;case"seconds":case"second":case"secs":case"sec":case"s":return s*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return s;default:return}}}}(e);if("number"===u&&isFinite(e))return s.long?(a=e,(c=Math.abs(a))>=i?o(a,c,i,"day"):c>=r?o(a,c,r,"hour"):c>=n?o(a,c,n,"minute"):c>=t?o(a,c,t,"second"):a+" ms"):function(e){var o=Math.abs(e);return o>=i?Math.round(e/i)+"d":o>=r?Math.round(e/r)+"h":o>=n?Math.round(e/n)+"m":o>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},2643:(e,t,n)=>{"use strict";var r,i=Object.defineProperty,o=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,c=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},u={};c(u,{Kind:()=>S,SimplePool:()=>W,finishEvent:()=>C,fj:()=>H,generatePrivateKey:()=>d,getBlankEvent:()=>O,getEventHash:()=>T,getPublicKey:()=>f,getSignature:()=>R,matchFilter:()=>j,matchFilters:()=>L,mergeFilters:()=>q,nip04:()=>fe,nip05:()=>me,nip06:()=>Oe,nip10:()=>Re,nip13:()=>Le,nip18:()=>De,nip19:()=>G,nip21:()=>ze,nip25:()=>Ge,nip26:()=>Ye,nip27:()=>rt,nip28:()=>at,nip39:()=>pt,nip42:()=>bt,nip57:()=>wt,nip98:()=>Ct,parseReferences:()=>de,relayInit:()=>V,serializeEvent:()=>A,signEvent:()=>P,utils:()=>b,validateEvent:()=>I,verifySignature:()=>N}),e.exports=(r=u,((e,t,n,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let n of s(t))a.call(e,n)||undefined===n||i(e,n,{get:()=>t[n],enumerable:!(r=o(t,n))||r.enumerable});return e})(i({},"__esModule",{value:!0}),r));var l=n(275),h=n(4099);function d(){return(0,h.bytesToHex)(l.schnorr.utils.randomPrivateKey())}function f(e){return(0,h.bytesToHex)(l.schnorr.getPublicKey(e))}var p=n(275),y=n(1581),g=n(4099),b={};c(b,{MessageNode:()=>k,MessageQueue:()=>x,insertEventIntoAscendingList:()=>E,insertEventIntoDescendingList:()=>_,normalizeURL:()=>m,utf8Decoder:()=>v,utf8Encoder:()=>w});var v=new TextDecoder("utf-8"),w=new TextEncoder;function m(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 _(e,t){let n,r=0,i=e.length-1,o=r;if(i<0)o=0;else if(t.created_at<e[i].created_at)o=i+1;else if(t.created_at>=e[r].created_at)o=r;else for(;;){if(i<=r+1){o=i;break}if(n=Math.floor(r+(i-r)/2),e[n].created_at>t.created_at)r=n;else{if(!(e[n].created_at<t.created_at)){o=n;break}i=n}}return e[o]?.id!==t.id?[...e.slice(0,o),t,...e.slice(o)]:e}function E(e,t){let n,r=0,i=e.length-1,o=r;if(i<0)o=0;else if(t.created_at>e[i].created_at)o=i+1;else if(t.created_at<=e[r].created_at)o=r;else for(;;){if(i<=r+1){o=i;break}if(n=Math.floor(r+(i-r)/2),e[n].created_at<t.created_at)r=n;else{if(!(e[n].created_at>t.created_at)){o=n;break}i=n}}return e[o]?.id!==t.id?[...e.slice(0,o),t,...e.slice(o)]:e}var k=class{_value;_next;get value(){return this._value}set value(e){this._value=e}get next(){return this._next}set next(e){this._next=e}constructor(e){this._value=e,this._next=null}},x=class{_first;_last;get first(){return this._first}set first(e){this._first=e}get last(){return this._last}set last(e){this._last=e}_size;get size(){return this._size}set size(e){this._size=e}constructor(){this._first=null,this._last=null,this._size=0}enqueue(e){const t=new k(e);return 0!==this._size&&this._last?(this._last.next=t,this._last=t):(this._first=t,this._last=t),this._size++,!0}dequeue(){if(0===this._size||!this._first)return null;let e=this._first;return this._first=e.next,e.next=null,this._size--,e.value}},S=(e=>(e[e.Metadata=0]="Metadata",e[e.Text=1]="Text",e[e.RecommendRelay=2]="RecommendRelay",e[e.Contacts=3]="Contacts",e[e.EncryptedDirectMessage=4]="EncryptedDirectMessage",e[e.EventDeletion=5]="EventDeletion",e[e.Repost=6]="Repost",e[e.Reaction=7]="Reaction",e[e.BadgeAward=8]="BadgeAward",e[e.ChannelCreation=40]="ChannelCreation",e[e.ChannelMetadata=41]="ChannelMetadata",e[e.ChannelMessage=42]="ChannelMessage",e[e.ChannelHideMessage=43]="ChannelHideMessage",e[e.ChannelMuteUser=44]="ChannelMuteUser",e[e.Blank=255]="Blank",e[e.Report=1984]="Report",e[e.ZapRequest=9734]="ZapRequest",e[e.Zap=9735]="Zap",e[e.RelayList=10002]="RelayList",e[e.ClientAuth=22242]="ClientAuth",e[e.HttpAuth=27235]="HttpAuth",e[e.ProfileBadge=30008]="ProfileBadge",e[e.BadgeDefinition=30009]="BadgeDefinition",e[e.Article=30023]="Article",e))(S||{});function O(e=255){return{kind:e,content:"",tags:[],created_at:0}}function C(e,t){let n=e;return n.pubkey=f(t),n.id=T(n),n.sig=R(n,t),n}function A(e){if(!I(e))throw new 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])}function T(e){let t=(0,y.sha256)(w.encode(A(e)));return(0,g.bytesToHex)(t)}var B=e=>e instanceof Object;function I(e){if(!B(e))return!1;if("number"!=typeof e.kind)return!1;if("string"!=typeof e.content)return!1;if("number"!=typeof e.created_at)return!1;if("string"!=typeof e.pubkey)return!1;if(!e.pubkey.match(/^[a-f0-9]{64}$/))return!1;if(!Array.isArray(e.tags))return!1;for(let t=0;t<e.tags.length;t++){let n=e.tags[t];if(!Array.isArray(n))return!1;for(let e=0;e<n.length;e++)if("object"==typeof n[e])return!1}return!0}function N(e){try{return p.schnorr.verify(e.sig,T(e),e.pubkey)}catch(e){return!1}}function P(e,t){return console.warn("nostr-tools: `signEvent` is deprecated and will be removed or changed in the future. Please use `getSignature` instead."),R(e,t)}function R(e,t){return(0,g.bytesToHex)(p.schnorr.sign(T(e),t))}function j(e,t){if(e.ids&&-1===e.ids.indexOf(t.id)&&!e.ids.some((e=>t.id.startsWith(e))))return!1;if(e.kinds&&-1===e.kinds.indexOf(t.kind))return!1;if(e.authors&&-1===e.authors.indexOf(t.pubkey)&&!e.authors.some((e=>t.pubkey.startsWith(e))))return!1;for(let n in e)if("#"===n[0]){let r=e[`#${n.slice(1)}`];if(r&&!t.tags.find((([e,t])=>e===n.slice(1)&&-1!==r.indexOf(t))))return!1}return!(e.since&&t.created_at<e.since||e.until&&t.created_at>e.until)}function L(e,t){for(let n=0;n<e.length;n++)if(j(e[n],t))return!0;return!1}function q(...e){let t={};for(let n=0;n<e.length;n++){let r=e[n];Object.entries(r).forEach((([e,n])=>{if("kinds"===e||"ids"===e||"authors"===e||"#"===e[0]){t[e]=t[e]||[];for(let r=0;r<n.length;r++){let i=n[r];t[e].includes(i)||t[e].push(i)}}})),r.limit&&(!t.limit||r.limit>t.limit)&&(t.limit=r.limit),r.until&&(!t.until||r.until>t.until)&&(t.until=r.until),r.since&&(!t.since||r.since<t.since)&&(t.since=r.since)}return t}var H={};function M(e,t){let n=t.length+3,r=e.indexOf(`"${t}":`)+n,i=e.slice(r).indexOf('"')+r+1;return e.slice(i,i+64)}function D(e,t){let n=t.length,r=e.indexOf(`"${t}":`)+n+3,i=e.slice(r),o=Math.min(i.indexOf(","),i.indexOf("}"));return parseInt(i.slice(0,o),10)}function F(e){let t=e.slice(0,22).indexOf('"EVENT"');if(-1===t)return null;let n=e.slice(t+7+1).indexOf('"');if(-1===n)return null;let r=t+7+1+n,i=e.slice(r+1,80).indexOf('"');if(-1===i)return null;let o=r+1+i;return e.slice(r+1,o)}function U(e,t){return t===M(e,"id")}function K(e,t){return t===M(e,"pubkey")}function z(e,t){return t===D(e,"kind")}c(H,{getHex64:()=>M,getInt:()=>D,getSubscriptionId:()=>F,matchEventId:()=>U,matchEventKind:()=>z,matchEventPubkey:()=>K});var $=()=>({connect:[],disconnect:[],error:[],notice:[],auth:[]});function V(e,t={}){let{listTimeout:n=3e3,getTimeout:r=3e3,countTimeout:i=3e3}=t;var o,s,a={},c=$(),u={},l={};function h(){return 1===o?.readyState}async function d(e){let t=JSON.stringify(e);if(h()||(await new Promise((e=>setTimeout(e,1e3))),h()))try{o.send(t)}catch(e){console.log(e)}}const f=(e,{verb:t="REQ",skipVerification:n=!1,alreadyHaveEvent:r=null,id:i=Math.random().toString().slice(2)}={})=>{let o=i;return a[o]={id:o,filters:e,skipVerification:n,alreadyHaveEvent:r},d([t,o,...e]),{sub:(t,i={})=>f(t||e,{skipVerification:i.skipVerification||n,alreadyHaveEvent:i.alreadyHaveEvent||r,id:o}),unsub:()=>{delete a[o],delete u[o],d(["CLOSE",o])},on:(e,t)=>{u[o]=u[o]||{event:[],count:[],eose:[]},u[o][e].push(t)},off:(e,t)=>{let n=u[o],r=n[e].indexOf(t);r>=0&&n[e].splice(r,1)}}};function p(e,t){return new Promise(((n,r)=>{if(!e.id)return void r(new Error(`event ${e} has no id`));let i=e.id;d([t,e]),l[i]={resolve:n,reject:r}}))}return{url:e,sub:f,on:(e,t)=>{c[e].push(t),"connect"===e&&1===o?.readyState&&t()},off:(e,t)=>{let n=c[e].indexOf(t);-1!==n&&c[e].splice(n,1)},list:(e,t)=>new Promise((r=>{let i=f(e,t),o=[],s=setTimeout((()=>{i.unsub(),r(o)}),n);i.on("eose",(()=>{i.unsub(),clearTimeout(s),r(o)})),i.on("event",(e=>{o.push(e)}))})),get:(e,t)=>new Promise((n=>{let i=f([e],t),o=setTimeout((()=>{i.unsub(),n(null)}),r);i.on("event",(e=>{i.unsub(),clearTimeout(o),n(e)}))})),count:e=>new Promise((t=>{let n=f(e,{...f,verb:"COUNT"}),r=setTimeout((()=>{n.unsub(),t(null)}),i);n.on("count",(e=>{n.unsub(),clearTimeout(r),t(e)}))})),async publish(e){await p(e,"EVENT")},async auth(e){await p(e,"AUTH")},connect:async function(){h()||await async function(){return s||(s=new Promise(((t,n)=>{try{o=new WebSocket(e)}catch(e){n(e)}o.onopen=()=>{c.connect.forEach((e=>e())),t()},o.onerror=()=>{s=void 0,c.error.forEach((e=>e())),n()},o.onclose=async()=>{s=void 0,c.disconnect.forEach((e=>e()))};let r,i=new x;function h(){if(0===i.size)return clearInterval(r),void(r=null);var t=i.dequeue();if(!t)return;let n=F(t);if(n){let r=a[n];if(r&&r.alreadyHaveEvent&&r.alreadyHaveEvent(M(t,"id"),e))return}try{let e=JSON.parse(t);switch(e[0]){case"EVENT":{let t=e[1],n=e[2];return void(I(n)&&a[t]&&(a[t].skipVerification||N(n))&&L(a[t].filters,n)&&(a[t],(u[t]?.event||[]).forEach((e=>e(n)))))}case"COUNT":let t=e[1],n=e[2];return void(a[t]&&(u[t]?.count||[]).forEach((e=>e(n))));case"EOSE":{let t=e[1];return void(t in u&&(u[t].eose.forEach((e=>e())),u[t].eose=[]))}case"OK":{let t=e[1],n=e[2],r=e[3]||"";if(t in l){let{resolve:e,reject:i}=l[t];n?e(null):i(new Error(r))}return}case"NOTICE":let r=e[1];return void c.notice.forEach((e=>e(r)));case"AUTH":{let t=e[1];return void c.auth?.forEach((e=>e(t)))}}}catch(e){return}}o.onmessage=e=>{i.enqueue(e.data),r||(r=setInterval(h,0))}})))}()},close(){c=$(),u={},l={},o.readyState===WebSocket.OPEN&&o?.close()},get status(){return o?.readyState??3}}}var W=class{_conn;_seenOn={};eoseSubTimeout;getTimeout;seenOnEnabled=!0;constructor(e={}){this._conn={},this.eoseSubTimeout=e.eoseSubTimeout||3400,this.getTimeout=e.getTimeout||3400,this.seenOnEnabled=!1!==e.seenOnEnabled}close(e){e.forEach((e=>{let t=this._conn[m(e)];t&&t.close()}))}async ensureRelay(e){const t=m(e);this._conn[t]||(this._conn[t]=V(t,{getTimeout:.9*this.getTimeout,listTimeout:.9*this.getTimeout}));const n=this._conn[t];return await n.connect(),n}sub(e,t,n){let r=new Set,i={...n||{}};i.alreadyHaveEvent=(e,t)=>{if(n?.alreadyHaveEvent?.(e,t))return!0;if(this.seenOnEnabled){let n=this._seenOn[e]||new Set;n.add(t),this._seenOn[e]=n}return r.has(e)};let o=[],s=new Set,a=new Set,c=e.length,u=!1,l=setTimeout((()=>{u=!0;for(let e of a.values())e()}),this.eoseSubTimeout);e.forEach((async e=>{let n;try{n=await this.ensureRelay(e)}catch(e){return void d()}if(!n)return;let h=n.sub(t,i);function d(){if(c--,0===c){clearTimeout(l);for(let e of a.values())e()}}h.on("event",(e=>{r.add(e.id);for(let t of s.values())t(e)})),h.on("eose",(()=>{u||d()})),o.push(h)}));let h={sub:(e,t)=>(o.forEach((n=>n.sub(e,t))),h),unsub(){o.forEach((e=>e.unsub()))},on(e,t){"event"===e?s.add(t):"eose"===e&&a.add(t)},off(e,t){"event"===e?s.delete(t):"eose"===e&&a.delete(t)}};return h}get(e,t,n){return new Promise((r=>{let i=this.sub(e,[t],n),o=setTimeout((()=>{i.unsub(),r(null)}),this.getTimeout);i.on("event",(e=>{r(e),clearTimeout(o),i.unsub()}))}))}list(e,t,n){return new Promise((r=>{let i=[],o=this.sub(e,t,n);o.on("event",(e=>{i.push(e)})),o.on("eose",(()=>{o.unsub(),r(i)}))}))}publish(e,t){return e.map((async e=>(await this.ensureRelay(e)).publish(t)))}seenOn(e){return Array.from(this._seenOn[e]?.values?.()||[])}},G={};c(G,{BECH32_REGEX:()=>Q,decode:()=>X,naddrEncode:()=>ce,neventEncode:()=>ae,noteEncode:()=>re,nprofileEncode:()=>se,npubEncode:()=>ne,nrelayEncode:()=>ue,nsecEncode:()=>te});var Z=n(4099),J=n(1027),Y=5e3,Q=/[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;function X(e){let{prefix:t,words:n}=J.bech32.decode(e,Y),r=new Uint8Array(J.bech32.fromWords(n));switch(t){case"nprofile":{let e=ee(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for nprofile");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:(0,Z.bytesToHex)(e[0][0]),relays:e[1]?e[1].map((e=>v.decode(e))):[]}}}case"nevent":{let e=ee(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for nevent");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");if(e[2]&&32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");return{type:"nevent",data:{id:(0,Z.bytesToHex)(e[0][0]),relays:e[1]?e[1].map((e=>v.decode(e))):[],author:e[2]?.[0]?(0,Z.bytesToHex)(e[2][0]):void 0}}}case"naddr":{let e=ee(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for naddr");if(!e[2]?.[0])throw new Error("missing TLV 2 for naddr");if(32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(!e[3]?.[0])throw new Error("missing TLV 3 for naddr");if(4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:v.decode(e[0][0]),pubkey:(0,Z.bytesToHex)(e[2][0]),kind:parseInt((0,Z.bytesToHex)(e[3][0]),16),relays:e[1]?e[1].map((e=>v.decode(e))):[]}}}case"nrelay":{let e=ee(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for nrelay");return{type:"nrelay",data:v.decode(e[0][0])}}case"nsec":case"npub":case"note":return{type:t,data:(0,Z.bytesToHex)(r)};default:throw new Error(`unknown prefix ${t}`)}}function ee(e){let t={},n=e;for(;n.length>0;){let e=n[0],r=n[1];if(!r)throw new Error(`malformed TLV ${e}`);let i=n.slice(2,2+r);if(n=n.slice(2+r),i.length<r)throw new Error(`not enough data to read on TLV ${e}`);t[e]=t[e]||[],t[e].push(i)}return t}function te(e){return oe("nsec",e)}function ne(e){return oe("npub",e)}function re(e){return oe("note",e)}function ie(e,t){let n=J.bech32.toWords(t);return J.bech32.encode(e,n,Y)}function oe(e,t){return ie(e,(0,Z.hexToBytes)(t))}function se(e){return ie("nprofile",le({0:[(0,Z.hexToBytes)(e.pubkey)],1:(e.relays||[]).map((e=>w.encode(e)))}))}function ae(e){return ie("nevent",le({0:[(0,Z.hexToBytes)(e.id)],1:(e.relays||[]).map((e=>w.encode(e))),2:e.author?[(0,Z.hexToBytes)(e.author)]:[]}))}function ce(e){let t=new ArrayBuffer(4);return new DataView(t).setUint32(0,e.kind,!1),ie("naddr",le({0:[w.encode(e.identifier)],1:(e.relays||[]).map((e=>w.encode(e))),2:[(0,Z.hexToBytes)(e.pubkey)],3:[new Uint8Array(t)]}))}function ue(e){return ie("nrelay",le({0:[w.encode(e)]}))}function le(e){let t=[];return Object.entries(e).forEach((([e,n])=>{n.forEach((n=>{let r=new Uint8Array(n.length+2);r.set([parseInt(e)],0),r.set([n.length],1),r.set(n,2),t.push(r)}))})),(0,Z.concatBytes)(...t)}var he=/\bnostr:((note|npub|naddr|nevent|nprofile)1\w+)\b|#\[(\d+)\]/g;function de(e){let t=[];for(let n of e.content.matchAll(he))if(n[2])try{let{type:e,data:r}=X(n[1]);switch(e){case"npub":t.push({text:n[0],profile:{pubkey:r,relays:[]}});break;case"nprofile":t.push({text:n[0],profile:r});break;case"note":t.push({text:n[0],event:{id:r,relays:[]}});break;case"nevent":t.push({text:n[0],event:r});break;case"naddr":t.push({text:n[0],address:r})}}catch(e){}else if(n[3]){let r=parseInt(n[3],10),i=e.tags[r];if(!i)continue;switch(i[0]){case"p":t.push({text:n[0],profile:{pubkey:i[1],relays:i[2]?[i[2]]:[]}});break;case"e":t.push({text:n[0],event:{id:i[1],relays:i[2]?[i[2]]:[]}});break;case"a":try{let[e,r,o]=i[1].split(":");t.push({text:n[0],address:{identifier:o,pubkey:r,kind:parseInt(e,10),relays:i[2]?[i[2]]:[]}})}catch(e){}}}return t}var fe={};c(fe,{decrypt:()=>ve,encrypt:()=>be});var pe=n(4099),ye=n(275),ge=n(1027);async function be(e,t,n){const r=we(ye.secp256k1.getSharedSecret(e,"02"+t));let i=Uint8Array.from((0,pe.randomBytes)(16)),o=w.encode(n),s=await crypto.subtle.importKey("raw",r,{name:"AES-CBC"},!1,["encrypt"]),a=await crypto.subtle.encrypt({name:"AES-CBC",iv:i},s,o);return`${ge.base64.encode(new Uint8Array(a))}?iv=${ge.base64.encode(new Uint8Array(i.buffer))}`}async function ve(e,t,n){let[r,i]=n.split("?iv="),o=we(ye.secp256k1.getSharedSecret(e,"02"+t)),s=await crypto.subtle.importKey("raw",o,{name:"AES-CBC"},!1,["decrypt"]),a=ge.base64.decode(r),c=ge.base64.decode(i),u=await crypto.subtle.decrypt({name:"AES-CBC",iv:c},s,a);return v.decode(u)}function we(e){return e.slice(1,33)}"undefined"!=typeof crypto&&!crypto.subtle&&crypto.webcrypto&&(crypto.subtle=crypto.webcrypto.subtle);var me={};c(me,{NIP05_REGEX:()=>Ee,queryProfile:()=>Se,searchDomain:()=>xe,useFetchImplementation:()=>ke});var _e,Ee=/^(?:([\w.+-]+)@)?([\w.-]+)$/;try{_e=fetch}catch{}function ke(e){_e=e}async function xe(e,t=""){try{return(await(await _e(`https://${e}/.well-known/nostr.json?name=${t}`)).json()).names}catch(e){return{}}}async function Se(e){const t=e.match(Ee);if(!t)return null;const[n,r="_",i]=t;try{const e=await _e(`https://${i}/.well-known/nostr.json?name=${r}`),{names:t,relays:n}=function(e){const t={names:{}};for(const[n,r]of Object.entries(e.names))"string"==typeof n&&"string"==typeof r&&(t.names[n]=r);if(e.relays){t.relays={};for(const[n,r]of Object.entries(e.relays))"string"==typeof n&&Array.isArray(r)&&(t.relays[n]=r.filter((e=>"string"==typeof e)))}return t}(await e.json()),o=t[r];return o?{pubkey:o,relays:n?.[o]}:null}catch(e){return null}}var Oe={};c(Oe,{generateSeedWords:()=>Ne,privateKeyFromSeedWords:()=>Ie,validateWords:()=>Pe});var Ce=n(4099),Ae=n(8859),Te=n(6812),Be=n(4002);function Ie(e,t){let n=Be.HDKey.fromMasterSeed((0,Te.mnemonicToSeedSync)(e,t)).derive("m/44'/1237'/0'/0/0").privateKey;if(!n)throw new Error("could not derive private key");return(0,Ce.bytesToHex)(n)}function Ne(){return(0,Te.generateMnemonic)(Ae.wordlist)}function Pe(e){return(0,Te.validateMnemonic)(e,Ae.wordlist)}var Re={};function je(e){const t={reply:void 0,root:void 0,mentions:[],profiles:[]},n=[];for(const r of e.tags)"e"===r[0]&&r[1]&&n.push(r),"p"===r[0]&&r[1]&&t.profiles.push({pubkey:r[1],relays:r[2]?[r[2]]:[]});for(let e=0;e<n.length;e++){const r=n[e],[i,o,s,a]=r,c={id:o,relays:s?[s]:[]},u=0===e,l=e===n.length-1;"root"!==a?"reply"!==a?"mention"!==a?u?t.root=c:l?t.reply=c:t.mentions.push(c):t.mentions.push(c):t.reply=c:t.root=c}return t}c(Re,{parse:()=>je});var Le={};c(Le,{getPow:()=>He});var qe=n(4099);function He(e){return function(e){let t,n,r;for(n=0,t=0;n<e.length&&(r=Me(e[n]),t+=r,8===r);n++);return t}((0,qe.hexToBytes)(e))}function Me(e){let t=0;if(0===e)return 8;for(;e>>=1;)t++;return 7-t}var De={};function Fe(e,t,n,r){return C({kind:6,tags:[...e.tags??[],["e",t.id,n],["p",t.pubkey]],content:""===e.content?"":JSON.stringify(t),created_at:e.created_at},r)}function Ue(e){if(6!==e.kind)return;let t,n;for(let r=e.tags.length-1;r>=0&&(void 0===t||void 0===n);r--){const i=e.tags[r];i.length>=2&&("e"===i[0]&&void 0===t?t=i:"p"===i[0]&&void 0===n&&(n=i))}return void 0!==t?{id:t[1],relays:[t[2],n?.[2]].filter((e=>"string"==typeof e)),author:n?.[1]}:void 0}function Ke(e,{skipVerification:t}={}){const n=Ue(e);if(void 0===n||""===e.content)return;let r;try{r=JSON.parse(e.content)}catch(e){return}return r.id===n.id&&(t||N(r))?r:void 0}c(De,{finishRepostEvent:()=>Fe,getRepostedEvent:()=>Ke,getRepostedEventPointer:()=>Ue});var ze={};c(ze,{NOSTR_URI_REGEX:()=>$e,parse:()=>We,test:()=>Ve});var $e=new RegExp(`nostr:(${Q.source})`);function Ve(e){return"string"==typeof e&&new RegExp(`^${$e.source}$`).test(e)}function We(e){const t=e.match(new RegExp(`^${$e.source}$`));if(!t)throw new Error(`Invalid Nostr URI: ${e}`);return{uri:t[0],value:t[1],decoded:X(t[1])}}var Ge={};function Ze(e,t,n){const r=t.tags.filter((e=>e.length>=2&&("e"===e[0]||"p"===e[0])));return C({...e,kind:7,tags:[...e.tags??[],...r,["e",t.id],["p",t.pubkey]],content:e.content??"+"},n)}function Je(e){if(7!==e.kind)return;let t,n;for(let r=e.tags.length-1;r>=0&&(void 0===t||void 0===n);r--){const i=e.tags[r];i.length>=2&&("e"===i[0]&&void 0===t?t=i:"p"===i[0]&&void 0===n&&(n=i))}return void 0!==t&&void 0!==n?{id:t[1],relays:[t[2],n[2]].filter((e=>void 0!==e)),author:n[1]}:void 0}c(Ge,{finishReactionEvent:()=>Ze,getReactedEventPointer:()=>Je});var Ye={};c(Ye,{createDelegation:()=>tt,getDelegator:()=>nt});var Qe=n(275),Xe=n(4099),et=n(1581);function tt(e,t){let n=[];(t.kind||-1)>=0&&n.push(`kind=${t.kind}`),t.until&&n.push(`created_at<${t.until}`),t.since&&n.push(`created_at>${t.since}`);let r=n.join("&");if(""===r)throw new Error("refusing to create a delegation without any conditions");let i=(0,et.sha256)(w.encode(`nostr:delegation:${t.pubkey}:${r}`)),o=(0,Xe.bytesToHex)(Qe.schnorr.sign(i,e));return{from:f(e),to:t.pubkey,cond:r,sig:o}}function nt(e){let t=e.tags.find((e=>"delegation"===e[0]&&e.length>=4));if(!t)return null;let n=t[1],r=t[2],i=t[3],o=r.split("&");for(let t=0;t<o.length;t++){let[n,r,i]=o[t].split(/\b/);if(("kind"!==n||"="!==r||e.kind!==parseInt(i))&&!("created_at"===n&&"<"===r&&e.created_at<parseInt(i)||"created_at"===n&&">"===r&&e.created_at>parseInt(i)))return null}let s=(0,et.sha256)(w.encode(`nostr:delegation:${e.pubkey}:${r}`));return Qe.schnorr.verify(i,s,n)?n:null}var rt={};c(rt,{matchAll:()=>ot,regex:()=>it,replaceAll:()=>st});var it=()=>new RegExp(`\\b${$e.source}\\b`,"g");function*ot(e){const t=e.matchAll(it());for(const e of t)try{const[t,n]=e;yield{uri:t,value:n,decoded:X(n),start:e.index,end:e.index+t.length}}catch(e){}}function st(e,t){return e.replaceAll(it(),((e,n)=>t({uri:e,value:n,decoded:X(n)})))}var at={};c(at,{channelCreateEvent:()=>ut,channelHideMessageEvent:()=>dt,channelMessageEvent:()=>ht,channelMetadataEvent:()=>lt,channelMuteUserEvent:()=>ft});var ct,ut=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return C({kind:40,tags:[...e.tags??[]],content:n,created_at:e.created_at},t)},lt=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return C({kind:41,tags:[["e",e.channel_create_event_id],...e.tags??[]],content:n,created_at:e.created_at},t)},ht=(e,t)=>{const n=[["e",e.channel_create_event_id,e.relay_url,"root"]];return e.reply_to_channel_message_event_id&&n.push(["e",e.reply_to_channel_message_event_id,e.relay_url,"reply"]),C({kind:42,tags:[...n,...e.tags??[]],content:e.content,created_at:e.created_at},t)},dt=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return C({kind:43,tags:[["e",e.channel_message_event_id],...e.tags??[]],content:n,created_at:e.created_at},t)},ft=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return C({kind:44,tags:[["p",e.pubkey_to_mute],...e.tags??[]],content:n,created_at:e.created_at},t)},pt={};c(pt,{useFetchImplementation:()=>yt,validateGithub:()=>gt});try{ct=fetch}catch{}function yt(e){ct=e}async function gt(e,t,n){try{return await(await ct(`https://gist.github.com/${t}/${n}/raw`)).text()===`Verifying that I control the following Nostr public key: ${e}`}catch(e){return!1}}var bt={};c(bt,{authenticate:()=>vt});var vt=async({challenge:e,relay:t,sign:n})=>{const r={kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t.url],["challenge",e]],content:""};return t.auth(await n(r))},wt={};c(wt,{getZapEndpoint:()=>kt,makeZapReceipt:()=>Ot,makeZapRequest:()=>xt,useFetchImplementation:()=>Et,validateZapRequest:()=>St});var mt,_t=n(1027);try{mt=fetch}catch{}function Et(e){mt=e}async function kt(e){try{let t="",{lud06:n,lud16:r}=JSON.parse(e.content);if(n){let{words:e}=_t.bech32.decode(n,1e3),r=_t.bech32.fromWords(e);t=v.decode(r)}else{if(!r)return null;{let[e,n]=r.split("@");t=`https://${n}/.well-known/lnurlp/${e}`}}let i=await mt(t),o=await i.json();if(o.allowsNostr&&o.nostrPubkey)return o.callback}catch(e){}return null}function xt({profile:e,event:t,amount:n,relays:r,comment:i=""}){if(!n)throw new Error("amount not given");if(!e)throw new Error("profile not given");let o={kind:9734,created_at:Math.round(Date.now()/1e3),content:i,tags:[["p",e],["amount",n.toString()],["relays",...r]]};return t&&o.tags.push(["e",t]),o}function St(e){let t;try{t=JSON.parse(e)}catch(e){return"Invalid zap request JSON."}if(!I(t))return"Zap request is not a valid Nostr event.";if(!N(t))return"Invalid signature on zap request.";let n=t.tags.find((([e,t])=>"p"===e&&t));if(!n)return"Zap request doesn't have a 'p' tag.";if(!n[1].match(/^[a-f0-9]{64}$/))return"Zap request 'p' tag is not valid hex.";let r=t.tags.find((([e,t])=>"e"===e&&t));return r&&!r[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 Ot({zapRequest:e,preimage:t,bolt11:n,paidAt:r}){let i=JSON.parse(e).tags.filter((([e])=>"e"===e||"p"===e||"a"===e)),o={kind:9735,created_at:Math.round(r.getTime()/1e3),content:"",tags:[...i,["bolt11",n],["description",e]]};return t&&o.tags.push(["preimage",t]),o}var Ct={};c(Ct,{getToken:()=>Bt,validateToken:()=>It});var At=n(1027),Tt="Nostr ";async function Bt(e,t,n,r=!1){if(!e||!t)throw new Error("Missing loginUrl or httpMethod");if("get"!==t&&"post"!==t)throw new Error("Unknown httpMethod");const i=O(27235);i.tags=[["u",e],["method",t]],i.created_at=Math.round((new Date).getTime()/1e3);const o=await n(i);return(r?Tt:"")+At.base64.encode(w.encode(JSON.stringify(o)))}async function It(e,t,n){if(!e)throw new Error("Missing token");e=e.replace(Tt,"");const r=v.decode(At.base64.decode(e));if(!r||0===r.length||!r.startsWith("{"))throw new Error("Invalid token");const i=JSON.parse(r);if(!i)throw new Error("Invalid nostr event");if(!N(i))throw new Error("Invalid nostr event, signature invalid");if(27235!==i.kind)throw new Error("Invalid nostr event, kind invalid");if(!i.created_at)throw new Error("Invalid nostr event, created_at invalid");if(Math.round((new Date).getTime()/1e3)-i.created_at>60)throw new Error("Invalid nostr event, expired");const o=i.tags.find((e=>"u"===e[0]));if(1!==o?.length&&o?.[1]!==t)throw new Error("Invalid nostr event, url tag invalid");const s=i.tags.find((e=>"method"===e[0]));if(1!==s?.length&&s?.[1].toLowerCase()!==n.toLowerCase())throw new Error("Invalid nostr event, method tag invalid");return!0}},3064:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.createHighlight=void 0;const i=n(9890);t.createHighlight=function(e,t,n,o){return r(this,void 0,void 0,(function*(){const r=new i.NDKEvent(e,{kind:9802,content:t});return n&&r.tags.push(["r",n]),o&&r.tags.push(...o.map((e=>["t",e]))),console.log("created",yield r.toNostrEvent()),yield r.sign(),yield r.publish(),r}))}},6045:function(e,t){"use strict";var n=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.addEventToList=void 0,t.addEventToList=function(e,t,r,i=!1){var o;return n(this,void 0,void 0,(function*(){const n=yield null===(o=e.signer)||void 0===o?void 0:o.user();if(!n)throw new Error("User not found");const s={kinds:[30001],"#d":[t],authors:[n.hexpubkey()]},a=yield e.fetchEvent(s);if(a){if(a.created_at=Math.floor(Date.now()/1e3),i){let e=[];a.content.length>0&&(yield a.decrypt(n),console.log("decrypted",a.content),e=JSON.parse(a.content)),e.push(r.tagReference()),a.content=JSON.stringify(e),yield a.encrypt(n),console.log("encrypted",a.rawEvent())}else a.tag(r);yield a.sign(),yield a.publish()}}))}},2768:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.runWithNDK=t.publishingNDK=t.publishingRelays=void 0;const o=i(n(9890)),s=n(9890),a=["wss://relay.nsecbunker.com"];let c,u;t.publishingRelays=["wss://relay.snort.social","wss://relay.f7z.io","wss://relay.damus.io"],chrome.storage.sync.get(["relays"],(({relays:e})=>{e&&(t.publishingRelays=e.split(/(,|\n)+/).map((e=>e.trim())).filter((e=>e)),t.publishingNDK=new o.default({explicitRelayUrls:t.publishingRelays}),t.publishingNDK.connect(2500))}));let l={npub:"",pk:""};function h(e,t){var n;return r(this,void 0,void 0,(function*(){return e&&(null===(n=e.signer)||void 0===n?void 0:n.user)&&0!==e.pool.stats().connected||(e=new o.default({explicitRelayUrls:t}),yield e.connect(2500)),e}))}t.runWithNDK=function(e){var n,i;return r(this,void 0,void 0,(function*(){yield Promise.all([(()=>r(this,void 0,void 0,(function*(){c=yield h(c,a)})))(),(()=>r(this,void 0,void 0,(function*(){t.publishingNDK=yield h(t.publishingNDK,t.publishingRelays)})))()]),(null===(n=t.publishingNDK.signer)||void 0===n?void 0:n.user)?(console.log("publishing signer is already present",!!e),e&&e(t.publishingNDK)):(null===(i=c.signer)||void 0===i?void 0:i.user)||chrome.storage.sync.get(["npub","pk","relays"],(({npub:n,pk:i,relays:o})=>r(this,void 0,void 0,(function*(){if(l.npub=n,i?(console.log("pk is present",{pk:i}),u=new s.NDKPrivateKeySigner(i)):(u=s.NDKPrivateKeySigner.generate(),chrome.storage.sync.set({pk:u.privateKey},(()=>{l.pk=u.privateKey}))),n){if(o){const e=o.split(/(,|\n)+/).map((e=>e.trim()));t.publishingNDK=yield h(void 0,e)}t.publishingNDK.signer=new s.NDKNip46Signer(c,n,u),t.publishingNDK.signer.blockUntilReady().then((n=>r(this,void 0,void 0,(function*(){var r;console.log("publishing signer is ready",{user:n});const i=yield null===(r=t.publishingNDK.signer)||void 0===r?void 0:r.user();i?(chrome.storage.sync.set({npub:i.npub},(()=>{l.npub=i.npub})),e&&e(t.publishingNDK)):console.log("no remote user")}))))}}))))}))}},9080:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.showAppOrSettings=t.showApp=t.showSettings=void 0;const r=n(2768);function i(){document.getElementById("app").style.display="none",document.getElementById("settings").style.display="block"}function o(){document.getElementById("app").style.display="block",document.getElementById("settings").style.display="none",chrome.storage.sync.get(["npub"],(({npub:e})=>{document.getElementById("npub").innerText=e}))}t.showSettings=i,t.showApp=o,t.showAppOrSettings=function(){chrome.storage.sync.get(["npub","relays"],(({npub:e,relays:t})=>{e?o():i()}))},document.getElementById("settings-save").addEventListener("click",(()=>{const e=document.getElementById("npubField").value,t=document.getElementById("relays").value;chrome.storage.sync.set({npub:e,relays:t},(()=>{window.location.reload(),o()}))})),document.getElementById("openSettings").addEventListener("click",(()=>{i()})),document.getElementById("closeSettings").addEventListener("click",(()=>{o()})),document.addEventListener("DOMContentLoaded",(()=>{chrome.storage.sync.get(["npub","relays"],(({npub:e,relays:t})=>{document.getElementById("npubField").value=e||"",document.getElementById("relays").value=t||r.publishingRelays.join("\n"),document.getElementById("npub").innerText=e}))}))},2407:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const i=n(9890),o=n(2768),s=n(9080),a=n(3064),c=n(6045);let u="",l="",h=null;function d(){const e=o.publishingNDK.pool.stats();document.getElementById("totalConnected").innerHTML=JSON.stringify(e),document.getElementById("totalConnected").innerHTML=`Connected to ${e.connected} relays`}function f(){return r(this,void 0,void 0,(function*(){const e=document.body.querySelector("#lists");(0,o.runWithNDK)((t=>r(this,void 0,void 0,(function*(){var n;const r=document.body.querySelector("#npub"),i=yield null===(n=t.signer)||void 0===n?void 0:n.user();i?(r.innerText=(null==i?void 0:i.npub)||"no npub",t.subscribe({kinds:[30001],authors:[i.hexpubkey()]}).on("event",(t=>{var n;const r=t.tagValue("d");if(!r)return;if(e.querySelector(`option[value="${r}"]`))return;const i=document.createElement("option");i.innerText=null!==(n=t.tagValue("name"))&&void 0!==n?n:r,i.value=r,e.appendChild(i)}))):r.innerText="no user"}))))}))}function p(){document.body.querySelector("#highlight-container").style.display="none"}function y({url:e,title:t}){u=e,l=t,document.body.querySelector("#url1").innerText=e,document.body.querySelector("#url2").innerText=e}document.addEventListener("DOMContentLoaded",(()=>{(0,s.showAppOrSettings)(),p(),chrome.tabs.query({active:!0,currentWindow:!0},(function(e){y({url:e[0].url,title:e[0].title})})),(0,o.runWithNDK)(),setTimeout(f,1e3),setInterval(d,1e3)})),document.getElementById("save").addEventListener("click",(()=>{const e=document.body.querySelector("#comment"),t=e.value.trim(),n=document.body.querySelector("#lists").value;(0,o.runWithNDK)((o=>r(void 0,void 0,void 0,(function*(){var r;if(h){const e=yield(0,a.createHighlight)(o,h,u,document.body.querySelector("#tags").value.split(",").map((e=>e.trim())).filter((e=>e.length>0)));let r=e;if(t.length>0){const n=new i.NDKEvent(o,{content:`nostr:${e.encode()}\n`+t,kind:1,tags:[["q",e.tagId(),"quote"],["k","9802"]]});yield n.sign(),yield n.publish(),r=n}n.length>0&&(0,c.addEventToList)(o,n,r)}else{if(!n||0===n.length)return void alert("Please select a list");const s=yield null===(r=o.signer)||void 0===r?void 0:r.user(),a=[u];l&&l.length>0&&a.push(l),t.length>0&&a.push(t),console.log("content",a);const h=new i.NDKEvent(o,{kind:4,content:a.join("\n\n")});h.tag(s),yield h.encrypt(s),yield h.publish(),yield(0,c.addEventToList)(o,n,h,!0),e.value=""}}))))})),chrome.runtime.onMessage.addListener((({name:e,data:t})=>r(void 0,void 0,void 0,(function*(){switch(f(),e){case"new-highlight":h=t.value,t?function({value:e}){document.body.querySelector("#highlight-container").style.display="flex",document.body.querySelector("#highlight").innerText=e,document.body.querySelector("#bookmark-container").style.display="none"}(t):p();break;case"new-url":document.body.querySelector("#bookmark-container").style.display="flex",p(),y(t)}}))))},9863:function(e,t,n){"use strict";var r=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.Container=void 0;var i=n(2850),o=function(){function e(){}return e.prototype.empty=function(){return 0===this.size()},e.prototype.rbegin=function(){return this.end().reverse()},e.prototype.rend=function(){return this.begin().reverse()},e.prototype[Symbol.iterator]=function(){return new i.ForOfAdaptor(this.begin(),this.end())},e.prototype.toJSON=function(){var e,t,n=[];try{for(var i=r(this),o=i.next();!o.done;o=i.next()){var s=o.value;n.push(s)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}return n},e}();t.Container=o},141:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.MapContainer=void 0;var o=n(9863),s=n(8766),a=function(e){function t(t){var n=e.call(this)||this;return n.data_=t(n),n}return i(t,e),t.prototype.assign=function(e,t){this.clear(),this.insert(e,t)},t.prototype.clear=function(){this.data_.clear()},t.prototype.begin=function(){return this.data_.begin()},t.prototype.end=function(){return this.data_.end()},t.prototype.has=function(e){return!this.find(e).equals(this.end())},t.prototype.size=function(){return this.data_.size()},t.prototype.push=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=new s.NativeArrayIterator(e,0),r=new s.NativeArrayIterator(e,e.length);return this.insert(n,r),this.size()},t.prototype.insert=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 1===e.length?this.emplace(e[0].first,e[0].second):e[0].next instanceof Function&&e[1].next instanceof Function?this._Insert_by_range(e[0],e[1]):this.emplace_hint(e[0],e[1].first,e[1].second)},t.prototype.erase=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 1!==e.length||e[0]instanceof this.end().constructor!=0&&e[0].source()===this?1===e.length?this._Erase_by_range(e[0]):this._Erase_by_range(e[0],e[1]):this._Erase_by_key(e[0])},t.prototype._Erase_by_range=function(e,t){void 0===t&&(t=e.next());var n=this.data_.erase(e,t);return this._Handle_erase(e,t),n},t}(o.Container);t.MapContainer=a},684:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.SetContainer=void 0;var o=n(9863),s=n(8766),a=function(e){function t(t){var n=e.call(this)||this;return n.data_=t(n),n}return i(t,e),t.prototype.assign=function(e,t){this.clear(),this.insert(e,t)},t.prototype.clear=function(){this.data_.clear()},t.prototype.begin=function(){return this.data_.begin()},t.prototype.end=function(){return this.data_.end()},t.prototype.has=function(e){return!this.find(e).equals(this.end())},t.prototype.size=function(){return this.data_.size()},t.prototype.push=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(0===e.length)return this.size();var n=new s.NativeArrayIterator(e,0),r=new s.NativeArrayIterator(e,e.length);return this._Insert_by_range(n,r),this.size()},t.prototype.insert=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 1===e.length?this._Insert_by_key(e[0]):e[0].next instanceof Function&&e[1].next instanceof Function?this._Insert_by_range(e[0],e[1]):this._Insert_by_hint(e[0],e[1])},t.prototype.erase=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 1!==e.length||e[0]instanceof this.end().constructor&&e[0].source()===this?1===e.length?this._Erase_by_range(e[0]):this._Erase_by_range(e[0],e[1]):this._Erase_by_val(e[0])},t.prototype._Erase_by_range=function(e,t){void 0===t&&(t=e.next());var n=this.data_.erase(e,t);return this._Handle_erase(e,t),n},t}(o.Container);t.SetContainer=a},22:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},s=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.UniqueMap=void 0;var a=n(141),c=n(2018),u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.count=function(e){return this.find(e).equals(this.end())?0:1},t.prototype.get=function(e){var t=this.find(e);if(!0===t.equals(this.end()))throw c.ErrorGenerator.key_nout_found(this,"get",e);return t.second},t.prototype.take=function(e,t){var n=this.find(e);return n.equals(this.end())?this.emplace(e,t()).first.second:n.second},t.prototype.set=function(e,t){this.insert_or_assign(e,t)},t.prototype.insert=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e.prototype.insert.apply(this,s([],o(t),!1))},t.prototype._Insert_by_range=function(e,t){for(var n=e;!n.equals(t);n=n.next())this.emplace(n.value.first,n.value.second)},t.prototype.insert_or_assign=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 2===e.length?this._Insert_or_assign_with_key_value(e[0],e[1]):3===e.length?this._Insert_or_assign_with_hint(e[0],e[1],e[2]):void 0},t.prototype._Insert_or_assign_with_key_value=function(e,t){var n=this.emplace(e,t);return!1===n.second&&(n.first.second=t),n},t.prototype._Insert_or_assign_with_hint=function(e,t,n){var r=this.emplace_hint(e,t,n);return r.second!==n&&(r.second=n),r},t.prototype.extract=function(e){return e instanceof this.end().constructor?this._Extract_by_iterator(e):this._Extract_by_key(e)},t.prototype._Extract_by_key=function(e){var t=this.find(e);if(!0===t.equals(this.end()))throw c.ErrorGenerator.key_nout_found(this,"extract",e);var n=t.value;return this._Erase_by_range(t),n},t.prototype._Extract_by_iterator=function(e){return!0===e.equals(this.end())?this.end():(this._Erase_by_range(e),e)},t.prototype._Erase_by_key=function(e){var t=this.find(e);return!0===t.equals(this.end())?0:(this._Erase_by_range(t),1)},t.prototype.merge=function(e){for(var t=e.begin();!t.equals(e.end());)!1===this.has(t.first)?(this.insert(t.value),t=e.erase(t)):t=t.next()},t}(a.MapContainer);t.UniqueMap=u},8053:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},s=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.UniqueSet=void 0;var a=n(684),c=n(2018),u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.count=function(e){return this.find(e).equals(this.end())?0:1},t.prototype.insert=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e.prototype.insert.apply(this,s([],o(t),!1))},t.prototype._Insert_by_range=function(e,t){for(;!e.equals(t);e=e.next())this._Insert_by_key(e.value)},t.prototype.extract=function(e){return e instanceof this.end().constructor?this._Extract_by_iterator(e):this._Extract_by_val(e)},t.prototype._Extract_by_val=function(e){var t=this.find(e);if(!0===t.equals(this.end()))throw c.ErrorGenerator.key_nout_found(this,"extract",e);return this._Erase_by_range(t),e},t.prototype._Extract_by_iterator=function(e){return!0===e.equals(this.end())||!1===this.has(e.value)?this.end():(this._Erase_by_range(e),e)},t.prototype._Erase_by_val=function(e){var t=this.find(e);return!0===t.equals(this.end())?0:(this._Erase_by_range(t),1)},t.prototype.merge=function(e){for(var t=e.begin();!t.equals(e.end());)!1===this.has(t.value)?(this.insert(t.value),t=e.erase(t)):t=t.next()},t}(a.SetContainer);t.UniqueSet=u},508:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},s=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.HashMap=void 0;var a=n(22),c=n(483),u=n(4892),l=n(9558),h=n(6249),d=n(5610),f=function(e){function t(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var i=e.call(this,(function(e){return new u.MapElementList(e)}))||this;return c.IHashContainer.construct.apply(c.IHashContainer,s([i,t,function(e,t){i.buckets_=new l.MapHashBuckets(i,e,t)}],o(n),!1)),i}return i(t,e),t.prototype.clear=function(){this.buckets_.clear(),e.prototype.clear.call(this)},t.prototype.swap=function(e){var t,n;t=o([e.data_,this.data_],2),this.data_=t[0],e.data_=t[1],u.MapElementList._Swap_associative(this.data_,e.data_),l.MapHashBuckets._Swap_source(this.buckets_,e.buckets_),n=o([e.buckets_,this.buckets_],2),this.buckets_=n[0],e.buckets_=n[1]},t.prototype.find=function(e){return this.buckets_.find(e)},t.prototype.begin=function(t){return void 0===t&&(t=null),null===t?e.prototype.begin.call(this):this.buckets_.at(t)[0]},t.prototype.end=function(t){if(void 0===t&&(t=null),null===t)return e.prototype.end.call(this);var n=this.buckets_.at(t);return n[n.length-1].next()},t.prototype.rbegin=function(e){return void 0===e&&(e=null),this.end(e).reverse()},t.prototype.rend=function(e){return void 0===e&&(e=null),this.begin(e).reverse()},t.prototype.bucket_count=function(){return this.buckets_.length()},t.prototype.bucket_size=function(e){return this.buckets_.at(e).length},t.prototype.load_factor=function(){return this.buckets_.load_factor()},t.prototype.hash_function=function(){return this.buckets_.hash_function()},t.prototype.key_eq=function(){return this.buckets_.key_eq()},t.prototype.bucket=function(e){return this.hash_function()(e)%this.buckets_.length()},t.prototype.max_load_factor=function(e){return void 0===e&&(e=null),this.buckets_.max_load_factor(e)},t.prototype.reserve=function(e){this.buckets_.reserve(e)},t.prototype.rehash=function(e){this.buckets_.rehash(e)},t.prototype.emplace=function(e,t){var n=this.find(e);return!1===n.equals(this.end())?new d.Pair(n,!1):(this.data_.push(new h.Entry(e,t)),n=n.prev(),this._Handle_insert(n,n.next()),new d.Pair(n,!0))},t.prototype.emplace_hint=function(e,t,n){var r=this.find(t);return!0===r.equals(this.end())&&(r=this.data_.insert(e,new h.Entry(t,n)),this._Handle_insert(r,r.next())),r},t.prototype._Handle_insert=function(e,t){for(;!e.equals(t);e=e.next())this.buckets_.insert(e)},t.prototype._Handle_erase=function(e,t){for(;!e.equals(t);e=e.next())this.buckets_.erase(e)},t}(a.UniqueMap);t.HashMap=f,function(e){e.Iterator=u.MapElementList.Iterator,e.ReverseIterator=u.MapElementList.ReverseIterator}(f=t.HashMap||(t.HashMap={})),t.HashMap=f},2810:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},s=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.HashSet=void 0;var a=n(8053),c=n(483),u=n(6827),l=n(5779),h=n(5610),d=function(e){function t(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var i=e.call(this,(function(e){return new u.SetElementList(e)}))||this;return c.IHashContainer.construct.apply(c.IHashContainer,s([i,t,function(e,t){i.buckets_=new l.SetHashBuckets(i,e,t)}],o(n),!1)),i}return i(t,e),t.prototype.clear=function(){this.buckets_.clear(),e.prototype.clear.call(this)},t.prototype.swap=function(e){var t,n;t=o([e.data_,this.data_],2),this.data_=t[0],e.data_=t[1],u.SetElementList._Swap_associative(this.data_,e.data_),l.SetHashBuckets._Swap_source(this.buckets_,e.buckets_),n=o([e.buckets_,this.buckets_],2),this.buckets_=n[0],e.buckets_=n[1]},t.prototype.find=function(e){return this.buckets_.find(e)},t.prototype.begin=function(t){return void 0===t&&(t=null),null===t?e.prototype.begin.call(this):this.buckets_.at(t)[0]},t.prototype.end=function(t){if(void 0===t&&(t=null),null===t)return e.prototype.end.call(this);var n=this.buckets_.at(t);return n[n.length-1].next()},t.prototype.rbegin=function(e){return void 0===e&&(e=null),this.end(e).reverse()},t.prototype.rend=function(e){return void 0===e&&(e=null),this.begin(e).reverse()},t.prototype.bucket_count=function(){return this.buckets_.length()},t.prototype.bucket_size=function(e){return this.buckets_.at(e).length},t.prototype.load_factor=function(){return this.buckets_.load_factor()},t.prototype.hash_function=function(){return this.buckets_.hash_function()},t.prototype.key_eq=function(){return this.buckets_.key_eq()},t.prototype.bucket=function(e){return this.hash_function()(e)%this.buckets_.length()},t.prototype.max_load_factor=function(e){return void 0===e&&(e=null),this.buckets_.max_load_factor(e)},t.prototype.reserve=function(e){this.buckets_.reserve(e)},t.prototype.rehash=function(e){this.buckets_.rehash(e)},t.prototype._Insert_by_key=function(e){var t=this.find(e);return!1===t.equals(this.end())?new h.Pair(t,!1):(this.data_.push(e),t=t.prev(),this._Handle_insert(t,t.next()),new h.Pair(t,!0))},t.prototype._Insert_by_hint=function(e,t){var n=this.find(t);return!0===n.equals(this.end())&&(n=this.data_.insert(e,t),this._Handle_insert(n,n.next())),n},t.prototype._Handle_insert=function(e,t){for(;!e.equals(t);e=e.next())this.buckets_.insert(e)},t.prototype._Handle_erase=function(e,t){for(;!e.equals(t);e=e.next())this.buckets_.erase(e)},t}(a.UniqueSet);t.HashSet=d,function(e){e.Iterator=u.SetElementList.Iterator,e.ReverseIterator=u.SetElementList.ReverseIterator}(d=t.HashSet||(t.HashSet={})),t.HashSet=d},4718:function(e,t){"use strict";var n,r=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.Exception=void 0;var i=function(e){function t(t){var n=this.constructor,r=e.call(this,t)||this,i=n.prototype;return Object.setPrototypeOf?Object.setPrototypeOf(r,i):r.__proto__=i,r}return r(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return this.constructor.name},enumerable:!1,configurable:!0}),t.prototype.what=function(){return this.message},t.prototype.toJSON=function(){return{name:this.name,message:this.message,stack:this.stack}},t}(Error);t.Exception=i},8521:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.InvalidArgument=void 0;var o=function(e){function t(t){return e.call(this,t)||this}return i(t,e),t}(n(6761).LogicError);t.InvalidArgument=o},6761:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.LogicError=void 0;var o=function(e){function t(t){return e.call(this,t)||this}return i(t,e),t}(n(4718).Exception);t.LogicError=o},334:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.OutOfRange=void 0;var o=function(e){function t(t){return e.call(this,t)||this}return i(t,e),t}(n(6761).LogicError);t.OutOfRange=o},9284:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.greater_equal=t.greater=t.less_equal=t.less=t.not_equal_to=t.equal_to=void 0;var r=n(9783);function i(e,t){return e=e?e.valueOf():e,t=t?t.valueOf():t,e instanceof Object&&e.equals instanceof Function?e.equals(t):e===t}function o(e,t){return e=e.valueOf(),t=t.valueOf(),e instanceof Object?e.less instanceof Function?e.less(t):(0,r.get_uid)(e)<(0,r.get_uid)(t):e<t}function s(e,t){return o(e,t)||i(e,t)}t.equal_to=i,t.not_equal_to=function(e,t){return!i(e,t)},t.less=o,t.less_equal=s,t.greater=function(e,t){return!s(e,t)},t.greater_equal=function(e,t){return!o(e,t)}},3425:function(e,t,n){"use strict";var r=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.hash=void 0;var i=n(9783);function o(e,t){return(t^=e?1:0)*u}function s(e,t){return a(e.toString(),t)}function a(e,t){for(var n=0;n<e.length;++n)t^=e.charCodeAt(n),t*=u;return Math.abs(t)}t.hash=function(){for(var e,t,n=[],l=0;l<arguments.length;l++)n[l]=arguments[l];var h=c;try{for(var d=r(n),f=d.next();!f.done;f=d.next()){var p=f.value,y=typeof(p=p?p.valueOf():p);if("boolean"===y)h=o(p,h);else if("number"===y||"bigint"===y)h=s(p,h);else if("string"===y)h=a(p,h);else if(p instanceof Object&&p.hashCode instanceof Function){var g=p.hashCode();if(1===n.length)return g;h^=g,h*=u}else h=s((0,i.get_uid)(p),h)}}catch(t){e={error:t}}finally{try{f&&!f.done&&(t=d.return)&&t.call(d)}finally{if(e)throw e.error}}return Math.abs(h)};var c=2166136261,u=16777619},9783:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.get_uid=void 0;var r=n(1414);t.get_uid=function(e){if(e instanceof Object){if(!1===e.hasOwnProperty("__get_m_iUID")){var t=++(0,r._Get_root)().__s_iUID;Object.defineProperty(e,"__get_m_iUID",{value:function(){return t}})}return e.__get_m_iUID()}return void 0===e?-1:0}},1414:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t._Get_root=void 0;var r=n(3362);t._Get_root=function(){return null===i&&void 0===(i=(0,r.is_node)()?n.g:self).__s_iUID&&(i.__s_iUID=0),i};var i=null},1843:function(e,t){"use strict";var n=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},r=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.IAssociativeContainer=void 0,(t.IAssociativeContainer||(t.IAssociativeContainer={})).construct=function(e){for(var t,i,o=[],s=1;s<arguments.length;s++)o[s-1]=arguments[s];return o.length>=1&&o[0]instanceof Array?(t=function(){var t=o[0];e.push.apply(e,r([],n(t),!1))},i=o.slice(1)):o.length>=2&&o[0].next instanceof Function&&o[1].next instanceof Function?(t=function(){var t=o[0],n=o[1];e.assign(t,n)},i=o.slice(2)):(t=null,i=o),{ramda:t,tail:i}}},483:function(e,t,n){"use strict";var r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.IHashContainer=void 0;var o=n(1843),s=n(3425),a=n(9284);(t.IHashContainer||(t.IHashContainer={})).construct=function(e,t,n){for(var c=[],u=3;u<arguments.length;u++)c[u-3]=arguments[u];var l=null,h=s.hash,d=a.equal_to;if(1===c.length&&c[0]instanceof t){var f=c[0];h=f.hash_function(),d=f.key_eq(),l=function(){var t=f.begin(),n=f.end();e.assign(t,n)}}else{var p=o.IAssociativeContainer.construct.apply(o.IAssociativeContainer,i([e],r(c),!1));l=p.ramda,p.tail.length>=1&&(h=p.tail[0]),p.tail.length>=2&&(d=p.tail[1])}n(h,d),null!==l&&l()}},4892:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s};Object.defineProperty(t,"__esModule",{value:!0}),t.MapElementList=void 0;var s=n(4286),a=n(5231),c=n(3282),u=function(e){function t(t){var n=e.call(this)||this;return n.associative_=t,n}return i(t,e),t.prototype._Create_iterator=function(e,n,r){return t.Iterator.create(this,e,n,r)},t._Swap_associative=function(e,t){var n;n=o([t.associative_,e.associative_],2),e.associative_=n[0],t.associative_=n[1]},t.prototype.associative=function(){return this.associative_},t}(s.ListContainer);t.MapElementList=u,function(e){var t=function(e){function t(t,n,r,i){var o=e.call(this,n,r,i)||this;return o.list_=t,o}return i(t,e),t.create=function(e,n,r,i){return new t(e,n,r,i)},t.prototype.reverse=function(){return new n(this)},t.prototype.source=function(){return this.list_.associative()},Object.defineProperty(t.prototype,"first",{get:function(){return this.value.first},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"second",{get:function(){return this.value.second},set:function(e){this.value.second=e},enumerable:!1,configurable:!0}),t}(a.ListIterator);e.Iterator=t;var n=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype._Create_neighbor=function(e){return new t(e)},Object.defineProperty(t.prototype,"first",{get:function(){return this.base_.first},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"second",{get:function(){return this.base_.second},set:function(e){this.base_.second=e},enumerable:!1,configurable:!0}),t}(c.ReverseIterator);e.ReverseIterator=n}(u=t.MapElementList||(t.MapElementList={})),t.MapElementList=u},6827:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s};Object.defineProperty(t,"__esModule",{value:!0}),t.SetElementList=void 0;var s=n(4286),a=n(5231),c=n(3282),u=function(e){function t(t){var n=e.call(this)||this;return n.associative_=t,n}return i(t,e),t.prototype._Create_iterator=function(e,n,r){return t.Iterator.create(this,e,n,r)},t._Swap_associative=function(e,t){var n;n=o([t.associative_,e.associative_],2),e.associative_=n[0],t.associative_=n[1]},t.prototype.associative=function(){return this.associative_},t}(s.ListContainer);t.SetElementList=u,function(e){var t=function(e){function t(t,n,r,i){var o=e.call(this,n,r,i)||this;return o.source_=t,o}return i(t,e),t.create=function(e,n,r,i){return new t(e,n,r,i)},t.prototype.reverse=function(){return new n(this)},t.prototype.source=function(){return this.source_.associative()},t}(a.ListIterator);e.Iterator=t;var n=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype._Create_neighbor=function(e){return new t(e)},t}(c.ReverseIterator);e.ReverseIterator=n}(u=t.SetElementList||(t.SetElementList={})),t.SetElementList=u},4286:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s};Object.defineProperty(t,"__esModule",{value:!0}),t.ListContainer=void 0;var s=n(9863),a=n(5231),c=n(5643),u=n(8766),l=n(2111),h=n(2018),d=function(e){function t(){var t=e.call(this)||this;return t.end_=t._Create_iterator(null,null),t.clear(),t}return i(t,e),t.prototype.assign=function(e,t){this.clear(),this.insert(this.end(),e,t)},t.prototype.clear=function(){a.ListIterator._Set_prev(this.end_,this.end_),a.ListIterator._Set_next(this.end_,this.end_),this.begin_=this.end_,this.size_=0},t.prototype.resize=function(e){var t=e-this.size();t>0?this.insert(this.end(),t,void 0):t<0&&this.erase((0,l.advance)(this.end(),-t),this.end())},t.prototype.begin=function(){return this.begin_},t.prototype.end=function(){return this.end_},t.prototype.size=function(){return this.size_},t.prototype.push_front=function(e){this.insert(this.begin_,e)},t.prototype.push_back=function(e){this.insert(this.end_,e)},t.prototype.pop_front=function(){if(!0===this.empty())throw h.ErrorGenerator.empty(this.end_.source().constructor.name,"pop_front");this.erase(this.begin_)},t.prototype.pop_back=function(){if(!0===this.empty())throw h.ErrorGenerator.empty(this.end_.source().constructor.name,"pop_back");this.erase(this.end_.prev())},t.prototype.push=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(0===e.length)return this.size();var n=new u.NativeArrayIterator(e,0),r=new u.NativeArrayIterator(e,e.length);return this._Insert_by_range(this.end(),n,r),this.size()},t.prototype.insert=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(e.source()!==this.end_.source())throw h.ErrorGenerator.not_my_iterator(this.end_.source(),"insert");if(!0===e.erased_)throw h.ErrorGenerator.erased_iterator(this.end_.source(),"insert");return 1===t.length?this._Insert_by_repeating_val(e,1,t[0]):2===t.length&&"number"==typeof t[0]?this._Insert_by_repeating_val(e,t[0],t[1]):this._Insert_by_range(e,t[0],t[1])},t.prototype._Insert_by_repeating_val=function(e,t,n){var r=new c.Repeater(0,n),i=new c.Repeater(t);return this._Insert_by_range(e,r,i)},t.prototype._Insert_by_range=function(e,t,n){for(var r=e.prev(),i=null,o=0,s=t;!1===s.equals(n);s=s.next()){var c=this._Create_iterator(r,null,s.value);0===o&&(i=c),a.ListIterator._Set_next(r,c),r=c,++o}return!0===e.equals(this.begin())&&(this.begin_=i),a.ListIterator._Set_next(r,e),a.ListIterator._Set_prev(e,r),this.size_+=o,i},t.prototype.erase=function(e,t){return void 0===t&&(t=e.next()),this._Erase_by_range(e,t)},t.prototype._Erase_by_range=function(e,t){if(e.source()!==this.end_.source())throw h.ErrorGenerator.not_my_iterator(this.end_.source(),"insert");if(!0===e.erased_)throw h.ErrorGenerator.erased_iterator(this.end_.source(),"insert");if(e.equals(this.end_))return this.end_;var n=e.prev();a.ListIterator._Set_next(n,t),a.ListIterator._Set_prev(t,n);for(var r=e;!r.equals(t);r=r.next())r.erased_=!0,--this.size_;return e.equals(this.begin_)&&(this.begin_=t),t},t.prototype.swap=function(e){var t,n,r;t=o([e.begin_,this.begin_],2),this.begin_=t[0],e.begin_=t[1],n=o([e.end_,this.end_],2),this.end_=n[0],e.end_=n[1],r=o([e.size_,this.size_],2),this.size_=r[0],e.size_=r[1]},t}(s.Container);t.ListContainer=d},2018:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorGenerator=void 0;var r=n(8521),i=n(334);!function(e){function t(e){if("string"==typeof e)return e;var t=e.constructor.name;return e.constructor.__MODULE&&(t="".concat(e.constructor.__MODULE,".").concat(t)),"std.".concat(t)}e.get_class_name=t,e.empty=function(e,n){return new i.OutOfRange("Error on ".concat(t(e),".").concat(n,"(): it's empty container."))},e.negative_index=function(e,n,r){return new i.OutOfRange("Error on ".concat(t(e),".").concat(n,"(): parametric index is negative -> (index = ").concat(r,")."))},e.excessive_index=function(e,n,r,o){return new i.OutOfRange("Error on ".concat(t(e),".").concat(n,"(): parametric index is equal or greater than size -> (index = ").concat(r,", size: ").concat(o,")."))},e.not_my_iterator=function(e,n){return new r.InvalidArgument("Error on ".concat(t(e),".").concat(n,"(): parametric iterator is not this container's own."))},e.erased_iterator=function(e,n){return new r.InvalidArgument("Error on ".concat(t(e),".").concat(n,"(): parametric iterator, it already has been erased."))},e.negative_iterator=function(e,n,r){return new i.OutOfRange("Error on ".concat(t(e),".").concat(n,"(): parametric iterator is directing negative position -> (index = ").concat(r,")."))},e.iterator_end_value=function(e,n){void 0===n&&(n="end");var r=t(e);return new i.OutOfRange("Error on ".concat(r,".Iterator.value: cannot access to the ").concat(r,".").concat(n,"().value."))},e.key_nout_found=function(e,n,r){throw new i.OutOfRange("Error on ".concat(t(e),".").concat(n,"(): unable to find the matched key -> ").concat(r))}}(t.ErrorGenerator||(t.ErrorGenerator={}))},6086:function(e,t){"use strict";var n=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.HashBuckets=void 0;var r=function(){function e(e,t){this.fetcher_=e,this.hasher_=t,this.max_load_factor_=o,this.data_=[],this.size_=0,this.initialize()}return e.prototype.clear=function(){this.data_=[],this.size_=0,this.initialize()},e.prototype.rehash=function(e){var t,r,o,s;e=Math.max(e,i);for(var a=[],c=0;c<e;++c)a.push([]);try{for(var u=n(this.data_),l=u.next();!l.done;l=u.next()){var h=l.value;try{for(var d=(o=void 0,n(h)),f=d.next();!f.done;f=d.next()){var p=f.value;a[this.hasher_(this.fetcher_(p))%a.length].push(p)}}catch(e){o={error:e}}finally{try{f&&!f.done&&(s=d.return)&&s.call(d)}finally{if(o)throw o.error}}}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=u.return)&&r.call(u)}finally{if(t)throw t.error}}this.data_=a},e.prototype.reserve=function(e){e>this.capacity()&&(e=Math.floor(e/this.max_load_factor_),this.rehash(e))},e.prototype.initialize=function(){for(var e=0;e<i;++e)this.data_.push([])},e.prototype.length=function(){return this.data_.length},e.prototype.capacity=function(){return this.data_.length*this.max_load_factor_},e.prototype.at=function(e){return this.data_[e]},e.prototype.load_factor=function(){return this.size_/this.length()},e.prototype.max_load_factor=function(e){if(void 0===e&&(e=null),null===e)return this.max_load_factor_;this.max_load_factor_=e},e.prototype.hash_function=function(){return this.hasher_},e.prototype.index=function(e){return this.hasher_(this.fetcher_(e))%this.length()},e.prototype.insert=function(e){var t=this.capacity();++this.size_>t&&this.reserve(2*t);var n=this.index(e);this.data_[n].push(e)},e.prototype.erase=function(e){for(var t=this.index(e),n=this.data_[t],r=0;r<n.length;++r)if(n[r]===e){n.splice(r,1),--this.size_;break}},e}();t.HashBuckets=r;var i=10,o=1},9558:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},s=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.MapHashBuckets=void 0;var a=function(e){function t(t,n,r){var i=e.call(this,c,n)||this;return i.source_=t,i.key_eq_=r,i}return i(t,e),t._Swap_source=function(e,t){var n;n=o([t.source_,e.source_],2),e.source_=n[0],t.source_=n[1]},t.prototype.key_eq=function(){return this.key_eq_},t.prototype.find=function(e){var t,n,r=this.hash_function()(e)%this.length(),i=this.at(r);try{for(var o=s(i),a=o.next();!a.done;a=o.next()){var c=a.value;if(this.key_eq_(c.first,e))return c}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return this.source_.end()},t}(n(6086).HashBuckets);function c(e){return e.first}t.MapHashBuckets=a},5779:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},s=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.SetHashBuckets=void 0;var a=function(e){function t(t,n,r){var i=e.call(this,c,n)||this;return i.source_=t,i.key_eq_=r,i}return i(t,e),t._Swap_source=function(e,t){var n;n=o([t.source_,e.source_],2),e.source_=n[0],t.source_=n[1]},t.prototype.key_eq=function(){return this.key_eq_},t.prototype.find=function(e){var t,n,r=this.hash_function()(e)%this.length(),i=this.at(r);try{for(var o=s(i),a=o.next();!a.done;a=o.next()){var c=a.value;if(this.key_eq_(c.value,e))return c}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return this.source_.end()},t}(n(6086).HashBuckets);function c(e){return e.value}t.SetHashBuckets=a},5231:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ListIterator=void 0;var r=n(2018),i=function(){function e(e,t,n){this.prev_=e,this.next_=t,this.value_=n}return e._Set_prev=function(e,t){e.prev_=t},e._Set_next=function(e,t){e.next_=t},e.prototype.prev=function(){return this.prev_},e.prototype.next=function(){return this.next_},Object.defineProperty(e.prototype,"value",{get:function(){return this._Try_value(),this.value_},enumerable:!1,configurable:!0}),e.prototype._Try_value=function(){if(void 0===this.value_&&!0===this.equals(this.source().end()))throw r.ErrorGenerator.iterator_end_value(this.source())},e.prototype.equals=function(e){return this===e},e}();t.ListIterator=i},3282:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReverseIterator=void 0;var n=function(){function e(e){this.base_=e.prev()}return e.prototype.source=function(){return this.base_.source()},e.prototype.base=function(){return this.base_.next()},Object.defineProperty(e.prototype,"value",{get:function(){return this.base_.value},enumerable:!1,configurable:!0}),e.prototype.prev=function(){return this._Create_neighbor(this.base().next())},e.prototype.next=function(){return this._Create_neighbor(this.base_)},e.prototype.equals=function(e){return this.base_.equals(e.base_)},e}();t.ReverseIterator=n},2850:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ForOfAdaptor=void 0;var n=function(){function e(e,t){this.it_=e,this.last_=t}return e.prototype.next=function(){if(this.it_.equals(this.last_))return{done:!0,value:void 0};var e=this.it_;return this.it_=this.it_.next(),{done:!1,value:e.value}},e.prototype[Symbol.iterator]=function(){return this},e}();t.ForOfAdaptor=n},8766:function(e,t){"use strict";var n=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s};Object.defineProperty(t,"__esModule",{value:!0}),t.NativeArrayIterator=void 0;var r=function(){function e(e,t){this.data_=e,this.index_=t}return e.prototype.index=function(){return this.index_},Object.defineProperty(e.prototype,"value",{get:function(){return this.data_[this.index_]},enumerable:!1,configurable:!0}),e.prototype.prev=function(){return--this.index_,this},e.prototype.next=function(){return++this.index_,this},e.prototype.advance=function(e){return this.index_+=e,this},e.prototype.equals=function(e){return this.data_===e.data_&&this.index_===e.index_},e.prototype.swap=function(e){var t,r;t=n([e.data_,this.data_],2),this.data_=t[0],e.data_=t[1],r=n([e.index_,this.index_],2),this.index_=r[0],e.index_=r[1]},e}();t.NativeArrayIterator=r},5643:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Repeater=void 0;var n=function(){function e(e,t){this.index_=e,this.value_=t}return e.prototype.index=function(){return this.index_},Object.defineProperty(e.prototype,"value",{get:function(){return this.value_},enumerable:!1,configurable:!0}),e.prototype.next=function(){return++this.index_,this},e.prototype.equals=function(e){return this.index_===e.index_},e}();t.Repeater=n},2111:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.next=t.prev=t.advance=t.distance=t.size=t.empty=void 0;var r=n(8521);function i(e,t){if(0===t)return e;if(e.advance instanceof Function)return e.advance(t);var n;if(t<0){if(!(e.prev instanceof Function))throw new r.InvalidArgument("Error on std.advance(): parametric iterator is not a bi-directional iterator, thus advancing to negative direction is not possible.");n=function(e){return e.prev()},t=-t}else n=function(e){return e.next()};for(;t-- >0;)e=n(e);return e}t.empty=function(e){return e instanceof Array?0!==e.length:e.empty()},t.size=function(e){return e instanceof Array?e.length:e.size()},t.distance=function(e,t){if(e.index instanceof Function)return function(e,t){var n=e.index(),r=t.index();return e.base instanceof Function?n-r:r-n}(e,t);for(var n=0;!e.equals(t);e=e.next())++n;return n},t.advance=i,t.prev=function(e,t){return void 0===t&&(t=1),1===t?e.prev():i(e,-t)},t.next=function(e,t){return void 0===t&&(t=1),1===t?e.next():i(e,t)}},6249:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Entry=void 0;var r=n(3425),i=n(9284),o=function(){function e(e,t){this.first=e,this.second=t}return e.prototype.equals=function(e){return(0,i.equal_to)(this.first,e.first)},e.prototype.less=function(e){return(0,i.less)(this.first,e.first)},e.prototype.hashCode=function(){return(0,r.hash)(this.first)},e}();t.Entry=o},5610:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.make_pair=t.Pair=void 0;var r=n(3425),i=n(9284),o=function(){function e(e,t){this.first=e,this.second=t}return e.prototype.equals=function(e){return(0,i.equal_to)(this.first,e.first)&&(0,i.equal_to)(this.second,e.second)},e.prototype.less=function(e){return!1===(0,i.equal_to)(this.first,e.first)?(0,i.less)(this.first,e.first):(0,i.less)(this.second,e.second)},e.prototype.hashCode=function(){return(0,r.hash)(this.first,this.second)},e}();t.Pair=o,t.make_pair=function(e,t){return new o(e,t)}},3362:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.is_node=void 0;var r=null;t.is_node=function(){return null===r&&(r="object"==typeof n.g&&"object"==typeof n.g.process&&"object"==typeof n.g.process.versions&&void 0!==n.g.process.versions.node),r}},3190:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},r(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__assign||function(){return o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},o.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0});var s=n(9315),a=n(5689),c=n(3047),u=n(7024),l=n(4048),h=n(8018),d=function(e){function t(n,r){var i=e.call(this)||this;return i.on_={},i.state_=t.CONNECTING,i.client_=new s.client,i.client_.on("connect",i._Handle_connect.bind(i)),i.client_.on("connectFailed",i._Handle_error.bind(i)),"string"==typeof r&&(r=[r]),i.client_.connect(n,r),i}return i(t,e),t.prototype.close=function(e,n){this.state_=t.CLOSING,void 0===e?this.connection_.sendCloseFrame():this.connection_.sendCloseFrame(e,n,!0)},t.prototype.send=function(e){if("string"==typeof e.valueOf())this.connection_.sendUTF(e);else{var t;t=e instanceof Buffer?e:e instanceof Blob?new Buffer(e,"blob"):e.buffer?new Buffer(e.buffer):new Buffer(e),this.connection_.sendBytes(t)}},Object.defineProperty(t.prototype,"url",{get:function(){return this.client_.url.href},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"protocol",{get:function(){return this.client_.protocols?this.client_.protocols[0]:""},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"extensions",{get:function(){return this.connection_&&this.connection_.extensions?this.connection_.extensions[0].name:""},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"readyState",{get:function(){return this.state_},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bufferedAmount",{get:function(){return this.connection_.bytesWaitingToFlush},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"binaryType",{get:function(){return"arraybuffer"},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onopen",{get:function(){return this.on_.open},set:function(e){this._Set_on("open",e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onclose",{get:function(){return this.on_.close},set:function(e){this._Set_on("close",e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onmessage",{get:function(){return this.on_.message},set:function(e){this._Set_on("message",e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onerror",{get:function(){return this.on_.error},set:function(e){this._Set_on("error",e)},enumerable:!0,configurable:!0}),t.prototype._Set_on=function(e,t){this.on_[e]&&this.removeEventListener(e,this.on_[e]),this.addEventListener(e,t),this.on_[e]=t},t.prototype._Handle_connect=function(e){this.connection_=e,this.state_=t.OPEN,this.connection_.on("message",this._Handle_message.bind(this)),this.connection_.on("error",this._Handle_error.bind(this)),this.connection_.on("close",this._Handle_close.bind(this));var n=new c.Event("open",f);this.dispatchEvent(n)},t.prototype._Handle_close=function(e,n){var r=new u.CloseEvent("close",o({},f,{code:e,reason:n}));this.state_=t.CLOSED,this.dispatchEvent(r)},t.prototype._Handle_message=function(e){var t=new l.MessageEvent("message",o({},f,{data:e.binaryData?e.binaryData:e.utf8Data}));this.dispatchEvent(t)},t.prototype._Handle_error=function(e){var n=new h.ErrorEvent("error",o({},f,{error:e,message:e.message}));this.state_===t.CONNECTING&&(this.state_=t.CLOSED),this.dispatchEvent(n)},t}(a.EventTarget);t.WebSocket=d,function(e){e.CONNECTING=0,e.OPEN=1,e.CLOSING=2,e.CLOSED=3}(d=t.WebSocket||(t.WebSocket={})),t.WebSocket=d;var f={bubbles:!1,cancelable:!1}},7024:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},r(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(t,n){return e.call(this,t,n)||this}return i(t,e),t}(n(3047).Event);t.CloseEvent=o},8018:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},r(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(t,n){return e.call(this,t,n)||this}return i(t,e),t}(n(3047).Event);t.ErrorEvent=o},3047:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Event=function(e,t){this.type=e,t&&Object.assign(this,t)}},5689:function(e,t,n){"use strict";var r=this&&this.__values||function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}};Object.defineProperty(t,"__esModule",{value:!0});var i=n(2810),o=n(508),s=function(){function e(){this.listeners_=new o.HashMap,this.created_at_=new Date}return e.prototype.dispatchEvent=function(e){var t,n,i=this.listeners_.find(e.type);if(!i.equals(this.listeners_.end())){e.target=this,e.timeStamp=(new Date).getTime()-this.created_at_.getTime();try{for(var o=r(i.second),s=o.next();!s.done;s=o.next())(0,s.value)(e)}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}}},e.prototype.addEventListener=function(e,t){var n=this.listeners_.find(e);n.equals(this.listeners_.end())&&(n=this.listeners_.emplace(e,new i.HashSet).first),n.second.insert(t)},e.prototype.removeEventListener=function(e,t){var n=this.listeners_.find(e);n.equals(this.listeners_.end())||(n.second.erase(t),n.second.empty()&&this.listeners_.erase(n))},e}();t.EventTarget=s},4048:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},r(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(t,n){return e.call(this,t,n)||this}return i(t,e),t}(n(3047).Event);t.MessageEvent=o},8e3:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),n(3362).is_node()&&(n.g.WebSocket=n(3190).WebSocket)},9315:(e,t,n)=>{var r;if("object"==typeof globalThis)r=globalThis;else try{r=n(3126)}catch(e){}finally{if(r||"undefined"==typeof window||(r=window),!r)throw new Error("Could not determine global this")}var i=r.WebSocket||r.MozWebSocket,o=n(9999);function s(e,t){return t?new i(e,t):new i(e)}i&&["CONNECTING","OPEN","CLOSING","CLOSED"].forEach((function(e){Object.defineProperty(s,e,{get:function(){return i[e]}})})),e.exports={w3cwebsocket:i?s:null,version:o}},9999:(e,t,n)=>{e.exports=n(2007).version},2007:e=>{"use strict";e.exports={version:"1.0.34"}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,n),o.exports}n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n(2407)})();
mandric commented 11 months ago

You should be able to download the build artifact in this GH Actions job, unzip and test out the extension. The "undefined (reading pool)" error should at least be gone.

DataN0strum commented 11 months ago

Thanks, I removed the extension and installed manually using your link.

The behavior is still the same; sidebar vanishes immediately, I can only glimpse the panel for an instant.

The error is now as follows:

image
mandric commented 10 months ago

I can't seem to reproduce this one, will try a few things...

DataN0strum commented 10 months ago

If it helps, I'm on MacOS 12.7

mandric commented 10 months ago

That's interesting, I am on 13.5.1 (22G90) of MacOS. What version of brave?

DataN0strum commented 10 months ago

Brave Version 1.57.57 Chromium: 116.0.5845.163 (Official Build) (arm64)

mandric commented 10 months ago

Do you want to test the latest version or are you trying to stay on an old version?

DataN0strum commented 10 months ago

You mean MacOS? I'm staying on 12.7 for now

mandric commented 10 months ago

No I mean Brave, the version I tested was Brave Version 1.58.131 Chromium: 117.0.5938.92 (Official Build) (×86_64). I believe that's the latest version?

mandric commented 10 months ago

maybe it's not available on arm64 (M1, 2 etc)?

DataN0strum commented 10 months ago

It works with the latest Brave (1.58.137)!

mandric commented 10 months ago

do you want to close the ticket?