!function(){"use strict";function e(){}function t(e){return e()}function n(){return Object.create(null)}function r(e){e.forEach(t)}function o(e){return"function"==typeof e}function i(e,t){return e!=e?t==t:e!==t||e&&"object"==typeof e||"function"==typeof e}let s;function a(e,t){return s||(s=document.createElement("a")),s.href=t,e===s.href}function c(t,n,r){t.$$.on_destroy.push(function(t,...n){if(null==t)return e;const r=t.subscribe(...n);return r.unsubscribe?()=>r.unsubscribe():r}(n,r))}function u(e,t,n){return e.set(n),t}const l="undefined"!=typeof window;let h=l?()=>window.performance.now():()=>Date.now(),f=l?e=>requestAnimationFrame(e):e;const d=new Set;function p(e){d.forEach((t=>{t.c(e)||(d.delete(t),t.f())})),0!==d.size&&f(p)}function y(e,t){e.appendChild(t)}function g(e,t,n){e.insertBefore(t,n||null)}function b(e){e.parentNode&&e.parentNode.removeChild(e)}function m(e,t){for(let n=0;ne.removeEventListener(t,n,r)}function k(e){return function(t){return t.preventDefault(),e.call(this,t)}}function S(e,t,n){null==n?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function O(e,t){t=""+t,e.wholeText!==t&&(e.data=t)}function A(e,t,n,r){null===n?e.style.removeProperty(t):e.style.setProperty(t,n,r?"important":"")}let C;function R(e){C=e}function T(){if(!C)throw new Error("Function called outside component initialization");return C}function L(e){T().$$.on_mount.push(e)}const I=[],P=[],j=[],U=[],B=Promise.resolve();let N=!1;function M(e){j.push(e)}function $(e){U.push(e)}const z=new Set;let F=0;function D(){if(0!==F)return;const e=C;do{try{for(;F{q.delete(e),r&&(n&&e.d(1),r())})),e.o(t)}else r&&r()}function Y(e,t,n){const r=e.$$.props[t];void 0!==r&&(e.$$.bound[r]=n,n(e.$$.ctx[r]))}function X(e){e&&e.c()}function J(e,n,i,s){const{fragment:a,after_update:c}=e.$$;a&&a.m(n,i),s||M((()=>{const n=e.$$.on_mount.map(t).filter(o);e.$$.on_destroy?e.$$.on_destroy.push(...n):r(n),e.$$.on_mount=[]})),c.forEach(M)}function Q(e,t){const n=e.$$;null!==n.fragment&&(r(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function ee(e,t){-1===e.$$.dirty[0]&&(I.push(e),N||(N=!0,B.then(D)),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const o=r.length?r[0]:n;return f.ctx&&a(f.ctx[e],f.ctx[e]=o)&&(!f.skip_bound&&f.bound[e]&&f.bound[e](o),d&&ee(t,e)),n})):[],f.update(),d=!0,r(f.before_update),f.fragment=!!s&&s(f.ctx),o.target){if(o.hydrate){const e=function(e){return Array.from(e.childNodes)}(o.target);f.fragment&&f.fragment.l(e),e.forEach(b)}else f.fragment&&f.fragment.c();o.intro&&Z(t.$$.fragment),J(t,o.target,o.anchor,o.customElement),D()}R(h)}class ne{$destroy(){Q(this,1),this.$destroy=e}$on(t,n){if(!o(n))return e;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(n),()=>{const e=r.indexOf(n);-1!==e&&r.splice(e,1)}}$set(e){var t;this.$$set&&(t=e,0!==Object.keys(t).length)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const re=[];function oe(t,n=e){let r;const o=new Set;function s(e){if(i(t,e)&&(t=e,r)){const e=!re.length;for(const e of o)e[1](),re.push(e,t);if(e){for(let e=0;e{o.delete(c),0===o.size&&(r(),r=null)}}}}const ie=oe(null),se=oe({events:[],profiles:{}}),ae=oe(null),ce=oe(null),ue=oe({});function le(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function he(e,...t){if(!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new TypeError(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}const fe={number:le,bool:function(e){if("boolean"!=typeof e)throw new Error(`Expected boolean, not ${e}`)},bytes:he,hash:function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");le(e.outputLen),le(e.blockLen)},exists:function(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")},output:function(e,t){he(e);const n=t.outputLen;if(e.lengthnew DataView(e.buffer,e.byteOffset,e.byteLength),ye=(e,t)=>e<<32-t|e>>>t;if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");const ge=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function be(e){if(!(e instanceof Uint8Array))throw new Error("Uint8Array expected");let t="";for(let n=0;ne instanceof Uint8Array)))throw new Error("Uint8Array list expected");if(1===e.length)return e[0];const t=e.reduce(((e,t)=>e+t.length),0),n=new Uint8Array(t);for(let t=0,r=0;te().update(ve(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function ke(e=32){if(de&&"function"==typeof de.getRandomValues)return de.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}let Se=class extends xe{constructor(e,t,n,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=pe(this.buffer)}update(e){fe.exists(this);const{view:t,buffer:n,blockLen:r}=this,o=(e=ve(e)).length;for(let i=0;ir-i&&(this.process(n,0),i=0);for(let e=i;e>o&i),a=Number(n&i),c=r?4:0,u=r?0:4;e.setUint32(t+c,s,r),e.setUint32(t+u,a,r)}(n,r-8,BigInt(8*this.length),o),this.process(n,0);const s=pe(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;ee&t^e&n^t&n,Ae=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ce=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Re=new Uint32Array(64);let Te=class extends Se{constructor(){super(64,32,8,!1),this.A=0|Ce[0],this.B=0|Ce[1],this.C=0|Ce[2],this.D=0|Ce[3],this.E=0|Ce[4],this.F=0|Ce[5],this.G=0|Ce[6],this.H=0|Ce[7]}get(){const{A:e,B:t,C:n,D:r,E:o,F:i,G:s,H:a}=this;return[e,t,n,r,o,i,s,a]}set(e,t,n,r,o,i,s,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|o,this.F=0|i,this.G=0|s,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)Re[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=Re[e-15],n=Re[e-2],r=ye(t,7)^ye(t,18)^t>>>3,o=ye(n,17)^ye(n,19)^n>>>10;Re[e]=o+Re[e-7]+r+Re[e-16]|0}let{A:n,B:r,C:o,D:i,E:s,F:a,G:c,H:u}=this;for(let e=0;e<64;e++){const t=u+(ye(s,6)^ye(s,11)^ye(s,25))+((l=s)&a^~l&c)+Ae[e]+Re[e]|0,h=(ye(n,2)^ye(n,13)^ye(n,22))+Oe(n,r,o)|0;u=c,c=a,a=s,s=i+t|0,i=o,o=r,r=n,n=t+h|0}var l;n=n+this.A|0,r=r+this.B|0,o=o+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(n,r,o,i,s,a,c,u)}roundClean(){Re.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},Le=class extends Te{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 Ie=Ee((()=>new Te));Ee((()=>new Le)); /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ const Pe=BigInt(0),je=BigInt(1),Ue=BigInt(2),Be=e=>e instanceof Uint8Array,Ne=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function Me(e){if(!Be(e))throw new Error("Uint8Array expected");let t="";for(let n=0;nFe(e.toString(16).padStart(2*t,"0")),We=(e,t)=>qe(e,t).reverse();function Ke(e,t,n){let r;if("string"==typeof t)try{r=Fe(t)}catch(n){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${n}`)}else{if(!Be(t))throw new Error(`${e} must be hex string or Uint8Array`);r=Uint8Array.from(t)}const o=r.length;if("number"==typeof n&&o!==n)throw new Error(`${e} expected ${n} bytes, got ${o}`);return r}function Ge(...e){const t=new Uint8Array(e.reduce(((e,t)=>e+t.length),0));let n=0;return e.forEach((e=>{if(!Be(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length})),t}function Ze(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return(new TextEncoder).encode(e)}const Ve=e=>(Ue<new Uint8Array(e),Xe=e=>Uint8Array.from(e);function Je(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");let r=Ye(e),o=Ye(e),i=0;const s=()=>{r.fill(1),o.fill(0),i=0},a=(...e)=>n(o,r,...e),c=(e=Ye())=>{o=a(Xe([0]),e),r=a(),0!==e.length&&(o=a(Xe([1]),e),r=a())},u=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e{let n;for(s(),c(e);!(n=t(u()));)c();return s(),n}}const Qe={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};function et(e,t,n={}){const r=(t,n,r)=>{const o=Qe[n];if("function"!=typeof o)throw new Error(`Invalid validator "${n}", expected function`);const i=e[t];if(!(r&&void 0===i||o(i,e)))throw new Error(`Invalid param ${String(t)}=${i} (${typeof i}), expected ${n}`)};for(const[e,n]of Object.entries(t))r(e,n,!1);for(const[e,t]of Object.entries(n))r(e,t,!0);return e}var tt=Object.freeze({__proto__:null,bitGet:(e,t)=>e>>BigInt(t)&je,bitLen:function(e){let t;for(t=0;e>Pe;e>>=je,t+=1);return t},bitMask:Ve,bitSet:(e,t,n)=>e|(n?je:Pe)<Fe($e(e)),utf8ToBytes:Ze,validateObject:et}); /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const nt=BigInt(0),rt=BigInt(1),ot=BigInt(2),it=BigInt(3),st=BigInt(4),at=BigInt(5),ct=BigInt(8);function ut(e,t){const n=e%t;return n>=nt?n:t+n}function lt(e,t,n){if(n<=nt||t 0");if(n===rt)return nt;let r=rt;for(;t>nt;)t&rt&&(r=r*e%n),e=e*e%n,t>>=rt;return r}function ht(e,t,n){let r=e;for(;t-- >nt;)r*=r,r%=n;return r}function ft(e,t){if(e===nt||t<=nt)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=ut(e,t),r=t,o=nt,i=rt;for(;n!==nt;){const e=r%n,t=o-i*(r/n);r=n,n=e,o=i,i=t}if(r!==rt)throw new Error("invert: does not exist");return ut(o,t)}function dt(e){if(e%st===it){const t=(e+rt)/st;return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}}if(e%ct===at){const t=(e-at)/ct;return function(e,n){const r=e.mul(n,ot),o=e.pow(r,t),i=e.mul(n,o),s=e.mul(e.mul(i,ot),o),a=e.mul(i,e.sub(s,e.ONE));if(!e.eql(e.sqr(a),n))throw new Error("Cannot find square root");return a}}return function(e){const t=(e-rt)/ot;let n,r,o;for(n=e-rt,r=0;n%ot===nt;n/=ot,r++);for(o=ot;o(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});return et(e,t)}function gt(e,t){const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}} /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ const bt=BigInt(0),mt=BigInt(1);function wt(e){return yt(e.Fp),et(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...gt(e.n,e.nBitLength),...e,p:e.Fp.ORDER})} /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const{bytesToNumberBE:vt,hexToBytes:_t}=tt,xt={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(e){const{Err:t}=xt;if(e.length<2||2!==e[0])throw new t("Invalid signature integer tag");const n=e[1],r=e.subarray(2,n+2);if(!n||r.length!==n)throw new t("Invalid signature integer: wrong length");if(128&r[0])throw new t("Invalid signature integer: negative");if(0===r[0]&&!(128&r[1]))throw new t("Invalid signature integer: unnecessary leading zero");return{d:vt(r),l:e.subarray(n+2)}},toSig(e){const{Err:t}=xt,n="string"==typeof e?_t(e):e;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||48!=n[0])throw new t("Invalid signature tag");if(n[1]!==r-2)throw new t("Invalid signature: incorrect length");const{d:o,l:i}=xt._parseInt(n.subarray(2)),{d:s,l:a}=xt._parseInt(i);if(a.length)throw new t("Invalid signature: left bytes after parsing");return{r:o,s:s}},hexFromSig(e){const t=e=>8&Number.parseInt(e[0],16)?"00"+e:e,n=e=>{const t=e.toString(16);return 1&t.length?`0${t}`:t},r=t(n(e.s)),o=t(n(e.r)),i=r.length/2,s=o.length/2,a=n(i),c=n(s);return`30${n(s+i+4)}02${c}${o}02${a}${r}`}},Et=BigInt(0),kt=BigInt(1),St=BigInt(2),Ot=BigInt(3),At=BigInt(4);function Ct(e){const t=function(e){const t=wt(e);et(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:o}=t;if(n){if(!r.eql(o,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}(e),{Fp:n}=t,r=t.toBytes||((e,t,r)=>{const o=t.toAffine();return Ge(Uint8Array.from([4]),n.toBytes(o.x),n.toBytes(o.y))}),o=t.fromBytes||(e=>{const t=e.subarray(1);return{x:n.fromBytes(t.subarray(0,n.BYTES)),y:n.fromBytes(t.subarray(n.BYTES,2*n.BYTES))}});function i(e){const{a:r,b:o}=t,i=n.sqr(e),s=n.mul(i,e);return n.add(n.add(s,n.mul(e,r)),o)}if(!n.eql(n.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function s(e){return"bigint"==typeof e&&Etn.eql(e,n.ZERO);return o(t)&&o(r)?h.ZERO:new h(t,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=n.invertBatch(e.map((e=>e.pz)));return e.map(((e,n)=>e.toAffine(t[n]))).map(h.fromAffine)}static fromHex(e){const t=h.fromAffine(o(Ke("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return h.BASE.multiply(c(e))}_setWindowSize(e){this._WINDOW_SIZE=e,u.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint)return;throw new Error("bad point: ZERO")}const{x:e,y:r}=this.toAffine();if(!n.isValid(e)||!n.isValid(r))throw new Error("bad point: x or y not FE");const o=n.sqr(r),s=i(e);if(!n.eql(o,s))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){l(e);const{px:t,py:r,pz:o}=this,{px:i,py:s,pz:a}=e,c=n.eql(n.mul(t,a),n.mul(i,o)),u=n.eql(n.mul(r,a),n.mul(s,o));return c&&u}negate(){return new h(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:r}=t,o=n.mul(r,Ot),{px:i,py:s,pz:a}=this;let c=n.ZERO,u=n.ZERO,l=n.ZERO,f=n.mul(i,i),d=n.mul(s,s),p=n.mul(a,a),y=n.mul(i,s);return y=n.add(y,y),l=n.mul(i,a),l=n.add(l,l),c=n.mul(e,l),u=n.mul(o,p),u=n.add(c,u),c=n.sub(d,u),u=n.add(d,u),u=n.mul(c,u),c=n.mul(y,c),l=n.mul(o,l),p=n.mul(e,p),y=n.sub(f,p),y=n.mul(e,y),y=n.add(y,l),l=n.add(f,f),f=n.add(l,f),f=n.add(f,p),f=n.mul(f,y),u=n.add(u,f),p=n.mul(s,a),p=n.add(p,p),f=n.mul(p,y),c=n.sub(c,f),l=n.mul(p,d),l=n.add(l,l),l=n.add(l,l),new h(c,u,l)}add(e){l(e);const{px:r,py:o,pz:i}=this,{px:s,py:a,pz:c}=e;let u=n.ZERO,f=n.ZERO,d=n.ZERO;const p=t.a,y=n.mul(t.b,Ot);let g=n.mul(r,s),b=n.mul(o,a),m=n.mul(i,c),w=n.add(r,o),v=n.add(s,a);w=n.mul(w,v),v=n.add(g,b),w=n.sub(w,v),v=n.add(r,i);let _=n.add(s,c);return v=n.mul(v,_),_=n.add(g,m),v=n.sub(v,_),_=n.add(o,i),u=n.add(a,c),_=n.mul(_,u),u=n.add(b,m),_=n.sub(_,u),d=n.mul(p,v),u=n.mul(y,m),d=n.add(u,d),u=n.sub(b,d),d=n.add(b,d),f=n.mul(u,d),b=n.add(g,g),b=n.add(b,g),m=n.mul(p,m),v=n.mul(y,v),b=n.add(b,m),m=n.sub(g,m),m=n.mul(p,m),v=n.add(v,m),g=n.mul(b,v),f=n.add(f,g),g=n.mul(_,v),u=n.mul(w,u),u=n.sub(u,g),g=n.mul(w,b),d=n.mul(_,d),d=n.add(d,g),new h(u,f,d)}subtract(e){return this.add(e.negate())}is0(){return this.equals(h.ZERO)}wNAF(e){return d.wNAFCached(this,u,e,(e=>{const t=n.invertBatch(e.map((e=>e.pz)));return e.map(((e,n)=>e.toAffine(t[n]))).map(h.fromAffine)}))}multiplyUnsafe(e){const r=h.ZERO;if(e===Et)return r;if(a(e),e===kt)return this;const{endo:o}=t;if(!o)return d.unsafeLadder(this,e);let{k1neg:i,k1:s,k2neg:c,k2:u}=o.splitScalar(e),l=r,f=r,p=this;for(;s>Et||u>Et;)s&kt&&(l=l.add(p)),u&kt&&(f=f.add(p)),p=p.double(),s>>=kt,u>>=kt;return i&&(l=l.negate()),c&&(f=f.negate()),f=new h(n.mul(f.px,o.beta),f.py,f.pz),l.add(f)}multiply(e){a(e);let r,o,i=e;const{endo:s}=t;if(s){const{k1neg:e,k1:t,k2neg:a,k2:c}=s.splitScalar(i);let{p:u,f:l}=this.wNAF(t),{p:f,f:p}=this.wNAF(c);u=d.constTimeNegate(e,u),f=d.constTimeNegate(a,f),f=new h(n.mul(f.px,s.beta),f.py,f.pz),r=u.add(f),o=l.add(p)}else{const{p:e,f:t}=this.wNAF(i);r=e,o=t}return h.normalizeZ([r,o])[0]}multiplyAndAddUnsafe(e,t,n){const r=h.BASE,o=(e,t)=>t!==Et&&t!==kt&&e.equals(r)?e.multiply(t):e.multiplyUnsafe(t),i=o(this,t).add(o(e,n));return i.is0()?void 0:i}toAffine(e){const{px:t,py:r,pz:o}=this,i=this.is0();null==e&&(e=i?n.ONE:n.inv(o));const s=n.mul(t,e),a=n.mul(r,e),c=n.mul(o,e);if(i)return{x:n.ZERO,y:n.ZERO};if(!n.eql(c,n.ONE))throw new Error("invZ was invalid");return{x:s,y:a}}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e===kt)return!0;if(n)return n(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:n}=t;return e===kt?this:n?n(h,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),r(h,this,e)}toHex(e=!0){return Me(this.toRawBytes(e))}}h.BASE=new h(t.Gx,t.Gy,n.ONE),h.ZERO=new h(n.ZERO,n.ONE,n.ZERO);const f=t.nBitLength,d=function(e,t){const n=(e,t)=>{const n=t.negate();return e?n:t},r=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:n,unsafeLadder(t,n){let r=e.ZERO,o=t;for(;n>bt;)n&mt&&(r=r.add(o)),o=o.double(),n>>=mt;return r},precomputeWindow(e,t){const{windows:n,windowSize:o}=r(t),i=[];let s=e,a=s;for(let e=0;e>=f,r>a&&(r-=h,i+=mt);const s=t,d=t+Math.abs(r)-1,p=e%2!=0,y=r<0;0===r?u=u.add(n(p,o[s])):c=c.add(n(y,o[d]))}return{p:c,f:u}},wNAFCached(e,t,n,r){const o=e._WINDOW_SIZE||1;let i=t.get(e);return i||(i=this.precomputeWindow(e,o),1!==o&&t.set(e,r(i))),this.wNAF(o,i,n)}}}(h,t.endo?Math.ceil(f/2):f);return{CURVE:t,ProjectivePoint:h,normPrivateKeyToScalar:c,weierstrassEquation:i,isWithinCurveOrder:s}}function Rt(e){const t=function(e){const t=wt(e);return et(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(e),{Fp:n,n:r}=t,o=n.BYTES+1,i=2*n.BYTES+1;function s(e){return ut(e,r)}function a(e){return ft(e,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:u,weierstrassEquation:l,isWithinCurveOrder:h}=Ct({...t,toBytes(e,t,r){const o=t.toAffine(),i=n.toBytes(o.x),s=Ge;return r?s(Uint8Array.from([t.hasEvenY()?2:3]),i):s(Uint8Array.from([4]),i,n.toBytes(o.y))},fromBytes(e){const t=e.length,r=e[0],s=e.subarray(1);if(t!==o||2!==r&&3!==r){if(t===i&&4===r){return{x:n.fromBytes(s.subarray(0,n.BYTES)),y:n.fromBytes(s.subarray(n.BYTES,2*n.BYTES))}}throw new Error(`Point of length ${t} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}{const e=De(s);if(!(Et<(a=e)&&aMe(qe(e,t.nByteLength));function d(e){return e>r>>kt}const p=(e,t,n)=>De(e.slice(t,n));class y{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(e){const n=t.nByteLength;return e=Ke("compactSignature",e,2*n),new y(p(e,0,n),p(e,n,2*n))}static fromDER(e){const{r:t,s:n}=xt.toSig(Ke("DER",e));return new y(t,n)}assertValidity(){if(!h(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!h(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(e){return new y(this.r,this.s,e)}recoverPublicKey(e){const{r:r,s:o,recovery:i}=this,u=w(Ke("msgHash",e));if(null==i||![0,1,2,3].includes(i))throw new Error("recovery id invalid");const l=2===i||3===i?r+t.n:r;if(l>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const h=0==(1&i)?"02":"03",d=c.fromHex(h+f(l)),p=a(l),y=s(-u*p),g=s(o*p),b=c.BASE.multiplyAndAddUnsafe(d,y,g);if(!b)throw new Error("point at infinify");return b.assertValidity(),b}hasHighS(){return d(this.s)}normalizeS(){return this.hasHighS()?new y(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return Fe(this.toDERHex())}toDERHex(){return xt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Fe(this.toCompactHex())}toCompactHex(){return f(this.r)+f(this.s)}}const g={isValidPrivateKey(e){try{return u(e),!0}catch(e){return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{const e=function(e,t,n=!1){const r=(e=Ke("privateHash",e)).length,o=gt(t).nByteLength+8;if(o<24||r1024)throw new Error(`hashToPrivateScalar: expected ${o}-1024 bytes of input, got ${r}`);return ut(n?He(e):De(e),t-rt)+rt}(t.randomBytes(n.BYTES+8),r);return qe(e,t.nByteLength)},precompute:(e=8,t=c.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function b(e){const t=e instanceof Uint8Array,n="string"==typeof e,r=(t||n)&&e.length;return t?r===o||r===i:n?r===2*o||r===2*i:e instanceof c}const m=t.bits2int||function(e){const n=De(e),r=8*e.length-t.nBitLength;return r>0?n>>BigInt(r):n},w=t.bits2int_modN||function(e){return s(m(e))},v=Ve(t.nBitLength);function _(e){if("bigint"!=typeof e)throw new Error("bigint expected");if(!(Et<=e&&ee in o)))throw new Error("sign() legacy options not supported");const{hash:i,randomBytes:l}=t;let{lowS:f,prehash:p,extraEntropy:g}=o;null==f&&(f=!0),e=Ke("msgHash",e),p&&(e=Ke("prehashed msgHash",i(e)));const b=w(e),v=u(r),x=[_(v),_(b)];if(null!=g){const e=!0===g?l(n.BYTES):g;x.push(Ke("extraEntropy",e,n.BYTES))}const k=Ge(...x),S=b;return{seed:k,k2sig:function(e){const t=m(e);if(!h(t))return;const n=a(t),r=c.BASE.multiply(t).toAffine(),o=s(r.x);if(o===Et)return;const i=s(n*s(S+o*v));if(i===Et)return;let u=(r.x===o?0:2)|Number(r.y&kt),l=i;return f&&d(i)&&(l=function(e){return d(e)?s(-e):e}(i),u^=1),new y(o,l,u)}}}const E={lowS:t.lowS,prehash:!1},k={lowS:t.lowS,prehash:!1};return c.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return c.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,n=!0){if(b(e))throw new Error("first arg must be private key");if(!b(t))throw new Error("second arg must be public key");return c.fromHex(t).multiply(u(e)).toRawBytes(n)},sign:function(e,n,r=E){const{seed:o,k2sig:i}=x(e,n,r);return Je(t.hash.outputLen,t.nByteLength,t.hmac)(o,i)},verify:function(e,n,r,o=k){const i=e;if(n=Ke("msgHash",n),r=Ke("publicKey",r),"strict"in o)throw new Error("options.strict was renamed to lowS");const{lowS:u,prehash:l}=o;let h,f;try{if("string"==typeof i||i instanceof Uint8Array)try{h=y.fromDER(i)}catch(e){if(!(e instanceof xt.Err))throw e;h=y.fromCompact(i)}else{if("object"!=typeof i||"bigint"!=typeof i.r||"bigint"!=typeof i.s)throw new Error("PARSE");{const{r:e,s:t}=i;h=new y(e,t)}}f=c.fromHex(r)}catch(e){if("PARSE"===e.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(u&&h.hasHighS())return!1;l&&(n=t.hash(n));const{r:d,s:p}=h,g=w(n),b=a(p),m=s(g*b),v=s(d*b),_=c.BASE.multiplyAndAddUnsafe(f,m,v)?.toAffine();return!!_&&s(_.x)===d},ProjectivePoint:c,Signature:y,utils:g}}class Tt extends xe{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,fe.hash(e);const n=ve(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new TypeError("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,o=new Uint8Array(r);o.set(n.length>r?e.create().update(n).digest():n);for(let e=0;enew Tt(e,t).update(n).digest(); /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ function It(e){return{hash:e,hmac:(t,...n)=>Lt(e,t,_e(...n)),randomBytes:ke}}Lt.create=(e,t)=>new Tt(e,t); /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ const Pt=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),jt=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Ut=BigInt(1),Bt=BigInt(2),Nt=(e,t)=>(e+t/Bt)/t;function Mt(e){const t=Pt,n=BigInt(3),r=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),u=e*e*e%t,l=u*u*e%t,h=ht(l,n,t)*l%t,f=ht(h,n,t)*l%t,d=ht(f,Bt,t)*u%t,p=ht(d,o,t)*d%t,y=ht(p,i,t)*p%t,g=ht(y,a,t)*y%t,b=ht(g,c,t)*g%t,m=ht(b,a,t)*y%t,w=ht(m,n,t)*l%t,v=ht(w,s,t)*p%t,_=ht(v,r,t)*u%t,x=ht(_,Bt,t);if(!$t.eql($t.sqr(x),e))throw new Error("Cannot find square root");return x}const $t=function(e,t,n=!1,r={}){if(e<=nt)throw new Error(`Expected Fp ORDER > 0, got ${e}`);const{nBitLength:o,nByteLength:i}=gt(e,t);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=dt(e),a=Object.freeze({ORDER:e,BITS:o,BYTES:i,MASK:Ve(o),ZERO:nt,ONE:rt,create:t=>ut(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return nt<=t&&te===nt,isOdd:e=>(e&rt)===rt,neg:t=>ut(-t,e),eql:(e,t)=>e===t,sqr:t=>ut(t*t,e),add:(t,n)=>ut(t+n,e),sub:(t,n)=>ut(t-n,e),mul:(t,n)=>ut(t*n,e),pow:(e,t)=>function(e,t,n){if(n 0");if(n===nt)return e.ONE;if(n===rt)return t;let r=e.ONE,o=t;for(;n>nt;)n&rt&&(r=e.mul(r,o)),o=e.sqr(o),n>>=rt;return r}(a,e,t),div:(t,n)=>ut(t*ft(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>ft(t,e),sqrt:r.sqrt||(e=>s(a,e)),invertBatch:e=>function(e,t){const n=new Array(t.length),r=t.reduce(((t,r,o)=>e.is0(r)?t:(n[o]=t,e.mul(t,r))),e.ONE),o=e.inv(r);return t.reduceRight(((t,r,o)=>e.is0(r)?t:(n[o]=e.mul(t,n[o]),e.mul(t,r))),o),n}(a,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?We(e,i):qe(e,i),fromBytes:e=>{if(e.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${e.length}`);return n?He(e):De(e)}});return Object.freeze(a)}(Pt,void 0,void 0,{sqrt:Mt}),zt=function(e,t){const n=t=>Rt({...e,...It(t)});return Object.freeze({...n(t),create:n})}({a:BigInt(0),b:BigInt(7),Fp:$t,n:jt,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=jt,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Ut*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,s=BigInt("0x100000000000000000000000000000000"),a=Nt(i*e,t),c=Nt(-r*e,t);let u=ut(e-a*n-c*o,t),l=ut(-a*r-c*i,t);const h=u>s,f=l>s;if(h&&(u=t-u),f&&(l=t-l),u>s||l>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:h,k1:u,k2neg:f,k2:l}}}},Ie),Ft=BigInt(0),Dt=e=>"bigint"==typeof e&&Fte.charCodeAt(0))));n=Ge(t,t),Ht[e]=n}return Ie(Ge(n,...t))}const Wt=e=>e.toRawBytes(!0).slice(1),Kt=e=>qe(e,32),Gt=e=>ut(e,Pt),Zt=e=>ut(e,jt),Vt=zt.ProjectivePoint;function Yt(e){let t=zt.utils.normPrivateKeyToScalar(e),n=Vt.fromPrivateKey(t);return{scalar:n.hasEvenY()?t:Zt(-t),bytes:Wt(n)}}function Xt(e){if(!Dt(e))throw new Error("bad x: need 0 < x < p");const t=Gt(e*e);let n=Mt(Gt(t*e+BigInt(7)));n%Bt!==Ft&&(n=Gt(-n));const r=new Vt(e,n,Ut);return r.assertValidity(),r}function Jt(...e){return Zt(De(qt("BIP0340/challenge",...e)))}function Qt(e,t,n){const r=Ke("signature",e,64),o=Ke("message",t),i=Ke("publicKey",n,32);try{const e=Xt(De(i)),t=De(r.subarray(0,32));if(!Dt(t))return!1;const n=De(r.subarray(32,64));if(!("bigint"==typeof(u=n)&&FtArray.from(e).reverse()));return(t,r)=>{const[o,i,s,a]=n.map((n=>n.reduce(((n,r)=>e.add(e.mul(n,t),r)))));return t=e.div(o,i),r=e.mul(r,e.div(s,a)),{x:t,y:r}}}($t,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map((e=>e.map((e=>BigInt(e)))))),nn=function(e,t){if(yt(e),!e.isValid(t.A)||!e.isValid(t.B)||!e.isValid(t.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const n=function(e,t){const n=e.ORDER;let r=Et;for(let e=n-kt;e%St===Et;e/=St)r+=kt;const o=r,i=(n-kt)/St**o,s=(i-kt)/St,a=St**o-kt,c=St**(o-kt),u=e.pow(t,i),l=e.pow(t,(i+kt)/St);let h=(t,n)=>{let r=u,i=e.pow(n,a),h=e.sqr(i);h=e.mul(h,n);let f=e.mul(t,h);f=e.pow(f,s),f=e.mul(f,i),i=e.mul(f,n),h=e.mul(f,t);let d=e.mul(h,i);f=e.pow(d,c);let p=e.eql(f,e.ONE);i=e.mul(h,l),f=e.mul(d,r),h=e.cmov(i,h,p),d=e.cmov(f,d,p);for(let t=o;t>kt;t--){let n=St**(t-St),o=e.pow(d,n);const s=e.eql(o,e.ONE);i=e.mul(h,r),r=e.mul(r,r),o=e.mul(d,r),h=e.cmov(i,h,s),d=e.cmov(o,d,s)}return{isValid:p,value:h}};if(e.ORDER%At===Ot){const n=(e.ORDER-Ot)/At,r=e.sqrt(e.neg(t));h=(t,o)=>{let i=e.sqr(o);const s=e.mul(t,o);i=e.mul(i,s);let a=e.pow(i,n);a=e.mul(a,s);const c=e.mul(a,r),u=e.mul(e.sqr(a),o),l=e.eql(u,t);return{isValid:l,value:e.cmov(c,a,l)}}}return h}(e,t.Z);if(!e.isOdd)throw new Error("Fp.isOdd is not implemented!");return r=>{let o,i,s,a,c,u,l,h;o=e.sqr(r),o=e.mul(o,t.Z),i=e.sqr(o),i=e.add(i,o),s=e.add(i,e.ONE),s=e.mul(s,t.B),a=e.cmov(t.Z,e.neg(i),!e.eql(i,e.ZERO)),a=e.mul(a,t.A),i=e.sqr(s),u=e.sqr(a),c=e.mul(u,t.A),i=e.add(i,c),i=e.mul(i,s),u=e.mul(u,a),c=e.mul(u,t.B),i=e.add(i,c),l=e.mul(o,s);const{isValid:f,value:d}=n(i,u);h=e.mul(o,r),h=e.mul(h,d),l=e.cmov(l,s,f),h=e.cmov(h,d,f);const p=e.isOdd(r)===e.isOdd(h);return h=e.cmov(e.neg(h),h,p),l=e.div(l,a),{x:l,y:h}}}($t,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:$t.create(BigInt("-11"))}); /*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */ function rn(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function on(...e){const t=(e,t)=>n=>e(t(n));return{encode:Array.from(e).reverse().reduce(((e,n)=>e?t(e,n.encode):n.encode),void 0),decode:e.reduce(((e,n)=>e?t(e,n.decode):n.decode),void 0)}}function sn(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("alphabet.encode input should be an array of numbers");return t.map((t=>{if(rn(t),t<0||t>=e.length)throw new Error(`Digit index outside alphabet: ${t} (alphabet: ${e.length})`);return e[t]}))},decode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("alphabet.decode input should be array of strings");return t.map((t=>{if("string"!=typeof t)throw new Error(`alphabet.decode: not string element=${t}`);const n=e.indexOf(t);if(-1===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n}))}}}function an(e=""){if("string"!=typeof e)throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("join.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`join.encode: non-string input=${e}`);return t.join(e)},decode:t=>{if("string"!=typeof t)throw new Error("join.decode input should be string");return t.split(e)}}}function cn(e,t="="){if(rn(e),"string"!=typeof t)throw new Error("padding chr should be string");return{encode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let e of n)if("string"!=typeof e)throw new Error(`padding.encode: non-string input=${e}`);for(;n.length*e%8;)n.push(t);return n},decode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let e of n)if("string"!=typeof e)throw new Error(`padding.decode: non-string input=${e}`);let r=n.length;if(r*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&n[r-1]===t;r--)if(!((r-1)*e%8))throw new Error("Invalid padding: string has too much padding");return n.slice(0,r)}}}function un(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function ln(e,t,n){if(t<2)throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let r=0;const o=[],i=Array.from(e);for(i.forEach((e=>{if(rn(e),e<0||e>=t)throw new Error(`Wrong integer: ${e}`)}));;){let e=0,s=!0;for(let o=r;o{const{x:t,y:n}=nn($t.create(e[0]));return tn(t,n)}),{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:$t.ORDER,m:1,k:128,expand:"xmd",hash:Ie});const hn=(e,t)=>t?hn(t,e%t):e,fn=(e,t)=>e+(t-hn(e,t));function dn(e,t,n,r){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(fn(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${fn(t,n)}`);let o=0,i=0;const s=2**n-1,a=[];for(const r of e){if(rn(r),r>=2**t)throw new Error(`convertRadix2: invalid data word=${r} from=${t}`);if(o=o<32)throw new Error(`convertRadix2: carry overflow pos=${i} from=${t}`);for(i+=t;i>=n;i-=n)a.push((o>>i-n&s)>>>0);o&=2**i-1}if(o=o<=t)throw new Error("Excess padding");if(!r&&o)throw new Error(`Non-zero padding: ${o}`);return r&&i>0&&a.push(o>>>0),a}function pn(e,t=!1){if(rn(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(fn(8,e)>32||fn(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!(n instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return dn(Array.from(n),8,e,!t)},decode:n=>{if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(dn(n,e,8,t))}}}function yn(e){if("function"!=typeof e)throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch(e){}}}const gn=on(pn(4),sn("0123456789ABCDEF"),an("")),bn=on(pn(5),sn("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),cn(5),an(""));on(pn(5),sn("0123456789ABCDEFGHIJKLMNOPQRSTUV"),cn(5),an("")),on(pn(5),sn("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),an(""),un((e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))));const mn=on(pn(6),sn("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),cn(6),an("")),wn=on(pn(6),sn("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),cn(6),an("")),vn=e=>{return on((rn(t=58),{encode:e=>{if(!(e instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return ln(Array.from(e),256,t)},decode:e=>{if(!Array.isArray(e)||e.length&&"number"!=typeof e[0])throw new Error("radix.decode input should be array of strings");return Uint8Array.from(ln(e,t,256))}}),sn(e),an(""));var t},_n=vn("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");vn("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),vn("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const xn=[0,2,3,5,6,7,9,10,11],En={encode(e){let t="";for(let n=0;n>25;let n=(33554431&e)<<5;for(let e=0;e>e&1)&&(n^=Sn[e]);return n}function An(e,t,n=1){const r=e.length;let o=1;for(let t=0;t126)throw new Error(`Invalid prefix (${e})`);o=On(o)^n>>5}o=On(o);for(let t=0;tn)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);const r=e.toLowerCase();if(e!==r&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const o=(e=r).lastIndexOf("1");if(0===o||-1===o)throw new Error('Letter "1" must be present between prefix and data only');const i=e.slice(0,o),s=e.slice(o+1);if(s.length<6)throw new Error("Data must be at least 6 characters long");const a=kn.decode(s).slice(0,-6),c=An(i,a,t);if(!s.endsWith(c))throw new Error(`Invalid checksum in ${e}: expected "${c}"`);return{prefix:i,words:a}}return{encode:function(e,n,r=90){if("string"!=typeof e)throw new Error("bech32.encode prefix should be string, not "+typeof e);if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof n);const o=e.length+7+n.length;if(!1!==r&&o>r)throw new TypeError(`Length ${o} exceeds limit ${r}`);return`${e=e.toLowerCase()}1${kn.encode(n)}${An(e,n,t)}`},decode:s,decodeToBytes:function(e){const{prefix:t,words:n}=s(e,!1);return{prefix:t,words:n,bytes:r(n)}},decodeUnsafe:yn(s),fromWords:r,fromWordsUnsafe:i,toWords:o}}const Rn=Cn("bech32");Cn("bech32m");const Tn={utf8:{encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)},hex:on(pn(4),sn("0123456789abcdef"),an(""),un((e=>{if("string"!=typeof e||e.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()}))),base16:gn,base32:bn,base64:mn,base64url:wn,base58:_n,base58xmr:En};Object.keys(Tn).join(", ");var Ln="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function In(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var Pn={};Object.defineProperty(Pn,"__esModule",{value:!0});var jn=Pn.wordlist=void 0;jn=Pn.wordlist="abandon\nability\nable\nabout\nabove\nabsent\nabsorb\nabstract\nabsurd\nabuse\naccess\naccident\naccount\naccuse\nachieve\nacid\nacoustic\nacquire\nacross\nact\naction\nactor\nactress\nactual\nadapt\nadd\naddict\naddress\nadjust\nadmit\nadult\nadvance\nadvice\naerobic\naffair\nafford\nafraid\nagain\nage\nagent\nagree\nahead\naim\nair\nairport\naisle\nalarm\nalbum\nalcohol\nalert\nalien\nall\nalley\nallow\nalmost\nalone\nalpha\nalready\nalso\nalter\nalways\namateur\namazing\namong\namount\namused\nanalyst\nanchor\nancient\nanger\nangle\nangry\nanimal\nankle\nannounce\nannual\nanother\nanswer\nantenna\nantique\nanxiety\nany\napart\napology\nappear\napple\napprove\napril\narch\narctic\narea\narena\nargue\narm\narmed\narmor\narmy\naround\narrange\narrest\narrive\narrow\nart\nartefact\nartist\nartwork\nask\naspect\nassault\nasset\nassist\nassume\nasthma\nathlete\natom\nattack\nattend\nattitude\nattract\nauction\naudit\naugust\naunt\nauthor\nauto\nautumn\naverage\navocado\navoid\nawake\naware\naway\nawesome\nawful\nawkward\naxis\nbaby\nbachelor\nbacon\nbadge\nbag\nbalance\nbalcony\nball\nbamboo\nbanana\nbanner\nbar\nbarely\nbargain\nbarrel\nbase\nbasic\nbasket\nbattle\nbeach\nbean\nbeauty\nbecause\nbecome\nbeef\nbefore\nbegin\nbehave\nbehind\nbelieve\nbelow\nbelt\nbench\nbenefit\nbest\nbetray\nbetter\nbetween\nbeyond\nbicycle\nbid\nbike\nbind\nbiology\nbird\nbirth\nbitter\nblack\nblade\nblame\nblanket\nblast\nbleak\nbless\nblind\nblood\nblossom\nblouse\nblue\nblur\nblush\nboard\nboat\nbody\nboil\nbomb\nbone\nbonus\nbook\nboost\nborder\nboring\nborrow\nboss\nbottom\nbounce\nbox\nboy\nbracket\nbrain\nbrand\nbrass\nbrave\nbread\nbreeze\nbrick\nbridge\nbrief\nbright\nbring\nbrisk\nbroccoli\nbroken\nbronze\nbroom\nbrother\nbrown\nbrush\nbubble\nbuddy\nbudget\nbuffalo\nbuild\nbulb\nbulk\nbullet\nbundle\nbunker\nburden\nburger\nburst\nbus\nbusiness\nbusy\nbutter\nbuyer\nbuzz\ncabbage\ncabin\ncable\ncactus\ncage\ncake\ncall\ncalm\ncamera\ncamp\ncan\ncanal\ncancel\ncandy\ncannon\ncanoe\ncanvas\ncanyon\ncapable\ncapital\ncaptain\ncar\ncarbon\ncard\ncargo\ncarpet\ncarry\ncart\ncase\ncash\ncasino\ncastle\ncasual\ncat\ncatalog\ncatch\ncategory\ncattle\ncaught\ncause\ncaution\ncave\nceiling\ncelery\ncement\ncensus\ncentury\ncereal\ncertain\nchair\nchalk\nchampion\nchange\nchaos\nchapter\ncharge\nchase\nchat\ncheap\ncheck\ncheese\nchef\ncherry\nchest\nchicken\nchief\nchild\nchimney\nchoice\nchoose\nchronic\nchuckle\nchunk\nchurn\ncigar\ncinnamon\ncircle\ncitizen\ncity\ncivil\nclaim\nclap\nclarify\nclaw\nclay\nclean\nclerk\nclever\nclick\nclient\ncliff\nclimb\nclinic\nclip\nclock\nclog\nclose\ncloth\ncloud\nclown\nclub\nclump\ncluster\nclutch\ncoach\ncoast\ncoconut\ncode\ncoffee\ncoil\ncoin\ncollect\ncolor\ncolumn\ncombine\ncome\ncomfort\ncomic\ncommon\ncompany\nconcert\nconduct\nconfirm\ncongress\nconnect\nconsider\ncontrol\nconvince\ncook\ncool\ncopper\ncopy\ncoral\ncore\ncorn\ncorrect\ncost\ncotton\ncouch\ncountry\ncouple\ncourse\ncousin\ncover\ncoyote\ncrack\ncradle\ncraft\ncram\ncrane\ncrash\ncrater\ncrawl\ncrazy\ncream\ncredit\ncreek\ncrew\ncricket\ncrime\ncrisp\ncritic\ncrop\ncross\ncrouch\ncrowd\ncrucial\ncruel\ncruise\ncrumble\ncrunch\ncrush\ncry\ncrystal\ncube\nculture\ncup\ncupboard\ncurious\ncurrent\ncurtain\ncurve\ncushion\ncustom\ncute\ncycle\ndad\ndamage\ndamp\ndance\ndanger\ndaring\ndash\ndaughter\ndawn\nday\ndeal\ndebate\ndebris\ndecade\ndecember\ndecide\ndecline\ndecorate\ndecrease\ndeer\ndefense\ndefine\ndefy\ndegree\ndelay\ndeliver\ndemand\ndemise\ndenial\ndentist\ndeny\ndepart\ndepend\ndeposit\ndepth\ndeputy\nderive\ndescribe\ndesert\ndesign\ndesk\ndespair\ndestroy\ndetail\ndetect\ndevelop\ndevice\ndevote\ndiagram\ndial\ndiamond\ndiary\ndice\ndiesel\ndiet\ndiffer\ndigital\ndignity\ndilemma\ndinner\ndinosaur\ndirect\ndirt\ndisagree\ndiscover\ndisease\ndish\ndismiss\ndisorder\ndisplay\ndistance\ndivert\ndivide\ndivorce\ndizzy\ndoctor\ndocument\ndog\ndoll\ndolphin\ndomain\ndonate\ndonkey\ndonor\ndoor\ndose\ndouble\ndove\ndraft\ndragon\ndrama\ndrastic\ndraw\ndream\ndress\ndrift\ndrill\ndrink\ndrip\ndrive\ndrop\ndrum\ndry\nduck\ndumb\ndune\nduring\ndust\ndutch\nduty\ndwarf\ndynamic\neager\neagle\nearly\nearn\nearth\neasily\neast\neasy\necho\necology\neconomy\nedge\nedit\neducate\neffort\negg\neight\neither\nelbow\nelder\nelectric\nelegant\nelement\nelephant\nelevator\nelite\nelse\nembark\nembody\nembrace\nemerge\nemotion\nemploy\nempower\nempty\nenable\nenact\nend\nendless\nendorse\nenemy\nenergy\nenforce\nengage\nengine\nenhance\nenjoy\nenlist\nenough\nenrich\nenroll\nensure\nenter\nentire\nentry\nenvelope\nepisode\nequal\nequip\nera\nerase\nerode\nerosion\nerror\nerupt\nescape\nessay\nessence\nestate\neternal\nethics\nevidence\nevil\nevoke\nevolve\nexact\nexample\nexcess\nexchange\nexcite\nexclude\nexcuse\nexecute\nexercise\nexhaust\nexhibit\nexile\nexist\nexit\nexotic\nexpand\nexpect\nexpire\nexplain\nexpose\nexpress\nextend\nextra\neye\neyebrow\nfabric\nface\nfaculty\nfade\nfaint\nfaith\nfall\nfalse\nfame\nfamily\nfamous\nfan\nfancy\nfantasy\nfarm\nfashion\nfat\nfatal\nfather\nfatigue\nfault\nfavorite\nfeature\nfebruary\nfederal\nfee\nfeed\nfeel\nfemale\nfence\nfestival\nfetch\nfever\nfew\nfiber\nfiction\nfield\nfigure\nfile\nfilm\nfilter\nfinal\nfind\nfine\nfinger\nfinish\nfire\nfirm\nfirst\nfiscal\nfish\nfit\nfitness\nfix\nflag\nflame\nflash\nflat\nflavor\nflee\nflight\nflip\nfloat\nflock\nfloor\nflower\nfluid\nflush\nfly\nfoam\nfocus\nfog\nfoil\nfold\nfollow\nfood\nfoot\nforce\nforest\nforget\nfork\nfortune\nforum\nforward\nfossil\nfoster\nfound\nfox\nfragile\nframe\nfrequent\nfresh\nfriend\nfringe\nfrog\nfront\nfrost\nfrown\nfrozen\nfruit\nfuel\nfun\nfunny\nfurnace\nfury\nfuture\ngadget\ngain\ngalaxy\ngallery\ngame\ngap\ngarage\ngarbage\ngarden\ngarlic\ngarment\ngas\ngasp\ngate\ngather\ngauge\ngaze\ngeneral\ngenius\ngenre\ngentle\ngenuine\ngesture\nghost\ngiant\ngift\ngiggle\nginger\ngiraffe\ngirl\ngive\nglad\nglance\nglare\nglass\nglide\nglimpse\nglobe\ngloom\nglory\nglove\nglow\nglue\ngoat\ngoddess\ngold\ngood\ngoose\ngorilla\ngospel\ngossip\ngovern\ngown\ngrab\ngrace\ngrain\ngrant\ngrape\ngrass\ngravity\ngreat\ngreen\ngrid\ngrief\ngrit\ngrocery\ngroup\ngrow\ngrunt\nguard\nguess\nguide\nguilt\nguitar\ngun\ngym\nhabit\nhair\nhalf\nhammer\nhamster\nhand\nhappy\nharbor\nhard\nharsh\nharvest\nhat\nhave\nhawk\nhazard\nhead\nhealth\nheart\nheavy\nhedgehog\nheight\nhello\nhelmet\nhelp\nhen\nhero\nhidden\nhigh\nhill\nhint\nhip\nhire\nhistory\nhobby\nhockey\nhold\nhole\nholiday\nhollow\nhome\nhoney\nhood\nhope\nhorn\nhorror\nhorse\nhospital\nhost\nhotel\nhour\nhover\nhub\nhuge\nhuman\nhumble\nhumor\nhundred\nhungry\nhunt\nhurdle\nhurry\nhurt\nhusband\nhybrid\nice\nicon\nidea\nidentify\nidle\nignore\nill\nillegal\nillness\nimage\nimitate\nimmense\nimmune\nimpact\nimpose\nimprove\nimpulse\ninch\ninclude\nincome\nincrease\nindex\nindicate\nindoor\nindustry\ninfant\ninflict\ninform\ninhale\ninherit\ninitial\ninject\ninjury\ninmate\ninner\ninnocent\ninput\ninquiry\ninsane\ninsect\ninside\ninspire\ninstall\nintact\ninterest\ninto\ninvest\ninvite\ninvolve\niron\nisland\nisolate\nissue\nitem\nivory\njacket\njaguar\njar\njazz\njealous\njeans\njelly\njewel\njob\njoin\njoke\njourney\njoy\njudge\njuice\njump\njungle\njunior\njunk\njust\nkangaroo\nkeen\nkeep\nketchup\nkey\nkick\nkid\nkidney\nkind\nkingdom\nkiss\nkit\nkitchen\nkite\nkitten\nkiwi\nknee\nknife\nknock\nknow\nlab\nlabel\nlabor\nladder\nlady\nlake\nlamp\nlanguage\nlaptop\nlarge\nlater\nlatin\nlaugh\nlaundry\nlava\nlaw\nlawn\nlawsuit\nlayer\nlazy\nleader\nleaf\nlearn\nleave\nlecture\nleft\nleg\nlegal\nlegend\nleisure\nlemon\nlend\nlength\nlens\nleopard\nlesson\nletter\nlevel\nliar\nliberty\nlibrary\nlicense\nlife\nlift\nlight\nlike\nlimb\nlimit\nlink\nlion\nliquid\nlist\nlittle\nlive\nlizard\nload\nloan\nlobster\nlocal\nlock\nlogic\nlonely\nlong\nloop\nlottery\nloud\nlounge\nlove\nloyal\nlucky\nluggage\nlumber\nlunar\nlunch\nluxury\nlyrics\nmachine\nmad\nmagic\nmagnet\nmaid\nmail\nmain\nmajor\nmake\nmammal\nman\nmanage\nmandate\nmango\nmansion\nmanual\nmaple\nmarble\nmarch\nmargin\nmarine\nmarket\nmarriage\nmask\nmass\nmaster\nmatch\nmaterial\nmath\nmatrix\nmatter\nmaximum\nmaze\nmeadow\nmean\nmeasure\nmeat\nmechanic\nmedal\nmedia\nmelody\nmelt\nmember\nmemory\nmention\nmenu\nmercy\nmerge\nmerit\nmerry\nmesh\nmessage\nmetal\nmethod\nmiddle\nmidnight\nmilk\nmillion\nmimic\nmind\nminimum\nminor\nminute\nmiracle\nmirror\nmisery\nmiss\nmistake\nmix\nmixed\nmixture\nmobile\nmodel\nmodify\nmom\nmoment\nmonitor\nmonkey\nmonster\nmonth\nmoon\nmoral\nmore\nmorning\nmosquito\nmother\nmotion\nmotor\nmountain\nmouse\nmove\nmovie\nmuch\nmuffin\nmule\nmultiply\nmuscle\nmuseum\nmushroom\nmusic\nmust\nmutual\nmyself\nmystery\nmyth\nnaive\nname\nnapkin\nnarrow\nnasty\nnation\nnature\nnear\nneck\nneed\nnegative\nneglect\nneither\nnephew\nnerve\nnest\nnet\nnetwork\nneutral\nnever\nnews\nnext\nnice\nnight\nnoble\nnoise\nnominee\nnoodle\nnormal\nnorth\nnose\nnotable\nnote\nnothing\nnotice\nnovel\nnow\nnuclear\nnumber\nnurse\nnut\noak\nobey\nobject\noblige\nobscure\nobserve\nobtain\nobvious\noccur\nocean\noctober\nodor\noff\noffer\noffice\noften\noil\nokay\nold\nolive\nolympic\nomit\nonce\none\nonion\nonline\nonly\nopen\nopera\nopinion\noppose\noption\norange\norbit\norchard\norder\nordinary\norgan\norient\noriginal\norphan\nostrich\nother\noutdoor\nouter\noutput\noutside\noval\noven\nover\nown\nowner\noxygen\noyster\nozone\npact\npaddle\npage\npair\npalace\npalm\npanda\npanel\npanic\npanther\npaper\nparade\nparent\npark\nparrot\nparty\npass\npatch\npath\npatient\npatrol\npattern\npause\npave\npayment\npeace\npeanut\npear\npeasant\npelican\npen\npenalty\npencil\npeople\npepper\nperfect\npermit\nperson\npet\nphone\nphoto\nphrase\nphysical\npiano\npicnic\npicture\npiece\npig\npigeon\npill\npilot\npink\npioneer\npipe\npistol\npitch\npizza\nplace\nplanet\nplastic\nplate\nplay\nplease\npledge\npluck\nplug\nplunge\npoem\npoet\npoint\npolar\npole\npolice\npond\npony\npool\npopular\nportion\nposition\npossible\npost\npotato\npottery\npoverty\npowder\npower\npractice\npraise\npredict\nprefer\nprepare\npresent\npretty\nprevent\nprice\npride\nprimary\nprint\npriority\nprison\nprivate\nprize\nproblem\nprocess\nproduce\nprofit\nprogram\nproject\npromote\nproof\nproperty\nprosper\nprotect\nproud\nprovide\npublic\npudding\npull\npulp\npulse\npumpkin\npunch\npupil\npuppy\npurchase\npurity\npurpose\npurse\npush\nput\npuzzle\npyramid\nquality\nquantum\nquarter\nquestion\nquick\nquit\nquiz\nquote\nrabbit\nraccoon\nrace\nrack\nradar\nradio\nrail\nrain\nraise\nrally\nramp\nranch\nrandom\nrange\nrapid\nrare\nrate\nrather\nraven\nraw\nrazor\nready\nreal\nreason\nrebel\nrebuild\nrecall\nreceive\nrecipe\nrecord\nrecycle\nreduce\nreflect\nreform\nrefuse\nregion\nregret\nregular\nreject\nrelax\nrelease\nrelief\nrely\nremain\nremember\nremind\nremove\nrender\nrenew\nrent\nreopen\nrepair\nrepeat\nreplace\nreport\nrequire\nrescue\nresemble\nresist\nresource\nresponse\nresult\nretire\nretreat\nreturn\nreunion\nreveal\nreview\nreward\nrhythm\nrib\nribbon\nrice\nrich\nride\nridge\nrifle\nright\nrigid\nring\nriot\nripple\nrisk\nritual\nrival\nriver\nroad\nroast\nrobot\nrobust\nrocket\nromance\nroof\nrookie\nroom\nrose\nrotate\nrough\nround\nroute\nroyal\nrubber\nrude\nrug\nrule\nrun\nrunway\nrural\nsad\nsaddle\nsadness\nsafe\nsail\nsalad\nsalmon\nsalon\nsalt\nsalute\nsame\nsample\nsand\nsatisfy\nsatoshi\nsauce\nsausage\nsave\nsay\nscale\nscan\nscare\nscatter\nscene\nscheme\nschool\nscience\nscissors\nscorpion\nscout\nscrap\nscreen\nscript\nscrub\nsea\nsearch\nseason\nseat\nsecond\nsecret\nsection\nsecurity\nseed\nseek\nsegment\nselect\nsell\nseminar\nsenior\nsense\nsentence\nseries\nservice\nsession\nsettle\nsetup\nseven\nshadow\nshaft\nshallow\nshare\nshed\nshell\nsheriff\nshield\nshift\nshine\nship\nshiver\nshock\nshoe\nshoot\nshop\nshort\nshoulder\nshove\nshrimp\nshrug\nshuffle\nshy\nsibling\nsick\nside\nsiege\nsight\nsign\nsilent\nsilk\nsilly\nsilver\nsimilar\nsimple\nsince\nsing\nsiren\nsister\nsituate\nsix\nsize\nskate\nsketch\nski\nskill\nskin\nskirt\nskull\nslab\nslam\nsleep\nslender\nslice\nslide\nslight\nslim\nslogan\nslot\nslow\nslush\nsmall\nsmart\nsmile\nsmoke\nsmooth\nsnack\nsnake\nsnap\nsniff\nsnow\nsoap\nsoccer\nsocial\nsock\nsoda\nsoft\nsolar\nsoldier\nsolid\nsolution\nsolve\nsomeone\nsong\nsoon\nsorry\nsort\nsoul\nsound\nsoup\nsource\nsouth\nspace\nspare\nspatial\nspawn\nspeak\nspecial\nspeed\nspell\nspend\nsphere\nspice\nspider\nspike\nspin\nspirit\nsplit\nspoil\nsponsor\nspoon\nsport\nspot\nspray\nspread\nspring\nspy\nsquare\nsqueeze\nsquirrel\nstable\nstadium\nstaff\nstage\nstairs\nstamp\nstand\nstart\nstate\nstay\nsteak\nsteel\nstem\nstep\nstereo\nstick\nstill\nsting\nstock\nstomach\nstone\nstool\nstory\nstove\nstrategy\nstreet\nstrike\nstrong\nstruggle\nstudent\nstuff\nstumble\nstyle\nsubject\nsubmit\nsubway\nsuccess\nsuch\nsudden\nsuffer\nsugar\nsuggest\nsuit\nsummer\nsun\nsunny\nsunset\nsuper\nsupply\nsupreme\nsure\nsurface\nsurge\nsurprise\nsurround\nsurvey\nsuspect\nsustain\nswallow\nswamp\nswap\nswarm\nswear\nsweet\nswift\nswim\nswing\nswitch\nsword\nsymbol\nsymptom\nsyrup\nsystem\ntable\ntackle\ntag\ntail\ntalent\ntalk\ntank\ntape\ntarget\ntask\ntaste\ntattoo\ntaxi\nteach\nteam\ntell\nten\ntenant\ntennis\ntent\nterm\ntest\ntext\nthank\nthat\ntheme\nthen\ntheory\nthere\nthey\nthing\nthis\nthought\nthree\nthrive\nthrow\nthumb\nthunder\nticket\ntide\ntiger\ntilt\ntimber\ntime\ntiny\ntip\ntired\ntissue\ntitle\ntoast\ntobacco\ntoday\ntoddler\ntoe\ntogether\ntoilet\ntoken\ntomato\ntomorrow\ntone\ntongue\ntonight\ntool\ntooth\ntop\ntopic\ntopple\ntorch\ntornado\ntortoise\ntoss\ntotal\ntourist\ntoward\ntower\ntown\ntoy\ntrack\ntrade\ntraffic\ntragic\ntrain\ntransfer\ntrap\ntrash\ntravel\ntray\ntreat\ntree\ntrend\ntrial\ntribe\ntrick\ntrigger\ntrim\ntrip\ntrophy\ntrouble\ntruck\ntrue\ntruly\ntrumpet\ntrust\ntruth\ntry\ntube\ntuition\ntumble\ntuna\ntunnel\nturkey\nturn\nturtle\ntwelve\ntwenty\ntwice\ntwin\ntwist\ntwo\ntype\ntypical\nugly\numbrella\nunable\nunaware\nuncle\nuncover\nunder\nundo\nunfair\nunfold\nunhappy\nuniform\nunique\nunit\nuniverse\nunknown\nunlock\nuntil\nunusual\nunveil\nupdate\nupgrade\nuphold\nupon\nupper\nupset\nurban\nurge\nusage\nuse\nused\nuseful\nuseless\nusual\nutility\nvacant\nvacuum\nvague\nvalid\nvalley\nvalve\nvan\nvanish\nvapor\nvarious\nvast\nvault\nvehicle\nvelvet\nvendor\nventure\nvenue\nverb\nverify\nversion\nvery\nvessel\nveteran\nviable\nvibrant\nvicious\nvictory\nvideo\nview\nvillage\nvintage\nviolin\nvirtual\nvirus\nvisa\nvisit\nvisual\nvital\nvivid\nvocal\nvoice\nvoid\nvolcano\nvolume\nvote\nvoyage\nwage\nwagon\nwait\nwalk\nwall\nwalnut\nwant\nwarfare\nwarm\nwarrior\nwash\nwasp\nwaste\nwater\nwave\nway\nwealth\nweapon\nwear\nweasel\nweather\nweb\nwedding\nweekend\nweird\nwelcome\nwest\nwet\nwhale\nwhat\nwheat\nwheel\nwhen\nwhere\nwhip\nwhisper\nwide\nwidth\nwife\nwild\nwill\nwin\nwindow\nwine\nwing\nwink\nwinner\nwinter\nwire\nwisdom\nwise\nwish\nwitness\nwolf\nwoman\nwonder\nwood\nwool\nword\nwork\nworld\nworry\nworth\nwrap\nwreck\nwrestle\nwrist\nwrite\nwrong\nyard\nyear\nyellow\nyou\nyoung\nyouth\nzebra\nzero\nzone\nzoo".split("\n");var Un={},Bn={};function Nn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function Mn(e){if("boolean"!=typeof e)throw new Error(`Expected boolean, not ${e}`)}function $n(e,...t){if(!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new TypeError(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function zn(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");Nn(e.outputLen),Nn(e.blockLen)}function Fn(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 Dn(e,t){$n(e);const n=t.outputLen;if(e.lengthnew Uint8Array(e.buffer,e.byteOffset,e.byteLength);e.u32=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));e.createView=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.rotr=(e,t)=>e<<32-t|e>>>t,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],!e.isLE)throw new Error("Non little-endian hardware is not supported");const n=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));e.bytesToHex=function(e){if(!(e instanceof Uint8Array))throw new Error("Uint8Array expected");let t="";for(let r=0;r{},e.asyncLoop=async function(t,n,r){let o=Date.now();for(let i=0;i=0&&te instanceof Uint8Array)))throw new Error("Uint8Array list expected");if(1===e.length)return e[0];const t=e.reduce(((e,t)=>e+t.length),0),n=new Uint8Array(t);for(let t=0,r=0;te().update(o(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t},e.wrapConstructorWithOpts=function(e){const t=(t,n)=>e(n).update(o(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t},e.randomBytes=function(e=32){if(t.crypto&&"function"==typeof t.crypto.getRandomValues)return t.crypto.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}}(Kn),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=void 0;const t=Bn,n=Kn;class r extends n.Hash{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,t.default.hash(e);const o=(0,n.toBytes)(r);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new TypeError("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,s=new Uint8Array(i);s.set(o.length>i?e.create().update(o).digest():o);for(let e=0;enew r(e,t).update(n).digest(),e.hmac.create=(e,t)=>new r(e,t)}(Wn),Object.defineProperty(qn,"__esModule",{value:!0}),qn.pbkdf2Async=qn.pbkdf2=void 0;const Zn=Bn,Vn=Wn,Yn=Kn;function Xn(e,t,n,r){Zn.default.hash(e);const o=(0,Yn.checkOpts)({dkLen:32,asyncTick:10},r),{c:i,dkLen:s,asyncTick:a}=o;if(Zn.default.number(i),Zn.default.number(s),Zn.default.number(a),i<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const c=(0,Yn.toBytes)(t),u=(0,Yn.toBytes)(n),l=new Uint8Array(s),h=Vn.hmac.create(e,c),f=h._cloneInto().update(u);return{c:i,dkLen:s,asyncTick:a,DK:l,PRF:h,PRFSalt:f}}function Jn(e,t,n,r,o){return e.destroy(),t.destroy(),r&&r.destroy(),o.fill(0),n}qn.pbkdf2=function(e,t,n,r){const{c:o,dkLen:i,DK:s,PRF:a,PRFSalt:c}=Xn(e,t,n,r);let u;const l=new Uint8Array(4),h=(0,Yn.createView)(l),f=new Uint8Array(a.outputLen);for(let e=1,t=0;t{c._cloneInto(l).update(d).digestInto(d);for(let e=0;er-i&&(this.process(n,0),i=0);for(let e=i;e>o&i),a=Number(n&i),c=r?4:0,u=r?0:4;e.setUint32(t+c,s,r),e.setUint32(t+u,a,r)}(n,r-8,BigInt(8*this.length),o),this.process(n,0);const s=(0,nr.createView)(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;ee&t^e&n^t&n,sr=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]),ar=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),cr=new Uint32Array(64);class ur extends rr.SHA2{constructor(){super(64,32,8,!1),this.A=0|ar[0],this.B=0|ar[1],this.C=0|ar[2],this.D=0|ar[3],this.E=0|ar[4],this.F=0|ar[5],this.G=0|ar[6],this.H=0|ar[7]}get(){const{A:e,B:t,C:n,D:r,E:o,F:i,G:s,H:a}=this;return[e,t,n,r,o,i,s,a]}set(e,t,n,r,o,i,s,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|o,this.F=0|i,this.G=0|s,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)cr[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=cr[e-15],n=cr[e-2],r=(0,or.rotr)(t,7)^(0,or.rotr)(t,18)^t>>>3,o=(0,or.rotr)(n,17)^(0,or.rotr)(n,19)^n>>>10;cr[e]=o+cr[e-7]+r+cr[e-16]|0}let{A:n,B:r,C:o,D:i,E:s,F:a,G:c,H:u}=this;for(let e=0;e<64;e++){const t=u+((0,or.rotr)(s,6)^(0,or.rotr)(s,11)^(0,or.rotr)(s,25))+((l=s)&a^~l&c)+sr[e]+cr[e]|0,h=((0,or.rotr)(n,2)^(0,or.rotr)(n,13)^(0,or.rotr)(n,22))+ir(n,r,o)|0;u=c,c=a,a=s,s=i+t|0,i=o,o=r,r=n,n=t+h|0}var l;n=n+this.A|0,r=r+this.B|0,o=o+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(n,r,o,i,s,a,c,u)}roundClean(){cr.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class lr extends ur{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}}Qn.sha256=(0,or.wrapConstructor)((()=>new ur)),Qn.sha224=(0,or.wrapConstructor)((()=>new lr));var hr={},fr={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.add=e.toBig=e.split=e.fromBig=void 0;const t=BigInt(2**32-1),n=BigInt(32);function r(e,r=!1){return r?{h:Number(e&t),l:Number(e>>n&t)}:{h:0|Number(e>>n&t),l:0|Number(e&t)}}function o(e,t=!1){let n=new Uint32Array(e.length),o=new Uint32Array(e.length);for(let i=0;iBigInt(e>>>0)<>>0);function i(e,t,n,r){const o=(t>>>0)+(r>>>0);return{h:e+n+(o/2**32|0)|0,l:0|o}}e.add=i;const s={fromBig:r,split:o,toBig:e.toBig,shrSH:(e,t,n)=>e>>>n,shrSL:(e,t,n)=>e<<32-n|t>>>n,rotrSH:(e,t,n)=>e>>>n|t<<32-n,rotrSL:(e,t,n)=>e<<32-n|t>>>n,rotrBH:(e,t,n)=>e<<64-n|t>>>n-32,rotrBL:(e,t,n)=>e>>>n-32|t<<64-n,rotr32H:(e,t)=>t,rotr32L:(e,t)=>e,rotlSH:(e,t,n)=>e<>>32-n,rotlSL:(e,t,n)=>t<>>32-n,rotlBH:(e,t,n)=>t<>>64-n,rotlBL:(e,t,n)=>e<>>64-n,add:i,add3L:(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),add3H:(e,t,n,r)=>t+n+r+(e/2**32|0)|0,add4L:(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),add4H:(e,t,n,r,o)=>t+n+r+o+(e/2**32|0)|0,add5H:(e,t,n,r,o,i)=>t+n+r+o+i+(e/2**32|0)|0,add5L:(e,t,n,r,o)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(o>>>0)};e.default=s}(fr),Object.defineProperty(hr,"__esModule",{value:!0}),hr.sha384=hr.sha512_256=hr.sha512_224=hr.sha512=hr.SHA512=void 0;const dr=er,pr=fr,yr=Kn,[gr,br]=pr.default.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((e=>BigInt(e)))),mr=new Uint32Array(80),wr=new Uint32Array(80);let vr=class extends dr.SHA2{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:n,Bl:r,Ch:o,Cl:i,Dh:s,Dl:a,Eh:c,El:u,Fh:l,Fl:h,Gh:f,Gl:d,Hh:p,Hl:y}=this;return[e,t,n,r,o,i,s,a,c,u,l,h,f,d,p,y]}set(e,t,n,r,o,i,s,a,c,u,l,h,f,d,p,y){this.Ah=0|e,this.Al=0|t,this.Bh=0|n,this.Bl=0|r,this.Ch=0|o,this.Cl=0|i,this.Dh=0|s,this.Dl=0|a,this.Eh=0|c,this.El=0|u,this.Fh=0|l,this.Fl=0|h,this.Gh=0|f,this.Gl=0|d,this.Hh=0|p,this.Hl=0|y}process(e,t){for(let n=0;n<16;n++,t+=4)mr[n]=e.getUint32(t),wr[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|mr[e-15],n=0|wr[e-15],r=pr.default.rotrSH(t,n,1)^pr.default.rotrSH(t,n,8)^pr.default.shrSH(t,n,7),o=pr.default.rotrSL(t,n,1)^pr.default.rotrSL(t,n,8)^pr.default.shrSL(t,n,7),i=0|mr[e-2],s=0|wr[e-2],a=pr.default.rotrSH(i,s,19)^pr.default.rotrBH(i,s,61)^pr.default.shrSH(i,s,6),c=pr.default.rotrSL(i,s,19)^pr.default.rotrBL(i,s,61)^pr.default.shrSL(i,s,6),u=pr.default.add4L(o,c,wr[e-7],wr[e-16]),l=pr.default.add4H(u,r,a,mr[e-7],mr[e-16]);mr[e]=0|l,wr[e]=0|u}let{Ah:n,Al:r,Bh:o,Bl:i,Ch:s,Cl:a,Dh:c,Dl:u,Eh:l,El:h,Fh:f,Fl:d,Gh:p,Gl:y,Hh:g,Hl:b}=this;for(let e=0;e<80;e++){const t=pr.default.rotrSH(l,h,14)^pr.default.rotrSH(l,h,18)^pr.default.rotrBH(l,h,41),m=pr.default.rotrSL(l,h,14)^pr.default.rotrSL(l,h,18)^pr.default.rotrBL(l,h,41),w=l&f^~l&p,v=h&d^~h&y,_=pr.default.add5L(b,m,v,br[e],wr[e]),x=pr.default.add5H(_,g,t,w,gr[e],mr[e]),E=0|_,k=pr.default.rotrSH(n,r,28)^pr.default.rotrBH(n,r,34)^pr.default.rotrBH(n,r,39),S=pr.default.rotrSL(n,r,28)^pr.default.rotrBL(n,r,34)^pr.default.rotrBL(n,r,39),O=n&o^n&s^o&s,A=r&i^r&a^i&a;g=0|p,b=0|y,p=0|f,y=0|d,f=0|l,d=0|h,({h:l,l:h}=pr.default.add(0|c,0|u,0|x,0|E)),c=0|s,u=0|a,s=0|o,a=0|i,o=0|n,i=0|r;const C=pr.default.add3L(E,S,A);n=pr.default.add3H(C,x,k,O),r=0|C}({h:n,l:r}=pr.default.add(0|this.Ah,0|this.Al,0|n,0|r)),({h:o,l:i}=pr.default.add(0|this.Bh,0|this.Bl,0|o,0|i)),({h:s,l:a}=pr.default.add(0|this.Ch,0|this.Cl,0|s,0|a)),({h:c,l:u}=pr.default.add(0|this.Dh,0|this.Dl,0|c,0|u)),({h:l,l:h}=pr.default.add(0|this.Eh,0|this.El,0|l,0|h)),({h:f,l:d}=pr.default.add(0|this.Fh,0|this.Fl,0|f,0|d)),({h:p,l:y}=pr.default.add(0|this.Gh,0|this.Gl,0|p,0|y)),({h:g,l:b}=pr.default.add(0|this.Hh,0|this.Hl,0|g,0|b)),this.set(n,r,o,i,s,a,c,u,l,h,f,d,p,y,g,b)}roundClean(){mr.fill(0),wr.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};hr.SHA512=vr;let _r=class extends vr{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}},xr=class extends vr{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}},Er=class extends vr{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}};hr.sha512=(0,yr.wrapConstructor)((()=>new vr)),hr.sha512_224=(0,yr.wrapConstructor)((()=>new _r)),hr.sha512_256=(0,yr.wrapConstructor)((()=>new xr)),hr.sha384=(0,yr.wrapConstructor)((()=>new Er));var kr={};!function(e){function t(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function n(...e){const t=(e,t)=>n=>e(t(n));return{encode:Array.from(e).reverse().reduce(((e,n)=>e?t(e,n.encode):n.encode),void 0),decode:e.reduce(((e,n)=>e?t(e,n.decode):n.decode),void 0)}}function r(e){return{encode:n=>{if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("alphabet.encode input should be an array of numbers");return n.map((n=>{if(t(n),n<0||n>=e.length)throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${e.length})`);return e[n]}))},decode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("alphabet.decode input should be array of strings");return t.map((t=>{if("string"!=typeof t)throw new Error(`alphabet.decode: not string element=${t}`);const n=e.indexOf(t);if(-1===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n}))}}}function o(e=""){if("string"!=typeof e)throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("join.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`join.encode: non-string input=${e}`);return t.join(e)},decode:t=>{if("string"!=typeof t)throw new Error("join.decode input should be string");return t.split(e)}}}function i(e,n="="){if(t(e),"string"!=typeof n)throw new Error("padding chr should be string");return{encode(t){if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("padding.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`padding.encode: non-string input=${e}`);for(;t.length*e%8;)t.push(n);return t},decode(t){if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("padding.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`padding.decode: non-string input=${e}`);let r=t.length;if(r*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&t[r-1]===n;r--)if(!((r-1)*e%8))throw new Error("Invalid padding: string has too much padding");return t.slice(0,r)}}}function s(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function a(e,n,r){if(n<2)throw new Error(`convertRadix: wrong from=${n}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: wrong to=${r}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let o=0;const i=[],s=Array.from(e);for(s.forEach((e=>{if(t(e),e<0||e>=n)throw new Error(`Wrong integer: ${e}`)}));;){let e=0,t=!0;for(let i=o;it?c(t,e%t):e,u=(e,t)=>e+(t-c(e,t));function l(e,n,r,o){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(n<=0||n>32)throw new Error(`convertRadix2: wrong from=${n}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(u(n,r)>32)throw new Error(`convertRadix2: carry overflow from=${n} to=${r} carryBits=${u(n,r)}`);let i=0,s=0;const a=2**r-1,c=[];for(const o of e){if(t(o),o>=2**n)throw new Error(`convertRadix2: invalid data word=${o} from=${n}`);if(i=i<32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${n}`);for(s+=n;s>=r;s-=r)c.push((i>>s-r&a)>>>0);i&=2**s-1}if(i=i<=n)throw new Error("Excess padding");if(!o&&i)throw new Error(`Non-zero padding: ${i}`);return o&&s>0&&c.push(i>>>0),c}function h(e){return t(e),{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return a(Array.from(t),256,e)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix.decode input should be array of strings");return Uint8Array.from(a(t,e,256))}}}function f(e,n=!1){if(t(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(u(8,e)>32||u(e,8)>32)throw new Error("radix2: carry overflow");return{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return l(Array.from(t),8,e,!n)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(l(t,e,8,n))}}}function d(e){if("function"!=typeof e)throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch(e){}}}function p(e,n){if(t(e),"function"!=typeof n)throw new Error("checksum fn should be function");return{encode(t){if(!(t instanceof Uint8Array))throw new Error("checksum.encode: input should be Uint8Array");const r=n(t).slice(0,e),o=new Uint8Array(t.length+e);return o.set(t),o.set(r,t.length),o},decode(t){if(!(t instanceof Uint8Array))throw new Error("checksum.decode: input should be Uint8Array");const r=t.slice(0,-e),o=n(r).slice(0,e),i=t.slice(-e);for(let t=0;te.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")))),e.base64=n(f(6),r("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),i(6),o("")),e.base64url=n(f(6),r("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),i(6),o(""));const y=e=>n(h(58),r(e),o(""));e.base58=y("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),e.base58flickr=y("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),e.base58xrp=y("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const g=[0,2,3,5,6,7,9,10,11];e.base58xmr={encode(t){let n="";for(let r=0;rn(p(4,(e=>t(t(e)))),e.base58);const b=n(r("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),o("")),m=[996825010,642813549,513874426,1027748829,705979059];function w(e){const t=e>>25;let n=(33554431&e)<<5;for(let e=0;e>e&1)&&(n^=m[e]);return n}function v(e,t,n=1){const r=e.length;let o=1;for(let t=0;t126)throw new Error(`Invalid prefix (${e})`);o=w(o)^n>>5}o=w(o);for(let t=0;tn)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);const r=e.toLowerCase();if(e!==r&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const o=(e=r).lastIndexOf("1");if(0===o||-1===o)throw new Error('Letter "1" must be present between prefix and data only');const i=e.slice(0,o),s=e.slice(o+1);if(s.length<6)throw new Error("Data must be at least 6 characters long");const a=b.decode(s).slice(0,-6),c=v(i,a,t);if(!s.endsWith(c))throw new Error(`Invalid checksum in ${e}: expected "${c}"`);return{prefix:i,words:a}}return{encode:function(e,n,r=90){if("string"!=typeof e)throw new Error("bech32.encode prefix should be string, not "+typeof e);if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof n);const o=e.length+7+n.length;if(!1!==r&&o>r)throw new TypeError(`Length ${o} exceeds limit ${r}`);return`${e=e.toLowerCase()}1${b.encode(n)}${v(e,n,t)}`},decode:s,decodeToBytes:function(e){const{prefix:t,words:n}=s(e,!1);return{prefix:t,words:n,bytes:r(n)}},decodeUnsafe:d(s),fromWords:r,fromWordsUnsafe:i,toWords:o}}e.bech32=_("bech32"),e.bech32m=_("bech32m"),e.utf8={encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)},e.hex=n(f(4),r("0123456789abcdef"),o(""),s((e=>{if("string"!=typeof e||e.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()})));const x={utf8:e.utf8,hex:e.hex,base16:e.base16,base32:e.base32,base64:e.base64,base64url:e.base64url,base58:e.base58,base58xmr:e.base58xmr},E=`Invalid encoding type. Available types: ${Object.keys(x).join(", ")}`;e.bytesToString=(e,t)=>{if("string"!=typeof e||!x.hasOwnProperty(e))throw new TypeError(E);if(!(t instanceof Uint8Array))throw new TypeError("bytesToString() expects Uint8Array");return x[e].encode(t)},e.str=e.bytesToString;e.stringToBytes=(e,t)=>{if(!x.hasOwnProperty(e))throw new TypeError(E);if("string"!=typeof t)throw new TypeError("stringToBytes() expects string");return x[e].decode(t)},e.bytes=e.stringToBytes}(kr),Object.defineProperty(Un,"__esModule",{value:!0});var Sr=Un.mnemonicToSeedSync=Un.mnemonicToSeed=zr=Un.validateMnemonic=Un.entropyToMnemonic=Un.mnemonicToEntropy=Ur=Un.generateMnemonic=void 0; /*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) */const Or=Bn,Ar=qn,Cr=Qn,Rr=hr,Tr=Kn,Lr=kr;function Ir(e){if("string"!=typeof e)throw new TypeError("Invalid mnemonic type: "+typeof e);return e.normalize("NFKD")}function Pr(e){const t=Ir(e),n=t.split(" ");if(![12,15,18,21,24].includes(n.length))throw new Error("Invalid mnemonic");return{nfkd:t,words:n}}function jr(e){Or.default.bytes(e,16,20,24,28,32)}var Ur=Un.generateMnemonic=function(e,t=128){if(Or.default.number(t),t%32!=0||t>256)throw new TypeError("Invalid entropy");return $r((0,Tr.randomBytes)(t/8),e)};const Br=e=>{const t=8-e.length/4;return new Uint8Array([(0,Cr.sha256)(e)[0]>>t<{if("string"!=typeof e)throw new Error(`Wordlist: non-string element: ${e}`)})),Lr.utils.chain(Lr.utils.checksum(1,Br),Lr.utils.radix2(11,!0),Lr.utils.alphabet(e))}function Mr(e,t){const{words:n}=Pr(e),r=Nr(t).decode(n);return jr(r),r}function $r(e,t){jr(e);return Nr(t).encode(e).join((e=>"ใ‚ใ„ใ“ใใ—ใ‚“"===e[0])(t)?"ใ€€":" ")}Un.mnemonicToEntropy=Mr,Un.entropyToMnemonic=$r;var zr=Un.validateMnemonic=function(e,t){try{Mr(e,t)}catch(e){return!1}return!0};const Fr=e=>Ir(`mnemonic${e}`);Un.mnemonicToSeed=function(e,t=""){return(0,Ar.pbkdf2Async)(Rr.sha512,Pr(e).nfkd,Fr(t),{c:2048,dkLen:64})},Sr=Un.mnemonicToSeedSync=function(e,t=""){return(0,Ar.pbkdf2)(Rr.sha512,Pr(e).nfkd,Fr(t),{c:2048,dkLen:64})};const Dr=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Hr=Uint8Array.from({length:16},((e,t)=>t)),qr=Hr.map((e=>(9*e+5)%16));let Wr=[Hr],Kr=[qr];for(let e=0;e<4;e++)for(let t of[Wr,Kr])t.push(t[e].map((e=>Dr[e])));const Gr=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map((e=>new Uint8Array(e))),Zr=Wr.map(((e,t)=>e.map((e=>Gr[t][e])))),Vr=Kr.map(((e,t)=>e.map((e=>Gr[t][e])))),Yr=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),Xr=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]),Jr=(e,t)=>e<>>32-t;function Qr(e,t,n,r){return 0===e?t^n^r:1===e?t&n|~t&r:2===e?(t|~n)^r:3===e?t&r|n&~r:t^(n|~r)}const eo=new Uint32Array(16);class to extends Se{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:e,h1:t,h2:n,h3:r,h4:o}=this;return[e,t,n,r,o]}set(e,t,n,r,o){this.h0=0|e,this.h1=0|t,this.h2=0|n,this.h3=0|r,this.h4=0|o}process(e,t){for(let n=0;n<16;n++,t+=4)eo[n]=e.getUint32(t,!0);let n=0|this.h0,r=n,o=0|this.h1,i=o,s=0|this.h2,a=s,c=0|this.h3,u=c,l=0|this.h4,h=l;for(let e=0;e<5;e++){const t=4-e,f=Yr[e],d=Xr[e],p=Wr[e],y=Kr[e],g=Zr[e],b=Vr[e];for(let t=0;t<16;t++){const r=Jr(n+Qr(e,o,s,c)+eo[p[t]]+f,g[t])+l|0;n=l,l=c,c=0|Jr(s,10),s=o,o=r}for(let e=0;e<16;e++){const n=Jr(r+Qr(t,i,a,u)+eo[y[e]]+d,b[e])+h|0;r=h,h=u,u=0|Jr(a,10),a=i,i=n}}this.set(this.h1+s+u|0,this.h2+c+h|0,this.h3+l+r|0,this.h4+n+i|0,this.h0+o+a|0)}roundClean(){eo.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}const no=Ee((()=>new to)),ro=BigInt(2**32-1),oo=BigInt(32);function io(e,t=!1){return t?{h:Number(e&ro),l:Number(e>>oo&ro)}:{h:0|Number(e>>oo&ro),l:0|Number(e&ro)}}const so={fromBig:io,split:function(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let o=0;oBigInt(e>>>0)<>>0),shrSH:(e,t,n)=>e>>>n,shrSL:(e,t,n)=>e<<32-n|t>>>n,rotrSH:(e,t,n)=>e>>>n|t<<32-n,rotrSL:(e,t,n)=>e<<32-n|t>>>n,rotrBH:(e,t,n)=>e<<64-n|t>>>n-32,rotrBL:(e,t,n)=>e>>>n-32|t<<64-n,rotr32H:(e,t)=>t,rotr32L:(e,t)=>e,rotlSH:(e,t,n)=>e<>>32-n,rotlSL:(e,t,n)=>t<>>32-n,rotlBH:(e,t,n)=>t<>>64-n,rotlBL:(e,t,n)=>e<>>64-n,add:function(e,t,n,r){const o=(t>>>0)+(r>>>0);return{h:e+n+(o/2**32|0)|0,l:0|o}},add3L:(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),add3H:(e,t,n,r)=>t+n+r+(e/2**32|0)|0,add4L:(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),add4H:(e,t,n,r,o)=>t+n+r+o+(e/2**32|0)|0,add5H:(e,t,n,r,o,i)=>t+n+r+o+i+(e/2**32|0)|0,add5L:(e,t,n,r,o)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(o>>>0)},[ao,co]=so.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((e=>BigInt(e)))),uo=new Uint32Array(80),lo=new Uint32Array(80);class ho extends Se{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:n,Bl:r,Ch:o,Cl:i,Dh:s,Dl:a,Eh:c,El:u,Fh:l,Fl:h,Gh:f,Gl:d,Hh:p,Hl:y}=this;return[e,t,n,r,o,i,s,a,c,u,l,h,f,d,p,y]}set(e,t,n,r,o,i,s,a,c,u,l,h,f,d,p,y){this.Ah=0|e,this.Al=0|t,this.Bh=0|n,this.Bl=0|r,this.Ch=0|o,this.Cl=0|i,this.Dh=0|s,this.Dl=0|a,this.Eh=0|c,this.El=0|u,this.Fh=0|l,this.Fl=0|h,this.Gh=0|f,this.Gl=0|d,this.Hh=0|p,this.Hl=0|y}process(e,t){for(let n=0;n<16;n++,t+=4)uo[n]=e.getUint32(t),lo[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|uo[e-15],n=0|lo[e-15],r=so.rotrSH(t,n,1)^so.rotrSH(t,n,8)^so.shrSH(t,n,7),o=so.rotrSL(t,n,1)^so.rotrSL(t,n,8)^so.shrSL(t,n,7),i=0|uo[e-2],s=0|lo[e-2],a=so.rotrSH(i,s,19)^so.rotrBH(i,s,61)^so.shrSH(i,s,6),c=so.rotrSL(i,s,19)^so.rotrBL(i,s,61)^so.shrSL(i,s,6),u=so.add4L(o,c,lo[e-7],lo[e-16]),l=so.add4H(u,r,a,uo[e-7],uo[e-16]);uo[e]=0|l,lo[e]=0|u}let{Ah:n,Al:r,Bh:o,Bl:i,Ch:s,Cl:a,Dh:c,Dl:u,Eh:l,El:h,Fh:f,Fl:d,Gh:p,Gl:y,Hh:g,Hl:b}=this;for(let e=0;e<80;e++){const t=so.rotrSH(l,h,14)^so.rotrSH(l,h,18)^so.rotrBH(l,h,41),m=so.rotrSL(l,h,14)^so.rotrSL(l,h,18)^so.rotrBL(l,h,41),w=l&f^~l&p,v=h&d^~h&y,_=so.add5L(b,m,v,co[e],lo[e]),x=so.add5H(_,g,t,w,ao[e],uo[e]),E=0|_,k=so.rotrSH(n,r,28)^so.rotrBH(n,r,34)^so.rotrBH(n,r,39),S=so.rotrSL(n,r,28)^so.rotrBL(n,r,34)^so.rotrBL(n,r,39),O=n&o^n&s^o&s,A=r&i^r&a^i&a;g=0|p,b=0|y,p=0|f,y=0|d,f=0|l,d=0|h,({h:l,l:h}=so.add(0|c,0|u,0|x,0|E)),c=0|s,u=0|a,s=0|o,a=0|i,o=0|n,i=0|r;const C=so.add3L(E,S,A);n=so.add3H(C,x,k,O),r=0|C}({h:n,l:r}=so.add(0|this.Ah,0|this.Al,0|n,0|r)),({h:o,l:i}=so.add(0|this.Bh,0|this.Bl,0|o,0|i)),({h:s,l:a}=so.add(0|this.Ch,0|this.Cl,0|s,0|a)),({h:c,l:u}=so.add(0|this.Dh,0|this.Dl,0|c,0|u)),({h:l,l:h}=so.add(0|this.Eh,0|this.El,0|l,0|h)),({h:f,l:d}=so.add(0|this.Fh,0|this.Fl,0|f,0|d)),({h:p,l:y}=so.add(0|this.Gh,0|this.Gl,0|p,0|y)),({h:g,l:b}=so.add(0|this.Hh,0|this.Hl,0|g,0|b)),this.set(n,r,o,i,s,a,c,u,l,h,f,d,p,y,g,b)}roundClean(){uo.fill(0),lo.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class fo extends ho{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}class po extends ho{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}class yo extends ho{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}const go=Ee((()=>new ho));Ee((()=>new fo)),Ee((()=>new po)),Ee((()=>new yo));const bo=zt.ProjectivePoint,mo=(e=>on(function(e,t){if(rn(e),"function"!=typeof t)throw new Error("checksum fn should be function");return{encode(n){if(!(n instanceof Uint8Array))throw new Error("checksum.encode: input should be Uint8Array");const r=t(n).slice(0,e),o=new Uint8Array(n.length+e);return o.set(n),o.set(r,n.length),o},decode(n){if(!(n instanceof Uint8Array))throw new Error("checksum.decode: input should be Uint8Array");const r=n.slice(0,-e),o=t(r).slice(0,e),i=n.slice(-e);for(let t=0;te(e(t)))),_n))(Ie);function wo(e){return BigInt(`0x${be(e)}`)}const vo=we("Bitcoin seed"),_o={private:76066276,public:76067358},xo=2147483648,Eo=e=>{if(!Number.isSafeInteger(e)||e<0||e>2**32-1)throw new Error(`Invalid number=${e}. Should be from 0 to 2 ** 32 - 1`);const t=new Uint8Array(4);return pe(t).setUint32(0,e,!1),t};class ko{get fingerprint(){if(!this.pubHash)throw new Error("No publicKey set!");return e=this.pubHash,pe(e).getUint32(0,!1);var e}get identifier(){return this.pubHash}get pubKeyHash(){return this.pubHash}get privateKey(){return this.privKeyBytes||null}get publicKey(){return this.pubKey||null}get privateExtendedKey(){const e=this.privateKey;if(!e)throw new Error("No private key");return mo.encode(this.serialize(this.versions.private,_e(new Uint8Array([0]),e)))}get publicExtendedKey(){if(!this.pubKey)throw new Error("No public key");return mo.encode(this.serialize(this.versions.public,this.pubKey))}static fromMasterSeed(e,t=_o){if(he(e),8*e.length<128||8*e.length>512)throw new Error(`HDKey: wrong seed length=${e.length}. Should be between 128 and 512 bits; 256 bits is advised)`);const n=Lt(go,vo,e);return new ko({versions:t,chainCode:n.slice(32),privateKey:n.slice(0,32)})}static fromExtendedKey(e,t=_o){const n=mo.decode(e),r=pe(n),o=r.getUint32(0,!1),i={versions:t,depth:n[4],parentFingerprint:r.getUint32(5,!1),index:r.getUint32(9,!1),chainCode:n.slice(13,45)},s=n.slice(45),a=0===s[0];if(o!==t[a?"private":"public"])throw new Error("Version mismatch");return new ko(a?{...i,privateKey:s.slice(1)}:{...i,publicKey:s})}static fromJSON(e){return ko.fromExtendedKey(e.xpriv)}constructor(e){if(this.depth=0,this.index=0,this.chainCode=null,this.parentFingerprint=0,!e||"object"!=typeof e)throw new Error("HDKey.constructor must not be called directly");if(this.versions=e.versions||_o,this.depth=e.depth||0,this.chainCode=e.chainCode,this.index=e.index||0,this.parentFingerprint=e.parentFingerprint||0,!this.depth&&(this.parentFingerprint||this.index))throw new Error("HDKey: zero depth with non-zero index/parent fingerprint");if(e.publicKey&&e.privateKey)throw new Error("HDKey: publicKey and privateKey at same time.");if(e.privateKey){if(!zt.utils.isValidPrivateKey(e.privateKey))throw new Error("Invalid private key");this.privKey="bigint"==typeof e.privateKey?e.privateKey:wo(e.privateKey),this.privKeyBytes=me(this.privKey.toString(16).padStart(64,"0")),this.pubKey=zt.getPublicKey(e.privateKey,!0)}else{if(!e.publicKey)throw new Error("HDKey: no public or private key provided");this.pubKey=bo.fromHex(e.publicKey).toRawBytes(!0)}var t;this.pubHash=(t=this.pubKey,no(Ie(t)))}derive(e){if(!/^[mM]'?/.test(e))throw new Error('Path must start with "m" or "M"');if(/^[mM]'?$/.test(e))return this;const t=e.replace(/^[mM]'?\//,"").split("/");let n=this;for(const e of t){const t=/^(\d+)('?)$/.exec(e);if(!t||3!==t.length)throw new Error(`Invalid child index: ${e}`);let r=+t[1];if(!Number.isSafeInteger(r)||r>=xo)throw new Error("Invalid index");"'"===t[2]&&(r+=xo),n=n.deriveChild(r)}return n}deriveChild(e){if(!this.pubKey||!this.chainCode)throw new Error("No publicKey or chainCode set");let t=Eo(e);if(e>=xo){const e=this.privateKey;if(!e)throw new Error("Could not derive hardened child key");t=_e(new Uint8Array([0]),e,t)}else t=_e(this.pubKey,t);const n=Lt(go,this.chainCode,t),r=wo(n.slice(0,32)),o=n.slice(32);if(!zt.utils.isValidPrivateKey(r))throw new Error("Tweak bigger than curve order");const i={versions:this.versions,chainCode:o,depth:this.depth+1,parentFingerprint:this.fingerprint,index:e};try{if(this.privateKey){const e=ut(this.privKey+r,zt.CURVE.n);if(!zt.utils.isValidPrivateKey(e))throw new Error("The tweak was out of range or the resulted private key is invalid");i.privateKey=e}else{const e=bo.fromHex(this.pubKey).add(bo.fromPrivateKey(r));if(e.equals(bo.ZERO))throw new Error("The tweak was equal to negative P, which made the result key invalid");i.publicKey=e.toRawBytes(!0)}return new ko(i)}catch(t){return this.deriveChild(e+1)}}sign(e){if(!this.privateKey)throw new Error("No privateKey set!");return he(e,32),zt.sign(e,this.privKey).toCompactRawBytes()}verify(e,t){if(he(e,32),he(t,64),!this.publicKey)throw new Error("No publicKey set!");let n;try{n=zt.Signature.fromCompact(t)}catch(e){return!1}return zt.verify(n,e,this.publicKey)}wipePrivateData(){return this.privKey=void 0,this.privKeyBytes&&(this.privKeyBytes.fill(0),this.privKeyBytes=void 0),this}toJSON(){return{xpriv:this.privateExtendedKey,xpub:this.publicExtendedKey}}serialize(e,t){if(!this.chainCode)throw new Error("No chainCode set");return he(t,33),_e(Eo(e),new Uint8Array([this.depth]),Eo(this.parentFingerprint),Eo(this.index),this.chainCode,t)}}var So=Object.defineProperty,Oo=(e,t)=>{for(var n in t)So(e,n,{get:t[n],enumerable:!0})};function Ao(){return be(en.utils.randomPrivateKey())}function Co(e){return be(en.getPublicKey(e))}Oo({},{insertEventIntoAscendingList:()=>Po,insertEventIntoDescendingList:()=>Io,normalizeURL:()=>Lo,utf8Decoder:()=>Ro,utf8Encoder:()=>To});var Ro=new TextDecoder("utf-8"),To=new TextEncoder;function Lo(e){let t=new URL(e);return t.pathname=t.pathname.replace(/\/+/g,"/"),t.pathname.endsWith("/")&&(t.pathname=t.pathname.slice(0,-1)),("80"===t.port&&"ws:"===t.protocol||"443"===t.port&&"wss:"===t.protocol)&&(t.port=""),t.searchParams.sort(),t.hash="",t.toString()}function Io(e,t){let n,r=0,o=e.length-1,i=r;if(o<0)i=0;else if(t.created_at=e[r].created_at)i=r;else for(;;){if(o<=r+1){i=o;break}if(n=Math.floor(r+(o-r)/2),e[n].created_at>t.created_at)r=n;else{if(!(e[n].created_ate[o].created_at)i=o+1;else if(t.created_at<=e[r].created_at)i=r;else for(;;){if(o<=r+1){i=o;break}if(n=Math.floor(r+(o-r)/2),e[n].created_att.created_at)){i=n;break}o=n}}return e[i]?.id!==t.id?[...e.slice(0,i),t,...e.slice(i)]:e}function jo(e,t){let n=e;return n.pubkey=Co(t),n.id=Uo(n),n.sig=$o(n,t),n}function Uo(e){return be(Ie(To.encode(function(e){if(!Bo(e))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content])}(e))))}function Bo(e){if(!(e instanceof Object))return!1;if("number"!=typeof e.kind)return!1;if("string"!=typeof e.content)return!1;if("number"!=typeof e.created_at)return!1;if("string"!=typeof e.pubkey)return!1;if(!e.pubkey.match(/^[a-f0-9]{64}$/))return!1;if(!Array.isArray(e.tags))return!1;for(let t=0;tt.id.startsWith(e))))return!1;if(e.kinds&&-1===e.kinds.indexOf(t.kind))return!1;if(e.authors&&-1===e.authors.indexOf(t.pubkey)&&!e.authors.some((e=>t.pubkey.startsWith(e))))return!1;for(let n in e)if("#"===n[0]){let r=e[`#${n.slice(1)}`];if(r&&!t.tags.find((([e,t])=>e===n.slice(1)&&-1!==r.indexOf(t))))return!1}return!(e.since&&t.created_at=e.until)}function Fo(e,t){let n=t.length+3,r=e.indexOf(`"${t}":`)+n,o=e.slice(r).indexOf('"')+r+1;return e.slice(o,o+64)}function Do(e,t){let n=t.length,r=e.indexOf(`"${t}":`)+n+3,o=e.slice(r),i=Math.min(o.indexOf(","),o.indexOf("}"));return parseInt(o.slice(0,i),10)}function Ho(e){let t=e.slice(0,22).indexOf('"EVENT"');if(-1===t)return null;let n=e.slice(t+7+1).indexOf('"');if(-1===n)return null;let r=t+7+1+n,o=e.slice(r+1,80).indexOf('"');if(-1===o)return null;let i=r+1+o;return e.slice(r+1,i)}function qo(e,t){return t===Fo(e,"id")}function Wo(e,t){return t===Fo(e,"pubkey")}function Ko(e,t){return t===Do(e,"kind")}Oo({},{getHex64:()=>Fo,getInt:()=>Do,getSubscriptionId:()=>Ho,matchEventId:()=>qo,matchEventKind:()=>Ko,matchEventPubkey:()=>Wo});function Go(e,t={}){let{listTimeout:n=3e3,getTimeout:r=3e3,countTimeout:o=3e3}=t;var i,s,a={},c={connect:[],disconnect:[],error:[],notice:[],auth:[]},u={},l={};async function h(){return s||(s=new Promise(((t,n)=>{try{i=new WebSocket(e)}catch(e){n(e)}i.onopen=()=>{c.connect.forEach((e=>e())),t()},i.onerror=()=>{s=void 0,c.error.forEach((e=>e())),n()},i.onclose=async()=>{s=void 0,c.disconnect.forEach((e=>e()))};let r,o=[];function h(){if(0===o.length)return clearInterval(r),void(r=null);var t=o.shift();if(!t)return;let n=Ho(t);if(n){let r=a[n];if(r&&r.alreadyHaveEvent&&r.alreadyHaveEvent(Fo(t,"id"),e))return}try{let e=JSON.parse(t);switch(e[0]){case"EVENT":{let t=e[1],n=e[2];return void(Bo(n)&&a[t]&&(a[t].skipVerification||No(n))&&function(e,t){for(let n=0;ne(n)))))}case"COUNT":let t=e[1],n=e[2];return void(a[t]&&(u[t]?.count||[]).forEach((e=>e(n))));case"EOSE":{let t=e[1];return void(t in u&&(u[t].eose.forEach((e=>e())),u[t].eose=[]))}case"OK":{let t=e[1],n=e[2],r=e[3]||"";return void(t in l&&(n?l[t].ok.forEach((e=>e())):l[t].failed.forEach((e=>e(r))),l[t].ok=[],l[t].failed=[]))}case"NOTICE":let r=e[1];return void c.notice.forEach((e=>e(r)));case"AUTH":{let t=e[1];return void c.auth?.forEach((e=>e(t)))}}}catch(e){return}}i.onmessage=e=>{o.push(e.data),r||(r=setInterval(h,0))}})),s)}function f(){return 1===i?.readyState}async function d(e){let t=JSON.stringify(e);if(f()||(await new Promise((e=>setTimeout(e,1e3))),f()))try{i.send(t)}catch(e){console.log(e)}}const p=(e,{verb:t="REQ",skipVerification:n=!1,alreadyHaveEvent:r=null,id:o=Math.random().toString().slice(2)}={})=>{let i=o;return a[i]={id:i,filters:e,skipVerification:n,alreadyHaveEvent:r},d([t,i,...e]),{sub:(t,o={})=>p(t||e,{skipVerification:o.skipVerification||n,alreadyHaveEvent:o.alreadyHaveEvent||r,id:i}),unsub:()=>{delete a[i],delete u[i],d(["CLOSE",i])},on:(e,t)=>{u[i]=u[i]||{event:[],count:[],eose:[]},u[i][e].push(t)},off:(e,t)=>{let n=u[i],r=n[e].indexOf(t);r>=0&&n[e].splice(r,1)}}};function y(e,t){if(!e.id)throw new Error(`event ${e} has no id`);let n=e.id;return d([t,e]),{on:(e,t)=>{l[n]=l[n]||{ok:[],failed:[]},l[n][e].push(t)},off:(e,t)=>{let r=l[n];if(!r)return;let o=r[e].indexOf(t);o>=0&&r[e].splice(o,1)}}}return{url:e,sub:p,on:(e,t)=>{c[e].push(t),"connect"===e&&1===i?.readyState&&t()},off:(e,t)=>{let n=c[e].indexOf(t);-1!==n&&c[e].splice(n,1)},list:(e,t)=>new Promise((r=>{let o=p(e,t),i=[],s=setTimeout((()=>{o.unsub(),r(i)}),n);o.on("eose",(()=>{o.unsub(),clearTimeout(s),r(i)})),o.on("event",(e=>{i.push(e)}))})),get:(e,t)=>new Promise((n=>{let o=p([e],t),i=setTimeout((()=>{o.unsub(),n(null)}),r);o.on("event",(e=>{o.unsub(),clearTimeout(i),n(e)}))})),count:e=>new Promise((t=>{let n=p(e,{...p,verb:"COUNT"}),r=setTimeout((()=>{n.unsub(),t(null)}),o);n.on("count",(e=>{n.unsub(),clearTimeout(r),t(e)}))})),publish:e=>y(e,"EVENT"),auth:e=>y(e,"AUTH"),connect:async function(){f()||await h()},close(){c={connect:[],disconnect:[],error:[],notice:[],auth:[]},u={},l={},i.readyState===WebSocket.OPEN&&i?.close()},get status(){return i?.readyState??3}}}var Zo={};Oo(Zo,{BECH32_REGEX:()=>Yo,decode:()=>Xo,naddrEncode:()=>ii,neventEncode:()=>oi,noteEncode:()=>ti,nprofileEncode:()=>ri,npubEncode:()=>ei,nrelayEncode:()=>si,nsecEncode:()=>Qo});var Vo=5e3,Yo=/[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;function Xo(e){let{prefix:t,words:n}=Rn.decode(e,Vo),r=new Uint8Array(Rn.fromWords(n));switch(t){case"nprofile":{let e=Jo(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for nprofile");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:be(e[0][0]),relays:e[1]?e[1].map((e=>Ro.decode(e))):[]}}}case"nevent":{let e=Jo(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for nevent");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");if(e[2]&&32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");return{type:"nevent",data:{id:be(e[0][0]),relays:e[1]?e[1].map((e=>Ro.decode(e))):[],author:e[2]?.[0]?be(e[2][0]):void 0}}}case"naddr":{let e=Jo(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for naddr");if(!e[2]?.[0])throw new Error("missing TLV 2 for naddr");if(32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(!e[3]?.[0])throw new Error("missing TLV 3 for naddr");if(4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:Ro.decode(e[0][0]),pubkey:be(e[2][0]),kind:parseInt(be(e[3][0]),16),relays:e[1]?e[1].map((e=>Ro.decode(e))):[]}}}case"nrelay":{let e=Jo(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for nrelay");return{type:"nrelay",data:Ro.decode(e[0][0])}}case"nsec":case"npub":case"note":return{type:t,data:be(r)};default:throw new Error(`unknown prefix ${t}`)}}function Jo(e){let t={},n=e;for(;n.length>0;){let e=n[0],r=n[1],o=n.slice(2,2+r);n=n.slice(2+r),o.lengthTo.encode(e)))}),n=Rn.toWords(t);return Rn.encode("nprofile",n,Vo)}function oi(e){let t=ai({0:[me(e.id)],1:(e.relays||[]).map((e=>To.encode(e))),2:e.author?[me(e.author)]:[]}),n=Rn.toWords(t);return Rn.encode("nevent",n,Vo)}function ii(e){let t=new ArrayBuffer(4);new DataView(t).setUint32(0,e.kind,!1);let n=ai({0:[To.encode(e.identifier)],1:(e.relays||[]).map((e=>To.encode(e))),2:[me(e.pubkey)],3:[new Uint8Array(t)]}),r=Rn.toWords(n);return Rn.encode("naddr",r,Vo)}function si(e){let t=ai({0:[To.encode(e)]}),n=Rn.toWords(t);return Rn.encode("nrelay",n,Vo)}function ai(e){let t=[];return Object.entries(e).forEach((([e,n])=>{n.forEach((n=>{let r=new Uint8Array(n.length+2);r.set([parseInt(e)],0),r.set([n.length],1),r.set(n,2),t.push(r)}))})),_e(...t)}var ci={};async function ui(e,t,n){const r=hi(zt.getSharedSecret(e,"02"+t));let o=Uint8Array.from(ke(16)),i=To.encode(n),s=await crypto.subtle.importKey("raw",r,{name:"AES-CBC"},!1,["encrypt"]),a=await crypto.subtle.encrypt({name:"AES-CBC",iv:o},s,i);return`${mn.encode(new Uint8Array(a))}?iv=${mn.encode(new Uint8Array(o.buffer))}`}async function li(e,t,n){let[r,o]=n.split("?iv="),i=hi(zt.getSharedSecret(e,"02"+t)),s=await crypto.subtle.importKey("raw",i,{name:"AES-CBC"},!1,["decrypt"]),a=mn.decode(r),c=mn.decode(o),u=await crypto.subtle.decrypt({name:"AES-CBC",iv:c},s,a);return Ro.decode(u)}function hi(e){return e.slice(1,33)}Oo(ci,{decrypt:()=>li,encrypt:()=>ui}),"undefined"!=typeof crypto&&!crypto.subtle&&crypto.webcrypto&&(crypto.subtle=crypto.webcrypto.subtle);var fi={};Oo(fi,{NIP05_REGEX:()=>pi,queryProfile:()=>bi,searchDomain:()=>gi,useFetchImplementation:()=>yi});var di,pi=/^(?:([\w.+-]+)@)?([\w.-]+)$/;try{di=fetch}catch{}function yi(e){di=e}async function gi(e,t=""){try{return(await(await di(`https://${e}/.well-known/nostr.json?name=${t}`)).json()).names}catch(e){return{}}}async function bi(e){const t=e.match(pi);if(!t)return null;const[n,r="_",o]=t;try{const e=await di(`https://${o}/.well-known/nostr.json?name=${r}`),{names:t,relays:n}=function(e){const t={names:{}};for(const[n,r]of Object.entries(e.names))"string"==typeof n&&"string"==typeof r&&(t.names[n]=r);if(e.relays){t.relays={};for(const[n,r]of Object.entries(e.relays))"string"==typeof n&&Array.isArray(r)&&(t.relays[n]=r.filter((e=>"string"==typeof e)))}return t}(await e.json()),i=t[r];return i?{pubkey:i,relays:n?.[i]}:null}catch(e){return null}}function mi(e,t){let n=ko.fromMasterSeed(Sr(e,t)).derive("m/44'/1237'/0'/0/0").privateKey;if(!n)throw new Error("could not derive private key");return be(n)}function wi(){return Ur(jn)}function vi(e){return zr(e,jn)}Oo({},{generateSeedWords:()=>wi,privateKeyFromSeedWords:()=>mi,validateWords:()=>vi});function _i(e){const t={reply:void 0,root:void 0,mentions:[],profiles:[]},n=[];for(const r of e.tags)"e"===r[0]&&r[1]&&n.push(r),"p"===r[0]&&r[1]&&t.profiles.push({pubkey:r[1],relays:r[2]?[r[2]]:[]});for(let e=0;e_i});function xi(e){return function(e){let t,n,r;for(n=0,t=0;n>=1;)t++;return 7-t}Oo({},{getPow:()=>xi});function ki(e,t,n,r){return jo({kind:6,tags:[...e.tags??[],["e",t.id,n],["p",t.pubkey]],content:""===e.content?"":JSON.stringify(t),created_at:e.created_at},r)}function Si(e){if(6!==e.kind)return;let t,n;for(let r=e.tags.length-1;r>=0&&(void 0===t||void 0===n);r--){const o=e.tags[r];o.length>=2&&("e"===o[0]&&void 0===t?t=o:"p"===o[0]&&void 0===n&&(n=o))}return void 0!==t?{id:t[1],relays:[t[2],n?.[2]].filter((e=>"string"==typeof e)),author:n?.[1]}:void 0}function Oi(e,{skipVerification:t}={}){const n=Si(e);if(void 0===n||""===e.content)return;let r;try{r=JSON.parse(e.content)}catch(e){return}return r.id===n.id&&(t||No(r))?r:void 0}Oo({},{finishRepostEvent:()=>ki,getRepostedEvent:()=>Oi,getRepostedEventPointer:()=>Si});Oo({},{NOSTR_URI_REGEX:()=>Ai,parse:()=>Ri,test:()=>Ci});var Ai=new RegExp(`nostr:(${Yo.source})`);function Ci(e){return"string"==typeof e&&new RegExp(`^${Ai.source}$`).test(e)}function Ri(e){const t=e.match(new RegExp(`^${Ai.source}$`));if(!t)throw new Error(`Invalid Nostr URI: ${e}`);return{uri:t[0],value:t[1],decoded:Xo(t[1])}}function Ti(e,t,n){const r=t.tags.filter((e=>e.length>=2&&("e"===e[0]||"p"===e[0])));return jo({...e,kind:7,tags:[...e.tags??[],...r,["e",t.id],["p",t.pubkey]],content:e.content??"+"},n)}function Li(e){if(7!==e.kind)return;let t,n;for(let r=e.tags.length-1;r>=0&&(void 0===t||void 0===n);r--){const o=e.tags[r];o.length>=2&&("e"===o[0]&&void 0===t?t=o:"p"===o[0]&&void 0===n&&(n=o))}return void 0!==t&&void 0!==n?{id:t[1],relays:[t[2],n[2]].filter((e=>void 0!==e)),author:n[1]}:void 0}Oo({},{finishReactionEvent:()=>Ti,getReactedEventPointer:()=>Li});function Ii(e,t){let n=[];(t.kind||-1)>=0&&n.push(`kind=${t.kind}`),t.until&&n.push(`created_at<${t.until}`),t.since&&n.push(`created_at>${t.since}`);let r=n.join("&");if(""===r)throw new Error("refusing to create a delegation without any conditions");let o=Ie(To.encode(`nostr:delegation:${t.pubkey}:${r}`)),i=be(en.sign(o,e));return{from:Co(e),to:t.pubkey,cond:r,sig:i}}function Pi(e){let t=e.tags.find((e=>"delegation"===e[0]&&e.length>=4));if(!t)return null;let n=t[1],r=t[2],o=t[3],i=r.split("&");for(let t=0;t"===r&&e.created_at>parseInt(o)))return null}let s=Ie(To.encode(`nostr:delegation:${e.pubkey}:${r}`));return en.verify(o,s,n)?n:null}Oo({},{createDelegation:()=>Ii,getDelegator:()=>Pi});Oo({},{matchAll:()=>Ui,regex:()=>ji,replaceAll:()=>Bi});var ji=()=>new RegExp(`\\b${Ai.source}\\b`,"g");function*Ui(e){const t=e.matchAll(ji());for(const e of t){const[t,n]=e;yield{uri:t,value:n,decoded:Xo(n),start:e.index,end:e.index+t.length}}}function Bi(e,t){return e.replaceAll(ji(),((e,n)=>t({uri:e,value:n,decoded:Xo(n)})))}var Ni;Oo({},{useFetchImplementation:()=>Mi,validateGithub:()=>$i});try{Ni=fetch}catch{}function Mi(e){Ni=e}async function $i(e,t,n){try{return await(await Ni(`https://gist.github.com/${t}/${n}/raw`)).text()===`Verifying that I control the following Nostr public key: ${e}`}catch(e){return!1}}Oo({},{authenticate:()=>Fi});var zi,Fi=async({challenge:e,relay:t,sign:n})=>{const r={kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t.url],["challenge",e]],content:""},o=t.auth(await n(r));return new Promise(((e,t)=>{o.on("ok",(function t(){o.off("ok",t),e()})),o.on("failed",(function e(n){o.off("failed",e),t(n)}))}))},Di={};Oo(Di,{getZapEndpoint:()=>qi,makeZapReceipt:()=>Gi,makeZapRequest:()=>Wi,useFetchImplementation:()=>Hi,validateZapRequest:()=>Ki});try{zi=fetch}catch{}function Hi(e){zi=e}async function qi(e){try{let t="",{lud06:n,lud16:r}=JSON.parse(e.content);if(n){let{words:e}=Rn.decode(n,1e3),r=Rn.fromWords(e);t=Ro.decode(r)}else{if(!r)return null;{let[e,n]=r.split("@");t=`https://${n}/.well-known/lnurlp/${e}`}}let o=await zi(t),i=await o.json();if(i.allowsNostr&&i.nostrPubkey)return i.callback}catch(e){}return null}function Wi({profile:e,event:t,amount:n,relays:r,comment:o=""}){if(!n)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",n.toString()],["relays",...r]]};return t&&i.tags.push(["e",t]),i}function Ki(e){let t;try{t=JSON.parse(e)}catch(e){return"Invalid zap request JSON."}if(!Bo(t))return"Zap request is not a valid Nostr event.";if(!No(t))return"Invalid signature on zap request.";let n=t.tags.find((([e,t])=>"p"===e&&t));if(!n)return"Zap request doesn't have a 'p' tag.";if(!n[1].match(/^[a-f0-9]{64}$/))return"Zap request 'p' tag is not valid hex.";let r=t.tags.find((([e,t])=>"e"===e&&t));if(r&&!r[1].match(/^[a-f0-9]{64}$/))return"Zap request 'e' tag is not valid hex.";let o=t.tags.find((([e,t])=>"relays"===e&&t));return o?null:"Zap request doesn't have a 'relays' tag."}function Gi({zapRequest:e,preimage:t,bolt11:n,paidAt:r}){let o=JSON.parse(e).tags.filter((([e])=>"e"===e||"p"===e||"a"===e)),i={kind:9735,created_at:Math.round(r.getTime()/1e3),content:"",tags:[...o,["bolt11",n],["description",e]]};return t&&i.tags.push(["preimage",t]),i}var Zi="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Vi=[],Yi=[],Xi="undefined"!=typeof Uint8Array?Uint8Array:Array,Ji=!1;function Qi(){Ji=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,n=e.length;t>18&63]+Vi[o>>12&63]+Vi[o>>6&63]+Vi[63&o]);return i.join("")}function ts(e){var t;Ji||Qi();for(var n=e.length,r=n%3,o="",i=[],s=16383,a=0,c=n-r;ac?c:a+s));return 1===r?(t=e[n-1],o+=Vi[t>>2],o+=Vi[t<<4&63],o+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],o+=Vi[t>>10],o+=Vi[t>>4&63],o+=Vi[t<<2&63],o+="="),i.push(o),i.join("")}function ns(e,t,n,r,o){var i,s,a=8*o-r-1,c=(1<>1,l=-7,h=n?o-1:0,f=n?-1:1,d=e[t+h];for(h+=f,i=d&(1<<-l)-1,d>>=-l,l+=a;l>0;i=256*i+e[t+h],h+=f,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=r;l>0;s=256*s+e[t+h],h+=f,l-=8);if(0===i)i=1-u;else{if(i===c)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,r),i-=u}return(d?-1:1)*s*Math.pow(2,i-r)}function rs(e,t,n,r,o,i){var s,a,c,u=8*i-o-1,l=(1<>1,f=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:i-1,p=r?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+h>=1?f/c:f*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=l?(a=0,s=l):s+h>=1?(a=(t*c-1)*Math.pow(2,o),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,o),s=0));o>=8;e[n+d]=255&a,d+=p,a/=256,o-=8);for(s=s<0;e[n+d]=255&s,d+=p,s/=256,u-=8);e[n+d-p]|=128*y}var os={}.toString,is=Array.isArray||function(e){return"[object Array]"==os.call(e)};us.TYPED_ARRAY_SUPPORT=void 0===Zi.TYPED_ARRAY_SUPPORT||Zi.TYPED_ARRAY_SUPPORT;var ss=as();function as(){return us.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function cs(e,t){if(as()=as())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+as().toString(16)+" bytes");return 0|e}function ys(e){return!(null==e||!e._isBuffer)}function gs(e,t){if(ys(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return Hs(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return qs(e).length;default:if(r)return Hs(e).length;t=(""+t).toLowerCase(),r=!0}}function bs(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Is(this,t,n);case"utf8":case"utf-8":return Cs(this,t,n);case"ascii":return Ts(this,t,n);case"latin1":case"binary":return Ls(this,t,n);case"base64":return As(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ps(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function ms(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function ws(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=us.from(t,r)),ys(t))return 0===t.length?-1:vs(e,t,n,r,o);if("number"==typeof t)return t&=255,us.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):vs(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function vs(e,t,n,r,o){var i,s=1,a=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,n/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var l=-1;for(i=n;ia&&(n=a-c),i=n;i>=0;i--){for(var h=!0,f=0;fo&&(r=o):r=o;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var s=0;s>8,o=n%256,i.push(o),i.push(r);return i}(t,e.length-n),e,n,r)}function As(e,t,n){return 0===t&&n===e.length?ts(e):ts(e.slice(t,n))}function Cs(e,t,n){n=Math.min(e.length,n);for(var r=[],o=t;o239?4:u>223?3:u>191?2:1;if(o+h<=n)switch(h){case 1:u<128&&(l=u);break;case 2:128==(192&(i=e[o+1]))&&(c=(31&u)<<6|63&i)>127&&(l=c);break;case 3:i=e[o+1],s=e[o+2],128==(192&i)&&128==(192&s)&&(c=(15&u)<<12|(63&i)<<6|63&s)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:i=e[o+1],s=e[o+2],a=e[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(l=c)}null===l?(l=65533,h=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),o+=h}return function(e){var t=e.length;if(t<=Rs)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},us.prototype.compare=function(e,t,n,r,o){if(!ys(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),a=Math.min(i,s),c=this.slice(r,o),u=e.slice(t,n),l=0;lo)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return _s(this,e,t,n);case"utf8":case"utf-8":return xs(this,e,t,n);case"ascii":return Es(this,e,t,n);case"latin1":case"binary":return ks(this,e,t,n);case"base64":return Ss(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Os(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},us.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Rs=4096;function Ts(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;or)&&(n=r);for(var o="",i=t;in)throw new RangeError("Trying to access beyond buffer length")}function Us(e,t,n,r,o,i){if(!ys(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||te.length)throw new RangeError("Index out of range")}function Bs(e,t,n,r){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-n,2);o>>8*(r?o:1-o)}function Ns(e,t,n,r){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-n,4);o>>8*(r?o:3-o)&255}function Ms(e,t,n,r,o,i){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function $s(e,t,n,r,o){return o||Ms(e,0,n,4),rs(e,t,n,r,23,4),n+4}function zs(e,t,n,r,o){return o||Ms(e,0,n,8),rs(e,t,n,r,52,8),n+8}us.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t0&&(o*=256);)r+=this[e+--t]*o;return r},us.prototype.readUInt8=function(e,t){return t||js(e,1,this.length),this[e]},us.prototype.readUInt16LE=function(e,t){return t||js(e,2,this.length),this[e]|this[e+1]<<8},us.prototype.readUInt16BE=function(e,t){return t||js(e,2,this.length),this[e]<<8|this[e+1]},us.prototype.readUInt32LE=function(e,t){return t||js(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},us.prototype.readUInt32BE=function(e,t){return t||js(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},us.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||js(e,t,this.length);for(var r=this[e],o=1,i=0;++i=(o*=128)&&(r-=Math.pow(2,8*t)),r},us.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||js(e,t,this.length);for(var r=t,o=1,i=this[e+--r];r>0&&(o*=256);)i+=this[e+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},us.prototype.readInt8=function(e,t){return t||js(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},us.prototype.readInt16LE=function(e,t){t||js(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},us.prototype.readInt16BE=function(e,t){t||js(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},us.prototype.readInt32LE=function(e,t){return t||js(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},us.prototype.readInt32BE=function(e,t){return t||js(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},us.prototype.readFloatLE=function(e,t){return t||js(e,4,this.length),ns(this,e,!0,23,4)},us.prototype.readFloatBE=function(e,t){return t||js(e,4,this.length),ns(this,e,!1,23,4)},us.prototype.readDoubleLE=function(e,t){return t||js(e,8,this.length),ns(this,e,!0,52,8)},us.prototype.readDoubleBE=function(e,t){return t||js(e,8,this.length),ns(this,e,!1,52,8)},us.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||Us(this,e,t,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[t]=255&e;++i=0&&(i*=256);)this[t+o]=e/i&255;return t+n},us.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||Us(this,e,t,1,255,0),us.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},us.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||Us(this,e,t,2,65535,0),us.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Bs(this,e,t,!0),t+2},us.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||Us(this,e,t,2,65535,0),us.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Bs(this,e,t,!1),t+2},us.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||Us(this,e,t,4,4294967295,0),us.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Ns(this,e,t,!0),t+4},us.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||Us(this,e,t,4,4294967295,0),us.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ns(this,e,t,!1),t+4},us.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);Us(this,e,t,n,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i>0)-a&255;return t+n},us.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);Us(this,e,t,n,o-1,-o)}var i=n-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},us.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||Us(this,e,t,1,127,-128),us.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},us.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||Us(this,e,t,2,32767,-32768),us.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Bs(this,e,t,!0),t+2},us.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||Us(this,e,t,2,32767,-32768),us.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Bs(this,e,t,!1),t+2},us.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||Us(this,e,t,4,2147483647,-2147483648),us.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Ns(this,e,t,!0),t+4},us.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||Us(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),us.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ns(this,e,t,!1),t+4},us.prototype.writeFloatLE=function(e,t,n){return $s(this,e,t,!0,n)},us.prototype.writeFloatBE=function(e,t,n){return $s(this,e,t,!1,n)},us.prototype.writeDoubleLE=function(e,t,n){return zs(this,e,t,!0,n)},us.prototype.writeDoubleBE=function(e,t,n){return zs(this,e,t,!1,n)},us.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t=0;--o)e[o+t]=this[o+n];else if(i<1e3||!us.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function qs(e){return function(e){var t,n,r,o,i,s;Ji||Qi();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");i="="===e[a-2]?2:"="===e[a-1]?1:0,s=new Xi(3*a/4-i),r=i>0?a-4:a;var c=0;for(t=0,n=0;t>16&255,s[c++]=o>>8&255,s[c++]=255&o;return 2===i?(o=Yi[e.charCodeAt(t)]<<2|Yi[e.charCodeAt(t+1)]>>4,s[c++]=255&o):1===i&&(o=Yi[e.charCodeAt(t)]<<10|Yi[e.charCodeAt(t+1)]<<4|Yi[e.charCodeAt(t+2)]>>2,s[c++]=o>>8&255,s[c++]=255&o),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Fs,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ws(e,t,n,r){for(var o=0;o=t.length||o>=e.length);++o)t[o+n]=e[o];return o}function Ks(e){return null!=e&&(!!e._isBuffer||Gs(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&Gs(e.slice(0,0))}(e))}function Gs(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var Zs=Object.freeze({__proto__:null,Buffer:us,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),us.alloc(+e)},isBuffer:Ks,kMaxLength:ss});function Vs(){throw new Error("setTimeout has not been defined")}function Ys(){throw new Error("clearTimeout has not been defined")}var Xs=Vs,Js=Ys;function Qs(e){if(Xs===setTimeout)return setTimeout(e,0);if((Xs===Vs||!Xs)&&setTimeout)return Xs=setTimeout,setTimeout(e,0);try{return Xs(e,0)}catch(t){try{return Xs.call(null,e,0)}catch(t){return Xs.call(this,e,0)}}}"function"==typeof Zi.setTimeout&&(Xs=setTimeout),"function"==typeof Zi.clearTimeout&&(Js=clearTimeout);var ea,ta=[],na=!1,ra=-1;function oa(){na&&ea&&(na=!1,ea.length?ta=ea.concat(ta):ra=-1,ta.length&&ia())}function ia(){if(!na){var e=Qs(oa);na=!0;for(var t=ta.length;t;){for(ea=ta,ta=[];++ra1)for(var n=1;n0&&s.length>o){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,a=c,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=i[t]=n,++e._eventsCount;return e}function Ra(e,t,n){var r=!1;function o(){e.removeListener(t,o),r||(r=!0,n.apply(e,arguments))}return o.listener=n,o}function Ta(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function La(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}va.prototype=Object.create(null),_a.EventEmitter=_a,_a.usingDomains=!1,_a.prototype.domain=void 0,_a.prototype._events=void 0,_a.prototype._maxListeners=void 0,_a.defaultMaxListeners=10,_a.init=function(){this.domain=null,_a.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new va,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_a.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_a.prototype.getMaxListeners=function(){return xa(this)},_a.prototype.emit=function(e){var t,n,r,o,i,s,a,c="error"===e;if(s=this._events)c=c&&null==s.error;else if(!c)return!1;if(a=this.domain,c){if(t=arguments[1],!a){if(t instanceof Error)throw t;var u=new Error('Uncaught, unspecified "error" event. ('+t+")");throw u.context=t,u}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(n=s[e]))return!1;var l="function"==typeof n;switch(r=arguments.length){case 1:Ea(n,l,this);break;case 2:ka(n,l,this,arguments[1]);break;case 3:Sa(n,l,this,arguments[1],arguments[2]);break;case 4:Oa(n,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(o=new Array(r-1),i=1;i0;)if(n[i]===t||n[i].listener&&n[i].listener===t){s=n[i].listener,o=i;break}if(o<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new va,this;delete r[e]}else!function(e,t){for(var n=t,r=n+1,o=e.length;r0?Reflect.ownKeys(this._events):[]};var Ia,Pa,ja=In(Object.freeze({__proto__:null,EventEmitter:_a,default:_a})),Ua=qa(Zi.fetch)&&qa(Zi.ReadableStream);function Ba(e){Pa||(Pa=new Zi.XMLHttpRequest).open("GET",Zi.location.host?"/":"https://example.com");try{return Pa.responseType=e,Pa.responseType===e}catch(e){return!1}}var Na=void 0!==Zi.ArrayBuffer,Ma=Na&&qa(Zi.ArrayBuffer.prototype.slice),$a=Na&&Ba("arraybuffer"),za=!Ua&&Ma&&Ba("ms-stream"),Fa=!Ua&&Na&&Ba("moz-chunked-arraybuffer"),Da=qa(Pa.overrideMimeType),Ha=qa(Zi.VBArray);function qa(e){return"function"==typeof e}Pa=null;var Wa="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e},Ka=/%[sdj%]/g;function Ga(e){if(!ic(e)){for(var t=[],n=0;n=o)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}})),s=r[n];n=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),rc(t)?n.showHidden=t:t&&dc(n,t),sc(n.showHidden)&&(n.showHidden=!1),sc(n.depth)&&(n.depth=2),sc(n.colors)&&(n.colors=!1),sc(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=Ja),ec(n,e,n.depth)}function Ja(e,t){var n=Xa.styles[t];return n?"["+Xa.colors[n][0]+"m"+e+"["+Xa.colors[n][1]+"m":e}function Qa(e,t){return e}function ec(e,t,n){if(e.customInspect&&t&&hc(t.inspect)&&t.inspect!==Xa&&(!t.constructor||t.constructor.prototype!==t)){var r=t.inspect(n,e);return ic(r)||(r=ec(e,r,n)),r}var o=function(e,t){if(sc(t))return e.stylize("undefined","undefined");if(ic(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}if(r=t,"number"==typeof r)return e.stylize(""+t,"number");var r;if(rc(t))return e.stylize(""+t,"boolean");if(oc(t))return e.stylize("null","null")}(e,t);if(o)return o;var i=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,n){t[e]=!0})),t}(i);if(e.showHidden&&(i=Object.getOwnPropertyNames(t)),lc(t)&&(i.indexOf("message")>=0||i.indexOf("description")>=0))return tc(t);if(0===i.length){if(hc(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(ac(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(uc(t))return e.stylize(Date.prototype.toString.call(t),"date");if(lc(t))return tc(t)}var c,u,l="",h=!1,f=["{","}"];(c=t,Array.isArray(c)&&(h=!0,f=["[","]"]),hc(t))&&(l=" [Function"+(t.name?": "+t.name:"")+"]");return ac(t)&&(l=" "+RegExp.prototype.toString.call(t)),uc(t)&&(l=" "+Date.prototype.toUTCString.call(t)),lc(t)&&(l=" "+tc(t)),0!==i.length||h&&0!=t.length?n<0?ac(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),u=h?function(e,t,n,r,o){for(var i=[],s=0,a=t.length;s60)return n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1];return n[0]+t+" "+e.join(", ")+" "+n[1]}(u,l,f)):f[0]+l+f[1]}function tc(e){return"["+Error.prototype.toString.call(e)+"]"}function nc(e,t,n,r,o,i){var s,a,c;if((c=Object.getOwnPropertyDescriptor(t,o)||{value:t[o]}).get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),pc(r,o)||(s="["+o+"]"),a||(e.seen.indexOf(c.value)<0?(a=oc(n)?ec(e,c.value,null):ec(e,c.value,n-1)).indexOf("\n")>-1&&(a=i?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),sc(s)){if(i&&o.match(/^\d+$/))return a;(s=JSON.stringify(""+o)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function rc(e){return"boolean"==typeof e}function oc(e){return null===e}function ic(e){return"string"==typeof e}function sc(e){return void 0===e}function ac(e){return cc(e)&&"[object RegExp]"===fc(e)}function cc(e){return"object"==typeof e&&null!==e}function uc(e){return cc(e)&&"[object Date]"===fc(e)}function lc(e){return cc(e)&&("[object Error]"===fc(e)||e instanceof Error)}function hc(e){return"function"==typeof e}function fc(e){return Object.prototype.toString.call(e)}function dc(e,t){if(!t||!cc(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}function pc(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function yc(){this.head=null,this.tail=null,this.length=0}Xa.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},Xa.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},yc.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},yc.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},yc.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},yc.prototype.clear=function(){this.head=this.tail=null,this.length=0},yc.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n},yc.prototype.concat=function(e){if(0===this.length)return us.alloc(0);if(1===this.length)return this.head.data;for(var t=us.allocUnsafe(e>>>0),n=this.head,r=0;n;)n.data.copy(t,r),r+=n.data.length,n=n.next;return t};var gc=us.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function bc(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!gc(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=wc;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=vc;break;default:return void(this.write=mc)}this.charBuffer=new us(6),this.charReceived=0,this.charLength=0}function mc(e){return e.toString(this.encoding)}function wc(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function vc(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}bc.prototype.write=function(e){for(var t="";this.charLength;){var n=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,n),this.charReceived+=n,this.charReceived=55296&&o<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var r=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,r),r-=this.charReceived);var o;r=(t+=e.toString(this.encoding,0,r)).length-1;if((o=t.charCodeAt(r))>=55296&&o<=56319){var i=this.surrogateSize;return this.charLength+=i,this.charReceived+=i,this.charBuffer.copy(this.charBuffer,i,0,i),e.copy(this.charBuffer,0,0,i),t.substring(0,r)}return t},bc.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var n=e[e.length-t];if(1==t&&n>>5==6){this.charLength=2;break}if(t<=2&&n>>4==14){this.charLength=3;break}if(t<=3&&n>>3==30){this.charLength=4;break}}this.charReceived=t},bc.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var n=this.charReceived,r=this.charBuffer,o=this.encoding;t+=r.slice(0,n).toString(o)}return t},Ec.ReadableState=xc;var _c=function(e){if(sc(Va)&&(Va=wa.env.NODE_DEBUG||""),e=e.toUpperCase(),!Ya[e])if(new RegExp("\\b"+e+"\\b","i").test(Va)){Ya[e]=function(){var t=Ga.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else Ya[e]=function(){};return Ya[e]}("stream");function xc(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof Xc&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var n=e.highWaterMark,r=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:r,this.highWaterMark=~~this.highWaterMark,this.buffer=new yc,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new bc(e.encoding),this.encoding=e.encoding)}function Ec(e){if(!(this instanceof Ec))return new Ec(e);this._readableState=new xc(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_a.call(this)}function kc(e,t,n,r,o){var i=function(e,t){var n=null;us.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(n=new TypeError("Invalid non-string/buffer chunk"));return n}(t,n);if(i)e.emit("error",i);else if(null===n)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,Ac(e)}(e,t);else if(t.objectMode||n&&n.length>0)if(t.ended&&!o){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&o){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var c;!t.decoder||o||r||(n=t.decoder.write(n),c=!t.objectMode&&0===n.length),o||(t.reading=!1),c||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,o?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&Ac(e))),function(e,t){t.readingMore||(t.readingMore=!0,sa(Rc,e,t))}(e,t)}else o||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=Sc?e=Sc:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Ac(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(_c("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?sa(Cc,e):Cc(e))}function Cc(e){_c("emit readable"),e.emit("readable"),Ic(e)}function Rc(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):n=function(e,t,n){var r;ei.length?i.length:e;if(s===i.length?o+=i:o+=i.slice(0,e),0===(e-=s)){s===i.length?(++r,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=i.slice(s));break}++r}return t.length-=r,o}(e,t):function(e,t){var n=us.allocUnsafe(e),r=t.head,o=1;r.data.copy(n),e-=r.data.length;for(;r=r.next;){var i=r.data,s=e>i.length?i.length:e;if(i.copy(n,n.length-e,0,s),0===(e-=s)){s===i.length?(++o,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=i.slice(s));break}++o}return t.length-=o,n}(e,t);return r}(e,t.buffer,t.decoder),n);var n}function jc(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,sa(Uc,t,e))}function Uc(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Bc(e,t){for(var n=0,r=e.length;n=t.highWaterMark||t.ended))return _c("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?jc(this):Ac(this),null;if(0===(e=Oc(e,t))&&t.ended)return 0===t.length&&jc(this),null;var r,o=t.needReadable;return _c("need readable",o),(0===t.length||t.length-e0?Pc(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&jc(this)),null!==r&&this.emit("data",r),r},Ec.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Ec.prototype.pipe=function(e,t){var n=this,r=this._readableState;switch(r.pipesCount){case 0:r.pipes=e;break;case 1:r.pipes=[r.pipes,e];break;default:r.pipes.push(e)}r.pipesCount+=1,_c("pipe count=%d opts=%j",r.pipesCount,t);var o=!t||!1!==t.end?s:u;function i(e){_c("onunpipe"),e===n&&u()}function s(){_c("onend"),e.end()}r.endEmitted?sa(o):n.once("end",o),e.on("unpipe",i);var a=function(e){return function(){var t=e._readableState;_c("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ic(e))}}(n);e.on("drain",a);var c=!1;function u(){_c("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",f),e.removeListener("unpipe",i),n.removeListener("end",s),n.removeListener("end",u),n.removeListener("data",h),c=!0,!r.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var l=!1;function h(t){_c("ondata"),l=!1,!1!==e.write(t)||l||((1===r.pipesCount&&r.pipes===e||r.pipesCount>1&&-1!==Bc(r.pipes,e))&&!c&&(_c("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,l=!0),n.pause())}function f(t){_c("onerror",t),y(),e.removeListener("error",f),0===function(e,t){return e.listeners(t).length}(e,"error")&&e.emit("error",t)}function d(){e.removeListener("finish",p),y()}function p(){_c("onfinish"),e.removeListener("close",d),y()}function y(){_c("unpipe"),n.unpipe(e)}return n.on("data",h),function(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}(e,"error",f),e.once("close",d),e.once("finish",p),e.emit("pipe",n),r.flowing||(_c("pipe resume"),n.resume()),e},Ec.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var n=t.pipes,r=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},zc.prototype._write=function(e,t,n){n(new Error("not implemented"))},zc.prototype._writev=null,zc.prototype.end=function(e,t,n){var r=this._writableState;"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!=e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||r.finished||function(e,t,n){t.ending=!0,Kc(e,t),n&&(t.finished?sa(n):e.once("finish",n));t.ended=!0,e.writable=!1}(this,r,n)},Wa(Xc,Ec);for(var Zc=Object.keys(zc.prototype),Vc=0;Vce._pos){var r=n.substr(e._pos);if("x-user-defined"===e._charset){for(var o=new us(r.length),i=0;ie._pos&&(e.push(new us(new Uint8Array(s.result.slice(e._pos)))),e._pos=s.result.byteLength)},s.onload=function(){e.push(null)},s.readAsArrayBuffer(n)}e._xhr.readyState===au&&"ms-stream"!==e._mode&&e.push(null)},Wa(uu,zc);var lu=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","user-agent","via"];uu.prototype.setHeader=function(e,t){var n=e.toLowerCase();-1===lu.indexOf(n)&&(this._headers[n]={name:e,value:t})},uu.prototype.getHeader=function(e){return this._headers[e.toLowerCase()].value},uu.prototype.removeHeader=function(e){delete this._headers[e.toLowerCase()]},uu.prototype._onFinish=function(){var e=this;if(!e._destroyed){var t,n=e._opts,r=e._headers;if("POST"!==n.method&&"PUT"!==n.method&&"PATCH"!==n.method||(t=function(){if(void 0!==Ia)return Ia;try{new Zi.Blob([new ArrayBuffer(1)]),Ia=!0}catch(e){Ia=!1}return Ia}()?new Zi.Blob(e._body.map((function(e){return function(e){if(e instanceof Uint8Array){if(0===e.byteOffset&&e.byteLength===e.buffer.byteLength)return e.buffer;if("function"==typeof e.buffer.slice)return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(Ks(e)){for(var t=new Uint8Array(e.length),n=e.length,r=0;r= 0x80 (not a basic code point)","invalid-input":"Invalid input"},yu=Math.floor,gu=String.fromCharCode;function bu(e){throw new RangeError(pu[e])}function mu(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function wu(e,t,n){var r=0;for(e=n?yu(e/700):e>>1,e+=yu(e/t);e>455;r+=36)e=yu(e/35);return yu(r+36*e/(e+38))}function vu(e){return function(e,t){var n=e.split("@"),r="";n.length>1&&(r=n[0]+"@",e=n[1]);var o=function(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}((e=e.replace(du,".")).split("."),t).join(".");return r+o}(e,(function(e){return fu.test(e)?"xn--"+function(e){var t,n,r,o,i,s,a,c,u,l,h,f,d,p,y,g=[];for(e=function(e){for(var t,n,r=[],o=0,i=e.length;o=55296&&t<=56319&&o=t&&hyu((hu-n)/(d=r+1))&&bu("overflow"),n+=(a-t)*d,t=a,s=0;shu&&bu("overflow"),h==t){for(c=n,u=36;!(c<(l=u<=i?1:u>=i+26?26:u-i));u+=36)y=c-l,p=36-l,g.push(gu(mu(l+y%p,0))),c=yu(y/p);g.push(gu(mu(c,0))),i=wu(n,d,r==o),n=0,++r}++n,++t}return g.join("")}(e):e}))}function _u(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var xu=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function Eu(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}}function ku(e,t){if(e.map)return e.map(t);for(var n=[],r=0;r0&&a>s&&(a=s);for(var c=0;c=0?(u=d.substr(0,p),l=d.substr(p+1)):(u=d,l=""),h=decodeURIComponent(u),f=decodeURIComponent(l),_u(o,h)?xu(o[h])?o[h].push(f):o[h]=[o[h],f]:o[h]=f}return o}const Au=Zi.URL,Cu=Zi.URLSearchParams;var Ru={parse:Hu,resolve:Zu,resolveObject:Vu,fileURLToPath:Wu,format:Ku,Url:Tu,URL:Au,URLSearchParams:Cu};function Tu(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var Lu=/^([a-z0-9.+-]+:)/i,Iu=/:[0-9]*$/,Pu=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,ju=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),Uu=["'"].concat(ju),Bu=["%","/","?",";","#"].concat(Uu),Nu=["/","?","#"],Mu=/^[+a-z0-9A-Z_-]{0,63}$/,$u=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,zu={javascript:!0,"javascript:":!0},Fu={javascript:!0,"javascript:":!0},Du={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function Hu(e,t,n){if(e&&cc(e)&&e instanceof Tu)return e;var r=new Tu;return r.parse(e,t,n),r}function qu(e,t,n,r){if(!ic(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var o=t.indexOf("?"),i=-1!==o&&o127?x+="x":x+=_[E];if(!x.match(Mu)){var S=v.slice(0,u),O=v.slice(u+1),A=_.match($u);A&&(S.push(A[1]),O.unshift(A[2])),O.length&&(a="/"+O.join(".")+a),e.hostname=S.join(".");break}}}}e.hostname.length>255?e.hostname="":e.hostname=e.hostname.toLowerCase(),w||(e.hostname=vu(e.hostname)),f=e.port?":"+e.port:"";var C=e.hostname||"";e.host=C+f,e.href+=e.host,w&&(e.hostname=e.hostname.substr(1,e.hostname.length-2),"/"!==a[0]&&(a="/"+a))}if(!zu[p])for(u=0,h=Uu.length;u0)&&r.host.split("@"))&&(r.auth=y.shift(),r.host=r.hostname=y.shift())),r.search=e.search,r.query=e.query,oc(r.pathname)&&oc(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r;if(!v.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var x=v.slice(-1)[0],E=(r.host||e.host||v.length>1)&&("."===x||".."===x)||""===x,k=0,S=v.length;S>=0;S--)"."===(x=v[S])?v.splice(S,1):".."===x?(v.splice(S,1),k++):k&&(v.splice(S,1),k--);if(!m&&!w)for(;k--;k)v.unshift("..");!m||""===v[0]||v[0]&&"/"===v[0].charAt(0)||v.unshift(""),E&&"/"!==v.join("/").substr(-1)&&v.push("");var O=""===v[0]||v[0]&&"/"===v[0].charAt(0);return _&&(r.hostname=r.host=O?"":v.length?v.shift():"",(y=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=y.shift(),r.host=r.hostname=y.shift())),(m=m||r.host&&v.length)&&!O&&v.unshift(""),v.length?r.pathname=v.join("/"):(r.pathname=null,r.path=null),oc(r.pathname)&&oc(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=e.auth||r.auth,r.slashes=r.slashes||e.slashes,r.href=r.format(),r},Tu.prototype.parseHost=function(){return Yu(this)};var Xu=Object.freeze({__proto__:null,URL:Au,URLSearchParams:Cu,Url:Tu,default:Ru,fileURLToPath:Wu,format:Ku,parse:Hu,resolve:Zu,resolveObject:Vu});function Ju(e,t){"string"==typeof e&&(e=Hu(e));var n=-1===Zi.location.protocol.search(/^https?:$/)?"http:":"",r=e.protocol||n,o=e.hostname||e.host,i=e.port,s=e.path||"/";o&&-1!==o.indexOf(":")&&(o="["+o+"]"),e.url=(o?r+"//"+o:"")+(i?":"+i:"")+s,e.method=(e.method||"GET").toUpperCase(),e.headers=e.headers||{};var a=new uu(e);return t&&a.on("response",t),a}function Qu(e,t){var n=Ju(e,t);return n.end(),n}function el(){}el.defaultMaxSockets=4;var tl=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"],nl={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",300:"Multiple Choices",301:"Moved Permanently",302:"Moved Temporarily",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Time-out",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Request Entity Too Large",414:"Request-URI Too Large",415:"Unsupported Media Type",416:"Requested Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Time-out",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"},rl={request:Ju,get:Qu,Agent:el,METHODS:tl,STATUS_CODES:nl},ol=In(Object.freeze({__proto__:null,Agent:el,METHODS:tl,STATUS_CODES:nl,default:rl,get:Qu,request:Ju}));function il(e,t){"string"==typeof e&&(e=Hu(e));var n=-1===Zi.location.protocol.search(/^https?:$/)?"http:":"",r=e.protocol||n,o=e.hostname||e.host,i=e.port,s=e.path||"/";o&&-1!==o.indexOf(":")&&(o="["+o+"]"),e.url=(o?r+"//"+o:"")+(i?":"+i:"")+s,e.method=(e.method||"GET").toUpperCase(),e.headers=e.headers||{};var a=new uu(e);return t&&a.on("response",t),a}function sl(e,t){var n=il(e,t);return n.end(),n}function al(){}al.defaultMaxSockets=4;var cl=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"],ul={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",300:"Multiple Choices",301:"Moved Permanently",302:"Moved Temporarily",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Time-out",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Request Entity Too Large",414:"Request-URI Too Large",415:"Unsupported Media Type",416:"Requested Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Time-out",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"},ll={request:il,get:sl,Agent:al,METHODS:cl,STATUS_CODES:ul},hl=In(Object.freeze({__proto__:null,Agent:al,METHODS:cl,STATUS_CODES:ul,default:ll,get:sl,request:il})),fl=In(Object.freeze({__proto__:null,default:{}})),dl=In(Object.freeze({__proto__:null,default:{}})),pl=In(Object.freeze({__proto__:null,default:{}})),yl=In(iu),gl=In(Xu),bl={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};function ml(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}function wl(e,t,n,r,o){if(t.subarray&&e.subarray)e.set(t.subarray(n,n+r),o);else for(var i=0;i=0;)e[t]=0}var kl=256,Sl=286,Ol=30,Al=15,Cl=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],Rl=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Tl=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],Ll=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Il=new Array(576);El(Il);var Pl=new Array(60);El(Pl);var jl=new Array(512);El(jl);var Ul=new Array(256);El(Ul);var Bl=new Array(29);El(Bl);var Nl,Ml,$l,zl=new Array(Ol);function Fl(e,t,n,r,o){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=o,this.has_stree=e&&e.length}function Dl(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function Hl(e){return e<256?jl[e]:jl[256+(e>>>7)]}function ql(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function Wl(e,t,n){e.bi_valid>16-n?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<>>=1,n<<=1}while(--t>0);return n>>>1}function Zl(e,t,n){var r,o,i=new Array(16),s=0;for(r=1;r<=Al;r++)i[r]=s=s+n[r-1]<<1;for(o=0;o<=t;o++){var a=e[2*o+1];0!==a&&(e[2*o]=Gl(i[a]++,a))}}function Vl(e){var t;for(t=0;t8?ql(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function Xl(e,t,n,r){var o=2*t,i=2*n;return e[o]>1;n>=1;n--)Jl(e,i,n);o=c;do{n=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Jl(e,i,1),r=e.heap[1],e.heap[--e.heap_max]=n,e.heap[--e.heap_max]=r,i[2*o]=i[2*n]+i[2*r],e.depth[o]=(e.depth[n]>=e.depth[r]?e.depth[n]:e.depth[r])+1,i[2*n+1]=i[2*r+1]=o,e.heap[1]=o++,Jl(e,i,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var n,r,o,i,s,a,c=t.dyn_tree,u=t.max_code,l=t.stat_desc.static_tree,h=t.stat_desc.has_stree,f=t.stat_desc.extra_bits,d=t.stat_desc.extra_base,p=t.stat_desc.max_length,y=0;for(i=0;i<=Al;i++)e.bl_count[i]=0;for(c[2*e.heap[e.heap_max]+1]=0,n=e.heap_max+1;n<573;n++)(i=c[2*c[2*(r=e.heap[n])+1]+1]+1)>p&&(i=p,y++),c[2*r+1]=i,r>u||(e.bl_count[i]++,s=0,r>=d&&(s=f[r-d]),a=c[2*r],e.opt_len+=a*(i+s),h&&(e.static_len+=a*(l[2*r+1]+s)));if(0!==y){do{for(i=p-1;0===e.bl_count[i];)i--;e.bl_count[i]--,e.bl_count[i+1]+=2,e.bl_count[p]--,y-=2}while(y>0);for(i=p;0!==i;i--)for(r=e.bl_count[i];0!==r;)(o=e.heap[--n])>u||(c[2*o+1]!==i&&(e.opt_len+=(i-c[2*o+1])*c[2*o],c[2*o+1]=i),r--)}}(e,t),Zl(i,u,e.bl_count)}function th(e,t,n){var r,o,i=-1,s=t[1],a=0,c=7,u=4;for(0===s&&(c=138,u=3),t[2*(n+1)+1]=65535,r=0;r<=n;r++)o=s,s=t[2*(r+1)+1],++a>=7;r=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}function ah(e,t,n,r){var o,i,s=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,n=4093624447;for(t=0;t<=31;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t=3&&0===e.bl_tree[2*Ll[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),o=e.opt_len+3+7>>>3,(i=e.static_len+3+7>>>3)<=o&&(o=i)):o=i=n+5,n+4<=o&&-1!==t?ih(e,t,n,r):4===e.strategy||i===o?(Wl(e,2+(r?1:0),3),Ql(e,Il,Pl)):(Wl(e,4+(r?1:0),3),function(e,t,n,r){var o;for(Wl(e,t-257,5),Wl(e,n-1,5),Wl(e,r-4,4),o=0;o>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&n,e.last_lit++,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(Ul[n]+kl+1)]++,e.dyn_dtree[2*Hl(t)]++),e.last_lit===e.lit_bufsize-1}function uh(e,t,n,r){for(var o=65535&e|0,i=e>>>16&65535|0,s=0;0!==n;){n-=s=n>2e3?2e3:n;do{i=i+(o=o+t[r++]|0)|0}while(--s);o%=65521,i%=65521}return o|i<<16|0}var lh=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();function hh(e,t,n,r){var o=lh,i=r+n;e^=-1;for(var s=r;s>>8^o[255&(e^t[s])];return-1^e}var fh,dh=-2,ph=258,yh=262,gh=103,bh=113,mh=666;function wh(e,t){return e.msg=bl[t],t}function vh(e){return(e<<1)-(e>4?9:0)}function _h(e){for(var t=e.length;--t>=0;)e[t]=0}function xh(e){var t=e.state,n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(wl(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))}function Eh(e,t){ah(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,xh(e.strm)}function kh(e,t){e.pending_buf[e.pending++]=t}function Sh(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function Oh(e,t){var n,r,o=e.max_chain_length,i=e.strstart,s=e.prev_length,a=e.nice_match,c=e.strstart>e.w_size-yh?e.strstart-(e.w_size-yh):0,u=e.window,l=e.w_mask,h=e.prev,f=e.strstart+ph,d=u[i+s-1],p=u[i+s];e.prev_length>=e.good_match&&(o>>=2),a>e.lookahead&&(a=e.lookahead);do{if(u[(n=t)+s]===p&&u[n+s-1]===d&&u[n]===u[i]&&u[++n]===u[i+1]){i+=2,n++;do{}while(u[++i]===u[++n]&&u[++i]===u[++n]&&u[++i]===u[++n]&&u[++i]===u[++n]&&u[++i]===u[++n]&&u[++i]===u[++n]&&u[++i]===u[++n]&&u[++i]===u[++n]&&is){if(e.match_start=t,s=r,r>=a)break;d=u[i+s-1],p=u[i+s]}}}while((t=h[t&l])>c&&0!=--o);return s<=e.lookahead?s:e.lookahead}function Ah(e){var t,n,r,o,i,s,a,c,u,l,h=e.w_size;do{if(o=e.window_size-e.lookahead-e.strstart,e.strstart>=h+(h-yh)){wl(e.window,e.window,h,h,0),e.match_start-=h,e.strstart-=h,e.block_start-=h,t=n=e.hash_size;do{r=e.head[--t],e.head[t]=r>=h?r-h:0}while(--n);t=n=h;do{r=e.prev[--t],e.prev[t]=r>=h?r-h:0}while(--n);o+=h}if(0===e.strm.avail_in)break;if(s=e.strm,a=e.window,c=e.strstart+e.lookahead,u=o,l=void 0,(l=s.avail_in)>u&&(l=u),n=0===l?0:(s.avail_in-=l,wl(a,s.input,s.next_in,l,c),1===s.state.wrap?s.adler=uh(s.adler,a,l,c):2===s.state.wrap&&(s.adler=hh(s.adler,a,l,c)),s.next_in+=l,s.total_in+=l,l),e.lookahead+=n,e.lookahead+e.insert>=3)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=(e.ins_h<=3&&(e.ins_h=(e.ins_h<=3)if(r=ch(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<=3&&(e.ins_h=(e.ins_h<4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){o=e.strstart+e.lookahead-3,r=ch(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=o&&(e.ins_h=(e.ins_h<5||t<0)return e?wh(e,dh):dh;if(r=e.state,!e.output||!e.input&&0!==e.avail_in||r.status===mh&&4!==t)return wh(e,0===e.avail_out?-5:dh);if(r.strm=e,n=r.last_flush,r.last_flush=t,42===r.status)if(2===r.wrap)e.adler=0,kh(r,31),kh(r,139),kh(r,8),r.gzhead?(kh(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),kh(r,255&r.gzhead.time),kh(r,r.gzhead.time>>8&255),kh(r,r.gzhead.time>>16&255),kh(r,r.gzhead.time>>24&255),kh(r,9===r.level?2:r.strategy>=2||r.level<2?4:0),kh(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(kh(r,255&r.gzhead.extra.length),kh(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=hh(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69):(kh(r,0),kh(r,0),kh(r,0),kh(r,0),kh(r,0),kh(r,9===r.level?2:r.strategy>=2||r.level<2?4:0),kh(r,3),r.status=bh);else{var s=8+(r.w_bits-8<<4)<<8;s|=(r.strategy>=2||r.level<2?0:r.level<6?1:6===r.level?2:3)<<6,0!==r.strstart&&(s|=32),s+=31-s%31,r.status=bh,Sh(r,s),0!==r.strstart&&(Sh(r,e.adler>>>16),Sh(r,65535&e.adler)),e.adler=1}if(69===r.status)if(r.gzhead.extra){for(o=r.pending;r.gzindex<(65535&r.gzhead.extra.length)&&(r.pending!==r.pending_buf_size||(r.gzhead.hcrc&&r.pending>o&&(e.adler=hh(e.adler,r.pending_buf,r.pending-o,o)),xh(e),o=r.pending,r.pending!==r.pending_buf_size));)kh(r,255&r.gzhead.extra[r.gzindex]),r.gzindex++;r.gzhead.hcrc&&r.pending>o&&(e.adler=hh(e.adler,r.pending_buf,r.pending-o,o)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=73)}else r.status=73;if(73===r.status)if(r.gzhead.name){o=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>o&&(e.adler=hh(e.adler,r.pending_buf,r.pending-o,o)),xh(e),o=r.pending,r.pending===r.pending_buf_size)){i=1;break}i=r.gzindexo&&(e.adler=hh(e.adler,r.pending_buf,r.pending-o,o)),0===i&&(r.gzindex=0,r.status=91)}else r.status=91;if(91===r.status)if(r.gzhead.comment){o=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>o&&(e.adler=hh(e.adler,r.pending_buf,r.pending-o,o)),xh(e),o=r.pending,r.pending===r.pending_buf_size)){i=1;break}i=r.gzindexo&&(e.adler=hh(e.adler,r.pending_buf,r.pending-o,o)),0===i&&(r.status=gh)}else r.status=gh;if(r.status===gh&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&xh(e),r.pending+2<=r.pending_buf_size&&(kh(r,255&e.adler),kh(r,e.adler>>8&255),e.adler=0,r.status=bh)):r.status=bh),0!==r.pending){if(xh(e),0===e.avail_out)return r.last_flush=-1,0}else if(0===e.avail_in&&vh(t)<=vh(n)&&4!==t)return wh(e,-5);if(r.status===mh&&0!==e.avail_in)return wh(e,-5);if(0!==e.avail_in||0!==r.lookahead||0!==t&&r.status!==mh){var a=2===r.strategy?function(e,t){for(var n;;){if(0===e.lookahead&&(Ah(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,n=ch(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(Eh(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(Eh(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(Eh(e,!1),0===e.strm.avail_out)?1:2}(r,t):3===r.strategy?function(e,t){for(var n,r,o,i,s=e.window;;){if(e.lookahead<=ph){if(Ah(e),e.lookahead<=ph&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(r=s[o=e.strstart-1])===s[++o]&&r===s[++o]&&r===s[++o]){i=e.strstart+ph;do{}while(r===s[++o]&&r===s[++o]&&r===s[++o]&&r===s[++o]&&r===s[++o]&&r===s[++o]&&r===s[++o]&&r===s[++o]&&oe.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=ch(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=ch(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(Eh(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(Eh(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(Eh(e,!1),0===e.strm.avail_out)?1:2}(r,t):fh[r.level].func(r,t);if(3!==a&&4!==a||(r.status=mh),1===a||3===a)return 0===e.avail_out&&(r.last_flush=-1),0;if(2===a&&(1===t?sh(r):5!==t&&(ih(r,0,0,!1),3===t&&(_h(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),xh(e),0===e.avail_out))return r.last_flush=-1,0}return 4!==t?0:r.wrap<=0?1:(2===r.wrap?(kh(r,255&e.adler),kh(r,e.adler>>8&255),kh(r,e.adler>>16&255),kh(r,e.adler>>24&255),kh(r,255&e.total_in),kh(r,e.total_in>>8&255),kh(r,e.total_in>>16&255),kh(r,e.total_in>>24&255)):(Sh(r,e.adler>>>16),Sh(r,65535&e.adler)),xh(e),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?0:1)}fh=[new Th(0,0,0,0,(function(e,t){var n=65535;for(n>e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(Ah(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+n;if((0===e.strstart||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,Eh(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-yh&&(Eh(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(Eh(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(Eh(e,!1),e.strm.avail_out),1)})),new Th(4,4,8,4,Ch),new Th(4,5,16,8,Ch),new Th(4,6,32,32,Ch),new Th(4,4,16,16,Rh),new Th(8,16,32,32,Rh),new Th(8,16,128,128,Rh),new Th(8,32,128,256,Rh),new Th(32,128,258,1024,Rh),new Th(32,258,258,4096,Rh)];function jh(e,t){var n,r,o,i,s,a,c,u,l,h,f,d,p,y,g,b,m,w,v,_,x,E,k,S,O;n=e.state,r=e.next_in,S=e.input,o=r+(e.avail_in-5),i=e.next_out,O=e.output,s=i-(t-e.avail_out),a=i+(e.avail_out-257),c=n.dmax,u=n.wsize,l=n.whave,h=n.wnext,f=n.window,d=n.hold,p=n.bits,y=n.lencode,g=n.distcode,b=(1<>>=v=w>>>24,p-=v,0===(v=w>>>16&255))O[i++]=65535&w;else{if(!(16&v)){if(0==(64&v)){w=y[(65535&w)+(d&(1<>>=v,p-=v),p<15&&(d+=S[r++]<>>=v=w>>>24,p-=v,!(16&(v=w>>>16&255))){if(0==(64&v)){w=g[(65535&w)+(d&(1<c){e.msg="invalid distance too far back",n.mode=30;break e}if(d>>>=v,p-=v,x>(v=i-s)){if((v=x-v)>l&&n.sane){e.msg="invalid distance too far back",n.mode=30;break e}if(E=0,k=f,0===h){if(E+=u-v,v<_){_-=v;do{O[i++]=f[E++]}while(--v);E=i-x,k=O}}else if(h2;)O[i++]=k[E++],O[i++]=k[E++],O[i++]=k[E++],_-=3;_&&(O[i++]=k[E++],_>1&&(O[i++]=k[E++]))}else{E=i-x;do{O[i++]=O[E++],O[i++]=O[E++],O[i++]=O[E++],_-=3}while(_>2);_&&(O[i++]=O[E++],_>1&&(O[i++]=O[E++]))}break}}break}}while(r>3,d&=(1<<(p-=_<<3))-1,e.next_in=r,e.next_out=i,e.avail_in=r=1&&0===T[_];_--);if(x>_&&(x=_),0===_)return o[i++]=20971520,o[i++]=20971520,a.bits=1,0;for(v=1;v<_&&0===T[v];v++);for(x0&&(0===e||1!==_))return-1;for(L[1]=0,m=1;m852||2===e&&O>592)return 1;for(;;){p=m-k,s[w]d?(y=I[P+s[w]],g=C[R+s[w]]):(y=96,g=0),c=1<>k)+(u-=c)]=p<<24|y<<16|g|0}while(0!==u);for(c=1<>=1;if(0!==c?(A&=c-1,A+=c):A=0,w++,0==--T[m]){if(m===_)break;m=t[n+s[w]]}if(m>x&&(A&h)!==l){for(0===k&&(k=x),f+=v,S=1<<(E=m-k);E+k<_&&!((S-=T[E+k])<=0);)E++,S<<=1;if(O+=1<852||2===e&&O>592)return 1;o[l=A&h]=x<<24|E<<16|f-i|0}}return 0!==A&&(o[f+A]=m-k<<24|64<<16|0),a.bits=x,0}var Fh=-2,Dh=12,Hh=30;function qh(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function Wh(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new _l(320),this.work=new _l(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Kh(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,function(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new xl(852),t.distcode=t.distdyn=new xl(592),t.sane=1,t.back=-1,0):Fh}(e)):Fh}function Gh(e,t){var n,r;return e?(r=new Wh,e.state=r,r.window=null,n=function(e,t){var n,r;return e&&e.state?(r=e.state,t<0?(n=0,t=-t):(n=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Fh:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,Kh(e))):Fh}(e,t),0!==n&&(e.state=null),n):Fh}var Zh,Vh,Yh=!0;function Xh(e){if(Yh){var t;for(Zh=new xl(512),Vh=new xl(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(zh(1,e.lens,0,288,Zh,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;zh(2,e.lens,0,32,Vh,0,e.work,{bits:5}),Yh=!1}e.lencode=Zh,e.lenbits=9,e.distcode=Vh,e.distbits=5}function Jh(e,t){var n,r,o,i,s,a,c,u,l,h,f,d,p,y,g,b,m,w,v,_,x,E,k,S,O=0,A=new vl(4),C=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return Fh;(n=e.state).mode===Dh&&(n.mode=13),s=e.next_out,o=e.output,c=e.avail_out,i=e.next_in,r=e.input,a=e.avail_in,u=n.hold,l=n.bits,h=a,f=c,E=0;e:for(;;)switch(n.mode){case 1:if(0===n.wrap){n.mode=13;break}for(;l<16;){if(0===a)break e;a--,u+=r[i++]<>>8&255,n.check=hh(n.check,A,2,0),u=0,l=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",n.mode=Hh;break}if(8!=(15&u)){e.msg="unknown compression method",n.mode=Hh;break}if(l-=4,x=8+(15&(u>>>=4)),0===n.wbits)n.wbits=x;else if(x>n.wbits){e.msg="invalid window size",n.mode=Hh;break}n.dmax=1<>8&1),512&n.flags&&(A[0]=255&u,A[1]=u>>>8&255,n.check=hh(n.check,A,2,0)),u=0,l=0,n.mode=3;case 3:for(;l<32;){if(0===a)break e;a--,u+=r[i++]<>>8&255,A[2]=u>>>16&255,A[3]=u>>>24&255,n.check=hh(n.check,A,4,0)),u=0,l=0,n.mode=4;case 4:for(;l<16;){if(0===a)break e;a--,u+=r[i++]<>8),512&n.flags&&(A[0]=255&u,A[1]=u>>>8&255,n.check=hh(n.check,A,2,0)),u=0,l=0,n.mode=5;case 5:if(1024&n.flags){for(;l<16;){if(0===a)break e;a--,u+=r[i++]<>>8&255,n.check=hh(n.check,A,2,0)),u=0,l=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&((d=n.length)>a&&(d=a),d&&(n.head&&(x=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),wl(n.head.extra,r,i,d,x)),512&n.flags&&(n.check=hh(n.check,r,d,i)),a-=d,i+=d,n.length-=d),n.length))break e;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===a)break e;d=0;do{x=r[i+d++],n.head&&x&&n.length<65536&&(n.head.name+=String.fromCharCode(x))}while(x&&d>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=Dh;break;case 10:for(;l<32;){if(0===a)break e;a--,u+=r[i++]<>>=7&l,l-=7&l,n.mode=27;break}for(;l<3;){if(0===a)break e;a--,u+=r[i++]<>>=1)){case 0:n.mode=14;break;case 1:if(Xh(n),n.mode=20,6===t){u>>>=2,l-=2;break e}break;case 2:n.mode=17;break;case 3:e.msg="invalid block type",n.mode=Hh}u>>>=2,l-=2;break;case 14:for(u>>>=7&l,l-=7&l;l<32;){if(0===a)break e;a--,u+=r[i++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=Hh;break}if(n.length=65535&u,u=0,l=0,n.mode=15,6===t)break e;case 15:n.mode=16;case 16:if(d=n.length){if(d>a&&(d=a),d>c&&(d=c),0===d)break e;wl(o,r,i,d,s),a-=d,i+=d,c-=d,s+=d,n.length-=d;break}n.mode=Dh;break;case 17:for(;l<14;){if(0===a)break e;a--,u+=r[i++]<>>=5,l-=5,n.ndist=1+(31&u),u>>>=5,l-=5,n.ncode=4+(15&u),u>>>=4,l-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=Hh;break}n.have=0,n.mode=18;case 18:for(;n.have>>=3,l-=3}for(;n.have<19;)n.lens[C[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,k={bits:n.lenbits},E=zh(0,n.lens,0,19,n.lencode,0,n.work,k),n.lenbits=k.bits,E){e.msg="invalid code lengths set",n.mode=Hh;break}n.have=0,n.mode=19;case 19:for(;n.have>>16&255,m=65535&O,!((g=O>>>24)<=l);){if(0===a)break e;a--,u+=r[i++]<>>=g,l-=g,n.lens[n.have++]=m;else{if(16===m){for(S=g+2;l>>=g,l-=g,0===n.have){e.msg="invalid bit length repeat",n.mode=Hh;break}x=n.lens[n.have-1],d=3+(3&u),u>>>=2,l-=2}else if(17===m){for(S=g+3;l>>=g)),u>>>=3,l-=3}else{for(S=g+7;l>>=g)),u>>>=7,l-=7}if(n.have+d>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=Hh;break}for(;d--;)n.lens[n.have++]=x}}if(n.mode===Hh)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=Hh;break}if(n.lenbits=9,k={bits:n.lenbits},E=zh(1,n.lens,0,n.nlen,n.lencode,0,n.work,k),n.lenbits=k.bits,E){e.msg="invalid literal/lengths set",n.mode=Hh;break}if(n.distbits=6,n.distcode=n.distdyn,k={bits:n.distbits},E=zh(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,k),n.distbits=k.bits,E){e.msg="invalid distances set",n.mode=Hh;break}if(n.mode=20,6===t)break e;case 20:n.mode=21;case 21:if(a>=6&&c>=258){e.next_out=s,e.avail_out=c,e.next_in=i,e.avail_in=a,n.hold=u,n.bits=l,jh(e,f),s=e.next_out,o=e.output,c=e.avail_out,i=e.next_in,r=e.input,a=e.avail_in,u=n.hold,l=n.bits,n.mode===Dh&&(n.back=-1);break}for(n.back=0;b=(O=n.lencode[u&(1<>>16&255,m=65535&O,!((g=O>>>24)<=l);){if(0===a)break e;a--,u+=r[i++]<>w)])>>>16&255,m=65535&O,!(w+(g=O>>>24)<=l);){if(0===a)break e;a--,u+=r[i++]<>>=w,l-=w,n.back+=w}if(u>>>=g,l-=g,n.back+=g,n.length=m,0===b){n.mode=26;break}if(32&b){n.back=-1,n.mode=Dh;break}if(64&b){e.msg="invalid literal/length code",n.mode=Hh;break}n.extra=15&b,n.mode=22;case 22:if(n.extra){for(S=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;b=(O=n.distcode[u&(1<>>16&255,m=65535&O,!((g=O>>>24)<=l);){if(0===a)break e;a--,u+=r[i++]<>w)])>>>16&255,m=65535&O,!(w+(g=O>>>24)<=l);){if(0===a)break e;a--,u+=r[i++]<>>=w,l-=w,n.back+=w}if(u>>>=g,l-=g,n.back+=g,64&b){e.msg="invalid distance code",n.mode=Hh;break}n.offset=m,n.extra=15&b,n.mode=24;case 24:if(n.extra){for(S=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=Hh;break}n.mode=25;case 25:if(0===c)break e;if(d=f-c,n.offset>d){if((d=n.offset-d)>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=Hh;break}d>n.wnext?(d-=n.wnext,p=n.wsize-d):p=n.wnext-d,d>n.length&&(d=n.length),y=n.window}else y=o,p=s-n.offset,d=n.length;d>c&&(d=c),c-=d,n.length-=d;do{o[s++]=y[p++]}while(--d);0===n.length&&(n.mode=21);break;case 26:if(0===c)break e;o[s++]=n.length,c--,n.mode=21;break;case 27:if(n.wrap){for(;l<32;){if(0===a)break e;a--,u|=r[i++]<=i.wsize?(wl(i.window,t,n-i.wsize,i.wsize,0),i.wnext=0,i.whave=i.wsize):((o=i.wsize-i.wnext)>r&&(o=r),wl(i.window,t,n-r,o,i.wnext),(r-=o)?(wl(i.window,t,n-r,r,0),i.wnext=r,i.whave=i.wsize):(i.wnext+=o,i.wnext===i.wsize&&(i.wnext=0),i.whave7)throw new TypeError("Bad argument");this.mode=e,this.init_done=!1,this.write_in_progress=!1,this.pending_close=!1,this.windowBits=0,this.level=0,this.memLevel=0,this.strategy=0,this.dictionary=null}function tf(e,t){for(var n=0;n15&&(s=2,r-=16),o<1||o>9||8!==n||r<8||r>15||t<0||t>9||i<0||i>4)return wh(e,dh);8===r&&(r=9);var a=new Lh;return e.state=a,a.strm=e,a.wrap=s,a.gzhead=null,a.w_bits=r,a.w_size=1<rf.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+e.chunkSize);if(e.windowBits&&(e.windowBitsrf.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+e.windowBits);if(e.level&&(e.levelrf.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+e.level);if(e.memLevel&&(e.memLevelrf.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+e.memLevel);if(e.strategy&&e.strategy!=rf.Z_FILTERED&&e.strategy!=rf.Z_HUFFMAN_ONLY&&e.strategy!=rf.Z_RLE&&e.strategy!=rf.Z_FIXED&&e.strategy!=rf.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+e.strategy);if(e.dictionary&&!us.isBuffer(e.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._binding=new rf.Zlib(t);var n=this;this._hadError=!1,this._binding.onerror=function(e,t){n._binding=null,n._hadError=!0;var r=new Error(e);r.errno=t,r.code=rf.codes[t],n.emit("error",r)};var r=rf.Z_DEFAULT_COMPRESSION;"number"==typeof e.level&&(r=e.level);var o=rf.Z_DEFAULT_STRATEGY;"number"==typeof e.strategy&&(o=e.strategy),this._binding.init(e.windowBits||rf.Z_DEFAULT_WINDOWBITS,r,e.memLevel||rf.Z_DEFAULT_MEMLEVEL,o,e.dictionary),this._buffer=new us(this._chunkSize),this._offset=0,this._closed=!1,this._level=r,this._strategy=o,this.once("end",this.close)}Object.keys(of).forEach((function(e){of[of[e]]=e})),Wa(Bf,tu),Bf.prototype.params=function(e,t,n){if(erf.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+e);if(t!=rf.Z_FILTERED&&t!=rf.Z_HUFFMAN_ONLY&&t!=rf.Z_RLE&&t!=rf.Z_FIXED&&t!=rf.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+t);if(this._level!==e||this._strategy!==t){var r=this;this.flush(rf.Z_SYNC_FLUSH,(function(){r._binding.params(e,t),r._hadError||(r._level=e,r._strategy=t,n&&n())}))}else wa.nextTick(n)},Bf.prototype.reset=function(){return this._binding.reset()},Bf.prototype._flush=function(e){this._transform(new us(0),"",e)},Bf.prototype.flush=function(e,t){var n=this._writableState;if(("function"==typeof e||void 0===e&&!t)&&(t=e,e=rf.Z_FULL_FLUSH),n.ended)t&&wa.nextTick(t);else if(n.ending)t&&this.once("end",t);else if(n.needDrain){var r=this;this.once("drain",(function(){r.flush(t)}))}else this._flushFlag=e,this.write(new us(0),"",t)},Bf.prototype.close=function(e){if(e&&wa.nextTick(e),!this._closed){this._closed=!0,this._binding.close();var t=this;wa.nextTick((function(){t.emit("close")}))}},Bf.prototype._transform=function(e,t,n){var r,o=this._writableState,i=(o.ending||o.ended)&&(!e||o.length===e.length);if(null===!e&&!us.isBuffer(e))return n(new Error("invalid input"));i?r=rf.Z_FINISH:(r=this._flushFlag,e.length>=o.length&&(this._flushFlag=this._opts.flush||rf.Z_NO_FLUSH)),this._processChunk(e,r,n)},Bf.prototype._processChunk=function(e,t,n){var r=e&&e.length,o=this._chunkSize-this._offset,i=0,s=this,a="function"==typeof n;if(!a){var c,u=[],l=0;this.on("error",(function(e){c=e}));do{var h=this._binding.writeSync(t,e,i,r,this._buffer,this._offset,o)}while(!this._hadError&&p(h[0],h[1]));if(this._hadError)throw c;var f=us.concat(u,l);return this.close(),f}var d=this._binding.write(t,e,i,r,this._buffer,this._offset,o);function p(c,h){if(!s._hadError){var f=o-h;if(function(e,t){if(!e)throw new Error(t)}(f>=0,"have should not go down"),f>0){var d=s._buffer.slice(s._offset,s._offset+f);s._offset+=f,a?s.push(d):(u.push(d),l+=d.length)}if((0===h||s._offset>=s._chunkSize)&&(o=s._chunkSize,s._offset=0,s._buffer=new us(s._chunkSize)),0===h){if(i+=r-c,r=c,!a)return!0;var y=s._binding.write(t,e,i,r,s._buffer,s._offset,s._chunkSize);return y.callback=p,void(y.buffer=e)}if(!a)return!1;n()}}d.buffer=e,d.callback=p},Wa(Rf,Bf),Wa(Tf,Bf),Wa(Lf,Bf),Wa(If,Bf),Wa(Pf,Bf),Wa(jf,Bf),Wa(Uf,Bf);var Nf,Mf,$f={codes:of,createDeflate:sf,createInflate:af,createDeflateRaw:cf,createInflateRaw:uf,createGzip:lf,createGunzip:hf,createUnzip:ff,deflate:df,deflateSync:pf,gzip:yf,gzipSync:gf,deflateRaw:bf,deflateRawSync:mf,unzip:wf,unzipSync:vf,inflate:_f,inflateSync:xf,gunzip:Ef,gunzipSync:kf,inflateRaw:Sf,inflateRawSync:Of,Deflate:Rf,Inflate:Tf,Gzip:Lf,Gunzip:If,DeflateRaw:Pf,InflateRaw:jf,Unzip:Uf,Zlib:Bf},zf=In(Object.freeze({__proto__:null,Deflate:Rf,DeflateRaw:Pf,Gunzip:If,Gzip:Lf,Inflate:Tf,InflateRaw:jf,Unzip:Uf,Zlib:Bf,codes:of,createDeflate:sf,createDeflateRaw:cf,createGunzip:hf,createGzip:lf,createInflate:af,createInflateRaw:uf,createUnzip:ff,default:$f,deflate:df,deflateRaw:bf,deflateRawSync:mf,deflateSync:pf,gunzip:Ef,gunzipSync:kf,gzip:yf,gzipSync:gf,inflate:_f,inflateRaw:Sf,inflateRawSync:Of,inflateSync:xf,unzip:wf,unzipSync:vf})),Ff={},Df={get exports(){return Ff},set exports(e){Ff=e}};function Hf(){return Mf?Nf:(Mf=1,Nf={BINARY_TYPES:["nodebuffer","arraybuffer","fragments"],EMPTY_BUFFER:us.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}})}var qf={},Wf={get exports(){return qf},set exports(e){qf=e}},Kf={},Gf={get exports(){return Kf},set exports(e){Kf=e}};function Zf(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Vf=In(Object.freeze({__proto__:null,default:{}}));function Yf(e,t){for(var n=0,r=e.length-1;r>=0;r--){var o=e[r];"."===o?e.splice(r,1):".."===o?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}var Xf=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,Jf=function(e){return Xf.exec(e).slice(1)};function Qf(){for(var e="",t=!1,n=arguments.length-1;n>=-1&&!t;n--){var r=n>=0?arguments[n]:"/";if("string"!=typeof r)throw new TypeError("Arguments to path.resolve must be strings");r&&(e=r+"/"+e,t="/"===r.charAt(0))}return(t?"/":"")+(e=Yf(cd(e.split("/"),(function(e){return!!e})),!t).join("/"))||"."}function ed(e){var t=td(e),n="/"===ld(e,-1);return(e=Yf(cd(e.split("/"),(function(e){return!!e})),!t).join("/"))||t||(e="."),e&&n&&(e+="/"),(t?"/":"")+e}function td(e){return"/"===e.charAt(0)}function nd(){var e=Array.prototype.slice.call(arguments,0);return ed(cd(e,(function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e})).join("/"))}function rd(e,t){function n(e){for(var t=0;t=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=Qf(e).substr(1),t=Qf(t).substr(1);for(var r=n(e.split("/")),o=n(t.split("/")),i=Math.min(r.length,o.length),s=i,a=0;an.specificity?-1:1:0}}return Cd=d,d.resolve=d.path=function(e){e=t.resolve(e||".");try{var n=r(t.join(e,"package.json")).name.toUpperCase().replace(/-/g,"_");wa.env[n+"_PREBUILD"]&&(e=wa.env[n+"_PREBUILD"])}catch(e){}if(!i){var o=y(t.join(e,"build/Release"),g);if(o)return o;var d=y(t.join(e,"build/Debug"),g);if(d)return d}var E=O(e);if(E)return E;var k=O(t.dirname(wa.execPath));if(k)return k;var S=["platform="+u,"arch="+c,"runtime="+a,"abi="+s,"uv="+f,h?"armv="+h:"","libc="+l,"node="+wa.versions.node,wa.versions.electron?"electron="+wa.versions.electron:"","function"==typeof __webpack_require__?"webpack=true":""].filter(Boolean).join(" ");throw new Error("No native build was found for "+S+"\n loaded from: "+e+"\n");function O(e){var n=p(t.join(e,"prebuilds")).map(b).filter(m(u,c)).sort(w)[0];if(n){var r=t.join(e,"prebuilds",n.name),o=p(r).map(v).filter(_(a,s)).sort(x(a))[0];return o?t.join(r,o.file):void 0}}},d.parseTags=v,d.matchTags=_,d.compareTags=x,d.parseTuple=b,d.matchTuple=m,d.compareTuples=w,Cd}()),Kf;var e}function Dd(){return Pd||(Pd=1,function(e){try{e.exports=Fd()("/Users/pablofernandez/src/pablo/nostri.chat/node_modules/bufferutil")}catch(t){e.exports=(Id||(Id=1,Ld={mask:(e,t,n,r,o)=>{for(var i=0;i{const n=e.length;for(var r=0;r{this.pending--,this[t]()},this.concurrency=n||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[t]()}[t](){if(this.pending!==this.concurrency&&this.jobs.length){const t=this.jobs.shift();this.pending++,t(this[e])}}}}(),{kStatusCode:r}=Hf(),o=us[Symbol.species],i=us.from([0,0,255,255]),s=Symbol("permessage-deflate"),a=Symbol("total-length"),c=Symbol("callback"),u=Symbol("buffers"),l=Symbol("error");let h;function f(e){this[u].push(e),this[a]+=e.length}function d(e){this[a]+=e.length,this[s]._maxPayload<1||this[a]<=this[s]._maxPayload?this[u].push(e):(this[l]=new RangeError("Max payload size exceeded"),this[l].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[l][r]=1009,this.removeListener("data",d),this.reset())}function p(e){this[s]._inflate=null,e[r]=1007,this[c](e)}return Nd=class{constructor(e,t,r){if(this._maxPayload=0|r,this._options=e||{},this._threshold=void 0!==this._options.threshold?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!h){const e=void 0!==this._options.concurrencyLimit?this._options.concurrencyLimit:10;h=new n(e)}}static get extensionName(){return"permessage-deflate"}offer(){const e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:null==this._options.clientMaxWindowBits&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){const e=this._deflate[c];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){const t=this._options,n=e.find((e=>!(!1===t.serverNoContextTakeover&&e.server_no_context_takeover||e.server_max_window_bits&&(!1===t.serverMaxWindowBits||"number"==typeof t.serverMaxWindowBits&&t.serverMaxWindowBits>e.server_max_window_bits)||"number"==typeof t.clientMaxWindowBits&&!e.client_max_window_bits)));if(!n)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(n.server_no_context_takeover=!0),t.clientNoContextTakeover&&(n.client_no_context_takeover=!0),"number"==typeof t.serverMaxWindowBits&&(n.server_max_window_bits=t.serverMaxWindowBits),"number"==typeof t.clientMaxWindowBits?n.client_max_window_bits=t.clientMaxWindowBits:!0!==n.client_max_window_bits&&!1!==t.clientMaxWindowBits||delete n.client_max_window_bits,n}acceptAsClient(e){const t=e[0];if(!1===this._options.clientNoContextTakeover&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(t.client_max_window_bits){if(!1===this._options.clientMaxWindowBits||"number"==typeof this._options.clientMaxWindowBits&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"')}else"number"==typeof this._options.clientMaxWindowBits&&(t.client_max_window_bits=this._options.clientMaxWindowBits);return t}normalizeParams(e){return e.forEach((e=>{Object.keys(e).forEach((t=>{let n=e[t];if(n.length>1)throw new Error(`Parameter "${t}" must have only a single value`);if(n=n[0],"client_max_window_bits"===t){if(!0!==n){const e=+n;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${n}`);n=e}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${t}": ${n}`)}else if("server_max_window_bits"===t){const e=+n;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${n}`);n=e}else{if("client_no_context_takeover"!==t&&"server_no_context_takeover"!==t)throw new Error(`Unknown parameter "${t}"`);if(!0!==n)throw new TypeError(`Invalid value for parameter "${t}": ${n}`)}e[t]=n}))})),e}decompress(e,t,n){h.add((r=>{this._decompress(e,t,((e,t)=>{r(),n(e,t)}))}))}compress(e,t,n){h.add((r=>{this._compress(e,t,((e,t)=>{r(),n(e,t)}))}))}_decompress(n,r,o){const h=this._isServer?"client":"server";if(!this._inflate){const t=`${h}_max_window_bits`,n="number"!=typeof this.params[t]?e.Z_DEFAULT_WINDOWBITS:this.params[t];this._inflate=e.createInflateRaw({...this._options.zlibInflateOptions,windowBits:n}),this._inflate[s]=this,this._inflate[a]=0,this._inflate[u]=[],this._inflate.on("error",p),this._inflate.on("data",d)}this._inflate[c]=o,this._inflate.write(n),r&&this._inflate.write(i),this._inflate.flush((()=>{const e=this._inflate[l];if(e)return this._inflate.close(),this._inflate=null,void o(e);const n=t.concat(this._inflate[u],this._inflate[a]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[a]=0,this._inflate[u]=[],r&&this.params[`${h}_no_context_takeover`]&&this._inflate.reset()),o(null,n)}))}_compress(n,r,i){const s=this._isServer?"server":"client";if(!this._deflate){const t=`${s}_max_window_bits`,n="number"!=typeof this.params[t]?e.Z_DEFAULT_WINDOWBITS:this.params[t];this._deflate=e.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:n}),this._deflate[a]=0,this._deflate[u]=[],this._deflate.on("data",f)}this._deflate[c]=i,this._deflate.write(n),this._deflate.flush(e.Z_SYNC_FLUSH,(()=>{if(!this._deflate)return;let e=t.concat(this._deflate[u],this._deflate[a]);r&&(e=new o(e.buffer,e.byteOffset,e.length-4)),this._deflate[c]=null,this._deflate[a]=0,this._deflate[u]=[],r&&this.params[`${s}_no_context_takeover`]&&this._deflate.reset(),i(null,e)}))}},Nd}var Wd,Kd,Gd,Zd,Vd,Yd,Xd,Jd,Qd,ep,tp,np,rp,op,ip,sp,ap,cp,up,lp,hp,fp,dp={},pp={get exports(){return dp},set exports(e){dp=e}},yp=In(Zs),gp={},bp={get exports(){return gp},set exports(e){gp=e}};function mp(){return Gd||(Gd=1,function(e){try{e.exports=Fd()("/Users/pablofernandez/src/pablo/nostri.chat/node_modules/utf-8-validate")}catch(t){e.exports=Kd?Wd:(Kd=1,Wd=function(e){const t=e.length;let n=0;for(;n=t||128!=(192&e[n+1])||128!=(192&e[n+2])||224===e[n]&&128==(224&e[n+1])||237===e[n]&&160==(224&e[n+1]))return!1;n+=3}else{if(240!=(248&e[n]))return!1;if(n+3>=t||128!=(192&e[n+1])||128!=(192&e[n+2])||128!=(192&e[n+3])||240===e[n]&&128==(240&e[n+1])||244===e[n]&&e[n+1]>143||e[n]>244)return!1;n+=4}return!0})}}(bp)),gp}function wp(){if(Zd)return dp;Zd=1;const{isUtf8:e}=yp;function t(e){const t=e.length;let n=0;for(;n=t||128!=(192&e[n+1])||128!=(192&e[n+2])||224===e[n]&&128==(224&e[n+1])||237===e[n]&&160==(224&e[n+1]))return!1;n+=3}else{if(240!=(248&e[n]))return!1;if(n+3>=t||128!=(192&e[n+1])||128!=(192&e[n+2])||128!=(192&e[n+3])||240===e[n]&&128==(240&e[n+1])||244===e[n]&&e[n+1]>143||e[n]>244)return!1;n+=4}return!0}if(pp.exports={isValidStatusCode:function(e){return e>=1e3&&e<=1014&&1004!==e&&1005!==e&&1006!==e||e>=3e3&&e<=4999},isValidUTF8:t,tokenChars:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0]},e)dp.isValidUTF8=function(n){return n.length<24?t(n):e(n)};else if(!wa.env.WS_NO_UTF_8_VALIDATE)try{const e=mp();dp.isValidUTF8=function(n){return n.length<32?t(n):e(n)}}catch(e){}return dp}function vp(){if(Yd)return Vd;Yd=1;const{Writable:e}=yl,t=qd(),{BINARY_TYPES:n,EMPTY_BUFFER:r,kStatusCode:o,kWebSocket:i}=Hf(),{concat:s,toArrayBuffer:a,unmask:c}=Hd(),{isValidStatusCode:u,isValidUTF8:l}=wp(),h=us[Symbol.species];function f(e,t,n,r,i){const s=new e(n?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(s,f),s.code=i,s[o]=r,s}return Vd=class extends e{constructor(e={}){super(),this._binaryType=e.binaryType||n[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=0|e.maxPayload,this._skipUTF8Validation=!!e.skipUTF8Validation,this[i]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._state=0,this._loop=!1}_write(e,t,n){if(8===this._opcode&&0==this._state)return n();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(n)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e=n.length?t.set(this._buffers.shift(),r):(t.set(new Uint8Array(n.buffer,n.byteOffset,e),r),this._buffers[0]=new h(n.buffer,n.byteOffset+e,n.length-e)),e-=n.length}while(e>0);return t}startLoop(e){let t;this._loop=!0;do{switch(this._state){case 0:t=this.getInfo();break;case 1:t=this.getPayloadLength16();break;case 2:t=this.getPayloadLength64();break;case 3:this.getMask();break;case 4:t=this.getData(e);break;default:return void(this._loop=!1)}}while(this._loop);e(t)}getInfo(){if(this._bufferedBytes<2)return void(this._loop=!1);const e=this.consume(2);if(0!=(48&e[0]))return this._loop=!1,f(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");const n=64==(64&e[0]);if(n&&!this._extensions[t.extensionName])return this._loop=!1,f(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._fin=128==(128&e[0]),this._opcode=15&e[0],this._payloadLength=127&e[1],0===this._opcode){if(n)return this._loop=!1,f(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(!this._fragmented)return this._loop=!1,f(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");this._opcode=this._fragmented}else if(1===this._opcode||2===this._opcode){if(this._fragmented)return this._loop=!1,f(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");this._compressed=n}else{if(!(this._opcode>7&&this._opcode<11))return this._loop=!1,f(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");if(!this._fin)return this._loop=!1,f(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");if(n)return this._loop=!1,f(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._payloadLength>125||8===this._opcode&&1===this._payloadLength)return this._loop=!1,f(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH")}if(this._fin||this._fragmented||(this._fragmented=this._opcode),this._masked=128==(128&e[1]),this._isServer){if(!this._masked)return this._loop=!1,f(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK")}else if(this._masked)return this._loop=!1,f(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");if(126===this._payloadLength)this._state=1;else{if(127!==this._payloadLength)return this.haveLength();this._state=2}}getPayloadLength16(){if(!(this._bufferedBytes<2))return this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength();this._loop=!1}getPayloadLength64(){if(this._bufferedBytes<8)return void(this._loop=!1);const e=this.consume(8),t=e.readUInt32BE(0);return t>Math.pow(2,21)-1?(this._loop=!1,f(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH")):(this._payloadLength=t*Math.pow(2,32)+e.readUInt32BE(4),this.haveLength())}haveLength(){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0))return this._loop=!1,f(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");this._masked?this._state=3:this._state=4}getMask(){this._bufferedBytes<4?this._loop=!1:(this._mask=this.consume(4),this._state=4)}getData(e){let t=r;if(this._payloadLength){if(this._bufferedBytes7?this.controlMessage(t):this._compressed?(this._state=5,void this.decompress(t,e)):(t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage())}decompress(e,n){this._extensions[t.extensionName].decompress(e,this._fin,((e,t)=>{if(e)return n(e);if(t.length){if(this._messageLength+=t.length,this._messageLength>this._maxPayload&&this._maxPayload>0)return n(f(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));this._fragments.push(t)}const r=this.dataMessage();if(r)return n(r);this.startLoop(n)}))}dataMessage(){if(this._fin){const e=this._messageLength,t=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],2===this._opcode){let n;n="nodebuffer"===this._binaryType?s(t,e):"arraybuffer"===this._binaryType?a(s(t,e)):t,this.emit("message",n,!0)}else{const n=s(t,e);if(!this._skipUTF8Validation&&!l(n))return this._loop=!1,f(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("message",n,!1)}}this._state=0}controlMessage(e){if(8===this._opcode)if(this._loop=!1,0===e.length)this.emit("conclude",1005,r),this.end();else{const t=e.readUInt16BE(0);if(!u(t))return f(RangeError,`invalid status code ${t}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");const n=new h(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!l(n))return f(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("conclude",t,n),this.end()}else 9===this._opcode?this.emit("ping",e):this.emit("pong",e);this._state=0}},Vd}function _p(){if(Jd)return Xd;Jd=1;const{randomFillSync:e}=pl,t=qd(),{EMPTY_BUFFER:n}=Hf(),{isValidStatusCode:r}=wp(),{mask:o,toBuffer:i}=Hd(),s=Symbol("kByteLength"),a=us.alloc(4);class c{constructor(e,t,n){this._extensions=t||{},n&&(this._generateMask=n,this._maskBuffer=us.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._deflating=!1,this._queue=[]}static frame(t,n){let r,i,c=!1,u=2,l=!1;n.mask&&(r=n.maskBuffer||a,n.generateMask?n.generateMask(r):e(r,0,4),l=0==(r[0]|r[1]|r[2]|r[3]),u=6),"string"==typeof t?i=n.mask&&!l||void 0===n[s]?(t=us.from(t)).length:n[s]:(i=t.length,c=n.mask&&n.readOnly&&!l);let h=i;i>=65536?(u+=8,h=127):i>125&&(u+=2,h=126);const f=us.allocUnsafe(c?i+u:u);return f[0]=n.fin?128|n.opcode:n.opcode,n.rsv1&&(f[0]|=64),f[1]=h,126===h?f.writeUInt16BE(i,2):127===h&&(f[2]=f[3]=0,f.writeUIntBE(i,4,6)),n.mask?(f[1]|=128,f[u-4]=r[0],f[u-3]=r[1],f[u-2]=r[2],f[u-1]=r[3],l?[f,t]:c?(o(t,r,f,u,i),[f]):(o(t,r,t,0,i),[f,t])):[f,t]}close(e,t,o,i){let a;if(void 0===e)a=n;else{if("number"!=typeof e||!r(e))throw new TypeError("First argument must be a valid error code number");if(void 0!==t&&t.length){const n=us.byteLength(t);if(n>123)throw new RangeError("The message must not be greater than 123 bytes");a=us.allocUnsafe(2+n),a.writeUInt16BE(e,0),"string"==typeof t?a.write(t,2):a.set(t,2)}else a=us.allocUnsafe(2),a.writeUInt16BE(e,0)}const u={[s]:a.length,fin:!0,generateMask:this._generateMask,mask:o,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._deflating?this.enqueue([this.dispatch,a,!1,u,i]):this.sendFrame(c.frame(a,u),i)}ping(e,t,n){let r,o;if("string"==typeof e?(r=us.byteLength(e),o=!1):(r=(e=i(e)).length,o=i.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");const a={[s]:r,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:o,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,a,n]):this.sendFrame(c.frame(e,a),n)}pong(e,t,n){let r,o;if("string"==typeof e?(r=us.byteLength(e),o=!1):(r=(e=i(e)).length,o=i.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");const a={[s]:r,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:o,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,a,n]):this.sendFrame(c.frame(e,a),n)}send(e,n,r){const o=this._extensions[t.extensionName];let a,u,l=n.binary?2:1,h=n.compress;if("string"==typeof e?(a=us.byteLength(e),u=!1):(a=(e=i(e)).length,u=i.readOnly),this._firstFragment?(this._firstFragment=!1,h&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(h=a>=o._threshold),this._compress=h):(h=!1,l=0),n.fin&&(this._firstFragment=!0),o){const t={[s]:a,fin:n.fin,generateMask:this._generateMask,mask:n.mask,maskBuffer:this._maskBuffer,opcode:l,readOnly:u,rsv1:h};this._deflating?this.enqueue([this.dispatch,e,this._compress,t,r]):this.dispatch(e,this._compress,t,r)}else this.sendFrame(c.frame(e,{[s]:a,fin:n.fin,generateMask:this._generateMask,mask:n.mask,maskBuffer:this._maskBuffer,opcode:l,readOnly:u,rsv1:!1}),r)}dispatch(e,n,r,o){if(!n)return void this.sendFrame(c.frame(e,r),o);const i=this._extensions[t.extensionName];this._bufferedBytes+=r[s],this._deflating=!0,i.compress(e,r.fin,((e,t)=>{if(this._socket.destroyed){const e=new Error("The socket was closed while data was being compressed");"function"==typeof o&&o(e);for(let t=0;t{let n=e[t];return Array.isArray(n)||(n=[n]),n.map((e=>[t].concat(Object.keys(e).map((t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map((e=>!0===e?t:`${t}=${e}`)).join("; ")}))).join("; "))).join(", ")})).join(", ")},parse:function(n){const r=Object.create(null);let o,i,s=Object.create(null),a=!1,c=!1,u=!1,l=-1,h=-1,f=-1,d=0;for(;d0&&e.unshift(t),e.on("close",H),e.on("data",q),e.on("end",W),e.on("error",K),this._readyState=C.OPEN,this.emit("open")}emitClose(){if(!this._socket)return this._readyState=C.CLOSED,void this.emit("close",this._closeCode,this._closeMessage);this._extensions[c.extensionName]&&this._extensions[c.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=C.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==C.CLOSED)if(this.readyState!==C.CONNECTING)this.readyState!==C.CLOSING?(this._readyState=C.CLOSING,this._sender.close(e,t,!this._isServer,(e=>{e||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())})),this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),3e4)):this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();else{const e="WebSocket was closed before the connection was established";P(this,this._req,e)}}pause(){this.readyState!==C.CONNECTING&&this.readyState!==C.CLOSED&&(this._paused=!0,this._socket.pause())}ping(e,t,n){if(this.readyState===C.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(n=e,e=t=void 0):"function"==typeof t&&(n=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===C.OPEN?(void 0===t&&(t=!this._isServer),this._sender.ping(e||f,t,n)):j(this,e,n)}pong(e,t,n){if(this.readyState===C.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(n=e,e=t=void 0):"function"==typeof t&&(n=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===C.OPEN?(void 0===t&&(t=!this._isServer),this._sender.pong(e||f,t,n)):j(this,e,n)}resume(){this.readyState!==C.CONNECTING&&this.readyState!==C.CLOSED&&(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,n){if(this.readyState===C.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if("function"==typeof t&&(n=t,t={}),"number"==typeof e&&(e=e.toString()),this.readyState!==C.OPEN)return void j(this,e,n);const r={binary:"string"!=typeof e,mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[c.extensionName]||(r.compress=!1),this._sender.send(e||f,r,n)}terminate(){if(this.readyState!==C.CLOSED)if(this.readyState!==C.CONNECTING)this._socket&&(this._readyState=C.CLOSING,this._socket.destroy());else{const e="WebSocket was closed before the connection was established";P(this,this._req,e)}}}function R(e,r,o,u){const l={protocolVersion:S[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...u,createConnection:void 0,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(!S.includes(l.protocolVersion))throw new RangeError(`Unsupported protocol version: ${l.protocolVersion} (supported versions: ${S.join(", ")})`);let h;if(r instanceof a)h=r,e._url=r.href;else{try{h=new a(r)}catch(e){throw new SyntaxError(`Invalid URL: ${r}`)}e._url=r}const f="wss:"===h.protocol,p="ws+unix:"===h.protocol;let y;if("ws:"===h.protocol||f||p?p&&!h.pathname?y="The URL's pathname is empty":h.hash&&(y="The URL contains a fragment identifier"):y='The URL\'s protocol must be one of "ws:", "wss:", or "ws+unix:"',y){const t=new SyntaxError(y);if(0===e._redirects)throw t;return void T(e,t)}const g=f?443:80,b=i(16).toString("base64"),m=f?t.request:n.request,w=new Set;let v,E;if(l.createConnection=f?I:L,l.defaultPort=l.defaultPort||g,l.port=h.port||g,l.host=h.hostname.startsWith("[")?h.hostname.slice(1,-1):h.hostname,l.headers={...l.headers,"Sec-WebSocket-Version":l.protocolVersion,"Sec-WebSocket-Key":b,Connection:"Upgrade",Upgrade:"websocket"},l.path=h.pathname+h.search,l.timeout=l.handshakeTimeout,l.perMessageDeflate&&(v=new c(!0!==l.perMessageDeflate?l.perMessageDeflate:{},!1,l.maxPayload),l.headers["Sec-WebSocket-Extensions"]=_({[c.extensionName]:v.offer()})),o.length){for(const e of o){if("string"!=typeof e||!A.test(e)||w.has(e))throw new SyntaxError("An invalid or duplicated subprotocol was specified");w.add(e)}l.headers["Sec-WebSocket-Protocol"]=o.join(",")}if(l.origin&&(l.protocolVersion<13?l.headers["Sec-WebSocket-Origin"]=l.origin:l.headers.Origin=l.origin),(h.username||h.password)&&(l.auth=`${h.username}:${h.password}`),p){const e=l.path.split(":");l.socketPath=e[0],l.path=e[1]}if(l.followRedirects){if(0===e._redirects){e._originalIpc=p,e._originalSecure=f,e._originalHostOrSocketPath=p?l.socketPath:h.host;const t=u&&u.headers;if(u={...u,headers:{}},t)for(const[e,n]of Object.entries(t))u.headers[e.toLowerCase()]=n}else if(0===e.listenerCount("redirect")){const t=p?!!e._originalIpc&&l.socketPath===e._originalHostOrSocketPath:!e._originalIpc&&h.host===e._originalHostOrSocketPath;(!t||e._originalSecure&&!f)&&(delete l.headers.authorization,delete l.headers.cookie,t||delete l.headers.host,l.auth=void 0)}l.auth&&!u.headers.authorization&&(u.headers.authorization="Basic "+us.from(l.auth).toString("base64")),E=e._req=m(l),e._redirects&&e.emit("redirect",e.url,E)}else E=e._req=m(l);l.timeout&&E.on("timeout",(()=>{P(e,E,"Opening handshake has timed out")})),E.on("error",(t=>{null===E||E[k]||(E=e._req=null,T(e,t))})),E.on("response",(t=>{const n=t.headers.location,i=t.statusCode;if(n&&l.followRedirects&&i>=300&&i<400){if(++e._redirects>l.maxRedirects)return void P(e,E,"Maximum redirects exceeded");let t;E.abort();try{t=new a(n,r)}catch(t){const r=new SyntaxError(`Invalid URL: ${n}`);return void T(e,r)}R(e,t,o,u)}else e.emit("unexpected-response",E,t)||P(e,E,`Unexpected server response: ${t.statusCode}`)})),E.on("upgrade",((t,n,r)=>{if(e.emit("upgrade",t),e.readyState!==C.CONNECTING)return;if(E=e._req=null,"websocket"!==t.headers.upgrade.toLowerCase())return void P(e,n,"Invalid Upgrade header");const o=s("sha1").update(b+d).digest("base64");if(t.headers["sec-websocket-accept"]!==o)return void P(e,n,"Invalid Sec-WebSocket-Accept header");const i=t.headers["sec-websocket-protocol"];let a;if(void 0!==i?w.size?w.has(i)||(a="Server sent an invalid subprotocol"):a="Server sent a subprotocol but none was requested":w.size&&(a="Server sent no subprotocol"),a)return void P(e,n,a);i&&(e._protocol=i);const u=t.headers["sec-websocket-extensions"];if(void 0!==u){if(!v){return void P(e,n,"Server sent a Sec-WebSocket-Extensions header but no extension was requested")}let t;try{t=x(u)}catch(t){return void P(e,n,"Invalid Sec-WebSocket-Extensions header")}const r=Object.keys(t);if(1!==r.length||r[0]!==c.extensionName){return void P(e,n,"Server indicated an extension that was not requested")}try{v.accept(t[c.extensionName])}catch(t){return void P(e,n,"Invalid Sec-WebSocket-Extensions header")}e._extensions[c.extensionName]=v}e.setSocket(n,r,{generateMask:l.generateMask,maxPayload:l.maxPayload,skipUTF8Validation:l.skipUTF8Validation})})),E.end()}function T(e,t){e._readyState=C.CLOSING,e.emit("error",t),e.emitClose()}function L(e){return e.path=e.socketPath,r.connect(e)}function I(e){return e.path=void 0,e.servername||""===e.servername||(e.servername=r.isIP(e.host)?"":e.host),o.connect(e)}function P(e,t,n){e._readyState=C.CLOSING;const r=new Error(n);Error.captureStackTrace(r,P),t.setHeader?(t[k]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),wa.nextTick(T,e,r)):(t.destroy(r),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function j(e,t,n){if(t){const n=E(t).length;e._socket?e._sender._bufferedBytes+=n:e._bufferedAmount+=n}if(n){const t=new Error(`WebSocket is not open: readyState ${e.readyState} (${O[e.readyState]})`);wa.nextTick(n,t)}}function U(e,t){const n=this[b];n._closeFrameReceived=!0,n._closeMessage=t,n._closeCode=e,void 0!==n._socket[b]&&(n._socket.removeListener("data",q),wa.nextTick(D,n._socket),1005===e?n.close():n.close(e,t))}function B(){const e=this[b];e.isPaused||e._socket.resume()}function N(e){const t=this[b];void 0!==t._socket[b]&&(t._socket.removeListener("data",q),wa.nextTick(D,t._socket),t.close(e[g])),t.emit("error",e)}function M(){this[b].emitClose()}function $(e,t){this[b].emit("message",e,t)}function z(e){const t=this[b];t.pong(e,!t._isServer,m),t.emit("ping",e)}function F(e){this[b].emit("pong",e)}function D(e){e.resume()}function H(){const e=this[b];let t;this.removeListener("close",H),this.removeListener("data",q),this.removeListener("end",W),e._readyState=C.CLOSING,this._readableState.endEmitted||e._closeFrameReceived||e._receiver._writableState.errorEmitted||null===(t=e._socket.read())||e._receiver.write(t),e._receiver.end(),this[b]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",M),e._receiver.on("finish",M))}function q(e){this[b]._receiver.write(e)||this.pause()}function W(){const e=this[b];e._readyState=C.CLOSING,e._receiver.end(),this.end()}function K(){const e=this[b];this.removeListener("error",K),this.on("error",m),e&&(e._readyState=C.CLOSING,this.destroy())}return Object.defineProperty(C,"CONNECTING",{enumerable:!0,value:O.indexOf("CONNECTING")}),Object.defineProperty(C.prototype,"CONNECTING",{enumerable:!0,value:O.indexOf("CONNECTING")}),Object.defineProperty(C,"OPEN",{enumerable:!0,value:O.indexOf("OPEN")}),Object.defineProperty(C.prototype,"OPEN",{enumerable:!0,value:O.indexOf("OPEN")}),Object.defineProperty(C,"CLOSING",{enumerable:!0,value:O.indexOf("CLOSING")}),Object.defineProperty(C.prototype,"CLOSING",{enumerable:!0,value:O.indexOf("CLOSING")}),Object.defineProperty(C,"CLOSED",{enumerable:!0,value:O.indexOf("CLOSED")}),Object.defineProperty(C.prototype,"CLOSED",{enumerable:!0,value:O.indexOf("CLOSED")}),["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach((e=>{Object.defineProperty(C.prototype,e,{enumerable:!0})})),["open","error","close","message"].forEach((e=>{Object.defineProperty(C.prototype,`on${e}`,{enumerable:!0,get(){for(const t of this.listeners(e))if(t[p])return t[y];return null},set(t){for(const t of this.listeners(e))if(t[p]){this.removeListener(e,t);break}"function"==typeof t&&this.addEventListener(e,t,{[p]:!0})}})})),C.prototype.addEventListener=w,C.prototype.removeEventListener=v,rp=C}function kp(){if(cp)return ap;cp=1;const{tokenChars:e}=wp();return ap={parse:function(t){const n=new Set;let r=-1,o=-1,i=0;for(;i`${e}: ${o[e]}`)).join("\r\n")+"\r\n\r\n"+r)}function d(e,t,n,r,o){if(e.listenerCount("wsClientError")){const r=new Error(o);Error.captureStackTrace(r,d),e.emit("wsClientError",r,n,t)}else f(n,r,o)}return up=class extends e{constructor(e,n){if(super(),null==(e={maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:s,...e}).port&&!e.server&&!e.noServer||null!=e.port&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(null!=e.port?(this._server=t.createServer(((e,n)=>{const r=t.STATUS_CODES[426];n.writeHead(426,{"Content-Length":r.length,"Content-Type":"text/plain"}),n.end(r)})),this._server.listen(e.port,e.host,e.backlog,n)):e.server&&(this._server=e.server),this._server){const e=this.emit.bind(this,"connection");this._removeListeners=function(e,t){for(const n of Object.keys(t))e.on(n,t[n]);return function(){for(const n of Object.keys(t))e.removeListener(n,t[n])}}(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(t,n,r)=>{this.handleUpgrade(t,n,r,e)}})}!0===e.perMessageDeflate&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=0}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(2===this._state)return e&&this.once("close",(()=>{e(new Error("The server is not running"))})),void wa.nextTick(l,this);if(e&&this.once("close",e),1!==this._state)if(this._state=1,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients&&this.clients.size?this._shouldEmitClose=!0:wa.nextTick(l,this);else{const e=this._server;this._removeListeners(),this._removeListeners=this._server=null,e.close((()=>{l(this)}))}}shouldHandle(e){if(this.options.path){const t=e.url.indexOf("?");if((-1!==t?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,n,s){t.on("error",h);const a=e.headers["sec-websocket-key"],c=+e.headers["sec-websocket-version"];if("GET"!==e.method){return void d(this,e,t,405,"Invalid HTTP method")}if("websocket"!==e.headers.upgrade.toLowerCase()){return void d(this,e,t,400,"Invalid Upgrade header")}if(!a||!u.test(a)){return void d(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header")}if(8!==c&&13!==c){return void d(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header")}if(!this.shouldHandle(e))return void f(t,400);const l=e.headers["sec-websocket-protocol"];let p=new Set;if(void 0!==l)try{p=i.parse(l)}catch(n){return void d(this,e,t,400,"Invalid Sec-WebSocket-Protocol header")}const y=e.headers["sec-websocket-extensions"],g={};if(this.options.perMessageDeflate&&void 0!==y){const n=new o(this.options.perMessageDeflate,!0,this.options.maxPayload);try{const e=r.parse(y);e[o.extensionName]&&(n.accept(e[o.extensionName]),g[o.extensionName]=n)}catch(n){return void d(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header")}}if(this.options.verifyClient){const r={origin:e.headers[""+(8===c?"sec-websocket-origin":"origin")],secure:!(!e.socket.authorized&&!e.socket.encrypted),req:e};if(2===this.options.verifyClient.length)return void this.options.verifyClient(r,((r,o,i,c)=>{if(!r)return f(t,o||401,i,c);this.completeUpgrade(g,a,p,e,t,n,s)}));if(!this.options.verifyClient(r))return f(t,401)}this.completeUpgrade(g,a,p,e,t,n,s)}completeUpgrade(e,t,i,s,u,d,p){if(!u.readable||!u.writable)return u.destroy();if(u[c])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return f(u,503);const y=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${n("sha1").update(t+a).digest("base64")}`],g=new this.options.WebSocket(null);if(i.size){const e=this.options.handleProtocols?this.options.handleProtocols(i,s):i.values().next().value;e&&(y.push(`Sec-WebSocket-Protocol: ${e}`),g._protocol=e)}if(e[o.extensionName]){const t=e[o.extensionName].params,n=r.format({[o.extensionName]:[t]});y.push(`Sec-WebSocket-Extensions: ${n}`),g._extensions=e}this.emit("headers",y,s),u.write(y.concat("\r\n").join("\r\n")),u.removeListener("error",h),g.setSocket(u,d,{maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(g),g.on("close",(()=>{this.clients.delete(g),this._shouldEmitClose&&!this.clients.size&&wa.nextTick(l,this)}))),p(g,s)}},up}const Op="undefined"!=typeof WebSocket?WebSocket:function(){if(fp)return hp;fp=1;const e=Ep();return e.createWebSocketStream=function(){if(sp)return ip;sp=1;const{Duplex:e}=yl;function t(e){e.emit("close")}function n(){!this.destroyed&&this._writableState.finished&&this.destroy()}function r(e){this.removeListener("error",r),this.destroy(),0===this.listenerCount("error")&&this.emit("error",e)}return ip=function(o,i){let s=!0;const a=new e({...i,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return o.on("message",(function(e,t){const n=!t&&a._readableState.objectMode?e.toString():e;a.push(n)||o.pause()})),o.once("error",(function(e){a.destroyed||(s=!1,a.destroy(e))})),o.once("close",(function(){a.destroyed||a.push(null)})),a._destroy=function(e,n){if(o.readyState===o.CLOSED)return n(e),void wa.nextTick(t,a);let r=!1;o.once("error",(function(e){r=!0,n(e)})),o.once("close",(function(){r||n(e),wa.nextTick(t,a)})),s&&o.terminate()},a._final=function(e){o.readyState!==o.CONNECTING?null!==o._socket&&(o._socket._writableState.finished?(e(),a._readableState.endEmitted&&a.destroy()):(o._socket.once("finish",(function(){e()})),o.close())):o.once("open",(function(){a._final(e)}))},a._read=function(){o.isPaused&&o.resume()},a._write=function(e,t,n){o.readyState!==o.CONNECTING?o.send(e,n):o.once("open",(function(){a._write(e,t,n)}))},a.on("end",n),a.on("error",r),a},ip}(),e.Server=Sp(),e.Receiver=vp(),e.Sender=_p(),e.WebSocket=e,e.WebSocketServer=e.Server,hp=e}();function Ap(e,t={}){if(!(this instanceof Ap))return new Ap(e,t);this.url=e,this.opts=t,null==t.reconnect&&(t.reconnect=!0);const n=this;return n.onfn={},Cp(n).catch((e=>{n.onfn.error&&n.onfn.error(e)})),this}function Cp(e){return new Promise(((t,n)=>{const r=e.ws=new Op(e.url);let o=!1;r.onmessage=t=>{!function(e,t){let n;try{n=JSON.parse(t.data)}catch(e){return void console.error("handle_nostr_message",e)}if(n.length>=2)switch(n[0]){case"EVENT":if(n.length<3)return;return e.onfn.event&&e.onfn.event(n[1],n[2]);case"EOSE":return e.onfn.eose&&e.onfn.eose(n[1]);case"NOTICE":return e.onfn.notice&&e.onfn.notice(...n.slice(1));case"OK":e.onfn.ok&&e.onfn.ok(...n.slice(1))}}(e,t),e.onfn.message&&e.onfn.message(t)},r.onclose=t=>{if(e.onfn.close&&e.onfn.close(t),e.reconnecting)return n(new Error("close during reconnect"));!e.manualClose&&e.opts.reconnect&&Tp(e)},r.onerror=t=>{if(e.onfn.error&&e.onfn.error(t),e.reconnecting)return n(new Error("error during reconnect"));e.opts.reconnect&&Tp(e)},r.onopen=n=>{e.onfn.open&&e.onfn.open(n),o||(o=!0,t(e))}}))}function Rp(e){return new Promise((t=>setTimeout(t,e)))}async function Tp(e){let t=100;try{e.reconnecting=!0,await Cp(e),e.reconnecting=!1}catch{await Rp(t),t*=1.5}}Ap.prototype.wait_connected=async function(e){let t=1e3;for(;;){if(1===this.ws.readyState)return;await Rp(t),t*=1.5}},Ap.prototype.on=function(e,t){return this.onfn[e]=t,this},Ap.prototype.close=function(){this.ws&&(this.manualClose=!0,this.ws.close())},Ap.prototype.subscribe=function(e,t){Array.isArray(t)?this.send(["REQ",e,...t]):this.send(["REQ",e,t])},Ap.prototype.unsubscribe=function(e){this.send(["CLOSE",e])},Ap.prototype.send=async function(e){await this.wait_connected(),this.ws.send(JSON.stringify(e))};const Lp=Ap;function Ip(e,t){if(!(this instanceof Ip))return new Ip(e,t);this.onfn={},this.relays=[],this.opts=t;for(const t of e)this.add(t);return this}Ip.prototype.close=function(){for(const e of this.relays)e.close()},Ip.prototype.on=function(e,t){for(const n of this.relays)this.onfn[e]=t,n.onfn[e]=t.bind(null,n);return this},Ip.prototype.has=function(e){for(const t of this.relays)if(t.url===e)return!0;return!1},Ip.prototype.send=function(e,t){const n=t?this.find_relays(t):this.relays;for(const t of n)t.send(e)},Ip.prototype.setupHandlers=function(){const e=Object.keys(this.onfn);for(const t of e)for(const e of this.relays)e.onfn[t]=this.onfn[t].bind(null,e)},Ip.prototype.remove=function(e){let t=0;for(const n of this.relays){if(n.url===e)return n.ws&&n.ws.close(),this.relays=this.replays.splice(t,1),!0;t+=1}return!1},Ip.prototype.subscribe=function(e,t,n){const r=n?this.find_relays(n):this.relays;for(const n of r)n.subscribe(e,t)},Ip.prototype.unsubscribe=function(e,t){const n=t?this.find_relays(t):this.relays;for(const t of n)t.unsubscribe(e)},Ip.prototype.add=function(e){if(e instanceof Lp)return!this.has(e.url)&&(this.relays.push(e),this.setupHandlers(),!0);if(this.has(e))return!1;const t=Lp(e,this.opts);return this.relays.push(t),this.setupHandlers(),!0},Ip.prototype.find_relays=function(e){if(e instanceof Lp)return[e];if(0===e.length)return[];if(!e[0])throw new Error("what!?");return e[0]instanceof Lp?e:this.relays.reduce(((t,n)=>(e.some((e=>n.url===e))&&t.push(n),t)),[])};var Pp=Ip;let jp;const Up=new Uint8Array(16);function Bp(){if(!jp&&(jp="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!jp))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return jp(Up)}const Np=[];for(let e=0;e<256;++e)Np.push((e+256).toString(16).slice(1));var Mp={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function $p(e,t,n){if(Mp.randomUUID&&!t&&!e)return Mp.randomUUID();const r=(e=e||{}).random||(e.rng||Bp)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=r[e];return t}return function(e,t=0){return(Np[e[t+0]]+Np[e[t+1]]+Np[e[t+2]]+Np[e[t+3]]+"-"+Np[e[t+4]]+Np[e[t+5]]+"-"+Np[e[t+6]]+Np[e[t+7]]+"-"+Np[e[t+8]]+Np[e[t+9]]+"-"+Np[e[t+10]]+Np[e[t+11]]+Np[e[t+12]]+Np[e[t+13]]+Np[e[t+14]]+Np[e[t+15]]).toLowerCase()}(r)}var zp,Fp,Dp={},Hp={get exports(){return Dp},set exports(e){Dp=e}};function qp(){if(Fp)return zp;Fp=1;var e=1e3,t=60*e,n=60*t,r=24*n,o=7*r,i=365.25*r;function s(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}return zp=function(a,c){c=c||{};var u=typeof a;if("string"===u&&a.length>0)return function(s){if((s=String(s)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(s);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*i;case"weeks":case"week":case"w":return c*o;case"days":case"day":case"d":return c*r;case"hours":case"hour":case"hrs":case"hr":case"h":return c*n;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(a);if("number"===u&&isFinite(a))return c.long?function(o){var i=Math.abs(o);if(i>=r)return s(o,i,r,"day");if(i>=n)return s(o,i,n,"hour");if(i>=t)return s(o,i,t,"minute");if(i>=e)return s(o,i,e,"second");return o+" ms"}(a):function(o){var i=Math.abs(o);if(i>=r)return Math.round(o/r)+"d";if(i>=n)return Math.round(o/n)+"h";if(i>=t)return Math.round(o/t)+"m";if(i>=e)return Math.round(o/e)+"s";return o+"ms"}(a);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a))},zp}var Wp=function(e){function t(e){let r,o,i,s=null;function a(...e){if(!a.enabled)return;const n=a,o=Number(new Date),i=o-(r||o);n.diff=i,n.prev=r,n.curr=o,r=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((r,o)=>{if("%%"===r)return"%";s++;const i=t.formatters[o];if("function"==typeof i){const t=e[s];r=i.call(n,t),e.splice(s,1),s--}return r})),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(o!==t.namespaces&&(o=t.namespaces,i=t.enabled(e)),i),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(r),...t.skips.map(r).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t{"%%"!==e&&(r++,"%c"===e&&(o=r))})),t.splice(o,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&void 0!==wa&&"env"in wa&&(e=wa.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=Wp(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(Hp,Dp);var Kp={},Gp={get exports(){return Kp},set exports(e){Kp=e}};!function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function i(e,t,r,i,s){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new o(r,i||e,s),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function a(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),a.prototype.eventNames=function(){var e,r,o=[];if(0===this._eventsCount)return o;for(r in e=this._events)t.call(e,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},a.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,s=new Array(i);o=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(hy,"__esModule",{value:!0}),hy.Container=void 0;var t=function(){if(iy)return fy;iy=1,Object.defineProperty(fy,"__esModule",{value:!0}),fy.ForOfAdaptor=void 0;var e=function(){function e(e,t){this.it_=e,this.last_=t}return e.prototype.next=function(){if(this.it_.equals(this.last_))return{done:!0,value:void 0};var e=this.it_;return this.it_=this.it_.next(),{done:!1,value:e.value}},e.prototype[Symbol.iterator]=function(){return this},e}();return fy.ForOfAdaptor=e,fy}(),n=function(){function n(){}return n.prototype.empty=function(){return 0===this.size()},n.prototype.rbegin=function(){return this.end().reverse()},n.prototype.rend=function(){return this.begin().reverse()},n.prototype[Symbol.iterator]=function(){return new t.ForOfAdaptor(this.begin(),this.end())},n.prototype.toJSON=function(){var t,n,r=[];try{for(var o=e(this),i=o.next();!i.done;i=o.next()){var s=i.value;r.push(s)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return r},n}();return hy.Container=n,hy}var py,yy,gy={};function by(){if(py)return gy;py=1;var e=Ln&&Ln.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s};Object.defineProperty(gy,"__esModule",{value:!0}),gy.NativeArrayIterator=void 0;var t=function(){function t(e,t){this.data_=e,this.index_=t}return t.prototype.index=function(){return this.index_},Object.defineProperty(t.prototype,"value",{get:function(){return this.data_[this.index_]},enumerable:!1,configurable:!0}),t.prototype.prev=function(){return--this.index_,this},t.prototype.next=function(){return++this.index_,this},t.prototype.advance=function(e){return this.index_+=e,this},t.prototype.equals=function(e){return this.data_===e.data_&&this.index_===e.index_},t.prototype.swap=function(t){var n,r;n=e([t.data_,this.data_],2),this.data_=n[0],t.data_=n[1],r=e([t.index_,this.index_],2),this.index_=r[0],t.index_=r[1]},t}();return gy.NativeArrayIterator=t,gy}var my,wy,vy,_y={},xy={},Ey={},ky={};function Sy(){if(wy)return Ey;wy=1;var e,t=Ln&&Ln.__extends||(e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)});Object.defineProperty(Ey,"__esModule",{value:!0}),Ey.LogicError=void 0;var n=function(){if(my)return ky;my=1;var e,t=Ln&&Ln.__extends||(e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)});Object.defineProperty(ky,"__esModule",{value:!0}),ky.Exception=void 0;var n=function(e){function n(t){var n=this.constructor,r=e.call(this,t)||this,o=n.prototype;return Object.setPrototypeOf?Object.setPrototypeOf(r,o):r.__proto__=o,r}return t(n,e),Object.defineProperty(n.prototype,"name",{get:function(){return this.constructor.name},enumerable:!1,configurable:!0}),n.prototype.what=function(){return this.message},n.prototype.toJSON=function(){return{name:this.name,message:this.message,stack:this.stack}},n}(Error);return ky.Exception=n,ky}(),r=function(e){function n(t){return e.call(this,t)||this}return t(n,e),n}(n.Exception);return Ey.LogicError=r,Ey}function Oy(){if(vy)return xy;vy=1;var e,t=Ln&&Ln.__extends||(e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)});Object.defineProperty(xy,"__esModule",{value:!0}),xy.InvalidArgument=void 0;var n=function(e){function n(t){return e.call(this,t)||this}return t(n,e),n}(Sy().LogicError);return xy.InvalidArgument=n,xy}var Ay,Cy,Ry,Ty={};function Ly(){return Cy||(Cy=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ErrorGenerator=void 0;var t=Oy(),n=function(){if(Ay)return Ty;Ay=1;var e,t=Ln&&Ln.__extends||(e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)});Object.defineProperty(Ty,"__esModule",{value:!0}),Ty.OutOfRange=void 0;var n=function(e){function n(t){return e.call(this,t)||this}return t(n,e),n}(Sy().LogicError);return Ty.OutOfRange=n,Ty}();!function(e){function r(e){if("string"==typeof e)return e;var t=e.constructor.name;return e.constructor.__MODULE&&(t="".concat(e.constructor.__MODULE,".").concat(t)),"std.".concat(t)}e.get_class_name=r,e.empty=function(e,t){return new n.OutOfRange("Error on ".concat(r(e),".").concat(t,"(): it's empty container."))},e.negative_index=function(e,t,o){return new n.OutOfRange("Error on ".concat(r(e),".").concat(t,"(): parametric index is negative -> (index = ").concat(o,")."))},e.excessive_index=function(e,t,o,i){return new n.OutOfRange("Error on ".concat(r(e),".").concat(t,"(): parametric index is equal or greater than size -> (index = ").concat(o,", size: ").concat(i,")."))},e.not_my_iterator=function(e,n){return new t.InvalidArgument("Error on ".concat(r(e),".").concat(n,"(): parametric iterator is not this container's own."))},e.erased_iterator=function(e,n){return new t.InvalidArgument("Error on ".concat(r(e),".").concat(n,"(): parametric iterator, it already has been erased."))},e.negative_iterator=function(e,t,o){return new n.OutOfRange("Error on ".concat(r(e),".").concat(t,"(): parametric iterator is directing negative position -> (index = ").concat(o,")."))},e.iterator_end_value=function(e,t){void 0===t&&(t="end");var o=r(e);return new n.OutOfRange("Error on ".concat(o,".Iterator.value: cannot access to the ").concat(o,".").concat(t,"().value."))},e.key_nout_found=function(e,t,o){throw new n.OutOfRange("Error on ".concat(r(e),".").concat(t,"(): unable to find the matched key -> ").concat(o))}}(e.ErrorGenerator||(e.ErrorGenerator={}))}(_y)),_y}function Iy(){if(Ry)return uy;Ry=1;var e,t=Ln&&Ln.__extends||(e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}),n=Ln&&Ln.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},r=Ln&&Ln.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty($y,"__esModule",{value:!0}),$y.hash=void 0;var t=Dy();function n(e,t){return t^=e?1:0,t*=s}function r(e,t){return o(e.toString(),t)}function o(e,t){for(var n=0;n0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},n=Ln&&Ln.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},n=Ln&&Ln.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o=1&&i[0]instanceof Array?(r=function(){var r=i[0];e.push.apply(e,n([],t(r),!1))},o=i.slice(1)):i.length>=2&&i[0].next instanceof Function&&i[1].next instanceof Function?(r=function(){var t=i[0],n=i[1];e.assign(t,n)},o=i.slice(2)):(r=null,o=i),{ramda:r,tail:o}}}(e.IAssociativeContainer||(e.IAssociativeContainer={}))),Uy;var e,t,n}(),o=Hy(),i=Gy();!function(e){e.construct=function(e,s,a){for(var c=[],u=3;u=1&&(h=p.tail[0]),p.tail.length>=2&&(f=p.tail[1])}a(h,f),null!==l&&l()}}(e.IHashContainer||(e.IHashContainer={}))}(jy)),jy}var Vy,Yy={},Xy={},Jy={};function Qy(){if(Vy)return Jy;Vy=1,Object.defineProperty(Jy,"__esModule",{value:!0}),Jy.ListIterator=void 0;var e=Ly(),t=function(){function t(e,t,n){this.prev_=e,this.next_=t,this.value_=n}return t._Set_prev=function(e,t){e.prev_=t},t._Set_next=function(e,t){e.next_=t},t.prototype.prev=function(){return this.prev_},t.prototype.next=function(){return this.next_},Object.defineProperty(t.prototype,"value",{get:function(){return this._Try_value(),this.value_},enumerable:!1,configurable:!0}),t.prototype._Try_value=function(){if(void 0===this.value_&&!0===this.equals(this.source().end()))throw e.ErrorGenerator.iterator_end_value(this.source())},t.prototype.equals=function(e){return this===e},t}();return Jy.ListIterator=t,Jy}var eg,tg={};var ng,rg,og={};function ig(){if(ng)return og;ng=1,Object.defineProperty(og,"__esModule",{value:!0}),og.next=og.prev=og.advance=og.distance=og.size=og.empty=void 0;var e=Oy();function t(t,n){if(0===n)return t;if(t.advance instanceof Function)return t.advance(n);var r;if(n<0){if(!(t.prev instanceof Function))throw new e.InvalidArgument("Error on std.advance(): parametric iterator is not a bi-directional iterator, thus advancing to negative direction is not possible.");r=function(e){return e.prev()},n=-n}else r=function(e){return e.next()};for(;n-- >0;)t=r(t);return t}return og.empty=function(e){return e instanceof Array?0!==e.length:e.empty()},og.size=function(e){return e instanceof Array?e.length:e.size()},og.distance=function(e,t){if(e.index instanceof Function)return function(e,t){var n=e.index(),r=t.index();return e.base instanceof Function?n-r:r-n}(e,t);for(var n=0;!e.equals(t);e=e.next())++n;return n},og.advance=t,og.prev=function(e,n){return void 0===n&&(n=1),1===n?e.prev():t(e,-n)},og.next=function(e,n){return void 0===n&&(n=1),1===n?e.next():t(e,n)},og}function sg(){if(rg)return Xy;rg=1;var e,t=Ln&&Ln.__extends||(e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}),n=Ln&&Ln.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s};Object.defineProperty(Xy,"__esModule",{value:!0}),Xy.ListContainer=void 0;var r=dy(),o=Qy(),i=function(){if(eg)return tg;eg=1,Object.defineProperty(tg,"__esModule",{value:!0}),tg.Repeater=void 0;var e=function(){function e(e,t){this.index_=e,this.value_=t}return e.prototype.index=function(){return this.index_},Object.defineProperty(e.prototype,"value",{get:function(){return this.value_},enumerable:!1,configurable:!0}),e.prototype.next=function(){return++this.index_,this},e.prototype.equals=function(e){return this.index_===e.index_},e}();return tg.Repeater=e,tg}(),s=by(),a=ig(),c=Ly(),u=function(e){function r(){var t=e.call(this)||this;return t.end_=t._Create_iterator(null,null),t.clear(),t}return t(r,e),r.prototype.assign=function(e,t){this.clear(),this.insert(this.end(),e,t)},r.prototype.clear=function(){o.ListIterator._Set_prev(this.end_,this.end_),o.ListIterator._Set_next(this.end_,this.end_),this.begin_=this.end_,this.size_=0},r.prototype.resize=function(e){var t=e-this.size();t>0?this.insert(this.end(),t,void 0):t<0&&this.erase((0,a.advance)(this.end(),-t),this.end())},r.prototype.begin=function(){return this.begin_},r.prototype.end=function(){return this.end_},r.prototype.size=function(){return this.size_},r.prototype.push_front=function(e){this.insert(this.begin_,e)},r.prototype.push_back=function(e){this.insert(this.end_,e)},r.prototype.pop_front=function(){if(!0===this.empty())throw c.ErrorGenerator.empty(this.end_.source().constructor.name,"pop_front");this.erase(this.begin_)},r.prototype.pop_back=function(){if(!0===this.empty())throw c.ErrorGenerator.empty(this.end_.source().constructor.name,"pop_back");this.erase(this.end_.prev())},r.prototype.push=function(){for(var e=[],t=0;t=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(pg,"__esModule",{value:!0}),pg.HashBuckets=void 0;var t=function(){function t(e,t){this.fetcher_=e,this.hasher_=t,this.max_load_factor_=r,this.data_=[],this.size_=0,this.initialize()}return t.prototype.clear=function(){this.data_=[],this.size_=0,this.initialize()},t.prototype.rehash=function(t){var r,o,i,s;t=Math.max(t,n);for(var a=[],c=0;cthis.capacity()&&(e=Math.floor(e/this.max_load_factor_),this.rehash(e))},t.prototype.initialize=function(){for(var e=0;et&&this.reserve(2*t);var n=this.index(e);this.data_[n].push(e)},t.prototype.erase=function(e){for(var t=this.index(e),n=this.data_[t],r=0;r0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},o=Ln&&Ln.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s};Object.defineProperty(e,"__esModule",{value:!0}),e.SetElementList=void 0;var o=sg(),i=Qy(),s=lg(),a=function(e){function t(t){var n=e.call(this)||this;return n.associative_=t,n}return n(t,e),t.prototype._Create_iterator=function(e,n,r){return t.Iterator.create(this,e,n,r)},t._Swap_associative=function(e,t){var n;n=r([t.associative_,e.associative_],2),e.associative_=n[0],t.associative_=n[1]},t.prototype.associative=function(){return this.associative_},t}(o.ListContainer);e.SetElementList=a,function(e){var t=function(e){function t(t,n,r,o){var i=e.call(this,n,r,o)||this;return i.source_=t,i}return n(t,e),t.create=function(e,n,r,o){return new t(e,n,r,o)},t.prototype.reverse=function(){return new r(this)},t.prototype.source=function(){return this.source_.associative()},t}(i.ListIterator);e.Iterator=t;var r=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype._Create_neighbor=function(e){return new t(e)},t}(s.ReverseIterator);e.ReverseIterator=r}(a=e.SetElementList||(e.SetElementList={})),e.SetElementList=a}(Yy)),Yy),c=function(){if(fg)return dg;fg=1;var e,t=Ln&&Ln.__extends||(e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}),n=Ln&&Ln.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},r=Ln&&Ln.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(dg,"__esModule",{value:!0}),dg.SetHashBuckets=void 0;var o=function(e){function o(t,n,r){var o=e.call(this,i,n)||this;return o.source_=t,o.key_eq_=r,o}return t(o,e),o._Swap_source=function(e,t){var r;r=n([t.source_,e.source_],2),e.source_=r[0],t.source_=r[1]},o.prototype.key_eq=function(){return this.key_eq_},o.prototype.find=function(e){var t,n,o=this.hash_function()(e)%this.length(),i=this.at(o);try{for(var s=r(i),a=s.next();!a.done;a=s.next()){var c=a.value;if(this.key_eq_(c.value,e))return c}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return this.source_.end()},o}(yg().HashBuckets);function i(e){return e.value}return dg.SetHashBuckets=o,dg}(),u=wg(),l=function(e){function t(){for(var n=[],i=0;i0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},r=Ln&&Ln.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},o=Ln&&Ln.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s};Object.defineProperty(e,"__esModule",{value:!0}),e.MapElementList=void 0;var o=sg(),i=Qy(),s=lg(),a=function(e){function t(t){var n=e.call(this)||this;return n.associative_=t,n}return n(t,e),t.prototype._Create_iterator=function(e,n,r){return t.Iterator.create(this,e,n,r)},t._Swap_associative=function(e,t){var n;n=r([t.associative_,e.associative_],2),e.associative_=n[0],t.associative_=n[1]},t.prototype.associative=function(){return this.associative_},t}(o.ListContainer);e.MapElementList=a,function(e){var t=function(e){function t(t,n,r,o){var i=e.call(this,n,r,o)||this;return i.list_=t,i}return n(t,e),t.create=function(e,n,r,o){return new t(e,n,r,o)},t.prototype.reverse=function(){return new r(this)},t.prototype.source=function(){return this.list_.associative()},Object.defineProperty(t.prototype,"first",{get:function(){return this.value.first},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"second",{get:function(){return this.value.second},set:function(e){this.value.second=e},enumerable:!1,configurable:!0}),t}(i.ListIterator);e.Iterator=t;var r=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype._Create_neighbor=function(e){return new t(e)},Object.defineProperty(t.prototype,"first",{get:function(){return this.base_.first},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"second",{get:function(){return this.base_.second},set:function(e){this.base_.second=e},enumerable:!1,configurable:!0}),t}(s.ReverseIterator);e.ReverseIterator=r}(a=e.MapElementList||(e.MapElementList={})),e.MapElementList=a}(Cg)),Cg),c=function(){if(Rg)return Tg;Rg=1;var e,t=Ln&&Ln.__extends||(e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}),n=Ln&&Ln.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},r=Ln&&Ln.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(Tg,"__esModule",{value:!0}),Tg.MapHashBuckets=void 0;var o=function(e){function o(t,n,r){var o=e.call(this,i,n)||this;return o.source_=t,o.key_eq_=r,o}return t(o,e),o._Swap_source=function(e,t){var r;r=n([t.source_,e.source_],2),e.source_=r[0],t.source_=r[1]},o.prototype.key_eq=function(){return this.key_eq_},o.prototype.find=function(e){var t,n,o=this.hash_function()(e)%this.length(),i=this.at(o);try{for(var s=r(i),a=s.next();!a.done;a=s.next()){var c=a.value;if(this.key_eq_(c.first,e))return c}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return this.source_.end()},o}(yg().HashBuckets);function i(e){return e.first}return Tg.MapHashBuckets=o,Tg}(),u=function(){if(Lg)return jg;Lg=1,Object.defineProperty(jg,"__esModule",{value:!0}),jg.Entry=void 0;var e=Hy(),t=Gy(),n=function(){function n(e,t){this.first=e,this.second=t}return n.prototype.equals=function(e){return(0,t.equal_to)(this.first,e.first)},n.prototype.less=function(e){return(0,t.less)(this.first,e.first)},n.prototype.hashCode=function(){return(0,e.hash)(this.first)},n}();return jg.Entry=n,jg}(),l=wg(),h=function(e){function t(){for(var n=[],i=0;i=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}};Object.defineProperty(ay,"__esModule",{value:!0});var t=vg(),n=Ug(),r=function(){function r(){this.listeners_=new n.HashMap,this.created_at_=new Date}return r.prototype.dispatchEvent=function(t){var n,r,o=this.listeners_.find(t.type);if(!o.equals(this.listeners_.end())){t.target=this,t.timeStamp=(new Date).getTime()-this.created_at_.getTime();try{for(var i=e(o.second),s=i.next();!s.done;s=i.next())(0,s.value)(t)}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}}},r.prototype.addEventListener=function(e,n){var r=this.listeners_.find(e);r.equals(this.listeners_.end())&&(r=this.listeners_.emplace(e,new t.HashSet).first),r.second.insert(n)},r.prototype.removeEventListener=function(e,t){var n=this.listeners_.find(e);n.equals(this.listeners_.end())||(n.second.erase(t),n.second.empty()&&this.listeners_.erase(n))},r}();return ay.EventTarget=r,ay}(),s=Mg(),a=function(){if($g)return zg;$g=1;var e,t=Ln&&Ln.__extends||(e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)},function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)});Object.defineProperty(zg,"__esModule",{value:!0});var n=function(e){function n(t,n){return e.call(this,t,n)||this}return t(n,e),n}(Mg().Event);return zg.CloseEvent=n,zg}(),c=function(){if(Fg)return Dg;Fg=1;var e,t=Ln&&Ln.__extends||(e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)},function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)});Object.defineProperty(Dg,"__esModule",{value:!0});var n=function(e){function n(t,n){return e.call(this,t,n)||this}return t(n,e),n}(Mg().Event);return Dg.MessageEvent=n,Dg}(),u=function(){if(Hg)return Wg;Hg=1;var e,t=Ln&&Ln.__extends||(e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)},function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)});Object.defineProperty(Wg,"__esModule",{value:!0});var n=function(e){function n(t,n){return e.call(this,t,n)||this}return t(n,e),n}(Mg().Event);return Wg.ErrorEvent=n,Wg}(),l=function(e){function t(n,r){var i=e.call(this)||this;return i.on_={},i.state_=t.CONNECTING,i.client_=new o.client,i.client_.on("connect",i._Handle_connect.bind(i)),i.client_.on("connectFailed",i._Handle_error.bind(i)),"string"==typeof r&&(r=[r]),i.client_.connect(n,r),i}return n(t,e),t.prototype.close=function(e,n){this.state_=t.CLOSING,void 0===e?this.connection_.sendCloseFrame():this.connection_.sendCloseFrame(e,n,!0)},t.prototype.send=function(e){if("string"==typeof e.valueOf())this.connection_.sendUTF(e);else{var t=void 0;t=e instanceof us?e:e instanceof Blob?new us(e,"blob"):e.buffer?new us(e.buffer):new us(e),this.connection_.sendBytes(t)}},Object.defineProperty(t.prototype,"url",{get:function(){return this.client_.url.href},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"protocol",{get:function(){return this.client_.protocols?this.client_.protocols[0]:""},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"extensions",{get:function(){return this.connection_&&this.connection_.extensions?this.connection_.extensions[0].name:""},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"readyState",{get:function(){return this.state_},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bufferedAmount",{get:function(){return this.connection_.bytesWaitingToFlush},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"binaryType",{get:function(){return"arraybuffer"},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onopen",{get:function(){return this.on_.open},set:function(e){this._Set_on("open",e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onclose",{get:function(){return this.on_.close},set:function(e){this._Set_on("close",e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onmessage",{get:function(){return this.on_.message},set:function(e){this._Set_on("message",e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onerror",{get:function(){return this.on_.error},set:function(e){this._Set_on("error",e)},enumerable:!0,configurable:!0}),t.prototype._Set_on=function(e,t){this.on_[e]&&this.removeEventListener(e,this.on_[e]),this.addEventListener(e,t),this.on_[e]=t},t.prototype._Handle_connect=function(e){this.connection_=e,this.state_=t.OPEN,this.connection_.on("message",this._Handle_message.bind(this)),this.connection_.on("error",this._Handle_error.bind(this)),this.connection_.on("close",this._Handle_close.bind(this));var n=new s.Event("open",h);this.dispatchEvent(n)},t.prototype._Handle_close=function(e,n){var o=new a.CloseEvent("close",r({},h,{code:e,reason:n}));this.state_=t.CLOSED,this.dispatchEvent(o)},t.prototype._Handle_message=function(e){var t=new c.MessageEvent("message",r({},h,{data:e.binaryData?e.binaryData:e.utf8Data}));this.dispatchEvent(t)},t.prototype._Handle_error=function(e){var n=new u.ErrorEvent("error",r({},h,{error:e,message:e.message}));this.state_===t.CONNECTING&&(this.state_=t.CLOSED),this.dispatchEvent(n)},t}(i.EventTarget);e.WebSocket=l,function(e){e.CONNECTING=0,e.OPEN=1,e.CLOSING=2,e.CLOSED=3}(l=e.WebSocket||(e.WebSocket={})),e.WebSocket=l;var h={bubbles:!1,cancelable:!1}}(Jp)),Jp).WebSocket);const{bech32:Kg,hex:Gg,utf8:Zg}=kr,Vg={bech32:"bc",pubKeyHash:0,scriptHash:5,validWitnessVersions:[0]},Yg={bech32:"tb",pubKeyHash:111,scriptHash:196,validWitnessVersions:[0]},Xg={bech32:"bcrt",pubKeyHash:111,scriptHash:196,validWitnessVersions:[0]},Jg={bech32:"sb",pubKeyHash:63,scriptHash:123,validWitnessVersions:[0]},Qg=["option_data_loss_protect","initial_routing_sync","option_upfront_shutdown_script","gossip_queries","var_onion_optin","gossip_queries_ex","option_static_remotekey","payment_secret","basic_mpp","option_support_large_channel"],eb={m:BigInt(1e3),u:BigInt(1e6),n:BigInt(1e9),p:BigInt(1e12)},tb=BigInt("2100000000000000000"),nb=BigInt(1e11),rb={payment_hash:1,payment_secret:16,description:13,payee:19,description_hash:23,expiry:6,min_final_cltv_expiry:24,fallback_address:9,route_hint:3,feature_bits:5,metadata:27},ob={};for(let e=0,t=Object.keys(rb);eGg.encode(Kg.fromWordsUnsafe(e)),16:e=>Gg.encode(Kg.fromWordsUnsafe(e)),13:e=>Zg.encode(Kg.fromWordsUnsafe(e)),19:e=>Gg.encode(Kg.fromWordsUnsafe(e)),23:e=>Gg.encode(Kg.fromWordsUnsafe(e)),27:e=>Gg.encode(Kg.fromWordsUnsafe(e)),6:ab,24:ab,3:function(e){const t=[];let n,r,o,i,s,a=Kg.fromWordsUnsafe(e);for(;a.length>0;)n=Gg.encode(a.slice(0,33)),r=Gg.encode(a.slice(33,41)),o=parseInt(Gg.encode(a.slice(41,45)),16),i=parseInt(Gg.encode(a.slice(45,49)),16),s=parseInt(Gg.encode(a.slice(49,51)),16),a=a.slice(51),t.push({pubkey:n,short_channel_id:r,fee_base_msat:o,fee_proportional_millionths:i,cltv_expiry_delta:s});return t},5:function(e){const t=e.slice().reverse().map((e=>[!!(1&e),!!(2&e),!!(4&e),!!(8&e),!!(16&e)])).reduce(((e,t)=>e.concat(t)),[]);for(;t.length<2*Qg.length;)t.push(!1);const n={};Qg.forEach(((e,r)=>{let o;o=t[2*r]?"required":t[2*r+1]?"supported":"unsupported",n[e]=o}));const r=t.slice(2*Qg.length);return n.extra_bits={start_bit:2*Qg.length,bits:r,has_required:r.reduce(((e,t,n)=>n%2!=0?e||!1:e||t),!1)},n}};function sb(e){return t=>({tagCode:parseInt(e),words:Kg.encode("unknown",t,Number.MAX_SAFE_INTEGER)})}function ab(e){return e.reverse().reduce(((e,t,n)=>e+t*Math.pow(32,n)),0)}function cb(e,t){let n,r;if(e.slice(-1).match(/^[munp]$/))n=e.slice(-1),r=e.slice(0,-1);else{if(e.slice(-1).match(/^[^munp0-9]$/))throw new Error("Not a valid multiplier for the amount");r=e}if(!r.match(/^\d+$/))throw new Error("Not a valid human readable amount");const o=BigInt(r),i=n?o*nb/eb[n]:o*nb;if("p"===n&&o%BigInt(10)!==BigInt(0)||i>tb)throw new Error("Amount is outside of valid range");return t?i.toString():i}var ub={decode:function(e,t){if("string"!=typeof e)throw new Error("Lightning Payment Request must be string");if("ln"!==e.slice(0,2).toLowerCase())throw new Error("Not a proper lightning payment request");const n=[],r=Kg.decode(e,Number.MAX_SAFE_INTEGER);e=e.toLowerCase();const o=r.prefix;let i=r.words,s=e.slice(o.length+1),a=i.slice(-104);i=i.slice(0,-104);let c=o.match(/^ln(\S+?)(\d*)([a-zA-Z]?)$/);if(c&&!c[2]&&(c=o.match(/^ln(\S+)$/)),!c)throw new Error("Not a proper lightning payment request");n.push({name:"lightning_network",letters:"ln"});const u=c[1];let l;if(t){if(void 0===t.bech32||void 0===t.pubKeyHash||void 0===t.scriptHash||!Array.isArray(t.validWitnessVersions))throw new Error("Invalid network");l=t}else switch(u){case Vg.bech32:l=Vg;break;case Yg.bech32:l=Yg;break;case Xg.bech32:l=Xg;break;case Jg.bech32:l=Jg}if(!l||l.bech32!==u)throw new Error("Unknown coin bech32 prefix");n.push({name:"coin_network",letters:u,value:l});const h=c[2];let f;if(h){f=cb(h+c[3],!0),n.push({name:"amount",letters:c[2]+c[3],value:f})}else f=null;n.push({name:"separator",letters:"1"});const d=ab(i.slice(0,7));let p,y,g,b;for(i=i.slice(7),n.push({name:"timestamp",letters:s.slice(0,7),value:d}),s=s.slice(7);i.length>0;){const e=i[0].toString();p=ob[e]||"unknown_tag",y=ib[e]||sb(e),i=i.slice(1),g=ab(i.slice(0,2)),i=i.slice(2),b=i.slice(0,g),i=i.slice(g),n.push({name:p,tag:s[0],letters:s.slice(0,3+g),value:y(b)}),s=s.slice(3+g)}n.push({name:"signature",letters:s.slice(0,104),value:Gg.encode(Kg.fromWordsUnsafe(a))}),s=s.slice(104),n.push({name:"checksum",letters:s});let m={paymentRequest:e,sections:n,get expiry(){let e=n.find((e=>"expiry"===e.name));if(e)return w("timestamp")+e.value},get route_hints(){return n.filter((e=>"route_hint"===e.name)).map((e=>e.value))}};for(let e in rb)"route_hint"!==e&&Object.defineProperty(m,e,{get:()=>w(e)});return m;function w(e){let t=n.find((t=>t.name===e));return t?t.value:void 0}},hrpToMillisat:cb};var lb=class extends Kp{ndk;zappedEvent;zappedUser;constructor(e){super(),this.ndk=e.ndk,this.zappedEvent=e.zappedEvent,this.zappedUser=e.zappedUser||this.ndk.getUser({hexpubkey:this.zappedEvent.pubkey})}async getZapEndpoint(){let e,t,n,r;if(this.zappedEvent){const n=(await this.zappedEvent.getMatchingTags("zap"))[0];if(n)switch(n[2]){case"lud06":e=n[1];break;case"lud16":t=n[1];break;default:throw new Error(`Unknown zap tag ${n}`)}}if(!this.zappedUser||e||t||(this.zappedUser.profile||await this.zappedUser.fetchProfile(),e=(this.zappedUser.profile||{}).lud06,t=(this.zappedUser.profile||{}).lud16),t){const[e,r]=t.split("@");n=`https://${r}/.well-known/lnurlp/${e}`}else if(e){const{words:t}=Rn.decode(e,1e3),r=Rn.fromWords(t);n=new TextDecoder("utf-8").decode(r)}if(!n)throw new Error("No zap endpoint found");const o=await fetch(n),i=await o.json();return i?.allowsNostr&&(i?.nostrPubkey||i?.nostrPubKey)&&(r=i.callback),r}async createZapRequest(e,t,n){const r=await this.getZapEndpoint();if(!r)throw new Error("No zap endpoint found");if(!this.zappedEvent)throw new Error("No zapped event found");const o=Di.makeZapRequest({profile:this.zappedUser.hexpubkey(),event:null,amount:e,comment:t||"",relays:["wss://nos.lol","wss://relay.nostr.band","wss://relay.f7z.io","wss://relay.damus.io","wss://nostr.mom","wss://no.str.cr"]});if(this.zappedEvent){const e=this.zappedEvent.tagReference();e&&o.tags.push(e)}o.tags.push(["lnurl",r]);const i=new mb(this.ndk,o);n&&(i.tags=i.tags.concat(n)),await i.sign();const s=await i.toNostrEvent(),a=await fetch(`${r}?`+new URLSearchParams({amount:e.toString(),nostr:JSON.stringify(s)}));return(await a.json()).pr}};function hb(){if(void 0===this.kind)throw new Error("Kind not set");return this.kind>=1e4&&this.kind<2e4}function fb(){if(void 0===this.kind)throw new Error("Kind not set");return this.kind>=3e4&&this.kind<4e4}async function db(){if(!this.ndk)throw new Error("NDK not set");const e=await this.ndk.fetchEvents({kinds:[3],authors:[this.hexpubkey()]});if(e){const t=new Set;return e.forEach((e=>{e.tags.forEach((e=>{if("p"===e[0])try{const n=Zo.npubEncode(e[1]);t.add(n)}catch(e){}}))})),[...t].reduce(((e,t)=>{const n=new pb({npub:t});return n.ndk=this.ndk,e.add(n),e}),new Set)}return new Set}var pb=class{ndk;profile;npub="";relayUrls=[];constructor(e){e.npub&&(this.npub=e.npub),e.hexpubkey&&(this.npub=Zo.npubEncode(e.hexpubkey)),e.relayUrls&&(this.relayUrls=e.relayUrls)}static async fromNip05(e){const t=await fi.queryProfile(e);if(t)return new pb({hexpubkey:t.pubkey,relayUrls:t.relays})}hexpubkey(){return Zo.decode(this.npub).data}async fetchProfile(e){if(!this.ndk)throw new Error("NDK not set");this.profile||(this.profile={});const t=await this.ndk.fetchEvents({kinds:[0],authors:[this.hexpubkey()]},e);if(t){Array.from(t).sort(((e,t)=>e.created_at-t.created_at)).forEach((e=>{try{this.profile=function(e,t){const n=JSON.parse(e.content);return n.name&&(t.name=n.name),n.display_name&&(t.displayName=n.display_name),n.displayName&&(t.displayName=n.displayName),n.image&&(t.image=n.image),n.picture&&(t.image=n.picture),n.banner&&(t.banner=n.banner),n.bio&&(t.bio=n.bio),n.nip05&&(t.nip05=n.nip05),n.lud06&&(t.lud06=n.lud06),n.lud16&&(t.lud16=n.lud16),n.about&&(t.about=n.about),n.zapService&&(t.zapService=n.zapService),t}(e,this.profile)}catch(e){}}))}return t}follows=db.bind(this);async relayList(){if(!this.ndk)throw new Error("NDK not set");const e=await this.ndk.fetchEvents({kinds:[10002],authors:[this.hexpubkey()]});return e||new Set}};async function yb(e,t){if(!t){if(!this.ndk)throw new Error("No signer available");await this.ndk.assertSigner(),t=this.ndk.signer}if(!e){const t=this.getMatchingTags("p");if(1!==t.length)throw new Error("No recipient could be determined and no explicit recipient was provided");(e=new pb({hexpubkey:t[0][1]})).ndk=this.ndk}this.content=await t.encrypt(e,this.content)}async function gb(e,t){if(!t){if(!this.ndk)throw new Error("No signer available");await this.ndk.assertSigner(),t=this.ndk.signer}e||(e=this.author()),this.content=await t.decrypt(e,this.content)}function bb(){return this.isParamReplaceable()?Zo.naddrEncode({kind:this.kind,pubkey:this.pubkey,identifier:this.replaceableDTag()}):Zo.noteEncode(this.tagId())}var mb=class extends Kp{ndk;created_at;content="";tags=[];kind;id="";sig;pubkey="";constructor(e,t){super(),this.ndk=e,this.created_at=t?.created_at,this.content=t?.content||"",this.tags=t?.tags||[],this.id=t?.id||"",this.sig=t?.sig,this.pubkey=t?.pubkey||"",this.kind=t?.kind}rawEvent(){return{created_at:this.created_at,content:this.content,tags:this.tags,kind:this.kind,pubkey:this.pubkey,id:this.id,sig:this.sig}}author(){const e=new pb({hexpubkey:this.pubkey});return e.ndk=this.ndk,e}async toNostrEvent(e){if(!e&&""===this.pubkey){const e=await(this.ndk?.signer?.user());this.pubkey=e?.hexpubkey()||""}this.created_at||(this.created_at=Math.floor(Date.now()/1e3));const t=this.rawEvent(),{content:n,tags:r}=this.generateTags();t.content=n||"",t.tags=r;try{this.id=Uo(t)}catch(e){}return this.id&&(t.id=this.id),this.sig&&(t.sig=this.sig),t}isReplaceable=hb.bind(this);isParamReplaceable=fb.bind(this);encode=bb.bind(this);encrypt=yb.bind(this);decrypt=gb.bind(this);getMatchingTags(e){return this.tags.filter((t=>t[0]===e))}async toString(){return await this.toNostrEvent()}async sign(e){e||this.ndk?.assertSigner(),await this.generateTags(),this.isReplaceable()&&(this.created_at=Math.floor(Date.now()/1e3));const t=await this.toNostrEvent(),n=e||this.ndk?.signer;this.sig=await n.sign(t)}async publish(e){return this.sig||await this.sign(),this.ndk?.publish(this,e)}generateTags(){let e=[];const t=function(e,t=[]){return e=e.replace(/(@|nostr:)(npub|nprofile|note|nevent)[a-zA-Z0-9]+/g,(e=>{try{const n=e.split(/(@|nostr:)/)[2],{type:r,data:o}=Zo.decode(n);let i;switch(r){case"npub":i=["p",o];break;case"nprofile":i=["p",o.pubkey];break;case"nevent":i=["e",o.id];break;case"note":i=["e",o];break;default:return e}return t.find((e=>e[0]==e[0]&&e[1]==e[1]))||t.push(i),`nostr:${n}`}catch(t){return e}})),{content:e,tags:t}}(this.content,this.tags),n=t.content;if(e=t.tags,this.kind&&this.kind>=3e4&&this.kind<=4e4){if(!this.getMatchingTags("d")[0]){const t=[...Array(16)].map((()=>Math.random().toString(36)[2])).join("");e.push(["d",t])}}return{content:n||"",tags:e}}replaceableDTag(){if(this.kind&&this.kind>=3e4&&this.kind<=4e4){const e=this.getMatchingTags("d")[0];return e?e[1]:""}throw new Error("Event is not a parameterized replaceable event")}tagId(){if(this.kind&&this.kind>=3e4&&this.kind<=4e4){const e=this.replaceableDTag();return`${this.kind}:${this.pubkey}:${e}`}return this.id}tagReference(){return this.kind&&this.kind>=3e4&&this.kind<=4e4?["a",this.tagId()]:["e",this.tagId()]}async zap(e,t,n){if(!this.ndk)throw new Error("No NDK instance found");this.ndk.assertSigner();const r=new lb({ndk:this.ndk,zappedEvent:this});return await r.createZapRequest(e,t,n)}},wb=class extends Kp{url;scores;relay;_status;connectedAt;_connectionStats={attempts:0,success:0,durations:[]};complaining=!1;debug;activeSubscriptions=new Set;constructor(e){super(),this.url=e,this.relay=Go(e),this.scores=new Map,this._status=3,this.debug=Dp(`ndk:relay:${e}`),this.relay.on("connect",(()=>{this.updateConnectionStats.connected(),this.emit("connect"),this._status=1})),this.relay.on("disconnect",(()=>{this.updateConnectionStats.disconnected(),this.emit("disconnect"),1===this._status&&(this._status=3,this.handleReconnection())})),this.relay.on("notice",(e=>this.handleNotice(e)))}isFlapping(){const e=this._connectionStats.durations;if(e.length<10)return!1;const t=e.reduce(((e,t)=>e+t),0)/e.length,n=e.map((e=>Math.pow(e-t,2))).reduce(((e,t)=>e+t),0)/e.length;return Math.sqrt(n)<1e3}handleReconnection(){this.isFlapping()&&this.emit("flapping",this,this._connectionStats),this.connectedAt&&Date.now()-this.connectedAt<5e3?setTimeout((()=>this.connect()),6e4):this.connect()}get status(){return this._status}async connect(){try{this.updateConnectionStats.attempt(),this._status=0,await this.relay.connect()}catch(e){throw this.debug("Failed to connect",e),this._status=3,e}}disconnect(){this._status=2,this.relay.close()}async handleNotice(e){(e.includes("oo many")||e.includes("aximum"))&&(this.disconnect(),setTimeout((()=>this.connect()),2e3),console.log(this.relay.url,"Relay complaining?",e)),this.emit("notice",this,e)}subscribe(e){const{filter:t}=e,n=this.relay.sub([t],{id:e.subId});return this.debug(`Subscribed to ${JSON.stringify(t)}`),n.on("event",(t=>{const n=new mb(void 0,t);e.eventReceived(n,this)})),n.on("eose",(()=>{e.eoseReceived(this)})),this.activeSubscriptions.add(e),e.on("close",(()=>{this.activeSubscriptions.delete(e)})),n}async publish(e){const t=await e.toNostrEvent(),n=this.relay.publish(t);n.on("failed",(t=>{this.debug("Publish failed",t,e.rawEvent())})),n.on("ok",(()=>{this.debug("Publish ok",e.rawEvent())})),this.debug(`Published event ${e.id}`,e.rawEvent())}scoreSlowerEvent(e){}updateConnectionStats={connected:()=>{this._connectionStats.success++,this._connectionStats.connectedAt=Date.now()},disconnected:()=>{this._connectionStats.connectedAt&&(this._connectionStats.durations.push(Date.now()-this._connectionStats.connectedAt),this._connectionStats.durations.length>100&&this._connectionStats.durations.shift()),this._connectionStats.connectedAt=void 0},attempt:()=>{this._connectionStats.attempts++}};get connectionStats(){return this._connectionStats}},vb=class extends Kp{relays=new Map;debug;constructor(e=[],t){super(),this.debug=t.debug.extend("pool");for(const t of e){const e=new wb(t);e.on("notice",((e,t)=>this.emit("notice",e,t))),e.on("connect",(()=>this.handleRelayConnect(t))),e.on("disconnect",(()=>this.emit("relay:disconnect",e))),e.on("flapping",(()=>this.handleFlapping(e))),this.relays.set(t,e)}}handleRelayConnect(e){this.debug(`Relay ${e} connected`),this.emit("relay:connect",this.relays.get(e)),this.stats().connected===this.relays.size&&this.emit("connect")}async connect(e){const t=[];this.debug(`Connecting to ${this.relays.size} relays${e?`, timeout ${e}...`:""}`);for(const n of this.relays.values())if(e){const r=new Promise(((t,n)=>{setTimeout((()=>n(`Timed out after ${e}ms`)),e)}));t.push(Promise.race([n.connect(),r]).catch((e=>{this.debug(`Failed to connect to relay ${n.url}: ${e}`)})))}else t.push(n.connect());await Promise.all(t)}handleFlapping(e){this.debug(`Relay ${e.url} is flapping`),this.relays.delete(e.url),this.emit("flapping",e)}size(){return this.relays.size}stats(){const e={total:0,connected:0,disconnected:0,connecting:0};for(const t of this.relays.values())e.total++,1===t.status?e.connected++:3===t.status?e.disconnected++:0===t.status&&e.connecting++;return e}},_b={closeOnEose:!0,cacheUsage:"CACHE_FIRST",groupable:!0,groupableDelay:100},xb=class extends Kp{subId;filter;opts;relaySet;ndk;relaySubscriptions;debug;constructor(e,t,n,r,o){if(super(),this.ndk=e,this.subId=o||Math.floor(9999991e3*Math.random()).toString(),this.filter=t,this.relaySet=r,this.opts={..._b,...n||{}},this.relaySubscriptions=new Map,this.debug=e.debug.extend("subscription"),"ONLY_CACHE"===this.opts.cacheUsage&&!this.opts.closeOnEose)throw new Error("Cannot use cache-only options with a persistent subscription")}groupableId(){if(!this.opts?.groupable)return null;const e=(this.filter.kinds?.length||0)>0,t=!this.filter.since&&!this.filter.until,n=!this.filter.limit;if(e&&t&&n){let e=this.filter.kinds.join(",");return e+=`-${Object.keys(this.filter||{}).sort().join("-")}`,e}return null}shouldQueryCache(){return"ONLY_RELAY"!==this.opts?.cacheUsage}shouldQueryRelays(){return"ONLY_CACHE"!==this.opts?.cacheUsage}async start(){let e;if(this.shouldQueryCache()){e=this.startWithCache();if(this.ndk.cacheAdapter?.locking&&this.shouldQueryRelays()&&"PARALLEL"!==this.opts?.cacheUsage&&(this.debug("waiting for cache to finish"),await e,this.eventFirstSeen.size>0))return this.debug("cache hit, skipping relay query"),void this.emit("eose",this)}this.shouldQueryRelays()&&this.startWithRelaySet()}stop(){this.relaySubscriptions.forEach((e=>e.unsub())),this.relaySubscriptions.clear(),this.emit("close",this)}async startWithCache(){if(this.ndk.cacheAdapter?.query){this.debug("querying cache");const e=this.ndk.cacheAdapter.query(this);this.ndk.cacheAdapter.locking&&await e}}startWithRelaySet(){this.relaySet||(this.relaySet=function(e,t){const n=new Set;return e.pool?.relays.forEach((t=>{t.complaining?e.debug(`Relay ${t.url} is complaining, not adding to set`):n.add(t)})),new kb(n,e)}(this.ndk,this.filter)),this.relaySet&&(this.debug("querying relays"),this.relaySet.subscribe(this))}eventFirstSeen=new Map;eventReceived(e,t,n=!1){if(!n&&t){if(this.eventFirstSeen.has(e.id)){const n=Date.now()-(this.eventFirstSeen.get(e.id)||0);return t.scoreSlowerEvent(n),void this.emit("event:dup",e,t,n,this)}this.ndk.cacheAdapter&&this.ndk.cacheAdapter.setEvent(e,this.filter),this.eventFirstSeen.set(`${e.id}`,Date.now())}else this.eventFirstSeen.set(`${e.id}`,0);this.emit("event",e,t,this)}eosesSeen=new Set;eoseTimeout;eoseReceived(e){this.opts?.closeOnEose&&(this.relaySubscriptions.get(e)?.unsub(),this.relaySubscriptions.delete(e),0===this.relaySubscriptions.size&&this.emit("close",this)),this.eosesSeen.add(e);this.eosesSeen.size===this.relaySet?.size()?this.emit("eose"):(this.eoseTimeout&&clearTimeout(this.eoseTimeout),this.eoseTimeout=setTimeout((()=>{this.emit("eose")}),500))}},Eb=class extends xb{subscriptions;constructor(e,t){const n=e.debug.extend("subscription-group"),r=function(e){const t={};return e.forEach((e=>{Object.entries(e).forEach((([e,n])=>{Array.isArray(n)?void 0===t[e]?t[e]=[...n]:t[e]=Array.from(new Set([...t[e],...n])):t[e]=n}))})),t}(t.map((e=>e.filter)));super(e,r,t[0].opts,t[0].relaySet),this.subscriptions=t,n("merged filters",{count:t.length,mergedFilters:this.filter}),this.on("event",this.forwardEvent),this.on("event:dup",this.forwardEventDup),this.on("eose",this.forwardEose),this.on("close",this.forwardClose)}isEventForSubscription(e,t){const{filter:n}=t;return!!n&&zo(n,e.rawEvent())}forwardEvent(e,t){for(const n of this.subscriptions)this.isEventForSubscription(e,n)&&n.emit("event",e,t,n)}forwardEventDup(e,t,n){for(const r of this.subscriptions)this.isEventForSubscription(e,r)&&r.emit("event:dup",e,t,n,r)}forwardEose(){for(const e of this.subscriptions)e.emit("eose",e)}forwardClose(){for(const e of this.subscriptions)e.emit("close",e)}};var kb=class{relays;debug;ndk;constructor(e,t){this.relays=e,this.ndk=t,this.debug=t.debug.extend("relayset")}static fromRelayUrls(e,t){const n=new Set;for(const r of e){const e=t.pool.relays.get(r);e&&n.add(e)}return new kb(new Set(n),t)}subscribeOnRelay(e,t){const n=e.subscribe(t);t.relaySubscriptions.set(e,n)}getId(){const e=Array.from(this.relays).map((e=>e.url)).sort().join(",");return be(Ie(e))}subscribe(e){const t=e.groupableId(),n=`${this.getId()}:${t}`;if(!n)return this.executeSubscription(e),e;const r=this.ndk.delayedSubscriptions.get(n);return r?r.push(e):(setTimeout((()=>{this.executeDelayedSubscription(n)}),e.opts.groupableDelay),this.ndk.delayedSubscriptions.set(n,[e])),e}executeDelayedSubscription(e){const t=this.ndk.delayedSubscriptions.get(e);this.ndk.delayedSubscriptions.delete(e),t&&(t.length>1?this.executeSubscriptions(t):this.executeSubscription(t[0]))}executeSubscriptions(e){const t=e[0].ndk,n=new Eb(t,e);this.executeSubscription(n)}executeSubscription(e){this.debug("subscribing",{filter:e.filter});for(const t of this.relays)if(1===t.status)this.subscribeOnRelay(t,e);else{const n=()=>{this.debug("new relay coming online for active subscription",{relay:t.url,filter:e.filter}),this.subscribeOnRelay(t,e)};t.once("connect",n),e.once("close",(()=>{t.removeListener("connect",n)}))}return e}async publish(e){this.relays.forEach((async t=>{try{await t.publish(e)}catch(e){}}))}size(){return this.relays.size}};var Sb=class extends Kp{pool;signer;cacheAdapter;debug;devWriteRelaySet;delayedSubscriptions;constructor(e={}){super(),this.debug=e.debug||Dp("ndk"),this.pool=new vb(e.explicitRelayUrls||[],this),this.signer=e.signer,this.cacheAdapter=e.cacheAdapter,this.delayedSubscriptions=new Map,e.devWriteRelayUrls&&(this.devWriteRelaySet=kb.fromRelayUrls(e.devWriteRelayUrls,this))}async connect(e){return this.debug("Connecting to relays",{timeoutMs:e}),this.pool.connect(e)}getUser(e){const t=new pb(e);return t.ndk=this,t}subscribe(e,t,n){const r=new xb(this,e,t,n);return r.start(),r}async publish(e,t){return t||(t=this.devWriteRelaySet||function(e,t){const n=new Set;return e.pool?.relays.forEach((e=>n.add(e))),new kb(n,e)}(this)),t.publish(e)}async fetchEvent(e,t={}){return new Promise((n=>{const r=this.subscribe(e,{...t,closeOnEose:!0});r.on("event",(e=>{e.ndk=this,n(e)})),r.on("eose",(()=>{n(null)}))}))}async fetchEvents(e,t={}){return new Promise((n=>{const r=new Map,o=this.subscribe(e,{...t,closeOnEose:!0});o.on("event",(e=>{const t=r.get(e.tagId());var n,o;t&&(o=e,e=(n=t).created_at>o.created_at?n:o),e.ndk=this,r.set(e.tagId(),e)})),o.on("eose",(()=>{n(new Set(r.values()))}))}))}async assertSigner(){if(!this.signer)throw this.emit("signerRequired"),new Error("Signer required")}};new Dp("nostr:adapter");const Ob=new Dp("nostr:adapter:profiles"),Ab=new Dp("nostr:adapter:write");class Cb{relayStatus={};#e=null;#t={};#n=new _a;#r={};tags;referenceTags;type;#o;chatId;relayUrls=[];#i=[];#s=[];#a;#c={};#u={};constructor(e,{tags:t,referenceTags:n,type:r="DM",chatId:o,websiteOwnerPubkey:i,relays:s}={}){this.pubkey=e,this.#o=i,this.relayUrls=s,r&&this.setChatConfiguration(r,t,n,o)}setChatConfiguration(e,t,n,r){this.type=e,this.tags=t,this.chatId=r,this.referenceTags=n,this.#e&&this.#l();let o=[];switch(this.type){case"DM":o.push({kinds:[4],"#p":[this.pubkey,this.#o],authors:[this.pubkey,this.#o]});break;case"GROUP":this.chatId&&o.push({kinds:[41,42],"#e":[this.chatId],limit:200});case"GLOBAL":this.tags&&this.tags.length>0&&o.push({kinds:[1],"#t":this.tags,limit:20}),this.referenceTags&&this.referenceTags.length>0&&o.push({kinds:[1],"#r":this.referenceTags,limit:20})}o&&o.length>0&&(this.#h(),this.subscribe(o,(e=>{this.#f(e)})))}async getPubKey(){return this.pubkey}on(e,t){this.#n.on(e,t)}async send(e,{tagPubKeys:t,tags:n}={}){let r;n||(n=[]),r="DM"===this.type?await this.sendKind4(e,{tagPubKeys:t,tags:n}):"GROUP"===this.type?await this.sendKind42(e,{tagPubKeys:t,tags:n,chatId:this.chatId}):await this.sendKind1(e,{tagPubKeys:t,tags:n}),r.id=Uo(r);const o=await this.signEvent(r);return this.#d(o),r.id}async sendKind4(e,{tagPubKeys:t,tags:n}={}){let r=await this.encrypt(this.#o,e);return{kind:4,pubkey:this.pubkey,created_at:Math.floor(Date.now()/1e3),content:r,tags:[["p",this.#o],...n]}}async sendKind42(e,{tagPubKeys:t,tags:n,chatId:r}={}){n||(n=[]),this.tags&&this.tags.forEach((e=>n.push(["t",e])));const o=!!n.find((e=>"e"===e[0]));o||n.push(["e",r,"wss://nos.lol",o?"reply":"root"]),this.referenceTags&&this.referenceTags.forEach((e=>n.push(["r",e])));let i={kind:42,created_at:Math.floor(Date.now()/1e3),tags:n,content:e,pubkey:this.pubkey};if(t)for(let e of t)e&&i.tags.push(["p",e]);return i.id=Uo(i),this.subscribeToEventAndResponses(i.id),i}async sendKind1(e,{tagPubKeys:t,tags:n}={}){n||(n=[]),this.tags&&this.tags.forEach((e=>n.push(["t",e]))),this.referenceTags&&this.referenceTags.forEach((e=>n.push(["r",e])));let r={kind:1,created_at:Math.floor(Date.now()/1e3),tags:n,content:e,pubkey:this.pubkey};if(t)for(let e of t)e&&r.tags.push(["p",e]);return r.id=Uo(r),this.subscribeToEventAndResponses(r.id),r}async#d(e){Ab("publish",e),this.#e.send(["EVENT",e])}async onEvent(e,t){this.#p(e.pubkey),t(e)}async delayedSubscribe(e,t,n){this.#c[t]=this.#c[t]||[],this.#c[t].push(e),this.#u[t]||(this.#u[t]=setTimeout((()=>{delete this.#u[t];let e=this.#c[t];delete this.#c[t];let n=[];n=e.reduce(((e,t,n)=>(n%10==0&&e.push([]),e[e.length-1].push(t),e)),n),n.forEach((e=>{this.subscribe(e,(e=>{this.#f(e)}))}))}),n))}async subscribe(e,t=null){return t||(t=e=>{this.#f(e)}),this.#y(e,t)}async#y(e,t){const n=$p();return this.#r[n]=t,Array.isArray(e)||(e=[e]),this.#e.subscribe(n,e),this.#e.on("event",((e,t,n)=>{this.onEvent(n,this.#r[t])})),n}async#f(e){if(this.#t[e.id])return;this.#t[e.id]=!0,4===e.kind&&(e.content=await this.decrypt(this.#o,e.content));let t,n=[];if(5===e.kind&&(n=e.tags.filter((e=>"e"===e[0])).map((e=>e[1]))),9735===e.kind){t=function(e){const t=e.getMatchingTags("description")[0],n=e.getMatchingTags("bolt11")[0];let r,o;if(!t||!n||!n[1])return null;try{let e=t[1];if(e.startsWith("%")&&(e=decodeURIComponent(e)),""===e)return null;o=JSON.parse(e),r=ub.decode(n[1])}catch(e){return null}const i=r.sections.find((e=>"amount"===e.name));if(!i)return null;const s=parseInt(i.value);if(!s)return null;const a=o.content,c=o.pubkey,u=e.getMatchingTags("p")[0][1];let l=e.getMatchingTags("e")[0];l||(l=e.getMatchingTags("a")[0]);const h=l?l[1]:void 0;return{id:e.id,zapper:e.pubkey,zappee:c,zapped:u,zappedEvent:h,amount:s,comment:a}}(new mb(null,e)),console.log(`received a zap invoice: ${t}`,e)}switch(e.kind){case 1:case 42:case 4:this.#n.emit("message",e);break;case 41:this.#n.emit("channelMetadata",e);break;case 5:this.#n.emit("deleted",n);break;case 7:this.#n.emit("reaction",e);break;case 9735:this.#n.emit("zap",t);break;default:console.log("unknown event kind",e.kind,e)}}subscribeToEventAndResponses(e){this.subscribe([{ids:[e]},{"#e":[e]}],(e=>{this.#f(e)}))}subscribeToResponses(e){this.subscribe([{"#e":[e.id]}],(e=>{this.#f(e),this.subscribeToResponses(e)}))}#h(){this.relayUrls.forEach((e=>{this.relayStatus[e]="disconnected"})),this.#n.emit("connectivity",this.relayStatus),this.#e=new Pp(this.relayUrls),this.#e.on("open",(e=>{this.relayStatus[e.url]="connected",this.#n.emit("connectivity",this.relayStatus)})),this.#e.on("error",((e,t,n)=>{this.relayStatus[e.url]="error",this.#n.emit("connectivity",this.relayStatus),console.log("error from relay",e.url,t,n)})),this.#e.on("close",((e,t)=>{this.relayStatus[e.url]="closed",this.#n.emit("connectivity",this.relayStatus),console.log("error from relay",e.url,t)})),this.#e.on("notice",((e,t)=>{console.log("notice",e.url,t)}))}#l(){this.relayUrls.forEach((e=>{this.relayStatus[e]="disconnected"})),this.#n.emit("connectivity",this.relayStatus),this.#e.close(),this.#e=null}reqProfile(e){this.#p(e)}#p(e,t=null){this.#i.includes(e)||this.#s.includes(e)||(this.#i.push(e),this.#s.push(e),this.#a||(this.#a=setTimeout((()=>{this.#a=null,this.#g()}),500)))}async#g(){if(this.#i.length>0){Ob("requesting profiles",this.#i);const e=await this.subscribe({kinds:[0],authors:this.#i},(e=>{this.#b(e)}));Ob("subscribed to request",{subId:e}),this.#i=[],setTimeout((()=>{Ob("unsubscribing from request",{subId:e}),this.#e.unsubscribe(e)}),5e3)}}#b(e){let t;Ob("received profile",e);try{t=JSON.parse(e.content)}catch(t){return void Ob("failed to parse profile",e)}this.#n.emit("profile",{pubkey:e.pubkey,profile:t})}}class Rb extends Cb{constructor(e,t={}){super(e,t)}async signEvent(e){return await window.nostr.signEvent(e)}async encrypt(e,t){return await window.nostr.nip04.encrypt(e,t)}async decrypt(e,t){return await window.nostr.nip04.decrypt(e,t)}}function Tb(){Tb=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",a=o.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function u(e,t,n,o){var i=t&&t.prototype instanceof f?t:f,s=Object.create(i.prototype),a=new S(o||[]);return r(s,"_invoke",{value:_(e,n,a)}),s}function l(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var h={};function f(){}function d(){}function p(){}var y={};c(y,i,(function(){return this}));var g=Object.getPrototypeOf,b=g&&g(g(O([])));b&&b!==t&&n.call(b,i)&&(y=b);var m=p.prototype=f.prototype=Object.create(y);function w(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function v(e,t){function o(r,i,s,a){var c=l(e[r],e,i);if("throw"!==c.type){var u=c.arg,h=u.value;return h&&"object"==typeof h&&n.call(h,"__await")?t.resolve(h.__await).then((function(e){o("next",e,s,a)}),(function(e){o("throw",e,s,a)})):t.resolve(h).then((function(e){u.value=e,s(u)}),(function(e){return o("throw",e,s,a)}))}a(c.arg)}var i;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){o(e,n,t,r)}))}return i=i?i.then(r,r):r()}})}function _(e,t,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return A()}for(n.method=o,n.arg=i;;){var s=n.delegate;if(s){var a=x(s,n);if(a){if(a===h)continue;return a}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var c=l(e,t,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}function x(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,x(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),h;var o=l(r,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,h;var i=o.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function E(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(E,this),this.reset(!0)}function O(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function t(){for(;++r=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var a=n.call(i,"catchLoc"),c=n.call(i,"finallyLoc");if(a&&c){if(this.prev=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;k(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:O(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),h}},e}function Lb(e,t,n,r,o,i,s){try{var a=e[i](s),c=a.value}catch(e){return void n(e)}a.done?t(c):Promise.resolve(c).then(r,o)}function Ib(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function s(e){Lb(i,r,o,s,a,"next",e)}function a(e){Lb(i,r,o,s,a,"throw",e)}s(void 0)}))}}function Pb(){return Pb=Object.assign?Object.assign.bind():function(e){for(var t=1;t(Ephemeral Keys)',S(i,"class","bg-purple-900 hover:bg-purple-700 w-full p-4 rounded-xl text-center font-regular text-gray-200 svelte-f7jodf"),S(a,"class","bg-purple-900 hover:bg-purple-700 w-full p-4 rounded-xl text-center font-regular text-gray-200 svelte-f7jodf"),S(n,"class","flex flex-col gap-1 svelte-f7jodf")},m(e,r){g(e,n,r),l&&l.m(n,null),y(n,o),y(n,i),y(n,s),y(n,a),c||(u=[E(i,"click",k(t[3])),E(a,"click",k(t[2]))],c=!0)},p(e,t){},d(e){e&&b(n),l&&l.d(),c=!1,r(u)}}}function Jb(t){let n,o,i,s,a,c,u;return{c(){n=w("p"),n.textContent="Scan this with your Nostr Connect (click to copy to clipboard)",o=_(),i=w("div"),s=_(),a=w("button"),a.textContent="Cancel",S(n,"class","text-gray-600 mb-3 svelte-f7jodf"),S(i,"class","bg-white w-full p-3 svelte-f7jodf"),S(a,"class","bg-purple-900 hover:bg-purple-700 w-full p-2 rounded-xl text-center font-regular text-white svelte-f7jodf")},m(e,r){g(e,n,r),g(e,o,r),g(e,i,r),g(e,s,r),g(e,a,r),c||(u=[E(i,"click",k(t[4])),E(a,"click",k(t[8]))],c=!0)},p:e,d(e){e&&b(n),e&&b(o),e&&b(i),e&&b(s),e&&b(a),c=!1,r(u)}}}function Qb(t){let n,r,o,i;function s(e,t){return e[0]?Jb:Xb}let a=s(t),c=a&&a(t);return{c(){n=w("h1"),n.textContent="How would you like to connect?",r=_(),o=_(),c&&c.c(),i=x(),S(n,"class","font-bold text-xl mb-3 svelte-f7jodf")},m(e,t){g(e,n,t),g(e,r,t),g(e,o,t),c&&c.m(e,t),g(e,i,t)},p(e,[t]){a===(a=s(e))&&c?c.p(e,t):(c&&c.d(1),c=a&&a(e),c&&(c.c(),c.m(i.parentNode,i)))},i:e,o:e,d(e){e&&b(n),e&&b(r),e&&b(o),c&&c.d(e),e&&b(i)}}}function em(e,t,n){let r,o,{websiteOwnerPubkey:i}=t,{chatConfiguration:s}=t,{relays:a}=t;function c(){window.nostr.getPublicKey().then((e=>{localStorage.setItem("nostrichat-type","nip07"),ie.set(new Rb(e,o))}))}async function u(){let e=localStorage.getItem("nostrichat-nostr-connect-key"),t=localStorage.getItem("nostrichat-nostr-connect-public-key");if(e)return void ie.set(new Vb(t,e,o));e=Ao();const i=new Zb({secretKey:e,relay:"wss://nostr.vulpem.com"});let s,a,c;i.events.on("connect",(o=>{localStorage.setItem("nostrichat-nostr-connect-key",e),localStorage.setItem("nostrichat-nostr-connect-public-key",o),localStorage.setItem("nostrichat-type","nip-46"),console.log("connected to nostr connect relay"),t=o,ie.set(new Vb(t,e)),n(0,r=null)})),i.events.on("disconnect",(()=>{console.log("disconnected from nostr connect relay")})),await i.init();try{s=window.document.title||"Nostrichat",a=new URL(window.location.href),c=a.hostname}catch(e){a=window.location.href,c=a}const u=new Gb({target:Co(e),relay:"wss://nostr.vulpem.com",metadata:{name:s,description:"๐Ÿ”‰๐Ÿ”‰๐Ÿ”‰",url:a}});n(0,r=u.toString())}L((()=>{const e=localStorage.getItem("nostrichat-type");"nip07"===e?c():"nip-46"===e&&u(),o={type:s.chatType,tags:s.chatTags,referenceTags:s.chatReferenceTags,websiteOwnerPubkey:i,relays:a}}));return e.$$set=e=>{"websiteOwnerPubkey"in e&&n(5,i=e.websiteOwnerPubkey),"chatConfiguration"in e&&n(6,s=e.chatConfiguration),"relays"in e&&n(7,a=e.relays)},[r,c,async function(){ie.set(new Yb(o))},u,function(){navigator.clipboard.writeText(r)},i,s,a,()=>{n(0,r=null)}]}class tm extends ne{constructor(e){super(),te(this,e,em,Qb,i,{websiteOwnerPubkey:5,chatConfiguration:6,relays:7})}}var nm,rm={},om={},im={},sm=Ln&&Ln.__extends||(nm=function(e,t){return nm=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},nm(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}nm(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});function am(e,t,n){if(Object.setPrototypeOf(e,n.prototype),t===n)if(e.name=t.name,Error.captureStackTrace)Error.captureStackTrace(e,n);else{var r=new Error(e.message).stack;r&&(e.stack=function(e,t){if(!e)return e;if(!t)return e;var n=new RegExp("\\s+at\\s".concat(t,"\\s")),r=e.split("\n");return r.filter((function(e){return!e.match(n)})).join("\n")}(r,"new ".concat(t.name)))}}Object.defineProperty(im,"__esModule",{value:!0}),im.InternalError=im.InvalidDataError=im.RoutingError=im.UnsupportedMethodError=im.ConnectionError=im.RejectionError=im.MissingProviderError=void 0;var cm=function(e){function t(n){var r=this.constructor,o=e.call(this,n)||this;return am(o,r,t),o}return sm(t,e),t}(Error);im.MissingProviderError=cm;var um=function(e){function t(n){var r=this.constructor,o=e.call(this,n)||this;return am(o,r,t),o}return sm(t,e),t}(Error);im.RejectionError=um;var lm=function(e){function t(n){var r=this.constructor,o=e.call(this,n)||this;return am(o,r,t),o}return sm(t,e),t}(Error);im.ConnectionError=lm;var hm=function(e){function t(n){var r=this.constructor,o=e.call(this,n)||this;return am(o,r,t),o}return sm(t,e),t}(Error);im.UnsupportedMethodError=hm;var fm=function(e){function t(n){var r=this.constructor,o=e.call(this,n)||this;return am(o,r,t),o}return sm(t,e),t}(Error);im.RoutingError=fm;var dm=function(e){function t(n){var r=this.constructor,o=e.call(this,n)||this;return am(o,r,t),o}return sm(t,e),t}(Error);im.InvalidDataError=dm;var pm=function(e){function t(n){var r=this.constructor,o=e.call(this,n)||this;return am(o,r,t),o}return sm(t,e),t}(Error);im.InternalError=pm,Object.defineProperty(om,"__esModule",{value:!0}),om.requestProvider=void 0;var ym=im;om.requestProvider=function(e){return new Promise((function(e,t){if("undefined"==typeof window)return t(new Error("Must be called in a browser context"));var n=window.webln;if(!n)return t(new ym.MissingProviderError("Your browser has no WebLN provider"));n.enable().then((function(){return e(n)})).catch((function(e){return t(e)}))}))};var gm,bm,mm,wm={};function vm(e){let t,n,r=(e[2]||e[1])+"";return{c(){t=w("span"),n=v(r),S(t,"class","text-base text-white flex flex-col items-center")},m(e,r){g(e,t,r),y(t,n)},p(e,t){6&t&&r!==(r=(e[2]||e[1])+"")&&O(n,r)},d(e){e&&b(t)}}}function _m(e){let t,n;return{c(){t=w("span"),n=v(e[0]),S(t,"class","text-xl")},m(e,r){g(e,t,r),y(t,n)},p(e,t){1&t&&O(n,e[0])},d(e){e&&b(t)}}}function xm(t){let n,o,i;function s(e,t){return e[3]?vm:_m}let a=s(t),c=a(t);return{c(){n=w("div"),c.c()},m(e,r){g(e,n,r),c.m(n,null),o||(i=[E(n,"mouseenter",t[7]),E(n,"mouseleave",t[8]),E(n,"click",k(t[4]))],o=!0)},p(e,[t]){a===(a=s(e))&&c?c.p(e,t):(c.d(1),c=a(e),c&&(c.c(),c.m(n,null)))},i:e,o:e,d(e){e&&b(n),c.d(),o=!1,r(i)}}}function Em(e,t,n){let r;c(e,ce,(e=>n(9,r=e)));let{icon:o,amount:i,amountDisplay:s,event:a,mobilePR:l}=t,h=!1;return e.$$set=e=>{"icon"in e&&n(0,o=e.icon),"amount"in e&&n(1,i=e.amount),"amountDisplay"in e&&n(2,s=e.amountDisplay),"event"in e&&n(6,a=e.event),"mobilePR"in e&&n(5,l=e.mobilePR)},[o,i,s,h,async function(){const e=new class{_userPromise;constructor(){if(!window.nostr)throw new Error("NIP-07 extension not available")}async blockUntilReady(){const e=await(window.nostr?.getPublicKey());if(!e)throw new Error("User rejected access");return new pb({hexpubkey:e})}async user(){return this._userPromise||(this._userPromise=this.blockUntilReady()),this._userPromise}async sign(e){if(!window.nostr)throw new Error("NIP-07 extension not available");return(await window.nostr.signEvent(e)).sig}async encrypt(e,t){if(!window.nostr)throw new Error("NIP-07 extension not available");const n=e.hexpubkey();return window.nostr.nip04.encrypt(n,t)}async decrypt(e,t){if(!window.nostr)throw new Error("NIP-07 extension not available");const n=e.hexpubkey();return window.nostr.nip04.decrypt(n,t)}},t=new Sb({explicitRelayUrls:["wss://nos.lol","wss://relay.nostr.band","wss://relay.damus.io","wss://nostr.mom","wss://no.str.cr"]});let o,s;t.signer=e,await t.connect();try{const e=new mb(t,a);o=await e.zap(1e3*i)}catch(e){return void alert(e)}try{s=await rm.requestProvider()}catch(e){return void n(5,l=o)}try{await s.sendPayment(o),u(ce,r=null,r)}catch(e){n(5,l=o)}},l,a,()=>n(3,h=!0),()=>n(3,h=!1)]}Object.defineProperty(wm,"__esModule",{value:!0}),gm=rm,bm=Ln&&Ln.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),mm=Ln&&Ln.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||bm(t,e,n)},Object.defineProperty(gm,"__esModule",{value:!0}),mm(om,gm),mm(wm,gm),mm(im,gm);class km extends ne{constructor(e){super(),te(this,e,Em,xm,i,{icon:0,amount:1,amountDisplay:2,event:6,mobilePR:5})}}function Sm(e,t,n){const r=e.slice();return r[32]=t[n],r}function Om(t){let n;return{c(){n=v("โšก๏ธ")},m(e,t){g(e,n,t)},p:e,d(e){e&&b(n)}}}function Am(e){let t,n,r,o,i=e[9]/1e3+"";return{c(){t=w("p"),n=v("โšก๏ธ\n "),r=w("span"),o=v(i),S(r,"class","text-orange-500 font-semibold svelte-f7jodf"),S(t,"class","flex flex-col items-center my-4 svelte-f7jodf")},m(e,i){g(e,t,i),y(t,n),y(t,r),y(r,o)},p(e,t){512&t[0]&&i!==(i=e[9]/1e3+"")&&O(o,i)},d(e){e&&b(t)}}}function Cm(e){let t,n,r,o;const i=[Tm,Rm],s=[];function a(e,t){return e[8]?0:1}return t=a(e),n=s[t]=i[t](e),{c(){n.c(),r=x()},m(e,n){s[t].m(e,n),g(e,r,n),o=!0},p(e,o){let c=t;t=a(e),t===c?s[t].p(e,o):(K(),V(s[c],1,1,(()=>{s[c]=null})),G(),n=s[t],n?n.p(e,o):(n=s[t]=i[t](e),n.c()),Z(n,1),n.m(r.parentNode,r))},i(e){o||(Z(n),o=!0)},o(e){V(n),o=!1},d(e){s[t].d(e),e&&b(r)}}}function Rm(e){let t,n,r,o,i,s,a,c,u,l,h,f,d,p,m,v,x,E,k,O,A,C,R,T,L;function I(t){e[20](t)}let j={icon:"๐Ÿ‘",amount:500,event:e[0]};function U(t){e[21](t)}void 0!==e[8]&&(j.mobilePR=e[8]),r=new km({props:j}),P.push((()=>Y(r,"mobilePR",I)));let B={icon:"๐Ÿค™",amount:2500,amountDisplay:"2.5k",event:e[0]};function N(t){e[22](t)}void 0!==e[8]&&(B.mobilePR=e[8]),a=new km({props:B}),P.push((()=>Y(a,"mobilePR",U)));let M={icon:"๐Ÿ™Œ",amount:5e3,amountDisplay:"5k",event:e[0]};function z(t){e[23](t)}void 0!==e[8]&&(M.mobilePR=e[8]),h=new km({props:M}),P.push((()=>Y(h,"mobilePR",N)));let F={icon:"๐Ÿงก",amount:1e4,amountDisplay:"10k",event:e[0]};function D(t){e[24](t)}void 0!==e[8]&&(F.mobilePR=e[8]),m=new km({props:F}),P.push((()=>Y(m,"mobilePR",z)));let H={icon:"๐Ÿคฏ",amount:1e5,amountDisplay:"100k",event:e[0]};function q(t){e[25](t)}void 0!==e[8]&&(H.mobilePR=e[8]),k=new km({props:H}),P.push((()=>Y(k,"mobilePR",D)));let W={icon:"๐Ÿ˜Ž",amount:1e6,amountDisplay:"1M",event:e[0]};return void 0!==e[8]&&(W.mobilePR=e[8]),R=new km({props:W}),P.push((()=>Y(R,"mobilePR",q))),{c(){t=w("div"),n=w("div"),X(r.$$.fragment),i=_(),s=w("div"),X(a.$$.fragment),u=_(),l=w("div"),X(h.$$.fragment),d=_(),p=w("div"),X(m.$$.fragment),x=_(),E=w("div"),X(k.$$.fragment),A=_(),C=w("div"),X(R.$$.fragment),S(n,"class","flex flex-col hover:bg-orange-500 text-white rounded-full w-12 h-12 items-center justify-center cursor-pointer svelte-f7jodf"),S(s,"class","flex flex-col hover:bg-orange-500 text-white rounded-full w-12 h-12 items-center justify-center cursor-pointer svelte-f7jodf"),S(l,"class","flex flex-col hover:bg-orange-500 text-white rounded-full w-12 h-12 items-center justify-center cursor-pointer svelte-f7jodf"),S(p,"class","flex flex-col hover:bg-orange-500 text-white rounded-full w-12 h-12 items-center justify-center cursor-pointer svelte-f7jodf"),S(E,"class","flex flex-col hover:bg-orange-500 text-white rounded-full w-12 h-12 items-center justify-center cursor-pointer svelte-f7jodf"),S(C,"class","flex flex-col hover:bg-orange-500 text-white rounded-full w-12 h-12 items-center justify-center cursor-pointer svelte-f7jodf"),S(t,"class","flex flex-row items-stretch justify-between w-full svelte-f7jodf")},m(e,o){g(e,t,o),y(t,n),J(r,n,null),y(t,i),y(t,s),J(a,s,null),y(t,u),y(t,l),J(h,l,null),y(t,d),y(t,p),J(m,p,null),y(t,x),y(t,E),J(k,E,null),y(t,A),y(t,C),J(R,C,null),L=!0},p(e,t){const n={};1&t[0]&&(n.event=e[0]),!o&&256&t[0]&&(o=!0,n.mobilePR=e[8],$((()=>o=!1))),r.$set(n);const i={};1&t[0]&&(i.event=e[0]),!c&&256&t[0]&&(c=!0,i.mobilePR=e[8],$((()=>c=!1))),a.$set(i);const s={};1&t[0]&&(s.event=e[0]),!f&&256&t[0]&&(f=!0,s.mobilePR=e[8],$((()=>f=!1))),h.$set(s);const u={};1&t[0]&&(u.event=e[0]),!v&&256&t[0]&&(v=!0,u.mobilePR=e[8],$((()=>v=!1))),m.$set(u);const l={};1&t[0]&&(l.event=e[0]),!O&&256&t[0]&&(O=!0,l.mobilePR=e[8],$((()=>O=!1))),k.$set(l);const d={};1&t[0]&&(d.event=e[0]),!T&&256&t[0]&&(T=!0,d.mobilePR=e[8],$((()=>T=!1))),R.$set(d)},i(e){L||(Z(r.$$.fragment,e),Z(a.$$.fragment,e),Z(h.$$.fragment,e),Z(m.$$.fragment,e),Z(k.$$.fragment,e),Z(R.$$.fragment,e),L=!0)},o(e){V(r.$$.fragment,e),V(a.$$.fragment,e),V(h.$$.fragment,e),V(m.$$.fragment,e),V(k.$$.fragment,e),V(R.$$.fragment,e),L=!1},d(e){e&&b(t),Q(r),Q(a),Q(h),Q(m),Q(k),Q(R)}}}function Tm(t){let n,r,o,i,s,a,c,u;return{c(){n=w("div"),r=w("a"),o=v("Open in wallet"),s=_(),a=w("button"),a.textContent="Cancel",S(r,"href",i=`lightning:${t[8]}`),S(r,"class","text-center w-full p-3 bg-black text-white rounded-t-xl svelte-f7jodf"),S(a,"class","bg-white rounder-b-xl p-3 svelte-f7jodf"),S(n,"class","flex flex-col gap-3 w-full svelte-f7jodf")},m(e,i){g(e,n,i),y(n,r),y(r,o),y(n,s),y(n,a),c||(u=E(a,"click",t[19]),c=!0)},p(e,t){256&t[0]&&i!==(i=`lightning:${e[8]}`)&&S(r,"href",i)},i:e,o:e,d(e){e&&b(n),c=!1,u()}}}function Lm(e){let t,n;return{c(){t=w("div"),n=v(e[10]),S(t,"class","text-xs text-gray-400 svelte-f7jodf")},m(e,r){g(e,t,r),y(t,n)},p(e,t){1024&t[0]&&O(n,e[10])},d(e){e&&b(t)}}}function Im(t){let n;return{c(){n=w("div"),n.textContent="Website owner",S(n,"class","text-purple-500 text-xs svelte-f7jodf")},m(e,t){g(e,n,t)},p:e,d(e){e&&b(n)}}}function Pm(e){let t,n,r=e[1][e[0].id],o=[];for(let t=0;tV(o[e],1,1,(()=>{o[e]=null}));return{c(){t=w("div");for(let e=0;e0?Am:Om}let Y=W(e),X=Y(e),J=e[6]&&Cm(e);let Q=function(e,t){return e[13]?Im:Lm}(e),ee=Q(e),te=e[1][e[0].id].length>0&&Pm(e);return{c(){t=w("div"),n=w("div"),o=w("div"),i=w("a"),s=w("img"),l=_(),h=w("button"),X.c(),d=_(),p=w("div"),J&&J.c(),A=_(),C=w("div"),R=w("div"),T=_(),L=w("div"),I=v(q),j=_(),U=w("div"),B=w("div"),N=w("span"),N.textContent=`${e[14].toLocaleString()}`,M=_(),ee.c(),$=_(),te&&te.c(),z=x(),a(s.src,c=e[4])||S(s,"src",c),S(s,"class","block w-8 h-8 rounded-full "+(e[13]?"ring-purple-700 ring-4":"")+" svelte-f7jodf"),S(s,"alt",""),S(i,"href",u=`nostr:${e[5]}`),S(i,"class","svelte-f7jodf"),S(h,"class",f="rounded-full "+(e[9]>0?"opacity-100 text-base":"bg-orange-500 opacity-10 text-xl")+" w-8 h-8 flex items-center justify-center hover:opacity-100 svelte-f7jodf"),S(p,"class",m=(e[6]?"w-full rounded-full bg-white drop-shadow-xl justify-between border-2 border-gray-200":" rounded-full w-8 h-8 justify-center")+" flex items-center absolute ml-5 mt-10 z-10 svelte-f7jodf"),S(o,"class","min-w-fit flex flex-col gap-2 svelte-f7jodf"),S(R,"class","flex flex-row justify-between text-center overflow-clip text-clip w-full svelte-f7jodf"),S(L,"class",P="max-h-64 text-base cursor-pointer border border-slate-200 "+(e[11]===e[0].id?"bg-purple-700 text-white":"bg-white text-gray-900 hover:bg-slate-100")+" p-4 py-2 overflow-auto rounded-2xl shadow-sm svelte-f7jodf"),S(N,"class","py-2 svelte-f7jodf"),S(B,"class","text-xs text-gray-400 text-ellipsis overflow-clip whitespace-nowrap svelte-f7jodf"),S(U,"class","flex flex-row-reverse justify-between mt-1 overflow-clip items-center relative svelte-f7jodf"),S(C,"class","w-full overflow-hidden svelte-f7jodf"),S(n,"class","flex flex-row gap-3 svelte-f7jodf"),S(t,"class","flex flex-col gap-4 p-2-lg mb-3 text-wrap relative svelte-f7jodf")},m(r,a){g(r,t,a),y(t,n),y(n,o),y(o,i),y(i,s),y(o,l),y(o,h),X.m(h,null),y(o,d),y(o,p),J&&J.m(p,null),y(n,A),y(n,C),y(C,R),y(C,T),y(C,L),y(L,I),y(C,j),y(C,U),y(U,B),y(B,N),y(U,M),ee.m(U,null),g(r,$,a),te&&te.m(r,a),g(r,z,a),F=!0,D||(H=[E(h,"click",k(e[18])),E(L,"click",k(e[26])),E(L,"keydown",k(e[27])),E(L,"keyup",k(e[28])),E(t,"mouseenter",e[29]),E(t,"mouseleave",e[30])],D=!0)},p(e,t){(!F||16&t[0]&&!a(s.src,c=e[4]))&&S(s,"src",c),(!F||32&t[0]&&u!==(u=`nostr:${e[5]}`))&&S(i,"href",u),Y===(Y=W(e))&&X?X.p(e,t):(X.d(1),X=Y(e),X&&(X.c(),X.m(h,null))),(!F||512&t[0]&&f!==(f="rounded-full "+(e[9]>0?"opacity-100 text-base":"bg-orange-500 opacity-10 text-xl")+" w-8 h-8 flex items-center justify-center hover:opacity-100 svelte-f7jodf"))&&S(h,"class",f),e[6]?J?(J.p(e,t),64&t[0]&&Z(J,1)):(J=Cm(e),J.c(),Z(J,1),J.m(p,null)):J&&(K(),V(J,1,1,(()=>{J=null})),G()),(!F||64&t[0]&&m!==(m=(e[6]?"w-full rounded-full bg-white drop-shadow-xl justify-between border-2 border-gray-200":" rounded-full w-8 h-8 justify-center")+" flex items-center absolute ml-5 mt-10 z-10 svelte-f7jodf"))&&S(p,"class",m),(!F||1&t[0])&&q!==(q=e[0].content+"")&&O(I,q),(!F||2049&t[0]&&P!==(P="max-h-64 text-base cursor-pointer border border-slate-200 "+(e[11]===e[0].id?"bg-purple-700 text-white":"bg-white text-gray-900 hover:bg-slate-100")+" p-4 py-2 overflow-auto rounded-2xl shadow-sm svelte-f7jodf"))&&S(L,"class",P),ee.p(e,t),e[1][e[0].id].length>0?te?(te.p(e,t),3&t[0]&&Z(te,1)):(te=Pm(e),te.c(),Z(te,1),te.m(z.parentNode,z)):te&&(K(),V(te,1,1,(()=>{te=null})),G())},i(e){F||(Z(J),Z(te),F=!0)},o(e){V(J),V(te),F=!1},d(e){e&&b(t),X.d(),J&&J.d(),ee.d(),e&&b($),te&&te.d(e),e&&b(z),D=!1,r(H)}}}function Bm(e,t,n){let r,o,i,s,a,l;c(e,ue,(e=>n(16,o=e))),c(e,ie,(e=>n(31,i=e))),c(e,ce,(e=>n(3,s=e))),c(e,se,(e=>n(17,a=e))),c(e,ae,(e=>n(11,l=e)));let h,f,d,p,y,{event:g}=t,{responses:b}=t,{websiteOwnerPubkey:m}=t,w={},v=0;function _(){l===g.id?u(ae,l=null,l):u(ae,l=g.id,l)}L((()=>{i.delayedSubscribe({kinds:[1,42,9735],"#e":[g.id]},"responses",500)}));const x=!!m===g.pubkey;var E;i.on("zap",(()=>{n(9,v=o[g.id]?.reduce(((e,t)=>e+t.amount),0)||0)})),E=()=>{n(9,v=o[g.id]?.reduce(((e,t)=>e+t.amount),0)||0)},T().$$.after_update.push(E);let k=new Date(1e3*g.created_at);return e.$$set=e=>{"event"in e&&n(0,g=e.event),"responses"in e&&n(1,b=e.responses),"websiteOwnerPubkey"in e&&n(2,m=e.websiteOwnerPubkey)},e.$$.update=()=>{if(131072&e.$$.dirty[0]&&n(15,w=a.profiles),32769&e.$$.dirty[0]&&n(10,r=w[g.pubkey]&&w[g.pubkey].display_name||`[${g.pubkey.slice(0,6)}]`),9&e.$$.dirty[0]&&n(6,d=s===g.id),1&e.$$.dirty[0])try{n(5,f=Zo.npubEncode(g.pubkey))}catch(e){n(5,f=g.pubkey)}65537&e.$$.dirty[0]&&n(9,v=o[g.id]?.reduce(((e,t)=>e+t.amount),0)||0),32769&e.$$.dirty[0]&&n(4,h=w[g.pubkey]&&w[g.pubkey].picture||`https://robohash.org/${g.pubkey.slice(0,1)}.png?set=set1`)},[g,b,m,s,h,f,d,p,y,v,r,l,_,x,k,w,o,a,()=>u(ce,s=s===g.id?null:g.id,s),()=>{u(ce,s=null,s)},function(e){y=e,n(8,y)},function(e){y=e,n(8,y)},function(e){y=e,n(8,y)},function(e){y=e,n(8,y)},function(e){y=e,n(8,y)},function(e){y=e,n(8,y)},()=>{_(g.id)},()=>{_(g.id)},()=>{_(g.id)},()=>n(7,p=!0),()=>n(7,p=!1)]}class Nm extends ne{constructor(e){super(),te(this,e,Bm,Um,i,{event:0,responses:1,websiteOwnerPubkey:2},null,[-1,-1])}}var Mm={$:e=>"string"==typeof e?document.querySelector(e):e,extend:(...e)=>Object.assign(...e),cumulativeOffset(e){let t=0,n=0;do{t+=e.offsetTop||0,n+=e.offsetLeft||0,e=e.offsetParent}while(e);return{top:t,left:n}},directScroll:e=>e&&e!==document&&e!==document.body,scrollTop(e,t){let n=void 0!==t;return this.directScroll(e)?n?e.scrollTop=t:e.scrollTop:n?document.documentElement.scrollTop=document.body.scrollTop=t:window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0},scrollLeft(e,t){let n=void 0!==t;return this.directScroll(e)?n?e.scrollLeft=t:e.scrollLeft:n?document.documentElement.scrollLeft=document.body.scrollLeft=t:window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0}};const $m={container:"body",duration:500,delay:0,offset:0,easing:function(e){return e<.5?4*e*e*e:.5*Math.pow(2*e-2,3)+1},onStart:e,onDone:e,onAborting:e,scrollX:!1,scrollY:!0},zm=e=>{let{offset:t,duration:n,delay:r,easing:o,x:i=0,y:s=0,scrollX:a,scrollY:c,onStart:u,onDone:l,container:y,onAborting:g,element:b}=e;"function"==typeof t&&(t=t());var m=Mm.cumulativeOffset(y),w=b?Mm.cumulativeOffset(b):{top:s,left:i},v=Mm.scrollLeft(y),_=Mm.scrollTop(y),x=w.left-m.left+t,E=w.top-m.top+t,k=x-v,S=E-_;let O=!0,A=!1,C=h()+r,R=C+n;function T(e){e||(A=!0,u(b,{x:i,y:s}))}function L(e){!function(e,t,n){a&&Mm.scrollLeft(e,n),c&&Mm.scrollTop(e,t)}(y,_+S*e,v+k*e)}function I(){O=!1}return function(e){let t;0===d.size&&f(p),new Promise((n=>{d.add(t={c:e,f:n})}))}((e=>{if(!A&&e>=C&&T(!1),A&&e>=R&&(L(1),I(),l(b,{x:i,y:s})),!O)return g(b,{x:i,y:s}),!1;if(A){L(0+1*o((e-C)/n))}return!0})),T(r),L(0),I},Fm=e=>{if(e&&e!==document&&e!==document.body)return e.scrollHeight-e.offsetHeight;{let e=document.body,t=document.documentElement;return Math.max(e.scrollHeight,e.offsetHeight,t.clientHeight,t.scrollHeight,t.offsetHeight)}},Dm=e=>(e=(e=>{let t=Mm.extend({},$m,e);return t.container=Mm.$(t.container),t.element=Mm.$(t.element),t})(e),zm(Mm.extend(e,{element:null,y:Fm(e.container)})));function Hm(e,t,n){const r=e.slice();return r[27]=t[n],r}function qm(e,t,n){const r=e.slice();return r[30]=t[n],r[32]=n,r}function Wm(e){let t;return{c(){t=v(e[8])},m(e,n){g(e,t,n)},p(e,n){256&n[0]&&O(t,e[8])},d(e){e&&b(t)}}}function Km(e){let t,n;return{c(){t=w("span"),S(t,"class",n="inline-block rounded-full "+(e[6]>e[32]?"bg-green-500":"bg-gray-300")+" w-2 h-2 svelte-f7jodf")},m(e,n){g(e,t,n)},p(e,r){64&r[0]&&n!==(n="inline-block rounded-full "+(e[6]>e[32]?"bg-green-500":"bg-gray-300")+" w-2 h-2 svelte-f7jodf")&&S(t,"class",n)},d(e){e&&b(t)}}}function Gm(e){let t,n,r,o,i,s,a=e[5].name+"",c=e[5].picture&&Zm(e),u=e[5].about&&Vm(e);return{c(){t=w("div"),c&&c.c(),n=_(),r=w("div"),o=w("div"),i=v(a),s=_(),u&&u.c(),S(o,"class","font-extrabold text-xl svelte-f7jodf"),S(r,"class","flex flex-col svelte-f7jodf"),S(t,"class","flex flex-row gap-2 mb-3 bg-zinc-300 text-zinc-800 px-4 py-2 -mx-4 -mt-3 svelte-f7jodf")},m(e,a){g(e,t,a),c&&c.m(t,null),y(t,n),y(t,r),y(r,o),y(o,i),y(r,s),u&&u.m(r,null)},p(e,o){e[5].picture?c?c.p(e,o):(c=Zm(e),c.c(),c.m(t,n)):c&&(c.d(1),c=null),32&o[0]&&a!==(a=e[5].name+"")&&O(i,a),e[5].about?u?u.p(e,o):(u=Vm(e),u.c(),u.m(r,null)):u&&(u.d(1),u=null)},d(e){e&&b(t),c&&c.d(),u&&u.d()}}}function Zm(e){let t,n;return{c(){t=w("img"),a(t.src,n=e[5].picture)||S(t,"src",n),S(t,"class","w-12 h-12 rounded-full svelte-f7jodf")},m(e,n){g(e,t,n)},p(e,r){32&r[0]&&!a(t.src,n=e[5].picture)&&S(t,"src",n)},d(e){e&&b(t)}}}function Vm(e){let t,n,r=e[5].about+"";return{c(){t=w("div"),n=v(r),S(t,"class","text-sm truncate font-regular svelte-f7jodf")},m(e,r){g(e,t,r),y(t,n)},p(e,t){32&t[0]&&r!==(r=e[5].about+"")&&O(n,r)},d(e){e&&b(t)}}}function Ym(e){let t,n;function r(e,n){return 512&n[0]&&(t=null),null==t&&(t=!e[10](e[9])),t?Jm:Xm}let o=r(e,[-1,-1]),i=o(e);return{c(){i.c(),n=x()},m(e,t){i.m(e,t),g(e,n,t)},p(e,t){o===(o=r(e,t))&&i?i.p(e,t):(i.d(1),i=o(e),i&&(i.c(),i.m(n.parentNode,n)))},d(e){i.d(e),e&&b(n)}}}function Xm(e){let t,n,r,o,i,s,a,c,u=e[10](e[9]).content+"";return{c(){t=w("div"),n=w("a"),n.innerHTML='',r=_(),o=w("div"),i=w("span"),s=v(u),S(n,"href","#"),S(n,"class","svelte-f7jodf"),S(i,"class","text-lg text-black overflow-hidden whitespace-nowrap text-ellipsis svelte-f7jodf"),S(o,"class","flex flex-col ml-2 svelte-f7jodf"),S(t,"class","flex flex-row mb-3 svelte-f7jodf")},m(u,l){g(u,t,l),y(t,n),y(t,r),y(t,o),y(o,i),y(i,s),a||(c=E(n,"click",k(e[13])),a=!0)},p(e,t){512&t[0]&&u!==(u=e[10](e[9]).content+"")&&O(s,u)},d(e){e&&b(t),a=!1,c()}}}function Jm(e){let t,n,r;return{c(){t=w("h1"),n=v("Couldn't find event with ID "),r=v(e[9]),S(t,"class","svelte-f7jodf")},m(e,o){g(e,t,o),y(t,n),y(t,r)},p(e,t){512&t[0]&&O(r,e[9])},d(e){e&&b(t)}}}function Qm(e){let t,n,r=e[3],o=[];for(let t=0;tV(o[e],1,1,(()=>{o[e]=null}));return{c(){for(let e=0;e