Files
next.orly.dev/app/web/dist/bundle.js
woikos 417866ebf4 feat(curating-ui): add Scan Database button to unclassified users tab
- Adds "Scan Database" button that calls the scanpubkeys API
- Shows results with total pubkeys, events, and skipped count
- Automatically refreshes the unclassified users list after scan

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 18:33:43 +01:00

26 lines
533 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
var app=function(){"use strict";function e(){}function t(e){return e()}function n(){return Object.create(null)}function i(e){e.forEach(t)}function r(e){return"function"==typeof e}function s(e,t){return e!=e?t==t:e!==t||e&&"object"==typeof e||"function"==typeof e}let o;function a(e,t){return o||(o=document.createElement("a")),o.href=t,e===o.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;n<e.length;n+=1)e[n]&&e[n].d(t)}function p(e){return document.createElement(e)}function h(e){return document.createElementNS("http://www.w3.org/2000/svg",e)}function g(e){return document.createTextNode(e)}function m(){return g(" ")}function v(){return g("")}function y(e,t,n,i){return e.addEventListener(t,n,i),()=>e.removeEventListener(t,n,i)}function w(e){return function(t){return t.stopPropagation(),e.call(this,t)}}function b(e,t,n){null==n?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function A(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 C(e,t,n,i){null==n?e.style.removeProperty(t):e.style.setProperty(t,n,i?"important":"")}function E(e,t,n){for(let n=0;n<e.options.length;n+=1){const i=e.options[n];if(i.__value===t)return void(i.selected=!0)}n&&void 0===t||(e.selectedIndex=-1)}function x(e){const t=e.querySelector(":checked");return t&&t.__value}function S(e,t,n){e.classList[n?"add":"remove"](t)}let B;function Q(e){B=e}function F(){if(!B)throw new Error("Function called outside component initialization");return B}function D(e){F().$$.on_mount.push(e)}function $(e){F().$$.on_destroy.push(e)}function P(){const e=F();return(t,n,{cancelable:i=!1}={})=>{const r=e.$$.callbacks[t];if(r){const s=function(e,t,{bubbles:n=!1,cancelable:i=!1}={}){const r=document.createEvent("CustomEvent");return r.initCustomEvent(e,n,i,t),r}(t,n,{cancelable:i});return r.slice().forEach(t=>{t.call(e,s)}),!s.defaultPrevented}return!0}}function R(e,t){const n=e.$$.callbacks[t.type];n&&n.slice().forEach(e=>e.call(this,t))}const T=[],U=[];let _=[];const N=[],L=Promise.resolve();let O=!1;function M(e){_.push(e)}function j(e){N.push(e)}const H=new Set;let G=0;function J(){if(0!==G)return;const e=B;do{try{for(;G<T.length;){const e=T[G];G++,Q(e),K(e.$$)}}catch(e){throw T.length=0,G=0,e}for(Q(null),T.length=0,G=0;U.length;)U.pop()();for(let e=0;e<_.length;e+=1){const t=_[e];H.has(t)||(H.add(t),t())}_.length=0}while(T.length);for(;N.length;)N.pop()();O=!1,H.clear(),Q(e)}function K(e){if(null!==e.fragment){e.update(),i(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(M)}}const V=new Set;let q;function Y(){q={r:0,c:[],p:q}}function W(){q.r||i(q.c),q=q.p}function z(e,t){e&&e.i&&(V.delete(e),e.i(t))}function Z(e,t,n,i){if(e&&e.o){if(V.has(e))return;V.add(e),q.c.push(()=>{V.delete(e),i&&(n&&e.d(1),i())}),e.o(t)}else i&&i()}function X(e,t,n){const i=e.$$.props[t];void 0!==i&&(e.$$.bound[i]=n,n(e.$$.ctx[i]))}function ee(e){e&&e.c()}function te(e,n,s,o){const{fragment:a,after_update:l}=e.$$;a&&a.m(n,s),o||M(()=>{const n=e.$$.on_mount.map(t).filter(r);e.$$.on_destroy?e.$$.on_destroy.push(...n):i(n),e.$$.on_mount=[]}),l.forEach(M)}function ne(e,t){const n=e.$$;null!==n.fragment&&(!function(e){const t=[],n=[];_.forEach(i=>-1===e.indexOf(i)?t.push(i):n.push(i)),n.forEach(e=>e()),_=t}(n.after_update),i(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function ie(e,t){-1===e.$$.dirty[0]&&(T.push(e),O||(O=!0,L.then(J)),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function re(t,r,s,o,a,l,c,u=[-1]){const f=B;Q(t);const p=t.$$={fragment:null,ctx:[],props:l,update:e,not_equal:a,bound:n(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(r.context||(f?f.$$.context:[])),callbacks:n(),dirty:u,skip_bound:!1,root:r.target||f.$$.root};c&&c(p.root);let h=!1;if(p.ctx=s?s(t,r.props||{},(e,n,...i)=>{const r=i.length?i[0]:n;return p.ctx&&a(p.ctx[e],p.ctx[e]=r)&&(!p.skip_bound&&p.bound[e]&&p.bound[e](r),h&&ie(t,e)),n}):[],p.update(),h=!0,i(p.before_update),p.fragment=!!o&&o(p.ctx),r.target){if(r.hydrate){const e=function(e){return Array.from(e.childNodes)}(r.target);p.fragment&&p.fragment.l(e),e.forEach(d)}else p.fragment&&p.fragment.c();r.intro&&z(t.$$.fragment),te(t,r.target,r.anchor,r.customElement),J()}Q(f)}class se{$destroy(){ne(this,1),this.$destroy=e}$on(t,n){if(!r(n))return e;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(n),()=>{const e=i.indexOf(n);-1!==e&&i.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 oe(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function ae(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 le(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 ce="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,ue=e=>e instanceof Uint8Array,de=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),fe=(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 pe(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)),!ue(e))throw new Error("expected Uint8Array, got "+typeof e);return e}let he=class{clone(){return this._cloneInto()}};function ge(e){const t=t=>e().update(pe(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function me(e=32){if(ce&&"function"==typeof ce.getRandomValues)return ce.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}let ve=class extends he{constructor(e,t,n,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=de(this.buffer)}update(e){le(this);const{view:t,buffer:n,blockLen:i}=this,r=(e=pe(e)).length;for(let s=0;s<r;){const o=Math.min(i-this.pos,r-s);if(o===i){const t=de(e);for(;i<=r-s;s+=i)this.process(t,s);continue}n.set(e.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){le(this),function(e,t){ae(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:i,isLE:r}=this;let{pos:s}=this;t[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let e=s;e<i;e++)t[e]=0;!function(e,t,n,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,i);const r=BigInt(32),s=BigInt(4294967295),o=Number(n>>r&s),a=Number(n&s),l=i?4:0,c=i?0:4;e.setUint32(t+l,o,i),e.setUint32(t+c,a,i)}(n,i-8,BigInt(8*this.length),r),this.process(n,0);const o=de(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=a/4,c=this.get();if(l>c.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<l;e++)o.setUint32(4*e,c[e],r)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:i,finished:r,destroyed:s,pos:o}=this;return e.length=i,e.pos=o,e.finished=r,e.destroyed=s,i%t&&e.buffer.set(n),e}};const ye=(e,t,n)=>e&t^~e&n,we=(e,t,n)=>e&t^e&n^t&n,be=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]),Ae=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ke=new Uint32Array(64);let Ie=class extends ve{constructor(){super(64,32,8,!1),this.A=0|Ae[0],this.B=0|Ae[1],this.C=0|Ae[2],this.D=0|Ae[3],this.E=0|Ae[4],this.F=0|Ae[5],this.G=0|Ae[6],this.H=0|Ae[7]}get(){const{A:e,B:t,C:n,D:i,E:r,F:s,G:o,H:a}=this;return[e,t,n,i,r,s,o,a]}set(e,t,n,i,r,s,o,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|i,this.E=0|r,this.F=0|s,this.G=0|o,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)ke[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=ke[e-15],n=ke[e-2],i=fe(t,7)^fe(t,18)^t>>>3,r=fe(n,17)^fe(n,19)^n>>>10;ke[e]=r+ke[e-7]+i+ke[e-16]|0}let{A:n,B:i,C:r,D:s,E:o,F:a,G:l,H:c}=this;for(let e=0;e<64;e++){const t=c+(fe(o,6)^fe(o,11)^fe(o,25))+ye(o,a,l)+be[e]+ke[e]|0,u=(fe(n,2)^fe(n,13)^fe(n,22))+we(n,i,r)|0;c=l,l=a,a=o,o=s+t|0,s=r,r=i,i=n,n=t+u|0}n=n+this.A|0,i=i+this.B|0,r=r+this.C|0,s=s+this.D|0,o=o+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(n,i,r,s,o,a,l,c)}roundClean(){ke.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const Ce=ge(()=>new Ie),Ee=BigInt(0),xe=BigInt(1),Se=BigInt(2),Be=e=>e instanceof Uint8Array,Qe=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Fe(e){if(!Be(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=Qe[e[n]];return t}function De(e){const t=e.toString(16);return 1&t.length?`0${t}`:t}function $e(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":`0x${e}`)}function Pe(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(t/2);for(let t=0;t<n.length;t++){const i=2*t,r=e.slice(i,i+2),s=Number.parseInt(r,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");n[t]=s}return n}function Re(e){return $e(Fe(e))}function Te(e){if(!Be(e))throw new Error("Uint8Array expected");return $e(Fe(Uint8Array.from(e).reverse()))}function Ue(e,t){return Pe(e.toString(16).padStart(2*t,"0"))}function _e(e,t){return Ue(e,t).reverse()}function Ne(e,t,n){let i;if("string"==typeof t)try{i=Pe(t)}catch(n){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${n}`)}else{if(!Be(t))throw new Error(`${e} must be hex string or Uint8Array`);i=Uint8Array.from(t)}const r=i.length;if("number"==typeof n&&r!==n)throw new Error(`${e} expected ${n} bytes, got ${r}`);return i}function Le(...e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;return e.forEach(e=>{if(!Be(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}const Oe=e=>(Se<<BigInt(e-1))-xe,Me=e=>new Uint8Array(e),je=e=>Uint8Array.from(e);function He(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 i=Me(e),r=Me(e),s=0;const o=()=>{i.fill(1),r.fill(0),s=0},a=(...e)=>n(r,i,...e),l=(e=Me())=>{r=a(je([0]),e),i=a(),0!==e.length&&(r=a(je([1]),e),i=a())},c=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){i=a();const t=i.slice();n.push(t),e+=i.length}return Le(...n)};return(e,t)=>{let n;for(o(),l(e);!(n=t(c()));)l();return o(),n}}const Ge={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 i=(t,n,i)=>{const r=Ge[n];if("function"!=typeof r)throw new Error(`Invalid validator "${n}", expected function`);const s=e[t];if(!(i&&void 0===s||r(s,e)))throw new Error(`Invalid param ${String(t)}=${s} (${typeof s}), expected ${n}`)};for(const[e,n]of Object.entries(t))i(e,n,!1);for(const[e,t]of Object.entries(n))i(e,t,!0);return e}var Ke=Object.freeze({__proto__:null,bitGet:function(e,t){return e>>BigInt(t)&xe},bitLen:function(e){let t;for(t=0;e>Ee;e>>=xe,t+=1);return t},bitMask:Oe,bitSet:(e,t,n)=>e|(n?xe:Ee)<<BigInt(t),bytesToHex:Fe,bytesToNumberBE:Re,bytesToNumberLE:Te,concatBytes:Le,createHmacDrbg:He,ensureBytes:Ne,equalBytes:function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},hexToBytes:Pe,hexToNumber:$e,numberToBytesBE:Ue,numberToBytesLE:_e,numberToHexUnpadded:De,numberToVarBytesBE:function(e){return Pe(De(e))},utf8ToBytes:function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))},validateObject:Je});
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ve=BigInt(0),qe=BigInt(1),Ye=BigInt(2),We=BigInt(3),ze=BigInt(4),Ze=BigInt(5),Xe=BigInt(8);function et(e,t){const n=e%t;return n>=Ve?n:t+n}function tt(e,t,n){if(n<=Ve||t<Ve)throw new Error("Expected power/modulo > 0");if(n===qe)return Ve;let i=qe;for(;t>Ve;)t&qe&&(i=i*e%n),e=e*e%n,t>>=qe;return i}function nt(e,t,n){let i=e;for(;t-- >Ve;)i*=i,i%=n;return i}function it(e,t){if(e===Ve||t<=Ve)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=et(e,t),i=t,r=Ve,s=qe;for(;n!==Ve;){const e=i%n,t=r-s*(i/n);i=n,n=e,r=s,s=t}if(i!==qe)throw new Error("invert: does not exist");return et(r,t)}function rt(e){if(e%ze===We){const t=(e+qe)/ze;return function(e,n){const i=e.pow(n,t);if(!e.eql(e.sqr(i),n))throw new Error("Cannot find square root");return i}}if(e%Xe===Ze){const t=(e-Ze)/Xe;return function(e,n){const i=e.mul(n,Ye),r=e.pow(i,t),s=e.mul(n,r),o=e.mul(e.mul(s,Ye),r),a=e.mul(s,e.sub(o,e.ONE));if(!e.eql(e.sqr(a),n))throw new Error("Cannot find square root");return a}}return function(e){const t=(e-qe)/Ye;let n,i,r;for(n=e-qe,i=0;n%Ye===Ve;n/=Ye,i++);for(r=Ye;r<e&&tt(r,t,e)!==e-qe;r++);if(1===i){const t=(e+qe)/ze;return function(e,n){const i=e.pow(n,t);if(!e.eql(e.sqr(i),n))throw new Error("Cannot find square root");return i}}const s=(n+qe)/Ye;return function(e,o){if(e.pow(o,t)===e.neg(e.ONE))throw new Error("Cannot find square root");let a=i,l=e.pow(e.mul(e.ONE,r),n),c=e.pow(o,s),u=e.pow(o,n);for(;!e.eql(u,e.ONE);){if(e.eql(u,e.ZERO))return e.ZERO;let t=1;for(let n=e.sqr(u);t<a&&!e.eql(n,e.ONE);t++)n=e.sqr(n);const n=e.pow(l,qe<<BigInt(a-t-1));l=e.sqr(n),c=e.mul(c,n),u=e.mul(u,l),a=t}return c}}(e)}BigInt(9),BigInt(16);const st=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ot(e,t){const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function at(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 lt(e){const t=at(e);return t+Math.ceil(t/2)}
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const ct=BigInt(0),ut=BigInt(1);function dt(e){return function(e){const t=st.reduce((e,t)=>(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({...ot(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const{bytesToNumberBE:ft,hexToBytes:pt}=Ke,ht={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(e){const{Err:t}=ht;if(e.length<2||2!==e[0])throw new t("Invalid signature integer tag");const n=e[1],i=e.subarray(2,n+2);if(!n||i.length!==n)throw new t("Invalid signature integer: wrong length");if(128&i[0])throw new t("Invalid signature integer: negative");if(0===i[0]&&!(128&i[1]))throw new t("Invalid signature integer: unnecessary leading zero");return{d:ft(i),l:e.subarray(n+2)}},toSig(e){const{Err:t}=ht,n="string"==typeof e?pt(e):e;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let i=n.length;if(i<2||48!=n[0])throw new t("Invalid signature tag");if(n[1]!==i-2)throw new t("Invalid signature: incorrect length");const{d:r,l:s}=ht._parseInt(n.subarray(2)),{d:o,l:a}=ht._parseInt(s);if(a.length)throw new t("Invalid signature: left bytes after parsing");return{r:r,s:o}},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},i=t(n(e.s)),r=t(n(e.r)),s=i.length/2,o=r.length/2,a=n(s),l=n(o);return`30${n(o+s+4)}02${l}${r}02${a}${i}`}},gt=BigInt(0),mt=BigInt(1);BigInt(2);const vt=BigInt(3);function yt(e){const t=function(e){const t=dt(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:i,a:r}=t;if(n){if(!i.eql(r,i.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,i=t.toBytes||((e,t,i)=>{const r=t.toAffine();return Le(Uint8Array.from([4]),n.toBytes(r.x),n.toBytes(r.y))}),r=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 s(e){const{a:i,b:r}=t,s=n.sqr(e),o=n.mul(s,e);return n.add(n.add(o,n.mul(e,i)),r)}if(!n.eql(n.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function o(e){return"bigint"==typeof e&&gt<e&&e<t.n}function a(e){if(!o(e))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function l(e){const{allowedPrivateKeyLengths:n,nByteLength:i,wrapPrivateKey:r,n:s}=t;if(n&&"bigint"!=typeof e){if(e instanceof Uint8Array&&(e=Fe(e)),"string"!=typeof e||!n.includes(e.length))throw new Error("Invalid key");e=e.padStart(2*i,"0")}let o;try{o="bigint"==typeof e?e:Re(Ne("private key",e,i))}catch(t){throw new Error(`private key must be ${i} bytes, hex or bigint, not ${typeof e}`)}return r&&(o=et(o,s)),a(o),o}const c=new Map;function u(e){if(!(e instanceof d))throw new Error("ProjectivePoint expected")}class d{constructor(e,t,i){if(this.px=e,this.py=t,this.pz=i,null==e||!n.isValid(e))throw new Error("x required");if(null==t||!n.isValid(t))throw new Error("y required");if(null==i||!n.isValid(i))throw new Error("z required")}static fromAffine(e){const{x:t,y:i}=e||{};if(!e||!n.isValid(t)||!n.isValid(i))throw new Error("invalid affine point");if(e instanceof d)throw new Error("projective point not allowed");const r=e=>n.eql(e,n.ZERO);return r(t)&&r(i)?d.ZERO:new d(t,i,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(r(Ne("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:i}=this.toAffine();if(!n.isValid(e)||!n.isValid(i))throw new Error("bad point: x or y not FE");const r=n.sqr(i),o=s(e);if(!n.eql(r,o))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){u(e);const{px:t,py:i,pz:r}=this,{px:s,py:o,pz:a}=e,l=n.eql(n.mul(t,a),n.mul(s,r)),c=n.eql(n.mul(i,a),n.mul(o,r));return l&&c}negate(){return new d(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:i}=t,r=n.mul(i,vt),{px:s,py:o,pz:a}=this;let l=n.ZERO,c=n.ZERO,u=n.ZERO,f=n.mul(s,s),p=n.mul(o,o),h=n.mul(a,a),g=n.mul(s,o);return g=n.add(g,g),u=n.mul(s,a),u=n.add(u,u),l=n.mul(e,u),c=n.mul(r,h),c=n.add(l,c),l=n.sub(p,c),c=n.add(p,c),c=n.mul(l,c),l=n.mul(g,l),u=n.mul(r,u),h=n.mul(e,h),g=n.sub(f,h),g=n.mul(e,g),g=n.add(g,u),u=n.add(f,f),f=n.add(u,f),f=n.add(f,h),f=n.mul(f,g),c=n.add(c,f),h=n.mul(o,a),h=n.add(h,h),f=n.mul(h,g),l=n.sub(l,f),u=n.mul(h,p),u=n.add(u,u),u=n.add(u,u),new d(l,c,u)}add(e){u(e);const{px:i,py:r,pz:s}=this,{px:o,py:a,pz:l}=e;let c=n.ZERO,f=n.ZERO,p=n.ZERO;const h=t.a,g=n.mul(t.b,vt);let m=n.mul(i,o),v=n.mul(r,a),y=n.mul(s,l),w=n.add(i,r),b=n.add(o,a);w=n.mul(w,b),b=n.add(m,v),w=n.sub(w,b),b=n.add(i,s);let A=n.add(o,l);return b=n.mul(b,A),A=n.add(m,y),b=n.sub(b,A),A=n.add(r,s),c=n.add(a,l),A=n.mul(A,c),c=n.add(v,y),A=n.sub(A,c),p=n.mul(h,b),c=n.mul(g,y),p=n.add(c,p),c=n.sub(v,p),p=n.add(v,p),f=n.mul(c,p),v=n.add(m,m),v=n.add(v,m),y=n.mul(h,y),b=n.mul(g,b),v=n.add(v,y),y=n.sub(m,y),y=n.mul(h,y),b=n.add(b,y),m=n.mul(v,b),f=n.add(f,m),m=n.mul(A,b),c=n.mul(w,c),c=n.sub(c,m),m=n.mul(w,v),p=n.mul(A,p),p=n.add(p,m),new d(c,f,p)}subtract(e){return this.add(e.negate())}is0(){return this.equals(d.ZERO)}wNAF(e){return p.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 i=d.ZERO;if(e===gt)return i;if(a(e),e===mt)return this;const{endo:r}=t;if(!r)return p.unsafeLadder(this,e);let{k1neg:s,k1:o,k2neg:l,k2:c}=r.splitScalar(e),u=i,f=i,h=this;for(;o>gt||c>gt;)o&mt&&(u=u.add(h)),c&mt&&(f=f.add(h)),h=h.double(),o>>=mt,c>>=mt;return s&&(u=u.negate()),l&&(f=f.negate()),f=new d(n.mul(f.px,r.beta),f.py,f.pz),u.add(f)}multiply(e){a(e);let i,r,s=e;const{endo:o}=t;if(o){const{k1neg:e,k1:t,k2neg:a,k2:l}=o.splitScalar(s);let{p:c,f:u}=this.wNAF(t),{p:f,f:h}=this.wNAF(l);c=p.constTimeNegate(e,c),f=p.constTimeNegate(a,f),f=new d(n.mul(f.px,o.beta),f.py,f.pz),i=c.add(f),r=u.add(h)}else{const{p:e,f:t}=this.wNAF(s);i=e,r=t}return d.normalizeZ([i,r])[0]}multiplyAndAddUnsafe(e,t,n){const i=d.BASE,r=(e,t)=>t!==gt&&t!==mt&&e.equals(i)?e.multiply(t):e.multiplyUnsafe(t),s=r(this,t).add(r(e,n));return s.is0()?void 0:s}toAffine(e){const{px:t,py:i,pz:r}=this,s=this.is0();null==e&&(e=s?n.ONE:n.inv(r));const o=n.mul(t,e),a=n.mul(i,e),l=n.mul(r,e);if(s)return{x:n.ZERO,y:n.ZERO};if(!n.eql(l,n.ONE))throw new Error("invZ was invalid");return{x:o,y:a}}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e===mt)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===mt?this:n?n(d,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),i(d,this,e)}toHex(e=!0){return Fe(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,p=function(e,t){const n=(e,t)=>{const n=t.negate();return e?n:t},i=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:n,unsafeLadder(t,n){let i=e.ZERO,r=t;for(;n>ct;)n&ut&&(i=i.add(r)),r=r.double(),n>>=ut;return i},precomputeWindow(e,t){const{windows:n,windowSize:r}=i(t),s=[];let o=e,a=o;for(let e=0;e<n;e++){a=o,s.push(a);for(let e=1;e<r;e++)a=a.add(o),s.push(a);o=a.double()}return s},wNAF(t,r,s){const{windows:o,windowSize:a}=i(t);let l=e.ZERO,c=e.BASE;const u=BigInt(2**t-1),d=2**t,f=BigInt(t);for(let e=0;e<o;e++){const t=e*a;let i=Number(s&u);s>>=f,i>a&&(i-=d,s+=ut);const o=t,p=t+Math.abs(i)-1,h=e%2!=0,g=i<0;0===i?c=c.add(n(h,r[o])):l=l.add(n(g,r[p]))}return{p:l,f:c}},wNAFCached(e,t,n,i){const r=e._WINDOW_SIZE||1;let s=t.get(e);return s||(s=this.precomputeWindow(e,r),1!==r&&t.set(e,i(s))),this.wNAF(r,s,n)}}}(d,t.endo?Math.ceil(f/2):f);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:l,weierstrassEquation:s,isWithinCurveOrder:o}}function wt(e){const t=function(e){const t=dt(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:i}=t,r=n.BYTES+1,s=2*n.BYTES+1;function o(e){return et(e,i)}function a(e){return it(e,i)}const{ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:u,isWithinCurveOrder:d}=yt({...t,toBytes(e,t,i){const r=t.toAffine(),s=n.toBytes(r.x),o=Le;return i?o(Uint8Array.from([t.hasEvenY()?2:3]),s):o(Uint8Array.from([4]),s,n.toBytes(r.y))},fromBytes(e){const t=e.length,i=e[0],o=e.subarray(1);if(t!==r||2!==i&&3!==i){if(t===s&&4===i){return{x:n.fromBytes(o.subarray(0,n.BYTES)),y:n.fromBytes(o.subarray(n.BYTES,2*n.BYTES))}}throw new Error(`Point of length ${t} was invalid. Expected ${r} compressed bytes or ${s} uncompressed bytes`)}{const e=Re(o);if(!(gt<(a=e)&&a<n.ORDER))throw new Error("Point is not on curve");const t=u(e);let r=n.sqrt(t);return!(1&~i)!==((r&mt)===mt)&&(r=n.neg(r)),{x:e,y:r}}var a}}),f=e=>Fe(Ue(e,t.nByteLength));function p(e){return e>i>>mt}const h=(e,t,n)=>Re(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=Ne("compactSignature",e,2*n),new g(h(e,0,n),h(e,n,2*n))}static fromDER(e){const{r:t,s:n}=ht.toSig(Ne("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:i,s:r,recovery:s}=this,c=w(Ne("msgHash",e));if(null==s||![0,1,2,3].includes(s))throw new Error("recovery id invalid");const u=2===s||3===s?i+t.n:i;if(u>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const d=1&s?"03":"02",p=l.fromHex(d+f(u)),h=a(u),g=o(-c*h),m=o(r*h),v=l.BASE.multiplyAndAddUnsafe(p,g,m);if(!v)throw new Error("point at infinify");return v.assertValidity(),v}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Pe(this.toDERHex())}toDERHex(){return ht.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Pe(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=lt(t.n);return function(e,t,n=!1){const i=e.length,r=at(t),s=lt(t);if(i<16||i<s||i>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${i}`);const o=et(n?Re(e):Te(e),t-qe)+qe;return n?_e(o,r):Ue(o,r)}(t.randomBytes(e),t.n)},precompute:(e=8,t=l.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function v(e){const t=e instanceof Uint8Array,n="string"==typeof e,i=(t||n)&&e.length;return t?i===r||i===s:n?i===2*r||i===2*s:e instanceof l}const y=t.bits2int||function(e){const n=Re(e),i=8*e.length-t.nBitLength;return i>0?n>>BigInt(i):n},w=t.bits2int_modN||function(e){return o(y(e))},b=Oe(t.nBitLength);function A(e){if("bigint"!=typeof e)throw new Error("bigint expected");if(!(gt<=e&&e<b))throw new Error(`bigint expected < 2^${t.nBitLength}`);return Ue(e,t.nByteLength)}function k(e,i,r=I){if(["recovered","canonical"].some(e=>e in r))throw new Error("sign() legacy options not supported");const{hash:s,randomBytes:u}=t;let{lowS:f,prehash:h,extraEntropy:m}=r;null==f&&(f=!0),e=Ne("msgHash",e),h&&(e=Ne("prehashed msgHash",s(e)));const v=w(e),b=c(i),k=[A(b),A(v)];if(null!=m){const e=!0===m?u(n.BYTES):m;k.push(Ne("extraEntropy",e))}const C=Le(...k),E=v;return{seed:C,k2sig:function(e){const t=y(e);if(!d(t))return;const n=a(t),i=l.BASE.multiply(t).toAffine(),r=o(i.x);if(r===gt)return;const s=o(n*o(E+r*b));if(s===gt)return;let c=(i.x===r?0:2)|Number(i.y&mt),u=s;return f&&p(s)&&(u=function(e){return p(e)?o(-e):e}(s),c^=1),new g(r,u,c)}}}const I={lowS:t.lowS,prehash:!1},C={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(v(e))throw new Error("first arg must be private key");if(!v(t))throw new Error("second arg must be public key");return l.fromHex(t).multiply(c(e)).toRawBytes(n)},sign:function(e,n,i=I){const{seed:r,k2sig:s}=k(e,n,i),o=t;return He(o.hash.outputLen,o.nByteLength,o.hmac)(r,s)},verify:function(e,n,i,r=C){const s=e;if(n=Ne("msgHash",n),i=Ne("publicKey",i),"strict"in r)throw new Error("options.strict was renamed to lowS");const{lowS:c,prehash:u}=r;let d,f;try{if("string"==typeof s||s instanceof Uint8Array)try{d=g.fromDER(s)}catch(e){if(!(e instanceof ht.Err))throw e;d=g.fromCompact(s)}else{if("object"!=typeof s||"bigint"!=typeof s.r||"bigint"!=typeof s.s)throw new Error("PARSE");{const{r:e,s:t}=s;d=new g(e,t)}}f=l.fromHex(i)}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:p,s:h}=d,m=w(n),v=a(h),y=o(m*v),b=o(p*v),A=l.BASE.multiplyAndAddUnsafe(f,y,b)?.toAffine();return!!A&&o(A.x)===p},ProjectivePoint:l,Signature:g,utils:m}}BigInt(4);let bt=class extends he{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");oe(e.outputLen),oe(e.blockLen)}(e);const n=pe(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 i=this.blockLen,r=new Uint8Array(i);r.set(n.length>i?e.create().update(n).digest():n);for(let e=0;e<r.length;e++)r[e]^=54;this.iHash.update(r),this.oHash=e.create();for(let e=0;e<r.length;e++)r[e]^=106;this.oHash.update(r),r.fill(0)}update(e){return le(this),this.iHash.update(e),this}digestInto(e){le(this),ae(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:i,destroyed:r,blockLen:s,outputLen:o}=this;return e.finished=i,e.destroyed=r,e.blockLen=s,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const At=(e,t,n)=>new bt(e,t).update(n).digest();
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
function kt(e){return{hash:e,hmac:(t,...n)=>At(e,t,function(...e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;return e.forEach(e=>{if(!ue(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}(...n)),randomBytes:me}}At.create=(e,t)=>new bt(e,t);
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const It=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ct=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Et=BigInt(1),xt=BigInt(2),St=(e,t)=>(e+t/xt)/t;function Bt(e){const t=It,n=BigInt(3),i=BigInt(6),r=BigInt(11),s=BigInt(22),o=BigInt(23),a=BigInt(44),l=BigInt(88),c=e*e*e%t,u=c*c*e%t,d=nt(u,n,t)*u%t,f=nt(d,n,t)*u%t,p=nt(f,xt,t)*c%t,h=nt(p,r,t)*p%t,g=nt(h,s,t)*h%t,m=nt(g,a,t)*g%t,v=nt(m,l,t)*m%t,y=nt(v,a,t)*g%t,w=nt(y,n,t)*u%t,b=nt(w,o,t)*h%t,A=nt(b,i,t)*c%t,k=nt(A,xt,t);if(!Qt.eql(Qt.sqr(k),e))throw new Error("Cannot find square root");return k}const Qt=function(e,t,n=!1,i={}){if(e<=Ve)throw new Error(`Expected Field ORDER > 0, got ${e}`);const{nBitLength:r,nByteLength:s}=ot(e,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=rt(e),a=Object.freeze({ORDER:e,BITS:r,BYTES:s,MASK:Oe(r),ZERO:Ve,ONE:qe,create:t=>et(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return Ve<=t&&t<e},is0:e=>e===Ve,isOdd:e=>(e&qe)===qe,neg:t=>et(-t,e),eql:(e,t)=>e===t,sqr:t=>et(t*t,e),add:(t,n)=>et(t+n,e),sub:(t,n)=>et(t-n,e),mul:(t,n)=>et(t*n,e),pow:(e,t)=>function(e,t,n){if(n<Ve)throw new Error("Expected power > 0");if(n===Ve)return e.ONE;if(n===qe)return t;let i=e.ONE,r=t;for(;n>Ve;)n&qe&&(i=e.mul(i,r)),r=e.sqr(r),n>>=qe;return i}(a,e,t),div:(t,n)=>et(t*it(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>it(t,e),sqrt:i.sqrt||(e=>o(a,e)),invertBatch:e=>function(e,t){const n=new Array(t.length),i=t.reduce((t,i,r)=>e.is0(i)?t:(n[r]=t,e.mul(t,i)),e.ONE),r=e.inv(i);return t.reduceRight((t,i,r)=>e.is0(i)?t:(n[r]=e.mul(t,n[r]),e.mul(t,i)),r),n}(a,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?_e(e,s):Ue(e,s),fromBytes:e=>{if(e.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${e.length}`);return n?Te(e):Re(e)}});return Object.freeze(a)}(It,void 0,void 0,{sqrt:Bt}),Ft=function(e,t){const n=t=>wt({...e,...kt(t)});return Object.freeze({...n(t),create:n})}({a:BigInt(0),b:BigInt(7),Fp:Qt,n:Ct,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=Ct,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),i=-Et*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),r=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,o=BigInt("0x100000000000000000000000000000000"),a=St(s*e,t),l=St(-i*e,t);let c=et(e-a*n-l*r,t),u=et(-a*i-l*s,t);const d=c>o,f=u>o;if(d&&(c=t-c),f&&(u=t-u),c>o||u>o)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:d,k1:c,k2neg:f,k2:u}}}},Ce),Dt=BigInt(0),$t=e=>"bigint"==typeof e&&Dt<e&&e<It,Pt={};function Rt(e,...t){let n=Pt[e];if(void 0===n){const t=Ce(Uint8Array.from(e,e=>e.charCodeAt(0)));n=Le(t,t),Pt[e]=n}return Ce(Le(n,...t))}const Tt=e=>e.toRawBytes(!0).slice(1),Ut=e=>Ue(e,32),_t=e=>et(e,It),Nt=e=>et(e,Ct),Lt=Ft.ProjectivePoint;function Ot(e){let t=Ft.utils.normPrivateKeyToScalar(e),n=Lt.fromPrivateKey(t);return{scalar:n.hasEvenY()?t:Nt(-t),bytes:Tt(n)}}function Mt(e){if(!$t(e))throw new Error("bad x: need 0 < x < p");const t=_t(e*e);let n=Bt(_t(t*e+BigInt(7)));n%xt!==Dt&&(n=_t(-n));const i=new Lt(e,n,Et);return i.assertValidity(),i}function jt(...e){return Nt(Re(Rt("BIP0340/challenge",...e)))}function Ht(e){return Ot(e).bytes}function Gt(e,t,n=me(32)){const i=Ne("message",e),{bytes:r,scalar:s}=Ot(t),o=Ne("auxRand",n,32),a=Ut(s^Re(Rt("BIP0340/aux",o))),l=Rt("BIP0340/nonce",a,r,i),c=Nt(Re(l));if(c===Dt)throw new Error("sign failed: k is zero");const{bytes:u,scalar:d}=Ot(c),f=jt(u,r,i),p=new Uint8Array(64);if(p.set(u,0),p.set(Ut(Nt(d+f*s)),32),!Jt(p,i,r))throw new Error("sign: Invalid signature produced");return p}function Jt(e,t,n){const i=Ne("signature",e,64),r=Ne("message",t),s=Ne("publicKey",n,32);try{const e=Mt(Re(s)),t=Re(i.subarray(0,32));if(!$t(t))return!1;const n=Re(i.subarray(32,64));if(!("bigint"==typeof(c=n)&&Dt<c&&c<Ct))return!1;const u=jt(Ut(t),Tt(e),r),d=(o=e,a=n,l=Nt(-u),Lt.BASE.multiplyAndAddUnsafe(o,a,l));return!(!d||!d.hasEvenY()||d.toAffine().x!==t)}catch(e){return!1}var o,a,l,c}const Kt=(()=>({getPublicKey:Ht,sign:Gt,verify:Jt,utils:{randomPrivateKey:Ft.utils.randomPrivateKey,lift_x:Mt,pointToBytes:Tt,numberToBytesBE:Ue,bytesToNumberBE:Re,taggedHash:Rt,mod:et}}))(),Vt="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,qt=e=>e instanceof Uint8Array,Yt=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),Wt=(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 zt=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Zt(e){if(!qt(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=zt[e[n]];return t}function Xt(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(t/2);for(let t=0;t<n.length;t++){const i=2*t,r=e.slice(i,i+2),s=Number.parseInt(r,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");n[t]=s}return n}function en(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)),!qt(e))throw new Error("expected Uint8Array, got "+typeof e);return e}function tn(...e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;return e.forEach(e=>{if(!qt(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}class nn{clone(){return this._cloneInto()}}function rn(e){const t=t=>e().update(en(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function sn(e=32){if(Vt&&"function"==typeof Vt.getRandomValues)return Vt.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}function on(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function an(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 ln={number:on,bool:function(e){if("boolean"!=typeof e)throw new Error(`Expected boolean, not ${e}`)},bytes:an,hash:function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");on(e.outputLen),on(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){an(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}};class cn extends nn{constructor(e,t,n,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Yt(this.buffer)}update(e){ln.exists(this);const{view:t,buffer:n,blockLen:i}=this,r=(e=en(e)).length;for(let s=0;s<r;){const o=Math.min(i-this.pos,r-s);if(o===i){const t=Yt(e);for(;i<=r-s;s+=i)this.process(t,s);continue}n.set(e.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){ln.exists(this),ln.output(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:i,isLE:r}=this;let{pos:s}=this;t[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let e=s;e<i;e++)t[e]=0;!function(e,t,n,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,i);const r=BigInt(32),s=BigInt(4294967295),o=Number(n>>r&s),a=Number(n&s),l=i?4:0,c=i?0:4;e.setUint32(t+l,o,i),e.setUint32(t+c,a,i)}(n,i-8,BigInt(8*this.length),r),this.process(n,0);const o=Yt(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=a/4,c=this.get();if(l>c.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<l;e++)o.setUint32(4*e,c[e],r)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:i,finished:r,destroyed:s,pos:o}=this;return e.length=i,e.pos=o,e.finished=r,e.destroyed=s,i%t&&e.buffer.set(n),e}}const un=(e,t,n)=>e&t^~e&n,dn=(e,t,n)=>e&t^e&n^t&n,fn=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]),pn=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),hn=new Uint32Array(64);class gn extends cn{constructor(){super(64,32,8,!1),this.A=0|pn[0],this.B=0|pn[1],this.C=0|pn[2],this.D=0|pn[3],this.E=0|pn[4],this.F=0|pn[5],this.G=0|pn[6],this.H=0|pn[7]}get(){const{A:e,B:t,C:n,D:i,E:r,F:s,G:o,H:a}=this;return[e,t,n,i,r,s,o,a]}set(e,t,n,i,r,s,o,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|i,this.E=0|r,this.F=0|s,this.G=0|o,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)hn[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=hn[e-15],n=hn[e-2],i=Wt(t,7)^Wt(t,18)^t>>>3,r=Wt(n,17)^Wt(n,19)^n>>>10;hn[e]=r+hn[e-7]+i+hn[e-16]|0}let{A:n,B:i,C:r,D:s,E:o,F:a,G:l,H:c}=this;for(let e=0;e<64;e++){const t=c+(Wt(o,6)^Wt(o,11)^Wt(o,25))+un(o,a,l)+fn[e]+hn[e]|0,u=(Wt(n,2)^Wt(n,13)^Wt(n,22))+dn(n,i,r)|0;c=l,l=a,a=o,o=s+t|0,s=r,r=i,i=n,n=t+u|0}n=n+this.A|0,i=i+this.B|0,r=r+this.C|0,s=s+this.D|0,o=o+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(n,i,r,s,o,a,l,c)}roundClean(){hn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class mn extends gn{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=rn(()=>new gn);rn(()=>new mn);var yn=Symbol("verified");function wn(e){if(!(e instanceof Object))return!1;if("number"!=typeof e.kind)return!1;if("string"!=typeof e.content)return!1;if("number"!=typeof e.created_at)return!1;if("string"!=typeof e.pubkey)return!1;if(!e.pubkey.match(/^[a-f0-9]{64}$/))return!1;if(!Array.isArray(e.tags))return!1;for(let t=0;t<e.tags.length;t++){let n=e.tags[t];if(!Array.isArray(n))return!1;for(let e=0;e<n.length;e++)if("string"!=typeof n[e])return!1}return!0}new TextDecoder("utf-8");var bn=new TextEncoder;function An(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}`)}}var kn=class{value;next=null;prev=null;constructor(e){this.value=e}},In=class{first;last;constructor(){this.first=null,this.last=null}enqueue(e){const t=new kn(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 Cn(e){return Zt(vn(bn.encode(function(e){if(!wn(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 En=new class{generateSecretKey(){return Kt.utils.randomPrivateKey()}getPublicKey(e){return Zt(Kt.getPublicKey(e))}finalizeEvent(e,t){const n=e;return n.pubkey=Zt(Kt.getPublicKey(t)),n.id=Cn(n),n.sig=Zt(Kt.sign(Cn(n),t)),n[yn]=!0,n}verifyEvent(e){if("boolean"==typeof e[yn])return e[yn];const t=Cn(e);if(t!==e.id)return e[yn]=!1,!1;try{const n=Kt.verify(e.sig,t,e.pubkey);return e[yn]=n,n}catch(t){return e[yn]=!1,!1}}};En.generateSecretKey,En.getPublicKey,En.finalizeEvent;var xn=En.verifyEvent;function Sn(e,t){if(e.ids&&-1===e.ids.indexOf(t.id))return!1;if(e.kinds&&-1===e.kinds.indexOf(t.kind))return!1;if(e.authors&&-1===e.authors.indexOf(t.pubkey))return!1;for(let n in e)if("#"===n[0]){let i=e[`#${n.slice(1)}`];if(i&&!t.tags.find(([e,t])=>e===n.slice(1)&&-1!==i.indexOf(t)))return!1}return!(e.since&&t.created_at<e.since)&&!(e.until&&t.created_at>e.until)}async function Bn(){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 Qn,Fn=e=>(e[yn]=!0,!0),Dn=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 In;queueRunning=!1;challenge;authPromise;serial=0;verifyEvent;_WebSocket;constructor(e,t){this.url=An(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 Bn();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 i=t+7+1+n,r=e.slice(i+1,80).indexOf('"');if(-1===r)return null;let s=i+1+r;return e.slice(i+1,s)}(e);if(t){const n=this.openSubs.get(t);if(!n)return;const i=function(e,t){let n=t.length+3,i=e.indexOf(`"${t}":`)+n,r=e.slice(i).indexOf('"')+i+1;return e.slice(r,r+64)}(e,"id"),r=n.alreadyHaveEvent?.(i);if(n.receivedEvent?.(this,i),r)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<e.length;n++)if(Sn(e[n],t))return!0;return!1}(e.filters,n)&&e.onevent(n))}case"COUNT":{const e=t[1],n=t[2],i=this.openCountRequests.get(e);return void(i&&(i.resolve(n.count),this.openCountRequests.delete(e)))}case"EOSE":{const e=this.openSubs.get(t[1]);if(!e)return;return void e.receivedEose()}case"OK":{const e=t[1],n=t[2],i=t[3],r=this.openEventPublishes.get(e);return void(r&&(clearTimeout(r.timeout),n?r.resolve(i):r.reject(new Error(i)),this.openEventPublishes.delete(e)))}case"CLOSED":{const e=t[1],n=this.openSubs.get(e);if(!n)return;return n.closed=!0,void n.close(t[2])}case"NOTICE":return void this.onnotice(t[1]);case"AUTH":return void(this.challenge=t[1])}}catch(e){return}}async send(e){if(!this.connectionPromise)throw new Dn(e,this.url);this.connectionPromise.then(()=>{this.ws?.send(e)})}async auth(e){const t=this.challenge;if(!t)throw new Error("can't perform auth, no challenge was received");return this.authPromise||(this.authPromise=new Promise(async(n,i)=>{try{let r=await e(function(e,t){return{kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",e],["challenge",t]],content:""}}(this.url,t)),s=setTimeout(()=>{let e=this.openEventPublishes.get(r.id);e&&(e.reject(new Error("auth timed out")),this.openEventPublishes.delete(r.id))},this.publishTimeout);this.openEventPublishes.set(r.id,{resolve:n,reject:i,timeout:s}),this.send('["AUTH",'+JSON.stringify(r)+"]")}catch(e){console.warn("subscribe auth function failed:",e)}})),this.authPromise}async publish(e){const t=new Promise((t,n)=>{const i=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:i})});return this.send('["EVENT",'+JSON.stringify(e)+"]"),t}async count(e,t){this.serial++;const n=t?.id||"count:"+this.serial,i=new Promise((e,t)=>{this.openCountRequests.set(n,{resolve:e,reject:t})});return this.send('["COUNT","'+n+'",'+JSON.stringify(e).substring(1)),i}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,i=new Pn(this,n,e,t);return this.openSubs.set(n,i),i}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()}},Pn=class{relay;id;closed=!1;eosed=!1;filters;alreadyHaveEvent;receivedEvent;onevent;oneose;onclose;eoseTimeout;eoseTimeoutHandle;constructor(e,t,n,i){this.relay=e,this.filters=n,this.id=t,this.alreadyHaveEvent=i.alreadyHaveEvent,this.receivedEvent=i.receivedEvent,this.eoseTimeout=i.eoseTimeout||e.baseEoseTimeout,this.oneose=i.oneose,this.onclose=i.onclose,this.onevent=i.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 Dn))throw e}this.closed=!0}this.relay.openSubs.delete(this.id),this.onclose?.(e)}},Rn=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=An(e);let n=this.relays.get(e);return n||(n=new $n(e,{verifyEvent:this.trustedRelayURLs.has(e)?Fn: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(An).forEach(e=>{this.relays.get(e)?.close(),this.relays.delete(e)})}subscribe(e,t,n){n.onauth=n.onauth||n.doauth;const i=[];for(let n=0;n<e.length;n++){const r=An(e[n]);i.find(e=>e.url===r)||i.push({url:r,filter:t})}return this.subscribeMap(i,n)}subscribeMany(e,t,n){n.onauth=n.onauth||n.doauth;const i=[],r=[];for(let n=0;n<e.length;n++){const s=An(e[n]);-1===r.indexOf(s)&&(r.push(s),i.push({url:s,filter:t}))}return this.subscribeMap(i,n)}subscribeMap(e,t){t.onauth=t.onauth||t.doauth;const n=new Map;for(const t of e){const{url:e,filter:i}=t;n.has(e)||n.set(e,[]),n.get(e).push(i)}const i=Array.from(n.entries()).map(([e,t])=>({url:e,filters:t}));this.trackRelays&&(t.receivedEvent=(e,t)=>{let n=this.seenOn.get(t);n||(n=new Set,this.seenOn.set(t,n)),n.add(e)});const r=new Set,s=[],o=[];let a=n=>{o[n]||(o[n]=!0,o.filter(e=>e).length===e.length&&(t.oneose?.(),a=()=>{}))};const l=[];let c=(n,i)=>{l[n]||(a(n),l[n]=i,l.filter(e=>e).length===e.length&&(t.onclose?.(l),c=()=>{}))};const u=e=>{if(t.alreadyHaveEvent?.(e))return!0;const n=r.has(e);return r.add(e),n},d=Promise.all(i.map(async({url:e,filters:n},i)=>{let r;try{r=await this.ensureRelay(e,{connectionTimeout:t.maxWait?Math.max(.8*t.maxWait,t.maxWait-1e3):void 0})}catch(e){return void c(i,e?.message||String(e))}let o=r.subscribe(n,{...t,oneose:()=>a(i),onclose:e=>{e.startsWith("auth-required: ")&&t.onauth?r.auth(t.onauth).then(()=>{r.subscribe(n,{...t,oneose:()=>a(i),onclose:e=>{c(i,e)},alreadyHaveEvent:u,eoseTimeout:t.maxWait})}).catch(e=>{c(i,`auth was required and attempted, but failed with: ${e}`)}):c(i,e)},alreadyHaveEvent:u,eoseTimeout:t.maxWait});s.push(o)}));return{async close(e){await d,s.forEach(t=>{t.close(e)})}}}subscribeEose(e,t,n){n.onauth=n.onauth||n.doauth;const i=this.subscribe(e,t,{...n,oneose(){i.close("closed automatically on eose")}});return i}subscribeManyEose(e,t,n){n.onauth=n.onauth||n.doauth;const i=this.subscribeMany(e,t,{...n,oneose(){i.close("closed automatically on eose")}});return i}async querySync(e,t,n){return new Promise(async i=>{const r=[];this.subscribeEose(e,t,{...n,onevent(e){r.push(e)},onclose(e){i(r)}})})}async get(e,t,n){t.limit=1;const i=await this.querySync(e,t,n);return i.sort((e,t)=>t.created_at-e.created_at),i[0]||null}publish(e,t,n){return e.map(An).map(async(e,i,r)=>{if(r.indexOf(e)!==i)return Promise.reject("duplicate url");let s=await this.ensureRelay(e);return s.publish(t).catch(async e=>{if(e instanceof Error&&e.message.startsWith("auth-required: ")&&n?.onauth)return await s.auth(n.onauth),s.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(s)}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{Qn=WebSocket}catch{}var Tn=class extends Rn{constructor(e){super({verifyEvent:xn,websocketImplementation:Qn,...e})}};
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Un(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),i=e.reduce((e,n)=>e?t(e,n.decode):n.decode,void 0);return{encode:n,decode:i}}function Nn(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(Un(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 Ln(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 On(e,t="="){if(Un(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 i=n.length;if(i*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;i>0&&n[i-1]===t;i--)if(!((i-1)*e%8))throw new Error("Invalid padding: string has too much padding");return n.slice(0,i)}}}function Mn(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function jn(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 i=0;const r=[],s=Array.from(e);for(s.forEach(e=>{if(Un(e),e<0||e>=t)throw new Error(`Wrong integer: ${e}`)});;){let e=0,o=!0;for(let r=i;r<s.length;r++){const a=s[r],l=t*e+a;if(!Number.isSafeInteger(l)||t*e/t!==e||l-a!==t*e)throw new Error("convertRadix: carry overflow");if(e=l%n,s[r]=Math.floor(l/n),!Number.isSafeInteger(s[r])||s[r]*n+e!==l)throw new Error("convertRadix: carry overflow");o&&(s[r]?o=!1:i=r)}if(r.push(e),o)break}for(let t=0;t<e.length-1&&0===e[t];t++)r.push(0);return r.reverse()}const Hn=(e,t)=>t?Hn(t,e%t):e,Gn=(e,t)=>e+(t-Hn(e,t));function Jn(e,t,n,i){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(Gn(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${Gn(t,n)}`);let r=0,s=0;const o=2**n-1,a=[];for(const i of e){if(Un(i),i>=2**t)throw new Error(`convertRadix2: invalid data word=${i} from=${t}`);if(r=r<<t|i,s+t>32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${t}`);for(s+=t;s>=n;s-=n)a.push((r>>s-n&o)>>>0);r&=2**s-1}if(r=r<<n-s&o,!i&&s>=t)throw new Error("Excess padding");if(!i&&r)throw new Error(`Non-zero padding: ${r}`);return i&&s>0&&a.push(r>>>0),a}function Kn(e,t=!1){if(Un(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(Gn(8,e)>32||Gn(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 Vn(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 qn=_n(Kn(4),Nn("0123456789ABCDEF"),Ln("")),Yn=_n(Kn(5),Nn("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),On(5),Ln(""));_n(Kn(5),Nn("0123456789ABCDEFGHIJKLMNOPQRSTUV"),On(5),Ln("")),_n(Kn(5),Nn("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),Ln(""),Mn(e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));const Wn=_n(Kn(6),Nn("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),On(6),Ln("")),zn=_n(Kn(6),Nn("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),On(6),Ln("")),Zn=e=>{return _n((Un(t=58),{encode:e=>{if(!(e instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return jn(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(jn(e,t,256))}}),Nn(e),Ln(""));var t},Xn=Zn("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");Zn("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),Zn("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const ei=[0,2,3,5,6,7,9,10,11],ti={encode(e){let t="";for(let n=0;n<e.length;n+=8){const i=e.subarray(n,n+8);t+=Xn.encode(i).padStart(ei[i.length],"1")}return t},decode(e){let t=[];for(let n=0;n<e.length;n+=11){const i=e.slice(n,n+11),r=ei.indexOf(i.length),s=Xn.decode(i);for(let e=0;e<s.length-r;e++)if(0!==s[e])throw new Error("base58xmr: wrong padding");t=t.concat(Array.from(s.slice(s.length-r)))}return Uint8Array.from(t)}},ni=_n(Nn("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),Ln("")),ii=[996825010,642813549,513874426,1027748829,705979059];function ri(e){const t=e>>25;let n=(33554431&e)<<5;for(let e=0;e<ii.length;e++)1==(t>>e&1)&&(n^=ii[e]);return n}function si(e,t,n=1){const i=e.length;let r=1;for(let t=0;t<i;t++){const n=e.charCodeAt(t);if(n<33||n>126)throw new Error(`Invalid prefix (${e})`);r=ri(r)^n>>5}r=ri(r);for(let t=0;t<i;t++)r=ri(r)^31&e.charCodeAt(t);for(let e of t)r=ri(r)^e;for(let e=0;e<6;e++)r=ri(r);return r^=n,ni.encode(Jn([r%2**30],30,5,!1))}function oi(e){const t="bech32"===e?1:734539939,n=Kn(5),i=n.decode,r=n.encode,s=Vn(i);function o(e,n=90){if("string"!=typeof e)throw new Error("bech32.decode input should be string, not "+typeof e);if(e.length<8||!1!==n&&e.length>n)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);const i=e.toLowerCase();if(e!==i&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const r=(e=i).lastIndexOf("1");if(0===r||-1===r)throw new Error('Letter "1" must be present between prefix and data only');const s=e.slice(0,r),o=e.slice(r+1);if(o.length<6)throw new Error("Data must be at least 6 characters long");const a=ni.decode(o).slice(0,-6),l=si(s,a,t);if(!o.endsWith(l))throw new Error(`Invalid checksum in ${e}: expected "${l}"`);return{prefix:s,words:a}}return{encode:function(e,n,i=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 r=e.length+7+n.length;if(!1!==i&&r>i)throw new TypeError(`Length ${r} exceeds limit ${i}`);return`${e=e.toLowerCase()}1${ni.encode(n)}${si(e,n,t)}`},decode:o,decodeToBytes:function(e){const{prefix:t,words:n}=o(e,!1);return{prefix:t,words:n,bytes:i(n)}},decodeUnsafe:Vn(o),fromWords:i,fromWordsUnsafe:s,toWords:r}}const ai=oi("bech32");oi("bech32m");const li={utf8:{encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)},hex:_n(Kn(4),Nn("0123456789abcdef"),Ln(""),Mn(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:qn,base32:Yn,base64:Wn,base64url:zn,base58:Xn,base58xmr:ti};function ci(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function ui(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}function di(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(li).join(", ");const fi=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 pi=16;function hi(e){return e<<1^283&-(e>>7)}function gi(e,t){let n=0;for(;t>0;t>>=1)n^=e&-(1&t),e=hi(e);return n}const mi=(()=>{let e=new Uint8Array(256);for(let t=0,n=1;t<256;t++,n^=hi(n))e[t]=n;const t=new Uint8Array(256);t[0]=99;for(let n=0;n<255;n++){let i=e[255-n];i|=i<<8,t[e[n]]=255&(i^i>>4^i>>5^i>>6^i>>7^99)}return t})(),vi=mi.map((e,t)=>mi.indexOf(t)),yi=e=>e<<24|e>>>8,wi=e=>e<<8|e>>>24;function bi(e,t){if(256!==e.length)throw new Error("Wrong sbox length");const n=new Uint32Array(256).map((n,i)=>t(e[i])),i=n.map(wi),r=i.map(wi),s=r.map(wi),o=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;o[u]=n[t]^i[c],a[u]=r[t]^s[c],l[u]=e[t]<<8|e[c]}return{sbox:e,sbox2:l,T0:n,T1:i,T2:r,T3:s,T01:o,T23:a}}const Ai=bi(mi,e=>gi(e,3)<<24|e<<16|e<<8|gi(e,2)),ki=bi(vi,e=>gi(e,11)<<24|gi(e,13)<<16|gi(e,9)<<8|gi(e,14)),Ii=(()=>{const e=new Uint8Array(16);for(let t=0,n=1;t<16;t++,n=hi(n))e[t]=n;return e})();function Ci(e){di(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}=Ai,i=fi(e),r=i.length,s=e=>xi(n,e,e,e,e),o=new Uint32Array(t+28);o.set(i);for(let e=r;e<o.length;e++){let t=o[e-1];e%r===0?t=s(yi(t))^Ii[e/r-1]:r>6&&e%r===4&&(t=s(t)),o[e]=o[e-r]^t}return o}function Ei(e,t,n,i,r,s){return e[n<<8&65280|i>>>8&255]^t[r>>>8&65280|s>>>24&255]}function xi(e,t,n,i,r){return e[255&t|65280&n]|e[i>>>16&255|r>>>16&65280]<<16}function Si(e,t,n,i,r){const{sbox2:s,T01:o,T23:a}=Ai;let l=0;t^=e[l++],n^=e[l++],i^=e[l++],r^=e[l++];const c=e.length/4-2;for(let s=0;s<c;s++){const s=e[l++]^Ei(o,a,t,n,i,r),c=e[l++]^Ei(o,a,n,i,r,t),u=e[l++]^Ei(o,a,i,r,t,n),d=e[l++]^Ei(o,a,r,t,n,i);t=s,n=c,i=u,r=d}return{s0:e[l++]^xi(s,t,n,i,r),s1:e[l++]^xi(s,n,i,r,t),s2:e[l++]^xi(s,i,r,t,n),s3:e[l++]^xi(s,r,t,n,i)}}function Bi(e,t,n,i,r){const{sbox2:s,T01:o,T23:a}=ki;let l=0;t^=e[l++],n^=e[l++],i^=e[l++],r^=e[l++];const c=e.length/4-2;for(let s=0;s<c;s++){const s=e[l++]^Ei(o,a,t,r,i,n),c=e[l++]^Ei(o,a,n,t,r,i),u=e[l++]^Ei(o,a,i,n,t,r),d=e[l++]^Ei(o,a,r,i,n,t);t=s,n=c,i=u,r=d}return{s0:e[l++]^xi(s,t,r,i,n),s1:e[l++]^xi(s,n,t,r,i),s2:e[l++]^xi(s,i,n,t,r),s3:e[l++]^xi(s,r,i,n,t)}}function Qi(e,t){if(!t)return new Uint8Array(e);if(di(t),t.length<e)throw new Error(`aes: wrong destination length, expected at least ${e}, got: ${t.length}`);return t}const Fi=(Di={blockSize:16,nonceLength:16},$i=function(e,t,n={}){di(e),di(t,16);const i=!n.disablePadding;return{encrypt:(n,r)=>{const s=Ci(e),{b:o,o:a,out:l}=function(e,t,n){let i=e.length;const r=i%pi;if(!t&&0!==r)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");const s=fi(e);if(t){let e=pi-r;e||(e=pi),i+=e}const o=Qi(i,n);return{b:s,o:fi(o),out:o}}(n,i,r),c=fi(t);let u=c[0],d=c[1],f=c[2],p=c[3],h=0;for(;h+4<=o.length;)u^=o[h+0],d^=o[h+1],f^=o[h+2],p^=o[h+3],({s0:u,s1:d,s2:f,s3:p}=Si(s,u,d,f,p)),a[h++]=u,a[h++]=d,a[h++]=f,a[h++]=p;if(i){const e=function(e){const t=new Uint8Array(16),n=fi(t);t.set(e);const i=pi-e.length;for(let e=pi-i;e<pi;e++)t[e]=i;return n}(n.subarray(4*h));u^=e[0],d^=e[1],f^=e[2],p^=e[3],({s0:u,s1:d,s2:f,s3:p}=Si(s,u,d,f,p)),a[h++]=u,a[h++]=d,a[h++]=f,a[h++]=p}return s.fill(0),l},decrypt:(n,r)=>{!function(e){if(di(e),e.length%pi!==0)throw new Error("aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size 16")}(n);const s=function(e){const t=Ci(e),n=t.slice(),i=t.length,{sbox2:r}=Ai,{T0:s,T1:o,T2:a,T3:l}=ki;for(let e=0;e<i;e+=4)for(let r=0;r<4;r++)n[e+r]=t[i-e-4+r];t.fill(0);for(let e=4;e<i-4;e++){const t=n[e],i=xi(r,t,t,t,t);n[e]=s[255&i]^o[i>>>8&255]^a[i>>>16&255]^l[i>>>24]}return n}(e),o=fi(t),a=Qi(n.length,r),l=fi(n),c=fi(a);let u=o[0],d=o[1],f=o[2],p=o[3];for(let e=0;e+4<=l.length;){const t=u,n=d,i=f,r=p;u=l[e+0],d=l[e+1],f=l[e+2],p=l[e+3];const{s0:o,s1:a,s2:h,s3:g}=Bi(s,u,d,f,p);c[e++]=o^t,c[e++]=a^n,c[e++]=h^i,c[e++]=g^r}return s.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 i=e[n-1];if(i<=0||i>16)throw new Error(`aes/pcks5: wrong padding byte: ${i}`);const r=e.subarray(0,-i);for(let t=0;t<i;t++)if(e[n-t-1]!==i)throw new Error("aes/pcks5: wrong padding");return r}(a,i)}}},Object.assign($i,Di),$i);var Di,$i;const Pi=e=>Uint8Array.from(e.split("").map(e=>e.charCodeAt(0))),Ri=Pi("expand 16-byte k"),Ti=Pi("expand 32-byte k"),Ui=fi(Ri),_i=fi(Ti);function Ni(e,t){return e<<t|e>>>32-t}function Li(e){return e.byteOffset%4==0}_i.slice();const Oi=2**32-1,Mi=new Uint32Array;function ji(e,t){const{allowShortKeys:n,extendNonceFn:i,counterLength:r,counterRight:s,rounds:o}=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 ci(r),ci(o),ui(s),ui(n),(t,a,l,c,u=0)=>{di(t),di(a),di(l);const d=l.length;if(c||(c=new Uint8Array(d)),di(c),ci(u),u<0||u>=Oi)throw new Error("arx: counter overflow");if(c.length<d)throw new Error(`arx: output (${c.length}) is shorter than data (${d})`);const f=[];let p,h,g=t.length;if(32===g)p=t.slice(),f.push(p),h=_i;else{if(16!==g||!n)throw new Error(`arx: invalid 32-byte key, got length=${g}`);p=new Uint8Array(32),p.set(t),p.set(t,16),h=Ui,f.push(p)}Li(a)||(a=a.slice(),f.push(a));const m=fi(p);if(i){if(24!==a.length)throw new Error("arx: extended nonce must be 24 bytes");i(h,m,fi(a.subarray(0,16)),m),a=a.subarray(16)}const v=16-r;if(v!==a.length)throw new Error(`arx: nonce must be ${v} or 16 bytes`);if(12!==v){const e=new Uint8Array(12);e.set(a,s?0:12-a.length),a=e,f.push(a)}const y=fi(a);for(!function(e,t,n,i,r,s,o,a){const l=r.length,c=new Uint8Array(64),u=fi(c),d=Li(r)&&Li(s),f=d?fi(r):Mi,p=d?fi(s):Mi;for(let h=0;h<l;o++){if(e(t,n,i,u,o,a),o>=Oi)throw new Error("arx: counter overflow");const g=Math.min(64,l-h);if(d&&64===g){const e=h/4;if(h%4!=0)throw new Error("arx: invalid block position");for(let t,n=0;n<16;n++)t=e+n,p[t]=f[t]^u[n];h+=64;continue}for(let e,t=0;t<g;t++)e=h+t,s[e]=r[e]^c[t];h+=g}}(e,h,m,y,l,c,u,o);f.length>0;)f.pop().fill(0);return c}}function Hi(e,t,n,i,r,s=20){let o=e[0],a=e[1],l=e[2],c=e[3],u=t[0],d=t[1],f=t[2],p=t[3],h=t[4],g=t[5],m=t[6],v=t[7],y=r,w=n[0],b=n[1],A=n[2],k=o,I=a,C=l,E=c,x=u,S=d,B=f,Q=p,F=h,D=g,$=m,P=v,R=y,T=w,U=b,_=A;for(let e=0;e<s;e+=2)k=k+x|0,R=Ni(R^k,16),F=F+R|0,x=Ni(x^F,12),k=k+x|0,R=Ni(R^k,8),F=F+R|0,x=Ni(x^F,7),I=I+S|0,T=Ni(T^I,16),D=D+T|0,S=Ni(S^D,12),I=I+S|0,T=Ni(T^I,8),D=D+T|0,S=Ni(S^D,7),C=C+B|0,U=Ni(U^C,16),$=$+U|0,B=Ni(B^$,12),C=C+B|0,U=Ni(U^C,8),$=$+U|0,B=Ni(B^$,7),E=E+Q|0,_=Ni(_^E,16),P=P+_|0,Q=Ni(Q^P,12),E=E+Q|0,_=Ni(_^E,8),P=P+_|0,Q=Ni(Q^P,7),k=k+S|0,_=Ni(_^k,16),$=$+_|0,S=Ni(S^$,12),k=k+S|0,_=Ni(_^k,8),$=$+_|0,S=Ni(S^$,7),I=I+B|0,R=Ni(R^I,16),P=P+R|0,B=Ni(B^P,12),I=I+B|0,R=Ni(R^I,8),P=P+R|0,B=Ni(B^P,7),C=C+Q|0,T=Ni(T^C,16),F=F+T|0,Q=Ni(Q^F,12),C=C+Q|0,T=Ni(T^C,8),F=F+T|0,Q=Ni(Q^F,7),E=E+x|0,U=Ni(U^E,16),D=D+U|0,x=Ni(x^D,12),E=E+x|0,U=Ni(U^E,8),D=D+U|0,x=Ni(x^D,7);let N=0;i[N++]=o+k|0,i[N++]=a+I|0,i[N++]=l+C|0,i[N++]=c+E|0,i[N++]=u+x|0,i[N++]=d+S|0,i[N++]=f+B|0,i[N++]=p+Q|0,i[N++]=h+F|0,i[N++]=g+D|0,i[N++]=m+$|0,i[N++]=v+P|0,i[N++]=y+R|0,i[N++]=w+T|0,i[N++]=b+U|0,i[N++]=A+_|0}const Gi=ji(Hi,{counterRight:!1,counterLength:4,allowShortKeys:!1});class Ji extends nn{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,ln.hash(e);const n=en(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 i=this.blockLen,r=new Uint8Array(i);r.set(n.length>i?e.create().update(n).digest():n);for(let e=0;e<r.length;e++)r[e]^=54;this.iHash.update(r),this.oHash=e.create();for(let e=0;e<r.length;e++)r[e]^=106;this.oHash.update(r),r.fill(0)}update(e){return ln.exists(this),this.iHash.update(e),this}digestInto(e){ln.exists(this),ln.bytes(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:i,destroyed:r,blockLen:s,outputLen:o}=this;return e.finished=i,e.destroyed=r,e.blockLen=s,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Ki=(e,t,n)=>new Ji(e,t).update(n).digest();Ki.create=(e,t)=>new Ji(e,t);const Vi=new Uint8Array([0]),qi=new Uint8Array;var Yi=Object.defineProperty,Wi=(e,t)=>{for(var n in t)Yi(e,n,{get:t[n],enumerable:!0})},zi=Symbol("verified");function Zi(e){if(!(e instanceof Object))return!1;if("number"!=typeof e.kind)return!1;if("string"!=typeof e.content)return!1;if("number"!=typeof e.created_at)return!1;if("string"!=typeof e.pubkey)return!1;if(!e.pubkey.match(/^[a-f0-9]{64}$/))return!1;if(!Array.isArray(e.tags))return!1;for(let t=0;t<e.tags.length;t++){let n=e.tags[t];if(!Array.isArray(n))return!1;for(let e=0;e<n.length;e++)if("string"!=typeof n[e])return!1}return!0}Wi({},{Queue:()=>or,QueueNode:()=>sr,binarySearch:()=>rr,bytesToHex:()=>Zt,hexToBytes:()=>Xt,insertEventIntoAscendingList:()=>ir,insertEventIntoDescendingList:()=>nr,normalizeURL:()=>tr,utf8Decoder:()=>Xi,utf8Encoder:()=>er});var Xi=new TextDecoder("utf-8"),er=new TextEncoder;function tr(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 nr(e,t){const[n,i]=rr(e,e=>t.id===e.id?0:t.created_at===e.created_at?-1:e.created_at-t.created_at);return i||e.splice(n,0,t),e}function ir(e,t){const[n,i]=rr(e,e=>t.id===e.id?0:t.created_at===e.created_at?-1:t.created_at-e.created_at);return i||e.splice(n,0,t),e}function rr(e,t){let n=0,i=e.length-1;for(;n<=i;){const r=Math.floor((n+i)/2),s=t(e[r]);if(0===s)return[r,!0];s<0?i=r-1:n=r+1}return[n,!1]}var sr=class{value;next=null;prev=null;constructor(e){this.value=e}},or=class{first;last;constructor(){this.first=null,this.last=null}enqueue(e){const t=new sr(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 ar(e){return Zt(vn(er.encode(function(e){if(!Zi(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 lr=new class{generateSecretKey(){return Kt.utils.randomPrivateKey()}getPublicKey(e){return Zt(Kt.getPublicKey(e))}finalizeEvent(e,t){const n=e;return n.pubkey=Zt(Kt.getPublicKey(t)),n.id=ar(n),n.sig=Zt(Kt.sign(ar(n),t)),n[zi]=!0,n}verifyEvent(e){if("boolean"==typeof e[zi])return e[zi];const t=ar(e);if(t!==e.id)return e[zi]=!1,!1;try{const n=Kt.verify(e.sig,t,e.pubkey);return e[zi]=n,n}catch(t){return e[zi]=!1,!1}}},cr=lr.generateSecretKey,ur=lr.getPublicKey,dr=lr.finalizeEvent,fr=lr.verifyEvent,pr={};function hr(e){return 1e3<=e&&e<1e4||[1,2,4,5,6,7,8,16,40,41,42,43,44].includes(e)}function gr(e){return[0,3].includes(e)||1e4<=e&&e<2e4}function mr(e){return 2e4<=e&&e<3e4}function vr(e){return 3e4<=e&&e<4e4}function yr(e){return hr(e)?"regular":gr(e)?"replaceable":mr(e)?"ephemeral":vr(e)?"parameterized":"unknown"}function wr(e,t){const n=t instanceof Array?t:[t];return Zi(e)&&n.includes(e.kind)||!1}Wi(pr,{Application:()=>Ds,BadgeAward:()=>Br,BadgeDefinition:()=>Cs,BlockedRelaysList:()=>ss,BookmarkList:()=>ns,Bookmarksets:()=>As,Calendar:()=>Ns,CalendarEventRSVP:()=>Ls,ChannelCreation:()=>$r,ChannelHideMessage:()=>Tr,ChannelMessage:()=>Rr,ChannelMetadata:()=>Pr,ChannelMuteUser:()=>Ur,ClassifiedListing:()=>Rs,ClientAuth:()=>ps,CommunitiesList:()=>is,CommunityDefinition:()=>js,CommunityPostApproval:()=>Jr,Contacts:()=>Ir,CreateOrUpdateProduct:()=>Ss,CreateOrUpdateStall:()=>xs,Curationsets:()=>ks,Date:()=>Us,DirectMessageRelaysList:()=>cs,DraftClassifiedListing:()=>Ts,DraftLong:()=>Qs,Emojisets:()=>Fs,EncryptedDirectMessage:()=>Cr,EventDeletion:()=>Er,FileMetadata:()=>Lr,FileServerPreference:()=>us,Followsets:()=>ys,GenericRepost:()=>Dr,Genericlists:()=>ws,GiftWrap:()=>Nr,HTTPAuth:()=>vs,Handlerinformation:()=>Ms,Handlerrecommendation:()=>Os,Highlights:()=>Zr,InterestsList:()=>as,Interestsets:()=>Es,JobFeedback:()=>qr,JobRequest:()=>Kr,JobResult:()=>Vr,Label:()=>Gr,LightningPubRPC:()=>fs,LiveChatMessage:()=>Or,LiveEvent:()=>$s,LongFormArticle:()=>Bs,Metadata:()=>br,Mutelist:()=>Xr,NWCWalletInfo:()=>ds,NWCWalletRequest:()=>hs,NWCWalletResponse:()=>gs,NostrConnect:()=>ms,OpenTimestamps:()=>_r,Pinlist:()=>es,PrivateDirectMessage:()=>Fr,ProblemTracker:()=>Mr,ProfileBadges:()=>Is,PublicChatsList:()=>rs,Reaction:()=>Sr,RecommendRelay:()=>kr,RelayList:()=>ts,Relaysets:()=>bs,Report:()=>jr,Reporting:()=>Hr,Repost:()=>xr,Seal:()=>Qr,SearchRelaysList:()=>os,ShortTextNote:()=>Ar,Time:()=>_s,UserEmojiList:()=>ls,UserStatuses:()=>Ps,Zap:()=>zr,ZapGoal:()=>Yr,ZapRequest:()=>Wr,classifyKind:()=>yr,isAddressableKind:()=>vr,isEphemeralKind:()=>mr,isKind:()=>wr,isRegularKind:()=>hr,isReplaceableKind:()=>gr});var br=0,Ar=1,kr=2,Ir=3,Cr=4,Er=5,xr=6,Sr=7,Br=8,Qr=13,Fr=14,Dr=16,$r=40,Pr=41,Rr=42,Tr=43,Ur=44,_r=1040,Nr=1059,Lr=1063,Or=1311,Mr=1971,jr=1984,Hr=1984,Gr=1985,Jr=4550,Kr=5999,Vr=6999,qr=7e3,Yr=9041,Wr=9734,zr=9735,Zr=9802,Xr=1e4,es=10001,ts=10002,ns=10003,is=10004,rs=10005,ss=10006,os=10007,as=10015,ls=10030,cs=10050,us=10096,ds=13194,fs=21e3,ps=22242,hs=23194,gs=23195,ms=24133,vs=27235,ys=3e4,ws=30001,bs=30002,As=30003,ks=30004,Is=30008,Cs=30009,Es=30015,xs=30017,Ss=30018,Bs=30023,Qs=30024,Fs=30030,Ds=30078,$s=30311,Ps=30315,Rs=30402,Ts=30403,Us=31922,_s=31923,Ns=31924,Ls=31925,Os=31989,Ms=31990,js=34550;function Hs(e,t){let n=t.length+3,i=e.indexOf(`"${t}":`)+n,r=e.slice(i).indexOf('"')+i+1;return e.slice(r,r+64)}function Gs(e,t){let n=t.length,i=e.indexOf(`"${t}":`)+n+3,r=e.slice(i),s=Math.min(r.indexOf(","),r.indexOf("}"));return parseInt(r.slice(0,s),10)}function Js(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 i=t+7+1+n,r=e.slice(i+1,80).indexOf('"');if(-1===r)return null;let s=i+1+r;return e.slice(i+1,s)}function Ks(e,t){return t===Hs(e,"id")}function Vs(e,t){return t===Hs(e,"pubkey")}function qs(e,t){return t===Gs(e,"kind")}Wi({},{getHex64:()=>Hs,getInt:()=>Gs,getSubscriptionId:()=>Js,matchEventId:()=>Ks,matchEventKind:()=>qs,matchEventPubkey:()=>Vs});function Ys(e,t){return{kind:ps,created_at:Math.floor(Date.now()/1e3),tags:[["relay",e],["challenge",t]],content:""}}Wi({},{makeAuthEvent:()=>Ys});try{WebSocket}catch{}try{WebSocket}catch{}var Ws={};Wi(Ws,{BECH32_REGEX:()=>Xs,Bech32MaxSize:()=>Zs,NostrTypeGuard:()=>zs,decode:()=>to,decodeNostrURI:()=>eo,encodeBytes:()=>ao,naddrEncode:()=>uo,neventEncode:()=>co,noteEncode:()=>so,nprofileEncode:()=>lo,npubEncode:()=>ro,nsecEncode:()=>io});var zs={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||"")},Zs=5e3,Xs=/[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;function eo(e){try{return e.startsWith("nostr:")&&(e=e.substring(6)),to(e)}catch(e){return{type:"invalid",data:null}}}function to(e){let{prefix:t,words:n}=ai.decode(e,Zs),i=new Uint8Array(ai.fromWords(n));switch(t){case"nprofile":{let e=no(i);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:Zt(e[0][0]),relays:e[1]?e[1].map(e=>Xi.decode(e)):[]}}}case"nevent":{let e=no(i);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:Zt(e[0][0]),relays:e[1]?e[1].map(e=>Xi.decode(e)):[],author:e[2]?.[0]?Zt(e[2][0]):void 0,kind:e[3]?.[0]?parseInt(Zt(e[3][0]),16):void 0}}}case"naddr":{let e=no(i);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:Xi.decode(e[0][0]),pubkey:Zt(e[2][0]),kind:parseInt(Zt(e[3][0]),16),relays:e[1]?e[1].map(e=>Xi.decode(e)):[]}}}case"nsec":return{type:t,data:i};case"npub":case"note":return{type:t,data:Zt(i)};default:throw new Error(`unknown prefix ${t}`)}}function no(e){let t={},n=e;for(;n.length>0;){let e=n[0],i=n[1],r=n.slice(2,2+i);if(n=n.slice(2+i),r.length<i)throw new Error(`not enough data to read on TLV ${e}`);t[e]=t[e]||[],t[e].push(r)}return t}function io(e){return ao("nsec",e)}function ro(e){return ao("npub",Xt(e))}function so(e){return ao("note",Xt(e))}function oo(e,t){let n=ai.toWords(t);return ai.encode(e,n,Zs)}function ao(e,t){return oo(e,t)}function lo(e){return oo("nprofile",fo({0:[Xt(e.pubkey)],1:(e.relays||[]).map(e=>er.encode(e))}))}function co(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)),oo("nevent",fo({0:[Xt(e.id)],1:(e.relays||[]).map(e=>er.encode(e)),2:e.author?[Xt(e.author)]:[],3:t?[new Uint8Array(t)]:[]}))}function uo(e){let t=new ArrayBuffer(4);return new DataView(t).setUint32(0,e.kind,!1),oo("naddr",fo({0:[er.encode(e.identifier)],1:(e.relays||[]).map(e=>er.encode(e)),2:[Xt(e.pubkey)],3:[new Uint8Array(t)]}))}function fo(e){let t=[];return Object.entries(e).reverse().forEach(([e,n])=>{n.forEach(n=>{let i=new Uint8Array(n.length+2);i.set([parseInt(e)],0),i.set([n.length],1),i.set(n,2),t.push(i)})}),tn(...t)}var po={};function ho(e,t,n){const i=e instanceof Uint8Array?Zt(e):e,r=mo(Ft.getSharedSecret(i,"02"+t));let s=Uint8Array.from(sn(16)),o=er.encode(n),a=Fi(r,s).encrypt(o);return`${Wn.encode(new Uint8Array(a))}?iv=${Wn.encode(new Uint8Array(s.buffer))}`}function go(e,t,n){const i=e instanceof Uint8Array?Zt(e):e;let[r,s]=n.split("?iv="),o=mo(Ft.getSharedSecret(i,"02"+t)),a=Wn.decode(s),l=Wn.decode(r),c=Fi(o,a).decrypt(l);return Xi.decode(c)}function mo(e){return e.slice(1,33)}Wi(po,{decrypt:()=>go,encrypt:()=>ho});Wi({},{NIP05_REGEX:()=>yo,isNip05:()=>wo,isValid:()=>Io,queryProfile:()=>ko,searchDomain:()=>Ao,useFetchImplementation:()=>bo});var vo,yo=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,wo=e=>yo.test(e||"");try{vo=fetch}catch(e){}function bo(e){vo=e}async function Ao(e,t=""){try{const n=`https://${e}/.well-known/nostr.json?name=${t}`,i=await vo(n,{redirect:"manual"});if(200!==i.status)throw Error("Wrong response code");return(await i.json()).names}catch(e){return{}}}async function ko(e){const t=e.match(yo);if(!t)return null;const[,n="_",i]=t;try{const e=`https://${i}/.well-known/nostr.json?name=${n}`,t=await vo(e,{redirect:"manual"});if(200!==t.status)throw Error("Wrong response code");const r=await t.json(),s=r.names[n];return s?{pubkey:s,relays:r.relays?.[s]}:null}catch(e){return null}}async function Io(e,t){const n=await ko(t);return!!n&&n.pubkey===e}function Co(e){const t={reply:void 0,root:void 0,mentions:[],profiles:[],quotes:[]};let n,i;for(let r=e.tags.length-1;r>=0;r--){const s=e.tags[r];if("e"===s[0]&&s[1]){const[e,r,o,a,l]=s,c={id:r,relays:o?[o]:[],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?i=c:n=c,t.mentions.push(c);continue}if("q"===s[0]&&s[1]){const[e,n,i]=s;t.quotes.push({id:n,relays:i?[i]:[]})}"p"===s[0]&&s[1]&&t.profiles.push({pubkey:s[1],relays:s[2]?[s[2]]:[]})}return t.root||(t.root=i||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}Wi({},{parse:()=>Co});Wi({},{fetchRelayInformation:()=>xo,useFetchImplementation:()=>Eo});try{fetch}catch{}function Eo(e){0}async function xo(e){return await(await fetch(e.replace("ws://","http://").replace("wss://","https://"),{headers:{Accept:"application/nostr+json"}})).json()}function So(e){let t=0;for(let n=0;n<64;n+=8){const i=parseInt(e.substring(n,n+8),16);if(0!==i){t+=Math.clz32(i);break}t+=32}return t}function Bo(e,t){let n=0;const i=e,r=["nonce",n.toString(),t.toString()];for(i.tags.push(r);;){const e=Math.floor((new Date).getTime()/1e3);if(e!==i.created_at&&(n=0,i.created_at=e),r[1]=(++n).toString(),i.id=Qo(i),So(i.id)>=t)break}return i}function Qo(e){return Zt(vn(er.encode(JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content]))))}Wi({},{fastEventHash:()=>Qo,getPow:()=>So,minePow:()=>Bo});Wi({},{unwrapEvent:()=>ta,unwrapManyEvents:()=>na,wrapEvent:()=>Xo,wrapManyEvents:()=>ea});Wi({},{createRumor:()=>Ko,createSeal:()=>Vo,createWrap:()=>qo,unwrapEvent:()=>zo,unwrapManyEvents:()=>Zo,wrapEvent:()=>Yo,wrapManyEvents:()=>Wo});var Fo={};Wi(Fo,{decrypt:()=>Lo,encrypt:()=>No,getConversationKey:()=>Po,v2:()=>Oo});var Do=1,$o=65535;function Po(e,t){const n=Ft.getSharedSecret(e,"02"+t).subarray(1,33);return function(e,t,n){return ln.hash(e),void 0===n&&(n=new Uint8Array(e.outputLen)),Ki(e,en(n),en(t))}(vn,n,"nip44-v2")}function Ro(e,t){const n=function(e,t,n,i=32){if(ln.hash(e),ln.number(i),i>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const r=Math.ceil(i/e.outputLen);void 0===n&&(n=qi);const s=new Uint8Array(r*e.outputLen),o=Ki.create(e,t),a=o._cloneInto(),l=new Uint8Array(o.outputLen);for(let t=0;t<r;t++)Vi[0]=t+1,a.update(0===t?qi:l).update(n).update(Vi).digestInto(l),s.set(l,e.outputLen*t),o._cloneInto(a);return o.destroy(),a.destroy(),l.fill(0),Vi.fill(0),s.slice(0,i)}(vn,e,t,76);return{chacha_key:n.subarray(0,32),chacha_nonce:n.subarray(32,44),hmac_key:n.subarray(44,76)}}function To(e){if(!Number.isSafeInteger(e)||e<1)throw new Error("expected positive integer");if(e<=32)return 32;const t=1<<Math.floor(Math.log2(e-1))+1,n=t<=256?32:t/8;return n*(Math.floor((e-1)/n)+1)}function Uo(e){const t=er.encode(e),n=t.length;return tn(function(e){if(!Number.isSafeInteger(e)||e<Do||e>$o)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(To(n)-n))}function _o(e,t,n){if(32!==n.length)throw new Error("AAD associated data must be 32 bytes");const i=tn(n,t);return Ki(vn,e,i)}function No(e,t,n=sn(32)){const{chacha_key:i,chacha_nonce:r,hmac_key:s}=Ro(t,n),o=Uo(e),a=Gi(i,r,o),l=_o(s,a,n);return Wn.encode(tn(new Uint8Array([2]),n,a,l))}function Lo(e,t){const{nonce:n,ciphertext:i,mac:r}=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=Wn.decode(e)}catch(e){throw new Error("invalid base64: "+e.message)}const i=n.length;if(i<99||i>65603)throw new Error("invalid data length: "+i);const r=n[0];if(2!==r)throw new Error("unknown encryption version "+r);return{nonce:n.subarray(1,33),ciphertext:n.subarray(33,-32),mac:n.subarray(-32)}}(e),{chacha_key:s,chacha_nonce:o,hmac_key:a}=Ro(t,n);if(!function(e,t){if(e.length!==t.length)return!1;let n=0;for(let i=0;i<e.length;i++)n|=e[i]^t[i];return 0===n}(_o(a,i,n),r))throw new Error("invalid MAC");return function(e){const t=new DataView(e.buffer).getUint16(0),n=e.subarray(2,2+t);if(t<Do||t>$o||n.length!==t||e.length!==2+To(t))throw new Error("invalid padding");return Xi.decode(n)}(Gi(s,o,i))}var Oo={utils:{getConversationKey:Po,calcPaddedLen:To},encrypt:No,decrypt:Lo},Mo=()=>Math.round(Date.now()/1e3),jo=()=>Math.round(Mo()-172800*Math.random()),Ho=(e,t)=>Po(e,t),Go=(e,t,n)=>No(JSON.stringify(e),Ho(t,n)),Jo=(e,t)=>JSON.parse(Lo(e.content,Ho(t,e.pubkey)));function Ko(e,t){const n={created_at:Mo(),content:"",tags:[],...e,pubkey:ur(t)};return n.id=ar(n),n}function Vo(e,t,n){return dr({kind:Qr,content:Go(e,t,n),created_at:jo(),tags:[]},t)}function qo(e,t){const n=cr();return dr({kind:Nr,content:Go(e,n,t),created_at:jo(),tags:[["p",t]]},n)}function Yo(e,t,n){return qo(Vo(Ko(e,t),t,n),n)}function Wo(e,t,n){if(!n||0===n.length)throw new Error("At least one recipient is required.");const i=ur(t),r=[Yo(e,t,i)];return n.forEach(n=>{r.push(Yo(e,t,n))}),r}function zo(e,t){const n=Jo(e,t);return Jo(n,t)}function Zo(e,t){let n=[];return e.forEach(e=>{n.push(zo(e,t))}),n.sort((e,t)=>e.created_at-t.created_at),n}function Xo(e,t,n,i,r){const s=function(e,t,n,i){const r={created_at:Math.ceil(Date.now()/1e3),kind:Fr,tags:[],content:t};return(Array.isArray(e)?e:[e]).forEach(({publicKey:e,relayUrl:t})=>{r.tags.push(t?["p",e,t]:["p",e])}),i&&r.tags.push(["e",i.eventId,i.relayUrl||"","reply"]),n&&r.tags.push(["subject",n]),r}(t,n,i,r);return Yo(s,e,t.publicKey)}function ea(e,t,n,i,r){if(!t||0===t.length)throw new Error("At least one recipient is required.");return[{publicKey:ur(e)},...t].map(t=>Xo(e,t,n,i,r))}var ta=zo,na=Zo;function ia(e,t,n,i){let r;const s=[...e.tags??[],["e",t.id,n],["p",t.pubkey]];return t.kind===Ar?r=xr:(r=Dr,s.push(["k",String(t.kind)])),dr({kind:r,tags:s,content:""===e.content||t.tags?.find(e=>"-"===e[0])?"":JSON.stringify(t),created_at:e.created_at},i)}function ra(e){if(![xr,Dr].includes(e.kind))return;let t,n;for(let i=e.tags.length-1;i>=0&&(void 0===t||void 0===n);i--){const r=e.tags[i];r.length>=2&&("e"===r[0]&&void 0===t?t=r:"p"===r[0]&&void 0===n&&(n=r))}return void 0!==t?{id:t[1],relays:[t[2],n?.[2]].filter(e=>"string"==typeof e),author:n?.[1]}:void 0}function sa(e,{skipVerification:t}={}){const n=ra(e);if(void 0===n||""===e.content)return;let i;try{i=JSON.parse(e.content)}catch(e){return}return i.id===n.id&&(t||fr(i))?i:void 0}Wi({},{finishRepostEvent:()=>ia,getRepostedEvent:()=>sa,getRepostedEventPointer:()=>ra});Wi({},{NOSTR_URI_REGEX:()=>oa,parse:()=>la,test:()=>aa});var oa=new RegExp(`nostr:(${Xs.source})`);function aa(e){return"string"==typeof e&&new RegExp(`^${oa.source}$`).test(e)}function la(e){const t=e.match(new RegExp(`^${oa.source}$`));if(!t)throw new Error(`Invalid Nostr URI: ${e}`);return{uri:t[0],value:t[1],decoded:to(t[1])}}function ca(e,t,n){const i=t.tags.filter(e=>e.length>=2&&("e"===e[0]||"p"===e[0]));return dr({...e,kind:Sr,tags:[...e.tags??[],...i,["e",t.id],["p",t.pubkey]],content:e.content??"+"},n)}function ua(e){if(e.kind!==Sr)return;let t,n;for(let i=e.tags.length-1;i>=0&&(void 0===t||void 0===n);i--){const r=e.tags[i];r.length>=2&&("e"===r[0]&&void 0===t?t=r:"p"===r[0]&&void 0===n&&(n=r))}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}Wi({},{finishReactionEvent:()=>ca,getReactedEventPointer:()=>ua});Wi({},{parse:()=>pa});var da=/\W/m,fa=/\W |\W$|$|,| /m;function*pa(e){const t=e.length;let n=0,i=0;for(;i<t;){let r=e.indexOf(":",i);if(-1===r)break;if("nostr"===e.substring(r-5,r)){const s=e.substring(r+60).match(da),o=s?r+60+s.index:t;try{let t,{data:s,type:a}=to(e.substring(r+1,o));switch(a){case"npub":t={pubkey:s};break;case"nsec":case"note":i=o+1;continue;default:t=s}n!==r-5&&(yield{type:"text",text:e.substring(n,r-5)}),yield{type:"reference",pointer:t},i=o,n=i;continue}catch(e){i=r+1;continue}}else if("https"===e.substring(r-5,r)||"http"===e.substring(r-4,r)){const s=e.substring(r+4).match(fa),o=s?r+4+s.index:t,a="s"===e[r-1]?5:4;try{let t=new URL(e.substring(r-a,o));if(-1===t.hostname.indexOf("."))throw new Error("invalid url");if(n!==r-a&&(yield{type:"text",text:e.substring(n,r-a)}),/\.(png|jpe?g|gif|webp)$/i.test(t.pathname)){yield{type:"image",url:t.toString()},i=o,n=i;continue}if(/\.(mp4|avi|webm|mkv)$/i.test(t.pathname)){yield{type:"video",url:t.toString()},i=o,n=i;continue}if(/\.(mp3|aac|ogg|opus)$/i.test(t.pathname)){yield{type:"audio",url:t.toString()},i=o,n=i;continue}yield{type:"url",url:t.toString()},i=o,n=i;continue}catch(e){i=o+1;continue}}else{if("wss"!==e.substring(r-3,r)&&"ws"!==e.substring(r-2,r)){i=r+1;continue}{const s=e.substring(r+4).match(fa),o=s?r+4+s.index:t,a="s"===e[r-1]?3:2;try{let t=new URL(e.substring(r-a,o));if(-1===t.hostname.indexOf("."))throw new Error("invalid ws url");n!==r-a&&(yield{type:"text",text:e.substring(n,r-a)}),yield{type:"relay",url:t.toString()},i=o,n=i;continue}catch(e){i=o+1;continue}}}}n!==t&&(yield{type:"text",text:e.substring(n)})}Wi({},{channelCreateEvent:()=>ha,channelHideMessageEvent:()=>va,channelMessageEvent:()=>ma,channelMetadataEvent:()=>ga,channelMuteUserEvent:()=>ya});var ha=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return dr({kind:$r,tags:[...e.tags??[]],content:n,created_at:e.created_at},t)},ga=(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 dr({kind:Pr,tags:[["e",e.channel_create_event_id],...e.tags??[]],content:n,created_at:e.created_at},t)},ma=(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"]),dr({kind:Rr,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 dr({kind:Tr,tags:[["e",e.channel_message_event_id],...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 dr({kind:Ur,tags:[["p",e.pubkey_to_mute],...e.tags??[]],content:n,created_at:e.created_at},t)};Wi({},{EMOJI_SHORTCODE_REGEX:()=>wa,matchAll:()=>Aa,regex:()=>ba,replaceAll:()=>ka});var wa=/:(\w+):/,ba=()=>new RegExp(`\\B${wa.source}\\B`,"g");function*Aa(e){const t=e.matchAll(ba());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 ka(e,t){return e.replaceAll(ba(),(e,n)=>t({shortcode:e,name:n}))}var Ia;Wi({},{useFetchImplementation:()=>Ca,validateGithub:()=>Ea});try{Ia=fetch}catch{}function Ca(e){Ia=e}async function Ea(e,t,n){try{return await(await Ia(`https://gist.github.com/${t}/${n}/raw`)).text()===`Verifying that I control the following Nostr public key: ${e}`}catch(e){return!1}}function xa(e){const{host:t,pathname:n,searchParams:i}=new URL(e),r=n||t,s=i.get("relay"),o=i.get("secret");if(!r||!s||!o)throw new Error("invalid connection string");return{pubkey:r,relay:s,secret:o}}async function Sa(e,t,n){const i={method:"pay_invoice",params:{invoice:n}},r=ho(t,e,JSON.stringify(i)),s={kind:hs,created_at:Math.round(Date.now()/1e3),content:r,tags:[["p",e]]};return dr(s,t)}Wi({},{makeNwcRequestEvent:()=>Sa,parseConnectionString:()=>xa});function Ba(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("")}Wi({},{normalizeIdentifier:()=>Ba});var Qa;Wi({},{getSatoshisAmountFromBolt11:()=>Ta,getZapEndpoint:()=>Da,makeZapReceipt:()=>Ra,makeZapRequest:()=>$a,useFetchImplementation:()=>Fa,validateZapRequest:()=>Pa});try{Qa=fetch}catch{}function Fa(e){Qa=e}async function Da(e){try{let t="",{lud06:n,lud16:i}=JSON.parse(e.content);if(n){let{words:e}=ai.decode(n,1e3),i=ai.fromWords(e);t=Xi.decode(i)}else{if(!i)return null;{let[e,n]=i.split("@");t=new URL(`/.well-known/lnurlp/${e}`,`https://${n}`).toString()}}let r=await Qa(t),s=await r.json();if(s.allowsNostr&&s.nostrPubkey)return s.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]),gr(e.event.kind)){const n=["a",`${e.event.kind}:${e.event.pubkey}:`];t.tags.push(n)}else if(vr(e.event.kind)){let n=e.event.tags.find(([e,t])=>"d"===e&&t);if(!n)throw new Error("d tag not found or is empty");const i=["a",`${e.event.kind}:${e.event.pubkey}:${n[1]}`];t.tags.push(i)}t.tags.push(["k",e.event.kind.toString()])}return t}function Pa(e){let t;try{t=JSON.parse(e)}catch(e){return"Invalid zap request JSON."}if(!Zi(t))return"Zap request is not a valid Nostr event.";if(!fr(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 i=t.tags.find(([e,t])=>"e"===e&&t);return i&&!i[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 Ra({zapRequest:e,preimage:t,bolt11:n,paidAt:i}){let r=JSON.parse(e),s=r.tags.filter(([e])=>"e"===e||"p"===e||"a"===e),o={kind:9735,created_at:Math.round(i.getTime()/1e3),content:"",tags:[...s,["P",r.pubkey],["bolt11",n],["description",e]]};return t&&o.tags.push(["preimage",t]),o}function Ta(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 i=n.substring(4);if(i.length<1)return 0;const r=i[i.length-1],s=r.charCodeAt(0)-"0".charCodeAt(0),o=s>=0&&s<=9;let a=i.length-1;if(o&&a++,a<1)return 0;const l=parseInt(i.substring(0,a));switch(r){case"m":return 1e5*l;case"u":return 100*l;case"n":return l/10;case"p":return l/1e4;default:return 1e8*l}}Wi({},{getToken:()=>_a,hashPayload:()=>Ga,unpackEventFromToken:()=>La,validateEvent:()=>Ka,validateEventKind:()=>Ma,validateEventMethodTag:()=>Ha,validateEventPayloadTag:()=>Ja,validateEventTimestamp:()=>Oa,validateEventUrlTag:()=>ja,validateToken:()=>Na});var Ua="Nostr ";async function _a(e,t,n,i=!1,r){const s={kind:vs,tags:[["u",e],["method",t]],created_at:Math.round((new Date).getTime()/1e3),content:""};r&&s.tags.push(["payload",Ga(r)]);const o=await n(s);return(i?Ua:"")+Wn.encode(er.encode(JSON.stringify(o)))}async function Na(e,t,n){const i=await La(e).catch(e=>{throw e});return await Ka(i,t,n).catch(e=>{throw e})}async function La(e){if(!e)throw new Error("Missing token");e=e.replace(Ua,"");const t=Xi.decode(Wn.decode(e));if(!t||0===t.length||!t.startsWith("{"))throw new Error("Invalid token");return JSON.parse(t)}function Oa(e){return!!e.created_at&&Math.round((new Date).getTime()/1e3)-e.created_at<60}function Ma(e){return e.kind===vs}function ja(e,t){const n=e.tags.find(e=>"u"===e[0]);return!!n&&(n.length>0&&n[1]===t)}function Ha(e,t){const n=e.tags.find(e=>"method"===e[0]);return!!n&&(n.length>0&&n[1].toLowerCase()===t.toLowerCase())}function Ga(e){return Zt(vn(er.encode(JSON.stringify(e))))}function Ja(e,t){const n=e.tags.find(e=>"payload"===e[0]);if(!n)return!1;const i=Ga(t);return n.length>0&&n[1]===i}async function Ka(e,t,n,i){if(!fr(e))throw new Error("Invalid nostr event, signature invalid");if(!Ma(e))throw new Error("Invalid nostr event, kind invalid");if(!Oa(e))throw new Error("Invalid nostr event, created_at timestamp invalid");if(!ja(e,t))throw new Error("Invalid nostr event, url tag invalid");if(!Ha(e,n))throw new Error("Invalid nostr event, method tag invalid");if(Boolean(i)&&"object"==typeof i&&Object.keys(i).length>0&&!Ja(e,i))throw new Error("Invalid nostr event, payload tag does not match request body hash");return!0}function Va(e){return[0,3].includes(e)||1e4<=e&&e<2e4}function qa(e){return 3e4<=e&&e<4e4}var Ya=function(e,t){return Ya=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])},Ya(e,t)};function Wa(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}Ya(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function za(e,t,n,i){return new(n||(n=Promise))(function(r,s){function o(e){try{l(i.next(e))}catch(e){s(e)}}function a(e){try{l(i.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(o,a)}l((i=i.apply(e,t||[])).next())})}function Za(e,t){var n,i,r,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(l){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,i&&(r=2&a[0]?i.return:a[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,a[1])).done)return r;switch(i=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,i=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){s.label=a[1];break}if(6===a[0]&&s.label<r[1]){s.label=r[1],r=a;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(a);break}r[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],i=0}finally{n=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,l])}}}function Xa(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],i=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function el(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,r,s=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(i=s.next()).done;)o.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return o}function tl(e,t,n){if(n||2===arguments.length)for(var i,r=0,s=t.length;r<s;r++)!i&&r in t||(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}function nl(e){return this instanceof nl?(this.v=e,this):new nl(e)}function il(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=n.apply(e,t||[]),s=[];return i=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",function(e){return function(t){return Promise.resolve(t).then(e,c)}}),i[Symbol.asyncIterator]=function(){return this},i;function o(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,i){s.push([e,t,n,i])>1||a(e,t)})},t&&(i[e]=t(i[e])))}function a(e,t){try{(n=r[e](t)).value instanceof nl?Promise.resolve(n.value.v).then(l,c):u(s[0][2],n)}catch(e){u(s[0][3],e)}var n}function l(e){a("next",e)}function c(e){a("throw",e)}function u(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}}function rl(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=Xa(e),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(n){t[n]=e[n]&&function(t){return new Promise(function(i,r){(function(e,t,n,i){Promise.resolve(i).then(function(t){e({value:t,done:n})},t)})(i,r,(t=e[n](t)).done,t.value)})}}}function sl(e){return"function"==typeof e}function ol(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 al=ol(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 ll(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var cl=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,i,r;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var o=Xa(s),a=o.next();!a.done;a=o.next()){a.value.remove(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}else s.remove(this);var l=this.initialTeardown;if(sl(l))try{l()}catch(e){r=e instanceof al?e.errors:[e]}var c=this._finalizers;if(c){this._finalizers=null;try{for(var u=Xa(c),d=u.next();!d.done;d=u.next()){var f=d.value;try{fl(f)}catch(e){r=null!=r?r:[],e instanceof al?r=tl(tl([],el(r)),el(e.errors)):r.push(e)}}}catch(e){n={error:e}}finally{try{d&&!d.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}}if(r)throw new al(r)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)fl(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)&&ll(t,e)},e.prototype.remove=function(t){var n=this._finalizers;n&&ll(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),ul=cl.EMPTY;function dl(e){return e instanceof cl||e&&"closed"in e&&sl(e.remove)&&sl(e.add)&&sl(e.unsubscribe)}function fl(e){sl(e)?e():e.unsubscribe()}var pl={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},hl={setTimeout:function(e,t){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];var r=hl.delegate;return(null==r?void 0:r.setTimeout)?r.setTimeout.apply(r,tl([e,t],el(n))):setTimeout.apply(void 0,tl([e,t],el(n)))},clearTimeout:function(e){var t=hl.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function gl(e){hl.setTimeout(function(){throw e})}function ml(){}function vl(e){e()}var yl=function(e){function t(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,dl(t)&&t.add(n)):n.destination=Cl,n}return Wa(t,e),t.create=function(e,t,n){return new kl(e,t,n)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(cl),wl=Function.prototype.bind;function bl(e,t){return wl.call(e,t)}var Al=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){Il(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){Il(e)}else Il(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){Il(e)}},e}(),kl=function(e){function t(t,n,i){var r,s,o=e.call(this)||this;sl(t)||!t?r={next:null!=t?t:void 0,error:null!=n?n:void 0,complete:null!=i?i:void 0}:o&&pl.useDeprecatedNextContext?((s=Object.create(t)).unsubscribe=function(){return o.unsubscribe()},r={next:t.next&&bl(t.next,s),error:t.error&&bl(t.error,s),complete:t.complete&&bl(t.complete,s)}):r=t;return o.destination=new Al(r),o}return Wa(t,e),t}(yl);function Il(e){gl(e)}var Cl={closed:!0,next:ml,error:function(e){throw e},complete:ml},El="function"==typeof Symbol&&Symbol.observable||"@@observable";function xl(e){return e}var Sl=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(e,t,n){var i,r=this,s=(i=e)&&i instanceof yl||function(e){return e&&sl(e.next)&&sl(e.error)&&sl(e.complete)}(i)&&dl(i)?e:new kl(e,t,n);return vl(function(){var e=r,t=e.operator,n=e.source;s.add(t?t.call(s,n):n?r._subscribe(s):r._trySubscribe(s))}),s},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var n=this;return new(t=Bl(t))(function(t,i){var r=new kl({next:function(t){try{e(t)}catch(e){i(e),r.unsubscribe()}},error:i,complete:t});n.subscribe(r)})},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[El]=function(){return this},e.prototype.pipe=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return(0===(e=t).length?xl:1===e.length?e[0]:function(t){return e.reduce(function(e,t){return t(e)},t)})(this)},e.prototype.toPromise=function(e){var t=this;return new(e=Bl(e))(function(e,n){var i;t.subscribe(function(e){return i=e},function(e){return n(e)},function(){return e(i)})})},e.create=function(t){return new e(t)},e}();function Bl(e){var t;return null!==(t=null!=e?e:pl.Promise)&&void 0!==t?t:Promise}function Ql(e){return function(t){if(function(e){return sl(null==e?void 0:e.lift)}(t))return t.lift(function(t){try{return e(t,this)}catch(e){this.error(e)}});throw new TypeError("Unable to lift unknown Observable type")}}function Fl(e,t,n,i,r){return new Dl(e,t,n,i,r)}var Dl=function(e){function t(t,n,i,r,s,o){var a=e.call(this,t)||this;return a.onFinalize=s,a.shouldUnsubscribe=o,a._next=n?function(e){try{n(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=r?function(e){try{r(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=i?function(){try{i()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return Wa(t,e),t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(yl),$l=ol(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Pl=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return Wa(t,e),t.prototype.lift=function(e){var t=new Rl(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new $l},t.prototype.next=function(e){var t=this;vl(function(){var n,i;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var r=Xa(t.currentObservers),s=r.next();!s.done;s=r.next()){s.value.next(e)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(n)throw n.error}}}})},t.prototype.error=function(e){var t=this;vl(function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var n=t.observers;n.length;)n.shift().error(e)}})},t.prototype.complete=function(){var e=this;vl(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},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,i=n.hasError,r=n.isStopped,s=n.observers;return i||r?ul:(this.currentObservers=null,s.push(e),new cl(function(){t.currentObservers=null,ll(s,e)}))},t.prototype._checkFinalizedStatuses=function(e){var t=this,n=t.hasError,i=t.thrownError,r=t.isStopped;n?e.error(i):r&&e.complete()},t.prototype.asObservable=function(){var e=new Sl;return e.source=this,e},t.create=function(e,t){return new Rl(e,t)},t}(Sl),Rl=function(e){function t(t,n){var i=e.call(this)||this;return i.destination=t,i.source=n,i}return Wa(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:ul},t}(Pl),Tl={now:function(){return(Tl.delegate||Date).now()},delegate:void 0},Ul=function(e){function t(t,n,i){void 0===t&&(t=1/0),void 0===n&&(n=1/0),void 0===i&&(i=Tl);var r=e.call(this)||this;return r._bufferSize=t,r._windowTime=n,r._timestampProvider=i,r._buffer=[],r._infiniteTimeWindow=!0,r._infiniteTimeWindow=n===1/0,r._bufferSize=Math.max(1,t),r._windowTime=Math.max(1,n),r}return Wa(t,e),t.prototype.next=function(t){var n=this,i=n.isStopped,r=n._buffer,s=n._infiniteTimeWindow,o=n._timestampProvider,a=n._windowTime;i||(r.push(t),!s&&r.push(o.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,i=this._buffer.slice(),r=0;r<i.length&&!e.closed;r+=n?1:2)e.next(i[r]);return this._checkFinalizedStatuses(e),t},t.prototype._trimBuffer=function(){var e=this,t=e._bufferSize,n=e._timestampProvider,i=e._buffer,r=e._infiniteTimeWindow,s=(r?1:2)*t;if(t<1/0&&s<i.length&&i.splice(0,i.length-s),!r){for(var o=n.now(),a=0,l=1;l<i.length&&i[l]<=o;l+=2)a=l;a&&i.splice(0,a+1)}},t}(Pl),_l=function(e){function t(t,n){return e.call(this)||this}return Wa(t,e),t.prototype.schedule=function(e,t){return this},t}(cl),Nl={setInterval:function(e,t){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];var r=Nl.delegate;return(null==r?void 0:r.setInterval)?r.setInterval.apply(r,tl([e,t],el(n))):setInterval.apply(void 0,tl([e,t],el(n)))},clearInterval:function(e){var t=Nl.delegate;return((null==t?void 0:t.clearInterval)||clearInterval)(e)},delegate:void 0},Ll=function(e){function t(t,n){var i=e.call(this,t,n)||this;return i.scheduler=t,i.work=n,i.pending=!1,i}return Wa(t,e),t.prototype.schedule=function(e,t){var n;if(void 0===t&&(t=0),this.closed)return this;this.state=e;var i=this.id,r=this.scheduler;return null!=i&&(this.id=this.recycleAsyncId(r,i,t)),this.pending=!0,this.delay=t,this.id=null!==(n=this.id)&&void 0!==n?n:this.requestAsyncId(r,this.id,t),this},t.prototype.requestAsyncId=function(e,t,n){return void 0===n&&(n=0),Nl.setInterval(e.flush.bind(e,this),n)},t.prototype.recycleAsyncId=function(e,t,n){if(void 0===n&&(n=0),null!=n&&this.delay===n&&!1===this.pending)return t;null!=t&&Nl.clearInterval(t)},t.prototype.execute=function(e,t){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var n=this._execute(e,t);if(n)return n;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,t){var n,i=!1;try{this.work(e)}catch(e){i=!0,n=e||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),n},t.prototype.unsubscribe=function(){if(!this.closed){var t=this.id,n=this.scheduler,i=n.actions;this.work=this.state=this.scheduler=null,this.pending=!1,ll(i,this),null!=t&&(this.id=this.recycleAsyncId(n,t,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(_l),Ol=function(){function e(t,n){void 0===n&&(n=e.now),this.schedulerActionCtor=t,this.now=n}return e.prototype.schedule=function(e,t,n){return void 0===t&&(t=0),new this.schedulerActionCtor(this,e).schedule(n,t)},e.now=Tl.now,e}(),Ml=function(e){function t(t,n){void 0===n&&(n=Ol.now);var i=e.call(this,t,n)||this;return i.actions=[],i._active=!1,i}return Wa(t,e),t.prototype.flush=function(e){var t=this.actions;if(this._active)t.push(e);else{var n;this._active=!0;do{if(n=e.execute(e.state,e.delay))break}while(e=t.shift());if(this._active=!1,n){for(;e=t.shift();)e.unsubscribe();throw n}}},t}(Ol),jl=new Ml(Ll),Hl=new Sl(function(e){return e.complete()});function Gl(e){return e&&sl(e.schedule)}function Jl(e){return e[e.length-1]}function Kl(e){return Gl(Jl(e))?e.pop():void 0}function Vl(e,t){return"number"==typeof Jl(e)?e.pop():t}var ql=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};function Yl(e){return sl(null==e?void 0:e.then)}function Wl(e){return sl(e[El])}function zl(e){return Symbol.asyncIterator&&sl(null==e?void 0:e[Symbol.asyncIterator])}function Zl(e){return new TypeError("You provided "+(null!==e&&"object"==typeof e?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}var Xl="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function ec(e){return sl(null==e?void 0:e[Xl])}function tc(e){return il(this,arguments,function(){var t,n,i;return Za(this,function(r){switch(r.label){case 0:t=e.getReader(),r.label=1;case 1:r.trys.push([1,,9,10]),r.label=2;case 2:return[4,nl(t.read())];case 3:return n=r.sent(),i=n.value,n.done?[4,nl(void 0)]:[3,5];case 4:return[2,r.sent()];case 5:return[4,nl(i)];case 6:return[4,r.sent()];case 7:return r.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function nc(e){return sl(null==e?void 0:e.getReader)}function ic(e){if(e instanceof Sl)return e;if(null!=e){if(Wl(e))return r=e,new Sl(function(e){var t=r[El]();if(sl(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")});if(ql(e))return i=e,new Sl(function(e){for(var t=0;t<i.length&&!e.closed;t++)e.next(i[t]);e.complete()});if(Yl(e))return n=e,new Sl(function(e){n.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,gl)});if(zl(e))return rc(e);if(ec(e))return t=e,new Sl(function(e){var n,i;try{for(var r=Xa(t),s=r.next();!s.done;s=r.next()){var o=s.value;if(e.next(o),e.closed)return}}catch(e){n={error:e}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(n)throw n.error}}e.complete()});if(nc(e))return rc(tc(e))}var t,n,i,r;throw Zl(e)}function rc(e){return new Sl(function(t){(function(e,t){var n,i,r,s;return za(this,void 0,void 0,function(){var o,a;return Za(this,function(l){switch(l.label){case 0:l.trys.push([0,5,6,11]),n=rl(e),l.label=1;case 1:return[4,n.next()];case 2:if((i=l.sent()).done)return[3,4];if(o=i.value,t.next(o),t.closed)return[2];l.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=l.sent(),r={error:a},[3,11];case 6:return l.trys.push([6,,9,10]),i&&!i.done&&(s=n.return)?[4,s.call(n)]:[3,8];case 7:l.sent(),l.label=8;case 8:return[3,10];case 9:if(r)throw r.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})})(e,t).catch(function(e){return t.error(e)})})}function sc(e,t,n,i,r){void 0===i&&(i=0),void 0===r&&(r=!1);var s=t.schedule(function(){n(),r?e.add(this.schedule(null,i)):this.unsubscribe()},i);if(e.add(s),!r)return s}function oc(e,t){return void 0===t&&(t=0),Ql(function(n,i){n.subscribe(Fl(i,function(n){return sc(i,e,function(){return i.next(n)},t)},function(){return sc(i,e,function(){return i.complete()},t)},function(n){return sc(i,e,function(){return i.error(n)},t)}))})}function ac(e,t){return void 0===t&&(t=0),Ql(function(n,i){i.add(e.schedule(function(){return n.subscribe(i)},t))})}function lc(e,t){if(!e)throw new Error("Iterable cannot be null");return new Sl(function(n){sc(n,t,function(){var i=e[Symbol.asyncIterator]();sc(n,t,function(){i.next().then(function(e){e.done?n.complete():n.next(e.value)})},0,!0)})})}function cc(e,t){if(null!=e){if(Wl(e))return function(e,t){return ic(e).pipe(ac(t),oc(t))}(e,t);if(ql(e))return function(e,t){return new Sl(function(n){var i=0;return t.schedule(function(){i===e.length?n.complete():(n.next(e[i++]),n.closed||this.schedule())})})}(e,t);if(Yl(e))return function(e,t){return ic(e).pipe(ac(t),oc(t))}(e,t);if(zl(e))return lc(e,t);if(ec(e))return function(e,t){return new Sl(function(n){var i;return sc(n,t,function(){i=e[Xl](),sc(n,t,function(){var e,t,r;try{t=(e=i.next()).value,r=e.done}catch(e){return void n.error(e)}r?n.complete():n.next(t)},0,!0)}),function(){return sl(null==i?void 0:i.return)&&i.return()}})}(e,t);if(nc(e))return function(e,t){return lc(tc(e),t)}(e,t)}throw Zl(e)}function uc(e,t){return t?cc(e,t):ic(e)}function dc(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return uc(e,Kl(e))}function fc(e,t){return Ql(function(n,i){var r=0;n.subscribe(Fl(i,function(n){i.next(e.call(t,n,r++))}))})}var pc=Array.isArray;function hc(e){return fc(function(t){return function(e,t){return pc(t)?e.apply(void 0,tl([],el(t))):e(t)}(e,t)})}var gc=Array.isArray,mc=Object.getPrototypeOf,vc=Object.prototype,yc=Object.keys;function wc(e){if(1===e.length){var t=e[0];if(gc(t))return{args:t,keys:null};if((i=t)&&"object"==typeof i&&mc(i)===vc){var n=yc(t);return{args:n.map(function(e){return t[e]}),keys:n}}}var i;return{args:e,keys:null}}function bc(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Kl(e),i=function(e){return sl(Jl(e))?e.pop():void 0}(e),r=wc(e),s=r.args,o=r.keys;if(0===s.length)return uc([],n);var a=new Sl(function(e,t,n){void 0===n&&(n=xl);return function(i){Ac(t,function(){for(var r=e.length,s=new Array(r),o=r,a=r,l=function(r){Ac(t,function(){var l=uc(e[r],t),c=!1;l.subscribe(Fl(i,function(e){s[r]=e,c||(c=!0,a--),a||i.next(n(s.slice()))},function(){--o||i.complete()}))},i)},c=0;c<r;c++)l(c)},i)}}(s,n,o?function(e){return function(e,t){return e.reduce(function(e,n,i){return e[n]=t[i],e},{})}(o,e)}:xl));return i?a.pipe(hc(i)):a}function Ac(e,t,n){e?sc(n,e,t):t()}function kc(e,t,n){return void 0===n&&(n=1/0),sl(t)?kc(function(n,i){return fc(function(e,r){return t(n,e,i,r)})(ic(e(n,i)))},n):("number"==typeof t&&(n=t),Ql(function(t,i){return function(e,t,n,i,r,s,o,a){var l=[],c=0,u=0,d=!1,f=function(){!d||l.length||c||t.complete()},p=function(e){return c<i?h(e):l.push(e)},h=function(e){s&&t.next(e),c++;var a=!1;ic(n(e,u++)).subscribe(Fl(t,function(e){null==r||r(e),s?p(e):t.next(e)},function(){a=!0},void 0,function(){if(a)try{c--;for(var e=function(){var e=l.shift();o?sc(t,o,function(){return h(e)}):h(e)};l.length&&c<i;)e();f()}catch(e){t.error(e)}}))};return e.subscribe(Fl(t,p,function(){d=!0,f()})),function(){null==a||a()}}(t,i,e,n)}))}function Ic(e){return void 0===e&&(e=1/0),kc(xl,e)}function Cc(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Ic(1)(uc(e,Kl(e)))}function Ec(e){return new Sl(function(t){ic(e()).subscribe(t)})}function xc(e,t,n){void 0===e&&(e=0),void 0===n&&(n=jl);var i=-1;return null!=t&&(Gl(t)?n=t:i=t),new Sl(function(t){var r,s=(r=e)instanceof Date&&!isNaN(r)?+e-n.now():e;s<0&&(s=0);var o=0;return n.schedule(function(){t.closed||(t.next(o++),0<=i?this.schedule(void 0,i):t.complete())},s)})}function Sc(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Kl(e),i=Vl(e,1/0),r=e;return r.length?1===r.length?ic(r[0]):Ic(i)(uc(r,n)):Hl}function Bc(e,t){return Ql(function(n,i){var r=0;n.subscribe(Fl(i,function(n){return e.call(t,n,r++)&&i.next(n)}))})}function Qc(e){return e<=0?function(){return Hl}:Ql(function(t,n){var i=0;t.subscribe(Fl(n,function(t){++i<=e&&(n.next(t),e<=i&&n.complete())}))})}function Fc(e,t){return void 0===t&&(t=xl),e=null!=e?e:Dc,Ql(function(n,i){var r,s=!0;n.subscribe(Fl(i,function(n){var o=t(n);!s&&e(r,o)||(s=!1,r=o,i.next(n))}))})}function Dc(e,t){return e===t}function $c(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){return Cc(t,dc.apply(void 0,tl([],el(e))))}}function Pc(e){return Ql(function(t,n){try{t.subscribe(n)}finally{n.add(e)}})}function Rc(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Kl(e),i=Vl(e,1/0);return Ql(function(t,r){Ic(i)(uc(tl([t],el(e)),n)).subscribe(r)})}function Tc(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Rc.apply(void 0,tl([],el(e)))}function Uc(e,t){return Ql(function(e,t,n,i,r){return function(s,o){var a=n,l=t,c=0;s.subscribe(Fl(o,function(t){var n=c++;l=a?e(l,t,n):(a=!0,t),i&&o.next(l)},r&&function(){a&&o.next(l),o.complete()}))}}(e,t,arguments.length>=2,!0))}function _c(e,t){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];if(!0!==t){if(!1!==t){var r=new kl({next:function(){r.unsubscribe(),e()}});return ic(t.apply(void 0,tl([],el(n)))).subscribe(r)}}else e()}function Nc(e,t){return Ql(function(n,i){var r=null,s=0,o=!1,a=function(){return o&&!r&&i.complete()};n.subscribe(Fl(i,function(n){null==r||r.unsubscribe();var o=0,l=s++;ic(e(n,l)).subscribe(r=Fl(i,function(e){return i.next(t?t(n,e,l,o++):e)},function(){r=null,a()}))},function(){o=!0,a()}))})}function Lc(e,t,n){var i=sl(e)||t||n?{next:e,error:t,complete:n}:e;return i?Ql(function(e,t){var n;null===(n=i.subscribe)||void 0===n||n.call(i);var r=!0;e.subscribe(Fl(t,function(e){var n;null===(n=i.next)||void 0===n||n.call(i,e),t.next(e)},function(){var e;r=!1,null===(e=i.complete)||void 0===e||e.call(i),t.complete()},function(e){var n;r=!1,null===(n=i.error)||void 0===n||n.call(i,e),t.error(e)},function(){var e,t;r&&(null===(e=i.unsubscribe)||void 0===e||e.call(i)),null===(t=i.finalize)||void 0===t||t.call(i)}))}):xl}function Oc(e,t){return void 0!==e[0]&&void 0!==e[1]&&(!t||e[0]===t)}function Mc(e){return Oc(e,"e")}function jc(e){return Oc(e,"p")}function Hc(e){return Oc(e,"r")}function Gc(e){return Oc(e,"a")}function Jc(e){return Oc(e,"t")}const Kc=(e,...t)=>t.reduce((e,t)=>{const n=[];for(const i of e)try{const e=t(i);if(void 0===e)continue;n.push(e)}catch(e){}return n},e);var Vc=Symbol("verified");function qc(e){if(!(e instanceof Object))return!1;if("number"!=typeof e.kind)return!1;if("string"!=typeof e.content)return!1;if("number"!=typeof e.created_at)return!1;if("string"!=typeof e.pubkey)return!1;if(!e.pubkey.match(/^[a-f0-9]{64}$/))return!1;if(!Array.isArray(e.tags))return!1;for(let t=0;t<e.tags.length;t++){let n=e.tags[t];if(!Array.isArray(n))return!1;for(let e=0;e<n.length;e++)if("string"!=typeof n[e])return!1}return!0}new TextDecoder("utf-8");var Yc=new TextEncoder;function Wc(e){return Zt(vn(Yc.encode(function(e){if(!qc(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 zc=new class{generateSecretKey(){return Kt.utils.randomPrivateKey()}getPublicKey(e){return Zt(Kt.getPublicKey(e))}finalizeEvent(e,t){const n=e;return n.pubkey=Zt(Kt.getPublicKey(t)),n.id=Wc(n),n.sig=Zt(Kt.sign(Wc(n),t)),n[Vc]=!0,n}verifyEvent(e){if("boolean"==typeof e[Vc])return e[Vc];const t=Wc(e);if(t!==e.id)return e[Vc]=!1,!1;try{const n=Kt.verify(e.sig,t,e.pubkey);return e[Vc]=n,n}catch(t){return e[Vc]=!1,!1}}},Zc=zc.generateSecretKey,Xc=zc.getPublicKey;function eu(e,t,n){if(Reflect.has(e,t))return Reflect.get(e,t);{const i=n();return Reflect.set(e,t,i),i}}function tu(e,t){const[n,i]=nu(e,e=>t.id===e.id?0:t.created_at===e.created_at?-1:e.created_at-t.created_at);return i||e.splice(n,0,t),e}function nu(e,t){let n=0,i=e.length-1;for(;n<=i;){const r=Math.floor((n+i)/2),s=t(e[r]);if(0===s)return[r,!0];s<0?i=r-1:n=r+1}return[n,!1]}zc.finalizeEvent,zc.verifyEvent,new TextDecoder("utf-8"),new TextEncoder;const iu=Symbol.for("event-store"),ru=Symbol.for("event-uid"),su=Symbol.for("replaceable-address"),ou=Symbol.for("from-cache"),au=Symbol.for("replaceable-identifier");function lu(e){return Va(e)||qa(e)}function cu(e){let t=Reflect.get(e,ru);return t||(t=qa(e.kind)||Va(e.kind)?uu(e):e.id,Reflect.set(e,ru,t)),t}function uu(e){if(!qa(e.kind)&&!Va(e.kind))throw new Error("Event is not replaceable or addressable");return eu(e,su,()=>du(e.kind,e.pubkey,fu(e)))}function du(e,t,n){return e+":"+t+":"+(n??"")}function fu(e){return eu(e,au,()=>e.tags.find(e=>"d"===e[0])?.[1]??"")}function pu(){return Math.round(Date.now()/1e3)}const hu=Symbol("expiration-timestamp");function gu(e){return eu(e,hu,()=>{const t=e.tags.find(e=>"expiration"===e[0])?.[1];return t?parseInt(t):void 0})}var mu=new TextDecoder("utf-8");new TextEncoder;function vu(e){let{prefix:t,words:n}=ai.decode(e,5e3),i=new Uint8Array(ai.fromWords(n));switch(t){case"nprofile":{let e=yu(i);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:Zt(e[0][0]),relays:e[1]?e[1].map(e=>mu.decode(e)):[]}}}case"nevent":{let e=yu(i);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:Zt(e[0][0]),relays:e[1]?e[1].map(e=>mu.decode(e)):[],author:e[2]?.[0]?Zt(e[2][0]):void 0,kind:e[3]?.[0]?parseInt(Zt(e[3][0]),16):void 0}}}case"naddr":{let e=yu(i);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:mu.decode(e[0][0]),pubkey:Zt(e[2][0]),kind:parseInt(Zt(e[3][0]),16),relays:e[1]?e[1].map(e=>mu.decode(e)):[]}}}case"nsec":return{type:t,data:i};case"npub":case"note":return{type:t,data:Zt(i)};default:throw new Error(`unknown prefix ${t}`)}}function yu(e){let t={},n=e;for(;n.length>0;){let e=n[0],i=n[1],r=n.slice(2,2+i);if(n=n.slice(2+i),r.length<i)throw new Error(`not enough data to read on TLV ${e}`);t[e]=t[e]||[],t[e].push(r)}return t}function wu(e){return bu("npub",Xt(e))}function bu(e,t){return function(e,t){let n=ai.toWords(t);return ai.encode(e,n,5e3)}(e,t)}function Au(e){let t=new URL(e);return t.pathname=t.pathname.replace(/\/+/g,"/"),("80"!==t.port||"ws:"!==t.protocol&&"http:"!==t.protocol)&&("443"!==t.port||"wss:"!==t.protocol&&"https:"!==t.protocol)||(t.port=""),"string"==typeof e?t.toString():t}const ku=Symbol.for("seen-relays");function Iu(e,t){return e[ku]||(e[ku]=new Set),e[ku].add(t),e[ku]}const Cu=/^wss?:\/\/([-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}|localhost)\b([-a-zA-Z0-9()@:%_\+.~#?&\/\/=]*)$/;function Eu(e){return e.length>=8&&Cu.test(e)}function xu(e){return!!e?.toLowerCase()?.match(/^[0-9a-f]{64}$/)}const Su="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Bu(e,...t){if(!((n=e)instanceof Uint8Array||ArrayBuffer.isView(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+", got length="+e.length)}const Qu=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),Fu=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Du(e){if(Bu(e),Qu)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=Fu[e[n]];return t}const $u=48,Pu=57,Ru=65,Tu=70,Uu=97,_u=102;function Nu(e){return e>=$u&&e<=Pu?e-$u:e>=Ru&&e<=Tu?e-(Ru-10):e>=Uu&&e<=_u?e-(Uu-10):void 0}function Lu(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(Qu)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 i=new Uint8Array(n);for(let t=0,r=0;t<n;t++,r+=2){const n=Nu(e.charCodeAt(r)),s=Nu(e.charCodeAt(r+1));if(void 0===n||void 0===s){const t=e[r]+e[r+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+r)}i[t]=16*n+s}return i}function Ou(e,t=!1,n=!0){const i=e.split(":"),r=i[0]?parseInt(i[0]):void 0,s=i[1],o=i[2];if(void 0===r){if(n)return null;throw new Error("Missing kind")}if(void 0===s||""===s){if(n)return null;throw new Error("Missing pubkey")}if(t&&void 0===o){if(n)return null;throw new Error("Missing identifier")}return{kind:r,pubkey:s,identifier:o}}function Mu(e){if(!e[1])throw new Error("Missing coordinate in tag");const t=Ou(e[1],!0,!1);return e[2]&&Eu(e[2])&&(t.relays=[e[2]]),t}function ju(e){if(!e[1])throw new Error("Missing pubkey in tag");if(!xu(e[1]))throw new Error("Invalid pubkey");const t={pubkey:e[1]};return e[2]&&Eu(e[2])&&(t.relays=[Au(e[2])]),t}function Hu(e){return e.kind+":"+e.pubkey+":"+e.identifier}const Gu=Symbol.for("encrypted-content"),Ju={[pr.EncryptedDirectMessage]:"nip04",[pr.Seal]:"nip44",[pr.GiftWrap]:"nip44"};function Ku(e,t){return Ju[e]=t,e}const Vu=Gu,qu=new Set([Ku(pr.DraftLong,"nip04")]);function Yu(e,t){return qu.add(Ku(e,t)),e}function Wu(e){return function(e){return void 0!==Ju[e]}(e)&&qu.has(e)}function zu(e){return!!Wu(e.kind)&&(function(e){return!0===Reflect.has(e,Gu)}(e)&&!0===Reflect.has(e,Vu))}function Zu(e){if(Wu(e.kind))return zu(e)?e[Gu]:function(e){return Reflect.get(e,Gu)}(e)}const Xu=Symbol.for("hidden-tags"),ed=new Set([Yu(pr.BookmarkList,"nip04"),Yu(pr.InterestsList,"nip04"),Yu(pr.Mutelist,"nip04"),Yu(pr.CommunitiesList,"nip04"),Yu(pr.PublicChatsList,"nip04"),Yu(pr.SearchRelaysList,"nip04"),Yu(10009,"nip04"),Yu(pr.Bookmarksets,"nip04"),Yu(pr.Relaysets,"nip04"),Yu(pr.Followsets,"nip04"),Yu(pr.Curationsets,"nip04"),Yu(pr.Interestsets,"nip04")]);function td(e){return Wu(e)&&ed.has(e)}function nd(e){return!!td(e.kind)&&(zu(e)&&Reflect.has(e,"HiddenTagsSymbol"))}function id(e){if(!td(e.kind))return;if(nd(e))return e[Xu];const t=Zu(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 i=n.filter(e=>Array.isArray(e)).map(e=>e.map(e=>String(e)));return Reflect.set(e,Xu,i),i}const rd="abcdefghijklmnopqrstuvwxyz",sd=new Set((rd+rd.toUpperCase()).split("")),od=Symbol.for("indexable-tags");function ad(e){let t=Reflect.get(e,od);if(!t){const n=new Set;for(const t of e.tags)t.length>=2&&1===t[0].length&&sd.has(t[0])&&n.add(t[0]+":"+t[1]);t=n,Reflect.set(e,od,n)}return t}class ld{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,i=this.resetTtl){let r;if(n||this.has(e)){if(r=this.items[e],r.value=t,!1===n&&i&&(r.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==r){const e=this.last,t=r.next,n=r.prev;this.first===r&&(this.first=r.next),r.next=null,r.prev=this.last,e.next=r,null!==n&&(n.next=t),null!==t&&(t.prev=n)}}else this.max>0&&this.size===this.max&&this.evict(!0),r=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=r:this.last.next=r;return this.last=r,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 ud,dd,fd={exports:{}};function pd(){if(dd)return ud;dd=1;var e=1e3,t=60*e,n=60*t,i=24*n,r=7*i,s=365.25*i;function o(e,t,n,i){var r=t>=1.5*n;return Math.round(e/n)+" "+i+(r?"s":"")}return ud=function(a,l){l=l||{};var c=typeof a;if("string"===c&&a.length>0)return function(o){if((o=String(o)).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(o);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*s;case"weeks":case"week":case"w":return l*r;case"days":case"day":case"d":return l*i;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(r){var s=Math.abs(r);if(s>=i)return o(r,s,i,"day");if(s>=n)return o(r,s,n,"hour");if(s>=t)return o(r,s,t,"minute");if(s>=e)return o(r,s,e,"second");return r+" ms"}(a):function(r){var s=Math.abs(r);if(s>=i)return Math.round(r/i)+"d";if(s>=n)return Math.round(r/n)+"h";if(s>=t)return Math.round(r/t)+"m";if(s>=e)return Math.round(r/e)+"s";return r+"ms"}(a);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a))}}var hd=function(e){function t(e){let i,r,s,o=null;function a(...e){if(!a.enabled)return;const n=a,r=Number(new Date),s=r-(i||r);n.diff=s,n.prev=i,n.curr=r,i=r,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(i,r)=>{if("%%"===i)return"%";o++;const s=t.formatters[r];if("function"==typeof s){const t=e[o];i=s.call(n,t),e.splice(o,1),o--}return i}),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!==o?o:(r!==t.namespaces&&(r=t.namespaces,s=t.enabled(e)),s),set:e=>{o=e}}),"function"==typeof t.init&&t.init(a),a}function n(e,n){const i=t(this.namespace+(void 0===n?":":n)+e);return i.log=this.log,i}function i(e,t){let n=0,i=0,r=-1,s=0;for(;n<e.length;)if(i<t.length&&(t[i]===e[n]||"*"===t[i]))"*"===t[i]?(r=i,s=n,i++):(n++,i++);else{if(-1===r)return!1;i=r+1,s++,n=s}for(;i<t.length&&"*"===t[i];)i++;return i===t.length}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names,...t.skips.map(e=>"-"+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(i(e,n))return!1;for(const n of t.names)if(i(e,n))return!0;return!1},t.humanize=pd(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(n=>{t[n]=e[n]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t};!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let i=0,r=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(i++,"%c"===e&&(r=i))}),t.splice(r,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=hd(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(fd,fd.exports);const gd=cd(fd.exports)("applesauce");class md{log=gd.extend("EventMemory");kinds=new Map;authors=new Map;tags=new ld;created_at=[];kindAuthor=new Map;events=new ld;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 i=this.replaceable.get(du(e,t,n));return!!i&&i.length>0}getReplaceable(e,t,n){const i=du(e,t,n),r=this.replaceable.get(i);return r?.[0]}getReplaceableHistory(e,t,n){const i=du(e,t,n);return this.replaceable.get(i)}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)tu(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 ad(e))this.tags.has(t)&&this.getTagIndex(t).add(e);if(tu(this.created_at,e),lu(e.kind)){const t=e.tags.find(e=>"d"===e[0])?.[1],n=du(e.kind,e.pubkey,t);let i=this.replaceable.get(n);this.replaceable.has(n)||(i=[],this.replaceable.set(n,i)),tu(i,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 i=`${t.kind}:${t.pubkey}`;this.kindAuthor.has(i)&&this.kindAuthor.get(i).delete(t);for(const e of ad(t))this.tags.has(e)&&this.getTagIndex(e).delete(t);if(this.removeFromSortedArray(this.created_at,t),this.events.delete(n),lu(t.kind)){const e=t.tags.find(e=>"d"===e[0])?.[1],n=du(t.kind,t.pubkey,e),i=this.replaceable.get(n);i&&this.removeFromSortedArray(i,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 i of n)if(this.remove(i),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())ad(n).has(e)&&t.add(n);const i=Date.now()-n;i>100&&this.log(`Built index ${e} took ${i}ms`),this.tags.set(e,t)}return this.tags.get(e)}removeFromSortedArray(e,t){if(0===e.length)return;const n=nu(e,e=>e.created_at-t.created_at);if(n){let i=n[0],r=!1;if(e[i]===t)return void e.splice(i,1);for(let n=i-1;n>=0&&e[n].created_at===t.created_at;n--)if(e[n]===t){e.splice(n,1),r=!0;break}if(r)return;for(let n=i+1;n<e.length&&e[n].created_at===t.created_at;n++)if(e[n]===t)return void e.splice(n,1)}const i=e.indexOf(t);-1!==i&&e.splice(i,1)}*iterateAuthors(e){for(const t of e){const e=this.authors.get(t);if(e)for(const t of e)yield t}}*iterateTag(e,t){for(const n of t){const t=this.getTagIndex(e+":"+n);if(t)for(const e of t)yield e}}*iterateKinds(e){for(const t of e){const e=this.kinds.get(t);if(e)for(const t of e)yield t}}*iterateTime(e,t){let n=0,i=this.created_at.length-1,r=t?nu(this.created_at,e=>e.created_at-t):void 0;r&&(n=r[0]);const s=e?nu(this.created_at,t=>t.created_at-e):void 0;s&&(i=s[0]);for(let r=n;r<=i;r++){const n=this.created_at[r];if(!(void 0!==t&&n.created_at>t)){if(void 0!==e&&n.created_at<e)break;yield n}}}*iterateIds(e){for(const t of e)this.events.has(t)&&(yield this.events.get(t))}getEventsForFilter(e){if(e.search)return new Set;let t=!0,n=new Set;const i=e=>{const i=e instanceof Set?e:new Set(e);if(t)n=i,t=!1;else for(const e of n)i.has(e)||n.delete(e);return n};e.ids&&i(this.iterateIds(e.ids));let r=null;void 0!==e.since&&(r=Array.from(this.iterateTime(e.since,e.until)),i(r));for(const t of sd){const n=e[`&${t}`];if(n?.length)for(const e of n)i(this.iterateTag(t,[e]))}for(const t of sd){const n=e[`#${t}`];if(n?.length){const r=e[`&${t}`],s=r?n.filter(e=>!r.includes(e)):n;s.length>0&&i(this.iterateTag(t,s))}}if(e.authors&&e.kinds&&e.authors.length*e.kinds.length<=20){const t=new Set;for(const n of e.kinds)for(const i of e.authors){const e=`${n}:${i}`,r=this.kindAuthor.get(e);if(r)for(const e of r)t.add(e)}i(t)}else e.authors&&i(this.iterateAuthors(e.authors)),e.kinds&&i(this.iterateKinds(e.kinds));if(void 0===e.since&&void 0!==e.until&&(r=Array.from(this.iterateTime(e.since,e.until)),i(r)),t)return new Set(this.events.values());if(e.limit&&r){const t=new Set;for(const i of r){if(t.size>=e.limit)break;n.has(i)&&t.add(i)}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 vd(e,t){var n,i;if(0===t.length)return e;for(n=0,i=t.length;n<i;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e<0?-2*e:e}function yd(e,t,n,i){var r,s=vd(vd(vd(e,n),(r=t,Object.prototype.toString.call(r))),typeof t);if(null===t)return vd(s,"null");if(void 0===t)return vd(s,"undefined");if("object"==typeof t||"function"==typeof t){if(-1!==i.indexOf(t))return vd(s,"[Circular]"+n);i.push(t);var o=function(e,t,n){return Object.keys(t).sort().reduce(function(e,i){return yd(e,t[i],i,n)},e)}(s,t,i);if(!("valueOf"in t)||"function"!=typeof t.valueOf)return o;try{return vd(o,String(t.valueOf()))}catch(e){return vd(o,"[valueOf exception]"+(e.stack||e.message))}}return vd(s,t.toString())}var wd=function(e){return function(e,t){for(;e.length<t;)e="0"+e;return e}(yd(0,e,"",[]).toString(16),8)},bd=cd(wd);function Ad(e,t){if(e.ids&&-1===e.ids.indexOf(t.id))return!1;if(e.kinds&&-1===e.kinds.indexOf(t.kind))return!1;if(e.authors&&-1===e.authors.indexOf(t.pubkey))return!1;if(e.since&&t.created_at<e.since)return!1;if(e.until&&t.created_at>e.until)return!1;for(let n in e)if("&"===n[0]){let i=n.slice(1),r=e[n];if(r&&r.length>0){const e=ad(t);for(const t of r)if(!e.has(i+":"+t))return!1}}for(let n in e)if("#"===n[0]){let i=n.slice(1),r=e[n];if(r){const n=e[`&${i}`],s=n?r.filter(e=>!n.includes(e)):r;if(0===s.length)continue;const o=ad(t);if(!1===s.some(e=>o.has(i+":"+e)))return!1}}return!0}function kd(e,t){for(let n=0;n<e.length;n++)if(Ad(e[n],t))return!0;return!1}function Id(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:10063,pubkey:e.pubkey,relays:e.relays}).pipe(fc(e=>e?function(e){const t=Array.isArray(e)?e:e.tags;return Kc(t,e=>Oc(e,"server")&&URL.canParse(e[1])?new URL("/",e[1]):void 0)}(e):[]))}const Cd=Symbol.for("profile-content");function Ed(e){return eu(e,Cd,()=>{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 xd(e){return!!e&&((e.kind===pr.Metadata||e.kind===pr.Handlerinformation)&&!!Ed(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),i=e.reduce((e,n)=>e?t(e,n.decode):n.decode,void 0);return{encode:n,decode:i}}function i(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 r(e=""){if("string"!=typeof e)throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("join.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`join.encode: non-string input=${e}`);return t.join(e)},decode:t=>{if("string"!=typeof t)throw new Error("join.decode input should be string");return t.split(e)}}}function s(e,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 i=t.length;if(i*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;i>0&&t[i-1]===n;i--)if(!((i-1)*e%8))throw new Error("Invalid padding: string has too much padding");return t.slice(0,i)}}}function o(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,i){if(n<2)throw new Error(`convertRadix: wrong from=${n}, base cannot be less than 2`);if(i<2)throw new Error(`convertRadix: wrong to=${i}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let r=0;const s=[],o=Array.from(e);for(o.forEach(e=>{if(t(e),e<0||e>=n)throw new Error(`Wrong integer: ${e}`)});;){let e=0,t=!0;for(let s=r;s<o.length;s++){const a=o[s],l=n*e+a;if(!Number.isSafeInteger(l)||n*e/n!==e||l-a!==n*e)throw new Error("convertRadix: carry overflow");if(e=l%i,o[s]=Math.floor(l/i),!Number.isSafeInteger(o[s])||o[s]*i+e!==l)throw new Error("convertRadix: carry overflow");t&&(o[s]?t=!1:r=s)}if(s.push(e),t)break}for(let t=0;t<e.length-1&&0===e[t];t++)s.push(0);return s.reverse()}
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
Object.defineProperty(e,"__esModule",{value:!0}),e.bytes=e.stringToBytes=e.str=e.bytesToString=e.hex=e.utf8=e.bech32m=e.bech32=e.base58check=e.base58xmr=e.base58xrp=e.base58flickr=e.base58=e.base64url=e.base64=e.base32crockford=e.base32hex=e.base32=e.base16=e.utils=e.assertNumber=void 0,e.assertNumber=t;const l=(e,t)=>t?l(t,e%t):e,c=(e,t)=>e+(t-l(e,t));function u(e,n,i,r){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(i<=0||i>32)throw new Error(`convertRadix2: wrong to=${i}`);if(c(n,i)>32)throw new Error(`convertRadix2: carry overflow from=${n} to=${i} carryBits=${c(n,i)}`);let s=0,o=0;const a=2**i-1,l=[];for(const r of e){if(t(r),r>=2**n)throw new Error(`convertRadix2: invalid data word=${r} from=${n}`);if(s=s<<n|r,o+n>32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${n}`);for(o+=n;o>=i;o-=i)l.push((s>>o-i&a)>>>0);s&=2**o-1}if(s=s<<i-o&a,!r&&o>=n)throw new Error("Excess padding");if(!r&&s)throw new Error(`Non-zero padding: ${s}`);return r&&o>0&&l.push(s>>>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 p(e){if("function"!=typeof e)throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch(e){}}}function h(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 i=n(t).slice(0,e),r=new Uint8Array(t.length+e);return r.set(t),r.set(i,t.length),r},decode(t){if(!(t instanceof Uint8Array))throw new Error("checksum.decode: input should be Uint8Array");const i=t.slice(0,-e),r=n(i).slice(0,e),s=t.slice(-e);for(let t=0;t<e;t++)if(r[t]!==s[t])throw new Error("Invalid checksum");return i}}}e.utils={alphabet:i,chain:n,checksum:h,radix:d,radix2:f,join:r,padding:s},e.base16=n(f(4),i("0123456789ABCDEF"),r("")),e.base32=n(f(5),i("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),s(5),r("")),e.base32hex=n(f(5),i("0123456789ABCDEFGHIJKLMNOPQRSTUV"),s(5),r("")),e.base32crockford=n(f(5),i("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),r(""),o(e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))),e.base64=n(f(6),i("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),s(6),r("")),e.base64url=n(f(6),i("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),s(6),r(""));const g=e=>n(d(58),i(e),r(""));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 i=0;i<t.length;i+=8){const r=t.subarray(i,i+8);n+=e.base58.encode(r).padStart(m[r.length],"1")}return n},decode(t){let n=[];for(let i=0;i<t.length;i+=11){const r=t.slice(i,i+11),s=m.indexOf(r.length),o=e.base58.decode(r);for(let e=0;e<o.length-s;e++)if(0!==o[e])throw new Error("base58xmr: wrong padding");n=n.concat(Array.from(o.slice(o.length-s)))}return Uint8Array.from(n)}};e.base58check=t=>n(h(4,e=>t(t(e))),e.base58);const v=n(i("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),r("")),y=[996825010,642813549,513874426,1027748829,705979059];function w(e){const t=e>>25;let n=(33554431&e)<<5;for(let e=0;e<y.length;e++)1==(t>>e&1)&&(n^=y[e]);return n}function b(e,t,n=1){const i=e.length;let r=1;for(let t=0;t<i;t++){const n=e.charCodeAt(t);if(n<33||n>126)throw new Error(`Invalid prefix (${e})`);r=w(r)^n>>5}r=w(r);for(let t=0;t<i;t++)r=w(r)^31&e.charCodeAt(t);for(let e of t)r=w(r)^e;for(let e=0;e<6;e++)r=w(r);return r^=n,v.encode(u([r%2**30],30,5,!1))}function A(e){const t="bech32"===e?1:734539939,n=f(5),i=n.decode,r=n.encode,s=p(i);function o(e,n=90){if("string"!=typeof e)throw new Error("bech32.decode input should be string, not "+typeof e);if(e.length<8||!1!==n&&e.length>n)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);const i=e.toLowerCase();if(e!==i&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const r=(e=i).lastIndexOf("1");if(0===r||-1===r)throw new Error('Letter "1" must be present between prefix and data only');const s=e.slice(0,r),o=e.slice(r+1);if(o.length<6)throw new Error("Data must be at least 6 characters long");const a=v.decode(o).slice(0,-6),l=b(s,a,t);if(!o.endsWith(l))throw new Error(`Invalid checksum in ${e}: expected "${l}"`);return{prefix:s,words:a}}return{encode:function(e,n,i=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 r=e.length+7+n.length;if(!1!==i&&r>i)throw new TypeError(`Length ${r} exceeds limit ${i}`);return`${e=e.toLowerCase()}1${v.encode(n)}${b(e,n,t)}`},decode:o,decodeToBytes:function(e){const{prefix:t,words:n}=o(e,!1);return{prefix:t,words:n,bytes:i(n)}},decodeUnsafe:p(o),fromWords:i,fromWordsUnsafe:s,toWords:r}}e.bech32=A("bech32"),e.bech32m=A("bech32m"),e.utf8={encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)},e.hex=n(f(4),i("0123456789abcdef"),r(""),o(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 Sd={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(Sd);e<t.length;e++)t[e],Sd[t[e]].toString();const Bd=Symbol.for("public-contacts"),Qd=Symbol.for("hidden-contacts");function Fd(e){return function(...e){const t=new Map;for(const n of e)if(Array.isArray(n))for(const e of n)e&&t.set(e.pubkey,e);else n&&t.set(n.pubkey,n);return Array.from(t.values())}(function(e){return eu(e,Bd,()=>Kc(e.tags,e=>jc(e)?e:void 0,ju))}(e),function(e){if(function(e){return nd(e)&&Reflect.has(e,Qd)}(e))return e[Qd];const t=id(e);if(!t)return;const n=Kc(t,e=>jc(e)?e:void 0,ju);return Reflect.set(e,Qd,n),n}(e))}gd.extend("EncryptedContentCache"),gd.extend("event-cache"),new TextDecoder;const Dd=Symbol.for("mailboxes-inboxes"),$d=Symbol.for("mailboxes-outboxes");function Pd(e){return eu(e,Dd,()=>{const t=[];for(const n of e.tags)if(Hc(n))try{const[,e,i]=n;!e||!Eu(e)||t.includes(e)||"read"!==i&&void 0!==i||t.push(Au(e))}catch{}return t})}function Rd(e){return eu(e,$d,()=>{const t=[];for(const n of e.tags)if(Hc(n))try{const[e,i,r]=n;"r"!==e||!Eu(i)||t.includes(i)||"write"!==r&&void 0!==r||t.push(Au(i))}catch{}return t})}const Td=Symbol.for("mute-public"),Ud=Symbol.for("mute-hidden");function _d(e){return{pubkeys:new Set(e.filter(jc).map(e=>e[1])),threads:new Set(e.filter(Mc).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 Nd(e){const t=function(e){if(function(e){return nd(e)&&Reflect.has(e,Ud)}(e))return e[Ud];const t=id(e);if(!t)return;const n=_d(t);return Reflect.set(e,Ud,n),n}(e),n=function(e){return eu(e,Td,()=>_d(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 Ld;!function(e){e.nudity="nudity",e.malware="malware",e.profanity="profanity",e.illegal="illegal",e.spam="spam",e.impersonation="impersonation",e.other="other"}(Ld||(Ld={}));const Od=Symbol.for("nip10-thread-refs");function Md(e){if(!e[1])throw new Error("Missing event id in tag");let t={id:e[1]};return e[2]&&Eu(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 jd(e){return t=>{const n=new Set;return t.pipe(Lc(t=>{if(void 0!==t)if(Array.isArray(t))for(const i of t)n.has(i)||(n.add(i),e.claim(i));else n.has(t)||(n.add(t),e.claim(t))}),Pc(()=>{for(const t of n)e.removeClaim(t)}))}}function Hd(e){return t=>{let n;return t.pipe(Lc(t=>{n!==t&&(n&&e.removeClaim(n),t&&e.claim(t),n=t)}),Pc(()=>{n&&e.removeClaim(n)}))}}function Gd(){return e=>e.pipe(Bc(e=>null!=e))}function Jd(e){return t=>new Sl(n=>{let i=!1;const r=t.subscribe({next:e=>{i=!0,n.next(e)},error:e=>n.error(e),complete:()=>n.complete()});return i||n.next(e),r})}function Kd(e){return"string"==typeof e&&(e={id:e}),t=>Sc(Ec(()=>function(e,t){const n=e.getEvent(t.id);return n instanceof Promise?uc(n):dc(n)}(t,e)).pipe(function(e,t){return Nc(n=>n?dc(n):e.eventLoader?uc(e.eventLoader(t)):Hl)}(t,e),Gd()),t.insert$.pipe(Bc(t=>t.id===e.id)),t.remove$.pipe(Bc(t=>t.id===e.id),Qc(1),Ql(function(e,t){e.subscribe(Fl(t,ml))}),$c(void 0))).pipe(Hd(t),Fc((e,t)=>e?.id===t?.id),Jd(void 0))}function Vd(e){return t=>{let n;return Sc(Ec(()=>function(e,t){const n=e.getReplaceable(t.kind,t.pubkey,t.identifier);return n instanceof Promise?uc(n):dc(n)}(t,e)).pipe(function(e,t){return Nc(n=>n?dc(n):void 0!==t.identifier?e.addressableLoader?uc(e.addressableLoader(t)).pipe(Bc(e=>!!e)):Hl:e.replaceableLoader?uc(e.replaceableLoader(t)).pipe(Bc(e=>!!e)):Hl)}(t,e),Gd()),t.insert$.pipe(Bc(t=>t.pubkey==e.pubkey&&t.kind===e.kind&&(void 0===e.identifier||fu(t)===e.identifier)))).pipe(Fc((e,t)=>e.created_at>=t.created_at),Lc(e=>n=e),(i=t.remove$.pipe(Bc(e=>e.id===n?.id)),Ql(function(e,t){ic(i).subscribe(Fl(t,function(){return t.complete()},ml)),!t.closed&&e.subscribe(t)})),$c(void 0),function(e){var t,n,i=1/0;return null!=e&&("object"==typeof e?(t=e.count,i=void 0===t?1/0:t,n=e.delay):i=e),i<=0?function(){return Hl}:Ql(function(e,t){var r,s=0,o=function(){if(null==r||r.unsubscribe(),r=null,null!=n){var e="number"==typeof n?xc(n):ic(n(s)),i=Fl(t,function(){i.unsubscribe(),a()});e.subscribe(i)}else a()},a=function(){var n=!1;r=e.subscribe(Fl(t,void 0,function(){++s<i?r?o():n=!0:t.complete()})),n&&o()};a()})}(),Hd(t),Jd(void 0));var i}}function qd(e,t){return e=Array.isArray(e)?e:[e],n=>{const i=new Map;return Ec(()=>{const t=n.getTimeline(e);return t instanceof Promise?uc(t):dc(t)}).pipe(jd(n),Tc(n.insert$.pipe(Bc(t=>kd(e,t)),jd(n))),Tc(n.remove$.pipe(Bc(t=>kd(e,t)),fc(e=>e.id))),Uc((e,n)=>{if("string"==typeof n)return e.filter(e=>e.id!==n);if(Array.isArray(n)){if(!t)for(const e of n)lu(e.kind)&&i.set(cu(e),e);return n}let r=[...e];if(!t&&lu(n.kind)){const t=cu(n),s=i.get(t);if(s&&n.created_at<s.created_at)return e;i.set(t,n),s&&r.slice(r.indexOf(s),1)}return tu(r,n),r},[]),Fc(),Pc(()=>i.clear()))}}function Yd(e){return t=>bc(Object.fromEntries(e.map(e=>[e,t.model(Kd,{id:e})])))}function Wd(e){return t=>bc(Object.fromEntries(e.map(e=>[du(e.kind,e.pubkey,e.identifier),t.model(Vd,e)])))}function zd(e){return t=>{let n;return Sc(t.pipe(Lc(e=>n=e)),e.update$.pipe(Bc(e=>e.id===n?.id)))}}function Zd(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:pr.Contacts,pubkey:e.pubkey,relays:e.relays}).pipe(zd(t),fc(e=>e?Fd(e):[]))}function Xd(e){return t=>{const n=[{kinds:[1111],"#e":[e.id]}];return qa(e.kind)&&n.push({kinds:[1111],"#a":[uu(e)]}),t.timeline(n)}}function ef(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:pr.RelayList,pubkey:e.pubkey,relays:e.relays}).pipe(fc(e=>e&&{inboxes:Pd(e),outboxes:Rd(e)}))}function tf(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:pr.Mutelist,pubkey:e.pubkey,relays:e.relays}).pipe(zd(t),fc(e=>e&&Nd(e)))}function nf(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:pr.Metadata,pubkey:e.pubkey,relays:e.relays}).pipe(Bc(xd),fc(e=>e&&Ed(e)),Jd(void 0))}function rf(e){return t=>t.timeline(lu(e.kind)?[{kinds:[pr.Reaction],"#e":[e.id]},{kinds:[pr.Reaction],"#a":[cu(e)]}]:[{kinds:[pr.Reaction],"#e":[e.id]}])}const sf={kinds:[pr.ShortTextNote]};function of(e,t){const n=new Map,i=new Map,{kinds:r}={...sf,...t};let s="";const o={},a={kinds:r};var l;return"string"!=typeof(l=e)&&Reflect.has(l,"identifier")&&Reflect.has(l,"pubkey")&&Reflect.has(l,"kind")?(s=Hu(e),o.kinds=[e.kind],o.authors=[e.pubkey],o["#d"]=[e.identifier],a["#a"]=[s]):"string"==typeof e?(s=e,o.ids=[e],a["#e"]=[e]):(s=e.id,o.ids=[e.id],a["#e"]=[e.id]),e=>e.filters([o,a]).pipe(fc(e=>{if(!i.has(cu(e))){const t=function(e){return eu(e,Od,()=>{const t=function(e){const t=e.filter(e=>"e"===e[0]&&e[1]),n=e.filter(e=>"a"===e[0]&&e[1]);let i=t.find(e=>"root"===e[3]),r=t.find(e=>"reply"===e[3]),s=n.find(e=>"root"===e[3]),o=n.find(e=>"reply"===e[3]);if(i&&r||(i=r=i||r),s&&o||(s=o=s||o),!i&&!r){const e=t.filter(e=>!e[3]);e.length>=1&&(i=e[0],r=e[e.length-1]??i)}return{root:i||s?{e:i,a:s}:void 0,reply:r||o?{e:r,a:o}:void 0}}(e.tags);let n,i;if(t.root)try{n={e:t.root.e&&Md(t.root.e),a:t.root.a&&Mu(t.root.a)}}catch(e){}if(t.reply)try{i={e:t.reply.e&&Md(t.reply.e),a:t.reply.a&&Mu(t.reply.a)}}catch(e){}return{root:n,reply:i}})}(e),r=n.get(cu(e))||new Set,s={event:e,refs:t,replies:r};for(const e of r)e.parent=s;if(t.reply?.e||t.reply?.a){let e=t.reply.e?t.reply.e.id:Hu(t.reply.a);if(s.parent=i.get(e),s.parent)s.parent.replies.add(s);else{let t=n.get(e);t||(t=new Set,n.set(e,t)),t.add(s)}}i.set(cu(e),s)}return{root:i.get(s),all:i}}))}function af(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 i=e.getKey?e.getKey(...t):bd(t);let r=n.get(i);if(!r){const s=()=>{n.get(i)===r&&n.delete(i)};r=e(...t)(this).pipe(Pc(s),function(e){void 0===e&&(e={});var t=e.connector,n=void 0===t?function(){return new Pl}:t,i=e.resetOnError,r=void 0===i||i,s=e.resetOnComplete,o=void 0===s||s,a=e.resetOnRefCountZero,l=void 0===a||a;return function(e){var t,i,s,a=0,c=!1,u=!1,d=function(){null==i||i.unsubscribe(),i=void 0},f=function(){d(),t=s=void 0,c=u=!1},p=function(){var e=t;f(),null==e||e.unsubscribe()};return Ql(function(e,h){a++,u||c||d();var g=s=null!=s?s:n();h.add(function(){0!==--a||u||c||(i=_c(p,l))}),g.subscribe(h),!t&&a>0&&(t=new kl({next:function(e){return g.next(e)},error:function(e){u=!0,d(),i=_c(f,r,e),g.error(e)},complete:function(){c=!0,d(),i=_c(f,o),g.complete()}}),ic(e).subscribe(t))})(e)}}({connector:()=>new Ul(1),resetOnComplete:()=>xc(this.modelKeepWarm),resetOnRefCountZero:()=>xc(this.modelKeepWarm)})),n.set(i,r)}return r}filters(e,t=!1){e=Array.isArray(e)?e:[e];const n=this.getByFilters(e);return Sc(t?Hl:n&&"function"==typeof n.then?uc(n).pipe(kc(e=>uc(Array.from(e)))):uc(Array.from(n)),this.insert$.pipe(Bc(t=>kd(e,t))))}event(e){return"string"==typeof e&&(e={id:e}),this.model(Kd,e)}replaceable(...e){let t;if(1===e.length)t=e[0];else if(3===e.length||2===e.length){let[n,i,r]=e;t={kind:n,pubkey:i,identifier:r}}if(!t)throw new Error("Invalid arguments, expected address pointer or kind, pubkey, identifier");return this.model(Vd,t)}addressable(e){return this.model(Vd,e)}timeline(e,t=!1){return this.model(qd,e,t)}profile(e){return this.model(nf,e)}contacts(e){return"string"==typeof e&&(e={pubkey:e}),this.model(Zd,e)}mutes(e){return"string"==typeof e&&(e={pubkey:e}),this.model(tf,e)}mailboxes(e){return"string"==typeof e&&(e={pubkey:e}),this.model(ef,e)}blossomServers(e){return"string"==typeof e&&(e={pubkey:e}),this.model(Id,e)}reactions(e){return this.model(rf,e)}thread(e){return this.model(of,e)}comments(e){return this.model(Xd,e)}events(e){return this.model(Yd,e)}replaceableSet(e){return this.model(Wd,e)}}}class lf extends(af(class{})){database;memory;keepOldVersions=!1;keepExpired=!1;verifyEvent;insert$=new Pl;update$=new Pl;remove$=new Pl;eventLoader;replaceableLoader;addressableLoader;constructor(e=new md){super(),e?(this.database=e,this.memory=new md):this.database=this.memory=new md,this.insert$.subscribe(e=>{Reflect.set(e,iu,this)}),this.remove$.subscribe(e=>{Reflect.deleteProperty(e,iu)})}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(qa(e.kind)){const t=e.tags.find(e=>"d"===e[0])?.[1],n=this.deletedCoords.get(du(e.kind,e.pubkey,t));if(n)return n>e.created_at}return!1}expirations=new Map;addExpiration(e){const t=gu(e);t&&Number.isFinite(t)&&this.expirations.set(e.id,t)}expirationTimeout=null;nextExpirationCheck=null;handleExpiringEvent(e){const t=gu(e);if(!t)return;if(this.expirations.set(e.id,t),this.expirationTimeout&&this.nextExpirationCheck&&this.nextExpirationCheck<t)return;this.expirationTimeout&&clearTimeout(this.expirationTimeout);const n=t-pu();this.expirationTimeout=setTimeout(this.pruneExpired.bind(this),1e3*n+10),this.nextExpirationCheck=t}pruneExpired(){const e=pu();for(const[t,n]of this.expirations)n<=e&&(this.expirations.delete(t),this.remove(t));this.expirationTimeout&&clearTimeout(this.expirationTimeout),this.nextExpirationCheck=null,this.expirationTimeout=null}handleDeleteEvent(e){const t=function(e){return e.tags.filter(Mc).map(e=>e[1])}(e);for(const e of t)this.deletedIds.add(e),this.remove(e);const n=function(e){return e.tags.filter(Gc).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=Ou(t);if(!n)continue;const i=this.database.getReplaceableHistory(n.kind,n.pubkey,n.identifier)??[];for(const t of i)t.created_at<e.created_at&&this.remove(t)}}static mergeDuplicateEvent(e,t){const n=e[ku];if(n)for(const e of n)Iu(t,e);const i=Reflect.get(e,ou);i&&!Reflect.get(t,ou)&&Reflect.set(t,ou,i)}add(e,t){if(e.kind===pr.EventDeletion&&this.handleDeleteEvent(e),this.checkDeleted(e))return e;const n=gu(e);if(!1===this.keepExpired&&n&&n<=pu())return null;const i=lu(e.kind)?e.tags.find(e=>"d"===e[0])?.[1]:void 0;if(!this.keepOldVersions&&lu(e.kind)){const t=this.database.getReplaceableHistory(e.kind,e.pubkey,i);if(t&&t.length>0&&t[0].created_at>=e.created_at)return lf.mergeDuplicateEvent(e,t[0]),t[0]}if(this.verifyEvent&&!1===this.verifyEvent(e))return null;const r=this.memory?.add(e);if(r&&r!==e)return lf.mergeDuplicateEvent(e,r),t&&Iu(r,t),r;const s=this.mapToMemory(this.database.add(e));if(e!==s&&lf.mergeDuplicateEvent(e,s),t&&Iu(s,t),s===e&&this.insert$.next(s),!this.keepOldVersions&&lu(e.kind)){const t=this.database.getReplaceableHistory(e.kind,e.pubkey,i);if(t&&t.length>0){const n=Array.from(t).filter(t=>t.created_at<e.created_at);for(const e of n)this.remove(e);if(t.length!==n.length)return t[0]}}return!1===this.keepExpired&&n&&this.handleExpiringEvent(s),s}remove(e){let t=this.memory?.getEvent("string"==typeof e?e:e.id);this.memory&&this.memory.remove(e);const n=this.database.remove(e);return n&&t&&this.remove$.next(t),n}removeByFilters(e){const t=this.getByFilters(e);this.memory&&this.memory.removeByFilters(e);const n=this.database.removeByFilters(e);for(const e of t)this.remove$.next(e);return n}update(e){return!!this.database.add(e)&&(this.database.update?.(e),this.update$.next(e),!0)}hasEvent(e){return this.memory?.hasEvent(e)||this.database.hasEvent(e)}getEvent(e){return this.memory?.getEvent(e)??this.mapToMemory(this.database.getEvent(e))}hasReplaceable(e,t,n){return this.memory?.hasReplaceable(e,t,n)||this.database.hasReplaceable(e,t,n)}getReplaceable(e,t,n){return this.memory?.getReplaceable(e,t,n)??this.mapToMemory(this.database.getReplaceable(e,t,n))}getReplaceableHistory(e,t,n){return this.memory?.getReplaceableHistory(e,t,n)??this.database.getReplaceableHistory(e,t,n)?.map(e=>this.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)?Hl:this.remove$.pipe(Bc(t=>t.id===e),Qc(1),kc(()=>Hl))}updated(e){return this.update$.pipe(Bc(t=>t.id===e||t===e))}}function cf(){let e,t;const n=new Promise((n,i)=>{e=n,t=i});return n.resolve=e,n.reject=t,n}"navigator"in globalThis&&navigator.userAgent.includes("Android")&&navigator.clipboard&&navigator.clipboard.readText;var uf,df;Yu(pr.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"}(uf||(uf={})),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"}(df||(df={}));class ff{key;constructor(e){this.key=e||cr()}async getPublicKey(){return ur(this.key)}async signEvent(e){return dr(e,this.key)}nip04={encrypt:async(e,t)=>po.encrypt(this.key,e,t),decrypt:async(e,t)=>po.decrypt(this.key,e,t)};nip44={encrypt:async(e,t)=>Fo.v2.encrypt(t,Fo.v2.utils.getConversationKey(this.key,e)),decrypt:async(e,t)=>Fo.v2.decrypt(t,Fo.v2.utils.getConversationKey(this.key,e))};static fromKey(e){return new ff(function(e){if(e instanceof Uint8Array)return e;if(xu(e))return Lu(e);{const t=Ws.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 pf=BigInt(0),hf=BigInt(1),gf=BigInt(2),mf=BigInt(3),vf=BigInt(8),yf=Object.freeze({a:pf,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:hf,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")}),wf=(e,t)=>(e+t/gf)/t,bf={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(e){const{n:t}=yf,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),i=-hf*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),r=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,o=BigInt("0x100000000000000000000000000000000"),a=wf(s*e,t),l=wf(-i*e,t);let c=Jf(e-a*n-l*r,t),u=Jf(-a*i-l*s,t);const d=c>o,f=u>o;if(d&&(c=t-c),f&&(u=t-u),c>o||u>o)throw new Error("splitScalarEndo: Endomorphism failed, k="+e);return{k1neg:d,k1:c,k2neg:f,k2:u}}},Af=32;function kf(e){const{a:t,b:n}=yf,i=Jf(e*e),r=Jf(i*e);return Jf(r+t*e+n)}const If=yf.a===pf;function Cf(e){if(!(e instanceof Ef))throw new TypeError("JacobianPoint expected")}class Ef{constructor(e,t,n){this.x=e,this.y=t,this.z=n}static fromAffine(e){if(!(e instanceof Bf))throw new TypeError("JacobianPoint#fromAffine: expected Point");return e.equals(Bf.ZERO)?Ef.ZERO:new Ef(e.x,e.y,hf)}static toAffineBatch(e){const t=function(e,t=yf.P){const n=new Array(e.length),i=e.reduce((e,i,r)=>i===pf?e:(n[r]=e,Jf(e*i,t)),hf),r=Vf(i,t);return e.reduceRight((e,i,r)=>i===pf?e:(n[r]=Jf(e*n[r],t),Jf(e*i,t)),r),n}(e.map(e=>e.z));return e.map((e,n)=>e.toAffine(t[n]))}static normalizeZ(e){return Ef.toAffineBatch(e).map(Ef.fromAffine)}equals(e){Cf(e);const{x:t,y:n,z:i}=this,{x:r,y:s,z:o}=e,a=Jf(i*i),l=Jf(o*o),c=Jf(t*l),u=Jf(r*a),d=Jf(Jf(n*o)*l),f=Jf(Jf(s*i)*a);return c===u&&d===f}negate(){return new Ef(this.x,Jf(-this.y),this.z)}double(){const{x:e,y:t,z:n}=this,i=Jf(e*e),r=Jf(t*t),s=Jf(r*r),o=e+r,a=Jf(gf*(Jf(o*o)-i-s)),l=Jf(mf*i),c=Jf(l*l),u=Jf(c-gf*a),d=Jf(l*(a-u)-vf*s),f=Jf(gf*t*n);return new Ef(u,d,f)}add(e){Cf(e);const{x:t,y:n,z:i}=this,{x:r,y:s,z:o}=e;if(r===pf||s===pf)return this;if(t===pf||n===pf)return e;const a=Jf(i*i),l=Jf(o*o),c=Jf(t*l),u=Jf(r*a),d=Jf(Jf(n*o)*l),f=Jf(Jf(s*i)*a),p=Jf(u-c),h=Jf(f-d);if(p===pf)return h===pf?this.double():Ef.ZERO;const g=Jf(p*p),m=Jf(p*g),v=Jf(c*g),y=Jf(h*h-m-gf*v),w=Jf(h*(v-y)-d*m),b=Jf(i*o*p);return new Ef(y,w,b)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){const t=Ef.ZERO;if("bigint"==typeof e&&e===pf)return t;let n=Gf(e);if(n===hf)return this;if(!If){let e=t,i=this;for(;n>pf;)n&hf&&(e=e.add(i)),i=i.double(),n>>=hf;return e}let{k1neg:i,k1:r,k2neg:s,k2:o}=bf.splitScalar(n),a=t,l=t,c=this;for(;r>pf||o>pf;)r&hf&&(a=a.add(c)),o&hf&&(l=l.add(c)),c=c.double(),r>>=hf,o>>=hf;return i&&(a=a.negate()),s&&(l=l.negate()),l=new Ef(Jf(l.x*bf.beta),l.y,l.z),a.add(l)}precomputeWindow(e){const t=If?128/e+1:256/e+1,n=[];let i=this,r=i;for(let s=0;s<t;s++){r=i,n.push(r);for(let t=1;t<2**(e-1);t++)r=r.add(i),n.push(r);i=r.double()}return n}wNAF(e,t){!t&&this.equals(Ef.BASE)&&(t=Bf.BASE);const n=t&&t._WINDOW_SIZE||1;if(256%n)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let i=t&&Sf.get(t);i||(i=this.precomputeWindow(n),t&&1!==n&&(i=Ef.normalizeZ(i),Sf.set(t,i)));let r=Ef.ZERO,s=Ef.BASE;const o=1+(If?128/n:256/n),a=2**(n-1),l=BigInt(2**n-1),c=2**n,u=BigInt(n);for(let t=0;t<o;t++){const n=t*a;let o=Number(e&l);e>>=u,o>a&&(o-=c,e+=hf);const d=n,f=n+Math.abs(o)-1,p=t%2!=0,h=o<0;0===o?s=s.add(xf(p,i[d])):r=r.add(xf(h,i[f]))}return{p:r,f:s}}multiply(e,t){let n,i,r=Gf(e);if(If){const{k1neg:e,k1:s,k2neg:o,k2:a}=bf.splitScalar(r);let{p:l,f:c}=this.wNAF(s,t),{p:u,f:d}=this.wNAF(a,t);l=xf(e,l),u=xf(o,u),u=new Ef(Jf(u.x*bf.beta),u.y,u.z),n=l.add(u),i=c.add(d)}else{const{p:e,f:s}=this.wNAF(r,t);n=e,i=s}return Ef.normalizeZ([n,i])[0]}toAffine(e){const{x:t,y:n,z:i}=this,r=this.equals(Ef.ZERO);null==e&&(e=r?vf:Vf(i));const s=e,o=Jf(s*s),a=Jf(o*s),l=Jf(t*o),c=Jf(n*a),u=Jf(i*s);if(r)return Bf.ZERO;if(u!==hf)throw new Error("invZ was invalid");return new Bf(l,c)}}function xf(e,t){const n=t.negate();return e?n:t}Ef.BASE=new Ef(yf.Gx,yf.Gy,hf),Ef.ZERO=new Ef(pf,hf,pf);const Sf=new WeakMap;class Bf{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,Sf.delete(this)}hasEvenY(){return this.y%gf===pf}static fromCompressedHex(e){const t=32===e.length,n=jf(t?e:e.subarray(1));if(!Yf(n))throw new Error("Point is not on curve");let i=function(e){const{P:t}=yf,n=BigInt(6),i=BigInt(11),r=BigInt(22),s=BigInt(23),o=BigInt(44),a=BigInt(88),l=e*e*e%t,c=l*l*e%t,u=Kf(c,mf)*c%t,d=Kf(u,mf)*c%t,f=Kf(d,gf)*l%t,p=Kf(f,i)*f%t,h=Kf(p,r)*p%t,g=Kf(h,o)*h%t,m=Kf(g,a)*g%t,v=Kf(m,o)*h%t,y=Kf(v,mf)*c%t,w=Kf(y,s)*p%t,b=Kf(w,n)*l%t,A=Kf(b,gf);if(A*A%t!==e)throw new Error("Cannot find square root");return A}(kf(n));const r=(i&hf)===hf;if(t)r&&(i=Jf(-i));else{!(1&~e[0])!==r&&(i=Jf(-i))}const s=new Bf(n,i);return s.assertValidity(),s}static fromUncompressedHex(e){const t=jf(e.subarray(1,33)),n=jf(e.subarray(33,65)),i=new Bf(t,n);return i.assertValidity(),i}static fromHex(e){const t=Hf(e),n=t.length,i=t[0];if(n===Af)return this.fromCompressedHex(t);if(33===n&&(2===i||3===i))return this.fromCompressedHex(t);if(65===n&&4===i)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 Bf.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=Mf(e)}else{if(!$f(e))throw new TypeError("Expected valid private key");if(32!==e.length)throw new Error("Expected 32 bytes of private key");t=jf(e)}if(!qf(t))throw new Error("Expected private key: 0 < key < n");return t}(e))}static fromSignature(e,t,n){const{r:i,s:r}=function(e){if(e instanceof Df)return e.assertValidity(),e;try{return Df.fromDER(e)}catch(t){return Df.fromCompact(e)}}(t);if(![0,1,2,3].includes(n))throw new Error("Cannot recover: invalid recovery bit");const s=function(e,t=!1){const n=function(e){const t=8*e.length-256,n=jf(e);return t>0?n>>BigInt(t):n}(e);if(t)return n;const{n:i}=yf;return n>=i?n-i:n}(Hf(e)),{n:o}=yf,a=2===n||3===n?i+o:i,l=Vf(a,o),c=Jf(-s*l,o),u=Jf(r*l,o),d=1&n?"03":"02",f=Bf.fromHex(d+Lf(a)),p=Bf.BASE.multiplyAndAddUnsafe(f,c,u);if(!p)throw new Error("Cannot recover signature: point at infinify");return p.assertValidity(),p}toRawBytes(e=!1){return _f(this.toHex(e))}toHex(e=!1){const t=Lf(this.x);if(e){return`${this.hasEvenY()?"02":"03"}${t}`}return`04${t}${Lf(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(!Yf(t)||!Yf(n))throw new Error(e);const i=Jf(n*n);if(Jf(i-kf(t))!==pf)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new Bf(this.x,Jf(-this.y))}double(){return Ef.fromAffine(this).double().toAffine()}add(e){return Ef.fromAffine(this).add(Ef.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return Ef.fromAffine(this).multiply(e,this).toAffine()}multiplyAndAddUnsafe(e,t,n){const i=Ef.fromAffine(this),r=t===pf||t===hf||this!==Bf.BASE?i.multiplyUnsafe(t):i.multiply(t),s=Ef.fromAffine(e).multiplyUnsafe(n),o=r.add(s);return o.equals(Ef.ZERO)?void 0:o.toAffine()}}function Qf(e){return Number.parseInt(e[0],16)>=8?"00"+e:e}function Ff(e){if(e.length<2||2!==e[0])throw new Error(`Invalid signature integer tag: ${Rf(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:jf(n),left:e.subarray(t+2)}}Bf.BASE=new Bf(yf.Gx,yf.Gy),Bf.ZERO=new Bf(pf,pf);class Df{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromCompact(e){const t=$f(e),n="Signature.fromCompact";if("string"!=typeof e&&!t)throw new TypeError(`${n}: Expected string or Uint8Array`);const i=t?Rf(e):e;if(128!==i.length)throw new Error(`${n}: Expected 64-byte hex`);return new Df(Mf(i.slice(0,64)),Mf(i.slice(64,128)))}static fromDER(e){const t=$f(e);if("string"!=typeof e&&!t)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:n,s:i}=function(e){if(e.length<2||48!=e[0])throw new Error(`Invalid signature tag: ${Rf(e)}`);if(e[1]!==e.length-2)throw new Error("Invalid signature: incorrect length");const{data:t,left:n}=Ff(e.subarray(2)),{data:i,left:r}=Ff(n);if(r.length)throw new Error(`Invalid signature: left bytes after parsing: ${Rf(r)}`);return{r:t,s:i}}(t?e:_f(e));return new Df(n,i)}static fromHex(e){return this.fromDER(e)}assertValidity(){const{r:e,s:t}=this;if(!qf(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!qf(t))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const e=yf.n>>hf;return this.s>e}normalizeS(){return this.hasHighS()?new Df(this.r,Jf(-this.s,yf.n)):this}toDERRawBytes(){return _f(this.toDERHex())}toDERHex(){const e=Qf(Of(this.s)),t=Qf(Of(this.r)),n=e.length/2,i=t.length/2,r=Of(n),s=Of(i);return`30${Of(i+n+4)}02${s}${t}02${r}${e}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return _f(this.toCompactHex())}toCompactHex(){return Lf(this.r)+Lf(this.s)}}function $f(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}const Pf=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Rf(e){!function(e){if(!$f(e))throw new Error("Uint8Array expected")}(e);let t="";for(let n=0;n<e.length;n++)t+=Pf[e[n]];return t}const Tf={_0:48,_9:57,A:65,F:70,a:97,f:102};function Uf(e){return e>=Tf._0&&e<=Tf._9?e-Tf._0:e>=Tf.A&&e<=Tf.F?e-(Tf.A-10):e>=Tf.a&&e<=Tf.f?e-(Tf.a-10):void 0}function _f(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 i=new Uint8Array(n);for(let t=0,r=0;t<n;t++,r+=2){const n=Uf(e.charCodeAt(r)),s=Uf(e.charCodeAt(r+1));if(void 0===n||void 0===s){const t=e[r]+e[r+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+r)}i[t]=16*n+s}return i}const Nf=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function Lf(e){if("bigint"!=typeof e)throw new Error("Expected bigint");if(!(pf<=e&&e<Nf))throw new Error("Expected number 0 <= n < 2^256");return e.toString(16).padStart(64,"0")}function Of(e){const t=e.toString(16);return 1&t.length?`0${t}`:t}function Mf(e){if("string"!=typeof e)throw new TypeError("hexToNumber: expected string, got "+typeof e);return BigInt(`0x${e}`)}function jf(e){return Mf(Rf(e))}function Hf(e){return $f(e)?Uint8Array.from(e):_f(e)}function Gf(e){if("number"==typeof e&&Number.isSafeInteger(e)&&e>0)return BigInt(e);if("bigint"==typeof e&&qf(e))return e;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function Jf(e,t=yf.P){const n=e%t;return n>=pf?n:t+n}function Kf(e,t){const{P:n}=yf;let i=e;for(;t-- >pf;)i*=i,i%=n;return i}function Vf(e,t=yf.P){if(e===pf||t<=pf)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=Jf(e,t),i=t,r=pf,s=hf;for(;n!==pf;){const e=i%n,t=r-s*(i/n);i=n,n=e,r=s,s=t}if(i!==hf)throw new Error("invert: does not exist");return Jf(r,t)}function qf(e){return pf<e&&e<yf.n}function Yf(e){return pf<e&&e<yf.P}
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
function Wf(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function zf(e,t){return!!Array.isArray(t)&&(0===t.length||(e?t.every(e=>"string"==typeof e):t.every(e=>Number.isSafeInteger(e))))}function Zf(e,t){if("string"!=typeof t)throw new Error(`${e}: string expected`);return!0}function Xf(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function ep(e){if(!Array.isArray(e))throw new Error("array expected")}function tp(e,t){if(!zf(!0,t))throw new Error(`${e}: array of strings expected`)}Bf.BASE._setWindowSize(8);const np=(e,t)=>0===t?e:np(t,e%t),ip=(e,t)=>e+(t-np(e,t)),rp=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function sp(e,t,n,i){if(ep(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(ip(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${ip(t,n)}`);let r=0,s=0;const o=rp[t],a=rp[n]-1,l=[];for(const i of e){if(Xf(i),i>=o)throw new Error(`convertRadix2: invalid data word=${i} from=${t}`);if(r=r<<t|i,s+t>32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${t}`);for(s+=t;s>=n;s-=n)l.push((r>>s-n&a)>>>0);const e=rp[s];if(void 0===e)throw new Error("invalid carry");r&=e-1}if(r=r<<n-s&a,!i&&s>=t)throw new Error("Excess padding");if(!i&&r>0)throw new Error(`Non-zero padding: ${r}`);return i&&s>0&&l.push(r>>>0),l}const op=(()=>"function"==typeof Uint8Array.from([]).toBase64&&"function"==typeof Uint8Array.fromBase64)()?{encode:e=>(function(e,...t){if(!Wf(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)=>{Zf("base64",e);const n=t?/^[A-Za-z0-9=_-]+$/:/^[A-Za-z0-9=+/]+$/,i=t?"base64url":"base64";if(e.length>0&&!n.test(e))throw new Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:i,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(Xf(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(ip(8,e)>32||ip(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!Wf(n))throw new Error("radix2.encode input should be Uint8Array");return sp(Array.from(n),8,e,!t)},decode:n=>(function(e,t){if(!zf(!1,t))throw new Error(`${e}: array of numbers expected`)}("radix2.decode",n),Uint8Array.from(sp(n,e,8,t)))}}(6),function(e){const t="string"==typeof e?e.split(""):e,n=t.length;tp("alphabet",t);const i=new Map(t.map((e,t)=>[e,t]));return{encode:i=>(ep(i),i.map(i=>{if(!Number.isSafeInteger(i)||i<0||i>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${e}`);return t[i]})),decode:t=>(ep(t),t.map(t=>{Zf("alphabet.decode",t);const n=i.get(t);if(void 0===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n}))}}("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),function(e,t="="){return Xf(e),Zf("padding",t),{encode(n){for(tp("padding.encode",n);n.length*e%8;)n.push(t);return n},decode(n){tp("padding.decode",n);let i=n.length;if(i*e%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;i>0&&n[i-1]===t;i--){if((i-1)*e%8==0)throw new Error("padding: invalid, string has too much padding")}return n.slice(0,i)}}}(6),function(e=""){return Zf("join",e),{encode:t=>(tp("join.decode",t),t.join(e)),decode:t=>(Zf("join.decode",t),t.split(e))}}(""));function ap(e){return Bf.fromHex(e).toHex().substring(2)}const lp=new TextDecoder("utf-8"),cp=new TextEncoder;class up{log=gd.extend("SerialPortSigner");writer=null;pubkey;get isConnected(){return!!this.writer}verifyEvent=fr;nip04;constructor(){this.nip04={encrypt:this.nip04Encrypt.bind(this),decrypt:this.nip04Decrypt.bind(this)}}lastCommand=null;async callMethodOnDevice(e,t,n={}){if(!up.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 i=cf();return this.lastCommand=i,this.sendCommand(e,t),setTimeout(()=>{i.reject(new Error("Device timeout")),this.lastCommand===i&&(this.lastCommand=null)},6e3),this.lastCommand}async connectToDevice({onConnect:e,onDisconnect:t,onError:n,onDone:i}){let r,s=await window.navigator.serial.requestPort();await s.open({baudRate:9600}),await(e=>new Promise(t=>setTimeout(t,e)))(1e3),(async()=>{for(;s&&s.readable;){const e=new window.TextDecoderStream;s.readable.pipeTo(e.writable),r=e.readable.getReader();const t=this.readFromSerialPort(r);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===up.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(i&&i())}}catch(e){if(e instanceof Error)throw this.writer=null,n&&n(e),this.lastCommand&&(this.lastCommand.reject(e),this.lastCommand=null),e}}})();const o=new window.TextEncoderStream;o.readable.pipeTo(s.writable),this.writer=o.writable.getWriter(),await this.sendCommand(up.METHOD_PING),await this.sendCommand(up.METHOD_PING,[window.location.host]),e&&e(),s.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(i="\n")=>{if(n.length)return{value:n.shift().trim(),done:!1};const r=[];for(t&&(r.push(t),t=void 0);;){const{value:s,done:o}=await e.read();if(s){const e=s.split(i);if(e.length>1)return r.push(e.shift()),t=e.pop(),n=e,{value:r.join("").trim(),done:!1};r.push(s)}if(o)return{value:r.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=Lu(await this.callMethodOnDevice(up.METHOD_SHARED_SECRET,[ap(e)]));let i=Uint8Array.from(function(e=32){if(Su&&"function"==typeof Su.getRandomValues)return Su.getRandomValues(new Uint8Array(e));if(Su&&"function"==typeof Su.randomBytes)return Uint8Array.from(Su.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}(16)),r=cp.encode(t),s=await crypto.subtle.importKey("raw",n,{name:"AES-CBC"},!1,["encrypt"]),o=await crypto.subtle.encrypt({name:"AES-CBC",iv:i},s,r);return`${op.encode(new Uint8Array(o))}?iv=${op.encode(new Uint8Array(i.buffer))}`}async nip04Decrypt(e,t){let[n,i]=t.split("?iv=");const r=Lu(await this.callMethodOnDevice(up.METHOD_SHARED_SECRET,[ap(e)]));let s=await crypto.subtle.importKey("raw",r,{name:"AES-CBC"},!1,["decrypt"]),o=op.decode(n),a=op.decode(i),l=await crypto.subtle.decrypt({name:"AES-CBC",iv:a},s,o);return lp.decode(l)}async getPublicKey(){const e=await this.callMethodOnDevice(up.METHOD_PUBLIC_KEY,[]);return this.pubkey=e,e}async restore(e){await this.callMethodOnDevice(up.METHOD_RESTORE,[Du(e)])}async signEvent(e){const t=e.pubkey||this.pubkey;if(!t)throw new Error("Unknown signer pubkey");const n={...e,id:ar({...e,pubkey:t})},i=await this.callMethodOnDevice(up.METHOD_SIGN_MESSAGE,[n.id]),r={...n,sig:i,pubkey:t};if(!this.verifyEvent(r))throw new Error("Invalid signature");return r}ping(){this.sendCommand(up.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=[up.METHOD_PUBLIC_KEY,up.METHOD_SIGN_MESSAGE,up.METHOD_SHARED_SECRET,up.METHOD_RESTORE]}const dp=[`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`],fp=["wss://relay.damus.io","wss://nos.lol","wss://relay.nostr.band","wss://purplepag.es"],pp=[{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)"}],hp={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"},gp=3e5;class mp{constructor(){this.pool=new Tn,this.eventStore=new lf,this.isConnected=!1,this.signer=null,this.relays=[...dp]}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,i=this.pool.publish(n,e);return await Promise.allSettled(i),console.log("✓ Event published successfully"),await Cp([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 vp=new mp;function yp(e,t){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of t){const t=n.get(e.id);(!t||e.created_at>=t.created_at)&&n.set(e.id,e)}return Array.from(n.values()).sort((e,t)=>t.created_at-e.created_at)}const wp="nostrCache",bp=2,Ap="events";function kp(){return new Promise((e,t)=>{try{const n=indexedDB.open(wp,bp);n.onupgradeneeded=e=>{const t=n.result;e.oldVersion;let i;i=t.objectStoreNames.contains(Ap)?n.transaction.objectStore(Ap):t.createObjectStore(Ap,{keyPath:"id"}),i.indexNames.contains("byKindAuthor")||i.createIndex("byKindAuthor",["kind","pubkey"],{unique:!1}),i.indexNames.contains("byKindAuthorCreated")||i.createIndex("byKindAuthorCreated",["kind","pubkey","created_at"],{unique:!1}),i.indexNames.contains("byKind")||i.createIndex("byKind","kind",{unique:!1}),i.indexNames.contains("byAuthor")||i.createIndex("byAuthor","pubkey",{unique:!1}),i.indexNames.contains("byCreatedAt")||i.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 Ip(e){try{const t=await kp();await new Promise((n,i)=>{const r=t.transaction(Ap,"readwrite");r.oncomplete=()=>n(),r.onerror=()=>i(r.error),r.objectStore(Ap).put(e)})}catch(e){console.warn("IDB putEvent failed",e)}}async function Cp(e){if(e&&0!==e.length)try{const t=await kp();await new Promise((n,i)=>{const r=t.transaction(Ap,"readwrite");r.oncomplete=()=>n(),r.onerror=()=>i(r.error);const s=r.objectStore(Ap);for(const t of e)s.put(t)}),console.log(`Stored ${e.length} events in IndexedDB`)}catch(e){console.warn("IDB putEvents failed",e)}}async function Ep(e){try{const t=await kp(),n=[];console.log("QueryEventsFromDB: Starting query with filters:",e);for(const i of e){console.log("QueryEventsFromDB: Processing filter:",i);const e=await new Promise((e,n)=>{const r=t.transaction(Ap,"readonly").objectStore(Ap),s=[];let o;if(i.kinds&&i.kinds.length>0&&i.authors&&i.authors.length>0){const e=i.kinds[0],t=i.authors[0];console.log(`QueryEventsFromDB: Using byKindAuthorCreated index for kind=${e}, author=${t.substring(0,8)}...`);const n=r.index("byKindAuthorCreated"),s=IDBKeyRange.bound([e,t,-1/0],[e,t,1/0]);o=n.openCursor(s,"prev")}else if(i.kinds&&i.kinds.length>0){console.log(`QueryEventsFromDB: Using byKind index for kind=${i.kinds[0]}`);const e=r.index("byKind");o=e.openCursor(IDBKeyRange.only(i.kinds[0]))}else if(i.authors&&i.authors.length>0){console.log(`QueryEventsFromDB: Using byAuthor index for author=${i.authors[0].substring(0,8)}...`);const e=r.index("byAuthor");o=e.openCursor(IDBKeyRange.only(i.authors[0]))}else console.log("QueryEventsFromDB: Scanning all events (no specific index)"),o=r.openCursor();o.onsuccess=t=>{const n=t.target.result;if(n){const t=n.value;let r=!0;if(i.kinds&&i.kinds.length>0&&!i.kinds.includes(t.kind)&&(r=!1),i.authors&&i.authors.length>0&&!i.authors.includes(t.pubkey)&&(r=!1),i.since&&t.created_at<i.since&&(r=!1),i.until&&t.created_at>i.until&&(r=!1),i.ids&&i.ids.length>0&&!i.ids.includes(t.id)&&(r=!1),r&&s.push(t),i.limit&&s.length>=i.limit)return console.log(`QueryEventsFromDB: Reached limit of ${i.limit}, found ${s.length} matching events`),void e(s);n.continue()}else console.log(`QueryEventsFromDB: Cursor exhausted, found ${s.length} matching events`),e(s)},o.onerror=()=>{console.error("QueryEventsFromDB: Cursor error:",o.error),n(o.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 xp(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 Sp(e){console.log(`Starting profile fetch for pubkey: ${e}`);try{const t=await async function(e){try{const t=await kp();return await new Promise((n,i)=>{const r=t.transaction(Ap,"readonly").objectStore(Ap).index("byKindAuthorCreated"),s=IDBKeyRange.bound([0,e,-1/0],[0,e,1/0]),o=r.openCursor(s,"prev");o.onsuccess=()=>{const e=o.result;n(e?e.value:null)},o.onerror=()=>i(o.error)})}catch(e){return console.warn("IDB getLatestProfileEvent failed",e),null}}(e);if(t){console.log("Using cached profile event");return xp(t)}}catch(e){console.warn("Failed to load cached profile",e)}const t=[{kinds:[0],authors:[e],limit:1}];try{const n=await Qp(t,{timeout:1e4});if(n.length>0){const t=n[0];return console.log("Profile fetched from local relay:",t),Bp(t,e)}}catch(e){console.warn("Failed to fetch profile from local relay:",e)}console.log("Profile not found on local relay, trying fallback relays:",fp);try{const n=await async function(e,t){return new Promise(e=>{const n=[],i=setTimeout(()=>{r.close(),n.length>0?(n.sort((e,t)=>t.created_at-e.created_at),e(n[0])):e(null)},5e3),r=vp.pool.subscribeMany(fp,t,{onevent(e){console.log("Profile event received from fallback relay:",e.id?.substring(0,8)),n.push(e)},oneose(){clearTimeout(i),r.close(),n.length>0?(n.sort((e,t)=>t.created_at-e.created_at),e(n[0])):e(null)}})})}(0,t);if(n)return Bp(n,e)}catch(e){console.warn("Failed to fetch profile from fallback relays:",e)}return console.log("No profile found for pubkey:",e),null}async function Bp(e,t){await Ip(e);try{console.log("Publishing profile event to local relay:",e.id),await vp.publish(e),console.log("Profile event successfully saved to local relay")}catch(e){console.warn("Failed to publish profile to local relay:",e)}const n=xp(e);try{"undefined"!=typeof window&&window.dispatchEvent&&window.dispatchEvent(new CustomEvent("profile-updated",{detail:{pubkey:t,profile:n,event:e}}))}catch(e){console.warn("Failed to dispatch profile-updated event",e)}return n}async function Qp(e,t={}){console.log("Starting event fetch with filters:",JSON.stringify(e,null,2)),console.log("Current relays:",vp.relays),vp.isConnected&&0!==vp.relays.length||(console.warn("Client not connected, initializing..."),await $p());const{timeout:n=3e4,useCache:i=!0}=t;let r=[];if(i)try{r=await Ep(e),r.length>0&&console.log(`Found ${r.length} cached events in IndexedDB`)}catch(e){console.warn("Failed to query cached events",e)}return new Promise((t,i)=>{const s=[],o=setTimeout(()=>{console.log(`Timeout reached after ${n}ms, returning ${s.length} relay events`),sub.close(),s.length>0&&Cp(s).catch(e=>console.warn("Failed to cache events",e));const e=yp(r,s);t(e)},n);try{const n=Math.random().toString(36).substring(7);console.log(`📤 REQ [${n}]:`,JSON.stringify(["REQ",n,...e],null,2));const i=vp.pool.subscribeMany(vp.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)}),s.push(e),Ip(e).catch(e=>console.warn("Failed to cache event",e))},oneose(){console.log(`✅ EOSE received for REQ [${n}], got ${s.length} relay events`),clearTimeout(o),i.close(),s.length>0&&Cp(s).catch(e=>console.warn("Failed to cache events",e));const e=yp(r,s);console.log(`Merged ${r.length} cached + ${s.length} relay = ${e.length} total events`),t(e)}})}catch(e){clearTimeout(o),console.error("Failed to fetch events:",e),i(e)}})}async function Fp(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 i=await Qp(t,{timeout:n});return console.log(`Fetched ${i.length} events`),i.length>0?i[0]:null}catch(e){throw console.error("Failed to fetch event by ID:",e),e}}async function Dp(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 i=await Qp(t,{timeout:n});return console.log(`Fetched ${i.length} delete events`),i}catch(e){throw console.error("Failed to fetch delete events:",e),e}}async function $p(){await vp.connect()}async function Pp(e,t={}){const{timeout:n=3e4,cacheFirst:i=!0,cacheOnly:r=!1}=t;let s=[];if(i||r)try{if(s=await Ep(e),console.log(`Found ${s.length} events in cache`),r||s.length>0)return s}catch(e){console.warn("Failed to query cache",e)}if(!r){const t=await Qp(e,{timeout:n,useCache:!1});return console.log(`Fetched ${t.length} events from relay`),t}return s}async function Rp(){try{const e=await kp(),t=e.transaction(Ap,"readonly").objectStore(Ap),n=await new Promise((e,n)=>{const i=t.getAll();i.onsuccess=()=>e(i.result),i.onerror=()=>n(i.error)}),i=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:",i),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:i,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 Tp(e,t,n,i){return new(n||(n=Promise))(function(r,s){function o(e){try{l(i.next(e))}catch(e){s(e)}}function a(e){try{l(i.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(o,a)}l((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class Up{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 Tp(this,void 0,void 0,function*(){const t=yield this.lock();try{return yield Promise.resolve(e())}finally{t()}})}}var _p;const Np="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,Lp=null!==(_p=Np.Buffer)&&void 0!==_p?_p:null,Op=Np.TextEncoder?new Np.TextEncoder:null;function Mp(e,t){return(15&e)+(e>>6|e>>3&8)<<4|(15&t)+(t>>6|t>>3&8)}function jp(e,t){const n=t.length>>1;for(let i=0;i<n;i++){const n=i<<1;e[i]=Mp(t.charCodeAt(n),t.charCodeAt(n+1))}}const Hp="a".charCodeAt(0)-10,Gp="0".charCodeAt(0);function Jp(e,t,n){let i=0;for(let r=0;r<n;r++){let n=t[r]>>>4;e[i++]=n>9?n+Hp:n+Gp,n=15&t[r],e[i++]=n>9?n+Hp:n+Gp}return String.fromCharCode.apply(null,e)}const Kp=null!==Lp?e=>{if("string"==typeof e){const t=Lp.from(e,"utf8");return new Uint8Array(t.buffer,t.byteOffset,t.length)}if(Lp.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 Op.encode(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Invalid data type!")},Vp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",qp=new Uint8Array(256);for(let e=0;e<64;e++)qp[Vp.charCodeAt(e)]=e;function Yp(e,t=!0){const n=e.length,i=n%3,r=[],s=n-i;for(let t=0;t<s;t+=3){const n=(e[t]<<16&16711680)+(e[t+1]<<8&65280)+(255&e[t+2]),i=Vp.charAt(n>>18&63)+Vp.charAt(n>>12&63)+Vp.charAt(n>>6&63)+Vp.charAt(63&n);r.push(i)}if(1===i){const i=e[n-1],s=Vp.charAt(i>>2),o=Vp.charAt(i<<4&63);r.push(`${s}${o}`),t&&r.push("==")}else if(2===i){const i=(e[n-2]<<8)+e[n-1],s=Vp.charAt(i>>10),o=Vp.charAt(i>>4&63),a=Vp.charAt(i<<2&63);r.push(`${s}${o}${a}`),t&&r.push("=")}return r.join("")}function Wp(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,i=new Uint8Array(t);let r=0;for(let t=0;t<n;t+=4){const n=qp[e.charCodeAt(t)],s=qp[e.charCodeAt(t+1)],o=qp[e.charCodeAt(t+2)],a=qp[e.charCodeAt(t+3)];i[r]=n<<2|s>>4,r+=1,i[r]=(15&s)<<4|o>>2,r+=1,i[r]=(3&o)<<6|63&a,r+=1}return i}const zp=16384,Zp=new Up,Xp=new Map;function eh(e,t){return Tp(this,void 0,void 0,function*(){let n=null,i=null,r=!1;if("undefined"==typeof WebAssembly)throw new Error("WebAssembly is not supported in this environment!");const s=()=>new DataView(n.exports.memory.buffer).getUint32(n.exports.STATE_SIZE,!0),o=Zp.dispatch(()=>Tp(this,void 0,void 0,function*(){if(!Xp.has(e.name)){const t=Wp(e.data),n=WebAssembly.compile(t);Xp.set(e.name,n)}const t=yield Xp.get(e.name);n=yield WebAssembly.instantiate(t,{})})),a=(e=null)=>{r=!0,n.exports.Hash_Init(e)},l=e=>{if(!r)throw new Error("update() called before init()");(e=>{let t=0;for(;t<e.length;){const r=e.subarray(t,t+zp);t+=r.length,i.set(r),n.exports.Hash_Update(r.length)}})(Kp(e))},c=new Uint8Array(2*t),u=(e,s=null)=>{if(!r)throw new Error("digest() called before init()");return r=!1,n.exports.Hash_Final(s),"binary"===e?i.slice(0,t):Jp(c,i,t)},d=e=>"string"==typeof e?e.length<4096:e.byteLength<zp;let f=d;switch(e.name){case"argon2":case"scrypt":f=()=>!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(()=>Tp(this,void 0,void 0,function*(){n||(yield o);const e=n.exports.Hash_GetBuffer(),t=n.exports.memory.buffer;i=new Uint8Array(t,e,zp)}))(),{getMemory:()=>i,writeMemory:(e,t=0)=>{i.set(e,t)},getExports:()=>n.exports,setMemorySize:e=>{n.exports.Hash_SetMemorySize(e);const t=n.exports.Hash_GetBuffer(),r=n.exports.memory.buffer;i=new Uint8Array(r,t,e)},init:a,update:l,digest:u,save:()=>{if(!r)throw new Error("save() can only be called after init() and before digest()");const t=n.exports.Hash_GetState(),i=s(),o=n.exports.memory.buffer,a=new Uint8Array(o,t,i),l=new Uint8Array(4+i);return jp(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 i=n.exports.Hash_GetState(),o=s(),a=4+o,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<t.length;n++){const i=n<<1;if(t[n]!==Mp(e.charCodeAt(i),e.charCodeAt(i+1)))return!1}return!0}(e.hash,t.subarray(0,4)))throw new Error("This state was written by an incompatible hash implementation");const c=t.subarray(4);new Uint8Array(l,i,o).set(c),r=!0},calculate:(e,r=null,s=null)=>{if(!f(e,r))return a(r),l(e),u("hex",s);const o=Kp(e);return i.set(o),n.exports.Hash_Calculate(o.length,r,s),Jp(c,i,t)},hashLength:t}})}new Up;var th={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"},nh={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 ih(e){return!Number.isInteger(e)||e<8||e>512||e%8!=0?new Error("Invalid variant! Valid values: 8, 16, ..., 512"):null}function rh(e=512,t=null){if(ih(e))return Promise.reject(ih(e));let n=null,i=e;if(null!==t){if(n=Kp(t),n.length>64)return Promise.reject(new Error("Max key length is 64 bytes"));r=e,s=n.length,i=r|s<<16}var r,s;const o=e/8;return eh(nh,o).then(e=>{i>512&&e.writeMemory(n),e.init(i);const t={init:i>512?()=>(e.writeMemory(n),e.init(i),t):()=>(e.init(i),t),update:n=>(e.update(n),t),digest:t=>e.digest(t),save:()=>e.save(),load:n=>(e.load(n),t),blockSize:128,digestSize:o};return t})}new Up;const sh=new DataView(new ArrayBuffer(4));function oh(e){return sh.setInt32(0,e,!0),new Uint8Array(sh.buffer)}function ah(e,t,n){return Tp(this,void 0,void 0,function*(){if(n<=64){const e=yield rh(8*n);return e.update(oh(n)),e.update(t),e.digest("binary")}const i=Math.ceil(n/32)-2,r=new Uint8Array(n);e.init(),e.update(oh(n)),e.update(t);let s=e.digest("binary");r.set(s.subarray(0,32),0);for(let t=1;t<i;t++)e.init(),e.update(s),s=e.digest("binary"),r.set(s.subarray(0,32),32*t);const o=n-32*i;let a;return 64===o?(a=e,a.init()):a=yield rh(8*o),a.update(s),s=a.digest("binary"),r.set(s.subarray(0,o),32*i),r})}function lh(e){return Tp(this,void 0,void 0,function*(){var t;const{parallelism:n,iterations:i,hashLength:r}=e,s=Kp(e.password),o=Kp(e.salt),a=function(e){switch(e){case"d":return 0;case"i":return 1;default:return 2}}(e.hashType),{memorySize:l}=e,c=Kp(null!==(t=e.secret)&&void 0!==t?t:""),[u,d]=yield Promise.all([eh(th,1024),rh(512)]);u.setMemorySize(1024*l+1024);const f=new Uint8Array(24),p=new DataView(f.buffer);p.setInt32(0,n,!0),p.setInt32(4,r,!0),p.setInt32(8,l,!0),p.setInt32(12,i,!0),p.setInt32(16,19,!0),p.setInt32(20,a,!0),u.writeMemory(f,1024*l),d.init(),d.update(f),d.update(oh(s.length)),d.update(s),d.update(oh(o.length)),d.update(o),d.update(oh(c.length)),d.update(c),d.update(oh(0));const h=4*Math.floor(l/(4*n)),g=new Uint8Array(72),m=d.digest("binary");g.set(m);for(let e=0;e<n;e++){g.set(oh(0),64),g.set(oh(e),68);let t=e*h,n=yield ah(d,g,1024);u.writeMemory(n,1024*t),t+=1,g.set(oh(1),64),n=yield ah(d,g,1024),u.writeMemory(n,1024*t)}const v=new Uint8Array(1024);jp(v,u.calculate(new Uint8Array([]),l));const y=yield ah(d,v,r);if("hex"===e.outputType){return Jp(new Uint8Array(2*r),y,r)}return"encoded"===e.outputType?function(e,t,n){const i=[`m=${t.memorySize}`,`t=${t.iterations}`,`p=${t.parallelism}`].join(",");return`$argon2${t.hashType}$v=19$${i}$${Yp(e,!1)}$${Yp(n,!1)}`}(o,e,y):y})}function ch(e){return Tp(this,void 0,void 0,function*(){return(e=>{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=Kp(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=Kp(e.salt),e.salt.length<8)throw new Error("Salt should be at least 8 bytes long");if(e.secret=Kp(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),lh(Object.assign(Object.assign({},e),{hashType:"id"}))})}new Up,new Up,new Up,new Up,new Up,new Up,new Up,new Up,new Up,new Up,new Up,new Up,new Up,new Up,new Up,new Up,new Up,new Up,new Up,new Up;const uh={parallelism:4,iterations:8,memorySize:262144,hashLength:32,outputType:"binary"};let dh=null,fh=0;const ph=new Map;async function hh(e,t){try{const n=function(){if(dh)return dh;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 dh=new Worker(URL.createObjectURL(e)),dh.onmessage=function(e){const{id:t,success:n,result:i,error:r}=e.data,s=ph.get(t);s&&(ph.delete(t),n?s.resolve(new Uint8Array(i)):s.reject(new Error(r)))},dh.onerror=function(e){console.error("Argon2 worker error:",e)},dh}(),i=++fh;return new Promise((r,s)=>{ph.set(i,{resolve:r,reject:s}),n.postMessage({id:i,password:e,salt:Array.from(t)})})}catch(n){console.warn("Worker failed, falling back to main thread:",n);return await ch({password:e,salt:t,...uh})}}const{window:gh}=l;function mh(e){let t,n,r,s,o,a,l,f,h,g,v,A,k,I,C,E,x,B;function Q(e,t){return"extension"===e[2]?yh:vh}let F=Q(e),D=F(e),$=e[10]&&Fh(e),P=e[11]&&Dh(e);return{c(){t=p("div"),n=p("div"),r=p("div"),s=p("h2"),s.textContent="Login to Nostr",o=m(),a=p("button"),a.textContent="×",l=m(),f=p("div"),h=p("div"),g=p("button"),g.textContent="Extension",v=m(),A=p("button"),A.textContent="Nsec",k=m(),I=p("div"),D.c(),C=m(),$&&$.c(),E=m(),P&&P.c(),b(s,"class","svelte-4xpfbi"),b(a,"class","close-btn svelte-4xpfbi"),b(r,"class","modal-header svelte-4xpfbi"),b(g,"class","tab-btn svelte-4xpfbi"),S(g,"active","extension"===e[2]),b(A,"class","tab-btn svelte-4xpfbi"),S(A,"active","nsec"===e[2]),b(h,"class","tabs svelte-4xpfbi"),b(I,"class","tab-content svelte-4xpfbi"),b(f,"class","tab-container svelte-4xpfbi"),b(n,"class","modal svelte-4xpfbi"),S(n,"dark-theme",e[1]),b(t,"class","modal-overlay svelte-4xpfbi"),b(t,"role","button"),b(t,"tabindex","0")},m(i,d){u(i,t,d),c(t,n),c(n,r),c(r,s),c(r,o),c(r,a),c(n,l),c(n,f),c(f,h),c(h,g),c(h,v),c(h,A),c(f,k),c(f,I),D.m(I,null),c(I,C),$&&$.m(I,null),c(I,E),P&&P.m(I,null),x||(B=[y(a,"click",e[17]),y(g,"click",e[26]),y(A,"click",e[27]),y(n,"click",w(e[24])),y(n,"keydown",w(e[25])),y(t,"click",e[17]),y(t,"keydown",e[32])],x=!0)},p(e,t){4&t[0]&&S(g,"active","extension"===e[2]),4&t[0]&&S(A,"active","nsec"===e[2]),F===(F=Q(e))&&D?D.p(e,t):(D.d(1),D=F(e),D&&(D.c(),D.m(I,C))),e[10]?$?$.p(e,t):($=Fh(e),$.c(),$.m(I,E)):$&&($.d(1),$=null),e[11]?P?P.p(e,t):(P=Dh(e),P.c(),P.m(I,null)):P&&(P.d(1),P=null),2&t[0]&&S(n,"dark-theme",e[1])},d(e){e&&d(t),D.d(),$&&$.d(),P&&P.d(),x=!1,i(B)}}}function vh(e){let t;function n(e,t){return e[14]?bh:wh}let i=n(e),r=i(e);return{c(){t=p("div"),r.c(),b(t,"class","nsec-login svelte-4xpfbi")},m(e,n){u(e,t,n),r.m(t,null)},p(e,s){i===(i=n(e))&&r?r.p(e,s):(r.d(1),r=i(e),r&&(r.c(),r.m(t,null)))},d(e){e&&d(t),r.d()}}}function yh(e){let t,n,i,r,s,o,a,l=e[7]?"Connecting...":"Log in using extension";return{c(){t=p("div"),n=p("p"),n.textContent="Login using a NIP-07 compatible browser\n extension like nos2x or Alby.",i=m(),r=p("button"),s=g(l),b(n,"class","svelte-4xpfbi"),b(r,"class","login-extension-btn svelte-4xpfbi"),r.disabled=e[7],b(t,"class","extension-login svelte-4xpfbi")},m(l,d){u(l,t,d),c(t,n),c(t,i),c(t,r),c(r,s),o||(a=y(r,"click",e[21]),o=!0)},p(e,t){128&t[0]&&l!==(l=e[7]?"Connecting...":"Log in using extension")&&k(s,l),128&t[0]&&(r.disabled=e[7])},d(e){e&&d(t),o=!1,a()}}}function wh(e){let t,n,r,s,o,a,l,f,h,v,w,A,C,E,x,S,B,Q,F,D,$,P,R,T=e[8]?"Generating...":"Generate New Key",U=e[12]&&Ah(e),_=e[4]&&kh(e);function N(e,t){return e[9]?Eh:e[7]?Ch:Ih}let L=N(e),O=L(e);return{c(){t=p("p"),t.textContent="Enter your nsec or generate a new one. Optionally\n set a password to encrypt it securely.",n=m(),r=p("button"),s=g(T),a=m(),U&&U.c(),l=m(),f=p("input"),v=m(),w=p("div"),A=p("label"),A.textContent="Encryption Password (optional but recommended):",C=m(),E=p("input"),S=m(),_&&_.c(),B=m(),Q=p("small"),Q.textContent="Password uses Argon2id with ~3 second derivation time for security.",F=m(),D=p("button"),O.c(),b(t,"class","svelte-4xpfbi"),b(r,"class","generate-btn svelte-4xpfbi"),r.disabled=o=e[7]||e[8],b(f,"type","password"),b(f,"placeholder","nsec1..."),f.disabled=h=e[7]||e[9],b(f,"class","nsec-input svelte-4xpfbi"),b(A,"class","svelte-4xpfbi"),b(E,"type","password"),b(E,"placeholder","Enter password (min 8 chars)"),E.disabled=x=e[7]||e[9],b(E,"class","password-input svelte-4xpfbi"),b(Q,"class","password-hint svelte-4xpfbi"),b(w,"class","password-section svelte-4xpfbi"),b(D,"class","login-nsec-btn svelte-4xpfbi"),D.disabled=$=e[7]||e[9]||!e[3].trim()},m(i,o){u(i,t,o),u(i,n,o),u(i,r,o),c(r,s),u(i,a,o),U&&U.m(i,o),u(i,l,o),u(i,f,o),I(f,e[3]),u(i,v,o),u(i,w,o),c(w,A),c(w,C),c(w,E),I(E,e[4]),c(w,S),_&&_.m(w,null),c(w,B),c(w,Q),u(i,F,o),u(i,D,o),O.m(D,null),P||(R=[y(r,"click",e[20]),y(f,"input",e[29]),y(E,"input",e[30]),y(D,"click",e[22])],P=!0)},p(e,t){256&t[0]&&T!==(T=e[8]?"Generating...":"Generate New Key")&&k(s,T),384&t[0]&&o!==(o=e[7]||e[8])&&(r.disabled=o),e[12]?U?U.p(e,t):(U=Ah(e),U.c(),U.m(l.parentNode,l)):U&&(U.d(1),U=null),640&t[0]&&h!==(h=e[7]||e[9])&&(f.disabled=h),8&t[0]&&f.value!==e[3]&&I(f,e[3]),640&t[0]&&x!==(x=e[7]||e[9])&&(E.disabled=x),16&t[0]&&E.value!==e[4]&&I(E,e[4]),e[4]?_?_.p(e,t):(_=kh(e),_.c(),_.m(w,B)):_&&(_.d(1),_=null),L!==(L=N(e))&&(O.d(1),O=L(e),O&&(O.c(),O.m(D,null))),648&t[0]&&$!==($=e[7]||e[9]||!e[3].trim())&&(D.disabled=$)},d(e){e&&d(t),e&&d(n),e&&d(r),e&&d(a),U&&U.d(e),e&&d(l),e&&d(f),e&&d(v),e&&d(w),_&&_.d(),e&&d(F),e&&d(D),O.d(),P=!1,i(R)}}}function bh(e){let t,n,r,s,o,a,l,f,h,v,w,A,k,C,E=e[15]&&xh(e);function x(e,t){return e[9]?Qh:e[7]?Bh:Sh}let S=x(e),B=S(e);return{c(){t=p("p"),t.textContent="You have a stored encrypted key. Enter your\n password to unlock it.",n=m(),E&&E.c(),r=m(),s=p("input"),a=m(),l=p("button"),B.c(),h=m(),v=p("button"),w=g("Clear stored key & start fresh"),b(t,"class","svelte-4xpfbi"),b(s,"type","password"),b(s,"placeholder","Enter your password"),s.disabled=o=e[7]||e[9],b(s,"class","password-input svelte-4xpfbi"),b(l,"class","login-nsec-btn svelte-4xpfbi"),l.disabled=f=e[7]||e[9]||!e[6],b(v,"class","clear-btn svelte-4xpfbi"),v.disabled=A=e[7]||e[9]},m(i,o){u(i,t,o),u(i,n,o),E&&E.m(i,o),u(i,r,o),u(i,s,o),I(s,e[6]),u(i,a,o),u(i,l,o),B.m(l,null),u(i,h,o),u(i,v,o),c(v,w),k||(C=[y(s,"input",e[28]),y(l,"click",e[18]),y(v,"click",e[16])],k=!0)},p(e,t){e[15]?E?E.p(e,t):(E=xh(e),E.c(),E.m(r.parentNode,r)):E&&(E.d(1),E=null),640&t[0]&&o!==(o=e[7]||e[9])&&(s.disabled=o),64&t[0]&&s.value!==e[6]&&I(s,e[6]),S!==(S=x(e))&&(B.d(1),B=S(e),B&&(B.c(),B.m(l,null))),704&t[0]&&f!==(f=e[7]||e[9]||!e[6])&&(l.disabled=f),640&t[0]&&A!==(A=e[7]||e[9])&&(v.disabled=A)},d(e){e&&d(t),e&&d(n),E&&E.d(e),e&&d(r),e&&d(s),e&&d(a),e&&d(l),B.d(),e&&d(h),e&&d(v),k=!1,i(C)}}}function Ah(e){let t,n,i,r,s;return{c(){t=p("div"),n=p("label"),n.textContent="Your new public key (npub):",i=m(),r=p("code"),s=g(e[12]),b(n,"class","svelte-4xpfbi"),b(r,"class","npub-display svelte-4xpfbi"),b(t,"class","generated-info svelte-4xpfbi")},m(e,o){u(e,t,o),c(t,n),c(t,i),c(t,r),c(r,s)},p(e,t){4096&t[0]&&k(s,e[12])},d(e){e&&d(t)}}}function kh(e){let t,n,i,r;return{c(){t=p("input"),b(t,"type","password"),b(t,"placeholder","Confirm password"),t.disabled=n=e[7]||e[9],b(t,"class","password-input svelte-4xpfbi")},m(n,s){u(n,t,s),I(t,e[5]),i||(r=y(t,"input",e[31]),i=!0)},p(e,i){640&i[0]&&n!==(n=e[7]||e[9])&&(t.disabled=n),32&i[0]&&t.value!==e[5]&&I(t,e[5])},d(e){e&&d(t),i=!1,r()}}}function Ih(e){let t;return{c(){t=g("Log in with nsec")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Ch(e){let t;return{c(){t=g("Logging in...")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Eh(e){let t;return{c(){t=g("Deriving key...")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function xh(e){let t,n,i,r,s,o,a,l=e[15].slice(0,16)+"",f=e[15].slice(-8)+"";return{c(){t=p("div"),n=p("label"),n.textContent="Stored public key:",i=m(),r=p("code"),s=g(l),o=g("..."),a=g(f),b(n,"class","svelte-4xpfbi"),b(r,"class","npub-display svelte-4xpfbi"),b(t,"class","stored-info svelte-4xpfbi")},m(e,l){u(e,t,l),c(t,n),c(t,i),c(t,r),c(r,s),c(r,o),c(r,a)},p(e,t){32768&t[0]&&l!==(l=e[15].slice(0,16)+"")&&k(s,l),32768&t[0]&&f!==(f=e[15].slice(-8)+"")&&k(a,f)},d(e){e&&d(t)}}}function Sh(e){let t;return{c(){t=g("Unlock")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Bh(e){let t;return{c(){t=g("Unlocking...")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Qh(e){let t;return{c(){t=g("Deriving key...")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Fh(e){let t,n;return{c(){t=p("div"),n=g(e[10]),b(t,"class","message error-message svelte-4xpfbi")},m(e,i){u(e,t,i),c(t,n)},p(e,t){1024&t[0]&&k(n,e[10])},d(e){e&&d(t)}}}function Dh(e){let t,n;return{c(){t=p("div"),n=g(e[11]),b(t,"class","message success-message svelte-4xpfbi")},m(e,i){u(e,t,i),c(t,n)},p(e,t){2048&t[0]&&k(n,e[11])},d(e){e&&d(t)}}}function $h(e){let t,n,i,r,s,o,a,l,f,h,v,y=e[13].toFixed(1)+"";return{c(){t=p("div"),n=p("div"),i=p("div"),r=m(),s=p("h3"),s.textContent="Deriving encryption key",o=m(),a=p("div"),l=g(y),f=g("s"),h=m(),v=p("p"),v.textContent="This may take 3-6 seconds for security",b(i,"class","deriving-spinner svelte-4xpfbi"),b(s,"class","svelte-4xpfbi"),b(a,"class","deriving-timer svelte-4xpfbi"),b(v,"class","deriving-note svelte-4xpfbi"),b(n,"class","deriving-modal svelte-4xpfbi"),S(n,"dark-theme",e[1]),b(t,"class","deriving-overlay svelte-4xpfbi")},m(e,d){u(e,t,d),c(t,n),c(n,i),c(n,r),c(n,s),c(n,o),c(n,a),c(a,l),c(a,f),c(n,h),c(n,v)},p(e,t){8192&t[0]&&y!==(y=e[13].toFixed(1)+"")&&k(l,y),2&t[0]&&S(n,"dark-theme",e[1])},d(e){e&&d(t)}}}function Ph(t){let n,i,r,s,o=t[0]&&mh(t),a=t[9]&&$h(t);return{c(){o&&o.c(),n=m(),a&&a.c(),i=v()},m(e,l){o&&o.m(e,l),u(e,n,l),a&&a.m(e,l),u(e,i,l),r||(s=y(gh,"keydown",t[23]),r=!0)},p(e,t){e[0]?o?o.p(e,t):(o=mh(e),o.c(),o.m(n.parentNode,n)):o&&(o.d(1),o=null),e[9]?a?a.p(e,t):(a=$h(e),a.c(),a.m(i.parentNode,i)):a&&(a.d(1),a=null)},i:e,o:e,d(e){o&&o.d(e),e&&d(n),a&&a.d(e),e&&d(i),r=!1,s()}}}function Rh(e,t,n){const i=P();let{showModal:r=!1}=t,{isDarkTheme:s=!1}=t,o="extension",a="",l="",c="",u="",d=!1,f=!1,p=!1,h="",g="",m="",v="",y=0,w=null,b=null;function A(){n(13,y=0),w=performance.now(),k()}function k(){null!==w&&(n(13,y=(performance.now()-w)/1e3),b=requestAnimationFrame(k))}function I(){w=null,b&&(cancelAnimationFrame(b),b=null)}$(()=>{I()});let C=!1,E="";function x(){n(14,C=!!localStorage.getItem("nostr_privkey_encrypted")),n(15,E=localStorage.getItem("nostr_pubkey")||"")}function S(){n(0,r=!1),n(3,a=""),n(4,l=""),n(5,c=""),n(6,u=""),n(10,h=""),n(11,g=""),m="",n(12,v=""),i("close")}function B(e){n(2,o=e),n(10,h=""),n(11,g=""),m="",n(12,v="")}async function Q(){n(7,d=!0),n(10,h=""),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=ff.fromKey(a.trim()),t=await e.getPublicKey();if(localStorage.setItem("nostr_auth_method","nsec"),localStorage.setItem("nostr_pubkey",t),l){n(9,p=!0),A();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)),i=crypto.getRandomValues(new Uint8Array(12)),r=await hh(t,n),s=await crypto.subtle.importKey("raw",r,{name:"AES-GCM"},!1,["encrypt"]),o=new TextEncoder,a=await crypto.subtle.encrypt({name:"AES-GCM",iv:i},s,o.encode(e)),l=new Uint8Array(n.length+i.length+a.byteLength);return l.set(n,0),l.set(i,n.length),l.set(new Uint8Array(a),n.length+i.length),btoa(String.fromCharCode(...l))}(a.trim(),l);I(),n(9,p=!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!");i("login",{method:"nsec",pubkey:t,privateKey:a.trim(),signer:e}),setTimeout(()=>{S()},1500)}catch(e){n(10,h=e.message)}finally{n(7,d=!1)}}D(()=>{x()});return e.$$set=e=>{"showModal"in e&&n(0,r=e.showModal),"isDarkTheme"in e&&n(1,s=e.isDarkTheme)},e.$$.update=()=>{1&e.$$.dirty[0]&&r&&x()},[r,s,o,a,l,c,u,d,f,p,h,g,v,y,C,E,function(){localStorage.removeItem("nostr_privkey_encrypted"),localStorage.removeItem("nostr_privkey"),localStorage.removeItem("nostr_pubkey"),localStorage.removeItem("nostr_auth_method"),n(14,C=!1),n(15,E=""),n(6,u=""),n(10,h=""),n(11,g="")},S,async function(){n(7,d=!0),n(9,p=!0),A(),n(10,h=""),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 i=n.slice(0,32),r=n.slice(32,44),s=n.slice(44),o=await hh(t,i),a=await crypto.subtle.importKey("raw",o,{name:"AES-GCM"},!1,["decrypt"]);let l;try{l=await crypto.subtle.decrypt({name:"AES-GCM",iv:r},a,s)}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,p=!1);const r=ff.fromKey(t),s=await r.getPublicKey();i("login",{method:"nsec",pubkey:s,privateKey:t,signer:r}),S()}catch(e){I(),e.message.includes("decrypt")||e.message.includes("tag")?n(10,h="Invalid password"):n(10,h=e.message)}finally{n(7,d=!1),n(9,p=!1),I()}},B,async function(){n(8,f=!0),n(10,h=""),n(11,g="");try{const e=Zc(),t=bu("nsec",e),i=wu(Xc(e));m=t,n(12,v=i),n(3,a=t),n(11,g="New key generated! Set an encryption password below to secure it.")}catch(e){n(10,h="Failed to generate key: "+e.message)}finally{n(8,f=!1)}},async function(){n(7,d=!0),n(10,h=""),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!"),i("login",{method:"extension",pubkey:e,signer:window.nostr}),setTimeout(()=>{S()},1500))}catch(e){n(10,h=e.message)}finally{n(7,d=!1)}},Q,function(e){"Escape"===e.key&&S(),"Enter"===e.key&&"nsec"===o&&Q()},function(t){R.call(this,e,t)},function(t){R.call(this,e,t)},()=>B("extension"),()=>B("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&&S()]}class Th extends se{constructor(e){super(),re(this,e,Rh,Ph,s,{showModal:0,isDarkTheme:1},null,[-1,-1])}}function Uh(e,t,n){const i=e.slice();return i[72]=t[n],i}function _h(e,t,n){const i=e.slice();return i[75]=t[n],i}function Nh(e,t,n){const i=e.slice();return i[72]=t[n],i}function Lh(e,t,n){const i=e.slice();return i[72]=t[n],i}function Oh(e,t,n){const i=e.slice();return i[72]=t[n],i}function Mh(e,t,n){const i=e.slice();return i[72]=t[n],i}function jh(e,t,n){const i=e.slice();return i[72]=t[n],i}function Hh(e){let t,n,i;return{c(){t=p("div"),n=g(e[3]),b(t,"class",i="message "+e[4]+" svelte-1y8wjwc")},m(e,i){u(e,t,i),c(t,n)},p(e,r){8&r[0]&&k(n,e[3]),16&r[0]&&i!==(i="message "+e[4]+" svelte-1y8wjwc")&&b(t,"class",i)},d(e){e&&d(t)}}}function Gh(e){let t,n,r,s,o,a,l,f,h,v,w,A,k,C,E,x,S,B,Q,F,D,$,P,R,T,U,_,N;function L(e,t){return e[5]&&e[5].length>0?Kh:Jh}let O=L(e),M=O(e);function j(e,t){return e[8]&&e[8].length>0?Wh:Yh}let H=j(e),G=H(e);return{c(){t=p("div"),n=p("div"),r=p("h3"),r.textContent="Banned Pubkeys",s=m(),o=p("div"),a=p("input"),l=m(),f=p("input"),h=m(),v=p("button"),w=g("Ban Pubkey"),A=m(),k=p("div"),M.c(),C=m(),E=p("div"),x=p("h3"),x.textContent="Allowed Pubkeys",S=m(),B=p("div"),Q=p("input"),F=m(),D=p("input"),$=m(),P=p("button"),R=g("Allow Pubkey"),T=m(),U=p("div"),G.c(),b(r,"class","svelte-1y8wjwc"),b(a,"type","text"),b(a,"placeholder","Pubkey (64 hex chars)"),b(a,"class","svelte-1y8wjwc"),b(f,"type","text"),b(f,"placeholder","Reason (optional)"),b(f,"class","svelte-1y8wjwc"),v.disabled=e[2],b(v,"class","svelte-1y8wjwc"),b(o,"class","add-form svelte-1y8wjwc"),b(k,"class","list svelte-1y8wjwc"),b(n,"class","section svelte-1y8wjwc"),b(x,"class","svelte-1y8wjwc"),b(Q,"type","text"),b(Q,"placeholder","Pubkey (64 hex chars)"),b(Q,"class","svelte-1y8wjwc"),b(D,"type","text"),b(D,"placeholder","Reason (optional)"),b(D,"class","svelte-1y8wjwc"),P.disabled=e[2],b(P,"class","svelte-1y8wjwc"),b(B,"class","add-form svelte-1y8wjwc"),b(U,"class","list svelte-1y8wjwc"),b(E,"class","section svelte-1y8wjwc"),b(t,"class","pubkeys-section")},m(i,d){u(i,t,d),c(t,n),c(n,r),c(n,s),c(n,o),c(o,a),I(a,e[6]),c(o,l),c(o,f),I(f,e[7]),c(o,h),c(o,v),c(v,w),c(n,A),c(n,k),M.m(k,null),c(t,C),c(t,E),c(E,x),c(E,S),c(E,B),c(B,Q),I(Q,e[9]),c(B,F),c(B,D),I(D,e[10]),c(B,$),c(B,P),c(P,R),c(E,T),c(E,U),G.m(U,null),_||(N=[y(a,"input",e[43]),y(f,"input",e[44]),y(v,"click",e[25]),y(Q,"input",e[45]),y(D,"input",e[46]),y(P,"click",e[26])],_=!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]&&(v.disabled=e[2]),O===(O=L(e))&&M?M.p(e,t):(M.d(1),M=O(e),M&&(M.c(),M.m(k,null))),512&t[0]&&Q.value!==e[9]&&I(Q,e[9]),1024&t[0]&&D.value!==e[10]&&I(D,e[10]),4&t[0]&&(P.disabled=e[2]),H===(H=j(e))&&G?G.p(e,t):(G.d(1),G=H(e),G&&(G.c(),G.m(U,null)))},d(e){e&&d(t),M.d(),G.d(),_=!1,i(N)}}}function Jh(t){let n;return{c(){n=p("div"),n.innerHTML="<p>No banned pubkeys configured.</p>",b(n,"class","no-items svelte-1y8wjwc")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Kh(e){let t,n=e[5],i=[];for(let t=0;t<n.length;t+=1)i[t]=qh(jh(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=v()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);u(e,t,n)},p(e,r){if(32&r[0]){let s;for(n=e[5],s=0;s<n.length;s+=1){const o=jh(e,n,s);i[s]?i[s].p(o,r):(i[s]=qh(o),i[s].c(),i[s].m(t.parentNode,t))}for(;s<i.length;s+=1)i[s].d(1);i.length=n.length}},d(e){f(i,e),e&&d(t)}}}function Vh(e){let t,n,i=e[72].reason+"";return{c(){t=p("span"),n=g(i),b(t,"class","reason svelte-1y8wjwc")},m(e,i){u(e,t,i),c(t,n)},p(e,t){32&t[0]&&i!==(i=e[72].reason+"")&&k(n,i)},d(e){e&&d(t)}}}function qh(e){let t,n,i,r,s,o=e[72].pubkey+"",a=e[72].reason&&Vh(e);return{c(){t=p("div"),n=p("span"),i=g(o),r=m(),a&&a.c(),s=m(),b(n,"class","pubkey svelte-1y8wjwc"),b(t,"class","list-item svelte-1y8wjwc")},m(e,o){u(e,t,o),c(t,n),c(n,i),c(t,r),a&&a.m(t,null),c(t,s)},p(e,n){32&n[0]&&o!==(o=e[72].pubkey+"")&&k(i,o),e[72].reason?a?a.p(e,n):(a=Vh(e),a.c(),a.m(t,s)):a&&(a.d(1),a=null)},d(e){e&&d(t),a&&a.d()}}}function Yh(t){let n;return{c(){n=p("div"),n.innerHTML="<p>No allowed pubkeys configured.</p>",b(n,"class","no-items svelte-1y8wjwc")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Wh(e){let t,n=e[8],i=[];for(let t=0;t<n.length;t+=1)i[t]=Zh(Mh(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=v()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);u(e,t,n)},p(e,r){if(256&r[0]){let s;for(n=e[8],s=0;s<n.length;s+=1){const o=Mh(e,n,s);i[s]?i[s].p(o,r):(i[s]=Zh(o),i[s].c(),i[s].m(t.parentNode,t))}for(;s<i.length;s+=1)i[s].d(1);i.length=n.length}},d(e){f(i,e),e&&d(t)}}}function zh(e){let t,n,i=e[72].reason+"";return{c(){t=p("span"),n=g(i),b(t,"class","reason svelte-1y8wjwc")},m(e,i){u(e,t,i),c(t,n)},p(e,t){256&t[0]&&i!==(i=e[72].reason+"")&&k(n,i)},d(e){e&&d(t)}}}function Zh(e){let t,n,i,r,s,o=e[72].pubkey+"",a=e[72].reason&&zh(e);return{c(){t=p("div"),n=p("span"),i=g(o),r=m(),a&&a.c(),s=m(),b(n,"class","pubkey svelte-1y8wjwc"),b(t,"class","list-item svelte-1y8wjwc")},m(e,o){u(e,t,o),c(t,n),c(n,i),c(t,r),a&&a.m(t,null),c(t,s)},p(e,n){256&n[0]&&o!==(o=e[72].pubkey+"")&&k(i,o),e[72].reason?a?a.p(e,n):(a=zh(e),a.c(),a.m(t,s)):a&&(a.d(1),a=null)},d(e){e&&d(t),a&&a.d()}}}function Xh(e){let t,n,r,s,o,a,l,f,h,v,w,A,k,C,E,x,S,B,Q,F,D,$,P,R,T,U,_,N;function L(e,t){return e[11]&&e[11].length>0?tg:eg}let O=L(e),M=O(e);let j=function(e){return e[22]&&e[22].length>0?sg:rg}(e),H=j(e);return{c(){t=p("div"),n=p("div"),r=p("h3"),r.textContent="Banned Events",s=m(),o=p("div"),a=p("input"),l=m(),f=p("input"),h=m(),v=p("button"),w=g("Ban Event"),A=m(),k=p("div"),M.c(),C=m(),E=p("div"),x=p("h3"),x.textContent="Allowed Events",S=m(),B=p("div"),Q=p("input"),F=m(),D=p("input"),$=m(),P=p("button"),R=g("Allow Event"),T=m(),U=p("div"),H.c(),b(r,"class","svelte-1y8wjwc"),b(a,"type","text"),b(a,"placeholder","Event ID (64 hex chars)"),b(a,"class","svelte-1y8wjwc"),b(f,"type","text"),b(f,"placeholder","Reason (optional)"),b(f,"class","svelte-1y8wjwc"),v.disabled=e[2],b(v,"class","svelte-1y8wjwc"),b(o,"class","add-form svelte-1y8wjwc"),b(k,"class","list svelte-1y8wjwc"),b(n,"class","section svelte-1y8wjwc"),b(x,"class","svelte-1y8wjwc"),b(Q,"type","text"),b(Q,"placeholder","Event ID (64 hex chars)"),b(Q,"class","svelte-1y8wjwc"),b(D,"type","text"),b(D,"placeholder","Reason (optional)"),b(D,"class","svelte-1y8wjwc"),P.disabled=e[2],b(P,"class","svelte-1y8wjwc"),b(B,"class","add-form svelte-1y8wjwc"),b(U,"class","list svelte-1y8wjwc"),b(E,"class","section svelte-1y8wjwc"),b(t,"class","events-section")},m(i,d){u(i,t,d),c(t,n),c(n,r),c(n,s),c(n,o),c(o,a),I(a,e[12]),c(o,l),c(o,f),I(f,e[13]),c(o,h),c(o,v),c(v,w),c(n,A),c(n,k),M.m(k,null),c(t,C),c(t,E),c(E,x),c(E,S),c(E,B),c(B,Q),I(Q,e[14]),c(B,F),c(B,D),I(D,e[15]),c(B,$),c(B,P),c(P,R),c(E,T),c(E,U),H.m(U,null),_||(N=[y(a,"input",e[47]),y(f,"input",e[48]),y(v,"click",e[27]),y(Q,"input",e[49]),y(D,"input",e[50]),y(P,"click",e[28])],_=!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]&&(v.disabled=e[2]),O===(O=L(e))&&M?M.p(e,t):(M.d(1),M=O(e),M&&(M.c(),M.m(k,null))),16384&t[0]&&Q.value!==e[14]&&I(Q,e[14]),32768&t[0]&&D.value!==e[15]&&I(D,e[15]),4&t[0]&&(P.disabled=e[2]),H.p(e,t)},d(e){e&&d(t),M.d(),H.d(),_=!1,i(N)}}}function eg(t){let n;return{c(){n=p("div"),n.innerHTML="<p>No banned events configured.</p>",b(n,"class","no-items svelte-1y8wjwc")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function tg(e){let t,n=e[11],i=[];for(let t=0;t<n.length;t+=1)i[t]=ig(Oh(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=v()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);u(e,t,n)},p(e,r){if(2048&r[0]){let s;for(n=e[11],s=0;s<n.length;s+=1){const o=Oh(e,n,s);i[s]?i[s].p(o,r):(i[s]=ig(o),i[s].c(),i[s].m(t.parentNode,t))}for(;s<i.length;s+=1)i[s].d(1);i.length=n.length}},d(e){f(i,e),e&&d(t)}}}function ng(e){let t,n,i=e[72].reason+"";return{c(){t=p("span"),n=g(i),b(t,"class","reason svelte-1y8wjwc")},m(e,i){u(e,t,i),c(t,n)},p(e,t){2048&t[0]&&i!==(i=e[72].reason+"")&&k(n,i)},d(e){e&&d(t)}}}function ig(e){let t,n,i,r,s,o=e[72].id+"",a=e[72].reason&&ng(e);return{c(){t=p("div"),n=p("span"),i=g(o),r=m(),a&&a.c(),s=m(),b(n,"class","event-id svelte-1y8wjwc"),b(t,"class","list-item svelte-1y8wjwc")},m(e,o){u(e,t,o),c(t,n),c(n,i),c(t,r),a&&a.m(t,null),c(t,s)},p(e,n){2048&n[0]&&o!==(o=e[72].id+"")&&k(i,o),e[72].reason?a?a.p(e,n):(a=ng(e),a.c(),a.m(t,s)):a&&(a.d(1),a=null)},d(e){e&&d(t),a&&a.d()}}}function rg(t){let n;return{c(){n=p("div"),n.innerHTML="<p>No allowed events configured.</p>",b(n,"class","no-items svelte-1y8wjwc")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function sg(e){let t,n=e[22],i=[];for(let t=0;t<n.length;t+=1)i[t]=og(Lh(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=v()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);u(e,t,n)},p(e,r){if(4194304&r[0]){let s;for(n=e[22],s=0;s<n.length;s+=1){const o=Lh(e,n,s);i[s]?i[s].p(o,r):(i[s]=og(o),i[s].c(),i[s].m(t.parentNode,t))}for(;s<i.length;s+=1)i[s].d(1);i.length=n.length}},d(e){f(i,e),e&&d(t)}}}function og(t){let n,i,r,s,o,a=t[72].id+"",l=t[72].reason&&function(t){let n,i,r=t[72].reason+"";return{c(){n=p("span"),i=g(r),b(n,"class","reason svelte-1y8wjwc")},m(e,t){u(e,n,t),c(n,i)},p:e,d(e){e&&d(n)}}}(t);return{c(){n=p("div"),i=p("span"),r=g(a),s=m(),l&&l.c(),o=m(),b(i,"class","event-id svelte-1y8wjwc"),b(n,"class","list-item svelte-1y8wjwc")},m(e,t){u(e,n,t),c(n,i),c(i,r),c(n,s),l&&l.m(n,null),c(n,o)},p(e,t){e[72].reason&&l.p(e,t)},d(e){e&&d(n),l&&l.d()}}}function ag(e){let t,n,r,s,o,a,l,f,h,v,w,A,k,C,E;function x(e,t){return e[16]&&e[16].length>0?cg:lg}let S=x(e),B=S(e);return{c(){t=p("div"),n=p("div"),r=p("h3"),r.textContent="Blocked IPs",s=m(),o=p("div"),a=p("input"),l=m(),f=p("input"),h=m(),v=p("button"),w=g("Block IP"),A=m(),k=p("div"),B.c(),b(r,"class","svelte-1y8wjwc"),b(a,"type","text"),b(a,"placeholder","IP Address"),b(a,"class","svelte-1y8wjwc"),b(f,"type","text"),b(f,"placeholder","Reason (optional)"),b(f,"class","svelte-1y8wjwc"),v.disabled=e[2],b(v,"class","svelte-1y8wjwc"),b(o,"class","add-form svelte-1y8wjwc"),b(k,"class","list svelte-1y8wjwc"),b(n,"class","section svelte-1y8wjwc"),b(t,"class","ips-section")},m(i,d){u(i,t,d),c(t,n),c(n,r),c(n,s),c(n,o),c(o,a),I(a,e[17]),c(o,l),c(o,f),I(f,e[18]),c(o,h),c(o,v),c(v,w),c(n,A),c(n,k),B.m(k,null),C||(E=[y(a,"input",e[51]),y(f,"input",e[52]),y(v,"click",e[29])],C=!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]&&(v.disabled=e[2]),S===(S=x(e))&&B?B.p(e,t):(B.d(1),B=S(e),B&&(B.c(),B.m(k,null)))},d(e){e&&d(t),B.d(),C=!1,i(E)}}}function lg(t){let n;return{c(){n=p("div"),n.innerHTML="<p>No blocked IPs configured.</p>",b(n,"class","no-items svelte-1y8wjwc")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function cg(e){let t,n=e[16],i=[];for(let t=0;t<n.length;t+=1)i[t]=dg(Nh(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=v()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);u(e,t,n)},p(e,r){if(65536&r[0]){let s;for(n=e[16],s=0;s<n.length;s+=1){const o=Nh(e,n,s);i[s]?i[s].p(o,r):(i[s]=dg(o),i[s].c(),i[s].m(t.parentNode,t))}for(;s<i.length;s+=1)i[s].d(1);i.length=n.length}},d(e){f(i,e),e&&d(t)}}}function ug(e){let t,n,i=e[72].reason+"";return{c(){t=p("span"),n=g(i),b(t,"class","reason svelte-1y8wjwc")},m(e,i){u(e,t,i),c(t,n)},p(e,t){65536&t[0]&&i!==(i=e[72].reason+"")&&k(n,i)},d(e){e&&d(t)}}}function dg(e){let t,n,i,r,s,o=e[72].ip+"",a=e[72].reason&&ug(e);return{c(){t=p("div"),n=p("span"),i=g(o),r=m(),a&&a.c(),s=m(),b(n,"class","ip svelte-1y8wjwc"),b(t,"class","list-item svelte-1y8wjwc")},m(e,o){u(e,t,o),c(t,n),c(n,i),c(t,r),a&&a.m(t,null),c(t,s)},p(e,n){65536&n[0]&&o!==(o=e[72].ip+"")&&k(i,o),e[72].reason?a?a.p(e,n):(a=ug(e),a.c(),a.m(t,s)):a&&(a.d(1),a=null)},d(e){e&&d(t),a&&a.d()}}}function fg(e){let t,n,r,s,o,a,l,f,h,v,w,k,C;function E(e,t){return e[19]&&e[19].length>0?hg:pg}let x=E(e),S=x(e);return{c(){t=p("div"),n=p("div"),r=p("h3"),r.textContent="Allowed Event Kinds",s=m(),o=p("div"),a=p("input"),l=m(),f=p("button"),h=g("Allow Kind"),v=m(),w=p("div"),S.c(),b(r,"class","svelte-1y8wjwc"),b(a,"type","number"),b(a,"placeholder","Kind number"),b(a,"class","svelte-1y8wjwc"),f.disabled=e[2],b(f,"class","svelte-1y8wjwc"),b(o,"class","add-form svelte-1y8wjwc"),b(w,"class","list svelte-1y8wjwc"),b(n,"class","section svelte-1y8wjwc"),b(t,"class","kinds-section")},m(i,d){u(i,t,d),c(t,n),c(n,r),c(n,s),c(n,o),c(o,a),I(a,e[20]),c(o,l),c(o,f),c(f,h),c(n,v),c(n,w),S.m(w,null),k||(C=[y(a,"input",e[53]),y(f,"click",e[30])],k=!0)},p(e,t){1048576&t[0]&&A(a.value)!==e[20]&&I(a,e[20]),4&t[0]&&(f.disabled=e[2]),x===(x=E(e))&&S?S.p(e,t):(S.d(1),S=x(e),S&&(S.c(),S.m(w,null)))},d(e){e&&d(t),S.d(),k=!1,i(C)}}}function pg(t){let n;return{c(){n=p("div"),n.innerHTML="<p>No allowed kinds configured. All kinds are\n allowed by default.</p>",b(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[19],i=[];for(let t=0;t<n.length;t+=1)i[t]=gg(_h(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=v()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);u(e,t,n)},p(e,r){if(524288&r[0]|1&r[1]){let s;for(n=e[19],s=0;s<n.length;s+=1){const o=_h(e,n,s);i[s]?i[s].p(o,r):(i[s]=gg(o),i[s].c(),i[s].m(t.parentNode,t))}for(;s<i.length;s+=1)i[s].d(1);i.length=n.length}},d(e){f(i,e),e&&d(t)}}}function gg(e){let t,n,i,r,s,o,a,l,f,h=e[75]+"";function v(){return e[54](e[75])}return{c(){t=p("div"),n=p("span"),i=g("Kind "),r=g(h),s=m(),o=p("button"),o.textContent="Remove",a=m(),b(n,"class","kind svelte-1y8wjwc"),b(o,"class","remove-btn svelte-1y8wjwc"),b(t,"class","list-item svelte-1y8wjwc")},m(e,d){u(e,t,d),c(t,n),c(n,i),c(n,r),c(t,s),c(t,o),c(t,a),l||(f=y(o,"click",v),l=!0)},p(t,n){e=t,524288&n[0]&&h!==(h=e[75]+"")&&k(r,h)},d(e){e&&d(t),l=!1,f()}}}function mg(e){let t,n,i,r,s,o,a,l,f,h;function v(e,t){return e[21]&&e[21].length>0?yg:vg}let w=v(e),A=w(e);return{c(){t=p("div"),n=p("div"),i=p("h3"),i.textContent="Events Needing Moderation",r=m(),s=p("button"),o=g("Refresh"),a=m(),l=p("div"),A.c(),b(i,"class","svelte-1y8wjwc"),s.disabled=e[2],b(l,"class","list svelte-1y8wjwc"),b(n,"class","section svelte-1y8wjwc"),b(t,"class","moderation-section")},m(d,p){u(d,t,p),c(t,n),c(n,i),c(n,r),c(n,s),c(s,o),c(n,a),c(n,l),A.m(l,null),f||(h=y(s,"click",e[24]),f=!0)},p(e,t){4&t[0]&&(s.disabled=e[2]),w===(w=v(e))&&A?A.p(e,t):(A.d(1),A=w(e),A&&(A.c(),A.m(l,null)))},d(e){e&&d(t),A.d(),f=!1,h()}}}function vg(t){let n;return{c(){n=p("div"),n.innerHTML="<p>No events need moderation at this time.</p>",b(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[21],i=[];for(let t=0;t<n.length;t+=1)i[t]=bg(Uh(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=v()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);u(e,t,n)},p(e,r){if(2097152&r[0]|12&r[1]){let s;for(n=e[21],s=0;s<n.length;s+=1){const o=Uh(e,n,s);i[s]?i[s].p(o,r):(i[s]=bg(o),i[s].c(),i[s].m(t.parentNode,t))}for(;s<i.length;s+=1)i[s].d(1);i.length=n.length}},d(e){f(i,e),e&&d(t)}}}function wg(e){let t,n,i=e[72].reason+"";return{c(){t=p("span"),n=g(i),b(t,"class","reason svelte-1y8wjwc")},m(e,i){u(e,t,i),c(t,n)},p(e,t){2097152&t[0]&&i!==(i=e[72].reason+"")&&k(n,i)},d(e){e&&d(t)}}}function bg(e){let t,n,r,s,o,a,l,f,h,v,w,A,I=e[72].id+"",C=e[72].reason&&wg(e);function E(){return e[55](e[72])}function x(){return e[56](e[72])}return{c(){t=p("div"),n=p("span"),r=g(I),s=m(),C&&C.c(),o=m(),a=p("div"),l=p("button"),l.textContent="Allow",f=m(),h=p("button"),h.textContent="Ban",v=m(),b(n,"class","event-id svelte-1y8wjwc"),b(l,"class","svelte-1y8wjwc"),b(h,"class","svelte-1y8wjwc"),b(a,"class","actions svelte-1y8wjwc"),b(t,"class","list-item svelte-1y8wjwc")},m(e,i){u(e,t,i),c(t,n),c(n,r),c(t,s),C&&C.m(t,null),c(t,o),c(t,a),c(a,l),c(a,f),c(a,h),c(t,v),w||(A=[y(l,"click",E),y(h,"click",x)],w=!0)},p(n,i){e=n,2097152&i[0]&&I!==(I=e[72].id+"")&&k(r,I),e[72].reason?C?C.p(e,i):(C=wg(e),C.c(),C.m(t,o)):C&&(C.d(1),C=null)},d(e){e&&d(t),C&&C.d(),w=!1,i(A)}}}function Ag(e){let t,n,r,s,o,a,l,f,h,v,w,A,k,C,E,x,S,B,Q,F,D,$,P,R,T,U,_,N;function L(e,t){return e[2]?Ig:kg}let O=L(e),M=O(e);return{c(){t=p("div"),n=p("div"),r=p("h3"),r.textContent="Relay Configuration",s=m(),o=p("div"),a=p("button"),l=g("🔄 Refresh from Relay Info"),f=m(),h=p("div"),v=p("div"),w=p("label"),w.textContent="Relay Name",A=m(),k=p("input"),C=m(),E=p("div"),x=p("label"),x.textContent="Relay Description",S=m(),B=p("textarea"),Q=m(),F=p("div"),D=p("label"),D.textContent="Relay Icon URL",$=m(),P=p("input"),R=m(),T=p("div"),U=p("button"),M.c(),b(r,"class","svelte-1y8wjwc"),a.disabled=e[2],b(a,"class","refresh-btn svelte-1y8wjwc"),b(o,"class","config-actions svelte-1y8wjwc"),b(w,"for","relay-name"),b(w,"class","svelte-1y8wjwc"),b(k,"id","relay-name"),b(k,"type","text"),b(k,"placeholder","Enter relay name"),b(k,"class","svelte-1y8wjwc"),b(v,"class","form-group svelte-1y8wjwc"),b(x,"for","relay-description"),b(x,"class","svelte-1y8wjwc"),b(B,"id","relay-description"),b(B,"placeholder","Enter relay description"),b(B,"class","svelte-1y8wjwc"),b(E,"class","form-group svelte-1y8wjwc"),b(D,"for","relay-icon"),b(D,"class","svelte-1y8wjwc"),b(P,"id","relay-icon"),b(P,"type","url"),b(P,"placeholder","Enter icon URL"),b(P,"class","svelte-1y8wjwc"),b(F,"class","form-group svelte-1y8wjwc"),U.disabled=e[2],b(U,"class","update-all-btn svelte-1y8wjwc"),b(T,"class","config-update-section svelte-1y8wjwc"),b(h,"class","config-form svelte-1y8wjwc"),b(n,"class","section svelte-1y8wjwc"),b(t,"class","relay-section")},m(i,d){u(i,t,d),c(t,n),c(n,r),c(n,s),c(n,o),c(o,a),c(a,l),c(n,f),c(n,h),c(h,v),c(v,w),c(v,A),c(v,k),I(k,e[0].relay_name),c(h,C),c(h,E),c(E,x),c(E,S),c(E,B),I(B,e[0].relay_description),c(h,Q),c(h,F),c(F,D),c(F,$),c(F,P),I(P,e[0].relay_icon),c(h,R),c(h,T),c(T,U),M.m(U,null),_||(N=[y(a,"click",e[23]),y(k,"input",e[57]),y(B,"input",e[58]),y(P,"input",e[59]),y(U,"click",e[32])],_=!0)},p(e,t){4&t[0]&&(a.disabled=e[2]),1&t[0]&&k.value!==e[0].relay_name&&I(k,e[0].relay_name),1&t[0]&&I(B,e[0].relay_description),1&t[0]&&P.value!==e[0].relay_icon&&I(P,e[0].relay_icon),O!==(O=L(e))&&(M.d(1),M=O(e),M&&(M.c(),M.m(U,null))),4&t[0]&&(U.disabled=e[2])},d(e){e&&d(t),M.d(),_=!1,i(N)}}}function kg(e){let t;return{c(){t=g("💾 Update Configuration")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Ig(e){let t;return{c(){t=g("⏳ Updating...")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Cg(t){let n,r,s,o,a,l,f,h,v,w,A,k,I,C,E,x,S,B,Q,F,D,$,P,R,T,U,_,N,L,O,M,j,H,G,J,K,V,q=t[3]&&Hh(t),Y="pubkeys"===t[1]&&Gh(t),W="events"===t[1]&&Xh(t),z="ips"===t[1]&&ag(t),Z="kinds"===t[1]&&fg(t),X="moderation"===t[1]&&mg(t),ee="relay"===t[1]&&Ag(t);return{c(){n=p("div"),r=p("div"),r.innerHTML='<h2 class="svelte-1y8wjwc">Managed ACL Configuration</h2> \n <p class="svelte-1y8wjwc">Configure access control using NIP-86 management API</p> \n <div class="owner-only-notice svelte-1y8wjwc"><strong>Owner Only:</strong> This interface is restricted to relay owners\n only.</div>',s=m(),q&&q.c(),o=m(),a=p("div"),l=p("button"),f=g("Pubkeys"),v=m(),w=p("button"),A=g("Events"),I=m(),C=p("button"),E=g("IPs"),S=m(),B=p("button"),Q=g("Kinds"),D=m(),$=p("button"),P=g("Moderation"),T=m(),U=p("button"),_=g("Relay Config"),L=m(),O=p("div"),Y&&Y.c(),M=m(),W&&W.c(),j=m(),z&&z.c(),H=m(),Z&&Z.c(),G=m(),X&&X.c(),J=m(),ee&&ee.c(),b(r,"class","header svelte-1y8wjwc"),b(l,"class",h="tab "+("pubkeys"===t[1]?"active":"")+" svelte-1y8wjwc"),b(w,"class",k="tab "+("events"===t[1]?"active":"")+" svelte-1y8wjwc"),b(C,"class",x="tab "+("ips"===t[1]?"active":"")+" svelte-1y8wjwc"),b(B,"class",F="tab "+("kinds"===t[1]?"active":"")+" svelte-1y8wjwc"),b($,"class",R="tab "+("moderation"===t[1]?"active":"")+" svelte-1y8wjwc"),b(U,"class",N="tab "+("relay"===t[1]?"active":"")+" svelte-1y8wjwc"),b(a,"class","tabs svelte-1y8wjwc"),b(O,"class","tab-content svelte-1y8wjwc")},m(e,i){u(e,n,i),c(n,r),c(n,s),q&&q.m(n,null),c(n,o),c(n,a),c(a,l),c(l,f),c(a,v),c(a,w),c(w,A),c(a,I),c(a,C),c(C,E),c(a,S),c(a,B),c(B,Q),c(a,D),c(a,$),c($,P),c(a,T),c(a,U),c(U,_),c(n,L),c(n,O),Y&&Y.m(O,null),c(O,M),W&&W.m(O,null),c(O,j),z&&z.m(O,null),c(O,H),Z&&Z.m(O,null),c(O,G),X&&X.m(O,null),c(O,J),ee&&ee.m(O,null),K||(V=[y(l,"click",t[37]),y(w,"click",t[38]),y(C,"click",t[39]),y(B,"click",t[40]),y($,"click",t[41]),y(U,"click",t[42])],K=!0)},p(e,t){e[3]?q?q.p(e,t):(q=Hh(e),q.c(),q.m(n,o)):q&&(q.d(1),q=null),2&t[0]&&h!==(h="tab "+("pubkeys"===e[1]?"active":"")+" svelte-1y8wjwc")&&b(l,"class",h),2&t[0]&&k!==(k="tab "+("events"===e[1]?"active":"")+" svelte-1y8wjwc")&&b(w,"class",k),2&t[0]&&x!==(x="tab "+("ips"===e[1]?"active":"")+" svelte-1y8wjwc")&&b(C,"class",x),2&t[0]&&F!==(F="tab "+("kinds"===e[1]?"active":"")+" svelte-1y8wjwc")&&b(B,"class",F),2&t[0]&&R!==(R="tab "+("moderation"===e[1]?"active":"")+" svelte-1y8wjwc")&&b($,"class",R),2&t[0]&&N!==(N="tab "+("relay"===e[1]?"active":"")+" svelte-1y8wjwc")&&b(U,"class",N),"pubkeys"===e[1]?Y?Y.p(e,t):(Y=Gh(e),Y.c(),Y.m(O,M)):Y&&(Y.d(1),Y=null),"events"===e[1]?W?W.p(e,t):(W=Xh(e),W.c(),W.m(O,j)):W&&(W.d(1),W=null),"ips"===e[1]?z?z.p(e,t):(z=ag(e),z.c(),z.m(O,H)):z&&(z.d(1),z=null),"kinds"===e[1]?Z?Z.p(e,t):(Z=fg(e),Z.c(),Z.m(O,G)):Z&&(Z.d(1),Z=null),"moderation"===e[1]?X?X.p(e,t):(X=mg(e),X.c(),X.m(O,J)):X&&(X.d(1),X=null),"relay"===e[1]?ee?ee.p(e,t):(ee=Ag(e),ee.c(),ee.m(O,null)):ee&&(ee.d(1),ee=null)},i:e,o:e,d(e){e&&d(n),q&&q.d(),Y&&Y.d(),W&&W.d(),z&&z.d(),Z&&Z.d(),X&&X.d(),ee&&ee.d(),K=!1,i(V)}}}function Eg(e,t,n){let{userSigner:i}=t,{userPubkey:r}=t,s="pubkeys",o=!1,a="",l="info",c=[],u="",d="",f=[],p="",h="",g=[],m="",v="",y="",w="",b=[],k="",I="",C=[],E="",x=[],S={relay_name:"",relay_description:"",relay_icon:""};async function B(){try{n(2,o=!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,S={relay_name:t.name||"",relay_description:t.description||"",relay_icon:t.icon||""}),console.log("Updated relayConfig:",S),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,o=!1)}}async function Q(e,t=[]){try{n(2,o=!0),n(3,a="");const s={method:e,params:t},l=await async function(e,t){if(!i)throw new Error("No signer available for authentication. Please log in with a Nostr extension.");if(!r)throw new Error("No user pubkey available for authentication.");const n=window.location.origin+t,s={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",n],["method",e]],content:"",pubkey:r},o=await i.signEvent(s),a=JSON.stringify(o);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(s)});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,o=!1)}}async function F(){try{n(5,c=await Q("listbannedpubkeys"))}catch(e){console.error("Failed to load banned pubkeys:",e)}}async function $(){try{n(8,f=await Q("listallowedpubkeys"))}catch(e){console.error("Failed to load allowed pubkeys:",e)}}async function P(){try{n(11,g=await Q("listbannedevents"))}catch(e){console.error("Failed to load banned events:",e)}}async function R(){try{n(16,b=await Q("listblockedips"))}catch(e){console.error("Failed to load blocked IPs:",e)}}async function T(){try{n(19,C=await Q("listallowedkinds"))}catch(e){console.error("Failed to load allowed kinds:",e)}}async function U(){try{n(2,o=!0),n(21,x=await Q("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,o=!1)}}async function _(e){try{await Q("disallowkind",[e]),n(3,a="Kind disallowed successfully"),n(4,l="success"),await T()}catch(e){console.error("Failed to disallow kind:",e)}}async function N(e){try{await Q("allowevent",[e,"Approved from moderation queue"]),n(3,a="Event allowed successfully"),n(4,l="success"),await U()}catch(e){console.error("Failed to allow event from moderation:",e)}}async function L(e){try{await Q("banevent",[e,"Banned from moderation queue"]),n(3,a="Event banned successfully"),n(4,l="success"),await U()}catch(e){console.error("Failed to ban event from moderation:",e)}}D(()=>{setTimeout(()=>{B()},100)}),async function(){await Promise.all([F(),$(),P(),R(),T()])}();return e.$$set=e=>{"userSigner"in e&&n(35,i=e.userSigner),"userPubkey"in e&&n(36,r=e.userPubkey)},e.$$.update=()=>{1&e.$$.dirty[0]&&console.log("relayConfig changed:",S)},[S,s,o,a,l,c,u,d,f,p,h,g,m,v,y,w,b,k,I,C,E,x,[],B,U,async function(){if(u)try{await Q("banpubkey",[u,d]),n(3,a="Pubkey banned successfully"),n(4,l="success"),n(6,u=""),n(7,d=""),await F()}catch(e){console.error("Failed to ban pubkey:",e)}},async function(){if(p)try{await Q("allowpubkey",[p,h]),n(3,a="Pubkey allowed successfully"),n(4,l="success"),n(9,p=""),n(10,h=""),await $()}catch(e){console.error("Failed to allow pubkey:",e)}},async function(){if(m)try{await Q("banevent",[m,v]),n(3,a="Event banned successfully"),n(4,l="success"),n(12,m=""),n(13,v=""),await P()}catch(e){console.error("Failed to ban event:",e)}},async function(){if(y)try{await Q("allowevent",[y,w]),n(3,a="Event allowed successfully"),n(4,l="success"),n(14,y=""),n(15,w="")}catch(e){console.error("Failed to allow event:",e)}},async function(){if(k)try{await Q("blockip",[k,I]),n(3,a="IP blocked successfully"),n(4,l="success"),n(17,k=""),n(18,I=""),await R()}catch(e){console.error("Failed to block IP:",e)}},async function(){if(!E)return;const e=parseInt(E);if(isNaN(e))return n(3,a="Invalid kind number"),void n(4,l="error");try{await Q("allowkind",[e]),n(3,a="Kind allowed successfully"),n(4,l="success"),n(20,E=""),await T()}catch(e){console.error("Failed to allow kind:",e)}},_,async function(){try{n(2,o=!0),n(3,a="");const e=[];if(S.relay_name&&e.push(Q("changerelayname",[S.relay_name])),S.relay_description&&e.push(Q("changerelaydescription",[S.relay_description])),S.relay_icon&&e.push(Q("changerelayicon",[S.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 B()}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,o=!1)}},N,L,i,r,()=>n(1,s="pubkeys"),()=>n(1,s="events"),()=>n(1,s="ips"),()=>n(1,s="kinds"),()=>{n(1,s="moderation"),x&&0!==x.length||U()},()=>n(1,s="relay"),function(){u=this.value,n(6,u)},function(){d=this.value,n(7,d)},function(){p=this.value,n(9,p)},function(){h=this.value,n(10,h)},function(){m=this.value,n(12,m)},function(){v=this.value,n(13,v)},function(){y=this.value,n(14,y)},function(){w=this.value,n(15,w)},function(){k=this.value,n(17,k)},function(){I=this.value,n(18,I)},function(){E=A(this.value),n(20,E)},e=>_(e),e=>N(e.id),e=>L(e.id),function(){S.relay_name=this.value,n(0,S)},function(){S.relay_description=this.value,n(0,S)},function(){S.relay_icon=this.value,n(0,S)}]}class xg extends se{constructor(e){super(),re(this,e,Eg,Cg,s,{userSigner:35,userPubkey:36},null,[-1,-1,-1])}}function Sg(e){let t,n;return{c(){t=p("span"),n=g(e[3]),b(t,"class","permission-badge svelte-1qkhxam")},m(e,i){u(e,t,i),c(t,n)},p(e,t){8&t&&k(n,e[3])},d(e){e&&d(t)}}}function Bg(t){let n,i,r;return{c(){n=p("button"),n.textContent="Log in",b(n,"class","login-btn svelte-1qkhxam")},m(e,s){u(e,n,s),i||(r=y(n,"click",t[7]),i=!0)},p:e,d(e){e&&d(n),i=!1,r()}}}function Qg(e){let t,n,i,r,s,o,a=(e[4]?.name||e[5])+"";function l(e,t){return e[4]?.picture?Dg:Fg}let f=l(e),h=f(e);return{c(){t=p("button"),h.c(),n=m(),i=p("span"),r=g(a),b(i,"class","user-name svelte-1qkhxam"),b(t,"class","user-profile-btn svelte-1qkhxam")},m(a,l){u(a,t,l),h.m(t,null),c(t,n),c(t,i),c(i,r),s||(o=y(t,"click",e[6]),s=!0)},p(e,i){f===(f=l(e))&&h?h.p(e,i):(h.d(1),h=f(e),h&&(h.c(),h.m(t,n))),48&i&&a!==(a=(e[4]?.name||e[5])+"")&&k(r,a)},d(e){e&&d(t),h.d(),s=!1,o()}}}function Fg(t){let n;return{c(){n=p("div"),n.textContent="👤",b(n,"class","user-avatar-placeholder svelte-1qkhxam")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Dg(e){let t,n;return{c(){t=p("img"),a(t.src,n=e[4].picture)||b(t,"src",n),b(t,"alt","User avatar"),b(t,"class","user-avatar svelte-1qkhxam")},m(e,n){u(e,t,n)},p(e,i){16&i&&!a(t.src,n=e[4].picture)&&b(t,"src",n)},d(e){e&&d(t)}}}function $g(t){let n,i,r,s,o,l,f,h,v,y,w=t[1]&&t[2]&&Sg(t);function A(e,t){return e[1]?Qg:Bg}let k=A(t),I=k(t);return{c(){n=p("header"),i=p("div"),r=p("img"),o=m(),l=p("div"),f=p("span"),h=g("ORLY? dashboard\n "),w&&w.c(),v=m(),y=p("div"),I.c(),a(r.src,s="/orly.png")||b(r,"src","/orly.png"),b(r,"alt","ORLY Logo"),b(r,"class","logo svelte-1qkhxam"),b(f,"class","app-title svelte-1qkhxam"),b(l,"class","header-title svelte-1qkhxam"),b(y,"class","header-buttons svelte-1qkhxam"),b(i,"class","header-content svelte-1qkhxam"),b(n,"class","main-header svelte-1qkhxam"),S(n,"dark-theme",t[0])},m(e,t){u(e,n,t),c(n,i),c(i,r),c(i,o),c(i,l),c(l,f),c(f,h),w&&w.m(f,null),c(i,v),c(i,y),I.m(y,null)},p(e,[t]){e[1]&&e[2]?w?w.p(e,t):(w=Sg(e),w.c(),w.m(f,null)):w&&(w.d(1),w=null),k===(k=A(e))&&I?I.p(e,t):(I.d(1),I=k(e),I&&(I.c(),I.m(y,null))),1&t&&S(n,"dark-theme",e[0])},i:e,o:e,d(e){e&&d(n),w&&w.d(),I.d()}}}function Pg(e,t,n){let{isDarkTheme:i=!1}=t,{isLoggedIn:r=!1}=t,{userRole:s=""}=t,{currentEffectiveRole:o=""}=t,{userProfile:a=null}=t,{userPubkey:l=""}=t;const c=P();return e.$$set=e=>{"isDarkTheme"in e&&n(0,i=e.isDarkTheme),"isLoggedIn"in e&&n(1,r=e.isLoggedIn),"userRole"in e&&n(2,s=e.userRole),"currentEffectiveRole"in e&&n(3,o=e.currentEffectiveRole),"userProfile"in e&&n(4,a=e.userProfile),"userPubkey"in e&&n(5,l=e.userPubkey)},[i,r,s,o,a,l,function(){c("openSettingsDrawer")},function(){c("openLoginModal")}]}class Rg extends se{constructor(e){super(),re(this,e,Pg,$g,s,{isDarkTheme:0,isLoggedIn:1,userRole:2,currentEffectiveRole:3,userProfile:4,userPubkey:5})}}function Tg(e,t,n){const i=e.slice();return i[10]=t[n],i}function Ug(e){let t,n,r;function s(){return e[6](e[10])}function o(...t){return e[7](e[10],...t)}return{c(){t=p("span"),t.textContent="✕",b(t,"class","tab-close-icon svelte-wfmuj"),b(t,"role","button"),b(t,"tabindex","0")},m(e,i){u(e,t,i),n||(r=[y(t,"click",w(s)),y(t,"keydown",o)],n=!0)},p(t,n){e=t},d(e){e&&d(t),n=!1,i(r)}}}function _g(e){let t,n,i,r,s,o,a,l,f,h,v=e[10].icon+"",w=e[10].label+"",A=e[10].isSearchTab&&Ug(e);function I(){return e[8](e[10])}return{c(){t=p("button"),n=p("span"),i=g(v),r=m(),s=p("span"),o=g(w),a=m(),A&&A.c(),l=m(),b(n,"class","tab-icon svelte-wfmuj"),b(s,"class","tab-label svelte-wfmuj"),b(t,"class","tab svelte-wfmuj"),S(t,"active",e[2]===e[10].id)},m(e,d){u(e,t,d),c(t,n),c(n,i),c(t,r),c(t,s),c(s,o),c(t,a),A&&A.m(t,null),c(t,l),f||(h=y(t,"click",I),f=!0)},p(n,r){e=n,2&r&&v!==(v=e[10].icon+"")&&k(i,v),2&r&&w!==(w=e[10].label+"")&&k(o,w),e[10].isSearchTab?A?A.p(e,r):(A=Ug(e),A.c(),A.m(t,l)):A&&(A.d(1),A=null),6&r&&S(t,"active",e[2]===e[10].id)},d(e){e&&d(t),A&&A.d(),f=!1,h()}}}function Ng(e){let t,n,i,r,s,o,a,l;return{c(){t=p("a"),n=h("svg"),i=h("path"),r=h("path"),s=m(),o=p("span"),a=g("v"),l=g(e[3]),b(i,"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"),b(r,"d","M9 9c1.5 0 3 .5 3 2.5S10.5 14 9 14c0-1.5.5-3.5 2-4.5"),b(r,"stroke","currentColor"),b(r,"stroke-width","1"),b(r,"fill","none"),b(n,"class","version-icon svelte-wfmuj"),b(n,"viewBox","0 0 24 24"),b(n,"fill","currentColor"),b(n,"xmlns","http://www.w3.org/2000/svg"),b(o,"class","version-text svelte-wfmuj"),b(t,"href","https://next.orly.dev"),b(t,"target","_blank"),b(t,"rel","noopener noreferrer"),b(t,"class","version-link svelte-wfmuj")},m(e,d){u(e,t,d),c(t,n),c(n,i),c(n,r),c(t,s),c(t,o),c(o,a),c(o,l)},p(e,t){8&t&&k(l,e[3])},d(e){e&&d(t)}}}function Lg(t){let n,i,r,s,o=t[1],a=[];for(let e=0;e<o.length;e+=1)a[e]=_g(Tg(t,o,e));let l=t[3]&&Ng(t);return{c(){n=p("aside"),i=p("div"),r=p("div");for(let e=0;e<a.length;e+=1)a[e].c();s=m(),l&&l.c(),b(r,"class","tabs svelte-wfmuj"),b(i,"class","sidebar-content svelte-wfmuj"),b(n,"class","sidebar svelte-wfmuj"),S(n,"dark-theme",t[0])},m(e,t){u(e,n,t),c(n,i),c(i,r);for(let e=0;e<a.length;e+=1)a[e]&&a[e].m(r,null);c(n,s),l&&l.m(n,null)},p(e,[t]){if(54&t){let n;for(o=e[1],n=0;n<o.length;n+=1){const i=Tg(e,o,n);a[n]?a[n].p(i,t):(a[n]=_g(i),a[n].c(),a[n].m(r,null))}for(;n<a.length;n+=1)a[n].d(1);a.length=o.length}e[3]?l?l.p(e,t):(l=Ng(e),l.c(),l.m(n,null)):l&&(l.d(1),l=null),1&t&&S(n,"dark-theme",e[0])},i:e,o:e,d(e){e&&d(n),f(a,e),l&&l.d()}}}function Og(e,t,n){let{isDarkTheme:i=!1}=t,{tabs:r=[]}=t,{selectedTab:s=""}=t,{version:o=""}=t;const a=P();function l(e){a("selectTab",e)}function c(e){a("closeSearchTab",e)}return e.$$set=e=>{"isDarkTheme"in e&&n(0,i=e.isDarkTheme),"tabs"in e&&n(1,r=e.tabs),"selectedTab"in e&&n(2,s=e.selectedTab),"version"in e&&n(3,o=e.version)},[i,r,s,o,l,c,e=>c(e.id),(e,t)=>"Enter"===t.key&&c(e.id),e=>l(e.id)]}class Mg extends se{constructor(e){super(),re(this,e,Og,Lg,s,{isDarkTheme:0,tabs:1,selectedTab:2,version:3})}}function jg(t){let n,i,r,s,o,a;return{c(){n=p("div"),i=p("p"),i.textContent="Please log in to access export functionality.",r=m(),s=p("button"),s.textContent="Log In",b(i,"class","svelte-jzrdtj"),b(s,"class","login-btn svelte-jzrdtj"),b(n,"class","login-prompt svelte-jzrdtj")},m(e,l){u(e,n,l),c(n,i),c(n,r),c(n,s),o||(a=y(s,"click",t[5]),o=!0)},p:e,d(e){e&&d(n),o=!1,a()}}}function Hg(e){let t,n,i=e[0]&&Gg(e),r=e[1]&&Jg(e);return{c(){i&&i.c(),t=m(),r&&r.c(),n=v()},m(e,s){i&&i.m(e,s),u(e,t,s),r&&r.m(e,s),u(e,n,s)},p(e,s){e[0]?i?i.p(e,s):(i=Gg(e),i.c(),i.m(t.parentNode,t)):i&&(i.d(1),i=null),e[1]?r?r.p(e,s):(r=Jg(e),r.c(),r.m(n.parentNode,n)):r&&(r.d(1),r=null)},d(e){i&&i.d(e),e&&d(t),r&&r.d(e),e&&d(n)}}}function Gg(t){let n,i,r,s,o,a,l,f;return{c(){n=p("div"),i=p("h3"),i.textContent="Export My Events",r=m(),s=p("p"),s.textContent="Download your personal events as a JSONL file.",o=m(),a=p("button"),a.textContent="📤 Export My Events",b(i,"class","svelte-jzrdtj"),b(s,"class","svelte-jzrdtj"),b(a,"class","export-btn svelte-jzrdtj"),b(n,"class","export-section svelte-jzrdtj")},m(e,d){u(e,n,d),c(n,i),c(n,r),c(n,s),c(n,o),c(n,a),l||(f=y(a,"click",t[3]),l=!0)},p:e,d(e){e&&d(n),l=!1,f()}}}function Jg(t){let n,i,r,s,o,a,l,f;return{c(){n=p("div"),i=p("h3"),i.textContent="Export All Events",r=m(),s=p("p"),s.textContent="Download the complete database as a JSONL file. This includes\n all events from all users.",o=m(),a=p("button"),a.textContent="📤 Export All Events",b(i,"class","svelte-jzrdtj"),b(s,"class","svelte-jzrdtj"),b(a,"class","export-btn svelte-jzrdtj"),b(n,"class","export-section svelte-jzrdtj")},m(e,d){u(e,n,d),c(n,i),c(n,r),c(n,s),c(n,o),c(n,a),l||(f=y(a,"click",t[4]),l=!0)},p:e,d(e){e&&d(n),l=!1,f()}}}function Kg(t){let n;function i(e,t){return e[2]?Hg:jg}let r=i(t),s=r(t);return{c(){s.c(),n=v()},m(e,t){s.m(e,t),u(e,n,t)},p(e,[t]){r===(r=i(e))&&s?s.p(e,t):(s.d(1),s=r(e),s&&(s.c(),s.m(n.parentNode,n)))},i:e,o:e,d(e){s.d(e),e&&d(n)}}}function Vg(e,t,n){let i,r,{isLoggedIn:s=!1}=t,{currentEffectiveRole:o=""}=t,{aclMode:a=""}=t;const l=P();return e.$$set=e=>{"isLoggedIn"in e&&n(0,s=e.isLoggedIn),"currentEffectiveRole"in e&&n(6,o=e.currentEffectiveRole),"aclMode"in e&&n(7,a=e.aclMode)},e.$$.update=()=>{129&e.$$.dirty&&n(2,i="none"===a||s),192&e.$$.dirty&&n(1,r="none"===a||"admin"===o||"owner"===o)},[s,r,i,function(){l("exportMyEvents")},function(){l("exportAllEvents")},function(){l("openLoginModal")},o,a]}class qg extends se{constructor(e){super(),re(this,e,Vg,Kg,s,{isLoggedIn:0,currentEffectiveRole:6,aclMode:7})}}function Yg(t){let n,i,r,s,o,a,l,f;return{c(){n=p("div"),i=p("h3"),i.textContent="Import Events",r=m(),s=p("p"),s.textContent="Please log in to access import functionality.",o=m(),a=p("button"),a.textContent="Log In",b(i,"class","recovery-header svelte-nonyqh"),b(s,"class","recovery-description svelte-nonyqh"),b(a,"class","login-btn svelte-nonyqh"),b(n,"class","login-prompt svelte-nonyqh")},m(e,d){u(e,n,d),c(n,i),c(n,r),c(n,s),c(n,o),c(n,a),l||(f=y(a,"click",t[6]),l=!0)},p:e,d(e){e&&d(n),l=!1,f()}}}function Wg(t){let n;return{c(){n=p("div"),n.innerHTML='<h3 class="recovery-header svelte-nonyqh">Import Events</h3> \n <p class="recovery-description svelte-nonyqh">Admin or owner permission required for import functionality.</p>',b(n,"class","permission-denied svelte-nonyqh")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function zg(e){let t,n,r,s,o,a,l,f,h,v,w,A,k,I,C=e[2]&&Zg(e);return{c(){t=p("h3"),t.textContent="Import Events",n=m(),r=p("p"),r.textContent="Upload a JSONL file to import events into the database.",s=m(),o=p("div"),a=p("input"),l=m(),f=p("div"),h=p("button"),v=g("Import Events"),A=m(),C&&C.c(),b(t,"class","svelte-nonyqh"),b(r,"class","svelte-nonyqh"),b(a,"type","file"),b(a,"id","import-file"),b(a,"accept",".jsonl,.txt"),b(a,"class","svelte-nonyqh"),b(h,"class","import-btn svelte-nonyqh"),h.disabled=w=!e[1]||"Uploading..."===e[2],b(f,"class","import-row svelte-nonyqh"),b(o,"class","recovery-controls-card svelte-nonyqh")},m(i,d){u(i,t,d),u(i,n,d),u(i,r,d),u(i,s,d),u(i,o,d),c(o,a),c(o,l),c(o,f),c(f,h),c(h,v),c(f,A),C&&C.m(f,null),k||(I=[y(a,"change",e[4]),y(h,"click",e[5])],k=!0)},p(e,t){6&t&&w!==(w=!e[1]||"Uploading..."===e[2])&&(h.disabled=w),e[2]?C?C.p(e,t):(C=Zg(e),C.c(),C.m(f,null)):C&&(C.d(1),C=null)},d(e){e&&d(t),e&&d(n),e&&d(r),e&&d(s),e&&d(o),C&&C.d(),k=!1,i(I)}}}function Zg(e){let t,n;return{c(){t=p("span"),n=g(e[2]),b(t,"class","import-message svelte-nonyqh"),S(t,"uploading","Uploading..."===e[2]),S(t,"success","Upload complete"===e[2]),S(t,"error",e[2].startsWith("Import failed")||e[2].startsWith("Admin")||e[2].startsWith("Please"))},m(e,i){u(e,t,i),c(t,n)},p(e,i){4&i&&k(n,e[2]),4&i&&S(t,"uploading","Uploading..."===e[2]),4&i&&S(t,"success","Upload complete"===e[2]),4&i&&S(t,"error",e[2].startsWith("Import failed")||e[2].startsWith("Admin")||e[2].startsWith("Please"))},d(e){e&&d(t)}}}function Xg(t){let n;function i(e,t){return e[3]?zg:e[0]?Wg:Yg}let r=i(t),s=r(t);return{c(){n=p("div"),s.c(),b(n,"class","import-section svelte-nonyqh")},m(e,t){u(e,n,t),s.m(n,null)},p(e,[t]){r===(r=i(e))&&s?s.p(e,t):(s.d(1),s=r(e),s&&(s.c(),s.m(n,null)))},i:e,o:e,d(e){e&&d(n),s.d()}}}function em(e,t,n){let i,{isLoggedIn:r=!1}=t,{currentEffectiveRole:s=""}=t,{selectedFile:o=null}=t,{aclMode:a=""}=t,{importMessage:l=""}=t;const c=P();return e.$$set=e=>{"isLoggedIn"in e&&n(0,r=e.isLoggedIn),"currentEffectiveRole"in e&&n(7,s=e.currentEffectiveRole),"selectedFile"in e&&n(1,o=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,i="none"===a||r&&("admin"===s||"owner"===s))},[r,o,l,i,function(e){c("fileSelect",e)},function(){c("importEvents")},function(){c("openLoginModal")},s,a]}class tm extends se{constructor(e){super(),re(this,e,em,Xg,s,{isLoggedIn:0,currentEffectiveRole:7,selectedFile:1,aclMode:8,importMessage:2})}}const nm={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 im(e,t=null){if(!e||"string"!=typeof e)return!1;return!!/^[0-9a-fA-F]+$/.test(e)&&(!t||e.length===t)}function rm(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 sm(e){return Math.floor(new Date(e).getTime()/1e3)}function om(e,t,n){const i=e.slice();return i[62]=t[n],i[64]=n,i}function am(e,t,n){const i=e.slice();return i[65]=t[n],i}function lm(e,t,n){const i=e.slice();return i[68]=t[n],i}function cm(e,t,n){const i=e.slice();return i[71]=t[n],i}function um(e,t,n){const i=e.slice();return i[71]=t[n].kind,i[74]=t[n].name,i}function dm(e){let t,n,i,r,s,o,a=e[20],l=[];for(let t=0;t<a.length;t+=1)l[t]=fm(um(e,a,t));return{c(){t=p("div"),n=p("input"),i=m(),r=p("div");for(let e=0;e<l.length;e+=1)l[e].c();b(n,"type","text"),b(n,"placeholder","Search kinds..."),b(n,"class","filter-input kind-search svelte-1a1v6k0"),b(r,"class","kinds-list svelte-1a1v6k0"),b(t,"class","kinds-picker svelte-1a1v6k0")},m(a,d){u(a,t,d),c(t,n),I(n,e[9]),c(t,i),c(t,r);for(let e=0;e<l.length;e+=1)l[e]&&l[e].m(r,null);s||(o=y(n,"input",e[40]),s=!0)},p(e,t){if(512&t[0]&&n.value!==e[9]&&I(n,e[9]),9437186&t[0]){let n;for(a=e[20],n=0;n<a.length;n+=1){const i=um(e,a,n);l[n]?l[n].p(i,t):(l[n]=fm(i),l[n].c(),l[n].m(r,null))}for(;n<l.length;n+=1)l[n].d(1);l.length=a.length}},d(e){e&&d(t),f(l,e),s=!1,o()}}}function fm(e){let t,n,i,r,s,o,a,l,f,h,v,w,A=e[71]+"",I=e[74]+"";function C(){return e[41](e[71])}return{c(){t=p("label"),n=p("input"),r=m(),s=p("span"),o=g(A),a=m(),l=p("span"),f=g(I),h=m(),b(n,"type","checkbox"),n.checked=i=e[1].includes(e[71]),b(n,"class","svelte-1a1v6k0"),b(s,"class","kind-number svelte-1a1v6k0"),b(l,"class","kind-name svelte-1a1v6k0"),b(t,"class","kind-checkbox svelte-1a1v6k0")},m(e,i){u(e,t,i),c(t,n),c(t,r),c(t,s),c(s,o),c(t,a),c(t,l),c(l,f),c(t,h),v||(w=y(n,"change",C),v=!0)},p(t,r){e=t,1048578&r[0]&&i!==(i=e[1].includes(e[71]))&&(n.checked=i),1048576&r[0]&&A!==(A=e[71]+"")&&k(o,A),1048576&r[0]&&I!==(I=e[74]+"")&&k(f,I)},d(e){e&&d(t),v=!1,w()}}}function pm(e){let t,n=e[1],i=[];for(let t=0;t<n.length;t+=1)i[t]=hm(cm(e,n,t));return{c(){t=p("div");for(let e=0;e<i.length;e+=1)i[e].c();b(t,"class","chips-container svelte-1a1v6k0")},m(e,n){u(e,t,n);for(let e=0;e<i.length;e+=1)i[e]&&i[e].m(t,null)},p(e,r){if(16777218&r[0]){let s;for(n=e[1],s=0;s<n.length;s+=1){const o=cm(e,n,s);i[s]?i[s].p(o,r):(i[s]=hm(o),i[s].c(),i[s].m(t,null))}for(;s<i.length;s+=1)i[s].d(1);i.length=n.length}},d(e){e&&d(t),f(i,e)}}}function hm(e){let t,n,i,r,s,o,a,l,f,h,v=e[71]+"",w=(nm[e[71]]||`Kind ${e[71]}`)+"";function A(){return e[42](e[71])}return{c(){t=p("div"),n=p("span"),i=g(v),r=g(": "),s=g(w),o=m(),a=p("button"),a.textContent="×",l=m(),b(n,"class","chip-text svelte-1a1v6k0"),b(a,"class","chip-remove svelte-1a1v6k0"),b(t,"class","chip svelte-1a1v6k0")},m(e,d){u(e,t,d),c(t,n),c(n,i),c(n,r),c(n,s),c(t,o),c(t,a),c(t,l),f||(h=y(a,"click",A),f=!0)},p(t,n){e=t,2&n[0]&&v!==(v=e[71]+"")&&k(i,v),2&n[0]&&w!==(w=(nm[e[71]]||`Kind ${e[71]}`)+"")&&k(s,w)},d(e){e&&d(t),f=!1,h()}}}function gm(e){let t,n;return{c(){t=p("div"),n=g(e[17]),b(t,"class","error-message svelte-1a1v6k0")},m(e,i){u(e,t,i),c(t,n)},p(e,t){131072&t[0]&&k(n,e[17])},d(e){e&&d(t)}}}function mm(e){let t,n=e[2],i=[];for(let t=0;t<n.length;t+=1)i[t]=vm(lm(e,n,t));return{c(){t=p("div");for(let e=0;e<i.length;e+=1)i[e].c();b(t,"class","list-items svelte-1a1v6k0")},m(e,n){u(e,t,n);for(let e=0;e<i.length;e+=1)i[e]&&i[e].m(t,null)},p(e,r){if(67108868&r[0]){let s;for(n=e[2],s=0;s<n.length;s+=1){const o=lm(e,n,s);i[s]?i[s].p(o,r):(i[s]=vm(o),i[s].c(),i[s].m(t,null))}for(;s<i.length;s+=1)i[s].d(1);i.length=n.length}},d(e){e&&d(t),f(i,e)}}}function vm(e){let t,n,i,r,s,o,a,l,f=e[68]+"";function h(){return e[45](e[68])}return{c(){t=p("div"),n=p("span"),i=g(f),r=m(),s=p("button"),s.textContent="×",o=m(),b(n,"class","list-item-text svelte-1a1v6k0"),b(s,"class","list-item-remove svelte-1a1v6k0"),b(t,"class","list-item svelte-1a1v6k0")},m(e,d){u(e,t,d),c(t,n),c(n,i),c(t,r),c(t,s),c(t,o),a||(l=y(s,"click",h),a=!0)},p(t,n){e=t,4&n[0]&&f!==(f=e[68]+"")&&k(i,f)},d(e){e&&d(t),a=!1,l()}}}function ym(e){let t,n;return{c(){t=p("div"),n=g(e[18]),b(t,"class","error-message svelte-1a1v6k0")},m(e,i){u(e,t,i),c(t,n)},p(e,t){262144&t[0]&&k(n,e[18])},d(e){e&&d(t)}}}function wm(e){let t,n=e[3],i=[];for(let t=0;t<n.length;t+=1)i[t]=bm(am(e,n,t));return{c(){t=p("div");for(let e=0;e<i.length;e+=1)i[e].c();b(t,"class","list-items svelte-1a1v6k0")},m(e,n){u(e,t,n);for(let e=0;e<i.length;e+=1)i[e]&&i[e].m(t,null)},p(e,r){if(268435464&r[0]){let s;for(n=e[3],s=0;s<n.length;s+=1){const o=am(e,n,s);i[s]?i[s].p(o,r):(i[s]=bm(o),i[s].c(),i[s].m(t,null))}for(;s<i.length;s+=1)i[s].d(1);i.length=n.length}},d(e){e&&d(t),f(i,e)}}}function bm(e){let t,n,i,r,s,o,a,l,f=e[65]+"";function h(){return e[48](e[65])}return{c(){t=p("div"),n=p("span"),i=g(f),r=m(),s=p("button"),s.textContent="×",o=m(),b(n,"class","list-item-text svelte-1a1v6k0"),b(s,"class","list-item-remove svelte-1a1v6k0"),b(t,"class","list-item svelte-1a1v6k0")},m(e,d){u(e,t,d),c(t,n),c(n,i),c(t,r),c(t,s),c(t,o),a||(l=y(s,"click",h),a=!0)},p(t,n){e=t,8&n[0]&&f!==(f=e[65]+"")&&k(i,f)},d(e){e&&d(t),a=!1,l()}}}function Am(e){let t,n;return{c(){t=p("div"),n=g(e[19]),b(t,"class","error-message svelte-1a1v6k0")},m(e,i){u(e,t,i),c(t,n)},p(e,t){524288&t[0]&&k(n,e[19])},d(e){e&&d(t)}}}function km(e){let t,n=e[4],i=[];for(let t=0;t<n.length;t+=1)i[t]=Im(om(e,n,t));return{c(){t=p("div");for(let e=0;e<i.length;e+=1)i[e].c();b(t,"class","list-items svelte-1a1v6k0")},m(e,n){u(e,t,n);for(let e=0;e<i.length;e+=1)i[e]&&i[e].m(t,null)},p(e,r){if(1073741840&r[0]){let s;for(n=e[4],s=0;s<n.length;s+=1){const o=om(e,n,s);i[s]?i[s].p(o,r):(i[s]=Im(o),i[s].c(),i[s].m(t,null))}for(;s<i.length;s+=1)i[s].d(1);i.length=n.length}},d(e){e&&d(t),f(i,e)}}}function Im(e){let t,n,i,r,s,o,a,l,f,h,v,w=e[62].name+"",A=e[62].value+"";function I(){return e[52](e[64])}return{c(){t=p("div"),n=p("span"),i=g("#"),r=g(w),s=g(": "),o=g(A),a=m(),l=p("button"),l.textContent="×",f=m(),b(n,"class","list-item-text svelte-1a1v6k0"),b(l,"class","list-item-remove svelte-1a1v6k0"),b(t,"class","list-item svelte-1a1v6k0")},m(e,d){u(e,t,d),c(t,n),c(n,i),c(n,r),c(n,s),c(n,o),c(t,a),c(t,l),c(t,f),h||(v=y(l,"click",I),h=!0)},p(t,n){e=t,16&n[0]&&w!==(w=e[62].name+"")&&k(r,w),16&n[0]&&A!==(A=e[62].value+"")&&k(o,A)},d(e){e&&d(t),h=!1,v()}}}function Cm(t){let n,i,r;return{c(){n=p("button"),n.textContent="×",b(n,"class","clear-timestamp-btn svelte-1a1v6k0")},m(e,s){u(e,n,s),i||(r=y(n,"click",t[53]),i=!0)},p:e,d(e){e&&d(n),i=!1,r()}}}function Em(t){let n,i,r;return{c(){n=p("button"),n.textContent="×",b(n,"class","clear-timestamp-btn svelte-1a1v6k0")},m(e,s){u(e,n,s),i||(r=y(n,"click",t[54]),i=!0)},p:e,d(e){e&&d(n),i=!1,r()}}}function xm(e){let t,n,r,s,o,a,l,f,h,g=e[11]&&Sm(e);return{c(){t=p("div"),n=p("label"),n.textContent="Filter JSON",r=m(),s=p("textarea"),o=m(),g&&g.c(),a=m(),l=p("button"),l.textContent="Apply JSON",b(n,"for","json-editor"),b(n,"class","svelte-1a1v6k0"),b(s,"id","json-editor"),b(s,"class","json-editor svelte-1a1v6k0"),b(s,"placeholder",'{"kinds": [1], "limit": 100}'),b(s,"rows","8"),b(l,"class","apply-json-btn svelte-1a1v6k0"),b(t,"class","json-editor-section svelte-1a1v6k0")},m(i,d){u(i,t,d),c(t,n),c(t,r),c(t,s),I(s,e[10]),c(t,o),g&&g.m(t,null),c(t,a),c(t,l),f||(h=[y(s,"input",e[56]),y(l,"click",e[22])],f=!0)},p(e,n){1024&n[0]&&I(s,e[10]),e[11]?g?g.p(e,n):(g=Sm(e),g.c(),g.m(t,a)):g&&(g.d(1),g=null)},d(e){e&&d(t),g&&g.d(),f=!1,i(h)}}}function Sm(e){let t,n;return{c(){t=p("div"),n=g(e[11]),b(t,"class","json-error svelte-1a1v6k0")},m(e,i){u(e,t,i),c(t,n)},p(e,t){2048&t[0]&&k(n,e[11])},d(e){e&&d(t)}}}function Bm(t){let n,r,s,o,a,l,f,h,v,w,C,E,x,B,Q,F,D,$,P,R,T,U,_,N,L,O,M,j,H,G,J,K,V,q,Y,W,z,Z,X,ee,te,ne,ie,re,se,oe,ae,le,ce,ue,de,fe,pe,he,ge,me,ve,ye,we,be,Ae,ke,Ie,Ce,Ee,xe,Se,Be,Qe,Fe,De,$e,Pe,Re,Te,Ue,_e,Ne,Le,Oe=t[12]?"▼":"▶",Me=t[1].length+"",je=t[12]&&dm(t),He=t[1].length>0&&pm(t),Ge=t[17]&&gm(t),Je=t[2].length>0&&mm(t),Ke=t[18]&&ym(t),Ve=t[3].length>0&&wm(t),qe=t[19]&&Am(t),Ye=t[4].length>0&&km(t),We=t[5]&&Cm(t),ze=t[6]&&Em(t),Ze=t[8]&&xm(t);return{c(){n=p("div"),r=p("div"),s=p("div"),o=p("label"),o.textContent="Search Text (NIP-50)",a=m(),l=p("div"),f=p("input"),h=m(),v=p("label"),v.textContent="Event Kinds",w=m(),C=p("div"),E=p("button"),x=g(Oe),B=g(" Select Kinds ("),Q=g(Me),F=g(" selected)"),D=m(),je&&je.c(),$=m(),He&&He.c(),P=m(),R=p("label"),R.textContent="Authors (Pubkeys)",T=m(),U=p("div"),_=p("div"),N=p("input"),L=m(),O=p("button"),O.textContent="Add",M=m(),Ge&&Ge.c(),j=m(),Je&&Je.c(),H=m(),G=p("label"),G.textContent="Event IDs",J=m(),K=p("div"),V=p("div"),q=p("input"),Y=m(),W=p("button"),W.textContent="Add",z=m(),Ke&&Ke.c(),Z=m(),Ve&&Ve.c(),X=m(),ee=p("label"),ee.textContent="Tags (#e, #p, #a)",te=m(),ne=p("div"),ie=p("div"),re=p("span"),re.textContent="#",se=m(),oe=p("input"),ae=m(),le=p("input"),ce=m(),ue=p("button"),ue.textContent="Add",de=m(),qe&&qe.c(),fe=m(),Ye&&Ye.c(),pe=m(),he=p("label"),he.textContent="Since",ge=m(),me=p("div"),ve=p("input"),ye=m(),We&&We.c(),we=m(),be=p("label"),be.textContent="Until",Ae=m(),ke=p("div"),Ie=p("input"),Ce=m(),ze&&ze.c(),Ee=m(),xe=p("label"),xe.textContent="Limit",Se=m(),Be=p("div"),Qe=p("input"),Fe=m(),Ze&&Ze.c(),De=m(),$e=p("div"),Pe=p("button"),Pe.textContent="🧹",Re=m(),Te=p("div"),Ue=m(),_e=p("button"),_e.textContent="</>",b(o,"for","search-text"),b(o,"class","svelte-1a1v6k0"),b(f,"id","search-text"),b(f,"type","text"),b(f,"placeholder","Search events..."),b(f,"class","filter-input svelte-1a1v6k0"),b(l,"class","field-content svelte-1a1v6k0"),b(v,"class","svelte-1a1v6k0"),b(E,"class","picker-toggle-btn svelte-1a1v6k0"),b(C,"class","field-content svelte-1a1v6k0"),b(R,"class","svelte-1a1v6k0"),b(N,"type","text"),b(N,"placeholder","64 character hex pubkey..."),b(N,"class","filter-input svelte-1a1v6k0"),b(N,"maxlength","64"),b(O,"class","add-btn svelte-1a1v6k0"),b(_,"class","input-group svelte-1a1v6k0"),b(U,"class","field-content svelte-1a1v6k0"),b(G,"class","svelte-1a1v6k0"),b(q,"type","text"),b(q,"placeholder","64 character hex event ID..."),b(q,"class","filter-input svelte-1a1v6k0"),b(q,"maxlength","64"),b(W,"class","add-btn svelte-1a1v6k0"),b(V,"class","input-group svelte-1a1v6k0"),b(K,"class","field-content svelte-1a1v6k0"),b(ee,"class","svelte-1a1v6k0"),b(re,"class","hash-prefix svelte-1a1v6k0"),b(oe,"type","text"),b(oe,"placeholder","Tag"),b(oe,"class","filter-input tag-name-input svelte-1a1v6k0"),b(oe,"maxlength","1"),b(le,"type","text"),b(le,"placeholder","Value..."),b(le,"class","filter-input tag-value-input svelte-1a1v6k0"),b(ue,"class","add-btn svelte-1a1v6k0"),b(ie,"class","tag-input-group svelte-1a1v6k0"),b(ne,"class","field-content svelte-1a1v6k0"),b(he,"for","since-timestamp"),b(he,"class","svelte-1a1v6k0"),b(ve,"id","since-timestamp"),b(ve,"type","datetime-local"),ve.value=t[32](),b(ve,"class","filter-input svelte-1a1v6k0"),b(me,"class","field-content timestamp-field svelte-1a1v6k0"),b(be,"for","until-timestamp"),b(be,"class","svelte-1a1v6k0"),b(Ie,"id","until-timestamp"),b(Ie,"type","datetime-local"),Ie.value=t[33](),b(Ie,"class","filter-input svelte-1a1v6k0"),b(ke,"class","field-content timestamp-field svelte-1a1v6k0"),b(xe,"for","limit"),b(xe,"class","svelte-1a1v6k0"),b(Qe,"id","limit"),b(Qe,"type","number"),b(Qe,"placeholder","Max events to return"),b(Qe,"class","filter-input svelte-1a1v6k0"),b(Qe,"min","1"),b(Be,"class","field-content svelte-1a1v6k0"),b(s,"class","filter-grid svelte-1a1v6k0"),b(r,"class","filter-content svelte-1a1v6k0"),b(Pe,"class","clear-all-btn svelte-1a1v6k0"),b(Pe,"title","Clear all filters"),b(Te,"class","spacer svelte-1a1v6k0"),b(_e,"class","json-toggle-btn svelte-1a1v6k0"),b(_e,"title","Edit filter JSON"),S(_e,"active",t[8]),b($e,"class","clear-column svelte-1a1v6k0"),b(n,"class","filter-builder svelte-1a1v6k0")},m(e,i){u(e,n,i),c(n,r),c(r,s),c(s,o),c(s,a),c(s,l),c(l,f),I(f,t[0]),c(s,h),c(s,v),c(s,w),c(s,C),c(C,E),c(E,x),c(E,B),c(E,Q),c(E,F),c(C,D),je&&je.m(C,null),c(C,$),He&&He.m(C,null),c(s,P),c(s,R),c(s,T),c(s,U),c(U,_),c(_,N),I(N,t[13]),c(_,L),c(_,O),c(U,M),Ge&&Ge.m(U,null),c(U,j),Je&&Je.m(U,null),c(s,H),c(s,G),c(s,J),c(s,K),c(K,V),c(V,q),I(q,t[14]),c(V,Y),c(V,W),c(K,z),Ke&&Ke.m(K,null),c(K,Z),Ve&&Ve.m(K,null),c(s,X),c(s,ee),c(s,te),c(s,ne),c(ne,ie),c(ie,re),c(ie,se),c(ie,oe),I(oe,t[15]),c(ie,ae),c(ie,le),I(le,t[16]),c(ie,ce),c(ie,ue),c(ne,de),qe&&qe.m(ne,null),c(ne,fe),Ye&&Ye.m(ne,null),c(s,pe),c(s,he),c(s,ge),c(s,me),c(me,ve),c(me,ye),We&&We.m(me,null),c(s,we),c(s,be),c(s,Ae),c(s,ke),c(ke,Ie),c(ke,Ce),ze&&ze.m(ke,null),c(s,Ee),c(s,xe),c(s,Se),c(s,Be),c(Be,Qe),I(Qe,t[7]),c(s,Fe),Ze&&Ze.m(s,null),c(n,De),c(n,$e),c($e,Pe),c($e,Re),c($e,Te),c($e,Ue),c($e,_e),Ne||(Le=[y(f,"input",t[38]),y(E,"click",t[39]),y(N,"input",t[43]),y(N,"keydown",t[44]),y(O,"click",t[25]),y(q,"input",t[46]),y(q,"keydown",t[47]),y(W,"click",t[27]),y(oe,"input",t[49]),y(le,"input",t[50]),y(le,"keydown",t[51]),y(ue,"click",t[29]),y(ve,"change",t[34]),y(Ie,"change",t[35]),y(Qe,"input",t[55]),y(Pe,"click",t[31]),y(_e,"click",t[57])],Ne=!0)},p(e,t){1&t[0]&&f.value!==e[0]&&I(f,e[0]),4096&t[0]&&Oe!==(Oe=e[12]?"▼":"▶")&&k(x,Oe),2&t[0]&&Me!==(Me=e[1].length+"")&&k(Q,Me),e[12]?je?je.p(e,t):(je=dm(e),je.c(),je.m(C,$)):je&&(je.d(1),je=null),e[1].length>0?He?He.p(e,t):(He=pm(e),He.c(),He.m(C,null)):He&&(He.d(1),He=null),8192&t[0]&&N.value!==e[13]&&I(N,e[13]),e[17]?Ge?Ge.p(e,t):(Ge=gm(e),Ge.c(),Ge.m(U,j)):Ge&&(Ge.d(1),Ge=null),e[2].length>0?Je?Je.p(e,t):(Je=mm(e),Je.c(),Je.m(U,null)):Je&&(Je.d(1),Je=null),16384&t[0]&&q.value!==e[14]&&I(q,e[14]),e[18]?Ke?Ke.p(e,t):(Ke=ym(e),Ke.c(),Ke.m(K,Z)):Ke&&(Ke.d(1),Ke=null),e[3].length>0?Ve?Ve.p(e,t):(Ve=wm(e),Ve.c(),Ve.m(K,null)):Ve&&(Ve.d(1),Ve=null),32768&t[0]&&oe.value!==e[15]&&I(oe,e[15]),65536&t[0]&&le.value!==e[16]&&I(le,e[16]),e[19]?qe?qe.p(e,t):(qe=Am(e),qe.c(),qe.m(ne,fe)):qe&&(qe.d(1),qe=null),e[4].length>0?Ye?Ye.p(e,t):(Ye=km(e),Ye.c(),Ye.m(ne,null)):Ye&&(Ye.d(1),Ye=null),e[5]?We?We.p(e,t):(We=Cm(e),We.c(),We.m(me,null)):We&&(We.d(1),We=null),e[6]?ze?ze.p(e,t):(ze=Em(e),ze.c(),ze.m(ke,null)):ze&&(ze.d(1),ze=null),128&t[0]&&A(Qe.value)!==e[7]&&I(Qe,e[7]),e[8]?Ze?Ze.p(e,t):(Ze=xm(e),Ze.c(),Ze.m(s,null)):Ze&&(Ze.d(1),Ze=null),256&t[0]&&S(_e,"active",e[8])},i:e,o:e,d(e){e&&d(n),je&&je.d(),He&&He.d(),Ge&&Ge.d(),Je&&Je.d(),Ke&&Ke.d(),Ve&&Ve.d(),qe&&qe.d(),Ye&&Ye.d(),We&&We.d(),ze&&ze.d(),Ze&&Ze.d(),Ne=!1,i(Le)}}}function Qm(e,t,n){let i,r;const s=P();let{searchText:o=""}=t,{selectedKinds:a=[]}=t,{pubkeys:l=[]}=t,{eventIds:c=[]}=t,{tags:u=[]}=t,{sinceTimestamp:d=null}=t,{untilTimestamp:f=null}=t,{limit:p=null}=t,{showJsonEditor:h=!1}=t,g="",m="",v=!1,y="",w="",b="",k="",I="",C="",E="",x="",S=null,B=!1;function Q(e){a.includes(e)?n(1,a=a.filter(t=>t!==e)):n(1,a=[...a,e].sort((e,t)=>e-t))}function F(e){n(1,a=a.filter(t=>t!==e))}function D(){const e=w.trim();e&&(im(e,64)?l.includes(e)?n(17,C="Pubkey already added"):(n(2,l=[...l,e]),n(13,w=""),n(17,C="")):n(17,C="Invalid pubkey: must be 64 character hex string"))}function R(e){n(2,l=l.filter(t=>t!==e))}function T(){const e=b.trim();e&&(im(e,64)?c.includes(e)?n(18,E="Event ID already added"):(n(3,c=[...c,e]),n(14,b=""),n(18,E="")):n(18,E="Invalid event ID: must be 64 character hex string"))}function U(e){n(3,c=c.filter(t=>t!==e))}function _(){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 N(e){n(4,u=u.filter((t,n)=>n!==e))}function L(){s("apply",{searchText:o,selectedKinds:a,pubkeys:l,eventIds:c,tags:u,sinceTimestamp:d,untilTimestamp:f,limit:p})}$(()=>{S&&clearTimeout(S)});return e.$$set=e=>{"searchText"in e&&n(0,o=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,p=e.limit),"showJsonEditor"in e&&n(8,h=e.showJsonEditor)},e.$$.update=()=>{if(256&e.$$.dirty[0]&&h){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),p&&(e.limit=p),o&&(e.search=o),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]&&(B?(S&&clearTimeout(S),S=setTimeout(()=>{L()},1e3)):n(36,B=!0)),512&e.$$.dirty[0]|64&e.$$.dirty[1]&&n(20,r=i.filter(e=>e.kind.toString().includes(y)||e.name.toLowerCase().includes(y.toLowerCase())))},n(37,i=Object.entries(nm).map(([e,t])=>({kind:parseInt(e),name:t})).sort((e,t)=>e.kind-t.kind)),[o,a,l,c,u,d,f,p,h,y,g,m,v,w,b,k,I,C,E,x,r,s,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,p=e.limit||null),n(0,o=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),S&&clearTimeout(S),L()}catch(e){n(11,m="Invalid JSON: "+e.message)}},Q,F,D,R,T,U,_,N,function(){n(0,o=""),n(1,a=[]),n(2,l=[]),n(3,c=[]),n(4,u=[]),n(5,d=null),n(6,f=null),n(7,p=null),s("clear")},function(){return d?rm(d):""},function(){return f?rm(f):""},function(e){const t=e.target.value;n(5,d=t?sm(t):null)},function(e){const t=e.target.value;n(6,f=t?sm(t):null)},B,i,function(){o=this.value,n(0,o)},()=>n(12,v=!v),function(){y=this.value,n(9,y)},e=>Q(e),e=>F(e),function(){w=this.value,n(13,w)},e=>"Enter"===e.key&&D(),e=>R(e),function(){b=this.value,n(14,b)},e=>"Enter"===e.key&&T(),e=>U(e),function(){k=this.value,n(15,k)},function(){I=this.value,n(16,I)},e=>"Enter"===e.key&&_(),e=>N(e),()=>n(5,d=null),()=>n(6,f=null),function(){p=A(this.value),n(7,p)},function(){g=this.value,n(10,g),n(8,h)},()=>s("toggleJson")]}class Fm extends se{constructor(e){super(),re(this,e,Qm,Bm,s,{searchText:0,selectedKinds:1,pubkeys:2,eventIds:3,tags:4,sinceTimestamp:5,untilTimestamp:6,limit:7,showJsonEditor:8},null,[-1,-1,-1])}}function Dm(e,t,n){const i=e.slice();return i[28]=t[n],i}function $m(e,t,n){const i=e.slice();return i[31]=t[n],i}function Pm(t){let n;return{c(){n=p("div"),n.innerHTML="<p>❌ Read, write, admin, or owner permission required to view all\n events.</p>",b(n,"class","permission-denied svelte-5kb1ec")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Rm(e){let t,n,i,r;function s(e,t){return e[4].length>0?Um:e[6]?void 0:Tm}let o=s(e),a=o&&o(e),l=e[6]&&Gm();return{c(){t=p("div"),a&&a.c(),n=m(),l&&l.c(),b(t,"class","events-view-content svelte-5kb1ec")},m(s,o){u(s,t,o),a&&a.m(t,null),c(t,n),l&&l.m(t,null),i||(r=y(t,"scroll",e[9]),i=!0)},p(e,i){o===(o=s(e))&&a?a.p(e,i):(a&&a.d(1),a=o&&o(e),a&&(a.c(),a.m(t,n))),e[6]?l||(l=Gm(),l.c(),l.m(t,null)):l&&(l.d(1),l=null)},d(e){e&&d(t),a&&a.d(),l&&l.d(),i=!1,r()}}}function Tm(t){let n;return{c(){n=p("div"),n.innerHTML="<p>No events found.</p>",b(n,"class","no-events svelte-5kb1ec")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Um(e){let t,n=e[4],i=[];for(let t=0;t<n.length;t+=1)i[t]=Hm(Dm(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=v()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);u(e,t,n)},p(e,r){if(7228&r[0]){let s;for(n=e[4],s=0;s<n.length;s+=1){const o=Dm(e,n,s);i[s]?i[s].p(o,r):(i[s]=Hm(o),i[s].c(),i[s].m(t.parentNode,t))}for(;s<i.length;s+=1)i[s].d(1);i.length=n.length}},d(e){f(i,e),e&&d(t)}}}function _m(e){let t,n,i=Zm(e[28].content)+"";return{c(){t=p("div"),n=g(i),b(t,"class","event-content-single-line svelte-5kb1ec")},m(e,i){u(e,t,i),c(t,n)},p(e,t){16&t[0]&&i!==(i=Zm(e[28].content)+"")&&k(n,i)},d(e){e&&d(t)}}}function Nm(e){let t,n,i,r=e[28].tags&&e[28].tags.length>0&&Lm(e);return{c(){t=p("div"),n=p("span"),n.textContent="🗑️ Delete Event",i=m(),r&&r.c(),b(n,"class","delete-event-label svelte-5kb1ec"),b(t,"class","delete-event-info svelte-5kb1ec")},m(e,s){u(e,t,s),c(t,n),c(t,i),r&&r.m(t,null)},p(e,n){e[28].tags&&e[28].tags.length>0?r?r.p(e,n):(r=Lm(e),r.c(),r.m(t,null)):r&&(r.d(1),r=null)},d(e){e&&d(t),r&&r.d()}}}function Lm(e){let t,n=e[28].tags.filter(Xm),i=[];for(let t=0;t<n.length;t+=1)i[t]=Om($m(e,n,t));return{c(){t=p("div");for(let e=0;e<i.length;e+=1)i[e].c();b(t,"class","delete-targets svelte-5kb1ec")},m(e,n){u(e,t,n);for(let e=0;e<i.length;e+=1)i[e]&&i[e].m(t,null)},p(e,r){if(16&r[0]){let s;for(n=e[28].tags.filter(Xm),s=0;s<n.length;s+=1){const o=$m(e,n,s);i[s]?i[s].p(o,r):(i[s]=Om(o),i[s].c(),i[s].m(t,null))}for(;s<i.length;s+=1)i[s].d(1);i.length=n.length}},d(e){e&&d(t),f(i,e)}}}function Om(e){let t,n,i,r,s,o=e[31][1].slice(0,8)+"",a=e[31][1].slice(-8)+"";return{c(){t=p("span"),n=g("Target: "),i=g(o),r=g("..."),s=g(a),b(t,"class","delete-target svelte-5kb1ec")},m(e,o){u(e,t,o),c(t,n),c(t,i),c(t,r),c(t,s)},p(e,t){16&t[0]&&o!==(o=e[31][1].slice(0,8)+"")&&k(i,o),16&t[0]&&a!==(a=e[31][1].slice(-8)+"")&&k(s,a)},d(e){e&&d(t)}}}function Mm(e){let t,n,i;function r(){return e[19](e[28])}return{c(){t=p("button"),t.textContent="🗑️",b(t,"class","delete-btn svelte-5kb1ec")},m(e,s){u(e,t,s),n||(i=y(t,"click",w(r)),n=!0)},p(t,n){e=t},d(e){e&&d(t),n=!1,i()}}}function jm(e){let t,n,i,r,s,o,a,l,f=JSON.stringify(e[28],null,2)+"";function h(...t){return e[22](e[28],...t)}return{c(){t=p("div"),n=p("div"),i=p("pre"),r=g(f),s=m(),o=p("button"),o.textContent="📋",b(i,"class","event-json svelte-5kb1ec"),b(o,"class","copy-json-btn svelte-5kb1ec"),b(o,"title","Copy minified JSON to clipboard"),b(n,"class","json-container svelte-5kb1ec"),b(t,"class","events-view-details svelte-5kb1ec")},m(e,d){u(e,t,d),c(t,n),c(n,i),c(i,r),c(n,s),c(n,o),a||(l=y(o,"click",w(h)),a=!0)},p(t,n){e=t,16&n[0]&&f!==(f=JSON.stringify(e[28],null,2)+"")&&k(r,f)},d(e){e&&d(t),a=!1,l()}}}function Hm(e){let t,n,r,s,o,a,l,f,h,v,w,A,I,C,E,x,B,Q,F,D,$,P,R,T,U=Ym(e[28].pubkey)+"",_=e[28].kind+"",N=Wm(e[28].kind)+"",L=zm(e[28].created_at)+"",O=e[5].has(e[28].id);function M(e,t){return 5===e[28].kind?Nm:_m}let j=M(e),H=j(e),G=5!==e[28].kind&&("admin"===e[2]||"owner"===e[2]||"write"===e[2]&&e[28].pubkey&&e[28].pubkey===e[3])&&Mm(e);function J(){return e[20](e[28])}function K(...t){return e[21](e[28],...t)}let V=O&&jm(e);return{c(){t=p("div"),n=p("div"),r=p("div"),r.innerHTML='<div class="avatar-placeholder svelte-5kb1ec">👤</div>',s=m(),o=p("div"),a=p("div"),l=g(U),f=m(),h=p("div"),v=p("span"),w=g(_),A=m(),I=p("span"),C=g(N),E=m(),x=p("div"),B=p("div"),Q=g(L),F=m(),H.c(),D=m(),G&&G.c(),$=m(),V&&V.c(),P=m(),b(r,"class","events-view-avatar svelte-5kb1ec"),b(a,"class","events-view-author svelte-5kb1ec"),b(v,"class","kind-number svelte-5kb1ec"),S(v,"delete-event",5===e[28].kind),b(I,"class","kind-name svelte-5kb1ec"),b(h,"class","events-view-kind svelte-5kb1ec"),b(o,"class","events-view-info svelte-5kb1ec"),b(B,"class","event-timestamp svelte-5kb1ec"),b(x,"class","events-view-content svelte-5kb1ec"),b(n,"class","events-view-row svelte-5kb1ec"),b(n,"role","button"),b(n,"tabindex","0"),b(t,"class","events-view-item svelte-5kb1ec"),S(t,"expanded",e[5].has(e[28].id))},m(e,i){u(e,t,i),c(t,n),c(n,r),c(n,s),c(n,o),c(o,a),c(a,l),c(o,f),c(o,h),c(h,v),c(v,w),c(h,A),c(h,I),c(I,C),c(n,E),c(n,x),c(x,B),c(B,Q),c(x,F),H.m(x,null),c(n,D),G&&G.m(n,null),c(t,$),V&&V.m(t,null),c(t,P),R||(T=[y(n,"click",J),y(n,"keydown",K)],R=!0)},p(i,r){e=i,16&r[0]&&U!==(U=Ym(e[28].pubkey)+"")&&k(l,U),16&r[0]&&_!==(_=e[28].kind+"")&&k(w,_),16&r[0]&&S(v,"delete-event",5===e[28].kind),16&r[0]&&N!==(N=Wm(e[28].kind)+"")&&k(C,N),16&r[0]&&L!==(L=zm(e[28].created_at)+"")&&k(Q,L),j===(j=M(e))&&H?H.p(e,r):(H.d(1),H=j(e),H&&(H.c(),H.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,r):(G=Mm(e),G.c(),G.m(n,null)):G&&(G.d(1),G=null),48&r[0]&&(O=e[5].has(e[28].id)),O?V?V.p(e,r):(V=jm(e),V.c(),V.m(t,P)):V&&(V.d(1),V=null),48&r[0]&&S(t,"expanded",e[5].has(e[28].id))},d(e){e&&d(t),H.d(),G&&G.d(),V&&V.d(),R=!1,i(T)}}}function Gm(e){let t;return{c(){t=p("div"),t.innerHTML='<div class="spinner svelte-5kb1ec"></div> \n <p>Loading events...</p>',b(t,"class","loading-events svelte-5kb1ec")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Jm(e){let t,n,r,s,o,a,l,f,h,v,w,A,k,I,C,E,x,B,Q,F,D,$,P,R;function T(e,t){return e[6]?Vm:Km}r=new Fm({props:{showJsonEditor:e[8]}}),r.$on("apply",e[17]),r.$on("clear",e[18]),r.$on("toggleJson",e[16]);let U=T(e),_=U(e);return{c(){t=p("div"),n=p("div"),ee(r.$$.fragment),s=m(),o=p("div"),a=p("div"),l=p("button"),l.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svelte-5kb1ec"><polygon points="22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"></polygon></svg>',f=m(),h=p("div"),v=p("label"),w=p("input"),A=m(),k=p("span"),I=m(),C=p("span"),C.textContent="Only show my events",E=m(),x=p("div"),B=p("button"),Q=g("🔄 Load More"),F=m(),D=p("button"),_.c(),b(n,"class","filter-panel svelte-5kb1ec"),S(n,"open",e[7]),b(l,"class","filter-btn svelte-5kb1ec"),b(l,"title","Filter events"),S(l,"active",e[7]),b(w,"type","checkbox"),b(w,"class","svelte-5kb1ec"),b(k,"class","toggle-slider svelte-5kb1ec"),b(C,"class","toggle-label svelte-5kb1ec"),b(v,"class","toggle-container svelte-5kb1ec"),b(h,"class","events-view-toggle svelte-5kb1ec"),b(a,"class","events-view-left svelte-5kb1ec"),b(B,"class","refresh-btn svelte-5kb1ec"),B.disabled=e[6],b(D,"class","reload-btn svelte-5kb1ec"),D.disabled=e[6],b(x,"class","events-view-buttons svelte-5kb1ec"),b(o,"class","events-view-header svelte-5kb1ec"),b(t,"class","events-view-footer svelte-5kb1ec")},m(i,d){u(i,t,d),c(t,n),te(r,n,null),c(t,s),c(t,o),c(o,a),c(a,l),c(a,f),c(a,h),c(h,v),c(v,w),w.checked=e[0],c(v,A),c(v,k),c(v,I),c(v,C),c(o,E),c(o,x),c(x,B),c(B,Q),c(x,F),c(x,D),_.m(D,null),$=!0,P||(R=[y(l,"click",e[15]),y(w,"change",e[23]),y(w,"change",e[24]),y(B,"click",e[25]),y(D,"click",e[26])],P=!0)},p(e,t){const i={};256&t[0]&&(i.showJsonEditor=e[8]),r.$set(i),(!$||128&t[0])&&S(n,"open",e[7]),(!$||128&t[0])&&S(l,"active",e[7]),1&t[0]&&(w.checked=e[0]),(!$||64&t[0])&&(B.disabled=e[6]),U!==(U=T(e))&&(_.d(1),_=U(e),_&&(_.c(),_.m(D,null))),(!$||64&t[0])&&(D.disabled=e[6])},i(e){$||(z(r.$$.fragment,e),$=!0)},o(e){Z(r.$$.fragment,e),$=!1},d(e){e&&d(t),ne(r),_.d(),P=!1,i(R)}}}function Km(e){let t;return{c(){t=g("🔄")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Vm(e){let t;return{c(){t=p("div"),b(t,"class","spinner svelte-5kb1ec")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function qm(e){let t,n,i;function r(e,t){return!e[1]||"read"!==e[2]&&"write"!==e[2]&&"admin"!==e[2]&&"owner"!==e[2]?Pm:Rm}let s=r(e),o=s(e),a=e[1]&&("read"===e[2]||"write"===e[2]||"admin"===e[2]||"owner"===e[2])&&Jm(e);return{c(){t=p("div"),o.c(),n=m(),a&&a.c(),b(t,"class","events-view-container svelte-5kb1ec")},m(e,r){u(e,t,r),o.m(t,null),c(t,n),a&&a.m(t,null),i=!0},p(e,i){s===(s=r(e))&&o?o.p(e,i):(o.d(1),o=s(e),o&&(o.c(),o.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}),W()):a?(a.p(e,i),6&i[0]&&z(a,1)):(a=Jm(e),a.c(),z(a,1),a.m(t,null))},i(e){i||(z(a),i=!0)},o(e){Z(a),i=!1},d(e){e&&d(t),o.d(),a&&a.d()}}}function Ym(e){return e?e.slice(0,8)+"..."+e.slice(-8):""}function Wm(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 zm(e){return new Date(1e3*e).toLocaleString()}function Zm(e){return e?e.length>100?e.slice(0,100)+"...":e:""}const Xm=e=>"e"===e[0];function ev(e,t,n){let{isLoggedIn:i=!1}=t,{userRole:r=""}=t,{userPubkey:s=""}=t,{filteredEvents:o=[]}=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 p(e){d("toggleEventExpansion",e)}function h(e){d("deleteEvent",e)}function g(e,t){d("copyEventToClipboard",{event:e,e:t})}function m(){d("toggleChange")}function v(e,t){d("loadAllEvents",{refresh:e,authors:t})}return e.$$set=e=>{"isLoggedIn"in e&&n(1,i=e.isLoggedIn),"userRole"in e&&n(2,r=e.userRole),"userPubkey"in e&&n(3,s=e.userPubkey),"filteredEvents"in e&&n(4,o=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,i,r,s,o,a,l,u,f,function(e){d("scroll",e)},p,h,g,m,v,function(){d("toggleFilterBuilder")},function(){n(8,f=!f)},function(e){d("filterApply",e.detail)},function(){d("filterClear")},e=>h(e.id),e=>p(e.id),(e,t)=>"Enter"===t.key&&p(e.id),(e,t)=>g(e,t),function(){c=this.checked,n(0,c)},()=>m(),()=>{v(!1,c&&s?[s]:null)},()=>{v(!0,c&&s?[s]:null)}]}class tv extends se{constructor(e){super(),re(this,e,ev,qm,s,{isLoggedIn:1,userRole:2,userPubkey:3,filteredEvents:4,expandedEvents:5,isLoadingEvents:6,showOnlyMyEvents:0,showFilterBuilder:7},null,[-1,-1])}}const nv=[{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 iv(e,t=null){const n=function(e){return nv.find(t=>t.kind===e)}(e);return n?{...n.template,created_at:Math.floor(Date.now()/1e3),pubkey:t||"<your_pubkey_here>"}:{kind:e,content:"",tags:[],created_at:Math.floor(Date.now()/1e3),pubkey:t||"<your_pubkey_here>"}}const rv=[{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 sv(e,t,n){const i=e.slice();return i[13]=t[n],i}function ov(e,t,n){const i=e.slice();return i[16]=t[n],i}function av(e){let t,n,r,s,o,a,l,h,v,w,A,C,E,x,S,B,Q,F,D,$,P,R,T,U,_,N=e[3].length+"",L=1!==e[3].length?"s":"",O=rv,M=[];for(let t=0;t<O.length;t+=1)M[t]=lv(ov(e,O,t));function j(e,t){return 0===e[3].length?uv:cv}let H=j(e),G=H(e);return{c(){t=p("div"),n=p("div"),r=p("div"),s=p("h2"),s.textContent="Generate Event Template",o=m(),a=p("button"),a.textContent="×",l=m(),h=p("div"),v=p("div"),w=p("input"),A=m(),C=p("div");for(let e=0;e<M.length;e+=1)M[e].c();E=m(),x=p("div"),S=p("div"),G.c(),B=m(),Q=p("div"),F=p("span"),D=g(N),$=g(" event type"),P=g(L),R=m(),T=p("button"),T.textContent="Cancel",b(s,"class","svelte-v55ls1"),b(a,"class","close-btn svelte-v55ls1"),b(r,"class","modal-header svelte-v55ls1"),b(w,"type","text"),b(w,"placeholder","Search by name, description, or kind number..."),b(w,"class","search-input svelte-v55ls1"),b(v,"class","search-box svelte-v55ls1"),b(C,"class","category-tabs svelte-v55ls1"),b(h,"class","modal-filters svelte-v55ls1"),b(S,"class","kinds-list svelte-v55ls1"),b(x,"class","modal-body svelte-v55ls1"),b(F,"class","result-count svelte-v55ls1"),b(T,"class","cancel-btn svelte-v55ls1"),b(Q,"class","modal-footer svelte-v55ls1"),b(n,"class","modal-content svelte-v55ls1"),b(t,"class","modal-backdrop svelte-v55ls1")},m(i,d){u(i,t,d),c(t,n),c(n,r),c(r,s),c(r,o),c(r,a),c(n,l),c(n,h),c(h,v),c(v,w),I(w,e[1]),c(h,A),c(h,C);for(let e=0;e<M.length;e+=1)M[e]&&M[e].m(C,null);c(n,E),c(n,x),c(x,S),G.m(S,null),c(n,B),c(n,Q),c(Q,F),c(F,D),c(F,$),c(F,P),c(Q,R),c(Q,T),U||(_=[y(a,"click",e[5]),y(w,"input",e[9]),y(T,"click",e[5]),y(t,"click",e[7])],U=!0)},p(e,t){if(2&t&&w.value!==e[1]&&I(w,e[1]),4&t){let n;for(O=rv,n=0;n<O.length;n+=1){const i=ov(e,O,n);M[n]?M[n].p(i,t):(M[n]=lv(i),M[n].c(),M[n].m(C,null))}for(;n<M.length;n+=1)M[n].d(1);M.length=O.length}H===(H=j(e))&&G?G.p(e,t):(G.d(1),G=H(e),G&&(G.c(),G.m(S,null))),8&t&&N!==(N=e[3].length+"")&&k(D,N),8&t&&L!==(L=1!==e[3].length?"s":"")&&k(P,L)},d(e){e&&d(t),f(M,e),G.d(),U=!1,i(_)}}}function lv(e){let t,n,i,r,s,o=e[16].name+"";function a(){return e[10](e[16])}return{c(){t=p("button"),n=g(o),i=m(),b(t,"class","category-tab svelte-v55ls1"),S(t,"active",e[2]===e[16].id)},m(e,o){u(e,t,o),c(t,n),c(t,i),r||(s=y(t,"click",a),r=!0)},p(n,i){e=n,4&i&&S(t,"active",e[2]===e[16].id)},d(e){e&&d(t),r=!1,s()}}}function cv(e){let t,n=e[3],i=[];for(let t=0;t<n.length;t+=1)i[t]=fv(sv(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=v()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);u(e,t,n)},p(e,r){if(24&r){let s;for(n=e[3],s=0;s<n.length;s+=1){const o=sv(e,n,s);i[s]?i[s].p(o,r):(i[s]=fv(o),i[s].c(),i[s].m(t.parentNode,t))}for(;s<i.length;s+=1)i[s].d(1);i.length=n.length}},d(e){f(i,e),e&&d(t)}}}function uv(e){let t,n,i,r;return{c(){t=p("div"),n=g('No event kinds found matching "'),i=g(e[1]),r=g('"'),b(t,"class","no-results svelte-v55ls1")},m(e,s){u(e,t,s),c(t,n),c(t,i),c(t,r)},p(e,t){2&t&&k(i,e[1])},d(e){e&&d(t)}}}function dv(e){let t,n,i,r=e[13].nip+"";return{c(){t=p("span"),n=g("NIP-"),i=g(r),b(t,"class","nip-badge svelte-v55ls1")},m(e,r){u(e,t,r),c(t,n),c(t,i)},p(e,t){8&t&&r!==(r=e[13].nip+"")&&k(i,r)},d(e){e&&d(t)}}}function fv(e){let t,n,i,r,s,o,a,l,f,h,v,w,A,I,C,E,x,S,B,Q=e[13].kind+"",F=gv(e[13])+"",D=e[13].name+"",$=e[13].description+"",P=e[13].nip&&"XX"!==e[13].nip&&dv(e);function R(){return e[11](e[13])}return{c(){t=p("button"),n=p("div"),i=p("span"),r=g("Kind "),s=g(Q),o=m(),a=p("span"),l=g(F),h=m(),P&&P.c(),v=m(),w=p("div"),A=g(D),I=m(),C=p("div"),E=g($),x=m(),b(i,"class","kind-number svelte-v55ls1"),b(a,"class",f="kind-badge "+hv(e[13])+" svelte-v55ls1"),b(n,"class","kind-header svelte-v55ls1"),b(w,"class","kind-name svelte-v55ls1"),b(C,"class","kind-description svelte-v55ls1"),b(t,"class","kind-item svelte-v55ls1")},m(e,d){u(e,t,d),c(t,n),c(n,i),c(i,r),c(i,s),c(n,o),c(n,a),c(a,l),c(n,h),P&&P.m(n,null),c(t,v),c(t,w),c(w,A),c(t,I),c(t,C),c(C,E),c(t,x),S||(B=y(t,"click",R),S=!0)},p(t,i){e=t,8&i&&Q!==(Q=e[13].kind+"")&&k(s,Q),8&i&&F!==(F=gv(e[13])+"")&&k(l,F),8&i&&f!==(f="kind-badge "+hv(e[13])+" svelte-v55ls1")&&b(a,"class",f),e[13].nip&&"XX"!==e[13].nip?P?P.p(e,i):(P=dv(e),P.c(),P.m(n,null)):P&&(P.d(1),P=null),8&i&&D!==(D=e[13].name+"")&&k(A,D),8&i&&$!==($=e[13].description+"")&&k(E,$)},d(e){e&&d(t),P&&P.d(),S=!1,B()}}}function pv(t){let n,i,r,s=t[0]&&av(t);return{c(){s&&s.c(),n=v()},m(e,o){s&&s.m(e,o),u(e,n,o),i||(r=y(window,"keydown",t[6]),i=!0)},p(e,[t]){e[0]?s?s.p(e,t):(s=av(e),s.c(),s.m(n.parentNode,n)):s&&(s.d(1),s=null)},i:e,o:e,d(e){s&&s.d(e),e&&d(n),i=!1,r()}}}function hv(e){return e.isAddressable?"badge-addressable":e.isReplaceable?"badge-replaceable":e.kind>=2e4&&e.kind<3e4?"badge-ephemeral":"badge-regular"}function gv(e){return e.isAddressable?"Addressable":e.isReplaceable?"Replaceable":e.kind>=2e4&&e.kind<3e4?"Ephemeral":"Regular"}function mv(e,t,n){let{isOpen:i=!1}=t,{userPubkey:r=""}=t;const s=P();let o="",a="all",l=nv;function c(e){const t=iv(e.kind,r);s("select",{kind:e,template:t}),u()}function u(){n(0,i=!1),n(1,o=""),n(2,a="all"),s("close")}return e.$$set=e=>{"isOpen"in e&&n(0,i=e.isOpen),"userPubkey"in e&&n(8,r=e.userPubkey)},e.$$.update=()=>{if(6&e.$$.dirty){let e=nv;const t=rv.find(e=>e.id===a);if(t&&(e=e.filter(t.filter)),o.trim()){const t=o.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)}},[i,o,a,l,c,u,function(e){"Escape"===e.key&&u()},function(e){e.target===e.currentTarget&&u()},r,function(){o=this.value,n(1,o)},e=>n(2,a=e.id),e=>c(e)]}class vv extends se{constructor(e){super(),re(this,e,mv,pv,s,{isOpen:0,userPubkey:8})}}function yv(e){let t,n,i,r,s,o,a,l,f,h;return{c(){t=p("div"),n=p("div"),i=p("span"),i.textContent="⚠",r=m(),s=p("span"),o=g(e[1]),a=m(),l=p("button"),l.textContent="×",b(i,"class","error-icon svelte-46pmgb"),b(s,"class","error-message svelte-46pmgb"),b(n,"class","error-content svelte-46pmgb"),b(l,"class","error-dismiss svelte-46pmgb"),b(t,"class","error-banner svelte-46pmgb")},m(d,p){u(d,t,p),c(t,n),c(n,i),c(n,r),c(n,s),c(s,o),c(t,a),c(t,l),f||(h=y(l,"click",e[10]),f=!0)},p(e,t){2&t&&k(o,e[1])},d(e){e&&d(t),f=!1,h()}}}function wv(e){let t,n,r,s,o,a,l,f,h,g,v,w,A,k,C,E,x,S,B,Q=e[1]&&yv(e);function F(t){e[14](t)}let D={userPubkey:e[2]};return void 0!==e[3]&&(D.isOpen=e[3]),C=new vv({props:D}),U.push(()=>X(C,"isOpen",F)),C.$on("select",e[8]),C.$on("close",e[9]),{c(){t=p("div"),n=p("div"),r=p("button"),r.textContent="Generate Template",s=m(),o=p("button"),o.textContent="Reformat",a=m(),l=p("button"),l.textContent="Sign",f=m(),h=p("button"),h.textContent="Publish",g=m(),Q&&Q.c(),v=m(),w=p("div"),A=p("textarea"),k=m(),ee(C.$$.fragment),b(r,"class","compose-btn template-btn svelte-46pmgb"),b(o,"class","compose-btn reformat-btn svelte-46pmgb"),b(l,"class","compose-btn sign-btn svelte-46pmgb"),b(h,"class","compose-btn publish-btn svelte-46pmgb"),b(n,"class","compose-header svelte-46pmgb"),b(A,"class","compose-textarea svelte-46pmgb"),b(A,"placeholder","Enter your Nostr event JSON here, or click 'Generate Template' to start with a template..."),b(A,"spellcheck","false"),b(w,"class","compose-editor svelte-46pmgb"),b(t,"class","compose-view svelte-46pmgb")},m(i,d){u(i,t,d),c(t,n),c(n,r),c(n,s),c(n,o),c(n,a),c(n,l),c(n,f),c(n,h),c(t,g),Q&&Q.m(t,null),c(t,v),c(t,w),c(w,A),I(A,e[0]),u(i,k,d),te(C,i,d),x=!0,S||(B=[y(r,"click",e[7]),y(o,"click",e[4]),y(l,"click",e[5]),y(h,"click",e[6]),y(A,"input",e[13])],S=!0)},p(e,[n]){e[1]?Q?Q.p(e,n):(Q=yv(e),Q.c(),Q.m(t,v)):Q&&(Q.d(1),Q=null),1&n&&I(A,e[0]);const i={};4&n&&(i.userPubkey=e[2]),!E&&8&n&&(E=!0,i.isOpen=e[3],j(()=>E=!1)),C.$set(i)},i(e){x||(z(C.$$.fragment,e),x=!0)},o(e){Z(C.$$.fragment,e),x=!1},d(e){e&&d(t),Q&&Q.d(),e&&d(k),ne(C,e),S=!1,i(B)}}}function bv(e,t,n){let{composeEventJson:i=""}=t,{userPubkey:r=""}=t,{userRole:s=""}=t,{policyEnabled:o=!1}=t,{publishError:a=""}=t;const l=P();let c=!1;return e.$$set=e=>{"composeEventJson"in e&&n(0,i=e.composeEventJson),"userPubkey"in e&&n(2,r=e.userPubkey),"userRole"in e&&n(11,s=e.userRole),"policyEnabled"in e&&n(12,o=e.policyEnabled),"publishError"in e&&n(1,a=e.publishError)},[i,a,r,c,function(){l("reformatJson")},function(){l("signEvent")},function(){l("publishEvent")},function(){n(3,c=!0)},function(e){const{kind:t,template:r}=e.detail;n(0,i=JSON.stringify(r,null,2)),l("templateSelected",{kind:t,template:r})},function(){n(3,c=!1)},function(){n(1,a=""),l("clearError")},s,o,function(){i=this.value,n(0,i)},function(e){c=e,n(3,c)}]}class Av extends se{constructor(e){super(),re(this,e,bv,wv,s,{composeEventJson:0,userPubkey:2,userRole:11,policyEnabled:12,publishError:1})}}function kv(e,t,n){const i=e.slice();return i[23]=t[n],i}function Iv(t){let n,i,r,s,o,a;return{c(){n=p("div"),i=p("p"),i.textContent="Please log in to access sprocket management.",r=m(),s=p("button"),s.textContent="Log In",b(i,"class","svelte-fiaj1r"),b(s,"class","login-btn svelte-fiaj1r"),b(n,"class","login-prompt svelte-fiaj1r")},m(e,l){u(e,n,l),c(n,i),c(n,r),c(n,s),o||(a=y(s,"click",t[18]),o=!0)},p:e,d(e){e&&d(n),o=!1,a()}}}function Cv(e){let t,n,i,r,s,o,a,l,f,h=(e[2]||"none")+"";return{c(){t=p("div"),n=p("p"),n.textContent="❌ Owner permission required for sprocket management.",i=m(),r=p("p"),r.innerHTML='To enable sprocket functionality, set the <code class="svelte-fiaj1r">ORLY_OWNERS</code> environment variable with your npub when starting the relay.',s=m(),o=p("p"),a=g("Current user role: "),l=p("strong"),f=g(h),b(n,"class","svelte-fiaj1r"),b(r,"class","svelte-fiaj1r"),b(o,"class","svelte-fiaj1r"),b(t,"class","permission-denied svelte-fiaj1r")},m(e,d){u(e,t,d),c(t,n),c(t,i),c(t,r),c(t,s),c(t,o),c(o,a),c(o,l),c(l,f)},p(e,t){4&t&&h!==(h=(e[2]||"none")+"")&&k(f,h)},d(e){e&&d(t)}}}function Ev(e){let t,n,r,s,o,a,l,h,v,w,A,C,E,x,B,Q,F,D,$,P,R,T,U,_,N,L,O,M,j,H,G,J,K,V,q,Y,W,z,Z,X,ee,te,ne,ie,re,se,oe,ae,le,ce,ue,de,fe,pe,he,ge,me=e[3]?.is_running?"🟢 Running":"🔴 Stopped",ve=e[3]?.script_exists?"✅ Exists":"❌ Not found",ye=e[3]?.pid&&xv(e),we=e[6]&&Sv(e),be=e[8],Ae=[];for(let t=0;t<be.length;t+=1)Ae[t]=Fv(kv(e,be,t));return{c(){t=p("div"),n=p("div"),r=p("h3"),r.textContent="Script Editor",s=m(),o=p("div"),a=p("button"),l=g("🔄 Restart"),h=m(),v=p("button"),w=g("🗑️ Delete Script"),C=m(),E=p("div"),x=p("h4"),x.textContent="Upload Script",B=m(),Q=p("div"),F=p("input"),D=m(),$=p("button"),P=g("📤 Upload & Update"),T=m(),U=p("div"),_=p("div"),N=p("span"),N.textContent="Status:",L=m(),O=p("span"),M=g(me),j=m(),ye&&ye.c(),H=m(),G=p("div"),J=p("span"),J.textContent="Script:",K=m(),V=p("span"),q=g(ve),Y=m(),W=p("div"),z=p("textarea"),Z=m(),X=p("div"),ee=p("button"),te=g("💾 Save & Update"),ne=m(),ie=p("button"),re=g("📥 Load Current"),se=m(),we&&we.c(),oe=m(),ae=p("div"),le=p("h3"),le.textContent="Script Versions",ce=m(),ue=p("div");for(let e=0;e<Ae.length;e+=1)Ae[e].c();de=m(),fe=p("button"),pe=g("🔄 Refresh Versions"),b(r,"class","svelte-fiaj1r"),b(a,"class","sprocket-btn restart-btn svelte-fiaj1r"),a.disabled=e[4],b(v,"class","sprocket-btn delete-btn svelte-fiaj1r"),v.disabled=A=e[4]||!e[3]?.script_exists,b(o,"class","sprocket-controls svelte-fiaj1r"),b(n,"class","sprocket-header svelte-fiaj1r"),b(x,"class","svelte-fiaj1r"),b(F,"type","file"),b(F,"id","sprocket-upload-file"),b(F,"accept",".sh,.bash"),F.disabled=e[4],b(F,"class","svelte-fiaj1r"),b($,"class","sprocket-btn upload-btn svelte-fiaj1r"),$.disabled=R=e[4]||!e[5],b(Q,"class","upload-controls svelte-fiaj1r"),b(E,"class","sprocket-upload-section svelte-fiaj1r"),b(N,"class","status-label svelte-fiaj1r"),b(O,"class","status-value svelte-fiaj1r"),S(O,"running",e[3]?.is_running),b(_,"class","status-item svelte-fiaj1r"),b(J,"class","status-label svelte-fiaj1r"),b(V,"class","status-value svelte-fiaj1r"),b(G,"class","status-item svelte-fiaj1r"),b(U,"class","sprocket-status svelte-fiaj1r"),b(z,"class","script-editor svelte-fiaj1r"),b(z,"placeholder","#!/bin/bash # Enter your sprocket script here..."),z.disabled=e[4],b(W,"class","script-editor-container svelte-fiaj1r"),b(ee,"class","sprocket-btn save-btn svelte-fiaj1r"),ee.disabled=e[4],b(ie,"class","sprocket-btn load-btn svelte-fiaj1r"),ie.disabled=e[4],b(X,"class","script-actions svelte-fiaj1r"),b(t,"class","sprocket-section svelte-fiaj1r"),b(ue,"class","versions-list svelte-fiaj1r"),b(fe,"class","sprocket-btn refresh-btn svelte-fiaj1r"),fe.disabled=e[4],b(ae,"class","sprocket-section svelte-fiaj1r")},m(i,d){u(i,t,d),c(t,n),c(n,r),c(n,s),c(n,o),c(o,a),c(a,l),c(o,h),c(o,v),c(v,w),c(t,C),c(t,E),c(E,x),c(E,B),c(E,Q),c(Q,F),c(Q,D),c(Q,$),c($,P),c(t,T),c(t,U),c(U,_),c(_,N),c(_,L),c(_,O),c(O,M),c(U,j),ye&&ye.m(U,null),c(U,H),c(U,G),c(G,J),c(G,K),c(G,V),c(V,q),c(t,Y),c(t,W),c(W,z),I(z,e[0]),c(t,Z),c(t,X),c(X,ee),c(ee,te),c(X,ne),c(X,ie),c(ie,re),c(t,se),we&&we.m(t,null),u(i,oe,d),u(i,ae,d),c(ae,le),c(ae,ce),c(ae,ue);for(let e=0;e<Ae.length;e+=1)Ae[e]&&Ae[e].m(ue,null);c(ae,de),c(ae,fe),c(fe,pe),he||(ge=[y(a,"click",e[9]),y(v,"click",e[10]),y(F,"change",e[11]),y($,"click",e[12]),y(z,"input",e[19]),y(ee,"click",e[13]),y(ie,"click",e[14]),y(fe,"click",e[15])],he=!0)},p(e,n){if(16&n&&(a.disabled=e[4]),24&n&&A!==(A=e[4]||!e[3]?.script_exists)&&(v.disabled=A),16&n&&(F.disabled=e[4]),48&n&&R!==(R=e[4]||!e[5])&&($.disabled=R),8&n&&me!==(me=e[3]?.is_running?"🟢 Running":"🔴 Stopped")&&k(M,me),8&n&&S(O,"running",e[3]?.is_running),e[3]?.pid?ye?ye.p(e,n):(ye=xv(e),ye.c(),ye.m(U,H)):ye&&(ye.d(1),ye=null),8&n&&ve!==(ve=e[3]?.script_exists?"✅ Exists":"❌ Not found")&&k(q,ve),16&n&&(z.disabled=e[4]),1&n&&I(z,e[0]),16&n&&(ee.disabled=e[4]),16&n&&(ie.disabled=e[4]),e[6]?we?we.p(e,n):(we=Sv(e),we.c(),we.m(t,null)):we&&(we.d(1),we=null),196880&n){let t;for(be=e[8],t=0;t<be.length;t+=1){const i=kv(e,be,t);Ae[t]?Ae[t].p(i,n):(Ae[t]=Fv(i),Ae[t].c(),Ae[t].m(ue,null))}for(;t<Ae.length;t+=1)Ae[t].d(1);Ae.length=be.length}16&n&&(fe.disabled=e[4])},d(e){e&&d(t),ye&&ye.d(),we&&we.d(),e&&d(oe),e&&d(ae),f(Ae,e),he=!1,i(ge)}}}function xv(e){let t,n,i,r,s,o=e[3].pid+"";return{c(){t=p("div"),n=p("span"),n.textContent="PID:",i=m(),r=p("span"),s=g(o),b(n,"class","status-label svelte-fiaj1r"),b(r,"class","status-value svelte-fiaj1r"),b(t,"class","status-item svelte-fiaj1r")},m(e,o){u(e,t,o),c(t,n),c(t,i),c(t,r),c(r,s)},p(e,t){8&t&&o!==(o=e[3].pid+"")&&k(s,o)},d(e){e&&d(t)}}}function Sv(e){let t,n;return{c(){t=p("div"),n=g(e[6]),b(t,"class","sprocket-message svelte-fiaj1r"),S(t,"error","error"===e[7])},m(e,i){u(e,t,i),c(t,n)},p(e,i){64&i&&k(n,e[6]),128&i&&S(t,"error","error"===e[7])},d(e){e&&d(t)}}}function Bv(e){let t;return{c(){t=p("span"),t.textContent="Current",b(t,"class","current-badge svelte-fiaj1r")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Qv(e){let t,n,i,r;function s(){return e[21](e[23])}return{c(){t=p("button"),n=g("🗑️ Delete"),b(t,"class","version-btn delete-btn svelte-fiaj1r"),t.disabled=e[4]},m(e,o){u(e,t,o),c(t,n),i||(r=y(t,"click",s),i=!0)},p(n,i){e=n,16&i&&(t.disabled=e[4])},d(e){e&&d(t),i=!1,r()}}}function Fv(e){let t,n,i,r,s,o,a,l,f,h,v,w,A,I,C,E,x=e[23].name+"",B=new Date(e[23].modified).toLocaleString()+"",Q=e[23].is_current&&Bv();function F(){return e[20](e[23])}let D=!e[23].is_current&&Qv(e);return{c(){t=p("div"),n=p("div"),i=p("div"),r=g(x),s=m(),o=p("div"),a=g(B),l=m(),Q&&Q.c(),f=m(),h=p("div"),v=p("button"),w=g("📥 Load"),A=m(),D&&D.c(),I=m(),b(i,"class","version-name svelte-fiaj1r"),b(o,"class","version-date svelte-fiaj1r"),b(n,"class","version-info svelte-fiaj1r"),b(v,"class","version-btn load-btn svelte-fiaj1r"),v.disabled=e[4],b(h,"class","version-actions svelte-fiaj1r"),b(t,"class","version-item svelte-fiaj1r"),S(t,"current",e[23].is_current)},m(e,d){u(e,t,d),c(t,n),c(n,i),c(i,r),c(n,s),c(n,o),c(o,a),c(o,l),Q&&Q.m(o,null),c(t,f),c(t,h),c(h,v),c(v,w),c(h,A),D&&D.m(h,null),c(t,I),C||(E=y(v,"click",F),C=!0)},p(n,i){e=n,256&i&&x!==(x=e[23].name+"")&&k(r,x),256&i&&B!==(B=new Date(e[23].modified).toLocaleString()+"")&&k(a,B),e[23].is_current?Q||(Q=Bv(),Q.c(),Q.m(o,null)):Q&&(Q.d(1),Q=null),16&i&&(v.disabled=e[4]),e[23].is_current?D&&(D.d(1),D=null):D?D.p(e,i):(D=Qv(e),D.c(),D.m(h,null)),256&i&&S(t,"current",e[23].is_current)},d(e){e&&d(t),Q&&Q.d(),D&&D.d(),C=!1,E()}}}function Dv(t){let n,i,r;function s(e,t){return e[1]&&"owner"===e[2]?Ev:e[1]?Cv:Iv}let o=s(t),a=o(t);return{c(){n=p("div"),i=p("h2"),i.textContent="Sprocket Script Management",r=m(),a.c(),b(i,"class","svelte-fiaj1r"),b(n,"class","sprocket-view svelte-fiaj1r")},m(e,t){u(e,n,t),c(n,i),c(n,r),a.m(n,null)},p(e,[t]){o===(o=s(e))&&a?a.p(e,t):(a.d(1),a=o(e),a&&(a.c(),a.m(n,null)))},i:e,o:e,d(e){e&&d(n),a.d()}}}function $v(e,t,n){let{isLoggedIn:i=!1}=t,{userRole:r=""}=t,{sprocketStatus:s=null}=t,{isLoadingSprocket:o=!1}=t,{sprocketUploadFile:a=null}=t,{sprocketScript:l=""}=t,{sprocketMessage:c=""}=t,{sprocketMessageType:u=""}=t,{sprocketVersions:d=[]}=t;const f=P();function p(e){f("loadVersion",e)}function h(e){f("deleteVersion",e)}return e.$$set=e=>{"isLoggedIn"in e&&n(1,i=e.isLoggedIn),"userRole"in e&&n(2,r=e.userRole),"sprocketStatus"in e&&n(3,s=e.sprocketStatus),"isLoadingSprocket"in e&&n(4,o=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,i,r,s,o,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")},p,h,function(){f("openLoginModal")},function(){l=this.value,n(0,l)},e=>p(e),e=>h(e.name)]}class Pv extends se{constructor(e){super(),re(this,e,$v,Dv,s,{isLoggedIn:1,userRole:2,sprocketStatus:3,isLoadingSprocket:4,sprocketUploadFile:5,sprocketScript:0,sprocketMessage:6,sprocketMessageType:7,sprocketVersions:8})}}function Rv(e,t,n){const i=e.slice();return i[26]=t[n],i}function Tv(e,t,n){const i=e.slice();return i[29]=t[n],i}function Uv(e,t,n){const i=e.slice();return i[32]=t[n],i}function _v(t){let n,i,r,s,o,a;return{c(){n=p("div"),i=p("p"),i.textContent="Please log in to access policy configuration.",r=m(),s=p("button"),s.textContent="Log In",b(i,"class","svelte-gkxvxc"),b(s,"class","login-btn svelte-gkxvxc"),b(n,"class","login-prompt svelte-gkxvxc")},m(e,l){u(e,n,l),c(n,i),c(n,r),c(n,s),o||(a=y(s,"click",t[16]),o=!0)},p:e,d(e){e&&d(n),o=!1,a()}}}function Nv(e){let t,n,i,r,s,o,a,l,f,h=(e[3]||"none")+"";return{c(){t=p("div"),n=p("p"),n.textContent="Policy configuration requires owner or policy admin permissions.",i=m(),r=p("p"),r.innerHTML='To become a policy admin, ask an existing policy admin to add your pubkey\n to the <code class="svelte-gkxvxc">policy_admins</code> list.',s=m(),o=p("p"),a=g("Current user role: "),l=p("strong"),f=g(h),b(n,"class","svelte-gkxvxc"),b(r,"class","svelte-gkxvxc"),b(o,"class","svelte-gkxvxc"),b(t,"class","permission-denied svelte-gkxvxc")},m(e,d){u(e,t,d),c(t,n),c(t,i),c(t,r),c(t,s),c(t,o),c(o,a),c(o,l),c(l,f)},p(e,t){8&t[0]&&h!==(h=(e[3]||"none")+"")&&k(f,h)},d(e){e&&d(t)}}}function Lv(e){let t,n,r,s,o,a,l,f,h,v,w,A,C,E,x,B,Q,F,D,$,P,R,T,U,_,N,L,O,M,j,H,G,J,K,V,q,Y,W,z,Z,X,ee,te,ne,ie,re,se,oe,ae,le,ce,ue,de,fe,pe,he,ge,me,ve,ye,we,be,Ae,ke,Ie,Ce,Ee,xe,Se,Be,Qe,Fe,De,$e,Pe,Re=e[5]?"Policy Enabled":"Policy Disabled",Te=e[10].length+"",Ue=e[4]&&Ov(),_e=e[9].length>0&&Mv(e),Ne=e[7]&&Hv(e);function Le(e,t){return 0===e[1].length?Jv:Gv}let Oe=Le(e),Me=Oe(e);function je(e,t){return 0===e[10].length?qv:Vv}let He=je(e),Ge=He(e);return{c(){t=p("div"),n=p("div"),r=p("h3"),r.textContent="Policy Editor",s=m(),o=p("div"),a=p("span"),l=g(Re),f=m(),Ue&&Ue.c(),h=m(),v=p("div"),v.innerHTML='<p class="svelte-gkxvxc">Edit the policy JSON below and click &quot;Save &amp; Publish&quot; to update the relay&#39;s policy configuration.\n Changes are applied immediately after validation.</p> \n <p class="info-note svelte-gkxvxc">Policy updates are published as kind 12345 events and require policy admin permissions.</p>',w=m(),A=p("div"),C=p("textarea"),E=m(),_e&&_e.c(),x=m(),B=p("div"),Q=p("button"),F=g("Load Current"),D=m(),$=p("button"),P=g("Format JSON"),R=m(),T=p("button"),U=g("Validate"),_=m(),N=p("button"),L=g("Save & Publish"),O=m(),Ne&&Ne.c(),M=m(),j=p("div"),H=p("h3"),H.textContent="Policy Administrators",G=m(),J=p("div"),J.innerHTML='<p class="svelte-gkxvxc">Policy admins can update the relay&#39;s policy configuration via kind 12345 events.\n Their follows get whitelisted if <code>policy_follow_whitelist_enabled</code> is true in the policy.</p> \n <p class="info-note svelte-gkxvxc"><strong>Note:</strong> Policy admins are separate from relay admins (ORLY_ADMINS).\n Changes here update the JSON editor - click &quot;Save &amp; Publish&quot; to apply.</p>',K=m(),V=p("div"),Me.c(),q=m(),Y=p("div"),W=p("input"),z=m(),Z=p("button"),X=g("+ Add Admin"),te=m(),ne=p("div"),ie=p("h3"),ie.textContent="Policy Follow Whitelist",re=m(),se=p("div"),se.innerHTML='<p class="svelte-gkxvxc">Pubkeys followed by policy admins (kind 3 events).\n These get automatic read+write access when rules have <code>write_allow_follows: true</code>.</p>',oe=m(),ae=p("div"),le=p("span"),ce=g(Te),ue=g(" pubkey(s) in whitelist"),de=m(),fe=p("button"),pe=g("🔄 Refresh Follows"),he=m(),ge=p("div"),Ge.c(),me=m(),ve=p("div"),ye=p("h3"),ye.textContent="Policy Reference",we=m(),be=p("div"),Ae=p("h4"),Ae.textContent="Structure Overview",ke=m(),Ie=p("ul"),Ie.innerHTML='<li class="svelte-gkxvxc"><code class="svelte-gkxvxc">kind.whitelist</code> - Only allow these event kinds (takes precedence)</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">kind.blacklist</code> - Deny these event kinds (if no whitelist)</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">global</code> - Rules applied to all events</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">rules</code> - Per-kind rules (keyed by kind number as string)</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">default_policy</code> - &quot;allow&quot; or &quot;deny&quot; when no rules match</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">policy_admins</code> - Hex pubkeys that can update policy</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">policy_follow_whitelist_enabled</code> - Enable follow-based access</li>',Ce=m(),Ee=p("h4"),Ee.textContent="Rule Fields",xe=m(),Se=p("ul"),Se.innerHTML='<li class="svelte-gkxvxc"><code class="svelte-gkxvxc">description</code> - Human-readable rule description</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">write_allow</code> / <code class="svelte-gkxvxc">write_deny</code> - Pubkey lists for write access</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">read_allow</code> / <code class="svelte-gkxvxc">read_deny</code> - Pubkey lists for read access</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">write_allow_follows</code> - Grant access to policy admin follows</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">size_limit</code> - Max total event size in bytes</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">content_limit</code> - Max content field size in bytes</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">max_expiry</code> - Max expiry offset in seconds</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">max_age_of_event</code> - Max age of created_at in seconds</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">max_age_event_in_future</code> - Max future offset in seconds</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">must_have_tags</code> - Required tag letters (e.g., [&quot;d&quot;, &quot;t&quot;])</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">tag_validation</code> - Regex patterns for tag values</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">script</code> - Path to external validation script</li>',Be=m(),Qe=p("h4"),Qe.textContent="Example Policy",Fe=m(),De=p("pre"),De.textContent=`${e[20]}`,b(r,"class","svelte-gkxvxc"),b(a,"class","status-badge svelte-gkxvxc"),S(a,"enabled",e[5]),b(o,"class","policy-status svelte-gkxvxc"),b(n,"class","policy-header svelte-gkxvxc"),b(v,"class","policy-info svelte-gkxvxc"),b(C,"class","policy-editor svelte-gkxvxc"),b(C,"placeholder","Loading policy configuration..."),C.disabled=e[6],b(C,"spellcheck","false"),b(A,"class","editor-container svelte-gkxvxc"),b(Q,"class","policy-btn load-btn svelte-gkxvxc"),Q.disabled=e[6],b($,"class","policy-btn format-btn svelte-gkxvxc"),$.disabled=e[6],b(T,"class","policy-btn validate-btn svelte-gkxvxc"),T.disabled=e[6],b(N,"class","policy-btn save-btn svelte-gkxvxc"),N.disabled=e[6],b(B,"class","policy-actions svelte-gkxvxc"),b(t,"class","policy-section svelte-gkxvxc"),b(J,"class","policy-info svelte-gkxvxc"),b(V,"class","admin-list svelte-gkxvxc"),b(W,"type","text"),b(W,"placeholder","npub or hex pubkey"),W.disabled=e[6],b(W,"class","svelte-gkxvxc"),b(Z,"class","policy-btn add-btn svelte-gkxvxc"),Z.disabled=ee=e[6]||!e[11].trim(),b(Y,"class","add-admin svelte-gkxvxc"),b(j,"class","policy-section svelte-gkxvxc"),b(se,"class","policy-info svelte-gkxvxc"),b(le,"class","follows-count svelte-gkxvxc"),b(fe,"class","policy-btn refresh-btn svelte-gkxvxc"),fe.disabled=e[6],b(ae,"class","follows-header svelte-gkxvxc"),b(ge,"class","follows-list svelte-gkxvxc"),b(ne,"class","policy-section svelte-gkxvxc"),b(Ae,"class","svelte-gkxvxc"),b(Ie,"class","field-list svelte-gkxvxc"),b(Ee,"class","svelte-gkxvxc"),b(Se,"class","field-list svelte-gkxvxc"),b(Qe,"class","svelte-gkxvxc"),b(De,"class","example-json svelte-gkxvxc"),b(be,"class","reference-content svelte-gkxvxc"),b(ve,"class","policy-section svelte-gkxvxc")},m(i,d){u(i,t,d),c(t,n),c(n,r),c(n,s),c(n,o),c(o,a),c(a,l),c(o,f),Ue&&Ue.m(o,null),c(t,h),c(t,v),c(t,w),c(t,A),c(A,C),I(C,e[0]),c(t,E),_e&&_e.m(t,null),c(t,x),c(t,B),c(B,Q),c(Q,F),c(B,D),c(B,$),c($,P),c(B,R),c(B,T),c(T,U),c(B,_),c(B,N),c(N,L),c(t,O),Ne&&Ne.m(t,null),u(i,M,d),u(i,j,d),c(j,H),c(j,G),c(j,J),c(j,K),c(j,V),Me.m(V,null),c(j,q),c(j,Y),c(Y,W),I(W,e[11]),c(Y,z),c(Y,Z),c(Z,X),u(i,te,d),u(i,ne,d),c(ne,ie),c(ne,re),c(ne,se),c(ne,oe),c(ne,ae),c(ae,le),c(le,ce),c(le,ue),c(ae,de),c(ae,fe),c(fe,pe),c(ne,he),c(ne,ge),Ge.m(ge,null),u(i,me,d),u(i,ve,d),c(ve,ye),c(ve,we),c(ve,be),c(be,Ae),c(be,ke),c(be,Ie),c(be,Ce),c(be,Ee),c(be,xe),c(be,Se),c(be,Be),c(be,Qe),c(be,Fe),c(be,De),$e||(Pe=[y(C,"input",e[21]),y(Q,"click",e[12]),y($,"click",e[15]),y(T,"click",e[13]),y(N,"click",e[14]),y(W,"input",e[23]),y(W,"keydown",e[24]),y(Z,"click",e[18]),y(fe,"click",e[17])],$e=!0)},p(e,n){32&n[0]&&Re!==(Re=e[5]?"Policy Enabled":"Policy Disabled")&&k(l,Re),32&n[0]&&S(a,"enabled",e[5]),e[4]?Ue||(Ue=Ov(),Ue.c(),Ue.m(o,null)):Ue&&(Ue.d(1),Ue=null),64&n[0]&&(C.disabled=e[6]),1&n[0]&&I(C,e[0]),e[9].length>0?_e?_e.p(e,n):(_e=Mv(e),_e.c(),_e.m(t,x)):_e&&(_e.d(1),_e=null),64&n[0]&&(Q.disabled=e[6]),64&n[0]&&($.disabled=e[6]),64&n[0]&&(T.disabled=e[6]),64&n[0]&&(N.disabled=e[6]),e[7]?Ne?Ne.p(e,n):(Ne=Hv(e),Ne.c(),Ne.m(t,null)):Ne&&(Ne.d(1),Ne=null),Oe===(Oe=Le(e))&&Me?Me.p(e,n):(Me.d(1),Me=Oe(e),Me&&(Me.c(),Me.m(V,null))),64&n[0]&&(W.disabled=e[6]),2048&n[0]&&W.value!==e[11]&&I(W,e[11]),2112&n[0]&&ee!==(ee=e[6]||!e[11].trim())&&(Z.disabled=ee),1024&n[0]&&Te!==(Te=e[10].length+"")&&k(ce,Te),64&n[0]&&(fe.disabled=e[6]),He===(He=je(e))&&Ge?Ge.p(e,n):(Ge.d(1),Ge=He(e),Ge&&(Ge.c(),Ge.m(ge,null)))},d(e){e&&d(t),Ue&&Ue.d(),_e&&_e.d(),Ne&&Ne.d(),e&&d(M),e&&d(j),Me.d(),e&&d(te),e&&d(ne),Ge.d(),e&&d(me),e&&d(ve),$e=!1,i(Pe)}}}function Ov(e){let t;return{c(){t=p("span"),t.textContent="Policy Admin",b(t,"class","admin-badge svelte-gkxvxc")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Mv(e){let t,n,i,r,s=e[9],o=[];for(let t=0;t<s.length;t+=1)o[t]=jv(Uv(e,s,t));return{c(){t=p("div"),n=p("h4"),n.textContent="Validation Errors:",i=m(),r=p("ul");for(let e=0;e<o.length;e+=1)o[e].c();b(n,"class","svelte-gkxvxc"),b(r,"class","svelte-gkxvxc"),b(t,"class","validation-errors svelte-gkxvxc")},m(e,s){u(e,t,s),c(t,n),c(t,i),c(t,r);for(let e=0;e<o.length;e+=1)o[e]&&o[e].m(r,null)},p(e,t){if(512&t[0]){let n;for(s=e[9],n=0;n<s.length;n+=1){const i=Uv(e,s,n);o[n]?o[n].p(i,t):(o[n]=jv(i),o[n].c(),o[n].m(r,null))}for(;n<o.length;n+=1)o[n].d(1);o.length=s.length}},d(e){e&&d(t),f(o,e)}}}function jv(e){let t,n,i=e[32]+"";return{c(){t=p("li"),n=g(i),b(t,"class","svelte-gkxvxc")},m(e,i){u(e,t,i),c(t,n)},p(e,t){512&t[0]&&i!==(i=e[32]+"")&&k(n,i)},d(e){e&&d(t)}}}function Hv(e){let t,n;return{c(){t=p("div"),n=g(e[7]),b(t,"class","policy-message svelte-gkxvxc"),S(t,"error","error"===e[8]),S(t,"success","success"===e[8])},m(e,i){u(e,t,i),c(t,n)},p(e,i){128&i[0]&&k(n,e[7]),256&i[0]&&S(t,"error","error"===e[8]),256&i[0]&&S(t,"success","success"===e[8])},d(e){e&&d(t)}}}function Gv(e){let t,n=e[1],i=[];for(let t=0;t<n.length;t+=1)i[t]=Kv(Tv(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=v()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);u(e,t,n)},p(e,r){if(524354&r[0]){let s;for(n=e[1],s=0;s<n.length;s+=1){const o=Tv(e,n,s);i[s]?i[s].p(o,r):(i[s]=Kv(o),i[s].c(),i[s].m(t.parentNode,t))}for(;s<i.length;s+=1)i[s].d(1);i.length=n.length}},d(e){f(i,e),e&&d(t)}}}function Jv(t){let n;return{c(){n=p("p"),n.textContent="No policy admins configured",b(n,"class","no-items svelte-gkxvxc")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Kv(e){let t,n,i,r,s,o,a,l,f,h,v,w,A=e[29].substring(0,16)+"",I=e[29].substring(e[29].length-8)+"";function C(){return e[22](e[29])}return{c(){t=p("div"),n=p("span"),i=g(A),r=g("..."),s=g(I),a=m(),l=p("button"),f=g("✕"),h=m(),b(n,"class","admin-pubkey svelte-gkxvxc"),b(n,"title",o=e[29]),b(l,"class","remove-btn svelte-gkxvxc"),l.disabled=e[6],b(l,"title","Remove admin"),b(t,"class","admin-item svelte-gkxvxc")},m(e,o){u(e,t,o),c(t,n),c(n,i),c(n,r),c(n,s),c(t,a),c(t,l),c(l,f),c(t,h),v||(w=y(l,"click",C),v=!0)},p(t,r){e=t,2&r[0]&&A!==(A=e[29].substring(0,16)+"")&&k(i,A),2&r[0]&&I!==(I=e[29].substring(e[29].length-8)+"")&&k(s,I),2&r[0]&&o!==(o=e[29])&&b(n,"title",o),64&r[0]&&(l.disabled=e[6])},d(e){e&&d(t),v=!1,w()}}}function Vv(e){let t,n=e[10],i=[];for(let t=0;t<n.length;t+=1)i[t]=Yv(Rv(e,n,t));return{c(){t=p("div");for(let e=0;e<i.length;e+=1)i[e].c();b(t,"class","follows-grid svelte-gkxvxc")},m(e,n){u(e,t,n);for(let e=0;e<i.length;e+=1)i[e]&&i[e].m(t,null)},p(e,r){if(1024&r[0]){let s;for(n=e[10],s=0;s<n.length;s+=1){const o=Rv(e,n,s);i[s]?i[s].p(o,r):(i[s]=Yv(o),i[s].c(),i[s].m(t,null))}for(;s<i.length;s+=1)i[s].d(1);i.length=n.length}},d(e){e&&d(t),f(i,e)}}}function qv(t){let n;return{c(){n=p("p"),n.textContent='No follows loaded. Click "Refresh Follows" to load from database.',b(n,"class","no-items svelte-gkxvxc")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Yv(e){let t,n,i,r,s,o,a=e[26].substring(0,12)+"",l=e[26].substring(e[26].length-6)+"";return{c(){t=p("div"),n=g(a),i=g("..."),r=g(l),s=m(),b(t,"class","follow-item svelte-gkxvxc"),b(t,"title",o=e[26])},m(e,o){u(e,t,o),c(t,n),c(t,i),c(t,r),c(t,s)},p(e,i){1024&i[0]&&a!==(a=e[26].substring(0,12)+"")&&k(n,a),1024&i[0]&&l!==(l=e[26].substring(e[26].length-6)+"")&&k(r,l),1024&i[0]&&o!==(o=e[26])&&b(t,"title",o)},d(e){e&&d(t)}}}function Wv(t){let n,i,r;function s(e,t){return e[2]&&("owner"===e[3]||e[4])?Lv:e[2]?Nv:_v}let o=s(t),a=o(t);return{c(){n=p("div"),i=p("h2"),i.textContent="Policy Configuration",r=m(),a.c(),b(i,"class","svelte-gkxvxc"),b(n,"class","policy-view svelte-gkxvxc")},m(e,t){u(e,n,t),c(n,i),c(n,r),a.m(n,null)},p(e,t){o===(o=s(e))&&a?a.p(e,t):(a.d(1),a=o(e),a&&(a.c(),a.m(n,null)))},i:e,o:e,d(e){e&&d(n),a.d()}}}function zv(e,t,n){let{isLoggedIn:i=!1}=t,{userRole:r=""}=t,{isPolicyAdmin:s=!1}=t,{policyEnabled:o=!1}=t,{policyJson:a=""}=t,{isLoadingPolicy:l=!1}=t,{policyMessage:c=""}=t,{policyMessageType:u=""}=t,{validationErrors:d=[]}=t,{policyAdmins:f=[]}=t,{policyFollows:p=[]}=t;const h=P();let g="";function m(){g.trim()&&(h("addPolicyAdmin",g.trim()),n(11,g=""))}function v(e){h("removePolicyAdmin",e)}return e.$$set=e=>{"isLoggedIn"in e&&n(2,i=e.isLoggedIn),"userRole"in e&&n(3,r=e.userRole),"isPolicyAdmin"in e&&n(4,s=e.isPolicyAdmin),"policyEnabled"in e&&n(5,o=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,p=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,i,r,s,o,l,c,u,d,p,g,function(){h("loadPolicy")},function(){h("validatePolicy")},function(){h("savePolicy")},function(){h("formatJson")},function(){h("openLoginModal")},function(){h("refreshFollows")},m,v,'{\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": ["<your-hex-pubkey>"],\n "policy_follow_whitelist_enabled": true\n}',function(){a=this.value,n(0,a)},e=>v(e),function(){g=this.value,n(11,g)},e=>"Enter"===e.key&&m()]}class Zv extends se{constructor(e){super(),re(this,e,zv,Wv,s,{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 Xv=[{id:"social",name:"Social/Notes",description:"User profiles, notes, follows, reposts, reactions, and relay lists",kinds:[0,1,3,6,7,10002]},{id:"dm",name:"Direct Messages",description:"Encrypted direct messages (legacy and NIP-17 gift-wrapped)",kinds:[4,14,1059]},{id:"longform",name:"Long-form Content",description:"Blog posts and article drafts",kinds:[30023,30024]},{id:"media",name:"Media",description:"File metadata and media attachments",kinds:[1063,20,21,22]},{id:"marketplace_nip15",name:"Marketplace (NIP-15)",description:"Legacy NIP-15 stalls and products",kinds:[30017,30018,30019,30020]},{id:"marketplace_nip99",name:"Marketplace (NIP-99/Gamma)",description:"NIP-99 classified listings, collections, shipping, reviews (Plebeian Market)",kinds:[30402,30403,30405,30406,31555]},{id:"order_communication",name:"Order Communication",description:"Gamma Markets order messages and payment receipts (kinds 16, 17)",kinds:[16,17]},{id:"groups_nip29",name:"Group Messaging (NIP-29)",description:"Simple relay-based group chat messages",kinds:[9,10,11,12]},{id:"groups_nip72",name:"Communities (NIP-72)",description:"Community definitions and threaded discussions",kinds:[34550,1111,4550]},{id:"lists",name:"Lists/Bookmarks",description:"Mute lists, pin lists, and parameterized list events",kinds:[1e4,10001,3e4,30001]}];function ey(e,t,n){const i=e.slice();return i[68]=t[n],i}function ty(e,t,n){const i=e.slice();return i[73]=t[n],i}function ny(e,t,n){const i=e.slice();return i[76]=t[n],i}function iy(e,t,n){const i=e.slice();return i[79]=t[n],i}function ry(e,t,n){const i=e.slice();return i[82]=t[n],i}function sy(e,t,n){const i=e.slice();return i[82]=t[n],i}function oy(e,t,n){const i=e.slice();return i[68]=t[n],i}function ay(e){let t,n,i;return{c(){t=p("div"),n=g(e[2]),b(t,"class",i="message "+e[3]+" svelte-vbat7g")},m(e,i){u(e,t,i),c(t,n)},p(e,r){4&r[0]&&k(n,e[2]),8&r[0]&&i!==(i="message "+e[3]+" svelte-vbat7g")&&b(t,"class",i)},d(e){e&&d(t)}}}function ly(e){let t,n,r,s,o,a,l,f,h,v,w,A,I,C,E,x,B,Q,F,D,$,P,R,T,U,_,N,L,O,M,j,H,G,J,K,V,q=e[6].length+"",Y=e[9].length+"",W=e[12].length+"",z=e[13].length+"",Z=e[14].length+"",X="trusted"===e[0]&&uy(e),ee="blacklist"===e[0]&&gy(e),te="unclassified"===e[0]&&by(e),ne="spam"===e[0]&&Cy(e),ie="ips"===e[0]&&Qy(e),re="settings"===e[0]&&Ty(e);return{c(){t=p("div"),n=p("button"),r=g("Trusted ("),s=g(q),o=g(")"),a=m(),l=p("button"),f=g("Blacklist ("),h=g(Y),v=g(")"),w=m(),A=p("button"),I=g("Unclassified ("),C=g(W),E=g(")"),x=m(),B=p("button"),Q=g("Spam ("),F=g(z),D=g(")"),$=m(),P=p("button"),R=g("Blocked IPs ("),T=g(Z),U=g(")"),_=m(),N=p("button"),N.textContent="Settings",L=m(),O=p("div"),X&&X.c(),M=m(),ee&&ee.c(),j=m(),te&&te.c(),H=m(),ne&&ne.c(),G=m(),ie&&ie.c(),J=m(),re&&re.c(),b(n,"class","tab svelte-vbat7g"),S(n,"active","trusted"===e[0]),b(l,"class","tab svelte-vbat7g"),S(l,"active","blacklist"===e[0]),b(A,"class","tab svelte-vbat7g"),S(A,"active","unclassified"===e[0]),b(B,"class","tab svelte-vbat7g"),S(B,"active","spam"===e[0]),b(P,"class","tab svelte-vbat7g"),S(P,"active","ips"===e[0]),b(N,"class","tab svelte-vbat7g"),S(N,"active","settings"===e[0]),b(t,"class","tabs svelte-vbat7g"),b(O,"class","tab-content svelte-vbat7g")},m(i,d){u(i,t,d),c(t,n),c(n,r),c(n,s),c(n,o),c(t,a),c(t,l),c(l,f),c(l,h),c(l,v),c(t,w),c(t,A),c(A,I),c(A,C),c(A,E),c(t,x),c(t,B),c(B,Q),c(B,F),c(B,D),c(t,$),c(t,P),c(P,R),c(P,T),c(P,U),c(t,_),c(t,N),u(i,L,d),u(i,O,d),X&&X.m(O,null),c(O,M),ee&&ee.m(O,null),c(O,j),te&&te.m(O,null),c(O,H),ne&&ne.m(O,null),c(O,G),ie&&ie.m(O,null),c(O,J),re&&re.m(O,null),K||(V=[y(n,"click",e[36]),y(l,"click",e[37]),y(A,"click",e[38]),y(B,"click",e[39]),y(P,"click",e[40]),y(N,"click",e[41])],K=!0)},p(e,t){64&t[0]&&q!==(q=e[6].length+"")&&k(s,q),1&t[0]&&S(n,"active","trusted"===e[0]),512&t[0]&&Y!==(Y=e[9].length+"")&&k(h,Y),1&t[0]&&S(l,"active","blacklist"===e[0]),4096&t[0]&&W!==(W=e[12].length+"")&&k(C,W),1&t[0]&&S(A,"active","unclassified"===e[0]),8192&t[0]&&z!==(z=e[13].length+"")&&k(F,z),1&t[0]&&S(B,"active","spam"===e[0]),16384&t[0]&&Z!==(Z=e[14].length+"")&&k(T,Z),1&t[0]&&S(P,"active","ips"===e[0]),1&t[0]&&S(N,"active","settings"===e[0]),"trusted"===e[0]?X?X.p(e,t):(X=uy(e),X.c(),X.m(O,M)):X&&(X.d(1),X=null),"blacklist"===e[0]?ee?ee.p(e,t):(ee=gy(e),ee.c(),ee.m(O,j)):ee&&(ee.d(1),ee=null),"unclassified"===e[0]?te?te.p(e,t):(te=by(e),te.c(),te.m(O,H)):te&&(te.d(1),te=null),"spam"===e[0]?ne?ne.p(e,t):(ne=Cy(e),ne.c(),ne.m(O,G)):ne&&(ne.d(1),ne=null),"ips"===e[0]?ie?ie.p(e,t):(ie=Qy(e),ie.c(),ie.m(O,J)):ie&&(ie.d(1),ie=null),"settings"===e[0]?re?re.p(e,t):(re=Ty(e),re.c(),re.m(O,null)):re&&(re.d(1),re=null)},d(e){e&&d(t),e&&d(L),e&&d(O),X&&X.d(),ee&&ee.d(),te&&te.d(),ne&&ne.d(),ie&&ie.d(),re&&re.d(),K=!1,i(V)}}}function cy(e){let t,n,r,s,o,a,l,h,g,v,w,k,C,E,x,S,B,Q,F,D,$,P,R,T,U,_,N,L,O,M,j,H,G,J,K,V,q,Y,W,z,Z,X=Xv,ee=[];for(let t=0;t<X.length;t+=1)ee[t]=Ly(oy(e,X,t));function te(e,t){return e[1]?My:Oy}let ne=te(e),ie=ne(e);return{c(){t=p("div"),n=p("div"),n.innerHTML='<h3 class="svelte-vbat7g">Initial Configuration</h3> \n <p class="svelte-vbat7g">Configure curating mode before the relay will accept events. Select which event kinds to allow and set rate limiting parameters.</p>',r=m(),s=p("div"),o=p("h4"),o.textContent="Allowed Event Kinds",a=m(),l=p("p"),l.textContent="Select categories of events to allow. At least one must be selected.",h=m(),g=p("div");for(let e=0;e<ee.length;e+=1)ee[e].c();v=m(),w=p("div"),k=p("label"),k.textContent='Custom Kinds (comma-separated, ranges allowed e.g., "100, 200-300")',C=m(),E=p("input"),x=m(),S=p("div"),B=p("h4"),B.textContent="Rate Limiting",Q=m(),F=p("div"),D=p("div"),$=p("label"),$.textContent="Daily Event Limit (unclassified users)",P=m(),R=p("input"),T=m(),U=p("div"),_=p("div"),N=p("label"),N.textContent="First IP Ban Duration (hours)",L=m(),O=p("input"),M=m(),j=p("div"),H=p("label"),H.textContent="Second+ IP Ban Duration (hours)",G=m(),J=p("input"),K=m(),V=p("div"),q=p("button"),ie.c(),Y=m(),W=p("p"),W.textContent="This will publish a kind 30078 event to activate curating mode.",b(n,"class","setup-header svelte-vbat7g"),b(o,"class","svelte-vbat7g"),b(l,"class","help-text svelte-vbat7g"),b(g,"class","category-grid svelte-vbat7g"),b(k,"for","custom-kinds"),b(k,"class","svelte-vbat7g"),b(E,"id","custom-kinds"),b(E,"type","text"),b(E,"placeholder","e.g., 100, 200-250, 500"),b(E,"class","svelte-vbat7g"),b(w,"class","custom-kinds svelte-vbat7g"),b(s,"class","config-section svelte-vbat7g"),b(B,"class","svelte-vbat7g"),b($,"for","daily-limit"),b($,"class","svelte-vbat7g"),b(R,"id","daily-limit"),b(R,"type","number"),b(R,"min","1"),b(R,"class","svelte-vbat7g"),b(D,"class","form-group svelte-vbat7g"),b(F,"class","form-row svelte-vbat7g"),b(N,"for","first-ban"),b(N,"class","svelte-vbat7g"),b(O,"id","first-ban"),b(O,"type","number"),b(O,"min","1"),b(O,"class","svelte-vbat7g"),b(_,"class","form-group svelte-vbat7g"),b(H,"for","second-ban"),b(H,"class","svelte-vbat7g"),b(J,"id","second-ban"),b(J,"type","number"),b(J,"min","1"),b(J,"class","svelte-vbat7g"),b(j,"class","form-group svelte-vbat7g"),b(U,"class","form-row svelte-vbat7g"),b(S,"class","config-section svelte-vbat7g"),b(q,"class","publish-btn svelte-vbat7g"),q.disabled=e[1],b(W,"class","publish-note svelte-vbat7g"),b(V,"class","publish-section svelte-vbat7g"),b(t,"class","setup-section svelte-vbat7g")},m(i,d){u(i,t,d),c(t,n),c(t,r),c(t,s),c(s,o),c(s,a),c(s,l),c(s,h),c(s,g);for(let e=0;e<ee.length;e+=1)ee[e]&&ee[e].m(g,null);c(s,v),c(s,w),c(w,k),c(w,C),c(w,E),I(E,e[5].custom_kinds),c(t,x),c(t,S),c(S,B),c(S,Q),c(S,F),c(F,D),c(D,$),c(D,P),c(D,R),I(R,e[5].daily_limit),c(S,T),c(S,U),c(U,_),c(_,N),c(_,L),c(_,O),I(O,e[5].first_ban_hours),c(U,M),c(U,j),c(j,H),c(j,G),c(j,J),I(J,e[5].second_ban_hours),c(t,K),c(t,V),c(V,q),ie.m(q,null),c(V,Y),c(V,W),z||(Z=[y(E,"input",e[32]),y(R,"input",e[33]),y(O,"input",e[34]),y(J,"input",e[35]),y(q,"click",e[27])],z=!0)},p(e,t){if(67108896&t[0]){let n;for(X=Xv,n=0;n<X.length;n+=1){const i=oy(e,X,n);ee[n]?ee[n].p(i,t):(ee[n]=Ly(i),ee[n].c(),ee[n].m(g,null))}for(;n<ee.length;n+=1)ee[n].d(1);ee.length=X.length}32&t[0]&&E.value!==e[5].custom_kinds&&I(E,e[5].custom_kinds),32&t[0]&&A(R.value)!==e[5].daily_limit&&I(R,e[5].daily_limit),32&t[0]&&A(O.value)!==e[5].first_ban_hours&&I(O,e[5].first_ban_hours),32&t[0]&&A(J.value)!==e[5].second_ban_hours&&I(J,e[5].second_ban_hours),ne!==(ne=te(e))&&(ie.d(1),ie=ne(e),ie&&(ie.c(),ie.m(q,null))),2&t[0]&&(q.disabled=e[1])},d(e){e&&d(t),f(ee,e),ie.d(),z=!1,i(Z)}}}function uy(e){let t,n,r,s,o,a,l,f,h,v,w,A,k,C,E,x;function S(e,t){return e[6].length>0?fy:dy}let B=S(e),Q=B(e);return{c(){t=p("div"),n=p("h3"),n.textContent="Trusted Publishers",r=m(),s=p("p"),s.textContent="Trusted users can publish unlimited events without rate limiting.",o=m(),a=p("div"),l=p("input"),f=m(),h=p("input"),v=m(),w=p("button"),A=g("Trust"),k=m(),C=p("div"),Q.c(),b(n,"class","svelte-vbat7g"),b(s,"class","help-text svelte-vbat7g"),b(l,"type","text"),b(l,"placeholder","Pubkey (64 hex chars)"),b(l,"class","svelte-vbat7g"),b(h,"type","text"),b(h,"placeholder","Note (optional)"),b(h,"class","svelte-vbat7g"),w.disabled=e[1],b(w,"class","svelte-vbat7g"),b(a,"class","add-form svelte-vbat7g"),b(C,"class","list svelte-vbat7g"),b(t,"class","section svelte-vbat7g")},m(i,d){u(i,t,d),c(t,n),c(t,r),c(t,s),c(t,o),c(t,a),c(a,l),I(l,e[7]),c(a,f),c(a,h),I(h,e[8]),c(a,v),c(a,w),c(w,A),c(t,k),c(t,C),Q.m(C,null),E||(x=[y(l,"input",e[42]),y(h,"input",e[43]),y(w,"click",e[44])],E=!0)},p(e,t){128&t[0]&&l.value!==e[7]&&I(l,e[7]),256&t[0]&&h.value!==e[8]&&I(h,e[8]),2&t[0]&&(w.disabled=e[1]),B===(B=S(e))&&Q?Q.p(e,t):(Q.d(1),Q=B(e),Q&&(Q.c(),Q.m(C,null)))},d(e){e&&d(t),Q.d(),E=!1,i(x)}}}function dy(t){let n;return{c(){n=p("div"),n.textContent="No trusted pubkeys yet.",b(n,"class","empty svelte-vbat7g")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function fy(e){let t,n=e[6],i=[];for(let t=0;t<n.length;t+=1)i[t]=hy(sy(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=v()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);u(e,t,n)},p(e,r){if(1048640&r[0]){let s;for(n=e[6],s=0;s<n.length;s+=1){const o=sy(e,n,s);i[s]?i[s].p(o,r):(i[s]=hy(o),i[s].c(),i[s].m(t.parentNode,t))}for(;s<i.length;s+=1)i[s].d(1);i.length=n.length}},d(e){f(i,e),e&&d(t)}}}function py(e){let t,n,i=e[82].note+"";return{c(){t=p("span"),n=g(i),b(t,"class","note svelte-vbat7g")},m(e,i){u(e,t,i),c(t,n)},p(e,t){64&t[0]&&i!==(i=e[82].note+"")&&k(n,i)},d(e){e&&d(t)}}}function hy(e){let t,n,i,r,s,o,a,l,f,h,v,w,A=Hy(e[82].pubkey)+"",I=e[82].note&&py(e);function C(){return e[45](e[82])}return{c(){t=p("div"),n=p("div"),i=p("span"),r=g(A),o=m(),I&&I.c(),a=m(),l=p("div"),f=p("button"),f.textContent="Remove",h=m(),b(i,"class","pubkey svelte-vbat7g"),b(i,"title",s=e[82].pubkey),b(n,"class","item-main svelte-vbat7g"),b(f,"class","btn-danger svelte-vbat7g"),b(l,"class","item-actions svelte-vbat7g"),b(t,"class","list-item svelte-vbat7g")},m(e,s){u(e,t,s),c(t,n),c(n,i),c(i,r),c(n,o),I&&I.m(n,null),c(t,a),c(t,l),c(l,f),c(t,h),v||(w=y(f,"click",C),v=!0)},p(t,o){e=t,64&o[0]&&A!==(A=Hy(e[82].pubkey)+"")&&k(r,A),64&o[0]&&s!==(s=e[82].pubkey)&&b(i,"title",s),e[82].note?I?I.p(e,o):(I=py(e),I.c(),I.m(n,null)):I&&(I.d(1),I=null)},d(e){e&&d(t),I&&I.d(),v=!1,w()}}}function gy(e){let t,n,r,s,o,a,l,f,h,v,w,A,k,C,E,x;function S(e,t){return e[9].length>0?vy:my}let B=S(e),Q=B(e);return{c(){t=p("div"),n=p("h3"),n.textContent="Blacklisted Publishers",r=m(),s=p("p"),s.textContent="Blacklisted users cannot publish any events.",o=m(),a=p("div"),l=p("input"),f=m(),h=p("input"),v=m(),w=p("button"),A=g("Blacklist"),k=m(),C=p("div"),Q.c(),b(n,"class","svelte-vbat7g"),b(s,"class","help-text svelte-vbat7g"),b(l,"type","text"),b(l,"placeholder","Pubkey (64 hex chars)"),b(l,"class","svelte-vbat7g"),b(h,"type","text"),b(h,"placeholder","Reason (optional)"),b(h,"class","svelte-vbat7g"),w.disabled=e[1],b(w,"class","svelte-vbat7g"),b(a,"class","add-form svelte-vbat7g"),b(C,"class","list svelte-vbat7g"),b(t,"class","section svelte-vbat7g")},m(i,d){u(i,t,d),c(t,n),c(t,r),c(t,s),c(t,o),c(t,a),c(a,l),I(l,e[10]),c(a,f),c(a,h),I(h,e[11]),c(a,v),c(a,w),c(w,A),c(t,k),c(t,C),Q.m(C,null),E||(x=[y(l,"input",e[46]),y(h,"input",e[47]),y(w,"click",e[48])],E=!0)},p(e,t){1024&t[0]&&l.value!==e[10]&&I(l,e[10]),2048&t[0]&&h.value!==e[11]&&I(h,e[11]),2&t[0]&&(w.disabled=e[1]),B===(B=S(e))&&Q?Q.p(e,t):(Q.d(1),Q=B(e),Q&&(Q.c(),Q.m(C,null)))},d(e){e&&d(t),Q.d(),E=!1,i(x)}}}function my(t){let n;return{c(){n=p("div"),n.textContent="No blacklisted pubkeys.",b(n,"class","empty svelte-vbat7g")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function vy(e){let t,n=e[9],i=[];for(let t=0;t<n.length;t+=1)i[t]=wy(ry(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=v()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);u(e,t,n)},p(e,r){if(4194816&r[0]){let s;for(n=e[9],s=0;s<n.length;s+=1){const o=ry(e,n,s);i[s]?i[s].p(o,r):(i[s]=wy(o),i[s].c(),i[s].m(t.parentNode,t))}for(;s<i.length;s+=1)i[s].d(1);i.length=n.length}},d(e){f(i,e),e&&d(t)}}}function yy(e){let t,n,i=e[82].reason+"";return{c(){t=p("span"),n=g(i),b(t,"class","reason svelte-vbat7g")},m(e,i){u(e,t,i),c(t,n)},p(e,t){512&t[0]&&i!==(i=e[82].reason+"")&&k(n,i)},d(e){e&&d(t)}}}function wy(e){let t,n,i,r,s,o,a,l,f,h,v,w,A=Hy(e[82].pubkey)+"",I=e[82].reason&&yy(e);function C(){return e[49](e[82])}return{c(){t=p("div"),n=p("div"),i=p("span"),r=g(A),o=m(),I&&I.c(),a=m(),l=p("div"),f=p("button"),f.textContent="Remove",h=m(),b(i,"class","pubkey svelte-vbat7g"),b(i,"title",s=e[82].pubkey),b(n,"class","item-main svelte-vbat7g"),b(f,"class","btn-success svelte-vbat7g"),b(l,"class","item-actions svelte-vbat7g"),b(t,"class","list-item svelte-vbat7g")},m(e,s){u(e,t,s),c(t,n),c(n,i),c(i,r),c(n,o),I&&I.m(n,null),c(t,a),c(t,l),c(l,f),c(t,h),v||(w=y(f,"click",C),v=!0)},p(t,o){e=t,512&o[0]&&A!==(A=Hy(e[82].pubkey)+"")&&k(r,A),512&o[0]&&s!==(s=e[82].pubkey)&&b(i,"title",s),e[82].reason?I?I.p(e,o):(I=yy(e),I.c(),I.m(n,null)):I&&(I.d(1),I=null)},d(e){e&&d(t),I&&I.d(),v=!1,w()}}}function by(e){let t,n,r,s,o,a,l,f,h,v,w,A,k,I,C;function E(e,t){return e[12].length>0?ky:Ay}let x=E(e),S=x(e);return{c(){t=p("div"),n=p("h3"),n.textContent="Unclassified Users",r=m(),s=p("p"),s.textContent="Users who have posted events but haven't been classified. Sorted by event count.",o=m(),a=p("div"),l=p("button"),f=g("Refresh"),h=m(),v=p("button"),w=g("Scan Database"),A=m(),k=p("div"),S.c(),b(n,"class","svelte-vbat7g"),b(s,"class","help-text svelte-vbat7g"),b(l,"class","refresh-btn svelte-vbat7g"),l.disabled=e[1],b(v,"class","scan-btn svelte-vbat7g"),v.disabled=e[1],b(a,"class","button-row svelte-vbat7g"),b(k,"class","list svelte-vbat7g"),b(t,"class","section svelte-vbat7g")},m(i,d){u(i,t,d),c(t,n),c(t,r),c(t,s),c(t,o),c(t,a),c(a,l),c(l,f),c(a,h),c(a,v),c(v,w),c(t,A),c(t,k),S.m(k,null),I||(C=[y(l,"click",e[15]),y(v,"click",e[16])],I=!0)},p(e,t){2&t[0]&&(l.disabled=e[1]),2&t[0]&&(v.disabled=e[1]),x===(x=E(e))&&S?S.p(e,t):(S.d(1),S=x(e),S&&(S.c(),S.m(k,null)))},d(e){e&&d(t),S.d(),I=!1,i(C)}}}function Ay(t){let n;return{c(){n=p("div"),n.textContent="No unclassified users.",b(n,"class","empty svelte-vbat7g")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function ky(e){let t,n=e[12],i=[];for(let t=0;t<n.length;t+=1)i[t]=Iy(iy(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=v()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);u(e,t,n)},p(e,r){if(2625536&r[0]){let s;for(n=e[12],s=0;s<n.length;s+=1){const o=iy(e,n,s);i[s]?i[s].p(o,r):(i[s]=Iy(o),i[s].c(),i[s].m(t.parentNode,t))}for(;s<i.length;s+=1)i[s].d(1);i.length=n.length}},d(e){f(i,e),e&&d(t)}}}function Iy(e){let t,n,r,s,o,a,l,f,h,v,w,A,I,C,E,x,S,B=Hy(e[79].pubkey)+"",Q=e[79].total_events+"";function F(){return e[50](e[79])}function D(){return e[51](e[79])}return{c(){t=p("div"),n=p("div"),r=p("span"),s=g(B),a=m(),l=p("span"),f=g(Q),h=g(" events"),v=m(),w=p("div"),A=p("button"),A.textContent="Trust",I=m(),C=p("button"),C.textContent="Blacklist",E=m(),b(r,"class","pubkey svelte-vbat7g"),b(r,"title",o=e[79].pubkey),b(l,"class","event-count svelte-vbat7g"),b(n,"class","item-main svelte-vbat7g"),b(A,"class","btn-success svelte-vbat7g"),b(C,"class","btn-danger svelte-vbat7g"),b(w,"class","item-actions svelte-vbat7g"),b(t,"class","list-item svelte-vbat7g")},m(e,i){u(e,t,i),c(t,n),c(n,r),c(r,s),c(n,a),c(n,l),c(l,f),c(l,h),c(t,v),c(t,w),c(w,A),c(w,I),c(w,C),c(t,E),x||(S=[y(A,"click",F),y(C,"click",D)],x=!0)},p(t,n){e=t,4096&n[0]&&B!==(B=Hy(e[79].pubkey)+"")&&k(s,B),4096&n[0]&&o!==(o=e[79].pubkey)&&b(r,"title",o),4096&n[0]&&Q!==(Q=e[79].total_events+"")&&k(f,Q)},d(e){e&&d(t),x=!1,i(S)}}}function Cy(e){let t,n,i,r,s,o,a,l,f,h,v;function w(e,t){return e[13].length>0?xy:Ey}let A=w(e),k=A(e);return{c(){t=p("div"),n=p("h3"),n.textContent="Spam Events",i=m(),r=p("p"),r.textContent="Events flagged as spam are hidden from query results but remain in the database.",s=m(),o=p("button"),a=g("Refresh"),l=m(),f=p("div"),k.c(),b(n,"class","svelte-vbat7g"),b(r,"class","help-text svelte-vbat7g"),b(o,"class","refresh-btn svelte-vbat7g"),o.disabled=e[1],b(f,"class","list svelte-vbat7g"),b(t,"class","section svelte-vbat7g")},m(d,p){u(d,t,p),c(t,n),c(t,i),c(t,r),c(t,s),c(t,o),c(o,a),c(t,l),c(t,f),k.m(f,null),h||(v=y(o,"click",e[17]),h=!0)},p(e,t){2&t[0]&&(o.disabled=e[1]),A===(A=w(e))&&k?k.p(e,t):(k.d(1),k=A(e),k&&(k.c(),k.m(f,null)))},d(e){e&&d(t),k.d(),h=!1,v()}}}function Ey(t){let n;return{c(){n=p("div"),n.textContent="No spam events flagged.",b(n,"class","empty svelte-vbat7g")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function xy(e){let t,n=e[13],i=[];for(let t=0;t<n.length;t+=1)i[t]=By(ny(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=v()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);u(e,t,n)},p(e,r){if(25174016&r[0]){let s;for(n=e[13],s=0;s<n.length;s+=1){const o=ny(e,n,s);i[s]?i[s].p(o,r):(i[s]=By(o),i[s].c(),i[s].m(t.parentNode,t))}for(;s<i.length;s+=1)i[s].d(1);i.length=n.length}},d(e){f(i,e),e&&d(t)}}}function Sy(e){let t,n,i=e[76].reason+"";return{c(){t=p("span"),n=g(i),b(t,"class","reason svelte-vbat7g")},m(e,i){u(e,t,i),c(t,n)},p(e,t){8192&t[0]&&i!==(i=e[76].reason+"")&&k(n,i)},d(e){e&&d(t)}}}function By(e){let t,n,r,s,o,a,l,f,h,v,w,A,I,C,E,x,S,B,Q,F=Hy(e[76].event_id)+"",D=Hy(e[76].pubkey)+"",$=e[76].reason&&Sy(e);function P(){return e[52](e[76])}function R(){return e[53](e[76])}return{c(){t=p("div"),n=p("div"),r=p("span"),s=g(F),a=m(),l=p("span"),f=g("by "),h=g(D),w=m(),$&&$.c(),A=m(),I=p("div"),C=p("button"),C.textContent="Unmark",E=m(),x=p("button"),x.textContent="Delete",S=m(),b(r,"class","event-id svelte-vbat7g"),b(r,"title",o=e[76].event_id),b(l,"class","pubkey svelte-vbat7g"),b(l,"title",v=e[76].pubkey),b(n,"class","item-main svelte-vbat7g"),b(C,"class","btn-success svelte-vbat7g"),b(x,"class","btn-danger svelte-vbat7g"),b(I,"class","item-actions svelte-vbat7g"),b(t,"class","list-item svelte-vbat7g")},m(e,i){u(e,t,i),c(t,n),c(n,r),c(r,s),c(n,a),c(n,l),c(l,f),c(l,h),c(n,w),$&&$.m(n,null),c(t,A),c(t,I),c(I,C),c(I,E),c(I,x),c(t,S),B||(Q=[y(C,"click",P),y(x,"click",R)],B=!0)},p(t,i){e=t,8192&i[0]&&F!==(F=Hy(e[76].event_id)+"")&&k(s,F),8192&i[0]&&o!==(o=e[76].event_id)&&b(r,"title",o),8192&i[0]&&D!==(D=Hy(e[76].pubkey)+"")&&k(h,D),8192&i[0]&&v!==(v=e[76].pubkey)&&b(l,"title",v),e[76].reason?$?$.p(e,i):($=Sy(e),$.c(),$.m(n,null)):$&&($.d(1),$=null)},d(e){e&&d(t),$&&$.d(),B=!1,i(Q)}}}function Qy(e){let t,n,i,r,s,o,a,l,f,h,v;function w(e,t){return e[14].length>0?Dy:Fy}let A=w(e),k=A(e);return{c(){t=p("div"),n=p("h3"),n.textContent="Blocked IP Addresses",i=m(),r=p("p"),r.textContent="IP addresses blocked due to rate limit violations.",s=m(),o=p("button"),a=g("Refresh"),l=m(),f=p("div"),k.c(),b(n,"class","svelte-vbat7g"),b(r,"class","help-text svelte-vbat7g"),b(o,"class","refresh-btn svelte-vbat7g"),o.disabled=e[1],b(f,"class","list svelte-vbat7g"),b(t,"class","section svelte-vbat7g")},m(d,p){u(d,t,p),c(t,n),c(t,i),c(t,r),c(t,s),c(t,o),c(o,a),c(t,l),c(t,f),k.m(f,null),h||(v=y(o,"click",e[18]),h=!0)},p(e,t){2&t[0]&&(o.disabled=e[1]),A===(A=w(e))&&k?k.p(e,t):(k.d(1),k=A(e),k&&(k.c(),k.m(f,null)))},d(e){e&&d(t),k.d(),h=!1,v()}}}function Fy(t){let n;return{c(){n=p("div"),n.textContent="No blocked IPs.",b(n,"class","empty svelte-vbat7g")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Dy(e){let t,n=e[14],i=[];for(let t=0;t<n.length;t+=1)i[t]=Ry(ty(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=v()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);u(e,t,n)},p(e,r){if(33570816&r[0]){let s;for(n=e[14],s=0;s<n.length;s+=1){const o=ty(e,n,s);i[s]?i[s].p(o,r):(i[s]=Ry(o),i[s].c(),i[s].m(t.parentNode,t))}for(;s<i.length;s+=1)i[s].d(1);i.length=n.length}},d(e){f(i,e),e&&d(t)}}}function $y(e){let t,n,i=e[73].reason+"";return{c(){t=p("span"),n=g(i),b(t,"class","reason svelte-vbat7g")},m(e,i){u(e,t,i),c(t,n)},p(e,t){16384&t[0]&&i!==(i=e[73].reason+"")&&k(n,i)},d(e){e&&d(t)}}}function Py(e){let t,n,i,r=Gy(e[73].expires_at)+"";return{c(){t=p("span"),n=g("Expires: "),i=g(r),b(t,"class","expires svelte-vbat7g")},m(e,r){u(e,t,r),c(t,n),c(t,i)},p(e,t){16384&t[0]&&r!==(r=Gy(e[73].expires_at)+"")&&k(i,r)},d(e){e&&d(t)}}}function Ry(e){let t,n,i,r,s,o,a,l,f,h,v,w,A=e[73].ip+"",I=e[73].reason&&$y(e),C=e[73].expires_at&&Py(e);function E(){return e[54](e[73])}return{c(){t=p("div"),n=p("div"),i=p("span"),r=g(A),s=m(),I&&I.c(),o=m(),C&&C.c(),a=m(),l=p("div"),f=p("button"),f.textContent="Unblock",h=m(),b(i,"class","ip svelte-vbat7g"),b(n,"class","item-main svelte-vbat7g"),b(f,"class","btn-success svelte-vbat7g"),b(l,"class","item-actions svelte-vbat7g"),b(t,"class","list-item svelte-vbat7g")},m(e,d){u(e,t,d),c(t,n),c(n,i),c(i,r),c(n,s),I&&I.m(n,null),c(n,o),C&&C.m(n,null),c(t,a),c(t,l),c(l,f),c(t,h),v||(w=y(f,"click",E),v=!0)},p(t,i){e=t,16384&i[0]&&A!==(A=e[73].ip+"")&&k(r,A),e[73].reason?I?I.p(e,i):(I=$y(e),I.c(),I.m(n,o)):I&&(I.d(1),I=null),e[73].expires_at?C?C.p(e,i):(C=Py(e),C.c(),C.m(n,null)):C&&(C.d(1),C=null)},d(e){e&&d(t),I&&I.d(),C&&C.d(),v=!1,w()}}}function Ty(e){let t,n,r,s,o,a,l,h,g,v,w,k,C,E,x,S,B,Q,F,D,$,P,R,T,U,_,N,L,O,M,j,H,G,J,K,V,q,Y,W,z=Xv,Z=[];for(let t=0;t<z.length;t+=1)Z[t]=Uy(ey(e,z,t));function X(e,t){return e[1]?Ny:_y}let ee=X(e),te=ee(e);return{c(){t=p("div"),n=p("h3"),n.textContent="Curating Configuration",r=m(),s=p("p"),s.textContent="Update curating mode settings. Changes will publish a new configuration event.",o=m(),a=p("div"),l=p("h4"),l.textContent="Allowed Event Kinds",h=m(),g=p("div");for(let e=0;e<Z.length;e+=1)Z[e].c();v=m(),w=p("div"),k=p("label"),k.textContent="Custom Kinds",C=m(),E=p("input"),x=m(),S=p("div"),B=p("h4"),B.textContent="Rate Limiting",Q=m(),F=p("div"),D=p("div"),$=p("label"),$.textContent="Daily Event Limit",P=m(),R=p("input"),T=m(),U=p("div"),_=p("div"),N=p("label"),N.textContent="First Ban (hours)",L=m(),O=p("input"),M=m(),j=p("div"),H=p("label"),H.textContent="Second+ Ban (hours)",G=m(),J=p("input"),K=m(),V=p("div"),q=p("button"),te.c(),b(n,"class","svelte-vbat7g"),b(s,"class","help-text svelte-vbat7g"),b(l,"class","svelte-vbat7g"),b(g,"class","category-grid svelte-vbat7g"),b(k,"for","custom-kinds-edit"),b(k,"class","svelte-vbat7g"),b(E,"id","custom-kinds-edit"),b(E,"type","text"),b(E,"placeholder","e.g., 100, 200-250, 500"),b(E,"class","svelte-vbat7g"),b(w,"class","custom-kinds svelte-vbat7g"),b(a,"class","config-section svelte-vbat7g"),b(B,"class","svelte-vbat7g"),b($,"for","daily-limit-edit"),b($,"class","svelte-vbat7g"),b(R,"id","daily-limit-edit"),b(R,"type","number"),b(R,"min","1"),b(R,"class","svelte-vbat7g"),b(D,"class","form-group svelte-vbat7g"),b(F,"class","form-row svelte-vbat7g"),b(N,"for","first-ban-edit"),b(N,"class","svelte-vbat7g"),b(O,"id","first-ban-edit"),b(O,"type","number"),b(O,"min","1"),b(O,"class","svelte-vbat7g"),b(_,"class","form-group svelte-vbat7g"),b(H,"for","second-ban-edit"),b(H,"class","svelte-vbat7g"),b(J,"id","second-ban-edit"),b(J,"type","number"),b(J,"min","1"),b(J,"class","svelte-vbat7g"),b(j,"class","form-group svelte-vbat7g"),b(U,"class","form-row svelte-vbat7g"),b(S,"class","config-section svelte-vbat7g"),b(q,"class","publish-btn svelte-vbat7g"),q.disabled=e[1],b(V,"class","publish-section svelte-vbat7g"),b(t,"class","section svelte-vbat7g")},m(i,d){u(i,t,d),c(t,n),c(t,r),c(t,s),c(t,o),c(t,a),c(a,l),c(a,h),c(a,g);for(let e=0;e<Z.length;e+=1)Z[e]&&Z[e].m(g,null);c(a,v),c(a,w),c(w,k),c(w,C),c(w,E),I(E,e[5].custom_kinds),c(t,x),c(t,S),c(S,B),c(S,Q),c(S,F),c(F,D),c(D,$),c(D,P),c(D,R),I(R,e[5].daily_limit),c(S,T),c(S,U),c(U,_),c(_,N),c(_,L),c(_,O),I(O,e[5].first_ban_hours),c(U,M),c(U,j),c(j,H),c(j,G),c(j,J),I(J,e[5].second_ban_hours),c(t,K),c(t,V),c(V,q),te.m(q,null),Y||(W=[y(E,"input",e[56]),y(R,"input",e[57]),y(O,"input",e[58]),y(J,"input",e[59]),y(q,"click",e[28])],Y=!0)},p(e,t){if(67108896&t[0]){let n;for(z=Xv,n=0;n<z.length;n+=1){const i=ey(e,z,n);Z[n]?Z[n].p(i,t):(Z[n]=Uy(i),Z[n].c(),Z[n].m(g,null))}for(;n<Z.length;n+=1)Z[n].d(1);Z.length=z.length}32&t[0]&&E.value!==e[5].custom_kinds&&I(E,e[5].custom_kinds),32&t[0]&&A(R.value)!==e[5].daily_limit&&I(R,e[5].daily_limit),32&t[0]&&A(O.value)!==e[5].first_ban_hours&&I(O,e[5].first_ban_hours),32&t[0]&&A(J.value)!==e[5].second_ban_hours&&I(J,e[5].second_ban_hours),ee!==(ee=X(e))&&(te.d(1),te=ee(e),te&&(te.c(),te.m(q,null))),2&t[0]&&(q.disabled=e[1])},d(e){e&&d(t),f(Z,e),te.d(),Y=!1,i(W)}}}function Uy(e){let t,n,i,r,s,o,a,l,f,h,v,w,A,k,I=e[68].name+"",C=e[68].kinds.join(", ")+"";function E(){return e[55](e[68])}return{c(){t=p("label"),n=p("input"),r=m(),s=p("div"),o=p("span"),a=g(I),l=m(),f=p("span"),h=g("Kinds: "),v=g(C),w=m(),b(n,"type","checkbox"),n.checked=i=e[5].categories.includes(e[68].id),b(n,"class","svelte-vbat7g"),b(o,"class","category-name svelte-vbat7g"),b(f,"class","category-kinds svelte-vbat7g"),b(s,"class","category-info svelte-vbat7g"),b(t,"class","category-item svelte-vbat7g"),S(t,"selected",e[5].categories.includes(e[68].id))},m(e,i){u(e,t,i),c(t,n),c(t,r),c(t,s),c(s,o),c(o,a),c(s,l),c(s,f),c(f,h),c(f,v),c(t,w),A||(k=y(n,"change",E),A=!0)},p(r,s){e=r,32&s[0]&&i!==(i=e[5].categories.includes(e[68].id))&&(n.checked=i),32&s[0]&&S(t,"selected",e[5].categories.includes(e[68].id))},d(e){e&&d(t),A=!1,k()}}}function _y(e){let t;return{c(){t=g("Update Configuration")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Ny(e){let t;return{c(){t=g("Updating...")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Ly(e){let t,n,i,r,s,o,a,l,f,h,v,w,A,k,I,C,E,x=e[68].name+"",B=e[68].description+"",Q=e[68].kinds.join(", ")+"";function F(){return e[31](e[68])}return{c(){t=p("label"),n=p("input"),r=m(),s=p("div"),o=p("span"),a=g(x),l=m(),f=p("span"),h=g(B),v=m(),w=p("span"),A=g("Kinds: "),k=g(Q),I=m(),b(n,"type","checkbox"),n.checked=i=e[5].categories.includes(e[68].id),b(n,"class","svelte-vbat7g"),b(o,"class","category-name svelte-vbat7g"),b(f,"class","category-desc svelte-vbat7g"),b(w,"class","category-kinds svelte-vbat7g"),b(s,"class","category-info svelte-vbat7g"),b(t,"class","category-item svelte-vbat7g"),S(t,"selected",e[5].categories.includes(e[68].id))},m(e,i){u(e,t,i),c(t,n),c(t,r),c(t,s),c(s,o),c(o,a),c(s,l),c(s,f),c(f,h),c(s,v),c(s,w),c(w,A),c(w,k),c(t,I),C||(E=y(n,"change",F),C=!0)},p(r,s){e=r,32&s[0]&&i!==(i=e[5].categories.includes(e[68].id))&&(n.checked=i),32&s[0]&&S(t,"selected",e[5].categories.includes(e[68].id))},d(e){e&&d(t),C=!1,E()}}}function Oy(e){let t;return{c(){t=g("Publish Configuration")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function My(e){let t;return{c(){t=g("Publishing...")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function jy(t){let n,i,r,s,o=t[2]&&ay(t);function a(e,t){return e[4]?ly:cy}let l=a(t),f=l(t);return{c(){n=p("div"),i=p("h2"),i.textContent="Curation Mode",r=m(),o&&o.c(),s=m(),f.c(),b(i,"class","svelte-vbat7g"),b(n,"class","curation-view svelte-vbat7g")},m(e,t){u(e,n,t),c(n,i),c(n,r),o&&o.m(n,null),c(n,s),f.m(n,null)},p(e,t){e[2]?o?o.p(e,t):(o=ay(e),o.c(),o.m(n,s)):o&&(o.d(1),o=null),l===(l=a(e))&&f?f.p(e,t):(f.d(1),f=l(e),f&&(f.c(),f.m(n,null)))},i:e,o:e,d(e){e&&d(n),o&&o.d(),f.d()}}}function Hy(e){return!e||e.length<16?e:`${e.slice(0,8)}...${e.slice(-8)}`}function Gy(e){return e?new Date(e).toLocaleString():""}function Jy(e,t,n){let{userSigner:i}=t,{userPubkey:r}=t,s="trusted",o=!1,a="",l="info",c=!1,u={daily_limit:50,first_ban_hours:1,second_ban_hours:168,categories:[],custom_kinds:"",kind_ranges:[]},d=[],f="",p="",h=[],g="",m="",v=[],y=[],w=[];async function b(e,t=[]){try{n(1,o=!0),n(2,a="");const s={method:e,params:t},l=await async function(e,t){if(!i)throw new Error("No signer available. Please log in with a Nostr extension.");if(!r)throw new Error("No user pubkey available.");const n=window.location.origin+t,s={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",n],["method",e]],content:"",pubkey:r},o=await i.signEvent(s);return`Nostr ${btoa(JSON.stringify(o))}`}("POST","/api/nip86"),c=await fetch("/api/nip86",{method:"POST",headers:{"Content-Type":"application/nostr+json+rpc",Authorization:l},body:JSON.stringify(s)});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(2,a=e.message),n(3,l="error"),e}finally{n(1,o=!1)}}async function k(){await Promise.all([I(),C(),E(),x(),S()])}async function I(){try{n(6,d=await b("listtrustedpubkeys"))}catch(e){console.error("Failed to load trusted pubkeys:",e),n(6,d=[])}}async function C(){try{n(9,h=await b("listblacklistedpubkeys"))}catch(e){console.error("Failed to load blacklisted pubkeys:",e),n(9,h=[])}}async function E(){try{n(12,v=await b("listunclassifiedusers"))}catch(e){console.error("Failed to load unclassified users:",e),n(12,v=[])}}async function x(){try{n(13,y=await b("listspamevents"))}catch(e){console.error("Failed to load spam events:",e),n(13,y=[])}}async function S(){try{n(14,w=await b("listblockedips"))}catch(e){console.error("Failed to load blocked IPs:",e),n(14,w=[])}}async function B(e=null,t=""){const i=e||f,r=e?t:p;if(i)try{await b("trustpubkey",[i,r]),n(2,a="Pubkey trusted successfully"),n(3,l="success"),n(7,f=""),n(8,p=""),await I(),await E()}catch(e){console.error("Failed to trust pubkey:",e)}}async function Q(e){try{await b("untrustpubkey",[e]),n(2,a="Pubkey untrusted"),n(3,l="success"),await I()}catch(e){console.error("Failed to untrust pubkey:",e)}}async function F(e=null,t=""){const i=e||g,r=e?t:m;if(i)try{await b("blacklistpubkey",[i,r]),n(2,a="Pubkey blacklisted"),n(3,l="success"),n(10,g=""),n(11,m=""),await C(),await E()}catch(e){console.error("Failed to blacklist pubkey:",e)}}async function $(e){try{await b("unblacklistpubkey",[e]),n(2,a="Pubkey removed from blacklist"),n(3,l="success"),await C()}catch(e){console.error("Failed to remove from blacklist:",e)}}async function P(e){try{await b("unmarkspam",[e]),n(2,a="Spam mark removed"),n(3,l="success"),await x()}catch(e){console.error("Failed to unmark spam:",e)}}async function R(e){if(confirm("Permanently delete this event?"))try{await b("deleteevent",[e]),n(2,a="Event deleted"),n(3,l="success"),await x()}catch(e){console.error("Failed to delete event:",e)}}async function T(e){try{await b("unblockip",[e]),n(2,a="IP unblocked"),n(3,l="success"),await S()}catch(e){console.error("Failed to unblock IP:",e)}}function U(e){u.categories.includes(e)?n(5,u.categories=u.categories.filter(t=>t!==e),u):n(5,u.categories=[...u.categories,e],u)}async function _(){if(!i||!r)return n(2,a="Please log in with a Nostr extension to publish configuration"),void n(3,l="error");if(0===u.categories.length&&!u.custom_kinds.trim())return n(2,a="Please select at least one kind category or enter custom kinds"),void n(3,l="error");try{n(1,o=!0),n(2,a="");const e=[["d","curating-config"],["daily_limit",String(u.daily_limit)],["first_ban_hours",String(u.first_ban_hours)],["second_ban_hours",String(u.second_ban_hours)]];for(const t of u.categories)e.push(["kind_category",t]);const t=function(e){if(!e||!e.trim())return[];const t=new Set,n=e.split(",").map(e=>e.trim());for(const e of n)if(e)if(e.includes("-")){const[n,i]=e.split("-").map(e=>parseInt(e.trim(),10));if(!isNaN(n)&&!isNaN(i)&&n<=i&&i-n<=1e3)for(let e=n;e<=i;e++)t.add(e)}else{const n=parseInt(e,10);isNaN(n)||t.add(n)}return Array.from(t).sort((e,t)=>e-t)}(u.custom_kinds);for(const n of t)e.push(["kind",String(n)]);const s={kind:30078,created_at:Math.floor(Date.now()/1e3),tags:e,content:"Curating relay configuration",pubkey:r},d=await i.signEvent(s),f=new WebSocket(window.location.origin.replace(/^http/,"ws"));await new Promise((e,t)=>{f.onopen=()=>{f.send(JSON.stringify(["EVENT",d]))},f.onmessage=n=>{const i=JSON.parse(n.data);"OK"===i[0]&&(!0===i[2]?e():t(new Error(i[3]||"Event rejected")))},f.onerror=e=>t(new Error("WebSocket error")),setTimeout(()=>t(new Error("Timeout")),1e4)}),f.close(),n(2,a="Configuration published successfully"),n(3,l="success"),n(4,c=!0),await k()}catch(e){console.error("Failed to publish configuration:",e),n(2,a=`Failed to publish: ${e.message}`),n(3,l="error")}finally{n(1,o=!1)}}D(async()=>{await async function(){try{const e=await b("isconfigured");n(4,c=!0===e),c&&(await async function(){try{const e=await b("getcuratingconfig");e&&n(5,u={daily_limit:e.daily_limit||50,first_ban_hours:e.first_ban_hours||1,second_ban_hours:e.second_ban_hours||168,categories:e.categories||[],custom_kinds:e.custom_kinds?e.custom_kinds.join(", "):"",kind_ranges:e.kind_ranges||[]})}catch(e){console.error("Failed to load config:",e)}}(),await k())}catch(e){console.error("Failed to check configuration:",e),n(4,c=!1)}}()});return e.$$set=e=>{"userSigner"in e&&n(29,i=e.userSigner),"userPubkey"in e&&n(30,r=e.userPubkey)},[s,o,a,l,c,u,d,f,p,h,g,m,v,y,w,E,async function(){try{const e=await b("scanpubkeys");showMessage(`Database scanned: ${e.total_pubkeys} pubkeys, ${e.total_events} events (${e.skipped} skipped)`,"success"),await E()}catch(e){console.error("Failed to scan database:",e),showMessage("Failed to scan database: "+e.message,"error")}},x,S,B,Q,F,$,P,R,T,U,_,async function(){await _()},i,r,e=>U(e.id),function(){u.custom_kinds=this.value,n(5,u)},function(){u.daily_limit=A(this.value),n(5,u)},function(){u.first_ban_hours=A(this.value),n(5,u)},function(){u.second_ban_hours=A(this.value),n(5,u)},()=>n(0,s="trusted"),()=>n(0,s="blacklist"),()=>n(0,s="unclassified"),()=>n(0,s="spam"),()=>n(0,s="ips"),()=>n(0,s="settings"),function(){f=this.value,n(7,f)},function(){p=this.value,n(8,p)},()=>B(),e=>Q(e.pubkey),function(){g=this.value,n(10,g)},function(){m=this.value,n(11,m)},()=>F(),e=>$(e.pubkey),e=>B(e.pubkey,""),e=>F(e.pubkey,""),e=>P(e.event_id),e=>R(e.event_id),e=>T(e.ip),e=>U(e.id),function(){u.custom_kinds=this.value,n(5,u)},function(){u.daily_limit=A(this.value),n(5,u)},function(){u.first_ban_hours=A(this.value),n(5,u)},function(){u.second_ban_hours=A(this.value),n(5,u)}]}class Ky extends se{constructor(e){super(),re(this,e,Jy,jy,s,{userSigner:29,userPubkey:30},null,[-1,-1,-1])}}const{window:Vy}=l;function qy(e,t,n){const i=e.slice();return i[57]=t[n],i}function Yy(e,t,n){const i=e.slice();return i[54]=t[n],i}function Wy(t){let n,i,r,s,o,a;return{c(){n=p("div"),i=p("p"),i.textContent="Please log in to view your Blossom storage.",r=m(),s=p("button"),s.textContent="Log In",b(i,"class","svelte-on0yal"),b(s,"class","login-btn svelte-on0yal"),b(n,"class","login-prompt svelte-on0yal")},m(e,l){u(e,n,l),c(n,i),c(n,r),c(n,s),o||(a=y(s,"click",t[20]),o=!0)},p:e,d(e){e&&d(n),o=!1,a()}}}function zy(e){let t,n,i,r,s,o,a,l,f,h,v,w,A,I,C=e[0]||e[12]?"Loading...":"Refresh";function E(e,t){return e[13]?ew:e[10]?Xy:Zy}let x=E(e),S=x(e),B=e[14]&&!e[10]&&!e[13]&&nw(e),Q=!e[10]&&!e[13]&&iw(e),F=e[2]&&sw(e);function D(e,t){return e[10]&&!e[13]?aw:ow}let $=D(e),P=$(e);return{c(){t=p("div"),n=p("div"),S.c(),i=m(),r=p("div"),B&&B.c(),s=m(),o=p("button"),a=g("🔄 "),l=g(C),h=m(),Q&&Q.c(),v=m(),F&&F.c(),w=m(),P.c(),b(o,"class","refresh-btn svelte-on0yal"),o.disabled=f=e[0]||e[12],b(r,"class","header-buttons svelte-on0yal"),b(n,"class","header-section svelte-on0yal"),b(t,"class","blossom-view svelte-on0yal")},m(d,f){u(d,t,f),c(t,n),S.m(n,null),c(n,i),c(n,r),B&&B.m(r,null),c(r,s),c(r,o),c(o,a),c(o,l),c(t,h),Q&&Q.m(t,null),c(t,v),F&&F.m(t,null),c(t,w),P.m(t,null),A||(I=y(o,"click",e[30]),A=!0)},p(e,a){x===(x=E(e))&&S?S.p(e,a):(S.d(1),S=x(e),S&&(S.c(),S.m(n,i))),!e[14]||e[10]||e[13]?B&&(B.d(1),B=null):B?B.p(e,a):(B=nw(e),B.c(),B.m(r,s)),4097&a[0]&&C!==(C=e[0]||e[12]?"Loading...":"Refresh")&&k(l,C),4097&a[0]&&f!==(f=e[0]||e[12])&&(o.disabled=f),e[10]||e[13]?Q&&(Q.d(1),Q=null):Q?Q.p(e,a):(Q=iw(e),Q.c(),Q.m(t,v)),e[2]?F?F.p(e,a):(F=sw(e),F.c(),F.m(t,w)):F&&(F.d(1),F=null),$===($=D(e))&&P?P.p(e,a):(P.d(1),P=$(e),P&&(P.c(),P.m(t,null)))},d(e){e&&d(t),S.d(),B&&B.d(),Q&&Q.d(),F&&F.d(),P.d(),A=!1,I()}}}function Zy(t){let n;return{c(){n=p("h3"),n.textContent="Blossom Media Storage",b(n,"class","svelte-on0yal")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Xy(t){let n,i,r,s,o;return{c(){n=p("button"),n.textContent="← Back",i=m(),r=p("h3"),r.textContent="All Users Storage",b(n,"class","back-btn svelte-on0yal"),b(r,"class","svelte-on0yal")},m(e,a){u(e,n,a),u(e,i,a),u(e,r,a),s||(o=y(n,"click",t[27]),s=!0)},p:e,d(e){e&&d(n),e&&d(i),e&&d(r),s=!1,o()}}}function ew(e){let t,n,i,r,s,o,a,l=(e[13].profile?.name||_w(e[25](e[13].pubkey)))+"",f=e[13].profile?.picture&&tw(e);return{c(){t=p("button"),t.textContent="← Back",n=m(),i=p("h3"),f&&f.c(),r=m(),s=g(l),b(t,"class","back-btn svelte-on0yal"),b(i,"class","user-header svelte-on0yal")},m(l,d){u(l,t,d),u(l,n,d),u(l,i,d),f&&f.m(i,null),c(i,r),c(i,s),o||(a=y(t,"click",e[29]),o=!0)},p(e,t){e[13].profile?.picture?f?f.p(e,t):(f=tw(e),f.c(),f.m(i,r)):f&&(f.d(1),f=null),8192&t[0]&&l!==(l=(e[13].profile?.name||_w(e[25](e[13].pubkey)))+"")&&k(s,l)},d(e){e&&d(t),e&&d(n),e&&d(i),f&&f.d(),o=!1,a()}}}function tw(e){let t,n;return{c(){t=p("img"),a(t.src,n=e[13].profile.picture)||b(t,"src",n),b(t,"alt",""),b(t,"class","header-avatar svelte-on0yal")},m(e,n){u(e,t,n)},p(e,i){8192&i[0]&&!a(t.src,n=e[13].profile.picture)&&b(t,"src",n)},d(e){e&&d(t)}}}function nw(e){let t,n,i,r;return{c(){t=p("button"),n=g("Admin"),b(t,"class","admin-btn svelte-on0yal"),t.disabled=e[0]},m(s,o){u(s,t,o),c(t,n),i||(r=y(t,"click",e[26]),i=!0)},p(e,n){1&n[0]&&(t.disabled=e[0])},d(e){e&&d(t),i=!1,r()}}}function iw(e){let t,n,r,s,o,a,l,f,h,v,w=e[3].length>0&&rw(e);return{c(){t=p("div"),n=p("span"),n.textContent="Upload new files",r=m(),s=p("input"),o=m(),w&&w.c(),a=m(),l=p("button"),f=g("Select Files"),b(n,"class","upload-label svelte-on0yal"),b(s,"type","file"),s.multiple=!0,b(s,"class","file-input-hidden svelte-on0yal"),b(l,"class","select-btn svelte-on0yal"),l.disabled=e[4],b(t,"class","upload-section svelte-on0yal")},m(i,d){u(i,t,d),c(t,n),c(t,r),c(t,s),e[39](s),c(t,o),w&&w.m(t,null),c(t,a),c(t,l),c(l,f),h||(v=[y(s,"change",e[22]),y(l,"click",e[23])],h=!0)},p(e,n){e[3].length>0?w?w.p(e,n):(w=rw(e),w.c(),w.m(t,a)):w&&(w.d(1),w=null),16&n[0]&&(l.disabled=e[4])},d(n){n&&d(t),e[39](null),w&&w.d(),h=!1,i(v)}}}function rw(e){let t,n,i,r,s,o,a,l,f=e[3].length+"",h=(e[4]?e[5]:"Upload")+"";return{c(){t=p("span"),n=g(f),i=g(" file(s) selected"),r=m(),s=p("button"),o=g(h),b(t,"class","selected-count svelte-on0yal"),b(s,"class","upload-btn svelte-on0yal"),s.disabled=e[4]},m(d,f){u(d,t,f),c(t,n),c(t,i),u(d,r,f),u(d,s,f),c(s,o),a||(l=y(s,"click",e[24]),a=!0)},p(e,t){8&t[0]&&f!==(f=e[3].length+"")&&k(n,f),48&t[0]&&h!==(h=(e[4]?e[5]:"Upload")+"")&&k(o,h),16&t[0]&&(s.disabled=e[4])},d(e){e&&d(t),e&&d(r),e&&d(s),a=!1,l()}}}function sw(e){let t,n;return{c(){t=p("div"),n=g(e[2]),b(t,"class","error-message svelte-on0yal")},m(e,i){u(e,t,i),c(t,n)},p(e,t){4&t[0]&&k(n,e[2])},d(e){e&&d(t)}}}function ow(e){let t,n,i;function r(e,i){return 1&i[0]&&(t=null),null==t&&(t=!(!e[0]||0!==e[31]().length)),t?uw:(null==n&&(n=!(0!==e[31]().length)),n?cw:lw)}let s=r(e,[-1,-1]),o=s(e);return{c(){o.c(),i=v()},m(e,t){o.m(e,t),u(e,i,t)},p(e,t){s===(s=r(e,t))&&o?o.p(e,t):(o.d(1),o=s(e),o&&(o.c(),o.m(i.parentNode,i)))},d(e){o.d(e),e&&d(i)}}}function aw(e){let t;function n(e,t){return e[12]?vw:0===e[11].length?mw:gw}let i=n(e),r=i(e);return{c(){r.c(),t=v()},m(e,n){r.m(e,n),u(e,t,n)},p(e,s){i===(i=n(e))&&r?r.p(e,s):(r.d(1),r=i(e),r&&(r.c(),r.m(t.parentNode,t)))},d(e){r.d(e),e&&d(t)}}}function lw(e){let t,n=e[31](),i=[];for(let t=0;t<n.length;t+=1)i[t]=hw(qy(e,n,t));return{c(){t=p("div");for(let e=0;e<i.length;e+=1)i[e].c();b(t,"class","blob-list svelte-on0yal")},m(e,n){u(e,t,n);for(let e=0;e<i.length;e+=1)i[e]&&i[e].m(t,null)},p(e,r){if(2129920&r[0]|1&r[1]){let s;for(n=e[31](),s=0;s<n.length;s+=1){const o=qy(e,n,s);i[s]?i[s].p(o,r):(i[s]=hw(o),i[s].c(),i[s].m(t,null))}for(;s<i.length;s+=1)i[s].d(1);i.length=n.length}},d(e){e&&d(t),f(i,e)}}}function cw(e){let t,n,i,r=e[13]?"No files found for this user.":"No files found in your Blossom storage.";return{c(){t=p("div"),n=p("p"),i=g(r),b(t,"class","empty-state svelte-on0yal")},m(e,r){u(e,t,r),c(t,n),c(n,i)},p(e,t){8192&t[0]&&r!==(r=e[13]?"No files found for this user.":"No files found in your Blossom storage.")&&k(i,r)},d(e){e&&d(t)}}}function uw(t){let n;return{c(){n=p("div"),n.textContent="Loading blobs...",b(n,"class","loading svelte-on0yal")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function dw(t){let n,i,r=Tw(t[57].type)+"";return{c(){n=p("span"),i=g(r),b(n,"class","thumbnail-icon svelte-on0yal")},m(e,t){u(e,n,t),c(n,i)},p:e,d(e){e&&d(n)}}}function fw(t){let n,i;return{c(){n=p("video"),a(n.src,i=Uw(t[57]))||b(n,"src",i),b(n,"class","thumbnail-video svelte-on0yal"),n.muted=!0,b(n,"preload","metadata")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function pw(t){let n,i;return{c(){n=p("img"),a(n.src,i=Uw(t[57]))||b(n,"src",i),b(n,"alt",""),b(n,"class","thumbnail-img svelte-on0yal")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function hw(e){let t,n,r,s,o,a,l,f,h,v,A,k,I,C,E,x,S,B,Q,F,D,$,P,R,T,U=e[57].sha256+"",_=Pw(e[57].sha256)+"",N=Dw(e[57].size)+"",L=(e[57].type||"unknown")+"",O=$w(e[57].uploaded)+"";let M=function(e){return"image"===Rw(e[57].type)?pw:"video"===Rw(e[57].type)?fw:dw}(e),j=M(e);function H(){return e[42](e[57])}function G(){return e[43](e[57])}function J(...t){return e[44](e[57],...t)}return{c(){t=p("div"),n=p("div"),j.c(),r=m(),s=p("div"),o=p("div"),a=p("span"),l=g(U),f=m(),h=p("span"),v=g(_),A=m(),k=p("div"),I=p("span"),C=g(N),E=m(),x=p("span"),S=g(L),B=m(),Q=p("div"),F=g(O),D=m(),$=p("button"),$.textContent="X",P=m(),b(n,"class","blob-thumbnail svelte-on0yal"),b(a,"class","hash-full svelte-on0yal"),b(h,"class","hash-truncated svelte-on0yal"),b(o,"class","blob-hash svelte-on0yal"),b(o,"title",e[57].sha256),b(I,"class","blob-size"),b(x,"class","blob-type"),b(k,"class","blob-meta svelte-on0yal"),b(s,"class","blob-info svelte-on0yal"),b(Q,"class","blob-date svelte-on0yal"),b($,"class","delete-btn svelte-on0yal"),b($,"title","Delete"),b(t,"class","blob-item svelte-on0yal"),b(t,"role","button"),b(t,"tabindex","0")},m(e,i){u(e,t,i),c(t,n),j.m(n,null),c(t,r),c(t,s),c(s,o),c(o,a),c(a,l),c(o,f),c(o,h),c(h,v),c(s,A),c(s,k),c(k,I),c(I,C),c(k,E),c(k,x),c(x,S),c(t,B),c(t,Q),c(Q,F),c(t,D),c(t,$),c(t,P),R||(T=[y($,"click",w(H)),y(t,"click",G),y(t,"keypress",J)],R=!0)},p(t,n){e=t,j.p(e,n)},d(e){e&&d(t),j.d(),R=!1,i(T)}}}function gw(e){let t,n=e[11],i=[];for(let t=0;t<n.length;t+=1)i[t]=bw(Yy(e,n,t));return{c(){t=p("div");for(let e=0;e<i.length;e+=1)i[e].c();b(t,"class","admin-users-list svelte-on0yal")},m(e,n){u(e,t,n);for(let e=0;e<i.length;e+=1)i[e]&&i[e].m(t,null)},p(e,r){if(301991936&r[0]){let s;for(n=e[11],s=0;s<n.length;s+=1){const o=Yy(e,n,s);i[s]?i[s].p(o,r):(i[s]=bw(o),i[s].c(),i[s].m(t,null))}for(;s<i.length;s+=1)i[s].d(1);i.length=n.length}},d(e){e&&d(t),f(i,e)}}}function mw(t){let n;return{c(){n=p("div"),n.innerHTML="<p>No users have uploaded files yet.</p>",b(n,"class","empty-state svelte-on0yal")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function vw(t){let n;return{c(){n=p("div"),n.textContent="Loading user statistics...",b(n,"class","loading svelte-on0yal")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function yw(t){let n;return{c(){n=p("div"),b(n,"class","user-avatar-placeholder svelte-on0yal")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function ww(e){let t,n;return{c(){t=p("img"),a(t.src,n=e[54].profile.picture)||b(t,"src",n),b(t,"alt",""),b(t,"class","user-avatar svelte-on0yal")},m(e,n){u(e,t,n)},p(e,i){2048&i[0]&&!a(t.src,n=e[54].profile.picture)&&b(t,"src",n)},d(e){e&&d(t)}}}function bw(e){let t,n,r,s,o,a,l,f,h,v,w,A,I,C,E,x,S,B,Q,F,D,$,P,R,T,U=(e[54].profile?.name||_w(e[25](e[54].pubkey)))+"",_=e[25](e[54].pubkey)+"",N=_w(e[25](e[54].pubkey))+"",L=e[54].blob_count+"",O=Dw(e[54].total_size_bytes)+"";function M(e,t){return e[54].profile?.picture?ww:yw}let j=M(e),H=j(e);function G(){return e[40](e[54])}function J(...t){return e[41](e[54],...t)}return{c(){t=p("div"),n=p("div"),H.c(),r=m(),s=p("div"),o=p("div"),a=g(U),l=m(),f=p("div"),h=p("span"),v=g(_),w=m(),A=p("span"),I=g(N),E=m(),x=p("div"),S=p("span"),B=g(L),Q=g(" files"),F=m(),D=p("span"),$=g(O),P=m(),b(n,"class","user-avatar-container svelte-on0yal"),b(o,"class","user-name svelte-on0yal"),b(h,"class","npub-full svelte-on0yal"),b(A,"class","npub-truncated svelte-on0yal"),b(f,"class","user-npub svelte-on0yal"),b(f,"title",C=e[54].pubkey),b(s,"class","user-info svelte-on0yal"),b(S,"class","blob-count svelte-on0yal"),b(D,"class","total-size svelte-on0yal"),b(x,"class","user-stats svelte-on0yal"),b(t,"class","user-stat-item svelte-on0yal"),b(t,"role","button"),b(t,"tabindex","0")},m(e,i){u(e,t,i),c(t,n),H.m(n,null),c(t,r),c(t,s),c(s,o),c(o,a),c(s,l),c(s,f),c(f,h),c(h,v),c(f,w),c(f,A),c(A,I),c(t,E),c(t,x),c(x,S),c(S,B),c(S,Q),c(x,F),c(x,D),c(D,$),c(t,P),R||(T=[y(t,"click",G),y(t,"keypress",J)],R=!0)},p(t,i){j===(j=M(e=t))&&H?H.p(e,i):(H.d(1),H=j(e),H&&(H.c(),H.m(n,null))),2048&i[0]&&U!==(U=(e[54].profile?.name||_w(e[25](e[54].pubkey)))+"")&&k(a,U),2048&i[0]&&_!==(_=e[25](e[54].pubkey)+"")&&k(v,_),2048&i[0]&&N!==(N=_w(e[25](e[54].pubkey))+"")&&k(I,N),2048&i[0]&&C!==(C=e[54].pubkey)&&b(f,"title",C),2048&i[0]&&L!==(L=e[54].blob_count+"")&&k(B,L),2048&i[0]&&O!==(O=Dw(e[54].total_size_bytes)+"")&&k($,O)},d(e){e&&d(t),H.d(),R=!1,i(T)}}}function Aw(e){let t,n,r,s,o,a,l,f,h,v,A,I,C,E,x,S,B,Q,F,D,$,P,R,T,U,_,N,L,O,M,j,H,G,J,K,V,q,Y,W,z,Z,X,ee,te=Pw(e[8].sha256)+"",ne=(e[8].type||"unknown")+"",ie="image"===Rw(e[8].type),re=Dw(e[8].size)+"",se=$w(e[8].uploaded)+"",oe=ie&&kw(e);function ae(e,t){return 256&t[0]&&(S=null),256&t[0]&&(B=null),256&t[0]&&(Q=null),null==S&&(S=!("image"!==Rw(e[8].type))),S?xw:(null==B&&(B=!("video"!==Rw(e[8].type))),B?Ew:(null==Q&&(Q=!("audio"!==Rw(e[8].type))),Q?Cw:Iw))}let le=ae(e,[-1,-1]),ce=le(e);return{c(){t=p("div"),n=p("div"),r=p("div"),s=p("div"),o=p("span"),a=g(te),l=m(),f=p("span"),h=g(ne),v=m(),A=p("div"),oe&&oe.c(),I=m(),C=p("button"),C.textContent="X",E=m(),x=p("div"),ce.c(),F=m(),D=p("div"),$=p("div"),P=p("span"),R=g("Size: "),T=g(re),U=m(),_=p("span"),N=g("Uploaded: "),L=g(se),O=m(),M=p("div"),j=p("input"),G=m(),J=p("button"),J.textContent="Copy",K=m(),V=p("div"),q=p("a"),Y=g("Open in New Tab"),z=m(),Z=p("button"),Z.textContent="Delete",b(o,"class","modal-hash svelte-on0yal"),b(f,"class","modal-type svelte-on0yal"),b(s,"class","modal-title svelte-on0yal"),b(C,"class","close-btn svelte-on0yal"),b(A,"class","modal-controls svelte-on0yal"),b(r,"class","modal-header svelte-on0yal"),b(x,"class","modal-body svelte-on0yal"),b($,"class","blob-details svelte-on0yal"),b(j,"type","text"),j.readOnly=!0,j.value=H=Uw(e[8]),b(j,"class","blob-url-input svelte-on0yal"),b(J,"class","copy-btn svelte-on0yal"),b(M,"class","blob-url-section svelte-on0yal"),b(q,"href",W=Uw(e[8])),b(q,"target","_blank"),b(q,"rel","noopener noreferrer"),b(q,"class","action-btn svelte-on0yal"),b(Z,"class","action-btn danger svelte-on0yal"),b(V,"class","modal-actions svelte-on0yal"),b(D,"class","modal-footer svelte-on0yal"),b(n,"class","modal-content svelte-on0yal"),b(n,"role","dialog"),b(t,"class","modal-overlay svelte-on0yal"),b(t,"role","button"),b(t,"tabindex","0")},m(i,d){u(i,t,d),c(t,n),c(n,r),c(r,s),c(s,o),c(o,a),c(s,l),c(s,f),c(f,h),c(r,v),c(r,A),oe&&oe.m(A,null),c(A,I),c(A,C),c(n,E),c(n,x),ce.m(x,null),c(n,F),c(n,D),c(D,$),c($,P),c(P,R),c(P,T),c($,U),c($,_),c(_,N),c(_,L),c(D,O),c(D,M),c(M,j),c(M,G),c(M,J),c(D,K),c(D,V),c(V,q),c(q,Y),c(V,z),c(V,Z),X||(ee=[y(C,"click",e[16]),y(j,"click",Nw),y(J,"click",e[45]),y(Z,"click",e[46]),y(n,"click",w(e[37])),y(n,"keypress",w(e[38])),y(t,"click",e[16]),y(t,"keypress",e[47])],X=!0)},p(e,t){256&t[0]&&te!==(te=Pw(e[8].sha256)+"")&&k(a,te),256&t[0]&&ne!==(ne=(e[8].type||"unknown")+"")&&k(h,ne),256&t[0]&&(ie="image"===Rw(e[8].type)),ie?oe?oe.p(e,t):(oe=kw(e),oe.c(),oe.m(A,I)):oe&&(oe.d(1),oe=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]&&re!==(re=Dw(e[8].size)+"")&&k(T,re),256&t[0]&&se!==(se=$w(e[8].uploaded)+"")&&k(L,se),256&t[0]&&H!==(H=Uw(e[8]))&&j.value!==H&&(j.value=H),256&t[0]&&W!==(W=Uw(e[8]))&&b(q,"href",W)},d(e){e&&d(t),oe&&oe.d(),ce.d(),X=!1,i(ee)}}}function kw(e){let t,n,r,s,o,a,l,f,h,v,w,A,I,C=Math.round(100*e[9])+"";return{c(){t=p("button"),n=g("-"),s=m(),o=p("span"),a=g(C),l=g("%"),f=m(),h=p("button"),v=g("+"),b(t,"class","zoom-btn svelte-on0yal"),t.disabled=r=e[9]<=Bw,b(o,"class","zoom-level svelte-on0yal"),b(h,"class","zoom-btn svelte-on0yal"),h.disabled=w=e[9]>=Qw},m(i,r){u(i,t,r),c(t,n),u(i,s,r),u(i,o,r),c(o,a),c(o,l),u(i,f,r),u(i,h,r),c(h,v),A||(I=[y(t,"click",e[18]),y(h,"click",e[17])],A=!0)},p(e,n){512&n[0]&&r!==(r=e[9]<=Bw)&&(t.disabled=r),512&n[0]&&C!==(C=Math.round(100*e[9])+"")&&k(a,C),512&n[0]&&w!==(w=e[9]>=Qw)&&(h.disabled=w)},d(e){e&&d(t),e&&d(s),e&&d(o),e&&d(f),e&&d(h),A=!1,i(I)}}}function Iw(e){let t,n,i,r,s,o,a,l,f,h=Tw(e[8].type)+"";return{c(){t=p("div"),n=p("div"),i=g(h),r=m(),s=p("p"),s.textContent="Preview not available for this file type.",o=m(),a=p("a"),l=g("Download File"),b(n,"class","file-icon svelte-on0yal"),b(a,"href",f=Uw(e[8])),b(a,"target","_blank"),b(a,"rel","noopener noreferrer"),b(a,"class","download-link svelte-on0yal"),b(t,"class","file-preview svelte-on0yal")},m(e,d){u(e,t,d),c(t,n),c(n,i),c(t,r),c(t,s),c(t,o),c(t,a),c(a,l)},p(e,t){256&t[0]&&h!==(h=Tw(e[8].type)+"")&&k(i,h),256&t[0]&&f!==(f=Uw(e[8]))&&b(a,"href",f)},d(e){e&&d(t)}}}function Cw(e){let t,n,i;return{c(){t=p("div"),n=p("audio"),n.controls=!0,a(n.src,i=Uw(e[8]))||b(n,"src",i),b(n,"class","svelte-on0yal"),b(t,"class","media-container audio svelte-on0yal")},m(e,i){u(e,t,i),c(t,n)},p(e,t){256&t[0]&&!a(n.src,i=Uw(e[8]))&&b(n,"src",i)},d(e){e&&d(t)}}}function Ew(e){let t,n,i,r;return{c(){t=p("div"),n=p("video"),i=p("track"),b(i,"kind","captions"),n.controls=!0,a(n.src,r=Uw(e[8]))||b(n,"src",r),b(n,"class","svelte-on0yal"),b(t,"class","media-container svelte-on0yal")},m(e,r){u(e,t,r),c(t,n),c(n,i)},p(e,t){256&t[0]&&!a(n.src,r=Uw(e[8]))&&b(n,"src",r)},d(e){e&&d(t)}}}function xw(e){let t,n,i;return{c(){t=p("div"),n=p("img"),a(n.src,i=Uw(e[8]))||b(n,"src",i),b(n,"alt","Blob content"),b(n,"class","svelte-on0yal"),b(t,"class","media-container svelte-on0yal"),C(t,"transform","scale("+e[9]+")")},m(e,i){u(e,t,i),c(t,n)},p(e,r){256&r[0]&&!a(n.src,i=Uw(e[8]))&&b(n,"src",i),512&r[0]&&C(t,"transform","scale("+e[9]+")")},d(e){e&&d(t)}}}function Sw(t){let n,i,r,s;function o(e,t){return e[1]?zy:Wy}let a=o(t),l=a(t),c=t[7]&&t[8]&&Aw(t);return{c(){l.c(),n=m(),c&&c.c(),i=v()},m(e,o){l.m(e,o),u(e,n,o),c&&c.m(e,o),u(e,i,o),r||(s=y(Vy,"keydown",t[19]),r=!0)},p(e,t){a===(a=o(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=Aw(e),c.c(),c.m(i.parentNode,i)):c&&(c.d(1),c=null)},i:e,o:e,d(e){l.d(e),e&&d(n),c&&c.d(e),e&&d(i),r=!1,s()}}}const Bw=.25,Qw=4;async function Fw(e,t,n=null){if(!e)return console.log("No signer available for Blossom auth"),null;try{const i=Math.floor(Date.now()/1e3),r=[["t",t],["expiration",(i+60).toString()]];n&&r.push(["x",n]);const s={kind:24242,created_at:i,tags:r,content:`Blossom ${t} operation`},o=await e.signEvent(s);return btoa(JSON.stringify(o)).replace(/\+/g,"-").replace(/\//g,"_")}catch(e){return console.error("Error creating Blossom auth:",e),null}}function Dw(e){if(!e)return"0 B";const t=["B","KB","MB","GB"];let n=0,i=e;for(;i>=1024&&n<t.length-1;)i/=1024,n++;return`${i.toFixed(0===n?0:1)} ${t[n]}`}function $w(e){return e?new Date(1e3*e).toLocaleString():"Unknown"}function Pw(e){return e?`${e.slice(0,8)}...${e.slice(-8)}`:""}function Rw(e){return e?e.startsWith("image/")?"image":e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":"file":"unknown"}function Tw(e){switch(Rw(e)){case"image":return"🖼️";case"video":return"🎬";case"audio":return"🎵";default:return"📄"}}function Uw(e){return e.url?e.url.startsWith("http://")||e.url.startsWith("https://")?e.url:e.url.startsWith("/")?`${window.location.origin}${e.url}`:`http://${e.url}`:`${window.location.origin}/blossom/${e.sha256}`}function _w(e){return e?`${e.slice(0,12)}...${e.slice(-8)}`:""}const Nw=e=>e.target.select();function Lw(e,t,n){let i,r,{isLoggedIn:s=!1}=t,{userPubkey:o=""}=t,{userSigner:a=null}=t,{currentEffectiveRole:l=""}=t;const c=P();let u,d=[],f=!1,p="",h=[],g=!1,m="",v=!1,y=null,w=1,b=!1,A=[],k=!1,I=null,C=[],E=!1;async function x(){if(o){n(0,f=!0),n(2,p="");try{const e=`${window.location.origin}/blossom/list/${o}`,t=await Fw(a,"list"),n=await fetch(e,{headers:t?{Authorization:`Nostr ${t}`}:{}});if(!n.ok)throw new Error(`Failed to load blobs: ${n.statusText}`);const i=await n.json();d=Array.isArray(i)?i:[],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,p=e.message||"Failed to load blobs")}finally{n(0,f=!1)}}}function S(e){n(8,y=e),n(9,w=1),n(7,v=!0)}function B(){n(7,v=!1),n(8,y=null),n(9,w=1)}function Q(){w<Qw&&n(9,w=Math.min(Qw,w+.25))}function F(){w>Bw&&n(9,w=Math.max(Bw,w-.25))}async function $(e){if(confirm(`Delete blob ${Pw(e.sha256)}?`))try{const t=`${window.location.origin}/blossom/${e.sha256}`,n=await Fw(a,"delete",e.sha256),i=await fetch(t,{method:"DELETE",headers:n?{Authorization:`Nostr ${n}`}:{}});if(!i.ok)throw new Error(`Failed to delete: ${i.statusText}`);d=d.filter(t=>t.sha256!==e.sha256),y?.sha256===e.sha256&&B()}catch(e){console.error("Error deleting blob:",e),alert(`Failed to delete blob: ${e.message}`)}}async function T(){n(12,k=!0),n(2,p="");try{const e=`${window.location.origin}/blossom/admin/users`,t=await Fw(a,"admin"),i=await fetch(e,{headers:t?{Authorization:`Nostr ${t}`}:{}});if(!i.ok)throw new Error(`Failed to load user stats: ${i.statusText}`);n(11,A=await i.json());for(const e of A)Sp(e.pubkey).then(t=>{e.profile=t||{name:"",picture:""},n(11,A)}).catch(()=>{e.profile={name:"",picture:""}})}catch(e){console.error("Error fetching admin user stats:",e),n(2,p=e.message||"Failed to load user stats")}finally{n(12,k=!1)}}async function _(e){n(0,f=!0),n(2,p="");try{const t=`${window.location.origin}/blossom/list/${e}`,n=await Fw(a,"list"),i=await fetch(t,{headers:n?{Authorization:`Nostr ${n}`}:{}});if(!i.ok)throw new Error(`Failed to load user blobs: ${i.statusText}`);C=await i.json(),C.sort((e,t)=>(t.uploaded||0)-(e.uploaded||0))}catch(e){console.error("Error loading user blobs:",e),n(2,p=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 _(e.pubkey)}D(()=>{i&&!E&&(n(36,E=!0),x())});return e.$$set=e=>{"isLoggedIn"in e&&n(32,s=e.isLoggedIn),"userPubkey"in e&&n(33,o=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,i=s&&o),16&e.$$.dirty[1]&&n(14,r="admin"===l||"owner"===l),3&e.$$.dirty[0]|32&e.$$.dirty[1]&&(!i||E||f||(n(36,E=!0),x()))},[f,i,p,h,g,m,u,v,y,w,b,A,k,I,r,S,B,Q,F,function(e){v&&("Escape"===e.key?B():"+"===e.key||"="===e.key?Q():"-"===e.key&&F())},function(){c("openLoginModal")},$,function(e){n(3,h=Array.from(e.target.files))},function(){u?.click()},async function(){if(0===h.length)return;n(4,g=!0),n(2,p="");const e=[],t=[];for(let i=0;i<h.length;i++){const r=h[i];n(5,m=`Uploading ${i+1}/${h.length}: ${r.name}`);try{const t=`${window.location.origin}/blossom/upload`,n=await Fw(a,"upload"),i=await fetch(t,{method:"PUT",headers:{"Content-Type":r.type||"application/octet-stream",...n?{Authorization:`Nostr ${n}`}:{}},body:r});if(!i.ok){const e=i.headers.get("X-Reason")||i.statusText;throw new Error(e)}const s=await i.json();console.log("Upload response:",s),e.push(s)}catch(e){console.error(`Error uploading ${r.name}:`,e),t.push({name:r.name,error:e.message})}}n(4,g=!1),n(5,m=""),n(3,h=[]),u&&n(6,u.value="",u),e.length>0&&await x(),t.length>0&&n(2,p=`Failed to upload: ${t.map(e=>e.name).join(", ")}`)},function(e){try{return wu(e)}catch(t){return Pw(e)}},function(){n(10,b=!0),T()},function(){n(10,b=!1),n(11,A=[]),n(13,I=null),C=[]},N,function(){n(13,I=null),C=[]},function(){I?_(I.pubkey):b?T():x()},function(){return I?C:d},s,o,a,l,E,function(t){R.call(this,e,t)},function(t){R.call(this,e,t)},function(e){U[e?"unshift":"push"](()=>{u=e,n(6,u)})},e=>N(e),(e,t)=>"Enter"===t.key&&N(e),e=>$(e),e=>S(e),(e,t)=>"Enter"===t.key&&S(e),()=>{navigator.clipboard.writeText(Uw(y))},()=>$(y),e=>"Enter"===e.key&&B()]}class Ow extends se{constructor(e){super(),re(this,e,Lw,Sw,s,{isLoggedIn:32,userPubkey:33,userSigner:34,currentEffectiveRole:35},null,[-1,-1])}}function Mw(e,t,n){const i=e.slice();return i[29]=t[n],i}function jw(e,t,n){const i=e.slice();return i[32]=t[n],i}function Hw(e){let t,n,i;function r(e,t){return e[0]?Jw:Kw}let s=r(e),o=s(e);return{c(){t=p("div"),n=p("p"),n.textContent="Log viewer is only available to relay owners.",i=m(),o.c(),b(n,"class","svelte-w6h7aj"),b(t,"class","login-prompt svelte-w6h7aj")},m(e,r){u(e,t,r),c(t,n),c(t,i),o.m(t,null)},p(e,n){s===(s=r(e))&&o?o.p(e,n):(o.d(1),o=s(e),o&&(o.c(),o.m(t,null)))},d(e){e&&d(t),o.d()}}}function Gw(e){let t,n,r,s,o,a,l,h,v,w,A,I,C,x,S,B,Q,F,D,$,P,R,T,U,_,N,L,O,j,H,G,J=e[3]?"Loading...":"Refresh",K=e[2].length+"",V=e[12],q=[];for(let t=0;t<V.length;t+=1)q[t]=Vw(jw(e,V,t));let Y=e[7]&&qw(e);function W(e,t){return 0!==e[2].length||e[3]?Yw:Ww}let z=W(e),Z=z(e);return{c(){t=p("div"),n=p("div"),r=p("h3"),r.textContent="Logs",s=m(),o=p("div"),a=p("div"),l=p("label"),l.textContent="Level:",h=m(),v=p("select");for(let e=0;e<q.length;e+=1)q[e].c();w=m(),A=p("button"),I=g("Clear"),x=m(),S=p("button"),B=g("🔄 "),Q=g(J),F=m(),Y&&Y.c(),D=m(),$=p("div"),P=g("Showing "),R=g(K),T=g(" of "),U=g(e[6]),_=g(" logs (Level: "),N=g(e[8]),L=g(")"),O=m(),j=p("div"),Z.c(),b(r,"class","svelte-w6h7aj"),b(l,"for","log-level"),b(l,"class","svelte-w6h7aj"),b(v,"id","log-level"),b(v,"class","svelte-w6h7aj"),void 0===e[9]&&M(()=>e[18].call(v)),b(a,"class","level-selector svelte-w6h7aj"),b(A,"class","clear-btn svelte-w6h7aj"),A.disabled=C=e[3]||0===e[2].length,b(S,"class","refresh-btn svelte-w6h7aj"),S.disabled=e[3],b(o,"class","header-controls svelte-w6h7aj"),b(n,"class","header-section svelte-w6h7aj"),b($,"class","log-info svelte-w6h7aj"),b(j,"class","log-list svelte-w6h7aj"),b(t,"class","log-view svelte-w6h7aj")},m(i,d){u(i,t,d),c(t,n),c(n,r),c(n,s),c(n,o),c(o,a),c(a,l),c(a,h),c(a,v);for(let e=0;e<q.length;e+=1)q[e]&&q[e].m(v,null);E(v,e[9],!0),c(o,w),c(o,A),c(A,I),c(o,x),c(o,S),c(S,B),c(S,Q),c(t,F),Y&&Y.m(t,null),c(t,D),c(t,$),c($,P),c($,R),c($,T),c($,U),c($,_),c($,N),c($,L),c(t,O),c(t,j),Z.m(j,null),e[21](j),H||(G=[y(v,"change",e[18]),y(v,"change",e[14]),y(A,"click",e[15]),y(S,"click",e[19])],H=!0)},p(e,n){if(4096&n[0]){let t;for(V=e[12],t=0;t<V.length;t+=1){const i=jw(e,V,t);q[t]?q[t].p(i,n):(q[t]=Vw(i),q[t].c(),q[t].m(v,null))}for(;t<q.length;t+=1)q[t].d(1);q.length=V.length}4608&n[0]&&E(v,e[9]),12&n[0]&&C!==(C=e[3]||0===e[2].length)&&(A.disabled=C),8&n[0]&&J!==(J=e[3]?"Loading...":"Refresh")&&k(Q,J),8&n[0]&&(S.disabled=e[3]),e[7]?Y?Y.p(e,n):(Y=qw(e),Y.c(),Y.m(t,D)):Y&&(Y.d(1),Y=null),4&n[0]&&K!==(K=e[2].length+"")&&k(R,K),64&n[0]&&k(U,e[6]),256&n[0]&&k(N,e[8]),z===(z=W(e))&&Z?Z.p(e,n):(Z.d(1),Z=z(e),Z&&(Z.c(),Z.m(j,null)))},d(n){n&&d(t),f(q,n),Y&&Y.d(),Z.d(),e[21](null),H=!1,i(G)}}}function Jw(e){let t,n,i,r;return{c(){t=p("p"),n=g("Your role ("),i=g(e[1]),r=g(") does not have access to this feature."),b(t,"class","access-denied svelte-w6h7aj")},m(e,s){u(e,t,s),c(t,n),c(t,i),c(t,r)},p(e,t){2&t[0]&&k(i,e[1])},d(e){e&&d(t)}}}function Kw(t){let n,i,r;return{c(){n=p("button"),n.textContent="Log In",b(n,"class","login-btn svelte-w6h7aj")},m(e,s){u(e,n,s),i||(r=y(n,"click",t[16]),i=!0)},p:e,d(e){e&&d(n),i=!1,r()}}}function Vw(t){let n,i,r=t[32]+"";return{c(){n=p("option"),i=g(r),n.__value=t[32],n.value=n.__value},m(e,t){u(e,n,t),c(n,i)},p:e,d(e){e&&d(n)}}}function qw(e){let t,n;return{c(){t=p("div"),n=g(e[7]),b(t,"class","error-message svelte-w6h7aj")},m(e,i){u(e,t,i),c(t,n)},p(e,t){128&t[0]&&k(n,e[7])},d(e){e&&d(t)}}}function Yw(e){let t,n,i=e[2],r=[];for(let t=0;t<i.length;t+=1)r[t]=Zw(Mw(e,i,t));function s(e,t){return e[3]?tb:e[5]?eb:Xw}let o=s(e),a=o(e);return{c(){for(let e=0;e<r.length;e+=1)r[e].c();t=m(),n=p("div"),a.c(),b(n,"class","load-more-trigger svelte-w6h7aj")},m(i,s){for(let e=0;e<r.length;e+=1)r[e]&&r[e].m(i,s);u(i,t,s),u(i,n,s),a.m(n,null),e[20](n)},p(e,l){if(4&l[0]){let n;for(i=e[2],n=0;n<i.length;n+=1){const s=Mw(e,i,n);r[n]?r[n].p(s,l):(r[n]=Zw(s),r[n].c(),r[n].m(t.parentNode,t))}for(;n<r.length;n+=1)r[n].d(1);r.length=i.length}o!==(o=s(e))&&(a.d(1),a=o(e),a&&(a.c(),a.m(n,null)))},d(i){f(r,i),i&&d(t),i&&d(n),a.d(),e[20](null)}}}function Ww(t){let n;return{c(){n=p("div"),n.innerHTML="<p>No logs available.</p>",b(n,"class","empty-state svelte-w6h7aj")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function zw(e){let t,n,i,r,s=e[29].file+"",o=e[29].line+"";return{c(){t=p("span"),n=g(s),i=g(":"),r=g(o),b(t,"class","log-location svelte-w6h7aj")},m(e,s){u(e,t,s),c(t,n),c(t,i),c(t,r)},p(e,t){4&t[0]&&s!==(s=e[29].file+"")&&k(n,s),4&t[0]&&o!==(o=e[29].line+"")&&k(r,o)},d(e){e&&d(t)}}}function Zw(e){let t,n,i,r,s,o,a,l,f,h,v,y=ib(e[29].timestamp)+"",w=e[29].level+"",A=e[29].message+"",I=e[29].file&&zw(e);return{c(){t=p("div"),n=p("span"),i=g(y),r=m(),s=p("span"),o=g(w),l=m(),I&&I.c(),f=m(),h=p("span"),v=g(A),b(n,"class","log-timestamp svelte-w6h7aj"),b(s,"class",a="log-level "+rb(e[29].level)+" svelte-w6h7aj"),b(h,"class","log-message svelte-w6h7aj"),b(t,"class","log-entry svelte-w6h7aj")},m(e,a){u(e,t,a),c(t,n),c(n,i),c(t,r),c(t,s),c(s,o),c(t,l),I&&I.m(t,null),c(t,f),c(t,h),c(h,v)},p(e,n){4&n[0]&&y!==(y=ib(e[29].timestamp)+"")&&k(i,y),4&n[0]&&w!==(w=e[29].level+"")&&k(o,w),4&n[0]&&a!==(a="log-level "+rb(e[29].level)+" svelte-w6h7aj")&&b(s,"class",a),e[29].file?I?I.p(e,n):(I=zw(e),I.c(),I.m(t,f)):I&&(I.d(1),I=null),4&n[0]&&A!==(A=e[29].message+"")&&k(v,A)},d(e){e&&d(t),I&&I.d()}}}function Xw(e){let t;return{c(){t=p("span"),t.textContent="End of logs"},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function eb(e){let t;return{c(){t=p("span"),t.textContent="Scroll for more"},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function tb(e){let t;return{c(){t=p("span"),t.textContent="Loading more..."},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function nb(t){let n;function i(e,t){return e[4]?Gw:Hw}let r=i(t),s=r(t);return{c(){s.c(),n=v()},m(e,t){s.m(e,t),u(e,n,t)},p(e,t){r===(r=i(e))&&s?s.p(e,t):(s.d(1),s=r(e),s&&(s.c(),s.m(n.parentNode,n)))},i:e,o:e,d(e){s.d(e),e&&d(n)}}}function ib(e){if(!e)return"";return new Date(e).toLocaleString()}function rb(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 sb(e,t,n){let i,{isLoggedIn:r=!1}=t,{userRole:s=""}=t,{userSigner:o=null}=t;const a=P();let l=[],c=!1,u=!0,d=0,f=0,p="",h="info",g="info";const m=["trace","debug","info","warn","error","fatal"];let v,y,w;async function b(e="GET",t="/api/logs"){if(!o)return null;try{const n={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",`${window.location.origin}${t}`],["method",e]],content:""},i=await o.signEvent(n);return btoa(JSON.stringify(i)).replace(/\+/g,"-").replace(/\//g,"_")}catch(e){return console.error("Error creating auth header:",e),null}}async function A(e=!1){if(!c){n(3,c=!0),n(7,p=""),e&&(d=0,n(2,l=[]));try{const t=`/api/logs?offset=${d}&limit=100`,i=await b("GET",t),r=`${window.location.origin}${t}`,s=await fetch(r,{headers:i?{Authorization:`Nostr ${i}`}:{}});if(!s.ok)throw new Error(`Failed to load logs: ${s.statusText}`);const o=await s.json();n(2,l=e?o.logs||[]:[...l,...o.logs||[]]),n(6,f=o.total||0),n(5,u=o.has_more||!1),d=l.length}catch(e){console.error("Error loading logs:",e),n(7,p=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,h=t.level||"info"),n(9,g=h)}}catch(e){console.error("Error loading log level:",e)}}D(()=>{i&&(A(!0),k(),function(){if(!y)return;w=new IntersectionObserver(e=>{e[0].isIntersecting&&u&&!c&&u&&!c&&A(!1)},{threshold:.1}),w.observe(y)}())}),$(()=>{w&&w.disconnect()});return e.$$set=e=>{"isLoggedIn"in e&&n(0,r=e.isLoggedIn),"userRole"in e&&n(1,s=e.userRole),"userSigner"in e&&n(17,o=e.userSigner)},e.$$.update=()=>{3&e.$$.dirty[0]&&n(4,i=r&&"owner"===s),28&e.$$.dirty[0]&&i&&0===l.length&&!c&&(A(!0),k())},[r,s,l,c,i,u,f,p,h,g,v,y,m,A,async function(){if(g!==h)try{const e=await b("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 i=await t.json();n(8,h=i.level),n(9,g=h)}catch(e){console.error("Error setting log level:",e),n(7,p=e.message||"Failed to set log level"),n(9,g=h)}},async function(){if(confirm("Are you sure you want to clear all logs?"))try{const e=await b("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,p=e.message||"Failed to clear logs")}},function(){a("openLoginModal")},o,function(){g=x(this),n(9,g),n(12,m)},()=>A(!0),function(e){U[e?"unshift":"push"](()=>{y=e,n(11,y)})},function(e){U[e?"unshift":"push"](()=>{v=e,n(10,v)})}]}class ob extends se{constructor(e){super(),re(this,e,sb,nb,s,{isLoggedIn:0,userRole:1,userSigner:17},null,[-1,-1])}}async function ab(e,t,n,i){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",i],["method",n.toUpperCase()]],content:""};console.log("createNIP98Auth: Signing event for",n,i);const r=await e.signEvent(t);console.log("createNIP98Auth: Signed event:",{id:r.id,pubkey:r.pubkey,kind:r.kind,created_at:r.created_at,tags:r.tags,hasSig:!!r.sig});const s=JSON.stringify(r);return btoa(s).replace(/\+/g,"-").replace(/\//g,"_")}catch(e){return console.error("createNIP98Auth: Error:",e),null}}async function lb(){try{const e=await fetch(`${window.location.origin}/api/nrc/config`);if(e.ok)return await e.json()}catch(e){console.error("Error fetching NRC config:",e)}return{enabled:!1,badger_required:!0}}function cb(e){return hp[e]||`Kind ${e}`}function ub(e){return e?e.slice(0,8)+"..."+e.slice(-8):"unknown"}function db(e,t=100){return e?e.length>t?e.slice(0,t)+"...":e:""}function fb(e){return e?new Date(1e3*e).toLocaleString():""}async function pb(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}}}function hb(e,t=!0){if(!e)return;const n=e.textContent,i=e.style.backgroundColor;t?(e.textContent="",e.style.backgroundColor="#4CAF50"):(e.textContent="L",e.style.backgroundColor="#f44336"),setTimeout(()=>{e.textContent=n,e.style.backgroundColor=i},2e3)}function gb(e,t,n){const i=e.slice();return i[31]=t[n],i}function mb(e){let t,n,r,s,o,a,l,f,h,w,A,C,E,x,S,B,Q,F,D,$,P,R,T,U,_,N,L,O,M,j,H,G,J,K,V,q,Y,W,z,Z,X,ee,te=(e[5].rendezvous_url||"Not configured")+"",ne=e[4].length+"",ie=e[5].mint_url&&bb(e),re=!e[5].mint_url&&Ab();function se(e,t){return 0===e[4].length?Ib:kb}let oe=se(e),ae=oe(e),le=e[7]&&Sb(e);return{c(){t=p("div"),n=p("div"),n.innerHTML='<span class="status-label svelte-gwb5vv">Status:</span> \n <span class="status-value enabled svelte-gwb5vv">Enabled</span>',r=m(),s=p("div"),o=p("span"),o.textContent="Rendezvous:",a=m(),l=p("span"),f=g(te),h=m(),ie&&ie.c(),w=m(),A=p("div"),C=p("h3"),C.textContent="Create New Connection",E=m(),x=p("div"),S=p("div"),B=p("label"),B.textContent="Device Label",Q=m(),F=p("input"),D=m(),$=p("div"),P=p("label"),R=p("input"),U=g("\n Include CAT (Cashu Access Token)\n "),re&&re.c(),_=m(),N=p("button"),L=g("+ Create Connection"),M=m(),j=p("div"),H=p("h3"),G=g("Connections ("),J=g(ne),K=g(")"),V=m(),ae.c(),q=m(),Y=p("button"),W=g("Refresh"),z=m(),le&&le.c(),Z=v(),b(n,"class","status-item svelte-gwb5vv"),b(o,"class","status-label svelte-gwb5vv"),b(l,"class","status-value svelte-gwb5vv"),b(s,"class","status-item svelte-gwb5vv"),b(t,"class","config-status svelte-gwb5vv"),b(C,"class","svelte-gwb5vv"),b(B,"for","new-label"),b(B,"class","svelte-gwb5vv"),b(F,"type","text"),b(F,"id","new-label"),b(F,"placeholder","e.g., Phone, Laptop, Tablet"),F.disabled=e[6],b(F,"class","svelte-gwb5vv"),b(S,"class","form-group svelte-gwb5vv"),b(R,"type","checkbox"),R.disabled=T=e[6]||!e[5].mint_url,b(R,"class","svelte-gwb5vv"),b(P,"class","svelte-gwb5vv"),b($,"class","form-group checkbox-group svelte-gwb5vv"),b(N,"class","create-btn svelte-gwb5vv"),N.disabled=O=e[6]||!e[9].trim(),b(x,"class","create-form svelte-gwb5vv"),b(A,"class","section svelte-gwb5vv"),b(H,"class","svelte-gwb5vv"),b(Y,"class","refresh-btn svelte-gwb5vv"),Y.disabled=e[6],b(j,"class","section svelte-gwb5vv")},m(i,d){u(i,t,d),c(t,n),c(t,r),c(t,s),c(s,o),c(s,a),c(s,l),c(l,f),c(t,h),ie&&ie.m(t,null),u(i,w,d),u(i,A,d),c(A,C),c(A,E),c(A,x),c(x,S),c(S,B),c(S,Q),c(S,F),I(F,e[9]),c(x,D),c(x,$),c($,P),c(P,R),R.checked=e[10],c(P,U),re&&re.m(P,null),c(x,_),c(x,N),c(N,L),u(i,M,d),u(i,j,d),c(j,H),c(H,G),c(H,J),c(H,K),c(j,V),ae.m(j,null),c(j,q),c(j,Y),c(Y,W),u(i,z,d),le&&le.m(i,d),u(i,Z,d),X||(ee=[y(F,"input",e[24]),y(R,"change",e[25]),y(N,"click",e[15]),y(Y,"click",e[14])],X=!0)},p(e,n){32&n[0]&&te!==(te=(e[5].rendezvous_url||"Not configured")+"")&&k(f,te),e[5].mint_url?ie?ie.p(e,n):(ie=bb(e),ie.c(),ie.m(t,null)):ie&&(ie.d(1),ie=null),64&n[0]&&(F.disabled=e[6]),512&n[0]&&F.value!==e[9]&&I(F,e[9]),96&n[0]&&T!==(T=e[6]||!e[5].mint_url)&&(R.disabled=T),1024&n[0]&&(R.checked=e[10]),e[5].mint_url?re&&(re.d(1),re=null):re||(re=Ab(),re.c(),re.m(P,null)),576&n[0]&&O!==(O=e[6]||!e[9].trim())&&(N.disabled=O),16&n[0]&&ne!==(ne=e[4].length+"")&&k(J,ne),oe===(oe=se(e))&&ae?ae.p(e,n):(ae.d(1),ae=oe(e),ae&&(ae.c(),ae.m(j,q))),64&n[0]&&(Y.disabled=e[6]),e[7]?le?le.p(e,n):(le=Sb(e),le.c(),le.m(Z.parentNode,Z)):le&&(le.d(1),le=null)},d(e){e&&d(t),ie&&ie.d(),e&&d(w),e&&d(A),re&&re.d(),e&&d(M),e&&d(j),ae.d(),e&&d(z),le&&le.d(e),e&&d(Z),X=!1,i(ee)}}}function vb(e){let t,n,i,r,s,o,a,l=(e[1]||"none")+"";return{c(){t=p("div"),n=p("p"),n.textContent="Owner permission required for relay connection management.",i=m(),r=p("p"),s=g("Current role: "),o=p("strong"),a=g(l),b(n,"class","svelte-gwb5vv"),b(r,"class","svelte-gwb5vv"),b(t,"class","permission-denied svelte-gwb5vv")},m(e,l){u(e,t,l),c(t,n),c(t,i),c(t,r),c(r,s),c(r,o),c(o,a)},p(e,t){2&t[0]&&l!==(l=(e[1]||"none")+"")&&k(a,l)},d(e){e&&d(t)}}}function yb(t){let n,i,r,s,o,a;return{c(){n=p("div"),i=p("p"),i.textContent="Please log in to manage relay connections.",r=m(),s=p("button"),s.textContent="Log In",b(i,"class","svelte-gwb5vv"),b(s,"class","login-btn svelte-gwb5vv"),b(n,"class","login-prompt svelte-gwb5vv")},m(e,l){u(e,n,l),c(n,i),c(n,r),c(n,s),o||(a=y(s,"click",t[20]),o=!0)},p:e,d(e){e&&d(n),o=!1,a()}}}function wb(e){let t;function n(e,t){return e[3]?Qb:Bb}let i=n(e),r=i(e);return{c(){t=p("div"),r.c(),b(t,"class","not-enabled svelte-gwb5vv")},m(e,n){u(e,t,n),r.m(t,null)},p(e,s){i!==(i=n(e))&&(r.d(1),r=i(e),r&&(r.c(),r.m(t,null)))},d(e){e&&d(t),r.d()}}}function bb(e){let t,n,i,r,s,o=e[5].mint_url+"";return{c(){t=p("div"),n=p("span"),n.textContent="Cashu Mint:",i=m(),r=p("span"),s=g(o),b(n,"class","status-label svelte-gwb5vv"),b(r,"class","status-value svelte-gwb5vv"),b(t,"class","status-item svelte-gwb5vv")},m(e,o){u(e,t,o),c(t,n),c(t,i),c(t,r),c(r,s)},p(e,t){32&t[0]&&o!==(o=e[5].mint_url+"")&&k(s,o)},d(e){e&&d(t)}}}function Ab(e){let t;return{c(){t=p("span"),t.textContent="(requires Cashu mint)",b(t,"class","hint svelte-gwb5vv")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function kb(e){let t,n=e[4],i=[];for(let t=0;t<n.length;t+=1)i[t]=xb(gb(e,n,t));return{c(){t=p("div");for(let e=0;e<i.length;e+=1)i[e].c();b(t,"class","connections-list svelte-gwb5vv")},m(e,n){u(e,t,n);for(let e=0;e<i.length;e+=1)i[e]&&i[e].m(t,null)},p(e,r){if(196688&r[0]){let s;for(n=e[4],s=0;s<n.length;s+=1){const o=gb(e,n,s);i[s]?i[s].p(o,r):(i[s]=xb(o),i[s].c(),i[s].m(t,null))}for(;s<i.length;s+=1)i[s].d(1);i.length=n.length}},d(e){e&&d(t),f(i,e)}}}function Ib(t){let n;return{c(){n=p("p"),n.textContent="No connections yet. Create one to get started.",b(n,"class","no-connections svelte-gwb5vv")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Cb(e){let t,n,i,r=$b(e[31].last_used)+"";return{c(){t=p("span"),n=g("Last used: "),i=g(r),b(t,"class","detail")},m(e,r){u(e,t,r),c(t,n),c(t,i)},p(e,t){16&t[0]&&r!==(r=$b(e[31].last_used)+"")&&k(i,r)},d(e){e&&d(t)}}}function Eb(e){let t;return{c(){t=p("span"),t.textContent="CAT",b(t,"class","badge cashu svelte-gwb5vv")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function xb(e){let t,n,r,s,o,a,l,f,h,v,w,A,I,C,E,x,S,B,Q,F,D,$,P,R,T,U,_=e[31].label+"",N=e[31].id.substring(0,8)+"",L=$b(e[31].created_at)+"",O=e[31].last_used&&Cb(e),M=e[31].use_cashu&&Eb();function j(){return e[26](e[31])}function H(){return e[27](e[31])}return{c(){t=p("div"),n=p("div"),r=p("div"),s=g(_),o=m(),a=p("div"),l=p("span"),f=g("ID: "),h=g(N),v=g("..."),w=m(),A=p("span"),I=g("Created: "),C=g(L),E=m(),O&&O.c(),x=m(),M&&M.c(),S=m(),B=p("div"),Q=p("button"),F=g("Show URI"),D=m(),$=p("button"),P=g("Delete"),R=m(),b(r,"class","connection-label svelte-gwb5vv"),b(l,"class","detail"),b(A,"class","detail"),b(a,"class","connection-details svelte-gwb5vv"),b(n,"class","connection-info svelte-gwb5vv"),b(Q,"class","action-btn show-uri-btn svelte-gwb5vv"),Q.disabled=e[6],b(Q,"title","Show connection URI"),b($,"class","action-btn delete-btn svelte-gwb5vv"),$.disabled=e[6],b($,"title","Delete connection"),b(B,"class","connection-actions svelte-gwb5vv"),b(t,"class","connection-item svelte-gwb5vv")},m(e,i){u(e,t,i),c(t,n),c(n,r),c(r,s),c(n,o),c(n,a),c(a,l),c(l,f),c(l,h),c(l,v),c(a,w),c(a,A),c(A,I),c(A,C),c(a,E),O&&O.m(a,null),c(a,x),M&&M.m(a,null),c(t,S),c(t,B),c(B,Q),c(Q,F),c(B,D),c(B,$),c($,P),c(t,R),T||(U=[y(Q,"click",j),y($,"click",H)],T=!0)},p(t,n){e=t,16&n[0]&&_!==(_=e[31].label+"")&&k(s,_),16&n[0]&&N!==(N=e[31].id.substring(0,8)+"")&&k(h,N),16&n[0]&&L!==(L=$b(e[31].created_at)+"")&&k(C,L),e[31].last_used?O?O.p(e,n):(O=Cb(e),O.c(),O.m(a,x)):O&&(O.d(1),O=null),e[31].use_cashu?M||(M=Eb(),M.c(),M.m(a,null)):M&&(M.d(1),M=null),64&n[0]&&(Q.disabled=e[6]),64&n[0]&&($.disabled=e[6])},d(e){e&&d(t),O&&O.d(),M&&M.d(),T=!1,i(U)}}}function Sb(e){let t,n;return{c(){t=p("div"),n=g(e[7]),b(t,"class","message svelte-gwb5vv"),S(t,"error","error"===e[8]),S(t,"success","success"===e[8])},m(e,i){u(e,t,i),c(t,n)},p(e,i){128&i[0]&&k(n,e[7]),256&i[0]&&S(t,"error","error"===e[8]),256&i[0]&&S(t,"success","success"===e[8])},d(e){e&&d(t)}}}function Bb(e){let t,n,i;return{c(){t=p("p"),t.textContent="NRC is not enabled on this relay.",n=m(),i=p("p"),i.innerHTML='Set <code class="svelte-gwb5vv">ORLY_NRC_ENABLED=true</code> and configure <code class="svelte-gwb5vv">ORLY_NRC_RENDEZVOUS_URL</code> to enable.',b(t,"class","svelte-gwb5vv"),b(i,"class","svelte-gwb5vv")},m(e,r){u(e,t,r),u(e,n,r),u(e,i,r)},d(e){e&&d(t),e&&d(n),e&&d(i)}}}function Qb(e){let t,n,i;return{c(){t=p("p"),t.textContent="NRC requires the Badger database backend.",n=m(),i=p("p"),i.innerHTML='Set <code class="svelte-gwb5vv">ORLY_DB_TYPE=badger</code> to enable NRC functionality.',b(t,"class","svelte-gwb5vv"),b(i,"class","svelte-gwb5vv")},m(e,r){u(e,t,r),u(e,n,r),u(e,i,r)},d(e){e&&d(t),e&&d(n),e&&d(i)}}}function Fb(e){let t,n,r,s,o,a,l,f,h,v,A,I,C,E,x,S,B,Q;return{c(){t=p("div"),n=p("div"),r=p("h3"),s=g('Connection URI for "'),o=g(e[13]),a=g('"'),l=m(),f=p("p"),f.textContent="Copy this URI to your Nostr client to connect to this relay remotely.\n Keep it secret - anyone with this URI can access your relay.",h=m(),v=p("div"),A=p("textarea"),I=m(),C=p("div"),E=p("button"),E.textContent="Copy to Clipboard",x=m(),S=p("button"),S.textContent="Close",b(r,"class","svelte-gwb5vv"),b(f,"class","modal-description svelte-gwb5vv"),A.readOnly=!0,A.value=e[12],b(A,"class","svelte-gwb5vv"),b(v,"class","uri-display svelte-gwb5vv"),b(E,"class","copy-btn svelte-gwb5vv"),b(S,"class","close-btn svelte-gwb5vv"),b(C,"class","modal-actions svelte-gwb5vv"),b(n,"class","modal svelte-gwb5vv"),b(t,"class","modal-overlay svelte-gwb5vv")},m(i,d){u(i,t,d),c(t,n),c(n,r),c(r,s),c(r,o),c(r,a),c(n,l),c(n,f),c(n,h),c(n,v),c(v,A),c(n,I),c(n,C),c(C,E),c(C,x),c(C,S),B||(Q=[y(E,"click",e[18]),y(S,"click",e[19]),y(n,"click",w(e[23])),y(t,"click",e[19])],B=!0)},p(e,t){8192&t[0]&&k(o,e[13]),4096&t[0]&&(A.value=e[12])},d(e){e&&d(t),B=!1,i(Q)}}}function Db(t){let n,i,r,s,o,a,l;function f(e,t){return e[2]?e[0]?"owner"!==e[1]?vb:mb:yb:wb}let h=f(t),g=h(t),y=t[11]&&Fb(t);return{c(){n=p("div"),i=p("h2"),i.textContent="Relay Connect",r=m(),s=p("p"),s.textContent="Nostr Relay Connect (NRC) allows remote access to this relay through a public relay tunnel.\n Create connection strings for your devices to sync securely.",o=m(),g.c(),a=m(),y&&y.c(),l=v(),b(i,"class","svelte-gwb5vv"),b(s,"class","description svelte-gwb5vv"),b(n,"class","relay-connect-view svelte-gwb5vv")},m(e,t){u(e,n,t),c(n,i),c(n,r),c(n,s),c(n,o),g.m(n,null),u(e,a,t),y&&y.m(e,t),u(e,l,t)},p(e,t){h===(h=f(e))&&g?g.p(e,t):(g.d(1),g=h(e),g&&(g.c(),g.m(n,null))),e[11]?y?y.p(e,t):(y=Fb(e),y.c(),y.m(l.parentNode,l)):y&&(y.d(1),y=null)},i:e,o:e,d(e){e&&d(n),g.d(),e&&d(a),y&&y.d(e),e&&d(l)}}}function $b(e){return e?new Date(1e3*e).toLocaleString():"Never"}function Pb(e,t,n){let{isLoggedIn:i=!1}=t,{userRole:r=""}=t,{userSigner:s=null}=t,{userPubkey:o=""}=t;const a=P();let l=!1,c=!1,u=[],d={},f=!1,p="",h="info",g="",m=!1,v=!1,y="",w="";async function b(){if(i&&s&&o){n(6,f=!0);try{const e=await async function(e,t){const n=`${window.location.origin}/api/nrc/connections`,i=await ab(e,t,"GET",n),r=await fetch(n,{headers:i?{Authorization:`Nostr ${i}`}:{}});if(!r.ok){const e=await r.text();throw new Error(e||`Failed to get NRC connections: ${r.statusText}`)}return await r.json()}(s,o);n(4,u=e.connections||[]),n(5,d=e.config||{})}catch(e){I(`Failed to load connections: ${e.message}`,"error")}finally{n(6,f=!1)}}}async function A(e,t){if(confirm(`Are you sure you want to delete the connection "${t}"? This will revoke access for any device using this connection.`)){n(6,f=!0);try{await async function(e,t,n){const i=`${window.location.origin}/api/nrc/connections/${n}`,r=await ab(e,t,"DELETE",i),s=await fetch(i,{method:"DELETE",headers:r?{Authorization:`Nostr ${r}`}:{}});if(!s.ok){const e=await s.text();throw new Error(e||`Failed to delete NRC connection: ${s.statusText}`)}return await s.json()}(s,o,e),await b(),I(`Connection "${t}" deleted`,"success")}catch(e){I(`Failed to delete connection: ${e.message}`,"error")}finally{n(6,f=!1)}}}async function k(e,t){n(6,f=!0);try{const i=await async function(e,t,n){const i=`${window.location.origin}/api/nrc/connections/${n}/uri`,r=await ab(e,t,"GET",i),s=await fetch(i,{headers:r?{Authorization:`Nostr ${r}`}:{}});if(!s.ok){const e=await s.text();throw new Error(e||`Failed to get NRC URI: ${s.statusText}`)}return await s.json()}(s,o,e);n(12,y=i.uri),n(13,w=t),n(11,v=!0)}catch(e){I(`Failed to get URI: ${e.message}`,"error")}finally{n(6,f=!1)}}function I(e,t="info"){n(7,p=e),n(8,h=t),setTimeout(()=>{p===e&&n(7,p="")},5e3)}D(async()=>{await async function(){try{const e=await lb();n(2,l=e.enabled),n(3,c=e.badger_required),l&&i&&"owner"===r&&await b()}catch(e){console.error("Failed to load NRC config:",e)}}()});return e.$$set=e=>{"isLoggedIn"in e&&n(0,i=e.isLoggedIn),"userRole"in e&&n(1,r=e.userRole),"userSigner"in e&&n(21,s=e.userSigner),"userPubkey"in e&&n(22,o=e.userPubkey)},e.$$.update=()=>{7&e.$$.dirty[0]&&i&&"owner"===r&&l&&b()},[i,r,l,c,u,d,f,p,h,g,m,v,y,w,b,async function(){if(g.trim()){n(6,f=!0);try{const e=await async function(e,t,n,i=!1){const r=`${window.location.origin}/api/nrc/connections`,s=await ab(e,t,"POST",r),o=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json",...s?{Authorization:`Nostr ${s}`}:{}},body:JSON.stringify({label:n,use_cashu:i})});if(!o.ok){const e=await o.text();throw new Error(e||`Failed to create NRC connection: ${o.statusText}`)}return await o.json()}(s,o,g.trim(),m);n(12,y=e.uri),n(13,w=e.label),n(11,v=!0),n(9,g=""),n(10,m=!1),await b(),I(`Connection "${e.label}" created successfully`,"success")}catch(e){I(`Failed to create connection: ${e.message}`,"error")}finally{n(6,f=!1)}}else I("Please enter a label for the connection","error")},A,k,async function(e){const t=await pb(y);hb(e.target.closest("button"),t),t||I("Failed to copy to clipboard","error")},function(){n(11,v=!1),n(12,y=""),n(13,w="")},function(){a("openLoginModal")},s,o,function(t){R.call(this,e,t)},function(){g=this.value,n(9,g)},function(){m=this.checked,n(10,m)},e=>k(e.id,e.label),e=>A(e.id,e.label)]}class Rb extends se{constructor(e){super(),re(this,e,Pb,Db,s,{isLoggedIn:0,userRole:1,userSigner:21,userPubkey:22},null,[-1,-1])}}function Tb(e){let t,n,i,r,s,o,a,l,f,h,v;return{c(){t=p("div"),n=p("div"),i=p("h3"),i.textContent="Active Filter",r=m(),s=p("button"),s.textContent="🧹 Sweep",o=m(),a=p("div"),l=p("pre"),f=g(e[2]),b(i,"class","svelte-1tyqaa5"),b(s,"class","sweep-btn svelte-1tyqaa5"),b(s,"title","Clear filter"),b(n,"class","filter-display-header svelte-1tyqaa5"),b(l,"class","filter-json svelte-1tyqaa5"),b(a,"class","filter-json-container svelte-1tyqaa5"),b(t,"class","filter-display svelte-1tyqaa5")},m(d,p){u(d,t,p),c(t,n),c(n,i),c(n,r),c(n,s),c(t,o),c(t,a),c(a,l),c(l,f),h||(v=y(s,"click",e[3]),h=!0)},p(e,t){4&t&&k(f,e[2])},d(e){e&&d(t),h=!1,v()}}}function Ub(t){let n,i=t[0]&&t[1]&&Tb(t);return{c(){i&&i.c(),n=v()},m(e,t){i&&i.m(e,t),u(e,n,t)},p(e,[t]){e[0]&&e[1]?i?i.p(e,t):(i=Tb(e),i.c(),i.m(n.parentNode,n)):i&&(i.d(1),i=null)},i:e,o:e,d(e){i&&i.d(e),e&&d(n)}}}function _b(e,t,n){let i,r;const s=P();let{filter:o={}}=t,{showFilter:a=!0}=t;return e.$$set=e=>{"filter"in e&&n(4,o=e.filter),"showFilter"in e&&n(0,a=e.showFilter)},e.$$.update=()=>{16&e.$$.dirty&&n(2,i=function(e){return JSON.stringify(e,null,2)}(o)),16&e.$$.dirty&&n(1,r=Object.keys(o).length>0)},[a,r,i,function(){s("sweep")},o]}class Nb extends se{constructor(e){super(),re(this,e,_b,Ub,s,{filter:4,showFilter:0})}}class Lb{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,i,r]=n;e&&i?(console.log("Authentication successful for event:",e),this.isAuthenticated=!0,this.authPromise&&(this.authPromise.resolve(),this.authPromise=null)):e&&!i&&(console.error("Authentication failed:",r),this.authPromise&&(this.authPromise.reject(new Error(r||"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 i=["EVENT",e];this.ws.send(JSON.stringify(i));const r=this.ws.onmessage,s=setTimeout(()=>{this.ws.onmessage=r,n(new Error("Publish timeout"))},15e3);this.ws.onmessage=async i=>{try{const o=JSON.parse(i.data),[a,l,c,u]=o;if("OK"===a&&l===e.id)if(c)clearTimeout(s),this.ws.onmessage=r,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(s),this.ws.onmessage=r,n(new Error(`Publish failed: ${u}`))}else if("AUTH"===a){this.challenge=o[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(s),this.ws.onmessage=r,n(new Error(`Authentication failed: ${e.message}`))}}else await this.handleMessage(o)}catch(e){clearTimeout(s),this.ws.onmessage=r,n(e)}}})}close(){this.ws&&(this.ws.close(),this.ws=null),this.isAuthenticated=!1,this.challenge=null}getAuthenticated(){return this.isAuthenticated}}async function Ob(e,t,n,i){const r=new Lb(e,n,i);try{await r.connect();return await r.publishEvent(t)}finally{r.close()}}function Mb(e,t,n){const i=e.slice();return i[171]=t[n],i}function jb(e,t,n){const i=e.slice();return i[181]=t[n],i}function Hb(e,t,n){const i=e.slice();return i[174]=t[n],i}function Gb(e,t,n){const i=e.slice();i[174]=t[n];const r=i[52](i[174]);return i[175]=r,i}function Jb(e,t,n){const i=e.slice();return i[178]=t[n],i}function Kb(t){let n;function i(e,t){return e[1]?aA:oA}let r=i(t),s=r(t);return{c(){n=p("div"),s.c(),b(n,"class","welcome-message svelte-u3u5mw")},m(e,t){u(e,n,t),s.m(n,null)},p(e,t){r===(r=i(e))&&s?s.p(e,t):(s.d(1),s=r(e),s&&(s.c(),s.m(n,null)))},i:e,o:e,d(e){e&&d(n),s.d()}}}function Vb(e){let t,n,i=e[6],r=[];for(let t=0;t<i.length;t+=1)r[t]=mA(jb(e,i,t));const s=e=>Z(r[e],1,1,()=>{r[e]=null});return{c(){for(let e=0;e<r.length;e+=1)r[e].c();t=v()},m(e,i){for(let t=0;t<r.length;t+=1)r[t]&&r[t].m(e,i);u(e,t,i),n=!0},p(e,n){if(262260&n[0]|47104&n[1]|1703936&n[2]){let o;for(i=e[6],o=0;o<i.length;o+=1){const s=jb(e,i,o);r[o]?(r[o].p(s,n),z(r[o],1)):(r[o]=mA(s),r[o].c(),z(r[o],1),r[o].m(t.parentNode,t))}for(Y(),o=i.length;o<r.length;o+=1)s(o);W()}},i(e){if(!n){for(let e=0;e<i.length;e+=1)z(r[e]);n=!0}},o(e){r=r.filter(Boolean);for(let e=0;e<r.length;e+=1)Z(r[e]);n=!1},d(e){f(r,e),e&&d(t)}}}function qb(t){let n,r,s,o,a,l,h,g,v,w,k,C,x,S,B,Q,F,D,$=null!==t[35]&&void 0!==t[35]&&t[35]>=0||""!==t[36]&&parseInt(t[36])>=0,P=pp,R=[];for(let e=0;e<P.length;e+=1)R[e]=vA(Jb(t,P,e));let T=$&&yA(t);return{c(){n=p("div"),r=p("div"),r.innerHTML='<h3 class="svelte-u3u5mw">Event Recovery</h3> \n <p class="svelte-u3u5mw">Search and recover old versions of replaceable events</p>',s=m(),o=p("div"),a=p("div"),l=p("div"),h=p("label"),h.textContent="Select Event Kind:",g=m(),v=p("select"),w=p("option"),w.textContent="Choose a replaceable kind...";for(let e=0;e<R.length;e+=1)R[e].c();k=m(),C=p("div"),x=p("label"),x.textContent="Or enter custom kind number:",S=m(),B=p("input"),Q=m(),T&&T.c(),b(h,"for","recovery-kind"),b(h,"class","svelte-u3u5mw"),w.__value=null,w.value=w.__value,b(v,"id","recovery-kind"),b(v,"class","svelte-u3u5mw"),void 0===t[35]&&M(()=>t[116].call(v)),b(l,"class","kind-selector svelte-u3u5mw"),b(x,"for","custom-kind"),b(x,"class","svelte-u3u5mw"),b(B,"id","custom-kind"),b(B,"type","number"),b(B,"placeholder","e.g., 10001"),b(B,"min","0"),b(B,"class","svelte-u3u5mw"),b(C,"class","custom-kind-input svelte-u3u5mw"),b(a,"class","recovery-controls svelte-u3u5mw"),b(o,"class","recovery-controls-card svelte-u3u5mw"),b(n,"class","recovery-tab svelte-u3u5mw")},m(e,i){u(e,n,i),c(n,r),c(n,s),c(n,o),c(o,a),c(a,l),c(l,h),c(l,g),c(l,v),c(v,w);for(let e=0;e<R.length;e+=1)R[e]&&R[e].m(v,null);E(v,t[35],!0),c(a,k),c(a,C),c(C,x),c(C,S),c(C,B),I(B,t[36]),c(n,Q),T&&T.m(n,null),F||(D=[y(v,"change",t[116]),y(v,"change",t[50]),y(B,"input",t[117]),y(B,"input",t[51])],F=!0)},p(e,t){if(0&t){let n;for(P=pp,n=0;n<P.length;n+=1){const i=Jb(e,P,n);R[n]?R[n].p(i,t):(R[n]=vA(i),R[n].c(),R[n].m(v,null))}for(;n<R.length;n+=1)R[n].d(1);R.length=P.length}16&t[1]&&E(v,e[35]),32&t[1]&&A(B.value)!==e[36]&&I(B,e[36]),48&t[1]&&($=null!==e[35]&&void 0!==e[35]&&e[35]>=0||""!==e[36]&&parseInt(e[36])>=0),$?T?T.p(e,t):(T=yA(e),T.c(),T.m(n,null)):T&&(T.d(1),T=null)},i:e,o:e,d(e){e&&d(n),f(R,e),T&&T.d(),F=!1,i(D)}}}function Yb(e){let t,n;return t=new ob({props:{isLoggedIn:e[1],userRole:e[4],userSigner:e[13]}}),t.$on("openLoginModal",e[70]),{c(){ee(t.$$.fragment)},m(e,i){te(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),16&n[0]&&(i.userRole=e[4]),8192&n[0]&&(i.userSigner=e[13]),t.$set(i)},i(e){n||(z(t.$$.fragment,e),n=!0)},o(e){Z(t.$$.fragment,e),n=!1},d(e){ne(t,e)}}}function Wb(e){let t,n;return t=new Rb({props:{isLoggedIn:e[1],userRole:e[4],userSigner:e[13],userPubkey:e[2]}}),t.$on("openLoginModal",e[70]),{c(){ee(t.$$.fragment)},m(e,i){te(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),16&n[0]&&(i.userRole=e[4]),8192&n[0]&&(i.userSigner=e[13]),4&n[0]&&(i.userPubkey=e[2]),t.$set(i)},i(e){n||(z(t.$$.fragment,e),n=!0)},o(e){Z(t.$$.fragment,e),n=!1},d(e){ne(t,e)}}}function zb(e){let t,n,i;function r(t){e[115](t)}let s={isLoggedIn:e[1],userRole:e[4],isPolicyAdmin:JA,policyEnabled:e[8],isLoadingPolicy:e[27],policyMessage:e[28],policyMessageType:e[29],validationErrors:e[30],policyFollows:e[31]};return void 0!==e[26]&&(s.policyJson=e[26]),t=new Zv({props:s}),U.push(()=>X(t,"policyJson",r)),t.$on("loadPolicy",e[60]),t.$on("validatePolicy",e[61]),t.$on("savePolicy",e[62]),t.$on("formatJson",e[63]),t.$on("addPolicyAdmin",e[64]),t.$on("removePolicyAdmin",e[65]),t.$on("refreshFollows",e[66]),t.$on("openLoginModal",e[70]),{c(){ee(t.$$.fragment)},m(e,n){te(t,e,n),i=!0},p(e,i){const r={};2&i[0]&&(r.isLoggedIn=e[1]),16&i[0]&&(r.userRole=e[4]),256&i[0]&&(r.policyEnabled=e[8]),134217728&i[0]&&(r.isLoadingPolicy=e[27]),268435456&i[0]&&(r.policyMessage=e[28]),536870912&i[0]&&(r.policyMessageType=e[29]),1073741824&i[0]&&(r.validationErrors=e[30]),1&i[1]&&(r.policyFollows=e[31]),!n&&67108864&i[0]&&(n=!0,r.policyJson=e[26],j(()=>n=!1)),t.$set(r)},i(e){i||(z(t.$$.fragment,e),i=!0)},o(e){Z(t.$$.fragment,e),i=!1},d(e){ne(t,e)}}}function Zb(e){let t,n,i;function r(t){e[112](t)}let s={isLoggedIn:e[1],userRole:e[4],sprocketStatus:e[20],isLoadingSprocket:e[22],sprocketUploadFile:e[25],sprocketMessage:e[23],sprocketMessageType:e[24],sprocketVersions:e[21]};return void 0!==e[19]&&(s.sprocketScript=e[19]),t=new Pv({props:s}),U.push(()=>X(t,"sprocketScript",r)),t.$on("restartSprocket",e[55]),t.$on("deleteSprocket",e[56]),t.$on("sprocketFileSelect",e[67]),t.$on("uploadSprocketScript",e[68]),t.$on("saveSprocket",e[54]),t.$on("loadSprocket",e[53]),t.$on("loadVersions",e[57]),t.$on("loadVersion",e[113]),t.$on("deleteVersion",e[114]),t.$on("openLoginModal",e[70]),{c(){ee(t.$$.fragment)},m(e,n){te(t,e,n),i=!0},p(e,i){const r={};2&i[0]&&(r.isLoggedIn=e[1]),16&i[0]&&(r.userRole=e[4]),1048576&i[0]&&(r.sprocketStatus=e[20]),4194304&i[0]&&(r.isLoadingSprocket=e[22]),33554432&i[0]&&(r.sprocketUploadFile=e[25]),8388608&i[0]&&(r.sprocketMessage=e[23]),16777216&i[0]&&(r.sprocketMessageType=e[24]),2097152&i[0]&&(r.sprocketVersions=e[21]),!n&&524288&i[0]&&(n=!0,r.sprocketScript=e[19],j(()=>n=!1)),t.$set(r)},i(e){i||(z(t.$$.fragment,e),i=!0)},o(e){Z(t.$$.fragment,e),i=!1},d(e){ne(t,e)}}}function Xb(e){let t,n,i,r;const s=[QA,BA,SA],o=[];function a(e,t){return"curating"!==e[9]?0:e[1]&&"owner"===e[4]?1:2}return n=a(e),i=o[n]=s[n](e),{c(){t=p("div"),i.c(),b(t,"class","curation-view-container")},m(e,i){u(e,t,i),o[n].m(t,null),r=!0},p(e,r){let l=n;n=a(e),n===l?o[n].p(e,r):(Y(),Z(o[l],1,1,()=>{o[l]=null}),W(),i=o[n],i?i.p(e,r):(i=o[n]=s[n](e),i.c()),z(i,1),i.m(t,null))},i(e){r||(z(i),r=!0)},o(e){Z(i),r=!1},d(e){e&&d(t),o[n].d()}}}function eA(e){let t,n,i,r;const s=[$A,DA,FA],o=[];function a(e,t){return"managed"!==e[9]?0:e[1]&&"owner"===e[4]?1:2}return n=a(e),i=o[n]=s[n](e),{c(){t=p("div"),i.c(),b(t,"class","managed-acl-view svelte-u3u5mw")},m(e,i){u(e,t,i),o[n].m(t,null),r=!0},p(e,r){let l=n;n=a(e),n===l?o[n].p(e,r):(Y(),Z(o[l],1,1,()=>{o[l]=null}),W(),i=o[n],i?i.p(e,r):(i=o[n]=s[n](e),i.c()),z(i,1),i.m(t,null))},i(e){r||(z(i),r=!0)},o(e){Z(i),r=!1},d(e){e&&d(t),o[n].d()}}}function tA(e){let t,n,i;function r(t){e[111](t)}let s={userPubkey:e[2],userRole:e[4],policyEnabled:e[8],publishError:e[34]};return void 0!==e[33]&&(s.composeEventJson=e[33]),t=new Av({props:s}),U.push(()=>X(t,"composeEventJson",r)),t.$on("reformatJson",e[90]),t.$on("signEvent",e[91]),t.$on("publishEvent",e[92]),t.$on("clearError",e[93]),{c(){ee(t.$$.fragment)},m(e,n){te(t,e,n),i=!0},p(e,i){const r={};4&i[0]&&(r.userPubkey=e[2]),16&i[0]&&(r.userRole=e[4]),256&i[0]&&(r.policyEnabled=e[8]),8&i[1]&&(r.publishError=e[34]),!n&&4&i[1]&&(n=!0,r.composeEventJson=e[33],j(()=>n=!1)),t.$set(r)},i(e){i||(z(t.$$.fragment,e),i=!0)},o(e){Z(t.$$.fragment,e),i=!1},d(e){ne(t,e)}}}function nA(e){let t,n;return t=new Ow({props:{isLoggedIn:e[1],userPubkey:e[2],userSigner:e[13],currentEffectiveRole:e[10]}}),t.$on("openLoginModal",e[70]),{c(){ee(t.$$.fragment)},m(e,i){te(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),4&n[0]&&(i.userPubkey=e[2]),8192&n[0]&&(i.userSigner=e[13]),1024&n[0]&&(i.currentEffectiveRole=e[10]),t.$set(i)},i(e){n||(z(t.$$.fragment,e),n=!0)},o(e){Z(t.$$.fragment,e),n=!1},d(e){ne(t,e)}}}function iA(e){let t,n;return t=new tv({props:{isLoggedIn:e[1],userRole:e[4],userPubkey:e[2],filteredEvents:e[41],expandedEvents:e[18],isLoadingEvents:e[7],showOnlyMyEvents:GA,showFilterBuilder:e[15]}}),t.$on("scroll",e[89]),t.$on("toggleEventExpansion",e[107]),t.$on("deleteEvent",e[108]),t.$on("copyEventToClipboard",e[109]),t.$on("toggleChange",e[45]),t.$on("loadAllEvents",e[110]),t.$on("toggleFilterBuilder",e[76]),t.$on("filterApply",e[77]),t.$on("filterClear",e[78]),{c(){ee(t.$$.fragment)},m(e,i){te(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),16&n[0]&&(i.userRole=e[4]),4&n[0]&&(i.userPubkey=e[2]),1024&n[1]&&(i.filteredEvents=e[41]),262144&n[0]&&(i.expandedEvents=e[18]),128&n[0]&&(i.isLoadingEvents=e[7]),32768&n[0]&&(i.showFilterBuilder=e[15]),t.$set(i)},i(e){n||(z(t.$$.fragment,e),n=!0)},o(e){Z(t.$$.fragment,e),n=!1},d(e){ne(t,e)}}}function rA(e){let t,n;return t=new tm({props:{isLoggedIn:e[1],currentEffectiveRole:e[10],selectedFile:e[16],aclMode:e[9],importMessage:e[17]}}),t.$on("fileSelect",e[86]),t.$on("importEvents",e[87]),t.$on("openLoginModal",e[70]),{c(){ee(t.$$.fragment)},m(e,i){te(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),1024&n[0]&&(i.currentEffectiveRole=e[10]),65536&n[0]&&(i.selectedFile=e[16]),512&n[0]&&(i.aclMode=e[9]),131072&n[0]&&(i.importMessage=e[17]),t.$set(i)},i(e){n||(z(t.$$.fragment,e),n=!0)},o(e){Z(t.$$.fragment,e),n=!1},d(e){ne(t,e)}}}function sA(e){let t,n;return t=new qg({props:{isLoggedIn:e[1],currentEffectiveRole:e[10],aclMode:e[9]}}),t.$on("exportMyEvents",e[85]),t.$on("exportAllEvents",e[84]),t.$on("openLoginModal",e[70]),{c(){ee(t.$$.fragment)},m(e,i){te(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),1024&n[0]&&(i.currentEffectiveRole=e[10]),512&n[0]&&(i.aclMode=e[9]),t.$set(i)},i(e){n||(z(t.$$.fragment,e),n=!0)},o(e){Z(t.$$.fragment,e),n=!1},d(e){ne(t,e)}}}function oA(t){let n;return{c(){n=p("p"),n.textContent="Log in to access your user dashboard",b(n,"class","svelte-u3u5mw")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function aA(e){let t,n,i,r=(e[3]?.name||e[2].slice(0,8)+"...")+"";return{c(){t=p("p"),n=g("Welcome "),i=g(r),b(t,"class","svelte-u3u5mw")},m(e,r){u(e,t,r),c(t,n),c(t,i)},p(e,t){12&t[0]&&r!==(r=(e[3]?.name||e[2].slice(0,8)+"...")+"")&&k(i,r)},d(e){e&&d(t)}}}function lA(e){let t,n,r,s,o,a,l,f,h,v,w,A,I,C,E,x,S,B,Q,F,D,$=e[181].label+"",P=e[42].get(e[181].id)?.isLoading,R=!e[42].get(e[181].id)?.hasMore&&e[42].get(e[181].id)?.events?.length>0;function T(){return e[121](e[181])}function U(e,t){return 64&t[0]&&(C=null),64&t[0]&&(E=null),null==C&&(C=!!(e[42].get(e[181].id)?.events?.length>0)),C?uA:(null==E&&(E=!e[42].get(e[181].id)?.isLoading),E?cA:void 0)}w=new Nb({props:{filter:e[42].get(e[181].id)?.filter||{}}}),w.$on("sweep",function(){return e[122](e[181])});let _=U(e,[-1,-1,-1,-1,-1,-1]),N=_&&_(e),L=P&&hA(),O=R&&gA();function M(...t){return e[127](e[181],...t)}return{c(){t=p("div"),n=p("div"),r=p("h2"),s=g("🔍 "),o=g($),a=m(),l=p("button"),f=g("🔄 Refresh"),v=m(),ee(w.$$.fragment),A=m(),I=p("div"),N&&N.c(),x=m(),L&&L.c(),S=m(),O&&O.c(),B=m(),b(r,"class","svelte-u3u5mw"),b(l,"class","refresh-btn svelte-u3u5mw"),l.disabled=h=e[42].get(e[181].id)?.isLoading,b(n,"class","search-results-header svelte-u3u5mw"),b(I,"class","search-results-content svelte-u3u5mw"),b(t,"class","search-results-view svelte-u3u5mw")},m(e,i){u(e,t,i),c(t,n),c(n,r),c(r,s),c(r,o),c(n,a),c(n,l),c(l,f),c(t,v),te(w,t,null),c(t,A),c(t,I),N&&N.m(I,null),c(I,x),L&&L.m(I,null),c(I,S),O&&O.m(I,null),c(t,B),Q=!0,F||(D=[y(l,"click",T),y(I,"scroll",M)],F=!0)},p(t,n){e=t,(!Q||64&n[0])&&$!==($=e[181].label+"")&&k(o,$),(!Q||64&n[0]&&h!==(h=e[42].get(e[181].id)?.isLoading))&&(l.disabled=h);const i={};64&n[0]&&(i.filter=e[42].get(e[181].id)?.filter||{}),w.$set(i),_===(_=U(e,n))&&N?N.p(e,n):(N&&N.d(1),N=_&&_(e),N&&(N.c(),N.m(I,x))),64&n[0]&&(P=e[42].get(e[181].id)?.isLoading),P?L||(L=hA(),L.c(),L.m(I,S)):L&&(L.d(1),L=null),64&n[0]&&(R=!e[42].get(e[181].id)?.hasMore&&e[42].get(e[181].id)?.events?.length>0),R?O||(O=gA(),O.c(),O.m(I,null)):O&&(O.d(1),O=null)},i(e){Q||(z(w.$$.fragment,e),Q=!0)},o(e){Z(w.$$.fragment,e),Q=!1},d(e){e&&d(t),ne(w),N&&N.d(),L&&L.d(),O&&O.d(),F=!1,i(D)}}}function cA(t){let n;return{c(){n=p("div"),n.innerHTML='<p class="svelte-u3u5mw">No search results found.</p>',b(n,"class","no-search-results svelte-u3u5mw")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function uA(e){let t,n=e[42].get(e[181].id).events,i=[];for(let t=0;t<n.length;t+=1)i[t]=pA(Hb(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=v()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);u(e,t,n)},p(e,r){if(262228&r[0]|47104&r[1]){let s;for(n=e[42].get(e[181].id).events,s=0;s<n.length;s+=1){const o=Hb(e,n,s);i[s]?i[s].p(o,r):(i[s]=pA(o),i[s].c(),i[s].m(t.parentNode,t))}for(;s<i.length;s+=1)i[s].d(1);i.length=n.length}},d(e){f(i,e),e&&d(t)}}}function dA(e){let t,n,i;function r(){return e[123](e[174])}return{c(){t=p("button"),t.textContent="🗑️",b(t,"class","delete-btn svelte-u3u5mw")},m(e,s){u(e,t,s),n||(i=y(t,"click",w(r)),n=!0)},p(t,n){e=t},d(e){e&&d(t),n=!1,i()}}}function fA(e){let t,n,i,r,s,o,a,l,f=JSON.stringify(e[174],null,2)+"";function h(...t){return e[126](e[174],...t)}return{c(){t=p("div"),n=p("div"),i=p("pre"),r=g(f),s=m(),o=p("button"),o.textContent="📋",b(i,"class","event-json svelte-u3u5mw"),b(o,"class","copy-json-btn svelte-u3u5mw"),b(o,"title","Copy minified JSON to clipboard"),b(n,"class","json-container svelte-u3u5mw"),b(t,"class","search-result-details svelte-u3u5mw")},m(e,d){u(e,t,d),c(t,n),c(n,i),c(i,r),c(n,s),c(n,o),a||(l=y(o,"click",w(h)),a=!0)},p(t,n){e=t,64&n[0]&&f!==(f=JSON.stringify(e[174],null,2)+"")&&k(r,f)},d(e){e&&d(t),a=!1,l()}}}function pA(e){let t,n,r,s,o,a,l,f,h,v,w,A,I,C,E,x,B,Q,F,D,$,P,R,T,U,_,N=ub(e[174].pubkey)+"",L=e[174].kind+"",O=cb(e[174].kind)+"",M=fb(e[174].created_at)+"",j=db(e[174].content)+"",H=e[18].has(e[174].id),G=5!==e[174].kind&&("admin"===e[4]||"owner"===e[4]||"write"===e[4]&&e[174].pubkey&&e[174].pubkey===e[2])&&dA(e);function J(){return e[124](e[174])}function K(...t){return e[125](e[174],...t)}let V=H&&fA(e);return{c(){t=p("div"),n=p("div"),r=p("div"),r.innerHTML='<div class="avatar-placeholder svelte-u3u5mw">👤</div>',s=m(),o=p("div"),a=p("div"),l=g(N),f=m(),h=p("div"),v=p("span"),w=g(L),A=m(),I=p("span"),C=g(O),E=m(),x=p("div"),B=p("div"),Q=g(M),F=m(),D=p("div"),$=g(j),P=m(),G&&G.c(),R=m(),V&&V.c(),T=m(),b(r,"class","search-result-avatar svelte-u3u5mw"),b(a,"class","search-result-author svelte-u3u5mw"),b(v,"class","kind-number svelte-u3u5mw"),b(I,"class","kind-name svelte-u3u5mw"),b(h,"class","search-result-kind svelte-u3u5mw"),b(o,"class","search-result-info svelte-u3u5mw"),b(B,"class","event-timestamp svelte-u3u5mw"),b(D,"class","event-content-single-line svelte-u3u5mw"),b(x,"class","search-result-content svelte-u3u5mw"),b(n,"class","search-result-row svelte-u3u5mw"),b(n,"role","button"),b(n,"tabindex","0"),b(t,"class","search-result-item svelte-u3u5mw"),S(t,"expanded",e[18].has(e[174].id))},m(e,i){u(e,t,i),c(t,n),c(n,r),c(n,s),c(n,o),c(o,a),c(a,l),c(o,f),c(o,h),c(h,v),c(v,w),c(h,A),c(h,I),c(I,C),c(n,E),c(n,x),c(x,B),c(B,Q),c(x,F),c(x,D),c(D,$),c(n,P),G&&G.m(n,null),c(t,R),V&&V.m(t,null),c(t,T),U||(_=[y(n,"click",J),y(n,"keydown",K)],U=!0)},p(i,r){e=i,64&r[0]&&N!==(N=ub(e[174].pubkey)+"")&&k(l,N),64&r[0]&&L!==(L=e[174].kind+"")&&k(w,L),64&r[0]&&O!==(O=cb(e[174].kind)+"")&&k(C,O),64&r[0]&&M!==(M=fb(e[174].created_at)+"")&&k(Q,M),64&r[0]&&j!==(j=db(e[174].content)+"")&&k($,j),5!==e[174].kind&&("admin"===e[4]||"owner"===e[4]||"write"===e[4]&&e[174].pubkey&&e[174].pubkey===e[2])?G?G.p(e,r):(G=dA(e),G.c(),G.m(n,null)):G&&(G.d(1),G=null),262208&r[0]&&(H=e[18].has(e[174].id)),H?V?V.p(e,r):(V=fA(e),V.c(),V.m(t,T)):V&&(V.d(1),V=null),262208&r[0]|2048&r[1]&&S(t,"expanded",e[18].has(e[174].id))},d(e){e&&d(t),G&&G.d(),V&&V.d(),U=!1,i(_)}}}function hA(e){let t;return{c(){t=p("div"),t.innerHTML='<div class="loading-spinner svelte-u3u5mw"></div> \n <p class="svelte-u3u5mw">Searching...</p>',b(t,"class","loading-search-results svelte-u3u5mw")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function gA(e){let t;return{c(){t=p("div"),t.innerHTML='<p class="svelte-u3u5mw">No more search results to load.</p>',b(t,"class","end-of-search-results svelte-u3u5mw")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function mA(e){let t,n,i=e[181].id===e[5]&&lA(e);return{c(){i&&i.c(),t=v()},m(e,r){i&&i.m(e,r),u(e,t,r),n=!0},p(e,n){e[181].id===e[5]?i?(i.p(e,n),96&n[0]&&z(i,1)):(i=lA(e),i.c(),z(i,1),i.m(t.parentNode,t)):i&&(Y(),Z(i,1,1,()=>{i=null}),W())},i(e){n||(z(i),n=!0)},o(e){Z(i),n=!1},d(e){i&&i.d(e),e&&d(t)}}}function vA(t){let n,i,r=t[178].label+"";return{c(){n=p("option"),i=g(r),n.__value=t[178].value,n.value=n.__value},m(e,t){u(e,n,t),c(n,i)},p:e,d(e){e&&d(n)}}}function yA(e){let t;function n(e,t){return e[38]?AA:0===e[37].length?bA:wA}let i=n(e),r=i(e);return{c(){t=p("div"),r.c(),b(t,"class","recovery-results svelte-u3u5mw")},m(e,n){u(e,t,n),r.m(t,null)},p(e,s){i===(i=n(e))&&r?r.p(e,s):(r.d(1),r=i(e),r&&(r.c(),r.m(t,null)))},d(e){e&&d(t),r.d()}}}function wA(e){let t,n,i,r=e[37],s=[];for(let t=0;t<r.length;t+=1)s[t]=EA(Gb(e,r,t));let o=e[39]&&xA(e);return{c(){t=p("div");for(let e=0;e<s.length;e+=1)s[e].c();n=m(),o&&o.c(),i=v(),b(t,"class","events-list svelte-u3u5mw")},m(e,r){u(e,t,r);for(let e=0;e<s.length;e+=1)s[e]&&s[e].m(t,null);u(e,n,r),o&&o.m(e,r),u(e,i,r)},p(e,n){if(1024&n[0]|2498624&n[1]){let i;for(r=e[37],i=0;i<r.length;i+=1){const o=Gb(e,r,i);s[i]?s[i].p(o,n):(s[i]=EA(o),s[i].c(),s[i].m(t,null))}for(;i<s.length;i+=1)s[i].d(1);s.length=r.length}e[39]?o?o.p(e,n):(o=xA(e),o.c(),o.m(i.parentNode,i)):o&&(o.d(1),o=null)},d(e){e&&d(t),f(s,e),e&&d(n),o&&o.d(e),e&&d(i)}}}function bA(t){let n;return{c(){n=p("div"),n.textContent="No events found for this kind",b(n,"class","no-events svelte-u3u5mw")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function AA(t){let n;return{c(){n=p("div"),n.textContent="Loading events...",b(n,"class","loading svelte-u3u5mw")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function kA(e){let t;return{c(){t=g("Current Version")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function IA(e){let t,n,i,r,s;function o(){return e[118](e[174])}let a="read"!==e[10]&&CA(e);return{c(){t=p("button"),t.textContent="🌐 Repost to All",n=m(),a&&a.c(),i=v(),b(t,"class","repost-all-button svelte-u3u5mw")},m(e,l){u(e,t,l),u(e,n,l),a&&a.m(e,l),u(e,i,l),r||(s=y(t,"click",o),r=!0)},p(t,n){"read"!==(e=t)[10]?a?a.p(e,n):(a=CA(e),a.c(),a.m(i.parentNode,i)):a&&(a.d(1),a=null)},d(e){e&&d(t),e&&d(n),a&&a.d(e),e&&d(i),r=!1,s()}}}function CA(e){let t,n,i;function r(){return e[119](e[174])}return{c(){t=p("button"),t.textContent="🔄 Repost",b(t,"class","repost-button svelte-u3u5mw")},m(e,s){u(e,t,s),n||(i=y(t,"click",r),n=!0)},p(t,n){e=t},d(e){e&&d(t),n=!1,i()}}}function EA(e){let t,n,i,r,s,o,a,l,f,h,v,A,I,C,E,x,B,Q,F=new Date(1e3*e[174].created_at).toLocaleString()+"",D=JSON.stringify(e[174],null,2)+"",$=e[175]&&kA(),P=!e[175]&&IA(e);function R(...t){return e[120](e[174],...t)}return{c(){t=p("div"),n=p("div"),i=p("div"),r=p("span"),$&&$.c(),s=m(),o=p("span"),a=g(F),l=m(),f=p("div"),P&&P.c(),h=m(),v=p("button"),v.textContent="📋 Copy JSON",A=m(),I=p("div"),C=p("pre"),E=g(D),x=m(),b(r,"class","event-kind svelte-u3u5mw"),b(o,"class","event-timestamp svelte-u3u5mw"),b(i,"class","event-header-left svelte-u3u5mw"),b(v,"class","copy-json-btn svelte-u3u5mw"),b(f,"class","event-header-actions svelte-u3u5mw"),b(n,"class","event-header svelte-u3u5mw"),b(C,"class","event-json svelte-u3u5mw"),b(I,"class","event-content svelte-u3u5mw"),b(t,"class","event-item svelte-u3u5mw"),S(t,"old-version",!e[175])},m(e,d){u(e,t,d),c(t,n),c(n,i),c(i,r),$&&$.m(r,null),c(i,s),c(i,o),c(o,a),c(n,l),c(n,f),P&&P.m(f,null),c(f,h),c(f,v),c(t,A),c(t,I),c(I,C),c(C,E),c(t,x),B||(Q=y(v,"click",w(R)),B=!0)},p(n,i){(e=n)[175]?$||($=kA(),$.c(),$.m(r,null)):$&&($.d(1),$=null),64&i[1]&&F!==(F=new Date(1e3*e[174].created_at).toLocaleString()+"")&&k(a,F),e[175]?P&&(P.d(1),P=null):P?P.p(e,i):(P=IA(e),P.c(),P.m(f,h)),64&i[1]&&D!==(D=JSON.stringify(e[174],null,2)+"")&&k(E,D),2097216&i[1]&&S(t,"old-version",!e[175])},d(e){e&&d(t),$&&$.d(),P&&P.d(),B=!1,Q()}}}function xA(e){let t,n,i,r;return{c(){t=p("button"),n=g("Load More Events"),b(t,"class","load-more svelte-u3u5mw"),t.disabled=e[38]},m(s,o){u(s,t,o),c(t,n),i||(r=y(t,"click",e[47]),i=!0)},p(e,n){128&n[1]&&(t.disabled=e[38])},d(e){e&&d(t),i=!1,r()}}}function SA(t){let n,i,r,s,o,a;return{c(){n=p("div"),i=p("p"),i.textContent="Please log in with owner permissions to access\n curation configuration.",r=m(),s=p("button"),s.textContent="Log In",b(s,"class","login-btn svelte-u3u5mw"),b(n,"class","access-denied")},m(e,l){u(e,n,l),c(n,i),c(n,r),c(n,s),o||(a=y(s,"click",t[70]),o=!0)},p:e,i:e,o:e,d(e){e&&d(n),o=!1,a()}}}function BA(e){let t,n;return t=new Ky({props:{userSigner:e[13],userPubkey:e[2]}}),{c(){ee(t.$$.fragment)},m(e,i){te(t,e,i),n=!0},p(e,n){const i={};8192&n[0]&&(i.userSigner=e[13]),4&n[0]&&(i.userPubkey=e[2]),t.$set(i)},i(e){n||(z(t.$$.fragment,e),n=!0)},o(e){Z(t.$$.fragment,e),n=!1},d(e){ne(t,e)}}}function QA(t){let n,i,r,s,o,a,l,f,h,v,y,w=(t[9]||"unknown")+"";return{c(){n=p("div"),i=p("h3"),i.textContent="Curating Mode Not Active",r=m(),s=p("p"),s.textContent='To use the Curation interface, you need to set\n the ACL mode to "curating" in your relay\n configuration.',o=m(),a=p("p"),l=g("Current ACL mode: "),f=p("strong"),h=g(w),v=m(),y=p("p"),y.innerHTML='Please set <code class="svelte-u3u5mw">ORLY_ACL_MODE=curating</code> in your\n environment variables and restart the relay.',b(i,"class","svelte-u3u5mw"),b(s,"class","svelte-u3u5mw"),b(a,"class","svelte-u3u5mw"),b(y,"class","svelte-u3u5mw"),b(n,"class","acl-mode-warning svelte-u3u5mw")},m(e,t){u(e,n,t),c(n,i),c(n,r),c(n,s),c(n,o),c(n,a),c(a,l),c(a,f),c(f,h),c(n,v),c(n,y)},p(e,t){512&t[0]&&w!==(w=(e[9]||"unknown")+"")&&k(h,w)},i:e,o:e,d(e){e&&d(n)}}}function FA(t){let n,i,r,s,o,a;return{c(){n=p("div"),i=p("p"),i.textContent="Please log in with owner permissions to access\n managed ACL configuration.",r=m(),s=p("button"),s.textContent="Log In",b(s,"class","login-btn svelte-u3u5mw"),b(n,"class","access-denied")},m(e,l){u(e,n,l),c(n,i),c(n,r),c(n,s),o||(a=y(s,"click",t[70]),o=!0)},p:e,i:e,o:e,d(e){e&&d(n),o=!1,a()}}}function DA(e){let t,n;return t=new xg({props:{userSigner:e[13],userPubkey:e[2]}}),{c(){ee(t.$$.fragment)},m(e,i){te(t,e,i),n=!0},p(e,n){const i={};8192&n[0]&&(i.userSigner=e[13]),4&n[0]&&(i.userPubkey=e[2]),t.$set(i)},i(e){n||(z(t.$$.fragment,e),n=!0)},o(e){Z(t.$$.fragment,e),n=!1},d(e){ne(t,e)}}}function $A(t){let n,i,r,s,o,a,l,f,h,v,y,w=(t[9]||"unknown")+"";return{c(){n=p("div"),i=p("h3"),i.textContent="⚠️ Managed ACL Mode Not Active",r=m(),s=p("p"),s.textContent='To use the Managed ACL interface, you need to set\n the ACL mode to "managed" in your relay\n configuration.',o=m(),a=p("p"),l=g("Current ACL mode: "),f=p("strong"),h=g(w),v=m(),y=p("p"),y.innerHTML='Please set <code class="svelte-u3u5mw">ORLY_ACL_MODE=managed</code> in your\n environment variables and restart the relay.',b(i,"class","svelte-u3u5mw"),b(s,"class","svelte-u3u5mw"),b(a,"class","svelte-u3u5mw"),b(y,"class","svelte-u3u5mw"),b(n,"class","acl-mode-warning svelte-u3u5mw")},m(e,t){u(e,n,t),c(n,i),c(n,r),c(n,s),c(n,o),c(n,a),c(a,l),c(a,f),c(f,h),c(n,v),c(n,y)},p(e,t){512&t[0]&&w!==(w=(e[9]||"unknown")+"")&&k(h,w)},i:e,o:e,d(e){e&&d(n)}}}function PA(e){let t,n,r,s,o,a,l,f,h,g;function v(e,t){return e[3]?TA:e[1]&&e[2]?RA:void 0}let A=v(e),k=A&&A(e);return{c(){t=p("div"),n=p("div"),r=p("div"),s=p("h2"),s.textContent="Settings",o=m(),a=p("button"),a.textContent="✕",l=m(),f=p("div"),k&&k.c(),b(s,"class","svelte-u3u5mw"),b(a,"class","close-btn svelte-u3u5mw"),b(r,"class","drawer-header svelte-u3u5mw"),b(f,"class","drawer-content"),b(n,"class","settings-drawer svelte-u3u5mw"),S(n,"dark-theme",e[0]),b(t,"class","drawer-overlay svelte-u3u5mw"),b(t,"role","button"),b(t,"tabindex","0")},m(i,d){u(i,t,d),c(t,n),c(n,r),c(r,s),c(r,o),c(r,a),c(n,l),c(n,f),k&&k.m(f,null),h||(g=[y(a,"click",e[75]),y(n,"click",w(e[102])),y(n,"keydown",w(e[103])),y(t,"click",e[75]),y(t,"keydown",e[129])],h=!0)},p(e,t){A===(A=v(e))&&k?k.p(e,t):(k&&k.d(1),k=A&&A(e),k&&(k.c(),k.m(f,null))),1&t[0]&&S(n,"dark-theme",e[0])},d(e){e&&d(t),k&&k.d(),h=!1,i(g)}}}function RA(e){let t,n,r,s,o,a,l,f,h,v,w,A,I,C,E,x,S,B=e[2].slice(0,16)+"",Q=e[2].slice(-8)+"";return{c(){t=p("div"),n=p("button"),n.textContent="Log out",r=m(),s=p("h3"),s.textContent="Profile Loading",o=m(),a=p("p"),a.textContent="Your profile metadata is being loaded...",l=m(),f=p("button"),f.textContent="Retry Loading Profile",h=m(),v=p("div"),w=p("strong"),w.textContent="Public Key:",A=m(),I=g(B),C=g("..."),E=g(Q),b(n,"class","logout-btn floating svelte-u3u5mw"),b(s,"class","svelte-u3u5mw"),b(a,"class","svelte-u3u5mw"),b(f,"class","retry-profile-btn svelte-u3u5mw"),b(v,"class","user-pubkey-display svelte-u3u5mw"),b(t,"class","profile-loading-section svelte-u3u5mw")},m(i,d){u(i,t,d),c(t,n),c(t,r),c(t,s),c(t,o),c(t,a),c(t,l),c(t,f),c(t,h),c(t,v),c(v,w),c(v,A),c(v,I),c(v,C),c(v,E),x||(S=[y(n,"click",e[72]),y(f,"click",e[83])],x=!0)},p(e,t){4&t[0]&&B!==(B=e[2].slice(0,16)+"")&&k(I,B),4&t[0]&&Q!==(Q=e[2].slice(-8)+"")&&k(E,Q)},d(e){e&&d(t),x=!1,i(S)}}}function TA(e){let t,n,i,r,s,o,a,l,f,h,w,A,I,C,E,x=(e[3].name||"Unknown User")+"",S=e[3].banner&&UA(e);function B(e,t){return e[3].picture?NA:_A}let Q=B(e),F=Q(e),D=e[3].nip05&&LA(e),$=e[3].about&&OA(e),P=e[4]&&"read"!==e[4]&&MA(e);return{c(){t=p("div"),n=p("div"),S&&S.c(),i=m(),r=p("button"),r.textContent="Log out",s=m(),F.c(),o=m(),a=p("div"),l=p("h3"),f=g(x),h=m(),D&&D.c(),w=m(),$&&$.c(),A=m(),P&&P.c(),I=v(),b(r,"class","logout-btn floating svelte-u3u5mw"),b(l,"class","profile-username svelte-u3u5mw"),b(a,"class","name-row svelte-u3u5mw"),b(n,"class","profile-hero svelte-u3u5mw"),b(t,"class","profile-section svelte-u3u5mw")},m(d,p){u(d,t,p),c(t,n),S&&S.m(n,null),c(n,i),c(n,r),c(n,s),F.m(n,null),c(n,o),c(n,a),c(a,l),c(l,f),c(a,h),D&&D.m(a,null),c(t,w),$&&$.m(t,null),u(d,A,p),P&&P.m(d,p),u(d,I,p),C||(E=y(r,"click",e[72]),C=!0)},p(e,r){e[3].banner?S?S.p(e,r):(S=UA(e),S.c(),S.m(n,i)):S&&(S.d(1),S=null),Q===(Q=B(e))&&F?F.p(e,r):(F.d(1),F=Q(e),F&&(F.c(),F.m(n,o))),8&r[0]&&x!==(x=(e[3].name||"Unknown User")+"")&&k(f,x),e[3].nip05?D?D.p(e,r):(D=LA(e),D.c(),D.m(a,null)):D&&(D.d(1),D=null),e[3].about?$?$.p(e,r):($=OA(e),$.c(),$.m(t,null)):$&&($.d(1),$=null),e[4]&&"read"!==e[4]?P?P.p(e,r):(P=MA(e),P.c(),P.m(I.parentNode,I)):P&&(P.d(1),P=null)},d(e){e&&d(t),S&&S.d(),F.d(),D&&D.d(),$&&$.d(),e&&d(A),P&&P.d(e),e&&d(I),C=!1,E()}}}function UA(e){let t,n;return{c(){t=p("img"),a(t.src,n=e[3].banner)||b(t,"src",n),b(t,"alt","Profile banner"),b(t,"class","profile-banner svelte-u3u5mw")},m(e,n){u(e,t,n)},p(e,i){8&i[0]&&!a(t.src,n=e[3].banner)&&b(t,"src",n)},d(e){e&&d(t)}}}function _A(t){let n;return{c(){n=p("div"),n.textContent="👤",b(n,"class","profile-avatar-placeholder overlap svelte-u3u5mw")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function NA(e){let t,n;return{c(){t=p("img"),a(t.src,n=e[3].picture)||b(t,"src",n),b(t,"alt","User avatar"),b(t,"class","profile-avatar overlap svelte-u3u5mw")},m(e,n){u(e,t,n)},p(e,i){8&i[0]&&!a(t.src,n=e[3].picture)&&b(t,"src",n)},d(e){e&&d(t)}}}function LA(e){let t,n,i=e[3].nip05+"";return{c(){t=p("span"),n=g(i),b(t,"class","profile-nip05-inline svelte-u3u5mw")},m(e,i){u(e,t,i),c(t,n)},p(e,t){8&t[0]&&i!==(i=e[3].nip05+"")&&k(n,i)},d(e){e&&d(t)}}}function OA(e){let t,n;return{c(){t=p("div"),n=p("p"),b(n,"class","profile-about svelte-u3u5mw"),b(t,"class","about-card svelte-u3u5mw")},m(i,r){u(i,t,r),c(t,n),n.innerHTML=e[40]},p(e,t){512&t[1]&&(n.innerHTML=e[40])},d(e){e&&d(t)}}}function MA(e){let t,n,i,r,s,o,a=e[95](),l=[];for(let t=0;t<a.length;t+=1)l[t]=jA(Mb(e,a,t));return{c(){t=p("div"),n=p("h3"),n.textContent="View as Role",i=m(),r=p("p"),r.textContent="See the interface as it appears for different\n permission levels:",s=m(),o=p("div");for(let e=0;e<l.length;e+=1)l[e].c();b(n,"class","svelte-u3u5mw"),b(r,"class","svelte-u3u5mw"),b(o,"class","radio-group svelte-u3u5mw"),b(t,"class","view-as-section svelte-u3u5mw")},m(e,a){u(e,t,a),c(t,n),c(t,i),c(t,r),c(t,s),c(t,o);for(let e=0;e<l.length;e+=1)l[e]&&l[e].m(o,null)},p(e,t){if(1040&t[0]|6&t[3]){let n;for(a=e[95](),n=0;n<a.length;n+=1){const i=Mb(e,a,n);l[n]?l[n].p(i,t):(l[n]=jA(i),l[n].c(),l[n].m(o,null))}for(;n<l.length;n+=1)l[n].d(1);l.length=a.length}},d(e){e&&d(t),f(l,e)}}}function jA(e){let t,n,i,r,s,o,a,l,f,h=e[171].charAt(0).toUpperCase()+e[171].slice(1)+"",v=e[171]===e[4]?" (Default)":"";function w(){return e[128](e[171])}return{c(){t=p("label"),n=p("input"),r=m(),s=g(h),o=g(v),a=m(),b(n,"type","radio"),b(n,"name","viewAsRole"),n.value=e[171],n.checked=i=e[10]===e[171],b(n,"class","svelte-u3u5mw"),b(t,"class","radio-label svelte-u3u5mw")},m(e,i){u(e,t,i),c(t,n),c(t,r),c(t,s),c(t,o),c(t,a),l||(f=y(n,"change",w),l=!0)},p(t,r){e=t,1024&r[0]&&i!==(i=e[10]===e[171])&&(n.checked=i),16&r[0]&&v!==(v=e[171]===e[4]?" (Default)":"")&&k(o,v)},d(e){e&&d(t),l=!1,f()}}}function HA(e){let t,n,i,r,s,o,a,l,f,h,g,v,y,w;t=new Rg({props:{isDarkTheme:e[0],isLoggedIn:e[1],userRole:e[4],currentEffectiveRole:e[10],userProfile:e[3],userPubkey:e[2]}}),t.$on("openSettingsDrawer",e[74]),t.$on("openLoginModal",e[70]),r=new Mg({props:{isDarkTheme:e[0],tabs:e[11],selectedTab:e[5],version:e[32]}}),r.$on("selectTab",e[105]),r.$on("closeSearchTab",e[106]);const A=[sA,rA,iA,nA,tA,eA,Xb,Zb,zb,Wb,Yb,qb,Vb,Kb],k=[];function I(e,t){return 96&t[0]&&(a=null),"export"===e[5]?0:"import"===e[5]?1:"events"===e[5]?2:"blossom"===e[5]?3:"compose"===e[5]?4:"managed-acl"===e[5]?5:"curation"===e[5]?6:"sprocket"===e[5]?7:"policy"===e[5]?8:"relay-connect"===e[5]?9:"logs"===e[5]?10:"recovery"===e[5]?11:(null==a&&(a=!!e[6].some(e[104])),a?12:13)}l=I(e,[-1,-1,-1,-1,-1,-1]),f=k[l]=A[l](e);let C=e[14]&&PA(e);function E(t){e[130](t)}let x={isDarkTheme:e[0]};return void 0!==e[12]&&(x.showModal=e[12]),v=new Th({props:x}),U.push(()=>X(v,"showModal",E)),v.$on("login",e[71]),v.$on("close",e[73]),{c(){ee(t.$$.fragment),n=m(),i=p("div"),ee(r.$$.fragment),s=m(),o=p("main"),f.c(),h=m(),C&&C.c(),g=m(),ee(v.$$.fragment),b(o,"class","main-content svelte-u3u5mw"),b(i,"class","app-container svelte-u3u5mw"),S(i,"dark-theme",e[0])},m(e,a){te(t,e,a),u(e,n,a),u(e,i,a),te(r,i,null),c(i,s),c(i,o),k[l].m(o,null),u(e,h,a),C&&C.m(e,a),u(e,g,a),te(v,e,a),w=!0},p(e,n){const s={};1&n[0]&&(s.isDarkTheme=e[0]),2&n[0]&&(s.isLoggedIn=e[1]),16&n[0]&&(s.userRole=e[4]),1024&n[0]&&(s.currentEffectiveRole=e[10]),8&n[0]&&(s.userProfile=e[3]),4&n[0]&&(s.userPubkey=e[2]),t.$set(s);const a={};1&n[0]&&(a.isDarkTheme=e[0]),2048&n[0]&&(a.tabs=e[11]),32&n[0]&&(a.selectedTab=e[5]),2&n[1]&&(a.version=e[32]),r.$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}),W(),f=k[l],f?f.p(e,n):(f=k[l]=A[l](e),f.c()),z(f,1),f.m(o,null)),(!w||1&n[0])&&S(i,"dark-theme",e[0]),e[14]?C?C.p(e,n):(C=PA(e),C.c(),C.m(g.parentNode,g)):C&&(C.d(1),C=null);const u={};1&n[0]&&(u.isDarkTheme=e[0]),!y&&4096&n[0]&&(y=!0,u.showModal=e[12],j(()=>y=!1)),v.$set(u)},i(e){w||(z(t.$$.fragment,e),z(r.$$.fragment,e),z(f),z(v.$$.fragment,e),w=!0)},o(e){Z(t.$$.fragment,e),Z(r.$$.fragment,e),Z(f),Z(v.$$.fragment,e),w=!1},d(e){ne(t,e),e&&d(n),e&&d(i),ne(r),k[l].d(),e&&d(h),C&&C.d(e),e&&d(g),ne(v,e)}}}let GA=!1,JA=!1;function KA(e,t,n){let i,r,s,o,a;"undefined"!=typeof window&&(window.debugIndexedDB=Rp);let l=!1,c=!1,u=!1,d="",f="",p=null,h="",g=null,m=!1,v=localStorage.getItem("selectedTab")||"export",y=!1,w={},b=[],k=[],I=null,C="",E=new Set,S=!1,B=!0,Q=null,F="",D=new Map,$=[],P=0,T=[],U=!0,_=null,N="",L=null,O=[],M=!1,j="",H="info",G=!1,J=null,K="",V=!1,q=!1,Y="",W="info",z=[],Z=[],X=!1,ee="",te="",ne="",ie="",re=null,se="",oe=[],ae=!1,le=!0,ce=null;function ue(e){E.has(e)?E.delete(e):E.add(e),n(18,E)}async function de(e,t){const n=JSON.stringify(e),i=await pb(n);hb(t.target.closest(".copy-json-btn"),i),i||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"===h||"owner"===h||"write"===h&&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 i={kind:5,created_at:Math.floor(Date.now()/1e3),tags:[["e",e]],content:""};console.log("Created delete event template:",i),console.log("User pubkey:",d),console.log("Target event:",t),console.log("Target event pubkey:",t.pubkey);const r=await g.signEvent(i);console.log("Signed delete event:",r),console.log("Signed delete event pubkey:",r.pubkey),console.log("Delete event tags:",r.tags);const s=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`;try{const e=await Ob(s,r,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 o=t.pubkey&&t.pubkey===d;if(o){const t=await vp.publish(r);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 Fp(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 Dp(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(96,k=k.filter(t=>t.id!==e)),T=T.filter(t=>t.id!==e),$=$.filter(t=>t.id!==e);for(const[t,n]of D)n.events&&(n.events=n.events.filter(t=>t.id!==e),D.set(t,n));me(),console.log("Reloading events to show delete event...");const i=GA&&u&&d?[d]:null;await Ue(!0,i),alert(`Event deleted successfully (accepted by ${t.okCount} relay(s))`)}}else{const t=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`,i=new mp;await i.connectToRelay(t);const s=await i.publish(r);if(console.log("Delete event published to local relay only:",s),!(s.success&&s.okCount>0))throw new Error("Local relay did not accept the delete event");{await new Promise(e=>setTimeout(e,2e3));try{const t=await Fp(e,{timeout:5e3});t?(console.warn("Event still exists after deletion attempt:",t),alert(`Warning: Delete event was accepted by ${s.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 Dp(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(96,k=k.filter(t=>t.id!==e)),T=T.filter(t=>t.id!==e),$=$.filter(t=>t.id!==e);for(const[t,n]of D)n.events&&(n.events=n.events.filter(t=>t.id!==e),D.set(t,n));me(),console.log("Reloading events to show delete event...");const t=GA&&u&&d?[d]:null;await Ue(!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 pe(){const e=se?parseInt(se):re;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(38,ae=!0);try{const t=[{kinds:[e],authors:[d],limit:100}];ce&&(t[0].until=ce),console.log("Recovery filters:",t);const i=await Pp(t,{timeout:3e4,cacheFirst:!0});console.log("Recovery events received:",i.length),console.log("Recovery events kinds:",i.map(e=>e.kind)),n(37,oe=ce?[...oe,...i]:i),i.length>0?(ce=Math.min(...i.map(e=>e.created_at)),n(39,le=100===i.length)):n(39,le=!1)}catch(e){console.error("Failed to load recovery events:",e)}finally{n(38,ae=!1)}}else console.log("Not logged in, cannot load recovery events")}async function he(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 i={...e};if(i.created_at=Math.floor(Date.now()/1e3),i.id="",i.sig="",e.kind>=3e4&&e.kind<=39999){const t=e.tags.find(e=>"d"===e[0]);t&&(i.tags=i.tags.filter(e=>"d"!==e[0]),i.tags.push(t))}if(g){const e=await g.signEvent(i);console.log("Signed event for repost:",e);const r=await vp.publish(e,[t]);console.log("Repost publish result:",r),r.success&&r.okCount>0?(alert("Event reposted successfully!"),n(39,le=!1),await pe()):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 Ep([{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],i=e.length>=3?e[2]:null;i&&"write"!==i||n.push(t)}return console.log("Found write relays:",n),n}catch(e){return console.error("Error fetching user write relays:",e),[]}}(),i=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`,r=[i,...t.filter(e=>e!==i)];1===r.length&&alert("No write relays found in your relay list. Only posting to local relay."),console.log("Reposting event to all relays:",r,e);const s={...e};if(s.created_at=Math.floor(Date.now()/1e3),s.id="",s.sig="",e.kind>=3e4&&e.kind<=39999){const t=e.tags.find(e=>"d"===e[0]);t&&(s.tags=s.tags.filter(e=>"d"!==e[0]),s.tags.push(t))}if(g){const e=await g.signEvent(s);console.log("Signed event for repost to all:",e);const t=await vp.publish(e,r);console.log("Repost to all publish result:",t),t.success&&t.okCount>0?(alert(`Event reposted successfully to ${r.length} relays!`),n(39,le=!1),await pe()):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(),Re()),function(){if("undefined"==typeof localStorage)return;try{const t=localStorage.getItem("app_state");if(t){const i=JSON.parse(t);i.selectedTab&&Ee.some(e=>e.id===i.selectedTab)&&n(5,v=i.selectedTab),i.expandedEvents&&n(18,E=new Set(i.expandedEvents)),i.globalEventsCache&&($=i.globalEventsCache),i.globalCacheTimestamp&&(P=i.globalCacheTimestamp),void 0!==i.hasMoreEvents&&(B=i.hasMoreEvents),i.oldestEventTimestamp&&(Q=i.oldestEventTimestamp),void 0!==i.hasMoreMyEvents&&(U=i.hasMoreMyEvents),i.oldestMyEventTimestamp&&(_=i.oldestMyEventTimestamp),$.length>0&&((e=P)&&Date.now()-e<gp)&&n(96,k=$)}}catch(e){console.error("Failed to load persistent state:",e)}var e}(),async function(){try{const e=await fetch("/api/sprocket/config",{method:"GET",headers:{"Content-Type":"application/json"}});if(e.ok){const t=await e.json();n(98,G=t.enabled)}}catch(e){console.error("Error loading sprocket config:",e)}}(),async function(){try{const e=await lb();n(99,X=e.enabled)}catch(e){console.error("Error loading NRC config:",e)}}(),async function(){try{const e=await fetch("/api/policy/config",{method:"GET",headers:{"Content-Type":"application/json"}});if(e.ok){const t=await e.json();n(8,V=t.enabled||!1)}}catch(e){console.error("Error loading policy config:",e),n(8,V=!1)}}(),async function(){try{const e=await async function(){try{const e=await fetch(window.location.origin,{headers:{Accept:"application/nostr+json"}});if(e.ok)return await e.json()}catch(e){console.error("Error fetching relay info:",e)}return null}();e&&e.version&&n(32,te=e.version)}catch(e){console.error("Error fetching relay version:",e)}}()}function me(){if("undefined"==typeof localStorage)return;const e={selectedTab:v,expandedEvents:Array.from(E),globalEventsCache:$,globalCacheTimestamp:P,hasMoreEvents:B,oldestEventTimestamp:Q};localStorage.setItem("app_state",JSON.stringify(e))}function ve(e){$=e.sort((e,t)=>t.created_at-e.created_at),P=Date.now(),me()}async function ye(){if(u&&"owner"===h&&G)try{n(22,M=!0);const e=await fetch("/api/sprocket/status",{method:"GET",headers:{Authorization:`Nostr ${await Oe("GET","/api/sprocket/status")}`,"Content-Type":"application/json"}});e.ok?n(20,L=await e.json()):ke("Failed to load sprocket status","error")}catch(e){ke(`Error loading sprocket status: ${e.message}`,"error")}finally{n(22,M=!1)}}async function we(){if(u&&"owner"===h)try{n(22,M=!0);const e=await fetch("/api/sprocket/versions",{method:"GET",headers:{Authorization:`Nostr ${await Oe("GET","/api/sprocket/versions")}`,"Content-Type":"application/json"}});e.ok?n(21,O=await e.json()):ke("Failed to load versions","error")}catch(e){ke(`Error loading versions: ${e.message}`,"error")}finally{n(22,M=!1)}}async function be(e){u&&"owner"===h&&(n(19,N=e.content),ke(`Loaded version: ${e.name}`,"success"))}async function Ae(e){if(u&&"owner"===h&&confirm(`Are you sure you want to delete version ${e}?`))try{n(22,M=!0);const t=await fetch("/api/sprocket/delete-version",{method:"POST",headers:{Authorization:`Nostr ${await Oe("POST","/api/sprocket/delete-version")}`,"Content-Type":"application/json"},body:JSON.stringify({filename:e})});if(t.ok)ke(`Version ${e} deleted successfully`,"success"),await we();else{ke(`Failed to delete version: ${await t.text()}`,"error")}}catch(e){ke(`Error deleting version: ${e.message}`,"error")}finally{n(22,M=!1)}}function ke(e,t="info"){n(23,j=e),n(24,H=t),setTimeout(()=>{n(23,j="")},5e3)}function Ie(e,t="info"){n(28,Y=e),n(29,W=t),"error"!==t&&setTimeout(()=>{n(28,Y="")},5e3)}async function Ce(){if(n(30,z=[]),!K.trim())return n(30,z=["Policy JSON is empty"]),Ie("Validation failed","error"),!1;try{const e=JSON.parse(K);if("object"!=typeof e||null===e)return n(30,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(30,z=[`JSON parse error: ${e.message}`]),Ie("Invalid JSON syntax","error"),!1}}const Ee=[{id:"export",icon:"📤",label:"Export"},{id:"import",icon:"💾",label:"Import",requiresAdmin:!0},{id:"events",icon:"📡",label:"Events"},{id:"blossom",icon:"🌸",label:"Blossom"},{id:"compose",icon:"✏️",label:"Compose",requiresWrite:!0},{id:"recovery",icon:"🔄",label:"Recovery"},{id:"managed-acl",icon:"🛡️",label:"Managed ACL",requiresOwner:!0},{id:"curation",icon:"📋",label:"Curation",requiresOwner:!0},{id:"sprocket",icon:"⚙️",label:"Sprocket",requiresOwner:!0},{id:"policy",icon:"📜",label:"Policy",requiresOwner:!0},{id:"relay-connect",icon:"🔗",label:"Relay Connect",requiresOwner:!0},{id:"logs",icon:"📋",label:"Logs",requiresOwner:!0}];function xe(e){n(5,v=e),"sprocket"===e&&u&&"owner"===h&&G&&(ye(),we()),me()}function Se(){n(14,m=!1)}function Be(e){Qe(e)}function Qe(e){n(6,b=b.filter(t=>t.id!==e)),D.delete(e),v===e&&n(5,v="export")}async function Fe(e,t=!0){const n=D.get(e);if(n&&!n.isLoading){n.isLoading=!0,D.set(e,n);try{const i={...n.filter};!t&&n.oldestTimestamp&&(i.until=n.oldestTimestamp),t||(i.limit=200),console.log("Loading search results with filter:",i);const r=await Qp([i],{timeout:3e4});if(console.log("Received search results:",r.length,"events"),n.events=t?r.sort((e,t)=>t.created_at-e.created_at):[...n.events,...r].sort((e,t)=>t.created_at-e.created_at),r.length>0){const e=Math.min(...r.map(e=>e.created_at));(!n.oldestTimestamp||e<n.oldestTimestamp)&&(n.oldestTimestamp=e)}n.hasMore=r.length===(t?i.limit||100:200),n.isLoading=!1,D.set(e,n)}catch(t){console.error("Failed to load search results:",t),n.isLoading=!1,D.set(e,n),alert("Failed to load search results: "+t.message)}}}function De(e,t){const{scrollTop:n,scrollHeight:i,clientHeight:r}=e.target;if(i-n-r<100){const e=D.get(t);e&&!e.isLoading&&e.hasMore&&async function(e){await Fe(e,!1)}(t)}}async function $e(){if(u&&d&&!p)try{console.log("Auto-fetching profile for:",d),await $p(),n(3,p=await Sp(d)),console.log("Profile auto-loaded:",p)}catch(e){console.error("Failed to auto-load profile:",e)}}async function Pe(){if(u&&d)try{const e=await fetch(`/api/permissions/${d}`);if(e.ok){const t=await e.json();n(4,h=t.permission||""),console.log("User role loaded:",h),console.log("Is owner?","owner"===h)}else console.error("Failed to fetch user role:",e.status),n(4,h="")}catch(e){console.error("Error fetching user role:",e),n(4,h="")}else n(4,h="")}async function Re(){try{const e=await fetch("/api/acl-mode");if(e.ok){const t=await e.json();n(9,ee=t.acl_mode||""),console.log("ACL mode loaded:",ee)}else console.error("Failed to fetch ACL mode:",e.status),n(9,ee="")}catch(e){console.error("Error fetching ACL mode:",e),n(9,ee="")}}async function Te(e=[]){if("none"===ee||u)if("none"===ee||0!==e.length||"admin"===a||"owner"===a)try{const t={"Content-Type":"application/json"};"none"!==ee&&u&&(t.Authorization=await Le("/api/export","POST"));const n=await fetch("/api/export",{method:"POST",headers:t,body:JSON.stringify({pubkeys:e})});if(!n.ok)throw new Error(`Export failed: ${n.status} ${n.statusText}`);const i=await n.blob(),r=window.URL.createObjectURL(i),s=document.createElement("a");s.href=r;const o=n.headers.get("Content-Disposition");let a="events.jsonl";if(o){const e=o.match(/filename="([^"]+)"/);e&&(a=e[1])}s.download=a,document.body.appendChild(s),s.click(),document.body.removeChild(s),window.URL.revokeObjectURL(r)}catch(e){console.error("Export failed:",e),alert("Export failed: "+e.message)}else alert("Admin or owner permission required to export all events");else alert("Please log in first")}async function Ue(e=!1,t=null){if(!u||"read"!==h&&"write"!==h&&"admin"!==h&&"owner"!==h)alert("Read, write, admin, or owner permission required");else if(!S){n(7,S=!0),e&&(Q=null);try{console.log("Loading events with authors filter:",t,"including delete events");const i=e?Math.floor(Date.now()/1e3):Q,r=w.authors||t,s=await async function(e={}){const{limit:t=100,since:n=null,until:i=null,authors:r=null,kinds:s=null,...o}=e,a=[{...o}];return n&&(a[0].since=n),i&&(a[0].until=i),r&&(a[0].authors=r),s&&(a[0].kinds=s),t&&(a[0].limit=t),await Qp(a,{timeout:3e4})}({...w,limit:e?100:200,until:w.until||i,authors:r});if(console.log("Received events:",s.length,"events"),t&&s.length>0){const e=s.filter(e=>e.pubkey&&e.pubkey!==d);e.length>0&&console.warn("Server returned non-user events:",e.length,"out of",s.length)}if(e?(n(96,k=s.sort((e,t)=>t.created_at-e.created_at)),ve(s)):(n(96,k=[...k,...s].sort((e,t)=>t.created_at-e.created_at)),ve(k)),s.length>0){const e=Math.min(...s.map(e=>e.created_at));(!Q||e<Q)&&(Q=e)}B=s.length===(e?1e3:200),e&&B&&setTimeout(()=>{if("events"===v){const e=document.querySelectorAll(".events-view-content")[0];e&&e.scrollHeight<=e.clientHeight&&_e()}},100)}catch(e){console.error("Failed to load events:",e),alert("Failed to load events: "+e.message)}finally{n(7,S=!1)}}}async function _e(){await Ue(!1)}let Ne=!1;async function Le(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 i;if(g&&"extension"===f)try{i=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(),i=n}const r=JSON.stringify(i);return`Nostr ${btoa(r)}`}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+t],["method",e.toUpperCase()]],content:"",pubkey:d};let i;if(g&&"extension"===f)try{i=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(),i=n}const r=JSON.stringify(i);return btoa(r)}function Me(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: ${h||"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 je(e){n(97,F=e),localStorage.setItem("viewAsRole",e),console.log("View as role changed to:",e,"Current effective role:",a)}F=localStorage.getItem("viewAsRole")||"";return e.$$.update=()=>{var t;if(6&e.$$.dirty[0]|8&e.$$.dirty[3]&&n(41,i=k.sort((e,t)=>t.created_at-e.created_at)),8&e.$$.dirty[0]&&n(40,r=p?.about?(t=p.about,t?t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"):"").replace(/\n{2,}/g,"<br>"):""),16&e.$$.dirty[0]|16&e.$$.dirty[3]&&n(10,a=F&&""!==F?F:h),1810&e.$$.dirty[0]|112&e.$$.dirty[3]&&n(101,s=Ee.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&&!G)&&(!("policy"===e.id&&!V)&&(!("relay-connect"===e.id&&!X)&&(("managed-acl"!==e.id||"managed"===ee)&&(("curation"!==e.id||"curating"===ee)&&(console.log(`Tab ${e.id} filter check:`,{isLoggedIn:u,userRole:h,viewAsRole:F,currentRole:t,requiresAdmin:e.requiresAdmin,requiresOwner:e.requiresOwner,requiresWrite:e.requiresWrite,visible:!0}),!0))))))))})),64&e.$$.dirty[0]|256&e.$$.dirty[3]&&n(11,o=[...s,...b]),2578&e.$$.dirty[0]|256&e.$$.dirty[3]&&console.log("Tabs debug:",{isLoggedIn:u,userRole:h,aclMode:ee,filteredBaseTabs:s.map(e=>e.id),allTabs:o.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&&!p&&$e(),182&e.$$.dirty[0]|136&e.$$.dirty[3]&&"events"===v&&u&&("read"===h||"write"===h||"admin"===h||"owner"===h)&&0===k.length&&!Ne&&!S){n(100,Ne=!0);Ue(!0,null)}32&e.$$.dirty[0]|8&e.$$.dirty[3]&&("events"!==v||"events"===v&&k.length>0)&&n(100,Ne=!1),32&e.$$.dirty[0]&&localStorage.setItem("selectedTab",v)},[l,u,d,p,h,v,b,S,V,ee,a,o,c,g,m,y,I,C,E,N,L,O,M,j,H,J,K,q,Y,W,z,Z,te,ne,ie,re,se,oe,ae,le,r,i,D,ue,de,async function(){console.log("Toggle changed, showOnlyMyEvents:",GA),n(100,Ne=!1),await Ue(!0,null)},fe,pe,he,ge,function(){console.log("selectRecoveryKind called, recoverySelectedKind:",re),null!=re?(n(36,se=""),n(37,oe=[]),ce=null,n(39,le=!0),pe()):console.log("No kind selected, skipping load")},function(){console.log("handleCustomKindInput called, recoveryCustomKind:",se);const e=parseInt(se);""!==se&&!isNaN(e)&&e>=0&&(n(35,re=null),n(37,oe=[]),ce=null,n(39,le=!0),pe())},function(e){const t=oe.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"===h)try{n(22,M=!0);const e=await fetch("/api/sprocket/status",{method:"GET",headers:{Authorization:`Nostr ${await Oe("GET","/api/sprocket/status")}`,"Content-Type":"application/json"}});if(e.ok){const t=await e.json();n(19,N=t.script_content||""),n(20,L=t),ke("Script loaded successfully","success")}else ke("Failed to load script","error")}catch(e){ke(`Error loading script: ${e.message}`,"error")}finally{n(22,M=!1)}},async function(){if(u&&"owner"===h)try{n(22,M=!0);const e=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await Oe("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:N});if(e.ok)ke("Script saved and updated successfully","success"),await ye(),await we();else{ke(`Failed to save script: ${await e.text()}`,"error")}}catch(e){ke(`Error saving script: ${e.message}`,"error")}finally{n(22,M=!1)}},async function(){if(u&&"owner"===h)try{n(22,M=!0);const e=await fetch("/api/sprocket/restart",{method:"POST",headers:{Authorization:`Nostr ${await Oe("POST","/api/sprocket/restart")}`,"Content-Type":"application/json"}});if(e.ok)ke("Sprocket restarted successfully","success"),await ye();else{ke(`Failed to restart sprocket: ${await e.text()}`,"error")}}catch(e){ke(`Error restarting sprocket: ${e.message}`,"error")}finally{n(22,M=!1)}},async function(){if(u&&"owner"===h&&confirm("Are you sure you want to delete the sprocket script? This will stop the current process."))try{n(22,M=!0);const e=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await Oe("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:""});if(e.ok)n(19,N=""),ke("Sprocket script deleted successfully","success"),await ye(),await we();else{ke(`Failed to delete script: ${await e.text()}`,"error")}}catch(e){ke(`Error deleting script: ${e.message}`,"error")}finally{n(22,M=!1)}},we,be,Ae,async function(){if(u&&("owner"===h||JA))try{n(27,q=!0),n(30,z=[]);const e={kinds:[12345],limit:1},t=await Pp(e);if(t&&t.length>0){n(26,K=t[0].content);try{n(26,K=JSON.stringify(JSON.parse(K),null,2))}catch(e){}Ie("Policy loaded successfully","success")}else{const e=await fetch("/api/policy",{method:"GET",headers:{Authorization:`Nostr ${await Oe("GET","/api/policy")}`,"Content-Type":"application/json"}});if(e.ok){const t=await e.json();n(26,K=JSON.stringify(t,null,2)),Ie("Policy loaded from file","success")}else Ie("No policy configuration found","info"),n(26,K="")}}catch(e){Ie(`Error loading policy: ${e.message}`,"error")}finally{n(27,q=!1)}},Ce,async function(){if(!u||"owner"!==h&&!JA)return;if(await Ce())try{n(27,q=!0);const e={kind:12345,created_at:Math.floor(Date.now()/1e3),tags:[],content:K},t=await Ob(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(27,q=!1)}},function(){try{const e=JSON.parse(K);n(26,K=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 i=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 i=[];for(const e of n){const n=t.indexOf(e.toLowerCase());if(-1===n)throw new Error("Invalid character in npub");i.push(...[...Array(5)].map((e,t)=>n>>4-t&1))}i=i.slice(0,-30);const r=[];for(let e=0;e+8<=i.length;e+=8){let t=0;for(let n=0;n<8;n++)t=t<<1|i[e+n];r.push(t)}return r.map(e=>e.toString(16).padStart(2,"0")).join("")}catch(e){return console.error("Failed to decode npub:",e),null}return null}(t);if(i&&64===i.length)try{const e=JSON.parse(K||"{}");if(e.policy_admins||(e.policy_admins=[]),e.policy_admins.includes(i))return void Ie("Admin already in list","warning");e.policy_admins.push(i),n(26,K=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(K||"{}");e.policy_admins&&(e.policy_admins=e.policy_admins.filter(e=>e!==t),n(26,K=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"===h||JA))try{n(27,q=!0),n(31,Z=[]);let e=[];try{e=JSON.parse(K||"{}").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},i=await Pp(t),r=new Set;for(const e of i)if(e.tags)for(const t of e.tags)"p"===t[0]&&t[1]&&64===t[1].length&&r.add(t[1]);n(31,Z=Array.from(r)),Ie(`Loaded ${Z.length} follows from ${i.length} admin(s)`,"success")}catch(e){Ie(`Error loading follows: ${e.message}`,"error")}finally{n(27,q=!1)}},function(e){n(25,J=e.target.files[0])},async function(){if(u&&"owner"===h&&J)try{n(22,M=!0);const e=await J.text(),t=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await Oe("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:e});if(t.ok)n(19,N=e),ke("Script uploaded and updated successfully","success"),await ye(),await we();else{ke(`Failed to upload script: ${await t.text()}`,"error")}}catch(e){ke(`Error uploading script: ${e.message}`,"error")}finally{n(22,M=!1),n(25,J=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:i,privateKey:r,signer:s}=e.detail;n(1,u=!0),n(2,d=i),f=t,n(13,g=s),n(12,c=!1);try{if(await $p(),"extension"===t&&s)vp.setSigner(s);else if("nsec"===t&&r){const e=new ff(r);vp.setSigner(e)}n(3,p=await Sp(i)),console.log("Profile loaded:",p)}catch(e){console.error("Failed to load profile:",e)}await Pe(),await Re()},function(){n(1,u=!1),n(2,d=""),f="",n(3,p=null),n(4,h=""),n(13,g=null),userPrivkey=null,n(14,m=!1),T=[],n(96,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(14,m=!0)},Se,function(){n(15,y=!y)},function(e){const{searchText:t,selectedKinds:n,pubkeys:i,eventIds:r,tags:s,sinceTimestamp:o,untilTimestamp:a,limit:l}=e.detail,c=function({searchText:e=null,kinds:t=[],authors:n=[],ids:i=[],tags:r=[],since:s=null,until:o=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),i&&i.length>0&&(l.ids=i),r&&r.length>0&&r.forEach(e=>{if(e.name&&e.value){const t=`#${e.name}`;l[t]||(l[t]=[]),l[t].push(e.value)}}),s&&(l.since=s),o&&(l.until=o),a&&a>0&&(l.limit=a),l}({searchText:t,kinds:n,authors:i,ids:r,tags:s,since:o,until:a,limit:l||100});w=c,Ue(!0,null)},function(){w={},Ue(!0,null)},Be,Qe,Fe,De,$e,async function(){await Te([])},async function(){await Te([d])},function(e){n(16,I=e.detail.target.files[0])},async function(){if("none"!==ee&&(!u||"admin"!==h&&"owner"!==h))return n(17,C="Admin or owner permission required"),void setTimeout(()=>{n(17,C="")},5e3);if(!I)return n(17,C="Please select a file"),void setTimeout(()=>{n(17,C="")},5e3);try{n(17,C="Uploading...");const e={};"none"!==ee&&u&&(e.Authorization=await Le("/api/import","POST"));const t=new FormData;t.append("file",I);const i=await fetch("/api/import",{method:"POST",headers:e,body:t});if(!i.ok)throw new Error(`Import failed: ${i.status} ${i.statusText}`);await i.json();n(17,C="Upload complete"),n(16,I=null),document.getElementById("import-file").value="",setTimeout(()=>{n(17,C="")},5e3)}catch(e){console.error("Import failed:",e),n(17,C="Import failed: "+e.message),setTimeout(()=>{n(17,C="")},5e3)}},Ue,function(e){const{scrollTop:t,scrollHeight:n,clientHeight:i}=e.target;n-t-i<100&&_e()},function(){try{if(!ne.trim())return void alert("Please enter some JSON to reformat");const e=JSON.parse(ne);n(33,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(33,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(34,ie="");try{if(!ne.trim())return void n(34,ie="Please enter an event to publish");if(!u)return void n(34,ie="Please log in to publish events");if(!g)return void n(34,ie="No signer available. Please log in with a valid authentication method.");let e;try{e=JSON.parse(ne)}catch(e){return void n(34,ie=`Invalid JSON: ${e.message}`)}if(!e.id||!e.sig)return void n(34,ie='Event must be signed before publishing. Please click "Sign" first.');if("read"===h)return void n(34,ie=`Permission denied: Your current role is "${h}" 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}/`,i=await Ob(t,e,g,d);if(i.success)n(34,ie=""),alert("Event published successfully to ORLY relay!");else{const t=i.reason||"Unknown error";n(34,ie=Me(t,e.kind))}}catch(e){console.error("Error publishing event:",e);const t=e.message||"Unknown error";n(34,ie=Me(t,null))}},function(){n(34,ie="")},je,function(){const e=["owner","admin","write","read"],t=e.indexOf(h);return-1===t?["read"]:e.slice(t)},k,F,G,X,Ne,s,function(t){R.call(this,e,t)},function(t){R.call(this,e,t)},e=>e.id===v,e=>xe(e.detail),e=>Qe(e.detail),e=>ue(e.detail),e=>fe(e.detail),e=>de(e.detail.event,e.detail.e),e=>Ue(e.detail.refresh,e.detail.authors),function(e){ne=e,n(33,ne)},function(e){N=e,n(19,N)},e=>be(e.detail),e=>Ae(e.detail),function(e){K=e,n(26,K)},function(){re=x(this),n(35,re)},function(){se=A(this.value),n(36,se)},e=>ge(e),e=>he(e),(e,t)=>de(e,t),e=>Fe(e.id,!0),e=>Be(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=>je(e===h?"":e),e=>"Escape"===e.key&&Se(),function(e){c=e,n(12,c)}]}return new class extends se{constructor(e){super(),re(this,e,KA,HA,s,{},null,[-1,-1,-1,-1,-1,-1])}}({target:document.body,props:{name:"world"}})}();
//# sourceMappingURL=bundle.js.map