Files
einundzwanzig-verein/public/dist/window.nostr.min.js.js

9 lines
182 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Minified by jsDelivr using Terser v5.39.0.
* Original file: /npm/window.nostr.js@0.7.0/dist/window.nostr.js
*
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
*/
var pf=Object.defineProperty,bf=(t,e,n)=>e in t?pf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,E=(t,e,n)=>bf(t,"symbol"!=typeof e?e+"":e,n);!function(){"use strict";var t,e,n,r,o,i,s;function a(){}function c(t){return t()}function l(){return Object.create(null)}function u(t){t.forEach(c)}function h(t){return"function"==typeof t}function d(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}let f;function p(t,e){return t===e||(f||(f=document.createElement("a")),f.href=e,t===f.href)}function g(t,e,n){t.$$.on_destroy.push(function(t,...e){if(null==t){for(const t of e)t(void 0);return a}const n=t.subscribe(...e);return n.unsubscribe?()=>n.unsubscribe():n}(e,n))}const w=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function b(t,e){t.appendChild(e)}function y(t,e,n){t.insertBefore(e,n||null)}function m(t){t.parentNode&&t.parentNode.removeChild(t)}function v(t){return document.createElement(t)}function x(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function k(t){return document.createTextNode(t)}function A(){return k(" ")}function S(){return k("")}function T(t,e,n,r){return t.addEventListener(e,n,r),()=>t.removeEventListener(e,n,r)}function I(t,e,n){null==n?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function P(t,e){e=""+e,t.data!==e&&(t.data=e)}function B(t,e){t.value=e??""}function R(t,e,n){t.classList.toggle(e,!!n)}let C;function $(t){C=t}function N(){if(!C)throw new Error("Function called outside component initialization");return C}const L=[],U=[];let O=[];const _=[],H=Promise.resolve();let M=!1;function j(t){O.push(t)}const q=new Set;let z=0;function D(){if(0!==z)return;const t=C;do{try{for(;z<L.length;){const t=L[z];z++,$(t),F(t.$$)}}catch(t){throw L.length=0,z=0,t}for($(null),L.length=0,z=0;U.length;)U.pop()();for(let t=0;t<O.length;t+=1){const e=O[t];q.has(e)||(q.add(e),e())}O.length=0}while(L.length);for(;_.length;)_.pop()();M=!1,q.clear(),$(t)}function F(t){if(null!==t.fragment){t.update(),u(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(j)}}const K=new Set;let W;function V(){W={r:0,c:[],p:W}}function J(){W.r||u(W.c),W=W.p}function Y(t,e){t&&t.i&&(K.delete(t),t.i(e))}function Z(t,e,n,r){if(t&&t.o){if(K.has(t))return;K.add(t),W.c.push((()=>{K.delete(t),r&&(n&&t.d(1),r())})),t.o(e)}else r&&r()}function Q(t,e){const n=e.token={};function r(t,r,o,i){if(e.token!==n)return;e.resolved=i;let s=e.ctx;void 0!==o&&(s=s.slice(),s[o]=i);const a=t&&(e.current=t)(s);let c=!1;e.block&&(e.blocks?e.blocks.forEach(((t,n)=>{n!==r&&t&&(V(),Z(t,1,1,(()=>{e.blocks[n]===t&&(e.blocks[n]=null)})),J())})):e.block.d(1),a.c(),Y(a,1),a.m(e.mount(),e.anchor),c=!0),e.block=a,e.blocks&&(e.blocks[r]=a),c&&D()}if(function(t){return!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then}(t)){const n=N();if(t.then((t=>{$(n),r(e.then,1,e.value,t),$(null)}),(t=>{if($(n),r(e.catch,2,e.error,t),$(null),!e.hasCatch)throw t})),e.current!==e.pending)return r(e.pending,0),!0}else{if(e.current!==e.then)return r(e.then,1,e.value,t),!0;e.resolved=t}}function G(t){t&&t.c()}function X(t,e,n){const{fragment:r,after_update:o}=t.$$;r&&r.m(e,n),j((()=>{const e=t.$$.on_mount.map(c).filter(h);t.$$.on_destroy?t.$$.on_destroy.push(...e):u(e),t.$$.on_mount=[]})),o.forEach(j)}function tt(t,e){const n=t.$$;null!==n.fragment&&(function(t){const e=[],n=[];O.forEach((r=>-1===t.indexOf(r)?e.push(r):n.push(r))),n.forEach((t=>t())),O=e}(n.after_update),u(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function et(t,e){-1===t.$$.dirty[0]&&(L.push(t),M||(M=!0,H.then(D)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function nt(t,e,n,r,o,i,s=null,c=[-1]){const h=C;$(t);const d=t.$$={fragment:null,ctx:[],props:i,update:a,not_equal:o,bound:l(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(h?h.$$.context:[])),callbacks:l(),dirty:c,skip_bound:!1,root:e.target||h.$$.root};s&&s(d.root);let f=!1;if(d.ctx=n?n(t,e.props||{},((e,n,...r)=>{const i=r.length?r[0]:n;return d.ctx&&o(d.ctx[e],d.ctx[e]=i)&&(!d.skip_bound&&d.bound[e]&&d.bound[e](i),f&&et(t,e)),n})):[],d.update(),f=!0,u(d.before_update),d.fragment=!!r&&r(d.ctx),e.target){if(e.hydrate){const t=function(t){return Array.from(t.childNodes)}(e.target);d.fragment&&d.fragment.l(t),t.forEach(m)}else d.fragment&&d.fragment.c();e.intro&&Y(t.$$.fragment),X(t,e.target,e.anchor),D()}$(h)}class rt{constructor(){E(this,"$$"),E(this,"$$set")}$destroy(){tt(this,1),this.$destroy=a}$on(t,e){if(!h(e))return a;const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}$set(t){var e;this.$$set&&(e=t,0!==Object.keys(e).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function ot(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function it(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function st(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add("4");const at="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,ct=t=>t instanceof Uint8Array,lt=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),ut=(t,e)=>t<<32-e|t>>>e;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");function ht(t){if("string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}(t)),!ct(t))throw new Error("expected Uint8Array, got "+typeof t);return t}let dt=class{clone(){return this._cloneInto()}};function ft(t=32){if(at&&"function"==typeof at.getRandomValues)return at.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}let pt=class extends dt{constructor(t,e,n,r){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=lt(this.buffer)}update(t){st(this);const{view:e,buffer:n,blockLen:r}=this,o=(t=ht(t)).length;for(let i=0;i<o;){const s=Math.min(r-this.pos,o-i);if(s!==r)n.set(t.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===r&&(this.process(e,0),this.pos=0);else{const e=lt(t);for(;r<=o-i;i+=r)this.process(e,i)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){st(this),function(t,e){it(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:r,isLE:o}=this;let{pos:i}=this;e[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>r-i&&(this.process(n,0),i=0);for(let t=i;t<r;t++)e[t]=0;(function(t,e,n,r){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,n,r);const o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),a=Number(n&i),c=r?4:0,l=r?0:4;t.setUint32(e+c,s,r),t.setUint32(e+l,a,r)})(n,r-8,BigInt(8*this.length),o),this.process(n,0);const s=lt(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<c;t++)s.setUint32(4*t,l[t],o)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:n,length:r,finished:o,destroyed:i,pos:s}=this;return t.length=r,t.pos=s,t.finished=o,t.destroyed=i,r%e&&t.buffer.set(n),t}};const gt=(t,e,n)=>t&e^~t&n,wt=(t,e,n)=>t&e^t&n^e&n,bt=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]),yt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),mt=new Uint32Array(64);let vt=class extends pt{constructor(){super(64,32,8,!1),this.A=0|yt[0],this.B=0|yt[1],this.C=0|yt[2],this.D=0|yt[3],this.E=0|yt[4],this.F=0|yt[5],this.G=0|yt[6],this.H=0|yt[7]}get(){const{A:t,B:e,C:n,D:r,E:o,F:i,G:s,H:a}=this;return[t,e,n,r,o,i,s,a]}set(t,e,n,r,o,i,s,a){this.A=0|t,this.B=0|e,this.C=0|n,this.D=0|r,this.E=0|o,this.F=0|i,this.G=0|s,this.H=0|a}process(t,e){for(let n=0;n<16;n++,e+=4)mt[n]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=mt[t-15],n=mt[t-2],r=ut(e,7)^ut(e,18)^e>>>3,o=ut(n,17)^ut(n,19)^n>>>10;mt[t]=o+mt[t-7]+r+mt[t-16]|0}let{A:n,B:r,C:o,D:i,E:s,F:a,G:c,H:l}=this;for(let t=0;t<64;t++){const e=l+(ut(s,6)^ut(s,11)^ut(s,25))+gt(s,a,c)+bt[t]+mt[t]|0,u=(ut(n,2)^ut(n,13)^ut(n,22))+wt(n,r,o)|0;l=c,c=a,a=s,s=i+e|0,i=o,o=r,r=n,n=e+u|0}n=n+this.A|0,r=r+this.B|0,o=o+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,o,i,s,a,c,l)}roundClean(){mt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const Et=function(t){const e=e=>t().update(ht(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}((()=>new vt));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */BigInt(0);const xt=BigInt(1),kt=BigInt(2),At=t=>t instanceof Uint8Array,St=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function Tt(t){if(!At(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=St[t[n]];return e}function It(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);return BigInt(""===t?"0":`0x${t}`)}function Pt(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);const e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(e/2);for(let e=0;e<n.length;e++){const r=2*e,o=t.slice(r,r+2),i=Number.parseInt(o,16);if(Number.isNaN(i)||i<0)throw new Error("Invalid byte sequence");n[e]=i}return n}function Bt(t){return It(Tt(t))}function Rt(t){if(!At(t))throw new Error("Uint8Array expected");return It(Tt(Uint8Array.from(t).reverse()))}function Ct(t,e){return Pt(t.toString(16).padStart(2*e,"0"))}function $t(t,e){return Ct(t,e).reverse()}function Nt(t,e,n){let r;if("string"==typeof e)try{r=Pt(e)}catch(n){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${n}`)}else{if(!At(e))throw new Error(`${t} must be hex string or Uint8Array`);r=Uint8Array.from(e)}const o=r.length;if("number"==typeof n&&o!==n)throw new Error(`${t} expected ${n} bytes, got ${o}`);return r}function Lt(...t){const e=new Uint8Array(t.reduce(((t,e)=>t+e.length),0));let n=0;return t.forEach((t=>{if(!At(t))throw new Error("Uint8Array expected");e.set(t,n),n+=t.length})),e}const Ut=t=>(kt<<BigInt(t-1))-xt,Ot=t=>new Uint8Array(t),_t=t=>Uint8Array.from(t);function Ht(t,e,n){if("number"!=typeof t||t<2)throw new Error("hashLen must be a number");if("number"!=typeof e||e<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");let r=Ot(t),o=Ot(t),i=0;const s=()=>{r.fill(1),o.fill(0),i=0},a=(...t)=>n(o,r,...t),c=(t=Ot())=>{o=a(_t([0]),t),r=a(),0!==t.length&&(o=a(_t([1]),t),r=a())},l=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let t=0;const n=[];for(;t<e;){r=a();const e=r.slice();n.push(e),t+=r.length}return Lt(...n)};return(t,e)=>{let n;for(s(),c(t);!(n=e(l()));)c();return s(),n}}const Mt={bigint:t=>"bigint"==typeof t,function:t=>"function"==typeof t,boolean:t=>"boolean"==typeof t,string:t=>"string"==typeof t,stringOrUint8Array:t=>"string"==typeof t||t instanceof Uint8Array,isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>"function"==typeof t&&Number.isSafeInteger(t.outputLen)};function jt(t,e,n={}){const r=(e,n,r)=>{const o=Mt[n];if("function"!=typeof o)throw new Error(`Invalid validator "${n}", expected function`);const i=t[e];if(!(r&&void 0===i||o(i,t)))throw new Error(`Invalid param ${String(e)}=${i} (${typeof i}), expected ${n}`)};for(const[t,n]of Object.entries(e))r(t,n,!1);for(const[t,e]of Object.entries(n))r(t,e,!0);return t}const qt=Object.freeze(Object.defineProperty({__proto__:null,bitMask:Ut,bytesToHex:Tt,bytesToNumberBE:Bt,bytesToNumberLE:Rt,concatBytes:Lt,createHmacDrbg:Ht,ensureBytes:Nt,hexToBytes:Pt,hexToNumber:It,numberToBytesBE:Ct,numberToBytesLE:$t,validateObject:jt},Symbol.toStringTag,{value:"Module"})),zt=BigInt(0),Dt=BigInt(1),Ft=BigInt(2),Kt=BigInt(3),Wt=BigInt(4),Vt=BigInt(5),Jt=BigInt(8);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Yt(t,e){const n=t%e;return n>=zt?n:e+n}function Zt(t,e,n){if(n<=zt||e<zt)throw new Error("Expected power/modulo > 0");if(n===Dt)return zt;let r=Dt;for(;e>zt;)e&Dt&&(r=r*t%n),t=t*t%n,e>>=Dt;return r}function Qt(t,e,n){let r=t;for(;e-- >zt;)r*=r,r%=n;return r}function Gt(t,e){if(t===zt||e<=zt)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=Yt(t,e),r=e,o=zt,i=Dt;for(;n!==zt;){const t=r%n,e=o-i*(r/n);r=n,n=t,o=i,i=e}if(r!==Dt)throw new Error("invert: does not exist");return Yt(o,e)}function Xt(t){if(t%Wt===Kt){const e=(t+Dt)/Wt;return function(t,n){const r=t.pow(n,e);if(!t.eql(t.sqr(r),n))throw new Error("Cannot find square root");return r}}if(t%Jt===Vt){const e=(t-Vt)/Jt;return function(t,n){const r=t.mul(n,Ft),o=t.pow(r,e),i=t.mul(n,o),s=t.mul(t.mul(i,Ft),o),a=t.mul(i,t.sub(s,t.ONE));if(!t.eql(t.sqr(a),n))throw new Error("Cannot find square root");return a}}return function(t){const e=(t-Dt)/Ft;let n,r,o;for(n=t-Dt,r=0;n%Ft===zt;n/=Ft,r++);for(o=Ft;o<t&&Zt(o,e,t)!==t-Dt;o++);if(1===r){const e=(t+Dt)/Wt;return function(t,n){const r=t.pow(n,e);if(!t.eql(t.sqr(r),n))throw new Error("Cannot find square root");return r}}const i=(n+Dt)/Ft;return function(t,s){if(t.pow(s,e)===t.neg(t.ONE))throw new Error("Cannot find square root");let a=r,c=t.pow(t.mul(t.ONE,o),n),l=t.pow(s,i),u=t.pow(s,n);for(;!t.eql(u,t.ONE);){if(t.eql(u,t.ZERO))return t.ZERO;let e=1;for(let n=t.sqr(u);e<a&&!t.eql(n,t.ONE);e++)n=t.sqr(n);const n=t.pow(c,Dt<<BigInt(a-e-1));c=t.sqr(n),l=t.mul(l,n),u=t.mul(u,c),a=e}return l}}(t)}BigInt(9),BigInt(16);const te=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ee(t,e){const n=void 0!==e?e:t.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function ne(t){if("bigint"!=typeof t)throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function re(t){const e=ne(t);return e+Math.ceil(e/2)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const oe=BigInt(0),ie=BigInt(1);function se(t){return function(t){jt(t,te.reduce(((t,e)=>(t[e]="function",t)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"}))}(t.Fp),jt(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...ee(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const{bytesToNumberBE:ae,hexToBytes:ce}=qt,le={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(t){const{Err:e}=le;if(t.length<2||2!==t[0])throw new e("Invalid signature integer tag");const n=t[1],r=t.subarray(2,n+2);if(!n||r.length!==n)throw new e("Invalid signature integer: wrong length");if(128&r[0])throw new e("Invalid signature integer: negative");if(0===r[0]&&!(128&r[1]))throw new e("Invalid signature integer: unnecessary leading zero");return{d:ae(r),l:t.subarray(n+2)}},toSig(t){const{Err:e}=le,n="string"==typeof t?ce(t):t;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||48!=n[0])throw new e("Invalid signature tag");if(n[1]!==r-2)throw new e("Invalid signature: incorrect length");const{d:o,l:i}=le._parseInt(n.subarray(2)),{d:s,l:a}=le._parseInt(i);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:o,s:s}},hexFromSig(t){const e=t=>8&Number.parseInt(t[0],16)?"00"+t:t,n=t=>{const e=t.toString(16);return 1&e.length?`0${e}`:e},r=e(n(t.s)),o=e(n(t.r)),i=r.length/2,s=o.length/2,a=n(i),c=n(s);return`30${n(s+i+4)}02${c}${o}02${a}${r}`}},ue=BigInt(0),he=BigInt(1);BigInt(2);const de=BigInt(3);function fe(t){const e=function(t){const e=se(t);jt(e,{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}=e;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({...e})}(t),{Fp:n}=e,r=e.toBytes||((t,e,r)=>{const o=e.toAffine();return Lt(Uint8Array.from([4]),n.toBytes(o.x),n.toBytes(o.y))}),o=e.fromBytes||(t=>{const e=t.subarray(1);return{x:n.fromBytes(e.subarray(0,n.BYTES)),y:n.fromBytes(e.subarray(n.BYTES,2*n.BYTES))}});function i(t){const{a:r,b:o}=e,i=n.sqr(t),s=n.mul(i,t);return n.add(n.add(s,n.mul(t,r)),o)}if(!n.eql(n.sqr(e.Gy),i(e.Gx)))throw new Error("bad generator point: equation left != right");function s(t){return"bigint"==typeof t&&ue<t&&t<e.n}function a(t){if(!s(t))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(t){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:o,n:i}=e;if(n&&"bigint"!=typeof t){if(t instanceof Uint8Array&&(t=Tt(t)),"string"!=typeof t||!n.includes(t.length))throw new Error("Invalid key");t=t.padStart(2*r,"0")}let s;try{s="bigint"==typeof t?t:Bt(Nt("private key",t,r))}catch{throw new Error(`private key must be ${r} bytes, hex or bigint, not ${typeof t}`)}return o&&(s=Yt(s,i)),a(s),s}const l=new Map;function u(t){if(!(t instanceof h))throw new Error("ProjectivePoint expected")}class h{constructor(t,e,r){if(this.px=t,this.py=e,this.pz=r,null==t||!n.isValid(t))throw new Error("x required");if(null==e||!n.isValid(e))throw new Error("y required");if(null==r||!n.isValid(r))throw new Error("z required")}static fromAffine(t){const{x:e,y:r}=t||{};if(!t||!n.isValid(e)||!n.isValid(r))throw new Error("invalid affine point");if(t instanceof h)throw new Error("projective point not allowed");const o=t=>n.eql(t,n.ZERO);return o(e)&&o(r)?h.ZERO:new h(e,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(t){const e=n.invertBatch(t.map((t=>t.pz)));return t.map(((t,n)=>t.toAffine(e[n]))).map(h.fromAffine)}static fromHex(t){const e=h.fromAffine(o(Nt("pointHex",t)));return e.assertValidity(),e}static fromPrivateKey(t){return h.BASE.multiply(c(t))}_setWindowSize(t){this._WINDOW_SIZE=t,l.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!n.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:t,y:r}=this.toAffine();if(!n.isValid(t)||!n.isValid(r))throw new Error("bad point: x or y not FE");const o=n.sqr(r),s=i(t);if(!n.eql(o,s))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:t}=this.toAffine();if(n.isOdd)return!n.isOdd(t);throw new Error("Field doesn't support isOdd")}equals(t){u(t);const{px:e,py:r,pz:o}=this,{px:i,py:s,pz:a}=t,c=n.eql(n.mul(e,a),n.mul(i,o)),l=n.eql(n.mul(r,a),n.mul(s,o));return c&&l}negate(){return new h(this.px,n.neg(this.py),this.pz)}double(){const{a:t,b:r}=e,o=n.mul(r,de),{px:i,py:s,pz:a}=this;let c=n.ZERO,l=n.ZERO,u=n.ZERO,d=n.mul(i,i),f=n.mul(s,s),p=n.mul(a,a),g=n.mul(i,s);return g=n.add(g,g),u=n.mul(i,a),u=n.add(u,u),c=n.mul(t,u),l=n.mul(o,p),l=n.add(c,l),c=n.sub(f,l),l=n.add(f,l),l=n.mul(c,l),c=n.mul(g,c),u=n.mul(o,u),p=n.mul(t,p),g=n.sub(d,p),g=n.mul(t,g),g=n.add(g,u),u=n.add(d,d),d=n.add(u,d),d=n.add(d,p),d=n.mul(d,g),l=n.add(l,d),p=n.mul(s,a),p=n.add(p,p),d=n.mul(p,g),c=n.sub(c,d),u=n.mul(p,f),u=n.add(u,u),u=n.add(u,u),new h(c,l,u)}add(t){u(t);const{px:r,py:o,pz:i}=this,{px:s,py:a,pz:c}=t;let l=n.ZERO,d=n.ZERO,f=n.ZERO;const p=e.a,g=n.mul(e.b,de);let w=n.mul(r,s),b=n.mul(o,a),y=n.mul(i,c),m=n.add(r,o),v=n.add(s,a);m=n.mul(m,v),v=n.add(w,b),m=n.sub(m,v),v=n.add(r,i);let E=n.add(s,c);return v=n.mul(v,E),E=n.add(w,y),v=n.sub(v,E),E=n.add(o,i),l=n.add(a,c),E=n.mul(E,l),l=n.add(b,y),E=n.sub(E,l),f=n.mul(p,v),l=n.mul(g,y),f=n.add(l,f),l=n.sub(b,f),f=n.add(b,f),d=n.mul(l,f),b=n.add(w,w),b=n.add(b,w),y=n.mul(p,y),v=n.mul(g,v),b=n.add(b,y),y=n.sub(w,y),y=n.mul(p,y),v=n.add(v,y),w=n.mul(b,v),d=n.add(d,w),w=n.mul(E,v),l=n.mul(m,l),l=n.sub(l,w),w=n.mul(m,b),f=n.mul(E,f),f=n.add(f,w),new h(l,d,f)}subtract(t){return this.add(t.negate())}is0(){return this.equals(h.ZERO)}wNAF(t){return f.wNAFCached(this,l,t,(t=>{const e=n.invertBatch(t.map((t=>t.pz)));return t.map(((t,n)=>t.toAffine(e[n]))).map(h.fromAffine)}))}multiplyUnsafe(t){const r=h.ZERO;if(t===ue)return r;if(a(t),t===he)return this;const{endo:o}=e;if(!o)return f.unsafeLadder(this,t);let{k1neg:i,k1:s,k2neg:c,k2:l}=o.splitScalar(t),u=r,d=r,p=this;for(;s>ue||l>ue;)s&he&&(u=u.add(p)),l&he&&(d=d.add(p)),p=p.double(),s>>=he,l>>=he;return i&&(u=u.negate()),c&&(d=d.negate()),d=new h(n.mul(d.px,o.beta),d.py,d.pz),u.add(d)}multiply(t){a(t);let r,o,i=t;const{endo:s}=e;if(s){const{k1neg:t,k1:e,k2neg:a,k2:c}=s.splitScalar(i);let{p:l,f:u}=this.wNAF(e),{p:d,f:p}=this.wNAF(c);l=f.constTimeNegate(t,l),d=f.constTimeNegate(a,d),d=new h(n.mul(d.px,s.beta),d.py,d.pz),r=l.add(d),o=u.add(p)}else{const{p:t,f:e}=this.wNAF(i);r=t,o=e}return h.normalizeZ([r,o])[0]}multiplyAndAddUnsafe(t,e,n){const r=h.BASE,o=(t,e)=>e!==ue&&e!==he&&t.equals(r)?t.multiply(e):t.multiplyUnsafe(e),i=o(this,e).add(o(t,n));return i.is0()?void 0:i}toAffine(t){const{px:e,py:r,pz:o}=this,i=this.is0();null==t&&(t=i?n.ONE:n.inv(o));const s=n.mul(e,t),a=n.mul(r,t),c=n.mul(o,t);if(i)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:t,isTorsionFree:n}=e;if(t===he)return!0;if(n)return n(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:t,clearCofactor:n}=e;return t===he?this:n?n(h,this):this.multiplyUnsafe(e.h)}toRawBytes(t=!0){return this.assertValidity(),r(h,this,t)}toHex(t=!0){return Tt(this.toRawBytes(t))}}h.BASE=new h(e.Gx,e.Gy,n.ONE),h.ZERO=new h(n.ZERO,n.ONE,n.ZERO);const d=e.nBitLength,f=function(t,e){const n=(t,e)=>{const n=e.negate();return t?n:e},r=t=>({windows:Math.ceil(e/t)+1,windowSize:2**(t-1)});return{constTimeNegate:n,unsafeLadder(e,n){let r=t.ZERO,o=e;for(;n>oe;)n&ie&&(r=r.add(o)),o=o.double(),n>>=ie;return r},precomputeWindow(t,e){const{windows:n,windowSize:o}=r(e),i=[];let s=t,a=s;for(let t=0;t<n;t++){a=s,i.push(a);for(let t=1;t<o;t++)a=a.add(s),i.push(a);s=a.double()}return i},wNAF(e,o,i){const{windows:s,windowSize:a}=r(e);let c=t.ZERO,l=t.BASE;const u=BigInt(2**e-1),h=2**e,d=BigInt(e);for(let t=0;t<s;t++){const e=t*a;let r=Number(i&u);i>>=d,r>a&&(r-=h,i+=ie);const s=e,f=e+Math.abs(r)-1,p=t%2!=0,g=r<0;0===r?l=l.add(n(p,o[s])):c=c.add(n(g,o[f]))}return{p:c,f:l}},wNAFCached(t,e,n,r){const o=t._WINDOW_SIZE||1;let i=e.get(t);return i||(i=this.precomputeWindow(t,o),1!==o&&e.set(t,r(i))),this.wNAF(o,i,n)}}}(h,e.endo?Math.ceil(d/2):d);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:c,weierstrassEquation:i,isWithinCurveOrder:s}}function pe(t){const e=function(t){const e=se(t);return jt(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}(t),{Fp:n,n:r}=e,o=n.BYTES+1,i=2*n.BYTES+1;function s(t){return Yt(t,r)}function a(t){return Gt(t,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:h}=fe({...e,toBytes(t,e,r){const o=e.toAffine(),i=n.toBytes(o.x),s=Lt;return r?s(Uint8Array.from([e.hasEvenY()?2:3]),i):s(Uint8Array.from([4]),i,n.toBytes(o.y))},fromBytes(t){const e=t.length,r=t[0],s=t.subarray(1);if(e!==o||2!==r&&3!==r){if(e===i&&4===r){return{x:n.fromBytes(s.subarray(0,n.BYTES)),y:n.fromBytes(s.subarray(n.BYTES,2*n.BYTES))}}throw new Error(`Point of length ${e} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}{const t=Bt(s);if(!function(t){return ue<t&&t<n.ORDER}(t))throw new Error("Point is not on curve");const e=u(t);let o=n.sqrt(e);return!(1&~r)!==((o&he)===he)&&(o=n.neg(o)),{x:t,y:o}}}}),d=t=>Tt(Ct(t,e.nByteLength));function f(t){return t>r>>he}const p=(t,e,n)=>Bt(t.slice(e,n));class g{constructor(t,e,n){this.r=t,this.s=e,this.recovery=n,this.assertValidity()}static fromCompact(t){const n=e.nByteLength;return t=Nt("compactSignature",t,2*n),new g(p(t,0,n),p(t,n,2*n))}static fromDER(t){const{r:e,s:n}=le.toSig(Nt("DER",t));return new g(e,n)}assertValidity(){if(!h(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!h(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(t){return new g(this.r,this.s,t)}recoverPublicKey(t){const{r:r,s:o,recovery:i}=this,l=m(Nt("msgHash",t));if(null==i||![0,1,2,3].includes(i))throw new Error("recovery id invalid");const u=2===i||3===i?r+e.n:r;if(u>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const h=1&i?"03":"02",f=c.fromHex(h+d(u)),p=a(u),g=s(-l*p),w=s(o*p),b=c.BASE.multiplyAndAddUnsafe(f,g,w);if(!b)throw new Error("point at infinify");return b.assertValidity(),b}hasHighS(){return f(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return Pt(this.toDERHex())}toDERHex(){return le.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Pt(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}const w={isValidPrivateKey(t){try{return l(t),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const t=re(e.n);return function(t,e,n=!1){const r=t.length,o=ne(e),i=re(e);if(r<16||r<i||r>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const s=Yt(n?Bt(t):Rt(t),e-Dt)+Dt;return n?$t(s,o):Ct(s,o)}(e.randomBytes(t),e.n)},precompute:(t=8,e=c.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)};function b(t){const e=t instanceof Uint8Array,n="string"==typeof t,r=(e||n)&&t.length;return e?r===o||r===i:n?r===2*o||r===2*i:t instanceof c}const y=e.bits2int||function(t){const n=Bt(t),r=8*t.length-e.nBitLength;return r>0?n>>BigInt(r):n},m=e.bits2int_modN||function(t){return s(y(t))},v=Ut(e.nBitLength);function E(t){if("bigint"!=typeof t)throw new Error("bigint expected");if(!(ue<=t&&t<v))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Ct(t,e.nByteLength)}function x(t,r,o=k){if(["recovered","canonical"].some((t=>t in o)))throw new Error("sign() legacy options not supported");const{hash:i,randomBytes:u}=e;let{lowS:d,prehash:p,extraEntropy:w}=o;null==d&&(d=!0),t=Nt("msgHash",t),p&&(t=Nt("prehashed msgHash",i(t)));const b=m(t),v=l(r),x=[E(v),E(b)];if(null!=w){const t=!0===w?u(n.BYTES):w;x.push(Nt("extraEntropy",t))}const A=Lt(...x),S=b;return{seed:A,k2sig:function(t){const e=y(t);if(!h(e))return;const n=a(e),r=c.BASE.multiply(e).toAffine(),o=s(r.x);if(o===ue)return;const i=s(n*s(S+o*v));if(i===ue)return;let l=(r.x===o?0:2)|Number(r.y&he),u=i;return d&&f(i)&&(u=function(t){return f(t)?s(-t):t}(i),l^=1),new g(o,u,l)}}}const k={lowS:e.lowS,prehash:!1},A={lowS:e.lowS,prehash:!1};return c.BASE._setWindowSize(8),{CURVE:e,getPublicKey:function(t,e=!0){return c.fromPrivateKey(t).toRawBytes(e)},getSharedSecret:function(t,e,n=!0){if(b(t))throw new Error("first arg must be private key");if(!b(e))throw new Error("second arg must be public key");return c.fromHex(e).multiply(l(t)).toRawBytes(n)},sign:function(t,n,r=k){const{seed:o,k2sig:i}=x(t,n,r),s=e;return Ht(s.hash.outputLen,s.nByteLength,s.hmac)(o,i)},verify:function(t,n,r,o=A){var i;const l=t;if(n=Nt("msgHash",n),r=Nt("publicKey",r),"strict"in o)throw new Error("options.strict was renamed to lowS");const{lowS:u,prehash:h}=o;let d,f;try{if("string"==typeof l||l instanceof Uint8Array)try{d=g.fromDER(l)}catch(t){if(!(t instanceof le.Err))throw t;d=g.fromCompact(l)}else{if("object"!=typeof l||"bigint"!=typeof l.r||"bigint"!=typeof l.s)throw new Error("PARSE");{const{r:t,s:e}=l;d=new g(t,e)}}f=c.fromHex(r)}catch(t){if("PARSE"===t.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(u&&d.hasHighS())return!1;h&&(n=e.hash(n));const{r:p,s:w}=d,b=m(n),y=a(w),v=s(b*y),E=s(p*y),x=null==(i=c.BASE.multiplyAndAddUnsafe(f,v,E))?void 0:i.toAffine();return!!x&&s(x.x)===p},ProjectivePoint:c,Signature:g,utils:w}}BigInt(4);let ge=class extends dt{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");ot(t.outputLen),ot(t.blockLen)}(t);const n=ht(e);if(this.iHash=t.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 r=this.blockLen,o=new Uint8Array(r);o.set(n.length>r?t.create().update(n).digest():n);for(let t=0;t<o.length;t++)o[t]^=54;this.iHash.update(o),this.oHash=t.create();for(let t=0;t<o.length;t++)o[t]^=106;this.oHash.update(o),o.fill(0)}update(t){return st(this),this.iHash.update(t),this}digestInto(t){st(this),it(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:n,finished:r,destroyed:o,blockLen:i,outputLen:s}=this;return t.finished=r,t.destroyed=o,t.blockLen=i,t.outputLen=s,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const we=(t,e,n)=>new ge(t,e).update(n).digest();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function be(t){return{hash:t,hmac:(e,...n)=>we(t,e,function(...t){const e=new Uint8Array(t.reduce(((t,e)=>t+e.length),0));let n=0;return t.forEach((t=>{if(!ct(t))throw new Error("Uint8Array expected");e.set(t,n),n+=t.length})),e}(...n)),randomBytes:ft}}we.create=(t,e)=>new ge(t,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ye=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),me=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),ve=BigInt(1),Ee=BigInt(2),xe=(t,e)=>(t+e/Ee)/e;function ke(t){const e=ye,n=BigInt(3),r=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),l=t*t*t%e,u=l*l*t%e,h=Qt(u,n,e)*u%e,d=Qt(h,n,e)*u%e,f=Qt(d,Ee,e)*l%e,p=Qt(f,o,e)*f%e,g=Qt(p,i,e)*p%e,w=Qt(g,a,e)*g%e,b=Qt(w,c,e)*w%e,y=Qt(b,a,e)*g%e,m=Qt(y,n,e)*u%e,v=Qt(m,s,e)*p%e,E=Qt(v,r,e)*l%e,x=Qt(E,Ee,e);if(!Ae.eql(Ae.sqr(x),t))throw new Error("Cannot find square root");return x}const Ae=function(t,e,n=!1,r={}){if(t<=zt)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:o,nByteLength:i}=ee(t,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=Xt(t),a=Object.freeze({ORDER:t,BITS:o,BYTES:i,MASK:Ut(o),ZERO:zt,ONE:Dt,create:e=>Yt(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("Invalid field element: expected bigint, got "+typeof e);return zt<=e&&e<t},is0:t=>t===zt,isOdd:t=>(t&Dt)===Dt,neg:e=>Yt(-e,t),eql:(t,e)=>t===e,sqr:e=>Yt(e*e,t),add:(e,n)=>Yt(e+n,t),sub:(e,n)=>Yt(e-n,t),mul:(e,n)=>Yt(e*n,t),pow:(t,e)=>function(t,e,n){if(n<zt)throw new Error("Expected power > 0");if(n===zt)return t.ONE;if(n===Dt)return e;let r=t.ONE,o=e;for(;n>zt;)n&Dt&&(r=t.mul(r,o)),o=t.sqr(o),n>>=Dt;return r}(a,t,e),div:(e,n)=>Yt(e*Gt(n,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>Gt(e,t),sqrt:r.sqrt||(t=>s(a,t)),invertBatch:t=>function(t,e){const n=new Array(e.length),r=e.reduce(((e,r,o)=>t.is0(r)?e:(n[o]=e,t.mul(e,r))),t.ONE),o=t.inv(r);return e.reduceRight(((e,r,o)=>t.is0(r)?e:(n[o]=t.mul(e,n[o]),t.mul(e,r))),o),n}(a,t),cmov:(t,e,n)=>n?e:t,toBytes:t=>n?$t(t,i):Ct(t,i),fromBytes:t=>{if(t.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${t.length}`);return n?Rt(t):Bt(t)}});return Object.freeze(a)}(ye,void 0,void 0,{sqrt:ke}),Se=function(t,e){const n=e=>pe({...t,...be(e)});return Object.freeze({...n(e),create:n})}({a:BigInt(0),b:BigInt(7),Fp:Ae,n:me,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=me,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-ve*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,s=BigInt("0x100000000000000000000000000000000"),a=xe(i*t,e),c=xe(-r*t,e);let l=Yt(t-a*n-c*o,e),u=Yt(-a*r-c*i,e);const h=l>s,d=u>s;if(h&&(l=e-l),d&&(u=e-u),l>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:h,k1:l,k2neg:d,k2:u}}}},Et),Te=BigInt(0),Ie=t=>"bigint"==typeof t&&Te<t&&t<ye,Pe={};function Be(t,...e){let n=Pe[t];if(void 0===n){const e=Et(Uint8Array.from(t,(t=>t.charCodeAt(0))));n=Lt(e,e),Pe[t]=n}return Et(Lt(n,...e))}const Re=t=>t.toRawBytes(!0).slice(1),Ce=t=>Ct(t,32),$e=t=>Yt(t,ye),Ne=t=>Yt(t,me),Le=Se.ProjectivePoint;function Ue(t){let e=Se.utils.normPrivateKeyToScalar(t),n=Le.fromPrivateKey(e);return{scalar:n.hasEvenY()?e:Ne(-e),bytes:Re(n)}}function Oe(t){if(!Ie(t))throw new Error("bad x: need 0 < x < p");const e=$e(t*t);let n=ke($e(e*t+BigInt(7)));n%Ee!==Te&&(n=$e(-n));const r=new Le(t,n,ve);return r.assertValidity(),r}function _e(...t){return Ne(Bt(Be("BIP0340/challenge",...t)))}function He(t,e,n){const r=Nt("signature",t,64),o=Nt("message",e),i=Nt("publicKey",n,32);try{const t=Oe(Bt(i)),e=Bt(r.subarray(0,32));if(!Ie(e))return!1;const n=Bt(r.subarray(32,64));if(!(t=>"bigint"==typeof t&&Te<t&&t<me)(n))return!1;const s=_e(Ce(e),Re(t),o),a=((t,e,n)=>Le.BASE.multiplyAndAddUnsafe(t,e,n))(t,n,Ne(-s));return!(!a||!a.hasEvenY()||a.toAffine().x!==e)}catch{return!1}}const Me={getPublicKey:function(t){return Ue(t).bytes},sign:function(t,e,n=ft(32)){const r=Nt("message",t),{bytes:o,scalar:i}=Ue(e),s=Nt("auxRand",n,32),a=Ce(i^Bt(Be("BIP0340/aux",s))),c=Be("BIP0340/nonce",a,o,r),l=Ne(Bt(c));if(l===Te)throw new Error("sign failed: k is zero");const{bytes:u,scalar:h}=Ue(l),d=_e(u,o,r),f=new Uint8Array(64);if(f.set(u,0),f.set(Ce(Ne(h+d*i)),32),!He(f,r,o))throw new Error("sign: Invalid signature produced");return f},verify:He,utils:{randomPrivateKey:Se.utils.randomPrivateKey,lift_x:Oe,pointToBytes:Re,numberToBytesBE:Ct,bytesToNumberBE:Bt,taggedHash:Be,mod:Yt}},je="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,qe=t=>t instanceof Uint8Array,ze=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),De=(t,e)=>t<<32-e|t>>>e;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");const Fe=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function Ke(t){if(!qe(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=Fe[t[n]];return e}function We(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);const e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(e/2);for(let e=0;e<n.length;e++){const r=2*e,o=t.slice(r,r+2),i=Number.parseInt(o,16);if(Number.isNaN(i)||i<0)throw new Error("Invalid byte sequence");n[e]=i}return n}function Ve(t){if("string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}(t)),!qe(t))throw new Error("expected Uint8Array, got "+typeof t);return t}function Je(...t){const e=new Uint8Array(t.reduce(((t,e)=>t+e.length),0));let n=0;return t.forEach((t=>{if(!qe(t))throw new Error("Uint8Array expected");e.set(t,n),n+=t.length})),e}class Ye{clone(){return this._cloneInto()}}function Ze(t){const e=e=>t().update(Ve(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function Qe(t=32){if(je&&"function"==typeof je.getRandomValues)return je.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}const Ge=Symbol("verified");function Xe(t){if(!(t=>t instanceof Object)(t)||"number"!=typeof t.kind||"string"!=typeof t.content||"number"!=typeof t.created_at||"string"!=typeof t.pubkey||!t.pubkey.match(/^[a-f0-9]{64}$/)||!Array.isArray(t.tags))return!1;for(let e=0;e<t.tags.length;e++){let n=t.tags[e];if(!Array.isArray(n))return!1;for(let t=0;t<n.length;t++)if("string"!=typeof n[t])return!1}return!0}function tn(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function en(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}const nn={number:tn,bool:function(t){if("boolean"!=typeof t)throw new Error(`Expected boolean, not ${t}`)},bytes:en,hash:function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");tn(t.outputLen),tn(t.blockLen)},exists:function(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")},output:function(t,e){en(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}};class rn extends Ye{constructor(t,e,n,r){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=ze(this.buffer)}update(t){nn.exists(this);const{view:e,buffer:n,blockLen:r}=this,o=(t=Ve(t)).length;for(let i=0;i<o;){const s=Math.min(r-this.pos,o-i);if(s!==r)n.set(t.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===r&&(this.process(e,0),this.pos=0);else{const e=ze(t);for(;r<=o-i;i+=r)this.process(e,i)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){nn.exists(this),nn.output(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:r,isLE:o}=this;let{pos:i}=this;e[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>r-i&&(this.process(n,0),i=0);for(let t=i;t<r;t++)e[t]=0;(function(t,e,n,r){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,n,r);const o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),a=Number(n&i),c=r?4:0,l=r?0:4;t.setUint32(e+c,s,r),t.setUint32(e+l,a,r)})(n,r-8,BigInt(8*this.length),o),this.process(n,0);const s=ze(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<c;t++)s.setUint32(4*t,l[t],o)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:n,length:r,finished:o,destroyed:i,pos:s}=this;return t.length=r,t.pos=s,t.finished=o,t.destroyed=i,r%e&&t.buffer.set(n),t}}const on=(t,e,n)=>t&e^~t&n,sn=(t,e,n)=>t&e^t&n^e&n,an=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]),cn=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ln=new Uint32Array(64);class un extends rn{constructor(){super(64,32,8,!1),this.A=0|cn[0],this.B=0|cn[1],this.C=0|cn[2],this.D=0|cn[3],this.E=0|cn[4],this.F=0|cn[5],this.G=0|cn[6],this.H=0|cn[7]}get(){const{A:t,B:e,C:n,D:r,E:o,F:i,G:s,H:a}=this;return[t,e,n,r,o,i,s,a]}set(t,e,n,r,o,i,s,a){this.A=0|t,this.B=0|e,this.C=0|n,this.D=0|r,this.E=0|o,this.F=0|i,this.G=0|s,this.H=0|a}process(t,e){for(let n=0;n<16;n++,e+=4)ln[n]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=ln[t-15],n=ln[t-2],r=De(e,7)^De(e,18)^e>>>3,o=De(n,17)^De(n,19)^n>>>10;ln[t]=o+ln[t-7]+r+ln[t-16]|0}let{A:n,B:r,C:o,D:i,E:s,F:a,G:c,H:l}=this;for(let t=0;t<64;t++){const e=l+(De(s,6)^De(s,11)^De(s,25))+on(s,a,c)+an[t]+ln[t]|0,u=(De(n,2)^De(n,13)^De(n,22))+sn(n,r,o)|0;l=c,c=a,a=s,s=i+e|0,i=o,o=r,r=n,n=e+u|0}n=n+this.A|0,r=r+this.B|0,o=o+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,o,i,s,a,c,l)}roundClean(){ln.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class hn extends un{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}}const dn=Ze((()=>new un));Ze((()=>new hn)),new TextDecoder("utf-8");const fn=new TextEncoder;function pn(t){try{-1===t.indexOf("://")&&(t="wss://"+t);let e=new URL(t);return"http:"===e.protocol?e.protocol="ws:":"https:"===e.protocol&&(e.protocol="wss:"),e.pathname=e.pathname.replace(/\/+/g,"/"),e.pathname.endsWith("/")&&(e.pathname=e.pathname.slice(0,-1)),("80"===e.port&&"ws:"===e.protocol||"443"===e.port&&"wss:"===e.protocol)&&(e.port=""),e.searchParams.sort(),e.hash="",e.toString()}catch{throw new Error(`Invalid URL: ${t}`)}}let gn=class{constructor(t){E(this,"value"),E(this,"next",null),E(this,"prev",null),this.value=t}},wn=class{constructor(){E(this,"first"),E(this,"last"),this.first=null,this.last=null}enqueue(t){const e=new gn(t);return this.last?this.last===this.first?(this.last=e,this.last.prev=this.first,this.first.next=e):(e.prev=this.last,this.last.next=e,this.last=e):(this.first=e,this.last=e),!0}dequeue(){if(!this.first)return null;if(this.first===this.last){const t=this.first;return this.first=null,this.last=null,t.value}const t=this.first;return this.first=t.next,this.first&&(this.first.prev=null),t.value}};function bn(t){let e=dn(fn.encode(function(t){if(!Xe(t))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,t.pubkey,t.created_at,t.kind,t.tags,t.content])}(t)));return Ke(e)}const yn=new class{generateSecretKey(){return Me.utils.randomPrivateKey()}getPublicKey(t){return Ke(Me.getPublicKey(t))}finalizeEvent(t,e){const n=t;return n.pubkey=Ke(Me.getPublicKey(e)),n.id=bn(n),n.sig=Ke(Me.sign(bn(n),e)),n[Ge]=!0,n}verifyEvent(t){if("boolean"==typeof t[Ge])return t[Ge];const e=bn(t);if(e!==t.id)return t[Ge]=!1,!1;try{const n=Me.verify(t.sig,e,t.pubkey);return t[Ge]=n,n}catch{return t[Ge]=!1,!1}}};yn.generateSecretKey,yn.getPublicKey,yn.finalizeEvent;const mn=yn.verifyEvent;function vn(t,e){if(t.ids&&-1===t.ids.indexOf(e.id)||t.kinds&&-1===t.kinds.indexOf(e.kind)||t.authors&&-1===t.authors.indexOf(e.pubkey))return!1;for(let n in t)if("#"===n[0]){let r=t[`#${n.slice(1)}`];if(r&&!e.tags.find((([t,e])=>t===n.slice(1)&&-1!==r.indexOf(e))))return!1}return!(t.since&&e.created_at<t.since||t.until&&e.created_at>t.until)}async function En(){return new Promise(((t,e)=>{try{if(typeof MessageChannel<"u"){const e=new MessageChannel,n=()=>{e.port1.removeEventListener("message",n),t()};e.port1.addEventListener("message",n),e.port2.postMessage(0),e.port1.start()}else typeof setImmediate<"u"?setImmediate(t):typeof setTimeout<"u"?setTimeout(t,0):t()}catch(t){console.error("during yield: ",t),e(t)}}))}const xn=t=>(t[Ge]=!0,!0);let kn=class extends Error{constructor(t,e){super(`Tried to send message '${t} on a closed connection to ${e}.`),this.name="SendingOnClosedConnection"}},An=class t{constructor(t,e){E(this,"url"),E(this,"_connected",!1),E(this,"onclose",null),E(this,"onnotice",(t=>console.debug(`NOTICE from ${this.url}: ${t}`))),E(this,"onauth"),E(this,"baseEoseTimeout",4400),E(this,"publishTimeout",4400),E(this,"pingFrequency",29e3),E(this,"pingTimeout",2e4),E(this,"resubscribeBackoff",[1e4,1e4,1e4,2e4,2e4,3e4,6e4]),E(this,"openSubs",new Map),E(this,"enablePing"),E(this,"enableReconnect"),E(this,"reconnectTimeoutHandle"),E(this,"pingIntervalHandle"),E(this,"reconnectAttempts",0),E(this,"closedIntentionally",!1),E(this,"connectionPromise"),E(this,"openCountRequests",new Map),E(this,"openEventPublishes",new Map),E(this,"ws"),E(this,"incomingMessageQueue",new wn),E(this,"queueRunning",!1),E(this,"challenge"),E(this,"authPromise"),E(this,"serial",0),E(this,"verifyEvent"),E(this,"_WebSocket"),this.url=pn(t),this.verifyEvent=e.verifyEvent,this._WebSocket=e.websocketImplementation||WebSocket,this.enablePing=e.enablePing,this.enableReconnect=e.enableReconnect||!1}static async connect(e,n){const r=new t(e,n);return await r.connect(n),r}closeAllSubscriptions(t){for(let[e,n]of this.openSubs)n.close(t);this.openSubs.clear();for(let[e,n]of this.openEventPublishes)n.reject(new Error(t));this.openEventPublishes.clear();for(let[e,n]of this.openCountRequests)n.reject(new Error(t));this.openCountRequests.clear()}get connected(){return this._connected}async reconnect(){const t=this.resubscribeBackoff[Math.min(this.reconnectAttempts,this.resubscribeBackoff.length-1)];this.reconnectAttempts++,this.reconnectTimeoutHandle=setTimeout((async()=>{try{await this.connect()}catch{}}),t)}handleHardClose(t){var e;this.pingIntervalHandle&&(clearInterval(this.pingIntervalHandle),this.pingIntervalHandle=void 0),this._connected=!1,this.connectionPromise=void 0;const n=this.closedIntentionally;this.closedIntentionally=!1,null==(e=this.onclose)||e.call(this),this.enableReconnect&&!n?this.reconnect():this.closeAllSubscriptions(t)}async connect(t){let e;return this.connectionPromise||(this.challenge=void 0,this.authPromise=void 0,this.connectionPromise=new Promise(((n,r)=>{null!=t&&t.timeout&&(e=setTimeout((()=>{var t;r("connection timed out"),this.connectionPromise=void 0,null==(t=this.onclose)||t.call(this),this.closeAllSubscriptions("relay connection timed out")}),t.timeout)),null!=t&&t.abort&&(t.abort.onabort=r);try{this.ws=new this._WebSocket(this.url)}catch(t){return clearTimeout(e),void r(t)}this.ws.onopen=()=>{this.reconnectTimeoutHandle&&(clearTimeout(this.reconnectTimeoutHandle),this.reconnectTimeoutHandle=void 0),clearTimeout(e),this._connected=!0;const t=this.reconnectAttempts>0;this.reconnectAttempts=0;for(const e of this.openSubs.values()){if(e.eosed=!1,t)for(let t=0;t<e.filters.length;t++)e.lastEmitted&&(e.filters[t].since=e.lastEmitted+1);e.fire()}this.enablePing&&(this.pingIntervalHandle=setInterval((()=>this.pingpong()),this.pingFrequency)),n()},this.ws.onerror=t=>{clearTimeout(e),r(t.message||"websocket error"),this.handleHardClose("relay connection errored")},this.ws.onclose=t=>{clearTimeout(e),r(t.message||"websocket closed"),this.handleHardClose("relay connection closed")},this.ws.onmessage=this._onmessage.bind(this)}))),this.connectionPromise}waitForPingPong(){return new Promise((t=>{this.ws.once("pong",(()=>t(!0))),this.ws.ping()}))}waitForDummyReq(){return new Promise(((t,e)=>{if(!this.connectionPromise)return e(new Error(`no connection to ${this.url}, can't ping`));try{const e=this.subscribe([{ids:["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"],limit:0}],{label:"forced-ping",oneose:()=>{t(!0),e.close()},onclose(){t(!0)},eoseTimeout:this.pingTimeout+1e3})}catch(t){e(t)}}))}async pingpong(){var t,e,n;1===(null==(t=this.ws)?void 0:t.readyState)&&(await Promise.any([this.ws&&this.ws.ping&&this.ws.once?this.waitForPingPong():this.waitForDummyReq(),new Promise((t=>setTimeout((()=>t(!1)),this.pingTimeout)))])||(null==(e=this.ws)?void 0:e.readyState)===this._WebSocket.OPEN&&(null==(n=this.ws)||n.close()))}async runQueue(){for(this.queueRunning=!0;!1!==this.handleNext();)await En();this.queueRunning=!1}handleNext(){var t,e,n;const r=this.incomingMessageQueue.dequeue();if(!r)return!1;const o=function(t){let e=t.slice(0,22).indexOf('"EVENT"');if(-1===e)return null;let n=t.slice(e+7+1).indexOf('"');if(-1===n)return null;let r=e+7+1+n,o=t.slice(r+1,80).indexOf('"');if(-1===o)return null;let i=r+1+o;return t.slice(r+1,i)}(r);if(o){const n=this.openSubs.get(o);if(!n)return;const i=function(t,e){let n=e.length+3,r=t.indexOf(`"${e}":`)+n,o=t.slice(r).indexOf('"')+r+1;return t.slice(o,o+64)}(r,"id"),s=null==(t=n.alreadyHaveEvent)?void 0:t.call(n,i);if(null==(e=n.receivedEvent)||e.call(n,this,i),s)return}try{let t=JSON.parse(r);switch(t[0]){case"EVENT":{const e=this.openSubs.get(t[1]),n=t[2];return this.verifyEvent(n)&&function(t,e){for(let n=0;n<t.length;n++)if(vn(t[n],e))return!0;return!1}(e.filters,n)&&e.onevent(n),void((!e.lastEmitted||e.lastEmitted<n.created_at)&&(e.lastEmitted=n.created_at))}case"COUNT":{const e=t[1],n=t[2],r=this.openCountRequests.get(e);return void(r&&(r.resolve(n.count),this.openCountRequests.delete(e)))}case"EOSE":{const e=this.openSubs.get(t[1]);if(!e)return;return void e.receivedEose()}case"OK":{const e=t[1],n=t[2],r=t[3],o=this.openEventPublishes.get(e);return void(o&&(clearTimeout(o.timeout),n?o.resolve(r):o.reject(new Error(r)),this.openEventPublishes.delete(e)))}case"CLOSED":{const e=t[1],n=this.openSubs.get(e);if(!n)return;return n.closed=!0,void n.close(t[2])}case"NOTICE":return void this.onnotice(t[1]);case"AUTH":return this.challenge=t[1],void(this.onauth&&this.auth(this.onauth));default:{const e=this.openSubs.get(t[1]);return void(null==(n=null==e?void 0:e.oncustom)||n.call(e,t))}}}catch{return}}async send(t){if(!this.connectionPromise)throw new kn(t,this.url);this.connectionPromise.then((()=>{var e;null==(e=this.ws)||e.send(t)}))}async auth(t){const e=this.challenge;if(!e)throw new Error("can't perform auth, no challenge was received");return this.authPromise||(this.authPromise=new Promise((async(n,r)=>{try{let o=await t(function(t,e){return{kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t],["challenge",e]],content:""}}(this.url,e)),i=setTimeout((()=>{let t=this.openEventPublishes.get(o.id);t&&(t.reject(new Error("auth timed out")),this.openEventPublishes.delete(o.id))}),this.publishTimeout);this.openEventPublishes.set(o.id,{resolve:n,reject:r,timeout:i}),this.send('["AUTH",'+JSON.stringify(o)+"]")}catch(t){console.warn("subscribe auth function failed:",t)}}))),this.authPromise}async publish(t){const e=new Promise(((e,n)=>{const r=setTimeout((()=>{const e=this.openEventPublishes.get(t.id);e&&(e.reject(new Error("publish timed out")),this.openEventPublishes.delete(t.id))}),this.publishTimeout);this.openEventPublishes.set(t.id,{resolve:e,reject:n,timeout:r})}));return this.send('["EVENT",'+JSON.stringify(t)+"]"),e}async count(t,e){this.serial++;const n=(null==e?void 0:e.id)||"count:"+this.serial,r=new Promise(((t,e)=>{this.openCountRequests.set(n,{resolve:t,reject:e})}));return this.send('["COUNT","'+n+'",'+JSON.stringify(t).substring(1)),r}subscribe(t,e){const n=this.prepareSubscription(t,e);return n.fire(),e.abort&&(e.abort.onabort=()=>n.close(String(e.abort.reason||"<aborted>"))),n}prepareSubscription(t,e){this.serial++;const n=e.id||(e.label?e.label+":":"sub:")+this.serial,r=new Sn(this,n,t,e);return this.openSubs.set(n,r),r}close(){var t,e,n;this.closedIntentionally=!0,this.reconnectTimeoutHandle&&(clearTimeout(this.reconnectTimeoutHandle),this.reconnectTimeoutHandle=void 0),this.pingIntervalHandle&&(clearInterval(this.pingIntervalHandle),this.pingIntervalHandle=void 0),this.closeAllSubscriptions("relay connection closed by us"),this._connected=!1,null==(t=this.onclose)||t.call(this),(null==(e=this.ws)?void 0:e.readyState)===this._WebSocket.OPEN&&(null==(n=this.ws)||n.close())}_onmessage(t){this.incomingMessageQueue.enqueue(t.data),this.queueRunning||this.runQueue()}},Sn=class{constructor(t,e,n,r){if(E(this,"relay"),E(this,"id"),E(this,"lastEmitted"),E(this,"closed",!1),E(this,"eosed",!1),E(this,"filters"),E(this,"alreadyHaveEvent"),E(this,"receivedEvent"),E(this,"onevent"),E(this,"oneose"),E(this,"onclose"),E(this,"oncustom"),E(this,"eoseTimeout"),E(this,"eoseTimeoutHandle"),0===n.length)throw new Error("subscription can't be created with zero filters");this.relay=t,this.filters=n,this.id=e,this.alreadyHaveEvent=r.alreadyHaveEvent,this.receivedEvent=r.receivedEvent,this.eoseTimeout=r.eoseTimeout||t.baseEoseTimeout,this.oneose=r.oneose,this.onclose=r.onclose,this.onevent=r.onevent||(t=>{console.warn(`onevent() callback not defined for subscription '${this.id}' in relay ${this.relay.url}. event received:`,t)})}fire(){this.relay.send('["REQ","'+this.id+'",'+JSON.stringify(this.filters).substring(1)),this.eoseTimeoutHandle=setTimeout(this.receivedEose.bind(this),this.eoseTimeout)}receivedEose(){var t;this.eosed||(clearTimeout(this.eoseTimeoutHandle),this.eosed=!0,null==(t=this.oneose)||t.call(this))}close(t="closed by caller"){var e;if(!this.closed&&this.relay.connected){try{this.relay.send('["CLOSE",'+JSON.stringify(this.id)+"]")}catch(t){if(!(t instanceof kn))throw t}this.closed=!0}this.relay.openSubs.delete(this.id),null==(e=this.onclose)||e.call(this,t)}},Tn=class{constructor(t){E(this,"relays",new Map),E(this,"seenOn",new Map),E(this,"trackRelays",!1),E(this,"verifyEvent"),E(this,"enablePing"),E(this,"enableReconnect"),E(this,"automaticallyAuth"),E(this,"trustedRelayURLs",new Set),E(this,"_WebSocket"),this.verifyEvent=t.verifyEvent,this._WebSocket=t.websocketImplementation,this.enablePing=t.enablePing,this.enableReconnect=t.enableReconnect||!1,this.automaticallyAuth=t.automaticallyAuth}async ensureRelay(t,e){t=pn(t);let n=this.relays.get(t);if(n||(n=new An(t,{verifyEvent:this.trustedRelayURLs.has(t)?xn:this.verifyEvent,websocketImplementation:this._WebSocket,enablePing:this.enablePing,enableReconnect:this.enableReconnect}),n.onclose=()=>{n&&!n.enableReconnect&&this.relays.delete(t)},this.relays.set(t,n)),this.automaticallyAuth){const e=this.automaticallyAuth(t);e&&(n.onauth=e)}return await n.connect({timeout:null==e?void 0:e.connectionTimeout,abort:null==e?void 0:e.abort}),n}close(t){t.map(pn).forEach((t=>{var e;null==(e=this.relays.get(t))||e.close(),this.relays.delete(t)}))}subscribe(t,e,n){const r=[];for(let n=0;n<t.length;n++){const o=pn(t[n]);r.find((t=>t.url===o))||r.push({url:o,filter:e})}return this.subscribeMap(r,n)}subscribeMany(t,e,n){const r=[],o=[];for(let n=0;n<t.length;n++){const i=pn(t[n]);-1===o.indexOf(i)&&(o.push(i),r.push({url:i,filter:e}))}return this.subscribeMap(r,n)}subscribeMap(t,e){const n=new Map;for(const e of t){const{url:t,filter:r}=e;n.has(t)||n.set(t,[]),n.get(t).push(r)}const r=Array.from(n.entries()).map((([t,e])=>({url:t,filters:e})));this.trackRelays&&(e.receivedEvent=(t,e)=>{let n=this.seenOn.get(e);n||(n=new Set,this.seenOn.set(e,n)),n.add(t)});const o=new Set,i=[],s=[];let a=t=>{var n;s[t]||(s[t]=!0,s.filter((t=>t)).length===r.length&&(null==(n=e.oneose)||n.call(e),a=()=>{}))};const c=[];let l=(t,n)=>{var o;c[t]||(a(t),c[t]=n,c.filter((t=>t)).length===r.length&&(null==(o=e.onclose)||o.call(e,c),l=()=>{}))};const u=t=>{var n;if(null!=(n=e.alreadyHaveEvent)&&n.call(e,t))return!0;const r=o.has(t);return o.add(t),r},h=Promise.all(r.map((async({url:t,filters:n},r)=>{let o;try{o=await this.ensureRelay(t,{connectionTimeout:e.maxWait?Math.max(.8*e.maxWait,e.maxWait-1e3):void 0,abort:e.abort})}catch(t){return void l(r,(null==t?void 0:t.message)||String(t))}let s=o.subscribe(n,{...e,oneose:()=>a(r),onclose:t=>{t.startsWith("auth-required: ")&&e.onauth?o.auth(e.onauth).then((()=>{o.subscribe(n,{...e,oneose:()=>a(r),onclose:t=>{l(r,t)},alreadyHaveEvent:u,eoseTimeout:e.maxWait,abort:e.abort})})).catch((t=>{l(r,`auth was required and attempted, but failed with: ${t}`)})):l(r,t)},alreadyHaveEvent:u,eoseTimeout:e.maxWait,abort:e.abort});i.push(s)})));return{async close(t){await h,i.forEach((e=>{e.close(t)}))}}}subscribeEose(t,e,n){const r=this.subscribe(t,e,{...n,oneose(){r.close("closed automatically on eose")}});return r}subscribeManyEose(t,e,n){const r=this.subscribeMany(t,e,{...n,oneose(){r.close("closed automatically on eose")}});return r}async querySync(t,e,n){return new Promise((async r=>{const o=[];this.subscribeEose(t,e,{...n,onevent(t){o.push(t)},onclose(t){r(o)}})}))}async get(t,e,n){e.limit=1;const r=await this.querySync(t,e,n);return r.sort(((t,e)=>e.created_at-t.created_at)),r[0]||null}publish(t,e,n){return t.map(pn).map((async(t,r,o)=>{if(o.indexOf(t)!==r)return Promise.reject("duplicate url");let i=await this.ensureRelay(t);return i.publish(e).catch((async t=>{if(t instanceof Error&&t.message.startsWith("auth-required: ")&&null!=n&&n.onauth)return await i.auth(n.onauth),i.publish(e);throw t})).then((t=>{if(this.trackRelays){let t=this.seenOn.get(e.id);t||(t=new Set,this.seenOn.set(e.id,t)),t.add(i)}return t}))}))}listConnectionStatus(){const t=new Map;return this.relays.forEach(((e,n)=>t.set(n,e.connected))),t}destroy(){this.relays.forEach((t=>t.close())),this.relays=new Map}};var In;try{In=WebSocket}catch{}var Pn=Math.pow(2,8)-1,Bn=Math.pow(2,16)-1,Rn=Math.pow(2,32)-1;function Cn(t){if(this.capacity=t,"number"!=typeof this.capacity||this.capacity<=0)throw new Error("mnemonist/lru-cache: capacity should be positive number.");if(!isFinite(this.capacity)||Math.floor(this.capacity)!==this.capacity)throw new Error("mnemonist/lru-cache: capacity should be a finite positive integer.");var e=function(t){var e=t-1;if(e<=Pn)return Uint8Array;if(e<=Bn)return Uint16Array;if(e<=Rn)return Uint32Array;throw new Error("mnemonist: Pointer Array of size > 4294967295 is not supported.")}(t);this.forward=new e(t),this.backward=new e(t),this.K=new Array(t),this.V=new Array(t),this.size=0,this.head=0,this.tail=0,this.items={}}Cn.prototype.clear=function(){this.size=0,this.head=0,this.tail=0,this.items={}},Cn.prototype.splayOnTop=function(t){var e=this.head;if(this.head===t)return this;var n=this.backward[t],r=this.forward[t];return this.tail===t?this.tail=n:this.backward[r]=n,this.forward[n]=r,this.backward[e]=t,this.head=t,this.forward[t]=e,this},Cn.prototype.set=function(t,e){var n=this.items[t];if(typeof n<"u")return this.splayOnTop(n),void(this.V[n]=e);this.size<this.capacity?n=this.size++:(n=this.tail,this.tail=this.backward[n],delete this.items[this.K[n]]),this.items[t]=n,this.K[n]=t,this.V[n]=e,this.forward[n]=this.head,this.backward[this.head]=n,this.head=n},Cn.prototype.setpop=function(t,e){var n=null,r=null,o=this.items[t];return typeof o<"u"?(this.splayOnTop(o),n=this.V[o],this.V[o]=e,{evicted:!1,key:t,value:n}):(this.size<this.capacity?o=this.size++:(o=this.tail,this.tail=this.backward[o],n=this.V[o],r=this.K[o],delete this.items[r]),this.items[t]=o,this.K[o]=t,this.V[o]=e,this.forward[o]=this.head,this.backward[this.head]=o,this.head=o,r?{evicted:!0,key:r,value:n}:null)},Cn.prototype.has=function(t){return t in this.items},Cn.prototype.get=function(t){var e=this.items[t];if(!(typeof e>"u"))return this.splayOnTop(e),this.V[e]},Cn.prototype.peek=function(t){var e=this.items[t];if(!(typeof e>"u"))return this.V[e]};class $n{constructor(t,e){if(E(this,"_batchLoadFn"),E(this,"_maxBatchSize"),E(this,"_cacheKeyFn"),E(this,"_cacheMap"),E(this,"_batch"),"function"!=typeof t)throw new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but got: ${t}.`);this._batchLoadFn=t,this._maxBatchSize=(null==e?void 0:e.maxBatchSize)||1/0,this._cacheKeyFn=null==e?void 0:e.cacheKeyFn;const n=new Cn(2e3);this._cacheMap={get:e.transformCacheHit?t=>{var r;return null==(r=n.get(t))?void 0:r.then(e.transformCacheHit)}:t=>n.get(t),set:(t,e)=>n.set(t,e),delete(t){n.set(t,void 0)},clear(){n.clear()}},this._batch=null}load(t){if(null==t)throw new TypeError(`The loader.load() function must be called with a value, but got: ${String(t)}.`);const e=function(t){const e=t._batch;if(null!==e&&!e.hasDispatched&&e.keys.length<t._maxBatchSize)return e;const n={hasDispatched:!1,keys:[],callbacks:[]};return t._batch=n,setTimeout((()=>{!function(t,e){if(e.hasDispatched=!0,0===e.keys.length)return void Ln(e);let n;try{n=t._batchLoadFn(e.keys)}catch(n){return Nn(t,e,new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function errored synchronously: ${String(n)}.`))}if(!n||"function"!=typeof n.then)return Nn(t,e,new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise: ${String(n)}.`));n.then((t=>{if(t.length!==e.keys.length)throw new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array of the same length as the Array of keys.\n\nKeys:\n${String(e.keys)}\n\nValues:\n${String(t)}`);Ln(e);for(let n=0;n<e.callbacks.length;n++){const r=t[n];r instanceof Error?e.callbacks[n].reject(r):e.callbacks[n].resolve(r)}})).catch((n=>{Nn(t,e,n)}))}(t,n)})),n}(this),n=this._cacheKeyFn(t),r=this._cacheMap.get(n);if(r){const t=e.cacheHits||(e.cacheHits=[]);return new Promise((e=>{t.push((()=>{e(r)}))}))}e.keys.push(t);const o=new Promise(((t,n)=>{e.callbacks.push({resolve:t,reject:n})}));return this._cacheMap.set(n,o),o}clear(t){const e=this._cacheMap;if(e){const n=this._cacheKeyFn(t);e.delete(n)}return this}}function Nn(t,e,n){Ln(e);for(let r=0;r<e.keys.length;r++)t.clear(e.keys[r]),e.callbacks[r].reject(n)}function Ln(t){if(t.cacheHits)for(let e=0;e<t.cacheHits.length;e++)t.cacheHits[e]()}function Un(t){return new Promise(((e,n)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>n(t.error)}))}function On(t,e){let n;return(r,o)=>(()=>{if(n)return n;const r=indexedDB.open(t);return r.onupgradeneeded=()=>r.result.createObjectStore(e),n=Un(r),n.then((t=>{t.onclose=()=>n=void 0}),(()=>{})),n})().then((t=>o(t.transaction(e,r).objectStore(e))))}let _n;function Hn(){return _n||(_n=On("keyval-store","keyval")),_n}function Mn(t){for(let e=0;e<64;e++){let n=t.charCodeAt(e);if(isNaN(n)||n<48||n>102||n>57&&n<97)return!1}return!0}function jn(t){return!!t}let qn=0;const zn=Symbol("event was just downloaded or force-updated, not loaded from cache");Kn(3,["wss://purplepag.es","wss://relay.nos.social","wss://relay.primal.net"],Fn((t=>{if(t.length>=2&&"p"===t[0]&&Mn(t[1]))return t[1]}))),Kn(10101,[],Fn((t=>{if(t.length>=2&&"p"===t[0]&&Mn(t[1]))return t[1]}))),Kn(10102,[],Fn((t=>{if(t.length>=2&&"relay"===t[0])return t[1]}))),Kn(10012,[],Fn((t=>{if(t.length>=2)switch(t[0]){case"relay":return pn(t[1]);case"a":const e=t[1].split(":");return Mn(e[1])&&"30002"===e[0]?{identifier:e.slice(2).join(":"),pubkey:e[1],kind:parseInt(e[0]),relays:t[2]?[t[2]]:[]}:void 0}})));const Dn=Kn(10002,["wss://purplepag.es","wss://relay.nos.social","wss://indexer.coracle.social"],Fn((t=>2===t.length?{url:t[1],read:!0,write:!0}:"read"===t[2]?{url:t[1],read:!0,write:!1}:"write"===t[2]?{url:t[1],read:!1,write:!0}:void 0)));function Fn(t){return e=>e?e.tags.map(t).filter(jn):[]}function Kn(t,e,n){const r=On(`@nostr/gadgets/list:${t}`,"cache"),o=new $n((o=>new Promise((async i=>{var s;let a=[],c=Math.round(Date.now()/1e3),l=await function(t,e=Hn()){return e("readonly",(e=>Promise.all(t.map((t=>Un(e.get(t)))))))}(o.map((t=>t.target)),r).then((t=>t.map(((t,e)=>{const i=o[e];if(i.index=e,"object"==typeof i.refreshStyle){const t={event:i.refreshStyle,items:n(i.refreshStyle),[zn]:!0};return function(t,e,n=Hn()){n("readwrite",(n=>(n.put(e,t),Un(n.transaction))))}(i.target,t,r),t}return t?!0===i.refreshStyle||!t.lastAttempt||t.lastAttempt<c-172800?(!1!==i.refreshStyle&&a.push(i),{...t,[zn]:!1}):null===t.event&&t.lastAttempt<Date.now()/1e3-3600?(!1!==i.refreshStyle&&a.push(i),{...t,[zn]:!1}):{...t,[zn]:!1}:(!1!==i.refreshStyle&&a.push(i),{items:i.defaultItems||[],event:null,[zn]:!1})}))));if(0===a.length)return void i(l);const u={};for(let n=0;n<a.length;n++){const r=a[n],o=r.relays.slice(0,Math.min(4,r.relays.length));do{o.push(Wn(e))}while(o.length<3);for(let e=0;e<o.length;e++){const n=o[e];let i=u[n];i||(i={kinds:[t],authors:[]},u[n]=i),null==(s=i.authors)||s.push(r.target)}}try{let e;e=Vn.subscribeMap(Object.entries(u).map((([t,e])=>({url:t,filter:e}))),{label:`kind:${t}:batch(${a.length})`,onevent(t){var e;for(let r=0;r<a.length;r++){const o=a[r];if(o.target===t.pubkey){const r=null==(e=l[o.index])?void 0:e.event;if(((null==r?void 0:r.created_at)||0)>t.created_at)return;return void(l[o.index]={event:t,items:n(t),[zn]:!0})}}},oneose(){null==e||e.close()},async onclose(){i(l),function(t,e=Hn()){e("readwrite",(e=>(t.forEach((t=>e.put(t[1],t[0]))),Un(e.transaction))))}(a.map((t=>[t.target,{...l[t.index],lastAttempt:c}])),r)}})}catch(t){i(l.map((e=>t)))}}))),{cacheKeyFn:t=>t.target,transformCacheHit:t=>(t[zn]=!1,t)});return async function(e,n=[],i,s){if(null===i)return await function(t,e=Hn()){return e("readwrite",(e=>(e.delete(t),Un(e.transaction))))}(e,r),o._cacheMap.delete(e),{items:s||[],event:null,[zn]:!0};let a=n;if(10002===t)return await o.load({target:e,relays:a,refreshStyle:i,defaultItems:s});{const t=await Dn(e,n,i);a.push(...t.items.filter((({write:t})=>t)).map((({url:t})=>t)).slice(0,3));const r={target:e,relays:a,refreshStyle:i,defaultItems:s};return i&&o.clear(r),await o.load(r)}}}function Wn(t){return t[qn++%t.length]}Kn(1e4,[],Fn((t=>{if(t.length>=2)switch(t[0]){case"p":if(Mn(t[1]))return{label:"pubkey",value:t[1]};break;case"e":if(Mn(t[1]))return{label:"thread",value:t[1]};break;case"t":return{label:"hashtag",value:t[1]};case"word":return{label:"word",value:t[1]}}else;}))),Kn(10003,[],Fn((t=>{if(t.length>=2&&("e"===t[0]||"a"===t[0])&&t[1])return t[1]}))),Kn(10063,[],(t=>t?t.tags.filter((([t,e])=>"server"===t&&e)).map((([,t])=>"http"+pn(t).substring(2))).filter(Boolean):[])),Kn(10030,[],Fn((t=>{if(!(t.length<2)){if("a"===t[0]){const e=t[1].split(":");return Mn(e[1])&&"30030"===e[0]?{identifier:e.slice(2).join(":"),pubkey:e[1],kind:parseInt(e[0]),relays:t[2]?[t[2]]:[]}:void 0}if(!(t.length<3||"emoji"!==t[0]))return{shortcode:t[1],url:t[2]}}}))),Kn(10001,[],Fn((t=>{if(t.length>=2&&"e"===t[0]&&t[1])return t[1]})));let Vn=new class extends Tn{constructor(t){super({verifyEvent:mn,websocketImplementation:In,...t})}};var Jn={},Yn={},Zn={};let Qn;const Gn=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];Zn.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return 4*t+17},Zn.getSymbolTotalCodewords=function(t){return Gn[t]},Zn.getBCHDigit=function(t){let e=0;for(;0!==t;)e++,t>>>=1;return e},Zn.setToSJISFunction=function(t){if("function"!=typeof t)throw new Error('"toSJISFunc" is not a valid function.');Qn=t},Zn.isKanjiModeEnabled=function(){return typeof Qn<"u"},Zn.toSJIS=function(t){return Qn(t)};var Xn,tr={};function er(){this.buffer=[],this.length=0}(Xn=tr).L={bit:1},Xn.M={bit:0},Xn.Q={bit:3},Xn.H={bit:2},Xn.isValid=function(t){return t&&typeof t.bit<"u"&&t.bit>=0&&t.bit<4},Xn.from=function(t,e){if(Xn.isValid(t))return t;try{return function(t){if("string"!=typeof t)throw new Error("Param is not a string");switch(t.toLowerCase()){case"l":case"low":return Xn.L;case"m":case"medium":return Xn.M;case"q":case"quartile":return Xn.Q;case"h":case"high":return Xn.H;default:throw new Error("Unknown EC Level: "+t)}}(t)}catch{return e}},er.prototype={get:function(t){const e=Math.floor(t/8);return 1==(this.buffer[e]>>>7-t%8&1)},put:function(t,e){for(let n=0;n<e;n++)this.putBit(1==(t>>>e-n-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}};var nr=er;function rr(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}rr.prototype.set=function(t,e,n,r){const o=t*this.size+e;this.data[o]=n,r&&(this.reservedBit[o]=!0)},rr.prototype.get=function(t,e){return this.data[t*this.size+e]},rr.prototype.xor=function(t,e,n){this.data[t*this.size+e]^=n},rr.prototype.isReserved=function(t,e){return this.reservedBit[t*this.size+e]};var or=rr,ir={};!function(t){const e=Zn.getSymbolSize;t.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,r=e(t),o=145===r?26:2*Math.ceil((r-13)/(2*n-2)),i=[r-7];for(let t=1;t<n-1;t++)i[t]=i[t-1]-o;return i.push(6),i.reverse()},t.getPositions=function(e){const n=[],r=t.getRowColCoords(e),o=r.length;for(let t=0;t<o;t++)for(let e=0;e<o;e++)0===t&&0===e||0===t&&e===o-1||t===o-1&&0===e||n.push([r[t],r[e]]);return n}}(ir);var sr={};const ar=Zn.getSymbolSize;sr.getPositions=function(t){const e=ar(t);return[[0,0],[e-7,0],[0,e-7]]};var cr={};!function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const e=3,n=3,r=40,o=10;function i(e,n,r){switch(e){case t.Patterns.PATTERN000:return(n+r)%2==0;case t.Patterns.PATTERN001:return n%2==0;case t.Patterns.PATTERN010:return r%3==0;case t.Patterns.PATTERN011:return(n+r)%3==0;case t.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case t.Patterns.PATTERN101:return n*r%2+n*r%3==0;case t.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case t.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw new Error("bad maskPattern:"+e)}}t.isValid=function(t){return null!=t&&""!==t&&!isNaN(t)&&t>=0&&t<=7},t.from=function(e){return t.isValid(e)?parseInt(e,10):void 0},t.getPenaltyN1=function(t){const n=t.size;let r=0,o=0,i=0,s=null,a=null;for(let c=0;c<n;c++){o=i=0,s=a=null;for(let l=0;l<n;l++){let n=t.get(c,l);n===s?o++:(o>=5&&(r+=e+(o-5)),s=n,o=1),n=t.get(l,c),n===a?i++:(i>=5&&(r+=e+(i-5)),a=n,i=1)}o>=5&&(r+=e+(o-5)),i>=5&&(r+=e+(i-5))}return r},t.getPenaltyN2=function(t){const e=t.size;let r=0;for(let n=0;n<e-1;n++)for(let o=0;o<e-1;o++){const e=t.get(n,o)+t.get(n,o+1)+t.get(n+1,o)+t.get(n+1,o+1);(4===e||0===e)&&r++}return r*n},t.getPenaltyN3=function(t){const e=t.size;let n=0,o=0,i=0;for(let r=0;r<e;r++){o=i=0;for(let s=0;s<e;s++)o=o<<1&2047|t.get(r,s),s>=10&&(1488===o||93===o)&&n++,i=i<<1&2047|t.get(s,r),s>=10&&(1488===i||93===i)&&n++}return n*r},t.getPenaltyN4=function(t){let e=0;const n=t.data.length;for(let r=0;r<n;r++)e+=t.data[r];return Math.abs(Math.ceil(100*e/n/5)-10)*o},t.applyMask=function(t,e){const n=e.size;for(let r=0;r<n;r++)for(let o=0;o<n;o++)e.isReserved(o,r)||e.xor(o,r,i(t,o,r))},t.getBestMask=function(e,n){const r=Object.keys(t.Patterns).length;let o=0,i=1/0;for(let s=0;s<r;s++){n(s),t.applyMask(s,e);const r=t.getPenaltyN1(e)+t.getPenaltyN2(e)+t.getPenaltyN3(e)+t.getPenaltyN4(e);t.applyMask(s,e),r<i&&(i=r,o=s)}return o}}(cr);var lr={};const ur=tr,hr=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],dr=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];lr.getBlocksCount=function(t,e){switch(e){case ur.L:return hr[4*(t-1)+0];case ur.M:return hr[4*(t-1)+1];case ur.Q:return hr[4*(t-1)+2];case ur.H:return hr[4*(t-1)+3];default:return}},lr.getTotalCodewordsCount=function(t,e){switch(e){case ur.L:return dr[4*(t-1)+0];case ur.M:return dr[4*(t-1)+1];case ur.Q:return dr[4*(t-1)+2];case ur.H:return dr[4*(t-1)+3];default:return}};var fr={},pr={};const gr=new Uint8Array(512),wr=new Uint8Array(256);(function(){let t=1;for(let e=0;e<255;e++)gr[e]=t,wr[t]=e,t<<=1,256&t&&(t^=285);for(let t=255;t<512;t++)gr[t]=gr[t-255]})(),pr.log=function(t){if(t<1)throw new Error("log("+t+")");return wr[t]},pr.exp=function(t){return gr[t]},pr.mul=function(t,e){return 0===t||0===e?0:gr[wr[t]+wr[e]]},function(t){const e=pr;t.mul=function(t,n){const r=new Uint8Array(t.length+n.length-1);for(let o=0;o<t.length;o++)for(let i=0;i<n.length;i++)r[o+i]^=e.mul(t[o],n[i]);return r},t.mod=function(t,n){let r=new Uint8Array(t);for(;r.length-n.length>=0;){const t=r[0];for(let o=0;o<n.length;o++)r[o]^=e.mul(n[o],t);let o=0;for(;o<r.length&&0===r[o];)o++;r=r.slice(o)}return r},t.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let o=0;o<n;o++)r=t.mul(r,new Uint8Array([1,e.exp(o)]));return r}}(fr);const br=fr;function yr(t){this.genPoly=void 0,this.degree=t,this.degree&&this.initialize(this.degree)}yr.prototype.initialize=function(t){this.degree=t,this.genPoly=br.generateECPolynomial(this.degree)},yr.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");const e=new Uint8Array(t.length+this.degree);e.set(t);const n=br.mod(e,this.genPoly),r=this.degree-n.length;if(r>0){const t=new Uint8Array(this.degree);return t.set(n,r),t}return n};var mr=yr,vr={},Er={},xr={isValid:function(t){return!isNaN(t)&&t>=1&&t<=40}},kr={};const Ar="[0-9]+";let Sr="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";Sr=Sr.replace(/u/g,"\\u");const Tr="(?:(?![A-Z0-9 $%*+\\-./:]|"+Sr+")(?:.|[\r\n]))+";kr.KANJI=new RegExp(Sr,"g"),kr.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),kr.BYTE=new RegExp(Tr,"g"),kr.NUMERIC=new RegExp(Ar,"g"),kr.ALPHANUMERIC=new RegExp("[A-Z $%*+\\-./:]+","g");const Ir=new RegExp("^"+Sr+"$"),Pr=new RegExp("^"+Ar+"$"),Br=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");kr.testKanji=function(t){return Ir.test(t)},kr.testNumeric=function(t){return Pr.test(t)},kr.testAlphanumeric=function(t){return Br.test(t)},function(t){const e=xr,n=kr;t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(t,n){if(!t.ccBits)throw new Error("Invalid mode: "+t);if(!e.isValid(n))throw new Error("Invalid version: "+n);return n>=1&&n<10?t.ccBits[0]:n<27?t.ccBits[1]:t.ccBits[2]},t.getBestModeForData=function(e){return n.testNumeric(e)?t.NUMERIC:n.testAlphanumeric(e)?t.ALPHANUMERIC:n.testKanji(e)?t.KANJI:t.BYTE},t.toString=function(t){if(t&&t.id)return t.id;throw new Error("Invalid mode")},t.isValid=function(t){return t&&t.bit&&t.ccBits},t.from=function(e,n){if(t.isValid(e))return e;try{return function(e){if("string"!=typeof e)throw new Error("Param is not a string");switch(e.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+e)}}(e)}catch{return n}}}(Er),function(t){const e=Zn,n=lr,r=tr,o=Er,i=xr,s=e.getBCHDigit(7973);function a(t,e){return o.getCharCountIndicator(t,e)+4}function c(t,e){let n=0;return t.forEach((function(t){const r=a(t.mode,e);n+=r+t.getBitsLength()})),n}t.from=function(t,e){return i.isValid(t)?parseInt(t,10):e},t.getCapacity=function(t,r,s){if(!i.isValid(t))throw new Error("Invalid QR Code version");typeof s>"u"&&(s=o.BYTE);const c=8*(e.getSymbolTotalCodewords(t)-n.getTotalCodewordsCount(t,r));if(s===o.MIXED)return c;const l=c-a(s,t);switch(s){case o.NUMERIC:return Math.floor(l/10*3);case o.ALPHANUMERIC:return Math.floor(l/11*2);case o.KANJI:return Math.floor(l/13);case o.BYTE:default:return Math.floor(l/8)}},t.getBestVersionForData=function(e,n){let i;const s=r.from(n,r.M);if(Array.isArray(e)){if(e.length>1)return function(e,n){for(let r=1;r<=40;r++)if(c(e,r)<=t.getCapacity(r,n,o.MIXED))return r}(e,s);if(0===e.length)return 1;i=e[0]}else i=e;return function(e,n,r){for(let o=1;o<=40;o++)if(n<=t.getCapacity(o,r,e))return o}(i.mode,i.getLength(),s)},t.getEncodedBits=function(t){if(!i.isValid(t)||t<7)throw new Error("Invalid QR Code version");let n=t<<12;for(;e.getBCHDigit(n)-s>=0;)n^=7973<<e.getBCHDigit(n)-s;return t<<12|n}}(vr);var Rr={};const Cr=Zn,$r=Cr.getBCHDigit(1335);Rr.getEncodedBits=function(t,e){const n=t.bit<<3|e;let r=n<<10;for(;Cr.getBCHDigit(r)-$r>=0;)r^=1335<<Cr.getBCHDigit(r)-$r;return 21522^(n<<10|r)};var Nr={};const Lr=Er;function Ur(t){this.mode=Lr.NUMERIC,this.data=t.toString()}Ur.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)},Ur.prototype.getLength=function(){return this.data.length},Ur.prototype.getBitsLength=function(){return Ur.getBitsLength(this.data.length)},Ur.prototype.write=function(t){let e,n,r;for(e=0;e+3<=this.data.length;e+=3)n=this.data.substr(e,3),r=parseInt(n,10),t.put(r,10);const o=this.data.length-e;o>0&&(n=this.data.substr(e),r=parseInt(n,10),t.put(r,3*o+1))};var Or=Ur;const _r=Er,Hr=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function Mr(t){this.mode=_r.ALPHANUMERIC,this.data=t}Mr.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},Mr.prototype.getLength=function(){return this.data.length},Mr.prototype.getBitsLength=function(){return Mr.getBitsLength(this.data.length)},Mr.prototype.write=function(t){let e;for(e=0;e+2<=this.data.length;e+=2){let n=45*Hr.indexOf(this.data[e]);n+=Hr.indexOf(this.data[e+1]),t.put(n,11)}this.data.length%2&&t.put(Hr.indexOf(this.data[e]),6)};var jr=Mr;const qr=Er;function zr(t){this.mode=qr.BYTE,this.data="string"==typeof t?(new TextEncoder).encode(t):new Uint8Array(t)}zr.getBitsLength=function(t){return 8*t},zr.prototype.getLength=function(){return this.data.length},zr.prototype.getBitsLength=function(){return zr.getBitsLength(this.data.length)},zr.prototype.write=function(t){for(let e=0,n=this.data.length;e<n;e++)t.put(this.data[e],8)};var Dr=zr;const Fr=Er,Kr=Zn;function Wr(t){this.mode=Fr.KANJI,this.data=t}Wr.getBitsLength=function(t){return 13*t},Wr.prototype.getLength=function(){return this.data.length},Wr.prototype.getBitsLength=function(){return Wr.getBitsLength(this.data.length)},Wr.prototype.write=function(t){let e;for(e=0;e<this.data.length;e++){let n=Kr.toSJIS(this.data[e]);if(n>=33088&&n<=40956)n-=33088;else{if(!(n>=57408&&n<=60351))throw new Error("Invalid SJIS character: "+this.data[e]+"\nMake sure your charset is UTF-8");n-=49472}n=192*(n>>>8&255)+(255&n),t.put(n,13)}};var Vr=Wr,Jr={exports:{}};!function(t){var e={single_source_shortest_paths:function(t,n,r){var o={},i={};i[n]=0;var s,a,c,l,u,h,d,f=e.PriorityQueue.make();for(f.push(n,0);!f.empty();)for(c in a=(s=f.pop()).value,l=s.cost,u=t[a]||{})u.hasOwnProperty(c)&&(h=l+u[c],d=i[c],(typeof i[c]>"u"||d>h)&&(i[c]=h,f.push(c,h),o[c]=a));if(typeof r<"u"&&typeof i[r]>"u"){var p=["Could not find a path from ",n," to ",r,"."].join("");throw new Error(p)}return o},extract_shortest_path_from_predecessor_list:function(t,e){for(var n=[],r=e;r;)n.push(r),t[r],r=t[r];return n.reverse(),n},find_path:function(t,n,r){var o=e.single_source_shortest_paths(t,n,r);return e.extract_shortest_path_from_predecessor_list(o,r)},PriorityQueue:{make:function(t){var n,r=e.PriorityQueue,o={};for(n in t=t||{},r)r.hasOwnProperty(n)&&(o[n]=r[n]);return o.queue=[],o.sorter=t.sorter||r.default_sorter,o},default_sorter:function(t,e){return t.cost-e.cost},push:function(t,e){var n={value:t,cost:e};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};t.exports=e}(Jr);var Yr=Jr.exports;!function(t){const e=Er,n=Or,r=jr,o=Dr,i=Vr,s=kr,a=Zn,c=Yr;function l(t){return unescape(encodeURIComponent(t)).length}function u(t,e,n){const r=[];let o;for(;null!==(o=t.exec(n));)r.push({data:o[0],index:o.index,mode:e,length:o[0].length});return r}function h(t){const n=u(s.NUMERIC,e.NUMERIC,t),r=u(s.ALPHANUMERIC,e.ALPHANUMERIC,t);let o,i;return a.isKanjiModeEnabled()?(o=u(s.BYTE,e.BYTE,t),i=u(s.KANJI,e.KANJI,t)):(o=u(s.BYTE_KANJI,e.BYTE,t),i=[]),n.concat(r,o,i).sort((function(t,e){return t.index-e.index})).map((function(t){return{data:t.data,mode:t.mode,length:t.length}}))}function d(t,s){switch(s){case e.NUMERIC:return n.getBitsLength(t);case e.ALPHANUMERIC:return r.getBitsLength(t);case e.KANJI:return i.getBitsLength(t);case e.BYTE:return o.getBitsLength(t)}}function f(t,s){let c;const l=e.getBestModeForData(t);if(c=e.from(s,l),c!==e.BYTE&&c.bit<l.bit)throw new Error('"'+t+'" cannot be encoded with mode '+e.toString(c)+".\n Suggested mode is: "+e.toString(l));switch(c===e.KANJI&&!a.isKanjiModeEnabled()&&(c=e.BYTE),c){case e.NUMERIC:return new n(t);case e.ALPHANUMERIC:return new r(t);case e.KANJI:return new i(t);case e.BYTE:return new o(t)}}t.fromArray=function(t){return t.reduce((function(t,e){return"string"==typeof e?t.push(f(e,null)):e.data&&t.push(f(e.data,e.mode)),t}),[])},t.fromString=function(n,r){const o=function(t){const n=[];for(let r=0;r<t.length;r++){const o=t[r];switch(o.mode){case e.NUMERIC:n.push([o,{data:o.data,mode:e.ALPHANUMERIC,length:o.length},{data:o.data,mode:e.BYTE,length:o.length}]);break;case e.ALPHANUMERIC:n.push([o,{data:o.data,mode:e.BYTE,length:o.length}]);break;case e.KANJI:n.push([o,{data:o.data,mode:e.BYTE,length:l(o.data)}]);break;case e.BYTE:n.push([{data:o.data,mode:e.BYTE,length:l(o.data)}])}}return n}(h(n,a.isKanjiModeEnabled())),i=function(t,n){const r={},o={start:{}};let i=["start"];for(let s=0;s<t.length;s++){const a=t[s],c=[];for(let t=0;t<a.length;t++){const l=a[t],u=""+s+t;c.push(u),r[u]={node:l,lastCount:0},o[u]={};for(let t=0;t<i.length;t++){const s=i[t];r[s]&&r[s].node.mode===l.mode?(o[s][u]=d(r[s].lastCount+l.length,l.mode)-d(r[s].lastCount,l.mode),r[s].lastCount+=l.length):(r[s]&&(r[s].lastCount=l.length),o[s][u]=d(l.length,l.mode)+4+e.getCharCountIndicator(l.mode,n))}}i=c}for(let t=0;t<i.length;t++)o[i[t]].end=0;return{map:o,table:r}}(o,r),s=c.find_path(i.map,"start","end"),u=[];for(let t=1;t<s.length-1;t++)u.push(i.table[s[t]].node);return t.fromArray(u.reduce((function(t,e){const n=t.length-1>=0?t[t.length-1]:null;return n&&n.mode===e.mode?(t[t.length-1].data+=e.data,t):(t.push(e),t)}),[]))},t.rawSplit=function(e){return t.fromArray(h(e,a.isKanjiModeEnabled()))}}(Nr);const Zr=Zn,Qr=tr,Gr=nr,Xr=or,to=ir,eo=sr,no=cr,ro=lr,oo=mr,io=vr,so=Rr,ao=Er,co=Nr;function lo(t,e,n){const r=t.size,o=so.getEncodedBits(e,n);let i,s;for(i=0;i<15;i++)s=1==(o>>i&1),i<6?t.set(i,8,s,!0):i<8?t.set(i+1,8,s,!0):t.set(r-15+i,8,s,!0),i<8?t.set(8,r-i-1,s,!0):i<9?t.set(8,15-i-1+1,s,!0):t.set(8,15-i-1,s,!0);t.set(r-8,8,1,!0)}function uo(t,e,n){const r=new Gr;n.forEach((function(e){r.put(e.mode.bit,4),r.put(e.getLength(),ao.getCharCountIndicator(e.mode,t)),e.write(r)}));const o=8*(Zr.getSymbolTotalCodewords(t)-ro.getTotalCodewordsCount(t,e));for(r.getLengthInBits()+4<=o&&r.put(0,4);r.getLengthInBits()%8!=0;)r.putBit(0);const i=(o-r.getLengthInBits())/8;for(let t=0;t<i;t++)r.put(t%2?17:236,8);return function(t,e,n){const r=Zr.getSymbolTotalCodewords(e),o=ro.getTotalCodewordsCount(e,n),i=r-o,s=ro.getBlocksCount(e,n),a=r%s,c=s-a,l=Math.floor(r/s),u=Math.floor(i/s),h=u+1,d=l-u,f=new oo(d);let p=0;const g=new Array(s),w=new Array(s);let b=0;const y=new Uint8Array(t.buffer);for(let t=0;t<s;t++){const e=t<c?u:h;g[t]=y.slice(p,p+e),w[t]=f.encode(g[t]),p+=e,b=Math.max(b,e)}const m=new Uint8Array(r);let v,E,x=0;for(v=0;v<b;v++)for(E=0;E<s;E++)v<g[E].length&&(m[x++]=g[E][v]);for(v=0;v<d;v++)for(E=0;E<s;E++)m[x++]=w[E][v];return m}(r,t,e)}function ho(t,e,n,r){let o;if(Array.isArray(t))o=co.fromArray(t);else{if("string"!=typeof t)throw new Error("Invalid data");{let r=e;if(!r){const e=co.rawSplit(t);r=io.getBestVersionForData(e,n)}o=co.fromString(t,r||40)}}const i=io.getBestVersionForData(o,n);if(!i)throw new Error("The amount of data is too big to be stored in a QR Code");if(e){if(e<i)throw new Error("\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: "+i+".\n")}else e=i;const s=uo(e,n,o),a=Zr.getSymbolSize(e),c=new Xr(a);return function(t,e){const n=t.size,r=eo.getPositions(e);for(let e=0;e<r.length;e++){const o=r[e][0],i=r[e][1];for(let e=-1;e<=7;e++)if(!(o+e<=-1||n<=o+e))for(let r=-1;r<=7;r++)i+r<=-1||n<=i+r||(e>=0&&e<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===e||6===e)||e>=2&&e<=4&&r>=2&&r<=4?t.set(o+e,i+r,!0,!0):t.set(o+e,i+r,!1,!0))}}(c,e),function(t){const e=t.size;for(let n=8;n<e-8;n++){const e=n%2==0;t.set(n,6,e,!0),t.set(6,n,e,!0)}}(c),function(t,e){const n=to.getPositions(e);for(let e=0;e<n.length;e++){const r=n[e][0],o=n[e][1];for(let e=-2;e<=2;e++)for(let n=-2;n<=2;n++)-2===e||2===e||-2===n||2===n||0===e&&0===n?t.set(r+e,o+n,!0,!0):t.set(r+e,o+n,!1,!0)}}(c,e),lo(c,n,0),e>=7&&function(t,e){const n=t.size,r=io.getEncodedBits(e);let o,i,s;for(let e=0;e<18;e++)o=Math.floor(e/3),i=e%3+n-8-3,s=1==(r>>e&1),t.set(o,i,s,!0),t.set(i,o,s,!0)}(c,e),function(t,e){const n=t.size;let r=-1,o=n-1,i=7,s=0;for(let a=n-1;a>0;a-=2)for(6===a&&a--;;){for(let n=0;n<2;n++)if(!t.isReserved(o,a-n)){let r=!1;s<e.length&&(r=1==(e[s]>>>i&1)),t.set(o,a-n,r),i--,-1===i&&(s++,i=7)}if(o+=r,o<0||n<=o){o-=r,r=-r;break}}}(c,s),isNaN(r)&&(r=no.getBestMask(c,lo.bind(null,c,n))),no.applyMask(r,c),lo(c,n,r),{modules:c,version:e,errorCorrectionLevel:n,maskPattern:r,segments:o}}Yn.create=function(t,e){if(typeof t>"u"||""===t)throw new Error("No input text");let n,r,o=Qr.M;return typeof e<"u"&&(o=Qr.from(e.errorCorrectionLevel,Qr.M),n=io.from(e.version),r=no.from(e.maskPattern),e.toSJISFunc&&Zr.setToSJISFunction(e.toSJISFunc)),ho(t,n,o,r)};var fo={},po={};(function(t){function e(t){if("number"==typeof t&&(t=t.toString()),"string"!=typeof t)throw new Error("Color should be defined as hex string");let e=t.slice().replace("#","").split("");if(e.length<3||5===e.length||e.length>8)throw new Error("Invalid hex color: "+t);(3===e.length||4===e.length)&&(e=Array.prototype.concat.apply([],e.map((function(t){return[t,t]})))),6===e.length&&e.push("F","F");const n=parseInt(e.join(""),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:"#"+e.slice(0,6).join("")}}t.getOptions=function(t){t||(t={}),t.color||(t.color={});const n=typeof t.margin>"u"||null===t.margin||t.margin<0?4:t.margin,r=t.width&&t.width>=21?t.width:void 0,o=t.scale||4;return{width:r,scale:r?4:o,margin:n,color:{dark:e(t.color.dark||"#000000ff"),light:e(t.color.light||"#ffffffff")},type:t.type,rendererOpts:t.rendererOpts||{}}},t.getScale=function(t,e){return e.width&&e.width>=t+2*e.margin?e.width/(t+2*e.margin):e.scale},t.getImageWidth=function(e,n){const r=t.getScale(e,n);return Math.floor((e+2*n.margin)*r)},t.qrToImageData=function(e,n,r){const o=n.modules.size,i=n.modules.data,s=t.getScale(o,r),a=Math.floor((o+2*r.margin)*s),c=r.margin*s,l=[r.color.light,r.color.dark];for(let t=0;t<a;t++)for(let n=0;n<a;n++){let u=4*(t*a+n),h=r.color.light;if(t>=c&&n>=c&&t<a-c&&n<a-c){h=l[i[Math.floor((t-c)/s)*o+Math.floor((n-c)/s)]?1:0]}e[u++]=h.r,e[u++]=h.g,e[u++]=h.b,e[u]=h.a}}})(po),function(t){const e=po;t.render=function(t,n,r){let o=r,i=n;typeof o>"u"&&(!n||!n.getContext)&&(o=n,n=void 0),n||(i=function(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}()),o=e.getOptions(o);const s=e.getImageWidth(t.modules.size,o),a=i.getContext("2d"),c=a.createImageData(s,s);return e.qrToImageData(c.data,t,o),function(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+"px",e.style.width=n+"px"}(a,i,s),a.putImageData(c,0,0),i},t.renderToDataURL=function(e,n,r){let o=r;typeof o>"u"&&(!n||!n.getContext)&&(o=n,n=void 0),o||(o={});const i=t.render(e,n,o),s=o.type||"image/png",a=o.rendererOpts||{};return i.toDataURL(s,a.quality)}}(fo);var go={};const wo=po;function bo(t,e){const n=t.a/255,r=e+'="'+t.hex+'"';return n<1?r+" "+e+'-opacity="'+n.toFixed(2).slice(1)+'"':r}function yo(t,e,n){let r=t+e;return typeof n<"u"&&(r+=" "+n),r}go.render=function(t,e,n){const r=wo.getOptions(e),o=t.modules.size,i=t.modules.data,s=o+2*r.margin,a=r.color.light.a?"<path "+bo(r.color.light,"fill")+' d="M0 0h'+s+"v"+s+'H0z"/>':"",c="<path "+bo(r.color.dark,"stroke")+' d="'+function(t,e,n){let r="",o=0,i=!1,s=0;for(let a=0;a<t.length;a++){const c=Math.floor(a%e),l=Math.floor(a/e);!c&&!i&&(i=!0),t[a]?(s++,a>0&&c>0&&t[a-1]||(r+=i?yo("M",c+n,.5+l+n):yo("m",o,0),o=0,i=!1),c+1<e&&t[a+1]||(r+=yo("h",s),s=0)):o++}return r}(i,o,r.margin)+'"/>',l='viewBox="0 0 '+s+" "+s+'"',u='<svg xmlns="http://www.w3.org/2000/svg" '+(r.width?'width="'+r.width+'" height="'+r.width+'" ':"")+l+' shape-rendering="crispEdges">'+a+c+"</svg>\n";return"function"==typeof n&&n(null,u),u};const mo=function(){return"function"==typeof Promise&&Promise.prototype&&Promise.prototype.then},vo=Yn,Eo=fo,xo=go;function ko(t,e,n,r,o){const i=[].slice.call(arguments,1),s=i.length,a="function"==typeof i[s-1];if(!a&&!mo())throw new Error("Callback required as last argument");if(!a){if(s<1)throw new Error("Too few arguments provided");return 1===s?(n=e,e=r=void 0):2===s&&!e.getContext&&(r=n,n=e,e=void 0),new Promise((function(o,i){try{const i=vo.create(n,r);o(t(i,e,r))}catch(t){i(t)}}))}if(s<2)throw new Error("Too few arguments provided");2===s?(o=n,n=e,e=r=void 0):3===s&&(e.getContext&&typeof o>"u"?(o=r,r=void 0):(o=r,r=n,n=e,e=void 0));try{const i=vo.create(n,r);o(null,t(i,e,r))}catch(t){o(t)}}Jn.create=vo.create,Jn.toCanvas=ko.bind(null,Eo.render),Jn.toDataURL=ko.bind(null,Eo.renderToDataURL),Jn.toString=ko.bind(null,(function(t,e,n){return xo.render(t,n)}));var Ao={exports:{}};function So(t,e=100,n={}){if("function"!=typeof t)throw new TypeError(`Expected the first parameter to be a function, got \`${typeof t}\`.`);if(e<0)throw new RangeError("`wait` must not be negative.");const{immediate:r}="boolean"==typeof n?{immediate:n}:n;let o,i,s,a,c;function l(){const n=Date.now()-a;if(n<e&&n>=0)s=setTimeout(l,e-n);else if(s=void 0,!r){const e=o,n=i;o=void 0,i=void 0,c=t.apply(e,n)}}const u=function(...n){if(o&&this!==o)throw new Error("Debounced method called with different contexts.");o=this,i=n,a=Date.now();const u=r&&!s;if(s||(s=setTimeout(l,e)),u){const e=o,n=i;o=void 0,i=void 0,c=t.apply(e,n)}return c};return u.clear=()=>{s&&(clearTimeout(s),s=void 0)},u.flush=()=>{if(!s)return;const e=o,n=i;o=void 0,i=void 0,c=t.apply(e,n),clearTimeout(s),s=void 0},u}Ao.exports.debounce=So,Ao.exports=So;const To=function(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}(Ao.exports),Io=Symbol("verified");function Po(t){if(!(t=>t instanceof Object)(t)||"number"!=typeof t.kind||"string"!=typeof t.content||"number"!=typeof t.created_at||"string"!=typeof t.pubkey||!t.pubkey.match(/^[a-f0-9]{64}$/)||!Array.isArray(t.tags))return!1;for(let e=0;e<t.tags.length;e++){let n=t.tags[e];if(!Array.isArray(n))return!1;for(let t=0;t<n.length;t++)if("string"!=typeof n[t])return!1}return!0}const Bo=new TextDecoder("utf-8"),Ro=new TextEncoder;function Co(t){try{-1===t.indexOf("://")&&(t="wss://"+t);let e=new URL(t);return"http:"===e.protocol?e.protocol="ws:":"https:"===e.protocol&&(e.protocol="wss:"),e.pathname=e.pathname.replace(/\/+/g,"/"),e.pathname.endsWith("/")&&(e.pathname=e.pathname.slice(0,-1)),("80"===e.port&&"ws:"===e.protocol||"443"===e.port&&"wss:"===e.protocol)&&(e.port=""),e.searchParams.sort(),e.hash="",e.toString()}catch{throw new Error(`Invalid URL: ${t}`)}}class $o{constructor(t){E(this,"value"),E(this,"next",null),E(this,"prev",null),this.value=t}}class No{constructor(){E(this,"first"),E(this,"last"),this.first=null,this.last=null}enqueue(t){const e=new $o(t);return this.last?this.last===this.first?(this.last=e,this.last.prev=this.first,this.first.next=e):(e.prev=this.last,this.last.next=e,this.last=e):(this.first=e,this.last=e),!0}dequeue(){if(!this.first)return null;if(this.first===this.last){const t=this.first;return this.first=null,this.last=null,t.value}const t=this.first;return this.first=t.next,this.first&&(this.first.prev=null),t.value}}function Lo(t){let e=dn(Ro.encode(function(t){if(!Po(t))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,t.pubkey,t.created_at,t.kind,t.tags,t.content])}(t)));return Ke(e)}const Uo=new class{generateSecretKey(){return Me.utils.randomPrivateKey()}getPublicKey(t){return Ke(Me.getPublicKey(t))}finalizeEvent(t,e){const n=t;return n.pubkey=Ke(Me.getPublicKey(e)),n.id=Lo(n),n.sig=Ke(Me.sign(Lo(n),e)),n[Io]=!0,n}verifyEvent(t){if("boolean"==typeof t[Io])return t[Io];const e=Lo(t);if(e!==t.id)return t[Io]=!1,!1;try{const n=Me.verify(t.sig,e,t.pubkey);return t[Io]=n,n}catch{return t[Io]=!1,!1}}},Oo=Uo.generateSecretKey,_o=Uo.getPublicKey,Ho=Uo.finalizeEvent,Mo=Uo.verifyEvent,jo=24133;function qo(t,e){if(t.ids&&-1===t.ids.indexOf(e.id)||t.kinds&&-1===t.kinds.indexOf(e.kind)||t.authors&&-1===t.authors.indexOf(e.pubkey))return!1;for(let n in t)if("#"===n[0]){let r=t[`#${n.slice(1)}`];if(r&&!e.tags.find((([t,e])=>t===n.slice(1)&&-1!==r.indexOf(e))))return!1}return!(t.since&&e.created_at<t.since||t.until&&e.created_at>t.until)}async function zo(){return new Promise(((t,e)=>{try{if(typeof MessageChannel<"u"){const e=new MessageChannel,n=()=>{e.port1.removeEventListener("message",n),t()};e.port1.addEventListener("message",n),e.port2.postMessage(0),e.port1.start()}else typeof setImmediate<"u"?setImmediate(t):typeof setTimeout<"u"?setTimeout(t,0):t()}catch(t){console.error("during yield: ",t),e(t)}}))}const Do=t=>(t[Io]=!0,!0);class Fo extends Error{constructor(t,e){super(`Tried to send message '${t} on a closed connection to ${e}.`),this.name="SendingOnClosedConnection"}}class Ko{constructor(t,e){E(this,"url"),E(this,"_connected",!1),E(this,"onclose",null),E(this,"onnotice",(t=>console.debug(`NOTICE from ${this.url}: ${t}`))),E(this,"onauth"),E(this,"baseEoseTimeout",4400),E(this,"publishTimeout",4400),E(this,"pingFrequency",29e3),E(this,"pingTimeout",2e4),E(this,"resubscribeBackoff",[1e4,1e4,1e4,2e4,2e4,3e4,6e4]),E(this,"openSubs",new Map),E(this,"enablePing"),E(this,"enableReconnect"),E(this,"reconnectTimeoutHandle"),E(this,"pingIntervalHandle"),E(this,"reconnectAttempts",0),E(this,"closedIntentionally",!1),E(this,"connectionPromise"),E(this,"openCountRequests",new Map),E(this,"openEventPublishes",new Map),E(this,"ws"),E(this,"incomingMessageQueue",new No),E(this,"queueRunning",!1),E(this,"challenge"),E(this,"authPromise"),E(this,"serial",0),E(this,"verifyEvent"),E(this,"_WebSocket"),this.url=Co(t),this.verifyEvent=e.verifyEvent,this._WebSocket=e.websocketImplementation||WebSocket,this.enablePing=e.enablePing,this.enableReconnect=e.enableReconnect||!1}static async connect(t,e){const n=new Ko(t,e);return await n.connect(e),n}closeAllSubscriptions(t){for(let[e,n]of this.openSubs)n.close(t);this.openSubs.clear();for(let[e,n]of this.openEventPublishes)n.reject(new Error(t));this.openEventPublishes.clear();for(let[e,n]of this.openCountRequests)n.reject(new Error(t));this.openCountRequests.clear()}get connected(){return this._connected}async reconnect(){const t=this.resubscribeBackoff[Math.min(this.reconnectAttempts,this.resubscribeBackoff.length-1)];this.reconnectAttempts++,this.reconnectTimeoutHandle=setTimeout((async()=>{try{await this.connect()}catch{}}),t)}handleHardClose(t){var e;this.pingIntervalHandle&&(clearInterval(this.pingIntervalHandle),this.pingIntervalHandle=void 0),this._connected=!1,this.connectionPromise=void 0;const n=this.closedIntentionally;this.closedIntentionally=!1,null==(e=this.onclose)||e.call(this),this.enableReconnect&&!n?this.reconnect():this.closeAllSubscriptions(t)}async connect(t){let e;return this.connectionPromise||(this.challenge=void 0,this.authPromise=void 0,this.connectionPromise=new Promise(((n,r)=>{null!=t&&t.timeout&&(e=setTimeout((()=>{var t;r("connection timed out"),this.connectionPromise=void 0,null==(t=this.onclose)||t.call(this),this.closeAllSubscriptions("relay connection timed out")}),t.timeout)),null!=t&&t.abort&&(t.abort.onabort=r);try{this.ws=new this._WebSocket(this.url)}catch(t){return clearTimeout(e),void r(t)}this.ws.onopen=()=>{this.reconnectTimeoutHandle&&(clearTimeout(this.reconnectTimeoutHandle),this.reconnectTimeoutHandle=void 0),clearTimeout(e),this._connected=!0;const t=this.reconnectAttempts>0;this.reconnectAttempts=0;for(const e of this.openSubs.values()){if(e.eosed=!1,t)for(let t=0;t<e.filters.length;t++)e.lastEmitted&&(e.filters[t].since=e.lastEmitted+1);e.fire()}this.enablePing&&(this.pingIntervalHandle=setInterval((()=>this.pingpong()),this.pingFrequency)),n()},this.ws.onerror=t=>{clearTimeout(e),r(t.message||"websocket error"),this.handleHardClose("relay connection errored")},this.ws.onclose=t=>{clearTimeout(e),r(t.message||"websocket closed"),this.handleHardClose("relay connection closed")},this.ws.onmessage=this._onmessage.bind(this)}))),this.connectionPromise}waitForPingPong(){return new Promise((t=>{this.ws.once("pong",(()=>t(!0))),this.ws.ping()}))}waitForDummyReq(){return new Promise(((t,e)=>{if(!this.connectionPromise)return e(new Error(`no connection to ${this.url}, can't ping`));try{const e=this.subscribe([{ids:["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"],limit:0}],{label:"forced-ping",oneose:()=>{t(!0),e.close()},onclose(){t(!0)},eoseTimeout:this.pingTimeout+1e3})}catch(t){e(t)}}))}async pingpong(){var t,e,n;1===(null==(t=this.ws)?void 0:t.readyState)&&(await Promise.any([this.ws&&this.ws.ping&&this.ws.once?this.waitForPingPong():this.waitForDummyReq(),new Promise((t=>setTimeout((()=>t(!1)),this.pingTimeout)))])||(null==(e=this.ws)?void 0:e.readyState)===this._WebSocket.OPEN&&(null==(n=this.ws)||n.close()))}async runQueue(){for(this.queueRunning=!0;!1!==this.handleNext();)await zo();this.queueRunning=!1}handleNext(){var t,e,n;const r=this.incomingMessageQueue.dequeue();if(!r)return!1;const o=function(t){let e=t.slice(0,22).indexOf('"EVENT"');if(-1===e)return null;let n=t.slice(e+7+1).indexOf('"');if(-1===n)return null;let r=e+7+1+n,o=t.slice(r+1,80).indexOf('"');if(-1===o)return null;let i=r+1+o;return t.slice(r+1,i)}(r);if(o){const n=this.openSubs.get(o);if(!n)return;const i=function(t,e){let n=e.length+3,r=t.indexOf(`"${e}":`)+n,o=t.slice(r).indexOf('"')+r+1;return t.slice(o,o+64)}(r,"id"),s=null==(t=n.alreadyHaveEvent)?void 0:t.call(n,i);if(null==(e=n.receivedEvent)||e.call(n,this,i),s)return}try{let t=JSON.parse(r);switch(t[0]){case"EVENT":{const e=this.openSubs.get(t[1]),n=t[2];return this.verifyEvent(n)&&function(t,e){for(let n=0;n<t.length;n++)if(qo(t[n],e))return!0;return!1}(e.filters,n)&&e.onevent(n),void((!e.lastEmitted||e.lastEmitted<n.created_at)&&(e.lastEmitted=n.created_at))}case"COUNT":{const e=t[1],n=t[2],r=this.openCountRequests.get(e);return void(r&&(r.resolve(n.count),this.openCountRequests.delete(e)))}case"EOSE":{const e=this.openSubs.get(t[1]);if(!e)return;return void e.receivedEose()}case"OK":{const e=t[1],n=t[2],r=t[3],o=this.openEventPublishes.get(e);return void(o&&(clearTimeout(o.timeout),n?o.resolve(r):o.reject(new Error(r)),this.openEventPublishes.delete(e)))}case"CLOSED":{const e=t[1],n=this.openSubs.get(e);if(!n)return;return n.closed=!0,void n.close(t[2])}case"NOTICE":return void this.onnotice(t[1]);case"AUTH":return this.challenge=t[1],void(this.onauth&&this.auth(this.onauth));default:{const e=this.openSubs.get(t[1]);return void(null==(n=null==e?void 0:e.oncustom)||n.call(e,t))}}}catch{return}}async send(t){if(!this.connectionPromise)throw new Fo(t,this.url);this.connectionPromise.then((()=>{var e;null==(e=this.ws)||e.send(t)}))}async auth(t){const e=this.challenge;if(!e)throw new Error("can't perform auth, no challenge was received");return this.authPromise||(this.authPromise=new Promise((async(n,r)=>{try{let o=await t(function(t,e){return{kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t],["challenge",e]],content:""}}(this.url,e)),i=setTimeout((()=>{let t=this.openEventPublishes.get(o.id);t&&(t.reject(new Error("auth timed out")),this.openEventPublishes.delete(o.id))}),this.publishTimeout);this.openEventPublishes.set(o.id,{resolve:n,reject:r,timeout:i}),this.send('["AUTH",'+JSON.stringify(o)+"]")}catch(t){console.warn("subscribe auth function failed:",t)}}))),this.authPromise}async publish(t){const e=new Promise(((e,n)=>{const r=setTimeout((()=>{const e=this.openEventPublishes.get(t.id);e&&(e.reject(new Error("publish timed out")),this.openEventPublishes.delete(t.id))}),this.publishTimeout);this.openEventPublishes.set(t.id,{resolve:e,reject:n,timeout:r})}));return this.send('["EVENT",'+JSON.stringify(t)+"]"),e}async count(t,e){this.serial++;const n=(null==e?void 0:e.id)||"count:"+this.serial,r=new Promise(((t,e)=>{this.openCountRequests.set(n,{resolve:t,reject:e})}));return this.send('["COUNT","'+n+'",'+JSON.stringify(t).substring(1)),r}subscribe(t,e){const n=this.prepareSubscription(t,e);return n.fire(),e.abort&&(e.abort.onabort=()=>n.close(String(e.abort.reason||"<aborted>"))),n}prepareSubscription(t,e){this.serial++;const n=e.id||(e.label?e.label+":":"sub:")+this.serial,r=new Wo(this,n,t,e);return this.openSubs.set(n,r),r}close(){var t,e,n;this.closedIntentionally=!0,this.reconnectTimeoutHandle&&(clearTimeout(this.reconnectTimeoutHandle),this.reconnectTimeoutHandle=void 0),this.pingIntervalHandle&&(clearInterval(this.pingIntervalHandle),this.pingIntervalHandle=void 0),this.closeAllSubscriptions("relay connection closed by us"),this._connected=!1,null==(t=this.onclose)||t.call(this),(null==(e=this.ws)?void 0:e.readyState)===this._WebSocket.OPEN&&(null==(n=this.ws)||n.close())}_onmessage(t){this.incomingMessageQueue.enqueue(t.data),this.queueRunning||this.runQueue()}}class Wo{constructor(t,e,n,r){if(E(this,"relay"),E(this,"id"),E(this,"lastEmitted"),E(this,"closed",!1),E(this,"eosed",!1),E(this,"filters"),E(this,"alreadyHaveEvent"),E(this,"receivedEvent"),E(this,"onevent"),E(this,"oneose"),E(this,"onclose"),E(this,"oncustom"),E(this,"eoseTimeout"),E(this,"eoseTimeoutHandle"),0===n.length)throw new Error("subscription can't be created with zero filters");this.relay=t,this.filters=n,this.id=e,this.alreadyHaveEvent=r.alreadyHaveEvent,this.receivedEvent=r.receivedEvent,this.eoseTimeout=r.eoseTimeout||t.baseEoseTimeout,this.oneose=r.oneose,this.onclose=r.onclose,this.onevent=r.onevent||(t=>{console.warn(`onevent() callback not defined for subscription '${this.id}' in relay ${this.relay.url}. event received:`,t)})}fire(){this.relay.send('["REQ","'+this.id+'",'+JSON.stringify(this.filters).substring(1)),this.eoseTimeoutHandle=setTimeout(this.receivedEose.bind(this),this.eoseTimeout)}receivedEose(){var t;this.eosed||(clearTimeout(this.eoseTimeoutHandle),this.eosed=!0,null==(t=this.oneose)||t.call(this))}close(t="closed by caller"){var e;if(!this.closed&&this.relay.connected){try{this.relay.send('["CLOSE",'+JSON.stringify(this.id)+"]")}catch(t){if(!(t instanceof Fo))throw t}this.closed=!0}this.relay.openSubs.delete(this.id),null==(e=this.onclose)||e.call(this,t)}}class Vo{constructor(t){E(this,"relays",new Map),E(this,"seenOn",new Map),E(this,"trackRelays",!1),E(this,"verifyEvent"),E(this,"enablePing"),E(this,"enableReconnect"),E(this,"automaticallyAuth"),E(this,"trustedRelayURLs",new Set),E(this,"_WebSocket"),this.verifyEvent=t.verifyEvent,this._WebSocket=t.websocketImplementation,this.enablePing=t.enablePing,this.enableReconnect=t.enableReconnect||!1,this.automaticallyAuth=t.automaticallyAuth}async ensureRelay(t,e){t=Co(t);let n=this.relays.get(t);if(n||(n=new Ko(t,{verifyEvent:this.trustedRelayURLs.has(t)?Do:this.verifyEvent,websocketImplementation:this._WebSocket,enablePing:this.enablePing,enableReconnect:this.enableReconnect}),n.onclose=()=>{n&&!n.enableReconnect&&this.relays.delete(t)},this.relays.set(t,n)),this.automaticallyAuth){const e=this.automaticallyAuth(t);e&&(n.onauth=e)}return await n.connect({timeout:null==e?void 0:e.connectionTimeout,abort:null==e?void 0:e.abort}),n}close(t){t.map(Co).forEach((t=>{var e;null==(e=this.relays.get(t))||e.close(),this.relays.delete(t)}))}subscribe(t,e,n){const r=[];for(let n=0;n<t.length;n++){const o=Co(t[n]);r.find((t=>t.url===o))||r.push({url:o,filter:e})}return this.subscribeMap(r,n)}subscribeMany(t,e,n){const r=[],o=[];for(let n=0;n<t.length;n++){const i=Co(t[n]);-1===o.indexOf(i)&&(o.push(i),r.push({url:i,filter:e}))}return this.subscribeMap(r,n)}subscribeMap(t,e){const n=new Map;for(const e of t){const{url:t,filter:r}=e;n.has(t)||n.set(t,[]),n.get(t).push(r)}const r=Array.from(n.entries()).map((([t,e])=>({url:t,filters:e})));this.trackRelays&&(e.receivedEvent=(t,e)=>{let n=this.seenOn.get(e);n||(n=new Set,this.seenOn.set(e,n)),n.add(t)});const o=new Set,i=[],s=[];let a=t=>{var n;s[t]||(s[t]=!0,s.filter((t=>t)).length===r.length&&(null==(n=e.oneose)||n.call(e),a=()=>{}))};const c=[];let l=(t,n)=>{var o;c[t]||(a(t),c[t]=n,c.filter((t=>t)).length===r.length&&(null==(o=e.onclose)||o.call(e,c),l=()=>{}))};const u=t=>{var n;if(null!=(n=e.alreadyHaveEvent)&&n.call(e,t))return!0;const r=o.has(t);return o.add(t),r},h=Promise.all(r.map((async({url:t,filters:n},r)=>{let o;try{o=await this.ensureRelay(t,{connectionTimeout:e.maxWait?Math.max(.8*e.maxWait,e.maxWait-1e3):void 0,abort:e.abort})}catch(t){return void l(r,(null==t?void 0:t.message)||String(t))}let s=o.subscribe(n,{...e,oneose:()=>a(r),onclose:t=>{t.startsWith("auth-required: ")&&e.onauth?o.auth(e.onauth).then((()=>{o.subscribe(n,{...e,oneose:()=>a(r),onclose:t=>{l(r,t)},alreadyHaveEvent:u,eoseTimeout:e.maxWait,abort:e.abort})})).catch((t=>{l(r,`auth was required and attempted, but failed with: ${t}`)})):l(r,t)},alreadyHaveEvent:u,eoseTimeout:e.maxWait,abort:e.abort});i.push(s)})));return{async close(t){await h,i.forEach((e=>{e.close(t)}))}}}subscribeEose(t,e,n){const r=this.subscribe(t,e,{...n,oneose(){r.close("closed automatically on eose")}});return r}subscribeManyEose(t,e,n){const r=this.subscribeMany(t,e,{...n,oneose(){r.close("closed automatically on eose")}});return r}async querySync(t,e,n){return new Promise((async r=>{const o=[];this.subscribeEose(t,e,{...n,onevent(t){o.push(t)},onclose(t){r(o)}})}))}async get(t,e,n){e.limit=1;const r=await this.querySync(t,e,n);return r.sort(((t,e)=>e.created_at-t.created_at)),r[0]||null}publish(t,e,n){return t.map(Co).map((async(t,r,o)=>{if(o.indexOf(t)!==r)return Promise.reject("duplicate url");let i=await this.ensureRelay(t);return i.publish(e).catch((async t=>{if(t instanceof Error&&t.message.startsWith("auth-required: ")&&null!=n&&n.onauth)return await i.auth(n.onauth),i.publish(e);throw t})).then((t=>{if(this.trackRelays){let t=this.seenOn.get(e.id);t||(t=new Set,this.seenOn.set(e.id,t)),t.add(i)}return t}))}))}listConnectionStatus(){const t=new Map;return this.relays.forEach(((e,n)=>t.set(n,e.connected))),t}destroy(){this.relays.forEach((t=>t.close())),this.relays=new Map}}var Jo;try{Jo=WebSocket}catch{}class Yo extends Vo{constructor(t){super({verifyEvent:Mo,websocketImplementation:Jo,...t})}}function Zo(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function Qo(t){if("boolean"!=typeof t)throw new Error(`boolean expected, not ${t}`)}function Go(t,...e){if(!function(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name}(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */const Xo=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");const ti=t=>Uint8Array.from(t.split("").map((t=>t.charCodeAt(0)))),ei=ti("expand 16-byte k"),ni=ti("expand 32-byte k"),ri=Xo(ei),oi=Xo(ni);function ii(t,e){return t<<e|t>>>32-e}function si(t){return t.byteOffset%4==0}oi.slice();const ai=2**32-1,ci=new Uint32Array;const li=function(t,e){const{allowShortKeys:n,extendNonceFn:r,counterLength:o,counterRight:i,rounds:s}=function(t,e){if(null==e||"object"!=typeof e)throw new Error("options must be defined");return Object.assign(t,e)}({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if("function"!=typeof t)throw new Error("core must be a function");return Zo(o),Zo(s),Qo(i),Qo(n),(e,a,c,l,u=0)=>{Go(e),Go(a),Go(c);const h=c.length;if(l||(l=new Uint8Array(h)),Go(l),Zo(u),u<0||u>=ai)throw new Error("arx: counter overflow");if(l.length<h)throw new Error(`arx: output (${l.length}) is shorter than data (${h})`);const d=[];let f,p,g=e.length;if(32===g)f=e.slice(),d.push(f),p=oi;else{if(16!==g||!n)throw new Error(`arx: invalid 32-byte key, got length=${g}`);f=new Uint8Array(32),f.set(e),f.set(e,16),p=ri,d.push(f)}si(a)||(a=a.slice(),d.push(a));const w=Xo(f);if(r){if(24!==a.length)throw new Error("arx: extended nonce must be 24 bytes");r(p,w,Xo(a.subarray(0,16)),w),a=a.subarray(16)}const b=16-o;if(b!==a.length)throw new Error(`arx: nonce must be ${b} or 16 bytes`);if(12!==b){const t=new Uint8Array(12);t.set(a,i?0:12-a.length),a=t,d.push(a)}const y=Xo(a);for(function(t,e,n,r,o,i,s,a){const c=o.length,l=new Uint8Array(64),u=Xo(l),h=si(o)&&si(i),d=h?Xo(o):ci,f=h?Xo(i):ci;for(let p=0;p<c;s++){if(t(e,n,r,u,s,a),s>=ai)throw new Error("arx: counter overflow");const g=Math.min(64,c-p);if(h&&64===g){const t=p/4;if(p%4!=0)throw new Error("arx: invalid block position");for(let e,n=0;n<16;n++)e=t+n,f[e]=d[e]^u[n];p+=64}else{for(let t,e=0;e<g;e++)t=p+e,i[t]=o[t]^l[e];p+=g}}}(t,p,w,y,c,l,u,s);d.length>0;)d.pop().fill(0);return l}}((function(t,e,n,r,o,i=20){let s=t[0],a=t[1],c=t[2],l=t[3],u=e[0],h=e[1],d=e[2],f=e[3],p=e[4],g=e[5],w=e[6],b=e[7],y=o,m=n[0],v=n[1],E=n[2],x=s,k=a,A=c,S=l,T=u,I=h,P=d,B=f,R=p,C=g,$=w,N=b,L=y,U=m,O=v,_=E;for(let t=0;t<i;t+=2)x=x+T|0,L=ii(L^x,16),R=R+L|0,T=ii(T^R,12),x=x+T|0,L=ii(L^x,8),R=R+L|0,T=ii(T^R,7),k=k+I|0,U=ii(U^k,16),C=C+U|0,I=ii(I^C,12),k=k+I|0,U=ii(U^k,8),C=C+U|0,I=ii(I^C,7),A=A+P|0,O=ii(O^A,16),$=$+O|0,P=ii(P^$,12),A=A+P|0,O=ii(O^A,8),$=$+O|0,P=ii(P^$,7),S=S+B|0,_=ii(_^S,16),N=N+_|0,B=ii(B^N,12),S=S+B|0,_=ii(_^S,8),N=N+_|0,B=ii(B^N,7),x=x+I|0,_=ii(_^x,16),$=$+_|0,I=ii(I^$,12),x=x+I|0,_=ii(_^x,8),$=$+_|0,I=ii(I^$,7),k=k+P|0,L=ii(L^k,16),N=N+L|0,P=ii(P^N,12),k=k+P|0,L=ii(L^k,8),N=N+L|0,P=ii(P^N,7),A=A+B|0,U=ii(U^A,16),R=R+U|0,B=ii(B^R,12),A=A+B|0,U=ii(U^A,8),R=R+U|0,B=ii(B^R,7),S=S+T|0,O=ii(O^S,16),C=C+O|0,T=ii(T^C,12),S=S+T|0,O=ii(O^S,8),C=C+O|0,T=ii(T^C,7);let H=0;r[H++]=s+x|0,r[H++]=a+k|0,r[H++]=c+A|0,r[H++]=l+S|0,r[H++]=u+T|0,r[H++]=h+I|0,r[H++]=d+P|0,r[H++]=f+B|0,r[H++]=p+R|0,r[H++]=g+C|0,r[H++]=w+$|0,r[H++]=b+N|0,r[H++]=y+L|0,r[H++]=m+U|0,r[H++]=v+O|0,r[H++]=E+_|0}),{counterRight:!1,counterLength:4,allowShortKeys:!1});class ui extends Ye{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,nn.hash(t);const n=Ve(e);if(this.iHash=t.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 r=this.blockLen,o=new Uint8Array(r);o.set(n.length>r?t.create().update(n).digest():n);for(let t=0;t<o.length;t++)o[t]^=54;this.iHash.update(o),this.oHash=t.create();for(let t=0;t<o.length;t++)o[t]^=106;this.oHash.update(o),o.fill(0)}update(t){return nn.exists(this),this.iHash.update(t),this}digestInto(t){nn.exists(this),nn.bytes(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:n,finished:r,destroyed:o,blockLen:i,outputLen:s}=this;return t.finished=r,t.destroyed=o,t.blockLen=i,t.outputLen=s,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const hi=(t,e,n)=>new ui(t,e).update(n).digest();hi.create=(t,e)=>new ui(t,e);const di=new Uint8Array([0]),fi=new Uint8Array;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function pi(t){if(!Number.isSafeInteger(t))throw new Error(`Wrong integer: ${t}`)}function gi(...t){const e=(t,e)=>n=>t(e(n));return{encode:Array.from(t).reverse().reduce(((t,n)=>t?e(t,n.encode):n.encode),void 0),decode:t.reduce(((t,n)=>t?e(t,n.decode):n.decode),void 0)}}function wi(t){return{encode:e=>{if(!Array.isArray(e)||e.length&&"number"!=typeof e[0])throw new Error("alphabet.encode input should be an array of numbers");return e.map((e=>{if(pi(e),e<0||e>=t.length)throw new Error(`Digit index outside alphabet: ${e} (alphabet: ${t.length})`);return t[e]}))},decode:e=>{if(!Array.isArray(e)||e.length&&"string"!=typeof e[0])throw new Error("alphabet.decode input should be array of strings");return e.map((e=>{if("string"!=typeof e)throw new Error(`alphabet.decode: not string element=${e}`);const n=t.indexOf(e);if(-1===n)throw new Error(`Unknown letter: "${e}". Allowed: ${t}`);return n}))}}}function bi(t=""){if("string"!=typeof t)throw new Error("join separator should be string");return{encode:e=>{if(!Array.isArray(e)||e.length&&"string"!=typeof e[0])throw new Error("join.encode input should be array of strings");for(let t of e)if("string"!=typeof t)throw new Error(`join.encode: non-string input=${t}`);return e.join(t)},decode:e=>{if("string"!=typeof e)throw new Error("join.decode input should be string");return e.split(t)}}}function yi(t,e="="){if(pi(t),"string"!=typeof e)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 t of n)if("string"!=typeof t)throw new Error(`padding.encode: non-string input=${t}`);for(;n.length*t%8;)n.push(e);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 t of n)if("string"!=typeof t)throw new Error(`padding.decode: non-string input=${t}`);let r=n.length;if(r*t%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&n[r-1]===e;r--)if(!((r-1)*t%8))throw new Error("Invalid padding: string has too much padding");return n.slice(0,r)}}}function mi(t){if("function"!=typeof t)throw new Error("normalize fn should be function");return{encode:t=>t,decode:e=>t(e)}}function vi(t,e,n){if(e<2)throw new Error(`convertRadix: wrong from=${e}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(t))throw new Error("convertRadix: data should be array");if(!t.length)return[];let r=0;const o=[],i=Array.from(t);for(i.forEach((t=>{if(pi(t),t<0||t>=e)throw new Error(`Wrong integer: ${t}`)}));;){let t=0,s=!0;for(let o=r;o<i.length;o++){const a=i[o],c=e*t+a;if(!Number.isSafeInteger(c)||e*t/e!==t||c-a!=e*t)throw new Error("convertRadix: carry overflow");if(t=c%n,i[o]=Math.floor(c/n),!Number.isSafeInteger(i[o])||i[o]*n+t!==c)throw new Error("convertRadix: carry overflow");s&&(i[o]?s=!1:r=o)}if(o.push(t),s)break}for(let e=0;e<t.length-1&&0===t[e];e++)o.push(0);return o.reverse()}const Ei=(t,e)=>e?Ei(e,t%e):t,xi=(t,e)=>t+(e-Ei(t,e));function ki(t,e,n,r){if(!Array.isArray(t))throw new Error("convertRadix2: data should be array");if(e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(xi(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${xi(e,n)}`);let o=0,i=0;const s=2**n-1,a=[];for(const r of t){if(pi(r),r>=2**e)throw new Error(`convertRadix2: invalid data word=${r} from=${e}`);if(o=o<<e|r,i+e>32)throw new Error(`convertRadix2: carry overflow pos=${i} from=${e}`);for(i+=e;i>=n;i-=n)a.push((o>>i-n&s)>>>0);o&=2**i-1}if(o=o<<n-i&s,!r&&i>=e)throw new Error("Excess padding");if(!r&&o)throw new Error(`Non-zero padding: ${o}`);return r&&i>0&&a.push(o>>>0),a}function Ai(t,e=!1){if(pi(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(xi(8,t)>32||xi(t,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 ki(Array.from(n),8,t,!e)},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(ki(n,t,8,e))}}}function Si(t){if("function"!=typeof t)throw new Error("unsafeWrapper fn should be function");return function(...e){try{return t.apply(null,e)}catch{}}}const Ti=gi(Ai(4),wi("0123456789ABCDEF"),bi("")),Ii=gi(Ai(5),wi("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),yi(5),bi(""));gi(Ai(5),wi("0123456789ABCDEFGHIJKLMNOPQRSTUV"),yi(5),bi("")),gi(Ai(5),wi("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),bi(""),mi((t=>t.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))));const Pi=gi(Ai(6),wi("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),yi(6),bi("")),Bi=gi(Ai(6),wi("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),yi(6),bi("")),Ri=t=>gi(function(t){return pi(t),{encode:e=>{if(!(e instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return vi(Array.from(e),256,t)},decode:e=>{if(!Array.isArray(e)||e.length&&"number"!=typeof e[0])throw new Error("radix.decode input should be array of strings");return Uint8Array.from(vi(e,t,256))}}}(58),wi(t),bi("")),Ci=Ri("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");Ri("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),Ri("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const $i=[0,2,3,5,6,7,9,10,11],Ni={encode(t){let e="";for(let n=0;n<t.length;n+=8){const r=t.subarray(n,n+8);e+=Ci.encode(r).padStart($i[r.length],"1")}return e},decode(t){let e=[];for(let n=0;n<t.length;n+=11){const r=t.slice(n,n+11),o=$i.indexOf(r.length),i=Ci.decode(r);for(let t=0;t<i.length-o;t++)if(0!==i[t])throw new Error("base58xmr: wrong padding");e=e.concat(Array.from(i.slice(i.length-o)))}return Uint8Array.from(e)}},Li=gi(wi("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),bi("")),Ui=[996825010,642813549,513874426,1027748829,705979059];function Oi(t){const e=t>>25;let n=(33554431&t)<<5;for(let t=0;t<Ui.length;t++)1==(e>>t&1)&&(n^=Ui[t]);return n}function _i(t,e,n=1){const r=t.length;let o=1;for(let e=0;e<r;e++){const n=t.charCodeAt(e);if(n<33||n>126)throw new Error(`Invalid prefix (${t})`);o=Oi(o)^n>>5}o=Oi(o);for(let e=0;e<r;e++)o=Oi(o)^31&t.charCodeAt(e);for(let t of e)o=Oi(o)^t;for(let t=0;t<6;t++)o=Oi(o);return o^=n,Li.encode(ki([o%2**30],30,5,!1))}function Hi(t){const e="bech32"===t?1:734539939,n=Ai(5),r=n.decode,o=n.encode,i=Si(r);function s(t,n=90){if("string"!=typeof t)throw new Error("bech32.decode input should be string, not "+typeof t);if(t.length<8||!1!==n&&t.length>n)throw new TypeError(`Wrong string length: ${t.length} (${t}). Expected (8..${n})`);const r=t.toLowerCase();if(t!==r&&t!==t.toUpperCase())throw new Error("String must be lowercase or uppercase");const o=(t=r).lastIndexOf("1");if(0===o||-1===o)throw new Error('Letter "1" must be present between prefix and data only');const i=t.slice(0,o),s=t.slice(o+1);if(s.length<6)throw new Error("Data must be at least 6 characters long");const a=Li.decode(s).slice(0,-6),c=_i(i,a,e);if(!s.endsWith(c))throw new Error(`Invalid checksum in ${t}: expected "${c}"`);return{prefix:i,words:a}}return{encode:function(t,n,r=90){if("string"!=typeof t)throw new Error("bech32.encode prefix should be string, not "+typeof t);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 o=t.length+7+n.length;if(!1!==r&&o>r)throw new TypeError(`Length ${o} exceeds limit ${r}`);return`${t=t.toLowerCase()}1${Li.encode(n)}${_i(t,n,e)}`},decode:s,decodeToBytes:function(t){const{prefix:e,words:n}=s(t,!1);return{prefix:e,words:n,bytes:r(n)}},decodeUnsafe:Si(s),fromWords:r,fromWordsUnsafe:i,toWords:o}}const Mi=Hi("bech32");Hi("bech32m");const ji={encode:t=>(new TextDecoder).decode(t),decode:t=>(new TextEncoder).encode(t)},qi=gi(Ai(4),wi("0123456789abcdef"),bi(""),mi((t=>{if("string"!=typeof t||t.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()})));Object.keys({utf8:ji,hex:qi,base16:Ti,base32:Ii,base64:Pi,base64url:Bi,base58:Ci,base58xmr:Ni}).join(", ");function zi(t,e){const n=Se.getSharedSecret(t,"02"+e).subarray(1,33);return function(t,e,n){return nn.hash(t),hi(t,Ve(n),Ve(e))}(dn,n,"nip44-v2")}function Di(t,e){const n=function(t,e,n,r=32){if(nn.hash(t),nn.number(r),r>255*t.outputLen)throw new Error("Length should be <= 255*HashLen");const o=Math.ceil(r/t.outputLen);void 0===n&&(n=fi);const i=new Uint8Array(o*t.outputLen),s=hi.create(t,e),a=s._cloneInto(),c=new Uint8Array(s.outputLen);for(let e=0;e<o;e++)di[0]=e+1,a.update(0===e?fi:c).update(n).update(di).digestInto(c),i.set(c,t.outputLen*e),s._cloneInto(a);return s.destroy(),a.destroy(),c.fill(0),di.fill(0),i.slice(0,r)}(dn,t,e,76);return{chacha_key:n.subarray(0,32),chacha_nonce:n.subarray(32,44),hmac_key:n.subarray(44,76)}}function Fi(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("expected positive integer");if(t<=32)return 32;const e=1<<Math.floor(Math.log2(t-1))+1,n=e<=256?32:e/8;return n*(Math.floor((t-1)/n)+1)}function Ki(t){const e=Ro.encode(t),n=e.length,r=function(t){if(!Number.isSafeInteger(t)||t<1||t>65535)throw new Error("invalid plaintext size: must be between 1 and 65535 bytes");const e=new Uint8Array(2);return new DataView(e.buffer).setUint16(0,t,!1),e}(n);return Je(r,e,new Uint8Array(Fi(n)-n))}function Wi(t,e,n){if(32!==n.length)throw new Error("AAD associated data must be 32 bytes");const r=Je(n,e);return hi(dn,t,r)}function Vi(t,e,n=Qe(32)){const{chacha_key:r,chacha_nonce:o,hmac_key:i}=Di(e,n),s=Ki(t),a=li(r,o,s),c=Wi(i,a,n);return Pi.encode(Je(new Uint8Array([2]),n,a,c))}function Ji(t,e){const{nonce:n,ciphertext:r,mac:o}=function(t){if("string"!=typeof t)throw new Error("payload must be a valid string");const e=t.length;if(e<132||e>87472)throw new Error("invalid payload length: "+e);if("#"===t[0])throw new Error("unknown encryption version");let n;try{n=Pi.decode(t)}catch(t){throw new Error("invalid base64: "+t.message)}const r=n.length;if(r<99||r>65603)throw new Error("invalid data length: "+r);const o=n[0];if(2!==o)throw new Error("unknown encryption version "+o);return{nonce:n.subarray(1,33),ciphertext:n.subarray(33,-32),mac:n.subarray(-32)}}(t),{chacha_key:i,chacha_nonce:s,hmac_key:a}=Di(e,n);if(!function(t,e){if(t.length!==e.length)return!1;let n=0;for(let r=0;r<t.length;r++)n|=t[r]^e[r];return 0===n}(Wi(a,r,n),o))throw new Error("invalid MAC");return function(t){const e=new DataView(t.buffer).getUint16(0),n=t.subarray(2,2+e);if(e<1||e>65535||n.length!==e||t.length!==2+Fi(e))throw new Error("invalid padding");return Bo.decode(n)}(li(i,s,r))}const Yi=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/;let Zi;try{Zi=fetch}catch{}var Qi;try{Qi=fetch}catch{}const Gi=/^bunker:\/\/([0-9a-f]{64})\??([?\/\w:.=&%-]*)$/;async function Xi(t){let e=t.match(Gi);if(e)try{const t=e[1],n=new URLSearchParams(e[2]);return{pubkey:t,relays:n.getAll("relay"),secret:n.get("secret")}}catch{}return async function(t){const e=t.match(Yi);if(!e)return null;const[n,r="_",o]=e;try{const t=`https://${o}/.well-known/nostr.json?name=${r}`,e=await(await Qi(t,{redirect:"error"})).json();let n=e.names[r];return{pubkey:n,relays:e.nip46[n]||[],secret:null}}catch{return null}}(t)}class ts{constructor(t,e){E(this,"params"),E(this,"pool"),E(this,"subCloser"),E(this,"isOpen"),E(this,"serial"),E(this,"idPrefix"),E(this,"listeners"),E(this,"waitingForAuth"),E(this,"secretKey"),E(this,"conversationKey"),E(this,"bp"),E(this,"cachedPubKey"),this.params=e,this.pool=e.pool||new Yo,this.secretKey=t,this.isOpen=!1,this.idPrefix=Math.random().toString(36).substring(7),this.serial=0,this.listeners={},this.waitingForAuth={}}static fromBunker(t,e,n={}){if(0===e.relays.length)throw new Error("no relays specified for this bunker");const r=new ts(t,n);return r.conversationKey=zi(t,e.pubkey),r.bp=e,r.setupSubscription(),r}static async fromURI(t,e,n={},r=3e5){const o=new ts(t,n),i=new URL(e),s=_o(t);return new Promise(((e,n)=>{let a=!1;const c=o.pool.subscribe(i.searchParams.getAll("relay"),{kinds:[jo],"#p":[s],limit:0},{onevent:async n=>{try{const r=zi(t,n.pubkey),s=Ji(n.content,r);JSON.parse(s).result===i.searchParams.get("secret")&&(c.close(),o.bp={pubkey:n.pubkey,relays:i.searchParams.getAll("relay"),secret:i.searchParams.get("secret")},o.conversationKey=zi(t,n.pubkey),o.setupSubscription(),a=!0,await Promise.race([new Promise((t=>setTimeout(t,1e3))),o.switchRelays()]),e(o))}catch(t){console.warn("failed to process potential connection event",t)}},onclose:()=>{a||n(new Error("subscription closed before connection was established."))},maxWait:"number"==typeof r?r:void 0,abort:"number"!=typeof r?r:void 0})}))}setupSubscription(){const t=this.listeners,e=this.waitingForAuth,n=this.conversationKey;this.subCloser=this.pool.subscribe(this.bp.relays,{kinds:[jo],authors:[this.bp.pubkey],"#p":[_o(this.secretKey)],limit:0},{onevent:async r=>{const o=JSON.parse(Ji(r.content,n)),{id:i,result:s,error:a}=o;if("auth_url"===s&&e[i])return delete e[i],void(this.params.onauth?this.params.onauth(a):console.warn(`nostr-tools/nip46: remote signer ${this.bp.pubkey} tried to send an "auth_url"='${a}' but there was no onauth() callback configured.`));let c=t[i];c&&(a?c.reject(a):s&&c.resolve(s),delete t[i])},onclose:()=>{this.subCloser=void 0}}),this.isOpen=!0}async switchRelays(){try{const t=await this.sendRequest("switch_relays",[]);let e=JSON.parse(t);if(!e||JSON.stringify(e.sort())===JSON.stringify(this.bp.relays))return!1;this.bp.relays=e;let n=this.subCloser;return setTimeout((()=>{n.close()}),5e3),this.subCloser=void 0,this.setupSubscription(),!0}catch{return!1}}async close(){this.isOpen=!1,this.subCloser.close()}async sendRequest(t,e){return new Promise((async(n,r)=>{try{if(!this.isOpen)throw new Error("this signer is not open anymore, create a new one");this.subCloser||this.setupSubscription(),this.serial++;const o=`${this.idPrefix}-${this.serial}`,i=Vi(JSON.stringify({id:o,method:t,params:e}),this.conversationKey),s=Ho({kind:jo,tags:[["p",this.bp.pubkey]],content:i,created_at:Math.floor(Date.now()/1e3)},this.secretKey);this.listeners[o]={resolve:n,reject:r},this.waitingForAuth[o]=!0,await Promise.any(this.pool.publish(this.bp.relays,s))}catch(t){r(t)}}))}async ping(){let t=await this.sendRequest("ping",[]);if("pong"!==t)throw new Error(`result is not pong: ${t}`)}async connect(){await this.sendRequest("connect",[this.bp.pubkey,this.bp.secret||""])}async getPublicKey(){return this.cachedPubKey||(this.cachedPubKey=await this.sendRequest("get_public_key",[])),this.cachedPubKey}async signEvent(t){let e=await this.sendRequest("sign_event",[JSON.stringify(t)]),n=JSON.parse(e);if(Mo(n))return n;throw new Error(`event returned from bunker is improperly signed: ${JSON.stringify(n)}`)}async nip04Encrypt(t,e){return await this.sendRequest("nip04_encrypt",[t,e])}async nip04Decrypt(t,e){return await this.sendRequest("nip04_decrypt",[t,e])}async nip44Encrypt(t,e){return await this.sendRequest("nip44_encrypt",[t,e])}async nip44Decrypt(t,e){return await this.sendRequest("nip44_decrypt",[t,e])}}const es=5e3;function ns(t){let e={},n=t;for(;n.length>0;){let t=n[0],r=n[1],o=n.slice(2,2+r);if(n=n.slice(2+r),o.length<r)throw new Error(`not enough data to read on TLV ${t}`);e[t]=e[t]||[],e[t].push(o)}return e}function rs(t){return function(t,e){return function(t,e){let n=Mi.toWords(e);return Mi.encode(t,n,es)}(t,e)}("npub",We(t))}const os=16;function is(t){return t<<1^283&-(t>>7)}function ss(t,e){let n=0;for(;e>0;e>>=1)n^=t&-(1&e),t=is(t);return n}const as=(()=>{let t=new Uint8Array(256);for(let e=0,n=1;e<256;e++,n^=is(n))t[e]=n;const e=new Uint8Array(256);e[0]=99;for(let n=0;n<255;n++){let r=t[255-n];r|=r<<8,e[t[n]]=255&(r^r>>4^r>>5^r>>6^r>>7^99)}return e})(),cs=as.map(((t,e)=>as.indexOf(e))),ls=t=>t<<24|t>>>8,us=t=>t<<8|t>>>24;function hs(t,e){if(256!==t.length)throw new Error("Wrong sbox length");const n=new Uint32Array(256).map(((n,r)=>e(t[r]))),r=n.map(us),o=r.map(us),i=o.map(us),s=new Uint32Array(65536),a=new Uint32Array(65536),c=new Uint16Array(65536);for(let e=0;e<256;e++)for(let l=0;l<256;l++){const u=256*e+l;s[u]=n[e]^r[l],a[u]=o[e]^i[l],c[u]=t[e]<<8|t[l]}return{sbox:t,sbox2:c,T0:n,T1:r,T2:o,T3:i,T01:s,T23:a}}const ds=hs(as,(t=>ss(t,3)<<24|t<<16|t<<8|ss(t,2))),fs=hs(cs,(t=>ss(t,11)<<24|ss(t,13)<<16|ss(t,9)<<8|ss(t,14))),ps=(()=>{const t=new Uint8Array(16);for(let e=0,n=1;e<16;e++,n=is(n))t[e]=n;return t})();function gs(t){Go(t);const e=t.length;if(![16,24,32].includes(e))throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${e}`);const{sbox2:n}=ds,r=Xo(t),o=r.length,i=t=>bs(n,t,t,t,t),s=new Uint32Array(e+28);s.set(r);for(let t=o;t<s.length;t++){let e=s[t-1];t%o==0?e=i(ls(e))^ps[t/o-1]:o>6&&t%o==4&&(e=i(e)),s[t]=s[t-o]^e}return s}function ws(t,e,n,r,o,i){return t[n<<8&65280|r>>>8&255]^e[o>>>8&65280|i>>>24&255]}function bs(t,e,n,r,o){return t[255&e|65280&n]|t[r>>>16&255|o>>>16&65280]<<16}function ys(t,e,n,r,o){const{sbox2:i,T01:s,T23:a}=ds;let c=0;e^=t[c++],n^=t[c++],r^=t[c++],o^=t[c++];const l=t.length/4-2;for(let i=0;i<l;i++){const i=t[c++]^ws(s,a,e,n,r,o),l=t[c++]^ws(s,a,n,r,o,e),u=t[c++]^ws(s,a,r,o,e,n),h=t[c++]^ws(s,a,o,e,n,r);e=i,n=l,r=u,o=h}return{s0:t[c++]^bs(i,e,n,r,o),s1:t[c++]^bs(i,n,r,o,e),s2:t[c++]^bs(i,r,o,e,n),s3:t[c++]^bs(i,o,e,n,r)}}function ms(t,e,n,r,o){const{sbox2:i,T01:s,T23:a}=fs;let c=0;e^=t[c++],n^=t[c++],r^=t[c++],o^=t[c++];const l=t.length/4-2;for(let i=0;i<l;i++){const i=t[c++]^ws(s,a,e,o,r,n),l=t[c++]^ws(s,a,n,e,o,r),u=t[c++]^ws(s,a,r,n,e,o),h=t[c++]^ws(s,a,o,r,n,e);e=i,n=l,r=u,o=h}return{s0:t[c++]^bs(i,e,o,r,n),s1:t[c++]^bs(i,n,e,o,r),s2:t[c++]^bs(i,r,n,e,o),s3:t[c++]^bs(i,o,r,n,e)}}function vs(t,e){if(!e)return new Uint8Array(t);if(Go(e),e.length<t)throw new Error(`aes: wrong destination length, expected at least ${t}, got: ${e.length}`);return e}const Es=((t,e)=>(Object.assign(e,t),e))({blockSize:16,nonceLength:16},(function(t,e,n={}){Go(t),Go(e,16);const r=!n.disablePadding;return{encrypt:(n,o)=>{const i=gs(t),{b:s,o:a,out:c}=function(t,e,n){let r=t.length;const o=r%os;if(!e&&0!==o)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");const i=Xo(t);if(e){let t=os-o;t||(t=os),r+=t}const s=vs(r,n);return{b:i,o:Xo(s),out:s}}(n,r,o),l=Xo(e);let u=l[0],h=l[1],d=l[2],f=l[3],p=0;for(;p+4<=s.length;)u^=s[p+0],h^=s[p+1],d^=s[p+2],f^=s[p+3],({s0:u,s1:h,s2:d,s3:f}=ys(i,u,h,d,f)),a[p++]=u,a[p++]=h,a[p++]=d,a[p++]=f;if(r){const t=function(t){const e=new Uint8Array(16),n=Xo(e);e.set(t);const r=os-t.length;for(let t=os-r;t<os;t++)e[t]=r;return n}(n.subarray(4*p));u^=t[0],h^=t[1],d^=t[2],f^=t[3],({s0:u,s1:h,s2:d,s3:f}=ys(i,u,h,d,f)),a[p++]=u,a[p++]=h,a[p++]=d,a[p++]=f}return i.fill(0),c},decrypt:(n,o)=>{!function(t){if(Go(t),t.length%os!=0)throw new Error("aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size 16")}(n);const i=function(t){const e=gs(t),n=e.slice(),r=e.length,{sbox2:o}=ds,{T0:i,T1:s,T2:a,T3:c}=fs;for(let t=0;t<r;t+=4)for(let o=0;o<4;o++)n[t+o]=e[r-t-4+o];e.fill(0);for(let t=4;t<r-4;t++){const e=n[t],r=bs(o,e,e,e,e);n[t]=i[255&r]^s[r>>>8&255]^a[r>>>16&255]^c[r>>>24]}return n}(t),s=Xo(e),a=vs(n.length,o),c=Xo(n),l=Xo(a);let u=s[0],h=s[1],d=s[2],f=s[3];for(let t=0;t+4<=c.length;){const e=u,n=h,r=d,o=f;u=c[t+0],h=c[t+1],d=c[t+2],f=c[t+3];const{s0:s,s1:a,s2:p,s3:g}=ms(i,u,h,d,f);l[t++]=s^e,l[t++]=a^n,l[t++]=p^r,l[t++]=g^o}return i.fill(0),function(t,e){if(!e)return t;const n=t.length;if(!n)throw new Error("aes/pcks5: empty ciphertext not allowed");const r=t[n-1];if(r<=0||r>16)throw new Error(`aes/pcks5: wrong padding byte: ${r}`);const o=t.subarray(0,-r);for(let e=0;e<r;e++)if(t[n-e-1]!==r)throw new Error("aes/pcks5: wrong padding");return o}(a,r)}}}));function xs(t){return t.slice(1,33)}const ks=[];const As=t=>{const{subscribe:e,set:n}=function(t,e=a){let n;const r=new Set;function o(e){if(d(t,e)&&(t=e,n)){const e=!ks.length;for(const e of r)e[1](),ks.push(e,t);if(e){for(let t=0;t<ks.length;t+=2)ks[t][0](ks[t+1]);ks.length=0}}}function i(e){o(e(t))}return{set:o,update:i,subscribe:function(s,c=a){const l=[s,c];return r.add(l),1===r.size&&(n=e(o,i)||a),s(t),()=>{r.delete(l),0===r.size&&n&&(n(),n=null)}}}}(void 0,(()=>{const e=window.matchMedia(t);n(e.matches);const r=()=>n(e.matches);return e.addEventListener("change",r),()=>{e.removeEventListener("change",r)}}));return{subscribe:e}};function Ss(t){let e,n,r;return{c(){e=x("svg"),n=x("circle"),r=x("path"),I(n,"class","opacity-25"),I(n,"cx","12"),I(n,"cy","12"),I(n,"r","10"),I(n,"stroke","currentColor"),I(n,"stroke-width","4"),I(r,"class","opacity-75"),I(r,"fill","currentColor"),I(r,"d","M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"),I(e,"class","ml-2 h-5 w-5 animate-spin text-white"),I(e,"xmlns","http://www.w3.org/2000/svg"),I(e,"fill","none"),I(e,"viewBox","0 0 24 24")},m(t,o){y(t,e,o),b(e,n),b(e,r)},p:a,i:a,o:a,d(t){t&&m(e)}}}class Ts extends rt{constructor(t){super(),nt(this,t,null,Ss,d,{})}}const{window:Is}=w;function Ps(t){let e,n,r,o,i,s,a,c,l,u,d,f,p=!t[18]&&!t[11]&&!t[12]&&!t[13]&&Cs(t);const g=[Hs,_s,Os,Us,Ls,Ns,$s],w=[];function E(t,e){return t[11]?0:t[12]?1:t[13]?2:t[18]?3:t[16]?4:t[19]?6:5}return a=E(t),c=w[a]=g[a](t),{c(){e=v("div"),n=v("button"),r=k(""),i=A(),p&&p.c(),s=A(),c.c(),I(n,"class",o="absolute right-2 top-0 cursor-pointer bg-transparent text-3xl text-"+t[0]+"-600"),I(e,"class",l="animate-show rounded-md bg-gradient-to-b px-8 py-8 shadow-[0_0px_30px_0px_rgba(0,0,0,0.6)] transition-all sm:w-96 bg-"+t[0]+"-800 from-"+t[0]+"-900 to-"+t[0]+"-700 "+t[26])},m(o,c){y(o,e,c),b(e,n),b(n,r),b(e,i),p&&p.m(e,null),b(e,s),w[a].m(e,null),u=!0,d||(f=T(n,"click",(function(){h(t[18]?t[33]:t[31])&&(t[18]?t[33]:t[31]).apply(this,arguments)})),d=!0)},p(r,i){t=r,(!u||1&i[0]&&o!==(o="absolute right-2 top-0 cursor-pointer bg-transparent text-3xl text-"+t[0]+"-600"))&&I(n,"class",o),t[18]||t[11]||t[12]||t[13]?p&&(p.d(1),p=null):p?p.p(t,i):(p=Cs(t),p.c(),p.m(e,s));let h=a;a=E(t),a===h?w[a].p(t,i):(V(),Z(w[h],1,1,(()=>{w[h]=null})),J(),c=w[a],c?c.p(t,i):(c=w[a]=g[a](t),c.c()),Y(c,1),c.m(e,null)),(!u||67108865&i[0]&&l!==(l="animate-show rounded-md bg-gradient-to-b px-8 py-8 shadow-[0_0px_30px_0px_rgba(0,0,0,0.6)] transition-all sm:w-96 bg-"+t[0]+"-800 from-"+t[0]+"-900 to-"+t[0]+"-700 "+t[26]))&&I(e,"class",l)},i(t){u||(Y(c),u=!0)},o(t){Z(c),u=!1},d(t){t&&m(e),p&&p.d(),w[a].d(),d=!1,f()}}}function Bs(t){let e,n,r,o,i;const s=[aa,sa,ia,oa],a=[];function c(t,e){return t[10]?0:t[19]?t[2]?3:2:1}return n=c(t),r=a[n]=s[n](t),{c(){e=v("div"),r.c(),I(e,"class",o="rounded px-2 py-2 shadow-[0_0px_10px_0px_rgba(0,0,0,0.3)] transition-all duration-200 bg-"+t[0]+"-700 hover:bg-"+t[0]+"-800 "+t[26])},m(t,r){y(t,e,r),a[n].m(e,null),i=!0},p(t,l){let u=n;n=c(t),n===u?a[n].p(t,l):(V(),Z(a[u],1,1,(()=>{a[u]=null})),J(),r=a[n],r?r.p(t,l):(r=a[n]=s[n](t),r.c()),Y(r,1),r.m(e,null)),(!i||67108865&l[0]&&o!==(o="rounded px-2 py-2 shadow-[0_0px_10px_0px_rgba(0,0,0,0.3)] transition-all duration-200 bg-"+t[0]+"-700 hover:bg-"+t[0]+"-800 "+t[26]))&&I(e,"class",o)},i(t){i||(Y(r),i=!0)},o(t){Z(r),i=!1},d(t){t&&m(e),a[n].d()}}}function Rs(t){return{c:a,m:a,p:a,i:a,o:a,d:a}}function Cs(t){let e,n,r,o,i;return{c(){e=v("button"),n=k("?"),I(e,"class",r="absolute bottom-1 right-3 cursor-pointer bg-transparent text-xl text-"+t[0]+"-600")},m(r,s){y(r,e,s),b(e,n),o||(i=T(e,"click",t[32]),o=!0)},p(t,n){1&n[0]&&r!==(r="absolute bottom-1 right-3 cursor-pointer bg-transparent text-xl text-"+t[0]+"-600")&&I(e,"class",r)},d(t){t&&m(e),o=!1,i()}}}function $s(t){let e,n,r,o,i,s,c,l,u,h,d,f,p,g,w,E,x=t[19].npub+"",B=(t[19].picture||t[19].name)&&Ms(t),R=!t[9]&&zs(t);return{c(){e=v("div"),n=v("div"),n.textContent="You are connected to Nostr as",r=A(),o=v("a"),B&&B.c(),i=A(),s=v("div"),c=k(x),u=A(),h=v("button"),d=k("Disconnect"),p=A(),R&&R.c(),g=S(),I(n,"class","mb-4 text-sm"),I(s,"class","block break-all"),I(o,"target","_blank"),I(o,"href",l="https://nosta.me/"+t[19].npub),I(o,"class","group text-white no-underline"),I(e,"class","text-center"),I(h,"class",f="my-2 mt-6 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950")},m(a,l){y(a,e,l),b(e,n),b(e,r),b(e,o),B&&B.m(o,null),b(o,i),b(o,s),b(s,c),y(a,u,l),y(a,h,l),b(h,d),y(a,p,l),R&&R.m(a,l),y(a,g,l),w||(E=T(h,"click",t[36]),w=!0)},p(t,e){t[19].picture||t[19].name?B?B.p(t,e):(B=Ms(t),B.c(),B.m(o,i)):B&&(B.d(1),B=null),524288&e[0]&&x!==(x=t[19].npub+"")&&P(c,x),524288&e[0]&&l!==(l="https://nosta.me/"+t[19].npub)&&I(o,"href",l),1&e[0]&&f!==(f="my-2 mt-6 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950")&&I(h,"class",f),t[9]?R&&(R.d(1),R=null):R?R.p(t,e):(R=zs(t),R.c(),R.m(g.parentNode,g))},i:a,o:a,d(t){t&&(m(e),m(u),m(h),m(p),m(g)),B&&B.d(),R&&R.d(t),w=!1,E()}}}function Ns(t){let e,n,r,o,i,s,a,c,l,h,d,f,p,g,w,E,x,k,P=t[17]&&Ds(t);const R=[Ks,Fs],C=[];function $(t,e){return t[10]?0:1}c=$(t),l=C[c]=R[c](t);let N=t[10]&&t[14]&&Ws(t),L=!t[10]&&Vs(t),U=!t[10]&&Zs(t);return{c(){e=v("div"),e.textContent="How do you want to connect to Nostr?",n=A(),r=v("form"),o=v("input"),i=A(),P&&P.c(),s=A(),a=v("button"),l.c(),f=A(),N&&N.c(),p=A(),L&&L.c(),g=A(),U&&U.c(),w=S(),I(e,"class","text-center text-lg"),I(o,"class","box-border w-full rounded px-2 py-1 text-lg text-neutral-800 bg-white outline-none"),I(o,"placeholder","bunker://... or nsec1..."),o.autofocus=!0,o.disabled=t[10],I(o,"autocapitalize","none"),I(a,"class",h="mt-4 flex w-full cursor-pointer items-center justify-center rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950"),a.disabled=d=!t[25]||t[10],I(r,"class","mb-1 mt-4 flex flex-col")},m(l,u){y(l,e,u),y(l,n,u),y(l,r,u),b(r,o),t[52](o),B(o,t[4]),b(r,i),P&&P.m(r,null),b(r,s),b(r,a),C[c].m(a,null),b(r,f),N&&N.m(r,null),y(l,p,u),L&&L.m(l,u),y(l,g,u),U&&U.m(l,u),y(l,w,u),E=!0,o.focus(),x||(k=[T(o,"input",t[53]),T(r,"submit",t[54])],x=!0)},p(t,e){(!E||1024&e[0])&&(o.disabled=t[10]),16&e[0]&&o.value!==t[4]&&B(o,t[4]),t[17]?P?P.p(t,e):(P=Ds(t),P.c(),P.m(r,s)):P&&(P.d(1),P=null);let n=c;c=$(t),c!==n&&(V(),Z(C[n],1,1,(()=>{C[n]=null})),J(),l=C[c],l||(l=C[c]=R[c](t),l.c()),Y(l,1),l.m(a,null)),(!E||1&e[0]&&h!==(h="mt-4 flex w-full cursor-pointer items-center justify-center rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950"))&&I(a,"class",h),(!E||33555456&e[0]&&d!==(d=!t[25]||t[10]))&&(a.disabled=d),t[10]&&t[14]?N?N.p(t,e):(N=Ws(t),N.c(),N.m(r,null)):N&&(N.d(1),N=null),t[10]?L&&(L.d(1),L=null):L?L.p(t,e):(L=Vs(t),L.c(),L.m(g.parentNode,g)),t[10]?U&&(V(),Z(U,1,1,(()=>{U=null})),J()):U?(U.p(t,e),1024&e[0]&&Y(U,1)):(U=Zs(t),U.c(),Y(U,1),U.m(w.parentNode,w))},i(t){E||(Y(l),Y(U),E=!0)},o(t){Z(l),Z(U),E=!1},d(o){o&&(m(e),m(n),m(r),m(p),m(g),m(w)),t[52](null),P&&P.d(),C[c].d(),N&&N.d(),L&&L.d(o),U&&U.d(o),x=!1,u(k)}}}function Ls(t){let e,n,r,o,i,s,c,l,h,d,f,p,g,w,E;return{c(){e=v("div"),e.textContent="Create a Nostr account",n=A(),r=v("div"),r.textContent="To use this Nostr app you need a profile. The following button opens a\n wizard that help you to create your keypair and safely manage it in a\n few steps. Are you ready?",o=A(),i=v("button"),s=k("Create an account »"),l=A(),h=v("div"),d=k("Do you already have a Nostr address?"),f=v("br"),p=A(),g=v("button"),g.textContent="Login now",I(e,"class","text-center text-lg"),I(r,"class","mt-4 text-base leading-5"),I(i,"class",c="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950"),i.disabled=fa,I(g,"class","cursor-pointer border-0 bg-transparent text-sm text-white underline"),I(h,"class","mt-6 text-center text-sm leading-3")},m(a,c){y(a,e,c),y(a,n,c),y(a,r,c),y(a,o,c),y(a,i,c),b(i,s),y(a,l,c),y(a,h,c),b(h,d),b(h,f),b(h,p),b(h,g),w||(E=[T(i,"click",t[43]),T(g,"click",t[38])],w=!0)},p(t,e){1&e[0]&&c!==(c="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950")&&I(i,"class",c)},i:a,o:a,d(t){t&&(m(e),m(n),m(r),m(o),m(i),m(l),m(h)),w=!1,u(E)}}}function Us(t){let e,n,r;return{c(){e=v("div"),e.textContent="What is that?",n=A(),r=v("div"),r.innerHTML='<p class="mb mt-4">This widget is created with <i>window.nostr.js</i>, a small script\n you can drop in any page that already uses NIP-07 and make it also\n work with NIP-46 automatically when the user doesn&#39;t have an\n extension installed.\n <br/>\n It adds a small floating button on the side of the window that users can\n use to create Nostr accuonts or connect to their NIP-46 bunkers.</p> <p class="mt-4">This tool is opensource, get the code from the <a target="_blank" class="underline" href="https://github.com/fiatjaf/window.nostr.js">project&#39;s page</a>.</p> <p class="mt-4">You don&#39;t know what Nostr is?\n <a target="_blank" class="underline" href="https://www.nostr.com">Learn more</a>.</p>',I(e,"class","text-center text-lg"),I(r,"class","text-base leading-5")},m(t,o){y(t,e,o),y(t,n,o),y(t,r,o)},p:a,i:a,o:a,d(t){t&&(m(e),m(n),m(r))}}}function Os(t){let e,n,r,o,i,s,c,l,u,h,d,f,p,g,w,E,x=new URL(t[13]).host+"";return{c(){e=v("div"),n=v("div"),n.textContent="An action requires your confirmation",r=A(),o=v("div"),i=k("A new window will now open, taking you to "),s=v("strong"),c=k(x),l=k("\n where you can approve the current action. If nothing happens, ensure your\n browser is not blocking popups."),u=v("br"),h=k("\n Afterward, you'll be redirected back to this page."),d=A(),f=v("button"),p=k("Confirm action »"),I(n,"class","text-center text-lg"),I(o,"class","mt-4 text-center text-sm leading-4"),I(f,"class",g="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950"),I(e,"class","m-auto w-full")},m(a,g){y(a,e,g),b(e,n),b(e,r),b(e,o),b(o,i),b(o,s),b(s,c),b(o,l),b(o,u),b(o,h),b(e,d),b(e,f),b(f,p),w||(E=T(f,"click",t[51]),w=!0)},p(t,e){8192&e[0]&&x!==(x=new URL(t[13]).host+"")&&P(c,x),1&e[0]&&g!==(g="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950")&&I(f,"class",g)},i:a,o:a,d(t){t&&m(e),w=!1,E()}}}function _s(t){let e,n,r,o,i,s,c,l,u,h,d,f,p,g,w,E,x=new URL(t[12]).host+"";return{c(){e=v("div"),n=v("div"),n.textContent="Login into a Nostr account",r=A(),o=v("div"),i=k("A new window will now open, taking you to "),s=v("strong"),c=k(x),l=k("\n where you can login and approve the permissions. If nothing happens, ensure\n your browser is not blocking popups. "),u=v("br"),h=k("\n Afterward, you'll be redirected back to this page."),d=A(),f=v("button"),p=k("Login now »"),I(n,"class","text-center text-lg"),I(o,"class","mt-4 text-center text-sm leading-4"),I(f,"class",g="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950"),I(e,"class","m-auto w-full")},m(a,g){y(a,e,g),b(e,n),b(e,r),b(e,o),b(o,i),b(o,s),b(s,c),b(o,l),b(o,u),b(o,h),b(e,d),b(e,f),b(f,p),w||(E=T(f,"click",t[50]),w=!0)},p(t,e){4096&e[0]&&x!==(x=new URL(t[12]).host+"")&&P(c,x),1&e[0]&&g!==(g="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950")&&I(f,"class",g)},i:a,o:a,d(t){t&&m(e),w=!1,E()}}}function Hs(t){let e,n,r,o,i,s,c,l,u,h,d,f,p,g,w,E,x=new URL(t[11]).host+"";return{c(){e=v("div"),n=v("div"),n.textContent="Create a Nostr account",r=A(),o=v("div"),i=k("A new window will now open, taking you to\n "),s=v("strong"),c=k(x),l=k("\n where the account creation will occur. If nothing happens, ensure your\n browser is not blocking popups.\n "),u=v("br"),h=k(" Afterward, you'll be redirected back to this page."),d=A(),f=v("button"),p=k("Start account creation »"),I(n,"class","text-center text-lg"),I(o,"class","mt-4 text-center text-sm leading-4"),I(f,"class",g="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950"),I(e,"class","m-auto w-full")},m(a,g){y(a,e,g),b(e,n),b(e,r),b(e,o),b(o,i),b(o,s),b(s,c),b(o,l),b(o,u),b(o,h),b(e,d),b(e,f),b(f,p),w||(E=T(f,"click",t[49]),w=!0)},p(t,e){2048&e[0]&&x!==(x=new URL(t[11]).host+"")&&P(c,x),1&e[0]&&g!==(g="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950")&&I(f,"class",g)},i:a,o:a,d(t){t&&m(e),w=!1,E()}}}function Ms(t){let e,n,r=t[19].picture&&js(t),o=t[19].name&&qs(t);return{c(){e=v("div"),r&&r.c(),n=A(),o&&o.c(),I(e,"class","mb-2 flex items-center justify-center gap-2")},m(t,i){y(t,e,i),r&&r.m(e,null),b(e,n),o&&o.m(e,null)},p(t,i){t[19].picture?r?r.p(t,i):(r=js(t),r.c(),r.m(e,n)):r&&(r.d(1),r=null),t[19].name?o?o.p(t,i):(o=qs(t),o.c(),o.m(e,null)):o&&(o.d(1),o=null)},d(t){t&&m(e),r&&r.d(),o&&o.d()}}}function js(t){let e,n,r;return{c(){e=v("img"),p(e.src,n=t[19].picture)||I(e,"src",n),I(e,"alt",""),I(e,"class",r="h-10 w-10 rounded-full border-2 border-solid border-transparent group-hover:border-"+t[0]+"-100")},m(t,n){y(t,e,n)},p(t,o){524288&o[0]&&!p(e.src,n=t[19].picture)&&I(e,"src",n),1&o[0]&&r!==(r="h-10 w-10 rounded-full border-2 border-solid border-transparent group-hover:border-"+t[0]+"-100")&&I(e,"class",r)},d(t){t&&m(e)}}}function qs(t){let e,n,r=t[19].name+"";return{c(){e=v("div"),n=k(r),I(e,"class","text-3xl decoration-2 underline-offset-4 group-hover:underline")},m(t,r){y(t,e,r),b(e,n)},p(t,e){524288&e[0]&&r!==(r=t[19].name+"")&&P(n,r)},d(t){t&&m(e)}}}function zs(t){let e,n,r,o,i,s=_o(t[8])+"";return{c(){e=v("div"),n=k("This webpage is using the public key:"),r=v("br"),o=A(),i=k(s),I(e,"class","mt-6 block break-all text-center text-xs")},m(t,s){y(t,e,s),b(e,n),b(e,r),b(e,o),b(e,i)},p(t,e){256&e[0]&&s!==(s=_o(t[8])+"")&&P(i,s)},d(t){t&&m(e)}}}function Ds(t){let e,n;return{c(){e=v("div"),n=k(t[17]),I(e,"class","my-2 rounded bg-yellow-100 p-2 text-center text-sm leading-4 text-red-400")},m(t,r){y(t,e,r),b(e,n)},p(t,e){131072&e[0]&&P(n,t[17])},d(t){t&&m(e)}}}function Fs(t){let e;return{c(){e=k("Connect »")},m(t,n){y(t,e,n)},i:a,o:a,d(t){t&&m(e)}}}function Ks(t){let e,n,r;return n=new Ts({}),{c(){e=k("Connecting to bunker\n "),G(n.$$.fragment)},m(t,o){y(t,e,o),X(n,t,o),r=!0},i(t){r||(Y(n.$$.fragment,t),r=!0)},o(t){Z(n.$$.fragment,t),r=!1},d(t){t&&m(e),tt(n,t)}}}function Ws(t){let e,n,r,o,i;return{c(){e=v("div"),n=k("Waiting too much?\n "),r=v("button"),r.textContent="Cancel the connection",I(r,"class","cursor-pointer border-0 bg-transparent text-sm text-white underline"),I(e,"class","mt-6 text-center text-sm leading-3")},m(s,a){y(s,e,a),b(e,n),b(e,r),o||(i=T(r,"click",t[39]),o=!0)},p:a,d(t){t&&m(e),o=!1,i()}}}function Vs(t){let e;function n(t,e){return t[15]?Ys:Js}let r=n(t),o=r(t);return{c(){e=v("div"),o.c(),I(e,"class","mt-6 text-center text-sm leading-3")},m(t,n){y(t,e,n),o.m(e,null)},p(t,i){r===(r=n(t))&&o?o.p(t,i):(o.d(1),o=r(t),o&&(o.c(),o.m(e,null)))},d(t){t&&m(e),o.d()}}}function Js(t){let e,n,r,o,i,s;return{c(){e=k("Do you need a Nostr account?"),n=v("br"),r=A(),o=v("button"),o.textContent="Sign up now",I(o,"class","cursor-pointer border-0 bg-transparent text-sm text-white underline")},m(a,c){y(a,e,c),y(a,n,c),y(a,r,c),y(a,o,c),i||(s=T(o,"click",t[43]),i=!0)},p:a,d(t){t&&(m(e),m(n),m(r),m(o)),i=!1,s()}}}function Ys(t){let e,n,r,o,i,s;return{c(){e=k("Is this bunker provider broken?"),n=v("br"),r=A(),o=v("button"),o.textContent="Clear it",I(o,"class","cursor-pointer border-0 bg-transparent text-sm text-white underline")},m(a,c){y(a,e,c),y(a,n,c),y(a,r,c),y(a,o,c),i||(s=T(o,"click",t[37]),i=!0)},p:a,d(t){t&&(m(e),m(n),m(r),m(o)),i=!1,s()}}}function Zs(t){let e,n,r,o,i,s;const a=[Gs,Qs],c=[];function l(t,e){return t[20]?0:1}return o=l(t),i=c[o]=a[o](t),{c(){e=v("div"),n=v("div"),n.textContent="Scan this QR code with a Nostr client to connect",r=A(),i.c(),I(n,"class","mb-2 text-sm"),I(e,"class","mt-4 text-center")},m(t,i){y(t,e,i),b(e,n),b(e,r),c[o].m(e,null),s=!0},p(t,n){let r=o;o=l(t),o===r?c[o].p(t,n):(V(),Z(c[r],1,1,(()=>{c[r]=null})),J(),i=c[o],i?i.p(t,n):(i=c[o]=a[o](t),i.c()),Y(i,1),i.m(e,null))},i(t){s||(Y(i),s=!0)},o(t){Z(i),s=!1},d(t){t&&m(e),c[o].d()}}}function Qs(t){let e,n,r;return n=new Ts({}),{c(){e=v("div"),G(n.$$.fragment),I(e,"class","mb-4 flex justify-center")},m(t,o){y(t,e,o),X(n,e,null),r=!0},p:a,i(t){r||(Y(n.$$.fragment,t),r=!0)},o(t){Z(n.$$.fragment,t),r=!1},d(t){t&&m(e),tt(n)}}}function Gs(t){let e,n,r,o,i,s={ctx:t,current:null,token:null,hasCatch:!0,pending:ea,then:ta,catch:Xs,value:27,error:85,blocks:[,,,]};function a(t,e){return t[21]?ra:na}Q(n=t[27],s);let c=a(t),l=c(t);return{c(){e=v("div"),s.block.c(),r=A(),l.c(),o=S(),I(e,"class","mb-4 flex justify-center")},m(t,n){y(t,e,n),s.block.m(e,s.anchor=null),s.mount=()=>e,s.anchor=null,y(t,r,n),l.m(t,n),y(t,o,n),i=!0},p(e,r){t=e,s.ctx=t,134217728&r[0]&&n!==(n=t[27])&&Q(n,s)||function(t,e,n){const r=e.slice(),{resolved:o}=t;t.current===t.then&&(r[t.value]=o),t.current===t.catch&&(r[t.error]=o),t.block.p(r,n)}(s,t,r),c===(c=a(t))&&l?l.p(t,r):(l.d(1),l=c(t),l&&(l.c(),l.m(o.parentNode,o)))},i(t){i||(Y(s.block),i=!0)},o(t){for(let t=0;t<3;t+=1){Z(s.blocks[t])}i=!1},d(t){t&&(m(e),m(r),m(o)),s.block.d(),s.token=null,s=null,l.d(t)}}}function Xs(t){let e,n,r=t[85]+"";return{c(){e=v("p"),n=k(r)},m(t,r){y(t,e,r),b(e,n)},p(t,e){134217728&e[0]&&r!==(r=t[85]+"")&&P(n,r)},i:a,o:a,d(t){t&&m(e)}}}function ta(t){let e,n,r,o,i;return{c(){e=v("div"),n=v("img"),p(n.src,r=t[27])||I(n,"src",r),I(n,"alt","Nostr Connect QR Code"),I(n,"class","rounded-lg bg-white p-2"),I(e,"class","cursor-pointer")},m(r,s){y(r,e,s),b(e,n),o||(i=[T(e,"click",t[29]),T(e,"keydown",t[55])],o=!0)},p(t,e){134217728&e[0]&&!p(n.src,r=t[27])&&I(n,"src",r)},i:a,o:a,d(t){t&&m(e),o=!1,u(i)}}}function ea(t){let e,n;return e=new Ts({}),{c(){G(e.$$.fragment)},m(t,r){X(e,t,r),n=!0},p:a,i(t){n||(Y(e.$$.fragment,t),n=!0)},o(t){Z(e.$$.fragment,t),n=!1},d(t){tt(e,t)}}}function na(t){let e,n,r,o,i,s,a;return{c(){e=v("div"),n=k(t[20]),r=A(),o=x("svg"),i=x("path"),I(i,"stroke-linecap","round"),I(i,"stroke-linejoin","round"),I(i,"stroke-width","2"),I(i,"d","M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"),I(o,"class","ml-1 inline-block h-3 w-3 align-middle"),I(o,"fill","none"),I(o,"stroke","currentColor"),I(o,"viewBox","0 0 24 24"),I(o,"xmlns","http://www.w3.org/2000/svg"),I(e,"class","mb-4 cursor-pointer break-all text-xs text-gray-300 transition-all hover:text-gray-200"),I(e,"role","button"),I(e,"tabindex","0"),I(e,"title","Click to copy")},m(c,l){y(c,e,l),b(e,n),b(e,r),b(e,o),b(o,i),s||(a=[T(e,"click",t[29]),T(e,"keydown",t[56])],s=!0)},p(t,e){1048576&e[0]&&P(n,t[20])},d(t){t&&m(e),s=!1,u(a)}}}function ra(t){let e;return{c(){e=v("div"),e.textContent="Copied!",I(e,"class","mb-38 mt-34 break-all text-xs text-gray-300")},m(t,n){y(t,e,n)},p:a,d(t){t&&m(e)}}}function oa(t){let e,n;return{c(){e=v("img"),p(e.src,n=t[19].picture)||I(e,"src",n),I(e,"alt",""),I(e,"class","h-6 w-6 rounded-full")},m(t,n){y(t,e,n)},p(t,r){524288&r[0]&&!p(e.src,n=t[19].picture)&&I(e,"src",n)},i:a,o:a,d(t){t&&m(e)}}}function ia(t){let e,n,r,o,i=(t[19].name||t[19].npub.slice(0,7)+"…"+t[19].npub.slice(-4))+"";function s(t,e){return t[19].picture?la:ca}let c=s(t),l=c(t);return{c(){e=v("div"),l.c(),n=A(),r=v("div"),o=k(i),I(r,"class","inline-block max-w-56 overflow-hidden overflow-ellipsis whitespace-nowrap"),I(e,"class","flex items-center px-2")},m(t,i){y(t,e,i),l.m(e,null),b(e,n),b(e,r),b(r,o)},p(t,r){c===(c=s(t))&&l?l.p(t,r):(l.d(1),l=c(t),l&&(l.c(),l.m(e,n))),524288&r[0]&&i!==(i=(t[19].name||t[19].npub.slice(0,7)+"…"+t[19].npub.slice(-4))+"")&&P(o,i)},i:a,o:a,d(t){t&&m(e),l.d()}}}function sa(t){let e;function n(t,e){return t[2]?ha:ua}let r=n(t),o=r(t);return{c(){o.c(),e=S()},m(t,n){o.m(t,n),y(t,e,n)},p(t,i){r!==(r=n(t))&&(o.d(1),o=r(t),o&&(o.c(),o.m(e.parentNode,e)))},i:a,o:a,d(t){t&&m(e),o.d(t)}}}function aa(t){let e,n,r,o;return r=new Ts({}),{c(){e=v("div"),n=k("Connecting to bunker\n "),G(r.$$.fragment),I(e,"class","flex items-center px-2")},m(t,i){y(t,e,i),b(e,n),X(r,e,null),o=!0},p:a,i(t){o||(Y(r.$$.fragment,t),o=!0)},o(t){Z(r.$$.fragment,t),o=!1},d(t){t&&m(e),tt(r)}}}function ca(t){let e;return{c(){e=v("span"),e.textContent="☉",I(e,"class","mr-2")},m(t,n){y(t,e,n)},p:a,d(t){t&&m(e)}}}function la(t){let e,n;return{c(){e=v("img"),p(e.src,n=t[19].picture)||I(e,"src",n),I(e,"alt",""),I(e,"class","mr-2 h-5 w-5 rounded-full")},m(t,n){y(t,e,n)},p(t,r){524288&r[0]&&!p(e.src,n=t[19].picture)&&I(e,"src",n)},d(t){t&&m(e)}}}function ua(t){let e;return{c(){e=v("div"),e.textContent="Connect with Nostr",I(e,"class","flex items-center px-2")},m(t,n){y(t,e,n)},d(t){t&&m(e)}}}function ha(t){let e;return{c(){e=v("div"),e.textContent="N",I(e,"class","w-6 text-center")},m(t,n){y(t,e,n)},d(t){t&&m(e)}}}function da(t){let e,n,r,o,i,s,a;const c=[Rs,Bs,Ps],l=[];function h(t,e){return t[24]||t[19]||!t[1]?t[24]?2:1:0}return n=h(t),r=l[n]=c[n](t),{c(){e=v("div"),r.c(),I(e,"class","draggable z-[9000] animate-fadein font-sans text-white"),I(e,"style",o="position: fixed; "+(t[24]&&t[5]?"width: 100vw;":"")+"; right: "+(t[24]&&t[5]?"0":t[3])+"px; user-select: none; "+(t[24]&&t[5]?"bottom: 0px":t[23]+":"+t[22]+"px")),R(e,"cursor-pointer",!t[19]&&!t[24])},m(r,o){y(r,e,o),l[n].m(e,null),t[57](e),i=!0,s||(a=[T(Is,"click",t[30]),T(Is,"mouseup",t[42]),T(Is,"mousemove",t[41]),T(e,"mousedown",t[40])],s=!0)},p(t,s){let a=n;n=h(t),n===a?l[n].p(t,s):(V(),Z(l[a],1,1,(()=>{l[a]=null})),J(),r=l[n],r?r.p(t,s):(r=l[n]=c[n](t),r.c()),Y(r,1),r.m(e,null)),(!i||29360168&s[0]&&o!==(o="position: fixed; "+(t[24]&&t[5]?"width: 100vw;":"")+"; right: "+(t[24]&&t[5]?"0":t[3])+"px; user-select: none; "+(t[24]&&t[5]?"bottom: 0px":t[23]+":"+t[22]+"px")))&&I(e,"style",o),(!i||17301504&s[0])&&R(e,"cursor-pointer",!t[19]&&!t[24])},i(t){i||(Y(r),i=!0)},o(t){Z(r),i=!1},d(r){r&&m(e),l[n].d(),t[57](null),s=!1,u(a)}}}let fa=!1;const pa="We could not connect to a NIP-46 bunker with that url, are you sure it is set up correctly?",ga="We were not able to connect using this address. For it to work it has to come from a NIP-46 provider.",wa=20;function ba(t){return window.open(t,"window.nostr","width=600,height=800,popup=yes")}function ya(t,e,n){let r,o,i,s,a,c;const l=window.location.hostname,u=window.location.protocol,h=As("only screen and (max-width: 640px)");g(t,h,(t=>n(5,c=t)));const d="wnj:origin",f="wnj:clientSecret",p="wnj:ypos",w="wnj:bunkerPointer";let b,{accent:y}=e,{position:m="top"}=e,{startHidden:v}=e,{compactMode:E}=e,{nostrConnectRelays:x}=e,{appMetadata:k}=e;const A=window;let S,T,I;const P=localStorage.getItem(f);P?I=We(P):(I=Oo(),localStorage.setItem(f,Ke(I)));let B,R,C,$,L,O,_,H,M,j,q,z,D,F="closed",K=!1,W=!1,V=null,J=null,Y=null,Z=!1,Q=!1,G=!1,X=[],tt=!1;async function et(){z&&(await navigator.clipboard.writeText(z),n(21,tt=!0),setTimeout((()=>{n(21,tt=!1)}),700))}let nt,rt,ot,{right:it=20}=e,st=!1,at=!1;const ct={pool:Vn,onauth(t){_?n(11,V=t):M?(n(13,Y=t),n(47,F="opened")):n(12,J=t)}},lt=To((()=>{switch(F){case"justopened":n(47,F="opened");break;case"justclosed":n(47,F="closed")}}),500);async function ut(){var t;n(47,F="justopened"),lt();const e=_o(I);n(20,z=function(t){const e=new URLSearchParams;return t.relays.forEach((t=>{e.append("relay",t)})),e.append("secret",t.secret),t.perms&&t.perms.length>0&&e.append("perms",t.perms.join(",")),t.name&&e.append("name",t.name),t.url&&e.append("url",t.url),t.image&&e.append("image",t.image),`nostrconnect://${t.clientPubkey}?${e.toString()}`}({clientPubkey:e,secret:Ke(Qe(8)),relays:x,name:k.name||location.hostname,url:k.url||location.href.split("#")[0].split("?")[0],image:k.image||(null==(t=document.head.querySelector('link[rel~="icon"]'))?void 0:t.href)||location.origin+"/favicon.ico"})),n(27,q=Jn.toDataURL(z.toString(),{width:256,margin:2,color:{dark:"#000000",light:"#FFFFFF"}})),D=new AbortController;try{const t=await ts.fromURI(I,z,ct,D.signal);B=t.bp,localStorage.setItem(w,JSON.stringify(B)),R(t),yt()}catch(t){console.warn("nostrconnect:// QR code handling failed:",t)}finally{D.abort("window.nostr.js interaction finished")}}function ht(){var t;n(47,F="justclosed"),lt(),null==(t=null==D?void 0:D.abort)||t.call(D,"window.nostr.js widget closed")}function dt(){!B||O?ut():bt()}pt();let ft={isWnj:!0,getPublicKey:async()=>new Promise((async(t,e)=>{X.push(e);try{!L&&!O&&dt();t(await(await $).getPublicKey())}catch(t){e(t)}finally{const t=X.indexOf(e);-1!==t&&X.splice(t,1)}})),async signEvent(t){try{return!L&&!O&&dt(),await(await $).signEvent(t)}finally{n(13,Y=null),ht()}},getRelays:async()=>({}),nip04:{encrypt:async(t,e)=>(!L&&!O&&dt(),(await $).nip04Encrypt(t,e)),decrypt:async(t,e)=>(!L&&!O&&dt(),(await $).nip04Decrypt(t,e))},nip44:{encrypt:async(t,e)=>(!L&&!O&&dt(),(await $).nip44Encrypt(t,e)),decrypt:async(t,e)=>(!L&&!O&&dt(),(await $).nip44Decrypt(t,e))}};function pt(){ht(),B=null,$=new Promise(((t,e)=>{R=t,C=e})),n(19,M=null),n(10,L=!1),n(14,Z=!1),n(16,_=!1),O=!1,j=null,n(17,H=""),n(20,z=void 0)}async function gt(t){var e;null==(e=null==t?void 0:t.preventDefault)||e.call(t),n(9,W=!1);try{if(B=await Xi(T),!B)return void(T.match(Gi)?n(17,H=pa):n(17,H=ga));S.setCustomValidity(""),n(17,H=""),await bt(),yt()}catch{T.match(Gi)?n(17,H=pa):n(17,H=ga),n(10,L=!1)}}function wt(t){var e;null==(e=null==t?void 0:t.preventDefault)||e.call(t);try{const t=T,e=function(t){var e,n,r,o,i,s,a;let{prefix:c,words:l}=Mi.decode(t,5e3),u=new Uint8Array(Mi.fromWords(l));switch(c){case"nprofile":{let t=ns(u);if(null==(e=t[0])||!e[0])throw new Error("missing TLV 0 for nprofile");if(32!==t[0][0].length)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:Ke(t[0][0]),relays:t[1]?t[1].map((t=>Bo.decode(t))):[]}}}case"nevent":{let t=ns(u);if(null==(n=t[0])||!n[0])throw new Error("missing TLV 0 for nevent");if(32!==t[0][0].length)throw new Error("TLV 0 should be 32 bytes");if(t[2]&&32!==t[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(t[3]&&4!==t[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"nevent",data:{id:Ke(t[0][0]),relays:t[1]?t[1].map((t=>Bo.decode(t))):[],author:null!=(r=t[2])&&r[0]?Ke(t[2][0]):void 0,kind:null!=(o=t[3])&&o[0]?parseInt(Ke(t[3][0]),16):void 0}}}case"naddr":{let t=ns(u);if(null==(i=t[0])||!i[0])throw new Error("missing TLV 0 for naddr");if(null==(s=t[2])||!s[0])throw new Error("missing TLV 2 for naddr");if(32!==t[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(null==(a=t[3])||!a[0])throw new Error("missing TLV 3 for naddr");if(4!==t[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:Bo.decode(t[0][0]),pubkey:Ke(t[2][0]),kind:parseInt(Ke(t[3][0]),16),relays:t[1]?t[1].map((t=>Bo.decode(t))):[]}}}case"nsec":return{type:c,data:u};case"npub":case"note":return{type:c,data:Ke(u)};default:throw new Error(`unknown prefix ${c}`)}}(t);if("nsec"===e.type){const r=e.data,o=_o(r);n(9,W=!0),$=Promise.resolve({getPublicKey:async()=>o,signEvent:async t=>Ho(t,r),nip04Decrypt:async(t,e)=>function(t,e,n){const r=t instanceof Uint8Array?Ke(t):t;let[o,i]=n.split("?iv="),s=xs(Se.getSharedSecret(r,"02"+e)),a=Pi.decode(i),c=Pi.decode(o),l=Es(s,a).decrypt(c);return Bo.decode(l)}(r,t,e),nip04Encrypt:async(t,e)=>function(t,e,n){const r=t instanceof Uint8Array?Ke(t):t,o=xs(Se.getSharedSecret(r,"02"+e));let i=Uint8Array.from(Qe(16)),s=Ro.encode(n),a=Es(o,i).encrypt(s);return`${Pi.encode(new Uint8Array(a))}?iv=${Pi.encode(new Uint8Array(i.buffer))}`}(r,t,e),nip44Decrypt:async(t,e)=>Ji(e,zi(r,t)),nip44Encrypt:async(t,e)=>Vi(e,zi(r,t))}),K=!0,ut(),n(17,H=""),n(10,L=!1),O=!0,yt(),localStorage.setItem(w,t)}}catch(t){console.error("failed to decode nsec:",t)}}async function bt(t=void 0){t=t||ts.fromBunker(I,B,ct),n(10,L=!0);let e=setTimeout((()=>{n(14,Z=!0),n(47,F="opened")}),5e3);try{await t.connect(),O=!0,ht(),Date.now()%20==0&&await t.switchRelays(),localStorage.setItem(w,JSON.stringify(B)),R(t)}catch(t){C((null==t?void 0:t.message)||String(t))}finally{clearTimeout(e),n(10,L=!1),n(14,Z=!1),n(11,V=null),n(12,J=null),n(13,Y=null),K&&ut()}}async function yt(){let t;try{t=await(await $).getPublicKey()}catch{return void n(15,Q=!0)}n(19,M={pubkey:t,npub:rs(t),event:null});const e=await Dn(t);j=Vn.subscribeMany(e.items.filter((t=>t.write)).map((t=>t.url)).concat(["wss://purplepag.es","wss://indexer.coracle.social","wss://relay.snort.social","wss://relay.nos.social"]),{kinds:[0],authors:[t]},{onevent(t){var e;if(!(((null==(e=M.event)?void 0:e.created_at)||0)>=t.created_at))try{let{name:e,picture:r}=JSON.parse(t.content);n(19,M.event=t,M),n(19,M.name=e,M),n(19,M.picture=r,M)}catch{}}})}!function(t){N().$$.on_mount.push(t)}((()=>{const t=window.location.hash;if(t.startsWith("#nostr-login=")){const e=t.substring(t.indexOf("=")+1),r=window.location.href.split("#")[0];history.replaceState(null,"",r),e.startsWith("bunker://")?(n(4,T=e),K=!0,ut(),gt()):e.startsWith("nsec1")&&(n(4,T=e),K=!0,ut(),wt())}if(!B){let t=localStorage.getItem(w);if(t)if(t.startsWith("nsec1"))n(4,T=t),wt(),yt();else{B=JSON.parse(t);let e=new URL(`bunker://${B.pubkey}`);B.relays.forEach((t=>{e.searchParams.append("relay",t)})),B.secret&&e.searchParams.set("secret",B.secret),n(4,T=e.toString()),yt(),bt()}}if(!A.nostr||A.nostr.isWnj)return Object.defineProperty(window,"nostr",{get:()=>ft,set(t){ft=t,t.isWnj||A.destroyWnj(),X.forEach((t=>{t(new Error("Nostr extension took over, please retry the operation"))})),X=[]},configurable:!0}),()=>{j&&j.close()};A.destroyWnj()}));return t.$$set=t=>{"accent"in t&&n(0,y=t.accent),"position"in t&&n(44,m=t.position),"startHidden"in t&&n(1,v=t.startHidden),"compactMode"in t&&n(2,E=t.compactMode),"nostrConnectRelays"in t&&n(45,x=t.nostrConnectRelays),"appMetadata"in t&&n(46,k=t.appMetadata),"right"in t&&n(3,it=t.right)},t.$$.update=()=>{32&t.$$.dirty[0]|8192&t.$$.dirty[1]&&n(23,r=c?"bottom":localStorage.getItem(d)||m),32&t.$$.dirty[0]&&n(22,o=c?wa:parseInt(localStorage.getItem(p)||"0")||wa),65536&t.$$.dirty[1]&&n(24,i="justopened"===F||"opened"===F),1&t.$$.dirty[0]|131072&t.$$.dirty[1]&&n(26,s=at?"cursor-grabbing outline-dashed outline-"+y+"-500 outline-1 outline-offset-4":"outline-none"),16&t.$$.dirty[0]&&n(25,a=T&&(T.match(Gi)||T.match(Yi)||T.startsWith("nsec1")&&63===T.length))},[y,v,E,it,T,c,b,S,I,W,L,V,J,Y,Z,Q,_,H,G,M,z,tt,o,r,i,a,s,q,h,et,function(t){Math.abs(o-rt)>6||Date.now()-ot>600||"justopened"===F||"justclosed"===F||(t.composedPath().find((t=>"wnj"===t.id))?ut():ht())},function(t){ht(),n(16,_=!1),n(11,V=null),n(12,J=null),n(13,Y=null),t.stopPropagation()},function(t){n(18,G=!0),t.stopPropagation()},function(t){n(18,G=!1),t.stopPropagation()},gt,wt,async function(t){t.preventDefault(),localStorage.removeItem(w),pt()},async function(t){t.preventDefault(),n(4,T=""),localStorage.removeItem(w),n(15,Q=!1)},function(t){n(16,_=!1)},function(){n(14,Z=!1),n(10,L=!1),C("connection aborted"),pt(),ut()},function(t){if(i)return;st=!0;const e=b.getBoundingClientRect();nt=t.clientY-e.top,rt=o,ot=Date.now()},function(t){st&&(n(22,o="top"===r?t.clientY:window.innerHeight-t.clientY),n(22,o-=nt),n(48,at=!0),o<wa&&n(22,o=wa),o>window.innerHeight-wa&&n(22,o=window.innerHeight-wa))},function(){if(st=!1,setTimeout((()=>{n(48,at=!1)}),10),at){const t=b.getBoundingClientRect(),e=window.innerHeight,i=e/2;t.top<i?(n(23,r="top"),n(22,o=t.top)):(n(23,r="bottom"),n(22,o=e-t.bottom)),o<wa&&n(22,o=wa),localStorage.setItem(d,r),localStorage.setItem(p,o.toString())}},function(){window.location.href=`https://nstart.me?an=${l}&at=web&ac=${u}//${l}&sfb=yes`},m,x,k,F,at,()=>ba(V),()=>ba(J),()=>{ba(Y)},function(t){U[t?"unshift":"push"]((()=>{S=t,n(7,S)}))},function(){T=this.value,n(4,T)},t=>T.startsWith("nsec1")?wt(t):gt(t),t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),et())},t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),et())},function(t){U[t?"unshift":"push"]((()=>{b=t,n(6,b)}))}]}const ma=window;ma.destroyWnj=()=>{setTimeout((()=>{Aa.$destroy()}),1)};const va=document.createElement("div");va.style.zIndex="90000",document.body.appendChild(va);const Ea=document.createElement("div");Ea.id="wnj";const xa=document.createElement("style");xa.innerHTML='*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.fixed{position:fixed}.absolute{position:absolute}.bottom-1{bottom:.25rem}.right-2{right:.5rem}.right-3{right:.75rem}.top-0{top:0}.z-\\[9000\\]{z-index:9000}.m-auto{margin:auto}.my-2{margin-top:.5rem;margin-bottom:.5rem}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-4{margin-bottom:1rem}.ml-1{margin-left:.25rem}.ml-2{margin-left:.5rem}.mr-2{margin-right:.5rem}.mt-4{margin-top:1rem}.mt-6{margin-top:1.5rem}.box-border{box-sizing:border-box}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.h-10{height:2.5rem}.h-3{height:.75rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.w-10{width:2.5rem}.w-3{width:.75rem}.w-5{width:1.25rem}.w-6{width:1.5rem}.w-full{width:100%}.max-w-56{max-width:14rem}@keyframes moveIn{0%{transform:translateY(-10px)}to{transform:translateY(0)}}.animate-fadein{animation:fadeIn 1s ease-in-out,moveIn 1s ease-in-out}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}.animate-show{animation:fadeIn .2s ease-in-out}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-grabbing{cursor:grabbing}.cursor-pointer{cursor:pointer}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-center{justify-content:center}.gap-2{gap:.5rem}.overflow-hidden{overflow:hidden}.overflow-ellipsis{text-overflow:ellipsis}.whitespace-nowrap{white-space:nowrap}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.border-0{border-width:0px}.border-2{border-width:2px}.border-solid{border-style:solid}.border-transparent{border-color:transparent}.bg-cyan-700{--tw-bg-opacity: 1;background-color:rgb(14 116 144 / var(--tw-bg-opacity, 1))}.bg-cyan-800{--tw-bg-opacity: 1;background-color:rgb(21 94 117 / var(--tw-bg-opacity, 1))}.bg-cyan-900{--tw-bg-opacity: 1;background-color:rgb(22 78 99 / var(--tw-bg-opacity, 1))}.bg-cyan-950{--tw-bg-opacity: 1;background-color:rgb(8 51 68 / var(--tw-bg-opacity, 1))}.bg-green-700{--tw-bg-opacity: 1;background-color:rgb(21 128 61 / var(--tw-bg-opacity, 1))}.bg-green-800{--tw-bg-opacity: 1;background-color:rgb(22 101 52 / var(--tw-bg-opacity, 1))}.bg-green-900{--tw-bg-opacity: 1;background-color:rgb(20 83 45 / var(--tw-bg-opacity, 1))}.bg-green-950{--tw-bg-opacity: 1;background-color:rgb(5 46 22 / var(--tw-bg-opacity, 1))}.bg-neutral-700{--tw-bg-opacity: 1;background-color:rgb(64 64 64 / var(--tw-bg-opacity, 1))}.bg-neutral-800{--tw-bg-opacity: 1;background-color:rgb(38 38 38 / var(--tw-bg-opacity, 1))}.bg-neutral-900{--tw-bg-opacity: 1;background-color:rgb(23 23 23 / var(--tw-bg-opacity, 1))}.bg-neutral-950{--tw-bg-opacity: 1;background-color:rgb(10 10 10 / var(--tw-bg-opacity, 1))}.bg-orange-700{--tw-bg-opacity: 1;background-color:rgb(194 65 12 / var(--tw-bg-opacity, 1))}.bg-orange-800{--tw-bg-opacity: 1;background-color:rgb(154 52 18 / var(--tw-bg-opacity, 1))}.bg-orange-900{--tw-bg-opacity: 1;background-color:rgb(124 45 18 / var(--tw-bg-opacity, 1))}.bg-orange-950{--tw-bg-opacity: 1;background-color:rgb(67 20 7 / var(--tw-bg-opacity, 1))}.bg-purple-700{--tw-bg-opacity: 1;background-color:rgb(126 34 206 / var(--tw-bg-opacity, 1))}.bg-purple-800{--tw-bg-opacity: 1;background-color:rgb(107 33 168 / var(--tw-bg-opacity, 1))}.bg-purple-900{--tw-bg-opacity: 1;background-color:rgb(88 28 135 / var(--tw-bg-opacity, 1))}.bg-purple-950{--tw-bg-opacity: 1;background-color:rgb(59 7 100 / var(--tw-bg-opacity, 1))}.bg-red-700{--tw-bg-opacity: 1;background-color:rgb(185 28 28 / var(--tw-bg-opacity, 1))}.bg-red-800{--tw-bg-opacity: 1;background-color:rgb(153 27 27 / var(--tw-bg-opacity, 1))}.bg-red-900{--tw-bg-opacity: 1;background-color:rgb(127 29 29 / var(--tw-bg-opacity, 1))}.bg-red-950{--tw-bg-opacity: 1;background-color:rgb(69 10 10 / var(--tw-bg-opacity, 1))}.bg-stone-700{--tw-bg-opacity: 1;background-color:rgb(68 64 60 / var(--tw-bg-opacity, 1))}.bg-stone-800{--tw-bg-opacity: 1;background-color:rgb(41 37 36 / var(--tw-bg-opacity, 1))}.bg-stone-900{--tw-bg-opacity: 1;background-color:rgb(28 25 23 / var(--tw-bg-opacity, 1))}.bg-stone-950{--tw-bg-opacity: 1;background-color:rgb(12 10 9 / var(--tw-bg-opacity, 1))}.bg-transparent{background-color:transparent}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.bg-yellow-100{--tw-bg-opacity: 1;background-color:rgb(254 249 195 / var(--tw-bg-opacity, 1))}.bg-gradient-to-b{background-image:linear-gradient(to bottom,var(--tw-gradient-stops))}.from-cyan-900{--tw-gradient-from: #164e63 var(--tw-gradient-from-position);--tw-gradient-to: rgb(22 78 99 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-green-900{--tw-gradient-from: #14532d var(--tw-gradient-from-position);--tw-gradient-to: rgb(20 83 45 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-neutral-900{--tw-gradient-from: #171717 var(--tw-gradient-from-position);--tw-gradient-to: rgb(23 23 23 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-orange-900{--tw-gradient-from: #7c2d12 var(--tw-gradient-from-position);--tw-gradient-to: rgb(124 45 18 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-purple-900{--tw-gradient-from: #581c87 var(--tw-gradient-from-position);--tw-gradient-to: rgb(88 28 135 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-red-900{--tw-gradient-from: #7f1d1d var(--tw-gradient-from-position);--tw-gradient-to: rgb(127 29 29 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-stone-900{--tw-gradient-from: #1c1917 var(--tw-gradient-from-position);--tw-gradient-to: rgb(28 25 23 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.to-cyan-700{--tw-gradient-to: #0e7490 var(--tw-gradient-to-position)}.to-green-700{--tw-gradient-to: #15803d var(--tw-gradient-to-position)}.to-neutral-700{--tw-gradient-to: #404040 var(--tw-gradient-to-position)}.to-orange-700{--tw-gradient-to: #c2410c var(--tw-gradient-to-position)}.to-purple-700{--tw-gradient-to: #7e22ce var(--tw-gradient-to-position)}.to-red-700{--tw-gradient-to: #b91c1c var(--tw-gradient-to-position)}.to-stone-700{--tw-gradient-to: #44403c var(--tw-gradient-to-position)}.p-2{padding:.5rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-8{padding-left:2rem;padding-right:2rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-8{padding-top:2rem;padding-bottom:2rem}.text-center{text-align:center}.align-middle{vertical-align:middle}.font-sans{font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji"}.text-3xl{font-size:1.875rem;line-height:2.25rem}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.leading-3{line-height:.75rem}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.text-cyan-600{--tw-text-opacity: 1;color:rgb(8 145 178 / var(--tw-text-opacity, 1))}.text-gray-300{--tw-text-opacity: 1;color:rgb(209 213 219 / var(--tw-text-opacity, 1))}.text-green-600{--tw-text-opacity: 1;color:rgb(22 163 74 / var(--tw-text-opacity, 1))}.text-neutral-600{--tw-text-opacity: 1;color:rgb(82 82 82 / var(--tw-text-opacity, 1))}.text-neutral-800{--tw-text-opacity: 1;color:rgb(38 38 38 / var(--tw-text-opacity, 1))}.text-orange-600{--tw-text-opacity: 1;color:rgb(234 88 12 / var(--tw-text-opacity, 1))}.text-purple-600{--tw-text-opacity: 1;color:rgb(147 51 234 / var(--tw-text-opacity, 1))}.text-red-400{--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.text-red-600{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.text-stone-600{--tw-text-opacity: 1;color:rgb(87 83 78 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.underline{text-decoration-line:underline}.no-underline{text-decoration-line:none}.decoration-2{text-decoration-thickness:2px}.underline-offset-4{text-underline-offset:4px}.opacity-25{opacity:.25}.opacity-75{opacity:.75}.shadow-\\[0_0px_10px_0px_rgba\\(0\\,0\\,0\\,0\\.3\\)\\]{--tw-shadow: 0 0px 10px 0px rgba(0,0,0,.3);--tw-shadow-colored: 0 0px 10px 0px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\\[0_0px_30px_0px_rgba\\(0\\,0\\,0\\,0\\.6\\)\\]{--tw-shadow: 0 0px 30px 0px rgba(0,0,0,.6);--tw-shadow-colored: 0 0px 30px 0px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.outline-none{outline:2px solid transparent;outline-offset:2px}.outline-dashed{outline-style:dashed}.outline-1{outline-width:1px}.outline-offset-4{outline-offset:4px}.outline-cyan-500{outline-color:#06b6d4}.outline-green-500{outline-color:#22c55e}.outline-neutral-500{outline-color:#737373}.outline-orange-500{outline-color:#f97316}.outline-purple-500{outline-color:#a855f7}.outline-red-500{outline-color:#ef4444}.outline-stone-500{outline-color:#78716c}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-200{transition-duration:.2s}.hover\\:bg-cyan-700:hover{--tw-bg-opacity: 1;background-color:rgb(14 116 144 / var(--tw-bg-opacity, 1))}.hover\\:bg-cyan-800:hover{--tw-bg-opacity: 1;background-color:rgb(21 94 117 / var(--tw-bg-opacity, 1))}.hover\\:bg-cyan-900:hover{--tw-bg-opacity: 1;background-color:rgb(22 78 99 / var(--tw-bg-opacity, 1))}.hover\\:bg-cyan-950:hover{--tw-bg-opacity: 1;background-color:rgb(8 51 68 / var(--tw-bg-opacity, 1))}.hover\\:bg-green-700:hover{--tw-bg-opacity: 1;background-color:rgb(21 128 61 / var(--tw-bg-opacity, 1))}.hover\\:bg-green-800:hover{--tw-bg-opacity: 1;background-color:rgb(22 101 52 / var(--tw-bg-opacity, 1))}.hover\\:bg-green-900:hover{--tw-bg-opacity: 1;background-color:rgb(20 83 45 / var(--tw-bg-opacity, 1))}.hover\\:bg-green-950:hover{--tw-bg-opacity: 1;background-color:rgb(5 46 22 / var(--tw-bg-opacity, 1))}.hover\\:bg-neutral-700:hover{--tw-bg-opacity: 1;background-color:rgb(64 64 64 / var(--tw-bg-opacity, 1))}.hover\\:bg-neutral-800:hover{--tw-bg-opacity: 1;background-color:rgb(38 38 38 / var(--tw-bg-opacity, 1))}.hover\\:bg-neutral-900:hover{--tw-bg-opacity: 1;background-color:rgb(23 23 23 / var(--tw-bg-opacity, 1))}.hover\\:bg-neutral-950:hover{--tw-bg-opacity: 1;background-color:rgb(10 10 10 / var(--tw-bg-opacity, 1))}.hover\\:bg-orange-700:hover{--tw-bg-opacity: 1;background-color:rgb(194 65 12 / var(--tw-bg-opacity, 1))}.hover\\:bg-orange-800:hover{--tw-bg-opacity: 1;background-color:rgb(154 52 18 / var(--tw-bg-opacity, 1))}.hover\\:bg-orange-900:hover{--tw-bg-opacity: 1;background-color:rgb(124 45 18 / var(--tw-bg-opacity, 1))}.hover\\:bg-orange-950:hover{--tw-bg-opacity: 1;background-color:rgb(67 20 7 / var(--tw-bg-opacity, 1))}.hover\\:bg-purple-700:hover{--tw-bg-opacity: 1;background-color:rgb(126 34 206 / var(--tw-bg-opacity, 1))}.hover\\:bg-purple-800:hover{--tw-bg-opacity: 1;background-color:rgb(107 33 168 / var(--tw-bg-opacity, 1))}.hover\\:bg-purple-900:hover{--tw-bg-opacity: 1;background-color:rgb(88 28 135 / var(--tw-bg-opacity, 1))}.hover\\:bg-purple-950:hover{--tw-bg-opacity: 1;background-color:rgb(59 7 100 / var(--tw-bg-opacity, 1))}.hover\\:bg-red-700:hover{--tw-bg-opacity: 1;background-color:rgb(185 28 28 / var(--tw-bg-opacity, 1))}.hover\\:bg-red-800:hover{--tw-bg-opacity: 1;background-color:rgb(153 27 27 / var(--tw-bg-opacity, 1))}.hover\\:bg-red-900:hover{--tw-bg-opacity: 1;background-color:rgb(127 29 29 / var(--tw-bg-opacity, 1))}.hover\\:bg-red-950:hover{--tw-bg-opacity: 1;background-color:rgb(69 10 10 / var(--tw-bg-opacity, 1))}.hover\\:bg-stone-700:hover{--tw-bg-opacity: 1;background-color:rgb(68 64 60 / var(--tw-bg-opacity, 1))}.hover\\:bg-stone-800:hover{--tw-bg-opacity: 1;background-color:rgb(41 37 36 / var(--tw-bg-opacity, 1))}.hover\\:bg-stone-900:hover{--tw-bg-opacity: 1;background-color:rgb(28 25 23 / var(--tw-bg-opacity, 1))}.hover\\:bg-stone-950:hover{--tw-bg-opacity: 1;background-color:rgb(12 10 9 / var(--tw-bg-opacity, 1))}.hover\\:text-gray-200:hover{--tw-text-opacity: 1;color:rgb(229 231 235 / var(--tw-text-opacity, 1))}.disabled\\:cursor-default:disabled{cursor:default}.disabled\\:bg-neutral-400:disabled{--tw-bg-opacity: 1;background-color:rgb(163 163 163 / var(--tw-bg-opacity, 1))}.disabled\\:text-neutral-200:disabled{--tw-text-opacity: 1;color:rgb(229 229 229 / var(--tw-text-opacity, 1))}.group:hover .group-hover\\:underline{text-decoration-line:underline}@media (min-width: 640px){.sm\\:w-96{width:24rem}}';const ka=va.attachShadow({mode:"open"});ka.appendChild(Ea),ka.appendChild(xa);const Aa=new class extends rt{constructor(t){super(),nt(this,t,ya,da,d,{accent:0,position:44,startHidden:1,compactMode:2,nostrConnectRelays:45,appMetadata:46,right:3},null,[-1,-1,-1])}}({target:Ea,props:{accent:(null==(t=ma.wnjParams)?void 0:t.accent)||"cyan",position:"bottom"===(null==(e=ma.wnjParams)?void 0:e.position)?"bottom":"top",startHidden:null==(n=ma.wnjParams)?void 0:n.startHidden,compactMode:null==(r=ma.wnjParams)?void 0:r.compactMode,nostrConnectRelays:(null==(o=ma.wnjParams)?void 0:o.nostrConnectRelays)||["wss://bucket.coracle.social","wss://relay.nsec.app","wss://nos.lol","wss://relay.primal.net"],appMetadata:(null==(i=ma.wnjParams)?void 0:i.appMetadata)||{}}});if(null==(s=ma.wnjParams)||!s.disableOverflowFix){const t=document.createElement("style"),e="\n html, body {\n overflow: auto;\n height: 100%;\n }\n ";t.innerHTML=e,document.head.appendChild(t)}}();
//# sourceMappingURL=/sm/f44deaf5a8cfbb0803736fe736f12bf55a752231c8808438368b56e0d752b787.map