diff --git a/app/privileged_events_test.go b/app/privileged_events_test.go index 5b82d20..07bf6aa 100644 --- a/app/privileged_events_test.go +++ b/app/privileged_events_test.go @@ -248,7 +248,7 @@ func TestAllPrivilegedKinds(t *testing.T) { kind.JWTBinding.K, kind.ApplicationSpecificData.K, kind.Seal.K, - kind.PrivateDirectMessage.K, + kind.DirectMessage.K, } for _, k := range privilegedKinds { diff --git a/app/web/dist/bundle.js b/app/web/dist/bundle.js index 5d43f9a..b0d03ac 100644 --- a/app/web/dist/bundle.js +++ b/app/web/dist/bundle.js @@ -18,5 +18,5 @@ Object.defineProperty(e,"__esModule",{value:!0}),e.bytes=e.stringToBytes=e.str=e /*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */ const tf=BigInt(0),nf=BigInt(1),rf=BigInt(2),of=BigInt(3),sf=BigInt(8),af=Object.freeze({a:tf,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:nf,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")}),lf=(e,t)=>(e+t/rf)/t,cf={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(e){const{n:t}=af,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-nf*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,s=BigInt("0x100000000000000000000000000000000"),a=lf(i*e,t),l=lf(-r*e,t);let c=Pf(e-a*n-l*o,t),u=Pf(-a*r-l*i,t);const d=c>s,f=u>s;if(d&&(c=t-c),f&&(u=t-u),c>s||u>s)throw new Error("splitScalarEndo: Endomorphism failed, k="+e);return{k1neg:d,k1:c,k2neg:f,k2:u}}},uf=32;function df(e){const{a:t,b:n}=af,r=Pf(e*e),o=Pf(r*e);return Pf(o+t*e+n)}const ff=af.a===tf;function hf(e){if(!(e instanceof pf))throw new TypeError("JacobianPoint expected")}class pf{constructor(e,t,n){this.x=e,this.y=t,this.z=n}static fromAffine(e){if(!(e instanceof wf))throw new TypeError("JacobianPoint#fromAffine: expected Point");return e.equals(wf.ZERO)?pf.ZERO:new pf(e.x,e.y,nf)}static toAffineBatch(e){const t=function(e,t=af.P){const n=new Array(e.length),r=e.reduce((e,r,o)=>r===tf?e:(n[o]=e,Pf(e*r,t)),nf),o=Nf(r,t);return e.reduceRight((e,r,o)=>r===tf?e:(n[o]=Pf(e*n[o],t),Pf(e*r,t)),o),n}(e.map(e=>e.z));return e.map((e,n)=>e.toAffine(t[n]))}static normalizeZ(e){return pf.toAffineBatch(e).map(pf.fromAffine)}equals(e){hf(e);const{x:t,y:n,z:r}=this,{x:o,y:i,z:s}=e,a=Pf(r*r),l=Pf(s*s),c=Pf(t*l),u=Pf(o*a),d=Pf(Pf(n*s)*l),f=Pf(Pf(i*r)*a);return c===u&&d===f}negate(){return new pf(this.x,Pf(-this.y),this.z)}double(){const{x:e,y:t,z:n}=this,r=Pf(e*e),o=Pf(t*t),i=Pf(o*o),s=e+o,a=Pf(rf*(Pf(s*s)-r-i)),l=Pf(of*r),c=Pf(l*l),u=Pf(c-rf*a),d=Pf(l*(a-u)-sf*i),f=Pf(rf*t*n);return new pf(u,d,f)}add(e){hf(e);const{x:t,y:n,z:r}=this,{x:o,y:i,z:s}=e;if(o===tf||i===tf)return this;if(t===tf||n===tf)return e;const a=Pf(r*r),l=Pf(s*s),c=Pf(t*l),u=Pf(o*a),d=Pf(Pf(n*s)*l),f=Pf(Pf(i*r)*a),h=Pf(u-c),p=Pf(f-d);if(h===tf)return p===tf?this.double():pf.ZERO;const y=Pf(h*h),g=Pf(h*y),w=Pf(c*y),v=Pf(p*p-g-rf*w),m=Pf(p*(w-v)-d*g),b=Pf(r*s*h);return new pf(v,m,b)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){const t=pf.ZERO;if("bigint"==typeof e&&e===tf)return t;let n=Of(e);if(n===nf)return this;if(!ff){let e=t,r=this;for(;n>tf;)n&nf&&(e=e.add(r)),r=r.double(),n>>=nf;return e}let{k1neg:r,k1:o,k2neg:i,k2:s}=cf.splitScalar(n),a=t,l=t,c=this;for(;o>tf||s>tf;)o&nf&&(a=a.add(c)),s&nf&&(l=l.add(c)),c=c.double(),o>>=nf,s>>=nf;return r&&(a=a.negate()),i&&(l=l.negate()),l=new pf(Pf(l.x*cf.beta),l.y,l.z),a.add(l)}precomputeWindow(e){const t=ff?128/e+1:256/e+1,n=[];let r=this,o=r;for(let i=0;i>=u,s>a&&(s-=c,e+=nf);const d=n,f=n+Math.abs(s)-1,h=t%2!=0,p=s<0;0===s?i=i.add(yf(h,r[d])):o=o.add(yf(p,r[f]))}return{p:o,f:i}}multiply(e,t){let n,r,o=Of(e);if(ff){const{k1neg:e,k1:i,k2neg:s,k2:a}=cf.splitScalar(o);let{p:l,f:c}=this.wNAF(i,t),{p:u,f:d}=this.wNAF(a,t);l=yf(e,l),u=yf(s,u),u=new pf(Pf(u.x*cf.beta),u.y,u.z),n=l.add(u),r=c.add(d)}else{const{p:e,f:i}=this.wNAF(o,t);n=e,r=i}return pf.normalizeZ([n,r])[0]}toAffine(e){const{x:t,y:n,z:r}=this,o=this.equals(pf.ZERO);null==e&&(e=o?sf:Nf(r));const i=e,s=Pf(i*i),a=Pf(s*i),l=Pf(t*s),c=Pf(n*a),u=Pf(r*i);if(o)return wf.ZERO;if(u!==nf)throw new Error("invZ was invalid");return new wf(l,c)}}function yf(e,t){const n=t.negate();return e?n:t}pf.BASE=new pf(af.Gx,af.Gy,nf),pf.ZERO=new pf(tf,nf,tf);const gf=new WeakMap;class wf{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,gf.delete(this)}hasEvenY(){return this.y%rf===tf}static fromCompressedHex(e){const t=32===e.length,n=If(t?e:e.subarray(1));if(!Uf(n))throw new Error("Point is not on curve");let r=function(e){const{P:t}=af,n=BigInt(6),r=BigInt(11),o=BigInt(22),i=BigInt(23),s=BigInt(44),a=BigInt(88),l=e*e*e%t,c=l*l*e%t,u=Bf(c,of)*c%t,d=Bf(u,of)*c%t,f=Bf(d,rf)*l%t,h=Bf(f,r)*f%t,p=Bf(h,o)*h%t,y=Bf(p,s)*p%t,g=Bf(y,a)*y%t,w=Bf(g,s)*p%t,v=Bf(w,of)*c%t,m=Bf(v,i)*h%t,b=Bf(m,n)*l%t,E=Bf(b,rf);if(E*E%t!==e)throw new Error("Cannot find square root");return E}(df(n));const o=(r&nf)===nf;if(t)o&&(r=Pf(-r));else{!(1&~e[0])!==o&&(r=Pf(-r))}const i=new wf(n,r);return i.assertValidity(),i}static fromUncompressedHex(e){const t=If(e.subarray(1,33)),n=If(e.subarray(33,65)),r=new wf(t,n);return r.assertValidity(),r}static fromHex(e){const t=Rf(e),n=t.length,r=t[0];if(n===uf)return this.fromCompressedHex(t);if(33===n&&(2===r||3===r))return this.fromCompressedHex(t);if(65===n&&4===r)return this.fromUncompressedHex(t);throw new Error(`Point.fromHex: received invalid point. Expected 32-33 compressed bytes or 65 uncompressed bytes, not ${n}`)}static fromPrivateKey(e){return wf.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=$f(e)}else{if(!Ef(e))throw new TypeError("Expected valid private key");if(32!==e.length)throw new Error("Expected 32 bytes of private key");t=If(e)}if(!Lf(t))throw new Error("Expected private key: 0 < key < n");return t}(e))}static fromSignature(e,t,n){const{r:r,s:o}=function(e){if(e instanceof bf)return e.assertValidity(),e;try{return bf.fromDER(e)}catch(t){return bf.fromCompact(e)}}(t);if(![0,1,2,3].includes(n))throw new Error("Cannot recover: invalid recovery bit");const i=function(e,t=!1){const n=function(e){const t=8*e.length-256,n=If(e);return t>0?n>>BigInt(t):n}(e);if(t)return n;const{n:r}=af;return n>=r?n-r:n}(Rf(e)),{n:s}=af,a=2===n||3===n?r+s:r,l=Nf(a,s),c=Pf(-i*l,s),u=Pf(o*l,s),d=1&n?"03":"02",f=wf.fromHex(d+Tf(a)),h=wf.BASE.multiplyAndAddUnsafe(f,c,u);if(!h)throw new Error("Cannot recover signature: point at infinify");return h.assertValidity(),h}toRawBytes(e=!1){return Af(this.toHex(e))}toHex(e=!1){const t=Tf(this.x);if(e){return`${this.hasEvenY()?"02":"03"}${t}`}return`04${t}${Tf(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(!Uf(t)||!Uf(n))throw new Error(e);const r=Pf(n*n);if(Pf(r-df(t))!==tf)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new wf(this.x,Pf(-this.y))}double(){return pf.fromAffine(this).double().toAffine()}add(e){return pf.fromAffine(this).add(pf.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return pf.fromAffine(this).multiply(e,this).toAffine()}multiplyAndAddUnsafe(e,t,n){const r=pf.fromAffine(this),o=t===tf||t===nf||this!==wf.BASE?r.multiplyUnsafe(t):r.multiply(t),i=pf.fromAffine(e).multiplyUnsafe(n),s=o.add(i);return s.equals(pf.ZERO)?void 0:s.toAffine()}}function vf(e){return Number.parseInt(e[0],16)>=8?"00"+e:e}function mf(e){if(e.length<2||2!==e[0])throw new Error(`Invalid signature integer tag: ${kf(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:If(n),left:e.subarray(t+2)}}wf.BASE=new wf(af.Gx,af.Gy),wf.ZERO=new wf(tf,tf);class bf{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromCompact(e){const t=Ef(e),n="Signature.fromCompact";if("string"!=typeof e&&!t)throw new TypeError(`${n}: Expected string or Uint8Array`);const r=t?kf(e):e;if(128!==r.length)throw new Error(`${n}: Expected 64-byte hex`);return new bf($f(r.slice(0,64)),$f(r.slice(64,128)))}static fromDER(e){const t=Ef(e);if("string"!=typeof e&&!t)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:n,s:r}=function(e){if(e.length<2||48!=e[0])throw new Error(`Invalid signature tag: ${kf(e)}`);if(e[1]!==e.length-2)throw new Error("Invalid signature: incorrect length");const{data:t,left:n}=mf(e.subarray(2)),{data:r,left:o}=mf(n);if(o.length)throw new Error(`Invalid signature: left bytes after parsing: ${kf(o)}`);return{r:t,s:r}}(t?e:Af(e));return new bf(n,r)}static fromHex(e){return this.fromDER(e)}assertValidity(){const{r:e,s:t}=this;if(!Lf(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Lf(t))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const e=af.n>>nf;return this.s>e}normalizeS(){return this.hasHighS()?new bf(this.r,Pf(-this.s,af.n)):this}toDERRawBytes(){return Af(this.toDERHex())}toDERHex(){const e=vf(_f(this.s)),t=vf(_f(this.r)),n=e.length/2,r=t.length/2,o=_f(n),i=_f(r);return`30${_f(r+n+4)}02${i}${t}02${o}${e}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return Af(this.toCompactHex())}toCompactHex(){return Tf(this.r)+Tf(this.s)}}function Ef(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}const xf=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function kf(e){!function(e){if(!Ef(e))throw new Error("Uint8Array expected")}(e);let t="";for(let n=0;n=Sf._0&&e<=Sf._9?e-Sf._0:e>=Sf.A&&e<=Sf.F?e-(Sf.A-10):e>=Sf.a&&e<=Sf.f?e-(Sf.a-10):void 0}function Af(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,o=0;t0)return BigInt(e);if("bigint"==typeof e&&Lf(e))return e;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function Pf(e,t=af.P){const n=e%t;return n>=tf?n:t+n}function Bf(e,t){const{P:n}=af;let r=e;for(;t-- >tf;)r*=r,r%=n;return r}function Nf(e,t=af.P){if(e===tf||t<=tf)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=Pf(e,t),r=t,o=tf,i=nf;for(;n!==tf;){const e=r%n,t=o-i*(r/n);r=n,n=e,o=i,i=t}if(r!==nf)throw new Error("invert: does not exist");return Pf(o,t)}function Lf(e){return tf"string"==typeof e):t.every(e=>Number.isSafeInteger(e))))}function Df(e,t){if("string"!=typeof t)throw new Error(`${e}: string expected`);return!0}function Hf(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function qf(e){if(!Array.isArray(e))throw new Error("array expected")}function zf(e,t){if(!Mf(!0,t))throw new Error(`${e}: array of strings expected`)}wf.BASE._setWindowSize(8);const Kf=(e,t)=>0===t?e:Kf(t,e%t),Wf=(e,t)=>e+(t-Kf(e,t)),Vf=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function Jf(e,t,n,r){if(qf(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(Wf(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${Wf(t,n)}`);let o=0,i=0;const s=Vf[t],a=Vf[n]-1,l=[];for(const r of e){if(Hf(r),r>=s)throw new Error(`convertRadix2: invalid data word=${r} from=${t}`);if(o=o<32)throw new Error(`convertRadix2: carry overflow pos=${i} from=${t}`);for(i+=t;i>=n;i-=n)l.push((o>>i-n&a)>>>0);const e=Vf[i];if(void 0===e)throw new Error("invalid carry");o&=e-1}if(o=o<=t)throw new Error("Excess padding");if(!r&&o>0)throw new Error(`Non-zero padding: ${o}`);return r&&i>0&&l.push(o>>>0),l}const Gf=(()=>"function"==typeof Uint8Array.from([]).toBase64&&"function"==typeof Uint8Array.fromBase64)()?{encode:e=>(function(e,...t){if(!Ff(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)=>{Df("base64",e);const n=t?/^[A-Za-z0-9=_-]+$/:/^[A-Za-z0-9=+/]+$/,r=t?"base64url":"base64";if(e.length>0&&!n.test(e))throw new Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,lastChunkHandling:"strict"})})(e,!1)}:function(...e){const t=e=>e,n=(e,t)=>n=>e(t(n));return{encode:e.map(e=>e.encode).reduceRight(n,t),decode:e.map(e=>e.decode).reduce(n,t)}}(function(e,t=!1){if(Hf(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(Wf(8,e)>32||Wf(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!Ff(n))throw new Error("radix2.encode input should be Uint8Array");return Jf(Array.from(n),8,e,!t)},decode:n=>(function(e,t){if(!Mf(!1,t))throw new Error(`${e}: array of numbers expected`)}("radix2.decode",n),Uint8Array.from(Jf(n,e,8,t)))}}(6),function(e){const t="string"==typeof e?e.split(""):e,n=t.length;zf("alphabet",t);const r=new Map(t.map((e,t)=>[e,t]));return{encode:r=>(qf(r),r.map(r=>{if(!Number.isSafeInteger(r)||r<0||r>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${r}". Allowed: ${e}`);return t[r]})),decode:t=>(qf(t),t.map(t=>{Df("alphabet.decode",t);const n=r.get(t);if(void 0===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n}))}}("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),function(e,t="="){return Hf(e),Df("padding",t),{encode(n){for(zf("padding.encode",n);n.length*e%8;)n.push(t);return n},decode(n){zf("padding.decode",n);let r=n.length;if(r*e%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;r>0&&n[r-1]===t;r--){if((r-1)*e%8==0)throw new Error("padding: invalid, string has too much padding")}return n.slice(0,r)}}}(6),function(e=""){return Df("join",e),{encode:t=>(zf("join.decode",t),t.join(e)),decode:t=>(Df("join.decode",t),t.split(e))}}(""));function Zf(e){return wf.fromHex(e).toHex().substring(2)}const Yf=new TextDecoder("utf-8"),Qf=new TextEncoder;class Xf{log=Ku.extend("SerialPortSigner");writer=null;pubkey;get isConnected(){return!!this.writer}verifyEvent=io;nip04;constructor(){this.nip04={encrypt:this.nip04Encrypt.bind(this),decrypt:this.nip04Decrypt.bind(this)}}lastCommand=null;async callMethodOnDevice(e,t,n={}){if(!Xf.SUPPORTED)throw new Error("Serial devices are not supported");if(this.writer||await this.connectToDevice(n),this.lastCommand)throw new Error("Previous command to device still pending!");const r=Ud();return this.lastCommand=r,this.sendCommand(e,t),setTimeout(()=>{r.reject(new Error("Device timeout")),this.lastCommand===r&&(this.lastCommand=null)},6e3),this.lastCommand}async connectToDevice({onConnect:e,onDisconnect:t,onError:n,onDone:r}){let o,i=await window.navigator.serial.requestPort();await i.open({baudRate:9600}),await(e=>new Promise(t=>setTimeout(t,e)))(1e3),(async()=>{for(;i&&i.readable;){const e=new window.TextDecoderStream;i.readable.pipeTo(e.writable),o=e.readable.getReader();const t=this.readFromSerialPort(o);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===Xf.PUBLIC_METHODS.indexOf(t))continue;this.log("Received: ",t,n),this.lastCommand&&(this.lastCommand.resolve(n),this.lastCommand=null)}if(n)return this.lastCommand=null,this.writer=null,void(r&&r())}}catch(e){if(e instanceof Error)throw this.writer=null,n&&n(e),this.lastCommand&&(this.lastCommand.reject(e),this.lastCommand=null),e}}})();const s=new window.TextEncoderStream;s.readable.pipeTo(i.writable),this.writer=s.writable.getWriter(),await this.sendCommand(Xf.METHOD_PING),await this.sendCommand(Xf.METHOD_PING,[window.location.host]),e&&e(),i.addEventListener("disconnect",()=>{this.log("Disconnected"),this.lastCommand=null,this.writer=null,t&&t()})}async sendCommand(e,t=[]){if(!this.writer)return;this.log("Send command",e,t);const n=[e].concat(t).join(" ");await this.writer.write(n+"\n")}readFromSerialPort(e){let t,n=[];return async(r="\n")=>{if(n.length)return{value:n.shift().trim(),done:!1};const o=[];for(t&&(o.push(t),t=void 0);;){const{value:i,done:s}=await e.read();if(i){const e=i.split(r);if(e.length>1)return o.push(e.shift()),t=e.pop(),n=e,{value:o.join("").trim(),done:!1};o.push(i)}if(s)return{value:o.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=ef(await this.callMethodOnDevice(Xf.METHOD_SHARED_SECRET,[Zf(e)]));let r=Uint8Array.from(function(e=32){if(Hd&&"function"==typeof Hd.getRandomValues)return Hd.getRandomValues(new Uint8Array(e));if(Hd&&"function"==typeof Hd.randomBytes)return Uint8Array.from(Hd.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}(16)),o=Qf.encode(t),i=await crypto.subtle.importKey("raw",n,{name:"AES-CBC"},!1,["encrypt"]),s=await crypto.subtle.encrypt({name:"AES-CBC",iv:r},i,o);return`${Gf.encode(new Uint8Array(s))}?iv=${Gf.encode(new Uint8Array(r.buffer))}`}async nip04Decrypt(e,t){let[n,r]=t.split("?iv=");const o=ef(await this.callMethodOnDevice(Xf.METHOD_SHARED_SECRET,[Zf(e)]));let i=await crypto.subtle.importKey("raw",o,{name:"AES-CBC"},!1,["decrypt"]),s=Gf.decode(n),a=Gf.decode(r),l=await crypto.subtle.decrypt({name:"AES-CBC",iv:a},i,s);return Yf.decode(l)}async getPublicKey(){const e=await this.callMethodOnDevice(Xf.METHOD_PUBLIC_KEY,[]);return this.pubkey=e,e}async restore(e){await this.callMethodOnDevice(Xf.METHOD_RESTORE,[Wd(e)])}async signEvent(e){const t=e.pubkey||this.pubkey;if(!t)throw new Error("Unknown signer pubkey");const n={...e,id:eo({...e,pubkey:t})},r=await this.callMethodOnDevice(Xf.METHOD_SIGN_MESSAGE,[n.id]),o={...n,sig:r,pubkey:t};if(!this.verifyEvent(o))throw new Error("Invalid signature");return o}ping(){this.sendCommand(Xf.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=[Xf.METHOD_PUBLIC_KEY,Xf.METHOD_SIGN_MESSAGE,Xf.METHOD_SHARED_SECRET,Xf.METHOD_RESTORE]}const eh=[`wss://${window.location.host}/`];class th{constructor(){this.pool=new Tn,this.eventStore=new Ld,this.isConnected=!1,this.signer=null,this.relays=[...eh]}async connect(){console.log("Starting connection to",this.relays.length,"relays...");try{this.isConnected=!0,console.log("✓ Successfully initialized relay pool"),await new Promise(e=>setTimeout(e,1e3))}catch(e){throw console.error("✗ Connection failed:",e),e}}async connectToRelay(e){console.log(`Adding relay: ${e}`);try{return this.relays.includes(e)||this.relays.push(e),console.log(`✓ Successfully added relay ${e}`),!0}catch(t){return console.error(`✗ Failed to add relay ${e}:`,t),!1}}subscribe(e,t){console.log("Creating subscription with filters:",e);const n=this.pool.subscribeMany(this.relays,e,{onevent(e){console.log("Event received:",e),t(e)},oneose(){console.log("EOSE received"),window.dispatchEvent(new CustomEvent("nostr-eose",{detail:{subscriptionId:n.id}}))}});return n}unsubscribe(e){console.log("Closing subscription"),e&&e.close&&e.close()}disconnect(){console.log("Disconnecting relay pool"),this.pool&&this.pool.close(this.relays),this.isConnected=!1}async publish(e,t=null){this.isConnected||(console.warn("Not connected to any relays, attempting to connect first"),await this.connect());try{const n=t||this.relays,r=this.pool.publish(n,e);return await Promise.allSettled(r),console.log("✓ Event published successfully"),await lh([e]),console.log("Event stored in IndexedDB"),{success:!0,okCount:1,errorCount:0}}catch(e){throw console.error("✗ Failed to publish event:",e),e}}getPool(){return this.pool}getEventStore(){return this.eventStore}getSigner(){return this.signer}setSigner(e){this.signer=e}}const nh=new th,rh="nostrCache",oh=2,ih="events";function sh(){return new Promise((e,t)=>{try{const n=indexedDB.open(rh,oh);n.onupgradeneeded=e=>{const t=n.result;e.oldVersion;let r;r=t.objectStoreNames.contains(ih)?n.transaction.objectStore(ih):t.createObjectStore(ih,{keyPath:"id"}),r.indexNames.contains("byKindAuthor")||r.createIndex("byKindAuthor",["kind","pubkey"],{unique:!1}),r.indexNames.contains("byKindAuthorCreated")||r.createIndex("byKindAuthorCreated",["kind","pubkey","created_at"],{unique:!1}),r.indexNames.contains("byKind")||r.createIndex("byKind","kind",{unique:!1}),r.indexNames.contains("byAuthor")||r.createIndex("byAuthor","pubkey",{unique:!1}),r.indexNames.contains("byCreatedAt")||r.createIndex("byCreatedAt","created_at",{unique:!1})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}catch(e){console.error("Failed to open IndexedDB",e),t(e)}})}async function ah(e){try{const t=await sh();await new Promise((n,r)=>{const o=t.transaction(ih,"readwrite");o.oncomplete=()=>n(),o.onerror=()=>r(o.error),o.objectStore(ih).put(e)})}catch(e){console.warn("IDB putEvent failed",e)}}async function lh(e){if(e&&0!==e.length)try{const t=await sh();await new Promise((n,r)=>{const o=t.transaction(ih,"readwrite");o.oncomplete=()=>n(),o.onerror=()=>r(o.error);const i=o.objectStore(ih);for(const t of e)i.put(t)}),console.log(`Stored ${e.length} events in IndexedDB`)}catch(e){console.warn("IDB putEvents failed",e)}}async function ch(e){try{const t=await sh(),n=[];console.log("QueryEventsFromDB: Starting query with filters:",e);for(const r of e){console.log("QueryEventsFromDB: Processing filter:",r);const e=await new Promise((e,n)=>{const o=t.transaction(ih,"readonly").objectStore(ih),i=[];let s;if(r.kinds&&r.kinds.length>0&&r.authors&&r.authors.length>0){const e=r.kinds[0],t=r.authors[0];console.log(`QueryEventsFromDB: Using byKindAuthorCreated index for kind=${e}, author=${t.substring(0,8)}...`);const n=o.index("byKindAuthorCreated"),i=IDBKeyRange.bound([e,t,-1/0],[e,t,1/0]);s=n.openCursor(i,"prev")}else if(r.kinds&&r.kinds.length>0){console.log(`QueryEventsFromDB: Using byKind index for kind=${r.kinds[0]}`);const e=o.index("byKind");s=e.openCursor(IDBKeyRange.only(r.kinds[0]))}else if(r.authors&&r.authors.length>0){console.log(`QueryEventsFromDB: Using byAuthor index for author=${r.authors[0].substring(0,8)}...`);const e=o.index("byAuthor");s=e.openCursor(IDBKeyRange.only(r.authors[0]))}else console.log("QueryEventsFromDB: Scanning all events (no specific index)"),s=o.openCursor();s.onsuccess=t=>{const n=t.target.result;if(n){const t=n.value;let o=!0;if(r.kinds&&r.kinds.length>0&&!r.kinds.includes(t.kind)&&(o=!1),r.authors&&r.authors.length>0&&!r.authors.includes(t.pubkey)&&(o=!1),r.since&&t.created_atr.until&&(o=!1),r.ids&&r.ids.length>0&&!r.ids.includes(t.id)&&(o=!1),o&&i.push(t),r.limit&&i.length>=r.limit)return console.log(`QueryEventsFromDB: Reached limit of ${r.limit}, found ${i.length} matching events`),void e(i);n.continue()}else console.log(`QueryEventsFromDB: Cursor exhausted, found ${i.length} matching events`),e(i)},s.onerror=()=>{console.error("QueryEventsFromDB: Cursor error:",s.error),n(s.error)}});console.log(`QueryEventsFromDB: Found ${e.length} events for this filter`),n.push(...e)}return n.sort((e,t)=>t.created_at-e.created_at),console.log(`QueryEventsFromDB: Returning ${n.length} total events`),n}catch(e){return console.error("QueryEventsFromDB failed:",e),[]}}function uh(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 dh(e){console.log(`Starting profile fetch for pubkey: ${e}`);try{const t=await async function(e){try{const t=await sh();return await new Promise((n,r)=>{const o=t.transaction(ih,"readonly").objectStore(ih).index("byKindAuthorCreated"),i=IDBKeyRange.bound([0,e,-1/0],[0,e,1/0]),s=o.openCursor(i,"prev");s.onsuccess=()=>{const e=s.result;n(e?e.value:null)},s.onerror=()=>r(s.error)})}catch(e){return console.warn("IDB getLatestProfileEvent failed",e),null}}(e);if(t){console.log("Using cached profile event");return uh(t)}}catch(e){console.warn("Failed to load cached profile",e)}try{const t=[{kinds:[0],authors:[e],limit:1}],n=await fh(t,{timeout:1e4});if(n.length>0){const t=n[0];console.log("Profile fetched:",t),await ah(t);try{console.log("Publishing profile event to local relay:",t.id),await nh.publish(t),console.log("Profile event successfully saved to local relay")}catch(e){console.warn("Failed to publish profile to local relay:",e)}const r=uh(t);try{"undefined"!=typeof window&&window.dispatchEvent&&window.dispatchEvent(new CustomEvent("profile-updated",{detail:{pubkey:e,profile:r,event:t}}))}catch(e){console.warn("Failed to dispatch profile-updated event",e)}return r}throw new Error("No profile found")}catch(e){throw console.error("Failed to fetch profile:",e),e}}async function fh(e,t={}){console.log("Starting event fetch with filters:",JSON.stringify(e,null,2)),console.log("Current relays:",nh.relays),nh.isConnected&&0!==nh.relays.length||(console.warn("Client not connected, initializing..."),await yh());const{timeout:n=3e4,useCache:r=!0}=t;if(r)try{const t=await ch(e);t.length>0&&console.log(`Found ${t.length} cached events in IndexedDB`)}catch(e){console.warn("Failed to query cached events",e)}return new Promise((t,r)=>{const o=[],i=setTimeout(()=>{console.log(`Timeout reached after ${n}ms, returning ${o.length} events`),sub.close(),o.length>0&&lh(o).catch(e=>console.warn("Failed to cache events",e)),t(o)},n);try{const n=Math.random().toString(36).substring(7);console.log(`📤 REQ [${n}]:`,JSON.stringify(["REQ",n,...e],null,2));const r=nh.pool.subscribeMany(nh.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)}),o.push(e),ah(e).catch(e=>console.warn("Failed to cache event",e))},oneose(){console.log(`✅ EOSE received for REQ [${n}], got ${o.length} events`),clearTimeout(i),r.close(),o.length>0&&lh(o).catch(e=>console.warn("Failed to cache events",e)),t(o)}})}catch(e){clearTimeout(i),console.error("Failed to fetch events:",e),r(e)}})}async function hh(e,t={}){const{timeout:n=1e4}=t;console.log(`Fetching event by ID: ${e}`);try{const t=[{ids:[e]}];console.log("Fetching event with filters:",t);const r=await fh(t,{timeout:n});return console.log(`Fetched ${r.length} events`),r.length>0?r[0]:null}catch(e){throw console.error("Failed to fetch event by ID:",e),e}}async function ph(e,t={}){const{timeout:n=1e4}=t;console.log(`Fetching delete events for target: ${e}`);try{const t=[{kinds:[5],"#e":[e]}];console.log("Fetching delete events with filters:",t);const r=await fh(t,{timeout:n});return console.log(`Fetched ${r.length} delete events`),r}catch(e){throw console.error("Failed to fetch delete events:",e),e}}async function yh(){await nh.connect()}async function gh(){try{const e=await sh(),t=e.transaction(ih,"readonly").objectStore(ih),n=await new Promise((e,n)=>{const r=t.getAll();r.onsuccess=()=>e(r.result),r.onerror=()=>n(r.error)}),r=n.reduce((e,t)=>(e[t.kind]=(e[t.kind]||0)+1,e),{});return console.log("===== IndexedDB Contents ====="),console.log(`Total events: ${n.length}`),console.log("Events by kind:",r),console.log("Kind 0 events:",n.filter(e=>0===e.kind)),console.log("All event IDs:",n.map(e=>({id:e.id.substring(0,8),kind:e.kind,pubkey:e.pubkey.substring(0,8)}))),console.log("=============================="),{total:n.length,byKind:r,events:n}}catch(e){return console.error("Failed to debug IndexedDB:",e),null}}const{window:wh}=l;function vh(e){let t,n,o,i,s,a,l,f,p,g,b,E,x,k,C,A,j,T;function _(e,t){return"extension"===e[2]?bh:mh}let $=_(e),I=$(e),R=e[5]&&Eh(e),O=e[6]&&xh(e);return{c(){t=h("div"),n=h("div"),o=h("div"),i=h("h2"),i.textContent="Login to Nostr",s=y(),a=h("button"),a.textContent="×",l=y(),f=h("div"),p=h("div"),g=h("button"),g.textContent="Extension",b=y(),E=h("button"),E.textContent="Nsec",x=y(),k=h("div"),I.c(),C=y(),R&&R.c(),A=y(),O&&O.c(),m(i,"class","svelte-1wl3v5c"),m(a,"class","close-btn svelte-1wl3v5c"),m(o,"class","modal-header svelte-1wl3v5c"),m(g,"class","tab-btn svelte-1wl3v5c"),S(g,"active","extension"===e[2]),m(E,"class","tab-btn svelte-1wl3v5c"),S(E,"active","nsec"===e[2]),m(p,"class","tabs svelte-1wl3v5c"),m(k,"class","tab-content svelte-1wl3v5c"),m(f,"class","tab-container svelte-1wl3v5c"),m(n,"class","modal svelte-1wl3v5c"),S(n,"dark-theme",e[1]),m(t,"class","modal-overlay svelte-1wl3v5c"),m(t,"role","button"),m(t,"tabindex","0")},m(r,d){u(r,t,d),c(t,n),c(n,o),c(o,i),c(o,s),c(o,a),c(n,l),c(n,f),c(f,p),c(p,g),c(p,b),c(p,E),c(f,x),c(f,k),I.m(k,null),c(k,C),R&&R.m(k,null),c(k,A),O&&O.m(k,null),j||(T=[w(a,"click",e[7]),w(g,"click",e[14]),w(E,"click",e[15]),w(n,"click",v(e[12])),w(n,"keydown",v(e[13])),w(t,"click",e[7]),w(t,"keydown",e[17])],j=!0)},p(e,t){4&t&&S(g,"active","extension"===e[2]),4&t&&S(E,"active","nsec"===e[2]),$===($=_(e))&&I?I.p(e,t):(I.d(1),I=$(e),I&&(I.c(),I.m(k,C))),e[5]?R?R.p(e,t):(R=Eh(e),R.c(),R.m(k,A)):R&&(R.d(1),R=null),e[6]?O?O.p(e,t):(O=xh(e),O.c(),O.m(k,null)):O&&(O.d(1),O=null),2&t&&S(n,"dark-theme",e[1])},d(e){e&&d(t),I.d(),R&&R.d(),O&&O.d(),j=!1,r(T)}}}function mh(e){let t,n,o,i,s,a,l,f,g,v,b=e[4]?"Logging in...":"Log in with nsec";return{c(){t=h("div"),n=h("p"),n.textContent="Enter your nsec (private key) to login. This\n will be stored securely in your browser.",o=y(),i=h("input"),s=y(),a=h("button"),l=p(b),m(n,"class","svelte-1wl3v5c"),m(i,"type","password"),m(i,"placeholder","nsec1..."),i.disabled=e[4],m(i,"class","nsec-input svelte-1wl3v5c"),m(a,"class","login-nsec-btn svelte-1wl3v5c"),a.disabled=f=e[4]||!e[3].trim(),m(t,"class","nsec-login svelte-1wl3v5c")},m(r,d){u(r,t,d),c(t,n),c(t,o),c(t,i),x(i,e[3]),c(t,s),c(t,a),c(a,l),g||(v=[w(i,"input",e[16]),w(a,"click",e[10])],g=!0)},p(e,t){16&t&&(i.disabled=e[4]),8&t&&i.value!==e[3]&&x(i,e[3]),16&t&&b!==(b=e[4]?"Logging in...":"Log in with nsec")&&E(l,b),24&t&&f!==(f=e[4]||!e[3].trim())&&(a.disabled=f)},d(e){e&&d(t),g=!1,r(v)}}}function bh(e){let t,n,r,o,i,s,a,l=e[4]?"Connecting...":"Log in using extension";return{c(){t=h("div"),n=h("p"),n.textContent="Login using a NIP-07 compatible browser\n extension like nos2x or Alby.",r=y(),o=h("button"),i=p(l),m(n,"class","svelte-1wl3v5c"),m(o,"class","login-extension-btn svelte-1wl3v5c"),o.disabled=e[4],m(t,"class","extension-login svelte-1wl3v5c")},m(l,d){u(l,t,d),c(t,n),c(t,r),c(t,o),c(o,i),s||(a=w(o,"click",e[9]),s=!0)},p(e,t){16&t&&l!==(l=e[4]?"Connecting...":"Log in using extension")&&E(i,l),16&t&&(o.disabled=e[4])},d(e){e&&d(t),s=!1,a()}}}function Eh(e){let t,n;return{c(){t=h("div"),n=p(e[5]),m(t,"class","message error-message svelte-1wl3v5c")},m(e,r){u(e,t,r),c(t,n)},p(e,t){32&t&&E(n,e[5])},d(e){e&&d(t)}}}function xh(e){let t,n;return{c(){t=h("div"),n=p(e[6]),m(t,"class","message success-message svelte-1wl3v5c")},m(e,r){u(e,t,r),c(t,n)},p(e,t){64&t&&E(n,e[6])},d(e){e&&d(t)}}}function kh(t){let n,r,o,i=t[0]&&vh(t);return{c(){i&&i.c(),n=g()},m(e,s){i&&i.m(e,s),u(e,n,s),r||(o=w(wh,"keydown",t[11]),r=!0)},p(e,[t]){e[0]?i?i.p(e,t):(i=vh(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),r=!1,o()}}}function Sh(e,t,n){const r=T();let{showModal:o=!1}=t,{isDarkTheme:i=!1}=t,s="extension",a="",l=!1,c="",u="";function d(){n(0,o=!1),n(3,a=""),n(5,c=""),n(6,u=""),r("close")}function f(e){n(2,s=e),n(5,c=""),n(6,u="")}async function h(){n(4,l=!0),n(5,c=""),n(6,u="");try{if(!a.trim())throw new Error("Please enter your nsec");if(!(e=a.trim()).startsWith("nsec1")||(e.length<60||e.length>70))throw new Error('Invalid nsec format. Must start with "nsec1"');const t=Dd.fromKey(a.trim()),o=await t.getPublicKey();localStorage.setItem("nostr_auth_method","nsec"),localStorage.setItem("nostr_pubkey",o),localStorage.setItem("nostr_privkey",a.trim()),n(6,u="Successfully logged in with nsec!"),r("login",{method:"nsec",pubkey:o,privateKey:a.trim(),signer:t}),setTimeout(()=>{d()},1500)}catch(e){n(5,c=e.message)}finally{n(4,l=!1)}var e}return e.$$set=e=>{"showModal"in e&&n(0,o=e.showModal),"isDarkTheme"in e&&n(1,i=e.isDarkTheme)},[o,i,s,a,l,c,u,d,f,async function(){n(4,l=!0),n(5,c=""),n(6,u="");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(6,u="Successfully logged in with extension!"),r("login",{method:"extension",pubkey:e,signer:window.nostr}),setTimeout(()=>{d()},1500))}catch(e){n(5,c=e.message)}finally{n(4,l=!1)}},h,function(e){"Escape"===e.key&&d(),"Enter"===e.key&&"nsec"===s&&h()},function(t){_.call(this,e,t)},function(t){_.call(this,e,t)},()=>f("extension"),()=>f("nsec"),function(){a=this.value,n(3,a)},e=>"Escape"===e.key&&d()]}class Ch extends Q{constructor(e){super(),Y(this,e,Sh,kh,i,{showModal:0,isDarkTheme:1})}}function Ah(e,t,n){const r=e.slice();return r[72]=t[n],r}function jh(e,t,n){const r=e.slice();return r[75]=t[n],r}function Th(e,t,n){const r=e.slice();return r[72]=t[n],r}function _h(e,t,n){const r=e.slice();return r[72]=t[n],r}function $h(e,t,n){const r=e.slice();return r[72]=t[n],r}function Ih(e,t,n){const r=e.slice();return r[72]=t[n],r}function Rh(e,t,n){const r=e.slice();return r[72]=t[n],r}function Oh(e){let t,n,r;return{c(){t=h("div"),n=p(e[3]),m(t,"class",r="message "+e[4]+" svelte-1smaj3x")},m(e,r){u(e,t,r),c(t,n)},p(e,o){8&o[0]&&E(n,e[3]),16&o[0]&&r!==(r="message "+e[4]+" svelte-1smaj3x")&&m(t,"class",r)},d(e){e&&d(t)}}}function Ph(e){let t,n,o,i,s,a,l,f,g,v,b,E,k,S,C,A,j,T,_,$,I,R,O,P,B,N,L,U;function F(e,t){return e[5]&&e[5].length>0?Nh:Bh}let M=F(e),D=M(e);function H(e,t){return e[8]&&e[8].length>0?Mh:Fh}let q=H(e),z=q(e);return{c(){t=h("div"),n=h("div"),o=h("h3"),o.textContent="Banned Pubkeys",i=y(),s=h("div"),a=h("input"),l=y(),f=h("input"),g=y(),v=h("button"),b=p("Ban Pubkey"),E=y(),k=h("div"),D.c(),S=y(),C=h("div"),A=h("h3"),A.textContent="Allowed Pubkeys",j=y(),T=h("div"),_=h("input"),$=y(),I=h("input"),R=y(),O=h("button"),P=p("Allow Pubkey"),B=y(),N=h("div"),z.c(),m(o,"class","svelte-1smaj3x"),m(a,"type","text"),m(a,"placeholder","Pubkey (64 hex chars)"),m(a,"class","svelte-1smaj3x"),m(f,"type","text"),m(f,"placeholder","Reason (optional)"),m(f,"class","svelte-1smaj3x"),v.disabled=e[2],m(v,"class","svelte-1smaj3x"),m(s,"class","add-form svelte-1smaj3x"),m(k,"class","list svelte-1smaj3x"),m(n,"class","section svelte-1smaj3x"),m(A,"class","svelte-1smaj3x"),m(_,"type","text"),m(_,"placeholder","Pubkey (64 hex chars)"),m(_,"class","svelte-1smaj3x"),m(I,"type","text"),m(I,"placeholder","Reason (optional)"),m(I,"class","svelte-1smaj3x"),O.disabled=e[2],m(O,"class","svelte-1smaj3x"),m(T,"class","add-form svelte-1smaj3x"),m(N,"class","list svelte-1smaj3x"),m(C,"class","section svelte-1smaj3x"),m(t,"class","pubkeys-section")},m(r,d){u(r,t,d),c(t,n),c(n,o),c(n,i),c(n,s),c(s,a),x(a,e[6]),c(s,l),c(s,f),x(f,e[7]),c(s,g),c(s,v),c(v,b),c(n,E),c(n,k),D.m(k,null),c(t,S),c(t,C),c(C,A),c(C,j),c(C,T),c(T,_),x(_,e[9]),c(T,$),c(T,I),x(I,e[10]),c(T,R),c(T,O),c(O,P),c(C,B),c(C,N),z.m(N,null),L||(U=[w(a,"input",e[43]),w(f,"input",e[44]),w(v,"click",e[25]),w(_,"input",e[45]),w(I,"input",e[46]),w(O,"click",e[26])],L=!0)},p(e,t){64&t[0]&&a.value!==e[6]&&x(a,e[6]),128&t[0]&&f.value!==e[7]&&x(f,e[7]),4&t[0]&&(v.disabled=e[2]),M===(M=F(e))&&D?D.p(e,t):(D.d(1),D=M(e),D&&(D.c(),D.m(k,null))),512&t[0]&&_.value!==e[9]&&x(_,e[9]),1024&t[0]&&I.value!==e[10]&&x(I,e[10]),4&t[0]&&(O.disabled=e[2]),q===(q=H(e))&&z?z.p(e,t):(z.d(1),z=q(e),z&&(z.c(),z.m(N,null)))},d(e){e&&d(t),D.d(),z.d(),L=!1,r(U)}}}function Bh(t){let n;return{c(){n=h("div"),n.innerHTML="

No banned pubkeys configured.

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

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

No banned events configured.

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

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

No blocked IPs configured.

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

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

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

No events need moderation at this time.

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

Configure access control using NIP-86 management API

\n
Owner Only: This interface is restricted to relay owners\n only.
',i=y(),J&&J.c(),s=y(),a=h("div"),l=h("button"),f=p("Pubkeys"),v=y(),b=h("button"),E=p("Events"),k=y(),S=h("button"),C=p("IPs"),j=y(),T=h("button"),_=p("Kinds"),I=y(),R=h("button"),O=p("Moderation"),B=y(),N=h("button"),L=p("Relay Config"),F=y(),M=h("div"),G&&G.c(),D=y(),Z&&Z.c(),H=y(),Y&&Y.c(),q=y(),Q&&Q.c(),z=y(),X&&X.c(),K=y(),ee&&ee.c(),m(o,"class","header svelte-1smaj3x"),m(l,"class",g="tab "+("pubkeys"===t[1]?"active":"")+" svelte-1smaj3x"),m(b,"class",x="tab "+("events"===t[1]?"active":"")+" svelte-1smaj3x"),m(S,"class",A="tab "+("ips"===t[1]?"active":"")+" svelte-1smaj3x"),m(T,"class",$="tab "+("kinds"===t[1]?"active":"")+" svelte-1smaj3x"),m(R,"class",P="tab "+("moderation"===t[1]?"active":"")+" svelte-1smaj3x"),m(N,"class",U="tab "+("relay"===t[1]?"active":"")+" svelte-1smaj3x"),m(a,"class","tabs svelte-1smaj3x"),m(M,"class","tab-content svelte-1smaj3x")},m(e,r){u(e,n,r),c(n,o),c(n,i),J&&J.m(n,null),c(n,s),c(n,a),c(a,l),c(l,f),c(a,v),c(a,b),c(b,E),c(a,k),c(a,S),c(S,C),c(a,j),c(a,T),c(T,_),c(a,I),c(a,R),c(R,O),c(a,B),c(a,N),c(N,L),c(n,F),c(n,M),G&&G.m(M,null),c(M,D),Z&&Z.m(M,null),c(M,H),Y&&Y.m(M,null),c(M,q),Q&&Q.m(M,null),c(M,z),X&&X.m(M,null),c(M,K),ee&&ee.m(M,null),W||(V=[w(l,"click",t[37]),w(b,"click",t[38]),w(S,"click",t[39]),w(T,"click",t[40]),w(R,"click",t[41]),w(N,"click",t[42])],W=!0)},p(e,t){e[3]?J?J.p(e,t):(J=Oh(e),J.c(),J.m(n,s)):J&&(J.d(1),J=null),2&t[0]&&g!==(g="tab "+("pubkeys"===e[1]?"active":"")+" svelte-1smaj3x")&&m(l,"class",g),2&t[0]&&x!==(x="tab "+("events"===e[1]?"active":"")+" svelte-1smaj3x")&&m(b,"class",x),2&t[0]&&A!==(A="tab "+("ips"===e[1]?"active":"")+" svelte-1smaj3x")&&m(S,"class",A),2&t[0]&&$!==($="tab "+("kinds"===e[1]?"active":"")+" svelte-1smaj3x")&&m(T,"class",$),2&t[0]&&P!==(P="tab "+("moderation"===e[1]?"active":"")+" svelte-1smaj3x")&&m(R,"class",P),2&t[0]&&U!==(U="tab "+("relay"===e[1]?"active":"")+" svelte-1smaj3x")&&m(N,"class",U),"pubkeys"===e[1]?G?G.p(e,t):(G=Ph(e),G.c(),G.m(M,D)):G&&(G.d(1),G=null),"events"===e[1]?Z?Z.p(e,t):(Z=qh(e),Z.c(),Z.m(M,H)):Z&&(Z.d(1),Z=null),"ips"===e[1]?Y?Y.p(e,t):(Y=Yh(e),Y.c(),Y.m(M,q)):Y&&(Y.d(1),Y=null),"kinds"===e[1]?Q?Q.p(e,t):(Q=np(e),Q.c(),Q.m(M,z)):Q&&(Q.d(1),Q=null),"moderation"===e[1]?X?X.p(e,t):(X=sp(e),X.c(),X.m(M,K)):X&&(X.d(1),X=null),"relay"===e[1]?ee?ee.p(e,t):(ee=dp(e),ee.c(),ee.m(M,null)):ee&&(ee.d(1),ee=null)},i:e,o:e,d(e){e&&d(n),J&&J.d(),G&&G.d(),Z&&Z.d(),Y&&Y.d(),Q&&Q.d(),X&&X.d(),ee&&ee.d(),W=!1,r(V)}}}function yp(e,t,n){let{userSigner:r}=t,{userPubkey:o}=t,i="pubkeys",s=!1,a="",l="info",c=[],u="",d="",f=[],h="",p="",y=[],g="",w="",v="",m="",E=[],x="",k="",S=[],C="",A=[],T={relay_name:"",relay_description:"",relay_icon:""};var _;async function $(){try{n(2,s=!0),console.log("Fetching relay info from /");const e=await fetch(window.location.origin+"/",{headers:{Accept:"application/nostr+json"}});if(console.log("Response status:",e.status),console.log("Response headers:",e.headers),e.ok){const t=await e.json();console.log("Raw relay info:",t),n(0,T={relay_name:t.name||"",relay_description:t.description||"",relay_icon:t.icon||""}),console.log("Updated relayConfig:",T),console.log("Loaded relay info:",t),n(3,a="Relay configuration loaded successfully"),n(4,l="success")}else console.error("Failed to fetch relay info, status:",e.status),n(3,a=`Failed to fetch relay info: ${e.status}`),n(4,l="error")}catch(e){console.error("Failed to fetch relay info:",e),n(3,a=`Failed to fetch relay info: ${e.message}`),n(4,l="error")}finally{n(2,s=!1)}}async function I(e,t=[]){try{n(2,s=!0),n(3,a="");const i={method:e,params:t},l=await async function(e,t){if(!r)throw new Error("No signer available for authentication. Please log in with a Nostr extension.");if(!o)throw new Error("No user pubkey available for authentication.");const n=window.location.origin+t,i={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",n],["method",e]],content:"",pubkey:o},s=await r.signEvent(i),a=JSON.stringify(s);return`Nostr ${btoa(a)}`}("POST","/api/nip86"),c=await fetch("/api/nip86",{method:"POST",headers:{"Content-Type":"application/nostr+json+rpc",Authorization:l},body:JSON.stringify(i)});if(!c.ok)throw new Error(`HTTP ${c.status}: ${c.statusText}`);const u=await c.json();if(u.error)throw new Error(u.error);return u.result}catch(e){throw console.error("NIP-86 API error:",e),n(3,a=e.message),n(4,l="error"),e}finally{n(2,s=!1)}}async function R(){try{n(5,c=await I("listbannedpubkeys"))}catch(e){console.error("Failed to load banned pubkeys:",e)}}async function O(){try{n(8,f=await I("listallowedpubkeys"))}catch(e){console.error("Failed to load allowed pubkeys:",e)}}async function P(){try{n(11,y=await I("listbannedevents"))}catch(e){console.error("Failed to load banned events:",e)}}async function B(){try{n(16,E=await I("listblockedips"))}catch(e){console.error("Failed to load blocked IPs:",e)}}async function N(){try{n(19,S=await I("listallowedkinds"))}catch(e){console.error("Failed to load allowed kinds:",e)}}async function L(){try{n(2,s=!0),n(21,A=await I("listeventsneedingmoderation")),console.log("Loaded events needing moderation:",A)}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,A=[])}finally{n(2,s=!1)}}async function U(e){try{await I("disallowkind",[e]),n(3,a="Kind disallowed successfully"),n(4,l="success"),await N()}catch(e){console.error("Failed to disallow kind:",e)}}async function F(e){try{await I("allowevent",[e,"Approved from moderation queue"]),n(3,a="Event allowed successfully"),n(4,l="success"),await L()}catch(e){console.error("Failed to allow event from moderation:",e)}}async function M(e){try{await I("banevent",[e,"Banned from moderation queue"]),n(3,a="Event banned successfully"),n(4,l="success"),await L()}catch(e){console.error("Failed to ban event from moderation:",e)}}_=()=>{setTimeout(()=>{$()},100)},j().$$.on_mount.push(_),async function(){await Promise.all([R(),O(),P(),B(),N()])}();return e.$$set=e=>{"userSigner"in e&&n(35,r=e.userSigner),"userPubkey"in e&&n(36,o=e.userPubkey)},e.$$.update=()=>{1&e.$$.dirty[0]&&console.log("relayConfig changed:",T)},[T,i,s,a,l,c,u,d,f,h,p,y,g,w,v,m,E,x,k,S,C,A,[],$,L,async function(){if(u)try{await I("banpubkey",[u,d]),n(3,a="Pubkey banned successfully"),n(4,l="success"),n(6,u=""),n(7,d=""),await R()}catch(e){console.error("Failed to ban pubkey:",e)}},async function(){if(h)try{await I("allowpubkey",[h,p]),n(3,a="Pubkey allowed successfully"),n(4,l="success"),n(9,h=""),n(10,p=""),await O()}catch(e){console.error("Failed to allow pubkey:",e)}},async function(){if(g)try{await I("banevent",[g,w]),n(3,a="Event banned successfully"),n(4,l="success"),n(12,g=""),n(13,w=""),await P()}catch(e){console.error("Failed to ban event:",e)}},async function(){if(v)try{await I("allowevent",[v,m]),n(3,a="Event allowed successfully"),n(4,l="success"),n(14,v=""),n(15,m="")}catch(e){console.error("Failed to allow event:",e)}},async function(){if(x)try{await I("blockip",[x,k]),n(3,a="IP blocked successfully"),n(4,l="success"),n(17,x=""),n(18,k=""),await B()}catch(e){console.error("Failed to block IP:",e)}},async function(){if(!C)return;const e=parseInt(C);if(isNaN(e))return n(3,a="Invalid kind number"),void n(4,l="error");try{await I("allowkind",[e]),n(3,a="Kind allowed successfully"),n(4,l="success"),n(20,C=""),await N()}catch(e){console.error("Failed to allow kind:",e)}},U,async function(){try{n(2,s=!0),n(3,a="");const e=[];if(T.relay_name&&e.push(I("changerelayname",[T.relay_name])),T.relay_description&&e.push(I("changerelaydescription",[T.relay_description])),T.relay_icon&&e.push(I("changerelayicon",[T.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 $()}catch(e){console.error("Failed to update relay configuration:",e),n(3,a=`Failed to update relay configuration: ${e.message}`),n(4,l="error")}finally{n(2,s=!1)}},F,M,r,o,()=>n(1,i="pubkeys"),()=>n(1,i="events"),()=>n(1,i="ips"),()=>n(1,i="kinds"),()=>{n(1,i="moderation"),A&&0!==A.length||L()},()=>n(1,i="relay"),function(){u=this.value,n(6,u)},function(){d=this.value,n(7,d)},function(){h=this.value,n(9,h)},function(){p=this.value,n(10,p)},function(){g=this.value,n(12,g)},function(){w=this.value,n(13,w)},function(){v=this.value,n(14,v)},function(){m=this.value,n(15,m)},function(){x=this.value,n(17,x)},function(){k=this.value,n(18,k)},function(){C=b(this.value),n(20,C)},e=>U(e),e=>F(e.id),e=>M(e.id),function(){T.relay_name=this.value,n(0,T)},function(){T.relay_description=this.value,n(0,T)},function(){T.relay_icon=this.value,n(0,T)}]}class gp extends Q{constructor(e){super(),Y(this,e,yp,pp,i,{userSigner:35,userPubkey:36},null,[-1,-1,-1])}}class wp{constructor(e,t,n){this.relayUrl=e,this.userSigner=t,this.userPubkey=n,this.ws=null,this.challenge=null,this.isAuthenticated=!1,this.authPromise=null}async connect(){return new Promise((e,t)=>{this.ws=new WebSocket(this.relayUrl),this.ws.onopen=()=>{console.log("WebSocket connected to relay:",this.relayUrl),e()},this.ws.onmessage=async e=>{try{const t=JSON.parse(e.data);await this.handleMessage(t)}catch(e){console.error("Error parsing relay message:",e)}},this.ws.onerror=e=>{console.error("WebSocket error:",e),t(new Error("Failed to connect to relay"))},this.ws.onclose=()=>{console.log("WebSocket connection closed"),this.isAuthenticated=!1,this.challenge=null},setTimeout(()=>{this.ws.readyState!==WebSocket.OPEN&&t(new Error("Connection timeout"))},1e4)})}async handleMessage(e){const[t,...n]=e;switch(t){case"AUTH":this.challenge=n[0],console.log("Received AUTH challenge:",this.challenge),await this.authenticate();break;case"OK":const[e,r,o]=n;e&&r?(console.log("Authentication successful for event:",e),this.isAuthenticated=!0,this.authPromise&&(this.authPromise.resolve(),this.authPromise=null)):e&&!r&&(console.error("Authentication failed:",o),this.authPromise&&(this.authPromise.reject(new Error(o||"Authentication failed")),this.authPromise=null));break;case"NOTICE":console.log("Relay notice:",n[0]);break;default:console.log("Unhandled message type:",t,n)}}async authenticate(){if(!this.challenge)throw new Error("No challenge received from relay");if(!this.userSigner)throw new Error("No signer available for authentication");try{const e={kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",this.relayUrl],["challenge",this.challenge]],content:"",pubkey:this.userPubkey},t=["AUTH",await this.userSigner.signEvent(e)];return this.ws.send(JSON.stringify(t)),console.log("Sent authentication event to relay"),new Promise((e,t)=>{this.authPromise={resolve:e,reject:t},setTimeout(()=>{this.authPromise&&(this.authPromise.reject(new Error("Authentication timeout")),this.authPromise=null)},1e4)})}catch(e){throw console.error("Authentication error:",e),e}}async publishEvent(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");return new Promise((t,n)=>{const r=["EVENT",e];this.ws.send(JSON.stringify(r));const o=this.ws.onmessage,i=setTimeout(()=>{this.ws.onmessage=o,n(new Error("Publish timeout"))},15e3);this.ws.onmessage=async r=>{try{const s=JSON.parse(r.data),[a,l,c,u]=s;if("OK"===a&&l===e.id)if(clearTimeout(i),this.ws.onmessage=o,c)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")){console.log("Authentication required, attempting to authenticate...");try{await this.authenticate();const t=["EVENT",e];return void this.ws.send(JSON.stringify(t))}catch(e){return void n(new Error(`Authentication failed: ${e.message}`))}}n(new Error(`Publish failed: ${u}`))}else await this.handleMessage(s)}catch(e){clearTimeout(i),this.ws.onmessage=o,n(e)}}})}close(){this.ws&&(this.ws.close(),this.ws=null),this.isAuthenticated=!1,this.challenge=null}getAuthenticated(){return this.isAuthenticated}}async function vp(e,t,n,r){const o=new wp(e,n,r);try{await o.connect();return await o.publishEvent(t)}finally{o.close()}}function mp(e,t,n){const r=e.slice();return r[150]=t[n],r}function bp(e,t,n){const r=e.slice();return r[168]=t[n],r}function Ep(e,t,n){const r=e.slice();return r[153]=t[n],r}function xp(e,t,n){const r=e.slice();r[153]=t[n];const o=r[46](r[153]);return r[162]=o,r}function kp(e,t,n){const r=e.slice();return r[165]=t[n],r}function Sp(e,t,n){const r=e.slice();return r[159]=t[n],r}function Cp(e,t,n){const r=e.slice();return r[153]=t[n],r}function Ap(e,t,n){const r=e.slice();return r[156]=t[n],r}function jp(e,t,n){const r=e.slice();return r[173]=t[n],r}function Tp(e){let t,n,r,o=e[1]&&e[4]&&$p(e);return{c(){t=h("div"),n=h("span"),r=p("ORLY? dashboard\n "),o&&o.c(),m(n,"class","app-title svelte-d3wb0j"),m(t,"class","header-title svelte-d3wb0j")},m(e,i){u(e,t,i),c(t,n),c(n,r),o&&o.m(n,null)},p(e,t){e[1]&&e[4]?o?o.p(e,t):(o=$p(e),o.c(),o.m(n,null)):o&&(o.d(1),o=null)},d(e){e&&d(t),o&&o.d()}}}function _p(e){let t,n,o,i;return{c(){t=h("div"),n=h("input"),m(n,"type","text"),m(n,"class","search-input svelte-d3wb0j"),m(n,"placeholder","Search..."),m(t,"class","search-input-container svelte-d3wb0j")},m(r,s){u(r,t,s),c(t,n),x(n,e[16]),o||(i=[w(n,"input",e[87]),w(n,"keydown",e[65])],o=!0)},p(e,t){65536&t[0]&&n.value!==e[16]&&x(n,e[16])},d(e){e&&d(t),o=!1,r(i)}}}function $p(e){let t,n;return{c(){t=h("span"),n=p(e[10]),m(t,"class","permission-badge svelte-d3wb0j")},m(e,r){u(e,t,r),c(t,n)},p(e,t){1024&t[0]&&E(n,e[10])},d(e){e&&d(t)}}}function Ip(t){let n,r,o;return{c(){n=h("button"),n.textContent="Log in",m(n,"class","login-btn svelte-d3wb0j")},m(e,i){u(e,n,i),r||(o=w(n,"click",t[58]),r=!0)},p:e,d(e){e&&d(n),r=!1,o()}}}function Rp(e){let t,n,r,o,i,s,a,l=(e[3]?.name||e[2].slice(0,8)+"...")+"";function f(e,t){return e[3]?.picture?Pp:Op}let g=f(e),v=g(e);return{c(){t=h("div"),n=h("button"),v.c(),r=y(),o=h("span"),i=p(l),m(o,"class","user-name svelte-d3wb0j"),m(n,"class","user-profile-btn svelte-d3wb0j"),m(t,"class","user-info svelte-d3wb0j")},m(l,d){u(l,t,d),c(t,n),v.m(n,null),c(n,r),c(n,o),c(o,i),s||(a=w(n,"click",e[62]),s=!0)},p(e,t){g===(g=f(e))&&v?v.p(e,t):(v.d(1),v=g(e),v&&(v.c(),v.m(n,r))),12&t[0]&&l!==(l=(e[3]?.name||e[2].slice(0,8)+"...")+"")&&E(i,l)},d(e){e&&d(t),v.d(),s=!1,a()}}}function Op(t){let n;return{c(){n=h("div"),n.textContent="👤",m(n,"class","user-avatar-placeholder svelte-d3wb0j")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Pp(e){let t,n;return{c(){t=h("img"),a(t.src,n=e[3].picture)||m(t,"src",n),m(t,"alt","User avatar"),m(t,"class","user-avatar svelte-d3wb0j")},m(e,n){u(e,t,n)},p(e,r){8&r[0]&&!a(t.src,n=e[3].picture)&&m(t,"src",n)},d(e){e&&d(t)}}}function Bp(e){let t,n,o;function i(){return e[88](e[173])}function s(...t){return e[89](e[173],...t)}return{c(){t=h("span"),t.textContent="✕",m(t,"class","tab-close-icon svelte-d3wb0j"),m(t,"role","button"),m(t,"tabindex","0")},m(e,r){u(e,t,r),n||(o=[w(t,"click",v(i)),w(t,"keydown",s)],n=!0)},p(t,n){e=t},d(e){e&&d(t),n=!1,r(o)}}}function Np(e){let t,n,r,o,i,s,a,l,f,g,v=e[173].icon+"",b=e[173].label+"",x=e[173].isSearchTab&&Bp(e);function k(){return e[90](e[173])}return{c(){t=h("button"),n=h("span"),r=p(v),o=y(),i=h("span"),s=p(b),a=y(),x&&x.c(),l=y(),m(n,"class","tab-icon svelte-d3wb0j"),m(i,"class","tab-label svelte-d3wb0j"),m(t,"class","tab svelte-d3wb0j"),S(t,"active",e[5]===e[173].id)},m(e,d){u(e,t,d),c(t,n),c(n,r),c(t,o),c(t,i),c(i,s),c(t,a),x&&x.m(t,null),c(t,l),f||(g=w(t,"click",k),f=!0)},p(n,o){e=n,2048&o[0]&&v!==(v=e[173].icon+"")&&E(r,v),2048&o[0]&&b!==(b=e[173].label+"")&&E(s,b),e[173].isSearchTab?x?x.p(e,o):(x=Bp(e),x.c(),x.m(t,l)):x&&(x.d(1),x=null),2080&o[0]&&S(t,"active",e[5]===e[173].id)},d(e){e&&d(t),x&&x.d(),f=!1,g()}}}function Lp(t){let n;function r(e,t){return e[1]?Vp:Wp}let o=r(t),i=o(t);return{c(){n=h("div"),i.c(),m(n,"class","welcome-message svelte-d3wb0j")},m(e,t){u(e,n,t),i.m(n,null)},p(e,t){o===(o=r(e))&&i?i.p(e,t):(i.d(1),i=o(e),i&&(i.c(),i.m(n,null)))},i:e,o:e,d(e){e&&d(n),i.d()}}}function Up(t){let n,r=t[6],o=[];for(let e=0;e=0||""!==t[30]&&parseInt(t[30])>=0,O=t[37],P=[];for(let e=0;eEvent Recovery \n

Search and recover old versions of replaceable events

',i=y(),s=h("div"),a=h("div"),l=h("div"),p=h("label"),p.textContent="Select Event Kind:",g=y(),v=h("select"),E=h("option"),E.textContent="Choose a replaceable kind...";for(let e=0;et[103].call(v)),m(l,"class","kind-selector svelte-d3wb0j"),m(A,"for","custom-kind"),m(A,"class","svelte-d3wb0j"),m(T,"id","custom-kind"),m(T,"type","number"),m(T,"placeholder","e.g., 10001"),m(T,"min","0"),m(T,"class","svelte-d3wb0j"),m(C,"class","custom-kind-input svelte-d3wb0j"),m(a,"class","recovery-controls svelte-d3wb0j"),m(s,"class","recovery-controls-card svelte-d3wb0j"),m(n,"class","recovery-tab svelte-d3wb0j")},m(e,r){u(e,n,r),c(n,o),c(n,i),c(n,s),c(s,a),c(a,l),c(l,p),c(l,g),c(l,v),c(v,E);for(let e=0;e=0||""!==e[30]&&parseInt(e[30])>=0),R?B?B.p(e,t):(B=oy(e),B.c(),B.m(n,null)):B&&(B.d(1),B=null)},i:e,o:e,d(e){e&&d(n),f(P,e),B&&B.d(),$=!1,r(I)}}}function Mp(t){let n,r,o;function i(e,t){return e[1]&&"owner"===e[4]?py:e[1]?hy:fy}let s=i(t),a=s(t);return{c(){n=h("div"),r=h("h2"),r.textContent="Sprocket Script Management",o=y(),a.c(),m(n,"class","sprocket-view svelte-d3wb0j")},m(e,t){u(e,n,t),c(n,r),c(n,o),a.m(n,null)},p(e,t){s===(s=i(e))&&a?a.p(e,t):(a.d(1),a=s(e),a&&(a.c(),a.m(n,null)))},i:e,o:e,d(e){e&&d(n),a.d()}}}function Dp(e){let t,n,r,o;const i=[xy,Ey,by],s=[];function a(e,t){return"managed"!==e[9]?0:e[1]&&"owner"===e[4]?1:2}return n=a(e),r=s[n]=i[n](e),{c(){t=h("div"),r.c(),m(t,"class","managed-acl-view svelte-d3wb0j")},m(e,r){u(e,t,r),s[n].m(t,null),o=!0},p(e,o){let l=n;n=a(e),n===l?s[n].p(e,o):(q(),W(s[l],1,1,()=>{s[l]=null}),z(),r=s[n],r?r.p(e,o):(r=s[n]=i[n](e),r.c()),K(r,1),r.m(t,null))},i(e){o||(K(r),o=!0)},o(e){W(r),o=!1},d(e){e&&d(t),s[n].d()}}}function Hp(t){let n,o,i,s,a,l,f,p,g,v,b,E;return{c(){n=h("div"),o=h("div"),i=h("button"),i.textContent="Reformat",s=y(),a=h("button"),a.textContent="Sign",l=y(),f=h("button"),f.textContent="Publish",p=y(),g=h("div"),v=h("textarea"),m(i,"class","compose-btn reformat-btn svelte-d3wb0j"),m(a,"class","compose-btn sign-btn svelte-d3wb0j"),m(f,"class","compose-btn publish-btn svelte-d3wb0j"),m(o,"class","compose-header svelte-d3wb0j"),m(v,"class","compose-textarea svelte-d3wb0j"),m(v,"placeholder","Enter your Nostr event JSON here..."),m(v,"spellcheck","false"),m(g,"class","compose-editor svelte-d3wb0j"),m(n,"class","compose-view svelte-d3wb0j")},m(e,r){u(e,n,r),c(n,o),c(o,i),c(o,s),c(o,a),c(o,l),c(o,f),c(n,p),c(n,g),c(g,v),x(v,t[28]),b||(E=[w(i,"click",t[76]),w(a,"click",t[77]),w(f,"click",t[78]),w(v,"input",t[99])],b=!0)},p(e,t){268435456&t[0]&&x(v,e[28])},i:e,o:e,d(e){e&&d(n),b=!1,r(E)}}}function qp(t){let n,r;function o(e,t){return!e[1]||"write"!==e[4]&&"admin"!==e[4]&&"owner"!==e[4]?ky:Sy}let i=o(t),s=i(t),a=t[1]&&("write"===t[4]||"admin"===t[4]||"owner"===t[4])&&Ny(t);return{c(){n=h("div"),s.c(),r=y(),a&&a.c(),m(n,"class","events-view-container svelte-d3wb0j")},m(e,t){u(e,n,t),s.m(n,null),c(n,r),a&&a.m(n,null)},p(e,t){i===(i=o(e))&&s?s.p(e,t):(s.d(1),s=i(e),s&&(s.c(),s.m(n,r))),!e[1]||"write"!==e[4]&&"admin"!==e[4]&&"owner"!==e[4]?a&&(a.d(1),a=null):a?a.p(e,t):(a=Ny(e),a.c(),a.m(n,null))},i:e,o:e,d(e){e&&d(n),s.d(),a&&a.d()}}}function zp(t){let n;function r(e,t){return!e[1]||"admin"!==e[10]&&"owner"!==e[10]?e[1]?My:Fy:Dy}let o=r(t),i=o(t);return{c(){n=h("div"),i.c(),m(n,"class","import-section svelte-d3wb0j")},m(e,t){u(e,n,t),i.m(n,null)},p(e,t){o===(o=r(e))&&i?i.p(e,t):(i.d(1),i=o(e),i&&(i.c(),i.m(n,null)))},i:e,o:e,d(e){e&&d(n),i.d()}}}function Kp(t){let n;function r(e,t){return e[1]?qy:Hy}let o=r(t),i=o(t);return{c(){i.c(),n=g()},m(e,t){i.m(e,t),u(e,n,t)},p(e,t){o===(o=r(e))&&i?i.p(e,t):(i.d(1),i=o(e),i&&(i.c(),i.m(n.parentNode,n)))},i:e,o:e,d(e){i.d(e),e&&d(n)}}}function Wp(t){let n;return{c(){n=h("p"),n.textContent="Log in to access your user dashboard",m(n,"class","svelte-d3wb0j")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Vp(e){let t,n,r,o=(e[3]?.name||e[2].slice(0,8)+"...")+"";return{c(){t=h("p"),n=p("Welcome "),r=p(o),m(t,"class","svelte-d3wb0j")},m(e,o){u(e,t,o),c(t,n),c(t,r)},p(e,t){12&t[0]&&o!==(o=(e[3]?.name||e[2].slice(0,8)+"...")+"")&&E(r,o)},d(e){e&&d(t)}}}function Jp(e){let t,n,o,i,s,a,l,f,g,v,b,x,k,S,C,A,j,T,_,$=e[168].query+"",I=e[36].get(e[168].id)?.isLoading,R=!e[36].get(e[168].id)?.hasMore&&e[36].get(e[168].id)?.events?.length>0;function O(){return e[107](e[168])}function P(e,t){return 64&t[0]&&(k=null),64&t[0]&&(S=null),null==k&&(k=!!(e[36].get(e[168].id)?.events?.length>0)),k?Zp:(null==S&&(S=!e[36].get(e[168].id)?.isLoading),S?Gp:void 0)}let B=P(e,[-1,-1,-1,-1,-1,-1]),N=B&&B(e),L=I&&ey(),U=R&&ty();function F(...t){return e[112](e[168],...t)}return{c(){t=h("div"),n=h("div"),o=h("h2"),i=p('🔍 Search Results: "'),s=p($),a=p('"'),l=y(),f=h("button"),g=p("🔄 Refresh"),b=y(),x=h("div"),N&&N.c(),C=y(),L&&L.c(),A=y(),U&&U.c(),j=y(),m(o,"class","svelte-d3wb0j"),m(f,"class","refresh-btn svelte-d3wb0j"),f.disabled=v=e[36].get(e[168].id)?.isLoading,m(n,"class","search-results-header svelte-d3wb0j"),m(x,"class","search-results-content svelte-d3wb0j"),m(t,"class","search-results-view svelte-d3wb0j")},m(e,r){u(e,t,r),c(t,n),c(n,o),c(o,i),c(o,s),c(o,a),c(n,l),c(n,f),c(f,g),c(t,b),c(t,x),N&&N.m(x,null),c(x,C),L&&L.m(x,null),c(x,A),U&&U.m(x,null),c(t,j),T||(_=[w(f,"click",O),w(x,"scroll",F)],T=!0)},p(t,n){e=t,64&n[0]&&$!==($=e[168].query+"")&&E(s,$),64&n[0]&&v!==(v=e[36].get(e[168].id)?.isLoading)&&(f.disabled=v),B===(B=P(e,n))&&N?N.p(e,n):(N&&N.d(1),N=B&&B(e),N&&(N.c(),N.m(x,C))),64&n[0]&&(I=e[36].get(e[168].id)?.isLoading),I?L||(L=ey(),L.c(),L.m(x,A)):L&&(L.d(1),L=null),64&n[0]&&(R=!e[36].get(e[168].id)?.hasMore&&e[36].get(e[168].id)?.events?.length>0),R?U||(U=ty(),U.c(),U.m(x,null)):U&&(U.d(1),U=null)},d(e){e&&d(t),N&&N.d(),L&&L.d(),U&&U.d(),T=!1,r(_)}}}function Gp(e){let t,n,r,o,i,s=e[168].query+"";return{c(){t=h("div"),n=h("p"),r=p('No search results found for "'),o=p(s),i=p('".'),m(n,"class","svelte-d3wb0j"),m(t,"class","no-search-results svelte-d3wb0j")},m(e,s){u(e,t,s),c(t,n),c(n,r),c(n,o),c(n,i)},p(e,t){64&t[0]&&s!==(s=e[168].query+"")&&E(o,s)},d(e){e&&d(t)}}}function Zp(e){let t,n=e[36].get(e[168].id).events,r=[];for(let t=0;t👤',i=y(),s=h("div"),a=h("div"),l=p(U),f=y(),g=h("div"),v=h("span"),b=p(F),x=y(),k=h("span"),C=p(M),A=y(),j=h("div"),T=h("div"),_=p(D),$=y(),I=h("div"),R=p(H),O=y(),z&&z.c(),P=y(),V&&V.c(),B=y(),m(o,"class","search-result-avatar svelte-d3wb0j"),m(a,"class","search-result-author svelte-d3wb0j"),m(v,"class","kind-number svelte-d3wb0j"),m(k,"class","kind-name svelte-d3wb0j"),m(g,"class","search-result-kind svelte-d3wb0j"),m(s,"class","search-result-info svelte-d3wb0j"),m(T,"class","event-timestamp svelte-d3wb0j"),m(I,"class","event-content-single-line svelte-d3wb0j"),m(j,"class","search-result-content svelte-d3wb0j"),m(n,"class","search-result-row svelte-d3wb0j"),m(n,"role","button"),m(n,"tabindex","0"),m(t,"class","search-result-item svelte-d3wb0j"),S(t,"expanded",e[18].has(e[153].id))},m(e,r){u(e,t,r),c(t,n),c(n,o),c(n,i),c(n,s),c(s,a),c(a,l),c(s,f),c(s,g),c(g,v),c(v,b),c(g,x),c(g,k),c(k,C),c(n,A),c(n,j),c(j,T),c(T,_),c(j,$),c(j,I),c(I,R),c(n,O),z&&z.m(n,null),c(t,P),V&&V.m(t,null),c(t,B),N||(L=[w(n,"click",K),w(n,"keydown",W)],N=!0)},p(r,o){e=r,64&o[0]&&U!==(U=ng(e[153].pubkey)+"")&&E(l,U),64&o[0]&&F!==(F=e[153].kind+"")&&E(b,F),64&o[0]&&M!==(M=e[38](e[153].kind)+"")&&E(C,M),64&o[0]&&D!==(D=og(e[153].created_at)+"")&&E(_,D),64&o[0]&&H!==(H=rg(e[153].content)+"")&&E(R,H),5!==e[153].kind&&("admin"===e[4]||"owner"===e[4]||"write"===e[4]&&e[153].pubkey&&e[153].pubkey===e[2])?z?z.p(e,o):(z=Yp(e),z.c(),z.m(n,null)):z&&(z.d(1),z=null),262208&o[0]&&(q=e[18].has(e[153].id)),q?V?V.p(e,o):(V=Qp(e),V.c(),V.m(t,B)):V&&(V.d(1),V=null),262208&o[0]|32&o[1]&&S(t,"expanded",e[18].has(e[153].id))},d(e){e&&d(t),z&&z.d(),V&&V.d(),N=!1,r(L)}}}function ey(e){let t;return{c(){t=h("div"),t.innerHTML='
\n

Searching...

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

No more search results to load.

',m(t,"class","end-of-search-results svelte-d3wb0j")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function ny(e){let t,n=e[168].id===e[5]&&Jp(e);return{c(){n&&n.c(),t=g()},m(e,r){n&&n.m(e,r),u(e,t,r)},p(e,r){e[168].id===e[5]?n?n.p(e,r):(n=Jp(e),n.c(),n.m(t.parentNode,t)):n&&(n.d(1),n=null)},d(e){n&&n.d(e),e&&d(t)}}}function ry(t){let n,r,o=t[165].label+"";return{c(){n=h("option"),r=p(o),n.__value=t[165].value,n.value=n.__value},m(e,t){u(e,n,t),c(n,r)},p:e,d(e){e&&d(n)}}}function oy(e){let t;function n(e,t){return e[32]?ay:0===e[31].length?sy:iy}let r=n(e),o=r(e);return{c(){t=h("div"),o.c(),m(t,"class","recovery-results svelte-d3wb0j")},m(e,n){u(e,t,n),o.m(t,null)},p(e,i){r===(r=n(e))&&o?o.p(e,i):(o.d(1),o=r(e),o&&(o.c(),o.m(t,null)))},d(e){e&&d(t),o.d()}}}function iy(e){let t,n,r,o=e[31],i=[];for(let t=0;tORLY_OWNERS environment variable with your npub when starting the\n relay.",i=y(),s=h("p"),a=p("Current user role: "),l=h("strong"),f=p(g),m(n,"class","svelte-d3wb0j"),m(o,"class","svelte-d3wb0j"),m(s,"class","svelte-d3wb0j"),m(t,"class","permission-denied svelte-d3wb0j")},m(e,d){u(e,t,d),c(t,n),c(t,r),c(t,o),c(t,i),c(t,s),c(s,a),c(s,l),c(l,f)},p(e,t){16&t[0]&&g!==(g=(e[4]||"none")+"")&&E(f,g)},d(e){e&&d(t)}}}function py(e){let t,n,o,i,s,a,l,g,v,b,k,C,A,j,T,_,$,I,R,O,P,B,N,L,U,F,M,D,H,q,z,K,W,V,J,G,Z,Y,Q,X,ee,te,ne,re,oe,ie,se,ae,le,ce,ue,de,fe,he,pe,ye,ge=e[22]?.is_running?"🟢 Running":"🔴 Stopped",we=e[22]?.script_exists?"✅ Exists":"❌ Not found",ve=e[22]?.pid&&yy(e),me=e[25]&&gy(e),be=e[23],Ee=[];for(let t=0;tORLY_ACL_MODE=managed in your\n environment variables and restart the relay.',m(r,"class","svelte-d3wb0j"),m(i,"class","svelte-d3wb0j"),m(a,"class","svelte-d3wb0j"),m(v,"class","svelte-d3wb0j"),m(n,"class","acl-mode-warning svelte-d3wb0j")},m(e,t){u(e,n,t),c(n,r),c(n,o),c(n,i),c(n,s),c(n,a),c(a,l),c(a,f),c(f,g),c(n,w),c(n,v)},p(e,t){512&t[0]&&b!==(b=(e[9]||"unknown")+"")&&E(g,b)},i:e,o:e,d(e){e&&d(n)}}}function ky(t){let n;return{c(){n=h("div"),n.innerHTML='

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

',m(n,"class","permission-denied svelte-d3wb0j")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Sy(e){let t,n,r,o,i;function s(e,t){return e[35].length>0?Ay:e[19]?void 0:Cy}let a=s(e),l=a&&a(e),f=e[19]&&Py(),p=!e[20]&&e[7].length>0&&By();return{c(){t=h("div"),l&&l.c(),n=y(),f&&f.c(),r=y(),p&&p.c(),m(t,"class","events-view-content svelte-d3wb0j")},m(s,a){u(s,t,a),l&&l.m(t,null),c(t,n),f&&f.m(t,null),c(t,r),p&&p.m(t,null),o||(i=w(t,"scroll",e[75]),o=!0)},p(e,o){a===(a=s(e))&&l?l.p(e,o):(l&&l.d(1),l=a&&a(e),l&&(l.c(),l.m(t,n))),e[19]?f||(f=Py(),f.c(),f.m(t,r)):f&&(f.d(1),f=null),!e[20]&&e[7].length>0?p||(p=By(),p.c(),p.m(t,null)):p&&(p.d(1),p=null)},d(e){e&&d(t),l&&l.d(),f&&f.d(),p&&p.d(),o=!1,i()}}}function Cy(t){let n;return{c(){n=h("div"),n.innerHTML='

No events found.

',m(n,"class","no-events svelte-d3wb0j")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Ay(e){let t,n=e[35],r=[];for(let t=0;t0&&_y(e);return{c(){t=h("div"),n=h("span"),n.textContent="🗑️ Delete Event",r=y(),o&&o.c(),m(n,"class","delete-event-label svelte-d3wb0j"),m(t,"class","delete-event-info svelte-d3wb0j")},m(e,i){u(e,t,i),c(t,n),c(t,r),o&&o.m(t,null)},p(e,n){e[153].tags&&e[153].tags.length>0?o?o.p(e,n):(o=_y(e),o.c(),o.m(t,null)):o&&(o.d(1),o=null)},d(e){e&&d(t),o&&o.d()}}}function _y(e){let t,n=e[153].tags.filter(sg),r=[];for(let t=0;t👤',i=y(),s=h("div"),a=h("div"),l=p(N),f=y(),g=h("div"),v=h("span"),b=p(L),x=y(),k=h("span"),C=p(U),A=y(),j=h("div"),T=h("div"),_=p(F),$=y(),q.c(),I=y(),z&&z.c(),R=y(),V&&V.c(),O=y(),m(o,"class","events-view-avatar svelte-d3wb0j"),m(a,"class","events-view-author svelte-d3wb0j"),m(v,"class","kind-number svelte-d3wb0j"),S(v,"delete-event",5===e[153].kind),m(k,"class","kind-name svelte-d3wb0j"),m(g,"class","events-view-kind svelte-d3wb0j"),m(s,"class","events-view-info svelte-d3wb0j"),m(T,"class","event-timestamp svelte-d3wb0j"),m(j,"class","events-view-content svelte-d3wb0j"),m(n,"class","events-view-row svelte-d3wb0j"),m(n,"role","button"),m(n,"tabindex","0"),m(t,"class","events-view-item svelte-d3wb0j"),S(t,"expanded",e[18].has(e[153].id))},m(e,r){u(e,t,r),c(t,n),c(n,o),c(n,i),c(n,s),c(s,a),c(a,l),c(s,f),c(s,g),c(g,v),c(v,b),c(g,x),c(g,k),c(k,C),c(n,A),c(n,j),c(j,T),c(T,_),c(j,$),q.m(j,null),c(n,I),z&&z.m(n,null),c(t,R),V&&V.m(t,null),c(t,O),P||(B=[w(n,"click",K),w(n,"keydown",W)],P=!0)},p(r,o){e=r,16&o[1]&&N!==(N=ng(e[153].pubkey)+"")&&E(l,N),16&o[1]&&L!==(L=e[153].kind+"")&&E(b,L),16&o[1]&&S(v,"delete-event",5===e[153].kind),16&o[1]&&U!==(U=e[38](e[153].kind)+"")&&E(C,U),16&o[1]&&F!==(F=og(e[153].created_at)+"")&&E(_,F),H===(H=D(e))&&q?q.p(e,o):(q.d(1),q=H(e),q&&(q.c(),q.m(j,null))),5!==e[153].kind&&("admin"===e[4]||"owner"===e[4]||"write"===e[4]&&e[153].pubkey&&e[153].pubkey===e[2])?z?z.p(e,o):(z=Iy(e),z.c(),z.m(n,null)):z&&(z.d(1),z=null),262144&o[0]|16&o[1]&&(M=e[18].has(e[153].id)),M?V?V.p(e,o):(V=Ry(e),V.c(),V.m(t,O)):V&&(V.d(1),V=null),262144&o[0]|16&o[1]&&S(t,"expanded",e[18].has(e[153].id))},d(e){e&&d(t),q.d(),z&&z.d(),V&&V.d(),P=!1,r(B)}}}function Py(e){let t;return{c(){t=h("div"),t.innerHTML='
\n

Loading events...

',m(t,"class","loading-events svelte-d3wb0j")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function By(e){let t;return{c(){t=h("div"),t.innerHTML='

No more events to load.

',m(t,"class","end-of-events svelte-d3wb0j")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Ny(e){let t,n,o,i,s,a,l,f,g,v,b,E,x,k,S,C;function A(e,t){return e[19]?Uy:Ly}let j=A(e),T=j(e);return{c(){t=h("div"),n=h("div"),o=h("label"),i=h("input"),s=y(),a=h("span"),l=y(),f=h("span"),f.textContent="Only show my events",g=y(),v=h("div"),b=h("button"),E=p("🔄 Load More"),x=y(),k=h("button"),T.c(),m(i,"type","checkbox"),m(i,"class","svelte-d3wb0j"),m(a,"class","toggle-slider svelte-d3wb0j"),m(f,"class","toggle-label svelte-d3wb0j"),m(o,"class","toggle-container svelte-d3wb0j"),m(n,"class","events-view-toggle svelte-d3wb0j"),m(b,"class","refresh-btn svelte-d3wb0j"),b.disabled=e[19],m(k,"class","reload-btn svelte-d3wb0j"),k.disabled=e[19],m(v,"class","events-view-buttons svelte-d3wb0j"),m(t,"class","events-view-header svelte-d3wb0j")},m(r,d){u(r,t,d),c(t,n),c(n,o),c(o,i),i.checked=e[8],c(o,s),c(o,a),c(o,l),c(o,f),c(t,g),c(t,v),c(v,b),c(b,E),c(v,x),c(v,k),T.m(k,null),S||(C=[w(i,"change",e[95]),w(i,"change",e[96]),w(b,"click",e[97]),w(k,"click",e[98])],S=!0)},p(e,t){256&t[0]&&(i.checked=e[8]),524288&t[0]&&(b.disabled=e[19]),j!==(j=A(e))&&(T.d(1),T=j(e),T&&(T.c(),T.m(k,null))),524288&t[0]&&(k.disabled=e[19])},d(e){e&&d(t),T.d(),S=!1,r(C)}}}function Ly(e){let t;return{c(){t=p("🔄")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Uy(e){let t;return{c(){t=h("div"),m(t,"class","spinner svelte-d3wb0j")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Fy(t){let n,r,o,i,s,a,l,f;return{c(){n=h("div"),r=h("h3"),r.textContent="Import Events",o=y(),i=h("p"),i.textContent="Please log in to access import functionality.",s=y(),a=h("button"),a.textContent="Log In",m(r,"class","recovery-header svelte-d3wb0j"),m(i,"class","recovery-description svelte-d3wb0j"),m(a,"class","login-btn svelte-d3wb0j"),m(n,"class","login-prompt svelte-d3wb0j")},m(e,d){u(e,n,d),c(n,r),c(n,o),c(n,i),c(n,s),c(n,a),l||(f=w(a,"click",t[58]),l=!0)},p:e,d(e){e&&d(n),l=!1,f()}}}function My(t){let n;return{c(){n=h("div"),n.innerHTML='

Import Events

\n

❌ Admin or owner permission required for import\n functionality.

',m(n,"class","permission-denied svelte-d3wb0j")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Dy(e){let t,n,o,i,s,a,l,f,g,v,b,E;return{c(){t=h("h3"),t.textContent="Import Events",n=y(),o=h("p"),o.textContent="Upload a JSONL file to import events into the database.",i=y(),s=h("div"),a=h("input"),l=y(),f=h("button"),g=p("Import Events"),m(t,"class","svelte-d3wb0j"),m(o,"class","svelte-d3wb0j"),m(a,"type","file"),m(a,"id","import-file"),m(a,"accept",".jsonl,.txt"),m(a,"class","svelte-d3wb0j"),m(f,"class","import-btn svelte-d3wb0j"),f.disabled=v=!e[17],m(s,"class","recovery-controls-card svelte-d3wb0j")},m(r,d){u(r,t,d),u(r,n,d),u(r,o,d),u(r,i,d),u(r,s,d),c(s,a),c(s,l),c(s,f),c(f,g),b||(E=[w(a,"change",e[72]),w(f,"click",e[73])],b=!0)},p(e,t){131072&t[0]&&v!==(v=!e[17])&&(f.disabled=v)},d(e){e&&d(t),e&&d(n),e&&d(o),e&&d(i),e&&d(s),b=!1,r(E)}}}function Hy(t){let n,r,o,i,s,a;return{c(){n=h("div"),r=h("p"),r.textContent="Please log in to access export functionality.",o=y(),i=h("button"),i.textContent="Log In",m(r,"class","svelte-d3wb0j"),m(i,"class","login-btn svelte-d3wb0j"),m(n,"class","login-prompt svelte-d3wb0j")},m(e,l){u(e,n,l),c(n,r),c(n,o),c(n,i),s||(a=w(i,"click",t[58]),s=!0)},p:e,d(e){e&&d(n),s=!1,a()}}}function qy(e){let t,n,r,o,i,s,a,l,f,p,v=("admin"===e[10]||"owner"===e[10])&&zy(e);return{c(){t=h("div"),n=h("h3"),n.textContent="Export My Events",r=y(),o=h("p"),o.textContent="Download your personal events as a JSONL file.",i=y(),s=h("button"),s.textContent="📤 Export My Events",a=y(),v&&v.c(),l=g(),m(n,"class","svelte-d3wb0j"),m(o,"class","svelte-d3wb0j"),m(s,"class","export-btn svelte-d3wb0j"),m(t,"class","export-section svelte-d3wb0j")},m(d,h){u(d,t,h),c(t,n),c(t,r),c(t,o),c(t,i),c(t,s),u(d,a,h),v&&v.m(d,h),u(d,l,h),f||(p=w(s,"click",e[71]),f=!0)},p(e,t){"admin"===e[10]||"owner"===e[10]?v?v.p(e,t):(v=zy(e),v.c(),v.m(l.parentNode,l)):v&&(v.d(1),v=null)},d(e){e&&d(t),e&&d(a),v&&v.d(e),e&&d(l),f=!1,p()}}}function zy(t){let n,r,o,i,s,a,l,f;return{c(){n=h("div"),r=h("h3"),r.textContent="Export All Events",o=y(),i=h("p"),i.textContent="Download the complete database as a JSONL file. This\n includes all events from all users.",s=y(),a=h("button"),a.textContent="📤 Export All Events",m(r,"class","svelte-d3wb0j"),m(i,"class","svelte-d3wb0j"),m(a,"class","export-btn svelte-d3wb0j"),m(n,"class","export-section svelte-d3wb0j")},m(e,d){u(e,n,d),c(n,r),c(n,o),c(n,i),c(n,s),c(n,a),l||(f=w(a,"click",t[70]),l=!0)},p:e,d(e){e&&d(n),l=!1,f()}}}function Ky(e){let t,n,o,i,s,a,l,f,p,g;function b(e,t){return e[3]?Vy:e[1]&&e[2]?Wy:void 0}let E=b(e),x=E&&E(e);return{c(){t=h("div"),n=h("div"),o=h("div"),i=h("h2"),i.textContent="Settings",s=y(),a=h("button"),a.textContent="✕",l=y(),f=h("div"),x&&x.c(),m(i,"class","svelte-d3wb0j"),m(a,"class","close-btn svelte-d3wb0j"),m(o,"class","drawer-header svelte-d3wb0j"),m(f,"class","drawer-content"),m(n,"class","settings-drawer svelte-d3wb0j"),S(n,"dark-theme",e[0]),m(t,"class","drawer-overlay svelte-d3wb0j"),m(t,"role","button"),m(t,"tabindex","0")},m(r,d){u(r,t,d),c(t,n),c(n,o),c(o,i),c(o,s),c(o,a),c(n,l),c(n,f),x&&x.m(f,null),p||(g=[w(a,"click",e[63]),w(n,"click",v(e[84])),w(n,"keydown",v(e[85])),w(t,"click",e[63]),w(t,"keydown",e[114])],p=!0)},p(e,t){E===(E=b(e))&&x?x.p(e,t):(x&&x.d(1),x=E&&E(e),x&&(x.c(),x.m(f,null))),1&t[0]&&S(n,"dark-theme",e[0])},d(e){e&&d(t),x&&x.d(),p=!1,r(g)}}}function Wy(e){let t,n,r,o,i,s,a,l,f,g,v,b,x,k,S,C=e[2].slice(0,16)+"",A=e[2].slice(-8)+"";return{c(){t=h("div"),n=h("h3"),n.textContent="Profile Loading",r=y(),o=h("p"),o.textContent="Your profile metadata is being loaded...",i=y(),s=h("button"),s.textContent="Retry Loading Profile",a=y(),l=h("div"),f=h("strong"),f.textContent="Public Key:",g=y(),v=p(C),b=p("..."),x=p(A),m(n,"class","svelte-d3wb0j"),m(o,"class","svelte-d3wb0j"),m(s,"class","retry-profile-btn svelte-d3wb0j"),m(l,"class","user-pubkey-display svelte-d3wb0j"),m(t,"class","profile-loading-section svelte-d3wb0j")},m(d,h){u(d,t,h),c(t,n),c(t,r),c(t,o),c(t,i),c(t,s),c(t,a),c(t,l),c(l,f),c(l,g),c(l,v),c(l,b),c(l,x),k||(S=w(s,"click",e[69]),k=!0)},p(e,t){4&t[0]&&C!==(C=e[2].slice(0,16)+"")&&E(v,C),4&t[0]&&A!==(A=e[2].slice(-8)+"")&&E(x,A)},d(e){e&&d(t),k=!1,S()}}}function Vy(e){let t,n,r,o,i,s,a,l,f,v,b,x,k,S,C,A=(e[3].name||"Unknown User")+"",j=e[3].banner&&Jy(e);function T(e,t){return e[3].picture?Zy:Gy}let _=T(e),$=_(e),I=e[3].nip05&&Yy(e),R=e[3].about&&Qy(e),O=e[4]&&"read"!==e[4]&&Xy(e);return{c(){t=h("div"),n=h("div"),j&&j.c(),r=y(),o=h("button"),o.textContent="Log out",i=y(),$.c(),s=y(),a=h("div"),l=h("h3"),f=p(A),v=y(),I&&I.c(),b=y(),R&&R.c(),x=y(),O&&O.c(),k=g(),m(o,"class","logout-btn floating svelte-d3wb0j"),m(l,"class","profile-username svelte-d3wb0j"),m(a,"class","name-row svelte-d3wb0j"),m(n,"class","profile-hero svelte-d3wb0j"),m(t,"class","profile-section svelte-d3wb0j")},m(d,h){u(d,t,h),c(t,n),j&&j.m(n,null),c(n,r),c(n,o),c(n,i),$.m(n,null),c(n,s),c(n,a),c(a,l),c(l,f),c(a,v),I&&I.m(a,null),c(t,b),R&&R.m(t,null),u(d,x,h),O&&O.m(d,h),u(d,k,h),S||(C=w(o,"click",e[60]),S=!0)},p(e,o){e[3].banner?j?j.p(e,o):(j=Jy(e),j.c(),j.m(n,r)):j&&(j.d(1),j=null),_===(_=T(e))&&$?$.p(e,o):($.d(1),$=_(e),$&&($.c(),$.m(n,s))),8&o[0]&&A!==(A=(e[3].name||"Unknown User")+"")&&E(f,A),e[3].nip05?I?I.p(e,o):(I=Yy(e),I.c(),I.m(a,null)):I&&(I.d(1),I=null),e[3].about?R?R.p(e,o):(R=Qy(e),R.c(),R.m(t,null)):R&&(R.d(1),R=null),e[4]&&"read"!==e[4]?O?O.p(e,o):(O=Xy(e),O.c(),O.m(k.parentNode,k)):O&&(O.d(1),O=null)},d(e){e&&d(t),j&&j.d(),$.d(),I&&I.d(),R&&R.d(),e&&d(x),O&&O.d(e),e&&d(k),S=!1,C()}}}function Jy(e){let t,n;return{c(){t=h("img"),a(t.src,n=e[3].banner)||m(t,"src",n),m(t,"alt","Profile banner"),m(t,"class","profile-banner svelte-d3wb0j")},m(e,n){u(e,t,n)},p(e,r){8&r[0]&&!a(t.src,n=e[3].banner)&&m(t,"src",n)},d(e){e&&d(t)}}}function Gy(t){let n;return{c(){n=h("div"),n.textContent="👤",m(n,"class","profile-avatar-placeholder overlap svelte-d3wb0j")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Zy(e){let t,n;return{c(){t=h("img"),a(t.src,n=e[3].picture)||m(t,"src",n),m(t,"alt","User avatar"),m(t,"class","profile-avatar overlap svelte-d3wb0j")},m(e,n){u(e,t,n)},p(e,r){8&r[0]&&!a(t.src,n=e[3].picture)&&m(t,"src",n)},d(e){e&&d(t)}}}function Yy(e){let t,n,r=e[3].nip05+"";return{c(){t=h("span"),n=p(r),m(t,"class","profile-nip05-inline svelte-d3wb0j")},m(e,r){u(e,t,r),c(t,n)},p(e,t){8&t[0]&&r!==(r=e[3].nip05+"")&&E(n,r)},d(e){e&&d(t)}}}function Qy(e){let t,n;return{c(){t=h("div"),n=h("p"),m(n,"class","profile-about svelte-d3wb0j"),m(t,"class","about-card svelte-d3wb0j")},m(r,o){u(r,t,o),c(t,n),n.innerHTML=e[34]},p(e,t){8&t[1]&&(n.innerHTML=e[34])},d(e){e&&d(t)}}}function Xy(e){let t,n,r,o,i,s,a=e[80](),l=[];for(let t=0;tfunction(e,t,n){const r=e.$$.props[t];void 0!==r&&(e.$$.bound[r]=n,n(e.$$.ctx[r]))}(F,"showModal",ue)),F.$on("login",e[59]),F.$on("close",e[61]),{c(){t=h("header"),n=h("div"),o=h("img"),s=y(),ee.c(),l=y(),g=h("button"),g.textContent="🔍",v=y(),b=h("button"),x=p(Y),k=y(),re.c(),C=y(),A=h("div"),j=h("aside"),T=h("div"),_=h("div");for(let e=0;e{ae[o]=null}),z(),N=ae[B],N?N.p(e,r):(N=ae[B]=se[B](e),N.c()),K(N,1),N.m(R,null)),(!D||1&r[0])&&S(A,"dark-theme",e[0]),e[14]?ce?ce.p(e,r):(ce=Ky(e),ce.c(),ce.m(U.parentNode,U)):ce&&(ce.d(1),ce=null);const i={};var s;1&r[0]&&(i.isDarkTheme=e[0]),!M&&4096&r[0]&&(M=!0,i.showModal=e[12],s=()=>M=!1,O.push(s)),F.$set(i)},i(e){D||(K(N),K(F.$$.fragment,e),D=!0)},o(e){W(N),W(F.$$.fragment,e),D=!1},d(e){e&&d(t),ee.d(),re.d(),e&&d(C),e&&d(A),f(ie,e),ae[B].d(),e&&d(L),ce&&ce.d(e),e&&d(U),G(F,e),H=!1,r(Z)}}}function ng(e){return e?e.slice(0,8)+"..."+e.slice(-8):"unknown"}function rg(e,t=100){return e?e.length>t?e.slice(0,t)+"...":e:""}function og(e){return e?new Date(1e3*e).toLocaleString():""}async function ig(e,t){try{const n=JSON.stringify(e);await navigator.clipboard.writeText(n);const r=t.target.closest(".copy-json-btn");if(r){const e=r.textContent;r.textContent="✅",r.style.backgroundColor="#4CAF50",setTimeout(()=>{r.textContent=e,r.style.backgroundColor=""},2e3)}}catch(n){console.error("Failed to copy to clipboard:",n);try{const n=document.createElement("textarea");n.value=JSON.stringify(e),document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n);const r=t.target.closest(".copy-json-btn");if(r){const e=r.textContent;r.textContent="✅",r.style.backgroundColor="#4CAF50",setTimeout(()=>{r.textContent=e,r.style.backgroundColor=""},2e3)}}catch(e){console.error("Fallback copy also failed:",e),alert("Failed to copy to clipboard. Please copy manually.")}}}const sg=e=>"e"===e[0];function ag(e,t,n){let r,o,i,s,a;"undefined"!=typeof window&&(window.debugIndexedDB=gh);let l=!1,c=!1,u=!1,d="",f="",h=null,p="",y=null,g=!1,w=localStorage.getItem("selectedTab")||"export",v=!1,m="",E=[],x=[],k=null,S=new Set,C=!1,A=!0,j=null,T="",$=new Map,I=[],R=0;const O=3e5;let P=!1,B=[],N=!0,L=null,U="",F=null,M=[],D=!1,H="",q="info",z=!1,K=null,W="",V="",J=null,G="",Z=[],Y=!1,Q=!0,X=null;const ee=[{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)"}],te={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"};function ne(e){S.has(e)?S.delete(e):S.add(e),n(18,S)}async function re(){console.log("Toggle changed, showOnlyMyEvents:",P);const e=P&&u&&d?[d]:null;await Se(!0,e)}async function oe(e){if(!u)return void alert("Please log in first");const t=x.find(t=>t.id===e);if(!t)return void alert("Event not found");if("admin"===p||"owner"===p||"write"===p&&t.pubkey&&t.pubkey===d){if(confirm("Are you sure you want to delete this event?"))try{if(!y)throw new Error("Signer not available for signing");const r={kind:5,created_at:Math.floor(Date.now()/1e3),tags:[["e",e]],content:""};console.log("Created delete event template:",r),console.log("User pubkey:",d),console.log("Target event:",t),console.log("Target event pubkey:",t.pubkey);const o=await y.signEvent(r);console.log("Signed delete event:",o),console.log("Signed delete event pubkey:",o.pubkey),console.log("Delete event tags:",o.tags);const i=`wss://${window.location.host}`;try{const e=await vp(i,o,y,d);e.success?console.log("Delete event published successfully to ORLY relay"):console.error("Failed to publish delete event:",e.reason)}catch(e){console.error("Error publishing delete event:",e)}const s=t.pubkey&&t.pubkey===d;if(s){const t=await nh.publish(o);if(console.log("Delete event published:",t),!(t.success&&t.okCount>0))throw new Error("No relays accepted the delete event");{await new Promise(e=>setTimeout(e,2e3));try{const n=await hh(e,{timeout:5e3});n?(console.warn("Event still exists after deletion attempt:",n),alert(`Warning: Delete event was accepted by ${t.okCount} relay(s), but the event still exists on the relay. This may indicate the relay does not properly handle delete events.`)):console.log("Event successfully deleted and verified")}catch(e){console.log("Could not fetch event after deletion (likely deleted):",e.message)}try{const t=await ph(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(7,x=x.filter(t=>t.id!==e)),B=B.filter(t=>t.id!==e),I=I.filter(t=>t.id!==e);for(const[t,n]of $)n.events&&(n.events=n.events.filter(t=>t.id!==e),$.set(t,n));ae(),console.log("Reloading events to show delete event...");const r=P&&u&&d?[d]:null;await Se(!0,r),alert(`Event deleted successfully (accepted by ${t.okCount} relay(s))`)}}else{const t=`wss://${window.location.host}/`,r=new th;await r.connectToRelay(t);const i=await r.publish(o);if(console.log("Delete event published to local relay only:",i),!(i.success&&i.okCount>0))throw new Error("Local relay did not accept the delete event");{await new Promise(e=>setTimeout(e,2e3));try{const t=await hh(e,{timeout:5e3});t?(console.warn("Event still exists after deletion attempt:",t),alert(`Warning: Delete event was accepted by ${i.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 ph(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(7,x=x.filter(t=>t.id!==e)),B=B.filter(t=>t.id!==e),I=I.filter(t=>t.id!==e);for(const[t,n]of $)n.events&&(n.events=n.events.filter(t=>t.id!==e),$.set(t,n));ae(),console.log("Reloading events to show delete event...");const t=P&&u&&d?[d]:null;await Se(!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 ie(){const e=G?parseInt(G):J;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(32,Y=!0);try{const t=[{kinds:[e],authors:[d],limit:100}];X&&(t[0].until=X),console.log("Recovery filters:",t);const r=await async function(e,t={}){const{timeout:n=3e4,cacheFirst:r=!0,cacheOnly:o=!1}=t;let i=[];if(r||o)try{if(i=await ch(e),console.log(`Found ${i.length} events in cache`),o||i.length>0)return i}catch(e){console.warn("Failed to query cache",e)}if(!o){const t=await fh(e,{timeout:n,useCache:!1});return console.log(`Fetched ${t.length} events from relay`),t}return i}(t,{timeout:3e4,cacheFirst:!0});console.log("Recovery events received:",r.length),console.log("Recovery events kinds:",r.map(e=>e.kind)),n(31,Z=X?[...Z,...r]:r),r.length>0?(X=Math.min(...r.map(e=>e.created_at)),n(33,Q=100===r.length)):n(33,Q=!1)}catch(e){console.error("Failed to load recovery events:",e)}finally{n(32,Y=!1)}}else console.log("Not logged in, cannot load recovery events")}async function se(e){if(confirm("Are you sure you want to repost this event?"))try{const t=`wss://${window.location.host}/`;console.log("Reposting event to local relay:",t,e);const r={...e};if(r.created_at=Math.floor(Date.now()/1e3),r.id="",r.sig="",e.kind>=3e4&&e.kind<=39999){const t=e.tags.find(e=>"d"===e[0]);t&&(r.tags=r.tags.filter(e=>"d"!==e[0]),r.tags.push(t))}if(y){const e=await y.sign(r);console.log("Signed event for repost:",e);const o=await nh.publish(e,[t]);console.log("Repost publish result:",o),o.success&&o.okCount>0?(alert("Event reposted successfully!"),n(33,Q=!1),await ie()):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)}}if("undefined"!=typeof localStorage){const e=localStorage.getItem("isDarkTheme");null!==e&&(l=JSON.parse(e));const t=localStorage.getItem("nostr_auth_method"),r=localStorage.getItem("nostr_pubkey");t&&r&&(u=!0,d=r,f=t,"extension"===t&&window.nostr&&(y=window.nostr),Ee(),xe()),function(){if("undefined"==typeof localStorage)return;try{const t=localStorage.getItem("app_state");if(t){const r=JSON.parse(t);r.selectedTab&&pe.some(e=>e.id===r.selectedTab)&&n(5,w=r.selectedTab),r.expandedEvents&&n(18,S=new Set(r.expandedEvents)),r.globalEventsCache&&(I=r.globalEventsCache),r.globalCacheTimestamp&&(R=r.globalCacheTimestamp),void 0!==r.hasMoreEvents&&n(20,A=r.hasMoreEvents),r.oldestEventTimestamp&&(j=r.oldestEventTimestamp),void 0!==r.hasMoreMyEvents&&(N=r.hasMoreMyEvents),r.oldestMyEventTimestamp&&(L=r.oldestMyEventTimestamp),I.length>0&&((e=R)&&Date.now()-et.created_at-e.created_at),R=Date.now(),ae()}async function ce(){if(u&&"owner"===p&&z)try{n(24,D=!0);const e=await fetch("/api/sprocket/status",{method:"GET",headers:{Authorization:`Nostr ${await je("GET","/api/sprocket/status")}`,"Content-Type":"application/json"}});e.ok?n(22,F=await e.json()):he("Failed to load sprocket status","error")}catch(e){he(`Error loading sprocket status: ${e.message}`,"error")}finally{n(24,D=!1)}}async function ue(){if(u&&"owner"===p)try{n(24,D=!0);const e=await fetch("/api/sprocket/versions",{method:"GET",headers:{Authorization:`Nostr ${await je("GET","/api/sprocket/versions")}`,"Content-Type":"application/json"}});e.ok?n(23,M=await e.json()):he("Failed to load versions","error")}catch(e){he(`Error loading versions: ${e.message}`,"error")}finally{n(24,D=!1)}}async function de(e){u&&"owner"===p&&(n(21,U=e.content),he(`Loaded version: ${e.name}`,"success"))}async function fe(e){if(u&&"owner"===p&&confirm(`Are you sure you want to delete version ${e}?`))try{n(24,D=!0);const t=await fetch("/api/sprocket/delete-version",{method:"POST",headers:{Authorization:`Nostr ${await je("POST","/api/sprocket/delete-version")}`,"Content-Type":"application/json"},body:JSON.stringify({filename:e})});if(t.ok)he(`Version ${e} deleted successfully`,"success"),await ue();else{he(`Failed to delete version: ${await t.text()}`,"error")}}catch(e){he(`Error deleting version: ${e.message}`,"error")}finally{n(24,D=!1)}}function he(e,t="info"){n(25,H=e),n(26,q=t),setTimeout(()=>{n(25,H="")},5e3)}const pe=[{id:"export",icon:"📤",label:"Export"},{id:"import",icon:"💾",label:"Import",requiresAdmin:!0},{id:"events",icon:"📡",label:"Events"},{id:"compose",icon:"✏️",label:"Compose",requiresWrite:!0},{id:"recovery",icon:"🔄",label:"Recovery"},{id:"managed-acl",icon:"🛡️",label:"Managed ACL",requiresOwner:!0},{id:"sprocket",icon:"⚙️",label:"Sprocket",requiresOwner:!0}];function ye(e){n(5,w=e),"sprocket"===e&&u&&"owner"===p&&z&&(ce(),ue()),ae()}function ge(){n(14,g=!1)}function we(e){n(6,E=E.filter(t=>t.id!==e)),$.delete(e),w===e&&n(5,w="export")}async function ve(e,t,n=!0){const r=$.get(e);if(r&&!r.isLoading){r.isLoading=!0,$.set(e,r);try{const o={limit:n?100:200,until:n?Math.floor(Date.now()/1e3):r.oldestTimestamp};console.log("Loading search results for query:",t,"with options:",o);const i=await async function(e,t={}){const{limit:n=100,since:r=null,until:o=null,kinds:i=null}=t,s=[{search:e}];return r&&(s[0].since=r),o&&(s[0].until=o),i&&(s[0].kinds=i),n&&(s[0].limit=n),await fh(s,{timeout:3e4})}(t,o);if(console.log("Received search results:",i.length,"events"),r.events=n?i.sort((e,t)=>t.created_at-e.created_at):[...r.events,...i].sort((e,t)=>t.created_at-e.created_at),i.length>0){const e=Math.min(...i.map(e=>e.created_at));(!r.oldestTimestamp||et.id===e);t&&await ve(e,t.query,!1)}(t)}}async function be(){if(u&&d&&!h)try{console.log("Auto-fetching profile for:",d),await yh(),n(3,h=await dh(d)),console.log("Profile auto-loaded:",h)}catch(e){console.error("Failed to auto-load profile:",e)}}async function Ee(){if(u&&d)try{const e=await fetch(`/api/permissions/${d}`);if(e.ok){const t=await e.json();n(4,p=t.permission||""),console.log("User role loaded:",p),console.log("Is owner?","owner"===p)}else console.error("Failed to fetch user role:",e.status),n(4,p="")}catch(e){console.error("Error fetching user role:",e),n(4,p="")}else n(4,p="")}async function xe(){try{const e=await fetch("/api/acl-mode");if(e.ok){const t=await e.json();n(9,W=t.acl_mode||""),console.log("ACL mode loaded:",W)}else console.error("Failed to fetch ACL mode:",e.status),n(9,W="")}catch(e){console.error("Error fetching ACL mode:",e),n(9,W="")}}async function ke(e=[]){if(u)if(0!==e.length||"admin"===a||"owner"===a)try{const t=await Ae("/api/export","POST"),n=await fetch("/api/export",{method:"POST",headers:{Authorization:t,"Content-Type":"application/json"},body:JSON.stringify({pubkeys:e})});if(!n.ok)throw new Error(`Export failed: ${n.status} ${n.statusText}`);const r=await n.blob(),o=window.URL.createObjectURL(r),i=document.createElement("a");i.href=o;const s=n.headers.get("Content-Disposition");let a="events.jsonl";if(s){const e=s.match(/filename="([^"]+)"/);e&&(a=e[1])}i.download=a,document.body.appendChild(i),i.click(),document.body.removeChild(i),window.URL.revokeObjectURL(o)}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 Se(e=!1,t=null){if(!u||"write"!==p&&"admin"!==p&&"owner"!==p)alert("Write, admin, or owner permission required");else if(!C){n(19,C=!0),e&&(j=null);try{console.log("Loading events with authors filter:",t,"including delete events");const r=await async function(e={}){const{limit:t=100,since:n=null,until:r=null,authors:o=null,kinds:i=null,...s}=e,a=[{...s}];return n&&(a[0].since=n),r&&(a[0].until=r),o&&(a[0].authors=o),i&&(a[0].kinds=i),t&&(a[0].limit=t),await fh(a,{timeout:3e4})}({limit:e?100:200,until:e?Math.floor(Date.now()/1e3):j,authors:t});if(console.log("Received events:",r.length,"events"),t&&r.length>0){const e=r.filter(e=>e.pubkey&&e.pubkey!==d);e.length>0&&console.warn("Server returned non-user events:",e.length,"out of",r.length)}if(e?(n(7,x=r.sort((e,t)=>t.created_at-e.created_at)),le(r)):(n(7,x=[...x,...r].sort((e,t)=>t.created_at-e.created_at)),le(x)),r.length>0){const e=Math.min(...r.map(e=>e.created_at));(!j||e{if("events"===w){const e=document.querySelectorAll(".events-view-content")[0];e&&e.scrollHeight<=e.clientHeight&&Ce()}},100)}catch(e){console.error("Failed to load events:",e),alert("Failed to load events: "+e.message)}finally{n(19,C=!1)}}}async function Ce(){await Se(!1)}async function Ae(e,t){if(!u||!d)throw new Error("Not logged in");const n={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",window.location.origin+e],["method",t.toUpperCase()]],content:"",pubkey:d};let r;if(y&&"extension"===f)try{r=await y.signEvent(n)}catch(e){throw new Error("Failed to sign with extension: "+e.message)}else{if("nsec"!==f)throw new Error("No valid signer available");n.id="mock-id-"+Date.now(),n.sig="mock-signature-"+Date.now(),r=n}const o=JSON.stringify(r);return`Nostr ${btoa(o)}`}async function je(e,t){if(!u||!d)throw new Error("Not logged in");const n={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",window.location.origin+t],["method",e.toUpperCase()]],content:"",pubkey:d};let r;if(y&&"extension"===f)try{r=await y.signEvent(n)}catch(e){throw new Error("Failed to sign with extension: "+e.message)}else{if("nsec"!==f)throw new Error("No valid signer available");n.id="mock-id-"+Date.now(),n.sig="mock-signature-"+Date.now(),r=n}const o=JSON.stringify(r);return btoa(o)}function Te(e){n(81,T=e),localStorage.setItem("viewAsRole",e),console.log("View as role changed to:",e,"Current effective role:",a)}T=localStorage.getItem("viewAsRole")||"";return e.$$.update=()=>{var t;if(390&e.$$.dirty[0]&&n(35,r=(P&&u&&d?x.filter(e=>e.pubkey&&e.pubkey===d):x).sort((e,t)=>t.created_at-e.created_at)),8&e.$$.dirty[0]&&n(34,o=h?.about?(t=h.about,String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")).replace(/\n{2,}/g,"
"):""),16&e.$$.dirty[0]|524288&e.$$.dirty[2]&&n(10,a=T&&""!==T?T:p),1554&e.$$.dirty[0]|1572864&e.$$.dirty[2]&&n(83,i=pe.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&&!z)&&(("managed-acl"!==e.id||"managed"===W)&&(console.log(`Tab ${e.id} filter check:`,{isLoggedIn:u,userRole:p,viewAsRole:T,currentRole:t,requiresAdmin:e.requiresAdmin,requiresOwner:e.requiresOwner,requiresWrite:e.requiresWrite,visible:!0}),!0)))))})),64&e.$$.dirty[0]|2097152&e.$$.dirty[2]&&n(11,s=[...i,...E]),2578&e.$$.dirty[0]|2097152&e.$$.dirty[2]&&console.log("Tabs debug:",{isLoggedIn:u,userRole:p,aclMode:W,filteredBaseTabs:i.map(e=>e.id),allTabs:s.map(e=>e.id)}),1&e.$$.dirty[0]&&"undefined"!=typeof document&&(l?document.body.classList.add("dark-theme"):document.body.classList.remove("dark-theme")),14&e.$$.dirty[0]&&u&&d&&!h&&be(),438&e.$$.dirty[0]&&"events"===w&&u&&("write"===p||"admin"===p||"owner"===p)&&0===x.length){Se(!0,P&&d?[d]:null)}32&e.$$.dirty[0]&&localStorage.setItem("selectedTab",w)},[l,u,d,h,p,w,E,x,P,W,a,s,c,y,g,v,m,k,S,C,A,U,F,M,D,H,q,K,V,J,G,Z,Y,Q,o,r,$,ee,function(e){return te[e]||`Kind ${e}`},ne,re,oe,ie,se,function(){console.log("selectRecoveryKind called, recoverySelectedKind:",J),null!=J?(n(30,G=""),n(31,Z=[]),X=null,n(33,Q=!0),ie()):console.log("No kind selected, skipping load")},function(){console.log("handleCustomKindInput called, recoveryCustomKind:",G);const e=parseInt(G);""!==G&&!isNaN(e)&&e>=0&&(n(29,J=null),n(31,Z=[]),X=null,n(33,Q=!0),ie())},function(e){const t=Z.filter(t=>t.kind===e.kind&&t.pubkey===e.pubkey),n=Math.max(...t.map(e=>e.created_at));return e.created_at===n},async function(){if(u&&"owner"===p)try{n(24,D=!0);const e=await fetch("/api/sprocket/status",{method:"GET",headers:{Authorization:`Nostr ${await je("GET","/api/sprocket/status")}`,"Content-Type":"application/json"}});if(e.ok){const t=await e.json();n(21,U=t.script_content||""),n(22,F=t),he("Script loaded successfully","success")}else he("Failed to load script","error")}catch(e){he(`Error loading script: ${e.message}`,"error")}finally{n(24,D=!1)}},async function(){if(u&&"owner"===p)try{n(24,D=!0);const e=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await je("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:U});if(e.ok)he("Script saved and updated successfully","success"),await ce(),await ue();else{he(`Failed to save script: ${await e.text()}`,"error")}}catch(e){he(`Error saving script: ${e.message}`,"error")}finally{n(24,D=!1)}},async function(){if(u&&"owner"===p)try{n(24,D=!0);const e=await fetch("/api/sprocket/restart",{method:"POST",headers:{Authorization:`Nostr ${await je("POST","/api/sprocket/restart")}`,"Content-Type":"application/json"}});if(e.ok)he("Sprocket restarted successfully","success"),await ce();else{he(`Failed to restart sprocket: ${await e.text()}`,"error")}}catch(e){he(`Error restarting sprocket: ${e.message}`,"error")}finally{n(24,D=!1)}},async function(){if(u&&"owner"===p&&confirm("Are you sure you want to delete the sprocket script? This will stop the current process."))try{n(24,D=!0);const e=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await je("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:""});if(e.ok)n(21,U=""),he("Sprocket script deleted successfully","success"),await ce(),await ue();else{he(`Failed to delete script: ${await e.text()}`,"error")}}catch(e){he(`Error deleting script: ${e.message}`,"error")}finally{n(24,D=!1)}},ue,de,fe,function(e){n(27,K=e.target.files[0])},async function(){if(u&&"owner"===p&&K)try{n(24,D=!0);const e=await K.text(),t=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await je("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:e});if(t.ok)n(21,U=e),he("Script uploaded and updated successfully","success"),await ce(),await ue();else{he(`Failed to upload script: ${await t.text()}`,"error")}}catch(e){he(`Error uploading script: ${e.message}`,"error")}finally{n(24,D=!1),n(27,K=null);const e=document.getElementById("sprocket-upload-file");e&&(e.value="")}},ye,function(){n(0,l=!l),"undefined"!=typeof localStorage&&localStorage.setItem("isDarkTheme",JSON.stringify(l))},function(){u||n(12,c=!0)},async function(e){const{method:t,pubkey:r,privateKey:o,signer:i}=e.detail;n(1,u=!0),n(2,d=r),f=t,n(13,y=i),n(12,c=!1);try{if(await yh(),"extension"===t&&i)nh.setSigner(i);else if("nsec"===t&&o){const e=new Dd(o);nh.setSigner(e)}n(3,h=await dh(r)),console.log("Profile loaded:",h)}catch(e){console.error("Failed to load profile:",e)}await Ee(),await xe()},function(){n(1,u=!1),n(2,d=""),f="",n(3,h=null),n(4,p=""),n(13,y=null),n(14,g=!1),B=[],n(7,x=[]),I=[],R=0,ae(),"undefined"!=typeof localStorage&&(localStorage.removeItem("nostr_auth_method"),localStorage.removeItem("nostr_pubkey"),localStorage.removeItem("nostr_privkey"))},function(){n(12,c=!1)},function(){n(14,g=!0)},ge,function(){n(15,v=!v),v||n(16,m="")},function(e){"Enter"===e.key&&m.trim()?(!function(e){const t=`search-${Date.now()}`,r={id:t,icon:"🔍",label:e,isSearchTab:!0,query:e};n(6,E=[...E,r]),n(5,w=t),$.set(t,{events:[],isLoading:!1,hasMore:!0,oldestTimestamp:null}),ve(t,e)}(m.trim()),n(16,m=""),n(15,v=!1)):"Escape"===e.key&&(n(15,v=!1),n(16,m=""))},we,ve,me,be,async function(){await ke([])},async function(){await ke([d])},function(e){n(17,k=e.target.files[0])},async function(){if(!u||"admin"!==p&&"owner"!==p)alert("Admin or owner permission required");else if(k)try{const e=await Ae("/api/import","POST"),t=new FormData;t.append("file",k);const r=await fetch("/api/import",{method:"POST",headers:{Authorization:e},body:t});if(!r.ok)throw new Error(`Import failed: ${r.status} ${r.statusText}`);await r.json();alert("Import started successfully"),n(17,k=null),document.getElementById("import-file").value=""}catch(e){console.error("Import failed:",e),alert("Import failed: "+e.message)}else alert("Please select a file")},Se,function(e){const{scrollTop:t,scrollHeight:n,clientHeight:r}=e.target;n-t-r<100&&Ce()},function(){try{if(!V.trim())return void alert("Please enter some JSON to reformat");const e=JSON.parse(V);n(28,V=JSON.stringify(e,null,2))}catch(e){alert("Invalid JSON: "+e.message)}},async function(){try{if(!V.trim())return void alert("Please enter an event to sign");if(!u||!d)return void alert("Please log in to sign events");if(!y)return void alert("No signer available. Please log in with a valid authentication method.");const e=JSON.parse(V);e.pubkey=d,e.created_at=Math.floor(Date.now()/1e3),delete e.id,delete e.sig;const t=await y.signEvent(e);n(28,V=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(){try{if(!V.trim())return void alert("Please enter an event to publish");if(!u)return void alert("Please log in to publish events");if(!y)return void alert("No signer available. Please log in with a valid authentication method.");const e=JSON.parse(V);if(!e.id||!e.sig)return void alert('Event must be signed before publishing. Please click "Sign" first.');const t=`wss://${window.location.host}`,n=await vp(t,e,y,d);n.success?alert("Event published successfully to ORLY relay!"):alert(`Event publishing failed: ${n.reason||"Unknown error"}`)}catch(e){console.error("Error publishing event:",e),alert("Error publishing event: "+e.message)}},Te,function(){const e=["owner","admin","write","read"],t=e.indexOf(p);return-1===t?["read"]:e.slice(t)},T,z,i,function(t){_.call(this,e,t)},function(t){_.call(this,e,t)},e=>e.id===w,function(){m=this.value,n(16,m)},e=>we(e.id),(e,t)=>"Enter"===t.key&&we(e.id),e=>ye(e.id),e=>oe(e.id),e=>ne(e.id),(e,t)=>"Enter"===t.key&&ne(e.id),(e,t)=>ig(e,t),function(){P=this.checked,n(8,P)},()=>re(),()=>{Se(!1,P&&d?[d]:null)},()=>{Se(!0,P&&d?[d]:null)},function(){V=this.value,n(28,V)},function(){U=this.value,n(21,U)},e=>de(e),e=>fe(e.name),function(){J=function(e){const t=e.querySelector(":checked");return t&&t.__value}(this),n(29,J),n(37,ee)},function(){G=b(this.value),n(30,G)},e=>se(e),(e,t)=>ig(e,t),e=>ve(e.id,e.query,!0),e=>oe(e.id),e=>ne(e.id),(e,t)=>"Enter"===t.key&&ne(e.id),(e,t)=>ig(e,t),(e,t)=>me(t,e.id),e=>Te(e===p?"":e),e=>"Escape"===e.key&&ge(),function(e){c=e,n(12,c)}]}return new class extends Q{constructor(e){super(),Y(this,e,ag,tg,i,{},null,[-1,-1,-1,-1,-1,-1])}}({target:document.body,props:{name:"world"}})}(); +function Ff(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function Mf(e,t){return!!Array.isArray(t)&&(0===t.length||(e?t.every(e=>"string"==typeof e):t.every(e=>Number.isSafeInteger(e))))}function Df(e,t){if("string"!=typeof t)throw new Error(`${e}: string expected`);return!0}function Hf(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function qf(e){if(!Array.isArray(e))throw new Error("array expected")}function zf(e,t){if(!Mf(!0,t))throw new Error(`${e}: array of strings expected`)}wf.BASE._setWindowSize(8);const Kf=(e,t)=>0===t?e:Kf(t,e%t),Wf=(e,t)=>e+(t-Kf(e,t)),Vf=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function Jf(e,t,n,r){if(qf(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(Wf(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${Wf(t,n)}`);let o=0,i=0;const s=Vf[t],a=Vf[n]-1,l=[];for(const r of e){if(Hf(r),r>=s)throw new Error(`convertRadix2: invalid data word=${r} from=${t}`);if(o=o<32)throw new Error(`convertRadix2: carry overflow pos=${i} from=${t}`);for(i+=t;i>=n;i-=n)l.push((o>>i-n&a)>>>0);const e=Vf[i];if(void 0===e)throw new Error("invalid carry");o&=e-1}if(o=o<=t)throw new Error("Excess padding");if(!r&&o>0)throw new Error(`Non-zero padding: ${o}`);return r&&i>0&&l.push(o>>>0),l}const Gf=(()=>"function"==typeof Uint8Array.from([]).toBase64&&"function"==typeof Uint8Array.fromBase64)()?{encode:e=>(function(e,...t){if(!Ff(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)=>{Df("base64",e);const n=t?/^[A-Za-z0-9=_-]+$/:/^[A-Za-z0-9=+/]+$/,r=t?"base64url":"base64";if(e.length>0&&!n.test(e))throw new Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,lastChunkHandling:"strict"})})(e,!1)}:function(...e){const t=e=>e,n=(e,t)=>n=>e(t(n));return{encode:e.map(e=>e.encode).reduceRight(n,t),decode:e.map(e=>e.decode).reduce(n,t)}}(function(e,t=!1){if(Hf(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(Wf(8,e)>32||Wf(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!Ff(n))throw new Error("radix2.encode input should be Uint8Array");return Jf(Array.from(n),8,e,!t)},decode:n=>(function(e,t){if(!Mf(!1,t))throw new Error(`${e}: array of numbers expected`)}("radix2.decode",n),Uint8Array.from(Jf(n,e,8,t)))}}(6),function(e){const t="string"==typeof e?e.split(""):e,n=t.length;zf("alphabet",t);const r=new Map(t.map((e,t)=>[e,t]));return{encode:r=>(qf(r),r.map(r=>{if(!Number.isSafeInteger(r)||r<0||r>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${r}". Allowed: ${e}`);return t[r]})),decode:t=>(qf(t),t.map(t=>{Df("alphabet.decode",t);const n=r.get(t);if(void 0===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n}))}}("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),function(e,t="="){return Hf(e),Df("padding",t),{encode(n){for(zf("padding.encode",n);n.length*e%8;)n.push(t);return n},decode(n){zf("padding.decode",n);let r=n.length;if(r*e%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;r>0&&n[r-1]===t;r--){if((r-1)*e%8==0)throw new Error("padding: invalid, string has too much padding")}return n.slice(0,r)}}}(6),function(e=""){return Df("join",e),{encode:t=>(zf("join.decode",t),t.join(e)),decode:t=>(Df("join.decode",t),t.split(e))}}(""));function Zf(e){return wf.fromHex(e).toHex().substring(2)}const Yf=new TextDecoder("utf-8"),Qf=new TextEncoder;class Xf{log=Ku.extend("SerialPortSigner");writer=null;pubkey;get isConnected(){return!!this.writer}verifyEvent=io;nip04;constructor(){this.nip04={encrypt:this.nip04Encrypt.bind(this),decrypt:this.nip04Decrypt.bind(this)}}lastCommand=null;async callMethodOnDevice(e,t,n={}){if(!Xf.SUPPORTED)throw new Error("Serial devices are not supported");if(this.writer||await this.connectToDevice(n),this.lastCommand)throw new Error("Previous command to device still pending!");const r=Ud();return this.lastCommand=r,this.sendCommand(e,t),setTimeout(()=>{r.reject(new Error("Device timeout")),this.lastCommand===r&&(this.lastCommand=null)},6e3),this.lastCommand}async connectToDevice({onConnect:e,onDisconnect:t,onError:n,onDone:r}){let o,i=await window.navigator.serial.requestPort();await i.open({baudRate:9600}),await(e=>new Promise(t=>setTimeout(t,e)))(1e3),(async()=>{for(;i&&i.readable;){const e=new window.TextDecoderStream;i.readable.pipeTo(e.writable),o=e.readable.getReader();const t=this.readFromSerialPort(o);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===Xf.PUBLIC_METHODS.indexOf(t))continue;this.log("Received: ",t,n),this.lastCommand&&(this.lastCommand.resolve(n),this.lastCommand=null)}if(n)return this.lastCommand=null,this.writer=null,void(r&&r())}}catch(e){if(e instanceof Error)throw this.writer=null,n&&n(e),this.lastCommand&&(this.lastCommand.reject(e),this.lastCommand=null),e}}})();const s=new window.TextEncoderStream;s.readable.pipeTo(i.writable),this.writer=s.writable.getWriter(),await this.sendCommand(Xf.METHOD_PING),await this.sendCommand(Xf.METHOD_PING,[window.location.host]),e&&e(),i.addEventListener("disconnect",()=>{this.log("Disconnected"),this.lastCommand=null,this.writer=null,t&&t()})}async sendCommand(e,t=[]){if(!this.writer)return;this.log("Send command",e,t);const n=[e].concat(t).join(" ");await this.writer.write(n+"\n")}readFromSerialPort(e){let t,n=[];return async(r="\n")=>{if(n.length)return{value:n.shift().trim(),done:!1};const o=[];for(t&&(o.push(t),t=void 0);;){const{value:i,done:s}=await e.read();if(i){const e=i.split(r);if(e.length>1)return o.push(e.shift()),t=e.pop(),n=e,{value:o.join("").trim(),done:!1};o.push(i)}if(s)return{value:o.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=ef(await this.callMethodOnDevice(Xf.METHOD_SHARED_SECRET,[Zf(e)]));let r=Uint8Array.from(function(e=32){if(Hd&&"function"==typeof Hd.getRandomValues)return Hd.getRandomValues(new Uint8Array(e));if(Hd&&"function"==typeof Hd.randomBytes)return Uint8Array.from(Hd.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}(16)),o=Qf.encode(t),i=await crypto.subtle.importKey("raw",n,{name:"AES-CBC"},!1,["encrypt"]),s=await crypto.subtle.encrypt({name:"AES-CBC",iv:r},i,o);return`${Gf.encode(new Uint8Array(s))}?iv=${Gf.encode(new Uint8Array(r.buffer))}`}async nip04Decrypt(e,t){let[n,r]=t.split("?iv=");const o=ef(await this.callMethodOnDevice(Xf.METHOD_SHARED_SECRET,[Zf(e)]));let i=await crypto.subtle.importKey("raw",o,{name:"AES-CBC"},!1,["decrypt"]),s=Gf.decode(n),a=Gf.decode(r),l=await crypto.subtle.decrypt({name:"AES-CBC",iv:a},i,s);return Yf.decode(l)}async getPublicKey(){const e=await this.callMethodOnDevice(Xf.METHOD_PUBLIC_KEY,[]);return this.pubkey=e,e}async restore(e){await this.callMethodOnDevice(Xf.METHOD_RESTORE,[Wd(e)])}async signEvent(e){const t=e.pubkey||this.pubkey;if(!t)throw new Error("Unknown signer pubkey");const n={...e,id:eo({...e,pubkey:t})},r=await this.callMethodOnDevice(Xf.METHOD_SIGN_MESSAGE,[n.id]),o={...n,sig:r,pubkey:t};if(!this.verifyEvent(o))throw new Error("Invalid signature");return o}ping(){this.sendCommand(Xf.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=[Xf.METHOD_PUBLIC_KEY,Xf.METHOD_SIGN_MESSAGE,Xf.METHOD_SHARED_SECRET,Xf.METHOD_RESTORE]}const eh=[`wss://${window.location.host}/`];class th{constructor(){this.pool=new Tn,this.eventStore=new Ld,this.isConnected=!1,this.signer=null,this.relays=[...eh]}async connect(){console.log("Starting connection to",this.relays.length,"relays...");try{this.isConnected=!0,console.log("✓ Successfully initialized relay pool"),await new Promise(e=>setTimeout(e,1e3))}catch(e){throw console.error("✗ Connection failed:",e),e}}async connectToRelay(e){console.log(`Adding relay: ${e}`);try{return this.relays.includes(e)||this.relays.push(e),console.log(`✓ Successfully added relay ${e}`),!0}catch(t){return console.error(`✗ Failed to add relay ${e}:`,t),!1}}subscribe(e,t){console.log("Creating subscription with filters:",e);const n=this.pool.subscribeMany(this.relays,e,{onevent(e){console.log("Event received:",e),t(e)},oneose(){console.log("EOSE received"),window.dispatchEvent(new CustomEvent("nostr-eose",{detail:{subscriptionId:n.id}}))}});return n}unsubscribe(e){console.log("Closing subscription"),e&&e.close&&e.close()}disconnect(){console.log("Disconnecting relay pool"),this.pool&&this.pool.close(this.relays),this.isConnected=!1}async publish(e,t=null){this.isConnected||(console.warn("Not connected to any relays, attempting to connect first"),await this.connect());try{const n=t||this.relays,r=this.pool.publish(n,e);return await Promise.allSettled(r),console.log("✓ Event published successfully"),await lh([e]),console.log("Event stored in IndexedDB"),{success:!0,okCount:1,errorCount:0}}catch(e){throw console.error("✗ Failed to publish event:",e),e}}getPool(){return this.pool}getEventStore(){return this.eventStore}getSigner(){return this.signer}setSigner(e){this.signer=e}}const nh=new th,rh="nostrCache",oh=2,ih="events";function sh(){return new Promise((e,t)=>{try{const n=indexedDB.open(rh,oh);n.onupgradeneeded=e=>{const t=n.result;e.oldVersion;let r;r=t.objectStoreNames.contains(ih)?n.transaction.objectStore(ih):t.createObjectStore(ih,{keyPath:"id"}),r.indexNames.contains("byKindAuthor")||r.createIndex("byKindAuthor",["kind","pubkey"],{unique:!1}),r.indexNames.contains("byKindAuthorCreated")||r.createIndex("byKindAuthorCreated",["kind","pubkey","created_at"],{unique:!1}),r.indexNames.contains("byKind")||r.createIndex("byKind","kind",{unique:!1}),r.indexNames.contains("byAuthor")||r.createIndex("byAuthor","pubkey",{unique:!1}),r.indexNames.contains("byCreatedAt")||r.createIndex("byCreatedAt","created_at",{unique:!1})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}catch(e){console.error("Failed to open IndexedDB",e),t(e)}})}async function ah(e){try{const t=await sh();await new Promise((n,r)=>{const o=t.transaction(ih,"readwrite");o.oncomplete=()=>n(),o.onerror=()=>r(o.error),o.objectStore(ih).put(e)})}catch(e){console.warn("IDB putEvent failed",e)}}async function lh(e){if(e&&0!==e.length)try{const t=await sh();await new Promise((n,r)=>{const o=t.transaction(ih,"readwrite");o.oncomplete=()=>n(),o.onerror=()=>r(o.error);const i=o.objectStore(ih);for(const t of e)i.put(t)}),console.log(`Stored ${e.length} events in IndexedDB`)}catch(e){console.warn("IDB putEvents failed",e)}}async function ch(e){try{const t=await sh(),n=[];console.log("QueryEventsFromDB: Starting query with filters:",e);for(const r of e){console.log("QueryEventsFromDB: Processing filter:",r);const e=await new Promise((e,n)=>{const o=t.transaction(ih,"readonly").objectStore(ih),i=[];let s;if(r.kinds&&r.kinds.length>0&&r.authors&&r.authors.length>0){const e=r.kinds[0],t=r.authors[0];console.log(`QueryEventsFromDB: Using byKindAuthorCreated index for kind=${e}, author=${t.substring(0,8)}...`);const n=o.index("byKindAuthorCreated"),i=IDBKeyRange.bound([e,t,-1/0],[e,t,1/0]);s=n.openCursor(i,"prev")}else if(r.kinds&&r.kinds.length>0){console.log(`QueryEventsFromDB: Using byKind index for kind=${r.kinds[0]}`);const e=o.index("byKind");s=e.openCursor(IDBKeyRange.only(r.kinds[0]))}else if(r.authors&&r.authors.length>0){console.log(`QueryEventsFromDB: Using byAuthor index for author=${r.authors[0].substring(0,8)}...`);const e=o.index("byAuthor");s=e.openCursor(IDBKeyRange.only(r.authors[0]))}else console.log("QueryEventsFromDB: Scanning all events (no specific index)"),s=o.openCursor();s.onsuccess=t=>{const n=t.target.result;if(n){const t=n.value;let o=!0;if(r.kinds&&r.kinds.length>0&&!r.kinds.includes(t.kind)&&(o=!1),r.authors&&r.authors.length>0&&!r.authors.includes(t.pubkey)&&(o=!1),r.since&&t.created_atr.until&&(o=!1),r.ids&&r.ids.length>0&&!r.ids.includes(t.id)&&(o=!1),o&&i.push(t),r.limit&&i.length>=r.limit)return console.log(`QueryEventsFromDB: Reached limit of ${r.limit}, found ${i.length} matching events`),void e(i);n.continue()}else console.log(`QueryEventsFromDB: Cursor exhausted, found ${i.length} matching events`),e(i)},s.onerror=()=>{console.error("QueryEventsFromDB: Cursor error:",s.error),n(s.error)}});console.log(`QueryEventsFromDB: Found ${e.length} events for this filter`),n.push(...e)}return n.sort((e,t)=>t.created_at-e.created_at),console.log(`QueryEventsFromDB: Returning ${n.length} total events`),n}catch(e){return console.error("QueryEventsFromDB failed:",e),[]}}function uh(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 dh(e){console.log(`Starting profile fetch for pubkey: ${e}`);try{const t=await async function(e){try{const t=await sh();return await new Promise((n,r)=>{const o=t.transaction(ih,"readonly").objectStore(ih).index("byKindAuthorCreated"),i=IDBKeyRange.bound([0,e,-1/0],[0,e,1/0]),s=o.openCursor(i,"prev");s.onsuccess=()=>{const e=s.result;n(e?e.value:null)},s.onerror=()=>r(s.error)})}catch(e){return console.warn("IDB getLatestProfileEvent failed",e),null}}(e);if(t){console.log("Using cached profile event");return uh(t)}}catch(e){console.warn("Failed to load cached profile",e)}try{const t=[{kinds:[0],authors:[e],limit:1}],n=await fh(t,{timeout:1e4});if(n.length>0){const t=n[0];console.log("Profile fetched:",t),await ah(t);try{console.log("Publishing profile event to local relay:",t.id),await nh.publish(t),console.log("Profile event successfully saved to local relay")}catch(e){console.warn("Failed to publish profile to local relay:",e)}const r=uh(t);try{"undefined"!=typeof window&&window.dispatchEvent&&window.dispatchEvent(new CustomEvent("profile-updated",{detail:{pubkey:e,profile:r,event:t}}))}catch(e){console.warn("Failed to dispatch profile-updated event",e)}return r}throw new Error("No profile found")}catch(e){throw console.error("Failed to fetch profile:",e),e}}async function fh(e,t={}){console.log("Starting event fetch with filters:",JSON.stringify(e,null,2)),console.log("Current relays:",nh.relays),nh.isConnected&&0!==nh.relays.length||(console.warn("Client not connected, initializing..."),await yh());const{timeout:n=3e4,useCache:r=!0}=t;if(r)try{const t=await ch(e);t.length>0&&console.log(`Found ${t.length} cached events in IndexedDB`)}catch(e){console.warn("Failed to query cached events",e)}return new Promise((t,r)=>{const o=[],i=setTimeout(()=>{console.log(`Timeout reached after ${n}ms, returning ${o.length} events`),sub.close(),o.length>0&&lh(o).catch(e=>console.warn("Failed to cache events",e)),t(o)},n);try{const n=Math.random().toString(36).substring(7);console.log(`📤 REQ [${n}]:`,JSON.stringify(["REQ",n,...e],null,2));const r=nh.pool.subscribeMany(nh.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)}),o.push(e),ah(e).catch(e=>console.warn("Failed to cache event",e))},oneose(){console.log(`✅ EOSE received for REQ [${n}], got ${o.length} events`),clearTimeout(i),r.close(),o.length>0&&lh(o).catch(e=>console.warn("Failed to cache events",e)),t(o)}})}catch(e){clearTimeout(i),console.error("Failed to fetch events:",e),r(e)}})}async function hh(e,t={}){const{timeout:n=1e4}=t;console.log(`Fetching event by ID: ${e}`);try{const t=[{ids:[e]}];console.log("Fetching event with filters:",t);const r=await fh(t,{timeout:n});return console.log(`Fetched ${r.length} events`),r.length>0?r[0]:null}catch(e){throw console.error("Failed to fetch event by ID:",e),e}}async function ph(e,t={}){const{timeout:n=1e4}=t;console.log(`Fetching delete events for target: ${e}`);try{const t=[{kinds:[5],"#e":[e]}];console.log("Fetching delete events with filters:",t);const r=await fh(t,{timeout:n});return console.log(`Fetched ${r.length} delete events`),r}catch(e){throw console.error("Failed to fetch delete events:",e),e}}async function yh(){await nh.connect()}async function gh(){try{const e=await sh(),t=e.transaction(ih,"readonly").objectStore(ih),n=await new Promise((e,n)=>{const r=t.getAll();r.onsuccess=()=>e(r.result),r.onerror=()=>n(r.error)}),r=n.reduce((e,t)=>(e[t.kind]=(e[t.kind]||0)+1,e),{});return console.log("===== IndexedDB Contents ====="),console.log(`Total events: ${n.length}`),console.log("Events by kind:",r),console.log("Kind 0 events:",n.filter(e=>0===e.kind)),console.log("All event IDs:",n.map(e=>({id:e.id.substring(0,8),kind:e.kind,pubkey:e.pubkey.substring(0,8)}))),console.log("=============================="),{total:n.length,byKind:r,events:n}}catch(e){return console.error("Failed to debug IndexedDB:",e),null}}const{window:wh}=l;function vh(e){let t,n,o,i,s,a,l,f,p,g,b,E,x,k,C,A,j,T;function _(e,t){return"extension"===e[2]?bh:mh}let $=_(e),I=$(e),R=e[5]&&Eh(e),O=e[6]&&xh(e);return{c(){t=h("div"),n=h("div"),o=h("div"),i=h("h2"),i.textContent="Login to Nostr",s=y(),a=h("button"),a.textContent="×",l=y(),f=h("div"),p=h("div"),g=h("button"),g.textContent="Extension",b=y(),E=h("button"),E.textContent="Nsec",x=y(),k=h("div"),I.c(),C=y(),R&&R.c(),A=y(),O&&O.c(),m(i,"class","svelte-1wl3v5c"),m(a,"class","close-btn svelte-1wl3v5c"),m(o,"class","modal-header svelte-1wl3v5c"),m(g,"class","tab-btn svelte-1wl3v5c"),S(g,"active","extension"===e[2]),m(E,"class","tab-btn svelte-1wl3v5c"),S(E,"active","nsec"===e[2]),m(p,"class","tabs svelte-1wl3v5c"),m(k,"class","tab-content svelte-1wl3v5c"),m(f,"class","tab-container svelte-1wl3v5c"),m(n,"class","modal svelte-1wl3v5c"),S(n,"dark-theme",e[1]),m(t,"class","modal-overlay svelte-1wl3v5c"),m(t,"role","button"),m(t,"tabindex","0")},m(r,d){u(r,t,d),c(t,n),c(n,o),c(o,i),c(o,s),c(o,a),c(n,l),c(n,f),c(f,p),c(p,g),c(p,b),c(p,E),c(f,x),c(f,k),I.m(k,null),c(k,C),R&&R.m(k,null),c(k,A),O&&O.m(k,null),j||(T=[w(a,"click",e[7]),w(g,"click",e[14]),w(E,"click",e[15]),w(n,"click",v(e[12])),w(n,"keydown",v(e[13])),w(t,"click",e[7]),w(t,"keydown",e[17])],j=!0)},p(e,t){4&t&&S(g,"active","extension"===e[2]),4&t&&S(E,"active","nsec"===e[2]),$===($=_(e))&&I?I.p(e,t):(I.d(1),I=$(e),I&&(I.c(),I.m(k,C))),e[5]?R?R.p(e,t):(R=Eh(e),R.c(),R.m(k,A)):R&&(R.d(1),R=null),e[6]?O?O.p(e,t):(O=xh(e),O.c(),O.m(k,null)):O&&(O.d(1),O=null),2&t&&S(n,"dark-theme",e[1])},d(e){e&&d(t),I.d(),R&&R.d(),O&&O.d(),j=!1,r(T)}}}function mh(e){let t,n,o,i,s,a,l,f,g,v,b=e[4]?"Logging in...":"Log in with nsec";return{c(){t=h("div"),n=h("p"),n.textContent="Enter your nsec (private key) to login. This\n will be stored securely in your browser.",o=y(),i=h("input"),s=y(),a=h("button"),l=p(b),m(n,"class","svelte-1wl3v5c"),m(i,"type","password"),m(i,"placeholder","nsec1..."),i.disabled=e[4],m(i,"class","nsec-input svelte-1wl3v5c"),m(a,"class","login-nsec-btn svelte-1wl3v5c"),a.disabled=f=e[4]||!e[3].trim(),m(t,"class","nsec-login svelte-1wl3v5c")},m(r,d){u(r,t,d),c(t,n),c(t,o),c(t,i),x(i,e[3]),c(t,s),c(t,a),c(a,l),g||(v=[w(i,"input",e[16]),w(a,"click",e[10])],g=!0)},p(e,t){16&t&&(i.disabled=e[4]),8&t&&i.value!==e[3]&&x(i,e[3]),16&t&&b!==(b=e[4]?"Logging in...":"Log in with nsec")&&E(l,b),24&t&&f!==(f=e[4]||!e[3].trim())&&(a.disabled=f)},d(e){e&&d(t),g=!1,r(v)}}}function bh(e){let t,n,r,o,i,s,a,l=e[4]?"Connecting...":"Log in using extension";return{c(){t=h("div"),n=h("p"),n.textContent="Login using a NIP-07 compatible browser\n extension like nos2x or Alby.",r=y(),o=h("button"),i=p(l),m(n,"class","svelte-1wl3v5c"),m(o,"class","login-extension-btn svelte-1wl3v5c"),o.disabled=e[4],m(t,"class","extension-login svelte-1wl3v5c")},m(l,d){u(l,t,d),c(t,n),c(t,r),c(t,o),c(o,i),s||(a=w(o,"click",e[9]),s=!0)},p(e,t){16&t&&l!==(l=e[4]?"Connecting...":"Log in using extension")&&E(i,l),16&t&&(o.disabled=e[4])},d(e){e&&d(t),s=!1,a()}}}function Eh(e){let t,n;return{c(){t=h("div"),n=p(e[5]),m(t,"class","message error-message svelte-1wl3v5c")},m(e,r){u(e,t,r),c(t,n)},p(e,t){32&t&&E(n,e[5])},d(e){e&&d(t)}}}function xh(e){let t,n;return{c(){t=h("div"),n=p(e[6]),m(t,"class","message success-message svelte-1wl3v5c")},m(e,r){u(e,t,r),c(t,n)},p(e,t){64&t&&E(n,e[6])},d(e){e&&d(t)}}}function kh(t){let n,r,o,i=t[0]&&vh(t);return{c(){i&&i.c(),n=g()},m(e,s){i&&i.m(e,s),u(e,n,s),r||(o=w(wh,"keydown",t[11]),r=!0)},p(e,[t]){e[0]?i?i.p(e,t):(i=vh(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),r=!1,o()}}}function Sh(e,t,n){const r=T();let{showModal:o=!1}=t,{isDarkTheme:i=!1}=t,s="extension",a="",l=!1,c="",u="";function d(){n(0,o=!1),n(3,a=""),n(5,c=""),n(6,u=""),r("close")}function f(e){n(2,s=e),n(5,c=""),n(6,u="")}async function h(){n(4,l=!0),n(5,c=""),n(6,u="");try{if(!a.trim())throw new Error("Please enter your nsec");if(!(e=a.trim()).startsWith("nsec1")||(e.length<60||e.length>70))throw new Error('Invalid nsec format. Must start with "nsec1"');const t=Dd.fromKey(a.trim()),o=await t.getPublicKey();localStorage.setItem("nostr_auth_method","nsec"),localStorage.setItem("nostr_pubkey",o),localStorage.setItem("nostr_privkey",a.trim()),n(6,u="Successfully logged in with nsec!"),r("login",{method:"nsec",pubkey:o,privateKey:a.trim(),signer:t}),setTimeout(()=>{d()},1500)}catch(e){n(5,c=e.message)}finally{n(4,l=!1)}var e}return e.$$set=e=>{"showModal"in e&&n(0,o=e.showModal),"isDarkTheme"in e&&n(1,i=e.isDarkTheme)},[o,i,s,a,l,c,u,d,f,async function(){n(4,l=!0),n(5,c=""),n(6,u="");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(6,u="Successfully logged in with extension!"),r("login",{method:"extension",pubkey:e,signer:window.nostr}),setTimeout(()=>{d()},1500))}catch(e){n(5,c=e.message)}finally{n(4,l=!1)}},h,function(e){"Escape"===e.key&&d(),"Enter"===e.key&&"nsec"===s&&h()},function(t){_.call(this,e,t)},function(t){_.call(this,e,t)},()=>f("extension"),()=>f("nsec"),function(){a=this.value,n(3,a)},e=>"Escape"===e.key&&d()]}class Ch extends Q{constructor(e){super(),Y(this,e,Sh,kh,i,{showModal:0,isDarkTheme:1})}}function Ah(e,t,n){const r=e.slice();return r[72]=t[n],r}function jh(e,t,n){const r=e.slice();return r[75]=t[n],r}function Th(e,t,n){const r=e.slice();return r[72]=t[n],r}function _h(e,t,n){const r=e.slice();return r[72]=t[n],r}function $h(e,t,n){const r=e.slice();return r[72]=t[n],r}function Ih(e,t,n){const r=e.slice();return r[72]=t[n],r}function Rh(e,t,n){const r=e.slice();return r[72]=t[n],r}function Oh(e){let t,n,r;return{c(){t=h("div"),n=p(e[3]),m(t,"class",r="message "+e[4]+" svelte-1smaj3x")},m(e,r){u(e,t,r),c(t,n)},p(e,o){8&o[0]&&E(n,e[3]),16&o[0]&&r!==(r="message "+e[4]+" svelte-1smaj3x")&&m(t,"class",r)},d(e){e&&d(t)}}}function Ph(e){let t,n,o,i,s,a,l,f,g,v,b,E,k,S,C,A,j,T,_,$,I,R,O,P,B,N,L,U;function F(e,t){return e[5]&&e[5].length>0?Nh:Bh}let M=F(e),D=M(e);function H(e,t){return e[8]&&e[8].length>0?Mh:Fh}let q=H(e),z=q(e);return{c(){t=h("div"),n=h("div"),o=h("h3"),o.textContent="Banned Pubkeys",i=y(),s=h("div"),a=h("input"),l=y(),f=h("input"),g=y(),v=h("button"),b=p("Ban Pubkey"),E=y(),k=h("div"),D.c(),S=y(),C=h("div"),A=h("h3"),A.textContent="Allowed Pubkeys",j=y(),T=h("div"),_=h("input"),$=y(),I=h("input"),R=y(),O=h("button"),P=p("Allow Pubkey"),B=y(),N=h("div"),z.c(),m(o,"class","svelte-1smaj3x"),m(a,"type","text"),m(a,"placeholder","Pubkey (64 hex chars)"),m(a,"class","svelte-1smaj3x"),m(f,"type","text"),m(f,"placeholder","Reason (optional)"),m(f,"class","svelte-1smaj3x"),v.disabled=e[2],m(v,"class","svelte-1smaj3x"),m(s,"class","add-form svelte-1smaj3x"),m(k,"class","list svelte-1smaj3x"),m(n,"class","section svelte-1smaj3x"),m(A,"class","svelte-1smaj3x"),m(_,"type","text"),m(_,"placeholder","Pubkey (64 hex chars)"),m(_,"class","svelte-1smaj3x"),m(I,"type","text"),m(I,"placeholder","Reason (optional)"),m(I,"class","svelte-1smaj3x"),O.disabled=e[2],m(O,"class","svelte-1smaj3x"),m(T,"class","add-form svelte-1smaj3x"),m(N,"class","list svelte-1smaj3x"),m(C,"class","section svelte-1smaj3x"),m(t,"class","pubkeys-section")},m(r,d){u(r,t,d),c(t,n),c(n,o),c(n,i),c(n,s),c(s,a),x(a,e[6]),c(s,l),c(s,f),x(f,e[7]),c(s,g),c(s,v),c(v,b),c(n,E),c(n,k),D.m(k,null),c(t,S),c(t,C),c(C,A),c(C,j),c(C,T),c(T,_),x(_,e[9]),c(T,$),c(T,I),x(I,e[10]),c(T,R),c(T,O),c(O,P),c(C,B),c(C,N),z.m(N,null),L||(U=[w(a,"input",e[43]),w(f,"input",e[44]),w(v,"click",e[25]),w(_,"input",e[45]),w(I,"input",e[46]),w(O,"click",e[26])],L=!0)},p(e,t){64&t[0]&&a.value!==e[6]&&x(a,e[6]),128&t[0]&&f.value!==e[7]&&x(f,e[7]),4&t[0]&&(v.disabled=e[2]),M===(M=F(e))&&D?D.p(e,t):(D.d(1),D=M(e),D&&(D.c(),D.m(k,null))),512&t[0]&&_.value!==e[9]&&x(_,e[9]),1024&t[0]&&I.value!==e[10]&&x(I,e[10]),4&t[0]&&(O.disabled=e[2]),q===(q=H(e))&&z?z.p(e,t):(z.d(1),z=q(e),z&&(z.c(),z.m(N,null)))},d(e){e&&d(t),D.d(),z.d(),L=!1,r(U)}}}function Bh(t){let n;return{c(){n=h("div"),n.innerHTML="

No banned pubkeys configured.

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

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

No banned events configured.

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

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

No blocked IPs configured.

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

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

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

No events need moderation at this time.

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

Configure access control using NIP-86 management API

\n
Owner Only: This interface is restricted to relay owners\n only.
',i=y(),J&&J.c(),s=y(),a=h("div"),l=h("button"),f=p("Pubkeys"),v=y(),b=h("button"),E=p("Events"),k=y(),S=h("button"),C=p("IPs"),j=y(),T=h("button"),_=p("Kinds"),I=y(),R=h("button"),O=p("Moderation"),B=y(),N=h("button"),L=p("Relay Config"),F=y(),M=h("div"),G&&G.c(),D=y(),Z&&Z.c(),H=y(),Y&&Y.c(),q=y(),Q&&Q.c(),z=y(),X&&X.c(),K=y(),ee&&ee.c(),m(o,"class","header svelte-1smaj3x"),m(l,"class",g="tab "+("pubkeys"===t[1]?"active":"")+" svelte-1smaj3x"),m(b,"class",x="tab "+("events"===t[1]?"active":"")+" svelte-1smaj3x"),m(S,"class",A="tab "+("ips"===t[1]?"active":"")+" svelte-1smaj3x"),m(T,"class",$="tab "+("kinds"===t[1]?"active":"")+" svelte-1smaj3x"),m(R,"class",P="tab "+("moderation"===t[1]?"active":"")+" svelte-1smaj3x"),m(N,"class",U="tab "+("relay"===t[1]?"active":"")+" svelte-1smaj3x"),m(a,"class","tabs svelte-1smaj3x"),m(M,"class","tab-content svelte-1smaj3x")},m(e,r){u(e,n,r),c(n,o),c(n,i),J&&J.m(n,null),c(n,s),c(n,a),c(a,l),c(l,f),c(a,v),c(a,b),c(b,E),c(a,k),c(a,S),c(S,C),c(a,j),c(a,T),c(T,_),c(a,I),c(a,R),c(R,O),c(a,B),c(a,N),c(N,L),c(n,F),c(n,M),G&&G.m(M,null),c(M,D),Z&&Z.m(M,null),c(M,H),Y&&Y.m(M,null),c(M,q),Q&&Q.m(M,null),c(M,z),X&&X.m(M,null),c(M,K),ee&&ee.m(M,null),W||(V=[w(l,"click",t[37]),w(b,"click",t[38]),w(S,"click",t[39]),w(T,"click",t[40]),w(R,"click",t[41]),w(N,"click",t[42])],W=!0)},p(e,t){e[3]?J?J.p(e,t):(J=Oh(e),J.c(),J.m(n,s)):J&&(J.d(1),J=null),2&t[0]&&g!==(g="tab "+("pubkeys"===e[1]?"active":"")+" svelte-1smaj3x")&&m(l,"class",g),2&t[0]&&x!==(x="tab "+("events"===e[1]?"active":"")+" svelte-1smaj3x")&&m(b,"class",x),2&t[0]&&A!==(A="tab "+("ips"===e[1]?"active":"")+" svelte-1smaj3x")&&m(S,"class",A),2&t[0]&&$!==($="tab "+("kinds"===e[1]?"active":"")+" svelte-1smaj3x")&&m(T,"class",$),2&t[0]&&P!==(P="tab "+("moderation"===e[1]?"active":"")+" svelte-1smaj3x")&&m(R,"class",P),2&t[0]&&U!==(U="tab "+("relay"===e[1]?"active":"")+" svelte-1smaj3x")&&m(N,"class",U),"pubkeys"===e[1]?G?G.p(e,t):(G=Ph(e),G.c(),G.m(M,D)):G&&(G.d(1),G=null),"events"===e[1]?Z?Z.p(e,t):(Z=qh(e),Z.c(),Z.m(M,H)):Z&&(Z.d(1),Z=null),"ips"===e[1]?Y?Y.p(e,t):(Y=Yh(e),Y.c(),Y.m(M,q)):Y&&(Y.d(1),Y=null),"kinds"===e[1]?Q?Q.p(e,t):(Q=np(e),Q.c(),Q.m(M,z)):Q&&(Q.d(1),Q=null),"moderation"===e[1]?X?X.p(e,t):(X=sp(e),X.c(),X.m(M,K)):X&&(X.d(1),X=null),"relay"===e[1]?ee?ee.p(e,t):(ee=dp(e),ee.c(),ee.m(M,null)):ee&&(ee.d(1),ee=null)},i:e,o:e,d(e){e&&d(n),J&&J.d(),G&&G.d(),Z&&Z.d(),Y&&Y.d(),Q&&Q.d(),X&&X.d(),ee&&ee.d(),W=!1,r(V)}}}function yp(e,t,n){let{userSigner:r}=t,{userPubkey:o}=t,i="pubkeys",s=!1,a="",l="info",c=[],u="",d="",f=[],h="",p="",y=[],g="",w="",v="",m="",E=[],x="",k="",S=[],C="",A=[],T={relay_name:"",relay_description:"",relay_icon:""};var _;async function $(){try{n(2,s=!0),console.log("Fetching relay info from /");const e=await fetch(window.location.origin+"/",{headers:{Accept:"application/nostr+json"}});if(console.log("Response status:",e.status),console.log("Response headers:",e.headers),e.ok){const t=await e.json();console.log("Raw relay info:",t),n(0,T={relay_name:t.name||"",relay_description:t.description||"",relay_icon:t.icon||""}),console.log("Updated relayConfig:",T),console.log("Loaded relay info:",t),n(3,a="Relay configuration loaded successfully"),n(4,l="success")}else console.error("Failed to fetch relay info, status:",e.status),n(3,a=`Failed to fetch relay info: ${e.status}`),n(4,l="error")}catch(e){console.error("Failed to fetch relay info:",e),n(3,a=`Failed to fetch relay info: ${e.message}`),n(4,l="error")}finally{n(2,s=!1)}}async function I(e,t=[]){try{n(2,s=!0),n(3,a="");const i={method:e,params:t},l=await async function(e,t){if(!r)throw new Error("No signer available for authentication. Please log in with a Nostr extension.");if(!o)throw new Error("No user pubkey available for authentication.");const n=window.location.origin+t,i={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",n],["method",e]],content:"",pubkey:o},s=await r.signEvent(i),a=JSON.stringify(s);return`Nostr ${btoa(a)}`}("POST","/api/nip86"),c=await fetch("/api/nip86",{method:"POST",headers:{"Content-Type":"application/nostr+json+rpc",Authorization:l},body:JSON.stringify(i)});if(!c.ok)throw new Error(`HTTP ${c.status}: ${c.statusText}`);const u=await c.json();if(u.error)throw new Error(u.error);return u.result}catch(e){throw console.error("NIP-86 API error:",e),n(3,a=e.message),n(4,l="error"),e}finally{n(2,s=!1)}}async function R(){try{n(5,c=await I("listbannedpubkeys"))}catch(e){console.error("Failed to load banned pubkeys:",e)}}async function O(){try{n(8,f=await I("listallowedpubkeys"))}catch(e){console.error("Failed to load allowed pubkeys:",e)}}async function P(){try{n(11,y=await I("listbannedevents"))}catch(e){console.error("Failed to load banned events:",e)}}async function B(){try{n(16,E=await I("listblockedips"))}catch(e){console.error("Failed to load blocked IPs:",e)}}async function N(){try{n(19,S=await I("listallowedkinds"))}catch(e){console.error("Failed to load allowed kinds:",e)}}async function L(){try{n(2,s=!0),n(21,A=await I("listeventsneedingmoderation")),console.log("Loaded events needing moderation:",A)}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,A=[])}finally{n(2,s=!1)}}async function U(e){try{await I("disallowkind",[e]),n(3,a="Kind disallowed successfully"),n(4,l="success"),await N()}catch(e){console.error("Failed to disallow kind:",e)}}async function F(e){try{await I("allowevent",[e,"Approved from moderation queue"]),n(3,a="Event allowed successfully"),n(4,l="success"),await L()}catch(e){console.error("Failed to allow event from moderation:",e)}}async function M(e){try{await I("banevent",[e,"Banned from moderation queue"]),n(3,a="Event banned successfully"),n(4,l="success"),await L()}catch(e){console.error("Failed to ban event from moderation:",e)}}_=()=>{setTimeout(()=>{$()},100)},j().$$.on_mount.push(_),async function(){await Promise.all([R(),O(),P(),B(),N()])}();return e.$$set=e=>{"userSigner"in e&&n(35,r=e.userSigner),"userPubkey"in e&&n(36,o=e.userPubkey)},e.$$.update=()=>{1&e.$$.dirty[0]&&console.log("relayConfig changed:",T)},[T,i,s,a,l,c,u,d,f,h,p,y,g,w,v,m,E,x,k,S,C,A,[],$,L,async function(){if(u)try{await I("banpubkey",[u,d]),n(3,a="Pubkey banned successfully"),n(4,l="success"),n(6,u=""),n(7,d=""),await R()}catch(e){console.error("Failed to ban pubkey:",e)}},async function(){if(h)try{await I("allowpubkey",[h,p]),n(3,a="Pubkey allowed successfully"),n(4,l="success"),n(9,h=""),n(10,p=""),await O()}catch(e){console.error("Failed to allow pubkey:",e)}},async function(){if(g)try{await I("banevent",[g,w]),n(3,a="Event banned successfully"),n(4,l="success"),n(12,g=""),n(13,w=""),await P()}catch(e){console.error("Failed to ban event:",e)}},async function(){if(v)try{await I("allowevent",[v,m]),n(3,a="Event allowed successfully"),n(4,l="success"),n(14,v=""),n(15,m="")}catch(e){console.error("Failed to allow event:",e)}},async function(){if(x)try{await I("blockip",[x,k]),n(3,a="IP blocked successfully"),n(4,l="success"),n(17,x=""),n(18,k=""),await B()}catch(e){console.error("Failed to block IP:",e)}},async function(){if(!C)return;const e=parseInt(C);if(isNaN(e))return n(3,a="Invalid kind number"),void n(4,l="error");try{await I("allowkind",[e]),n(3,a="Kind allowed successfully"),n(4,l="success"),n(20,C=""),await N()}catch(e){console.error("Failed to allow kind:",e)}},U,async function(){try{n(2,s=!0),n(3,a="");const e=[];if(T.relay_name&&e.push(I("changerelayname",[T.relay_name])),T.relay_description&&e.push(I("changerelaydescription",[T.relay_description])),T.relay_icon&&e.push(I("changerelayicon",[T.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 $()}catch(e){console.error("Failed to update relay configuration:",e),n(3,a=`Failed to update relay configuration: ${e.message}`),n(4,l="error")}finally{n(2,s=!1)}},F,M,r,o,()=>n(1,i="pubkeys"),()=>n(1,i="events"),()=>n(1,i="ips"),()=>n(1,i="kinds"),()=>{n(1,i="moderation"),A&&0!==A.length||L()},()=>n(1,i="relay"),function(){u=this.value,n(6,u)},function(){d=this.value,n(7,d)},function(){h=this.value,n(9,h)},function(){p=this.value,n(10,p)},function(){g=this.value,n(12,g)},function(){w=this.value,n(13,w)},function(){v=this.value,n(14,v)},function(){m=this.value,n(15,m)},function(){x=this.value,n(17,x)},function(){k=this.value,n(18,k)},function(){C=b(this.value),n(20,C)},e=>U(e),e=>F(e.id),e=>M(e.id),function(){T.relay_name=this.value,n(0,T)},function(){T.relay_description=this.value,n(0,T)},function(){T.relay_icon=this.value,n(0,T)}]}class gp extends Q{constructor(e){super(),Y(this,e,yp,pp,i,{userSigner:35,userPubkey:36},null,[-1,-1,-1])}}class wp{constructor(e,t,n){this.relayUrl=e,this.userSigner=t,this.userPubkey=n,this.ws=null,this.challenge=null,this.isAuthenticated=!1,this.authPromise=null}async connect(){return new Promise((e,t)=>{this.ws=new WebSocket(this.relayUrl),this.ws.onopen=()=>{console.log("WebSocket connected to relay:",this.relayUrl),e()},this.ws.onmessage=async e=>{try{const t=JSON.parse(e.data);await this.handleMessage(t)}catch(e){console.error("Error parsing relay message:",e)}},this.ws.onerror=e=>{console.error("WebSocket error:",e),t(new Error("Failed to connect to relay"))},this.ws.onclose=()=>{console.log("WebSocket connection closed"),this.isAuthenticated=!1,this.challenge=null},setTimeout(()=>{this.ws.readyState!==WebSocket.OPEN&&t(new Error("Connection timeout"))},1e4)})}async handleMessage(e){const[t,...n]=e;switch(t){case"AUTH":this.challenge=n[0],console.log("Received AUTH challenge:",this.challenge),await this.authenticate();break;case"OK":const[e,r,o]=n;e&&r?(console.log("Authentication successful for event:",e),this.isAuthenticated=!0,this.authPromise&&(this.authPromise.resolve(),this.authPromise=null)):e&&!r&&(console.error("Authentication failed:",o),this.authPromise&&(this.authPromise.reject(new Error(o||"Authentication failed")),this.authPromise=null));break;case"NOTICE":console.log("Relay notice:",n[0]);break;default:console.log("Unhandled message type:",t,n)}}async authenticate(){if(!this.challenge)throw new Error("No challenge received from relay");if(!this.userSigner)throw new Error("No signer available for authentication");try{const e={kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",this.relayUrl],["challenge",this.challenge]],content:"",pubkey:this.userPubkey},t=["AUTH",await this.userSigner.signEvent(e)];return this.ws.send(JSON.stringify(t)),console.log("Sent authentication event to relay"),new Promise((e,t)=>{this.authPromise={resolve:e,reject:t},setTimeout(()=>{this.authPromise&&(this.authPromise.reject(new Error("Authentication timeout")),this.authPromise=null)},1e4)})}catch(e){throw console.error("Authentication error:",e),e}}async publishEvent(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");return new Promise((t,n)=>{const r=["EVENT",e];this.ws.send(JSON.stringify(r));const o=this.ws.onmessage,i=setTimeout(()=>{this.ws.onmessage=o,n(new Error("Publish timeout"))},15e3);this.ws.onmessage=async r=>{try{const s=JSON.parse(r.data),[a,l,c,u]=s;if("OK"===a&&l===e.id)if(clearTimeout(i),this.ws.onmessage=o,c)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")){console.log("Authentication required, attempting to authenticate...");try{await this.authenticate();const t=["EVENT",e];return void this.ws.send(JSON.stringify(t))}catch(e){return void n(new Error(`Authentication failed: ${e.message}`))}}n(new Error(`Publish failed: ${u}`))}else await this.handleMessage(s)}catch(e){clearTimeout(i),this.ws.onmessage=o,n(e)}}})}close(){this.ws&&(this.ws.close(),this.ws=null),this.isAuthenticated=!1,this.challenge=null}getAuthenticated(){return this.isAuthenticated}}async function vp(e,t,n,r){const o=new wp(e,n,r);try{await o.connect();return await o.publishEvent(t)}finally{o.close()}}function mp(e,t,n){const r=e.slice();return r[150]=t[n],r}function bp(e,t,n){const r=e.slice();return r[168]=t[n],r}function Ep(e,t,n){const r=e.slice();return r[153]=t[n],r}function xp(e,t,n){const r=e.slice();r[153]=t[n];const o=r[46](r[153]);return r[162]=o,r}function kp(e,t,n){const r=e.slice();return r[165]=t[n],r}function Sp(e,t,n){const r=e.slice();return r[159]=t[n],r}function Cp(e,t,n){const r=e.slice();return r[153]=t[n],r}function Ap(e,t,n){const r=e.slice();return r[156]=t[n],r}function jp(e,t,n){const r=e.slice();return r[173]=t[n],r}function Tp(e){let t,n,r,o=e[1]&&e[4]&&$p(e);return{c(){t=h("div"),n=h("span"),r=p("ORLY? dashboard\n "),o&&o.c(),m(n,"class","app-title svelte-d3wb0j"),m(t,"class","header-title svelte-d3wb0j")},m(e,i){u(e,t,i),c(t,n),c(n,r),o&&o.m(n,null)},p(e,t){e[1]&&e[4]?o?o.p(e,t):(o=$p(e),o.c(),o.m(n,null)):o&&(o.d(1),o=null)},d(e){e&&d(t),o&&o.d()}}}function _p(e){let t,n,o,i;return{c(){t=h("div"),n=h("input"),m(n,"type","text"),m(n,"class","search-input svelte-d3wb0j"),m(n,"placeholder","Search..."),m(t,"class","search-input-container svelte-d3wb0j")},m(r,s){u(r,t,s),c(t,n),x(n,e[16]),o||(i=[w(n,"input",e[87]),w(n,"keydown",e[65])],o=!0)},p(e,t){65536&t[0]&&n.value!==e[16]&&x(n,e[16])},d(e){e&&d(t),o=!1,r(i)}}}function $p(e){let t,n;return{c(){t=h("span"),n=p(e[10]),m(t,"class","permission-badge svelte-d3wb0j")},m(e,r){u(e,t,r),c(t,n)},p(e,t){1024&t[0]&&E(n,e[10])},d(e){e&&d(t)}}}function Ip(t){let n,r,o;return{c(){n=h("button"),n.textContent="Log in",m(n,"class","login-btn svelte-d3wb0j")},m(e,i){u(e,n,i),r||(o=w(n,"click",t[58]),r=!0)},p:e,d(e){e&&d(n),r=!1,o()}}}function Rp(e){let t,n,r,o,i,s,a,l=(e[3]?.name||e[2].slice(0,8)+"...")+"";function f(e,t){return e[3]?.picture?Pp:Op}let g=f(e),v=g(e);return{c(){t=h("div"),n=h("button"),v.c(),r=y(),o=h("span"),i=p(l),m(o,"class","user-name svelte-d3wb0j"),m(n,"class","user-profile-btn svelte-d3wb0j"),m(t,"class","user-info svelte-d3wb0j")},m(l,d){u(l,t,d),c(t,n),v.m(n,null),c(n,r),c(n,o),c(o,i),s||(a=w(n,"click",e[62]),s=!0)},p(e,t){g===(g=f(e))&&v?v.p(e,t):(v.d(1),v=g(e),v&&(v.c(),v.m(n,r))),12&t[0]&&l!==(l=(e[3]?.name||e[2].slice(0,8)+"...")+"")&&E(i,l)},d(e){e&&d(t),v.d(),s=!1,a()}}}function Op(t){let n;return{c(){n=h("div"),n.textContent="👤",m(n,"class","user-avatar-placeholder svelte-d3wb0j")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Pp(e){let t,n;return{c(){t=h("img"),a(t.src,n=e[3].picture)||m(t,"src",n),m(t,"alt","User avatar"),m(t,"class","user-avatar svelte-d3wb0j")},m(e,n){u(e,t,n)},p(e,r){8&r[0]&&!a(t.src,n=e[3].picture)&&m(t,"src",n)},d(e){e&&d(t)}}}function Bp(e){let t,n,o;function i(){return e[88](e[173])}function s(...t){return e[89](e[173],...t)}return{c(){t=h("span"),t.textContent="✕",m(t,"class","tab-close-icon svelte-d3wb0j"),m(t,"role","button"),m(t,"tabindex","0")},m(e,r){u(e,t,r),n||(o=[w(t,"click",v(i)),w(t,"keydown",s)],n=!0)},p(t,n){e=t},d(e){e&&d(t),n=!1,r(o)}}}function Np(e){let t,n,r,o,i,s,a,l,f,g,v=e[173].icon+"",b=e[173].label+"",x=e[173].isSearchTab&&Bp(e);function k(){return e[90](e[173])}return{c(){t=h("button"),n=h("span"),r=p(v),o=y(),i=h("span"),s=p(b),a=y(),x&&x.c(),l=y(),m(n,"class","tab-icon svelte-d3wb0j"),m(i,"class","tab-label svelte-d3wb0j"),m(t,"class","tab svelte-d3wb0j"),S(t,"active",e[5]===e[173].id)},m(e,d){u(e,t,d),c(t,n),c(n,r),c(t,o),c(t,i),c(i,s),c(t,a),x&&x.m(t,null),c(t,l),f||(g=w(t,"click",k),f=!0)},p(n,o){e=n,2048&o[0]&&v!==(v=e[173].icon+"")&&E(r,v),2048&o[0]&&b!==(b=e[173].label+"")&&E(s,b),e[173].isSearchTab?x?x.p(e,o):(x=Bp(e),x.c(),x.m(t,l)):x&&(x.d(1),x=null),2080&o[0]&&S(t,"active",e[5]===e[173].id)},d(e){e&&d(t),x&&x.d(),f=!1,g()}}}function Lp(t){let n;function r(e,t){return e[1]?Vp:Wp}let o=r(t),i=o(t);return{c(){n=h("div"),i.c(),m(n,"class","welcome-message svelte-d3wb0j")},m(e,t){u(e,n,t),i.m(n,null)},p(e,t){o===(o=r(e))&&i?i.p(e,t):(i.d(1),i=o(e),i&&(i.c(),i.m(n,null)))},i:e,o:e,d(e){e&&d(n),i.d()}}}function Up(t){let n,r=t[6],o=[];for(let e=0;e=0||""!==t[30]&&parseInt(t[30])>=0,O=t[37],P=[];for(let e=0;eEvent Recovery \n

Search and recover old versions of replaceable events

',i=y(),s=h("div"),a=h("div"),l=h("div"),p=h("label"),p.textContent="Select Event Kind:",g=y(),v=h("select"),E=h("option"),E.textContent="Choose a replaceable kind...";for(let e=0;et[103].call(v)),m(l,"class","kind-selector svelte-d3wb0j"),m(A,"for","custom-kind"),m(A,"class","svelte-d3wb0j"),m(T,"id","custom-kind"),m(T,"type","number"),m(T,"placeholder","e.g., 10001"),m(T,"min","0"),m(T,"class","svelte-d3wb0j"),m(C,"class","custom-kind-input svelte-d3wb0j"),m(a,"class","recovery-controls svelte-d3wb0j"),m(s,"class","recovery-controls-card svelte-d3wb0j"),m(n,"class","recovery-tab svelte-d3wb0j")},m(e,r){u(e,n,r),c(n,o),c(n,i),c(n,s),c(s,a),c(a,l),c(l,p),c(l,g),c(l,v),c(v,E);for(let e=0;e=0||""!==e[30]&&parseInt(e[30])>=0),R?B?B.p(e,t):(B=oy(e),B.c(),B.m(n,null)):B&&(B.d(1),B=null)},i:e,o:e,d(e){e&&d(n),f(P,e),B&&B.d(),$=!1,r(I)}}}function Mp(t){let n,r,o;function i(e,t){return e[1]&&"owner"===e[4]?py:e[1]?hy:fy}let s=i(t),a=s(t);return{c(){n=h("div"),r=h("h2"),r.textContent="Sprocket Script Management",o=y(),a.c(),m(n,"class","sprocket-view svelte-d3wb0j")},m(e,t){u(e,n,t),c(n,r),c(n,o),a.m(n,null)},p(e,t){s===(s=i(e))&&a?a.p(e,t):(a.d(1),a=s(e),a&&(a.c(),a.m(n,null)))},i:e,o:e,d(e){e&&d(n),a.d()}}}function Dp(e){let t,n,r,o;const i=[xy,Ey,by],s=[];function a(e,t){return"managed"!==e[9]?0:e[1]&&"owner"===e[4]?1:2}return n=a(e),r=s[n]=i[n](e),{c(){t=h("div"),r.c(),m(t,"class","managed-acl-view svelte-d3wb0j")},m(e,r){u(e,t,r),s[n].m(t,null),o=!0},p(e,o){let l=n;n=a(e),n===l?s[n].p(e,o):(q(),W(s[l],1,1,()=>{s[l]=null}),z(),r=s[n],r?r.p(e,o):(r=s[n]=i[n](e),r.c()),K(r,1),r.m(t,null))},i(e){o||(K(r),o=!0)},o(e){W(r),o=!1},d(e){e&&d(t),s[n].d()}}}function Hp(t){let n,o,i,s,a,l,f,p,g,v,b,E;return{c(){n=h("div"),o=h("div"),i=h("button"),i.textContent="Reformat",s=y(),a=h("button"),a.textContent="Sign",l=y(),f=h("button"),f.textContent="Publish",p=y(),g=h("div"),v=h("textarea"),m(i,"class","compose-btn reformat-btn svelte-d3wb0j"),m(a,"class","compose-btn sign-btn svelte-d3wb0j"),m(f,"class","compose-btn publish-btn svelte-d3wb0j"),m(o,"class","compose-header svelte-d3wb0j"),m(v,"class","compose-textarea svelte-d3wb0j"),m(v,"placeholder","Enter your Nostr event JSON here..."),m(v,"spellcheck","false"),m(g,"class","compose-editor svelte-d3wb0j"),m(n,"class","compose-view svelte-d3wb0j")},m(e,r){u(e,n,r),c(n,o),c(o,i),c(o,s),c(o,a),c(o,l),c(o,f),c(n,p),c(n,g),c(g,v),x(v,t[28]),b||(E=[w(i,"click",t[76]),w(a,"click",t[77]),w(f,"click",t[78]),w(v,"input",t[99])],b=!0)},p(e,t){268435456&t[0]&&x(v,e[28])},i:e,o:e,d(e){e&&d(n),b=!1,r(E)}}}function qp(t){let n,r;function o(e,t){return!e[1]||"write"!==e[4]&&"admin"!==e[4]&&"owner"!==e[4]?ky:Sy}let i=o(t),s=i(t),a=t[1]&&("write"===t[4]||"admin"===t[4]||"owner"===t[4])&&Ny(t);return{c(){n=h("div"),s.c(),r=y(),a&&a.c(),m(n,"class","events-view-container svelte-d3wb0j")},m(e,t){u(e,n,t),s.m(n,null),c(n,r),a&&a.m(n,null)},p(e,t){i===(i=o(e))&&s?s.p(e,t):(s.d(1),s=i(e),s&&(s.c(),s.m(n,r))),!e[1]||"write"!==e[4]&&"admin"!==e[4]&&"owner"!==e[4]?a&&(a.d(1),a=null):a?a.p(e,t):(a=Ny(e),a.c(),a.m(n,null))},i:e,o:e,d(e){e&&d(n),s.d(),a&&a.d()}}}function zp(t){let n;function r(e,t){return!e[1]||"admin"!==e[10]&&"owner"!==e[10]?e[1]?My:Fy:Dy}let o=r(t),i=o(t);return{c(){n=h("div"),i.c(),m(n,"class","import-section svelte-d3wb0j")},m(e,t){u(e,n,t),i.m(n,null)},p(e,t){o===(o=r(e))&&i?i.p(e,t):(i.d(1),i=o(e),i&&(i.c(),i.m(n,null)))},i:e,o:e,d(e){e&&d(n),i.d()}}}function Kp(t){let n;function r(e,t){return e[1]?qy:Hy}let o=r(t),i=o(t);return{c(){i.c(),n=g()},m(e,t){i.m(e,t),u(e,n,t)},p(e,t){o===(o=r(e))&&i?i.p(e,t):(i.d(1),i=o(e),i&&(i.c(),i.m(n.parentNode,n)))},i:e,o:e,d(e){i.d(e),e&&d(n)}}}function Wp(t){let n;return{c(){n=h("p"),n.textContent="Log in to access your user dashboard",m(n,"class","svelte-d3wb0j")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Vp(e){let t,n,r,o=(e[3]?.name||e[2].slice(0,8)+"...")+"";return{c(){t=h("p"),n=p("Welcome "),r=p(o),m(t,"class","svelte-d3wb0j")},m(e,o){u(e,t,o),c(t,n),c(t,r)},p(e,t){12&t[0]&&o!==(o=(e[3]?.name||e[2].slice(0,8)+"...")+"")&&E(r,o)},d(e){e&&d(t)}}}function Jp(e){let t,n,o,i,s,a,l,f,g,v,b,x,k,S,C,A,j,T,_,$=e[168].query+"",I=e[36].get(e[168].id)?.isLoading,R=!e[36].get(e[168].id)?.hasMore&&e[36].get(e[168].id)?.events?.length>0;function O(){return e[107](e[168])}function P(e,t){return 64&t[0]&&(k=null),64&t[0]&&(S=null),null==k&&(k=!!(e[36].get(e[168].id)?.events?.length>0)),k?Zp:(null==S&&(S=!e[36].get(e[168].id)?.isLoading),S?Gp:void 0)}let B=P(e,[-1,-1,-1,-1,-1,-1]),N=B&&B(e),L=I&&ey(),U=R&&ty();function F(...t){return e[112](e[168],...t)}return{c(){t=h("div"),n=h("div"),o=h("h2"),i=p('🔍 Search Results: "'),s=p($),a=p('"'),l=y(),f=h("button"),g=p("🔄 Refresh"),b=y(),x=h("div"),N&&N.c(),C=y(),L&&L.c(),A=y(),U&&U.c(),j=y(),m(o,"class","svelte-d3wb0j"),m(f,"class","refresh-btn svelte-d3wb0j"),f.disabled=v=e[36].get(e[168].id)?.isLoading,m(n,"class","search-results-header svelte-d3wb0j"),m(x,"class","search-results-content svelte-d3wb0j"),m(t,"class","search-results-view svelte-d3wb0j")},m(e,r){u(e,t,r),c(t,n),c(n,o),c(o,i),c(o,s),c(o,a),c(n,l),c(n,f),c(f,g),c(t,b),c(t,x),N&&N.m(x,null),c(x,C),L&&L.m(x,null),c(x,A),U&&U.m(x,null),c(t,j),T||(_=[w(f,"click",O),w(x,"scroll",F)],T=!0)},p(t,n){e=t,64&n[0]&&$!==($=e[168].query+"")&&E(s,$),64&n[0]&&v!==(v=e[36].get(e[168].id)?.isLoading)&&(f.disabled=v),B===(B=P(e,n))&&N?N.p(e,n):(N&&N.d(1),N=B&&B(e),N&&(N.c(),N.m(x,C))),64&n[0]&&(I=e[36].get(e[168].id)?.isLoading),I?L||(L=ey(),L.c(),L.m(x,A)):L&&(L.d(1),L=null),64&n[0]&&(R=!e[36].get(e[168].id)?.hasMore&&e[36].get(e[168].id)?.events?.length>0),R?U||(U=ty(),U.c(),U.m(x,null)):U&&(U.d(1),U=null)},d(e){e&&d(t),N&&N.d(),L&&L.d(),U&&U.d(),T=!1,r(_)}}}function Gp(e){let t,n,r,o,i,s=e[168].query+"";return{c(){t=h("div"),n=h("p"),r=p('No search results found for "'),o=p(s),i=p('".'),m(n,"class","svelte-d3wb0j"),m(t,"class","no-search-results svelte-d3wb0j")},m(e,s){u(e,t,s),c(t,n),c(n,r),c(n,o),c(n,i)},p(e,t){64&t[0]&&s!==(s=e[168].query+"")&&E(o,s)},d(e){e&&d(t)}}}function Zp(e){let t,n=e[36].get(e[168].id).events,r=[];for(let t=0;t👤',i=y(),s=h("div"),a=h("div"),l=p(U),f=y(),g=h("div"),v=h("span"),b=p(F),x=y(),k=h("span"),C=p(M),A=y(),j=h("div"),T=h("div"),_=p(D),$=y(),I=h("div"),R=p(H),O=y(),z&&z.c(),P=y(),V&&V.c(),B=y(),m(o,"class","search-result-avatar svelte-d3wb0j"),m(a,"class","search-result-author svelte-d3wb0j"),m(v,"class","kind-number svelte-d3wb0j"),m(k,"class","kind-name svelte-d3wb0j"),m(g,"class","search-result-kind svelte-d3wb0j"),m(s,"class","search-result-info svelte-d3wb0j"),m(T,"class","event-timestamp svelte-d3wb0j"),m(I,"class","event-content-single-line svelte-d3wb0j"),m(j,"class","search-result-content svelte-d3wb0j"),m(n,"class","search-result-row svelte-d3wb0j"),m(n,"role","button"),m(n,"tabindex","0"),m(t,"class","search-result-item svelte-d3wb0j"),S(t,"expanded",e[18].has(e[153].id))},m(e,r){u(e,t,r),c(t,n),c(n,o),c(n,i),c(n,s),c(s,a),c(a,l),c(s,f),c(s,g),c(g,v),c(v,b),c(g,x),c(g,k),c(k,C),c(n,A),c(n,j),c(j,T),c(T,_),c(j,$),c(j,I),c(I,R),c(n,O),z&&z.m(n,null),c(t,P),V&&V.m(t,null),c(t,B),N||(L=[w(n,"click",K),w(n,"keydown",W)],N=!0)},p(r,o){e=r,64&o[0]&&U!==(U=ng(e[153].pubkey)+"")&&E(l,U),64&o[0]&&F!==(F=e[153].kind+"")&&E(b,F),64&o[0]&&M!==(M=e[38](e[153].kind)+"")&&E(C,M),64&o[0]&&D!==(D=og(e[153].created_at)+"")&&E(_,D),64&o[0]&&H!==(H=rg(e[153].content)+"")&&E(R,H),5!==e[153].kind&&("admin"===e[4]||"owner"===e[4]||"write"===e[4]&&e[153].pubkey&&e[153].pubkey===e[2])?z?z.p(e,o):(z=Yp(e),z.c(),z.m(n,null)):z&&(z.d(1),z=null),262208&o[0]&&(q=e[18].has(e[153].id)),q?V?V.p(e,o):(V=Qp(e),V.c(),V.m(t,B)):V&&(V.d(1),V=null),262208&o[0]|32&o[1]&&S(t,"expanded",e[18].has(e[153].id))},d(e){e&&d(t),z&&z.d(),V&&V.d(),N=!1,r(L)}}}function ey(e){let t;return{c(){t=h("div"),t.innerHTML='
\n

Searching...

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

No more search results to load.

',m(t,"class","end-of-search-results svelte-d3wb0j")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function ny(e){let t,n=e[168].id===e[5]&&Jp(e);return{c(){n&&n.c(),t=g()},m(e,r){n&&n.m(e,r),u(e,t,r)},p(e,r){e[168].id===e[5]?n?n.p(e,r):(n=Jp(e),n.c(),n.m(t.parentNode,t)):n&&(n.d(1),n=null)},d(e){n&&n.d(e),e&&d(t)}}}function ry(t){let n,r,o=t[165].label+"";return{c(){n=h("option"),r=p(o),n.__value=t[165].value,n.value=n.__value},m(e,t){u(e,n,t),c(n,r)},p:e,d(e){e&&d(n)}}}function oy(e){let t;function n(e,t){return e[32]?ay:0===e[31].length?sy:iy}let r=n(e),o=r(e);return{c(){t=h("div"),o.c(),m(t,"class","recovery-results svelte-d3wb0j")},m(e,n){u(e,t,n),o.m(t,null)},p(e,i){r===(r=n(e))&&o?o.p(e,i):(o.d(1),o=r(e),o&&(o.c(),o.m(t,null)))},d(e){e&&d(t),o.d()}}}function iy(e){let t,n,r,o=e[31],i=[];for(let t=0;tORLY_OWNERS environment variable with your npub when starting the\n relay.",i=y(),s=h("p"),a=p("Current user role: "),l=h("strong"),f=p(g),m(n,"class","svelte-d3wb0j"),m(o,"class","svelte-d3wb0j"),m(s,"class","svelte-d3wb0j"),m(t,"class","permission-denied svelte-d3wb0j")},m(e,d){u(e,t,d),c(t,n),c(t,r),c(t,o),c(t,i),c(t,s),c(s,a),c(s,l),c(l,f)},p(e,t){16&t[0]&&g!==(g=(e[4]||"none")+"")&&E(f,g)},d(e){e&&d(t)}}}function py(e){let t,n,o,i,s,a,l,g,v,b,k,C,A,j,T,_,$,I,R,O,P,B,N,L,U,F,M,D,H,q,z,K,W,V,J,G,Z,Y,Q,X,ee,te,ne,re,oe,ie,se,ae,le,ce,ue,de,fe,he,pe,ye,ge=e[22]?.is_running?"🟢 Running":"🔴 Stopped",we=e[22]?.script_exists?"✅ Exists":"❌ Not found",ve=e[22]?.pid&&yy(e),me=e[25]&&gy(e),be=e[23],Ee=[];for(let t=0;tORLY_ACL_MODE=managed in your\n environment variables and restart the relay.',m(r,"class","svelte-d3wb0j"),m(i,"class","svelte-d3wb0j"),m(a,"class","svelte-d3wb0j"),m(v,"class","svelte-d3wb0j"),m(n,"class","acl-mode-warning svelte-d3wb0j")},m(e,t){u(e,n,t),c(n,r),c(n,o),c(n,i),c(n,s),c(n,a),c(a,l),c(a,f),c(f,g),c(n,w),c(n,v)},p(e,t){512&t[0]&&b!==(b=(e[9]||"unknown")+"")&&E(g,b)},i:e,o:e,d(e){e&&d(n)}}}function ky(t){let n;return{c(){n=h("div"),n.innerHTML='

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

',m(n,"class","permission-denied svelte-d3wb0j")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Sy(e){let t,n,r,o,i;function s(e,t){return e[35].length>0?Ay:e[19]?void 0:Cy}let a=s(e),l=a&&a(e),f=e[19]&&Py(),p=!e[20]&&e[7].length>0&&By();return{c(){t=h("div"),l&&l.c(),n=y(),f&&f.c(),r=y(),p&&p.c(),m(t,"class","events-view-content svelte-d3wb0j")},m(s,a){u(s,t,a),l&&l.m(t,null),c(t,n),f&&f.m(t,null),c(t,r),p&&p.m(t,null),o||(i=w(t,"scroll",e[75]),o=!0)},p(e,o){a===(a=s(e))&&l?l.p(e,o):(l&&l.d(1),l=a&&a(e),l&&(l.c(),l.m(t,n))),e[19]?f||(f=Py(),f.c(),f.m(t,r)):f&&(f.d(1),f=null),!e[20]&&e[7].length>0?p||(p=By(),p.c(),p.m(t,null)):p&&(p.d(1),p=null)},d(e){e&&d(t),l&&l.d(),f&&f.d(),p&&p.d(),o=!1,i()}}}function Cy(t){let n;return{c(){n=h("div"),n.innerHTML='

No events found.

',m(n,"class","no-events svelte-d3wb0j")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Ay(e){let t,n=e[35],r=[];for(let t=0;t0&&_y(e);return{c(){t=h("div"),n=h("span"),n.textContent="🗑️ Delete Event",r=y(),o&&o.c(),m(n,"class","delete-event-label svelte-d3wb0j"),m(t,"class","delete-event-info svelte-d3wb0j")},m(e,i){u(e,t,i),c(t,n),c(t,r),o&&o.m(t,null)},p(e,n){e[153].tags&&e[153].tags.length>0?o?o.p(e,n):(o=_y(e),o.c(),o.m(t,null)):o&&(o.d(1),o=null)},d(e){e&&d(t),o&&o.d()}}}function _y(e){let t,n=e[153].tags.filter(sg),r=[];for(let t=0;t👤',i=y(),s=h("div"),a=h("div"),l=p(N),f=y(),g=h("div"),v=h("span"),b=p(L),x=y(),k=h("span"),C=p(U),A=y(),j=h("div"),T=h("div"),_=p(F),$=y(),q.c(),I=y(),z&&z.c(),R=y(),V&&V.c(),O=y(),m(o,"class","events-view-avatar svelte-d3wb0j"),m(a,"class","events-view-author svelte-d3wb0j"),m(v,"class","kind-number svelte-d3wb0j"),S(v,"delete-event",5===e[153].kind),m(k,"class","kind-name svelte-d3wb0j"),m(g,"class","events-view-kind svelte-d3wb0j"),m(s,"class","events-view-info svelte-d3wb0j"),m(T,"class","event-timestamp svelte-d3wb0j"),m(j,"class","events-view-content svelte-d3wb0j"),m(n,"class","events-view-row svelte-d3wb0j"),m(n,"role","button"),m(n,"tabindex","0"),m(t,"class","events-view-item svelte-d3wb0j"),S(t,"expanded",e[18].has(e[153].id))},m(e,r){u(e,t,r),c(t,n),c(n,o),c(n,i),c(n,s),c(s,a),c(a,l),c(s,f),c(s,g),c(g,v),c(v,b),c(g,x),c(g,k),c(k,C),c(n,A),c(n,j),c(j,T),c(T,_),c(j,$),q.m(j,null),c(n,I),z&&z.m(n,null),c(t,R),V&&V.m(t,null),c(t,O),P||(B=[w(n,"click",K),w(n,"keydown",W)],P=!0)},p(r,o){e=r,16&o[1]&&N!==(N=ng(e[153].pubkey)+"")&&E(l,N),16&o[1]&&L!==(L=e[153].kind+"")&&E(b,L),16&o[1]&&S(v,"delete-event",5===e[153].kind),16&o[1]&&U!==(U=e[38](e[153].kind)+"")&&E(C,U),16&o[1]&&F!==(F=og(e[153].created_at)+"")&&E(_,F),H===(H=D(e))&&q?q.p(e,o):(q.d(1),q=H(e),q&&(q.c(),q.m(j,null))),5!==e[153].kind&&("admin"===e[4]||"owner"===e[4]||"write"===e[4]&&e[153].pubkey&&e[153].pubkey===e[2])?z?z.p(e,o):(z=Iy(e),z.c(),z.m(n,null)):z&&(z.d(1),z=null),262144&o[0]|16&o[1]&&(M=e[18].has(e[153].id)),M?V?V.p(e,o):(V=Ry(e),V.c(),V.m(t,O)):V&&(V.d(1),V=null),262144&o[0]|16&o[1]&&S(t,"expanded",e[18].has(e[153].id))},d(e){e&&d(t),q.d(),z&&z.d(),V&&V.d(),P=!1,r(B)}}}function Py(e){let t;return{c(){t=h("div"),t.innerHTML='
\n

Loading events...

',m(t,"class","loading-events svelte-d3wb0j")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function By(e){let t;return{c(){t=h("div"),t.innerHTML='

No more events to load.

',m(t,"class","end-of-events svelte-d3wb0j")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Ny(e){let t,n,o,i,s,a,l,f,g,v,b,E,x,k,S,C;function A(e,t){return e[19]?Uy:Ly}let j=A(e),T=j(e);return{c(){t=h("div"),n=h("div"),o=h("label"),i=h("input"),s=y(),a=h("span"),l=y(),f=h("span"),f.textContent="Only show my events",g=y(),v=h("div"),b=h("button"),E=p("🔄 Load More"),x=y(),k=h("button"),T.c(),m(i,"type","checkbox"),m(i,"class","svelte-d3wb0j"),m(a,"class","toggle-slider svelte-d3wb0j"),m(f,"class","toggle-label svelte-d3wb0j"),m(o,"class","toggle-container svelte-d3wb0j"),m(n,"class","events-view-toggle svelte-d3wb0j"),m(b,"class","refresh-btn svelte-d3wb0j"),b.disabled=e[19],m(k,"class","reload-btn svelte-d3wb0j"),k.disabled=e[19],m(v,"class","events-view-buttons svelte-d3wb0j"),m(t,"class","events-view-header svelte-d3wb0j")},m(r,d){u(r,t,d),c(t,n),c(n,o),c(o,i),i.checked=e[8],c(o,s),c(o,a),c(o,l),c(o,f),c(t,g),c(t,v),c(v,b),c(b,E),c(v,x),c(v,k),T.m(k,null),S||(C=[w(i,"change",e[95]),w(i,"change",e[96]),w(b,"click",e[97]),w(k,"click",e[98])],S=!0)},p(e,t){256&t[0]&&(i.checked=e[8]),524288&t[0]&&(b.disabled=e[19]),j!==(j=A(e))&&(T.d(1),T=j(e),T&&(T.c(),T.m(k,null))),524288&t[0]&&(k.disabled=e[19])},d(e){e&&d(t),T.d(),S=!1,r(C)}}}function Ly(e){let t;return{c(){t=p("🔄")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Uy(e){let t;return{c(){t=h("div"),m(t,"class","spinner svelte-d3wb0j")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Fy(t){let n,r,o,i,s,a,l,f;return{c(){n=h("div"),r=h("h3"),r.textContent="Import Events",o=y(),i=h("p"),i.textContent="Please log in to access import functionality.",s=y(),a=h("button"),a.textContent="Log In",m(r,"class","recovery-header svelte-d3wb0j"),m(i,"class","recovery-description svelte-d3wb0j"),m(a,"class","login-btn svelte-d3wb0j"),m(n,"class","login-prompt svelte-d3wb0j")},m(e,d){u(e,n,d),c(n,r),c(n,o),c(n,i),c(n,s),c(n,a),l||(f=w(a,"click",t[58]),l=!0)},p:e,d(e){e&&d(n),l=!1,f()}}}function My(t){let n;return{c(){n=h("div"),n.innerHTML='

Import Events

\n

❌ Admin or owner permission required for import\n functionality.

',m(n,"class","permission-denied svelte-d3wb0j")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Dy(e){let t,n,o,i,s,a,l,f,g,v,b,E;return{c(){t=h("h3"),t.textContent="Import Events",n=y(),o=h("p"),o.textContent="Upload a JSONL file to import events into the database.",i=y(),s=h("div"),a=h("input"),l=y(),f=h("button"),g=p("Import Events"),m(t,"class","svelte-d3wb0j"),m(o,"class","svelte-d3wb0j"),m(a,"type","file"),m(a,"id","import-file"),m(a,"accept",".jsonl,.txt"),m(a,"class","svelte-d3wb0j"),m(f,"class","import-btn svelte-d3wb0j"),f.disabled=v=!e[17],m(s,"class","recovery-controls-card svelte-d3wb0j")},m(r,d){u(r,t,d),u(r,n,d),u(r,o,d),u(r,i,d),u(r,s,d),c(s,a),c(s,l),c(s,f),c(f,g),b||(E=[w(a,"change",e[72]),w(f,"click",e[73])],b=!0)},p(e,t){131072&t[0]&&v!==(v=!e[17])&&(f.disabled=v)},d(e){e&&d(t),e&&d(n),e&&d(o),e&&d(i),e&&d(s),b=!1,r(E)}}}function Hy(t){let n,r,o,i,s,a;return{c(){n=h("div"),r=h("p"),r.textContent="Please log in to access export functionality.",o=y(),i=h("button"),i.textContent="Log In",m(r,"class","svelte-d3wb0j"),m(i,"class","login-btn svelte-d3wb0j"),m(n,"class","login-prompt svelte-d3wb0j")},m(e,l){u(e,n,l),c(n,r),c(n,o),c(n,i),s||(a=w(i,"click",t[58]),s=!0)},p:e,d(e){e&&d(n),s=!1,a()}}}function qy(e){let t,n,r,o,i,s,a,l,f,p,v=("admin"===e[10]||"owner"===e[10])&&zy(e);return{c(){t=h("div"),n=h("h3"),n.textContent="Export My Events",r=y(),o=h("p"),o.textContent="Download your personal events as a JSONL file.",i=y(),s=h("button"),s.textContent="📤 Export My Events",a=y(),v&&v.c(),l=g(),m(n,"class","svelte-d3wb0j"),m(o,"class","svelte-d3wb0j"),m(s,"class","export-btn svelte-d3wb0j"),m(t,"class","export-section svelte-d3wb0j")},m(d,h){u(d,t,h),c(t,n),c(t,r),c(t,o),c(t,i),c(t,s),u(d,a,h),v&&v.m(d,h),u(d,l,h),f||(p=w(s,"click",e[71]),f=!0)},p(e,t){"admin"===e[10]||"owner"===e[10]?v?v.p(e,t):(v=zy(e),v.c(),v.m(l.parentNode,l)):v&&(v.d(1),v=null)},d(e){e&&d(t),e&&d(a),v&&v.d(e),e&&d(l),f=!1,p()}}}function zy(t){let n,r,o,i,s,a,l,f;return{c(){n=h("div"),r=h("h3"),r.textContent="Export All Events",o=y(),i=h("p"),i.textContent="Download the complete database as a JSONL file. This\n includes all events from all users.",s=y(),a=h("button"),a.textContent="📤 Export All Events",m(r,"class","svelte-d3wb0j"),m(i,"class","svelte-d3wb0j"),m(a,"class","export-btn svelte-d3wb0j"),m(n,"class","export-section svelte-d3wb0j")},m(e,d){u(e,n,d),c(n,r),c(n,o),c(n,i),c(n,s),c(n,a),l||(f=w(a,"click",t[70]),l=!0)},p:e,d(e){e&&d(n),l=!1,f()}}}function Ky(e){let t,n,o,i,s,a,l,f,p,g;function b(e,t){return e[3]?Vy:e[1]&&e[2]?Wy:void 0}let E=b(e),x=E&&E(e);return{c(){t=h("div"),n=h("div"),o=h("div"),i=h("h2"),i.textContent="Settings",s=y(),a=h("button"),a.textContent="✕",l=y(),f=h("div"),x&&x.c(),m(i,"class","svelte-d3wb0j"),m(a,"class","close-btn svelte-d3wb0j"),m(o,"class","drawer-header svelte-d3wb0j"),m(f,"class","drawer-content"),m(n,"class","settings-drawer svelte-d3wb0j"),S(n,"dark-theme",e[0]),m(t,"class","drawer-overlay svelte-d3wb0j"),m(t,"role","button"),m(t,"tabindex","0")},m(r,d){u(r,t,d),c(t,n),c(n,o),c(o,i),c(o,s),c(o,a),c(n,l),c(n,f),x&&x.m(f,null),p||(g=[w(a,"click",e[63]),w(n,"click",v(e[84])),w(n,"keydown",v(e[85])),w(t,"click",e[63]),w(t,"keydown",e[114])],p=!0)},p(e,t){E===(E=b(e))&&x?x.p(e,t):(x&&x.d(1),x=E&&E(e),x&&(x.c(),x.m(f,null))),1&t[0]&&S(n,"dark-theme",e[0])},d(e){e&&d(t),x&&x.d(),p=!1,r(g)}}}function Wy(e){let t,n,r,o,i,s,a,l,f,g,v,b,x,k,S,C=e[2].slice(0,16)+"",A=e[2].slice(-8)+"";return{c(){t=h("div"),n=h("h3"),n.textContent="Profile Loading",r=y(),o=h("p"),o.textContent="Your profile metadata is being loaded...",i=y(),s=h("button"),s.textContent="Retry Loading Profile",a=y(),l=h("div"),f=h("strong"),f.textContent="Public Key:",g=y(),v=p(C),b=p("..."),x=p(A),m(n,"class","svelte-d3wb0j"),m(o,"class","svelte-d3wb0j"),m(s,"class","retry-profile-btn svelte-d3wb0j"),m(l,"class","user-pubkey-display svelte-d3wb0j"),m(t,"class","profile-loading-section svelte-d3wb0j")},m(d,h){u(d,t,h),c(t,n),c(t,r),c(t,o),c(t,i),c(t,s),c(t,a),c(t,l),c(l,f),c(l,g),c(l,v),c(l,b),c(l,x),k||(S=w(s,"click",e[69]),k=!0)},p(e,t){4&t[0]&&C!==(C=e[2].slice(0,16)+"")&&E(v,C),4&t[0]&&A!==(A=e[2].slice(-8)+"")&&E(x,A)},d(e){e&&d(t),k=!1,S()}}}function Vy(e){let t,n,r,o,i,s,a,l,f,v,b,x,k,S,C,A=(e[3].name||"Unknown User")+"",j=e[3].banner&&Jy(e);function T(e,t){return e[3].picture?Zy:Gy}let _=T(e),$=_(e),I=e[3].nip05&&Yy(e),R=e[3].about&&Qy(e),O=e[4]&&"read"!==e[4]&&Xy(e);return{c(){t=h("div"),n=h("div"),j&&j.c(),r=y(),o=h("button"),o.textContent="Log out",i=y(),$.c(),s=y(),a=h("div"),l=h("h3"),f=p(A),v=y(),I&&I.c(),b=y(),R&&R.c(),x=y(),O&&O.c(),k=g(),m(o,"class","logout-btn floating svelte-d3wb0j"),m(l,"class","profile-username svelte-d3wb0j"),m(a,"class","name-row svelte-d3wb0j"),m(n,"class","profile-hero svelte-d3wb0j"),m(t,"class","profile-section svelte-d3wb0j")},m(d,h){u(d,t,h),c(t,n),j&&j.m(n,null),c(n,r),c(n,o),c(n,i),$.m(n,null),c(n,s),c(n,a),c(a,l),c(l,f),c(a,v),I&&I.m(a,null),c(t,b),R&&R.m(t,null),u(d,x,h),O&&O.m(d,h),u(d,k,h),S||(C=w(o,"click",e[60]),S=!0)},p(e,o){e[3].banner?j?j.p(e,o):(j=Jy(e),j.c(),j.m(n,r)):j&&(j.d(1),j=null),_===(_=T(e))&&$?$.p(e,o):($.d(1),$=_(e),$&&($.c(),$.m(n,s))),8&o[0]&&A!==(A=(e[3].name||"Unknown User")+"")&&E(f,A),e[3].nip05?I?I.p(e,o):(I=Yy(e),I.c(),I.m(a,null)):I&&(I.d(1),I=null),e[3].about?R?R.p(e,o):(R=Qy(e),R.c(),R.m(t,null)):R&&(R.d(1),R=null),e[4]&&"read"!==e[4]?O?O.p(e,o):(O=Xy(e),O.c(),O.m(k.parentNode,k)):O&&(O.d(1),O=null)},d(e){e&&d(t),j&&j.d(),$.d(),I&&I.d(),R&&R.d(),e&&d(x),O&&O.d(e),e&&d(k),S=!1,C()}}}function Jy(e){let t,n;return{c(){t=h("img"),a(t.src,n=e[3].banner)||m(t,"src",n),m(t,"alt","Profile banner"),m(t,"class","profile-banner svelte-d3wb0j")},m(e,n){u(e,t,n)},p(e,r){8&r[0]&&!a(t.src,n=e[3].banner)&&m(t,"src",n)},d(e){e&&d(t)}}}function Gy(t){let n;return{c(){n=h("div"),n.textContent="👤",m(n,"class","profile-avatar-placeholder overlap svelte-d3wb0j")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Zy(e){let t,n;return{c(){t=h("img"),a(t.src,n=e[3].picture)||m(t,"src",n),m(t,"alt","User avatar"),m(t,"class","profile-avatar overlap svelte-d3wb0j")},m(e,n){u(e,t,n)},p(e,r){8&r[0]&&!a(t.src,n=e[3].picture)&&m(t,"src",n)},d(e){e&&d(t)}}}function Yy(e){let t,n,r=e[3].nip05+"";return{c(){t=h("span"),n=p(r),m(t,"class","profile-nip05-inline svelte-d3wb0j")},m(e,r){u(e,t,r),c(t,n)},p(e,t){8&t[0]&&r!==(r=e[3].nip05+"")&&E(n,r)},d(e){e&&d(t)}}}function Qy(e){let t,n;return{c(){t=h("div"),n=h("p"),m(n,"class","profile-about svelte-d3wb0j"),m(t,"class","about-card svelte-d3wb0j")},m(r,o){u(r,t,o),c(t,n),n.innerHTML=e[34]},p(e,t){8&t[1]&&(n.innerHTML=e[34])},d(e){e&&d(t)}}}function Xy(e){let t,n,r,o,i,s,a=e[80](),l=[];for(let t=0;tfunction(e,t,n){const r=e.$$.props[t];void 0!==r&&(e.$$.bound[r]=n,n(e.$$.ctx[r]))}(F,"showModal",ue)),F.$on("login",e[59]),F.$on("close",e[61]),{c(){t=h("header"),n=h("div"),o=h("img"),s=y(),ee.c(),l=y(),g=h("button"),g.textContent="🔍",v=y(),b=h("button"),x=p(Y),k=y(),re.c(),C=y(),A=h("div"),j=h("aside"),T=h("div"),_=h("div");for(let e=0;e{ae[o]=null}),z(),N=ae[B],N?N.p(e,r):(N=ae[B]=se[B](e),N.c()),K(N,1),N.m(R,null)),(!D||1&r[0])&&S(A,"dark-theme",e[0]),e[14]?ce?ce.p(e,r):(ce=Ky(e),ce.c(),ce.m(U.parentNode,U)):ce&&(ce.d(1),ce=null);const i={};var s;1&r[0]&&(i.isDarkTheme=e[0]),!M&&4096&r[0]&&(M=!0,i.showModal=e[12],s=()=>M=!1,O.push(s)),F.$set(i)},i(e){D||(K(N),K(F.$$.fragment,e),D=!0)},o(e){W(N),W(F.$$.fragment,e),D=!1},d(e){e&&d(t),ee.d(),re.d(),e&&d(C),e&&d(A),f(ie,e),ae[B].d(),e&&d(L),ce&&ce.d(e),e&&d(U),G(F,e),H=!1,r(Z)}}}function ng(e){return e?e.slice(0,8)+"..."+e.slice(-8):"unknown"}function rg(e,t=100){return e?e.length>t?e.slice(0,t)+"...":e:""}function og(e){return e?new Date(1e3*e).toLocaleString():""}async function ig(e,t){try{const n=JSON.stringify(e);await navigator.clipboard.writeText(n);const r=t.target.closest(".copy-json-btn");if(r){const e=r.textContent;r.textContent="✅",r.style.backgroundColor="#4CAF50",setTimeout(()=>{r.textContent=e,r.style.backgroundColor=""},2e3)}}catch(n){console.error("Failed to copy to clipboard:",n);try{const n=document.createElement("textarea");n.value=JSON.stringify(e),document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n);const r=t.target.closest(".copy-json-btn");if(r){const e=r.textContent;r.textContent="✅",r.style.backgroundColor="#4CAF50",setTimeout(()=>{r.textContent=e,r.style.backgroundColor=""},2e3)}}catch(e){console.error("Fallback copy also failed:",e),alert("Failed to copy to clipboard. Please copy manually.")}}}const sg=e=>"e"===e[0];function ag(e,t,n){let r,o,i,s,a;"undefined"!=typeof window&&(window.debugIndexedDB=gh);let l=!1,c=!1,u=!1,d="",f="",h=null,p="",y=null,g=!1,w=localStorage.getItem("selectedTab")||"export",v=!1,m="",E=[],x=[],k=null,S=new Set,C=!1,A=!0,j=null,T="",$=new Map,I=[],R=0;const O=3e5;let P=!1,B=[],N=!0,L=null,U="",F=null,M=[],D=!1,H="",q="info",z=!1,K=null,W="",V="",J=null,G="",Z=[],Y=!1,Q=!0,X=null;const ee=[{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)"}],te={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"};function ne(e){S.has(e)?S.delete(e):S.add(e),n(18,S)}async function re(){console.log("Toggle changed, showOnlyMyEvents:",P);const e=P&&u&&d?[d]:null;await Se(!0,e)}async function oe(e){if(!u)return void alert("Please log in first");const t=x.find(t=>t.id===e);if(!t)return void alert("Event not found");if("admin"===p||"owner"===p||"write"===p&&t.pubkey&&t.pubkey===d){if(confirm("Are you sure you want to delete this event?"))try{if(!y)throw new Error("Signer not available for signing");const r={kind:5,created_at:Math.floor(Date.now()/1e3),tags:[["e",e]],content:""};console.log("Created delete event template:",r),console.log("User pubkey:",d),console.log("Target event:",t),console.log("Target event pubkey:",t.pubkey);const o=await y.signEvent(r);console.log("Signed delete event:",o),console.log("Signed delete event pubkey:",o.pubkey),console.log("Delete event tags:",o.tags);const i=`wss://${window.location.host}`;try{const e=await vp(i,o,y,d);e.success?console.log("Delete event published successfully to ORLY relay"):console.error("Failed to publish delete event:",e.reason)}catch(e){console.error("Error publishing delete event:",e)}const s=t.pubkey&&t.pubkey===d;if(s){const t=await nh.publish(o);if(console.log("Delete event published:",t),!(t.success&&t.okCount>0))throw new Error("No relays accepted the delete event");{await new Promise(e=>setTimeout(e,2e3));try{const n=await hh(e,{timeout:5e3});n?(console.warn("Event still exists after deletion attempt:",n),alert(`Warning: Delete event was accepted by ${t.okCount} relay(s), but the event still exists on the relay. This may indicate the relay does not properly handle delete events.`)):console.log("Event successfully deleted and verified")}catch(e){console.log("Could not fetch event after deletion (likely deleted):",e.message)}try{const t=await ph(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(7,x=x.filter(t=>t.id!==e)),B=B.filter(t=>t.id!==e),I=I.filter(t=>t.id!==e);for(const[t,n]of $)n.events&&(n.events=n.events.filter(t=>t.id!==e),$.set(t,n));ae(),console.log("Reloading events to show delete event...");const r=P&&u&&d?[d]:null;await Se(!0,r),alert(`Event deleted successfully (accepted by ${t.okCount} relay(s))`)}}else{const t=`wss://${window.location.host}/`,r=new th;await r.connectToRelay(t);const i=await r.publish(o);if(console.log("Delete event published to local relay only:",i),!(i.success&&i.okCount>0))throw new Error("Local relay did not accept the delete event");{await new Promise(e=>setTimeout(e,2e3));try{const t=await hh(e,{timeout:5e3});t?(console.warn("Event still exists after deletion attempt:",t),alert(`Warning: Delete event was accepted by ${i.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 ph(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(7,x=x.filter(t=>t.id!==e)),B=B.filter(t=>t.id!==e),I=I.filter(t=>t.id!==e);for(const[t,n]of $)n.events&&(n.events=n.events.filter(t=>t.id!==e),$.set(t,n));ae(),console.log("Reloading events to show delete event...");const t=P&&u&&d?[d]:null;await Se(!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 ie(){const e=G?parseInt(G):J;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(32,Y=!0);try{const t=[{kinds:[e],authors:[d],limit:100}];X&&(t[0].until=X),console.log("Recovery filters:",t);const r=await async function(e,t={}){const{timeout:n=3e4,cacheFirst:r=!0,cacheOnly:o=!1}=t;let i=[];if(r||o)try{if(i=await ch(e),console.log(`Found ${i.length} events in cache`),o||i.length>0)return i}catch(e){console.warn("Failed to query cache",e)}if(!o){const t=await fh(e,{timeout:n,useCache:!1});return console.log(`Fetched ${t.length} events from relay`),t}return i}(t,{timeout:3e4,cacheFirst:!0});console.log("Recovery events received:",r.length),console.log("Recovery events kinds:",r.map(e=>e.kind)),n(31,Z=X?[...Z,...r]:r),r.length>0?(X=Math.min(...r.map(e=>e.created_at)),n(33,Q=100===r.length)):n(33,Q=!1)}catch(e){console.error("Failed to load recovery events:",e)}finally{n(32,Y=!1)}}else console.log("Not logged in, cannot load recovery events")}async function se(e){if(confirm("Are you sure you want to repost this event?"))try{const t=`wss://${window.location.host}/`;console.log("Reposting event to local relay:",t,e);const r={...e};if(r.created_at=Math.floor(Date.now()/1e3),r.id="",r.sig="",e.kind>=3e4&&e.kind<=39999){const t=e.tags.find(e=>"d"===e[0]);t&&(r.tags=r.tags.filter(e=>"d"!==e[0]),r.tags.push(t))}if(y){const e=await y.signEvent(r);console.log("Signed event for repost:",e);const o=await nh.publish(e,[t]);console.log("Repost publish result:",o),o.success&&o.okCount>0?(alert("Event reposted successfully!"),n(33,Q=!1),await ie()):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)}}if("undefined"!=typeof localStorage){const e=localStorage.getItem("isDarkTheme");null!==e&&(l=JSON.parse(e));const t=localStorage.getItem("nostr_auth_method"),r=localStorage.getItem("nostr_pubkey");t&&r&&(u=!0,d=r,f=t,"extension"===t&&window.nostr&&(y=window.nostr),Ee(),xe()),function(){if("undefined"==typeof localStorage)return;try{const t=localStorage.getItem("app_state");if(t){const r=JSON.parse(t);r.selectedTab&&pe.some(e=>e.id===r.selectedTab)&&n(5,w=r.selectedTab),r.expandedEvents&&n(18,S=new Set(r.expandedEvents)),r.globalEventsCache&&(I=r.globalEventsCache),r.globalCacheTimestamp&&(R=r.globalCacheTimestamp),void 0!==r.hasMoreEvents&&n(20,A=r.hasMoreEvents),r.oldestEventTimestamp&&(j=r.oldestEventTimestamp),void 0!==r.hasMoreMyEvents&&(N=r.hasMoreMyEvents),r.oldestMyEventTimestamp&&(L=r.oldestMyEventTimestamp),I.length>0&&((e=R)&&Date.now()-et.created_at-e.created_at),R=Date.now(),ae()}async function ce(){if(u&&"owner"===p&&z)try{n(24,D=!0);const e=await fetch("/api/sprocket/status",{method:"GET",headers:{Authorization:`Nostr ${await je("GET","/api/sprocket/status")}`,"Content-Type":"application/json"}});e.ok?n(22,F=await e.json()):he("Failed to load sprocket status","error")}catch(e){he(`Error loading sprocket status: ${e.message}`,"error")}finally{n(24,D=!1)}}async function ue(){if(u&&"owner"===p)try{n(24,D=!0);const e=await fetch("/api/sprocket/versions",{method:"GET",headers:{Authorization:`Nostr ${await je("GET","/api/sprocket/versions")}`,"Content-Type":"application/json"}});e.ok?n(23,M=await e.json()):he("Failed to load versions","error")}catch(e){he(`Error loading versions: ${e.message}`,"error")}finally{n(24,D=!1)}}async function de(e){u&&"owner"===p&&(n(21,U=e.content),he(`Loaded version: ${e.name}`,"success"))}async function fe(e){if(u&&"owner"===p&&confirm(`Are you sure you want to delete version ${e}?`))try{n(24,D=!0);const t=await fetch("/api/sprocket/delete-version",{method:"POST",headers:{Authorization:`Nostr ${await je("POST","/api/sprocket/delete-version")}`,"Content-Type":"application/json"},body:JSON.stringify({filename:e})});if(t.ok)he(`Version ${e} deleted successfully`,"success"),await ue();else{he(`Failed to delete version: ${await t.text()}`,"error")}}catch(e){he(`Error deleting version: ${e.message}`,"error")}finally{n(24,D=!1)}}function he(e,t="info"){n(25,H=e),n(26,q=t),setTimeout(()=>{n(25,H="")},5e3)}const pe=[{id:"export",icon:"📤",label:"Export"},{id:"import",icon:"💾",label:"Import",requiresAdmin:!0},{id:"events",icon:"📡",label:"Events"},{id:"compose",icon:"✏️",label:"Compose",requiresWrite:!0},{id:"recovery",icon:"🔄",label:"Recovery"},{id:"managed-acl",icon:"🛡️",label:"Managed ACL",requiresOwner:!0},{id:"sprocket",icon:"⚙️",label:"Sprocket",requiresOwner:!0}];function ye(e){n(5,w=e),"sprocket"===e&&u&&"owner"===p&&z&&(ce(),ue()),ae()}function ge(){n(14,g=!1)}function we(e){n(6,E=E.filter(t=>t.id!==e)),$.delete(e),w===e&&n(5,w="export")}async function ve(e,t,n=!0){const r=$.get(e);if(r&&!r.isLoading){r.isLoading=!0,$.set(e,r);try{const o={limit:n?100:200,until:n?Math.floor(Date.now()/1e3):r.oldestTimestamp};console.log("Loading search results for query:",t,"with options:",o);const i=await async function(e,t={}){const{limit:n=100,since:r=null,until:o=null,kinds:i=null}=t,s=[{search:e}];return r&&(s[0].since=r),o&&(s[0].until=o),i&&(s[0].kinds=i),n&&(s[0].limit=n),await fh(s,{timeout:3e4})}(t,o);if(console.log("Received search results:",i.length,"events"),r.events=n?i.sort((e,t)=>t.created_at-e.created_at):[...r.events,...i].sort((e,t)=>t.created_at-e.created_at),i.length>0){const e=Math.min(...i.map(e=>e.created_at));(!r.oldestTimestamp||et.id===e);t&&await ve(e,t.query,!1)}(t)}}async function be(){if(u&&d&&!h)try{console.log("Auto-fetching profile for:",d),await yh(),n(3,h=await dh(d)),console.log("Profile auto-loaded:",h)}catch(e){console.error("Failed to auto-load profile:",e)}}async function Ee(){if(u&&d)try{const e=await fetch(`/api/permissions/${d}`);if(e.ok){const t=await e.json();n(4,p=t.permission||""),console.log("User role loaded:",p),console.log("Is owner?","owner"===p)}else console.error("Failed to fetch user role:",e.status),n(4,p="")}catch(e){console.error("Error fetching user role:",e),n(4,p="")}else n(4,p="")}async function xe(){try{const e=await fetch("/api/acl-mode");if(e.ok){const t=await e.json();n(9,W=t.acl_mode||""),console.log("ACL mode loaded:",W)}else console.error("Failed to fetch ACL mode:",e.status),n(9,W="")}catch(e){console.error("Error fetching ACL mode:",e),n(9,W="")}}async function ke(e=[]){if(u)if(0!==e.length||"admin"===a||"owner"===a)try{const t=await Ae("/api/export","POST"),n=await fetch("/api/export",{method:"POST",headers:{Authorization:t,"Content-Type":"application/json"},body:JSON.stringify({pubkeys:e})});if(!n.ok)throw new Error(`Export failed: ${n.status} ${n.statusText}`);const r=await n.blob(),o=window.URL.createObjectURL(r),i=document.createElement("a");i.href=o;const s=n.headers.get("Content-Disposition");let a="events.jsonl";if(s){const e=s.match(/filename="([^"]+)"/);e&&(a=e[1])}i.download=a,document.body.appendChild(i),i.click(),document.body.removeChild(i),window.URL.revokeObjectURL(o)}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 Se(e=!1,t=null){if(!u||"write"!==p&&"admin"!==p&&"owner"!==p)alert("Write, admin, or owner permission required");else if(!C){n(19,C=!0),e&&(j=null);try{console.log("Loading events with authors filter:",t,"including delete events");const r=await async function(e={}){const{limit:t=100,since:n=null,until:r=null,authors:o=null,kinds:i=null,...s}=e,a=[{...s}];return n&&(a[0].since=n),r&&(a[0].until=r),o&&(a[0].authors=o),i&&(a[0].kinds=i),t&&(a[0].limit=t),await fh(a,{timeout:3e4})}({limit:e?100:200,until:e?Math.floor(Date.now()/1e3):j,authors:t});if(console.log("Received events:",r.length,"events"),t&&r.length>0){const e=r.filter(e=>e.pubkey&&e.pubkey!==d);e.length>0&&console.warn("Server returned non-user events:",e.length,"out of",r.length)}if(e?(n(7,x=r.sort((e,t)=>t.created_at-e.created_at)),le(r)):(n(7,x=[...x,...r].sort((e,t)=>t.created_at-e.created_at)),le(x)),r.length>0){const e=Math.min(...r.map(e=>e.created_at));(!j||e{if("events"===w){const e=document.querySelectorAll(".events-view-content")[0];e&&e.scrollHeight<=e.clientHeight&&Ce()}},100)}catch(e){console.error("Failed to load events:",e),alert("Failed to load events: "+e.message)}finally{n(19,C=!1)}}}async function Ce(){await Se(!1)}async function Ae(e,t){if(!u||!d)throw new Error("Not logged in");const n={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",window.location.origin+e],["method",t.toUpperCase()]],content:"",pubkey:d};let r;if(y&&"extension"===f)try{r=await y.signEvent(n)}catch(e){throw new Error("Failed to sign with extension: "+e.message)}else{if("nsec"!==f)throw new Error("No valid signer available");n.id="mock-id-"+Date.now(),n.sig="mock-signature-"+Date.now(),r=n}const o=JSON.stringify(r);return`Nostr ${btoa(o)}`}async function je(e,t){if(!u||!d)throw new Error("Not logged in");const n={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",window.location.origin+t],["method",e.toUpperCase()]],content:"",pubkey:d};let r;if(y&&"extension"===f)try{r=await y.signEvent(n)}catch(e){throw new Error("Failed to sign with extension: "+e.message)}else{if("nsec"!==f)throw new Error("No valid signer available");n.id="mock-id-"+Date.now(),n.sig="mock-signature-"+Date.now(),r=n}const o=JSON.stringify(r);return btoa(o)}function Te(e){n(81,T=e),localStorage.setItem("viewAsRole",e),console.log("View as role changed to:",e,"Current effective role:",a)}T=localStorage.getItem("viewAsRole")||"";return e.$$.update=()=>{var t;if(390&e.$$.dirty[0]&&n(35,r=(P&&u&&d?x.filter(e=>e.pubkey&&e.pubkey===d):x).sort((e,t)=>t.created_at-e.created_at)),8&e.$$.dirty[0]&&n(34,o=h?.about?(t=h.about,String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")).replace(/\n{2,}/g,"
"):""),16&e.$$.dirty[0]|524288&e.$$.dirty[2]&&n(10,a=T&&""!==T?T:p),1554&e.$$.dirty[0]|1572864&e.$$.dirty[2]&&n(83,i=pe.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&&!z)&&(("managed-acl"!==e.id||"managed"===W)&&(console.log(`Tab ${e.id} filter check:`,{isLoggedIn:u,userRole:p,viewAsRole:T,currentRole:t,requiresAdmin:e.requiresAdmin,requiresOwner:e.requiresOwner,requiresWrite:e.requiresWrite,visible:!0}),!0)))))})),64&e.$$.dirty[0]|2097152&e.$$.dirty[2]&&n(11,s=[...i,...E]),2578&e.$$.dirty[0]|2097152&e.$$.dirty[2]&&console.log("Tabs debug:",{isLoggedIn:u,userRole:p,aclMode:W,filteredBaseTabs:i.map(e=>e.id),allTabs:s.map(e=>e.id)}),1&e.$$.dirty[0]&&"undefined"!=typeof document&&(l?document.body.classList.add("dark-theme"):document.body.classList.remove("dark-theme")),14&e.$$.dirty[0]&&u&&d&&!h&&be(),438&e.$$.dirty[0]&&"events"===w&&u&&("write"===p||"admin"===p||"owner"===p)&&0===x.length){Se(!0,P&&d?[d]:null)}32&e.$$.dirty[0]&&localStorage.setItem("selectedTab",w)},[l,u,d,h,p,w,E,x,P,W,a,s,c,y,g,v,m,k,S,C,A,U,F,M,D,H,q,K,V,J,G,Z,Y,Q,o,r,$,ee,function(e){return te[e]||`Kind ${e}`},ne,re,oe,ie,se,function(){console.log("selectRecoveryKind called, recoverySelectedKind:",J),null!=J?(n(30,G=""),n(31,Z=[]),X=null,n(33,Q=!0),ie()):console.log("No kind selected, skipping load")},function(){console.log("handleCustomKindInput called, recoveryCustomKind:",G);const e=parseInt(G);""!==G&&!isNaN(e)&&e>=0&&(n(29,J=null),n(31,Z=[]),X=null,n(33,Q=!0),ie())},function(e){const t=Z.filter(t=>t.kind===e.kind&&t.pubkey===e.pubkey),n=Math.max(...t.map(e=>e.created_at));return e.created_at===n},async function(){if(u&&"owner"===p)try{n(24,D=!0);const e=await fetch("/api/sprocket/status",{method:"GET",headers:{Authorization:`Nostr ${await je("GET","/api/sprocket/status")}`,"Content-Type":"application/json"}});if(e.ok){const t=await e.json();n(21,U=t.script_content||""),n(22,F=t),he("Script loaded successfully","success")}else he("Failed to load script","error")}catch(e){he(`Error loading script: ${e.message}`,"error")}finally{n(24,D=!1)}},async function(){if(u&&"owner"===p)try{n(24,D=!0);const e=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await je("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:U});if(e.ok)he("Script saved and updated successfully","success"),await ce(),await ue();else{he(`Failed to save script: ${await e.text()}`,"error")}}catch(e){he(`Error saving script: ${e.message}`,"error")}finally{n(24,D=!1)}},async function(){if(u&&"owner"===p)try{n(24,D=!0);const e=await fetch("/api/sprocket/restart",{method:"POST",headers:{Authorization:`Nostr ${await je("POST","/api/sprocket/restart")}`,"Content-Type":"application/json"}});if(e.ok)he("Sprocket restarted successfully","success"),await ce();else{he(`Failed to restart sprocket: ${await e.text()}`,"error")}}catch(e){he(`Error restarting sprocket: ${e.message}`,"error")}finally{n(24,D=!1)}},async function(){if(u&&"owner"===p&&confirm("Are you sure you want to delete the sprocket script? This will stop the current process."))try{n(24,D=!0);const e=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await je("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:""});if(e.ok)n(21,U=""),he("Sprocket script deleted successfully","success"),await ce(),await ue();else{he(`Failed to delete script: ${await e.text()}`,"error")}}catch(e){he(`Error deleting script: ${e.message}`,"error")}finally{n(24,D=!1)}},ue,de,fe,function(e){n(27,K=e.target.files[0])},async function(){if(u&&"owner"===p&&K)try{n(24,D=!0);const e=await K.text(),t=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await je("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:e});if(t.ok)n(21,U=e),he("Script uploaded and updated successfully","success"),await ce(),await ue();else{he(`Failed to upload script: ${await t.text()}`,"error")}}catch(e){he(`Error uploading script: ${e.message}`,"error")}finally{n(24,D=!1),n(27,K=null);const e=document.getElementById("sprocket-upload-file");e&&(e.value="")}},ye,function(){n(0,l=!l),"undefined"!=typeof localStorage&&localStorage.setItem("isDarkTheme",JSON.stringify(l))},function(){u||n(12,c=!0)},async function(e){const{method:t,pubkey:r,privateKey:o,signer:i}=e.detail;n(1,u=!0),n(2,d=r),f=t,n(13,y=i),n(12,c=!1);try{if(await yh(),"extension"===t&&i)nh.setSigner(i);else if("nsec"===t&&o){const e=new Dd(o);nh.setSigner(e)}n(3,h=await dh(r)),console.log("Profile loaded:",h)}catch(e){console.error("Failed to load profile:",e)}await Ee(),await xe()},function(){n(1,u=!1),n(2,d=""),f="",n(3,h=null),n(4,p=""),n(13,y=null),n(14,g=!1),B=[],n(7,x=[]),I=[],R=0,ae(),"undefined"!=typeof localStorage&&(localStorage.removeItem("nostr_auth_method"),localStorage.removeItem("nostr_pubkey"),localStorage.removeItem("nostr_privkey"))},function(){n(12,c=!1)},function(){n(14,g=!0)},ge,function(){n(15,v=!v),v||n(16,m="")},function(e){"Enter"===e.key&&m.trim()?(!function(e){const t=`search-${Date.now()}`,r={id:t,icon:"🔍",label:e,isSearchTab:!0,query:e};n(6,E=[...E,r]),n(5,w=t),$.set(t,{events:[],isLoading:!1,hasMore:!0,oldestTimestamp:null}),ve(t,e)}(m.trim()),n(16,m=""),n(15,v=!1)):"Escape"===e.key&&(n(15,v=!1),n(16,m=""))},we,ve,me,be,async function(){await ke([])},async function(){await ke([d])},function(e){n(17,k=e.target.files[0])},async function(){if(!u||"admin"!==p&&"owner"!==p)alert("Admin or owner permission required");else if(k)try{const e=await Ae("/api/import","POST"),t=new FormData;t.append("file",k);const r=await fetch("/api/import",{method:"POST",headers:{Authorization:e},body:t});if(!r.ok)throw new Error(`Import failed: ${r.status} ${r.statusText}`);await r.json();alert("Import started successfully"),n(17,k=null),document.getElementById("import-file").value=""}catch(e){console.error("Import failed:",e),alert("Import failed: "+e.message)}else alert("Please select a file")},Se,function(e){const{scrollTop:t,scrollHeight:n,clientHeight:r}=e.target;n-t-r<100&&Ce()},function(){try{if(!V.trim())return void alert("Please enter some JSON to reformat");const e=JSON.parse(V);n(28,V=JSON.stringify(e,null,2))}catch(e){alert("Invalid JSON: "+e.message)}},async function(){try{if(!V.trim())return void alert("Please enter an event to sign");if(!u||!d)return void alert("Please log in to sign events");if(!y)return void alert("No signer available. Please log in with a valid authentication method.");const e=JSON.parse(V);e.pubkey=d,e.created_at=Math.floor(Date.now()/1e3),delete e.id,delete e.sig;const t=await y.signEvent(e);n(28,V=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(){try{if(!V.trim())return void alert("Please enter an event to publish");if(!u)return void alert("Please log in to publish events");if(!y)return void alert("No signer available. Please log in with a valid authentication method.");const e=JSON.parse(V);if(!e.id||!e.sig)return void alert('Event must be signed before publishing. Please click "Sign" first.');const t=`wss://${window.location.host}`,n=await vp(t,e,y,d);n.success?alert("Event published successfully to ORLY relay!"):alert(`Event publishing failed: ${n.reason||"Unknown error"}`)}catch(e){console.error("Error publishing event:",e),alert("Error publishing event: "+e.message)}},Te,function(){const e=["owner","admin","write","read"],t=e.indexOf(p);return-1===t?["read"]:e.slice(t)},T,z,i,function(t){_.call(this,e,t)},function(t){_.call(this,e,t)},e=>e.id===w,function(){m=this.value,n(16,m)},e=>we(e.id),(e,t)=>"Enter"===t.key&&we(e.id),e=>ye(e.id),e=>oe(e.id),e=>ne(e.id),(e,t)=>"Enter"===t.key&&ne(e.id),(e,t)=>ig(e,t),function(){P=this.checked,n(8,P)},()=>re(),()=>{Se(!1,P&&d?[d]:null)},()=>{Se(!0,P&&d?[d]:null)},function(){V=this.value,n(28,V)},function(){U=this.value,n(21,U)},e=>de(e),e=>fe(e.name),function(){J=function(e){const t=e.querySelector(":checked");return t&&t.__value}(this),n(29,J),n(37,ee)},function(){G=b(this.value),n(30,G)},e=>se(e),(e,t)=>ig(e,t),e=>ve(e.id,e.query,!0),e=>oe(e.id),e=>ne(e.id),(e,t)=>"Enter"===t.key&&ne(e.id),(e,t)=>ig(e,t),(e,t)=>me(t,e.id),e=>Te(e===p?"":e),e=>"Escape"===e.key&&ge(),function(e){c=e,n(12,c)}]}return new class extends Q{constructor(e){super(),Y(this,e,ag,tg,i,{},null,[-1,-1,-1,-1,-1,-1])}}({target:document.body,props:{name:"world"}})}(); //# sourceMappingURL=bundle.js.map diff --git a/app/web/dist/bundle.js.map b/app/web/dist/bundle.js.map index c6623f0..d874089 100644 --- a/app/web/dist/bundle.js.map +++ b/app/web/dist/bundle.js.map @@ -1 +1 @@ -{"version":3,"file":"bundle.js","sources":["../node_modules/svelte/internal/index.mjs","../node_modules/@noble/curves/node_modules/@noble/hashes/esm/_assert.js","../node_modules/@noble/curves/node_modules/@noble/hashes/esm/crypto.js","../node_modules/@noble/curves/node_modules/@noble/hashes/esm/utils.js","../node_modules/@noble/curves/node_modules/@noble/hashes/esm/_sha2.js","../node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha256.js","../node_modules/@noble/curves/esm/abstract/utils.js","../node_modules/@noble/curves/esm/abstract/modular.js","../node_modules/@noble/curves/esm/abstract/curve.js","../node_modules/@noble/curves/esm/abstract/weierstrass.js","../node_modules/@noble/curves/node_modules/@noble/hashes/esm/hmac.js","../node_modules/@noble/curves/esm/_shortw_utils.js","../node_modules/@noble/curves/esm/secp256k1.js","../node_modules/nostr-tools/node_modules/@noble/hashes/esm/crypto.js","../node_modules/nostr-tools/node_modules/@noble/hashes/esm/utils.js","../node_modules/nostr-tools/node_modules/@noble/hashes/esm/_assert.js","../node_modules/nostr-tools/node_modules/@noble/hashes/esm/_sha2.js","../node_modules/nostr-tools/node_modules/@noble/hashes/esm/sha256.js","../node_modules/nostr-tools/lib/esm/pool.js","../node_modules/nostr-tools/node_modules/@scure/base/lib/esm/index.js","../node_modules/@noble/ciphers/esm/_assert.js","../node_modules/@noble/ciphers/esm/utils.js","../node_modules/@noble/ciphers/esm/aes.js","../node_modules/@noble/ciphers/esm/_arx.js","../node_modules/@noble/ciphers/esm/chacha.js","../node_modules/nostr-tools/node_modules/@noble/hashes/esm/hmac.js","../node_modules/nostr-tools/node_modules/@noble/hashes/esm/hkdf.js","../node_modules/nostr-tools/lib/esm/index.js","../node_modules/nostr-tools/lib/esm/kinds.js","../node_modules/tslib/tslib.es6.mjs","../node_modules/rxjs/dist/esm5/internal/util/isFunction.js","../node_modules/rxjs/dist/esm5/internal/util/createErrorClass.js","../node_modules/rxjs/dist/esm5/internal/util/UnsubscriptionError.js","../node_modules/rxjs/dist/esm5/internal/util/arrRemove.js","../node_modules/rxjs/dist/esm5/internal/Subscription.js","../node_modules/rxjs/dist/esm5/internal/config.js","../node_modules/rxjs/dist/esm5/internal/scheduler/timeoutProvider.js","../node_modules/rxjs/dist/esm5/internal/util/reportUnhandledError.js","../node_modules/rxjs/dist/esm5/internal/util/noop.js","../node_modules/rxjs/dist/esm5/internal/util/errorContext.js","../node_modules/rxjs/dist/esm5/internal/Subscriber.js","../node_modules/rxjs/dist/esm5/internal/symbol/observable.js","../node_modules/rxjs/dist/esm5/internal/util/identity.js","../node_modules/rxjs/dist/esm5/internal/Observable.js","../node_modules/rxjs/dist/esm5/internal/util/pipe.js","../node_modules/rxjs/dist/esm5/internal/util/lift.js","../node_modules/rxjs/dist/esm5/internal/operators/OperatorSubscriber.js","../node_modules/rxjs/dist/esm5/internal/util/ObjectUnsubscribedError.js","../node_modules/rxjs/dist/esm5/internal/Subject.js","../node_modules/rxjs/dist/esm5/internal/scheduler/dateTimestampProvider.js","../node_modules/rxjs/dist/esm5/internal/ReplaySubject.js","../node_modules/rxjs/dist/esm5/internal/scheduler/Action.js","../node_modules/rxjs/dist/esm5/internal/scheduler/intervalProvider.js","../node_modules/rxjs/dist/esm5/internal/scheduler/AsyncAction.js","../node_modules/rxjs/dist/esm5/internal/Scheduler.js","../node_modules/rxjs/dist/esm5/internal/scheduler/AsyncScheduler.js","../node_modules/rxjs/dist/esm5/internal/scheduler/async.js","../node_modules/rxjs/dist/esm5/internal/observable/empty.js","../node_modules/rxjs/dist/esm5/internal/util/isScheduler.js","../node_modules/rxjs/dist/esm5/internal/util/args.js","../node_modules/rxjs/dist/esm5/internal/util/isArrayLike.js","../node_modules/rxjs/dist/esm5/internal/util/isPromise.js","../node_modules/rxjs/dist/esm5/internal/util/isInteropObservable.js","../node_modules/rxjs/dist/esm5/internal/util/isAsyncIterable.js","../node_modules/rxjs/dist/esm5/internal/util/throwUnobservableError.js","../node_modules/rxjs/dist/esm5/internal/symbol/iterator.js","../node_modules/rxjs/dist/esm5/internal/util/isIterable.js","../node_modules/rxjs/dist/esm5/internal/util/isReadableStreamLike.js","../node_modules/rxjs/dist/esm5/internal/observable/innerFrom.js","../node_modules/rxjs/dist/esm5/internal/util/executeSchedule.js","../node_modules/rxjs/dist/esm5/internal/operators/observeOn.js","../node_modules/rxjs/dist/esm5/internal/operators/subscribeOn.js","../node_modules/rxjs/dist/esm5/internal/scheduled/scheduleAsyncIterable.js","../node_modules/rxjs/dist/esm5/internal/scheduled/scheduled.js","../node_modules/rxjs/dist/esm5/internal/scheduled/scheduleObservable.js","../node_modules/rxjs/dist/esm5/internal/scheduled/scheduleArray.js","../node_modules/rxjs/dist/esm5/internal/scheduled/schedulePromise.js","../node_modules/rxjs/dist/esm5/internal/scheduled/scheduleIterable.js","../node_modules/rxjs/dist/esm5/internal/scheduled/scheduleReadableStreamLike.js","../node_modules/rxjs/dist/esm5/internal/observable/from.js","../node_modules/rxjs/dist/esm5/internal/observable/of.js","../node_modules/rxjs/dist/esm5/internal/operators/map.js","../node_modules/rxjs/dist/esm5/internal/util/mapOneOrManyArgs.js","../node_modules/rxjs/dist/esm5/internal/util/argsArgArrayOrObject.js","../node_modules/rxjs/dist/esm5/internal/observable/combineLatest.js","../node_modules/rxjs/dist/esm5/internal/util/createObject.js","../node_modules/rxjs/dist/esm5/internal/operators/mergeMap.js","../node_modules/rxjs/dist/esm5/internal/operators/mergeInternals.js","../node_modules/rxjs/dist/esm5/internal/operators/mergeAll.js","../node_modules/rxjs/dist/esm5/internal/observable/concat.js","../node_modules/rxjs/dist/esm5/internal/operators/concatAll.js","../node_modules/rxjs/dist/esm5/internal/observable/defer.js","../node_modules/rxjs/dist/esm5/internal/observable/timer.js","../node_modules/rxjs/dist/esm5/internal/util/isDate.js","../node_modules/rxjs/dist/esm5/internal/observable/merge.js","../node_modules/rxjs/dist/esm5/internal/operators/filter.js","../node_modules/rxjs/dist/esm5/internal/operators/take.js","../node_modules/rxjs/dist/esm5/internal/operators/distinctUntilChanged.js","../node_modules/rxjs/dist/esm5/internal/operators/endWith.js","../node_modules/rxjs/dist/esm5/internal/operators/finalize.js","../node_modules/rxjs/dist/esm5/internal/operators/merge.js","../node_modules/rxjs/dist/esm5/internal/operators/mergeWith.js","../node_modules/rxjs/dist/esm5/internal/operators/scan.js","../node_modules/rxjs/dist/esm5/internal/operators/scanInternals.js","../node_modules/rxjs/dist/esm5/internal/operators/share.js","../node_modules/rxjs/dist/esm5/internal/operators/switchMap.js","../node_modules/rxjs/dist/esm5/internal/operators/tap.js","../node_modules/applesauce-core/dist/helpers/tags.js","../node_modules/applesauce-core/dist/helpers/cache.js","../node_modules/nostr-tools/lib/esm/utils.js","../node_modules/applesauce-core/dist/helpers/event.js","../node_modules/applesauce-core/dist/helpers/time.js","../node_modules/applesauce-core/dist/helpers/expiration.js","../node_modules/applesauce-core/dist/helpers/url.js","../node_modules/applesauce-core/dist/helpers/relays.js","../node_modules/applesauce-core/dist/helpers/string.js","../node_modules/applesauce-core/node_modules/@noble/hashes/esm/utils.js","../node_modules/applesauce-core/dist/helpers/pointers.js","../node_modules/applesauce-core/dist/helpers/groups.js","../node_modules/applesauce-core/dist/helpers/encrypted-content.js","../node_modules/applesauce-core/dist/helpers/hidden-content.js","../node_modules/applesauce-core/dist/helpers/hidden-tags.js","../node_modules/applesauce-core/dist/helpers/event-tags.js","../node_modules/applesauce-core/dist/helpers/lru.js","../node_modules/ms/index.js","../node_modules/debug/src/common.js","../node_modules/debug/src/browser.js","../node_modules/applesauce-core/dist/logger.js","../node_modules/applesauce-core/dist/event-store/event-memory.js","../node_modules/hash-sum/hash-sum.js","../node_modules/applesauce-core/dist/helpers/filter.js","../node_modules/applesauce-core/dist/models/blossom.js","../node_modules/applesauce-core/dist/helpers/blossom.js","../node_modules/applesauce-core/dist/helpers/profile.js","../node_modules/applesauce-core/dist/helpers/json.js","../node_modules/light-bolt11-decoder/node_modules/@scure/base/lib/index.js","../node_modules/light-bolt11-decoder/bolt11.js","../node_modules/applesauce-core/dist/helpers/comment.js","../node_modules/applesauce-core/dist/helpers/contacts.js","../node_modules/applesauce-core/dist/helpers/encrypted-content-cache.js","../node_modules/applesauce-core/dist/helpers/event-cache.js","../node_modules/applesauce-core/dist/helpers/lnurl.js","../node_modules/applesauce-core/dist/helpers/mailboxes.js","../node_modules/applesauce-core/dist/helpers/mutes.js","../node_modules/applesauce-core/dist/helpers/reports.js","../node_modules/applesauce-core/dist/helpers/threading.js","../node_modules/applesauce-core/dist/observable/claim-events.js","../node_modules/applesauce-core/dist/observable/claim-latest.js","../node_modules/applesauce-core/dist/observable/defined.js","../node_modules/applesauce-core/dist/observable/with-immediate-value.js","../node_modules/applesauce-core/dist/models/common.js","../node_modules/rxjs/dist/esm5/internal/operators/ignoreElements.js","../node_modules/rxjs/dist/esm5/internal/operators/takeUntil.js","../node_modules/rxjs/dist/esm5/internal/operators/repeat.js","../node_modules/applesauce-core/dist/observable/watch-event-updates.js","../node_modules/applesauce-core/dist/models/contacts.js","../node_modules/applesauce-core/dist/models/comments.js","../node_modules/applesauce-core/dist/models/mailboxes.js","../node_modules/applesauce-core/dist/models/mutes.js","../node_modules/applesauce-core/dist/models/profile.js","../node_modules/applesauce-core/dist/models/reactions.js","../node_modules/applesauce-core/dist/models/thread.js","../node_modules/applesauce-core/dist/event-store/model-mixin.js","../node_modules/applesauce-core/dist/event-store/event-store.js","../node_modules/applesauce-core/dist/helpers/delete.js","../node_modules/applesauce-core/dist/promise/deferred.js","../node_modules/applesauce-signers/dist/signers/amber-clipboard-signer.js","../node_modules/applesauce-signers/dist/helpers/nostr-connect.js","../node_modules/applesauce-signers/dist/signers/private-key-signer.js","../node_modules/applesauce-signers/node_modules/@noble/hashes/esm/crypto.js","../node_modules/applesauce-signers/node_modules/@noble/hashes/esm/utils.js","../node_modules/applesauce-signers/node_modules/@noble/secp256k1/lib/esm/index.js","../node_modules/applesauce-signers/node_modules/@scure/base/lib/esm/index.js","../node_modules/applesauce-signers/dist/signers/serial-port-signer.js","../src/constants.js","../src/nostr.js","../src/LoginModal.svelte","../src/ManagedACL.svelte","../src/websocket-auth.js","../src/App.svelte","../src/main.js"],"sourcesContent":["function noop() { }\nconst identity = x => x;\nfunction assign(tar, src) {\n // @ts-ignore\n for (const k in src)\n tar[k] = src[k];\n return tar;\n}\n// Adapted from https://github.com/then/is-promise/blob/master/index.js\n// Distributed under MIT License https://github.com/then/is-promise/blob/master/LICENSE\nfunction is_promise(value) {\n return !!value && (typeof value === 'object' || typeof value === 'function') && typeof value.then === 'function';\n}\nfunction add_location(element, file, line, column, char) {\n element.__svelte_meta = {\n loc: { file, line, column, char }\n };\n}\nfunction run(fn) {\n return fn();\n}\nfunction blank_object() {\n return Object.create(null);\n}\nfunction run_all(fns) {\n fns.forEach(run);\n}\nfunction is_function(thing) {\n return typeof thing === 'function';\n}\nfunction safe_not_equal(a, b) {\n return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');\n}\nlet src_url_equal_anchor;\nfunction src_url_equal(element_src, url) {\n if (!src_url_equal_anchor) {\n src_url_equal_anchor = document.createElement('a');\n }\n src_url_equal_anchor.href = url;\n return element_src === src_url_equal_anchor.href;\n}\nfunction not_equal(a, b) {\n return a != a ? b == b : a !== b;\n}\nfunction is_empty(obj) {\n return Object.keys(obj).length === 0;\n}\nfunction validate_store(store, name) {\n if (store != null && typeof store.subscribe !== 'function') {\n throw new Error(`'${name}' is not a store with a 'subscribe' method`);\n }\n}\nfunction subscribe(store, ...callbacks) {\n if (store == null) {\n return noop;\n }\n const unsub = store.subscribe(...callbacks);\n return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;\n}\nfunction get_store_value(store) {\n let value;\n subscribe(store, _ => value = _)();\n return value;\n}\nfunction component_subscribe(component, store, callback) {\n component.$$.on_destroy.push(subscribe(store, callback));\n}\nfunction create_slot(definition, ctx, $$scope, fn) {\n if (definition) {\n const slot_ctx = get_slot_context(definition, ctx, $$scope, fn);\n return definition[0](slot_ctx);\n }\n}\nfunction get_slot_context(definition, ctx, $$scope, fn) {\n return definition[1] && fn\n ? assign($$scope.ctx.slice(), definition[1](fn(ctx)))\n : $$scope.ctx;\n}\nfunction get_slot_changes(definition, $$scope, dirty, fn) {\n if (definition[2] && fn) {\n const lets = definition[2](fn(dirty));\n if ($$scope.dirty === undefined) {\n return lets;\n }\n if (typeof lets === 'object') {\n const merged = [];\n const len = Math.max($$scope.dirty.length, lets.length);\n for (let i = 0; i < len; i += 1) {\n merged[i] = $$scope.dirty[i] | lets[i];\n }\n return merged;\n }\n return $$scope.dirty | lets;\n }\n return $$scope.dirty;\n}\nfunction update_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn) {\n if (slot_changes) {\n const slot_context = get_slot_context(slot_definition, ctx, $$scope, get_slot_context_fn);\n slot.p(slot_context, slot_changes);\n }\n}\nfunction update_slot(slot, slot_definition, ctx, $$scope, dirty, get_slot_changes_fn, get_slot_context_fn) {\n const slot_changes = get_slot_changes(slot_definition, $$scope, dirty, get_slot_changes_fn);\n update_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn);\n}\nfunction get_all_dirty_from_scope($$scope) {\n if ($$scope.ctx.length > 32) {\n const dirty = [];\n const length = $$scope.ctx.length / 32;\n for (let i = 0; i < length; i++) {\n dirty[i] = -1;\n }\n return dirty;\n }\n return -1;\n}\nfunction exclude_internal_props(props) {\n const result = {};\n for (const k in props)\n if (k[0] !== '$')\n result[k] = props[k];\n return result;\n}\nfunction compute_rest_props(props, keys) {\n const rest = {};\n keys = new Set(keys);\n for (const k in props)\n if (!keys.has(k) && k[0] !== '$')\n rest[k] = props[k];\n return rest;\n}\nfunction compute_slots(slots) {\n const result = {};\n for (const key in slots) {\n result[key] = true;\n }\n return result;\n}\nfunction once(fn) {\n let ran = false;\n return function (...args) {\n if (ran)\n return;\n ran = true;\n fn.call(this, ...args);\n };\n}\nfunction null_to_empty(value) {\n return value == null ? '' : value;\n}\nfunction set_store_value(store, ret, value) {\n store.set(value);\n return ret;\n}\nconst has_prop = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);\nfunction action_destroyer(action_result) {\n return action_result && is_function(action_result.destroy) ? action_result.destroy : noop;\n}\nfunction split_css_unit(value) {\n const split = typeof value === 'string' && value.match(/^\\s*(-?[\\d.]+)([^\\s]*)\\s*$/);\n return split ? [parseFloat(split[1]), split[2] || 'px'] : [value, 'px'];\n}\nconst contenteditable_truthy_values = ['', true, 1, 'true', 'contenteditable'];\n\nconst is_client = typeof window !== 'undefined';\nlet now = is_client\n ? () => window.performance.now()\n : () => Date.now();\nlet raf = is_client ? cb => requestAnimationFrame(cb) : noop;\n// used internally for testing\nfunction set_now(fn) {\n now = fn;\n}\nfunction set_raf(fn) {\n raf = fn;\n}\n\nconst tasks = new Set();\nfunction run_tasks(now) {\n tasks.forEach(task => {\n if (!task.c(now)) {\n tasks.delete(task);\n task.f();\n }\n });\n if (tasks.size !== 0)\n raf(run_tasks);\n}\n/**\n * For testing purposes only!\n */\nfunction clear_loops() {\n tasks.clear();\n}\n/**\n * Creates a new task that runs on each raf frame\n * until it returns a falsy value or is aborted\n */\nfunction loop(callback) {\n let task;\n if (tasks.size === 0)\n raf(run_tasks);\n return {\n promise: new Promise(fulfill => {\n tasks.add(task = { c: callback, f: fulfill });\n }),\n abort() {\n tasks.delete(task);\n }\n };\n}\n\nconst globals = (typeof window !== 'undefined'\n ? window\n : typeof globalThis !== 'undefined'\n ? globalThis\n : global);\n\n/**\n * Resize observer singleton.\n * One listener per element only!\n * https://groups.google.com/a/chromium.org/g/blink-dev/c/z6ienONUb5A/m/F5-VcUZtBAAJ\n */\nclass ResizeObserverSingleton {\n constructor(options) {\n this.options = options;\n this._listeners = 'WeakMap' in globals ? new WeakMap() : undefined;\n }\n observe(element, listener) {\n this._listeners.set(element, listener);\n this._getObserver().observe(element, this.options);\n return () => {\n this._listeners.delete(element);\n this._observer.unobserve(element); // this line can probably be removed\n };\n }\n _getObserver() {\n var _a;\n return (_a = this._observer) !== null && _a !== void 0 ? _a : (this._observer = new ResizeObserver((entries) => {\n var _a;\n for (const entry of entries) {\n ResizeObserverSingleton.entries.set(entry.target, entry);\n (_a = this._listeners.get(entry.target)) === null || _a === void 0 ? void 0 : _a(entry);\n }\n }));\n }\n}\n// Needs to be written like this to pass the tree-shake-test\nResizeObserverSingleton.entries = 'WeakMap' in globals ? new WeakMap() : undefined;\n\n// Track which nodes are claimed during hydration. Unclaimed nodes can then be removed from the DOM\n// at the end of hydration without touching the remaining nodes.\nlet is_hydrating = false;\nfunction start_hydrating() {\n is_hydrating = true;\n}\nfunction end_hydrating() {\n is_hydrating = false;\n}\nfunction upper_bound(low, high, key, value) {\n // Return first index of value larger than input value in the range [low, high)\n while (low < high) {\n const mid = low + ((high - low) >> 1);\n if (key(mid) <= value) {\n low = mid + 1;\n }\n else {\n high = mid;\n }\n }\n return low;\n}\nfunction init_hydrate(target) {\n if (target.hydrate_init)\n return;\n target.hydrate_init = true;\n // We know that all children have claim_order values since the unclaimed have been detached if target is not \n let children = target.childNodes;\n // If target is , there may be children without claim_order\n if (target.nodeName === 'HEAD') {\n const myChildren = [];\n for (let i = 0; i < children.length; i++) {\n const node = children[i];\n if (node.claim_order !== undefined) {\n myChildren.push(node);\n }\n }\n children = myChildren;\n }\n /*\n * Reorder claimed children optimally.\n * We can reorder claimed children optimally by finding the longest subsequence of\n * nodes that are already claimed in order and only moving the rest. The longest\n * subsequence of nodes that are claimed in order can be found by\n * computing the longest increasing subsequence of .claim_order values.\n *\n * This algorithm is optimal in generating the least amount of reorder operations\n * possible.\n *\n * Proof:\n * We know that, given a set of reordering operations, the nodes that do not move\n * always form an increasing subsequence, since they do not move among each other\n * meaning that they must be already ordered among each other. Thus, the maximal\n * set of nodes that do not move form a longest increasing subsequence.\n */\n // Compute longest increasing subsequence\n // m: subsequence length j => index k of smallest value that ends an increasing subsequence of length j\n const m = new Int32Array(children.length + 1);\n // Predecessor indices + 1\n const p = new Int32Array(children.length);\n m[0] = -1;\n let longest = 0;\n for (let i = 0; i < children.length; i++) {\n const current = children[i].claim_order;\n // Find the largest subsequence length such that it ends in a value less than our current value\n // upper_bound returns first greater value, so we subtract one\n // with fast path for when we are on the current longest subsequence\n const seqLen = ((longest > 0 && children[m[longest]].claim_order <= current) ? longest + 1 : upper_bound(1, longest, idx => children[m[idx]].claim_order, current)) - 1;\n p[i] = m[seqLen] + 1;\n const newLen = seqLen + 1;\n // We can guarantee that current is the smallest value. Otherwise, we would have generated a longer sequence.\n m[newLen] = i;\n longest = Math.max(newLen, longest);\n }\n // The longest increasing subsequence of nodes (initially reversed)\n const lis = [];\n // The rest of the nodes, nodes that will be moved\n const toMove = [];\n let last = children.length - 1;\n for (let cur = m[longest] + 1; cur != 0; cur = p[cur - 1]) {\n lis.push(children[cur - 1]);\n for (; last >= cur; last--) {\n toMove.push(children[last]);\n }\n last--;\n }\n for (; last >= 0; last--) {\n toMove.push(children[last]);\n }\n lis.reverse();\n // We sort the nodes being moved to guarantee that their insertion order matches the claim order\n toMove.sort((a, b) => a.claim_order - b.claim_order);\n // Finally, we move the nodes\n for (let i = 0, j = 0; i < toMove.length; i++) {\n while (j < lis.length && toMove[i].claim_order >= lis[j].claim_order) {\n j++;\n }\n const anchor = j < lis.length ? lis[j] : null;\n target.insertBefore(toMove[i], anchor);\n }\n}\nfunction append(target, node) {\n target.appendChild(node);\n}\nfunction append_styles(target, style_sheet_id, styles) {\n const append_styles_to = get_root_for_style(target);\n if (!append_styles_to.getElementById(style_sheet_id)) {\n const style = element('style');\n style.id = style_sheet_id;\n style.textContent = styles;\n append_stylesheet(append_styles_to, style);\n }\n}\nfunction get_root_for_style(node) {\n if (!node)\n return document;\n const root = node.getRootNode ? node.getRootNode() : node.ownerDocument;\n if (root && root.host) {\n return root;\n }\n return node.ownerDocument;\n}\nfunction append_empty_stylesheet(node) {\n const style_element = element('style');\n append_stylesheet(get_root_for_style(node), style_element);\n return style_element.sheet;\n}\nfunction append_stylesheet(node, style) {\n append(node.head || node, style);\n return style.sheet;\n}\nfunction append_hydration(target, node) {\n if (is_hydrating) {\n init_hydrate(target);\n if ((target.actual_end_child === undefined) || ((target.actual_end_child !== null) && (target.actual_end_child.parentNode !== target))) {\n target.actual_end_child = target.firstChild;\n }\n // Skip nodes of undefined ordering\n while ((target.actual_end_child !== null) && (target.actual_end_child.claim_order === undefined)) {\n target.actual_end_child = target.actual_end_child.nextSibling;\n }\n if (node !== target.actual_end_child) {\n // We only insert if the ordering of this node should be modified or the parent node is not target\n if (node.claim_order !== undefined || node.parentNode !== target) {\n target.insertBefore(node, target.actual_end_child);\n }\n }\n else {\n target.actual_end_child = node.nextSibling;\n }\n }\n else if (node.parentNode !== target || node.nextSibling !== null) {\n target.appendChild(node);\n }\n}\nfunction insert(target, node, anchor) {\n target.insertBefore(node, anchor || null);\n}\nfunction insert_hydration(target, node, anchor) {\n if (is_hydrating && !anchor) {\n append_hydration(target, node);\n }\n else if (node.parentNode !== target || node.nextSibling != anchor) {\n target.insertBefore(node, anchor || null);\n }\n}\nfunction detach(node) {\n if (node.parentNode) {\n node.parentNode.removeChild(node);\n }\n}\nfunction destroy_each(iterations, detaching) {\n for (let i = 0; i < iterations.length; i += 1) {\n if (iterations[i])\n iterations[i].d(detaching);\n }\n}\nfunction element(name) {\n return document.createElement(name);\n}\nfunction element_is(name, is) {\n return document.createElement(name, { is });\n}\nfunction object_without_properties(obj, exclude) {\n const target = {};\n for (const k in obj) {\n if (has_prop(obj, k)\n // @ts-ignore\n && exclude.indexOf(k) === -1) {\n // @ts-ignore\n target[k] = obj[k];\n }\n }\n return target;\n}\nfunction svg_element(name) {\n return document.createElementNS('http://www.w3.org/2000/svg', name);\n}\nfunction text(data) {\n return document.createTextNode(data);\n}\nfunction space() {\n return text(' ');\n}\nfunction empty() {\n return text('');\n}\nfunction comment(content) {\n return document.createComment(content);\n}\nfunction listen(node, event, handler, options) {\n node.addEventListener(event, handler, options);\n return () => node.removeEventListener(event, handler, options);\n}\nfunction prevent_default(fn) {\n return function (event) {\n event.preventDefault();\n // @ts-ignore\n return fn.call(this, event);\n };\n}\nfunction stop_propagation(fn) {\n return function (event) {\n event.stopPropagation();\n // @ts-ignore\n return fn.call(this, event);\n };\n}\nfunction stop_immediate_propagation(fn) {\n return function (event) {\n event.stopImmediatePropagation();\n // @ts-ignore\n return fn.call(this, event);\n };\n}\nfunction self(fn) {\n return function (event) {\n // @ts-ignore\n if (event.target === this)\n fn.call(this, event);\n };\n}\nfunction trusted(fn) {\n return function (event) {\n // @ts-ignore\n if (event.isTrusted)\n fn.call(this, event);\n };\n}\nfunction attr(node, attribute, value) {\n if (value == null)\n node.removeAttribute(attribute);\n else if (node.getAttribute(attribute) !== value)\n node.setAttribute(attribute, value);\n}\n/**\n * List of attributes that should always be set through the attr method,\n * because updating them through the property setter doesn't work reliably.\n * In the example of `width`/`height`, the problem is that the setter only\n * accepts numeric values, but the attribute can also be set to a string like `50%`.\n * If this list becomes too big, rethink this approach.\n */\nconst always_set_through_set_attribute = ['width', 'height'];\nfunction set_attributes(node, attributes) {\n // @ts-ignore\n const descriptors = Object.getOwnPropertyDescriptors(node.__proto__);\n for (const key in attributes) {\n if (attributes[key] == null) {\n node.removeAttribute(key);\n }\n else if (key === 'style') {\n node.style.cssText = attributes[key];\n }\n else if (key === '__value') {\n node.value = node[key] = attributes[key];\n }\n else if (descriptors[key] && descriptors[key].set && always_set_through_set_attribute.indexOf(key) === -1) {\n node[key] = attributes[key];\n }\n else {\n attr(node, key, attributes[key]);\n }\n }\n}\nfunction set_svg_attributes(node, attributes) {\n for (const key in attributes) {\n attr(node, key, attributes[key]);\n }\n}\nfunction set_custom_element_data_map(node, data_map) {\n Object.keys(data_map).forEach((key) => {\n set_custom_element_data(node, key, data_map[key]);\n });\n}\nfunction set_custom_element_data(node, prop, value) {\n if (prop in node) {\n node[prop] = typeof node[prop] === 'boolean' && value === '' ? true : value;\n }\n else {\n attr(node, prop, value);\n }\n}\nfunction set_dynamic_element_data(tag) {\n return (/-/.test(tag)) ? set_custom_element_data_map : set_attributes;\n}\nfunction xlink_attr(node, attribute, value) {\n node.setAttributeNS('http://www.w3.org/1999/xlink', attribute, value);\n}\nfunction get_binding_group_value(group, __value, checked) {\n const value = new Set();\n for (let i = 0; i < group.length; i += 1) {\n if (group[i].checked)\n value.add(group[i].__value);\n }\n if (!checked) {\n value.delete(__value);\n }\n return Array.from(value);\n}\nfunction init_binding_group(group) {\n let _inputs;\n return {\n /* push */ p(...inputs) {\n _inputs = inputs;\n _inputs.forEach(input => group.push(input));\n },\n /* remove */ r() {\n _inputs.forEach(input => group.splice(group.indexOf(input), 1));\n }\n };\n}\nfunction init_binding_group_dynamic(group, indexes) {\n let _group = get_binding_group(group);\n let _inputs;\n function get_binding_group(group) {\n for (let i = 0; i < indexes.length; i++) {\n group = group[indexes[i]] = group[indexes[i]] || [];\n }\n return group;\n }\n function push() {\n _inputs.forEach(input => _group.push(input));\n }\n function remove() {\n _inputs.forEach(input => _group.splice(_group.indexOf(input), 1));\n }\n return {\n /* update */ u(new_indexes) {\n indexes = new_indexes;\n const new_group = get_binding_group(group);\n if (new_group !== _group) {\n remove();\n _group = new_group;\n push();\n }\n },\n /* push */ p(...inputs) {\n _inputs = inputs;\n push();\n },\n /* remove */ r: remove\n };\n}\nfunction to_number(value) {\n return value === '' ? null : +value;\n}\nfunction time_ranges_to_array(ranges) {\n const array = [];\n for (let i = 0; i < ranges.length; i += 1) {\n array.push({ start: ranges.start(i), end: ranges.end(i) });\n }\n return array;\n}\nfunction children(element) {\n return Array.from(element.childNodes);\n}\nfunction init_claim_info(nodes) {\n if (nodes.claim_info === undefined) {\n nodes.claim_info = { last_index: 0, total_claimed: 0 };\n }\n}\nfunction claim_node(nodes, predicate, processNode, createNode, dontUpdateLastIndex = false) {\n // Try to find nodes in an order such that we lengthen the longest increasing subsequence\n init_claim_info(nodes);\n const resultNode = (() => {\n // We first try to find an element after the previous one\n for (let i = nodes.claim_info.last_index; i < nodes.length; i++) {\n const node = nodes[i];\n if (predicate(node)) {\n const replacement = processNode(node);\n if (replacement === undefined) {\n nodes.splice(i, 1);\n }\n else {\n nodes[i] = replacement;\n }\n if (!dontUpdateLastIndex) {\n nodes.claim_info.last_index = i;\n }\n return node;\n }\n }\n // Otherwise, we try to find one before\n // We iterate in reverse so that we don't go too far back\n for (let i = nodes.claim_info.last_index - 1; i >= 0; i--) {\n const node = nodes[i];\n if (predicate(node)) {\n const replacement = processNode(node);\n if (replacement === undefined) {\n nodes.splice(i, 1);\n }\n else {\n nodes[i] = replacement;\n }\n if (!dontUpdateLastIndex) {\n nodes.claim_info.last_index = i;\n }\n else if (replacement === undefined) {\n // Since we spliced before the last_index, we decrease it\n nodes.claim_info.last_index--;\n }\n return node;\n }\n }\n // If we can't find any matching node, we create a new one\n return createNode();\n })();\n resultNode.claim_order = nodes.claim_info.total_claimed;\n nodes.claim_info.total_claimed += 1;\n return resultNode;\n}\nfunction claim_element_base(nodes, name, attributes, create_element) {\n return claim_node(nodes, (node) => node.nodeName === name, (node) => {\n const remove = [];\n for (let j = 0; j < node.attributes.length; j++) {\n const attribute = node.attributes[j];\n if (!attributes[attribute.name]) {\n remove.push(attribute.name);\n }\n }\n remove.forEach(v => node.removeAttribute(v));\n return undefined;\n }, () => create_element(name));\n}\nfunction claim_element(nodes, name, attributes) {\n return claim_element_base(nodes, name, attributes, element);\n}\nfunction claim_svg_element(nodes, name, attributes) {\n return claim_element_base(nodes, name, attributes, svg_element);\n}\nfunction claim_text(nodes, data) {\n return claim_node(nodes, (node) => node.nodeType === 3, (node) => {\n const dataStr = '' + data;\n if (node.data.startsWith(dataStr)) {\n if (node.data.length !== dataStr.length) {\n return node.splitText(dataStr.length);\n }\n }\n else {\n node.data = dataStr;\n }\n }, () => text(data), true // Text nodes should not update last index since it is likely not worth it to eliminate an increasing subsequence of actual elements\n );\n}\nfunction claim_space(nodes) {\n return claim_text(nodes, ' ');\n}\nfunction claim_comment(nodes, data) {\n return claim_node(nodes, (node) => node.nodeType === 8, (node) => {\n node.data = '' + data;\n return undefined;\n }, () => comment(data), true);\n}\nfunction find_comment(nodes, text, start) {\n for (let i = start; i < nodes.length; i += 1) {\n const node = nodes[i];\n if (node.nodeType === 8 /* comment node */ && node.textContent.trim() === text) {\n return i;\n }\n }\n return nodes.length;\n}\nfunction claim_html_tag(nodes, is_svg) {\n // find html opening tag\n const start_index = find_comment(nodes, 'HTML_TAG_START', 0);\n const end_index = find_comment(nodes, 'HTML_TAG_END', start_index);\n if (start_index === end_index) {\n return new HtmlTagHydration(undefined, is_svg);\n }\n init_claim_info(nodes);\n const html_tag_nodes = nodes.splice(start_index, end_index - start_index + 1);\n detach(html_tag_nodes[0]);\n detach(html_tag_nodes[html_tag_nodes.length - 1]);\n const claimed_nodes = html_tag_nodes.slice(1, html_tag_nodes.length - 1);\n for (const n of claimed_nodes) {\n n.claim_order = nodes.claim_info.total_claimed;\n nodes.claim_info.total_claimed += 1;\n }\n return new HtmlTagHydration(claimed_nodes, is_svg);\n}\nfunction set_data(text, data) {\n data = '' + data;\n if (text.data === data)\n return;\n text.data = data;\n}\nfunction set_data_contenteditable(text, data) {\n data = '' + data;\n if (text.wholeText === data)\n return;\n text.data = data;\n}\nfunction set_data_maybe_contenteditable(text, data, attr_value) {\n if (~contenteditable_truthy_values.indexOf(attr_value)) {\n set_data_contenteditable(text, data);\n }\n else {\n set_data(text, data);\n }\n}\nfunction set_input_value(input, value) {\n input.value = value == null ? '' : value;\n}\nfunction set_input_type(input, type) {\n try {\n input.type = type;\n }\n catch (e) {\n // do nothing\n }\n}\nfunction set_style(node, key, value, important) {\n if (value == null) {\n node.style.removeProperty(key);\n }\n else {\n node.style.setProperty(key, value, important ? 'important' : '');\n }\n}\nfunction select_option(select, value, mounting) {\n for (let i = 0; i < select.options.length; i += 1) {\n const option = select.options[i];\n if (option.__value === value) {\n option.selected = true;\n return;\n }\n }\n if (!mounting || value !== undefined) {\n select.selectedIndex = -1; // no option should be selected\n }\n}\nfunction select_options(select, value) {\n for (let i = 0; i < select.options.length; i += 1) {\n const option = select.options[i];\n option.selected = ~value.indexOf(option.__value);\n }\n}\nfunction select_value(select) {\n const selected_option = select.querySelector(':checked');\n return selected_option && selected_option.__value;\n}\nfunction select_multiple_value(select) {\n return [].map.call(select.querySelectorAll(':checked'), option => option.__value);\n}\n// unfortunately this can't be a constant as that wouldn't be tree-shakeable\n// so we cache the result instead\nlet crossorigin;\nfunction is_crossorigin() {\n if (crossorigin === undefined) {\n crossorigin = false;\n try {\n if (typeof window !== 'undefined' && window.parent) {\n void window.parent.document;\n }\n }\n catch (error) {\n crossorigin = true;\n }\n }\n return crossorigin;\n}\nfunction add_iframe_resize_listener(node, fn) {\n const computed_style = getComputedStyle(node);\n if (computed_style.position === 'static') {\n node.style.position = 'relative';\n }\n const iframe = element('iframe');\n iframe.setAttribute('style', 'display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; ' +\n 'overflow: hidden; border: 0; opacity: 0; pointer-events: none; z-index: -1;');\n iframe.setAttribute('aria-hidden', 'true');\n iframe.tabIndex = -1;\n const crossorigin = is_crossorigin();\n let unsubscribe;\n if (crossorigin) {\n iframe.src = \"data:text/html,\";\n unsubscribe = listen(window, 'message', (event) => {\n if (event.source === iframe.contentWindow)\n fn();\n });\n }\n else {\n iframe.src = 'about:blank';\n iframe.onload = () => {\n unsubscribe = listen(iframe.contentWindow, 'resize', fn);\n // make sure an initial resize event is fired _after_ the iframe is loaded (which is asynchronous)\n // see https://github.com/sveltejs/svelte/issues/4233\n fn();\n };\n }\n append(node, iframe);\n return () => {\n if (crossorigin) {\n unsubscribe();\n }\n else if (unsubscribe && iframe.contentWindow) {\n unsubscribe();\n }\n detach(iframe);\n };\n}\nconst resize_observer_content_box = /* @__PURE__ */ new ResizeObserverSingleton({ box: 'content-box' });\nconst resize_observer_border_box = /* @__PURE__ */ new ResizeObserverSingleton({ box: 'border-box' });\nconst resize_observer_device_pixel_content_box = /* @__PURE__ */ new ResizeObserverSingleton({ box: 'device-pixel-content-box' });\nfunction toggle_class(element, name, toggle) {\n element.classList[toggle ? 'add' : 'remove'](name);\n}\nfunction custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {\n const e = document.createEvent('CustomEvent');\n e.initCustomEvent(type, bubbles, cancelable, detail);\n return e;\n}\nfunction query_selector_all(selector, parent = document.body) {\n return Array.from(parent.querySelectorAll(selector));\n}\nfunction head_selector(nodeId, head) {\n const result = [];\n let started = 0;\n for (const node of head.childNodes) {\n if (node.nodeType === 8 /* comment node */) {\n const comment = node.textContent.trim();\n if (comment === `HEAD_${nodeId}_END`) {\n started -= 1;\n result.push(node);\n }\n else if (comment === `HEAD_${nodeId}_START`) {\n started += 1;\n result.push(node);\n }\n }\n else if (started > 0) {\n result.push(node);\n }\n }\n return result;\n}\nclass HtmlTag {\n constructor(is_svg = false) {\n this.is_svg = false;\n this.is_svg = is_svg;\n this.e = this.n = null;\n }\n c(html) {\n this.h(html);\n }\n m(html, target, anchor = null) {\n if (!this.e) {\n if (this.is_svg)\n this.e = svg_element(target.nodeName);\n /** #7364 target for