From 42fc2d744d5a722bc63ad4ffb43d5249c34656c5 Mon Sep 17 00:00:00 2001 From: HolgerHatGarKeineNode Date: Wed, 28 Jan 2026 20:11:05 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=97=20Update=20`window.nostr.min.js`?= =?UTF-8?q?=20to=20use=20version=200.7.0=20for=20compatibility=20and=20enh?= =?UTF-8?q?ancements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/dist/window.nostr.min.js.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/dist/window.nostr.min.js.js b/public/dist/window.nostr.min.js.js index 1faf690..de994fc 100644 --- a/public/dist/window.nostr.min.js.js +++ b/public/dist/window.nostr.min.js.js @@ -1,8 +1,8 @@ /** * Minified by jsDelivr using Terser v5.39.0. - * Original file: /npm/window.nostr.js@0.5.0/dist/window.nostr.js + * 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 tl=Object.defineProperty,el=(t,e,n)=>e in t?tl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,v=(t,e,n)=>(el(t,"symbol"!=typeof e?e+"":e,n),n);!function(){"use strict";var t,e,n,r,o;function i(){}function s(t){return t()}function a(){return Object.create(null)}function c(t){t.forEach(s)}function l(t){return"function"==typeof t}function u(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}let h;function d(t,e){return t===e||(h||(h=document.createElement("a")),h.href=e,t===h.href)}function f(t,e,n){t.$$.on_destroy.push(function(t,...e){if(null==t){for(const t of e)t(void 0);return i}const n=t.subscribe(...e);return n.unsubscribe?()=>n.unsubscribe():n}(e,n))}const p=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function g(t,e){t.appendChild(e)}function w(t,e,n){t.insertBefore(e,n||null)}function b(t){t.parentNode&&t.parentNode.removeChild(t)}function y(t){return document.createElement(t)}function m(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function x(t){return document.createTextNode(t)}function E(){return x(" ")}function k(){return x("")}function A(t,e,n,r){return t.addEventListener(e,n,r),()=>t.removeEventListener(e,n,r)}function S(t,e,n){null==n?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function $(t,e){e=""+e,t.data!==e&&(t.data=e)}function I(t,e){t.value=e??""}function O(t,e,n){t.classList.toggle(e,!!n)}let B;function T(t){B=t}function U(t){(function(){if(!B)throw new Error("Function called outside component initialization");return B})().$$.on_mount.push(t)}const _=[],L=[];let P=[];const R=[],N=Promise.resolve();let H=!1;function C(t){P.push(t)}const j=new Set;let q=0;function M(){if(0!==q)return;const t=B;do{try{for(;q<_.length;){const t=_[q];q++,T(t),z(t.$$)}}catch(t){throw _.length=0,q=0,t}for(T(null),_.length=0,q=0;L.length;)L.pop()();for(let t=0;t{K.delete(t),r&&(n&&t.d(1),r())})),t.o(e)}else r&&r()}function J(t){t&&t.c()}function Y(t,e,n){const{fragment:r,after_update:o}=t.$$;r&&r.m(e,n),C((()=>{const e=t.$$.on_mount.map(s).filter(l);t.$$.on_destroy?t.$$.on_destroy.push(...e):c(e),t.$$.on_mount=[]})),o.forEach(C)}function G(t,e){const n=t.$$;null!==n.fragment&&(function(t){const e=[],n=[];P.forEach((r=>-1===t.indexOf(r)?e.push(r):n.push(r))),n.forEach((t=>t())),P=e}(n.after_update),c(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function Q(t,e){-1===t.$$.dirty[0]&&(_.push(t),H||(H=!0,N.then(M)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<{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&&Q(t,e)),n})):[],d.update(),f=!0,c(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(b)}else d.fragment&&d.fragment.c();e.intro&&V(t.$$.fragment),Y(t,e.target,e.anchor),M()}T(h)}class tt{constructor(){v(this,"$$"),v(this,"$$set")}$destroy(){G(this,1),this.$destroy=i}$on(t,e){if(!l(e))return i;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)}}typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add("4");var et={exports:{}};function nt(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=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}et.exports.debounce=nt,et.exports=nt;var rt=et.exports;const ot=(st=rt)&&st.__esModule&&Object.prototype.hasOwnProperty.call(st,"default")?st.default:st,it="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */var st;const at=t=>t instanceof Uint8Array,ct=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),lt=(t,e)=>t<<32-e|t>>>e;if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");const ut=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function ht(t){if(!at(t))throw new Error("Uint8Array expected");let e="";for(let n=0;nt+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}let gt=class{clone(){return this._cloneInto()}};function wt(t){const e=e=>t().update(ft(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function bt(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function yt(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 mt(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")}const vt="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,xt=t=>t instanceof Uint8Array,Et=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),kt=(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 At(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)),!xt(t))throw new Error("expected Uint8Array, got "+typeof t);return t}class St{clone(){return this._cloneInto()}}function $t(t=32){if(vt&&"function"==typeof vt.getRandomValues)return vt.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}let It=class extends St{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=Et(this.buffer)}update(t){mt(this);const{view:e,buffer:n,blockLen:r}=this,o=(t=At(t)).length;for(let i=0;ir-i&&(this.process(n,0),i=0);for(let t=i;t>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=Et(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;tt&e^~t&n,Bt=(t,e,n)=>t&e^t&n^e&n,Tt=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]),Ut=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),_t=new Uint32Array(64);let Lt=class extends It{constructor(){super(64,32,8,!1),this.A=0|Ut[0],this.B=0|Ut[1],this.C=0|Ut[2],this.D=0|Ut[3],this.E=0|Ut[4],this.F=0|Ut[5],this.G=0|Ut[6],this.H=0|Ut[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)_t[n]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=_t[t-15],n=_t[t-2],r=kt(e,7)^kt(e,18)^e>>>3,o=kt(n,17)^kt(n,19)^n>>>10;_t[t]=o+_t[t-7]+r+_t[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+(kt(s,6)^kt(s,11)^kt(s,25))+Ot(s,a,c)+Tt[t]+_t[t]|0,u=(kt(n,2)^kt(n,13)^kt(n,22))+Bt(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(){_t.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const Pt=function(t){const e=e=>t().update(At(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}((()=>new Lt)),Rt=BigInt(0),Nt=BigInt(1),Ht=BigInt(2),Ct=t=>t instanceof Uint8Array,jt=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function qt(t){if(!Ct(t))throw new Error("Uint8Array expected");let e="";for(let n=0;nt+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}const Yt=t=>(Ht<new Uint8Array(t),Qt=t=>Uint8Array.from(t);function Xt(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=Gt(t),o=Gt(t),i=0;const s=()=>{r.fill(1),o.fill(0),i=0},a=(...t)=>n(o,r,...t),c=(t=Gt())=>{o=a(Qt([0]),t),r=a(),0!==t.length&&(o=a(Qt([1]),t),r=a())},l=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let t=0;const n=[];for(;t{let n;for(s(),c(t);!(n=e(l()));)c();return s(),n}}const te={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 ee(t,e,n={}){const r=(e,n,r)=>{const o=te[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 ne=Object.freeze(Object.defineProperty({__proto__:null,bitGet:function(t,e){return t>>BigInt(e)&Nt},bitLen:function(t){let e;for(e=0;t>Rt;t>>=Nt,e+=1);return e},bitMask:Yt,bitSet:(t,e,n)=>t|(n?Nt:Rt)<=re?n:e+n}function he(t,e,n){if(n<=re||e 0");if(n===oe)return re;let r=oe;for(;e>re;)e&oe&&(r=r*t%n),t=t*t%n,e>>=oe;return r}function de(t,e,n){let r=t;for(;e-- >re;)r*=r,r%=n;return r}function fe(t,e){if(t===re||e<=re)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=ue(t,e),r=e,o=re,i=oe;for(;n!==re;){const t=r%n,e=o-i*(r/n);r=n,n=t,o=i,i=e}if(r!==oe)throw new Error("invert: does not exist");return ue(o,e)}function pe(t){if(t%ae===se){const e=(t+oe)/ae;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%le===ce){const e=(t-ce)/le;return function(t,n){const r=t.mul(n,ie),o=t.pow(r,e),i=t.mul(n,o),s=t.mul(t.mul(i,ie),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-oe)/ie;let n,r,o;for(n=t-oe,r=0;n%ie===re;n/=ie,r++);for(o=ie;o(t[e]="function",t)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"}))}(t.Fp),ee(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...we(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const{bytesToNumberBE:Ee,hexToBytes:ke}=ne,Ae={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(t){const{Err:e}=Ae;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:Ee(r),l:t.subarray(n+2)}},toSig(t){const{Err:e}=Ae,n="string"==typeof t?ke(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}=Ae._parseInt(n.subarray(2)),{d:s,l:a}=Ae._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}`}},Se=BigInt(0),$e=BigInt(1);BigInt(2);const Ie=BigInt(3);function Oe(t){const e=function(t){const e=xe(t);ee(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 Jt(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&&Sen.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(Zt("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,Ie),{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,Ie);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 x=n.add(s,c);return v=n.mul(v,x),x=n.add(w,y),v=n.sub(v,x),x=n.add(o,i),l=n.add(a,c),x=n.mul(x,l),l=n.add(b,y),x=n.sub(x,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(x,v),l=n.mul(m,l),l=n.sub(l,w),w=n.mul(m,b),f=n.mul(x,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===Se)return r;if(a(t),t===$e)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>Se||l>Se;)s&$e&&(u=u.add(p)),l&$e&&(d=d.add(p)),p=p.double(),s>>=$e,l>>=$e;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!==Se&&e!==$e&&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===$e)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===$e?this:n?n(h,this):this.multiplyUnsafe(e.h)}toRawBytes(t=!0){return this.assertValidity(),r(h,this,t)}toHex(t=!0){return qt(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>me;)n&ve&&(r=r.add(o)),o=o.double(),n>>=ve;return r},precomputeWindow(t,e){const{windows:n,windowSize:o}=r(e),i=[];let s=t,a=s;for(let t=0;t>=d,r>a&&(r-=h,i+=ve);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 Be(t){const e=function(t){const e=xe(t);return ee(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 ue(t,r)}function a(t){return fe(t,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:h}=Oe({...e,toBytes(t,e,r){const o=e.toAffine(),i=n.toBytes(o.x),s=Jt;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=Wt(s);if(!function(t){return Seqt(Ft(t,e.nByteLength));function f(t){return t>r>>$e}const p=(t,e,n)=>Wt(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=Zt("compactSignature",t,2*n),new g(p(t,0,n),p(t,n,2*n))}static fromDER(t){const{r:e,s:n}=Ae.toSig(Zt("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(Zt("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 Kt(this.toDERHex())}toDERHex(){return Ae.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Kt(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=ye(e.n);return function(t,e,n=!1){const r=t.length,o=be(e),i=ye(e);if(r<16||r1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const s=ue(n?Wt(t):Dt(t),e-oe)+oe;return n?Vt(s,o):Ft(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=Wt(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=Yt(e.nBitLength);function x(t){if("bigint"!=typeof t)throw new Error("bigint expected");if(!(Se<=t&&tt 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=Zt("msgHash",t),p&&(t=Zt("prehashed msgHash",i(t)));const b=m(t),v=l(r),E=[x(v),x(b)];if(null!=w){const t=!0===w?u(n.BYTES):w;E.push(Zt("extraEntropy",t))}const A=Jt(...E),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===Se)return;const i=s(n*s(S+o*v));if(i===Se)return;let l=(r.x===o?0:2)|Number(r.y&$e),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}=E(t,n,r),s=e;return Xt(s.hash.outputLen,s.nByteLength,s.hmac)(o,i)},verify:function(t,n,r,o=A){var i;const l=t;if(n=Zt("msgHash",n),r=Zt("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 Ae.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),x=s(p*y),E=null==(i=c.BASE.multiplyAndAddUnsafe(f,v,x))?void 0:i.toAffine();return!!E&&s(E.x)===p},ProjectivePoint:c,Signature:g,utils:w}}BigInt(4);let Te=class extends St{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");bt(t.outputLen),bt(t.blockLen)}(t);const n=At(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;tnew Te(t,e).update(n).digest();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function _e(t){return{hash:t,hmac:(e,...n)=>Ue(t,e,function(...t){const e=new Uint8Array(t.reduce(((t,e)=>t+e.length),0));let n=0;return t.forEach((t=>{if(!xt(t))throw new Error("Uint8Array expected");e.set(t,n),n+=t.length})),e}(...n)),randomBytes:$t}}Ue.create=(t,e)=>new Te(t,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Le=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Pe=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Re=BigInt(1),Ne=BigInt(2),He=(t,e)=>(t+e/Ne)/e;function Ce(t){const e=Le,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=de(u,n,e)*u%e,d=de(h,n,e)*u%e,f=de(d,Ne,e)*l%e,p=de(f,o,e)*f%e,g=de(p,i,e)*p%e,w=de(g,a,e)*g%e,b=de(w,c,e)*w%e,y=de(b,a,e)*g%e,m=de(y,n,e)*u%e,v=de(m,s,e)*p%e,x=de(v,r,e)*l%e,E=de(x,Ne,e);if(!je.eql(je.sqr(E),t))throw new Error("Cannot find square root");return E}const je=function(t,e,n=!1,r={}){if(t<=re)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:o,nByteLength:i}=we(t,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=pe(t),a=Object.freeze({ORDER:t,BITS:o,BYTES:i,MASK:Yt(o),ZERO:re,ONE:oe,create:e=>ue(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("Invalid field element: expected bigint, got "+typeof e);return re<=e&&et===re,isOdd:t=>(t&oe)===oe,neg:e=>ue(-e,t),eql:(t,e)=>t===e,sqr:e=>ue(e*e,t),add:(e,n)=>ue(e+n,t),sub:(e,n)=>ue(e-n,t),mul:(e,n)=>ue(e*n,t),pow:(t,e)=>function(t,e,n){if(n 0");if(n===re)return t.ONE;if(n===oe)return e;let r=t.ONE,o=e;for(;n>re;)n&oe&&(r=t.mul(r,o)),o=t.sqr(o),n>>=oe;return r}(a,t,e),div:(e,n)=>ue(e*fe(n,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>fe(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?Vt(t,i):Ft(t,i),fromBytes:t=>{if(t.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${t.length}`);return n?Dt(t):Wt(t)}});return Object.freeze(a)}(Le,void 0,void 0,{sqrt:Ce}),qe=function(t,e){const n=e=>Be({...t,..._e(e)});return Object.freeze({...n(e),create:n})}({a:BigInt(0),b:BigInt(7),Fp:je,n:Pe,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=Pe,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Re*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,s=BigInt("0x100000000000000000000000000000000"),a=He(i*t,e),c=He(-r*t,e);let l=ue(t-a*n-c*o,e),u=ue(-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}}}},Pt),Me=BigInt(0),ze=t=>"bigint"==typeof t&&Met.charCodeAt(0))));n=Jt(e,e),Ke[t]=n}return Pt(Jt(n,...e))}const De=t=>t.toRawBytes(!0).slice(1),Fe=t=>Ft(t,32),Ve=t=>ue(t,Le),Ze=t=>ue(t,Pe),Je=qe.ProjectivePoint;function Ye(t){let e=qe.utils.normPrivateKeyToScalar(t),n=Je.fromPrivateKey(e);return{scalar:n.hasEvenY()?e:Ze(-e),bytes:De(n)}}function Ge(t){if(!ze(t))throw new Error("bad x: need 0 < x < p");const e=Ve(t*t);let n=Ce(Ve(e*t+BigInt(7)));n%Ne!==Me&&(n=Ve(-n));const r=new Je(t,n,Re);return r.assertValidity(),r}function Qe(...t){return Ze(Wt(We("BIP0340/challenge",...t)))}function Xe(t,e,n){const r=Zt("signature",t,64),o=Zt("message",e),i=Zt("publicKey",n,32);try{const t=Ge(Wt(i)),e=Wt(r.subarray(0,32));if(!ze(e))return!1;const n=Wt(r.subarray(32,64));if(!(t=>"bigint"==typeof t&&MeJe.BASE.multiplyAndAddUnsafe(t,e,n))(t,n,Ze(-s));return!(!a||!a.hasEvenY()||a.toAffine().x!==e)}catch{return!1}}const tn={getPublicKey:function(t){return Ye(t).bytes},sign:function(t,e,n=$t(32)){const r=Zt("message",t),{bytes:o,scalar:i}=Ye(e),s=Zt("auxRand",n,32),a=Fe(i^Wt(We("BIP0340/aux",s))),c=We("BIP0340/nonce",a,o,r),l=Ze(Wt(c));if(l===Me)throw new Error("sign failed: k is zero");const{bytes:u,scalar:h}=Ye(l),d=Qe(u,o,r),f=new Uint8Array(64);if(f.set(u,0),f.set(Fe(Ze(h+d*i)),32),!Xe(f,r,o))throw new Error("sign: Invalid signature produced");return f},verify:Xe,utils:{randomPrivateKey:qe.utils.randomPrivateKey,lift_x:Ge,pointToBytes:De,numberToBytesBE:Ft,bytesToNumberBE:Wt,taggedHash:We,mod:ue}};function en(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function nn(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 rn={number:en,bool:function(t){if("boolean"!=typeof t)throw new Error(`Expected boolean, not ${t}`)},bytes:nn,hash:function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");en(t.outputLen),en(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){nn(t);const n=e.outputLen;if(t.lengthr-i&&(this.process(n,0),i=0);for(let t=i;t>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=ct(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;tt&e^~t&n,an=(t,e,n)=>t&e^t&n^e&n,cn=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]),ln=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),un=new Uint32Array(64);class hn extends on{constructor(){super(64,32,8,!1),this.A=0|ln[0],this.B=0|ln[1],this.C=0|ln[2],this.D=0|ln[3],this.E=0|ln[4],this.F=0|ln[5],this.G=0|ln[6],this.H=0|ln[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)un[n]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=un[t-15],n=un[t-2],r=lt(e,7)^lt(e,18)^e>>>3,o=lt(n,17)^lt(n,19)^n>>>10;un[t]=o+un[t-7]+r+un[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+(lt(s,6)^lt(s,11)^lt(s,25))+sn(s,a,c)+cn[t]+un[t]|0,u=(lt(n,2)^lt(n,13)^lt(n,22))+an(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(){un.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class dn extends hn{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 fn=wt((()=>new hn));wt((()=>new dn));var pn=Symbol("verified");function gn(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;et 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;et===n.slice(1)&&-1!==r.indexOf(e))))return!1}return!(t.since&&e.created_att.until)}async function Un(){return new Promise((t=>{const e=new MessageChannel,n=()=>{e.port1.removeEventListener("message",n),t()};e.port1.addEventListener("message",n),e.port2.postMessage(0),e.port1.start()}))}var _n,Ln=t=>(t[xn]=!0,!0),Pn=class{constructor(t,e){v(this,"url"),v(this,"_connected",!1),v(this,"onclose",null),v(this,"onnotice",(t=>console.debug(`NOTICE from ${this.url}: ${t}`))),v(this,"_onauth",null),v(this,"baseEoseTimeout",4400),v(this,"connectionTimeout",4400),v(this,"publishTimeout",4400),v(this,"openSubs",new Map),v(this,"connectionTimeoutHandle"),v(this,"connectionPromise"),v(this,"openCountRequests",new Map),v(this,"openEventPublishes",new Map),v(this,"ws"),v(this,"incomingMessageQueue",new $n),v(this,"queueRunning",!1),v(this,"challenge"),v(this,"serial",0),v(this,"verifyEvent"),v(this,"_WebSocket"),this.url=An(t),this.verifyEvent=e.verifyEvent,this._WebSocket=e.websocketImplementation||WebSocket}static async connect(t,e){const n=new Pn(t,e);return await n.connect(),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 connect(){return this.connectionPromise||(this.challenge=void 0,this.connectionPromise=new Promise(((t,e)=>{this.connectionTimeoutHandle=setTimeout((()=>{var t;e("connection timed out"),this.connectionPromise=void 0,null==(t=this.onclose)||t.call(this),this.closeAllSubscriptions("relay connection timed out")}),this.connectionTimeout);try{this.ws=new this._WebSocket(this.url)}catch(t){return void e(t)}this.ws.onopen=()=>{clearTimeout(this.connectionTimeoutHandle),this._connected=!0,t()},this.ws.onerror=t=>{var n;e(t.message||"websocket error"),this._connected&&(this._connected=!1,this.connectionPromise=void 0,null==(n=this.onclose)||n.call(this),this.closeAllSubscriptions("relay connection errored"))},this.ws.onclose=async()=>{var t;this._connected&&(this._connected=!1,this.connectionPromise=void 0,null==(t=this.onclose)||t.call(this),this.closeAllSubscriptions("relay connection closed"))},this.ws.onmessage=this._onmessage.bind(this)}))),this.connectionPromise}async runQueue(){for(this.queueRunning=!0;!1!==this.handleNext();)await Un();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 void(this.verifyEvent(n)&&function(t,e){for(let n=0;n{var e;null==(e=this.ws)||e.send(t)}))}async auth(t){if(!this.challenge)throw new Error("can't perform auth, no challenge was received");const e=await t(function(t,e){return{kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t],["challenge",e]],content:""}}(this.url,this.challenge)),n=new Promise(((t,n)=>{const r=setTimeout((()=>{const t=this.openEventPublishes.get(e.id);t&&(t.reject(new Error("auth timed out")),this.openEventPublishes.delete(e.id))}),this.publishTimeout);this.openEventPublishes.set(e.id,{resolve:t,reject:n,timeout:r})}));return this.send('["AUTH",'+JSON.stringify(e)+"]"),n}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(),n}prepareSubscription(t,e){this.serial++;const n=e.id||(e.label?e.label+":":"sub:")+this.serial,r=new Rn(this,n,t,e);return this.openSubs.set(n,r),r}close(){var t;this.closeAllSubscriptions("relay connection closed by us"),this._connected=!1,null==(t=this.ws)||t.close()}_onmessage(t){this.incomingMessageQueue.enqueue(t.data),this.queueRunning||this.runQueue()}},Rn=class{constructor(t,e,n,r){v(this,"relay"),v(this,"id"),v(this,"closed",!1),v(this,"eosed",!1),v(this,"filters"),v(this,"alreadyHaveEvent"),v(this,"receivedEvent"),v(this,"onevent"),v(this,"oneose"),v(this,"onclose"),v(this,"eoseTimeout"),v(this,"eoseTimeoutHandle"),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;!this.closed&&this.relay.connected&&(this.relay.send('["CLOSE",'+JSON.stringify(this.id)+"]"),this.closed=!0),this.relay.openSubs.delete(this.id),null==(e=this.onclose)||e.call(this,t)}},Nn=class{constructor(t){v(this,"relays",new Map),v(this,"seenOn",new Map),v(this,"trackRelays",!1),v(this,"verifyEvent"),v(this,"trustedRelayURLs",new Set),v(this,"_WebSocket"),this.verifyEvent=t.verifyEvent,this._WebSocket=t.websocketImplementation}async ensureRelay(t,e){t=An(t);let n=this.relays.get(t);return n||(n=new Pn(t,{verifyEvent:this.trustedRelayURLs.has(t)?Ln:this.verifyEvent,websocketImplementation:this._WebSocket}),null!=e&&e.connectionTimeout&&(n.connectionTimeout=e.connectionTimeout),this.relays.set(t,n)),await n.connect(),n}close(t){t.map(An).forEach((t=>{var e;null==(e=this.relays.get(t))||e.close()}))}subscribeMany(t,e,n){return this.subscribeManyMap(Object.fromEntries(t.map((t=>[t,e]))),n)}subscribeManyMap(t,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 n=new Set,r=[],o=Object.keys(t).length,i=[];let s=t=>{var n;i[t]||(i[t]=!0,i.filter((t=>t)).length===o&&(null==(n=e.oneose)||n.call(e),s=()=>{}))};const a=[];let c=(t,n)=>{var r;a[t]||(s(t),a[t]=n,a.filter((t=>t)).length===o&&(null==(r=e.onclose)||r.call(e,a),c=()=>{}))};const l=t=>{var r;if(null!=(r=e.alreadyHaveEvent)&&r.call(e,t))return!0;const o=n.has(t);return n.add(t),o},u=Promise.all(Object.entries(t).map((async(t,n,o)=>{if(o.indexOf(t)!==n)return void c(n,"duplicate url");let i,[a,u]=t;a=An(a);try{i=await this.ensureRelay(a,{connectionTimeout:e.maxWait?Math.max(.8*e.maxWait,e.maxWait-1e3):void 0})}catch(t){return void c(n,(null==t?void 0:t.message)||String(t))}let h=i.subscribe(u,{...e,oneose:()=>s(n),onclose:t=>c(n,t),alreadyHaveEvent:l,eoseTimeout:e.maxWait});r.push(h)})));return{async close(){await u,r.forEach((t=>{t.close()}))}}}subscribeManyEose(t,e,n){const r=this.subscribeMany(t,e,{...n,oneose(){r.close()}});return r}async querySync(t,e,n){return new Promise((async r=>{const o=[];this.subscribeManyEose(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){return t.map(An).map((async(t,n,r)=>{if(r.indexOf(t)!==n)return Promise.reject("duplicate url");let o=await this.ensureRelay(t);return o.publish(e).then((t=>{if(this.trackRelays){let t=this.seenOn.get(e.id);t||(t=new Set,this.seenOn.set(e.id,t)),t.add(o)}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}};try{_n=WebSocket}catch{}var Hn=class extends Nn{constructor(){super({verifyEvent:Bn,websocketImplementation:_n})}};function Cn(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function jn(t){if("boolean"!=typeof t)throw new Error(`boolean expected, not ${t}`)}function qn(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name}function Mn(t,...e){if(!qn(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}`)}function zn(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Kn(t,e){Mn(t);const n=e.outputLen;if(t.lengthnew 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");function Dn(t){if("string"!=typeof t)throw new Error("string expected, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}function Fn(t){if("string"==typeof t)t=Dn(t);else{if(!qn(t))throw new Error("Uint8Array expected, got "+typeof t);t=t.slice()}return t}const Vn=16,Zn=new Uint8Array(16),Jn=Wn(Zn),Yn=(t,e,n,r)=>({s3:n<<31|r>>>1,s2:e<<31|n>>>1,s1:t<<31|e>>>1,s0:t>>>1^225<<24&-(1&(1&r))}),Gn=t=>(t>>>0&255)<<24|(t>>>8&255)<<16|(t>>>16&255)<<8|t>>>24&255;class Qn{constructor(t,e){this.blockLen=Vn,this.outputLen=Vn,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,Mn(t=Fn(t),16);const n=(t=>new DataView(t.buffer,t.byteOffset,t.byteLength))(t);let r=n.getUint32(0,!1),o=n.getUint32(4,!1),i=n.getUint32(8,!1),s=n.getUint32(12,!1);const a=[];for(let t=0;t<128;t++)a.push({s0:Gn(r),s1:Gn(o),s2:Gn(i),s3:Gn(s)}),({s0:r,s1:o,s2:i,s3:s}=Yn(r,o,i,s));const c=(t=>t>65536?8:t>1024?4:2)(e||1024);if(![1,2,4,8].includes(c))throw new Error(`ghash: wrong window size=${c}, should be 2, 4 or 8`);this.W=c;const l=128/c,u=this.windowSize=2**c,h=[];for(let t=0;t>>c-s-1&1))continue;const{s0:l,s1:u,s2:h,s3:d}=a[c*t+s];n^=l,r^=u,o^=h,i^=d}h.push({s0:n,s1:r,s2:o,s3:i})}this.t=h}_updateBlock(t,e,n,r){t^=this.s0,e^=this.s1,n^=this.s2,r^=this.s3;const{W:o,t:i,windowSize:s}=this;let a=0,c=0,l=0,u=0;const h=(1<>>8*t&255;for(let t=8/o-1;t>=0;t--){const n=e>>>o*t&h,{s0:r,s1:f,s2:p,s3:g}=i[d*s+n];a^=r,c^=f,l^=p,u^=g,d+=1}}this.s0=a,this.s1=c,this.s2=l,this.s3=u}update(t){t=Fn(t),zn(this);const e=Wn(t),n=Math.floor(t.length/Vn),r=t.length%Vn;for(let t=0;t>>1|n,n=(1&r)<<7}return t[0]^=225&-e,t}((t=Fn(t)).slice());super(n,e),n.fill(0)}update(t){t=Fn(t),zn(this);const e=Wn(t),n=t.length%Vn,r=Math.floor(t.length/Vn);for(let t=0;tt(n,e.length).update(Fn(e)).digest(),n=t(new Uint8Array(16),0);return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=(e,n)=>t(e,n),e}tr(((t,e)=>new Qn(t,e))),tr(((t,e)=>new Xn(t,e)));const er=16;function nr(t){return t<<1^283&-(t>>7)}function rr(t,e){let n=0;for(;e>0;e>>=1)n^=t&-(1&e),t=nr(t);return n}const or=(()=>{let t=new Uint8Array(256);for(let e=0,n=1;e<256;e++,n^=nr(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})(),ir=or.map(((t,e)=>or.indexOf(e))),sr=t=>t<<24|t>>>8,ar=t=>t<<8|t>>>24;function cr(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(ar),o=r.map(ar),i=o.map(ar),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 lr=cr(or,(t=>rr(t,3)<<24|t<<16|t<<8|rr(t,2))),ur=cr(ir,(t=>rr(t,11)<<24|rr(t,13)<<16|rr(t,9)<<8|rr(t,14))),hr=(()=>{const t=new Uint8Array(16);for(let e=0,n=1;e<16;e++,n=nr(n))t[e]=n;return t})();function dr(t){Mn(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}=lr,r=Wn(t),o=r.length,i=t=>pr(n,t,t,t,t),s=new Uint32Array(e+28);s.set(r);for(let t=o;t6&&t%o==4&&(e=i(e)),s[t]=s[t-o]^e}return s}function fr(t,e,n,r,o,i){return t[n<<8&65280|r>>>8&255]^e[o>>>8&65280|i>>>24&255]}function pr(t,e,n,r,o){return t[255&e|65280&n]|t[r>>>16&255|o>>>16&65280]<<16}function gr(t,e,n,r,o){const{sbox2:i,T01:s,T23:a}=lr;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(Object.assign(e,t),e))({blockSize:16,nonceLength:16},(function(t,e,n={}){Mn(t),Mn(e,16);const r=!n.disablePadding;return{encrypt:(n,o)=>{const i=dr(t),{b:s,o:a,out:c}=function(t,e,n){let r=t.length;const o=r%er;if(!e&&0!==o)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");const i=Wn(t);if(e){let t=er-o;t||(t=er),r+=t}const s=br(r,n);return{b:i,o:Wn(s),out:s}}(n,r,o),l=Wn(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}=gr(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=Wn(e);e.set(t);const r=er-t.length;for(let t=er-r;t{!function(t){if(Mn(t),t.length%er!=0)throw new Error("aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size 16")}(n);const i=function(t){const e=dr(t),n=e.slice(),r=e.length,{sbox2:o}=lr,{T0:i,T1:s,T2:a,T3:c}=ur;for(let t=0;t>>8&255]^a[r>>>16&255]^c[r>>>24]}return n}(t),s=Wn(e),a=br(n.length,o),c=Wn(n),l=Wn(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}=wr(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;en=>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 xr(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(mr(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 Er(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 kr(t,e="="){if(mr(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 Ar(t){if("function"!=typeof t)throw new Error("normalize fn should be function");return{encode:t=>t,decode:e=>t(e)}}function Sr(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(mr(t),t<0||t>=e)throw new Error(`Wrong integer: ${t}`)}));;){let t=0,s=!0;for(let o=r;oe?$r(e,t%e):t,Ir=(t,e)=>t+(e-$r(t,e));function Or(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(Ir(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${Ir(e,n)}`);let o=0,i=0;const s=2**n-1,a=[];for(const r of t){if(mr(r),r>=2**e)throw new Error(`convertRadix2: invalid data word=${r} from=${e}`);if(o=o<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<=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 Br(t,e=!1){if(mr(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(Ir(8,t)>32||Ir(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 Or(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(Or(n,t,8,e))}}}function Tr(t){if("function"!=typeof t)throw new Error("unsafeWrapper fn should be function");return function(...e){try{return t.apply(null,e)}catch{}}}const Ur=vr(Br(4),xr("0123456789ABCDEF"),Er("")),_r=vr(Br(5),xr("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),kr(5),Er(""));vr(Br(5),xr("0123456789ABCDEFGHIJKLMNOPQRSTUV"),kr(5),Er("")),vr(Br(5),xr("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),Er(""),Ar((t=>t.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))));const Lr=vr(Br(6),xr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),kr(6),Er("")),Pr=vr(Br(6),xr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),kr(6),Er("")),Rr=t=>vr(function(t){return mr(t),{encode:e=>{if(!(e instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return Sr(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(Sr(e,t,256))}}}(58),xr(t),Er("")),Nr=Rr("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");Rr("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),Rr("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const Hr=[0,2,3,5,6,7,9,10,11],Cr={encode(t){let e="";for(let n=0;n>25;let n=(33554431&t)<<5;for(let t=0;t>t&1)&&(n^=qr[t]);return n}function zr(t,e,n=1){const r=t.length;let o=1;for(let e=0;e126)throw new Error(`Invalid prefix (${t})`);o=Mr(o)^n>>5}o=Mr(o);for(let e=0;en)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=jr.decode(s).slice(0,-6),c=zr(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${jr.encode(n)}${zr(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:Tr(s),fromWords:r,fromWordsUnsafe:i,toWords:o}}const Wr=Kr("bech32");Kr("bech32m");const Dr={encode:t=>(new TextDecoder).decode(t),decode:t=>(new TextEncoder).encode(t)},Fr=vr(Br(4),xr("0123456789abcdef"),Er(""),Ar((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:Dr,hex:Fr,base16:Ur,base32:_r,base64:Lr,base64url:Pr,base58:Nr,base58xmr:Cr}).join(", ");const Vr=(t,e)=>255&t[e++]|(255&t[e++])<<8;class Zr{constructor(t){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,Mn(t=Fn(t),32);const e=Vr(t,0),n=Vr(t,2),r=Vr(t,4),o=Vr(t,6),i=Vr(t,8),s=Vr(t,10),a=Vr(t,12),c=Vr(t,14);this.r[0]=8191&e,this.r[1]=8191&(e>>>13|n<<3),this.r[2]=7939&(n>>>10|r<<6),this.r[3]=8191&(r>>>7|o<<9),this.r[4]=255&(o>>>4|i<<12),this.r[5]=i>>>1&8190,this.r[6]=8191&(i>>>14|s<<2),this.r[7]=8065&(s>>>11|a<<5),this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127;for(let e=0;e<8;e++)this.pad[e]=Vr(t,16+2*e)}process(t,e,n=!1){const r=n?0:2048,{h:o,r:i}=this,s=i[0],a=i[1],c=i[2],l=i[3],u=i[4],h=i[5],d=i[6],f=i[7],p=i[8],g=i[9],w=Vr(t,e+0),b=Vr(t,e+2),y=Vr(t,e+4),m=Vr(t,e+6),v=Vr(t,e+8),x=Vr(t,e+10),E=Vr(t,e+12),k=Vr(t,e+14);let A=o[0]+(8191&w),S=o[1]+(8191&(w>>>13|b<<3)),$=o[2]+(8191&(b>>>10|y<<6)),I=o[3]+(8191&(y>>>7|m<<9)),O=o[4]+(8191&(m>>>4|v<<12)),B=o[5]+(v>>>1&8191),T=o[6]+(8191&(v>>>14|x<<2)),U=o[7]+(8191&(x>>>11|E<<5)),_=o[8]+(8191&(E>>>8|k<<8)),L=o[9]+(k>>>5|r),P=0,R=P+A*s+S*(5*g)+$*(5*p)+I*(5*f)+O*(5*d);P=R>>>13,R&=8191,R+=B*(5*h)+T*(5*u)+U*(5*l)+_*(5*c)+L*(5*a),P+=R>>>13,R&=8191;let N=P+A*a+S*s+$*(5*g)+I*(5*p)+O*(5*f);P=N>>>13,N&=8191,N+=B*(5*d)+T*(5*h)+U*(5*u)+_*(5*l)+L*(5*c),P+=N>>>13,N&=8191;let H=P+A*c+S*a+$*s+I*(5*g)+O*(5*p);P=H>>>13,H&=8191,H+=B*(5*f)+T*(5*d)+U*(5*h)+_*(5*u)+L*(5*l),P+=H>>>13,H&=8191;let C=P+A*l+S*c+$*a+I*s+O*(5*g);P=C>>>13,C&=8191,C+=B*(5*p)+T*(5*f)+U*(5*d)+_*(5*h)+L*(5*u),P+=C>>>13,C&=8191;let j=P+A*u+S*l+$*c+I*a+O*s;P=j>>>13,j&=8191,j+=B*(5*g)+T*(5*p)+U*(5*f)+_*(5*d)+L*(5*h),P+=j>>>13,j&=8191;let q=P+A*h+S*u+$*l+I*c+O*a;P=q>>>13,q&=8191,q+=B*s+T*(5*g)+U*(5*p)+_*(5*f)+L*(5*d),P+=q>>>13,q&=8191;let M=P+A*d+S*h+$*u+I*l+O*c;P=M>>>13,M&=8191,M+=B*a+T*s+U*(5*g)+_*(5*p)+L*(5*f),P+=M>>>13,M&=8191;let z=P+A*f+S*d+$*h+I*u+O*l;P=z>>>13,z&=8191,z+=B*c+T*a+U*s+_*(5*g)+L*(5*p),P+=z>>>13,z&=8191;let K=P+A*p+S*f+$*d+I*h+O*u;P=K>>>13,K&=8191,K+=B*l+T*c+U*a+_*s+L*(5*g),P+=K>>>13,K&=8191;let W=P+A*g+S*p+$*f+I*d+O*h;P=W>>>13,W&=8191,W+=B*u+T*l+U*c+_*a+L*s,P+=W>>>13,W&=8191,P=(P<<2)+P|0,P=P+R|0,R=8191&P,P>>>=13,N+=P,o[0]=R,o[1]=N,o[2]=H,o[3]=C,o[4]=j,o[5]=q,o[6]=M,o[7]=z,o[8]=K,o[9]=W}finalize(){const{h:t,pad:e}=this,n=new Uint16Array(10);let r=t[1]>>>13;t[1]&=8191;for(let e=2;e<10;e++)t[e]+=r,r=t[e]>>>13,t[e]&=8191;t[0]+=5*r,r=t[0]>>>13,t[0]&=8191,t[1]+=r,r=t[1]>>>13,t[1]&=8191,t[2]+=r,n[0]=t[0]+5,r=n[0]>>>13,n[0]&=8191;for(let e=1;e<10;e++)n[e]=t[e]+r,r=n[e]>>>13,n[e]&=8191;n[9]-=8192;let o=(1^r)-1;for(let t=0;t<10;t++)n[t]&=o;o=~o;for(let e=0;e<10;e++)t[e]=t[e]&o|n[e];t[0]=65535&(t[0]|t[1]<<13),t[1]=65535&(t[1]>>>3|t[2]<<10),t[2]=65535&(t[2]>>>6|t[3]<<7),t[3]=65535&(t[3]>>>9|t[4]<<4),t[4]=65535&(t[4]>>>12|t[5]<<1|t[6]<<14),t[5]=65535&(t[6]>>>2|t[7]<<11),t[6]=65535&(t[7]>>>5|t[8]<<8),t[7]=65535&(t[8]>>>8|t[9]<<5);let i=t[0]+e[0];t[0]=65535&i;for(let n=1;n<8;n++)i=(t[n]+e[n]|0)+(i>>>16)|0,t[n]=65535&i}update(t){zn(this);const{buffer:e,blockLen:n}=this,r=(t=Fn(t)).length;for(let o=0;o>>0,t[o++]=n[e]>>>8;return t}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}}!function(t){const e=(e,n)=>t(n).update(Fn(e)).digest(),n=t(new Uint8Array(32));e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=e=>t(e)}((t=>new Zr(t)));const Jr=Dn("expand 16-byte k"),Yr=Dn("expand 32-byte k"),Gr=Wn(Jr),Qr=Wn(Yr);function Xr(t,e){return t<>>32-e}function to(t){return t.byteOffset%4==0}const eo=2**32-1,no=new Uint32Array;const ro=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 Cn(o),Cn(s),jn(i),jn(n),(e,a,c,l,u=0)=>{Mn(e),Mn(a),Mn(c);const h=c.length;if(l||(l=new Uint8Array(h)),Mn(l),Cn(u),u<0||u>=eo)throw new Error("arx: counter overflow");if(l.length=eo)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;e0;)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],x=n[2],E=s,k=a,A=c,S=l,$=u,I=h,O=d,B=f,T=p,U=g,_=w,L=b,P=y,R=m,N=v,H=x;for(let t=0;tr?t.create().update(n).digest():n);for(let t=0;tnew oo(t,e).update(n).digest();io.create=(t,e)=>new oo(t,e);const so=new Uint8Array([0]),ao=new Uint8Array;var co=Symbol("verified");function lo(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;e255*t.outputLen)throw new Error("Length should be <= 255*HashLen");const o=Math.ceil(r/t.outputLen);void 0===n&&(n=ao);const i=new Uint8Array(o*t.outputLen),s=io.create(t,e),a=s._cloneInto(),c=new Uint8Array(s.outputLen);for(let e=0;e65535)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 pt(r,e,new Uint8Array(ko(n)-n))}function So(t,e,n){if(32!==n.length)throw new Error("AAD associated data must be 32 bytes");const r=pt(n,e);return io(fn,t,r)}function $o(t,e,n=function(t=32){if(it&&"function"==typeof it.getRandomValues)return it.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}(32)){const{chacha_key:r,chacha_nonce:o,hmac_key:i}=Eo(e,n),s=Ao(t),a=ro(r,o,s),c=So(i,a,n);return Lr.encode(pt(new Uint8Array([2]),n,a,c))}function Io(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=Lr.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}=Eo(e,n);if(!function(t,e){if(t.length!==e.length)return!1;let n=0;for(let r=0;r65535||n.length!==e||t.length!==2+ko(e))throw new Error("invalid padding");return uo.decode(n)}(ro(i,s,r))}var Oo=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/;try{fetch}catch{}function Bo(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_att.until)}async function To(){return new Promise((t=>{const e=new MessageChannel,n=()=>{e.port1.removeEventListener("message",n),t()};e.port1.addEventListener("message",n),e.port2.postMessage(0),e.port1.start()}))}var Uo,_o=t=>(t[co]=!0,!0),Lo=class{constructor(t,e){v(this,"url"),v(this,"_connected",!1),v(this,"onclose",null),v(this,"onnotice",(t=>console.debug(`NOTICE from ${this.url}: ${t}`))),v(this,"_onauth",null),v(this,"baseEoseTimeout",4400),v(this,"connectionTimeout",4400),v(this,"publishTimeout",4400),v(this,"openSubs",new Map),v(this,"connectionTimeoutHandle"),v(this,"connectionPromise"),v(this,"openCountRequests",new Map),v(this,"openEventPublishes",new Map),v(this,"ws"),v(this,"incomingMessageQueue",new go),v(this,"queueRunning",!1),v(this,"challenge"),v(this,"serial",0),v(this,"verifyEvent"),v(this,"_WebSocket"),this.url=fo(t),this.verifyEvent=e.verifyEvent,this._WebSocket=e.websocketImplementation||WebSocket}static async connect(t,e){const n=new Lo(t,e);return await n.connect(),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 connect(){return this.connectionPromise||(this.challenge=void 0,this.connectionPromise=new Promise(((t,e)=>{this.connectionTimeoutHandle=setTimeout((()=>{var t;e("connection timed out"),this.connectionPromise=void 0,null==(t=this.onclose)||t.call(this),this.closeAllSubscriptions("relay connection timed out")}),this.connectionTimeout);try{this.ws=new this._WebSocket(this.url)}catch(t){return void e(t)}this.ws.onopen=()=>{clearTimeout(this.connectionTimeoutHandle),this._connected=!0,t()},this.ws.onerror=t=>{var n;e(t.message||"websocket error"),this._connected&&(this._connected=!1,this.connectionPromise=void 0,null==(n=this.onclose)||n.call(this),this.closeAllSubscriptions("relay connection errored"))},this.ws.onclose=async()=>{var t;this._connected&&(this._connected=!1,this.connectionPromise=void 0,null==(t=this.onclose)||t.call(this),this.closeAllSubscriptions("relay connection closed"))},this.ws.onmessage=this._onmessage.bind(this)}))),this.connectionPromise}async runQueue(){for(this.queueRunning=!0;!1!==this.handleNext();)await To();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 void(this.verifyEvent(n)&&function(t,e){for(let n=0;n{var e;null==(e=this.ws)||e.send(t)}))}async auth(t){if(!this.challenge)throw new Error("can't perform auth, no challenge was received");const e=await t(function(t,e){return{kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t],["challenge",e]],content:""}}(this.url,this.challenge)),n=new Promise(((t,n)=>{const r=setTimeout((()=>{const t=this.openEventPublishes.get(e.id);t&&(t.reject(new Error("auth timed out")),this.openEventPublishes.delete(e.id))}),this.publishTimeout);this.openEventPublishes.set(e.id,{resolve:t,reject:n,timeout:r})}));return this.send('["AUTH",'+JSON.stringify(e)+"]"),n}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(),n}prepareSubscription(t,e){this.serial++;const n=e.id||(e.label?e.label+":":"sub:")+this.serial,r=new Po(this,n,t,e);return this.openSubs.set(n,r),r}close(){var t;this.closeAllSubscriptions("relay connection closed by us"),this._connected=!1,null==(t=this.ws)||t.close()}_onmessage(t){this.incomingMessageQueue.enqueue(t.data),this.queueRunning||this.runQueue()}},Po=class{constructor(t,e,n,r){v(this,"relay"),v(this,"id"),v(this,"closed",!1),v(this,"eosed",!1),v(this,"filters"),v(this,"alreadyHaveEvent"),v(this,"receivedEvent"),v(this,"onevent"),v(this,"oneose"),v(this,"onclose"),v(this,"eoseTimeout"),v(this,"eoseTimeoutHandle"),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;!this.closed&&this.relay.connected&&(this.relay.send('["CLOSE",'+JSON.stringify(this.id)+"]"),this.closed=!0),this.relay.openSubs.delete(this.id),null==(e=this.onclose)||e.call(this,t)}},Ro=class{constructor(t){v(this,"relays",new Map),v(this,"seenOn",new Map),v(this,"trackRelays",!1),v(this,"verifyEvent"),v(this,"trustedRelayURLs",new Set),v(this,"_WebSocket"),this.verifyEvent=t.verifyEvent,this._WebSocket=t.websocketImplementation}async ensureRelay(t,e){t=fo(t);let n=this.relays.get(t);return n||(n=new Lo(t,{verifyEvent:this.trustedRelayURLs.has(t)?_o:this.verifyEvent,websocketImplementation:this._WebSocket}),null!=e&&e.connectionTimeout&&(n.connectionTimeout=e.connectionTimeout),this.relays.set(t,n)),await n.connect(),n}close(t){t.map(fo).forEach((t=>{var e;null==(e=this.relays.get(t))||e.close()}))}subscribeMany(t,e,n){return this.subscribeManyMap(Object.fromEntries(t.map((t=>[t,e]))),n)}subscribeManyMap(t,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 n=new Set,r=[],o=Object.keys(t).length,i=[];let s=t=>{var n;i[t]||(i[t]=!0,i.filter((t=>t)).length===o&&(null==(n=e.oneose)||n.call(e),s=()=>{}))};const a=[];let c=(t,n)=>{var r;a[t]||(s(t),a[t]=n,a.filter((t=>t)).length===o&&(null==(r=e.onclose)||r.call(e,a),c=()=>{}))};const l=t=>{var r;if(null!=(r=e.alreadyHaveEvent)&&r.call(e,t))return!0;const o=n.has(t);return n.add(t),o},u=Promise.all(Object.entries(t).map((async(t,n,o)=>{if(o.indexOf(t)!==n)return void c(n,"duplicate url");let i,[a,u]=t;a=fo(a);try{i=await this.ensureRelay(a,{connectionTimeout:e.maxWait?Math.max(.8*e.maxWait,e.maxWait-1e3):void 0})}catch(t){return void c(n,(null==t?void 0:t.message)||String(t))}let h=i.subscribe(u,{...e,oneose:()=>s(n),onclose:t=>c(n,t),alreadyHaveEvent:l,eoseTimeout:e.maxWait});r.push(h)})));return{async close(){await u,r.forEach((t=>{t.close()}))}}}subscribeManyEose(t,e,n){const r=this.subscribeMany(t,e,{...n,oneose(){r.close()}});return r}async querySync(t,e,n){return new Promise((async r=>{const o=[];this.subscribeManyEose(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){return t.map(fo).map((async(t,n,r)=>{if(r.indexOf(t)!==n)return Promise.reject("duplicate url");let o=await this.ensureRelay(t);return o.publish(e).then((t=>{if(this.trackRelays){let t=this.seenOn.get(e.id);t||(t=new Set,this.seenOn.set(e.id,t)),t.add(o)}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}};try{Uo=WebSocket}catch{}var No,Ho=class extends Ro{constructor(){super({verifyEvent:vo,websocketImplementation:Uo})}};try{No=fetch}catch{}var Co=/^bunker:\/\/([0-9a-f]{64})\??([?\/\w:.=&%-]*)$/;async function jo(t){let e=t.match(Co);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(Oo);if(!e)return null;const[n,r="_",o]=e;try{const t=`https://${o}/.well-known/nostr.json?name=${r}`,e=await(await No(t,{redirect:"error"})).json();let n=e.names[r];return{pubkey:n,relays:e.nip46[n]||[],secret:null}}catch{return null}}(t)}var qo=class{constructor(t,e,n={}){if(v(this,"pool"),v(this,"subCloser"),v(this,"isOpen"),v(this,"serial"),v(this,"idPrefix"),v(this,"listeners"),v(this,"waitingForAuth"),v(this,"secretKey"),v(this,"conversationKey"),v(this,"bp"),v(this,"cachedPubKey"),0===e.relays.length)throw new Error("no relays are specified for this bunker");this.pool=n.pool||new Ho,this.secretKey=t,this.conversationKey=xo(t,e.pubkey),this.bp=e,this.isOpen=!1,this.idPrefix=Math.random().toString(36).substring(7),this.serial=0,this.listeners={},this.waitingForAuth={};const r=this.listeners,o=this.waitingForAuth,i=this.conversationKey;this.subCloser=this.pool.subscribeMany(this.bp.relays,[{kinds:[24133],authors:[e.pubkey],"#p":[yo(this.secretKey)]}],{async onevent(s){let a;try{a=JSON.parse(Io(s.content,i))}catch{a=JSON.parse(await async function(t,e,n){const r=t instanceof Uint8Array?ht(t):t;let[o,i]=n.split("?iv="),s=function(t){return t.slice(1,33)}(qe.getSharedSecret(r,"02"+e)),a=Lr.decode(i),c=Lr.decode(o),l=yr(s,a).decrypt(c);return uo.decode(l)}(t,s.pubkey,s.content))}const{id:c,result:l,error:u}=a;if("auth_url"===l&&o[c])return delete o[c],void(n.onauth?n.onauth(u):console.warn(`nostr-tools/nip46: remote signer ${e.pubkey} tried to send an "auth_url"='${u}' but there was no onauth() callback configured.`));let h=r[c];h&&(u?h.reject(u):l&&h.resolve(l),delete r[c])}}),this.isOpen=!0}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.serial++;const o=`${this.idPrefix}-${this.serial}`,i=$o(JSON.stringify({id:o,method:t,params:e}),this.conversationKey),s=mo({kind:24133,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 getRelays(){return JSON.parse(await this.sendRequest("get_relays",[]))}async signEvent(t){let e=await this.sendRequest("sign_event",[JSON.stringify(t)]),n=JSON.parse(e);if(vo(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])}},Mo=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/;try{fetch}catch{}new TextDecoder("utf-8"),new TextEncoder;function zo(t){return function(t,e){return function(t,e){let n=Wr.toWords(e);return Wr.encode(t,n,5e3)}(t,e)}("npub",dt(t))}const Ko=[];const Wo=t=>{const{subscribe:e,set:n}=function(t,e=i){let n;const r=new Set;function o(e){if(u(t,e)&&(t=e,n)){const e=!Ko.length;for(const e of r)e[1](),Ko.push(e,t);if(e){for(let t=0;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 Do(t){let e,n,r;return{c(){e=m("svg"),n=m("circle"),r=m("path"),S(n,"class","opacity-25"),S(n,"cx","12"),S(n,"cy","12"),S(n,"r","10"),S(n,"stroke","currentColor"),S(n,"stroke-width","4"),S(r,"class","opacity-75"),S(r,"fill","currentColor"),S(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"),S(e,"class","ml-2 h-5 w-5 animate-spin text-white"),S(e,"xmlns","http://www.w3.org/2000/svg"),S(e,"fill","none"),S(e,"viewBox","0 0 24 24")},m(t,o){w(t,e,o),g(e,n),g(e,r)},p:i,i:i,o:i,d(t){t&&b(e)}}}class Fo extends tt{constructor(t){super(),X(this,t,null,Do,u,{})}}const{window:Vo}=p;function Zo(t){let e,n,r,o,i,s,a,c,u,h,d,f,p=!t[17]&&!t[10]&&!t[11]&&!t[12]&&Go(t);const m=[oi,ri,ni,ei,ti,Xo,Qo],v=[];function k(t,e){return t[10]?0:t[11]?1:t[12]?2:t[17]?3:t[15]?4:t[18]?6:5}return a=k(t),c=v[a]=m[a](t),{c(){e=y("div"),n=y("button"),r=x("⤫"),i=E(),p&&p.c(),s=E(),c.c(),S(n,"class",o="absolute right-2 top-0 cursor-pointer bg-transparent text-3xl text-"+t[0]+"-600"),S(e,"class",u="animate-show rounded-md bg-linear-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[23])},m(o,c){w(o,e,c),g(e,n),g(n,r),g(e,i),p&&p.m(e,null),g(e,s),v[a].m(e,null),h=!0,d||(f=A(n,"click",(function(){l(t[17]?t[28]:t[26])&&(t[17]?t[28]:t[26]).apply(this,arguments)})),d=!0)},p(r,i){t=r,(!h||1&i[0]&&o!==(o="absolute right-2 top-0 cursor-pointer bg-transparent text-3xl text-"+t[0]+"-600"))&&S(n,"class",o),t[17]||t[10]||t[11]||t[12]?p&&(p.d(1),p=null):p?p.p(t,i):(p=Go(t),p.c(),p.m(e,s));let l=a;a=k(t),a===l?v[a].p(t,i):(D(),Z(v[l],1,1,(()=>{v[l]=null})),F(),c=v[a],c?c.p(t,i):(c=v[a]=m[a](t),c.c()),V(c,1),c.m(e,null)),(!h||8388609&i[0]&&u!==(u="animate-show rounded-md bg-linear-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[23]))&&S(e,"class",u)},i(t){h||(V(c),h=!0)},o(t){Z(c),h=!1},d(t){t&&b(e),p&&p.d(),v[a].d(),d=!1,f()}}}function Jo(t){let e,n,r,o,i;const s=[yi,bi,wi,gi],a=[];function c(t,e){return t[9]?0:t[18]?t[2]?3:2:1}return n=c(t),r=a[n]=s[n](t),{c(){e=y("div"),r.c(),S(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[23])},m(t,r){w(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):(D(),Z(a[u],1,1,(()=>{a[u]=null})),F(),r=a[n],r?r.p(t,l):(r=a[n]=s[n](t),r.c()),V(r,1),r.m(e,null)),(!i||8388609&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[23]))&&S(e,"class",o)},i(t){i||(V(r),i=!0)},o(t){Z(r),i=!1},d(t){t&&b(e),a[n].d()}}}function Yo(t){return{c:i,m:i,p:i,i:i,o:i,d:i}}function Go(t){let e,n,r,o,i;return{c(){e=y("button"),n=x("?"),S(e,"class",r="absolute bottom-1 right-3 cursor-pointer bg-transparent text-xl text-"+t[0]+"-600")},m(r,s){w(r,e,s),g(e,n),o||(i=A(e,"click",t[27]),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")&&S(e,"class",r)},d(t){t&&b(e),o=!1,i()}}}function Qo(t){let e,n,r,o,s,a,c,l,u,h,d,f,p,m,v,k,I,O,B,T,U=t[18].npub+"",_=vn(t[8])+"",L=(t[18].picture||t[18].name)&&ii(t);return{c(){e=y("div"),n=y("div"),n.textContent="You are connected to Nostr as",r=E(),o=y("a"),L&&L.c(),s=E(),a=y("div"),c=x(U),u=E(),h=y("button"),d=x("Disconnect"),p=E(),m=y("div"),v=x("This webpage is using the public key:"),k=y("br"),I=E(),O=x(_),S(n,"class","mb-4 text-sm"),S(a,"class","block break-all"),S(o,"target","_blank"),S(o,"href",l="https://nosta.me/"+t[18].npub),S(o,"class","group text-white no-underline"),S(e,"class","text-center"),S(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"),S(m,"class","mt-6 block break-all text-center text-sm")},m(i,l){w(i,e,l),g(e,n),g(e,r),g(e,o),L&&L.m(o,null),g(o,s),g(o,a),g(a,c),w(i,u,l),w(i,h,l),g(h,d),w(i,p,l),w(i,m,l),g(m,v),g(m,k),g(m,I),g(m,O),B||(T=A(h,"click",t[30]),B=!0)},p(t,e){t[18].picture||t[18].name?L?L.p(t,e):(L=ii(t),L.c(),L.m(o,s)):L&&(L.d(1),L=null),262144&e[0]&&U!==(U=t[18].npub+"")&&$(c,U),262144&e[0]&&l!==(l="https://nosta.me/"+t[18].npub)&&S(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")&&S(h,"class",f),256&e[0]&&_!==(_=vn(t[8])+"")&&$(O,_)},i:i,o:i,d(t){t&&(b(e),b(u),b(h),b(p),b(m)),L&&L.d(),B=!1,T()}}}function Xo(t){let e,n,r,o,i,s,a,l,u,h,d,f,p,m,v,x,$,O=t[16]&&ci(t);const B=[ui,li],T=[];function U(t,e){return t[9]?0:1}l=U(t),u=T[l]=B[l](t);let _=t[9]&&t[13]&&hi(t),L=!t[9]&&di(t);return{c(){e=y("div"),e.textContent="How do you want to connect to Nostr?",n=E(),r=y("form"),o=y("input"),i=E(),O&&O.c(),s=E(),a=y("button"),u.c(),f=E(),_&&_.c(),p=E(),L&&L.c(),m=k(),S(e,"class","text-center text-lg"),S(o,"class","box-border w-full rounded px-2 py-1 text-lg text-neutral-800 outline-none"),S(o,"placeholder","user@provider or bunker://..."),o.autofocus=!0,o.disabled=t[9],S(o,"autocapitalize","none"),S(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[22]||t[9],S(r,"class","mb-1 mt-4 flex flex-col")},m(c,u){w(c,e,u),w(c,n,u),w(c,r,u),g(r,o),t[44](o),I(o,t[4]),g(r,i),O&&O.m(r,null),g(r,s),g(r,a),T[l].m(a,null),g(r,f),_&&_.m(r,null),w(c,p,u),L&&L.m(c,u),w(c,m,u),v=!0,o.focus(),x||($=[A(o,"input",t[45]),A(r,"submit",t[29])],x=!0)},p(t,e){(!v||512&e[0])&&(o.disabled=t[9]),16&e[0]&&o.value!==t[4]&&I(o,t[4]),t[16]?O?O.p(t,e):(O=ci(t),O.c(),O.m(r,s)):O&&(O.d(1),O=null);let n=l;l=U(t),l!==n&&(D(),Z(T[n],1,1,(()=>{T[n]=null})),F(),u=T[l],u||(u=T[l]=B[l](t),u.c()),V(u,1),u.m(a,null)),(!v||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"))&&S(a,"class",h),(!v||4194816&e[0]&&d!==(d=!t[22]||t[9]))&&(a.disabled=d),t[9]&&t[13]?_?_.p(t,e):(_=hi(t),_.c(),_.m(r,null)):_&&(_.d(1),_=null),t[9]?L&&(L.d(1),L=null):L?L.p(t,e):(L=di(t),L.c(),L.m(m.parentNode,m))},i(t){v||(V(u),v=!0)},o(t){Z(u),v=!1},d(o){o&&(b(e),b(n),b(r),b(p),b(m)),t[44](null),O&&O.d(),T[l].d(),_&&_.d(),L&&L.d(o),x=!1,c($)}}}function ti(t){let e,n,r,o,s,a,l,u,h,d,f,p,m,v,k;return{c(){e=y("div"),e.textContent="Create a Nostr account",n=E(),r=y("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=E(),s=y("button"),a=x("Create an account »"),u=E(),h=y("div"),d=x("Do you already have a Nostr address?"),f=y("br"),p=E(),m=y("button"),m.textContent="Login now",S(e,"class","text-center text-lg"),S(r,"class","mt-4 text-base leading-5"),S(s,"class",l="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"),s.disabled=Ai,S(m,"class","cursor-pointer border-0 bg-transparent text-sm text-white underline"),S(h,"class","mt-6 text-center text-sm leading-3")},m(i,c){w(i,e,c),w(i,n,c),w(i,r,c),w(i,o,c),w(i,s,c),g(s,a),w(i,u,c),w(i,h,c),g(h,d),g(h,f),g(h,p),g(h,m),v||(k=[A(s,"click",t[37]),A(m,"click",t[32])],v=!0)},p(t,e){1&e[0]&&l!==(l="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")&&S(s,"class",l)},i:i,o:i,d(t){t&&(b(e),b(n),b(r),b(o),b(s),b(u),b(h)),v=!1,c(k)}}}function ei(t){let e,n,r;return{c(){e=y("div"),e.textContent="What is that?",n=E(),r=y("div"),r.innerHTML='

This widget is created with window.nostr.js, 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't have an\n extension installed.\n
\n It adds a small floating button on the side of the window that users\n can use to create Nostr accuonts or connect to their NIP-46 bunkers.

This tool is opensource, get the code from the project's page.

You don't know what Nostr is?\n Learn more.

',S(e,"class","text-center text-lg"),S(r,"class","text-base leading-5")},m(t,o){w(t,e,o),w(t,n,o),w(t,r,o)},p:i,i:i,o:i,d(t){t&&(b(e),b(n),b(r))}}}function ni(t){let e,n,r,o,s,a,c,l,u,h,d,f,p,m,v,k,I=new URL(t[12]).host+"";return{c(){e=y("div"),n=y("div"),n.textContent="An action requires your confirmation",r=E(),o=y("div"),s=x("A new window will now open, taking you to "),a=y("strong"),c=x(I),l=x("\n where you can approve the current action. If nothing happens, ensure\n your browser is not blocking popups."),u=y("br"),h=x("\n Afterward, you'll be redirected back to this page."),d=E(),f=y("button"),p=x("Confirm action »"),S(n,"class","text-center text-lg"),S(o,"class","mt-4 text-center text-sm leading-4"),S(f,"class",m="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"),S(e,"class","m-auto w-full")},m(i,b){w(i,e,b),g(e,n),g(e,r),g(e,o),g(o,s),g(o,a),g(a,c),g(o,l),g(o,u),g(o,h),g(e,d),g(e,f),g(f,p),v||(k=A(f,"click",t[43]),v=!0)},p(t,e){4096&e[0]&&I!==(I=new URL(t[12]).host+"")&&$(c,I),1&e[0]&&m!==(m="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")&&S(f,"class",m)},i:i,o:i,d(t){t&&b(e),v=!1,k()}}}function ri(t){let e,n,r,o,s,a,c,l,u,h,d,f,p,m,v,k,I=new URL(t[11]).host+"";return{c(){e=y("div"),n=y("div"),n.textContent="Login into a Nostr account",r=E(),o=y("div"),s=x("A new window will now open, taking you to "),a=y("strong"),c=x(I),l=x("\n where you can login and approve the permissions. If nothing happens,\n ensure your browser is not blocking popups. "),u=y("br"),h=x("\n Afterward, you'll be redirected back to this page."),d=E(),f=y("button"),p=x("Login now »"),S(n,"class","text-center text-lg"),S(o,"class","mt-4 text-center text-sm leading-4"),S(f,"class",m="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"),S(e,"class","m-auto w-full")},m(i,b){w(i,e,b),g(e,n),g(e,r),g(e,o),g(o,s),g(o,a),g(a,c),g(o,l),g(o,u),g(o,h),g(e,d),g(e,f),g(f,p),v||(k=A(f,"click",t[42]),v=!0)},p(t,e){2048&e[0]&&I!==(I=new URL(t[11]).host+"")&&$(c,I),1&e[0]&&m!==(m="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")&&S(f,"class",m)},i:i,o:i,d(t){t&&b(e),v=!1,k()}}}function oi(t){let e,n,r,o,s,a,c,l,u,h,d,f,p,m,v,k,I=new URL(t[10]).host+"";return{c(){e=y("div"),n=y("div"),n.textContent="Create a Nostr account",r=E(),o=y("div"),s=x("A new window will now open, taking you to\n "),a=y("strong"),c=x(I),l=x("\n where the account creation will occur. If nothing happens, ensure your\n browser is not blocking popups.\n "),u=y("br"),h=x(" Afterward, you'll be redirected back to this page."),d=E(),f=y("button"),p=x("Start account creation »"),S(n,"class","text-center text-lg"),S(o,"class","mt-4 text-center text-sm leading-4"),S(f,"class",m="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"),S(e,"class","m-auto w-full")},m(i,b){w(i,e,b),g(e,n),g(e,r),g(e,o),g(o,s),g(o,a),g(a,c),g(o,l),g(o,u),g(o,h),g(e,d),g(e,f),g(f,p),v||(k=A(f,"click",t[41]),v=!0)},p(t,e){1024&e[0]&&I!==(I=new URL(t[10]).host+"")&&$(c,I),1&e[0]&&m!==(m="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")&&S(f,"class",m)},i:i,o:i,d(t){t&&b(e),v=!1,k()}}}function ii(t){let e,n,r=t[18].picture&&si(t),o=t[18].name&&ai(t);return{c(){e=y("div"),r&&r.c(),n=E(),o&&o.c(),S(e,"class","mb-2 flex items-center justify-center gap-2")},m(t,i){w(t,e,i),r&&r.m(e,null),g(e,n),o&&o.m(e,null)},p(t,i){t[18].picture?r?r.p(t,i):(r=si(t),r.c(),r.m(e,n)):r&&(r.d(1),r=null),t[18].name?o?o.p(t,i):(o=ai(t),o.c(),o.m(e,null)):o&&(o.d(1),o=null)},d(t){t&&b(e),r&&r.d(),o&&o.d()}}}function si(t){let e,n,r;return{c(){e=y("img"),d(e.src,n=t[18].picture)||S(e,"src",n),S(e,"alt",""),S(e,"class",r="h-10 w-10 rounded-full border-2 border-solid border-transparent group-hover:border-"+t[0]+"-100")},m(t,n){w(t,e,n)},p(t,o){262144&o[0]&&!d(e.src,n=t[18].picture)&&S(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")&&S(e,"class",r)},d(t){t&&b(e)}}}function ai(t){let e,n,r=t[18].name+"";return{c(){e=y("div"),n=x(r),S(e,"class","text-3xl decoration-2 underline-offset-4 group-hover:underline")},m(t,r){w(t,e,r),g(e,n)},p(t,e){262144&e[0]&&r!==(r=t[18].name+"")&&$(n,r)},d(t){t&&b(e)}}}function ci(t){let e,n;return{c(){e=y("div"),n=x(t[16]),S(e,"class","my-2 rounded bg-yellow-100 p-2 text-center text-sm leading-4 text-red-400")},m(t,r){w(t,e,r),g(e,n)},p(t,e){65536&e[0]&&$(n,t[16])},d(t){t&&b(e)}}}function li(t){let e;return{c(){e=x("Connect »")},m(t,n){w(t,e,n)},i:i,o:i,d(t){t&&b(e)}}}function ui(t){let e,n,r;return n=new Fo({}),{c(){e=x("Connecting to bunker\n "),J(n.$$.fragment)},m(t,o){w(t,e,o),Y(n,t,o),r=!0},i(t){r||(V(n.$$.fragment,t),r=!0)},o(t){Z(n.$$.fragment,t),r=!1},d(t){t&&b(e),G(n,t)}}}function hi(t){let e,n,r,o,s;return{c(){e=y("div"),n=x("Waiting too much?\n "),r=y("button"),r.textContent="Cancel the connection",S(r,"class","cursor-pointer border-0 bg-transparent text-sm text-white underline"),S(e,"class","mt-6 text-center text-sm leading-3")},m(i,a){w(i,e,a),g(e,n),g(e,r),o||(s=A(r,"click",t[33]),o=!0)},p:i,d(t){t&&b(e),o=!1,s()}}}function di(t){let e;function n(t,e){return t[14]?pi:fi}let r=n(t),o=r(t);return{c(){e=y("div"),o.c(),S(e,"class","mt-6 text-center text-sm leading-3")},m(t,n){w(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&&b(e),o.d()}}}function fi(t){let e,n,r,o,s,a;return{c(){e=x("Do you need a Nostr account?"),n=y("br"),r=E(),o=y("button"),o.textContent="Sign up now",S(o,"class","cursor-pointer border-0 bg-transparent text-sm text-white underline")},m(i,c){w(i,e,c),w(i,n,c),w(i,r,c),w(i,o,c),s||(a=A(o,"click",t[37]),s=!0)},p:i,d(t){t&&(b(e),b(n),b(r),b(o)),s=!1,a()}}}function pi(t){let e,n,r,o,s,a;return{c(){e=x("Is this bunker provider broken?"),n=y("br"),r=E(),o=y("button"),o.textContent="Clear it",S(o,"class","cursor-pointer border-0 bg-transparent text-sm text-white underline")},m(i,c){w(i,e,c),w(i,n,c),w(i,r,c),w(i,o,c),s||(a=A(o,"click",t[31]),s=!0)},p:i,d(t){t&&(b(e),b(n),b(r),b(o)),s=!1,a()}}}function gi(t){let e,n;return{c(){e=y("img"),d(e.src,n=t[18].picture)||S(e,"src",n),S(e,"alt",""),S(e,"class","h-6 w-6 rounded-full")},m(t,n){w(t,e,n)},p(t,r){262144&r[0]&&!d(e.src,n=t[18].picture)&&S(e,"src",n)},i:i,o:i,d(t){t&&b(e)}}}function wi(t){let e,n,r,o,s=(t[18].name||t[18].npub.slice(0,7)+"…"+t[18].npub.slice(-4))+"";function a(t,e){return t[18].picture?vi:mi}let c=a(t),l=c(t);return{c(){e=y("div"),l.c(),n=E(),r=y("div"),o=x(s),S(r,"class","inline-block max-w-56 overflow-hidden text-ellipsis whitespace-nowrap"),S(e,"class","flex items-center px-2")},m(t,i){w(t,e,i),l.m(e,null),g(e,n),g(e,r),g(r,o)},p(t,r){c===(c=a(t))&&l?l.p(t,r):(l.d(1),l=c(t),l&&(l.c(),l.m(e,n))),262144&r[0]&&s!==(s=(t[18].name||t[18].npub.slice(0,7)+"…"+t[18].npub.slice(-4))+"")&&$(o,s)},i:i,o:i,d(t){t&&b(e),l.d()}}}function bi(t){let e;function n(t,e){return t[2]?Ei:xi}let r=n(t),o=r(t);return{c(){o.c(),e=k()},m(t,n){o.m(t,n),w(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:i,o:i,d(t){t&&b(e),o.d(t)}}}function yi(t){let e,n,r,o;return r=new Fo({}),{c(){e=y("div"),n=x("Connecting to bunker\n "),J(r.$$.fragment),S(e,"class","flex items-center px-2")},m(t,i){w(t,e,i),g(e,n),Y(r,e,null),o=!0},p:i,i(t){o||(V(r.$$.fragment,t),o=!0)},o(t){Z(r.$$.fragment,t),o=!1},d(t){t&&b(e),G(r)}}}function mi(t){let e;return{c(){e=y("span"),e.textContent="☉",S(e,"class","mr-2")},m(t,n){w(t,e,n)},p:i,d(t){t&&b(e)}}}function vi(t){let e,n;return{c(){e=y("img"),d(e.src,n=t[18].picture)||S(e,"src",n),S(e,"alt",""),S(e,"class","mr-2 h-5 w-5 rounded-full")},m(t,n){w(t,e,n)},p(t,r){262144&r[0]&&!d(e.src,n=t[18].picture)&&S(e,"src",n)},d(t){t&&b(e)}}}function xi(t){let e;return{c(){e=y("div"),e.textContent="Connect with Nostr",S(e,"class","flex items-center px-2")},m(t,n){w(t,e,n)},d(t){t&&b(e)}}}function Ei(t){let e;return{c(){e=y("div"),e.textContent="N",S(e,"class","w-6 text-center")},m(t,n){w(t,e,n)},d(t){t&&b(e)}}}function ki(t){let e,n,r,o,i,s,a;const l=[Yo,Jo,Zo],u=[];function h(t,e){return t[21]||t[18]||!t[1]?t[21]?2:1:0}return n=h(t),r=u[n]=l[n](t),{c(){e=y("div"),r.c(),S(e,"class","draggable z-9000 animate-fadein font-sans text-white"),S(e,"style",o="position: fixed; "+(t[21]&&t[5]?"width: 100vw;":"")+"; right: "+(t[21]&&t[5]?"0":t[3])+"px; user-select: none; "+(t[21]&&t[5]?"bottom: 0px":t[20]+":"+t[19]+"px")),O(e,"cursor-pointer",!t[18]&&!t[21])},m(r,o){w(r,e,o),u[n].m(e,null),t[46](e),i=!0,s||(a=[A(Vo,"click",t[25]),A(Vo,"mouseup",t[36]),A(Vo,"mousemove",t[35]),A(e,"mousedown",t[34])],s=!0)},p(t,s){let a=n;n=h(t),n===a?u[n].p(t,s):(D(),Z(u[a],1,1,(()=>{u[a]=null})),F(),r=u[n],r?r.p(t,s):(r=u[n]=l[n](t),r.c()),V(r,1),r.m(e,null)),(!i||3670056&s[0]&&o!==(o="position: fixed; "+(t[21]&&t[5]?"width: 100vw;":"")+"; right: "+(t[21]&&t[5]?"0":t[3])+"px; user-select: none; "+(t[21]&&t[5]?"bottom: 0px":t[20]+":"+t[19]+"px")))&&S(e,"style",o),(!i||2359296&s[0])&&O(e,"cursor-pointer",!t[18]&&!t[21])},i(t){i||(V(r),i=!0)},o(t){Z(r),i=!1},d(r){r&&b(e),u[n].d(),t[46](null),s=!1,c(a)}}}let Ai=!1;const Si="We could not connect to a NIP-46 bunker with that url, are you sure it is set up correctly?",$i="We were not able to connect using this address. For it to work it has to come from a NIP-46 provider.",Ii=20;function Oi(t){return window.open(t,"window.nostr","width=600,height=800,popup=yes")}function Bi(t,e,n){let r,o,i,s,a,c;const l=window.location.hostname,u=window.location.protocol,h=Wo("only screen and (max-width: 640px)");f(t,h,(t=>n(5,c=t)));const d="wnj:origin",p="wnj:clientSecret",g="wnj:ypos",w="wnj:bunkerPointer";let b,{accent:y}=e,{position:m="top"}=e,{startHidden:v}=e,{compactMode:x}=e;const E=window,k=new Hn;let A,S,$;const I=localStorage.getItem(p);I?$=dt(I):($=mn(),localStorage.setItem(p,ht($)));let O,B,T,_,P,R,N,H,C,j,q,M,z,K="closed",W=!1,D=null,F=null,V=null,Z=!1,J=!1,Y=!1,G=[],{right:Q=20}=e,X=!1,tt=!1;const et={pool:k,onauth(t){N?n(10,D=t):C?(n(12,V=t),n(39,K="opened")):n(11,F=t)}},nt=ot((()=>{switch(K){case"justopened":n(39,K="opened");break;case"justclosed":n(39,K="closed")}}),500);function rt(){n(39,K="justopened"),nt()}function it(){n(39,K="justclosed"),nt()}function st(){!O||R?rt():ut()}ct();let at={isWnj:!0,getPublicKey:async()=>new Promise((async(t,e)=>{G.push(e);try{!P&&!R&&st();t(await(await _).getPublicKey())}catch(t){e(t)}finally{const t=G.indexOf(e);-1!==t&&G.splice(t,1)}})),async signEvent(t){try{return!P&&!R&&st(),await(await _).signEvent(t)}finally{n(12,V=null),it()}},getRelays:async()=>({}),nip04:{encrypt:async(t,e)=>(!P&&!R&&st(),(await _).nip04Encrypt(t,e)),decrypt:async(t,e)=>(!P&&!R&&st(),(await _).nip04Decrypt(t,e))},nip44:{encrypt:async(t,e)=>(!P&&!R&&st(),(await _).nip44Encrypt(t,e)),decrypt:async(t,e)=>(!P&&!R&&st(),(await _).nip44Decrypt(t,e))}};function ct(){it(),O=null,_=new Promise(((t,e)=>{B=t,T=e})),n(18,C=null),n(9,P=!1),n(13,Z=!1),n(15,N=!1),R=!1,j=null,n(16,H="")}async function lt(t){t.preventDefault();try{if(O=await jo(S),!O)return void(S.match(Co)?n(16,H=Si):n(16,H=$i));A.setCustomValidity(""),n(16,H=""),await ut(),ft()}catch{S.match(Co)?n(16,H=Si):n(16,H=$i),n(9,P=!1)}}async function ut(t=void 0){t=t||new qo($,O,et),n(9,P=!0);let e=setTimeout((()=>{n(13,Z=!0),n(39,K="opened")}),5e3);try{await t.connect(),R=!0,localStorage.setItem(w,JSON.stringify(O)),it(),B(t)}catch(t){T((null==t?void 0:t.message)||String(t))}finally{clearTimeout(e),n(9,P=!1),n(13,Z=!1),n(10,D=null),n(11,F=null),n(12,V=null),W&&rt()}}async function ft(){let t;try{t=await(await _).getPublicKey()}catch{return void n(14,J=!0)}n(18,C={pubkey:t,npub:zo(t),event:null}),j=k.subscribeMany(["wss://purplepag.es","wss://relay.snort.social","wss://relay.nos.social"],[{kinds:[0],authors:[t]}],{onevent(t){var e;if(!(((null==(e=C.event)?void 0:e.created_at)||0)>=t.created_at))try{let{name:e,picture:r}=JSON.parse(t.content);n(18,C.event=t,C),n(18,C.name=e,C),n(18,C.picture=r,C)}catch{}}})}U((()=>{const t=window.location.hash;if(t.startsWith("#nostr-login=")){const e=t.substring(t.indexOf("=")+1),r=window.location.href.split("#")[0];if(history.replaceState(null,"",r),e.startsWith("bunker://")){n(4,S=e);const t=new SubmitEvent("submit",{bubbles:!0,cancelable:!0});W=!0,rt(),lt(t)}}if(!O){let t=localStorage.getItem(w);if(t){O=JSON.parse(t);let e=new URL(`bunker://${O.pubkey}`);O.relays.forEach((t=>{e.searchParams.append("relay",t)})),O.secret&&e.searchParams.set("secret",O.secret),n(4,S=e.toString()),ft(),ut()}}if(!E.nostr||E.nostr.isWnj)return Object.defineProperty(window,"nostr",{get:()=>at,set(t){at=t,t.isWnj||E.destroyWnj(),G.forEach((t=>{t(new Error("Nostr extension took over, please retry the operation"))})),G=[]},configurable:!0}),()=>{j&&j.close()};E.destroyWnj()}));return t.$$set=t=>{"accent"in t&&n(0,y=t.accent),"position"in t&&n(38,m=t.position),"startHidden"in t&&n(1,v=t.startHidden),"compactMode"in t&&n(2,x=t.compactMode),"right"in t&&n(3,Q=t.right)},t.$$.update=()=>{32&t.$$.dirty[0]|128&t.$$.dirty[1]&&n(20,r=c?"bottom":localStorage.getItem(d)||m),32&t.$$.dirty[0]&&n(19,o=c?Ii:parseInt(localStorage.getItem(g)||"0")||Ii),256&t.$$.dirty[1]&&n(21,i="justopened"===K||"opened"===K),1&t.$$.dirty[0]|512&t.$$.dirty[1]&&n(23,s=tt?"cursor-grabbing outline-dashed outline-"+y+"-500 outline-1 outline-offset-4":"outline-none"),16&t.$$.dirty[0]&&n(22,a=S&&(S.match(Co)||S.match(Mo)))},[y,v,x,Q,S,c,b,A,$,P,D,F,V,Z,J,N,H,Y,C,o,r,i,a,s,h,function(t){Math.abs(o-M)>6||Date.now()-z>600||"justopened"===K||"justclosed"===K||(t.composedPath().find((t=>"wnj"===t.id))?rt():it())},function(t){it(),n(15,N=!1),n(10,D=null),n(11,F=null),n(12,V=null),t.stopPropagation()},function(t){n(17,Y=!0),t.stopPropagation()},function(t){n(17,Y=!1),t.stopPropagation()},lt,async function(t){t.preventDefault(),localStorage.removeItem(w),ct()},async function(t){t.preventDefault(),n(4,S=""),localStorage.removeItem(w),n(14,J=!1)},function(t){n(15,N=!1)},function(){n(13,Z=!1),n(9,P=!1),T("connection aborted"),ct(),rt()},function(t){if(i)return;X=!0;const e=b.getBoundingClientRect();q=t.clientY-e.top,M=o,z=Date.now()},function(t){X&&(n(19,o="top"===r?t.clientY:window.innerHeight-t.clientY),n(19,o-=q),n(40,tt=!0),owindow.innerHeight-Ii&&n(19,o=window.innerHeight-Ii))},function(){if(X=!1,setTimeout((()=>{n(40,tt=!1)}),10),tt){const t=b.getBoundingClientRect(),e=window.innerHeight,i=e/2;t.topOi(D),()=>Oi(F),()=>{Oi(V)},function(t){L[t?"unshift":"push"]((()=>{A=t,n(7,A)}))},function(){S=this.value,n(4,S)},function(t){L[t?"unshift":"push"]((()=>{b=t,n(6,b)}))}]}const Ti=window;Ti.destroyWnj=()=>{setTimeout((()=>{Ri.$destroy()}),1)};const Ui=document.createElement("div");Ui.style.zIndex="90000",document.body.appendChild(Ui);const _i=document.createElement("div");_i.id="wnj";const Li=document.createElement("style");Li.innerHTML='*,: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;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,[type=button],[type=reset],[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]{display:none}*,: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: }::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: }.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-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-5{height:1.25rem}.h-6{height:1.5rem}.w-10{width:2.5rem}.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}.text-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-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))}.bg-cyan-800{--tw-bg-opacity: 1;background-color:rgb(21 94 117 / var(--tw-bg-opacity))}.bg-cyan-900{--tw-bg-opacity: 1;background-color:rgb(22 78 99 / var(--tw-bg-opacity))}.bg-cyan-950{--tw-bg-opacity: 1;background-color:rgb(8 51 68 / var(--tw-bg-opacity))}.bg-green-700{--tw-bg-opacity: 1;background-color:rgb(21 128 61 / var(--tw-bg-opacity))}.bg-green-800{--tw-bg-opacity: 1;background-color:rgb(22 101 52 / var(--tw-bg-opacity))}.bg-green-900{--tw-bg-opacity: 1;background-color:rgb(20 83 45 / var(--tw-bg-opacity))}.bg-green-950{--tw-bg-opacity: 1;background-color:rgb(5 46 22 / var(--tw-bg-opacity))}.bg-neutral-700{--tw-bg-opacity: 1;background-color:rgb(64 64 64 / var(--tw-bg-opacity))}.bg-neutral-800{--tw-bg-opacity: 1;background-color:rgb(38 38 38 / var(--tw-bg-opacity))}.bg-neutral-900{--tw-bg-opacity: 1;background-color:rgb(23 23 23 / var(--tw-bg-opacity))}.bg-neutral-950{--tw-bg-opacity: 1;background-color:rgb(10 10 10 / var(--tw-bg-opacity))}.bg-orange-700{--tw-bg-opacity: 1;background-color:rgb(194 65 12 / var(--tw-bg-opacity))}.bg-orange-800{--tw-bg-opacity: 1;background-color:rgb(154 52 18 / var(--tw-bg-opacity))}.bg-orange-900{--tw-bg-opacity: 1;background-color:rgb(124 45 18 / var(--tw-bg-opacity))}.bg-orange-950{--tw-bg-opacity: 1;background-color:rgb(67 20 7 / var(--tw-bg-opacity))}.bg-purple-700{--tw-bg-opacity: 1;background-color:rgb(126 34 206 / var(--tw-bg-opacity))}.bg-purple-800{--tw-bg-opacity: 1;background-color:rgb(107 33 168 / var(--tw-bg-opacity))}.bg-purple-900{--tw-bg-opacity: 1;background-color:rgb(88 28 135 / var(--tw-bg-opacity))}.bg-purple-950{--tw-bg-opacity: 1;background-color:rgb(59 7 100 / var(--tw-bg-opacity))}.bg-red-700{--tw-bg-opacity: 1;background-color:rgb(185 28 28 / var(--tw-bg-opacity))}.bg-red-800{--tw-bg-opacity: 1;background-color:rgb(153 27 27 / var(--tw-bg-opacity))}.bg-red-900{--tw-bg-opacity: 1;background-color:rgb(127 29 29 / var(--tw-bg-opacity))}.bg-red-950{--tw-bg-opacity: 1;background-color:rgb(69 10 10 / var(--tw-bg-opacity))}.bg-stone-700{--tw-bg-opacity: 1;background-color:rgb(68 64 60 / var(--tw-bg-opacity))}.bg-stone-800{--tw-bg-opacity: 1;background-color:rgb(41 37 36 / var(--tw-bg-opacity))}.bg-stone-900{--tw-bg-opacity: 1;background-color:rgb(28 25 23 / var(--tw-bg-opacity))}.bg-stone-950{--tw-bg-opacity: 1;background-color:rgb(12 10 9 / var(--tw-bg-opacity))}.bg-transparent{background-color:transparent}.bg-yellow-100{--tw-bg-opacity: 1;background-color:rgb(254 249 195 / var(--tw-bg-opacity))}.bg-linear-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}.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}.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))}.text-green-600{--tw-text-opacity: 1;color:rgb(22 163 74 / var(--tw-text-opacity))}.text-neutral-600{--tw-text-opacity: 1;color:rgb(82 82 82 / var(--tw-text-opacity))}.text-neutral-800{--tw-text-opacity: 1;color:rgb(38 38 38 / var(--tw-text-opacity))}.text-orange-600{--tw-text-opacity: 1;color:rgb(234 88 12 / var(--tw-text-opacity))}.text-purple-600{--tw-text-opacity: 1;color:rgb(147 51 234 / var(--tw-text-opacity))}.text-red-400{--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity))}.text-red-600{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity))}.text-stone-600{--tw-text-opacity: 1;color:rgb(87 83 78 / var(--tw-text-opacity))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity))}.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}.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))}.hover\\:bg-cyan-800:hover{--tw-bg-opacity: 1;background-color:rgb(21 94 117 / var(--tw-bg-opacity))}.hover\\:bg-cyan-900:hover{--tw-bg-opacity: 1;background-color:rgb(22 78 99 / var(--tw-bg-opacity))}.hover\\:bg-cyan-950:hover{--tw-bg-opacity: 1;background-color:rgb(8 51 68 / var(--tw-bg-opacity))}.hover\\:bg-green-700:hover{--tw-bg-opacity: 1;background-color:rgb(21 128 61 / var(--tw-bg-opacity))}.hover\\:bg-green-800:hover{--tw-bg-opacity: 1;background-color:rgb(22 101 52 / var(--tw-bg-opacity))}.hover\\:bg-green-900:hover{--tw-bg-opacity: 1;background-color:rgb(20 83 45 / var(--tw-bg-opacity))}.hover\\:bg-green-950:hover{--tw-bg-opacity: 1;background-color:rgb(5 46 22 / var(--tw-bg-opacity))}.hover\\:bg-neutral-700:hover{--tw-bg-opacity: 1;background-color:rgb(64 64 64 / var(--tw-bg-opacity))}.hover\\:bg-neutral-800:hover{--tw-bg-opacity: 1;background-color:rgb(38 38 38 / var(--tw-bg-opacity))}.hover\\:bg-neutral-900:hover{--tw-bg-opacity: 1;background-color:rgb(23 23 23 / var(--tw-bg-opacity))}.hover\\:bg-neutral-950:hover{--tw-bg-opacity: 1;background-color:rgb(10 10 10 / var(--tw-bg-opacity))}.hover\\:bg-orange-700:hover{--tw-bg-opacity: 1;background-color:rgb(194 65 12 / var(--tw-bg-opacity))}.hover\\:bg-orange-800:hover{--tw-bg-opacity: 1;background-color:rgb(154 52 18 / var(--tw-bg-opacity))}.hover\\:bg-orange-900:hover{--tw-bg-opacity: 1;background-color:rgb(124 45 18 / var(--tw-bg-opacity))}.hover\\:bg-orange-950:hover{--tw-bg-opacity: 1;background-color:rgb(67 20 7 / var(--tw-bg-opacity))}.hover\\:bg-purple-700:hover{--tw-bg-opacity: 1;background-color:rgb(126 34 206 / var(--tw-bg-opacity))}.hover\\:bg-purple-800:hover{--tw-bg-opacity: 1;background-color:rgb(107 33 168 / var(--tw-bg-opacity))}.hover\\:bg-purple-900:hover{--tw-bg-opacity: 1;background-color:rgb(88 28 135 / var(--tw-bg-opacity))}.hover\\:bg-purple-950:hover{--tw-bg-opacity: 1;background-color:rgb(59 7 100 / var(--tw-bg-opacity))}.hover\\:bg-red-700:hover{--tw-bg-opacity: 1;background-color:rgb(185 28 28 / var(--tw-bg-opacity))}.hover\\:bg-red-800:hover{--tw-bg-opacity: 1;background-color:rgb(153 27 27 / var(--tw-bg-opacity))}.hover\\:bg-red-900:hover{--tw-bg-opacity: 1;background-color:rgb(127 29 29 / var(--tw-bg-opacity))}.hover\\:bg-red-950:hover{--tw-bg-opacity: 1;background-color:rgb(69 10 10 / var(--tw-bg-opacity))}.hover\\:bg-stone-700:hover{--tw-bg-opacity: 1;background-color:rgb(68 64 60 / var(--tw-bg-opacity))}.hover\\:bg-stone-800:hover{--tw-bg-opacity: 1;background-color:rgb(41 37 36 / var(--tw-bg-opacity))}.hover\\:bg-stone-900:hover{--tw-bg-opacity: 1;background-color:rgb(28 25 23 / var(--tw-bg-opacity))}.hover\\:bg-stone-950:hover{--tw-bg-opacity: 1;background-color:rgb(12 10 9 / var(--tw-bg-opacity))}.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))}.disabled\\:text-neutral-200:disabled{--tw-text-opacity: 1;color:rgb(229 229 229 / var(--tw-text-opacity))}.group:hover .group-hover\\:underline{text-decoration-line:underline}@media (min-width: 640px){.sm\\:w-96{width:24rem}}';const Pi=Ui.attachShadow({mode:"open"});Pi.appendChild(_i),Pi.appendChild(Li);const Ri=new class extends tt{constructor(t){super(),X(this,t,Bi,ki,u,{accent:0,position:38,startHidden:1,compactMode:2,right:3},null,[-1,-1,-1])}}({target:_i,props:{accent:(null==(t=Ti.wnjParams)?void 0:t.accent)||"cyan",position:"bottom"===(null==(e=Ti.wnjParams)?void 0:e.position)?"bottom":"top",startHidden:null==(n=Ti.wnjParams)?void 0:n.startHidden,compactMode:null==(r=Ti.wnjParams)?void 0:r.compactMode}});if(null==(o=Ti.wnjParams)||!o.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/c70b83e199fa1741533055a0248868439d650c779d78ea522db6d51a1121b0d9.map +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{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<{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;ir-i&&(this.process(n,0),i=0);for(let t=i;t>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;tt&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;nt+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<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{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 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[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&&uen.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>=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 ueTt(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||r1024)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&&tt 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;tnew 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&&et===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 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&&Tet.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&&TeLe.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;nt+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;e0&&!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.lengthr-i&&(this.process(n,0),i=0);for(let t=i;t>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;tt&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_att.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;tthis.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{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||""))),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;nt.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({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"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 and returns Promise>, 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{!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 and returns Promise>, 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 and returns Promise>, 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 and returns Promise>, 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{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{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({url:t,filter:e}))),{label:`kind:${t}:batch(${a.length})`,onevent(t){var e;for(let r=0;rt.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-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=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=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=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=0;){const t=r[0];for(let o=0;o0){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<=0;)r^=1335<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=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=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=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=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>>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=c&&n>=c&&t"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?"':"",c="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',l='viewBox="0 0 '+s+" "+s+'"',u=''+a+c+"\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=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;et===n.slice(1)&&-1!==r.indexOf(e))))return!1}return!(t.since&&e.created_att.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;tthis.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{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||""))),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;nt.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({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<>>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=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;e0;)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;tr?t.create().update(n).digest():n);for(let t=0;tnew 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;oe?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<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<=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>25;let n=(33554431&t)<<5;for(let t=0;t>t&1)&&(n^=Ui[t]);return n}function _i(t,e,n=1){const r=t.length;let o=1;for(let e=0;e126)throw new Error(`Invalid prefix (${t})`);o=Oi(o)^n>>5}o=Oi(o);for(let e=0;en)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;e65535)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;r65535||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>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;t6&&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(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{!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>>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{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{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='

This widget is created with window.nostr.js, 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't have an\n extension installed.\n
\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.

This tool is opensource, get the code from the project's page.

You don't know what Nostr is?\n Learn more.

',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),owindow.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.topba(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