nostr-blog-widget 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/485.nostr-blog.js +1 -1
- package/dist/nostr-blog.css +1 -1
- package/dist/nostr-blog.js +1 -1
- package/package.json +1 -1
package/dist/485.nostr-blog.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! Nostr Blog Widget v0.3.
|
|
1
|
+
/*! Nostr Blog Widget v0.3.3 | https://github.com/bigmarh/nostr-blog-widget */
|
|
2
2
|
"use strict";(this.webpackChunkNostrBlog=this.webpackChunkNostrBlog||[]).push([[485],{485(n,r,e){e.d(r,{Navigation:()=>s});var t=e(35),b=e(701),o=(0,t.vs)('<nav class=nbw-space-y-2><a href=#/ class="nbw-block nbw-px-4 nbw-py-2 nbw-rounded nbw-transition-colors hover:nbw-bg-gray-100 nbw-text-gray-900 nbw-no-underline">Home</a><div class="nbw-border-t nbw-border-gray-200 nbw-my-2">'),a=(0,t.vs)('<a class="nbw-block nbw-px-4 nbw-py-2 nbw-rounded nbw-transition-colors hover:nbw-bg-gray-100 nbw-text-gray-700 nbw-no-underline nbw-text-sm">');const s=n=>(()=>{var r=o(),e=r.firstChild;e.nextSibling;return e.$$click=r=>{r.preventDefault(),n.onHome()},(0,t.Yr)(r,(0,b.a0)(b.a,{get each(){return n.posts},children:r=>{return(e=a()).$$click=e=>{e.preventDefault(),n.onNavigate(r.id)},(0,t.Yr)(e,()=>r.title),(0,b.gb)(b=>{var o=`#/post/${r.id}`,a={"nbw-bg-gray-200 nbw-font-semibold":n.currentPostId===r.id};return o!==b.e&&(0,t.Bq)(e,"href",b.e=o),b.t=(0,t.pP)(e,a,b.t),b},{e:void 0,t:void 0}),e;var e}}),null),(0,b.gb)(r=>(0,t.pP)(e,{"nbw-bg-gray-200 nbw-font-semibold":!n.currentPostId},r)),r})();(0,t.z_)(["click"])}}]);
|
|
3
3
|
//# sourceMappingURL=485.nostr-blog.js.map
|
package/dist/nostr-blog.css
CHANGED
package/dist/nostr-blog.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! Nostr Blog Widget v0.3.
|
|
1
|
+
/*! Nostr Blog Widget v0.3.3 | https://github.com/bigmarh/nostr-blog-widget */
|
|
2
2
|
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.NostrBlog=t():e.NostrBlog=t()}(this,()=>(()=>{"use strict";var e,t,n={35(e,t,n){n.d(t,{Bq:()=>c,XX:()=>i,Yr:()=>h,pP:()=>u,ph:()=>s,vs:()=>a,z_:()=>l});var r=n(701);Object.create(null),Object.create(null);const s=e=>(0,r.To)(()=>e());const o="_$DX_DELEGATE";function i(e,t,n,s={}){let o;return(0,r.Hr)(r=>{o=r,t===document?e():h(t,e(),t.firstChild?null:void 0,n)},s.owner),()=>{o(),t.textContent=""}}function a(e,t,n,s){let o;const i=()=>{const t=s?document.createElementNS("http://www.w3.org/1998/Math/MathML","template"):document.createElement("template");return t.innerHTML=e,n?t.content.firstChild.firstChild:s?t.firstChild:t.content.firstChild},a=t?()=>(0,r.vz)(()=>document.importNode(o||(o=i()),!0)):()=>(o||(o=i())).cloneNode(!0);return a.cloneNode=a,a}function l(e,t=window.document){const n=t[o]||(t[o]=new Set);for(let r=0,s=e.length;r<s;r++){const s=e[r];n.has(s)||(n.add(s),t.addEventListener(s,p))}}function c(e,t,n){d(e)||(null==n?e.removeAttribute(t):e.setAttribute(t,n))}function u(e,t,n={}){const r=Object.keys(t||{}),s=Object.keys(n);let o,i;for(o=0,i=s.length;o<i;o++){const r=s[o];r&&"undefined"!==r&&!t[r]&&(f(e,r,!1),delete n[r])}for(o=0,i=r.length;o<i;o++){const s=r[o],i=!!t[s];s&&"undefined"!==s&&n[s]!==i&&i&&(f(e,s,!0),n[s]=i)}return n}function h(e,t,n,s){if(void 0===n||s||(s=[]),"function"!=typeof t)return g(e,t,s,n);(0,r.gb)(r=>g(e,t(),r,n),s)}function d(e){return!!r.sE.context&&!r.sE.done&&(!e||e.isConnected)}function f(e,t,n){const r=t.trim().split(/\s+/);for(let t=0,s=r.length;t<s;t++)e.classList.toggle(r[t],n)}function p(e){if(r.sE.registry&&r.sE.events&&r.sE.events.find(([t,n])=>n===e))return;let t=e.target;const n=`$$${e.type}`,s=e.target,o=e.currentTarget,i=t=>Object.defineProperty(e,"target",{configurable:!0,value:t}),a=()=>{const r=t[n];if(r&&!t.disabled){const s=t[`${n}Data`];if(void 0!==s?r.call(t,s,e):r.call(t,e),e.cancelBubble)return}return t.host&&"string"!=typeof t.host&&!t.host._$host&&t.contains(e.target)&&i(t.host),!0},l=()=>{for(;a()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get:()=>t||document}),r.sE.registry&&!r.sE.done&&(r.sE.done=_$HY.done=!0),e.composedPath){const n=e.composedPath();i(n[0]);for(let e=0;e<n.length-2&&(t=n[e],a());e++){if(t._$host){t=t._$host,l();break}if(t.parentNode===o)break}}else l();i(s)}function g(e,t,n,s,o){const i=d(e);if(i){!n&&(n=[...e.childNodes]);let t=[];for(let e=0;e<n.length;e++){const r=n[e];8===r.nodeType&&"!$"===r.data.slice(0,2)?r.remove():t.push(r)}n=t}for(;"function"==typeof n;)n=n();if(t===n)return n;const a=typeof t,l=void 0!==s;if(e=l&&n[0]&&n[0].parentNode||e,"string"===a||"number"===a){if(i)return n;if("number"===a&&(t=t.toString())===n)return n;if(l){let r=n[0];r&&3===r.nodeType?r.data!==t&&(r.data=t):r=document.createTextNode(t),n=y(e,n,s,r)}else n=""!==n&&"string"==typeof n?e.firstChild.data=t:e.textContent=t}else if(null==t||"boolean"===a){if(i)return n;n=y(e,n,s)}else{if("function"===a)return(0,r.gb)(()=>{let r=t();for(;"function"==typeof r;)r=r();n=g(e,r,n,s)}),()=>n;if(Array.isArray(t)){const a=[],c=n&&Array.isArray(n);if(w(a,t,n,o))return(0,r.gb)(()=>n=g(e,a,n,s,!0)),()=>n;if(i){if(!a.length)return n;if(void 0===s)return n=[...e.childNodes];let t=a[0];if(t.parentNode!==e)return n;const r=[t];for(;(t=t.nextSibling)!==s;)r.push(t);return n=r}if(0===a.length){if(n=y(e,n,s),l)return n}else c?0===n.length?b(e,a,s):function(e,t,n){let r=n.length,s=t.length,o=r,i=0,a=0,l=t[s-1].nextSibling,c=null;for(;i<s||a<o;)if(t[i]!==n[a]){for(;t[s-1]===n[o-1];)s--,o--;if(s===i){const t=o<r?a?n[a-1].nextSibling:n[o-a]:l;for(;a<o;)e.insertBefore(n[a++],t)}else if(o===a)for(;i<s;)c&&c.has(t[i])||t[i].remove(),i++;else if(t[i]===n[o-1]&&n[a]===t[s-1]){const r=t[--s].nextSibling;e.insertBefore(n[a++],t[i++].nextSibling),e.insertBefore(n[--o],r),t[s]=n[o]}else{if(!c){c=new Map;let e=a;for(;e<o;)c.set(n[e],e++)}const r=c.get(t[i]);if(null!=r)if(a<r&&r<o){let l,u=i,h=1;for(;++u<s&&u<o&&null!=(l=c.get(t[u]))&&l===r+h;)h++;if(h>r-a){const s=t[i];for(;a<r;)e.insertBefore(n[a++],s)}else e.replaceChild(n[a++],t[i++])}else i++;else t[i++].remove()}}else i++,a++}(e,n,a):(n&&y(e),b(e,a));n=a}else if(t.nodeType){if(i&&t.parentNode)return n=l?[t]:t;if(Array.isArray(n)){if(l)return n=y(e,n,s,t);y(e,n,null,t)}else null!=n&&""!==n&&e.firstChild?e.replaceChild(t,e.firstChild):e.appendChild(t);n=t}}return n}function w(e,t,n,r){let s=!1;for(let o=0,i=t.length;o<i;o++){let i,a=t[o],l=n&&n[e.length];if(null==a||!0===a||!1===a);else if("object"==(i=typeof a)&&a.nodeType)e.push(a);else if(Array.isArray(a))s=w(e,a,l)||s;else if("function"===i)if(r){for(;"function"==typeof a;)a=a();s=w(e,Array.isArray(a)?a:[a],Array.isArray(l)?l:[l])||s}else e.push(a),s=!0;else{const t=String(a);l&&3===l.nodeType&&l.data===t?e.push(l):e.push(document.createTextNode(t))}}return s}function b(e,t,n=null){for(let r=0,s=t.length;r<s;r++)e.insertBefore(t[r],n)}function y(e,t,n,r){if(void 0===n)return e.textContent="";const s=r||document.createTextNode("");if(t.length){let r=!1;for(let o=t.length-1;o>=0;o--){const i=t[o];if(s!==i){const t=i.parentNode===e;r||o?t&&i.remove():t?e.replaceChild(s,i):e.insertBefore(s,n)}else r=!0}}else e.insertBefore(s,n);return[s]}Symbol()},168(e,t,n){n.d(t,{createRouter:()=>s});var r=n(701);function s(){const[e,t]=(0,r.n5)(n());function n(){const e=window.location.hash.slice(1);if(!e||"/"===e)return{view:"list"};const t=e.match(/^\/post\/(.+)$/);return t?{view:"detail",postId:t[1]}:{view:"list"}}function s(){t(n())}return window.addEventListener("hashchange",s),(0,r.Ki)(()=>window.removeEventListener("hashchange",s)),{route:e,navigateToPost:function(e){window.location.hash=`/post/${e}`},navigateToList:function(){window.location.hash="/"}}}},261(e,t,n){n.d(t,{NostrService:()=>tl});var r={};function s(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function o(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function i(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");s(e.outputLen),s(e.blockLen)}function a(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function l(e,t){o(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}n.r(r),n.d(r,{OG:()=>z,My:()=>I,Ph:()=>_,lX:()=>P,Id:()=>O,fg:()=>H,qj:()=>N,aT:()=>L,lq:()=>C,z:()=>U,Q5:()=>D});const c="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,u=e=>e instanceof Uint8Array,h=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),d=(e,t)=>e<<32-t|e>>>t;if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");function f(e){if("string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),!u(e))throw new Error("expected Uint8Array, got "+typeof e);return e}class p{clone(){return this._cloneInto()}}function g(e){const t=t=>e().update(f(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function w(e=32){if(c&&"function"==typeof c.getRandomValues)return c.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}class b extends p{constructor(e,t,n,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=h(this.buffer)}update(e){a(this);const{view:t,buffer:n,blockLen:r}=this,s=(e=f(e)).length;for(let o=0;o<s;){const i=Math.min(r-this.pos,s-o);if(i===r){const t=h(e);for(;r<=s-o;o+=r)this.process(t,o);continue}n.set(e.subarray(o,o+i),this.pos),this.pos+=i,o+=i,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){a(this),l(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:s}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>r-o&&(this.process(n,0),o=0);for(let e=o;e<r;e++)t[e]=0;!function(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const s=BigInt(32),o=BigInt(4294967295),i=Number(n>>s&o),a=Number(n&o),l=r?4:0,c=r?0:4;e.setUint32(t+l,i,r),e.setUint32(t+c,a,r)}(n,r-8,BigInt(8*this.length),s),this.process(n,0);const i=h(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,d=this.get();if(u>d.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<u;e++)i.setUint32(4*e,d[e],s)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:s,destroyed:o,pos:i}=this;return e.length=r,e.pos=i,e.finished=s,e.destroyed=o,r%t&&e.buffer.set(n),e}}const y=(e,t,n)=>e&t^~e&n,m=(e,t,n)=>e&t^e&n^t&n,v=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]),k=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),x=new Uint32Array(64);class E extends b{constructor(){super(64,32,8,!1),this.A=0|k[0],this.B=0|k[1],this.C=0|k[2],this.D=0|k[3],this.E=0|k[4],this.F=0|k[5],this.G=0|k[6],this.H=0|k[7]}get(){const{A:e,B:t,C:n,D:r,E:s,F:o,G:i,H:a}=this;return[e,t,n,r,s,o,i,a]}set(e,t,n,r,s,o,i,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|s,this.F=0|o,this.G=0|i,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)x[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=x[e-15],n=x[e-2],r=d(t,7)^d(t,18)^t>>>3,s=d(n,17)^d(n,19)^n>>>10;x[e]=s+x[e-7]+r+x[e-16]|0}let{A:n,B:r,C:s,D:o,E:i,F:a,G:l,H:c}=this;for(let e=0;e<64;e++){const t=c+(d(i,6)^d(i,11)^d(i,25))+y(i,a,l)+v[e]+x[e]|0,u=(d(n,2)^d(n,13)^d(n,22))+m(n,r,s)|0;c=l,l=a,a=i,i=o+t|0,o=s,s=r,r=n,n=t+u|0}n=n+this.A|0,r=r+this.B|0,s=s+this.C|0,o=o+this.D|0,i=i+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(n,r,s,o,i,a,l,c)}roundClean(){x.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const S=g(()=>new E),A=(BigInt(0),BigInt(1)),T=BigInt(2),$=e=>e instanceof Uint8Array,R=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function I(e){if(!$(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=R[e[n]];return t}function B(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":`0x${e}`)}function L(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(t/2);for(let t=0;t<n.length;t++){const r=2*t,s=e.slice(r,r+2),o=Number.parseInt(s,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");n[t]=o}return n}function _(e){return B(I(e))}function P(e){if(!$(e))throw new Error("Uint8Array expected");return B(I(Uint8Array.from(e).reverse()))}function C(e,t){return L(e.toString(16).padStart(2*t,"0"))}function U(e,t){return C(e,t).reverse()}function N(e,t,n){let r;if("string"==typeof t)try{r=L(t)}catch(n){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${n}`)}else{if(!$(t))throw new Error(`${e} must be hex string or Uint8Array`);r=Uint8Array.from(t)}const s=r.length;if("number"==typeof n&&s!==n)throw new Error(`${e} expected ${n} bytes, got ${s}`);return r}function O(...e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;return e.forEach(e=>{if(!$(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}const z=e=>(T<<BigInt(e-1))-A,q=e=>new Uint8Array(e),M=e=>Uint8Array.from(e);function H(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");let r=q(e),s=q(e),o=0;const i=()=>{r.fill(1),s.fill(0),o=0},a=(...e)=>n(s,r,...e),l=(e=q())=>{s=a(M([0]),e),r=a(),0!==e.length&&(s=a(M([1]),e),r=a())},c=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){r=a();const t=r.slice();n.push(t),e+=r.length}return O(...n)};return(e,t)=>{let n;for(i(),l(e);!(n=t(c()));)l();return i(),n}}const j={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||e instanceof Uint8Array,isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};function D(e,t,n={}){const r=(t,n,r)=>{const s=j[n];if("function"!=typeof s)throw new Error(`Invalid validator "${n}", expected function`);const o=e[t];if(!(r&&void 0===o||s(o,e)))throw new Error(`Invalid param ${String(t)}=${o} (${typeof o}), expected ${n}`)};for(const[e,n]of Object.entries(t))r(e,n,!1);for(const[e,t]of Object.entries(n))r(e,t,!0);return e}const F=BigInt(0),V=BigInt(1),W=BigInt(2),Z=BigInt(3),K=BigInt(4),Y=BigInt(5),G=BigInt(8);BigInt(9),BigInt(16);function J(e,t){const n=e%t;return n>=F?n:t+n}function Q(e,t,n){if(n<=F||t<F)throw new Error("Expected power/modulo > 0");if(n===V)return F;let r=V;for(;t>F;)t&V&&(r=r*e%n),e=e*e%n,t>>=V;return r}function X(e,t,n){let r=e;for(;t-- >F;)r*=r,r%=n;return r}function ee(e,t){if(e===F||t<=F)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=J(e,t),r=t,s=F,o=V,i=V,a=F;for(;n!==F;){const e=r/n,t=r%n,l=s-i*e,c=o-a*e;r=n,n=t,s=i,o=a,i=l,a=c}if(r!==V)throw new Error("invert: does not exist");return J(s,t)}function te(e){if(e%K===Z){const t=(e+V)/K;return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}}if(e%G===Y){const t=(e-Y)/G;return function(e,n){const r=e.mul(n,W),s=e.pow(r,t),o=e.mul(n,s),i=e.mul(e.mul(o,W),s),a=e.mul(o,e.sub(i,e.ONE));if(!e.eql(e.sqr(a),n))throw new Error("Cannot find square root");return a}}return function(e){const t=(e-V)/W;let n,r,s;for(n=e-V,r=0;n%W===F;n/=W,r++);for(s=W;s<e&&Q(s,t,e)!==e-V;s++);if(1===r){const t=(e+V)/K;return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}}const o=(n+V)/W;return function(e,i){if(e.pow(i,t)===e.neg(e.ONE))throw new Error("Cannot find square root");let a=r,l=e.pow(e.mul(e.ONE,s),n),c=e.pow(i,o),u=e.pow(i,n);for(;!e.eql(u,e.ONE);){if(e.eql(u,e.ZERO))return e.ZERO;let t=1;for(let n=e.sqr(u);t<a&&!e.eql(n,e.ONE);t++)n=e.sqr(n);const n=e.pow(l,V<<BigInt(a-t-1));l=e.sqr(n),c=e.mul(c,n),u=e.mul(u,l),a=t}return c}}(e)}const ne=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function re(e,t){const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function se(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function oe(e){const t=se(e);return t+Math.ceil(t/2)}class ie extends p{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,i(e);const n=f(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,s=new Uint8Array(r);s.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<s.length;e++)s[e]^=54;this.iHash.update(s),this.oHash=e.create();for(let e=0;e<s.length;e++)s[e]^=106;this.oHash.update(s),s.fill(0)}update(e){return a(this),this.iHash.update(e),this}digestInto(e){a(this),o(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:s,blockLen:o,outputLen:i}=this;return e.finished=r,e.destroyed=s,e.blockLen=o,e.outputLen=i,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const ae=(e,t,n)=>new ie(e,t).update(n).digest();ae.create=(e,t)=>new ie(e,t);const le=BigInt(0),ce=BigInt(1);function ue(e){return D(e.Fp,ne.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"})),D(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...re(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}const{Ph:he,aT:de}=r,fe={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(e){const{Err:t}=fe;if(e.length<2||2!==e[0])throw new t("Invalid signature integer tag");const n=e[1],r=e.subarray(2,n+2);if(!n||r.length!==n)throw new t("Invalid signature integer: wrong length");if(128&r[0])throw new t("Invalid signature integer: negative");if(0===r[0]&&!(128&r[1]))throw new t("Invalid signature integer: unnecessary leading zero");return{d:he(r),l:e.subarray(n+2)}},toSig(e){const{Err:t}=fe,n="string"==typeof e?de(e):e;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||48!=n[0])throw new t("Invalid signature tag");if(n[1]!==r-2)throw new t("Invalid signature: incorrect length");const{d:s,l:o}=fe._parseInt(n.subarray(2)),{d:i,l:a}=fe._parseInt(o);if(a.length)throw new t("Invalid signature: left bytes after parsing");return{r:s,s:i}},hexFromSig(e){const t=e=>8&Number.parseInt(e[0],16)?"00"+e:e,n=e=>{const t=e.toString(16);return 1&t.length?`0${t}`:t},r=t(n(e.s)),s=t(n(e.r)),o=r.length/2,i=s.length/2,a=n(o),l=n(i);return`30${n(i+o+4)}02${l}${s}02${a}${r}`}},pe=BigInt(0),ge=BigInt(1),we=(BigInt(2),BigInt(3));BigInt(4);function be(e){const t=function(e){const t=ue(e);D(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:s}=t;if(n){if(!r.eql(s,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}(e),{Fp:n}=t,r=t.toBytes||((e,t,r)=>{const s=t.toAffine();return O(Uint8Array.from([4]),n.toBytes(s.x),n.toBytes(s.y))}),s=t.fromBytes||(e=>{const t=e.subarray(1);return{x:n.fromBytes(t.subarray(0,n.BYTES)),y:n.fromBytes(t.subarray(n.BYTES,2*n.BYTES))}});function o(e){const{a:r,b:s}=t,o=n.sqr(e),i=n.mul(o,e);return n.add(n.add(i,n.mul(e,r)),s)}if(!n.eql(n.sqr(t.Gy),o(t.Gx)))throw new Error("bad generator point: equation left != right");function i(e){return"bigint"==typeof e&&pe<e&&e<t.n}function a(e){if(!i(e))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function l(e){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:s,n:o}=t;if(n&&"bigint"!=typeof e){if(e instanceof Uint8Array&&(e=I(e)),"string"!=typeof e||!n.includes(e.length))throw new Error("Invalid key");e=e.padStart(2*r,"0")}let i;try{i="bigint"==typeof e?e:_(N("private key",e,r))}catch(t){throw new Error(`private key must be ${r} bytes, hex or bigint, not ${typeof e}`)}return s&&(i=J(i,o)),a(i),i}const c=new Map;function u(e){if(!(e instanceof h))throw new Error("ProjectivePoint expected")}class h{constructor(e,t,r){if(this.px=e,this.py=t,this.pz=r,null==e||!n.isValid(e))throw new Error("x required");if(null==t||!n.isValid(t))throw new Error("y required");if(null==r||!n.isValid(r))throw new Error("z required")}static fromAffine(e){const{x:t,y:r}=e||{};if(!e||!n.isValid(t)||!n.isValid(r))throw new Error("invalid affine point");if(e instanceof h)throw new Error("projective point not allowed");const s=e=>n.eql(e,n.ZERO);return s(t)&&s(r)?h.ZERO:new h(t,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(h.fromAffine)}static fromHex(e){const t=h.fromAffine(s(N("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return h.BASE.multiply(l(e))}_setWindowSize(e){this._WINDOW_SIZE=e,c.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!n.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:e,y:r}=this.toAffine();if(!n.isValid(e)||!n.isValid(r))throw new Error("bad point: x or y not FE");const s=n.sqr(r),i=o(e);if(!n.eql(s,i))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){u(e);const{px:t,py:r,pz:s}=this,{px:o,py:i,pz:a}=e,l=n.eql(n.mul(t,a),n.mul(o,s)),c=n.eql(n.mul(r,a),n.mul(i,s));return l&&c}negate(){return new h(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:r}=t,s=n.mul(r,we),{px:o,py:i,pz:a}=this;let l=n.ZERO,c=n.ZERO,u=n.ZERO,d=n.mul(o,o),f=n.mul(i,i),p=n.mul(a,a),g=n.mul(o,i);return g=n.add(g,g),u=n.mul(o,a),u=n.add(u,u),l=n.mul(e,u),c=n.mul(s,p),c=n.add(l,c),l=n.sub(f,c),c=n.add(f,c),c=n.mul(l,c),l=n.mul(g,l),u=n.mul(s,u),p=n.mul(e,p),g=n.sub(d,p),g=n.mul(e,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),c=n.add(c,d),p=n.mul(i,a),p=n.add(p,p),d=n.mul(p,g),l=n.sub(l,d),u=n.mul(p,f),u=n.add(u,u),u=n.add(u,u),new h(l,c,u)}add(e){u(e);const{px:r,py:s,pz:o}=this,{px:i,py:a,pz:l}=e;let c=n.ZERO,d=n.ZERO,f=n.ZERO;const p=t.a,g=n.mul(t.b,we);let w=n.mul(r,i),b=n.mul(s,a),y=n.mul(o,l),m=n.add(r,s),v=n.add(i,a);m=n.mul(m,v),v=n.add(w,b),m=n.sub(m,v),v=n.add(r,o);let k=n.add(i,l);return v=n.mul(v,k),k=n.add(w,y),v=n.sub(v,k),k=n.add(s,o),c=n.add(a,l),k=n.mul(k,c),c=n.add(b,y),k=n.sub(k,c),f=n.mul(p,v),c=n.mul(g,y),f=n.add(c,f),c=n.sub(b,f),f=n.add(b,f),d=n.mul(c,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(k,v),c=n.mul(m,c),c=n.sub(c,w),w=n.mul(m,b),f=n.mul(k,f),f=n.add(f,w),new h(c,d,f)}subtract(e){return this.add(e.negate())}is0(){return this.equals(h.ZERO)}wNAF(e){return f.wNAFCached(this,c,e,e=>{const t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(h.fromAffine)})}multiplyUnsafe(e){const r=h.ZERO;if(e===pe)return r;if(a(e),e===ge)return this;const{endo:s}=t;if(!s)return f.unsafeLadder(this,e);let{k1neg:o,k1:i,k2neg:l,k2:c}=s.splitScalar(e),u=r,d=r,p=this;for(;i>pe||c>pe;)i&ge&&(u=u.add(p)),c&ge&&(d=d.add(p)),p=p.double(),i>>=ge,c>>=ge;return o&&(u=u.negate()),l&&(d=d.negate()),d=new h(n.mul(d.px,s.beta),d.py,d.pz),u.add(d)}multiply(e){a(e);let r,s,o=e;const{endo:i}=t;if(i){const{k1neg:e,k1:t,k2neg:a,k2:l}=i.splitScalar(o);let{p:c,f:u}=this.wNAF(t),{p:d,f:p}=this.wNAF(l);c=f.constTimeNegate(e,c),d=f.constTimeNegate(a,d),d=new h(n.mul(d.px,i.beta),d.py,d.pz),r=c.add(d),s=u.add(p)}else{const{p:e,f:t}=this.wNAF(o);r=e,s=t}return h.normalizeZ([r,s])[0]}multiplyAndAddUnsafe(e,t,n){const r=h.BASE,s=(e,t)=>t!==pe&&t!==ge&&e.equals(r)?e.multiply(t):e.multiplyUnsafe(t),o=s(this,t).add(s(e,n));return o.is0()?void 0:o}toAffine(e){const{px:t,py:r,pz:s}=this,o=this.is0();null==e&&(e=o?n.ONE:n.inv(s));const i=n.mul(t,e),a=n.mul(r,e),l=n.mul(s,e);if(o)return{x:n.ZERO,y:n.ZERO};if(!n.eql(l,n.ONE))throw new Error("invZ was invalid");return{x:i,y:a}}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e===ge)return!0;if(n)return n(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:n}=t;return e===ge?this:n?n(h,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),r(h,this,e)}toHex(e=!0){return I(this.toRawBytes(e))}}h.BASE=new h(t.Gx,t.Gy,n.ONE),h.ZERO=new h(n.ZERO,n.ONE,n.ZERO);const d=t.nBitLength,f=function(e,t){const n=(e,t)=>{const n=t.negate();return e?n:t},r=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:n,unsafeLadder(t,n){let r=e.ZERO,s=t;for(;n>le;)n&ce&&(r=r.add(s)),s=s.double(),n>>=ce;return r},precomputeWindow(e,t){const{windows:n,windowSize:s}=r(t),o=[];let i=e,a=i;for(let e=0;e<n;e++){a=i,o.push(a);for(let e=1;e<s;e++)a=a.add(i),o.push(a);i=a.double()}return o},wNAF(t,s,o){const{windows:i,windowSize:a}=r(t);let l=e.ZERO,c=e.BASE;const u=BigInt(2**t-1),h=2**t,d=BigInt(t);for(let e=0;e<i;e++){const t=e*a;let r=Number(o&u);o>>=d,r>a&&(r-=h,o+=ce);const i=t,f=t+Math.abs(r)-1,p=e%2!=0,g=r<0;0===r?c=c.add(n(p,s[i])):l=l.add(n(g,s[f]))}return{p:l,f:c}},wNAFCached(e,t,n,r){const s=e._WINDOW_SIZE||1;let o=t.get(e);return o||(o=this.precomputeWindow(e,s),1!==s&&t.set(e,r(o))),this.wNAF(s,o,n)}}}(h,t.endo?Math.ceil(d/2):d);return{CURVE:t,ProjectivePoint:h,normPrivateKeyToScalar:l,weierstrassEquation:o,isWithinCurveOrder:i}}function ye(e){const t=function(e){const t=ue(e);return D(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(e),{Fp:n,n:r}=t,s=n.BYTES+1,o=2*n.BYTES+1;function i(e){return J(e,r)}function a(e){return ee(e,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:u,isWithinCurveOrder:h}=be({...t,toBytes(e,t,r){const s=t.toAffine(),o=n.toBytes(s.x),i=O;return r?i(Uint8Array.from([t.hasEvenY()?2:3]),o):i(Uint8Array.from([4]),o,n.toBytes(s.y))},fromBytes(e){const t=e.length,r=e[0],i=e.subarray(1);if(t!==s||2!==r&&3!==r){if(t===o&&4===r){return{x:n.fromBytes(i.subarray(0,n.BYTES)),y:n.fromBytes(i.subarray(n.BYTES,2*n.BYTES))}}throw new Error(`Point of length ${t} was invalid. Expected ${s} compressed bytes or ${o} uncompressed bytes`)}{const e=_(i);if(!(pe<(a=e)&&a<n.ORDER))throw new Error("Point is not on curve");const t=u(e);let s=n.sqrt(t);return!(1&~r)!==((s&ge)===ge)&&(s=n.neg(s)),{x:e,y:s}}var a}}),d=e=>I(C(e,t.nByteLength));function f(e){return e>r>>ge}const p=(e,t,n)=>_(e.slice(t,n));class g{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(e){const n=t.nByteLength;return e=N("compactSignature",e,2*n),new g(p(e,0,n),p(e,n,2*n))}static fromDER(e){const{r:t,s:n}=fe.toSig(N("DER",e));return new g(t,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(e){return new g(this.r,this.s,e)}recoverPublicKey(e){const{r,s,recovery:o}=this,c=m(N("msgHash",e));if(null==o||![0,1,2,3].includes(o))throw new Error("recovery id invalid");const u=2===o||3===o?r+t.n:r;if(u>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const h=1&o?"03":"02",f=l.fromHex(h+d(u)),p=a(u),g=i(-c*p),w=i(s*p),b=l.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,i(-this.s),this.recovery):this}toDERRawBytes(){return L(this.toDERHex())}toDERHex(){return fe.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return L(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}const w={isValidPrivateKey(e){try{return c(e),!0}catch(e){return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{const e=oe(t.n);return function(e,t,n=!1){const r=e.length,s=se(t),o=oe(t);if(r<16||r<o||r>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${r}`);const i=J(n?_(e):P(e),t-V)+V;return n?U(i,s):C(i,s)}(t.randomBytes(e),t.n)},precompute:(e=8,t=l.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function b(e){const t=e instanceof Uint8Array,n="string"==typeof e,r=(t||n)&&e.length;return t?r===s||r===o:n?r===2*s||r===2*o:e instanceof l}const y=t.bits2int||function(e){const n=_(e),r=8*e.length-t.nBitLength;return r>0?n>>BigInt(r):n},m=t.bits2int_modN||function(e){return i(y(e))},v=z(t.nBitLength);function k(e){if("bigint"!=typeof e)throw new Error("bigint expected");if(!(pe<=e&&e<v))throw new Error(`bigint expected < 2^${t.nBitLength}`);return C(e,t.nByteLength)}function x(e,r,s=E){if(["recovered","canonical"].some(e=>e in s))throw new Error("sign() legacy options not supported");const{hash:o,randomBytes:u}=t;let{lowS:d,prehash:p,extraEntropy:w}=s;null==d&&(d=!0),e=N("msgHash",e),p&&(e=N("prehashed msgHash",o(e)));const b=m(e),v=c(r),x=[k(v),k(b)];if(null!=w){const e=!0===w?u(n.BYTES):w;x.push(N("extraEntropy",e))}const S=O(...x),A=b;return{seed:S,k2sig:function(e){const t=y(e);if(!h(t))return;const n=a(t),r=l.BASE.multiply(t).toAffine(),s=i(r.x);if(s===pe)return;const o=i(n*i(A+s*v));if(o===pe)return;let c=(r.x===s?0:2)|Number(r.y&ge),u=o;return d&&f(o)&&(u=function(e){return f(e)?i(-e):e}(o),c^=1),new g(s,u,c)}}}const E={lowS:t.lowS,prehash:!1},S={lowS:t.lowS,prehash:!1};return l.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return l.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,n=!0){if(b(e))throw new Error("first arg must be private key");if(!b(t))throw new Error("second arg must be public key");return l.fromHex(t).multiply(c(e)).toRawBytes(n)},sign:function(e,n,r=E){const{seed:s,k2sig:o}=x(e,n,r),i=t;return H(i.hash.outputLen,i.nByteLength,i.hmac)(s,o)},verify:function(e,n,r,s=S){const o=e;if(n=N("msgHash",n),r=N("publicKey",r),"strict"in s)throw new Error("options.strict was renamed to lowS");const{lowS:c,prehash:u}=s;let h,d;try{if("string"==typeof o||o instanceof Uint8Array)try{h=g.fromDER(o)}catch(e){if(!(e instanceof fe.Err))throw e;h=g.fromCompact(o)}else{if("object"!=typeof o||"bigint"!=typeof o.r||"bigint"!=typeof o.s)throw new Error("PARSE");{const{r:e,s:t}=o;h=new g(e,t)}}d=l.fromHex(r)}catch(e){if("PARSE"===e.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(c&&h.hasHighS())return!1;u&&(n=t.hash(n));const{r:f,s:p}=h,w=m(n),b=a(p),y=i(w*b),v=i(f*b),k=l.BASE.multiplyAndAddUnsafe(d,y,v)?.toAffine();return!!k&&i(k.x)===f},ProjectivePoint:l,Signature:g,utils:w}}function me(e){return{hash:e,hmac:(t,...n)=>ae(e,t,function(...e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;return e.forEach(e=>{if(!u(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}(...n)),randomBytes:w}}const ve=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),ke=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),xe=BigInt(1),Ee=BigInt(2),Se=(e,t)=>(e+t/Ee)/t;function Ae(e){const t=ve,n=BigInt(3),r=BigInt(6),s=BigInt(11),o=BigInt(22),i=BigInt(23),a=BigInt(44),l=BigInt(88),c=e*e*e%t,u=c*c*e%t,h=X(u,n,t)*u%t,d=X(h,n,t)*u%t,f=X(d,Ee,t)*c%t,p=X(f,s,t)*f%t,g=X(p,o,t)*p%t,w=X(g,a,t)*g%t,b=X(w,l,t)*w%t,y=X(b,a,t)*g%t,m=X(y,n,t)*u%t,v=X(m,i,t)*p%t,k=X(v,r,t)*c%t,x=X(k,Ee,t);if(!Te.eql(Te.sqr(x),e))throw new Error("Cannot find square root");return x}const Te=function(e,t,n=!1,r={}){if(e<=F)throw new Error(`Expected Field ORDER > 0, got ${e}`);const{nBitLength:s,nByteLength:o}=re(e,t);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const i=te(e),a=Object.freeze({ORDER:e,BITS:s,BYTES:o,MASK:z(s),ZERO:F,ONE:V,create:t=>J(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return F<=t&&t<e},is0:e=>e===F,isOdd:e=>(e&V)===V,neg:t=>J(-t,e),eql:(e,t)=>e===t,sqr:t=>J(t*t,e),add:(t,n)=>J(t+n,e),sub:(t,n)=>J(t-n,e),mul:(t,n)=>J(t*n,e),pow:(e,t)=>function(e,t,n){if(n<F)throw new Error("Expected power > 0");if(n===F)return e.ONE;if(n===V)return t;let r=e.ONE,s=t;for(;n>F;)n&V&&(r=e.mul(r,s)),s=e.sqr(s),n>>=V;return r}(a,e,t),div:(t,n)=>J(t*ee(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>ee(t,e),sqrt:r.sqrt||(e=>i(a,e)),invertBatch:e=>function(e,t){const n=new Array(t.length),r=t.reduce((t,r,s)=>e.is0(r)?t:(n[s]=t,e.mul(t,r)),e.ONE),s=e.inv(r);return t.reduceRight((t,r,s)=>e.is0(r)?t:(n[s]=e.mul(t,n[s]),e.mul(t,r)),s),n}(a,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?U(e,o):C(e,o),fromBytes:e=>{if(e.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${e.length}`);return n?P(e):_(e)}});return Object.freeze(a)}(ve,void 0,void 0,{sqrt:Ae}),$e=function(e,t){const n=t=>ye({...e,...me(t)});return Object.freeze({...n(t),create:n})}({a:BigInt(0),b:BigInt(7),Fp:Te,n:ke,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=ke,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-xe*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=n,i=BigInt("0x100000000000000000000000000000000"),a=Se(o*e,t),l=Se(-r*e,t);let c=J(e-a*n-l*s,t),u=J(-a*r-l*o,t);const h=c>i,d=u>i;if(h&&(c=t-c),d&&(u=t-u),c>i||u>i)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:h,k1:c,k2neg:d,k2:u}}}},S),Re=BigInt(0),Ie=e=>"bigint"==typeof e&&Re<e&&e<ve,Be={};function Le(e,...t){let n=Be[e];if(void 0===n){const t=S(Uint8Array.from(e,e=>e.charCodeAt(0)));n=O(t,t),Be[e]=n}return S(O(n,...t))}const _e=e=>e.toRawBytes(!0).slice(1),Pe=e=>C(e,32),Ce=e=>J(e,ve),Ue=e=>J(e,ke),Ne=$e.ProjectivePoint;function Oe(e){let t=$e.utils.normPrivateKeyToScalar(e),n=Ne.fromPrivateKey(t);return{scalar:n.hasEvenY()?t:Ue(-t),bytes:_e(n)}}function ze(e){if(!Ie(e))throw new Error("bad x: need 0 < x < p");const t=Ce(e*e);let n=Ae(Ce(t*e+BigInt(7)));n%Ee!==Re&&(n=Ce(-n));const r=new Ne(e,n,xe);return r.assertValidity(),r}function qe(...e){return Ue(_(Le("BIP0340/challenge",...e)))}function Me(e){return Oe(e).bytes}function He(e,t,n=w(32)){const r=N("message",e),{bytes:s,scalar:o}=Oe(t),i=N("auxRand",n,32),a=Pe(o^_(Le("BIP0340/aux",i))),l=Le("BIP0340/nonce",a,s,r),c=Ue(_(l));if(c===Re)throw new Error("sign failed: k is zero");const{bytes:u,scalar:h}=Oe(c),d=qe(u,s,r),f=new Uint8Array(64);if(f.set(u,0),f.set(Pe(Ue(h+d*o)),32),!je(f,r,s))throw new Error("sign: Invalid signature produced");return f}function je(e,t,n){const r=N("signature",e,64),s=N("message",t),o=N("publicKey",n,32);try{const e=ze(_(o)),t=_(r.subarray(0,32));if(!Ie(t))return!1;const n=_(r.subarray(32,64));if(!(e=>"bigint"==typeof e&&Re<e&&e<ke)(n))return!1;const i=qe(Pe(t),_e(e),s),a=((e,t,n)=>Ne.BASE.multiplyAndAddUnsafe(e,t,n))(e,n,Ue(-i));return!(!a||!a.hasEvenY()||a.toAffine().x!==t)}catch(e){return!1}}const De=(()=>({getPublicKey:Me,sign:He,verify:je,utils:{randomPrivateKey:$e.utils.randomPrivateKey,lift_x:ze,pointToBytes:_e,numberToBytesBE:C,bytesToNumberBE:_,taggedHash:Le,mod:J}}))(),Fe="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,Ve=e=>e instanceof Uint8Array,We=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),Ze=(e,t)=>e<<32-t|e>>>t;if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");const Ke=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Ye(e){if(!Ve(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=Ke[e[n]];return t}function Ge(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(t/2);for(let t=0;t<n.length;t++){const r=2*t,s=e.slice(r,r+2),o=Number.parseInt(s,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");n[t]=o}return n}function Je(e){if("string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),!Ve(e))throw new Error("expected Uint8Array, got "+typeof e);return e}function Qe(...e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;return e.forEach(e=>{if(!Ve(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}class Xe{clone(){return this._cloneInto()}}function et(e){const t=t=>e().update(Je(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function tt(e=32){if(Fe&&"function"==typeof Fe.getRandomValues)return Fe.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}function nt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function rt(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}const st={number:nt,bool:function(e){if("boolean"!=typeof e)throw new Error(`Expected boolean, not ${e}`)},bytes:rt,hash:function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");nt(e.outputLen),nt(e.blockLen)},exists:function(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")},output:function(e,t){rt(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}},ot=st;class it extends Xe{constructor(e,t,n,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=We(this.buffer)}update(e){ot.exists(this);const{view:t,buffer:n,blockLen:r}=this,s=(e=Je(e)).length;for(let o=0;o<s;){const i=Math.min(r-this.pos,s-o);if(i===r){const t=We(e);for(;r<=s-o;o+=r)this.process(t,o);continue}n.set(e.subarray(o,o+i),this.pos),this.pos+=i,o+=i,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){ot.exists(this),ot.output(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:s}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>r-o&&(this.process(n,0),o=0);for(let e=o;e<r;e++)t[e]=0;!function(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const s=BigInt(32),o=BigInt(4294967295),i=Number(n>>s&o),a=Number(n&o),l=r?4:0,c=r?0:4;e.setUint32(t+l,i,r),e.setUint32(t+c,a,r)}(n,r-8,BigInt(8*this.length),s),this.process(n,0);const i=We(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=a/4,c=this.get();if(l>c.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<l;e++)i.setUint32(4*e,c[e],s)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:s,destroyed:o,pos:i}=this;return e.length=r,e.pos=i,e.finished=s,e.destroyed=o,r%t&&e.buffer.set(n),e}}const at=(e,t,n)=>e&t^~e&n,lt=(e,t,n)=>e&t^e&n^t&n,ct=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]),ht=new Uint32Array(64);class dt 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:e,B:t,C:n,D:r,E:s,F:o,G:i,H:a}=this;return[e,t,n,r,s,o,i,a]}set(e,t,n,r,s,o,i,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|s,this.F=0|o,this.G=0|i,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)ht[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=ht[e-15],n=ht[e-2],r=Ze(t,7)^Ze(t,18)^t>>>3,s=Ze(n,17)^Ze(n,19)^n>>>10;ht[e]=s+ht[e-7]+r+ht[e-16]|0}let{A:n,B:r,C:s,D:o,E:i,F:a,G:l,H:c}=this;for(let e=0;e<64;e++){const t=c+(Ze(i,6)^Ze(i,11)^Ze(i,25))+at(i,a,l)+ct[e]+ht[e]|0,u=(Ze(n,2)^Ze(n,13)^Ze(n,22))+lt(n,r,s)|0;c=l,l=a,a=i,i=o+t|0,o=s,s=r,r=n,n=t+u|0}n=n+this.A|0,r=r+this.B|0,s=s+this.C|0,o=o+this.D|0,i=i+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(n,r,s,o,i,a,l,c)}roundClean(){ht.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class ft extends dt{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 pt=et(()=>new dt);et(()=>new ft);function gt(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function wt(...e){const t=(e,t)=>n=>e(t(n)),n=Array.from(e).reverse().reduce((e,n)=>e?t(e,n.encode):n.encode,void 0),r=e.reduce((e,n)=>e?t(e,n.decode):n.decode,void 0);return{encode:n,decode:r}}function bt(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("alphabet.encode input should be an array of numbers");return t.map(t=>{if(gt(t),t<0||t>=e.length)throw new Error(`Digit index outside alphabet: ${t} (alphabet: ${e.length})`);return e[t]})},decode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("alphabet.decode input should be array of strings");return t.map(t=>{if("string"!=typeof t)throw new Error(`alphabet.decode: not string element=${t}`);const n=e.indexOf(t);if(-1===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n})}}}function yt(e=""){if("string"!=typeof e)throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("join.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`join.encode: non-string input=${e}`);return t.join(e)},decode:t=>{if("string"!=typeof t)throw new Error("join.decode input should be string");return t.split(e)}}}function mt(e,t="="){if(gt(e),"string"!=typeof t)throw new Error("padding chr should be string");return{encode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let e of n)if("string"!=typeof e)throw new Error(`padding.encode: non-string input=${e}`);for(;n.length*e%8;)n.push(t);return n},decode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let e of n)if("string"!=typeof e)throw new Error(`padding.decode: non-string input=${e}`);let r=n.length;if(r*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&n[r-1]===t;r--)if(!((r-1)*e%8))throw new Error("Invalid padding: string has too much padding");return n.slice(0,r)}}}function vt(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function kt(e,t,n){if(t<2)throw new Error(`convertRadix: wrong from=${t}, 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(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let r=0;const s=[],o=Array.from(e);for(o.forEach(e=>{if(gt(e),e<0||e>=t)throw new Error(`Wrong integer: ${e}`)});;){let e=0,i=!0;for(let s=r;s<o.length;s++){const a=o[s],l=t*e+a;if(!Number.isSafeInteger(l)||t*e/t!==e||l-a!==t*e)throw new Error("convertRadix: carry overflow");if(e=l%n,o[s]=Math.floor(l/n),!Number.isSafeInteger(o[s])||o[s]*n+e!==l)throw new Error("convertRadix: carry overflow");i&&(o[s]?i=!1:r=s)}if(s.push(e),i)break}for(let t=0;t<e.length-1&&0===e[t];t++)s.push(0);return s.reverse()}const xt=(e,t)=>t?xt(t,e%t):e,Et=(e,t)=>e+(t-xt(e,t));function St(e,t,n,r){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(Et(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${Et(t,n)}`);let s=0,o=0;const i=2**n-1,a=[];for(const r of e){if(gt(r),r>=2**t)throw new Error(`convertRadix2: invalid data word=${r} from=${t}`);if(s=s<<t|r,o+t>32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${t}`);for(o+=t;o>=n;o-=n)a.push((s>>o-n&i)>>>0);s&=2**o-1}if(s=s<<n-o&i,!r&&o>=t)throw new Error("Excess padding");if(!r&&s)throw new Error(`Non-zero padding: ${s}`);return r&&o>0&&a.push(s>>>0),a}function At(e){return gt(e),{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return kt(Array.from(t),256,e)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix.decode input should be array of strings");return Uint8Array.from(kt(t,e,256))}}}function Tt(e,t=!1){if(gt(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(Et(8,e)>32||Et(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!(n instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return St(Array.from(n),8,e,!t)},decode:n=>{if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(St(n,e,8,t))}}}function $t(e){if("function"!=typeof e)throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch(e){}}}const Rt=wt(Tt(4),bt("0123456789ABCDEF"),yt("")),It=wt(Tt(5),bt("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),mt(5),yt("")),Bt=(wt(Tt(5),bt("0123456789ABCDEFGHIJKLMNOPQRSTUV"),mt(5),yt("")),wt(Tt(5),bt("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),yt(""),vt(e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))),wt(Tt(6),bt("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),mt(6),yt(""))),Lt=wt(Tt(6),bt("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),mt(6),yt("")),_t=e=>wt(At(58),bt(e),yt("")),Pt=_t("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),Ct=(_t("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),_t("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"),[0,2,3,5,6,7,9,10,11]),Ut={encode(e){let t="";for(let n=0;n<e.length;n+=8){const r=e.subarray(n,n+8);t+=Pt.encode(r).padStart(Ct[r.length],"1")}return t},decode(e){let t=[];for(let n=0;n<e.length;n+=11){const r=e.slice(n,n+11),s=Ct.indexOf(r.length),o=Pt.decode(r);for(let e=0;e<o.length-s;e++)if(0!==o[e])throw new Error("base58xmr: wrong padding");t=t.concat(Array.from(o.slice(o.length-s)))}return Uint8Array.from(t)}},Nt=wt(bt("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),yt("")),Ot=[996825010,642813549,513874426,1027748829,705979059];function zt(e){const t=e>>25;let n=(33554431&e)<<5;for(let e=0;e<Ot.length;e++)1==(t>>e&1)&&(n^=Ot[e]);return n}function qt(e,t,n=1){const r=e.length;let s=1;for(let t=0;t<r;t++){const n=e.charCodeAt(t);if(n<33||n>126)throw new Error(`Invalid prefix (${e})`);s=zt(s)^n>>5}s=zt(s);for(let t=0;t<r;t++)s=zt(s)^31&e.charCodeAt(t);for(let e of t)s=zt(s)^e;for(let e=0;e<6;e++)s=zt(s);return s^=n,Nt.encode(St([s%2**30],30,5,!1))}function Mt(e){const t="bech32"===e?1:734539939,n=Tt(5),r=n.decode,s=n.encode,o=$t(r);function i(e,n=90){if("string"!=typeof e)throw new Error("bech32.decode input should be string, not "+typeof e);if(e.length<8||!1!==n&&e.length>n)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);const r=e.toLowerCase();if(e!==r&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const s=(e=r).lastIndexOf("1");if(0===s||-1===s)throw new Error('Letter "1" must be present between prefix and data only');const o=e.slice(0,s),i=e.slice(s+1);if(i.length<6)throw new Error("Data must be at least 6 characters long");const a=Nt.decode(i).slice(0,-6),l=qt(o,a,t);if(!i.endsWith(l))throw new Error(`Invalid checksum in ${e}: expected "${l}"`);return{prefix:o,words:a}}return{encode:function(e,n,r=90){if("string"!=typeof e)throw new Error("bech32.encode prefix should be string, not "+typeof e);if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof n);const s=e.length+7+n.length;if(!1!==r&&s>r)throw new TypeError(`Length ${s} exceeds limit ${r}`);return`${e=e.toLowerCase()}1${Nt.encode(n)}${qt(e,n,t)}`},decode:i,decodeToBytes:function(e){const{prefix:t,words:n}=i(e,!1);return{prefix:t,words:n,bytes:r(n)}},decodeUnsafe:$t(i),fromWords:r,fromWordsUnsafe:o,toWords:s}}const Ht=Mt("bech32"),jt=(Mt("bech32m"),{encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)});wt(Tt(4),bt("0123456789abcdef"),yt(""),vt(e=>{if("string"!=typeof e||e.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()}));function Dt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function Ft(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}function Vt(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function Wt(e,...t){if(!Vt(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function Zt(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Kt(e,t){Wt(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const Yt=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),Gt=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),Jt=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");const Qt=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Xt(e){Wt(e);let t="";for(let n=0;n<e.length;n++)t+=Qt[e[n]];return t}const en=48,tn=57,nn=65,rn=70,sn=97,on=102;function an(e){return e>=en&&e<=tn?e-en:e>=nn&&e<=rn?e-(nn-10):e>=sn&&e<=on?e-(sn-10):void 0}function ln(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,n=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,s=0;t<n;t++,s+=2){const n=an(e.charCodeAt(s)),o=an(e.charCodeAt(s+1));if(void 0===n||void 0===o){const t=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+s)}r[t]=16*n+o}return r}function cn(e){if("string"==typeof e)e=function(e){if("string"!=typeof e)throw new Error("string expected, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e);else{if(!Vt(e))throw new Error("Uint8Array expected, got "+typeof e);e=e.slice()}return e}function un(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return 0===n}const hn=(e,t)=>(Object.assign(t,e),t);function dn(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const s=BigInt(32),o=BigInt(4294967295),i=Number(n>>s&o),a=Number(n&o),l=r?4:0,c=r?0:4;e.setUint32(t+l,i,r),e.setUint32(t+c,a,r)}const fn=16,pn=new Uint8Array(16),gn=Gt(pn),wn=(e,t,n,r)=>({s3:n<<31|r>>>1,s2:t<<31|n>>>1,s1:e<<31|t>>>1,s0:e>>>1^225<<24&-(1&(1&r))}),bn=e=>(e>>>0&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255;class yn{constructor(e,t){this.blockLen=fn,this.outputLen=fn,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,Wt(e=cn(e),16);const n=Jt(e);let r=n.getUint32(0,!1),s=n.getUint32(4,!1),o=n.getUint32(8,!1),i=n.getUint32(12,!1);const a=[];for(let e=0;e<128;e++)a.push({s0:bn(r),s1:bn(s),s2:bn(o),s3:bn(i)}),({s0:r,s1:s,s2:o,s3:i}=wn(r,s,o,i));const l=(e=>e>65536?8:e>1024?4:2)(t||1024);if(![1,2,4,8].includes(l))throw new Error(`ghash: wrong window size=${l}, should be 2, 4 or 8`);this.W=l;const c=128/l,u=this.windowSize=2**l,h=[];for(let e=0;e<c;e++)for(let t=0;t<u;t++){let n=0,r=0,s=0,o=0;for(let i=0;i<l;i++){if(!(t>>>l-i-1&1))continue;const{s0:c,s1:u,s2:h,s3:d}=a[l*e+i];n^=c,r^=u,s^=h,o^=d}h.push({s0:n,s1:r,s2:s,s3:o})}this.t=h}_updateBlock(e,t,n,r){e^=this.s0,t^=this.s1,n^=this.s2,r^=this.s3;const{W:s,t:o,windowSize:i}=this;let a=0,l=0,c=0,u=0;const h=(1<<s)-1;let d=0;for(const f of[e,t,n,r])for(let e=0;e<4;e++){const t=f>>>8*e&255;for(let e=8/s-1;e>=0;e--){const n=t>>>s*e&h,{s0:r,s1:f,s2:p,s3:g}=o[d*i+n];a^=r,l^=f,c^=p,u^=g,d+=1}}this.s0=a,this.s1=l,this.s2=c,this.s3=u}update(e){e=cn(e),Zt(this);const t=Gt(e),n=Math.floor(e.length/fn),r=e.length%fn;for(let e=0;e<n;e++)this._updateBlock(t[4*e+0],t[4*e+1],t[4*e+2],t[4*e+3]);return r&&(pn.set(e.subarray(n*fn)),this._updateBlock(gn[0],gn[1],gn[2],gn[3]),gn.fill(0)),this}destroy(){const{t:e}=this;for(const t of e)t.s0=0,t.s1=0,t.s2=0,t.s3=0}digestInto(e){Zt(this),Kt(e,this),this.finished=!0;const{s0:t,s1:n,s2:r,s3:s}=this,o=Gt(e);return o[0]=t,o[1]=n,o[2]=r,o[3]=s,e}digest(){const e=new Uint8Array(fn);return this.digestInto(e),this.destroy(),e}}class mn extends yn{constructor(e,t){const n=function(e){e.reverse();const t=1&e[15];let n=0;for(let t=0;t<e.length;t++){const r=e[t];e[t]=r>>>1|n,n=(1&r)<<7}return e[0]^=225&-t,e}((e=cn(e)).slice());super(n,t),n.fill(0)}update(e){e=cn(e),Zt(this);const t=Gt(e),n=e.length%fn,r=Math.floor(e.length/fn);for(let e=0;e<r;e++)this._updateBlock(bn(t[4*e+3]),bn(t[4*e+2]),bn(t[4*e+1]),bn(t[4*e+0]));return n&&(pn.set(e.subarray(r*fn)),this._updateBlock(bn(gn[3]),bn(gn[2]),bn(gn[1]),bn(gn[0])),gn.fill(0)),this}digestInto(e){Zt(this),Kt(e,this),this.finished=!0;const{s0:t,s1:n,s2:r,s3:s}=this,o=Gt(e);return o[0]=t,o[1]=n,o[2]=r,o[3]=s,e.reverse()}}function vn(e){const t=(t,n)=>e(n,t.length).update(cn(t)).digest(),n=e(new Uint8Array(16),0);return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=(t,n)=>e(t,n),t}const kn=vn((e,t)=>new yn(e,t)),xn=vn((e,t)=>new mn(e,t)),En=16,Sn=new Uint8Array(En);function An(e){return e<<1^283&-(e>>7)}function Tn(e,t){let n=0;for(;t>0;t>>=1)n^=e&-(1&t),e=An(e);return n}const $n=(()=>{let e=new Uint8Array(256);for(let t=0,n=1;t<256;t++,n^=An(n))e[t]=n;const t=new Uint8Array(256);t[0]=99;for(let n=0;n<255;n++){let r=e[255-n];r|=r<<8,t[e[n]]=255&(r^r>>4^r>>5^r>>6^r>>7^99)}return t})(),Rn=$n.map((e,t)=>$n.indexOf(t)),In=e=>e<<24|e>>>8,Bn=e=>e<<8|e>>>24;function Ln(e,t){if(256!==e.length)throw new Error("Wrong sbox length");const n=new Uint32Array(256).map((n,r)=>t(e[r])),r=n.map(Bn),s=r.map(Bn),o=s.map(Bn),i=new Uint32Array(65536),a=new Uint32Array(65536),l=new Uint16Array(65536);for(let t=0;t<256;t++)for(let c=0;c<256;c++){const u=256*t+c;i[u]=n[t]^r[c],a[u]=s[t]^o[c],l[u]=e[t]<<8|e[c]}return{sbox:e,sbox2:l,T0:n,T1:r,T2:s,T3:o,T01:i,T23:a}}const _n=Ln($n,e=>Tn(e,3)<<24|e<<16|e<<8|Tn(e,2)),Pn=Ln(Rn,e=>Tn(e,11)<<24|Tn(e,13)<<16|Tn(e,9)<<8|Tn(e,14)),Cn=(()=>{const e=new Uint8Array(16);for(let t=0,n=1;t<16;t++,n=An(n))e[t]=n;return e})();function Un(e){Wt(e);const t=e.length;if(![16,24,32].includes(t))throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${t}`);const{sbox2:n}=_n,r=Gt(e),s=r.length,o=e=>zn(n,e,e,e,e),i=new Uint32Array(t+28);i.set(r);for(let e=s;e<i.length;e++){let t=i[e-1];e%s===0?t=o(In(t))^Cn[e/s-1]:s>6&&e%s===4&&(t=o(t)),i[e]=i[e-s]^t}return i}function Nn(e){const t=Un(e),n=t.slice(),r=t.length,{sbox2:s}=_n,{T0:o,T1:i,T2:a,T3:l}=Pn;for(let e=0;e<r;e+=4)for(let s=0;s<4;s++)n[e+s]=t[r-e-4+s];t.fill(0);for(let e=4;e<r-4;e++){const t=n[e],r=zn(s,t,t,t,t);n[e]=o[255&r]^i[r>>>8&255]^a[r>>>16&255]^l[r>>>24]}return n}function On(e,t,n,r,s,o){return e[n<<8&65280|r>>>8&255]^t[s>>>8&65280|o>>>24&255]}function zn(e,t,n,r,s){return e[255&t|65280&n]|e[r>>>16&255|s>>>16&65280]<<16}function qn(e,t,n,r,s){const{sbox2:o,T01:i,T23:a}=_n;let l=0;t^=e[l++],n^=e[l++],r^=e[l++],s^=e[l++];const c=e.length/4-2;for(let o=0;o<c;o++){const o=e[l++]^On(i,a,t,n,r,s),c=e[l++]^On(i,a,n,r,s,t),u=e[l++]^On(i,a,r,s,t,n),h=e[l++]^On(i,a,s,t,n,r);t=o,n=c,r=u,s=h}return{s0:e[l++]^zn(o,t,n,r,s),s1:e[l++]^zn(o,n,r,s,t),s2:e[l++]^zn(o,r,s,t,n),s3:e[l++]^zn(o,s,t,n,r)}}function Mn(e,t,n,r,s){const{sbox2:o,T01:i,T23:a}=Pn;let l=0;t^=e[l++],n^=e[l++],r^=e[l++],s^=e[l++];const c=e.length/4-2;for(let o=0;o<c;o++){const o=e[l++]^On(i,a,t,s,r,n),c=e[l++]^On(i,a,n,t,s,r),u=e[l++]^On(i,a,r,n,t,s),h=e[l++]^On(i,a,s,r,n,t);t=o,n=c,r=u,s=h}return{s0:e[l++]^zn(o,t,s,r,n),s1:e[l++]^zn(o,n,t,s,r),s2:e[l++]^zn(o,r,n,t,s),s3:e[l++]^zn(o,s,r,n,t)}}function Hn(e,t){if(!t)return new Uint8Array(e);if(Wt(t),t.length<e)throw new Error(`aes: wrong destination length, expected at least ${e}, got: ${t.length}`);return t}function jn(e,t,n,r){Wt(t,En),Wt(n);const s=n.length;r=Hn(s,r);const o=t,i=Gt(o);let{s0:a,s1:l,s2:c,s3:u}=qn(e,i[0],i[1],i[2],i[3]);const h=Gt(n),d=Gt(r);for(let t=0;t+4<=h.length;t+=4){d[t+0]=h[t+0]^a,d[t+1]=h[t+1]^l,d[t+2]=h[t+2]^c,d[t+3]=h[t+3]^u;let n=1;for(let e=o.length-1;e>=0;e--)n=n+(255&o[e])|0,o[e]=255&n,n>>>=8;({s0:a,s1:l,s2:c,s3:u}=qn(e,i[0],i[1],i[2],i[3]))}const f=En*Math.floor(h.length/4);if(f<s){const e=new Uint32Array([a,l,c,u]),t=Yt(e);for(let e=f,o=0;e<s;e++,o++)r[e]=n[e]^t[o]}return r}function Dn(e,t,n,r,s){Wt(n,En),Wt(r),s=Hn(r.length,s);const o=n,i=Gt(o),a=Jt(o),l=Gt(r),c=Gt(s),u=t?0:12,h=r.length;let d=a.getUint32(u,t),{s0:f,s1:p,s2:g,s3:w}=qn(e,i[0],i[1],i[2],i[3]);for(let n=0;n+4<=l.length;n+=4)c[n+0]=l[n+0]^f,c[n+1]=l[n+1]^p,c[n+2]=l[n+2]^g,c[n+3]=l[n+3]^w,d=d+1>>>0,a.setUint32(u,d,t),({s0:f,s1:p,s2:g,s3:w}=qn(e,i[0],i[1],i[2],i[3]));const b=En*Math.floor(l.length/4);if(b<h){const e=new Uint32Array([f,p,g,w]),t=Yt(e);for(let e=b,n=0;e<h;e++,n++)s[e]=r[e]^t[n]}return s}hn({blockSize:16,nonceLength:16},function(e,t){function n(n,r){const s=Un(e),o=t.slice(),i=jn(s,o,n,r);return s.fill(0),o.fill(0),i}return Wt(e),Wt(t,En),{encrypt:(e,t)=>n(e,t),decrypt:(e,t)=>n(e,t)}});function Fn(e){if(Wt(e),e.length%En!==0)throw new Error("aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size 16")}function Vn(e,t,n){let r=e.length;const s=r%En;if(!t&&0!==s)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");const o=Gt(e);if(t){let e=En-s;e||(e=En),r+=e}const i=Hn(r,n);return{b:o,o:Gt(i),out:i}}function Wn(e,t){if(!t)return e;const n=e.length;if(!n)throw new Error("aes/pcks5: empty ciphertext not allowed");const r=e[n-1];if(r<=0||r>16)throw new Error(`aes/pcks5: wrong padding byte: ${r}`);const s=e.subarray(0,-r);for(let t=0;t<r;t++)if(e[n-t-1]!==r)throw new Error("aes/pcks5: wrong padding");return s}function Zn(e){const t=new Uint8Array(16),n=Gt(t);t.set(e);const r=En-e.length;for(let e=En-r;e<En;e++)t[e]=r;return n}hn({blockSize:16},function(e,t={}){Wt(e);const n=!t.disablePadding;return{encrypt:(t,r)=>{Wt(t);const{b:s,o,out:i}=Vn(t,n,r),a=Un(e);let l=0;for(;l+4<=s.length;){const{s0:e,s1:t,s2:n,s3:r}=qn(a,s[l+0],s[l+1],s[l+2],s[l+3]);o[l++]=e,o[l++]=t,o[l++]=n,o[l++]=r}if(n){const e=Zn(t.subarray(4*l)),{s0:n,s1:r,s2:s,s3:i}=qn(a,e[0],e[1],e[2],e[3]);o[l++]=n,o[l++]=r,o[l++]=s,o[l++]=i}return a.fill(0),i},decrypt:(t,r)=>{Fn(t);const s=Nn(e),o=Hn(t.length,r),i=Gt(t),a=Gt(o);for(let e=0;e+4<=i.length;){const{s0:t,s1:n,s2:r,s3:o}=Mn(s,i[e+0],i[e+1],i[e+2],i[e+3]);a[e++]=t,a[e++]=n,a[e++]=r,a[e++]=o}return s.fill(0),Wn(o,n)}}});const Kn=hn({blockSize:16,nonceLength:16},function(e,t,n={}){Wt(e),Wt(t,16);const r=!n.disablePadding;return{encrypt:(n,s)=>{const o=Un(e),{b:i,o:a,out:l}=Vn(n,r,s),c=Gt(t);let u=c[0],h=c[1],d=c[2],f=c[3],p=0;for(;p+4<=i.length;)u^=i[p+0],h^=i[p+1],d^=i[p+2],f^=i[p+3],({s0:u,s1:h,s2:d,s3:f}=qn(o,u,h,d,f)),a[p++]=u,a[p++]=h,a[p++]=d,a[p++]=f;if(r){const e=Zn(n.subarray(4*p));u^=e[0],h^=e[1],d^=e[2],f^=e[3],({s0:u,s1:h,s2:d,s3:f}=qn(o,u,h,d,f)),a[p++]=u,a[p++]=h,a[p++]=d,a[p++]=f}return o.fill(0),l},decrypt:(n,s)=>{Fn(n);const o=Nn(e),i=Gt(t),a=Hn(n.length,s),l=Gt(n),c=Gt(a);let u=i[0],h=i[1],d=i[2],f=i[3];for(let e=0;e+4<=l.length;){const t=u,n=h,r=d,s=f;u=l[e+0],h=l[e+1],d=l[e+2],f=l[e+3];const{s0:i,s1:a,s2:p,s3:g}=Mn(o,u,h,d,f);c[e++]=i^t,c[e++]=a^n,c[e++]=p^r,c[e++]=g^s}return o.fill(0),Wn(a,r)}}});hn({blockSize:16,nonceLength:16},function(e,t){function n(n,r,s){const o=Un(e),i=n.length;s=Hn(i,s);const a=Gt(n),l=Gt(s),c=r?l:a,u=Gt(t);let h=u[0],d=u[1],f=u[2],p=u[3];for(let e=0;e+4<=a.length;){const{s0:t,s1:n,s2:r,s3:s}=qn(o,h,d,f,p);l[e+0]=a[e+0]^t,l[e+1]=a[e+1]^n,l[e+2]=a[e+2]^r,l[e+3]=a[e+3]^s,h=c[e++],d=c[e++],f=c[e++],p=c[e++]}const g=En*Math.floor(a.length/4);if(g<i){({s0:h,s1:d,s2:f,s3:p}=qn(o,h,d,f,p));const e=Yt(new Uint32Array([h,d,f,p]));for(let t=g,r=0;t<i;t++,r++)s[t]=n[t]^e[r];e.fill(0)}return o.fill(0),s}return Wt(e),Wt(t,16),{encrypt:(e,t)=>n(e,!0,t),decrypt:(e,t)=>n(e,!1,t)}});function Yn(e,t,n,r,s){const o=e.create(n,r.length+(s?.length||0));s&&o.update(s),o.update(r);const i=new Uint8Array(16),a=Jt(i);return s&&dn(a,0,BigInt(8*s.length),t),dn(a,8,BigInt(8*r.length),t),o.update(i),o.digest()}hn({blockSize:16,nonceLength:12,tagLength:16},function(e,t,n){if(Wt(t),0===t.length)throw new Error("aes/gcm: empty nonce");const r=16;function s(e,t,r){const s=Yn(kn,!1,e,r,n);for(let e=0;e<t.length;e++)s[e]^=t[e];return s}function o(){const n=Un(e),r=Sn.slice(),s=Sn.slice();if(Dn(n,!1,s,s,r),12===t.length)s.set(t);else{const e=Sn.slice();dn(Jt(e),8,BigInt(8*t.length),!1),kn.create(r).update(t).update(e).digestInto(s)}return{xk:n,authKey:r,counter:s,tagMask:Dn(n,!1,s,Sn)}}return{encrypt:e=>{Wt(e);const{xk:t,authKey:n,counter:i,tagMask:a}=o(),l=new Uint8Array(e.length+r);Dn(t,!1,i,e,l);const c=s(n,a,l.subarray(0,l.length-r));return l.set(c,e.length),t.fill(0),l},decrypt:e=>{if(Wt(e),e.length<r)throw new Error("aes/gcm: ciphertext less than tagLen (16)");const{xk:t,authKey:n,counter:i,tagMask:a}=o(),l=e.subarray(0,-16),c=e.subarray(-16);if(!un(s(n,a,l),c))throw new Error("aes/gcm: invalid ghash tag");const u=Dn(t,!1,i,l);return n.fill(0),a.fill(0),t.fill(0),u}}});const Gn=(e,t,n)=>r=>{if(!Number.isSafeInteger(r)||t>r||r>n)throw new Error(`${e}: invalid value=${r}, must be [${t}..${n}]`)};hn({blockSize:16,nonceLength:12,tagLength:16},function(e,t,n){const r=Gn("AAD",0,2**36),s=Gn("plaintext",0,2**36),o=Gn("nonce",12,12),i=Gn("ciphertext",16,2**36+16);function a(){const n=e.length;if(16!==n&&24!==n&&32!==n)throw new Error(`key length must be 16, 24 or 32 bytes, got: ${n} bytes`);const r=Un(e),s=new Uint8Array(n),o=new Uint8Array(16),i=Gt(t);let a=0,l=i[0],c=i[1],u=i[2],h=0;for(const e of[o,s].map(Gt)){const t=Gt(e);for(let e=0;e<t.length;e+=2){const{s0:n,s1:s}=qn(r,a,l,c,u);t[e+0]=n,t[e+1]=s,a=++h}}return r.fill(0),{authKey:o,encKey:Un(s)}}function l(e,r,s){const o=Yn(xn,!0,r,s,n);for(let e=0;e<12;e++)o[e]^=t[e];o[15]&=127;const i=Gt(o);let a=i[0],l=i[1],c=i[2],u=i[3];return({s0:a,s1:l,s2:c,s3:u}=qn(e,a,l,c,u)),i[0]=a,i[1]=l,i[2]=c,i[3]=u,o}function c(e,t,n){let r=t.slice();return r[15]|=128,Dn(e,!0,r,n)}return Wt(t),o(t.length),n&&(Wt(n),r(n.length)),{encrypt:e=>{Wt(e),s(e.length);const{encKey:t,authKey:n}=a(),r=l(t,n,e),o=new Uint8Array(e.length+16);return o.set(r,e.length),o.set(c(t,r,e)),t.fill(0),n.fill(0),o},decrypt:e=>{Wt(e),i(e.length);const t=e.subarray(-16),{encKey:n,authKey:r}=a(),s=c(n,t,e.subarray(0,-16)),o=l(n,r,s);if(n.fill(0),r.fill(0),!un(t,o))throw new Error("invalid polyval tag");return s}}});const Jn=(e,t)=>255&e[t++]|(255&e[t++])<<8;class Qn{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,Wt(e=cn(e),32);const t=Jn(e,0),n=Jn(e,2),r=Jn(e,4),s=Jn(e,6),o=Jn(e,8),i=Jn(e,10),a=Jn(e,12),l=Jn(e,14);this.r[0]=8191&t,this.r[1]=8191&(t>>>13|n<<3),this.r[2]=7939&(n>>>10|r<<6),this.r[3]=8191&(r>>>7|s<<9),this.r[4]=255&(s>>>4|o<<12),this.r[5]=o>>>1&8190,this.r[6]=8191&(o>>>14|i<<2),this.r[7]=8065&(i>>>11|a<<5),this.r[8]=8191&(a>>>8|l<<8),this.r[9]=l>>>5&127;for(let t=0;t<8;t++)this.pad[t]=Jn(e,16+2*t)}process(e,t,n=!1){const r=n?0:2048,{h:s,r:o}=this,i=o[0],a=o[1],l=o[2],c=o[3],u=o[4],h=o[5],d=o[6],f=o[7],p=o[8],g=o[9],w=Jn(e,t+0),b=Jn(e,t+2),y=Jn(e,t+4),m=Jn(e,t+6),v=Jn(e,t+8),k=Jn(e,t+10),x=Jn(e,t+12),E=Jn(e,t+14);let S=s[0]+(8191&w),A=s[1]+(8191&(w>>>13|b<<3)),T=s[2]+(8191&(b>>>10|y<<6)),$=s[3]+(8191&(y>>>7|m<<9)),R=s[4]+(8191&(m>>>4|v<<12)),I=s[5]+(v>>>1&8191),B=s[6]+(8191&(v>>>14|k<<2)),L=s[7]+(8191&(k>>>11|x<<5)),_=s[8]+(8191&(x>>>8|E<<8)),P=s[9]+(E>>>5|r),C=0,U=C+S*i+A*(5*g)+T*(5*p)+$*(5*f)+R*(5*d);C=U>>>13,U&=8191,U+=I*(5*h)+B*(5*u)+L*(5*c)+_*(5*l)+P*(5*a),C+=U>>>13,U&=8191;let N=C+S*a+A*i+T*(5*g)+$*(5*p)+R*(5*f);C=N>>>13,N&=8191,N+=I*(5*d)+B*(5*h)+L*(5*u)+_*(5*c)+P*(5*l),C+=N>>>13,N&=8191;let O=C+S*l+A*a+T*i+$*(5*g)+R*(5*p);C=O>>>13,O&=8191,O+=I*(5*f)+B*(5*d)+L*(5*h)+_*(5*u)+P*(5*c),C+=O>>>13,O&=8191;let z=C+S*c+A*l+T*a+$*i+R*(5*g);C=z>>>13,z&=8191,z+=I*(5*p)+B*(5*f)+L*(5*d)+_*(5*h)+P*(5*u),C+=z>>>13,z&=8191;let q=C+S*u+A*c+T*l+$*a+R*i;C=q>>>13,q&=8191,q+=I*(5*g)+B*(5*p)+L*(5*f)+_*(5*d)+P*(5*h),C+=q>>>13,q&=8191;let M=C+S*h+A*u+T*c+$*l+R*a;C=M>>>13,M&=8191,M+=I*i+B*(5*g)+L*(5*p)+_*(5*f)+P*(5*d),C+=M>>>13,M&=8191;let H=C+S*d+A*h+T*u+$*c+R*l;C=H>>>13,H&=8191,H+=I*a+B*i+L*(5*g)+_*(5*p)+P*(5*f),C+=H>>>13,H&=8191;let j=C+S*f+A*d+T*h+$*u+R*c;C=j>>>13,j&=8191,j+=I*l+B*a+L*i+_*(5*g)+P*(5*p),C+=j>>>13,j&=8191;let D=C+S*p+A*f+T*d+$*h+R*u;C=D>>>13,D&=8191,D+=I*c+B*l+L*a+_*i+P*(5*g),C+=D>>>13,D&=8191;let F=C+S*g+A*p+T*f+$*d+R*h;C=F>>>13,F&=8191,F+=I*u+B*c+L*l+_*a+P*i,C+=F>>>13,F&=8191,C=(C<<2)+C|0,C=C+U|0,U=8191&C,C>>>=13,N+=C,s[0]=U,s[1]=N,s[2]=O,s[3]=z,s[4]=q,s[5]=M,s[6]=H,s[7]=j,s[8]=D,s[9]=F}finalize(){const{h:e,pad:t}=this,n=new Uint16Array(10);let r=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=r,r=e[t]>>>13,e[t]&=8191;e[0]+=5*r,r=e[0]>>>13,e[0]&=8191,e[1]+=r,r=e[1]>>>13,e[1]&=8191,e[2]+=r,n[0]=e[0]+5,r=n[0]>>>13,n[0]&=8191;for(let t=1;t<10;t++)n[t]=e[t]+r,r=n[t]>>>13,n[t]&=8191;n[9]-=8192;let s=(1^r)-1;for(let e=0;e<10;e++)n[e]&=s;s=~s;for(let t=0;t<10;t++)e[t]=e[t]&s|n[t];e[0]=65535&(e[0]|e[1]<<13),e[1]=65535&(e[1]>>>3|e[2]<<10),e[2]=65535&(e[2]>>>6|e[3]<<7),e[3]=65535&(e[3]>>>9|e[4]<<4),e[4]=65535&(e[4]>>>12|e[5]<<1|e[6]<<14),e[5]=65535&(e[6]>>>2|e[7]<<11),e[6]=65535&(e[7]>>>5|e[8]<<8),e[7]=65535&(e[8]>>>8|e[9]<<5);let o=e[0]+t[0];e[0]=65535&o;for(let n=1;n<8;n++)o=(e[n]+t[n]|0)+(o>>>16)|0,e[n]=65535&o}update(e){Zt(this);const{buffer:t,blockLen:n}=this,r=(e=cn(e)).length;for(let s=0;s<r;){const o=Math.min(n-this.pos,r-s);if(o!==n)t.set(e.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===n&&(this.process(t,0,!1),this.pos=0);else for(;n<=r-s;s+=n)this.process(e,s)}return this}destroy(){this.h.fill(0),this.r.fill(0),this.buffer.fill(0),this.pad.fill(0)}digestInto(e){Zt(this),Kt(e,this),this.finished=!0;const{buffer:t,h:n}=this;let{pos:r}=this;if(r){for(t[r++]=1;r<16;r++)t[r]=0;this.process(t,0,!0)}this.finalize();let s=0;for(let t=0;t<8;t++)e[s++]=n[t]>>>0,e[s++]=n[t]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}}const Xn=function(e){const t=(t,n)=>e(n).update(cn(t)).digest(),n=e(new Uint8Array(32));return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}(e=>new Qn(e)),er=e=>Uint8Array.from(e.split("").map(e=>e.charCodeAt(0))),tr=er("expand 16-byte k"),nr=er("expand 32-byte k"),rr=Gt(tr),sr=Gt(nr);sr.slice();function or(e,t){return e<<t|e>>>32-t}function ir(e){return e.byteOffset%4==0}const ar=2**32-1,lr=new Uint32Array;function cr(e,t){const{allowShortKeys:n,extendNonceFn:r,counterLength:s,counterRight:o,rounds:i}=function(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign(e,t)}({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if("function"!=typeof e)throw new Error("core must be a function");return Dt(s),Dt(i),Ft(o),Ft(n),(t,a,l,c,u=0)=>{Wt(t),Wt(a),Wt(l);const h=l.length;if(c||(c=new Uint8Array(h)),Wt(c),Dt(u),u<0||u>=ar)throw new Error("arx: counter overflow");if(c.length<h)throw new Error(`arx: output (${c.length}) is shorter than data (${h})`);const d=[];let f,p,g=t.length;if(32===g)f=t.slice(),d.push(f),p=sr;else{if(16!==g||!n)throw new Error(`arx: invalid 32-byte key, got length=${g}`);f=new Uint8Array(32),f.set(t),f.set(t,16),p=rr,d.push(f)}ir(a)||(a=a.slice(),d.push(a));const w=Gt(f);if(r){if(24!==a.length)throw new Error("arx: extended nonce must be 24 bytes");r(p,w,Gt(a.subarray(0,16)),w),a=a.subarray(16)}const b=16-s;if(b!==a.length)throw new Error(`arx: nonce must be ${b} or 16 bytes`);if(12!==b){const e=new Uint8Array(12);e.set(a,o?0:12-a.length),a=e,d.push(a)}const y=Gt(a);for(!function(e,t,n,r,s,o,i,a){const l=s.length,c=new Uint8Array(64),u=Gt(c),h=ir(s)&&ir(o),d=h?Gt(s):lr,f=h?Gt(o):lr;for(let p=0;p<l;i++){if(e(t,n,r,u,i,a),i>=ar)throw new Error("arx: counter overflow");const g=Math.min(64,l-p);if(h&&64===g){const e=p/4;if(p%4!=0)throw new Error("arx: invalid block position");for(let t,n=0;n<16;n++)t=e+n,f[t]=d[t]^u[n];p+=64;continue}for(let e,t=0;t<g;t++)e=p+t,o[e]=s[e]^c[t];p+=g}}(e,p,w,y,l,c,u,i);d.length>0;)d.pop().fill(0);return c}}function ur(e,t,n,r,s,o=20){let i=e[0],a=e[1],l=e[2],c=e[3],u=t[0],h=t[1],d=t[2],f=t[3],p=t[4],g=t[5],w=t[6],b=t[7],y=s,m=n[0],v=n[1],k=n[2],x=i,E=a,S=l,A=c,T=u,$=h,R=d,I=f,B=p,L=g,_=w,P=b,C=y,U=m,N=v,O=k;for(let e=0;e<o;e+=2)x=x+T|0,C=or(C^x,16),B=B+C|0,T=or(T^B,12),x=x+T|0,C=or(C^x,8),B=B+C|0,T=or(T^B,7),E=E+$|0,U=or(U^E,16),L=L+U|0,$=or($^L,12),E=E+$|0,U=or(U^E,8),L=L+U|0,$=or($^L,7),S=S+R|0,N=or(N^S,16),_=_+N|0,R=or(R^_,12),S=S+R|0,N=or(N^S,8),_=_+N|0,R=or(R^_,7),A=A+I|0,O=or(O^A,16),P=P+O|0,I=or(I^P,12),A=A+I|0,O=or(O^A,8),P=P+O|0,I=or(I^P,7),x=x+$|0,O=or(O^x,16),_=_+O|0,$=or($^_,12),x=x+$|0,O=or(O^x,8),_=_+O|0,$=or($^_,7),E=E+R|0,C=or(C^E,16),P=P+C|0,R=or(R^P,12),E=E+R|0,C=or(C^E,8),P=P+C|0,R=or(R^P,7),S=S+I|0,U=or(U^S,16),B=B+U|0,I=or(I^B,12),S=S+I|0,U=or(U^S,8),B=B+U|0,I=or(I^B,7),A=A+T|0,N=or(N^A,16),L=L+N|0,T=or(T^L,12),A=A+T|0,N=or(N^A,8),L=L+N|0,T=or(T^L,7);let z=0;r[z++]=i+x|0,r[z++]=a+E|0,r[z++]=l+S|0,r[z++]=c+A|0,r[z++]=u+T|0,r[z++]=h+$|0,r[z++]=d+R|0,r[z++]=f+I|0,r[z++]=p+B|0,r[z++]=g+L|0,r[z++]=w+_|0,r[z++]=b+P|0,r[z++]=y+C|0,r[z++]=m+U|0,r[z++]=v+N|0,r[z++]=k+O|0}const hr=cr(ur,{counterRight:!1,counterLength:4,allowShortKeys:!1}),dr=cr(ur,{counterRight:!1,counterLength:8,extendNonceFn:function(e,t,n,r){let s=e[0],o=e[1],i=e[2],a=e[3],l=t[0],c=t[1],u=t[2],h=t[3],d=t[4],f=t[5],p=t[6],g=t[7],w=n[0],b=n[1],y=n[2],m=n[3];for(let e=0;e<20;e+=2)s=s+l|0,w=or(w^s,16),d=d+w|0,l=or(l^d,12),s=s+l|0,w=or(w^s,8),d=d+w|0,l=or(l^d,7),o=o+c|0,b=or(b^o,16),f=f+b|0,c=or(c^f,12),o=o+c|0,b=or(b^o,8),f=f+b|0,c=or(c^f,7),i=i+u|0,y=or(y^i,16),p=p+y|0,u=or(u^p,12),i=i+u|0,y=or(y^i,8),p=p+y|0,u=or(u^p,7),a=a+h|0,m=or(m^a,16),g=g+m|0,h=or(h^g,12),a=a+h|0,m=or(m^a,8),g=g+m|0,h=or(h^g,7),s=s+c|0,m=or(m^s,16),p=p+m|0,c=or(c^p,12),s=s+c|0,m=or(m^s,8),p=p+m|0,c=or(c^p,7),o=o+u|0,w=or(w^o,16),g=g+w|0,u=or(u^g,12),o=o+u|0,w=or(w^o,8),g=g+w|0,u=or(u^g,7),i=i+h|0,b=or(b^i,16),d=d+b|0,h=or(h^d,12),i=i+h|0,b=or(b^i,8),d=d+b|0,h=or(h^d,7),a=a+l|0,y=or(y^a,16),f=f+y|0,l=or(l^f,12),a=a+l|0,y=or(y^a,8),f=f+y|0,l=or(l^f,7);let v=0;r[v++]=s,r[v++]=o,r[v++]=i,r[v++]=a,r[v++]=w,r[v++]=b,r[v++]=y,r[v++]=m},allowShortKeys:!1}),fr=new Uint8Array(16),pr=(e,t)=>{e.update(t);const n=t.length%16;n&&e.update(fr.subarray(n))},gr=new Uint8Array(32);function wr(e,t,n,r,s){const o=e(t,n,gr),i=Xn.create(o);s&&pr(i,s),pr(i,r);const a=new Uint8Array(16),l=Jt(a);dn(l,0,BigInt(s?s.length:0),!0),dn(l,8,BigInt(r.length),!0),i.update(a);const c=i.digest();return o.fill(0),c}const br=e=>(t,n,r)=>{const s=16;return Wt(t,32),Wt(n),{encrypt:(o,i)=>{const a=o.length,l=a+s;i?Wt(i,l):i=new Uint8Array(l),e(t,n,o,i,1);const c=wr(e,t,n,i.subarray(0,-16),r);return i.set(c,a),i},decrypt:(o,i)=>{const a=o.length,l=a-s;if(a<s)throw new Error("encrypted data must be at least 16 bytes");i?Wt(i,l):i=new Uint8Array(l);const c=o.subarray(0,-16);if(!un(o.subarray(-16),wr(e,t,n,c,r)))throw new Error("invalid tag");return e(t,n,c,i,1),i}}};br(hr),br(dr);class yr extends Xe{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,ot.hash(e);const n=Je(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,s=new Uint8Array(r);s.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<s.length;e++)s[e]^=54;this.iHash.update(s),this.oHash=e.create();for(let e=0;e<s.length;e++)s[e]^=106;this.oHash.update(s),s.fill(0)}update(e){return ot.exists(this),this.iHash.update(e),this}digestInto(e){ot.exists(this),ot.bytes(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:s,blockLen:o,outputLen:i}=this;return e.finished=r,e.destroyed=s,e.blockLen=o,e.outputLen=i,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const mr=(e,t,n)=>new yr(e,t).update(n).digest();function vr(e,t,n){return ot.hash(e),void 0===n&&(n=new Uint8Array(e.outputLen)),mr(e,Je(n),Je(t))}mr.create=(e,t)=>new yr(e,t);const kr=new Uint8Array([0]),xr=new Uint8Array;function Er(e,t,n,r=32){if(ot.hash(e),ot.number(r),r>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const s=Math.ceil(r/e.outputLen);void 0===n&&(n=xr);const o=new Uint8Array(s*e.outputLen),i=mr.create(e,t),a=i._cloneInto(),l=new Uint8Array(i.outputLen);for(let t=0;t<s;t++)kr[0]=t+1,a.update(0===t?xr:l).update(n).update(kr).digestInto(l),o.set(l,e.outputLen*t),i._cloneInto(a);return i.destroy(),a.destroy(),l.fill(0),kr.fill(0),o.slice(0,r)}var Sr=Object.defineProperty,Ar=(e,t)=>{for(var n in t)Sr(e,n,{get:t[n],enumerable:!0})},Tr=Symbol("verified");function $r(e){if(!(e instanceof Object))return!1;if("number"!=typeof e.kind)return!1;if("string"!=typeof e.content)return!1;if("number"!=typeof e.created_at)return!1;if("string"!=typeof e.pubkey)return!1;if(!e.pubkey.match(/^[a-f0-9]{64}$/))return!1;if(!Array.isArray(e.tags))return!1;for(let t=0;t<e.tags.length;t++){let n=e.tags[t];if(!Array.isArray(n))return!1;for(let e=0;e<n.length;e++)if("string"!=typeof n[e])return!1}return!0}Ar({},{Queue:()=>Ur,QueueNode:()=>Cr,binarySearch:()=>Pr,bytesToHex:()=>Ye,hexToBytes:()=>Ge,insertEventIntoAscendingList:()=>_r,insertEventIntoDescendingList:()=>Lr,normalizeURL:()=>Br,utf8Decoder:()=>Rr,utf8Encoder:()=>Ir});var Rr=new TextDecoder("utf-8"),Ir=new TextEncoder;function Br(e){try{-1===e.indexOf("://")&&(e="wss://"+e);let t=new URL(e);return"http:"===t.protocol?t.protocol="ws:":"https:"===t.protocol&&(t.protocol="wss:"),t.pathname=t.pathname.replace(/\/+/g,"/"),t.pathname.endsWith("/")&&(t.pathname=t.pathname.slice(0,-1)),("80"===t.port&&"ws:"===t.protocol||"443"===t.port&&"wss:"===t.protocol)&&(t.port=""),t.searchParams.sort(),t.hash="",t.toString()}catch(t){throw new Error(`Invalid URL: ${e}`)}}function Lr(e,t){const[n,r]=Pr(e,e=>t.id===e.id?0:t.created_at===e.created_at?-1:e.created_at-t.created_at);return r||e.splice(n,0,t),e}function _r(e,t){const[n,r]=Pr(e,e=>t.id===e.id?0:t.created_at===e.created_at?-1:t.created_at-e.created_at);return r||e.splice(n,0,t),e}function Pr(e,t){let n=0,r=e.length-1;for(;n<=r;){const s=Math.floor((n+r)/2),o=t(e[s]);if(0===o)return[s,!0];o<0?r=s-1:n=s+1}return[n,!1]}var Cr=class{value;next=null;prev=null;constructor(e){this.value=e}},Ur=class{first;last;constructor(){this.first=null,this.last=null}enqueue(e){const t=new Cr(e);return this.last?this.last===this.first?(this.last=t,this.last.prev=this.first,this.first.next=t):(t.prev=this.last,this.last.next=t,this.last=t):(this.first=t,this.last=t),!0}dequeue(){if(!this.first)return null;if(this.first===this.last){const e=this.first;return this.first=null,this.last=null,e.value}const e=this.first;return this.first=e.next,this.first&&(this.first.prev=null),e.value}};function Nr(e){return Ye(pt(Ir.encode(function(e){if(!$r(e))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content])}(e))))}var Or=new class{generateSecretKey(){return De.utils.randomPrivateKey()}getPublicKey(e){return Ye(De.getPublicKey(e))}finalizeEvent(e,t){const n=e;return n.pubkey=Ye(De.getPublicKey(t)),n.id=Nr(n),n.sig=Ye(De.sign(Nr(n),t)),n[Tr]=!0,n}verifyEvent(e){if("boolean"==typeof e[Tr])return e[Tr];const t=Nr(e);if(t!==e.id)return e[Tr]=!1,!1;try{const n=De.verify(e.sig,t,e.pubkey);return e[Tr]=n,n}catch(t){return e[Tr]=!1,!1}}},zr=Or.generateSecretKey,qr=Or.getPublicKey,Mr=Or.finalizeEvent,Hr=Or.verifyEvent;function jr(e){return e<1e4&&0!==e&&3!==e}function Dr(e){return 0===e||3===e||1e4<=e&&e<2e4}function Fr(e){return 2e4<=e&&e<3e4}function Vr(e){return 3e4<=e&&e<4e4}function Wr(e){return jr(e)?"regular":Dr(e)?"replaceable":Fr(e)?"ephemeral":Vr(e)?"parameterized":"unknown"}function Zr(e,t){const n=t instanceof Array?t:[t];return $r(e)&&n.includes(e.kind)||!1}Ar({},{Application:()=>mo,BadgeAward:()=>ns,BadgeDefinition:()=>ho,BlockedRelaysList:()=>Fs,BlossomServerList:()=>Js,BookmarkList:()=>Hs,Bookmarksets:()=>lo,Calendar:()=>To,CalendarEventRSVP:()=>$o,ChannelCreation:()=>ds,ChannelHideMessage:()=>gs,ChannelMessage:()=>ps,ChannelMetadata:()=>fs,ChannelMuteUser:()=>ws,ChatMessage:()=>rs,ClassifiedListing:()=>xo,ClientAuth:()=>eo,Comment:()=>ks,CommunitiesList:()=>js,CommunityDefinition:()=>Lo,CommunityPostApproval:()=>Is,Contacts:()=>Jr,CreateOrUpdateProduct:()=>go,CreateOrUpdateStall:()=>po,Curationsets:()=>co,Date:()=>So,DirectMessageRelaysList:()=>Ys,DraftClassifiedListing:()=>Eo,DraftLong:()=>bo,Emojisets:()=>yo,EncryptedDirectMessage:()=>Qr,EventDeletion:()=>Xr,FavoriteRelays:()=>Ws,FileMessage:()=>as,FileMetadata:()=>vs,FileServerPreference:()=>Gs,Followsets:()=>oo,ForumThread:()=>ss,GenericRepost:()=>ls,Genericlists:()=>io,GiftWrap:()=>ys,GroupMetadata:()=>_o,HTTPAuth:()=>so,Handlerinformation:()=>Bo,Handlerrecommendation:()=>Io,Highlights:()=>Ns,InterestsList:()=>Zs,Interestsets:()=>fo,JobFeedback:()=>_s,JobRequest:()=>Bs,JobResult:()=>Ls,Label:()=>Rs,LightningPubRPC:()=>Xs,LiveChatMessage:()=>xs,LiveEvent:()=>vo,LongFormArticle:()=>wo,Metadata:()=>Kr,Mutelist:()=>zs,NWCWalletInfo:()=>Qs,NWCWalletRequest:()=>to,NWCWalletResponse:()=>no,NormalVideo:()=>us,NostrConnect:()=>ro,OpenTimestamps:()=>bs,Photo:()=>cs,Pinlist:()=>qs,Poll:()=>ms,PollResponse:()=>Os,PrivateDirectMessage:()=>is,ProblemTracker:()=>As,ProfileBadges:()=>uo,PublicChatsList:()=>Ds,Reaction:()=>ts,RecommendRelay:()=>Gr,RelayList:()=>Ms,RelayReview:()=>Ro,Relaysets:()=>ao,Report:()=>Ts,Reporting:()=>$s,Repost:()=>es,Seal:()=>os,SearchRelaysList:()=>Vs,ShortTextNote:()=>Yr,ShortVideo:()=>hs,Time:()=>Ao,UserEmojiList:()=>Ks,UserStatuses:()=>ko,Voice:()=>Es,VoiceComment:()=>Ss,Zap:()=>Us,ZapGoal:()=>Ps,ZapRequest:()=>Cs,classifyKind:()=>Wr,isAddressableKind:()=>Vr,isEphemeralKind:()=>Fr,isKind:()=>Zr,isRegularKind:()=>jr,isReplaceableKind:()=>Dr});var Kr=0,Yr=1,Gr=2,Jr=3,Qr=4,Xr=5,es=6,ts=7,ns=8,rs=9,ss=11,os=13,is=14,as=15,ls=16,cs=20,us=21,hs=22,ds=40,fs=41,ps=42,gs=43,ws=44,bs=1040,ys=1059,ms=1068,vs=1063,ks=1111,xs=1311,Es=1222,Ss=1244,As=1971,Ts=1984,$s=1984,Rs=1985,Is=4550,Bs=5999,Ls=6999,_s=7e3,Ps=9041,Cs=9734,Us=9735,Ns=9802,Os=1018,zs=1e4,qs=10001,Ms=10002,Hs=10003,js=10004,Ds=10005,Fs=10006,Vs=10007,Ws=10012,Zs=10015,Ks=10030,Ys=10050,Gs=10096,Js=10063,Qs=13194,Xs=21e3,eo=22242,to=23194,no=23195,ro=24133,so=27235,oo=3e4,io=30001,ao=30002,lo=30003,co=30004,uo=30008,ho=30009,fo=30015,po=30017,go=30018,wo=30023,bo=30024,yo=30030,mo=30078,vo=30311,ko=30315,xo=30402,Eo=30403,So=31922,Ao=31923,To=31924,$o=31925,Ro=31987,Io=31989,Bo=31990,Lo=34550,_o=39e3;function Po(e,t){if(e.ids&&-1===e.ids.indexOf(t.id))return!1;if(e.kinds&&-1===e.kinds.indexOf(t.kind))return!1;if(e.authors&&-1===e.authors.indexOf(t.pubkey))return!1;for(let n in e)if("#"===n[0]){let r=e[`#${n.slice(1)}`];if(r&&!t.tags.find(([e,t])=>e===n.slice(1)&&-1!==r.indexOf(t)))return!1}return!(e.since&&t.created_at<e.since)&&!(e.until&&t.created_at>e.until)}function Co(e,t){let n=t.length+3,r=e.indexOf(`"${t}":`)+n,s=e.slice(r).indexOf('"')+r+1;return e.slice(s,s+64)}function Uo(e,t){let n=t.length,r=e.indexOf(`"${t}":`)+n+3,s=e.slice(r),o=Math.min(s.indexOf(","),s.indexOf("}"));return parseInt(s.slice(0,o),10)}function No(e){let t=e.slice(0,22).indexOf('"EVENT"');if(-1===t)return null;let n=e.slice(t+7+1).indexOf('"');if(-1===n)return null;let r=t+7+1+n,s=e.slice(r+1,80).indexOf('"');if(-1===s)return null;let o=r+1+s;return e.slice(r+1,o)}function Oo(e,t){return t===Co(e,"id")}function zo(e,t){return t===Co(e,"pubkey")}function qo(e,t){return t===Uo(e,"kind")}Ar({},{getHex64:()=>Co,getInt:()=>Uo,getSubscriptionId:()=>No,matchEventId:()=>Oo,matchEventKind:()=>qo,matchEventPubkey:()=>zo});function Mo(e,t){return{kind:eo,created_at:Math.floor(Date.now()/1e3),tags:[["relay",e],["challenge",t]],content:""}}async function Ho(){return new Promise((e,t)=>{try{if("undefined"!=typeof MessageChannel){const t=new MessageChannel,n=()=>{t.port1.removeEventListener("message",n),e()};t.port1.addEventListener("message",n),t.port2.postMessage(0),t.port1.start()}else"undefined"!=typeof setImmediate?setImmediate(e):"undefined"!=typeof setTimeout?setTimeout(e,0):e()}catch(e){console.error("during yield: ",e),t(e)}})}Ar({},{makeAuthEvent:()=>Mo});var jo=e=>(e[Tr]=!0,!0),Do=class extends Error{constructor(e,t){super(`Tried to send message '${e} on a closed connection to ${t}.`),this.name="SendingOnClosedConnection"}},Fo=class{url;_connected=!1;onclose=null;onnotice=e=>console.debug(`NOTICE from ${this.url}: ${e}`);onauth;baseEoseTimeout=4400;connectionTimeout=4400;publishTimeout=4400;pingFrequency=29e3;pingTimeout=2e4;resubscribeBackoff=[1e4,1e4,1e4,2e4,2e4,3e4,6e4];openSubs=new Map;enablePing;enableReconnect;connectionTimeoutHandle;reconnectTimeoutHandle;pingIntervalHandle;reconnectAttempts=0;closedIntentionally=!1;connectionPromise;openCountRequests=new Map;openEventPublishes=new Map;ws;incomingMessageQueue=new Ur;queueRunning=!1;challenge;authPromise;serial=0;verifyEvent;_WebSocket;constructor(e,t){this.url=Br(e),this.verifyEvent=t.verifyEvent,this._WebSocket=t.websocketImplementation||WebSocket,this.enablePing=t.enablePing,this.enableReconnect=t.enableReconnect||!1}static async connect(e,t){const n=new Fo(e,t);return await n.connect(),n}closeAllSubscriptions(e){for(let[t,n]of this.openSubs)n.close(e);this.openSubs.clear();for(let[t,n]of this.openEventPublishes)n.reject(new Error(e));this.openEventPublishes.clear();for(let[t,n]of this.openCountRequests)n.reject(new Error(e));this.openCountRequests.clear()}get connected(){return this._connected}async reconnect(){const e=this.resubscribeBackoff[Math.min(this.reconnectAttempts,this.resubscribeBackoff.length-1)];this.reconnectAttempts++,this.reconnectTimeoutHandle=setTimeout(async()=>{try{await this.connect()}catch(e){}},e)}handleHardClose(e){this.pingIntervalHandle&&(clearInterval(this.pingIntervalHandle),this.pingIntervalHandle=void 0),this._connected=!1,this.connectionPromise=void 0;const t=this.closedIntentionally;this.closedIntentionally=!1,this.onclose?.(),this.enableReconnect&&!t?this.reconnect():this.closeAllSubscriptions(e)}async connect(){return this.connectionPromise||(this.challenge=void 0,this.authPromise=void 0,this.connectionPromise=new Promise((e,t)=>{this.connectionTimeoutHandle=setTimeout(()=>{t("connection timed out"),this.connectionPromise=void 0,this.onclose?.(),this.closeAllSubscriptions("relay connection timed out")},this.connectionTimeout);try{this.ws=new this._WebSocket(this.url)}catch(e){return clearTimeout(this.connectionTimeoutHandle),void t(e)}this.ws.onopen=()=>{this.reconnectTimeoutHandle&&(clearTimeout(this.reconnectTimeoutHandle),this.reconnectTimeoutHandle=void 0),clearTimeout(this.connectionTimeoutHandle),this._connected=!0;const t=this.reconnectAttempts>0;this.reconnectAttempts=0;for(const e of this.openSubs.values()){if(e.eosed=!1,t)for(let t=0;t<e.filters.length;t++)e.lastEmitted&&(e.filters[t].since=e.lastEmitted+1);e.fire()}this.enablePing&&(this.pingIntervalHandle=setInterval(()=>this.pingpong(),this.pingFrequency)),e()},this.ws.onerror=e=>{clearTimeout(this.connectionTimeoutHandle),t(e.message||"websocket error"),this.handleHardClose("relay connection errored")},this.ws.onclose=e=>{clearTimeout(this.connectionTimeoutHandle),t(e.message||"websocket closed"),this.handleHardClose("relay connection closed")},this.ws.onmessage=this._onmessage.bind(this)})),this.connectionPromise}waitForPingPong(){return new Promise(e=>{this.ws.once("pong",()=>e(!0)),this.ws.ping()})}waitForDummyReq(){return new Promise((e,t)=>{if(!this.connectionPromise)return t(new Error(`no connection to ${this.url}, can't ping`));try{const t=this.subscribe([{ids:["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"],limit:0}],{label:"forced-ping",oneose:()=>{e(!0),t.close()},onclose(){e(!0)},eoseTimeout:this.pingTimeout+1e3})}catch(e){t(e)}})}async pingpong(){if(1===this.ws?.readyState){await Promise.any([this.ws&&this.ws.ping&&this.ws.once?this.waitForPingPong():this.waitForDummyReq(),new Promise(e=>setTimeout(()=>e(!1),this.pingTimeout))])||this.ws?.readyState===this._WebSocket.OPEN&&this.ws?.close()}}async runQueue(){for(this.queueRunning=!0;!1!==this.handleNext();)await Ho();this.queueRunning=!1}handleNext(){const e=this.incomingMessageQueue.dequeue();if(!e)return!1;const t=No(e);if(t){const n=this.openSubs.get(t);if(!n)return;const r=Co(e,"id"),s=n.alreadyHaveEvent?.(r);if(n.receivedEvent?.(this,r),s)return}try{let t=JSON.parse(e);switch(t[0]){case"EVENT":{const e=this.openSubs.get(t[1]),n=t[2];return this.verifyEvent(n)&&function(e,t){for(let n=0;n<e.length;n++)if(Po(e[n],t))return!0;return!1}(e.filters,n)&&e.onevent(n),void((!e.lastEmitted||e.lastEmitted<n.created_at)&&(e.lastEmitted=n.created_at))}case"COUNT":{const e=t[1],n=t[2],r=this.openCountRequests.get(e);return void(r&&(r.resolve(n.count),this.openCountRequests.delete(e)))}case"EOSE":{const e=this.openSubs.get(t[1]);if(!e)return;return void e.receivedEose()}case"OK":{const e=t[1],n=t[2],r=t[3],s=this.openEventPublishes.get(e);return void(s&&(clearTimeout(s.timeout),n?s.resolve(r):s.reject(new Error(r)),this.openEventPublishes.delete(e)))}case"CLOSED":{const e=t[1],n=this.openSubs.get(e);if(!n)return;return n.closed=!0,void n.close(t[2])}case"NOTICE":return void this.onnotice(t[1]);case"AUTH":return this.challenge=t[1],void(this.onauth&&this.auth(this.onauth));default:{const e=this.openSubs.get(t[1]);return void e?.oncustom?.(t)}}}catch(e){return}}async send(e){if(!this.connectionPromise)throw new Do(e,this.url);this.connectionPromise.then(()=>{this.ws?.send(e)})}async auth(e){const t=this.challenge;if(!t)throw new Error("can't perform auth, no challenge was received");return this.authPromise||(this.authPromise=new Promise(async(n,r)=>{try{let s=await e(Mo(this.url,t)),o=setTimeout(()=>{let e=this.openEventPublishes.get(s.id);e&&(e.reject(new Error("auth timed out")),this.openEventPublishes.delete(s.id))},this.publishTimeout);this.openEventPublishes.set(s.id,{resolve:n,reject:r,timeout:o}),this.send('["AUTH",'+JSON.stringify(s)+"]")}catch(e){console.warn("subscribe auth function failed:",e)}})),this.authPromise}async publish(e){const t=new Promise((t,n)=>{const r=setTimeout(()=>{const t=this.openEventPublishes.get(e.id);t&&(t.reject(new Error("publish timed out")),this.openEventPublishes.delete(e.id))},this.publishTimeout);this.openEventPublishes.set(e.id,{resolve:t,reject:n,timeout:r})});return this.send('["EVENT",'+JSON.stringify(e)+"]"),t}async count(e,t){this.serial++;const n=t?.id||"count:"+this.serial,r=new Promise((e,t)=>{this.openCountRequests.set(n,{resolve:e,reject:t})});return this.send('["COUNT","'+n+'",'+JSON.stringify(e).substring(1)),r}subscribe(e,t){const n=this.prepareSubscription(e,t);return n.fire(),n}prepareSubscription(e,t){this.serial++;const n=t.id||(t.label?t.label+":":"sub:")+this.serial,r=new Vo(this,n,e,t);return this.openSubs.set(n,r),r}close(){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,this.onclose?.(),this.ws?.readyState===this._WebSocket.OPEN&&this.ws?.close()}_onmessage(e){this.incomingMessageQueue.enqueue(e.data),this.queueRunning||this.runQueue()}},Vo=class{relay;id;lastEmitted;closed=!1;eosed=!1;filters;alreadyHaveEvent;receivedEvent;onevent;oneose;onclose;oncustom;eoseTimeout;eoseTimeoutHandle;constructor(e,t,n,r){if(0===n.length)throw new Error("subscription can't be created with zero filters");this.relay=e,this.filters=n,this.id=t,this.alreadyHaveEvent=r.alreadyHaveEvent,this.receivedEvent=r.receivedEvent,this.eoseTimeout=r.eoseTimeout||e.baseEoseTimeout,this.oneose=r.oneose,this.onclose=r.onclose,this.onevent=r.onevent||(e=>{console.warn(`onevent() callback not defined for subscription '${this.id}' in relay ${this.relay.url}. event received:`,e)})}fire(){this.relay.send('["REQ","'+this.id+'",'+JSON.stringify(this.filters).substring(1)),this.eoseTimeoutHandle=setTimeout(this.receivedEose.bind(this),this.eoseTimeout)}receivedEose(){this.eosed||(clearTimeout(this.eoseTimeoutHandle),this.eosed=!0,this.oneose?.())}close(e="closed by caller"){if(!this.closed&&this.relay.connected){try{this.relay.send('["CLOSE",'+JSON.stringify(this.id)+"]")}catch(e){if(!(e instanceof Do))throw e}this.closed=!0}this.relay.openSubs.delete(this.id),this.onclose?.(e)}};try{WebSocket}catch{}var Wo,Zo=class{relays=new Map;seenOn=new Map;trackRelays=!1;verifyEvent;enablePing;enableReconnect;automaticallyAuth;trustedRelayURLs=new Set;_WebSocket;constructor(e){this.verifyEvent=e.verifyEvent,this._WebSocket=e.websocketImplementation,this.enablePing=e.enablePing,this.enableReconnect=e.enableReconnect||!1,this.automaticallyAuth=e.automaticallyAuth}async ensureRelay(e,t){e=Br(e);let n=this.relays.get(e);if(n||(n=new Fo(e,{verifyEvent:this.trustedRelayURLs.has(e)?jo:this.verifyEvent,websocketImplementation:this._WebSocket,enablePing:this.enablePing,enableReconnect:this.enableReconnect}),n.onclose=()=>{n&&!n.enableReconnect&&this.relays.delete(e)},t?.connectionTimeout&&(n.connectionTimeout=t.connectionTimeout),this.relays.set(e,n)),this.automaticallyAuth){const t=this.automaticallyAuth(e);t&&(n.onauth=t)}return await n.connect(),n}close(e){e.map(Br).forEach(e=>{this.relays.get(e)?.close(),this.relays.delete(e)})}subscribe(e,t,n){const r=[];for(let n=0;n<e.length;n++){const s=Br(e[n]);r.find(e=>e.url===s)||r.push({url:s,filter:t})}return this.subscribeMap(r,n)}subscribeMany(e,t,n){const r=[],s=[];for(let n=0;n<e.length;n++){const o=Br(e[n]);-1===s.indexOf(o)&&(s.push(o),r.push({url:o,filter:t}))}return this.subscribeMap(r,n)}subscribeMap(e,t){const n=new Map;for(const t of e){const{url:e,filter:r}=t;n.has(e)||n.set(e,[]),n.get(e).push(r)}const r=Array.from(n.entries()).map(([e,t])=>({url:e,filters:t}));this.trackRelays&&(t.receivedEvent=(e,t)=>{let n=this.seenOn.get(t);n||(n=new Set,this.seenOn.set(t,n)),n.add(e)});const s=new Set,o=[],i=[];let a=e=>{i[e]||(i[e]=!0,i.filter(e=>e).length===r.length&&(t.oneose?.(),a=()=>{}))};const l=[];let c=(e,n)=>{l[e]||(a(e),l[e]=n,l.filter(e=>e).length===r.length&&(t.onclose?.(l),c=()=>{}))};const u=e=>{if(t.alreadyHaveEvent?.(e))return!0;const n=s.has(e);return s.add(e),n},h=Promise.all(r.map(async({url:e,filters:n},r)=>{let s;try{s=await this.ensureRelay(e,{connectionTimeout:t.maxWait?Math.max(.8*t.maxWait,t.maxWait-1e3):void 0})}catch(e){return void c(r,e?.message||String(e))}let i=s.subscribe(n,{...t,oneose:()=>a(r),onclose:e=>{e.startsWith("auth-required: ")&&t.onauth?s.auth(t.onauth).then(()=>{s.subscribe(n,{...t,oneose:()=>a(r),onclose:e=>{c(r,e)},alreadyHaveEvent:u,eoseTimeout:t.maxWait})}).catch(e=>{c(r,`auth was required and attempted, but failed with: ${e}`)}):c(r,e)},alreadyHaveEvent:u,eoseTimeout:t.maxWait});o.push(i)}));return{async close(e){await h,o.forEach(t=>{t.close(e)})}}}subscribeEose(e,t,n){const r=this.subscribe(e,t,{...n,oneose(){r.close("closed automatically on eose")}});return r}subscribeManyEose(e,t,n){const r=this.subscribeMany(e,t,{...n,oneose(){r.close("closed automatically on eose")}});return r}async querySync(e,t,n){return new Promise(async r=>{const s=[];this.subscribeEose(e,t,{...n,onevent(e){s.push(e)},onclose(e){r(s)}})})}async get(e,t,n){t.limit=1;const r=await this.querySync(e,t,n);return r.sort((e,t)=>t.created_at-e.created_at),r[0]||null}publish(e,t,n){return e.map(Br).map(async(e,r,s)=>{if(s.indexOf(e)!==r)return Promise.reject("duplicate url");let o=await this.ensureRelay(e);return o.publish(t).catch(async e=>{if(e instanceof Error&&e.message.startsWith("auth-required: ")&&n?.onauth)return await o.auth(n.onauth),o.publish(t);throw e}).then(e=>{if(this.trackRelays){let e=this.seenOn.get(t.id);e||(e=new Set,this.seenOn.set(t.id,e)),e.add(o)}return e})})}listConnectionStatus(){const e=new Map;return this.relays.forEach((t,n)=>e.set(n,t.connected)),e}destroy(){this.relays.forEach(e=>e.close()),this.relays=new Map}};try{Wo=WebSocket}catch{}var Ko=class extends Zo{constructor(e){super({verifyEvent:Hr,websocketImplementation:Wo,...e})}},Yo={};Ar(Yo,{BECH32_REGEX:()=>Qo,Bech32MaxSize:()=>Jo,NostrTypeGuard:()=>Go,decode:()=>ei,decodeNostrURI:()=>Xo,encodeBytes:()=>ii,naddrEncode:()=>ci,neventEncode:()=>li,noteEncode:()=>si,nprofileEncode:()=>ai,npubEncode:()=>ri,nsecEncode:()=>ni});var Go={isNProfile:e=>/^nprofile1[a-z\d]+$/.test(e||""),isNEvent:e=>/^nevent1[a-z\d]+$/.test(e||""),isNAddr:e=>/^naddr1[a-z\d]+$/.test(e||""),isNSec:e=>/^nsec1[a-z\d]{58}$/.test(e||""),isNPub:e=>/^npub1[a-z\d]{58}$/.test(e||""),isNote:e=>/^note1[a-z\d]+$/.test(e||""),isNcryptsec:e=>/^ncryptsec1[a-z\d]+$/.test(e||"")},Jo=5e3,Qo=/[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;function Xo(e){try{return e.startsWith("nostr:")&&(e=e.substring(6)),ei(e)}catch(e){return{type:"invalid",data:null}}}function ei(e){let{prefix:t,words:n}=Ht.decode(e,Jo),r=new Uint8Array(Ht.fromWords(n));switch(t){case"nprofile":{let e=ti(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for nprofile");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:Ye(e[0][0]),relays:e[1]?e[1].map(e=>Rr.decode(e)):[]}}}case"nevent":{let e=ti(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for nevent");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");if(e[2]&&32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(e[3]&&4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"nevent",data:{id:Ye(e[0][0]),relays:e[1]?e[1].map(e=>Rr.decode(e)):[],author:e[2]?.[0]?Ye(e[2][0]):void 0,kind:e[3]?.[0]?parseInt(Ye(e[3][0]),16):void 0}}}case"naddr":{let e=ti(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for naddr");if(!e[2]?.[0])throw new Error("missing TLV 2 for naddr");if(32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(!e[3]?.[0])throw new Error("missing TLV 3 for naddr");if(4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:Rr.decode(e[0][0]),pubkey:Ye(e[2][0]),kind:parseInt(Ye(e[3][0]),16),relays:e[1]?e[1].map(e=>Rr.decode(e)):[]}}}case"nsec":return{type:t,data:r};case"npub":case"note":return{type:t,data:Ye(r)};default:throw new Error(`unknown prefix ${t}`)}}function ti(e){let t={},n=e;for(;n.length>0;){let e=n[0],r=n[1],s=n.slice(2,2+r);if(n=n.slice(2+r),s.length<r)throw new Error(`not enough data to read on TLV ${e}`);t[e]=t[e]||[],t[e].push(s)}return t}function ni(e){return ii("nsec",e)}function ri(e){return ii("npub",Ge(e))}function si(e){return ii("note",Ge(e))}function oi(e,t){let n=Ht.toWords(t);return Ht.encode(e,n,Jo)}function ii(e,t){return oi(e,t)}function ai(e){return oi("nprofile",ui({0:[Ge(e.pubkey)],1:(e.relays||[]).map(e=>Ir.encode(e))}))}function li(e){let t;return void 0!==e.kind&&(t=function(e){const t=new Uint8Array(4);return t[0]=e>>24&255,t[1]=e>>16&255,t[2]=e>>8&255,t[3]=255&e,t}(e.kind)),oi("nevent",ui({0:[Ge(e.id)],1:(e.relays||[]).map(e=>Ir.encode(e)),2:e.author?[Ge(e.author)]:[],3:t?[new Uint8Array(t)]:[]}))}function ci(e){let t=new ArrayBuffer(4);return new DataView(t).setUint32(0,e.kind,!1),oi("naddr",ui({0:[Ir.encode(e.identifier)],1:(e.relays||[]).map(e=>Ir.encode(e)),2:[Ge(e.pubkey)],3:[new Uint8Array(t)]}))}function ui(e){let t=[];return Object.entries(e).reverse().forEach(([e,n])=>{n.forEach(n=>{let r=new Uint8Array(n.length+2);r.set([parseInt(e)],0),r.set([n.length],1),r.set(n,2),t.push(r)})}),Qe(...t)}function hi(e,t,n){const r=e instanceof Uint8Array?Ye(e):e,s=fi($e.getSharedSecret(r,"02"+t));let o=Uint8Array.from(tt(16)),i=Ir.encode(n),a=Kn(s,o).encrypt(i);return`${Bt.encode(new Uint8Array(a))}?iv=${Bt.encode(new Uint8Array(o.buffer))}`}function di(e,t,n){const r=e instanceof Uint8Array?Ye(e):e;let[s,o]=n.split("?iv="),i=fi($e.getSharedSecret(r,"02"+t)),a=Bt.decode(o),l=Bt.decode(s),c=Kn(i,a).decrypt(l);return Rr.decode(c)}function fi(e){return e.slice(1,33)}Ar({},{decrypt:()=>di,encrypt:()=>hi});Ar({},{NIP05_REGEX:()=>gi,isNip05:()=>wi,isValid:()=>vi,queryProfile:()=>mi,searchDomain:()=>yi,useFetchImplementation:()=>bi});var pi,gi=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,wi=e=>gi.test(e||"");try{pi=fetch}catch(e){}function bi(e){pi=e}async function yi(e,t=""){try{const n=`https://${e}/.well-known/nostr.json?name=${t}`,r=await pi(n,{redirect:"manual"});if(200!==r.status)throw Error("Wrong response code");return(await r.json()).names}catch(e){return{}}}async function mi(e){const t=e.match(gi);if(!t)return null;const[,n="_",r]=t;try{const e=`https://${r}/.well-known/nostr.json?name=${n}`,t=await pi(e,{redirect:"manual"});if(200!==t.status)throw Error("Wrong response code");const s=await t.json(),o=s.names[n];return o?{pubkey:o,relays:s.relays?.[o]}:null}catch(e){return null}}async function vi(e,t){const n=await mi(t);return!!n&&n.pubkey===e}function ki(e){const t={reply:void 0,root:void 0,mentions:[],profiles:[],quotes:[]};let n,r;for(let s=e.tags.length-1;s>=0;s--){const o=e.tags[s];if("e"===o[0]&&o[1]){const[e,s,i,a,l]=o,c={id:s,relays:i?[i]:[],author:l};if("root"===a){t.root=c;continue}if("reply"===a){t.reply=c;continue}if("mention"===a){t.mentions.push(c);continue}n?r=c:n=c,t.mentions.push(c);continue}if("q"===o[0]&&o[1]){const[e,n,r]=o;t.quotes.push({id:n,relays:r?[r]:[]})}"p"===o[0]&&o[1]&&t.profiles.push({pubkey:o[1],relays:o[2]?[o[2]]:[]})}return t.root||(t.root=r||n||t.reply),t.reply||(t.reply=n||t.root),[t.reply,t.root].forEach(e=>{if(!e)return;let n=t.mentions.indexOf(e);if(-1!==n&&t.mentions.splice(n,1),e.author){let n=t.profiles.find(t=>t.pubkey===e.author);n&&n.relays&&(e.relays||(e.relays=[]),n.relays.forEach(t=>{-1===e.relays?.indexOf(t)&&e.relays.push(t)}),n.relays=e.relays)}}),t.mentions.forEach(e=>{if(e.author){let n=t.profiles.find(t=>t.pubkey===e.author);n&&n.relays&&(e.relays||(e.relays=[]),n.relays.forEach(t=>{-1===e.relays.indexOf(t)&&e.relays.push(t)}),n.relays=e.relays)}}),t}Ar({},{parse:()=>ki});Ar({},{fetchRelayInformation:()=>Ei,useFetchImplementation:()=>xi});try{fetch}catch{}function xi(e){0}async function Ei(e){return await(await fetch(e.replace("ws://","http://").replace("wss://","https://"),{headers:{Accept:"application/nostr+json"}})).json()}function Si(e){let t=0;for(let n=0;n<64;n+=8){const r=parseInt(e.substring(n,n+8),16);if(0!==r){t+=Math.clz32(r);break}t+=32}return t}function Ai(e,t){let n=0;const r=e,s=["nonce",n.toString(),t.toString()];for(r.tags.push(s);;){const e=Math.floor((new Date).getTime()/1e3);if(e!==r.created_at&&(n=0,r.created_at=e),s[1]=(++n).toString(),r.id=Ti(r),Si(r.id)>=t)break}return r}function Ti(e){return Ye(pt(Ir.encode(JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content]))))}Ar({},{fastEventHash:()=>Ti,getPow:()=>Si,minePow:()=>Ai});Ar({},{unwrapEvent:()=>Yi,unwrapManyEvents:()=>Gi,wrapEvent:()=>Zi,wrapManyEvents:()=>Ki});Ar({},{createRumor:()=>Mi,createSeal:()=>Hi,createWrap:()=>ji,unwrapEvent:()=>Vi,unwrapManyEvents:()=>Wi,wrapEvent:()=>Di,wrapManyEvents:()=>Fi});Ar({},{decrypt:()=>Pi,encrypt:()=>_i,getConversationKey:()=>$i,v2:()=>Ci});function $i(e,t){const n=$e.getSharedSecret(e,"02"+t).subarray(1,33);return vr(pt,n,"nip44-v2")}function Ri(e,t){const n=Er(pt,e,t,76);return{chacha_key:n.subarray(0,32),chacha_nonce:n.subarray(32,44),hmac_key:n.subarray(44,76)}}function Ii(e){if(!Number.isSafeInteger(e)||e<1)throw new Error("expected positive integer");if(e<=32)return 32;const t=1<<Math.floor(Math.log2(e-1))+1,n=t<=256?32:t/8;return n*(Math.floor((e-1)/n)+1)}function Bi(e){const t=Ir.encode(e),n=t.length;return Qe(function(e){if(!Number.isSafeInteger(e)||e<1||e>65535)throw new Error("invalid plaintext size: must be between 1 and 65535 bytes");const t=new Uint8Array(2);return new DataView(t.buffer).setUint16(0,e,!1),t}(n),t,new Uint8Array(Ii(n)-n))}function Li(e,t,n){if(32!==n.length)throw new Error("AAD associated data must be 32 bytes");const r=Qe(n,t);return mr(pt,e,r)}function _i(e,t,n=tt(32)){const{chacha_key:r,chacha_nonce:s,hmac_key:o}=Ri(t,n),i=Bi(e),a=hr(r,s,i),l=Li(o,a,n);return Bt.encode(Qe(new Uint8Array([2]),n,a,l))}function Pi(e,t){const{nonce:n,ciphertext:r,mac:s}=function(e){if("string"!=typeof e)throw new Error("payload must be a valid string");const t=e.length;if(t<132||t>87472)throw new Error("invalid payload length: "+t);if("#"===e[0])throw new Error("unknown encryption version");let n;try{n=Bt.decode(e)}catch(e){throw new Error("invalid base64: "+e.message)}const r=n.length;if(r<99||r>65603)throw new Error("invalid data length: "+r);const s=n[0];if(2!==s)throw new Error("unknown encryption version "+s);return{nonce:n.subarray(1,33),ciphertext:n.subarray(33,-32),mac:n.subarray(-32)}}(e),{chacha_key:o,chacha_nonce:i,hmac_key:a}=Ri(t,n);if(!un(Li(a,r,n),s))throw new Error("invalid MAC");return function(e){const t=new DataView(e.buffer).getUint16(0),n=e.subarray(2,2+t);if(t<1||t>65535||n.length!==t||e.length!==2+Ii(t))throw new Error("invalid padding");return Rr.decode(n)}(hr(o,i,r))}var Ci={utils:{getConversationKey:$i,calcPaddedLen:Ii},encrypt:_i,decrypt:Pi},Ui=()=>Math.round(Date.now()/1e3),Ni=()=>Math.round(Ui()-172800*Math.random()),Oi=(e,t)=>$i(e,t),zi=(e,t,n)=>_i(JSON.stringify(e),Oi(t,n)),qi=(e,t)=>JSON.parse(Pi(e.content,Oi(t,e.pubkey)));function Mi(e,t){const n={created_at:Ui(),content:"",tags:[],...e,pubkey:qr(t)};return n.id=Nr(n),n}function Hi(e,t,n){return Mr({kind:os,content:zi(e,t,n),created_at:Ni(),tags:[]},t)}function ji(e,t){const n=zr();return Mr({kind:ys,content:zi(e,n,t),created_at:Ni(),tags:[["p",t]]},n)}function Di(e,t,n){return ji(Hi(Mi(e,t),t,n),n)}function Fi(e,t,n){if(!n||0===n.length)throw new Error("At least one recipient is required.");const r=qr(t),s=[Di(e,t,r)];return n.forEach(n=>{s.push(Di(e,t,n))}),s}function Vi(e,t){const n=qi(e,t);return qi(n,t)}function Wi(e,t){let n=[];return e.forEach(e=>{n.push(Vi(e,t))}),n.sort((e,t)=>e.created_at-t.created_at),n}function Zi(e,t,n,r,s){const o=function(e,t,n,r){const s={created_at:Math.ceil(Date.now()/1e3),kind:is,tags:[],content:t};return(Array.isArray(e)?e:[e]).forEach(({publicKey:e,relayUrl:t})=>{s.tags.push(t?["p",e,t]:["p",e])}),r&&s.tags.push(["e",r.eventId,r.relayUrl||"","reply"]),n&&s.tags.push(["subject",n]),s}(t,n,r,s);return Di(o,e,t.publicKey)}function Ki(e,t,n,r,s){if(!t||0===t.length)throw new Error("At least one recipient is required.");return[{publicKey:qr(e)},...t].map(t=>Zi(e,t,n,r,s))}var Yi=Vi,Gi=Wi;function Ji(e,t,n,r){let s;const o=[...e.tags??[],["e",t.id,n],["p",t.pubkey]];return t.kind===Yr?s=es:(s=ls,o.push(["k",String(t.kind)])),Mr({kind:s,tags:o,content:""===e.content||t.tags?.find(e=>"-"===e[0])?"":JSON.stringify(t),created_at:e.created_at},r)}function Qi(e){if(![es,ls].includes(e.kind))return;let t,n;for(let r=e.tags.length-1;r>=0&&(void 0===t||void 0===n);r--){const s=e.tags[r];s.length>=2&&("e"===s[0]&&void 0===t?t=s:"p"===s[0]&&void 0===n&&(n=s))}return void 0!==t?{id:t[1],relays:[t[2],n?.[2]].filter(e=>"string"==typeof e),author:n?.[1]}:void 0}function Xi(e,{skipVerification:t}={}){const n=Qi(e);if(void 0===n||""===e.content)return;let r;try{r=JSON.parse(e.content)}catch(e){return}return r.id===n.id&&(t||Hr(r))?r:void 0}Ar({},{finishRepostEvent:()=>Ji,getRepostedEvent:()=>Xi,getRepostedEventPointer:()=>Qi});Ar({},{NOSTR_URI_REGEX:()=>ea,parse:()=>na,test:()=>ta});var ea=new RegExp(`nostr:(${Qo.source})`);function ta(e){return"string"==typeof e&&new RegExp(`^${ea.source}$`).test(e)}function na(e){const t=e.match(new RegExp(`^${ea.source}$`));if(!t)throw new Error(`Invalid Nostr URI: ${e}`);return{uri:t[0],value:t[1],decoded:ei(t[1])}}function ra(e,t,n){const r=t.tags.filter(e=>e.length>=2&&("e"===e[0]||"p"===e[0]));return Mr({...e,kind:ts,tags:[...e.tags??[],...r,["e",t.id],["p",t.pubkey]],content:e.content??"+"},n)}function sa(e){if(e.kind!==ts)return;let t,n;for(let r=e.tags.length-1;r>=0&&(void 0===t||void 0===n);r--){const s=e.tags[r];s.length>=2&&("e"===s[0]&&void 0===t?t=s:"p"===s[0]&&void 0===n&&(n=s))}return void 0!==t&&void 0!==n?{id:t[1],relays:[t[2],n[2]].filter(e=>void 0!==e),author:n[1]}:void 0}Ar({},{finishReactionEvent:()=>ra,getReactedEventPointer:()=>sa});Ar({},{parse:()=>aa});var oa=/\W/m,ia=/[^\w\/] |[^\w\/]$|$|,| /m;function*aa(e){let t=[];if("string"!=typeof e){for(let n=0;n<e.tags.length;n++){const r=e.tags[n];"emoji"===r[0]&&r.length>=3&&t.push({type:"emoji",shortcode:r[1],url:r[2]})}e=e.content}const n=e.length;let r=0,s=0;e:for(;s<n;){const o=e.indexOf(":",s),i=e.indexOf("#",s);if(-1===o&&-1===i)break e;if(-1===o||i>=0&&i<o){if(0===i||" "===e[i-1]){const t=e.slice(i+1,i+42).match(oa),o=t?i+1+t.index:n;yield{type:"text",text:e.slice(r,i)},yield{type:"hashtag",value:e.slice(i+1,o)},s=o,r=s;continue e}s=i+1}else if("nostr"===e.slice(o-5,o)){const t=e.slice(o+60).match(oa),i=t?o+60+t.index:n;try{let t,{data:n,type:a}=ei(e.slice(o+1,i));switch(a){case"npub":t={pubkey:n};break;case"note":t={id:n};break;case"nsec":s=i+1;continue;default:t=n}r!==o-5&&(yield{type:"text",text:e.slice(r,o-5)}),yield{type:"reference",pointer:t},s=i,r=s;continue e}catch(e){s=o+1;continue e}}else if("https"===e.slice(o-5,o)||"http"===e.slice(o-4,o)){const t=e.slice(o+4).match(ia),i=t?o+4+t.index:n,a="s"===e[o-1]?5:4;try{let t=new URL(e.slice(o-a,i));if(-1===t.hostname.indexOf("."))throw new Error("invalid url");if(r!==o-a&&(yield{type:"text",text:e.slice(r,o-a)}),/\.(png|jpe?g|gif|webp|heic|svg)$/i.test(t.pathname)){yield{type:"image",url:t.toString()},s=i,r=s;continue e}if(/\.(mp4|avi|webm|mkv|mov)$/i.test(t.pathname)){yield{type:"video",url:t.toString()},s=i,r=s;continue e}if(/\.(mp3|aac|ogg|opus|wav|flac)$/i.test(t.pathname)){yield{type:"audio",url:t.toString()},s=i,r=s;continue e}yield{type:"url",url:t.toString()},s=i,r=s;continue e}catch(e){s=i+1;continue e}}else{if("wss"!==e.slice(o-3,o)&&"ws"!==e.slice(o-2,o)){for(let n=0;n<t.length;n++){const i=t[n];if(":"===e[o+i.shortcode.length+1]&&e.slice(o+1,o+i.shortcode.length+1)===i.shortcode){r!==o&&(yield{type:"text",text:e.slice(r,o)}),yield i,s=o+i.shortcode.length+2,r=s;continue e}}s=o+1;continue e}{const t=e.slice(o+4).match(ia),i=t?o+4+t.index:n,a="s"===e[o-1]?3:2;try{let t=new URL(e.slice(o-a,i));if(-1===t.hostname.indexOf("."))throw new Error("invalid ws url");r!==o-a&&(yield{type:"text",text:e.slice(r,o-a)}),yield{type:"relay",url:t.toString()},s=i,r=s;continue e}catch(e){s=i+1;continue e}}}}r!==n&&(yield{type:"text",text:e.slice(r)})}Ar({},{channelCreateEvent:()=>la,channelHideMessageEvent:()=>ha,channelMessageEvent:()=>ua,channelMetadataEvent:()=>ca,channelMuteUserEvent:()=>da});var la=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return Mr({kind:ds,tags:[...e.tags??[]],content:n,created_at:e.created_at},t)},ca=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return Mr({kind:fs,tags:[["e",e.channel_create_event_id],...e.tags??[]],content:n,created_at:e.created_at},t)},ua=(e,t)=>{const n=[["e",e.channel_create_event_id,e.relay_url,"root"]];return e.reply_to_channel_message_event_id&&n.push(["e",e.reply_to_channel_message_event_id,e.relay_url,"reply"]),Mr({kind:ps,tags:[...n,...e.tags??[]],content:e.content,created_at:e.created_at},t)},ha=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return Mr({kind:gs,tags:[["e",e.channel_message_event_id],...e.tags??[]],content:n,created_at:e.created_at},t)},da=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return Mr({kind:ws,tags:[["p",e.pubkey_to_mute],...e.tags??[]],content:n,created_at:e.created_at},t)};Ar({},{EMOJI_SHORTCODE_REGEX:()=>fa,matchAll:()=>ga,regex:()=>pa,replaceAll:()=>wa});var fa=/:(\w+):/,pa=()=>new RegExp(`\\B${fa.source}\\B`,"g");function*ga(e){const t=e.matchAll(pa());for(const e of t)try{const[t,n]=e;yield{shortcode:t,name:n,start:e.index,end:e.index+t.length}}catch(e){}}function wa(e,t){return e.replaceAll(pa(),(e,n)=>t({shortcode:e,name:n}))}var ba;Ar({},{useFetchImplementation:()=>ya,validateGithub:()=>ma});try{ba=fetch}catch{}function ya(e){ba=e}async function ma(e,t,n){try{return await(await ba(`https://gist.github.com/${t}/${n}/raw`)).text()===`Verifying that I control the following Nostr public key: ${e}`}catch(e){return!1}}function va(e){const{host:t,pathname:n,searchParams:r}=new URL(e),s=n||t,o=r.get("relay"),i=r.get("secret");if(!s||!o||!i)throw new Error("invalid connection string");return{pubkey:s,relay:o,secret:i}}async function ka(e,t,n){const r={method:"pay_invoice",params:{invoice:n}},s=hi(t,e,JSON.stringify(r)),o={kind:to,created_at:Math.round(Date.now()/1e3),content:s,tags:[["p",e]]};return Mr(o,t)}Ar({},{makeNwcRequestEvent:()=>ka,parseConnectionString:()=>va});function xa(e){return e=(e=e.trim().toLowerCase()).normalize("NFKC"),Array.from(e).map(e=>/\p{Letter}/u.test(e)||/\p{Number}/u.test(e)?e:"-").join("")}Ar({},{normalizeIdentifier:()=>xa});var Ea;Ar({},{getSatoshisAmountFromBolt11:()=>Ia,getZapEndpoint:()=>Aa,makeZapReceipt:()=>Ra,makeZapRequest:()=>Ta,useFetchImplementation:()=>Sa,validateZapRequest:()=>$a});try{Ea=fetch}catch{}function Sa(e){Ea=e}async function Aa(e){try{let t="",{lud06:n,lud16:r}=JSON.parse(e.content);if(r){let[e,n]=r.split("@");t=new URL(`/.well-known/lnurlp/${e}`,`https://${n}`).toString()}else{if(!n)return null;{let{words:e}=Ht.decode(n,1e3),r=Ht.fromWords(e);t=Rr.decode(r)}}let s=await Ea(t),o=await s.json();if(o.allowsNostr&&o.nostrPubkey)return o.callback}catch(e){}return null}function Ta(e){let t={kind:9734,created_at:Math.round(Date.now()/1e3),content:e.comment||"",tags:[["p","pubkey"in e?e.pubkey:e.event.pubkey],["amount",e.amount.toString()],["relays",...e.relays]]};if("event"in e){if(t.tags.push(["e",e.event.id]),Dr(e.event.kind)){const n=["a",`${e.event.kind}:${e.event.pubkey}:`];t.tags.push(n)}else if(Vr(e.event.kind)){let n=e.event.tags.find(([e,t])=>"d"===e&&t);if(!n)throw new Error("d tag not found or is empty");const r=["a",`${e.event.kind}:${e.event.pubkey}:${n[1]}`];t.tags.push(r)}t.tags.push(["k",e.event.kind.toString()])}return t}function $a(e){let t;try{t=JSON.parse(e)}catch(e){return"Invalid zap request JSON."}if(!$r(t))return"Zap request is not a valid Nostr event.";if(!Hr(t))return"Invalid signature on zap request.";let n=t.tags.find(([e,t])=>"p"===e&&t);if(!n)return"Zap request doesn't have a 'p' tag.";if(!n[1].match(/^[a-f0-9]{64}$/))return"Zap request 'p' tag is not valid hex.";let r=t.tags.find(([e,t])=>"e"===e&&t);if(r&&!r[1].match(/^[a-f0-9]{64}$/))return"Zap request 'e' tag is not valid hex.";let s=t.tags.find(([e,t])=>"relays"===e&&t);return s?null:"Zap request doesn't have a 'relays' tag."}function Ra({zapRequest:e,preimage:t,bolt11:n,paidAt:r}){let s=JSON.parse(e),o=s.tags.filter(([e])=>"e"===e||"p"===e||"a"===e),i={kind:9735,created_at:Math.round(r.getTime()/1e3),content:"",tags:[...o,["P",s.pubkey],["bolt11",n],["description",e]]};return t&&i.tags.push(["preimage",t]),i}function Ia(e){if(e.length<50)return 0;const t=(e=e.substring(0,50)).lastIndexOf("1");if(-1===t)return 0;const n=e.substring(0,t);if(!n.startsWith("lnbc"))return 0;const r=n.substring(4);if(r.length<1)return 0;const s=r[r.length-1],o=s.charCodeAt(0)-"0".charCodeAt(0),i=o>=0&&o<=9;let a=r.length-1;if(i&&a++,a<1)return 0;const l=parseInt(r.substring(0,a));switch(s){case"m":return 1e5*l;case"u":return 100*l;case"n":return l/10;case"p":return l/1e4;default:return 1e8*l}}Ar({},{Negentropy:()=>Ma,NegentropyStorageVector:()=>qa,NegentropySync:()=>Da});var Ba=32,La=0,_a=1,Pa=2,Ca=class{_raw;length;constructor(e){"number"==typeof e?(this._raw=new Uint8Array(e),this.length=0):e instanceof Uint8Array?(this._raw=new Uint8Array(e),this.length=e.length):(this._raw=new Uint8Array(512),this.length=0)}unwrap(){return this._raw.subarray(0,this.length)}get capacity(){return this._raw.byteLength}extend(e){if(e instanceof Ca&&(e=e.unwrap()),"number"!=typeof e.length)throw Error("bad length");const t=e.length+this.length;if(this.capacity<t){const e=this._raw,n=Math.max(2*this.capacity,t);this._raw=new Uint8Array(n),this._raw.set(e)}this._raw.set(e,this.length),this.length+=e.length}shift(){const e=this._raw[0];return this._raw=this._raw.subarray(1),this.length--,e}shiftN(e=1){const t=this._raw.subarray(0,e);return this._raw=this._raw.subarray(e),this.length-=e,t}};function Ua(e){let t=0;for(;;){if(0===e.length)throw Error("parse ends prematurely");let n=e.shift();if(t=t<<7|127&n,!(128&n))break}return t}function Na(e){if(0===e)return new Ca(new Uint8Array([0]));let t=[];for(;0!==e;)t.push(127&e),e>>>=7;t.reverse();for(let e=0;e<t.length-1;e++)t[e]|=128;return new Ca(new Uint8Array(t))}function Oa(e,t){if(e.length<t)throw Error("parse ends prematurely");return e.shiftN(t)}var za=class{buf;constructor(){this.setToZero()}setToZero(){this.buf=new Uint8Array(Ba)}add(e){let t=0,n=0,r=new DataView(this.buf.buffer),s=new DataView(e.buffer);for(let e=0;e<8;e++){let o=4*e,i=r.getUint32(o,!0);i+=t,i+=s.getUint32(o,!0),i>4294967295&&(n=1),r.setUint32(o,4294967295&i,!0),t=n,n=0}}negate(){let e=new DataView(this.buf.buffer);for(let t=0;t<8;t++){let n=4*t;e.setUint32(n,~e.getUint32(n,!0))}let t=new Uint8Array(Ba);t[0]=1,this.add(t)}getFingerprint(e){let t=new Ca;return t.extend(this.buf),t.extend(Na(e)),pt(t.unwrap()).subarray(0,16)}},qa=class{items;sealed;constructor(){this.items=[],this.sealed=!1}insert(e,t){if(this.sealed)throw Error("already sealed");const n=ln(t);if(n.byteLength!==Ba)throw Error("bad id size for added item");this.items.push({timestamp:e,id:n})}seal(){if(this.sealed)throw Error("already sealed");this.sealed=!0,this.items.sort(ja);for(let e=1;e<this.items.length;e++)if(0===ja(this.items[e-1],this.items[e]))throw Error("duplicate item inserted")}unseal(){this.sealed=!1}size(){return this._checkSealed(),this.items.length}getItem(e){if(this._checkSealed(),e>=this.items.length)throw Error("out of range");return this.items[e]}iterate(e,t,n){this._checkSealed(),this._checkBounds(e,t);for(let r=e;r<t&&n(this.items[r],r);++r);}findLowerBound(e,t,n){return this._checkSealed(),this._checkBounds(e,t),this._binarySearch(this.items,e,t,e=>ja(e,n)<0)}fingerprint(e,t){let n=new za;return n.setToZero(),this.iterate(e,t,e=>(n.add(e.id),!0)),n.getFingerprint(t-e)}_checkSealed(){if(!this.sealed)throw Error("not sealed")}_checkBounds(e,t){if(e>t||t>this.items.length)throw Error("bad range")}_binarySearch(e,t,n,r){let s=n-t;for(;s>0;){let n=t,o=Math.floor(s/2);n+=o,r(e[n])?(t=++n,s-=o+1):s=o}return t}},Ma=class{storage;frameSizeLimit;lastTimestampIn;lastTimestampOut;constructor(e,t=6e4){if(t<4096)throw Error("frameSizeLimit too small");this.storage=e,this.frameSizeLimit=t,this.lastTimestampIn=0,this.lastTimestampOut=0}_bound(e,t){return{timestamp:e,id:t||new Uint8Array(0)}}initiate(){let e=new Ca;return e.extend(new Uint8Array([97])),this.splitRange(0,this.storage.size(),this._bound(Number.MAX_VALUE),e),Xt(e.unwrap())}reconcile(e,t,n){const r=new Ca(ln(e));this.lastTimestampIn=this.lastTimestampOut=0;let s=new Ca;s.extend(new Uint8Array([97]));let o=Oa(r,1)[0];if(o<96||o>111)throw Error("invalid negentropy protocol version byte");if(97!==o)throw Error("unsupported negentropy protocol version requested: "+(o-96));let i=this.storage.size(),a=this._bound(0),l=0,c=!1;for(;0!==r.length;){let e=new Ca,o=()=>{c&&(c=!1,e.extend(this.encodeBound(a)),e.extend(Na(La)))},u=this.decodeBound(r),h=Ua(r),d=l,f=this.storage.findLowerBound(l,i,u);if(h===La)c=!0;else if(h===_a){0!==Ha(Oa(r,16),this.storage.fingerprint(d,f))?(o(),this.splitRange(d,f,u,e)):c=!0}else{if(h!==Pa)throw Error("unexpected mode");{let e=Ua(r),s={};for(let t=0;t<e;t++){let e=Oa(r,Ba);s[Xt(e)]=e}if(c=!0,this.storage.iterate(d,f,e=>{let n=e.id;const r=Xt(n);return s[r]?delete s[Xt(n)]:t?.(r),!0}),n)for(let e of Object.values(s))n(Xt(e))}}if(this.exceededFrameSizeLimit(s.length+e.length)){let e=this.storage.fingerprint(f,i);s.extend(this.encodeBound(this._bound(Number.MAX_VALUE))),s.extend(Na(_a)),s.extend(e);break}s.extend(e),l=f,a=u}return 1===s.length?null:Xt(s.unwrap())}splitRange(e,t,n,r){let s=t-e;if(s<32)r.extend(this.encodeBound(n)),r.extend(Na(Pa)),r.extend(Na(s)),this.storage.iterate(e,t,e=>(r.extend(e.id),!0));else{let o=Math.floor(s/16),i=s%16,a=e;for(let e=0;e<16;e++){let s,l=o+(e<i?1:0),c=this.storage.fingerprint(a,a+l);if(a+=l,a===t)s=n;else{let e,t;this.storage.iterate(a-1,a+1,(n,r)=>(r===a-1?e=n:t=n,!0)),s=this.getMinimalBound(e,t)}r.extend(this.encodeBound(s)),r.extend(Na(_a)),r.extend(c)}}}exceededFrameSizeLimit(e){return e>this.frameSizeLimit-200}decodeTimestampIn(e){let t=Ua(e);return t=0===t?Number.MAX_VALUE:t-1,this.lastTimestampIn===Number.MAX_VALUE||t===Number.MAX_VALUE?(this.lastTimestampIn=Number.MAX_VALUE,Number.MAX_VALUE):(t+=this.lastTimestampIn,this.lastTimestampIn=t,t)}decodeBound(e){let t=this.decodeTimestampIn(e),n=Ua(e);if(n>Ba)throw Error("bound key too long");return{timestamp:t,id:Oa(e,n)}}encodeTimestampOut(e){if(e===Number.MAX_VALUE)return this.lastTimestampOut=Number.MAX_VALUE,Na(0);let t=e;return e-=this.lastTimestampOut,this.lastTimestampOut=t,Na(e+1)}encodeBound(e){let t=new Ca;return t.extend(this.encodeTimestampOut(e.timestamp)),t.extend(Na(e.id.length)),t.extend(e.id),t}getMinimalBound(e,t){if(t.timestamp!==e.timestamp)return this._bound(t.timestamp);{let n=0,r=t.id,s=e.id;for(let e=0;e<Ba&&r[e]===s[e];e++)n++;return this._bound(t.timestamp,t.id.subarray(0,n+1))}}};function Ha(e,t){for(let n=0;n<e.byteLength;n++){if(e[n]<t[n])return-1;if(e[n]>t[n])return 1}return e.byteLength>t.byteLength?1:e.byteLength<t.byteLength?-1:0}function ja(e,t){return e.timestamp===t.timestamp?Ha(e.id,t.id):e.timestamp-t.timestamp}var Da=class{relay;storage;neg;filter;subscription;onhave;onneed;constructor(e,t,n,r={}){this.relay=e,this.storage=t,this.neg=new Ma(t),this.onhave=r.onhave,this.onneed=r.onneed,this.filter=n,this.subscription=this.relay.prepareSubscription([{}],{label:r.label||"negentropy"}),this.subscription.oncustom=e=>{switch(e[0]){case"NEG-MSG":e.length<3&&console.warn(`got invalid NEG-MSG from ${this.relay.url}: ${e}`);try{const t=this.neg.reconcile(e[2],this.onhave,this.onneed);t?this.relay.send(`["NEG-MSG", "${this.subscription.id}", "${t}"]`):(this.close(),r.onclose?.())}catch(e){console.error("negentropy reconcile error:",e),r?.onclose?.(`reconcile error: ${e}`)}break;case"NEG-CLOSE":{const t=e[2];console.warn("negentropy error:",t),r.onclose?.(t);break}case"NEG-ERR":r.onclose?.()}}}async start(){const e=this.neg.initiate();this.relay.send(`["NEG-OPEN","${this.subscription.id}",${JSON.stringify(this.filter)},"${e}"]`)}close(){this.relay.send(`["NEG-CLOSE","${this.subscription.id}"]`),this.subscription.close()}};Ar({},{getToken:()=>Va,hashPayload:()=>Qa,unpackEventFromToken:()=>Za,validateEvent:()=>el,validateEventKind:()=>Ya,validateEventMethodTag:()=>Ja,validateEventPayloadTag:()=>Xa,validateEventTimestamp:()=>Ka,validateEventUrlTag:()=>Ga,validateToken:()=>Wa});var Fa="Nostr ";async function Va(e,t,n,r=!1,s){const o={kind:so,tags:[["u",e],["method",t]],created_at:Math.round((new Date).getTime()/1e3),content:""};s&&o.tags.push(["payload",Qa(s)]);const i=await n(o);return(r?Fa:"")+Bt.encode(Ir.encode(JSON.stringify(i)))}async function Wa(e,t,n){const r=await Za(e).catch(e=>{throw e});return await el(r,t,n).catch(e=>{throw e})}async function Za(e){if(!e)throw new Error("Missing token");e=e.replace(Fa,"");const t=Rr.decode(Bt.decode(e));if(!t||0===t.length||!t.startsWith("{"))throw new Error("Invalid token");return JSON.parse(t)}function Ka(e){return!!e.created_at&&Math.round((new Date).getTime()/1e3)-e.created_at<60}function Ya(e){return e.kind===so}function Ga(e,t){const n=e.tags.find(e=>"u"===e[0]);return!!n&&(n.length>0&&n[1]===t)}function Ja(e,t){const n=e.tags.find(e=>"method"===e[0]);return!!n&&(n.length>0&&n[1].toLowerCase()===t.toLowerCase())}function Qa(e){return Ye(pt(Ir.encode(JSON.stringify(e))))}function Xa(e,t){const n=e.tags.find(e=>"payload"===e[0]);if(!n)return!1;const r=Qa(t);return n.length>0&&n[1]===r}async function el(e,t,n,r){if(!Hr(e))throw new Error("Invalid nostr event, signature invalid");if(!Ya(e))throw new Error("Invalid nostr event, kind invalid");if(!Ka(e))throw new Error("Invalid nostr event, created_at timestamp invalid");if(!Ga(e,t))throw new Error("Invalid nostr event, url tag invalid");if(!Ja(e,n))throw new Error("Invalid nostr event, method tag invalid");if(Boolean(r)&&"object"==typeof r&&Object.keys(r).length>0&&!Xa(e,r))throw new Error("Invalid nostr event, payload tag does not match request body hash");return!0}class tl{constructor(e){this.profileCache=new Map,this.pool=new Ko,this.relays=e}normalizePublicKey(e){if(e.startsWith("npub"))try{return Yo.decode(e).data}catch(t){return console.error("Invalid npub format:",t),e}return e}async fetchPosts(e,t=50,n="all",r){const s=(Array.isArray(e)?e:[e]).map(e=>this.normalizePublicKey(e));let o;switch(n){case"long-form":o=[30023];break;case"short-form":o=[1];break;default:o=[30023,1]}let i=[];if(s.length>1){const e=Math.ceil(t/s.length);for(const t of s){const n={authors:[t],kinds:o,limit:e};r?.since&&(n.since=r.since),r?.until&&(n.until=r.until);const s=await this.pool.querySync(this.relays,n);i=i.concat(s)}}else{const e={authors:s,kinds:o,limit:t};r?.since&&(e.since=r.since),r?.until&&(e.until=r.until),i=await this.pool.querySync(this.relays,e)}return await this.fetchAuthorProfiles(s),this.parsePosts(i)}async fetchAuthorProfiles(e){const t=e.filter(e=>!this.profileCache.has(e));if(0===t.length)return;const n={authors:t,kinds:[0],limit:t.length};try{(await this.pool.querySync(this.relays,n)).forEach(e=>{try{const t=JSON.parse(e.content);this.profileCache.set(e.pubkey,t)}catch(t){console.error("Failed to parse profile for",e.pubkey,t)}})}catch(e){console.error("Failed to fetch author profiles:",e)}}async fetchPostById(e){if(e.startsWith("naddr"))return this.fetchPostByNaddr(e);if(e.startsWith("nevent"))return this.fetchPostByNevent(e);if(e.startsWith("note1"))try{const t=Yo.decode(e);"note"===t.type&&(e=t.data)}catch(e){console.error("Failed to decode note1:",e)}const t={ids:[e]},n=await this.pool.querySync(this.relays,t);if(0===n.length)return null;n[0]?.pubkey&&await this.fetchAuthorProfiles([n[0].pubkey]);return this.parsePosts(n)[0]||null}async fetchPostByNevent(e){try{const t=Yo.decode(e);if("nevent"!==t.type)return console.error("Not a valid nevent"),null;const n=t.data,r=n.relays&&n.relays.length>0?n.relays:this.relays,s={ids:[n.id]};n.author&&(s.authors=[n.author]);const o=await this.pool.querySync(r,s);if(0===o.length)return null;o[0]?.pubkey&&await this.fetchAuthorProfiles([o[0].pubkey]);return this.parsePosts(o)[0]||null}catch(e){return console.error("Failed to decode nevent:",e),null}}async fetchPostByNaddr(e){try{const t=Yo.decode(e);if("naddr"!==t.type)return console.error("Not a valid naddr"),null;const n=t.data,r=n.relays&&n.relays.length>0?n.relays:this.relays,s={authors:[n.pubkey],kinds:[n.kind],"#d":[n.identifier],limit:1},o=await this.pool.querySync(r,s);if(0===o.length)return null;const i=o.reduce((e,t)=>t.created_at>e.created_at?t:e);i?.pubkey&&await this.fetchAuthorProfiles([i.pubkey]);return this.parsePost(i)}catch(e){return console.error("Failed to decode naddr:",e),null}}parsePosts(e){const t=[],n=new Map;for(const r of e)if(30023===r.kind){const e=r.tags.find(([e])=>"d"===e)?.[1];if(e){const t=`${r.pubkey}:${e}`,s=n.get(t);(!s||r.created_at>s.created_at)&&n.set(t,r)}}else t.push(r);return t.push(...n.values()),t.map(e=>this.parsePost(e)).sort((e,t)=>(t.published_at||t.created_at)-(e.published_at||e.created_at))}parsePost(e){const t={...e};let n;if(e.tags.forEach(([e,r])=>{switch(e){case"title":t.title=r;break;case"summary":t.summary=r;break;case"image":t.image=r;break;case"published_at":t.published_at=parseInt(r,10);break;case"d":n=r}}),30023===e.kind&&n?t.naddr=Yo.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:n,relays:this.relays.slice(0,2)}):1===e.kind&&(t.naddr=Yo.neventEncode({id:e.id,relays:this.relays.slice(0,2),author:e.pubkey})),t.content=e.content,!t.summary&&e.content){let n=e.content.replace(/https?:\/\/\S+/gi,"").replace(/nostr:(naddr1|note1|npub1|nevent1|nprofile1|nrelay1)\S+/gi,"").replace(/(naddr1|note1|npub1|nevent1|nprofile1|nrelay1)\S+/gi,"").replace(/\s+/g," ").trim();t.summary=n.substring(0,200)+(n.length>200?"...":"")}if(!t.title)if(30023===e.kind){const n=e.content.match(/^#\s+(.+)$/m);t.title=n?n[1]:"Untitled Post"}else{const n=e.content.split("\n")[0];t.title=n.substring(0,50)+(n.length>50?"...":"")}const r=this.profileCache.get(e.pubkey);if(r?(t.authorName=r.display_name||r.name||"Anonymous",t.authorAvatar=r.picture,t.authorNip05=r.nip05):t.authorName=e.pubkey.substring(0,8)+"...",30023===e.kind){const n=e.tags.find(([e])=>"d"===e);if(n&&n[1])try{const r=Yo.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:n[1],relays:this.relays.slice(0,2)});t.naddr=r}catch(e){console.error("Failed to encode naddr:",e)}}return t}close(){this.pool.close(this.relays)}}},701(e,t,n){n.d(t,{EH:()=>E,Hr:()=>v,Ki:()=>$,Rc:()=>T,To:()=>S,a:()=>ee,a0:()=>Q,gb:()=>x,n5:()=>k,sE:()=>r,vz:()=>A,wv:()=>te});const r={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return s(this.context.count)},getNextContextId(){return s(this.context.count++)}};function s(e){const t=String(e),n=t.length-1;return r.context.id+(n?String.fromCharCode(96+n):"")+t}function o(e){r.context=e}const i=(e,t)=>e===t,a=(Symbol("solid-proxy"),Symbol("solid-track")),l=(Symbol("solid-dev-component"),{equals:i});let c=null,u=M;const h={owned:null,cleanups:null,context:null,owner:null};var d=null;let f=null,p=null,g=null,w=null,b=null,y=null,m=0;function v(e,t){const n=w,r=d,s=0===e.length,o=void 0===t?r:t,i=s?h:{owned:null,cleanups:null,context:o?o.context:null,owner:o},a=s?e:()=>e(()=>A(()=>F(i)));d=i,w=null;try{return q(a,!0)}finally{w=n,d=r}}function k(e,t){const n={value:e,observers:null,observerSlots:null,comparator:(t=t?Object.assign({},l,t):l).equals||void 0};return[P.bind(n),e=>("function"==typeof e&&(e=f&&f.running&&f.sources.has(n)?e(n.tValue):e(n.value)),C(n,e))]}function x(e,t,n){const r=O(e,t,!1,1);p&&f&&f.running?b.push(r):U(r)}function E(e,t,n){u=H;const r=O(e,t,!1,1),s=_&&L(_);s&&(r.suspense=s),n&&n.render||(r.user=!0),y?y.push(r):U(r)}function S(e,t,n){n=n?Object.assign({},l,n):l;const r=O(e,t,!0,0);return r.observers=null,r.observerSlots=null,r.comparator=n.equals||void 0,p&&f&&f.running?(r.tState=1,b.push(r)):U(r),P.bind(r)}function A(e){if(!g&&null===w)return e();const t=w;w=null;try{return g?g.untrack(e):e()}finally{w=t}}function T(e){E(()=>A(e))}function $(e){return null===d||(null===d.cleanups?d.cleanups=[e]:d.cleanups.push(e)),e}function R(e){if(f&&f.running)return e(),f.done;const t=w,n=d;return Promise.resolve().then(()=>{let r;return w=t,d=n,(p||_)&&(r=f||(f={sources:new Set,effects:[],promises:new Set,disposed:new Set,queue:new Set,running:!0}),r.done||(r.done=new Promise(e=>r.resolve=e)),r.running=!0),q(e,!1),w=d=null,r?r.done:void 0})}const[I,B]=k(!1);function L(e){let t;return d&&d.context&&void 0!==(t=d.context[e.id])?t:e.defaultValue}let _;function P(){const e=f&&f.running;if(this.sources&&(e?this.tState:this.state))if(1===(e?this.tState:this.state))U(this);else{const e=b;b=null,q(()=>j(this),!1),b=e}if(w){const e=this.observers?this.observers.length:0;w.sources?(w.sources.push(this),w.sourceSlots.push(e)):(w.sources=[this],w.sourceSlots=[e]),this.observers?(this.observers.push(w),this.observerSlots.push(w.sources.length-1)):(this.observers=[w],this.observerSlots=[w.sources.length-1])}return e&&f.sources.has(this)?this.tValue:this.value}function C(e,t,n){let r=f&&f.running&&f.sources.has(e)?e.tValue:e.value;if(!e.comparator||!e.comparator(r,t)){if(f){const r=f.running;(r||!n&&f.sources.has(e))&&(f.sources.add(e),e.tValue=t),r||(e.value=t)}else e.value=t;e.observers&&e.observers.length&&q(()=>{for(let t=0;t<e.observers.length;t+=1){const n=e.observers[t],r=f&&f.running;r&&f.disposed.has(n)||((r?n.tState:n.state)||(n.pure?b.push(n):y.push(n),n.observers&&D(n)),r?n.tState=1:n.state=1)}if(b.length>1e6)throw b=[],new Error},!1)}return t}function U(e){if(!e.fn)return;F(e);const t=m;N(e,f&&f.running&&f.sources.has(e)?e.tValue:e.value,t),f&&!f.running&&f.sources.has(e)&&queueMicrotask(()=>{q(()=>{f&&(f.running=!0),w=d=e,N(e,e.tValue,t),w=d=null},!1)})}function N(e,t,n){let r;const s=d,o=w;w=d=e;try{r=e.fn(t)}catch(t){return e.pure&&(f&&f.running?(e.tState=1,e.tOwned&&e.tOwned.forEach(F),e.tOwned=void 0):(e.state=1,e.owned&&e.owned.forEach(F),e.owned=null)),e.updatedAt=n+1,K(t)}finally{w=o,d=s}(!e.updatedAt||e.updatedAt<=n)&&(null!=e.updatedAt&&"observers"in e?C(e,r,!0):f&&f.running&&e.pure?(f.sources.add(e),e.tValue=r):e.value=r,e.updatedAt=n)}function O(e,t,n,r=1,s){const o={fn:e,state:r,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:d,context:d?d.context:null,pure:n};if(f&&f.running&&(o.state=0,o.tState=r),null===d||d!==h&&(f&&f.running&&d.pure?d.tOwned?d.tOwned.push(o):d.tOwned=[o]:d.owned?d.owned.push(o):d.owned=[o]),g&&o.fn){const[e,t]=k(void 0,{equals:!1}),n=g.factory(o.fn,t);$(()=>n.dispose());const r=()=>R(t).then(()=>s.dispose()),s=g.factory(o.fn,r);o.fn=t=>(e(),f&&f.running?s.track(t):n.track(t))}return o}function z(e){const t=f&&f.running;if(0===(t?e.tState:e.state))return;if(2===(t?e.tState:e.state))return j(e);if(e.suspense&&A(e.suspense.inFallback))return e.suspense.effects.push(e);const n=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<m);){if(t&&f.disposed.has(e))return;(t?e.tState:e.state)&&n.push(e)}for(let r=n.length-1;r>=0;r--){if(e=n[r],t){let t=e,s=n[r+1];for(;(t=t.owner)&&t!==s;)if(f.disposed.has(t))return}if(1===(t?e.tState:e.state))U(e);else if(2===(t?e.tState:e.state)){const t=b;b=null,q(()=>j(e,n[0]),!1),b=t}}}function q(e,t){if(b)return e();let n=!1;t||(b=[]),y?n=!0:y=[],m++;try{const t=e();return function(e){b&&(p&&f&&f.running?function(e){for(let t=0;t<e.length;t++){const n=e[t],r=f.queue;r.has(n)||(r.add(n),p(()=>{r.delete(n),q(()=>{f.running=!0,z(n)},!1),f&&(f.running=!1)}))}}(b):M(b),b=null);if(e)return;let t;if(f)if(f.promises.size||f.queue.size){if(f.running)return f.running=!1,f.effects.push.apply(f.effects,y),y=null,void B(!0)}else{const e=f.sources,n=f.disposed;y.push.apply(y,f.effects),t=f.resolve;for(const e of y)"tState"in e&&(e.state=e.tState),delete e.tState;f=null,q(()=>{for(const e of n)F(e);for(const t of e){if(t.value=t.tValue,t.owned)for(let e=0,n=t.owned.length;e<n;e++)F(t.owned[e]);t.tOwned&&(t.owned=t.tOwned),delete t.tValue,delete t.tOwned,t.tState=0}B(!1)},!1)}const n=y;y=null,n.length&&q(()=>u(n),!1);t&&t()}(n),t}catch(e){n||(y=null),b=null,K(e)}}function M(e){for(let t=0;t<e.length;t++)z(e[t])}function H(e){let t,n=0;for(t=0;t<e.length;t++){const r=e[t];r.user?e[n++]=r:z(r)}if(r.context){if(r.count)return r.effects||(r.effects=[]),void r.effects.push(...e.slice(0,n));o()}for(!r.effects||!r.done&&r.count||(e=[...r.effects,...e],n+=r.effects.length,delete r.effects),t=0;t<n;t++)z(e[t])}function j(e,t){const n=f&&f.running;n?e.tState=0:e.state=0;for(let r=0;r<e.sources.length;r+=1){const s=e.sources[r];if(s.sources){const e=n?s.tState:s.state;1===e?s!==t&&(!s.updatedAt||s.updatedAt<m)&&z(s):2===e&&j(s,t)}}}function D(e){const t=f&&f.running;for(let n=0;n<e.observers.length;n+=1){const r=e.observers[n];(t?r.tState:r.state)||(t?r.tState=2:r.state=2,r.pure?b.push(r):y.push(r),r.observers&&D(r))}}function F(e){let t;if(e.sources)for(;e.sources.length;){const t=e.sources.pop(),n=e.sourceSlots.pop(),r=t.observers;if(r&&r.length){const e=r.pop(),s=t.observerSlots.pop();n<r.length&&(e.sourceSlots[s]=n,r[n]=e,t.observerSlots[n]=s)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)F(e.tOwned[t]);delete e.tOwned}if(f&&f.running&&e.pure)V(e,!0);else if(e.owned){for(t=e.owned.length-1;t>=0;t--)F(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}f&&f.running?e.tState=0:e.state=0}function V(e,t){if(t||(e.tState=0,f.disposed.add(e)),e.owned)for(let t=0;t<e.owned.length;t++)V(e.owned[t])}function W(e){return e instanceof Error?e:new Error("string"==typeof e?e:"Unknown error",{cause:e})}function Z(e,t,n){try{for(const n of t)n(e)}catch(e){K(e,n&&n.owner||null)}}function K(e,t=d){const n=c&&t&&t.context&&t.context[c],r=W(e);if(!n)throw r;y?y.push({fn(){Z(r,n,t)},state:1}):Z(r,n,t)}const Y=Symbol("fallback");function G(e){for(let t=0;t<e.length;t++)e[t]()}let J=!1;function Q(e,t){if(J&&r.context){const n=r.context;o({...r.context,id:r.getNextContextId(),count:0});const s=A(()=>e(t||{}));return o(n),s}return A(()=>e(t||{}))}const X=e=>`Stale read from <${e}>.`;function ee(e){const t="fallback"in e&&{fallback:()=>e.fallback};return S(function(e,t,n={}){let r=[],s=[],o=[],i=0,l=t.length>1?[]:null;return $(()=>G(o)),()=>{let c,u,h=e()||[],d=h.length;return h[a],A(()=>{let e,t,a,p,g,w,b,y,m;if(0===d)0!==i&&(G(o),o=[],r=[],s=[],i=0,l&&(l=[])),n.fallback&&(r=[Y],s[0]=v(e=>(o[0]=e,n.fallback())),i=1);else if(0===i){for(s=new Array(d),u=0;u<d;u++)r[u]=h[u],s[u]=v(f);i=d}else{for(a=new Array(d),p=new Array(d),l&&(g=new Array(d)),w=0,b=Math.min(i,d);w<b&&r[w]===h[w];w++);for(b=i-1,y=d-1;b>=w&&y>=w&&r[b]===h[y];b--,y--)a[y]=s[b],p[y]=o[b],l&&(g[y]=l[b]);for(e=new Map,t=new Array(y+1),u=y;u>=w;u--)m=h[u],c=e.get(m),t[u]=void 0===c?-1:c,e.set(m,u);for(c=w;c<=b;c++)m=r[c],u=e.get(m),void 0!==u&&-1!==u?(a[u]=s[c],p[u]=o[c],l&&(g[u]=l[c]),u=t[u],e.set(m,u)):o[c]();for(u=w;u<d;u++)u in a?(s[u]=a[u],o[u]=p[u],l&&(l[u]=g[u],l[u](u))):s[u]=v(f);s=s.slice(0,i=d),r=h.slice(0)}return s});function f(e){if(o[u]=e,l){const[e,n]=k(u);return l[u]=n,t(h[u],e)}return t(h[u])}}}(()=>e.each,e.children,t||void 0))}function te(e){const t=e.keyed,n=S(()=>e.when,void 0,void 0),r=t?n:S(n,void 0,{equals:(e,t)=>!e==!t});return S(()=>{const s=r();if(s){const o=e.children;return"function"==typeof o&&o.length>0?A(()=>o(t?s:()=>{if(!A(r))throw X("Show");return n()})):o}return e.fallback},void 0,void 0)}}},r={};function s(e){var t=r[e];if(void 0!==t)return t.exports;var o=r[e]={exports:{}};return n[e](o,o.exports,s),o.exports}s.m=n,s.d=(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.f={},s.e=e=>Promise.all(Object.keys(s.f).reduce((t,n)=>(s.f[n](e,t),t),[])),s.u=e=>e+".nostr-blog.js",s.miniCssF=e=>{},s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e={},t="NostrBlog:",s.l=(n,r,o,i)=>{if(e[n])e[n].push(r);else{var a,l;if(void 0!==o)for(var c=document.getElementsByTagName("script"),u=0;u<c.length;u++){var h=c[u];if(h.getAttribute("src")==n||h.getAttribute("data-webpack")==t+o){a=h;break}}a||(l=!0,(a=document.createElement("script")).charset="utf-8",s.nc&&a.setAttribute("nonce",s.nc),a.setAttribute("data-webpack",t+o),a.src=n),e[n]=[r];var d=(t,r)=>{a.onerror=a.onload=null,clearTimeout(f);var s=e[n];if(delete e[n],a.parentNode&&a.parentNode.removeChild(a),s&&s.forEach(e=>e(r)),t)return t(r)},f=setTimeout(d.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=d.bind(null,a.onerror),a.onload=d.bind(null,a.onload),l&&document.head.appendChild(a)}},s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;s.g.importScripts&&(e=s.g.location+"");var t=s.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var n=t.getElementsByTagName("script");if(n.length)for(var r=n.length-1;r>-1&&(!e||!/^http(s?):/.test(e));)e=n[r--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),s.p=e})(),(()=>{var e={792:0};s.f.j=(t,n)=>{var r=s.o(e,t)?e[t]:void 0;if(0!==r)if(r)n.push(r[2]);else{var o=new Promise((n,s)=>r=e[t]=[n,s]);n.push(r[2]=o);var i=s.p+s.u(t),a=new Error;s.l(i,n=>{if(s.o(e,t)&&(0!==(r=e[t])&&(e[t]=void 0),r)){var o=n&&("load"===n.type?"missing":n.type),i=n&&n.target&&n.target.src;a.message="Loading chunk "+t+" failed.\n("+o+": "+i+")",a.name="ChunkLoadError",a.type=o,a.request=i,r[1](a)}},"chunk-"+t,t)}};var t=(t,n)=>{var r,o,[i,a,l]=n,c=0;if(i.some(t=>0!==e[t])){for(r in a)s.o(a,r)&&(s.m[r]=a[r]);if(l)l(s)}for(t&&t(n);c<i.length;c++)o=i[c],s.o(e,o)&&e[o]&&e[o][0](),e[o]=0},n=this.webpackChunkNostrBlog=this.webpackChunkNostrBlog||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))})();var o={};s.d(o,{default:()=>it});var i=s(701),a=s(35),l=s(261),c=s(168);function u(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var h={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function d(e){h=e}var f={exec:()=>null};function p(e,t=""){let n="string"==typeof e?e:e.source,r={replace:(e,t)=>{let s="string"==typeof t?t:t.source;return s=s.replace(w.caret,"$1"),n=n.replace(e,s),r},getRegex:()=>new RegExp(n,t)};return r}var g=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),w={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[\t ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},b=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,y=/(?:[*+-]|\d{1,9}[.)])/,m=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,v=p(m).replace(/bull/g,y).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),k=p(m).replace(/bull/g,y).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),x=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,E=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,S=p(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",E).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),A=p(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,y).getRegex(),T="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",$=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,R=p("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",$).replace("tag",T).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),I=p(x).replace("hr",b).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",T).getRegex(),B={blockquote:p(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",I).getRegex(),code:/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,def:S,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:b,html:R,lheading:v,list:A,newline:/^(?:[ \t]*(?:\n|$))+/,paragraph:I,table:f,text:/^[^\n]+/},L=p("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",b).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",T).getRegex(),_={...B,lheading:k,table:L,paragraph:p(x).replace("hr",b).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",L).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",T).getRegex()},P={...B,html:p("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",$).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:f,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:p(x).replace("hr",b).replace("heading"," *#{1,6} *[^\n]").replace("lheading",v).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},C=/^( {2,}|\\)\n(?!\s*$)/,U=/[\p{P}\p{S}]/u,N=/[\s\p{P}\p{S}]/u,O=/[^\s\p{P}\p{S}]/u,z=p(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,N).getRegex(),q=/(?!~)[\p{P}\p{S}]/u,M=p(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",g?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),H=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,j=p(H,"u").replace(/punct/g,U).getRegex(),D=p(H,"u").replace(/punct/g,q).getRegex(),F="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",V=p(F,"gu").replace(/notPunctSpace/g,O).replace(/punctSpace/g,N).replace(/punct/g,U).getRegex(),W=p(F,"gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|~)/u).replace(/punctSpace/g,/(?!~)[\s\p{P}\p{S}]/u).replace(/punct/g,q).getRegex(),Z=p("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,O).replace(/punctSpace/g,N).replace(/punct/g,U).getRegex(),K=p(/\\(punct)/,"gu").replace(/punct/g,U).getRegex(),Y=p(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),G=p($).replace("(?:--\x3e|$)","--\x3e").getRegex(),J=p("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",G).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Q=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,X=p(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Q).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ee=p(/^!?\[(label)\]\[(ref)\]/).replace("label",Q).replace("ref",E).getRegex(),te=p(/^!?\[(ref)\](?:\[\])?/).replace("ref",E).getRegex(),ne=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,re={_backpedal:f,anyPunctuation:K,autolink:Y,blockSkip:M,br:C,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:f,emStrongLDelim:j,emStrongRDelimAst:V,emStrongRDelimUnd:Z,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:X,nolink:te,punctuation:z,reflink:ee,reflinkSearch:p("reflink|nolink(?!\\()","g").replace("reflink",ee).replace("nolink",te).getRegex(),tag:J,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:f},se={...re,link:p(/^!?\[(label)\]\((.*?)\)/).replace("label",Q).getRegex(),reflink:p(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Q).getRegex()},oe={...re,emStrongRDelimAst:W,emStrongLDelim:D,url:p(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",ne).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:p(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",ne).getRegex()},ie={...oe,br:p(C).replace("{2,}","*").getRegex(),text:p(oe.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ae={normal:B,gfm:_,pedantic:P},le={normal:re,gfm:oe,breaks:ie,pedantic:se},ce={"&":"&","<":"<",">":">",'"':""","'":"'"},ue=e=>ce[e];function he(e,t){if(t){if(w.escapeTest.test(e))return e.replace(w.escapeReplace,ue)}else if(w.escapeTestNoEncode.test(e))return e.replace(w.escapeReplaceNoEncode,ue);return e}function de(e){try{e=encodeURI(e).replace(w.percentDecode,"%")}catch{return null}return e}function fe(e,t){let n=e.replace(w.findPipe,(e,t,n)=>{let r=!1,s=t;for(;--s>=0&&"\\"===n[s];)r=!r;return r?"|":" |"}).split(w.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;r<n.length;r++)n[r]=n[r].trim().replace(w.slashPipe,"|");return n}function pe(e,t,n){let r=e.length;if(0===r)return"";let s=0;for(;s<r;){let o=e.charAt(r-s-1);if(o!==t||n){if(o===t||!n)break;s++}else s++}return e.slice(0,r-s)}function ge(e,t,n,r,s){let o=t.href,i=t.title||null,a=e[1].replace(s.other.outputLinkReplace,"$1");r.state.inLink=!0;let l={type:"!"===e[0].charAt(0)?"image":"link",raw:n,href:o,title:i,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,l}var we=class{options;rules;lexer;constructor(e){this.options=e||h}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:pe(e,"\n")}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=function(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(null===r)return t;let s=r[1];return t.split("\n").map(e=>{let t=e.match(n.other.beginningSpace);if(null===t)return e;let[r]=t;return r.length>=s.length?e.slice(s.length):e}).join("\n")}(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=pe(e,"#");(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:pe(t[0],"\n")}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=pe(t[0],"\n").split("\n"),n="",r="",s=[];for(;e.length>0;){let t,o=!1,i=[];for(t=0;t<e.length;t++)if(this.rules.other.blockquoteStart.test(e[t]))i.push(e[t]),o=!0;else{if(o)break;i.push(e[t])}e=e.slice(t);let a=i.join("\n"),l=a.replace(this.rules.other.blockquoteSetextReplace,"\n $1").replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}\n${a}`:a,r=r?`${r}\n${l}`:l;let c=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(l,s,!0),this.lexer.state.top=c,0===e.length)break;let u=s.at(-1);if("code"===u?.type)break;if("blockquote"===u?.type){let t=u,o=t.raw+"\n"+e.join("\n"),i=this.blockquote(o);s[s.length-1]=i,n=n.substring(0,n.length-t.raw.length)+i.raw,r=r.substring(0,r.length-t.text.length)+i.text;break}if("list"===u?.type){let t=u,o=t.raw+"\n"+e.join("\n"),i=this.list(o);s[s.length-1]=i,n=n.substring(0,n.length-u.raw.length)+i.raw,r=r.substring(0,r.length-t.raw.length)+i.raw,e=o.substring(s.at(-1).raw.length).split("\n");continue}}return{type:"blockquote",raw:n,tokens:s,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,s={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let o=this.rules.other.listItemRegex(n),i=!1;for(;e;){let n=!1,r="",a="";if(!(t=o.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let l=t[2].split("\n",1)[0].replace(this.rules.other.listReplaceTabs,e=>" ".repeat(3*e.length)),c=e.split("\n",1)[0],u=!l.trim(),h=0;if(this.options.pedantic?(h=2,a=l.trimStart()):u?h=t[1].length+1:(h=t[2].search(this.rules.other.nonSpaceChar),h=h>4?1:h,a=l.slice(h),h+=t[1].length),u&&this.rules.other.blankLine.test(c)&&(r+=c+"\n",e=e.substring(c.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(h),n=this.rules.other.hrRegex(h),s=this.rules.other.fencesBeginRegex(h),o=this.rules.other.headingBeginRegex(h),i=this.rules.other.htmlBeginRegex(h);for(;e;){let d,f=e.split("\n",1)[0];if(c=f,this.options.pedantic?(c=c.replace(this.rules.other.listReplaceNesting," "),d=c):d=c.replace(this.rules.other.tabCharGlobal," "),s.test(c)||o.test(c)||i.test(c)||t.test(c)||n.test(c))break;if(d.search(this.rules.other.nonSpaceChar)>=h||!c.trim())a+="\n"+d.slice(h);else{if(u||l.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||s.test(l)||o.test(l)||n.test(l))break;a+="\n"+c}!u&&!c.trim()&&(u=!0),r+=f+"\n",e=e.substring(f.length+1),l=d.slice(h)}}s.loose||(i?s.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(i=!0)),s.items.push({type:"list_item",raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(a),loose:!1,text:a,tokens:[]}),s.raw+=r}let a=s.items.at(-1);if(!a)return;a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd(),s.raw=s.raw.trimEnd();for(let e of s.items){if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),e.task){if(e.text=e.text.replace(this.rules.other.listReplaceTask,""),"text"===e.tokens[0]?.type||"paragraph"===e.tokens[0]?.type){e.tokens[0].raw=e.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),e.tokens[0].text=e.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,"");break}}let t=this.rules.other.listTaskCheckbox.exec(e.raw);if(t){let n={type:"checkbox",raw:t[0]+" ",checked:"[ ]"!==t[0]};e.checked=n.checked,s.loose?e.tokens[0]&&["paragraph","text"].includes(e.tokens[0].type)&&"tokens"in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=n.raw+e.tokens[0].raw,e.tokens[0].text=n.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(n)):e.tokens.unshift({type:"paragraph",raw:n.raw,text:n.raw,tokens:[n]}):e.tokens.unshift(n)}}if(!s.loose){let t=e.tokens.filter(e=>"space"===e.type),n=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw));s.loose=n}}if(s.loose)for(let e of s.items){e.loose=!0;for(let t of e.tokens)"text"===t.type&&(t.type="paragraph")}return s}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=fe(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split("\n"):[],o={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?o.align.push("right"):this.rules.other.tableAlignCenter.test(e)?o.align.push("center"):this.rules.other.tableAlignLeft.test(e)?o.align.push("left"):o.align.push(null);for(let e=0;e<n.length;e++)o.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:o.align[e]});for(let e of s)o.rows.push(fe(e,o.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:o.align[t]})));return o}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e="\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=pe(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{let e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let r=0;r<e.length;r++)if("\\"===e[r])r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}(t[2],"()");if(-2===e)return;if(e>-1){let n=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let n=t[2],r="";if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),ge(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return ge(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!r[1]&&!r[2]||!n||this.rules.inline.punctuation.exec(n))){let n,s,o=[...r[0]].length-1,i=o,a=0,l="*"===r[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(l.lastIndex=0,t=t.slice(-1*e.length+o);null!=(r=l.exec(t));){if(n=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!n)continue;if(s=[...n].length,r[3]||r[4]){i+=s;continue}if((r[5]||r[6])&&o%3&&!((o+s)%3)){a+=s;continue}if(i-=s,i>0)continue;s=Math.min(s,s+i+a);let t=[...r[0]][0].length,l=e.slice(0,o+r.index+t+s);if(Math.min(o,s)%2){let e=l.slice(1,-1);return{type:"em",raw:l,text:e,tokens:this.lexer.inlineTokens(e)}}let c=l.slice(2,-2);return{type:"strong",raw:l,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return"@"===t[2]?(e=t[1],n="mailto:"+e):(e=t[1],n=e),{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if("@"===t[2])e=t[0],n="mailto:"+e;else{let r;do{r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??""}while(r!==t[0]);e=t[0],n="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},be=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||h,this.options.tokenizer=this.options.tokenizer||new we,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:w,block:ae.normal,inline:le.normal};this.options.pedantic?(t.block=ae.pedantic,t.inline=le.pedantic):this.options.gfm&&(t.block=ae.gfm,this.options.breaks?t.inline=le.breaks:t.inline=le.gfm),this.tokenizer.rules=t}static get rules(){return{block:ae,inline:le}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(w.carriageReturn,"\n"),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.options.pedantic&&(e=e.replace(w.tabCharGlobal," ").replace(w.spaceLine,""));e;){let r;if(this.options.extensions?.block?.some(n=>!!(r=n.call({lexer:this},e,t))&&(e=e.substring(r.raw.length),t.push(r),!0)))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);1===r.raw.length&&void 0!==n?n.raw+="\n":t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+r.raw,n.text+="\n"+r.text,this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+r.raw,n.text+="\n"+r.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},t.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}let s=e;if(this.options.extensions?.startBlock){let t,n=1/0,r=e.slice(1);this.options.extensions.startBlock.forEach(e=>{t=e.call({lexer:this},r),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(s=e.substring(0,n+1))}if(this.state.top&&(r=this.tokenizer.paragraph(s))){let o=t.at(-1);n&&"paragraph"===o?.type?(o.raw+=(o.raw.endsWith("\n")?"":"\n")+r.raw,o.text+="\n"+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):t.push(r),n=s.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let n=t.at(-1);"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+r.raw,n.text+="\n"+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n,r=e,s=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(s=this.tokenizer.rules.inline.reflinkSearch.exec(r));)e.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(s=this.tokenizer.rules.inline.anyPunctuation.exec(r));)r=r.slice(0,s.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;null!=(s=this.tokenizer.rules.inline.blockSkip.exec(r));)n=s[2]?s[2].length:0,r=r.slice(0,s.index+n)+"["+"a".repeat(s[0].length-n-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let o=!1,i="";for(;e;){let n;if(o||(i=""),o=!1,this.options.extensions?.inline?.some(r=>!!(n=r.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0)))continue;if(n=this.tokenizer.escape(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.tag(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.link(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(n.raw.length);let r=t.at(-1);"text"===n.type&&"text"===r?.type?(r.raw+=n.raw,r.text+=n.text):t.push(n);continue}if(n=this.tokenizer.emStrong(e,r,i)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.codespan(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.br(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.del(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.autolink(e)){e=e.substring(n.raw.length),t.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(e))){e=e.substring(n.raw.length),t.push(n);continue}let s=e;if(this.options.extensions?.startInline){let t,n=1/0,r=e.slice(1);this.options.extensions.startInline.forEach(e=>{t=e.call({lexer:this},r),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(s=e.substring(0,n+1))}if(n=this.tokenizer.inlineText(s)){e=e.substring(n.raw.length),"_"!==n.raw.slice(-1)&&(i=n.raw.slice(-1)),o=!0;let r=t.at(-1);"text"===r?.type?(r.raw+=n.raw,r.text+=n.text):t.push(n);continue}if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return t}},ye=class{options;parser;constructor(e){this.options=e||h}space(e){return""}code({text:e,lang:t,escaped:n}){let r=(t||"").match(w.notSpaceStart)?.[0],s=e.replace(w.endingNewline,"")+"\n";return r?'<pre><code class="language-'+he(r)+'">'+(n?s:he(s,!0))+"</code></pre>\n":"<pre><code>"+(n?s:he(s,!0))+"</code></pre>\n"}blockquote({tokens:e}){return`<blockquote>\n${this.parser.parse(e)}</blockquote>\n`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>\n`}hr(e){return"<hr>\n"}list(e){let t=e.ordered,n=e.start,r="";for(let t=0;t<e.items.length;t++){let n=e.items[t];r+=this.listitem(n)}let s=t?"ol":"ul";return"<"+s+(t&&1!==n?' start="'+n+'"':"")+">\n"+r+"</"+s+">\n"}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>\n`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>\n`}table(e){let t="",n="";for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let r="";for(let t=0;t<e.rows.length;t++){let s=e.rows[t];n="";for(let e=0;e<s.length;e++)n+=this.tablecell(s[e]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),"<table>\n<thead>\n"+t+"</thead>\n"+r+"</table>\n"}tablerow({text:e}){return`<tr>\n${e}</tr>\n`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>\n`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${he(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),s=de(e);if(null===s)return r;let o='<a href="'+(e=s)+'"';return t&&(o+=' title="'+he(t)+'"'),o+=">"+r+"</a>",o}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let s=de(e);if(null===s)return he(n);let o=`<img src="${e=s}" alt="${n}"`;return t&&(o+=` title="${he(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:he(e.text)}},me=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},ve=class e{options;renderer;textRenderer;constructor(e){this.options=e||h,this.options.renderer=this.options.renderer||new ye,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new me}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){let t="";for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==n||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(e.type)){t+=n||"";continue}}let s=r;switch(s.type){case"space":t+=this.renderer.space(s);break;case"hr":t+=this.renderer.hr(s);break;case"heading":t+=this.renderer.heading(s);break;case"code":t+=this.renderer.code(s);break;case"table":t+=this.renderer.table(s);break;case"blockquote":t+=this.renderer.blockquote(s);break;case"list":t+=this.renderer.list(s);break;case"checkbox":t+=this.renderer.checkbox(s);break;case"html":t+=this.renderer.html(s);break;case"def":t+=this.renderer.def(s);break;case"paragraph":t+=this.renderer.paragraph(s);break;case"text":t+=this.renderer.text(s);break;default:{let e='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return t}parseInline(e,t=this.renderer){let n="";for(let r=0;r<e.length;r++){let s=e[r];if(this.options.extensions?.renderers?.[s.type]){let e=this.options.extensions.renderers[s.type].call({parser:this},s);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){n+=e||"";continue}}let o=s;switch(o.type){case"escape":case"text":n+=t.text(o);break;case"html":n+=t.html(o);break;case"link":n+=t.link(o);break;case"image":n+=t.image(o);break;case"checkbox":n+=t.checkbox(o);break;case"strong":n+=t.strong(o);break;case"em":n+=t.em(o);break;case"codespan":n+=t.codespan(o);break;case"br":n+=t.br(o);break;case"del":n+=t.del(o);break;default:{let e='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}},ke=class{options;block;constructor(e){this.options=e||h}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?be.lex:be.lexInline}provideParser(){return this.block?ve.parse:ve.parseInline}},xe=new class{defaults={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=ve;Renderer=ye;TextRenderer=me;Lexer=be;Tokenizer=we;Hooks=ke;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case"table":{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case"list":{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let s=e[r].flat(1/0);n=n.concat(this.walkTokens(s,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){let n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let r=e.renderer.apply(this,t);return!1===r&&(r=n.apply(this,t)),r}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new ye(this.defaults);for(let n in e.renderer){if(!(n in t))throw new Error(`renderer '${n}' does not exist`);if(["options","parser"].includes(n))continue;let r=n,s=e.renderer[r],o=t[r];t[r]=(...e)=>{let n=s.apply(t,e);return!1===n&&(n=o.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new we(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;let r=n,s=e.tokenizer[r],o=t[r];t[r]=(...e)=>{let n=s.apply(t,e);return!1===n&&(n=o.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new ke;for(let n in e.hooks){if(!(n in t))throw new Error(`hook '${n}' does not exist`);if(["options","block"].includes(n))continue;let r=n,s=e.hooks[r],o=t[r];ke.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&ke.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await s.call(t,e);return o.call(t,n)})();let r=s.call(t,e);return o.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await s.apply(t,e);return!1===n&&(n=await o.apply(t,e)),n})();let n=s.apply(t,e);return!1===n&&(n=o.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return be.lex(e,t??this.defaults)}parser(e,t){return ve.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},s={...this.defaults,...r},o=this.onError(!!s.silent,!!s.async);if(!0===this.defaults.async&&!1===r.async)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||null===t)return o(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof t)return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=e),s.async)return(async()=>{let n=s.hooks?await s.hooks.preprocess(t):t,r=await(s.hooks?await s.hooks.provideLexer():e?be.lex:be.lexInline)(n,s),o=s.hooks?await s.hooks.processAllTokens(r):r;s.walkTokens&&await Promise.all(this.walkTokens(o,s.walkTokens));let i=await(s.hooks?await s.hooks.provideParser():e?ve.parse:ve.parseInline)(o,s);return s.hooks?await s.hooks.postprocess(i):i})().catch(o);try{s.hooks&&(t=s.hooks.preprocess(t));let n=(s.hooks?s.hooks.provideLexer():e?be.lex:be.lexInline)(t,s);s.hooks&&(n=s.hooks.processAllTokens(n)),s.walkTokens&&this.walkTokens(n,s.walkTokens);let r=(s.hooks?s.hooks.provideParser():e?ve.parse:ve.parseInline)(n,s);return s.hooks&&(r=s.hooks.postprocess(r)),r}catch(e){return o(e)}}}onError(e,t){return n=>{if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){let e="<p>An error occurred:</p><pre>"+he(n.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function Ee(e,t){return xe.parse(e,t)}Ee.options=Ee.setOptions=function(e){return xe.setOptions(e),Ee.defaults=xe.defaults,d(Ee.defaults),Ee},Ee.getDefaults=u,Ee.defaults=h,Ee.use=function(...e){return xe.use(...e),Ee.defaults=xe.defaults,d(Ee.defaults),Ee},Ee.walkTokens=function(e,t){return xe.walkTokens(e,t)},Ee.parseInline=xe.parseInline,Ee.Parser=ve,Ee.parser=ve.parse,Ee.Renderer=ye,Ee.TextRenderer=me,Ee.Lexer=be,Ee.lexer=be.lex,Ee.Tokenizer=we,Ee.Hooks=ke,Ee.parse=Ee;Ee.options,Ee.setOptions,Ee.use,Ee.walkTokens,Ee.parseInline,ve.parse,be.lex;var Se=(0,a.vs)('<div class="nbw-p-4 nbw-text-gray-500 nbw-text-sm">Loading post...'),Ae=(0,a.vs)('<div class="nbw-p-4 nbw-text-red-500 nbw-text-sm">Failed to load embedded post'),Te=(0,a.vs)('<img class="nbw-w-full nbw-h-32 nbw-object-cover nbw-rounded nbw-mb-3">'),$e=(0,a.vs)('<p class="nbw-text-sm nbw-text-gray-600 nbw-mb-3 nbw-line-clamp-2">'),Re=(0,a.vs)('<img class="nbw-w-5 nbw-h-5 nbw-rounded-full">'),Ie=(0,a.vs)('<a class="nbw-block nbw-no-underline hover:nbw-no-underline"><div class="nbw-embedded-post-content nbw-p-4"><h4 class="nbw-text-lg nbw-font-semibold nbw-text-gray-900 nbw-mb-2 nbw-line-clamp-2"></h4><div class="nbw-flex nbw-items-center nbw-gap-2 nbw-text-xs nbw-text-gray-500"><span class="nbw-font-medium nbw-text-gray-700"></span><span>•</span><span>'),Be=(0,a.vs)('<div class="nbw-embedded-post nbw-my-4 nbw-border nbw-border-gray-300 nbw-rounded-lg nbw-overflow-hidden nbw-bg-gray-50 hover:nbw-bg-gray-100 nbw-transition-colors">');const Le=e=>{const[t,n]=(0,i.n5)(null),[r,s]=(0,i.n5)(!0),[o,l]=(0,i.n5)(!1);(0,i.Rc)(async()=>{try{s(!0);const t=await e.onFetch(e.eventId);n(t),l(!t)}catch(e){console.error("Failed to fetch embedded post:",e),l(!0)}finally{s(!1)}});return c=Be(),(0,a.Yr)(c,(0,i.a0)(i.wv,{get when(){return r()},get children(){return Se()}}),null),(0,a.Yr)(c,(0,i.a0)(i.wv,{get when(){return(0,a.ph)(()=>!!o())()&&!r()},get children(){return Ae()}}),null),(0,a.Yr)(c,(0,i.a0)(i.wv,{get when(){return(0,a.ph)(()=>!!t())()&&!r()},get children(){var n=Ie(),r=n.firstChild,s=r.firstChild,o=s.nextSibling,l=o.firstChild,c=l.nextSibling.nextSibling;return(0,a.Yr)(r,(0,i.a0)(i.wv,{get when(){return t().image},get children(){var e=Te();return(0,i.gb)(n=>{var r=t().image,s=t().title;return r!==n.e&&(0,a.Bq)(e,"src",n.e=r),s!==n.t&&(0,a.Bq)(e,"alt",n.t=s),n},{e:void 0,t:void 0}),e}}),s),(0,a.Yr)(s,()=>t().title||"Untitled Post"),(0,a.Yr)(r,(0,i.a0)(i.wv,{get when(){return t().summary},get children(){var e=$e();return(0,a.Yr)(e,()=>t().summary),e}}),o),(0,a.Yr)(o,(0,i.a0)(i.wv,{get when(){return t().authorAvatar},get children(){var e=Re();return(0,i.gb)(n=>{var r=t().authorAvatar,s=t().authorName;return r!==n.e&&(0,a.Bq)(e,"src",n.e=r),s!==n.t&&(0,a.Bq)(e,"alt",n.t=s),n},{e:void 0,t:void 0}),e}}),l),(0,a.Yr)(l,()=>t().authorName),(0,a.Yr)(c,()=>{return e=t().published_at||t().created_at,new Date(1e3*e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"});var e}),(0,i.gb)(()=>(0,a.Bq)(n,"href",`#/post/${e.eventId}`)),n}}),null),c;var c};var _e=(0,a.vs)("<div class=nbw-content-renderer>"),Pe=(0,a.vs)("<div>");const Ce=e=>{const[t,n]=(0,i.n5)([]),[r,s]=(0,i.n5)([]);return(0,i.EH)(()=>{(e=>{const t=/(?:nostr\s*:?\s*)?(naddr1\S+|note1\S+|nevent1\S+|nprofile1\S+|npub1\S+|nrelay1\S+)/gi,r=[],o=[];let i,a=0,l=0;for(;null!==(i=t.exec(e));){const t=i[1].trim().replace(/[)\]\}\.,!?:;"'>]+$/,""),n=t.substring(0,t.indexOf("1")+1).toLowerCase();let s="other";if(n.startsWith("naddr")?s="naddr":n.startsWith("nevent")?s="nevent":n.startsWith("note")&&(s="note"),"other"!==s){o.push(e.substring(a,i.index));const n="nostr-ref-"+l++;o.push(`[[${n}]]`),r.push({id:n,fullId:t,type:s}),a=i.index+i[0].length}}o.push(e.substring(a));const c=o.map(e=>{if(e.startsWith("[[")&&e.endsWith("]]"))return e;let t=(e=>e.replace(/(https?:\/\/[^\s]+\.(?:jpg|jpeg|png|gif|webp|svg|mp4|webm|mov|avi))/gi,e=>{const t=e.toLowerCase();return t.endsWith(".mp4")||t.endsWith(".webm")||t.endsWith(".mov")||t.endsWith(".avi")?`\n\n<video controls class="nbw-content-video nbw-max-w-full nbw-h-auto nbw-rounded-lg nbw-my-4"><source src="${e}"></video>\n\n`:`\n\n<img src="${e}" alt="Image" class="nbw-content-image nbw-max-w-full nbw-h-auto nbw-rounded-lg nbw-my-4" />\n\n`}))(e);return t=t.replace(/(?:nostr:\s*)?(npub1\S+|nprofile1\S+|nrelay1\S+)/gi,(e,t)=>`<a href="https://njump.me/${t}" target="_blank" rel="noopener noreferrer" class="nbw-nostr-link nbw-text-blue-600 hover:nbw-underline">${t}</a>`),t});n(r),s(c)})(e.content)}),o=_e(),(0,a.Yr)(o,(0,i.a0)(i.a,{get each(){return r()},children:n=>{if(n.startsWith("[[")&&n.endsWith("]]")){const r=n.slice(2,-2),s=t().find(e=>e.id===r);return s?(0,i.a0)(Le,{get eventId(){return s.fullId},get onFetch(){return e.onFetchPost}}):null}if(e.useMarkdown)return s=Pe(),(0,i.gb)(()=>s.innerHTML=Ee(n)),s;{const e=n.replace(/\n/g,"<br />");return(r=Pe()).innerHTML=e,r}var r,s}})),o;var o};var Ue=(0,a.vs)('<div class="nbw-grid nbw-gap-6">'),Ne=(0,a.vs)('<div class="nbw-py-2 nbw-border-b nbw-border-gray-200"><div class="nbw-text-gray-500 nbw-text-xs nbw-mb-1"></div><a class="nbw-text-blue-600 hover:nbw-underline nbw-font-medium nbw-no-underline hover:nbw-text-blue-800">'),Oe=(0,a.vs)('<article class="nbw-bg-white nbw-rounded-lg nbw-shadow-md nbw-overflow-hidden nbw-cursor-pointer"><div class=nbw-p-6><h2 class="nbw-text-2xl nbw-font-bold nbw-mb-2 nbw-text-gray-900 hover:nbw-underline"></h2><div class="nbw-flex nbw-items-center nbw-gap-3 nbw-mb-3"><div class=nbw-flex-1><p class="nbw-text-gray-900 nbw-text-sm nbw-font-medium"></p><p class="nbw-text-gray-600 nbw-text-xs">'),ze=(0,a.vs)('<img class="nbw-w-full nbw-h-48 nbw-object-cover">'),qe=(0,a.vs)('<img class="nbw-w-8 nbw-h-8 nbw-rounded-full nbw-object-cover">'),Me=(0,a.vs)('<div class="nbw-flex nbw-justify-end"><a class="nbw-read-more nbw-text-black nbw-font-medium nbw-no-underline hover:nbw-underline">Read more →'),He=(0,a.vs)('<p class="nbw-text-gray-700 nbw-mb-4">');const je=e=>{const t=t=>{const n=new Date(1e3*t);switch(e.config.dateFormat){case"short":default:return n.toLocaleDateString();case"long":return n.toLocaleDateString(void 0,{year:"numeric",month:"long",day:"numeric"});case"relative":const e=Date.now()-n.getTime(),t=Math.floor(e/864e5);return 0===t?"Today":1===t?"Yesterday":t<7?`${t} days ago`:t<30?`${Math.floor(t/7)} weeks ago`:t<365?`${Math.floor(t/30)} months ago`:`${Math.floor(t/365)} years ago`}};return n=Ue(),(0,a.Yr)(n,(0,i.a0)(i.a,{get each(){return e.posts},children:n=>{return"compact"===e.config.layout?(g=Ne(),w=g.firstChild,b=w.nextSibling,(0,a.Yr)(w,()=>t(n.published_at||n.created_at)),b.$$click=t=>{t.preventDefault(),e.onNavigate(n.naddr||n.id)},(0,a.Yr)(b,()=>n.title),(0,i.gb)(()=>(0,a.Bq)(b,"href",`#/post/${n.naddr||n.id}`)),g):(l=Oe(),c=l.firstChild,u=c.firstChild,h=u.nextSibling,d=h.firstChild,f=d.firstChild,p=f.nextSibling,l.$$click=()=>e.onNavigate(n.naddr||n.id),(0,a.Yr)(l,(r=(0,a.ph)(()=>!(!e.config.showImages||!n.image)),()=>{return r()&&(e=ze(),(0,i.gb)(t=>{var r=n.image,s=n.title;return r!==t.e&&(0,a.Bq)(e,"src",t.e=r),s!==t.t&&(0,a.Bq)(e,"alt",t.t=s),t},{e:void 0,t:void 0}),e);var e}),c),(0,a.Yr)(u,()=>n.title),(0,a.Yr)(h,(s=(0,a.ph)(()=>!!n.authorAvatar),()=>{return s()&&(e=qe(),(0,i.gb)(t=>{var r=n.authorAvatar,s=n.authorName;return r!==t.e&&(0,a.Bq)(e,"src",t.e=r),s!==t.t&&(0,a.Bq)(e,"alt",t.t=s),t},{e:void 0,t:void 0}),e);var e}),d),(0,a.Yr)(f,()=>n.authorName),(0,a.Yr)(p,()=>t(n.published_at||n.created_at)),(0,a.Yr)(c,(o=(0,a.ph)(()=>!(1!==n.kind&&"1"!==n.kind)),()=>{return o()?(0,i.a0)(Ce,{get content(){return n.content||""},get onFetchPost(){return e.onFetchPost},useMarkdown:!1}):[(0,a.ph)(()=>{return(0,a.ph)(()=>!(!e.config.showSummary||!n.summary))()&&(t=He(),(0,a.Yr)(t,()=>n.summary),t);var t}),(t=Me(),r=t.firstChild,r.$$click=t=>{t.stopPropagation(),t.preventDefault(),e.onNavigate(n.naddr||n.id)},(0,i.gb)(()=>(0,a.Bq)(r,"href",`#/post/${n.naddr||n.id}`)),t)];var t,r}),null),l);var r,s,o,l,c,u,h,d,f,p,g,w,b}})),(0,i.gb)(t=>(0,a.pP)(n,{"nbw-grid-cols-1":"list"===e.config.layout||"compact"===e.config.layout,"nbw-grid-cols-1 md:nbw-grid-cols-2 lg:nbw-grid-cols-3":"grid"===e.config.layout},t)),n;var n};(0,a.z_)(["click"]);var De=(0,a.vs)('<img class="nbw-w-full nbw-h-64 nbw-object-cover">'),Fe=(0,a.vs)('<img class="nbw-w-12 nbw-h-12 nbw-rounded-full nbw-object-cover">'),Ve=(0,a.vs)('<article class="nbw-bg-white nbw-rounded-lg nbw-shadow-lg nbw-overflow-hidden"><div class=nbw-p-8><button class="nbw-mb-4 nbw-text-blue-600 hover:nbw-text-blue-800 nbw-font-semibold nbw-bg-transparent nbw-border-none nbw-cursor-pointer nbw-p-0">← Back to posts</button><h1 class="nbw-text-4xl nbw-font-bold nbw-mb-4 nbw-text-gray-900"></h1><div class="nbw-flex nbw-items-center nbw-gap-4 nbw-mb-6 nbw-pb-6 nbw-border-b nbw-border-gray-200"><div class=nbw-flex-1><p class="nbw-text-gray-900 nbw-font-semibold"></p><p class="nbw-text-gray-600 nbw-text-sm"></p></div></div><div class="nbw-prose nbw-max-w-none nbw-text-gray-800">');const We=e=>{return t=Ve(),n=t.firstChild,r=n.firstChild,s=r.nextSibling,o=s.nextSibling,l=o.firstChild,c=l.firstChild,u=c.nextSibling,h=o.nextSibling,(0,a.Yr)(t,(0,i.a0)(i.wv,{get when(){return(0,a.ph)(()=>!!e.config.showImages)()&&e.post.image},get children(){var t=De();return(0,i.gb)(n=>{var r=e.post.image,s=e.post.title;return r!==n.e&&(0,a.Bq)(t,"src",n.e=r),s!==n.t&&(0,a.Bq)(t,"alt",n.t=s),n},{e:void 0,t:void 0}),t}}),n),r.$$click=()=>e.onBack(),(0,a.Yr)(s,()=>e.post.title),(0,a.Yr)(o,(0,i.a0)(i.wv,{get when(){return e.post.authorAvatar},get children(){var t=Fe();return(0,i.gb)(n=>{var r=e.post.authorAvatar,s=e.post.authorName;return r!==n.e&&(0,a.Bq)(t,"src",n.e=r),s!==n.t&&(0,a.Bq)(t,"alt",n.t=s),n},{e:void 0,t:void 0}),t}}),l),(0,a.Yr)(c,()=>e.post.authorName),(0,a.Yr)(u,()=>{return t=e.post.published_at||e.post.created_at,new Date(1e3*t).toLocaleDateString(void 0,{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"});var t}),(0,a.Yr)(h,(0,i.a0)(Ce,{get content(){return e.post.content||""},get onFetchPost(){return e.onFetchPost},get useMarkdown(){return 30023===e.post.kind||"30023"===e.post.kind}})),t;var t,n,r,s,o,l,c,u,h};(0,a.z_)(["click"]);var Ze=(0,a.vs)('<div class="nbw-flex nbw-items-center nbw-justify-center nbw-p-8"><div class="nbw-animate-spin nbw-rounded-full nbw-h-12 nbw-w-12 nbw-border-b-2 nbw-border-gray-900">');const Ke=()=>Ze();var Ye=(0,a.vs)('<div class="nbw-divider nbw-hidden md:nbw-block nbw-h-8 nbw-w-px nbw-bg-gray-300">'),Ge=(0,a.vs)('<div class="nbw-control-group nbw-author-control nbw-flex nbw-flex-col nbw-gap-1"><select class="nbw-author-select nbw-px-3 nbw-py-1.5 nbw-text-sm nbw-font-medium nbw-border nbw-border-gray-300 nbw-rounded-md nbw-bg-white nbw-text-gray-700 hover:nbw-bg-gray-50 nbw-transition-all nbw-cursor-pointer focus:nbw-outline-none focus:nbw-ring-2 focus:nbw-ring-blue-500"><option class=nbw-author-option value>All Authors</option></select><span class="nbw-control-label nbw-text-xs nbw-text-gray-500 nbw-text-center">Author'),Je=(0,a.vs)('<div class="nbw-control-panel nbw-bg-white nbw-border nbw-border-gray-200 nbw-rounded-lg nbw-shadow-sm nbw-mb-6 nbw-p-4"><div class="nbw-control-panel-inner nbw-flex nbw-flex-wrap nbw-items-center nbw-gap-3 md:nbw-gap-4"><div class="nbw-control-group nbw-layout-control nbw-flex nbw-flex-col nbw-gap-1"><div class="nbw-button-group nbw-flex nbw-rounded-md nbw-shadow-sm"><button class="nbw-layout-btn nbw-layout-btn-list nbw-px-3 nbw-py-1.5 nbw-text-sm nbw-font-medium nbw-border nbw-rounded-l-md nbw-transition-all"title="List View"><svg class="nbw-icon nbw-w-4 nbw-h-4"fill=none stroke=currentColor viewBox="0 0 24 24"><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M4 6h16M4 12h16M4 18h16"></path></svg></button><button class="nbw-layout-btn nbw-layout-btn-grid nbw-px-3 nbw-py-1.5 nbw-text-sm nbw-font-medium nbw-border nbw-border-l-0 nbw-transition-all"title="Grid View"><svg class="nbw-icon nbw-w-4 nbw-h-4"fill=none stroke=currentColor viewBox="0 0 24 24"><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M4 5a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1H5a1 1 0 01-1-1V5zM14 5a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 01-1-1V5zM4 15a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1H5a1 1 0 01-1-1v-4zM14 15a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 01-1-1v-4z"></path></svg></button><button class="nbw-layout-btn nbw-layout-btn-compact nbw-px-3 nbw-py-1.5 nbw-text-sm nbw-font-medium nbw-border nbw-border-l-0 nbw-rounded-r-md nbw-transition-all"title="Compact View"><svg class="nbw-icon nbw-w-4 nbw-h-4"fill=none stroke=currentColor viewBox="0 0 24 24"><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M4 8h16M4 16h16"></path></svg></button></div><span class="nbw-control-label nbw-text-xs nbw-text-gray-500 nbw-text-center">View</span></div><div class="nbw-divider nbw-hidden md:nbw-block nbw-h-8 nbw-w-px nbw-bg-gray-300"></div><div class="nbw-control-group nbw-content-type-control nbw-flex nbw-flex-col nbw-gap-1"><div class="nbw-button-group nbw-flex nbw-rounded-md nbw-shadow-sm"><button class="nbw-content-btn nbw-content-btn-all nbw-px-3 nbw-py-1.5 nbw-text-sm nbw-font-medium nbw-border nbw-rounded-l-md nbw-transition-all"title="All Content">All</button><button class="nbw-content-btn nbw-content-btn-articles nbw-px-3 nbw-py-1.5 nbw-text-sm nbw-font-medium nbw-border nbw-border-l-0 nbw-transition-all"title="Articles Only">Articles</button><button class="nbw-content-btn nbw-content-btn-notes nbw-px-3 nbw-py-1.5 nbw-text-sm nbw-font-medium nbw-border nbw-border-l-0 nbw-rounded-r-md nbw-transition-all"title="Notes Only">Notes</button></div><span class="nbw-control-label nbw-text-xs nbw-text-gray-500 nbw-text-center">Type</span></div><div class="nbw-divider nbw-hidden md:nbw-block nbw-h-8 nbw-w-px nbw-bg-gray-300"></div><div class="nbw-control-group nbw-date-control nbw-flex nbw-flex-col nbw-gap-1"><select class="nbw-date-select nbw-px-3 nbw-py-1.5 nbw-text-sm nbw-font-medium nbw-border nbw-border-gray-300 nbw-rounded-md nbw-bg-white nbw-text-gray-700 hover:nbw-bg-gray-50 nbw-transition-all nbw-cursor-pointer focus:nbw-outline-none focus:nbw-ring-2 focus:nbw-ring-blue-500"><option class=nbw-date-option value=all>All Time</option><option class=nbw-date-option value=week>Last Week</option><option class=nbw-date-option value=month>Last Month</option><option class=nbw-date-option value=year>Last Year</option></select><span class="nbw-control-label nbw-text-xs nbw-text-gray-500 nbw-text-center">Period</span></div><div class="nbw-spacer nbw-flex-1 nbw-hidden lg:nbw-block"></div><div class="nbw-control-group nbw-refresh-control nbw-flex nbw-flex-col nbw-gap-1"><button class="nbw-refresh-btn nbw-px-4 nbw-py-1.5 nbw-bg-blue-600 nbw-text-white nbw-text-sm nbw-font-medium nbw-rounded-md hover:nbw-bg-blue-700 nbw-transition-all nbw-shadow-sm hover:nbw-shadow focus:nbw-outline-none focus:nbw-ring-2 focus:nbw-ring-blue-500"title="Refresh Posts"><svg class="nbw-icon nbw-w-4 nbw-h-4 nbw-inline nbw-mr-1.5"fill=none stroke=currentColor viewBox="0 0 24 24"><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"></path></svg><span class="nbw-hidden sm:nbw-inline">Refresh</span></button><span class="nbw-control-label nbw-text-xs nbw-text-gray-500 nbw-text-center nbw-invisible">Action'),Qe=(0,a.vs)("<option class=nbw-author-option>");const Xe=e=>{const t=(0,i.To)(()=>{const t=new Map;return e.posts.forEach(e=>{t.has(e.pubkey)||t.set(e.pubkey,{pubkey:e.pubkey,name:e.authorName||e.pubkey.substring(0,8)+"...",avatar:e.authorAvatar})}),Array.from(t.values())}),n=(0,i.To)(()=>t().length>1),r=(0,i.To)(()=>e.config.selectedAuthor??"");return s=Je(),o=s.firstChild,l=o.firstChild,c=l.firstChild.firstChild,u=c.nextSibling,h=u.nextSibling,d=l.nextSibling.nextSibling,f=d.firstChild.firstChild,p=f.nextSibling,g=p.nextSibling,w=d.nextSibling.nextSibling,b=w.firstChild,y=w.nextSibling,m=y.nextSibling.firstChild,c.$$click=()=>e.onLayoutChange("list"),u.$$click=()=>e.onLayoutChange("grid"),h.$$click=()=>e.onLayoutChange("compact"),f.$$click=()=>e.onContentTypeChange("all"),p.$$click=()=>e.onContentTypeChange("long-form"),g.$$click=()=>e.onContentTypeChange("short-form"),b.addEventListener("change",t=>e.onDateRangeChange(t.currentTarget.value)),(0,a.Yr)(o,(0,i.a0)(i.wv,{get when(){return n()},get children(){return[Ye(),(n=Ge(),s=n.firstChild,o=s.firstChild,s.addEventListener("change",t=>e.onAuthorChange(t.currentTarget.value||void 0)),(0,a.Yr)(s,(0,i.a0)(i.a,{get each(){return t()},children:e=>{return t=Qe(),(0,a.Yr)(t,()=>e.name),(0,i.gb)(()=>t.selected=r()===e.pubkey),(0,i.gb)(()=>t.value=e.pubkey),t;var t}}),null),(0,i.gb)(()=>o.selected=""===r()),(0,i.gb)(()=>s.value=r()),n)];var n,s,o}}),y),m.$$click=()=>e.onRefresh(),(0,i.gb)(t=>{var n={"nbw-active nbw-bg-blue-600 nbw-text-white nbw-border-blue-600":"list"===e.config.layout,"nbw-bg-white nbw-text-gray-700 nbw-border-gray-300 hover:nbw-bg-gray-50":"list"!==e.config.layout},r={"nbw-active nbw-bg-blue-600 nbw-text-white nbw-border-blue-600":"grid"===e.config.layout,"nbw-bg-white nbw-text-gray-700 nbw-border-gray-300 hover:nbw-bg-gray-50":"grid"!==e.config.layout},s={"nbw-active nbw-bg-blue-600 nbw-text-white nbw-border-blue-600":"compact"===e.config.layout,"nbw-bg-white nbw-text-gray-700 nbw-border-gray-300 hover:nbw-bg-gray-50":"compact"!==e.config.layout},o={"nbw-active nbw-bg-blue-600 nbw-text-white nbw-border-blue-600":"all"===e.config.contentType,"nbw-bg-white nbw-text-gray-700 nbw-border-gray-300 hover:nbw-bg-gray-50":"all"!==e.config.contentType},i={"nbw-active nbw-bg-blue-600 nbw-text-white nbw-border-blue-600":"long-form"===e.config.contentType,"nbw-bg-white nbw-text-gray-700 nbw-border-gray-300 hover:nbw-bg-gray-50":"long-form"!==e.config.contentType},l={"nbw-active nbw-bg-blue-600 nbw-text-white nbw-border-blue-600":"short-form"===e.config.contentType,"nbw-bg-white nbw-text-gray-700 nbw-border-gray-300 hover:nbw-bg-gray-50":"short-form"!==e.config.contentType};return t.e=(0,a.pP)(c,n,t.e),t.t=(0,a.pP)(u,r,t.t),t.a=(0,a.pP)(h,s,t.a),t.o=(0,a.pP)(f,o,t.o),t.i=(0,a.pP)(p,i,t.i),t.n=(0,a.pP)(g,l,t.n),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),s;var s,o,l,c,u,h,d,f,p,g,w,b,y,m};(0,a.z_)(["click"]);var et=(0,a.vs)('<div class="nbw-bg-red-100 nbw-border nbw-border-red-400 nbw-text-red-700 nbw-px-4 nbw-py-3 nbw-rounded nbw-mb-4">'),tt=(0,a.vs)('<div class="nbw-font-sans nbw-antialiased">'),nt=(0,a.vs)('<svg class="nbw-animate-spin nbw-h-5 nbw-w-5 nbw-inline nbw-mr-2"fill=none viewBox="0 0 24 24"><circle class=nbw-opacity-25 cx=12 cy=12 r=10 stroke=currentColor stroke-width=4></circle><path class=nbw-opacity-75 fill=currentColor 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">'),rt=(0,a.vs)('<div class="nbw-load-more-container nbw-flex nbw-justify-center nbw-mt-8"><button class="nbw-load-more-btn nbw-px-6 nbw-py-3 nbw-bg-blue-600 nbw-text-white nbw-font-medium nbw-rounded-lg hover:nbw-bg-blue-700 nbw-transition-all nbw-shadow-md hover:nbw-shadow-lg disabled:nbw-opacity-50 disabled:nbw-cursor-not-allowed">');const st=e=>{const[t,n]=(0,i.n5)([]),[r,s]=(0,i.n5)([]),[o,u]=(0,i.n5)(0),[h,d]=(0,i.n5)(null),[f,p]=(0,i.n5)(!0),[g,w]=(0,i.n5)(!1),[b,y]=(0,i.n5)(null),[m,v]=(0,i.n5)(e.config),k=(0,c.createRouter)(),x=new l.NostrService(m().relays),E=async(e=!1)=>{try{e?w(!0):p(!0),y(null);const t=m(),r=3*t.postsPerPage,i=await x.fetchPosts(t.pubkey,r,t.contentType,t.dateRange);s(i);const a=t.selectedAuthor?i.filter(e=>e.pubkey===t.selectedAuthor):i;u(e?Math.min(o()+t.postsPerPage,a.length):Math.min(t.postsPerPage,a.length));const l=a.slice(0,o());n(l),p(!1),w(!1)}catch(e){y("Failed to load posts. Please try again later."),p(!1),w(!1),console.error("Error fetching posts:",e)}},S=()=>{const e=o(),t=r(),s=m(),i=s.selectedAuthor?t.filter(e=>e.pubkey===s.selectedAuthor):t,a=Math.min(e+s.postsPerPage,i.length);u(a),n(i.slice(0,a))};(0,i.EH)(()=>{m(),E()}),(0,i.EH)(async()=>{const e=k.route();if("detail"===e.view&&e.postId){const n=t().find(t=>t.id===e.postId);if(n)d(n);else try{p(!0);const t=await x.fetchPostById(e.postId);d(t),p(!1)}catch(e){y("Failed to load post."),p(!1),console.error("Error fetching post:",e)}}else d(null)}),(0,i.Ki)(()=>{x.close()});const A=e=>{v({...m(),layout:e})},T=e=>{v({...m(),contentType:e})},$=e=>{const t=Math.floor(Date.now()/1e3);let n;switch(e){case"week":n={since:t-604800};break;case"month":n={since:t-2592e3};break;case"year":n={since:t-31536e3};break;default:n=void 0}v({...m(),dateRange:n})},R=e=>{v({...m(),selectedAuthor:e})};return I=tt(),(0,a.Yr)(I,(0,i.a0)(i.wv,{get when(){return b()},get children(){var e=et();return(0,a.Yr)(e,b),e}}),null),(0,a.Yr)(I,(0,i.a0)(i.wv,{get when(){return(0,a.ph)(()=>!!m().showControls)()&&"list"===k.route().view},get children(){return(0,i.a0)(Xe,{get config(){return m()},get posts(){return r()},onLayoutChange:A,onContentTypeChange:T,onDateRangeChange:$,onAuthorChange:R,onRefresh:E})}}),null),(0,a.Yr)(I,(0,i.a0)(i.wv,{get when(){return f()},get children(){return(0,i.a0)(Ke,{})}}),null),(0,a.Yr)(I,(0,i.a0)(i.wv,{get when(){return!f()},get children(){return(0,i.a0)(i.wv,{get when(){return(0,a.ph)(()=>"detail"===k.route().view)()&&h()},get fallback(){return[(0,i.a0)(je,{get posts(){return t()},get config(){return m()},get onNavigate(){return k.navigateToPost},onFetchPost:e=>x.fetchPostById(e)}),(0,i.a0)(i.wv,{get when(){return(0,a.ph)(()=>!!(()=>{const e=m(),t=r(),n=e.selectedAuthor?t.filter(t=>t.pubkey===e.selectedAuthor):t;return o()<n.length})())()&&"load-more"===m().pagination},get children(){var e=rt(),t=e.firstChild;return t.$$click=S,(0,a.Yr)(t,(0,i.a0)(i.wv,{get when(){return g()},fallback:"Load More Posts",get children(){return[nt(),"Loading..."]}})),(0,i.gb)(()=>t.disabled=g()),e}})]},children:e=>(0,i.a0)(We,{get post(){return e()},get config(){return m()},get onBack(){return k.navigateToList},onFetchPost:e=>x.fetchPostById(e)})})}}),null),(0,i.gb)(()=>(0,a.Bq)(I,"data-theme",m().theme)),I;var I};function ot(){const e=document.querySelector("script[data-pubkey]");if(!e)return void console.error("NostrBlog: Could not find script tag with data-pubkey attribute");const t=e.dataset.pubkey||"";let n,r;try{n=JSON.parse(t)}catch{n=t}(e.dataset.dateSince||e.dataset.dateUntil)&&(r={},e.dataset.dateSince&&(r.since=parseInt(e.dataset.dateSince,10)),e.dataset.dateUntil&&(r.until=parseInt(e.dataset.dateUntil,10)));const o={pubkey:n,relays:JSON.parse(e.dataset.relays||'["wss://relay.damus.io", "wss://nos.lol"]'),navSelector:e.dataset.navSelector||"",contentSelector:e.dataset.contentSelector||"",layout:e.dataset.layout||"list",theme:e.dataset.theme||"light",postsPerPage:parseInt(e.dataset.postsPerPage||"10",10),showImages:"false"!==e.dataset.showImages,dateFormat:e.dataset.dateFormat||"short",contentType:e.dataset.contentType||"all",dateRange:r,showControls:"true"===e.dataset.showControls,pagination:e.dataset.pagination||"load-more",showSummary:"false"!==e.dataset.showSummary};if(!o.pubkey||Array.isArray(o.pubkey)&&0===o.pubkey.length)return void console.error("NostrBlog: pubkey is required");if(!o.contentSelector)return void console.error("NostrBlog: contentSelector is required");const l=document.querySelector(o.contentSelector);if(!l)return void console.error(`NostrBlog: Could not find element with selector "${o.contentSelector}"`);const c=o.navSelector?document.querySelector(o.navSelector):null;(0,a.XX)(()=>(0,i.a0)(st,{config:o}),l),c&&s.e(485).then(s.bind(s,485)).then(({Navigation:e})=>{Promise.resolve().then(s.bind(s,261)).then(({NostrService:t})=>{Promise.resolve().then(s.bind(s,168)).then(({createRouter:n})=>{const r=new t(o.relays),s=n();r.fetchPosts(o.pubkey).then(t=>{(0,a.XX)(()=>(0,i.a0)(e,{posts:t,get currentPostId(){return s.route().postId},get onNavigate(){return s.navigateToPost},get onHome(){return s.navigateToList}}),c)})})})}),console.log("NostrBlog initialized with config:",o)}(0,a.z_)(["click"]),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",ot):ot();const it={init:ot};return o=o.default})());
|
|
3
3
|
//# sourceMappingURL=nostr-blog.js.map
|
package/package.json
CHANGED