diff --git a/app/web/dist/bundle.js b/app/web/dist/bundle.js index 058551c..7e7d212 100644 --- a/app/web/dist/bundle.js +++ b/app/web/dist/bundle.js @@ -1,35 +1,35 @@ -var app=function(){"use strict";function e(){}function t(e){return e()}function n(){return Object.create(null)}function r(e){e.forEach(t)}function i(e){return"function"==typeof e}function o(e,t){return e!=e?t==t:e!==t||e&&"object"==typeof e||"function"==typeof e}let s;function a(e,t){return s||(s=document.createElement("a")),s.href=t,e===s.href}const l="undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:global;function c(e,t){e.appendChild(t)}function u(e,t,n){e.insertBefore(t,n||null)}function d(e){e.parentNode&&e.parentNode.removeChild(e)}function f(e,t){for(let n=0;ne.removeEventListener(t,n,r)}function v(e){return function(t){return t.stopPropagation(),e.call(this,t)}}function A(e,t,n){null==n?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function b(e){return""===e?null:+e}function k(e,t){t=""+t,e.data!==t&&(e.data=t)}function I(e,t){e.value=null==t?"":t}function E(e,t,n,r){null==n?e.style.removeProperty(t):e.style.setProperty(t,n,r?"important":"")}function C(e,t,n){for(let n=0;n{const i=e.$$.callbacks[t];if(i){const o=function(e,t,{bubbles:n=!1,cancelable:r=!1}={}){const i=document.createEvent("CustomEvent");return i.initCustomEvent(e,n,r,t),i}(t,n,{cancelable:r});return i.slice().forEach(t=>{t.call(e,o)}),!o.defaultPrevented}return!0}}function $(e,t){const n=e.$$.callbacks[t.type];n&&n.slice().forEach(e=>e.call(this,t))}const U=[],T=[];let N=[];const L=[],O=Promise.resolve();let M=!1;function _(e){N.push(e)}function H(e){L.push(e)}const j=new Set;let G=0;function q(){if(0!==G)return;const e=S;do{try{for(;G{J.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}function X(e,t){const n=t.token={};function r(e,r,i,o){if(t.token!==n)return;t.resolved=o;let s=t.ctx;void 0!==i&&(s=s.slice(),s[i]=o);const a=e&&(t.current=e)(s);let l=!1;t.block&&(t.blocks?t.blocks.forEach((e,n)=>{n!==r&&e&&(Y(),Z(e,1,1,()=>{t.blocks[n]===e&&(t.blocks[n]=null)}),z())}):t.block.d(1),a.c(),W(a,1),a.m(t.mount(),t.anchor),l=!0),t.block=a,t.blocks&&(t.blocks[r]=a),l&&q()}if(!(i=e)||"object"!=typeof i&&"function"!=typeof i||"function"!=typeof i.then){if(t.current!==t.then)return r(t.then,1,t.value,e),!0;t.resolved=e}else{const n=Q();if(e.then(e=>{F(n),r(t.then,1,t.value,e),F(null)},e=>{if(F(n),r(t.catch,2,t.error,e),F(null),!t.hasCatch)throw e}),t.current!==t.pending)return r(t.pending,0),!0}var i}function ee(e,t){e.d(1),t.delete(e.key)}function te(e,t,n){const r=e.$$.props[t];void 0!==r&&(e.$$.bound[r]=n,n(e.$$.ctx[r]))}function ne(e){e&&e.c()}function re(e,n,o,s){const{fragment:a,after_update:l}=e.$$;a&&a.m(n,o),s||_(()=>{const n=e.$$.on_mount.map(t).filter(i);e.$$.on_destroy?e.$$.on_destroy.push(...n):r(n),e.$$.on_mount=[]}),l.forEach(_)}function ie(e,t){const n=e.$$;null!==n.fragment&&(!function(e){const t=[],n=[];N.forEach(r=>-1===e.indexOf(r)?t.push(r):n.push(r)),n.forEach(e=>e()),N=t}(n.after_update),r(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function oe(e,t){-1===e.$$.dirty[0]&&(U.push(e),M||(M=!0,O.then(q)),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const i=r.length?r[0]:n;return h.ctx&&a(h.ctx[e],h.ctx[e]=i)&&(!h.skip_bound&&h.bound[e]&&h.bound[e](i),p&&oe(t,e)),n}):[],h.update(),p=!0,r(h.before_update),h.fragment=!!s&&s(h.ctx),i.target){if(i.hydrate){const e=function(e){return Array.from(e.childNodes)}(i.target);h.fragment&&h.fragment.l(e),e.forEach(d)}else h.fragment&&h.fragment.c();i.intro&&W(t.$$.fragment),re(t,i.target,i.anchor,i.customElement),q()}F(f)}class ae{$destroy(){ie(this,1),this.$destroy=e}$on(t,n){if(!i(n))return e;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(n),()=>{const e=r.indexOf(n);-1!==e&&r.splice(e,1)}}$set(e){var t;this.$$set&&(t=e,0!==Object.keys(t).length)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}function le(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function ce(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 ue(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")}const de="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,fe=e=>e instanceof Uint8Array,he=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),pe=(e,t)=>e<<32-t|e>>>t; -/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");function ge(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)),!fe(e))throw new Error("expected Uint8Array, got "+typeof e);return e}let me=class{clone(){return this._cloneInto()}};function ye(e){const t=t=>e().update(ge(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function we(e=32){if(de&&"function"==typeof de.getRandomValues)return de.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}let ve=class extends me{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=he(this.buffer)}update(e){ue(this);const{view:t,buffer:n,blockLen:r}=this,i=(e=ge(e)).length;for(let o=0;or-o&&(this.process(n,0),o=0);for(let e=o;e>i&o),a=Number(n&o),l=r?4:0,c=r?0:4;e.setUint32(t+l,s,r),e.setUint32(t+c,a,r)}(n,r-8,BigInt(8*this.length),i),this.process(n,0);const s=he(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;ee&t^~e&n,be=(e,t,n)=>e&t^e&n^t&n,ke=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]),Ie=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ee=new Uint32Array(64);let Ce=class extends ve{constructor(){super(64,32,8,!1),this.A=0|Ie[0],this.B=0|Ie[1],this.C=0|Ie[2],this.D=0|Ie[3],this.E=0|Ie[4],this.F=0|Ie[5],this.G=0|Ie[6],this.H=0|Ie[7]}get(){const{A:e,B:t,C:n,D:r,E:i,F:o,G:s,H:a}=this;return[e,t,n,r,i,o,s,a]}set(e,t,n,r,i,o,s,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)Ee[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=Ee[e-15],n=Ee[e-2],r=pe(t,7)^pe(t,18)^t>>>3,i=pe(n,17)^pe(n,19)^n>>>10;Ee[e]=i+Ee[e-7]+r+Ee[e-16]|0}let{A:n,B:r,C:i,D:o,E:s,F:a,G:l,H:c}=this;for(let e=0;e<64;e++){const t=c+(pe(s,6)^pe(s,11)^pe(s,25))+Ae(s,a,l)+ke[e]+Ee[e]|0,u=(pe(n,2)^pe(n,13)^pe(n,22))+be(n,r,i)|0;c=l,l=a,a=s,s=o+t|0,o=i,i=r,r=n,n=t+u|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(n,r,i,o,s,a,l,c)}roundClean(){Ee.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const xe=ye(()=>new Ce),Be=BigInt(0),Se=BigInt(1),Fe=BigInt(2),Qe=e=>e instanceof Uint8Array,De=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0")); -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Re(e){if(!Qe(e))throw new Error("Uint8Array expected");let t="";for(let n=0;ne+t.length,0));let n=0;return e.forEach(e=>{if(!Qe(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}const He=e=>(Fe<new Uint8Array(e),Ge=e=>Uint8Array.from(e);function qe(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=je(e),i=je(e),o=0;const s=()=>{r.fill(1),i.fill(0),o=0},a=(...e)=>n(i,r,...e),l=(e=je())=>{i=a(Ge([0]),e),r=a(),0!==e.length&&(i=a(Ge([1]),e),r=a())},c=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e{let n;for(s(),l(e);!(n=t(c()));)l();return s(),n}}const Ke={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 Je(e,t,n={}){const r=(t,n,r)=>{const i=Ke[n];if("function"!=typeof i)throw new Error(`Invalid validator "${n}", expected function`);const o=e[t];if(!(r&&void 0===o||i(o,e)))throw new Error(`Invalid param ${String(t)}=${o} (${typeof o}), expected ${n}`)};for(const[e,n]of Object.entries(t))r(e,n,!1);for(const[e,t]of Object.entries(n))r(e,t,!0);return e}var Ve=Object.freeze({__proto__:null,bitGet:function(e,t){return e>>BigInt(t)&Se},bitLen:function(e){let t;for(t=0;e>Be;e>>=Se,t+=1);return t},bitMask:He,bitSet:(e,t,n)=>e|(n?Se:Be)<=Ye?n:t+n}function rt(e,t,n){if(n<=Ye||t 0");if(n===ze)return Ye;let r=ze;for(;t>Ye;)t&ze&&(r=r*e%n),e=e*e%n,t>>=ze;return r}function it(e,t,n){let r=e;for(;t-- >Ye;)r*=r,r%=n;return r}function ot(e,t){if(e===Ye||t<=Ye)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=nt(e,t),r=t,i=Ye,o=ze;for(;n!==Ye;){const e=r%n,t=i-o*(r/n);r=n,n=e,i=o,o=t}if(r!==ze)throw new Error("invert: does not exist");return nt(i,t)}function st(e){if(e%Xe===Ze){const t=(e+ze)/Xe;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%tt===et){const t=(e-et)/tt;return function(e,n){const r=e.mul(n,We),i=e.pow(r,t),o=e.mul(n,i),s=e.mul(e.mul(o,We),i),a=e.mul(o,e.sub(s,e.ONE));if(!e.eql(e.sqr(a),n))throw new Error("Cannot find square root");return a}}return function(e){const t=(e-ze)/We;let n,r,i;for(n=e-ze,r=0;n%We===Ye;n/=We,r++);for(i=We;ir.unsubscribe():r}function c(e,t,n){e.$$.on_destroy.push(l(t,n))}const u="undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:global;function d(e,t){e.appendChild(t)}function f(e,t,n){e.insertBefore(t,n||null)}function h(e){e.parentNode&&e.parentNode.removeChild(e)}function p(e,t){for(let n=0;ne.removeEventListener(t,n,r)}function b(e){return function(t){return t.stopPropagation(),e.call(this,t)}}function k(e,t,n){null==n?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function I(e){return""===e?null:+e}function E(e,t){t=""+t,e.data!==t&&(e.data=t)}function C(e,t){e.value=null==t?"":t}function x(e,t,n,r){null==n?e.style.removeProperty(t):e.style.setProperty(t,n,r?"important":"")}function B(e,t,n){for(let n=0;n{const i=e.$$.callbacks[t];if(i){const o=function(e,t,{bubbles:n=!1,cancelable:r=!1}={}){const i=document.createEvent("CustomEvent");return i.initCustomEvent(e,n,r,t),i}(t,n,{cancelable:r});return i.slice().forEach(t=>{t.call(e,o)}),!o.defaultPrevented}return!0}}function T(e,t){const n=e.$$.callbacks[t.type];n&&n.slice().forEach(e=>e.call(this,t))}const N=[],L=[];let O=[];const M=[],_=Promise.resolve();let H=!1;function j(e){O.push(e)}function G(e){M.push(e)}const q=new Set;let K=0;function J(){if(0!==K)return;const e=Q;do{try{for(;K{Y.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}function te(e,t){const n=t.token={};function r(e,r,i,o){if(t.token!==n)return;t.resolved=o;let s=t.ctx;void 0!==i&&(s=s.slice(),s[i]=o);const a=e&&(t.current=e)(s);let l=!1;t.block&&(t.blocks?t.blocks.forEach((e,n)=>{n!==r&&e&&(W(),ee(e,1,1,()=>{t.blocks[n]===e&&(t.blocks[n]=null)}),Z())}):t.block.d(1),a.c(),X(a,1),a.m(t.mount(),t.anchor),l=!0),t.block=a,t.blocks&&(t.blocks[r]=a),l&&J()}if(!(i=e)||"object"!=typeof i&&"function"!=typeof i||"function"!=typeof i.then){if(t.current!==t.then)return r(t.then,1,t.value,e),!0;t.resolved=e}else{const n=R();if(e.then(e=>{D(n),r(t.then,1,t.value,e),D(null)},e=>{if(D(n),r(t.catch,2,t.error,e),D(null),!t.hasCatch)throw e}),t.current!==t.pending)return r(t.pending,0),!0}var i}function ne(e,t){e.d(1),t.delete(e.key)}function re(e,t,n){const r=e.$$.props[t];void 0!==r&&(e.$$.bound[r]=n,n(e.$$.ctx[r]))}function ie(e){e&&e.c()}function oe(e,n,o,s){const{fragment:a,after_update:l}=e.$$;a&&a.m(n,o),s||j(()=>{const n=e.$$.on_mount.map(t).filter(i);e.$$.on_destroy?e.$$.on_destroy.push(...n):r(n),e.$$.on_mount=[]}),l.forEach(j)}function se(e,t){const n=e.$$;null!==n.fragment&&(!function(e){const t=[],n=[];O.forEach(r=>-1===e.indexOf(r)?t.push(r):n.push(r)),n.forEach(e=>e()),O=t}(n.after_update),r(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function ae(e,t){-1===e.$$.dirty[0]&&(N.push(e),H||(H=!0,_.then(J)),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const i=r.length?r[0]:n;return f.ctx&&a(f.ctx[e],f.ctx[e]=i)&&(!f.skip_bound&&f.bound[e]&&f.bound[e](i),p&&ae(t,e)),n}):[],f.update(),p=!0,r(f.before_update),f.fragment=!!s&&s(f.ctx),i.target){if(i.hydrate){const e=function(e){return Array.from(e.childNodes)}(i.target);f.fragment&&f.fragment.l(e),e.forEach(h)}else f.fragment&&f.fragment.c();i.intro&&X(t.$$.fragment),oe(t,i.target,i.anchor,i.customElement),J()}D(d)}class ce{$destroy(){se(this,1),this.$destroy=e}$on(t,n){if(!i(n))return e;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(n),()=>{const e=r.indexOf(n);-1!==e&&r.splice(e,1)}}$set(e){var t;this.$$set&&(t=e,0!==Object.keys(t).length)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}function ue(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function de(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 fe(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")}const he="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,pe=e=>e instanceof Uint8Array,ge=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),me=(e,t)=>e<<32-t|e>>>t; +/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");function ye(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)),!pe(e))throw new Error("expected Uint8Array, got "+typeof e);return e}let we=class{clone(){return this._cloneInto()}};function ve(e){const t=t=>e().update(ye(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Ae(e=32){if(he&&"function"==typeof he.getRandomValues)return he.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}let be=class extends we{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=ge(this.buffer)}update(e){fe(this);const{view:t,buffer:n,blockLen:r}=this,i=(e=ye(e)).length;for(let o=0;or-o&&(this.process(n,0),o=0);for(let e=o;e>i&o),a=Number(n&o),l=r?4:0,c=r?0:4;e.setUint32(t+l,s,r),e.setUint32(t+c,a,r)}(n,r-8,BigInt(8*this.length),i),this.process(n,0);const s=ge(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;ee&t^~e&n,Ie=(e,t,n)=>e&t^e&n^t&n,Ee=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]),Ce=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),xe=new Uint32Array(64);let Be=class extends be{constructor(){super(64,32,8,!1),this.A=0|Ce[0],this.B=0|Ce[1],this.C=0|Ce[2],this.D=0|Ce[3],this.E=0|Ce[4],this.F=0|Ce[5],this.G=0|Ce[6],this.H=0|Ce[7]}get(){const{A:e,B:t,C:n,D:r,E:i,F:o,G:s,H:a}=this;return[e,t,n,r,i,o,s,a]}set(e,t,n,r,i,o,s,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)xe[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=xe[e-15],n=xe[e-2],r=me(t,7)^me(t,18)^t>>>3,i=me(n,17)^me(n,19)^n>>>10;xe[e]=i+xe[e-7]+r+xe[e-16]|0}let{A:n,B:r,C:i,D:o,E:s,F:a,G:l,H:c}=this;for(let e=0;e<64;e++){const t=c+(me(s,6)^me(s,11)^me(s,25))+ke(s,a,l)+Ee[e]+xe[e]|0,u=(me(n,2)^me(n,13)^me(n,22))+Ie(n,r,i)|0;c=l,l=a,a=s,s=o+t|0,o=i,i=r,r=n,n=t+u|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(n,r,i,o,s,a,l,c)}roundClean(){xe.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const Se=ve(()=>new Be),Fe=BigInt(0),Qe=BigInt(1),De=BigInt(2),Re=e=>e instanceof Uint8Array,$e=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0")); +/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Pe(e){if(!Re(e))throw new Error("Uint8Array expected");let t="";for(let n=0;ne+t.length,0));let n=0;return e.forEach(e=>{if(!Re(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}const Ge=e=>(De<new Uint8Array(e),Ke=e=>Uint8Array.from(e);function Je(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=qe(e),i=qe(e),o=0;const s=()=>{r.fill(1),i.fill(0),o=0},a=(...e)=>n(i,r,...e),l=(e=qe())=>{i=a(Ke([0]),e),r=a(),0!==e.length&&(i=a(Ke([1]),e),r=a())},c=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e{let n;for(s(),l(e);!(n=t(c()));)l();return s(),n}}const Ve={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 Ye(e,t,n={}){const r=(t,n,r)=>{const i=Ve[n];if("function"!=typeof i)throw new Error(`Invalid validator "${n}", expected function`);const o=e[t];if(!(r&&void 0===o||i(o,e)))throw new Error(`Invalid param ${String(t)}=${o} (${typeof o}), expected ${n}`)};for(const[e,n]of Object.entries(t))r(e,n,!1);for(const[e,t]of Object.entries(n))r(e,t,!0);return e}var ze=Object.freeze({__proto__:null,bitGet:function(e,t){return e>>BigInt(t)&Qe},bitLen:function(e){let t;for(t=0;e>Fe;e>>=Qe,t+=1);return t},bitMask:Ge,bitSet:(e,t,n)=>e|(n?Qe:Fe)<=We?n:t+n}function ot(e,t,n){if(n<=We||t 0");if(n===Ze)return We;let r=Ze;for(;t>We;)t&Ze&&(r=r*e%n),e=e*e%n,t>>=Ze;return r}function st(e,t,n){let r=e;for(;t-- >We;)r*=r,r%=n;return r}function at(e,t){if(e===We||t<=We)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=it(e,t),r=t,i=We,o=Ze;for(;n!==We;){const e=r%n,t=i-o*(r/n);r=n,n=e,i=o,o=t}if(r!==Ze)throw new Error("invert: does not exist");return it(i,t)}function lt(e){if(e%tt===et){const t=(e+Ze)/tt;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%rt===nt){const t=(e-nt)/rt;return function(e,n){const r=e.mul(n,Xe),i=e.pow(r,t),o=e.mul(n,i),s=e.mul(e.mul(o,Xe),i),a=e.mul(o,e.sub(s,e.ONE));if(!e.eql(e.sqr(a),n))throw new Error("Cannot find square root");return a}}return function(e){const t=(e-Ze)/Xe;let n,r,i;for(n=e-Ze,r=0;n%Xe===We;n/=Xe,r++);for(i=Xe;i(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});Je(e,t)}(e.Fp),Je(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...lt(e.n,e.nBitLength),...e,p:e.Fp.ORDER})} -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const{bytesToNumberBE:pt,hexToBytes:gt}=Ve,mt={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(e){const{Err:t}=mt;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:pt(r),l:e.subarray(n+2)}},toSig(e){const{Err:t}=mt,n="string"==typeof e?gt(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:i,l:o}=mt._parseInt(n.subarray(2)),{d:s,l:a}=mt._parseInt(o);if(a.length)throw new t("Invalid signature: left bytes after parsing");return{r:i,s:s}},hexFromSig(e){const t=e=>8&Number.parseInt(e[0],16)?"00"+e:e,n=e=>{const t=e.toString(16);return 1&t.length?`0${t}`:t},r=t(n(e.s)),i=t(n(e.r)),o=r.length/2,s=i.length/2,a=n(o),l=n(s);return`30${n(s+o+4)}02${l}${i}02${a}${r}`}},yt=BigInt(0),wt=BigInt(1);BigInt(2);const vt=BigInt(3);function At(e){const t=function(e){const t=ht(e);Je(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:i}=t;if(n){if(!r.eql(i,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 i=t.toAffine();return _e(Uint8Array.from([4]),n.toBytes(i.x),n.toBytes(i.y))}),i=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:i}=t,o=n.sqr(e),s=n.mul(o,e);return n.add(n.add(s,n.mul(e,r)),i)}if(!n.eql(n.sqr(t.Gy),o(t.Gx)))throw new Error("bad generator point: equation left != right");function s(e){return"bigint"==typeof e&&ytn.eql(e,n.ZERO);return i(t)&&i(r)?d.ZERO:new d(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(d.fromAffine)}static fromHex(e){const t=d.fromAffine(i(Me("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return d.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 i=n.sqr(r),s=o(e);if(!n.eql(i,s))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y: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:i}=this,{px:o,py:s,pz:a}=e,l=n.eql(n.mul(t,a),n.mul(o,i)),c=n.eql(n.mul(r,a),n.mul(s,i));return l&&c}negate(){return new d(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:r}=t,i=n.mul(r,vt),{px:o,py:s,pz:a}=this;let l=n.ZERO,c=n.ZERO,u=n.ZERO,f=n.mul(o,o),h=n.mul(s,s),p=n.mul(a,a),g=n.mul(o,s);return g=n.add(g,g),u=n.mul(o,a),u=n.add(u,u),l=n.mul(e,u),c=n.mul(i,p),c=n.add(l,c),l=n.sub(h,c),c=n.add(h,c),c=n.mul(l,c),l=n.mul(g,l),u=n.mul(i,u),p=n.mul(e,p),g=n.sub(f,p),g=n.mul(e,g),g=n.add(g,u),u=n.add(f,f),f=n.add(u,f),f=n.add(f,p),f=n.mul(f,g),c=n.add(c,f),p=n.mul(s,a),p=n.add(p,p),f=n.mul(p,g),l=n.sub(l,f),u=n.mul(p,h),u=n.add(u,u),u=n.add(u,u),new d(l,c,u)}add(e){u(e);const{px:r,py:i,pz:o}=this,{px:s,py:a,pz:l}=e;let c=n.ZERO,f=n.ZERO,h=n.ZERO;const p=t.a,g=n.mul(t.b,vt);let m=n.mul(r,s),y=n.mul(i,a),w=n.mul(o,l),v=n.add(r,i),A=n.add(s,a);v=n.mul(v,A),A=n.add(m,y),v=n.sub(v,A),A=n.add(r,o);let b=n.add(s,l);return A=n.mul(A,b),b=n.add(m,w),A=n.sub(A,b),b=n.add(i,o),c=n.add(a,l),b=n.mul(b,c),c=n.add(y,w),b=n.sub(b,c),h=n.mul(p,A),c=n.mul(g,w),h=n.add(c,h),c=n.sub(y,h),h=n.add(y,h),f=n.mul(c,h),y=n.add(m,m),y=n.add(y,m),w=n.mul(p,w),A=n.mul(g,A),y=n.add(y,w),w=n.sub(m,w),w=n.mul(p,w),A=n.add(A,w),m=n.mul(y,A),f=n.add(f,m),m=n.mul(b,A),c=n.mul(v,c),c=n.sub(c,m),m=n.mul(v,y),h=n.mul(b,h),h=n.add(h,m),new d(c,f,h)}subtract(e){return this.add(e.negate())}is0(){return this.equals(d.ZERO)}wNAF(e){return h.wNAFCached(this,c,e,e=>{const t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(d.fromAffine)})}multiplyUnsafe(e){const r=d.ZERO;if(e===yt)return r;if(a(e),e===wt)return this;const{endo:i}=t;if(!i)return h.unsafeLadder(this,e);let{k1neg:o,k1:s,k2neg:l,k2:c}=i.splitScalar(e),u=r,f=r,p=this;for(;s>yt||c>yt;)s&wt&&(u=u.add(p)),c&wt&&(f=f.add(p)),p=p.double(),s>>=wt,c>>=wt;return o&&(u=u.negate()),l&&(f=f.negate()),f=new d(n.mul(f.px,i.beta),f.py,f.pz),u.add(f)}multiply(e){a(e);let r,i,o=e;const{endo:s}=t;if(s){const{k1neg:e,k1:t,k2neg:a,k2:l}=s.splitScalar(o);let{p:c,f:u}=this.wNAF(t),{p:f,f:p}=this.wNAF(l);c=h.constTimeNegate(e,c),f=h.constTimeNegate(a,f),f=new d(n.mul(f.px,s.beta),f.py,f.pz),r=c.add(f),i=u.add(p)}else{const{p:e,f:t}=this.wNAF(o);r=e,i=t}return d.normalizeZ([r,i])[0]}multiplyAndAddUnsafe(e,t,n){const r=d.BASE,i=(e,t)=>t!==yt&&t!==wt&&e.equals(r)?e.multiply(t):e.multiplyUnsafe(t),o=i(this,t).add(i(e,n));return o.is0()?void 0:o}toAffine(e){const{px:t,py:r,pz:i}=this,o=this.is0();null==e&&(e=o?n.ONE:n.inv(i));const s=n.mul(t,e),a=n.mul(r,e),l=n.mul(i,e);if(o)return{x:n.ZERO,y:n.ZERO};if(!n.eql(l,n.ONE))throw new Error("invZ was invalid");return{x:s,y:a}}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e===wt)return!0;if(n)return n(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:n}=t;return e===wt?this:n?n(d,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),r(d,this,e)}toHex(e=!0){return Re(this.toRawBytes(e))}}d.BASE=new d(t.Gx,t.Gy,n.ONE),d.ZERO=new d(n.ZERO,n.ONE,n.ZERO);const f=t.nBitLength,h=function(e,t){const n=(e,t)=>{const n=t.negate();return e?n:t},r=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:n,unsafeLadder(t,n){let r=e.ZERO,i=t;for(;n>dt;)n&ft&&(r=r.add(i)),i=i.double(),n>>=ft;return r},precomputeWindow(e,t){const{windows:n,windowSize:i}=r(t),o=[];let s=e,a=s;for(let e=0;e>=f,r>a&&(r-=d,o+=ft);const s=t,h=t+Math.abs(r)-1,p=e%2!=0,g=r<0;0===r?c=c.add(n(p,i[s])):l=l.add(n(g,i[h]))}return{p:l,f:c}},wNAFCached(e,t,n,r){const i=e._WINDOW_SIZE||1;let o=t.get(e);return o||(o=this.precomputeWindow(e,i),1!==i&&t.set(e,r(o))),this.wNAF(i,o,n)}}}(d,t.endo?Math.ceil(f/2):f);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:l,weierstrassEquation:o,isWithinCurveOrder:s}}function bt(e){const t=function(e){const t=ht(e);return Je(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,i=n.BYTES+1,o=2*n.BYTES+1;function s(e){return nt(e,r)}function a(e){return ot(e,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:u,isWithinCurveOrder:d}=At({...t,toBytes(e,t,r){const i=t.toAffine(),o=n.toBytes(i.x),s=_e;return r?s(Uint8Array.from([t.hasEvenY()?2:3]),o):s(Uint8Array.from([4]),o,n.toBytes(i.y))},fromBytes(e){const t=e.length,r=e[0],s=e.subarray(1);if(t!==i||2!==r&&3!==r){if(t===o&&4===r){return{x:n.fromBytes(s.subarray(0,n.BYTES)),y:n.fromBytes(s.subarray(n.BYTES,2*n.BYTES))}}throw new Error(`Point of length ${t} was invalid. Expected ${i} compressed bytes or ${o} uncompressed bytes`)}{const e=Te(s);if(!(yt<(a=e)&&aRe(Le(e,t.nByteLength));function h(e){return e>r>>wt}const p=(e,t,n)=>Te(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=Me("compactSignature",e,2*n),new g(p(e,0,n),p(e,n,2*n))}static fromDER(e){const{r:t,s:n}=mt.toSig(Me("DER",e));return new g(t,n)}assertValidity(){if(!d(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!d(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:r,s:i,recovery:o}=this,c=v(Me("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 d=1&o?"03":"02",h=l.fromHex(d+f(u)),p=a(u),g=s(-c*p),m=s(i*p),y=l.BASE.multiplyAndAddUnsafe(h,g,m);if(!y)throw new Error("point at infinify");return y.assertValidity(),y}hasHighS(){return h(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return Ue(this.toDERHex())}toDERHex(){return mt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Ue(this.toCompactHex())}toCompactHex(){return f(this.r)+f(this.s)}}const m={isValidPrivateKey(e){try{return c(e),!0}catch(e){return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{const e=ut(t.n);return function(e,t,n=!1){const r=e.length,i=ct(t),o=ut(t);if(r<16||r1024)throw new Error(`expected ${o}-1024 bytes of input, got ${r}`);const s=nt(n?Te(e):Ne(e),t-ze)+ze;return n?Oe(s,i):Le(s,i)}(t.randomBytes(e),t.n)},precompute:(e=8,t=l.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function y(e){const t=e instanceof Uint8Array,n="string"==typeof e,r=(t||n)&&e.length;return t?r===i||r===o:n?r===2*i||r===2*o:e instanceof l}const w=t.bits2int||function(e){const n=Te(e),r=8*e.length-t.nBitLength;return r>0?n>>BigInt(r):n},v=t.bits2int_modN||function(e){return s(w(e))},A=He(t.nBitLength);function b(e){if("bigint"!=typeof e)throw new Error("bigint expected");if(!(yt<=e&&ee in i))throw new Error("sign() legacy options not supported");const{hash:o,randomBytes:u}=t;let{lowS:f,prehash:p,extraEntropy:m}=i;null==f&&(f=!0),e=Me("msgHash",e),p&&(e=Me("prehashed msgHash",o(e)));const y=v(e),A=c(r),k=[b(A),b(y)];if(null!=m){const e=!0===m?u(n.BYTES):m;k.push(Me("extraEntropy",e))}const E=_e(...k),C=y;return{seed:E,k2sig:function(e){const t=w(e);if(!d(t))return;const n=a(t),r=l.BASE.multiply(t).toAffine(),i=s(r.x);if(i===yt)return;const o=s(n*s(C+i*A));if(o===yt)return;let c=(r.x===i?0:2)|Number(r.y&wt),u=o;return f&&h(o)&&(u=function(e){return h(e)?s(-e):e}(o),c^=1),new g(i,u,c)}}}const I={lowS:t.lowS,prehash:!1},E={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(y(e))throw new Error("first arg must be private key");if(!y(t))throw new Error("second arg must be public key");return l.fromHex(t).multiply(c(e)).toRawBytes(n)},sign:function(e,n,r=I){const{seed:i,k2sig:o}=k(e,n,r),s=t;return qe(s.hash.outputLen,s.nByteLength,s.hmac)(i,o)},verify:function(e,n,r,i=E){const o=e;if(n=Me("msgHash",n),r=Me("publicKey",r),"strict"in i)throw new Error("options.strict was renamed to lowS");const{lowS:c,prehash:u}=i;let d,f;try{if("string"==typeof o||o instanceof Uint8Array)try{d=g.fromDER(o)}catch(e){if(!(e instanceof mt.Err))throw e;d=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;d=new g(e,t)}}f=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&&d.hasHighS())return!1;u&&(n=t.hash(n));const{r:h,s:p}=d,m=v(n),y=a(p),w=s(m*y),A=s(h*y),b=l.BASE.multiplyAndAddUnsafe(f,w,A)?.toAffine();return!!b&&s(b.x)===h},ProjectivePoint:l,Signature:g,utils:m}}BigInt(4);let kt=class extends me{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");le(e.outputLen),le(e.blockLen)}(e);const n=ge(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,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let e=0;enew kt(e,t).update(n).digest(); +const ht=BigInt(0),pt=BigInt(1);function gt(e){return function(e){const t=ct.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});Ye(e,t)}(e.Fp),Ye(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...ut(e.n,e.nBitLength),...e,p:e.Fp.ORDER})} +/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const{bytesToNumberBE:mt,hexToBytes:yt}=ze,wt={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(e){const{Err:t}=wt;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:mt(r),l:e.subarray(n+2)}},toSig(e){const{Err:t}=wt,n="string"==typeof e?yt(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:i,l:o}=wt._parseInt(n.subarray(2)),{d:s,l:a}=wt._parseInt(o);if(a.length)throw new t("Invalid signature: left bytes after parsing");return{r:i,s:s}},hexFromSig(e){const t=e=>8&Number.parseInt(e[0],16)?"00"+e:e,n=e=>{const t=e.toString(16);return 1&t.length?`0${t}`:t},r=t(n(e.s)),i=t(n(e.r)),o=r.length/2,s=i.length/2,a=n(o),l=n(s);return`30${n(s+o+4)}02${l}${i}02${a}${r}`}},vt=BigInt(0),At=BigInt(1);BigInt(2);const bt=BigInt(3);function kt(e){const t=function(e){const t=gt(e);Ye(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:i}=t;if(n){if(!r.eql(i,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 i=t.toAffine();return je(Uint8Array.from([4]),n.toBytes(i.x),n.toBytes(i.y))}),i=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:i}=t,o=n.sqr(e),s=n.mul(o,e);return n.add(n.add(s,n.mul(e,r)),i)}if(!n.eql(n.sqr(t.Gy),o(t.Gx)))throw new Error("bad generator point: equation left != right");function s(e){return"bigint"==typeof e&&vtn.eql(e,n.ZERO);return i(t)&&i(r)?d.ZERO:new d(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(d.fromAffine)}static fromHex(e){const t=d.fromAffine(i(He("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return d.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 i=n.sqr(r),s=o(e);if(!n.eql(i,s))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y: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:i}=this,{px:o,py:s,pz:a}=e,l=n.eql(n.mul(t,a),n.mul(o,i)),c=n.eql(n.mul(r,a),n.mul(s,i));return l&&c}negate(){return new d(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:r}=t,i=n.mul(r,bt),{px:o,py:s,pz:a}=this;let l=n.ZERO,c=n.ZERO,u=n.ZERO,f=n.mul(o,o),h=n.mul(s,s),p=n.mul(a,a),g=n.mul(o,s);return g=n.add(g,g),u=n.mul(o,a),u=n.add(u,u),l=n.mul(e,u),c=n.mul(i,p),c=n.add(l,c),l=n.sub(h,c),c=n.add(h,c),c=n.mul(l,c),l=n.mul(g,l),u=n.mul(i,u),p=n.mul(e,p),g=n.sub(f,p),g=n.mul(e,g),g=n.add(g,u),u=n.add(f,f),f=n.add(u,f),f=n.add(f,p),f=n.mul(f,g),c=n.add(c,f),p=n.mul(s,a),p=n.add(p,p),f=n.mul(p,g),l=n.sub(l,f),u=n.mul(p,h),u=n.add(u,u),u=n.add(u,u),new d(l,c,u)}add(e){u(e);const{px:r,py:i,pz:o}=this,{px:s,py:a,pz:l}=e;let c=n.ZERO,f=n.ZERO,h=n.ZERO;const p=t.a,g=n.mul(t.b,bt);let m=n.mul(r,s),y=n.mul(i,a),w=n.mul(o,l),v=n.add(r,i),A=n.add(s,a);v=n.mul(v,A),A=n.add(m,y),v=n.sub(v,A),A=n.add(r,o);let b=n.add(s,l);return A=n.mul(A,b),b=n.add(m,w),A=n.sub(A,b),b=n.add(i,o),c=n.add(a,l),b=n.mul(b,c),c=n.add(y,w),b=n.sub(b,c),h=n.mul(p,A),c=n.mul(g,w),h=n.add(c,h),c=n.sub(y,h),h=n.add(y,h),f=n.mul(c,h),y=n.add(m,m),y=n.add(y,m),w=n.mul(p,w),A=n.mul(g,A),y=n.add(y,w),w=n.sub(m,w),w=n.mul(p,w),A=n.add(A,w),m=n.mul(y,A),f=n.add(f,m),m=n.mul(b,A),c=n.mul(v,c),c=n.sub(c,m),m=n.mul(v,y),h=n.mul(b,h),h=n.add(h,m),new d(c,f,h)}subtract(e){return this.add(e.negate())}is0(){return this.equals(d.ZERO)}wNAF(e){return h.wNAFCached(this,c,e,e=>{const t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(d.fromAffine)})}multiplyUnsafe(e){const r=d.ZERO;if(e===vt)return r;if(a(e),e===At)return this;const{endo:i}=t;if(!i)return h.unsafeLadder(this,e);let{k1neg:o,k1:s,k2neg:l,k2:c}=i.splitScalar(e),u=r,f=r,p=this;for(;s>vt||c>vt;)s&At&&(u=u.add(p)),c&At&&(f=f.add(p)),p=p.double(),s>>=At,c>>=At;return o&&(u=u.negate()),l&&(f=f.negate()),f=new d(n.mul(f.px,i.beta),f.py,f.pz),u.add(f)}multiply(e){a(e);let r,i,o=e;const{endo:s}=t;if(s){const{k1neg:e,k1:t,k2neg:a,k2:l}=s.splitScalar(o);let{p:c,f:u}=this.wNAF(t),{p:f,f:p}=this.wNAF(l);c=h.constTimeNegate(e,c),f=h.constTimeNegate(a,f),f=new d(n.mul(f.px,s.beta),f.py,f.pz),r=c.add(f),i=u.add(p)}else{const{p:e,f:t}=this.wNAF(o);r=e,i=t}return d.normalizeZ([r,i])[0]}multiplyAndAddUnsafe(e,t,n){const r=d.BASE,i=(e,t)=>t!==vt&&t!==At&&e.equals(r)?e.multiply(t):e.multiplyUnsafe(t),o=i(this,t).add(i(e,n));return o.is0()?void 0:o}toAffine(e){const{px:t,py:r,pz:i}=this,o=this.is0();null==e&&(e=o?n.ONE:n.inv(i));const s=n.mul(t,e),a=n.mul(r,e),l=n.mul(i,e);if(o)return{x:n.ZERO,y:n.ZERO};if(!n.eql(l,n.ONE))throw new Error("invZ was invalid");return{x:s,y:a}}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e===At)return!0;if(n)return n(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:n}=t;return e===At?this:n?n(d,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),r(d,this,e)}toHex(e=!0){return Pe(this.toRawBytes(e))}}d.BASE=new d(t.Gx,t.Gy,n.ONE),d.ZERO=new d(n.ZERO,n.ONE,n.ZERO);const f=t.nBitLength,h=function(e,t){const n=(e,t)=>{const n=t.negate();return e?n:t},r=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:n,unsafeLadder(t,n){let r=e.ZERO,i=t;for(;n>ht;)n&pt&&(r=r.add(i)),i=i.double(),n>>=pt;return r},precomputeWindow(e,t){const{windows:n,windowSize:i}=r(t),o=[];let s=e,a=s;for(let e=0;e>=f,r>a&&(r-=d,o+=pt);const s=t,h=t+Math.abs(r)-1,p=e%2!=0,g=r<0;0===r?c=c.add(n(p,i[s])):l=l.add(n(g,i[h]))}return{p:l,f:c}},wNAFCached(e,t,n,r){const i=e._WINDOW_SIZE||1;let o=t.get(e);return o||(o=this.precomputeWindow(e,i),1!==i&&t.set(e,r(o))),this.wNAF(i,o,n)}}}(d,t.endo?Math.ceil(f/2):f);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:l,weierstrassEquation:o,isWithinCurveOrder:s}}function It(e){const t=function(e){const t=gt(e);return Ye(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,i=n.BYTES+1,o=2*n.BYTES+1;function s(e){return it(e,r)}function a(e){return at(e,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:u,isWithinCurveOrder:d}=kt({...t,toBytes(e,t,r){const i=t.toAffine(),o=n.toBytes(i.x),s=je;return r?s(Uint8Array.from([t.hasEvenY()?2:3]),o):s(Uint8Array.from([4]),o,n.toBytes(i.y))},fromBytes(e){const t=e.length,r=e[0],s=e.subarray(1);if(t!==i||2!==r&&3!==r){if(t===o&&4===r){return{x:n.fromBytes(s.subarray(0,n.BYTES)),y:n.fromBytes(s.subarray(n.BYTES,2*n.BYTES))}}throw new Error(`Point of length ${t} was invalid. Expected ${i} compressed bytes or ${o} uncompressed bytes`)}{const e=Le(s);if(!(vt<(a=e)&&aPe(Me(e,t.nByteLength));function h(e){return e>r>>At}const p=(e,t,n)=>Le(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=He("compactSignature",e,2*n),new g(p(e,0,n),p(e,n,2*n))}static fromDER(e){const{r:t,s:n}=wt.toSig(He("DER",e));return new g(t,n)}assertValidity(){if(!d(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!d(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:r,s:i,recovery:o}=this,c=v(He("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 d=1&o?"03":"02",h=l.fromHex(d+f(u)),p=a(u),g=s(-c*p),m=s(i*p),y=l.BASE.multiplyAndAddUnsafe(h,g,m);if(!y)throw new Error("point at infinify");return y.assertValidity(),y}hasHighS(){return h(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return Ne(this.toDERHex())}toDERHex(){return wt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Ne(this.toCompactHex())}toCompactHex(){return f(this.r)+f(this.s)}}const m={isValidPrivateKey(e){try{return c(e),!0}catch(e){return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{const e=ft(t.n);return function(e,t,n=!1){const r=e.length,i=dt(t),o=ft(t);if(r<16||r1024)throw new Error(`expected ${o}-1024 bytes of input, got ${r}`);const s=it(n?Le(e):Oe(e),t-Ze)+Ze;return n?_e(s,i):Me(s,i)}(t.randomBytes(e),t.n)},precompute:(e=8,t=l.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function y(e){const t=e instanceof Uint8Array,n="string"==typeof e,r=(t||n)&&e.length;return t?r===i||r===o:n?r===2*i||r===2*o:e instanceof l}const w=t.bits2int||function(e){const n=Le(e),r=8*e.length-t.nBitLength;return r>0?n>>BigInt(r):n},v=t.bits2int_modN||function(e){return s(w(e))},A=Ge(t.nBitLength);function b(e){if("bigint"!=typeof e)throw new Error("bigint expected");if(!(vt<=e&&ee in i))throw new Error("sign() legacy options not supported");const{hash:o,randomBytes:u}=t;let{lowS:f,prehash:p,extraEntropy:m}=i;null==f&&(f=!0),e=He("msgHash",e),p&&(e=He("prehashed msgHash",o(e)));const y=v(e),A=c(r),k=[b(A),b(y)];if(null!=m){const e=!0===m?u(n.BYTES):m;k.push(He("extraEntropy",e))}const E=je(...k),C=y;return{seed:E,k2sig:function(e){const t=w(e);if(!d(t))return;const n=a(t),r=l.BASE.multiply(t).toAffine(),i=s(r.x);if(i===vt)return;const o=s(n*s(C+i*A));if(o===vt)return;let c=(r.x===i?0:2)|Number(r.y&At),u=o;return f&&h(o)&&(u=function(e){return h(e)?s(-e):e}(o),c^=1),new g(i,u,c)}}}const I={lowS:t.lowS,prehash:!1},E={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(y(e))throw new Error("first arg must be private key");if(!y(t))throw new Error("second arg must be public key");return l.fromHex(t).multiply(c(e)).toRawBytes(n)},sign:function(e,n,r=I){const{seed:i,k2sig:o}=k(e,n,r),s=t;return Je(s.hash.outputLen,s.nByteLength,s.hmac)(i,o)},verify:function(e,n,r,i=E){const o=e;if(n=He("msgHash",n),r=He("publicKey",r),"strict"in i)throw new Error("options.strict was renamed to lowS");const{lowS:c,prehash:u}=i;let d,f;try{if("string"==typeof o||o instanceof Uint8Array)try{d=g.fromDER(o)}catch(e){if(!(e instanceof wt.Err))throw e;d=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;d=new g(e,t)}}f=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&&d.hasHighS())return!1;u&&(n=t.hash(n));const{r:h,s:p}=d,m=v(n),y=a(p),w=s(m*y),A=s(h*y),b=l.BASE.multiplyAndAddUnsafe(f,w,A)?.toAffine();return!!b&&s(b.x)===h},ProjectivePoint:l,Signature:g,utils:m}}BigInt(4);let Et=class extends we{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");ue(e.outputLen),ue(e.blockLen)}(e);const n=ye(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,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let e=0;enew Et(e,t).update(n).digest(); /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -function Et(e){return{hash:e,hmac:(t,...n)=>It(e,t,function(...e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;return e.forEach(e=>{if(!fe(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}(...n)),randomBytes:we}}It.create=(e,t)=>new kt(e,t); +function xt(e){return{hash:e,hmac:(t,...n)=>Ct(e,t,function(...e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;return e.forEach(e=>{if(!pe(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}(...n)),randomBytes:Ae}}Ct.create=(e,t)=>new Et(e,t); /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const Ct=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),xt=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Bt=BigInt(1),St=BigInt(2),Ft=(e,t)=>(e+t/St)/t;function Qt(e){const t=Ct,n=BigInt(3),r=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),l=BigInt(88),c=e*e*e%t,u=c*c*e%t,d=it(u,n,t)*u%t,f=it(d,n,t)*u%t,h=it(f,St,t)*c%t,p=it(h,i,t)*h%t,g=it(p,o,t)*p%t,m=it(g,a,t)*g%t,y=it(m,l,t)*m%t,w=it(y,a,t)*g%t,v=it(w,n,t)*u%t,A=it(v,s,t)*p%t,b=it(A,r,t)*c%t,k=it(b,St,t);if(!Dt.eql(Dt.sqr(k),e))throw new Error("Cannot find square root");return k}const Dt=function(e,t,n=!1,r={}){if(e<=Ye)throw new Error(`Expected Field ORDER > 0, got ${e}`);const{nBitLength:i,nByteLength:o}=lt(e,t);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=st(e),a=Object.freeze({ORDER:e,BITS:i,BYTES:o,MASK:He(i),ZERO:Ye,ONE:ze,create:t=>nt(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return Ye<=t&&te===Ye,isOdd:e=>(e&ze)===ze,neg:t=>nt(-t,e),eql:(e,t)=>e===t,sqr:t=>nt(t*t,e),add:(t,n)=>nt(t+n,e),sub:(t,n)=>nt(t-n,e),mul:(t,n)=>nt(t*n,e),pow:(e,t)=>function(e,t,n){if(n 0");if(n===Ye)return e.ONE;if(n===ze)return t;let r=e.ONE,i=t;for(;n>Ye;)n&ze&&(r=e.mul(r,i)),i=e.sqr(i),n>>=ze;return r}(a,e,t),div:(t,n)=>nt(t*ot(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>ot(t,e),sqrt:r.sqrt||(e=>s(a,e)),invertBatch:e=>function(e,t){const n=new Array(t.length),r=t.reduce((t,r,i)=>e.is0(r)?t:(n[i]=t,e.mul(t,r)),e.ONE),i=e.inv(r);return t.reduceRight((t,r,i)=>e.is0(r)?t:(n[i]=e.mul(t,n[i]),e.mul(t,r)),i),n}(a,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?Oe(e,o):Le(e,o),fromBytes:e=>{if(e.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${e.length}`);return n?Ne(e):Te(e)}});return Object.freeze(a)}(Ct,void 0,void 0,{sqrt:Qt}),Rt=function(e,t){const n=t=>bt({...e,...Et(t)});return Object.freeze({...n(t),create:n})}({a:BigInt(0),b:BigInt(7),Fp:Dt,n:xt,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=xt,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Bt*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=n,s=BigInt("0x100000000000000000000000000000000"),a=Ft(o*e,t),l=Ft(-r*e,t);let c=nt(e-a*n-l*i,t),u=nt(-a*r-l*o,t);const d=c>s,f=u>s;if(d&&(c=t-c),f&&(u=t-u),c>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:d,k1:c,k2neg:f,k2:u}}}},xe),Pt=BigInt(0),$t=e=>"bigint"==typeof e&&Pte.charCodeAt(0)));n=_e(t,t),Ut[e]=n}return xe(_e(n,...t))}const Nt=e=>e.toRawBytes(!0).slice(1),Lt=e=>Le(e,32),Ot=e=>nt(e,Ct),Mt=e=>nt(e,xt),_t=Rt.ProjectivePoint;function Ht(e){let t=Rt.utils.normPrivateKeyToScalar(e),n=_t.fromPrivateKey(t);return{scalar:n.hasEvenY()?t:Mt(-t),bytes:Nt(n)}}function jt(e){if(!$t(e))throw new Error("bad x: need 0 < x < p");const t=Ot(e*e);let n=Qt(Ot(t*e+BigInt(7)));n%St!==Pt&&(n=Ot(-n));const r=new _t(e,n,Bt);return r.assertValidity(),r}function Gt(...e){return Mt(Te(Tt("BIP0340/challenge",...e)))}function qt(e){return Ht(e).bytes}function Kt(e,t,n=we(32)){const r=Me("message",e),{bytes:i,scalar:o}=Ht(t),s=Me("auxRand",n,32),a=Lt(o^Te(Tt("BIP0340/aux",s))),l=Tt("BIP0340/nonce",a,i,r),c=Mt(Te(l));if(c===Pt)throw new Error("sign failed: k is zero");const{bytes:u,scalar:d}=Ht(c),f=Gt(u,i,r),h=new Uint8Array(64);if(h.set(u,0),h.set(Lt(Mt(d+f*o)),32),!Jt(h,r,i))throw new Error("sign: Invalid signature produced");return h}function Jt(e,t,n){const r=Me("signature",e,64),i=Me("message",t),o=Me("publicKey",n,32);try{const e=jt(Te(o)),t=Te(r.subarray(0,32));if(!$t(t))return!1;const n=Te(r.subarray(32,64));if(!("bigint"==typeof(c=n)&&Pt({getPublicKey:qt,sign:Kt,verify:Jt,utils:{randomPrivateKey:Rt.utils.randomPrivateKey,lift_x:jt,pointToBytes:Nt,numberToBytesBE:Le,bytesToNumberBE:Te,taggedHash:Tt,mod:nt}}))(),Yt="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,zt=e=>e instanceof Uint8Array,Wt=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),Zt=(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 Xt=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function en(e){if(!zt(e))throw new Error("Uint8Array expected");let t="";for(let n=0;ne+t.length,0));let n=0;return e.forEach(e=>{if(!zt(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}let on=class{clone(){return this._cloneInto()}};function sn(e){const t=t=>e().update(nn(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function an(e=32){if(Yt&&"function"==typeof Yt.getRandomValues)return Yt.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}function ln(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function cn(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 un={number:ln,bool:function(e){if("boolean"!=typeof e)throw new Error(`Expected boolean, not ${e}`)},bytes:cn,hash:function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");ln(e.outputLen),ln(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){cn(e);const n=t.outputLen;if(e.lengthr-o&&(this.process(n,0),o=0);for(let e=o;e>i&o),a=Number(n&o),l=r?4:0,c=r?0:4;e.setUint32(t+l,s,r),e.setUint32(t+c,a,r)}(n,r-8,BigInt(8*this.length),i),this.process(n,0);const s=Wt(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;ee&t^~e&n,hn=(e,t,n)=>e&t^e&n^t&n,pn=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]),gn=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),mn=new Uint32Array(64);let yn=class extends dn{constructor(){super(64,32,8,!1),this.A=0|gn[0],this.B=0|gn[1],this.C=0|gn[2],this.D=0|gn[3],this.E=0|gn[4],this.F=0|gn[5],this.G=0|gn[6],this.H=0|gn[7]}get(){const{A:e,B:t,C:n,D:r,E:i,F:o,G:s,H:a}=this;return[e,t,n,r,i,o,s,a]}set(e,t,n,r,i,o,s,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)mn[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=mn[e-15],n=mn[e-2],r=Zt(t,7)^Zt(t,18)^t>>>3,i=Zt(n,17)^Zt(n,19)^n>>>10;mn[e]=i+mn[e-7]+r+mn[e-16]|0}let{A:n,B:r,C:i,D:o,E:s,F:a,G:l,H:c}=this;for(let e=0;e<64;e++){const t=c+(Zt(s,6)^Zt(s,11)^Zt(s,25))+fn(s,a,l)+pn[e]+mn[e]|0,u=(Zt(n,2)^Zt(n,13)^Zt(n,22))+hn(n,r,i)|0;c=l,l=a,a=s,s=o+t|0,o=i,i=r,r=n,n=t+u|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(n,r,i,o,s,a,l,c)}roundClean(){mn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};class wn extends yn{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 vn=sn(()=>new yn);sn(()=>new wn);var An=Symbol("verified");function bn(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;te===n.slice(1)&&-1!==r.indexOf(t)))return!1}return!(e.since&&t.created_ate.until)}async function Qn(){return new Promise(e=>{const t=new MessageChannel,n=()=>{t.port1.removeEventListener("message",n),e()};t.port1.addEventListener("message",n),t.port2.postMessage(0),t.port1.start()})}var Dn,Rn=e=>(e[An]=!0,!0),Pn=class extends Error{constructor(e,t){super(`Tried to send message '${e} on a closed connection to ${t}.`),this.name="SendingOnClosedConnection"}},$n=class{url;_connected=!1;onclose=null;onnotice=e=>console.debug(`NOTICE from ${this.url}: ${e}`);baseEoseTimeout=4400;connectionTimeout=4400;publishTimeout=4400;pingFrequency=2e4;pingTimeout=2e4;openSubs=new Map;enablePing;connectionTimeoutHandle;connectionPromise;openCountRequests=new Map;openEventPublishes=new Map;ws;incomingMessageQueue=new Cn;queueRunning=!1;challenge;authPromise;serial=0;verifyEvent;_WebSocket;constructor(e,t){this.url=In(e),this.verifyEvent=t.verifyEvent,this._WebSocket=t.websocketImplementation||WebSocket,this.enablePing=t.enablePing}static async connect(e,t){const n=new $n(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 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=()=>{clearTimeout(this.connectionTimeoutHandle),this._connected=!0,this.enablePing&&this.pingpong(),e()},this.ws.onerror=e=>{clearTimeout(this.connectionTimeoutHandle),t(e.message||"websocket error"),this._connected=!1,this.connectionPromise=void 0,this.onclose?.(),this.closeAllSubscriptions("relay connection errored")},this.ws.onclose=e=>{clearTimeout(this.connectionTimeoutHandle),t(e.message||"websocket closed"),this._connected=!1,this.connectionPromise=void 0,this.onclose?.(),this.closeAllSubscriptions("relay connection closed")},this.ws.onmessage=this._onmessage.bind(this)})),this.connectionPromise}async waitForPingPong(){return new Promise((e,t)=>{this.ws&&this.ws.on&&this.ws.on("pong",()=>e(!0))||t("ws can't listen for pong"),this.ws&&this.ws.ping&&this.ws.ping()})}async waitForDummyReq(){return new Promise((e,t)=>{const n=this.subscribe([{ids:["a".repeat(64)]}],{oneose:()=>{n.close(),e(!0)},eoseTimeout:this.pingTimeout+1e3})})}async pingpong(){if(1===this.ws?.readyState){await Promise.any([this.ws&&this.ws.ping&&this.ws.on?this.waitForPingPong():this.waitForDummyReq(),new Promise(e=>setTimeout(()=>e(!1),this.pingTimeout))])?setTimeout(()=>this.pingpong(),this.pingFrequency):(this.closeAllSubscriptions("pingpong timed out"),this._connected=!1,this.onclose?.(),this.ws?.close())}}async runQueue(){for(this.queueRunning=!0;!1!==this.handleNext();)await Qn();this.queueRunning=!1}handleNext(){const e=this.incomingMessageQueue.dequeue();if(!e)return!1;const t=function(e){let t=e.slice(0,22).indexOf('"EVENT"');if(-1===t)return null;let n=e.slice(t+7+1).indexOf('"');if(-1===n)return null;let r=t+7+1+n,i=e.slice(r+1,80).indexOf('"');if(-1===i)return null;let o=r+1+i;return e.slice(r+1,o)}(e);if(t){const n=this.openSubs.get(t);if(!n)return;const r=function(e,t){let n=t.length+3,r=e.indexOf(`"${t}":`)+n,i=e.slice(r).indexOf('"')+r+1;return e.slice(i,i+64)}(e,"id"),i=n.alreadyHaveEvent?.(r);if(n.receivedEvent?.(this,r),i)return}try{let t=JSON.parse(e);switch(t[0]){case"EVENT":{const e=this.openSubs.get(t[1]),n=t[2];return void(this.verifyEvent(n)&&function(e,t){for(let n=0;n{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 i=await e(function(e,t){return{kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",e],["challenge",t]],content:""}}(this.url,t)),o=setTimeout(()=>{let e=this.openEventPublishes.get(i.id);e&&(e.reject(new Error("auth timed out")),this.openEventPublishes.delete(i.id))},this.publishTimeout);this.openEventPublishes.set(i.id,{resolve:n,reject:r,timeout:o}),this.send('["AUTH",'+JSON.stringify(i)+"]")}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 Un(this,n,e,t);return this.openSubs.set(n,r),r}close(){this.closeAllSubscriptions("relay connection closed by us"),this._connected=!1,this.onclose?.(),this.ws?.close()}_onmessage(e){this.incomingMessageQueue.enqueue(e.data),this.queueRunning||this.runQueue()}},Un=class{relay;id;closed=!1;eosed=!1;filters;alreadyHaveEvent;receivedEvent;onevent;oneose;onclose;eoseTimeout;eoseTimeoutHandle;constructor(e,t,n,r){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 Pn))throw e}this.closed=!0}this.relay.openSubs.delete(this.id),this.onclose?.(e)}},Tn=class{relays=new Map;seenOn=new Map;trackRelays=!1;verifyEvent;enablePing;trustedRelayURLs=new Set;_WebSocket;constructor(e){this.verifyEvent=e.verifyEvent,this._WebSocket=e.websocketImplementation,this.enablePing=e.enablePing}async ensureRelay(e,t){e=In(e);let n=this.relays.get(e);return n||(n=new $n(e,{verifyEvent:this.trustedRelayURLs.has(e)?Rn:this.verifyEvent,websocketImplementation:this._WebSocket,enablePing:this.enablePing}),n.onclose=()=>{this.relays.delete(e)},t?.connectionTimeout&&(n.connectionTimeout=t.connectionTimeout),this.relays.set(e,n)),await n.connect(),n}close(e){e.map(In).forEach(e=>{this.relays.get(e)?.close(),this.relays.delete(e)})}subscribe(e,t,n){n.onauth=n.onauth||n.doauth;const r=[];for(let n=0;ne.url===i)||r.push({url:i,filter:t})}return this.subscribeMap(r,n)}subscribeMany(e,t,n){n.onauth=n.onauth||n.doauth;const r=[],i=[];for(let n=0;n({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 i=new Set,o=[],s=[];let a=n=>{s[n]||(s[n]=!0,s.filter(e=>e).length===e.length&&(t.oneose?.(),a=()=>{}))};const l=[];let c=(n,r)=>{l[n]||(a(n),l[n]=r,l.filter(e=>e).length===e.length&&(t.onclose?.(l),c=()=>{}))};const u=e=>{if(t.alreadyHaveEvent?.(e))return!0;const n=i.has(e);return i.add(e),n},d=Promise.all(r.map(async({url:e,filters:n},r)=>{let i;try{i=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 s=i.subscribe(n,{...t,oneose:()=>a(r),onclose:e=>{e.startsWith("auth-required: ")&&t.onauth?i.auth(t.onauth).then(()=>{i.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(s)}));return{async close(e){await d,o.forEach(t=>{t.close(e)})}}}subscribeEose(e,t,n){n.onauth=n.onauth||n.doauth;const r=this.subscribe(e,t,{...n,oneose(){r.close("closed automatically on eose")}});return r}subscribeManyEose(e,t,n){n.onauth=n.onauth||n.doauth;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 i=[];this.subscribeEose(e,t,{...n,onevent(e){i.push(e)},onclose(e){r(i)}})})}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(In).map(async(e,r,i)=>{if(i.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{Dn=WebSocket}catch{}var Nn=class extends Tn{constructor(e){super({verifyEvent:Sn,websocketImplementation:Dn,...e})}}; -/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ln(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function On(...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 Mn(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(Ln(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 _n(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 Hn(e,t="="){if(Ln(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 jn(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function Gn(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 i=[],o=Array.from(e);for(o.forEach(e=>{if(Ln(e),e<0||e>=t)throw new Error(`Wrong integer: ${e}`)});;){let e=0,s=!0;for(let i=r;it?qn(t,e%t):e,Kn=(e,t)=>e+(t-qn(e,t));function Jn(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(Kn(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${Kn(t,n)}`);let i=0,o=0;const s=2**n-1,a=[];for(const r of e){if(Ln(r),r>=2**t)throw new Error(`convertRadix2: invalid data word=${r} from=${t}`);if(i=i<32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${t}`);for(o+=t;o>=n;o-=n)a.push((i>>o-n&s)>>>0);i&=2**o-1}if(i=i<=t)throw new Error("Excess padding");if(!r&&i)throw new Error(`Non-zero padding: ${i}`);return r&&o>0&&a.push(i>>>0),a}function Vn(e,t=!1){if(Ln(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(Kn(8,e)>32||Kn(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 Jn(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(Jn(n,e,8,t))}}}function Yn(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 zn=On(Vn(4),Mn("0123456789ABCDEF"),_n("")),Wn=On(Vn(5),Mn("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Hn(5),_n(""));On(Vn(5),Mn("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Hn(5),_n("")),On(Vn(5),Mn("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),_n(""),jn(e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));const Zn=On(Vn(6),Mn("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Hn(6),_n("")),Xn=On(Vn(6),Mn("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Hn(6),_n("")),er=e=>{return On((Ln(t=58),{encode:e=>{if(!(e instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return Gn(Array.from(e),256,t)},decode:e=>{if(!Array.isArray(e)||e.length&&"number"!=typeof e[0])throw new Error("radix.decode input should be array of strings");return Uint8Array.from(Gn(e,t,256))}}),Mn(e),_n(""));var t},tr=er("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");er("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),er("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const nr=[0,2,3,5,6,7,9,10,11],rr={encode(e){let t="";for(let n=0;n>25;let n=(33554431&e)<<5;for(let e=0;e>e&1)&&(n^=or[e]);return n}function ar(e,t,n=1){const r=e.length;let i=1;for(let t=0;t126)throw new Error(`Invalid prefix (${e})`);i=sr(i)^n>>5}i=sr(i);for(let t=0;tn)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);const r=e.toLowerCase();if(e!==r&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const i=(e=r).lastIndexOf("1");if(0===i||-1===i)throw new Error('Letter "1" must be present between prefix and data only');const o=e.slice(0,i),s=e.slice(i+1);if(s.length<6)throw new Error("Data must be at least 6 characters long");const a=ir.decode(s).slice(0,-6),l=ar(o,a,t);if(!s.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 i=e.length+7+n.length;if(!1!==r&&i>r)throw new TypeError(`Length ${i} exceeds limit ${r}`);return`${e=e.toLowerCase()}1${ir.encode(n)}${ar(e,n,t)}`},decode:s,decodeToBytes:function(e){const{prefix:t,words:n}=s(e,!1);return{prefix:t,words:n,bytes:r(n)}},decodeUnsafe:Yn(s),fromWords:r,fromWordsUnsafe:o,toWords:i}}const cr=lr("bech32");lr("bech32m");const ur={utf8:{encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)},hex:On(Vn(4),Mn("0123456789abcdef"),_n(""),jn(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()})),base16:zn,base32:Wn,base64:Zn,base64url:Xn,base58:tr,base58xmr:rr};function dr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function fr(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}function hr(e,...t){if(!((n=e)instanceof Uint8Array||null!=n&&"object"==typeof n&&"Uint8Array"===n.constructor.name))throw new Error("Uint8Array expected");var n;if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)} -/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */Object.keys(ur).join(", ");const pr=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");const gr=16;function mr(e){return e<<1^283&-(e>>7)}function yr(e,t){let n=0;for(;t>0;t>>=1)n^=e&-(1&t),e=mr(e);return n}const wr=(()=>{let e=new Uint8Array(256);for(let t=0,n=1;t<256;t++,n^=mr(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})(),vr=wr.map((e,t)=>wr.indexOf(t)),Ar=e=>e<<24|e>>>8,br=e=>e<<8|e>>>24;function kr(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(br),i=r.map(br),o=i.map(br),s=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;s[u]=n[t]^r[c],a[u]=i[t]^o[c],l[u]=e[t]<<8|e[c]}return{sbox:e,sbox2:l,T0:n,T1:r,T2:i,T3:o,T01:s,T23:a}}const Ir=kr(wr,e=>yr(e,3)<<24|e<<16|e<<8|yr(e,2)),Er=kr(vr,e=>yr(e,11)<<24|yr(e,13)<<16|yr(e,9)<<8|yr(e,14)),Cr=(()=>{const e=new Uint8Array(16);for(let t=0,n=1;t<16;t++,n=mr(n))e[t]=n;return e})();function xr(e){hr(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}=Ir,r=pr(e),i=r.length,o=e=>Sr(n,e,e,e,e),s=new Uint32Array(t+28);s.set(r);for(let e=i;e6&&e%i===4&&(t=o(t)),s[e]=s[e-i]^t}return s}function Br(e,t,n,r,i,o){return e[n<<8&65280|r>>>8&255]^t[i>>>8&65280|o>>>24&255]}function Sr(e,t,n,r,i){return e[255&t|65280&n]|e[r>>>16&255|i>>>16&65280]<<16}function Fr(e,t,n,r,i){const{sbox2:o,T01:s,T23:a}=Ir;let l=0;t^=e[l++],n^=e[l++],r^=e[l++],i^=e[l++];const c=e.length/4-2;for(let o=0;o{const o=xr(e),{b:s,o:a,out:l}=function(e,t,n){let r=e.length;const i=r%gr;if(!t&&0!==i)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");const o=pr(e);if(t){let e=gr-i;e||(e=gr),r+=e}const s=Dr(r,n);return{b:o,o:pr(s),out:s}}(n,r,i),c=pr(t);let u=c[0],d=c[1],f=c[2],h=c[3],p=0;for(;p+4<=s.length;)u^=s[p+0],d^=s[p+1],f^=s[p+2],h^=s[p+3],({s0:u,s1:d,s2:f,s3:h}=Fr(o,u,d,f,h)),a[p++]=u,a[p++]=d,a[p++]=f,a[p++]=h;if(r){const e=function(e){const t=new Uint8Array(16),n=pr(t);t.set(e);const r=gr-e.length;for(let e=gr-r;e{!function(e){if(hr(e),e.length%gr!==0)throw new Error("aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size 16")}(n);const o=function(e){const t=xr(e),n=t.slice(),r=t.length,{sbox2:i}=Ir,{T0:o,T1:s,T2:a,T3:l}=Er;for(let e=0;e>>8&255]^a[r>>>16&255]^l[r>>>24]}return n}(e),s=pr(t),a=Dr(n.length,i),l=pr(n),c=pr(a);let u=s[0],d=s[1],f=s[2],h=s[3];for(let e=0;e+4<=l.length;){const t=u,n=d,r=f,i=h;u=l[e+0],d=l[e+1],f=l[e+2],h=l[e+3];const{s0:s,s1:a,s2:p,s3:g}=Qr(o,u,d,f,h);c[e++]=s^t,c[e++]=a^n,c[e++]=p^r,c[e++]=g^i}return o.fill(0),function(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 i=e.subarray(0,-r);for(let t=0;tUint8Array.from(e.split("").map(e=>e.charCodeAt(0))),Tr=Ur("expand 16-byte k"),Nr=Ur("expand 32-byte k"),Lr=pr(Tr),Or=pr(Nr);function Mr(e,t){return e<>>32-t}function _r(e){return e.byteOffset%4==0}Or.slice();const Hr=2**32-1,jr=new Uint32Array;function Gr(e,t){const{allowShortKeys:n,extendNonceFn:r,counterLength:i,counterRight:o,rounds:s}=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 dr(i),dr(s),fr(o),fr(n),(t,a,l,c,u=0)=>{hr(t),hr(a),hr(l);const d=l.length;if(c||(c=new Uint8Array(d)),hr(c),dr(u),u<0||u>=Hr)throw new Error("arx: counter overflow");if(c.length=Hr)throw new Error("arx: counter overflow");const g=Math.min(64,l-p);if(d&&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,h[t]=f[t]^u[n];p+=64;continue}for(let e,t=0;t0;)f.pop().fill(0);return c}}function qr(e,t,n,r,i,o=20){let s=e[0],a=e[1],l=e[2],c=e[3],u=t[0],d=t[1],f=t[2],h=t[3],p=t[4],g=t[5],m=t[6],y=t[7],w=i,v=n[0],A=n[1],b=n[2],k=s,I=a,E=l,C=c,x=u,B=d,S=f,F=h,Q=p,D=g,R=m,P=y,$=w,U=v,T=A,N=b;for(let e=0;er?e.create().update(n).digest():n);for(let e=0;enew Jr(e,t).update(n).digest();Vr.create=(e,t)=>new Jr(e,t);const Yr=new Uint8Array([0]),zr=new Uint8Array;var Wr=Object.defineProperty,Zr=(e,t)=>{for(var n in t)Wr(e,n,{get:t[n],enumerable:!0})},Xr=Symbol("verified");function ei(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;tli,QueueNode:()=>ai,binarySearch:()=>si,bytesToHex:()=>en,hexToBytes:()=>tn,insertEventIntoAscendingList:()=>oi,insertEventIntoDescendingList:()=>ii,normalizeURL:()=>ri,utf8Decoder:()=>ti,utf8Encoder:()=>ni});var ti=new TextDecoder("utf-8"),ni=new TextEncoder;function ri(e){try{-1===e.indexOf("://")&&(e="wss://"+e);let t=new URL(e);return t.pathname=t.pathname.replace(/\/+/g,"/"),t.pathname.endsWith("/")&&(t.pathname=t.pathname.slice(0,-1)),("80"===t.port&&"ws:"===t.protocol||"443"===t.port&&"wss:"===t.protocol)&&(t.port=""),t.searchParams.sort(),t.hash="",t.toString()}catch(t){throw new Error(`Invalid URL: ${e}`)}}function ii(e,t){const[n,r]=si(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 oi(e,t){const[n,r]=si(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 si(e,t){let n=0,r=e.length-1;for(;n<=r;){const i=Math.floor((n+r)/2),o=t(e[i]);if(0===o)return[i,!0];o<0?r=i-1:n=i+1}return[n,!1]}var ai=class{value;next=null;prev=null;constructor(e){this.value=e}},li=class{first;last;constructor(){this.first=null,this.last=null}enqueue(e){const t=new ai(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 ci(e){return en(vn(ni.encode(function(e){if(!ei(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 ui=new class{generateSecretKey(){return Vt.utils.randomPrivateKey()}getPublicKey(e){return en(Vt.getPublicKey(e))}finalizeEvent(e,t){const n=e;return n.pubkey=en(Vt.getPublicKey(t)),n.id=ci(n),n.sig=en(Vt.sign(ci(n),t)),n[Xr]=!0,n}verifyEvent(e){if("boolean"==typeof e[Xr])return e[Xr];const t=ci(e);if(t!==e.id)return e[Xr]=!1,!1;try{const n=Vt.verify(e.sig,t,e.pubkey);return e[Xr]=n,n}catch(t){return e[Xr]=!1,!1}}},di=ui.generateSecretKey,fi=ui.getPublicKey,hi=ui.finalizeEvent,pi=ui.verifyEvent,gi={};function mi(e){return 1e3<=e&&e<1e4||[1,2,4,5,6,7,8,16,40,41,42,43,44].includes(e)}function yi(e){return[0,3].includes(e)||1e4<=e&&e<2e4}function wi(e){return 2e4<=e&&e<3e4}function vi(e){return 3e4<=e&&e<4e4}function Ai(e){return mi(e)?"regular":yi(e)?"replaceable":wi(e)?"ephemeral":vi(e)?"parameterized":"unknown"}function bi(e,t){const n=t instanceof Array?t:[t];return ei(e)&&n.includes(e.kind)||!1}Zr(gi,{Application:()=>$o,BadgeAward:()=>Qi,BadgeDefinition:()=>Bo,BlockedRelaysList:()=>ao,BookmarkList:()=>io,Bookmarksets:()=>Eo,Calendar:()=>_o,CalendarEventRSVP:()=>Ho,ChannelCreation:()=>$i,ChannelHideMessage:()=>Ni,ChannelMessage:()=>Ti,ChannelMetadata:()=>Ui,ChannelMuteUser:()=>Li,ClassifiedListing:()=>No,ClientAuth:()=>mo,CommunitiesList:()=>oo,CommunityDefinition:()=>qo,CommunityPostApproval:()=>Ji,Contacts:()=>Ci,CreateOrUpdateProduct:()=>Qo,CreateOrUpdateStall:()=>Fo,Curationsets:()=>Co,Date:()=>Oo,DirectMessageRelaysList:()=>fo,DraftClassifiedListing:()=>Lo,DraftLong:()=>Ro,Emojisets:()=>Po,EncryptedDirectMessage:()=>xi,EventDeletion:()=>Bi,FileMetadata:()=>_i,FileServerPreference:()=>ho,Followsets:()=>bo,GenericRepost:()=>Pi,Genericlists:()=>ko,GiftWrap:()=>Mi,HTTPAuth:()=>Ao,Handlerinformation:()=>Go,Handlerrecommendation:()=>jo,Highlights:()=>eo,InterestsList:()=>co,Interestsets:()=>So,JobFeedback:()=>zi,JobRequest:()=>Vi,JobResult:()=>Yi,Label:()=>Ki,LightningPubRPC:()=>go,LiveChatMessage:()=>Hi,LiveEvent:()=>Uo,LongFormArticle:()=>Do,Metadata:()=>ki,Mutelist:()=>to,NWCWalletInfo:()=>po,NWCWalletRequest:()=>yo,NWCWalletResponse:()=>wo,NostrConnect:()=>vo,OpenTimestamps:()=>Oi,Pinlist:()=>no,PrivateDirectMessage:()=>Ri,ProblemTracker:()=>ji,ProfileBadges:()=>xo,PublicChatsList:()=>so,Reaction:()=>Fi,RecommendRelay:()=>Ei,RelayList:()=>ro,Relaysets:()=>Io,Report:()=>Gi,Reporting:()=>qi,Repost:()=>Si,Seal:()=>Di,SearchRelaysList:()=>lo,ShortTextNote:()=>Ii,Time:()=>Mo,UserEmojiList:()=>uo,UserStatuses:()=>To,Zap:()=>Xi,ZapGoal:()=>Wi,ZapRequest:()=>Zi,classifyKind:()=>Ai,isAddressableKind:()=>vi,isEphemeralKind:()=>wi,isKind:()=>bi,isRegularKind:()=>mi,isReplaceableKind:()=>yi});var ki=0,Ii=1,Ei=2,Ci=3,xi=4,Bi=5,Si=6,Fi=7,Qi=8,Di=13,Ri=14,Pi=16,$i=40,Ui=41,Ti=42,Ni=43,Li=44,Oi=1040,Mi=1059,_i=1063,Hi=1311,ji=1971,Gi=1984,qi=1984,Ki=1985,Ji=4550,Vi=5999,Yi=6999,zi=7e3,Wi=9041,Zi=9734,Xi=9735,eo=9802,to=1e4,no=10001,ro=10002,io=10003,oo=10004,so=10005,ao=10006,lo=10007,co=10015,uo=10030,fo=10050,ho=10096,po=13194,go=21e3,mo=22242,yo=23194,wo=23195,vo=24133,Ao=27235,bo=3e4,ko=30001,Io=30002,Eo=30003,Co=30004,xo=30008,Bo=30009,So=30015,Fo=30017,Qo=30018,Do=30023,Ro=30024,Po=30030,$o=30078,Uo=30311,To=30315,No=30402,Lo=30403,Oo=31922,Mo=31923,_o=31924,Ho=31925,jo=31989,Go=31990,qo=34550;function Ko(e,t){let n=t.length+3,r=e.indexOf(`"${t}":`)+n,i=e.slice(r).indexOf('"')+r+1;return e.slice(i,i+64)}function Jo(e,t){let n=t.length,r=e.indexOf(`"${t}":`)+n+3,i=e.slice(r),o=Math.min(i.indexOf(","),i.indexOf("}"));return parseInt(i.slice(0,o),10)}function Vo(e){let t=e.slice(0,22).indexOf('"EVENT"');if(-1===t)return null;let n=e.slice(t+7+1).indexOf('"');if(-1===n)return null;let r=t+7+1+n,i=e.slice(r+1,80).indexOf('"');if(-1===i)return null;let o=r+1+i;return e.slice(r+1,o)}function Yo(e,t){return t===Ko(e,"id")}function zo(e,t){return t===Ko(e,"pubkey")}function Wo(e,t){return t===Jo(e,"kind")}Zr({},{getHex64:()=>Ko,getInt:()=>Jo,getSubscriptionId:()=>Vo,matchEventId:()=>Yo,matchEventKind:()=>Wo,matchEventPubkey:()=>zo});function Zo(e,t){return{kind:mo,created_at:Math.floor(Date.now()/1e3),tags:[["relay",e],["challenge",t]],content:""}}Zr({},{makeAuthEvent:()=>Zo});try{WebSocket}catch{}try{WebSocket}catch{}var Xo={};Zr(Xo,{BECH32_REGEX:()=>ns,Bech32MaxSize:()=>ts,NostrTypeGuard:()=>es,decode:()=>is,decodeNostrURI:()=>rs,encodeBytes:()=>us,naddrEncode:()=>hs,neventEncode:()=>fs,noteEncode:()=>ls,nprofileEncode:()=>ds,npubEncode:()=>as,nsecEncode:()=>ss});var es={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||"")},ts=5e3,ns=/[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;function rs(e){try{return e.startsWith("nostr:")&&(e=e.substring(6)),is(e)}catch(e){return{type:"invalid",data:null}}}function is(e){let{prefix:t,words:n}=cr.decode(e,ts),r=new Uint8Array(cr.fromWords(n));switch(t){case"nprofile":{let e=os(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:en(e[0][0]),relays:e[1]?e[1].map(e=>ti.decode(e)):[]}}}case"nevent":{let e=os(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:en(e[0][0]),relays:e[1]?e[1].map(e=>ti.decode(e)):[],author:e[2]?.[0]?en(e[2][0]):void 0,kind:e[3]?.[0]?parseInt(en(e[3][0]),16):void 0}}}case"naddr":{let e=os(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:ti.decode(e[0][0]),pubkey:en(e[2][0]),kind:parseInt(en(e[3][0]),16),relays:e[1]?e[1].map(e=>ti.decode(e)):[]}}}case"nsec":return{type:t,data:r};case"npub":case"note":return{type:t,data:en(r)};default:throw new Error(`unknown prefix ${t}`)}}function os(e){let t={},n=e;for(;n.length>0;){let e=n[0],r=n[1],i=n.slice(2,2+r);if(n=n.slice(2+r),i.lengthni.encode(e))}))}function fs(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)),cs("nevent",ps({0:[tn(e.id)],1:(e.relays||[]).map(e=>ni.encode(e)),2:e.author?[tn(e.author)]:[],3:t?[new Uint8Array(t)]:[]}))}function hs(e){let t=new ArrayBuffer(4);return new DataView(t).setUint32(0,e.kind,!1),cs("naddr",ps({0:[ni.encode(e.identifier)],1:(e.relays||[]).map(e=>ni.encode(e)),2:[tn(e.pubkey)],3:[new Uint8Array(t)]}))}function ps(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)})}),rn(...t)}var gs={};function ms(e,t,n){const r=e instanceof Uint8Array?en(e):e,i=ws(Rt.getSharedSecret(r,"02"+t));let o=Uint8Array.from(an(16)),s=ni.encode(n),a=Rr(i,o).encrypt(s);return`${Zn.encode(new Uint8Array(a))}?iv=${Zn.encode(new Uint8Array(o.buffer))}`}function ys(e,t,n){const r=e instanceof Uint8Array?en(e):e;let[i,o]=n.split("?iv="),s=ws(Rt.getSharedSecret(r,"02"+t)),a=Zn.decode(o),l=Zn.decode(i),c=Rr(s,a).decrypt(l);return ti.decode(c)}function ws(e){return e.slice(1,33)}Zr(gs,{decrypt:()=>ys,encrypt:()=>ms});Zr({},{NIP05_REGEX:()=>As,isNip05:()=>bs,isValid:()=>Cs,queryProfile:()=>Es,searchDomain:()=>Is,useFetchImplementation:()=>ks});var vs,As=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,bs=e=>As.test(e||"");try{vs=fetch}catch(e){}function ks(e){vs=e}async function Is(e,t=""){try{const n=`https://${e}/.well-known/nostr.json?name=${t}`,r=await vs(n,{redirect:"manual"});if(200!==r.status)throw Error("Wrong response code");return(await r.json()).names}catch(e){return{}}}async function Es(e){const t=e.match(As);if(!t)return null;const[,n="_",r]=t;try{const e=`https://${r}/.well-known/nostr.json?name=${n}`,t=await vs(e,{redirect:"manual"});if(200!==t.status)throw Error("Wrong response code");const i=await t.json(),o=i.names[n];return o?{pubkey:o,relays:i.relays?.[o]}:null}catch(e){return null}}async function Cs(e,t){const n=await Es(t);return!!n&&n.pubkey===e}function xs(e){const t={reply:void 0,root:void 0,mentions:[],profiles:[],quotes:[]};let n,r;for(let i=e.tags.length-1;i>=0;i--){const o=e.tags[i];if("e"===o[0]&&o[1]){const[e,i,s,a,l]=o,c={id:i,relays:s?[s]:[],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}Zr({},{parse:()=>xs});Zr({},{fetchRelayInformation:()=>Ss,useFetchImplementation:()=>Bs});try{fetch}catch{}function Bs(e){0}async function Ss(e){return await(await fetch(e.replace("ws://","http://").replace("wss://","https://"),{headers:{Accept:"application/nostr+json"}})).json()}function Fs(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 Qs(e,t){let n=0;const r=e,i=["nonce",n.toString(),t.toString()];for(r.tags.push(i);;){const e=Math.floor((new Date).getTime()/1e3);if(e!==r.created_at&&(n=0,r.created_at=e),i[1]=(++n).toString(),r.id=Ds(r),Fs(r.id)>=t)break}return r}function Ds(e){return en(vn(ni.encode(JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content]))))}Zr({},{fastEventHash:()=>Ds,getPow:()=>Fs,minePow:()=>Qs});Zr({},{unwrapEvent:()=>ra,unwrapManyEvents:()=>ia,wrapEvent:()=>ta,wrapManyEvents:()=>na});Zr({},{createRumor:()=>Vs,createSeal:()=>Ys,createWrap:()=>zs,unwrapEvent:()=>Xs,unwrapManyEvents:()=>ea,wrapEvent:()=>Ws,wrapManyEvents:()=>Zs});var Rs={};Zr(Rs,{decrypt:()=>_s,encrypt:()=>Ms,getConversationKey:()=>Us,v2:()=>Hs});var Ps=1,$s=65535;function Us(e,t){const n=Rt.getSharedSecret(e,"02"+t).subarray(1,33);return function(e,t,n){return un.hash(e),void 0===n&&(n=new Uint8Array(e.outputLen)),Vr(e,nn(n),nn(t))}(vn,n,"nip44-v2")}function Ts(e,t){const n=function(e,t,n,r=32){if(un.hash(e),un.number(r),r>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const i=Math.ceil(r/e.outputLen);void 0===n&&(n=zr);const o=new Uint8Array(i*e.outputLen),s=Vr.create(e,t),a=s._cloneInto(),l=new Uint8Array(s.outputLen);for(let t=0;t$s)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(Ns(n)-n))}function Os(e,t,n){if(32!==n.length)throw new Error("AAD associated data must be 32 bytes");const r=rn(n,t);return Vr(vn,e,r)}function Ms(e,t,n=an(32)){const{chacha_key:r,chacha_nonce:i,hmac_key:o}=Ts(t,n),s=Ls(e),a=Kr(r,i,s),l=Os(o,a,n);return Zn.encode(rn(new Uint8Array([2]),n,a,l))}function _s(e,t){const{nonce:n,ciphertext:r,mac:i}=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=Zn.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 i=n[0];if(2!==i)throw new Error("unknown encryption version "+i);return{nonce:n.subarray(1,33),ciphertext:n.subarray(33,-32),mac:n.subarray(-32)}}(e),{chacha_key:o,chacha_nonce:s,hmac_key:a}=Ts(t,n);if(!function(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r$s||n.length!==t||e.length!==2+Ns(t))throw new Error("invalid padding");return ti.decode(n)}(Kr(o,s,r))}var Hs={utils:{getConversationKey:Us,calcPaddedLen:Ns},encrypt:Ms,decrypt:_s},js=()=>Math.round(Date.now()/1e3),Gs=()=>Math.round(js()-172800*Math.random()),qs=(e,t)=>Us(e,t),Ks=(e,t,n)=>Ms(JSON.stringify(e),qs(t,n)),Js=(e,t)=>JSON.parse(_s(e.content,qs(t,e.pubkey)));function Vs(e,t){const n={created_at:js(),content:"",tags:[],...e,pubkey:fi(t)};return n.id=ci(n),n}function Ys(e,t,n){return hi({kind:Di,content:Ks(e,t,n),created_at:Gs(),tags:[]},t)}function zs(e,t){const n=di();return hi({kind:Mi,content:Ks(e,n,t),created_at:Gs(),tags:[["p",t]]},n)}function Ws(e,t,n){return zs(Ys(Vs(e,t),t,n),n)}function Zs(e,t,n){if(!n||0===n.length)throw new Error("At least one recipient is required.");const r=fi(t),i=[Ws(e,t,r)];return n.forEach(n=>{i.push(Ws(e,t,n))}),i}function Xs(e,t){const n=Js(e,t);return Js(n,t)}function ea(e,t){let n=[];return e.forEach(e=>{n.push(Xs(e,t))}),n.sort((e,t)=>e.created_at-t.created_at),n}function ta(e,t,n,r,i){const o=function(e,t,n,r){const i={created_at:Math.ceil(Date.now()/1e3),kind:Ri,tags:[],content:t};return(Array.isArray(e)?e:[e]).forEach(({publicKey:e,relayUrl:t})=>{i.tags.push(t?["p",e,t]:["p",e])}),r&&i.tags.push(["e",r.eventId,r.relayUrl||"","reply"]),n&&i.tags.push(["subject",n]),i}(t,n,r,i);return Ws(o,e,t.publicKey)}function na(e,t,n,r,i){if(!t||0===t.length)throw new Error("At least one recipient is required.");return[{publicKey:fi(e)},...t].map(t=>ta(e,t,n,r,i))}var ra=Xs,ia=ea;function oa(e,t,n,r){let i;const o=[...e.tags??[],["e",t.id,n],["p",t.pubkey]];return t.kind===Ii?i=Si:(i=Pi,o.push(["k",String(t.kind)])),hi({kind:i,tags:o,content:""===e.content||t.tags?.find(e=>"-"===e[0])?"":JSON.stringify(t),created_at:e.created_at},r)}function sa(e){if(![Si,Pi].includes(e.kind))return;let t,n;for(let r=e.tags.length-1;r>=0&&(void 0===t||void 0===n);r--){const i=e.tags[r];i.length>=2&&("e"===i[0]&&void 0===t?t=i:"p"===i[0]&&void 0===n&&(n=i))}return void 0!==t?{id:t[1],relays:[t[2],n?.[2]].filter(e=>"string"==typeof e),author:n?.[1]}:void 0}function aa(e,{skipVerification:t}={}){const n=sa(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||pi(r))?r:void 0}Zr({},{finishRepostEvent:()=>oa,getRepostedEvent:()=>aa,getRepostedEventPointer:()=>sa});Zr({},{NOSTR_URI_REGEX:()=>la,parse:()=>ua,test:()=>ca});var la=new RegExp(`nostr:(${ns.source})`);function ca(e){return"string"==typeof e&&new RegExp(`^${la.source}$`).test(e)}function ua(e){const t=e.match(new RegExp(`^${la.source}$`));if(!t)throw new Error(`Invalid Nostr URI: ${e}`);return{uri:t[0],value:t[1],decoded:is(t[1])}}function da(e,t,n){const r=t.tags.filter(e=>e.length>=2&&("e"===e[0]||"p"===e[0]));return hi({...e,kind:Fi,tags:[...e.tags??[],...r,["e",t.id],["p",t.pubkey]],content:e.content??"+"},n)}function fa(e){if(e.kind!==Fi)return;let t,n;for(let r=e.tags.length-1;r>=0&&(void 0===t||void 0===n);r--){const i=e.tags[r];i.length>=2&&("e"===i[0]&&void 0===t?t=i:"p"===i[0]&&void 0===n&&(n=i))}return void 0!==t&&void 0!==n?{id:t[1],relays:[t[2],n[2]].filter(e=>void 0!==e),author:n[1]}:void 0}Zr({},{finishReactionEvent:()=>da,getReactedEventPointer:()=>fa});Zr({},{parse:()=>ga});var ha=/\W/m,pa=/\W |\W$|$|,| /m;function*ga(e){const t=e.length;let n=0,r=0;for(;rma,channelHideMessageEvent:()=>va,channelMessageEvent:()=>wa,channelMetadataEvent:()=>ya,channelMuteUserEvent:()=>Aa});var ma=(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 hi({kind:$i,tags:[...e.tags??[]],content:n,created_at:e.created_at},t)},ya=(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 hi({kind:Ui,tags:[["e",e.channel_create_event_id],...e.tags??[]],content:n,created_at:e.created_at},t)},wa=(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"]),hi({kind:Ti,tags:[...n,...e.tags??[]],content:e.content,created_at:e.created_at},t)},va=(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 hi({kind:Ni,tags:[["e",e.channel_message_event_id],...e.tags??[]],content:n,created_at:e.created_at},t)},Aa=(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 hi({kind:Li,tags:[["p",e.pubkey_to_mute],...e.tags??[]],content:n,created_at:e.created_at},t)};Zr({},{EMOJI_SHORTCODE_REGEX:()=>ba,matchAll:()=>Ia,regex:()=>ka,replaceAll:()=>Ea});var ba=/:(\w+):/,ka=()=>new RegExp(`\\B${ba.source}\\B`,"g");function*Ia(e){const t=e.matchAll(ka());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 Ea(e,t){return e.replaceAll(ka(),(e,n)=>t({shortcode:e,name:n}))}var Ca;Zr({},{useFetchImplementation:()=>xa,validateGithub:()=>Ba});try{Ca=fetch}catch{}function xa(e){Ca=e}async function Ba(e,t,n){try{return await(await Ca(`https://gist.github.com/${t}/${n}/raw`)).text()===`Verifying that I control the following Nostr public key: ${e}`}catch(e){return!1}}function Sa(e){const{host:t,pathname:n,searchParams:r}=new URL(e),i=n||t,o=r.get("relay"),s=r.get("secret");if(!i||!o||!s)throw new Error("invalid connection string");return{pubkey:i,relay:o,secret:s}}async function Fa(e,t,n){const r={method:"pay_invoice",params:{invoice:n}},i=ms(t,e,JSON.stringify(r)),o={kind:yo,created_at:Math.round(Date.now()/1e3),content:i,tags:[["p",e]]};return hi(o,t)}Zr({},{makeNwcRequestEvent:()=>Fa,parseConnectionString:()=>Sa});function Qa(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("")}Zr({},{normalizeIdentifier:()=>Qa});var Da;Zr({},{getSatoshisAmountFromBolt11:()=>Na,getZapEndpoint:()=>Pa,makeZapReceipt:()=>Ta,makeZapRequest:()=>$a,useFetchImplementation:()=>Ra,validateZapRequest:()=>Ua});try{Da=fetch}catch{}function Ra(e){Da=e}async function Pa(e){try{let t="",{lud06:n,lud16:r}=JSON.parse(e.content);if(n){let{words:e}=cr.decode(n,1e3),r=cr.fromWords(e);t=ti.decode(r)}else{if(!r)return null;{let[e,n]=r.split("@");t=new URL(`/.well-known/lnurlp/${e}`,`https://${n}`).toString()}}let i=await Da(t),o=await i.json();if(o.allowsNostr&&o.nostrPubkey)return o.callback}catch(e){}return null}function $a(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]),yi(e.event.kind)){const n=["a",`${e.event.kind}:${e.event.pubkey}:`];t.tags.push(n)}else if(vi(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 Ua(e){let t;try{t=JSON.parse(e)}catch(e){return"Invalid zap request JSON."}if(!ei(t))return"Zap request is not a valid Nostr event.";if(!pi(t))return"Invalid signature on zap request.";let n=t.tags.find(([e,t])=>"p"===e&&t);if(!n)return"Zap request doesn't have a 'p' tag.";if(!n[1].match(/^[a-f0-9]{64}$/))return"Zap request 'p' tag is not valid hex.";let r=t.tags.find(([e,t])=>"e"===e&&t);return r&&!r[1].match(/^[a-f0-9]{64}$/)?"Zap request 'e' tag is not valid hex.":t.tags.find(([e,t])=>"relays"===e&&t)?null:"Zap request doesn't have a 'relays' tag."}function Ta({zapRequest:e,preimage:t,bolt11:n,paidAt:r}){let i=JSON.parse(e),o=i.tags.filter(([e])=>"e"===e||"p"===e||"a"===e),s={kind:9735,created_at:Math.round(r.getTime()/1e3),content:"",tags:[...o,["P",i.pubkey],["bolt11",n],["description",e]]};return t&&s.tags.push(["preimage",t]),s}function Na(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 i=r[r.length-1],o=i.charCodeAt(0)-"0".charCodeAt(0),s=o>=0&&o<=9;let a=r.length-1;if(s&&a++,a<1)return 0;const l=parseInt(r.substring(0,a));switch(i){case"m":return 1e5*l;case"u":return 100*l;case"n":return l/10;case"p":return l/1e4;default:return 1e8*l}}Zr({},{getToken:()=>Oa,hashPayload:()=>Ka,unpackEventFromToken:()=>_a,validateEvent:()=>Va,validateEventKind:()=>ja,validateEventMethodTag:()=>qa,validateEventPayloadTag:()=>Ja,validateEventTimestamp:()=>Ha,validateEventUrlTag:()=>Ga,validateToken:()=>Ma});var La="Nostr ";async function Oa(e,t,n,r=!1,i){const o={kind:Ao,tags:[["u",e],["method",t]],created_at:Math.round((new Date).getTime()/1e3),content:""};i&&o.tags.push(["payload",Ka(i)]);const s=await n(o);return(r?La:"")+Zn.encode(ni.encode(JSON.stringify(s)))}async function Ma(e,t,n){const r=await _a(e).catch(e=>{throw e});return await Va(r,t,n).catch(e=>{throw e})}async function _a(e){if(!e)throw new Error("Missing token");e=e.replace(La,"");const t=ti.decode(Zn.decode(e));if(!t||0===t.length||!t.startsWith("{"))throw new Error("Invalid token");return JSON.parse(t)}function Ha(e){return!!e.created_at&&Math.round((new Date).getTime()/1e3)-e.created_at<60}function ja(e){return e.kind===Ao}function Ga(e,t){const n=e.tags.find(e=>"u"===e[0]);return!!n&&(n.length>0&&n[1]===t)}function qa(e,t){const n=e.tags.find(e=>"method"===e[0]);return!!n&&(n.length>0&&n[1].toLowerCase()===t.toLowerCase())}function Ka(e){return en(vn(ni.encode(JSON.stringify(e))))}function Ja(e,t){const n=e.tags.find(e=>"payload"===e[0]);if(!n)return!1;const r=Ka(t);return n.length>0&&n[1]===r}async function Va(e,t,n,r){if(!pi(e))throw new Error("Invalid nostr event, signature invalid");if(!ja(e))throw new Error("Invalid nostr event, kind invalid");if(!Ha(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(!qa(e,n))throw new Error("Invalid nostr event, method tag invalid");if(Boolean(r)&&"object"==typeof r&&Object.keys(r).length>0&&!Ja(e,r))throw new Error("Invalid nostr event, payload tag does not match request body hash");return!0}function Ya(e){return[0,3].includes(e)||1e4<=e&&e<2e4}function za(e){return 3e4<=e&&e<4e4}var Wa=function(e,t){return Wa=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Wa(e,t)};function Za(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}Wa(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function Xa(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{l(r.next(e))}catch(e){o(e)}}function a(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((r=r.apply(e,t||[])).next())})}function el(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(l){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function nl(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function rl(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i1||a(e,t)})},t&&(r[e]=t(r[e])))}function a(e,t){try{(n=i[e](t)).value instanceof il?Promise.resolve(n.value.v).then(l,c):u(o[0][2],n)}catch(e){u(o[0][3],e)}var n}function l(e){a("next",e)}function c(e){a("throw",e)}function u(e,t){e(t),o.shift(),o.length&&a(o[0][0],o[0][1])}}function sl(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=tl(e),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise(function(r,i){(function(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)})(r,i,(t=e[n](t)).done,t.value)})}}}function al(e){return"function"==typeof e}function ll(e){var t=e(function(e){Error.call(e),e.stack=(new Error).stack});return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}"function"==typeof SuppressedError&&SuppressedError;var cl=ll(function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map(function(e,t){return t+1+") "+e.toString()}).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}});function ul(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var dl=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var e,t,n,r,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var s=tl(o),a=s.next();!a.done;a=s.next()){a.value.remove(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}else o.remove(this);var l=this.initialTeardown;if(al(l))try{l()}catch(e){i=e instanceof cl?e.errors:[e]}var c=this._finalizers;if(c){this._finalizers=null;try{for(var u=tl(c),d=u.next();!d.done;d=u.next()){var f=d.value;try{pl(f)}catch(e){i=null!=i?i:[],e instanceof cl?i=rl(rl([],nl(i)),nl(e.errors)):i.push(e)}}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}}if(i)throw new cl(i)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)pl(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(n=this._finalizers)&&void 0!==n?n:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&ul(t,e)},e.prototype.remove=function(t){var n=this._finalizers;n&&ul(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),fl=dl.EMPTY;function hl(e){return e instanceof dl||e&&"closed"in e&&al(e.remove)&&al(e.add)&&al(e.unsubscribe)}function pl(e){al(e)?e():e.unsubscribe()}var gl={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},ml={setTimeout:function(e,t){for(var n=[],r=2;r0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,n=this,r=n.hasError,i=n.isStopped,o=n.observers;return r||i?fl:(this.currentObservers=null,o.push(e),new dl(function(){t.currentObservers=null,ul(o,e)}))},t.prototype._checkFinalizedStatuses=function(e){var t=this,n=t.hasError,r=t.thrownError,i=t.isStopped;n?e.error(r):i&&e.complete()},t.prototype.asObservable=function(){var e=new Fl;return e.source=this,e},t.create=function(e,t){return new Tl(e,t)},t}(Fl),Tl=function(e){function t(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return Za(t,e),t.prototype.next=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===n||n.call(t,e)},t.prototype.error=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===n||n.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,n;return null!==(n=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==n?n:fl},t}(Ul),Nl={now:function(){return(Nl.delegate||Date).now()},delegate:void 0},Ll=function(e){function t(t,n,r){void 0===t&&(t=1/0),void 0===n&&(n=1/0),void 0===r&&(r=Nl);var i=e.call(this)||this;return i._bufferSize=t,i._windowTime=n,i._timestampProvider=r,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=n===1/0,i._bufferSize=Math.max(1,t),i._windowTime=Math.max(1,n),i}return Za(t,e),t.prototype.next=function(t){var n=this,r=n.isStopped,i=n._buffer,o=n._infiniteTimeWindow,s=n._timestampProvider,a=n._windowTime;r||(i.push(t),!o&&i.push(s.now()+a)),this._trimBuffer(),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var t=this._innerSubscribe(e),n=this._infiniteTimeWindow,r=this._buffer.slice(),i=0;i=2,!0))}function Oc(e,t){for(var n=[],r=2;rt.reduce((e,t)=>{const n=[];for(const r of e)try{const e=t(r);if(void 0===e)continue;n.push(e)}catch(e){}return n},e);var Yc=Symbol("verified");function zc(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;tt.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 iu(e,t){let n=0,r=e.length-1;for(;n<=r;){const i=Math.floor((n+r)/2),o=t(e[i]);if(0===o)return[i,!0];o<0?r=i-1:n=i+1}return[n,!1]}Xc.finalizeEvent,Xc.verifyEvent,new TextDecoder("utf-8"),new TextEncoder;const ou=Symbol.for("event-store"),su=Symbol.for("event-uid"),au=Symbol.for("replaceable-address"),lu=Symbol.for("from-cache"),cu=Symbol.for("replaceable-identifier");function uu(e){return Ya(e)||za(e)}function du(e){let t=Reflect.get(e,su);return t||(t=za(e.kind)||Ya(e.kind)?fu(e):e.id,Reflect.set(e,su,t)),t}function fu(e){if(!za(e.kind)&&!Ya(e.kind))throw new Error("Event is not replaceable or addressable");return nu(e,au,()=>hu(e.kind,e.pubkey,pu(e)))}function hu(e,t,n){return e+":"+t+":"+(n??"")}function pu(e){return nu(e,cu,()=>e.tags.find(e=>"d"===e[0])?.[1]??"")}function gu(){return Math.round(Date.now()/1e3)}const mu=Symbol("expiration-timestamp");function yu(e){return nu(e,mu,()=>{const t=e.tags.find(e=>"expiration"===e[0])?.[1];return t?parseInt(t):void 0})}var wu=new TextDecoder("utf-8");new TextEncoder;function vu(e){let{prefix:t,words:n}=cr.decode(e,5e3),r=new Uint8Array(cr.fromWords(n));switch(t){case"nprofile":{let e=Au(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:en(e[0][0]),relays:e[1]?e[1].map(e=>wu.decode(e)):[]}}}case"nevent":{let e=Au(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:en(e[0][0]),relays:e[1]?e[1].map(e=>wu.decode(e)):[],author:e[2]?.[0]?en(e[2][0]):void 0,kind:e[3]?.[0]?parseInt(en(e[3][0]),16):void 0}}}case"naddr":{let e=Au(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:wu.decode(e[0][0]),pubkey:en(e[2][0]),kind:parseInt(en(e[3][0]),16),relays:e[1]?e[1].map(e=>wu.decode(e)):[]}}}case"nsec":return{type:t,data:r};case"npub":case"note":return{type:t,data:en(r)};default:throw new Error(`unknown prefix ${t}`)}}function Au(e){let t={},n=e;for(;n.length>0;){let e=n[0],r=n[1],i=n.slice(2,2+r);if(n=n.slice(2+r),i.length=8&&xu.test(e)}function Su(e){return!!e?.toLowerCase()?.match(/^[0-9a-f]{64}$/)}const Fu="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0; -/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Qu(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function Du(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Ru(e,...t){if(!Qu(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Pu(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");Du(e.outputLen),Du(e.blockLen)}function $u(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 Uu(...e){for(let t=0;t>>t}const Lu=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),Ou=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Mu(e){if(Ru(e),Lu)return e.toHex();let t="";for(let n=0;n=_u&&e<=Hu?e-_u:e>=ju&&e<=Gu?e-(ju-10):e>=qu&&e<=Ku?e-(qu-10):void 0}function Vu(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(Lu)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,i=0;te().update(Yu(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Xu(e=32){if(Fu&&"function"==typeof Fu.getRandomValues)return Fu.getRandomValues(new Uint8Array(e));if(Fu&&"function"==typeof Fu.randomBytes)return Uint8Array.from(Fu.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function ed(e,t=!1,n=!0){const r=e.split(":"),i=r[0]?parseInt(r[0]):void 0,o=r[1],s=r[2];if(void 0===i){if(n)return null;throw new Error("Missing kind")}if(void 0===o||""===o){if(n)return null;throw new Error("Missing pubkey")}if(t&&void 0===s){if(n)return null;throw new Error("Missing identifier")}return{kind:i,pubkey:o,identifier:s}}function td(e){if(!e[1])throw new Error("Missing coordinate in tag");const t=ed(e[1],!0,!1);return e[2]&&Bu(e[2])&&(t.relays=[e[2]]),t}function nd(e){if(!e[1])throw new Error("Missing pubkey in tag");if(!Su(e[1]))throw new Error("Invalid pubkey");const t={pubkey:e[1]};return e[2]&&Bu(e[2])&&(t.relays=[Iu(e[2])]),t}function rd(e){return e.kind+":"+e.pubkey+":"+e.identifier}const id=Symbol.for("encrypted-content"),od={[gi.EncryptedDirectMessage]:"nip04",[gi.Seal]:"nip44",[gi.GiftWrap]:"nip44"};function sd(e,t){return od[e]=t,e}const ad=id,ld=new Set([sd(gi.DraftLong,"nip04")]);function cd(e,t){return ld.add(sd(e,t)),e}function ud(e){return function(e){return void 0!==od[e]}(e)&&ld.has(e)}function dd(e){return!!ud(e.kind)&&(function(e){return!0===Reflect.has(e,id)}(e)&&!0===Reflect.has(e,ad))}function fd(e){if(ud(e.kind))return dd(e)?e[id]:function(e){return Reflect.get(e,id)}(e)}const hd=Symbol.for("hidden-tags"),pd=new Set([cd(gi.BookmarkList,"nip04"),cd(gi.InterestsList,"nip04"),cd(gi.Mutelist,"nip04"),cd(gi.CommunitiesList,"nip04"),cd(gi.PublicChatsList,"nip04"),cd(gi.SearchRelaysList,"nip04"),cd(10009,"nip04"),cd(gi.Bookmarksets,"nip04"),cd(gi.Relaysets,"nip04"),cd(gi.Followsets,"nip04"),cd(gi.Curationsets,"nip04"),cd(gi.Interestsets,"nip04")]);function gd(e){return ud(e)&&pd.has(e)}function md(e){return!!gd(e.kind)&&(dd(e)&&Reflect.has(e,"HiddenTagsSymbol"))}function yd(e){if(!gd(e.kind))return;if(md(e))return e[hd];const t=fd(e);if(void 0===t)return;const n=JSON.parse(t);if(!Array.isArray(n))throw new Error("Content is not an array of tags");const r=n.filter(e=>Array.isArray(e)).map(e=>e.map(e=>String(e)));return Reflect.set(e,hd,r),r}const wd="abcdefghijklmnopqrstuvwxyz",vd=new Set((wd+wd.toUpperCase()).split("")),Ad=Symbol.for("indexable-tags");function bd(e){let t=Reflect.get(e,Ad);if(!t){const n=new Set;for(const t of e.tags)t.length>=2&&1===t[0].length&&vd.has(t[0])&&n.add(t[0]+":"+t[1]);t=n,Reflect.set(e,Ad,n)}return t}class kd{first=null;items=Object.create(null);last=null;max;resetTtl;size;ttl;constructor(e=0,t=0,n=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=e,this.resetTtl=n,this.size=0,this.ttl=t}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(e){if(this.has(e)){const t=this.items[e];delete this.items[e],this.size--,null!==t.prev&&(t.prev.next=t.next),null!==t.next&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),this.last===t&&(this.last=t.prev)}return this}entries(e=this.keys()){return e.map(e=>[e,this.get(e)])}evict(e=!1){if(e||this.size>0){const e=this.first;delete this.items[e.key],0===--this.size?(this.first=null,this.last=null):(this.first=e.next,this.first.prev=null)}return this}expiresAt(e){let t;return this.has(e)&&(t=this.items[e].expiry),t}get(e){let t;if(this.has(e)){const n=this.items[e];this.ttl>0&&n.expiry<=Date.now()?this.delete(e):(t=n.value,this.set(e,t,!0))}return t}has(e){return e in this.items}keys(){const e=[];let t=this.first;for(;null!==t;)e.push(t.key),t=t.next;return e}set(e,t,n=!1,r=this.resetTtl){let i;if(n||this.has(e)){if(i=this.items[e],i.value=t,!1===n&&r&&(i.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==i){const e=this.last,t=i.next,n=i.prev;this.first===i&&(this.first=i.next),i.next=null,i.prev=this.last,e.next=i,null!==n&&(n.next=t),null!==t&&(t.prev=n)}}else this.max>0&&this.size===this.max&&this.evict(!0),i=this.items[e]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:e,prev:this.last,next:null,value:t},1===++this.size?this.first=i:this.last.next=i;return this.last=i,this}values(e=this.keys()){return e.map(e=>this.get(e))}}function Id(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ed,Cd,xd={exports:{}};function Bd(){if(Cd)return Ed;Cd=1;var e=1e3,t=60*e,n=60*t,r=24*n,i=7*r,o=365.25*r;function s(e,t,n,r){var i=t>=1.5*n;return Math.round(e/n)+" "+r+(i?"s":"")}return Ed=function(a,l){l=l||{};var c=typeof a;if("string"===c&&a.length>0)return function(s){if((s=String(s)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(s);if(!a)return;var l=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return l*o;case"weeks":case"week":case"w":return l*i;case"days":case"day":case"d":return l*r;case"hours":case"hour":case"hrs":case"hr":case"h":return l*n;case"minutes":case"minute":case"mins":case"min":case"m":return l*t;case"seconds":case"second":case"secs":case"sec":case"s":return l*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return l;default:return}}(a);if("number"===c&&isFinite(a))return l.long?function(i){var o=Math.abs(i);if(o>=r)return s(i,o,r,"day");if(o>=n)return s(i,o,n,"hour");if(o>=t)return s(i,o,t,"minute");if(o>=e)return s(i,o,e,"second");return i+" ms"}(a):function(i){var o=Math.abs(i);if(o>=r)return Math.round(i/r)+"d";if(o>=n)return Math.round(i/n)+"h";if(o>=t)return Math.round(i/t)+"m";if(o>=e)return Math.round(i/e)+"s";return i+"ms"}(a);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a))}}var Sd=function(e){function t(e){let r,i,o,s=null;function a(...e){if(!a.enabled)return;const n=a,i=Number(new Date),o=i-(r||i);n.diff=o,n.prev=r,n.curr=i,r=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,i)=>{if("%%"===r)return"%";s++;const o=t.formatters[i];if("function"==typeof o){const t=e[s];r=o.call(n,t),e.splice(s,1),s--}return r}),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(i!==t.namespaces&&(i=t.namespaces,o=t.enabled(e)),o),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(e,t){let n=0,r=0,i=-1,o=0;for(;n"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const e of n)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const n of t.skips)if(r(e,n))return!1;for(const n of t.names)if(r(e,n))return!0;return!1},t.humanize=Bd(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(n=>{t[n]=e[n]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t{"%%"!==e&&(r++,"%c"===e&&(i=r))}),t.splice(i,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=Sd(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(xd,xd.exports);const Fd=Id(xd.exports)("applesauce");class Qd{log=Fd.extend("EventMemory");kinds=new Map;authors=new Map;tags=new kd;created_at=[];kindAuthor=new Map;events=new kd;replaceable=new Map;get size(){return this.events.size}hasEvent(e){return this.events.has(e)}getEvent(e){return this.events.get(e)}hasReplaceable(e,t,n){const r=this.replaceable.get(hu(e,t,n));return!!r&&r.length>0}getReplaceable(e,t,n){const r=hu(e,t,n),i=this.replaceable.get(r);return i?.[0]}getReplaceableHistory(e,t,n){const r=hu(e,t,n);return this.replaceable.get(r)}getByFilters(e){return Array.from(this.getEventsForFilters(Array.isArray(e)?e:[e]))}getTimeline(e){const t=[],n=this.getByFilters(e);for(const e of n)ru(t,e);return t}add(e){const t=e.id,n=this.events.get(t);if(n)return n;this.events.set(t,e),this.getKindIndex(e.kind).add(e),this.getAuthorsIndex(e.pubkey).add(e),this.getKindAuthorIndex(e.kind,e.pubkey).add(e);for(const t of bd(e))this.tags.has(t)&&this.getTagIndex(t).add(e);if(ru(this.created_at,e),uu(e.kind)){const t=e.tags.find(e=>"d"===e[0])?.[1],n=hu(e.kind,e.pubkey,t);let r=this.replaceable.get(n);this.replaceable.has(n)||(r=[],this.replaceable.set(n,r)),ru(r,e)}return e}remove(e){let t="string"==typeof e?this.events.get(e):e;if(!t)return!1;const n=t.id;if(!this.events.has(n))return!1;this.getAuthorsIndex(t.pubkey).delete(t),this.getKindIndex(t.kind).delete(t);const r=`${t.kind}:${t.pubkey}`;this.kindAuthor.has(r)&&this.kindAuthor.get(r).delete(t);for(const e of bd(t))this.tags.has(e)&&this.getTagIndex(e).delete(t);if(this.removeFromSortedArray(this.created_at,t),this.events.delete(n),uu(t.kind)){const e=t.tags.find(e=>"d"===e[0])?.[1],n=hu(t.kind,t.pubkey,e),r=this.replaceable.get(n);r&&this.removeFromSortedArray(r,t)}return this.claims.delete(t),!0}removeByFilters(e){const t=this.getByFilters(e);let n=0;for(const e of t)this.remove(e)&&n++;return n}update(e){}claims=new WeakMap;touch(e){this.events.has(e.id)&&this.events.set(e.id,e)}claim(e){const t=this.claims.get(e)||0;this.claims.set(e,t+1),this.touch(e)}isClaimed(e){const t=this.claims.get(e);return void 0!==t&&t>0}removeClaim(e){const t=this.claims.get(e);if(void 0!==t&&t>0){const n=t-1;0===n?this.claims.delete(e):this.claims.set(e,n)}}clearClaim(e){this.claims.delete(e)}*unclaimed(){let e=this.events.first;for(;e;){const t=e.value;this.isClaimed(t)||(yield t),e=e.next}return 0}prune(e){let t=0;const n=this.unclaimed();for(const r of n)if(this.remove(r),t++,e&&t>=e)break;return t}getKindIndex(e){return this.kinds.has(e)||this.kinds.set(e,new Set),this.kinds.get(e)}getAuthorsIndex(e){return this.authors.has(e)||this.authors.set(e,new Set),this.authors.get(e)}getKindAuthorIndex(e,t){const n=`${e}:${t}`;return this.kindAuthor.has(n)||this.kindAuthor.set(n,new Set),this.kindAuthor.get(n)}getTagIndex(e){if(!this.tags.has(e)){const t=new Set,n=Date.now();for(const n of this.events.values())bd(n).has(e)&&t.add(n);const r=Date.now()-n;r>100&&this.log(`Built index ${e} took ${r}ms`),this.tags.set(e,t)}return this.tags.get(e)}removeFromSortedArray(e,t){if(0===e.length)return;const n=iu(e,e=>e.created_at-t.created_at);if(n){let r=n[0],i=!1;if(e[r]===t)return void e.splice(r,1);for(let n=r-1;n>=0&&e[n].created_at===t.created_at;n--)if(e[n]===t){e.splice(n,1),i=!0;break}if(i)return;for(let n=r+1;ne.created_at-t):void 0;i&&(n=i[0]);const o=e?iu(this.created_at,t=>t.created_at-e):void 0;o&&(r=o[0]);for(let i=n;i<=r;i++){const n=this.created_at[i];if(!(void 0!==t&&n.created_at>t)){if(void 0!==e&&n.created_at{const r=e instanceof Set?e:new Set(e);if(t)n=r,t=!1;else for(const e of n)r.has(e)||n.delete(e);return n};e.ids&&r(this.iterateIds(e.ids));let i=null;void 0!==e.since&&(i=Array.from(this.iterateTime(e.since,e.until)),r(i));for(const t of vd){const n=e[`&${t}`];if(n?.length)for(const e of n)r(this.iterateTag(t,[e]))}for(const t of vd){const n=e[`#${t}`];if(n?.length){const i=e[`&${t}`],o=i?n.filter(e=>!i.includes(e)):n;o.length>0&&r(this.iterateTag(t,o))}}if(e.authors&&e.kinds&&e.authors.length*e.kinds.length<=20){const t=new Set;for(const n of e.kinds)for(const r of e.authors){const e=`${n}:${r}`,i=this.kindAuthor.get(e);if(i)for(const e of i)t.add(e)}r(t)}else e.authors&&r(this.iterateAuthors(e.authors)),e.kinds&&r(this.iterateKinds(e.kinds));if(void 0===e.since&&void 0!==e.until&&(i=Array.from(this.iterateTime(e.since,e.until)),r(i)),t)return new Set(this.events.values());if(e.limit&&i){const t=new Set;for(const r of i){if(t.size>=e.limit)break;n.has(r)&&t.add(r)}return t}return n}getEventsForFilters(e){if(0===e.length)return new Set;let t=new Set;for(const n of e){const e=this.getEventsForFilter(n);for(const n of e)t.add(n)}return t}reset(){this.events.clear(),this.kinds.clear(),this.authors.clear(),this.kindAuthor.clear(),this.tags.clear(),this.created_at=[],this.replaceable.clear(),this.claims=new WeakMap}}function Dd(e,t){var n,r;if(0===t.length)return e;for(n=0,r=t.length;ne.until)return!1;for(let n in e)if("&"===n[0]){let r=n.slice(1),i=e[n];if(i&&i.length>0){const e=bd(t);for(const t of i)if(!e.has(r+":"+t))return!1}}for(let n in e)if("#"===n[0]){let r=n.slice(1),i=e[n];if(i){const n=e[`&${r}`],o=n?i.filter(e=>!n.includes(e)):i;if(0===o.length)continue;const s=bd(t);if(!1===o.some(e=>s.has(r+":"+e)))return!1}}return!0}function Td(e,t){for(let n=0;nt.replaceable({kind:10063,pubkey:e.pubkey,relays:e.relays}).pipe(pc(e=>e?function(e){const t=Array.isArray(e)?e:e.tags;return Vc(t,e=>Hc(e,"server")&&URL.canParse(e[1])?new URL("/",e[1]):void 0)}(e):[]))}const Ld=Symbol.for("profile-content");function Od(e){return nu(e,Ld,()=>{const t=function(e){try{return JSON.parse(e)}catch(e){return}}(e.content);if(t)return t.nip05&&"string"!=typeof t.nip05&&(t.nip05=String(t.nip05)),t.website&&t.website?.length>0&&!1===t.website?.startsWith("http")&&(t.website="https://"+t.website),t})}function Md(e){return!!e&&((e.kind===gi.Metadata||e.kind===gi.Handlerinformation)&&!!Od(e))}!function(e){function t(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function n(...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 r(e){return{encode:n=>{if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("alphabet.encode input should be an array of numbers");return n.map(n=>{if(t(n),n<0||n>=e.length)throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${e.length})`);return e[n]})},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 i(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 o(e,n="="){if(t(e),"string"!=typeof n)throw new Error("padding chr should be string");return{encode(t){if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("padding.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`padding.encode: non-string input=${e}`);for(;t.length*e%8;)t.push(n);return t},decode(t){if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("padding.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`padding.decode: non-string input=${e}`);let r=t.length;if(r*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&t[r-1]===n;r--)if(!((r-1)*e%8))throw new Error("Invalid padding: string has too much padding");return t.slice(0,r)}}}function s(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function a(e,n,r){if(n<2)throw new Error(`convertRadix: wrong from=${n}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: wrong to=${r}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let i=0;const o=[],s=Array.from(e);for(s.forEach(e=>{if(t(e),e<0||e>=n)throw new Error(`Wrong integer: ${e}`)});;){let e=0,t=!0;for(let o=i;o(e+t/Qt)/t;function Rt(e){const t=Bt,n=BigInt(3),r=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),l=BigInt(88),c=e*e*e%t,u=c*c*e%t,d=st(u,n,t)*u%t,f=st(d,n,t)*u%t,h=st(f,Qt,t)*c%t,p=st(h,i,t)*h%t,g=st(p,o,t)*p%t,m=st(g,a,t)*g%t,y=st(m,l,t)*m%t,w=st(y,a,t)*g%t,v=st(w,n,t)*u%t,A=st(v,s,t)*p%t,b=st(A,r,t)*c%t,k=st(b,Qt,t);if(!$t.eql($t.sqr(k),e))throw new Error("Cannot find square root");return k}const $t=function(e,t,n=!1,r={}){if(e<=We)throw new Error(`Expected Field ORDER > 0, got ${e}`);const{nBitLength:i,nByteLength:o}=ut(e,t);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=lt(e),a=Object.freeze({ORDER:e,BITS:i,BYTES:o,MASK:Ge(i),ZERO:We,ONE:Ze,create:t=>it(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return We<=t&&te===We,isOdd:e=>(e&Ze)===Ze,neg:t=>it(-t,e),eql:(e,t)=>e===t,sqr:t=>it(t*t,e),add:(t,n)=>it(t+n,e),sub:(t,n)=>it(t-n,e),mul:(t,n)=>it(t*n,e),pow:(e,t)=>function(e,t,n){if(n 0");if(n===We)return e.ONE;if(n===Ze)return t;let r=e.ONE,i=t;for(;n>We;)n&Ze&&(r=e.mul(r,i)),i=e.sqr(i),n>>=Ze;return r}(a,e,t),div:(t,n)=>it(t*at(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>at(t,e),sqrt:r.sqrt||(e=>s(a,e)),invertBatch:e=>function(e,t){const n=new Array(t.length),r=t.reduce((t,r,i)=>e.is0(r)?t:(n[i]=t,e.mul(t,r)),e.ONE),i=e.inv(r);return t.reduceRight((t,r,i)=>e.is0(r)?t:(n[i]=e.mul(t,n[i]),e.mul(t,r)),i),n}(a,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?_e(e,o):Me(e,o),fromBytes:e=>{if(e.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${e.length}`);return n?Oe(e):Le(e)}});return Object.freeze(a)}(Bt,void 0,void 0,{sqrt:Rt}),Pt=function(e,t){const n=t=>It({...e,...xt(t)});return Object.freeze({...n(t),create:n})}({a:BigInt(0),b:BigInt(7),Fp:$t,n:St,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=St,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Ft*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=n,s=BigInt("0x100000000000000000000000000000000"),a=Dt(o*e,t),l=Dt(-r*e,t);let c=it(e-a*n-l*i,t),u=it(-a*r-l*o,t);const d=c>s,f=u>s;if(d&&(c=t-c),f&&(u=t-u),c>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:d,k1:c,k2neg:f,k2:u}}}},Se),Ut=BigInt(0),Tt=e=>"bigint"==typeof e&&Ute.charCodeAt(0)));n=je(t,t),Nt[e]=n}return Se(je(n,...t))}const Ot=e=>e.toRawBytes(!0).slice(1),Mt=e=>Me(e,32),_t=e=>it(e,Bt),Ht=e=>it(e,St),jt=Pt.ProjectivePoint;function Gt(e){let t=Pt.utils.normPrivateKeyToScalar(e),n=jt.fromPrivateKey(t);return{scalar:n.hasEvenY()?t:Ht(-t),bytes:Ot(n)}}function qt(e){if(!Tt(e))throw new Error("bad x: need 0 < x < p");const t=_t(e*e);let n=Rt(_t(t*e+BigInt(7)));n%Qt!==Ut&&(n=_t(-n));const r=new jt(e,n,Ft);return r.assertValidity(),r}function Kt(...e){return Ht(Le(Lt("BIP0340/challenge",...e)))}function Jt(e){return Gt(e).bytes}function Vt(e,t,n=Ae(32)){const r=He("message",e),{bytes:i,scalar:o}=Gt(t),s=He("auxRand",n,32),a=Mt(o^Le(Lt("BIP0340/aux",s))),l=Lt("BIP0340/nonce",a,i,r),c=Ht(Le(l));if(c===Ut)throw new Error("sign failed: k is zero");const{bytes:u,scalar:d}=Gt(c),f=Kt(u,i,r),h=new Uint8Array(64);if(h.set(u,0),h.set(Mt(Ht(d+f*o)),32),!Yt(h,r,i))throw new Error("sign: Invalid signature produced");return h}function Yt(e,t,n){const r=He("signature",e,64),i=He("message",t),o=He("publicKey",n,32);try{const e=qt(Le(o)),t=Le(r.subarray(0,32));if(!Tt(t))return!1;const n=Le(r.subarray(32,64));if(!("bigint"==typeof(c=n)&&Ut({getPublicKey:Jt,sign:Vt,verify:Yt,utils:{randomPrivateKey:Pt.utils.randomPrivateKey,lift_x:qt,pointToBytes:Ot,numberToBytesBE:Me,bytesToNumberBE:Le,taggedHash:Lt,mod:it}}))(),Wt="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,Zt=e=>e instanceof Uint8Array,Xt=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),en=(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 tn=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function nn(e){if(!Zt(e))throw new Error("Uint8Array expected");let t="";for(let n=0;ne+t.length,0));let n=0;return e.forEach(e=>{if(!Zt(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}let an=class{clone(){return this._cloneInto()}};function ln(e){const t=t=>e().update(on(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function cn(e=32){if(Wt&&"function"==typeof Wt.getRandomValues)return Wt.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}function un(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function dn(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 fn={number:un,bool:function(e){if("boolean"!=typeof e)throw new Error(`Expected boolean, not ${e}`)},bytes:dn,hash:function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");un(e.outputLen),un(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){dn(e);const n=t.outputLen;if(e.lengthr-o&&(this.process(n,0),o=0);for(let e=o;e>i&o),a=Number(n&o),l=r?4:0,c=r?0:4;e.setUint32(t+l,s,r),e.setUint32(t+c,a,r)}(n,r-8,BigInt(8*this.length),i),this.process(n,0);const s=Xt(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;ee&t^~e&n,gn=(e,t,n)=>e&t^e&n^t&n,mn=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]),yn=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),wn=new Uint32Array(64);let vn=class extends hn{constructor(){super(64,32,8,!1),this.A=0|yn[0],this.B=0|yn[1],this.C=0|yn[2],this.D=0|yn[3],this.E=0|yn[4],this.F=0|yn[5],this.G=0|yn[6],this.H=0|yn[7]}get(){const{A:e,B:t,C:n,D:r,E:i,F:o,G:s,H:a}=this;return[e,t,n,r,i,o,s,a]}set(e,t,n,r,i,o,s,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)wn[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=wn[e-15],n=wn[e-2],r=en(t,7)^en(t,18)^t>>>3,i=en(n,17)^en(n,19)^n>>>10;wn[e]=i+wn[e-7]+r+wn[e-16]|0}let{A:n,B:r,C:i,D:o,E:s,F:a,G:l,H:c}=this;for(let e=0;e<64;e++){const t=c+(en(s,6)^en(s,11)^en(s,25))+pn(s,a,l)+mn[e]+wn[e]|0,u=(en(n,2)^en(n,13)^en(n,22))+gn(n,r,i)|0;c=l,l=a,a=s,s=o+t|0,o=i,i=r,r=n,n=t+u|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(n,r,i,o,s,a,l,c)}roundClean(){wn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};class An extends vn{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 bn=ln(()=>new vn);ln(()=>new An);var kn=Symbol("verified");function In(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;te===n.slice(1)&&-1!==r.indexOf(t)))return!1}return!(e.since&&t.created_ate.until)}async function Rn(){return new Promise(e=>{const t=new MessageChannel,n=()=>{t.port1.removeEventListener("message",n),e()};t.port1.addEventListener("message",n),t.port2.postMessage(0),t.port1.start()})}var $n,Pn=e=>(e[kn]=!0,!0),Un=class extends Error{constructor(e,t){super(`Tried to send message '${e} on a closed connection to ${t}.`),this.name="SendingOnClosedConnection"}},Tn=class{url;_connected=!1;onclose=null;onnotice=e=>console.debug(`NOTICE from ${this.url}: ${e}`);baseEoseTimeout=4400;connectionTimeout=4400;publishTimeout=4400;pingFrequency=2e4;pingTimeout=2e4;openSubs=new Map;enablePing;connectionTimeoutHandle;connectionPromise;openCountRequests=new Map;openEventPublishes=new Map;ws;incomingMessageQueue=new Bn;queueRunning=!1;challenge;authPromise;serial=0;verifyEvent;_WebSocket;constructor(e,t){this.url=Cn(e),this.verifyEvent=t.verifyEvent,this._WebSocket=t.websocketImplementation||WebSocket,this.enablePing=t.enablePing}static async connect(e,t){const n=new Tn(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 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=()=>{clearTimeout(this.connectionTimeoutHandle),this._connected=!0,this.enablePing&&this.pingpong(),e()},this.ws.onerror=e=>{clearTimeout(this.connectionTimeoutHandle),t(e.message||"websocket error"),this._connected=!1,this.connectionPromise=void 0,this.onclose?.(),this.closeAllSubscriptions("relay connection errored")},this.ws.onclose=e=>{clearTimeout(this.connectionTimeoutHandle),t(e.message||"websocket closed"),this._connected=!1,this.connectionPromise=void 0,this.onclose?.(),this.closeAllSubscriptions("relay connection closed")},this.ws.onmessage=this._onmessage.bind(this)})),this.connectionPromise}async waitForPingPong(){return new Promise((e,t)=>{this.ws&&this.ws.on&&this.ws.on("pong",()=>e(!0))||t("ws can't listen for pong"),this.ws&&this.ws.ping&&this.ws.ping()})}async waitForDummyReq(){return new Promise((e,t)=>{const n=this.subscribe([{ids:["a".repeat(64)]}],{oneose:()=>{n.close(),e(!0)},eoseTimeout:this.pingTimeout+1e3})})}async pingpong(){if(1===this.ws?.readyState){await Promise.any([this.ws&&this.ws.ping&&this.ws.on?this.waitForPingPong():this.waitForDummyReq(),new Promise(e=>setTimeout(()=>e(!1),this.pingTimeout))])?setTimeout(()=>this.pingpong(),this.pingFrequency):(this.closeAllSubscriptions("pingpong timed out"),this._connected=!1,this.onclose?.(),this.ws?.close())}}async runQueue(){for(this.queueRunning=!0;!1!==this.handleNext();)await Rn();this.queueRunning=!1}handleNext(){const e=this.incomingMessageQueue.dequeue();if(!e)return!1;const t=function(e){let t=e.slice(0,22).indexOf('"EVENT"');if(-1===t)return null;let n=e.slice(t+7+1).indexOf('"');if(-1===n)return null;let r=t+7+1+n,i=e.slice(r+1,80).indexOf('"');if(-1===i)return null;let o=r+1+i;return e.slice(r+1,o)}(e);if(t){const n=this.openSubs.get(t);if(!n)return;const r=function(e,t){let n=t.length+3,r=e.indexOf(`"${t}":`)+n,i=e.slice(r).indexOf('"')+r+1;return e.slice(i,i+64)}(e,"id"),i=n.alreadyHaveEvent?.(r);if(n.receivedEvent?.(this,r),i)return}try{let t=JSON.parse(e);switch(t[0]){case"EVENT":{const e=this.openSubs.get(t[1]),n=t[2];return void(this.verifyEvent(n)&&function(e,t){for(let n=0;n{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 i=await e(function(e,t){return{kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",e],["challenge",t]],content:""}}(this.url,t)),o=setTimeout(()=>{let e=this.openEventPublishes.get(i.id);e&&(e.reject(new Error("auth timed out")),this.openEventPublishes.delete(i.id))},this.publishTimeout);this.openEventPublishes.set(i.id,{resolve:n,reject:r,timeout:o}),this.send('["AUTH",'+JSON.stringify(i)+"]")}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 Nn(this,n,e,t);return this.openSubs.set(n,r),r}close(){this.closeAllSubscriptions("relay connection closed by us"),this._connected=!1,this.onclose?.(),this.ws?.close()}_onmessage(e){this.incomingMessageQueue.enqueue(e.data),this.queueRunning||this.runQueue()}},Nn=class{relay;id;closed=!1;eosed=!1;filters;alreadyHaveEvent;receivedEvent;onevent;oneose;onclose;eoseTimeout;eoseTimeoutHandle;constructor(e,t,n,r){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 Un))throw e}this.closed=!0}this.relay.openSubs.delete(this.id),this.onclose?.(e)}},Ln=class{relays=new Map;seenOn=new Map;trackRelays=!1;verifyEvent;enablePing;trustedRelayURLs=new Set;_WebSocket;constructor(e){this.verifyEvent=e.verifyEvent,this._WebSocket=e.websocketImplementation,this.enablePing=e.enablePing}async ensureRelay(e,t){e=Cn(e);let n=this.relays.get(e);return n||(n=new Tn(e,{verifyEvent:this.trustedRelayURLs.has(e)?Pn:this.verifyEvent,websocketImplementation:this._WebSocket,enablePing:this.enablePing}),n.onclose=()=>{this.relays.delete(e)},t?.connectionTimeout&&(n.connectionTimeout=t.connectionTimeout),this.relays.set(e,n)),await n.connect(),n}close(e){e.map(Cn).forEach(e=>{this.relays.get(e)?.close(),this.relays.delete(e)})}subscribe(e,t,n){n.onauth=n.onauth||n.doauth;const r=[];for(let n=0;ne.url===i)||r.push({url:i,filter:t})}return this.subscribeMap(r,n)}subscribeMany(e,t,n){n.onauth=n.onauth||n.doauth;const r=[],i=[];for(let n=0;n({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 i=new Set,o=[],s=[];let a=n=>{s[n]||(s[n]=!0,s.filter(e=>e).length===e.length&&(t.oneose?.(),a=()=>{}))};const l=[];let c=(n,r)=>{l[n]||(a(n),l[n]=r,l.filter(e=>e).length===e.length&&(t.onclose?.(l),c=()=>{}))};const u=e=>{if(t.alreadyHaveEvent?.(e))return!0;const n=i.has(e);return i.add(e),n},d=Promise.all(r.map(async({url:e,filters:n},r)=>{let i;try{i=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 s=i.subscribe(n,{...t,oneose:()=>a(r),onclose:e=>{e.startsWith("auth-required: ")&&t.onauth?i.auth(t.onauth).then(()=>{i.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(s)}));return{async close(e){await d,o.forEach(t=>{t.close(e)})}}}subscribeEose(e,t,n){n.onauth=n.onauth||n.doauth;const r=this.subscribe(e,t,{...n,oneose(){r.close("closed automatically on eose")}});return r}subscribeManyEose(e,t,n){n.onauth=n.onauth||n.doauth;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 i=[];this.subscribeEose(e,t,{...n,onevent(e){i.push(e)},onclose(e){r(i)}})})}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(Cn).map(async(e,r,i)=>{if(i.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{$n=WebSocket}catch{}var On=class extends Ln{constructor(e){super({verifyEvent:Qn,websocketImplementation:$n,...e})}}; +/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Mn(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function _n(...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 Hn(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(Mn(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 jn(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 Gn(e,t="="){if(Mn(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 qn(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function Kn(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 i=[],o=Array.from(e);for(o.forEach(e=>{if(Mn(e),e<0||e>=t)throw new Error(`Wrong integer: ${e}`)});;){let e=0,s=!0;for(let i=r;it?Jn(t,e%t):e,Vn=(e,t)=>e+(t-Jn(e,t));function Yn(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(Vn(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${Vn(t,n)}`);let i=0,o=0;const s=2**n-1,a=[];for(const r of e){if(Mn(r),r>=2**t)throw new Error(`convertRadix2: invalid data word=${r} from=${t}`);if(i=i<32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${t}`);for(o+=t;o>=n;o-=n)a.push((i>>o-n&s)>>>0);i&=2**o-1}if(i=i<=t)throw new Error("Excess padding");if(!r&&i)throw new Error(`Non-zero padding: ${i}`);return r&&o>0&&a.push(i>>>0),a}function zn(e,t=!1){if(Mn(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(Vn(8,e)>32||Vn(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 Yn(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(Yn(n,e,8,t))}}}function Wn(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 Zn=_n(zn(4),Hn("0123456789ABCDEF"),jn("")),Xn=_n(zn(5),Hn("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Gn(5),jn(""));_n(zn(5),Hn("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Gn(5),jn("")),_n(zn(5),Hn("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),jn(""),qn(e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));const er=_n(zn(6),Hn("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Gn(6),jn("")),tr=_n(zn(6),Hn("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Gn(6),jn("")),nr=e=>{return _n((Mn(t=58),{encode:e=>{if(!(e instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return Kn(Array.from(e),256,t)},decode:e=>{if(!Array.isArray(e)||e.length&&"number"!=typeof e[0])throw new Error("radix.decode input should be array of strings");return Uint8Array.from(Kn(e,t,256))}}),Hn(e),jn(""));var t},rr=nr("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");nr("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),nr("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const ir=[0,2,3,5,6,7,9,10,11],or={encode(e){let t="";for(let n=0;n>25;let n=(33554431&e)<<5;for(let e=0;e>e&1)&&(n^=ar[e]);return n}function cr(e,t,n=1){const r=e.length;let i=1;for(let t=0;t126)throw new Error(`Invalid prefix (${e})`);i=lr(i)^n>>5}i=lr(i);for(let t=0;tn)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);const r=e.toLowerCase();if(e!==r&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const i=(e=r).lastIndexOf("1");if(0===i||-1===i)throw new Error('Letter "1" must be present between prefix and data only');const o=e.slice(0,i),s=e.slice(i+1);if(s.length<6)throw new Error("Data must be at least 6 characters long");const a=sr.decode(s).slice(0,-6),l=cr(o,a,t);if(!s.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 i=e.length+7+n.length;if(!1!==r&&i>r)throw new TypeError(`Length ${i} exceeds limit ${r}`);return`${e=e.toLowerCase()}1${sr.encode(n)}${cr(e,n,t)}`},decode:s,decodeToBytes:function(e){const{prefix:t,words:n}=s(e,!1);return{prefix:t,words:n,bytes:r(n)}},decodeUnsafe:Wn(s),fromWords:r,fromWordsUnsafe:o,toWords:i}}const dr=ur("bech32");ur("bech32m");const fr={utf8:{encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)},hex:_n(zn(4),Hn("0123456789abcdef"),jn(""),qn(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()})),base16:Zn,base32:Xn,base64:er,base64url:tr,base58:rr,base58xmr:or};function hr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function pr(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}function gr(e,...t){if(!((n=e)instanceof Uint8Array||null!=n&&"object"==typeof n&&"Uint8Array"===n.constructor.name))throw new Error("Uint8Array expected");var n;if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)} +/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */Object.keys(fr).join(", ");const mr=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");const yr=16;function wr(e){return e<<1^283&-(e>>7)}function vr(e,t){let n=0;for(;t>0;t>>=1)n^=e&-(1&t),e=wr(e);return n}const Ar=(()=>{let e=new Uint8Array(256);for(let t=0,n=1;t<256;t++,n^=wr(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})(),br=Ar.map((e,t)=>Ar.indexOf(t)),kr=e=>e<<24|e>>>8,Ir=e=>e<<8|e>>>24;function Er(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(Ir),i=r.map(Ir),o=i.map(Ir),s=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;s[u]=n[t]^r[c],a[u]=i[t]^o[c],l[u]=e[t]<<8|e[c]}return{sbox:e,sbox2:l,T0:n,T1:r,T2:i,T3:o,T01:s,T23:a}}const Cr=Er(Ar,e=>vr(e,3)<<24|e<<16|e<<8|vr(e,2)),xr=Er(br,e=>vr(e,11)<<24|vr(e,13)<<16|vr(e,9)<<8|vr(e,14)),Br=(()=>{const e=new Uint8Array(16);for(let t=0,n=1;t<16;t++,n=wr(n))e[t]=n;return e})();function Sr(e){gr(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}=Cr,r=mr(e),i=r.length,o=e=>Qr(n,e,e,e,e),s=new Uint32Array(t+28);s.set(r);for(let e=i;e6&&e%i===4&&(t=o(t)),s[e]=s[e-i]^t}return s}function Fr(e,t,n,r,i,o){return e[n<<8&65280|r>>>8&255]^t[i>>>8&65280|o>>>24&255]}function Qr(e,t,n,r,i){return e[255&t|65280&n]|e[r>>>16&255|i>>>16&65280]<<16}function Dr(e,t,n,r,i){const{sbox2:o,T01:s,T23:a}=Cr;let l=0;t^=e[l++],n^=e[l++],r^=e[l++],i^=e[l++];const c=e.length/4-2;for(let o=0;o{const o=Sr(e),{b:s,o:a,out:l}=function(e,t,n){let r=e.length;const i=r%yr;if(!t&&0!==i)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");const o=mr(e);if(t){let e=yr-i;e||(e=yr),r+=e}const s=$r(r,n);return{b:o,o:mr(s),out:s}}(n,r,i),c=mr(t);let u=c[0],d=c[1],f=c[2],h=c[3],p=0;for(;p+4<=s.length;)u^=s[p+0],d^=s[p+1],f^=s[p+2],h^=s[p+3],({s0:u,s1:d,s2:f,s3:h}=Dr(o,u,d,f,h)),a[p++]=u,a[p++]=d,a[p++]=f,a[p++]=h;if(r){const e=function(e){const t=new Uint8Array(16),n=mr(t);t.set(e);const r=yr-e.length;for(let e=yr-r;e{!function(e){if(gr(e),e.length%yr!==0)throw new Error("aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size 16")}(n);const o=function(e){const t=Sr(e),n=t.slice(),r=t.length,{sbox2:i}=Cr,{T0:o,T1:s,T2:a,T3:l}=xr;for(let e=0;e>>8&255]^a[r>>>16&255]^l[r>>>24]}return n}(e),s=mr(t),a=$r(n.length,i),l=mr(n),c=mr(a);let u=s[0],d=s[1],f=s[2],h=s[3];for(let e=0;e+4<=l.length;){const t=u,n=d,r=f,i=h;u=l[e+0],d=l[e+1],f=l[e+2],h=l[e+3];const{s0:s,s1:a,s2:p,s3:g}=Rr(o,u,d,f,h);c[e++]=s^t,c[e++]=a^n,c[e++]=p^r,c[e++]=g^i}return o.fill(0),function(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 i=e.subarray(0,-r);for(let t=0;tUint8Array.from(e.split("").map(e=>e.charCodeAt(0))),Lr=Nr("expand 16-byte k"),Or=Nr("expand 32-byte k"),Mr=mr(Lr),_r=mr(Or);function Hr(e,t){return e<>>32-t}function jr(e){return e.byteOffset%4==0}_r.slice();const Gr=2**32-1,qr=new Uint32Array;function Kr(e,t){const{allowShortKeys:n,extendNonceFn:r,counterLength:i,counterRight:o,rounds:s}=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 hr(i),hr(s),pr(o),pr(n),(t,a,l,c,u=0)=>{gr(t),gr(a),gr(l);const d=l.length;if(c||(c=new Uint8Array(d)),gr(c),hr(u),u<0||u>=Gr)throw new Error("arx: counter overflow");if(c.length=Gr)throw new Error("arx: counter overflow");const g=Math.min(64,l-p);if(d&&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,h[t]=f[t]^u[n];p+=64;continue}for(let e,t=0;t0;)f.pop().fill(0);return c}}function Jr(e,t,n,r,i,o=20){let s=e[0],a=e[1],l=e[2],c=e[3],u=t[0],d=t[1],f=t[2],h=t[3],p=t[4],g=t[5],m=t[6],y=t[7],w=i,v=n[0],A=n[1],b=n[2],k=s,I=a,E=l,C=c,x=u,B=d,S=f,F=h,Q=p,D=g,R=m,$=y,P=w,U=v,T=A,N=b;for(let e=0;er?e.create().update(n).digest():n);for(let e=0;enew Yr(e,t).update(n).digest();zr.create=(e,t)=>new Yr(e,t);const Wr=new Uint8Array([0]),Zr=new Uint8Array;var Xr=Object.defineProperty,ei=(e,t)=>{for(var n in t)Xr(e,n,{get:t[n],enumerable:!0})},ti=Symbol("verified");function ni(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;tui,QueueNode:()=>ci,binarySearch:()=>li,bytesToHex:()=>nn,hexToBytes:()=>rn,insertEventIntoAscendingList:()=>ai,insertEventIntoDescendingList:()=>si,normalizeURL:()=>oi,utf8Decoder:()=>ri,utf8Encoder:()=>ii});var ri=new TextDecoder("utf-8"),ii=new TextEncoder;function oi(e){try{-1===e.indexOf("://")&&(e="wss://"+e);let t=new URL(e);return t.pathname=t.pathname.replace(/\/+/g,"/"),t.pathname.endsWith("/")&&(t.pathname=t.pathname.slice(0,-1)),("80"===t.port&&"ws:"===t.protocol||"443"===t.port&&"wss:"===t.protocol)&&(t.port=""),t.searchParams.sort(),t.hash="",t.toString()}catch(t){throw new Error(`Invalid URL: ${e}`)}}function si(e,t){const[n,r]=li(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 ai(e,t){const[n,r]=li(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 li(e,t){let n=0,r=e.length-1;for(;n<=r;){const i=Math.floor((n+r)/2),o=t(e[i]);if(0===o)return[i,!0];o<0?r=i-1:n=i+1}return[n,!1]}var ci=class{value;next=null;prev=null;constructor(e){this.value=e}},ui=class{first;last;constructor(){this.first=null,this.last=null}enqueue(e){const t=new ci(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 di(e){return nn(bn(ii.encode(function(e){if(!ni(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 fi=new class{generateSecretKey(){return zt.utils.randomPrivateKey()}getPublicKey(e){return nn(zt.getPublicKey(e))}finalizeEvent(e,t){const n=e;return n.pubkey=nn(zt.getPublicKey(t)),n.id=di(n),n.sig=nn(zt.sign(di(n),t)),n[ti]=!0,n}verifyEvent(e){if("boolean"==typeof e[ti])return e[ti];const t=di(e);if(t!==e.id)return e[ti]=!1,!1;try{const n=zt.verify(e.sig,t,e.pubkey);return e[ti]=n,n}catch(t){return e[ti]=!1,!1}}},hi=fi.generateSecretKey,pi=fi.getPublicKey,gi=fi.finalizeEvent,mi=fi.verifyEvent,yi={};function wi(e){return 1e3<=e&&e<1e4||[1,2,4,5,6,7,8,16,40,41,42,43,44].includes(e)}function vi(e){return[0,3].includes(e)||1e4<=e&&e<2e4}function Ai(e){return 2e4<=e&&e<3e4}function bi(e){return 3e4<=e&&e<4e4}function ki(e){return wi(e)?"regular":vi(e)?"replaceable":Ai(e)?"ephemeral":bi(e)?"parameterized":"unknown"}function Ii(e,t){const n=t instanceof Array?t:[t];return ni(e)&&n.includes(e.kind)||!1}ei(yi,{Application:()=>To,BadgeAward:()=>Ri,BadgeDefinition:()=>Fo,BlockedRelaysList:()=>co,BookmarkList:()=>so,Bookmarksets:()=>xo,Calendar:()=>jo,CalendarEventRSVP:()=>Go,ChannelCreation:()=>Ti,ChannelHideMessage:()=>Oi,ChannelMessage:()=>Li,ChannelMetadata:()=>Ni,ChannelMuteUser:()=>Mi,ClassifiedListing:()=>Oo,ClientAuth:()=>wo,CommunitiesList:()=>ao,CommunityDefinition:()=>Jo,CommunityPostApproval:()=>Yi,Contacts:()=>Bi,CreateOrUpdateProduct:()=>Ro,CreateOrUpdateStall:()=>Do,Curationsets:()=>Bo,Date:()=>_o,DirectMessageRelaysList:()=>po,DraftClassifiedListing:()=>Mo,DraftLong:()=>Po,Emojisets:()=>Uo,EncryptedDirectMessage:()=>Si,EventDeletion:()=>Fi,FileMetadata:()=>ji,FileServerPreference:()=>go,Followsets:()=>Io,GenericRepost:()=>Ui,Genericlists:()=>Eo,GiftWrap:()=>Hi,HTTPAuth:()=>ko,Handlerinformation:()=>Ko,Handlerrecommendation:()=>qo,Highlights:()=>no,InterestsList:()=>fo,Interestsets:()=>Qo,JobFeedback:()=>Zi,JobRequest:()=>zi,JobResult:()=>Wi,Label:()=>Vi,LightningPubRPC:()=>yo,LiveChatMessage:()=>Gi,LiveEvent:()=>No,LongFormArticle:()=>$o,Metadata:()=>Ei,Mutelist:()=>ro,NWCWalletInfo:()=>mo,NWCWalletRequest:()=>vo,NWCWalletResponse:()=>Ao,NostrConnect:()=>bo,OpenTimestamps:()=>_i,Pinlist:()=>io,PrivateDirectMessage:()=>Pi,ProblemTracker:()=>qi,ProfileBadges:()=>So,PublicChatsList:()=>lo,Reaction:()=>Di,RecommendRelay:()=>xi,RelayList:()=>oo,Relaysets:()=>Co,Report:()=>Ki,Reporting:()=>Ji,Repost:()=>Qi,Seal:()=>$i,SearchRelaysList:()=>uo,ShortTextNote:()=>Ci,Time:()=>Ho,UserEmojiList:()=>ho,UserStatuses:()=>Lo,Zap:()=>to,ZapGoal:()=>Xi,ZapRequest:()=>eo,classifyKind:()=>ki,isAddressableKind:()=>bi,isEphemeralKind:()=>Ai,isKind:()=>Ii,isRegularKind:()=>wi,isReplaceableKind:()=>vi});var Ei=0,Ci=1,xi=2,Bi=3,Si=4,Fi=5,Qi=6,Di=7,Ri=8,$i=13,Pi=14,Ui=16,Ti=40,Ni=41,Li=42,Oi=43,Mi=44,_i=1040,Hi=1059,ji=1063,Gi=1311,qi=1971,Ki=1984,Ji=1984,Vi=1985,Yi=4550,zi=5999,Wi=6999,Zi=7e3,Xi=9041,eo=9734,to=9735,no=9802,ro=1e4,io=10001,oo=10002,so=10003,ao=10004,lo=10005,co=10006,uo=10007,fo=10015,ho=10030,po=10050,go=10096,mo=13194,yo=21e3,wo=22242,vo=23194,Ao=23195,bo=24133,ko=27235,Io=3e4,Eo=30001,Co=30002,xo=30003,Bo=30004,So=30008,Fo=30009,Qo=30015,Do=30017,Ro=30018,$o=30023,Po=30024,Uo=30030,To=30078,No=30311,Lo=30315,Oo=30402,Mo=30403,_o=31922,Ho=31923,jo=31924,Go=31925,qo=31989,Ko=31990,Jo=34550;function Vo(e,t){let n=t.length+3,r=e.indexOf(`"${t}":`)+n,i=e.slice(r).indexOf('"')+r+1;return e.slice(i,i+64)}function Yo(e,t){let n=t.length,r=e.indexOf(`"${t}":`)+n+3,i=e.slice(r),o=Math.min(i.indexOf(","),i.indexOf("}"));return parseInt(i.slice(0,o),10)}function zo(e){let t=e.slice(0,22).indexOf('"EVENT"');if(-1===t)return null;let n=e.slice(t+7+1).indexOf('"');if(-1===n)return null;let r=t+7+1+n,i=e.slice(r+1,80).indexOf('"');if(-1===i)return null;let o=r+1+i;return e.slice(r+1,o)}function Wo(e,t){return t===Vo(e,"id")}function Zo(e,t){return t===Vo(e,"pubkey")}function Xo(e,t){return t===Yo(e,"kind")}ei({},{getHex64:()=>Vo,getInt:()=>Yo,getSubscriptionId:()=>zo,matchEventId:()=>Wo,matchEventKind:()=>Xo,matchEventPubkey:()=>Zo});function es(e,t){return{kind:wo,created_at:Math.floor(Date.now()/1e3),tags:[["relay",e],["challenge",t]],content:""}}ei({},{makeAuthEvent:()=>es});try{WebSocket}catch{}try{WebSocket}catch{}var ts={};ei(ts,{BECH32_REGEX:()=>is,Bech32MaxSize:()=>rs,NostrTypeGuard:()=>ns,decode:()=>ss,decodeNostrURI:()=>os,encodeBytes:()=>fs,naddrEncode:()=>gs,neventEncode:()=>ps,noteEncode:()=>us,nprofileEncode:()=>hs,npubEncode:()=>cs,nsecEncode:()=>ls});var ns={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||"")},rs=5e3,is=/[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;function os(e){try{return e.startsWith("nostr:")&&(e=e.substring(6)),ss(e)}catch(e){return{type:"invalid",data:null}}}function ss(e){let{prefix:t,words:n}=dr.decode(e,rs),r=new Uint8Array(dr.fromWords(n));switch(t){case"nprofile":{let e=as(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:nn(e[0][0]),relays:e[1]?e[1].map(e=>ri.decode(e)):[]}}}case"nevent":{let e=as(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:nn(e[0][0]),relays:e[1]?e[1].map(e=>ri.decode(e)):[],author:e[2]?.[0]?nn(e[2][0]):void 0,kind:e[3]?.[0]?parseInt(nn(e[3][0]),16):void 0}}}case"naddr":{let e=as(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:ri.decode(e[0][0]),pubkey:nn(e[2][0]),kind:parseInt(nn(e[3][0]),16),relays:e[1]?e[1].map(e=>ri.decode(e)):[]}}}case"nsec":return{type:t,data:r};case"npub":case"note":return{type:t,data:nn(r)};default:throw new Error(`unknown prefix ${t}`)}}function as(e){let t={},n=e;for(;n.length>0;){let e=n[0],r=n[1],i=n.slice(2,2+r);if(n=n.slice(2+r),i.lengthii.encode(e))}))}function ps(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)),ds("nevent",ms({0:[rn(e.id)],1:(e.relays||[]).map(e=>ii.encode(e)),2:e.author?[rn(e.author)]:[],3:t?[new Uint8Array(t)]:[]}))}function gs(e){let t=new ArrayBuffer(4);return new DataView(t).setUint32(0,e.kind,!1),ds("naddr",ms({0:[ii.encode(e.identifier)],1:(e.relays||[]).map(e=>ii.encode(e)),2:[rn(e.pubkey)],3:[new Uint8Array(t)]}))}function ms(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)})}),sn(...t)}var ys={};function ws(e,t,n){const r=e instanceof Uint8Array?nn(e):e,i=As(Pt.getSharedSecret(r,"02"+t));let o=Uint8Array.from(cn(16)),s=ii.encode(n),a=Pr(i,o).encrypt(s);return`${er.encode(new Uint8Array(a))}?iv=${er.encode(new Uint8Array(o.buffer))}`}function vs(e,t,n){const r=e instanceof Uint8Array?nn(e):e;let[i,o]=n.split("?iv="),s=As(Pt.getSharedSecret(r,"02"+t)),a=er.decode(o),l=er.decode(i),c=Pr(s,a).decrypt(l);return ri.decode(c)}function As(e){return e.slice(1,33)}ei(ys,{decrypt:()=>vs,encrypt:()=>ws});ei({},{NIP05_REGEX:()=>ks,isNip05:()=>Is,isValid:()=>Bs,queryProfile:()=>xs,searchDomain:()=>Cs,useFetchImplementation:()=>Es});var bs,ks=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,Is=e=>ks.test(e||"");try{bs=fetch}catch(e){}function Es(e){bs=e}async function Cs(e,t=""){try{const n=`https://${e}/.well-known/nostr.json?name=${t}`,r=await bs(n,{redirect:"manual"});if(200!==r.status)throw Error("Wrong response code");return(await r.json()).names}catch(e){return{}}}async function xs(e){const t=e.match(ks);if(!t)return null;const[,n="_",r]=t;try{const e=`https://${r}/.well-known/nostr.json?name=${n}`,t=await bs(e,{redirect:"manual"});if(200!==t.status)throw Error("Wrong response code");const i=await t.json(),o=i.names[n];return o?{pubkey:o,relays:i.relays?.[o]}:null}catch(e){return null}}async function Bs(e,t){const n=await xs(t);return!!n&&n.pubkey===e}function Ss(e){const t={reply:void 0,root:void 0,mentions:[],profiles:[],quotes:[]};let n,r;for(let i=e.tags.length-1;i>=0;i--){const o=e.tags[i];if("e"===o[0]&&o[1]){const[e,i,s,a,l]=o,c={id:i,relays:s?[s]:[],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}ei({},{parse:()=>Ss});ei({},{fetchRelayInformation:()=>Qs,useFetchImplementation:()=>Fs});try{fetch}catch{}function Fs(e){0}async function Qs(e){return await(await fetch(e.replace("ws://","http://").replace("wss://","https://"),{headers:{Accept:"application/nostr+json"}})).json()}function Ds(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 Rs(e,t){let n=0;const r=e,i=["nonce",n.toString(),t.toString()];for(r.tags.push(i);;){const e=Math.floor((new Date).getTime()/1e3);if(e!==r.created_at&&(n=0,r.created_at=e),i[1]=(++n).toString(),r.id=$s(r),Ds(r.id)>=t)break}return r}function $s(e){return nn(bn(ii.encode(JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content]))))}ei({},{fastEventHash:()=>$s,getPow:()=>Ds,minePow:()=>Rs});ei({},{unwrapEvent:()=>oa,unwrapManyEvents:()=>sa,wrapEvent:()=>ra,wrapManyEvents:()=>ia});ei({},{createRumor:()=>zs,createSeal:()=>Ws,createWrap:()=>Zs,unwrapEvent:()=>ta,unwrapManyEvents:()=>na,wrapEvent:()=>Xs,wrapManyEvents:()=>ea});var Ps={};ei(Ps,{decrypt:()=>js,encrypt:()=>Hs,getConversationKey:()=>Ns,v2:()=>Gs});var Us=1,Ts=65535;function Ns(e,t){const n=Pt.getSharedSecret(e,"02"+t).subarray(1,33);return function(e,t,n){return fn.hash(e),void 0===n&&(n=new Uint8Array(e.outputLen)),zr(e,on(n),on(t))}(bn,n,"nip44-v2")}function Ls(e,t){const n=function(e,t,n,r=32){if(fn.hash(e),fn.number(r),r>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const i=Math.ceil(r/e.outputLen);void 0===n&&(n=Zr);const o=new Uint8Array(i*e.outputLen),s=zr.create(e,t),a=s._cloneInto(),l=new Uint8Array(s.outputLen);for(let t=0;tTs)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(Os(n)-n))}function _s(e,t,n){if(32!==n.length)throw new Error("AAD associated data must be 32 bytes");const r=sn(n,t);return zr(bn,e,r)}function Hs(e,t,n=cn(32)){const{chacha_key:r,chacha_nonce:i,hmac_key:o}=Ls(t,n),s=Ms(e),a=Vr(r,i,s),l=_s(o,a,n);return er.encode(sn(new Uint8Array([2]),n,a,l))}function js(e,t){const{nonce:n,ciphertext:r,mac:i}=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=er.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 i=n[0];if(2!==i)throw new Error("unknown encryption version "+i);return{nonce:n.subarray(1,33),ciphertext:n.subarray(33,-32),mac:n.subarray(-32)}}(e),{chacha_key:o,chacha_nonce:s,hmac_key:a}=Ls(t,n);if(!function(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;rTs||n.length!==t||e.length!==2+Os(t))throw new Error("invalid padding");return ri.decode(n)}(Vr(o,s,r))}var Gs={utils:{getConversationKey:Ns,calcPaddedLen:Os},encrypt:Hs,decrypt:js},qs=()=>Math.round(Date.now()/1e3),Ks=()=>Math.round(qs()-172800*Math.random()),Js=(e,t)=>Ns(e,t),Vs=(e,t,n)=>Hs(JSON.stringify(e),Js(t,n)),Ys=(e,t)=>JSON.parse(js(e.content,Js(t,e.pubkey)));function zs(e,t){const n={created_at:qs(),content:"",tags:[],...e,pubkey:pi(t)};return n.id=di(n),n}function Ws(e,t,n){return gi({kind:$i,content:Vs(e,t,n),created_at:Ks(),tags:[]},t)}function Zs(e,t){const n=hi();return gi({kind:Hi,content:Vs(e,n,t),created_at:Ks(),tags:[["p",t]]},n)}function Xs(e,t,n){return Zs(Ws(zs(e,t),t,n),n)}function ea(e,t,n){if(!n||0===n.length)throw new Error("At least one recipient is required.");const r=pi(t),i=[Xs(e,t,r)];return n.forEach(n=>{i.push(Xs(e,t,n))}),i}function ta(e,t){const n=Ys(e,t);return Ys(n,t)}function na(e,t){let n=[];return e.forEach(e=>{n.push(ta(e,t))}),n.sort((e,t)=>e.created_at-t.created_at),n}function ra(e,t,n,r,i){const o=function(e,t,n,r){const i={created_at:Math.ceil(Date.now()/1e3),kind:Pi,tags:[],content:t};return(Array.isArray(e)?e:[e]).forEach(({publicKey:e,relayUrl:t})=>{i.tags.push(t?["p",e,t]:["p",e])}),r&&i.tags.push(["e",r.eventId,r.relayUrl||"","reply"]),n&&i.tags.push(["subject",n]),i}(t,n,r,i);return Xs(o,e,t.publicKey)}function ia(e,t,n,r,i){if(!t||0===t.length)throw new Error("At least one recipient is required.");return[{publicKey:pi(e)},...t].map(t=>ra(e,t,n,r,i))}var oa=ta,sa=na;function aa(e,t,n,r){let i;const o=[...e.tags??[],["e",t.id,n],["p",t.pubkey]];return t.kind===Ci?i=Qi:(i=Ui,o.push(["k",String(t.kind)])),gi({kind:i,tags:o,content:""===e.content||t.tags?.find(e=>"-"===e[0])?"":JSON.stringify(t),created_at:e.created_at},r)}function la(e){if(![Qi,Ui].includes(e.kind))return;let t,n;for(let r=e.tags.length-1;r>=0&&(void 0===t||void 0===n);r--){const i=e.tags[r];i.length>=2&&("e"===i[0]&&void 0===t?t=i:"p"===i[0]&&void 0===n&&(n=i))}return void 0!==t?{id:t[1],relays:[t[2],n?.[2]].filter(e=>"string"==typeof e),author:n?.[1]}:void 0}function ca(e,{skipVerification:t}={}){const n=la(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||mi(r))?r:void 0}ei({},{finishRepostEvent:()=>aa,getRepostedEvent:()=>ca,getRepostedEventPointer:()=>la});ei({},{NOSTR_URI_REGEX:()=>ua,parse:()=>fa,test:()=>da});var ua=new RegExp(`nostr:(${is.source})`);function da(e){return"string"==typeof e&&new RegExp(`^${ua.source}$`).test(e)}function fa(e){const t=e.match(new RegExp(`^${ua.source}$`));if(!t)throw new Error(`Invalid Nostr URI: ${e}`);return{uri:t[0],value:t[1],decoded:ss(t[1])}}function ha(e,t,n){const r=t.tags.filter(e=>e.length>=2&&("e"===e[0]||"p"===e[0]));return gi({...e,kind:Di,tags:[...e.tags??[],...r,["e",t.id],["p",t.pubkey]],content:e.content??"+"},n)}function pa(e){if(e.kind!==Di)return;let t,n;for(let r=e.tags.length-1;r>=0&&(void 0===t||void 0===n);r--){const i=e.tags[r];i.length>=2&&("e"===i[0]&&void 0===t?t=i:"p"===i[0]&&void 0===n&&(n=i))}return void 0!==t&&void 0!==n?{id:t[1],relays:[t[2],n[2]].filter(e=>void 0!==e),author:n[1]}:void 0}ei({},{finishReactionEvent:()=>ha,getReactedEventPointer:()=>pa});ei({},{parse:()=>ya});var ga=/\W/m,ma=/\W |\W$|$|,| /m;function*ya(e){const t=e.length;let n=0,r=0;for(;rwa,channelHideMessageEvent:()=>ba,channelMessageEvent:()=>Aa,channelMetadataEvent:()=>va,channelMuteUserEvent:()=>ka});var wa=(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 gi({kind:Ti,tags:[...e.tags??[]],content:n,created_at:e.created_at},t)},va=(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 gi({kind:Ni,tags:[["e",e.channel_create_event_id],...e.tags??[]],content:n,created_at:e.created_at},t)},Aa=(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"]),gi({kind:Li,tags:[...n,...e.tags??[]],content:e.content,created_at:e.created_at},t)},ba=(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 gi({kind:Oi,tags:[["e",e.channel_message_event_id],...e.tags??[]],content:n,created_at:e.created_at},t)},ka=(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 gi({kind:Mi,tags:[["p",e.pubkey_to_mute],...e.tags??[]],content:n,created_at:e.created_at},t)};ei({},{EMOJI_SHORTCODE_REGEX:()=>Ia,matchAll:()=>Ca,regex:()=>Ea,replaceAll:()=>xa});var Ia=/:(\w+):/,Ea=()=>new RegExp(`\\B${Ia.source}\\B`,"g");function*Ca(e){const t=e.matchAll(Ea());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 xa(e,t){return e.replaceAll(Ea(),(e,n)=>t({shortcode:e,name:n}))}var Ba;ei({},{useFetchImplementation:()=>Sa,validateGithub:()=>Fa});try{Ba=fetch}catch{}function Sa(e){Ba=e}async function Fa(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 Qa(e){const{host:t,pathname:n,searchParams:r}=new URL(e),i=n||t,o=r.get("relay"),s=r.get("secret");if(!i||!o||!s)throw new Error("invalid connection string");return{pubkey:i,relay:o,secret:s}}async function Da(e,t,n){const r={method:"pay_invoice",params:{invoice:n}},i=ws(t,e,JSON.stringify(r)),o={kind:vo,created_at:Math.round(Date.now()/1e3),content:i,tags:[["p",e]]};return gi(o,t)}ei({},{makeNwcRequestEvent:()=>Da,parseConnectionString:()=>Qa});function Ra(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("")}ei({},{normalizeIdentifier:()=>Ra});var $a;ei({},{getSatoshisAmountFromBolt11:()=>Oa,getZapEndpoint:()=>Ua,makeZapReceipt:()=>La,makeZapRequest:()=>Ta,useFetchImplementation:()=>Pa,validateZapRequest:()=>Na});try{$a=fetch}catch{}function Pa(e){$a=e}async function Ua(e){try{let t="",{lud06:n,lud16:r}=JSON.parse(e.content);if(n){let{words:e}=dr.decode(n,1e3),r=dr.fromWords(e);t=ri.decode(r)}else{if(!r)return null;{let[e,n]=r.split("@");t=new URL(`/.well-known/lnurlp/${e}`,`https://${n}`).toString()}}let i=await $a(t),o=await i.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]),vi(e.event.kind)){const n=["a",`${e.event.kind}:${e.event.pubkey}:`];t.tags.push(n)}else if(bi(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 Na(e){let t;try{t=JSON.parse(e)}catch(e){return"Invalid zap request JSON."}if(!ni(t))return"Zap request is not a valid Nostr event.";if(!mi(t))return"Invalid signature on zap request.";let n=t.tags.find(([e,t])=>"p"===e&&t);if(!n)return"Zap request doesn't have a 'p' tag.";if(!n[1].match(/^[a-f0-9]{64}$/))return"Zap request 'p' tag is not valid hex.";let r=t.tags.find(([e,t])=>"e"===e&&t);return r&&!r[1].match(/^[a-f0-9]{64}$/)?"Zap request 'e' tag is not valid hex.":t.tags.find(([e,t])=>"relays"===e&&t)?null:"Zap request doesn't have a 'relays' tag."}function La({zapRequest:e,preimage:t,bolt11:n,paidAt:r}){let i=JSON.parse(e),o=i.tags.filter(([e])=>"e"===e||"p"===e||"a"===e),s={kind:9735,created_at:Math.round(r.getTime()/1e3),content:"",tags:[...o,["P",i.pubkey],["bolt11",n],["description",e]]};return t&&s.tags.push(["preimage",t]),s}function Oa(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 i=r[r.length-1],o=i.charCodeAt(0)-"0".charCodeAt(0),s=o>=0&&o<=9;let a=r.length-1;if(s&&a++,a<1)return 0;const l=parseInt(r.substring(0,a));switch(i){case"m":return 1e5*l;case"u":return 100*l;case"n":return l/10;case"p":return l/1e4;default:return 1e8*l}}ei({},{getToken:()=>_a,hashPayload:()=>Va,unpackEventFromToken:()=>ja,validateEvent:()=>za,validateEventKind:()=>qa,validateEventMethodTag:()=>Ja,validateEventPayloadTag:()=>Ya,validateEventTimestamp:()=>Ga,validateEventUrlTag:()=>Ka,validateToken:()=>Ha});var Ma="Nostr ";async function _a(e,t,n,r=!1,i){const o={kind:ko,tags:[["u",e],["method",t]],created_at:Math.round((new Date).getTime()/1e3),content:""};i&&o.tags.push(["payload",Va(i)]);const s=await n(o);return(r?Ma:"")+er.encode(ii.encode(JSON.stringify(s)))}async function Ha(e,t,n){const r=await ja(e).catch(e=>{throw e});return await za(r,t,n).catch(e=>{throw e})}async function ja(e){if(!e)throw new Error("Missing token");e=e.replace(Ma,"");const t=ri.decode(er.decode(e));if(!t||0===t.length||!t.startsWith("{"))throw new Error("Invalid token");return JSON.parse(t)}function Ga(e){return!!e.created_at&&Math.round((new Date).getTime()/1e3)-e.created_at<60}function qa(e){return e.kind===ko}function Ka(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 Va(e){return nn(bn(ii.encode(JSON.stringify(e))))}function Ya(e,t){const n=e.tags.find(e=>"payload"===e[0]);if(!n)return!1;const r=Va(t);return n.length>0&&n[1]===r}async function za(e,t,n,r){if(!mi(e))throw new Error("Invalid nostr event, signature invalid");if(!qa(e))throw new Error("Invalid nostr event, kind invalid");if(!Ga(e))throw new Error("Invalid nostr event, created_at timestamp invalid");if(!Ka(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&&!Ya(e,r))throw new Error("Invalid nostr event, payload tag does not match request body hash");return!0}function Wa(e){return[0,3].includes(e)||1e4<=e&&e<2e4}function Za(e){return 3e4<=e&&e<4e4}var Xa=function(e,t){return Xa=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Xa(e,t)};function el(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}Xa(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function tl(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{l(r.next(e))}catch(e){o(e)}}function a(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((r=r.apply(e,t||[])).next())})}function nl(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(l){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function il(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function ol(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i1||a(e,t)})},t&&(r[e]=t(r[e])))}function a(e,t){try{(n=i[e](t)).value instanceof sl?Promise.resolve(n.value.v).then(l,c):u(o[0][2],n)}catch(e){u(o[0][3],e)}var n}function l(e){a("next",e)}function c(e){a("throw",e)}function u(e,t){e(t),o.shift(),o.length&&a(o[0][0],o[0][1])}}function ll(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=rl(e),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise(function(r,i){(function(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)})(r,i,(t=e[n](t)).done,t.value)})}}}function cl(e){return"function"==typeof e}function ul(e){var t=e(function(e){Error.call(e),e.stack=(new Error).stack});return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}"function"==typeof SuppressedError&&SuppressedError;var dl=ul(function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map(function(e,t){return t+1+") "+e.toString()}).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}});function fl(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var hl=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var e,t,n,r,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var s=rl(o),a=s.next();!a.done;a=s.next()){a.value.remove(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}else o.remove(this);var l=this.initialTeardown;if(cl(l))try{l()}catch(e){i=e instanceof dl?e.errors:[e]}var c=this._finalizers;if(c){this._finalizers=null;try{for(var u=rl(c),d=u.next();!d.done;d=u.next()){var f=d.value;try{ml(f)}catch(e){i=null!=i?i:[],e instanceof dl?i=ol(ol([],il(i)),il(e.errors)):i.push(e)}}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}}if(i)throw new dl(i)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)ml(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(n=this._finalizers)&&void 0!==n?n:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&fl(t,e)},e.prototype.remove=function(t){var n=this._finalizers;n&&fl(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),pl=hl.EMPTY;function gl(e){return e instanceof hl||e&&"closed"in e&&cl(e.remove)&&cl(e.add)&&cl(e.unsubscribe)}function ml(e){cl(e)?e():e.unsubscribe()}var yl={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},wl={setTimeout:function(e,t){for(var n=[],r=2;r0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,n=this,r=n.hasError,i=n.isStopped,o=n.observers;return r||i?pl:(this.currentObservers=null,o.push(e),new hl(function(){t.currentObservers=null,fl(o,e)}))},t.prototype._checkFinalizedStatuses=function(e){var t=this,n=t.hasError,r=t.thrownError,i=t.isStopped;n?e.error(r):i&&e.complete()},t.prototype.asObservable=function(){var e=new Dl;return e.source=this,e},t.create=function(e,t){return new Ll(e,t)},t}(Dl),Ll=function(e){function t(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return el(t,e),t.prototype.next=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===n||n.call(t,e)},t.prototype.error=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===n||n.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,n;return null!==(n=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==n?n:pl},t}(Nl),Ol={now:function(){return(Ol.delegate||Date).now()},delegate:void 0},Ml=function(e){function t(t,n,r){void 0===t&&(t=1/0),void 0===n&&(n=1/0),void 0===r&&(r=Ol);var i=e.call(this)||this;return i._bufferSize=t,i._windowTime=n,i._timestampProvider=r,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=n===1/0,i._bufferSize=Math.max(1,t),i._windowTime=Math.max(1,n),i}return el(t,e),t.prototype.next=function(t){var n=this,r=n.isStopped,i=n._buffer,o=n._infiniteTimeWindow,s=n._timestampProvider,a=n._windowTime;r||(i.push(t),!o&&i.push(s.now()+a)),this._trimBuffer(),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var t=this._innerSubscribe(e),n=this._infiniteTimeWindow,r=this._buffer.slice(),i=0;i=2,!0))}function _c(e,t){for(var n=[],r=2;rt.reduce((e,t)=>{const n=[];for(const r of e)try{const e=t(r);if(void 0===e)continue;n.push(e)}catch(e){}return n},e);var Wc=Symbol("verified");function Zc(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;tt.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 su(e,t){let n=0,r=e.length-1;for(;n<=r;){const i=Math.floor((n+r)/2),o=t(e[i]);if(0===o)return[i,!0];o<0?r=i-1:n=i+1}return[n,!1]}tu.finalizeEvent,tu.verifyEvent,new TextDecoder("utf-8"),new TextEncoder;const au=Symbol.for("event-store"),lu=Symbol.for("event-uid"),cu=Symbol.for("replaceable-address"),uu=Symbol.for("from-cache"),du=Symbol.for("replaceable-identifier");function fu(e){return Wa(e)||Za(e)}function hu(e){let t=Reflect.get(e,lu);return t||(t=Za(e.kind)||Wa(e.kind)?pu(e):e.id,Reflect.set(e,lu,t)),t}function pu(e){if(!Za(e.kind)&&!Wa(e.kind))throw new Error("Event is not replaceable or addressable");return iu(e,cu,()=>gu(e.kind,e.pubkey,mu(e)))}function gu(e,t,n){return e+":"+t+":"+(n??"")}function mu(e){return iu(e,du,()=>e.tags.find(e=>"d"===e[0])?.[1]??"")}function yu(){return Math.round(Date.now()/1e3)}const wu=Symbol("expiration-timestamp");function vu(e){return iu(e,wu,()=>{const t=e.tags.find(e=>"expiration"===e[0])?.[1];return t?parseInt(t):void 0})}var Au=new TextDecoder("utf-8");new TextEncoder;function bu(e){let{prefix:t,words:n}=dr.decode(e,5e3),r=new Uint8Array(dr.fromWords(n));switch(t){case"nprofile":{let e=ku(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:nn(e[0][0]),relays:e[1]?e[1].map(e=>Au.decode(e)):[]}}}case"nevent":{let e=ku(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:nn(e[0][0]),relays:e[1]?e[1].map(e=>Au.decode(e)):[],author:e[2]?.[0]?nn(e[2][0]):void 0,kind:e[3]?.[0]?parseInt(nn(e[3][0]),16):void 0}}}case"naddr":{let e=ku(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:Au.decode(e[0][0]),pubkey:nn(e[2][0]),kind:parseInt(nn(e[3][0]),16),relays:e[1]?e[1].map(e=>Au.decode(e)):[]}}}case"nsec":return{type:t,data:r};case"npub":case"note":return{type:t,data:nn(r)};default:throw new Error(`unknown prefix ${t}`)}}function ku(e){let t={},n=e;for(;n.length>0;){let e=n[0],r=n[1],i=n.slice(2,2+r);if(n=n.slice(2+r),i.length=8&&Su.test(e)}function Qu(e){return!!e?.toLowerCase()?.match(/^[0-9a-f]{64}$/)}const Du="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0; +/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ru(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function $u(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Pu(e,...t){if(!Ru(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Uu(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");$u(e.outputLen),$u(e.blockLen)}function Tu(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 Nu(...e){for(let t=0;t>>t}const Mu=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),_u=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Hu(e){if(Pu(e),Mu)return e.toHex();let t="";for(let n=0;n=ju&&e<=Gu?e-ju:e>=qu&&e<=Ku?e-(qu-10):e>=Ju&&e<=Vu?e-(Ju-10):void 0}function zu(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(Mu)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,i=0;te().update(Wu(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function td(e=32){if(Du&&"function"==typeof Du.getRandomValues)return Du.getRandomValues(new Uint8Array(e));if(Du&&"function"==typeof Du.randomBytes)return Uint8Array.from(Du.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function nd(e,t=!1,n=!0){const r=e.split(":"),i=r[0]?parseInt(r[0]):void 0,o=r[1],s=r[2];if(void 0===i){if(n)return null;throw new Error("Missing kind")}if(void 0===o||""===o){if(n)return null;throw new Error("Missing pubkey")}if(t&&void 0===s){if(n)return null;throw new Error("Missing identifier")}return{kind:i,pubkey:o,identifier:s}}function rd(e){if(!e[1])throw new Error("Missing coordinate in tag");const t=nd(e[1],!0,!1);return e[2]&&Fu(e[2])&&(t.relays=[e[2]]),t}function id(e){if(!e[1])throw new Error("Missing pubkey in tag");if(!Qu(e[1]))throw new Error("Invalid pubkey");const t={pubkey:e[1]};return e[2]&&Fu(e[2])&&(t.relays=[Cu(e[2])]),t}function od(e){return e.kind+":"+e.pubkey+":"+e.identifier}const sd=Symbol.for("encrypted-content"),ad={[yi.EncryptedDirectMessage]:"nip04",[yi.Seal]:"nip44",[yi.GiftWrap]:"nip44"};function ld(e,t){return ad[e]=t,e}const cd=sd,ud=new Set([ld(yi.DraftLong,"nip04")]);function dd(e,t){return ud.add(ld(e,t)),e}function fd(e){return function(e){return void 0!==ad[e]}(e)&&ud.has(e)}function hd(e){return!!fd(e.kind)&&(function(e){return!0===Reflect.has(e,sd)}(e)&&!0===Reflect.has(e,cd))}function pd(e){if(fd(e.kind))return hd(e)?e[sd]:function(e){return Reflect.get(e,sd)}(e)}const gd=Symbol.for("hidden-tags"),md=new Set([dd(yi.BookmarkList,"nip04"),dd(yi.InterestsList,"nip04"),dd(yi.Mutelist,"nip04"),dd(yi.CommunitiesList,"nip04"),dd(yi.PublicChatsList,"nip04"),dd(yi.SearchRelaysList,"nip04"),dd(10009,"nip04"),dd(yi.Bookmarksets,"nip04"),dd(yi.Relaysets,"nip04"),dd(yi.Followsets,"nip04"),dd(yi.Curationsets,"nip04"),dd(yi.Interestsets,"nip04")]);function yd(e){return fd(e)&&md.has(e)}function wd(e){return!!yd(e.kind)&&(hd(e)&&Reflect.has(e,"HiddenTagsSymbol"))}function vd(e){if(!yd(e.kind))return;if(wd(e))return e[gd];const t=pd(e);if(void 0===t)return;const n=JSON.parse(t);if(!Array.isArray(n))throw new Error("Content is not an array of tags");const r=n.filter(e=>Array.isArray(e)).map(e=>e.map(e=>String(e)));return Reflect.set(e,gd,r),r}const Ad="abcdefghijklmnopqrstuvwxyz",bd=new Set((Ad+Ad.toUpperCase()).split("")),kd=Symbol.for("indexable-tags");function Id(e){let t=Reflect.get(e,kd);if(!t){const n=new Set;for(const t of e.tags)t.length>=2&&1===t[0].length&&bd.has(t[0])&&n.add(t[0]+":"+t[1]);t=n,Reflect.set(e,kd,n)}return t}class Ed{first=null;items=Object.create(null);last=null;max;resetTtl;size;ttl;constructor(e=0,t=0,n=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=e,this.resetTtl=n,this.size=0,this.ttl=t}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(e){if(this.has(e)){const t=this.items[e];delete this.items[e],this.size--,null!==t.prev&&(t.prev.next=t.next),null!==t.next&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),this.last===t&&(this.last=t.prev)}return this}entries(e=this.keys()){return e.map(e=>[e,this.get(e)])}evict(e=!1){if(e||this.size>0){const e=this.first;delete this.items[e.key],0===--this.size?(this.first=null,this.last=null):(this.first=e.next,this.first.prev=null)}return this}expiresAt(e){let t;return this.has(e)&&(t=this.items[e].expiry),t}get(e){let t;if(this.has(e)){const n=this.items[e];this.ttl>0&&n.expiry<=Date.now()?this.delete(e):(t=n.value,this.set(e,t,!0))}return t}has(e){return e in this.items}keys(){const e=[];let t=this.first;for(;null!==t;)e.push(t.key),t=t.next;return e}set(e,t,n=!1,r=this.resetTtl){let i;if(n||this.has(e)){if(i=this.items[e],i.value=t,!1===n&&r&&(i.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==i){const e=this.last,t=i.next,n=i.prev;this.first===i&&(this.first=i.next),i.next=null,i.prev=this.last,e.next=i,null!==n&&(n.next=t),null!==t&&(t.prev=n)}}else this.max>0&&this.size===this.max&&this.evict(!0),i=this.items[e]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:e,prev:this.last,next:null,value:t},1===++this.size?this.first=i:this.last.next=i;return this.last=i,this}values(e=this.keys()){return e.map(e=>this.get(e))}}function Cd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var xd,Bd,Sd={exports:{}};function Fd(){if(Bd)return xd;Bd=1;var e=1e3,t=60*e,n=60*t,r=24*n,i=7*r,o=365.25*r;function s(e,t,n,r){var i=t>=1.5*n;return Math.round(e/n)+" "+r+(i?"s":"")}return xd=function(a,l){l=l||{};var c=typeof a;if("string"===c&&a.length>0)return function(s){if((s=String(s)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(s);if(!a)return;var l=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return l*o;case"weeks":case"week":case"w":return l*i;case"days":case"day":case"d":return l*r;case"hours":case"hour":case"hrs":case"hr":case"h":return l*n;case"minutes":case"minute":case"mins":case"min":case"m":return l*t;case"seconds":case"second":case"secs":case"sec":case"s":return l*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return l;default:return}}(a);if("number"===c&&isFinite(a))return l.long?function(i){var o=Math.abs(i);if(o>=r)return s(i,o,r,"day");if(o>=n)return s(i,o,n,"hour");if(o>=t)return s(i,o,t,"minute");if(o>=e)return s(i,o,e,"second");return i+" ms"}(a):function(i){var o=Math.abs(i);if(o>=r)return Math.round(i/r)+"d";if(o>=n)return Math.round(i/n)+"h";if(o>=t)return Math.round(i/t)+"m";if(o>=e)return Math.round(i/e)+"s";return i+"ms"}(a);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a))}}var Qd=function(e){function t(e){let r,i,o,s=null;function a(...e){if(!a.enabled)return;const n=a,i=Number(new Date),o=i-(r||i);n.diff=o,n.prev=r,n.curr=i,r=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,i)=>{if("%%"===r)return"%";s++;const o=t.formatters[i];if("function"==typeof o){const t=e[s];r=o.call(n,t),e.splice(s,1),s--}return r}),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(i!==t.namespaces&&(i=t.namespaces,o=t.enabled(e)),o),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(e,t){let n=0,r=0,i=-1,o=0;for(;n"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const e of n)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const n of t.skips)if(r(e,n))return!1;for(const n of t.names)if(r(e,n))return!0;return!1},t.humanize=Fd(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(n=>{t[n]=e[n]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t{"%%"!==e&&(r++,"%c"===e&&(i=r))}),t.splice(i,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=Qd(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(Sd,Sd.exports);const Dd=Cd(Sd.exports)("applesauce");class Rd{log=Dd.extend("EventMemory");kinds=new Map;authors=new Map;tags=new Ed;created_at=[];kindAuthor=new Map;events=new Ed;replaceable=new Map;get size(){return this.events.size}hasEvent(e){return this.events.has(e)}getEvent(e){return this.events.get(e)}hasReplaceable(e,t,n){const r=this.replaceable.get(gu(e,t,n));return!!r&&r.length>0}getReplaceable(e,t,n){const r=gu(e,t,n),i=this.replaceable.get(r);return i?.[0]}getReplaceableHistory(e,t,n){const r=gu(e,t,n);return this.replaceable.get(r)}getByFilters(e){return Array.from(this.getEventsForFilters(Array.isArray(e)?e:[e]))}getTimeline(e){const t=[],n=this.getByFilters(e);for(const e of n)ou(t,e);return t}add(e){const t=e.id,n=this.events.get(t);if(n)return n;this.events.set(t,e),this.getKindIndex(e.kind).add(e),this.getAuthorsIndex(e.pubkey).add(e),this.getKindAuthorIndex(e.kind,e.pubkey).add(e);for(const t of Id(e))this.tags.has(t)&&this.getTagIndex(t).add(e);if(ou(this.created_at,e),fu(e.kind)){const t=e.tags.find(e=>"d"===e[0])?.[1],n=gu(e.kind,e.pubkey,t);let r=this.replaceable.get(n);this.replaceable.has(n)||(r=[],this.replaceable.set(n,r)),ou(r,e)}return e}remove(e){let t="string"==typeof e?this.events.get(e):e;if(!t)return!1;const n=t.id;if(!this.events.has(n))return!1;this.getAuthorsIndex(t.pubkey).delete(t),this.getKindIndex(t.kind).delete(t);const r=`${t.kind}:${t.pubkey}`;this.kindAuthor.has(r)&&this.kindAuthor.get(r).delete(t);for(const e of Id(t))this.tags.has(e)&&this.getTagIndex(e).delete(t);if(this.removeFromSortedArray(this.created_at,t),this.events.delete(n),fu(t.kind)){const e=t.tags.find(e=>"d"===e[0])?.[1],n=gu(t.kind,t.pubkey,e),r=this.replaceable.get(n);r&&this.removeFromSortedArray(r,t)}return this.claims.delete(t),!0}removeByFilters(e){const t=this.getByFilters(e);let n=0;for(const e of t)this.remove(e)&&n++;return n}update(e){}claims=new WeakMap;touch(e){this.events.has(e.id)&&this.events.set(e.id,e)}claim(e){const t=this.claims.get(e)||0;this.claims.set(e,t+1),this.touch(e)}isClaimed(e){const t=this.claims.get(e);return void 0!==t&&t>0}removeClaim(e){const t=this.claims.get(e);if(void 0!==t&&t>0){const n=t-1;0===n?this.claims.delete(e):this.claims.set(e,n)}}clearClaim(e){this.claims.delete(e)}*unclaimed(){let e=this.events.first;for(;e;){const t=e.value;this.isClaimed(t)||(yield t),e=e.next}return 0}prune(e){let t=0;const n=this.unclaimed();for(const r of n)if(this.remove(r),t++,e&&t>=e)break;return t}getKindIndex(e){return this.kinds.has(e)||this.kinds.set(e,new Set),this.kinds.get(e)}getAuthorsIndex(e){return this.authors.has(e)||this.authors.set(e,new Set),this.authors.get(e)}getKindAuthorIndex(e,t){const n=`${e}:${t}`;return this.kindAuthor.has(n)||this.kindAuthor.set(n,new Set),this.kindAuthor.get(n)}getTagIndex(e){if(!this.tags.has(e)){const t=new Set,n=Date.now();for(const n of this.events.values())Id(n).has(e)&&t.add(n);const r=Date.now()-n;r>100&&this.log(`Built index ${e} took ${r}ms`),this.tags.set(e,t)}return this.tags.get(e)}removeFromSortedArray(e,t){if(0===e.length)return;const n=su(e,e=>e.created_at-t.created_at);if(n){let r=n[0],i=!1;if(e[r]===t)return void e.splice(r,1);for(let n=r-1;n>=0&&e[n].created_at===t.created_at;n--)if(e[n]===t){e.splice(n,1),i=!0;break}if(i)return;for(let n=r+1;ne.created_at-t):void 0;i&&(n=i[0]);const o=e?su(this.created_at,t=>t.created_at-e):void 0;o&&(r=o[0]);for(let i=n;i<=r;i++){const n=this.created_at[i];if(!(void 0!==t&&n.created_at>t)){if(void 0!==e&&n.created_at{const r=e instanceof Set?e:new Set(e);if(t)n=r,t=!1;else for(const e of n)r.has(e)||n.delete(e);return n};e.ids&&r(this.iterateIds(e.ids));let i=null;void 0!==e.since&&(i=Array.from(this.iterateTime(e.since,e.until)),r(i));for(const t of bd){const n=e[`&${t}`];if(n?.length)for(const e of n)r(this.iterateTag(t,[e]))}for(const t of bd){const n=e[`#${t}`];if(n?.length){const i=e[`&${t}`],o=i?n.filter(e=>!i.includes(e)):n;o.length>0&&r(this.iterateTag(t,o))}}if(e.authors&&e.kinds&&e.authors.length*e.kinds.length<=20){const t=new Set;for(const n of e.kinds)for(const r of e.authors){const e=`${n}:${r}`,i=this.kindAuthor.get(e);if(i)for(const e of i)t.add(e)}r(t)}else e.authors&&r(this.iterateAuthors(e.authors)),e.kinds&&r(this.iterateKinds(e.kinds));if(void 0===e.since&&void 0!==e.until&&(i=Array.from(this.iterateTime(e.since,e.until)),r(i)),t)return new Set(this.events.values());if(e.limit&&i){const t=new Set;for(const r of i){if(t.size>=e.limit)break;n.has(r)&&t.add(r)}return t}return n}getEventsForFilters(e){if(0===e.length)return new Set;let t=new Set;for(const n of e){const e=this.getEventsForFilter(n);for(const n of e)t.add(n)}return t}reset(){this.events.clear(),this.kinds.clear(),this.authors.clear(),this.kindAuthor.clear(),this.tags.clear(),this.created_at=[],this.replaceable.clear(),this.claims=new WeakMap}}function $d(e,t){var n,r;if(0===t.length)return e;for(n=0,r=t.length;ne.until)return!1;for(let n in e)if("&"===n[0]){let r=n.slice(1),i=e[n];if(i&&i.length>0){const e=Id(t);for(const t of i)if(!e.has(r+":"+t))return!1}}for(let n in e)if("#"===n[0]){let r=n.slice(1),i=e[n];if(i){const n=e[`&${r}`],o=n?i.filter(e=>!n.includes(e)):i;if(0===o.length)continue;const s=Id(t);if(!1===o.some(e=>s.has(r+":"+e)))return!1}}return!0}function Ld(e,t){for(let n=0;nt.replaceable({kind:10063,pubkey:e.pubkey,relays:e.relays}).pipe(mc(e=>e?function(e){const t=Array.isArray(e)?e:e.tags;return zc(t,e=>Gc(e,"server")&&URL.canParse(e[1])?new URL("/",e[1]):void 0)}(e):[]))}const Md=Symbol.for("profile-content");function _d(e){return iu(e,Md,()=>{const t=function(e){try{return JSON.parse(e)}catch(e){return}}(e.content);if(t)return t.nip05&&"string"!=typeof t.nip05&&(t.nip05=String(t.nip05)),t.website&&t.website?.length>0&&!1===t.website?.startsWith("http")&&(t.website="https://"+t.website),t})}function Hd(e){return!!e&&((e.kind===yi.Metadata||e.kind===yi.Handlerinformation)&&!!_d(e))}!function(e){function t(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function n(...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 r(e){return{encode:n=>{if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("alphabet.encode input should be an array of numbers");return n.map(n=>{if(t(n),n<0||n>=e.length)throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${e.length})`);return e[n]})},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 i(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 o(e,n="="){if(t(e),"string"!=typeof n)throw new Error("padding chr should be string");return{encode(t){if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("padding.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`padding.encode: non-string input=${e}`);for(;t.length*e%8;)t.push(n);return t},decode(t){if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("padding.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`padding.decode: non-string input=${e}`);let r=t.length;if(r*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&t[r-1]===n;r--)if(!((r-1)*e%8))throw new Error("Invalid padding: string has too much padding");return t.slice(0,r)}}}function s(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function a(e,n,r){if(n<2)throw new Error(`convertRadix: wrong from=${n}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: wrong to=${r}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let i=0;const o=[],s=Array.from(e);for(s.forEach(e=>{if(t(e),e<0||e>=n)throw new Error(`Wrong integer: ${e}`)});;){let e=0,t=!0;for(let o=i;ot?l(t,e%t):e,c=(e,t)=>e+(t-l(e,t));function u(e,n,r,i){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(n<=0||n>32)throw new Error(`convertRadix2: wrong from=${n}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(c(n,r)>32)throw new Error(`convertRadix2: carry overflow from=${n} to=${r} carryBits=${c(n,r)}`);let o=0,s=0;const a=2**r-1,l=[];for(const i of e){if(t(i),i>=2**n)throw new Error(`convertRadix2: invalid data word=${i} from=${n}`);if(o=o<32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${n}`);for(s+=n;s>=r;s-=r)l.push((o>>s-r&a)>>>0);o&=2**s-1}if(o=o<=n)throw new Error("Excess padding");if(!i&&o)throw new Error(`Non-zero padding: ${o}`);return i&&s>0&&l.push(o>>>0),l}function d(e){return t(e),{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return a(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(a(t,e,256))}}}function f(e,n=!1){if(t(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(c(8,e)>32||c(e,8)>32)throw new Error("radix2: carry overflow");return{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return u(Array.from(t),8,e,!n)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(u(t,e,8,n))}}}function h(e){if("function"!=typeof e)throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch(e){}}}function p(e,n){if(t(e),"function"!=typeof n)throw new Error("checksum fn should be function");return{encode(t){if(!(t instanceof Uint8Array))throw new Error("checksum.encode: input should be Uint8Array");const r=n(t).slice(0,e),i=new Uint8Array(t.length+e);return i.set(t),i.set(r,t.length),i},decode(t){if(!(t instanceof Uint8Array))throw new Error("checksum.decode: input should be Uint8Array");const r=t.slice(0,-e),i=n(r).slice(0,e),o=t.slice(-e);for(let t=0;te.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))),e.base64=n(f(6),r("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),o(6),i("")),e.base64url=n(f(6),r("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),o(6),i(""));const g=e=>n(d(58),r(e),i(""));e.base58=g("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),e.base58flickr=g("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),e.base58xrp=g("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const m=[0,2,3,5,6,7,9,10,11];e.base58xmr={encode(t){let n="";for(let r=0;rn(p(4,e=>t(t(e))),e.base58);const y=n(r("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),i("")),w=[996825010,642813549,513874426,1027748829,705979059];function v(e){const t=e>>25;let n=(33554431&e)<<5;for(let e=0;e>e&1)&&(n^=w[e]);return n}function A(e,t,n=1){const r=e.length;let i=1;for(let t=0;t126)throw new Error(`Invalid prefix (${e})`);i=v(i)^n>>5}i=v(i);for(let t=0;tn)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);const r=e.toLowerCase();if(e!==r&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const i=(e=r).lastIndexOf("1");if(0===i||-1===i)throw new Error('Letter "1" must be present between prefix and data only');const o=e.slice(0,i),s=e.slice(i+1);if(s.length<6)throw new Error("Data must be at least 6 characters long");const a=y.decode(s).slice(0,-6),l=A(o,a,t);if(!s.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 i=e.length+7+n.length;if(!1!==r&&i>r)throw new TypeError(`Length ${i} exceeds limit ${r}`);return`${e=e.toLowerCase()}1${y.encode(n)}${A(e,n,t)}`},decode:s,decodeToBytes:function(e){const{prefix:t,words:n}=s(e,!1);return{prefix:t,words:n,bytes:r(n)}},decodeUnsafe:h(s),fromWords:r,fromWordsUnsafe:o,toWords:i}}e.bech32=b("bech32"),e.bech32m=b("bech32m"),e.utf8={encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)},e.hex=n(f(4),r("0123456789abcdef"),i(""),s(e=>{if("string"!=typeof e||e.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()}));const k={utf8:e.utf8,hex:e.hex,base16:e.base16,base32:e.base32,base64:e.base64,base64url:e.base64url,base58:e.base58,base58xmr:e.base58xmr},I=`Invalid encoding type. Available types: ${Object.keys(k).join(", ")}`;e.bytesToString=(e,t)=>{if("string"!=typeof e||!k.hasOwnProperty(e))throw new TypeError(I);if(!(t instanceof Uint8Array))throw new TypeError("bytesToString() expects Uint8Array");return k[e].encode(t)},e.str=e.bytesToString;e.stringToBytes=(e,t)=>{if(!k.hasOwnProperty(e))throw new TypeError(I);if("string"!=typeof t)throw new TypeError("stringToBytes() expects string");return k[e].decode(t)},e.bytes=e.stringToBytes}({}),BigInt(1e3),BigInt(1e6),BigInt(1e9),BigInt(1e12),BigInt("2100000000000000000"),BigInt(1e11);const _d={payment_hash:1,payment_secret:16,description:13,payee:19,description_hash:23,expiry:6,min_final_cltv_expiry:24,fallback_address:9,route_hint:3,feature_bits:5,metadata:27};for(let e=0,t=Object.keys(_d);eVc(e.tags,e=>Gc(e)?e:void 0,nd))}(e),function(e){if(function(e){return md(e)&&Reflect.has(e,jd)}(e))return e[jd];const t=yd(e);if(!t)return;const n=Vc(t,e=>Gc(e)?e:void 0,nd);return Reflect.set(e,jd,n),n}(e))}Fd.extend("EncryptedContentCache"),Fd.extend("event-cache"),new TextDecoder;const qd=Symbol.for("mailboxes-inboxes"),Kd=Symbol.for("mailboxes-outboxes");function Jd(e){return nu(e,qd,()=>{const t=[];for(const n of e.tags)if(qc(n))try{const[,e,r]=n;!e||!Bu(e)||t.includes(e)||"read"!==r&&void 0!==r||t.push(Iu(e))}catch{}return t})}function Vd(e){return nu(e,Kd,()=>{const t=[];for(const n of e.tags)if(qc(n))try{const[e,r,i]=n;"r"!==e||!Bu(r)||t.includes(r)||"write"!==i&&void 0!==i||t.push(Iu(r))}catch{}return t})}const Yd=Symbol.for("mute-public"),zd=Symbol.for("mute-hidden");function Wd(e){return{pubkeys:new Set(e.filter(Gc).map(e=>e[1])),threads:new Set(e.filter(jc).map(e=>e[1])),hashtags:new Set(e.filter(Jc).map(e=>e[1].toLocaleLowerCase())),words:new Set(e.filter(e=>"word"===e[0]&&e[1]).map(e=>e[1].toLocaleLowerCase()))}}function Zd(e){const t=function(e){if(function(e){return md(e)&&Reflect.has(e,zd)}(e))return e[zd];const t=yd(e);if(!t)return;const n=Wd(t);return Reflect.set(e,zd,n),n}(e),n=function(e){return nu(e,Yd,()=>Wd(e.tags))}(e);return t?function(...e){const t={pubkeys:new Set,threads:new Set,hashtags:new Set,words:new Set};for(const n of e){for(const e of n.pubkeys)t.pubkeys.add(e);for(const e of n.threads)t.threads.add(e);for(const e of n.hashtags)t.hashtags.add(e);for(const e of n.words)t.words.add(e)}return t}(t,n):n}var Xd;!function(e){e.nudity="nudity",e.malware="malware",e.profanity="profanity",e.illegal="illegal",e.spam="spam",e.impersonation="impersonation",e.other="other"}(Xd||(Xd={}));const ef=Symbol.for("nip10-thread-refs");function tf(e){if(!e[1])throw new Error("Missing event id in tag");let t={id:e[1]};return e[2]&&Bu(e[2])&&(t.relays=[e[2]]),"e"!==e[0]||"root"!==e[3]&&"reply"!==e[3]&&"mention"!==e[3]||!e[4]||64!==e[4].length||(t.author=e[4]),t}function nf(e){return t=>{const n=new Set;return t.pipe(_c(t=>{if(void 0!==t)if(Array.isArray(t))for(const r of t)n.has(r)||(n.add(r),e.claim(r));else n.has(t)||(n.add(t),e.claim(t))}),Uc(()=>{for(const t of n)e.removeClaim(t)}))}}function rf(e){return t=>{let n;return t.pipe(_c(t=>{n!==t&&(n&&e.removeClaim(n),t&&e.claim(t),n=t)}),Uc(()=>{n&&e.removeClaim(n)}))}}function of(){return e=>e.pipe(Qc(e=>null!=e))}function sf(e){return t=>new Fl(n=>{let r=!1;const i=t.subscribe({next:e=>{r=!0,n.next(e)},error:e=>n.error(e),complete:()=>n.complete()});return r||n.next(e),i})}function af(e){return"string"==typeof e&&(e={id:e}),t=>Fc(Bc(()=>function(e,t){const n=e.getEvent(t.id);return n instanceof Promise?fc(n):hc(n)}(t,e)).pipe(function(e,t){return Mc(n=>n?hc(n):e.eventLoader?fc(e.eventLoader(t)):ql)}(t,e),of()),t.insert$.pipe(Qc(t=>t.id===e.id)),t.remove$.pipe(Qc(t=>t.id===e.id),Dc(1),Dl(function(e,t){e.subscribe(Rl(t,wl))}),$c(void 0))).pipe(rf(t),Rc((e,t)=>e?.id===t?.id),sf(void 0))}function lf(e){return t=>{let n;return Fc(Bc(()=>function(e,t){const n=e.getReplaceable(t.kind,t.pubkey,t.identifier);return n instanceof Promise?fc(n):hc(n)}(t,e)).pipe(function(e,t){return Mc(n=>n?hc(n):void 0!==t.identifier?e.addressableLoader?fc(e.addressableLoader(t)).pipe(Qc(e=>!!e)):ql:e.replaceableLoader?fc(e.replaceableLoader(t)).pipe(Qc(e=>!!e)):ql)}(t,e),of()),t.insert$.pipe(Qc(t=>t.pubkey==e.pubkey&&t.kind===e.kind&&(void 0===e.identifier||pu(t)===e.identifier)))).pipe(Rc((e,t)=>e.created_at>=t.created_at),_c(e=>n=e),(r=t.remove$.pipe(Qc(e=>e.id===n?.id)),Dl(function(e,t){oc(r).subscribe(Rl(t,function(){return t.complete()},wl)),!t.closed&&e.subscribe(t)})),$c(void 0),function(e){var t,n,r=1/0;return null!=e&&("object"==typeof e?(t=e.count,r=void 0===t?1/0:t,n=e.delay):r=e),r<=0?function(){return ql}:Dl(function(e,t){var i,o=0,s=function(){if(null==i||i.unsubscribe(),i=null,null!=n){var e="number"==typeof n?Sc(n):oc(n(o)),r=Rl(t,function(){r.unsubscribe(),a()});e.subscribe(r)}else a()},a=function(){var n=!1;i=e.subscribe(Rl(t,void 0,function(){++o{const r=new Map;return Bc(()=>{const t=n.getTimeline(e);return t instanceof Promise?fc(t):hc(t)}).pipe(nf(n),Nc(n.insert$.pipe(Qc(t=>Td(e,t)),nf(n))),Nc(n.remove$.pipe(Qc(t=>Td(e,t)),pc(e=>e.id))),Lc((e,n)=>{if("string"==typeof n)return e.filter(e=>e.id!==n);if(Array.isArray(n)){if(!t)for(const e of n)uu(e.kind)&&r.set(du(e),e);return n}let i=[...e];if(!t&&uu(n.kind)){const t=du(n),o=r.get(t);if(o&&n.created_atr.clear()))}}function uf(e){return t=>kc(Object.fromEntries(e.map(e=>[e,t.model(af,{id:e})])))}function df(e){return t=>kc(Object.fromEntries(e.map(e=>[hu(e.kind,e.pubkey,e.identifier),t.model(lf,e)])))}function ff(e){return t=>{let n;return Fc(t.pipe(_c(e=>n=e)),e.update$.pipe(Qc(e=>e.id===n?.id)))}}function hf(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:gi.Contacts,pubkey:e.pubkey,relays:e.relays}).pipe(ff(t),pc(e=>e?Gd(e):[]))}function pf(e){return t=>{const n=[{kinds:[1111],"#e":[e.id]}];return za(e.kind)&&n.push({kinds:[1111],"#a":[fu(e)]}),t.timeline(n)}}function gf(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:gi.RelayList,pubkey:e.pubkey,relays:e.relays}).pipe(pc(e=>e&&{inboxes:Jd(e),outboxes:Vd(e)}))}function mf(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:gi.Mutelist,pubkey:e.pubkey,relays:e.relays}).pipe(ff(t),pc(e=>e&&Zd(e)))}function yf(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:gi.Metadata,pubkey:e.pubkey,relays:e.relays}).pipe(Qc(Md),pc(e=>e&&Od(e)),sf(void 0))}function wf(e){return t=>t.timeline(uu(e.kind)?[{kinds:[gi.Reaction],"#e":[e.id]},{kinds:[gi.Reaction],"#a":[du(e)]}]:[{kinds:[gi.Reaction],"#e":[e.id]}])}const vf={kinds:[gi.ShortTextNote]};function Af(e,t){const n=new Map,r=new Map,{kinds:i}={...vf,...t};let o="";const s={},a={kinds:i};var l;return"string"!=typeof(l=e)&&Reflect.has(l,"identifier")&&Reflect.has(l,"pubkey")&&Reflect.has(l,"kind")?(o=rd(e),s.kinds=[e.kind],s.authors=[e.pubkey],s["#d"]=[e.identifier],a["#a"]=[o]):"string"==typeof e?(o=e,s.ids=[e],a["#e"]=[e]):(o=e.id,s.ids=[e.id],a["#e"]=[e.id]),e=>e.filters([s,a]).pipe(pc(e=>{if(!r.has(du(e))){const t=function(e){return nu(e,ef,()=>{const t=function(e){const t=e.filter(e=>"e"===e[0]&&e[1]),n=e.filter(e=>"a"===e[0]&&e[1]);let r=t.find(e=>"root"===e[3]),i=t.find(e=>"reply"===e[3]),o=n.find(e=>"root"===e[3]),s=n.find(e=>"reply"===e[3]);if(r&&i||(r=i=r||i),o&&s||(o=s=o||s),!r&&!i){const e=t.filter(e=>!e[3]);e.length>=1&&(r=e[0],i=e[e.length-1]??r)}return{root:r||o?{e:r,a:o}:void 0,reply:i||s?{e:i,a:s}:void 0}}(e.tags);let n,r;if(t.root)try{n={e:t.root.e&&tf(t.root.e),a:t.root.a&&td(t.root.a)}}catch(e){}if(t.reply)try{r={e:t.reply.e&&tf(t.reply.e),a:t.reply.a&&td(t.reply.a)}}catch(e){}return{root:n,reply:r}})}(e),i=n.get(du(e))||new Set,o={event:e,refs:t,replies:i};for(const e of i)e.parent=o;if(t.reply?.e||t.reply?.a){let e=t.reply.e?t.reply.e.id:rd(t.reply.a);if(o.parent=r.get(e),o.parent)o.parent.replies.add(o);else{let t=n.get(e);t||(t=new Set,n.set(e,t)),t.add(o)}}r.set(du(e),o)}return{root:r.get(o),all:r}}))}function bf(e){return class extends e{models=new Map;modelKeepWarm=6e4;model(e,...t){let n=this.models.get(e);n||(n=new Map,this.models.set(e,n));const r=e.getKey?e.getKey(...t):$d(t);let i=n.get(r);if(!i){const o=()=>{n.get(r)===i&&n.delete(r)};i=e(...t)(this).pipe(Uc(o),function(e){void 0===e&&(e={});var t=e.connector,n=void 0===t?function(){return new Ul}:t,r=e.resetOnError,i=void 0===r||r,o=e.resetOnComplete,s=void 0===o||o,a=e.resetOnRefCountZero,l=void 0===a||a;return function(e){var t,r,o,a=0,c=!1,u=!1,d=function(){null==r||r.unsubscribe(),r=void 0},f=function(){d(),t=o=void 0,c=u=!1},h=function(){var e=t;f(),null==e||e.unsubscribe()};return Dl(function(e,p){a++,u||c||d();var g=o=null!=o?o:n();p.add(function(){0!==--a||u||c||(r=Oc(h,l))}),g.subscribe(p),!t&&a>0&&(t=new El({next:function(e){return g.next(e)},error:function(e){u=!0,d(),r=Oc(f,i,e),g.error(e)},complete:function(){c=!0,d(),r=Oc(f,s),g.complete()}}),oc(e).subscribe(t))})(e)}}({connector:()=>new Ll(1),resetOnComplete:()=>Sc(this.modelKeepWarm),resetOnRefCountZero:()=>Sc(this.modelKeepWarm)})),n.set(r,i)}return i}filters(e,t=!1){e=Array.isArray(e)?e:[e];const n=this.getByFilters(e);return Fc(t?ql:n&&"function"==typeof n.then?fc(n).pipe(Ec(e=>fc(Array.from(e)))):fc(Array.from(n)),this.insert$.pipe(Qc(t=>Td(e,t))))}event(e){return"string"==typeof e&&(e={id:e}),this.model(af,e)}replaceable(...e){let t;if(1===e.length)t=e[0];else if(3===e.length||2===e.length){let[n,r,i]=e;t={kind:n,pubkey:r,identifier:i}}if(!t)throw new Error("Invalid arguments, expected address pointer or kind, pubkey, identifier");return this.model(lf,t)}addressable(e){return this.model(lf,e)}timeline(e,t=!1){return this.model(cf,e,t)}profile(e){return this.model(yf,e)}contacts(e){return"string"==typeof e&&(e={pubkey:e}),this.model(hf,e)}mutes(e){return"string"==typeof e&&(e={pubkey:e}),this.model(mf,e)}mailboxes(e){return"string"==typeof e&&(e={pubkey:e}),this.model(gf,e)}blossomServers(e){return"string"==typeof e&&(e={pubkey:e}),this.model(Nd,e)}reactions(e){return this.model(wf,e)}thread(e){return this.model(Af,e)}comments(e){return this.model(pf,e)}events(e){return this.model(uf,e)}replaceableSet(e){return this.model(df,e)}}}class kf extends(bf(class{})){database;memory;keepOldVersions=!1;keepExpired=!1;verifyEvent;insert$=new Ul;update$=new Ul;remove$=new Ul;eventLoader;replaceableLoader;addressableLoader;constructor(e=new Qd){super(),e?(this.database=e,this.memory=new Qd):this.database=this.memory=new Qd,this.insert$.subscribe(e=>{Reflect.set(e,ou,this)}),this.remove$.subscribe(e=>{Reflect.deleteProperty(e,ou)})}mapToMemory(e){if(void 0!==e)return this.memory?this.memory.add(e):e}deletedIds=new Set;deletedCoords=new Map;checkDeleted(e){if("string"==typeof e)return this.deletedIds.has(e);if(this.deletedIds.has(e.id))return!0;if(za(e.kind)){const t=e.tags.find(e=>"d"===e[0])?.[1],n=this.deletedCoords.get(hu(e.kind,e.pubkey,t));if(n)return n>e.created_at}return!1}expirations=new Map;addExpiration(e){const t=yu(e);t&&Number.isFinite(t)&&this.expirations.set(e.id,t)}expirationTimeout=null;nextExpirationCheck=null;handleExpiringEvent(e){const t=yu(e);if(!t)return;if(this.expirations.set(e.id,t),this.expirationTimeout&&this.nextExpirationCheck&&this.nextExpirationChecke[1])}(e);for(const e of t)this.deletedIds.add(e),this.remove(e);const n=function(e){return e.tags.filter(Kc).map(e=>e[1])}(e);for(const t of n){this.deletedCoords.set(t,Math.max(this.deletedCoords.get(t)??0,e.created_at));const n=ed(t);if(!n)continue;const r=this.database.getReplaceableHistory(n.kind,n.pubkey,n.identifier)??[];for(const t of r)t.created_at"d"===e[0])?.[1]:void 0;if(!this.keepOldVersions&&uu(e.kind)){const t=this.database.getReplaceableHistory(e.kind,e.pubkey,r);if(t&&t.length>0&&t[0].created_at>=e.created_at)return kf.mergeDuplicateEvent(e,t[0]),t[0]}if(this.verifyEvent&&!1===this.verifyEvent(e))return null;const i=this.memory?.add(e);if(i&&i!==e)return kf.mergeDuplicateEvent(e,i),t&&Cu(i,t),i;const o=this.mapToMemory(this.database.add(e));if(e!==o&&kf.mergeDuplicateEvent(e,o),t&&Cu(o,t),o===e&&this.insert$.next(o),!this.keepOldVersions&&uu(e.kind)){const t=this.database.getReplaceableHistory(e.kind,e.pubkey,r);if(t&&t.length>0){const n=Array.from(t).filter(t=>t.created_atthis.mapToMemory(e)??e)}getByFilters(e){const t=this.database.getByFilters(e);return this.memory?t.map(e=>this.mapToMemory(e)):t}getTimeline(e){const t=this.database.getTimeline(e);return this.memory?t.map(e=>this.mapToMemory(e)):t}touch(e){return this.memory?.touch(e)}claim(e){return this.memory?.claim(e)}isClaimed(e){return this.memory?.isClaimed(e)??!1}removeClaim(e){return this.memory?.removeClaim(e)}clearClaim(e){return this.memory?.clearClaim(e)}unclaimed(){return this.memory?.unclaimed()||function*(){}()}prune(e){return this.memory?.prune(e)??0}removed(e){return this.checkDeleted(e)?ql:this.remove$.pipe(Qc(t=>t.id===e),Dc(1),Ec(()=>ql))}updated(e){return this.update$.pipe(Qc(t=>t.id===e||t===e))}}function If(){let e,t;const n=new Promise((n,r)=>{e=n,t=r});return n.resolve=e,n.reject=t,n}"navigator"in globalThis&&navigator.userAgent.includes("Android")&&navigator.clipboard&&navigator.clipboard.readText;var Ef,Cf;cd(gi.NostrConnect,"nip44"),function(e){e.GetPublicKey="get_pubic_key",e.SignEvent="sign_event",e.Nip04Encrypt="nip04_encrypt",e.Nip04Decrypt="nip04_decrypt",e.Nip44Encrypt="nip44_encrypt",e.Nip44Decrypt="nip44_decrypt"}(Ef||(Ef={})),function(e){e.Connect="connect",e.CreateAccount="create_account",e.GetPublicKey="get_public_key",e.SignEvent="sign_event",e.Nip04Encrypt="nip04_encrypt",e.Nip04Decrypt="nip04_decrypt",e.Nip44Encrypt="nip44_encrypt",e.Nip44Decrypt="nip44_decrypt"}(Cf||(Cf={}));class xf{key;constructor(e){this.key=e||di()}async getPublicKey(){return fi(this.key)}async signEvent(e){return hi(e,this.key)}nip04={encrypt:async(e,t)=>gs.encrypt(this.key,e,t),decrypt:async(e,t)=>gs.decrypt(this.key,e,t)};nip44={encrypt:async(e,t)=>Rs.v2.encrypt(t,Rs.v2.utils.getConversationKey(this.key,e)),decrypt:async(e,t)=>Rs.v2.decrypt(t,Rs.v2.utils.getConversationKey(this.key,e))};static fromKey(e){return new xf(function(e){if(e instanceof Uint8Array)return e;if(Su(e))return Vu(e);{const t=Xo.decode(e);if("nsec"!==t.type)throw new Error(`Cant get secret key from ${t.type}`);return t.data}}(e))}} -/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */const Bf=BigInt(0),Sf=BigInt(1),Ff=BigInt(2),Qf=BigInt(3),Df=BigInt(8),Rf=Object.freeze({a:Bf,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:Sf,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")}),Pf=(e,t)=>(e+t/Ff)/t,$f={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(e){const{n:t}=Rf,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Sf*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=n,s=BigInt("0x100000000000000000000000000000000"),a=Pf(o*e,t),l=Pf(-r*e,t);let c=oh(e-a*n-l*i,t),u=oh(-a*r-l*o,t);const d=c>s,f=u>s;if(d&&(c=t-c),f&&(u=t-u),c>s||u>s)throw new Error("splitScalarEndo: Endomorphism failed, k="+e);return{k1neg:d,k1:c,k2neg:f,k2:u}}},Uf=32;function Tf(e){const{a:t,b:n}=Rf,r=oh(e*e),i=oh(r*e);return oh(i+t*e+n)}const Nf=Rf.a===Bf;function Lf(e){if(!(e instanceof Of))throw new TypeError("JacobianPoint expected")}class Of{constructor(e,t,n){this.x=e,this.y=t,this.z=n}static fromAffine(e){if(!(e instanceof Hf))throw new TypeError("JacobianPoint#fromAffine: expected Point");return e.equals(Hf.ZERO)?Of.ZERO:new Of(e.x,e.y,Sf)}static toAffineBatch(e){const t=function(e,t=Rf.P){const n=new Array(e.length),r=e.reduce((e,r,i)=>r===Bf?e:(n[i]=e,oh(e*r,t)),Sf),i=ah(r,t);return e.reduceRight((e,r,i)=>r===Bf?e:(n[i]=oh(e*n[i],t),oh(e*r,t)),i),n}(e.map(e=>e.z));return e.map((e,n)=>e.toAffine(t[n]))}static normalizeZ(e){return Of.toAffineBatch(e).map(Of.fromAffine)}equals(e){Lf(e);const{x:t,y:n,z:r}=this,{x:i,y:o,z:s}=e,a=oh(r*r),l=oh(s*s),c=oh(t*l),u=oh(i*a),d=oh(oh(n*s)*l),f=oh(oh(o*r)*a);return c===u&&d===f}negate(){return new Of(this.x,oh(-this.y),this.z)}double(){const{x:e,y:t,z:n}=this,r=oh(e*e),i=oh(t*t),o=oh(i*i),s=e+i,a=oh(Ff*(oh(s*s)-r-o)),l=oh(Qf*r),c=oh(l*l),u=oh(c-Ff*a),d=oh(l*(a-u)-Df*o),f=oh(Ff*t*n);return new Of(u,d,f)}add(e){Lf(e);const{x:t,y:n,z:r}=this,{x:i,y:o,z:s}=e;if(i===Bf||o===Bf)return this;if(t===Bf||n===Bf)return e;const a=oh(r*r),l=oh(s*s),c=oh(t*l),u=oh(i*a),d=oh(oh(n*s)*l),f=oh(oh(o*r)*a),h=oh(u-c),p=oh(f-d);if(h===Bf)return p===Bf?this.double():Of.ZERO;const g=oh(h*h),m=oh(h*g),y=oh(c*g),w=oh(p*p-m-Ff*y),v=oh(p*(y-w)-d*m),A=oh(r*s*h);return new Of(w,v,A)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){const t=Of.ZERO;if("bigint"==typeof e&&e===Bf)return t;let n=ih(e);if(n===Sf)return this;if(!Nf){let e=t,r=this;for(;n>Bf;)n&Sf&&(e=e.add(r)),r=r.double(),n>>=Sf;return e}let{k1neg:r,k1:i,k2neg:o,k2:s}=$f.splitScalar(n),a=t,l=t,c=this;for(;i>Bf||s>Bf;)i&Sf&&(a=a.add(c)),s&Sf&&(l=l.add(c)),c=c.double(),i>>=Sf,s>>=Sf;return r&&(a=a.negate()),o&&(l=l.negate()),l=new Of(oh(l.x*$f.beta),l.y,l.z),a.add(l)}precomputeWindow(e){const t=Nf?128/e+1:256/e+1,n=[];let r=this,i=r;for(let o=0;o>=u,s>a&&(s-=c,e+=Sf);const d=n,f=n+Math.abs(s)-1,h=t%2!=0,p=s<0;0===s?o=o.add(Mf(h,r[d])):i=i.add(Mf(p,r[f]))}return{p:i,f:o}}multiply(e,t){let n,r,i=ih(e);if(Nf){const{k1neg:e,k1:o,k2neg:s,k2:a}=$f.splitScalar(i);let{p:l,f:c}=this.wNAF(o,t),{p:u,f:d}=this.wNAF(a,t);l=Mf(e,l),u=Mf(s,u),u=new Of(oh(u.x*$f.beta),u.y,u.z),n=l.add(u),r=c.add(d)}else{const{p:e,f:o}=this.wNAF(i,t);n=e,r=o}return Of.normalizeZ([n,r])[0]}toAffine(e){const{x:t,y:n,z:r}=this,i=this.equals(Of.ZERO);null==e&&(e=i?Df:ah(r));const o=e,s=oh(o*o),a=oh(s*o),l=oh(t*s),c=oh(n*a),u=oh(r*o);if(i)return Hf.ZERO;if(u!==Sf)throw new Error("invZ was invalid");return new Hf(l,c)}}function Mf(e,t){const n=t.negate();return e?n:t}Of.BASE=new Of(Rf.Gx,Rf.Gy,Sf),Of.ZERO=new Of(Bf,Sf,Bf);const _f=new WeakMap;class Hf{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,_f.delete(this)}hasEvenY(){return this.y%Ff===Bf}static fromCompressedHex(e){const t=32===e.length,n=nh(t?e:e.subarray(1));if(!ch(n))throw new Error("Point is not on curve");let r=function(e){const{P:t}=Rf,n=BigInt(6),r=BigInt(11),i=BigInt(22),o=BigInt(23),s=BigInt(44),a=BigInt(88),l=e*e*e%t,c=l*l*e%t,u=sh(c,Qf)*c%t,d=sh(u,Qf)*c%t,f=sh(d,Ff)*l%t,h=sh(f,r)*f%t,p=sh(h,i)*h%t,g=sh(p,s)*p%t,m=sh(g,a)*g%t,y=sh(m,s)*p%t,w=sh(y,Qf)*c%t,v=sh(w,o)*h%t,A=sh(v,n)*l%t,b=sh(A,Ff);if(b*b%t!==e)throw new Error("Cannot find square root");return b}(Tf(n));const i=(r&Sf)===Sf;if(t)i&&(r=oh(-r));else{!(1&~e[0])!==i&&(r=oh(-r))}const o=new Hf(n,r);return o.assertValidity(),o}static fromUncompressedHex(e){const t=nh(e.subarray(1,33)),n=nh(e.subarray(33,65)),r=new Hf(t,n);return r.assertValidity(),r}static fromHex(e){const t=rh(e),n=t.length,r=t[0];if(n===Uf)return this.fromCompressedHex(t);if(33===n&&(2===r||3===r))return this.fromCompressedHex(t);if(65===n&&4===r)return this.fromUncompressedHex(t);throw new Error(`Point.fromHex: received invalid point. Expected 32-33 compressed bytes or 65 uncompressed bytes, not ${n}`)}static fromPrivateKey(e){return Hf.BASE.multiply(function(e){let t;if("bigint"==typeof e)t=e;else if("number"==typeof e&&Number.isSafeInteger(e)&&e>0)t=BigInt(e);else if("string"==typeof e){if(64!==e.length)throw new Error("Expected 32 bytes of private key");t=th(e)}else{if(!Kf(e))throw new TypeError("Expected valid private key");if(32!==e.length)throw new Error("Expected 32 bytes of private key");t=nh(e)}if(!lh(t))throw new Error("Expected private key: 0 < key < n");return t}(e))}static fromSignature(e,t,n){const{r:r,s:i}=function(e){if(e instanceof qf)return e.assertValidity(),e;try{return qf.fromDER(e)}catch(t){return qf.fromCompact(e)}}(t);if(![0,1,2,3].includes(n))throw new Error("Cannot recover: invalid recovery bit");const o=function(e,t=!1){const n=function(e){const t=8*e.length-256,n=nh(e);return t>0?n>>BigInt(t):n}(e);if(t)return n;const{n:r}=Rf;return n>=r?n-r:n}(rh(e)),{n:s}=Rf,a=2===n||3===n?r+s:r,l=ah(a,s),c=oh(-o*l,s),u=oh(i*l,s),d=1&n?"03":"02",f=Hf.fromHex(d+Xf(a)),h=Hf.BASE.multiplyAndAddUnsafe(f,c,u);if(!h)throw new Error("Cannot recover signature: point at infinify");return h.assertValidity(),h}toRawBytes(e=!1){return Wf(this.toHex(e))}toHex(e=!1){const t=Xf(this.x);if(e){return`${this.hasEvenY()?"02":"03"}${t}`}return`04${t}${Xf(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const e="Point is not on elliptic curve",{x:t,y:n}=this;if(!ch(t)||!ch(n))throw new Error(e);const r=oh(n*n);if(oh(r-Tf(t))!==Bf)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new Hf(this.x,oh(-this.y))}double(){return Of.fromAffine(this).double().toAffine()}add(e){return Of.fromAffine(this).add(Of.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return Of.fromAffine(this).multiply(e,this).toAffine()}multiplyAndAddUnsafe(e,t,n){const r=Of.fromAffine(this),i=t===Bf||t===Sf||this!==Hf.BASE?r.multiplyUnsafe(t):r.multiply(t),o=Of.fromAffine(e).multiplyUnsafe(n),s=i.add(o);return s.equals(Of.ZERO)?void 0:s.toAffine()}}function jf(e){return Number.parseInt(e[0],16)>=8?"00"+e:e}function Gf(e){if(e.length<2||2!==e[0])throw new Error(`Invalid signature integer tag: ${Vf(e)}`);const t=e[1],n=e.subarray(2,t+2);if(!t||n.length!==t)throw new Error("Invalid signature integer: wrong length");if(0===n[0]&&n[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:nh(n),left:e.subarray(t+2)}}Hf.BASE=new Hf(Rf.Gx,Rf.Gy),Hf.ZERO=new Hf(Bf,Bf);class qf{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromCompact(e){const t=Kf(e),n="Signature.fromCompact";if("string"!=typeof e&&!t)throw new TypeError(`${n}: Expected string or Uint8Array`);const r=t?Vf(e):e;if(128!==r.length)throw new Error(`${n}: Expected 64-byte hex`);return new qf(th(r.slice(0,64)),th(r.slice(64,128)))}static fromDER(e){const t=Kf(e);if("string"!=typeof e&&!t)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:n,s:r}=function(e){if(e.length<2||48!=e[0])throw new Error(`Invalid signature tag: ${Vf(e)}`);if(e[1]!==e.length-2)throw new Error("Invalid signature: incorrect length");const{data:t,left:n}=Gf(e.subarray(2)),{data:r,left:i}=Gf(n);if(i.length)throw new Error(`Invalid signature: left bytes after parsing: ${Vf(i)}`);return{r:t,s:r}}(t?e:Wf(e));return new qf(n,r)}static fromHex(e){return this.fromDER(e)}assertValidity(){const{r:e,s:t}=this;if(!lh(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!lh(t))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const e=Rf.n>>Sf;return this.s>e}normalizeS(){return this.hasHighS()?new qf(this.r,oh(-this.s,Rf.n)):this}toDERRawBytes(){return Wf(this.toDERHex())}toDERHex(){const e=jf(eh(this.s)),t=jf(eh(this.r)),n=e.length/2,r=t.length/2,i=eh(n),o=eh(r);return`30${eh(r+n+4)}02${o}${t}02${i}${e}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return Wf(this.toCompactHex())}toCompactHex(){return Xf(this.r)+Xf(this.s)}}function Kf(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}const Jf=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Vf(e){!function(e){if(!Kf(e))throw new Error("Uint8Array expected")}(e);let t="";for(let n=0;n=Yf._0&&e<=Yf._9?e-Yf._0:e>=Yf.A&&e<=Yf.F?e-(Yf.A-10):e>=Yf.a&&e<=Yf.f?e-(Yf.a-10):void 0}function Wf(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("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,i=0;t0)return BigInt(e);if("bigint"==typeof e&&lh(e))return e;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function oh(e,t=Rf.P){const n=e%t;return n>=Bf?n:t+n}function sh(e,t){const{P:n}=Rf;let r=e;for(;t-- >Bf;)r*=r,r%=n;return r}function ah(e,t=Rf.P){if(e===Bf||t<=Bf)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=oh(e,t),r=t,i=Bf,o=Sf;for(;n!==Bf;){const e=r%n,t=i-o*(r/n);r=n,n=e,i=o,o=t}if(r!==Sf)throw new Error("invert: does not exist");return oh(i,t)}function lh(e){return Bft?l(t,e%t):e,c=(e,t)=>e+(t-l(e,t));function u(e,n,r,i){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(n<=0||n>32)throw new Error(`convertRadix2: wrong from=${n}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(c(n,r)>32)throw new Error(`convertRadix2: carry overflow from=${n} to=${r} carryBits=${c(n,r)}`);let o=0,s=0;const a=2**r-1,l=[];for(const i of e){if(t(i),i>=2**n)throw new Error(`convertRadix2: invalid data word=${i} from=${n}`);if(o=o<32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${n}`);for(s+=n;s>=r;s-=r)l.push((o>>s-r&a)>>>0);o&=2**s-1}if(o=o<=n)throw new Error("Excess padding");if(!i&&o)throw new Error(`Non-zero padding: ${o}`);return i&&s>0&&l.push(o>>>0),l}function d(e){return t(e),{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return a(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(a(t,e,256))}}}function f(e,n=!1){if(t(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(c(8,e)>32||c(e,8)>32)throw new Error("radix2: carry overflow");return{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return u(Array.from(t),8,e,!n)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(u(t,e,8,n))}}}function h(e){if("function"!=typeof e)throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch(e){}}}function p(e,n){if(t(e),"function"!=typeof n)throw new Error("checksum fn should be function");return{encode(t){if(!(t instanceof Uint8Array))throw new Error("checksum.encode: input should be Uint8Array");const r=n(t).slice(0,e),i=new Uint8Array(t.length+e);return i.set(t),i.set(r,t.length),i},decode(t){if(!(t instanceof Uint8Array))throw new Error("checksum.decode: input should be Uint8Array");const r=t.slice(0,-e),i=n(r).slice(0,e),o=t.slice(-e);for(let t=0;te.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))),e.base64=n(f(6),r("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),o(6),i("")),e.base64url=n(f(6),r("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),o(6),i(""));const g=e=>n(d(58),r(e),i(""));e.base58=g("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),e.base58flickr=g("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),e.base58xrp=g("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const m=[0,2,3,5,6,7,9,10,11];e.base58xmr={encode(t){let n="";for(let r=0;rn(p(4,e=>t(t(e))),e.base58);const y=n(r("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),i("")),w=[996825010,642813549,513874426,1027748829,705979059];function v(e){const t=e>>25;let n=(33554431&e)<<5;for(let e=0;e>e&1)&&(n^=w[e]);return n}function A(e,t,n=1){const r=e.length;let i=1;for(let t=0;t126)throw new Error(`Invalid prefix (${e})`);i=v(i)^n>>5}i=v(i);for(let t=0;tn)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);const r=e.toLowerCase();if(e!==r&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const i=(e=r).lastIndexOf("1");if(0===i||-1===i)throw new Error('Letter "1" must be present between prefix and data only');const o=e.slice(0,i),s=e.slice(i+1);if(s.length<6)throw new Error("Data must be at least 6 characters long");const a=y.decode(s).slice(0,-6),l=A(o,a,t);if(!s.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 i=e.length+7+n.length;if(!1!==r&&i>r)throw new TypeError(`Length ${i} exceeds limit ${r}`);return`${e=e.toLowerCase()}1${y.encode(n)}${A(e,n,t)}`},decode:s,decodeToBytes:function(e){const{prefix:t,words:n}=s(e,!1);return{prefix:t,words:n,bytes:r(n)}},decodeUnsafe:h(s),fromWords:r,fromWordsUnsafe:o,toWords:i}}e.bech32=b("bech32"),e.bech32m=b("bech32m"),e.utf8={encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)},e.hex=n(f(4),r("0123456789abcdef"),i(""),s(e=>{if("string"!=typeof e||e.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()}));const k={utf8:e.utf8,hex:e.hex,base16:e.base16,base32:e.base32,base64:e.base64,base64url:e.base64url,base58:e.base58,base58xmr:e.base58xmr},I=`Invalid encoding type. Available types: ${Object.keys(k).join(", ")}`;e.bytesToString=(e,t)=>{if("string"!=typeof e||!k.hasOwnProperty(e))throw new TypeError(I);if(!(t instanceof Uint8Array))throw new TypeError("bytesToString() expects Uint8Array");return k[e].encode(t)},e.str=e.bytesToString;e.stringToBytes=(e,t)=>{if(!k.hasOwnProperty(e))throw new TypeError(I);if("string"!=typeof t)throw new TypeError("stringToBytes() expects string");return k[e].decode(t)},e.bytes=e.stringToBytes}({}),BigInt(1e3),BigInt(1e6),BigInt(1e9),BigInt(1e12),BigInt("2100000000000000000"),BigInt(1e11);const jd={payment_hash:1,payment_secret:16,description:13,payee:19,description_hash:23,expiry:6,min_final_cltv_expiry:24,fallback_address:9,route_hint:3,feature_bits:5,metadata:27};for(let e=0,t=Object.keys(jd);ezc(e.tags,e=>Kc(e)?e:void 0,id))}(e),function(e){if(function(e){return wd(e)&&Reflect.has(e,qd)}(e))return e[qd];const t=vd(e);if(!t)return;const n=zc(t,e=>Kc(e)?e:void 0,id);return Reflect.set(e,qd,n),n}(e))}Dd.extend("EncryptedContentCache"),Dd.extend("event-cache"),new TextDecoder;const Jd=Symbol.for("mailboxes-inboxes"),Vd=Symbol.for("mailboxes-outboxes");function Yd(e){return iu(e,Jd,()=>{const t=[];for(const n of e.tags)if(Jc(n))try{const[,e,r]=n;!e||!Fu(e)||t.includes(e)||"read"!==r&&void 0!==r||t.push(Cu(e))}catch{}return t})}function zd(e){return iu(e,Vd,()=>{const t=[];for(const n of e.tags)if(Jc(n))try{const[e,r,i]=n;"r"!==e||!Fu(r)||t.includes(r)||"write"!==i&&void 0!==i||t.push(Cu(r))}catch{}return t})}const Wd=Symbol.for("mute-public"),Zd=Symbol.for("mute-hidden");function Xd(e){return{pubkeys:new Set(e.filter(Kc).map(e=>e[1])),threads:new Set(e.filter(qc).map(e=>e[1])),hashtags:new Set(e.filter(Yc).map(e=>e[1].toLocaleLowerCase())),words:new Set(e.filter(e=>"word"===e[0]&&e[1]).map(e=>e[1].toLocaleLowerCase()))}}function ef(e){const t=function(e){if(function(e){return wd(e)&&Reflect.has(e,Zd)}(e))return e[Zd];const t=vd(e);if(!t)return;const n=Xd(t);return Reflect.set(e,Zd,n),n}(e),n=function(e){return iu(e,Wd,()=>Xd(e.tags))}(e);return t?function(...e){const t={pubkeys:new Set,threads:new Set,hashtags:new Set,words:new Set};for(const n of e){for(const e of n.pubkeys)t.pubkeys.add(e);for(const e of n.threads)t.threads.add(e);for(const e of n.hashtags)t.hashtags.add(e);for(const e of n.words)t.words.add(e)}return t}(t,n):n}var tf;!function(e){e.nudity="nudity",e.malware="malware",e.profanity="profanity",e.illegal="illegal",e.spam="spam",e.impersonation="impersonation",e.other="other"}(tf||(tf={}));const nf=Symbol.for("nip10-thread-refs");function rf(e){if(!e[1])throw new Error("Missing event id in tag");let t={id:e[1]};return e[2]&&Fu(e[2])&&(t.relays=[e[2]]),"e"!==e[0]||"root"!==e[3]&&"reply"!==e[3]&&"mention"!==e[3]||!e[4]||64!==e[4].length||(t.author=e[4]),t}function of(e){return t=>{const n=new Set;return t.pipe(jc(t=>{if(void 0!==t)if(Array.isArray(t))for(const r of t)n.has(r)||(n.add(r),e.claim(r));else n.has(t)||(n.add(t),e.claim(t))}),Nc(()=>{for(const t of n)e.removeClaim(t)}))}}function sf(e){return t=>{let n;return t.pipe(jc(t=>{n!==t&&(n&&e.removeClaim(n),t&&e.claim(t),n=t)}),Nc(()=>{n&&e.removeClaim(n)}))}}function af(){return e=>e.pipe(Rc(e=>null!=e))}function lf(e){return t=>new Dl(n=>{let r=!1;const i=t.subscribe({next:e=>{r=!0,n.next(e)},error:e=>n.error(e),complete:()=>n.complete()});return r||n.next(e),i})}function cf(e){return"string"==typeof e&&(e={id:e}),t=>Dc(Fc(()=>function(e,t){const n=e.getEvent(t.id);return n instanceof Promise?pc(n):gc(n)}(t,e)).pipe(function(e,t){return Hc(n=>n?gc(n):e.eventLoader?pc(e.eventLoader(t)):Jl)}(t,e),af()),t.insert$.pipe(Rc(t=>t.id===e.id)),t.remove$.pipe(Rc(t=>t.id===e.id),$c(1),$l(function(e,t){e.subscribe(Pl(t,Al))}),Tc(void 0))).pipe(sf(t),Pc((e,t)=>e?.id===t?.id),lf(void 0))}function uf(e){return t=>{let n;return Dc(Fc(()=>function(e,t){const n=e.getReplaceable(t.kind,t.pubkey,t.identifier);return n instanceof Promise?pc(n):gc(n)}(t,e)).pipe(function(e,t){return Hc(n=>n?gc(n):void 0!==t.identifier?e.addressableLoader?pc(e.addressableLoader(t)).pipe(Rc(e=>!!e)):Jl:e.replaceableLoader?pc(e.replaceableLoader(t)).pipe(Rc(e=>!!e)):Jl)}(t,e),af()),t.insert$.pipe(Rc(t=>t.pubkey==e.pubkey&&t.kind===e.kind&&(void 0===e.identifier||mu(t)===e.identifier)))).pipe(Pc((e,t)=>e.created_at>=t.created_at),jc(e=>n=e),(r=t.remove$.pipe(Rc(e=>e.id===n?.id)),$l(function(e,t){ac(r).subscribe(Pl(t,function(){return t.complete()},Al)),!t.closed&&e.subscribe(t)})),Tc(void 0),function(e){var t,n,r=1/0;return null!=e&&("object"==typeof e?(t=e.count,r=void 0===t?1/0:t,n=e.delay):r=e),r<=0?function(){return Jl}:$l(function(e,t){var i,o=0,s=function(){if(null==i||i.unsubscribe(),i=null,null!=n){var e="number"==typeof n?Qc(n):ac(n(o)),r=Pl(t,function(){r.unsubscribe(),a()});e.subscribe(r)}else a()},a=function(){var n=!1;i=e.subscribe(Pl(t,void 0,function(){++o{const r=new Map;return Fc(()=>{const t=n.getTimeline(e);return t instanceof Promise?pc(t):gc(t)}).pipe(of(n),Oc(n.insert$.pipe(Rc(t=>Ld(e,t)),of(n))),Oc(n.remove$.pipe(Rc(t=>Ld(e,t)),mc(e=>e.id))),Mc((e,n)=>{if("string"==typeof n)return e.filter(e=>e.id!==n);if(Array.isArray(n)){if(!t)for(const e of n)fu(e.kind)&&r.set(hu(e),e);return n}let i=[...e];if(!t&&fu(n.kind)){const t=hu(n),o=r.get(t);if(o&&n.created_atr.clear()))}}function ff(e){return t=>Ec(Object.fromEntries(e.map(e=>[e,t.model(cf,{id:e})])))}function hf(e){return t=>Ec(Object.fromEntries(e.map(e=>[gu(e.kind,e.pubkey,e.identifier),t.model(uf,e)])))}function pf(e){return t=>{let n;return Dc(t.pipe(jc(e=>n=e)),e.update$.pipe(Rc(e=>e.id===n?.id)))}}function gf(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:yi.Contacts,pubkey:e.pubkey,relays:e.relays}).pipe(pf(t),mc(e=>e?Kd(e):[]))}function mf(e){return t=>{const n=[{kinds:[1111],"#e":[e.id]}];return Za(e.kind)&&n.push({kinds:[1111],"#a":[pu(e)]}),t.timeline(n)}}function yf(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:yi.RelayList,pubkey:e.pubkey,relays:e.relays}).pipe(mc(e=>e&&{inboxes:Yd(e),outboxes:zd(e)}))}function wf(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:yi.Mutelist,pubkey:e.pubkey,relays:e.relays}).pipe(pf(t),mc(e=>e&&ef(e)))}function vf(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:yi.Metadata,pubkey:e.pubkey,relays:e.relays}).pipe(Rc(Hd),mc(e=>e&&_d(e)),lf(void 0))}function Af(e){return t=>t.timeline(fu(e.kind)?[{kinds:[yi.Reaction],"#e":[e.id]},{kinds:[yi.Reaction],"#a":[hu(e)]}]:[{kinds:[yi.Reaction],"#e":[e.id]}])}const bf={kinds:[yi.ShortTextNote]};function kf(e,t){const n=new Map,r=new Map,{kinds:i}={...bf,...t};let o="";const s={},a={kinds:i};var l;return"string"!=typeof(l=e)&&Reflect.has(l,"identifier")&&Reflect.has(l,"pubkey")&&Reflect.has(l,"kind")?(o=od(e),s.kinds=[e.kind],s.authors=[e.pubkey],s["#d"]=[e.identifier],a["#a"]=[o]):"string"==typeof e?(o=e,s.ids=[e],a["#e"]=[e]):(o=e.id,s.ids=[e.id],a["#e"]=[e.id]),e=>e.filters([s,a]).pipe(mc(e=>{if(!r.has(hu(e))){const t=function(e){return iu(e,nf,()=>{const t=function(e){const t=e.filter(e=>"e"===e[0]&&e[1]),n=e.filter(e=>"a"===e[0]&&e[1]);let r=t.find(e=>"root"===e[3]),i=t.find(e=>"reply"===e[3]),o=n.find(e=>"root"===e[3]),s=n.find(e=>"reply"===e[3]);if(r&&i||(r=i=r||i),o&&s||(o=s=o||s),!r&&!i){const e=t.filter(e=>!e[3]);e.length>=1&&(r=e[0],i=e[e.length-1]??r)}return{root:r||o?{e:r,a:o}:void 0,reply:i||s?{e:i,a:s}:void 0}}(e.tags);let n,r;if(t.root)try{n={e:t.root.e&&rf(t.root.e),a:t.root.a&&rd(t.root.a)}}catch(e){}if(t.reply)try{r={e:t.reply.e&&rf(t.reply.e),a:t.reply.a&&rd(t.reply.a)}}catch(e){}return{root:n,reply:r}})}(e),i=n.get(hu(e))||new Set,o={event:e,refs:t,replies:i};for(const e of i)e.parent=o;if(t.reply?.e||t.reply?.a){let e=t.reply.e?t.reply.e.id:od(t.reply.a);if(o.parent=r.get(e),o.parent)o.parent.replies.add(o);else{let t=n.get(e);t||(t=new Set,n.set(e,t)),t.add(o)}}r.set(hu(e),o)}return{root:r.get(o),all:r}}))}function If(e){return class extends e{models=new Map;modelKeepWarm=6e4;model(e,...t){let n=this.models.get(e);n||(n=new Map,this.models.set(e,n));const r=e.getKey?e.getKey(...t):Td(t);let i=n.get(r);if(!i){const o=()=>{n.get(r)===i&&n.delete(r)};i=e(...t)(this).pipe(Nc(o),function(e){void 0===e&&(e={});var t=e.connector,n=void 0===t?function(){return new Nl}:t,r=e.resetOnError,i=void 0===r||r,o=e.resetOnComplete,s=void 0===o||o,a=e.resetOnRefCountZero,l=void 0===a||a;return function(e){var t,r,o,a=0,c=!1,u=!1,d=function(){null==r||r.unsubscribe(),r=void 0},f=function(){d(),t=o=void 0,c=u=!1},h=function(){var e=t;f(),null==e||e.unsubscribe()};return $l(function(e,p){a++,u||c||d();var g=o=null!=o?o:n();p.add(function(){0!==--a||u||c||(r=_c(h,l))}),g.subscribe(p),!t&&a>0&&(t=new xl({next:function(e){return g.next(e)},error:function(e){u=!0,d(),r=_c(f,i,e),g.error(e)},complete:function(){c=!0,d(),r=_c(f,s),g.complete()}}),ac(e).subscribe(t))})(e)}}({connector:()=>new Ml(1),resetOnComplete:()=>Qc(this.modelKeepWarm),resetOnRefCountZero:()=>Qc(this.modelKeepWarm)})),n.set(r,i)}return i}filters(e,t=!1){e=Array.isArray(e)?e:[e];const n=this.getByFilters(e);return Dc(t?Jl:n&&"function"==typeof n.then?pc(n).pipe(xc(e=>pc(Array.from(e)))):pc(Array.from(n)),this.insert$.pipe(Rc(t=>Ld(e,t))))}event(e){return"string"==typeof e&&(e={id:e}),this.model(cf,e)}replaceable(...e){let t;if(1===e.length)t=e[0];else if(3===e.length||2===e.length){let[n,r,i]=e;t={kind:n,pubkey:r,identifier:i}}if(!t)throw new Error("Invalid arguments, expected address pointer or kind, pubkey, identifier");return this.model(uf,t)}addressable(e){return this.model(uf,e)}timeline(e,t=!1){return this.model(df,e,t)}profile(e){return this.model(vf,e)}contacts(e){return"string"==typeof e&&(e={pubkey:e}),this.model(gf,e)}mutes(e){return"string"==typeof e&&(e={pubkey:e}),this.model(wf,e)}mailboxes(e){return"string"==typeof e&&(e={pubkey:e}),this.model(yf,e)}blossomServers(e){return"string"==typeof e&&(e={pubkey:e}),this.model(Od,e)}reactions(e){return this.model(Af,e)}thread(e){return this.model(kf,e)}comments(e){return this.model(mf,e)}events(e){return this.model(ff,e)}replaceableSet(e){return this.model(hf,e)}}}class Ef extends(If(class{})){database;memory;keepOldVersions=!1;keepExpired=!1;verifyEvent;insert$=new Nl;update$=new Nl;remove$=new Nl;eventLoader;replaceableLoader;addressableLoader;constructor(e=new Rd){super(),e?(this.database=e,this.memory=new Rd):this.database=this.memory=new Rd,this.insert$.subscribe(e=>{Reflect.set(e,au,this)}),this.remove$.subscribe(e=>{Reflect.deleteProperty(e,au)})}mapToMemory(e){if(void 0!==e)return this.memory?this.memory.add(e):e}deletedIds=new Set;deletedCoords=new Map;checkDeleted(e){if("string"==typeof e)return this.deletedIds.has(e);if(this.deletedIds.has(e.id))return!0;if(Za(e.kind)){const t=e.tags.find(e=>"d"===e[0])?.[1],n=this.deletedCoords.get(gu(e.kind,e.pubkey,t));if(n)return n>e.created_at}return!1}expirations=new Map;addExpiration(e){const t=vu(e);t&&Number.isFinite(t)&&this.expirations.set(e.id,t)}expirationTimeout=null;nextExpirationCheck=null;handleExpiringEvent(e){const t=vu(e);if(!t)return;if(this.expirations.set(e.id,t),this.expirationTimeout&&this.nextExpirationCheck&&this.nextExpirationChecke[1])}(e);for(const e of t)this.deletedIds.add(e),this.remove(e);const n=function(e){return e.tags.filter(Vc).map(e=>e[1])}(e);for(const t of n){this.deletedCoords.set(t,Math.max(this.deletedCoords.get(t)??0,e.created_at));const n=nd(t);if(!n)continue;const r=this.database.getReplaceableHistory(n.kind,n.pubkey,n.identifier)??[];for(const t of r)t.created_at"d"===e[0])?.[1]:void 0;if(!this.keepOldVersions&&fu(e.kind)){const t=this.database.getReplaceableHistory(e.kind,e.pubkey,r);if(t&&t.length>0&&t[0].created_at>=e.created_at)return Ef.mergeDuplicateEvent(e,t[0]),t[0]}if(this.verifyEvent&&!1===this.verifyEvent(e))return null;const i=this.memory?.add(e);if(i&&i!==e)return Ef.mergeDuplicateEvent(e,i),t&&Bu(i,t),i;const o=this.mapToMemory(this.database.add(e));if(e!==o&&Ef.mergeDuplicateEvent(e,o),t&&Bu(o,t),o===e&&this.insert$.next(o),!this.keepOldVersions&&fu(e.kind)){const t=this.database.getReplaceableHistory(e.kind,e.pubkey,r);if(t&&t.length>0){const n=Array.from(t).filter(t=>t.created_atthis.mapToMemory(e)??e)}getByFilters(e){const t=this.database.getByFilters(e);return this.memory?t.map(e=>this.mapToMemory(e)):t}getTimeline(e){const t=this.database.getTimeline(e);return this.memory?t.map(e=>this.mapToMemory(e)):t}touch(e){return this.memory?.touch(e)}claim(e){return this.memory?.claim(e)}isClaimed(e){return this.memory?.isClaimed(e)??!1}removeClaim(e){return this.memory?.removeClaim(e)}clearClaim(e){return this.memory?.clearClaim(e)}unclaimed(){return this.memory?.unclaimed()||function*(){}()}prune(e){return this.memory?.prune(e)??0}removed(e){return this.checkDeleted(e)?Jl:this.remove$.pipe(Rc(t=>t.id===e),$c(1),xc(()=>Jl))}updated(e){return this.update$.pipe(Rc(t=>t.id===e||t===e))}}function Cf(){let e,t;const n=new Promise((n,r)=>{e=n,t=r});return n.resolve=e,n.reject=t,n}"navigator"in globalThis&&navigator.userAgent.includes("Android")&&navigator.clipboard&&navigator.clipboard.readText;var xf,Bf;dd(yi.NostrConnect,"nip44"),function(e){e.GetPublicKey="get_pubic_key",e.SignEvent="sign_event",e.Nip04Encrypt="nip04_encrypt",e.Nip04Decrypt="nip04_decrypt",e.Nip44Encrypt="nip44_encrypt",e.Nip44Decrypt="nip44_decrypt"}(xf||(xf={})),function(e){e.Connect="connect",e.CreateAccount="create_account",e.GetPublicKey="get_public_key",e.SignEvent="sign_event",e.Nip04Encrypt="nip04_encrypt",e.Nip04Decrypt="nip04_decrypt",e.Nip44Encrypt="nip44_encrypt",e.Nip44Decrypt="nip44_decrypt"}(Bf||(Bf={}));class Sf{key;constructor(e){this.key=e||hi()}async getPublicKey(){return pi(this.key)}async signEvent(e){return gi(e,this.key)}nip04={encrypt:async(e,t)=>ys.encrypt(this.key,e,t),decrypt:async(e,t)=>ys.decrypt(this.key,e,t)};nip44={encrypt:async(e,t)=>Ps.v2.encrypt(t,Ps.v2.utils.getConversationKey(this.key,e)),decrypt:async(e,t)=>Ps.v2.decrypt(t,Ps.v2.utils.getConversationKey(this.key,e))};static fromKey(e){return new Sf(function(e){if(e instanceof Uint8Array)return e;if(Qu(e))return zu(e);{const t=ts.decode(e);if("nsec"!==t.type)throw new Error(`Cant get secret key from ${t.type}`);return t.data}}(e))}} +/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */const Ff=BigInt(0),Qf=BigInt(1),Df=BigInt(2),Rf=BigInt(3),$f=BigInt(8),Pf=Object.freeze({a:Ff,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:Qf,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")}),Uf=(e,t)=>(e+t/Df)/t,Tf={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(e){const{n:t}=Pf,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Qf*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=n,s=BigInt("0x100000000000000000000000000000000"),a=Uf(o*e,t),l=Uf(-r*e,t);let c=ah(e-a*n-l*i,t),u=ah(-a*r-l*o,t);const d=c>s,f=u>s;if(d&&(c=t-c),f&&(u=t-u),c>s||u>s)throw new Error("splitScalarEndo: Endomorphism failed, k="+e);return{k1neg:d,k1:c,k2neg:f,k2:u}}},Nf=32;function Lf(e){const{a:t,b:n}=Pf,r=ah(e*e),i=ah(r*e);return ah(i+t*e+n)}const Of=Pf.a===Ff;function Mf(e){if(!(e instanceof _f))throw new TypeError("JacobianPoint expected")}class _f{constructor(e,t,n){this.x=e,this.y=t,this.z=n}static fromAffine(e){if(!(e instanceof Gf))throw new TypeError("JacobianPoint#fromAffine: expected Point");return e.equals(Gf.ZERO)?_f.ZERO:new _f(e.x,e.y,Qf)}static toAffineBatch(e){const t=function(e,t=Pf.P){const n=new Array(e.length),r=e.reduce((e,r,i)=>r===Ff?e:(n[i]=e,ah(e*r,t)),Qf),i=ch(r,t);return e.reduceRight((e,r,i)=>r===Ff?e:(n[i]=ah(e*n[i],t),ah(e*r,t)),i),n}(e.map(e=>e.z));return e.map((e,n)=>e.toAffine(t[n]))}static normalizeZ(e){return _f.toAffineBatch(e).map(_f.fromAffine)}equals(e){Mf(e);const{x:t,y:n,z:r}=this,{x:i,y:o,z:s}=e,a=ah(r*r),l=ah(s*s),c=ah(t*l),u=ah(i*a),d=ah(ah(n*s)*l),f=ah(ah(o*r)*a);return c===u&&d===f}negate(){return new _f(this.x,ah(-this.y),this.z)}double(){const{x:e,y:t,z:n}=this,r=ah(e*e),i=ah(t*t),o=ah(i*i),s=e+i,a=ah(Df*(ah(s*s)-r-o)),l=ah(Rf*r),c=ah(l*l),u=ah(c-Df*a),d=ah(l*(a-u)-$f*o),f=ah(Df*t*n);return new _f(u,d,f)}add(e){Mf(e);const{x:t,y:n,z:r}=this,{x:i,y:o,z:s}=e;if(i===Ff||o===Ff)return this;if(t===Ff||n===Ff)return e;const a=ah(r*r),l=ah(s*s),c=ah(t*l),u=ah(i*a),d=ah(ah(n*s)*l),f=ah(ah(o*r)*a),h=ah(u-c),p=ah(f-d);if(h===Ff)return p===Ff?this.double():_f.ZERO;const g=ah(h*h),m=ah(h*g),y=ah(c*g),w=ah(p*p-m-Df*y),v=ah(p*(y-w)-d*m),A=ah(r*s*h);return new _f(w,v,A)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){const t=_f.ZERO;if("bigint"==typeof e&&e===Ff)return t;let n=sh(e);if(n===Qf)return this;if(!Of){let e=t,r=this;for(;n>Ff;)n&Qf&&(e=e.add(r)),r=r.double(),n>>=Qf;return e}let{k1neg:r,k1:i,k2neg:o,k2:s}=Tf.splitScalar(n),a=t,l=t,c=this;for(;i>Ff||s>Ff;)i&Qf&&(a=a.add(c)),s&Qf&&(l=l.add(c)),c=c.double(),i>>=Qf,s>>=Qf;return r&&(a=a.negate()),o&&(l=l.negate()),l=new _f(ah(l.x*Tf.beta),l.y,l.z),a.add(l)}precomputeWindow(e){const t=Of?128/e+1:256/e+1,n=[];let r=this,i=r;for(let o=0;o>=u,s>a&&(s-=c,e+=Qf);const d=n,f=n+Math.abs(s)-1,h=t%2!=0,p=s<0;0===s?o=o.add(Hf(h,r[d])):i=i.add(Hf(p,r[f]))}return{p:i,f:o}}multiply(e,t){let n,r,i=sh(e);if(Of){const{k1neg:e,k1:o,k2neg:s,k2:a}=Tf.splitScalar(i);let{p:l,f:c}=this.wNAF(o,t),{p:u,f:d}=this.wNAF(a,t);l=Hf(e,l),u=Hf(s,u),u=new _f(ah(u.x*Tf.beta),u.y,u.z),n=l.add(u),r=c.add(d)}else{const{p:e,f:o}=this.wNAF(i,t);n=e,r=o}return _f.normalizeZ([n,r])[0]}toAffine(e){const{x:t,y:n,z:r}=this,i=this.equals(_f.ZERO);null==e&&(e=i?$f:ch(r));const o=e,s=ah(o*o),a=ah(s*o),l=ah(t*s),c=ah(n*a),u=ah(r*o);if(i)return Gf.ZERO;if(u!==Qf)throw new Error("invZ was invalid");return new Gf(l,c)}}function Hf(e,t){const n=t.negate();return e?n:t}_f.BASE=new _f(Pf.Gx,Pf.Gy,Qf),_f.ZERO=new _f(Ff,Qf,Ff);const jf=new WeakMap;class Gf{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,jf.delete(this)}hasEvenY(){return this.y%Df===Ff}static fromCompressedHex(e){const t=32===e.length,n=ih(t?e:e.subarray(1));if(!dh(n))throw new Error("Point is not on curve");let r=function(e){const{P:t}=Pf,n=BigInt(6),r=BigInt(11),i=BigInt(22),o=BigInt(23),s=BigInt(44),a=BigInt(88),l=e*e*e%t,c=l*l*e%t,u=lh(c,Rf)*c%t,d=lh(u,Rf)*c%t,f=lh(d,Df)*l%t,h=lh(f,r)*f%t,p=lh(h,i)*h%t,g=lh(p,s)*p%t,m=lh(g,a)*g%t,y=lh(m,s)*p%t,w=lh(y,Rf)*c%t,v=lh(w,o)*h%t,A=lh(v,n)*l%t,b=lh(A,Df);if(b*b%t!==e)throw new Error("Cannot find square root");return b}(Lf(n));const i=(r&Qf)===Qf;if(t)i&&(r=ah(-r));else{!(1&~e[0])!==i&&(r=ah(-r))}const o=new Gf(n,r);return o.assertValidity(),o}static fromUncompressedHex(e){const t=ih(e.subarray(1,33)),n=ih(e.subarray(33,65)),r=new Gf(t,n);return r.assertValidity(),r}static fromHex(e){const t=oh(e),n=t.length,r=t[0];if(n===Nf)return this.fromCompressedHex(t);if(33===n&&(2===r||3===r))return this.fromCompressedHex(t);if(65===n&&4===r)return this.fromUncompressedHex(t);throw new Error(`Point.fromHex: received invalid point. Expected 32-33 compressed bytes or 65 uncompressed bytes, not ${n}`)}static fromPrivateKey(e){return Gf.BASE.multiply(function(e){let t;if("bigint"==typeof e)t=e;else if("number"==typeof e&&Number.isSafeInteger(e)&&e>0)t=BigInt(e);else if("string"==typeof e){if(64!==e.length)throw new Error("Expected 32 bytes of private key");t=rh(e)}else{if(!Vf(e))throw new TypeError("Expected valid private key");if(32!==e.length)throw new Error("Expected 32 bytes of private key");t=ih(e)}if(!uh(t))throw new Error("Expected private key: 0 < key < n");return t}(e))}static fromSignature(e,t,n){const{r:r,s:i}=function(e){if(e instanceof Jf)return e.assertValidity(),e;try{return Jf.fromDER(e)}catch(t){return Jf.fromCompact(e)}}(t);if(![0,1,2,3].includes(n))throw new Error("Cannot recover: invalid recovery bit");const o=function(e,t=!1){const n=function(e){const t=8*e.length-256,n=ih(e);return t>0?n>>BigInt(t):n}(e);if(t)return n;const{n:r}=Pf;return n>=r?n-r:n}(oh(e)),{n:s}=Pf,a=2===n||3===n?r+s:r,l=ch(a,s),c=ah(-o*l,s),u=ah(i*l,s),d=1&n?"03":"02",f=Gf.fromHex(d+th(a)),h=Gf.BASE.multiplyAndAddUnsafe(f,c,u);if(!h)throw new Error("Cannot recover signature: point at infinify");return h.assertValidity(),h}toRawBytes(e=!1){return Xf(this.toHex(e))}toHex(e=!1){const t=th(this.x);if(e){return`${this.hasEvenY()?"02":"03"}${t}`}return`04${t}${th(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const e="Point is not on elliptic curve",{x:t,y:n}=this;if(!dh(t)||!dh(n))throw new Error(e);const r=ah(n*n);if(ah(r-Lf(t))!==Ff)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new Gf(this.x,ah(-this.y))}double(){return _f.fromAffine(this).double().toAffine()}add(e){return _f.fromAffine(this).add(_f.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return _f.fromAffine(this).multiply(e,this).toAffine()}multiplyAndAddUnsafe(e,t,n){const r=_f.fromAffine(this),i=t===Ff||t===Qf||this!==Gf.BASE?r.multiplyUnsafe(t):r.multiply(t),o=_f.fromAffine(e).multiplyUnsafe(n),s=i.add(o);return s.equals(_f.ZERO)?void 0:s.toAffine()}}function qf(e){return Number.parseInt(e[0],16)>=8?"00"+e:e}function Kf(e){if(e.length<2||2!==e[0])throw new Error(`Invalid signature integer tag: ${zf(e)}`);const t=e[1],n=e.subarray(2,t+2);if(!t||n.length!==t)throw new Error("Invalid signature integer: wrong length");if(0===n[0]&&n[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:ih(n),left:e.subarray(t+2)}}Gf.BASE=new Gf(Pf.Gx,Pf.Gy),Gf.ZERO=new Gf(Ff,Ff);class Jf{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromCompact(e){const t=Vf(e),n="Signature.fromCompact";if("string"!=typeof e&&!t)throw new TypeError(`${n}: Expected string or Uint8Array`);const r=t?zf(e):e;if(128!==r.length)throw new Error(`${n}: Expected 64-byte hex`);return new Jf(rh(r.slice(0,64)),rh(r.slice(64,128)))}static fromDER(e){const t=Vf(e);if("string"!=typeof e&&!t)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:n,s:r}=function(e){if(e.length<2||48!=e[0])throw new Error(`Invalid signature tag: ${zf(e)}`);if(e[1]!==e.length-2)throw new Error("Invalid signature: incorrect length");const{data:t,left:n}=Kf(e.subarray(2)),{data:r,left:i}=Kf(n);if(i.length)throw new Error(`Invalid signature: left bytes after parsing: ${zf(i)}`);return{r:t,s:r}}(t?e:Xf(e));return new Jf(n,r)}static fromHex(e){return this.fromDER(e)}assertValidity(){const{r:e,s:t}=this;if(!uh(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!uh(t))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const e=Pf.n>>Qf;return this.s>e}normalizeS(){return this.hasHighS()?new Jf(this.r,ah(-this.s,Pf.n)):this}toDERRawBytes(){return Xf(this.toDERHex())}toDERHex(){const e=qf(nh(this.s)),t=qf(nh(this.r)),n=e.length/2,r=t.length/2,i=nh(n),o=nh(r);return`30${nh(r+n+4)}02${o}${t}02${i}${e}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return Xf(this.toCompactHex())}toCompactHex(){return th(this.r)+th(this.s)}}function Vf(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}const Yf=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function zf(e){!function(e){if(!Vf(e))throw new Error("Uint8Array expected")}(e);let t="";for(let n=0;n=Wf._0&&e<=Wf._9?e-Wf._0:e>=Wf.A&&e<=Wf.F?e-(Wf.A-10):e>=Wf.a&&e<=Wf.f?e-(Wf.a-10):void 0}function Xf(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("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,i=0;t0)return BigInt(e);if("bigint"==typeof e&&uh(e))return e;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function ah(e,t=Pf.P){const n=e%t;return n>=Ff?n:t+n}function lh(e,t){const{P:n}=Pf;let r=e;for(;t-- >Ff;)r*=r,r%=n;return r}function ch(e,t=Pf.P){if(e===Ff||t<=Ff)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=ah(e,t),r=t,i=Ff,o=Qf;for(;n!==Ff;){const e=r%n,t=i-o*(r/n);r=n,n=e,i=o,o=t}if(r!==Qf)throw new Error("invert: does not exist");return ah(i,t)}function uh(e){return Ff"string"==typeof e):t.every(e=>Number.isSafeInteger(e))))}function fh(e,t){if("string"!=typeof t)throw new Error(`${e}: string expected`);return!0}function hh(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function ph(e){if(!Array.isArray(e))throw new Error("array expected")}function gh(e,t){if(!dh(!0,t))throw new Error(`${e}: array of strings expected`)}Hf.BASE._setWindowSize(8);const mh=(e,t)=>0===t?e:mh(t,e%t),yh=(e,t)=>e+(t-mh(e,t)),wh=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function vh(e,t,n,r){if(ph(e),t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(yh(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${yh(t,n)}`);let i=0,o=0;const s=wh[t],a=wh[n]-1,l=[];for(const r of e){if(hh(r),r>=s)throw new Error(`convertRadix2: invalid data word=${r} from=${t}`);if(i=i<32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${t}`);for(o+=t;o>=n;o-=n)l.push((i>>o-n&a)>>>0);const e=wh[o];if(void 0===e)throw new Error("invalid carry");i&=e-1}if(i=i<=t)throw new Error("Excess padding");if(!r&&i>0)throw new Error(`Non-zero padding: ${i}`);return r&&o>0&&l.push(i>>>0),l}const Ah=(()=>"function"==typeof Uint8Array.from([]).toBase64&&"function"==typeof Uint8Array.fromBase64)()?{encode:e=>(function(e,...t){if(!uh(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}(e),e.toBase64()),decode:e=>((e,t)=>{fh("base64",e);const n=t?/^[A-Za-z0-9=_-]+$/:/^[A-Za-z0-9=+/]+$/,r=t?"base64url":"base64";if(e.length>0&&!n.test(e))throw new Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,lastChunkHandling:"strict"})})(e,!1)}:function(...e){const t=e=>e,n=(e,t)=>n=>e(t(n));return{encode:e.map(e=>e.encode).reduceRight(n,t),decode:e.map(e=>e.decode).reduce(n,t)}}(function(e,t=!1){if(hh(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(yh(8,e)>32||yh(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!uh(n))throw new Error("radix2.encode input should be Uint8Array");return vh(Array.from(n),8,e,!t)},decode:n=>(function(e,t){if(!dh(!1,t))throw new Error(`${e}: array of numbers expected`)}("radix2.decode",n),Uint8Array.from(vh(n,e,8,t)))}}(6),function(e){const t="string"==typeof e?e.split(""):e,n=t.length;gh("alphabet",t);const r=new Map(t.map((e,t)=>[e,t]));return{encode:r=>(ph(r),r.map(r=>{if(!Number.isSafeInteger(r)||r<0||r>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${r}". Allowed: ${e}`);return t[r]})),decode:t=>(ph(t),t.map(t=>{fh("alphabet.decode",t);const n=r.get(t);if(void 0===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n}))}}("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),function(e,t="="){return hh(e),fh("padding",t),{encode(n){for(gh("padding.encode",n);n.length*e%8;)n.push(t);return n},decode(n){gh("padding.decode",n);let r=n.length;if(r*e%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;r>0&&n[r-1]===t;r--){if((r-1)*e%8==0)throw new Error("padding: invalid, string has too much padding")}return n.slice(0,r)}}}(6),function(e=""){return fh("join",e),{encode:t=>(gh("join.decode",t),t.join(e)),decode:t=>(fh("join.decode",t),t.split(e))}}(""));function bh(e){return Hf.fromHex(e).toHex().substring(2)}const kh=new TextDecoder("utf-8"),Ih=new TextEncoder;class Eh{log=Fd.extend("SerialPortSigner");writer=null;pubkey;get isConnected(){return!!this.writer}verifyEvent=pi;nip04;constructor(){this.nip04={encrypt:this.nip04Encrypt.bind(this),decrypt:this.nip04Decrypt.bind(this)}}lastCommand=null;async callMethodOnDevice(e,t,n={}){if(!Eh.SUPPORTED)throw new Error("Serial devices are not supported");if(this.writer||await this.connectToDevice(n),this.lastCommand)throw new Error("Previous command to device still pending!");const r=If();return this.lastCommand=r,this.sendCommand(e,t),setTimeout(()=>{r.reject(new Error("Device timeout")),this.lastCommand===r&&(this.lastCommand=null)},6e3),this.lastCommand}async connectToDevice({onConnect:e,onDisconnect:t,onError:n,onDone:r}){let i,o=await window.navigator.serial.requestPort();await o.open({baudRate:9600}),await(e=>new Promise(t=>setTimeout(t,e)))(1e3),(async()=>{for(;o&&o.readable;){const e=new window.TextDecoderStream;o.readable.pipeTo(e.writable),i=e.readable.getReader();const t=this.readFromSerialPort(i);try{for(;;){const{value:e,done:n}=await t("\n");if(e){const{method:t,data:n}=this.parseResponse(e);if("/ping"===t&&this.log("Pong"),-1===Eh.PUBLIC_METHODS.indexOf(t))continue;this.log("Received: ",t,n),this.lastCommand&&(this.lastCommand.resolve(n),this.lastCommand=null)}if(n)return this.lastCommand=null,this.writer=null,void(r&&r())}}catch(e){if(e instanceof Error)throw this.writer=null,n&&n(e),this.lastCommand&&(this.lastCommand.reject(e),this.lastCommand=null),e}}})();const s=new window.TextEncoderStream;s.readable.pipeTo(o.writable),this.writer=s.writable.getWriter(),await this.sendCommand(Eh.METHOD_PING),await this.sendCommand(Eh.METHOD_PING,[window.location.host]),e&&e(),o.addEventListener("disconnect",()=>{this.log("Disconnected"),this.lastCommand=null,this.writer=null,t&&t()})}async sendCommand(e,t=[]){if(!this.writer)return;this.log("Send command",e,t);const n=[e].concat(t).join(" ");await this.writer.write(n+"\n")}readFromSerialPort(e){let t,n=[];return async(r="\n")=>{if(n.length)return{value:n.shift().trim(),done:!1};const i=[];for(t&&(i.push(t),t=void 0);;){const{value:o,done:s}=await e.read();if(o){const e=o.split(r);if(e.length>1)return i.push(e.shift()),t=e.pop(),n=e,{value:i.join("").trim(),done:!1};i.push(o)}if(s)return{value:i.join("").trim(),done:!0}}}}parseResponse(e){const t=e.split(" ")[0];return{method:t,data:e.substring(t.length).trim()}}async nip04Encrypt(e,t){const n=Vu(await this.callMethodOnDevice(Eh.METHOD_SHARED_SECRET,[bh(e)]));let r=Uint8Array.from(Xu(16)),i=Ih.encode(t),o=await crypto.subtle.importKey("raw",n,{name:"AES-CBC"},!1,["encrypt"]),s=await crypto.subtle.encrypt({name:"AES-CBC",iv:r},o,i);return`${Ah.encode(new Uint8Array(s))}?iv=${Ah.encode(new Uint8Array(r.buffer))}`}async nip04Decrypt(e,t){let[n,r]=t.split("?iv=");const i=Vu(await this.callMethodOnDevice(Eh.METHOD_SHARED_SECRET,[bh(e)]));let o=await crypto.subtle.importKey("raw",i,{name:"AES-CBC"},!1,["decrypt"]),s=Ah.decode(n),a=Ah.decode(r),l=await crypto.subtle.decrypt({name:"AES-CBC",iv:a},o,s);return kh.decode(l)}async getPublicKey(){const e=await this.callMethodOnDevice(Eh.METHOD_PUBLIC_KEY,[]);return this.pubkey=e,e}async restore(e){await this.callMethodOnDevice(Eh.METHOD_RESTORE,[Mu(e)])}async signEvent(e){const t=e.pubkey||this.pubkey;if(!t)throw new Error("Unknown signer pubkey");const n={...e,id:ci({...e,pubkey:t})},r=await this.callMethodOnDevice(Eh.METHOD_SIGN_MESSAGE,[n.id]),i={...n,sig:r,pubkey:t};if(!this.verifyEvent(i))throw new Error("Invalid signature");return i}ping(){this.sendCommand(Eh.METHOD_PING,[window.location.host])}static SUPPORTED="navigator"in globalThis&&!!navigator.serial;static METHOD_PING="/ping";static METHOD_LOG="/log";static METHOD_SIGN_MESSAGE="/sign-message";static METHOD_SHARED_SECRET="/shared-secret";static METHOD_PUBLIC_KEY="/public-key";static METHOD_RESTORE="/restore";static PUBLIC_METHODS=[Eh.METHOD_PUBLIC_KEY,Eh.METHOD_SIGN_MESSAGE,Eh.METHOD_SHARED_SECRET,Eh.METHOD_RESTORE]}const Ch=[`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`],xh=[{value:0,label:"User Metadata (0)"},{value:3,label:"Follows (3)"},{value:1e4,label:"Mute list (10000)"},{value:10001,label:"Pin list (10001)"},{value:10002,label:"Relay List Metadata (10002)"},{value:10003,label:"Bookmark list (10003)"},{value:10004,label:"Communities list (10004)"},{value:10005,label:"Public chats list (10005)"},{value:10006,label:"Blocked relays list (10006)"},{value:10007,label:"Search relays list (10007)"},{value:10009,label:"User groups (10009)"},{value:10012,label:"Favorite relays list (10012)"},{value:10013,label:"Private event relay list (10013)"},{value:10015,label:"Interests list (10015)"},{value:10019,label:"Nutzap Mint Recommendation (10019)"},{value:10020,label:"Media follows (10020)"},{value:10030,label:"User emoji list (10030)"},{value:10050,label:"Relay list to receive DMs (10050)"},{value:10051,label:"KeyPackage Relays List (10051)"},{value:10063,label:"User server list (10063)"},{value:10096,label:"File storage server list (10096)"},{value:10166,label:"Relay Monitor Announcement (10166)"},{value:10312,label:"Room Presence (10312)"},{value:10377,label:"Proxy Announcement (10377)"},{value:11111,label:"Transport Method Announcement (11111)"},{value:13194,label:"Wallet Info (13194)"},{value:17375,label:"Cashu Wallet Event (17375)"},{value:3e4,label:"Follow sets (30000)"},{value:30001,label:"Generic lists (30001)"},{value:30002,label:"Relay sets (30002)"},{value:30003,label:"Bookmark sets (30003)"},{value:30004,label:"Curation sets (30004)"},{value:30005,label:"Video sets (30005)"},{value:30007,label:"Kind mute sets (30007)"},{value:30008,label:"Profile Badges (30008)"},{value:30009,label:"Badge Definition (30009)"},{value:30015,label:"Interest sets (30015)"},{value:30017,label:"Create or update a stall (30017)"},{value:30018,label:"Create or update a product (30018)"},{value:30019,label:"Marketplace UI/UX (30019)"},{value:30020,label:"Product sold as an auction (30020)"},{value:30023,label:"Long-form Content (30023)"},{value:30024,label:"Draft Long-form Content (30024)"},{value:30030,label:"Emoji sets (30030)"},{value:30040,label:"Curated Publication Index (30040)"},{value:30041,label:"Curated Publication Content (30041)"},{value:30063,label:"Release artifact sets (30063)"},{value:30078,label:"Application-specific Data (30078)"},{value:30166,label:"Relay Discovery (30166)"},{value:30267,label:"App curation sets (30267)"},{value:30311,label:"Live Event (30311)"},{value:30312,label:"Interactive Room (30312)"},{value:30313,label:"Conference Event (30313)"},{value:30315,label:"User Statuses (30315)"},{value:30388,label:"Slide Set (30388)"},{value:30402,label:"Classified Listing (30402)"},{value:30403,label:"Draft Classified Listing (30403)"},{value:30617,label:"Repository announcements (30617)"},{value:30618,label:"Repository state announcements (30618)"},{value:30818,label:"Wiki article (30818)"},{value:30819,label:"Redirects (30819)"},{value:31234,label:"Draft Event (31234)"},{value:31388,label:"Link Set (31388)"},{value:31890,label:"Feed (31890)"},{value:31922,label:"Date-Based Calendar Event (31922)"},{value:31923,label:"Time-Based Calendar Event (31923)"},{value:31924,label:"Calendar (31924)"},{value:31925,label:"Calendar Event RSVP (31925)"},{value:31989,label:"Handler recommendation (31989)"},{value:31990,label:"Handler information (31990)"},{value:32267,label:"Software Application (32267)"},{value:34550,label:"Community Definition (34550)"},{value:37516,label:"Geocache listing (37516)"},{value:38172,label:"Cashu Mint Announcement (38172)"},{value:38173,label:"Fedimint Announcement (38173)"},{value:38383,label:"Peer-to-peer Order events (38383)"},{value:39089,label:"Starter packs (39089)"},{value:39092,label:"Media starter packs (39092)"},{value:39701,label:"Web bookmarks (39701)"}],Bh={0:"User Metadata",1:"Short Text Note",2:"Recommend Relay",3:"Follows",4:"Encrypted Direct Messages",5:"Event Deletion Request",6:"Repost",7:"Reaction",8:"Badge Award",9:"Chat Message",10:"Group Chat Threaded Reply",11:"Thread",12:"Group Thread Reply",13:"Seal",14:"Direct Message",15:"File Message",16:"Generic Repost",17:"Reaction to a website",20:"Picture",40:"Channel Creation",41:"Channel Metadata",42:"Channel Message",43:"Channel Hide Message",44:"Channel Mute User",1021:"Bid",1022:"Bid Confirmation",1040:"OpenTimestamps",1063:"File Metadata",1311:"Live Chat Message",1971:"Problem Tracker",1984:"Reporting",1985:"Label",4550:"Community Post Approval",5e3:"Job Request",5999:"Job Request",6e3:"Job Result",6999:"Job Result",7e3:"Job Feedback",9041:"Zap Goal",9734:"Zap Request",9735:"Zap",9882:"Highlights",1e4:"Mute list",10001:"Pin list",10002:"Relay List Metadata",10003:"Bookmarks list",10004:"Communities list",10005:"Public Chats list",10006:"Blocked Relays list",10007:"Search Relays list",10015:"Interests",10030:"User Emoji list",10050:"DM relays",10096:"File Storage Server List",13194:"Wallet Service Info",21e3:"Lightning pub RPC",22242:"Client Authentication",23194:"Wallet Request",23195:"Wallet Response",23196:"Wallet Notification",23197:"Wallet Notification",24133:"Nostr Connect",27235:"HTTP Auth",3e4:"Follow sets",30001:"Generic lists",30002:"Relay sets",30003:"Bookmark sets",30004:"Curation sets",30008:"Profile Badges",30009:"Badge Definition",30015:"Interest sets",30017:"Stall Definition",30018:"Product Definition",30019:"Marketplace UI/UX",30020:"Product sold as an auction",30023:"Long-form Content",30024:"Draft Long-form Content",30030:"Emoji sets",30078:"Application-specific Data",30311:"Live Event",30315:"User Statuses",30402:"Classified Listing",30403:"Draft Classified Listing",31922:"Date-Based Calendar Event",31923:"Time-Based Calendar Event",31924:"Calendar",31925:"Calendar Event RSVP",31989:"Handler recommendation",31990:"Handler information",34235:"Video Event Horizontal",34236:"Video Event Vertical",34550:"Community Definition"},Sh=3e5;class Fh{constructor(){this.pool=new Nn,this.eventStore=new kf,this.isConnected=!1,this.signer=null,this.relays=[...Ch]}async connect(){console.log("Starting connection to",this.relays.length,"relays...");try{this.isConnected=!0,console.log("✓ Successfully initialized relay pool"),await new Promise(e=>setTimeout(e,1e3))}catch(e){throw console.error("✗ Connection failed:",e),e}}async connectToRelay(e){console.log(`Adding relay: ${e}`);try{return this.relays.includes(e)||this.relays.push(e),console.log(`✓ Successfully added relay ${e}`),!0}catch(t){return console.error(`✗ Failed to add relay ${e}:`,t),!1}}subscribe(e,t){console.log("Creating subscription with filters:",e);const n=this.pool.subscribeMany(this.relays,e,{onevent(e){console.log("Event received:",e),t(e)},oneose(){console.log("EOSE received"),window.dispatchEvent(new CustomEvent("nostr-eose",{detail:{subscriptionId:n.id}}))}});return n}unsubscribe(e){console.log("Closing subscription"),e&&e.close&&e.close()}disconnect(){console.log("Disconnecting relay pool"),this.pool&&this.pool.close(this.relays),this.isConnected=!1}async publish(e,t=null){this.isConnected||(console.warn("Not connected to any relays, attempting to connect first"),await this.connect());try{const n=t||this.relays,r=this.pool.publish(n,e);return await Promise.allSettled(r),console.log("✓ Event published successfully"),await Th([e]),console.log("Event stored in IndexedDB"),{success:!0,okCount:1,errorCount:0}}catch(e){throw console.error("✗ Failed to publish event:",e),e}}getPool(){return this.pool}getEventStore(){return this.eventStore}getSigner(){return this.signer}setSigner(e){this.signer=e}}const Qh=new Fh,Dh="nostrCache",Rh=2,Ph="events";function $h(){return new Promise((e,t)=>{try{const n=indexedDB.open(Dh,Rh);n.onupgradeneeded=e=>{const t=n.result;e.oldVersion;let r;r=t.objectStoreNames.contains(Ph)?n.transaction.objectStore(Ph):t.createObjectStore(Ph,{keyPath:"id"}),r.indexNames.contains("byKindAuthor")||r.createIndex("byKindAuthor",["kind","pubkey"],{unique:!1}),r.indexNames.contains("byKindAuthorCreated")||r.createIndex("byKindAuthorCreated",["kind","pubkey","created_at"],{unique:!1}),r.indexNames.contains("byKind")||r.createIndex("byKind","kind",{unique:!1}),r.indexNames.contains("byAuthor")||r.createIndex("byAuthor","pubkey",{unique:!1}),r.indexNames.contains("byCreatedAt")||r.createIndex("byCreatedAt","created_at",{unique:!1})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}catch(e){console.error("Failed to open IndexedDB",e),t(e)}})}async function Uh(e){try{const t=await $h();await new Promise((n,r)=>{const i=t.transaction(Ph,"readwrite");i.oncomplete=()=>n(),i.onerror=()=>r(i.error),i.objectStore(Ph).put(e)})}catch(e){console.warn("IDB putEvent failed",e)}}async function Th(e){if(e&&0!==e.length)try{const t=await $h();await new Promise((n,r)=>{const i=t.transaction(Ph,"readwrite");i.oncomplete=()=>n(),i.onerror=()=>r(i.error);const o=i.objectStore(Ph);for(const t of e)o.put(t)}),console.log(`Stored ${e.length} events in IndexedDB`)}catch(e){console.warn("IDB putEvents failed",e)}}async function Nh(e){try{const t=await $h(),n=[];console.log("QueryEventsFromDB: Starting query with filters:",e);for(const r of e){console.log("QueryEventsFromDB: Processing filter:",r);const e=await new Promise((e,n)=>{const i=t.transaction(Ph,"readonly").objectStore(Ph),o=[];let s;if(r.kinds&&r.kinds.length>0&&r.authors&&r.authors.length>0){const e=r.kinds[0],t=r.authors[0];console.log(`QueryEventsFromDB: Using byKindAuthorCreated index for kind=${e}, author=${t.substring(0,8)}...`);const n=i.index("byKindAuthorCreated"),o=IDBKeyRange.bound([e,t,-1/0],[e,t,1/0]);s=n.openCursor(o,"prev")}else if(r.kinds&&r.kinds.length>0){console.log(`QueryEventsFromDB: Using byKind index for kind=${r.kinds[0]}`);const e=i.index("byKind");s=e.openCursor(IDBKeyRange.only(r.kinds[0]))}else if(r.authors&&r.authors.length>0){console.log(`QueryEventsFromDB: Using byAuthor index for author=${r.authors[0].substring(0,8)}...`);const e=i.index("byAuthor");s=e.openCursor(IDBKeyRange.only(r.authors[0]))}else console.log("QueryEventsFromDB: Scanning all events (no specific index)"),s=i.openCursor();s.onsuccess=t=>{const n=t.target.result;if(n){const t=n.value;let i=!0;if(r.kinds&&r.kinds.length>0&&!r.kinds.includes(t.kind)&&(i=!1),r.authors&&r.authors.length>0&&!r.authors.includes(t.pubkey)&&(i=!1),r.since&&t.created_atr.until&&(i=!1),r.ids&&r.ids.length>0&&!r.ids.includes(t.id)&&(i=!1),i&&o.push(t),r.limit&&o.length>=r.limit)return console.log(`QueryEventsFromDB: Reached limit of ${r.limit}, found ${o.length} matching events`),void e(o);n.continue()}else console.log(`QueryEventsFromDB: Cursor exhausted, found ${o.length} matching events`),e(o)},s.onerror=()=>{console.error("QueryEventsFromDB: Cursor error:",s.error),n(s.error)}});console.log(`QueryEventsFromDB: Found ${e.length} events for this filter`),n.push(...e)}return n.sort((e,t)=>t.created_at-e.created_at),console.log(`QueryEventsFromDB: Returning ${n.length} total events`),n}catch(e){return console.error("QueryEventsFromDB failed:",e),[]}}function Lh(e){try{const t=JSON.parse(e.content||"{}");return{name:t.name||t.display_name||"",picture:t.picture||"",banner:t.banner||"",about:t.about||"",nip05:t.nip05||"",lud16:t.lud16||t.lud06||""}}catch(e){return{name:"",picture:"",banner:"",about:"",nip05:"",lud16:""}}}async function Oh(e){console.log(`Starting profile fetch for pubkey: ${e}`);try{const t=await async function(e){try{const t=await $h();return await new Promise((n,r)=>{const i=t.transaction(Ph,"readonly").objectStore(Ph).index("byKindAuthorCreated"),o=IDBKeyRange.bound([0,e,-1/0],[0,e,1/0]),s=i.openCursor(o,"prev");s.onsuccess=()=>{const e=s.result;n(e?e.value:null)},s.onerror=()=>r(s.error)})}catch(e){return console.warn("IDB getLatestProfileEvent failed",e),null}}(e);if(t){console.log("Using cached profile event");return Lh(t)}}catch(e){console.warn("Failed to load cached profile",e)}try{const t=[{kinds:[0],authors:[e],limit:1}],n=await _h(t,{timeout:1e4});if(n.length>0){const t=n[0];console.log("Profile fetched:",t),await Uh(t);try{console.log("Publishing profile event to local relay:",t.id),await Qh.publish(t),console.log("Profile event successfully saved to local relay")}catch(e){console.warn("Failed to publish profile to local relay:",e)}const r=Lh(t);try{"undefined"!=typeof window&&window.dispatchEvent&&window.dispatchEvent(new CustomEvent("profile-updated",{detail:{pubkey:e,profile:r,event:t}}))}catch(e){console.warn("Failed to dispatch profile-updated event",e)}return r}return console.log("No profile found for pubkey, creating default:",e),await Mh(e)}catch(t){console.error("Failed to fetch profile:",t);try{return await Mh(e)}catch(e){return console.error("Failed to create default profile:",e),null}}}async function Mh(e){const t=`testuser${e.slice(0,6)}`,n=`${window.location.origin}/orly.png`,r={name:t,display_name:t,picture:n,about:"New ORLY user"},i={name:t,displayName:t,picture:n,about:"New ORLY user",pubkey:e};if(Qh.signer)try{const e={kind:0,content:JSON.stringify(r),tags:[],created_at:Math.floor(Date.now()/1e3)},t=await Qh.signer.signEvent(e);await Qh.publish(t),console.log("Default profile published:",t.id)}catch(e){console.warn("Failed to publish default profile:",e)}return i}async function _h(e,t={}){console.log("Starting event fetch with filters:",JSON.stringify(e,null,2)),console.log("Current relays:",Qh.relays),Qh.isConnected&&0!==Qh.relays.length||(console.warn("Client not connected, initializing..."),await Gh());const{timeout:n=3e4,useCache:r=!0}=t;if(r)try{const t=await Nh(e);t.length>0&&console.log(`Found ${t.length} cached events in IndexedDB`)}catch(e){console.warn("Failed to query cached events",e)}return new Promise((t,r)=>{const i=[],o=setTimeout(()=>{console.log(`Timeout reached after ${n}ms, returning ${i.length} events`),sub.close(),i.length>0&&Th(i).catch(e=>console.warn("Failed to cache events",e)),t(i)},n);try{const n=Math.random().toString(36).substring(7);console.log(`📤 REQ [${n}]:`,JSON.stringify(["REQ",n,...e],null,2));const r=Qh.pool.subscribeMany(Qh.relays,e,{onevent(e){console.log(`📥 EVENT received for REQ [${n}]:`,{id:e.id?.substring(0,8)+"...",kind:e.kind,pubkey:e.pubkey?.substring(0,8)+"...",created_at:e.created_at,content_preview:e.content?.substring(0,50)}),i.push(e),Uh(e).catch(e=>console.warn("Failed to cache event",e))},oneose(){console.log(`✅ EOSE received for REQ [${n}], got ${i.length} events`),clearTimeout(o),r.close(),i.length>0&&Th(i).catch(e=>console.warn("Failed to cache events",e)),t(i)}})}catch(e){clearTimeout(o),console.error("Failed to fetch events:",e),r(e)}})}async function Hh(e,t={}){const{timeout:n=1e4}=t;console.log(`Fetching event by ID: ${e}`);try{const t=[{ids:[e]}];console.log("Fetching event with filters:",t);const r=await _h(t,{timeout:n});return console.log(`Fetched ${r.length} events`),r.length>0?r[0]:null}catch(e){throw console.error("Failed to fetch event by ID:",e),e}}async function jh(e,t={}){const{timeout:n=1e4}=t;console.log(`Fetching delete events for target: ${e}`);try{const t=[{kinds:[5],"#e":[e]}];console.log("Fetching delete events with filters:",t);const r=await _h(t,{timeout:n});return console.log(`Fetched ${r.length} delete events`),r}catch(e){throw console.error("Failed to fetch delete events:",e),e}}async function Gh(){await Qh.connect()}async function qh(e,t={}){const{timeout:n=3e4,cacheFirst:r=!0,cacheOnly:i=!1}=t;let o=[];if(r||i)try{if(o=await Nh(e),console.log(`Found ${o.length} events in cache`),i||o.length>0)return o}catch(e){console.warn("Failed to query cache",e)}if(!i){const t=await _h(e,{timeout:n,useCache:!1});return console.log(`Fetched ${t.length} events from relay`),t}return o}async function Kh(){try{const e=await $h(),t=e.transaction(Ph,"readonly").objectStore(Ph),n=await new Promise((e,n)=>{const r=t.getAll();r.onsuccess=()=>e(r.result),r.onerror=()=>n(r.error)}),r=n.reduce((e,t)=>(e[t.kind]=(e[t.kind]||0)+1,e),{});return console.log("===== IndexedDB Contents ====="),console.log(`Total events: ${n.length}`),console.log("Events by kind:",r),console.log("Kind 0 events:",n.filter(e=>0===e.kind)),console.log("All event IDs:",n.map(e=>({id:e.id.substring(0,8),kind:e.kind,pubkey:e.pubkey.substring(0,8)}))),console.log("=============================="),{total:n.length,byKind:r,events:n}}catch(e){return console.error("Failed to debug IndexedDB:",e),null}} +function fh(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function hh(e,t){return!!Array.isArray(t)&&(0===t.length||(e?t.every(e=>"string"==typeof e):t.every(e=>Number.isSafeInteger(e))))}function ph(e,t){if("string"!=typeof t)throw new Error(`${e}: string expected`);return!0}function gh(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function mh(e){if(!Array.isArray(e))throw new Error("array expected")}function yh(e,t){if(!hh(!0,t))throw new Error(`${e}: array of strings expected`)}Gf.BASE._setWindowSize(8);const wh=(e,t)=>0===t?e:wh(t,e%t),vh=(e,t)=>e+(t-wh(e,t)),Ah=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function bh(e,t,n,r){if(mh(e),t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(vh(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${vh(t,n)}`);let i=0,o=0;const s=Ah[t],a=Ah[n]-1,l=[];for(const r of e){if(gh(r),r>=s)throw new Error(`convertRadix2: invalid data word=${r} from=${t}`);if(i=i<32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${t}`);for(o+=t;o>=n;o-=n)l.push((i>>o-n&a)>>>0);const e=Ah[o];if(void 0===e)throw new Error("invalid carry");i&=e-1}if(i=i<=t)throw new Error("Excess padding");if(!r&&i>0)throw new Error(`Non-zero padding: ${i}`);return r&&o>0&&l.push(i>>>0),l}const kh=(()=>"function"==typeof Uint8Array.from([]).toBase64&&"function"==typeof Uint8Array.fromBase64)()?{encode:e=>(function(e,...t){if(!fh(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}(e),e.toBase64()),decode:e=>((e,t)=>{ph("base64",e);const n=t?/^[A-Za-z0-9=_-]+$/:/^[A-Za-z0-9=+/]+$/,r=t?"base64url":"base64";if(e.length>0&&!n.test(e))throw new Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,lastChunkHandling:"strict"})})(e,!1)}:function(...e){const t=e=>e,n=(e,t)=>n=>e(t(n));return{encode:e.map(e=>e.encode).reduceRight(n,t),decode:e.map(e=>e.decode).reduce(n,t)}}(function(e,t=!1){if(gh(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(vh(8,e)>32||vh(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!fh(n))throw new Error("radix2.encode input should be Uint8Array");return bh(Array.from(n),8,e,!t)},decode:n=>(function(e,t){if(!hh(!1,t))throw new Error(`${e}: array of numbers expected`)}("radix2.decode",n),Uint8Array.from(bh(n,e,8,t)))}}(6),function(e){const t="string"==typeof e?e.split(""):e,n=t.length;yh("alphabet",t);const r=new Map(t.map((e,t)=>[e,t]));return{encode:r=>(mh(r),r.map(r=>{if(!Number.isSafeInteger(r)||r<0||r>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${r}". Allowed: ${e}`);return t[r]})),decode:t=>(mh(t),t.map(t=>{ph("alphabet.decode",t);const n=r.get(t);if(void 0===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n}))}}("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),function(e,t="="){return gh(e),ph("padding",t),{encode(n){for(yh("padding.encode",n);n.length*e%8;)n.push(t);return n},decode(n){yh("padding.decode",n);let r=n.length;if(r*e%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;r>0&&n[r-1]===t;r--){if((r-1)*e%8==0)throw new Error("padding: invalid, string has too much padding")}return n.slice(0,r)}}}(6),function(e=""){return ph("join",e),{encode:t=>(yh("join.decode",t),t.join(e)),decode:t=>(ph("join.decode",t),t.split(e))}}(""));function Ih(e){return Gf.fromHex(e).toHex().substring(2)}const Eh=new TextDecoder("utf-8"),Ch=new TextEncoder;class xh{log=Dd.extend("SerialPortSigner");writer=null;pubkey;get isConnected(){return!!this.writer}verifyEvent=mi;nip04;constructor(){this.nip04={encrypt:this.nip04Encrypt.bind(this),decrypt:this.nip04Decrypt.bind(this)}}lastCommand=null;async callMethodOnDevice(e,t,n={}){if(!xh.SUPPORTED)throw new Error("Serial devices are not supported");if(this.writer||await this.connectToDevice(n),this.lastCommand)throw new Error("Previous command to device still pending!");const r=Cf();return this.lastCommand=r,this.sendCommand(e,t),setTimeout(()=>{r.reject(new Error("Device timeout")),this.lastCommand===r&&(this.lastCommand=null)},6e3),this.lastCommand}async connectToDevice({onConnect:e,onDisconnect:t,onError:n,onDone:r}){let i,o=await window.navigator.serial.requestPort();await o.open({baudRate:9600}),await(e=>new Promise(t=>setTimeout(t,e)))(1e3),(async()=>{for(;o&&o.readable;){const e=new window.TextDecoderStream;o.readable.pipeTo(e.writable),i=e.readable.getReader();const t=this.readFromSerialPort(i);try{for(;;){const{value:e,done:n}=await t("\n");if(e){const{method:t,data:n}=this.parseResponse(e);if("/ping"===t&&this.log("Pong"),-1===xh.PUBLIC_METHODS.indexOf(t))continue;this.log("Received: ",t,n),this.lastCommand&&(this.lastCommand.resolve(n),this.lastCommand=null)}if(n)return this.lastCommand=null,this.writer=null,void(r&&r())}}catch(e){if(e instanceof Error)throw this.writer=null,n&&n(e),this.lastCommand&&(this.lastCommand.reject(e),this.lastCommand=null),e}}})();const s=new window.TextEncoderStream;s.readable.pipeTo(o.writable),this.writer=s.writable.getWriter(),await this.sendCommand(xh.METHOD_PING),await this.sendCommand(xh.METHOD_PING,[window.location.host]),e&&e(),o.addEventListener("disconnect",()=>{this.log("Disconnected"),this.lastCommand=null,this.writer=null,t&&t()})}async sendCommand(e,t=[]){if(!this.writer)return;this.log("Send command",e,t);const n=[e].concat(t).join(" ");await this.writer.write(n+"\n")}readFromSerialPort(e){let t,n=[];return async(r="\n")=>{if(n.length)return{value:n.shift().trim(),done:!1};const i=[];for(t&&(i.push(t),t=void 0);;){const{value:o,done:s}=await e.read();if(o){const e=o.split(r);if(e.length>1)return i.push(e.shift()),t=e.pop(),n=e,{value:i.join("").trim(),done:!1};i.push(o)}if(s)return{value:i.join("").trim(),done:!0}}}}parseResponse(e){const t=e.split(" ")[0];return{method:t,data:e.substring(t.length).trim()}}async nip04Encrypt(e,t){const n=zu(await this.callMethodOnDevice(xh.METHOD_SHARED_SECRET,[Ih(e)]));let r=Uint8Array.from(td(16)),i=Ch.encode(t),o=await crypto.subtle.importKey("raw",n,{name:"AES-CBC"},!1,["encrypt"]),s=await crypto.subtle.encrypt({name:"AES-CBC",iv:r},o,i);return`${kh.encode(new Uint8Array(s))}?iv=${kh.encode(new Uint8Array(r.buffer))}`}async nip04Decrypt(e,t){let[n,r]=t.split("?iv=");const i=zu(await this.callMethodOnDevice(xh.METHOD_SHARED_SECRET,[Ih(e)]));let o=await crypto.subtle.importKey("raw",i,{name:"AES-CBC"},!1,["decrypt"]),s=kh.decode(n),a=kh.decode(r),l=await crypto.subtle.decrypt({name:"AES-CBC",iv:a},o,s);return Eh.decode(l)}async getPublicKey(){const e=await this.callMethodOnDevice(xh.METHOD_PUBLIC_KEY,[]);return this.pubkey=e,e}async restore(e){await this.callMethodOnDevice(xh.METHOD_RESTORE,[Hu(e)])}async signEvent(e){const t=e.pubkey||this.pubkey;if(!t)throw new Error("Unknown signer pubkey");const n={...e,id:di({...e,pubkey:t})},r=await this.callMethodOnDevice(xh.METHOD_SIGN_MESSAGE,[n.id]),i={...n,sig:r,pubkey:t};if(!this.verifyEvent(i))throw new Error("Invalid signature");return i}ping(){this.sendCommand(xh.METHOD_PING,[window.location.host])}static SUPPORTED="navigator"in globalThis&&!!navigator.serial;static METHOD_PING="/ping";static METHOD_LOG="/log";static METHOD_SIGN_MESSAGE="/sign-message";static METHOD_SHARED_SECRET="/shared-secret";static METHOD_PUBLIC_KEY="/public-key";static METHOD_RESTORE="/restore";static PUBLIC_METHODS=[xh.METHOD_PUBLIC_KEY,xh.METHOD_SIGN_MESSAGE,xh.METHOD_SHARED_SECRET,xh.METHOD_RESTORE]}const Bh=[`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`],Sh=[{value:0,label:"User Metadata (0)"},{value:3,label:"Follows (3)"},{value:1e4,label:"Mute list (10000)"},{value:10001,label:"Pin list (10001)"},{value:10002,label:"Relay List Metadata (10002)"},{value:10003,label:"Bookmark list (10003)"},{value:10004,label:"Communities list (10004)"},{value:10005,label:"Public chats list (10005)"},{value:10006,label:"Blocked relays list (10006)"},{value:10007,label:"Search relays list (10007)"},{value:10009,label:"User groups (10009)"},{value:10012,label:"Favorite relays list (10012)"},{value:10013,label:"Private event relay list (10013)"},{value:10015,label:"Interests list (10015)"},{value:10019,label:"Nutzap Mint Recommendation (10019)"},{value:10020,label:"Media follows (10020)"},{value:10030,label:"User emoji list (10030)"},{value:10050,label:"Relay list to receive DMs (10050)"},{value:10051,label:"KeyPackage Relays List (10051)"},{value:10063,label:"User server list (10063)"},{value:10096,label:"File storage server list (10096)"},{value:10166,label:"Relay Monitor Announcement (10166)"},{value:10312,label:"Room Presence (10312)"},{value:10377,label:"Proxy Announcement (10377)"},{value:11111,label:"Transport Method Announcement (11111)"},{value:13194,label:"Wallet Info (13194)"},{value:17375,label:"Cashu Wallet Event (17375)"},{value:3e4,label:"Follow sets (30000)"},{value:30001,label:"Generic lists (30001)"},{value:30002,label:"Relay sets (30002)"},{value:30003,label:"Bookmark sets (30003)"},{value:30004,label:"Curation sets (30004)"},{value:30005,label:"Video sets (30005)"},{value:30007,label:"Kind mute sets (30007)"},{value:30008,label:"Profile Badges (30008)"},{value:30009,label:"Badge Definition (30009)"},{value:30015,label:"Interest sets (30015)"},{value:30017,label:"Create or update a stall (30017)"},{value:30018,label:"Create or update a product (30018)"},{value:30019,label:"Marketplace UI/UX (30019)"},{value:30020,label:"Product sold as an auction (30020)"},{value:30023,label:"Long-form Content (30023)"},{value:30024,label:"Draft Long-form Content (30024)"},{value:30030,label:"Emoji sets (30030)"},{value:30040,label:"Curated Publication Index (30040)"},{value:30041,label:"Curated Publication Content (30041)"},{value:30063,label:"Release artifact sets (30063)"},{value:30078,label:"Application-specific Data (30078)"},{value:30166,label:"Relay Discovery (30166)"},{value:30267,label:"App curation sets (30267)"},{value:30311,label:"Live Event (30311)"},{value:30312,label:"Interactive Room (30312)"},{value:30313,label:"Conference Event (30313)"},{value:30315,label:"User Statuses (30315)"},{value:30388,label:"Slide Set (30388)"},{value:30402,label:"Classified Listing (30402)"},{value:30403,label:"Draft Classified Listing (30403)"},{value:30617,label:"Repository announcements (30617)"},{value:30618,label:"Repository state announcements (30618)"},{value:30818,label:"Wiki article (30818)"},{value:30819,label:"Redirects (30819)"},{value:31234,label:"Draft Event (31234)"},{value:31388,label:"Link Set (31388)"},{value:31890,label:"Feed (31890)"},{value:31922,label:"Date-Based Calendar Event (31922)"},{value:31923,label:"Time-Based Calendar Event (31923)"},{value:31924,label:"Calendar (31924)"},{value:31925,label:"Calendar Event RSVP (31925)"},{value:31989,label:"Handler recommendation (31989)"},{value:31990,label:"Handler information (31990)"},{value:32267,label:"Software Application (32267)"},{value:34550,label:"Community Definition (34550)"},{value:37516,label:"Geocache listing (37516)"},{value:38172,label:"Cashu Mint Announcement (38172)"},{value:38173,label:"Fedimint Announcement (38173)"},{value:38383,label:"Peer-to-peer Order events (38383)"},{value:39089,label:"Starter packs (39089)"},{value:39092,label:"Media starter packs (39092)"},{value:39701,label:"Web bookmarks (39701)"}],Fh={0:"User Metadata",1:"Short Text Note",2:"Recommend Relay",3:"Follows",4:"Encrypted Direct Messages",5:"Event Deletion Request",6:"Repost",7:"Reaction",8:"Badge Award",9:"Chat Message",10:"Group Chat Threaded Reply",11:"Thread",12:"Group Thread Reply",13:"Seal",14:"Direct Message",15:"File Message",16:"Generic Repost",17:"Reaction to a website",20:"Picture",40:"Channel Creation",41:"Channel Metadata",42:"Channel Message",43:"Channel Hide Message",44:"Channel Mute User",1021:"Bid",1022:"Bid Confirmation",1040:"OpenTimestamps",1063:"File Metadata",1311:"Live Chat Message",1971:"Problem Tracker",1984:"Reporting",1985:"Label",4550:"Community Post Approval",5e3:"Job Request",5999:"Job Request",6e3:"Job Result",6999:"Job Result",7e3:"Job Feedback",9041:"Zap Goal",9734:"Zap Request",9735:"Zap",9882:"Highlights",1e4:"Mute list",10001:"Pin list",10002:"Relay List Metadata",10003:"Bookmarks list",10004:"Communities list",10005:"Public Chats list",10006:"Blocked Relays list",10007:"Search Relays list",10015:"Interests",10030:"User Emoji list",10050:"DM relays",10096:"File Storage Server List",13194:"Wallet Service Info",21e3:"Lightning pub RPC",22242:"Client Authentication",23194:"Wallet Request",23195:"Wallet Response",23196:"Wallet Notification",23197:"Wallet Notification",24133:"Nostr Connect",27235:"HTTP Auth",3e4:"Follow sets",30001:"Generic lists",30002:"Relay sets",30003:"Bookmark sets",30004:"Curation sets",30008:"Profile Badges",30009:"Badge Definition",30015:"Interest sets",30017:"Stall Definition",30018:"Product Definition",30019:"Marketplace UI/UX",30020:"Product sold as an auction",30023:"Long-form Content",30024:"Draft Long-form Content",30030:"Emoji sets",30078:"Application-specific Data",30311:"Live Event",30315:"User Statuses",30402:"Classified Listing",30403:"Draft Classified Listing",31922:"Date-Based Calendar Event",31923:"Time-Based Calendar Event",31924:"Calendar",31925:"Calendar Event RSVP",31989:"Handler recommendation",31990:"Handler information",34235:"Video Event Horizontal",34236:"Video Event Vertical",34550:"Community Definition"},Qh=3e5;class Dh{constructor(){this.pool=new On,this.eventStore=new Ef,this.isConnected=!1,this.signer=null,this.relays=[...Bh]}async connect(){console.log("Starting connection to",this.relays.length,"relays...");try{this.isConnected=!0,console.log("✓ Successfully initialized relay pool"),await new Promise(e=>setTimeout(e,1e3))}catch(e){throw console.error("✗ Connection failed:",e),e}}async connectToRelay(e){console.log(`Adding relay: ${e}`);try{return this.relays.includes(e)||this.relays.push(e),console.log(`✓ Successfully added relay ${e}`),!0}catch(t){return console.error(`✗ Failed to add relay ${e}:`,t),!1}}subscribe(e,t){console.log("Creating subscription with filters:",e);const n=this.pool.subscribeMany(this.relays,e,{onevent(e){console.log("Event received:",e),t(e)},oneose(){console.log("EOSE received"),window.dispatchEvent(new CustomEvent("nostr-eose",{detail:{subscriptionId:n.id}}))}});return n}unsubscribe(e){console.log("Closing subscription"),e&&e.close&&e.close()}disconnect(){console.log("Disconnecting relay pool"),this.pool&&this.pool.close(this.relays),this.isConnected=!1}async publish(e,t=null){this.isConnected||(console.warn("Not connected to any relays, attempting to connect first"),await this.connect());try{const n=t||this.relays,r=this.pool.publish(n,e);return await Promise.allSettled(r),console.log("✓ Event published successfully"),await Lh([e]),console.log("Event stored in IndexedDB"),{success:!0,okCount:1,errorCount:0}}catch(e){throw console.error("✗ Failed to publish event:",e),e}}getPool(){return this.pool}getEventStore(){return this.eventStore}getSigner(){return this.signer}setSigner(e){this.signer=e}}const Rh=new Dh,$h="nostrCache",Ph=2,Uh="events";function Th(){return new Promise((e,t)=>{try{const n=indexedDB.open($h,Ph);n.onupgradeneeded=e=>{const t=n.result;e.oldVersion;let r;r=t.objectStoreNames.contains(Uh)?n.transaction.objectStore(Uh):t.createObjectStore(Uh,{keyPath:"id"}),r.indexNames.contains("byKindAuthor")||r.createIndex("byKindAuthor",["kind","pubkey"],{unique:!1}),r.indexNames.contains("byKindAuthorCreated")||r.createIndex("byKindAuthorCreated",["kind","pubkey","created_at"],{unique:!1}),r.indexNames.contains("byKind")||r.createIndex("byKind","kind",{unique:!1}),r.indexNames.contains("byAuthor")||r.createIndex("byAuthor","pubkey",{unique:!1}),r.indexNames.contains("byCreatedAt")||r.createIndex("byCreatedAt","created_at",{unique:!1})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}catch(e){console.error("Failed to open IndexedDB",e),t(e)}})}async function Nh(e){try{const t=await Th();await new Promise((n,r)=>{const i=t.transaction(Uh,"readwrite");i.oncomplete=()=>n(),i.onerror=()=>r(i.error),i.objectStore(Uh).put(e)})}catch(e){console.warn("IDB putEvent failed",e)}}async function Lh(e){if(e&&0!==e.length)try{const t=await Th();await new Promise((n,r)=>{const i=t.transaction(Uh,"readwrite");i.oncomplete=()=>n(),i.onerror=()=>r(i.error);const o=i.objectStore(Uh);for(const t of e)o.put(t)}),console.log(`Stored ${e.length} events in IndexedDB`)}catch(e){console.warn("IDB putEvents failed",e)}}async function Oh(e){try{const t=await Th(),n=[];console.log("QueryEventsFromDB: Starting query with filters:",e);for(const r of e){console.log("QueryEventsFromDB: Processing filter:",r);const e=await new Promise((e,n)=>{const i=t.transaction(Uh,"readonly").objectStore(Uh),o=[];let s;if(r.kinds&&r.kinds.length>0&&r.authors&&r.authors.length>0){const e=r.kinds[0],t=r.authors[0];console.log(`QueryEventsFromDB: Using byKindAuthorCreated index for kind=${e}, author=${t.substring(0,8)}...`);const n=i.index("byKindAuthorCreated"),o=IDBKeyRange.bound([e,t,-1/0],[e,t,1/0]);s=n.openCursor(o,"prev")}else if(r.kinds&&r.kinds.length>0){console.log(`QueryEventsFromDB: Using byKind index for kind=${r.kinds[0]}`);const e=i.index("byKind");s=e.openCursor(IDBKeyRange.only(r.kinds[0]))}else if(r.authors&&r.authors.length>0){console.log(`QueryEventsFromDB: Using byAuthor index for author=${r.authors[0].substring(0,8)}...`);const e=i.index("byAuthor");s=e.openCursor(IDBKeyRange.only(r.authors[0]))}else console.log("QueryEventsFromDB: Scanning all events (no specific index)"),s=i.openCursor();s.onsuccess=t=>{const n=t.target.result;if(n){const t=n.value;let i=!0;if(r.kinds&&r.kinds.length>0&&!r.kinds.includes(t.kind)&&(i=!1),r.authors&&r.authors.length>0&&!r.authors.includes(t.pubkey)&&(i=!1),r.since&&t.created_atr.until&&(i=!1),r.ids&&r.ids.length>0&&!r.ids.includes(t.id)&&(i=!1),i&&o.push(t),r.limit&&o.length>=r.limit)return console.log(`QueryEventsFromDB: Reached limit of ${r.limit}, found ${o.length} matching events`),void e(o);n.continue()}else console.log(`QueryEventsFromDB: Cursor exhausted, found ${o.length} matching events`),e(o)},s.onerror=()=>{console.error("QueryEventsFromDB: Cursor error:",s.error),n(s.error)}});console.log(`QueryEventsFromDB: Found ${e.length} events for this filter`),n.push(...e)}return n.sort((e,t)=>t.created_at-e.created_at),console.log(`QueryEventsFromDB: Returning ${n.length} total events`),n}catch(e){return console.error("QueryEventsFromDB failed:",e),[]}}function Mh(e){try{const t=JSON.parse(e.content||"{}");return{name:t.name||t.display_name||"",picture:t.picture||"",banner:t.banner||"",about:t.about||"",nip05:t.nip05||"",lud16:t.lud16||t.lud06||""}}catch(e){return{name:"",picture:"",banner:"",about:"",nip05:"",lud16:""}}}async function _h(e){console.log(`Starting profile fetch for pubkey: ${e}`);try{const t=await async function(e){try{const t=await Th();return await new Promise((n,r)=>{const i=t.transaction(Uh,"readonly").objectStore(Uh).index("byKindAuthorCreated"),o=IDBKeyRange.bound([0,e,-1/0],[0,e,1/0]),s=i.openCursor(o,"prev");s.onsuccess=()=>{const e=s.result;n(e?e.value:null)},s.onerror=()=>r(s.error)})}catch(e){return console.warn("IDB getLatestProfileEvent failed",e),null}}(e);if(t){console.log("Using cached profile event");return Mh(t)}}catch(e){console.warn("Failed to load cached profile",e)}try{const t=[{kinds:[0],authors:[e],limit:1}],n=await jh(t,{timeout:1e4});if(n.length>0){const t=n[0];console.log("Profile fetched:",t),await Nh(t);try{console.log("Publishing profile event to local relay:",t.id),await Rh.publish(t),console.log("Profile event successfully saved to local relay")}catch(e){console.warn("Failed to publish profile to local relay:",e)}const r=Mh(t);try{"undefined"!=typeof window&&window.dispatchEvent&&window.dispatchEvent(new CustomEvent("profile-updated",{detail:{pubkey:e,profile:r,event:t}}))}catch(e){console.warn("Failed to dispatch profile-updated event",e)}return r}return console.log("No profile found for pubkey, creating default:",e),await Hh(e)}catch(t){console.error("Failed to fetch profile:",t);try{return await Hh(e)}catch(e){return console.error("Failed to create default profile:",e),null}}}async function Hh(e){const t=`testuser${e.slice(0,6)}`,n=`${window.location.origin}/orly.png`,r={name:t,display_name:t,picture:n,about:"New ORLY user"},i={name:t,displayName:t,picture:n,about:"New ORLY user",pubkey:e};if(Rh.signer)try{const e={kind:0,content:JSON.stringify(r),tags:[],created_at:Math.floor(Date.now()/1e3)},t=await Rh.signer.signEvent(e);await Rh.publish(t),console.log("Default profile published:",t.id)}catch(e){console.warn("Failed to publish default profile:",e)}return i}async function jh(e,t={}){console.log("Starting event fetch with filters:",JSON.stringify(e,null,2)),console.log("Current relays:",Rh.relays),Rh.isConnected&&0!==Rh.relays.length||(console.warn("Client not connected, initializing..."),await Kh());const{timeout:n=3e4,useCache:r=!0}=t;if(r)try{const t=await Oh(e);t.length>0&&console.log(`Found ${t.length} cached events in IndexedDB`)}catch(e){console.warn("Failed to query cached events",e)}return new Promise((t,r)=>{const i=[],o=setTimeout(()=>{console.log(`Timeout reached after ${n}ms, returning ${i.length} events`),sub.close(),i.length>0&&Lh(i).catch(e=>console.warn("Failed to cache events",e)),t(i)},n);try{const n=Math.random().toString(36).substring(7);console.log(`📤 REQ [${n}]:`,JSON.stringify(["REQ",n,...e],null,2));const r=Rh.pool.subscribeMany(Rh.relays,e,{onevent(e){console.log(`📥 EVENT received for REQ [${n}]:`,{id:e.id?.substring(0,8)+"...",kind:e.kind,pubkey:e.pubkey?.substring(0,8)+"...",created_at:e.created_at,content_preview:e.content?.substring(0,50)}),i.push(e),Nh(e).catch(e=>console.warn("Failed to cache event",e))},oneose(){console.log(`✅ EOSE received for REQ [${n}], got ${i.length} events`),clearTimeout(o),r.close(),i.length>0&&Lh(i).catch(e=>console.warn("Failed to cache events",e)),t(i)}})}catch(e){clearTimeout(o),console.error("Failed to fetch events:",e),r(e)}})}async function Gh(e,t={}){const{timeout:n=1e4}=t;console.log(`Fetching event by ID: ${e}`);try{const t=[{ids:[e]}];console.log("Fetching event with filters:",t);const r=await jh(t,{timeout:n});return console.log(`Fetched ${r.length} events`),r.length>0?r[0]:null}catch(e){throw console.error("Failed to fetch event by ID:",e),e}}async function qh(e,t={}){const{timeout:n=1e4}=t;console.log(`Fetching delete events for target: ${e}`);try{const t=[{kinds:[5],"#e":[e]}];console.log("Fetching delete events with filters:",t);const r=await jh(t,{timeout:n});return console.log(`Fetched ${r.length} delete events`),r}catch(e){throw console.error("Failed to fetch delete events:",e),e}}async function Kh(){await Rh.connect()}async function Jh(e,t={}){const{timeout:n=3e4,cacheFirst:r=!0,cacheOnly:i=!1}=t;let o=[];if(r||i)try{if(o=await Oh(e),console.log(`Found ${o.length} events in cache`),i||o.length>0)return o}catch(e){console.warn("Failed to query cache",e)}if(!i){const t=await jh(e,{timeout:n,useCache:!1});return console.log(`Fetched ${t.length} events from relay`),t}return o}async function Vh(){try{const e=await Th(),t=e.transaction(Uh,"readonly").objectStore(Uh),n=await new Promise((e,n)=>{const r=t.getAll();r.onsuccess=()=>e(r.result),r.onerror=()=>n(r.error)}),r=n.reduce((e,t)=>(e[t.kind]=(e[t.kind]||0)+1,e),{});return console.log("===== IndexedDB Contents ====="),console.log(`Total events: ${n.length}`),console.log("Events by kind:",r),console.log("Kind 0 events:",n.filter(e=>0===e.kind)),console.log("All event IDs:",n.map(e=>({id:e.id.substring(0,8),kind:e.kind,pubkey:e.pubkey.substring(0,8)}))),console.log("=============================="),{total:n.length,byKind:r,events:n}}catch(e){return console.error("Failed to debug IndexedDB:",e),null}} /*! * hash-wasm (https://www.npmjs.com/package/hash-wasm) * (c) Dani Biro * @license MIT - */function Jh(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{l(r.next(e))}catch(e){o(e)}}function a(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((r=r.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class Vh{constructor(){this.mutex=Promise.resolve()}lock(){let e=()=>{};return this.mutex=this.mutex.then(()=>new Promise(e)),new Promise(t=>{e=t})}dispatch(e){return Jh(this,void 0,void 0,function*(){const t=yield this.lock();try{return yield Promise.resolve(e())}finally{t()}})}}var Yh;const zh="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,Wh=null!==(Yh=zh.Buffer)&&void 0!==Yh?Yh:null,Zh=zh.TextEncoder?new zh.TextEncoder:null;function Xh(e,t){return(15&e)+(e>>6|e>>3&8)<<4|(15&t)+(t>>6|t>>3&8)}function ep(e,t){const n=t.length>>1;for(let r=0;r>>4;e[r++]=n>9?n+tp:n+np,n=15&t[i],e[r++]=n>9?n+tp:n+np}return String.fromCharCode.apply(null,e)}const ip=null!==Wh?e=>{if("string"==typeof e){const t=Wh.from(e,"utf8");return new Uint8Array(t.buffer,t.byteOffset,t.length)}if(Wh.isBuffer(e))return new Uint8Array(e.buffer,e.byteOffset,e.length);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Invalid data type!")}:e=>{if("string"==typeof e)return Zh.encode(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Invalid data type!")},op="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",sp=new Uint8Array(256);for(let e=0;e<64;e++)sp[op.charCodeAt(e)]=e;function ap(e,t=!0){const n=e.length,r=n%3,i=[],o=n-r;for(let t=0;t>18&63)+op.charAt(n>>12&63)+op.charAt(n>>6&63)+op.charAt(63&n);i.push(r)}if(1===r){const r=e[n-1],o=op.charAt(r>>2),s=op.charAt(r<<4&63);i.push(`${o}${s}`),t&&i.push("==")}else if(2===r){const r=(e[n-2]<<8)+e[n-1],o=op.charAt(r>>10),s=op.charAt(r>>4&63),a=op.charAt(r<<2&63);i.push(`${o}${s}${a}`),t&&i.push("=")}return i.join("")}function lp(e){const t=function(e){let t=Math.floor(.75*e.length);const n=e.length;return"="===e[n-1]&&(t-=1,"="===e[n-2]&&(t-=1)),t}(e),n=e.length,r=new Uint8Array(t);let i=0;for(let t=0;t>4,i+=1,r[i]=(15&o)<<4|s>>2,i+=1,r[i]=(3&s)<<6|63&a,i+=1}return r}const cp=16384,up=new Vh,dp=new Map;function fp(e,t){return Jh(this,void 0,void 0,function*(){let n=null,r=null,i=!1;if("undefined"==typeof WebAssembly)throw new Error("WebAssembly is not supported in this environment!");const o=()=>new DataView(n.exports.memory.buffer).getUint32(n.exports.STATE_SIZE,!0),s=up.dispatch(()=>Jh(this,void 0,void 0,function*(){if(!dp.has(e.name)){const t=lp(e.data),n=WebAssembly.compile(t);dp.set(e.name,n)}const t=yield dp.get(e.name);n=yield WebAssembly.instantiate(t,{})})),a=(e=null)=>{i=!0,n.exports.Hash_Init(e)},l=e=>{if(!i)throw new Error("update() called before init()");(e=>{let t=0;for(;t{if(!i)throw new Error("digest() called before init()");return i=!1,n.exports.Hash_Final(o),"binary"===e?r.slice(0,t):rp(c,r,t)},d=e=>"string"==typeof e?e.length<4096:e.byteLength!0;break;case"blake2b":case"blake2s":f=(e,t)=>t<=512&&d(e);break;case"blake3":f=(e,t)=>0===t&&d(e);break;case"xxhash64":case"xxhash3":case"xxhash128":case"crc64":f=()=>!1}return yield(()=>Jh(this,void 0,void 0,function*(){n||(yield s);const e=n.exports.Hash_GetBuffer(),t=n.exports.memory.buffer;r=new Uint8Array(t,e,cp)}))(),{getMemory:()=>r,writeMemory:(e,t=0)=>{r.set(e,t)},getExports:()=>n.exports,setMemorySize:e=>{n.exports.Hash_SetMemorySize(e);const t=n.exports.Hash_GetBuffer(),i=n.exports.memory.buffer;r=new Uint8Array(i,t,e)},init:a,update:l,digest:u,save:()=>{if(!i)throw new Error("save() can only be called after init() and before digest()");const t=n.exports.Hash_GetState(),r=o(),s=n.exports.memory.buffer,a=new Uint8Array(s,t,r),l=new Uint8Array(4+r);return ep(l,e.hash),l.set(a,4),l},load:t=>{if(!(t instanceof Uint8Array))throw new Error("load() expects an Uint8Array generated by save()");const r=n.exports.Hash_GetState(),s=o(),a=4+s,l=n.exports.memory.buffer;if(t.length!==a)throw new Error(`Bad state length (expected ${a} bytes, got ${t.length})`);if(!function(e,t){if(e.length!==2*t.length)return!1;for(let n=0;n{if(!f(e,i))return a(i),l(e),u("hex",o);const s=ip(e);return r.set(s),n.exports.Hash_Calculate(s.length,i,o),rp(c,r,t)},hashLength:t}})}new Vh;var hp={name:"argon2",data:"AGFzbQEAAAABKQVgAX8Bf2AAAX9gEH9/f39/f39/f39/f39/f38AYAR/f39/AGACf38AAwYFAAECAwQFBgEBAoCAAgYIAX8BQZCoBAsHQQQGbWVtb3J5AgASSGFzaF9TZXRNZW1vcnlTaXplAAAOSGFzaF9HZXRCdWZmZXIAAQ5IYXNoX0NhbGN1bGF0ZQAECvEyBVgBAn9BACEBAkAgAEEAKAKICCICRg0AAkAgACACayIAQRB2IABBgIB8cSAASWoiAEAAQX9HDQBB/wHADwtBACEBQQBBACkDiAggAEEQdK18NwOICAsgAcALcAECfwJAQQAoAoAIIgANAEEAPwBBEHQiADYCgAhBACgCiAgiAUGAgCBGDQACQEGAgCAgAWsiAEEQdiAAQYCAfHEgAElqIgBAAEF/Rw0AQQAPC0EAQQApA4gIIABBEHStfDcDiAhBACgCgAghAAsgAAvcDgECfiAAIAQpAwAiECAAKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAMIBAgDCkDAIVCIIkiEDcDACAIIBAgCCkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgBCAQIAQpAwCFQiiJIhA3AwAgACAQIAApAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIAwgECAMKQMAhUIwiSIQNwMAIAggECAIKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAEIBAgBCkDAIVCAYk3AwAgASAFKQMAIhAgASkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgDSAQIA0pAwCFQiCJIhA3AwAgCSAQIAkpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAUgECAFKQMAhUIoiSIQNwMAIAEgECABKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACANIBAgDSkDAIVCMIkiEDcDACAJIBAgCSkDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgBSAQIAUpAwCFQgGJNwMAIAIgBikDACIQIAIpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIA4gECAOKQMAhUIgiSIQNwMAIAogECAKKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAGIBAgBikDAIVCKIkiEDcDACACIBAgAikDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgDiAQIA4pAwCFQjCJIhA3AwAgCiAQIAopAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIAYgECAGKQMAhUIBiTcDACADIAcpAwAiECADKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAPIBAgDykDAIVCIIkiEDcDACALIBAgCykDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgByAQIAcpAwCFQiiJIhA3AwAgAyAQIAMpAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIA8gECAPKQMAhUIwiSIQNwMAIAsgECALKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAHIBAgBykDAIVCAYk3AwAgACAFKQMAIhAgACkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgDyAQIA8pAwCFQiCJIhA3AwAgCiAQIAopAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAUgECAFKQMAhUIoiSIQNwMAIAAgECAAKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAPIBAgDykDAIVCMIkiEDcDACAKIBAgCikDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgBSAQIAUpAwCFQgGJNwMAIAEgBikDACIQIAEpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAwgECAMKQMAhUIgiSIQNwMAIAsgECALKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAGIBAgBikDAIVCKIkiEDcDACABIBAgASkDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgDCAQIAwpAwCFQjCJIhA3AwAgCyAQIAspAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIAYgECAGKQMAhUIBiTcDACACIAcpAwAiECACKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACANIBAgDSkDAIVCIIkiEDcDACAIIBAgCCkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgByAQIAcpAwCFQiiJIhA3AwAgAiAQIAIpAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIA0gECANKQMAhUIwiSIQNwMAIAggECAIKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAHIBAgBykDAIVCAYk3AwAgAyAEKQMAIhAgAykDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgDiAQIA4pAwCFQiCJIhA3AwAgCSAQIAkpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAQgECAEKQMAhUIoiSIQNwMAIAMgECADKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAOIBAgDikDAIVCMIkiEDcDACAJIBAgCSkDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgBCAQIAQpAwCFQgGJNwMAC98aAQN/QQAhBEEAIAIpAwAgASkDAIU3A5AIQQAgAikDCCABKQMIhTcDmAhBACACKQMQIAEpAxCFNwOgCEEAIAIpAxggASkDGIU3A6gIQQAgAikDICABKQMghTcDsAhBACACKQMoIAEpAyiFNwO4CEEAIAIpAzAgASkDMIU3A8AIQQAgAikDOCABKQM4hTcDyAhBACACKQNAIAEpA0CFNwPQCEEAIAIpA0ggASkDSIU3A9gIQQAgAikDUCABKQNQhTcD4AhBACACKQNYIAEpA1iFNwPoCEEAIAIpA2AgASkDYIU3A/AIQQAgAikDaCABKQNohTcD+AhBACACKQNwIAEpA3CFNwOACUEAIAIpA3ggASkDeIU3A4gJQQAgAikDgAEgASkDgAGFNwOQCUEAIAIpA4gBIAEpA4gBhTcDmAlBACACKQOQASABKQOQAYU3A6AJQQAgAikDmAEgASkDmAGFNwOoCUEAIAIpA6ABIAEpA6ABhTcDsAlBACACKQOoASABKQOoAYU3A7gJQQAgAikDsAEgASkDsAGFNwPACUEAIAIpA7gBIAEpA7gBhTcDyAlBACACKQPAASABKQPAAYU3A9AJQQAgAikDyAEgASkDyAGFNwPYCUEAIAIpA9ABIAEpA9ABhTcD4AlBACACKQPYASABKQPYAYU3A+gJQQAgAikD4AEgASkD4AGFNwPwCUEAIAIpA+gBIAEpA+gBhTcD+AlBACACKQPwASABKQPwAYU3A4AKQQAgAikD+AEgASkD+AGFNwOICkEAIAIpA4ACIAEpA4AChTcDkApBACACKQOIAiABKQOIAoU3A5gKQQAgAikDkAIgASkDkAKFNwOgCkEAIAIpA5gCIAEpA5gChTcDqApBACACKQOgAiABKQOgAoU3A7AKQQAgAikDqAIgASkDqAKFNwO4CkEAIAIpA7ACIAEpA7AChTcDwApBACACKQO4AiABKQO4AoU3A8gKQQAgAikDwAIgASkDwAKFNwPQCkEAIAIpA8gCIAEpA8gChTcD2ApBACACKQPQAiABKQPQAoU3A+AKQQAgAikD2AIgASkD2AKFNwPoCkEAIAIpA+ACIAEpA+AChTcD8ApBACACKQPoAiABKQPoAoU3A/gKQQAgAikD8AIgASkD8AKFNwOAC0EAIAIpA/gCIAEpA/gChTcDiAtBACACKQOAAyABKQOAA4U3A5ALQQAgAikDiAMgASkDiAOFNwOYC0EAIAIpA5ADIAEpA5ADhTcDoAtBACACKQOYAyABKQOYA4U3A6gLQQAgAikDoAMgASkDoAOFNwOwC0EAIAIpA6gDIAEpA6gDhTcDuAtBACACKQOwAyABKQOwA4U3A8ALQQAgAikDuAMgASkDuAOFNwPIC0EAIAIpA8ADIAEpA8ADhTcD0AtBACACKQPIAyABKQPIA4U3A9gLQQAgAikD0AMgASkD0AOFNwPgC0EAIAIpA9gDIAEpA9gDhTcD6AtBACACKQPgAyABKQPgA4U3A/ALQQAgAikD6AMgASkD6AOFNwP4C0EAIAIpA/ADIAEpA/ADhTcDgAxBACACKQP4AyABKQP4A4U3A4gMQQAgAikDgAQgASkDgASFNwOQDEEAIAIpA4gEIAEpA4gEhTcDmAxBACACKQOQBCABKQOQBIU3A6AMQQAgAikDmAQgASkDmASFNwOoDEEAIAIpA6AEIAEpA6AEhTcDsAxBACACKQOoBCABKQOoBIU3A7gMQQAgAikDsAQgASkDsASFNwPADEEAIAIpA7gEIAEpA7gEhTcDyAxBACACKQPABCABKQPABIU3A9AMQQAgAikDyAQgASkDyASFNwPYDEEAIAIpA9AEIAEpA9AEhTcD4AxBACACKQPYBCABKQPYBIU3A+gMQQAgAikD4AQgASkD4ASFNwPwDEEAIAIpA+gEIAEpA+gEhTcD+AxBACACKQPwBCABKQPwBIU3A4ANQQAgAikD+AQgASkD+ASFNwOIDUEAIAIpA4AFIAEpA4AFhTcDkA1BACACKQOIBSABKQOIBYU3A5gNQQAgAikDkAUgASkDkAWFNwOgDUEAIAIpA5gFIAEpA5gFhTcDqA1BACACKQOgBSABKQOgBYU3A7ANQQAgAikDqAUgASkDqAWFNwO4DUEAIAIpA7AFIAEpA7AFhTcDwA1BACACKQO4BSABKQO4BYU3A8gNQQAgAikDwAUgASkDwAWFNwPQDUEAIAIpA8gFIAEpA8gFhTcD2A1BACACKQPQBSABKQPQBYU3A+ANQQAgAikD2AUgASkD2AWFNwPoDUEAIAIpA+AFIAEpA+AFhTcD8A1BACACKQPoBSABKQPoBYU3A/gNQQAgAikD8AUgASkD8AWFNwOADkEAIAIpA/gFIAEpA/gFhTcDiA5BACACKQOABiABKQOABoU3A5AOQQAgAikDiAYgASkDiAaFNwOYDkEAIAIpA5AGIAEpA5AGhTcDoA5BACACKQOYBiABKQOYBoU3A6gOQQAgAikDoAYgASkDoAaFNwOwDkEAIAIpA6gGIAEpA6gGhTcDuA5BACACKQOwBiABKQOwBoU3A8AOQQAgAikDuAYgASkDuAaFNwPIDkEAIAIpA8AGIAEpA8AGhTcD0A5BACACKQPIBiABKQPIBoU3A9gOQQAgAikD0AYgASkD0AaFNwPgDkEAIAIpA9gGIAEpA9gGhTcD6A5BACACKQPgBiABKQPgBoU3A/AOQQAgAikD6AYgASkD6AaFNwP4DkEAIAIpA/AGIAEpA/AGhTcDgA9BACACKQP4BiABKQP4BoU3A4gPQQAgAikDgAcgASkDgAeFNwOQD0EAIAIpA4gHIAEpA4gHhTcDmA9BACACKQOQByABKQOQB4U3A6APQQAgAikDmAcgASkDmAeFNwOoD0EAIAIpA6AHIAEpA6AHhTcDsA9BACACKQOoByABKQOoB4U3A7gPQQAgAikDsAcgASkDsAeFNwPAD0EAIAIpA7gHIAEpA7gHhTcDyA9BACACKQPAByABKQPAB4U3A9APQQAgAikDyAcgASkDyAeFNwPYD0EAIAIpA9AHIAEpA9AHhTcD4A9BACACKQPYByABKQPYB4U3A+gPQQAgAikD4AcgASkD4AeFNwPwD0EAIAIpA+gHIAEpA+gHhTcD+A9BACACKQPwByABKQPwB4U3A4AQQQAgAikD+AcgASkD+AeFNwOIEEGQCEGYCEGgCEGoCEGwCEG4CEHACEHICEHQCEHYCEHgCEHoCEHwCEH4CEGACUGICRACQZAJQZgJQaAJQagJQbAJQbgJQcAJQcgJQdAJQdgJQeAJQegJQfAJQfgJQYAKQYgKEAJBkApBmApBoApBqApBsApBuApBwApByApB0ApB2ApB4ApB6ApB8ApB+ApBgAtBiAsQAkGQC0GYC0GgC0GoC0GwC0G4C0HAC0HIC0HQC0HYC0HgC0HoC0HwC0H4C0GADEGIDBACQZAMQZgMQaAMQagMQbAMQbgMQcAMQcgMQdAMQdgMQeAMQegMQfAMQfgMQYANQYgNEAJBkA1BmA1BoA1BqA1BsA1BuA1BwA1ByA1B0A1B2A1B4A1B6A1B8A1B+A1BgA5BiA4QAkGQDkGYDkGgDkGoDkGwDkG4DkHADkHIDkHQDkHYDkHgDkHoDkHwDkH4DkGAD0GIDxACQZAPQZgPQaAPQagPQbAPQbgPQcAPQcgPQdAPQdgPQeAPQegPQfAPQfgPQYAQQYgQEAJBkAhBmAhBkAlBmAlBkApBmApBkAtBmAtBkAxBmAxBkA1BmA1BkA5BmA5BkA9BmA8QAkGgCEGoCEGgCUGoCUGgCkGoCkGgC0GoC0GgDEGoDEGgDUGoDUGgDkGoDkGgD0GoDxACQbAIQbgIQbAJQbgJQbAKQbgKQbALQbgLQbAMQbgMQbANQbgNQbAOQbgOQbAPQbgPEAJBwAhByAhBwAlByAlBwApByApBwAtByAtBwAxByAxBwA1ByA1BwA5ByA5BwA9ByA8QAkHQCEHYCEHQCUHYCUHQCkHYCkHQC0HYC0HQDEHYDEHQDUHYDUHQDkHYDkHQD0HYDxACQeAIQegIQeAJQegJQeAKQegKQeALQegLQeAMQegMQeANQegNQeAOQegOQeAPQegPEAJB8AhB+AhB8AlB+AlB8ApB+ApB8AtB+AtB8AxB+AxB8A1B+A1B8A5B+A5B8A9B+A8QAkGACUGICUGACkGICkGAC0GIC0GADEGIDEGADUGIDUGADkGIDkGAD0GID0GAEEGIEBACAkACQCADRQ0AA0AgACAEaiIDIAIgBGoiBSkDACABIARqIgYpAwCFIARBkAhqKQMAhSADKQMAhTcDACADQQhqIgMgBUEIaikDACAGQQhqKQMAhSAEQZgIaikDAIUgAykDAIU3AwAgBEEQaiIEQYAIRw0ADAILC0EAIQQDQCAAIARqIgMgAiAEaiIFKQMAIAEgBGoiBikDAIUgBEGQCGopAwCFNwMAIANBCGogBUEIaikDACAGQQhqKQMAhSAEQZgIaikDAIU3AwAgBEEQaiIEQYAIRw0ACwsL5QcMBX8BfgR/An4BfwF+AX8Bfgd/AX4DfwF+AkBBACgCgAgiAiABQQp0aiIDKAIIIAFHDQAgAygCDCEEIAMoAgAhBUEAIAMoAhQiBq03A7gQQQAgBK0iBzcDsBBBACAFIAEgBUECdG4iCGwiCUECdK03A6gQAkACQAJAAkAgBEUNAEF/IQogBUUNASAIQQNsIQsgCEECdCIErSEMIAWtIQ0gBkF/akECSSEOQgAhDwNAQQAgDzcDkBAgD6chEEIAIRFBACEBA0BBACARNwOgECAPIBGEUCIDIA5xIRIgBkEBRiAPUCITIAZBAkYgEUICVHFxciEUQX8gAUEBakEDcSAIbEF/aiATGyEVIAEgEHIhFiABIAhsIRcgA0EBdCEYQgAhGQNAQQBCADcDwBBBACAZNwOYECAYIQECQCASRQ0AQQBCATcDwBBBkBhBkBBBkCBBABADQZAYQZAYQZAgQQAQA0ECIQELAkAgASAITw0AIAQgGaciGmwgF2ogAWohAwNAIANBACAEIAEbQQAgEVAiGxtqQX9qIRwCQAJAIBQNAEEAKAKACCICIBxBCnQiHGohCgwBCwJAIAFB/wBxIgINAEEAQQApA8AQQgF8NwPAEEGQGEGQEEGQIEEAEANBkBhBkBhBkCBBABADCyAcQQp0IRwgAkEDdEGQGGohCkEAKAKACCECCyACIANBCnRqIAIgHGogAiAKKQMAIh1CIIinIAVwIBogFhsiHCAEbCABIAFBACAZIBytUSIcGyIKIBsbIBdqIAogC2ogExsgAUUgHHJrIhsgFWqtIB1C/////w+DIh0gHX5CIIggG61+QiCIfSAMgqdqQQp0akEBEAMgA0EBaiEDIAggAUEBaiIBRw0ACwsgGUIBfCIZIA1SDQALIBFCAXwiEachASARQgRSDQALIA9CAXwiDyAHUg0AC0EAKAKACCECCyAJQQx0QYB4aiEXIAVBf2oiCkUNAgwBC0EAQgM3A6AQQQAgBEF/aq03A5AQQYB4IRcLIAIgF2ohGyAIQQx0IQhBACEcA0AgCCAcQQFqIhxsQYB4aiEEQQAhAQNAIBsgAWoiAyADKQMAIAIgBCABamopAwCFNwMAIANBCGoiAyADKQMAIAIgBCABQQhyamopAwCFNwMAIAFBCGohAyABQRBqIQEgA0H4B0kNAAsgHCAKRw0ACwsgAiAXaiEbQXghAQNAIAIgAWoiA0EIaiAbIAFqIgRBCGopAwA3AwAgA0EQaiAEQRBqKQMANwMAIANBGGogBEEYaikDADcDACADQSBqIARBIGopAwA3AwAgAUEgaiIBQfgHSQ0ACwsL",hash:"e4cdc523"},pp={name:"blake2b",data:"AGFzbQEAAAABEQRgAAF/YAJ/fwBgAX8AYAAAAwoJAAECAwECAgABBQQBAQICBg4CfwFBsIsFC38AQYAICwdwCAZtZW1vcnkCAA5IYXNoX0dldEJ1ZmZlcgAACkhhc2hfRmluYWwAAwlIYXNoX0luaXQABQtIYXNoX1VwZGF0ZQAGDUhhc2hfR2V0U3RhdGUABw5IYXNoX0NhbGN1bGF0ZQAIClNUQVRFX1NJWkUDAQrTOAkFAEGACQvrAgIFfwF+AkAgAUEBSA0AAkACQAJAIAFBgAFBACgC4IoBIgJrIgNKDQAgASEEDAELQQBBADYC4IoBAkAgAkH/AEoNACACQeCJAWohBSAAIQRBACEGA0AgBSAELQAAOgAAIARBAWohBCAFQQFqIQUgAyAGQQFqIgZB/wFxSg0ACwtBAEEAKQPAiQEiB0KAAXw3A8CJAUEAQQApA8iJASAHQv9+Vq18NwPIiQFB4IkBEAIgACADaiEAAkAgASADayIEQYEBSA0AIAIgAWohBQNAQQBBACkDwIkBIgdCgAF8NwPAiQFBAEEAKQPIiQEgB0L/flatfDcDyIkBIAAQAiAAQYABaiEAIAVBgH9qIgVBgAJLDQALIAVBgH9qIQQMAQsgBEEATA0BC0EAIQUDQCAFQQAoAuCKAWpB4IkBaiAAIAVqLQAAOgAAIAQgBUEBaiIFQf8BcUoNAAsLQQBBACgC4IoBIARqNgLgigELC78uASR+QQBBACkD0IkBQQApA7CJASIBQQApA5CJAXwgACkDICICfCIDhULr+obav7X2wR+FQiCJIgRCq/DT9K/uvLc8fCIFIAGFQiiJIgYgA3wgACkDKCIBfCIHIASFQjCJIgggBXwiCSAGhUIBiSIKQQApA8iJAUEAKQOoiQEiBEEAKQOIiQF8IAApAxAiA3wiBYVCn9j52cKR2oKbf4VCIIkiC0K7zqqm2NDrs7t/fCIMIASFQiiJIg0gBXwgACkDGCIEfCIOfCAAKQNQIgV8Ig9BACkDwIkBQQApA6CJASIQQQApA4CJASIRfCAAKQMAIgZ8IhKFQtGFmu/6z5SH0QCFQiCJIhNCiJLznf/M+YTqAHwiFCAQhUIoiSIVIBJ8IAApAwgiEHwiFiAThUIwiSIXhUIgiSIYQQApA9iJAUEAKQO4iQEiE0EAKQOYiQF8IAApAzAiEnwiGYVC+cL4m5Gjs/DbAIVCIIkiGkLx7fT4paf9p6V/fCIbIBOFQiiJIhwgGXwgACkDOCITfCIZIBqFQjCJIhogG3wiG3wiHSAKhUIoiSIeIA98IAApA1giCnwiDyAYhUIwiSIYIB18Ih0gDiALhUIwiSIOIAx8Ih8gDYVCAYkiDCAWfCAAKQNAIgt8Ig0gGoVCIIkiFiAJfCIaIAyFQiiJIiAgDXwgACkDSCIJfCIhIBaFQjCJIhYgGyAchUIBiSIMIAd8IAApA2AiB3wiDSAOhUIgiSIOIBcgFHwiFHwiFyAMhUIoiSIbIA18IAApA2giDHwiHCAOhUIwiSIOIBd8IhcgG4VCAYkiGyAZIBQgFYVCAYkiFHwgACkDcCINfCIVIAiFQiCJIhkgH3wiHyAUhUIoiSIUIBV8IAApA3giCHwiFXwgDHwiIoVCIIkiI3wiJCAbhUIoiSIbICJ8IBJ8IiIgFyAYIBUgGYVCMIkiFSAffCIZIBSFQgGJIhQgIXwgDXwiH4VCIIkiGHwiFyAUhUIoiSIUIB98IAV8Ih8gGIVCMIkiGCAXfCIXIBSFQgGJIhR8IAF8IiEgFiAafCIWIBUgHSAehUIBiSIaIBx8IAl8IhyFQiCJIhV8Ih0gGoVCKIkiGiAcfCAIfCIcIBWFQjCJIhWFQiCJIh4gGSAOIBYgIIVCAYkiFiAPfCACfCIPhUIgiSIOfCIZIBaFQiiJIhYgD3wgC3wiDyAOhUIwiSIOIBl8Ihl8IiAgFIVCKIkiFCAhfCAEfCIhIB6FQjCJIh4gIHwiICAiICOFQjCJIiIgJHwiIyAbhUIBiSIbIBx8IAp8IhwgDoVCIIkiDiAXfCIXIBuFQiiJIhsgHHwgE3wiHCAOhUIwiSIOIBkgFoVCAYkiFiAffCAQfCIZICKFQiCJIh8gFSAdfCIVfCIdIBaFQiiJIhYgGXwgB3wiGSAfhUIwiSIfIB18Ih0gFoVCAYkiFiAVIBqFQgGJIhUgD3wgBnwiDyAYhUIgiSIYICN8IhogFYVCKIkiFSAPfCADfCIPfCAHfCIihUIgiSIjfCIkIBaFQiiJIhYgInwgBnwiIiAjhUIwiSIjICR8IiQgFoVCAYkiFiAOIBd8Ig4gDyAYhUIwiSIPICAgFIVCAYkiFCAZfCAKfCIXhUIgiSIYfCIZIBSFQiiJIhQgF3wgC3wiF3wgBXwiICAPIBp8Ig8gHyAOIBuFQgGJIg4gIXwgCHwiGoVCIIkiG3wiHyAOhUIoiSIOIBp8IAx8IhogG4VCMIkiG4VCIIkiISAdIB4gDyAVhUIBiSIPIBx8IAF8IhWFQiCJIhx8Ih0gD4VCKIkiDyAVfCADfCIVIByFQjCJIhwgHXwiHXwiHiAWhUIoiSIWICB8IA18IiAgIYVCMIkiISAefCIeIBogFyAYhUIwiSIXIBl8IhggFIVCAYkiFHwgCXwiGSAchUIgiSIaICR8IhwgFIVCKIkiFCAZfCACfCIZIBqFQjCJIhogHSAPhUIBiSIPICJ8IAR8Ih0gF4VCIIkiFyAbIB98Iht8Ih8gD4VCKIkiDyAdfCASfCIdIBeFQjCJIhcgH3wiHyAPhUIBiSIPIBsgDoVCAYkiDiAVfCATfCIVICOFQiCJIhsgGHwiGCAOhUIoiSIOIBV8IBB8IhV8IAx8IiKFQiCJIiN8IiQgD4VCKIkiDyAifCAHfCIiICOFQjCJIiMgJHwiJCAPhUIBiSIPIBogHHwiGiAVIBuFQjCJIhUgHiAWhUIBiSIWIB18IAR8IhuFQiCJIhx8Ih0gFoVCKIkiFiAbfCAQfCIbfCABfCIeIBUgGHwiFSAXIBogFIVCAYkiFCAgfCATfCIYhUIgiSIXfCIaIBSFQiiJIhQgGHwgCXwiGCAXhUIwiSIXhUIgiSIgIB8gISAVIA6FQgGJIg4gGXwgCnwiFYVCIIkiGXwiHyAOhUIoiSIOIBV8IA18IhUgGYVCMIkiGSAffCIffCIhIA+FQiiJIg8gHnwgBXwiHiAghUIwiSIgICF8IiEgGyAchUIwiSIbIB18IhwgFoVCAYkiFiAYfCADfCIYIBmFQiCJIhkgJHwiHSAWhUIoiSIWIBh8IBJ8IhggGYVCMIkiGSAfIA6FQgGJIg4gInwgAnwiHyAbhUIgiSIbIBcgGnwiF3wiGiAOhUIoiSIOIB98IAZ8Ih8gG4VCMIkiGyAafCIaIA6FQgGJIg4gFSAXIBSFQgGJIhR8IAh8IhUgI4VCIIkiFyAcfCIcIBSFQiiJIhQgFXwgC3wiFXwgBXwiIoVCIIkiI3wiJCAOhUIoiSIOICJ8IAh8IiIgGiAgIBUgF4VCMIkiFSAcfCIXIBSFQgGJIhQgGHwgCXwiGIVCIIkiHHwiGiAUhUIoiSIUIBh8IAZ8IhggHIVCMIkiHCAafCIaIBSFQgGJIhR8IAR8IiAgGSAdfCIZIBUgISAPhUIBiSIPIB98IAN8Ih2FQiCJIhV8Ih8gD4VCKIkiDyAdfCACfCIdIBWFQjCJIhWFQiCJIiEgFyAbIBkgFoVCAYkiFiAefCABfCIZhUIgiSIbfCIXIBaFQiiJIhYgGXwgE3wiGSAbhUIwiSIbIBd8Ihd8Ih4gFIVCKIkiFCAgfCAMfCIgICGFQjCJIiEgHnwiHiAiICOFQjCJIiIgJHwiIyAOhUIBiSIOIB18IBJ8Ih0gG4VCIIkiGyAafCIaIA6FQiiJIg4gHXwgC3wiHSAbhUIwiSIbIBcgFoVCAYkiFiAYfCANfCIXICKFQiCJIhggFSAffCIVfCIfIBaFQiiJIhYgF3wgEHwiFyAYhUIwiSIYIB98Ih8gFoVCAYkiFiAVIA+FQgGJIg8gGXwgCnwiFSAchUIgiSIZICN8IhwgD4VCKIkiDyAVfCAHfCIVfCASfCIihUIgiSIjfCIkIBaFQiiJIhYgInwgBXwiIiAjhUIwiSIjICR8IiQgFoVCAYkiFiAbIBp8IhogFSAZhUIwiSIVIB4gFIVCAYkiFCAXfCADfCIXhUIgiSIZfCIbIBSFQiiJIhQgF3wgB3wiF3wgAnwiHiAVIBx8IhUgGCAaIA6FQgGJIg4gIHwgC3wiGoVCIIkiGHwiHCAOhUIoiSIOIBp8IAR8IhogGIVCMIkiGIVCIIkiICAfICEgFSAPhUIBiSIPIB18IAZ8IhWFQiCJIh18Ih8gD4VCKIkiDyAVfCAKfCIVIB2FQjCJIh0gH3wiH3wiISAWhUIoiSIWIB58IAx8Ih4gIIVCMIkiICAhfCIhIBogFyAZhUIwiSIXIBt8IhkgFIVCAYkiFHwgEHwiGiAdhUIgiSIbICR8Ih0gFIVCKIkiFCAafCAJfCIaIBuFQjCJIhsgHyAPhUIBiSIPICJ8IBN8Ih8gF4VCIIkiFyAYIBx8Ihh8IhwgD4VCKIkiDyAffCABfCIfIBeFQjCJIhcgHHwiHCAPhUIBiSIPIBggDoVCAYkiDiAVfCAIfCIVICOFQiCJIhggGXwiGSAOhUIoiSIOIBV8IA18IhV8IA18IiKFQiCJIiN8IiQgD4VCKIkiDyAifCAMfCIiICOFQjCJIiMgJHwiJCAPhUIBiSIPIBsgHXwiGyAVIBiFQjCJIhUgISAWhUIBiSIWIB98IBB8IhiFQiCJIh18Ih8gFoVCKIkiFiAYfCAIfCIYfCASfCIhIBUgGXwiFSAXIBsgFIVCAYkiFCAefCAHfCIZhUIgiSIXfCIbIBSFQiiJIhQgGXwgAXwiGSAXhUIwiSIXhUIgiSIeIBwgICAVIA6FQgGJIg4gGnwgAnwiFYVCIIkiGnwiHCAOhUIoiSIOIBV8IAV8IhUgGoVCMIkiGiAcfCIcfCIgIA+FQiiJIg8gIXwgBHwiISAehUIwiSIeICB8IiAgGCAdhUIwiSIYIB98Ih0gFoVCAYkiFiAZfCAGfCIZIBqFQiCJIhogJHwiHyAWhUIoiSIWIBl8IBN8IhkgGoVCMIkiGiAcIA6FQgGJIg4gInwgCXwiHCAYhUIgiSIYIBcgG3wiF3wiGyAOhUIoiSIOIBx8IAN8IhwgGIVCMIkiGCAbfCIbIA6FQgGJIg4gFSAXIBSFQgGJIhR8IAt8IhUgI4VCIIkiFyAdfCIdIBSFQiiJIhQgFXwgCnwiFXwgBHwiIoVCIIkiI3wiJCAOhUIoiSIOICJ8IAl8IiIgGyAeIBUgF4VCMIkiFSAdfCIXIBSFQgGJIhQgGXwgDHwiGYVCIIkiHXwiGyAUhUIoiSIUIBl8IAp8IhkgHYVCMIkiHSAbfCIbIBSFQgGJIhR8IAN8Ih4gGiAffCIaIBUgICAPhUIBiSIPIBx8IAd8IhyFQiCJIhV8Ih8gD4VCKIkiDyAcfCAQfCIcIBWFQjCJIhWFQiCJIiAgFyAYIBogFoVCAYkiFiAhfCATfCIahUIgiSIYfCIXIBaFQiiJIhYgGnwgDXwiGiAYhUIwiSIYIBd8Ihd8IiEgFIVCKIkiFCAefCAFfCIeICCFQjCJIiAgIXwiISAiICOFQjCJIiIgJHwiIyAOhUIBiSIOIBx8IAt8IhwgGIVCIIkiGCAbfCIbIA6FQiiJIg4gHHwgEnwiHCAYhUIwiSIYIBcgFoVCAYkiFiAZfCABfCIXICKFQiCJIhkgFSAffCIVfCIfIBaFQiiJIhYgF3wgBnwiFyAZhUIwiSIZIB98Ih8gFoVCAYkiFiAVIA+FQgGJIg8gGnwgCHwiFSAdhUIgiSIaICN8Ih0gD4VCKIkiDyAVfCACfCIVfCANfCIihUIgiSIjfCIkIBaFQiiJIhYgInwgCXwiIiAjhUIwiSIjICR8IiQgFoVCAYkiFiAYIBt8IhggFSAahUIwiSIVICEgFIVCAYkiFCAXfCASfCIXhUIgiSIafCIbIBSFQiiJIhQgF3wgCHwiF3wgB3wiISAVIB18IhUgGSAYIA6FQgGJIg4gHnwgBnwiGIVCIIkiGXwiHSAOhUIoiSIOIBh8IAt8IhggGYVCMIkiGYVCIIkiHiAfICAgFSAPhUIBiSIPIBx8IAp8IhWFQiCJIhx8Ih8gD4VCKIkiDyAVfCAEfCIVIByFQjCJIhwgH3wiH3wiICAWhUIoiSIWICF8IAN8IiEgHoVCMIkiHiAgfCIgIBggFyAahUIwiSIXIBt8IhogFIVCAYkiFHwgBXwiGCAchUIgiSIbICR8IhwgFIVCKIkiFCAYfCABfCIYIBuFQjCJIhsgHyAPhUIBiSIPICJ8IAx8Ih8gF4VCIIkiFyAZIB18Ihl8Ih0gD4VCKIkiDyAffCATfCIfIBeFQjCJIhcgHXwiHSAPhUIBiSIPIBkgDoVCAYkiDiAVfCAQfCIVICOFQiCJIhkgGnwiGiAOhUIoiSIOIBV8IAJ8IhV8IBN8IiKFQiCJIiN8IiQgD4VCKIkiDyAifCASfCIiICOFQjCJIiMgJHwiJCAPhUIBiSIPIBsgHHwiGyAVIBmFQjCJIhUgICAWhUIBiSIWIB98IAt8IhmFQiCJIhx8Ih8gFoVCKIkiFiAZfCACfCIZfCAJfCIgIBUgGnwiFSAXIBsgFIVCAYkiFCAhfCAFfCIahUIgiSIXfCIbIBSFQiiJIhQgGnwgA3wiGiAXhUIwiSIXhUIgiSIhIB0gHiAVIA6FQgGJIg4gGHwgEHwiFYVCIIkiGHwiHSAOhUIoiSIOIBV8IAF8IhUgGIVCMIkiGCAdfCIdfCIeIA+FQiiJIg8gIHwgDXwiICAhhUIwiSIhIB58Ih4gGSAchUIwiSIZIB98IhwgFoVCAYkiFiAafCAIfCIaIBiFQiCJIhggJHwiHyAWhUIoiSIWIBp8IAp8IhogGIVCMIkiGCAdIA6FQgGJIg4gInwgBHwiHSAZhUIgiSIZIBcgG3wiF3wiGyAOhUIoiSIOIB18IAd8Ih0gGYVCMIkiGSAbfCIbIA6FQgGJIg4gFSAXIBSFQgGJIhR8IAx8IhUgI4VCIIkiFyAcfCIcIBSFQiiJIhQgFXwgBnwiFXwgEnwiIoVCIIkiI3wiJCAOhUIoiSIOICJ8IBN8IiIgGyAhIBUgF4VCMIkiFSAcfCIXIBSFQgGJIhQgGnwgBnwiGoVCIIkiHHwiGyAUhUIoiSIUIBp8IBB8IhogHIVCMIkiHCAbfCIbIBSFQgGJIhR8IA18IiEgGCAffCIYIBUgHiAPhUIBiSIPIB18IAJ8Ih2FQiCJIhV8Ih4gD4VCKIkiDyAdfCABfCIdIBWFQjCJIhWFQiCJIh8gFyAZIBggFoVCAYkiFiAgfCADfCIYhUIgiSIZfCIXIBaFQiiJIhYgGHwgBHwiGCAZhUIwiSIZIBd8Ihd8IiAgFIVCKIkiFCAhfCAIfCIhIB+FQjCJIh8gIHwiICAiICOFQjCJIiIgJHwiIyAOhUIBiSIOIB18IAd8Ih0gGYVCIIkiGSAbfCIbIA6FQiiJIg4gHXwgDHwiHSAZhUIwiSIZIBcgFoVCAYkiFiAafCALfCIXICKFQiCJIhogFSAefCIVfCIeIBaFQiiJIhYgF3wgCXwiFyAahUIwiSIaIB58Ih4gFoVCAYkiFiAVIA+FQgGJIg8gGHwgBXwiFSAchUIgiSIYICN8IhwgD4VCKIkiDyAVfCAKfCIVfCACfCIChUIgiSIifCIjIBaFQiiJIhYgAnwgC3wiAiAihUIwiSILICN8IiIgFoVCAYkiFiAZIBt8IhkgFSAYhUIwiSIVICAgFIVCAYkiFCAXfCANfCINhUIgiSIXfCIYIBSFQiiJIhQgDXwgBXwiBXwgEHwiECAVIBx8Ig0gGiAZIA6FQgGJIg4gIXwgDHwiDIVCIIkiFXwiGSAOhUIoiSIOIAx8IBJ8IhIgFYVCMIkiDIVCIIkiFSAeIB8gDSAPhUIBiSINIB18IAl8IgmFQiCJIg98IhogDYVCKIkiDSAJfCAIfCIJIA+FQjCJIgggGnwiD3wiGiAWhUIoiSIWIBB8IAd8IhAgEYUgDCAZfCIHIA6FQgGJIgwgCXwgCnwiCiALhUIgiSILIAUgF4VCMIkiBSAYfCIJfCIOIAyFQiiJIgwgCnwgE3wiEyALhUIwiSIKIA58IguFNwOAiQFBACADIAYgDyANhUIBiSINIAJ8fCICIAWFQiCJIgUgB3wiBiANhUIoiSIHIAJ8fCICQQApA4iJAYUgBCABIBIgCSAUhUIBiSIDfHwiASAIhUIgiSISICJ8IgkgA4VCKIkiAyABfHwiASAShUIwiSIEIAl8IhKFNwOIiQFBACATQQApA5CJAYUgECAVhUIwiSIQIBp8IhOFNwOQiQFBACABQQApA5iJAYUgAiAFhUIwiSICIAZ8IgGFNwOYiQFBACASIAOFQgGJQQApA6CJAYUgAoU3A6CJAUEAIBMgFoVCAYlBACkDqIkBhSAKhTcDqIkBQQAgASAHhUIBiUEAKQOwiQGFIASFNwOwiQFBACALIAyFQgGJQQApA7iJAYUgEIU3A7iJAQvdAgUBfwF+AX8BfgJ/IwBBwABrIgAkAAJAQQApA9CJAUIAUg0AQQBBACkDwIkBIgFBACgC4IoBIgKsfCIDNwPAiQFBAEEAKQPIiQEgAyABVK18NwPIiQECQEEALQDoigFFDQBBAEJ/NwPYiQELQQBCfzcD0IkBAkAgAkH/AEoNAEEAIQQDQCACIARqQeCJAWpBADoAACAEQQFqIgRBgAFBACgC4IoBIgJrSA0ACwtB4IkBEAIgAEEAKQOAiQE3AwAgAEEAKQOIiQE3AwggAEEAKQOQiQE3AxAgAEEAKQOYiQE3AxggAEEAKQOgiQE3AyAgAEEAKQOoiQE3AyggAEEAKQOwiQE3AzAgAEEAKQO4iQE3AzhBACgC5IoBIgVBAUgNAEEAIQRBACECA0AgBEGACWogACAEai0AADoAACAEQQFqIQQgBSACQQFqIgJB/wFxSg0ACwsgAEHAAGokAAv9AwMBfwF+AX8jAEGAAWsiAiQAQQBBgQI7AfKKAUEAIAE6APGKAUEAIAA6APCKAUGQfiEAA0AgAEGAiwFqQgA3AAAgAEH4igFqQgA3AAAgAEHwigFqQgA3AAAgAEEYaiIADQALQQAhAEEAQQApA/CKASIDQoiS853/zPmE6gCFNwOAiQFBAEEAKQP4igFCu86qptjQ67O7f4U3A4iJAUEAQQApA4CLAUKr8NP0r+68tzyFNwOQiQFBAEEAKQOIiwFC8e30+KWn/aelf4U3A5iJAUEAQQApA5CLAULRhZrv+s+Uh9EAhTcDoIkBQQBBACkDmIsBQp/Y+dnCkdqCm3+FNwOoiQFBAEEAKQOgiwFC6/qG2r+19sEfhTcDsIkBQQBBACkDqIsBQvnC+JuRo7Pw2wCFNwO4iQFBACADp0H/AXE2AuSKAQJAIAFBAUgNACACQgA3A3ggAkIANwNwIAJCADcDaCACQgA3A2AgAkIANwNYIAJCADcDUCACQgA3A0ggAkIANwNAIAJCADcDOCACQgA3AzAgAkIANwMoIAJCADcDICACQgA3AxggAkIANwMQIAJCADcDCCACQgA3AwBBACEEA0AgAiAAaiAAQYAJai0AADoAACAAQQFqIQAgBEEBaiIEQf8BcSABSA0ACyACQYABEAELIAJBgAFqJAALEgAgAEEDdkH/P3EgAEEQdhAECwkAQYAJIAAQAQsGAEGAiQELGwAgAUEDdkH/P3EgAUEQdhAEQYAJIAAQARADCwsLAQBBgAgLBPAAAAA=",hash:"c6f286e6"};function gp(e){return!Number.isInteger(e)||e<8||e>512||e%8!=0?new Error("Invalid variant! Valid values: 8, 16, ..., 512"):null}function mp(e=512,t=null){if(gp(e))return Promise.reject(gp(e));let n=null,r=e;if(null!==t){if(n=ip(t),n.length>64)return Promise.reject(new Error("Max key length is 64 bytes"));i=e,o=n.length,r=i|o<<16}var i,o;const s=e/8;return fp(pp,s).then(e=>{r>512&&e.writeMemory(n),e.init(r);const t={init:r>512?()=>(e.writeMemory(n),e.init(r),t):()=>(e.init(r),t),update:n=>(e.update(n),t),digest:t=>e.digest(t),save:()=>e.save(),load:n=>(e.load(n),t),blockSize:128,digestSize:s};return t})}new Vh;const yp=new DataView(new ArrayBuffer(4));function wp(e){return yp.setInt32(0,e,!0),new Uint8Array(yp.buffer)}function vp(e,t,n){return Jh(this,void 0,void 0,function*(){if(n<=64){const e=yield mp(8*n);return e.update(wp(n)),e.update(t),e.digest("binary")}const r=Math.ceil(n/32)-2,i=new Uint8Array(n);e.init(),e.update(wp(n)),e.update(t);let o=e.digest("binary");i.set(o.subarray(0,32),0);for(let t=1;t{var t;if(!e||"object"!=typeof e)throw new Error("Invalid options parameter. It requires an object.");if(!e.password)throw new Error("Password must be specified");if(e.password=ip(e.password),e.password.length<1)throw new Error("Password must be specified");if(!e.salt)throw new Error("Salt must be specified");if(e.salt=ip(e.salt),e.salt.length<8)throw new Error("Salt should be at least 8 bytes long");if(e.secret=ip(null!==(t=e.secret)&&void 0!==t?t:""),!Number.isInteger(e.iterations)||e.iterations<1)throw new Error("Iterations should be a positive number");if(!Number.isInteger(e.parallelism)||e.parallelism<1)throw new Error("Parallelism should be a positive number");if(!Number.isInteger(e.hashLength)||e.hashLength<4)throw new Error("Hash length should be at least 4 bytes.");if(!Number.isInteger(e.memorySize))throw new Error("Memory size should be specified.");if(e.memorySize<8*e.parallelism)throw new Error("Memory size should be at least 8 * parallelism.");if(void 0===e.outputType&&(e.outputType="hex"),!["hex","binary","encoded"].includes(e.outputType))throw new Error(`Insupported output type ${e.outputType}. Valid values: ['hex', 'binary', 'encoded']`)})(e),Ap(Object.assign(Object.assign({},e),{hashType:"id"}))})}new Vh,new Vh,new Vh,new Vh,new Vh,new Vh,new Vh,new Vh,new Vh,new Vh,new Vh,new Vh,new Vh,new Vh,new Vh,new Vh,new Vh,new Vh,new Vh,new Vh;const kp={parallelism:4,iterations:8,memorySize:262144,hashLength:32,outputType:"binary"};let Ip=null,Ep=0;const Cp=new Map;async function xp(e,t){try{const n=function(){if(Ip)return Ip;const e=new Blob(["\n importScripts('https://cdn.jsdelivr.net/npm/hash-wasm@4.11.0/dist/argon2.umd.min.js');\n\n const ARGON2_CONFIG = {\n parallelism: 4,\n iterations: 8,\n memorySize: 262144,\n hashLength: 32,\n outputType: \"binary\"\n };\n\n self.onmessage = async function(e) {\n const { password, salt, id } = e.data;\n\n try {\n const result = await hashwasm.argon2id({\n password: password,\n salt: new Uint8Array(salt),\n ...ARGON2_CONFIG\n });\n\n self.postMessage({\n id,\n success: true,\n result: Array.from(result)\n });\n } catch (error) {\n self.postMessage({\n id,\n success: false,\n error: error.message\n });\n }\n };\n "],{type:"application/javascript"});return Ip=new Worker(URL.createObjectURL(e)),Ip.onmessage=function(e){const{id:t,success:n,result:r,error:i}=e.data,o=Cp.get(t);o&&(Cp.delete(t),n?o.resolve(new Uint8Array(r)):o.reject(new Error(i)))},Ip.onerror=function(e){console.error("Argon2 worker error:",e)},Ip}(),r=++Ep;return new Promise((i,o)=>{Cp.set(r,{resolve:i,reject:o}),n.postMessage({id:r,password:e,salt:Array.from(t)})})}catch(n){console.warn("Worker failed, falling back to main thread:",n);return await bp({password:e,salt:t,...kp})}}const{window:Bp}=l;function Sp(e){let t,n,i,o,s,a,l,f,p,g,y,b,k,I,E,C,x,S;function F(e,t){return"extension"===e[2]?Qp:Fp}let Q=F(e),D=Q(e),R=e[10]&&Hp(e),P=e[11]&&jp(e);return{c(){t=h("div"),n=h("div"),i=h("div"),o=h("h2"),o.textContent="Login to Nostr",s=m(),a=h("button"),a.textContent="×",l=m(),f=h("div"),p=h("div"),g=h("button"),g.textContent="Extension",y=m(),b=h("button"),b.textContent="Nsec",k=m(),I=h("div"),D.c(),E=m(),R&&R.c(),C=m(),P&&P.c(),A(o,"class","svelte-4xpfbi"),A(a,"class","close-btn svelte-4xpfbi"),A(i,"class","modal-header svelte-4xpfbi"),A(g,"class","tab-btn svelte-4xpfbi"),B(g,"active","extension"===e[2]),A(b,"class","tab-btn svelte-4xpfbi"),B(b,"active","nsec"===e[2]),A(p,"class","tabs svelte-4xpfbi"),A(I,"class","tab-content svelte-4xpfbi"),A(f,"class","tab-container svelte-4xpfbi"),A(n,"class","modal svelte-4xpfbi"),B(n,"dark-theme",e[1]),A(t,"class","modal-overlay svelte-4xpfbi"),A(t,"role","button"),A(t,"tabindex","0")},m(r,d){u(r,t,d),c(t,n),c(n,i),c(i,o),c(i,s),c(i,a),c(n,l),c(n,f),c(f,p),c(p,g),c(p,y),c(p,b),c(f,k),c(f,I),D.m(I,null),c(I,E),R&&R.m(I,null),c(I,C),P&&P.m(I,null),x||(S=[w(a,"click",e[17]),w(g,"click",e[26]),w(b,"click",e[27]),w(n,"click",v(e[24])),w(n,"keydown",v(e[25])),w(t,"click",e[17]),w(t,"keydown",e[32])],x=!0)},p(e,t){4&t[0]&&B(g,"active","extension"===e[2]),4&t[0]&&B(b,"active","nsec"===e[2]),Q===(Q=F(e))&&D?D.p(e,t):(D.d(1),D=Q(e),D&&(D.c(),D.m(I,E))),e[10]?R?R.p(e,t):(R=Hp(e),R.c(),R.m(I,C)):R&&(R.d(1),R=null),e[11]?P?P.p(e,t):(P=jp(e),P.c(),P.m(I,null)):P&&(P.d(1),P=null),2&t[0]&&B(n,"dark-theme",e[1])},d(e){e&&d(t),D.d(),R&&R.d(),P&&P.d(),x=!1,r(S)}}}function Fp(e){let t;function n(e,t){return e[14]?Rp:Dp}let r=n(e),i=r(e);return{c(){t=h("div"),i.c(),A(t,"class","nsec-login svelte-4xpfbi")},m(e,n){u(e,t,n),i.m(t,null)},p(e,o){r===(r=n(e))&&i?i.p(e,o):(i.d(1),i=r(e),i&&(i.c(),i.m(t,null)))},d(e){e&&d(t),i.d()}}}function Qp(e){let t,n,r,i,o,s,a,l=e[7]?"Connecting...":"Log in using extension";return{c(){t=h("div"),n=h("p"),n.textContent="Login using a NIP-07 compatible browser\n extension like nos2x or Alby.",r=m(),i=h("button"),o=g(l),A(n,"class","svelte-4xpfbi"),A(i,"class","login-extension-btn svelte-4xpfbi"),i.disabled=e[7],A(t,"class","extension-login svelte-4xpfbi")},m(l,d){u(l,t,d),c(t,n),c(t,r),c(t,i),c(i,o),s||(a=w(i,"click",e[21]),s=!0)},p(e,t){128&t[0]&&l!==(l=e[7]?"Connecting...":"Log in using extension")&&k(o,l),128&t[0]&&(i.disabled=e[7])},d(e){e&&d(t),s=!1,a()}}}function Dp(e){let t,n,i,o,s,a,l,f,p,y,v,b,E,C,x,B,S,F,Q,D,R,P,$,U=e[8]?"Generating...":"Generate New Key",T=e[12]&&Pp(e),N=e[4]&&$p(e);function L(e,t){return e[9]?Np:e[7]?Tp:Up}let O=L(e),M=O(e);return{c(){t=h("p"),t.textContent="Enter your nsec or generate a new one. Optionally\n set a password to encrypt it securely.",n=m(),i=h("button"),o=g(U),a=m(),T&&T.c(),l=m(),f=h("input"),y=m(),v=h("div"),b=h("label"),b.textContent="Encryption Password (optional but recommended):",E=m(),C=h("input"),B=m(),N&&N.c(),S=m(),F=h("small"),F.textContent="Password uses Argon2id with ~3 second derivation time for security.",Q=m(),D=h("button"),M.c(),A(t,"class","svelte-4xpfbi"),A(i,"class","generate-btn svelte-4xpfbi"),i.disabled=s=e[7]||e[8],A(f,"type","password"),A(f,"placeholder","nsec1..."),f.disabled=p=e[7]||e[9],A(f,"class","nsec-input svelte-4xpfbi"),A(b,"class","svelte-4xpfbi"),A(C,"type","password"),A(C,"placeholder","Enter password (min 8 chars)"),C.disabled=x=e[7]||e[9],A(C,"class","password-input svelte-4xpfbi"),A(F,"class","password-hint svelte-4xpfbi"),A(v,"class","password-section svelte-4xpfbi"),A(D,"class","login-nsec-btn svelte-4xpfbi"),D.disabled=R=e[7]||e[9]||!e[3].trim()},m(r,s){u(r,t,s),u(r,n,s),u(r,i,s),c(i,o),u(r,a,s),T&&T.m(r,s),u(r,l,s),u(r,f,s),I(f,e[3]),u(r,y,s),u(r,v,s),c(v,b),c(v,E),c(v,C),I(C,e[4]),c(v,B),N&&N.m(v,null),c(v,S),c(v,F),u(r,Q,s),u(r,D,s),M.m(D,null),P||($=[w(i,"click",e[20]),w(f,"input",e[29]),w(C,"input",e[30]),w(D,"click",e[22])],P=!0)},p(e,t){256&t[0]&&U!==(U=e[8]?"Generating...":"Generate New Key")&&k(o,U),384&t[0]&&s!==(s=e[7]||e[8])&&(i.disabled=s),e[12]?T?T.p(e,t):(T=Pp(e),T.c(),T.m(l.parentNode,l)):T&&(T.d(1),T=null),640&t[0]&&p!==(p=e[7]||e[9])&&(f.disabled=p),8&t[0]&&f.value!==e[3]&&I(f,e[3]),640&t[0]&&x!==(x=e[7]||e[9])&&(C.disabled=x),16&t[0]&&C.value!==e[4]&&I(C,e[4]),e[4]?N?N.p(e,t):(N=$p(e),N.c(),N.m(v,S)):N&&(N.d(1),N=null),O!==(O=L(e))&&(M.d(1),M=O(e),M&&(M.c(),M.m(D,null))),648&t[0]&&R!==(R=e[7]||e[9]||!e[3].trim())&&(D.disabled=R)},d(e){e&&d(t),e&&d(n),e&&d(i),e&&d(a),T&&T.d(e),e&&d(l),e&&d(f),e&&d(y),e&&d(v),N&&N.d(),e&&d(Q),e&&d(D),M.d(),P=!1,r($)}}}function Rp(e){let t,n,i,o,s,a,l,f,p,y,v,b,k,E,C=e[15]&&Lp(e);function x(e,t){return e[9]?_p:e[7]?Mp:Op}let B=x(e),S=B(e);return{c(){t=h("p"),t.textContent="You have a stored encrypted key. Enter your\n password to unlock it.",n=m(),C&&C.c(),i=m(),o=h("input"),a=m(),l=h("button"),S.c(),p=m(),y=h("button"),v=g("Clear stored key & start fresh"),A(t,"class","svelte-4xpfbi"),A(o,"type","password"),A(o,"placeholder","Enter your password"),o.disabled=s=e[7]||e[9],A(o,"class","password-input svelte-4xpfbi"),A(l,"class","login-nsec-btn svelte-4xpfbi"),l.disabled=f=e[7]||e[9]||!e[6],A(y,"class","clear-btn svelte-4xpfbi"),y.disabled=b=e[7]||e[9]},m(r,s){u(r,t,s),u(r,n,s),C&&C.m(r,s),u(r,i,s),u(r,o,s),I(o,e[6]),u(r,a,s),u(r,l,s),S.m(l,null),u(r,p,s),u(r,y,s),c(y,v),k||(E=[w(o,"input",e[28]),w(l,"click",e[18]),w(y,"click",e[16])],k=!0)},p(e,t){e[15]?C?C.p(e,t):(C=Lp(e),C.c(),C.m(i.parentNode,i)):C&&(C.d(1),C=null),640&t[0]&&s!==(s=e[7]||e[9])&&(o.disabled=s),64&t[0]&&o.value!==e[6]&&I(o,e[6]),B!==(B=x(e))&&(S.d(1),S=B(e),S&&(S.c(),S.m(l,null))),704&t[0]&&f!==(f=e[7]||e[9]||!e[6])&&(l.disabled=f),640&t[0]&&b!==(b=e[7]||e[9])&&(y.disabled=b)},d(e){e&&d(t),e&&d(n),C&&C.d(e),e&&d(i),e&&d(o),e&&d(a),e&&d(l),S.d(),e&&d(p),e&&d(y),k=!1,r(E)}}}function Pp(e){let t,n,r,i,o;return{c(){t=h("div"),n=h("label"),n.textContent="Your new public key (npub):",r=m(),i=h("code"),o=g(e[12]),A(n,"class","svelte-4xpfbi"),A(i,"class","npub-display svelte-4xpfbi"),A(t,"class","generated-info svelte-4xpfbi")},m(e,s){u(e,t,s),c(t,n),c(t,r),c(t,i),c(i,o)},p(e,t){4096&t[0]&&k(o,e[12])},d(e){e&&d(t)}}}function $p(e){let t,n,r,i;return{c(){t=h("input"),A(t,"type","password"),A(t,"placeholder","Confirm password"),t.disabled=n=e[7]||e[9],A(t,"class","password-input svelte-4xpfbi")},m(n,o){u(n,t,o),I(t,e[5]),r||(i=w(t,"input",e[31]),r=!0)},p(e,r){640&r[0]&&n!==(n=e[7]||e[9])&&(t.disabled=n),32&r[0]&&t.value!==e[5]&&I(t,e[5])},d(e){e&&d(t),r=!1,i()}}}function Up(e){let t;return{c(){t=g("Log in with nsec")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Tp(e){let t;return{c(){t=g("Logging in...")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Np(e){let t;return{c(){t=g("Deriving key...")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Lp(e){let t,n,r,i,o,s,a,l=e[15].slice(0,16)+"",f=e[15].slice(-8)+"";return{c(){t=h("div"),n=h("label"),n.textContent="Stored public key:",r=m(),i=h("code"),o=g(l),s=g("..."),a=g(f),A(n,"class","svelte-4xpfbi"),A(i,"class","npub-display svelte-4xpfbi"),A(t,"class","stored-info svelte-4xpfbi")},m(e,l){u(e,t,l),c(t,n),c(t,r),c(t,i),c(i,o),c(i,s),c(i,a)},p(e,t){32768&t[0]&&l!==(l=e[15].slice(0,16)+"")&&k(o,l),32768&t[0]&&f!==(f=e[15].slice(-8)+"")&&k(a,f)},d(e){e&&d(t)}}}function Op(e){let t;return{c(){t=g("Unlock")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Mp(e){let t;return{c(){t=g("Unlocking...")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function _p(e){let t;return{c(){t=g("Deriving key...")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Hp(e){let t,n;return{c(){t=h("div"),n=g(e[10]),A(t,"class","message error-message svelte-4xpfbi")},m(e,r){u(e,t,r),c(t,n)},p(e,t){1024&t[0]&&k(n,e[10])},d(e){e&&d(t)}}}function jp(e){let t,n;return{c(){t=h("div"),n=g(e[11]),A(t,"class","message success-message svelte-4xpfbi")},m(e,r){u(e,t,r),c(t,n)},p(e,t){2048&t[0]&&k(n,e[11])},d(e){e&&d(t)}}}function Gp(e){let t,n,r,i,o,s,a,l,f,p,y,w=e[13].toFixed(1)+"";return{c(){t=h("div"),n=h("div"),r=h("div"),i=m(),o=h("h3"),o.textContent="Deriving encryption key",s=m(),a=h("div"),l=g(w),f=g("s"),p=m(),y=h("p"),y.textContent="This may take 3-6 seconds for security",A(r,"class","deriving-spinner svelte-4xpfbi"),A(o,"class","svelte-4xpfbi"),A(a,"class","deriving-timer svelte-4xpfbi"),A(y,"class","deriving-note svelte-4xpfbi"),A(n,"class","deriving-modal svelte-4xpfbi"),B(n,"dark-theme",e[1]),A(t,"class","deriving-overlay svelte-4xpfbi")},m(e,d){u(e,t,d),c(t,n),c(n,r),c(n,i),c(n,o),c(n,s),c(n,a),c(a,l),c(a,f),c(n,p),c(n,y)},p(e,t){8192&t[0]&&w!==(w=e[13].toFixed(1)+"")&&k(l,w),2&t[0]&&B(n,"dark-theme",e[1])},d(e){e&&d(t)}}}function qp(t){let n,r,i,o,s=t[0]&&Sp(t),a=t[9]&&Gp(t);return{c(){s&&s.c(),n=m(),a&&a.c(),r=y()},m(e,l){s&&s.m(e,l),u(e,n,l),a&&a.m(e,l),u(e,r,l),i||(o=w(Bp,"keydown",t[23]),i=!0)},p(e,t){e[0]?s?s.p(e,t):(s=Sp(e),s.c(),s.m(n.parentNode,n)):s&&(s.d(1),s=null),e[9]?a?a.p(e,t):(a=Gp(e),a.c(),a.m(r.parentNode,r)):a&&(a.d(1),a=null)},i:e,o:e,d(e){s&&s.d(e),e&&d(n),a&&a.d(e),e&&d(r),i=!1,o()}}}function Kp(e,t,n){const r=P();let{showModal:i=!1}=t,{isDarkTheme:o=!1}=t,s="extension",a="",l="",c="",u="",d=!1,f=!1,h=!1,p="",g="",m="",y="",w=0,v=null,A=null;function b(){n(13,w=0),v=performance.now(),k()}function k(){null!==v&&(n(13,w=(performance.now()-v)/1e3),A=requestAnimationFrame(k))}function I(){v=null,A&&(cancelAnimationFrame(A),A=null)}R(()=>{I()});let E=!1,C="";function x(){n(14,E=!!localStorage.getItem("nostr_privkey_encrypted")),n(15,C=localStorage.getItem("nostr_pubkey")||"")}function B(){n(0,i=!1),n(3,a=""),n(4,l=""),n(5,c=""),n(6,u=""),n(10,p=""),n(11,g=""),m="",n(12,y=""),r("close")}function S(e){n(2,s=e),n(10,p=""),n(11,g=""),m="",n(12,y="")}async function F(){n(7,d=!0),n(10,p=""),n(11,g="");try{if(!a.trim())throw new Error("Please enter your nsec");if(!function(e){if(!e||!e.startsWith("nsec1"))return!1;try{return"nsec"===vu(e).type}catch{return!1}}(a.trim()))throw new Error("Invalid nsec format or checksum");if(l){if(l.length<8)throw new Error("Password must be at least 8 characters");if(l!==c)throw new Error("Passwords do not match")}const e=xf.fromKey(a.trim()),t=await e.getPublicKey();if(localStorage.setItem("nostr_auth_method","nsec"),localStorage.setItem("nostr_pubkey",t),l){n(9,h=!0),b();const e=await async function(e,t){if(!e.startsWith("nsec1"))throw new Error("Invalid nsec format - must start with nsec1");try{if("nsec"!==vu(e).type)throw new Error("Invalid nsec - wrong type")}catch(e){throw new Error("Invalid nsec - bech32 checksum failed")}const n=crypto.getRandomValues(new Uint8Array(32)),r=crypto.getRandomValues(new Uint8Array(12)),i=await xp(t,n),o=await crypto.subtle.importKey("raw",i,{name:"AES-GCM"},!1,["encrypt"]),s=new TextEncoder,a=await crypto.subtle.encrypt({name:"AES-GCM",iv:r},o,s.encode(e)),l=new Uint8Array(n.length+r.length+a.byteLength);return l.set(n,0),l.set(r,n.length),l.set(new Uint8Array(a),n.length+r.length),btoa(String.fromCharCode(...l))}(a.trim(),l);I(),n(9,h=!1),localStorage.setItem("nostr_privkey_encrypted",e),localStorage.removeItem("nostr_privkey")}else localStorage.setItem("nostr_privkey",a.trim()),localStorage.removeItem("nostr_privkey_encrypted"),n(11,g="Successfully logged in with nsec!");r("login",{method:"nsec",pubkey:t,privateKey:a.trim(),signer:e}),setTimeout(()=>{B()},1500)}catch(e){n(10,p=e.message)}finally{n(7,d=!1)}}D(()=>{x()});return e.$$set=e=>{"showModal"in e&&n(0,i=e.showModal),"isDarkTheme"in e&&n(1,o=e.isDarkTheme)},e.$$.update=()=>{1&e.$$.dirty[0]&&i&&x()},[i,o,s,a,l,c,u,d,f,h,p,g,y,w,E,C,function(){localStorage.removeItem("nostr_privkey_encrypted"),localStorage.removeItem("nostr_privkey"),localStorage.removeItem("nostr_pubkey"),localStorage.removeItem("nostr_auth_method"),n(14,E=!1),n(15,C=""),n(6,u=""),n(10,p=""),n(11,g="")},B,async function(){n(7,d=!0),n(9,h=!0),b(),n(10,p=""),n(11,g="");try{if(!u)throw new Error("Please enter your password");const e=localStorage.getItem("nostr_privkey_encrypted");if(!e)throw new Error("No encrypted key found");const t=await async function(e,t){const n=new Uint8Array(atob(e).split("").map(e=>e.charCodeAt(0)));if(n.length<60)throw new Error("Invalid encrypted data - too short");const r=n.slice(0,32),i=n.slice(32,44),o=n.slice(44),s=await xp(t,r),a=await crypto.subtle.importKey("raw",s,{name:"AES-GCM"},!1,["decrypt"]);let l;try{l=await crypto.subtle.decrypt({name:"AES-GCM",iv:i},a,o)}catch(e){throw new Error("Decryption failed - invalid password or corrupted data")}const c=(new TextDecoder).decode(l);if(!c.startsWith("nsec1"))throw new Error("Decryption produced invalid data - not an nsec");try{if("nsec"!==vu(c).type)throw new Error("Decryption produced invalid nsec type")}catch(e){throw new Error("Decryption produced invalid nsec - bech32 checksum failed")}return c}(e,u);I(),n(9,h=!1);const i=xf.fromKey(t),o=await i.getPublicKey();r("login",{method:"nsec",pubkey:o,privateKey:t,signer:i}),B()}catch(e){I(),e.message.includes("decrypt")||e.message.includes("tag")?n(10,p="Invalid password"):n(10,p=e.message)}finally{n(7,d=!1),n(9,h=!1),I()}},S,async function(){n(8,f=!0),n(10,p=""),n(11,g="");try{const e=eu(),t=ku("nsec",e),r=bu(tu(e));m=t,n(12,y=r),n(3,a=t),n(11,g="New key generated! Set an encryption password below to secure it.")}catch(e){n(10,p="Failed to generate key: "+e.message)}finally{n(8,f=!1)}},async function(){n(7,d=!0),n(10,p=""),n(11,g="");try{if(!window.nostr)throw new Error("No Nostr extension found. Please install a NIP-07 compatible extension like nos2x or Alby.");const e=await window.nostr.getPublicKey();e&&(localStorage.setItem("nostr_auth_method","extension"),localStorage.setItem("nostr_pubkey",e),n(11,g="Successfully logged in with extension!"),r("login",{method:"extension",pubkey:e,signer:window.nostr}),setTimeout(()=>{B()},1500))}catch(e){n(10,p=e.message)}finally{n(7,d=!1)}},F,function(e){"Escape"===e.key&&B(),"Enter"===e.key&&"nsec"===s&&F()},function(t){$.call(this,e,t)},function(t){$.call(this,e,t)},()=>S("extension"),()=>S("nsec"),function(){u=this.value,n(6,u)},function(){a=this.value,n(3,a)},function(){l=this.value,n(4,l)},function(){c=this.value,n(5,c)},e=>"Escape"===e.key&&B()]}class Jp extends ae{constructor(e){super(),se(this,e,Kp,qp,o,{showModal:0,isDarkTheme:1},null,[-1,-1])}}function Vp(e,t,n){const r=e.slice();return r[72]=t[n],r}function Yp(e,t,n){const r=e.slice();return r[75]=t[n],r}function zp(e,t,n){const r=e.slice();return r[72]=t[n],r}function Wp(e,t,n){const r=e.slice();return r[72]=t[n],r}function Zp(e,t,n){const r=e.slice();return r[72]=t[n],r}function Xp(e,t,n){const r=e.slice();return r[72]=t[n],r}function eg(e,t,n){const r=e.slice();return r[72]=t[n],r}function tg(e){let t,n,r;return{c(){t=h("div"),n=g(e[3]),A(t,"class",r="message "+e[4]+" svelte-1y8wjwc")},m(e,r){u(e,t,r),c(t,n)},p(e,i){8&i[0]&&k(n,e[3]),16&i[0]&&r!==(r="message "+e[4]+" svelte-1y8wjwc")&&A(t,"class",r)},d(e){e&&d(t)}}}function ng(e){let t,n,i,o,s,a,l,f,p,y,v,b,k,E,C,x,B,S,F,Q,D,R,P,$,U,T,N,L;function O(e,t){return e[5]&&e[5].length>0?ig:rg}let M=O(e),_=M(e);function H(e,t){return e[8]&&e[8].length>0?lg:ag}let j=H(e),G=j(e);return{c(){t=h("div"),n=h("div"),i=h("h3"),i.textContent="Banned Pubkeys",o=m(),s=h("div"),a=h("input"),l=m(),f=h("input"),p=m(),y=h("button"),v=g("Ban Pubkey"),b=m(),k=h("div"),_.c(),E=m(),C=h("div"),x=h("h3"),x.textContent="Allowed Pubkeys",B=m(),S=h("div"),F=h("input"),Q=m(),D=h("input"),R=m(),P=h("button"),$=g("Allow Pubkey"),U=m(),T=h("div"),G.c(),A(i,"class","svelte-1y8wjwc"),A(a,"type","text"),A(a,"placeholder","Pubkey (64 hex chars)"),A(a,"class","svelte-1y8wjwc"),A(f,"type","text"),A(f,"placeholder","Reason (optional)"),A(f,"class","svelte-1y8wjwc"),y.disabled=e[2],A(y,"class","svelte-1y8wjwc"),A(s,"class","add-form svelte-1y8wjwc"),A(k,"class","list svelte-1y8wjwc"),A(n,"class","section svelte-1y8wjwc"),A(x,"class","svelte-1y8wjwc"),A(F,"type","text"),A(F,"placeholder","Pubkey (64 hex chars)"),A(F,"class","svelte-1y8wjwc"),A(D,"type","text"),A(D,"placeholder","Reason (optional)"),A(D,"class","svelte-1y8wjwc"),P.disabled=e[2],A(P,"class","svelte-1y8wjwc"),A(S,"class","add-form svelte-1y8wjwc"),A(T,"class","list svelte-1y8wjwc"),A(C,"class","section svelte-1y8wjwc"),A(t,"class","pubkeys-section")},m(r,d){u(r,t,d),c(t,n),c(n,i),c(n,o),c(n,s),c(s,a),I(a,e[6]),c(s,l),c(s,f),I(f,e[7]),c(s,p),c(s,y),c(y,v),c(n,b),c(n,k),_.m(k,null),c(t,E),c(t,C),c(C,x),c(C,B),c(C,S),c(S,F),I(F,e[9]),c(S,Q),c(S,D),I(D,e[10]),c(S,R),c(S,P),c(P,$),c(C,U),c(C,T),G.m(T,null),N||(L=[w(a,"input",e[43]),w(f,"input",e[44]),w(y,"click",e[25]),w(F,"input",e[45]),w(D,"input",e[46]),w(P,"click",e[26])],N=!0)},p(e,t){64&t[0]&&a.value!==e[6]&&I(a,e[6]),128&t[0]&&f.value!==e[7]&&I(f,e[7]),4&t[0]&&(y.disabled=e[2]),M===(M=O(e))&&_?_.p(e,t):(_.d(1),_=M(e),_&&(_.c(),_.m(k,null))),512&t[0]&&F.value!==e[9]&&I(F,e[9]),1024&t[0]&&D.value!==e[10]&&I(D,e[10]),4&t[0]&&(P.disabled=e[2]),j===(j=H(e))&&G?G.p(e,t):(G.d(1),G=j(e),G&&(G.c(),G.m(T,null)))},d(e){e&&d(t),_.d(),G.d(),N=!1,r(L)}}}function rg(t){let n;return{c(){n=h("div"),n.innerHTML="

No banned pubkeys configured.

",A(n,"class","no-items svelte-1y8wjwc")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function ig(e){let t,n=e[5],r=[];for(let t=0;tNo allowed pubkeys configured.

",A(n,"class","no-items svelte-1y8wjwc")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function lg(e){let t,n=e[8],r=[];for(let t=0;t0?hg:fg}let M=O(e),_=M(e);let H=function(e){return e[22]&&e[22].length>0?yg:mg}(e),j=H(e);return{c(){t=h("div"),n=h("div"),i=h("h3"),i.textContent="Banned Events",o=m(),s=h("div"),a=h("input"),l=m(),f=h("input"),p=m(),y=h("button"),v=g("Ban Event"),b=m(),k=h("div"),_.c(),E=m(),C=h("div"),x=h("h3"),x.textContent="Allowed Events",B=m(),S=h("div"),F=h("input"),Q=m(),D=h("input"),R=m(),P=h("button"),$=g("Allow Event"),U=m(),T=h("div"),j.c(),A(i,"class","svelte-1y8wjwc"),A(a,"type","text"),A(a,"placeholder","Event ID (64 hex chars)"),A(a,"class","svelte-1y8wjwc"),A(f,"type","text"),A(f,"placeholder","Reason (optional)"),A(f,"class","svelte-1y8wjwc"),y.disabled=e[2],A(y,"class","svelte-1y8wjwc"),A(s,"class","add-form svelte-1y8wjwc"),A(k,"class","list svelte-1y8wjwc"),A(n,"class","section svelte-1y8wjwc"),A(x,"class","svelte-1y8wjwc"),A(F,"type","text"),A(F,"placeholder","Event ID (64 hex chars)"),A(F,"class","svelte-1y8wjwc"),A(D,"type","text"),A(D,"placeholder","Reason (optional)"),A(D,"class","svelte-1y8wjwc"),P.disabled=e[2],A(P,"class","svelte-1y8wjwc"),A(S,"class","add-form svelte-1y8wjwc"),A(T,"class","list svelte-1y8wjwc"),A(C,"class","section svelte-1y8wjwc"),A(t,"class","events-section")},m(r,d){u(r,t,d),c(t,n),c(n,i),c(n,o),c(n,s),c(s,a),I(a,e[12]),c(s,l),c(s,f),I(f,e[13]),c(s,p),c(s,y),c(y,v),c(n,b),c(n,k),_.m(k,null),c(t,E),c(t,C),c(C,x),c(C,B),c(C,S),c(S,F),I(F,e[14]),c(S,Q),c(S,D),I(D,e[15]),c(S,R),c(S,P),c(P,$),c(C,U),c(C,T),j.m(T,null),N||(L=[w(a,"input",e[47]),w(f,"input",e[48]),w(y,"click",e[27]),w(F,"input",e[49]),w(D,"input",e[50]),w(P,"click",e[28])],N=!0)},p(e,t){4096&t[0]&&a.value!==e[12]&&I(a,e[12]),8192&t[0]&&f.value!==e[13]&&I(f,e[13]),4&t[0]&&(y.disabled=e[2]),M===(M=O(e))&&_?_.p(e,t):(_.d(1),_=M(e),_&&(_.c(),_.m(k,null))),16384&t[0]&&F.value!==e[14]&&I(F,e[14]),32768&t[0]&&D.value!==e[15]&&I(D,e[15]),4&t[0]&&(P.disabled=e[2]),j.p(e,t)},d(e){e&&d(t),_.d(),j.d(),N=!1,r(L)}}}function fg(t){let n;return{c(){n=h("div"),n.innerHTML="

No banned events configured.

",A(n,"class","no-items svelte-1y8wjwc")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function hg(e){let t,n=e[11],r=[];for(let t=0;tNo allowed events configured.

",A(n,"class","no-items svelte-1y8wjwc")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function yg(e){let t,n=e[22],r=[];for(let t=0;t0?bg:Ag}let B=x(e),S=B(e);return{c(){t=h("div"),n=h("div"),i=h("h3"),i.textContent="Blocked IPs",o=m(),s=h("div"),a=h("input"),l=m(),f=h("input"),p=m(),y=h("button"),v=g("Block IP"),b=m(),k=h("div"),S.c(),A(i,"class","svelte-1y8wjwc"),A(a,"type","text"),A(a,"placeholder","IP Address"),A(a,"class","svelte-1y8wjwc"),A(f,"type","text"),A(f,"placeholder","Reason (optional)"),A(f,"class","svelte-1y8wjwc"),y.disabled=e[2],A(y,"class","svelte-1y8wjwc"),A(s,"class","add-form svelte-1y8wjwc"),A(k,"class","list svelte-1y8wjwc"),A(n,"class","section svelte-1y8wjwc"),A(t,"class","ips-section")},m(r,d){u(r,t,d),c(t,n),c(n,i),c(n,o),c(n,s),c(s,a),I(a,e[17]),c(s,l),c(s,f),I(f,e[18]),c(s,p),c(s,y),c(y,v),c(n,b),c(n,k),S.m(k,null),E||(C=[w(a,"input",e[51]),w(f,"input",e[52]),w(y,"click",e[29])],E=!0)},p(e,t){131072&t[0]&&a.value!==e[17]&&I(a,e[17]),262144&t[0]&&f.value!==e[18]&&I(f,e[18]),4&t[0]&&(y.disabled=e[2]),B===(B=x(e))&&S?S.p(e,t):(S.d(1),S=B(e),S&&(S.c(),S.m(k,null)))},d(e){e&&d(t),S.d(),E=!1,r(C)}}}function Ag(t){let n;return{c(){n=h("div"),n.innerHTML="

No blocked IPs configured.

",A(n,"class","no-items svelte-1y8wjwc")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function bg(e){let t,n=e[16],r=[];for(let t=0;t0?xg:Cg}let x=C(e),B=x(e);return{c(){t=h("div"),n=h("div"),i=h("h3"),i.textContent="Allowed Event Kinds",o=m(),s=h("div"),a=h("input"),l=m(),f=h("button"),p=g("Allow Kind"),y=m(),v=h("div"),B.c(),A(i,"class","svelte-1y8wjwc"),A(a,"type","number"),A(a,"placeholder","Kind number"),A(a,"class","svelte-1y8wjwc"),f.disabled=e[2],A(f,"class","svelte-1y8wjwc"),A(s,"class","add-form svelte-1y8wjwc"),A(v,"class","list svelte-1y8wjwc"),A(n,"class","section svelte-1y8wjwc"),A(t,"class","kinds-section")},m(r,d){u(r,t,d),c(t,n),c(n,i),c(n,o),c(n,s),c(s,a),I(a,e[20]),c(s,l),c(s,f),c(f,p),c(n,y),c(n,v),B.m(v,null),k||(E=[w(a,"input",e[53]),w(f,"click",e[30])],k=!0)},p(e,t){1048576&t[0]&&b(a.value)!==e[20]&&I(a,e[20]),4&t[0]&&(f.disabled=e[2]),x===(x=C(e))&&B?B.p(e,t):(B.d(1),B=x(e),B&&(B.c(),B.m(v,null)))},d(e){e&&d(t),B.d(),k=!1,r(E)}}}function Cg(t){let n;return{c(){n=h("div"),n.innerHTML="

No allowed kinds configured. All kinds are\n allowed by default.

",A(n,"class","no-items svelte-1y8wjwc")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function xg(e){let t,n=e[19],r=[];for(let t=0;t0?Qg:Fg}let v=y(e),b=v(e);return{c(){t=h("div"),n=h("div"),r=h("h3"),r.textContent="Events Needing Moderation",i=m(),o=h("button"),s=g("Refresh"),a=m(),l=h("div"),b.c(),A(r,"class","svelte-1y8wjwc"),o.disabled=e[2],A(l,"class","list svelte-1y8wjwc"),A(n,"class","section svelte-1y8wjwc"),A(t,"class","moderation-section")},m(d,h){u(d,t,h),c(t,n),c(n,r),c(n,i),c(n,o),c(o,s),c(n,a),c(n,l),b.m(l,null),f||(p=w(o,"click",e[24]),f=!0)},p(e,t){4&t[0]&&(o.disabled=e[2]),v===(v=y(e))&&b?b.p(e,t):(b.d(1),b=v(e),b&&(b.c(),b.m(l,null)))},d(e){e&&d(t),b.d(),f=!1,p()}}}function Fg(t){let n;return{c(){n=h("div"),n.innerHTML="

No events need moderation at this time.

",A(n,"class","no-items svelte-1y8wjwc")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Qg(e){let t,n=e[21],r=[];for(let t=0;tManaged ACL Configuration \n

Configure access control using NIP-86 management API

\n
Owner Only: This interface is restricted to relay owners\n only.
',o=m(),V&&V.c(),s=m(),a=h("div"),l=h("button"),f=g("Pubkeys"),y=m(),v=h("button"),b=g("Events"),I=m(),E=h("button"),C=g("IPs"),B=m(),S=h("button"),F=g("Kinds"),D=m(),R=h("button"),P=g("Moderation"),U=m(),T=h("button"),N=g("Relay Config"),O=m(),M=h("div"),Y&&Y.c(),_=m(),z&&z.c(),H=m(),W&&W.c(),j=m(),Z&&Z.c(),G=m(),X&&X.c(),q=m(),ee&&ee.c(),A(i,"class","header svelte-1y8wjwc"),A(l,"class",p="tab "+("pubkeys"===t[1]?"active":"")+" svelte-1y8wjwc"),A(v,"class",k="tab "+("events"===t[1]?"active":"")+" svelte-1y8wjwc"),A(E,"class",x="tab "+("ips"===t[1]?"active":"")+" svelte-1y8wjwc"),A(S,"class",Q="tab "+("kinds"===t[1]?"active":"")+" svelte-1y8wjwc"),A(R,"class",$="tab "+("moderation"===t[1]?"active":"")+" svelte-1y8wjwc"),A(T,"class",L="tab "+("relay"===t[1]?"active":"")+" svelte-1y8wjwc"),A(a,"class","tabs svelte-1y8wjwc"),A(M,"class","tab-content svelte-1y8wjwc")},m(e,r){u(e,n,r),c(n,i),c(n,o),V&&V.m(n,null),c(n,s),c(n,a),c(a,l),c(l,f),c(a,y),c(a,v),c(v,b),c(a,I),c(a,E),c(E,C),c(a,B),c(a,S),c(S,F),c(a,D),c(a,R),c(R,P),c(a,U),c(a,T),c(T,N),c(n,O),c(n,M),Y&&Y.m(M,null),c(M,_),z&&z.m(M,null),c(M,H),W&&W.m(M,null),c(M,j),Z&&Z.m(M,null),c(M,G),X&&X.m(M,null),c(M,q),ee&&ee.m(M,null),K||(J=[w(l,"click",t[37]),w(v,"click",t[38]),w(E,"click",t[39]),w(S,"click",t[40]),w(R,"click",t[41]),w(T,"click",t[42])],K=!0)},p(e,t){e[3]?V?V.p(e,t):(V=tg(e),V.c(),V.m(n,s)):V&&(V.d(1),V=null),2&t[0]&&p!==(p="tab "+("pubkeys"===e[1]?"active":"")+" svelte-1y8wjwc")&&A(l,"class",p),2&t[0]&&k!==(k="tab "+("events"===e[1]?"active":"")+" svelte-1y8wjwc")&&A(v,"class",k),2&t[0]&&x!==(x="tab "+("ips"===e[1]?"active":"")+" svelte-1y8wjwc")&&A(E,"class",x),2&t[0]&&Q!==(Q="tab "+("kinds"===e[1]?"active":"")+" svelte-1y8wjwc")&&A(S,"class",Q),2&t[0]&&$!==($="tab "+("moderation"===e[1]?"active":"")+" svelte-1y8wjwc")&&A(R,"class",$),2&t[0]&&L!==(L="tab "+("relay"===e[1]?"active":"")+" svelte-1y8wjwc")&&A(T,"class",L),"pubkeys"===e[1]?Y?Y.p(e,t):(Y=ng(e),Y.c(),Y.m(M,_)):Y&&(Y.d(1),Y=null),"events"===e[1]?z?z.p(e,t):(z=dg(e),z.c(),z.m(M,H)):z&&(z.d(1),z=null),"ips"===e[1]?W?W.p(e,t):(W=vg(e),W.c(),W.m(M,j)):W&&(W.d(1),W=null),"kinds"===e[1]?Z?Z.p(e,t):(Z=Eg(e),Z.c(),Z.m(M,G)):Z&&(Z.d(1),Z=null),"moderation"===e[1]?X?X.p(e,t):(X=Sg(e),X.c(),X.m(M,q)):X&&(X.d(1),X=null),"relay"===e[1]?ee?ee.p(e,t):(ee=Pg(e),ee.c(),ee.m(M,null)):ee&&(ee.d(1),ee=null)},i:e,o:e,d(e){e&&d(n),V&&V.d(),Y&&Y.d(),z&&z.d(),W&&W.d(),Z&&Z.d(),X&&X.d(),ee&&ee.d(),K=!1,r(J)}}}function Ng(e,t,n){let{userSigner:r}=t,{userPubkey:i}=t,o="pubkeys",s=!1,a="",l="info",c=[],u="",d="",f=[],h="",p="",g=[],m="",y="",w="",v="",A=[],k="",I="",E=[],C="",x=[],B={relay_name:"",relay_description:"",relay_icon:""};async function S(){try{n(2,s=!0),console.log("Fetching relay info from /");const e=await fetch(window.location.origin+"/",{headers:{Accept:"application/nostr+json"}});if(console.log("Response status:",e.status),console.log("Response headers:",e.headers),e.ok){const t=await e.json();console.log("Raw relay info:",t),n(0,B={relay_name:t.name||"",relay_description:t.description||"",relay_icon:t.icon||""}),console.log("Updated relayConfig:",B),console.log("Loaded relay info:",t),n(3,a="Relay configuration loaded successfully"),n(4,l="success")}else console.error("Failed to fetch relay info, status:",e.status),n(3,a=`Failed to fetch relay info: ${e.status}`),n(4,l="error")}catch(e){console.error("Failed to fetch relay info:",e),n(3,a=`Failed to fetch relay info: ${e.message}`),n(4,l="error")}finally{n(2,s=!1)}}async function F(e,t=[]){try{n(2,s=!0),n(3,a="");const o={method:e,params:t},l=await async function(e,t){if(!r)throw new Error("No signer available for authentication. Please log in with a Nostr extension.");if(!i)throw new Error("No user pubkey available for authentication.");const n=window.location.origin+t,o={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",n],["method",e]],content:"",pubkey:i},s=await r.signEvent(o),a=JSON.stringify(s);return`Nostr ${btoa(a)}`}("POST","/api/nip86"),c=await fetch("/api/nip86",{method:"POST",headers:{"Content-Type":"application/nostr+json+rpc",Authorization:l},body:JSON.stringify(o)});if(!c.ok)throw new Error(`HTTP ${c.status}: ${c.statusText}`);const u=await c.json();if(u.error)throw new Error(u.error);return u.result}catch(e){throw console.error("NIP-86 API error:",e),n(3,a=e.message),n(4,l="error"),e}finally{n(2,s=!1)}}async function Q(){try{n(5,c=await F("listbannedpubkeys"))}catch(e){console.error("Failed to load banned pubkeys:",e)}}async function R(){try{n(8,f=await F("listallowedpubkeys"))}catch(e){console.error("Failed to load allowed pubkeys:",e)}}async function P(){try{n(11,g=await F("listbannedevents"))}catch(e){console.error("Failed to load banned events:",e)}}async function $(){try{n(16,A=await F("listblockedips"))}catch(e){console.error("Failed to load blocked IPs:",e)}}async function U(){try{n(19,E=await F("listallowedkinds"))}catch(e){console.error("Failed to load allowed kinds:",e)}}async function T(){try{n(2,s=!0),n(21,x=await F("listeventsneedingmoderation")),console.log("Loaded events needing moderation:",x)}catch(e){console.error("Failed to load events needing moderation:",e),n(3,a=`Failed to load moderation events: ${e.message}`),n(4,l="error"),n(21,x=[])}finally{n(2,s=!1)}}async function N(e){try{await F("disallowkind",[e]),n(3,a="Kind disallowed successfully"),n(4,l="success"),await U()}catch(e){console.error("Failed to disallow kind:",e)}}async function L(e){try{await F("allowevent",[e,"Approved from moderation queue"]),n(3,a="Event allowed successfully"),n(4,l="success"),await T()}catch(e){console.error("Failed to allow event from moderation:",e)}}async function O(e){try{await F("banevent",[e,"Banned from moderation queue"]),n(3,a="Event banned successfully"),n(4,l="success"),await T()}catch(e){console.error("Failed to ban event from moderation:",e)}}D(()=>{setTimeout(()=>{S()},100)}),async function(){await Promise.all([Q(),R(),P(),$(),U()])}();return e.$$set=e=>{"userSigner"in e&&n(35,r=e.userSigner),"userPubkey"in e&&n(36,i=e.userPubkey)},e.$$.update=()=>{1&e.$$.dirty[0]&&console.log("relayConfig changed:",B)},[B,o,s,a,l,c,u,d,f,h,p,g,m,y,w,v,A,k,I,E,C,x,[],S,T,async function(){if(u)try{await F("banpubkey",[u,d]),n(3,a="Pubkey banned successfully"),n(4,l="success"),n(6,u=""),n(7,d=""),await Q()}catch(e){console.error("Failed to ban pubkey:",e)}},async function(){if(h)try{await F("allowpubkey",[h,p]),n(3,a="Pubkey allowed successfully"),n(4,l="success"),n(9,h=""),n(10,p=""),await R()}catch(e){console.error("Failed to allow pubkey:",e)}},async function(){if(m)try{await F("banevent",[m,y]),n(3,a="Event banned successfully"),n(4,l="success"),n(12,m=""),n(13,y=""),await P()}catch(e){console.error("Failed to ban event:",e)}},async function(){if(w)try{await F("allowevent",[w,v]),n(3,a="Event allowed successfully"),n(4,l="success"),n(14,w=""),n(15,v="")}catch(e){console.error("Failed to allow event:",e)}},async function(){if(k)try{await F("blockip",[k,I]),n(3,a="IP blocked successfully"),n(4,l="success"),n(17,k=""),n(18,I=""),await $()}catch(e){console.error("Failed to block IP:",e)}},async function(){if(!C)return;const e=parseInt(C);if(isNaN(e))return n(3,a="Invalid kind number"),void n(4,l="error");try{await F("allowkind",[e]),n(3,a="Kind allowed successfully"),n(4,l="success"),n(20,C=""),await U()}catch(e){console.error("Failed to allow kind:",e)}},N,async function(){try{n(2,s=!0),n(3,a="");const e=[];if(B.relay_name&&e.push(F("changerelayname",[B.relay_name])),B.relay_description&&e.push(F("changerelaydescription",[B.relay_description])),B.relay_icon&&e.push(F("changerelayicon",[B.relay_icon])),0===e.length)return n(3,a="No changes to update"),void n(4,l="info");await Promise.all(e),n(3,a="Relay configuration updated successfully"),n(4,l="success"),await S()}catch(e){console.error("Failed to update relay configuration:",e),n(3,a=`Failed to update relay configuration: ${e.message}`),n(4,l="error")}finally{n(2,s=!1)}},L,O,r,i,()=>n(1,o="pubkeys"),()=>n(1,o="events"),()=>n(1,o="ips"),()=>n(1,o="kinds"),()=>{n(1,o="moderation"),x&&0!==x.length||T()},()=>n(1,o="relay"),function(){u=this.value,n(6,u)},function(){d=this.value,n(7,d)},function(){h=this.value,n(9,h)},function(){p=this.value,n(10,p)},function(){m=this.value,n(12,m)},function(){y=this.value,n(13,y)},function(){w=this.value,n(14,w)},function(){v=this.value,n(15,v)},function(){k=this.value,n(17,k)},function(){I=this.value,n(18,I)},function(){C=b(this.value),n(20,C)},e=>N(e),e=>L(e.id),e=>O(e.id),function(){B.relay_name=this.value,n(0,B)},function(){B.relay_description=this.value,n(0,B)},function(){B.relay_icon=this.value,n(0,B)}]}class Lg extends ae{constructor(e){super(),se(this,e,Ng,Tg,o,{userSigner:35,userPubkey:36},null,[-1,-1,-1])}}function Og(e){let t,n;return{c(){t=h("span"),n=g(e[3]),A(t,"class","permission-badge svelte-1qkhxam")},m(e,r){u(e,t,r),c(t,n)},p(e,t){8&t&&k(n,e[3])},d(e){e&&d(t)}}}function Mg(t){let n,r,i;return{c(){n=h("button"),n.textContent="Log in",A(n,"class","login-btn svelte-1qkhxam")},m(e,o){u(e,n,o),r||(i=w(n,"click",t[7]),r=!0)},p:e,d(e){e&&d(n),r=!1,i()}}}function _g(e){let t,n,r,i,o,s,a=(e[4]?.name||e[5])+"";function l(e,t){return e[4]?.picture?jg:Hg}let f=l(e),p=f(e);return{c(){t=h("button"),p.c(),n=m(),r=h("span"),i=g(a),A(r,"class","user-name svelte-1qkhxam"),A(t,"class","user-profile-btn svelte-1qkhxam")},m(a,l){u(a,t,l),p.m(t,null),c(t,n),c(t,r),c(r,i),o||(s=w(t,"click",e[6]),o=!0)},p(e,r){f===(f=l(e))&&p?p.p(e,r):(p.d(1),p=f(e),p&&(p.c(),p.m(t,n))),48&r&&a!==(a=(e[4]?.name||e[5])+"")&&k(i,a)},d(e){e&&d(t),p.d(),o=!1,s()}}}function Hg(t){let n;return{c(){n=h("div"),n.textContent="👤",A(n,"class","user-avatar-placeholder svelte-1qkhxam")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function jg(e){let t,n;return{c(){t=h("img"),a(t.src,n=e[4].picture)||A(t,"src",n),A(t,"alt","User avatar"),A(t,"class","user-avatar svelte-1qkhxam")},m(e,n){u(e,t,n)},p(e,r){16&r&&!a(t.src,n=e[4].picture)&&A(t,"src",n)},d(e){e&&d(t)}}}function Gg(t){let n,r,i,o,s,l,f,p,y,w,v=t[1]&&t[2]&&Og(t);function b(e,t){return e[1]?_g:Mg}let k=b(t),I=k(t);return{c(){n=h("header"),r=h("div"),i=h("img"),s=m(),l=h("div"),f=h("span"),p=g("ORLY? dashboard\n "),v&&v.c(),y=m(),w=h("div"),I.c(),a(i.src,o="/orly.png")||A(i,"src","/orly.png"),A(i,"alt","ORLY Logo"),A(i,"class","logo svelte-1qkhxam"),A(f,"class","app-title svelte-1qkhxam"),A(l,"class","header-title svelte-1qkhxam"),A(w,"class","header-buttons svelte-1qkhxam"),A(r,"class","header-content svelte-1qkhxam"),A(n,"class","main-header svelte-1qkhxam"),B(n,"dark-theme",t[0])},m(e,t){u(e,n,t),c(n,r),c(r,i),c(r,s),c(r,l),c(l,f),c(f,p),v&&v.m(f,null),c(r,y),c(r,w),I.m(w,null)},p(e,[t]){e[1]&&e[2]?v?v.p(e,t):(v=Og(e),v.c(),v.m(f,null)):v&&(v.d(1),v=null),k===(k=b(e))&&I?I.p(e,t):(I.d(1),I=k(e),I&&(I.c(),I.m(w,null))),1&t&&B(n,"dark-theme",e[0])},i:e,o:e,d(e){e&&d(n),v&&v.d(),I.d()}}}function qg(e,t,n){let{isDarkTheme:r=!1}=t,{isLoggedIn:i=!1}=t,{userRole:o=""}=t,{currentEffectiveRole:s=""}=t,{userProfile:a=null}=t,{userPubkey:l=""}=t;const c=P();return e.$$set=e=>{"isDarkTheme"in e&&n(0,r=e.isDarkTheme),"isLoggedIn"in e&&n(1,i=e.isLoggedIn),"userRole"in e&&n(2,o=e.userRole),"currentEffectiveRole"in e&&n(3,s=e.currentEffectiveRole),"userProfile"in e&&n(4,a=e.userProfile),"userPubkey"in e&&n(5,l=e.userPubkey)},[r,i,o,s,a,l,function(){c("openSettingsDrawer")},function(){c("openLoginModal")}]}class Kg extends ae{constructor(e){super(),se(this,e,qg,Gg,o,{isDarkTheme:0,isLoggedIn:1,userRole:2,currentEffectiveRole:3,userProfile:4,userPubkey:5})}}function Jg(e,t,n){const r=e.slice();return r[10]=t[n],r}function Vg(e){let t,n,i;function o(){return e[6](e[10])}function s(...t){return e[7](e[10],...t)}return{c(){t=h("span"),t.textContent="✕",A(t,"class","tab-close-icon svelte-wfmuj"),A(t,"role","button"),A(t,"tabindex","0")},m(e,r){u(e,t,r),n||(i=[w(t,"click",v(o)),w(t,"keydown",s)],n=!0)},p(t,n){e=t},d(e){e&&d(t),n=!1,r(i)}}}function Yg(e){let t,n,r,i,o,s,a,l,f,p,y=e[10].icon+"",v=e[10].label+"",b=e[10].isSearchTab&&Vg(e);function I(){return e[8](e[10])}return{c(){t=h("button"),n=h("span"),r=g(y),i=m(),o=h("span"),s=g(v),a=m(),b&&b.c(),l=m(),A(n,"class","tab-icon svelte-wfmuj"),A(o,"class","tab-label svelte-wfmuj"),A(t,"class","tab svelte-wfmuj"),B(t,"active",e[2]===e[10].id)},m(e,d){u(e,t,d),c(t,n),c(n,r),c(t,i),c(t,o),c(o,s),c(t,a),b&&b.m(t,null),c(t,l),f||(p=w(t,"click",I),f=!0)},p(n,i){e=n,2&i&&y!==(y=e[10].icon+"")&&k(r,y),2&i&&v!==(v=e[10].label+"")&&k(s,v),e[10].isSearchTab?b?b.p(e,i):(b=Vg(e),b.c(),b.m(t,l)):b&&(b.d(1),b=null),6&i&&B(t,"active",e[2]===e[10].id)},d(e){e&&d(t),b&&b.d(),f=!1,p()}}}function zg(e){let t,n,r,i,o,s,a,l;return{c(){t=h("a"),n=p("svg"),r=p("path"),i=p("path"),o=m(),s=h("span"),a=g("v"),l=g(e[3]),A(r,"d","M5 6h12v2h1.5c1.38 0 2.5 1.12 2.5 2.5v1c0 1.38-1.12 2.5-2.5 2.5H17v1c0 1.66-1.34 3-3 3H8c-1.66 0-3-1.34-3-3V6zm12 6h1.5c.28 0 .5-.22.5-.5v-1c0-.28-.22-.5-.5-.5H17v2z"),A(i,"d","M9 9c1.5 0 3 .5 3 2.5S10.5 14 9 14c0-1.5.5-3.5 2-4.5"),A(i,"stroke","currentColor"),A(i,"stroke-width","1"),A(i,"fill","none"),A(n,"class","version-icon svelte-wfmuj"),A(n,"viewBox","0 0 24 24"),A(n,"fill","currentColor"),A(n,"xmlns","http://www.w3.org/2000/svg"),A(s,"class","version-text svelte-wfmuj"),A(t,"href","https://next.orly.dev"),A(t,"target","_blank"),A(t,"rel","noopener noreferrer"),A(t,"class","version-link svelte-wfmuj")},m(e,d){u(e,t,d),c(t,n),c(n,r),c(n,i),c(t,o),c(t,s),c(s,a),c(s,l)},p(e,t){8&t&&k(l,e[3])},d(e){e&&d(t)}}}function Wg(t){let n,r,i,o,s=t[1],a=[];for(let e=0;e{"isDarkTheme"in e&&n(0,r=e.isDarkTheme),"tabs"in e&&n(1,i=e.tabs),"selectedTab"in e&&n(2,o=e.selectedTab),"version"in e&&n(3,s=e.version)},[r,i,o,s,l,c,e=>c(e.id),(e,t)=>"Enter"===t.key&&c(e.id),e=>l(e.id)]}class Xg extends ae{constructor(e){super(),se(this,e,Zg,Wg,o,{isDarkTheme:0,tabs:1,selectedTab:2,version:3})}}function em(t){let n,r,i,o,s,a;return{c(){n=h("div"),r=h("p"),r.textContent="Please log in to access export functionality.",i=m(),o=h("button"),o.textContent="Log In",A(r,"class","svelte-jzrdtj"),A(o,"class","login-btn svelte-jzrdtj"),A(n,"class","login-prompt svelte-jzrdtj")},m(e,l){u(e,n,l),c(n,r),c(n,i),c(n,o),s||(a=w(o,"click",t[5]),s=!0)},p:e,d(e){e&&d(n),s=!1,a()}}}function tm(e){let t,n,r=e[0]&&nm(e),i=e[1]&&rm(e);return{c(){r&&r.c(),t=m(),i&&i.c(),n=y()},m(e,o){r&&r.m(e,o),u(e,t,o),i&&i.m(e,o),u(e,n,o)},p(e,o){e[0]?r?r.p(e,o):(r=nm(e),r.c(),r.m(t.parentNode,t)):r&&(r.d(1),r=null),e[1]?i?i.p(e,o):(i=rm(e),i.c(),i.m(n.parentNode,n)):i&&(i.d(1),i=null)},d(e){r&&r.d(e),e&&d(t),i&&i.d(e),e&&d(n)}}}function nm(t){let n,r,i,o,s,a,l,f;return{c(){n=h("div"),r=h("h3"),r.textContent="Export My Events",i=m(),o=h("p"),o.textContent="Download your personal events as a JSONL file.",s=m(),a=h("button"),a.textContent="📤 Export My Events",A(r,"class","svelte-jzrdtj"),A(o,"class","svelte-jzrdtj"),A(a,"class","export-btn svelte-jzrdtj"),A(n,"class","export-section svelte-jzrdtj")},m(e,d){u(e,n,d),c(n,r),c(n,i),c(n,o),c(n,s),c(n,a),l||(f=w(a,"click",t[3]),l=!0)},p:e,d(e){e&&d(n),l=!1,f()}}}function rm(t){let n,r,i,o,s,a,l,f;return{c(){n=h("div"),r=h("h3"),r.textContent="Export All Events",i=m(),o=h("p"),o.textContent="Download the complete database as a JSONL file. This includes\n all events from all users.",s=m(),a=h("button"),a.textContent="📤 Export All Events",A(r,"class","svelte-jzrdtj"),A(o,"class","svelte-jzrdtj"),A(a,"class","export-btn svelte-jzrdtj"),A(n,"class","export-section svelte-jzrdtj")},m(e,d){u(e,n,d),c(n,r),c(n,i),c(n,o),c(n,s),c(n,a),l||(f=w(a,"click",t[4]),l=!0)},p:e,d(e){e&&d(n),l=!1,f()}}}function im(t){let n;function r(e,t){return e[2]?tm:em}let i=r(t),o=i(t);return{c(){o.c(),n=y()},m(e,t){o.m(e,t),u(e,n,t)},p(e,[t]){i===(i=r(e))&&o?o.p(e,t):(o.d(1),o=i(e),o&&(o.c(),o.m(n.parentNode,n)))},i:e,o:e,d(e){o.d(e),e&&d(n)}}}function om(e,t,n){let r,i,{isLoggedIn:o=!1}=t,{currentEffectiveRole:s=""}=t,{aclMode:a=""}=t;const l=P();return e.$$set=e=>{"isLoggedIn"in e&&n(0,o=e.isLoggedIn),"currentEffectiveRole"in e&&n(6,s=e.currentEffectiveRole),"aclMode"in e&&n(7,a=e.aclMode)},e.$$.update=()=>{129&e.$$.dirty&&n(2,r="none"===a||o),192&e.$$.dirty&&n(1,i="none"===a||"admin"===s||"owner"===s)},[o,i,r,function(){l("exportMyEvents")},function(){l("exportAllEvents")},function(){l("openLoginModal")},s,a]}class sm extends ae{constructor(e){super(),se(this,e,om,im,o,{isLoggedIn:0,currentEffectiveRole:6,aclMode:7})}}function am(t){let n,r,i,o,s,a,l,f;return{c(){n=h("div"),r=h("h3"),r.textContent="Import Events",i=m(),o=h("p"),o.textContent="Please log in to access import functionality.",s=m(),a=h("button"),a.textContent="Log In",A(r,"class","recovery-header svelte-nonyqh"),A(o,"class","recovery-description svelte-nonyqh"),A(a,"class","login-btn svelte-nonyqh"),A(n,"class","login-prompt svelte-nonyqh")},m(e,d){u(e,n,d),c(n,r),c(n,i),c(n,o),c(n,s),c(n,a),l||(f=w(a,"click",t[6]),l=!0)},p:e,d(e){e&&d(n),l=!1,f()}}}function lm(t){let n;return{c(){n=h("div"),n.innerHTML='

Import Events

\n

Admin or owner permission required for import functionality.

',A(n,"class","permission-denied svelte-nonyqh")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function cm(e){let t,n,i,o,s,a,l,f,p,y,v,b,k,I,E=e[2]&&um(e);return{c(){t=h("h3"),t.textContent="Import Events",n=m(),i=h("p"),i.textContent="Upload a JSONL file to import events into the database.",o=m(),s=h("div"),a=h("input"),l=m(),f=h("div"),p=h("button"),y=g("Import Events"),b=m(),E&&E.c(),A(t,"class","svelte-nonyqh"),A(i,"class","svelte-nonyqh"),A(a,"type","file"),A(a,"id","import-file"),A(a,"accept",".jsonl,.txt"),A(a,"class","svelte-nonyqh"),A(p,"class","import-btn svelte-nonyqh"),p.disabled=v=!e[1]||"Uploading..."===e[2],A(f,"class","import-row svelte-nonyqh"),A(s,"class","recovery-controls-card svelte-nonyqh")},m(r,d){u(r,t,d),u(r,n,d),u(r,i,d),u(r,o,d),u(r,s,d),c(s,a),c(s,l),c(s,f),c(f,p),c(p,y),c(f,b),E&&E.m(f,null),k||(I=[w(a,"change",e[4]),w(p,"click",e[5])],k=!0)},p(e,t){6&t&&v!==(v=!e[1]||"Uploading..."===e[2])&&(p.disabled=v),e[2]?E?E.p(e,t):(E=um(e),E.c(),E.m(f,null)):E&&(E.d(1),E=null)},d(e){e&&d(t),e&&d(n),e&&d(i),e&&d(o),e&&d(s),E&&E.d(),k=!1,r(I)}}}function um(e){let t,n;return{c(){t=h("span"),n=g(e[2]),A(t,"class","import-message svelte-nonyqh"),B(t,"uploading","Uploading..."===e[2]),B(t,"success","Upload complete"===e[2]),B(t,"error",e[2].startsWith("Import failed")||e[2].startsWith("Admin")||e[2].startsWith("Please"))},m(e,r){u(e,t,r),c(t,n)},p(e,r){4&r&&k(n,e[2]),4&r&&B(t,"uploading","Uploading..."===e[2]),4&r&&B(t,"success","Upload complete"===e[2]),4&r&&B(t,"error",e[2].startsWith("Import failed")||e[2].startsWith("Admin")||e[2].startsWith("Please"))},d(e){e&&d(t)}}}function dm(t){let n;function r(e,t){return e[3]?cm:e[0]?lm:am}let i=r(t),o=i(t);return{c(){n=h("div"),o.c(),A(n,"class","import-section svelte-nonyqh")},m(e,t){u(e,n,t),o.m(n,null)},p(e,[t]){i===(i=r(e))&&o?o.p(e,t):(o.d(1),o=i(e),o&&(o.c(),o.m(n,null)))},i:e,o:e,d(e){e&&d(n),o.d()}}}function fm(e,t,n){let r,{isLoggedIn:i=!1}=t,{currentEffectiveRole:o=""}=t,{selectedFile:s=null}=t,{aclMode:a=""}=t,{importMessage:l=""}=t;const c=P();return e.$$set=e=>{"isLoggedIn"in e&&n(0,i=e.isLoggedIn),"currentEffectiveRole"in e&&n(7,o=e.currentEffectiveRole),"selectedFile"in e&&n(1,s=e.selectedFile),"aclMode"in e&&n(8,a=e.aclMode),"importMessage"in e&&n(2,l=e.importMessage)},e.$$.update=()=>{385&e.$$.dirty&&n(3,r="none"===a||i&&("admin"===o||"owner"===o))},[i,s,l,r,function(e){c("fileSelect",e)},function(){c("importEvents")},function(){c("openLoginModal")},o,a]}class hm extends ae{constructor(e){super(),se(this,e,fm,dm,o,{isLoggedIn:0,currentEffectiveRole:7,selectedFile:1,aclMode:8,importMessage:2})}}const pm={0:"Profile Metadata",1:"Text Note",2:"Recommend Relay",3:"Contacts",4:"Encrypted DM",5:"Delete Request",6:"Repost",7:"Reaction",8:"Badge Award",16:"Generic Repost",40:"Channel Creation",41:"Channel Metadata",42:"Channel Message",43:"Channel Hide Message",44:"Channel Mute User",1063:"File Metadata",1311:"Live Chat Message",1984:"Reporting",1985:"Label",9734:"Zap Request",9735:"Zap Receipt",1e4:"Mute List",10001:"Pin List",10002:"Relay List Metadata",10003:"Bookmark List",10004:"Communities List",10005:"Public Chats List",10006:"Blocked Relays List",10007:"Search Relays List",10009:"User Groups",10015:"Interests List",10030:"User Emoji List",13194:"Wallet Info",22242:"Client Auth",23194:"Wallet Request",23195:"Wallet Response",24133:"Nostr Connect",27235:"HTTP Auth",3e4:"Categorized People List",30001:"Categorized Bookmarks",30002:"Categorized Relay List",30003:"Bookmark Sets",30004:"Curation Sets",30005:"Video Sets",30008:"Profile Badges",30009:"Badge Definition",30015:"Interest Sets",30017:"Create/Update Stall",30018:"Create/Update Product",30019:"Marketplace UI/UX",30020:"Product Sold As Auction",30023:"Long-form Content",30024:"Draft Long-form Content",30030:"Emoji Sets",30063:"Release Artifact Sets",30078:"Application-specific Data",30311:"Live Event",30315:"User Statuses",30388:"Slide Set",30402:"Classified Listing",30403:"Draft Classified Listing",30617:"Repository Announcement",30618:"Repository State Announcement",30818:"Wiki Article",30819:"Redirects",31922:"Date-Based Calendar Event",31923:"Time-Based Calendar Event",31924:"Calendar",31925:"Calendar Event RSVP",31989:"Handler Recommendation",31990:"Handler Information",34550:"Community Definition",34551:"Community Post Approval"};function gm(e,t=null){if(!e||"string"!=typeof e)return!1;return!!/^[0-9a-fA-F]+$/.test(e)&&(!t||e.length===t)}function mm(e){const t=new Date(1e3*e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}T${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function ym(e){return Math.floor(new Date(e).getTime()/1e3)}function wm(e,t,n){const r=e.slice();return r[62]=t[n],r[64]=n,r}function vm(e,t,n){const r=e.slice();return r[65]=t[n],r}function Am(e,t,n){const r=e.slice();return r[68]=t[n],r}function bm(e,t,n){const r=e.slice();return r[71]=t[n],r}function km(e,t,n){const r=e.slice();return r[71]=t[n].kind,r[74]=t[n].name,r}function Im(e){let t,n,r,i,o,s,a=e[20],l=[];for(let t=0;t0&&Cm(t),Ge=t[17]&&Bm(t),qe=t[2].length>0&&Sm(t),Ke=t[18]&&Qm(t),Je=t[3].length>0&&Dm(t),Ve=t[19]&&Pm(t),Ye=t[4].length>0&&$m(t),ze=t[5]&&Tm(t),We=t[6]&&Nm(t),Ze=t[8]&&Lm(t);return{c(){n=h("div"),i=h("div"),o=h("div"),s=h("label"),s.textContent="Search Text (NIP-50)",a=m(),l=h("div"),f=h("input"),p=m(),y=h("label"),y.textContent="Event Kinds",v=m(),E=h("div"),C=h("button"),x=g(Me),S=g(" Select Kinds ("),F=g(_e),Q=g(" selected)"),D=m(),He&&He.c(),R=m(),je&&je.c(),P=m(),$=h("label"),$.textContent="Authors (Pubkeys)",U=m(),T=h("div"),N=h("div"),L=h("input"),O=m(),M=h("button"),M.textContent="Add",_=m(),Ge&&Ge.c(),H=m(),qe&&qe.c(),j=m(),G=h("label"),G.textContent="Event IDs",q=m(),K=h("div"),J=h("div"),V=h("input"),Y=m(),z=h("button"),z.textContent="Add",W=m(),Ke&&Ke.c(),Z=m(),Je&&Je.c(),X=m(),ee=h("label"),ee.textContent="Tags (#e, #p, #a)",te=m(),ne=h("div"),re=h("div"),ie=h("span"),ie.textContent="#",oe=m(),se=h("input"),ae=m(),le=h("input"),ce=m(),ue=h("button"),ue.textContent="Add",de=m(),Ve&&Ve.c(),fe=m(),Ye&&Ye.c(),he=m(),pe=h("label"),pe.textContent="Since",ge=m(),me=h("div"),ye=h("input"),we=m(),ze&&ze.c(),ve=m(),Ae=h("label"),Ae.textContent="Until",be=m(),ke=h("div"),Ie=h("input"),Ee=m(),We&&We.c(),Ce=m(),xe=h("label"),xe.textContent="Limit",Be=m(),Se=h("div"),Fe=h("input"),Qe=m(),Ze&&Ze.c(),De=m(),Re=h("div"),Pe=h("button"),Pe.textContent="🧹",$e=m(),Ue=h("div"),Te=m(),Ne=h("button"),Ne.textContent="",A(s,"for","search-text"),A(s,"class","svelte-1a1v6k0"),A(f,"id","search-text"),A(f,"type","text"),A(f,"placeholder","Search events..."),A(f,"class","filter-input svelte-1a1v6k0"),A(l,"class","field-content svelte-1a1v6k0"),A(y,"class","svelte-1a1v6k0"),A(C,"class","picker-toggle-btn svelte-1a1v6k0"),A(E,"class","field-content svelte-1a1v6k0"),A($,"class","svelte-1a1v6k0"),A(L,"type","text"),A(L,"placeholder","64 character hex pubkey..."),A(L,"class","filter-input svelte-1a1v6k0"),A(L,"maxlength","64"),A(M,"class","add-btn svelte-1a1v6k0"),A(N,"class","input-group svelte-1a1v6k0"),A(T,"class","field-content svelte-1a1v6k0"),A(G,"class","svelte-1a1v6k0"),A(V,"type","text"),A(V,"placeholder","64 character hex event ID..."),A(V,"class","filter-input svelte-1a1v6k0"),A(V,"maxlength","64"),A(z,"class","add-btn svelte-1a1v6k0"),A(J,"class","input-group svelte-1a1v6k0"),A(K,"class","field-content svelte-1a1v6k0"),A(ee,"class","svelte-1a1v6k0"),A(ie,"class","hash-prefix svelte-1a1v6k0"),A(se,"type","text"),A(se,"placeholder","Tag"),A(se,"class","filter-input tag-name-input svelte-1a1v6k0"),A(se,"maxlength","1"),A(le,"type","text"),A(le,"placeholder","Value..."),A(le,"class","filter-input tag-value-input svelte-1a1v6k0"),A(ue,"class","add-btn svelte-1a1v6k0"),A(re,"class","tag-input-group svelte-1a1v6k0"),A(ne,"class","field-content svelte-1a1v6k0"),A(pe,"for","since-timestamp"),A(pe,"class","svelte-1a1v6k0"),A(ye,"id","since-timestamp"),A(ye,"type","datetime-local"),ye.value=t[32](),A(ye,"class","filter-input svelte-1a1v6k0"),A(me,"class","field-content timestamp-field svelte-1a1v6k0"),A(Ae,"for","until-timestamp"),A(Ae,"class","svelte-1a1v6k0"),A(Ie,"id","until-timestamp"),A(Ie,"type","datetime-local"),Ie.value=t[33](),A(Ie,"class","filter-input svelte-1a1v6k0"),A(ke,"class","field-content timestamp-field svelte-1a1v6k0"),A(xe,"for","limit"),A(xe,"class","svelte-1a1v6k0"),A(Fe,"id","limit"),A(Fe,"type","number"),A(Fe,"placeholder","Max events to return"),A(Fe,"class","filter-input svelte-1a1v6k0"),A(Fe,"min","1"),A(Se,"class","field-content svelte-1a1v6k0"),A(o,"class","filter-grid svelte-1a1v6k0"),A(i,"class","filter-content svelte-1a1v6k0"),A(Pe,"class","clear-all-btn svelte-1a1v6k0"),A(Pe,"title","Clear all filters"),A(Ue,"class","spacer svelte-1a1v6k0"),A(Ne,"class","json-toggle-btn svelte-1a1v6k0"),A(Ne,"title","Edit filter JSON"),B(Ne,"active",t[8]),A(Re,"class","clear-column svelte-1a1v6k0"),A(n,"class","filter-builder svelte-1a1v6k0")},m(e,r){u(e,n,r),c(n,i),c(i,o),c(o,s),c(o,a),c(o,l),c(l,f),I(f,t[0]),c(o,p),c(o,y),c(o,v),c(o,E),c(E,C),c(C,x),c(C,S),c(C,F),c(C,Q),c(E,D),He&&He.m(E,null),c(E,R),je&&je.m(E,null),c(o,P),c(o,$),c(o,U),c(o,T),c(T,N),c(N,L),I(L,t[13]),c(N,O),c(N,M),c(T,_),Ge&&Ge.m(T,null),c(T,H),qe&&qe.m(T,null),c(o,j),c(o,G),c(o,q),c(o,K),c(K,J),c(J,V),I(V,t[14]),c(J,Y),c(J,z),c(K,W),Ke&&Ke.m(K,null),c(K,Z),Je&&Je.m(K,null),c(o,X),c(o,ee),c(o,te),c(o,ne),c(ne,re),c(re,ie),c(re,oe),c(re,se),I(se,t[15]),c(re,ae),c(re,le),I(le,t[16]),c(re,ce),c(re,ue),c(ne,de),Ve&&Ve.m(ne,null),c(ne,fe),Ye&&Ye.m(ne,null),c(o,he),c(o,pe),c(o,ge),c(o,me),c(me,ye),c(me,we),ze&&ze.m(me,null),c(o,ve),c(o,Ae),c(o,be),c(o,ke),c(ke,Ie),c(ke,Ee),We&&We.m(ke,null),c(o,Ce),c(o,xe),c(o,Be),c(o,Se),c(Se,Fe),I(Fe,t[7]),c(o,Qe),Ze&&Ze.m(o,null),c(n,De),c(n,Re),c(Re,Pe),c(Re,$e),c(Re,Ue),c(Re,Te),c(Re,Ne),Le||(Oe=[w(f,"input",t[38]),w(C,"click",t[39]),w(L,"input",t[43]),w(L,"keydown",t[44]),w(M,"click",t[25]),w(V,"input",t[46]),w(V,"keydown",t[47]),w(z,"click",t[27]),w(se,"input",t[49]),w(le,"input",t[50]),w(le,"keydown",t[51]),w(ue,"click",t[29]),w(ye,"change",t[34]),w(Ie,"change",t[35]),w(Fe,"input",t[55]),w(Pe,"click",t[31]),w(Ne,"click",t[57])],Le=!0)},p(e,t){1&t[0]&&f.value!==e[0]&&I(f,e[0]),4096&t[0]&&Me!==(Me=e[12]?"▼":"▶")&&k(x,Me),2&t[0]&&_e!==(_e=e[1].length+"")&&k(F,_e),e[12]?He?He.p(e,t):(He=Im(e),He.c(),He.m(E,R)):He&&(He.d(1),He=null),e[1].length>0?je?je.p(e,t):(je=Cm(e),je.c(),je.m(E,null)):je&&(je.d(1),je=null),8192&t[0]&&L.value!==e[13]&&I(L,e[13]),e[17]?Ge?Ge.p(e,t):(Ge=Bm(e),Ge.c(),Ge.m(T,H)):Ge&&(Ge.d(1),Ge=null),e[2].length>0?qe?qe.p(e,t):(qe=Sm(e),qe.c(),qe.m(T,null)):qe&&(qe.d(1),qe=null),16384&t[0]&&V.value!==e[14]&&I(V,e[14]),e[18]?Ke?Ke.p(e,t):(Ke=Qm(e),Ke.c(),Ke.m(K,Z)):Ke&&(Ke.d(1),Ke=null),e[3].length>0?Je?Je.p(e,t):(Je=Dm(e),Je.c(),Je.m(K,null)):Je&&(Je.d(1),Je=null),32768&t[0]&&se.value!==e[15]&&I(se,e[15]),65536&t[0]&&le.value!==e[16]&&I(le,e[16]),e[19]?Ve?Ve.p(e,t):(Ve=Pm(e),Ve.c(),Ve.m(ne,fe)):Ve&&(Ve.d(1),Ve=null),e[4].length>0?Ye?Ye.p(e,t):(Ye=$m(e),Ye.c(),Ye.m(ne,null)):Ye&&(Ye.d(1),Ye=null),e[5]?ze?ze.p(e,t):(ze=Tm(e),ze.c(),ze.m(me,null)):ze&&(ze.d(1),ze=null),e[6]?We?We.p(e,t):(We=Nm(e),We.c(),We.m(ke,null)):We&&(We.d(1),We=null),128&t[0]&&b(Fe.value)!==e[7]&&I(Fe,e[7]),e[8]?Ze?Ze.p(e,t):(Ze=Lm(e),Ze.c(),Ze.m(o,null)):Ze&&(Ze.d(1),Ze=null),256&t[0]&&B(Ne,"active",e[8])},i:e,o:e,d(e){e&&d(n),He&&He.d(),je&&je.d(),Ge&&Ge.d(),qe&&qe.d(),Ke&&Ke.d(),Je&&Je.d(),Ve&&Ve.d(),Ye&&Ye.d(),ze&&ze.d(),We&&We.d(),Ze&&Ze.d(),Le=!1,r(Oe)}}}function _m(e,t,n){let r,i;const o=P();let{searchText:s=""}=t,{selectedKinds:a=[]}=t,{pubkeys:l=[]}=t,{eventIds:c=[]}=t,{tags:u=[]}=t,{sinceTimestamp:d=null}=t,{untilTimestamp:f=null}=t,{limit:h=null}=t,{showJsonEditor:p=!1}=t,g="",m="",y=!1,w="",v="",A="",k="",I="",E="",C="",x="",B=null,S=!1;function F(e){a.includes(e)?n(1,a=a.filter(t=>t!==e)):n(1,a=[...a,e].sort((e,t)=>e-t))}function Q(e){n(1,a=a.filter(t=>t!==e))}function D(){const e=v.trim();e&&(gm(e,64)?l.includes(e)?n(17,E="Pubkey already added"):(n(2,l=[...l,e]),n(13,v=""),n(17,E="")):n(17,E="Invalid pubkey: must be 64 character hex string"))}function $(e){n(2,l=l.filter(t=>t!==e))}function U(){const e=A.trim();e&&(gm(e,64)?c.includes(e)?n(18,C="Event ID already added"):(n(3,c=[...c,e]),n(14,A=""),n(18,C="")):n(18,C="Invalid event ID: must be 64 character hex string"))}function T(e){n(3,c=c.filter(t=>t!==e))}function N(){const e=k.trim(),t=I.trim();e&&t&&(/^[a-zA-Z]$/.test(e)?u.some(n=>n.name===e&&n.value===t)?n(19,x="Tag already added"):(n(4,u=[...u,{name:e,value:t}]),n(15,k=""),n(16,I=""),n(19,x="")):n(19,x="Invalid tag name: must be single letter a-z or A-Z"))}function L(e){n(4,u=u.filter((t,n)=>n!==e))}function O(){o("apply",{searchText:s,selectedKinds:a,pubkeys:l,eventIds:c,tags:u,sinceTimestamp:d,untilTimestamp:f,limit:h})}R(()=>{B&&clearTimeout(B)});return e.$$set=e=>{"searchText"in e&&n(0,s=e.searchText),"selectedKinds"in e&&n(1,a=e.selectedKinds),"pubkeys"in e&&n(2,l=e.pubkeys),"eventIds"in e&&n(3,c=e.eventIds),"tags"in e&&n(4,u=e.tags),"sinceTimestamp"in e&&n(5,d=e.sinceTimestamp),"untilTimestamp"in e&&n(6,f=e.untilTimestamp),"limit"in e&&n(7,h=e.limit),"showJsonEditor"in e&&n(8,p=e.showJsonEditor)},e.$$.update=()=>{if(256&e.$$.dirty[0]&&p){const e=function(){const e={};return a.length>0&&(e.kinds=a),l.length>0&&(e.authors=l),c.length>0&&(e.ids=c),d&&(e.since=d),f&&(e.until=f),h&&(e.limit=h),s&&(e.search=s),u.forEach(t=>{const n=`#${t.name}`;e[n]||(e[n]=[]),e[n].push(t.value)}),e}();n(10,g=JSON.stringify(e,null,2))}255&e.$$.dirty[0]|32&e.$$.dirty[1]&&(S?(B&&clearTimeout(B),B=setTimeout(()=>{O()},1e3)):n(36,S=!0)),512&e.$$.dirty[0]|64&e.$$.dirty[1]&&n(20,i=r.filter(e=>e.kind.toString().includes(w)||e.name.toLowerCase().includes(w.toLowerCase())))},n(37,r=Object.entries(pm).map(([e,t])=>({kind:parseInt(e),name:t})).sort((e,t)=>e.kind-t.kind)),[s,a,l,c,u,d,f,h,p,w,g,m,y,v,A,k,I,E,C,x,i,o,function(){try{const e=JSON.parse(g);n(11,m=""),n(1,a=e.kinds||[]),n(2,l=e.authors||[]),n(3,c=e.ids||[]),n(5,d=e.since||null),n(6,f=e.until||null),n(7,h=e.limit||null),n(0,s=e.search||""),n(4,u=[]),Object.keys(e).forEach(t=>{if(t.startsWith("#")&&2===t.length){const n=t.slice(1);(Array.isArray(e[t])?e[t]:[e[t]]).forEach(e=>{u.push({name:n,value:String(e)})})}}),n(4,u),B&&clearTimeout(B),O()}catch(e){n(11,m="Invalid JSON: "+e.message)}},F,Q,D,$,U,T,N,L,function(){n(0,s=""),n(1,a=[]),n(2,l=[]),n(3,c=[]),n(4,u=[]),n(5,d=null),n(6,f=null),n(7,h=null),o("clear")},function(){return d?mm(d):""},function(){return f?mm(f):""},function(e){const t=e.target.value;n(5,d=t?ym(t):null)},function(e){const t=e.target.value;n(6,f=t?ym(t):null)},S,r,function(){s=this.value,n(0,s)},()=>n(12,y=!y),function(){w=this.value,n(9,w)},e=>F(e),e=>Q(e),function(){v=this.value,n(13,v)},e=>"Enter"===e.key&&D(),e=>$(e),function(){A=this.value,n(14,A)},e=>"Enter"===e.key&&U(),e=>T(e),function(){k=this.value,n(15,k)},function(){I=this.value,n(16,I)},e=>"Enter"===e.key&&N(),e=>L(e),()=>n(5,d=null),()=>n(6,f=null),function(){h=b(this.value),n(7,h)},function(){g=this.value,n(10,g),n(8,p)},()=>o("toggleJson")]}class Hm extends ae{constructor(e){super(),se(this,e,_m,Mm,o,{searchText:0,selectedKinds:1,pubkeys:2,eventIds:3,tags:4,sinceTimestamp:5,untilTimestamp:6,limit:7,showJsonEditor:8},null,[-1,-1,-1])}}function jm(e,t,n){const r=e.slice();return r[28]=t[n],r}function Gm(e,t,n){const r=e.slice();return r[31]=t[n],r}function qm(t){let n;return{c(){n=h("div"),n.innerHTML="

❌ Read, write, admin, or owner permission required to view all\n events.

",A(n,"class","permission-denied svelte-5kb1ec")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Km(e){let t,n,r,i;function o(e,t){return e[4].length>0?Vm:e[6]?void 0:Jm}let s=o(e),a=s&&s(e),l=e[6]&&ny();return{c(){t=h("div"),a&&a.c(),n=m(),l&&l.c(),A(t,"class","events-view-content svelte-5kb1ec")},m(o,s){u(o,t,s),a&&a.m(t,null),c(t,n),l&&l.m(t,null),r||(i=w(t,"scroll",e[9]),r=!0)},p(e,r){s===(s=o(e))&&a?a.p(e,r):(a&&a.d(1),a=s&&s(e),a&&(a.c(),a.m(t,n))),e[6]?l||(l=ny(),l.c(),l.m(t,null)):l&&(l.d(1),l=null)},d(e){e&&d(t),a&&a.d(),l&&l.d(),r=!1,i()}}}function Jm(t){let n;return{c(){n=h("div"),n.innerHTML="

No events found.

",A(n,"class","no-events svelte-5kb1ec")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Vm(e){let t,n=e[4],r=[];for(let t=0;t0&&Wm(e);return{c(){t=h("div"),n=h("span"),n.textContent="🗑️ Delete Event",r=m(),i&&i.c(),A(n,"class","delete-event-label svelte-5kb1ec"),A(t,"class","delete-event-info svelte-5kb1ec")},m(e,o){u(e,t,o),c(t,n),c(t,r),i&&i.m(t,null)},p(e,n){e[28].tags&&e[28].tags.length>0?i?i.p(e,n):(i=Wm(e),i.c(),i.m(t,null)):i&&(i.d(1),i=null)},d(e){e&&d(t),i&&i.d()}}}function Wm(e){let t,n=e[28].tags.filter(dy),r=[];for(let t=0;t👤',o=m(),s=h("div"),a=h("div"),l=g(T),f=m(),p=h("div"),y=h("span"),v=g(N),b=m(),I=h("span"),E=g(L),C=m(),x=h("div"),S=h("div"),F=g(O),Q=m(),j.c(),D=m(),G&&G.c(),R=m(),J&&J.c(),P=m(),A(i,"class","events-view-avatar svelte-5kb1ec"),A(a,"class","events-view-author svelte-5kb1ec"),A(y,"class","kind-number svelte-5kb1ec"),B(y,"delete-event",5===e[28].kind),A(I,"class","kind-name svelte-5kb1ec"),A(p,"class","events-view-kind svelte-5kb1ec"),A(s,"class","events-view-info svelte-5kb1ec"),A(S,"class","event-timestamp svelte-5kb1ec"),A(x,"class","events-view-content svelte-5kb1ec"),A(n,"class","events-view-row svelte-5kb1ec"),A(n,"role","button"),A(n,"tabindex","0"),A(t,"class","events-view-item svelte-5kb1ec"),B(t,"expanded",e[5].has(e[28].id))},m(e,r){u(e,t,r),c(t,n),c(n,i),c(n,o),c(n,s),c(s,a),c(a,l),c(s,f),c(s,p),c(p,y),c(y,v),c(p,b),c(p,I),c(I,E),c(n,C),c(n,x),c(x,S),c(S,F),c(x,Q),j.m(x,null),c(n,D),G&&G.m(n,null),c(t,R),J&&J.m(t,null),c(t,P),$||(U=[w(n,"click",q),w(n,"keydown",K)],$=!0)},p(r,i){e=r,16&i[0]&&T!==(T=ay(e[28].pubkey)+"")&&k(l,T),16&i[0]&&N!==(N=e[28].kind+"")&&k(v,N),16&i[0]&&B(y,"delete-event",5===e[28].kind),16&i[0]&&L!==(L=ly(e[28].kind)+"")&&k(E,L),16&i[0]&&O!==(O=cy(e[28].created_at)+"")&&k(F,O),H===(H=_(e))&&j?j.p(e,i):(j.d(1),j=H(e),j&&(j.c(),j.m(x,null))),5!==e[28].kind&&("admin"===e[2]||"owner"===e[2]||"write"===e[2]&&e[28].pubkey&&e[28].pubkey===e[3])?G?G.p(e,i):(G=Xm(e),G.c(),G.m(n,null)):G&&(G.d(1),G=null),48&i[0]&&(M=e[5].has(e[28].id)),M?J?J.p(e,i):(J=ey(e),J.c(),J.m(t,P)):J&&(J.d(1),J=null),48&i[0]&&B(t,"expanded",e[5].has(e[28].id))},d(e){e&&d(t),j.d(),G&&G.d(),J&&J.d(),$=!1,r(U)}}}function ny(e){let t;return{c(){t=h("div"),t.innerHTML='
\n

Loading events...

',A(t,"class","loading-events svelte-5kb1ec")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function ry(e){let t,n,i,o,s,a,l,f,p,y,v,b,k,I,E,C,x,S,F,Q,D,R,P,$;function U(e,t){return e[6]?oy:iy}i=new Hm({props:{showJsonEditor:e[8]}}),i.$on("apply",e[17]),i.$on("clear",e[18]),i.$on("toggleJson",e[16]);let T=U(e),N=T(e);return{c(){t=h("div"),n=h("div"),ne(i.$$.fragment),o=m(),s=h("div"),a=h("div"),l=h("button"),l.innerHTML='',f=m(),p=h("div"),y=h("label"),v=h("input"),b=m(),k=h("span"),I=m(),E=h("span"),E.textContent="Only show my events",C=m(),x=h("div"),S=h("button"),F=g("🔄 Load More"),Q=m(),D=h("button"),N.c(),A(n,"class","filter-panel svelte-5kb1ec"),B(n,"open",e[7]),A(l,"class","filter-btn svelte-5kb1ec"),A(l,"title","Filter events"),B(l,"active",e[7]),A(v,"type","checkbox"),A(v,"class","svelte-5kb1ec"),A(k,"class","toggle-slider svelte-5kb1ec"),A(E,"class","toggle-label svelte-5kb1ec"),A(y,"class","toggle-container svelte-5kb1ec"),A(p,"class","events-view-toggle svelte-5kb1ec"),A(a,"class","events-view-left svelte-5kb1ec"),A(S,"class","refresh-btn svelte-5kb1ec"),S.disabled=e[6],A(D,"class","reload-btn svelte-5kb1ec"),D.disabled=e[6],A(x,"class","events-view-buttons svelte-5kb1ec"),A(s,"class","events-view-header svelte-5kb1ec"),A(t,"class","events-view-footer svelte-5kb1ec")},m(r,d){u(r,t,d),c(t,n),re(i,n,null),c(t,o),c(t,s),c(s,a),c(a,l),c(a,f),c(a,p),c(p,y),c(y,v),v.checked=e[0],c(y,b),c(y,k),c(y,I),c(y,E),c(s,C),c(s,x),c(x,S),c(S,F),c(x,Q),c(x,D),N.m(D,null),R=!0,P||($=[w(l,"click",e[15]),w(v,"change",e[23]),w(v,"change",e[24]),w(S,"click",e[25]),w(D,"click",e[26])],P=!0)},p(e,t){const r={};256&t[0]&&(r.showJsonEditor=e[8]),i.$set(r),(!R||128&t[0])&&B(n,"open",e[7]),(!R||128&t[0])&&B(l,"active",e[7]),1&t[0]&&(v.checked=e[0]),(!R||64&t[0])&&(S.disabled=e[6]),T!==(T=U(e))&&(N.d(1),N=T(e),N&&(N.c(),N.m(D,null))),(!R||64&t[0])&&(D.disabled=e[6])},i(e){R||(W(i.$$.fragment,e),R=!0)},o(e){Z(i.$$.fragment,e),R=!1},d(e){e&&d(t),ie(i),N.d(),P=!1,r($)}}}function iy(e){let t;return{c(){t=g("🔄")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function oy(e){let t;return{c(){t=h("div"),A(t,"class","spinner svelte-5kb1ec")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function sy(e){let t,n,r;function i(e,t){return!e[1]||"read"!==e[2]&&"write"!==e[2]&&"admin"!==e[2]&&"owner"!==e[2]?qm:Km}let o=i(e),s=o(e),a=e[1]&&("read"===e[2]||"write"===e[2]||"admin"===e[2]||"owner"===e[2])&&ry(e);return{c(){t=h("div"),s.c(),n=m(),a&&a.c(),A(t,"class","events-view-container svelte-5kb1ec")},m(e,i){u(e,t,i),s.m(t,null),c(t,n),a&&a.m(t,null),r=!0},p(e,r){o===(o=i(e))&&s?s.p(e,r):(s.d(1),s=o(e),s&&(s.c(),s.m(t,n))),!e[1]||"read"!==e[2]&&"write"!==e[2]&&"admin"!==e[2]&&"owner"!==e[2]?a&&(Y(),Z(a,1,1,()=>{a=null}),z()):a?(a.p(e,r),6&r[0]&&W(a,1)):(a=ry(e),a.c(),W(a,1),a.m(t,null))},i(e){r||(W(a),r=!0)},o(e){Z(a),r=!1},d(e){e&&d(t),s.d(),a&&a.d()}}}function ay(e){return e?e.slice(0,8)+"..."+e.slice(-8):""}function ly(e){return{0:"Profile",1:"Text Note",2:"Recommend Relay",3:"Contacts",4:"Encrypted DM",5:"Delete",6:"Repost",7:"Reaction",8:"Badge Award",16:"Generic Repost",40:"Channel Creation",41:"Channel Metadata",42:"Channel Message",43:"Channel Hide Message",44:"Channel Mute User",1984:"Reporting",9734:"Zap Request",9735:"Zap",1e4:"Mute List",10001:"Pin List",10002:"Relay List",22242:"Client Auth",24133:"Nostr Connect",27235:"HTTP Auth",3e4:"Categorized People",30001:"Categorized Bookmarks",30008:"Profile Badges",30009:"Badge Definition",30017:"Create or update a stall",30018:"Create or update a product",30023:"Long-form Content",30024:"Draft Long-form Content",30078:"Application-specific Data",30311:"Live Event",30315:"User Statuses",30402:"Classified Listing",30403:"Draft Classified Listing",31922:"Date-Based Calendar Event",31923:"Time-Based Calendar Event",31924:"Calendar",31925:"Calendar Event RSVP",31989:"Handler recommendation",31990:"Handler information",34550:"Community Definition"}[e]||`Kind ${e}`}function cy(e){return new Date(1e3*e).toLocaleString()}function uy(e){return e?e.length>100?e.slice(0,100)+"...":e:""}const dy=e=>"e"===e[0];function fy(e,t,n){let{isLoggedIn:r=!1}=t,{userRole:i=""}=t,{userPubkey:o=""}=t,{filteredEvents:s=[]}=t,{expandedEvents:a=new Set}=t,{isLoadingEvents:l=!1}=t,{showOnlyMyEvents:c=!1}=t,{showFilterBuilder:u=!1}=t;const d=P();let f=!1;function h(e){d("toggleEventExpansion",e)}function p(e){d("deleteEvent",e)}function g(e,t){d("copyEventToClipboard",{event:e,e:t})}function m(){d("toggleChange")}function y(e,t){d("loadAllEvents",{refresh:e,authors:t})}return e.$$set=e=>{"isLoggedIn"in e&&n(1,r=e.isLoggedIn),"userRole"in e&&n(2,i=e.userRole),"userPubkey"in e&&n(3,o=e.userPubkey),"filteredEvents"in e&&n(4,s=e.filteredEvents),"expandedEvents"in e&&n(5,a=e.expandedEvents),"isLoadingEvents"in e&&n(6,l=e.isLoadingEvents),"showOnlyMyEvents"in e&&n(0,c=e.showOnlyMyEvents),"showFilterBuilder"in e&&n(7,u=e.showFilterBuilder)},[c,r,i,o,s,a,l,u,f,function(e){d("scroll",e)},h,p,g,m,y,function(){d("toggleFilterBuilder")},function(){n(8,f=!f)},function(e){d("filterApply",e.detail)},function(){d("filterClear")},e=>p(e.id),e=>h(e.id),(e,t)=>"Enter"===t.key&&h(e.id),(e,t)=>g(e,t),function(){c=this.checked,n(0,c)},()=>m(),()=>{y(!1,c&&o?[o]:null)},()=>{y(!0,c&&o?[o]:null)}]}class hy extends ae{constructor(e){super(),se(this,e,fy,sy,o,{isLoggedIn:1,userRole:2,userPubkey:3,filteredEvents:4,expandedEvents:5,isLoadingEvents:6,showOnlyMyEvents:0,showFilterBuilder:7},null,[-1,-1])}}const py=[{kind:0,name:"Metadata",description:"User profile information (name, about, picture, nip05, etc.)",nip:"01",isReplaceable:!0,template:{kind:0,content:"",tags:[]}},{kind:1,name:"Short Text Note",description:"Short-form text post (like a tweet)",nip:"01",template:{kind:1,content:"",tags:[]}},{kind:2,name:"Recommend Relay",description:"Relay recommendation",nip:"01",deprecated:!0,template:{kind:2,content:"",tags:[]}},{kind:3,name:"Follows",description:"Following list with optional relay hints",nip:"02",isReplaceable:!0,template:{kind:3,content:"",tags:[]}},{kind:4,name:"Encrypted Direct Message",description:"Private message using NIP-04 encryption",nip:"04",deprecated:!0,template:{kind:4,content:"",tags:[]}},{kind:5,name:"Event Deletion Request",description:"Request to delete events",nip:"09",template:{kind:5,content:"",tags:[]}},{kind:6,name:"Repost",description:"Share/repost another text note",nip:"18",template:{kind:6,content:"",tags:[]}},{kind:7,name:"Reaction",description:"Like, emoji reaction to an event",nip:"25",template:{kind:7,content:"",tags:[]}},{kind:8,name:"Badge Award",description:"Award a badge to someone",nip:"58",template:{kind:8,content:"",tags:[]}},{kind:9,name:"Chat Message",description:"Chat message",nip:"C7",template:{kind:9,content:"",tags:[]}},{kind:10,name:"Group Chat Threaded Reply",description:"Threaded reply in group chat",nip:"29",deprecated:!0,template:{kind:10,content:"",tags:[]}},{kind:11,name:"Thread",description:"Thread event",nip:"7D",template:{kind:11,content:"",tags:[]}},{kind:12,name:"Group Thread Reply",description:"Reply in group thread",nip:"29",deprecated:!0,template:{kind:12,content:"",tags:[]}},{kind:13,name:"Seal",description:"Sealed/encrypted event wrapper",nip:"59",template:{kind:13,content:"",tags:[]}},{kind:14,name:"Direct Message",description:"Private direct message using NIP-17",nip:"17",template:{kind:14,content:"",tags:[]}},{kind:15,name:"File Message",description:"File message in DMs",nip:"17",template:{kind:15,content:"",tags:[]}},{kind:16,name:"Generic Repost",description:"Repost any event kind",nip:"18",template:{kind:16,content:"",tags:[]}},{kind:17,name:"Reaction to Website",description:"Reaction to a website URL",nip:"25",template:{kind:17,content:"",tags:[]}},{kind:20,name:"Picture",description:"Picture-first feed post",nip:"68",template:{kind:20,content:"",tags:[]}},{kind:21,name:"Video Event",description:"Horizontal video event",nip:"71",template:{kind:21,content:"",tags:[]}},{kind:22,name:"Short-form Video",description:"Short-form portrait video (like TikTok)",nip:"71",template:{kind:22,content:"",tags:[]}},{kind:40,name:"Channel Creation",description:"Create a public chat channel",nip:"28",template:{kind:40,content:"",tags:[]}},{kind:41,name:"Channel Metadata",description:"Set channel name, about, picture",nip:"28",template:{kind:41,content:"",tags:[]}},{kind:42,name:"Channel Message",description:"Post message in channel",nip:"28",template:{kind:42,content:"",tags:[]}},{kind:43,name:"Channel Hide Message",description:"Hide a message in channel",nip:"28",template:{kind:43,content:"",tags:[]}},{kind:44,name:"Channel Mute User",description:"Mute a user in channel",nip:"28",template:{kind:44,content:"",tags:[]}},{kind:62,name:"Request to Vanish",description:"Request permanent deletion of all user data",nip:"62",template:{kind:62,content:"",tags:[]}},{kind:64,name:"Chess (PGN)",description:"Chess game in PGN format",nip:"64",template:{kind:64,content:"",tags:[]}},{kind:443,name:"KeyPackage",description:"Marmot protocol key package",nip:null,spec:"Marmot",template:{kind:443,content:"",tags:[]}},{kind:444,name:"Welcome Message",description:"Marmot protocol welcome message",nip:null,spec:"Marmot",template:{kind:444,content:"",tags:[]}},{kind:445,name:"Group Event",description:"Marmot protocol group event",nip:null,spec:"Marmot",template:{kind:445,content:"",tags:[]}},{kind:818,name:"Merge Requests",description:"Git merge request",nip:"54",template:{kind:818,content:"",tags:[]}},{kind:1018,name:"Poll Response",description:"Response to a poll",nip:"88",template:{kind:1018,content:"",tags:[]}},{kind:1021,name:"Bid",description:"Auction bid",nip:"15",template:{kind:1021,content:"",tags:[]}},{kind:1022,name:"Bid Confirmation",description:"Confirmation of auction bid",nip:"15",template:{kind:1022,content:"",tags:[]}},{kind:1040,name:"OpenTimestamps",description:"OpenTimestamps attestation",nip:"03",template:{kind:1040,content:"",tags:[]}},{kind:1059,name:"Gift Wrap",description:"Encrypted gift-wrapped event",nip:"59",template:{kind:1059,content:"",tags:[]}},{kind:1060,name:"Gift Wrap (Kind 4)",description:"Gift wrap variant for NIP-04 compatibility",nip:"59",template:{kind:1060,content:"",tags:[]}},{kind:1063,name:"File Metadata",description:"Metadata for shared files",nip:"94",template:{kind:1063,content:"",tags:[]}},{kind:1068,name:"Poll",description:"Create a poll",nip:"88",template:{kind:1068,content:"",tags:[]}},{kind:1111,name:"Comment",description:"Comment on events or external content",nip:"22",template:{kind:1111,content:"",tags:[]}},{kind:1222,name:"Voice Message",description:"Voice message",nip:"A0",template:{kind:1222,content:"",tags:[]}},{kind:1244,name:"Voice Message Comment",description:"Comment on voice message",nip:"A0",template:{kind:1244,content:"",tags:[]}},{kind:1311,name:"Live Chat Message",description:"Message in live stream chat",nip:"53",template:{kind:1311,content:"",tags:[]}},{kind:1337,name:"Code Snippet",description:"Code snippet post",nip:"C0",template:{kind:1337,content:"",tags:[]}},{kind:1517,name:"Bitcoin Block",description:"Bitcoin block data",nip:null,spec:"Nostrocket",template:{kind:1517,content:"",tags:[]}},{kind:1617,name:"Patches",description:"Git patches",nip:"34",template:{kind:1617,content:"",tags:[]}},{kind:1618,name:"Pull Requests",description:"Git pull request",nip:"34",template:{kind:1618,content:"",tags:[]}},{kind:1619,name:"Pull Request Updates",description:"Updates to git pull request",nip:"34",template:{kind:1619,content:"",tags:[]}},{kind:1621,name:"Issues",description:"Git issues",nip:"34",template:{kind:1621,content:"",tags:[]}},{kind:1622,name:"Git Replies",description:"Replies on git objects",nip:"34",deprecated:!0,template:{kind:1622,content:"",tags:[]}},{kind:1630,name:"Status",description:"Git status",nip:"34",template:{kind:1630,content:"",tags:[]}},{kind:1631,name:"Status",description:"Git status",nip:"34",template:{kind:1631,content:"",tags:[]}},{kind:1632,name:"Status",description:"Git status",nip:"34",template:{kind:1632,content:"",tags:[]}},{kind:1633,name:"Status",description:"Git status",nip:"34",template:{kind:1633,content:"",tags:[]}},{kind:1808,name:"Live Stream",description:"Live streaming event",nip:null,spec:"zap.stream",template:{kind:1808,content:"",tags:[]}},{kind:1971,name:"Problem Tracker",description:"Problem tracking",nip:null,spec:"Nostrocket",template:{kind:1971,content:"",tags:[]}},{kind:1984,name:"Reporting",description:"Report content or users",nip:"56",template:{kind:1984,content:"",tags:[]}},{kind:1985,name:"Label",description:"Label/tag content with namespace",nip:"32",template:{kind:1985,content:"",tags:[]}},{kind:1986,name:"Relay Reviews",description:"Reviews of relays",nip:null,template:{kind:1986,content:"",tags:[]}},{kind:1987,name:"AI Embeddings",description:"AI embeddings/vector lists",nip:null,spec:"NKBIP-02",template:{kind:1987,content:"",tags:[]}},{kind:2003,name:"Torrent",description:"Torrent magnet link",nip:"35",template:{kind:2003,content:"",tags:[]}},{kind:2004,name:"Torrent Comment",description:"Comment on torrent",nip:"35",template:{kind:2004,content:"",tags:[]}},{kind:2022,name:"Coinjoin Pool",description:"Coinjoin coordination",nip:null,spec:"joinstr",template:{kind:2022,content:"",tags:[]}},{kind:4550,name:"Community Post Approval",description:"Approve post in community",nip:"72",template:{kind:4550,content:"",tags:[]}},{kind:5e3,name:"Job Request",description:"Data vending machine job request (start of range)",nip:"90",template:{kind:5e3,content:"",tags:[]}},{kind:6e3,name:"Job Result",description:"Data vending machine job result (start of range)",nip:"90",template:{kind:6e3,content:"",tags:[]}},{kind:7e3,name:"Job Feedback",description:"Feedback on job request/result",nip:"90",template:{kind:7e3,content:"",tags:[]}},{kind:7374,name:"Reserved Cashu Wallet Tokens",description:"Reserved Cashu wallet tokens",nip:"60",template:{kind:7374,content:"",tags:[]}},{kind:7375,name:"Cashu Wallet Tokens",description:"Cashu wallet tokens",nip:"60",template:{kind:7375,content:"",tags:[]}},{kind:7376,name:"Cashu Wallet History",description:"Cashu wallet transaction history",nip:"60",template:{kind:7376,content:"",tags:[]}},{kind:7516,name:"Geocache Log",description:"Geocaching log entry",nip:null,spec:"geocaching",template:{kind:7516,content:"",tags:[]}},{kind:7517,name:"Geocache Proof of Find",description:"Proof of geocache find",nip:null,spec:"geocaching",template:{kind:7517,content:"",tags:[]}},{kind:8e3,name:"Add User",description:"Add user to group",nip:"43",template:{kind:8e3,content:"",tags:[]}},{kind:8001,name:"Remove User",description:"Remove user from group",nip:"43",template:{kind:8001,content:"",tags:[]}},{kind:9e3,name:"Group Control Events",description:"Group control events (start of range)",nip:"29",template:{kind:9e3,content:"",tags:[]}},{kind:9041,name:"Zap Goal",description:"Fundraising goal for zaps",nip:"75",template:{kind:9041,content:"",tags:[]}},{kind:9321,name:"Nutzap",description:"Cashu nutzap",nip:"61",template:{kind:9321,content:"",tags:[]}},{kind:9467,name:"Tidal Login",description:"Tidal streaming login",nip:null,spec:"Tidal-nostr",template:{kind:9467,content:"",tags:[]}},{kind:9734,name:"Zap Request",description:"Request Lightning payment",nip:"57",template:{kind:9734,content:"",tags:[]}},{kind:9735,name:"Zap",description:"Lightning payment receipt",nip:"57",template:{kind:9735,content:"",tags:[]}},{kind:9802,name:"Highlights",description:"Highlighted text selection",nip:"84",template:{kind:9802,content:"",tags:[]}},{kind:1e4,name:"Mute List",description:"List of muted users/content",nip:"51",isReplaceable:!0,template:{kind:1e4,content:"",tags:[]}},{kind:10001,name:"Pin List",description:"Pinned events",nip:"51",isReplaceable:!0,template:{kind:10001,content:"",tags:[]}},{kind:10002,name:"Relay List Metadata",description:"User's preferred relays for read/write",nip:"65",isReplaceable:!0,template:{kind:10002,content:"",tags:[]}},{kind:10003,name:"Bookmark List",description:"Bookmarked events",nip:"51",isReplaceable:!0,template:{kind:10003,content:"",tags:[]}},{kind:10004,name:"Communities List",description:"Communities user belongs to",nip:"51",isReplaceable:!0,template:{kind:10004,content:"",tags:[]}},{kind:10005,name:"Public Chats List",description:"Public chats user is in",nip:"51",isReplaceable:!0,template:{kind:10005,content:"",tags:[]}},{kind:10006,name:"Blocked Relays List",description:"Relays user has blocked",nip:"51",isReplaceable:!0,template:{kind:10006,content:"",tags:[]}},{kind:10007,name:"Search Relays List",description:"Preferred search relays",nip:"51",isReplaceable:!0,template:{kind:10007,content:"",tags:[]}},{kind:10008,name:"Relay Group Configuration",description:"Relay group configuration",nip:null,isReplaceable:!0,template:{kind:10008,content:"",tags:[]}},{kind:10009,name:"User Groups",description:"Groups user belongs to",nip:"29",isReplaceable:!0,template:{kind:10009,content:"",tags:[]}},{kind:10012,name:"Favorite Relays List",description:"User's favorite relays",nip:"51",isReplaceable:!0,template:{kind:10012,content:"",tags:[]}},{kind:10013,name:"Private Event Relay List",description:"Relays for private events",nip:"37",isReplaceable:!0,template:{kind:10013,content:"",tags:[]}},{kind:10015,name:"Interests List",description:"User interests/topics",nip:"51",isReplaceable:!0,template:{kind:10015,content:"",tags:[]}},{kind:10019,name:"Nutzap Mint Recommendation",description:"Recommended Cashu mints for nutzaps",nip:"61",isReplaceable:!0,template:{kind:10019,content:"",tags:[]}},{kind:10020,name:"Media Follows",description:"Followed media accounts",nip:"51",isReplaceable:!0,template:{kind:10020,content:"",tags:[]}},{kind:10030,name:"User Emoji List",description:"Custom emoji list",nip:"51",isReplaceable:!0,template:{kind:10030,content:"",tags:[]}},{kind:10050,name:"DM Relays List",description:"Relays to receive DMs on",nip:"17",isReplaceable:!0,template:{kind:10050,content:"",tags:[]}},{kind:10051,name:"KeyPackage Relays List",description:"Marmot key package relays",nip:null,isReplaceable:!0,spec:"Marmot",template:{kind:10051,content:"",tags:[]}},{kind:10063,name:"User Server List",description:"Blossom server list",nip:null,isReplaceable:!0,spec:"Blossom",template:{kind:10063,content:"",tags:[]}},{kind:10096,name:"File Storage Server List",description:"File storage servers",nip:"96",isReplaceable:!0,deprecated:!0,template:{kind:10096,content:"",tags:[]}},{kind:10166,name:"Relay Monitor Announcement",description:"Relay monitoring announcement",nip:"66",isReplaceable:!0,template:{kind:10166,content:"",tags:[]}},{kind:10312,name:"Room Presence",description:"Presence in live room",nip:"53",isReplaceable:!0,template:{kind:10312,content:"",tags:[]}},{kind:10377,name:"Proxy Announcement",description:"Nostr proxy announcement",nip:null,isReplaceable:!0,spec:"Nostr Epoxy",template:{kind:10377,content:"",tags:[]}},{kind:11111,name:"Transport Method Announcement",description:"Transport method announcement",nip:null,isReplaceable:!0,spec:"Nostr Epoxy",template:{kind:11111,content:"",tags:[]}},{kind:12345,name:"Relay Policy Configuration",description:"Relay-internal policy configuration (admin only)",nip:null,isReplaceable:!0,spec:"orly",template:{kind:12345,content:"",tags:[]}},{kind:13004,name:"JWT Binding",description:"Link between JWT certificate and pubkey",nip:null,isReplaceable:!0,template:{kind:13004,content:"",tags:[]}},{kind:13194,name:"Wallet Service Info",description:"NWC wallet service information",nip:"47",isReplaceable:!0,template:{kind:13194,content:"",tags:[]}},{kind:13534,name:"Membership Lists",description:"Group membership lists",nip:"43",isReplaceable:!0,template:{kind:13534,content:"",tags:[]}},{kind:14388,name:"User Sound Effect Lists",description:"Sound effect lists",nip:null,isReplaceable:!0,spec:"Corny Chat",template:{kind:14388,content:"",tags:[]}},{kind:17375,name:"Cashu Wallet Event",description:"Cashu wallet event",nip:"60",isReplaceable:!0,template:{kind:17375,content:"",tags:[]}},{kind:21e3,name:"Lightning Pub RPC",description:"Lightning.Pub RPC",nip:null,isEphemeral:!0,spec:"Lightning.Pub",template:{kind:21e3,content:"",tags:[]}},{kind:22242,name:"Client Authentication",description:"Authenticate to relay",nip:"42",isEphemeral:!0,template:{kind:22242,content:"",tags:[]}},{kind:23194,name:"Wallet Request",description:"NWC wallet request",nip:"47",isEphemeral:!0,template:{kind:23194,content:"",tags:[]}},{kind:23195,name:"Wallet Response",description:"NWC wallet response",nip:"47",isEphemeral:!0,template:{kind:23195,content:"",tags:[]}},{kind:23196,name:"Wallet Notification (NIP-04)",description:"NWC wallet notification (NIP-04 encrypted)",nip:"47",isEphemeral:!0,template:{kind:23196,content:"",tags:[]}},{kind:23197,name:"Wallet Notification",description:"NWC wallet notification",nip:"47",isEphemeral:!0,template:{kind:23197,content:"",tags:[]}},{kind:24133,name:"Nostr Connect",description:"Remote signer connection",nip:"46",isEphemeral:!0,template:{kind:24133,content:"",tags:[]}},{kind:24242,name:"Blobs Stored on Mediaservers",description:"Blossom blob storage",nip:null,isEphemeral:!0,spec:"Blossom",template:{kind:24242,content:"",tags:[]}},{kind:27235,name:"HTTP Auth",description:"Authenticate HTTP requests",nip:"98",isEphemeral:!0,template:{kind:27235,content:"",tags:[]}},{kind:28934,name:"Join Request",description:"Request to join group",nip:"43",isEphemeral:!0,template:{kind:28934,content:"",tags:[]}},{kind:28935,name:"Invite Request",description:"Invite to group",nip:"43",isEphemeral:!0,template:{kind:28935,content:"",tags:[]}},{kind:28936,name:"Leave Request",description:"Leave group request",nip:"43",isEphemeral:!0,template:{kind:28936,content:"",tags:[]}},{kind:3e4,name:"Follow Sets",description:"Categorized people lists",nip:"51",isAddressable:!0,template:{kind:3e4,content:"",tags:[["d","identifier"]]}},{kind:30001,name:"Generic Lists",description:"Generic categorized lists",nip:"51",isAddressable:!0,deprecated:!0,template:{kind:30001,content:"",tags:[["d","identifier"]]}},{kind:30002,name:"Relay Sets",description:"Categorized relay lists",nip:"51",isAddressable:!0,template:{kind:30002,content:"",tags:[["d","identifier"]]}},{kind:30003,name:"Bookmark Sets",description:"Categorized bookmark lists",nip:"51",isAddressable:!0,template:{kind:30003,content:"",tags:[["d","identifier"]]}},{kind:30004,name:"Curation Sets",description:"Curated content sets",nip:"51",isAddressable:!0,template:{kind:30004,content:"",tags:[["d","identifier"]]}},{kind:30005,name:"Video Sets",description:"Video playlists",nip:"51",isAddressable:!0,template:{kind:30005,content:"",tags:[["d","identifier"]]}},{kind:30007,name:"Kind Mute Sets",description:"Muted event kinds",nip:"51",isAddressable:!0,template:{kind:30007,content:"",tags:[["d","identifier"]]}},{kind:30008,name:"Profile Badges",description:"Badges displayed on profile",nip:"58",isAddressable:!0,template:{kind:30008,content:"",tags:[["d","identifier"]]}},{kind:30009,name:"Badge Definition",description:"Define a badge/achievement",nip:"58",isAddressable:!0,template:{kind:30009,content:"",tags:[["d","identifier"]]}},{kind:30015,name:"Interest Sets",description:"Interest/topic sets",nip:"51",isAddressable:!0,template:{kind:30015,content:"",tags:[["d","identifier"]]}},{kind:30017,name:"Stall",description:"Marketplace stall definition",nip:"15",isAddressable:!0,template:{kind:30017,content:"",tags:[["d","identifier"]]}},{kind:30018,name:"Product",description:"Marketplace product listing",nip:"15",isAddressable:!0,template:{kind:30018,content:"",tags:[["d","identifier"]]}},{kind:30019,name:"Marketplace UI/UX",description:"Marketplace interface settings",nip:"15",isAddressable:!0,template:{kind:30019,content:"",tags:[["d","identifier"]]}},{kind:30020,name:"Product Sold as Auction",description:"Auction product listing",nip:"15",isAddressable:!0,template:{kind:30020,content:"",tags:[["d","identifier"]]}},{kind:30023,name:"Long-form Content",description:"Blog post, article in markdown",nip:"23",isAddressable:!0,template:{kind:30023,content:"",tags:[["d","identifier"]]}},{kind:30024,name:"Draft Long-form Content",description:"Draft article",nip:"23",isAddressable:!0,template:{kind:30024,content:"",tags:[["d","identifier"]]}},{kind:30030,name:"Emoji Sets",description:"Custom emoji sets",nip:"51",isAddressable:!0,template:{kind:30030,content:"",tags:[["d","identifier"]]}},{kind:30040,name:"Curated Publication Index",description:"Publication index",nip:null,isAddressable:!0,spec:"NKBIP-01",template:{kind:30040,content:"",tags:[["d","identifier"]]}},{kind:30041,name:"Curated Publication Content",description:"Publication content",nip:null,isAddressable:!0,spec:"NKBIP-01",template:{kind:30041,content:"",tags:[["d","identifier"]]}},{kind:30063,name:"Release Artifact Sets",description:"Software release artifacts",nip:"51",isAddressable:!0,template:{kind:30063,content:"",tags:[["d","identifier"]]}},{kind:30078,name:"Application-specific Data",description:"App-specific key-value storage",nip:"78",isAddressable:!0,template:{kind:30078,content:"",tags:[["d","identifier"]]}},{kind:30166,name:"Relay Discovery",description:"Relay discovery/monitoring",nip:"66",isAddressable:!0,template:{kind:30166,content:"",tags:[["d","identifier"]]}},{kind:30267,name:"App Curation Sets",description:"Curated app sets",nip:"51",isAddressable:!0,template:{kind:30267,content:"",tags:[["d","identifier"]]}},{kind:30311,name:"Live Event",description:"Live streaming event",nip:"53",isAddressable:!0,template:{kind:30311,content:"",tags:[["d","identifier"]]}},{kind:30312,name:"Interactive Room",description:"Interactive live room",nip:"53",isAddressable:!0,template:{kind:30312,content:"",tags:[["d","identifier"]]}},{kind:30313,name:"Conference Event",description:"Conference/meetup event",nip:"53",isAddressable:!0,template:{kind:30313,content:"",tags:[["d","identifier"]]}},{kind:30315,name:"User Statuses",description:"User status updates",nip:"38",isAddressable:!0,template:{kind:30315,content:"",tags:[["d","identifier"]]}},{kind:30388,name:"Slide Set",description:"Presentation slides",nip:null,isAddressable:!0,spec:"Corny Chat",template:{kind:30388,content:"",tags:[["d","identifier"]]}},{kind:30402,name:"Classified Listing",description:"Classified ad listing",nip:"99",isAddressable:!0,template:{kind:30402,content:"",tags:[["d","identifier"]]}},{kind:30403,name:"Draft Classified Listing",description:"Draft classified ad",nip:"99",isAddressable:!0,template:{kind:30403,content:"",tags:[["d","identifier"]]}},{kind:30617,name:"Repository Announcements",description:"Git repository announcement",nip:"34",isAddressable:!0,template:{kind:30617,content:"",tags:[["d","identifier"]]}},{kind:30618,name:"Repository State Announcements",description:"Git repository state",nip:"34",isAddressable:!0,template:{kind:30618,content:"",tags:[["d","identifier"]]}},{kind:30818,name:"Wiki Article",description:"Wiki article",nip:"54",isAddressable:!0,template:{kind:30818,content:"",tags:[["d","identifier"]]}},{kind:30819,name:"Redirects",description:"URL redirects",nip:"54",isAddressable:!0,template:{kind:30819,content:"",tags:[["d","identifier"]]}},{kind:31234,name:"Draft Event",description:"Draft of any event",nip:"37",isAddressable:!0,template:{kind:31234,content:"",tags:[["d","identifier"]]}},{kind:31388,name:"Link Set",description:"Link collection",nip:null,isAddressable:!0,spec:"Corny Chat",template:{kind:31388,content:"",tags:[["d","identifier"]]}},{kind:31890,name:"Feed",description:"Custom feed definition",nip:null,isAddressable:!0,spec:"NUD: Custom Feeds",template:{kind:31890,content:"",tags:[["d","identifier"]]}},{kind:31922,name:"Date-Based Calendar Event",description:"All-day calendar event",nip:"52",isAddressable:!0,template:{kind:31922,content:"",tags:[["d","identifier"]]}},{kind:31923,name:"Time-Based Calendar Event",description:"Calendar event with time",nip:"52",isAddressable:!0,template:{kind:31923,content:"",tags:[["d","identifier"]]}},{kind:31924,name:"Calendar",description:"Calendar definition",nip:"52",isAddressable:!0,template:{kind:31924,content:"",tags:[["d","identifier"]]}},{kind:31925,name:"Calendar Event RSVP",description:"RSVP to calendar event",nip:"52",isAddressable:!0,template:{kind:31925,content:"",tags:[["d","identifier"]]}},{kind:31989,name:"Handler Recommendation",description:"Recommended app for event kind",nip:"89",isAddressable:!0,template:{kind:31989,content:"",tags:[["d","identifier"]]}},{kind:31990,name:"Handler Information",description:"App handler declaration",nip:"89",isAddressable:!0,template:{kind:31990,content:"",tags:[["d","identifier"]]}},{kind:32123,name:"WaveLake Track",description:"WaveLake music track",nip:null,isAddressable:!0,spec:"WaveLake",template:{kind:32123,content:"",tags:[["d","identifier"]]}},{kind:32267,name:"Software Application",description:"Software application listing",nip:null,isAddressable:!0,template:{kind:32267,content:"",tags:[["d","identifier"]]}},{kind:32388,name:"User Room Favorites",description:"Favorite rooms",nip:null,isAddressable:!0,spec:"Corny Chat",template:{kind:32388,content:"",tags:[["d","identifier"]]}},{kind:33388,name:"High Scores",description:"Game high scores",nip:null,isAddressable:!0,spec:"Corny Chat",template:{kind:33388,content:"",tags:[["d","identifier"]]}},{kind:34235,name:"Video Event Horizontal",description:"Horizontal video event",nip:"71",isAddressable:!0,template:{kind:34235,content:"",tags:[["d","identifier"]]}},{kind:34236,name:"Video Event Vertical",description:"Vertical video event",nip:"71",isAddressable:!0,template:{kind:34236,content:"",tags:[["d","identifier"]]}},{kind:34388,name:"Sound Effects",description:"Sound effect definitions",nip:null,isAddressable:!0,spec:"Corny Chat",template:{kind:34388,content:"",tags:[["d","identifier"]]}},{kind:34550,name:"Community Definition",description:"Define a community",nip:"72",isAddressable:!0,template:{kind:34550,content:"",tags:[["d","identifier"]]}},{kind:37516,name:"Geocache Listing",description:"Geocache location listing",nip:null,isAddressable:!0,spec:"geocaching",template:{kind:37516,content:"",tags:[["d","identifier"]]}},{kind:38172,name:"Cashu Mint Announcement",description:"Cashu mint announcement",nip:"87",isAddressable:!0,template:{kind:38172,content:"",tags:[["d","identifier"]]}},{kind:38173,name:"Fedimint Announcement",description:"Fedimint announcement",nip:"87",isAddressable:!0,template:{kind:38173,content:"",tags:[["d","identifier"]]}},{kind:38383,name:"Peer-to-peer Order Events",description:"P2P trading orders",nip:"69",isAddressable:!0,template:{kind:38383,content:"",tags:[["d","identifier"]]}},{kind:39e3,name:"Group Metadata Events",description:"Group metadata (start of range)",nip:"29",isAddressable:!0,template:{kind:39e3,content:"",tags:[["d","identifier"]]}},{kind:39089,name:"Starter Packs",description:"Starter pack lists",nip:"51",isAddressable:!0,template:{kind:39089,content:"",tags:[["d","identifier"]]}},{kind:39092,name:"Media Starter Packs",description:"Media starter packs",nip:"51",isAddressable:!0,template:{kind:39092,content:"",tags:[["d","identifier"]]}},{kind:39701,name:"Web Bookmarks",description:"Web URL bookmarks",nip:"B0",isAddressable:!0,template:{kind:39701,content:"",tags:[["d","identifier"]]}},{kind:39998,name:"ACL Event",description:"Access control list event",nip:null,isAddressable:!0,template:{kind:39998,content:"",tags:[["d","identifier"]]}}];function gy(e,t=null){const n=function(e){return py.find(t=>t.kind===e)}(e);return n?{...n.template,created_at:Math.floor(Date.now()/1e3),pubkey:t||""}:{kind:e,content:"",tags:[],created_at:Math.floor(Date.now()/1e3),pubkey:t||""}}const my=[{id:"all",name:"All Kinds",filter:()=>!0},{id:"regular",name:"Regular Events (0-9999)",filter:e=>e.kind<1e4&&!e.isReplaceable},{id:"replaceable",name:"Replaceable (10000-19999)",filter:e=>e.isReplaceable},{id:"ephemeral",name:"Ephemeral (20000-29999)",filter:e=>e.isEphemeral},{id:"addressable",name:"Addressable (30000-39999)",filter:e=>e.isAddressable},{id:"social",name:"Social",filter:e=>[0,1,3,6,7].includes(e.kind)},{id:"messaging",name:"Messaging",filter:e=>[4,9,10,11,12,14,15,40,41,42].includes(e.kind)},{id:"lists",name:"Lists",filter:e=>e.name.toLowerCase().includes("list")||e.name.toLowerCase().includes("set")},{id:"marketplace",name:"Marketplace",filter:e=>[30017,30018,30019,30020,1021,1022,30402,30403].includes(e.kind)},{id:"lightning",name:"Lightning/Zaps",filter:e=>[9734,9735,9041,9321,7374,7375,7376].includes(e.kind)},{id:"media",name:"Media",filter:e=>[20,21,22,1063,1222,1244].includes(e.kind)},{id:"git",name:"Git/Code",filter:e=>[818,1337,1617,1618,1619,1621,1622,30617,30618].includes(e.kind)},{id:"calendar",name:"Calendar",filter:e=>[31922,31923,31924,31925].includes(e.kind)},{id:"groups",name:"Groups",filter:e=>e.kind>=9e3&&e.kind<=9030||e.kind>=39e3&&e.kind<=39009}];function yy(e,t,n){const r=e.slice();return r[13]=t[n],r}function wy(e,t,n){const r=e.slice();return r[16]=t[n],r}function vy(e){let t,n,i,o,s,a,l,p,y,v,b,E,C,x,B,S,F,Q,D,R,P,$,U,T,N,L=e[3].length+"",O=1!==e[3].length?"s":"",M=my,_=[];for(let t=0;t=2e4&&e.kind<3e4?"badge-ephemeral":"badge-regular"}function By(e){return e.isAddressable?"Addressable":e.isReplaceable?"Replaceable":e.kind>=2e4&&e.kind<3e4?"Ephemeral":"Regular"}function Sy(e,t,n){let{isOpen:r=!1}=t,{userPubkey:i=""}=t;const o=P();let s="",a="all",l=py;function c(e){const t=gy(e.kind,i);o("select",{kind:e,template:t}),u()}function u(){n(0,r=!1),n(1,s=""),n(2,a="all"),o("close")}return e.$$set=e=>{"isOpen"in e&&n(0,r=e.isOpen),"userPubkey"in e&&n(8,i=e.userPubkey)},e.$$.update=()=>{if(6&e.$$.dirty){let e=py;const t=my.find(e=>e.id===a);if(t&&(e=e.filter(t.filter)),s.trim()){const t=s.toLowerCase();e=e.filter(e=>e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.kind.toString().includes(t)||e.nip&&e.nip.includes(t))}n(3,l=e)}},[r,s,a,l,c,u,function(e){"Escape"===e.key&&u()},function(e){e.target===e.currentTarget&&u()},i,function(){s=this.value,n(1,s)},e=>n(2,a=e.id),e=>c(e)]}class Fy extends ae{constructor(e){super(),se(this,e,Sy,Cy,o,{isOpen:0,userPubkey:8})}}function Qy(e){let t,n,r,i,o,s,a,l,f,p;return{c(){t=h("div"),n=h("div"),r=h("span"),r.textContent="⚠",i=m(),o=h("span"),s=g(e[1]),a=m(),l=h("button"),l.textContent="×",A(r,"class","error-icon svelte-46pmgb"),A(o,"class","error-message svelte-46pmgb"),A(n,"class","error-content svelte-46pmgb"),A(l,"class","error-dismiss svelte-46pmgb"),A(t,"class","error-banner svelte-46pmgb")},m(d,h){u(d,t,h),c(t,n),c(n,r),c(n,i),c(n,o),c(o,s),c(t,a),c(t,l),f||(p=w(l,"click",e[10]),f=!0)},p(e,t){2&t&&k(s,e[1])},d(e){e&&d(t),f=!1,p()}}}function Dy(e){let t,n,i,o,s,a,l,f,p,g,y,v,b,k,E,C,x,B,S,F=e[1]&&Qy(e);function Q(t){e[14](t)}let D={userPubkey:e[2]};return void 0!==e[3]&&(D.isOpen=e[3]),E=new Fy({props:D}),T.push(()=>te(E,"isOpen",Q)),E.$on("select",e[8]),E.$on("close",e[9]),{c(){t=h("div"),n=h("div"),i=h("button"),i.textContent="Generate Template",o=m(),s=h("button"),s.textContent="Reformat",a=m(),l=h("button"),l.textContent="Sign",f=m(),p=h("button"),p.textContent="Publish",g=m(),F&&F.c(),y=m(),v=h("div"),b=h("textarea"),k=m(),ne(E.$$.fragment),A(i,"class","compose-btn template-btn svelte-46pmgb"),A(s,"class","compose-btn reformat-btn svelte-46pmgb"),A(l,"class","compose-btn sign-btn svelte-46pmgb"),A(p,"class","compose-btn publish-btn svelte-46pmgb"),A(n,"class","compose-header svelte-46pmgb"),A(b,"class","compose-textarea svelte-46pmgb"),A(b,"placeholder","Enter your Nostr event JSON here, or click 'Generate Template' to start with a template..."),A(b,"spellcheck","false"),A(v,"class","compose-editor svelte-46pmgb"),A(t,"class","compose-view svelte-46pmgb")},m(r,d){u(r,t,d),c(t,n),c(n,i),c(n,o),c(n,s),c(n,a),c(n,l),c(n,f),c(n,p),c(t,g),F&&F.m(t,null),c(t,y),c(t,v),c(v,b),I(b,e[0]),u(r,k,d),re(E,r,d),x=!0,B||(S=[w(i,"click",e[7]),w(s,"click",e[4]),w(l,"click",e[5]),w(p,"click",e[6]),w(b,"input",e[13])],B=!0)},p(e,[n]){e[1]?F?F.p(e,n):(F=Qy(e),F.c(),F.m(t,y)):F&&(F.d(1),F=null),1&n&&I(b,e[0]);const r={};4&n&&(r.userPubkey=e[2]),!C&&8&n&&(C=!0,r.isOpen=e[3],H(()=>C=!1)),E.$set(r)},i(e){x||(W(E.$$.fragment,e),x=!0)},o(e){Z(E.$$.fragment,e),x=!1},d(e){e&&d(t),F&&F.d(),e&&d(k),ie(E,e),B=!1,r(S)}}}function Ry(e,t,n){let{composeEventJson:r=""}=t,{userPubkey:i=""}=t,{userRole:o=""}=t,{policyEnabled:s=!1}=t,{publishError:a=""}=t;const l=P();let c=!1;return e.$$set=e=>{"composeEventJson"in e&&n(0,r=e.composeEventJson),"userPubkey"in e&&n(2,i=e.userPubkey),"userRole"in e&&n(11,o=e.userRole),"policyEnabled"in e&&n(12,s=e.policyEnabled),"publishError"in e&&n(1,a=e.publishError)},[r,a,i,c,function(){l("reformatJson")},function(){l("signEvent")},function(){l("publishEvent")},function(){n(3,c=!0)},function(e){const{kind:t,template:i}=e.detail;n(0,r=JSON.stringify(i,null,2)),l("templateSelected",{kind:t,template:i})},function(){n(3,c=!1)},function(){n(1,a=""),l("clearError")},o,s,function(){r=this.value,n(0,r)},function(e){c=e,n(3,c)}]}class Py extends ae{constructor(e){super(),se(this,e,Ry,Dy,o,{composeEventJson:0,userPubkey:2,userRole:11,policyEnabled:12,publishError:1})}}function $y(e,t,n){const r=e.slice();return r[23]=t[n],r}function Uy(t){let n,r,i,o,s,a;return{c(){n=h("div"),r=h("p"),r.textContent="Please log in to access sprocket management.",i=m(),o=h("button"),o.textContent="Log In",A(r,"class","svelte-fiaj1r"),A(o,"class","login-btn svelte-fiaj1r"),A(n,"class","login-prompt svelte-fiaj1r")},m(e,l){u(e,n,l),c(n,r),c(n,i),c(n,o),s||(a=w(o,"click",t[18]),s=!0)},p:e,d(e){e&&d(n),s=!1,a()}}}function Ty(e){let t,n,r,i,o,s,a,l,f,p=(e[2]||"none")+"";return{c(){t=h("div"),n=h("p"),n.textContent="❌ Owner permission required for sprocket management.",r=m(),i=h("p"),i.innerHTML='To enable sprocket functionality, set the ORLY_OWNERS environment variable with your npub when starting the relay.',o=m(),s=h("p"),a=g("Current user role: "),l=h("strong"),f=g(p),A(n,"class","svelte-fiaj1r"),A(i,"class","svelte-fiaj1r"),A(s,"class","svelte-fiaj1r"),A(t,"class","permission-denied svelte-fiaj1r")},m(e,d){u(e,t,d),c(t,n),c(t,r),c(t,i),c(t,o),c(t,s),c(s,a),c(s,l),c(l,f)},p(e,t){4&t&&p!==(p=(e[2]||"none")+"")&&k(f,p)},d(e){e&&d(t)}}}function Ny(e){let t,n,i,o,s,a,l,p,y,v,b,E,C,x,S,F,Q,D,R,P,$,U,T,N,L,O,M,_,H,j,G,q,K,J,V,Y,z,W,Z,X,ee,te,ne,re,ie,oe,se,ae,le,ce,ue,de,fe,he,pe,ge,me=e[3]?.is_running?"🟢 Running":"🔴 Stopped",ye=e[3]?.script_exists?"✅ Exists":"❌ Not found",we=e[3]?.pid&&Ly(e),ve=e[6]&&Oy(e),Ae=e[8],be=[];for(let t=0;t{"isLoggedIn"in e&&n(1,r=e.isLoggedIn),"userRole"in e&&n(2,i=e.userRole),"sprocketStatus"in e&&n(3,o=e.sprocketStatus),"isLoadingSprocket"in e&&n(4,s=e.isLoadingSprocket),"sprocketUploadFile"in e&&n(5,a=e.sprocketUploadFile),"sprocketScript"in e&&n(0,l=e.sprocketScript),"sprocketMessage"in e&&n(6,c=e.sprocketMessage),"sprocketMessageType"in e&&n(7,u=e.sprocketMessageType),"sprocketVersions"in e&&n(8,d=e.sprocketVersions)},[l,r,i,o,s,a,c,u,d,function(){f("restartSprocket")},function(){f("deleteSprocket")},function(e){f("sprocketFileSelect",e)},function(){f("uploadSprocketScript")},function(){f("saveSprocket")},function(){f("loadSprocket")},function(){f("loadVersions")},h,p,function(){f("openLoginModal")},function(){l=this.value,n(0,l)},e=>h(e),e=>p(e.name)]}class qy extends ae{constructor(e){super(),se(this,e,Gy,jy,o,{isLoggedIn:1,userRole:2,sprocketStatus:3,isLoadingSprocket:4,sprocketUploadFile:5,sprocketScript:0,sprocketMessage:6,sprocketMessageType:7,sprocketVersions:8})}}function Ky(e,t,n){const r=e.slice();return r[26]=t[n],r}function Jy(e,t,n){const r=e.slice();return r[29]=t[n],r}function Vy(e,t,n){const r=e.slice();return r[32]=t[n],r}function Yy(t){let n,r,i,o,s,a;return{c(){n=h("div"),r=h("p"),r.textContent="Please log in to access policy configuration.",i=m(),o=h("button"),o.textContent="Log In",A(r,"class","svelte-gkxvxc"),A(o,"class","login-btn svelte-gkxvxc"),A(n,"class","login-prompt svelte-gkxvxc")},m(e,l){u(e,n,l),c(n,r),c(n,i),c(n,o),s||(a=w(o,"click",t[16]),s=!0)},p:e,d(e){e&&d(n),s=!1,a()}}}function zy(e){let t,n,r,i,o,s,a,l,f,p=(e[3]||"none")+"";return{c(){t=h("div"),n=h("p"),n.textContent="Policy configuration requires owner or policy admin permissions.",r=m(),i=h("p"),i.innerHTML='To become a policy admin, ask an existing policy admin to add your pubkey\n to the policy_admins list.',o=m(),s=h("p"),a=g("Current user role: "),l=h("strong"),f=g(p),A(n,"class","svelte-gkxvxc"),A(i,"class","svelte-gkxvxc"),A(s,"class","svelte-gkxvxc"),A(t,"class","permission-denied svelte-gkxvxc")},m(e,d){u(e,t,d),c(t,n),c(t,r),c(t,i),c(t,o),c(t,s),c(s,a),c(s,l),c(l,f)},p(e,t){8&t[0]&&p!==(p=(e[3]||"none")+"")&&k(f,p)},d(e){e&&d(t)}}}function Wy(e){let t,n,i,o,s,a,l,f,p,y,v,b,E,C,x,S,F,Q,D,R,P,$,U,T,N,L,O,M,_,H,j,G,q,K,J,V,Y,z,W,Z,X,ee,te,ne,re,ie,oe,se,ae,le,ce,ue,de,fe,he,pe,ge,me,ye,we,ve,Ae,be,ke,Ie,Ee,Ce,xe,Be,Se,Fe,Qe,De,Re,Pe,$e=e[5]?"Policy Enabled":"Policy Disabled",Ue=e[10].length+"",Te=e[4]&&Zy(),Ne=e[9].length>0&&Xy(e),Le=e[7]&&tw(e);function Oe(e,t){return 0===e[1].length?rw:nw}let Me=Oe(e),_e=Me(e);function He(e,t){return 0===e[10].length?sw:ow}let je=He(e),Ge=je(e);return{c(){t=h("div"),n=h("div"),i=h("h3"),i.textContent="Policy Editor",o=m(),s=h("div"),a=h("span"),l=g($e),f=m(),Te&&Te.c(),p=m(),y=h("div"),y.innerHTML='

Edit the policy JSON below and click "Save & Publish" to update the relay's policy configuration.\n Changes are applied immediately after validation.

\n

Policy updates are published as kind 12345 events and require policy admin permissions.

',v=m(),b=h("div"),E=h("textarea"),C=m(),Ne&&Ne.c(),x=m(),S=h("div"),F=h("button"),Q=g("Load Current"),D=m(),R=h("button"),P=g("Format JSON"),$=m(),U=h("button"),T=g("Validate"),N=m(),L=h("button"),O=g("Save & Publish"),M=m(),Le&&Le.c(),_=m(),H=h("div"),j=h("h3"),j.textContent="Policy Administrators",G=m(),q=h("div"),q.innerHTML='

Policy admins can update the relay's policy configuration via kind 12345 events.\n Their follows get whitelisted if policy_follow_whitelist_enabled is true in the policy.

\n

Note: Policy admins are separate from relay admins (ORLY_ADMINS).\n Changes here update the JSON editor - click "Save & Publish" to apply.

',K=m(),J=h("div"),_e.c(),V=m(),Y=h("div"),z=h("input"),W=m(),Z=h("button"),X=g("+ Add Admin"),te=m(),ne=h("div"),re=h("h3"),re.textContent="Policy Follow Whitelist",ie=m(),oe=h("div"),oe.innerHTML='

Pubkeys followed by policy admins (kind 3 events).\n These get automatic read+write access when rules have write_allow_follows: true.

',se=m(),ae=h("div"),le=h("span"),ce=g(Ue),ue=g(" pubkey(s) in whitelist"),de=m(),fe=h("button"),he=g("🔄 Refresh Follows"),pe=m(),ge=h("div"),Ge.c(),me=m(),ye=h("div"),we=h("h3"),we.textContent="Policy Reference",ve=m(),Ae=h("div"),be=h("h4"),be.textContent="Structure Overview",ke=m(),Ie=h("ul"),Ie.innerHTML='
  • kind.whitelist - Only allow these event kinds (takes precedence)
  • \n
  • kind.blacklist - Deny these event kinds (if no whitelist)
  • \n
  • global - Rules applied to all events
  • \n
  • rules - Per-kind rules (keyed by kind number as string)
  • \n
  • default_policy - "allow" or "deny" when no rules match
  • \n
  • policy_admins - Hex pubkeys that can update policy
  • \n
  • policy_follow_whitelist_enabled - Enable follow-based access
  • ',Ee=m(),Ce=h("h4"),Ce.textContent="Rule Fields",xe=m(),Be=h("ul"),Be.innerHTML='
  • description - Human-readable rule description
  • \n
  • write_allow / write_deny - Pubkey lists for write access
  • \n
  • read_allow / read_deny - Pubkey lists for read access
  • \n
  • write_allow_follows - Grant access to policy admin follows
  • \n
  • size_limit - Max total event size in bytes
  • \n
  • content_limit - Max content field size in bytes
  • \n
  • max_expiry - Max expiry offset in seconds
  • \n
  • max_age_of_event - Max age of created_at in seconds
  • \n
  • max_age_event_in_future - Max future offset in seconds
  • \n
  • must_have_tags - Required tag letters (e.g., ["d", "t"])
  • \n
  • tag_validation - Regex patterns for tag values
  • \n
  • script - Path to external validation script
  • ',Se=m(),Fe=h("h4"),Fe.textContent="Example Policy",Qe=m(),De=h("pre"),De.textContent=`${e[20]}`,A(i,"class","svelte-gkxvxc"),A(a,"class","status-badge svelte-gkxvxc"),B(a,"enabled",e[5]),A(s,"class","policy-status svelte-gkxvxc"),A(n,"class","policy-header svelte-gkxvxc"),A(y,"class","policy-info svelte-gkxvxc"),A(E,"class","policy-editor svelte-gkxvxc"),A(E,"placeholder","Loading policy configuration..."),E.disabled=e[6],A(E,"spellcheck","false"),A(b,"class","editor-container svelte-gkxvxc"),A(F,"class","policy-btn load-btn svelte-gkxvxc"),F.disabled=e[6],A(R,"class","policy-btn format-btn svelte-gkxvxc"),R.disabled=e[6],A(U,"class","policy-btn validate-btn svelte-gkxvxc"),U.disabled=e[6],A(L,"class","policy-btn save-btn svelte-gkxvxc"),L.disabled=e[6],A(S,"class","policy-actions svelte-gkxvxc"),A(t,"class","policy-section svelte-gkxvxc"),A(q,"class","policy-info svelte-gkxvxc"),A(J,"class","admin-list svelte-gkxvxc"),A(z,"type","text"),A(z,"placeholder","npub or hex pubkey"),z.disabled=e[6],A(z,"class","svelte-gkxvxc"),A(Z,"class","policy-btn add-btn svelte-gkxvxc"),Z.disabled=ee=e[6]||!e[11].trim(),A(Y,"class","add-admin svelte-gkxvxc"),A(H,"class","policy-section svelte-gkxvxc"),A(oe,"class","policy-info svelte-gkxvxc"),A(le,"class","follows-count svelte-gkxvxc"),A(fe,"class","policy-btn refresh-btn svelte-gkxvxc"),fe.disabled=e[6],A(ae,"class","follows-header svelte-gkxvxc"),A(ge,"class","follows-list svelte-gkxvxc"),A(ne,"class","policy-section svelte-gkxvxc"),A(be,"class","svelte-gkxvxc"),A(Ie,"class","field-list svelte-gkxvxc"),A(Ce,"class","svelte-gkxvxc"),A(Be,"class","field-list svelte-gkxvxc"),A(Fe,"class","svelte-gkxvxc"),A(De,"class","example-json svelte-gkxvxc"),A(Ae,"class","reference-content svelte-gkxvxc"),A(ye,"class","policy-section svelte-gkxvxc")},m(r,d){u(r,t,d),c(t,n),c(n,i),c(n,o),c(n,s),c(s,a),c(a,l),c(s,f),Te&&Te.m(s,null),c(t,p),c(t,y),c(t,v),c(t,b),c(b,E),I(E,e[0]),c(t,C),Ne&&Ne.m(t,null),c(t,x),c(t,S),c(S,F),c(F,Q),c(S,D),c(S,R),c(R,P),c(S,$),c(S,U),c(U,T),c(S,N),c(S,L),c(L,O),c(t,M),Le&&Le.m(t,null),u(r,_,d),u(r,H,d),c(H,j),c(H,G),c(H,q),c(H,K),c(H,J),_e.m(J,null),c(H,V),c(H,Y),c(Y,z),I(z,e[11]),c(Y,W),c(Y,Z),c(Z,X),u(r,te,d),u(r,ne,d),c(ne,re),c(ne,ie),c(ne,oe),c(ne,se),c(ne,ae),c(ae,le),c(le,ce),c(le,ue),c(ae,de),c(ae,fe),c(fe,he),c(ne,pe),c(ne,ge),Ge.m(ge,null),u(r,me,d),u(r,ye,d),c(ye,we),c(ye,ve),c(ye,Ae),c(Ae,be),c(Ae,ke),c(Ae,Ie),c(Ae,Ee),c(Ae,Ce),c(Ae,xe),c(Ae,Be),c(Ae,Se),c(Ae,Fe),c(Ae,Qe),c(Ae,De),Re||(Pe=[w(E,"input",e[21]),w(F,"click",e[12]),w(R,"click",e[15]),w(U,"click",e[13]),w(L,"click",e[14]),w(z,"input",e[23]),w(z,"keydown",e[24]),w(Z,"click",e[18]),w(fe,"click",e[17])],Re=!0)},p(e,n){32&n[0]&&$e!==($e=e[5]?"Policy Enabled":"Policy Disabled")&&k(l,$e),32&n[0]&&B(a,"enabled",e[5]),e[4]?Te||(Te=Zy(),Te.c(),Te.m(s,null)):Te&&(Te.d(1),Te=null),64&n[0]&&(E.disabled=e[6]),1&n[0]&&I(E,e[0]),e[9].length>0?Ne?Ne.p(e,n):(Ne=Xy(e),Ne.c(),Ne.m(t,x)):Ne&&(Ne.d(1),Ne=null),64&n[0]&&(F.disabled=e[6]),64&n[0]&&(R.disabled=e[6]),64&n[0]&&(U.disabled=e[6]),64&n[0]&&(L.disabled=e[6]),e[7]?Le?Le.p(e,n):(Le=tw(e),Le.c(),Le.m(t,null)):Le&&(Le.d(1),Le=null),Me===(Me=Oe(e))&&_e?_e.p(e,n):(_e.d(1),_e=Me(e),_e&&(_e.c(),_e.m(J,null))),64&n[0]&&(z.disabled=e[6]),2048&n[0]&&z.value!==e[11]&&I(z,e[11]),2112&n[0]&&ee!==(ee=e[6]||!e[11].trim())&&(Z.disabled=ee),1024&n[0]&&Ue!==(Ue=e[10].length+"")&&k(ce,Ue),64&n[0]&&(fe.disabled=e[6]),je===(je=He(e))&&Ge?Ge.p(e,n):(Ge.d(1),Ge=je(e),Ge&&(Ge.c(),Ge.m(ge,null)))},d(e){e&&d(t),Te&&Te.d(),Ne&&Ne.d(),Le&&Le.d(),e&&d(_),e&&d(H),_e.d(),e&&d(te),e&&d(ne),Ge.d(),e&&d(me),e&&d(ye),Re=!1,r(Pe)}}}function Zy(e){let t;return{c(){t=h("span"),t.textContent="Policy Admin",A(t,"class","admin-badge svelte-gkxvxc")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Xy(e){let t,n,r,i,o=e[9],s=[];for(let t=0;t{"isLoggedIn"in e&&n(2,r=e.isLoggedIn),"userRole"in e&&n(3,i=e.userRole),"isPolicyAdmin"in e&&n(4,o=e.isPolicyAdmin),"policyEnabled"in e&&n(5,s=e.policyEnabled),"policyJson"in e&&n(0,a=e.policyJson),"isLoadingPolicy"in e&&n(6,l=e.isLoadingPolicy),"policyMessage"in e&&n(7,c=e.policyMessage),"policyMessageType"in e&&n(8,u=e.policyMessageType),"validationErrors"in e&&n(9,d=e.validationErrors),"policyAdmins"in e&&n(1,f=e.policyAdmins),"policyFollows"in e&&n(10,h=e.policyFollows)},e.$$.update=()=>{if(1&e.$$.dirty[0])try{if(a){const e=JSON.parse(a);n(1,f=e.policy_admins||[])}}catch(e){}},[a,f,r,i,o,s,l,c,u,d,h,g,function(){p("loadPolicy")},function(){p("validatePolicy")},function(){p("savePolicy")},function(){p("formatJson")},function(){p("openLoginModal")},function(){p("refreshFollows")},m,y,'{\n "kind": {\n "whitelist": [0, 1, 3, 6, 7, 10002],\n "blacklist": []\n },\n "global": {\n "description": "Global rules applied to all events",\n "size_limit": 65536,\n "max_age_of_event": 86400,\n "max_age_event_in_future": 300\n },\n "rules": {\n "1": {\n "description": "Kind 1 (short text notes)",\n "content_limit": 8192,\n "write_allow_follows": true\n },\n "30023": {\n "description": "Long-form articles",\n "content_limit": 100000,\n "tag_validation": {\n "d": "^[a-z0-9-]{1,64}$",\n "t": "^[a-z0-9-]{1,32}$"\n }\n }\n },\n "default_policy": "allow",\n "policy_admins": [""],\n "policy_follow_whitelist_enabled": true\n}',function(){a=this.value,n(0,a)},e=>y(e),function(){g=this.value,n(11,g)},e=>"Enter"===e.key&&m()]}class uw extends ae{constructor(e){super(),se(this,e,cw,lw,o,{isLoggedIn:2,userRole:3,isPolicyAdmin:4,policyEnabled:5,policyJson:0,isLoadingPolicy:6,policyMessage:7,policyMessageType:8,validationErrors:9,policyAdmins:1,policyFollows:10},null,[-1,-1])}}const{window:dw}=l;function fw(e,t,n){const r=e.slice();return r[57]=t[n],r}function hw(e,t,n){const r=e.slice();return r[54]=t[n],r}function pw(t){let n,r,i,o,s,a;return{c(){n=h("div"),r=h("p"),r.textContent="Please log in to view your Blossom storage.",i=m(),o=h("button"),o.textContent="Log In",A(r,"class","svelte-on0yal"),A(o,"class","login-btn svelte-on0yal"),A(n,"class","login-prompt svelte-on0yal")},m(e,l){u(e,n,l),c(n,r),c(n,i),c(n,o),s||(a=w(o,"click",t[20]),s=!0)},p:e,d(e){e&&d(n),s=!1,a()}}}function gw(e){let t,n,r,i,o,s,a,l,f,p,y,v,b,I,E=e[0]||e[12]?"Loading...":"Refresh";function C(e,t){return e[13]?ww:e[10]?yw:mw}let x=C(e),B=x(e),S=e[14]&&!e[10]&&!e[13]&&Aw(e),F=!e[10]&&!e[13]&&bw(e),Q=e[2]&&Iw(e);function D(e,t){return e[10]&&!e[13]?Cw:Ew}let R=D(e),P=R(e);return{c(){t=h("div"),n=h("div"),B.c(),r=m(),i=h("div"),S&&S.c(),o=m(),s=h("button"),a=g("🔄 "),l=g(E),p=m(),F&&F.c(),y=m(),Q&&Q.c(),v=m(),P.c(),A(s,"class","refresh-btn svelte-on0yal"),s.disabled=f=e[0]||e[12],A(i,"class","header-buttons svelte-on0yal"),A(n,"class","header-section svelte-on0yal"),A(t,"class","blossom-view svelte-on0yal")},m(d,f){u(d,t,f),c(t,n),B.m(n,null),c(n,r),c(n,i),S&&S.m(i,null),c(i,o),c(i,s),c(s,a),c(s,l),c(t,p),F&&F.m(t,null),c(t,y),Q&&Q.m(t,null),c(t,v),P.m(t,null),b||(I=w(s,"click",e[30]),b=!0)},p(e,a){x===(x=C(e))&&B?B.p(e,a):(B.d(1),B=x(e),B&&(B.c(),B.m(n,r))),!e[14]||e[10]||e[13]?S&&(S.d(1),S=null):S?S.p(e,a):(S=Aw(e),S.c(),S.m(i,o)),4097&a[0]&&E!==(E=e[0]||e[12]?"Loading...":"Refresh")&&k(l,E),4097&a[0]&&f!==(f=e[0]||e[12])&&(s.disabled=f),e[10]||e[13]?F&&(F.d(1),F=null):F?F.p(e,a):(F=bw(e),F.c(),F.m(t,y)),e[2]?Q?Q.p(e,a):(Q=Iw(e),Q.c(),Q.m(t,v)):Q&&(Q.d(1),Q=null),R===(R=D(e))&&P?P.p(e,a):(P.d(1),P=R(e),P&&(P.c(),P.m(t,null)))},d(e){e&&d(t),B.d(),S&&S.d(),F&&F.d(),Q&&Q.d(),P.d(),b=!1,I()}}}function mw(t){let n;return{c(){n=h("h3"),n.textContent="Blossom Media Storage",A(n,"class","svelte-on0yal")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function yw(t){let n,r,i,o,s;return{c(){n=h("button"),n.textContent="← Back",r=m(),i=h("h3"),i.textContent="All Users Storage",A(n,"class","back-btn svelte-on0yal"),A(i,"class","svelte-on0yal")},m(e,a){u(e,n,a),u(e,r,a),u(e,i,a),o||(s=w(n,"click",t[27]),o=!0)},p:e,d(e){e&&d(n),e&&d(r),e&&d(i),o=!1,s()}}}function ww(e){let t,n,r,i,o,s,a,l=(e[13].profile?.name||tv(e[25](e[13].pubkey)))+"",f=e[13].profile?.picture&&vw(e);return{c(){t=h("button"),t.textContent="← Back",n=m(),r=h("h3"),f&&f.c(),i=m(),o=g(l),A(t,"class","back-btn svelte-on0yal"),A(r,"class","user-header svelte-on0yal")},m(l,d){u(l,t,d),u(l,n,d),u(l,r,d),f&&f.m(r,null),c(r,i),c(r,o),s||(a=w(t,"click",e[29]),s=!0)},p(e,t){e[13].profile?.picture?f?f.p(e,t):(f=vw(e),f.c(),f.m(r,i)):f&&(f.d(1),f=null),8192&t[0]&&l!==(l=(e[13].profile?.name||tv(e[25](e[13].pubkey)))+"")&&k(o,l)},d(e){e&&d(t),e&&d(n),e&&d(r),f&&f.d(),s=!1,a()}}}function vw(e){let t,n;return{c(){t=h("img"),a(t.src,n=e[13].profile.picture)||A(t,"src",n),A(t,"alt",""),A(t,"class","header-avatar svelte-on0yal")},m(e,n){u(e,t,n)},p(e,r){8192&r[0]&&!a(t.src,n=e[13].profile.picture)&&A(t,"src",n)},d(e){e&&d(t)}}}function Aw(e){let t,n,r,i;return{c(){t=h("button"),n=g("Admin"),A(t,"class","admin-btn svelte-on0yal"),t.disabled=e[0]},m(o,s){u(o,t,s),c(t,n),r||(i=w(t,"click",e[26]),r=!0)},p(e,n){1&n[0]&&(t.disabled=e[0])},d(e){e&&d(t),r=!1,i()}}}function bw(e){let t,n,i,o,s,a,l,f,p,y,v=e[3].length>0&&kw(e);return{c(){t=h("div"),n=h("span"),n.textContent="Upload new files",i=m(),o=h("input"),s=m(),v&&v.c(),a=m(),l=h("button"),f=g("Select Files"),A(n,"class","upload-label svelte-on0yal"),A(o,"type","file"),o.multiple=!0,A(o,"class","file-input-hidden svelte-on0yal"),A(l,"class","select-btn svelte-on0yal"),l.disabled=e[4],A(t,"class","upload-section svelte-on0yal")},m(r,d){u(r,t,d),c(t,n),c(t,i),c(t,o),e[39](o),c(t,s),v&&v.m(t,null),c(t,a),c(t,l),c(l,f),p||(y=[w(o,"change",e[22]),w(l,"click",e[23])],p=!0)},p(e,n){e[3].length>0?v?v.p(e,n):(v=kw(e),v.c(),v.m(t,a)):v&&(v.d(1),v=null),16&n[0]&&(l.disabled=e[4])},d(n){n&&d(t),e[39](null),v&&v.d(),p=!1,r(y)}}}function kw(e){let t,n,r,i,o,s,a,l,f=e[3].length+"",p=(e[4]?e[5]:"Upload")+"";return{c(){t=h("span"),n=g(f),r=g(" file(s) selected"),i=m(),o=h("button"),s=g(p),A(t,"class","selected-count svelte-on0yal"),A(o,"class","upload-btn svelte-on0yal"),o.disabled=e[4]},m(d,f){u(d,t,f),c(t,n),c(t,r),u(d,i,f),u(d,o,f),c(o,s),a||(l=w(o,"click",e[24]),a=!0)},p(e,t){8&t[0]&&f!==(f=e[3].length+"")&&k(n,f),48&t[0]&&p!==(p=(e[4]?e[5]:"Upload")+"")&&k(s,p),16&t[0]&&(o.disabled=e[4])},d(e){e&&d(t),e&&d(i),e&&d(o),a=!1,l()}}}function Iw(e){let t,n;return{c(){t=h("div"),n=g(e[2]),A(t,"class","error-message svelte-on0yal")},m(e,r){u(e,t,r),c(t,n)},p(e,t){4&t[0]&&k(n,e[2])},d(e){e&&d(t)}}}function Ew(e){let t,n,r;function i(e,r){return 1&r[0]&&(t=null),null==t&&(t=!(!e[0]||0!==e[31]().length)),t?Sw:(null==n&&(n=!(0!==e[31]().length)),n?Bw:xw)}let o=i(e,[-1,-1]),s=o(e);return{c(){s.c(),r=y()},m(e,t){s.m(e,t),u(e,r,t)},p(e,t){o===(o=i(e,t))&&s?s.p(e,t):(s.d(1),s=o(e),s&&(s.c(),s.m(r.parentNode,r)))},d(e){s.d(e),e&&d(r)}}}function Cw(e){let t;function n(e,t){return e[12]?Uw:0===e[11].length?$w:Pw}let r=n(e),i=r(e);return{c(){i.c(),t=y()},m(e,n){i.m(e,n),u(e,t,n)},p(e,o){r===(r=n(e))&&i?i.p(e,o):(i.d(1),i=r(e),i&&(i.c(),i.m(t.parentNode,t)))},d(e){i.d(e),e&&d(t)}}}function xw(e){let t,n=e[31](),r=[];for(let t=0;tNo users have uploaded files yet.

    ",A(n,"class","empty-state svelte-on0yal")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Uw(t){let n;return{c(){n=h("div"),n.textContent="Loading user statistics...",A(n,"class","loading svelte-on0yal")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Tw(t){let n;return{c(){n=h("div"),A(n,"class","user-avatar-placeholder svelte-on0yal")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Nw(e){let t,n;return{c(){t=h("img"),a(t.src,n=e[54].profile.picture)||A(t,"src",n),A(t,"alt",""),A(t,"class","user-avatar svelte-on0yal")},m(e,n){u(e,t,n)},p(e,r){2048&r[0]&&!a(t.src,n=e[54].profile.picture)&&A(t,"src",n)},d(e){e&&d(t)}}}function Lw(e){let t,n,i,o,s,a,l,f,p,y,v,b,I,E,C,x,B,S,F,Q,D,R,P,$,U,T=(e[54].profile?.name||tv(e[25](e[54].pubkey)))+"",N=e[25](e[54].pubkey)+"",L=tv(e[25](e[54].pubkey))+"",O=e[54].blob_count+"",M=Yw(e[54].total_size_bytes)+"";function _(e,t){return e[54].profile?.picture?Nw:Tw}let H=_(e),j=H(e);function G(){return e[40](e[54])}function q(...t){return e[41](e[54],...t)}return{c(){t=h("div"),n=h("div"),j.c(),i=m(),o=h("div"),s=h("div"),a=g(T),l=m(),f=h("div"),p=h("span"),y=g(N),v=m(),b=h("span"),I=g(L),C=m(),x=h("div"),B=h("span"),S=g(O),F=g(" files"),Q=m(),D=h("span"),R=g(M),P=m(),A(n,"class","user-avatar-container svelte-on0yal"),A(s,"class","user-name svelte-on0yal"),A(p,"class","npub-full svelte-on0yal"),A(b,"class","npub-truncated svelte-on0yal"),A(f,"class","user-npub svelte-on0yal"),A(f,"title",E=e[54].pubkey),A(o,"class","user-info svelte-on0yal"),A(B,"class","blob-count svelte-on0yal"),A(D,"class","total-size svelte-on0yal"),A(x,"class","user-stats svelte-on0yal"),A(t,"class","user-stat-item svelte-on0yal"),A(t,"role","button"),A(t,"tabindex","0")},m(e,r){u(e,t,r),c(t,n),j.m(n,null),c(t,i),c(t,o),c(o,s),c(s,a),c(o,l),c(o,f),c(f,p),c(p,y),c(f,v),c(f,b),c(b,I),c(t,C),c(t,x),c(x,B),c(B,S),c(B,F),c(x,Q),c(x,D),c(D,R),c(t,P),$||(U=[w(t,"click",G),w(t,"keypress",q)],$=!0)},p(t,r){H===(H=_(e=t))&&j?j.p(e,r):(j.d(1),j=H(e),j&&(j.c(),j.m(n,null))),2048&r[0]&&T!==(T=(e[54].profile?.name||tv(e[25](e[54].pubkey)))+"")&&k(a,T),2048&r[0]&&N!==(N=e[25](e[54].pubkey)+"")&&k(y,N),2048&r[0]&&L!==(L=tv(e[25](e[54].pubkey))+"")&&k(I,L),2048&r[0]&&E!==(E=e[54].pubkey)&&A(f,"title",E),2048&r[0]&&O!==(O=e[54].blob_count+"")&&k(S,O),2048&r[0]&&M!==(M=Yw(e[54].total_size_bytes)+"")&&k(R,M)},d(e){e&&d(t),j.d(),$=!1,r(U)}}}function Ow(e){let t,n,i,o,s,a,l,f,p,y,b,I,E,C,x,B,S,F,Q,D,R,P,$,U,T,N,L,O,M,_,H,j,G,q,K,J,V,Y,z,W,Z,X,ee,te=Ww(e[8].sha256)+"",ne=(e[8].type||"unknown")+"",re="image"===Zw(e[8].type),ie=Yw(e[8].size)+"",oe=zw(e[8].uploaded)+"",se=re&&Mw(e);function ae(e,t){return 256&t[0]&&(B=null),256&t[0]&&(S=null),256&t[0]&&(F=null),null==B&&(B=!("image"!==Zw(e[8].type))),B?Gw:(null==S&&(S=!("video"!==Zw(e[8].type))),S?jw:(null==F&&(F=!("audio"!==Zw(e[8].type))),F?Hw:_w))}let le=ae(e,[-1,-1]),ce=le(e);return{c(){t=h("div"),n=h("div"),i=h("div"),o=h("div"),s=h("span"),a=g(te),l=m(),f=h("span"),p=g(ne),y=m(),b=h("div"),se&&se.c(),I=m(),E=h("button"),E.textContent="X",C=m(),x=h("div"),ce.c(),Q=m(),D=h("div"),R=h("div"),P=h("span"),$=g("Size: "),U=g(ie),T=m(),N=h("span"),L=g("Uploaded: "),O=g(oe),M=m(),_=h("div"),H=h("input"),G=m(),q=h("button"),q.textContent="Copy",K=m(),J=h("div"),V=h("a"),Y=g("Open in New Tab"),W=m(),Z=h("button"),Z.textContent="Delete",A(s,"class","modal-hash svelte-on0yal"),A(f,"class","modal-type svelte-on0yal"),A(o,"class","modal-title svelte-on0yal"),A(E,"class","close-btn svelte-on0yal"),A(b,"class","modal-controls svelte-on0yal"),A(i,"class","modal-header svelte-on0yal"),A(x,"class","modal-body svelte-on0yal"),A(R,"class","blob-details svelte-on0yal"),A(H,"type","text"),H.readOnly=!0,H.value=j=ev(e[8]),A(H,"class","blob-url-input svelte-on0yal"),A(q,"class","copy-btn svelte-on0yal"),A(_,"class","blob-url-section svelte-on0yal"),A(V,"href",z=ev(e[8])),A(V,"target","_blank"),A(V,"rel","noopener noreferrer"),A(V,"class","action-btn svelte-on0yal"),A(Z,"class","action-btn danger svelte-on0yal"),A(J,"class","modal-actions svelte-on0yal"),A(D,"class","modal-footer svelte-on0yal"),A(n,"class","modal-content svelte-on0yal"),A(n,"role","dialog"),A(t,"class","modal-overlay svelte-on0yal"),A(t,"role","button"),A(t,"tabindex","0")},m(r,d){u(r,t,d),c(t,n),c(n,i),c(i,o),c(o,s),c(s,a),c(o,l),c(o,f),c(f,p),c(i,y),c(i,b),se&&se.m(b,null),c(b,I),c(b,E),c(n,C),c(n,x),ce.m(x,null),c(n,Q),c(n,D),c(D,R),c(R,P),c(P,$),c(P,U),c(R,T),c(R,N),c(N,L),c(N,O),c(D,M),c(D,_),c(_,H),c(_,G),c(_,q),c(D,K),c(D,J),c(J,V),c(V,Y),c(J,W),c(J,Z),X||(ee=[w(E,"click",e[16]),w(H,"click",nv),w(q,"click",e[45]),w(Z,"click",e[46]),w(n,"click",v(e[37])),w(n,"keypress",v(e[38])),w(t,"click",e[16]),w(t,"keypress",e[47])],X=!0)},p(e,t){256&t[0]&&te!==(te=Ww(e[8].sha256)+"")&&k(a,te),256&t[0]&&ne!==(ne=(e[8].type||"unknown")+"")&&k(p,ne),256&t[0]&&(re="image"===Zw(e[8].type)),re?se?se.p(e,t):(se=Mw(e),se.c(),se.m(b,I)):se&&(se.d(1),se=null),le===(le=ae(e,t))&&ce?ce.p(e,t):(ce.d(1),ce=le(e),ce&&(ce.c(),ce.m(x,null))),256&t[0]&&ie!==(ie=Yw(e[8].size)+"")&&k(U,ie),256&t[0]&&oe!==(oe=zw(e[8].uploaded)+"")&&k(O,oe),256&t[0]&&j!==(j=ev(e[8]))&&H.value!==j&&(H.value=j),256&t[0]&&z!==(z=ev(e[8]))&&A(V,"href",z)},d(e){e&&d(t),se&&se.d(),ce.d(),X=!1,r(ee)}}}function Mw(e){let t,n,i,o,s,a,l,f,p,y,v,b,I,E=Math.round(100*e[9])+"";return{c(){t=h("button"),n=g("-"),o=m(),s=h("span"),a=g(E),l=g("%"),f=m(),p=h("button"),y=g("+"),A(t,"class","zoom-btn svelte-on0yal"),t.disabled=i=e[9]<=Kw,A(s,"class","zoom-level svelte-on0yal"),A(p,"class","zoom-btn svelte-on0yal"),p.disabled=v=e[9]>=Jw},m(r,i){u(r,t,i),c(t,n),u(r,o,i),u(r,s,i),c(s,a),c(s,l),u(r,f,i),u(r,p,i),c(p,y),b||(I=[w(t,"click",e[18]),w(p,"click",e[17])],b=!0)},p(e,n){512&n[0]&&i!==(i=e[9]<=Kw)&&(t.disabled=i),512&n[0]&&E!==(E=Math.round(100*e[9])+"")&&k(a,E),512&n[0]&&v!==(v=e[9]>=Jw)&&(p.disabled=v)},d(e){e&&d(t),e&&d(o),e&&d(s),e&&d(f),e&&d(p),b=!1,r(I)}}}function _w(e){let t,n,r,i,o,s,a,l,f,p=Xw(e[8].type)+"";return{c(){t=h("div"),n=h("div"),r=g(p),i=m(),o=h("p"),o.textContent="Preview not available for this file type.",s=m(),a=h("a"),l=g("Download File"),A(n,"class","file-icon svelte-on0yal"),A(a,"href",f=ev(e[8])),A(a,"target","_blank"),A(a,"rel","noopener noreferrer"),A(a,"class","download-link svelte-on0yal"),A(t,"class","file-preview svelte-on0yal")},m(e,d){u(e,t,d),c(t,n),c(n,r),c(t,i),c(t,o),c(t,s),c(t,a),c(a,l)},p(e,t){256&t[0]&&p!==(p=Xw(e[8].type)+"")&&k(r,p),256&t[0]&&f!==(f=ev(e[8]))&&A(a,"href",f)},d(e){e&&d(t)}}}function Hw(e){let t,n,r;return{c(){t=h("div"),n=h("audio"),n.controls=!0,a(n.src,r=ev(e[8]))||A(n,"src",r),A(n,"class","svelte-on0yal"),A(t,"class","media-container audio svelte-on0yal")},m(e,r){u(e,t,r),c(t,n)},p(e,t){256&t[0]&&!a(n.src,r=ev(e[8]))&&A(n,"src",r)},d(e){e&&d(t)}}}function jw(e){let t,n,r,i;return{c(){t=h("div"),n=h("video"),r=h("track"),A(r,"kind","captions"),n.controls=!0,a(n.src,i=ev(e[8]))||A(n,"src",i),A(n,"class","svelte-on0yal"),A(t,"class","media-container svelte-on0yal")},m(e,i){u(e,t,i),c(t,n),c(n,r)},p(e,t){256&t[0]&&!a(n.src,i=ev(e[8]))&&A(n,"src",i)},d(e){e&&d(t)}}}function Gw(e){let t,n,r;return{c(){t=h("div"),n=h("img"),a(n.src,r=ev(e[8]))||A(n,"src",r),A(n,"alt","Blob content"),A(n,"class","svelte-on0yal"),A(t,"class","media-container svelte-on0yal"),E(t,"transform","scale("+e[9]+")")},m(e,r){u(e,t,r),c(t,n)},p(e,i){256&i[0]&&!a(n.src,r=ev(e[8]))&&A(n,"src",r),512&i[0]&&E(t,"transform","scale("+e[9]+")")},d(e){e&&d(t)}}}function qw(t){let n,r,i,o;function s(e,t){return e[1]?gw:pw}let a=s(t),l=a(t),c=t[7]&&t[8]&&Ow(t);return{c(){l.c(),n=m(),c&&c.c(),r=y()},m(e,s){l.m(e,s),u(e,n,s),c&&c.m(e,s),u(e,r,s),i||(o=w(dw,"keydown",t[19]),i=!0)},p(e,t){a===(a=s(e))&&l?l.p(e,t):(l.d(1),l=a(e),l&&(l.c(),l.m(n.parentNode,n))),e[7]&&e[8]?c?c.p(e,t):(c=Ow(e),c.c(),c.m(r.parentNode,r)):c&&(c.d(1),c=null)},i:e,o:e,d(e){l.d(e),e&&d(n),c&&c.d(e),e&&d(r),i=!1,o()}}}const Kw=.25,Jw=4;async function Vw(e,t,n=null){if(!e)return console.log("No signer available for Blossom auth"),null;try{const r=Math.floor(Date.now()/1e3),i=[["t",t],["expiration",(r+60).toString()]];n&&i.push(["x",n]);const o={kind:24242,created_at:r,tags:i,content:`Blossom ${t} operation`},s=await e.signEvent(o);return btoa(JSON.stringify(s)).replace(/\+/g,"-").replace(/\//g,"_")}catch(e){return console.error("Error creating Blossom auth:",e),null}}function Yw(e){if(!e)return"0 B";const t=["B","KB","MB","GB"];let n=0,r=e;for(;r>=1024&&ne.target.select();function rv(e,t,n){let r,i,{isLoggedIn:o=!1}=t,{userPubkey:s=""}=t,{userSigner:a=null}=t,{currentEffectiveRole:l=""}=t;const c=P();let u,d=[],f=!1,h="",p=[],g=!1,m="",y=!1,w=null,v=1,A=!1,b=[],k=!1,I=null,E=[],C=!1;async function x(){if(s){n(0,f=!0),n(2,h="");try{const e=`${window.location.origin}/blossom/list/${s}`,t=await Vw(a,"list"),n=await fetch(e,{headers:t?{Authorization:`Nostr ${t}`}:{}});if(!n.ok)throw new Error(`Failed to load blobs: ${n.statusText}`);const r=await n.json();d=Array.isArray(r)?r:[],d.sort((e,t)=>(t.uploaded||0)-(e.uploaded||0)),console.log("Loaded blobs:",d)}catch(e){console.error("Error loading blobs:",e),n(2,h=e.message||"Failed to load blobs")}finally{n(0,f=!1)}}}function B(e){n(8,w=e),n(9,v=1),n(7,y=!0)}function S(){n(7,y=!1),n(8,w=null),n(9,v=1)}function F(){vKw&&n(9,v=Math.max(Kw,v-.25))}async function R(e){if(confirm(`Delete blob ${Ww(e.sha256)}?`))try{const t=`${window.location.origin}/blossom/${e.sha256}`,n=await Vw(a,"delete",e.sha256),r=await fetch(t,{method:"DELETE",headers:n?{Authorization:`Nostr ${n}`}:{}});if(!r.ok)throw new Error(`Failed to delete: ${r.statusText}`);d=d.filter(t=>t.sha256!==e.sha256),w?.sha256===e.sha256&&S()}catch(e){console.error("Error deleting blob:",e),alert(`Failed to delete blob: ${e.message}`)}}async function U(){n(12,k=!0),n(2,h="");try{const e=`${window.location.origin}/blossom/admin/users`,t=await Vw(a,"admin"),r=await fetch(e,{headers:t?{Authorization:`Nostr ${t}`}:{}});if(!r.ok)throw new Error(`Failed to load user stats: ${r.statusText}`);n(11,b=await r.json());for(const e of b)Oh(e.pubkey).then(t=>{e.profile=t||{name:"",picture:""},n(11,b)}).catch(()=>{e.profile={name:"",picture:""}})}catch(e){console.error("Error fetching admin user stats:",e),n(2,h=e.message||"Failed to load user stats")}finally{n(12,k=!1)}}async function N(e){n(0,f=!0),n(2,h="");try{const t=`${window.location.origin}/blossom/list/${e}`,n=await Vw(a,"list"),r=await fetch(t,{headers:n?{Authorization:`Nostr ${n}`}:{}});if(!r.ok)throw new Error(`Failed to load user blobs: ${r.statusText}`);E=await r.json(),E.sort((e,t)=>(t.uploaded||0)-(e.uploaded||0))}catch(e){console.error("Error loading user blobs:",e),n(2,h=e.message||"Failed to load user blobs")}finally{n(0,f=!1)}}async function L(e){n(13,I={pubkey:e.pubkey,profile:e.profile}),await N(e.pubkey)}D(()=>{r&&!C&&(n(36,C=!0),x())});return e.$$set=e=>{"isLoggedIn"in e&&n(32,o=e.isLoggedIn),"userPubkey"in e&&n(33,s=e.userPubkey),"userSigner"in e&&n(34,a=e.userSigner),"currentEffectiveRole"in e&&n(35,l=e.currentEffectiveRole)},e.$$.update=()=>{6&e.$$.dirty[1]&&n(1,r=o&&s),16&e.$$.dirty[1]&&n(14,i="admin"===l||"owner"===l),3&e.$$.dirty[0]|32&e.$$.dirty[1]&&(!r||C||f||(n(36,C=!0),x()))},[f,r,h,p,g,m,u,y,w,v,A,b,k,I,i,B,S,F,Q,function(e){y&&("Escape"===e.key?S():"+"===e.key||"="===e.key?F():"-"===e.key&&Q())},function(){c("openLoginModal")},R,function(e){n(3,p=Array.from(e.target.files))},function(){u?.click()},async function(){if(0===p.length)return;n(4,g=!0),n(2,h="");const e=[],t=[];for(let r=0;r0&&await x(),t.length>0&&n(2,h=`Failed to upload: ${t.map(e=>e.name).join(", ")}`)},function(e){try{return bu(e)}catch(t){return Ww(e)}},function(){n(10,A=!0),U()},function(){n(10,A=!1),n(11,b=[]),n(13,I=null),E=[]},L,function(){n(13,I=null),E=[]},function(){I?N(I.pubkey):A?U():x()},function(){return I?E:d},o,s,a,l,C,function(t){$.call(this,e,t)},function(t){$.call(this,e,t)},function(e){T[e?"unshift":"push"](()=>{u=e,n(6,u)})},e=>L(e),(e,t)=>"Enter"===t.key&&L(e),e=>R(e),e=>B(e),(e,t)=>"Enter"===t.key&&B(e),()=>{navigator.clipboard.writeText(ev(w))},()=>R(w),e=>"Enter"===e.key&&S()]}class iv extends ae{constructor(e){super(),se(this,e,rv,qw,o,{isLoggedIn:32,userPubkey:33,userSigner:34,currentEffectiveRole:35},null,[-1,-1])}}var ov={},sv={},av={};let lv;const cv=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];av.getSymbolSize=function(e){if(!e)throw new Error('"version" cannot be null or undefined');if(e<1||e>40)throw new Error('"version" should be in range from 1 to 40');return 4*e+17},av.getSymbolTotalCodewords=function(e){return cv[e]},av.getBCHDigit=function(e){let t=0;for(;0!==e;)t++,e>>>=1;return t},av.setToSJISFunction=function(e){if("function"!=typeof e)throw new Error('"toSJISFunc" is not a valid function.');lv=e},av.isKanjiModeEnabled=function(){return void 0!==lv},av.toSJIS=function(e){return lv(e)};var uv,dv={};function fv(){this.buffer=[],this.length=0}(uv=dv).L={bit:1},uv.M={bit:0},uv.Q={bit:3},uv.H={bit:2},uv.isValid=function(e){return e&&void 0!==e.bit&&e.bit>=0&&e.bit<4},uv.from=function(e,t){if(uv.isValid(e))return e;try{return function(e){if("string"!=typeof e)throw new Error("Param is not a string");switch(e.toLowerCase()){case"l":case"low":return uv.L;case"m":case"medium":return uv.M;case"q":case"quartile":return uv.Q;case"h":case"high":return uv.H;default:throw new Error("Unknown EC Level: "+e)}}(e)}catch(e){return t}},fv.prototype={get:function(e){const t=Math.floor(e/8);return 1==(this.buffer[t]>>>7-e%8&1)},put:function(e,t){for(let n=0;n>>t-n-1&1))},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var hv=fv;function pv(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}pv.prototype.set=function(e,t,n,r){const i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},pv.prototype.get=function(e,t){return this.data[e*this.size+t]},pv.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},pv.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var gv=pv,mv={};!function(e){const t=av.getSymbolSize;e.getRowColCoords=function(e){if(1===e)return[];const n=Math.floor(e/7)+2,r=t(e),i=145===r?26:2*Math.ceil((r-13)/(2*n-2)),o=[r-7];for(let e=1;e=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){const n=e.size;let r=0,i=0,o=0,s=null,a=null;for(let l=0;l=5&&(r+=t+(i-5)),s=n,i=1),n=e.get(c,l),n===a?o++:(o>=5&&(r+=t+(o-5)),a=n,o=1)}i>=5&&(r+=t+(i-5)),o>=5&&(r+=t+(o-5))}return r},e.getPenaltyN2=function(e){const t=e.size;let r=0;for(let n=0;n=10&&(1488===i||93===i)&&n++,o=o<<1&2047|e.get(s,r),s>=10&&(1488===o||93===o)&&n++}return n*r},e.getPenaltyN4=function(e){let t=0;const n=e.data.length;for(let r=0;r=0;){const e=r[0];for(let i=0;i0){const e=new Uint8Array(this.degree);return e.set(n,r),e}return n};var Qv=Fv,Dv={},Rv={},Pv={isValid:function(e){return!isNaN(e)&&e>=1&&e<=40}},$v={};const Uv="[0-9]+";let Tv="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";Tv=Tv.replace(/u/g,"\\u");const Nv="(?:(?![A-Z0-9 $%*+\\-./:]|"+Tv+")(?:.|[\r\n]))+";$v.KANJI=new RegExp(Tv,"g"),$v.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),$v.BYTE=new RegExp(Nv,"g"),$v.NUMERIC=new RegExp(Uv,"g"),$v.ALPHANUMERIC=new RegExp("[A-Z $%*+\\-./:]+","g");const Lv=new RegExp("^"+Tv+"$"),Ov=new RegExp("^"+Uv+"$"),Mv=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");$v.testKanji=function(e){return Lv.test(e)},$v.testNumeric=function(e){return Ov.test(e)},$v.testAlphanumeric=function(e){return Mv.test(e)},function(e){const t=Pv,n=$v;e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw new Error("Invalid mode: "+e);if(!t.isValid(n))throw new Error("Invalid version: "+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw new Error("Invalid mode")},e.isValid=function(e){return e&&e.bit&&e.ccBits},e.from=function(t,n){if(e.isValid(t))return t;try{return function(t){if("string"!=typeof t)throw new Error("Param is not a string");switch(t.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+t)}}(t)}catch(e){return n}}}(Rv),function(e){const t=av,n=Av,r=dv,i=Rv,o=Pv,s=t.getBCHDigit(7973);function a(e,t){return i.getCharCountIndicator(e,t)+4}function l(e,t){let n=0;return e.forEach(function(e){const r=a(e.mode,t);n+=r+e.getBitsLength()}),n}e.from=function(e,t){return o.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,s){if(!o.isValid(e))throw new Error("Invalid QR Code version");void 0===s&&(s=i.BYTE);const l=8*(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r));if(s===i.MIXED)return l;const c=l-a(s,e);switch(s){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(t,n){let o;const s=r.from(n,r.M);if(Array.isArray(t)){if(t.length>1)return function(t,n){for(let r=1;r<=40;r++)if(l(t,r)<=e.getCapacity(r,n,i.MIXED))return r}(t,s);if(0===t.length)return 1;o=t[0]}else o=t;return function(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}(o.mode,o.getLength(),s)},e.getEncodedBits=function(e){if(!o.isValid(e)||e<7)throw new Error("Invalid QR Code version");let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=7973<=0;)r^=1335<0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,3*i+1))};var Jv=Kv;const Vv=Rv,Yv=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function zv(e){this.mode=Vv.ALPHANUMERIC,this.data=e}zv.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},zv.prototype.getLength=function(){return this.data.length},zv.prototype.getBitsLength=function(){return zv.getBitsLength(this.data.length)},zv.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=45*Yv.indexOf(this.data[t]);n+=Yv.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(Yv.indexOf(this.data[t]),6)};var Wv=zv;const Zv=Rv;function Xv(e){this.mode=Zv.BYTE,this.data="string"==typeof e?(new TextEncoder).encode(e):new Uint8Array(e)}Xv.getBitsLength=function(e){return 8*e},Xv.prototype.getLength=function(){return this.data.length},Xv.prototype.getBitsLength=function(){return Xv.getBitsLength(this.data.length)},Xv.prototype.write=function(e){for(let t=0,n=this.data.length;t=33088&&n<=40956)n-=33088;else{if(!(n>=57408&&n<=60351))throw new Error("Invalid SJIS character: "+this.data[t]+"\nMake sure your charset is UTF-8");n-=49472}n=192*(n>>>8&255)+(255&n),e.put(n,13)}};var iA=rA,oA={exports:{}};!function(e){var t={single_source_shortest_paths:function(e,n,r){var i={},o={};o[n]=0;var s,a,l,c,u,d,f,h=t.PriorityQueue.make();for(h.push(n,0);!h.empty();)for(l in a=(s=h.pop()).value,c=s.cost,u=e[a]||{})u.hasOwnProperty(l)&&(d=c+u[l],f=o[l],(void 0===o[l]||f>d)&&(o[l]=d,h.push(l,d),i[l]=a));if(void 0!==r&&void 0===o[r]){var p=["Could not find a path from ",n," to ",r,"."].join("");throw new Error(p)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,n,r){var i=t.single_source_shortest_paths(e,n,r);return t.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var n,r=t.PriorityQueue,i={};for(n in e=e||{},r)r.hasOwnProperty(n)&&(i[n]=r[n]);return i.queue=[],i.sorter=e.sorter||r.default_sorter,i},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};e.exports=t}(oA);var sA=oA.exports;!function(e){const t=Rv,n=Jv,r=Wv,i=eA,o=iA,s=$v,a=av,l=sA;function c(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){const r=[];let i;for(;null!==(i=e.exec(n));)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){const n=u(s.NUMERIC,t.NUMERIC,e),r=u(s.ALPHANUMERIC,t.ALPHANUMERIC,e);let i,o;a.isKanjiModeEnabled()?(i=u(s.BYTE,t.BYTE,e),o=u(s.KANJI,t.KANJI,e)):(i=u(s.BYTE_KANJI,t.BYTE,e),o=[]);return n.concat(r,i,o).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,s){switch(s){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return o.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function h(e,s){let l;const c=t.getBestModeForData(e);if(l=t.from(s,c),l!==t.BYTE&&l.bit=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}(u))},e.rawSplit=function(t){return e.fromArray(d(t,a.isKanjiModeEnabled()))}}(Gv);const aA=av,lA=dv,cA=hv,uA=gv,dA=mv,fA=yv,hA=vv,pA=Av,gA=Qv,mA=Dv,yA=_v,wA=Rv,vA=Gv;function AA(e,t,n){const r=e.size,i=yA.getEncodedBits(t,n);let o,s;for(o=0;o<15;o++)s=1==(i>>o&1),o<6?e.set(o,8,s,!0):o<8?e.set(o+1,8,s,!0):e.set(r-15+o,8,s,!0),o<8?e.set(8,r-o-1,s,!0):o<9?e.set(8,15-o-1+1,s,!0):e.set(8,15-o-1,s,!0);e.set(r-8,8,1,!0)}function bA(e,t,n){const r=new cA;n.forEach(function(t){r.put(t.mode.bit,4),r.put(t.getLength(),wA.getCharCountIndicator(t.mode,e)),t.write(r)});const i=8*(aA.getSymbolTotalCodewords(e)-pA.getTotalCodewordsCount(e,t));for(r.getLengthInBits()+4<=i&&r.put(0,4);r.getLengthInBits()%8!=0;)r.putBit(0);const o=(i-r.getLengthInBits())/8;for(let e=0;e=0&&t<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===t||6===t)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,o+r,!0,!0):e.set(i+t,o+r,!1,!0))}}(l,t),function(e){const t=e.size;for(let n=8;n=7&&function(e,t){const n=e.size,r=mA.getEncodedBits(t);let i,o,s;for(let t=0;t<18;t++)i=Math.floor(t/3),o=t%3+n-8-3,s=1==(r>>t&1),e.set(i,o,s,!0),e.set(o,i,s,!0)}(l,t),function(e,t){const n=e.size;let r=-1,i=n-1,o=7,s=0;for(let a=n-1;a>0;a-=2)for(6===a&&a--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,a-n)){let r=!1;s>>o&1)),e.set(i,a-n,r),o--,-1===o&&(s++,o=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}(l,s),isNaN(r)&&(r=hA.getBestMask(l,AA.bind(null,l,n))),hA.applyMask(r,l),AA(l,n,r),{modules:l,version:t,errorCorrectionLevel:n,maskPattern:r,segments:i}}sv.create=function(e,t){if(void 0===e||""===e)throw new Error("No input text");let n,r,i=lA.M;return void 0!==t&&(i=lA.from(t.errorCorrectionLevel,lA.M),n=mA.from(t.version),r=hA.from(t.maskPattern),t.toSJISFunc&&aA.setToSJISFunction(t.toSJISFunc)),kA(e,n,i,r)};var IA={},EA={};!function(e){function t(e){if("number"==typeof e&&(e=e.toString()),"string"!=typeof e)throw new Error("Color should be defined as hex string");let t=e.slice().replace("#","").split("");if(t.length<3||5===t.length||t.length>8)throw new Error("Invalid hex color: "+e);3!==t.length&&4!==t.length||(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),6===t.length&&t.push("F","F");const n=parseInt(t.join(""),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:"#"+t.slice(0,6).join("")}}e.getOptions=function(e){e||(e={}),e.color||(e.color={});const n=void 0===e.margin||null===e.margin||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,i=e.scale||4;return{width:r,scale:r?4:i,margin:n,color:{dark:t(e.color.dark||"#000000ff"),light:t(e.color.light||"#ffffffff")},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+2*t.margin?t.width/(e+2*t.margin):t.scale},e.getImageWidth=function(t,n){const r=e.getScale(t,n);return Math.floor((t+2*n.margin)*r)},e.qrToImageData=function(t,n,r){const i=n.modules.size,o=n.modules.data,s=e.getScale(i,r),a=Math.floor((i+2*r.margin)*s),l=r.margin*s,c=[r.color.light,r.color.dark];for(let e=0;e=l&&n>=l&&e':"",l="0&&l>0&&e[a-1]||(r+=o?SA("M",l+n,.5+c+n):SA("m",i,0),i=0,o=!1),l+1',c='viewBox="0 0 '+s+" "+s+'"',u=''+a+l+"\n";return"function"==typeof n&&n(null,u),u};const FA=function(){return"function"==typeof Promise&&Promise.prototype&&Promise.prototype.then},QA=sv,DA=IA,RA=CA;function PA(e,t,n,r,i){const o=[].slice.call(arguments,1),s=o.length,a="function"==typeof o[s-1];if(!a&&!FA())throw new Error("Callback required as last argument");if(!a){if(s<1)throw new Error("Too few arguments provided");return 1===s?(n=t,t=r=void 0):2!==s||t.getContext||(r=n,n=t,t=void 0),new Promise(function(i,o){try{const o=QA.create(n,r);i(e(o,t,r))}catch(e){o(e)}})}if(s<2)throw new Error("Too few arguments provided");2===s?(i=n,n=t,t=r=void 0):3===s&&(t.getContext&&void 0===i?(i=r,r=void 0):(i=r,r=n,n=t,t=void 0));try{const o=QA.create(n,r);i(null,e(o,t,r))}catch(e){i(e)}}async function $A(e,t,n,r){if(!e||!t)return console.log("createNIP98Auth: No signer or pubkey available",{hasSigner:!!e,hasPubkey:!!t}),null;try{const t={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",r],["method",n.toUpperCase()]],content:""};console.log("createNIP98Auth: Signing event for",n,r);const i=await e.signEvent(t);console.log("createNIP98Auth: Signed event:",{id:i.id,pubkey:i.pubkey,kind:i.kind,created_at:i.created_at,tags:i.tags,hasSig:!!i.sig});const o=JSON.stringify(i);return btoa(o).replace(/\+/g,"-").replace(/\//g,"_")}catch(e){return console.error("createNIP98Auth: Error:",e),null}}function UA(e,t,n){return e&t^~e&n}function TA(e,t,n){return e&t^e&n^t&n}ov.create=QA.create,ov.toCanvas=PA.bind(null,DA.render),ov.toDataURL=PA.bind(null,DA.renderToDataURL),ov.toString=PA.bind(null,function(e,t,n){return RA.render(e,n)});class NA extends Wu{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=Tu(this.buffer)}update(e){$u(this),Ru(e=Yu(e));const{view:t,buffer:n,blockLen:r}=this,i=e.length;for(let o=0;or-o&&(this.process(n,0),o=0);for(let e=o;e>i&o),a=Number(n&o),l=r?4:0,c=r?0:4;e.setUint32(t+l,s,r),e.setUint32(t+c,a,r)}(n,r-8,BigInt(8*this.length),i),this.process(n,0);const s=Tu(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>>3,i=Nu(n,17)^Nu(n,19)^n>>>10;MA[e]=i+MA[e-7]+r+MA[e-16]|0}let{A:n,B:r,C:i,D:o,E:s,F:a,G:l,H:c}=this;for(let e=0;e<64;e++){const t=c+(Nu(s,6)^Nu(s,11)^Nu(s,25))+UA(s,a,l)+OA[e]+MA[e]|0,u=(Nu(n,2)^Nu(n,13)^Nu(n,22))+TA(n,r,i)|0;c=l,l=a,a=s,s=o+t|0,o=i,i=r,r=n,n=t+u|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(n,r,i,o,s,a,l,c)}roundClean(){Uu(MA)}destroy(){this.set(0,0,0,0,0,0,0,0),Uu(this.buffer)}}const HA=Zu(()=>new _A);class jA extends Wu{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Pu(e);const n=Yu(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,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let e=0;enew jA(e,t).update(n).digest();GA.create=(e,t)=>new jA(e,t); + */function Yh(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{l(r.next(e))}catch(e){o(e)}}function a(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((r=r.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class zh{constructor(){this.mutex=Promise.resolve()}lock(){let e=()=>{};return this.mutex=this.mutex.then(()=>new Promise(e)),new Promise(t=>{e=t})}dispatch(e){return Yh(this,void 0,void 0,function*(){const t=yield this.lock();try{return yield Promise.resolve(e())}finally{t()}})}}var Wh;const Zh="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,Xh=null!==(Wh=Zh.Buffer)&&void 0!==Wh?Wh:null,ep=Zh.TextEncoder?new Zh.TextEncoder:null;function tp(e,t){return(15&e)+(e>>6|e>>3&8)<<4|(15&t)+(t>>6|t>>3&8)}function np(e,t){const n=t.length>>1;for(let r=0;r>>4;e[r++]=n>9?n+rp:n+ip,n=15&t[i],e[r++]=n>9?n+rp:n+ip}return String.fromCharCode.apply(null,e)}const sp=null!==Xh?e=>{if("string"==typeof e){const t=Xh.from(e,"utf8");return new Uint8Array(t.buffer,t.byteOffset,t.length)}if(Xh.isBuffer(e))return new Uint8Array(e.buffer,e.byteOffset,e.length);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Invalid data type!")}:e=>{if("string"==typeof e)return ep.encode(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Invalid data type!")},ap="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",lp=new Uint8Array(256);for(let e=0;e<64;e++)lp[ap.charCodeAt(e)]=e;function cp(e,t=!0){const n=e.length,r=n%3,i=[],o=n-r;for(let t=0;t>18&63)+ap.charAt(n>>12&63)+ap.charAt(n>>6&63)+ap.charAt(63&n);i.push(r)}if(1===r){const r=e[n-1],o=ap.charAt(r>>2),s=ap.charAt(r<<4&63);i.push(`${o}${s}`),t&&i.push("==")}else if(2===r){const r=(e[n-2]<<8)+e[n-1],o=ap.charAt(r>>10),s=ap.charAt(r>>4&63),a=ap.charAt(r<<2&63);i.push(`${o}${s}${a}`),t&&i.push("=")}return i.join("")}function up(e){const t=function(e){let t=Math.floor(.75*e.length);const n=e.length;return"="===e[n-1]&&(t-=1,"="===e[n-2]&&(t-=1)),t}(e),n=e.length,r=new Uint8Array(t);let i=0;for(let t=0;t>4,i+=1,r[i]=(15&o)<<4|s>>2,i+=1,r[i]=(3&s)<<6|63&a,i+=1}return r}const dp=16384,fp=new zh,hp=new Map;function pp(e,t){return Yh(this,void 0,void 0,function*(){let n=null,r=null,i=!1;if("undefined"==typeof WebAssembly)throw new Error("WebAssembly is not supported in this environment!");const o=()=>new DataView(n.exports.memory.buffer).getUint32(n.exports.STATE_SIZE,!0),s=fp.dispatch(()=>Yh(this,void 0,void 0,function*(){if(!hp.has(e.name)){const t=up(e.data),n=WebAssembly.compile(t);hp.set(e.name,n)}const t=yield hp.get(e.name);n=yield WebAssembly.instantiate(t,{})})),a=(e=null)=>{i=!0,n.exports.Hash_Init(e)},l=e=>{if(!i)throw new Error("update() called before init()");(e=>{let t=0;for(;t{if(!i)throw new Error("digest() called before init()");return i=!1,n.exports.Hash_Final(o),"binary"===e?r.slice(0,t):op(c,r,t)},d=e=>"string"==typeof e?e.length<4096:e.byteLength!0;break;case"blake2b":case"blake2s":f=(e,t)=>t<=512&&d(e);break;case"blake3":f=(e,t)=>0===t&&d(e);break;case"xxhash64":case"xxhash3":case"xxhash128":case"crc64":f=()=>!1}return yield(()=>Yh(this,void 0,void 0,function*(){n||(yield s);const e=n.exports.Hash_GetBuffer(),t=n.exports.memory.buffer;r=new Uint8Array(t,e,dp)}))(),{getMemory:()=>r,writeMemory:(e,t=0)=>{r.set(e,t)},getExports:()=>n.exports,setMemorySize:e=>{n.exports.Hash_SetMemorySize(e);const t=n.exports.Hash_GetBuffer(),i=n.exports.memory.buffer;r=new Uint8Array(i,t,e)},init:a,update:l,digest:u,save:()=>{if(!i)throw new Error("save() can only be called after init() and before digest()");const t=n.exports.Hash_GetState(),r=o(),s=n.exports.memory.buffer,a=new Uint8Array(s,t,r),l=new Uint8Array(4+r);return np(l,e.hash),l.set(a,4),l},load:t=>{if(!(t instanceof Uint8Array))throw new Error("load() expects an Uint8Array generated by save()");const r=n.exports.Hash_GetState(),s=o(),a=4+s,l=n.exports.memory.buffer;if(t.length!==a)throw new Error(`Bad state length (expected ${a} bytes, got ${t.length})`);if(!function(e,t){if(e.length!==2*t.length)return!1;for(let n=0;n{if(!f(e,i))return a(i),l(e),u("hex",o);const s=sp(e);return r.set(s),n.exports.Hash_Calculate(s.length,i,o),op(c,r,t)},hashLength:t}})}new zh;var gp={name:"argon2",data:"AGFzbQEAAAABKQVgAX8Bf2AAAX9gEH9/f39/f39/f39/f39/f38AYAR/f39/AGACf38AAwYFAAECAwQFBgEBAoCAAgYIAX8BQZCoBAsHQQQGbWVtb3J5AgASSGFzaF9TZXRNZW1vcnlTaXplAAAOSGFzaF9HZXRCdWZmZXIAAQ5IYXNoX0NhbGN1bGF0ZQAECvEyBVgBAn9BACEBAkAgAEEAKAKICCICRg0AAkAgACACayIAQRB2IABBgIB8cSAASWoiAEAAQX9HDQBB/wHADwtBACEBQQBBACkDiAggAEEQdK18NwOICAsgAcALcAECfwJAQQAoAoAIIgANAEEAPwBBEHQiADYCgAhBACgCiAgiAUGAgCBGDQACQEGAgCAgAWsiAEEQdiAAQYCAfHEgAElqIgBAAEF/Rw0AQQAPC0EAQQApA4gIIABBEHStfDcDiAhBACgCgAghAAsgAAvcDgECfiAAIAQpAwAiECAAKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAMIBAgDCkDAIVCIIkiEDcDACAIIBAgCCkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgBCAQIAQpAwCFQiiJIhA3AwAgACAQIAApAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIAwgECAMKQMAhUIwiSIQNwMAIAggECAIKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAEIBAgBCkDAIVCAYk3AwAgASAFKQMAIhAgASkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgDSAQIA0pAwCFQiCJIhA3AwAgCSAQIAkpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAUgECAFKQMAhUIoiSIQNwMAIAEgECABKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACANIBAgDSkDAIVCMIkiEDcDACAJIBAgCSkDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgBSAQIAUpAwCFQgGJNwMAIAIgBikDACIQIAIpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIA4gECAOKQMAhUIgiSIQNwMAIAogECAKKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAGIBAgBikDAIVCKIkiEDcDACACIBAgAikDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgDiAQIA4pAwCFQjCJIhA3AwAgCiAQIAopAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIAYgECAGKQMAhUIBiTcDACADIAcpAwAiECADKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAPIBAgDykDAIVCIIkiEDcDACALIBAgCykDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgByAQIAcpAwCFQiiJIhA3AwAgAyAQIAMpAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIA8gECAPKQMAhUIwiSIQNwMAIAsgECALKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAHIBAgBykDAIVCAYk3AwAgACAFKQMAIhAgACkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgDyAQIA8pAwCFQiCJIhA3AwAgCiAQIAopAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAUgECAFKQMAhUIoiSIQNwMAIAAgECAAKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAPIBAgDykDAIVCMIkiEDcDACAKIBAgCikDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgBSAQIAUpAwCFQgGJNwMAIAEgBikDACIQIAEpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAwgECAMKQMAhUIgiSIQNwMAIAsgECALKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAGIBAgBikDAIVCKIkiEDcDACABIBAgASkDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgDCAQIAwpAwCFQjCJIhA3AwAgCyAQIAspAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIAYgECAGKQMAhUIBiTcDACACIAcpAwAiECACKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACANIBAgDSkDAIVCIIkiEDcDACAIIBAgCCkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgByAQIAcpAwCFQiiJIhA3AwAgAiAQIAIpAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIA0gECANKQMAhUIwiSIQNwMAIAggECAIKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAHIBAgBykDAIVCAYk3AwAgAyAEKQMAIhAgAykDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgDiAQIA4pAwCFQiCJIhA3AwAgCSAQIAkpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAQgECAEKQMAhUIoiSIQNwMAIAMgECADKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAOIBAgDikDAIVCMIkiEDcDACAJIBAgCSkDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgBCAQIAQpAwCFQgGJNwMAC98aAQN/QQAhBEEAIAIpAwAgASkDAIU3A5AIQQAgAikDCCABKQMIhTcDmAhBACACKQMQIAEpAxCFNwOgCEEAIAIpAxggASkDGIU3A6gIQQAgAikDICABKQMghTcDsAhBACACKQMoIAEpAyiFNwO4CEEAIAIpAzAgASkDMIU3A8AIQQAgAikDOCABKQM4hTcDyAhBACACKQNAIAEpA0CFNwPQCEEAIAIpA0ggASkDSIU3A9gIQQAgAikDUCABKQNQhTcD4AhBACACKQNYIAEpA1iFNwPoCEEAIAIpA2AgASkDYIU3A/AIQQAgAikDaCABKQNohTcD+AhBACACKQNwIAEpA3CFNwOACUEAIAIpA3ggASkDeIU3A4gJQQAgAikDgAEgASkDgAGFNwOQCUEAIAIpA4gBIAEpA4gBhTcDmAlBACACKQOQASABKQOQAYU3A6AJQQAgAikDmAEgASkDmAGFNwOoCUEAIAIpA6ABIAEpA6ABhTcDsAlBACACKQOoASABKQOoAYU3A7gJQQAgAikDsAEgASkDsAGFNwPACUEAIAIpA7gBIAEpA7gBhTcDyAlBACACKQPAASABKQPAAYU3A9AJQQAgAikDyAEgASkDyAGFNwPYCUEAIAIpA9ABIAEpA9ABhTcD4AlBACACKQPYASABKQPYAYU3A+gJQQAgAikD4AEgASkD4AGFNwPwCUEAIAIpA+gBIAEpA+gBhTcD+AlBACACKQPwASABKQPwAYU3A4AKQQAgAikD+AEgASkD+AGFNwOICkEAIAIpA4ACIAEpA4AChTcDkApBACACKQOIAiABKQOIAoU3A5gKQQAgAikDkAIgASkDkAKFNwOgCkEAIAIpA5gCIAEpA5gChTcDqApBACACKQOgAiABKQOgAoU3A7AKQQAgAikDqAIgASkDqAKFNwO4CkEAIAIpA7ACIAEpA7AChTcDwApBACACKQO4AiABKQO4AoU3A8gKQQAgAikDwAIgASkDwAKFNwPQCkEAIAIpA8gCIAEpA8gChTcD2ApBACACKQPQAiABKQPQAoU3A+AKQQAgAikD2AIgASkD2AKFNwPoCkEAIAIpA+ACIAEpA+AChTcD8ApBACACKQPoAiABKQPoAoU3A/gKQQAgAikD8AIgASkD8AKFNwOAC0EAIAIpA/gCIAEpA/gChTcDiAtBACACKQOAAyABKQOAA4U3A5ALQQAgAikDiAMgASkDiAOFNwOYC0EAIAIpA5ADIAEpA5ADhTcDoAtBACACKQOYAyABKQOYA4U3A6gLQQAgAikDoAMgASkDoAOFNwOwC0EAIAIpA6gDIAEpA6gDhTcDuAtBACACKQOwAyABKQOwA4U3A8ALQQAgAikDuAMgASkDuAOFNwPIC0EAIAIpA8ADIAEpA8ADhTcD0AtBACACKQPIAyABKQPIA4U3A9gLQQAgAikD0AMgASkD0AOFNwPgC0EAIAIpA9gDIAEpA9gDhTcD6AtBACACKQPgAyABKQPgA4U3A/ALQQAgAikD6AMgASkD6AOFNwP4C0EAIAIpA/ADIAEpA/ADhTcDgAxBACACKQP4AyABKQP4A4U3A4gMQQAgAikDgAQgASkDgASFNwOQDEEAIAIpA4gEIAEpA4gEhTcDmAxBACACKQOQBCABKQOQBIU3A6AMQQAgAikDmAQgASkDmASFNwOoDEEAIAIpA6AEIAEpA6AEhTcDsAxBACACKQOoBCABKQOoBIU3A7gMQQAgAikDsAQgASkDsASFNwPADEEAIAIpA7gEIAEpA7gEhTcDyAxBACACKQPABCABKQPABIU3A9AMQQAgAikDyAQgASkDyASFNwPYDEEAIAIpA9AEIAEpA9AEhTcD4AxBACACKQPYBCABKQPYBIU3A+gMQQAgAikD4AQgASkD4ASFNwPwDEEAIAIpA+gEIAEpA+gEhTcD+AxBACACKQPwBCABKQPwBIU3A4ANQQAgAikD+AQgASkD+ASFNwOIDUEAIAIpA4AFIAEpA4AFhTcDkA1BACACKQOIBSABKQOIBYU3A5gNQQAgAikDkAUgASkDkAWFNwOgDUEAIAIpA5gFIAEpA5gFhTcDqA1BACACKQOgBSABKQOgBYU3A7ANQQAgAikDqAUgASkDqAWFNwO4DUEAIAIpA7AFIAEpA7AFhTcDwA1BACACKQO4BSABKQO4BYU3A8gNQQAgAikDwAUgASkDwAWFNwPQDUEAIAIpA8gFIAEpA8gFhTcD2A1BACACKQPQBSABKQPQBYU3A+ANQQAgAikD2AUgASkD2AWFNwPoDUEAIAIpA+AFIAEpA+AFhTcD8A1BACACKQPoBSABKQPoBYU3A/gNQQAgAikD8AUgASkD8AWFNwOADkEAIAIpA/gFIAEpA/gFhTcDiA5BACACKQOABiABKQOABoU3A5AOQQAgAikDiAYgASkDiAaFNwOYDkEAIAIpA5AGIAEpA5AGhTcDoA5BACACKQOYBiABKQOYBoU3A6gOQQAgAikDoAYgASkDoAaFNwOwDkEAIAIpA6gGIAEpA6gGhTcDuA5BACACKQOwBiABKQOwBoU3A8AOQQAgAikDuAYgASkDuAaFNwPIDkEAIAIpA8AGIAEpA8AGhTcD0A5BACACKQPIBiABKQPIBoU3A9gOQQAgAikD0AYgASkD0AaFNwPgDkEAIAIpA9gGIAEpA9gGhTcD6A5BACACKQPgBiABKQPgBoU3A/AOQQAgAikD6AYgASkD6AaFNwP4DkEAIAIpA/AGIAEpA/AGhTcDgA9BACACKQP4BiABKQP4BoU3A4gPQQAgAikDgAcgASkDgAeFNwOQD0EAIAIpA4gHIAEpA4gHhTcDmA9BACACKQOQByABKQOQB4U3A6APQQAgAikDmAcgASkDmAeFNwOoD0EAIAIpA6AHIAEpA6AHhTcDsA9BACACKQOoByABKQOoB4U3A7gPQQAgAikDsAcgASkDsAeFNwPAD0EAIAIpA7gHIAEpA7gHhTcDyA9BACACKQPAByABKQPAB4U3A9APQQAgAikDyAcgASkDyAeFNwPYD0EAIAIpA9AHIAEpA9AHhTcD4A9BACACKQPYByABKQPYB4U3A+gPQQAgAikD4AcgASkD4AeFNwPwD0EAIAIpA+gHIAEpA+gHhTcD+A9BACACKQPwByABKQPwB4U3A4AQQQAgAikD+AcgASkD+AeFNwOIEEGQCEGYCEGgCEGoCEGwCEG4CEHACEHICEHQCEHYCEHgCEHoCEHwCEH4CEGACUGICRACQZAJQZgJQaAJQagJQbAJQbgJQcAJQcgJQdAJQdgJQeAJQegJQfAJQfgJQYAKQYgKEAJBkApBmApBoApBqApBsApBuApBwApByApB0ApB2ApB4ApB6ApB8ApB+ApBgAtBiAsQAkGQC0GYC0GgC0GoC0GwC0G4C0HAC0HIC0HQC0HYC0HgC0HoC0HwC0H4C0GADEGIDBACQZAMQZgMQaAMQagMQbAMQbgMQcAMQcgMQdAMQdgMQeAMQegMQfAMQfgMQYANQYgNEAJBkA1BmA1BoA1BqA1BsA1BuA1BwA1ByA1B0A1B2A1B4A1B6A1B8A1B+A1BgA5BiA4QAkGQDkGYDkGgDkGoDkGwDkG4DkHADkHIDkHQDkHYDkHgDkHoDkHwDkH4DkGAD0GIDxACQZAPQZgPQaAPQagPQbAPQbgPQcAPQcgPQdAPQdgPQeAPQegPQfAPQfgPQYAQQYgQEAJBkAhBmAhBkAlBmAlBkApBmApBkAtBmAtBkAxBmAxBkA1BmA1BkA5BmA5BkA9BmA8QAkGgCEGoCEGgCUGoCUGgCkGoCkGgC0GoC0GgDEGoDEGgDUGoDUGgDkGoDkGgD0GoDxACQbAIQbgIQbAJQbgJQbAKQbgKQbALQbgLQbAMQbgMQbANQbgNQbAOQbgOQbAPQbgPEAJBwAhByAhBwAlByAlBwApByApBwAtByAtBwAxByAxBwA1ByA1BwA5ByA5BwA9ByA8QAkHQCEHYCEHQCUHYCUHQCkHYCkHQC0HYC0HQDEHYDEHQDUHYDUHQDkHYDkHQD0HYDxACQeAIQegIQeAJQegJQeAKQegKQeALQegLQeAMQegMQeANQegNQeAOQegOQeAPQegPEAJB8AhB+AhB8AlB+AlB8ApB+ApB8AtB+AtB8AxB+AxB8A1B+A1B8A5B+A5B8A9B+A8QAkGACUGICUGACkGICkGAC0GIC0GADEGIDEGADUGIDUGADkGIDkGAD0GID0GAEEGIEBACAkACQCADRQ0AA0AgACAEaiIDIAIgBGoiBSkDACABIARqIgYpAwCFIARBkAhqKQMAhSADKQMAhTcDACADQQhqIgMgBUEIaikDACAGQQhqKQMAhSAEQZgIaikDAIUgAykDAIU3AwAgBEEQaiIEQYAIRw0ADAILC0EAIQQDQCAAIARqIgMgAiAEaiIFKQMAIAEgBGoiBikDAIUgBEGQCGopAwCFNwMAIANBCGogBUEIaikDACAGQQhqKQMAhSAEQZgIaikDAIU3AwAgBEEQaiIEQYAIRw0ACwsL5QcMBX8BfgR/An4BfwF+AX8Bfgd/AX4DfwF+AkBBACgCgAgiAiABQQp0aiIDKAIIIAFHDQAgAygCDCEEIAMoAgAhBUEAIAMoAhQiBq03A7gQQQAgBK0iBzcDsBBBACAFIAEgBUECdG4iCGwiCUECdK03A6gQAkACQAJAAkAgBEUNAEF/IQogBUUNASAIQQNsIQsgCEECdCIErSEMIAWtIQ0gBkF/akECSSEOQgAhDwNAQQAgDzcDkBAgD6chEEIAIRFBACEBA0BBACARNwOgECAPIBGEUCIDIA5xIRIgBkEBRiAPUCITIAZBAkYgEUICVHFxciEUQX8gAUEBakEDcSAIbEF/aiATGyEVIAEgEHIhFiABIAhsIRcgA0EBdCEYQgAhGQNAQQBCADcDwBBBACAZNwOYECAYIQECQCASRQ0AQQBCATcDwBBBkBhBkBBBkCBBABADQZAYQZAYQZAgQQAQA0ECIQELAkAgASAITw0AIAQgGaciGmwgF2ogAWohAwNAIANBACAEIAEbQQAgEVAiGxtqQX9qIRwCQAJAIBQNAEEAKAKACCICIBxBCnQiHGohCgwBCwJAIAFB/wBxIgINAEEAQQApA8AQQgF8NwPAEEGQGEGQEEGQIEEAEANBkBhBkBhBkCBBABADCyAcQQp0IRwgAkEDdEGQGGohCkEAKAKACCECCyACIANBCnRqIAIgHGogAiAKKQMAIh1CIIinIAVwIBogFhsiHCAEbCABIAFBACAZIBytUSIcGyIKIBsbIBdqIAogC2ogExsgAUUgHHJrIhsgFWqtIB1C/////w+DIh0gHX5CIIggG61+QiCIfSAMgqdqQQp0akEBEAMgA0EBaiEDIAggAUEBaiIBRw0ACwsgGUIBfCIZIA1SDQALIBFCAXwiEachASARQgRSDQALIA9CAXwiDyAHUg0AC0EAKAKACCECCyAJQQx0QYB4aiEXIAVBf2oiCkUNAgwBC0EAQgM3A6AQQQAgBEF/aq03A5AQQYB4IRcLIAIgF2ohGyAIQQx0IQhBACEcA0AgCCAcQQFqIhxsQYB4aiEEQQAhAQNAIBsgAWoiAyADKQMAIAIgBCABamopAwCFNwMAIANBCGoiAyADKQMAIAIgBCABQQhyamopAwCFNwMAIAFBCGohAyABQRBqIQEgA0H4B0kNAAsgHCAKRw0ACwsgAiAXaiEbQXghAQNAIAIgAWoiA0EIaiAbIAFqIgRBCGopAwA3AwAgA0EQaiAEQRBqKQMANwMAIANBGGogBEEYaikDADcDACADQSBqIARBIGopAwA3AwAgAUEgaiIBQfgHSQ0ACwsL",hash:"e4cdc523"},mp={name:"blake2b",data:"AGFzbQEAAAABEQRgAAF/YAJ/fwBgAX8AYAAAAwoJAAECAwECAgABBQQBAQICBg4CfwFBsIsFC38AQYAICwdwCAZtZW1vcnkCAA5IYXNoX0dldEJ1ZmZlcgAACkhhc2hfRmluYWwAAwlIYXNoX0luaXQABQtIYXNoX1VwZGF0ZQAGDUhhc2hfR2V0U3RhdGUABw5IYXNoX0NhbGN1bGF0ZQAIClNUQVRFX1NJWkUDAQrTOAkFAEGACQvrAgIFfwF+AkAgAUEBSA0AAkACQAJAIAFBgAFBACgC4IoBIgJrIgNKDQAgASEEDAELQQBBADYC4IoBAkAgAkH/AEoNACACQeCJAWohBSAAIQRBACEGA0AgBSAELQAAOgAAIARBAWohBCAFQQFqIQUgAyAGQQFqIgZB/wFxSg0ACwtBAEEAKQPAiQEiB0KAAXw3A8CJAUEAQQApA8iJASAHQv9+Vq18NwPIiQFB4IkBEAIgACADaiEAAkAgASADayIEQYEBSA0AIAIgAWohBQNAQQBBACkDwIkBIgdCgAF8NwPAiQFBAEEAKQPIiQEgB0L/flatfDcDyIkBIAAQAiAAQYABaiEAIAVBgH9qIgVBgAJLDQALIAVBgH9qIQQMAQsgBEEATA0BC0EAIQUDQCAFQQAoAuCKAWpB4IkBaiAAIAVqLQAAOgAAIAQgBUEBaiIFQf8BcUoNAAsLQQBBACgC4IoBIARqNgLgigELC78uASR+QQBBACkD0IkBQQApA7CJASIBQQApA5CJAXwgACkDICICfCIDhULr+obav7X2wR+FQiCJIgRCq/DT9K/uvLc8fCIFIAGFQiiJIgYgA3wgACkDKCIBfCIHIASFQjCJIgggBXwiCSAGhUIBiSIKQQApA8iJAUEAKQOoiQEiBEEAKQOIiQF8IAApAxAiA3wiBYVCn9j52cKR2oKbf4VCIIkiC0K7zqqm2NDrs7t/fCIMIASFQiiJIg0gBXwgACkDGCIEfCIOfCAAKQNQIgV8Ig9BACkDwIkBQQApA6CJASIQQQApA4CJASIRfCAAKQMAIgZ8IhKFQtGFmu/6z5SH0QCFQiCJIhNCiJLznf/M+YTqAHwiFCAQhUIoiSIVIBJ8IAApAwgiEHwiFiAThUIwiSIXhUIgiSIYQQApA9iJAUEAKQO4iQEiE0EAKQOYiQF8IAApAzAiEnwiGYVC+cL4m5Gjs/DbAIVCIIkiGkLx7fT4paf9p6V/fCIbIBOFQiiJIhwgGXwgACkDOCITfCIZIBqFQjCJIhogG3wiG3wiHSAKhUIoiSIeIA98IAApA1giCnwiDyAYhUIwiSIYIB18Ih0gDiALhUIwiSIOIAx8Ih8gDYVCAYkiDCAWfCAAKQNAIgt8Ig0gGoVCIIkiFiAJfCIaIAyFQiiJIiAgDXwgACkDSCIJfCIhIBaFQjCJIhYgGyAchUIBiSIMIAd8IAApA2AiB3wiDSAOhUIgiSIOIBcgFHwiFHwiFyAMhUIoiSIbIA18IAApA2giDHwiHCAOhUIwiSIOIBd8IhcgG4VCAYkiGyAZIBQgFYVCAYkiFHwgACkDcCINfCIVIAiFQiCJIhkgH3wiHyAUhUIoiSIUIBV8IAApA3giCHwiFXwgDHwiIoVCIIkiI3wiJCAbhUIoiSIbICJ8IBJ8IiIgFyAYIBUgGYVCMIkiFSAffCIZIBSFQgGJIhQgIXwgDXwiH4VCIIkiGHwiFyAUhUIoiSIUIB98IAV8Ih8gGIVCMIkiGCAXfCIXIBSFQgGJIhR8IAF8IiEgFiAafCIWIBUgHSAehUIBiSIaIBx8IAl8IhyFQiCJIhV8Ih0gGoVCKIkiGiAcfCAIfCIcIBWFQjCJIhWFQiCJIh4gGSAOIBYgIIVCAYkiFiAPfCACfCIPhUIgiSIOfCIZIBaFQiiJIhYgD3wgC3wiDyAOhUIwiSIOIBl8Ihl8IiAgFIVCKIkiFCAhfCAEfCIhIB6FQjCJIh4gIHwiICAiICOFQjCJIiIgJHwiIyAbhUIBiSIbIBx8IAp8IhwgDoVCIIkiDiAXfCIXIBuFQiiJIhsgHHwgE3wiHCAOhUIwiSIOIBkgFoVCAYkiFiAffCAQfCIZICKFQiCJIh8gFSAdfCIVfCIdIBaFQiiJIhYgGXwgB3wiGSAfhUIwiSIfIB18Ih0gFoVCAYkiFiAVIBqFQgGJIhUgD3wgBnwiDyAYhUIgiSIYICN8IhogFYVCKIkiFSAPfCADfCIPfCAHfCIihUIgiSIjfCIkIBaFQiiJIhYgInwgBnwiIiAjhUIwiSIjICR8IiQgFoVCAYkiFiAOIBd8Ig4gDyAYhUIwiSIPICAgFIVCAYkiFCAZfCAKfCIXhUIgiSIYfCIZIBSFQiiJIhQgF3wgC3wiF3wgBXwiICAPIBp8Ig8gHyAOIBuFQgGJIg4gIXwgCHwiGoVCIIkiG3wiHyAOhUIoiSIOIBp8IAx8IhogG4VCMIkiG4VCIIkiISAdIB4gDyAVhUIBiSIPIBx8IAF8IhWFQiCJIhx8Ih0gD4VCKIkiDyAVfCADfCIVIByFQjCJIhwgHXwiHXwiHiAWhUIoiSIWICB8IA18IiAgIYVCMIkiISAefCIeIBogFyAYhUIwiSIXIBl8IhggFIVCAYkiFHwgCXwiGSAchUIgiSIaICR8IhwgFIVCKIkiFCAZfCACfCIZIBqFQjCJIhogHSAPhUIBiSIPICJ8IAR8Ih0gF4VCIIkiFyAbIB98Iht8Ih8gD4VCKIkiDyAdfCASfCIdIBeFQjCJIhcgH3wiHyAPhUIBiSIPIBsgDoVCAYkiDiAVfCATfCIVICOFQiCJIhsgGHwiGCAOhUIoiSIOIBV8IBB8IhV8IAx8IiKFQiCJIiN8IiQgD4VCKIkiDyAifCAHfCIiICOFQjCJIiMgJHwiJCAPhUIBiSIPIBogHHwiGiAVIBuFQjCJIhUgHiAWhUIBiSIWIB18IAR8IhuFQiCJIhx8Ih0gFoVCKIkiFiAbfCAQfCIbfCABfCIeIBUgGHwiFSAXIBogFIVCAYkiFCAgfCATfCIYhUIgiSIXfCIaIBSFQiiJIhQgGHwgCXwiGCAXhUIwiSIXhUIgiSIgIB8gISAVIA6FQgGJIg4gGXwgCnwiFYVCIIkiGXwiHyAOhUIoiSIOIBV8IA18IhUgGYVCMIkiGSAffCIffCIhIA+FQiiJIg8gHnwgBXwiHiAghUIwiSIgICF8IiEgGyAchUIwiSIbIB18IhwgFoVCAYkiFiAYfCADfCIYIBmFQiCJIhkgJHwiHSAWhUIoiSIWIBh8IBJ8IhggGYVCMIkiGSAfIA6FQgGJIg4gInwgAnwiHyAbhUIgiSIbIBcgGnwiF3wiGiAOhUIoiSIOIB98IAZ8Ih8gG4VCMIkiGyAafCIaIA6FQgGJIg4gFSAXIBSFQgGJIhR8IAh8IhUgI4VCIIkiFyAcfCIcIBSFQiiJIhQgFXwgC3wiFXwgBXwiIoVCIIkiI3wiJCAOhUIoiSIOICJ8IAh8IiIgGiAgIBUgF4VCMIkiFSAcfCIXIBSFQgGJIhQgGHwgCXwiGIVCIIkiHHwiGiAUhUIoiSIUIBh8IAZ8IhggHIVCMIkiHCAafCIaIBSFQgGJIhR8IAR8IiAgGSAdfCIZIBUgISAPhUIBiSIPIB98IAN8Ih2FQiCJIhV8Ih8gD4VCKIkiDyAdfCACfCIdIBWFQjCJIhWFQiCJIiEgFyAbIBkgFoVCAYkiFiAefCABfCIZhUIgiSIbfCIXIBaFQiiJIhYgGXwgE3wiGSAbhUIwiSIbIBd8Ihd8Ih4gFIVCKIkiFCAgfCAMfCIgICGFQjCJIiEgHnwiHiAiICOFQjCJIiIgJHwiIyAOhUIBiSIOIB18IBJ8Ih0gG4VCIIkiGyAafCIaIA6FQiiJIg4gHXwgC3wiHSAbhUIwiSIbIBcgFoVCAYkiFiAYfCANfCIXICKFQiCJIhggFSAffCIVfCIfIBaFQiiJIhYgF3wgEHwiFyAYhUIwiSIYIB98Ih8gFoVCAYkiFiAVIA+FQgGJIg8gGXwgCnwiFSAchUIgiSIZICN8IhwgD4VCKIkiDyAVfCAHfCIVfCASfCIihUIgiSIjfCIkIBaFQiiJIhYgInwgBXwiIiAjhUIwiSIjICR8IiQgFoVCAYkiFiAbIBp8IhogFSAZhUIwiSIVIB4gFIVCAYkiFCAXfCADfCIXhUIgiSIZfCIbIBSFQiiJIhQgF3wgB3wiF3wgAnwiHiAVIBx8IhUgGCAaIA6FQgGJIg4gIHwgC3wiGoVCIIkiGHwiHCAOhUIoiSIOIBp8IAR8IhogGIVCMIkiGIVCIIkiICAfICEgFSAPhUIBiSIPIB18IAZ8IhWFQiCJIh18Ih8gD4VCKIkiDyAVfCAKfCIVIB2FQjCJIh0gH3wiH3wiISAWhUIoiSIWIB58IAx8Ih4gIIVCMIkiICAhfCIhIBogFyAZhUIwiSIXIBt8IhkgFIVCAYkiFHwgEHwiGiAdhUIgiSIbICR8Ih0gFIVCKIkiFCAafCAJfCIaIBuFQjCJIhsgHyAPhUIBiSIPICJ8IBN8Ih8gF4VCIIkiFyAYIBx8Ihh8IhwgD4VCKIkiDyAffCABfCIfIBeFQjCJIhcgHHwiHCAPhUIBiSIPIBggDoVCAYkiDiAVfCAIfCIVICOFQiCJIhggGXwiGSAOhUIoiSIOIBV8IA18IhV8IA18IiKFQiCJIiN8IiQgD4VCKIkiDyAifCAMfCIiICOFQjCJIiMgJHwiJCAPhUIBiSIPIBsgHXwiGyAVIBiFQjCJIhUgISAWhUIBiSIWIB98IBB8IhiFQiCJIh18Ih8gFoVCKIkiFiAYfCAIfCIYfCASfCIhIBUgGXwiFSAXIBsgFIVCAYkiFCAefCAHfCIZhUIgiSIXfCIbIBSFQiiJIhQgGXwgAXwiGSAXhUIwiSIXhUIgiSIeIBwgICAVIA6FQgGJIg4gGnwgAnwiFYVCIIkiGnwiHCAOhUIoiSIOIBV8IAV8IhUgGoVCMIkiGiAcfCIcfCIgIA+FQiiJIg8gIXwgBHwiISAehUIwiSIeICB8IiAgGCAdhUIwiSIYIB98Ih0gFoVCAYkiFiAZfCAGfCIZIBqFQiCJIhogJHwiHyAWhUIoiSIWIBl8IBN8IhkgGoVCMIkiGiAcIA6FQgGJIg4gInwgCXwiHCAYhUIgiSIYIBcgG3wiF3wiGyAOhUIoiSIOIBx8IAN8IhwgGIVCMIkiGCAbfCIbIA6FQgGJIg4gFSAXIBSFQgGJIhR8IAt8IhUgI4VCIIkiFyAdfCIdIBSFQiiJIhQgFXwgCnwiFXwgBHwiIoVCIIkiI3wiJCAOhUIoiSIOICJ8IAl8IiIgGyAeIBUgF4VCMIkiFSAdfCIXIBSFQgGJIhQgGXwgDHwiGYVCIIkiHXwiGyAUhUIoiSIUIBl8IAp8IhkgHYVCMIkiHSAbfCIbIBSFQgGJIhR8IAN8Ih4gGiAffCIaIBUgICAPhUIBiSIPIBx8IAd8IhyFQiCJIhV8Ih8gD4VCKIkiDyAcfCAQfCIcIBWFQjCJIhWFQiCJIiAgFyAYIBogFoVCAYkiFiAhfCATfCIahUIgiSIYfCIXIBaFQiiJIhYgGnwgDXwiGiAYhUIwiSIYIBd8Ihd8IiEgFIVCKIkiFCAefCAFfCIeICCFQjCJIiAgIXwiISAiICOFQjCJIiIgJHwiIyAOhUIBiSIOIBx8IAt8IhwgGIVCIIkiGCAbfCIbIA6FQiiJIg4gHHwgEnwiHCAYhUIwiSIYIBcgFoVCAYkiFiAZfCABfCIXICKFQiCJIhkgFSAffCIVfCIfIBaFQiiJIhYgF3wgBnwiFyAZhUIwiSIZIB98Ih8gFoVCAYkiFiAVIA+FQgGJIg8gGnwgCHwiFSAdhUIgiSIaICN8Ih0gD4VCKIkiDyAVfCACfCIVfCANfCIihUIgiSIjfCIkIBaFQiiJIhYgInwgCXwiIiAjhUIwiSIjICR8IiQgFoVCAYkiFiAYIBt8IhggFSAahUIwiSIVICEgFIVCAYkiFCAXfCASfCIXhUIgiSIafCIbIBSFQiiJIhQgF3wgCHwiF3wgB3wiISAVIB18IhUgGSAYIA6FQgGJIg4gHnwgBnwiGIVCIIkiGXwiHSAOhUIoiSIOIBh8IAt8IhggGYVCMIkiGYVCIIkiHiAfICAgFSAPhUIBiSIPIBx8IAp8IhWFQiCJIhx8Ih8gD4VCKIkiDyAVfCAEfCIVIByFQjCJIhwgH3wiH3wiICAWhUIoiSIWICF8IAN8IiEgHoVCMIkiHiAgfCIgIBggFyAahUIwiSIXIBt8IhogFIVCAYkiFHwgBXwiGCAchUIgiSIbICR8IhwgFIVCKIkiFCAYfCABfCIYIBuFQjCJIhsgHyAPhUIBiSIPICJ8IAx8Ih8gF4VCIIkiFyAZIB18Ihl8Ih0gD4VCKIkiDyAffCATfCIfIBeFQjCJIhcgHXwiHSAPhUIBiSIPIBkgDoVCAYkiDiAVfCAQfCIVICOFQiCJIhkgGnwiGiAOhUIoiSIOIBV8IAJ8IhV8IBN8IiKFQiCJIiN8IiQgD4VCKIkiDyAifCASfCIiICOFQjCJIiMgJHwiJCAPhUIBiSIPIBsgHHwiGyAVIBmFQjCJIhUgICAWhUIBiSIWIB98IAt8IhmFQiCJIhx8Ih8gFoVCKIkiFiAZfCACfCIZfCAJfCIgIBUgGnwiFSAXIBsgFIVCAYkiFCAhfCAFfCIahUIgiSIXfCIbIBSFQiiJIhQgGnwgA3wiGiAXhUIwiSIXhUIgiSIhIB0gHiAVIA6FQgGJIg4gGHwgEHwiFYVCIIkiGHwiHSAOhUIoiSIOIBV8IAF8IhUgGIVCMIkiGCAdfCIdfCIeIA+FQiiJIg8gIHwgDXwiICAhhUIwiSIhIB58Ih4gGSAchUIwiSIZIB98IhwgFoVCAYkiFiAafCAIfCIaIBiFQiCJIhggJHwiHyAWhUIoiSIWIBp8IAp8IhogGIVCMIkiGCAdIA6FQgGJIg4gInwgBHwiHSAZhUIgiSIZIBcgG3wiF3wiGyAOhUIoiSIOIB18IAd8Ih0gGYVCMIkiGSAbfCIbIA6FQgGJIg4gFSAXIBSFQgGJIhR8IAx8IhUgI4VCIIkiFyAcfCIcIBSFQiiJIhQgFXwgBnwiFXwgEnwiIoVCIIkiI3wiJCAOhUIoiSIOICJ8IBN8IiIgGyAhIBUgF4VCMIkiFSAcfCIXIBSFQgGJIhQgGnwgBnwiGoVCIIkiHHwiGyAUhUIoiSIUIBp8IBB8IhogHIVCMIkiHCAbfCIbIBSFQgGJIhR8IA18IiEgGCAffCIYIBUgHiAPhUIBiSIPIB18IAJ8Ih2FQiCJIhV8Ih4gD4VCKIkiDyAdfCABfCIdIBWFQjCJIhWFQiCJIh8gFyAZIBggFoVCAYkiFiAgfCADfCIYhUIgiSIZfCIXIBaFQiiJIhYgGHwgBHwiGCAZhUIwiSIZIBd8Ihd8IiAgFIVCKIkiFCAhfCAIfCIhIB+FQjCJIh8gIHwiICAiICOFQjCJIiIgJHwiIyAOhUIBiSIOIB18IAd8Ih0gGYVCIIkiGSAbfCIbIA6FQiiJIg4gHXwgDHwiHSAZhUIwiSIZIBcgFoVCAYkiFiAafCALfCIXICKFQiCJIhogFSAefCIVfCIeIBaFQiiJIhYgF3wgCXwiFyAahUIwiSIaIB58Ih4gFoVCAYkiFiAVIA+FQgGJIg8gGHwgBXwiFSAchUIgiSIYICN8IhwgD4VCKIkiDyAVfCAKfCIVfCACfCIChUIgiSIifCIjIBaFQiiJIhYgAnwgC3wiAiAihUIwiSILICN8IiIgFoVCAYkiFiAZIBt8IhkgFSAYhUIwiSIVICAgFIVCAYkiFCAXfCANfCINhUIgiSIXfCIYIBSFQiiJIhQgDXwgBXwiBXwgEHwiECAVIBx8Ig0gGiAZIA6FQgGJIg4gIXwgDHwiDIVCIIkiFXwiGSAOhUIoiSIOIAx8IBJ8IhIgFYVCMIkiDIVCIIkiFSAeIB8gDSAPhUIBiSINIB18IAl8IgmFQiCJIg98IhogDYVCKIkiDSAJfCAIfCIJIA+FQjCJIgggGnwiD3wiGiAWhUIoiSIWIBB8IAd8IhAgEYUgDCAZfCIHIA6FQgGJIgwgCXwgCnwiCiALhUIgiSILIAUgF4VCMIkiBSAYfCIJfCIOIAyFQiiJIgwgCnwgE3wiEyALhUIwiSIKIA58IguFNwOAiQFBACADIAYgDyANhUIBiSINIAJ8fCICIAWFQiCJIgUgB3wiBiANhUIoiSIHIAJ8fCICQQApA4iJAYUgBCABIBIgCSAUhUIBiSIDfHwiASAIhUIgiSISICJ8IgkgA4VCKIkiAyABfHwiASAShUIwiSIEIAl8IhKFNwOIiQFBACATQQApA5CJAYUgECAVhUIwiSIQIBp8IhOFNwOQiQFBACABQQApA5iJAYUgAiAFhUIwiSICIAZ8IgGFNwOYiQFBACASIAOFQgGJQQApA6CJAYUgAoU3A6CJAUEAIBMgFoVCAYlBACkDqIkBhSAKhTcDqIkBQQAgASAHhUIBiUEAKQOwiQGFIASFNwOwiQFBACALIAyFQgGJQQApA7iJAYUgEIU3A7iJAQvdAgUBfwF+AX8BfgJ/IwBBwABrIgAkAAJAQQApA9CJAUIAUg0AQQBBACkDwIkBIgFBACgC4IoBIgKsfCIDNwPAiQFBAEEAKQPIiQEgAyABVK18NwPIiQECQEEALQDoigFFDQBBAEJ/NwPYiQELQQBCfzcD0IkBAkAgAkH/AEoNAEEAIQQDQCACIARqQeCJAWpBADoAACAEQQFqIgRBgAFBACgC4IoBIgJrSA0ACwtB4IkBEAIgAEEAKQOAiQE3AwAgAEEAKQOIiQE3AwggAEEAKQOQiQE3AxAgAEEAKQOYiQE3AxggAEEAKQOgiQE3AyAgAEEAKQOoiQE3AyggAEEAKQOwiQE3AzAgAEEAKQO4iQE3AzhBACgC5IoBIgVBAUgNAEEAIQRBACECA0AgBEGACWogACAEai0AADoAACAEQQFqIQQgBSACQQFqIgJB/wFxSg0ACwsgAEHAAGokAAv9AwMBfwF+AX8jAEGAAWsiAiQAQQBBgQI7AfKKAUEAIAE6APGKAUEAIAA6APCKAUGQfiEAA0AgAEGAiwFqQgA3AAAgAEH4igFqQgA3AAAgAEHwigFqQgA3AAAgAEEYaiIADQALQQAhAEEAQQApA/CKASIDQoiS853/zPmE6gCFNwOAiQFBAEEAKQP4igFCu86qptjQ67O7f4U3A4iJAUEAQQApA4CLAUKr8NP0r+68tzyFNwOQiQFBAEEAKQOIiwFC8e30+KWn/aelf4U3A5iJAUEAQQApA5CLAULRhZrv+s+Uh9EAhTcDoIkBQQBBACkDmIsBQp/Y+dnCkdqCm3+FNwOoiQFBAEEAKQOgiwFC6/qG2r+19sEfhTcDsIkBQQBBACkDqIsBQvnC+JuRo7Pw2wCFNwO4iQFBACADp0H/AXE2AuSKAQJAIAFBAUgNACACQgA3A3ggAkIANwNwIAJCADcDaCACQgA3A2AgAkIANwNYIAJCADcDUCACQgA3A0ggAkIANwNAIAJCADcDOCACQgA3AzAgAkIANwMoIAJCADcDICACQgA3AxggAkIANwMQIAJCADcDCCACQgA3AwBBACEEA0AgAiAAaiAAQYAJai0AADoAACAAQQFqIQAgBEEBaiIEQf8BcSABSA0ACyACQYABEAELIAJBgAFqJAALEgAgAEEDdkH/P3EgAEEQdhAECwkAQYAJIAAQAQsGAEGAiQELGwAgAUEDdkH/P3EgAUEQdhAEQYAJIAAQARADCwsLAQBBgAgLBPAAAAA=",hash:"c6f286e6"};function yp(e){return!Number.isInteger(e)||e<8||e>512||e%8!=0?new Error("Invalid variant! Valid values: 8, 16, ..., 512"):null}function wp(e=512,t=null){if(yp(e))return Promise.reject(yp(e));let n=null,r=e;if(null!==t){if(n=sp(t),n.length>64)return Promise.reject(new Error("Max key length is 64 bytes"));i=e,o=n.length,r=i|o<<16}var i,o;const s=e/8;return pp(mp,s).then(e=>{r>512&&e.writeMemory(n),e.init(r);const t={init:r>512?()=>(e.writeMemory(n),e.init(r),t):()=>(e.init(r),t),update:n=>(e.update(n),t),digest:t=>e.digest(t),save:()=>e.save(),load:n=>(e.load(n),t),blockSize:128,digestSize:s};return t})}new zh;const vp=new DataView(new ArrayBuffer(4));function Ap(e){return vp.setInt32(0,e,!0),new Uint8Array(vp.buffer)}function bp(e,t,n){return Yh(this,void 0,void 0,function*(){if(n<=64){const e=yield wp(8*n);return e.update(Ap(n)),e.update(t),e.digest("binary")}const r=Math.ceil(n/32)-2,i=new Uint8Array(n);e.init(),e.update(Ap(n)),e.update(t);let o=e.digest("binary");i.set(o.subarray(0,32),0);for(let t=1;t{var t;if(!e||"object"!=typeof e)throw new Error("Invalid options parameter. It requires an object.");if(!e.password)throw new Error("Password must be specified");if(e.password=sp(e.password),e.password.length<1)throw new Error("Password must be specified");if(!e.salt)throw new Error("Salt must be specified");if(e.salt=sp(e.salt),e.salt.length<8)throw new Error("Salt should be at least 8 bytes long");if(e.secret=sp(null!==(t=e.secret)&&void 0!==t?t:""),!Number.isInteger(e.iterations)||e.iterations<1)throw new Error("Iterations should be a positive number");if(!Number.isInteger(e.parallelism)||e.parallelism<1)throw new Error("Parallelism should be a positive number");if(!Number.isInteger(e.hashLength)||e.hashLength<4)throw new Error("Hash length should be at least 4 bytes.");if(!Number.isInteger(e.memorySize))throw new Error("Memory size should be specified.");if(e.memorySize<8*e.parallelism)throw new Error("Memory size should be at least 8 * parallelism.");if(void 0===e.outputType&&(e.outputType="hex"),!["hex","binary","encoded"].includes(e.outputType))throw new Error(`Insupported output type ${e.outputType}. Valid values: ['hex', 'binary', 'encoded']`)})(e),kp(Object.assign(Object.assign({},e),{hashType:"id"}))})}new zh,new zh,new zh,new zh,new zh,new zh,new zh,new zh,new zh,new zh,new zh,new zh,new zh,new zh,new zh,new zh,new zh,new zh,new zh,new zh;const Ep={parallelism:4,iterations:8,memorySize:262144,hashLength:32,outputType:"binary"};let Cp=null,xp=0;const Bp=new Map;async function Sp(e,t){try{const n=function(){if(Cp)return Cp;const e=new Blob(["\n importScripts('https://cdn.jsdelivr.net/npm/hash-wasm@4.11.0/dist/argon2.umd.min.js');\n\n const ARGON2_CONFIG = {\n parallelism: 4,\n iterations: 8,\n memorySize: 262144,\n hashLength: 32,\n outputType: \"binary\"\n };\n\n self.onmessage = async function(e) {\n const { password, salt, id } = e.data;\n\n try {\n const result = await hashwasm.argon2id({\n password: password,\n salt: new Uint8Array(salt),\n ...ARGON2_CONFIG\n });\n\n self.postMessage({\n id,\n success: true,\n result: Array.from(result)\n });\n } catch (error) {\n self.postMessage({\n id,\n success: false,\n error: error.message\n });\n }\n };\n "],{type:"application/javascript"});return Cp=new Worker(URL.createObjectURL(e)),Cp.onmessage=function(e){const{id:t,success:n,result:r,error:i}=e.data,o=Bp.get(t);o&&(Bp.delete(t),n?o.resolve(new Uint8Array(r)):o.reject(new Error(i)))},Cp.onerror=function(e){console.error("Argon2 worker error:",e)},Cp}(),r=++xp;return new Promise((i,o)=>{Bp.set(r,{resolve:i,reject:o}),n.postMessage({id:r,password:e,salt:Array.from(t)})})}catch(n){console.warn("Worker failed, falling back to main thread:",n);return await Ip({password:e,salt:t,...Ep})}}const{window:Fp}=u;function Qp(e){let t,n,i,o,s,a,l,c,u,p,m,y,v,I,E,C,x,B;function S(e,t){return"extension"===e[2]?Rp:Dp}let Q=S(e),D=Q(e),R=e[10]&&Gp(e),$=e[11]&&qp(e);return{c(){t=g("div"),n=g("div"),i=g("div"),o=g("h2"),o.textContent="Login to Nostr",s=w(),a=g("button"),a.textContent="×",l=w(),c=g("div"),u=g("div"),p=g("button"),p.textContent="Extension",m=w(),y=g("button"),y.textContent="Nsec",v=w(),I=g("div"),D.c(),E=w(),R&&R.c(),C=w(),$&&$.c(),k(o,"class","svelte-4xpfbi"),k(a,"class","close-btn svelte-4xpfbi"),k(i,"class","modal-header svelte-4xpfbi"),k(p,"class","tab-btn svelte-4xpfbi"),F(p,"active","extension"===e[2]),k(y,"class","tab-btn svelte-4xpfbi"),F(y,"active","nsec"===e[2]),k(u,"class","tabs svelte-4xpfbi"),k(I,"class","tab-content svelte-4xpfbi"),k(c,"class","tab-container svelte-4xpfbi"),k(n,"class","modal svelte-4xpfbi"),F(n,"dark-theme",e[1]),k(t,"class","modal-overlay svelte-4xpfbi"),k(t,"role","button"),k(t,"tabindex","0")},m(r,h){f(r,t,h),d(t,n),d(n,i),d(i,o),d(i,s),d(i,a),d(n,l),d(n,c),d(c,u),d(u,p),d(u,m),d(u,y),d(c,v),d(c,I),D.m(I,null),d(I,E),R&&R.m(I,null),d(I,C),$&&$.m(I,null),x||(B=[A(a,"click",e[17]),A(p,"click",e[26]),A(y,"click",e[27]),A(n,"click",b(e[24])),A(n,"keydown",b(e[25])),A(t,"click",e[17]),A(t,"keydown",e[32])],x=!0)},p(e,t){4&t[0]&&F(p,"active","extension"===e[2]),4&t[0]&&F(y,"active","nsec"===e[2]),Q===(Q=S(e))&&D?D.p(e,t):(D.d(1),D=Q(e),D&&(D.c(),D.m(I,E))),e[10]?R?R.p(e,t):(R=Gp(e),R.c(),R.m(I,C)):R&&(R.d(1),R=null),e[11]?$?$.p(e,t):($=qp(e),$.c(),$.m(I,null)):$&&($.d(1),$=null),2&t[0]&&F(n,"dark-theme",e[1])},d(e){e&&h(t),D.d(),R&&R.d(),$&&$.d(),x=!1,r(B)}}}function Dp(e){let t;function n(e,t){return e[14]?Pp:$p}let r=n(e),i=r(e);return{c(){t=g("div"),i.c(),k(t,"class","nsec-login svelte-4xpfbi")},m(e,n){f(e,t,n),i.m(t,null)},p(e,o){r===(r=n(e))&&i?i.p(e,o):(i.d(1),i=r(e),i&&(i.c(),i.m(t,null)))},d(e){e&&h(t),i.d()}}}function Rp(e){let t,n,r,i,o,s,a,l=e[7]?"Connecting...":"Log in using extension";return{c(){t=g("div"),n=g("p"),n.textContent="Login using a NIP-07 compatible browser\n extension like nos2x or Alby.",r=w(),i=g("button"),o=y(l),k(n,"class","svelte-4xpfbi"),k(i,"class","login-extension-btn svelte-4xpfbi"),i.disabled=e[7],k(t,"class","extension-login svelte-4xpfbi")},m(l,c){f(l,t,c),d(t,n),d(t,r),d(t,i),d(i,o),s||(a=A(i,"click",e[21]),s=!0)},p(e,t){128&t[0]&&l!==(l=e[7]?"Connecting...":"Log in using extension")&&E(o,l),128&t[0]&&(i.disabled=e[7])},d(e){e&&h(t),s=!1,a()}}}function $p(e){let t,n,i,o,s,a,l,c,u,p,m,v,b,I,x,B,S,F,Q,D,R,$,P,U=e[8]?"Generating...":"Generate New Key",T=e[12]&&Up(e),N=e[4]&&Tp(e);function L(e,t){return e[9]?Op:e[7]?Lp:Np}let O=L(e),M=O(e);return{c(){t=g("p"),t.textContent="Enter your nsec or generate a new one. Optionally\n set a password to encrypt it securely.",n=w(),i=g("button"),o=y(U),a=w(),T&&T.c(),l=w(),c=g("input"),p=w(),m=g("div"),v=g("label"),v.textContent="Encryption Password (optional but recommended):",b=w(),I=g("input"),B=w(),N&&N.c(),S=w(),F=g("small"),F.textContent="Password uses Argon2id with ~3 second derivation time for security.",Q=w(),D=g("button"),M.c(),k(t,"class","svelte-4xpfbi"),k(i,"class","generate-btn svelte-4xpfbi"),i.disabled=s=e[7]||e[8],k(c,"type","password"),k(c,"placeholder","nsec1..."),c.disabled=u=e[7]||e[9],k(c,"class","nsec-input svelte-4xpfbi"),k(v,"class","svelte-4xpfbi"),k(I,"type","password"),k(I,"placeholder","Enter password (min 8 chars)"),I.disabled=x=e[7]||e[9],k(I,"class","password-input svelte-4xpfbi"),k(F,"class","password-hint svelte-4xpfbi"),k(m,"class","password-section svelte-4xpfbi"),k(D,"class","login-nsec-btn svelte-4xpfbi"),D.disabled=R=e[7]||e[9]||!e[3].trim()},m(r,s){f(r,t,s),f(r,n,s),f(r,i,s),d(i,o),f(r,a,s),T&&T.m(r,s),f(r,l,s),f(r,c,s),C(c,e[3]),f(r,p,s),f(r,m,s),d(m,v),d(m,b),d(m,I),C(I,e[4]),d(m,B),N&&N.m(m,null),d(m,S),d(m,F),f(r,Q,s),f(r,D,s),M.m(D,null),$||(P=[A(i,"click",e[20]),A(c,"input",e[29]),A(I,"input",e[30]),A(D,"click",e[22])],$=!0)},p(e,t){256&t[0]&&U!==(U=e[8]?"Generating...":"Generate New Key")&&E(o,U),384&t[0]&&s!==(s=e[7]||e[8])&&(i.disabled=s),e[12]?T?T.p(e,t):(T=Up(e),T.c(),T.m(l.parentNode,l)):T&&(T.d(1),T=null),640&t[0]&&u!==(u=e[7]||e[9])&&(c.disabled=u),8&t[0]&&c.value!==e[3]&&C(c,e[3]),640&t[0]&&x!==(x=e[7]||e[9])&&(I.disabled=x),16&t[0]&&I.value!==e[4]&&C(I,e[4]),e[4]?N?N.p(e,t):(N=Tp(e),N.c(),N.m(m,S)):N&&(N.d(1),N=null),O!==(O=L(e))&&(M.d(1),M=O(e),M&&(M.c(),M.m(D,null))),648&t[0]&&R!==(R=e[7]||e[9]||!e[3].trim())&&(D.disabled=R)},d(e){e&&h(t),e&&h(n),e&&h(i),e&&h(a),T&&T.d(e),e&&h(l),e&&h(c),e&&h(p),e&&h(m),N&&N.d(),e&&h(Q),e&&h(D),M.d(),$=!1,r(P)}}}function Pp(e){let t,n,i,o,s,a,l,c,u,p,m,v,b,I,E=e[15]&&Mp(e);function x(e,t){return e[9]?jp:e[7]?Hp:_p}let B=x(e),S=B(e);return{c(){t=g("p"),t.textContent="You have a stored encrypted key. Enter your\n password to unlock it.",n=w(),E&&E.c(),i=w(),o=g("input"),a=w(),l=g("button"),S.c(),u=w(),p=g("button"),m=y("Clear stored key & start fresh"),k(t,"class","svelte-4xpfbi"),k(o,"type","password"),k(o,"placeholder","Enter your password"),o.disabled=s=e[7]||e[9],k(o,"class","password-input svelte-4xpfbi"),k(l,"class","login-nsec-btn svelte-4xpfbi"),l.disabled=c=e[7]||e[9]||!e[6],k(p,"class","clear-btn svelte-4xpfbi"),p.disabled=v=e[7]||e[9]},m(r,s){f(r,t,s),f(r,n,s),E&&E.m(r,s),f(r,i,s),f(r,o,s),C(o,e[6]),f(r,a,s),f(r,l,s),S.m(l,null),f(r,u,s),f(r,p,s),d(p,m),b||(I=[A(o,"input",e[28]),A(l,"click",e[18]),A(p,"click",e[16])],b=!0)},p(e,t){e[15]?E?E.p(e,t):(E=Mp(e),E.c(),E.m(i.parentNode,i)):E&&(E.d(1),E=null),640&t[0]&&s!==(s=e[7]||e[9])&&(o.disabled=s),64&t[0]&&o.value!==e[6]&&C(o,e[6]),B!==(B=x(e))&&(S.d(1),S=B(e),S&&(S.c(),S.m(l,null))),704&t[0]&&c!==(c=e[7]||e[9]||!e[6])&&(l.disabled=c),640&t[0]&&v!==(v=e[7]||e[9])&&(p.disabled=v)},d(e){e&&h(t),e&&h(n),E&&E.d(e),e&&h(i),e&&h(o),e&&h(a),e&&h(l),S.d(),e&&h(u),e&&h(p),b=!1,r(I)}}}function Up(e){let t,n,r,i,o;return{c(){t=g("div"),n=g("label"),n.textContent="Your new public key (npub):",r=w(),i=g("code"),o=y(e[12]),k(n,"class","svelte-4xpfbi"),k(i,"class","npub-display svelte-4xpfbi"),k(t,"class","generated-info svelte-4xpfbi")},m(e,s){f(e,t,s),d(t,n),d(t,r),d(t,i),d(i,o)},p(e,t){4096&t[0]&&E(o,e[12])},d(e){e&&h(t)}}}function Tp(e){let t,n,r,i;return{c(){t=g("input"),k(t,"type","password"),k(t,"placeholder","Confirm password"),t.disabled=n=e[7]||e[9],k(t,"class","password-input svelte-4xpfbi")},m(n,o){f(n,t,o),C(t,e[5]),r||(i=A(t,"input",e[31]),r=!0)},p(e,r){640&r[0]&&n!==(n=e[7]||e[9])&&(t.disabled=n),32&r[0]&&t.value!==e[5]&&C(t,e[5])},d(e){e&&h(t),r=!1,i()}}}function Np(e){let t;return{c(){t=y("Log in with nsec")},m(e,n){f(e,t,n)},d(e){e&&h(t)}}}function Lp(e){let t;return{c(){t=y("Logging in...")},m(e,n){f(e,t,n)},d(e){e&&h(t)}}}function Op(e){let t;return{c(){t=y("Deriving key...")},m(e,n){f(e,t,n)},d(e){e&&h(t)}}}function Mp(e){let t,n,r,i,o,s,a,l=e[15].slice(0,16)+"",c=e[15].slice(-8)+"";return{c(){t=g("div"),n=g("label"),n.textContent="Stored public key:",r=w(),i=g("code"),o=y(l),s=y("..."),a=y(c),k(n,"class","svelte-4xpfbi"),k(i,"class","npub-display svelte-4xpfbi"),k(t,"class","stored-info svelte-4xpfbi")},m(e,l){f(e,t,l),d(t,n),d(t,r),d(t,i),d(i,o),d(i,s),d(i,a)},p(e,t){32768&t[0]&&l!==(l=e[15].slice(0,16)+"")&&E(o,l),32768&t[0]&&c!==(c=e[15].slice(-8)+"")&&E(a,c)},d(e){e&&h(t)}}}function _p(e){let t;return{c(){t=y("Unlock")},m(e,n){f(e,t,n)},d(e){e&&h(t)}}}function Hp(e){let t;return{c(){t=y("Unlocking...")},m(e,n){f(e,t,n)},d(e){e&&h(t)}}}function jp(e){let t;return{c(){t=y("Deriving key...")},m(e,n){f(e,t,n)},d(e){e&&h(t)}}}function Gp(e){let t,n;return{c(){t=g("div"),n=y(e[10]),k(t,"class","message error-message svelte-4xpfbi")},m(e,r){f(e,t,r),d(t,n)},p(e,t){1024&t[0]&&E(n,e[10])},d(e){e&&h(t)}}}function qp(e){let t,n;return{c(){t=g("div"),n=y(e[11]),k(t,"class","message success-message svelte-4xpfbi")},m(e,r){f(e,t,r),d(t,n)},p(e,t){2048&t[0]&&E(n,e[11])},d(e){e&&h(t)}}}function Kp(e){let t,n,r,i,o,s,a,l,c,u,p,m=e[13].toFixed(1)+"";return{c(){t=g("div"),n=g("div"),r=g("div"),i=w(),o=g("h3"),o.textContent="Deriving encryption key",s=w(),a=g("div"),l=y(m),c=y("s"),u=w(),p=g("p"),p.textContent="This may take 3-6 seconds for security",k(r,"class","deriving-spinner svelte-4xpfbi"),k(o,"class","svelte-4xpfbi"),k(a,"class","deriving-timer svelte-4xpfbi"),k(p,"class","deriving-note svelte-4xpfbi"),k(n,"class","deriving-modal svelte-4xpfbi"),F(n,"dark-theme",e[1]),k(t,"class","deriving-overlay svelte-4xpfbi")},m(e,h){f(e,t,h),d(t,n),d(n,r),d(n,i),d(n,o),d(n,s),d(n,a),d(a,l),d(a,c),d(n,u),d(n,p)},p(e,t){8192&t[0]&&m!==(m=e[13].toFixed(1)+"")&&E(l,m),2&t[0]&&F(n,"dark-theme",e[1])},d(e){e&&h(t)}}}function Jp(t){let n,r,i,o,s=t[0]&&Qp(t),a=t[9]&&Kp(t);return{c(){s&&s.c(),n=w(),a&&a.c(),r=v()},m(e,l){s&&s.m(e,l),f(e,n,l),a&&a.m(e,l),f(e,r,l),i||(o=A(Fp,"keydown",t[23]),i=!0)},p(e,t){e[0]?s?s.p(e,t):(s=Qp(e),s.c(),s.m(n.parentNode,n)):s&&(s.d(1),s=null),e[9]?a?a.p(e,t):(a=Kp(e),a.c(),a.m(r.parentNode,r)):a&&(a.d(1),a=null)},i:e,o:e,d(e){s&&s.d(e),e&&h(n),a&&a.d(e),e&&h(r),i=!1,o()}}}function Vp(e,t,n){const r=U();let{showModal:i=!1}=t,{isDarkTheme:o=!1}=t,s="extension",a="",l="",c="",u="",d=!1,f=!1,h=!1,p="",g="",m="",y="",w=0,v=null,A=null;function b(){n(13,w=0),v=performance.now(),k()}function k(){null!==v&&(n(13,w=(performance.now()-v)/1e3),A=requestAnimationFrame(k))}function I(){v=null,A&&(cancelAnimationFrame(A),A=null)}P(()=>{I()});let E=!1,C="";function x(){n(14,E=!!localStorage.getItem("nostr_privkey_encrypted")),n(15,C=localStorage.getItem("nostr_pubkey")||"")}function B(){n(0,i=!1),n(3,a=""),n(4,l=""),n(5,c=""),n(6,u=""),n(10,p=""),n(11,g=""),m="",n(12,y=""),r("close")}function S(e){n(2,s=e),n(10,p=""),n(11,g=""),m="",n(12,y="")}async function F(){n(7,d=!0),n(10,p=""),n(11,g="");try{if(!a.trim())throw new Error("Please enter your nsec");if(!function(e){if(!e||!e.startsWith("nsec1"))return!1;try{return"nsec"===bu(e).type}catch{return!1}}(a.trim()))throw new Error("Invalid nsec format or checksum");if(l){if(l.length<8)throw new Error("Password must be at least 8 characters");if(l!==c)throw new Error("Passwords do not match")}const e=Sf.fromKey(a.trim()),t=await e.getPublicKey();if(localStorage.setItem("nostr_auth_method","nsec"),localStorage.setItem("nostr_pubkey",t),l){n(9,h=!0),b();const e=await async function(e,t){if(!e.startsWith("nsec1"))throw new Error("Invalid nsec format - must start with nsec1");try{if("nsec"!==bu(e).type)throw new Error("Invalid nsec - wrong type")}catch(e){throw new Error("Invalid nsec - bech32 checksum failed")}const n=crypto.getRandomValues(new Uint8Array(32)),r=crypto.getRandomValues(new Uint8Array(12)),i=await Sp(t,n),o=await crypto.subtle.importKey("raw",i,{name:"AES-GCM"},!1,["encrypt"]),s=new TextEncoder,a=await crypto.subtle.encrypt({name:"AES-GCM",iv:r},o,s.encode(e)),l=new Uint8Array(n.length+r.length+a.byteLength);return l.set(n,0),l.set(r,n.length),l.set(new Uint8Array(a),n.length+r.length),btoa(String.fromCharCode(...l))}(a.trim(),l);I(),n(9,h=!1),localStorage.setItem("nostr_privkey_encrypted",e),localStorage.removeItem("nostr_privkey")}else localStorage.setItem("nostr_privkey",a.trim()),localStorage.removeItem("nostr_privkey_encrypted"),n(11,g="Successfully logged in with nsec!");r("login",{method:"nsec",pubkey:t,privateKey:a.trim(),signer:e}),setTimeout(()=>{B()},1500)}catch(e){n(10,p=e.message)}finally{n(7,d=!1)}}$(()=>{x()});return e.$$set=e=>{"showModal"in e&&n(0,i=e.showModal),"isDarkTheme"in e&&n(1,o=e.isDarkTheme)},e.$$.update=()=>{1&e.$$.dirty[0]&&i&&x()},[i,o,s,a,l,c,u,d,f,h,p,g,y,w,E,C,function(){localStorage.removeItem("nostr_privkey_encrypted"),localStorage.removeItem("nostr_privkey"),localStorage.removeItem("nostr_pubkey"),localStorage.removeItem("nostr_auth_method"),n(14,E=!1),n(15,C=""),n(6,u=""),n(10,p=""),n(11,g="")},B,async function(){n(7,d=!0),n(9,h=!0),b(),n(10,p=""),n(11,g="");try{if(!u)throw new Error("Please enter your password");const e=localStorage.getItem("nostr_privkey_encrypted");if(!e)throw new Error("No encrypted key found");const t=await async function(e,t){const n=new Uint8Array(atob(e).split("").map(e=>e.charCodeAt(0)));if(n.length<60)throw new Error("Invalid encrypted data - too short");const r=n.slice(0,32),i=n.slice(32,44),o=n.slice(44),s=await Sp(t,r),a=await crypto.subtle.importKey("raw",s,{name:"AES-GCM"},!1,["decrypt"]);let l;try{l=await crypto.subtle.decrypt({name:"AES-GCM",iv:i},a,o)}catch(e){throw new Error("Decryption failed - invalid password or corrupted data")}const c=(new TextDecoder).decode(l);if(!c.startsWith("nsec1"))throw new Error("Decryption produced invalid data - not an nsec");try{if("nsec"!==bu(c).type)throw new Error("Decryption produced invalid nsec type")}catch(e){throw new Error("Decryption produced invalid nsec - bech32 checksum failed")}return c}(e,u);I(),n(9,h=!1);const i=Sf.fromKey(t),o=await i.getPublicKey();r("login",{method:"nsec",pubkey:o,privateKey:t,signer:i}),B()}catch(e){I(),e.message.includes("decrypt")||e.message.includes("tag")?n(10,p="Invalid password"):n(10,p=e.message)}finally{n(7,d=!1),n(9,h=!1),I()}},S,async function(){n(8,f=!0),n(10,p=""),n(11,g="");try{const e=nu(),t=Eu("nsec",e),r=Iu(ru(e));m=t,n(12,y=r),n(3,a=t),n(11,g="New key generated! Set an encryption password below to secure it.")}catch(e){n(10,p="Failed to generate key: "+e.message)}finally{n(8,f=!1)}},async function(){n(7,d=!0),n(10,p=""),n(11,g="");try{if(!window.nostr)throw new Error("No Nostr extension found. Please install a NIP-07 compatible extension like nos2x or Alby.");const e=await window.nostr.getPublicKey();e&&(localStorage.setItem("nostr_auth_method","extension"),localStorage.setItem("nostr_pubkey",e),n(11,g="Successfully logged in with extension!"),r("login",{method:"extension",pubkey:e,signer:window.nostr}),setTimeout(()=>{B()},1500))}catch(e){n(10,p=e.message)}finally{n(7,d=!1)}},F,function(e){"Escape"===e.key&&B(),"Enter"===e.key&&"nsec"===s&&F()},function(t){T.call(this,e,t)},function(t){T.call(this,e,t)},()=>S("extension"),()=>S("nsec"),function(){u=this.value,n(6,u)},function(){a=this.value,n(3,a)},function(){l=this.value,n(4,l)},function(){c=this.value,n(5,c)},e=>"Escape"===e.key&&B()]}class Yp extends ce{constructor(e){super(),le(this,e,Vp,Jp,o,{showModal:0,isDarkTheme:1},null,[-1,-1])}}function zp(e,t,n){const r=e.slice();return r[72]=t[n],r}function Wp(e,t,n){const r=e.slice();return r[75]=t[n],r}function Zp(e,t,n){const r=e.slice();return r[72]=t[n],r}function Xp(e,t,n){const r=e.slice();return r[72]=t[n],r}function eg(e,t,n){const r=e.slice();return r[72]=t[n],r}function tg(e,t,n){const r=e.slice();return r[72]=t[n],r}function ng(e,t,n){const r=e.slice();return r[72]=t[n],r}function rg(e){let t,n,r;return{c(){t=g("div"),n=y(e[3]),k(t,"class",r="message "+e[4]+" svelte-1y8wjwc")},m(e,r){f(e,t,r),d(t,n)},p(e,i){8&i[0]&&E(n,e[3]),16&i[0]&&r!==(r="message "+e[4]+" svelte-1y8wjwc")&&k(t,"class",r)},d(e){e&&h(t)}}}function ig(e){let t,n,i,o,s,a,l,c,u,p,m,v,b,I,E,x,B,S,F,Q,D,R,$,P,U,T,N,L;function O(e,t){return e[5]&&e[5].length>0?sg:og}let M=O(e),_=M(e);function H(e,t){return e[8]&&e[8].length>0?ug:cg}let j=H(e),G=j(e);return{c(){t=g("div"),n=g("div"),i=g("h3"),i.textContent="Banned Pubkeys",o=w(),s=g("div"),a=g("input"),l=w(),c=g("input"),u=w(),p=g("button"),m=y("Ban Pubkey"),v=w(),b=g("div"),_.c(),I=w(),E=g("div"),x=g("h3"),x.textContent="Allowed Pubkeys",B=w(),S=g("div"),F=g("input"),Q=w(),D=g("input"),R=w(),$=g("button"),P=y("Allow Pubkey"),U=w(),T=g("div"),G.c(),k(i,"class","svelte-1y8wjwc"),k(a,"type","text"),k(a,"placeholder","Pubkey (64 hex chars)"),k(a,"class","svelte-1y8wjwc"),k(c,"type","text"),k(c,"placeholder","Reason (optional)"),k(c,"class","svelte-1y8wjwc"),p.disabled=e[2],k(p,"class","svelte-1y8wjwc"),k(s,"class","add-form svelte-1y8wjwc"),k(b,"class","list svelte-1y8wjwc"),k(n,"class","section svelte-1y8wjwc"),k(x,"class","svelte-1y8wjwc"),k(F,"type","text"),k(F,"placeholder","Pubkey (64 hex chars)"),k(F,"class","svelte-1y8wjwc"),k(D,"type","text"),k(D,"placeholder","Reason (optional)"),k(D,"class","svelte-1y8wjwc"),$.disabled=e[2],k($,"class","svelte-1y8wjwc"),k(S,"class","add-form svelte-1y8wjwc"),k(T,"class","list svelte-1y8wjwc"),k(E,"class","section svelte-1y8wjwc"),k(t,"class","pubkeys-section")},m(r,h){f(r,t,h),d(t,n),d(n,i),d(n,o),d(n,s),d(s,a),C(a,e[6]),d(s,l),d(s,c),C(c,e[7]),d(s,u),d(s,p),d(p,m),d(n,v),d(n,b),_.m(b,null),d(t,I),d(t,E),d(E,x),d(E,B),d(E,S),d(S,F),C(F,e[9]),d(S,Q),d(S,D),C(D,e[10]),d(S,R),d(S,$),d($,P),d(E,U),d(E,T),G.m(T,null),N||(L=[A(a,"input",e[43]),A(c,"input",e[44]),A(p,"click",e[25]),A(F,"input",e[45]),A(D,"input",e[46]),A($,"click",e[26])],N=!0)},p(e,t){64&t[0]&&a.value!==e[6]&&C(a,e[6]),128&t[0]&&c.value!==e[7]&&C(c,e[7]),4&t[0]&&(p.disabled=e[2]),M===(M=O(e))&&_?_.p(e,t):(_.d(1),_=M(e),_&&(_.c(),_.m(b,null))),512&t[0]&&F.value!==e[9]&&C(F,e[9]),1024&t[0]&&D.value!==e[10]&&C(D,e[10]),4&t[0]&&($.disabled=e[2]),j===(j=H(e))&&G?G.p(e,t):(G.d(1),G=j(e),G&&(G.c(),G.m(T,null)))},d(e){e&&h(t),_.d(),G.d(),N=!1,r(L)}}}function og(t){let n;return{c(){n=g("div"),n.innerHTML="

    No banned pubkeys configured.

    ",k(n,"class","no-items svelte-1y8wjwc")},m(e,t){f(e,n,t)},p:e,d(e){e&&h(n)}}}function sg(e){let t,n=e[5],r=[];for(let t=0;tNo allowed pubkeys configured.

    ",k(n,"class","no-items svelte-1y8wjwc")},m(e,t){f(e,n,t)},p:e,d(e){e&&h(n)}}}function ug(e){let t,n=e[8],r=[];for(let t=0;t0?gg:pg}let M=O(e),_=M(e);let H=function(e){return e[22]&&e[22].length>0?vg:wg}(e),j=H(e);return{c(){t=g("div"),n=g("div"),i=g("h3"),i.textContent="Banned Events",o=w(),s=g("div"),a=g("input"),l=w(),c=g("input"),u=w(),p=g("button"),m=y("Ban Event"),v=w(),b=g("div"),_.c(),I=w(),E=g("div"),x=g("h3"),x.textContent="Allowed Events",B=w(),S=g("div"),F=g("input"),Q=w(),D=g("input"),R=w(),$=g("button"),P=y("Allow Event"),U=w(),T=g("div"),j.c(),k(i,"class","svelte-1y8wjwc"),k(a,"type","text"),k(a,"placeholder","Event ID (64 hex chars)"),k(a,"class","svelte-1y8wjwc"),k(c,"type","text"),k(c,"placeholder","Reason (optional)"),k(c,"class","svelte-1y8wjwc"),p.disabled=e[2],k(p,"class","svelte-1y8wjwc"),k(s,"class","add-form svelte-1y8wjwc"),k(b,"class","list svelte-1y8wjwc"),k(n,"class","section svelte-1y8wjwc"),k(x,"class","svelte-1y8wjwc"),k(F,"type","text"),k(F,"placeholder","Event ID (64 hex chars)"),k(F,"class","svelte-1y8wjwc"),k(D,"type","text"),k(D,"placeholder","Reason (optional)"),k(D,"class","svelte-1y8wjwc"),$.disabled=e[2],k($,"class","svelte-1y8wjwc"),k(S,"class","add-form svelte-1y8wjwc"),k(T,"class","list svelte-1y8wjwc"),k(E,"class","section svelte-1y8wjwc"),k(t,"class","events-section")},m(r,h){f(r,t,h),d(t,n),d(n,i),d(n,o),d(n,s),d(s,a),C(a,e[12]),d(s,l),d(s,c),C(c,e[13]),d(s,u),d(s,p),d(p,m),d(n,v),d(n,b),_.m(b,null),d(t,I),d(t,E),d(E,x),d(E,B),d(E,S),d(S,F),C(F,e[14]),d(S,Q),d(S,D),C(D,e[15]),d(S,R),d(S,$),d($,P),d(E,U),d(E,T),j.m(T,null),N||(L=[A(a,"input",e[47]),A(c,"input",e[48]),A(p,"click",e[27]),A(F,"input",e[49]),A(D,"input",e[50]),A($,"click",e[28])],N=!0)},p(e,t){4096&t[0]&&a.value!==e[12]&&C(a,e[12]),8192&t[0]&&c.value!==e[13]&&C(c,e[13]),4&t[0]&&(p.disabled=e[2]),M===(M=O(e))&&_?_.p(e,t):(_.d(1),_=M(e),_&&(_.c(),_.m(b,null))),16384&t[0]&&F.value!==e[14]&&C(F,e[14]),32768&t[0]&&D.value!==e[15]&&C(D,e[15]),4&t[0]&&($.disabled=e[2]),j.p(e,t)},d(e){e&&h(t),_.d(),j.d(),N=!1,r(L)}}}function pg(t){let n;return{c(){n=g("div"),n.innerHTML="

    No banned events configured.

    ",k(n,"class","no-items svelte-1y8wjwc")},m(e,t){f(e,n,t)},p:e,d(e){e&&h(n)}}}function gg(e){let t,n=e[11],r=[];for(let t=0;tNo allowed events configured.

    ",k(n,"class","no-items svelte-1y8wjwc")},m(e,t){f(e,n,t)},p:e,d(e){e&&h(n)}}}function vg(e){let t,n=e[22],r=[];for(let t=0;t0?Ig:kg}let B=x(e),S=B(e);return{c(){t=g("div"),n=g("div"),i=g("h3"),i.textContent="Blocked IPs",o=w(),s=g("div"),a=g("input"),l=w(),c=g("input"),u=w(),p=g("button"),m=y("Block IP"),v=w(),b=g("div"),S.c(),k(i,"class","svelte-1y8wjwc"),k(a,"type","text"),k(a,"placeholder","IP Address"),k(a,"class","svelte-1y8wjwc"),k(c,"type","text"),k(c,"placeholder","Reason (optional)"),k(c,"class","svelte-1y8wjwc"),p.disabled=e[2],k(p,"class","svelte-1y8wjwc"),k(s,"class","add-form svelte-1y8wjwc"),k(b,"class","list svelte-1y8wjwc"),k(n,"class","section svelte-1y8wjwc"),k(t,"class","ips-section")},m(r,h){f(r,t,h),d(t,n),d(n,i),d(n,o),d(n,s),d(s,a),C(a,e[17]),d(s,l),d(s,c),C(c,e[18]),d(s,u),d(s,p),d(p,m),d(n,v),d(n,b),S.m(b,null),I||(E=[A(a,"input",e[51]),A(c,"input",e[52]),A(p,"click",e[29])],I=!0)},p(e,t){131072&t[0]&&a.value!==e[17]&&C(a,e[17]),262144&t[0]&&c.value!==e[18]&&C(c,e[18]),4&t[0]&&(p.disabled=e[2]),B===(B=x(e))&&S?S.p(e,t):(S.d(1),S=B(e),S&&(S.c(),S.m(b,null)))},d(e){e&&h(t),S.d(),I=!1,r(E)}}}function kg(t){let n;return{c(){n=g("div"),n.innerHTML="

    No blocked IPs configured.

    ",k(n,"class","no-items svelte-1y8wjwc")},m(e,t){f(e,n,t)},p:e,d(e){e&&h(n)}}}function Ig(e){let t,n=e[16],r=[];for(let t=0;t0?Sg:Bg}let x=E(e),B=x(e);return{c(){t=g("div"),n=g("div"),i=g("h3"),i.textContent="Allowed Event Kinds",o=w(),s=g("div"),a=g("input"),l=w(),c=g("button"),u=y("Allow Kind"),p=w(),m=g("div"),B.c(),k(i,"class","svelte-1y8wjwc"),k(a,"type","number"),k(a,"placeholder","Kind number"),k(a,"class","svelte-1y8wjwc"),c.disabled=e[2],k(c,"class","svelte-1y8wjwc"),k(s,"class","add-form svelte-1y8wjwc"),k(m,"class","list svelte-1y8wjwc"),k(n,"class","section svelte-1y8wjwc"),k(t,"class","kinds-section")},m(r,h){f(r,t,h),d(t,n),d(n,i),d(n,o),d(n,s),d(s,a),C(a,e[20]),d(s,l),d(s,c),d(c,u),d(n,p),d(n,m),B.m(m,null),v||(b=[A(a,"input",e[53]),A(c,"click",e[30])],v=!0)},p(e,t){1048576&t[0]&&I(a.value)!==e[20]&&C(a,e[20]),4&t[0]&&(c.disabled=e[2]),x===(x=E(e))&&B?B.p(e,t):(B.d(1),B=x(e),B&&(B.c(),B.m(m,null)))},d(e){e&&h(t),B.d(),v=!1,r(b)}}}function Bg(t){let n;return{c(){n=g("div"),n.innerHTML="

    No allowed kinds configured. All kinds are\n allowed by default.

    ",k(n,"class","no-items svelte-1y8wjwc")},m(e,t){f(e,n,t)},p:e,d(e){e&&h(n)}}}function Sg(e){let t,n=e[19],r=[];for(let t=0;t0?Rg:Dg}let m=p(e),v=m(e);return{c(){t=g("div"),n=g("div"),r=g("h3"),r.textContent="Events Needing Moderation",i=w(),o=g("button"),s=y("Refresh"),a=w(),l=g("div"),v.c(),k(r,"class","svelte-1y8wjwc"),o.disabled=e[2],k(l,"class","list svelte-1y8wjwc"),k(n,"class","section svelte-1y8wjwc"),k(t,"class","moderation-section")},m(h,p){f(h,t,p),d(t,n),d(n,r),d(n,i),d(n,o),d(o,s),d(n,a),d(n,l),v.m(l,null),c||(u=A(o,"click",e[24]),c=!0)},p(e,t){4&t[0]&&(o.disabled=e[2]),m===(m=p(e))&&v?v.p(e,t):(v.d(1),v=m(e),v&&(v.c(),v.m(l,null)))},d(e){e&&h(t),v.d(),c=!1,u()}}}function Dg(t){let n;return{c(){n=g("div"),n.innerHTML="

    No events need moderation at this time.

    ",k(n,"class","no-items svelte-1y8wjwc")},m(e,t){f(e,n,t)},p:e,d(e){e&&h(n)}}}function Rg(e){let t,n=e[21],r=[];for(let t=0;tManaged ACL Configuration \n

    Configure access control using NIP-86 management API

    \n
    Owner Only: This interface is restricted to relay owners\n only.
    ',o=w(),V&&V.c(),s=w(),a=g("div"),l=g("button"),c=y("Pubkeys"),p=w(),m=g("button"),v=y("Events"),I=w(),E=g("button"),C=y("IPs"),B=w(),S=g("button"),F=y("Kinds"),D=w(),R=g("button"),$=y("Moderation"),U=w(),T=g("button"),N=y("Relay Config"),O=w(),M=g("div"),Y&&Y.c(),_=w(),z&&z.c(),H=w(),W&&W.c(),j=w(),Z&&Z.c(),G=w(),X&&X.c(),q=w(),ee&&ee.c(),k(i,"class","header svelte-1y8wjwc"),k(l,"class",u="tab "+("pubkeys"===t[1]?"active":"")+" svelte-1y8wjwc"),k(m,"class",b="tab "+("events"===t[1]?"active":"")+" svelte-1y8wjwc"),k(E,"class",x="tab "+("ips"===t[1]?"active":"")+" svelte-1y8wjwc"),k(S,"class",Q="tab "+("kinds"===t[1]?"active":"")+" svelte-1y8wjwc"),k(R,"class",P="tab "+("moderation"===t[1]?"active":"")+" svelte-1y8wjwc"),k(T,"class",L="tab "+("relay"===t[1]?"active":"")+" svelte-1y8wjwc"),k(a,"class","tabs svelte-1y8wjwc"),k(M,"class","tab-content svelte-1y8wjwc")},m(e,r){f(e,n,r),d(n,i),d(n,o),V&&V.m(n,null),d(n,s),d(n,a),d(a,l),d(l,c),d(a,p),d(a,m),d(m,v),d(a,I),d(a,E),d(E,C),d(a,B),d(a,S),d(S,F),d(a,D),d(a,R),d(R,$),d(a,U),d(a,T),d(T,N),d(n,O),d(n,M),Y&&Y.m(M,null),d(M,_),z&&z.m(M,null),d(M,H),W&&W.m(M,null),d(M,j),Z&&Z.m(M,null),d(M,G),X&&X.m(M,null),d(M,q),ee&&ee.m(M,null),K||(J=[A(l,"click",t[37]),A(m,"click",t[38]),A(E,"click",t[39]),A(S,"click",t[40]),A(R,"click",t[41]),A(T,"click",t[42])],K=!0)},p(e,t){e[3]?V?V.p(e,t):(V=rg(e),V.c(),V.m(n,s)):V&&(V.d(1),V=null),2&t[0]&&u!==(u="tab "+("pubkeys"===e[1]?"active":"")+" svelte-1y8wjwc")&&k(l,"class",u),2&t[0]&&b!==(b="tab "+("events"===e[1]?"active":"")+" svelte-1y8wjwc")&&k(m,"class",b),2&t[0]&&x!==(x="tab "+("ips"===e[1]?"active":"")+" svelte-1y8wjwc")&&k(E,"class",x),2&t[0]&&Q!==(Q="tab "+("kinds"===e[1]?"active":"")+" svelte-1y8wjwc")&&k(S,"class",Q),2&t[0]&&P!==(P="tab "+("moderation"===e[1]?"active":"")+" svelte-1y8wjwc")&&k(R,"class",P),2&t[0]&&L!==(L="tab "+("relay"===e[1]?"active":"")+" svelte-1y8wjwc")&&k(T,"class",L),"pubkeys"===e[1]?Y?Y.p(e,t):(Y=ig(e),Y.c(),Y.m(M,_)):Y&&(Y.d(1),Y=null),"events"===e[1]?z?z.p(e,t):(z=hg(e),z.c(),z.m(M,H)):z&&(z.d(1),z=null),"ips"===e[1]?W?W.p(e,t):(W=bg(e),W.c(),W.m(M,j)):W&&(W.d(1),W=null),"kinds"===e[1]?Z?Z.p(e,t):(Z=xg(e),Z.c(),Z.m(M,G)):Z&&(Z.d(1),Z=null),"moderation"===e[1]?X?X.p(e,t):(X=Qg(e),X.c(),X.m(M,q)):X&&(X.d(1),X=null),"relay"===e[1]?ee?ee.p(e,t):(ee=Ug(e),ee.c(),ee.m(M,null)):ee&&(ee.d(1),ee=null)},i:e,o:e,d(e){e&&h(n),V&&V.d(),Y&&Y.d(),z&&z.d(),W&&W.d(),Z&&Z.d(),X&&X.d(),ee&&ee.d(),K=!1,r(J)}}}function Og(e,t,n){let{userSigner:r}=t,{userPubkey:i}=t,o="pubkeys",s=!1,a="",l="info",c=[],u="",d="",f=[],h="",p="",g=[],m="",y="",w="",v="",A=[],b="",k="",E=[],C="",x=[],B={relay_name:"",relay_description:"",relay_icon:""};async function S(){try{n(2,s=!0),console.log("Fetching relay info from /");const e=await fetch(window.location.origin+"/",{headers:{Accept:"application/nostr+json"}});if(console.log("Response status:",e.status),console.log("Response headers:",e.headers),e.ok){const t=await e.json();console.log("Raw relay info:",t),n(0,B={relay_name:t.name||"",relay_description:t.description||"",relay_icon:t.icon||""}),console.log("Updated relayConfig:",B),console.log("Loaded relay info:",t),n(3,a="Relay configuration loaded successfully"),n(4,l="success")}else console.error("Failed to fetch relay info, status:",e.status),n(3,a=`Failed to fetch relay info: ${e.status}`),n(4,l="error")}catch(e){console.error("Failed to fetch relay info:",e),n(3,a=`Failed to fetch relay info: ${e.message}`),n(4,l="error")}finally{n(2,s=!1)}}async function F(e,t=[]){try{n(2,s=!0),n(3,a="");const o={method:e,params:t},l=await async function(e,t){if(!r)throw new Error("No signer available for authentication. Please log in with a Nostr extension.");if(!i)throw new Error("No user pubkey available for authentication.");const n=window.location.origin+t,o={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",n],["method",e]],content:"",pubkey:i},s=await r.signEvent(o),a=JSON.stringify(s);return`Nostr ${btoa(a)}`}("POST","/api/nip86"),c=await fetch("/api/nip86",{method:"POST",headers:{"Content-Type":"application/nostr+json+rpc",Authorization:l},body:JSON.stringify(o)});if(!c.ok)throw new Error(`HTTP ${c.status}: ${c.statusText}`);const u=await c.json();if(u.error)throw new Error(u.error);return u.result}catch(e){throw console.error("NIP-86 API error:",e),n(3,a=e.message),n(4,l="error"),e}finally{n(2,s=!1)}}async function Q(){try{n(5,c=await F("listbannedpubkeys"))}catch(e){console.error("Failed to load banned pubkeys:",e)}}async function D(){try{n(8,f=await F("listallowedpubkeys"))}catch(e){console.error("Failed to load allowed pubkeys:",e)}}async function R(){try{n(11,g=await F("listbannedevents"))}catch(e){console.error("Failed to load banned events:",e)}}async function P(){try{n(16,A=await F("listblockedips"))}catch(e){console.error("Failed to load blocked IPs:",e)}}async function U(){try{n(19,E=await F("listallowedkinds"))}catch(e){console.error("Failed to load allowed kinds:",e)}}async function T(){try{n(2,s=!0),n(21,x=await F("listeventsneedingmoderation")),console.log("Loaded events needing moderation:",x)}catch(e){console.error("Failed to load events needing moderation:",e),n(3,a=`Failed to load moderation events: ${e.message}`),n(4,l="error"),n(21,x=[])}finally{n(2,s=!1)}}async function N(e){try{await F("disallowkind",[e]),n(3,a="Kind disallowed successfully"),n(4,l="success"),await U()}catch(e){console.error("Failed to disallow kind:",e)}}async function L(e){try{await F("allowevent",[e,"Approved from moderation queue"]),n(3,a="Event allowed successfully"),n(4,l="success"),await T()}catch(e){console.error("Failed to allow event from moderation:",e)}}async function O(e){try{await F("banevent",[e,"Banned from moderation queue"]),n(3,a="Event banned successfully"),n(4,l="success"),await T()}catch(e){console.error("Failed to ban event from moderation:",e)}}$(()=>{setTimeout(()=>{S()},100)}),async function(){await Promise.all([Q(),D(),R(),P(),U()])}();return e.$$set=e=>{"userSigner"in e&&n(35,r=e.userSigner),"userPubkey"in e&&n(36,i=e.userPubkey)},e.$$.update=()=>{1&e.$$.dirty[0]&&console.log("relayConfig changed:",B)},[B,o,s,a,l,c,u,d,f,h,p,g,m,y,w,v,A,b,k,E,C,x,[],S,T,async function(){if(u)try{await F("banpubkey",[u,d]),n(3,a="Pubkey banned successfully"),n(4,l="success"),n(6,u=""),n(7,d=""),await Q()}catch(e){console.error("Failed to ban pubkey:",e)}},async function(){if(h)try{await F("allowpubkey",[h,p]),n(3,a="Pubkey allowed successfully"),n(4,l="success"),n(9,h=""),n(10,p=""),await D()}catch(e){console.error("Failed to allow pubkey:",e)}},async function(){if(m)try{await F("banevent",[m,y]),n(3,a="Event banned successfully"),n(4,l="success"),n(12,m=""),n(13,y=""),await R()}catch(e){console.error("Failed to ban event:",e)}},async function(){if(w)try{await F("allowevent",[w,v]),n(3,a="Event allowed successfully"),n(4,l="success"),n(14,w=""),n(15,v="")}catch(e){console.error("Failed to allow event:",e)}},async function(){if(b)try{await F("blockip",[b,k]),n(3,a="IP blocked successfully"),n(4,l="success"),n(17,b=""),n(18,k=""),await P()}catch(e){console.error("Failed to block IP:",e)}},async function(){if(!C)return;const e=parseInt(C);if(isNaN(e))return n(3,a="Invalid kind number"),void n(4,l="error");try{await F("allowkind",[e]),n(3,a="Kind allowed successfully"),n(4,l="success"),n(20,C=""),await U()}catch(e){console.error("Failed to allow kind:",e)}},N,async function(){try{n(2,s=!0),n(3,a="");const e=[];if(B.relay_name&&e.push(F("changerelayname",[B.relay_name])),B.relay_description&&e.push(F("changerelaydescription",[B.relay_description])),B.relay_icon&&e.push(F("changerelayicon",[B.relay_icon])),0===e.length)return n(3,a="No changes to update"),void n(4,l="info");await Promise.all(e),n(3,a="Relay configuration updated successfully"),n(4,l="success"),await S()}catch(e){console.error("Failed to update relay configuration:",e),n(3,a=`Failed to update relay configuration: ${e.message}`),n(4,l="error")}finally{n(2,s=!1)}},L,O,r,i,()=>n(1,o="pubkeys"),()=>n(1,o="events"),()=>n(1,o="ips"),()=>n(1,o="kinds"),()=>{n(1,o="moderation"),x&&0!==x.length||T()},()=>n(1,o="relay"),function(){u=this.value,n(6,u)},function(){d=this.value,n(7,d)},function(){h=this.value,n(9,h)},function(){p=this.value,n(10,p)},function(){m=this.value,n(12,m)},function(){y=this.value,n(13,y)},function(){w=this.value,n(14,w)},function(){v=this.value,n(15,v)},function(){b=this.value,n(17,b)},function(){k=this.value,n(18,k)},function(){C=I(this.value),n(20,C)},e=>N(e),e=>L(e.id),e=>O(e.id),function(){B.relay_name=this.value,n(0,B)},function(){B.relay_description=this.value,n(0,B)},function(){B.relay_icon=this.value,n(0,B)}]}class Mg extends ce{constructor(e){super(),le(this,e,Og,Lg,o,{userSigner:35,userPubkey:36},null,[-1,-1,-1])}}function _g(e){let t,n;return{c(){t=g("span"),n=y(e[3]),k(t,"class","permission-badge svelte-1qkhxam")},m(e,r){f(e,t,r),d(t,n)},p(e,t){8&t&&E(n,e[3])},d(e){e&&h(t)}}}function Hg(t){let n,r,i;return{c(){n=g("button"),n.textContent="Log in",k(n,"class","login-btn svelte-1qkhxam")},m(e,o){f(e,n,o),r||(i=A(n,"click",t[7]),r=!0)},p:e,d(e){e&&h(n),r=!1,i()}}}function jg(e){let t,n,r,i,o,s,a=(e[4]?.name||e[5])+"";function l(e,t){return e[4]?.picture?qg:Gg}let c=l(e),u=c(e);return{c(){t=g("button"),u.c(),n=w(),r=g("span"),i=y(a),k(r,"class","user-name svelte-1qkhxam"),k(t,"class","user-profile-btn svelte-1qkhxam")},m(a,l){f(a,t,l),u.m(t,null),d(t,n),d(t,r),d(r,i),o||(s=A(t,"click",e[6]),o=!0)},p(e,r){c===(c=l(e))&&u?u.p(e,r):(u.d(1),u=c(e),u&&(u.c(),u.m(t,n))),48&r&&a!==(a=(e[4]?.name||e[5])+"")&&E(i,a)},d(e){e&&h(t),u.d(),o=!1,s()}}}function Gg(t){let n;return{c(){n=g("div"),n.textContent="👤",k(n,"class","user-avatar-placeholder svelte-1qkhxam")},m(e,t){f(e,n,t)},p:e,d(e){e&&h(n)}}}function qg(e){let t,n;return{c(){t=g("img"),a(t.src,n=e[4].picture)||k(t,"src",n),k(t,"alt","User avatar"),k(t,"class","user-avatar svelte-1qkhxam")},m(e,n){f(e,t,n)},p(e,r){16&r&&!a(t.src,n=e[4].picture)&&k(t,"src",n)},d(e){e&&h(t)}}}function Kg(t){let n,r,i,o,s,l,c,u,p,m,v=t[1]&&t[2]&&_g(t);function A(e,t){return e[1]?jg:Hg}let b=A(t),I=b(t);return{c(){n=g("header"),r=g("div"),i=g("img"),s=w(),l=g("div"),c=g("span"),u=y("ORLY? dashboard\n "),v&&v.c(),p=w(),m=g("div"),I.c(),a(i.src,o="/orly.png")||k(i,"src","/orly.png"),k(i,"alt","ORLY Logo"),k(i,"class","logo svelte-1qkhxam"),k(c,"class","app-title svelte-1qkhxam"),k(l,"class","header-title svelte-1qkhxam"),k(m,"class","header-buttons svelte-1qkhxam"),k(r,"class","header-content svelte-1qkhxam"),k(n,"class","main-header svelte-1qkhxam"),F(n,"dark-theme",t[0])},m(e,t){f(e,n,t),d(n,r),d(r,i),d(r,s),d(r,l),d(l,c),d(c,u),v&&v.m(c,null),d(r,p),d(r,m),I.m(m,null)},p(e,[t]){e[1]&&e[2]?v?v.p(e,t):(v=_g(e),v.c(),v.m(c,null)):v&&(v.d(1),v=null),b===(b=A(e))&&I?I.p(e,t):(I.d(1),I=b(e),I&&(I.c(),I.m(m,null))),1&t&&F(n,"dark-theme",e[0])},i:e,o:e,d(e){e&&h(n),v&&v.d(),I.d()}}}function Jg(e,t,n){let{isDarkTheme:r=!1}=t,{isLoggedIn:i=!1}=t,{userRole:o=""}=t,{currentEffectiveRole:s=""}=t,{userProfile:a=null}=t,{userPubkey:l=""}=t;const c=U();return e.$$set=e=>{"isDarkTheme"in e&&n(0,r=e.isDarkTheme),"isLoggedIn"in e&&n(1,i=e.isLoggedIn),"userRole"in e&&n(2,o=e.userRole),"currentEffectiveRole"in e&&n(3,s=e.currentEffectiveRole),"userProfile"in e&&n(4,a=e.userProfile),"userPubkey"in e&&n(5,l=e.userPubkey)},[r,i,o,s,a,l,function(){c("openSettingsDrawer")},function(){c("openLoginModal")}]}class Vg extends ce{constructor(e){super(),le(this,e,Jg,Kg,o,{isDarkTheme:0,isLoggedIn:1,userRole:2,currentEffectiveRole:3,userProfile:4,userPubkey:5})}}function Yg(e,t,n){const r=e.slice();return r[10]=t[n],r}function zg(e){let t,n,i;function o(){return e[6](e[10])}function s(...t){return e[7](e[10],...t)}return{c(){t=g("span"),t.textContent="✕",k(t,"class","tab-close-icon svelte-wfmuj"),k(t,"role","button"),k(t,"tabindex","0")},m(e,r){f(e,t,r),n||(i=[A(t,"click",b(o)),A(t,"keydown",s)],n=!0)},p(t,n){e=t},d(e){e&&h(t),n=!1,r(i)}}}function Wg(e){let t,n,r,i,o,s,a,l,c,u,p=e[10].icon+"",m=e[10].label+"",v=e[10].isSearchTab&&zg(e);function b(){return e[8](e[10])}return{c(){t=g("button"),n=g("span"),r=y(p),i=w(),o=g("span"),s=y(m),a=w(),v&&v.c(),l=w(),k(n,"class","tab-icon svelte-wfmuj"),k(o,"class","tab-label svelte-wfmuj"),k(t,"class","tab svelte-wfmuj"),F(t,"active",e[2]===e[10].id)},m(e,h){f(e,t,h),d(t,n),d(n,r),d(t,i),d(t,o),d(o,s),d(t,a),v&&v.m(t,null),d(t,l),c||(u=A(t,"click",b),c=!0)},p(n,i){e=n,2&i&&p!==(p=e[10].icon+"")&&E(r,p),2&i&&m!==(m=e[10].label+"")&&E(s,m),e[10].isSearchTab?v?v.p(e,i):(v=zg(e),v.c(),v.m(t,l)):v&&(v.d(1),v=null),6&i&&F(t,"active",e[2]===e[10].id)},d(e){e&&h(t),v&&v.d(),c=!1,u()}}}function Zg(e){let t,n,r,i,o,s,a,l;return{c(){t=g("a"),n=m("svg"),r=m("path"),i=m("path"),o=w(),s=g("span"),a=y("v"),l=y(e[3]),k(r,"d","M5 6h12v2h1.5c1.38 0 2.5 1.12 2.5 2.5v1c0 1.38-1.12 2.5-2.5 2.5H17v1c0 1.66-1.34 3-3 3H8c-1.66 0-3-1.34-3-3V6zm12 6h1.5c.28 0 .5-.22.5-.5v-1c0-.28-.22-.5-.5-.5H17v2z"),k(i,"d","M9 9c1.5 0 3 .5 3 2.5S10.5 14 9 14c0-1.5.5-3.5 2-4.5"),k(i,"stroke","currentColor"),k(i,"stroke-width","1"),k(i,"fill","none"),k(n,"class","version-icon svelte-wfmuj"),k(n,"viewBox","0 0 24 24"),k(n,"fill","currentColor"),k(n,"xmlns","http://www.w3.org/2000/svg"),k(s,"class","version-text svelte-wfmuj"),k(t,"href","https://next.orly.dev"),k(t,"target","_blank"),k(t,"rel","noopener noreferrer"),k(t,"class","version-link svelte-wfmuj")},m(e,c){f(e,t,c),d(t,n),d(n,r),d(n,i),d(t,o),d(t,s),d(s,a),d(s,l)},p(e,t){8&t&&E(l,e[3])},d(e){e&&h(t)}}}function Xg(t){let n,r,i,o,s=t[1],a=[];for(let e=0;e{"isDarkTheme"in e&&n(0,r=e.isDarkTheme),"tabs"in e&&n(1,i=e.tabs),"selectedTab"in e&&n(2,o=e.selectedTab),"version"in e&&n(3,s=e.version)},[r,i,o,s,l,c,e=>c(e.id),(e,t)=>"Enter"===t.key&&c(e.id),e=>l(e.id)]}class tm extends ce{constructor(e){super(),le(this,e,em,Xg,o,{isDarkTheme:0,tabs:1,selectedTab:2,version:3})}}function nm(t){let n,r,i,o,s,a;return{c(){n=g("div"),r=g("p"),r.textContent="Please log in to access export functionality.",i=w(),o=g("button"),o.textContent="Log In",k(r,"class","svelte-jzrdtj"),k(o,"class","login-btn svelte-jzrdtj"),k(n,"class","login-prompt svelte-jzrdtj")},m(e,l){f(e,n,l),d(n,r),d(n,i),d(n,o),s||(a=A(o,"click",t[5]),s=!0)},p:e,d(e){e&&h(n),s=!1,a()}}}function rm(e){let t,n,r=e[0]&&im(e),i=e[1]&&om(e);return{c(){r&&r.c(),t=w(),i&&i.c(),n=v()},m(e,o){r&&r.m(e,o),f(e,t,o),i&&i.m(e,o),f(e,n,o)},p(e,o){e[0]?r?r.p(e,o):(r=im(e),r.c(),r.m(t.parentNode,t)):r&&(r.d(1),r=null),e[1]?i?i.p(e,o):(i=om(e),i.c(),i.m(n.parentNode,n)):i&&(i.d(1),i=null)},d(e){r&&r.d(e),e&&h(t),i&&i.d(e),e&&h(n)}}}function im(t){let n,r,i,o,s,a,l,c;return{c(){n=g("div"),r=g("h3"),r.textContent="Export My Events",i=w(),o=g("p"),o.textContent="Download your personal events as a JSONL file.",s=w(),a=g("button"),a.textContent="📤 Export My Events",k(r,"class","svelte-jzrdtj"),k(o,"class","svelte-jzrdtj"),k(a,"class","export-btn svelte-jzrdtj"),k(n,"class","export-section svelte-jzrdtj")},m(e,u){f(e,n,u),d(n,r),d(n,i),d(n,o),d(n,s),d(n,a),l||(c=A(a,"click",t[3]),l=!0)},p:e,d(e){e&&h(n),l=!1,c()}}}function om(t){let n,r,i,o,s,a,l,c;return{c(){n=g("div"),r=g("h3"),r.textContent="Export All Events",i=w(),o=g("p"),o.textContent="Download the complete database as a JSONL file. This includes\n all events from all users.",s=w(),a=g("button"),a.textContent="📤 Export All Events",k(r,"class","svelte-jzrdtj"),k(o,"class","svelte-jzrdtj"),k(a,"class","export-btn svelte-jzrdtj"),k(n,"class","export-section svelte-jzrdtj")},m(e,u){f(e,n,u),d(n,r),d(n,i),d(n,o),d(n,s),d(n,a),l||(c=A(a,"click",t[4]),l=!0)},p:e,d(e){e&&h(n),l=!1,c()}}}function sm(t){let n;function r(e,t){return e[2]?rm:nm}let i=r(t),o=i(t);return{c(){o.c(),n=v()},m(e,t){o.m(e,t),f(e,n,t)},p(e,[t]){i===(i=r(e))&&o?o.p(e,t):(o.d(1),o=i(e),o&&(o.c(),o.m(n.parentNode,n)))},i:e,o:e,d(e){o.d(e),e&&h(n)}}}function am(e,t,n){let r,i,{isLoggedIn:o=!1}=t,{currentEffectiveRole:s=""}=t,{aclMode:a=""}=t;const l=U();return e.$$set=e=>{"isLoggedIn"in e&&n(0,o=e.isLoggedIn),"currentEffectiveRole"in e&&n(6,s=e.currentEffectiveRole),"aclMode"in e&&n(7,a=e.aclMode)},e.$$.update=()=>{129&e.$$.dirty&&n(2,r="none"===a||o),192&e.$$.dirty&&n(1,i="none"===a||"admin"===s||"owner"===s)},[o,i,r,function(){l("exportMyEvents")},function(){l("exportAllEvents")},function(){l("openLoginModal")},s,a]}class lm extends ce{constructor(e){super(),le(this,e,am,sm,o,{isLoggedIn:0,currentEffectiveRole:6,aclMode:7})}}function cm(t){let n,r,i,o,s,a,l,c;return{c(){n=g("div"),r=g("h3"),r.textContent="Import Events",i=w(),o=g("p"),o.textContent="Please log in to access import functionality.",s=w(),a=g("button"),a.textContent="Log In",k(r,"class","recovery-header svelte-nonyqh"),k(o,"class","recovery-description svelte-nonyqh"),k(a,"class","login-btn svelte-nonyqh"),k(n,"class","login-prompt svelte-nonyqh")},m(e,u){f(e,n,u),d(n,r),d(n,i),d(n,o),d(n,s),d(n,a),l||(c=A(a,"click",t[6]),l=!0)},p:e,d(e){e&&h(n),l=!1,c()}}}function um(t){let n;return{c(){n=g("div"),n.innerHTML='

    Import Events

    \n

    Admin or owner permission required for import functionality.

    ',k(n,"class","permission-denied svelte-nonyqh")},m(e,t){f(e,n,t)},p:e,d(e){e&&h(n)}}}function dm(e){let t,n,i,o,s,a,l,c,u,p,m,v,b,I,E=e[2]&&fm(e);return{c(){t=g("h3"),t.textContent="Import Events",n=w(),i=g("p"),i.textContent="Upload a JSONL file to import events into the database.",o=w(),s=g("div"),a=g("input"),l=w(),c=g("div"),u=g("button"),p=y("Import Events"),v=w(),E&&E.c(),k(t,"class","svelte-nonyqh"),k(i,"class","svelte-nonyqh"),k(a,"type","file"),k(a,"id","import-file"),k(a,"accept",".jsonl,.txt"),k(a,"class","svelte-nonyqh"),k(u,"class","import-btn svelte-nonyqh"),u.disabled=m=!e[1]||"Uploading..."===e[2],k(c,"class","import-row svelte-nonyqh"),k(s,"class","recovery-controls-card svelte-nonyqh")},m(r,h){f(r,t,h),f(r,n,h),f(r,i,h),f(r,o,h),f(r,s,h),d(s,a),d(s,l),d(s,c),d(c,u),d(u,p),d(c,v),E&&E.m(c,null),b||(I=[A(a,"change",e[4]),A(u,"click",e[5])],b=!0)},p(e,t){6&t&&m!==(m=!e[1]||"Uploading..."===e[2])&&(u.disabled=m),e[2]?E?E.p(e,t):(E=fm(e),E.c(),E.m(c,null)):E&&(E.d(1),E=null)},d(e){e&&h(t),e&&h(n),e&&h(i),e&&h(o),e&&h(s),E&&E.d(),b=!1,r(I)}}}function fm(e){let t,n;return{c(){t=g("span"),n=y(e[2]),k(t,"class","import-message svelte-nonyqh"),F(t,"uploading","Uploading..."===e[2]),F(t,"success","Upload complete"===e[2]),F(t,"error",e[2].startsWith("Import failed")||e[2].startsWith("Admin")||e[2].startsWith("Please"))},m(e,r){f(e,t,r),d(t,n)},p(e,r){4&r&&E(n,e[2]),4&r&&F(t,"uploading","Uploading..."===e[2]),4&r&&F(t,"success","Upload complete"===e[2]),4&r&&F(t,"error",e[2].startsWith("Import failed")||e[2].startsWith("Admin")||e[2].startsWith("Please"))},d(e){e&&h(t)}}}function hm(t){let n;function r(e,t){return e[3]?dm:e[0]?um:cm}let i=r(t),o=i(t);return{c(){n=g("div"),o.c(),k(n,"class","import-section svelte-nonyqh")},m(e,t){f(e,n,t),o.m(n,null)},p(e,[t]){i===(i=r(e))&&o?o.p(e,t):(o.d(1),o=i(e),o&&(o.c(),o.m(n,null)))},i:e,o:e,d(e){e&&h(n),o.d()}}}function pm(e,t,n){let r,{isLoggedIn:i=!1}=t,{currentEffectiveRole:o=""}=t,{selectedFile:s=null}=t,{aclMode:a=""}=t,{importMessage:l=""}=t;const c=U();return e.$$set=e=>{"isLoggedIn"in e&&n(0,i=e.isLoggedIn),"currentEffectiveRole"in e&&n(7,o=e.currentEffectiveRole),"selectedFile"in e&&n(1,s=e.selectedFile),"aclMode"in e&&n(8,a=e.aclMode),"importMessage"in e&&n(2,l=e.importMessage)},e.$$.update=()=>{385&e.$$.dirty&&n(3,r="none"===a||i&&("admin"===o||"owner"===o))},[i,s,l,r,function(e){c("fileSelect",e)},function(){c("importEvents")},function(){c("openLoginModal")},o,a]}class gm extends ce{constructor(e){super(),le(this,e,pm,hm,o,{isLoggedIn:0,currentEffectiveRole:7,selectedFile:1,aclMode:8,importMessage:2})}}const mm={0:"Profile Metadata",1:"Text Note",2:"Recommend Relay",3:"Contacts",4:"Encrypted DM",5:"Delete Request",6:"Repost",7:"Reaction",8:"Badge Award",16:"Generic Repost",40:"Channel Creation",41:"Channel Metadata",42:"Channel Message",43:"Channel Hide Message",44:"Channel Mute User",1063:"File Metadata",1311:"Live Chat Message",1984:"Reporting",1985:"Label",9734:"Zap Request",9735:"Zap Receipt",1e4:"Mute List",10001:"Pin List",10002:"Relay List Metadata",10003:"Bookmark List",10004:"Communities List",10005:"Public Chats List",10006:"Blocked Relays List",10007:"Search Relays List",10009:"User Groups",10015:"Interests List",10030:"User Emoji List",13194:"Wallet Info",22242:"Client Auth",23194:"Wallet Request",23195:"Wallet Response",24133:"Nostr Connect",27235:"HTTP Auth",3e4:"Categorized People List",30001:"Categorized Bookmarks",30002:"Categorized Relay List",30003:"Bookmark Sets",30004:"Curation Sets",30005:"Video Sets",30008:"Profile Badges",30009:"Badge Definition",30015:"Interest Sets",30017:"Create/Update Stall",30018:"Create/Update Product",30019:"Marketplace UI/UX",30020:"Product Sold As Auction",30023:"Long-form Content",30024:"Draft Long-form Content",30030:"Emoji Sets",30063:"Release Artifact Sets",30078:"Application-specific Data",30311:"Live Event",30315:"User Statuses",30388:"Slide Set",30402:"Classified Listing",30403:"Draft Classified Listing",30617:"Repository Announcement",30618:"Repository State Announcement",30818:"Wiki Article",30819:"Redirects",31922:"Date-Based Calendar Event",31923:"Time-Based Calendar Event",31924:"Calendar",31925:"Calendar Event RSVP",31989:"Handler Recommendation",31990:"Handler Information",34550:"Community Definition",34551:"Community Post Approval"};function ym(e,t=null){if(!e||"string"!=typeof e)return!1;return!!/^[0-9a-fA-F]+$/.test(e)&&(!t||e.length===t)}function wm(e){const t=new Date(1e3*e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}T${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function vm(e){return Math.floor(new Date(e).getTime()/1e3)}function Am(e,t,n){const r=e.slice();return r[62]=t[n],r[64]=n,r}function bm(e,t,n){const r=e.slice();return r[65]=t[n],r}function km(e,t,n){const r=e.slice();return r[68]=t[n],r}function Im(e,t,n){const r=e.slice();return r[71]=t[n],r}function Em(e,t,n){const r=e.slice();return r[71]=t[n].kind,r[74]=t[n].name,r}function Cm(e){let t,n,r,i,o,s,a=e[20],l=[];for(let t=0;t0&&Bm(t),Ge=t[17]&&Fm(t),qe=t[2].length>0&&Qm(t),Ke=t[18]&&Rm(t),Je=t[3].length>0&&$m(t),Ve=t[19]&&Um(t),Ye=t[4].length>0&&Tm(t),ze=t[5]&&Lm(t),We=t[6]&&Om(t),Ze=t[8]&&Mm(t);return{c(){n=g("div"),i=g("div"),o=g("div"),s=g("label"),s.textContent="Search Text (NIP-50)",a=w(),l=g("div"),c=g("input"),u=w(),p=g("label"),p.textContent="Event Kinds",m=w(),v=g("div"),b=g("button"),x=y(Me),B=y(" Select Kinds ("),S=y(_e),Q=y(" selected)"),D=w(),He&&He.c(),R=w(),je&&je.c(),$=w(),P=g("label"),P.textContent="Authors (Pubkeys)",U=w(),T=g("div"),N=g("div"),L=g("input"),O=w(),M=g("button"),M.textContent="Add",_=w(),Ge&&Ge.c(),H=w(),qe&&qe.c(),j=w(),G=g("label"),G.textContent="Event IDs",q=w(),K=g("div"),J=g("div"),V=g("input"),Y=w(),z=g("button"),z.textContent="Add",W=w(),Ke&&Ke.c(),Z=w(),Je&&Je.c(),X=w(),ee=g("label"),ee.textContent="Tags (#e, #p, #a)",te=w(),ne=g("div"),re=g("div"),ie=g("span"),ie.textContent="#",oe=w(),se=g("input"),ae=w(),le=g("input"),ce=w(),ue=g("button"),ue.textContent="Add",de=w(),Ve&&Ve.c(),fe=w(),Ye&&Ye.c(),he=w(),pe=g("label"),pe.textContent="Since",ge=w(),me=g("div"),ye=g("input"),we=w(),ze&&ze.c(),ve=w(),Ae=g("label"),Ae.textContent="Until",be=w(),ke=g("div"),Ie=g("input"),Ee=w(),We&&We.c(),Ce=w(),xe=g("label"),xe.textContent="Limit",Be=w(),Se=g("div"),Fe=g("input"),Qe=w(),Ze&&Ze.c(),De=w(),Re=g("div"),$e=g("button"),$e.textContent="🧹",Pe=w(),Ue=g("div"),Te=w(),Ne=g("button"),Ne.textContent="",k(s,"for","search-text"),k(s,"class","svelte-1a1v6k0"),k(c,"id","search-text"),k(c,"type","text"),k(c,"placeholder","Search events..."),k(c,"class","filter-input svelte-1a1v6k0"),k(l,"class","field-content svelte-1a1v6k0"),k(p,"class","svelte-1a1v6k0"),k(b,"class","picker-toggle-btn svelte-1a1v6k0"),k(v,"class","field-content svelte-1a1v6k0"),k(P,"class","svelte-1a1v6k0"),k(L,"type","text"),k(L,"placeholder","64 character hex pubkey..."),k(L,"class","filter-input svelte-1a1v6k0"),k(L,"maxlength","64"),k(M,"class","add-btn svelte-1a1v6k0"),k(N,"class","input-group svelte-1a1v6k0"),k(T,"class","field-content svelte-1a1v6k0"),k(G,"class","svelte-1a1v6k0"),k(V,"type","text"),k(V,"placeholder","64 character hex event ID..."),k(V,"class","filter-input svelte-1a1v6k0"),k(V,"maxlength","64"),k(z,"class","add-btn svelte-1a1v6k0"),k(J,"class","input-group svelte-1a1v6k0"),k(K,"class","field-content svelte-1a1v6k0"),k(ee,"class","svelte-1a1v6k0"),k(ie,"class","hash-prefix svelte-1a1v6k0"),k(se,"type","text"),k(se,"placeholder","Tag"),k(se,"class","filter-input tag-name-input svelte-1a1v6k0"),k(se,"maxlength","1"),k(le,"type","text"),k(le,"placeholder","Value..."),k(le,"class","filter-input tag-value-input svelte-1a1v6k0"),k(ue,"class","add-btn svelte-1a1v6k0"),k(re,"class","tag-input-group svelte-1a1v6k0"),k(ne,"class","field-content svelte-1a1v6k0"),k(pe,"for","since-timestamp"),k(pe,"class","svelte-1a1v6k0"),k(ye,"id","since-timestamp"),k(ye,"type","datetime-local"),ye.value=t[32](),k(ye,"class","filter-input svelte-1a1v6k0"),k(me,"class","field-content timestamp-field svelte-1a1v6k0"),k(Ae,"for","until-timestamp"),k(Ae,"class","svelte-1a1v6k0"),k(Ie,"id","until-timestamp"),k(Ie,"type","datetime-local"),Ie.value=t[33](),k(Ie,"class","filter-input svelte-1a1v6k0"),k(ke,"class","field-content timestamp-field svelte-1a1v6k0"),k(xe,"for","limit"),k(xe,"class","svelte-1a1v6k0"),k(Fe,"id","limit"),k(Fe,"type","number"),k(Fe,"placeholder","Max events to return"),k(Fe,"class","filter-input svelte-1a1v6k0"),k(Fe,"min","1"),k(Se,"class","field-content svelte-1a1v6k0"),k(o,"class","filter-grid svelte-1a1v6k0"),k(i,"class","filter-content svelte-1a1v6k0"),k($e,"class","clear-all-btn svelte-1a1v6k0"),k($e,"title","Clear all filters"),k(Ue,"class","spacer svelte-1a1v6k0"),k(Ne,"class","json-toggle-btn svelte-1a1v6k0"),k(Ne,"title","Edit filter JSON"),F(Ne,"active",t[8]),k(Re,"class","clear-column svelte-1a1v6k0"),k(n,"class","filter-builder svelte-1a1v6k0")},m(e,r){f(e,n,r),d(n,i),d(i,o),d(o,s),d(o,a),d(o,l),d(l,c),C(c,t[0]),d(o,u),d(o,p),d(o,m),d(o,v),d(v,b),d(b,x),d(b,B),d(b,S),d(b,Q),d(v,D),He&&He.m(v,null),d(v,R),je&&je.m(v,null),d(o,$),d(o,P),d(o,U),d(o,T),d(T,N),d(N,L),C(L,t[13]),d(N,O),d(N,M),d(T,_),Ge&&Ge.m(T,null),d(T,H),qe&&qe.m(T,null),d(o,j),d(o,G),d(o,q),d(o,K),d(K,J),d(J,V),C(V,t[14]),d(J,Y),d(J,z),d(K,W),Ke&&Ke.m(K,null),d(K,Z),Je&&Je.m(K,null),d(o,X),d(o,ee),d(o,te),d(o,ne),d(ne,re),d(re,ie),d(re,oe),d(re,se),C(se,t[15]),d(re,ae),d(re,le),C(le,t[16]),d(re,ce),d(re,ue),d(ne,de),Ve&&Ve.m(ne,null),d(ne,fe),Ye&&Ye.m(ne,null),d(o,he),d(o,pe),d(o,ge),d(o,me),d(me,ye),d(me,we),ze&&ze.m(me,null),d(o,ve),d(o,Ae),d(o,be),d(o,ke),d(ke,Ie),d(ke,Ee),We&&We.m(ke,null),d(o,Ce),d(o,xe),d(o,Be),d(o,Se),d(Se,Fe),C(Fe,t[7]),d(o,Qe),Ze&&Ze.m(o,null),d(n,De),d(n,Re),d(Re,$e),d(Re,Pe),d(Re,Ue),d(Re,Te),d(Re,Ne),Le||(Oe=[A(c,"input",t[38]),A(b,"click",t[39]),A(L,"input",t[43]),A(L,"keydown",t[44]),A(M,"click",t[25]),A(V,"input",t[46]),A(V,"keydown",t[47]),A(z,"click",t[27]),A(se,"input",t[49]),A(le,"input",t[50]),A(le,"keydown",t[51]),A(ue,"click",t[29]),A(ye,"change",t[34]),A(Ie,"change",t[35]),A(Fe,"input",t[55]),A($e,"click",t[31]),A(Ne,"click",t[57])],Le=!0)},p(e,t){1&t[0]&&c.value!==e[0]&&C(c,e[0]),4096&t[0]&&Me!==(Me=e[12]?"▼":"▶")&&E(x,Me),2&t[0]&&_e!==(_e=e[1].length+"")&&E(S,_e),e[12]?He?He.p(e,t):(He=Cm(e),He.c(),He.m(v,R)):He&&(He.d(1),He=null),e[1].length>0?je?je.p(e,t):(je=Bm(e),je.c(),je.m(v,null)):je&&(je.d(1),je=null),8192&t[0]&&L.value!==e[13]&&C(L,e[13]),e[17]?Ge?Ge.p(e,t):(Ge=Fm(e),Ge.c(),Ge.m(T,H)):Ge&&(Ge.d(1),Ge=null),e[2].length>0?qe?qe.p(e,t):(qe=Qm(e),qe.c(),qe.m(T,null)):qe&&(qe.d(1),qe=null),16384&t[0]&&V.value!==e[14]&&C(V,e[14]),e[18]?Ke?Ke.p(e,t):(Ke=Rm(e),Ke.c(),Ke.m(K,Z)):Ke&&(Ke.d(1),Ke=null),e[3].length>0?Je?Je.p(e,t):(Je=$m(e),Je.c(),Je.m(K,null)):Je&&(Je.d(1),Je=null),32768&t[0]&&se.value!==e[15]&&C(se,e[15]),65536&t[0]&&le.value!==e[16]&&C(le,e[16]),e[19]?Ve?Ve.p(e,t):(Ve=Um(e),Ve.c(),Ve.m(ne,fe)):Ve&&(Ve.d(1),Ve=null),e[4].length>0?Ye?Ye.p(e,t):(Ye=Tm(e),Ye.c(),Ye.m(ne,null)):Ye&&(Ye.d(1),Ye=null),e[5]?ze?ze.p(e,t):(ze=Lm(e),ze.c(),ze.m(me,null)):ze&&(ze.d(1),ze=null),e[6]?We?We.p(e,t):(We=Om(e),We.c(),We.m(ke,null)):We&&(We.d(1),We=null),128&t[0]&&I(Fe.value)!==e[7]&&C(Fe,e[7]),e[8]?Ze?Ze.p(e,t):(Ze=Mm(e),Ze.c(),Ze.m(o,null)):Ze&&(Ze.d(1),Ze=null),256&t[0]&&F(Ne,"active",e[8])},i:e,o:e,d(e){e&&h(n),He&&He.d(),je&&je.d(),Ge&&Ge.d(),qe&&qe.d(),Ke&&Ke.d(),Je&&Je.d(),Ve&&Ve.d(),Ye&&Ye.d(),ze&&ze.d(),We&&We.d(),Ze&&Ze.d(),Le=!1,r(Oe)}}}function jm(e,t,n){let r,i;const o=U();let{searchText:s=""}=t,{selectedKinds:a=[]}=t,{pubkeys:l=[]}=t,{eventIds:c=[]}=t,{tags:u=[]}=t,{sinceTimestamp:d=null}=t,{untilTimestamp:f=null}=t,{limit:h=null}=t,{showJsonEditor:p=!1}=t,g="",m="",y=!1,w="",v="",A="",b="",k="",E="",C="",x="",B=null,S=!1;function F(e){a.includes(e)?n(1,a=a.filter(t=>t!==e)):n(1,a=[...a,e].sort((e,t)=>e-t))}function Q(e){n(1,a=a.filter(t=>t!==e))}function D(){const e=v.trim();e&&(ym(e,64)?l.includes(e)?n(17,E="Pubkey already added"):(n(2,l=[...l,e]),n(13,v=""),n(17,E="")):n(17,E="Invalid pubkey: must be 64 character hex string"))}function R(e){n(2,l=l.filter(t=>t!==e))}function $(){const e=A.trim();e&&(ym(e,64)?c.includes(e)?n(18,C="Event ID already added"):(n(3,c=[...c,e]),n(14,A=""),n(18,C="")):n(18,C="Invalid event ID: must be 64 character hex string"))}function T(e){n(3,c=c.filter(t=>t!==e))}function N(){const e=b.trim(),t=k.trim();e&&t&&(/^[a-zA-Z]$/.test(e)?u.some(n=>n.name===e&&n.value===t)?n(19,x="Tag already added"):(n(4,u=[...u,{name:e,value:t}]),n(15,b=""),n(16,k=""),n(19,x="")):n(19,x="Invalid tag name: must be single letter a-z or A-Z"))}function L(e){n(4,u=u.filter((t,n)=>n!==e))}function O(){o("apply",{searchText:s,selectedKinds:a,pubkeys:l,eventIds:c,tags:u,sinceTimestamp:d,untilTimestamp:f,limit:h})}P(()=>{B&&clearTimeout(B)});return e.$$set=e=>{"searchText"in e&&n(0,s=e.searchText),"selectedKinds"in e&&n(1,a=e.selectedKinds),"pubkeys"in e&&n(2,l=e.pubkeys),"eventIds"in e&&n(3,c=e.eventIds),"tags"in e&&n(4,u=e.tags),"sinceTimestamp"in e&&n(5,d=e.sinceTimestamp),"untilTimestamp"in e&&n(6,f=e.untilTimestamp),"limit"in e&&n(7,h=e.limit),"showJsonEditor"in e&&n(8,p=e.showJsonEditor)},e.$$.update=()=>{if(256&e.$$.dirty[0]&&p){const e=function(){const e={};return a.length>0&&(e.kinds=a),l.length>0&&(e.authors=l),c.length>0&&(e.ids=c),d&&(e.since=d),f&&(e.until=f),h&&(e.limit=h),s&&(e.search=s),u.forEach(t=>{const n=`#${t.name}`;e[n]||(e[n]=[]),e[n].push(t.value)}),e}();n(10,g=JSON.stringify(e,null,2))}255&e.$$.dirty[0]|32&e.$$.dirty[1]&&(S?(B&&clearTimeout(B),B=setTimeout(()=>{O()},1e3)):n(36,S=!0)),512&e.$$.dirty[0]|64&e.$$.dirty[1]&&n(20,i=r.filter(e=>e.kind.toString().includes(w)||e.name.toLowerCase().includes(w.toLowerCase())))},n(37,r=Object.entries(mm).map(([e,t])=>({kind:parseInt(e),name:t})).sort((e,t)=>e.kind-t.kind)),[s,a,l,c,u,d,f,h,p,w,g,m,y,v,A,b,k,E,C,x,i,o,function(){try{const e=JSON.parse(g);n(11,m=""),n(1,a=e.kinds||[]),n(2,l=e.authors||[]),n(3,c=e.ids||[]),n(5,d=e.since||null),n(6,f=e.until||null),n(7,h=e.limit||null),n(0,s=e.search||""),n(4,u=[]),Object.keys(e).forEach(t=>{if(t.startsWith("#")&&2===t.length){const n=t.slice(1);(Array.isArray(e[t])?e[t]:[e[t]]).forEach(e=>{u.push({name:n,value:String(e)})})}}),n(4,u),B&&clearTimeout(B),O()}catch(e){n(11,m="Invalid JSON: "+e.message)}},F,Q,D,R,$,T,N,L,function(){n(0,s=""),n(1,a=[]),n(2,l=[]),n(3,c=[]),n(4,u=[]),n(5,d=null),n(6,f=null),n(7,h=null),o("clear")},function(){return d?wm(d):""},function(){return f?wm(f):""},function(e){const t=e.target.value;n(5,d=t?vm(t):null)},function(e){const t=e.target.value;n(6,f=t?vm(t):null)},S,r,function(){s=this.value,n(0,s)},()=>n(12,y=!y),function(){w=this.value,n(9,w)},e=>F(e),e=>Q(e),function(){v=this.value,n(13,v)},e=>"Enter"===e.key&&D(),e=>R(e),function(){A=this.value,n(14,A)},e=>"Enter"===e.key&&$(),e=>T(e),function(){b=this.value,n(15,b)},function(){k=this.value,n(16,k)},e=>"Enter"===e.key&&N(),e=>L(e),()=>n(5,d=null),()=>n(6,f=null),function(){h=I(this.value),n(7,h)},function(){g=this.value,n(10,g),n(8,p)},()=>o("toggleJson")]}class Gm extends ce{constructor(e){super(),le(this,e,jm,Hm,o,{searchText:0,selectedKinds:1,pubkeys:2,eventIds:3,tags:4,sinceTimestamp:5,untilTimestamp:6,limit:7,showJsonEditor:8},null,[-1,-1,-1])}}function qm(e,t,n){const r=e.slice();return r[28]=t[n],r}function Km(e,t,n){const r=e.slice();return r[31]=t[n],r}function Jm(t){let n;return{c(){n=g("div"),n.innerHTML="

    ❌ Read, write, admin, or owner permission required to view all\n events.

    ",k(n,"class","permission-denied svelte-5kb1ec")},m(e,t){f(e,n,t)},p:e,d(e){e&&h(n)}}}function Vm(e){let t,n,r,i;function o(e,t){return e[4].length>0?zm:e[6]?void 0:Ym}let s=o(e),a=s&&s(e),l=e[6]&&iy();return{c(){t=g("div"),a&&a.c(),n=w(),l&&l.c(),k(t,"class","events-view-content svelte-5kb1ec")},m(o,s){f(o,t,s),a&&a.m(t,null),d(t,n),l&&l.m(t,null),r||(i=A(t,"scroll",e[9]),r=!0)},p(e,r){s===(s=o(e))&&a?a.p(e,r):(a&&a.d(1),a=s&&s(e),a&&(a.c(),a.m(t,n))),e[6]?l||(l=iy(),l.c(),l.m(t,null)):l&&(l.d(1),l=null)},d(e){e&&h(t),a&&a.d(),l&&l.d(),r=!1,i()}}}function Ym(t){let n;return{c(){n=g("div"),n.innerHTML="

    No events found.

    ",k(n,"class","no-events svelte-5kb1ec")},m(e,t){f(e,n,t)},p:e,d(e){e&&h(n)}}}function zm(e){let t,n=e[4],r=[];for(let t=0;t0&&Xm(e);return{c(){t=g("div"),n=g("span"),n.textContent="🗑️ Delete Event",r=w(),i&&i.c(),k(n,"class","delete-event-label svelte-5kb1ec"),k(t,"class","delete-event-info svelte-5kb1ec")},m(e,o){f(e,t,o),d(t,n),d(t,r),i&&i.m(t,null)},p(e,n){e[28].tags&&e[28].tags.length>0?i?i.p(e,n):(i=Xm(e),i.c(),i.m(t,null)):i&&(i.d(1),i=null)},d(e){e&&h(t),i&&i.d()}}}function Xm(e){let t,n=e[28].tags.filter(hy),r=[];for(let t=0;t👤',o=w(),s=g("div"),a=g("div"),l=y(T),c=w(),u=g("div"),p=g("span"),m=y(N),v=w(),b=g("span"),I=y(L),C=w(),x=g("div"),B=g("div"),S=y(O),Q=w(),j.c(),D=w(),G&&G.c(),R=w(),J&&J.c(),$=w(),k(i,"class","events-view-avatar svelte-5kb1ec"),k(a,"class","events-view-author svelte-5kb1ec"),k(p,"class","kind-number svelte-5kb1ec"),F(p,"delete-event",5===e[28].kind),k(b,"class","kind-name svelte-5kb1ec"),k(u,"class","events-view-kind svelte-5kb1ec"),k(s,"class","events-view-info svelte-5kb1ec"),k(B,"class","event-timestamp svelte-5kb1ec"),k(x,"class","events-view-content svelte-5kb1ec"),k(n,"class","events-view-row svelte-5kb1ec"),k(n,"role","button"),k(n,"tabindex","0"),k(t,"class","events-view-item svelte-5kb1ec"),F(t,"expanded",e[5].has(e[28].id))},m(e,r){f(e,t,r),d(t,n),d(n,i),d(n,o),d(n,s),d(s,a),d(a,l),d(s,c),d(s,u),d(u,p),d(p,m),d(u,v),d(u,b),d(b,I),d(n,C),d(n,x),d(x,B),d(B,S),d(x,Q),j.m(x,null),d(n,D),G&&G.m(n,null),d(t,R),J&&J.m(t,null),d(t,$),P||(U=[A(n,"click",q),A(n,"keydown",K)],P=!0)},p(r,i){e=r,16&i[0]&&T!==(T=cy(e[28].pubkey)+"")&&E(l,T),16&i[0]&&N!==(N=e[28].kind+"")&&E(m,N),16&i[0]&&F(p,"delete-event",5===e[28].kind),16&i[0]&&L!==(L=uy(e[28].kind)+"")&&E(I,L),16&i[0]&&O!==(O=dy(e[28].created_at)+"")&&E(S,O),H===(H=_(e))&&j?j.p(e,i):(j.d(1),j=H(e),j&&(j.c(),j.m(x,null))),5!==e[28].kind&&("admin"===e[2]||"owner"===e[2]||"write"===e[2]&&e[28].pubkey&&e[28].pubkey===e[3])?G?G.p(e,i):(G=ty(e),G.c(),G.m(n,null)):G&&(G.d(1),G=null),48&i[0]&&(M=e[5].has(e[28].id)),M?J?J.p(e,i):(J=ny(e),J.c(),J.m(t,$)):J&&(J.d(1),J=null),48&i[0]&&F(t,"expanded",e[5].has(e[28].id))},d(e){e&&h(t),j.d(),G&&G.d(),J&&J.d(),P=!1,r(U)}}}function iy(e){let t;return{c(){t=g("div"),t.innerHTML='
    \n

    Loading events...

    ',k(t,"class","loading-events svelte-5kb1ec")},m(e,n){f(e,t,n)},d(e){e&&h(t)}}}function oy(e){let t,n,i,o,s,a,l,c,u,p,m,v,b,I,E,C,x,B,S,Q,D,R,$,P;function U(e,t){return e[6]?ay:sy}i=new Gm({props:{showJsonEditor:e[8]}}),i.$on("apply",e[17]),i.$on("clear",e[18]),i.$on("toggleJson",e[16]);let T=U(e),N=T(e);return{c(){t=g("div"),n=g("div"),ie(i.$$.fragment),o=w(),s=g("div"),a=g("div"),l=g("button"),l.innerHTML='',c=w(),u=g("div"),p=g("label"),m=g("input"),v=w(),b=g("span"),I=w(),E=g("span"),E.textContent="Only show my events",C=w(),x=g("div"),B=g("button"),S=y("🔄 Load More"),Q=w(),D=g("button"),N.c(),k(n,"class","filter-panel svelte-5kb1ec"),F(n,"open",e[7]),k(l,"class","filter-btn svelte-5kb1ec"),k(l,"title","Filter events"),F(l,"active",e[7]),k(m,"type","checkbox"),k(m,"class","svelte-5kb1ec"),k(b,"class","toggle-slider svelte-5kb1ec"),k(E,"class","toggle-label svelte-5kb1ec"),k(p,"class","toggle-container svelte-5kb1ec"),k(u,"class","events-view-toggle svelte-5kb1ec"),k(a,"class","events-view-left svelte-5kb1ec"),k(B,"class","refresh-btn svelte-5kb1ec"),B.disabled=e[6],k(D,"class","reload-btn svelte-5kb1ec"),D.disabled=e[6],k(x,"class","events-view-buttons svelte-5kb1ec"),k(s,"class","events-view-header svelte-5kb1ec"),k(t,"class","events-view-footer svelte-5kb1ec")},m(r,h){f(r,t,h),d(t,n),oe(i,n,null),d(t,o),d(t,s),d(s,a),d(a,l),d(a,c),d(a,u),d(u,p),d(p,m),m.checked=e[0],d(p,v),d(p,b),d(p,I),d(p,E),d(s,C),d(s,x),d(x,B),d(B,S),d(x,Q),d(x,D),N.m(D,null),R=!0,$||(P=[A(l,"click",e[15]),A(m,"change",e[23]),A(m,"change",e[24]),A(B,"click",e[25]),A(D,"click",e[26])],$=!0)},p(e,t){const r={};256&t[0]&&(r.showJsonEditor=e[8]),i.$set(r),(!R||128&t[0])&&F(n,"open",e[7]),(!R||128&t[0])&&F(l,"active",e[7]),1&t[0]&&(m.checked=e[0]),(!R||64&t[0])&&(B.disabled=e[6]),T!==(T=U(e))&&(N.d(1),N=T(e),N&&(N.c(),N.m(D,null))),(!R||64&t[0])&&(D.disabled=e[6])},i(e){R||(X(i.$$.fragment,e),R=!0)},o(e){ee(i.$$.fragment,e),R=!1},d(e){e&&h(t),se(i),N.d(),$=!1,r(P)}}}function sy(e){let t;return{c(){t=y("🔄")},m(e,n){f(e,t,n)},d(e){e&&h(t)}}}function ay(e){let t;return{c(){t=g("div"),k(t,"class","spinner svelte-5kb1ec")},m(e,n){f(e,t,n)},d(e){e&&h(t)}}}function ly(e){let t,n,r;function i(e,t){return!e[1]||"read"!==e[2]&&"write"!==e[2]&&"admin"!==e[2]&&"owner"!==e[2]?Jm:Vm}let o=i(e),s=o(e),a=e[1]&&("read"===e[2]||"write"===e[2]||"admin"===e[2]||"owner"===e[2])&&oy(e);return{c(){t=g("div"),s.c(),n=w(),a&&a.c(),k(t,"class","events-view-container svelte-5kb1ec")},m(e,i){f(e,t,i),s.m(t,null),d(t,n),a&&a.m(t,null),r=!0},p(e,r){o===(o=i(e))&&s?s.p(e,r):(s.d(1),s=o(e),s&&(s.c(),s.m(t,n))),!e[1]||"read"!==e[2]&&"write"!==e[2]&&"admin"!==e[2]&&"owner"!==e[2]?a&&(W(),ee(a,1,1,()=>{a=null}),Z()):a?(a.p(e,r),6&r[0]&&X(a,1)):(a=oy(e),a.c(),X(a,1),a.m(t,null))},i(e){r||(X(a),r=!0)},o(e){ee(a),r=!1},d(e){e&&h(t),s.d(),a&&a.d()}}}function cy(e){return e?e.slice(0,8)+"..."+e.slice(-8):""}function uy(e){return{0:"Profile",1:"Text Note",2:"Recommend Relay",3:"Contacts",4:"Encrypted DM",5:"Delete",6:"Repost",7:"Reaction",8:"Badge Award",16:"Generic Repost",40:"Channel Creation",41:"Channel Metadata",42:"Channel Message",43:"Channel Hide Message",44:"Channel Mute User",1984:"Reporting",9734:"Zap Request",9735:"Zap",1e4:"Mute List",10001:"Pin List",10002:"Relay List",22242:"Client Auth",24133:"Nostr Connect",27235:"HTTP Auth",3e4:"Categorized People",30001:"Categorized Bookmarks",30008:"Profile Badges",30009:"Badge Definition",30017:"Create or update a stall",30018:"Create or update a product",30023:"Long-form Content",30024:"Draft Long-form Content",30078:"Application-specific Data",30311:"Live Event",30315:"User Statuses",30402:"Classified Listing",30403:"Draft Classified Listing",31922:"Date-Based Calendar Event",31923:"Time-Based Calendar Event",31924:"Calendar",31925:"Calendar Event RSVP",31989:"Handler recommendation",31990:"Handler information",34550:"Community Definition"}[e]||`Kind ${e}`}function dy(e){return new Date(1e3*e).toLocaleString()}function fy(e){return e?e.length>100?e.slice(0,100)+"...":e:""}const hy=e=>"e"===e[0];function py(e,t,n){let{isLoggedIn:r=!1}=t,{userRole:i=""}=t,{userPubkey:o=""}=t,{filteredEvents:s=[]}=t,{expandedEvents:a=new Set}=t,{isLoadingEvents:l=!1}=t,{showOnlyMyEvents:c=!1}=t,{showFilterBuilder:u=!1}=t;const d=U();let f=!1;function h(e){d("toggleEventExpansion",e)}function p(e){d("deleteEvent",e)}function g(e,t){d("copyEventToClipboard",{event:e,e:t})}function m(){d("toggleChange")}function y(e,t){d("loadAllEvents",{refresh:e,authors:t})}return e.$$set=e=>{"isLoggedIn"in e&&n(1,r=e.isLoggedIn),"userRole"in e&&n(2,i=e.userRole),"userPubkey"in e&&n(3,o=e.userPubkey),"filteredEvents"in e&&n(4,s=e.filteredEvents),"expandedEvents"in e&&n(5,a=e.expandedEvents),"isLoadingEvents"in e&&n(6,l=e.isLoadingEvents),"showOnlyMyEvents"in e&&n(0,c=e.showOnlyMyEvents),"showFilterBuilder"in e&&n(7,u=e.showFilterBuilder)},[c,r,i,o,s,a,l,u,f,function(e){d("scroll",e)},h,p,g,m,y,function(){d("toggleFilterBuilder")},function(){n(8,f=!f)},function(e){d("filterApply",e.detail)},function(){d("filterClear")},e=>p(e.id),e=>h(e.id),(e,t)=>"Enter"===t.key&&h(e.id),(e,t)=>g(e,t),function(){c=this.checked,n(0,c)},()=>m(),()=>{y(!1,c&&o?[o]:null)},()=>{y(!0,c&&o?[o]:null)}]}class gy extends ce{constructor(e){super(),le(this,e,py,ly,o,{isLoggedIn:1,userRole:2,userPubkey:3,filteredEvents:4,expandedEvents:5,isLoadingEvents:6,showOnlyMyEvents:0,showFilterBuilder:7},null,[-1,-1])}}const my=[{kind:0,name:"Metadata",description:"User profile information (name, about, picture, nip05, etc.)",nip:"01",isReplaceable:!0,template:{kind:0,content:"",tags:[]}},{kind:1,name:"Short Text Note",description:"Short-form text post (like a tweet)",nip:"01",template:{kind:1,content:"",tags:[]}},{kind:2,name:"Recommend Relay",description:"Relay recommendation",nip:"01",deprecated:!0,template:{kind:2,content:"",tags:[]}},{kind:3,name:"Follows",description:"Following list with optional relay hints",nip:"02",isReplaceable:!0,template:{kind:3,content:"",tags:[]}},{kind:4,name:"Encrypted Direct Message",description:"Private message using NIP-04 encryption",nip:"04",deprecated:!0,template:{kind:4,content:"",tags:[]}},{kind:5,name:"Event Deletion Request",description:"Request to delete events",nip:"09",template:{kind:5,content:"",tags:[]}},{kind:6,name:"Repost",description:"Share/repost another text note",nip:"18",template:{kind:6,content:"",tags:[]}},{kind:7,name:"Reaction",description:"Like, emoji reaction to an event",nip:"25",template:{kind:7,content:"",tags:[]}},{kind:8,name:"Badge Award",description:"Award a badge to someone",nip:"58",template:{kind:8,content:"",tags:[]}},{kind:9,name:"Chat Message",description:"Chat message",nip:"C7",template:{kind:9,content:"",tags:[]}},{kind:10,name:"Group Chat Threaded Reply",description:"Threaded reply in group chat",nip:"29",deprecated:!0,template:{kind:10,content:"",tags:[]}},{kind:11,name:"Thread",description:"Thread event",nip:"7D",template:{kind:11,content:"",tags:[]}},{kind:12,name:"Group Thread Reply",description:"Reply in group thread",nip:"29",deprecated:!0,template:{kind:12,content:"",tags:[]}},{kind:13,name:"Seal",description:"Sealed/encrypted event wrapper",nip:"59",template:{kind:13,content:"",tags:[]}},{kind:14,name:"Direct Message",description:"Private direct message using NIP-17",nip:"17",template:{kind:14,content:"",tags:[]}},{kind:15,name:"File Message",description:"File message in DMs",nip:"17",template:{kind:15,content:"",tags:[]}},{kind:16,name:"Generic Repost",description:"Repost any event kind",nip:"18",template:{kind:16,content:"",tags:[]}},{kind:17,name:"Reaction to Website",description:"Reaction to a website URL",nip:"25",template:{kind:17,content:"",tags:[]}},{kind:20,name:"Picture",description:"Picture-first feed post",nip:"68",template:{kind:20,content:"",tags:[]}},{kind:21,name:"Video Event",description:"Horizontal video event",nip:"71",template:{kind:21,content:"",tags:[]}},{kind:22,name:"Short-form Video",description:"Short-form portrait video (like TikTok)",nip:"71",template:{kind:22,content:"",tags:[]}},{kind:40,name:"Channel Creation",description:"Create a public chat channel",nip:"28",template:{kind:40,content:"",tags:[]}},{kind:41,name:"Channel Metadata",description:"Set channel name, about, picture",nip:"28",template:{kind:41,content:"",tags:[]}},{kind:42,name:"Channel Message",description:"Post message in channel",nip:"28",template:{kind:42,content:"",tags:[]}},{kind:43,name:"Channel Hide Message",description:"Hide a message in channel",nip:"28",template:{kind:43,content:"",tags:[]}},{kind:44,name:"Channel Mute User",description:"Mute a user in channel",nip:"28",template:{kind:44,content:"",tags:[]}},{kind:62,name:"Request to Vanish",description:"Request permanent deletion of all user data",nip:"62",template:{kind:62,content:"",tags:[]}},{kind:64,name:"Chess (PGN)",description:"Chess game in PGN format",nip:"64",template:{kind:64,content:"",tags:[]}},{kind:443,name:"KeyPackage",description:"Marmot protocol key package",nip:null,spec:"Marmot",template:{kind:443,content:"",tags:[]}},{kind:444,name:"Welcome Message",description:"Marmot protocol welcome message",nip:null,spec:"Marmot",template:{kind:444,content:"",tags:[]}},{kind:445,name:"Group Event",description:"Marmot protocol group event",nip:null,spec:"Marmot",template:{kind:445,content:"",tags:[]}},{kind:818,name:"Merge Requests",description:"Git merge request",nip:"54",template:{kind:818,content:"",tags:[]}},{kind:1018,name:"Poll Response",description:"Response to a poll",nip:"88",template:{kind:1018,content:"",tags:[]}},{kind:1021,name:"Bid",description:"Auction bid",nip:"15",template:{kind:1021,content:"",tags:[]}},{kind:1022,name:"Bid Confirmation",description:"Confirmation of auction bid",nip:"15",template:{kind:1022,content:"",tags:[]}},{kind:1040,name:"OpenTimestamps",description:"OpenTimestamps attestation",nip:"03",template:{kind:1040,content:"",tags:[]}},{kind:1059,name:"Gift Wrap",description:"Encrypted gift-wrapped event",nip:"59",template:{kind:1059,content:"",tags:[]}},{kind:1060,name:"Gift Wrap (Kind 4)",description:"Gift wrap variant for NIP-04 compatibility",nip:"59",template:{kind:1060,content:"",tags:[]}},{kind:1063,name:"File Metadata",description:"Metadata for shared files",nip:"94",template:{kind:1063,content:"",tags:[]}},{kind:1068,name:"Poll",description:"Create a poll",nip:"88",template:{kind:1068,content:"",tags:[]}},{kind:1111,name:"Comment",description:"Comment on events or external content",nip:"22",template:{kind:1111,content:"",tags:[]}},{kind:1222,name:"Voice Message",description:"Voice message",nip:"A0",template:{kind:1222,content:"",tags:[]}},{kind:1244,name:"Voice Message Comment",description:"Comment on voice message",nip:"A0",template:{kind:1244,content:"",tags:[]}},{kind:1311,name:"Live Chat Message",description:"Message in live stream chat",nip:"53",template:{kind:1311,content:"",tags:[]}},{kind:1337,name:"Code Snippet",description:"Code snippet post",nip:"C0",template:{kind:1337,content:"",tags:[]}},{kind:1517,name:"Bitcoin Block",description:"Bitcoin block data",nip:null,spec:"Nostrocket",template:{kind:1517,content:"",tags:[]}},{kind:1617,name:"Patches",description:"Git patches",nip:"34",template:{kind:1617,content:"",tags:[]}},{kind:1618,name:"Pull Requests",description:"Git pull request",nip:"34",template:{kind:1618,content:"",tags:[]}},{kind:1619,name:"Pull Request Updates",description:"Updates to git pull request",nip:"34",template:{kind:1619,content:"",tags:[]}},{kind:1621,name:"Issues",description:"Git issues",nip:"34",template:{kind:1621,content:"",tags:[]}},{kind:1622,name:"Git Replies",description:"Replies on git objects",nip:"34",deprecated:!0,template:{kind:1622,content:"",tags:[]}},{kind:1630,name:"Status",description:"Git status",nip:"34",template:{kind:1630,content:"",tags:[]}},{kind:1631,name:"Status",description:"Git status",nip:"34",template:{kind:1631,content:"",tags:[]}},{kind:1632,name:"Status",description:"Git status",nip:"34",template:{kind:1632,content:"",tags:[]}},{kind:1633,name:"Status",description:"Git status",nip:"34",template:{kind:1633,content:"",tags:[]}},{kind:1808,name:"Live Stream",description:"Live streaming event",nip:null,spec:"zap.stream",template:{kind:1808,content:"",tags:[]}},{kind:1971,name:"Problem Tracker",description:"Problem tracking",nip:null,spec:"Nostrocket",template:{kind:1971,content:"",tags:[]}},{kind:1984,name:"Reporting",description:"Report content or users",nip:"56",template:{kind:1984,content:"",tags:[]}},{kind:1985,name:"Label",description:"Label/tag content with namespace",nip:"32",template:{kind:1985,content:"",tags:[]}},{kind:1986,name:"Relay Reviews",description:"Reviews of relays",nip:null,template:{kind:1986,content:"",tags:[]}},{kind:1987,name:"AI Embeddings",description:"AI embeddings/vector lists",nip:null,spec:"NKBIP-02",template:{kind:1987,content:"",tags:[]}},{kind:2003,name:"Torrent",description:"Torrent magnet link",nip:"35",template:{kind:2003,content:"",tags:[]}},{kind:2004,name:"Torrent Comment",description:"Comment on torrent",nip:"35",template:{kind:2004,content:"",tags:[]}},{kind:2022,name:"Coinjoin Pool",description:"Coinjoin coordination",nip:null,spec:"joinstr",template:{kind:2022,content:"",tags:[]}},{kind:4550,name:"Community Post Approval",description:"Approve post in community",nip:"72",template:{kind:4550,content:"",tags:[]}},{kind:5e3,name:"Job Request",description:"Data vending machine job request (start of range)",nip:"90",template:{kind:5e3,content:"",tags:[]}},{kind:6e3,name:"Job Result",description:"Data vending machine job result (start of range)",nip:"90",template:{kind:6e3,content:"",tags:[]}},{kind:7e3,name:"Job Feedback",description:"Feedback on job request/result",nip:"90",template:{kind:7e3,content:"",tags:[]}},{kind:7374,name:"Reserved Cashu Wallet Tokens",description:"Reserved Cashu wallet tokens",nip:"60",template:{kind:7374,content:"",tags:[]}},{kind:7375,name:"Cashu Wallet Tokens",description:"Cashu wallet tokens",nip:"60",template:{kind:7375,content:"",tags:[]}},{kind:7376,name:"Cashu Wallet History",description:"Cashu wallet transaction history",nip:"60",template:{kind:7376,content:"",tags:[]}},{kind:7516,name:"Geocache Log",description:"Geocaching log entry",nip:null,spec:"geocaching",template:{kind:7516,content:"",tags:[]}},{kind:7517,name:"Geocache Proof of Find",description:"Proof of geocache find",nip:null,spec:"geocaching",template:{kind:7517,content:"",tags:[]}},{kind:8e3,name:"Add User",description:"Add user to group",nip:"43",template:{kind:8e3,content:"",tags:[]}},{kind:8001,name:"Remove User",description:"Remove user from group",nip:"43",template:{kind:8001,content:"",tags:[]}},{kind:9e3,name:"Group Control Events",description:"Group control events (start of range)",nip:"29",template:{kind:9e3,content:"",tags:[]}},{kind:9041,name:"Zap Goal",description:"Fundraising goal for zaps",nip:"75",template:{kind:9041,content:"",tags:[]}},{kind:9321,name:"Nutzap",description:"Cashu nutzap",nip:"61",template:{kind:9321,content:"",tags:[]}},{kind:9467,name:"Tidal Login",description:"Tidal streaming login",nip:null,spec:"Tidal-nostr",template:{kind:9467,content:"",tags:[]}},{kind:9734,name:"Zap Request",description:"Request Lightning payment",nip:"57",template:{kind:9734,content:"",tags:[]}},{kind:9735,name:"Zap",description:"Lightning payment receipt",nip:"57",template:{kind:9735,content:"",tags:[]}},{kind:9802,name:"Highlights",description:"Highlighted text selection",nip:"84",template:{kind:9802,content:"",tags:[]}},{kind:1e4,name:"Mute List",description:"List of muted users/content",nip:"51",isReplaceable:!0,template:{kind:1e4,content:"",tags:[]}},{kind:10001,name:"Pin List",description:"Pinned events",nip:"51",isReplaceable:!0,template:{kind:10001,content:"",tags:[]}},{kind:10002,name:"Relay List Metadata",description:"User's preferred relays for read/write",nip:"65",isReplaceable:!0,template:{kind:10002,content:"",tags:[]}},{kind:10003,name:"Bookmark List",description:"Bookmarked events",nip:"51",isReplaceable:!0,template:{kind:10003,content:"",tags:[]}},{kind:10004,name:"Communities List",description:"Communities user belongs to",nip:"51",isReplaceable:!0,template:{kind:10004,content:"",tags:[]}},{kind:10005,name:"Public Chats List",description:"Public chats user is in",nip:"51",isReplaceable:!0,template:{kind:10005,content:"",tags:[]}},{kind:10006,name:"Blocked Relays List",description:"Relays user has blocked",nip:"51",isReplaceable:!0,template:{kind:10006,content:"",tags:[]}},{kind:10007,name:"Search Relays List",description:"Preferred search relays",nip:"51",isReplaceable:!0,template:{kind:10007,content:"",tags:[]}},{kind:10008,name:"Relay Group Configuration",description:"Relay group configuration",nip:null,isReplaceable:!0,template:{kind:10008,content:"",tags:[]}},{kind:10009,name:"User Groups",description:"Groups user belongs to",nip:"29",isReplaceable:!0,template:{kind:10009,content:"",tags:[]}},{kind:10012,name:"Favorite Relays List",description:"User's favorite relays",nip:"51",isReplaceable:!0,template:{kind:10012,content:"",tags:[]}},{kind:10013,name:"Private Event Relay List",description:"Relays for private events",nip:"37",isReplaceable:!0,template:{kind:10013,content:"",tags:[]}},{kind:10015,name:"Interests List",description:"User interests/topics",nip:"51",isReplaceable:!0,template:{kind:10015,content:"",tags:[]}},{kind:10019,name:"Nutzap Mint Recommendation",description:"Recommended Cashu mints for nutzaps",nip:"61",isReplaceable:!0,template:{kind:10019,content:"",tags:[]}},{kind:10020,name:"Media Follows",description:"Followed media accounts",nip:"51",isReplaceable:!0,template:{kind:10020,content:"",tags:[]}},{kind:10030,name:"User Emoji List",description:"Custom emoji list",nip:"51",isReplaceable:!0,template:{kind:10030,content:"",tags:[]}},{kind:10050,name:"DM Relays List",description:"Relays to receive DMs on",nip:"17",isReplaceable:!0,template:{kind:10050,content:"",tags:[]}},{kind:10051,name:"KeyPackage Relays List",description:"Marmot key package relays",nip:null,isReplaceable:!0,spec:"Marmot",template:{kind:10051,content:"",tags:[]}},{kind:10063,name:"User Server List",description:"Blossom server list",nip:null,isReplaceable:!0,spec:"Blossom",template:{kind:10063,content:"",tags:[]}},{kind:10096,name:"File Storage Server List",description:"File storage servers",nip:"96",isReplaceable:!0,deprecated:!0,template:{kind:10096,content:"",tags:[]}},{kind:10166,name:"Relay Monitor Announcement",description:"Relay monitoring announcement",nip:"66",isReplaceable:!0,template:{kind:10166,content:"",tags:[]}},{kind:10312,name:"Room Presence",description:"Presence in live room",nip:"53",isReplaceable:!0,template:{kind:10312,content:"",tags:[]}},{kind:10377,name:"Proxy Announcement",description:"Nostr proxy announcement",nip:null,isReplaceable:!0,spec:"Nostr Epoxy",template:{kind:10377,content:"",tags:[]}},{kind:11111,name:"Transport Method Announcement",description:"Transport method announcement",nip:null,isReplaceable:!0,spec:"Nostr Epoxy",template:{kind:11111,content:"",tags:[]}},{kind:12345,name:"Relay Policy Configuration",description:"Relay-internal policy configuration (admin only)",nip:null,isReplaceable:!0,spec:"orly",template:{kind:12345,content:"",tags:[]}},{kind:13004,name:"JWT Binding",description:"Link between JWT certificate and pubkey",nip:null,isReplaceable:!0,template:{kind:13004,content:"",tags:[]}},{kind:13194,name:"Wallet Service Info",description:"NWC wallet service information",nip:"47",isReplaceable:!0,template:{kind:13194,content:"",tags:[]}},{kind:13534,name:"Membership Lists",description:"Group membership lists",nip:"43",isReplaceable:!0,template:{kind:13534,content:"",tags:[]}},{kind:14388,name:"User Sound Effect Lists",description:"Sound effect lists",nip:null,isReplaceable:!0,spec:"Corny Chat",template:{kind:14388,content:"",tags:[]}},{kind:17375,name:"Cashu Wallet Event",description:"Cashu wallet event",nip:"60",isReplaceable:!0,template:{kind:17375,content:"",tags:[]}},{kind:21e3,name:"Lightning Pub RPC",description:"Lightning.Pub RPC",nip:null,isEphemeral:!0,spec:"Lightning.Pub",template:{kind:21e3,content:"",tags:[]}},{kind:22242,name:"Client Authentication",description:"Authenticate to relay",nip:"42",isEphemeral:!0,template:{kind:22242,content:"",tags:[]}},{kind:23194,name:"Wallet Request",description:"NWC wallet request",nip:"47",isEphemeral:!0,template:{kind:23194,content:"",tags:[]}},{kind:23195,name:"Wallet Response",description:"NWC wallet response",nip:"47",isEphemeral:!0,template:{kind:23195,content:"",tags:[]}},{kind:23196,name:"Wallet Notification (NIP-04)",description:"NWC wallet notification (NIP-04 encrypted)",nip:"47",isEphemeral:!0,template:{kind:23196,content:"",tags:[]}},{kind:23197,name:"Wallet Notification",description:"NWC wallet notification",nip:"47",isEphemeral:!0,template:{kind:23197,content:"",tags:[]}},{kind:24133,name:"Nostr Connect",description:"Remote signer connection",nip:"46",isEphemeral:!0,template:{kind:24133,content:"",tags:[]}},{kind:24242,name:"Blobs Stored on Mediaservers",description:"Blossom blob storage",nip:null,isEphemeral:!0,spec:"Blossom",template:{kind:24242,content:"",tags:[]}},{kind:27235,name:"HTTP Auth",description:"Authenticate HTTP requests",nip:"98",isEphemeral:!0,template:{kind:27235,content:"",tags:[]}},{kind:28934,name:"Join Request",description:"Request to join group",nip:"43",isEphemeral:!0,template:{kind:28934,content:"",tags:[]}},{kind:28935,name:"Invite Request",description:"Invite to group",nip:"43",isEphemeral:!0,template:{kind:28935,content:"",tags:[]}},{kind:28936,name:"Leave Request",description:"Leave group request",nip:"43",isEphemeral:!0,template:{kind:28936,content:"",tags:[]}},{kind:3e4,name:"Follow Sets",description:"Categorized people lists",nip:"51",isAddressable:!0,template:{kind:3e4,content:"",tags:[["d","identifier"]]}},{kind:30001,name:"Generic Lists",description:"Generic categorized lists",nip:"51",isAddressable:!0,deprecated:!0,template:{kind:30001,content:"",tags:[["d","identifier"]]}},{kind:30002,name:"Relay Sets",description:"Categorized relay lists",nip:"51",isAddressable:!0,template:{kind:30002,content:"",tags:[["d","identifier"]]}},{kind:30003,name:"Bookmark Sets",description:"Categorized bookmark lists",nip:"51",isAddressable:!0,template:{kind:30003,content:"",tags:[["d","identifier"]]}},{kind:30004,name:"Curation Sets",description:"Curated content sets",nip:"51",isAddressable:!0,template:{kind:30004,content:"",tags:[["d","identifier"]]}},{kind:30005,name:"Video Sets",description:"Video playlists",nip:"51",isAddressable:!0,template:{kind:30005,content:"",tags:[["d","identifier"]]}},{kind:30007,name:"Kind Mute Sets",description:"Muted event kinds",nip:"51",isAddressable:!0,template:{kind:30007,content:"",tags:[["d","identifier"]]}},{kind:30008,name:"Profile Badges",description:"Badges displayed on profile",nip:"58",isAddressable:!0,template:{kind:30008,content:"",tags:[["d","identifier"]]}},{kind:30009,name:"Badge Definition",description:"Define a badge/achievement",nip:"58",isAddressable:!0,template:{kind:30009,content:"",tags:[["d","identifier"]]}},{kind:30015,name:"Interest Sets",description:"Interest/topic sets",nip:"51",isAddressable:!0,template:{kind:30015,content:"",tags:[["d","identifier"]]}},{kind:30017,name:"Stall",description:"Marketplace stall definition",nip:"15",isAddressable:!0,template:{kind:30017,content:"",tags:[["d","identifier"]]}},{kind:30018,name:"Product",description:"Marketplace product listing",nip:"15",isAddressable:!0,template:{kind:30018,content:"",tags:[["d","identifier"]]}},{kind:30019,name:"Marketplace UI/UX",description:"Marketplace interface settings",nip:"15",isAddressable:!0,template:{kind:30019,content:"",tags:[["d","identifier"]]}},{kind:30020,name:"Product Sold as Auction",description:"Auction product listing",nip:"15",isAddressable:!0,template:{kind:30020,content:"",tags:[["d","identifier"]]}},{kind:30023,name:"Long-form Content",description:"Blog post, article in markdown",nip:"23",isAddressable:!0,template:{kind:30023,content:"",tags:[["d","identifier"]]}},{kind:30024,name:"Draft Long-form Content",description:"Draft article",nip:"23",isAddressable:!0,template:{kind:30024,content:"",tags:[["d","identifier"]]}},{kind:30030,name:"Emoji Sets",description:"Custom emoji sets",nip:"51",isAddressable:!0,template:{kind:30030,content:"",tags:[["d","identifier"]]}},{kind:30040,name:"Curated Publication Index",description:"Publication index",nip:null,isAddressable:!0,spec:"NKBIP-01",template:{kind:30040,content:"",tags:[["d","identifier"]]}},{kind:30041,name:"Curated Publication Content",description:"Publication content",nip:null,isAddressable:!0,spec:"NKBIP-01",template:{kind:30041,content:"",tags:[["d","identifier"]]}},{kind:30063,name:"Release Artifact Sets",description:"Software release artifacts",nip:"51",isAddressable:!0,template:{kind:30063,content:"",tags:[["d","identifier"]]}},{kind:30078,name:"Application-specific Data",description:"App-specific key-value storage",nip:"78",isAddressable:!0,template:{kind:30078,content:"",tags:[["d","identifier"]]}},{kind:30166,name:"Relay Discovery",description:"Relay discovery/monitoring",nip:"66",isAddressable:!0,template:{kind:30166,content:"",tags:[["d","identifier"]]}},{kind:30267,name:"App Curation Sets",description:"Curated app sets",nip:"51",isAddressable:!0,template:{kind:30267,content:"",tags:[["d","identifier"]]}},{kind:30311,name:"Live Event",description:"Live streaming event",nip:"53",isAddressable:!0,template:{kind:30311,content:"",tags:[["d","identifier"]]}},{kind:30312,name:"Interactive Room",description:"Interactive live room",nip:"53",isAddressable:!0,template:{kind:30312,content:"",tags:[["d","identifier"]]}},{kind:30313,name:"Conference Event",description:"Conference/meetup event",nip:"53",isAddressable:!0,template:{kind:30313,content:"",tags:[["d","identifier"]]}},{kind:30315,name:"User Statuses",description:"User status updates",nip:"38",isAddressable:!0,template:{kind:30315,content:"",tags:[["d","identifier"]]}},{kind:30388,name:"Slide Set",description:"Presentation slides",nip:null,isAddressable:!0,spec:"Corny Chat",template:{kind:30388,content:"",tags:[["d","identifier"]]}},{kind:30402,name:"Classified Listing",description:"Classified ad listing",nip:"99",isAddressable:!0,template:{kind:30402,content:"",tags:[["d","identifier"]]}},{kind:30403,name:"Draft Classified Listing",description:"Draft classified ad",nip:"99",isAddressable:!0,template:{kind:30403,content:"",tags:[["d","identifier"]]}},{kind:30617,name:"Repository Announcements",description:"Git repository announcement",nip:"34",isAddressable:!0,template:{kind:30617,content:"",tags:[["d","identifier"]]}},{kind:30618,name:"Repository State Announcements",description:"Git repository state",nip:"34",isAddressable:!0,template:{kind:30618,content:"",tags:[["d","identifier"]]}},{kind:30818,name:"Wiki Article",description:"Wiki article",nip:"54",isAddressable:!0,template:{kind:30818,content:"",tags:[["d","identifier"]]}},{kind:30819,name:"Redirects",description:"URL redirects",nip:"54",isAddressable:!0,template:{kind:30819,content:"",tags:[["d","identifier"]]}},{kind:31234,name:"Draft Event",description:"Draft of any event",nip:"37",isAddressable:!0,template:{kind:31234,content:"",tags:[["d","identifier"]]}},{kind:31388,name:"Link Set",description:"Link collection",nip:null,isAddressable:!0,spec:"Corny Chat",template:{kind:31388,content:"",tags:[["d","identifier"]]}},{kind:31890,name:"Feed",description:"Custom feed definition",nip:null,isAddressable:!0,spec:"NUD: Custom Feeds",template:{kind:31890,content:"",tags:[["d","identifier"]]}},{kind:31922,name:"Date-Based Calendar Event",description:"All-day calendar event",nip:"52",isAddressable:!0,template:{kind:31922,content:"",tags:[["d","identifier"]]}},{kind:31923,name:"Time-Based Calendar Event",description:"Calendar event with time",nip:"52",isAddressable:!0,template:{kind:31923,content:"",tags:[["d","identifier"]]}},{kind:31924,name:"Calendar",description:"Calendar definition",nip:"52",isAddressable:!0,template:{kind:31924,content:"",tags:[["d","identifier"]]}},{kind:31925,name:"Calendar Event RSVP",description:"RSVP to calendar event",nip:"52",isAddressable:!0,template:{kind:31925,content:"",tags:[["d","identifier"]]}},{kind:31989,name:"Handler Recommendation",description:"Recommended app for event kind",nip:"89",isAddressable:!0,template:{kind:31989,content:"",tags:[["d","identifier"]]}},{kind:31990,name:"Handler Information",description:"App handler declaration",nip:"89",isAddressable:!0,template:{kind:31990,content:"",tags:[["d","identifier"]]}},{kind:32123,name:"WaveLake Track",description:"WaveLake music track",nip:null,isAddressable:!0,spec:"WaveLake",template:{kind:32123,content:"",tags:[["d","identifier"]]}},{kind:32267,name:"Software Application",description:"Software application listing",nip:null,isAddressable:!0,template:{kind:32267,content:"",tags:[["d","identifier"]]}},{kind:32388,name:"User Room Favorites",description:"Favorite rooms",nip:null,isAddressable:!0,spec:"Corny Chat",template:{kind:32388,content:"",tags:[["d","identifier"]]}},{kind:33388,name:"High Scores",description:"Game high scores",nip:null,isAddressable:!0,spec:"Corny Chat",template:{kind:33388,content:"",tags:[["d","identifier"]]}},{kind:34235,name:"Video Event Horizontal",description:"Horizontal video event",nip:"71",isAddressable:!0,template:{kind:34235,content:"",tags:[["d","identifier"]]}},{kind:34236,name:"Video Event Vertical",description:"Vertical video event",nip:"71",isAddressable:!0,template:{kind:34236,content:"",tags:[["d","identifier"]]}},{kind:34388,name:"Sound Effects",description:"Sound effect definitions",nip:null,isAddressable:!0,spec:"Corny Chat",template:{kind:34388,content:"",tags:[["d","identifier"]]}},{kind:34550,name:"Community Definition",description:"Define a community",nip:"72",isAddressable:!0,template:{kind:34550,content:"",tags:[["d","identifier"]]}},{kind:37516,name:"Geocache Listing",description:"Geocache location listing",nip:null,isAddressable:!0,spec:"geocaching",template:{kind:37516,content:"",tags:[["d","identifier"]]}},{kind:38172,name:"Cashu Mint Announcement",description:"Cashu mint announcement",nip:"87",isAddressable:!0,template:{kind:38172,content:"",tags:[["d","identifier"]]}},{kind:38173,name:"Fedimint Announcement",description:"Fedimint announcement",nip:"87",isAddressable:!0,template:{kind:38173,content:"",tags:[["d","identifier"]]}},{kind:38383,name:"Peer-to-peer Order Events",description:"P2P trading orders",nip:"69",isAddressable:!0,template:{kind:38383,content:"",tags:[["d","identifier"]]}},{kind:39e3,name:"Group Metadata Events",description:"Group metadata (start of range)",nip:"29",isAddressable:!0,template:{kind:39e3,content:"",tags:[["d","identifier"]]}},{kind:39089,name:"Starter Packs",description:"Starter pack lists",nip:"51",isAddressable:!0,template:{kind:39089,content:"",tags:[["d","identifier"]]}},{kind:39092,name:"Media Starter Packs",description:"Media starter packs",nip:"51",isAddressable:!0,template:{kind:39092,content:"",tags:[["d","identifier"]]}},{kind:39701,name:"Web Bookmarks",description:"Web URL bookmarks",nip:"B0",isAddressable:!0,template:{kind:39701,content:"",tags:[["d","identifier"]]}},{kind:39998,name:"ACL Event",description:"Access control list event",nip:null,isAddressable:!0,template:{kind:39998,content:"",tags:[["d","identifier"]]}}];function yy(e,t=null){const n=function(e){return my.find(t=>t.kind===e)}(e);return n?{...n.template,created_at:Math.floor(Date.now()/1e3),pubkey:t||""}:{kind:e,content:"",tags:[],created_at:Math.floor(Date.now()/1e3),pubkey:t||""}}const wy=[{id:"all",name:"All Kinds",filter:()=>!0},{id:"regular",name:"Regular Events (0-9999)",filter:e=>e.kind<1e4&&!e.isReplaceable},{id:"replaceable",name:"Replaceable (10000-19999)",filter:e=>e.isReplaceable},{id:"ephemeral",name:"Ephemeral (20000-29999)",filter:e=>e.isEphemeral},{id:"addressable",name:"Addressable (30000-39999)",filter:e=>e.isAddressable},{id:"social",name:"Social",filter:e=>[0,1,3,6,7].includes(e.kind)},{id:"messaging",name:"Messaging",filter:e=>[4,9,10,11,12,14,15,40,41,42].includes(e.kind)},{id:"lists",name:"Lists",filter:e=>e.name.toLowerCase().includes("list")||e.name.toLowerCase().includes("set")},{id:"marketplace",name:"Marketplace",filter:e=>[30017,30018,30019,30020,1021,1022,30402,30403].includes(e.kind)},{id:"lightning",name:"Lightning/Zaps",filter:e=>[9734,9735,9041,9321,7374,7375,7376].includes(e.kind)},{id:"media",name:"Media",filter:e=>[20,21,22,1063,1222,1244].includes(e.kind)},{id:"git",name:"Git/Code",filter:e=>[818,1337,1617,1618,1619,1621,1622,30617,30618].includes(e.kind)},{id:"calendar",name:"Calendar",filter:e=>[31922,31923,31924,31925].includes(e.kind)},{id:"groups",name:"Groups",filter:e=>e.kind>=9e3&&e.kind<=9030||e.kind>=39e3&&e.kind<=39009}];function vy(e,t,n){const r=e.slice();return r[13]=t[n],r}function Ay(e,t,n){const r=e.slice();return r[16]=t[n],r}function by(e){let t,n,i,o,s,a,l,c,u,m,v,b,I,x,B,S,F,Q,D,R,$,P,U,T,N,L=e[3].length+"",O=1!==e[3].length?"s":"",M=wy,_=[];for(let t=0;t=2e4&&e.kind<3e4?"badge-ephemeral":"badge-regular"}function Fy(e){return e.isAddressable?"Addressable":e.isReplaceable?"Replaceable":e.kind>=2e4&&e.kind<3e4?"Ephemeral":"Regular"}function Qy(e,t,n){let{isOpen:r=!1}=t,{userPubkey:i=""}=t;const o=U();let s="",a="all",l=my;function c(e){const t=yy(e.kind,i);o("select",{kind:e,template:t}),u()}function u(){n(0,r=!1),n(1,s=""),n(2,a="all"),o("close")}return e.$$set=e=>{"isOpen"in e&&n(0,r=e.isOpen),"userPubkey"in e&&n(8,i=e.userPubkey)},e.$$.update=()=>{if(6&e.$$.dirty){let e=my;const t=wy.find(e=>e.id===a);if(t&&(e=e.filter(t.filter)),s.trim()){const t=s.toLowerCase();e=e.filter(e=>e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.kind.toString().includes(t)||e.nip&&e.nip.includes(t))}n(3,l=e)}},[r,s,a,l,c,u,function(e){"Escape"===e.key&&u()},function(e){e.target===e.currentTarget&&u()},i,function(){s=this.value,n(1,s)},e=>n(2,a=e.id),e=>c(e)]}class Dy extends ce{constructor(e){super(),le(this,e,Qy,By,o,{isOpen:0,userPubkey:8})}}function Ry(e){let t,n,r,i,o,s,a,l,c,u;return{c(){t=g("div"),n=g("div"),r=g("span"),r.textContent="⚠",i=w(),o=g("span"),s=y(e[1]),a=w(),l=g("button"),l.textContent="×",k(r,"class","error-icon svelte-46pmgb"),k(o,"class","error-message svelte-46pmgb"),k(n,"class","error-content svelte-46pmgb"),k(l,"class","error-dismiss svelte-46pmgb"),k(t,"class","error-banner svelte-46pmgb")},m(h,p){f(h,t,p),d(t,n),d(n,r),d(n,i),d(n,o),d(o,s),d(t,a),d(t,l),c||(u=A(l,"click",e[10]),c=!0)},p(e,t){2&t&&E(s,e[1])},d(e){e&&h(t),c=!1,u()}}}function $y(e){let t,n,i,o,s,a,l,c,u,p,m,y,v,b,I,E,x,B,S,F=e[1]&&Ry(e);function Q(t){e[14](t)}let D={userPubkey:e[2]};return void 0!==e[3]&&(D.isOpen=e[3]),I=new Dy({props:D}),L.push(()=>re(I,"isOpen",Q)),I.$on("select",e[8]),I.$on("close",e[9]),{c(){t=g("div"),n=g("div"),i=g("button"),i.textContent="Generate Template",o=w(),s=g("button"),s.textContent="Reformat",a=w(),l=g("button"),l.textContent="Sign",c=w(),u=g("button"),u.textContent="Publish",p=w(),F&&F.c(),m=w(),y=g("div"),v=g("textarea"),b=w(),ie(I.$$.fragment),k(i,"class","compose-btn template-btn svelte-46pmgb"),k(s,"class","compose-btn reformat-btn svelte-46pmgb"),k(l,"class","compose-btn sign-btn svelte-46pmgb"),k(u,"class","compose-btn publish-btn svelte-46pmgb"),k(n,"class","compose-header svelte-46pmgb"),k(v,"class","compose-textarea svelte-46pmgb"),k(v,"placeholder","Enter your Nostr event JSON here, or click 'Generate Template' to start with a template..."),k(v,"spellcheck","false"),k(y,"class","compose-editor svelte-46pmgb"),k(t,"class","compose-view svelte-46pmgb")},m(r,h){f(r,t,h),d(t,n),d(n,i),d(n,o),d(n,s),d(n,a),d(n,l),d(n,c),d(n,u),d(t,p),F&&F.m(t,null),d(t,m),d(t,y),d(y,v),C(v,e[0]),f(r,b,h),oe(I,r,h),x=!0,B||(S=[A(i,"click",e[7]),A(s,"click",e[4]),A(l,"click",e[5]),A(u,"click",e[6]),A(v,"input",e[13])],B=!0)},p(e,[n]){e[1]?F?F.p(e,n):(F=Ry(e),F.c(),F.m(t,m)):F&&(F.d(1),F=null),1&n&&C(v,e[0]);const r={};4&n&&(r.userPubkey=e[2]),!E&&8&n&&(E=!0,r.isOpen=e[3],G(()=>E=!1)),I.$set(r)},i(e){x||(X(I.$$.fragment,e),x=!0)},o(e){ee(I.$$.fragment,e),x=!1},d(e){e&&h(t),F&&F.d(),e&&h(b),se(I,e),B=!1,r(S)}}}function Py(e,t,n){let{composeEventJson:r=""}=t,{userPubkey:i=""}=t,{userRole:o=""}=t,{policyEnabled:s=!1}=t,{publishError:a=""}=t;const l=U();let c=!1;return e.$$set=e=>{"composeEventJson"in e&&n(0,r=e.composeEventJson),"userPubkey"in e&&n(2,i=e.userPubkey),"userRole"in e&&n(11,o=e.userRole),"policyEnabled"in e&&n(12,s=e.policyEnabled),"publishError"in e&&n(1,a=e.publishError)},[r,a,i,c,function(){l("reformatJson")},function(){l("signEvent")},function(){l("publishEvent")},function(){n(3,c=!0)},function(e){const{kind:t,template:i}=e.detail;n(0,r=JSON.stringify(i,null,2)),l("templateSelected",{kind:t,template:i})},function(){n(3,c=!1)},function(){n(1,a=""),l("clearError")},o,s,function(){r=this.value,n(0,r)},function(e){c=e,n(3,c)}]}class Uy extends ce{constructor(e){super(),le(this,e,Py,$y,o,{composeEventJson:0,userPubkey:2,userRole:11,policyEnabled:12,publishError:1})}}function Ty(e,t,n){const r=e.slice();return r[23]=t[n],r}function Ny(t){let n,r,i,o,s,a;return{c(){n=g("div"),r=g("p"),r.textContent="Please log in to access sprocket management.",i=w(),o=g("button"),o.textContent="Log In",k(r,"class","svelte-fiaj1r"),k(o,"class","login-btn svelte-fiaj1r"),k(n,"class","login-prompt svelte-fiaj1r")},m(e,l){f(e,n,l),d(n,r),d(n,i),d(n,o),s||(a=A(o,"click",t[18]),s=!0)},p:e,d(e){e&&h(n),s=!1,a()}}}function Ly(e){let t,n,r,i,o,s,a,l,c,u=(e[2]||"none")+"";return{c(){t=g("div"),n=g("p"),n.textContent="❌ Owner permission required for sprocket management.",r=w(),i=g("p"),i.innerHTML='To enable sprocket functionality, set the ORLY_OWNERS environment variable with your npub when starting the relay.',o=w(),s=g("p"),a=y("Current user role: "),l=g("strong"),c=y(u),k(n,"class","svelte-fiaj1r"),k(i,"class","svelte-fiaj1r"),k(s,"class","svelte-fiaj1r"),k(t,"class","permission-denied svelte-fiaj1r")},m(e,u){f(e,t,u),d(t,n),d(t,r),d(t,i),d(t,o),d(t,s),d(s,a),d(s,l),d(l,c)},p(e,t){4&t&&u!==(u=(e[2]||"none")+"")&&E(c,u)},d(e){e&&h(t)}}}function Oy(e){let t,n,i,o,s,a,l,c,u,m,v,b,I,x,B,S,Q,D,R,$,P,U,T,N,L,O,M,_,H,j,G,q,K,J,V,Y,z,W,Z,X,ee,te,ne,re,ie,oe,se,ae,le,ce,ue,de,fe,he,pe,ge,me=e[3]?.is_running?"🟢 Running":"🔴 Stopped",ye=e[3]?.script_exists?"✅ Exists":"❌ Not found",we=e[3]?.pid&&My(e),ve=e[6]&&_y(e),Ae=e[8],be=[];for(let t=0;t{"isLoggedIn"in e&&n(1,r=e.isLoggedIn),"userRole"in e&&n(2,i=e.userRole),"sprocketStatus"in e&&n(3,o=e.sprocketStatus),"isLoadingSprocket"in e&&n(4,s=e.isLoadingSprocket),"sprocketUploadFile"in e&&n(5,a=e.sprocketUploadFile),"sprocketScript"in e&&n(0,l=e.sprocketScript),"sprocketMessage"in e&&n(6,c=e.sprocketMessage),"sprocketMessageType"in e&&n(7,u=e.sprocketMessageType),"sprocketVersions"in e&&n(8,d=e.sprocketVersions)},[l,r,i,o,s,a,c,u,d,function(){f("restartSprocket")},function(){f("deleteSprocket")},function(e){f("sprocketFileSelect",e)},function(){f("uploadSprocketScript")},function(){f("saveSprocket")},function(){f("loadSprocket")},function(){f("loadVersions")},h,p,function(){f("openLoginModal")},function(){l=this.value,n(0,l)},e=>h(e),e=>p(e.name)]}class Jy extends ce{constructor(e){super(),le(this,e,Ky,qy,o,{isLoggedIn:1,userRole:2,sprocketStatus:3,isLoadingSprocket:4,sprocketUploadFile:5,sprocketScript:0,sprocketMessage:6,sprocketMessageType:7,sprocketVersions:8})}}function Vy(e,t,n){const r=e.slice();return r[26]=t[n],r}function Yy(e,t,n){const r=e.slice();return r[29]=t[n],r}function zy(e,t,n){const r=e.slice();return r[32]=t[n],r}function Wy(t){let n,r,i,o,s,a;return{c(){n=g("div"),r=g("p"),r.textContent="Please log in to access policy configuration.",i=w(),o=g("button"),o.textContent="Log In",k(r,"class","svelte-gkxvxc"),k(o,"class","login-btn svelte-gkxvxc"),k(n,"class","login-prompt svelte-gkxvxc")},m(e,l){f(e,n,l),d(n,r),d(n,i),d(n,o),s||(a=A(o,"click",t[16]),s=!0)},p:e,d(e){e&&h(n),s=!1,a()}}}function Zy(e){let t,n,r,i,o,s,a,l,c,u=(e[3]||"none")+"";return{c(){t=g("div"),n=g("p"),n.textContent="Policy configuration requires owner or policy admin permissions.",r=w(),i=g("p"),i.innerHTML='To become a policy admin, ask an existing policy admin to add your pubkey\n to the policy_admins list.',o=w(),s=g("p"),a=y("Current user role: "),l=g("strong"),c=y(u),k(n,"class","svelte-gkxvxc"),k(i,"class","svelte-gkxvxc"),k(s,"class","svelte-gkxvxc"),k(t,"class","permission-denied svelte-gkxvxc")},m(e,u){f(e,t,u),d(t,n),d(t,r),d(t,i),d(t,o),d(t,s),d(s,a),d(s,l),d(l,c)},p(e,t){8&t[0]&&u!==(u=(e[3]||"none")+"")&&E(c,u)},d(e){e&&h(t)}}}function Xy(e){let t,n,i,o,s,a,l,c,u,p,m,v,b,I,x,B,S,Q,D,R,$,P,U,T,N,L,O,M,_,H,j,G,q,K,J,V,Y,z,W,Z,X,ee,te,ne,re,ie,oe,se,ae,le,ce,ue,de,fe,he,pe,ge,me,ye,we,ve,Ae,be,ke,Ie,Ee,Ce,xe,Be,Se,Fe,Qe,De,Re,$e,Pe=e[5]?"Policy Enabled":"Policy Disabled",Ue=e[10].length+"",Te=e[4]&&ew(),Ne=e[9].length>0&&tw(e),Le=e[7]&&rw(e);function Oe(e,t){return 0===e[1].length?ow:iw}let Me=Oe(e),_e=Me(e);function He(e,t){return 0===e[10].length?lw:aw}let je=He(e),Ge=je(e);return{c(){t=g("div"),n=g("div"),i=g("h3"),i.textContent="Policy Editor",o=w(),s=g("div"),a=g("span"),l=y(Pe),c=w(),Te&&Te.c(),u=w(),p=g("div"),p.innerHTML='

    Edit the policy JSON below and click "Save & Publish" to update the relay's policy configuration.\n Changes are applied immediately after validation.

    \n

    Policy updates are published as kind 12345 events and require policy admin permissions.

    ',m=w(),v=g("div"),b=g("textarea"),I=w(),Ne&&Ne.c(),x=w(),B=g("div"),S=g("button"),Q=y("Load Current"),D=w(),R=g("button"),$=y("Format JSON"),P=w(),U=g("button"),T=y("Validate"),N=w(),L=g("button"),O=y("Save & Publish"),M=w(),Le&&Le.c(),_=w(),H=g("div"),j=g("h3"),j.textContent="Policy Administrators",G=w(),q=g("div"),q.innerHTML='

    Policy admins can update the relay's policy configuration via kind 12345 events.\n Their follows get whitelisted if policy_follow_whitelist_enabled is true in the policy.

    \n

    Note: Policy admins are separate from relay admins (ORLY_ADMINS).\n Changes here update the JSON editor - click "Save & Publish" to apply.

    ',K=w(),J=g("div"),_e.c(),V=w(),Y=g("div"),z=g("input"),W=w(),Z=g("button"),X=y("+ Add Admin"),te=w(),ne=g("div"),re=g("h3"),re.textContent="Policy Follow Whitelist",ie=w(),oe=g("div"),oe.innerHTML='

    Pubkeys followed by policy admins (kind 3 events).\n These get automatic read+write access when rules have write_allow_follows: true.

    ',se=w(),ae=g("div"),le=g("span"),ce=y(Ue),ue=y(" pubkey(s) in whitelist"),de=w(),fe=g("button"),he=y("🔄 Refresh Follows"),pe=w(),ge=g("div"),Ge.c(),me=w(),ye=g("div"),we=g("h3"),we.textContent="Policy Reference",ve=w(),Ae=g("div"),be=g("h4"),be.textContent="Structure Overview",ke=w(),Ie=g("ul"),Ie.innerHTML='
  • kind.whitelist - Only allow these event kinds (takes precedence)
  • \n
  • kind.blacklist - Deny these event kinds (if no whitelist)
  • \n
  • global - Rules applied to all events
  • \n
  • rules - Per-kind rules (keyed by kind number as string)
  • \n
  • default_policy - "allow" or "deny" when no rules match
  • \n
  • policy_admins - Hex pubkeys that can update policy
  • \n
  • policy_follow_whitelist_enabled - Enable follow-based access
  • ',Ee=w(),Ce=g("h4"),Ce.textContent="Rule Fields",xe=w(),Be=g("ul"),Be.innerHTML='
  • description - Human-readable rule description
  • \n
  • write_allow / write_deny - Pubkey lists for write access
  • \n
  • read_allow / read_deny - Pubkey lists for read access
  • \n
  • write_allow_follows - Grant access to policy admin follows
  • \n
  • size_limit - Max total event size in bytes
  • \n
  • content_limit - Max content field size in bytes
  • \n
  • max_expiry - Max expiry offset in seconds
  • \n
  • max_age_of_event - Max age of created_at in seconds
  • \n
  • max_age_event_in_future - Max future offset in seconds
  • \n
  • must_have_tags - Required tag letters (e.g., ["d", "t"])
  • \n
  • tag_validation - Regex patterns for tag values
  • \n
  • script - Path to external validation script
  • ',Se=w(),Fe=g("h4"),Fe.textContent="Example Policy",Qe=w(),De=g("pre"),De.textContent=`${e[20]}`,k(i,"class","svelte-gkxvxc"),k(a,"class","status-badge svelte-gkxvxc"),F(a,"enabled",e[5]),k(s,"class","policy-status svelte-gkxvxc"),k(n,"class","policy-header svelte-gkxvxc"),k(p,"class","policy-info svelte-gkxvxc"),k(b,"class","policy-editor svelte-gkxvxc"),k(b,"placeholder","Loading policy configuration..."),b.disabled=e[6],k(b,"spellcheck","false"),k(v,"class","editor-container svelte-gkxvxc"),k(S,"class","policy-btn load-btn svelte-gkxvxc"),S.disabled=e[6],k(R,"class","policy-btn format-btn svelte-gkxvxc"),R.disabled=e[6],k(U,"class","policy-btn validate-btn svelte-gkxvxc"),U.disabled=e[6],k(L,"class","policy-btn save-btn svelte-gkxvxc"),L.disabled=e[6],k(B,"class","policy-actions svelte-gkxvxc"),k(t,"class","policy-section svelte-gkxvxc"),k(q,"class","policy-info svelte-gkxvxc"),k(J,"class","admin-list svelte-gkxvxc"),k(z,"type","text"),k(z,"placeholder","npub or hex pubkey"),z.disabled=e[6],k(z,"class","svelte-gkxvxc"),k(Z,"class","policy-btn add-btn svelte-gkxvxc"),Z.disabled=ee=e[6]||!e[11].trim(),k(Y,"class","add-admin svelte-gkxvxc"),k(H,"class","policy-section svelte-gkxvxc"),k(oe,"class","policy-info svelte-gkxvxc"),k(le,"class","follows-count svelte-gkxvxc"),k(fe,"class","policy-btn refresh-btn svelte-gkxvxc"),fe.disabled=e[6],k(ae,"class","follows-header svelte-gkxvxc"),k(ge,"class","follows-list svelte-gkxvxc"),k(ne,"class","policy-section svelte-gkxvxc"),k(be,"class","svelte-gkxvxc"),k(Ie,"class","field-list svelte-gkxvxc"),k(Ce,"class","svelte-gkxvxc"),k(Be,"class","field-list svelte-gkxvxc"),k(Fe,"class","svelte-gkxvxc"),k(De,"class","example-json svelte-gkxvxc"),k(Ae,"class","reference-content svelte-gkxvxc"),k(ye,"class","policy-section svelte-gkxvxc")},m(r,h){f(r,t,h),d(t,n),d(n,i),d(n,o),d(n,s),d(s,a),d(a,l),d(s,c),Te&&Te.m(s,null),d(t,u),d(t,p),d(t,m),d(t,v),d(v,b),C(b,e[0]),d(t,I),Ne&&Ne.m(t,null),d(t,x),d(t,B),d(B,S),d(S,Q),d(B,D),d(B,R),d(R,$),d(B,P),d(B,U),d(U,T),d(B,N),d(B,L),d(L,O),d(t,M),Le&&Le.m(t,null),f(r,_,h),f(r,H,h),d(H,j),d(H,G),d(H,q),d(H,K),d(H,J),_e.m(J,null),d(H,V),d(H,Y),d(Y,z),C(z,e[11]),d(Y,W),d(Y,Z),d(Z,X),f(r,te,h),f(r,ne,h),d(ne,re),d(ne,ie),d(ne,oe),d(ne,se),d(ne,ae),d(ae,le),d(le,ce),d(le,ue),d(ae,de),d(ae,fe),d(fe,he),d(ne,pe),d(ne,ge),Ge.m(ge,null),f(r,me,h),f(r,ye,h),d(ye,we),d(ye,ve),d(ye,Ae),d(Ae,be),d(Ae,ke),d(Ae,Ie),d(Ae,Ee),d(Ae,Ce),d(Ae,xe),d(Ae,Be),d(Ae,Se),d(Ae,Fe),d(Ae,Qe),d(Ae,De),Re||($e=[A(b,"input",e[21]),A(S,"click",e[12]),A(R,"click",e[15]),A(U,"click",e[13]),A(L,"click",e[14]),A(z,"input",e[23]),A(z,"keydown",e[24]),A(Z,"click",e[18]),A(fe,"click",e[17])],Re=!0)},p(e,n){32&n[0]&&Pe!==(Pe=e[5]?"Policy Enabled":"Policy Disabled")&&E(l,Pe),32&n[0]&&F(a,"enabled",e[5]),e[4]?Te||(Te=ew(),Te.c(),Te.m(s,null)):Te&&(Te.d(1),Te=null),64&n[0]&&(b.disabled=e[6]),1&n[0]&&C(b,e[0]),e[9].length>0?Ne?Ne.p(e,n):(Ne=tw(e),Ne.c(),Ne.m(t,x)):Ne&&(Ne.d(1),Ne=null),64&n[0]&&(S.disabled=e[6]),64&n[0]&&(R.disabled=e[6]),64&n[0]&&(U.disabled=e[6]),64&n[0]&&(L.disabled=e[6]),e[7]?Le?Le.p(e,n):(Le=rw(e),Le.c(),Le.m(t,null)):Le&&(Le.d(1),Le=null),Me===(Me=Oe(e))&&_e?_e.p(e,n):(_e.d(1),_e=Me(e),_e&&(_e.c(),_e.m(J,null))),64&n[0]&&(z.disabled=e[6]),2048&n[0]&&z.value!==e[11]&&C(z,e[11]),2112&n[0]&&ee!==(ee=e[6]||!e[11].trim())&&(Z.disabled=ee),1024&n[0]&&Ue!==(Ue=e[10].length+"")&&E(ce,Ue),64&n[0]&&(fe.disabled=e[6]),je===(je=He(e))&&Ge?Ge.p(e,n):(Ge.d(1),Ge=je(e),Ge&&(Ge.c(),Ge.m(ge,null)))},d(e){e&&h(t),Te&&Te.d(),Ne&&Ne.d(),Le&&Le.d(),e&&h(_),e&&h(H),_e.d(),e&&h(te),e&&h(ne),Ge.d(),e&&h(me),e&&h(ye),Re=!1,r($e)}}}function ew(e){let t;return{c(){t=g("span"),t.textContent="Policy Admin",k(t,"class","admin-badge svelte-gkxvxc")},m(e,n){f(e,t,n)},d(e){e&&h(t)}}}function tw(e){let t,n,r,i,o=e[9],s=[];for(let t=0;t{"isLoggedIn"in e&&n(2,r=e.isLoggedIn),"userRole"in e&&n(3,i=e.userRole),"isPolicyAdmin"in e&&n(4,o=e.isPolicyAdmin),"policyEnabled"in e&&n(5,s=e.policyEnabled),"policyJson"in e&&n(0,a=e.policyJson),"isLoadingPolicy"in e&&n(6,l=e.isLoadingPolicy),"policyMessage"in e&&n(7,c=e.policyMessage),"policyMessageType"in e&&n(8,u=e.policyMessageType),"validationErrors"in e&&n(9,d=e.validationErrors),"policyAdmins"in e&&n(1,f=e.policyAdmins),"policyFollows"in e&&n(10,h=e.policyFollows)},e.$$.update=()=>{if(1&e.$$.dirty[0])try{if(a){const e=JSON.parse(a);n(1,f=e.policy_admins||[])}}catch(e){}},[a,f,r,i,o,s,l,c,u,d,h,g,function(){p("loadPolicy")},function(){p("validatePolicy")},function(){p("savePolicy")},function(){p("formatJson")},function(){p("openLoginModal")},function(){p("refreshFollows")},m,y,'{\n "kind": {\n "whitelist": [0, 1, 3, 6, 7, 10002],\n "blacklist": []\n },\n "global": {\n "description": "Global rules applied to all events",\n "size_limit": 65536,\n "max_age_of_event": 86400,\n "max_age_event_in_future": 300\n },\n "rules": {\n "1": {\n "description": "Kind 1 (short text notes)",\n "content_limit": 8192,\n "write_allow_follows": true\n },\n "30023": {\n "description": "Long-form articles",\n "content_limit": 100000,\n "tag_validation": {\n "d": "^[a-z0-9-]{1,64}$",\n "t": "^[a-z0-9-]{1,32}$"\n }\n }\n },\n "default_policy": "allow",\n "policy_admins": [""],\n "policy_follow_whitelist_enabled": true\n}',function(){a=this.value,n(0,a)},e=>y(e),function(){g=this.value,n(11,g)},e=>"Enter"===e.key&&m()]}class fw extends ce{constructor(e){super(),le(this,e,dw,uw,o,{isLoggedIn:2,userRole:3,isPolicyAdmin:4,policyEnabled:5,policyJson:0,isLoadingPolicy:6,policyMessage:7,policyMessageType:8,validationErrors:9,policyAdmins:1,policyFollows:10},null,[-1,-1])}}const{window:hw}=u;function pw(e,t,n){const r=e.slice();return r[57]=t[n],r}function gw(e,t,n){const r=e.slice();return r[54]=t[n],r}function mw(t){let n,r,i,o,s,a;return{c(){n=g("div"),r=g("p"),r.textContent="Please log in to view your Blossom storage.",i=w(),o=g("button"),o.textContent="Log In",k(r,"class","svelte-on0yal"),k(o,"class","login-btn svelte-on0yal"),k(n,"class","login-prompt svelte-on0yal")},m(e,l){f(e,n,l),d(n,r),d(n,i),d(n,o),s||(a=A(o,"click",t[20]),s=!0)},p:e,d(e){e&&h(n),s=!1,a()}}}function yw(e){let t,n,r,i,o,s,a,l,c,u,p,m,v,b,I=e[0]||e[12]?"Loading...":"Refresh";function C(e,t){return e[13]?Aw:e[10]?vw:ww}let x=C(e),B=x(e),S=e[14]&&!e[10]&&!e[13]&&kw(e),F=!e[10]&&!e[13]&&Iw(e),Q=e[2]&&Cw(e);function D(e,t){return e[10]&&!e[13]?Bw:xw}let R=D(e),$=R(e);return{c(){t=g("div"),n=g("div"),B.c(),r=w(),i=g("div"),S&&S.c(),o=w(),s=g("button"),a=y("🔄 "),l=y(I),u=w(),F&&F.c(),p=w(),Q&&Q.c(),m=w(),$.c(),k(s,"class","refresh-btn svelte-on0yal"),s.disabled=c=e[0]||e[12],k(i,"class","header-buttons svelte-on0yal"),k(n,"class","header-section svelte-on0yal"),k(t,"class","blossom-view svelte-on0yal")},m(c,h){f(c,t,h),d(t,n),B.m(n,null),d(n,r),d(n,i),S&&S.m(i,null),d(i,o),d(i,s),d(s,a),d(s,l),d(t,u),F&&F.m(t,null),d(t,p),Q&&Q.m(t,null),d(t,m),$.m(t,null),v||(b=A(s,"click",e[30]),v=!0)},p(e,a){x===(x=C(e))&&B?B.p(e,a):(B.d(1),B=x(e),B&&(B.c(),B.m(n,r))),!e[14]||e[10]||e[13]?S&&(S.d(1),S=null):S?S.p(e,a):(S=kw(e),S.c(),S.m(i,o)),4097&a[0]&&I!==(I=e[0]||e[12]?"Loading...":"Refresh")&&E(l,I),4097&a[0]&&c!==(c=e[0]||e[12])&&(s.disabled=c),e[10]||e[13]?F&&(F.d(1),F=null):F?F.p(e,a):(F=Iw(e),F.c(),F.m(t,p)),e[2]?Q?Q.p(e,a):(Q=Cw(e),Q.c(),Q.m(t,m)):Q&&(Q.d(1),Q=null),R===(R=D(e))&&$?$.p(e,a):($.d(1),$=R(e),$&&($.c(),$.m(t,null)))},d(e){e&&h(t),B.d(),S&&S.d(),F&&F.d(),Q&&Q.d(),$.d(),v=!1,b()}}}function ww(t){let n;return{c(){n=g("h3"),n.textContent="Blossom Media Storage",k(n,"class","svelte-on0yal")},m(e,t){f(e,n,t)},p:e,d(e){e&&h(n)}}}function vw(t){let n,r,i,o,s;return{c(){n=g("button"),n.textContent="← Back",r=w(),i=g("h3"),i.textContent="All Users Storage",k(n,"class","back-btn svelte-on0yal"),k(i,"class","svelte-on0yal")},m(e,a){f(e,n,a),f(e,r,a),f(e,i,a),o||(s=A(n,"click",t[27]),o=!0)},p:e,d(e){e&&h(n),e&&h(r),e&&h(i),o=!1,s()}}}function Aw(e){let t,n,r,i,o,s,a,l=(e[13].profile?.name||rv(e[25](e[13].pubkey)))+"",c=e[13].profile?.picture&&bw(e);return{c(){t=g("button"),t.textContent="← Back",n=w(),r=g("h3"),c&&c.c(),i=w(),o=y(l),k(t,"class","back-btn svelte-on0yal"),k(r,"class","user-header svelte-on0yal")},m(l,u){f(l,t,u),f(l,n,u),f(l,r,u),c&&c.m(r,null),d(r,i),d(r,o),s||(a=A(t,"click",e[29]),s=!0)},p(e,t){e[13].profile?.picture?c?c.p(e,t):(c=bw(e),c.c(),c.m(r,i)):c&&(c.d(1),c=null),8192&t[0]&&l!==(l=(e[13].profile?.name||rv(e[25](e[13].pubkey)))+"")&&E(o,l)},d(e){e&&h(t),e&&h(n),e&&h(r),c&&c.d(),s=!1,a()}}}function bw(e){let t,n;return{c(){t=g("img"),a(t.src,n=e[13].profile.picture)||k(t,"src",n),k(t,"alt",""),k(t,"class","header-avatar svelte-on0yal")},m(e,n){f(e,t,n)},p(e,r){8192&r[0]&&!a(t.src,n=e[13].profile.picture)&&k(t,"src",n)},d(e){e&&h(t)}}}function kw(e){let t,n,r,i;return{c(){t=g("button"),n=y("Admin"),k(t,"class","admin-btn svelte-on0yal"),t.disabled=e[0]},m(o,s){f(o,t,s),d(t,n),r||(i=A(t,"click",e[26]),r=!0)},p(e,n){1&n[0]&&(t.disabled=e[0])},d(e){e&&h(t),r=!1,i()}}}function Iw(e){let t,n,i,o,s,a,l,c,u,p,m=e[3].length>0&&Ew(e);return{c(){t=g("div"),n=g("span"),n.textContent="Upload new files",i=w(),o=g("input"),s=w(),m&&m.c(),a=w(),l=g("button"),c=y("Select Files"),k(n,"class","upload-label svelte-on0yal"),k(o,"type","file"),o.multiple=!0,k(o,"class","file-input-hidden svelte-on0yal"),k(l,"class","select-btn svelte-on0yal"),l.disabled=e[4],k(t,"class","upload-section svelte-on0yal")},m(r,h){f(r,t,h),d(t,n),d(t,i),d(t,o),e[39](o),d(t,s),m&&m.m(t,null),d(t,a),d(t,l),d(l,c),u||(p=[A(o,"change",e[22]),A(l,"click",e[23])],u=!0)},p(e,n){e[3].length>0?m?m.p(e,n):(m=Ew(e),m.c(),m.m(t,a)):m&&(m.d(1),m=null),16&n[0]&&(l.disabled=e[4])},d(n){n&&h(t),e[39](null),m&&m.d(),u=!1,r(p)}}}function Ew(e){let t,n,r,i,o,s,a,l,c=e[3].length+"",u=(e[4]?e[5]:"Upload")+"";return{c(){t=g("span"),n=y(c),r=y(" file(s) selected"),i=w(),o=g("button"),s=y(u),k(t,"class","selected-count svelte-on0yal"),k(o,"class","upload-btn svelte-on0yal"),o.disabled=e[4]},m(c,u){f(c,t,u),d(t,n),d(t,r),f(c,i,u),f(c,o,u),d(o,s),a||(l=A(o,"click",e[24]),a=!0)},p(e,t){8&t[0]&&c!==(c=e[3].length+"")&&E(n,c),48&t[0]&&u!==(u=(e[4]?e[5]:"Upload")+"")&&E(s,u),16&t[0]&&(o.disabled=e[4])},d(e){e&&h(t),e&&h(i),e&&h(o),a=!1,l()}}}function Cw(e){let t,n;return{c(){t=g("div"),n=y(e[2]),k(t,"class","error-message svelte-on0yal")},m(e,r){f(e,t,r),d(t,n)},p(e,t){4&t[0]&&E(n,e[2])},d(e){e&&h(t)}}}function xw(e){let t,n,r;function i(e,r){return 1&r[0]&&(t=null),null==t&&(t=!(!e[0]||0!==e[31]().length)),t?Qw:(null==n&&(n=!(0!==e[31]().length)),n?Fw:Sw)}let o=i(e,[-1,-1]),s=o(e);return{c(){s.c(),r=v()},m(e,t){s.m(e,t),f(e,r,t)},p(e,t){o===(o=i(e,t))&&s?s.p(e,t):(s.d(1),s=o(e),s&&(s.c(),s.m(r.parentNode,r)))},d(e){s.d(e),e&&h(r)}}}function Bw(e){let t;function n(e,t){return e[12]?Nw:0===e[11].length?Tw:Uw}let r=n(e),i=r(e);return{c(){i.c(),t=v()},m(e,n){i.m(e,n),f(e,t,n)},p(e,o){r===(r=n(e))&&i?i.p(e,o):(i.d(1),i=r(e),i&&(i.c(),i.m(t.parentNode,t)))},d(e){i.d(e),e&&h(t)}}}function Sw(e){let t,n=e[31](),r=[];for(let t=0;tNo users have uploaded files yet.

    ",k(n,"class","empty-state svelte-on0yal")},m(e,t){f(e,n,t)},p:e,d(e){e&&h(n)}}}function Nw(t){let n;return{c(){n=g("div"),n.textContent="Loading user statistics...",k(n,"class","loading svelte-on0yal")},m(e,t){f(e,n,t)},p:e,d(e){e&&h(n)}}}function Lw(t){let n;return{c(){n=g("div"),k(n,"class","user-avatar-placeholder svelte-on0yal")},m(e,t){f(e,n,t)},p:e,d(e){e&&h(n)}}}function Ow(e){let t,n;return{c(){t=g("img"),a(t.src,n=e[54].profile.picture)||k(t,"src",n),k(t,"alt",""),k(t,"class","user-avatar svelte-on0yal")},m(e,n){f(e,t,n)},p(e,r){2048&r[0]&&!a(t.src,n=e[54].profile.picture)&&k(t,"src",n)},d(e){e&&h(t)}}}function Mw(e){let t,n,i,o,s,a,l,c,u,p,m,v,b,I,C,x,B,S,F,Q,D,R,$,P,U,T=(e[54].profile?.name||rv(e[25](e[54].pubkey)))+"",N=e[25](e[54].pubkey)+"",L=rv(e[25](e[54].pubkey))+"",O=e[54].blob_count+"",M=Ww(e[54].total_size_bytes)+"";function _(e,t){return e[54].profile?.picture?Ow:Lw}let H=_(e),j=H(e);function G(){return e[40](e[54])}function q(...t){return e[41](e[54],...t)}return{c(){t=g("div"),n=g("div"),j.c(),i=w(),o=g("div"),s=g("div"),a=y(T),l=w(),c=g("div"),u=g("span"),p=y(N),m=w(),v=g("span"),b=y(L),C=w(),x=g("div"),B=g("span"),S=y(O),F=y(" files"),Q=w(),D=g("span"),R=y(M),$=w(),k(n,"class","user-avatar-container svelte-on0yal"),k(s,"class","user-name svelte-on0yal"),k(u,"class","npub-full svelte-on0yal"),k(v,"class","npub-truncated svelte-on0yal"),k(c,"class","user-npub svelte-on0yal"),k(c,"title",I=e[54].pubkey),k(o,"class","user-info svelte-on0yal"),k(B,"class","blob-count svelte-on0yal"),k(D,"class","total-size svelte-on0yal"),k(x,"class","user-stats svelte-on0yal"),k(t,"class","user-stat-item svelte-on0yal"),k(t,"role","button"),k(t,"tabindex","0")},m(e,r){f(e,t,r),d(t,n),j.m(n,null),d(t,i),d(t,o),d(o,s),d(s,a),d(o,l),d(o,c),d(c,u),d(u,p),d(c,m),d(c,v),d(v,b),d(t,C),d(t,x),d(x,B),d(B,S),d(B,F),d(x,Q),d(x,D),d(D,R),d(t,$),P||(U=[A(t,"click",G),A(t,"keypress",q)],P=!0)},p(t,r){H===(H=_(e=t))&&j?j.p(e,r):(j.d(1),j=H(e),j&&(j.c(),j.m(n,null))),2048&r[0]&&T!==(T=(e[54].profile?.name||rv(e[25](e[54].pubkey)))+"")&&E(a,T),2048&r[0]&&N!==(N=e[25](e[54].pubkey)+"")&&E(p,N),2048&r[0]&&L!==(L=rv(e[25](e[54].pubkey))+"")&&E(b,L),2048&r[0]&&I!==(I=e[54].pubkey)&&k(c,"title",I),2048&r[0]&&O!==(O=e[54].blob_count+"")&&E(S,O),2048&r[0]&&M!==(M=Ww(e[54].total_size_bytes)+"")&&E(R,M)},d(e){e&&h(t),j.d(),P=!1,r(U)}}}function _w(e){let t,n,i,o,s,a,l,c,u,p,m,v,I,C,x,B,S,F,Q,D,R,$,P,U,T,N,L,O,M,_,H,j,G,q,K,J,V,Y,z,W,Z,X,ee,te=Xw(e[8].sha256)+"",ne=(e[8].type||"unknown")+"",re="image"===ev(e[8].type),ie=Ww(e[8].size)+"",oe=Zw(e[8].uploaded)+"",se=re&&Hw(e);function ae(e,t){return 256&t[0]&&(B=null),256&t[0]&&(S=null),256&t[0]&&(F=null),null==B&&(B=!("image"!==ev(e[8].type))),B?Kw:(null==S&&(S=!("video"!==ev(e[8].type))),S?qw:(null==F&&(F=!("audio"!==ev(e[8].type))),F?Gw:jw))}let le=ae(e,[-1,-1]),ce=le(e);return{c(){t=g("div"),n=g("div"),i=g("div"),o=g("div"),s=g("span"),a=y(te),l=w(),c=g("span"),u=y(ne),p=w(),m=g("div"),se&&se.c(),v=w(),I=g("button"),I.textContent="X",C=w(),x=g("div"),ce.c(),Q=w(),D=g("div"),R=g("div"),$=g("span"),P=y("Size: "),U=y(ie),T=w(),N=g("span"),L=y("Uploaded: "),O=y(oe),M=w(),_=g("div"),H=g("input"),G=w(),q=g("button"),q.textContent="Copy",K=w(),J=g("div"),V=g("a"),Y=y("Open in New Tab"),W=w(),Z=g("button"),Z.textContent="Delete",k(s,"class","modal-hash svelte-on0yal"),k(c,"class","modal-type svelte-on0yal"),k(o,"class","modal-title svelte-on0yal"),k(I,"class","close-btn svelte-on0yal"),k(m,"class","modal-controls svelte-on0yal"),k(i,"class","modal-header svelte-on0yal"),k(x,"class","modal-body svelte-on0yal"),k(R,"class","blob-details svelte-on0yal"),k(H,"type","text"),H.readOnly=!0,H.value=j=nv(e[8]),k(H,"class","blob-url-input svelte-on0yal"),k(q,"class","copy-btn svelte-on0yal"),k(_,"class","blob-url-section svelte-on0yal"),k(V,"href",z=nv(e[8])),k(V,"target","_blank"),k(V,"rel","noopener noreferrer"),k(V,"class","action-btn svelte-on0yal"),k(Z,"class","action-btn danger svelte-on0yal"),k(J,"class","modal-actions svelte-on0yal"),k(D,"class","modal-footer svelte-on0yal"),k(n,"class","modal-content svelte-on0yal"),k(n,"role","dialog"),k(t,"class","modal-overlay svelte-on0yal"),k(t,"role","button"),k(t,"tabindex","0")},m(r,h){f(r,t,h),d(t,n),d(n,i),d(i,o),d(o,s),d(s,a),d(o,l),d(o,c),d(c,u),d(i,p),d(i,m),se&&se.m(m,null),d(m,v),d(m,I),d(n,C),d(n,x),ce.m(x,null),d(n,Q),d(n,D),d(D,R),d(R,$),d($,P),d($,U),d(R,T),d(R,N),d(N,L),d(N,O),d(D,M),d(D,_),d(_,H),d(_,G),d(_,q),d(D,K),d(D,J),d(J,V),d(V,Y),d(J,W),d(J,Z),X||(ee=[A(I,"click",e[16]),A(H,"click",iv),A(q,"click",e[45]),A(Z,"click",e[46]),A(n,"click",b(e[37])),A(n,"keypress",b(e[38])),A(t,"click",e[16]),A(t,"keypress",e[47])],X=!0)},p(e,t){256&t[0]&&te!==(te=Xw(e[8].sha256)+"")&&E(a,te),256&t[0]&&ne!==(ne=(e[8].type||"unknown")+"")&&E(u,ne),256&t[0]&&(re="image"===ev(e[8].type)),re?se?se.p(e,t):(se=Hw(e),se.c(),se.m(m,v)):se&&(se.d(1),se=null),le===(le=ae(e,t))&&ce?ce.p(e,t):(ce.d(1),ce=le(e),ce&&(ce.c(),ce.m(x,null))),256&t[0]&&ie!==(ie=Ww(e[8].size)+"")&&E(U,ie),256&t[0]&&oe!==(oe=Zw(e[8].uploaded)+"")&&E(O,oe),256&t[0]&&j!==(j=nv(e[8]))&&H.value!==j&&(H.value=j),256&t[0]&&z!==(z=nv(e[8]))&&k(V,"href",z)},d(e){e&&h(t),se&&se.d(),ce.d(),X=!1,r(ee)}}}function Hw(e){let t,n,i,o,s,a,l,c,u,p,m,v,b,I=Math.round(100*e[9])+"";return{c(){t=g("button"),n=y("-"),o=w(),s=g("span"),a=y(I),l=y("%"),c=w(),u=g("button"),p=y("+"),k(t,"class","zoom-btn svelte-on0yal"),t.disabled=i=e[9]<=Vw,k(s,"class","zoom-level svelte-on0yal"),k(u,"class","zoom-btn svelte-on0yal"),u.disabled=m=e[9]>=Yw},m(r,i){f(r,t,i),d(t,n),f(r,o,i),f(r,s,i),d(s,a),d(s,l),f(r,c,i),f(r,u,i),d(u,p),v||(b=[A(t,"click",e[18]),A(u,"click",e[17])],v=!0)},p(e,n){512&n[0]&&i!==(i=e[9]<=Vw)&&(t.disabled=i),512&n[0]&&I!==(I=Math.round(100*e[9])+"")&&E(a,I),512&n[0]&&m!==(m=e[9]>=Yw)&&(u.disabled=m)},d(e){e&&h(t),e&&h(o),e&&h(s),e&&h(c),e&&h(u),v=!1,r(b)}}}function jw(e){let t,n,r,i,o,s,a,l,c,u=tv(e[8].type)+"";return{c(){t=g("div"),n=g("div"),r=y(u),i=w(),o=g("p"),o.textContent="Preview not available for this file type.",s=w(),a=g("a"),l=y("Download File"),k(n,"class","file-icon svelte-on0yal"),k(a,"href",c=nv(e[8])),k(a,"target","_blank"),k(a,"rel","noopener noreferrer"),k(a,"class","download-link svelte-on0yal"),k(t,"class","file-preview svelte-on0yal")},m(e,c){f(e,t,c),d(t,n),d(n,r),d(t,i),d(t,o),d(t,s),d(t,a),d(a,l)},p(e,t){256&t[0]&&u!==(u=tv(e[8].type)+"")&&E(r,u),256&t[0]&&c!==(c=nv(e[8]))&&k(a,"href",c)},d(e){e&&h(t)}}}function Gw(e){let t,n,r;return{c(){t=g("div"),n=g("audio"),n.controls=!0,a(n.src,r=nv(e[8]))||k(n,"src",r),k(n,"class","svelte-on0yal"),k(t,"class","media-container audio svelte-on0yal")},m(e,r){f(e,t,r),d(t,n)},p(e,t){256&t[0]&&!a(n.src,r=nv(e[8]))&&k(n,"src",r)},d(e){e&&h(t)}}}function qw(e){let t,n,r,i;return{c(){t=g("div"),n=g("video"),r=g("track"),k(r,"kind","captions"),n.controls=!0,a(n.src,i=nv(e[8]))||k(n,"src",i),k(n,"class","svelte-on0yal"),k(t,"class","media-container svelte-on0yal")},m(e,i){f(e,t,i),d(t,n),d(n,r)},p(e,t){256&t[0]&&!a(n.src,i=nv(e[8]))&&k(n,"src",i)},d(e){e&&h(t)}}}function Kw(e){let t,n,r;return{c(){t=g("div"),n=g("img"),a(n.src,r=nv(e[8]))||k(n,"src",r),k(n,"alt","Blob content"),k(n,"class","svelte-on0yal"),k(t,"class","media-container svelte-on0yal"),x(t,"transform","scale("+e[9]+")")},m(e,r){f(e,t,r),d(t,n)},p(e,i){256&i[0]&&!a(n.src,r=nv(e[8]))&&k(n,"src",r),512&i[0]&&x(t,"transform","scale("+e[9]+")")},d(e){e&&h(t)}}}function Jw(t){let n,r,i,o;function s(e,t){return e[1]?yw:mw}let a=s(t),l=a(t),c=t[7]&&t[8]&&_w(t);return{c(){l.c(),n=w(),c&&c.c(),r=v()},m(e,s){l.m(e,s),f(e,n,s),c&&c.m(e,s),f(e,r,s),i||(o=A(hw,"keydown",t[19]),i=!0)},p(e,t){a===(a=s(e))&&l?l.p(e,t):(l.d(1),l=a(e),l&&(l.c(),l.m(n.parentNode,n))),e[7]&&e[8]?c?c.p(e,t):(c=_w(e),c.c(),c.m(r.parentNode,r)):c&&(c.d(1),c=null)},i:e,o:e,d(e){l.d(e),e&&h(n),c&&c.d(e),e&&h(r),i=!1,o()}}}const Vw=.25,Yw=4;async function zw(e,t,n=null){if(!e)return console.log("No signer available for Blossom auth"),null;try{const r=Math.floor(Date.now()/1e3),i=[["t",t],["expiration",(r+60).toString()]];n&&i.push(["x",n]);const o={kind:24242,created_at:r,tags:i,content:`Blossom ${t} operation`},s=await e.signEvent(o);return btoa(JSON.stringify(s)).replace(/\+/g,"-").replace(/\//g,"_")}catch(e){return console.error("Error creating Blossom auth:",e),null}}function Ww(e){if(!e)return"0 B";const t=["B","KB","MB","GB"];let n=0,r=e;for(;r>=1024&&ne.target.select();function ov(e,t,n){let r,i,{isLoggedIn:o=!1}=t,{userPubkey:s=""}=t,{userSigner:a=null}=t,{currentEffectiveRole:l=""}=t;const c=U();let u,d=[],f=!1,h="",p=[],g=!1,m="",y=!1,w=null,v=1,A=!1,b=[],k=!1,I=null,E=[],C=!1;async function x(){if(s){n(0,f=!0),n(2,h="");try{const e=`${window.location.origin}/blossom/list/${s}`,t=await zw(a,"list"),n=await fetch(e,{headers:t?{Authorization:`Nostr ${t}`}:{}});if(!n.ok)throw new Error(`Failed to load blobs: ${n.statusText}`);const r=await n.json();d=Array.isArray(r)?r:[],d.sort((e,t)=>(t.uploaded||0)-(e.uploaded||0)),console.log("Loaded blobs:",d)}catch(e){console.error("Error loading blobs:",e),n(2,h=e.message||"Failed to load blobs")}finally{n(0,f=!1)}}}function B(e){n(8,w=e),n(9,v=1),n(7,y=!0)}function S(){n(7,y=!1),n(8,w=null),n(9,v=1)}function F(){vVw&&n(9,v=Math.max(Vw,v-.25))}async function D(e){if(confirm(`Delete blob ${Xw(e.sha256)}?`))try{const t=`${window.location.origin}/blossom/${e.sha256}`,n=await zw(a,"delete",e.sha256),r=await fetch(t,{method:"DELETE",headers:n?{Authorization:`Nostr ${n}`}:{}});if(!r.ok)throw new Error(`Failed to delete: ${r.statusText}`);d=d.filter(t=>t.sha256!==e.sha256),w?.sha256===e.sha256&&S()}catch(e){console.error("Error deleting blob:",e),alert(`Failed to delete blob: ${e.message}`)}}async function R(){n(12,k=!0),n(2,h="");try{const e=`${window.location.origin}/blossom/admin/users`,t=await zw(a,"admin"),r=await fetch(e,{headers:t?{Authorization:`Nostr ${t}`}:{}});if(!r.ok)throw new Error(`Failed to load user stats: ${r.statusText}`);n(11,b=await r.json());for(const e of b)_h(e.pubkey).then(t=>{e.profile=t||{name:"",picture:""},n(11,b)}).catch(()=>{e.profile={name:"",picture:""}})}catch(e){console.error("Error fetching admin user stats:",e),n(2,h=e.message||"Failed to load user stats")}finally{n(12,k=!1)}}async function P(e){n(0,f=!0),n(2,h="");try{const t=`${window.location.origin}/blossom/list/${e}`,n=await zw(a,"list"),r=await fetch(t,{headers:n?{Authorization:`Nostr ${n}`}:{}});if(!r.ok)throw new Error(`Failed to load user blobs: ${r.statusText}`);E=await r.json(),E.sort((e,t)=>(t.uploaded||0)-(e.uploaded||0))}catch(e){console.error("Error loading user blobs:",e),n(2,h=e.message||"Failed to load user blobs")}finally{n(0,f=!1)}}async function N(e){n(13,I={pubkey:e.pubkey,profile:e.profile}),await P(e.pubkey)}$(()=>{r&&!C&&(n(36,C=!0),x())});return e.$$set=e=>{"isLoggedIn"in e&&n(32,o=e.isLoggedIn),"userPubkey"in e&&n(33,s=e.userPubkey),"userSigner"in e&&n(34,a=e.userSigner),"currentEffectiveRole"in e&&n(35,l=e.currentEffectiveRole)},e.$$.update=()=>{6&e.$$.dirty[1]&&n(1,r=o&&s),16&e.$$.dirty[1]&&n(14,i="admin"===l||"owner"===l),3&e.$$.dirty[0]|32&e.$$.dirty[1]&&(!r||C||f||(n(36,C=!0),x()))},[f,r,h,p,g,m,u,y,w,v,A,b,k,I,i,B,S,F,Q,function(e){y&&("Escape"===e.key?S():"+"===e.key||"="===e.key?F():"-"===e.key&&Q())},function(){c("openLoginModal")},D,function(e){n(3,p=Array.from(e.target.files))},function(){u?.click()},async function(){if(0===p.length)return;n(4,g=!0),n(2,h="");const e=[],t=[];for(let r=0;r0&&await x(),t.length>0&&n(2,h=`Failed to upload: ${t.map(e=>e.name).join(", ")}`)},function(e){try{return Iu(e)}catch(t){return Xw(e)}},function(){n(10,A=!0),R()},function(){n(10,A=!1),n(11,b=[]),n(13,I=null),E=[]},N,function(){n(13,I=null),E=[]},function(){I?P(I.pubkey):A?R():x()},function(){return I?E:d},o,s,a,l,C,function(t){T.call(this,e,t)},function(t){T.call(this,e,t)},function(e){L[e?"unshift":"push"](()=>{u=e,n(6,u)})},e=>N(e),(e,t)=>"Enter"===t.key&&N(e),e=>D(e),e=>B(e),(e,t)=>"Enter"===t.key&&B(e),()=>{navigator.clipboard.writeText(nv(w))},()=>D(w),e=>"Enter"===e.key&&S()]}class sv extends ce{constructor(e){super(),le(this,e,ov,Jw,o,{isLoggedIn:32,userPubkey:33,userSigner:34,currentEffectiveRole:35},null,[-1,-1])}}var av={},lv={},cv={};let uv;const dv=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];cv.getSymbolSize=function(e){if(!e)throw new Error('"version" cannot be null or undefined');if(e<1||e>40)throw new Error('"version" should be in range from 1 to 40');return 4*e+17},cv.getSymbolTotalCodewords=function(e){return dv[e]},cv.getBCHDigit=function(e){let t=0;for(;0!==e;)t++,e>>>=1;return t},cv.setToSJISFunction=function(e){if("function"!=typeof e)throw new Error('"toSJISFunc" is not a valid function.');uv=e},cv.isKanjiModeEnabled=function(){return void 0!==uv},cv.toSJIS=function(e){return uv(e)};var fv,hv={};function pv(){this.buffer=[],this.length=0}(fv=hv).L={bit:1},fv.M={bit:0},fv.Q={bit:3},fv.H={bit:2},fv.isValid=function(e){return e&&void 0!==e.bit&&e.bit>=0&&e.bit<4},fv.from=function(e,t){if(fv.isValid(e))return e;try{return function(e){if("string"!=typeof e)throw new Error("Param is not a string");switch(e.toLowerCase()){case"l":case"low":return fv.L;case"m":case"medium":return fv.M;case"q":case"quartile":return fv.Q;case"h":case"high":return fv.H;default:throw new Error("Unknown EC Level: "+e)}}(e)}catch(e){return t}},pv.prototype={get:function(e){const t=Math.floor(e/8);return 1==(this.buffer[t]>>>7-e%8&1)},put:function(e,t){for(let n=0;n>>t-n-1&1))},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var gv=pv;function mv(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}mv.prototype.set=function(e,t,n,r){const i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},mv.prototype.get=function(e,t){return this.data[e*this.size+t]},mv.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},mv.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var yv=mv,wv={};!function(e){const t=cv.getSymbolSize;e.getRowColCoords=function(e){if(1===e)return[];const n=Math.floor(e/7)+2,r=t(e),i=145===r?26:2*Math.ceil((r-13)/(2*n-2)),o=[r-7];for(let e=1;e=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){const n=e.size;let r=0,i=0,o=0,s=null,a=null;for(let l=0;l=5&&(r+=t+(i-5)),s=n,i=1),n=e.get(c,l),n===a?o++:(o>=5&&(r+=t+(o-5)),a=n,o=1)}i>=5&&(r+=t+(i-5)),o>=5&&(r+=t+(o-5))}return r},e.getPenaltyN2=function(e){const t=e.size;let r=0;for(let n=0;n=10&&(1488===i||93===i)&&n++,o=o<<1&2047|e.get(s,r),s>=10&&(1488===o||93===o)&&n++}return n*r},e.getPenaltyN4=function(e){let t=0;const n=e.data.length;for(let r=0;r=0;){const e=r[0];for(let i=0;i0){const e=new Uint8Array(this.degree);return e.set(n,r),e}return n};var Rv=Dv,$v={},Pv={},Uv={isValid:function(e){return!isNaN(e)&&e>=1&&e<=40}},Tv={};const Nv="[0-9]+";let Lv="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";Lv=Lv.replace(/u/g,"\\u");const Ov="(?:(?![A-Z0-9 $%*+\\-./:]|"+Lv+")(?:.|[\r\n]))+";Tv.KANJI=new RegExp(Lv,"g"),Tv.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Tv.BYTE=new RegExp(Ov,"g"),Tv.NUMERIC=new RegExp(Nv,"g"),Tv.ALPHANUMERIC=new RegExp("[A-Z $%*+\\-./:]+","g");const Mv=new RegExp("^"+Lv+"$"),_v=new RegExp("^"+Nv+"$"),Hv=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");Tv.testKanji=function(e){return Mv.test(e)},Tv.testNumeric=function(e){return _v.test(e)},Tv.testAlphanumeric=function(e){return Hv.test(e)},function(e){const t=Uv,n=Tv;e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw new Error("Invalid mode: "+e);if(!t.isValid(n))throw new Error("Invalid version: "+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw new Error("Invalid mode")},e.isValid=function(e){return e&&e.bit&&e.ccBits},e.from=function(t,n){if(e.isValid(t))return t;try{return function(t){if("string"!=typeof t)throw new Error("Param is not a string");switch(t.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+t)}}(t)}catch(e){return n}}}(Pv),function(e){const t=cv,n=kv,r=hv,i=Pv,o=Uv,s=t.getBCHDigit(7973);function a(e,t){return i.getCharCountIndicator(e,t)+4}function l(e,t){let n=0;return e.forEach(function(e){const r=a(e.mode,t);n+=r+e.getBitsLength()}),n}e.from=function(e,t){return o.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,s){if(!o.isValid(e))throw new Error("Invalid QR Code version");void 0===s&&(s=i.BYTE);const l=8*(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r));if(s===i.MIXED)return l;const c=l-a(s,e);switch(s){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(t,n){let o;const s=r.from(n,r.M);if(Array.isArray(t)){if(t.length>1)return function(t,n){for(let r=1;r<=40;r++)if(l(t,r)<=e.getCapacity(r,n,i.MIXED))return r}(t,s);if(0===t.length)return 1;o=t[0]}else o=t;return function(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}(o.mode,o.getLength(),s)},e.getEncodedBits=function(e){if(!o.isValid(e)||e<7)throw new Error("Invalid QR Code version");let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=7973<=0;)r^=1335<0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,3*i+1))};var Yv=Vv;const zv=Pv,Wv=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function Zv(e){this.mode=zv.ALPHANUMERIC,this.data=e}Zv.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},Zv.prototype.getLength=function(){return this.data.length},Zv.prototype.getBitsLength=function(){return Zv.getBitsLength(this.data.length)},Zv.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=45*Wv.indexOf(this.data[t]);n+=Wv.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(Wv.indexOf(this.data[t]),6)};var Xv=Zv;const eA=Pv;function tA(e){this.mode=eA.BYTE,this.data="string"==typeof e?(new TextEncoder).encode(e):new Uint8Array(e)}tA.getBitsLength=function(e){return 8*e},tA.prototype.getLength=function(){return this.data.length},tA.prototype.getBitsLength=function(){return tA.getBitsLength(this.data.length)},tA.prototype.write=function(e){for(let t=0,n=this.data.length;t=33088&&n<=40956)n-=33088;else{if(!(n>=57408&&n<=60351))throw new Error("Invalid SJIS character: "+this.data[t]+"\nMake sure your charset is UTF-8");n-=49472}n=192*(n>>>8&255)+(255&n),e.put(n,13)}};var sA=oA,aA={exports:{}};!function(e){var t={single_source_shortest_paths:function(e,n,r){var i={},o={};o[n]=0;var s,a,l,c,u,d,f,h=t.PriorityQueue.make();for(h.push(n,0);!h.empty();)for(l in a=(s=h.pop()).value,c=s.cost,u=e[a]||{})u.hasOwnProperty(l)&&(d=c+u[l],f=o[l],(void 0===o[l]||f>d)&&(o[l]=d,h.push(l,d),i[l]=a));if(void 0!==r&&void 0===o[r]){var p=["Could not find a path from ",n," to ",r,"."].join("");throw new Error(p)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,n,r){var i=t.single_source_shortest_paths(e,n,r);return t.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var n,r=t.PriorityQueue,i={};for(n in e=e||{},r)r.hasOwnProperty(n)&&(i[n]=r[n]);return i.queue=[],i.sorter=e.sorter||r.default_sorter,i},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};e.exports=t}(aA);var lA=aA.exports;!function(e){const t=Pv,n=Yv,r=Xv,i=nA,o=sA,s=Tv,a=cv,l=lA;function c(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){const r=[];let i;for(;null!==(i=e.exec(n));)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){const n=u(s.NUMERIC,t.NUMERIC,e),r=u(s.ALPHANUMERIC,t.ALPHANUMERIC,e);let i,o;a.isKanjiModeEnabled()?(i=u(s.BYTE,t.BYTE,e),o=u(s.KANJI,t.KANJI,e)):(i=u(s.BYTE_KANJI,t.BYTE,e),o=[]);return n.concat(r,i,o).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,s){switch(s){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return o.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function h(e,s){let l;const c=t.getBestModeForData(e);if(l=t.from(s,c),l!==t.BYTE&&l.bit=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}(u))},e.rawSplit=function(t){return e.fromArray(d(t,a.isKanjiModeEnabled()))}}(Kv);const cA=cv,uA=hv,dA=gv,fA=yv,hA=wv,pA=vv,gA=bv,mA=kv,yA=Rv,wA=$v,vA=jv,AA=Pv,bA=Kv;function kA(e,t,n){const r=e.size,i=vA.getEncodedBits(t,n);let o,s;for(o=0;o<15;o++)s=1==(i>>o&1),o<6?e.set(o,8,s,!0):o<8?e.set(o+1,8,s,!0):e.set(r-15+o,8,s,!0),o<8?e.set(8,r-o-1,s,!0):o<9?e.set(8,15-o-1+1,s,!0):e.set(8,15-o-1,s,!0);e.set(r-8,8,1,!0)}function IA(e,t,n){const r=new dA;n.forEach(function(t){r.put(t.mode.bit,4),r.put(t.getLength(),AA.getCharCountIndicator(t.mode,e)),t.write(r)});const i=8*(cA.getSymbolTotalCodewords(e)-mA.getTotalCodewordsCount(e,t));for(r.getLengthInBits()+4<=i&&r.put(0,4);r.getLengthInBits()%8!=0;)r.putBit(0);const o=(i-r.getLengthInBits())/8;for(let e=0;e=0&&t<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===t||6===t)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,o+r,!0,!0):e.set(i+t,o+r,!1,!0))}}(l,t),function(e){const t=e.size;for(let n=8;n=7&&function(e,t){const n=e.size,r=wA.getEncodedBits(t);let i,o,s;for(let t=0;t<18;t++)i=Math.floor(t/3),o=t%3+n-8-3,s=1==(r>>t&1),e.set(i,o,s,!0),e.set(o,i,s,!0)}(l,t),function(e,t){const n=e.size;let r=-1,i=n-1,o=7,s=0;for(let a=n-1;a>0;a-=2)for(6===a&&a--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,a-n)){let r=!1;s>>o&1)),e.set(i,a-n,r),o--,-1===o&&(s++,o=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}(l,s),isNaN(r)&&(r=gA.getBestMask(l,kA.bind(null,l,n))),gA.applyMask(r,l),kA(l,n,r),{modules:l,version:t,errorCorrectionLevel:n,maskPattern:r,segments:i}}lv.create=function(e,t){if(void 0===e||""===e)throw new Error("No input text");let n,r,i=uA.M;return void 0!==t&&(i=uA.from(t.errorCorrectionLevel,uA.M),n=wA.from(t.version),r=gA.from(t.maskPattern),t.toSJISFunc&&cA.setToSJISFunction(t.toSJISFunc)),EA(e,n,i,r)};var CA={},xA={};!function(e){function t(e){if("number"==typeof e&&(e=e.toString()),"string"!=typeof e)throw new Error("Color should be defined as hex string");let t=e.slice().replace("#","").split("");if(t.length<3||5===t.length||t.length>8)throw new Error("Invalid hex color: "+e);3!==t.length&&4!==t.length||(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),6===t.length&&t.push("F","F");const n=parseInt(t.join(""),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:"#"+t.slice(0,6).join("")}}e.getOptions=function(e){e||(e={}),e.color||(e.color={});const n=void 0===e.margin||null===e.margin||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,i=e.scale||4;return{width:r,scale:r?4:i,margin:n,color:{dark:t(e.color.dark||"#000000ff"),light:t(e.color.light||"#ffffffff")},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+2*t.margin?t.width/(e+2*t.margin):t.scale},e.getImageWidth=function(t,n){const r=e.getScale(t,n);return Math.floor((t+2*n.margin)*r)},e.qrToImageData=function(t,n,r){const i=n.modules.size,o=n.modules.data,s=e.getScale(i,r),a=Math.floor((i+2*r.margin)*s),l=r.margin*s,c=[r.color.light,r.color.dark];for(let e=0;e=l&&n>=l&&e':"",l="0&&l>0&&e[a-1]||(r+=o?QA("M",l+n,.5+c+n):QA("m",i,0),i=0,o=!1),l+1',c='viewBox="0 0 '+s+" "+s+'"',u=''+a+l+"\n";return"function"==typeof n&&n(null,u),u};const DA=function(){return"function"==typeof Promise&&Promise.prototype&&Promise.prototype.then},RA=lv,$A=CA,PA=BA;function UA(e,t,n,r,i){const o=[].slice.call(arguments,1),s=o.length,a="function"==typeof o[s-1];if(!a&&!DA())throw new Error("Callback required as last argument");if(!a){if(s<1)throw new Error("Too few arguments provided");return 1===s?(n=t,t=r=void 0):2!==s||t.getContext||(r=n,n=t,t=void 0),new Promise(function(i,o){try{const o=RA.create(n,r);i(e(o,t,r))}catch(e){o(e)}})}if(s<2)throw new Error("Too few arguments provided");2===s?(i=n,n=t,t=r=void 0):3===s&&(t.getContext&&void 0===i?(i=r,r=void 0):(i=r,r=n,n=t,t=void 0));try{const o=RA.create(n,r);i(null,e(o,t,r))}catch(e){i(e)}}async function TA(e,t,n,r){if(!e||!t)return console.log("createNIP98Auth: No signer or pubkey available",{hasSigner:!!e,hasPubkey:!!t}),null;try{const t={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",r],["method",n.toUpperCase()]],content:""};console.log("createNIP98Auth: Signing event for",n,r);const i=await e.signEvent(t);console.log("createNIP98Auth: Signed event:",{id:i.id,pubkey:i.pubkey,kind:i.kind,created_at:i.created_at,tags:i.tags,hasSig:!!i.sig});const o=JSON.stringify(i);return btoa(o).replace(/\+/g,"-").replace(/\//g,"_")}catch(e){return console.error("createNIP98Auth: Error:",e),null}}function NA(e,t,n){return e&t^~e&n}function LA(e,t,n){return e&t^e&n^t&n}av.create=RA.create,av.toCanvas=UA.bind(null,$A.render),av.toDataURL=UA.bind(null,$A.renderToDataURL),av.toString=UA.bind(null,function(e,t,n){return PA.render(e,n)});class OA extends Xu{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=Lu(this.buffer)}update(e){Tu(this),Pu(e=Wu(e));const{view:t,buffer:n,blockLen:r}=this,i=e.length;for(let o=0;or-o&&(this.process(n,0),o=0);for(let e=o;e>i&o),a=Number(n&o),l=r?4:0,c=r?0:4;e.setUint32(t+l,s,r),e.setUint32(t+c,a,r)}(n,r-8,BigInt(8*this.length),i),this.process(n,0);const s=Lu(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>>3,i=Ou(n,17)^Ou(n,19)^n>>>10;HA[e]=i+HA[e-7]+r+HA[e-16]|0}let{A:n,B:r,C:i,D:o,E:s,F:a,G:l,H:c}=this;for(let e=0;e<64;e++){const t=c+(Ou(s,6)^Ou(s,11)^Ou(s,25))+NA(s,a,l)+_A[e]+HA[e]|0,u=(Ou(n,2)^Ou(n,13)^Ou(n,22))+LA(n,r,i)|0;c=l,l=a,a=s,s=o+t|0,o=i,i=r,r=n,n=t+u|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(n,r,i,o,s,a,l,c)}roundClean(){Nu(HA)}destroy(){this.set(0,0,0,0,0,0,0,0),Nu(this.buffer)}}const GA=ed(()=>new jA);class qA extends Xu{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Uu(e);const n=Wu(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,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let e=0;enew qA(e,t).update(n).digest();KA.create=(e,t)=>new qA(e,t); /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const qA=BigInt(0),KA=BigInt(1);function JA(e,t=""){if("boolean"!=typeof e){throw new Error((t&&`"${t}"`)+"expected boolean, got type="+typeof e)}return e}function VA(e,t,n=""){const r=Qu(e),i=e?.length,o=void 0!==t;if(!r||o&&i!==t){throw new Error((n&&`"${n}" `)+"expected Uint8Array"+(o?` of length ${t}`:"")+", got "+(r?`length=${i}`:"type="+typeof e))}return e}function YA(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function zA(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?qA:BigInt("0x"+e)}function WA(e){return zA(Mu(e))}function ZA(e){return Ru(e),zA(Mu(Uint8Array.from(e).reverse()))}function XA(e,t){return Vu(e.toString(16).padStart(2*t,"0"))}function eb(e,t){return XA(e,t).reverse()}function tb(e,t,n){let r;if("string"==typeof t)try{r=Vu(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!Qu(t))throw new Error(e+" must be hex string or Uint8Array");r=Uint8Array.from(t)}const i=r.length;if("number"==typeof n&&i!==n)throw new Error(e+" of length "+n+" expected, got "+i);return r}const nb=e=>"bigint"==typeof e&&qA<=e;function rb(e,t,n,r){if(!function(e,t,n){return nb(e)&&nb(t)&&nb(n)&&t<=e&&eqA;e>>=KA,t+=1);return t}const ob=e=>(KA<r(e,t,!1)),Object.entries(n).forEach(([e,t])=>r(e,t,!0))}function ab(e){const t=new WeakMap;return(n,...r)=>{const i=t.get(n);if(void 0!==i)return i;const o=e(n,...r);return t.set(n,o),o}} -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const lb=BigInt(0),cb=BigInt(1),ub=BigInt(2),db=BigInt(3),fb=BigInt(4),hb=BigInt(5),pb=BigInt(7),gb=BigInt(8),mb=BigInt(9),yb=BigInt(16);function wb(e,t){const n=e%t;return n>=lb?n:t+n}function vb(e,t,n){let r=e;for(;t-- >lb;)r*=r,r%=n;return r}function Ab(e,t){if(e===lb)throw new Error("invert: expected non-zero number");if(t<=lb)throw new Error("invert: expected positive modulus, got "+t);let n=wb(e,t),r=t,i=lb,o=cb;for(;n!==lb;){const e=r%n,t=i-o*(r/n);r=n,n=e,i=o,o=t}if(r!==cb)throw new Error("invert: does not exist");return wb(i,t)}function bb(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function kb(e,t){const n=(e.ORDER+cb)/fb,r=e.pow(t,n);return bb(e,r,t),r}function Ib(e,t){const n=(e.ORDER-hb)/gb,r=e.mul(t,ub),i=e.pow(r,n),o=e.mul(t,i),s=e.mul(e.mul(o,ub),i),a=e.mul(o,e.sub(s,e.ONE));return bb(e,a,t),a}function Eb(e){if(e1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return kb;let o=i.pow(r,t);const s=(t+cb)/ub;return function(e,r){if(e.is0(r))return r;if(1!==Sb(e,r))throw new Error("Cannot find square root");let i=n,a=e.mul(e.ONE,o),l=e.pow(r,t),c=e.pow(r,s);for(;!e.eql(l,e.ONE);){if(e.is0(l))return e.ZERO;let t=1,n=e.sqr(l);for(;!e.eql(n,e.ONE);)if(t++,n=e.sqr(n),t===i)throw new Error("Cannot find square root");const r=cb<{let n=e.pow(t,s),a=e.mul(n,r);const l=e.mul(n,i),c=e.mul(n,o),u=e.eql(e.sqr(a),t),d=e.eql(e.sqr(l),t);n=e.cmov(n,a,u),a=e.cmov(c,l,d);const f=e.eql(e.sqr(a),t),h=e.cmov(n,a,f);return bb(e,h,t),h}}(e):Eb(e)}const xb=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Bb(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),i=t.reduce((t,n,i)=>e.is0(n)?t:(r[i]=t,e.mul(t,n)),e.ONE),o=e.inv(i);return t.reduceRight((t,n,i)=>e.is0(n)?t:(r[i]=e.mul(t,r[i]),e.mul(t,n)),o),r}function Sb(e,t){const n=(e.ORDER-cb)/ub,r=e.pow(t,n),i=e.eql(r,e.ONE),o=e.eql(r,e.ZERO),s=e.eql(r,e.neg(e.ONE));if(!i&&!o&&!s)throw new Error("invalid Legendre symbol result");return i?1:o?0:-1}function Fb(e,t){void 0!==t&&Du(t);const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Qb(e,t,n=!1,r={}){if(e<=lb)throw new Error("invalid field: expected ORDER > 0, got "+e);let i,o,s,a=!1;if("object"==typeof t&&null!=t){if(r.sqrt||n)throw new Error("cannot specify opts in two arguments");const e=t;e.BITS&&(i=e.BITS),e.sqrt&&(o=e.sqrt),"boolean"==typeof e.isLE&&(n=e.isLE),"boolean"==typeof e.modFromBytes&&(a=e.modFromBytes),s=e.allowedLengths}else"number"==typeof t&&(i=t),r.sqrt&&(o=r.sqrt);const{nBitLength:l,nByteLength:c}=Fb(e,i);if(c>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let u;const d=Object.freeze({ORDER:e,isLE:n,BITS:l,BYTES:c,MASK:ob(l),ZERO:lb,ONE:cb,allowedLengths:s,create:t=>wb(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return lb<=t&&te===lb,isValidNot0:e=>!d.is0(e)&&d.isValid(e),isOdd:e=>(e&cb)===cb,neg:t=>wb(-t,e),eql:(e,t)=>e===t,sqr:t=>wb(t*t,e),add:(t,n)=>wb(t+n,e),sub:(t,n)=>wb(t-n,e),mul:(t,n)=>wb(t*n,e),pow:(e,t)=>function(e,t,n){if(nlb;)n&cb&&(r=e.mul(r,i)),i=e.sqr(i),n>>=cb;return r}(d,e,t),div:(t,n)=>wb(t*Ab(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>Ab(t,e),sqrt:o||(t=>(u||(u=Cb(e)),u(d,t))),toBytes:e=>n?eb(e,c):XA(e,c),fromBytes:(t,r=!0)=>{if(s){if(!s.includes(t.length)||t.length>c)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+t.length);const e=new Uint8Array(c);e.set(t,n?0:e.length-t.length),t=e}if(t.length!==c)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+t.length);let i=n?ZA(t):WA(t);if(a&&(i=wb(i,e)),!r&&!d.isValid(i))throw new Error("invalid field element: outside of range 0..ORDER");return i},invertBatch:e=>Bb(d,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(d)}function Db(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 Rb(e){const t=Db(e);return t+Math.ceil(t/2)} +const JA=BigInt(0),VA=BigInt(1);function YA(e,t=""){if("boolean"!=typeof e){throw new Error((t&&`"${t}"`)+"expected boolean, got type="+typeof e)}return e}function zA(e,t,n=""){const r=Ru(e),i=e?.length,o=void 0!==t;if(!r||o&&i!==t){throw new Error((n&&`"${n}" `)+"expected Uint8Array"+(o?` of length ${t}`:"")+", got "+(r?`length=${i}`:"type="+typeof e))}return e}function WA(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function ZA(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?JA:BigInt("0x"+e)}function XA(e){return ZA(Hu(e))}function eb(e){return Pu(e),ZA(Hu(Uint8Array.from(e).reverse()))}function tb(e,t){return zu(e.toString(16).padStart(2*t,"0"))}function nb(e,t){return tb(e,t).reverse()}function rb(e,t,n){let r;if("string"==typeof t)try{r=zu(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!Ru(t))throw new Error(e+" must be hex string or Uint8Array");r=Uint8Array.from(t)}const i=r.length;if("number"==typeof n&&i!==n)throw new Error(e+" of length "+n+" expected, got "+i);return r}const ib=e=>"bigint"==typeof e&&JA<=e;function ob(e,t,n,r){if(!function(e,t,n){return ib(e)&&ib(t)&&ib(n)&&t<=e&&eJA;e>>=VA,t+=1);return t}const ab=e=>(VA<r(e,t,!1)),Object.entries(n).forEach(([e,t])=>r(e,t,!0))}function cb(e){const t=new WeakMap;return(n,...r)=>{const i=t.get(n);if(void 0!==i)return i;const o=e(n,...r);return t.set(n,o),o}} +/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ub=BigInt(0),db=BigInt(1),fb=BigInt(2),hb=BigInt(3),pb=BigInt(4),gb=BigInt(5),mb=BigInt(7),yb=BigInt(8),wb=BigInt(9),vb=BigInt(16);function Ab(e,t){const n=e%t;return n>=ub?n:t+n}function bb(e,t,n){let r=e;for(;t-- >ub;)r*=r,r%=n;return r}function kb(e,t){if(e===ub)throw new Error("invert: expected non-zero number");if(t<=ub)throw new Error("invert: expected positive modulus, got "+t);let n=Ab(e,t),r=t,i=ub,o=db;for(;n!==ub;){const e=r%n,t=i-o*(r/n);r=n,n=e,i=o,o=t}if(r!==db)throw new Error("invert: does not exist");return Ab(i,t)}function Ib(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function Eb(e,t){const n=(e.ORDER+db)/pb,r=e.pow(t,n);return Ib(e,r,t),r}function Cb(e,t){const n=(e.ORDER-gb)/yb,r=e.mul(t,fb),i=e.pow(r,n),o=e.mul(t,i),s=e.mul(e.mul(o,fb),i),a=e.mul(o,e.sub(s,e.ONE));return Ib(e,a,t),a}function xb(e){if(e1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return Eb;let o=i.pow(r,t);const s=(t+db)/fb;return function(e,r){if(e.is0(r))return r;if(1!==Qb(e,r))throw new Error("Cannot find square root");let i=n,a=e.mul(e.ONE,o),l=e.pow(r,t),c=e.pow(r,s);for(;!e.eql(l,e.ONE);){if(e.is0(l))return e.ZERO;let t=1,n=e.sqr(l);for(;!e.eql(n,e.ONE);)if(t++,n=e.sqr(n),t===i)throw new Error("Cannot find square root");const r=db<{let n=e.pow(t,s),a=e.mul(n,r);const l=e.mul(n,i),c=e.mul(n,o),u=e.eql(e.sqr(a),t),d=e.eql(e.sqr(l),t);n=e.cmov(n,a,u),a=e.cmov(c,l,d);const f=e.eql(e.sqr(a),t),h=e.cmov(n,a,f);return Ib(e,h,t),h}}(e):xb(e)}const Sb=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Fb(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),i=t.reduce((t,n,i)=>e.is0(n)?t:(r[i]=t,e.mul(t,n)),e.ONE),o=e.inv(i);return t.reduceRight((t,n,i)=>e.is0(n)?t:(r[i]=e.mul(t,r[i]),e.mul(t,n)),o),r}function Qb(e,t){const n=(e.ORDER-db)/fb,r=e.pow(t,n),i=e.eql(r,e.ONE),o=e.eql(r,e.ZERO),s=e.eql(r,e.neg(e.ONE));if(!i&&!o&&!s)throw new Error("invalid Legendre symbol result");return i?1:o?0:-1}function Db(e,t){void 0!==t&&$u(t);const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Rb(e,t,n=!1,r={}){if(e<=ub)throw new Error("invalid field: expected ORDER > 0, got "+e);let i,o,s,a=!1;if("object"==typeof t&&null!=t){if(r.sqrt||n)throw new Error("cannot specify opts in two arguments");const e=t;e.BITS&&(i=e.BITS),e.sqrt&&(o=e.sqrt),"boolean"==typeof e.isLE&&(n=e.isLE),"boolean"==typeof e.modFromBytes&&(a=e.modFromBytes),s=e.allowedLengths}else"number"==typeof t&&(i=t),r.sqrt&&(o=r.sqrt);const{nBitLength:l,nByteLength:c}=Db(e,i);if(c>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let u;const d=Object.freeze({ORDER:e,isLE:n,BITS:l,BYTES:c,MASK:ab(l),ZERO:ub,ONE:db,allowedLengths:s,create:t=>Ab(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return ub<=t&&te===ub,isValidNot0:e=>!d.is0(e)&&d.isValid(e),isOdd:e=>(e&db)===db,neg:t=>Ab(-t,e),eql:(e,t)=>e===t,sqr:t=>Ab(t*t,e),add:(t,n)=>Ab(t+n,e),sub:(t,n)=>Ab(t-n,e),mul:(t,n)=>Ab(t*n,e),pow:(e,t)=>function(e,t,n){if(nub;)n&db&&(r=e.mul(r,i)),i=e.sqr(i),n>>=db;return r}(d,e,t),div:(t,n)=>Ab(t*kb(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>kb(t,e),sqrt:o||(t=>(u||(u=Bb(e)),u(d,t))),toBytes:e=>n?nb(e,c):tb(e,c),fromBytes:(t,r=!0)=>{if(s){if(!s.includes(t.length)||t.length>c)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+t.length);const e=new Uint8Array(c);e.set(t,n?0:e.length-t.length),t=e}if(t.length!==c)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+t.length);let i=n?eb(t):XA(t);if(a&&(i=Ab(i,e)),!r&&!d.isValid(i))throw new Error("invalid field element: outside of range 0..ORDER");return i},invertBatch:e=>Fb(d,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(d)}function $b(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 Pb(e){const t=$b(e);return t+Math.ceil(t/2)} /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const Pb=BigInt(0),$b=BigInt(1);function Ub(e,t){const n=t.negate();return e?n:t}function Tb(e,t){const n=Bb(e.Fp,t.map(e=>e.Z));return t.map((t,r)=>e.fromAffine(t.toAffine(n[r])))}function Nb(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Lb(e,t){Nb(e,t);const n=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:ob(e),maxNumber:n,shiftBy:BigInt(e)}}function Ob(e,t,n){const{windowSize:r,mask:i,maxNumber:o,shiftBy:s}=n;let a=Number(e&i),l=e>>s;a>r&&(a-=o,l+=$b);const c=t*r;return{nextN:l,offset:c+Math.abs(a)-1,isZero:0===a,isNeg:a<0,isNegF:t%2!=0,offsetF:c}}const Mb=new WeakMap,_b=new WeakMap;function Hb(e){return _b.get(e)||1}function jb(e){if(e!==Pb)throw new Error("invalid wNAF")}class Gb{constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,n=this.ZERO){let r=e;for(;t>Pb;)t&$b&&(n=n.add(r)),r=r.double(),t>>=$b;return n}precomputeWindow(e,t){const{windows:n,windowSize:r}=Lb(t,this.bits),i=[];let o=e,s=o;for(let e=0;e{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}(n,e),function(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}(r,t);const i=n.length,o=r.length;if(i!==o)throw new Error("arrays of points and scalars must have equal length");const s=e.ZERO,a=ib(BigInt(i));let l=1;a>12?l=a-3:a>4?l=a-2:a>0&&(l=2);const c=ob(l),u=new Array(Number(c)+1).fill(s);let d=s;for(let e=Math.floor((t.BITS-1)/l)*l;e>=0;e-=l){u.fill(s);for(let t=0;t>BigInt(e)&c);u[o]=u[o].add(n[t])}let t=s;for(let e=u.length-1,n=s;e>0;e--)n=n.add(u[e]),t=t.add(n);if(d=d.add(t),0!==e)for(let e=0;e(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"});sb(e,t)}(t),t}return Qb(e,{isLE:n})} +const Ub=BigInt(0),Tb=BigInt(1);function Nb(e,t){const n=t.negate();return e?n:t}function Lb(e,t){const n=Fb(e.Fp,t.map(e=>e.Z));return t.map((t,r)=>e.fromAffine(t.toAffine(n[r])))}function Ob(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Mb(e,t){Ob(e,t);const n=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:ab(e),maxNumber:n,shiftBy:BigInt(e)}}function _b(e,t,n){const{windowSize:r,mask:i,maxNumber:o,shiftBy:s}=n;let a=Number(e&i),l=e>>s;a>r&&(a-=o,l+=Tb);const c=t*r;return{nextN:l,offset:c+Math.abs(a)-1,isZero:0===a,isNeg:a<0,isNegF:t%2!=0,offsetF:c}}const Hb=new WeakMap,jb=new WeakMap;function Gb(e){return jb.get(e)||1}function qb(e){if(e!==Ub)throw new Error("invalid wNAF")}class Kb{constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,n=this.ZERO){let r=e;for(;t>Ub;)t&Tb&&(n=n.add(r)),r=r.double(),t>>=Tb;return n}precomputeWindow(e,t){const{windows:n,windowSize:r}=Mb(t,this.bits),i=[];let o=e,s=o;for(let e=0;e{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}(n,e),function(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}(r,t);const i=n.length,o=r.length;if(i!==o)throw new Error("arrays of points and scalars must have equal length");const s=e.ZERO,a=sb(BigInt(i));let l=1;a>12?l=a-3:a>4?l=a-2:a>0&&(l=2);const c=ab(l),u=new Array(Number(c)+1).fill(s);let d=s;for(let e=Math.floor((t.BITS-1)/l)*l;e>=0;e-=l){u.fill(s);for(let t=0;t>BigInt(e)&c);u[o]=u[o].add(n[t])}let t=s;for(let e=u.length-1,n=s;e>0;e--)n=n.add(u[e]),t=t.add(n);if(d=d.add(t),0!==e)for(let e=0;e(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"});lb(e,t)}(t),t}return Rb(e,{isLE:n})} /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const Jb=(e,t)=>(e+(e>=0?t:-t)/ek)/t;function Vb(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Yb(e,t){const n={};for(let r of Object.keys(t))n[r]=void 0===e[r]?t[r]:e[r];return JA(n.lowS,"lowS"),JA(n.prehash,"prehash"),void 0!==n.format&&Vb(n.format),n}class zb extends Error{constructor(e=""){super(e)}}const Wb={Err:zb,_tlv:{encode:(e,t)=>{const{Err:n}=Wb;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(1&t.length)throw new n("tlv.encode: unpadded data");const r=t.length/2,i=YA(r);if(i.length/2&128)throw new n("tlv.encode: long form length too big");const o=r>127?YA(i.length/2|128):"";return YA(e)+o+i+t},decode(e,t){const{Err:n}=Wb;let r=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[r++]!==e)throw new n("tlv.decode: wrong tlv");const i=t[r++];let o=0;if(!!(128&i)){const e=127&i;if(!e)throw new n("tlv.decode(long): indefinite length not supported");if(e>4)throw new n("tlv.decode(long): byte length is too big");const s=t.subarray(r,r+e);if(s.length!==e)throw new n("tlv.decode: length bytes not complete");if(0===s[0])throw new n("tlv.decode(long): zero leftmost byte");for(const e of s)o=o<<8|e;if(r+=e,o<128)throw new n("tlv.decode(long): not minimal encoding")}else o=i;const s=t.subarray(r,r+o);if(s.length!==o)throw new n("tlv.decode: wrong value length");return{v:s,l:t.subarray(r+o)}}},_int:{encode(e){const{Err:t}=Wb;if(ePb))throw new Error(`CURVE.${e} must be positive bigint`)}const i=Kb(t.p,n.Fp,r),o=Kb(t.n,n.Fn,r),s=["Gx","Gy","a","weierstrass"===e?"b":"d"];for(const e of s)if(!i.isValid(t[e]))throw new Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return{CURVE:t=Object.freeze(Object.assign({},t)),Fp:i,Fn:o}}("weierstrass",e,t),{Fp:r,Fn:i}=n;let o=n.CURVE;const{h:s,n:a}=o;sb(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:l}=t;if(l&&(!r.is0(o.a)||"bigint"!=typeof l.beta||!Array.isArray(l.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const c=sk(r,i);function u(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const d=t.toBytes||function(e,t,n){const{x:i,y:o}=t.toAffine(),s=r.toBytes(i);if(JA(n,"isCompressed"),n){u();return zu(ok(!r.isOdd(o)),s)}return zu(Uint8Array.of(4),s,r.toBytes(o))},f=t.fromBytes||function(e){VA(e,void 0,"Point");const{publicKey:t,publicKeyUncompressed:n}=c,i=e.length,o=e[0],s=e.subarray(1);if(i!==t||2!==o&&3!==o){if(i===n&&4===o){const e=r.BYTES,t=r.fromBytes(s.subarray(0,e)),n=r.fromBytes(s.subarray(e,2*e));if(!p(t,n))throw new Error("bad point: is not on curve");return{x:t,y:n}}throw new Error(`bad point: got length ${i}, expected compressed=${t} or uncompressed=${n}`)}{const e=r.fromBytes(s);if(!r.isValid(e))throw new Error("bad point: is not on curve, wrong x");const t=h(e);let n;try{n=r.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("bad point: is not on curve, sqrt error"+t)}u();return!(1&~o)!==r.isOdd(n)&&(n=r.neg(n)),{x:e,y:n}}};function h(e){const t=r.sqr(e),n=r.mul(t,e);return r.add(r.add(n,r.mul(e,o.a)),o.b)}function p(e,t){const n=r.sqr(t),i=h(e);return r.eql(n,i)}if(!p(o.Gx,o.Gy))throw new Error("bad curve params: generator point");const g=r.mul(r.pow(o.a,tk),nk),m=r.mul(r.sqr(o.b),BigInt(27));if(r.is0(r.add(g,m)))throw new Error("bad curve params: a or b");function y(e,t,n=!1){if(!r.isValid(t)||n&&r.is0(t))throw new Error(`bad point coordinate ${e}`);return t}function w(e){if(!(e instanceof I))throw new Error("ProjectivePoint expected")}function v(e){if(!l||!l.basises)throw new Error("no endo");return function(e,t,n){const[[r,i],[o,s]]=t,a=Jb(s*e,n),l=Jb(-i*e,n);let c=e-a*r-l*o,u=-a*i-l*s;const d=c=h||u=h)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:d,k1:c,k2neg:f,k2:u}}(e,l.basises,i.ORDER)}const A=ab((e,t)=>{const{X:n,Y:i,Z:o}=e;if(r.eql(o,r.ONE))return{x:n,y:i};const s=e.is0();null==t&&(t=s?r.ONE:r.inv(o));const a=r.mul(n,t),l=r.mul(i,t),c=r.mul(o,t);if(s)return{x:r.ZERO,y:r.ZERO};if(!r.eql(c,r.ONE))throw new Error("invZ was invalid");return{x:a,y:l}}),b=ab(e=>{if(e.is0()){if(t.allowInfinityPoint&&!r.is0(e.Y))return;throw new Error("bad point: ZERO")}const{x:n,y:i}=e.toAffine();if(!r.isValid(n)||!r.isValid(i))throw new Error("bad point: x or y not field elements");if(!p(n,i))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function k(e,t,n,i,o){return n=new I(r.mul(n.X,e),n.Y,n.Z),t=Ub(i,t),n=Ub(o,n),t.add(n)}class I{constructor(e,t,n){this.X=y("x",e),this.Y=y("y",t,!0),this.Z=y("z",n),Object.freeze(this)}static CURVE(){return o}static fromAffine(e){const{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw new Error("invalid affine point");if(e instanceof I)throw new Error("projective point not allowed");return r.is0(t)&&r.is0(n)?I.ZERO:new I(t,n,r.ONE)}static fromBytes(e){const t=I.fromAffine(f(VA(e,void 0,"point")));return t.assertValidity(),t}static fromHex(e){return I.fromBytes(tb("pointHex",e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return C.createCache(this,e),t||this.multiply(tk),this}assertValidity(){b(this)}hasEvenY(){const{y:e}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(e)}equals(e){w(e);const{X:t,Y:n,Z:i}=this,{X:o,Y:s,Z:a}=e,l=r.eql(r.mul(t,a),r.mul(o,i)),c=r.eql(r.mul(n,a),r.mul(s,i));return l&&c}negate(){return new I(this.X,r.neg(this.Y),this.Z)}double(){const{a:e,b:t}=o,n=r.mul(t,tk),{X:i,Y:s,Z:a}=this;let l=r.ZERO,c=r.ZERO,u=r.ZERO,d=r.mul(i,i),f=r.mul(s,s),h=r.mul(a,a),p=r.mul(i,s);return p=r.add(p,p),u=r.mul(i,a),u=r.add(u,u),l=r.mul(e,u),c=r.mul(n,h),c=r.add(l,c),l=r.sub(f,c),c=r.add(f,c),c=r.mul(l,c),l=r.mul(p,l),u=r.mul(n,u),h=r.mul(e,h),p=r.sub(d,h),p=r.mul(e,p),p=r.add(p,u),u=r.add(d,d),d=r.add(u,d),d=r.add(d,h),d=r.mul(d,p),c=r.add(c,d),h=r.mul(s,a),h=r.add(h,h),d=r.mul(h,p),l=r.sub(l,d),u=r.mul(h,f),u=r.add(u,u),u=r.add(u,u),new I(l,c,u)}add(e){w(e);const{X:t,Y:n,Z:i}=this,{X:s,Y:a,Z:l}=e;let c=r.ZERO,u=r.ZERO,d=r.ZERO;const f=o.a,h=r.mul(o.b,tk);let p=r.mul(t,s),g=r.mul(n,a),m=r.mul(i,l),y=r.add(t,n),v=r.add(s,a);y=r.mul(y,v),v=r.add(p,g),y=r.sub(y,v),v=r.add(t,i);let A=r.add(s,l);return v=r.mul(v,A),A=r.add(p,m),v=r.sub(v,A),A=r.add(n,i),c=r.add(a,l),A=r.mul(A,c),c=r.add(g,m),A=r.sub(A,c),d=r.mul(f,v),c=r.mul(h,m),d=r.add(c,d),c=r.sub(g,d),d=r.add(g,d),u=r.mul(c,d),g=r.add(p,p),g=r.add(g,p),m=r.mul(f,m),v=r.mul(h,v),g=r.add(g,m),m=r.sub(p,m),m=r.mul(f,m),v=r.add(v,m),p=r.mul(g,v),u=r.add(u,p),p=r.mul(A,v),c=r.mul(y,c),c=r.sub(c,p),p=r.mul(y,g),d=r.mul(A,d),d=r.add(d,p),new I(c,u,d)}subtract(e){return this.add(e.negate())}is0(){return this.equals(I.ZERO)}multiply(e){const{endo:n}=t;if(!i.isValidNot0(e))throw new Error("invalid scalar: out of range");let r,o;const s=e=>C.cached(this,e,e=>Tb(I,e));if(n){const{k1neg:t,k1:i,k2neg:a,k2:l}=v(e),{p:c,f:u}=s(i),{p:d,f:f}=s(l);o=u.add(f),r=k(n.beta,c,d,t,a)}else{const{p:t,f:n}=s(e);r=t,o=n}return Tb(I,[r,o])[0]}multiplyUnsafe(e){const{endo:n}=t,r=this;if(!i.isValid(e))throw new Error("invalid scalar: out of range");if(e===Zb||r.is0())return I.ZERO;if(e===Xb)return r;if(C.hasCache(this))return this.multiply(e);if(n){const{k1neg:t,k1:i,k2neg:o,k2:s}=v(e),{p1:a,p2:l}=function(e,t,n,r){let i=t,o=e.ZERO,s=e.ZERO;for(;n>Pb||r>Pb;)n&$b&&(o=o.add(i)),r&$b&&(s=s.add(i)),i=i.double(),n>>=$b,r>>=$b;return{p1:o,p2:s}}(I,r,i,s);return k(n.beta,a,l,t,o)}return C.unsafe(r,e)}multiplyAndAddUnsafe(e,t,n){const r=this.multiplyUnsafe(t).add(e.multiplyUnsafe(n));return r.is0()?void 0:r}toAffine(e){return A(this,e)}isTorsionFree(){const{isTorsionFree:e}=t;return s===Xb||(e?e(I,this):C.unsafe(this,a).is0())}clearCofactor(){const{clearCofactor:e}=t;return s===Xb?this:e?e(I,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(e=!0){return JA(e,"isCompressed"),this.assertValidity(),d(I,this,e)}toHex(e=!0){return Mu(this.toBytes(e))}toString(){return``}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(e=!0){return this.toBytes(e)}_setWindowSize(e){this.precompute(e)}static normalizeZ(e){return Tb(I,e)}static msm(e,t){return qb(I,i,e,t)}static fromPrivateKey(e){return I.BASE.multiply(rk(i,e))}}I.BASE=new I(o.Gx,o.Gy,r.ONE),I.ZERO=new I(r.ZERO,r.ONE,r.ZERO),I.Fp=r,I.Fn=i;const E=i.BITS,C=new Gb(I,t.endo?Math.ceil(E/2):E);return I.BASE.precompute(8),I}function ok(e){return Uint8Array.of(e?2:3)}function sk(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function ak(e,t={}){const{Fn:n}=e,r=t.randomBytes||Xu,i=Object.assign(sk(e.Fp,n),{seed:Rb(n.ORDER)});function o(e){try{return!!rk(n,e)}catch(e){return!1}}function s(e=r(i.seed)){return function(e,t,n=!1){const r=e.length,i=Db(t),o=Rb(t);if(r<16||r1024)throw new Error("expected "+o+"-1024 bytes of input, got "+r);const s=wb(n?ZA(e):WA(e),t-cb)+cb;return n?eb(s,i):XA(s,i)}(VA(e,i.seed,"seed"),n.ORDER)}function a(t,r=!0){return e.BASE.multiply(rk(n,t)).toBytes(r)}function l(t){if("bigint"==typeof t)return!1;if(t instanceof e)return!0;const{secretKey:r,publicKey:o,publicKeyUncompressed:s}=i;if(n.allowedLengths||r===o)return;const a=tb("key",t).length;return a===o||a===s}const c={isValidSecretKey:o,isValidPublicKey:function(t,n){const{publicKey:r,publicKeyUncompressed:o}=i;try{const i=t.length;return(!0!==n||i===r)&&((!1!==n||i===o)&&!!e.fromBytes(t))}catch(e){return!1}},randomSecretKey:s,isValidPrivateKey:o,randomPrivateKey:s,normPrivateKeyToScalar:e=>rk(n,e),precompute:(t=8,n=e.BASE)=>n.precompute(t,!1)};return Object.freeze({getPublicKey:a,getSharedSecret:function(t,r,i=!0){if(!0===l(t))throw new Error("first arg must be private key");if(!1===l(r))throw new Error("second arg must be public key");const o=rk(n,t);return e.fromHex(r).multiply(o).toBytes(i)},keygen:function(e){const t=s(e);return{secretKey:t,publicKey:a(t)}},Point:e,utils:c,lengths:i})}function lk(e,t,n={}){Pu(t),sb(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=n.randomBytes||Xu,i=n.hmac||((e,...n)=>GA(t,e,zu(...n))),{Fp:o,Fn:s}=e,{ORDER:a,BITS:l}=s,{keygen:c,getPublicKey:u,getSharedSecret:d,utils:f,lengths:h}=ak(e,n),p={prehash:!1,lowS:"boolean"==typeof n.lowS&&n.lowS,format:void 0,extraEntropy:!1},g="compact";function m(e){return e>a>>Xb}function y(e,t){if(!s.isValidNot0(t))throw new Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}class w{constructor(e,t,n){this.r=y("r",e),this.s=y("s",t),null!=n&&(this.recovery=n),Object.freeze(this)}static fromBytes(e,t=g){let n;if(function(e,t){Vb(t);const n=h.signature;VA(e,"compact"===t?n:"recovered"===t?n+1:void 0,`${t} signature`)}(e,t),"der"===t){const{r:t,s:n}=Wb.toSig(VA(e));return new w(t,n)}"recovered"===t&&(n=e[0],t="compact",e=e.subarray(1));const r=s.BYTES,i=e.subarray(0,r),o=e.subarray(r,2*r);return new w(s.fromBytes(i),s.fromBytes(o),n)}static fromHex(e,t){return this.fromBytes(Vu(e),t)}addRecoveryBit(e){return new w(this.r,this.s,e)}recoverPublicKey(t){const n=o.ORDER,{r:r,s:i,recovery:l}=this;if(null==l||![0,1,2,3].includes(l))throw new Error("recovery id invalid");if(a*ek1)throw new Error("recovery id is ambiguous for h>1 curve");const c=2===l||3===l?r+a:r;if(!o.isValid(c))throw new Error("recovery id 2 or 3 invalid");const u=o.toBytes(c),d=e.fromBytes(zu(ok(!(1&l)),u)),f=s.inv(c),h=A(tb("msgHash",t)),p=s.create(-h*f),g=s.create(i*f),m=e.BASE.multiplyUnsafe(p).add(d.multiplyUnsafe(g));if(m.is0())throw new Error("point at infinify");return m.assertValidity(),m}hasHighS(){return m(this.s)}toBytes(e=g){if(Vb(e),"der"===e)return Vu(Wb.hexFromSig(this));const t=s.toBytes(this.r),n=s.toBytes(this.s);if("recovered"===e){if(null==this.recovery)throw new Error("recovery bit must be present");return zu(Uint8Array.of(this.recovery),t,n)}return zu(t,n)}toHex(e){return Mu(this.toBytes(e))}assertValidity(){}static fromCompact(e){return w.fromBytes(tb("sig",e),"compact")}static fromDER(e){return w.fromBytes(tb("sig",e),"der")}normalizeS(){return this.hasHighS()?new w(this.r,s.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return Mu(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return Mu(this.toBytes("compact"))}}const v=n.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=WA(e),n=8*e.length-l;return n>0?t>>BigInt(n):t},A=n.bits2int_modN||function(e){return s.create(v(e))},b=ob(l);function k(e){return rb("num < 2^"+l,e,Zb,b),s.toBytes(e)}function I(e,n){return VA(e,void 0,"message"),n?VA(t(e),void 0,"prehashed message"):e}return Object.freeze({keygen:c,getPublicKey:u,getSharedSecret:d,utils:f,lengths:h,Point:e,sign:function(n,o,a={}){n=tb("message",n);const{seed:l,k2sig:c}=function(t,n,i){if(["recovered","canonical"].some(e=>e in i))throw new Error("sign() legacy options not supported");const{lowS:o,prehash:a,extraEntropy:l}=Yb(i,p);t=I(t,a);const c=A(t),u=rk(s,n),d=[k(u),k(c)];if(null!=l&&!1!==l){const e=!0===l?r(h.secretKey):l;d.push(tb("extraEntropy",e))}const f=zu(...d),g=c;return{seed:f,k2sig:function(t){const n=v(t);if(!s.isValidNot0(n))return;const r=s.inv(n),i=e.BASE.multiply(n).toAffine(),a=s.create(i.x);if(a===Zb)return;const l=s.create(r*s.create(g+a*u));if(l===Zb)return;let c=(i.x===a?0:2)|Number(i.y&Xb),d=l;return o&&m(l)&&(d=s.neg(l),c^=1),new w(a,d,c)}}}(n,o,a),u=function(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");const r=e=>new Uint8Array(e),i=e=>Uint8Array.of(e);let o=r(e),s=r(e),a=0;const l=()=>{o.fill(1),s.fill(0),a=0},c=(...e)=>n(s,o,...e),u=(e=r(0))=>{s=c(i(0),e),o=c(),0!==e.length&&(s=c(i(1),e),o=c())},d=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e{let n;for(l(),u(e);!(n=t(d()));)u();return l(),n}}(t.outputLen,s.BYTES,i);return u(l,c)},verify:function(t,n,r,i={}){const{lowS:o,prehash:a,format:l}=Yb(i,p);if(r=tb("publicKey",r),n=I(tb("message",n),a),"strict"in i)throw new Error("options.strict was renamed to lowS");const c=void 0===l?function(e){let t;const n="string"==typeof e||Qu(e),r=!n&&null!==e&&"object"==typeof e&&"bigint"==typeof e.r&&"bigint"==typeof e.s;if(!n&&!r)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(r)t=new w(e.r,e.s);else if(n){try{t=w.fromBytes(tb("sig",e),"der")}catch(e){if(!(e instanceof Wb.Err))throw e}if(!t)try{t=w.fromBytes(tb("sig",e),"compact")}catch(e){return!1}}return t||!1}(t):w.fromBytes(tb("sig",t),l);if(!1===c)return!1;try{const t=e.fromBytes(r);if(o&&c.hasHighS())return!1;const{r:i,s:a}=c,l=A(n),u=s.inv(a),d=s.create(l*u),f=s.create(i*u),h=e.BASE.multiplyUnsafe(d).add(t.multiplyUnsafe(f));if(h.is0())return!1;return s.create(h.x)===i}catch(e){return!1}},recoverPublicKey:function(e,t,n={}){const{prehash:r}=Yb(n,p);return t=I(t,r),w.fromBytes(e,"recovered").recoverPublicKey(t).toBytes()},Signature:w,hash:t})}function ck(e){const{CURVE:t,curveOpts:n}=function(e){const t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp;let r=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map(e=>Math.ceil(e/2)))):void 0;return{CURVE:t,curveOpts:{Fp:n,Fn:Qb(t.n,{BITS:e.nBitLength,allowedLengths:r,modFromBytes:e.wrapPrivateKey}),allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes}}}(e),r={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:n,hash:e.hash,ecdsaOpts:r}}function uk(e){const{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:i}=ck(e);return function(e,t){const n=t.Point;return Object.assign({},t,{ProjectivePoint:n,CURVE:Object.assign({},e,Fb(n.Fn.ORDER,n.Fn.BITS))})}(e,lk(ik(t,n),r,i))} +const Yb=(e,t)=>(e+(e>=0?t:-t)/nk)/t;function zb(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Wb(e,t){const n={};for(let r of Object.keys(t))n[r]=void 0===e[r]?t[r]:e[r];return YA(n.lowS,"lowS"),YA(n.prehash,"prehash"),void 0!==n.format&&zb(n.format),n}class Zb extends Error{constructor(e=""){super(e)}}const Xb={Err:Zb,_tlv:{encode:(e,t)=>{const{Err:n}=Xb;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(1&t.length)throw new n("tlv.encode: unpadded data");const r=t.length/2,i=WA(r);if(i.length/2&128)throw new n("tlv.encode: long form length too big");const o=r>127?WA(i.length/2|128):"";return WA(e)+o+i+t},decode(e,t){const{Err:n}=Xb;let r=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[r++]!==e)throw new n("tlv.decode: wrong tlv");const i=t[r++];let o=0;if(!!(128&i)){const e=127&i;if(!e)throw new n("tlv.decode(long): indefinite length not supported");if(e>4)throw new n("tlv.decode(long): byte length is too big");const s=t.subarray(r,r+e);if(s.length!==e)throw new n("tlv.decode: length bytes not complete");if(0===s[0])throw new n("tlv.decode(long): zero leftmost byte");for(const e of s)o=o<<8|e;if(r+=e,o<128)throw new n("tlv.decode(long): not minimal encoding")}else o=i;const s=t.subarray(r,r+o);if(s.length!==o)throw new n("tlv.decode: wrong value length");return{v:s,l:t.subarray(r+o)}}},_int:{encode(e){const{Err:t}=Xb;if(eUb))throw new Error(`CURVE.${e} must be positive bigint`)}const i=Vb(t.p,n.Fp,r),o=Vb(t.n,n.Fn,r),s=["Gx","Gy","a","weierstrass"===e?"b":"d"];for(const e of s)if(!i.isValid(t[e]))throw new Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return{CURVE:t=Object.freeze(Object.assign({},t)),Fp:i,Fn:o}}("weierstrass",e,t),{Fp:r,Fn:i}=n;let o=n.CURVE;const{h:s,n:a}=o;lb(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:l}=t;if(l&&(!r.is0(o.a)||"bigint"!=typeof l.beta||!Array.isArray(l.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const c=lk(r,i);function u(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const d=t.toBytes||function(e,t,n){const{x:i,y:o}=t.toAffine(),s=r.toBytes(i);if(YA(n,"isCompressed"),n){u();return Zu(ak(!r.isOdd(o)),s)}return Zu(Uint8Array.of(4),s,r.toBytes(o))},f=t.fromBytes||function(e){zA(e,void 0,"Point");const{publicKey:t,publicKeyUncompressed:n}=c,i=e.length,o=e[0],s=e.subarray(1);if(i!==t||2!==o&&3!==o){if(i===n&&4===o){const e=r.BYTES,t=r.fromBytes(s.subarray(0,e)),n=r.fromBytes(s.subarray(e,2*e));if(!p(t,n))throw new Error("bad point: is not on curve");return{x:t,y:n}}throw new Error(`bad point: got length ${i}, expected compressed=${t} or uncompressed=${n}`)}{const e=r.fromBytes(s);if(!r.isValid(e))throw new Error("bad point: is not on curve, wrong x");const t=h(e);let n;try{n=r.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("bad point: is not on curve, sqrt error"+t)}u();return!(1&~o)!==r.isOdd(n)&&(n=r.neg(n)),{x:e,y:n}}};function h(e){const t=r.sqr(e),n=r.mul(t,e);return r.add(r.add(n,r.mul(e,o.a)),o.b)}function p(e,t){const n=r.sqr(t),i=h(e);return r.eql(n,i)}if(!p(o.Gx,o.Gy))throw new Error("bad curve params: generator point");const g=r.mul(r.pow(o.a,rk),ik),m=r.mul(r.sqr(o.b),BigInt(27));if(r.is0(r.add(g,m)))throw new Error("bad curve params: a or b");function y(e,t,n=!1){if(!r.isValid(t)||n&&r.is0(t))throw new Error(`bad point coordinate ${e}`);return t}function w(e){if(!(e instanceof I))throw new Error("ProjectivePoint expected")}function v(e){if(!l||!l.basises)throw new Error("no endo");return function(e,t,n){const[[r,i],[o,s]]=t,a=Yb(s*e,n),l=Yb(-i*e,n);let c=e-a*r-l*o,u=-a*i-l*s;const d=c=h||u=h)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:d,k1:c,k2neg:f,k2:u}}(e,l.basises,i.ORDER)}const A=cb((e,t)=>{const{X:n,Y:i,Z:o}=e;if(r.eql(o,r.ONE))return{x:n,y:i};const s=e.is0();null==t&&(t=s?r.ONE:r.inv(o));const a=r.mul(n,t),l=r.mul(i,t),c=r.mul(o,t);if(s)return{x:r.ZERO,y:r.ZERO};if(!r.eql(c,r.ONE))throw new Error("invZ was invalid");return{x:a,y:l}}),b=cb(e=>{if(e.is0()){if(t.allowInfinityPoint&&!r.is0(e.Y))return;throw new Error("bad point: ZERO")}const{x:n,y:i}=e.toAffine();if(!r.isValid(n)||!r.isValid(i))throw new Error("bad point: x or y not field elements");if(!p(n,i))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function k(e,t,n,i,o){return n=new I(r.mul(n.X,e),n.Y,n.Z),t=Nb(i,t),n=Nb(o,n),t.add(n)}class I{constructor(e,t,n){this.X=y("x",e),this.Y=y("y",t,!0),this.Z=y("z",n),Object.freeze(this)}static CURVE(){return o}static fromAffine(e){const{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw new Error("invalid affine point");if(e instanceof I)throw new Error("projective point not allowed");return r.is0(t)&&r.is0(n)?I.ZERO:new I(t,n,r.ONE)}static fromBytes(e){const t=I.fromAffine(f(zA(e,void 0,"point")));return t.assertValidity(),t}static fromHex(e){return I.fromBytes(rb("pointHex",e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return C.createCache(this,e),t||this.multiply(rk),this}assertValidity(){b(this)}hasEvenY(){const{y:e}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(e)}equals(e){w(e);const{X:t,Y:n,Z:i}=this,{X:o,Y:s,Z:a}=e,l=r.eql(r.mul(t,a),r.mul(o,i)),c=r.eql(r.mul(n,a),r.mul(s,i));return l&&c}negate(){return new I(this.X,r.neg(this.Y),this.Z)}double(){const{a:e,b:t}=o,n=r.mul(t,rk),{X:i,Y:s,Z:a}=this;let l=r.ZERO,c=r.ZERO,u=r.ZERO,d=r.mul(i,i),f=r.mul(s,s),h=r.mul(a,a),p=r.mul(i,s);return p=r.add(p,p),u=r.mul(i,a),u=r.add(u,u),l=r.mul(e,u),c=r.mul(n,h),c=r.add(l,c),l=r.sub(f,c),c=r.add(f,c),c=r.mul(l,c),l=r.mul(p,l),u=r.mul(n,u),h=r.mul(e,h),p=r.sub(d,h),p=r.mul(e,p),p=r.add(p,u),u=r.add(d,d),d=r.add(u,d),d=r.add(d,h),d=r.mul(d,p),c=r.add(c,d),h=r.mul(s,a),h=r.add(h,h),d=r.mul(h,p),l=r.sub(l,d),u=r.mul(h,f),u=r.add(u,u),u=r.add(u,u),new I(l,c,u)}add(e){w(e);const{X:t,Y:n,Z:i}=this,{X:s,Y:a,Z:l}=e;let c=r.ZERO,u=r.ZERO,d=r.ZERO;const f=o.a,h=r.mul(o.b,rk);let p=r.mul(t,s),g=r.mul(n,a),m=r.mul(i,l),y=r.add(t,n),v=r.add(s,a);y=r.mul(y,v),v=r.add(p,g),y=r.sub(y,v),v=r.add(t,i);let A=r.add(s,l);return v=r.mul(v,A),A=r.add(p,m),v=r.sub(v,A),A=r.add(n,i),c=r.add(a,l),A=r.mul(A,c),c=r.add(g,m),A=r.sub(A,c),d=r.mul(f,v),c=r.mul(h,m),d=r.add(c,d),c=r.sub(g,d),d=r.add(g,d),u=r.mul(c,d),g=r.add(p,p),g=r.add(g,p),m=r.mul(f,m),v=r.mul(h,v),g=r.add(g,m),m=r.sub(p,m),m=r.mul(f,m),v=r.add(v,m),p=r.mul(g,v),u=r.add(u,p),p=r.mul(A,v),c=r.mul(y,c),c=r.sub(c,p),p=r.mul(y,g),d=r.mul(A,d),d=r.add(d,p),new I(c,u,d)}subtract(e){return this.add(e.negate())}is0(){return this.equals(I.ZERO)}multiply(e){const{endo:n}=t;if(!i.isValidNot0(e))throw new Error("invalid scalar: out of range");let r,o;const s=e=>C.cached(this,e,e=>Lb(I,e));if(n){const{k1neg:t,k1:i,k2neg:a,k2:l}=v(e),{p:c,f:u}=s(i),{p:d,f:f}=s(l);o=u.add(f),r=k(n.beta,c,d,t,a)}else{const{p:t,f:n}=s(e);r=t,o=n}return Lb(I,[r,o])[0]}multiplyUnsafe(e){const{endo:n}=t,r=this;if(!i.isValid(e))throw new Error("invalid scalar: out of range");if(e===ek||r.is0())return I.ZERO;if(e===tk)return r;if(C.hasCache(this))return this.multiply(e);if(n){const{k1neg:t,k1:i,k2neg:o,k2:s}=v(e),{p1:a,p2:l}=function(e,t,n,r){let i=t,o=e.ZERO,s=e.ZERO;for(;n>Ub||r>Ub;)n&Tb&&(o=o.add(i)),r&Tb&&(s=s.add(i)),i=i.double(),n>>=Tb,r>>=Tb;return{p1:o,p2:s}}(I,r,i,s);return k(n.beta,a,l,t,o)}return C.unsafe(r,e)}multiplyAndAddUnsafe(e,t,n){const r=this.multiplyUnsafe(t).add(e.multiplyUnsafe(n));return r.is0()?void 0:r}toAffine(e){return A(this,e)}isTorsionFree(){const{isTorsionFree:e}=t;return s===tk||(e?e(I,this):C.unsafe(this,a).is0())}clearCofactor(){const{clearCofactor:e}=t;return s===tk?this:e?e(I,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(e=!0){return YA(e,"isCompressed"),this.assertValidity(),d(I,this,e)}toHex(e=!0){return Hu(this.toBytes(e))}toString(){return``}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(e=!0){return this.toBytes(e)}_setWindowSize(e){this.precompute(e)}static normalizeZ(e){return Lb(I,e)}static msm(e,t){return Jb(I,i,e,t)}static fromPrivateKey(e){return I.BASE.multiply(ok(i,e))}}I.BASE=new I(o.Gx,o.Gy,r.ONE),I.ZERO=new I(r.ZERO,r.ONE,r.ZERO),I.Fp=r,I.Fn=i;const E=i.BITS,C=new Kb(I,t.endo?Math.ceil(E/2):E);return I.BASE.precompute(8),I}function ak(e){return Uint8Array.of(e?2:3)}function lk(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function ck(e,t={}){const{Fn:n}=e,r=t.randomBytes||td,i=Object.assign(lk(e.Fp,n),{seed:Pb(n.ORDER)});function o(e){try{return!!ok(n,e)}catch(e){return!1}}function s(e=r(i.seed)){return function(e,t,n=!1){const r=e.length,i=$b(t),o=Pb(t);if(r<16||r1024)throw new Error("expected "+o+"-1024 bytes of input, got "+r);const s=Ab(n?eb(e):XA(e),t-db)+db;return n?nb(s,i):tb(s,i)}(zA(e,i.seed,"seed"),n.ORDER)}function a(t,r=!0){return e.BASE.multiply(ok(n,t)).toBytes(r)}function l(t){if("bigint"==typeof t)return!1;if(t instanceof e)return!0;const{secretKey:r,publicKey:o,publicKeyUncompressed:s}=i;if(n.allowedLengths||r===o)return;const a=rb("key",t).length;return a===o||a===s}const c={isValidSecretKey:o,isValidPublicKey:function(t,n){const{publicKey:r,publicKeyUncompressed:o}=i;try{const i=t.length;return(!0!==n||i===r)&&((!1!==n||i===o)&&!!e.fromBytes(t))}catch(e){return!1}},randomSecretKey:s,isValidPrivateKey:o,randomPrivateKey:s,normPrivateKeyToScalar:e=>ok(n,e),precompute:(t=8,n=e.BASE)=>n.precompute(t,!1)};return Object.freeze({getPublicKey:a,getSharedSecret:function(t,r,i=!0){if(!0===l(t))throw new Error("first arg must be private key");if(!1===l(r))throw new Error("second arg must be public key");const o=ok(n,t);return e.fromHex(r).multiply(o).toBytes(i)},keygen:function(e){const t=s(e);return{secretKey:t,publicKey:a(t)}},Point:e,utils:c,lengths:i})}function uk(e,t,n={}){Uu(t),lb(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=n.randomBytes||td,i=n.hmac||((e,...n)=>KA(t,e,Zu(...n))),{Fp:o,Fn:s}=e,{ORDER:a,BITS:l}=s,{keygen:c,getPublicKey:u,getSharedSecret:d,utils:f,lengths:h}=ck(e,n),p={prehash:!1,lowS:"boolean"==typeof n.lowS&&n.lowS,format:void 0,extraEntropy:!1},g="compact";function m(e){return e>a>>tk}function y(e,t){if(!s.isValidNot0(t))throw new Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}class w{constructor(e,t,n){this.r=y("r",e),this.s=y("s",t),null!=n&&(this.recovery=n),Object.freeze(this)}static fromBytes(e,t=g){let n;if(function(e,t){zb(t);const n=h.signature;zA(e,"compact"===t?n:"recovered"===t?n+1:void 0,`${t} signature`)}(e,t),"der"===t){const{r:t,s:n}=Xb.toSig(zA(e));return new w(t,n)}"recovered"===t&&(n=e[0],t="compact",e=e.subarray(1));const r=s.BYTES,i=e.subarray(0,r),o=e.subarray(r,2*r);return new w(s.fromBytes(i),s.fromBytes(o),n)}static fromHex(e,t){return this.fromBytes(zu(e),t)}addRecoveryBit(e){return new w(this.r,this.s,e)}recoverPublicKey(t){const n=o.ORDER,{r:r,s:i,recovery:l}=this;if(null==l||![0,1,2,3].includes(l))throw new Error("recovery id invalid");if(a*nk1)throw new Error("recovery id is ambiguous for h>1 curve");const c=2===l||3===l?r+a:r;if(!o.isValid(c))throw new Error("recovery id 2 or 3 invalid");const u=o.toBytes(c),d=e.fromBytes(Zu(ak(!(1&l)),u)),f=s.inv(c),h=A(rb("msgHash",t)),p=s.create(-h*f),g=s.create(i*f),m=e.BASE.multiplyUnsafe(p).add(d.multiplyUnsafe(g));if(m.is0())throw new Error("point at infinify");return m.assertValidity(),m}hasHighS(){return m(this.s)}toBytes(e=g){if(zb(e),"der"===e)return zu(Xb.hexFromSig(this));const t=s.toBytes(this.r),n=s.toBytes(this.s);if("recovered"===e){if(null==this.recovery)throw new Error("recovery bit must be present");return Zu(Uint8Array.of(this.recovery),t,n)}return Zu(t,n)}toHex(e){return Hu(this.toBytes(e))}assertValidity(){}static fromCompact(e){return w.fromBytes(rb("sig",e),"compact")}static fromDER(e){return w.fromBytes(rb("sig",e),"der")}normalizeS(){return this.hasHighS()?new w(this.r,s.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return Hu(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return Hu(this.toBytes("compact"))}}const v=n.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=XA(e),n=8*e.length-l;return n>0?t>>BigInt(n):t},A=n.bits2int_modN||function(e){return s.create(v(e))},b=ab(l);function k(e){return ob("num < 2^"+l,e,ek,b),s.toBytes(e)}function I(e,n){return zA(e,void 0,"message"),n?zA(t(e),void 0,"prehashed message"):e}return Object.freeze({keygen:c,getPublicKey:u,getSharedSecret:d,utils:f,lengths:h,Point:e,sign:function(n,o,a={}){n=rb("message",n);const{seed:l,k2sig:c}=function(t,n,i){if(["recovered","canonical"].some(e=>e in i))throw new Error("sign() legacy options not supported");const{lowS:o,prehash:a,extraEntropy:l}=Wb(i,p);t=I(t,a);const c=A(t),u=ok(s,n),d=[k(u),k(c)];if(null!=l&&!1!==l){const e=!0===l?r(h.secretKey):l;d.push(rb("extraEntropy",e))}const f=Zu(...d),g=c;return{seed:f,k2sig:function(t){const n=v(t);if(!s.isValidNot0(n))return;const r=s.inv(n),i=e.BASE.multiply(n).toAffine(),a=s.create(i.x);if(a===ek)return;const l=s.create(r*s.create(g+a*u));if(l===ek)return;let c=(i.x===a?0:2)|Number(i.y&tk),d=l;return o&&m(l)&&(d=s.neg(l),c^=1),new w(a,d,c)}}}(n,o,a),u=function(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");const r=e=>new Uint8Array(e),i=e=>Uint8Array.of(e);let o=r(e),s=r(e),a=0;const l=()=>{o.fill(1),s.fill(0),a=0},c=(...e)=>n(s,o,...e),u=(e=r(0))=>{s=c(i(0),e),o=c(),0!==e.length&&(s=c(i(1),e),o=c())},d=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e{let n;for(l(),u(e);!(n=t(d()));)u();return l(),n}}(t.outputLen,s.BYTES,i);return u(l,c)},verify:function(t,n,r,i={}){const{lowS:o,prehash:a,format:l}=Wb(i,p);if(r=rb("publicKey",r),n=I(rb("message",n),a),"strict"in i)throw new Error("options.strict was renamed to lowS");const c=void 0===l?function(e){let t;const n="string"==typeof e||Ru(e),r=!n&&null!==e&&"object"==typeof e&&"bigint"==typeof e.r&&"bigint"==typeof e.s;if(!n&&!r)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(r)t=new w(e.r,e.s);else if(n){try{t=w.fromBytes(rb("sig",e),"der")}catch(e){if(!(e instanceof Xb.Err))throw e}if(!t)try{t=w.fromBytes(rb("sig",e),"compact")}catch(e){return!1}}return t||!1}(t):w.fromBytes(rb("sig",t),l);if(!1===c)return!1;try{const t=e.fromBytes(r);if(o&&c.hasHighS())return!1;const{r:i,s:a}=c,l=A(n),u=s.inv(a),d=s.create(l*u),f=s.create(i*u),h=e.BASE.multiplyUnsafe(d).add(t.multiplyUnsafe(f));if(h.is0())return!1;return s.create(h.x)===i}catch(e){return!1}},recoverPublicKey:function(e,t,n={}){const{prehash:r}=Wb(n,p);return t=I(t,r),w.fromBytes(e,"recovered").recoverPublicKey(t).toBytes()},Signature:w,hash:t})}function dk(e){const{CURVE:t,curveOpts:n}=function(e){const t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp;let r=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map(e=>Math.ceil(e/2)))):void 0;return{CURVE:t,curveOpts:{Fp:n,Fn:Rb(t.n,{BITS:e.nBitLength,allowedLengths:r,modFromBytes:e.wrapPrivateKey}),allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes}}}(e),r={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:n,hash:e.hash,ecdsaOpts:r}}function fk(e){const{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:i}=dk(e);return function(e,t){const n=t.Point;return Object.assign({},t,{ProjectivePoint:n,CURVE:Object.assign({},e,Db(n.Fn.ORDER,n.Fn.BITS))})}(e,uk(sk(t,n),r,i))} /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const dk={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},fk={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},hk=BigInt(2);const pk=Qb(dk.p,{sqrt:function(e){const t=dk.p,n=BigInt(3),r=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),l=BigInt(88),c=e*e*e%t,u=c*c*e%t,d=vb(u,n,t)*u%t,f=vb(d,n,t)*u%t,h=vb(f,hk,t)*c%t,p=vb(h,i,t)*h%t,g=vb(p,o,t)*p%t,m=vb(g,a,t)*g%t,y=vb(m,l,t)*m%t,w=vb(y,a,t)*g%t,v=vb(w,n,t)*u%t,A=vb(v,s,t)*p%t,b=vb(A,r,t)*c%t,k=vb(b,hk,t);if(!pk.eql(pk.sqr(k),e))throw new Error("Cannot find square root");return k}}),gk=function(e,t){const n=t=>uk({...e,hash:t});return{...n(t),create:n}}({...dk,Fp:pk,lowS:!0,endo:fk},HA),mk=HA,yk="nip46";function wk(e){let t=0n;for(const n of e)t=t<<8n|BigInt(n);return t}function vk(e){const t=gk.utils.randomPrivateKey(),n=gk.ProjectivePoint.fromHex(function(e){const t=(new TextEncoder).encode("Secp256k1_HashToCurve_Cashu_"),n=mk(new Uint8Array([...t,...e]));for(let e=0;e<65536;e++){const t=new Uint8Array(4);new DataView(t.buffer).setUint32(0,e,!0);const r=new Uint8Array([...n,...t]),i=mk(r),o=new Uint8Array([2,...i]);try{if(!gk.ProjectivePoint.fromHex(o).equals(gk.ProjectivePoint.ZERO))return o}catch{}}throw new Error("Failed to hash to curve after 65536 attempts")}(e)),r=gk.ProjectivePoint.BASE.multiply(wk(t));return{B_:n.add(r).toRawBytes(!0),secret:e,r:t}}function Ak(e){const t={k:e.keysetId,s:Mu(e.secret),c:Mu(e.signature),p:Mu(e.pubkey),e:e.expiry,sc:e.scope,kinds:e.kinds,kind_ranges:e.kindRanges},n=JSON.stringify(t);return"cashuA"+btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function bk(e,t,n,r,i,o){const s=vk(crypto.getRandomValues(new Uint8Array(32))),a={blinded_message:Mu(s.B_),scope:t,kinds:i,kind_ranges:o},l=`${e}/cashu/mint`,c=await r(l,"POST"),u=await fetch(l,{method:"POST",headers:{"Content-Type":"application/json",Authorization:c},body:JSON.stringify(a)});if(!u.ok){const e=await u.text();throw new Error(`Mint request failed: ${e}`)}const d=await u.json(),f=Vu(d.blinded_signature),h=Vu(d.mint_pubkey),p=function(e,t,n){const r=gk.ProjectivePoint.fromHex(e),i=gk.ProjectivePoint.fromHex(n).multiply(wk(t));return r.subtract(i).toRawBytes(!0)}(f,s.r,h);return{keysetId:d.keyset_id,secret:s.secret,signature:p,pubkey:n,expiry:d.expiry,scope:t,kinds:i,kindRanges:o}}async function kk(e){let t=e.replace("wss://","https://").replace("ws://","http://").replace(/\/$/,"");try{const e=await fetch(`${t}/cashu/info`);if(!e.ok)return null;const n=await e.json();return n.mintUrl=t,n}catch{return null}}const Ik="connect",Ek="get_public_key",Ck="sign_event",xk="nip04_encrypt",Bk="nip04_decrypt",Sk="ping";class Fk{constructor(e,t,n){this.relayUrl=e,this.userPubkey=t,this.userPrivkey=n,this.ws=null,this.connected=!1,this.allowedSecrets=new Set,this.connectedClients=new Map,this.requestLog=[],this.heartbeatInterval=null,this.subscriptionId=null,this.catToken=null,this.onClientConnected=null,this.onClientDisconnected=null,this.onRequest=null,this.onStatusChange=null}addAllowedSecret(e){this.allowedSecrets.add(e)}removeAllowedSecret(e){this.allowedSecrets.delete(e)}setCatToken(e){this.catToken=e}async connect(){return new Promise((e,t)=>{let n=this.relayUrl;if(n.startsWith("http://")?n="ws://"+n.slice(7):n.startsWith("https://")?n="wss://"+n.slice(8):n.startsWith("ws://")||n.startsWith("wss://")||(n="wss://"+n),this.catToken){const e=Ak(this.catToken),t=new URL(n);t.searchParams.set("token",e),n=t.toString()}console.log("[BunkerService] Connecting to:",n.split("?")[0]);const r=new WebSocket(n),i=setTimeout(()=>{r.close(),t(new Error("Connection timeout"))},1e4);r.onopen=()=>{clearTimeout(i),this.ws=r,this.connected=!0,console.log("[BunkerService] Connected to relay"),this.subscriptionId=function(e=16){const t=new Uint8Array(e);return crypto.getRandomValues(t),Mu(t)}(8);const t=JSON.stringify(["REQ",this.subscriptionId,{kinds:[24133],"#p":[this.userPubkey],since:Math.floor(Date.now()/1e3)-60}]);r.send(t),console.log("[BunkerService] Subscribed to NIP-46 events"),this.startHeartbeat(),this.onStatusChange&&this.onStatusChange("connected"),e()},r.onerror=e=>{clearTimeout(i),console.error("[BunkerService] WebSocket error:",e),t(new Error("WebSocket error"))},r.onclose=()=>{this.connected=!1,this.ws=null,this.stopHeartbeat(),console.log("[BunkerService] Disconnected from relay"),this.onStatusChange&&this.onStatusChange("disconnected")},r.onmessage=e=>{this.handleMessage(e.data)}})}startHeartbeat(e=3e4){this.stopHeartbeat(),this.heartbeatInterval=setInterval(()=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN){const e=JSON.stringify(["REQ",this.subscriptionId,{kinds:[24133],"#p":[this.userPubkey],since:Math.floor(Date.now()/1e3)-60}]);this.ws.send(e)}},e)}stopHeartbeat(){this.heartbeatInterval&&(clearInterval(this.heartbeatInterval),this.heartbeatInterval=null)}disconnect(){this.stopHeartbeat(),this.ws&&(this.subscriptionId&&this.ws.send(JSON.stringify(["CLOSE",this.subscriptionId])),this.ws.close(),this.ws=null),this.connected=!1,this.connectedClients.clear()}async handleMessage(e){try{const t=JSON.parse(e);if(!Array.isArray(t))return;const[n,...r]=t;if("EVENT"===n){const[,e]=r;24133===e.kind&&await this.handleNIP46Request(e)}else"OK"===n?console.log("[BunkerService] Event published:",r[0]?.substring(0,8)):"NOTICE"===n&&console.warn("[BunkerService] Relay notice:",r[0])}catch(e){console.error("[BunkerService] Failed to parse message:",e)}}async handleNIP46Request(e){try{const t=Mu(this.userPrivkey),n=await gs.decrypt(t,e.pubkey,e.content),r=JSON.parse(n);console.log("[BunkerService] Received request:",r.method,"from:",e.pubkey.substring(0,8)),this.requestLog.push({id:r.id,method:r.method,from:e.pubkey,timestamp:Date.now()}),this.requestLog.length>100&&this.requestLog.shift(),this.onRequest&&this.onRequest(r,e.pubkey);let i=null,o=null;try{switch(r.method){case Ik:i=await this.handleConnect(r,e.pubkey);break;case Ek:i=await this.handleGetPublicKey(r,e.pubkey);break;case Ck:i=await this.handleSignEvent(r,e.pubkey);break;case xk:i=await this.handleNip04Encrypt(r,e.pubkey);break;case Bk:i=await this.handleNip04Decrypt(r,e.pubkey);break;case Sk:i="pong";break;default:o=`Unknown method: ${r.method}`}}catch(e){console.error("[BunkerService] Error handling request:",e),o=e.message}await this.sendResponse(r.id,i,o,e.pubkey)}catch(e){console.error("[BunkerService] Failed to handle NIP-46 request:",e)}}async handleConnect(e,t){const[n,r]=e.params;if(this.allowedSecrets.size>0&&(!r||!this.allowedSecrets.has(r)))throw new Error("Invalid or missing connection secret");return this.connectedClients.set(t,{clientPubkey:n||t,connectedAt:Date.now(),lastActivity:Date.now()}),console.log("[BunkerService] Client connected:",t.substring(0,8)),this.onClientConnected&&this.onClientConnected(t),"ack"}async handleGetPublicKey(e,t){return this.connectedClients.has(t)&&(this.connectedClients.get(t).lastActivity=Date.now()),this.userPubkey}async handleSignEvent(e,t){if(!this.connectedClients.has(t))throw new Error("Not connected");this.connectedClients.get(t).lastActivity=Date.now();const[n]=e.params,r=JSON.parse(n);if(r.pubkey&&r.pubkey!==this.userPubkey)throw new Error("Event pubkey does not match signer pubkey");r.pubkey=this.userPubkey;const i=JSON.stringify([0,r.pubkey,r.created_at,r.kind,r.tags,r.content]),o=await crypto.subtle.digest("SHA-256",(new TextEncoder).encode(i));r.id=Mu(new Uint8Array(o));const s=gk.sign(Vu(r.id),this.userPrivkey);return r.sig=s.toCompactHex(),console.log("[BunkerService] Signed event:",r.id.substring(0,8),"kind:",r.kind),JSON.stringify(r)}async handleNip04Encrypt(e,t){if(!this.connectedClients.has(t))throw new Error("Not connected");this.connectedClients.get(t).lastActivity=Date.now();const[n,r]=e.params,i=Mu(this.userPrivkey);return await gs.encrypt(i,n,r)}async handleNip04Decrypt(e,t){if(!this.connectedClients.has(t))throw new Error("Not connected");this.connectedClients.get(t).lastActivity=Date.now();const[n,r]=e.params,i=Mu(this.userPrivkey);return await gs.decrypt(i,n,r)}async sendResponse(e,t,n,r){if(!this.ws||!this.connected)return void console.error("[BunkerService] Cannot send response: not connected");const i={id:e,result:null!==t?t:void 0,error:null!==n?n:void 0},o=Mu(this.userPrivkey),s=await gs.encrypt(o,r,JSON.stringify(i)),a={kind:24133,pubkey:this.userPubkey,created_at:Math.floor(Date.now()/1e3),content:s,tags:[["p",r]]},l=JSON.stringify([0,a.pubkey,a.created_at,a.kind,a.tags,a.content]),c=await crypto.subtle.digest("SHA-256",(new TextEncoder).encode(l));a.id=Mu(new Uint8Array(c));const u=gk.sign(Vu(a.id),this.userPrivkey);a.sig=u.toCompactHex(),this.ws.send(JSON.stringify(["EVENT",a])),console.log("[BunkerService] Sent response for:",e)}isConnected(){return this.connected}getConnectedClients(){return Array.from(this.connectedClients.entries()).map(([e,t])=>({pubkey:e,...t}))}getRequestLog(){return[...this.requestLog]}}function Qk(e,t,n){const r=e.slice();return r[48]=t[n],r}function Dk(e,t,n){const r=e.slice();return r[52]=t[n],r}function Rk(t){let n,r,i,o,s,a;return{c(){n=h("div"),r=h("p"),r.textContent="Please log in to access remote signing.",i=m(),o=h("button"),o.textContent="Log In",A(r,"class","svelte-13nqrp7"),A(o,"class","login-btn svelte-13nqrp7"),A(n,"class","login-prompt svelte-13nqrp7")},m(e,l){u(e,n,l),c(n,r),c(n,i),c(n,o),s||(a=w(o,"click",t[24]),s=!0)},p:e,d(e){e&&d(n),s=!1,a()}}}function Pk(e){let t,n,r,i,o,s,a,l,f=(e[3]||"read-only")+"";return{c(){t=h("div"),n=h("div"),r=h("h3"),r.textContent="Access Denied",i=m(),o=h("p"),s=g("You need write access to use remote signing. Your current access level: "),a=h("strong"),l=g(f),A(r,"class","svelte-13nqrp7"),A(o,"class","svelte-13nqrp7"),A(n,"class","access-denied svelte-13nqrp7"),A(t,"class","bunker-view svelte-13nqrp7")},m(e,d){u(e,t,d),c(t,n),c(n,r),c(n,i),c(n,o),c(o,s),c(o,a),c(a,l)},p(e,t){8&t[0]&&f!==(f=(e[3]||"read-only")+"")&&k(l,f)},d(e){e&&d(t)}}}function $k(e){let t,n,r,i,o,s,a,l,f,p,y,v=e[7]?"Loading...":"Refresh",b=e[8]&&Tk(e),I=e[4]?.cashu_enabled&&"none"!==e[4]?.acl_mode&&Nk();function E(e,t){return e[7]&&!e[4]?Ok:e[4]?Lk:void 0}let C=E(e),x=C&&C(e);return{c(){t=h("div"),n=h("div"),r=h("h3"),r.textContent="Remote Signing (NIP-46 Bunker)",i=m(),o=h("button"),s=g(v),a=m(),b&&b.c(),l=m(),I&&I.c(),f=m(),x&&x.c(),A(r,"class","svelte-13nqrp7"),A(o,"class","refresh-btn svelte-13nqrp7"),o.disabled=e[7],A(n,"class","header-section svelte-13nqrp7"),A(t,"class","bunker-view svelte-13nqrp7")},m(d,h){u(d,t,h),c(t,n),c(n,r),c(n,i),c(n,o),c(o,s),c(t,a),b&&b.m(t,null),c(t,l),I&&I.m(t,null),c(t,f),x&&x.m(t,null),p||(y=w(o,"click",e[21]),p=!0)},p(e,n){128&n[0]&&v!==(v=e[7]?"Loading...":"Refresh")&&k(s,v),128&n[0]&&(o.disabled=e[7]),e[8]?b?b.p(e,n):(b=Tk(e),b.c(),b.m(t,l)):b&&(b.d(1),b=null),e[4]?.cashu_enabled&&"none"!==e[4]?.acl_mode?I||(I=Nk(),I.c(),I.m(t,f)):I&&(I.d(1),I=null),C===(C=E(e))&&x?x.p(e,n):(x&&x.d(1),x=C&&C(e),x&&(x.c(),x.m(t,null)))},d(e){e&&d(t),b&&b.d(),I&&I.d(),x&&x.d(),p=!1,y()}}}function Uk(t){let n;return{c(){n=h("div"),n.innerHTML='

    Remote Signing Not Available

    \n

    This relay does not have bunker mode enabled, or ACL mode is set to "none".

    \n

    Remote signing requires the relay operator to enable ACL mode "follows" or "managed".

    ',A(n,"class","bunker-view svelte-13nqrp7")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Tk(e){let t,n;return{c(){t=h("div"),n=g(e[8]),A(t,"class","error-message svelte-13nqrp7")},m(e,r){u(e,t,r),c(t,n)},p(e,t){256&t[0]&&k(n,e[8])},d(e){e&&d(t)}}}function Nk(e){let t;return{c(){t=h("div"),t.innerHTML="CAT Required: This relay requires Cashu Access Tokens (CAT) for bunker connections.\n Your client must support CAT authentication or connections will be rejected.",A(t,"class","cat-warning svelte-13nqrp7")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Lk(e){let t,n,i,o,s,a,l,f,p,y,v,b,I,E,C,x,S,F,Q,D,R,P,$,U,T,N,L,O,M,_,H,j,G,q,K,J,V,Y,z,W,Z=e[10]?"Active":"Inactive",X=e[4].relay_url+"",ee="relay"===e[9]?"Copied!":"Copy";function te(e,t){return e[2]?Mk:_k}let ne=te(e),re=ne(e),ie=e[6].length>0&&Kk(e);return{c(){t=h("div"),t.innerHTML='

    How it works: Start the bunker service to allow remote apps (like Smesh) to request signatures from your ORLY account.\n Share the QR code or bunker URL with your client app.

    ',n=m(),i=h("div"),o=h("div"),s=h("h4"),s.textContent="Bunker Service",a=m(),l=h("div"),f=h("span"),p=m(),y=g(Z),v=m(),re.c(),b=m(),ie&&ie.c(),I=m(),E=h("div"),C=h("h4"),C.textContent="Connection Details",x=m(),S=h("div"),F=h("span"),F.textContent="Relay:",Q=m(),D=h("code"),R=g(X),P=m(),$=h("button"),U=g(ee),T=m(),N=h("div"),L=h("span"),L.textContent="Your npub:",O=m(),M=h("code"),_=g(e[1]),H=m(),j=h("div"),G=h("span"),G.textContent="Secret:",q=m(),K=h("code"),J=g(e[5]),V=m(),Y=h("button"),Y.textContent="Regenerate",A(t,"class","instructions svelte-13nqrp7"),A(s,"class","svelte-13nqrp7"),A(f,"class","status-dot svelte-13nqrp7"),A(l,"class","service-status svelte-13nqrp7"),B(l,"active",e[10]),A(o,"class","service-header svelte-13nqrp7"),A(i,"class","service-control svelte-13nqrp7"),A(C,"class","svelte-13nqrp7"),A(F,"class","label svelte-13nqrp7"),A(D,"class","svelte-13nqrp7"),A($,"class","copy-btn svelte-13nqrp7"),A(S,"class","info-row svelte-13nqrp7"),A(L,"class","label svelte-13nqrp7"),A(M,"class","npub svelte-13nqrp7"),A(N,"class","info-row svelte-13nqrp7"),A(G,"class","label svelte-13nqrp7"),A(K,"class","secret svelte-13nqrp7"),A(Y,"class","copy-btn svelte-13nqrp7"),A(j,"class","info-row svelte-13nqrp7"),A(E,"class","connection-info svelte-13nqrp7")},m(r,d){u(r,t,d),u(r,n,d),u(r,i,d),c(i,o),c(o,s),c(o,a),c(o,l),c(l,f),c(l,p),c(l,y),c(i,v),re.m(i,null),u(r,b,d),ie&&ie.m(r,d),u(r,I,d),u(r,E,d),c(E,C),c(E,x),c(E,S),c(S,F),c(S,Q),c(S,D),c(D,R),c(S,P),c(S,$),c($,U),c(E,T),c(E,N),c(N,L),c(N,O),c(N,M),c(M,_),c(E,H),c(E,j),c(j,G),c(j,q),c(j,K),c(K,J),c(j,V),c(j,Y),z||(W=[w($,"click",e[37]),w(Y,"click",e[22])],z=!0)},p(e,t){1024&t[0]&&Z!==(Z=e[10]?"Active":"Inactive")&&k(y,Z),1024&t[0]&&B(l,"active",e[10]),ne===(ne=te(e))&&re?re.p(e,t):(re.d(1),re=ne(e),re&&(re.c(),re.m(i,null))),e[6].length>0?ie?ie.p(e,t):(ie=Kk(e),ie.c(),ie.m(I.parentNode,I)):ie&&(ie.d(1),ie=null),16&t[0]&&X!==(X=e[4].relay_url+"")&&k(R,X),512&t[0]&&ee!==(ee="relay"===e[9]?"Copied!":"Copy")&&k(U,ee),2&t[0]&&k(_,e[1]),32&t[0]&&k(J,e[5])},d(e){e&&d(t),e&&d(n),e&&d(i),re.d(),e&&d(b),ie&&ie.d(e),e&&d(I),e&&d(E),z=!1,r(W)}}}function Ok(t){let n;return{c(){n=h("div"),n.textContent="Loading bunker information...",A(n,"class","loading svelte-13nqrp7")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Mk(e){let t,n,r;function i(e,t){return e[10]?jk:Hk}let o=i(e),s=o(e),a=e[10]&&e[12].length>0&&Gk(e);return{c(){t=h("div"),s.c(),n=m(),a&&a.c(),r=y(),A(t,"class","service-actions svelte-13nqrp7")},m(e,i){u(e,t,i),s.m(t,null),u(e,n,i),a&&a.m(e,i),u(e,r,i)},p(e,n){o===(o=i(e))&&s?s.p(e,n):(s.d(1),s=o(e),s&&(s.c(),s.m(t,null))),e[10]&&e[12].length>0?a?a.p(e,n):(a=Gk(e),a.c(),a.m(r.parentNode,r)):a&&(a.d(1),a=null)},d(e){e&&d(t),s.d(),e&&d(n),a&&a.d(e),e&&d(r)}}}function _k(t){let n;return{c(){n=h("div"),n.textContent="Bunker service requires nsec login. Please log in with your private key to enable remote signing.",A(n,"class","no-privkey-warning svelte-13nqrp7")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Hk(e){let t,n,r,i,o=e[11]?"Starting...":"Start Service";return{c(){t=h("button"),n=g(o),A(t,"class","start-btn svelte-13nqrp7"),t.disabled=e[11]},m(o,s){u(o,t,s),c(t,n),r||(i=w(t,"click",e[19]),r=!0)},p(e,r){2048&r[0]&&o!==(o=e[11]?"Starting...":"Start Service")&&k(n,o),2048&r[0]&&(t.disabled=e[11])},d(e){e&&d(t),r=!1,i()}}}function jk(t){let n,r,i;return{c(){n=h("button"),n.textContent="Stop Service",A(n,"class","stop-btn svelte-13nqrp7")},m(e,o){u(e,n,o),r||(i=w(n,"click",t[20]),r=!0)},p:e,d(e){e&&d(n),r=!1,i()}}}function Gk(e){let t,n,r,i,o,s,a=e[12].length+"",l=e[12],p=[];for(let t=0;te[48].id;for(let t=0;tl.p(e,t)):(l=u(r,e),l.c()),w.set(r,y[g]=l),r in m&&v.set(r,Math.abs(g-m[r]))}const b=new Set,k=new Set;function I(e){W(e,1),e.m(l,d),a.set(e.key,e),d=e.first,p--}for(;h&&p;){const t=y[p-1],n=e[h-1],r=t.key,i=n.key;t===n?(d=t.first,h--,p--):w.has(i)?!a.has(r)||b.has(r)?I(t):k.has(i)?h--:v.get(r)>v.get(i)?(k.add(r),I(t)):(b.add(i),h--):(c(n,a),h--)}for(;h--;){const t=e[h];w.has(t.key)||c(t,a)}for(;p;)I(y[p-1]);return r(A),y}(v,t,I,1,e,k,b,p,ee,Wk,null,Qk))},d(e){e&&d(t);for(let e=0;et,r.anchor=null},p(t,i){e=t,r.ctx=e,64&i[0]&&n!==(n=e[18](e[48]))&&X(n,r)||function(e,t,n){const r=t.slice(),{resolved:i}=e;e.current===e.then&&(r[e.value]=i),e.current===e.catch&&(r[e.error]=i),e.block.p(r,n)}(r,e,i)},d(e){e&&d(t),r.block.d(),r.token=null,r=null}}}function Vk(t){let n;return{c(){n=h("div"),n.textContent="Failed to generate QR",A(n,"class","error-message svelte-13nqrp7")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Yk(e){let t,n,i,o,s,l,f,p,y,v,b,I,E,C,x,S,F,Q,D,R,P,$,U,T,N,L,O,M,_,H=new Date(e[48].createdAt).toLocaleString()+"",j=new Date(1e3*e[48].token.expiry).toLocaleString()+"",G=`bunker://${e[1]}?relay=${encodeURIComponent(e[4].relay_url)}${e[5]?`&secret=${e[5]}`:""}&cat=${e[48].encoded}`;function q(){return e[35](e[48])}function K(...t){return e[36](e[48],...t)}return{c(){t=h("div"),n=h("div"),i=h("img"),s=m(),l=h("div"),l.textContent="Copied!",f=m(),p=h("div"),y=h("div"),v=h("span"),v.textContent="Created:",b=m(),I=h("span"),E=g(H),C=m(),x=h("div"),S=h("span"),S.textContent="Expires:",F=m(),Q=h("span"),D=g(j),R=m(),P=h("div"),$=h("span"),$.textContent="Bunker URL:",U=m(),T=h("code"),N=g(G),L=m(),O=h("div"),O.textContent="Click QR code to copy URL",a(i.src,o=e[51])||A(i,"src",o),A(i,"alt","Token QR Code"),A(i,"class","qr-code small svelte-13nqrp7"),A(l,"class","qr-overlay svelte-13nqrp7"),B(l,"visible",e[9]===e[48].id),A(n,"class","qr-container small clickable svelte-13nqrp7"),A(n,"role","button"),A(n,"tabindex","0"),A(n,"title","Click to copy bunker URL"),A(v,"class","label svelte-13nqrp7"),A(y,"class","info-item svelte-13nqrp7"),A(S,"class","label svelte-13nqrp7"),A(x,"class","info-item svelte-13nqrp7"),A($,"class","label svelte-13nqrp7"),A(T,"class","bunker-url small svelte-13nqrp7"),A(P,"class","info-item url-item svelte-13nqrp7"),A(O,"class","copy-hint svelte-13nqrp7"),A(p,"class","token-info svelte-13nqrp7"),A(t,"class","token-detail-content svelte-13nqrp7")},m(e,r){u(e,t,r),c(t,n),c(n,i),c(n,s),c(n,l),c(t,f),c(t,p),c(p,y),c(y,v),c(y,b),c(y,I),c(I,E),c(p,C),c(p,x),c(x,S),c(x,F),c(x,Q),c(Q,D),c(p,R),c(p,P),c(P,$),c(P,U),c(P,T),c(T,N),c(p,L),c(p,O),M||(_=[w(n,"click",q),w(n,"keypress",K)],M=!0)},p(t,n){e=t,64&n[0]&&!a(i.src,o=e[51])&&A(i,"src",o),576&n[0]&&B(l,"visible",e[9]===e[48].id),64&n[0]&&H!==(H=new Date(e[48].createdAt).toLocaleString()+"")&&k(E,H),64&n[0]&&j!==(j=new Date(1e3*e[48].token.expiry).toLocaleString()+"")&&k(D,j),114&n[0]&&G!==(G=`bunker://${e[1]}?relay=${encodeURIComponent(e[4].relay_url)}${e[5]?`&secret=${e[5]}`:""}&cat=${e[48].encoded}`)&&k(N,G)},d(e){e&&d(t),M=!1,r(_)}}}function zk(t){let n;return{c(){n=h("div"),n.textContent="Loading QR...",A(n,"class","qr-placeholder small svelte-13nqrp7")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Wk(e,t){let n,i,o,s,a,l,f,p,y,b,I,E,C,x,S,F,Q,D,R,P,$=t[48].isExpanded?"▼":"▶",U=new Date(t[48].createdAt).toLocaleDateString()+"",T=new Date(1e3*t[48].token.expiry).toLocaleDateString()+"";function N(...e){return t[31](t[48],...e)}function L(){return t[32](t[48])}function O(){return t[33](t[48])}function M(...e){return t[34](t[48],...e)}let _=t[48].isExpanded&&Jk(t);return{key:e,first:null,c(){n=h("div"),i=h("div"),o=h("span"),s=g($),a=m(),l=h("input"),p=m(),y=h("span"),b=g(U),I=m(),E=h("span"),C=g("Expires: "),x=g(T),S=m(),F=h("button"),F.textContent="Revoke",Q=m(),_&&_.c(),D=m(),A(o,"class","expand-icon svelte-13nqrp7"),A(l,"type","text"),A(l,"class","token-name-input svelte-13nqrp7"),l.value=f=t[48].name,A(l,"placeholder","Token name"),A(y,"class","token-created svelte-13nqrp7"),A(E,"class","token-expiry svelte-13nqrp7"),A(F,"class","revoke-btn svelte-13nqrp7"),A(F,"title","Revoke this token"),A(i,"class","token-main svelte-13nqrp7"),A(i,"role","button"),A(i,"tabindex","0"),A(n,"class","token-row svelte-13nqrp7"),B(n,"expanded",t[48].isExpanded),this.first=n},m(e,r){u(e,n,r),c(n,i),c(i,o),c(o,s),c(i,a),c(i,l),c(i,p),c(i,y),c(y,b),c(i,I),c(i,E),c(E,C),c(E,x),c(i,S),c(i,F),c(n,Q),_&&_.m(n,null),c(n,D),R||(P=[w(l,"input",N),w(l,"click",v(t[30])),w(F,"click",v(L)),w(i,"click",O),w(i,"keypress",M)],R=!0)},p(e,r){t=e,64&r[0]&&$!==($=t[48].isExpanded?"▼":"▶")&&k(s,$),64&r[0]&&f!==(f=t[48].name)&&l.value!==f&&(l.value=f),64&r[0]&&U!==(U=new Date(t[48].createdAt).toLocaleDateString()+"")&&k(b,U),64&r[0]&&T!==(T=new Date(1e3*t[48].token.expiry).toLocaleDateString()+"")&&k(x,T),t[48].isExpanded?_?_.p(t,r):(_=Jk(t),_.c(),_.m(n,D)):_&&(_.d(1),_=null),64&r[0]&&B(n,"expanded",t[48].isExpanded)},d(e){e&&d(n),_&&_.d(),R=!1,r(P)}}}function Zk(t){let n;function r(e,t){return e[4]?.available?e[13]?$k:e[0]?Pk:Rk:Uk}let i=r(t),o=i(t);return{c(){o.c(),n=y()},m(e,t){o.m(e,t),u(e,n,t)},p(e,t){i===(i=r(e))&&o?o.p(e,t):(o.d(1),o=i(e),o&&(o.c(),o.m(n.parentNode,n)))},i:e,o:e,d(e){o.d(e),e&&d(n)}}}function Xk(){const e=new Uint8Array(16);return crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,"0")).join("")}function eI(e,t,n){let r,i,o,s,{isLoggedIn:a=!1}=t,{userPubkey:l=""}=t,{userSigner:c=null}=t,{userPrivkey:u=null}=t,{currentEffectiveRole:d=""}=t;const f=P();let h=null,p=!1,g="",m="",y="",w=null,v=!1,A=!1,b=[],k=null,I=[],E=null;const C=["brave","calm","clever","cosmic","cozy","daring","eager","fancy","gentle","happy","jolly","keen","lively","merry","nimble","peppy","quick","rustic","shiny","swift","tender","vivid","witty","zesty"],x=["badger","bunny","coral","dolphin","falcon","gecko","heron","iguana","jaguar","koala","lemur","mango","narwhal","otter","panda","quail","rabbit","salmon","turtle","urchin","viper","walrus","yak","zebra"];async function B(e,t){const r=await bk(e.mintUrl,yk,Vu(l),t,[24133]),i=Ak(r),o=crypto.randomUUID().split("-")[0],s={id:o,name:`${C[Math.floor(Math.random()*C.length)]}-${x[Math.floor(Math.random()*x.length)]}`,token:r,encoded:i,createdAt:Date.now(),isExpanded:!1};return n(6,I=[...I,s]),E||n(26,E=o),console.log(`Client token "${s.name}" created, expires:`,new Date(1e3*r.expiry).toISOString()),s}function S(e){n(6,I=I.filter(t=>t.id!==e)),E===e&&n(26,E=I.length>0?I[0].id:null),T()}function F(e){n(6,I=I.map(t=>t.id===e?{...t,isExpanded:!t.isExpanded}:t))}function Q(e,t){n(6,I=I.map(n=>n.id===e?{...n,name:t}:n))}async function U(){n(7,p=!0),n(8,g="");try{n(4,h=await async function(){const e=`${window.location.origin}/api/bunker/info`,t=await fetch(e);if(!t.ok){const e=await t.text();throw new Error(e||`Failed to get bunker info: ${t.statusText}`)}return await t.json()}()),y||n(5,y=Xk()),await T()}catch(e){console.error("Error loading bunker info:",e),n(8,g=e.message||"Failed to load bunker information")}finally{n(7,p=!1)}}async function T(){o&&await ov.toDataURL(o,{width:280,margin:2,color:{dark:"#000000",light:"#ffffff"}}),s&&await ov.toDataURL(s,{width:280,margin:2,color:{dark:"#000000",light:"#ffffff"}})}function N(e,t){navigator.clipboard.writeText(e),n(9,m=t),setTimeout(()=>{n(9,m="")},2e3)}D(async()=>{await U()}),R(()=>{w&&(w.disconnect(),w=null,n(10,v=!1))});return e.$$set=e=>{"isLoggedIn"in e&&n(0,a=e.isLoggedIn),"userPubkey"in e&&n(1,l=e.userPubkey),"userSigner"in e&&n(25,c=e.userSigner),"userPrivkey"in e&&n(2,u=e.userPrivkey),"currentEffectiveRole"in e&&n(3,d=e.currentEffectiveRole)},e.$$.update=()=>{11&e.$$.dirty[0]&&n(13,r=a&&l&&("write"===d||"admin"===d||"owner"===d)),67108928&e.$$.dirty[0]&&n(29,i=I.find(e=>e.id===E)),536870962&e.$$.dirty[0]&&n(28,o=h&&l&&i?`bunker://${l}?relay=${encodeURIComponent(h.relay_url)}${y?`&secret=${y}`:""}&cat=${i.encoded}`:""),16&e.$$.dirty[0]&&n(27,s=h?`nostr+connect://${h.relay_url}`:""),402653184&e.$$.dirty[0]&&(o||s)&&T()},[a,l,u,d,h,y,I,p,g,m,v,A,b,r,async function(){if(h?.cashu_enabled)try{const e=await kk(h.relay_url);if(!e)return;const t=async(e,t)=>`Nostr ${await $A(c,l,t,e)}`;await B(e,t),await T()}catch(e){console.error("Failed to add token:",e),n(8,g=e.message||"Failed to add token")}},S,F,Q,async function(e){if(!h||!l)return null;const t=`bunker://${l}?relay=${encodeURIComponent(h.relay_url)}${y?`&secret=${y}`:""}&cat=${e.encoded}`;return await ov.toDataURL(t,{width:200,margin:2,color:{dark:"#000000",light:"#ffffff"}})},async function(){if(v||A)console.log("Service already active or starting, ignoring");else if(u&&l&&h){n(11,A=!0),n(8,g="");try{if(h.cashu_enabled){console.log("CAT required, minting tokens...");const e=await kk(h.relay_url);if(e){const t=async(e,t)=>`Nostr ${await $A(c,l,t,e)}`;k=await bk(e.mintUrl,yk,Vu(l),t,[24133]),console.log("Service CAT token acquired, expires:",new Date(1e3*k.expiry).toISOString()),await B(e,t)}}w=new Fk(h.relay_url,l,u),y&&w.addAllowedSecret(y),k&&w.setCatToken(k),w.onClientConnected=e=>{n(12,b=w.getConnectedClients())},w.onStatusChange=e=>{console.log("[BunkerView] Service status changed:",e),n(10,v="connected"===e),"disconnected"===e&&n(12,b=[])},await w.connect(),n(10,v=!0),await T(),console.log("Bunker service started successfully")}catch(e){console.error("Failed to start bunker service:",e),n(8,g=e.message||"Failed to start bunker service"),w=null,n(10,v=!1),k=null,n(6,I=[]),n(26,E=null)}finally{n(11,A=!1)}}else n(8,g="Missing private key or bunker info")},function(){w&&(w.disconnect(),w=null),n(10,v=!1),n(12,b=[]),k=null,n(6,I=[]),n(26,E=null),T()},U,async function(){n(5,y=Xk()),await T()},N,function(){f("openLoginModal")},c,E,s,o,i,function(t){$.call(this,e,t)},(e,t)=>Q(e.id,t.target.value),e=>S(e.id),e=>F(e.id),(e,t)=>"Enter"===t.key&&F(e.id),e=>{N(`bunker://${l}?relay=${encodeURIComponent(h.relay_url)}${y?`&secret=${y}`:""}&cat=${e.encoded}`,e.id)},(e,t)=>{if("Enter"===t.key){N(`bunker://${l}?relay=${encodeURIComponent(h.relay_url)}${y?`&secret=${y}`:""}&cat=${e.encoded}`,e.id)}},()=>N(h.relay_url,"relay")]}class tI extends ae{constructor(e){super(),se(this,e,eI,Zk,o,{isLoggedIn:0,userPubkey:1,userSigner:25,userPrivkey:2,currentEffectiveRole:3},null,[-1,-1])}}function nI(e,t,n){const r=e.slice();return r[29]=t[n],r}function rI(e,t,n){const r=e.slice();return r[32]=t[n],r}function iI(e){let t,n,r;function i(e,t){return e[0]?sI:aI}let o=i(e),s=o(e);return{c(){t=h("div"),n=h("p"),n.textContent="Log viewer is only available to relay owners.",r=m(),s.c(),A(n,"class","svelte-w6h7aj"),A(t,"class","login-prompt svelte-w6h7aj")},m(e,i){u(e,t,i),c(t,n),c(t,r),s.m(t,null)},p(e,n){o===(o=i(e))&&s?s.p(e,n):(s.d(1),s=o(e),s&&(s.c(),s.m(t,null)))},d(e){e&&d(t),s.d()}}}function oI(e){let t,n,i,o,s,a,l,p,y,v,b,I,E,x,B,S,F,Q,D,R,P,$,U,T,N,L,O,M,H,j,G,q=e[3]?"Loading...":"Refresh",K=e[2].length+"",J=e[12],V=[];for(let t=0;te[18].call(y)),A(a,"class","level-selector svelte-w6h7aj"),A(b,"class","clear-btn svelte-w6h7aj"),b.disabled=E=e[3]||0===e[2].length,A(B,"class","refresh-btn svelte-w6h7aj"),B.disabled=e[3],A(s,"class","header-controls svelte-w6h7aj"),A(n,"class","header-section svelte-w6h7aj"),A(R,"class","log-info svelte-w6h7aj"),A(H,"class","log-list svelte-w6h7aj"),A(t,"class","log-view svelte-w6h7aj")},m(r,d){u(r,t,d),c(t,n),c(n,i),c(n,o),c(n,s),c(s,a),c(a,l),c(a,p),c(a,y);for(let e=0;eNo logs available.

    ",A(n,"class","empty-state svelte-w6h7aj")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function fI(e){let t,n,r,i,o=e[29].file+"",s=e[29].line+"";return{c(){t=h("span"),n=g(o),r=g(":"),i=g(s),A(t,"class","log-location svelte-w6h7aj")},m(e,o){u(e,t,o),c(t,n),c(t,r),c(t,i)},p(e,t){4&t[0]&&o!==(o=e[29].file+"")&&k(n,o),4&t[0]&&s!==(s=e[29].line+"")&&k(i,s)},d(e){e&&d(t)}}}function hI(e){let t,n,r,i,o,s,a,l,f,p,y,w=wI(e[29].timestamp)+"",v=e[29].level+"",b=e[29].message+"",I=e[29].file&&fI(e);return{c(){t=h("div"),n=h("span"),r=g(w),i=m(),o=h("span"),s=g(v),l=m(),I&&I.c(),f=m(),p=h("span"),y=g(b),A(n,"class","log-timestamp svelte-w6h7aj"),A(o,"class",a="log-level "+vI(e[29].level)+" svelte-w6h7aj"),A(p,"class","log-message svelte-w6h7aj"),A(t,"class","log-entry svelte-w6h7aj")},m(e,a){u(e,t,a),c(t,n),c(n,r),c(t,i),c(t,o),c(o,s),c(t,l),I&&I.m(t,null),c(t,f),c(t,p),c(p,y)},p(e,n){4&n[0]&&w!==(w=wI(e[29].timestamp)+"")&&k(r,w),4&n[0]&&v!==(v=e[29].level+"")&&k(s,v),4&n[0]&&a!==(a="log-level "+vI(e[29].level)+" svelte-w6h7aj")&&A(o,"class",a),e[29].file?I?I.p(e,n):(I=fI(e),I.c(),I.m(t,f)):I&&(I.d(1),I=null),4&n[0]&&b!==(b=e[29].message+"")&&k(y,b)},d(e){e&&d(t),I&&I.d()}}}function pI(e){let t;return{c(){t=h("span"),t.textContent="End of logs"},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function gI(e){let t;return{c(){t=h("span"),t.textContent="Scroll for more"},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function mI(e){let t;return{c(){t=h("span"),t.textContent="Loading more..."},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function yI(t){let n;function r(e,t){return e[4]?oI:iI}let i=r(t),o=i(t);return{c(){o.c(),n=y()},m(e,t){o.m(e,t),u(e,n,t)},p(e,t){i===(i=r(e))&&o?o.p(e,t):(o.d(1),o=i(e),o&&(o.c(),o.m(n.parentNode,n)))},i:e,o:e,d(e){o.d(e),e&&d(n)}}}function wI(e){if(!e)return"";return new Date(e).toLocaleString()}function vI(e){switch(e?.toUpperCase()){case"TRC":case"TRACE":return"level-trace";case"DBG":case"DEBUG":return"level-debug";case"INF":case"INFO":default:return"level-info";case"WRN":case"WARN":return"level-warn";case"ERR":case"ERROR":return"level-error";case"FTL":case"FATAL":return"level-fatal"}}function AI(e,t,n){let r,{isLoggedIn:i=!1}=t,{userRole:o=""}=t,{userSigner:s=null}=t;const a=P();let l=[],c=!1,u=!0,d=0,f=0,h="",p="info",g="info";const m=["trace","debug","info","warn","error","fatal"];let y,w,v;async function A(e="GET",t="/api/logs"){if(!s)return null;try{const n={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",`${window.location.origin}${t}`],["method",e]],content:""},r=await s.signEvent(n);return btoa(JSON.stringify(r)).replace(/\+/g,"-").replace(/\//g,"_")}catch(e){return console.error("Error creating auth header:",e),null}}async function b(e=!1){if(!c){n(3,c=!0),n(7,h=""),e&&(d=0,n(2,l=[]));try{const t=`/api/logs?offset=${d}&limit=100`,r=await A("GET",t),i=`${window.location.origin}${t}`,o=await fetch(i,{headers:r?{Authorization:`Nostr ${r}`}:{}});if(!o.ok)throw new Error(`Failed to load logs: ${o.statusText}`);const s=await o.json();n(2,l=e?s.logs||[]:[...l,...s.logs||[]]),n(6,f=s.total||0),n(5,u=s.has_more||!1),d=l.length}catch(e){console.error("Error loading logs:",e),n(7,h=e.message||"Failed to load logs")}finally{n(3,c=!1)}}}async function k(){try{const e=await fetch(`${window.location.origin}/api/logs/level`);if(e.ok){const t=await e.json();n(8,p=t.level||"info"),n(9,g=p)}}catch(e){console.error("Error loading log level:",e)}}D(()=>{r&&(b(!0),k(),function(){if(!w)return;v=new IntersectionObserver(e=>{e[0].isIntersecting&&u&&!c&&u&&!c&&b(!1)},{threshold:.1}),v.observe(w)}())}),R(()=>{v&&v.disconnect()});return e.$$set=e=>{"isLoggedIn"in e&&n(0,i=e.isLoggedIn),"userRole"in e&&n(1,o=e.userRole),"userSigner"in e&&n(17,s=e.userSigner)},e.$$.update=()=>{3&e.$$.dirty[0]&&n(4,r=i&&"owner"===o),28&e.$$.dirty[0]&&r&&0===l.length&&!c&&(b(!0),k())},[i,o,l,c,r,u,f,h,p,g,y,w,m,b,async function(){if(g!==p)try{const e=await A("POST","/api/logs/level"),t=await fetch(`${window.location.origin}/api/logs/level`,{method:"POST",headers:{"Content-Type":"application/json",...e?{Authorization:`Nostr ${e}`}:{}},body:JSON.stringify({level:g})});if(!t.ok)throw new Error(`Failed to set log level: ${t.statusText}`);const r=await t.json();n(8,p=r.level),n(9,g=p)}catch(e){console.error("Error setting log level:",e),n(7,h=e.message||"Failed to set log level"),n(9,g=p)}},async function(){if(confirm("Are you sure you want to clear all logs?"))try{const e=await A("POST","/api/logs/clear"),t=await fetch(`${window.location.origin}/api/logs/clear`,{method:"POST",headers:e?{Authorization:`Nostr ${e}`}:{}});if(!t.ok)throw new Error(`Failed to clear logs: ${t.statusText}`);n(2,l=[]),d=0,n(5,u=!1),n(6,f=0)}catch(e){console.error("Error clearing logs:",e),n(7,h=e.message||"Failed to clear logs")}},function(){a("openLoginModal")},s,function(){g=x(this),n(9,g),n(12,m)},()=>b(!0),function(e){T[e?"unshift":"push"](()=>{w=e,n(11,w)})},function(e){T[e?"unshift":"push"](()=>{y=e,n(10,y)})}]}class bI extends ae{constructor(e){super(),se(this,e,AI,yI,o,{isLoggedIn:0,userRole:1,userSigner:17},null,[-1,-1])}}function kI(e){let t,n,r,i,o,s,a,l,f,p,y;return{c(){t=h("div"),n=h("div"),r=h("h3"),r.textContent="Active Filter",i=m(),o=h("button"),o.textContent="🧹 Sweep",s=m(),a=h("div"),l=h("pre"),f=g(e[2]),A(r,"class","svelte-1tyqaa5"),A(o,"class","sweep-btn svelte-1tyqaa5"),A(o,"title","Clear filter"),A(n,"class","filter-display-header svelte-1tyqaa5"),A(l,"class","filter-json svelte-1tyqaa5"),A(a,"class","filter-json-container svelte-1tyqaa5"),A(t,"class","filter-display svelte-1tyqaa5")},m(d,h){u(d,t,h),c(t,n),c(n,r),c(n,i),c(n,o),c(t,s),c(t,a),c(a,l),c(l,f),p||(y=w(o,"click",e[3]),p=!0)},p(e,t){4&t&&k(f,e[2])},d(e){e&&d(t),p=!1,y()}}}function II(t){let n,r=t[0]&&t[1]&&kI(t);return{c(){r&&r.c(),n=y()},m(e,t){r&&r.m(e,t),u(e,n,t)},p(e,[t]){e[0]&&e[1]?r?r.p(e,t):(r=kI(e),r.c(),r.m(n.parentNode,n)):r&&(r.d(1),r=null)},i:e,o:e,d(e){r&&r.d(e),e&&d(n)}}}function EI(e,t,n){let r,i;const o=P();let{filter:s={}}=t,{showFilter:a=!0}=t;return e.$$set=e=>{"filter"in e&&n(4,s=e.filter),"showFilter"in e&&n(0,a=e.showFilter)},e.$$.update=()=>{16&e.$$.dirty&&n(2,r=function(e){return JSON.stringify(e,null,2)}(s)),16&e.$$.dirty&&n(1,i=Object.keys(s).length>0)},[a,i,r,function(){o("sweep")},s]}class CI extends ae{constructor(e){super(),se(this,e,EI,II,o,{filter:4,showFilter:0})}}function xI(e){return Bh[e]||`Kind ${e}`}function BI(e){return e?e.slice(0,8)+"..."+e.slice(-8):"unknown"}function SI(e,t=100){return e?e.length>t?e.slice(0,t)+"...":e:""}function FI(e){return e?new Date(1e3*e).toLocaleString():""}class QI{constructor(e,t,n){this.relayUrl=e,this.userSigner=t,this.userPubkey=n,this.ws=null,this.challenge=null,this.isAuthenticated=!1,this.authPromise=null}async connect(){return new Promise((e,t)=>{this.ws=new WebSocket(this.relayUrl),this.ws.onopen=()=>{console.log("WebSocket connected to relay:",this.relayUrl),e()},this.ws.onmessage=async e=>{try{const t=JSON.parse(e.data);await this.handleMessage(t)}catch(e){console.error("Error parsing relay message:",e)}},this.ws.onerror=e=>{console.error("WebSocket error:",e),t(new Error("Failed to connect to relay"))},this.ws.onclose=()=>{console.log("WebSocket connection closed"),this.isAuthenticated=!1,this.challenge=null},setTimeout(()=>{this.ws.readyState!==WebSocket.OPEN&&t(new Error("Connection timeout"))},1e4)})}async handleMessage(e){const[t,...n]=e;switch(t){case"AUTH":this.challenge=n[0],console.log("Received AUTH challenge:",this.challenge),await this.authenticate();break;case"OK":const[e,r,i]=n;e&&r?(console.log("Authentication successful for event:",e),this.isAuthenticated=!0,this.authPromise&&(this.authPromise.resolve(),this.authPromise=null)):e&&!r&&(console.error("Authentication failed:",i),this.authPromise&&(this.authPromise.reject(new Error(i||"Authentication failed")),this.authPromise=null));break;case"NOTICE":console.log("Relay notice:",n[0]);break;default:console.log("Unhandled message type:",t,n)}}async authenticate(){if(!this.challenge)throw new Error("No challenge received from relay");if(!this.userSigner)throw new Error("No signer available for authentication");try{const e={kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",this.relayUrl],["challenge",this.challenge]],content:"",pubkey:this.userPubkey},t=["AUTH",await this.userSigner.signEvent(e)];return this.ws.send(JSON.stringify(t)),console.log("Sent authentication event to relay"),new Promise((e,t)=>{this.authPromise={resolve:e,reject:t},setTimeout(()=>{this.authPromise&&(this.authPromise.reject(new Error("Authentication timeout")),this.authPromise=null)},1e4)})}catch(e){throw console.error("Authentication error:",e),e}}async publishEvent(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");return new Promise((t,n)=>{const r=["EVENT",e];this.ws.send(JSON.stringify(r));const i=this.ws.onmessage,o=setTimeout(()=>{this.ws.onmessage=i,n(new Error("Publish timeout"))},15e3);this.ws.onmessage=async r=>{try{const s=JSON.parse(r.data),[a,l,c,u]=s;if("OK"===a&&l===e.id)if(c)clearTimeout(o),this.ws.onmessage=i,console.log("Event published successfully:",l),t({success:!0,eventId:l,reason:u});else{if(console.error("Event publish failed:",u),u&&u.includes("auth-required"))return void console.log("Authentication required, waiting for AUTH challenge...");clearTimeout(o),this.ws.onmessage=i,n(new Error(`Publish failed: ${u}`))}else if("AUTH"===a){this.challenge=s[1],console.log("Received AUTH challenge during publish:",this.challenge);try{await this.authenticate(),console.log("Authentication successful, retrying event publish...");const t=["EVENT",e];this.ws.send(JSON.stringify(t))}catch(e){clearTimeout(o),this.ws.onmessage=i,n(new Error(`Authentication failed: ${e.message}`))}}else await this.handleMessage(s)}catch(e){clearTimeout(o),this.ws.onmessage=i,n(e)}}})}close(){this.ws&&(this.ws.close(),this.ws=null),this.isAuthenticated=!1,this.challenge=null}getAuthenticated(){return this.isAuthenticated}}async function DI(e,t,n,r){const i=new QI(e,n,r);try{await i.connect();return await i.publishEvent(t)}finally{i.close()}}function RI(e,t,n){const r=e.slice();return r[170]=t[n],r}function PI(e,t,n){const r=e.slice();return r[180]=t[n],r}function $I(e,t,n){const r=e.slice();return r[173]=t[n],r}function UI(e,t,n){const r=e.slice();r[173]=t[n];const i=r[53](r[173]);return r[174]=i,r}function TI(e,t,n){const r=e.slice();return r[177]=t[n],r}function NI(t){let n;function r(e,t){return e[1]?WI:zI}let i=r(t),o=i(t);return{c(){n=h("div"),o.c(),A(n,"class","welcome-message svelte-u3u5mw")},m(e,t){u(e,n,t),o.m(n,null)},p(e,t){i===(i=r(e))&&o?o.p(e,t):(o.d(1),o=i(e),o&&(o.c(),o.m(n,null)))},i:e,o:e,d(e){e&&d(n),o.d()}}}function LI(e){let t,n,r=e[6],i=[];for(let t=0;tZ(i[e],1,1,()=>{i[e]=null});return{c(){for(let e=0;e=0||""!==t[37]&&parseInt(t[37])>=0,P=xh,$=[];for(let e=0;eEvent Recovery \n

    Search and recover old versions of replaceable events

    ',o=m(),s=h("div"),a=h("div"),l=h("div"),p=h("label"),p.textContent="Select Event Kind:",g=m(),y=h("select"),v=h("option"),v.textContent="Choose a replaceable kind...";for(let e=0;e<$.length;e+=1)$[e].c();k=m(),E=h("div"),x=h("label"),x.textContent="Or enter custom kind number:",B=m(),S=h("input"),F=m(),U&&U.c(),A(p,"for","recovery-kind"),A(p,"class","svelte-u3u5mw"),v.__value=null,v.value=v.__value,A(y,"id","recovery-kind"),A(y,"class","svelte-u3u5mw"),void 0===t[36]&&_(()=>t[116].call(y)),A(l,"class","kind-selector svelte-u3u5mw"),A(x,"for","custom-kind"),A(x,"class","svelte-u3u5mw"),A(S,"id","custom-kind"),A(S,"type","number"),A(S,"placeholder","e.g., 10001"),A(S,"min","0"),A(S,"class","svelte-u3u5mw"),A(E,"class","custom-kind-input svelte-u3u5mw"),A(a,"class","recovery-controls svelte-u3u5mw"),A(s,"class","recovery-controls-card svelte-u3u5mw"),A(n,"class","recovery-tab svelte-u3u5mw")},m(e,r){u(e,n,r),c(n,i),c(n,o),c(n,s),c(s,a),c(a,l),c(l,p),c(l,g),c(l,y),c(y,v);for(let e=0;e<$.length;e+=1)$[e]&&$[e].m(y,null);C(y,t[36],!0),c(a,k),c(a,E),c(E,x),c(E,B),c(E,S),I(S,t[37]),c(n,F),U&&U.m(n,null),Q||(D=[w(y,"change",t[116]),w(y,"change",t[51]),w(S,"input",t[117]),w(S,"input",t[52])],Q=!0)},p(e,t){if(0&t){let n;for(P=xh,n=0;n=0||""!==e[37]&&parseInt(e[37])>=0),R?U?U.p(e,t):(U=lE(e),U.c(),U.m(n,null)):U&&(U.d(1),U=null)},i:e,o:e,d(e){e&&d(n),f($,e),U&&U.d(),Q=!1,r(D)}}}function MI(e){let t,n;return t=new bI({props:{isLoggedIn:e[1],userRole:e[4],userSigner:e[13]}}),t.$on("openLoginModal",e[71]),{c(){ne(t.$$.fragment)},m(e,r){re(t,e,r),n=!0},p(e,n){const r={};2&n[0]&&(r.isLoggedIn=e[1]),16&n[0]&&(r.userRole=e[4]),8192&n[0]&&(r.userSigner=e[13]),t.$set(r)},i(e){n||(W(t.$$.fragment,e),n=!0)},o(e){Z(t.$$.fragment,e),n=!1},d(e){ie(t,e)}}}function _I(e){let t,n,r;function i(t){e[115](t)}let o={isLoggedIn:e[1],userRole:e[4],isPolicyAdmin:RE,policyEnabled:e[8],isLoadingPolicy:e[28],policyMessage:e[29],policyMessageType:e[30],validationErrors:e[31],policyFollows:e[32]};return void 0!==e[27]&&(o.policyJson=e[27]),t=new uw({props:o}),T.push(()=>te(t,"policyJson",i)),t.$on("loadPolicy",e[61]),t.$on("validatePolicy",e[62]),t.$on("savePolicy",e[63]),t.$on("formatJson",e[64]),t.$on("addPolicyAdmin",e[65]),t.$on("removePolicyAdmin",e[66]),t.$on("refreshFollows",e[67]),t.$on("openLoginModal",e[71]),{c(){ne(t.$$.fragment)},m(e,n){re(t,e,n),r=!0},p(e,r){const i={};2&r[0]&&(i.isLoggedIn=e[1]),16&r[0]&&(i.userRole=e[4]),256&r[0]&&(i.policyEnabled=e[8]),268435456&r[0]&&(i.isLoadingPolicy=e[28]),536870912&r[0]&&(i.policyMessage=e[29]),1073741824&r[0]&&(i.policyMessageType=e[30]),1&r[1]&&(i.validationErrors=e[31]),2&r[1]&&(i.policyFollows=e[32]),!n&&134217728&r[0]&&(n=!0,i.policyJson=e[27],H(()=>n=!1)),t.$set(i)},i(e){r||(W(t.$$.fragment,e),r=!0)},o(e){Z(t.$$.fragment,e),r=!1},d(e){ie(t,e)}}}function HI(e){let t,n,r;function i(t){e[112](t)}let o={isLoggedIn:e[1],userRole:e[4],sprocketStatus:e[21],isLoadingSprocket:e[23],sprocketUploadFile:e[26],sprocketMessage:e[24],sprocketMessageType:e[25],sprocketVersions:e[22]};return void 0!==e[20]&&(o.sprocketScript=e[20]),t=new qy({props:o}),T.push(()=>te(t,"sprocketScript",i)),t.$on("restartSprocket",e[56]),t.$on("deleteSprocket",e[57]),t.$on("sprocketFileSelect",e[68]),t.$on("uploadSprocketScript",e[69]),t.$on("saveSprocket",e[55]),t.$on("loadSprocket",e[54]),t.$on("loadVersions",e[58]),t.$on("loadVersion",e[113]),t.$on("deleteVersion",e[114]),t.$on("openLoginModal",e[71]),{c(){ne(t.$$.fragment)},m(e,n){re(t,e,n),r=!0},p(e,r){const i={};2&r[0]&&(i.isLoggedIn=e[1]),16&r[0]&&(i.userRole=e[4]),2097152&r[0]&&(i.sprocketStatus=e[21]),8388608&r[0]&&(i.isLoadingSprocket=e[23]),67108864&r[0]&&(i.sprocketUploadFile=e[26]),16777216&r[0]&&(i.sprocketMessage=e[24]),33554432&r[0]&&(i.sprocketMessageType=e[25]),4194304&r[0]&&(i.sprocketVersions=e[22]),!n&&1048576&r[0]&&(n=!0,i.sprocketScript=e[20],H(()=>n=!1)),t.$set(i)},i(e){r||(W(t.$$.fragment,e),r=!0)},o(e){Z(t.$$.fragment,e),r=!1},d(e){ie(t,e)}}}function jI(e){let t,n,r,i;const o=[vE,wE,yE],s=[];function a(e,t){return"managed"!==e[9]?0:e[1]&&"owner"===e[4]?1:2}return n=a(e),r=s[n]=o[n](e),{c(){t=h("div"),r.c(),A(t,"class","managed-acl-view svelte-u3u5mw")},m(e,r){u(e,t,r),s[n].m(t,null),i=!0},p(e,i){let l=n;n=a(e),n===l?s[n].p(e,i):(Y(),Z(s[l],1,1,()=>{s[l]=null}),z(),r=s[n],r?r.p(e,i):(r=s[n]=o[n](e),r.c()),W(r,1),r.m(t,null))},i(e){i||(W(r),i=!0)},o(e){Z(r),i=!1},d(e){e&&d(t),s[n].d()}}}function GI(e){let t,n,r;function i(t){e[111](t)}let o={userPubkey:e[2],userRole:e[4],policyEnabled:e[8],publishError:e[35]};return void 0!==e[34]&&(o.composeEventJson=e[34]),t=new Py({props:o}),T.push(()=>te(t,"composeEventJson",i)),t.$on("reformatJson",e[91]),t.$on("signEvent",e[92]),t.$on("publishEvent",e[93]),t.$on("clearError",e[94]),{c(){ne(t.$$.fragment)},m(e,n){re(t,e,n),r=!0},p(e,r){const i={};4&r[0]&&(i.userPubkey=e[2]),16&r[0]&&(i.userRole=e[4]),256&r[0]&&(i.policyEnabled=e[8]),16&r[1]&&(i.publishError=e[35]),!n&&8&r[1]&&(n=!0,i.composeEventJson=e[34],H(()=>n=!1)),t.$set(i)},i(e){r||(W(t.$$.fragment,e),r=!0)},o(e){Z(t.$$.fragment,e),r=!1},d(e){ie(t,e)}}}function qI(e){let t,n;return t=new tI({props:{isLoggedIn:e[1],userPubkey:e[2],userSigner:e[13],userPrivkey:e[14],currentEffectiveRole:e[10]}}),t.$on("openLoginModal",e[71]),{c(){ne(t.$$.fragment)},m(e,r){re(t,e,r),n=!0},p(e,n){const r={};2&n[0]&&(r.isLoggedIn=e[1]),4&n[0]&&(r.userPubkey=e[2]),8192&n[0]&&(r.userSigner=e[13]),16384&n[0]&&(r.userPrivkey=e[14]),1024&n[0]&&(r.currentEffectiveRole=e[10]),t.$set(r)},i(e){n||(W(t.$$.fragment,e),n=!0)},o(e){Z(t.$$.fragment,e),n=!1},d(e){ie(t,e)}}}function KI(e){let t,n;return t=new iv({props:{isLoggedIn:e[1],userPubkey:e[2],userSigner:e[13],currentEffectiveRole:e[10]}}),t.$on("openLoginModal",e[71]),{c(){ne(t.$$.fragment)},m(e,r){re(t,e,r),n=!0},p(e,n){const r={};2&n[0]&&(r.isLoggedIn=e[1]),4&n[0]&&(r.userPubkey=e[2]),8192&n[0]&&(r.userSigner=e[13]),1024&n[0]&&(r.currentEffectiveRole=e[10]),t.$set(r)},i(e){n||(W(t.$$.fragment,e),n=!0)},o(e){Z(t.$$.fragment,e),n=!1},d(e){ie(t,e)}}}function JI(e){let t,n;return t=new hy({props:{isLoggedIn:e[1],userRole:e[4],userPubkey:e[2],filteredEvents:e[42],expandedEvents:e[19],isLoadingEvents:e[7],showOnlyMyEvents:DE,showFilterBuilder:e[16]}}),t.$on("scroll",e[90]),t.$on("toggleEventExpansion",e[107]),t.$on("deleteEvent",e[108]),t.$on("copyEventToClipboard",e[109]),t.$on("toggleChange",e[46]),t.$on("loadAllEvents",e[110]),t.$on("toggleFilterBuilder",e[77]),t.$on("filterApply",e[78]),t.$on("filterClear",e[79]),{c(){ne(t.$$.fragment)},m(e,r){re(t,e,r),n=!0},p(e,n){const r={};2&n[0]&&(r.isLoggedIn=e[1]),16&n[0]&&(r.userRole=e[4]),4&n[0]&&(r.userPubkey=e[2]),2048&n[1]&&(r.filteredEvents=e[42]),524288&n[0]&&(r.expandedEvents=e[19]),128&n[0]&&(r.isLoadingEvents=e[7]),65536&n[0]&&(r.showFilterBuilder=e[16]),t.$set(r)},i(e){n||(W(t.$$.fragment,e),n=!0)},o(e){Z(t.$$.fragment,e),n=!1},d(e){ie(t,e)}}}function VI(e){let t,n;return t=new hm({props:{isLoggedIn:e[1],currentEffectiveRole:e[10],selectedFile:e[17],aclMode:e[9],importMessage:e[18]}}),t.$on("fileSelect",e[87]),t.$on("importEvents",e[88]),t.$on("openLoginModal",e[71]),{c(){ne(t.$$.fragment)},m(e,r){re(t,e,r),n=!0},p(e,n){const r={};2&n[0]&&(r.isLoggedIn=e[1]),1024&n[0]&&(r.currentEffectiveRole=e[10]),131072&n[0]&&(r.selectedFile=e[17]),512&n[0]&&(r.aclMode=e[9]),262144&n[0]&&(r.importMessage=e[18]),t.$set(r)},i(e){n||(W(t.$$.fragment,e),n=!0)},o(e){Z(t.$$.fragment,e),n=!1},d(e){ie(t,e)}}}function YI(e){let t,n;return t=new sm({props:{isLoggedIn:e[1],currentEffectiveRole:e[10],aclMode:e[9]}}),t.$on("exportMyEvents",e[86]),t.$on("exportAllEvents",e[85]),t.$on("openLoginModal",e[71]),{c(){ne(t.$$.fragment)},m(e,r){re(t,e,r),n=!0},p(e,n){const r={};2&n[0]&&(r.isLoggedIn=e[1]),1024&n[0]&&(r.currentEffectiveRole=e[10]),512&n[0]&&(r.aclMode=e[9]),t.$set(r)},i(e){n||(W(t.$$.fragment,e),n=!0)},o(e){Z(t.$$.fragment,e),n=!1},d(e){ie(t,e)}}}function zI(t){let n;return{c(){n=h("p"),n.textContent="Log in to access your user dashboard",A(n,"class","svelte-u3u5mw")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function WI(e){let t,n,r,i=(e[3]?.name||e[2].slice(0,8)+"...")+"";return{c(){t=h("p"),n=g("Welcome "),r=g(i),A(t,"class","svelte-u3u5mw")},m(e,i){u(e,t,i),c(t,n),c(t,r)},p(e,t){12&t[0]&&i!==(i=(e[3]?.name||e[2].slice(0,8)+"...")+"")&&k(r,i)},d(e){e&&d(t)}}}function ZI(e){let t,n,i,o,s,a,l,f,p,y,v,b,I,E,C,x,B,S,F,Q,D,R=e[180].label+"",P=e[43].get(e[180].id)?.isLoading,$=!e[43].get(e[180].id)?.hasMore&&e[43].get(e[180].id)?.events?.length>0;function U(){return e[121](e[180])}function T(e,t){return 64&t[0]&&(E=null),64&t[0]&&(C=null),null==E&&(E=!!(e[43].get(e[180].id)?.events?.length>0)),E?eE:(null==C&&(C=!e[43].get(e[180].id)?.isLoading),C?XI:void 0)}v=new CI({props:{filter:e[43].get(e[180].id)?.filter||{}}}),v.$on("sweep",function(){return e[122](e[180])});let N=T(e,[-1,-1,-1,-1,-1,-1]),L=N&&N(e),O=P&&iE(),M=$&&oE();function _(...t){return e[127](e[180],...t)}return{c(){t=h("div"),n=h("div"),i=h("h2"),o=g("🔍 "),s=g(R),a=m(),l=h("button"),f=g("🔄 Refresh"),y=m(),ne(v.$$.fragment),b=m(),I=h("div"),L&&L.c(),x=m(),O&&O.c(),B=m(),M&&M.c(),S=m(),A(i,"class","svelte-u3u5mw"),A(l,"class","refresh-btn svelte-u3u5mw"),l.disabled=p=e[43].get(e[180].id)?.isLoading,A(n,"class","search-results-header svelte-u3u5mw"),A(I,"class","search-results-content svelte-u3u5mw"),A(t,"class","search-results-view svelte-u3u5mw")},m(e,r){u(e,t,r),c(t,n),c(n,i),c(i,o),c(i,s),c(n,a),c(n,l),c(l,f),c(t,y),re(v,t,null),c(t,b),c(t,I),L&&L.m(I,null),c(I,x),O&&O.m(I,null),c(I,B),M&&M.m(I,null),c(t,S),F=!0,Q||(D=[w(l,"click",U),w(I,"scroll",_)],Q=!0)},p(t,n){e=t,(!F||64&n[0])&&R!==(R=e[180].label+"")&&k(s,R),(!F||64&n[0]&&p!==(p=e[43].get(e[180].id)?.isLoading))&&(l.disabled=p);const r={};64&n[0]&&(r.filter=e[43].get(e[180].id)?.filter||{}),v.$set(r),N===(N=T(e,n))&&L?L.p(e,n):(L&&L.d(1),L=N&&N(e),L&&(L.c(),L.m(I,x))),64&n[0]&&(P=e[43].get(e[180].id)?.isLoading),P?O||(O=iE(),O.c(),O.m(I,B)):O&&(O.d(1),O=null),64&n[0]&&($=!e[43].get(e[180].id)?.hasMore&&e[43].get(e[180].id)?.events?.length>0),$?M||(M=oE(),M.c(),M.m(I,null)):M&&(M.d(1),M=null)},i(e){F||(W(v.$$.fragment,e),F=!0)},o(e){Z(v.$$.fragment,e),F=!1},d(e){e&&d(t),ie(v),L&&L.d(),O&&O.d(),M&&M.d(),Q=!1,r(D)}}}function XI(t){let n;return{c(){n=h("div"),n.innerHTML='

    No search results found.

    ',A(n,"class","no-search-results svelte-u3u5mw")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function eE(e){let t,n=e[43].get(e[180].id).events,r=[];for(let t=0;t👤',o=m(),s=h("div"),a=h("div"),l=g(L),f=m(),p=h("div"),y=h("span"),v=g(O),b=m(),I=h("span"),E=g(M),C=m(),x=h("div"),S=h("div"),F=g(_),Q=m(),D=h("div"),R=g(H),P=m(),G&&G.c(),$=m(),J&&J.c(),U=m(),A(i,"class","search-result-avatar svelte-u3u5mw"),A(a,"class","search-result-author svelte-u3u5mw"),A(y,"class","kind-number svelte-u3u5mw"),A(I,"class","kind-name svelte-u3u5mw"),A(p,"class","search-result-kind svelte-u3u5mw"),A(s,"class","search-result-info svelte-u3u5mw"),A(S,"class","event-timestamp svelte-u3u5mw"),A(D,"class","event-content-single-line svelte-u3u5mw"),A(x,"class","search-result-content svelte-u3u5mw"),A(n,"class","search-result-row svelte-u3u5mw"),A(n,"role","button"),A(n,"tabindex","0"),A(t,"class","search-result-item svelte-u3u5mw"),B(t,"expanded",e[19].has(e[173].id))},m(e,r){u(e,t,r),c(t,n),c(n,i),c(n,o),c(n,s),c(s,a),c(a,l),c(s,f),c(s,p),c(p,y),c(y,v),c(p,b),c(p,I),c(I,E),c(n,C),c(n,x),c(x,S),c(S,F),c(x,Q),c(x,D),c(D,R),c(n,P),G&&G.m(n,null),c(t,$),J&&J.m(t,null),c(t,U),T||(N=[w(n,"click",q),w(n,"keydown",K)],T=!0)},p(r,i){e=r,64&i[0]&&L!==(L=BI(e[173].pubkey)+"")&&k(l,L),64&i[0]&&O!==(O=e[173].kind+"")&&k(v,O),64&i[0]&&M!==(M=xI(e[173].kind)+"")&&k(E,M),64&i[0]&&_!==(_=FI(e[173].created_at)+"")&&k(F,_),64&i[0]&&H!==(H=SI(e[173].content)+"")&&k(R,H),5!==e[173].kind&&("admin"===e[4]||"owner"===e[4]||"write"===e[4]&&e[173].pubkey&&e[173].pubkey===e[2])?G?G.p(e,i):(G=tE(e),G.c(),G.m(n,null)):G&&(G.d(1),G=null),524352&i[0]&&(j=e[19].has(e[173].id)),j?J?J.p(e,i):(J=nE(e),J.c(),J.m(t,U)):J&&(J.d(1),J=null),524352&i[0]|4096&i[1]&&B(t,"expanded",e[19].has(e[173].id))},d(e){e&&d(t),G&&G.d(),J&&J.d(),T=!1,r(N)}}}function iE(e){let t;return{c(){t=h("div"),t.innerHTML='
    \n

    Searching...

    ',A(t,"class","loading-search-results svelte-u3u5mw")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function oE(e){let t;return{c(){t=h("div"),t.innerHTML='

    No more search results to load.

    ',A(t,"class","end-of-search-results svelte-u3u5mw")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function sE(e){let t,n,r=e[180].id===e[5]&&ZI(e);return{c(){r&&r.c(),t=y()},m(e,i){r&&r.m(e,i),u(e,t,i),n=!0},p(e,n){e[180].id===e[5]?r?(r.p(e,n),96&n[0]&&W(r,1)):(r=ZI(e),r.c(),W(r,1),r.m(t.parentNode,t)):r&&(Y(),Z(r,1,1,()=>{r=null}),z())},i(e){n||(W(r),n=!0)},o(e){Z(r),n=!1},d(e){r&&r.d(e),e&&d(t)}}}function aE(t){let n,r,i=t[177].label+"";return{c(){n=h("option"),r=g(i),n.__value=t[177].value,n.value=n.__value},m(e,t){u(e,n,t),c(n,r)},p:e,d(e){e&&d(n)}}}function lE(e){let t;function n(e,t){return e[39]?dE:0===e[38].length?uE:cE}let r=n(e),i=r(e);return{c(){t=h("div"),i.c(),A(t,"class","recovery-results svelte-u3u5mw")},m(e,n){u(e,t,n),i.m(t,null)},p(e,o){r===(r=n(e))&&i?i.p(e,o):(i.d(1),i=r(e),i&&(i.c(),i.m(t,null)))},d(e){e&&d(t),i.d()}}}function cE(e){let t,n,r,i=e[38],o=[];for(let t=0;tORLY_ACL_MODE=managed in your\n environment variables and restart the relay.',A(r,"class","svelte-u3u5mw"),A(o,"class","svelte-u3u5mw"),A(a,"class","svelte-u3u5mw"),A(w,"class","svelte-u3u5mw"),A(n,"class","acl-mode-warning svelte-u3u5mw")},m(e,t){u(e,n,t),c(n,r),c(n,i),c(n,o),c(n,s),c(n,a),c(a,l),c(a,f),c(f,p),c(n,y),c(n,w)},p(e,t){512&t[0]&&v!==(v=(e[9]||"unknown")+"")&&k(p,v)},i:e,o:e,d(e){e&&d(n)}}}function AE(e){let t,n,i,o,s,a,l,f,p,g;function y(e,t){return e[3]?kE:e[1]&&e[2]?bE:void 0}let b=y(e),k=b&&b(e);return{c(){t=h("div"),n=h("div"),i=h("div"),o=h("h2"),o.textContent="Settings",s=m(),a=h("button"),a.textContent="✕",l=m(),f=h("div"),k&&k.c(),A(o,"class","svelte-u3u5mw"),A(a,"class","close-btn svelte-u3u5mw"),A(i,"class","drawer-header svelte-u3u5mw"),A(f,"class","drawer-content"),A(n,"class","settings-drawer svelte-u3u5mw"),B(n,"dark-theme",e[0]),A(t,"class","drawer-overlay svelte-u3u5mw"),A(t,"role","button"),A(t,"tabindex","0")},m(r,d){u(r,t,d),c(t,n),c(n,i),c(i,o),c(i,s),c(i,a),c(n,l),c(n,f),k&&k.m(f,null),p||(g=[w(a,"click",e[76]),w(n,"click",v(e[102])),w(n,"keydown",v(e[103])),w(t,"click",e[76]),w(t,"keydown",e[129])],p=!0)},p(e,t){b===(b=y(e))&&k?k.p(e,t):(k&&k.d(1),k=b&&b(e),k&&(k.c(),k.m(f,null))),1&t[0]&&B(n,"dark-theme",e[0])},d(e){e&&d(t),k&&k.d(),p=!1,r(g)}}}function bE(e){let t,n,i,o,s,a,l,f,p,y,v,b,I,E,C,x,B,S=e[2].slice(0,16)+"",F=e[2].slice(-8)+"";return{c(){t=h("div"),n=h("button"),n.textContent="Log out",i=m(),o=h("h3"),o.textContent="Profile Loading",s=m(),a=h("p"),a.textContent="Your profile metadata is being loaded...",l=m(),f=h("button"),f.textContent="Retry Loading Profile",p=m(),y=h("div"),v=h("strong"),v.textContent="Public Key:",b=m(),I=g(S),E=g("..."),C=g(F),A(n,"class","logout-btn floating svelte-u3u5mw"),A(o,"class","svelte-u3u5mw"),A(a,"class","svelte-u3u5mw"),A(f,"class","retry-profile-btn svelte-u3u5mw"),A(y,"class","user-pubkey-display svelte-u3u5mw"),A(t,"class","profile-loading-section svelte-u3u5mw")},m(r,d){u(r,t,d),c(t,n),c(t,i),c(t,o),c(t,s),c(t,a),c(t,l),c(t,f),c(t,p),c(t,y),c(y,v),c(y,b),c(y,I),c(y,E),c(y,C),x||(B=[w(n,"click",e[73]),w(f,"click",e[84])],x=!0)},p(e,t){4&t[0]&&S!==(S=e[2].slice(0,16)+"")&&k(I,S),4&t[0]&&F!==(F=e[2].slice(-8)+"")&&k(C,F)},d(e){e&&d(t),x=!1,r(B)}}}function kE(e){let t,n,r,i,o,s,a,l,f,p,v,b,I,E,C,x=(e[3].name||"Unknown User")+"",B=e[3].banner&&IE(e);function S(e,t){return e[3].picture?CE:EE}let F=S(e),Q=F(e),D=e[3].nip05&&xE(e),R=e[3].about&&BE(e),P=e[4]&&"read"!==e[4]&&SE(e);return{c(){t=h("div"),n=h("div"),B&&B.c(),r=m(),i=h("button"),i.textContent="Log out",o=m(),Q.c(),s=m(),a=h("div"),l=h("h3"),f=g(x),p=m(),D&&D.c(),v=m(),R&&R.c(),b=m(),P&&P.c(),I=y(),A(i,"class","logout-btn floating svelte-u3u5mw"),A(l,"class","profile-username svelte-u3u5mw"),A(a,"class","name-row svelte-u3u5mw"),A(n,"class","profile-hero svelte-u3u5mw"),A(t,"class","profile-section svelte-u3u5mw")},m(d,h){u(d,t,h),c(t,n),B&&B.m(n,null),c(n,r),c(n,i),c(n,o),Q.m(n,null),c(n,s),c(n,a),c(a,l),c(l,f),c(a,p),D&&D.m(a,null),c(t,v),R&&R.m(t,null),u(d,b,h),P&&P.m(d,h),u(d,I,h),E||(C=w(i,"click",e[73]),E=!0)},p(e,i){e[3].banner?B?B.p(e,i):(B=IE(e),B.c(),B.m(n,r)):B&&(B.d(1),B=null),F===(F=S(e))&&Q?Q.p(e,i):(Q.d(1),Q=F(e),Q&&(Q.c(),Q.m(n,s))),8&i[0]&&x!==(x=(e[3].name||"Unknown User")+"")&&k(f,x),e[3].nip05?D?D.p(e,i):(D=xE(e),D.c(),D.m(a,null)):D&&(D.d(1),D=null),e[3].about?R?R.p(e,i):(R=BE(e),R.c(),R.m(t,null)):R&&(R.d(1),R=null),e[4]&&"read"!==e[4]?P?P.p(e,i):(P=SE(e),P.c(),P.m(I.parentNode,I)):P&&(P.d(1),P=null)},d(e){e&&d(t),B&&B.d(),Q.d(),D&&D.d(),R&&R.d(),e&&d(b),P&&P.d(e),e&&d(I),E=!1,C()}}}function IE(e){let t,n;return{c(){t=h("img"),a(t.src,n=e[3].banner)||A(t,"src",n),A(t,"alt","Profile banner"),A(t,"class","profile-banner svelte-u3u5mw")},m(e,n){u(e,t,n)},p(e,r){8&r[0]&&!a(t.src,n=e[3].banner)&&A(t,"src",n)},d(e){e&&d(t)}}}function EE(t){let n;return{c(){n=h("div"),n.textContent="👤",A(n,"class","profile-avatar-placeholder overlap svelte-u3u5mw")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function CE(e){let t,n;return{c(){t=h("img"),a(t.src,n=e[3].picture)||A(t,"src",n),A(t,"alt","User avatar"),A(t,"class","profile-avatar overlap svelte-u3u5mw")},m(e,n){u(e,t,n)},p(e,r){8&r[0]&&!a(t.src,n=e[3].picture)&&A(t,"src",n)},d(e){e&&d(t)}}}function xE(e){let t,n,r=e[3].nip05+"";return{c(){t=h("span"),n=g(r),A(t,"class","profile-nip05-inline svelte-u3u5mw")},m(e,r){u(e,t,r),c(t,n)},p(e,t){8&t[0]&&r!==(r=e[3].nip05+"")&&k(n,r)},d(e){e&&d(t)}}}function BE(e){let t,n;return{c(){t=h("div"),n=h("p"),A(n,"class","profile-about svelte-u3u5mw"),A(t,"class","about-card svelte-u3u5mw")},m(r,i){u(r,t,i),c(t,n),n.innerHTML=e[41]},p(e,t){1024&t[1]&&(n.innerHTML=e[41])},d(e){e&&d(t)}}}function SE(e){let t,n,r,i,o,s,a=e[96](),l=[];for(let t=0;tte(y,"showModal",C)),y.$on("login",e[72]),y.$on("close",e[74]),{c(){ne(t.$$.fragment),n=m(),r=h("div"),ne(i.$$.fragment),o=m(),s=h("main"),f.c(),p=m(),E&&E.c(),g=m(),ne(y.$$.fragment),A(s,"class","main-content svelte-u3u5mw"),A(r,"class","app-container svelte-u3u5mw"),B(r,"dark-theme",e[0])},m(e,a){re(t,e,a),u(e,n,a),u(e,r,a),re(i,r,null),c(r,o),c(r,s),k[l].m(s,null),u(e,p,a),E&&E.m(e,a),u(e,g,a),re(y,e,a),v=!0},p(e,n){const o={};1&n[0]&&(o.isDarkTheme=e[0]),2&n[0]&&(o.isLoggedIn=e[1]),16&n[0]&&(o.userRole=e[4]),1024&n[0]&&(o.currentEffectiveRole=e[10]),8&n[0]&&(o.userProfile=e[3]),4&n[0]&&(o.userPubkey=e[2]),t.$set(o);const a={};1&n[0]&&(a.isDarkTheme=e[0]),2048&n[0]&&(a.tabs=e[11]),32&n[0]&&(a.selectedTab=e[5]),4&n[1]&&(a.version=e[33]),i.$set(a);let c=l;l=I(e,n),l===c?k[l].p(e,n):(Y(),Z(k[c],1,1,()=>{k[c]=null}),z(),f=k[l],f?f.p(e,n):(f=k[l]=b[l](e),f.c()),W(f,1),f.m(s,null)),(!v||1&n[0])&&B(r,"dark-theme",e[0]),e[15]?E?E.p(e,n):(E=AE(e),E.c(),E.m(g.parentNode,g)):E&&(E.d(1),E=null);const u={};1&n[0]&&(u.isDarkTheme=e[0]),!w&&4096&n[0]&&(w=!0,u.showModal=e[12],H(()=>w=!1)),y.$set(u)},i(e){v||(W(t.$$.fragment,e),W(i.$$.fragment,e),W(f),W(y.$$.fragment,e),v=!0)},o(e){Z(t.$$.fragment,e),Z(i.$$.fragment,e),Z(f),Z(y.$$.fragment,e),v=!1},d(e){ie(t,e),e&&d(n),e&&d(r),ie(i),k[l].d(),e&&d(p),E&&E.d(e),e&&d(g),ie(y,e)}}}let DE=!1,RE=!1;function PE(e,t,n){let r,i,o,s,a;"undefined"!=typeof window&&(window.debugIndexedDB=Kh);let l=!1,c=!1,u=!1,d="",f="",h=null,p="",g=null,m=null,y=!1,w=localStorage.getItem("selectedTab")||"export",v=!1,A={},k=[],I=[],E=null,C="",B=new Set,S=!1,F=!0,Q=null,D="",R=new Map,P=[],U=0,T=[],N=!0,L=null,O="",M=null,_=[],H=!1,j="",G="info",q=!1,K=null,J="",V=!1,Y=!1,z="",W="info",Z=[],X=[],ee="",te="",ne="",re="",ie=null,oe="",se=[],ae=!1,le=!0,ce=null;function ue(e){B.has(e)?B.delete(e):B.add(e),n(19,B)}async function de(e,t){const n=JSON.stringify(e),r=await async function(e){try{return await navigator.clipboard.writeText(e),!0}catch(t){console.error("Failed to copy to clipboard:",t);try{const t=document.createElement("textarea");return t.value=e,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t),!0}catch(e){return console.error("Fallback copy also failed:",e),!1}}}(n);!function(e,t=!0){if(!e)return;const n=e.textContent,r=e.style.backgroundColor;t?(e.textContent="",e.style.backgroundColor="#4CAF50"):(e.textContent="L",e.style.backgroundColor="#f44336"),setTimeout(()=>{e.textContent=n,e.style.backgroundColor=r},2e3)}(t.target.closest(".copy-json-btn"),r),r||alert("Failed to copy to clipboard. Please copy manually.")}async function fe(e){if(!u)return void alert("Please log in first");const t=I.find(t=>t.id===e);if(!t)return void alert("Event not found");if("admin"===p||"owner"===p||"write"===p&&t.pubkey&&t.pubkey===d){if(confirm("Are you sure you want to delete this event?"))try{if(!g)throw new Error("Signer not available for signing");const r={kind:5,created_at:Math.floor(Date.now()/1e3),tags:[["e",e]],content:""};console.log("Created delete event template:",r),console.log("User pubkey:",d),console.log("Target event:",t),console.log("Target event pubkey:",t.pubkey);const i=await g.signEvent(r);console.log("Signed delete event:",i),console.log("Signed delete event pubkey:",i.pubkey),console.log("Delete event tags:",i.tags);const o=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`;try{const e=await DI(o,i,g,d);e.success?console.log("Delete event published successfully to ORLY relay"):console.error("Failed to publish delete event:",e.reason)}catch(e){console.error("Error publishing delete event:",e)}const s=t.pubkey&&t.pubkey===d;if(s){const t=await Qh.publish(i);if(console.log("Delete event published:",t),!(t.success&&t.okCount>0))throw new Error("No relays accepted the delete event");{await new Promise(e=>setTimeout(e,2e3));try{const n=await Hh(e,{timeout:5e3});n?(console.warn("Event still exists after deletion attempt:",n),alert(`Warning: Delete event was accepted by ${t.okCount} relay(s), but the event still exists on the relay. This may indicate the relay does not properly handle delete events.`)):console.log("Event successfully deleted and verified")}catch(e){console.log("Could not fetch event after deletion (likely deleted):",e.message)}try{const t=await jh(e,{timeout:5e3});if(t.length>0){console.log(`Delete event verification: Found ${t.length} delete event(s) targeting ${e}`);const n=t.find(e=>e.pubkey&&e.pubkey===d);n?console.log("Our delete event found in database:",n.id):console.warn("Our delete event not found in database, but other delete events exist")}else console.warn("No delete events found in database for target event:",e)}catch(e){console.log("Could not verify delete event in database:",e.message)}n(97,I=I.filter(t=>t.id!==e)),T=T.filter(t=>t.id!==e),P=P.filter(t=>t.id!==e);for(const[t,n]of R)n.events&&(n.events=n.events.filter(t=>t.id!==e),R.set(t,n));me(),console.log("Reloading events to show delete event...");const r=DE&&u&&d?[d]:null;await Te(!0,r),alert(`Event deleted successfully (accepted by ${t.okCount} relay(s))`)}}else{const t=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`,r=new Fh;await r.connectToRelay(t);const o=await r.publish(i);if(console.log("Delete event published to local relay only:",o),!(o.success&&o.okCount>0))throw new Error("Local relay did not accept the delete event");{await new Promise(e=>setTimeout(e,2e3));try{const t=await Hh(e,{timeout:5e3});t?(console.warn("Event still exists after deletion attempt:",t),alert(`Warning: Delete event was accepted by ${o.okCount} relay(s), but the event still exists on the relay. This may indicate the relay does not properly handle delete events.`)):console.log("Event successfully deleted and verified")}catch(e){console.log("Could not fetch event after deletion (likely deleted):",e.message)}try{const t=await jh(e,{timeout:5e3});if(t.length>0){console.log(`Delete event verification: Found ${t.length} delete event(s) targeting ${e}`);const n=t.find(e=>e.pubkey&&e.pubkey===d);n?console.log("Our delete event found in database:",n.id):console.warn("Our delete event not found in database, but other delete events exist")}else console.warn("No delete events found in database for target event:",e)}catch(e){console.log("Could not verify delete event in database:",e.message)}n(97,I=I.filter(t=>t.id!==e)),T=T.filter(t=>t.id!==e),P=P.filter(t=>t.id!==e);for(const[t,n]of R)n.events&&(n.events=n.events.filter(t=>t.id!==e),R.set(t,n));me(),console.log("Reloading events to show delete event...");const t=DE&&u&&d?[d]:null;await Te(!0,t),alert("Event deleted successfully (local relay only - admin/owner deleting other user's event)")}}}catch(e){console.error("Failed to delete event:",e),alert("Failed to delete event: "+e.message)}}else alert("You do not have permission to delete this event")}async function he(){const e=oe?parseInt(oe):ie;if(null==e||isNaN(e))console.log("No valid kind to load, kindToUse:",e);else if(u){console.log("Loading recovery events for kind:",e,"user:",d),n(39,ae=!0);try{const t=[{kinds:[e],authors:[d],limit:100}];ce&&(t[0].until=ce),console.log("Recovery filters:",t);const r=await qh(t,{timeout:3e4,cacheFirst:!0});console.log("Recovery events received:",r.length),console.log("Recovery events kinds:",r.map(e=>e.kind)),n(38,se=ce?[...se,...r]:r),r.length>0?(ce=Math.min(...r.map(e=>e.created_at)),n(40,le=100===r.length)):n(40,le=!1)}catch(e){console.error("Failed to load recovery events:",e)}finally{n(39,ae=!1)}}else console.log("Not logged in, cannot load recovery events")}async function pe(e){if(confirm("Are you sure you want to repost this event?"))try{const t=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`;console.log("Reposting event to local relay:",t,e);const r={...e};if(r.created_at=Math.floor(Date.now()/1e3),r.id="",r.sig="",e.kind>=3e4&&e.kind<=39999){const t=e.tags.find(e=>"d"===e[0]);t&&(r.tags=r.tags.filter(e=>"d"!==e[0]),r.tags.push(t))}if(g){const e=await g.signEvent(r);console.log("Signed event for repost:",e);const i=await Qh.publish(e,[t]);console.log("Repost publish result:",i),i.success&&i.okCount>0?(alert("Event reposted successfully!"),n(40,le=!1),await he()):alert("Failed to repost event. Check console for details.")}else alert("No signer available. Please log in.")}catch(e){console.error("Error reposting event:",e),alert("Error reposting event: "+e.message)}}async function ge(e){if(confirm("Are you sure you want to repost this event to all your write relays?"))try{const t=await async function(){if(!d)return[];try{const e=await Nh([{kinds:[10002],authors:[d],limit:1}]);if(0===e.length)return console.log("No relay list event found for user"),[];const t=e[0];console.log("Found relay list event:",t);const n=[];for(const e of t.tags)if("r"===e[0]&&e.length>=2){const t=e[1],r=e.length>=3?e[2]:null;r&&"write"!==r||n.push(t)}return console.log("Found write relays:",n),n}catch(e){return console.error("Error fetching user write relays:",e),[]}}(),r=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`,i=[r,...t.filter(e=>e!==r)];1===i.length&&alert("No write relays found in your relay list. Only posting to local relay."),console.log("Reposting event to all relays:",i,e);const o={...e};if(o.created_at=Math.floor(Date.now()/1e3),o.id="",o.sig="",e.kind>=3e4&&e.kind<=39999){const t=e.tags.find(e=>"d"===e[0]);t&&(o.tags=o.tags.filter(e=>"d"!==e[0]),o.tags.push(t))}if(g){const e=await g.signEvent(o);console.log("Signed event for repost to all:",e);const t=await Qh.publish(e,i);console.log("Repost to all publish result:",t),t.success&&t.okCount>0?(alert(`Event reposted successfully to ${i.length} relays!`),n(40,le=!1),await he()):alert("Failed to repost event. Check console for details.")}else alert("No signer available. Please log in.")}catch(e){console.error("Error reposting event to all:",e),alert("Error reposting event to all: "+e.message)}}if("undefined"!=typeof window&&window.matchMedia){const e=window.matchMedia("(prefers-color-scheme: dark)");l=e.matches,e.addEventListener("change",e=>{n(0,l=e.matches)})}if("undefined"!=typeof localStorage){const e=localStorage.getItem("nostr_auth_method"),t=localStorage.getItem("nostr_pubkey");e&&t&&(u=!0,d=t,f=e,"extension"===e&&window.nostr&&(g=window.nostr),Pe(),$e()),function(){if("undefined"==typeof localStorage)return;try{const t=localStorage.getItem("app_state");if(t){const r=JSON.parse(t);r.selectedTab&&Ce.some(e=>e.id===r.selectedTab)&&n(5,w=r.selectedTab),r.expandedEvents&&n(19,B=new Set(r.expandedEvents)),r.globalEventsCache&&(P=r.globalEventsCache),r.globalCacheTimestamp&&(U=r.globalCacheTimestamp),void 0!==r.hasMoreEvents&&(F=r.hasMoreEvents),r.oldestEventTimestamp&&(Q=r.oldestEventTimestamp),void 0!==r.hasMoreMyEvents&&(N=r.hasMoreMyEvents),r.oldestMyEventTimestamp&&(L=r.oldestMyEventTimestamp),P.length>0&&((e=U)&&Date.now()-et.created_at-e.created_at),U=Date.now(),me()}async function we(){if(u&&"owner"===p&&q)try{n(23,H=!0);const e=await fetch("/api/sprocket/status",{method:"GET",headers:{Authorization:`Nostr ${await Me("GET","/api/sprocket/status")}`,"Content-Type":"application/json"}});e.ok?n(21,M=await e.json()):ke("Failed to load sprocket status","error")}catch(e){ke(`Error loading sprocket status: ${e.message}`,"error")}finally{n(23,H=!1)}}async function ve(){if(u&&"owner"===p)try{n(23,H=!0);const e=await fetch("/api/sprocket/versions",{method:"GET",headers:{Authorization:`Nostr ${await Me("GET","/api/sprocket/versions")}`,"Content-Type":"application/json"}});e.ok?n(22,_=await e.json()):ke("Failed to load versions","error")}catch(e){ke(`Error loading versions: ${e.message}`,"error")}finally{n(23,H=!1)}}async function Ae(e){u&&"owner"===p&&(n(20,O=e.content),ke(`Loaded version: ${e.name}`,"success"))}async function be(e){if(u&&"owner"===p&&confirm(`Are you sure you want to delete version ${e}?`))try{n(23,H=!0);const t=await fetch("/api/sprocket/delete-version",{method:"POST",headers:{Authorization:`Nostr ${await Me("POST","/api/sprocket/delete-version")}`,"Content-Type":"application/json"},body:JSON.stringify({filename:e})});if(t.ok)ke(`Version ${e} deleted successfully`,"success"),await ve();else{ke(`Failed to delete version: ${await t.text()}`,"error")}}catch(e){ke(`Error deleting version: ${e.message}`,"error")}finally{n(23,H=!1)}}function ke(e,t="info"){n(24,j=e),n(25,G=t),setTimeout(()=>{n(24,j="")},5e3)}function Ie(e,t="info"){n(29,z=e),n(30,W=t),"error"!==t&&setTimeout(()=>{n(29,z="")},5e3)}async function Ee(){if(n(31,Z=[]),!J.trim())return n(31,Z=["Policy JSON is empty"]),Ie("Validation failed","error"),!1;try{const e=JSON.parse(J);if("object"!=typeof e||null===e)return n(31,Z=["Policy must be a JSON object"]),Ie("Validation failed","error"),!1;if(e.policy_admins)if(Array.isArray(e.policy_admins))for(const t of e.policy_admins)"string"==typeof t&&/^[0-9a-fA-F]{64}$/.test(t)||Z.push(`Invalid policy_admin pubkey: ${t}`);else Z.push("policy_admins must be an array");if(e.rules)if("object"!=typeof e.rules)Z.push("rules must be an object");else for(const[t,n]of Object.entries(e.rules))if(/^\d+$/.test(t)||Z.push(`Invalid kind number: ${t}`),n.tag_validation&&"object"==typeof n.tag_validation)for(const[e,t]of Object.entries(n.tag_validation))try{new RegExp(t)}catch(n){Z.push(`Invalid regex for tag '${e}': ${t}`)}return e.default_policy&&!["allow","deny"].includes(e.default_policy)&&Z.push("default_policy must be 'allow' or 'deny'"),Z.length>0?(Ie("Validation failed - see errors below","error"),!1):(Ie("Validation passed","success"),!0)}catch(e){return n(31,Z=[`JSON parse error: ${e.message}`]),Ie("Invalid JSON syntax","error"),!1}}const Ce=[{id:"export",icon:"📤",label:"Export"},{id:"import",icon:"💾",label:"Import",requiresAdmin:!0},{id:"events",icon:"📡",label:"Events"},{id:"blossom",icon:"🌸",label:"Blossom"},{id:"bunker",icon:"🔐",label:"Bunker",requiresWrite:!0},{id:"compose",icon:"✏️",label:"Compose",requiresWrite:!0},{id:"recovery",icon:"🔄",label:"Recovery"},{id:"managed-acl",icon:"🛡️",label:"Managed ACL",requiresOwner:!0},{id:"sprocket",icon:"⚙️",label:"Sprocket",requiresOwner:!0},{id:"policy",icon:"📜",label:"Policy",requiresOwner:!0},{id:"logs",icon:"📋",label:"Logs",requiresOwner:!0}];function xe(e){n(5,w=e),"sprocket"===e&&u&&"owner"===p&&q&&(we(),ve()),me()}function Be(){n(15,y=!1)}function Se(e){Fe(e)}function Fe(e){n(6,k=k.filter(t=>t.id!==e)),R.delete(e),w===e&&n(5,w="export")}async function Qe(e,t=!0){const n=R.get(e);if(n&&!n.isLoading){n.isLoading=!0,R.set(e,n);try{const r={...n.filter};!t&&n.oldestTimestamp&&(r.until=n.oldestTimestamp),t||(r.limit=200),console.log("Loading search results with filter:",r);const i=await _h([r],{timeout:3e4});if(console.log("Received search results:",i.length,"events"),n.events=t?i.sort((e,t)=>t.created_at-e.created_at):[...n.events,...i].sort((e,t)=>t.created_at-e.created_at),i.length>0){const e=Math.min(...i.map(e=>e.created_at));(!n.oldestTimestamp||e0){const e=o.filter(e=>e.pubkey&&e.pubkey!==d);e.length>0&&console.warn("Server returned non-user events:",e.length,"out of",o.length)}if(e?(n(97,I=o.sort((e,t)=>t.created_at-e.created_at)),ye(o)):(n(97,I=[...I,...o].sort((e,t)=>t.created_at-e.created_at)),ye(I)),o.length>0){const e=Math.min(...o.map(e=>e.created_at));(!Q||e{if("events"===w){const e=document.querySelectorAll(".events-view-content")[0];e&&e.scrollHeight<=e.clientHeight&&Ne()}},100)}catch(e){console.error("Failed to load events:",e),alert("Failed to load events: "+e.message)}finally{n(7,S=!1)}}}async function Ne(){await Te(!1)}let Le=!1;async function Oe(e,t){if(!u||!d)throw new Error("Not logged in");const n={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",window.location.origin+e],["method",t.toUpperCase()]],content:"",pubkey:d};let r;if(g&&"extension"===f)try{r=await g.signEvent(n)}catch(e){throw new Error("Failed to sign with extension: "+e.message)}else{if("nsec"!==f)throw new Error("No valid signer available");n.id="mock-id-"+Date.now(),n.sig="mock-signature-"+Date.now(),r=n}const i=JSON.stringify(r);return`Nostr ${btoa(i)}`}async function Me(e,t){if(!u||!d)throw new Error("Not logged in");const n={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",window.location.origin+t],["method",e.toUpperCase()]],content:"",pubkey:d};let r;if(g&&"extension"===f)try{r=await g.signEvent(n)}catch(e){throw new Error("Failed to sign with extension: "+e.message)}else{if("nsec"!==f)throw new Error("No valid signer available");n.id="mock-id-"+Date.now(),n.sig="mock-signature-"+Date.now(),r=n}const i=JSON.stringify(r);return btoa(i)}function _e(e,t){const n=e.toLowerCase();if(n.includes("policy")||n.includes("blocked")||n.includes("denied")){let n=`Policy Error: ${e}`;return null!==t&&(n+=`\n\nKind ${t} may be restricted by the relay's policy configuration.`),V&&(n+="\n\nThe relay has policy enforcement enabled. Contact a relay administrator to allow this event kind or adjust your permissions."),n}if(n.includes("auth")||n.includes("permission")||n.includes("unauthorized"))return`Permission Error: ${e}\n\nYour current permissions may not allow publishing this type of event. Current role: ${p||"unknown"}. Contact a relay administrator to upgrade your permissions.`;if(n.includes("kind")||n.includes("not allowed")||n.includes("restricted")){let n=`Event Type Error: ${e}`;return null!==t&&(n+=`\n\nKind ${t} is not currently allowed on this relay.`),n+="\n\nThe relay administrator may need to update the policy configuration to allow this event kind.",n}return n.includes("rate")||n.includes("limit")||n.includes("too many")?`Rate Limit Error: ${e}\n\nPlease wait a moment before trying again.`:n.includes("size")||n.includes("too large")||n.includes("content")?`Size Limit Error: ${e}\n\nThe event may exceed the relay's size limits. Try reducing the content length.`:`Publishing failed: ${e}`}function He(e){n(98,D=e),localStorage.setItem("viewAsRole",e),console.log("View as role changed to:",e,"Current effective role:",a)}D=localStorage.getItem("viewAsRole")||"";return e.$$.update=()=>{var t;if(6&e.$$.dirty[0]|16&e.$$.dirty[3]&&n(42,r=I.sort((e,t)=>t.created_at-e.created_at)),8&e.$$.dirty[0]&&n(41,i=h?.about?(t=h.about,t?t.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"):"").replace(/\n{2,}/g,"
    "):""),16&e.$$.dirty[0]|32&e.$$.dirty[3]&&n(10,a=D&&""!==D?D:p),1810&e.$$.dirty[0]|96&e.$$.dirty[3]&&n(101,o=Ce.filter(e=>{const t=a;return!(e.requiresAdmin&&(!u||"admin"!==t&&"owner"!==t))&&(!(e.requiresOwner&&(!u||"owner"!==t))&&(!(e.requiresWrite&&(!u||"read"===t))&&(!("sprocket"===e.id&&!q)&&(!("policy"===e.id&&!V)&&(("managed-acl"!==e.id||"managed"===ee)&&(console.log(`Tab ${e.id} filter check:`,{isLoggedIn:u,userRole:p,viewAsRole:D,currentRole:t,requiresAdmin:e.requiresAdmin,requiresOwner:e.requiresOwner,requiresWrite:e.requiresWrite,visible:!0}),!0))))))})),64&e.$$.dirty[0]|256&e.$$.dirty[3]&&n(11,s=[...o,...k]),2578&e.$$.dirty[0]|256&e.$$.dirty[3]&&console.log("Tabs debug:",{isLoggedIn:u,userRole:p,aclMode:ee,filteredBaseTabs:o.map(e=>e.id),allTabs:s.map(e=>e.id)}),1&e.$$.dirty[0]&&"undefined"!=typeof document&&(l?document.body.classList.add("dark-theme"):document.body.classList.remove("dark-theme")),14&e.$$.dirty[0]&&u&&d&&!h&&Re(),182&e.$$.dirty[0]|144&e.$$.dirty[3]&&"events"===w&&u&&("read"===p||"write"===p||"admin"===p||"owner"===p)&&0===I.length&&!Le&&!S){n(100,Le=!0);Te(!0,null)}32&e.$$.dirty[0]|16&e.$$.dirty[3]&&("events"!==w||"events"===w&&I.length>0)&&n(100,Le=!1),32&e.$$.dirty[0]&&localStorage.setItem("selectedTab",w)},[l,u,d,h,p,w,k,S,V,ee,a,s,c,g,m,y,v,E,C,B,O,M,_,H,j,G,K,J,Y,z,W,Z,X,te,ne,re,ie,oe,se,ae,le,i,r,R,ue,de,async function(){console.log("Toggle changed, showOnlyMyEvents:",DE),n(100,Le=!1),await Te(!0,null)},fe,he,pe,ge,function(){console.log("selectRecoveryKind called, recoverySelectedKind:",ie),null!=ie?(n(37,oe=""),n(38,se=[]),ce=null,n(40,le=!0),he()):console.log("No kind selected, skipping load")},function(){console.log("handleCustomKindInput called, recoveryCustomKind:",oe);const e=parseInt(oe);""!==oe&&!isNaN(e)&&e>=0&&(n(36,ie=null),n(38,se=[]),ce=null,n(40,le=!0),he())},function(e){const t=se.filter(t=>t.kind===e.kind&&t.pubkey===e.pubkey),n=Math.max(...t.map(e=>e.created_at));return e.created_at===n},async function(){if(u&&"owner"===p)try{n(23,H=!0);const e=await fetch("/api/sprocket/status",{method:"GET",headers:{Authorization:`Nostr ${await Me("GET","/api/sprocket/status")}`,"Content-Type":"application/json"}});if(e.ok){const t=await e.json();n(20,O=t.script_content||""),n(21,M=t),ke("Script loaded successfully","success")}else ke("Failed to load script","error")}catch(e){ke(`Error loading script: ${e.message}`,"error")}finally{n(23,H=!1)}},async function(){if(u&&"owner"===p)try{n(23,H=!0);const e=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await Me("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:O});if(e.ok)ke("Script saved and updated successfully","success"),await we(),await ve();else{ke(`Failed to save script: ${await e.text()}`,"error")}}catch(e){ke(`Error saving script: ${e.message}`,"error")}finally{n(23,H=!1)}},async function(){if(u&&"owner"===p)try{n(23,H=!0);const e=await fetch("/api/sprocket/restart",{method:"POST",headers:{Authorization:`Nostr ${await Me("POST","/api/sprocket/restart")}`,"Content-Type":"application/json"}});if(e.ok)ke("Sprocket restarted successfully","success"),await we();else{ke(`Failed to restart sprocket: ${await e.text()}`,"error")}}catch(e){ke(`Error restarting sprocket: ${e.message}`,"error")}finally{n(23,H=!1)}},async function(){if(u&&"owner"===p&&confirm("Are you sure you want to delete the sprocket script? This will stop the current process."))try{n(23,H=!0);const e=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await Me("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:""});if(e.ok)n(20,O=""),ke("Sprocket script deleted successfully","success"),await we(),await ve();else{ke(`Failed to delete script: ${await e.text()}`,"error")}}catch(e){ke(`Error deleting script: ${e.message}`,"error")}finally{n(23,H=!1)}},ve,Ae,be,async function(){if(u&&("owner"===p||RE))try{n(28,Y=!0),n(31,Z=[]);const e={kinds:[12345],limit:1},t=await qh(e);if(t&&t.length>0){n(27,J=t[0].content);try{n(27,J=JSON.stringify(JSON.parse(J),null,2))}catch(e){}Ie("Policy loaded successfully","success")}else{const e=await fetch("/api/policy",{method:"GET",headers:{Authorization:`Nostr ${await Me("GET","/api/policy")}`,"Content-Type":"application/json"}});if(e.ok){const t=await e.json();n(27,J=JSON.stringify(t,null,2)),Ie("Policy loaded from file","success")}else Ie("No policy configuration found","info"),n(27,J="")}}catch(e){Ie(`Error loading policy: ${e.message}`,"error")}finally{n(28,Y=!1)}},Ee,async function(){if(!u||"owner"!==p&&!RE)return;if(await Ee())try{n(28,Y=!0);const e={kind:12345,created_at:Math.floor(Date.now()/1e3),tags:[],content:J},t=await DI(e,g);t.success?Ie("Policy updated successfully","success"):Ie(`Failed to publish policy: ${t.error||"Unknown error"}`,"error")}catch(e){Ie(`Error saving policy: ${e.message}`,"error")}finally{n(28,Y=!1)}},function(){try{const e=JSON.parse(J);n(27,J=JSON.stringify(e,null,2)),Ie("JSON formatted","success")}catch(e){Ie(`Cannot format: ${e.message}`,"error")}},function(e){const t=e.detail;if(!t)return void Ie("Please enter a pubkey","error");const r=function(e){if(!e)return null;if(/^[0-9a-fA-F]{64}$/.test(e))return e.toLowerCase();if(e.startsWith("npub1"))try{const t="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n=e.slice(5);let r=[];for(const e of n){const n=t.indexOf(e.toLowerCase());if(-1===n)throw new Error("Invalid character in npub");r.push(...[...Array(5)].map((e,t)=>n>>4-t&1))}r=r.slice(0,-30);const i=[];for(let e=0;e+8<=r.length;e+=8){let t=0;for(let n=0;n<8;n++)t=t<<1|r[e+n];i.push(t)}return i.map(e=>e.toString(16).padStart(2,"0")).join("")}catch(e){return console.error("Failed to decode npub:",e),null}return null}(t);if(r&&64===r.length)try{const e=JSON.parse(J||"{}");if(e.policy_admins||(e.policy_admins=[]),e.policy_admins.includes(r))return void Ie("Admin already in list","warning");e.policy_admins.push(r),n(27,J=JSON.stringify(e,null,2)),Ie("Admin added - click 'Save & Publish' to apply","info")}catch(e){Ie(`Error adding admin: ${e.message}`,"error")}else Ie("Invalid pubkey format. Use hex (64 chars) or npub","error")},function(e){const t=e.detail;try{const e=JSON.parse(J||"{}");e.policy_admins&&(e.policy_admins=e.policy_admins.filter(e=>e!==t),n(27,J=JSON.stringify(e,null,2)),Ie("Admin removed - click 'Save & Publish' to apply","info"))}catch(e){Ie(`Error removing admin: ${e.message}`,"error")}},async function(){if(u&&("owner"===p||RE))try{n(28,Y=!0),n(32,X=[]);let e=[];try{e=JSON.parse(J||"{}").policy_admins||[]}catch(e){return void Ie("Cannot parse policy JSON to get admins","error")}if(0===e.length)return void Ie("No policy admins configured","warning");const t={kinds:[3],authors:e,limit:e.length},r=await qh(t),i=new Set;for(const e of r)if(e.tags)for(const t of e.tags)"p"===t[0]&&t[1]&&64===t[1].length&&i.add(t[1]);n(32,X=Array.from(i)),Ie(`Loaded ${X.length} follows from ${r.length} admin(s)`,"success")}catch(e){Ie(`Error loading follows: ${e.message}`,"error")}finally{n(28,Y=!1)}},function(e){n(26,K=e.target.files[0])},async function(){if(u&&"owner"===p&&K)try{n(23,H=!0);const e=await K.text(),t=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await Me("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:e});if(t.ok)n(20,O=e),ke("Script uploaded and updated successfully","success"),await we(),await ve();else{ke(`Failed to upload script: ${await t.text()}`,"error")}}catch(e){ke(`Error uploading script: ${e.message}`,"error")}finally{n(23,H=!1),n(26,K=null);const e=document.getElementById("sprocket-upload-file");e&&(e.value="")}},xe,function(){u||n(12,c=!0)},async function(e){const{method:t,pubkey:r,privateKey:i,signer:o}=e.detail;n(1,u=!0),n(2,d=r),f=t,n(13,g=o),n(12,c=!1),n(14,m="nsec"===t&&i?i:null);try{if(await Gh(),"extension"===t&&o)Qh.setSigner(o);else if("nsec"===t&&i){const e=new xf(i);Qh.setSigner(e)}n(3,h=await Oh(r)),console.log("Profile loaded:",h)}catch(e){console.error("Failed to load profile:",e)}await Pe(),await $e()},function(){n(1,u=!1),n(2,d=""),f="",n(3,h=null),n(4,p=""),n(13,g=null),n(14,m=null),n(15,y=!1),T=[],n(97,I=[]),P=[],U=0,me(),"undefined"!=typeof localStorage&&(localStorage.removeItem("nostr_auth_method"),localStorage.removeItem("nostr_pubkey"),localStorage.removeItem("nostr_privkey"))},function(){n(12,c=!1)},function(){n(15,y=!0)},Be,function(){n(16,v=!v)},function(e){const{searchText:t,selectedKinds:n,pubkeys:r,eventIds:i,tags:o,sinceTimestamp:s,untilTimestamp:a,limit:l}=e.detail,c=function({searchText:e=null,kinds:t=[],authors:n=[],ids:r=[],tags:i=[],since:o=null,until:s=null,limit:a=null}){const l={};return e&&e.trim()&&(l.search=e.trim()),t&&t.length>0&&(l.kinds=t),n&&n.length>0&&(l.authors=n),r&&r.length>0&&(l.ids=r),i&&i.length>0&&i.forEach(e=>{if(e.name&&e.value){const t=`#${e.name}`;l[t]||(l[t]=[]),l[t].push(e.value)}}),o&&(l.since=o),s&&(l.until=s),a&&a>0&&(l.limit=a),l}({searchText:t,kinds:n,authors:r,ids:i,tags:o,since:s,until:a,limit:l||100});A=c,Te(!0,null)},function(){A={},Te(!0,null)},Se,Fe,Qe,De,Re,async function(){await Ue([])},async function(){await Ue([d])},function(e){n(17,E=e.detail.target.files[0])},async function(){if("none"!==ee&&(!u||"admin"!==p&&"owner"!==p))return n(18,C="Admin or owner permission required"),void setTimeout(()=>{n(18,C="")},5e3);if(!E)return n(18,C="Please select a file"),void setTimeout(()=>{n(18,C="")},5e3);try{n(18,C="Uploading...");const e={};"none"!==ee&&u&&(e.Authorization=await Oe("/api/import","POST"));const t=new FormData;t.append("file",E);const r=await fetch("/api/import",{method:"POST",headers:e,body:t});if(!r.ok)throw new Error(`Import failed: ${r.status} ${r.statusText}`);await r.json();n(18,C="Upload complete"),n(17,E=null),document.getElementById("import-file").value="",setTimeout(()=>{n(18,C="")},5e3)}catch(e){console.error("Import failed:",e),n(18,C="Import failed: "+e.message),setTimeout(()=>{n(18,C="")},5e3)}},Te,function(e){const{scrollTop:t,scrollHeight:n,clientHeight:r}=e.target;n-t-r<100&&Ne()},function(){try{if(!ne.trim())return void alert("Please enter some JSON to reformat");const e=JSON.parse(ne);n(34,ne=JSON.stringify(e,null,2))}catch(e){alert("Invalid JSON: "+e.message)}},async function(){try{if(!ne.trim())return void alert("Please enter an event to sign");if(!u||!d)return void alert("Please log in to sign events");if(!g)return void alert("No signer available. Please log in with a valid authentication method.");const e=JSON.parse(ne);e.pubkey=d,e.created_at=Math.floor(Date.now()/1e3),delete e.id,delete e.sig;const t=await g.signEvent(e);n(34,ne=JSON.stringify(t,null,2)),alert("Event signed successfully!")}catch(e){console.error("Error signing event:",e),alert("Error signing event: "+e.message)}},async function(){n(35,re="");try{if(!ne.trim())return void n(35,re="Please enter an event to publish");if(!u)return void n(35,re="Please log in to publish events");if(!g)return void n(35,re="No signer available. Please log in with a valid authentication method.");let e;try{e=JSON.parse(ne)}catch(e){return void n(35,re=`Invalid JSON: ${e.message}`)}if(!e.id||!e.sig)return void n(35,re='Event must be signed before publishing. Please click "Sign" first.');if("read"===p)return void n(35,re=`Permission denied: Your current role is "${p}" which does not allow publishing events. Contact a relay administrator to upgrade your permissions.`);const t=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`,r=await DI(t,e,g,d);if(r.success)n(35,re=""),alert("Event published successfully to ORLY relay!");else{const t=r.reason||"Unknown error";n(35,re=_e(t,e.kind))}}catch(e){console.error("Error publishing event:",e);const t=e.message||"Unknown error";n(35,re=_e(t,null))}},function(){n(35,re="")},He,function(){const e=["owner","admin","write","read"],t=e.indexOf(p);return-1===t?["read"]:e.slice(t)},I,D,q,Le,o,function(t){$.call(this,e,t)},function(t){$.call(this,e,t)},e=>e.id===w,e=>xe(e.detail),e=>Fe(e.detail),e=>ue(e.detail),e=>fe(e.detail),e=>de(e.detail.event,e.detail.e),e=>Te(e.detail.refresh,e.detail.authors),function(e){ne=e,n(34,ne)},function(e){O=e,n(20,O)},e=>Ae(e.detail),e=>be(e.detail),function(e){J=e,n(27,J)},function(){ie=x(this),n(36,ie)},function(){oe=b(this.value),n(37,oe)},e=>ge(e),e=>pe(e),(e,t)=>de(e,t),e=>Qe(e.id,!0),e=>Se(e.id),e=>fe(e.id),e=>ue(e.id),(e,t)=>"Enter"===t.key&&ue(e.id),(e,t)=>de(e,t),(e,t)=>De(t,e.id),e=>He(e===p?"":e),e=>"Escape"===e.key&&Be(),function(e){c=e,n(12,c)}]}return new class extends ae{constructor(e){super(),se(this,e,PE,QE,o,{},null,[-1,-1,-1,-1,-1,-1])}}({target:document.body,props:{name:"world"}})}(); +const hk={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},pk={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},gk=BigInt(2);const mk=Rb(hk.p,{sqrt:function(e){const t=hk.p,n=BigInt(3),r=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),l=BigInt(88),c=e*e*e%t,u=c*c*e%t,d=bb(u,n,t)*u%t,f=bb(d,n,t)*u%t,h=bb(f,gk,t)*c%t,p=bb(h,i,t)*h%t,g=bb(p,o,t)*p%t,m=bb(g,a,t)*g%t,y=bb(m,l,t)*m%t,w=bb(y,a,t)*g%t,v=bb(w,n,t)*u%t,A=bb(v,s,t)*p%t,b=bb(A,r,t)*c%t,k=bb(b,gk,t);if(!mk.eql(mk.sqr(k),e))throw new Error("Cannot find square root");return k}}),yk=function(e,t){const n=t=>fk({...e,hash:t});return{...n(t),create:n}}({...hk,Fp:mk,lowS:!0,endo:pk},GA),wk=GA,vk="nip46";function Ak(e){let t=0n;for(const n of e)t=t<<8n|BigInt(n);return t}function bk(e){const t=yk.utils.randomPrivateKey(),n=yk.ProjectivePoint.fromHex(function(e){const t=(new TextEncoder).encode("Secp256k1_HashToCurve_Cashu_"),n=wk(new Uint8Array([...t,...e]));for(let e=0;e<65536;e++){const t=new Uint8Array(4);new DataView(t.buffer).setUint32(0,e,!0);const r=new Uint8Array([...n,...t]),i=wk(r),o=new Uint8Array([2,...i]);try{if(!yk.ProjectivePoint.fromHex(o).equals(yk.ProjectivePoint.ZERO))return o}catch{}}throw new Error("Failed to hash to curve after 65536 attempts")}(e)),r=yk.ProjectivePoint.BASE.multiply(Ak(t));return{B_:n.add(r).toRawBytes(!0),secret:e,r:t}}function kk(e){const t={k:e.keysetId,s:Hu(e.secret),c:Hu(e.signature),p:Hu(e.pubkey),e:e.expiry,sc:e.scope,kinds:e.kinds,kind_ranges:e.kindRanges},n=JSON.stringify(t);return"cashuA"+btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function Ik(e,t,n,r,i,o){const s=bk(crypto.getRandomValues(new Uint8Array(32))),a={blinded_message:Hu(s.B_),scope:t,kinds:i,kind_ranges:o},l=`${e}/cashu/mint`,c=await r(l,"POST"),u=await fetch(l,{method:"POST",headers:{"Content-Type":"application/json",Authorization:c},body:JSON.stringify(a)});if(!u.ok){const e=await u.text();throw new Error(`Mint request failed: ${e}`)}const d=await u.json(),f=zu(d.blinded_signature),h=zu(d.mint_pubkey),p=function(e,t,n){const r=yk.ProjectivePoint.fromHex(e),i=yk.ProjectivePoint.fromHex(n).multiply(Ak(t));return r.subtract(i).toRawBytes(!0)}(f,s.r,h);return{keysetId:d.keyset_id,secret:s.secret,signature:p,pubkey:n,expiry:d.expiry,scope:t,kinds:i,kindRanges:o}}async function Ek(e){let t=e.replace("wss://","https://").replace("ws://","http://").replace(/\/$/,"");try{const e=await fetch(`${t}/cashu/info`);if(!e.ok)return null;const n=await e.json();return n.mintUrl=t,n}catch{return null}}const Ck=[];function xk(t,n=e){let r;const i=new Set;function s(e){if(o(t,e)&&(t=e,r)){const e=!Ck.length;for(const e of i)e[1](),Ck.push(e,t);if(e){for(let e=0;e{i.delete(l),0===i.size&&r&&(r(),r=null)}}}}!function(t,n,o){const s=!Array.isArray(t),a=s?[t]:t,c=n.length<2;return u=t=>{let o=!1;const u=[];let d=0,f=e;const h=()=>{if(d)return;f();const r=n(s?u[0]:u,t);c?t(r):f=i(r)?r:e},p=a.map((e,t)=>l(e,e=>{u[t]=e,d&=~(1<{d|=1<t||e),xk(localStorage.getItem("selectedTab")||"export");const Bk=xk(null),Sk=xk(!1),Fk=xk(null),Qk=xk([]),Dk=xk(null),Rk=xk([]);let $k=null;function Pk(){return $k||$k||($k=new Worker("/bunker-worker.js"),$k.onmessage=e=>{const{type:t,...n}=e.data;switch(t){case"status":Sk.set("connected"===n.status);break;case"clients":Rk.set(n.clients||[]);break;case"error":console.error("[BunkerStore] Worker error:",n.error);break;case"request":console.log("[BunkerStore] NIP-46 request:",n.method,"from:",n.from?.substring(0,8))}},$k.onerror=e=>{console.error("[BunkerStore] Worker error:",e),Sk.set(!1)},Bk.set($k),$k)}function Uk(){$k&&$k.postMessage({type:"disconnect"}),Sk.set(!1),Fk.set(null),Qk.set([]),Dk.set(null),Rk.set([])}function Tk(e,t,n){const r=e.slice();return r[50]=t[n],r}function Nk(e,t,n){const r=e.slice();return r[54]=t[n],r}function Lk(t){let n,r,i,o,s,a;return{c(){n=g("div"),r=g("p"),r.textContent="Please log in to access remote signing.",i=w(),o=g("button"),o.textContent="Log In",k(r,"class","svelte-13nqrp7"),k(o,"class","login-btn svelte-13nqrp7"),k(n,"class","login-prompt svelte-13nqrp7")},m(e,l){f(e,n,l),d(n,r),d(n,i),d(n,o),s||(a=A(o,"click",t[24]),s=!0)},p:e,d(e){e&&h(n),s=!1,a()}}}function Ok(e){let t,n,r,i,o,s,a,l,c=(e[3]||"read-only")+"";return{c(){t=g("div"),n=g("div"),r=g("h3"),r.textContent="Access Denied",i=w(),o=g("p"),s=y("You need write access to use remote signing. Your current access level: "),a=g("strong"),l=y(c),k(r,"class","svelte-13nqrp7"),k(o,"class","svelte-13nqrp7"),k(n,"class","access-denied svelte-13nqrp7"),k(t,"class","bunker-view svelte-13nqrp7")},m(e,c){f(e,t,c),d(t,n),d(n,r),d(n,i),d(n,o),d(o,s),d(o,a),d(a,l)},p(e,t){8&t[0]&&c!==(c=(e[3]||"read-only")+"")&&E(l,c)},d(e){e&&h(t)}}}function Mk(e){let t,n,r,i,o,s,a,l,c,u,p,m=e[7]?"Loading...":"Refresh",v=e[8]&&Hk(e),b=e[4]?.cashu_enabled&&"none"!==e[4]?.acl_mode&&jk();function I(e,t){return e[7]&&!e[4]?qk:e[4]?Gk:void 0}let C=I(e),x=C&&C(e);return{c(){t=g("div"),n=g("div"),r=g("h3"),r.textContent="Remote Signing (NIP-46 Bunker)",i=w(),o=g("button"),s=y(m),a=w(),v&&v.c(),l=w(),b&&b.c(),c=w(),x&&x.c(),k(r,"class","svelte-13nqrp7"),k(o,"class","refresh-btn svelte-13nqrp7"),o.disabled=e[7],k(n,"class","header-section svelte-13nqrp7"),k(t,"class","bunker-view svelte-13nqrp7")},m(h,g){f(h,t,g),d(t,n),d(n,r),d(n,i),d(n,o),d(o,s),d(t,a),v&&v.m(t,null),d(t,l),b&&b.m(t,null),d(t,c),x&&x.m(t,null),u||(p=A(o,"click",e[21]),u=!0)},p(e,n){128&n[0]&&m!==(m=e[7]?"Loading...":"Refresh")&&E(s,m),128&n[0]&&(o.disabled=e[7]),e[8]?v?v.p(e,n):(v=Hk(e),v.c(),v.m(t,l)):v&&(v.d(1),v=null),e[4]?.cashu_enabled&&"none"!==e[4]?.acl_mode?b||(b=jk(),b.c(),b.m(t,c)):b&&(b.d(1),b=null),C===(C=I(e))&&x?x.p(e,n):(x&&x.d(1),x=C&&C(e),x&&(x.c(),x.m(t,null)))},d(e){e&&h(t),v&&v.d(),b&&b.d(),x&&x.d(),u=!1,p()}}}function _k(t){let n;return{c(){n=g("div"),n.innerHTML='

    Remote Signing Not Available

    \n

    This relay does not have bunker mode enabled, or ACL mode is set to "none".

    \n

    Remote signing requires the relay operator to enable ACL mode "follows" or "managed".

    ',k(n,"class","bunker-view svelte-13nqrp7")},m(e,t){f(e,n,t)},p:e,d(e){e&&h(n)}}}function Hk(e){let t,n;return{c(){t=g("div"),n=y(e[8]),k(t,"class","error-message svelte-13nqrp7")},m(e,r){f(e,t,r),d(t,n)},p(e,t){256&t[0]&&E(n,e[8])},d(e){e&&h(t)}}}function jk(e){let t;return{c(){t=g("div"),t.innerHTML="CAT Required: This relay requires Cashu Access Tokens (CAT) for bunker connections.\n Your client must support CAT authentication or connections will be rejected.",k(t,"class","cat-warning svelte-13nqrp7")},m(e,n){f(e,t,n)},d(e){e&&h(t)}}}function Gk(e){let t,n,i,o,s,a,l,c,u,p,m,v,b,I,C,x,B,S,Q,D,R,$,P,U,T,N,L,O,M,_,H,j,G,q,K,J,V,Y,z,W,Z=e[11]?"Active":"Inactive",X=e[4].relay_url+"",ee="relay"===e[9]?"Copied!":"Copy";function te(e,t){return e[2]?Kk:Jk}let ne=te(e),re=ne(e),ie=e[6].length>0&&Zk(e);return{c(){t=g("div"),t.innerHTML='

    How it works: Start the bunker service to allow remote apps (like Smesh) to request signatures from your ORLY account.\n Share the QR code or bunker URL with your client app.

    ',n=w(),i=g("div"),o=g("div"),s=g("h4"),s.textContent="Bunker Service",a=w(),l=g("div"),c=g("span"),u=w(),p=y(Z),m=w(),re.c(),v=w(),ie&&ie.c(),b=w(),I=g("div"),C=g("h4"),C.textContent="Connection Details",x=w(),B=g("div"),S=g("span"),S.textContent="Relay:",Q=w(),D=g("code"),R=y(X),$=w(),P=g("button"),U=y(ee),T=w(),N=g("div"),L=g("span"),L.textContent="Your npub:",O=w(),M=g("code"),_=y(e[1]),H=w(),j=g("div"),G=g("span"),G.textContent="Secret:",q=w(),K=g("code"),J=y(e[5]),V=w(),Y=g("button"),Y.textContent="Regenerate",k(t,"class","instructions svelte-13nqrp7"),k(s,"class","svelte-13nqrp7"),k(c,"class","status-dot svelte-13nqrp7"),k(l,"class","service-status svelte-13nqrp7"),F(l,"active",e[11]),k(o,"class","service-header svelte-13nqrp7"),k(i,"class","service-control svelte-13nqrp7"),k(C,"class","svelte-13nqrp7"),k(S,"class","label svelte-13nqrp7"),k(D,"class","svelte-13nqrp7"),k(P,"class","copy-btn svelte-13nqrp7"),k(B,"class","info-row svelte-13nqrp7"),k(L,"class","label svelte-13nqrp7"),k(M,"class","npub svelte-13nqrp7"),k(N,"class","info-row svelte-13nqrp7"),k(G,"class","label svelte-13nqrp7"),k(K,"class","secret svelte-13nqrp7"),k(Y,"class","copy-btn svelte-13nqrp7"),k(j,"class","info-row svelte-13nqrp7"),k(I,"class","connection-info svelte-13nqrp7")},m(r,h){f(r,t,h),f(r,n,h),f(r,i,h),d(i,o),d(o,s),d(o,a),d(o,l),d(l,c),d(l,u),d(l,p),d(i,m),re.m(i,null),f(r,v,h),ie&&ie.m(r,h),f(r,b,h),f(r,I,h),d(I,C),d(I,x),d(I,B),d(B,S),d(B,Q),d(B,D),d(D,R),d(B,$),d(B,P),d(P,U),d(I,T),d(I,N),d(N,L),d(N,O),d(N,M),d(M,_),d(I,H),d(I,j),d(j,G),d(j,q),d(j,K),d(K,J),d(j,V),d(j,Y),z||(W=[A(P,"click",e[41]),A(Y,"click",e[22])],z=!0)},p(e,t){2048&t[0]&&Z!==(Z=e[11]?"Active":"Inactive")&&E(p,Z),2048&t[0]&&F(l,"active",e[11]),ne===(ne=te(e))&&re?re.p(e,t):(re.d(1),re=ne(e),re&&(re.c(),re.m(i,null))),e[6].length>0?ie?ie.p(e,t):(ie=Zk(e),ie.c(),ie.m(b.parentNode,b)):ie&&(ie.d(1),ie=null),16&t[0]&&X!==(X=e[4].relay_url+"")&&E(R,X),512&t[0]&&ee!==(ee="relay"===e[9]?"Copied!":"Copy")&&E(U,ee),2&t[0]&&E(_,e[1]),32&t[0]&&E(J,e[5])},d(e){e&&h(t),e&&h(n),e&&h(i),re.d(),e&&h(v),ie&&ie.d(e),e&&h(b),e&&h(I),z=!1,r(W)}}}function qk(t){let n;return{c(){n=g("div"),n.textContent="Loading bunker information...",k(n,"class","loading svelte-13nqrp7")},m(e,t){f(e,n,t)},p:e,d(e){e&&h(n)}}}function Kk(e){let t,n,r;function i(e,t){return e[11]?Yk:Vk}let o=i(e),s=o(e),a=e[11]&&e[13].length>0&&zk(e);return{c(){t=g("div"),s.c(),n=w(),a&&a.c(),r=v(),k(t,"class","service-actions svelte-13nqrp7")},m(e,i){f(e,t,i),s.m(t,null),f(e,n,i),a&&a.m(e,i),f(e,r,i)},p(e,n){o===(o=i(e))&&s?s.p(e,n):(s.d(1),s=o(e),s&&(s.c(),s.m(t,null))),e[11]&&e[13].length>0?a?a.p(e,n):(a=zk(e),a.c(),a.m(r.parentNode,r)):a&&(a.d(1),a=null)},d(e){e&&h(t),s.d(),e&&h(n),a&&a.d(e),e&&h(r)}}}function Jk(t){let n;return{c(){n=g("div"),n.textContent="Bunker service requires nsec login. Please log in with your private key to enable remote signing.",k(n,"class","no-privkey-warning svelte-13nqrp7")},m(e,t){f(e,n,t)},p:e,d(e){e&&h(n)}}}function Vk(e){let t,n,r,i,o=e[10]?"Starting...":"Start Service";return{c(){t=g("button"),n=y(o),k(t,"class","start-btn svelte-13nqrp7"),t.disabled=e[10]},m(o,s){f(o,t,s),d(t,n),r||(i=A(t,"click",e[19]),r=!0)},p(e,r){1024&r[0]&&o!==(o=e[10]?"Starting...":"Start Service")&&E(n,o),1024&r[0]&&(t.disabled=e[10])},d(e){e&&h(t),r=!1,i()}}}function Yk(t){let n,r,i;return{c(){n=g("button"),n.textContent="Stop Service",k(n,"class","stop-btn svelte-13nqrp7")},m(e,o){f(e,n,o),r||(i=A(n,"click",t[20]),r=!0)},p:e,d(e){e&&h(n),r=!1,i()}}}function zk(e){let t,n,r,i,o,s,a=e[13].length+"",l=e[13],c=[];for(let t=0;te[50].id;for(let t=0;tl.p(e,t)):(l=u(r,e),l.c()),w.set(r,y[g]=l),r in m&&v.set(r,Math.abs(g-m[r]))}const b=new Set,k=new Set;function I(e){X(e,1),e.m(l,d),a.set(e.key,e),d=e.first,p--}for(;h&&p;){const t=y[p-1],n=e[h-1],r=t.key,i=n.key;t===n?(d=t.first,h--,p--):w.has(i)?!a.has(r)||b.has(r)?I(t):k.has(i)?h--:v.get(r)>v.get(i)?(k.add(r),I(t)):(b.add(i),h--):(c(n,a),h--)}for(;h--;){const t=e[h];w.has(t.key)||c(t,a)}for(;p;)I(y[p-1]);return r(A),y}(y,t,I,1,e,b,v,u,ne,rI,null,Tk))},d(e){e&&h(t);for(let e=0;et,r.anchor=null},p(t,i){e=t,r.ctx=e,64&i[0]&&n!==(n=e[18](e[50]))&&te(n,r)||function(e,t,n){const r=t.slice(),{resolved:i}=e;e.current===e.then&&(r[e.value]=i),e.current===e.catch&&(r[e.error]=i),e.block.p(r,n)}(r,e,i)},d(e){e&&h(t),r.block.d(),r.token=null,r=null}}}function eI(t){let n;return{c(){n=g("div"),n.textContent="Failed to generate QR",k(n,"class","error-message svelte-13nqrp7")},m(e,t){f(e,n,t)},p:e,d(e){e&&h(n)}}}function tI(e){let t,n,i,o,s,l,c,u,p,m,v,b,I,C,x,B,S,Q,D,R,$,P,U,T,N,L,O,M,_,H=new Date(e[50].createdAt).toLocaleString()+"",j=new Date(1e3*e[50].token.expiry).toLocaleString()+"",G=`bunker://${e[1]}?relay=${encodeURIComponent(e[4].relay_url)}${e[5]?`&secret=${e[5]}`:""}&cat=${e[50].encoded}`;function q(){return e[39](e[50])}function K(...t){return e[40](e[50],...t)}return{c(){t=g("div"),n=g("div"),i=g("img"),s=w(),l=g("div"),l.textContent="Copied!",c=w(),u=g("div"),p=g("div"),m=g("span"),m.textContent="Created:",v=w(),b=g("span"),I=y(H),C=w(),x=g("div"),B=g("span"),B.textContent="Expires:",S=w(),Q=g("span"),D=y(j),R=w(),$=g("div"),P=g("span"),P.textContent="Bunker URL:",U=w(),T=g("code"),N=y(G),L=w(),O=g("div"),O.textContent="Click QR code to copy URL",a(i.src,o=e[53])||k(i,"src",o),k(i,"alt","Token QR Code"),k(i,"class","qr-code small svelte-13nqrp7"),k(l,"class","qr-overlay svelte-13nqrp7"),F(l,"visible",e[9]===e[50].id),k(n,"class","qr-container small clickable svelte-13nqrp7"),k(n,"role","button"),k(n,"tabindex","0"),k(n,"title","Click to copy bunker URL"),k(m,"class","label svelte-13nqrp7"),k(p,"class","info-item svelte-13nqrp7"),k(B,"class","label svelte-13nqrp7"),k(x,"class","info-item svelte-13nqrp7"),k(P,"class","label svelte-13nqrp7"),k(T,"class","bunker-url small svelte-13nqrp7"),k($,"class","info-item url-item svelte-13nqrp7"),k(O,"class","copy-hint svelte-13nqrp7"),k(u,"class","token-info svelte-13nqrp7"),k(t,"class","token-detail-content svelte-13nqrp7")},m(e,r){f(e,t,r),d(t,n),d(n,i),d(n,s),d(n,l),d(t,c),d(t,u),d(u,p),d(p,m),d(p,v),d(p,b),d(b,I),d(u,C),d(u,x),d(x,B),d(x,S),d(x,Q),d(Q,D),d(u,R),d(u,$),d($,P),d($,U),d($,T),d(T,N),d(u,L),d(u,O),M||(_=[A(n,"click",q),A(n,"keypress",K)],M=!0)},p(t,n){e=t,64&n[0]&&!a(i.src,o=e[53])&&k(i,"src",o),576&n[0]&&F(l,"visible",e[9]===e[50].id),64&n[0]&&H!==(H=new Date(e[50].createdAt).toLocaleString()+"")&&E(I,H),64&n[0]&&j!==(j=new Date(1e3*e[50].token.expiry).toLocaleString()+"")&&E(D,j),114&n[0]&&G!==(G=`bunker://${e[1]}?relay=${encodeURIComponent(e[4].relay_url)}${e[5]?`&secret=${e[5]}`:""}&cat=${e[50].encoded}`)&&E(N,G)},d(e){e&&h(t),M=!1,r(_)}}}function nI(t){let n;return{c(){n=g("div"),n.textContent="Loading QR...",k(n,"class","qr-placeholder small svelte-13nqrp7")},m(e,t){f(e,n,t)},p:e,d(e){e&&h(n)}}}function rI(e,t){let n,i,o,s,a,l,c,u,p,m,v,I,C,x,B,S,Q,D,R,$,P=t[50].isExpanded?"▼":"▶",U=new Date(t[50].createdAt).toLocaleDateString()+"",T=new Date(1e3*t[50].token.expiry).toLocaleDateString()+"";function N(...e){return t[35](t[50],...e)}function L(){return t[36](t[50])}function O(){return t[37](t[50])}function M(...e){return t[38](t[50],...e)}let _=t[50].isExpanded&&Xk(t);return{key:e,first:null,c(){n=g("div"),i=g("div"),o=g("span"),s=y(P),a=w(),l=g("input"),u=w(),p=g("span"),m=y(U),v=w(),I=g("span"),C=y("Expires: "),x=y(T),B=w(),S=g("button"),S.textContent="Revoke",Q=w(),_&&_.c(),D=w(),k(o,"class","expand-icon svelte-13nqrp7"),k(l,"type","text"),k(l,"class","token-name-input svelte-13nqrp7"),l.value=c=t[50].name,k(l,"placeholder","Token name"),k(p,"class","token-created svelte-13nqrp7"),k(I,"class","token-expiry svelte-13nqrp7"),k(S,"class","revoke-btn svelte-13nqrp7"),k(S,"title","Revoke this token"),k(i,"class","token-main svelte-13nqrp7"),k(i,"role","button"),k(i,"tabindex","0"),k(n,"class","token-row svelte-13nqrp7"),F(n,"expanded",t[50].isExpanded),this.first=n},m(e,r){f(e,n,r),d(n,i),d(i,o),d(o,s),d(i,a),d(i,l),d(i,u),d(i,p),d(p,m),d(i,v),d(i,I),d(I,C),d(I,x),d(i,B),d(i,S),d(n,Q),_&&_.m(n,null),d(n,D),R||($=[A(l,"input",N),A(l,"click",b(t[34])),A(S,"click",b(L)),A(i,"click",O),A(i,"keypress",M)],R=!0)},p(e,r){t=e,64&r[0]&&P!==(P=t[50].isExpanded?"▼":"▶")&&E(s,P),64&r[0]&&c!==(c=t[50].name)&&l.value!==c&&(l.value=c),64&r[0]&&U!==(U=new Date(t[50].createdAt).toLocaleDateString()+"")&&E(m,U),64&r[0]&&T!==(T=new Date(1e3*t[50].token.expiry).toLocaleDateString()+"")&&E(x,T),t[50].isExpanded?_?_.p(t,r):(_=Xk(t),_.c(),_.m(n,D)):_&&(_.d(1),_=null),64&r[0]&&F(n,"expanded",t[50].isExpanded)},d(e){e&&h(n),_&&_.d(),R=!1,r($)}}}function iI(t){let n;function r(e,t){return e[4]?.available?e[12]?Mk:e[0]?Ok:Lk:_k}let i=r(t),o=i(t);return{c(){o.c(),n=v()},m(e,t){o.m(e,t),f(e,n,t)},p(e,t){i===(i=r(e))&&o?o.p(e,t):(o.d(1),o=i(e),o&&(o.c(),o.m(n.parentNode,n)))},i:e,o:e,d(e){o.d(e),e&&h(n)}}}function oI(){const e=new Uint8Array(16);return crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,"0")).join("")}function sI(e,t,n){let r,i,o,s,a,l,u,d,f,h,p,g;c(e,Dk,e=>n(30,f=e)),c(e,Rk,e=>n(31,h=e)),c(e,Qk,e=>n(32,p=e)),c(e,Sk,e=>n(33,g=e));let{isLoggedIn:m=!1}=t,{userPubkey:y=""}=t,{userSigner:w=null}=t,{userPrivkey:v=null}=t,{currentEffectiveRole:A=""}=t;const b=U();let k=null,I=!1,E="",C="",x="",B=!1;const S=["brave","calm","clever","cosmic","cozy","daring","eager","fancy","gentle","happy","jolly","keen","lively","merry","nimble","peppy","quick","rustic","shiny","swift","tender","vivid","witty","zesty"],F=["badger","bunny","coral","dolphin","falcon","gecko","heron","iguana","jaguar","koala","lemur","mango","narwhal","otter","panda","quail","rabbit","salmon","turtle","urchin","viper","walrus","yak","zebra"];async function Q(e,t){const n=await Ik(e.mintUrl,vk,zu(y),t,[24133]),r=kk(n),i=crypto.randomUUID().split("-")[0],o={id:i,name:`${S[Math.floor(Math.random()*S.length)]}-${F[Math.floor(Math.random()*F.length)]}`,token:n,encoded:r,createdAt:Date.now(),isExpanded:!1};return Qk.update(e=>[...e,o]),f||Dk.set(i),console.log(`Client token "${o.name}" created, expires:`,new Date(1e3*n.expiry).toISOString()),o}function D(e){n(6,i=i.filter(t=>t.id!==e)),o===e&&n(29,o=i.length>0?i[0].id:null),L()}function R(e){n(6,i=i.map(t=>t.id===e?{...t,isExpanded:!t.isExpanded}:t))}function P(e,t){n(6,i=i.map(n=>n.id===e?{...n,name:t}:n))}async function N(){n(7,I=!0),n(8,E="");try{n(4,k=await async function(){const e=`${window.location.origin}/api/bunker/info`,t=await fetch(e);if(!t.ok){const e=await t.text();throw new Error(e||`Failed to get bunker info: ${t.statusText}`)}return await t.json()}()),x||n(5,x=oI()),await L()}catch(e){console.error("Error loading bunker info:",e),n(8,E=e.message||"Failed to load bunker information")}finally{n(7,I=!1)}}async function L(){u&&await av.toDataURL(u,{width:280,margin:2,color:{dark:"#000000",light:"#ffffff"}}),d&&await av.toDataURL(d,{width:280,margin:2,color:{dark:"#000000",light:"#ffffff"}})}function O(e,t){navigator.clipboard.writeText(e),n(9,C=t),setTimeout(()=>{n(9,C="")},2e3)}$(async()=>{await N(),$k&&$k.postMessage({type:"getStatus"})});return e.$$set=e=>{"isLoggedIn"in e&&n(0,m=e.isLoggedIn),"userPubkey"in e&&n(1,y=e.userPubkey),"userSigner"in e&&n(25,w=e.userSigner),"userPrivkey"in e&&n(2,v=e.userPrivkey),"currentEffectiveRole"in e&&n(3,A=e.currentEffectiveRole)},e.$$.update=()=>{4&e.$$.dirty[1]&&n(11,r=g),2&e.$$.dirty[1]&&n(6,i=p),1073741824&e.$$.dirty[0]&&n(29,o=f),1&e.$$.dirty[1]&&n(13,s=h),11&e.$$.dirty[0]&&n(12,a=m&&y&&("write"===A||"admin"===A||"owner"===A)),536870976&e.$$.dirty[0]&&n(28,l=i.find(e=>e.id===o)),268435506&e.$$.dirty[0]&&n(27,u=k&&y&&l?`bunker://${y}?relay=${encodeURIComponent(k.relay_url)}${x?`&secret=${x}`:""}&cat=${l.encoded}`:""),16&e.$$.dirty[0]&&n(26,d=k?`nostr+connect://${k.relay_url}`:""),201326592&e.$$.dirty[0]&&(u||d)&&L()},[m,y,v,A,k,x,i,I,E,C,B,r,a,s,async function(){if(k?.cashu_enabled)try{const e=await Ek(k.relay_url);if(!e)return;const t=async(e,t)=>`Nostr ${await TA(w,y,t,e)}`;await Q(e,t),await L()}catch(e){console.error("Failed to add token:",e),n(8,E=e.message||"Failed to add token")}},D,R,P,async function(e){if(!k||!y)return null;const t=`bunker://${y}?relay=${encodeURIComponent(k.relay_url)}${x?`&secret=${x}`:""}&cat=${e.encoded}`;return await av.toDataURL(t,{width:200,margin:2,color:{dark:"#000000",light:"#ffffff"}})},async function(){if(r||B)console.log("Service already active or starting, ignoring");else if(v&&y&&k){n(10,B=!0),n(8,E="");try{let e=null;if(k.cashu_enabled){console.log("CAT required, minting tokens...");const t=await Ek(k.relay_url);if(t){const n=async(e,t)=>`Nostr ${await TA(w,y,t,e)}`,r=await Ik(t.mintUrl,vk,zu(y),n,[24133]);e=kk(r),Fk.set(r),console.log("Service CAT token acquired, expires:",new Date(1e3*r.expiry).toISOString()),await Q(t,n)}}const t=v instanceof Uint8Array?Hu(v):v;!function(e){Pk().postMessage({type:"configure",...e})}({userPubkey:y,userPrivkey:t,relayUrl:k.relay_url,catTokenEncoded:e,secrets:x?[x]:[]}),Pk().postMessage({type:"connect"}),await L(),console.log("Bunker worker started successfully")}catch(e){console.error("Failed to start bunker service:",e),n(8,E=e.message||"Failed to start bunker service"),Uk()}finally{n(10,B=!1)}}else n(8,E="Missing private key or bunker info")},function(){Uk(),L()},N,async function(){n(5,x=oI()),await L()},O,function(){b("openLoginModal")},w,d,u,l,o,f,h,p,g,function(t){T.call(this,e,t)},(e,t)=>P(e.id,t.target.value),e=>D(e.id),e=>R(e.id),(e,t)=>"Enter"===t.key&&R(e.id),e=>{O(`bunker://${y}?relay=${encodeURIComponent(k.relay_url)}${x?`&secret=${x}`:""}&cat=${e.encoded}`,e.id)},(e,t)=>{if("Enter"===t.key){O(`bunker://${y}?relay=${encodeURIComponent(k.relay_url)}${x?`&secret=${x}`:""}&cat=${e.encoded}`,e.id)}},()=>O(k.relay_url,"relay")]}class aI extends ce{constructor(e){super(),le(this,e,sI,iI,o,{isLoggedIn:0,userPubkey:1,userSigner:25,userPrivkey:2,currentEffectiveRole:3},null,[-1,-1])}}function lI(e,t,n){const r=e.slice();return r[29]=t[n],r}function cI(e,t,n){const r=e.slice();return r[32]=t[n],r}function uI(e){let t,n,r;function i(e,t){return e[0]?fI:hI}let o=i(e),s=o(e);return{c(){t=g("div"),n=g("p"),n.textContent="Log viewer is only available to relay owners.",r=w(),s.c(),k(n,"class","svelte-w6h7aj"),k(t,"class","login-prompt svelte-w6h7aj")},m(e,i){f(e,t,i),d(t,n),d(t,r),s.m(t,null)},p(e,n){o===(o=i(e))&&s?s.p(e,n):(s.d(1),s=o(e),s&&(s.c(),s.m(t,null)))},d(e){e&&h(t),s.d()}}}function dI(e){let t,n,i,o,s,a,l,c,u,m,v,b,I,C,x,S,F,Q,D,R,$,P,U,T,N,L,O,M,_,H,G,q=e[3]?"Loading...":"Refresh",K=e[2].length+"",J=e[12],V=[];for(let t=0;te[18].call(u)),k(a,"class","level-selector svelte-w6h7aj"),k(v,"class","clear-btn svelte-w6h7aj"),v.disabled=I=e[3]||0===e[2].length,k(x,"class","refresh-btn svelte-w6h7aj"),x.disabled=e[3],k(s,"class","header-controls svelte-w6h7aj"),k(n,"class","header-section svelte-w6h7aj"),k(R,"class","log-info svelte-w6h7aj"),k(_,"class","log-list svelte-w6h7aj"),k(t,"class","log-view svelte-w6h7aj")},m(r,h){f(r,t,h),d(t,n),d(n,i),d(n,o),d(n,s),d(s,a),d(a,l),d(a,c),d(a,u);for(let e=0;eNo logs available.

    ",k(n,"class","empty-state svelte-w6h7aj")},m(e,t){f(e,n,t)},p:e,d(e){e&&h(n)}}}function wI(e){let t,n,r,i,o=e[29].file+"",s=e[29].line+"";return{c(){t=g("span"),n=y(o),r=y(":"),i=y(s),k(t,"class","log-location svelte-w6h7aj")},m(e,o){f(e,t,o),d(t,n),d(t,r),d(t,i)},p(e,t){4&t[0]&&o!==(o=e[29].file+"")&&E(n,o),4&t[0]&&s!==(s=e[29].line+"")&&E(i,s)},d(e){e&&h(t)}}}function vI(e){let t,n,r,i,o,s,a,l,c,u,p,m=EI(e[29].timestamp)+"",v=e[29].level+"",A=e[29].message+"",b=e[29].file&&wI(e);return{c(){t=g("div"),n=g("span"),r=y(m),i=w(),o=g("span"),s=y(v),l=w(),b&&b.c(),c=w(),u=g("span"),p=y(A),k(n,"class","log-timestamp svelte-w6h7aj"),k(o,"class",a="log-level "+CI(e[29].level)+" svelte-w6h7aj"),k(u,"class","log-message svelte-w6h7aj"),k(t,"class","log-entry svelte-w6h7aj")},m(e,a){f(e,t,a),d(t,n),d(n,r),d(t,i),d(t,o),d(o,s),d(t,l),b&&b.m(t,null),d(t,c),d(t,u),d(u,p)},p(e,n){4&n[0]&&m!==(m=EI(e[29].timestamp)+"")&&E(r,m),4&n[0]&&v!==(v=e[29].level+"")&&E(s,v),4&n[0]&&a!==(a="log-level "+CI(e[29].level)+" svelte-w6h7aj")&&k(o,"class",a),e[29].file?b?b.p(e,n):(b=wI(e),b.c(),b.m(t,c)):b&&(b.d(1),b=null),4&n[0]&&A!==(A=e[29].message+"")&&E(p,A)},d(e){e&&h(t),b&&b.d()}}}function AI(e){let t;return{c(){t=g("span"),t.textContent="End of logs"},m(e,n){f(e,t,n)},d(e){e&&h(t)}}}function bI(e){let t;return{c(){t=g("span"),t.textContent="Scroll for more"},m(e,n){f(e,t,n)},d(e){e&&h(t)}}}function kI(e){let t;return{c(){t=g("span"),t.textContent="Loading more..."},m(e,n){f(e,t,n)},d(e){e&&h(t)}}}function II(t){let n;function r(e,t){return e[4]?dI:uI}let i=r(t),o=i(t);return{c(){o.c(),n=v()},m(e,t){o.m(e,t),f(e,n,t)},p(e,t){i===(i=r(e))&&o?o.p(e,t):(o.d(1),o=i(e),o&&(o.c(),o.m(n.parentNode,n)))},i:e,o:e,d(e){o.d(e),e&&h(n)}}}function EI(e){if(!e)return"";return new Date(e).toLocaleString()}function CI(e){switch(e?.toUpperCase()){case"TRC":case"TRACE":return"level-trace";case"DBG":case"DEBUG":return"level-debug";case"INF":case"INFO":default:return"level-info";case"WRN":case"WARN":return"level-warn";case"ERR":case"ERROR":return"level-error";case"FTL":case"FATAL":return"level-fatal"}}function xI(e,t,n){let r,{isLoggedIn:i=!1}=t,{userRole:o=""}=t,{userSigner:s=null}=t;const a=U();let l=[],c=!1,u=!0,d=0,f=0,h="",p="info",g="info";const m=["trace","debug","info","warn","error","fatal"];let y,w,v;async function A(e="GET",t="/api/logs"){if(!s)return null;try{const n={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",`${window.location.origin}${t}`],["method",e]],content:""},r=await s.signEvent(n);return btoa(JSON.stringify(r)).replace(/\+/g,"-").replace(/\//g,"_")}catch(e){return console.error("Error creating auth header:",e),null}}async function b(e=!1){if(!c){n(3,c=!0),n(7,h=""),e&&(d=0,n(2,l=[]));try{const t=`/api/logs?offset=${d}&limit=100`,r=await A("GET",t),i=`${window.location.origin}${t}`,o=await fetch(i,{headers:r?{Authorization:`Nostr ${r}`}:{}});if(!o.ok)throw new Error(`Failed to load logs: ${o.statusText}`);const s=await o.json();n(2,l=e?s.logs||[]:[...l,...s.logs||[]]),n(6,f=s.total||0),n(5,u=s.has_more||!1),d=l.length}catch(e){console.error("Error loading logs:",e),n(7,h=e.message||"Failed to load logs")}finally{n(3,c=!1)}}}async function k(){try{const e=await fetch(`${window.location.origin}/api/logs/level`);if(e.ok){const t=await e.json();n(8,p=t.level||"info"),n(9,g=p)}}catch(e){console.error("Error loading log level:",e)}}$(()=>{r&&(b(!0),k(),function(){if(!w)return;v=new IntersectionObserver(e=>{e[0].isIntersecting&&u&&!c&&u&&!c&&b(!1)},{threshold:.1}),v.observe(w)}())}),P(()=>{v&&v.disconnect()});return e.$$set=e=>{"isLoggedIn"in e&&n(0,i=e.isLoggedIn),"userRole"in e&&n(1,o=e.userRole),"userSigner"in e&&n(17,s=e.userSigner)},e.$$.update=()=>{3&e.$$.dirty[0]&&n(4,r=i&&"owner"===o),28&e.$$.dirty[0]&&r&&0===l.length&&!c&&(b(!0),k())},[i,o,l,c,r,u,f,h,p,g,y,w,m,b,async function(){if(g!==p)try{const e=await A("POST","/api/logs/level"),t=await fetch(`${window.location.origin}/api/logs/level`,{method:"POST",headers:{"Content-Type":"application/json",...e?{Authorization:`Nostr ${e}`}:{}},body:JSON.stringify({level:g})});if(!t.ok)throw new Error(`Failed to set log level: ${t.statusText}`);const r=await t.json();n(8,p=r.level),n(9,g=p)}catch(e){console.error("Error setting log level:",e),n(7,h=e.message||"Failed to set log level"),n(9,g=p)}},async function(){if(confirm("Are you sure you want to clear all logs?"))try{const e=await A("POST","/api/logs/clear"),t=await fetch(`${window.location.origin}/api/logs/clear`,{method:"POST",headers:e?{Authorization:`Nostr ${e}`}:{}});if(!t.ok)throw new Error(`Failed to clear logs: ${t.statusText}`);n(2,l=[]),d=0,n(5,u=!1),n(6,f=0)}catch(e){console.error("Error clearing logs:",e),n(7,h=e.message||"Failed to clear logs")}},function(){a("openLoginModal")},s,function(){g=S(this),n(9,g),n(12,m)},()=>b(!0),function(e){L[e?"unshift":"push"](()=>{w=e,n(11,w)})},function(e){L[e?"unshift":"push"](()=>{y=e,n(10,y)})}]}class BI extends ce{constructor(e){super(),le(this,e,xI,II,o,{isLoggedIn:0,userRole:1,userSigner:17},null,[-1,-1])}}function SI(e){let t,n,r,i,o,s,a,l,c,u,p;return{c(){t=g("div"),n=g("div"),r=g("h3"),r.textContent="Active Filter",i=w(),o=g("button"),o.textContent="🧹 Sweep",s=w(),a=g("div"),l=g("pre"),c=y(e[2]),k(r,"class","svelte-1tyqaa5"),k(o,"class","sweep-btn svelte-1tyqaa5"),k(o,"title","Clear filter"),k(n,"class","filter-display-header svelte-1tyqaa5"),k(l,"class","filter-json svelte-1tyqaa5"),k(a,"class","filter-json-container svelte-1tyqaa5"),k(t,"class","filter-display svelte-1tyqaa5")},m(h,g){f(h,t,g),d(t,n),d(n,r),d(n,i),d(n,o),d(t,s),d(t,a),d(a,l),d(l,c),u||(p=A(o,"click",e[3]),u=!0)},p(e,t){4&t&&E(c,e[2])},d(e){e&&h(t),u=!1,p()}}}function FI(t){let n,r=t[0]&&t[1]&&SI(t);return{c(){r&&r.c(),n=v()},m(e,t){r&&r.m(e,t),f(e,n,t)},p(e,[t]){e[0]&&e[1]?r?r.p(e,t):(r=SI(e),r.c(),r.m(n.parentNode,n)):r&&(r.d(1),r=null)},i:e,o:e,d(e){r&&r.d(e),e&&h(n)}}}function QI(e,t,n){let r,i;const o=U();let{filter:s={}}=t,{showFilter:a=!0}=t;return e.$$set=e=>{"filter"in e&&n(4,s=e.filter),"showFilter"in e&&n(0,a=e.showFilter)},e.$$.update=()=>{16&e.$$.dirty&&n(2,r=function(e){return JSON.stringify(e,null,2)}(s)),16&e.$$.dirty&&n(1,i=Object.keys(s).length>0)},[a,i,r,function(){o("sweep")},s]}class DI extends ce{constructor(e){super(),le(this,e,QI,FI,o,{filter:4,showFilter:0})}}function RI(e){return Fh[e]||`Kind ${e}`}function $I(e){return e?e.slice(0,8)+"..."+e.slice(-8):"unknown"}function PI(e,t=100){return e?e.length>t?e.slice(0,t)+"...":e:""}function UI(e){return e?new Date(1e3*e).toLocaleString():""}class TI{constructor(e,t,n){this.relayUrl=e,this.userSigner=t,this.userPubkey=n,this.ws=null,this.challenge=null,this.isAuthenticated=!1,this.authPromise=null}async connect(){return new Promise((e,t)=>{this.ws=new WebSocket(this.relayUrl),this.ws.onopen=()=>{console.log("WebSocket connected to relay:",this.relayUrl),e()},this.ws.onmessage=async e=>{try{const t=JSON.parse(e.data);await this.handleMessage(t)}catch(e){console.error("Error parsing relay message:",e)}},this.ws.onerror=e=>{console.error("WebSocket error:",e),t(new Error("Failed to connect to relay"))},this.ws.onclose=()=>{console.log("WebSocket connection closed"),this.isAuthenticated=!1,this.challenge=null},setTimeout(()=>{this.ws.readyState!==WebSocket.OPEN&&t(new Error("Connection timeout"))},1e4)})}async handleMessage(e){const[t,...n]=e;switch(t){case"AUTH":this.challenge=n[0],console.log("Received AUTH challenge:",this.challenge),await this.authenticate();break;case"OK":const[e,r,i]=n;e&&r?(console.log("Authentication successful for event:",e),this.isAuthenticated=!0,this.authPromise&&(this.authPromise.resolve(),this.authPromise=null)):e&&!r&&(console.error("Authentication failed:",i),this.authPromise&&(this.authPromise.reject(new Error(i||"Authentication failed")),this.authPromise=null));break;case"NOTICE":console.log("Relay notice:",n[0]);break;default:console.log("Unhandled message type:",t,n)}}async authenticate(){if(!this.challenge)throw new Error("No challenge received from relay");if(!this.userSigner)throw new Error("No signer available for authentication");try{const e={kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",this.relayUrl],["challenge",this.challenge]],content:"",pubkey:this.userPubkey},t=["AUTH",await this.userSigner.signEvent(e)];return this.ws.send(JSON.stringify(t)),console.log("Sent authentication event to relay"),new Promise((e,t)=>{this.authPromise={resolve:e,reject:t},setTimeout(()=>{this.authPromise&&(this.authPromise.reject(new Error("Authentication timeout")),this.authPromise=null)},1e4)})}catch(e){throw console.error("Authentication error:",e),e}}async publishEvent(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");return new Promise((t,n)=>{const r=["EVENT",e];this.ws.send(JSON.stringify(r));const i=this.ws.onmessage,o=setTimeout(()=>{this.ws.onmessage=i,n(new Error("Publish timeout"))},15e3);this.ws.onmessage=async r=>{try{const s=JSON.parse(r.data),[a,l,c,u]=s;if("OK"===a&&l===e.id)if(c)clearTimeout(o),this.ws.onmessage=i,console.log("Event published successfully:",l),t({success:!0,eventId:l,reason:u});else{if(console.error("Event publish failed:",u),u&&u.includes("auth-required"))return void console.log("Authentication required, waiting for AUTH challenge...");clearTimeout(o),this.ws.onmessage=i,n(new Error(`Publish failed: ${u}`))}else if("AUTH"===a){this.challenge=s[1],console.log("Received AUTH challenge during publish:",this.challenge);try{await this.authenticate(),console.log("Authentication successful, retrying event publish...");const t=["EVENT",e];this.ws.send(JSON.stringify(t))}catch(e){clearTimeout(o),this.ws.onmessage=i,n(new Error(`Authentication failed: ${e.message}`))}}else await this.handleMessage(s)}catch(e){clearTimeout(o),this.ws.onmessage=i,n(e)}}})}close(){this.ws&&(this.ws.close(),this.ws=null),this.isAuthenticated=!1,this.challenge=null}getAuthenticated(){return this.isAuthenticated}}async function NI(e,t,n,r){const i=new TI(e,n,r);try{await i.connect();return await i.publishEvent(t)}finally{i.close()}}function LI(e,t,n){const r=e.slice();return r[170]=t[n],r}function OI(e,t,n){const r=e.slice();return r[180]=t[n],r}function MI(e,t,n){const r=e.slice();return r[173]=t[n],r}function _I(e,t,n){const r=e.slice();r[173]=t[n];const i=r[53](r[173]);return r[174]=i,r}function HI(e,t,n){const r=e.slice();return r[177]=t[n],r}function jI(t){let n;function r(e,t){return e[1]?rE:nE}let i=r(t),o=i(t);return{c(){n=g("div"),o.c(),k(n,"class","welcome-message svelte-u3u5mw")},m(e,t){f(e,n,t),o.m(n,null)},p(e,t){i===(i=r(e))&&o?o.p(e,t):(o.d(1),o=i(e),o&&(o.c(),o.m(n,null)))},i:e,o:e,d(e){e&&h(n),o.d()}}}function GI(e){let t,n,r=e[6],i=[];for(let t=0;tee(i[e],1,1,()=>{i[e]=null});return{c(){for(let e=0;e=0||""!==t[37]&&parseInt(t[37])>=0,$=Sh,P=[];for(let e=0;e<$.length;e+=1)P[e]=hE(HI(t,$,e));let U=R&&pE(t);return{c(){n=g("div"),i=g("div"),i.innerHTML='

    Event Recovery

    \n

    Search and recover old versions of replaceable events

    ',o=w(),s=g("div"),a=g("div"),l=g("div"),c=g("label"),c.textContent="Select Event Kind:",u=w(),m=g("select"),y=g("option"),y.textContent="Choose a replaceable kind...";for(let e=0;et[116].call(m)),k(l,"class","kind-selector svelte-u3u5mw"),k(E,"for","custom-kind"),k(E,"class","svelte-u3u5mw"),k(S,"id","custom-kind"),k(S,"type","number"),k(S,"placeholder","e.g., 10001"),k(S,"min","0"),k(S,"class","svelte-u3u5mw"),k(b,"class","custom-kind-input svelte-u3u5mw"),k(a,"class","recovery-controls svelte-u3u5mw"),k(s,"class","recovery-controls-card svelte-u3u5mw"),k(n,"class","recovery-tab svelte-u3u5mw")},m(e,r){f(e,n,r),d(n,i),d(n,o),d(n,s),d(s,a),d(a,l),d(l,c),d(l,u),d(l,m),d(m,y);for(let e=0;e=0||""!==e[37]&&parseInt(e[37])>=0),R?U?U.p(e,t):(U=pE(e),U.c(),U.m(n,null)):U&&(U.d(1),U=null)},i:e,o:e,d(e){e&&h(n),p(P,e),U&&U.d(),Q=!1,r(D)}}}function KI(e){let t,n;return t=new BI({props:{isLoggedIn:e[1],userRole:e[4],userSigner:e[13]}}),t.$on("openLoginModal",e[71]),{c(){ie(t.$$.fragment)},m(e,r){oe(t,e,r),n=!0},p(e,n){const r={};2&n[0]&&(r.isLoggedIn=e[1]),16&n[0]&&(r.userRole=e[4]),8192&n[0]&&(r.userSigner=e[13]),t.$set(r)},i(e){n||(X(t.$$.fragment,e),n=!0)},o(e){ee(t.$$.fragment,e),n=!1},d(e){se(t,e)}}}function JI(e){let t,n,r;function i(t){e[115](t)}let o={isLoggedIn:e[1],userRole:e[4],isPolicyAdmin:LE,policyEnabled:e[8],isLoadingPolicy:e[28],policyMessage:e[29],policyMessageType:e[30],validationErrors:e[31],policyFollows:e[32]};return void 0!==e[27]&&(o.policyJson=e[27]),t=new fw({props:o}),L.push(()=>re(t,"policyJson",i)),t.$on("loadPolicy",e[61]),t.$on("validatePolicy",e[62]),t.$on("savePolicy",e[63]),t.$on("formatJson",e[64]),t.$on("addPolicyAdmin",e[65]),t.$on("removePolicyAdmin",e[66]),t.$on("refreshFollows",e[67]),t.$on("openLoginModal",e[71]),{c(){ie(t.$$.fragment)},m(e,n){oe(t,e,n),r=!0},p(e,r){const i={};2&r[0]&&(i.isLoggedIn=e[1]),16&r[0]&&(i.userRole=e[4]),256&r[0]&&(i.policyEnabled=e[8]),268435456&r[0]&&(i.isLoadingPolicy=e[28]),536870912&r[0]&&(i.policyMessage=e[29]),1073741824&r[0]&&(i.policyMessageType=e[30]),1&r[1]&&(i.validationErrors=e[31]),2&r[1]&&(i.policyFollows=e[32]),!n&&134217728&r[0]&&(n=!0,i.policyJson=e[27],G(()=>n=!1)),t.$set(i)},i(e){r||(X(t.$$.fragment,e),r=!0)},o(e){ee(t.$$.fragment,e),r=!1},d(e){se(t,e)}}}function VI(e){let t,n,r;function i(t){e[112](t)}let o={isLoggedIn:e[1],userRole:e[4],sprocketStatus:e[21],isLoadingSprocket:e[23],sprocketUploadFile:e[26],sprocketMessage:e[24],sprocketMessageType:e[25],sprocketVersions:e[22]};return void 0!==e[20]&&(o.sprocketScript=e[20]),t=new Jy({props:o}),L.push(()=>re(t,"sprocketScript",i)),t.$on("restartSprocket",e[56]),t.$on("deleteSprocket",e[57]),t.$on("sprocketFileSelect",e[68]),t.$on("uploadSprocketScript",e[69]),t.$on("saveSprocket",e[55]),t.$on("loadSprocket",e[54]),t.$on("loadVersions",e[58]),t.$on("loadVersion",e[113]),t.$on("deleteVersion",e[114]),t.$on("openLoginModal",e[71]),{c(){ie(t.$$.fragment)},m(e,n){oe(t,e,n),r=!0},p(e,r){const i={};2&r[0]&&(i.isLoggedIn=e[1]),16&r[0]&&(i.userRole=e[4]),2097152&r[0]&&(i.sprocketStatus=e[21]),8388608&r[0]&&(i.isLoadingSprocket=e[23]),67108864&r[0]&&(i.sprocketUploadFile=e[26]),16777216&r[0]&&(i.sprocketMessage=e[24]),33554432&r[0]&&(i.sprocketMessageType=e[25]),4194304&r[0]&&(i.sprocketVersions=e[22]),!n&&1048576&r[0]&&(n=!0,i.sprocketScript=e[20],G(()=>n=!1)),t.$set(i)},i(e){r||(X(t.$$.fragment,e),r=!0)},o(e){ee(t.$$.fragment,e),r=!1},d(e){se(t,e)}}}function YI(e){let t,n,r,i;const o=[CE,EE,IE],s=[];function a(e,t){return"managed"!==e[9]?0:e[1]&&"owner"===e[4]?1:2}return n=a(e),r=s[n]=o[n](e),{c(){t=g("div"),r.c(),k(t,"class","managed-acl-view svelte-u3u5mw")},m(e,r){f(e,t,r),s[n].m(t,null),i=!0},p(e,i){let l=n;n=a(e),n===l?s[n].p(e,i):(W(),ee(s[l],1,1,()=>{s[l]=null}),Z(),r=s[n],r?r.p(e,i):(r=s[n]=o[n](e),r.c()),X(r,1),r.m(t,null))},i(e){i||(X(r),i=!0)},o(e){ee(r),i=!1},d(e){e&&h(t),s[n].d()}}}function zI(e){let t,n,r;function i(t){e[111](t)}let o={userPubkey:e[2],userRole:e[4],policyEnabled:e[8],publishError:e[35]};return void 0!==e[34]&&(o.composeEventJson=e[34]),t=new Uy({props:o}),L.push(()=>re(t,"composeEventJson",i)),t.$on("reformatJson",e[91]),t.$on("signEvent",e[92]),t.$on("publishEvent",e[93]),t.$on("clearError",e[94]),{c(){ie(t.$$.fragment)},m(e,n){oe(t,e,n),r=!0},p(e,r){const i={};4&r[0]&&(i.userPubkey=e[2]),16&r[0]&&(i.userRole=e[4]),256&r[0]&&(i.policyEnabled=e[8]),16&r[1]&&(i.publishError=e[35]),!n&&8&r[1]&&(n=!0,i.composeEventJson=e[34],G(()=>n=!1)),t.$set(i)},i(e){r||(X(t.$$.fragment,e),r=!0)},o(e){ee(t.$$.fragment,e),r=!1},d(e){se(t,e)}}}function WI(e){let t,n;return t=new aI({props:{isLoggedIn:e[1],userPubkey:e[2],userSigner:e[13],userPrivkey:e[14],currentEffectiveRole:e[10]}}),t.$on("openLoginModal",e[71]),{c(){ie(t.$$.fragment)},m(e,r){oe(t,e,r),n=!0},p(e,n){const r={};2&n[0]&&(r.isLoggedIn=e[1]),4&n[0]&&(r.userPubkey=e[2]),8192&n[0]&&(r.userSigner=e[13]),16384&n[0]&&(r.userPrivkey=e[14]),1024&n[0]&&(r.currentEffectiveRole=e[10]),t.$set(r)},i(e){n||(X(t.$$.fragment,e),n=!0)},o(e){ee(t.$$.fragment,e),n=!1},d(e){se(t,e)}}}function ZI(e){let t,n;return t=new sv({props:{isLoggedIn:e[1],userPubkey:e[2],userSigner:e[13],currentEffectiveRole:e[10]}}),t.$on("openLoginModal",e[71]),{c(){ie(t.$$.fragment)},m(e,r){oe(t,e,r),n=!0},p(e,n){const r={};2&n[0]&&(r.isLoggedIn=e[1]),4&n[0]&&(r.userPubkey=e[2]),8192&n[0]&&(r.userSigner=e[13]),1024&n[0]&&(r.currentEffectiveRole=e[10]),t.$set(r)},i(e){n||(X(t.$$.fragment,e),n=!0)},o(e){ee(t.$$.fragment,e),n=!1},d(e){se(t,e)}}}function XI(e){let t,n;return t=new gy({props:{isLoggedIn:e[1],userRole:e[4],userPubkey:e[2],filteredEvents:e[42],expandedEvents:e[19],isLoadingEvents:e[7],showOnlyMyEvents:NE,showFilterBuilder:e[16]}}),t.$on("scroll",e[90]),t.$on("toggleEventExpansion",e[107]),t.$on("deleteEvent",e[108]),t.$on("copyEventToClipboard",e[109]),t.$on("toggleChange",e[46]),t.$on("loadAllEvents",e[110]),t.$on("toggleFilterBuilder",e[77]),t.$on("filterApply",e[78]),t.$on("filterClear",e[79]),{c(){ie(t.$$.fragment)},m(e,r){oe(t,e,r),n=!0},p(e,n){const r={};2&n[0]&&(r.isLoggedIn=e[1]),16&n[0]&&(r.userRole=e[4]),4&n[0]&&(r.userPubkey=e[2]),2048&n[1]&&(r.filteredEvents=e[42]),524288&n[0]&&(r.expandedEvents=e[19]),128&n[0]&&(r.isLoadingEvents=e[7]),65536&n[0]&&(r.showFilterBuilder=e[16]),t.$set(r)},i(e){n||(X(t.$$.fragment,e),n=!0)},o(e){ee(t.$$.fragment,e),n=!1},d(e){se(t,e)}}}function eE(e){let t,n;return t=new gm({props:{isLoggedIn:e[1],currentEffectiveRole:e[10],selectedFile:e[17],aclMode:e[9],importMessage:e[18]}}),t.$on("fileSelect",e[87]),t.$on("importEvents",e[88]),t.$on("openLoginModal",e[71]),{c(){ie(t.$$.fragment)},m(e,r){oe(t,e,r),n=!0},p(e,n){const r={};2&n[0]&&(r.isLoggedIn=e[1]),1024&n[0]&&(r.currentEffectiveRole=e[10]),131072&n[0]&&(r.selectedFile=e[17]),512&n[0]&&(r.aclMode=e[9]),262144&n[0]&&(r.importMessage=e[18]),t.$set(r)},i(e){n||(X(t.$$.fragment,e),n=!0)},o(e){ee(t.$$.fragment,e),n=!1},d(e){se(t,e)}}}function tE(e){let t,n;return t=new lm({props:{isLoggedIn:e[1],currentEffectiveRole:e[10],aclMode:e[9]}}),t.$on("exportMyEvents",e[86]),t.$on("exportAllEvents",e[85]),t.$on("openLoginModal",e[71]),{c(){ie(t.$$.fragment)},m(e,r){oe(t,e,r),n=!0},p(e,n){const r={};2&n[0]&&(r.isLoggedIn=e[1]),1024&n[0]&&(r.currentEffectiveRole=e[10]),512&n[0]&&(r.aclMode=e[9]),t.$set(r)},i(e){n||(X(t.$$.fragment,e),n=!0)},o(e){ee(t.$$.fragment,e),n=!1},d(e){se(t,e)}}}function nE(t){let n;return{c(){n=g("p"),n.textContent="Log in to access your user dashboard",k(n,"class","svelte-u3u5mw")},m(e,t){f(e,n,t)},p:e,d(e){e&&h(n)}}}function rE(e){let t,n,r,i=(e[3]?.name||e[2].slice(0,8)+"...")+"";return{c(){t=g("p"),n=y("Welcome "),r=y(i),k(t,"class","svelte-u3u5mw")},m(e,i){f(e,t,i),d(t,n),d(t,r)},p(e,t){12&t[0]&&i!==(i=(e[3]?.name||e[2].slice(0,8)+"...")+"")&&E(r,i)},d(e){e&&h(t)}}}function iE(e){let t,n,i,o,s,a,l,c,u,p,m,v,b,I,C,x,B,S,F,Q,D,R=e[180].label+"",$=e[43].get(e[180].id)?.isLoading,P=!e[43].get(e[180].id)?.hasMore&&e[43].get(e[180].id)?.events?.length>0;function U(){return e[121](e[180])}function T(e,t){return 64&t[0]&&(I=null),64&t[0]&&(C=null),null==I&&(I=!!(e[43].get(e[180].id)?.events?.length>0)),I?sE:(null==C&&(C=!e[43].get(e[180].id)?.isLoading),C?oE:void 0)}m=new DI({props:{filter:e[43].get(e[180].id)?.filter||{}}}),m.$on("sweep",function(){return e[122](e[180])});let N=T(e,[-1,-1,-1,-1,-1,-1]),L=N&&N(e),O=$&&uE(),M=P&&dE();function _(...t){return e[127](e[180],...t)}return{c(){t=g("div"),n=g("div"),i=g("h2"),o=y("🔍 "),s=y(R),a=w(),l=g("button"),c=y("🔄 Refresh"),p=w(),ie(m.$$.fragment),v=w(),b=g("div"),L&&L.c(),x=w(),O&&O.c(),B=w(),M&&M.c(),S=w(),k(i,"class","svelte-u3u5mw"),k(l,"class","refresh-btn svelte-u3u5mw"),l.disabled=u=e[43].get(e[180].id)?.isLoading,k(n,"class","search-results-header svelte-u3u5mw"),k(b,"class","search-results-content svelte-u3u5mw"),k(t,"class","search-results-view svelte-u3u5mw")},m(e,r){f(e,t,r),d(t,n),d(n,i),d(i,o),d(i,s),d(n,a),d(n,l),d(l,c),d(t,p),oe(m,t,null),d(t,v),d(t,b),L&&L.m(b,null),d(b,x),O&&O.m(b,null),d(b,B),M&&M.m(b,null),d(t,S),F=!0,Q||(D=[A(l,"click",U),A(b,"scroll",_)],Q=!0)},p(t,n){e=t,(!F||64&n[0])&&R!==(R=e[180].label+"")&&E(s,R),(!F||64&n[0]&&u!==(u=e[43].get(e[180].id)?.isLoading))&&(l.disabled=u);const r={};64&n[0]&&(r.filter=e[43].get(e[180].id)?.filter||{}),m.$set(r),N===(N=T(e,n))&&L?L.p(e,n):(L&&L.d(1),L=N&&N(e),L&&(L.c(),L.m(b,x))),64&n[0]&&($=e[43].get(e[180].id)?.isLoading),$?O||(O=uE(),O.c(),O.m(b,B)):O&&(O.d(1),O=null),64&n[0]&&(P=!e[43].get(e[180].id)?.hasMore&&e[43].get(e[180].id)?.events?.length>0),P?M||(M=dE(),M.c(),M.m(b,null)):M&&(M.d(1),M=null)},i(e){F||(X(m.$$.fragment,e),F=!0)},o(e){ee(m.$$.fragment,e),F=!1},d(e){e&&h(t),se(m),L&&L.d(),O&&O.d(),M&&M.d(),Q=!1,r(D)}}}function oE(t){let n;return{c(){n=g("div"),n.innerHTML='

    No search results found.

    ',k(n,"class","no-search-results svelte-u3u5mw")},m(e,t){f(e,n,t)},p:e,d(e){e&&h(n)}}}function sE(e){let t,n=e[43].get(e[180].id).events,r=[];for(let t=0;t👤',o=w(),s=g("div"),a=g("div"),l=y(L),c=w(),u=g("div"),p=g("span"),m=y(O),v=w(),b=g("span"),I=y(M),C=w(),x=g("div"),B=g("div"),S=y(_),Q=w(),D=g("div"),R=y(H),$=w(),G&&G.c(),P=w(),J&&J.c(),U=w(),k(i,"class","search-result-avatar svelte-u3u5mw"),k(a,"class","search-result-author svelte-u3u5mw"),k(p,"class","kind-number svelte-u3u5mw"),k(b,"class","kind-name svelte-u3u5mw"),k(u,"class","search-result-kind svelte-u3u5mw"),k(s,"class","search-result-info svelte-u3u5mw"),k(B,"class","event-timestamp svelte-u3u5mw"),k(D,"class","event-content-single-line svelte-u3u5mw"),k(x,"class","search-result-content svelte-u3u5mw"),k(n,"class","search-result-row svelte-u3u5mw"),k(n,"role","button"),k(n,"tabindex","0"),k(t,"class","search-result-item svelte-u3u5mw"),F(t,"expanded",e[19].has(e[173].id))},m(e,r){f(e,t,r),d(t,n),d(n,i),d(n,o),d(n,s),d(s,a),d(a,l),d(s,c),d(s,u),d(u,p),d(p,m),d(u,v),d(u,b),d(b,I),d(n,C),d(n,x),d(x,B),d(B,S),d(x,Q),d(x,D),d(D,R),d(n,$),G&&G.m(n,null),d(t,P),J&&J.m(t,null),d(t,U),T||(N=[A(n,"click",q),A(n,"keydown",K)],T=!0)},p(r,i){e=r,64&i[0]&&L!==(L=$I(e[173].pubkey)+"")&&E(l,L),64&i[0]&&O!==(O=e[173].kind+"")&&E(m,O),64&i[0]&&M!==(M=RI(e[173].kind)+"")&&E(I,M),64&i[0]&&_!==(_=UI(e[173].created_at)+"")&&E(S,_),64&i[0]&&H!==(H=PI(e[173].content)+"")&&E(R,H),5!==e[173].kind&&("admin"===e[4]||"owner"===e[4]||"write"===e[4]&&e[173].pubkey&&e[173].pubkey===e[2])?G?G.p(e,i):(G=aE(e),G.c(),G.m(n,null)):G&&(G.d(1),G=null),524352&i[0]&&(j=e[19].has(e[173].id)),j?J?J.p(e,i):(J=lE(e),J.c(),J.m(t,U)):J&&(J.d(1),J=null),524352&i[0]|4096&i[1]&&F(t,"expanded",e[19].has(e[173].id))},d(e){e&&h(t),G&&G.d(),J&&J.d(),T=!1,r(N)}}}function uE(e){let t;return{c(){t=g("div"),t.innerHTML='
    \n

    Searching...

    ',k(t,"class","loading-search-results svelte-u3u5mw")},m(e,n){f(e,t,n)},d(e){e&&h(t)}}}function dE(e){let t;return{c(){t=g("div"),t.innerHTML='

    No more search results to load.

    ',k(t,"class","end-of-search-results svelte-u3u5mw")},m(e,n){f(e,t,n)},d(e){e&&h(t)}}}function fE(e){let t,n,r=e[180].id===e[5]&&iE(e);return{c(){r&&r.c(),t=v()},m(e,i){r&&r.m(e,i),f(e,t,i),n=!0},p(e,n){e[180].id===e[5]?r?(r.p(e,n),96&n[0]&&X(r,1)):(r=iE(e),r.c(),X(r,1),r.m(t.parentNode,t)):r&&(W(),ee(r,1,1,()=>{r=null}),Z())},i(e){n||(X(r),n=!0)},o(e){ee(r),n=!1},d(e){r&&r.d(e),e&&h(t)}}}function hE(t){let n,r,i=t[177].label+"";return{c(){n=g("option"),r=y(i),n.__value=t[177].value,n.value=n.__value},m(e,t){f(e,n,t),d(n,r)},p:e,d(e){e&&h(n)}}}function pE(e){let t;function n(e,t){return e[39]?yE:0===e[38].length?mE:gE}let r=n(e),i=r(e);return{c(){t=g("div"),i.c(),k(t,"class","recovery-results svelte-u3u5mw")},m(e,n){f(e,t,n),i.m(t,null)},p(e,o){r===(r=n(e))&&i?i.p(e,o):(i.d(1),i=r(e),i&&(i.c(),i.m(t,null)))},d(e){e&&h(t),i.d()}}}function gE(e){let t,n,r,i=e[38],o=[];for(let t=0;tORLY_ACL_MODE=managed in your\n environment variables and restart the relay.',k(r,"class","svelte-u3u5mw"),k(o,"class","svelte-u3u5mw"),k(a,"class","svelte-u3u5mw"),k(m,"class","svelte-u3u5mw"),k(n,"class","acl-mode-warning svelte-u3u5mw")},m(e,t){f(e,n,t),d(n,r),d(n,i),d(n,o),d(n,s),d(n,a),d(a,l),d(a,c),d(c,u),d(n,p),d(n,m)},p(e,t){512&t[0]&&v!==(v=(e[9]||"unknown")+"")&&E(u,v)},i:e,o:e,d(e){e&&h(n)}}}function xE(e){let t,n,i,o,s,a,l,c,u,p;function m(e,t){return e[3]?SE:e[1]&&e[2]?BE:void 0}let y=m(e),v=y&&y(e);return{c(){t=g("div"),n=g("div"),i=g("div"),o=g("h2"),o.textContent="Settings",s=w(),a=g("button"),a.textContent="✕",l=w(),c=g("div"),v&&v.c(),k(o,"class","svelte-u3u5mw"),k(a,"class","close-btn svelte-u3u5mw"),k(i,"class","drawer-header svelte-u3u5mw"),k(c,"class","drawer-content"),k(n,"class","settings-drawer svelte-u3u5mw"),F(n,"dark-theme",e[0]),k(t,"class","drawer-overlay svelte-u3u5mw"),k(t,"role","button"),k(t,"tabindex","0")},m(r,h){f(r,t,h),d(t,n),d(n,i),d(i,o),d(i,s),d(i,a),d(n,l),d(n,c),v&&v.m(c,null),u||(p=[A(a,"click",e[76]),A(n,"click",b(e[102])),A(n,"keydown",b(e[103])),A(t,"click",e[76]),A(t,"keydown",e[129])],u=!0)},p(e,t){y===(y=m(e))&&v?v.p(e,t):(v&&v.d(1),v=y&&y(e),v&&(v.c(),v.m(c,null))),1&t[0]&&F(n,"dark-theme",e[0])},d(e){e&&h(t),v&&v.d(),u=!1,r(p)}}}function BE(e){let t,n,i,o,s,a,l,c,u,p,m,v,b,I,C,x,B,S=e[2].slice(0,16)+"",F=e[2].slice(-8)+"";return{c(){t=g("div"),n=g("button"),n.textContent="Log out",i=w(),o=g("h3"),o.textContent="Profile Loading",s=w(),a=g("p"),a.textContent="Your profile metadata is being loaded...",l=w(),c=g("button"),c.textContent="Retry Loading Profile",u=w(),p=g("div"),m=g("strong"),m.textContent="Public Key:",v=w(),b=y(S),I=y("..."),C=y(F),k(n,"class","logout-btn floating svelte-u3u5mw"),k(o,"class","svelte-u3u5mw"),k(a,"class","svelte-u3u5mw"),k(c,"class","retry-profile-btn svelte-u3u5mw"),k(p,"class","user-pubkey-display svelte-u3u5mw"),k(t,"class","profile-loading-section svelte-u3u5mw")},m(r,h){f(r,t,h),d(t,n),d(t,i),d(t,o),d(t,s),d(t,a),d(t,l),d(t,c),d(t,u),d(t,p),d(p,m),d(p,v),d(p,b),d(p,I),d(p,C),x||(B=[A(n,"click",e[73]),A(c,"click",e[84])],x=!0)},p(e,t){4&t[0]&&S!==(S=e[2].slice(0,16)+"")&&E(b,S),4&t[0]&&F!==(F=e[2].slice(-8)+"")&&E(C,F)},d(e){e&&h(t),x=!1,r(B)}}}function SE(e){let t,n,r,i,o,s,a,l,c,u,p,m,b,I,C,x=(e[3].name||"Unknown User")+"",B=e[3].banner&&FE(e);function S(e,t){return e[3].picture?DE:QE}let F=S(e),Q=F(e),D=e[3].nip05&&RE(e),R=e[3].about&&$E(e),$=e[4]&&"read"!==e[4]&&PE(e);return{c(){t=g("div"),n=g("div"),B&&B.c(),r=w(),i=g("button"),i.textContent="Log out",o=w(),Q.c(),s=w(),a=g("div"),l=g("h3"),c=y(x),u=w(),D&&D.c(),p=w(),R&&R.c(),m=w(),$&&$.c(),b=v(),k(i,"class","logout-btn floating svelte-u3u5mw"),k(l,"class","profile-username svelte-u3u5mw"),k(a,"class","name-row svelte-u3u5mw"),k(n,"class","profile-hero svelte-u3u5mw"),k(t,"class","profile-section svelte-u3u5mw")},m(h,g){f(h,t,g),d(t,n),B&&B.m(n,null),d(n,r),d(n,i),d(n,o),Q.m(n,null),d(n,s),d(n,a),d(a,l),d(l,c),d(a,u),D&&D.m(a,null),d(t,p),R&&R.m(t,null),f(h,m,g),$&&$.m(h,g),f(h,b,g),I||(C=A(i,"click",e[73]),I=!0)},p(e,i){e[3].banner?B?B.p(e,i):(B=FE(e),B.c(),B.m(n,r)):B&&(B.d(1),B=null),F===(F=S(e))&&Q?Q.p(e,i):(Q.d(1),Q=F(e),Q&&(Q.c(),Q.m(n,s))),8&i[0]&&x!==(x=(e[3].name||"Unknown User")+"")&&E(c,x),e[3].nip05?D?D.p(e,i):(D=RE(e),D.c(),D.m(a,null)):D&&(D.d(1),D=null),e[3].about?R?R.p(e,i):(R=$E(e),R.c(),R.m(t,null)):R&&(R.d(1),R=null),e[4]&&"read"!==e[4]?$?$.p(e,i):($=PE(e),$.c(),$.m(b.parentNode,b)):$&&($.d(1),$=null)},d(e){e&&h(t),B&&B.d(),Q.d(),D&&D.d(),R&&R.d(),e&&h(m),$&&$.d(e),e&&h(b),I=!1,C()}}}function FE(e){let t,n;return{c(){t=g("img"),a(t.src,n=e[3].banner)||k(t,"src",n),k(t,"alt","Profile banner"),k(t,"class","profile-banner svelte-u3u5mw")},m(e,n){f(e,t,n)},p(e,r){8&r[0]&&!a(t.src,n=e[3].banner)&&k(t,"src",n)},d(e){e&&h(t)}}}function QE(t){let n;return{c(){n=g("div"),n.textContent="👤",k(n,"class","profile-avatar-placeholder overlap svelte-u3u5mw")},m(e,t){f(e,n,t)},p:e,d(e){e&&h(n)}}}function DE(e){let t,n;return{c(){t=g("img"),a(t.src,n=e[3].picture)||k(t,"src",n),k(t,"alt","User avatar"),k(t,"class","profile-avatar overlap svelte-u3u5mw")},m(e,n){f(e,t,n)},p(e,r){8&r[0]&&!a(t.src,n=e[3].picture)&&k(t,"src",n)},d(e){e&&h(t)}}}function RE(e){let t,n,r=e[3].nip05+"";return{c(){t=g("span"),n=y(r),k(t,"class","profile-nip05-inline svelte-u3u5mw")},m(e,r){f(e,t,r),d(t,n)},p(e,t){8&t[0]&&r!==(r=e[3].nip05+"")&&E(n,r)},d(e){e&&h(t)}}}function $E(e){let t,n;return{c(){t=g("div"),n=g("p"),k(n,"class","profile-about svelte-u3u5mw"),k(t,"class","about-card svelte-u3u5mw")},m(r,i){f(r,t,i),d(t,n),n.innerHTML=e[41]},p(e,t){1024&t[1]&&(n.innerHTML=e[41])},d(e){e&&h(t)}}}function PE(e){let t,n,r,i,o,s,a=e[96](),l=[];for(let t=0;tre(m,"showModal",C)),m.$on("login",e[72]),m.$on("close",e[74]),{c(){ie(t.$$.fragment),n=w(),r=g("div"),ie(i.$$.fragment),o=w(),s=g("main"),c.c(),u=w(),E&&E.c(),p=w(),ie(m.$$.fragment),k(s,"class","main-content svelte-u3u5mw"),k(r,"class","app-container svelte-u3u5mw"),F(r,"dark-theme",e[0])},m(e,a){oe(t,e,a),f(e,n,a),f(e,r,a),oe(i,r,null),d(r,o),d(r,s),b[l].m(s,null),f(e,u,a),E&&E.m(e,a),f(e,p,a),oe(m,e,a),v=!0},p(e,n){const o={};1&n[0]&&(o.isDarkTheme=e[0]),2&n[0]&&(o.isLoggedIn=e[1]),16&n[0]&&(o.userRole=e[4]),1024&n[0]&&(o.currentEffectiveRole=e[10]),8&n[0]&&(o.userProfile=e[3]),4&n[0]&&(o.userPubkey=e[2]),t.$set(o);const a={};1&n[0]&&(a.isDarkTheme=e[0]),2048&n[0]&&(a.tabs=e[11]),32&n[0]&&(a.selectedTab=e[5]),4&n[1]&&(a.version=e[33]),i.$set(a);let u=l;l=I(e,n),l===u?b[l].p(e,n):(W(),ee(b[u],1,1,()=>{b[u]=null}),Z(),c=b[l],c?c.p(e,n):(c=b[l]=A[l](e),c.c()),X(c,1),c.m(s,null)),(!v||1&n[0])&&F(r,"dark-theme",e[0]),e[15]?E?E.p(e,n):(E=xE(e),E.c(),E.m(p.parentNode,p)):E&&(E.d(1),E=null);const d={};1&n[0]&&(d.isDarkTheme=e[0]),!y&&4096&n[0]&&(y=!0,d.showModal=e[12],G(()=>y=!1)),m.$set(d)},i(e){v||(X(t.$$.fragment,e),X(i.$$.fragment,e),X(c),X(m.$$.fragment,e),v=!0)},o(e){ee(t.$$.fragment,e),ee(i.$$.fragment,e),ee(c),ee(m.$$.fragment,e),v=!1},d(e){se(t,e),e&&h(n),e&&h(r),se(i),b[l].d(),e&&h(u),E&&E.d(e),e&&h(p),se(m,e)}}}let NE=!1,LE=!1;function OE(e,t,n){let r,i,o,s,a;"undefined"!=typeof window&&(window.debugIndexedDB=Vh);let l=!1,c=!1,u=!1,d="",f="",h=null,p="",g=null,m=null,y=!1,w=localStorage.getItem("selectedTab")||"export",v=!1,A={},b=[],k=[],E=null,C="",x=new Set,B=!1,F=!0,Q=null,D="",R=new Map,$=[],P=0,U=[],N=!0,L=null,O="",M=null,_=[],H=!1,j="",G="info",q=!1,K=null,J="",V=!1,Y=!1,z="",W="info",Z=[],X=[],ee="",te="",ne="",re="",ie=null,oe="",se=[],ae=!1,le=!0,ce=null;function ue(e){x.has(e)?x.delete(e):x.add(e),n(19,x)}async function de(e,t){const n=JSON.stringify(e),r=await async function(e){try{return await navigator.clipboard.writeText(e),!0}catch(t){console.error("Failed to copy to clipboard:",t);try{const t=document.createElement("textarea");return t.value=e,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t),!0}catch(e){return console.error("Fallback copy also failed:",e),!1}}}(n);!function(e,t=!0){if(!e)return;const n=e.textContent,r=e.style.backgroundColor;t?(e.textContent="",e.style.backgroundColor="#4CAF50"):(e.textContent="L",e.style.backgroundColor="#f44336"),setTimeout(()=>{e.textContent=n,e.style.backgroundColor=r},2e3)}(t.target.closest(".copy-json-btn"),r),r||alert("Failed to copy to clipboard. Please copy manually.")}async function fe(e){if(!u)return void alert("Please log in first");const t=k.find(t=>t.id===e);if(!t)return void alert("Event not found");if("admin"===p||"owner"===p||"write"===p&&t.pubkey&&t.pubkey===d){if(confirm("Are you sure you want to delete this event?"))try{if(!g)throw new Error("Signer not available for signing");const r={kind:5,created_at:Math.floor(Date.now()/1e3),tags:[["e",e]],content:""};console.log("Created delete event template:",r),console.log("User pubkey:",d),console.log("Target event:",t),console.log("Target event pubkey:",t.pubkey);const i=await g.signEvent(r);console.log("Signed delete event:",i),console.log("Signed delete event pubkey:",i.pubkey),console.log("Delete event tags:",i.tags);const o=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`;try{const e=await NI(o,i,g,d);e.success?console.log("Delete event published successfully to ORLY relay"):console.error("Failed to publish delete event:",e.reason)}catch(e){console.error("Error publishing delete event:",e)}const s=t.pubkey&&t.pubkey===d;if(s){const t=await Rh.publish(i);if(console.log("Delete event published:",t),!(t.success&&t.okCount>0))throw new Error("No relays accepted the delete event");{await new Promise(e=>setTimeout(e,2e3));try{const n=await Gh(e,{timeout:5e3});n?(console.warn("Event still exists after deletion attempt:",n),alert(`Warning: Delete event was accepted by ${t.okCount} relay(s), but the event still exists on the relay. This may indicate the relay does not properly handle delete events.`)):console.log("Event successfully deleted and verified")}catch(e){console.log("Could not fetch event after deletion (likely deleted):",e.message)}try{const t=await qh(e,{timeout:5e3});if(t.length>0){console.log(`Delete event verification: Found ${t.length} delete event(s) targeting ${e}`);const n=t.find(e=>e.pubkey&&e.pubkey===d);n?console.log("Our delete event found in database:",n.id):console.warn("Our delete event not found in database, but other delete events exist")}else console.warn("No delete events found in database for target event:",e)}catch(e){console.log("Could not verify delete event in database:",e.message)}n(97,k=k.filter(t=>t.id!==e)),U=U.filter(t=>t.id!==e),$=$.filter(t=>t.id!==e);for(const[t,n]of R)n.events&&(n.events=n.events.filter(t=>t.id!==e),R.set(t,n));me(),console.log("Reloading events to show delete event...");const r=NE&&u&&d?[d]:null;await Te(!0,r),alert(`Event deleted successfully (accepted by ${t.okCount} relay(s))`)}}else{const t=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`,r=new Dh;await r.connectToRelay(t);const o=await r.publish(i);if(console.log("Delete event published to local relay only:",o),!(o.success&&o.okCount>0))throw new Error("Local relay did not accept the delete event");{await new Promise(e=>setTimeout(e,2e3));try{const t=await Gh(e,{timeout:5e3});t?(console.warn("Event still exists after deletion attempt:",t),alert(`Warning: Delete event was accepted by ${o.okCount} relay(s), but the event still exists on the relay. This may indicate the relay does not properly handle delete events.`)):console.log("Event successfully deleted and verified")}catch(e){console.log("Could not fetch event after deletion (likely deleted):",e.message)}try{const t=await qh(e,{timeout:5e3});if(t.length>0){console.log(`Delete event verification: Found ${t.length} delete event(s) targeting ${e}`);const n=t.find(e=>e.pubkey&&e.pubkey===d);n?console.log("Our delete event found in database:",n.id):console.warn("Our delete event not found in database, but other delete events exist")}else console.warn("No delete events found in database for target event:",e)}catch(e){console.log("Could not verify delete event in database:",e.message)}n(97,k=k.filter(t=>t.id!==e)),U=U.filter(t=>t.id!==e),$=$.filter(t=>t.id!==e);for(const[t,n]of R)n.events&&(n.events=n.events.filter(t=>t.id!==e),R.set(t,n));me(),console.log("Reloading events to show delete event...");const t=NE&&u&&d?[d]:null;await Te(!0,t),alert("Event deleted successfully (local relay only - admin/owner deleting other user's event)")}}}catch(e){console.error("Failed to delete event:",e),alert("Failed to delete event: "+e.message)}}else alert("You do not have permission to delete this event")}async function he(){const e=oe?parseInt(oe):ie;if(null==e||isNaN(e))console.log("No valid kind to load, kindToUse:",e);else if(u){console.log("Loading recovery events for kind:",e,"user:",d),n(39,ae=!0);try{const t=[{kinds:[e],authors:[d],limit:100}];ce&&(t[0].until=ce),console.log("Recovery filters:",t);const r=await Jh(t,{timeout:3e4,cacheFirst:!0});console.log("Recovery events received:",r.length),console.log("Recovery events kinds:",r.map(e=>e.kind)),n(38,se=ce?[...se,...r]:r),r.length>0?(ce=Math.min(...r.map(e=>e.created_at)),n(40,le=100===r.length)):n(40,le=!1)}catch(e){console.error("Failed to load recovery events:",e)}finally{n(39,ae=!1)}}else console.log("Not logged in, cannot load recovery events")}async function pe(e){if(confirm("Are you sure you want to repost this event?"))try{const t=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`;console.log("Reposting event to local relay:",t,e);const r={...e};if(r.created_at=Math.floor(Date.now()/1e3),r.id="",r.sig="",e.kind>=3e4&&e.kind<=39999){const t=e.tags.find(e=>"d"===e[0]);t&&(r.tags=r.tags.filter(e=>"d"!==e[0]),r.tags.push(t))}if(g){const e=await g.signEvent(r);console.log("Signed event for repost:",e);const i=await Rh.publish(e,[t]);console.log("Repost publish result:",i),i.success&&i.okCount>0?(alert("Event reposted successfully!"),n(40,le=!1),await he()):alert("Failed to repost event. Check console for details.")}else alert("No signer available. Please log in.")}catch(e){console.error("Error reposting event:",e),alert("Error reposting event: "+e.message)}}async function ge(e){if(confirm("Are you sure you want to repost this event to all your write relays?"))try{const t=await async function(){if(!d)return[];try{const e=await Oh([{kinds:[10002],authors:[d],limit:1}]);if(0===e.length)return console.log("No relay list event found for user"),[];const t=e[0];console.log("Found relay list event:",t);const n=[];for(const e of t.tags)if("r"===e[0]&&e.length>=2){const t=e[1],r=e.length>=3?e[2]:null;r&&"write"!==r||n.push(t)}return console.log("Found write relays:",n),n}catch(e){return console.error("Error fetching user write relays:",e),[]}}(),r=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`,i=[r,...t.filter(e=>e!==r)];1===i.length&&alert("No write relays found in your relay list. Only posting to local relay."),console.log("Reposting event to all relays:",i,e);const o={...e};if(o.created_at=Math.floor(Date.now()/1e3),o.id="",o.sig="",e.kind>=3e4&&e.kind<=39999){const t=e.tags.find(e=>"d"===e[0]);t&&(o.tags=o.tags.filter(e=>"d"!==e[0]),o.tags.push(t))}if(g){const e=await g.signEvent(o);console.log("Signed event for repost to all:",e);const t=await Rh.publish(e,i);console.log("Repost to all publish result:",t),t.success&&t.okCount>0?(alert(`Event reposted successfully to ${i.length} relays!`),n(40,le=!1),await he()):alert("Failed to repost event. Check console for details.")}else alert("No signer available. Please log in.")}catch(e){console.error("Error reposting event to all:",e),alert("Error reposting event to all: "+e.message)}}if("undefined"!=typeof window&&window.matchMedia){const e=window.matchMedia("(prefers-color-scheme: dark)");l=e.matches,e.addEventListener("change",e=>{n(0,l=e.matches)})}if("undefined"!=typeof localStorage){const e=localStorage.getItem("nostr_auth_method"),t=localStorage.getItem("nostr_pubkey");e&&t&&(u=!0,d=t,f=e,"extension"===e&&window.nostr&&(g=window.nostr),$e(),Pe()),function(){if("undefined"==typeof localStorage)return;try{const t=localStorage.getItem("app_state");if(t){const r=JSON.parse(t);r.selectedTab&&Ce.some(e=>e.id===r.selectedTab)&&n(5,w=r.selectedTab),r.expandedEvents&&n(19,x=new Set(r.expandedEvents)),r.globalEventsCache&&($=r.globalEventsCache),r.globalCacheTimestamp&&(P=r.globalCacheTimestamp),void 0!==r.hasMoreEvents&&(F=r.hasMoreEvents),r.oldestEventTimestamp&&(Q=r.oldestEventTimestamp),void 0!==r.hasMoreMyEvents&&(N=r.hasMoreMyEvents),r.oldestMyEventTimestamp&&(L=r.oldestMyEventTimestamp),$.length>0&&((e=P)&&Date.now()-et.created_at-e.created_at),P=Date.now(),me()}async function we(){if(u&&"owner"===p&&q)try{n(23,H=!0);const e=await fetch("/api/sprocket/status",{method:"GET",headers:{Authorization:`Nostr ${await Me("GET","/api/sprocket/status")}`,"Content-Type":"application/json"}});e.ok?n(21,M=await e.json()):ke("Failed to load sprocket status","error")}catch(e){ke(`Error loading sprocket status: ${e.message}`,"error")}finally{n(23,H=!1)}}async function ve(){if(u&&"owner"===p)try{n(23,H=!0);const e=await fetch("/api/sprocket/versions",{method:"GET",headers:{Authorization:`Nostr ${await Me("GET","/api/sprocket/versions")}`,"Content-Type":"application/json"}});e.ok?n(22,_=await e.json()):ke("Failed to load versions","error")}catch(e){ke(`Error loading versions: ${e.message}`,"error")}finally{n(23,H=!1)}}async function Ae(e){u&&"owner"===p&&(n(20,O=e.content),ke(`Loaded version: ${e.name}`,"success"))}async function be(e){if(u&&"owner"===p&&confirm(`Are you sure you want to delete version ${e}?`))try{n(23,H=!0);const t=await fetch("/api/sprocket/delete-version",{method:"POST",headers:{Authorization:`Nostr ${await Me("POST","/api/sprocket/delete-version")}`,"Content-Type":"application/json"},body:JSON.stringify({filename:e})});if(t.ok)ke(`Version ${e} deleted successfully`,"success"),await ve();else{ke(`Failed to delete version: ${await t.text()}`,"error")}}catch(e){ke(`Error deleting version: ${e.message}`,"error")}finally{n(23,H=!1)}}function ke(e,t="info"){n(24,j=e),n(25,G=t),setTimeout(()=>{n(24,j="")},5e3)}function Ie(e,t="info"){n(29,z=e),n(30,W=t),"error"!==t&&setTimeout(()=>{n(29,z="")},5e3)}async function Ee(){if(n(31,Z=[]),!J.trim())return n(31,Z=["Policy JSON is empty"]),Ie("Validation failed","error"),!1;try{const e=JSON.parse(J);if("object"!=typeof e||null===e)return n(31,Z=["Policy must be a JSON object"]),Ie("Validation failed","error"),!1;if(e.policy_admins)if(Array.isArray(e.policy_admins))for(const t of e.policy_admins)"string"==typeof t&&/^[0-9a-fA-F]{64}$/.test(t)||Z.push(`Invalid policy_admin pubkey: ${t}`);else Z.push("policy_admins must be an array");if(e.rules)if("object"!=typeof e.rules)Z.push("rules must be an object");else for(const[t,n]of Object.entries(e.rules))if(/^\d+$/.test(t)||Z.push(`Invalid kind number: ${t}`),n.tag_validation&&"object"==typeof n.tag_validation)for(const[e,t]of Object.entries(n.tag_validation))try{new RegExp(t)}catch(n){Z.push(`Invalid regex for tag '${e}': ${t}`)}return e.default_policy&&!["allow","deny"].includes(e.default_policy)&&Z.push("default_policy must be 'allow' or 'deny'"),Z.length>0?(Ie("Validation failed - see errors below","error"),!1):(Ie("Validation passed","success"),!0)}catch(e){return n(31,Z=[`JSON parse error: ${e.message}`]),Ie("Invalid JSON syntax","error"),!1}}const Ce=[{id:"export",icon:"📤",label:"Export"},{id:"import",icon:"💾",label:"Import",requiresAdmin:!0},{id:"events",icon:"📡",label:"Events"},{id:"blossom",icon:"🌸",label:"Blossom"},{id:"bunker",icon:"🔐",label:"Bunker",requiresWrite:!0},{id:"compose",icon:"✏️",label:"Compose",requiresWrite:!0},{id:"recovery",icon:"🔄",label:"Recovery"},{id:"managed-acl",icon:"🛡️",label:"Managed ACL",requiresOwner:!0},{id:"sprocket",icon:"⚙️",label:"Sprocket",requiresOwner:!0},{id:"policy",icon:"📜",label:"Policy",requiresOwner:!0},{id:"logs",icon:"📋",label:"Logs",requiresOwner:!0}];function xe(e){n(5,w=e),"sprocket"===e&&u&&"owner"===p&&q&&(we(),ve()),me()}function Be(){n(15,y=!1)}function Se(e){Fe(e)}function Fe(e){n(6,b=b.filter(t=>t.id!==e)),R.delete(e),w===e&&n(5,w="export")}async function Qe(e,t=!0){const n=R.get(e);if(n&&!n.isLoading){n.isLoading=!0,R.set(e,n);try{const r={...n.filter};!t&&n.oldestTimestamp&&(r.until=n.oldestTimestamp),t||(r.limit=200),console.log("Loading search results with filter:",r);const i=await jh([r],{timeout:3e4});if(console.log("Received search results:",i.length,"events"),n.events=t?i.sort((e,t)=>t.created_at-e.created_at):[...n.events,...i].sort((e,t)=>t.created_at-e.created_at),i.length>0){const e=Math.min(...i.map(e=>e.created_at));(!n.oldestTimestamp||e0){const e=o.filter(e=>e.pubkey&&e.pubkey!==d);e.length>0&&console.warn("Server returned non-user events:",e.length,"out of",o.length)}if(e?(n(97,k=o.sort((e,t)=>t.created_at-e.created_at)),ye(o)):(n(97,k=[...k,...o].sort((e,t)=>t.created_at-e.created_at)),ye(k)),o.length>0){const e=Math.min(...o.map(e=>e.created_at));(!Q||e{if("events"===w){const e=document.querySelectorAll(".events-view-content")[0];e&&e.scrollHeight<=e.clientHeight&&Ne()}},100)}catch(e){console.error("Failed to load events:",e),alert("Failed to load events: "+e.message)}finally{n(7,B=!1)}}}async function Ne(){await Te(!1)}let Le=!1;async function Oe(e,t){if(!u||!d)throw new Error("Not logged in");const n={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",window.location.origin+e],["method",t.toUpperCase()]],content:"",pubkey:d};let r;if(g&&"extension"===f)try{r=await g.signEvent(n)}catch(e){throw new Error("Failed to sign with extension: "+e.message)}else{if("nsec"!==f)throw new Error("No valid signer available");n.id="mock-id-"+Date.now(),n.sig="mock-signature-"+Date.now(),r=n}const i=JSON.stringify(r);return`Nostr ${btoa(i)}`}async function Me(e,t){if(!u||!d)throw new Error("Not logged in");const n={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",window.location.origin+t],["method",e.toUpperCase()]],content:"",pubkey:d};let r;if(g&&"extension"===f)try{r=await g.signEvent(n)}catch(e){throw new Error("Failed to sign with extension: "+e.message)}else{if("nsec"!==f)throw new Error("No valid signer available");n.id="mock-id-"+Date.now(),n.sig="mock-signature-"+Date.now(),r=n}const i=JSON.stringify(r);return btoa(i)}function _e(e,t){const n=e.toLowerCase();if(n.includes("policy")||n.includes("blocked")||n.includes("denied")){let n=`Policy Error: ${e}`;return null!==t&&(n+=`\n\nKind ${t} may be restricted by the relay's policy configuration.`),V&&(n+="\n\nThe relay has policy enforcement enabled. Contact a relay administrator to allow this event kind or adjust your permissions."),n}if(n.includes("auth")||n.includes("permission")||n.includes("unauthorized"))return`Permission Error: ${e}\n\nYour current permissions may not allow publishing this type of event. Current role: ${p||"unknown"}. Contact a relay administrator to upgrade your permissions.`;if(n.includes("kind")||n.includes("not allowed")||n.includes("restricted")){let n=`Event Type Error: ${e}`;return null!==t&&(n+=`\n\nKind ${t} is not currently allowed on this relay.`),n+="\n\nThe relay administrator may need to update the policy configuration to allow this event kind.",n}return n.includes("rate")||n.includes("limit")||n.includes("too many")?`Rate Limit Error: ${e}\n\nPlease wait a moment before trying again.`:n.includes("size")||n.includes("too large")||n.includes("content")?`Size Limit Error: ${e}\n\nThe event may exceed the relay's size limits. Try reducing the content length.`:`Publishing failed: ${e}`}function He(e){n(98,D=e),localStorage.setItem("viewAsRole",e),console.log("View as role changed to:",e,"Current effective role:",a)}D=localStorage.getItem("viewAsRole")||"";return e.$$.update=()=>{var t;if(6&e.$$.dirty[0]|16&e.$$.dirty[3]&&n(42,r=k.sort((e,t)=>t.created_at-e.created_at)),8&e.$$.dirty[0]&&n(41,i=h?.about?(t=h.about,t?t.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"):"").replace(/\n{2,}/g,"
    "):""),16&e.$$.dirty[0]|32&e.$$.dirty[3]&&n(10,a=D&&""!==D?D:p),1810&e.$$.dirty[0]|96&e.$$.dirty[3]&&n(101,o=Ce.filter(e=>{const t=a;return!(e.requiresAdmin&&(!u||"admin"!==t&&"owner"!==t))&&(!(e.requiresOwner&&(!u||"owner"!==t))&&(!(e.requiresWrite&&(!u||"read"===t))&&(!("sprocket"===e.id&&!q)&&(!("policy"===e.id&&!V)&&(("managed-acl"!==e.id||"managed"===ee)&&(console.log(`Tab ${e.id} filter check:`,{isLoggedIn:u,userRole:p,viewAsRole:D,currentRole:t,requiresAdmin:e.requiresAdmin,requiresOwner:e.requiresOwner,requiresWrite:e.requiresWrite,visible:!0}),!0))))))})),64&e.$$.dirty[0]|256&e.$$.dirty[3]&&n(11,s=[...o,...b]),2578&e.$$.dirty[0]|256&e.$$.dirty[3]&&console.log("Tabs debug:",{isLoggedIn:u,userRole:p,aclMode:ee,filteredBaseTabs:o.map(e=>e.id),allTabs:s.map(e=>e.id)}),1&e.$$.dirty[0]&&"undefined"!=typeof document&&(l?document.body.classList.add("dark-theme"):document.body.classList.remove("dark-theme")),14&e.$$.dirty[0]&&u&&d&&!h&&Re(),182&e.$$.dirty[0]|144&e.$$.dirty[3]&&"events"===w&&u&&("read"===p||"write"===p||"admin"===p||"owner"===p)&&0===k.length&&!Le&&!B){n(100,Le=!0);Te(!0,null)}32&e.$$.dirty[0]|16&e.$$.dirty[3]&&("events"!==w||"events"===w&&k.length>0)&&n(100,Le=!1),32&e.$$.dirty[0]&&localStorage.setItem("selectedTab",w)},[l,u,d,h,p,w,b,B,V,ee,a,s,c,g,m,y,v,E,C,x,O,M,_,H,j,G,K,J,Y,z,W,Z,X,te,ne,re,ie,oe,se,ae,le,i,r,R,ue,de,async function(){console.log("Toggle changed, showOnlyMyEvents:",NE),n(100,Le=!1),await Te(!0,null)},fe,he,pe,ge,function(){console.log("selectRecoveryKind called, recoverySelectedKind:",ie),null!=ie?(n(37,oe=""),n(38,se=[]),ce=null,n(40,le=!0),he()):console.log("No kind selected, skipping load")},function(){console.log("handleCustomKindInput called, recoveryCustomKind:",oe);const e=parseInt(oe);""!==oe&&!isNaN(e)&&e>=0&&(n(36,ie=null),n(38,se=[]),ce=null,n(40,le=!0),he())},function(e){const t=se.filter(t=>t.kind===e.kind&&t.pubkey===e.pubkey),n=Math.max(...t.map(e=>e.created_at));return e.created_at===n},async function(){if(u&&"owner"===p)try{n(23,H=!0);const e=await fetch("/api/sprocket/status",{method:"GET",headers:{Authorization:`Nostr ${await Me("GET","/api/sprocket/status")}`,"Content-Type":"application/json"}});if(e.ok){const t=await e.json();n(20,O=t.script_content||""),n(21,M=t),ke("Script loaded successfully","success")}else ke("Failed to load script","error")}catch(e){ke(`Error loading script: ${e.message}`,"error")}finally{n(23,H=!1)}},async function(){if(u&&"owner"===p)try{n(23,H=!0);const e=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await Me("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:O});if(e.ok)ke("Script saved and updated successfully","success"),await we(),await ve();else{ke(`Failed to save script: ${await e.text()}`,"error")}}catch(e){ke(`Error saving script: ${e.message}`,"error")}finally{n(23,H=!1)}},async function(){if(u&&"owner"===p)try{n(23,H=!0);const e=await fetch("/api/sprocket/restart",{method:"POST",headers:{Authorization:`Nostr ${await Me("POST","/api/sprocket/restart")}`,"Content-Type":"application/json"}});if(e.ok)ke("Sprocket restarted successfully","success"),await we();else{ke(`Failed to restart sprocket: ${await e.text()}`,"error")}}catch(e){ke(`Error restarting sprocket: ${e.message}`,"error")}finally{n(23,H=!1)}},async function(){if(u&&"owner"===p&&confirm("Are you sure you want to delete the sprocket script? This will stop the current process."))try{n(23,H=!0);const e=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await Me("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:""});if(e.ok)n(20,O=""),ke("Sprocket script deleted successfully","success"),await we(),await ve();else{ke(`Failed to delete script: ${await e.text()}`,"error")}}catch(e){ke(`Error deleting script: ${e.message}`,"error")}finally{n(23,H=!1)}},ve,Ae,be,async function(){if(u&&("owner"===p||LE))try{n(28,Y=!0),n(31,Z=[]);const e={kinds:[12345],limit:1},t=await Jh(e);if(t&&t.length>0){n(27,J=t[0].content);try{n(27,J=JSON.stringify(JSON.parse(J),null,2))}catch(e){}Ie("Policy loaded successfully","success")}else{const e=await fetch("/api/policy",{method:"GET",headers:{Authorization:`Nostr ${await Me("GET","/api/policy")}`,"Content-Type":"application/json"}});if(e.ok){const t=await e.json();n(27,J=JSON.stringify(t,null,2)),Ie("Policy loaded from file","success")}else Ie("No policy configuration found","info"),n(27,J="")}}catch(e){Ie(`Error loading policy: ${e.message}`,"error")}finally{n(28,Y=!1)}},Ee,async function(){if(!u||"owner"!==p&&!LE)return;if(await Ee())try{n(28,Y=!0);const e={kind:12345,created_at:Math.floor(Date.now()/1e3),tags:[],content:J},t=await NI(e,g);t.success?Ie("Policy updated successfully","success"):Ie(`Failed to publish policy: ${t.error||"Unknown error"}`,"error")}catch(e){Ie(`Error saving policy: ${e.message}`,"error")}finally{n(28,Y=!1)}},function(){try{const e=JSON.parse(J);n(27,J=JSON.stringify(e,null,2)),Ie("JSON formatted","success")}catch(e){Ie(`Cannot format: ${e.message}`,"error")}},function(e){const t=e.detail;if(!t)return void Ie("Please enter a pubkey","error");const r=function(e){if(!e)return null;if(/^[0-9a-fA-F]{64}$/.test(e))return e.toLowerCase();if(e.startsWith("npub1"))try{const t="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n=e.slice(5);let r=[];for(const e of n){const n=t.indexOf(e.toLowerCase());if(-1===n)throw new Error("Invalid character in npub");r.push(...[...Array(5)].map((e,t)=>n>>4-t&1))}r=r.slice(0,-30);const i=[];for(let e=0;e+8<=r.length;e+=8){let t=0;for(let n=0;n<8;n++)t=t<<1|r[e+n];i.push(t)}return i.map(e=>e.toString(16).padStart(2,"0")).join("")}catch(e){return console.error("Failed to decode npub:",e),null}return null}(t);if(r&&64===r.length)try{const e=JSON.parse(J||"{}");if(e.policy_admins||(e.policy_admins=[]),e.policy_admins.includes(r))return void Ie("Admin already in list","warning");e.policy_admins.push(r),n(27,J=JSON.stringify(e,null,2)),Ie("Admin added - click 'Save & Publish' to apply","info")}catch(e){Ie(`Error adding admin: ${e.message}`,"error")}else Ie("Invalid pubkey format. Use hex (64 chars) or npub","error")},function(e){const t=e.detail;try{const e=JSON.parse(J||"{}");e.policy_admins&&(e.policy_admins=e.policy_admins.filter(e=>e!==t),n(27,J=JSON.stringify(e,null,2)),Ie("Admin removed - click 'Save & Publish' to apply","info"))}catch(e){Ie(`Error removing admin: ${e.message}`,"error")}},async function(){if(u&&("owner"===p||LE))try{n(28,Y=!0),n(32,X=[]);let e=[];try{e=JSON.parse(J||"{}").policy_admins||[]}catch(e){return void Ie("Cannot parse policy JSON to get admins","error")}if(0===e.length)return void Ie("No policy admins configured","warning");const t={kinds:[3],authors:e,limit:e.length},r=await Jh(t),i=new Set;for(const e of r)if(e.tags)for(const t of e.tags)"p"===t[0]&&t[1]&&64===t[1].length&&i.add(t[1]);n(32,X=Array.from(i)),Ie(`Loaded ${X.length} follows from ${r.length} admin(s)`,"success")}catch(e){Ie(`Error loading follows: ${e.message}`,"error")}finally{n(28,Y=!1)}},function(e){n(26,K=e.target.files[0])},async function(){if(u&&"owner"===p&&K)try{n(23,H=!0);const e=await K.text(),t=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await Me("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:e});if(t.ok)n(20,O=e),ke("Script uploaded and updated successfully","success"),await we(),await ve();else{ke(`Failed to upload script: ${await t.text()}`,"error")}}catch(e){ke(`Error uploading script: ${e.message}`,"error")}finally{n(23,H=!1),n(26,K=null);const e=document.getElementById("sprocket-upload-file");e&&(e.value="")}},xe,function(){u||n(12,c=!0)},async function(e){const{method:t,pubkey:r,privateKey:i,signer:o}=e.detail;n(1,u=!0),n(2,d=r),f=t,n(13,g=o),n(12,c=!1),n(14,m="nsec"===t&&i?i:null);try{if(await Kh(),"extension"===t&&o)Rh.setSigner(o);else if("nsec"===t&&i){const e=new Sf(i);Rh.setSigner(e)}n(3,h=await _h(r)),console.log("Profile loaded:",h)}catch(e){console.error("Failed to load profile:",e)}await $e(),await Pe()},function(){n(1,u=!1),n(2,d=""),f="",n(3,h=null),n(4,p=""),n(13,g=null),n(14,m=null),n(15,y=!1),U=[],n(97,k=[]),$=[],P=0,me(),"undefined"!=typeof localStorage&&(localStorage.removeItem("nostr_auth_method"),localStorage.removeItem("nostr_pubkey"),localStorage.removeItem("nostr_privkey"))},function(){n(12,c=!1)},function(){n(15,y=!0)},Be,function(){n(16,v=!v)},function(e){const{searchText:t,selectedKinds:n,pubkeys:r,eventIds:i,tags:o,sinceTimestamp:s,untilTimestamp:a,limit:l}=e.detail,c=function({searchText:e=null,kinds:t=[],authors:n=[],ids:r=[],tags:i=[],since:o=null,until:s=null,limit:a=null}){const l={};return e&&e.trim()&&(l.search=e.trim()),t&&t.length>0&&(l.kinds=t),n&&n.length>0&&(l.authors=n),r&&r.length>0&&(l.ids=r),i&&i.length>0&&i.forEach(e=>{if(e.name&&e.value){const t=`#${e.name}`;l[t]||(l[t]=[]),l[t].push(e.value)}}),o&&(l.since=o),s&&(l.until=s),a&&a>0&&(l.limit=a),l}({searchText:t,kinds:n,authors:r,ids:i,tags:o,since:s,until:a,limit:l||100});A=c,Te(!0,null)},function(){A={},Te(!0,null)},Se,Fe,Qe,De,Re,async function(){await Ue([])},async function(){await Ue([d])},function(e){n(17,E=e.detail.target.files[0])},async function(){if("none"!==ee&&(!u||"admin"!==p&&"owner"!==p))return n(18,C="Admin or owner permission required"),void setTimeout(()=>{n(18,C="")},5e3);if(!E)return n(18,C="Please select a file"),void setTimeout(()=>{n(18,C="")},5e3);try{n(18,C="Uploading...");const e={};"none"!==ee&&u&&(e.Authorization=await Oe("/api/import","POST"));const t=new FormData;t.append("file",E);const r=await fetch("/api/import",{method:"POST",headers:e,body:t});if(!r.ok)throw new Error(`Import failed: ${r.status} ${r.statusText}`);await r.json();n(18,C="Upload complete"),n(17,E=null),document.getElementById("import-file").value="",setTimeout(()=>{n(18,C="")},5e3)}catch(e){console.error("Import failed:",e),n(18,C="Import failed: "+e.message),setTimeout(()=>{n(18,C="")},5e3)}},Te,function(e){const{scrollTop:t,scrollHeight:n,clientHeight:r}=e.target;n-t-r<100&&Ne()},function(){try{if(!ne.trim())return void alert("Please enter some JSON to reformat");const e=JSON.parse(ne);n(34,ne=JSON.stringify(e,null,2))}catch(e){alert("Invalid JSON: "+e.message)}},async function(){try{if(!ne.trim())return void alert("Please enter an event to sign");if(!u||!d)return void alert("Please log in to sign events");if(!g)return void alert("No signer available. Please log in with a valid authentication method.");const e=JSON.parse(ne);e.pubkey=d,e.created_at=Math.floor(Date.now()/1e3),delete e.id,delete e.sig;const t=await g.signEvent(e);n(34,ne=JSON.stringify(t,null,2)),alert("Event signed successfully!")}catch(e){console.error("Error signing event:",e),alert("Error signing event: "+e.message)}},async function(){n(35,re="");try{if(!ne.trim())return void n(35,re="Please enter an event to publish");if(!u)return void n(35,re="Please log in to publish events");if(!g)return void n(35,re="No signer available. Please log in with a valid authentication method.");let e;try{e=JSON.parse(ne)}catch(e){return void n(35,re=`Invalid JSON: ${e.message}`)}if(!e.id||!e.sig)return void n(35,re='Event must be signed before publishing. Please click "Sign" first.');if("read"===p)return void n(35,re=`Permission denied: Your current role is "${p}" which does not allow publishing events. Contact a relay administrator to upgrade your permissions.`);const t=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`,r=await NI(t,e,g,d);if(r.success)n(35,re=""),alert("Event published successfully to ORLY relay!");else{const t=r.reason||"Unknown error";n(35,re=_e(t,e.kind))}}catch(e){console.error("Error publishing event:",e);const t=e.message||"Unknown error";n(35,re=_e(t,null))}},function(){n(35,re="")},He,function(){const e=["owner","admin","write","read"],t=e.indexOf(p);return-1===t?["read"]:e.slice(t)},k,D,q,Le,o,function(t){T.call(this,e,t)},function(t){T.call(this,e,t)},e=>e.id===w,e=>xe(e.detail),e=>Fe(e.detail),e=>ue(e.detail),e=>fe(e.detail),e=>de(e.detail.event,e.detail.e),e=>Te(e.detail.refresh,e.detail.authors),function(e){ne=e,n(34,ne)},function(e){O=e,n(20,O)},e=>Ae(e.detail),e=>be(e.detail),function(e){J=e,n(27,J)},function(){ie=S(this),n(36,ie)},function(){oe=I(this.value),n(37,oe)},e=>ge(e),e=>pe(e),(e,t)=>de(e,t),e=>Qe(e.id,!0),e=>Se(e.id),e=>fe(e.id),e=>ue(e.id),(e,t)=>"Enter"===t.key&&ue(e.id),(e,t)=>de(e,t),(e,t)=>De(t,e.id),e=>He(e===p?"":e),e=>"Escape"===e.key&&Be(),function(e){c=e,n(12,c)}]}return new class extends ce{constructor(e){super(),le(this,e,OE,TE,o,{},null,[-1,-1,-1,-1,-1,-1])}}({target:document.body,props:{name:"world"}})}(); //# sourceMappingURL=bundle.js.map diff --git a/app/web/dist/bundle.js.map b/app/web/dist/bundle.js.map index bba76bf..17d9e32 100644 --- a/app/web/dist/bundle.js.map +++ b/app/web/dist/bundle.js.map @@ -1 +1 @@ -{"version":3,"file":"bundle.js","sources":["../node_modules/svelte/internal/index.mjs","../node_modules/nostr-tools/node_modules/@noble/curves/node_modules/@noble/hashes/esm/_assert.js","../node_modules/nostr-tools/node_modules/@noble/curves/node_modules/@noble/hashes/esm/crypto.js","../node_modules/nostr-tools/node_modules/@noble/curves/node_modules/@noble/hashes/esm/utils.js","../node_modules/nostr-tools/node_modules/@noble/curves/node_modules/@noble/hashes/esm/_sha2.js","../node_modules/nostr-tools/node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha256.js","../node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/utils.js","../node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/modular.js","../node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/curve.js","../node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/weierstrass.js","../node_modules/nostr-tools/node_modules/@noble/curves/node_modules/@noble/hashes/esm/hmac.js","../node_modules/nostr-tools/node_modules/@noble/curves/esm/_shortw_utils.js","../node_modules/nostr-tools/node_modules/@noble/curves/esm/secp256k1.js","../node_modules/nostr-tools/node_modules/@noble/hashes/esm/crypto.js","../node_modules/nostr-tools/node_modules/@noble/hashes/esm/utils.js","../node_modules/nostr-tools/node_modules/@noble/hashes/esm/_assert.js","../node_modules/nostr-tools/node_modules/@noble/hashes/esm/_sha2.js","../node_modules/nostr-tools/node_modules/@noble/hashes/esm/sha256.js","../node_modules/nostr-tools/lib/esm/pool.js","../node_modules/nostr-tools/node_modules/@scure/base/lib/esm/index.js","../node_modules/@noble/ciphers/esm/_assert.js","../node_modules/@noble/ciphers/esm/utils.js","../node_modules/@noble/ciphers/esm/aes.js","../node_modules/@noble/ciphers/esm/_arx.js","../node_modules/@noble/ciphers/esm/chacha.js","../node_modules/nostr-tools/node_modules/@noble/hashes/esm/hmac.js","../node_modules/nostr-tools/node_modules/@noble/hashes/esm/hkdf.js","../node_modules/nostr-tools/lib/esm/index.js","../node_modules/nostr-tools/lib/esm/kinds.js","../node_modules/tslib/tslib.es6.mjs","../node_modules/rxjs/dist/esm5/internal/util/isFunction.js","../node_modules/rxjs/dist/esm5/internal/util/createErrorClass.js","../node_modules/rxjs/dist/esm5/internal/util/UnsubscriptionError.js","../node_modules/rxjs/dist/esm5/internal/util/arrRemove.js","../node_modules/rxjs/dist/esm5/internal/Subscription.js","../node_modules/rxjs/dist/esm5/internal/config.js","../node_modules/rxjs/dist/esm5/internal/scheduler/timeoutProvider.js","../node_modules/rxjs/dist/esm5/internal/util/reportUnhandledError.js","../node_modules/rxjs/dist/esm5/internal/util/noop.js","../node_modules/rxjs/dist/esm5/internal/util/errorContext.js","../node_modules/rxjs/dist/esm5/internal/Subscriber.js","../node_modules/rxjs/dist/esm5/internal/symbol/observable.js","../node_modules/rxjs/dist/esm5/internal/util/identity.js","../node_modules/rxjs/dist/esm5/internal/Observable.js","../node_modules/rxjs/dist/esm5/internal/util/pipe.js","../node_modules/rxjs/dist/esm5/internal/util/lift.js","../node_modules/rxjs/dist/esm5/internal/operators/OperatorSubscriber.js","../node_modules/rxjs/dist/esm5/internal/util/ObjectUnsubscribedError.js","../node_modules/rxjs/dist/esm5/internal/Subject.js","../node_modules/rxjs/dist/esm5/internal/scheduler/dateTimestampProvider.js","../node_modules/rxjs/dist/esm5/internal/ReplaySubject.js","../node_modules/rxjs/dist/esm5/internal/scheduler/Action.js","../node_modules/rxjs/dist/esm5/internal/scheduler/intervalProvider.js","../node_modules/rxjs/dist/esm5/internal/scheduler/AsyncAction.js","../node_modules/rxjs/dist/esm5/internal/Scheduler.js","../node_modules/rxjs/dist/esm5/internal/scheduler/AsyncScheduler.js","../node_modules/rxjs/dist/esm5/internal/scheduler/async.js","../node_modules/rxjs/dist/esm5/internal/observable/empty.js","../node_modules/rxjs/dist/esm5/internal/util/isScheduler.js","../node_modules/rxjs/dist/esm5/internal/util/args.js","../node_modules/rxjs/dist/esm5/internal/util/isArrayLike.js","../node_modules/rxjs/dist/esm5/internal/util/isPromise.js","../node_modules/rxjs/dist/esm5/internal/util/isInteropObservable.js","../node_modules/rxjs/dist/esm5/internal/util/isAsyncIterable.js","../node_modules/rxjs/dist/esm5/internal/util/throwUnobservableError.js","../node_modules/rxjs/dist/esm5/internal/symbol/iterator.js","../node_modules/rxjs/dist/esm5/internal/util/isIterable.js","../node_modules/rxjs/dist/esm5/internal/util/isReadableStreamLike.js","../node_modules/rxjs/dist/esm5/internal/observable/innerFrom.js","../node_modules/rxjs/dist/esm5/internal/util/executeSchedule.js","../node_modules/rxjs/dist/esm5/internal/operators/observeOn.js","../node_modules/rxjs/dist/esm5/internal/operators/subscribeOn.js","../node_modules/rxjs/dist/esm5/internal/scheduled/scheduleAsyncIterable.js","../node_modules/rxjs/dist/esm5/internal/scheduled/scheduled.js","../node_modules/rxjs/dist/esm5/internal/scheduled/scheduleObservable.js","../node_modules/rxjs/dist/esm5/internal/scheduled/scheduleArray.js","../node_modules/rxjs/dist/esm5/internal/scheduled/schedulePromise.js","../node_modules/rxjs/dist/esm5/internal/scheduled/scheduleIterable.js","../node_modules/rxjs/dist/esm5/internal/scheduled/scheduleReadableStreamLike.js","../node_modules/rxjs/dist/esm5/internal/observable/from.js","../node_modules/rxjs/dist/esm5/internal/observable/of.js","../node_modules/rxjs/dist/esm5/internal/operators/map.js","../node_modules/rxjs/dist/esm5/internal/util/mapOneOrManyArgs.js","../node_modules/rxjs/dist/esm5/internal/util/argsArgArrayOrObject.js","../node_modules/rxjs/dist/esm5/internal/observable/combineLatest.js","../node_modules/rxjs/dist/esm5/internal/util/createObject.js","../node_modules/rxjs/dist/esm5/internal/operators/mergeMap.js","../node_modules/rxjs/dist/esm5/internal/operators/mergeInternals.js","../node_modules/rxjs/dist/esm5/internal/operators/mergeAll.js","../node_modules/rxjs/dist/esm5/internal/observable/concat.js","../node_modules/rxjs/dist/esm5/internal/operators/concatAll.js","../node_modules/rxjs/dist/esm5/internal/observable/defer.js","../node_modules/rxjs/dist/esm5/internal/observable/timer.js","../node_modules/rxjs/dist/esm5/internal/util/isDate.js","../node_modules/rxjs/dist/esm5/internal/observable/merge.js","../node_modules/rxjs/dist/esm5/internal/operators/filter.js","../node_modules/rxjs/dist/esm5/internal/operators/take.js","../node_modules/rxjs/dist/esm5/internal/operators/distinctUntilChanged.js","../node_modules/rxjs/dist/esm5/internal/operators/endWith.js","../node_modules/rxjs/dist/esm5/internal/operators/finalize.js","../node_modules/rxjs/dist/esm5/internal/operators/merge.js","../node_modules/rxjs/dist/esm5/internal/operators/mergeWith.js","../node_modules/rxjs/dist/esm5/internal/operators/scan.js","../node_modules/rxjs/dist/esm5/internal/operators/scanInternals.js","../node_modules/rxjs/dist/esm5/internal/operators/share.js","../node_modules/rxjs/dist/esm5/internal/operators/switchMap.js","../node_modules/rxjs/dist/esm5/internal/operators/tap.js","../node_modules/applesauce-core/dist/helpers/tags.js","../node_modules/nostr-tools/lib/esm/pure.js","../node_modules/applesauce-core/dist/helpers/cache.js","../node_modules/nostr-tools/lib/esm/utils.js","../node_modules/applesauce-core/dist/helpers/event.js","../node_modules/applesauce-core/dist/helpers/time.js","../node_modules/applesauce-core/dist/helpers/expiration.js","../node_modules/nostr-tools/lib/esm/nip19.js","../node_modules/applesauce-core/dist/helpers/url.js","../node_modules/applesauce-core/dist/helpers/relays.js","../node_modules/applesauce-core/dist/helpers/string.js","../node_modules/@noble/hashes/esm/crypto.js","../node_modules/@noble/hashes/esm/utils.js","../node_modules/applesauce-core/dist/helpers/pointers.js","../node_modules/applesauce-core/dist/helpers/groups.js","../node_modules/applesauce-core/dist/helpers/encrypted-content.js","../node_modules/applesauce-core/dist/helpers/hidden-content.js","../node_modules/applesauce-core/dist/helpers/hidden-tags.js","../node_modules/applesauce-core/dist/helpers/event-tags.js","../node_modules/applesauce-core/dist/helpers/lru.js","../node_modules/ms/index.js","../node_modules/debug/src/common.js","../node_modules/debug/src/browser.js","../node_modules/applesauce-core/dist/logger.js","../node_modules/applesauce-core/dist/event-store/event-memory.js","../node_modules/hash-sum/hash-sum.js","../node_modules/applesauce-core/dist/helpers/filter.js","../node_modules/applesauce-core/dist/models/blossom.js","../node_modules/applesauce-core/dist/helpers/blossom.js","../node_modules/applesauce-core/dist/helpers/profile.js","../node_modules/applesauce-core/dist/helpers/json.js","../node_modules/light-bolt11-decoder/node_modules/@scure/base/lib/index.js","../node_modules/light-bolt11-decoder/bolt11.js","../node_modules/applesauce-core/dist/helpers/comment.js","../node_modules/applesauce-core/dist/helpers/contacts.js","../node_modules/applesauce-core/dist/helpers/encrypted-content-cache.js","../node_modules/applesauce-core/dist/helpers/event-cache.js","../node_modules/applesauce-core/dist/helpers/lnurl.js","../node_modules/applesauce-core/dist/helpers/mailboxes.js","../node_modules/applesauce-core/dist/helpers/mutes.js","../node_modules/applesauce-core/dist/helpers/reports.js","../node_modules/applesauce-core/dist/helpers/threading.js","../node_modules/applesauce-core/dist/observable/claim-events.js","../node_modules/applesauce-core/dist/observable/claim-latest.js","../node_modules/applesauce-core/dist/observable/defined.js","../node_modules/applesauce-core/dist/observable/with-immediate-value.js","../node_modules/applesauce-core/dist/models/common.js","../node_modules/rxjs/dist/esm5/internal/operators/ignoreElements.js","../node_modules/rxjs/dist/esm5/internal/operators/takeUntil.js","../node_modules/rxjs/dist/esm5/internal/operators/repeat.js","../node_modules/applesauce-core/dist/observable/watch-event-updates.js","../node_modules/applesauce-core/dist/models/contacts.js","../node_modules/applesauce-core/dist/models/comments.js","../node_modules/applesauce-core/dist/models/mailboxes.js","../node_modules/applesauce-core/dist/models/mutes.js","../node_modules/applesauce-core/dist/models/profile.js","../node_modules/applesauce-core/dist/models/reactions.js","../node_modules/applesauce-core/dist/models/thread.js","../node_modules/applesauce-core/dist/event-store/model-mixin.js","../node_modules/applesauce-core/dist/event-store/event-store.js","../node_modules/applesauce-core/dist/helpers/delete.js","../node_modules/applesauce-core/dist/promise/deferred.js","../node_modules/applesauce-signers/dist/signers/amber-clipboard-signer.js","../node_modules/applesauce-signers/dist/helpers/nostr-connect.js","../node_modules/applesauce-signers/dist/signers/private-key-signer.js","../node_modules/applesauce-signers/node_modules/@noble/secp256k1/lib/esm/index.js","../node_modules/applesauce-signers/node_modules/@scure/base/lib/esm/index.js","../node_modules/applesauce-signers/dist/signers/serial-port-signer.js","../src/constants.js","../src/nostr.js","../node_modules/hash-wasm/dist/index.esm.js","../src/nsec-crypto.js","../src/LoginModal.svelte","../src/ManagedACL.svelte","../src/Header.svelte","../src/Sidebar.svelte","../src/ExportView.svelte","../src/ImportView.svelte","../src/helpers.tsx","../src/FilterBuilder.svelte","../src/EventsView.svelte","../src/eventKinds.js","../src/EventTemplateSelector.svelte","../src/ComposeView.svelte","../src/SprocketView.svelte","../src/PolicyView.svelte","../src/BlossomView.svelte","../node_modules/qrcode/lib/core/utils.js","../node_modules/qrcode/lib/core/bit-buffer.js","../node_modules/qrcode/lib/core/error-correction-level.js","../node_modules/qrcode/lib/core/bit-matrix.js","../node_modules/qrcode/lib/core/alignment-pattern.js","../node_modules/qrcode/lib/core/finder-pattern.js","../node_modules/qrcode/lib/core/mask-pattern.js","../node_modules/qrcode/lib/core/error-correction-code.js","../node_modules/qrcode/lib/core/galois-field.js","../node_modules/qrcode/lib/core/polynomial.js","../node_modules/qrcode/lib/core/reed-solomon-encoder.js","../node_modules/qrcode/lib/core/version-check.js","../node_modules/qrcode/lib/core/regex.js","../node_modules/qrcode/lib/core/mode.js","../node_modules/qrcode/lib/core/version.js","../node_modules/qrcode/lib/core/format-info.js","../node_modules/qrcode/lib/core/numeric-data.js","../node_modules/qrcode/lib/core/alphanumeric-data.js","../node_modules/qrcode/lib/core/byte-data.js","../node_modules/qrcode/lib/core/kanji-data.js","../node_modules/dijkstrajs/dijkstra.js","../node_modules/qrcode/lib/core/segments.js","../node_modules/qrcode/lib/core/qrcode.js","../node_modules/qrcode/lib/renderer/utils.js","../node_modules/qrcode/lib/renderer/canvas.js","../node_modules/qrcode/lib/renderer/svg-tag.js","../node_modules/qrcode/lib/browser.js","../node_modules/qrcode/lib/can-promise.js","../src/api.js","../node_modules/@noble/hashes/esm/_md.js","../node_modules/@noble/hashes/esm/sha2.js","../node_modules/@noble/hashes/esm/hmac.js","../node_modules/@noble/curves/esm/utils.js","../node_modules/@noble/curves/esm/abstract/modular.js","../node_modules/@noble/curves/esm/abstract/curve.js","../node_modules/@noble/curves/esm/abstract/weierstrass.js","../node_modules/@noble/curves/esm/secp256k1.js","../node_modules/@noble/curves/esm/_shortw_utils.js","../node_modules/@noble/hashes/esm/sha256.js","../src/cashu-client.js","../src/bunker-service.js","../src/BunkerView.svelte","../src/LogView.svelte","../src/FilterDisplay.svelte","../src/utils.js","../src/websocket-auth.js","../src/App.svelte","../src/main.js"],"sourcesContent":["function noop() { }\nconst identity = x => x;\nfunction assign(tar, src) {\n // @ts-ignore\n for (const k in src)\n tar[k] = src[k];\n return tar;\n}\n// Adapted from https://github.com/then/is-promise/blob/master/index.js\n// Distributed under MIT License https://github.com/then/is-promise/blob/master/LICENSE\nfunction is_promise(value) {\n return !!value && (typeof value === 'object' || typeof value === 'function') && typeof value.then === 'function';\n}\nfunction add_location(element, file, line, column, char) {\n element.__svelte_meta = {\n loc: { file, line, column, char }\n };\n}\nfunction run(fn) {\n return fn();\n}\nfunction blank_object() {\n return Object.create(null);\n}\nfunction run_all(fns) {\n fns.forEach(run);\n}\nfunction is_function(thing) {\n return typeof thing === 'function';\n}\nfunction safe_not_equal(a, b) {\n return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');\n}\nlet src_url_equal_anchor;\nfunction src_url_equal(element_src, url) {\n if (!src_url_equal_anchor) {\n src_url_equal_anchor = document.createElement('a');\n }\n src_url_equal_anchor.href = url;\n return element_src === src_url_equal_anchor.href;\n}\nfunction not_equal(a, b) {\n return a != a ? b == b : a !== b;\n}\nfunction is_empty(obj) {\n return Object.keys(obj).length === 0;\n}\nfunction validate_store(store, name) {\n if (store != null && typeof store.subscribe !== 'function') {\n throw new Error(`'${name}' is not a store with a 'subscribe' method`);\n }\n}\nfunction subscribe(store, ...callbacks) {\n if (store == null) {\n return noop;\n }\n const unsub = store.subscribe(...callbacks);\n return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;\n}\nfunction get_store_value(store) {\n let value;\n subscribe(store, _ => value = _)();\n return value;\n}\nfunction component_subscribe(component, store, callback) {\n component.$$.on_destroy.push(subscribe(store, callback));\n}\nfunction create_slot(definition, ctx, $$scope, fn) {\n if (definition) {\n const slot_ctx = get_slot_context(definition, ctx, $$scope, fn);\n return definition[0](slot_ctx);\n }\n}\nfunction get_slot_context(definition, ctx, $$scope, fn) {\n return definition[1] && fn\n ? assign($$scope.ctx.slice(), definition[1](fn(ctx)))\n : $$scope.ctx;\n}\nfunction get_slot_changes(definition, $$scope, dirty, fn) {\n if (definition[2] && fn) {\n const lets = definition[2](fn(dirty));\n if ($$scope.dirty === undefined) {\n return lets;\n }\n if (typeof lets === 'object') {\n const merged = [];\n const len = Math.max($$scope.dirty.length, lets.length);\n for (let i = 0; i < len; i += 1) {\n merged[i] = $$scope.dirty[i] | lets[i];\n }\n return merged;\n }\n return $$scope.dirty | lets;\n }\n return $$scope.dirty;\n}\nfunction update_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn) {\n if (slot_changes) {\n const slot_context = get_slot_context(slot_definition, ctx, $$scope, get_slot_context_fn);\n slot.p(slot_context, slot_changes);\n }\n}\nfunction update_slot(slot, slot_definition, ctx, $$scope, dirty, get_slot_changes_fn, get_slot_context_fn) {\n const slot_changes = get_slot_changes(slot_definition, $$scope, dirty, get_slot_changes_fn);\n update_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn);\n}\nfunction get_all_dirty_from_scope($$scope) {\n if ($$scope.ctx.length > 32) {\n const dirty = [];\n const length = $$scope.ctx.length / 32;\n for (let i = 0; i < length; i++) {\n dirty[i] = -1;\n }\n return dirty;\n }\n return -1;\n}\nfunction exclude_internal_props(props) {\n const result = {};\n for (const k in props)\n if (k[0] !== '$')\n result[k] = props[k];\n return result;\n}\nfunction compute_rest_props(props, keys) {\n const rest = {};\n keys = new Set(keys);\n for (const k in props)\n if (!keys.has(k) && k[0] !== '$')\n rest[k] = props[k];\n return rest;\n}\nfunction compute_slots(slots) {\n const result = {};\n for (const key in slots) {\n result[key] = true;\n }\n return result;\n}\nfunction once(fn) {\n let ran = false;\n return function (...args) {\n if (ran)\n return;\n ran = true;\n fn.call(this, ...args);\n };\n}\nfunction null_to_empty(value) {\n return value == null ? '' : value;\n}\nfunction set_store_value(store, ret, value) {\n store.set(value);\n return ret;\n}\nconst has_prop = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);\nfunction action_destroyer(action_result) {\n return action_result && is_function(action_result.destroy) ? action_result.destroy : noop;\n}\nfunction split_css_unit(value) {\n const split = typeof value === 'string' && value.match(/^\\s*(-?[\\d.]+)([^\\s]*)\\s*$/);\n return split ? [parseFloat(split[1]), split[2] || 'px'] : [value, 'px'];\n}\nconst contenteditable_truthy_values = ['', true, 1, 'true', 'contenteditable'];\n\nconst is_client = typeof window !== 'undefined';\nlet now = is_client\n ? () => window.performance.now()\n : () => Date.now();\nlet raf = is_client ? cb => requestAnimationFrame(cb) : noop;\n// used internally for testing\nfunction set_now(fn) {\n now = fn;\n}\nfunction set_raf(fn) {\n raf = fn;\n}\n\nconst tasks = new Set();\nfunction run_tasks(now) {\n tasks.forEach(task => {\n if (!task.c(now)) {\n tasks.delete(task);\n task.f();\n }\n });\n if (tasks.size !== 0)\n raf(run_tasks);\n}\n/**\n * For testing purposes only!\n */\nfunction clear_loops() {\n tasks.clear();\n}\n/**\n * Creates a new task that runs on each raf frame\n * until it returns a falsy value or is aborted\n */\nfunction loop(callback) {\n let task;\n if (tasks.size === 0)\n raf(run_tasks);\n return {\n promise: new Promise(fulfill => {\n tasks.add(task = { c: callback, f: fulfill });\n }),\n abort() {\n tasks.delete(task);\n }\n };\n}\n\nconst globals = (typeof window !== 'undefined'\n ? window\n : typeof globalThis !== 'undefined'\n ? globalThis\n : global);\n\n/**\n * Resize observer singleton.\n * One listener per element only!\n * https://groups.google.com/a/chromium.org/g/blink-dev/c/z6ienONUb5A/m/F5-VcUZtBAAJ\n */\nclass ResizeObserverSingleton {\n constructor(options) {\n this.options = options;\n this._listeners = 'WeakMap' in globals ? new WeakMap() : undefined;\n }\n observe(element, listener) {\n this._listeners.set(element, listener);\n this._getObserver().observe(element, this.options);\n return () => {\n this._listeners.delete(element);\n this._observer.unobserve(element); // this line can probably be removed\n };\n }\n _getObserver() {\n var _a;\n return (_a = this._observer) !== null && _a !== void 0 ? _a : (this._observer = new ResizeObserver((entries) => {\n var _a;\n for (const entry of entries) {\n ResizeObserverSingleton.entries.set(entry.target, entry);\n (_a = this._listeners.get(entry.target)) === null || _a === void 0 ? void 0 : _a(entry);\n }\n }));\n }\n}\n// Needs to be written like this to pass the tree-shake-test\nResizeObserverSingleton.entries = 'WeakMap' in globals ? new WeakMap() : undefined;\n\n// Track which nodes are claimed during hydration. Unclaimed nodes can then be removed from the DOM\n// at the end of hydration without touching the remaining nodes.\nlet is_hydrating = false;\nfunction start_hydrating() {\n is_hydrating = true;\n}\nfunction end_hydrating() {\n is_hydrating = false;\n}\nfunction upper_bound(low, high, key, value) {\n // Return first index of value larger than input value in the range [low, high)\n while (low < high) {\n const mid = low + ((high - low) >> 1);\n if (key(mid) <= value) {\n low = mid + 1;\n }\n else {\n high = mid;\n }\n }\n return low;\n}\nfunction init_hydrate(target) {\n if (target.hydrate_init)\n return;\n target.hydrate_init = true;\n // We know that all children have claim_order values since the unclaimed have been detached if target is not \n let children = target.childNodes;\n // If target is , there may be children without claim_order\n if (target.nodeName === 'HEAD') {\n const myChildren = [];\n for (let i = 0; i < children.length; i++) {\n const node = children[i];\n if (node.claim_order !== undefined) {\n myChildren.push(node);\n }\n }\n children = myChildren;\n }\n /*\n * Reorder claimed children optimally.\n * We can reorder claimed children optimally by finding the longest subsequence of\n * nodes that are already claimed in order and only moving the rest. The longest\n * subsequence of nodes that are claimed in order can be found by\n * computing the longest increasing subsequence of .claim_order values.\n *\n * This algorithm is optimal in generating the least amount of reorder operations\n * possible.\n *\n * Proof:\n * We know that, given a set of reordering operations, the nodes that do not move\n * always form an increasing subsequence, since they do not move among each other\n * meaning that they must be already ordered among each other. Thus, the maximal\n * set of nodes that do not move form a longest increasing subsequence.\n */\n // Compute longest increasing subsequence\n // m: subsequence length j => index k of smallest value that ends an increasing subsequence of length j\n const m = new Int32Array(children.length + 1);\n // Predecessor indices + 1\n const p = new Int32Array(children.length);\n m[0] = -1;\n let longest = 0;\n for (let i = 0; i < children.length; i++) {\n const current = children[i].claim_order;\n // Find the largest subsequence length such that it ends in a value less than our current value\n // upper_bound returns first greater value, so we subtract one\n // with fast path for when we are on the current longest subsequence\n const seqLen = ((longest > 0 && children[m[longest]].claim_order <= current) ? longest + 1 : upper_bound(1, longest, idx => children[m[idx]].claim_order, current)) - 1;\n p[i] = m[seqLen] + 1;\n const newLen = seqLen + 1;\n // We can guarantee that current is the smallest value. Otherwise, we would have generated a longer sequence.\n m[newLen] = i;\n longest = Math.max(newLen, longest);\n }\n // The longest increasing subsequence of nodes (initially reversed)\n const lis = [];\n // The rest of the nodes, nodes that will be moved\n const toMove = [];\n let last = children.length - 1;\n for (let cur = m[longest] + 1; cur != 0; cur = p[cur - 1]) {\n lis.push(children[cur - 1]);\n for (; last >= cur; last--) {\n toMove.push(children[last]);\n }\n last--;\n }\n for (; last >= 0; last--) {\n toMove.push(children[last]);\n }\n lis.reverse();\n // We sort the nodes being moved to guarantee that their insertion order matches the claim order\n toMove.sort((a, b) => a.claim_order - b.claim_order);\n // Finally, we move the nodes\n for (let i = 0, j = 0; i < toMove.length; i++) {\n while (j < lis.length && toMove[i].claim_order >= lis[j].claim_order) {\n j++;\n }\n const anchor = j < lis.length ? lis[j] : null;\n target.insertBefore(toMove[i], anchor);\n }\n}\nfunction append(target, node) {\n target.appendChild(node);\n}\nfunction append_styles(target, style_sheet_id, styles) {\n const append_styles_to = get_root_for_style(target);\n if (!append_styles_to.getElementById(style_sheet_id)) {\n const style = element('style');\n style.id = style_sheet_id;\n style.textContent = styles;\n append_stylesheet(append_styles_to, style);\n }\n}\nfunction get_root_for_style(node) {\n if (!node)\n return document;\n const root = node.getRootNode ? node.getRootNode() : node.ownerDocument;\n if (root && root.host) {\n return root;\n }\n return node.ownerDocument;\n}\nfunction append_empty_stylesheet(node) {\n const style_element = element('style');\n append_stylesheet(get_root_for_style(node), style_element);\n return style_element.sheet;\n}\nfunction append_stylesheet(node, style) {\n append(node.head || node, style);\n return style.sheet;\n}\nfunction append_hydration(target, node) {\n if (is_hydrating) {\n init_hydrate(target);\n if ((target.actual_end_child === undefined) || ((target.actual_end_child !== null) && (target.actual_end_child.parentNode !== target))) {\n target.actual_end_child = target.firstChild;\n }\n // Skip nodes of undefined ordering\n while ((target.actual_end_child !== null) && (target.actual_end_child.claim_order === undefined)) {\n target.actual_end_child = target.actual_end_child.nextSibling;\n }\n if (node !== target.actual_end_child) {\n // We only insert if the ordering of this node should be modified or the parent node is not target\n if (node.claim_order !== undefined || node.parentNode !== target) {\n target.insertBefore(node, target.actual_end_child);\n }\n }\n else {\n target.actual_end_child = node.nextSibling;\n }\n }\n else if (node.parentNode !== target || node.nextSibling !== null) {\n target.appendChild(node);\n }\n}\nfunction insert(target, node, anchor) {\n target.insertBefore(node, anchor || null);\n}\nfunction insert_hydration(target, node, anchor) {\n if (is_hydrating && !anchor) {\n append_hydration(target, node);\n }\n else if (node.parentNode !== target || node.nextSibling != anchor) {\n target.insertBefore(node, anchor || null);\n }\n}\nfunction detach(node) {\n if (node.parentNode) {\n node.parentNode.removeChild(node);\n }\n}\nfunction destroy_each(iterations, detaching) {\n for (let i = 0; i < iterations.length; i += 1) {\n if (iterations[i])\n iterations[i].d(detaching);\n }\n}\nfunction element(name) {\n return document.createElement(name);\n}\nfunction element_is(name, is) {\n return document.createElement(name, { is });\n}\nfunction object_without_properties(obj, exclude) {\n const target = {};\n for (const k in obj) {\n if (has_prop(obj, k)\n // @ts-ignore\n && exclude.indexOf(k) === -1) {\n // @ts-ignore\n target[k] = obj[k];\n }\n }\n return target;\n}\nfunction svg_element(name) {\n return document.createElementNS('http://www.w3.org/2000/svg', name);\n}\nfunction text(data) {\n return document.createTextNode(data);\n}\nfunction space() {\n return text(' ');\n}\nfunction empty() {\n return text('');\n}\nfunction comment(content) {\n return document.createComment(content);\n}\nfunction listen(node, event, handler, options) {\n node.addEventListener(event, handler, options);\n return () => node.removeEventListener(event, handler, options);\n}\nfunction prevent_default(fn) {\n return function (event) {\n event.preventDefault();\n // @ts-ignore\n return fn.call(this, event);\n };\n}\nfunction stop_propagation(fn) {\n return function (event) {\n event.stopPropagation();\n // @ts-ignore\n return fn.call(this, event);\n };\n}\nfunction stop_immediate_propagation(fn) {\n return function (event) {\n event.stopImmediatePropagation();\n // @ts-ignore\n return fn.call(this, event);\n };\n}\nfunction self(fn) {\n return function (event) {\n // @ts-ignore\n if (event.target === this)\n fn.call(this, event);\n };\n}\nfunction trusted(fn) {\n return function (event) {\n // @ts-ignore\n if (event.isTrusted)\n fn.call(this, event);\n };\n}\nfunction attr(node, attribute, value) {\n if (value == null)\n node.removeAttribute(attribute);\n else if (node.getAttribute(attribute) !== value)\n node.setAttribute(attribute, value);\n}\n/**\n * List of attributes that should always be set through the attr method,\n * because updating them through the property setter doesn't work reliably.\n * In the example of `width`/`height`, the problem is that the setter only\n * accepts numeric values, but the attribute can also be set to a string like `50%`.\n * If this list becomes too big, rethink this approach.\n */\nconst always_set_through_set_attribute = ['width', 'height'];\nfunction set_attributes(node, attributes) {\n // @ts-ignore\n const descriptors = Object.getOwnPropertyDescriptors(node.__proto__);\n for (const key in attributes) {\n if (attributes[key] == null) {\n node.removeAttribute(key);\n }\n else if (key === 'style') {\n node.style.cssText = attributes[key];\n }\n else if (key === '__value') {\n node.value = node[key] = attributes[key];\n }\n else if (descriptors[key] && descriptors[key].set && always_set_through_set_attribute.indexOf(key) === -1) {\n node[key] = attributes[key];\n }\n else {\n attr(node, key, attributes[key]);\n }\n }\n}\nfunction set_svg_attributes(node, attributes) {\n for (const key in attributes) {\n attr(node, key, attributes[key]);\n }\n}\nfunction set_custom_element_data_map(node, data_map) {\n Object.keys(data_map).forEach((key) => {\n set_custom_element_data(node, key, data_map[key]);\n });\n}\nfunction set_custom_element_data(node, prop, value) {\n if (prop in node) {\n node[prop] = typeof node[prop] === 'boolean' && value === '' ? true : value;\n }\n else {\n attr(node, prop, value);\n }\n}\nfunction set_dynamic_element_data(tag) {\n return (/-/.test(tag)) ? set_custom_element_data_map : set_attributes;\n}\nfunction xlink_attr(node, attribute, value) {\n node.setAttributeNS('http://www.w3.org/1999/xlink', attribute, value);\n}\nfunction get_binding_group_value(group, __value, checked) {\n const value = new Set();\n for (let i = 0; i < group.length; i += 1) {\n if (group[i].checked)\n value.add(group[i].__value);\n }\n if (!checked) {\n value.delete(__value);\n }\n return Array.from(value);\n}\nfunction init_binding_group(group) {\n let _inputs;\n return {\n /* push */ p(...inputs) {\n _inputs = inputs;\n _inputs.forEach(input => group.push(input));\n },\n /* remove */ r() {\n _inputs.forEach(input => group.splice(group.indexOf(input), 1));\n }\n };\n}\nfunction init_binding_group_dynamic(group, indexes) {\n let _group = get_binding_group(group);\n let _inputs;\n function get_binding_group(group) {\n for (let i = 0; i < indexes.length; i++) {\n group = group[indexes[i]] = group[indexes[i]] || [];\n }\n return group;\n }\n function push() {\n _inputs.forEach(input => _group.push(input));\n }\n function remove() {\n _inputs.forEach(input => _group.splice(_group.indexOf(input), 1));\n }\n return {\n /* update */ u(new_indexes) {\n indexes = new_indexes;\n const new_group = get_binding_group(group);\n if (new_group !== _group) {\n remove();\n _group = new_group;\n push();\n }\n },\n /* push */ p(...inputs) {\n _inputs = inputs;\n push();\n },\n /* remove */ r: remove\n };\n}\nfunction to_number(value) {\n return value === '' ? null : +value;\n}\nfunction time_ranges_to_array(ranges) {\n const array = [];\n for (let i = 0; i < ranges.length; i += 1) {\n array.push({ start: ranges.start(i), end: ranges.end(i) });\n }\n return array;\n}\nfunction children(element) {\n return Array.from(element.childNodes);\n}\nfunction init_claim_info(nodes) {\n if (nodes.claim_info === undefined) {\n nodes.claim_info = { last_index: 0, total_claimed: 0 };\n }\n}\nfunction claim_node(nodes, predicate, processNode, createNode, dontUpdateLastIndex = false) {\n // Try to find nodes in an order such that we lengthen the longest increasing subsequence\n init_claim_info(nodes);\n const resultNode = (() => {\n // We first try to find an element after the previous one\n for (let i = nodes.claim_info.last_index; i < nodes.length; i++) {\n const node = nodes[i];\n if (predicate(node)) {\n const replacement = processNode(node);\n if (replacement === undefined) {\n nodes.splice(i, 1);\n }\n else {\n nodes[i] = replacement;\n }\n if (!dontUpdateLastIndex) {\n nodes.claim_info.last_index = i;\n }\n return node;\n }\n }\n // Otherwise, we try to find one before\n // We iterate in reverse so that we don't go too far back\n for (let i = nodes.claim_info.last_index - 1; i >= 0; i--) {\n const node = nodes[i];\n if (predicate(node)) {\n const replacement = processNode(node);\n if (replacement === undefined) {\n nodes.splice(i, 1);\n }\n else {\n nodes[i] = replacement;\n }\n if (!dontUpdateLastIndex) {\n nodes.claim_info.last_index = i;\n }\n else if (replacement === undefined) {\n // Since we spliced before the last_index, we decrease it\n nodes.claim_info.last_index--;\n }\n return node;\n }\n }\n // If we can't find any matching node, we create a new one\n return createNode();\n })();\n resultNode.claim_order = nodes.claim_info.total_claimed;\n nodes.claim_info.total_claimed += 1;\n return resultNode;\n}\nfunction claim_element_base(nodes, name, attributes, create_element) {\n return claim_node(nodes, (node) => node.nodeName === name, (node) => {\n const remove = [];\n for (let j = 0; j < node.attributes.length; j++) {\n const attribute = node.attributes[j];\n if (!attributes[attribute.name]) {\n remove.push(attribute.name);\n }\n }\n remove.forEach(v => node.removeAttribute(v));\n return undefined;\n }, () => create_element(name));\n}\nfunction claim_element(nodes, name, attributes) {\n return claim_element_base(nodes, name, attributes, element);\n}\nfunction claim_svg_element(nodes, name, attributes) {\n return claim_element_base(nodes, name, attributes, svg_element);\n}\nfunction claim_text(nodes, data) {\n return claim_node(nodes, (node) => node.nodeType === 3, (node) => {\n const dataStr = '' + data;\n if (node.data.startsWith(dataStr)) {\n if (node.data.length !== dataStr.length) {\n return node.splitText(dataStr.length);\n }\n }\n else {\n node.data = dataStr;\n }\n }, () => text(data), true // Text nodes should not update last index since it is likely not worth it to eliminate an increasing subsequence of actual elements\n );\n}\nfunction claim_space(nodes) {\n return claim_text(nodes, ' ');\n}\nfunction claim_comment(nodes, data) {\n return claim_node(nodes, (node) => node.nodeType === 8, (node) => {\n node.data = '' + data;\n return undefined;\n }, () => comment(data), true);\n}\nfunction find_comment(nodes, text, start) {\n for (let i = start; i < nodes.length; i += 1) {\n const node = nodes[i];\n if (node.nodeType === 8 /* comment node */ && node.textContent.trim() === text) {\n return i;\n }\n }\n return nodes.length;\n}\nfunction claim_html_tag(nodes, is_svg) {\n // find html opening tag\n const start_index = find_comment(nodes, 'HTML_TAG_START', 0);\n const end_index = find_comment(nodes, 'HTML_TAG_END', start_index);\n if (start_index === end_index) {\n return new HtmlTagHydration(undefined, is_svg);\n }\n init_claim_info(nodes);\n const html_tag_nodes = nodes.splice(start_index, end_index - start_index + 1);\n detach(html_tag_nodes[0]);\n detach(html_tag_nodes[html_tag_nodes.length - 1]);\n const claimed_nodes = html_tag_nodes.slice(1, html_tag_nodes.length - 1);\n for (const n of claimed_nodes) {\n n.claim_order = nodes.claim_info.total_claimed;\n nodes.claim_info.total_claimed += 1;\n }\n return new HtmlTagHydration(claimed_nodes, is_svg);\n}\nfunction set_data(text, data) {\n data = '' + data;\n if (text.data === data)\n return;\n text.data = data;\n}\nfunction set_data_contenteditable(text, data) {\n data = '' + data;\n if (text.wholeText === data)\n return;\n text.data = data;\n}\nfunction set_data_maybe_contenteditable(text, data, attr_value) {\n if (~contenteditable_truthy_values.indexOf(attr_value)) {\n set_data_contenteditable(text, data);\n }\n else {\n set_data(text, data);\n }\n}\nfunction set_input_value(input, value) {\n input.value = value == null ? '' : value;\n}\nfunction set_input_type(input, type) {\n try {\n input.type = type;\n }\n catch (e) {\n // do nothing\n }\n}\nfunction set_style(node, key, value, important) {\n if (value == null) {\n node.style.removeProperty(key);\n }\n else {\n node.style.setProperty(key, value, important ? 'important' : '');\n }\n}\nfunction select_option(select, value, mounting) {\n for (let i = 0; i < select.options.length; i += 1) {\n const option = select.options[i];\n if (option.__value === value) {\n option.selected = true;\n return;\n }\n }\n if (!mounting || value !== undefined) {\n select.selectedIndex = -1; // no option should be selected\n }\n}\nfunction select_options(select, value) {\n for (let i = 0; i < select.options.length; i += 1) {\n const option = select.options[i];\n option.selected = ~value.indexOf(option.__value);\n }\n}\nfunction select_value(select) {\n const selected_option = select.querySelector(':checked');\n return selected_option && selected_option.__value;\n}\nfunction select_multiple_value(select) {\n return [].map.call(select.querySelectorAll(':checked'), option => option.__value);\n}\n// unfortunately this can't be a constant as that wouldn't be tree-shakeable\n// so we cache the result instead\nlet crossorigin;\nfunction is_crossorigin() {\n if (crossorigin === undefined) {\n crossorigin = false;\n try {\n if (typeof window !== 'undefined' && window.parent) {\n void window.parent.document;\n }\n }\n catch (error) {\n crossorigin = true;\n }\n }\n return crossorigin;\n}\nfunction add_iframe_resize_listener(node, fn) {\n const computed_style = getComputedStyle(node);\n if (computed_style.position === 'static') {\n node.style.position = 'relative';\n }\n const iframe = element('iframe');\n iframe.setAttribute('style', 'display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; ' +\n 'overflow: hidden; border: 0; opacity: 0; pointer-events: none; z-index: -1;');\n iframe.setAttribute('aria-hidden', 'true');\n iframe.tabIndex = -1;\n const crossorigin = is_crossorigin();\n let unsubscribe;\n if (crossorigin) {\n iframe.src = \"data:text/html,\";\n unsubscribe = listen(window, 'message', (event) => {\n if (event.source === iframe.contentWindow)\n fn();\n });\n }\n else {\n iframe.src = 'about:blank';\n iframe.onload = () => {\n unsubscribe = listen(iframe.contentWindow, 'resize', fn);\n // make sure an initial resize event is fired _after_ the iframe is loaded (which is asynchronous)\n // see https://github.com/sveltejs/svelte/issues/4233\n fn();\n };\n }\n append(node, iframe);\n return () => {\n if (crossorigin) {\n unsubscribe();\n }\n else if (unsubscribe && iframe.contentWindow) {\n unsubscribe();\n }\n detach(iframe);\n };\n}\nconst resize_observer_content_box = /* @__PURE__ */ new ResizeObserverSingleton({ box: 'content-box' });\nconst resize_observer_border_box = /* @__PURE__ */ new ResizeObserverSingleton({ box: 'border-box' });\nconst resize_observer_device_pixel_content_box = /* @__PURE__ */ new ResizeObserverSingleton({ box: 'device-pixel-content-box' });\nfunction toggle_class(element, name, toggle) {\n element.classList[toggle ? 'add' : 'remove'](name);\n}\nfunction custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {\n const e = document.createEvent('CustomEvent');\n e.initCustomEvent(type, bubbles, cancelable, detail);\n return e;\n}\nfunction query_selector_all(selector, parent = document.body) {\n return Array.from(parent.querySelectorAll(selector));\n}\nfunction head_selector(nodeId, head) {\n const result = [];\n let started = 0;\n for (const node of head.childNodes) {\n if (node.nodeType === 8 /* comment node */) {\n const comment = node.textContent.trim();\n if (comment === `HEAD_${nodeId}_END`) {\n started -= 1;\n result.push(node);\n }\n else if (comment === `HEAD_${nodeId}_START`) {\n started += 1;\n result.push(node);\n }\n }\n else if (started > 0) {\n result.push(node);\n }\n }\n return result;\n}\nclass HtmlTag {\n constructor(is_svg = false) {\n this.is_svg = false;\n this.is_svg = is_svg;\n this.e = this.n = null;\n }\n c(html) {\n this.h(html);\n }\n m(html, target, anchor = null) {\n if (!this.e) {\n if (this.is_svg)\n this.e = svg_element(target.nodeName);\n /** #7364 target for