a===W,isOdd:a=>(a&j)===j,neg:a=>K(-a,e),eql:(a,c)=>a===c,sqr:a=>K(a*a,e),add:(a,c)=>K(a+c,e),sub:(a,c)=>K(a-c,e),mul:(a,c)=>K(a*c,e),pow:(a,c)=>_a(l,a,c),div:(a,c)=>K(a*Cr(c,e),e),sqrN:a=>a*a,addN:(a,c)=>a+c,subN:(a,c)=>a-c,mulN:(a,c)=>a*c,inv:a=>Cr(a,e),sqrt:n.sqrt||(a=>s(l,a)),invertBatch:a=>$a(l,a),cmov:(a,c,u)=>u?c:a,toBytes:a=>r?Xr(a,i):Tt(a,i),fromBytes:a=>{if(a.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${a.length}`);return r?Yr(a):X(a)}});return Object.freeze(l)}function Lo(e){if(typeof e!="bigint")throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function Uo(e){const t=Lo(e);return t+Math.ceil(t/2)}function Sa(e,t,r=!1){const n=e.length,o=Lo(t),i=Uo(t);if(n<16||n1024)throw new Error(`expected ${i}-1024 bytes of input, got ${n}`);const s=r?X(e):Yr(e),l=K(s,t-j)+j;return r?Xr(l,o):Tt(l,o)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ka=BigInt(0),hr=BigInt(1);function Pa(e,t){const r=(o,i)=>{const s=i.negate();return o?s:i},n=o=>{const i=Math.ceil(t/o)+1,s=2**(o-1);return{windows:i,windowSize:s}};return{constTimeNegate:r,unsafeLadder(o,i){let s=e.ZERO,l=o;for(;i>ka;)i&hr&&(s=s.add(l)),l=l.double(),i>>=hr;return s},precomputeWindow(o,i){const{windows:s,windowSize:l}=n(i),a=[];let c=o,u=c;for(let d=0;d>=g,f>a&&(f-=m,s+=hr);const b=h,x=h+Math.abs(f)-1,A=p%2!==0,U=f<0;f===0?u=u.add(r(A,i[b])):c=c.add(r(U,i[x]))}return{p:c,f:u}},wNAFCached(o,i,s,l){const a=o._WINDOW_SIZE||1;let c=i.get(o);return c||(c=this.precomputeWindow(o,a),a!==1&&i.set(o,l(c))),this.wNAF(a,c,s)}}}function To(e){return Ea(e.Fp),Ae(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Bo(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ca(e){const t=To(e);Ae(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:r,Fp:n,a:o}=t;if(r){if(!n.eql(o,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}const{bytesToNumberBE:Ba,hexToBytes:La}=ba,Dt={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(e){const{Err:t}=Dt;if(e.length<2||e[0]!==2)throw new t("Invalid signature integer tag");const r=e[1],n=e.subarray(2,r+2);if(!r||n.length!==r)throw new t("Invalid signature integer: wrong length");if(n[0]&128)throw new t("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return{d:Ba(n),l:e.subarray(r+2)}},toSig(e){const{Err:t}=Dt,r=typeof e=="string"?La(e):e;if(!(r instanceof Uint8Array))throw new Error("ui8a expected");let n=r.length;if(n<2||r[0]!=48)throw new t("Invalid signature tag");if(r[1]!==n-2)throw new t("Invalid signature: incorrect length");const{d:o,l:i}=Dt._parseInt(r.subarray(2)),{d:s,l}=Dt._parseInt(i);if(l.length)throw new t("Invalid signature: left bytes after parsing");return{r:o,s}},hexFromSig(e){const t=c=>Number.parseInt(c[0],16)&8?"00"+c:c,r=c=>{const u=c.toString(16);return u.length&1?`0${u}`:u},n=t(r(e.s)),o=t(r(e.r)),i=n.length/2,s=o.length/2,l=r(i),a=r(s);return`30${r(s+i+4)}02${a}${o}02${l}${n}`}},ht=BigInt(0),tt=BigInt(1);BigInt(2);const Gn=BigInt(3);BigInt(4);function Ua(e){const t=Ca(e),{Fp:r}=t,n=t.toBytes||((p,h,f)=>{const b=h.toAffine();return Ft(Uint8Array.from([4]),r.toBytes(b.x),r.toBytes(b.y))}),o=t.fromBytes||(p=>{const h=p.subarray(1),f=r.fromBytes(h.subarray(0,r.BYTES)),b=r.fromBytes(h.subarray(r.BYTES,2*r.BYTES));return{x:f,y:b}});function i(p){const{a:h,b:f}=t,b=r.sqr(p),x=r.mul(b,p);return r.add(r.add(x,r.mul(p,h)),f)}if(!r.eql(r.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function s(p){return typeof p=="bigint"&&htr.eql(A,r.ZERO);return x(f)&&x(b)?d.ZERO:new d(f,b,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){const f=r.invertBatch(h.map(b=>b.pz));return h.map((b,x)=>b.toAffine(f[x])).map(d.fromAffine)}static fromHex(h){const f=d.fromAffine(o(Z("pointHex",h)));return f.assertValidity(),f}static fromPrivateKey(h){return d.BASE.multiply(a(h))}_setWindowSize(h){this._WINDOW_SIZE=h,c.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:h,y:f}=this.toAffine();if(!r.isValid(h)||!r.isValid(f))throw new Error("bad point: x or y not FE");const b=r.sqr(f),x=i(h);if(!r.eql(b,x))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:h}=this.toAffine();if(r.isOdd)return!r.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){u(h);const{px:f,py:b,pz:x}=this,{px:A,py:U,pz:C}=h,v=r.eql(r.mul(f,C),r.mul(A,x)),E=r.eql(r.mul(b,C),r.mul(U,x));return v&&E}negate(){return new d(this.px,r.neg(this.py),this.pz)}double(){const{a:h,b:f}=t,b=r.mul(f,Gn),{px:x,py:A,pz:U}=this;let C=r.ZERO,v=r.ZERO,E=r.ZERO,_=r.mul(x,x),V=r.mul(A,A),L=r.mul(U,U),k=r.mul(x,A);return k=r.add(k,k),E=r.mul(x,U),E=r.add(E,E),C=r.mul(h,E),v=r.mul(b,L),v=r.add(C,v),C=r.sub(V,v),v=r.add(V,v),v=r.mul(C,v),C=r.mul(k,C),E=r.mul(b,E),L=r.mul(h,L),k=r.sub(_,L),k=r.mul(h,k),k=r.add(k,E),E=r.add(_,_),_=r.add(E,_),_=r.add(_,L),_=r.mul(_,k),v=r.add(v,_),L=r.mul(A,U),L=r.add(L,L),_=r.mul(L,k),C=r.sub(C,_),E=r.mul(L,V),E=r.add(E,E),E=r.add(E,E),new d(C,v,E)}add(h){u(h);const{px:f,py:b,pz:x}=this,{px:A,py:U,pz:C}=h;let v=r.ZERO,E=r.ZERO,_=r.ZERO;const V=t.a,L=r.mul(t.b,Gn);let k=r.mul(f,A),O=r.mul(b,U),H=r.mul(x,C),D=r.add(f,b),y=r.add(A,U);D=r.mul(D,y),y=r.add(k,O),D=r.sub(D,y),y=r.add(f,x);let w=r.add(A,C);return y=r.mul(y,w),w=r.add(k,H),y=r.sub(y,w),w=r.add(b,x),v=r.add(U,C),w=r.mul(w,v),v=r.add(O,H),w=r.sub(w,v),_=r.mul(V,y),v=r.mul(L,H),_=r.add(v,_),v=r.sub(O,_),_=r.add(O,_),E=r.mul(v,_),O=r.add(k,k),O=r.add(O,k),H=r.mul(V,H),y=r.mul(L,y),O=r.add(O,H),H=r.sub(k,H),H=r.mul(V,H),y=r.add(y,H),k=r.mul(O,y),E=r.add(E,k),k=r.mul(w,y),v=r.mul(D,v),v=r.sub(v,k),k=r.mul(D,O),_=r.mul(w,_),_=r.add(_,k),new d(v,E,_)}subtract(h){return this.add(h.negate())}is0(){return this.equals(d.ZERO)}wNAF(h){return g.wNAFCached(this,c,h,f=>{const b=r.invertBatch(f.map(x=>x.pz));return f.map((x,A)=>x.toAffine(b[A])).map(d.fromAffine)})}multiplyUnsafe(h){const f=d.ZERO;if(h===ht)return f;if(l(h),h===tt)return this;const{endo:b}=t;if(!b)return g.unsafeLadder(this,h);let{k1neg:x,k1:A,k2neg:U,k2:C}=b.splitScalar(h),v=f,E=f,_=this;for(;A>ht||C>ht;)A&tt&&(v=v.add(_)),C&tt&&(E=E.add(_)),_=_.double(),A>>=tt,C>>=tt;return x&&(v=v.negate()),U&&(E=E.negate()),E=new d(r.mul(E.px,b.beta),E.py,E.pz),v.add(E)}multiply(h){l(h);let f=h,b,x;const{endo:A}=t;if(A){const{k1neg:U,k1:C,k2neg:v,k2:E}=A.splitScalar(f);let{p:_,f:V}=this.wNAF(C),{p:L,f:k}=this.wNAF(E);_=g.constTimeNegate(U,_),L=g.constTimeNegate(v,L),L=new d(r.mul(L.px,A.beta),L.py,L.pz),b=_.add(L),x=V.add(k)}else{const{p:U,f:C}=this.wNAF(f);b=U,x=C}return d.normalizeZ([b,x])[0]}multiplyAndAddUnsafe(h,f,b){const x=d.BASE,A=(C,v)=>v===ht||v===tt||!C.equals(x)?C.multiplyUnsafe(v):C.multiply(v),U=A(this,f).add(A(h,b));return U.is0()?void 0:U}toAffine(h){const{px:f,py:b,pz:x}=this,A=this.is0();h==null&&(h=A?r.ONE:r.inv(x));const U=r.mul(f,h),C=r.mul(b,h),v=r.mul(x,h);if(A)return{x:r.ZERO,y:r.ZERO};if(!r.eql(v,r.ONE))throw new Error("invZ was invalid");return{x:U,y:C}}isTorsionFree(){const{h,isTorsionFree:f}=t;if(h===tt)return!0;if(f)return f(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h,clearCofactor:f}=t;return h===tt?this:f?f(d,this):this.multiplyUnsafe(t.h)}toRawBytes(h=!0){return this.assertValidity(),n(d,this,h)}toHex(h=!0){return ee(this.toRawBytes(h))}}d.BASE=new d(t.Gx,t.Gy,r.ONE),d.ZERO=new d(r.ZERO,r.ONE,r.ZERO);const m=t.nBitLength,g=Pa(d,t.endo?Math.ceil(m/2):m);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:a,weierstrassEquation:i,isWithinCurveOrder:s}}function Ta(e){const t=To(e);return Ae(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Ia(e){const t=Ta(e),{Fp:r,n}=t,o=r.BYTES+1,i=2*r.BYTES+1;function s(y){return htee(Tt(y,t.nByteLength));function p(y){const w=n>>tt;return y>w}function h(y){return p(y)?l(-y):y}const f=(y,w,$)=>X(y.slice(w,$));class b{constructor(w,$,B){this.r=w,this.s=$,this.recovery=B,this.assertValidity()}static fromCompact(w){const $=t.nByteLength;return w=Z("compactSignature",w,$*2),new b(f(w,0,$),f(w,$,2*$))}static fromDER(w){const{r:$,s:B}=Dt.toSig(Z("DER",w));return new b($,B)}assertValidity(){if(!m(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!m(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(w){return new b(this.r,this.s,w)}recoverPublicKey(w){const{r:$,s:B,recovery:P}=this,I=E(Z("msgHash",w));if(P==null||![0,1,2,3].includes(P))throw new Error("recovery id invalid");const z=P===2||P===3?$+t.n:$;if(z>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");const R=P&1?"03":"02",et=c.fromHex(R+g(z)),Et=a(z),Kt=l(-I*Et),ce=l(B*Et),_t=c.BASE.multiplyAndAddUnsafe(et,Kt,ce);if(!_t)throw new Error("point at infinify");return _t.assertValidity(),_t}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new b(this.r,l(-this.s),this.recovery):this}toDERRawBytes(){return re(this.toDERHex())}toDERHex(){return Dt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return re(this.toCompactHex())}toCompactHex(){return g(this.r)+g(this.s)}}const x={isValidPrivateKey(y){try{return u(y),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{const y=Uo(t.n);return Sa(t.randomBytes(y),t.n)},precompute(y=8,w=c.BASE){return w._setWindowSize(y),w.multiply(BigInt(3)),w}};function A(y,w=!0){return c.fromPrivateKey(y).toRawBytes(w)}function U(y){const w=y instanceof Uint8Array,$=typeof y=="string",B=(w||$)&&y.length;return w?B===o||B===i:$?B===2*o||B===2*i:y instanceof c}function C(y,w,$=!0){if(U(y))throw new Error("first arg must be private key");if(!U(w))throw new Error("second arg must be public key");return c.fromHex(w).multiply(u(y)).toRawBytes($)}const v=t.bits2int||function(y){const w=X(y),$=y.length*8-t.nBitLength;return $>0?w>>BigInt($):w},E=t.bits2int_modN||function(y){return l(v(y))},_=Qr(t.nBitLength);function V(y){if(typeof y!="bigint")throw new Error("bigint expected");if(!(ht<=y&&y<_))throw new Error(`bigint expected < 2^${t.nBitLength}`);return Tt(y,t.nByteLength)}function L(y,w,$=k){if(["recovered","canonical"].some(Nt=>Nt in $))throw new Error("sign() legacy options not supported");const{hash:B,randomBytes:P}=t;let{lowS:I,prehash:z,extraEntropy:R}=$;I==null&&(I=!0),y=Z("msgHash",y),z&&(y=Z("prehashed msgHash",B(y)));const et=E(y),Et=u(w),Kt=[V(Et),V(et)];if(R!=null){const Nt=R===!0?P(r.BYTES):R;Kt.push(Z("extraEntropy",Nt))}const ce=Ft(...Kt),_t=et;function ar(Nt){const Zt=v(Nt);if(!m(Zt))return;const Bn=a(Zt),nt=c.BASE.multiply(Zt).toAffine(),Gt=l(nt.x);if(Gt===ht)return;const Se=l(Bn*l(_t+Gt*Et));if(Se===ht)return;let Ln=(nt.x===Gt?0:2)|Number(nt.y&tt),Un=Se;return I&&p(Se)&&(Un=h(Se),Ln^=1),new b(Gt,Un,Ln)}return{seed:ce,k2sig:ar}}const k={lowS:t.lowS,prehash:!1},O={lowS:t.lowS,prehash:!1};function H(y,w,$=k){const{seed:B,k2sig:P}=L(y,w,$),I=t;return Co(I.hash.outputLen,I.nByteLength,I.hmac)(B,P)}c.BASE._setWindowSize(8);function D(y,w,$,B=O){const P=y;if(w=Z("msgHash",w),$=Z("publicKey",$),"strict"in B)throw new Error("options.strict was renamed to lowS");const{lowS:I,prehash:z}=B;let R,et;try{if(typeof P=="string"||P instanceof Uint8Array)try{R=b.fromDER(P)}catch(nt){if(!(nt instanceof Dt.Err))throw nt;R=b.fromCompact(P)}else if(typeof P=="object"&&typeof P.r=="bigint"&&typeof P.s=="bigint"){const{r:nt,s:Gt}=P;R=new b(nt,Gt)}else throw new Error("PARSE");et=c.fromHex($)}catch(nt){if(nt.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(I&&R.hasHighS())return!1;z&&(w=t.hash(w));const{r:Et,s:Kt}=R,ce=E(w),_t=a(Kt),ar=l(ce*_t),Nt=l(Et*_t),Zt=c.BASE.multiplyAndAddUnsafe(et,ar,Nt)?.toAffine();return Zt?l(Zt.x)===Et:!1}return{CURVE:t,getPublicKey:A,getSharedSecret:C,sign:H,verify:D,ProjectivePoint:c,Signature:b,utils:x}}let Io=class extends Ao{constructor(t,r){super(),this.finished=!1,this.destroyed=!1,Gs(t);const n=Gr(r);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,i=new Uint8Array(o);i.set(n.length>o?t.create().update(n).digest():n);for(let s=0;snew Io(e,t).update(r).digest();Mo.create=(e,t)=>new Io(e,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ma(e){return{hash:e,hmac:(t,...r)=>Mo(e,t,Qs(...r)),randomBytes:So}}function Ra(e,t){const r=n=>Ia({...e,...Ma(n)});return Object.freeze({...r(t),create:r})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const We=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ne=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Ro=BigInt(1),Oe=BigInt(2),Jn=(e,t)=>(e+t/Oe)/t;function No(e){const t=We,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),l=BigInt(44),a=BigInt(88),c=e*e*e%t,u=c*c*e%t,d=Q(u,r,t)*u%t,m=Q(d,r,t)*u%t,g=Q(m,Oe,t)*c%t,p=Q(g,o,t)*g%t,h=Q(p,i,t)*p%t,f=Q(h,l,t)*h%t,b=Q(f,a,t)*f%t,x=Q(b,l,t)*h%t,A=Q(x,r,t)*u%t,U=Q(A,s,t)*p%t,C=Q(U,n,t)*c%t,v=Q(C,Oe,t);if(!Br.eql(Br.sqr(v),e))throw new Error("Cannot find square root");return v}const Br=Aa(We,void 0,void 0,{sqrt:No}),se=Ra({a:BigInt(0),b:BigInt(7),Fp:Br,n:Ne,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=Ne,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Ro*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=r,s=BigInt("0x100000000000000000000000000000000"),l=Jn(i*e,t),a=Jn(-n*e,t);let c=K(e-l*r-a*o,t),u=K(-l*n-a*i,t);const d=c>s,m=u>s;if(d&&(c=t-c),m&&(u=t-u),c>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:d,k1:c,k2neg:m,k2:u}}}},kr),Ke=BigInt(0),Oo=e=>typeof e=="bigint"&&Ketypeof e=="bigint"&&Keo.charCodeAt(0)));r=Ft(n,n),Yn[e]=r}return kr(Ft(r,...t))}const tn=e=>e.toRawBytes(!0).slice(1),Lr=e=>Tt(e,32),fr=e=>K(e,We),xe=e=>K(e,Ne),en=se.ProjectivePoint,Oa=(e,t,r)=>en.BASE.multiplyAndAddUnsafe(e,t,r);function Ur(e){let t=se.utils.normPrivateKeyToScalar(e),r=en.fromPrivateKey(t);return{scalar:r.hasEvenY()?t:xe(-t),bytes:tn(r)}}function Ho(e){if(!Oo(e))throw new Error("bad x: need 0 < x < p");const t=fr(e*e),r=fr(t*e+BigInt(7));let n=No(r);n%Oe!==Ke&&(n=fr(-n));const o=new en(e,n,Ro);return o.assertValidity(),o}function zo(...e){return xe(X(He("BIP0340/challenge",...e)))}function Ha(e){return Ur(e).bytes}function za(e,t,r=So(32)){const n=Z("message",e),{bytes:o,scalar:i}=Ur(t),s=Z("auxRand",r,32),l=Lr(i^X(He("BIP0340/aux",s))),a=He("BIP0340/nonce",l,o,n),c=xe(X(a));if(c===Ke)throw new Error("sign failed: k is zero");const{bytes:u,scalar:d}=Ur(c),m=zo(u,o,n),g=new Uint8Array(64);if(g.set(u,0),g.set(Lr(xe(d+m*i)),32),!Vo(g,n,o))throw new Error("sign: Invalid signature produced");return g}function Vo(e,t,r){const n=Z("signature",e,64),o=Z("message",t),i=Z("publicKey",r,32);try{const s=Ho(X(i)),l=X(n.subarray(0,32));if(!Oo(l))return!1;const a=X(n.subarray(32,64));if(!Na(a))return!1;const c=zo(Lr(l),tn(s),o),u=Oa(s,a,xe(-c));return!(!u||!u.hasEvenY()||u.toAffine().x!==l)}catch{return!1}}const ue={getPublicKey:Ha,sign:za,verify:Vo,utils:{randomPrivateKey:se.utils.randomPrivateKey,lift_x:Ho,pointToBytes:tn,numberToBytesBE:Tt,bytesToNumberBE:X,taggedHash:He,mod:K}},pr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const rn=e=>e instanceof Uint8Array,gr=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),it=(e,t)=>e<<32-t|e>>>t,Va=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Va)throw new Error("Non little-endian hardware is not supported");const Da=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Y(e){if(!rn(e))throw new Error("Uint8Array expected");let t="";for(let r=0;rn+o.length,0));let r=0;return e.forEach(n=>{if(!rn(n))throw new Error("Uint8Array expected");t.set(n,r),r+=n.length}),t}class Do{clone(){return this._cloneInto()}}function qo(e){const t=n=>e().update(Ee(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function jo(e=32){if(pr&&typeof pr.getRandomValues=="function")return pr.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}function Tr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function ja(e){if(typeof e!="boolean")throw new Error(`Expected boolean, not ${e}`)}function Fo(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function Fa(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Tr(e.outputLen),Tr(e.blockLen)}function Wa(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Ka(e,t){Fo(e);const r=t.outputLen;if(e.length>o&i),l=Number(r&i),a=n?4:0,c=n?0:4;e.setUint32(t+a,s,n),e.setUint32(t+c,l,n)}class Ga extends Do{constructor(t,r,n,o){super(),this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=gr(this.buffer)}update(t){st.exists(this);const{view:r,buffer:n,blockLen:o}=this;t=Ee(t);const i=t.length;for(let s=0;so-s&&(this.process(n,0),s=0);for(let d=s;du.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;de&t^~e&r,Ya=(e,t,r)=>e&t^e&r^t&r,Xa=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),St=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),kt=new Uint32Array(64);class Wo extends Ga{constructor(){super(64,32,8,!1),this.A=St[0]|0,this.B=St[1]|0,this.C=St[2]|0,this.D=St[3]|0,this.E=St[4]|0,this.F=St[5]|0,this.G=St[6]|0,this.H=St[7]|0}get(){const{A:t,B:r,C:n,D:o,E:i,F:s,G:l,H:a}=this;return[t,r,n,o,i,s,l,a]}set(t,r,n,o,i,s,l,a){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=l|0,this.H=a|0}process(t,r){for(let d=0;d<16;d++,r+=4)kt[d]=t.getUint32(r,!1);for(let d=16;d<64;d++){const m=kt[d-15],g=kt[d-2],p=it(m,7)^it(m,18)^m>>>3,h=it(g,17)^it(g,19)^g>>>10;kt[d]=h+kt[d-7]+p+kt[d-16]|0}let{A:n,B:o,C:i,D:s,E:l,F:a,G:c,H:u}=this;for(let d=0;d<64;d++){const m=it(l,6)^it(l,11)^it(l,25),g=u+m+Ja(l,a,c)+Xa[d]+kt[d]|0,h=(it(n,2)^it(n,13)^it(n,22))+Ya(n,o,i)|0;u=c,c=a,a=l,l=s+g|0,s=i,i=o,o=n,n=g+h|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,l=l+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(n,o,i,s,l,a,c,u)}roundClean(){kt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class Qa extends Wo{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}const ae=qo(()=>new Wo);qo(()=>new Qa);/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function le(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function yt(...e){const t=(o,i)=>s=>o(i(s)),r=Array.from(e).reverse().reduce((o,i)=>o?t(o,i.encode):i.encode,void 0),n=e.reduce((o,i)=>o?t(o,i.decode):i.decode,void 0);return{encode:r,decode:n}}function wt(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return t.map(r=>{if(le(r),r<0||r>=e.length)throw new Error(`Digit index outside alphabet: ${r} (alphabet: ${e.length})`);return e[r]})},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="string")throw new Error("alphabet.decode input should be array of strings");return t.map(r=>{if(typeof r!="string")throw new Error(`alphabet.decode: not string element=${r}`);const n=e.indexOf(r);if(n===-1)throw new Error(`Unknown letter: "${r}". Allowed: ${e}`);return n})}}}function vt(e=""){if(typeof e!="string")throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="string")throw new Error("join.encode input should be array of strings");for(let r of t)if(typeof r!="string")throw new Error(`join.encode: non-string input=${r}`);return t.join(e)},decode:t=>{if(typeof t!="string")throw new Error("join.decode input should be string");return t.split(e)}}}function Ge(e,t="="){if(le(e),typeof t!="string")throw new Error("padding chr should be string");return{encode(r){if(!Array.isArray(r)||r.length&&typeof r[0]!="string")throw new Error("padding.encode input should be array of strings");for(let n of r)if(typeof n!="string")throw new Error(`padding.encode: non-string input=${n}`);for(;r.length*e%8;)r.push(t);return r},decode(r){if(!Array.isArray(r)||r.length&&typeof r[0]!="string")throw new Error("padding.encode input should be array of strings");for(let o of r)if(typeof o!="string")throw new Error(`padding.decode: non-string input=${o}`);let n=r.length;if(n*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;n>0&&r[n-1]===t;n--)if(!((n-1)*e%8))throw new Error("Invalid padding: string has too much padding");return r.slice(0,n)}}}function Ko(e){if(typeof e!="function")throw new Error("normalize fn should be function");return{encode:t=>t,decode:t=>e(t)}}function Xn(e,t,r){if(t<2)throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: wrong to=${r}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let n=0;const o=[],i=Array.from(e);for(i.forEach(s=>{if(le(s),s<0||s>=t)throw new Error(`Wrong integer: ${s}`)});;){let s=0,l=!0;for(let a=n;at?Zo(t,e%t):e,ze=(e,t)=>e+(t-Zo(e,t));function Ir(e,t,r,n){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(ze(t,r)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${ze(t,r)}`);let o=0,i=0;const s=2**r-1,l=[];for(const a of e){if(le(a),a>=2**t)throw new Error(`convertRadix2: invalid data word=${a} from=${t}`);if(o=o<32)throw new Error(`convertRadix2: carry overflow pos=${i} from=${t}`);for(i+=t;i>=r;i-=r)l.push((o>>i-r&s)>>>0);o&=2**i-1}if(o=o<=t)throw new Error("Excess padding");if(!n&&o)throw new Error(`Non-zero padding: ${o}`);return n&&i>0&&l.push(o>>>0),l}function tl(e){return le(e),{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return Xn(Array.from(t),2**8,e)},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="number")throw new Error("radix.decode input should be array of strings");return Uint8Array.from(Xn(t,e,2**8))}}}function It(e,t=!1){if(le(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(ze(8,e)>32||ze(e,8)>32)throw new Error("radix2: carry overflow");return{encode:r=>{if(!(r instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return Ir(Array.from(r),8,e,!t)},decode:r=>{if(!Array.isArray(r)||r.length&&typeof r[0]!="number")throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(Ir(r,e,8,t))}}}function Qn(e){if(typeof e!="function")throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch{}}}const el=yt(It(4),wt("0123456789ABCDEF"),vt("")),rl=yt(It(5),wt("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Ge(5),vt(""));yt(It(5),wt("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Ge(5),vt(""));yt(It(5),wt("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),vt(""),Ko(e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));const bt=yt(It(6),wt("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Ge(6),vt("")),nl=yt(It(6),wt("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Ge(6),vt("")),nn=e=>yt(tl(58),wt(e),vt("")),Mr=nn("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");nn("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ");nn("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const to=[0,2,3,5,6,7,9,10,11],ol={encode(e){let t="";for(let r=0;r>25;let r=(e&33554431)<<5;for(let n=0;n>n&1)===1&&(r^=eo[n]);return r}function ro(e,t,r=1){const n=e.length;let o=1;for(let i=0;i126)throw new Error(`Invalid prefix (${e})`);o=he(o)^s>>5}o=he(o);for(let i=0;im)throw new TypeError(`Length ${g} exceeds limit ${m}`);return u=u.toLowerCase(),`${u}1${Rr.encode(d)}${ro(u,d,t)}`}function l(u,d=90){if(typeof u!="string")throw new Error(`bech32.decode input should be string, not ${typeof u}`);if(u.length<8||d!==!1&&u.length>d)throw new TypeError(`Wrong string length: ${u.length} (${u}). Expected (8..${d})`);const m=u.toLowerCase();if(u!==m&&u!==u.toUpperCase())throw new Error("String must be lowercase or uppercase");u=m;const g=u.lastIndexOf("1");if(g===0||g===-1)throw new Error('Letter "1" must be present between prefix and data only');const p=u.slice(0,g),h=u.slice(g+1);if(h.length<6)throw new Error("Data must be at least 6 characters long");const f=Rr.decode(h).slice(0,-6),b=ro(p,f,t);if(!h.endsWith(b))throw new Error(`Invalid checksum in ${u}: expected "${b}"`);return{prefix:p,words:f}}const a=Qn(l);function c(u){const{prefix:d,words:m}=l(u,!1);return{prefix:d,words:m,bytes:n(m)}}return{encode:s,decode:l,decodeToBytes:c,decodeUnsafe:a,fromWords:n,fromWordsUnsafe:i,toWords:o}}const oe=Go("bech32");Go("bech32m");const il={encode:e=>new TextDecoder().decode(e),decode:e=>new TextEncoder().encode(e)},sl=yt(It(4),wt("0123456789abcdef"),vt(""),Ko(e=>{if(typeof e!="string"||e.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()})),al={utf8:il,hex:sl,base16:el,base32:rl,base64:bt,base64url:nl,base58:Mr,base58xmr:ol};`${Object.keys(al).join(", ")}`;function br(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function no(e){if(typeof e!="boolean")throw new Error(`boolean expected, not ${e}`)}function ll(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function ft(e,...t){if(!ll(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */const J=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),cl=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!cl)throw new Error("Non little-endian hardware is not supported");function dl(e,t){if(t==null||typeof t!="object")throw new Error("options must be defined");return Object.assign(e,t)}function ul(e,t){if(e.length!==t.length)return!1;let r=0;for(let n=0;n(Object.assign(t,e),t),Ut=16,fl=283;function on(e){return e<<1^fl&-(e>>7)}function Xt(e,t){let r=0;for(;t>0;t>>=1)r^=e&-(t&1),e=on(e);return r}const Nr=(()=>{let e=new Uint8Array(256);for(let r=0,n=1;r<256;r++,n^=on(n))e[r]=n;const t=new Uint8Array(256);t[0]=99;for(let r=0;r<255;r++){let n=e[255-r];n|=n<<8,t[e[r]]=(n^n>>4^n>>5^n>>6^n>>7^99)&255}return t})(),pl=Nr.map((e,t)=>Nr.indexOf(t)),gl=e=>e<<24|e>>>8,mr=e=>e<<8|e>>>24;function Jo(e,t){if(e.length!==256)throw new Error("Wrong sbox length");const r=new Uint32Array(256).map((c,u)=>t(e[u])),n=r.map(mr),o=n.map(mr),i=o.map(mr),s=new Uint32Array(256*256),l=new Uint32Array(256*256),a=new Uint16Array(256*256);for(let c=0;c<256;c++)for(let u=0;u<256;u++){const d=c*256+u;s[d]=r[c]^n[u],l[d]=o[c]^i[u],a[d]=e[c]<<8|e[u]}return{sbox:e,sbox2:a,T0:r,T1:n,T2:o,T3:i,T01:s,T23:l}}const sn=Jo(Nr,e=>Xt(e,3)<<24|e<<16|e<<8|Xt(e,2)),Yo=Jo(pl,e=>Xt(e,11)<<24|Xt(e,13)<<16|Xt(e,9)<<8|Xt(e,14)),bl=(()=>{const e=new Uint8Array(16);for(let t=0,r=1;t<16;t++,r=on(r))e[t]=r;return e})();function Xo(e){ft(e);const t=e.length;if(![16,24,32].includes(t))throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${t}`);const{sbox2:r}=sn,n=J(e),o=n.length,i=l=>at(r,l,l,l,l),s=new Uint32Array(t+28);s.set(n);for(let l=o;l6&&l%o===4&&(a=i(a)),s[l]=s[l-o]^a}return s}function ml(e){const t=Xo(e),r=t.slice(),n=t.length,{sbox2:o}=sn,{T0:i,T1:s,T2:l,T3:a}=Yo;for(let c=0;c>>8&255]^l[d>>>16&255]^a[d>>>24]}return r}function Bt(e,t,r,n,o,i){return e[r<<8&65280|n>>>8&255]^t[o>>>8&65280|i>>>24&255]}function at(e,t,r,n,o){return e[t&255|r&65280]|e[n>>>16&255|o>>>16&65280]<<16}function oo(e,t,r,n,o){const{sbox2:i,T01:s,T23:l}=sn;let a=0;t^=e[a++],r^=e[a++],n^=e[a++],o^=e[a++];const c=e.length/4-2;for(let p=0;p16)throw new Error(`aes/pcks5: wrong padding byte: ${n}`);const o=e.subarray(0,-n);for(let i=0;i{const l=Xo(t),{b:a,o:c,out:u}=vl(i,o,s),d=J(r);let m=d[0],g=d[1],p=d[2],h=d[3],f=0;for(;f+4<=a.length;)m^=a[f+0],g^=a[f+1],p^=a[f+2],h^=a[f+3],{s0:m,s1:g,s2:p,s3:h}=oo(l,m,g,p,h),c[f++]=m,c[f++]=g,c[f++]=p,c[f++]=h;if(o){const b=El(i.subarray(f*4));m^=b[0],g^=b[1],p^=b[2],h^=b[3],{s0:m,s1:g,s2:p,s3:h}=oo(l,m,g,p,h),c[f++]=m,c[f++]=g,c[f++]=p,c[f++]=h}return l.fill(0),u},decrypt:(i,s)=>{wl(i);const l=ml(t),a=J(r),c=Qo(i.length,s),u=J(i),d=J(c);let m=a[0],g=a[1],p=a[2],h=a[3];for(let f=0;f+4<=u.length;){const b=m,x=g,A=p,U=h;m=u[f+0],g=u[f+1],p=u[f+2],h=u[f+3];const{s0:C,s1:v,s2:E,s3:_}=yl(l,m,g,p,h);d[f++]=C^b,d[f++]=v^x,d[f++]=E^A,d[f++]=_^U}return l.fill(0),xl(c,o)}}}),ei=e=>Uint8Array.from(e.split("").map(t=>t.charCodeAt(0))),_l=ei("expand 16-byte k"),$l=ei("expand 32-byte k"),Al=J(_l),ri=J($l);ri.slice();function M(e,t){return e<>>32-t}function Or(e){return e.byteOffset%4===0}const ke=64,Sl=16,ni=2**32-1,io=new Uint32Array;function kl(e,t,r,n,o,i,s,l){const a=o.length,c=new Uint8Array(ke),u=J(c),d=Or(o)&&Or(i),m=d?J(o):io,g=d?J(i):io;for(let p=0;p=ni)throw new Error("arx: counter overflow");const h=Math.min(ke,a-p);if(d&&h===ke){const f=p/4;if(p%4!==0)throw new Error("arx: invalid block position");for(let b=0,x;b{ft(l),ft(a),ft(c);const m=c.length;if(u||(u=new Uint8Array(m)),ft(u),br(d),d<0||d>=ni)throw new Error("arx: counter overflow");if(u.length0;)g.pop().fill(0);return u}}function Cl(e,t,r,n,o,i=20){let s=e[0],l=e[1],a=e[2],c=e[3],u=t[0],d=t[1],m=t[2],g=t[3],p=t[4],h=t[5],f=t[6],b=t[7],x=o,A=r[0],U=r[1],C=r[2],v=s,E=l,_=a,V=c,L=u,k=d,O=m,H=g,D=p,y=h,w=f,$=b,B=x,P=A,I=U,z=C;for(let et=0;eto?t.create().update(n).digest():n);for(let s=0;snew ii(e,t).update(r).digest();Je.create=(e,t)=>new ii(e,t);function Bl(e,t,r){return st.hash(e),Je(e,Ee(r),Ee(t))}const yr=new Uint8Array([0]),so=new Uint8Array;function Ll(e,t,r,n=32){if(st.hash(e),st.number(n),n>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const o=Math.ceil(n/e.outputLen);r===void 0&&(r=so);const i=new Uint8Array(o*e.outputLen),s=Je.create(e,t),l=s._cloneInto(),a=new Uint8Array(s.outputLen);for(let c=0;c{for(var r in t)Ul(e,r,{get:t[r],enumerable:!0})},Jt=Symbol("verified"),Tl=e=>e instanceof Object;function an(e){if(!Tl(e)||typeof e.kind!="number"||typeof e.content!="string"||typeof e.created_at!="number"||typeof e.pubkey!="string"||!e.pubkey.match(/^[a-f0-9]{64}$/)||!Array.isArray(e.tags))return!1;for(let t=0;tli,QueueNode:()=>ai,binarySearch:()=>ln,insertEventIntoAscendingList:()=>Rl,insertEventIntoDescendingList:()=>Ml,normalizeURL:()=>si,utf8Decoder:()=>pt,utf8Encoder:()=>rt});var pt=new TextDecoder("utf-8"),rt=new TextEncoder;function si(e){e.indexOf("://")===-1&&(e="wss://"+e);let t=new URL(e);return t.pathname=t.pathname.replace(/\/+/g,"/"),t.pathname.endsWith("/")&&(t.pathname=t.pathname.slice(0,-1)),(t.port==="80"&&t.protocol==="ws:"||t.port==="443"&&t.protocol==="wss:")&&(t.port=""),t.searchParams.sort(),t.hash="",t.toString()}function Ml(e,t){const[r,n]=ln(e,o=>t.id===o.id?0:t.created_at===o.created_at?-1:o.created_at-t.created_at);return n||e.splice(r,0,t),e}function Rl(e,t){const[r,n]=ln(e,o=>t.id===o.id?0:t.created_at===o.created_at?-1:t.created_at-o.created_at);return n||e.splice(r,0,t),e}function ln(e,t){let r=0,n=e.length-1;for(;r<=n;){const o=Math.floor((r+n)/2),i=t(e[o]);if(i===0)return[o,!0];i<0?n=o-1:r=o+1}return[r,!1]}var ai=class{value;next=null;prev=null;constructor(e){this.value=e}},li=class{first;last;constructor(){this.first=null,this.last=null}enqueue(e){const t=new ai(e);return this.last?this.last===this.first?(this.last=t,this.last.prev=this.first,this.first.next=t):(t.prev=this.last,this.last.next=t,this.last=t):(this.first=t,this.last=t),!0}dequeue(){if(!this.first)return null;if(this.first===this.last){const t=this.first;return this.first=null,this.last=null,t.value}const e=this.first;return this.first=e.next,e.value}},Nl=class{generateSecretKey(){return ue.utils.randomPrivateKey()}getPublicKey(e){return Y(ue.getPublicKey(e))}finalizeEvent(e,t){const r=e;return r.pubkey=Y(ue.getPublicKey(t)),r.id=Le(r),r.sig=Y(ue.sign(Le(r),t)),r[Jt]=!0,r}verifyEvent(e){if(typeof e[Jt]=="boolean")return e[Jt];const t=Le(e);if(t!==e.id)return e[Jt]=!1,!1;try{const r=ue.verify(e.sig,t,e.pubkey);return e[Jt]=r,r}catch{return e[Jt]=!1,!1}}};function Ol(e){if(!an(e))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content])}function Le(e){let t=ae(rt.encode(Ol(e)));return Y(t)}var Ye=new Nl,Hl=Ye.generateSecretKey,ci=Ye.getPublicKey,dt=Ye.finalizeEvent,Xe=Ye.verifyEvent,zl={};q(zl,{Application:()=>Dc,BadgeAward:()=>Gl,BadgeDefinition:()=>Mc,BlockedRelaysList:()=>wc,BookmarkList:()=>bc,Bookmarksets:()=>Uc,Calendar:()=>Gc,CalendarEventRSVP:()=>Jc,ChannelCreation:()=>gi,ChannelHideMessage:()=>yi,ChannelMessage:()=>mi,ChannelMetadata:()=>bi,ChannelMuteUser:()=>wi,ClassifiedListing:()=>Fc,ClientAuth:()=>xi,CommunitiesList:()=>mc,CommunityDefinition:()=>Qc,CommunityPostApproval:()=>ic,Contacts:()=>Wl,CreateOrUpdateProduct:()=>Oc,CreateOrUpdateStall:()=>Nc,Curationsets:()=>Tc,Date:()=>Kc,DirectMessageRelaysList:()=>_c,DraftClassifiedListing:()=>Wc,DraftLong:()=>zc,Emojisets:()=>Vc,EncryptedDirectMessage:()=>Kl,EventDeletion:()=>Zl,FileMetadata:()=>Ql,FileServerPreference:()=>$c,Followsets:()=>Cc,GenericRepost:()=>Yl,Genericlists:()=>Bc,GiftWrap:()=>vi,HTTPAuth:()=>un,Handlerinformation:()=>Xc,Handlerrecommendation:()=>Yc,Highlights:()=>hc,InterestsList:()=>xc,Interestsets:()=>Rc,JobFeedback:()=>lc,JobRequest:()=>sc,JobResult:()=>ac,Label:()=>oc,LightningPubRPC:()=>Sc,LiveChatMessage:()=>tc,LiveEvent:()=>qc,LongFormArticle:()=>Hc,Metadata:()=>ql,Mutelist:()=>fc,NWCWalletInfo:()=>Ac,NWCWalletRequest:()=>Ei,NWCWalletResponse:()=>kc,NostrConnect:()=>Pc,OpenTimestamps:()=>Xl,Pinlist:()=>pc,PrivateDirectMessage:()=>Jl,ProblemTracker:()=>ec,ProfileBadges:()=>Ic,PublicChatsList:()=>yc,Reaction:()=>dn,RecommendRelay:()=>Fl,RelayList:()=>gc,Relaysets:()=>Lc,Report:()=>rc,Reporting:()=>nc,Repost:()=>cn,Seal:()=>pi,SearchRelaysList:()=>vc,ShortTextNote:()=>jl,Time:()=>Zc,UserEmojiList:()=>Ec,UserStatuses:()=>jc,Zap:()=>uc,ZapGoal:()=>cc,ZapRequest:()=>dc,classifyKind:()=>Vl,isEphemeralKind:()=>hi,isKind:()=>Dl,isParameterizedReplaceableKind:()=>fi,isRegularKind:()=>di,isReplaceableKind:()=>ui});function di(e){return 1e3<=e&&e<1e4||[1,2,4,5,6,7,8,16,40,41,42,43,44].includes(e)}function ui(e){return[0,3].includes(e)||1e4<=e&&e<2e4}function hi(e){return 2e4<=e&&e<3e4}function fi(e){return 3e4<=e&&e<4e4}function Vl(e){return di(e)?"regular":ui(e)?"replaceable":hi(e)?"ephemeral":fi(e)?"parameterized":"unknown"}function Dl(e,t){const r=t instanceof Array?t:[t];return an(e)&&r.includes(e.kind)||!1}var ql=0,jl=1,Fl=2,Wl=3,Kl=4,Zl=5,cn=6,dn=7,Gl=8,pi=13,Jl=14,Yl=16,gi=40,bi=41,mi=42,yi=43,wi=44,Xl=1040,vi=1059,Ql=1063,tc=1311,ec=1971,rc=1984,nc=1984,oc=1985,ic=4550,sc=5999,ac=6999,lc=7e3,cc=9041,dc=9734,uc=9735,hc=9802,fc=1e4,pc=10001,gc=10002,bc=10003,mc=10004,yc=10005,wc=10006,vc=10007,xc=10015,Ec=10030,_c=10050,$c=10096,Ac=13194,Sc=21e3,xi=22242,Ei=23194,kc=23195,Pc=24133,un=27235,Cc=3e4,Bc=30001,Lc=30002,Uc=30003,Tc=30004,Ic=30008,Mc=30009,Rc=30015,Nc=30017,Oc=30018,Hc=30023,zc=30024,Vc=30030,Dc=30078,qc=30311,jc=30315,Fc=30402,Wc=30403,Kc=31922,Zc=31923,Gc=31924,Jc=31925,Yc=31989,Xc=31990,Qc=34550;function td(e,t){if(e.ids&&e.ids.indexOf(t.id)===-1||e.kinds&&e.kinds.indexOf(t.kind)===-1||e.authors&&e.authors.indexOf(t.pubkey)===-1)return!1;for(let r in e)if(r[0]==="#"){let n=r.slice(1),o=e[`#${n}`];if(o&&!t.tags.find(([i,s])=>i===r.slice(1)&&o.indexOf(s)!==-1))return!1}return!(e.since&&t.created_ate.until)}function ed(e,t){for(let r=0;rQe,getInt:()=>_i,getSubscriptionId:()=>$i,matchEventId:()=>nd,matchEventKind:()=>id,matchEventPubkey:()=>od});function Qe(e,t){let r=t.length+3,n=e.indexOf(`"${t}":`)+r,o=e.slice(n).indexOf('"')+n+1;return e.slice(o,o+64)}function _i(e,t){let r=t.length,n=e.indexOf(`"${t}":`)+r+3,o=e.slice(n),i=Math.min(o.indexOf(","),o.indexOf("}"));return parseInt(o.slice(0,i),10)}function $i(e){let t=e.slice(0,22).indexOf('"EVENT"');if(t===-1)return null;let r=e.slice(t+7+1).indexOf('"');if(r===-1)return null;let n=t+7+1+r,o=e.slice(n+1,80).indexOf('"');if(o===-1)return null;let i=n+1+o;return e.slice(n+1,i)}function nd(e,t){return t===Qe(e,"id")}function od(e,t){return t===Qe(e,"pubkey")}function id(e,t){return t===_i(e,"kind")}var sd={};q(sd,{makeAuthEvent:()=>Ai});function Ai(e,t){return{kind:xi,created_at:Math.floor(Date.now()/1e3),tags:[["relay",e],["challenge",t]],content:""}}async function ad(){return new Promise(e=>{const t=new MessageChannel,r=()=>{t.port1.removeEventListener("message",r),e()};t.port1.addEventListener("message",r),t.port2.postMessage(0),t.port1.start()})}var Si=class{url;_connected=!1;onclose=null;onnotice=e=>console.debug(`NOTICE from ${this.url}: ${e}`);_onauth=null;baseEoseTimeout=4400;connectionTimeout=4400;publishTimeout=4400;openSubs=new Map;connectionTimeoutHandle;connectionPromise;openCountRequests=new Map;openEventPublishes=new Map;ws;incomingMessageQueue=new li;queueRunning=!1;challenge;serial=0;verifyEvent;_WebSocket;constructor(e,t){this.url=si(e),this.verifyEvent=t.verifyEvent,this._WebSocket=t.websocketImplementation||WebSocket}static async connect(e,t){const r=new Si(e,t);return await r.connect(),r}closeAllSubscriptions(e){for(let[t,r]of this.openSubs)r.close(e);this.openSubs.clear();for(let[t,r]of this.openEventPublishes)r.reject(new Error(e));this.openEventPublishes.clear();for(let[t,r]of this.openCountRequests)r.reject(new Error(e));this.openCountRequests.clear()}get connected(){return this._connected}async connect(){return this.connectionPromise?this.connectionPromise:(this.challenge=void 0,this.connectionPromise=new Promise((e,t)=>{this.connectionTimeoutHandle=setTimeout(()=>{t("connection timed out"),this.connectionPromise=void 0,this.onclose?.(),this.closeAllSubscriptions("relay connection timed out")},this.connectionTimeout);try{this.ws=new this._WebSocket(this.url)}catch(r){t(r);return}this.ws.onopen=()=>{clearTimeout(this.connectionTimeoutHandle),this._connected=!0,e()},this.ws.onerror=r=>{t(r.message||"websocket error"),this._connected&&(this._connected=!1,this.connectionPromise=void 0,this.onclose?.(),this.closeAllSubscriptions("relay connection errored"))},this.ws.onclose=async()=>{this._connected&&(this._connected=!1,this.connectionPromise=void 0,this.onclose?.(),this.closeAllSubscriptions("relay connection closed"))},this.ws.onmessage=this._onmessage.bind(this)}),this.connectionPromise)}async runQueue(){for(this.queueRunning=!0;this.handleNext()!==!1;)await ad();this.queueRunning=!1}handleNext(){const e=this.incomingMessageQueue.dequeue();if(!e)return!1;const t=$i(e);if(t){const r=this.openSubs.get(t);if(!r)return;const n=Qe(e,"id"),o=r.alreadyHaveEvent?.(n);if(r.receivedEvent?.(this,n),o)return}try{let r=JSON.parse(e);switch(r[0]){case"EVENT":{const n=this.openSubs.get(r[1]),o=r[2];this.verifyEvent(o)&&ed(n.filters,o)&&n.onevent(o);return}case"COUNT":{const n=r[1],o=r[2],i=this.openCountRequests.get(n);i&&(i.resolve(o.count),this.openCountRequests.delete(n));return}case"EOSE":{const n=this.openSubs.get(r[1]);if(!n)return;n.receivedEose();return}case"OK":{const n=r[1],o=r[2],i=r[3],s=this.openEventPublishes.get(n);s&&(o?s.resolve(i):s.reject(new Error(i)),this.openEventPublishes.delete(n));return}case"CLOSED":{const n=r[1],o=this.openSubs.get(n);if(!o)return;o.closed=!0,o.close(r[2]);return}case"NOTICE":this.onnotice(r[1]);return;case"AUTH":{this.challenge=r[1],this._onauth?.(r[1]);return}}}catch{return}}async send(e){if(!this.connectionPromise)throw new Error("sending on closed connection");this.connectionPromise.then(()=>{this.ws?.send(e)})}async auth(e){if(!this.challenge)throw new Error("can't perform auth, no challenge was received");const t=await e(Ai(this.url,this.challenge)),r=new Promise((n,o)=>{this.openEventPublishes.set(t.id,{resolve:n,reject:o})});return this.send('["AUTH",'+JSON.stringify(t)+"]"),r}async publish(e){const t=new Promise((r,n)=>{this.openEventPublishes.set(e.id,{resolve:r,reject:n})});return this.send('["EVENT",'+JSON.stringify(e)+"]"),setTimeout(()=>{const r=this.openEventPublishes.get(e.id);r&&(r.reject(new Error("publish timed out")),this.openEventPublishes.delete(e.id))},this.publishTimeout),t}async count(e,t){this.serial++;const r=t?.id||"count:"+this.serial,n=new Promise((o,i)=>{this.openCountRequests.set(r,{resolve:o,reject:i})});return this.send('["COUNT","'+r+'",'+JSON.stringify(e).substring(1)),n}subscribe(e,t){const r=this.prepareSubscription(e,t);return r.fire(),r}prepareSubscription(e,t){this.serial++;const r=t.id||"sub:"+this.serial,n=new ld(this,r,e,t);return this.openSubs.set(r,n),n}close(){this.closeAllSubscriptions("relay connection closed by us"),this._connected=!1,this.ws?.close()}_onmessage(e){this.incomingMessageQueue.enqueue(e.data),this.queueRunning||this.runQueue()}},ld=class{relay;id;closed=!1;eosed=!1;filters;alreadyHaveEvent;receivedEvent;onevent;oneose;onclose;eoseTimeout;eoseTimeoutHandle;constructor(e,t,r,n){this.relay=e,this.filters=r,this.id=t,this.alreadyHaveEvent=n.alreadyHaveEvent,this.receivedEvent=n.receivedEvent,this.eoseTimeout=n.eoseTimeout||e.baseEoseTimeout,this.oneose=n.oneose,this.onclose=n.onclose,this.onevent=n.onevent||(o=>{console.warn(`onevent() callback not defined for subscription '${this.id}' in relay ${this.relay.url}. event received:`,o)})}fire(){this.relay.send('["REQ","'+this.id+'",'+JSON.stringify(this.filters).substring(1)),this.eoseTimeoutHandle=setTimeout(this.receivedEose.bind(this),this.eoseTimeout)}receivedEose(){this.eosed||(clearTimeout(this.eoseTimeoutHandle),this.eosed=!0,this.oneose?.())}close(e="closed by caller"){!this.closed&&this.relay.connected&&(this.relay.send('["CLOSE",'+JSON.stringify(this.id)+"]"),this.closed=!0),this.relay.openSubs.delete(this.id),this.onclose?.(e)}},ki;try{ki=WebSocket}catch{}var tr=class extends Si{constructor(e){super(e,{verifyEvent:Xe,websocketImplementation:ki})}static async connect(e){const t=new tr(e);return await t.connect(),t}},cd;try{cd=WebSocket}catch{}var dd={};q(dd,{BECH32_REGEX:()=>Pi,Bech32MaxSize:()=>hn,NostrTypeGuard:()=>ud,decode:()=>er,encodeBytes:()=>nr,naddrEncode:()=>yd,neventEncode:()=>md,noteEncode:()=>gd,nprofileEncode:()=>bd,npubEncode:()=>pd,nsecEncode:()=>fd});var ud={isNProfile:e=>/^nprofile1[a-z\d]+$/.test(e||""),isNEvent:e=>/^nevent1[a-z\d]+$/.test(e||""),isNAddr:e=>/^naddr1[a-z\d]+$/.test(e||""),isNSec:e=>/^nsec1[a-z\d]{58}$/.test(e||""),isNPub:e=>/^npub1[a-z\d]{58}$/.test(e||""),isNote:e=>/^note1[a-z\d]+$/.test(e||""),isNcryptsec:e=>/^ncryptsec1[a-z\d]+$/.test(e||"")},hn=5e3,Pi=/[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;function hd(e){const t=new Uint8Array(4);return t[0]=e>>24&255,t[1]=e>>16&255,t[2]=e>>8&255,t[3]=e&255,t}function er(e){let{prefix:t,words:r}=oe.decode(e,hn),n=new Uint8Array(oe.fromWords(r));switch(t){case"nprofile":{let o=wr(n);if(!o[0]?.[0])throw new Error("missing TLV 0 for nprofile");if(o[0][0].length!==32)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:Y(o[0][0]),relays:o[1]?o[1].map(i=>pt.decode(i)):[]}}}case"nevent":{let o=wr(n);if(!o[0]?.[0])throw new Error("missing TLV 0 for nevent");if(o[0][0].length!==32)throw new Error("TLV 0 should be 32 bytes");if(o[2]&&o[2][0].length!==32)throw new Error("TLV 2 should be 32 bytes");if(o[3]&&o[3][0].length!==4)throw new Error("TLV 3 should be 4 bytes");return{type:"nevent",data:{id:Y(o[0][0]),relays:o[1]?o[1].map(i=>pt.decode(i)):[],author:o[2]?.[0]?Y(o[2][0]):void 0,kind:o[3]?.[0]?parseInt(Y(o[3][0]),16):void 0}}}case"naddr":{let o=wr(n);if(!o[0]?.[0])throw new Error("missing TLV 0 for naddr");if(!o[2]?.[0])throw new Error("missing TLV 2 for naddr");if(o[2][0].length!==32)throw new Error("TLV 2 should be 32 bytes");if(!o[3]?.[0])throw new Error("missing TLV 3 for naddr");if(o[3][0].length!==4)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:pt.decode(o[0][0]),pubkey:Y(o[2][0]),kind:parseInt(Y(o[3][0]),16),relays:o[1]?o[1].map(i=>pt.decode(i)):[]}}}case"nsec":return{type:t,data:n};case"npub":case"note":return{type:t,data:Y(n)};default:throw new Error(`unknown prefix ${t}`)}}function wr(e){let t={},r=e;for(;r.length>0;){let n=r[0],o=r[1],i=r.slice(2,2+o);if(r=r.slice(2+o),i.lengthrt.encode(r))});return rr("nprofile",t)}function md(e){let t;e.kind!==void 0&&(t=hd(e.kind));let r=fn({0:[ne(e.id)],1:(e.relays||[]).map(n=>rt.encode(n)),2:e.author?[ne(e.author)]:[],3:t?[new Uint8Array(t)]:[]});return rr("nevent",r)}function yd(e){let t=new ArrayBuffer(4);new DataView(t).setUint32(0,e.kind,!1);let r=fn({0:[rt.encode(e.identifier)],1:(e.relays||[]).map(n=>rt.encode(n)),2:[ne(e.pubkey)],3:[new Uint8Array(t)]});return rr("naddr",r)}function fn(e){let t=[];return Object.entries(e).reverse().forEach(([r,n])=>{n.forEach(o=>{let i=new Uint8Array(o.length+2);i.set([parseInt(r)],0),i.set([o.length],1),i.set(o,2),t.push(i)})}),Ze(...t)}var wd={};q(wd,{decrypt:()=>vd,encrypt:()=>Ci});async function Ci(e,t,r){const n=e instanceof Uint8Array?Y(e):e,o=se.getSharedSecret(n,"02"+t),i=Bi(o);let s=Uint8Array.from(jo(16)),l=rt.encode(r),a=ti(i,s).encrypt(l),c=bt.encode(new Uint8Array(a)),u=bt.encode(new Uint8Array(s.buffer));return`${c}?iv=${u}`}async function vd(e,t,r){const n=e instanceof Uint8Array?Y(e):e;let[o,i]=r.split("?iv="),s=se.getSharedSecret(n,"02"+t),l=Bi(s),a=bt.decode(i),c=bt.decode(o),u=ti(l,a).decrypt(c);return pt.decode(u)}function Bi(e){return e.slice(1,33)}var xd={};q(xd,{NIP05_REGEX:()=>pn,isNip05:()=>Ed,isValid:()=>Ad,queryProfile:()=>Li,searchDomain:()=>$d,useFetchImplementation:()=>_d});var pn=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,Ed=e=>pn.test(e||""),or;try{or=fetch}catch{}function _d(e){or=e}async function $d(e,t=""){try{const r=`https://${e}/.well-known/nostr.json?name=${t}`,n=await or(r,{redirect:"manual"});if(n.status!==200)throw Error("Wrong response code");return(await n.json()).names}catch{return{}}}async function Li(e){const t=e.match(pn);if(!t)return null;const[,r="_",n]=t;try{const o=`https://${n}/.well-known/nostr.json?name=${r}`,i=await or(o,{redirect:"manual"});if(i.status!==200)throw Error("Wrong response code");const s=await i.json(),l=s.names[r];return l?{pubkey:l,relays:s.relays?.[l]}:null}catch{return null}}async function Ad(e,t){const r=await Li(t);return r?r.pubkey===e:!1}var Sd={};q(Sd,{parse:()=>kd});function kd(e){const t={reply:void 0,root:void 0,mentions:[],profiles:[]},r=[];for(const n of e.tags)n[0]==="e"&&n[1]&&r.push(n),n[0]==="p"&&n[1]&&t.profiles.push({pubkey:n[1],relays:n[2]?[n[2]]:[]});for(let n=0;nBd,useFetchImplementation:()=>Cd});var Ui;try{Ui=fetch}catch{}function Cd(e){Ui=e}async function Bd(e){return await(await fetch(e.replace("ws://","http://").replace("wss://","https://"),{headers:{Accept:"application/nostr+json"}})).json()}var Ld={};q(Ld,{fastEventHash:()=>Ii,getPow:()=>Ti,minePow:()=>Ud});function Ti(e){let t=0;for(let r=0;r<64;r+=8){const n=parseInt(e.substring(r,r+8),16);if(n===0)t+=32;else{t+=Math.clz32(n);break}}return t}function Ud(e,t){let r=0;const n=e,o=["nonce",r.toString(),t.toString()];for(n.tags.push(o);;){const i=Math.floor(new Date().getTime()/1e3);if(i!==n.created_at&&(r=0,n.created_at=i),o[1]=(++r).toString(),n.id=Ii(n),Ti(n.id)>=t)break}return n}function Ii(e){return Y(ae(rt.encode(JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content]))))}var Td={};q(Td,{finishRepostEvent:()=>Id,getRepostedEvent:()=>Md,getRepostedEventPointer:()=>Mi});function Id(e,t,r,n){return dt({kind:cn,tags:[...e.tags??[],["e",t.id,r],["p",t.pubkey]],content:e.content===""?"":JSON.stringify(t),created_at:e.created_at},n)}function Mi(e){if(e.kind!==cn)return;let t,r;for(let n=e.tags.length-1;n>=0&&(t===void 0||r===void 0);n--){const o=e.tags[n];o.length>=2&&(o[0]==="e"&&t===void 0?t=o:o[0]==="p"&&r===void 0&&(r=o))}if(t!==void 0)return{id:t[1],relays:[t[2],r?.[2]].filter(n=>typeof n=="string"),author:r?.[1]}}function Md(e,{skipVerification:t}={}){const r=Mi(e);if(r===void 0||e.content==="")return;let n;try{n=JSON.parse(e.content)}catch{return}if(n.id===r.id&&!(!t&&!Xe(n)))return n}var Rd={};q(Rd,{NOSTR_URI_REGEX:()=>ir,parse:()=>Od,test:()=>Nd});var ir=new RegExp(`nostr:(${Pi.source})`);function Nd(e){return typeof e=="string"&&new RegExp(`^${ir.source}$`).test(e)}function Od(e){const t=e.match(new RegExp(`^${ir.source}$`));if(!t)throw new Error(`Invalid Nostr URI: ${e}`);return{uri:t[0],value:t[1],decoded:er(t[1])}}var Hd={};q(Hd,{finishReactionEvent:()=>zd,getReactedEventPointer:()=>Vd});function zd(e,t,r){const n=t.tags.filter(o=>o.length>=2&&(o[0]==="e"||o[0]==="p"));return dt({...e,kind:dn,tags:[...e.tags??[],...n,["e",t.id],["p",t.pubkey]],content:e.content??"+"},r)}function Vd(e){if(e.kind!==dn)return;let t,r;for(let n=e.tags.length-1;n>=0&&(t===void 0||r===void 0);n--){const o=e.tags[n];o.length>=2&&(o[0]==="e"&&t===void 0?t=o:o[0]==="p"&&r===void 0&&(r=o))}if(!(t===void 0||r===void 0))return{id:t[1],relays:[t[2],r[2]].filter(n=>n!==void 0),author:r[1]}}var Dd={};q(Dd,{matchAll:()=>qd,regex:()=>gn,replaceAll:()=>jd});var gn=()=>new RegExp(`\\b${ir.source}\\b`,"g");function*qd(e){const t=e.matchAll(gn());for(const r of t)try{const[n,o]=r;yield{uri:n,value:o,decoded:er(o),start:r.index,end:r.index+n.length}}catch{}}function jd(e,t){return e.replaceAll(gn(),(r,n)=>t({uri:r,value:n,decoded:er(n)}))}var Fd={};q(Fd,{channelCreateEvent:()=>Wd,channelHideMessageEvent:()=>Gd,channelMessageEvent:()=>Zd,channelMetadataEvent:()=>Kd,channelMuteUserEvent:()=>Jd});var Wd=(e,t)=>{let r;if(typeof e.content=="object")r=JSON.stringify(e.content);else if(typeof e.content=="string")r=e.content;else return;return dt({kind:gi,tags:[...e.tags??[]],content:r,created_at:e.created_at},t)},Kd=(e,t)=>{let r;if(typeof e.content=="object")r=JSON.stringify(e.content);else if(typeof e.content=="string")r=e.content;else return;return dt({kind:bi,tags:[["e",e.channel_create_event_id],...e.tags??[]],content:r,created_at:e.created_at},t)},Zd=(e,t)=>{const r=[["e",e.channel_create_event_id,e.relay_url,"root"]];return e.reply_to_channel_message_event_id&&r.push(["e",e.reply_to_channel_message_event_id,e.relay_url,"reply"]),dt({kind:mi,tags:[...r,...e.tags??[]],content:e.content,created_at:e.created_at},t)},Gd=(e,t)=>{let r;if(typeof e.content=="object")r=JSON.stringify(e.content);else if(typeof e.content=="string")r=e.content;else return;return dt({kind:yi,tags:[["e",e.channel_message_event_id],...e.tags??[]],content:r,created_at:e.created_at},t)},Jd=(e,t)=>{let r;if(typeof e.content=="object")r=JSON.stringify(e.content);else if(typeof e.content=="string")r=e.content;else return;return dt({kind:wi,tags:[["p",e.pubkey_to_mute],...e.tags??[]],content:r,created_at:e.created_at},t)},Yd={};q(Yd,{EMOJI_SHORTCODE_REGEX:()=>Ri,matchAll:()=>Xd,regex:()=>bn,replaceAll:()=>Qd});var Ri=/:(\w+):/,bn=()=>new RegExp(`\\B${Ri.source}\\B`,"g");function*Xd(e){const t=e.matchAll(bn());for(const r of t)try{const[n,o]=r;yield{shortcode:n,name:o,start:r.index,end:r.index+n.length}}catch{}}function Qd(e,t){return e.replaceAll(bn(),(r,n)=>t({shortcode:r,name:n}))}var tu={};q(tu,{useFetchImplementation:()=>eu,validateGithub:()=>ru});var mn;try{mn=fetch}catch{}function eu(e){mn=e}async function ru(e,t,r){try{return await(await mn(`https://gist.github.com/${t}/${r}/raw`)).text()===`Verifying that I control the following Nostr public key: ${e}`}catch{return!1}}var nu={};q(nu,{decrypt:()=>xn,encrypt:()=>vn,getConversationKey:()=>yn,v2:()=>lu});var Ni=1,Oi=65535;function yn(e,t){const r=se.getSharedSecret(e,"02"+t).subarray(1,33);return Bl(ae,r,"nip44-v2")}function Hi(e,t){const r=Ll(ae,e,t,76);return{chacha_key:r.subarray(0,32),chacha_nonce:r.subarray(32,44),hmac_key:r.subarray(44,76)}}function wn(e){if(!Number.isSafeInteger(e)||e<1)throw new Error("expected positive integer");if(e<=32)return 32;const t=1<Oi)throw new Error("invalid plaintext size: must be between 1 and 65535 bytes");const t=new Uint8Array(2);return new DataView(t.buffer).setUint16(0,e,!1),t}function iu(e){const t=rt.encode(e),r=t.length,n=ou(r),o=new Uint8Array(wn(r)-r);return Ze(n,t,o)}function su(e){const t=new DataView(e.buffer).getUint16(0),r=e.subarray(2,2+t);if(tOi||r.length!==t||e.length!==2+wn(t))throw new Error("invalid padding");return pt.decode(r)}function zi(e,t,r){if(r.length!==32)throw new Error("AAD associated data must be 32 bytes");const n=Ze(r,t);return Je(ae,e,n)}function au(e){if(typeof e!="string")throw new Error("payload must be a valid string");const t=e.length;if(t<132||t>87472)throw new Error("invalid payload length: "+t);if(e[0]==="#")throw new Error("unknown encryption version");let r;try{r=bt.decode(e)}catch(i){throw new Error("invalid base64: "+i.message)}const n=r.length;if(n<99||n>65603)throw new Error("invalid data length: "+n);const o=r[0];if(o!==2)throw new Error("unknown encryption version "+o);return{nonce:r.subarray(1,33),ciphertext:r.subarray(33,-32),mac:r.subarray(-32)}}function vn(e,t,r=jo(32)){const{chacha_key:n,chacha_nonce:o,hmac_key:i}=Hi(t,r),s=iu(e),l=oi(n,o,s),a=zi(i,l,r);return bt.encode(Ze(new Uint8Array([2]),r,l,a))}function xn(e,t){const{nonce:r,ciphertext:n,mac:o}=au(e),{chacha_key:i,chacha_nonce:s,hmac_key:l}=Hi(t,r),a=zi(l,n,r);if(!ul(a,o))throw new Error("invalid MAC");const c=oi(i,s,n);return su(c)}var lu={utils:{getConversationKey:yn,calcPaddedLen:wn},encrypt:vn,decrypt:xn},cu={};q(cu,{makeNwcRequestEvent:()=>uu,parseConnectionString:()=>du});function du(e){const{pathname:t,searchParams:r}=new URL(e),n=t,o=r.get("relay"),i=r.get("secret");if(!n||!o||!i)throw new Error("invalid connection string");return{pubkey:n,relay:o,secret:i}}async function uu(e,t,r){const o=await Ci(t,e,JSON.stringify({method:"pay_invoice",params:{invoice:r}})),i={kind:Ei,created_at:Math.round(Date.now()/1e3),content:o,tags:[["p",e]]};return dt(i,t)}var hu={};q(hu,{getZapEndpoint:()=>pu,makeZapReceipt:()=>mu,makeZapRequest:()=>gu,useFetchImplementation:()=>fu,validateZapRequest:()=>bu});var En;try{En=fetch}catch{}function fu(e){En=e}async function pu(e){try{let t="",{lud06:r,lud16:n}=JSON.parse(e.content);if(r){let{words:s}=oe.decode(r,1e3),l=oe.fromWords(s);t=pt.decode(l)}else if(n){let[s,l]=n.split("@");t=new URL(`/.well-known/lnurlp/${s}`,`https://${l}`).toString()}else return null;let i=await(await En(t)).json();if(i.allowsNostr&&i.nostrPubkey)return i.callback}catch{}return null}function gu({profile:e,event:t,amount:r,relays:n,comment:o=""}){if(!r)throw new Error("amount not given");if(!e)throw new Error("profile not given");let i={kind:9734,created_at:Math.round(Date.now()/1e3),content:o,tags:[["p",e],["amount",r.toString()],["relays",...n]]};return t&&i.tags.push(["e",t]),i}function bu(e){let t;try{t=JSON.parse(e)}catch{return"Invalid zap request JSON."}if(!an(t))return"Zap request is not a valid Nostr event.";if(!Xe(t))return"Invalid signature on zap request.";let r=t.tags.find(([i,s])=>i==="p"&&s);if(!r)return"Zap request doesn't have a 'p' tag.";if(!r[1].match(/^[a-f0-9]{64}$/))return"Zap request 'p' tag is not valid hex.";let n=t.tags.find(([i,s])=>i==="e"&&s);return n&&!n[1].match(/^[a-f0-9]{64}$/)?"Zap request 'e' tag is not valid hex.":t.tags.find(([i,s])=>i==="relays"&&s)?null:"Zap request doesn't have a 'relays' tag."}function mu({zapRequest:e,preimage:t,bolt11:r,paidAt:n}){let o=JSON.parse(e),i=o.tags.filter(([l])=>l==="e"||l==="p"||l==="a"),s={kind:9735,created_at:Math.round(n.getTime()/1e3),content:"",tags:[...i,["P",o.pubkey],["bolt11",r],["description",e]]};return t&&s.tags.push(["preimage",t]),s}var yu={};q(yu,{createRumor:()=>Fi,createSeal:()=>Wi,createWrap:()=>Ki,unwrapEvent:()=>Zi,unwrapManyEvents:()=>xu,wrapEvent:()=>Hr,wrapManyEvents:()=>vu});var wu=2*24*60*60,Vi=()=>Math.round(Date.now()/1e3),Di=()=>Math.round(Vi()-Math.random()*wu),qi=(e,t)=>yn(e,t),ji=(e,t,r)=>vn(JSON.stringify(e),qi(t,r)),ao=(e,t)=>JSON.parse(xn(e.content,qi(t,e.pubkey)));function Fi(e,t){const r={created_at:Vi(),content:"",tags:[],...e,pubkey:ci(t)};return r.id=Le(r),r}function Wi(e,t,r){return dt({kind:pi,content:ji(e,t,r),created_at:Di(),tags:[]},t)}function Ki(e,t){const r=Hl();return dt({kind:vi,content:ji(e,r,t),created_at:Di(),tags:[["p",t]]},r)}function Hr(e,t,r){const n=Fi(e,t),o=Wi(n,t,r);return Ki(o,r)}function vu(e,t,r){if(!r||r.length===0)throw new Error("At least one recipient is required.");const n=ci(t),o=[Hr(e,t,n)];return r.forEach(i=>{o.push(Hr(e,t,i))}),o}function Zi(e,t){const r=ao(e,t);return ao(r,t)}function xu(e,t){let r=[];return e.forEach(n=>{r.push(Zi(n,t))}),r.sort((n,o)=>n.created_at-o.created_at),r}var Eu={};q(Eu,{getToken:()=>_u,hashPayload:()=>_n,unpackEventFromToken:()=>Ji,validateEvent:()=>rs,validateEventKind:()=>Xi,validateEventMethodTag:()=>ts,validateEventPayloadTag:()=>es,validateEventTimestamp:()=>Yi,validateEventUrlTag:()=>Qi,validateToken:()=>$u});var Gi="Nostr ";async function _u(e,t,r,n=!1,o){const i={kind:un,tags:[["u",e],["method",t]],created_at:Math.round(new Date().getTime()/1e3),content:""};o&&i.tags.push(["payload",_n(o)]);const s=await r(i);return(n?Gi:"")+bt.encode(rt.encode(JSON.stringify(s)))}async function $u(e,t,r){const n=await Ji(e).catch(i=>{throw i});return await rs(n,t,r).catch(i=>{throw i})}async function Ji(e){if(!e)throw new Error("Missing token");e=e.replace(Gi,"");const t=pt.decode(bt.decode(e));if(!t||t.length===0||!t.startsWith("{"))throw new Error("Invalid token");return JSON.parse(t)}function Yi(e){return e.created_at?Math.round(new Date().getTime()/1e3)-e.created_at<60:!1}function Xi(e){return e.kind===un}function Qi(e,t){const r=e.tags.find(n=>n[0]==="u");return r?r.length>0&&r[1]===t:!1}function ts(e,t){const r=e.tags.find(n=>n[0]==="method");return r?r.length>0&&r[1].toLowerCase()===t.toLowerCase():!1}function _n(e){const t=ae(rt.encode(JSON.stringify(e)));return Y(t)}function es(e,t){const r=e.tags.find(o=>o[0]==="payload");if(!r)return!1;const n=_n(t);return r.length>0&&r[1]===n}async function rs(e,t,r,n){if(!Xe(e))throw new Error("Invalid nostr event, signature invalid");if(!Xi(e))throw new Error("Invalid nostr event, kind invalid");if(!Yi(e))throw new Error("Invalid nostr event, created_at timestamp invalid");if(!Qi(e,t))throw new Error("Invalid nostr event, url tag invalid");if(!ts(e,r))throw new Error("Invalid nostr event, method tag invalid");if(n&&typeof n=="object"&&Object.keys(n).length>0&&!es(e,n))throw new Error("Invalid nostr event, payload tag does not match request body hash");return!0}var Au=ct`
:host {
--border-color: var(--sl-color-neutral-200);
--border-radius: var(--sl-border-radius-medium);
--border-width: 1px;
--padding: var(--sl-spacing-large);
display: inline-block;
}
.card {
display: flex;
flex-direction: column;
background-color: var(--sl-panel-background-color);
box-shadow: var(--sl-shadow-x-small);
border: solid var(--border-width) var(--border-color);
border-radius: var(--border-radius);
}
.card__image {
display: flex;
border-top-left-radius: var(--border-radius);
border-top-right-radius: var(--border-radius);
margin: calc(-1 * var(--border-width));
overflow: hidden;
}
.card__image::slotted(img) {
display: block;
width: 100%;
}
.card:not(.card--has-image) .card__image {
display: none;
}
.card__header {
display: block;
border-bottom: solid var(--border-width) var(--border-color);
padding: calc(var(--padding) / 2) var(--padding);
}
.card:not(.card--has-header) .card__header {
display: none;
}
.card:not(.card--has-image) .card__header {
border-top-left-radius: var(--border-radius);
border-top-right-radius: var(--border-radius);
}
.card__body {
display: block;
padding: var(--padding);
}
.card--has-footer .card__footer {
display: block;
border-top: solid var(--border-width) var(--border-color);
padding: var(--padding);
}
.card:not(.card--has-footer) .card__footer {
display: none;
}
`,ns=class{constructor(e,...t){this.slotNames=[],this.handleSlotChange=r=>{const n=r.target;(this.slotNames.includes("[default]")&&!n.name||n.name&&this.slotNames.includes(n.name))&&this.host.requestUpdate()},(this.host=e).addController(this),this.slotNames=t}hasDefaultSlot(){return[...this.host.childNodes].some(e=>{if(e.nodeType===e.TEXT_NODE&&e.textContent.trim()!=="")return!0;if(e.nodeType===e.ELEMENT_NODE){const t=e;if(t.tagName.toLowerCase()==="sl-visually-hidden")return!1;if(!t.hasAttribute("slot"))return!0}return!1})}hasNamedSlot(e){return this.host.querySelector(`:scope > [slot="${e}"]`)!==null}test(e){return e==="[default]"?this.hasDefaultSlot():this.hasNamedSlot(e)}hostConnected(){this.host.shadowRoot.addEventListener("slotchange",this.handleSlotChange)}hostDisconnected(){this.host.shadowRoot.removeEventListener("slotchange",this.handleSlotChange)}},sr=ct`
:host {
box-sizing: border-box;
}
:host *,
:host *::before,
:host *::after {
box-sizing: inherit;
}
[hidden] {
display: none !important;
}
`,Ue,Mt=class extends gt{constructor(){super(),xs(this,Ue,!1),this.initialReflectedProperties=new Map,Object.entries(this.constructor.dependencies).forEach(([e,t])=>{this.constructor.define(e,t)})}emit(e,t){const r=new CustomEvent(e,_e({bubbles:!0,cancelable:!1,composed:!0,detail:{}},t));return this.dispatchEvent(r),r}static define(e,t=this,r={}){const n=customElements.get(e);if(!n){try{customElements.define(e,t,r)}catch{customElements.define(e,class extends t{},r)}return}let o=" (unknown version)",i=o;"version"in t&&t.version&&(o=" v"+t.version),"version"in n&&n.version&&(i=" v"+n.version),!(o&&i&&o===i)&&console.warn(`Attempted to register <${e}>${o}, but <${e}>${i} has already been registered.`)}attributeChangedCallback(e,t,r){vs(this,Ue)||(this.constructor.elementProperties.forEach((n,o)=>{n.reflect&&this[o]!=null&&this.initialReflectedProperties.set(o,this[o])}),Es(this,Ue,!0)),super.attributeChangedCallback(e,t,r)}willUpdate(e){super.willUpdate(e),this.initialReflectedProperties.forEach((t,r)=>{e.has(r)&&this[r]==null&&(this[r]=t)})}};Ue=new WeakMap;Mt.version="2.18.0";Mt.dependencies={};T([S()],Mt.prototype,"dir",2);T([S()],Mt.prototype,"lang",2);/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const Su={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},ku=e=>(...t)=>({_$litDirective$:e,values:t});let Pu=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,r,n){this._$Ct=t,this._$AM=r,this._$Ci=n}_$AS(t,r){return this.update(t,r)}update(t,r){return this.render(...r)}};/**
* @license
* Copyright 2018 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const os=ku(class extends Pu{constructor(e){if(super(e),e.type!==Su.ATTRIBUTE||e.name!=="class"||e.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(e){return" "+Object.keys(e).filter(t=>e[t]).join(" ")+" "}update(e,[t]){if(this.st===void 0){this.st=new Set,e.strings!==void 0&&(this.nt=new Set(e.strings.join(" ").split(/\s/).filter(n=>n!=="")));for(const n in t)t[n]&&!this.nt?.has(n)&&this.st.add(n);return this.render(t)}const r=e.element.classList;for(const n of this.st)n in t||(r.remove(n),this.st.delete(n));for(const n in t){const o=!!t[n];o===this.st.has(n)||this.nt?.has(n)||(o?(r.add(n),this.st.add(n)):(r.remove(n),this.st.delete(n)))}return jt}});var is=class extends Mt{constructor(){super(...arguments),this.hasSlotController=new ns(this,"footer","header","image")}render(){return G`
`}};is.styles=[sr,Au];is.define("sl-card");var Cu=ct`
:host {
--track-width: 2px;
--track-color: rgb(128 128 128 / 25%);
--indicator-color: var(--sl-color-primary-600);
--speed: 2s;
display: inline-flex;
width: 1em;
height: 1em;
flex: none;
}
.spinner {
flex: 1 1 auto;
height: 100%;
width: 100%;
}
.spinner__track,
.spinner__indicator {
fill: none;
stroke-width: var(--track-width);
r: calc(0.5em - var(--track-width) / 2);
cx: 0.5em;
cy: 0.5em;
transform-origin: 50% 50%;
}
.spinner__track {
stroke: var(--track-color);
transform-origin: 0% 0%;
}
.spinner__indicator {
stroke: var(--indicator-color);
stroke-linecap: round;
stroke-dasharray: 150% 75%;
animation: spin var(--speed) linear infinite;
}
@keyframes spin {
0% {
transform: rotate(0deg);
stroke-dasharray: 0.05em, 3em;
}
50% {
transform: rotate(450deg);
stroke-dasharray: 1.375em, 1.375em;
}
100% {
transform: rotate(1080deg);
stroke-dasharray: 0.05em, 3em;
}
}
`;const zr=new Set,Qt=new Map;let zt,$n="ltr",An="en";const ss=typeof MutationObserver<"u"&&typeof document<"u"&&typeof document.documentElement<"u";if(ss){const e=new MutationObserver(ls);$n=document.documentElement.dir||"ltr",An=document.documentElement.lang||navigator.language,e.observe(document.documentElement,{attributes:!0,attributeFilter:["dir","lang"]})}function as(...e){e.map(t=>{const r=t.$code.toLowerCase();Qt.has(r)?Qt.set(r,Object.assign(Object.assign({},Qt.get(r)),t)):Qt.set(r,t),zt||(zt=t)}),ls()}function ls(){ss&&($n=document.documentElement.dir||"ltr",An=document.documentElement.lang||navigator.language),[...zr.keys()].map(e=>{typeof e.requestUpdate=="function"&&e.requestUpdate()})}let Bu=class{constructor(t){this.host=t,this.host.addController(this)}hostConnected(){zr.add(this.host)}hostDisconnected(){zr.delete(this.host)}dir(){return`${this.host.dir||$n}`.toLowerCase()}lang(){return`${this.host.lang||An}`.toLowerCase()}getTranslationData(t){var r,n;const o=new Intl.Locale(t.replace(/_/g,"-")),i=o?.language.toLowerCase(),s=(n=(r=o?.region)===null||r===void 0?void 0:r.toLowerCase())!==null&&n!==void 0?n:"",l=Qt.get(`${i}-${s}`),a=Qt.get(i);return{locale:o,language:i,region:s,primary:l,secondary:a}}exists(t,r){var n;const{primary:o,secondary:i}=this.getTranslationData((n=r.lang)!==null&&n!==void 0?n:this.lang());return r=Object.assign({includeFallback:!1},r),!!(o&&o[t]||i&&i[t]||r.includeFallback&&zt&&zt[t])}term(t,...r){const{primary:n,secondary:o}=this.getTranslationData(this.lang());let i;if(n&&n[t])i=n[t];else if(o&&o[t])i=o[t];else if(zt&&zt[t])i=zt[t];else return console.error(`No translation found for: ${String(t)}`),String(t);return typeof i=="function"?i(...r):i}date(t,r){return t=new Date(t),new Intl.DateTimeFormat(this.lang(),r).format(t)}number(t,r){return t=Number(t),isNaN(t)?"":new Intl.NumberFormat(this.lang(),r).format(t)}relativeTime(t,r,n){return new Intl.RelativeTimeFormat(this.lang(),n).format(t,r)}};var cs={$code:"en",$name:"English",$dir:"ltr",carousel:"Carousel",clearEntry:"Clear entry",close:"Close",copied:"Copied",copy:"Copy",currentValue:"Current value",error:"Error",goToSlide:(e,t)=>`Go to slide ${e} of ${t}`,hidePassword:"Hide password",loading:"Loading",nextSlide:"Next slide",numOptionsSelected:e=>e===0?"No options selected":e===1?"1 option selected":`${e} options selected`,previousSlide:"Previous slide",progress:"Progress",remove:"Remove",resize:"Resize",scrollToEnd:"Scroll to end",scrollToStart:"Scroll to start",selectAColorFromTheScreen:"Select a color from the screen",showPassword:"Show password",slideNum:e=>`Slide ${e}`,toggleColorFormat:"Toggle color format"};as(cs);var Lu=cs,ds=class extends Bu{};as(Lu);var us=class extends Mt{constructor(){super(...arguments),this.localize=new ds(this)}render(){return G`
`}};us.styles=[sr,Cu];var fe=new WeakMap,pe=new WeakMap,ge=new WeakMap,vr=new WeakSet,Pe=new WeakMap,Uu=class{constructor(e,t){this.handleFormData=r=>{const n=this.options.disabled(this.host),o=this.options.name(this.host),i=this.options.value(this.host),s=this.host.tagName.toLowerCase()==="sl-button";this.host.isConnected&&!n&&!s&&typeof o=="string"&&o.length>0&&typeof i<"u"&&(Array.isArray(i)?i.forEach(l=>{r.formData.append(o,l.toString())}):r.formData.append(o,i.toString()))},this.handleFormSubmit=r=>{var n;const o=this.options.disabled(this.host),i=this.options.reportValidity;this.form&&!this.form.noValidate&&((n=fe.get(this.form))==null||n.forEach(s=>{this.setUserInteracted(s,!0)})),this.form&&!this.form.noValidate&&!o&&!i(this.host)&&(r.preventDefault(),r.stopImmediatePropagation())},this.handleFormReset=()=>{this.options.setValue(this.host,this.options.defaultValue(this.host)),this.setUserInteracted(this.host,!1),Pe.set(this.host,[])},this.handleInteraction=r=>{const n=Pe.get(this.host);n.includes(r.type)||n.push(r.type),n.length===this.options.assumeInteractionOn.length&&this.setUserInteracted(this.host,!0)},this.checkFormValidity=()=>{if(this.form&&!this.form.noValidate){const r=this.form.querySelectorAll("*");for(const n of r)if(typeof n.checkValidity=="function"&&!n.checkValidity())return!1}return!0},this.reportFormValidity=()=>{if(this.form&&!this.form.noValidate){const r=this.form.querySelectorAll("*");for(const n of r)if(typeof n.reportValidity=="function"&&!n.reportValidity())return!1}return!0},(this.host=e).addController(this),this.options=_e({form:r=>{const n=r.form;if(n){const i=r.getRootNode().querySelector(`#${n}`);if(i)return i}return r.closest("form")},name:r=>r.name,value:r=>r.value,defaultValue:r=>r.defaultValue,disabled:r=>{var n;return(n=r.disabled)!=null?n:!1},reportValidity:r=>typeof r.reportValidity=="function"?r.reportValidity():!0,checkValidity:r=>typeof r.checkValidity=="function"?r.checkValidity():!0,setValue:(r,n)=>r.value=n,assumeInteractionOn:["sl-input"]},t)}hostConnected(){const e=this.options.form(this.host);e&&this.attachForm(e),Pe.set(this.host,[]),this.options.assumeInteractionOn.forEach(t=>{this.host.addEventListener(t,this.handleInteraction)})}hostDisconnected(){this.detachForm(),Pe.delete(this.host),this.options.assumeInteractionOn.forEach(e=>{this.host.removeEventListener(e,this.handleInteraction)})}hostUpdated(){const e=this.options.form(this.host);e||this.detachForm(),e&&this.form!==e&&(this.detachForm(),this.attachForm(e)),this.host.hasUpdated&&this.setValidity(this.host.validity.valid)}attachForm(e){e?(this.form=e,fe.has(this.form)?fe.get(this.form).add(this.host):fe.set(this.form,new Set([this.host])),this.form.addEventListener("formdata",this.handleFormData),this.form.addEventListener("submit",this.handleFormSubmit),this.form.addEventListener("reset",this.handleFormReset),pe.has(this.form)||(pe.set(this.form,this.form.reportValidity),this.form.reportValidity=()=>this.reportFormValidity()),ge.has(this.form)||(ge.set(this.form,this.form.checkValidity),this.form.checkValidity=()=>this.checkFormValidity())):this.form=void 0}detachForm(){if(!this.form)return;const e=fe.get(this.form);e&&(e.delete(this.host),e.size<=0&&(this.form.removeEventListener("formdata",this.handleFormData),this.form.removeEventListener("submit",this.handleFormSubmit),this.form.removeEventListener("reset",this.handleFormReset),pe.has(this.form)&&(this.form.reportValidity=pe.get(this.form),pe.delete(this.form)),ge.has(this.form)&&(this.form.checkValidity=ge.get(this.form),ge.delete(this.form)),this.form=void 0))}setUserInteracted(e,t){t?vr.add(e):vr.delete(e),e.requestUpdate()}doAction(e,t){if(this.form){const r=document.createElement("button");r.type=e,r.style.position="absolute",r.style.width="0",r.style.height="0",r.style.clipPath="inset(50%)",r.style.overflow="hidden",r.style.whiteSpace="nowrap",t&&(r.name=t.name,r.value=t.value,["formaction","formenctype","formmethod","formnovalidate","formtarget"].forEach(n=>{t.hasAttribute(n)&&r.setAttribute(n,t.getAttribute(n))})),this.form.append(r),r.click(),r.remove()}}getForm(){var e;return(e=this.form)!=null?e:null}reset(e){this.doAction("reset",e)}submit(e){this.doAction("submit",e)}setValidity(e){const t=this.host,r=!!vr.has(t),n=!!t.required;t.toggleAttribute("data-required",n),t.toggleAttribute("data-optional",!n),t.toggleAttribute("data-invalid",!e),t.toggleAttribute("data-valid",e),t.toggleAttribute("data-user-invalid",!e&&r),t.toggleAttribute("data-user-valid",e&&r)}updateValidity(){const e=this.host;this.setValidity(e.validity.valid)}emitInvalidEvent(e){const t=new CustomEvent("sl-invalid",{bubbles:!1,composed:!1,cancelable:!0,detail:{}});e||t.preventDefault(),this.host.dispatchEvent(t)||e?.preventDefault()}},Sn=Object.freeze({badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:!0,valueMissing:!1});Object.freeze(bo(_e({},Sn),{valid:!1,valueMissing:!0}));Object.freeze(bo(_e({},Sn),{valid:!1,customError:!0}));var Tu=ct`
:host {
display: inline-block;
position: relative;
width: auto;
cursor: pointer;
}
.button {
display: inline-flex;
align-items: stretch;
justify-content: center;
width: 100%;
border-style: solid;
border-width: var(--sl-input-border-width);
font-family: var(--sl-input-font-family);
font-weight: var(--sl-font-weight-semibold);
text-decoration: none;
user-select: none;
-webkit-user-select: none;
white-space: nowrap;
vertical-align: middle;
padding: 0;
transition:
var(--sl-transition-x-fast) background-color,
var(--sl-transition-x-fast) color,
var(--sl-transition-x-fast) border,
var(--sl-transition-x-fast) box-shadow;
cursor: inherit;
}
.button::-moz-focus-inner {
border: 0;
}
.button:focus {
outline: none;
}
.button:focus-visible {
outline: var(--sl-focus-ring);
outline-offset: var(--sl-focus-ring-offset);
}
.button--disabled {
opacity: 0.5;
cursor: not-allowed;
}
/* When disabled, prevent mouse events from bubbling up from children */
.button--disabled * {
pointer-events: none;
}
.button__prefix,
.button__suffix {
flex: 0 0 auto;
display: flex;
align-items: center;
pointer-events: none;
}
.button__label {
display: inline-block;
}
.button__label::slotted(sl-icon) {
vertical-align: -2px;
}
/*
* Standard buttons
*/
/* Default */
.button--standard.button--default {
background-color: var(--sl-color-neutral-0);
border-color: var(--sl-input-border-color);
color: var(--sl-color-neutral-700);
}
.button--standard.button--default:hover:not(.button--disabled) {
background-color: var(--sl-color-primary-50);
border-color: var(--sl-color-primary-300);
color: var(--sl-color-primary-700);
}
.button--standard.button--default:active:not(.button--disabled) {
background-color: var(--sl-color-primary-100);
border-color: var(--sl-color-primary-400);
color: var(--sl-color-primary-700);
}
/* Primary */
.button--standard.button--primary {
background-color: var(--sl-color-primary-600);
border-color: var(--sl-color-primary-600);
color: var(--sl-color-neutral-0);
}
.button--standard.button--primary:hover:not(.button--disabled) {
background-color: var(--sl-color-primary-500);
border-color: var(--sl-color-primary-500);
color: var(--sl-color-neutral-0);
}
.button--standard.button--primary:active:not(.button--disabled) {
background-color: var(--sl-color-primary-600);
border-color: var(--sl-color-primary-600);
color: var(--sl-color-neutral-0);
}
/* Success */
.button--standard.button--success {
background-color: var(--sl-color-success-600);
border-color: var(--sl-color-success-600);
color: var(--sl-color-neutral-0);
}
.button--standard.button--success:hover:not(.button--disabled) {
background-color: var(--sl-color-success-500);
border-color: var(--sl-color-success-500);
color: var(--sl-color-neutral-0);
}
.button--standard.button--success:active:not(.button--disabled) {
background-color: var(--sl-color-success-600);
border-color: var(--sl-color-success-600);
color: var(--sl-color-neutral-0);
}
/* Neutral */
.button--standard.button--neutral {
background-color: var(--sl-color-neutral-600);
border-color: var(--sl-color-neutral-600);
color: var(--sl-color-neutral-0);
}
.button--standard.button--neutral:hover:not(.button--disabled) {
background-color: var(--sl-color-neutral-500);
border-color: var(--sl-color-neutral-500);
color: var(--sl-color-neutral-0);
}
.button--standard.button--neutral:active:not(.button--disabled) {
background-color: var(--sl-color-neutral-600);
border-color: var(--sl-color-neutral-600);
color: var(--sl-color-neutral-0);
}
/* Warning */
.button--standard.button--warning {
background-color: var(--sl-color-warning-600);
border-color: var(--sl-color-warning-600);
color: var(--sl-color-neutral-0);
}
.button--standard.button--warning:hover:not(.button--disabled) {
background-color: var(--sl-color-warning-500);
border-color: var(--sl-color-warning-500);
color: var(--sl-color-neutral-0);
}
.button--standard.button--warning:active:not(.button--disabled) {
background-color: var(--sl-color-warning-600);
border-color: var(--sl-color-warning-600);
color: var(--sl-color-neutral-0);
}
/* Danger */
.button--standard.button--danger {
background-color: var(--sl-color-danger-600);
border-color: var(--sl-color-danger-600);
color: var(--sl-color-neutral-0);
}
.button--standard.button--danger:hover:not(.button--disabled) {
background-color: var(--sl-color-danger-500);
border-color: var(--sl-color-danger-500);
color: var(--sl-color-neutral-0);
}
.button--standard.button--danger:active:not(.button--disabled) {
background-color: var(--sl-color-danger-600);
border-color: var(--sl-color-danger-600);
color: var(--sl-color-neutral-0);
}
/*
* Outline buttons
*/
.button--outline {
background: none;
border: solid 1px;
}
/* Default */
.button--outline.button--default {
border-color: var(--sl-input-border-color);
color: var(--sl-color-neutral-700);
}
.button--outline.button--default:hover:not(.button--disabled),
.button--outline.button--default.button--checked:not(.button--disabled) {
border-color: var(--sl-color-primary-600);
background-color: var(--sl-color-primary-600);
color: var(--sl-color-neutral-0);
}
.button--outline.button--default:active:not(.button--disabled) {
border-color: var(--sl-color-primary-700);
background-color: var(--sl-color-primary-700);
color: var(--sl-color-neutral-0);
}
/* Primary */
.button--outline.button--primary {
border-color: var(--sl-color-primary-600);
color: var(--sl-color-primary-600);
}
.button--outline.button--primary:hover:not(.button--disabled),
.button--outline.button--primary.button--checked:not(.button--disabled) {
background-color: var(--sl-color-primary-600);
color: var(--sl-color-neutral-0);
}
.button--outline.button--primary:active:not(.button--disabled) {
border-color: var(--sl-color-primary-700);
background-color: var(--sl-color-primary-700);
color: var(--sl-color-neutral-0);
}
/* Success */
.button--outline.button--success {
border-color: var(--sl-color-success-600);
color: var(--sl-color-success-600);
}
.button--outline.button--success:hover:not(.button--disabled),
.button--outline.button--success.button--checked:not(.button--disabled) {
background-color: var(--sl-color-success-600);
color: var(--sl-color-neutral-0);
}
.button--outline.button--success:active:not(.button--disabled) {
border-color: var(--sl-color-success-700);
background-color: var(--sl-color-success-700);
color: var(--sl-color-neutral-0);
}
/* Neutral */
.button--outline.button--neutral {
border-color: var(--sl-color-neutral-600);
color: var(--sl-color-neutral-600);
}
.button--outline.button--neutral:hover:not(.button--disabled),
.button--outline.button--neutral.button--checked:not(.button--disabled) {
background-color: var(--sl-color-neutral-600);
color: var(--sl-color-neutral-0);
}
.button--outline.button--neutral:active:not(.button--disabled) {
border-color: var(--sl-color-neutral-700);
background-color: var(--sl-color-neutral-700);
color: var(--sl-color-neutral-0);
}
/* Warning */
.button--outline.button--warning {
border-color: var(--sl-color-warning-600);
color: var(--sl-color-warning-600);
}
.button--outline.button--warning:hover:not(.button--disabled),
.button--outline.button--warning.button--checked:not(.button--disabled) {
background-color: var(--sl-color-warning-600);
color: var(--sl-color-neutral-0);
}
.button--outline.button--warning:active:not(.button--disabled) {
border-color: var(--sl-color-warning-700);
background-color: var(--sl-color-warning-700);
color: var(--sl-color-neutral-0);
}
/* Danger */
.button--outline.button--danger {
border-color: var(--sl-color-danger-600);
color: var(--sl-color-danger-600);
}
.button--outline.button--danger:hover:not(.button--disabled),
.button--outline.button--danger.button--checked:not(.button--disabled) {
background-color: var(--sl-color-danger-600);
color: var(--sl-color-neutral-0);
}
.button--outline.button--danger:active:not(.button--disabled) {
border-color: var(--sl-color-danger-700);
background-color: var(--sl-color-danger-700);
color: var(--sl-color-neutral-0);
}
@media (forced-colors: active) {
.button.button--outline.button--checked:not(.button--disabled) {
outline: solid 2px transparent;
}
}
/*
* Text buttons
*/
.button--text {
background-color: transparent;
border-color: transparent;
color: var(--sl-color-primary-600);
}
.button--text:hover:not(.button--disabled) {
background-color: transparent;
border-color: transparent;
color: var(--sl-color-primary-500);
}
.button--text:focus-visible:not(.button--disabled) {
background-color: transparent;
border-color: transparent;
color: var(--sl-color-primary-500);
}
.button--text:active:not(.button--disabled) {
background-color: transparent;
border-color: transparent;
color: var(--sl-color-primary-700);
}
/*
* Size modifiers
*/
.button--small {
height: auto;
min-height: var(--sl-input-height-small);
font-size: var(--sl-button-font-size-small);
line-height: calc(var(--sl-input-height-small) - var(--sl-input-border-width) * 2);
border-radius: var(--sl-input-border-radius-small);
}
.button--medium {
height: auto;
min-height: var(--sl-input-height-medium);
font-size: var(--sl-button-font-size-medium);
line-height: calc(var(--sl-input-height-medium) - var(--sl-input-border-width) * 2);
border-radius: var(--sl-input-border-radius-medium);
}
.button--large {
height: auto;
min-height: var(--sl-input-height-large);
font-size: var(--sl-button-font-size-large);
line-height: calc(var(--sl-input-height-large) - var(--sl-input-border-width) * 2);
border-radius: var(--sl-input-border-radius-large);
}
/*
* Pill modifier
*/
.button--pill.button--small {
border-radius: var(--sl-input-height-small);
}
.button--pill.button--medium {
border-radius: var(--sl-input-height-medium);
}
.button--pill.button--large {
border-radius: var(--sl-input-height-large);
}
/*
* Circle modifier
*/
.button--circle {
padding-left: 0;
padding-right: 0;
}
.button--circle.button--small {
width: var(--sl-input-height-small);
border-radius: 50%;
}
.button--circle.button--medium {
width: var(--sl-input-height-medium);
border-radius: 50%;
}
.button--circle.button--large {
width: var(--sl-input-height-large);
border-radius: 50%;
}
.button--circle .button__prefix,
.button--circle .button__suffix,
.button--circle .button__caret {
display: none;
}
/*
* Caret modifier
*/
.button--caret .button__suffix {
display: none;
}
.button--caret .button__caret {
height: auto;
}
/*
* Loading modifier
*/
.button--loading {
position: relative;
cursor: wait;
}
.button--loading .button__prefix,
.button--loading .button__label,
.button--loading .button__suffix,
.button--loading .button__caret {
visibility: hidden;
}
.button--loading sl-spinner {
--indicator-color: currentColor;
position: absolute;
font-size: 1em;
height: 1em;
width: 1em;
top: calc(50% - 0.5em);
left: calc(50% - 0.5em);
}
/*
* Badges
*/
.button ::slotted(sl-badge) {
position: absolute;
top: 0;
right: 0;
translate: 50% -50%;
pointer-events: none;
}
.button--rtl ::slotted(sl-badge) {
right: auto;
left: 0;
translate: -50% -50%;
}
/*
* Button spacing
*/
.button--has-label.button--small .button__label {
padding: 0 var(--sl-spacing-small);
}
.button--has-label.button--medium .button__label {
padding: 0 var(--sl-spacing-medium);
}
.button--has-label.button--large .button__label {
padding: 0 var(--sl-spacing-large);
}
.button--has-prefix.button--small {
padding-inline-start: var(--sl-spacing-x-small);
}
.button--has-prefix.button--small .button__label {
padding-inline-start: var(--sl-spacing-x-small);
}
.button--has-prefix.button--medium {
padding-inline-start: var(--sl-spacing-small);
}
.button--has-prefix.button--medium .button__label {
padding-inline-start: var(--sl-spacing-small);
}
.button--has-prefix.button--large {
padding-inline-start: var(--sl-spacing-small);
}
.button--has-prefix.button--large .button__label {
padding-inline-start: var(--sl-spacing-small);
}
.button--has-suffix.button--small,
.button--caret.button--small {
padding-inline-end: var(--sl-spacing-x-small);
}
.button--has-suffix.button--small .button__label,
.button--caret.button--small .button__label {
padding-inline-end: var(--sl-spacing-x-small);
}
.button--has-suffix.button--medium,
.button--caret.button--medium {
padding-inline-end: var(--sl-spacing-small);
}
.button--has-suffix.button--medium .button__label,
.button--caret.button--medium .button__label {
padding-inline-end: var(--sl-spacing-small);
}
.button--has-suffix.button--large,
.button--caret.button--large {
padding-inline-end: var(--sl-spacing-small);
}
.button--has-suffix.button--large .button__label,
.button--caret.button--large .button__label {
padding-inline-end: var(--sl-spacing-small);
}
/*
* Button groups support a variety of button types (e.g. buttons with tooltips, buttons as dropdown triggers, etc.).
* This means buttons aren't always direct descendants of the button group, thus we can't target them with the
* ::slotted selector. To work around this, the button group component does some magic to add these special classes to
* buttons and we style them here instead.
*/
:host([data-sl-button-group__button--first]:not([data-sl-button-group__button--last])) .button {
border-start-end-radius: 0;
border-end-end-radius: 0;
}
:host([data-sl-button-group__button--inner]) .button {
border-radius: 0;
}
:host([data-sl-button-group__button--last]:not([data-sl-button-group__button--first])) .button {
border-start-start-radius: 0;
border-end-start-radius: 0;
}
/* All except the first */
:host([data-sl-button-group__button]:not([data-sl-button-group__button--first])) {
margin-inline-start: calc(-1 * var(--sl-input-border-width));
}
/* Add a visual separator between solid buttons */
:host(
[data-sl-button-group__button]:not(
[data-sl-button-group__button--first],
[data-sl-button-group__button--radio],
[variant='default']
):not(:hover)
)
.button:after {
content: '';
position: absolute;
top: 0;
inset-inline-start: 0;
bottom: 0;
border-left: solid 1px rgb(128 128 128 / 33%);
mix-blend-mode: multiply;
}
/* Bump hovered, focused, and checked buttons up so their focus ring isn't clipped */
:host([data-sl-button-group__button--hover]) {
z-index: 1;
}
/* Focus and checked are always on top */
:host([data-sl-button-group__button--focus]),
:host([data-sl-button-group__button][checked]) {
z-index: 2;
}
`,Iu={name:"default",resolver:e=>ps(`assets/icons/${e}.svg`)},Mu=Iu,lo={caret:`
`,check:`
`,"chevron-down":`
`,"chevron-left":`
`,"chevron-right":`
`,copy:`
`,eye:`
`,"eye-slash":`
`,eyedropper:`
`,"grip-vertical":`
`,indeterminate:`
`,"person-fill":`
`,"play-fill":`
`,"pause-fill":`
`,radio:`
`,"star-fill":`
`,"x-lg":`
`,"x-circle-fill":`
`},Ru={name:"system",resolver:e=>e in lo?`data:image/svg+xml,${encodeURIComponent(lo[e])}`:""},Nu=Ru,Ou=[Mu,Nu],Vr=[];function Hu(e){Vr.push(e)}function zu(e){Vr=Vr.filter(t=>t!==e)}function co(e){return Ou.find(t=>t.name===e)}var Vu=ct`
:host {
display: inline-block;
width: 1em;
height: 1em;
box-sizing: content-box !important;
}
svg {
display: block;
height: 100%;
width: 100%;
}
`;function kn(e,t){const r=_e({waitUntilFirstUpdate:!1},t);return(n,o)=>{const{update:i}=n,s=Array.isArray(e)?e:[e];n.update=function(l){s.forEach(a=>{const c=a;if(l.has(c)){const u=l.get(c),d=this[c];u!==d&&(!r.waitUntilFirstUpdate||this.hasUpdated)&&this[o](u,d)}}),i.call(this,l)}}}/**
* @license
* Copyright 2020 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const Du=(e,t)=>e?._$litType$!==void 0;var be=Symbol(),Ce=Symbol(),xr,Er=new Map,xt=class extends Mt{constructor(){super(...arguments),this.initialRender=!1,this.svg=null,this.label="",this.library="default"}async resolveIcon(e,t){var r;let n;if(t?.spriteSheet)return this.svg=G``,this.svg;try{if(n=await fetch(e,{mode:"cors"}),!n.ok)return n.status===410?be:Ce}catch{return Ce}try{const o=document.createElement("div");o.innerHTML=await n.text();const i=o.firstElementChild;if(((r=i?.tagName)==null?void 0:r.toLowerCase())!=="svg")return be;xr||(xr=new DOMParser);const l=xr.parseFromString(i.outerHTML,"text/html").body.querySelector("svg");return l?(l.part.add("svg"),document.adoptNode(l)):be}catch{return be}}connectedCallback(){super.connectedCallback(),Hu(this)}firstUpdated(){this.initialRender=!0,this.setIcon()}disconnectedCallback(){super.disconnectedCallback(),zu(this)}getIconSource(){const e=co(this.library);return this.name&&e?{url:e.resolver(this.name),fromLibrary:!0}:{url:this.src,fromLibrary:!1}}handleLabelChange(){typeof this.label=="string"&&this.label.length>0?(this.setAttribute("role","img"),this.setAttribute("aria-label",this.label),this.removeAttribute("aria-hidden")):(this.removeAttribute("role"),this.removeAttribute("aria-label"),this.setAttribute("aria-hidden","true"))}async setIcon(){var e;const{url:t,fromLibrary:r}=this.getIconSource(),n=r?co(this.library):void 0;if(!t){this.svg=null;return}let o=Er.get(t);if(o||(o=this.resolveIcon(t,n),Er.set(t,o)),!this.initialRender)return;const i=await o;if(i===Ce&&Er.delete(t),t===this.getIconSource().url){if(Du(i)){if(this.svg=i,n){await this.updateComplete;const s=this.shadowRoot.querySelector("[part='svg']");typeof n.mutator=="function"&&s&&n.mutator(s)}return}switch(i){case Ce:case be:this.svg=null,this.emit("sl-error");break;default:this.svg=i.cloneNode(!0),(e=n?.mutator)==null||e.call(n,this.svg),this.emit("sl-load")}}}render(){return this.svg}};xt.styles=[sr,Vu];T([Zr()],xt.prototype,"svg",2);T([S({reflect:!0})],xt.prototype,"name",2);T([S()],xt.prototype,"src",2);T([S()],xt.prototype,"label",2);T([S({reflect:!0})],xt.prototype,"library",2);T([kn("label")],xt.prototype,"handleLabelChange",1);T([kn(["name","src","library"])],xt.prototype,"setIcon",1);/**
* @license
* Copyright 2020 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const hs=Symbol.for(""),qu=e=>{if(e?.r===hs)return e?._$litStatic$},uo=(e,...t)=>({_$litStatic$:t.reduce((r,n,o)=>r+(i=>{if(i._$litStatic$!==void 0)return i._$litStatic$;throw Error(`Value passed to 'literal' function must be a 'literal' result: ${i}. Use 'unsafeStatic' to pass non-literal values, but
take care to ensure page security.`)})(n)+e[o+1],e[0]),r:hs}),ho=new Map,ju=e=>(t,...r)=>{const n=r.length;let o,i;const s=[],l=[];let a,c=0,u=!1;for(;ce??F;var N=class extends Mt{constructor(){super(...arguments),this.formControlController=new Uu(this,{assumeInteractionOn:["click"]}),this.hasSlotController=new ns(this,"[default]","prefix","suffix"),this.localize=new ds(this),this.hasFocus=!1,this.invalid=!1,this.title="",this.variant="default",this.size="medium",this.caret=!1,this.disabled=!1,this.loading=!1,this.outline=!1,this.pill=!1,this.circle=!1,this.type="button",this.name="",this.value="",this.href="",this.rel="noreferrer noopener"}get validity(){return this.isButton()?this.button.validity:Sn}get validationMessage(){return this.isButton()?this.button.validationMessage:""}firstUpdated(){this.isButton()&&this.formControlController.updateValidity()}handleBlur(){this.hasFocus=!1,this.emit("sl-blur")}handleFocus(){this.hasFocus=!0,this.emit("sl-focus")}handleClick(){this.type==="submit"&&this.formControlController.submit(this),this.type==="reset"&&this.formControlController.reset(this)}handleInvalid(e){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(e)}isButton(){return!this.href}isLink(){return!!this.href}handleDisabledChange(){this.isButton()&&this.formControlController.setValidity(this.disabled)}click(){this.button.click()}focus(e){this.button.focus(e)}blur(){this.button.blur()}checkValidity(){return this.isButton()?this.button.checkValidity():!0}getForm(){return this.formControlController.getForm()}reportValidity(){return this.isButton()?this.button.reportValidity():!0}setCustomValidity(e){this.isButton()&&(this.button.setCustomValidity(e),this.formControlController.updateValidity())}render(){const e=this.isLink(),t=e?uo`a`:uo`button`;return _r`
<${t}
part="base"
class=${os({button:!0,"button--default":this.variant==="default","button--primary":this.variant==="primary","button--success":this.variant==="success","button--neutral":this.variant==="neutral","button--warning":this.variant==="warning","button--danger":this.variant==="danger","button--text":this.variant==="text","button--small":this.size==="small","button--medium":this.size==="medium","button--large":this.size==="large","button--caret":this.caret,"button--circle":this.circle,"button--disabled":this.disabled,"button--focused":this.hasFocus,"button--loading":this.loading,"button--standard":!this.outline,"button--outline":this.outline,"button--pill":this.pill,"button--rtl":this.localize.dir()==="rtl","button--has-label":this.hasSlotController.test("[default]"),"button--has-prefix":this.hasSlotController.test("prefix"),"button--has-suffix":this.hasSlotController.test("suffix")})}
?disabled=${ut(e?void 0:this.disabled)}
type=${ut(e?void 0:this.type)}
title=${this.title}
name=${ut(e?void 0:this.name)}
value=${ut(e?void 0:this.value)}
href=${ut(e&&!this.disabled?this.href:void 0)}
target=${ut(e?this.target:void 0)}
download=${ut(e?this.download:void 0)}
rel=${ut(e?this.rel:void 0)}
role=${ut(e?void 0:"button")}
aria-disabled=${this.disabled?"true":"false"}
tabindex=${this.disabled?"-1":"0"}
@blur=${this.handleBlur}
@focus=${this.handleFocus}
@invalid=${this.isButton()?this.handleInvalid:null}
@click=${this.handleClick}
>
${this.caret?_r` `:""}
${this.loading?_r``:""}
${t}>
`}};N.styles=[sr,Tu];N.dependencies={"sl-icon":xt,"sl-spinner":us};T([Zs(".button")],N.prototype,"button",2);T([Zr()],N.prototype,"hasFocus",2);T([Zr()],N.prototype,"invalid",2);T([S()],N.prototype,"title",2);T([S({reflect:!0})],N.prototype,"variant",2);T([S({reflect:!0})],N.prototype,"size",2);T([S({type:Boolean,reflect:!0})],N.prototype,"caret",2);T([S({type:Boolean,reflect:!0})],N.prototype,"disabled",2);T([S({type:Boolean,reflect:!0})],N.prototype,"loading",2);T([S({type:Boolean,reflect:!0})],N.prototype,"outline",2);T([S({type:Boolean,reflect:!0})],N.prototype,"pill",2);T([S({type:Boolean,reflect:!0})],N.prototype,"circle",2);T([S()],N.prototype,"type",2);T([S()],N.prototype,"name",2);T([S()],N.prototype,"value",2);T([S()],N.prototype,"href",2);T([S()],N.prototype,"target",2);T([S()],N.prototype,"rel",2);T([S()],N.prototype,"download",2);T([S()],N.prototype,"form",2);T([S({attribute:"formaction"})],N.prototype,"formAction",2);T([S({attribute:"formenctype"})],N.prototype,"formEnctype",2);T([S({attribute:"formmethod"})],N.prototype,"formMethod",2);T([S({attribute:"formnovalidate",type:Boolean})],N.prototype,"formNoValidate",2);T([S({attribute:"formtarget"})],N.prototype,"formTarget",2);T([kn("disabled",{waitUntilFirstUpdate:!0})],N.prototype,"handleDisabledChange",1);N.define("sl-button");const fs=ct`
@media(min-width: 1000px) {
sl-card {
max-width: 70vw;
}
}
main {
margin-top: 70px;
padding: 12px;
}
.ProseMirror {
position: relative;
word-wrap: break-word;
white-space: pre-wrap;
-webkit-font-variant-ligatures: none;
font-variant-ligatures: none;
padding: 1rem;
line-height: 1.2;
outline: none;
font-family: var(
--markdown-editor-typography-font-family,
var(--mdc-typography-font-family, Montserrat, sans-serif)
);
font-size: var(
--markdown-editor-typography-font-size,
var(--mdc-typography-subtitle1-font-size, 1rem)
);
font-weight: var(
--markdown-editor-typography-font-weight,
var(--mdc-typography-subtitle1-font-weight, 400)
);
letter-spacing: var(
--markdown-editor-typography-letter-spacing,
var(--mdc-typography-subtitle1-letter-spacing, 0.009375em)
);
}
.ProseMirror pre {
white-space: pre-wrap;
}
.ProseMirror li {
position: relative;
}
.ProseMirror p:first-child,
.ProseMirror h1:first-child,
.ProseMirror h2:first-child,
.ProseMirror h3:first-child,
.ProseMirror h4:first-child,
.ProseMirror h5:first-child,
.ProseMirror h6:first-child {
margin-top: 10px;
}
.ProseMirror a {
color: var(--markdown-editor-typography-anchor-color, -webkit-link);
text-decoration: var(--markdown-editor-typography-anchor-text-decoration);
}
.ProseMirror p {
margin-bottom: 1em;
}
.ProseMirror-hideselection {
caret-color: transparent;
}
.ProseMirror-hideselection *::selection,
.ProseMirror-hideselection *::-moz-selection {
background: transparent;
}
.ProseMirror-selectednode {
outline: 2px solid #8cf;
}
/* Make sure li selections wrap around markers */
li.ProseMirror-selectednode {
outline: none;
}
li.ProseMirror-selectednode:after {
content: '';
position: absolute;
left: -32px;
right: -2px;
top: -2px;
bottom: -2px;
border: 2px solid #8cf;
pointer-events: none;
}
.ProseMirror-textblock-dropdown {
min-width: 3em;
}
.ProseMirror-menu {
margin: 0 -4px;
line-height: 1;
}
.ProseMirror-tooltip .ProseMirror-menu {
width: -webkit-fit-content;
width: fit-content;
white-space: pre;
}
.ProseMirror-menuitem {
margin: 0.25rem 0.25rem 0.25rem 0;
display: flex;
justify-content: center;
align-items: center;
border-radius: 4px;
overflow: hidden;
}
.ProseMirror-menuitem:hover {
background-color: #f5f5f5;
}
.ProseMirror-menuseparator {
margin: 0 8px;
}
.ProseMirror-menu-dropdown,
.ProseMirror-menu-dropdown-menu {
font-size: 90%;
white-space: nowrap;
}
.ProseMirror-menu-dropdown {
vertical-align: 1px;
cursor: pointer;
position: relative;
padding-right: 15px;
}
.ProseMirror-menu-dropdown-wrap {
padding: 1px 0 1px 4px;
display: inline-block;
position: relative;
}
.ProseMirror-menu-dropdown:after {
content: '';
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 4px solid currentColor;
opacity: 0.6;
position: absolute;
right: 4px;
top: calc(50% - 2px);
}
.ProseMirror-menu-dropdown-menu,
.ProseMirror-menu-submenu {
position: absolute;
background: white;
color: #666;
border: 1px solid #aaa;
padding: 2px;
}
.ProseMirror-menu-dropdown-menu {
z-index: 1;
min-width: 6em;
}
.ProseMirror-menu-dropdown-item {
cursor: pointer;
}
.ProseMirror-menu-dropdown-item:hover {
background: #f2f2f2;
}
.ProseMirror-menu-dropdown-item > div {
padding: 0.375rem 0.5rem;
}
.ProseMirror-menu-submenu-wrap {
position: relative;
margin-right: -4px;
}
.ProseMirror-menu-submenu-label:after {
content: '';
border-top: 4px solid transparent;
border-bottom: 4px solid transparent;
border-left: 4px solid currentColor;
opacity: 0.6;
position: absolute;
right: 4px;
top: calc(50% - 4px);
}
.ProseMirror-menu-submenu {
display: none;
min-width: 4em;
left: 100%;
top: -3px;
}
.ProseMirror-menu-active {
background: #eee;
border-radius: 4px;
color: black;
}
.ProseMirror-menu-submenu-wrap:hover .ProseMirror-menu-submenu,
.ProseMirror-menu-submenu-wrap-active .ProseMirror-menu-submenu {
display: block;
}
.ProseMirror-menubar {
display: flex;
flex-wrap: wrap;
position: relative;
background: white;
min-height: 1em;
overflow: visible;
z-index: 2;
top: 0;
left: 0;
right: 0;
color: #666;
padding: 1px 6px;
border-top-left-radius: inherit;
border-top-right-radius: inherit;
border-bottom: 1px solid
var(--markdown-editor-outline-idle-border-color, rgba(0, 0, 0, 0.38));
box-sizing: border-box;
-moz-box-sizing: border-box;
}
.ProseMirror-icon {
display: inline-block;
line-height: 0.8;
vertical-align: -2px;
/* Compensate for padding */
padding: 2px 8px;
cursor: pointer;
}
.ProseMirror-menu-disabled {
color: rgba(0,0,0,0.37);
background-color: rgba(0,0,0,0.12);
cursor: not-allowed;
}
.ProseMirror-menu-disabled.ProseMirror-icon {
cursor: not-allowed;
}
.ProseMirror-icon svg {
fill: currentColor;
height: 1em;
}
.ProseMirror-icon span {
vertical-align: text-top;
}
.ProseMirror-gapcursor {
display: none;
pointer-events: none;
position: absolute;
}
.ProseMirror-gapcursor:after {
content: '';
display: block;
position: absolute;
top: -2px;
width: 20px;
border-top: 1px solid black;
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
}
@keyframes ProseMirror-cursor-blink {
to {
visibility: hidden;
}
}
.ProseMirror-focused .ProseMirror-gapcursor {
display: block;
}
/* Add space around the hr to make clicking it easier */
.ProseMirror-example-setup-style hr {
padding: 2px 10px;
border: none;
margin: 1em 0;
}
.ProseMirror-example-setup-style hr:after {
content: '';
display: block;
height: 1px;
background-color: silver;
line-height: 2px;
}
.ProseMirror ul,
.ProseMirror ol {
padding-left: 30px;
}
.ProseMirror blockquote {
padding-left: 1em;
border-left: 3px solid #eee;
margin-left: 0;
margin-right: 0;
}
.ProseMirror-example-setup-style img {
cursor: default;
}
.ProseMirror-invalid {
background: #ffc;
border: 1px solid #cc7;
border-radius: 4px;
padding: 5px 10px;
position: absolute;
min-width: 10em;
}
.ProseMirror h1.title.empty-node::before,
.ProseMirror h2.instructional-prompt.empty-node::before,
.ProseMirror h3.mechanical-promp.empty-node::before {
content: 'Enter title here...';
}
.ProseMirror div.passage-subtitle.empty-node:first-child::before {
content: 'Enter subtitle here...';
}
.ProseMirror div.passage-author.empty-node:first-child::before,
.ProseMirror div.passage-cast-title.empty-node:first-child::before,
.ProseMirror div.passage-act-title.empty-node:first-child::before,
.ProseMirror div.passage-scene-title.empty-node:first-child::before,
.ProseMirror div.passage-verse.empty-node:first-child::before,
.ProseMirror div.passage-footnotes.empty-node:first-child::before,
.ProseMirror div.paragraph.empty-node:first-child::before {
content: 'Enter text here...';
}
div[contenteditable]:focus h1.title.empty-node::before,
div[contenteditable]:focus h2.instructional-prompt.empty-node::before,
div[contenteditable]:focus h3.mechanical-promp.empty-node::before,
div[contenteditable]:focus
div.passage-subtitle.empty-node:first-child::before,
div[contenteditable]:focus div.passage-author.empty-node:first-child::before,
div[contenteditable]:focus
div.passage-cast-title.empty-node:first-child::before,
div[contenteditable]:focus
div.passage-act-title.empty-node:first-child::before,
div[contenteditable]:focus
div.passage-scene-title.empty-node:first-child::before,
div[contenteditable]:focus div.passage-verse.empty-node:first-child::before,
div[contenteditable]:focus
div.passage-footnotes.empty-node:first-child::before,
div[contenteditable]:focus div.paragraph.empty-node:first-child::before {
content: '';
}
.ProseMirror .empty-node::before {
position: absolute;
color: #aaa;
cursor: text;
font-style: italic;
}
#editor, .editor {
background: white;
color: black;
background-clip: padding-box;
padding: 5px 0;
}
#editor[disabled] .ProseMirror-menubar {
display: none!important;
}
drop-down-editor rich-text .inline-component-button,
expand-collapse rich-text .inline-component-button,
flip-reveal rich-text .inline-component-button,
hint-list rich-text .inline-component-button,
option-list rich-text .inline-component-button,
plankton-passage rich-text .inline-component-button {
pointer-events: none;
color: lightgray;
}
#ProseMirror-icon-collection path {
fill-rule: evenodd;
}
#welcomeBar {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
#welcomeCard,
#infoCard {
padding: 18px;
padding-top: 0px;
}
sl-card::part(footer) {
display: flex;
justify-content: flex-end;
}
@media(min-width: 750px) {
sl-card {
width: 70vw;
}
}
@media (horizontal-viewport-segments: 2) {
#welcomeBar {
flex-direction: row;
align-items: flex-start;
justify-content: space-between;
}
@media (horizontal-viewport-segments: 2) {
#welcomeBar {
flex-direction: row;
align-items: flex-start;
justify-content: space-between;
}
}
.boring {
background: grey;
}
.plus {
position: absolute;
padding: 8px;
background-color: #4CAF50;
color: red;
border: none;
cursor: pointer;
}
.plus:hover {
background-color: #45a049;
}
.ProseMirror-textblock-dropdown {
min-width: 3em;
}
}`;var Fu=Object.defineProperty,Wu=Object.getOwnPropertyDescriptor,Pn=(e,t,r,n)=>{for(var o=n>1?void 0:n?Wu(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&Fu(t,r,o),o};let ie=class extends gt{constructor(){super(...arguments),this.notes=[],this.relayName="",this.note=""}getUserLang(){return navigator.language||"en"}async firstUpdated(){console.log("Here are some recent notes from the neighborhood")}async connectedCallback(){super.connectedCallback(),await Promise.all([this.fetchNotes()])}async fetchNotes(){const e=await tr.connect("wss://notes.miguelalmodo.com");console.log(`connected to ${e.url}`),this.relayName=e.url;const t=e.subscribe([{kinds:[30023],limit:5}],{onevent:async r=>{console.log("Event received:",r),this.notes=[...this.notes,{content:r.content,date:new Date(r.created_at*1e3).toLocaleDateString()}],this.requestUpdate(),console.log(e)},oneose:()=>{t.close(),this.requestUpdate()}})}async displayLongNotes(){}share(){navigator.share&&navigator.share({title:"Nostr Micro Client",text:"Share this with your homie!",url:"https://miguelalmodo.com/"})}render(){return G`
Recent Notes from ${this.relayName}
`}};ie.styles=[fs,ct`
.comment-wall .main-section-header {
margin-bottom: 3px;
}
.comment-wall .main-section-h2 {
margin-bottom: 0;
}
#comment-counter {
margin-top: 0;
margin-left: 15px;
margin-bottom: 3px;
}
.comment-wall table {
margin: auto;
margin-bottom: 5px;
color: black;
}
.comment-wall th {
width: 158px;
padding: 3px;
vertical-align: top;
}
.comment-wall td {
vertical-align: top;
width: 269px;
padding: 3px;
}
.comment-wall figcaption,
.comment-wall figure {
margin: 0;
}
.comment-wall figcaption {
margin-bottom: 1em;
}
.comment-wall figure {
margin-bottom: 49.33px;
}
.comment-wall h3 {
font-size: 10pt;
margin: 0;
margin-bottom: 3em;
}
.comment-wall p {
font-weight: normal;
text-align: center;
margin: 0;
}
#add-comment {
text-align: right;
margin-right: 10px;
margin-bottom: 5px;
}
`];Pn([S({type:Array})],ie.prototype,"notes",2);Pn([S({type:String})],ie.prototype,"relayName",2);ie=Pn([qe("note-wall")],ie);const Ku=Object.freeze(Object.defineProperty({__proto__:null,get NoteWall(){return ie}},Symbol.toStringTag,{value:"Module"})),Zu="modulepreload",Gu=function(e){return"/"+e},fo={},Te=function(t,r,n){let o=Promise.resolve();if(r&&r.length>0){document.getElementsByTagName("link");const s=document.querySelector("meta[property=csp-nonce]"),l=s?.nonce||s?.getAttribute("nonce");o=Promise.allSettled(r.map(a=>{if(a=Gu(a),a in fo)return;fo[a]=!0;const c=a.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${a}"]${u}`))return;const d=document.createElement("link");if(d.rel=c?"stylesheet":Zu,c||(d.as="script"),d.crossOrigin="",d.href=a,l&&d.setAttribute("nonce",l),document.head.appendChild(d),c)return new Promise((m,g)=>{d.addEventListener("load",m),d.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${a}`)))})}))}function i(s){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=s,window.dispatchEvent(l),!l.defaultPrevented)throw s}return o.then(s=>{for(const l of s||[])l.status==="rejected"&&i(l.reason);return t().catch(i)})},Cn=Symbol.for("app-tools::log::1.x");globalThis[Cn]={setDebug:Ju,debug:"window"in globalThis?new URL(window.location.href).searchParams.has("app-tools-debug"):!1};function Ju(e){globalThis[Cn].debug=!!e}function Yu(e,t){globalThis[Cn].debug&&(console.groupCollapsed(`[app-tools] ${e}`),t&&console.log(t),console.groupEnd())}function Xu(e){return(t,r)=>{Yu(`${e}: ${t}`,r)}}const Pt=Xu("router");class Qu extends Event{constructor(t){super("route-changed"),this.context=t}}class th extends EventTarget{context={params:{},query:{},title:"",url:new URL(window.location.href)};constructor(t){super(),this.config=t,this.routes=t.routes.map(r=>({...r,urlPattern:new URLPattern({pathname:r.path,baseURL:window.location.href,search:"*",hash:"*"})})),Pt("Initialized routes",this.routes),queueMicrotask(()=>{this.navigate(new URL(window.location.href),{replace:!0})}),window.addEventListener("popstate",this._onPopState),window.addEventListener("click",this._onAnchorClick)}uninstall(){window.removeEventListener("popstate",this._onPopState),window.removeEventListener("click",this._onAnchorClick)}get url(){return new URL(window.location.href)}get fallback(){return new URL(this.config?.fallback||this.baseUrl.href.substring(window.location.origin.length),this.baseUrl)}get baseUrl(){return new URL("./",document.baseURI)}render(){return Pt(`Rendering route ${this.context.url.pathname}${this.context.url.search}${this.context.url.hash}`,{context:this.context,route:this.route}),this.route?.render?.(this.context)}_matchRoute(t){for(const r of this.routes){const n=r.urlPattern.exec(t);if(n){const{title:o}=r,i=Object.fromEntries(new URLSearchParams(t.search)),s=n?.pathname?.groups??{};return this.context={url:t,title:typeof o=="function"?o({params:s,query:i,url:t}):o,params:s,query:i},r}}return Pt(`No route matched for ${t.pathname}${t.search}${t.hash}`,t),null}_notifyUrlChanged(){this.dispatchEvent(new Qu(this.context))}_onPopState=()=>{this.navigate(new URL(window.location.href),{backNav:!0})};_onAnchorClick=t=>{if(t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey)return;const r=t.composedPath().find(i=>i.tagName==="A");if(!r||!r.href)return;const n=new URL(r.href);if(this.url.href===n.href||n.host!==window.location.host||r.hasAttribute("download")||r.href.includes("mailto:"))return;const o=r.getAttribute("target");o&&o!==""&&o!=="_self"||(t.preventDefault(),this.navigate(n))};_collectPlugins(t){return[...this.config?.plugins??[],...t?.plugins??[]]}async navigate(t,r={}){typeof t=="string"&&(t=new URL(t,this.baseUrl));let n=this._matchRoute(t)||this._matchRoute(this.fallback);Pt(`Navigating to ${t.pathname}${t.search}${t.hash}`,{context:this.context,route:this.route});let o=this._collectPlugins(n);for(const i of o)try{const s=await i?.shouldNavigate?.(this.context);s&&(await s.condition()||(t=new URL(s.redirect,this.baseUrl),n=this._matchRoute(t)||this._matchRoute(this.fallback),o=this._collectPlugins(n),Pt("Redirecting",{context:this.context,route:this.route})))}catch(s){throw Pt(`Plugin "${i.name}" error on shouldNavigate hook`,s),s}if(this.route=n,!this.route)throw new Error(`[ROUTER] No route or fallback matched for url ${t}`);for(const i of o)try{await i?.beforeNavigation?.(this.context)}catch(s){throw Pt(`Plugin "${i.name}" error on beforeNavigation hook`,s),s}r?.replace?window.history.replaceState(null,"",`${t.pathname}${t.search}${t.hash}`):r.backNav||window.history.pushState(null,"",`${t.pathname}${t.search}${t.hash}`),document.title=this.context.title,this._notifyUrlChanged();for(const i of o)try{await i?.afterNavigation?.(this.context)}catch(s){throw Pt(`Plugin "${i.name}" error on afterNavigation hook`,s),s}}}function $r(e){return{name:"lazy",beforeNavigation:()=>{e()}}}globalThis.URLPattern||await Te(()=>import("./index-CBloBB_n.js"),[]);const eh="/",po=new th({routes:[{path:Lt(),title:"Home",render:()=>G`
`},{path:Lt("about"),title:"About",plugins:[$r(()=>Te(()=>import("./app-about-BGKiJfUr.js"),[]))],render:()=>G`
`},{path:Lt("note-wall"),title:"Note Wall",plugins:[$r(()=>Te(()=>Promise.resolve().then(()=>Ku),void 0))],render:()=>G`
`},{path:Lt("write"),title:"Write",plugins:[$r(()=>Te(()=>import("./app-write-DLE2Mxxa.js"),[]))],render:()=>G`
`}]});function Lt(e){var t=eh;return e&&(t=t+e),t}var rh=Object.defineProperty,nh=Object.getOwnPropertyDescriptor,Wt=(e,t,r,n)=>{for(var o=n>1?void 0:n?nh(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&rh(t,r,o),o};let mt=class extends gt{constructor(){super(...arguments),this.message="Welcome to my demo!",this.nostrAddy="",this.bio="",this.profilePic="",this.isSignedIn=!1,this.publicKey=""}async firstUpdated(){console.log("Welcome to my home page")}connectedCallback(){super.connectedCallback(),this.addEventListener("user-state-changed",e=>{const t=e.detail;this.nostrAddy=t.nostrAddy,this.bio=t.bio,this.profilePic=t.profilePic,this.isSignedIn=t.isSignedIn})}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("profile-updated",this.updateProfileFromEvent.bind(this)),window.removeEventListener("user-signed-out",this.handlesSignOut.bind(this))}updateProfileFromEvent(e){console.log("Profile updated event received:",e.detail);const t=e.detail;this.nostrAddy=t.nostrAddy,this.bio=t.bio,this.profilePic=t.profilePic,this.isSignedIn=!0,this.requestUpdate()}handlesSignOut(){this.profilePic="",this.bio="",this.nostrAddy="Guest",this.isSignedIn=!1,this.requestUpdate()}async fetchAndDisplayProfile(e){this.nostrAddy=e,this.bio="Loading profile info...",this.profilePic="/assets/img/loading_pfp.png";try{const r=(await tr.connect("wss://notes.miguelalmodo.com")).subscribe([{kinds:[0],authors:[e]}],{onevent:n=>{const o=JSON.parse(n.content);this.nostrAddy=o.nip05||"No address available",this.bio=o.about||"No bio available",this.profilePic=o.picture||"/assets/img/default_pfp.png",this.requestUpdate()},oneose:()=>r.close()})}catch(t){console.error("Error fetching profile:",t),this.displayGuestView()}}displayGuestView(){this.nostrAddy="",this.bio="Welcome, guest! Please sign in with a browser extension to view your profile.",this.profilePic="/assets/img/default_pfp.png",this.isSignedIn=!1}share(){navigator.share&&navigator.share({title:"A MiggyMofongo Project",text:"This is a personal progressive social web app",url:"https://miguelalmodo.com/dist2"})}render(){return G`
Welcome to ${this.nostrAddy||"Guest"}'s Profile
You can upgrade your website into
a micro blog client with a social protocol to do things
like browse a feed, compose a note, or post to your network.
${this.bio||"Welcome, guest! Please sign in to view your profile."}
About this Web App
Feed
Compose a Note
${"share"in navigator?G`
Share this personal website with a friend!
`:null}
`}};mt.styles=[fs,ct`
@media (horizontal-viewport-segments: 2) {
#welcomeBar {
flex-direction: row;
align-items: flex-start;
justify-content: space-between;
}
#welcomeCard {
margin-right: 64px;
}
}
/*
========================================
Profile Picture Container
========================================
*/
.profile-picture-container {
display: grid;
grid-template-columns: 400px 200px;
grid-template-rows: 250px;
grid-column-gap: 15px;
margin-bottom: 12px;
}
.profile-picture-container p {
margin: 0;
}
.profile-pic {
grid-area: 1/1;
margin-top: 25px;
margin-left: 100px;
margin-bottom: 10px;
border-radius: 50%;
}
.personal-msg {
grid-area: 1/2;
align-content: center;
align-items: center;
}
.nav-button-container {
justify-self: center;
align-self: end;
}
`];Wt([S()],mt.prototype,"message",2);Wt([S({type:String})],mt.prototype,"nostrAddy",2);Wt([S({type:String})],mt.prototype,"bio",2);Wt([S({type:String})],mt.prototype,"profilePic",2);Wt([S({type:Boolean})],mt.prototype,"isSignedIn",2);Wt([S({type:String})],mt.prototype,"publicKey",2);mt=Wt([qe("app-home")],mt);var oh=Object.defineProperty,ih=Object.getOwnPropertyDescriptor,Rt=(e,t,r,n)=>{for(var o=n>1?void 0:n?ih(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&oh(t,r,o),o};let lt=class extends gt{constructor(){super(...arguments),this.title="fostr",this.enableBack=!1,this.nostrAddy="",this.bio="",this.profilePic="",this.isSignedIn=!1,this.publicKey=""}connectedCallback(){super.connectedCallback();const e=localStorage.getItem("pubkey");e?(this.isSignedIn=!0,this.fetchProfileMetadata(e)):this.displayGuestView()}displayGuestView(){this.nostrAddy="",this.bio="Welcome, guest! Please sign in with a browser extension to view your profile.",this.profilePic="/public/assets/img/default_pfp.png",this.isSignedIn=!1,this.dispatchUserStateChanged()}async fetchProfileMetadata(e){try{const r=(await tr.connect("wss://notes.miguelalmodo.com")).subscribe([{kinds:[0],authors:[e]}],{onevent:n=>{const o=JSON.parse(n.content);this.profilePic=o.picture||"/assets/img/default_pfp.png",this.nostrAddy=o.nip05||"no addy available",this.bio=o.about||"bio not available",this.dispatchUserStateChanged()},oneose:()=>r.close()})}catch(t){console.error("Failed to fetch profile metadata:",t),this.displayGuestView()}}async signInWithNostr(){if(window.nostr)try{const e=await window.nostr.getPublicKey();this.isSignedIn=!0,localStorage.setItem("pubkey",e),await this.fetchProfileMetadata(e)}catch(e){console.error("Failed to sign in:",e),this.isSignedIn=!1}else alert("Nostr extension not detected. Please install a Nostr extension.")}signOut(){localStorage.removeItem("pubkey"),this.displayGuestView()}dispatchUserStateChanged(){this.dispatchEvent(new CustomEvent("user-state-changed",{detail:{isSignedIn:this.isSignedIn,nostrAddy:this.nostrAddy,bio:this.bio,profilePic:this.profilePic},bubbles:!0,composed:!0}))}render(){return G`
`}};lt.styles=ct`
header {
display: flex;
justify-content: space-between;
align-items: center;
background: var(--app-color-primary);
color: white;
padding: 12px;
padding-top: 4px;
position: fixed;
left: env(titlebar-area-x, 0);
top: env(titlebar-area-y, 0);
height: env(titlebar-area-height, 30px);
width: env(titlebar-area-width, 100%);
-webkit-app-region: drag;
}
header h1 {
margin-top: 0;
margin-bottom: 0;
font-size: 12px;
font-weight: bold;
}
nav a {
margin-left: 10px;
}
#back-button-block {
display: flex;
justify-content: space-between;
align-items: center;
gap: 8px;
}
@media(prefers-color-scheme: light) {
header {
color: black;
}
nav a {
color: initial;
}
}
`;Rt([S({type:String})],lt.prototype,"title",2);Rt([S({type:Boolean})],lt.prototype,"enableBack",2);Rt([S({type:String})],lt.prototype,"nostrAddy",2);Rt([S({type:String})],lt.prototype,"bio",2);Rt([S({type:String})],lt.prototype,"profilePic",2);Rt([S({type:Boolean})],lt.prototype,"isSignedIn",2);Rt([S({type:String})],lt.prototype,"publicKey",2);lt=Rt([qe("app-header")],lt);var sh=Object.defineProperty,ah=Object.getOwnPropertyDescriptor,lh=(e,t,r,n)=>{for(var o=n>1?void 0:n?ah(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&sh(t,r,o),o};let Dr=class extends gt{firstUpdated(){po.addEventListener("route-changed",()=>{"startViewTransition"in document?document.startViewTransition(()=>this.requestUpdate()):this.requestUpdate()})}render(){return po.render()}};Dr.styles=ct`
main {
padding-left: 16px;
padding-right: 16px;
padding-bottom: 16px;
}
`;Dr=lh([qe("app-index")],Dr);export{Zs as e,ct as i,S as n,gt as r,fs as s,qe as t,G as x};
//# sourceMappingURL=index-COc6jZBc.js.map