dsnt-chat/static/public/bundle.js
2023-06-05 23:50:16 +02:00

21 lines
452 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

!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;n<e.length;n+=1)e[n]&&e[n].d(t)}function w(e){return document.createElement(e)}function v(e){return document.createTextNode(e)}function _(){return v(" ")}function x(){return v("")}function E(e,t,n,r){return e.addEventListener(t,n,r),()=>e.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<I.length;){const e=I[F];F++,R(e),H(e.$$)}}catch(e){throw I.length=0,F=0,e}for(R(null),I.length=0,F=0;P.length;)P.pop()();for(let e=0;e<j.length;e+=1){const t=j[e];z.has(t)||(z.add(t),t())}j.length=0}while(I.length);for(;U.length;)U.pop()();N=!1,z.clear(),R(e)}function H(e){if(null!==e.fragment){e.update(),r(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(M)}}const q=new Set;let W;function K(){W={r:0,c:[],p:W}}function G(){W.r||r(W.c),W=W.p}function Z(e,t){e&&e.i&&(q.delete(e),e.i(t))}function V(e,t,n,r){if(e&&e.o){if(q.has(e))return;q.add(e),W.c.push((()=>{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<<t%31}function te(t,o,i,s,a,c,u,l=[-1]){const h=C;R(t);const f=t.$$={fragment:null,ctx:[],props:c,update:e,not_equal:a,bound:n(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(o.context||(h?h.$$.context:[])),callbacks:n(),dirty:l,skip_bound:!1,root:o.target||h.$$.root};u&&u(f.root);let d=!1;if(f.ctx=i?i(t,o.props||{},((e,n,...r)=>{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<re.length;e+=2)re[e][0](re[e+1]);re.length=0}}}return{set:s,update:function(e){s(e(t))},subscribe:function(i,a=e){const c=[i,a];return o.add(c),1===o.size&&(r=n(s)||e),i(t),()=>{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.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}},de="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,pe=e=>new 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;n<e.length;n++)t+=ge[e[n]];return t}function me(e){if("string"!=typeof e)throw new TypeError("hexToBytes: expected string, got "+typeof e);if(e.length%2)throw new Error("hexToBytes: received invalid unpadded hex");const t=new Uint8Array(e.length/2);for(let n=0;n<t.length;n++){const r=2*n,o=e.slice(r,r+2),i=Number.parseInt(o,16);if(Number.isNaN(i)||i<0)throw new Error("Invalid byte sequence");t[n]=i}return t}function we(e){if("string"!=typeof e)throw new TypeError("utf8ToBytes expected string, got "+typeof e);return(new TextEncoder).encode(e)}function ve(e){if("string"==typeof e&&(e=we(e)),!(e instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof e})`);return e}function _e(...e){if(!e.every((e=>e 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;t<e.length;t++){const o=e[t];n.set(o,r),r+=o.length}return n}class xe{clone(){return this._cloneInto()}}function Ee(e){const t=t=>e().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;i<o;){const s=Math.min(r-this.pos,o-i);if(s!==r)n.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===r&&(this.process(t,0),this.pos=0);else{const t=pe(e);for(;r<=o-i;i+=r)this.process(t,i)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){fe.exists(this),fe.output(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:o}=this;let{pos:i}=this;t[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>r-i&&(this.process(n,0),i=0);for(let e=i;e<r;e++)t[e]=0;!function(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const o=BigInt(32),i=BigInt(4294967295),s=Number(n>>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;e<c;e++)s.setUint32(4*e,u[e],o)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:o,destroyed:i,pos:s}=this;return e.length=r,e.pos=s,e.finished=o,e.destroyed=i,r%t&&e.buffer.set(n),e}};const Oe=(e,t,n)=>e&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;n<e.length;n++)t+=Ne[e[n]];return t}function $e(e){const t=e.toString(16);return 1&t.length?`0${t}`:t}function ze(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":`0x${e}`)}function Fe(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(e.length%2)throw new Error("hex string is invalid: unpadded "+e.length);const t=new Uint8Array(e.length/2);for(let n=0;n<t.length;n++){const r=2*n,o=e.slice(r,r+2),i=Number.parseInt(o,16);if(Number.isNaN(i)||i<0)throw new Error("invalid byte sequence");t[n]=i}return t}function De(e){return ze(Me(e))}function He(e){if(!Be(e))throw new Error("Uint8Array expected");return ze(Me(Uint8Array.from(e).reverse()))}const qe=(e,t)=>Fe(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<<BigInt(e-1))-je,Ye=e=>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<t;){r=a();const t=r.slice();n.push(t),e+=r.length}return Ge(...n)};return(e,t)=>{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)<<BigInt(t),bytesToHex:Me,bytesToNumberBE:De,bytesToNumberLE:He,concatBytes:Ge,createHmacDrbg:Je,ensureBytes:Ke,equalBytes:function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},hexToBytes:Fe,hexToNumber:ze,numberToBytesBE:qe,numberToBytesLE:We,numberToHexUnpadded:$e,numberToVarBytesBE:e=>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<nt)throw new Error("Expected power/modulo > 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&&lt(o,t,e)!==e-rt;o++);if(1===r){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}}const i=(n+rt)/ot;return function(e,s){if(e.pow(s,t)===e.neg(e.ONE))throw new Error("Cannot find square root");let a=r,c=e.pow(e.mul(e.ONE,o),n),u=e.pow(s,i),l=e.pow(s,n);for(;!e.eql(l,e.ONE);){if(e.eql(l,e.ZERO))return e.ZERO;let t=1;for(let n=e.sqr(l);t<a&&!e.eql(n,e.ONE);t++)n=e.sqr(n);const n=e.pow(c,rt<<BigInt(a-t-1));c=e.sqr(n),u=e.mul(u,n),l=e.mul(l,c),a=t}return u}}(e)}BigInt(9),BigInt(16);const pt=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function yt(e){const t=pt.reduce(((e,t)=>(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&&Et<e&&e<t.n}function a(e){if(!s(e))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(e){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:o,n:i}=t;if(n&&"bigint"!=typeof e){if(e instanceof Uint8Array&&(e=Me(e)),"string"!=typeof e||!n.includes(e.length))throw new Error("Invalid key");e=e.padStart(2*r,"0")}let s;try{s="bigint"==typeof e?e:De(Ke("private key",e,r))}catch(t){throw new Error(`private key must be ${r} bytes, hex or bigint, not ${typeof e}`)}return o&&(s=ut(s,i)),a(s),s}const u=new Map;function l(e){if(!(e instanceof h))throw new Error("ProjectivePoint expected")}class h{constructor(e,t,r){if(this.px=e,this.py=t,this.pz=r,null==e||!n.isValid(e))throw new Error("x required");if(null==t||!n.isValid(t))throw new Error("y required");if(null==r||!n.isValid(r))throw new Error("z required")}static fromAffine(e){const{x:t,y:r}=e||{};if(!e||!n.isValid(t)||!n.isValid(r))throw new Error("invalid affine point");if(e instanceof h)throw new Error("projective point not allowed");const o=e=>n.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<n;e++){a=s,i.push(a);for(let e=1;e<o;e++)a=a.add(s),i.push(a);s=a.double()}return i},wNAF(t,o,i){const{windows:s,windowSize:a}=r(t);let c=e.ZERO,u=e.BASE;const l=BigInt(2**t-1),h=2**t,f=BigInt(t);for(let e=0;e<s;e++){const t=e*a;let r=Number(i&l);i>>=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)&&a<n.ORDER))throw new Error("Point is not on curve");const t=l(e);let o=n.sqrt(t);return 1==(1&r)!==((o&kt)===kt)&&(o=n.neg(o)),{x:e,y:o}}var a}}),f=e=>Me(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||r<o||r>1024)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&&e<v))throw new Error(`bigint expected < 2^${t.nBitLength}`);return qe(e,t.nByteLength)}function x(e,r,o=E){if(["recovered","canonical"].some((e=>e 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;e<o.length;e++)o[e]^=54;this.iHash.update(o),this.oHash=e.create();for(let e=0;e<o.length;e++)o[e]^=106;this.oHash.update(o),o.fill(0)}update(e){return fe.exists(this),this.iHash.update(e),this}digestInto(e){fe.exists(this),fe.bytes(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:o,blockLen:i,outputLen:s}=this;return e.finished=r,e.destroyed=o,e.blockLen=i,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Lt=(e,t,n)=>new 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&&t<e},is0:e=>e===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<nt)throw new Error("Expected power > 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&&Ft<e&&e<Pt,Ht={};function qt(e,...t){let n=Ht[e];if(void 0===n){const t=Ie(Uint8Array.from(e,(e=>e.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)&&Ft<u&&u<jt))return!1;const l=Jt(Kt(t),Wt(e),o),h=(s=e,a=n,c=Zt(-l),Vt.BASE.multiplyAndAddUnsafe(s,a,c));return!(!h||!h.hasEvenY()||h.toAffine().x!==t)}catch(e){return!1}var s,a,c,u}const en={getPublicKey:function(e){return Yt(e).bytes},sign:function(e,t,n=ke(32)){const r=Ke("message",e),{bytes:o,scalar:i}=Yt(t),s=Ke("auxRand",n,32),a=Kt(i^De(qt("BIP0340/aux",s))),c=qt("BIP0340/nonce",a,o,r),u=Zt(De(c));if(u===Ft)throw new Error("sign failed: k is zero");const{bytes:l,scalar:h}=Yt(u),f=Jt(l,o,r),d=new Uint8Array(64);if(d.set(l,0),d.set(Kt(Zt(h+f*i)),32),!Qt(d,r,o))throw new Error("sign: Invalid signature produced");return d},verify:Qt,utils:{randomPrivateKey:zt.utils.randomPrivateKey,lift_x:Xt,pointToBytes:Wt,numberToBytesBE:qe,bytesToNumberBE:De,taggedHash:qt,mod:ut}},tn=function(e,t){const n=t.map((e=>Array.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<i.length;o++){const a=i[o],c=t*e+a;if(!Number.isSafeInteger(c)||t*e/t!==e||c-a!=t*e)throw new Error("convertRadix: carry overflow");if(e=c%n,i[o]=Math.floor(c/n),!Number.isSafeInteger(i[o])||i[o]*n+e!==c)throw new Error("convertRadix: carry overflow");s&&(i[o]?s=!1:r=o)}if(o.push(e),s)break}for(let t=0;t<e.length-1&&0===e[t];t++)o.push(0);return o.reverse()}!function(e,t,n){if("function"!=typeof t)throw new Error("mapToCurve() must be defined")}(zt.ProjectivePoint,(e=>{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<<t|r,i+t>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<<n-i&s,!r&&i>=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<e.length;n+=8){const r=e.subarray(n,n+8);t+=_n.encode(r).padStart(xn[r.length],"1")}return t},decode(e){let t=[];for(let n=0;n<e.length;n+=11){const r=e.slice(n,n+11),o=xn.indexOf(r.length),i=_n.decode(r);for(let e=0;e<i.length-o;e++)if(0!==i[e])throw new Error("base58xmr: wrong padding");t=t.concat(Array.from(i.slice(i.length-o)))}return Uint8Array.from(t)}},kn=on(sn("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),an("")),Sn=[996825010,642813549,513874426,1027748829,705979059];function On(e){const t=e>>25;let n=(33554431&e)<<5;for(let e=0;e<Sn.length;e++)1==(t>>e&1)&&(n^=Sn[e]);return n}function An(e,t,n=1){const r=e.length;let o=1;for(let t=0;t<r;t++){const n=e.charCodeAt(t);if(n<33||n>126)throw new Error(`Invalid prefix (${e})`);o=On(o)^n>>5}o=On(o);for(let t=0;t<r;t++)o=On(o)^31&e.charCodeAt(t);for(let e of t)o=On(o)^e;for(let e=0;e<6;e++)o=On(o);return o^=n,kn.encode(dn([o%2**30],30,5,!1))}function Cn(e){const t="bech32"===e?1:734539939,n=pn(5),r=n.decode,o=n.encode,i=yn(r);function s(e,n=90){if("string"!=typeof e)throw new Error("bech32.decode input should be string, not "+typeof e);if(e.length<8||!1!==n&&e.length>n)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);const 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.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}Object.defineProperty(Bn,"__esModule",{value:!0}),Bn.output=Bn.exists=Bn.hash=Bn.bytes=Bn.bool=Bn.number=void 0,Bn.number=Nn,Bn.bool=Mn,Bn.bytes=$n,Bn.hash=zn,Bn.exists=Fn,Bn.output=Dn;const Hn={number:Nn,bool:Mn,bytes:$n,hash:zn,exists:Fn,output:Dn};Bn.default=Hn;var qn={},Wn={},Kn={},Gn={};Object.defineProperty(Gn,"__esModule",{value:!0}),Gn.crypto=void 0,Gn.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,function(e){
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
Object.defineProperty(e,"__esModule",{value:!0}),e.randomBytes=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.isLE=e.rotr=e.createView=e.u32=e.u8=void 0;const t=Gn;e.u8=e=>new 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.length;r++)t+=n[e[r]];return t},e.hexToBytes=function(e){if("string"!=typeof e)throw new TypeError("hexToBytes: expected string, got "+typeof e);if(e.length%2)throw new Error("hexToBytes: received invalid unpadded hex");const t=new Uint8Array(e.length/2);for(let n=0;n<t.length;n++){const r=2*n,o=e.slice(r,r+2),i=Number.parseInt(o,16);if(Number.isNaN(i)||i<0)throw new Error("Invalid byte sequence");t[n]=i}return t};function r(e){if("string"!=typeof e)throw new TypeError("utf8ToBytes expected string, got "+typeof e);return(new TextEncoder).encode(e)}function o(e){if("string"==typeof e&&(e=r(e)),!(e instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof e})`);return e}e.nextTick=async()=>{},e.asyncLoop=async function(t,n,r){let o=Date.now();for(let i=0;i<t;i++){r(i);const t=Date.now()-o;t>=0&&t<n||(await(0,e.nextTick)(),o+=t)}},e.utf8ToBytes=r,e.toBytes=o,e.concatBytes=function(...e){if(!e.every((e=>e 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;t<e.length;t++){const o=e[t];n.set(o,r),r+=o.length}return n};e.Hash=class{clone(){return this._cloneInto()}};e.checkOpts=function(e,t){if(void 0!==t&&("object"!=typeof t||(n=t,"[object Object]"!==Object.prototype.toString.call(n)||n.constructor!==Object)))throw new TypeError("Options should be object or undefined");var n;return Object.assign(e,t)},e.wrapConstructor=function(e){const t=t=>e().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;e<s.length;e++)s[e]^=54;this.iHash.update(s),this.oHash=e.create();for(let e=0;e<s.length;e++)s[e]^=106;this.oHash.update(s),s.fill(0)}update(e){return t.default.exists(this),this.iHash.update(e),this}digestInto(e){t.default.exists(this),t.default.bytes(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:o,blockLen:i,outputLen:s}=this;return e.finished=r,e.destroyed=o,e.blockLen=i,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}e.hmac=(e,t,n)=>new 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<i;e++,t+=a.outputLen){const n=s.subarray(t,t+a.outputLen);h.setInt32(0,e,!1),(u=c._cloneInto(u)).update(l).digestInto(f),n.set(f.subarray(0,n.length));for(let e=1;e<o;e++){a._cloneInto(u).update(f).digestInto(f);for(let e=0;e<n.length;e++)n[e]^=f[e]}}return Jn(a,c,s,u,f)},qn.pbkdf2Async=async function(e,t,n,r){const{c:o,dkLen:i,asyncTick:s,DK:a,PRF:c,PRFSalt:u}=Xn(e,t,n,r);let l;const h=new Uint8Array(4),f=(0,Yn.createView)(h),d=new Uint8Array(c.outputLen);for(let e=1,t=0;t<i;e++,t+=c.outputLen){const n=a.subarray(t,t+c.outputLen);f.setInt32(0,e,!1),(l=u._cloneInto(l)).update(h).digestInto(d),n.set(d.subarray(0,n.length)),await(0,Yn.asyncLoop)(o-1,s,(e=>{c._cloneInto(l).update(d).digestInto(d);for(let e=0;e<n.length;e++)n[e]^=d[e]}))}return Jn(c,u,a,l,d)};var Qn={},er={};Object.defineProperty(er,"__esModule",{value:!0}),er.SHA2=void 0;const tr=Bn,nr=Kn;er.SHA2=class extends nr.Hash{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=(0,nr.createView)(this.buffer)}update(e){tr.default.exists(this);const{view:t,buffer:n,blockLen:r}=this,o=(e=(0,nr.toBytes)(e)).length;for(let i=0;i<o;){const s=Math.min(r-this.pos,o-i);if(s!==r)n.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===r&&(this.process(t,0),this.pos=0);else{const t=(0,nr.createView)(e);for(;r<=o-i;i+=r)this.process(t,i)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){tr.default.exists(this),tr.default.output(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:o}=this;let{pos:i}=this;t[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>r-i&&(this.process(n,0),i=0);for(let e=i;e<r;e++)t[e]=0;!function(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const o=BigInt(32),i=BigInt(4294967295),s=Number(n>>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;e<c;e++)s.setUint32(4*e,u[e],o)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:o,destroyed:i,pos:s}=this;return e.length=r,e.pos=s,e.finished=o,e.destroyed=i,r%t&&e.buffer.set(n),e}},Object.defineProperty(Qn,"__esModule",{value:!0}),Qn.sha224=Qn.sha256=void 0;const rr=er,or=Kn,ir=(e,t,n)=>e&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;i<e.length;i++){const{h:s,l:a}=r(e[i],t);[n[i],o[i]]=[s,a]}return[n,o]}e.fromBig=r,e.split=o;e.toBig=(e,t)=>BigInt(e>>>0)<<n|BigInt(t>>>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<<n|t>>>32-n,rotlSL:(e,t,n)=>t<<n|e>>>32-n,rotlBH:(e,t,n)=>t<<n-32|e>>>64-n,rotlBL:(e,t,n)=>e<<n-32|t>>>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;i<s.length;i++){const a=s[i],c=n*e+a;if(!Number.isSafeInteger(c)||n*e/n!==e||c-a!=n*e)throw new Error("convertRadix: carry overflow");if(e=c%r,s[i]=Math.floor(c/r),!Number.isSafeInteger(s[i])||s[i]*r+e!==c)throw new Error("convertRadix: carry overflow");t&&(s[i]?t=!1:o=i)}if(i.push(e),t)break}for(let t=0;t<e.length-1&&0===e[t];t++)i.push(0);return i.reverse()}
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
Object.defineProperty(e,"__esModule",{value:!0}),e.bytes=e.stringToBytes=e.str=e.bytesToString=e.hex=e.utf8=e.bech32m=e.bech32=e.base58check=e.base58xmr=e.base58xrp=e.base58flickr=e.base58=e.base64url=e.base64=e.base32crockford=e.base32hex=e.base32=e.base16=e.utils=e.assertNumber=void 0,e.assertNumber=t;const c=(e,t)=>t?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<<n|o,s+n>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<<r-s&a,!o&&s>=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;t<e;t++)if(o[t]!==i[t])throw new Error("Invalid checksum");return r}}}e.utils={alphabet:r,chain:n,checksum:p,radix:h,radix2:f,join:o,padding:i},e.base16=n(f(4),r("0123456789ABCDEF"),o("")),e.base32=n(f(5),r("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),i(5),o("")),e.base32hex=n(f(5),r("0123456789ABCDEFGHIJKLMNOPQRSTUV"),i(5),o("")),e.base32crockford=n(f(5),r("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),o(""),s((e=>e.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;r<t.length;r+=8){const o=t.subarray(r,r+8);n+=e.base58.encode(o).padStart(g[o.length],"1")}return n},decode(t){let n=[];for(let r=0;r<t.length;r+=11){const o=t.slice(r,r+11),i=g.indexOf(o.length),s=e.base58.decode(o);for(let e=0;e<s.length-i;e++)if(0!==s[e])throw new Error("base58xmr: wrong padding");n=n.concat(Array.from(s.slice(s.length-i)))}return Uint8Array.from(n)}};e.base58check=t=>n(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<m.length;e++)1==(t>>e&1)&&(n^=m[e]);return n}function v(e,t,n=1){const r=e.length;let o=1;for(let t=0;t<r;t++){const n=e.charCodeAt(t);if(n<33||n>126)throw new Error(`Invalid prefix (${e})`);o=w(o)^n>>5}o=w(o);for(let t=0;t<r;t++)o=w(o)^31&e.charCodeAt(t);for(let e of t)o=w(o)^e;for(let e=0;e<6;e++)o=w(o);return o^=n,b.encode(l([o%2**30],30,5,!1))}function _(e){const t="bech32"===e?1:734539939,n=f(5),r=n.decode,o=n.encode,i=d(r);function s(e,n=90){if("string"!=typeof e)throw new Error("bech32.decode input should be string, not "+typeof e);if(e.length<8||!1!==n&&e.length>n)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);const 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<<t])};function Nr(e){if(!Array.isArray(e)||2048!==e.length||"string"!=typeof e[0])throw new Error("Worlist: expected array of 2048 strings");return e.forEach((e=>{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<<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;o<e.length;o++){const{h:i,l:s}=io(e[o],t);[n[o],r[o]]=[i,s]}return[n,r]},toBig:(e,t)=>BigInt(e>>>0)<<oo|BigInt(t>>>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<<n|t>>>32-n,rotlSL:(e,t,n)=>t<<n|e>>>32-n,rotlBH:(e,t,n)=>t<<n-32|e>>>64-n,rotlBL:(e,t,n)=>e<<n-32|t>>>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;t<e;t++)if(o[t]!==i[t])throw new Error("Invalid checksum");return r}}}(4,(t=>e(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[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_at>t.created_at)r=n;else{if(!(e[n].created_at<t.created_at)){i=n;break}o=n}}return e[i]?.id!==t.id?[...e.slice(0,i),t,...e.slice(i)]:e}function Po(e,t){let n,r=0,o=e.length-1,i=r;if(o<0)i=0;else if(t.created_at>e[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_at<t.created_at)r=n;else{if(!(e[n].created_at>t.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;t<e.tags.length;t++){let n=e.tags[t];if(!Array.isArray(n))return!1;for(let e=0;e<n.length;e++)if("object"==typeof n[e])return!1}return!0}function No(e){try{return en.verify(e.sig,Uo(e),e.pubkey)}catch(e){return!1}}function Mo(e,t){return console.warn("nostr-tools: `signEvent` is deprecated and will be removed or changed in the future. Please use `getSignature` instead."),$o(e,t)}function $o(e,t){return be(en.sign(Uo(e),t))}function zo(e,t){if(e.ids&&-1===e.ids.indexOf(t.id)&&!e.ids.some((e=>t.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.since)&&!(e.until&&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;n<e.length;n++)if(zo(e[n],t))return!0;return!1}(a[t].filters,n)&&(a[t],(u[t]?.event||[]).forEach((e=>e(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.length<r||(t[e]=t[e]||[],t[e].push(o))}return t}function Qo(e){return ni("nsec",e)}function ei(e){return ni("npub",e)}function ti(e){return ni("note",e)}function ni(e,t){let n=me(t),r=Rn.toWords(n);return Rn.encode(e,r,Vo)}function ri(e){let t=ai({0:[me(e.pubkey)],1:(e.relays||[]).map((e=>To.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<n.length;e++){const r=n[e],[o,i,s,a]=r,c={id:i,relays:s?[s]:[]},u=0===e,l=e===n.length-1;"root"!==a?"reply"!==a?"mention"!==a?u?t.root=c:l?t.reply=c:t.mentions.push(c):t.mentions.push(c):t.reply=c:t.root=c}return t}Oo({},{parse:()=>_i});function xi(e){return function(e){let t,n,r;for(n=0,t=0;n<e.length&&(r=Ei(e[n]),t+=r,8===r);n++);return t}(me(e))}function Ei(e){let t=0;if(0===e)return 8;for(;e>>=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<i.length;t++){let[n,r,o]=i[t].split(/\b/);if(("kind"!==n||"="!==r||e.kind!==parseInt(o))&&!("created_at"===n&&"<"===r&&e.created_at<parseInt(o)||"created_at"===n&&">"===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<n;++t)Vi[t]=e[t],Yi[e.charCodeAt(t)]=t;Yi["-".charCodeAt(0)]=62,Yi["_".charCodeAt(0)]=63}function es(e,t,n){for(var r,o,i=[],s=t;s<n;s+=3)r=(e[s]<<16)+(e[s+1]<<8)+e[s+2],i.push(Vi[(o=r)>>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;a<c;a+=s)i.push(es(e,a,a+s>c?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<<a)-1,u=c>>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<<u)-1,h=l>>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<<o|a,u+=o;u>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()<t)throw new RangeError("Invalid typed array length");return us.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=us.prototype:(null===e&&(e=new us(t)),e.length=t),e}function us(e,t,n){if(!(us.TYPED_ARRAY_SUPPORT||this instanceof us))return new us(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return fs(this,e)}return ls(this,e,t,n)}function ls(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r);us.TYPED_ARRAY_SUPPORT?(e=t).__proto__=us.prototype:e=ds(e,t);return e}(e,t,n,r):"string"==typeof t?function(e,t,n){"string"==typeof n&&""!==n||(n="utf8");if(!us.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|gs(t,n);e=cs(e,r);var o=e.write(t,n);o!==r&&(e=e.slice(0,o));return e}(e,t,n):function(e,t){if(ys(t)){var n=0|ps(t.length);return 0===(e=cs(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?cs(e,0):ds(e,t);if("Buffer"===t.type&&is(t.data))return ds(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function hs(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function fs(e,t){if(hs(t),e=cs(e,t<0?0:0|ps(t)),!us.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function ds(e,t){var n=t.length<0?0:0|ps(t.length);e=cs(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function ps(e){if(e>=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;i<a;i++)if(u(e,i)===u(t,-1===l?0:i-l)){if(-1===l&&(l=i),i-l+1===c)return l*s}else-1!==l&&(i-=i-l),l=-1}else for(n+c>a&&(n=a-c),i=n;i>=0;i--){for(var h=!0,f=0;f<c;f++)if(u(e,i+f)!==u(t,f)){h=!1;break}if(h)return i}return-1}function _s(e,t,n,r){n=Number(n)||0;var o=e.length-n;r?(r=Number(r))>o&&(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<r;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[n+s]=a}return s}function xs(e,t,n,r){return Ws(Hs(t,e.length-n),e,n,r)}function Es(e,t,n,r){return Ws(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function ks(e,t,n,r){return Es(e,t,n,r)}function Ss(e,t,n,r){return Ws(qs(t),e,n,r)}function Os(e,t,n,r){return Ws(function(e,t){for(var n,r,o,i=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(n=e.charCodeAt(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;o<n;){var i,s,a,c,u=e[o],l=null,h=u>239?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(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=Rs));return n}(r)}us.poolSize=8192,us._augment=function(e){return e.__proto__=us.prototype,e},us.from=function(e,t,n){return ls(null,e,t,n)},us.TYPED_ARRAY_SUPPORT&&(us.prototype.__proto__=Uint8Array.prototype,us.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&us[Symbol.species]),us.alloc=function(e,t,n){return function(e,t,n,r){return hs(t),t<=0?cs(e,t):void 0!==n?"string"==typeof r?cs(e,t).fill(n,r):cs(e,t).fill(n):cs(e,t)}(null,e,t,n)},us.allocUnsafe=function(e){return fs(null,e)},us.allocUnsafeSlow=function(e){return fs(null,e)},us.isBuffer=Ks,us.compare=function(e,t){if(!ys(e)||!ys(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,o=0,i=Math.min(n,r);o<i;++o)if(e[o]!==t[o]){n=e[o],r=t[o];break}return n<r?-1:r<n?1:0},us.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},us.concat=function(e,t){if(!is(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return us.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=us.allocUnsafe(t),o=0;for(n=0;n<e.length;++n){var i=e[n];if(!ys(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(r,o),o+=i.length}return r},us.byteLength=gs,us.prototype._isBuffer=!0,us.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)ms(this,t,t+1);return this},us.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)ms(this,t,t+3),ms(this,t+1,t+2);return this},us.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)ms(this,t,t+7),ms(this,t+1,t+6),ms(this,t+2,t+5),ms(this,t+3,t+4);return this},us.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?Cs(this,0,e):bs.apply(this,arguments)},us.prototype.equals=function(e){if(!ys(e))throw new TypeError("Argument must be a Buffer");return this===e||0===us.compare(this,e)},us.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+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;l<a;++l)if(c[l]!==u[l]){i=c[l],s=u[l];break}return i<s?-1:s<i?1:0},us.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},us.prototype.indexOf=function(e,t,n){return ws(this,e,t,n,!0)},us.prototype.lastIndexOf=function(e,t,n){return ws(this,e,t,n,!1)},us.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-t;if((void 0===n||n>o)&&(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;o<n;++o)r+=String.fromCharCode(127&e[o]);return r}function Ls(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(e[o]);return r}function Is(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var o="",i=t;i<n;++i)o+=Ds(e[i]);return o}function Ps(e,t,n){for(var r=e.slice(t,n),o="",i=0;i<r.length;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function js(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)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||t<i)throw new RangeError('"value" argument is out of bounds');if(n+r>e.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<i;++o)e[n+o]=(t&255<<8*(r?o:1-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<i;++o)e[n+o]=t>>>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),t<e&&(t=e),us.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=us.prototype;else{var o=t-e;n=new us(o,void 0);for(var i=0;i<o;++i)n[i]=this[i+e]}return n},us.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||js(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r},us.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||js(e,t,this.length);for(var r=this[e+--t],o=1;t>0&&(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<t&&(o*=256);)r+=this[e+i]*o;return r>=(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<n&&(o*=256);)this[t+i]=e/o&255;return t+n},us.prototype.writeUIntBE=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=n-1,i=1;for(this[t+o]=255&e;--o>=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<n&&(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.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<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=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<r-n&&(r=e.length-t+n);var o,i=r-n;if(this===e&&n<t&&t<r)for(o=i-1;o>=0;--o)e[o+t]=this[o+n];else if(i<1e3||!us.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)e[o+t]=this[o+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+i),t);return i},us.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var o=e.charCodeAt(0);o<256&&(e=o)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!us.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var i;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i<n;++i)this[i]=e;else{var s=ys(e)?e:Hs(new us(e,r).toString()),a=s.length;for(i=0;i<n-t;++i)this[i+t]=s[i%a]}return this};var Fs=/[^+\/0-9A-Za-z-_]/g;function Ds(e){return e<16?"0"+e.toString(16):e.toString(16)}function Hs(e,t){var n;t=t||1/0;for(var r=e.length,o=null,i=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&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<r;t+=4,n+=3)o=Yi[e.charCodeAt(t)]<<18|Yi[e.charCodeAt(t+1)]<<12|Yi[e.charCodeAt(t+2)]<<6|Yi[e.charCodeAt(t+3)],s[c++]=o>>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<r&&!(o+n>=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=[];++ra<t;)ea&&ea[ra].run();ra=-1,t=ta.length}ea=null,na=!1,function(e){if(Js===clearTimeout)return clearTimeout(e);if((Js===Ys||!Js)&&clearTimeout)return Js=clearTimeout,clearTimeout(e);try{Js(e)}catch(t){try{return Js.call(null,e)}catch(t){return Js.call(this,e)}}}(e)}}function sa(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];ta.push(new aa(e,t)),1!==ta.length||na||Qs(ia)}function aa(e,t){this.fun=e,this.array=t}aa.prototype.run=function(){this.fun.apply(null,this.array)};function ca(){}var ua=ca,la=ca,ha=ca,fa=ca,da=ca,pa=ca,ya=ca;var ga=Zi.performance||{},ba=ga.now||ga.mozNow||ga.msNow||ga.oNow||ga.webkitNow||function(){return(new Date).getTime()};var ma=new Date;var wa={nextTick:sa,title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:ua,addListener:la,once:ha,off:fa,removeListener:da,removeAllListeners:pa,emit:ya,binding:function(e){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(e){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(e){var t=.001*ba.call(ga),n=Math.floor(t),r=Math.floor(t%1*1e9);return e&&(n-=e[0],(r-=e[1])<0&&(n--,r+=1e9)),[n,r]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-ma)/1e3}};function va(){}function _a(){_a.init.call(this)}function xa(e){return void 0===e._maxListeners?_a.defaultMaxListeners:e._maxListeners}function Ea(e,t,n){if(t)e.call(n);else for(var r=e.length,o=La(e,r),i=0;i<r;++i)o[i].call(n)}function ka(e,t,n,r){if(t)e.call(n,r);else for(var o=e.length,i=La(e,o),s=0;s<o;++s)i[s].call(n,r)}function Sa(e,t,n,r,o){if(t)e.call(n,r,o);else for(var i=e.length,s=La(e,i),a=0;a<i;++a)s[a].call(n,r,o)}function Oa(e,t,n,r,o,i){if(t)e.call(n,r,o,i);else for(var s=e.length,a=La(e,s),c=0;c<s;++c)a[c].call(n,r,o,i)}function Aa(e,t,n,r){if(t)e.apply(n,r);else for(var o=e.length,i=La(e,o),s=0;s<o;++s)i[s].apply(n,r)}function Ca(e,t,n,r){var o,i,s,a;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((i=e._events)?(i.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),i=e._events),s=i[t]):(i=e._events=new va,e._eventsCount=0),s){if("function"==typeof s?s=i[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),!s.warned&&(o=xa(e))&&o>0&&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;i<r;i++)o[i-1]=arguments[i];Aa(n,l,this,o)}return!0},_a.prototype.addListener=function(e,t){return Ca(this,e,t,!1)},_a.prototype.on=_a.prototype.addListener,_a.prototype.prependListener=function(e,t){return Ca(this,e,t,!0)},_a.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,Ra(this,e,t)),this},_a.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,Ra(this,e,t)),this},_a.prototype.removeListener=function(e,t){var n,r,o,i,s;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[e]))return this;if(n===t||n.listener&&n.listener===t)0==--this._eventsCount?this._events=new va:(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(o=-1,i=n.length;i-- >0;)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;r<o;n+=1,r+=1)e[n]=e[r];e.pop()}(n,o);r.removeListener&&this.emit("removeListener",e,s||t)}return this},_a.prototype.off=function(e,t){return this.removeListener(e,t)},_a.prototype.removeAllListeners=function(e){var t,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new va,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new va:delete n[e]),this;if(0===arguments.length){for(var r,o=Object.keys(n),i=0;i<o.length;++i)"removeListener"!==(r=o[i])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=new va,this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},_a.prototype.listeners=function(e){var t,n=this._events;return n&&(t=n[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(t):[]},_a.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Ta.call(e,t)},_a.prototype.listenerCount=Ta,_a.prototype.eventNames=function(){return this._eventsCount>0?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<arguments.length;n++)t.push(Xa(arguments[n]));return t.join(" ")}n=1;for(var r=arguments,o=r.length,i=String(e).replace(Ka,(function(e){if("%%"===e)return"%";if(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<o;s=r[++n])oc(s)||!cc(s)?i+=" "+s:i+=" "+Xa(s);return i}function Za(e,t){if(sc(Zi.process))return function(){return Za(e,t).apply(this,arguments)};if(!0===wa.noDeprecation)return e;var n=!1;return function(){if(!n){if(wa.throwDeprecation)throw new Error(t);wa.traceDeprecation?console.trace(t):console.error(t),n=!0}return e.apply(this,arguments)}}var Va,Ya={};function Xa(e,t){var n={seen:[],stylize:Qa};return arguments.length>=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;s<a;++s)pc(t,String(s))?i.push(nc(e,t,n,r,String(s),!0)):i.push("");return o.forEach((function(o){o.match(/^\d+$/)||i.push(nc(e,t,n,r,o,!0))})),i}(e,t,n,s,i):i.map((function(r){return nc(e,t,n,s,r,h)})),e.seen.pop(),function(e,t,n){var r=e.reduce((function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0);if(r>60)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<this.charLength)return"";if(e=e.slice(n,e.length),!((o=(t=this.charBuffer.slice(0,this.charLength).toString(this.encoding)).charCodeAt(t.length-1))>=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.length<e.highWaterMark||0===e.length)}(t)}Wa(Ec,_a),Ec.prototype.push=function(e,t){var n=this._readableState;return n.objectMode||"string"!=typeof e||(t=t||n.defaultEncoding)!==n.encoding&&(e=us.from(e,t),t=""),kc(this,n,e,t,!1)},Ec.prototype.unshift=function(e){return kc(this,this._readableState,e,"",!0)},Ec.prototype.isPaused=function(){return!1===this._readableState.flowing},Ec.prototype.setEncoding=function(e){return this._readableState.decoder=new bc(e),this._readableState.encoding=e,this};var Sc=8388608;function Oc(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.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.highWaterMark&&(_c("maybeReadMore read 0"),e.read(0),n!==t.length);)n=t.length;t.readingMore=!1}function Tc(e){_c("readable nexttick read 0"),e.read(0)}function Lc(e,t){t.reading||(_c("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),Ic(e),t.flowing&&!t.reading&&e.read(0)}function Ic(e){var t=e._readableState;for(_c("flow",t.flowing);t.flowing&&null!==e.read(););}function Pc(e,t){return 0===t.length?null:(t.objectMode?n=t.buffer.shift():!e||e>=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;e<t.head.data.length?(r=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):r=e===t.head.data.length?t.shift():n?function(e,t){var n=t.head,r=1,o=n.data;e-=o.length;for(;n=n.next;){var i=n.data,s=e>i.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<r;n++)if(e[n]===t)return n;return-1}function Nc(){}function Mc(e,t,n){this.chunk=e,this.encoding=t,this.callback=n,this.next=null}function $c(e,t){Object.defineProperty(this,"buffer",{get:Za((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")}),e=e||{},this.objectMode=!!e.objectMode,t instanceof Xc&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var n=e.highWaterMark,r=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:r,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var o=!1===e.decodeStrings;this.decodeStrings=!o,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var n=e._writableState,r=n.sync,o=n.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(n),t)!function(e,t,n,r,o){--t.pendingcb,n?sa(o,r):o(r);e._writableState.errorEmitted=!0,e.emit("error",r)}(e,n,r,t,o);else{var i=qc(n);i||n.corked||n.bufferProcessing||!n.bufferedRequest||Hc(e,n),r?sa(Dc,e,n,i,o):Dc(e,n,i,o)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new Gc(this)}function zc(e){if(!(this instanceof zc||this instanceof Xc))return new zc(e);this._writableState=new $c(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev)),_a.call(this)}function Fc(e,t,n,r,o,i,s){t.writelen=r,t.writecb=s,t.writing=!0,t.sync=!0,n?e._writev(o,t.onwrite):e._write(o,i,t.onwrite),t.sync=!1}function Dc(e,t,n,r){n||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,r(),Kc(e,t)}function Hc(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var r=t.bufferedRequestCount,o=new Array(r),i=t.corkedRequestsFree;i.entry=n;for(var s=0;n;)o[s]=n,n=n.next,s+=1;Fc(e,t,!0,t.length,o,"",i.finish),t.pendingcb++,t.lastBufferedRequest=null,i.next?(t.corkedRequestsFree=i.next,i.next=null):t.corkedRequestsFree=new Gc(t)}else{for(;n;){var a=n.chunk,c=n.encoding,u=n.callback;if(Fc(e,t,!1,t.objectMode?1:a.length,a,c,u),n=n.next,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequestCount=0,t.bufferedRequest=n,t.bufferProcessing=!1}function qc(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function Wc(e,t){t.prefinished||(t.prefinished=!0,e.emit("prefinish"))}function Kc(e,t){var n=qc(t);return n&&(0===t.pendingcb?(Wc(e,t),t.finished=!0,e.emit("finish")):Wc(e,t)),n}function Gc(e){var t=this;this.next=null,this.entry=null,this.finish=function(n){var r=t.entry;for(t.entry=null;r;){var o=r.callback;e.pendingcb--,o(n),r=r.next}e.corkedRequestsFree?e.corkedRequestsFree.next=t:e.corkedRequestsFree=t}}Ec.prototype.read=function(e){_c("read",e),e=parseInt(e,10);var t=this._readableState,n=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=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-e<t.highWaterMark)&&_c("length less than watermark",o=!0),t.ended||t.reading?_c("reading or ended",o=!1):o&&(_c("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=Oc(n,t))),null===(r=e>0?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<r;o++)n[o].emit("unpipe",this);return this}var i=Bc(t.pipes,e);return-1===i||(t.pipes.splice(i,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this)),this},Ec.prototype.on=function(e,t){var n=_a.prototype.on.call(this,e,t);if("data"===e)!1!==this._readableState.flowing&&this.resume();else if("readable"===e){var r=this._readableState;r.endEmitted||r.readableListening||(r.readableListening=r.needReadable=!0,r.emittedReadable=!1,r.reading?r.length&&Ac(this):sa(Tc,this))}return n},Ec.prototype.addListener=Ec.prototype.on,Ec.prototype.resume=function(){var e=this._readableState;return e.flowing||(_c("resume"),e.flowing=!0,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,sa(Lc,e,t))}(this,e)),this},Ec.prototype.pause=function(){return _c("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(_c("pause"),this._readableState.flowing=!1,this.emit("pause")),this},Ec.prototype.wrap=function(e){var t=this._readableState,n=!1,r=this;for(var o in e.on("end",(function(){if(_c("wrapped end"),t.decoder&&!t.ended){var e=t.decoder.end();e&&e.length&&r.push(e)}r.push(null)})),e.on("data",(function(o){(_c("wrapped data"),t.decoder&&(o=t.decoder.write(o)),t.objectMode&&null==o)||(t.objectMode||o&&o.length)&&(r.push(o)||(n=!0,e.pause()))})),e)void 0===this[o]&&"function"==typeof e[o]&&(this[o]=function(t){return function(){return e[t].apply(e,arguments)}}(o));return function(e,t){for(var n=0,r=e.length;n<r;n++)t(e[n],n)}(["error","close","destroy","pause","resume"],(function(t){e.on(t,r.emit.bind(r,t))})),r._read=function(t){_c("wrapped _read",t),n&&(n=!1,e.resume())},r},Ec._fromList=Pc,zc.WritableState=$c,Wa(zc,_a),$c.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},zc.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},zc.prototype.write=function(e,t,n){var r=this._writableState,o=!1;return"function"==typeof t&&(n=t,t=null),us.isBuffer(e)?t="buffer":t||(t=r.defaultEncoding),"function"!=typeof n&&(n=Nc),r.ended?function(e,t){var n=new Error("write after end");e.emit("error",n),sa(t,n)}(this,n):function(e,t,n,r){var o=!0,i=!1;return null===n?i=new TypeError("May not write null values to stream"):us.isBuffer(n)||"string"==typeof n||void 0===n||t.objectMode||(i=new TypeError("Invalid non-string/buffer chunk")),i&&(e.emit("error",i),sa(r,i),o=!1),o}(this,r,e,n)&&(r.pendingcb++,o=function(e,t,n,r,o){n=function(e,t,n){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=us.from(t,n));return t}(t,n,r),us.isBuffer(n)&&(r="buffer");var i=t.objectMode?1:n.length;t.length+=i;var s=t.length<t.highWaterMark;s||(t.needDrain=!0);if(t.writing||t.corked){var a=t.lastBufferedRequest;t.lastBufferedRequest=new Mc(n,r,o),a?a.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else Fc(e,t,!1,i,n,r,o);return s}(this,r,e,t,n)),o},zc.prototype.cork=function(){this._writableState.corked++},zc.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||Hc(this,e))},zc.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-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;Vc<Zc.length;Vc++){var Yc=Zc[Vc];Xc.prototype[Yc]||(Xc.prototype[Yc]=zc.prototype[Yc])}function Xc(e){if(!(this instanceof Xc))return new Xc(e);Ec.call(this,e),zc.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",Jc)}function Jc(){this.allowHalfOpen||this._writableState.ended||sa(Qc,this)}function Qc(e){e.end()}function eu(e){this.afterTransform=function(t,n){return function(e,t,n){var r=e._transformState;r.transforming=!1;var o=r.writecb;if(!o)return e.emit("error",new Error("no writecb in Transform class"));r.writechunk=null,r.writecb=null,null!=n&&e.push(n);o(t);var i=e._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&e._read(i.highWaterMark)}(e,t,n)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null,this.writeencoding=null}function tu(e){if(!(this instanceof tu))return new tu(e);Xc.call(this,e),this._transformState=new eu(this);var t=this;this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.once("prefinish",(function(){"function"==typeof this._flush?this._flush((function(e){nu(t,e)})):nu(t)}))}function nu(e,t){if(t)return e.emit("error",t);var n=e._writableState,r=e._transformState;if(n.length)throw new Error("Calling transform done when ws.length != 0");if(r.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}function ru(e){if(!(this instanceof ru))return new ru(e);tu.call(this,e)}function ou(){_a.call(this)}Wa(tu,Xc),tu.prototype.push=function(e,t){return this._transformState.needTransform=!1,Xc.prototype.push.call(this,e,t)},tu.prototype._transform=function(e,t,n){throw new Error("Not implemented")},tu.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var o=this._readableState;(r.needTransform||o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}},tu.prototype._read=function(e){var t=this._transformState;null!==t.writechunk&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0},Wa(ru,tu),ru.prototype._transform=function(e,t,n){n(null,e)},Wa(ou,_a),ou.Readable=Ec,ou.Writable=zc,ou.Duplex=Xc,ou.Transform=tu,ou.PassThrough=ru,ou.Stream=ou,ou.prototype.pipe=function(e,t){var n=this;function r(t){e.writable&&!1===e.write(t)&&n.pause&&n.pause()}function o(){n.readable&&n.resume&&n.resume()}n.on("data",r),e.on("drain",o),e._isStdio||t&&!1===t.end||(n.on("end",s),n.on("close",a));var i=!1;function s(){i||(i=!0,e.end())}function a(){i||(i=!0,"function"==typeof e.destroy&&e.destroy())}function c(e){if(u(),0===_a.listenerCount(this,"error"))throw e}function u(){n.removeListener("data",r),e.removeListener("drain",o),n.removeListener("end",s),n.removeListener("close",a),n.removeListener("error",c),e.removeListener("error",c),n.removeListener("end",u),n.removeListener("close",u),e.removeListener("close",u)}return n.on("error",c),e.on("error",c),n.on("end",u),n.on("close",u),e.on("close",u),e.emit("pipe",n),e};var iu=Object.freeze({__proto__:null,Duplex:Xc,PassThrough:ru,Readable:Ec,Stream:ou,Transform:tu,Writable:zc,default:ou}),su=3,au=4;function cu(e,t,n){var r,o=this;if(Ec.call(o),o._mode=n,o.headers={},o.rawHeaders=[],o.trailers={},o.rawTrailers=[],o.on("end",(function(){wa.nextTick((function(){o.emit("close")}))})),"fetch"===n){o._fetchResponse=t,o.url=t.url,o.statusCode=t.status,o.statusMessage=t.statusText;for(var i,s,a=t.headers[Symbol.iterator]();i=(s=a.next()).value,!s.done;)o.headers[i[0].toLowerCase()]=i[1],o.rawHeaders.push(i[0],i[1]);var c=t.body.getReader();(r=function(){c.read().then((function(e){o._destroyed||(e.done?o.push(null):(o.push(new us(e.value)),r()))}))})()}else{if(o._xhr=e,o._pos=0,o.url=e.responseURL,o.statusCode=e.status,o.statusMessage=e.statusText,e.getAllResponseHeaders().split(/\r?\n/).forEach((function(e){var t=e.match(/^([^:]+):\s*(.*)/);if(t){var n=t[1].toLowerCase();"set-cookie"===n?(void 0===o.headers[n]&&(o.headers[n]=[]),o.headers[n].push(t[2])):void 0!==o.headers[n]?o.headers[n]+=", "+t[2]:o.headers[n]=t[2],o.rawHeaders.push(t[1],t[2])}})),o._charset="x-user-defined",!Da){var u=o.rawHeaders["mime-type"];if(u){var l=u.match(/;\s*charset=([^;])(;|$)/);l&&(o._charset=l[1].toLowerCase())}o._charset||(o._charset="utf-8")}}}function uu(e){var t,n=this;zc.call(n),n._opts=e,n._body=[],n._headers={},e.auth&&n.setHeader("Authorization","Basic "+new us(e.auth).toString("base64")),Object.keys(e.headers).forEach((function(t){n.setHeader(t,e.headers[t])}));var r=!0;if("disable-fetch"===e.mode)r=!1,t=!0;else if("prefer-streaming"===e.mode)t=!1;else if("allow-wrong-content-type"===e.mode)t=!Da;else{if(e.mode&&"default"!==e.mode&&"prefer-fast"!==e.mode)throw new Error("Invalid value for opts.mode");t=!0}n._mode=function(e,t){return Ua&&t?"fetch":Fa?"moz-chunked-arraybuffer":za?"ms-stream":$a&&e?"arraybuffer":Ha&&e?"text:vbarray":"text"}(t,r),n.on("finish",(function(){n._onFinish()}))}Wa(cu,Ec),cu.prototype._read=function(){},cu.prototype._onXHRProgress=function(){var e=this,t=e._xhr,n=null;switch(e._mode){case"text:vbarray":if(t.readyState!==au)break;try{n=new Zi.VBArray(t.responseBody).toArray()}catch(e){}if(null!==n){e.push(new us(n));break}case"text":try{n=t.responseText}catch(t){e._mode="text:vbarray";break}if(n.length>e._pos){var r=n.substr(e._pos);if("x-user-defined"===e._charset){for(var o=new us(r.length),i=0;i<r.length;i++)o[i]=255&r.charCodeAt(i);e.push(o)}else e.push(r,e._charset);e._pos=n.length}break;case"arraybuffer":if(t.readyState!==au||!t.response)break;n=t.response,e.push(new us(new Uint8Array(n)));break;case"moz-chunked-arraybuffer":if(n=t.response,t.readyState!==su||!n)break;e.push(new us(new Uint8Array(n)));break;case"ms-stream":if(n=t.response,t.readyState!==su)break;var s=new Zi.MSStreamReader;s.onprogress=function(){s.result.byteLength>e._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<n;r++)t[r]=e[r];return t.buffer}throw new Error("Argument must be a Buffer")}(e)})),{type:(r["content-type"]||{}).value||""}):us.concat(e._body).toString()),"fetch"===e._mode){var o=Object.keys(r).map((function(e){return[r[e].name,r[e].value]}));Zi.fetch(e._opts.url,{method:e._opts.method,headers:o,body:t,mode:"cors",credentials:n.withCredentials?"include":"same-origin"}).then((function(t){e._fetchResponse=t,e._connect()}),(function(t){e.emit("error",t)}))}else{var i=e._xhr=new Zi.XMLHttpRequest;try{i.open(e._opts.method,e._opts.url,!0)}catch(t){return void wa.nextTick((function(){e.emit("error",t)}))}"responseType"in i&&(i.responseType=e._mode.split(":")[0]),"withCredentials"in i&&(i.withCredentials=!!n.withCredentials),"text"===e._mode&&"overrideMimeType"in i&&i.overrideMimeType("text/plain; charset=x-user-defined"),Object.keys(r).forEach((function(e){i.setRequestHeader(r[e].name,r[e].value)})),e._response=null,i.onreadystatechange=function(){switch(i.readyState){case su:case au:e._onXHRProgress()}},"moz-chunked-arraybuffer"===e._mode&&(i.onprogress=function(){e._onXHRProgress()}),i.onerror=function(){e._destroyed||e.emit("error",new Error("XHR error"))};try{i.send(t)}catch(t){return void wa.nextTick((function(){e.emit("error",t)}))}}}},uu.prototype._onXHRProgress=function(){var e=this;(function(e){try{var t=e.status;return null!==t&&0!==t}catch(e){return!1}})(e._xhr)&&!e._destroyed&&(e._response||e._connect(),e._response._onXHRProgress())},uu.prototype._connect=function(){var e=this;e._destroyed||(e._response=new cu(e._xhr,e._fetchResponse,e._mode),e.emit("response",e._response))},uu.prototype._write=function(e,t,n){this._body.push(e),n()},uu.prototype.abort=uu.prototype.destroy=function(){var e=this;e._destroyed=!0,e._response&&(e._response._destroyed=!0),e._xhr&&e._xhr.abort()},uu.prototype.end=function(e,t,n){"function"==typeof e&&(n=e,e=void 0),zc.prototype.end.call(this,e,t,n)},uu.prototype.flushHeaders=function(){},uu.prototype.setTimeout=function(){},uu.prototype.setNoDelay=function(){},uu.prototype.setSocketKeepAlive=function(){};
/*! https://mths.be/punycode v1.4.1 by @mathias */
var hu=2147483647,fu=/[^\x20-\x7E]/,du=/[\x2E\u3002\uFF0E\uFF61]/g,pu={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 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<i;)(t=e.charCodeAt(o++))>=55296&&t<=56319&&o<i?56320==(64512&(n=e.charCodeAt(o++)))?r.push(((1023&t)<<10)+(1023&n)+65536):(r.push(t),o--):r.push(t);return r}(e),f=e.length,t=128,n=0,i=72,s=0;s<f;++s)(h=e[s])<128&&g.push(gu(h));for(r=o=g.length,o&&g.push("-");r<f;){for(a=hu,s=0;s<f;++s)(h=e[s])>=t&&h<a&&(a=h);for(a-t>yu((hu-n)/(d=r+1))&&bu("overflow"),n+=(a-t)*d,t=a,s=0;s<f;++s)if((h=e[s])<t&&++n>hu&&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;r<e.length;r++)n.push(t(e[r],r));return n}var Su=Object.keys||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t};function Ou(e,t,n,r){t=t||"&",n=n||"=";var o={};if("string"!=typeof e||0===e.length)return o;var i=/\+/g;e=e.split(t);var s=1e3;r&&"number"==typeof r.maxKeys&&(s=r.maxKeys);var a=e.length;s>0&&a>s&&(a=s);for(var c=0;c<a;++c){var u,l,h,f,d=e[c].replace(i,"%20"),p=d.indexOf(n);p>=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&&o<t.indexOf("#")?"?":"#",s=t.split(i);s[0]=s[0].replace(/\\/g,"/");var a=t=s.join(i);if(a=a.trim(),!r&&1===t.split("#").length){var c=Pu.exec(a);if(c)return e.path=a,e.href=a,e.pathname=c[1],c[2]?(e.search=c[2],e.query=n?Ou(e.search.substr(1)):e.search.substr(1)):n&&(e.search="",e.query={}),e}var u,l,h,f,d=Lu.exec(a);if(d){var p=(d=d[0]).toLowerCase();e.protocol=p,a=a.substr(d.length)}if(r||d||a.match(/^\/\/[^@\/]+@[^@\/]+/)){var y="//"===a.substr(0,2);!y||d&&Fu[d]||(a=a.substr(2),e.slashes=!0)}if(!Fu[d]&&(y||d&&!Du[d])){var g,b,m=-1;for(u=0;u<Nu.length;u++)-1!==(l=a.indexOf(Nu[u]))&&(-1===m||l<m)&&(m=l);for(-1!==(b=-1===m?a.lastIndexOf("@"):a.lastIndexOf("@",m))&&(g=a.slice(0,b),a=a.slice(b+1),e.auth=decodeURIComponent(g)),m=-1,u=0;u<Bu.length;u++)-1!==(l=a.indexOf(Bu[u]))&&(-1===m||l<m)&&(m=l);-1===m&&(m=a.length),e.host=a.slice(0,m),a=a.slice(m),Yu(e),e.hostname=e.hostname||"";var w="["===e.hostname[0]&&"]"===e.hostname[e.hostname.length-1];if(!w){var v=e.hostname.split(/\./);for(u=0,h=v.length;u<h;u++){var _=v[u];if(_&&!_.match(Mu)){for(var x="",E=0,k=_.length;E<k;E++)_.charCodeAt(E)>127?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;u<h;u++){var R=Uu[u];if(-1!==a.indexOf(R)){var T=encodeURIComponent(R);T===R&&(T=escape(R)),a=a.split(R).join(T)}}var L=a.indexOf("#");-1!==L&&(e.hash=a.substr(L),a=a.slice(0,L));var I=a.indexOf("?");if(-1!==I?(e.search=a.substr(I),e.query=a.substr(I+1),n&&(e.query=Ou(e.query)),a=a.slice(0,I)):n&&(e.search="",e.query={}),a&&(e.pathname=a),Du[p]&&e.hostname&&!e.pathname&&(e.pathname="/"),e.pathname||e.search){f=e.pathname||"";var P=e.search||"";e.path=f+P}return e.href=Gu(e),e}function Wu(e){if("string"==typeof e)e=(new Tu).parse(e);else if(!(e instanceof Tu))throw new TypeError('The "path" argument must be of type string or an instance of URL. Received type '+typeof e+String(e));if("file:"!==e.protocol)throw new TypeError("The URL must be of scheme file");return function(e){const t=e.pathname;for(let e=0;e<t.length;e++)if("%"===t[e]){const n=32|t.codePointAt(e+2);if("2"===t[e+1]&&102===n)throw new TypeError("must not include encoded / characters")}return decodeURIComponent(t)}(e)}function Ku(e){return ic(e)&&(e=qu({},e)),Gu(e)}function Gu(e){var t=e.auth||"";t&&(t=(t=encodeURIComponent(t)).replace(/%3A/i,":"),t+="@");var n=e.protocol||"",r=e.pathname||"",o=e.hash||"",i=!1,s="";e.host?i=t+e.host:e.hostname&&(i=t+(-1===e.hostname.indexOf(":")?e.hostname:"["+this.hostname+"]"),e.port&&(i+=":"+e.port)),e.query&&cc(e.query)&&Object.keys(e.query).length&&(s=function(e,t,n,r){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"==typeof e?ku(Su(e),(function(r){var o=encodeURIComponent(Eu(r))+n;return xu(e[r])?ku(e[r],(function(e){return o+encodeURIComponent(Eu(e))})).join(t):o+encodeURIComponent(Eu(e[r]))})).join(t):r?encodeURIComponent(Eu(r))+n+encodeURIComponent(Eu(e)):""}(e.query));var a=e.search||s&&"?"+s||"";return n&&":"!==n.substr(-1)&&(n+=":"),e.slashes||(!n||Du[n])&&!1!==i?(i="//"+(i||""),r&&"/"!==r.charAt(0)&&(r="/"+r)):i||(i=""),o&&"#"!==o.charAt(0)&&(o="#"+o),a&&"?"!==a.charAt(0)&&(a="?"+a),n+i+(r=r.replace(/[?#]/g,(function(e){return encodeURIComponent(e)})))+(a=a.replace("#","%23"))+o}function Zu(e,t){return Hu(e,!1,!0).resolve(t)}function Vu(e,t){return e?Hu(e,!1,!0).resolveObject(t):t}function Yu(e){var t=e.host,n=Iu.exec(t);n&&(":"!==(n=n[0])&&(e.port=n.substr(1)),t=t.substr(0,t.length-n.length)),t&&(e.hostname=t)}Tu.prototype.parse=function(e,t,n){return qu(this,e,t,n)},Tu.prototype.format=function(){return Gu(this)},Tu.prototype.resolve=function(e){return this.resolveObject(Hu(e,!1,!0)).format()},Tu.prototype.resolveObject=function(e){if(ic(e)){var t=new Tu;t.parse(e,!1,!0),e=t}for(var n,r=new Tu,o=Object.keys(this),i=0;i<o.length;i++){var s=o[i];r[s]=this[s]}if(r.hash=e.hash,""===e.href)return r.href=r.format(),r;if(e.slashes&&!e.protocol){for(var a=Object.keys(e),c=0;c<a.length;c++){var u=a[c];"protocol"!==u&&(r[u]=e[u])}return Du[r.protocol]&&r.hostname&&!r.pathname&&(r.path=r.pathname="/"),r.href=r.format(),r}if(e.protocol&&e.protocol!==r.protocol){if(!Du[e.protocol]){for(var l=Object.keys(e),h=0;h<l.length;h++){var f=l[h];r[f]=e[f]}return r.href=r.format(),r}if(r.protocol=e.protocol,e.host||Fu[e.protocol])r.pathname=e.pathname;else{for(n=(e.pathname||"").split("/");n.length&&!(e.host=n.shift()););e.host||(e.host=""),e.hostname||(e.hostname=""),""!==n[0]&&n.unshift(""),n.length<2&&n.unshift(""),r.pathname=n.join("/")}if(r.search=e.search,r.query=e.query,r.host=e.host||"",r.auth=e.auth,r.hostname=e.hostname||e.host,r.port=e.port,r.pathname||r.search){var d=r.pathname||"",p=r.search||"";r.path=d+p}return r.slashes=r.slashes||e.slashes,r.href=r.format(),r}var y,g=r.pathname&&"/"===r.pathname.charAt(0),b=e.host||e.pathname&&"/"===e.pathname.charAt(0),m=b||g||r.host&&e.pathname,w=m,v=r.pathname&&r.pathname.split("/")||[],_=r.protocol&&!Du[r.protocol];if(n=e.pathname&&e.pathname.split("/")||[],_&&(r.hostname="",r.port=null,r.host&&(""===v[0]?v[0]=r.host:v.unshift(r.host)),r.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===n[0]?n[0]=e.host:n.unshift(e.host)),e.host=null),m=m&&(""===n[0]||""===v[0])),b)r.host=e.host||""===e.host?e.host:r.host,r.hostname=e.hostname||""===e.hostname?e.hostname:r.hostname,r.search=e.search,r.query=e.query,v=n;else if(n.length)v||(v=[]),v.pop(),v=v.concat(n),r.search=e.search,r.query=e.query;else if(null!=e.search)return _&&(r.hostname=r.host=v.shift(),(y=!!(r.host&&r.host.indexOf("@")>0)&&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<r;i++)e[o+i]=t[n+i]}var vl=Uint8Array,_l=Uint16Array,xl=Int32Array;function El(e){for(var t=e.length;--t>=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<<e.bi_valid&65535,ql(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)}function Kl(e,t,n){Wl(e,n[2*t],n[2*t+1])}function Gl(e,t){var n=0;do{n|=1&e,e>>>=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;t<Sl;t++)e.dyn_ltree[2*t]=0;for(t=0;t<Ol;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function Yl(e){e.bi_valid>8?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]<e[i]||e[o]===e[i]&&r[t]<=r[n]}function Jl(e,t,n){for(var r=e.heap[n],o=n<<1;o<=e.heap_len&&(o<e.heap_len&&Xl(t,e.heap[o+1],e.heap[o],e.depth)&&o++,!Xl(t,r,e.heap[o],e.depth));)e.heap[n]=e.heap[o],n=o,o<<=1;e.heap[n]=r}function Ql(e,t,n){var r,o,i,s,a=0;if(0!==e.last_lit)do{r=e.pending_buf[e.d_buf+2*a]<<8|e.pending_buf[e.d_buf+2*a+1],o=e.pending_buf[e.l_buf+a],a++,0===r?Kl(e,o,t):(Kl(e,(i=Ul[o])+kl+1,t),0!==(s=Cl[i])&&Wl(e,o-=Bl[i],s),Kl(e,i=Hl(--r),n),0!==(s=Rl[i])&&Wl(e,r-=zl[i],s))}while(a<e.last_lit);Kl(e,256,t)}function eh(e,t){var n,r,o,i=t.dyn_tree,s=t.stat_desc.static_tree,a=t.stat_desc.has_stree,c=t.stat_desc.elems,u=-1;for(e.heap_len=0,e.heap_max=573,n=0;n<c;n++)0!==i[2*n]?(e.heap[++e.heap_len]=u=n,e.depth[n]=0):i[2*n+1]=0;for(;e.heap_len<2;)i[2*(o=e.heap[++e.heap_len]=u<2?++u:0)]=1,e.depth[o]=0,e.opt_len--,a&&(e.static_len-=s[2*o+1]);for(t.max_code=u,n=e.heap_len>>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<c&&o===s||(a<u?e.bl_tree[2*o]+=a:0!==o?(o!==i&&e.bl_tree[2*o]++,e.bl_tree[32]++):a<=10?e.bl_tree[34]++:e.bl_tree[36]++,a=0,i=o,0===s?(c=138,u=3):o===s?(c=6,u=3):(c=7,u=4))}function nh(e,t,n){var r,o,i=-1,s=t[1],a=0,c=7,u=4;for(0===s&&(c=138,u=3),r=0;r<=n;r++)if(o=s,s=t[2*(r+1)+1],!(++a<c&&o===s)){if(a<u)do{Kl(e,o,e.bl_tree)}while(0!=--a);else 0!==o?(o!==i&&(Kl(e,o,e.bl_tree),a--),Kl(e,16,e.bl_tree),Wl(e,a-3,2)):a<=10?(Kl(e,17,e.bl_tree),Wl(e,a-3,3)):(Kl(e,18,e.bl_tree),Wl(e,a-11,7));a=0,i=o,0===s?(c=138,u=3):o===s?(c=6,u=3):(c=7,u=4)}}El(zl);var rh=!1;function oh(e){rh||(!function(){var e,t,n,r,o,i=new Array(16);for(n=0,r=0;r<28;r++)for(Bl[r]=n,e=0;e<1<<Cl[r];e++)Ul[n++]=r;for(Ul[n-1]=r,o=0,r=0;r<16;r++)for(zl[r]=o,e=0;e<1<<Rl[r];e++)jl[o++]=r;for(o>>=7;r<Ol;r++)for(zl[r]=o<<7,e=0;e<1<<Rl[r]-7;e++)jl[256+o++]=r;for(t=0;t<=Al;t++)i[t]=0;for(e=0;e<=143;)Il[2*e+1]=8,e++,i[8]++;for(;e<=255;)Il[2*e+1]=9,e++,i[9]++;for(;e<=279;)Il[2*e+1]=7,e++,i[7]++;for(;e<=287;)Il[2*e+1]=8,e++,i[8]++;for(Zl(Il,287,i),e=0;e<Ol;e++)Pl[2*e+1]=5,Pl[2*e]=Gl(e,5);Nl=new Fl(Il,Cl,257,Sl,Al),Ml=new Fl(Pl,Rl,0,Ol,Al),$l=new Fl(new Array(0),Tl,0,19,7)}(),rh=!0),e.l_desc=new Dl(e.dyn_ltree,Nl),e.d_desc=new Dl(e.dyn_dtree,Ml),e.bl_desc=new Dl(e.bl_tree,$l),e.bi_buf=0,e.bi_valid=0,Vl(e)}function ih(e,t,n,r){Wl(e,0+(r?1:0),3),function(e,t,n,r){Yl(e),r&&(ql(e,n),ql(e,~n)),wl(e.pending_buf,e.window,t,n,e.pending),e.pending+=n}(e,t,n,!0)}function sh(e){Wl(e,2,3),Kl(e,256,Il),function(e){16===e.bi_valid?(ql(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=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<kl;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),eh(e,e.l_desc),eh(e,e.d_desc),s=function(e){var t;for(th(e,e.dyn_ltree,e.l_desc.max_code),th(e,e.dyn_dtree,e.d_desc.max_code),eh(e,e.bl_desc),t=18;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<r;o++)Wl(e,e.bl_tree[2*Ll[o]+1],3);nh(e,e.dyn_ltree,t-1),nh(e,e.dyn_dtree,n-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),Ql(e,e.dyn_ltree,e.dyn_dtree)),Vl(e),r&&Yl(e)}function ch(e,t,n){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>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<i;s++)e=e>>>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]&&i<f);if(r=ph-(f-i),i=f-ph,r>s){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<<e.hash_shift^e.window[i+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[i+3-1])&e.hash_mask,e.prev[i&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=i,i++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<yh&&0!==e.strm.avail_in)}function Ch(e,t){for(var n,r;;){if(e.lookahead<yh){if(Ah(e),e.lookahead<yh&&0===t)return 1;if(0===e.lookahead)break}if(n=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==n&&e.strstart-n<=e.w_size-yh&&(e.match_length=Oh(e,n)),e.match_length>=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<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else r=ch(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(Eh(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,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}function Rh(e,t){for(var n,r,o;;){if(e.lookahead<yh){if(Ah(e),e.lookahead<yh&&0===t)return 1;if(0===e.lookahead)break}if(n=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==n&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-yh&&(e.match_length=Oh(e,n),e.match_length<=5&&(1===e.strategy||3===e.match_length&&e.strstart-e.match_start>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<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,r&&(Eh(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((r=ch(e,0,e.window[e.strstart-1]))&&Eh(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=ch(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,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}function Th(e,t,n,r,o){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=o}function Lh(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new _l(1146),this.dyn_dtree=new _l(122),this.bl_tree=new _l(78),_h(this.dyn_ltree),_h(this.dyn_dtree),_h(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new _l(16),this.heap=new _l(573),_h(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new _l(573),_h(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function Ih(e){var t,n=function(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=2,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?42:bh,e.adler=2===t.wrap?0:1,t.last_flush=0,oh(t),0):wh(e,dh)}(e);return 0===n&&((t=e.state).window_size=2*t.w_size,_h(t.head),t.max_lazy_match=fh[t.level].max_lazy,t.good_match=fh[t.level].good_length,t.nice_match=fh[t.level].nice_length,t.max_chain_length=fh[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0),n}function Ph(e,t){var n,r,o,i;if(!e||!e.state||t>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.gzindex<r.gzhead.name.length?255&r.gzhead.name.charCodeAt(r.gzindex++):0,kh(r,i)}while(0!==i);r.gzhead.hcrc&&r.pending>o&&(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.gzindex<r.gzhead.comment.length?255&r.gzhead.comment.charCodeAt(r.gzindex++):0,kh(r,i)}while(0!==i);r.gzhead.hcrc&&r.pending>o&&(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]&&o<i);e.match_length=ph-(i-o),e.match_length>e.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<<n.lenbits)-1,m=(1<<n.distbits)-1;e:do{p<15&&(d+=S[r++]<<p,p+=8,d+=S[r++]<<p,p+=8),w=y[d&b];t:for(;;){if(d>>>=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)-1)];continue t}if(32&v){n.mode=12;break e}e.msg="invalid literal/length code",n.mode=30;break e}_=65535&w,(v&=15)&&(p<v&&(d+=S[r++]<<p,p+=8),_+=d&(1<<v)-1,d>>>=v,p-=v),p<15&&(d+=S[r++]<<p,p+=8,d+=S[r++]<<p,p+=8),w=g[d&m];n:for(;;){if(d>>>=v=w>>>24,p-=v,!(16&(v=w>>>16&255))){if(0==(64&v)){w=g[(65535&w)+(d&(1<<v)-1)];continue n}e.msg="invalid distance code",n.mode=30;break e}if(x=65535&w,p<(v&=15)&&(d+=S[r++]<<p,(p+=8)<v&&(d+=S[r++]<<p,p+=8)),(x+=d&(1<<v)-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(h<v){if(E+=u+h-v,(v-=h)<_){_-=v;do{O[i++]=f[E++]}while(--v);if(E=0,h<_){_-=v=h;do{O[i++]=f[E++]}while(--v);E=i-x,k=O}}}else if(E+=h-v,v<_){_-=v;do{O[i++]=f[E++]}while(--v);E=i-x,k=O}for(;_>2;)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<o&&i<a);r-=_=p>>3,d&=(1<<(p-=_<<3))-1,e.next_in=r,e.next_out=i,e.avail_in=r<o?o-r+5:5-(r-o),e.avail_out=i<a?a-i+257:257-(i-a),n.hold=d,n.bits=p}var Uh=15,Bh=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],Nh=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],Mh=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],$h=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];function zh(e,t,n,r,o,i,s,a){var c,u,l,h,f,d,p,y,g,b=a.bits,m=0,w=0,v=0,_=0,x=0,E=0,k=0,S=0,O=0,A=0,C=null,R=0,T=new _l(16),L=new _l(16),I=null,P=0;for(m=0;m<=Uh;m++)T[m]=0;for(w=0;w<r;w++)T[t[n+w]]++;for(x=b,_=Uh;_>=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(x<v&&(x=v),S=1,m=1;m<=Uh;m++)if(S<<=1,(S-=T[m])<0)return-1;if(S>0&&(0===e||1!==_))return-1;for(L[1]=0,m=1;m<Uh;m++)L[m+1]=L[m]+T[m];for(w=0;w<r;w++)0!==t[n+w]&&(s[L[t[n+w]]++]=w);if(0===e?(C=I=s,d=19):1===e?(C=Bh,R-=257,I=Nh,P-=257,d=256):(C=Mh,I=$h,d=-1),A=0,w=0,m=v,f=i,E=x,k=0,l=-1,h=(O=1<<x)-1,1===e&&O>852||2===e&&O>592)return 1;for(;;){p=m-k,s[w]<d?(y=0,g=s[w]):s[w]>d?(y=I[P+s[w]],g=C[R+s[w]]):(y=96,g=0),c=1<<m-k,v=u=1<<E;do{o[f+(A>>k)+(u-=c)]=p<<24|y<<16|g|0}while(0!==u);for(c=1<<m-1;A&c;)c>>=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<<E,1===e&&O>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++]<<l,l+=8}if(2&n.wrap&&35615===u){n.check=0,A[0]=255&u,A[1]=u>>>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<<x,e.adler=n.check=1,n.mode=512&u?10:Dh,u=0,l=0;break;case 2:for(;l<16;){if(0===a)break e;a--,u+=r[i++]<<l,l+=8}if(n.flags=u,8!=(255&n.flags)){e.msg="unknown compression method",n.mode=Hh;break}if(57344&n.flags){e.msg="unknown header flags set",n.mode=Hh;break}n.head&&(n.head.text=u>>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++]<<l,l+=8}n.head&&(n.head.time=u),512&n.flags&&(A[0]=255&u,A[1]=u>>>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++]<<l,l+=8}n.head&&(n.head.xflags=255&u,n.head.os=u>>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++]<<l,l+=8}n.length=u,n.head&&(n.head.extra_len=u),512&n.flags&&(A[0]=255&u,A[1]=u>>>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<a);if(512&n.flags&&(n.check=hh(n.check,r,d,i)),a-=d,i+=d,x)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=8;case 8:if(4096&n.flags){if(0===a)break e;d=0;do{x=r[i+d++],n.head&&x&&n.length<65536&&(n.head.comment+=String.fromCharCode(x))}while(x&&d<a);if(512&n.flags&&(n.check=hh(n.check,r,d,i)),a-=d,i+=d,x)break e}else n.head&&(n.head.comment=null);n.mode=9;case 9:if(512&n.flags){for(;l<16;){if(0===a)break e;a--,u+=r[i++]<<l,l+=8}if(u!==(65535&n.check)){e.msg="header crc mismatch",n.mode=Hh;break}u=0,l=0}n.head&&(n.head.hcrc=n.flags>>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++]<<l,l+=8}e.adler=n.check=qh(u),u=0,l=0,n.mode=11;case 11:if(0===n.havedict)return e.next_out=s,e.avail_out=c,e.next_in=i,e.avail_in=a,n.hold=u,n.bits=l,2;e.adler=n.check=1,n.mode=Dh;case Dh:if(5===t||6===t)break e;case 13:if(n.last){u>>>=7&l,l-=7&l,n.mode=27;break}for(;l<3;){if(0===a)break e;a--,u+=r[i++]<<l,l+=8}switch(n.last=1&u,l-=1,3&(u>>>=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++]<<l,l+=8}if((65535&u)!=(u>>>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++]<<l,l+=8}if(n.nlen=257+(31&u),u>>>=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<n.ncode;){for(;l<3;){if(0===a)break e;a--,u+=r[i++]<<l,l+=8}n.lens[C[n.have++]]=7&u,u>>>=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<n.nlen+n.ndist;){for(;b=(O=n.lencode[u&(1<<n.lenbits)-1])>>>16&255,m=65535&O,!((g=O>>>24)<=l);){if(0===a)break e;a--,u+=r[i++]<<l,l+=8}if(m<16)u>>>=g,l-=g,n.lens[n.have++]=m;else{if(16===m){for(S=g+2;l<S;){if(0===a)break e;a--,u+=r[i++]<<l,l+=8}if(u>>>=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<S;){if(0===a)break e;a--,u+=r[i++]<<l,l+=8}l-=g,x=0,d=3+(7&(u>>>=g)),u>>>=3,l-=3}else{for(S=g+7;l<S;){if(0===a)break e;a--,u+=r[i++]<<l,l+=8}l-=g,x=0,d=11+(127&(u>>>=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<<n.lenbits)-1])>>>16&255,m=65535&O,!((g=O>>>24)<=l);){if(0===a)break e;a--,u+=r[i++]<<l,l+=8}if(b&&0==(240&b)){for(w=g,v=b,_=m;b=(O=n.lencode[_+((u&(1<<w+v)-1)>>w)])>>>16&255,m=65535&O,!(w+(g=O>>>24)<=l);){if(0===a)break e;a--,u+=r[i++]<<l,l+=8}u>>>=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<S;){if(0===a)break e;a--,u+=r[i++]<<l,l+=8}n.length+=u&(1<<n.extra)-1,u>>>=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<<n.distbits)-1])>>>16&255,m=65535&O,!((g=O>>>24)<=l);){if(0===a)break e;a--,u+=r[i++]<<l,l+=8}if(0==(240&b)){for(w=g,v=b,_=m;b=(O=n.distcode[_+((u&(1<<w+v)-1)>>w)])>>>16&255,m=65535&O,!(w+(g=O>>>24)<=l);){if(0===a)break e;a--,u+=r[i++]<<l,l+=8}u>>>=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<S;){if(0===a)break e;a--,u+=r[i++]<<l,l+=8}n.offset+=u&(1<<n.extra)-1,u>>>=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++]<<l,l+=8}if(f-=c,e.total_out+=f,n.total+=f,f&&(e.adler=n.check=n.flags?hh(n.check,o,f,s-f):uh(n.check,o,f,s-f)),f=c,(n.flags?u:qh(u))!==n.check){e.msg="incorrect data check",n.mode=Hh;break}u=0,l=0}n.mode=28;case 28:if(n.wrap&&n.flags){for(;l<32;){if(0===a)break e;a--,u+=r[i++]<<l,l+=8}if(u!==(4294967295&n.total)){e.msg="incorrect length check",n.mode=Hh;break}u=0,l=0}n.mode=29;case 29:E=1;break e;case Hh:E=-3;break e;case 31:return-4;default:return Fh}return e.next_out=s,e.avail_out=c,e.next_in=i,e.avail_in=a,n.hold=u,n.bits=l,(n.wsize||f!==e.avail_out&&n.mode<Hh&&(n.mode<27||4!==t))&&function(e,t,n,r){var o,i=e.state;null===i.window&&(i.wsize=1<<i.wbits,i.wnext=0,i.whave=0,i.window=new vl(i.wsize)),r>=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.whave<i.wsize&&(i.whave+=o)))}(e,e.output,e.next_out,f-e.avail_out),h-=e.avail_in,f-=e.avail_out,e.total_in+=h,e.total_out+=f,n.total+=f,n.wrap&&f&&(e.adler=n.check=n.flags?hh(n.check,o,f,e.next_out-f):uh(n.check,o,f,e.next_out-f)),e.data_type=n.bits+(n.last?64:0)+(n.mode===Dh?128:0)+(20===n.mode||15===n.mode?256:0),(0===h&&0===f||4===t)&&0===E&&(E=-5),E}var Qh;function ef(e){if(e<1||e>7)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;n<e.length;n++)this[t+n]=e[n]}ef.prototype.init=function(e,t,n,r,o){var i;switch(this.windowBits=e,this.level=t,this.memLevel=n,this.strategy=r,3!==this.mode&&4!==this.mode||(this.windowBits+=16),7===this.mode&&(this.windowBits+=32),5!==this.mode&&6!==this.mode||(this.windowBits=-this.windowBits),this.strm=new ml,this.mode){case 1:case 3:case 5:i=function(e,t,n,r,o,i){if(!e)return dh;var s=1;if(-1===t&&(t=6),r<0?(s=0,r=-r):r>15&&(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<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=o+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+3-1)/3),a.window=new vl(2*a.w_size),a.head=new _l(a.hash_size),a.prev=new _l(a.w_size),a.lit_bufsize=1<<o+6,a.pending_buf_size=4*a.lit_bufsize,a.pending_buf=new vl(a.pending_buf_size),a.d_buf=1*a.lit_bufsize,a.l_buf=3*a.lit_bufsize,a.level=t,a.strategy=i,a.method=n,Ih(e)}(this.strm,this.level,8,this.windowBits,this.memLevel,this.strategy);break;case 2:case 4:case 6:case 7:i=Gh(this.strm,this.windowBits);break;default:throw new Error("Unknown mode "+this.mode)}0===i?(this.write_in_progress=!1,this.init_done=!0):this._error(i)},ef.prototype.params=function(){throw new Error("deflateParams Not supported")},ef.prototype._writeCheck=function(){if(!this.init_done)throw new Error("write before init");if(0===this.mode)throw new Error("already finalized");if(this.write_in_progress)throw new Error("write already in progress");if(this.pending_close)throw new Error("close is pending")},ef.prototype.write=function(e,t,n,r,o,i,s){this._writeCheck(),this.write_in_progress=!0;var a=this;return wa.nextTick((function(){a.write_in_progress=!1;var c=a._write(e,t,n,r,o,i,s);a.callback(c[0],c[1]),a.pending_close&&a.close()})),this},ef.prototype.writeSync=function(e,t,n,r,o,i,s){return this._writeCheck(),this._write(e,t,n,r,o,i,s)},ef.prototype._write=function(e,t,n,r,o,i,s){if(this.write_in_progress=!0,0!==e&&1!==e&&2!==e&&3!==e&&4!==e&&5!==e)throw new Error("Invalid flush value");null==t&&(t=new us(0),r=0,n=0),o._set?o.set=o._set:o.set=tf;var a,c=this.strm;switch(c.avail_in=r,c.input=t,c.next_in=n,c.avail_out=s,c.output=o,c.next_out=i,this.mode){case 1:case 3:case 5:a=Ph(c,e);break;case 7:case 2:case 4:case 6:a=Jh(c,e);break;default:throw new Error("Unknown mode "+this.mode)}return 1!==a&&0!==a&&this._error(a),this.write_in_progress=!1,[c.avail_in,c.avail_out]},ef.prototype.close=function(){this.write_in_progress?this.pending_close=!0:(this.pending_close=!1,1===this.mode||3===this.mode||5===this.mode?function(e){var t;e&&e.state&&(42!==(t=e.state.status)&&69!==t&&73!==t&&91!==t&&t!==gh&&t!==bh&&t!==mh?wh(e,dh):(e.state=null,t===bh&&wh(e,-3)))}(this.strm):function(e){if(!e||!e.state)return Fh;var t=e.state;t.window&&(t.window=null),e.state=null}(this.strm),this.mode=0)},ef.prototype.reset=function(){switch(this.mode){case 1:case 5:Qh=Ih(this.strm);break;case 2:case 6:Qh=Kh(this.strm)}0!==Qh&&this._error(Qh)},ef.prototype._error=function(e){this.onerror(bl[e]+": "+this.strm.msg,e),this.write_in_progress=!1,this.pending_close&&this.close()};var nf=Object.freeze({__proto__:null,DEFLATE:1,DEFLATERAW:5,GUNZIP:4,GZIP:3,INFLATE:2,INFLATERAW:6,NONE:0,UNZIP:7,Z_BEST_COMPRESSION:9,Z_BEST_SPEED:1,Z_BINARY:0,Z_BLOCK:5,Z_BUF_ERROR:-5,Z_DATA_ERROR:-3,Z_DEFAULT_COMPRESSION:-1,Z_DEFAULT_STRATEGY:0,Z_DEFLATED:8,Z_ERRNO:-1,Z_FILTERED:1,Z_FINISH:4,Z_FIXED:4,Z_FULL_FLUSH:3,Z_HUFFMAN_ONLY:2,Z_NEED_DICT:2,Z_NO_COMPRESSION:0,Z_NO_FLUSH:0,Z_OK:0,Z_PARTIAL_FLUSH:1,Z_RLE:3,Z_STREAM_END:1,Z_STREAM_ERROR:-2,Z_SYNC_FLUSH:2,Z_TEXT:1,Z_TREES:6,Z_UNKNOWN:2,Zlib:ef});var rf={};Object.keys(nf).forEach((function(e){rf[e]=nf[e]})),rf.Z_MIN_WINDOWBITS=8,rf.Z_MAX_WINDOWBITS=15,rf.Z_DEFAULT_WINDOWBITS=15,rf.Z_MIN_CHUNK=64,rf.Z_MAX_CHUNK=1/0,rf.Z_DEFAULT_CHUNK=16384,rf.Z_MIN_MEMLEVEL=1,rf.Z_MAX_MEMLEVEL=9,rf.Z_DEFAULT_MEMLEVEL=8,rf.Z_MIN_LEVEL=-1,rf.Z_MAX_LEVEL=9,rf.Z_DEFAULT_LEVEL=rf.Z_DEFAULT_COMPRESSION;var of={Z_OK:rf.Z_OK,Z_STREAM_END:rf.Z_STREAM_END,Z_NEED_DICT:rf.Z_NEED_DICT,Z_ERRNO:rf.Z_ERRNO,Z_STREAM_ERROR:rf.Z_STREAM_ERROR,Z_DATA_ERROR:rf.Z_DATA_ERROR,Z_MEM_ERROR:rf.Z_MEM_ERROR,Z_BUF_ERROR:rf.Z_BUF_ERROR,Z_VERSION_ERROR:rf.Z_VERSION_ERROR};function sf(e){return new Rf(e)}function af(e){return new Tf(e)}function cf(e){return new Pf(e)}function uf(e){return new jf(e)}function lf(e){return new Lf(e)}function hf(e){return new If(e)}function ff(e){return new Uf(e)}function df(e,t,n){return"function"==typeof t&&(n=t,t={}),Af(new Rf(t),e,n)}function pf(e,t){return Cf(new Rf(t),e)}function yf(e,t,n){return"function"==typeof t&&(n=t,t={}),Af(new Lf(t),e,n)}function gf(e,t){return Cf(new Lf(t),e)}function bf(e,t,n){return"function"==typeof t&&(n=t,t={}),Af(new Pf(t),e,n)}function mf(e,t){return Cf(new Pf(t),e)}function wf(e,t,n){return"function"==typeof t&&(n=t,t={}),Af(new Uf(t),e,n)}function vf(e,t){return Cf(new Uf(t),e)}function _f(e,t,n){return"function"==typeof t&&(n=t,t={}),Af(new Tf(t),e,n)}function xf(e,t){return Cf(new Tf(t),e)}function Ef(e,t,n){return"function"==typeof t&&(n=t,t={}),Af(new If(t),e,n)}function kf(e,t){return Cf(new If(t),e)}function Sf(e,t,n){return"function"==typeof t&&(n=t,t={}),Af(new jf(t),e,n)}function Of(e,t){return Cf(new jf(t),e)}function Af(e,t,n){var r=[],o=0;function i(){for(var t;null!==(t=e.read());)r.push(t),o+=t.length;e.once("readable",i)}function s(){var t=us.concat(r,o);r=[],n(null,t),e.close()}e.on("error",(function(t){e.removeListener("end",s),e.removeListener("readable",i),n(t)})),e.on("end",s),e.end(t),i()}function Cf(e,t){if("string"==typeof t&&(t=new us(t)),!us.isBuffer(t))throw new TypeError("Not a string or buffer");var n=rf.Z_FINISH;return e._processChunk(t,n)}function Rf(e){if(!(this instanceof Rf))return new Rf(e);Bf.call(this,e,rf.DEFLATE)}function Tf(e){if(!(this instanceof Tf))return new Tf(e);Bf.call(this,e,rf.INFLATE)}function Lf(e){if(!(this instanceof Lf))return new Lf(e);Bf.call(this,e,rf.GZIP)}function If(e){if(!(this instanceof If))return new If(e);Bf.call(this,e,rf.GUNZIP)}function Pf(e){if(!(this instanceof Pf))return new Pf(e);Bf.call(this,e,rf.DEFLATERAW)}function jf(e){if(!(this instanceof jf))return new jf(e);Bf.call(this,e,rf.INFLATERAW)}function Uf(e){if(!(this instanceof Uf))return new Uf(e);Bf.call(this,e,rf.UNZIP)}function Bf(e,t){if(this._opts=e=e||{},this._chunkSize=e.chunkSize||rf.Z_DEFAULT_CHUNK,tu.call(this,e),e.flush&&e.flush!==rf.Z_NO_FLUSH&&e.flush!==rf.Z_PARTIAL_FLUSH&&e.flush!==rf.Z_SYNC_FLUSH&&e.flush!==rf.Z_FULL_FLUSH&&e.flush!==rf.Z_FINISH&&e.flush!==rf.Z_BLOCK)throw new Error("Invalid flush flag: "+e.flush);if(this._flushFlag=e.flush||rf.Z_NO_FLUSH,e.chunkSize&&(e.chunkSize<rf.Z_MIN_CHUNK||e.chunkSize>rf.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+e.chunkSize);if(e.windowBits&&(e.windowBits<rf.Z_MIN_WINDOWBITS||e.windowBits>rf.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+e.windowBits);if(e.level&&(e.level<rf.Z_MIN_LEVEL||e.level>rf.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+e.level);if(e.memLevel&&(e.memLevel<rf.Z_MIN_MEMLEVEL||e.memLevel>rf.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(e<rf.Z_MIN_LEVEL||e>rf.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<e.length&&""===e[t];t++);for(var n=e.length-1;n>=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;a<i;a++)if(r[a]!==o[a]){s=a;break}var c=[];for(a=s;a<r.length;a++)c.push("..");return(c=c.concat(o.slice(s))).join("/")}function od(e){var t=Jf(e),n=t[0],r=t[1];return n||r?(r&&(r=r.substr(0,r.length-1)),n+r):"."}function id(e,t){var n=Jf(e)[2];return t&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n}function sd(e){return Jf(e)[3]}var ad={extname:sd,basename:id,dirname:od,sep:"/",delimiter:":",relative:rd,join:nd,isAbsolute:td,normalize:ed,resolve:Qf};function cd(e,t){if(e.filter)return e.filter(t);for(var n=[],r=0;r<e.length;r++)t(e[r],r,e)&&n.push(e[r]);return n}var ud,ld="b"==="ab".substr(-1)?function(e,t,n){return e.substr(t,n)}:function(e,t,n){return t<0&&(t=e.length+t),e.substr(t,n)},hd=In(Object.freeze({__proto__:null,basename:id,default:ad,delimiter:":",dirname:od,extname:sd,isAbsolute:td,join:nd,normalize:ed,relative:rd,resolve:Qf,sep:"/"}));function fd(){if(void 0===ud){var e=new ArrayBuffer(2),t=new Uint8Array(e),n=new Uint16Array(e);if(t[0]=1,t[1]=2,258===n[0])ud="BE";else{if(513!==n[0])throw new Error("unable to figure out endianess");ud="LE"}}return ud}function dd(){return void 0!==Zi.location?Zi.location.hostname:""}function pd(){return[]}function yd(){return 0}function gd(){return Number.MAX_VALUE}function bd(){return Number.MAX_VALUE}function md(){return[]}function wd(){return"Browser"}function vd(){return void 0!==Zi.navigator?Zi.navigator.appVersion:""}function _d(){return{}}function xd(){return{}}function Ed(){return"javascript"}function kd(){return"browser"}function Sd(){return"/tmp"}var Od=Sd;function Ad(){return"$HOME"}var Cd,Rd,Td,Ld,Id,Pd,jd,Ud,Bd,Nd,Md,$d={homedir:Ad,EOL:"\n",arch:Ed,platform:kd,tmpdir:Od,tmpDir:Sd,networkInterfaces:_d,getNetworkInterfaces:xd,release:vd,type:wd,cpus:md,totalmem:bd,freemem:gd,uptime:yd,loadavg:pd,hostname:dd,endianness:fd},zd=In(Object.freeze({__proto__:null,EOL:"\n",arch:Ed,cpus:md,default:$d,endianness:fd,freemem:gd,getNetworkInterfaces:xd,homedir:Ad,hostname:dd,loadavg:pd,networkInterfaces:_d,platform:kd,release:vd,tmpDir:Sd,tmpdir:Od,totalmem:bd,type:wd,uptime:yd}));function Fd(){return Td||(Td=1,e=Gf,"function"==typeof wa.addon?e.exports=wa.addon.bind(wa):e.exports=function(){if(Rd)return Cd;Rd=1;var e=Vf,t=hd,n=zd,r="function"==typeof __webpack_require__?__non_webpack_require__:Zf,o=wa.config&&wa.config.variables||{},i=!!wa.env.PREBUILDS_ONLY,s=wa.versions.modules,a=wa.versions&&wa.versions.electron||wa.env.ELECTRON_RUN_AS_NODE||"undefined"!=typeof window&&window.process&&"renderer"===window.process.type?"electron":wa.versions&&wa.versions.nw?"node-webkit":"node",c=wa.env.npm_config_arch||n.arch(),u=wa.env.npm_config_platform||n.platform(),l=wa.env.LIBC||(function(t){return"linux"===t&&e.existsSync("/etc/alpine-release")}(u)?"musl":"glibc"),h=wa.env.ARM_VERSION||("arm64"===c?"8":o.arm_version)||"",f=(wa.versions.uv||"").split(".")[0];function d(e){return r(d.resolve(e))}function p(t){try{return e.readdirSync(t)}catch(e){return[]}}function y(e,n){var r=p(e).filter(n);return r[0]&&t.join(e,r[0])}function g(e){return/\.node$/.test(e)}function b(e){var t=e.split("-");if(2===t.length){var n=t[0],r=t[1].split("+");if(n&&r.length&&r.every(Boolean))return{name:e,platform:n,architectures:r}}}function m(e,t){return function(n){return null!=n&&n.platform===e&&n.architectures.includes(t)}}function w(e,t){return e.architectures.length-t.architectures.length}function v(e){var t=e.split("."),n={file:e,specificity:0};if("node"===t.pop()){for(var r=0;r<t.length;r++){var o=t[r];if("node"===o||"electron"===o||"node-webkit"===o)n.runtime=o;else if("napi"===o)n.napi=!0;else if("abi"===o.slice(0,3))n.abi=o.slice(3);else if("uv"===o.slice(0,2))n.uv=o.slice(2);else if("armv"===o.slice(0,4))n.armv=o.slice(4);else{if("glibc"!==o&&"musl"!==o)continue;n.libc=o}n.specificity++}return n}}function _(e,t){return function(n){return!(null==n||n.runtime!==e&&!function(e){return"node"===e.runtime&&e.napi}(n)||n.abi!==t&&!n.napi||n.uv&&n.uv!==f||n.armv&&n.armv!==h||n.libc&&n.libc!==l)}}function x(e){return function(t,n){return t.runtime!==n.runtime?t.runtime===e?-1:1:t.abi!==n.abi?t.abi?-1:1:t.specificity!==n.specificity?t.specificity>n.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<o;i++)n[r+i]=e[i]^t[3&i]},unmask:(e,t)=>{const n=e.length;for(var r=0;r<n;r++)e[r]^=t[3&r]}}),Ld)}}(Wf)),qf}function Hd(){if(jd)return Ff;jd=1;const{EMPTY_BUFFER:e}=Hf(),t=us[Symbol.species];function n(e,t,n,r,o){for(let i=0;i<o;i++)n[r+i]=e[i]^t[3&i]}function r(e,t){for(let n=0;n<e.length;n++)e[n]^=t[3&n]}if(Df.exports={concat:function(n,r){if(0===n.length)return e;if(1===n.length)return n[0];const o=us.allocUnsafe(r);let i=0;for(let e=0;e<n.length;e++){const t=n[e];o.set(t,i),i+=t.length}return i<r?new t(o.buffer,o.byteOffset,i):o},mask:n,toArrayBuffer:function(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)},toBuffer:function e(n){if(e.readOnly=!0,us.isBuffer(n))return n;let r;return n instanceof ArrayBuffer?r=new t(n):ArrayBuffer.isView(n)?r=new t(n.buffer,n.byteOffset,n.byteLength):(r=us.from(n),e.readOnly=!1),r},unmask:r},!wa.env.WS_NO_BUFFER_UTIL)try{const e=Dd();Ff.mask=function(t,r,o,i,s){s<48?n(t,r,o,i,s):e.mask(t,r,o,i,s)},Ff.unmask=function(t,n){t.length<32?r(t,n):e.unmask(t,n)}}catch(e){}return Ff}function qd(){if(Md)return Nd;Md=1;const e=zf,t=Hd(),n=function(){if(Bd)return Ud;Bd=1;const e=Symbol("kDone"),t=Symbol("kRun");return Ud=class{constructor(n){this[e]=()=>{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;)if(0==(128&e[n]))n++;else if(192==(224&e[n])){if(n+1===t||128!=(192&e[n+1])||192==(254&e[n]))return!1;n+=2}else if(224==(240&e[n])){if(n+2>=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;)if(0==(128&e[n]))n++;else if(192==(224&e[n])){if(n+1===t||128!=(192&e[n+1])||192==(254&e[n]))return!1;n+=2}else if(224==(240&e[n])){if(n+2>=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<this._buffers[0].length){const t=this._buffers[0];return this._buffers[0]=new h(t.buffer,t.byteOffset+e,t.length-e),new h(t.buffer,t.byteOffset,e)}const t=us.allocUnsafe(e);do{const n=this._buffers[0],r=t.length-e;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._bufferedBytes<this._payloadLength)return void(this._loop=!1);t=this.consume(this._payloadLength),this._masked&&0!=(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])&&c(t,this._mask)}return this._opcode>7?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<this._queue.length;t++){const n=this._queue[t],r=n[n.length-1];"function"==typeof r&&r(e)}}else this._bufferedBytes-=r[s],this._deflating=!1,r.readOnly=!1,this.sendFrame(c.frame(t,r),o),this.dequeue()}))}dequeue(){for(;!this._deflating&&this._queue.length;){const e=this._queue.shift();this._bufferedBytes-=e[3][s],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][s],this._queue.push(e)}sendFrame(e,t){2===e.length?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}}return Xd=c}function xp(){if(np)return tp;np=1;const{tokenChars:e}=wp();function t(e,t,n){void 0===e[t]?e[t]=[n]:e[t].push(n)}return tp={format:function(e){return Object.keys(e).map((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(;d<n.length;d++)if(h=n.charCodeAt(d),void 0===o)if(-1===f&&1===e[h])-1===l&&(l=d);else if(0===d||32!==h&&9!==h){if(59!==h&&44!==h)throw new SyntaxError(`Unexpected character at index ${d}`);{if(-1===l)throw new SyntaxError(`Unexpected character at index ${d}`);-1===f&&(f=d);const e=n.slice(l,f);44===h?(t(r,e,s),s=Object.create(null)):o=e,l=f=-1}}else-1===f&&-1!==l&&(f=d);else if(void 0===i)if(-1===f&&1===e[h])-1===l&&(l=d);else if(32===h||9===h)-1===f&&-1!==l&&(f=d);else if(59===h||44===h){if(-1===l)throw new SyntaxError(`Unexpected character at index ${d}`);-1===f&&(f=d),t(s,n.slice(l,f),!0),44===h&&(t(r,o,s),s=Object.create(null),o=void 0),l=f=-1}else{if(61!==h||-1===l||-1!==f)throw new SyntaxError(`Unexpected character at index ${d}`);i=n.slice(l,d),l=f=-1}else if(c){if(1!==e[h])throw new SyntaxError(`Unexpected character at index ${d}`);-1===l?l=d:a||(a=!0),c=!1}else if(u)if(1===e[h])-1===l&&(l=d);else if(34===h&&-1!==l)u=!1,f=d;else{if(92!==h)throw new SyntaxError(`Unexpected character at index ${d}`);c=!0}else if(34===h&&61===n.charCodeAt(d-1))u=!0;else if(-1===f&&1===e[h])-1===l&&(l=d);else if(-1===l||32!==h&&9!==h){if(59!==h&&44!==h)throw new SyntaxError(`Unexpected character at index ${d}`);{if(-1===l)throw new SyntaxError(`Unexpected character at index ${d}`);-1===f&&(f=d);let e=n.slice(l,f);a&&(e=e.replace(/\\/g,""),a=!1),t(s,i,e),44===h&&(t(r,o,s),s=Object.create(null),o=void 0),i=void 0,l=f=-1}}else-1===f&&(f=d);if(-1===l||u||32===h||9===h)throw new SyntaxError("Unexpected end of input");-1===f&&(f=d);const p=n.slice(l,f);return void 0===o?t(r,p,s):(void 0===i?t(s,p,!0):t(s,i,a?p.replace(/\\/g,""):p),t(r,o,s)),r}},tp}function Ep(){if(op)return rp;op=1;const e=ja,t=ol,n=hl,r=fl,o=dl,{randomBytes:i,createHash:s}=pl,{URL:a}=gl,c=qd(),u=vp(),l=_p(),{BINARY_TYPES:h,EMPTY_BUFFER:f,GUID:d,kForOnEventAttribute:p,kListener:y,kStatusCode:g,kWebSocket:b,NOOP:m}=Hf(),{EventTarget:{addEventListener:w,removeEventListener:v}}=function(){if(ep)return Qd;ep=1;const{kForOnEventAttribute:e,kListener:t}=Hf(),n=Symbol("kCode"),r=Symbol("kData"),o=Symbol("kError"),i=Symbol("kMessage"),s=Symbol("kReason"),a=Symbol("kTarget"),c=Symbol("kType"),u=Symbol("kWasClean");class l{constructor(e){this[a]=null,this[c]=e}get target(){return this[a]}get type(){return this[c]}}Object.defineProperty(l.prototype,"target",{enumerable:!0}),Object.defineProperty(l.prototype,"type",{enumerable:!0});class h extends l{constructor(e,t={}){super(e),this[n]=void 0===t.code?0:t.code,this[s]=void 0===t.reason?"":t.reason,this[u]=void 0!==t.wasClean&&t.wasClean}get code(){return this[n]}get reason(){return this[s]}get wasClean(){return this[u]}}Object.defineProperty(h.prototype,"code",{enumerable:!0}),Object.defineProperty(h.prototype,"reason",{enumerable:!0}),Object.defineProperty(h.prototype,"wasClean",{enumerable:!0});class f extends l{constructor(e,t={}){super(e),this[o]=void 0===t.error?null:t.error,this[i]=void 0===t.message?"":t.message}get error(){return this[o]}get message(){return this[i]}}Object.defineProperty(f.prototype,"error",{enumerable:!0}),Object.defineProperty(f.prototype,"message",{enumerable:!0});class d extends l{constructor(e,t={}){super(e),this[r]=void 0===t.data?null:t.data}get data(){return this[r]}}Object.defineProperty(d.prototype,"data",{enumerable:!0});const p={addEventListener(n,r,o={}){for(const i of this.listeners(n))if(!o[e]&&i[t]===r&&!i[e])return;let i;if("message"===n)i=function(e,t){const n=new d("message",{data:t?e:e.toString()});n[a]=this,y(r,this,n)};else if("close"===n)i=function(e,t){const n=new h("close",{code:e,reason:t.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});n[a]=this,y(r,this,n)};else if("error"===n)i=function(e){const t=new f("error",{error:e,message:e.message});t[a]=this,y(r,this,t)};else{if("open"!==n)return;i=function(){const e=new l("open");e[a]=this,y(r,this,e)}}i[e]=!!o[e],i[t]=r,o.once?this.once(n,i):this.on(n,i)},removeEventListener(n,r){for(const o of this.listeners(n))if(o[t]===r&&!o[e]){this.removeListener(n,o);break}}};function y(e,t,n){"object"==typeof e&&e.handleEvent?e.handleEvent.call(e,n):e.call(t,n)}return Qd={CloseEvent:h,ErrorEvent:f,Event:l,EventTarget:p,MessageEvent:d}}(),{format:_,parse:x}=xp(),{toBuffer:E}=Hd(),k=Symbol("kAborted"),S=[8,13],O=["CONNECTING","OPEN","CLOSING","CLOSED"],A=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class C extends e{constructor(e,t,n){super(),this._binaryType=h[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=f,this._closeTimer=null,this._extensions={},this._paused=!1,this._protocol="",this._readyState=C.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,null!==e?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,void 0===t?t=[]:Array.isArray(t)||("object"==typeof t&&null!==t?(n=t,t=[]):t=[t]),R(this,e,t,n)):this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(e){h.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,n){const r=new u({binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation});this._sender=new l(e,this._extensions,n.generateMask),this._receiver=r,this._socket=e,r[b]=this,e[b]=this,r.on("conclude",U),r.on("drain",B),r.on("error",N),r.on("message",$),r.on("ping",z),r.on("pong",F),e.setTimeout(0),e.setNoDelay(),t.length>0&&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<t.length;i++){const s=t.charCodeAt(i);if(-1===o&&1===e[s])-1===r&&(r=i);else if(0===i||32!==s&&9!==s){if(44!==s)throw new SyntaxError(`Unexpected character at index ${i}`);{if(-1===r)throw new SyntaxError(`Unexpected character at index ${i}`);-1===o&&(o=i);const e=t.slice(r,o);if(n.has(e))throw new SyntaxError(`The "${e}" subprotocol is duplicated`);n.add(e),r=o=-1}}else-1===o&&-1!==r&&(o=i)}if(-1===r||-1!==o)throw new SyntaxError("Unexpected end of input");const s=t.slice(r,i);if(n.has(s))throw new SyntaxError(`The "${s}" subprotocol is duplicated`);return n.add(s),n}}}function Sp(){if(lp)return up;lp=1;const e=ja,t=hl,{createHash:n}=pl,r=xp(),o=qd(),i=kp(),s=Ep(),{GUID:a,kWebSocket:c}=Hf(),u=/^[+/0-9A-Za-z]{22}==$/;function l(e){e._state=2,e.emit("close")}function h(){this.destroy()}function f(e,n,r,o){r=r||t.STATUS_CODES[n],o={Connection:"close","Content-Type":"text/html","Content-Length":us.byteLength(r),...o},e.once("finish",e.destroy),e.end(`HTTP/1.1 ${n} ${t.STATUS_CODES[n]}\r\n`+Object.keys(o).map((e=>`${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<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=qp(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((n=>{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t};!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==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<i;o++)s[o]=r[o].fn;return s},a.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},a.prototype.emit=function(e,t,r,o,i,s){var a=n?n+e:e;if(!this._events[a])return!1;var c,u,l=this._events[a],h=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),h){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,r),!0;case 4:return l.fn.call(l.context,t,r,o),!0;case 5:return l.fn.call(l.context,t,r,o,i),!0;case 6:return l.fn.call(l.context,t,r,o,i,s),!0}for(u=1,c=new Array(h-1);u<h;u++)c[u-1]=arguments[u];l.fn.apply(l.context,c)}else{var f,d=l.length;for(u=0;u<d;u++)switch(l[u].once&&this.removeListener(e,l[u].fn,void 0,!0),h){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,t);break;case 3:l[u].fn.call(l[u].context,t,r);break;case 4:l[u].fn.call(l[u].context,t,r,o);break;default:if(!c)for(f=1,c=new Array(h-1);f<h;f++)c[f-1]=arguments[f];l[u].fn.apply(l[u].context,c)}}return!0},a.prototype.on=function(e,t,n){return i(this,e,t,n,!1)},a.prototype.once=function(e,t,n){return i(this,e,t,n,!0)},a.prototype.removeListener=function(e,t,r,o){var i=n?n+e:e;if(!this._events[i])return this;if(!t)return s(this,i),this;var a=this._events[i];if(a.fn)a.fn!==t||o&&!a.once||r&&a.context!==r||s(this,i);else{for(var c=0,u=[],l=a.length;c<l;c++)(a[c].fn!==t||o&&!a[c].once||r&&a[c].context!==r)&&u.push(a[c]);u.length?this._events[i]=1===u.length?u[0]:u:s(this,i)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&s(this,t)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,e.exports=a}(Gp);var Zp={};Object.defineProperty(Zp,"__esModule",{value:!0}),Zp.is_node=void 0;var Vp=null;Zp.is_node=function(){return null===Vp&&(Vp="object"==typeof Ln&&"object"==typeof Ln.process&&"object"==typeof Ln.process.versions&&void 0!==Ln.process.versions.node),Vp};var Yp,Xp,Jp={};var Qp,ey,ty,ny,ry="1.0.34";function oy(){if(ny)return ty;var e;if(ny=1,"object"==typeof globalThis)e=globalThis;else try{e=function(){if(Xp)return Yp;Xp=1;var e=function(){if("object"==typeof self&&self)return self;if("object"==typeof window&&window)return window;throw new Error("Unable to resolve global `this`")};return Yp=function(){if(this)return this;if("object"==typeof globalThis&&globalThis)return globalThis;try{Object.defineProperty(Object.prototype,"__global__",{get:function(){return this},configurable:!0})}catch(t){return e()}try{return __global__||e()}finally{delete Object.prototype.__global__}}()}()}catch(e){}finally{if(e||"undefined"==typeof window||(e=window),!e)throw new Error("Could not determine global this")}var t=e.WebSocket||e.MozWebSocket,n=ey?Qp:(ey=1,Qp=ry);function r(e,n){return n?new t(e,n):new t(e)}return t&&["CONNECTING","OPEN","CLOSING","CLOSED"].forEach((function(e){Object.defineProperty(r,e,{get:function(){return t[e]}})})),ty={w3cwebsocket:t?r:null,version:n}}var iy,sy,ay={},cy={},uy={},ly={},hy={},fy={};function dy(){if(sy)return hy;sy=1;var e=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(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<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};Object.defineProperty(uy,"__esModule",{value:!0}),uy.UniqueSet=void 0;var o=function(){if(yy)return ly;yy=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(ly,"__esModule",{value:!0}),ly.SetContainer=void 0;var n=dy(),r=by(),o=function(e){function n(t){var n=e.call(this)||this;return n.data_=t(n),n}return t(n,e),n.prototype.assign=function(e,t){this.clear(),this.insert(e,t)},n.prototype.clear=function(){this.data_.clear()},n.prototype.begin=function(){return this.data_.begin()},n.prototype.end=function(){return this.data_.end()},n.prototype.has=function(e){return!this.find(e).equals(this.end())},n.prototype.size=function(){return this.data_.size()},n.prototype.push=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(0===e.length)return this.size();var n=new r.NativeArrayIterator(e,0),o=new r.NativeArrayIterator(e,e.length);return this._Insert_by_range(n,o),this.size()},n.prototype.insert=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 1===e.length?this._Insert_by_key(e[0]):e[0].next instanceof Function&&e[1].next instanceof Function?this._Insert_by_range(e[0],e[1]):this._Insert_by_hint(e[0],e[1])},n.prototype.erase=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 1!==e.length||e[0]instanceof this.end().constructor&&e[0].source()===this?1===e.length?this._Erase_by_range(e[0]):this._Erase_by_range(e[0],e[1]):this._Erase_by_val(e[0])},n.prototype._Erase_by_range=function(e,t){void 0===t&&(t=e.next());var n=this.data_.erase(e,t);return this._Handle_erase(e,t),n},n}(n.Container);return ly.SetContainer=o,ly}(),i=Ly(),s=function(e){function o(){return null!==e&&e.apply(this,arguments)||this}return t(o,e),o.prototype.count=function(e){return this.find(e).equals(this.end())?0:1},o.prototype.insert=function(){for(var t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];return e.prototype.insert.apply(this,r([],n(t),!1))},o.prototype._Insert_by_range=function(e,t){for(;!e.equals(t);e=e.next())this._Insert_by_key(e.value)},o.prototype.extract=function(e){return e instanceof this.end().constructor?this._Extract_by_iterator(e):this._Extract_by_val(e)},o.prototype._Extract_by_val=function(e){var t=this.find(e);if(!0===t.equals(this.end()))throw i.ErrorGenerator.key_nout_found(this,"extract",e);return this._Erase_by_range(t),e},o.prototype._Extract_by_iterator=function(e){return!0===e.equals(this.end())||!1===this.has(e.value)?this.end():(this._Erase_by_range(e),e)},o.prototype._Erase_by_val=function(e){var t=this.find(e);return!0===t.equals(this.end())?0:(this._Erase_by_range(t),1)},o.prototype.merge=function(e){for(var t=e.begin();!t.equals(e.end());)!1===this.has(t.value)?(this.insert(t.value),t=e.erase(t)):t=t.next()},o}(o.SetContainer);return uy.UniqueSet=s,uy}var Py,jy={},Uy={};var By,Ny,My,$y={},zy={},Fy={};function Dy(){if(Ny)return zy;Ny=1,Object.defineProperty(zy,"__esModule",{value:!0}),zy.get_uid=void 0;var e=function(){if(By)return Fy;By=1,Object.defineProperty(Fy,"__esModule",{value:!0}),Fy._Get_root=void 0;var e=Zp;Fy._Get_root=function(){return null===t&&void 0===(t=(0,e.is_node)()?Ln:self).__s_iUID&&(t.__s_iUID=0),t};var t=null;return Fy}();return zy.get_uid=function(t){if(t instanceof Object){if(!1===t.hasOwnProperty("__get_m_iUID")){var n=++(0,e._Get_root)().__s_iUID;Object.defineProperty(t,"__get_m_iUID",{value:function(){return n}})}return t.__get_m_iUID()}return void 0===t?-1:0},zy}function Hy(){if(My)return $y;My=1;var e=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($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;n<e.length;++n)t^=e.charCodeAt(n),t*=s;return Math.abs(t)}$y.hash=function(){for(var a,c,u=[],l=0;l<arguments.length;l++)u[l]=arguments[l];var h=i;try{for(var f=e(u),d=f.next();!d.done;d=f.next()){var p=d.value,y=typeof(p=p?p.valueOf():p);if("boolean"===y)h=n(p,h);else if("number"===y||"bigint"===y)h=r(p,h);else if("string"===y)h=o(p,h);else if(p instanceof Object&&p.hashCode instanceof Function){var g=p.hashCode();if(1===u.length)return g;h^=g,h*=s}else h=r((0,t.get_uid)(p),h)}}catch(e){a={error:e}}finally{try{d&&!d.done&&(c=f.return)&&c.call(f)}finally{if(a)throw a.error}}return Math.abs(h)};var i=2166136261,s=16777619;return $y}var qy,Wy,Ky={};function Gy(){if(qy)return Ky;qy=1,Object.defineProperty(Ky,"__esModule",{value:!0}),Ky.greater_equal=Ky.greater=Ky.less_equal=Ky.less=Ky.not_equal_to=Ky.equal_to=void 0;var e=Dy();function t(e,t){return e=e?e.valueOf():e,t=t?t.valueOf():t,e instanceof Object&&e.equals instanceof Function?e.equals(t):e===t}function n(t,n){return t=t.valueOf(),n=n.valueOf(),t instanceof Object?t.less instanceof Function?t.less(n):(0,e.get_uid)(t)<(0,e.get_uid)(n):t<n}function r(e,r){return n(e,r)||t(e,r)}return Ky.equal_to=t,Ky.not_equal_to=function(e,n){return!t(e,n)},Ky.less=n,Ky.less_equal=r,Ky.greater=function(e,t){return!r(e,t)},Ky.greater_equal=function(e,t){return!n(e,t)},Ky}function Zy(){return Wy||(Wy=1,function(e){var t=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},n=Ln&&Ln.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};Object.defineProperty(e,"__esModule",{value:!0}),e.IHashContainer=void 0;var r=function(){return Py||(Py=1,e=Uy,t=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},n=Ln&&Ln.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))},Object.defineProperty(e,"__esModule",{value:!0}),e.IAssociativeContainer=void 0,function(e){e.construct=function(e){for(var r,o,i=[],s=1;s<arguments.length;s++)i[s-1]=arguments[s];return i.length>=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<arguments.length;u++)c[u-3]=arguments[u];var l=null,h=o.hash,f=i.equal_to;if(1===c.length&&c[0]instanceof s){var d=c[0];h=d.hash_function(),f=d.key_eq(),l=function(){var t=d.begin(),n=d.end();e.assign(t,n)}}else{var p=r.IAssociativeContainer.construct.apply(r.IAssociativeContainer,n([e],t(c),!1));l=p.ramda,p.tail.length>=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<arguments.length;t++)e[t]=arguments[t];if(0===e.length)return this.size();var n=new s.NativeArrayIterator(e,0),r=new s.NativeArrayIterator(e,e.length);return this._Insert_by_range(this.end(),n,r),this.size()},r.prototype.insert=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(e.source()!==this.end_.source())throw c.ErrorGenerator.not_my_iterator(this.end_.source(),"insert");if(!0===e.erased_)throw c.ErrorGenerator.erased_iterator(this.end_.source(),"insert");return 1===t.length?this._Insert_by_repeating_val(e,1,t[0]):2===t.length&&"number"==typeof t[0]?this._Insert_by_repeating_val(e,t[0],t[1]):this._Insert_by_range(e,t[0],t[1])},r.prototype._Insert_by_repeating_val=function(e,t,n){var r=new i.Repeater(0,n),o=new i.Repeater(t);return this._Insert_by_range(e,r,o)},r.prototype._Insert_by_range=function(e,t,n){for(var r=e.prev(),i=null,s=0,a=t;!1===a.equals(n);a=a.next()){var c=this._Create_iterator(r,null,a.value);0===s&&(i=c),o.ListIterator._Set_next(r,c),r=c,++s}return!0===e.equals(this.begin())&&(this.begin_=i),o.ListIterator._Set_next(r,e),o.ListIterator._Set_prev(e,r),this.size_+=s,i},r.prototype.erase=function(e,t){return void 0===t&&(t=e.next()),this._Erase_by_range(e,t)},r.prototype._Erase_by_range=function(e,t){if(e.source()!==this.end_.source())throw c.ErrorGenerator.not_my_iterator(this.end_.source(),"insert");if(!0===e.erased_)throw c.ErrorGenerator.erased_iterator(this.end_.source(),"insert");if(e.equals(this.end_))return this.end_;var n=e.prev();o.ListIterator._Set_next(n,t),o.ListIterator._Set_prev(t,n);for(var r=e;!r.equals(t);r=r.next())r.erased_=!0,--this.size_;return e.equals(this.begin_)&&(this.begin_=t),t},r.prototype.swap=function(e){var t,r,o;t=n([e.begin_,this.begin_],2),this.begin_=t[0],e.begin_=t[1],r=n([e.end_,this.end_],2),this.end_=r[0],e.end_=r[1],o=n([e.size_,this.size_],2),this.size_=o[0],e.size_=o[1]},r}(r.Container);return Xy.ListContainer=u,Xy}var ag,cg,ug={};function lg(){if(ag)return ug;ag=1,Object.defineProperty(ug,"__esModule",{value:!0}),ug.ReverseIterator=void 0;var e=function(){function e(e){this.base_=e.prev()}return e.prototype.source=function(){return this.base_.source()},e.prototype.base=function(){return this.base_.next()},Object.defineProperty(e.prototype,"value",{get:function(){return this.base_.value},enumerable:!1,configurable:!0}),e.prototype.prev=function(){return this._Create_neighbor(this.base().next())},e.prototype.next=function(){return this._Create_neighbor(this.base_)},e.prototype.equals=function(e){return this.base_.equals(e.base_)},e}();return ug.ReverseIterator=e,ug}var hg,fg,dg={},pg={};function yg(){if(hg)return pg;hg=1;var e=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(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;c<t;++c)a.push([]);try{for(var u=e(this.data_),l=u.next();!l.done;l=u.next()){var h=l.value;try{for(var f=(i=void 0,e(h)),d=f.next();!d.done;d=f.next()){var p=d.value;a[this.hasher_(this.fetcher_(p))%a.length].push(p)}}catch(e){i={error:e}}finally{try{d&&!d.done&&(s=f.return)&&s.call(f)}finally{if(i)throw i.error}}}}catch(e){r={error:e}}finally{try{l&&!l.done&&(o=u.return)&&o.call(u)}finally{if(r)throw r.error}}this.data_=a},t.prototype.reserve=function(e){e>this.capacity()&&(e=Math.floor(e/this.max_load_factor_),this.rehash(e))},t.prototype.initialize=function(){for(var e=0;e<n;++e)this.data_.push([])},t.prototype.length=function(){return this.data_.length},t.prototype.capacity=function(){return this.data_.length*this.max_load_factor_},t.prototype.at=function(e){return this.data_[e]},t.prototype.load_factor=function(){return this.size_/this.length()},t.prototype.max_load_factor=function(e){if(void 0===e&&(e=null),null===e)return this.max_load_factor_;this.max_load_factor_=e},t.prototype.hash_function=function(){return this.hasher_},t.prototype.index=function(e){return this.hasher_(this.fetcher_(e))%this.length()},t.prototype.insert=function(e){var t=this.capacity();++this.size_>t&&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;r<n.length;++r)if(n[r]===e){n.splice(r,1),--this.size_;break}},t}();pg.HashBuckets=t;var n=10,r=1;return pg}var gg,bg,mg={};function wg(){if(gg)return mg;gg=1,Object.defineProperty(mg,"__esModule",{value:!0}),mg.make_pair=mg.Pair=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)&&(0,t.equal_to)(this.second,e.second)},n.prototype.less=function(e){return!1===(0,t.equal_to)(this.first,e.first)?(0,t.less)(this.first,e.first):(0,t.less)(this.second,e.second)},n.prototype.hashCode=function(){return(0,e.hash)(this.first,this.second)},n}();return mg.Pair=n,mg.make_pair=function(e,t){return new n(e,t)},mg}function vg(){return bg||(bg=1,function(e){var t,n=Ln&&Ln.__extends||(t=function(e,n){return t=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])},t(e,n)},function(e,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=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}),r=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},o=Ln&&Ln.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};Object.defineProperty(e,"__esModule",{value:!0}),e.HashSet=void 0;var i=Iy(),s=Zy(),a=(cg||(cg=1,function(e){var t,n=Ln&&Ln.__extends||(t=function(e,n){return t=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])},t(e,n)},function(e,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=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}),r=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(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;i<arguments.length;i++)n[i]=arguments[i];var u=e.call(this,(function(e){return new a.SetElementList(e)}))||this;return s.IHashContainer.construct.apply(s.IHashContainer,o([u,t,function(e,t){u.buckets_=new c.SetHashBuckets(u,e,t)}],r(n),!1)),u}return n(t,e),t.prototype.clear=function(){this.buckets_.clear(),e.prototype.clear.call(this)},t.prototype.swap=function(e){var t,n;t=r([e.data_,this.data_],2),this.data_=t[0],e.data_=t[1],a.SetElementList._Swap_associative(this.data_,e.data_),c.SetHashBuckets._Swap_source(this.buckets_,e.buckets_),n=r([e.buckets_,this.buckets_],2),this.buckets_=n[0],e.buckets_=n[1]},t.prototype.find=function(e){return this.buckets_.find(e)},t.prototype.begin=function(t){return void 0===t&&(t=null),null===t?e.prototype.begin.call(this):this.buckets_.at(t)[0]},t.prototype.end=function(t){if(void 0===t&&(t=null),null===t)return e.prototype.end.call(this);var n=this.buckets_.at(t);return n[n.length-1].next()},t.prototype.rbegin=function(e){return void 0===e&&(e=null),this.end(e).reverse()},t.prototype.rend=function(e){return void 0===e&&(e=null),this.begin(e).reverse()},t.prototype.bucket_count=function(){return this.buckets_.length()},t.prototype.bucket_size=function(e){return this.buckets_.at(e).length},t.prototype.load_factor=function(){return this.buckets_.load_factor()},t.prototype.hash_function=function(){return this.buckets_.hash_function()},t.prototype.key_eq=function(){return this.buckets_.key_eq()},t.prototype.bucket=function(e){return this.hash_function()(e)%this.buckets_.length()},t.prototype.max_load_factor=function(e){return void 0===e&&(e=null),this.buckets_.max_load_factor(e)},t.prototype.reserve=function(e){this.buckets_.reserve(e)},t.prototype.rehash=function(e){this.buckets_.rehash(e)},t.prototype._Insert_by_key=function(e){var t=this.find(e);return!1===t.equals(this.end())?new u.Pair(t,!1):(this.data_.push(e),t=t.prev(),this._Handle_insert(t,t.next()),new u.Pair(t,!0))},t.prototype._Insert_by_hint=function(e,t){var n=this.find(t);return!0===n.equals(this.end())&&(n=this.data_.insert(e,t),this._Handle_insert(n,n.next())),n},t.prototype._Handle_insert=function(e,t){for(;!e.equals(t);e=e.next())this.buckets_.insert(e)},t.prototype._Handle_erase=function(e,t){for(;!e.equals(t);e=e.next())this.buckets_.erase(e)},t}(i.UniqueSet);e.HashSet=l,function(e){e.Iterator=a.SetElementList.Iterator,e.ReverseIterator=a.SetElementList.ReverseIterator}(l=e.HashSet||(e.HashSet={})),e.HashSet=l}(cy)),cy}var _g,xg,Eg={},kg={},Sg={};function Og(){if(xg)return kg;xg=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<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};Object.defineProperty(kg,"__esModule",{value:!0}),kg.UniqueMap=void 0;var o=function(){if(_g)return Sg;_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)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(Sg,"__esModule",{value:!0}),Sg.MapContainer=void 0;var n=dy(),r=by(),o=function(e){function n(t){var n=e.call(this)||this;return n.data_=t(n),n}return t(n,e),n.prototype.assign=function(e,t){this.clear(),this.insert(e,t)},n.prototype.clear=function(){this.data_.clear()},n.prototype.begin=function(){return this.data_.begin()},n.prototype.end=function(){return this.data_.end()},n.prototype.has=function(e){return!this.find(e).equals(this.end())},n.prototype.size=function(){return this.data_.size()},n.prototype.push=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=new r.NativeArrayIterator(e,0),o=new r.NativeArrayIterator(e,e.length);return this.insert(n,o),this.size()},n.prototype.insert=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 1===e.length?this.emplace(e[0].first,e[0].second):e[0].next instanceof Function&&e[1].next instanceof Function?this._Insert_by_range(e[0],e[1]):this.emplace_hint(e[0],e[1].first,e[1].second)},n.prototype.erase=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 1!==e.length||e[0]instanceof this.end().constructor!=0&&e[0].source()===this?1===e.length?this._Erase_by_range(e[0]):this._Erase_by_range(e[0],e[1]):this._Erase_by_key(e[0])},n.prototype._Erase_by_range=function(e,t){void 0===t&&(t=e.next());var n=this.data_.erase(e,t);return this._Handle_erase(e,t),n},n}(n.Container);return Sg.MapContainer=o,Sg}(),i=Ly(),s=function(e){function o(){return null!==e&&e.apply(this,arguments)||this}return t(o,e),o.prototype.count=function(e){return this.find(e).equals(this.end())?0:1},o.prototype.get=function(e){var t=this.find(e);if(!0===t.equals(this.end()))throw i.ErrorGenerator.key_nout_found(this,"get",e);return t.second},o.prototype.take=function(e,t){var n=this.find(e);return n.equals(this.end())?this.emplace(e,t()).first.second:n.second},o.prototype.set=function(e,t){this.insert_or_assign(e,t)},o.prototype.insert=function(){for(var t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];return e.prototype.insert.apply(this,r([],n(t),!1))},o.prototype._Insert_by_range=function(e,t){for(var n=e;!n.equals(t);n=n.next())this.emplace(n.value.first,n.value.second)},o.prototype.insert_or_assign=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 2===e.length?this._Insert_or_assign_with_key_value(e[0],e[1]):3===e.length?this._Insert_or_assign_with_hint(e[0],e[1],e[2]):void 0},o.prototype._Insert_or_assign_with_key_value=function(e,t){var n=this.emplace(e,t);return!1===n.second&&(n.first.second=t),n},o.prototype._Insert_or_assign_with_hint=function(e,t,n){var r=this.emplace_hint(e,t,n);return r.second!==n&&(r.second=n),r},o.prototype.extract=function(e){return e instanceof this.end().constructor?this._Extract_by_iterator(e):this._Extract_by_key(e)},o.prototype._Extract_by_key=function(e){var t=this.find(e);if(!0===t.equals(this.end()))throw i.ErrorGenerator.key_nout_found(this,"extract",e);var n=t.value;return this._Erase_by_range(t),n},o.prototype._Extract_by_iterator=function(e){return!0===e.equals(this.end())?this.end():(this._Erase_by_range(e),e)},o.prototype._Erase_by_key=function(e){var t=this.find(e);return!0===t.equals(this.end())?0:(this._Erase_by_range(t),1)},o.prototype.merge=function(e){for(var t=e.begin();!t.equals(e.end());)!1===this.has(t.first)?(this.insert(t.value),t=e.erase(t)):t=t.next()},o}(o.MapContainer);return kg.UniqueMap=s,kg}var Ag,Cg={};var Rg,Tg={};var Lg,Ig,Pg,jg={};function Ug(){return Ig||(Ig=1,function(e){var t,n=Ln&&Ln.__extends||(t=function(e,n){return t=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])},t(e,n)},function(e,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=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}),r=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},o=Ln&&Ln.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};Object.defineProperty(e,"__esModule",{value:!0}),e.HashMap=void 0;var i=Og(),s=Zy(),a=(Ag||(Ag=1,function(e){var t,n=Ln&&Ln.__extends||(t=function(e,n){return t=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])},t(e,n)},function(e,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=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}),r=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(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<arguments.length;i++)n[i]=arguments[i];var u=e.call(this,(function(e){return new a.MapElementList(e)}))||this;return s.IHashContainer.construct.apply(s.IHashContainer,o([u,t,function(e,t){u.buckets_=new c.MapHashBuckets(u,e,t)}],r(n),!1)),u}return n(t,e),t.prototype.clear=function(){this.buckets_.clear(),e.prototype.clear.call(this)},t.prototype.swap=function(e){var t,n;t=r([e.data_,this.data_],2),this.data_=t[0],e.data_=t[1],a.MapElementList._Swap_associative(this.data_,e.data_),c.MapHashBuckets._Swap_source(this.buckets_,e.buckets_),n=r([e.buckets_,this.buckets_],2),this.buckets_=n[0],e.buckets_=n[1]},t.prototype.find=function(e){return this.buckets_.find(e)},t.prototype.begin=function(t){return void 0===t&&(t=null),null===t?e.prototype.begin.call(this):this.buckets_.at(t)[0]},t.prototype.end=function(t){if(void 0===t&&(t=null),null===t)return e.prototype.end.call(this);var n=this.buckets_.at(t);return n[n.length-1].next()},t.prototype.rbegin=function(e){return void 0===e&&(e=null),this.end(e).reverse()},t.prototype.rend=function(e){return void 0===e&&(e=null),this.begin(e).reverse()},t.prototype.bucket_count=function(){return this.buckets_.length()},t.prototype.bucket_size=function(e){return this.buckets_.at(e).length},t.prototype.load_factor=function(){return this.buckets_.load_factor()},t.prototype.hash_function=function(){return this.buckets_.hash_function()},t.prototype.key_eq=function(){return this.buckets_.key_eq()},t.prototype.bucket=function(e){return this.hash_function()(e)%this.buckets_.length()},t.prototype.max_load_factor=function(e){return void 0===e&&(e=null),this.buckets_.max_load_factor(e)},t.prototype.reserve=function(e){this.buckets_.reserve(e)},t.prototype.rehash=function(e){this.buckets_.rehash(e)},t.prototype.emplace=function(e,t){var n=this.find(e);return!1===n.equals(this.end())?new l.Pair(n,!1):(this.data_.push(new u.Entry(e,t)),n=n.prev(),this._Handle_insert(n,n.next()),new l.Pair(n,!0))},t.prototype.emplace_hint=function(e,t,n){var r=this.find(t);return!0===r.equals(this.end())&&(r=this.data_.insert(e,new u.Entry(t,n)),this._Handle_insert(r,r.next())),r},t.prototype._Handle_insert=function(e,t){for(;!e.equals(t);e=e.next())this.buckets_.insert(e)},t.prototype._Handle_erase=function(e,t){for(;!e.equals(t);e=e.next())this.buckets_.erase(e)},t}(i.UniqueMap);e.HashMap=h,function(e){e.Iterator=a.MapElementList.Iterator,e.ReverseIterator=a.MapElementList.ReverseIterator}(h=e.HashMap||(e.HashMap={})),e.HashMap=h}(Eg)),Eg}var Bg,Ng={};function Mg(){if(Bg)return Ng;Bg=1,Object.defineProperty(Ng,"__esModule",{value:!0});var e=function(e,t){this.type=e,t&&Object.assign(this,t)};return Ng.Event=e,Ng}var $g,zg={};var Fg,Dg={};var Hg,qg,Wg={};Zp.is_node()&&(Ln.WebSocket=(qg||(qg=1,function(e){var t,n=Ln&&Ln.__extends||(t=function(e,n){return t=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])},t(e,n)},function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}),r=Ln&&Ln.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0});var o=oy(),i=function(){if(Pg)return ay;Pg=1;var e=Ln&&Ln.__values||function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=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);e<t.length;e++){const n=t[e],r=rb[t[e]].toString();ob[r]=n}const ib={1:e=>Gg.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<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:A}}function A(){return{value:void 0,done:!0}}return d.prototype=p,r(m,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:d,configurable:!0}),d.displayName=c(p,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,c(e,a,"GeneratorFunction")),e.prototype=Object.create(m),e},e.awrap=function(e){return{__await:e}},w(v.prototype),c(v.prototype,s,(function(){return this})),e.AsyncIterator=v,e.async=function(t,n,r,o,i){void 0===i&&(i=Promise);var s=new v(u(t,n,r,o),i);return e.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},w(m),c(m,a,"Generator"),c(m,i,(function(){return this})),c(m,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=O,S.prototype={constructor:S,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return s.type="throw",s.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=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<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=e,s.arg=t,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=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<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Pb.apply(this,arguments)}var jb=function(){function e(e){this.events=new _a,this.relay=e.relay||"wss://nostr.vulpem.com",this.self={pubkey:Co(e.secretKey),secret:e.secretKey}}var t=e.prototype;return t.call=function(){var e=Ib(Tb().mark((function e(t,n){var r,o,i,s,a,c,u,l,h,f,d=this;return Tb().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.target,o=t.request,i=o.id,s=void 0===i?Bb():i,a=o.method,c=o.params,u=void 0===c?[]:c,e.next=3,Hb(this.relay);case 3:return l=e.sent,h=Nb(s,a,u),e.next=7,$b(this.self.secret,r,h);case 7:return f=e.sent,e.abrupt("return",new Promise(function(){var e=Ib(Tb().mark((function e(t,o){var i;return Tb().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=l.sub([{kinds:[24133],authors:[r],"#p":[d.self.pubkey],limit:1}]),e.next=3,Wb(l,f,!0);case 3:n&&!0===n.skipResponse&&t(),i.on("event",function(){var e=Ib(Tb().mark((function e(n){var r,i;return Tb().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,ci.decrypt(d.self.secret,n.pubkey,n.content);case 3:if(i=e.sent){e.next=6;break}throw new Error("failed to decrypt event");case 6:r=JSON.parse(i),e.next=12;break;case 9:return e.prev=9,e.t0=e.catch(0),e.abrupt("return");case 12:if(Db(r)){e.next=14;break}return e.abrupt("return");case 14:if(r.id===s){e.next=16;break}return e.abrupt("return");case 16:r.error&&o(r.error),r.result&&t(r.result);case 18:case"end":return e.stop()}}),e,null,[[0,9]])})));return function(t){return e.apply(this,arguments)}}());case 5:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}()));case 9:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),t.listen=function(){var e=Ib(Tb().mark((function e(){var t,n,r=this;return Tb().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Hb(this.relay);case 2:return t=e.sent,(n=t.sub([{kinds:[24133],"#p":[this.self.pubkey],since:Ub()}])).on("event",function(){var e=Ib(Tb().mark((function e(n){var o,i,s,a,c;return Tb().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,ci.decrypt(r.self.secret,n.pubkey,n.content);case 3:if(i=e.sent){e.next=6;break}throw new Error("failed to decrypt event");case 6:o=JSON.parse(i),e.next=12;break;case 9:return e.prev=9,e.t0=e.catch(0),e.abrupt("return");case 12:if(Fb(o)){e.next=14;break}return e.abrupt("return");case 14:return e.next=17,r.handleRequest(o,n);case 17:return s=e.sent,a=Mb(s.id,s.result,s.error),e.next=21,$b(r.self.secret,n.pubkey,a);case 21:c=e.sent,t.publish(c);case 23:case"end":return e.stop()}}),e,null,[[0,9]])})));return function(t){return e.apply(this,arguments)}}()),e.abrupt("return",n);case 6:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.handleRequest=function(){var e=Ib(Tb().mark((function e(t,n){var r,o,i,s,a;return Tb().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.id,o=t.method,i=t.params,s=null,a=null,e.prev=3,this.event=n,e.next=7,this[o].apply(this,i);case 7:s=e.sent,this.event=void 0,e.next=14;break;case 11:e.prev=11,e.t0=e.catch(3),a=e.t0 instanceof Error?e.t0.message:"unknown error";case 14:return e.abrupt("return",{id:r,result:s,error:a});case 15:case"end":return e.stop()}}),e,this,[[3,11]])})));return function(t,n){return e.apply(this,arguments)}}(),e}();function Ub(){return Math.floor(Date.now()/1e3)}function Bb(){return Math.random().toString().slice(2)}function Nb(e,t,n){return JSON.stringify({id:e,method:t,params:n})}function Mb(e,t,n){return JSON.stringify({id:e,result:t,error:n})}function $b(e,t,n){return zb.apply(this,arguments)}function zb(){return(zb=Ib(Tb().mark((function e(t,n,r){var o,i,s,a,c,u,l;return Tb().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ci.encrypt(t,n,r);case 2:if(o=e.sent,i={kind:24133,created_at:Ub(),pubkey:Co(t),tags:[["p",n]],content:o},s=Uo(i),a=Mo(i,t),c=Pb({},i,{id:s,sig:a}),u=Bo(c),l=No(c),u&&l){e.next=11;break}throw new Error("Event is not valid");case 11:return e.abrupt("return",c);case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Fb(e){if(!e)return!1;var t=Object.keys(e);return!!(t.includes("id")&&t.includes("method")&&t.includes("params"))}function Db(e){if(!e)return!1;var t=Object.keys(e);return!!(t.includes("id")&&t.includes("result")&&t.includes("error"))}function Hb(e){return qb.apply(this,arguments)}function qb(){return qb=Ib(Tb().mark((function e(t){var n;return Tb().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Go(t),e.next=3,n.connect();case 3:return e.next=5,new Promise((function(e,t){n.on("connect",(function(){e()})),n.on("error",(function(){t(new Error("not possible to connect to "+n.url))}))}));case 5:return e.abrupt("return",n);case 6:case"end":return e.stop()}}),e)}))),qb.apply(this,arguments)}function Wb(e,t,n){return Kb.apply(this,arguments)}function Kb(){return Kb=Ib(Tb().mark((function e(t,n,r){return Tb().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===r&&(r=!1),e.next=3,new Promise((function(e,o){t.on("error",(function(){o(new Error("failed to connect to "+t.url))}));var i=t.publish(n);r&&e(),i.on("failed",(function(e){o(e)})),i.on("seen",(function(){e()}))}));case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e)}))),Kb.apply(this,arguments)}var Gb=function(){function e(e){var t=e.target,n=e.metadata,r=e.relay;this.target=t,this.metadata=n,this.relay=r}e.fromURI=function(t){var n=new URL(t),r=n.hostname||n.pathname.substring(2);if(!r)throw new Error("Invalid connect URI: missing target");var o=n.searchParams.get("relay");if(!o)throw new Error("Invalid connect URI: missing relay");var i=n.searchParams.get("metadata");if(!i)throw new Error("Invalid connect URI: missing metadata");try{return new e({target:r,metadata:JSON.parse(i),relay:o})}catch(e){throw new Error("Invalid connect URI: metadata is not valid JSON")}};var t=e.prototype;return t.toString=function(){return"nostrconnect://"+this.target+"?metadata="+encodeURIComponent(JSON.stringify(this.metadata))+"&relay="+encodeURIComponent(this.relay)},t.approve=function(){var e=Ib(Tb().mark((function e(t){var n;return Tb().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new jb({relay:this.relay,secretKey:t}),e.next=3,n.call({target:this.target,request:{method:"connect",params:[Co(t)]}},{skipResponse:!0});case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.reject=function(){var e=Ib(Tb().mark((function e(t){var n;return Tb().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new jb({relay:this.relay,secretKey:t}),e.next=3,n.call({target:this.target,request:{method:"disconnect",params:[]}},{skipResponse:!0});case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),e}(),Zb=function(){function e(e){var t,n,r=e.target,o=e.relay,i=e.secretKey;this.events=new _a,this.nip04={encrypt:(n=Ib(Tb().mark((function e(t,n){return Tb().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("Not implemented");case 1:case"end":return e.stop()}}),e)}))),function(e,t){return n.apply(this,arguments)}),decrypt:(t=Ib(Tb().mark((function e(t,n){return Tb().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("Not implemented");case 1:case"end":return e.stop()}}),e)}))),function(e,n){return t.apply(this,arguments)})},this.rpc=new jb({relay:o,secretKey:i}),r&&(this.target=r)}var t=e.prototype;return t.init=function(){var e=Ib(Tb().mark((function e(){var t=this;return Tb().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.rpc.listen();case 2:e.sent.on("event",function(){var e=Ib(Tb().mark((function e(n){var r,o,i,s;return Tb().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,ci.decrypt(t.rpc.self.secret,n.pubkey,n.content);case 3:if(o=e.sent){e.next=6;break}throw new Error("failed to decrypt event");case 6:r=JSON.parse(o),e.next=12;break;case 9:return e.prev=9,e.t0=e.catch(0),e.abrupt("return");case 12:if(Fb(r)){e.next=14;break}return e.abrupt("return");case 14:e.t1=r.method,e.next="connect"===e.t1?17:"disconnect"===e.t1?23:26;break;case 17:if(r.params&&1===r.params.length){e.next=19;break}throw new Error("connect: missing pubkey");case 19:return i=r.params,s=i[0],t.target=s,t.events.emit("connect",s),e.abrupt("break",26);case 23:return t.target=void 0,t.events.emit("disconnect"),e.abrupt("break",26);case 26:case"end":return e.stop()}}),e,null,[[0,9]])})));return function(t){return e.apply(this,arguments)}}());case 4:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.on=function(e,t){this.events.on(e,t)},t.off=function(e,t){this.events.off(e,t)},t.disconnect=function(){var e=Ib(Tb().mark((function e(){return Tb().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.target){e.next=2;break}throw new Error("Not connected");case 2:return this.events.emit("disconnect"),e.prev=3,e.next=6,this.rpc.call({target:this.target,request:{method:"disconnect",params:[]}},{skipResponse:!0});case 6:e.next=11;break;case 8:throw e.prev=8,e.t0=e.catch(3),new Error("Failed to disconnect");case 11:this.target=void 0;case 12:case"end":return e.stop()}}),e,this,[[3,8]])})));return function(){return e.apply(this,arguments)}}(),t.getPublicKey=function(){var e=Ib(Tb().mark((function e(){var t;return Tb().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.target){e.next=2;break}throw new Error("Not connected");case 2:return e.next=4,this.rpc.call({target:this.target,request:{method:"get_public_key",params:[]}});case 4:return t=e.sent,e.abrupt("return",t);case 6:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.signEvent=function(){var e=Ib(Tb().mark((function e(t){var n;return Tb().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.target){e.next=2;break}throw new Error("Not connected");case 2:return e.next=4,this.rpc.call({target:this.target,request:{method:"sign_event",params:[t]}});case 4:return n=e.sent,e.abrupt("return",n);case 6:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.getRelays=function(){var e=Ib(Tb().mark((function e(){return Tb().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("Not implemented");case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),e}();class Vb extends Cb{#m=null;constructor(e,t,n={}){super(e,n),this.#m=t}async signEvent(e){const t=new Zb({secretKey:this.#m,target:this.pubkey});return await t.init(),e.sig=await t.signEvent("12323423434"),e}}class Yb extends Cb{#w;constructor(e={}){let t=localStorage.getItem("nostrichat-discardable-key"),n=localStorage.getItem("nostrichat-discardable-public-key");t||(t=Ao(),console.log("generated key",t),n=Co(t)),localStorage.setItem("nostrichat-discardable-key",t),localStorage.setItem("nostrichat-discardable-public-key",n),super(n,e),this.#w=t,console.log(t)}async signEvent(e){return e.sig=await Mo(e,this.#w),e}async encrypt(e,t){return console.log(this.#w),await ci.encrypt(this.#w,e,t)}async decrypt(e,t){return await ci.decrypt(this.#w,e,t)}}function Xb(t){let n,o,i,s,a,c,u,l=function(t){let n,r,o;return{c(){n=w("button"),n.textContent="Browser Extension (NIP-07)",S(n,"class","bg-purple-900 hover:bg-purple-700 w-full p-4 rounded-xl text-center font-regular text-gray-200 svelte-f7jodf")},m(e,i){g(e,n,i),r||(o=E(n,"click",k(t[1])),r=!0)},p:e,d(e){e&&b(n),r=!1,o()}}}(t);return{c(){n=w("div"),l&&l.c(),o=_(),i=w("button"),i.textContent="Nostr Connect (NIP-46)",s=_(),a=w("button"),a.innerHTML='Anonymous\n <span class="text-xs text-gray-300 svelte-f7jodf">(Ephemeral Keys)</span>',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;t<r.length;t+=1)o[t]=jm(Sm(e,r,t));const i=e=>V(o[e],1,1,(()=>{o[e]=null}));return{c(){t=w("div");for(let e=0;e<o.length;e+=1)o[e].c();S(t,"class","pl-5 border-l border-l-gray-400 flex flex-col gap-4 svelte-f7jodf")},m(e,r){g(e,t,r);for(let e=0;e<o.length;e+=1)o[e].m(t,null);n=!0},p(e,n){if(7&n[0]){let s;for(r=e[1][e[0].id],s=0;s<r.length;s+=1){const i=Sm(e,r,s);o[s]?(o[s].p(i,n),Z(o[s],1)):(o[s]=jm(i),o[s].c(),Z(o[s],1),o[s].m(t,null))}for(K(),s=r.length;s<o.length;s+=1)i(s);G()}},i(e){if(!n){for(let e=0;e<r.length;e+=1)Z(o[e]);n=!0}},o(e){o=o.filter(Boolean);for(let e=0;e<o.length;e+=1)V(o[e]);n=!1},d(e){e&&b(t),m(o,e)}}}function jm(e){let t,n;return t=new Nm({props:{websiteOwnerPubkey:e[2],event:e[32],responses:e[1]}}),{c(){X(t.$$.fragment)},m(e,r){J(t,e,r),n=!0},p(e,n){const r={};4&n[0]&&(r.websiteOwnerPubkey=e[2]),3&n[0]&&(r.event=e[32]),2&n[0]&&(r.responses=e[1]),t.$set(r)},i(e){n||(Z(t.$$.fragment,e),n=!0)},o(e){V(t.$$.fragment,e),n=!1},d(e){Q(t,e)}}}function Um(e){let t,n,o,i,s,c,u,l,h,f,d,p,m,A,C,R,T,L,I,P,j,U,B,N,M,$,z,F,D,H,q=e[0].content+"";function W(e,t){return e[9]>0?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='<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6 svelte-f7jodf"><path stroke-linecap="round" stroke-linejoin="round" d="M19.5 12h-15m0 0l6.75 6.75M4.5 12l6.75-6.75" class="svelte-f7jodf"></path></svg>',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;t<r.length;t+=1)o[t]=nw(Hm(e,r,t));const i=e=>V(o[e],1,1,(()=>{o[e]=null}));return{c(){for(let e=0;e<o.length;e+=1)o[e].c();t=x()},m(e,r){for(let t=0;t<o.length;t+=1)o[t].m(e,r);g(e,t,r),n=!0},p(e,n){if(25&n[0]){let s;for(r=e[3],s=0;s<r.length;s+=1){const i=Hm(e,r,s);o[s]?(o[s].p(i,n),Z(o[s],1)):(o[s]=nw(i),o[s].c(),Z(o[s],1),o[s].m(t.parentNode,t))}for(K(),s=r.length;s<o.length;s+=1)i(s);G()}},i(e){if(!n){for(let e=0;e<r.length;e+=1)Z(o[e]);n=!0}},o(e){o=o.filter(Boolean);for(let e=0;e<o.length;e+=1)V(o[e]);n=!1},d(e){m(o,e),e&&b(t)}}}function ew(e){let t,n;return t=new Nm({props:{event:e[10](e[9]),responses:e[4],websiteOwnerPubkey:e[0]}}),{c(){X(t.$$.fragment)},m(e,r){J(t,e,r),n=!0},p(e,n){const r={};512&n[0]&&(r.event=e[10](e[9])),16&n[0]&&(r.responses=e[4]),1&n[0]&&(r.websiteOwnerPubkey=e[0]),t.$set(r)},i(e){n||(Z(t.$$.fragment,e),n=!0)},o(e){V(t.$$.fragment,e),n=!1},d(e){Q(t,e)}}}function tw(e){let t;return{c(){t=v("👆 deleted")},m(e,n){g(e,t,n)},d(e){e&&b(t)}}}function nw(e){let t,n,r,o;t=new Nm({props:{event:e[27],responses:e[4],websiteOwnerPubkey:e[0]}});let i=e[27].deleted&&tw();return{c(){X(t.$$.fragment),n=_(),i&&i.c(),r=x()},m(e,s){J(t,e,s),g(e,n,s),i&&i.m(e,s),g(e,r,s),o=!0},p(e,n){const o={};8&n[0]&&(o.event=e[27]),16&n[0]&&(o.responses=e[4]),1&n[0]&&(o.websiteOwnerPubkey=e[0]),t.$set(o),e[27].deleted?i||(i=tw(),i.c(),i.m(r.parentNode,r)):i&&(i.d(1),i=null)},i(e){o||(Z(t.$$.fragment,e),o=!0)},o(e){V(t.$$.fragment,e),o=!1},d(e){Q(t,e),e&&b(n),i&&i.d(e),e&&b(r)}}}function rw(e){let t,n;return{c(){t=w("b"),t.textContent="Public notes:",n=v("\n your followers see your messages on their timeline"),S(t,"class","svelte-f7jodf")},m(e,r){g(e,t,r),g(e,n,r)},d(e){e&&b(t),e&&b(n)}}}function ow(e){let t,n;return{c(){t=w("b"),t.textContent="Public chat:",n=v("\n anyone can see these messages."),S(t,"class","svelte-f7jodf")},m(e,r){g(e,t,r),g(e,n,r)},d(e){e&&b(t),e&&b(n)}}}function iw(e){let t,n;return{c(){t=w("b"),t.textContent="Encrypted chat:",n=v("\n only your chat partner can see these messages."),S(t,"class","svelte-f7jodf")},m(e,r){g(e,t,r),g(e,n,r)},d(e){e&&b(t),e&&b(n)}}}function sw(e){let t,n,o,i,s,a,c,u,l,h,f,d,p,x,C,R,T,L,I,P,j,U,B,N,M,$,z,F,D=e[2]?.pubkey&&Wm(e),H=Array(e[7]),q=[];for(let t=0;t<H.length;t+=1)q[t]=Km(qm(e,H,t));let W=e[5].name&&Gm(e),Y=e[9]&&Ym(e);const X=[ew,Qm],J=[];function Q(e,t){return e[9]?0:1}function ee(e,t){return"DM"===e[1].chatType?iw:"GROUP"===e[1].chatType?ow:rw}R=Q(e),T=J[R]=X[R](e);let te=ee(e),ne=te(e);return{c(){t=w("div"),n=w("div"),D&&D.c(),o=_(),i=w("span"),s=w("div");for(let e=0;e<q.length;e+=1)q[e].c();a=_(),c=v(e[6]),u=v("/"),l=v(e[7]),h=v(" relays"),f=_(),W&&W.c(),d=_(),Y&&Y.c(),p=_(),x=w("div"),C=w("div"),T.c(),L=_(),I=w("div"),P=w("div"),ne.c(),j=_(),U=w("div"),B=w("textarea"),N=_(),M=w("button"),M.innerHTML='<svg aria-hidden="true" class="w-6 h-6 rotate-90 svelte-f7jodf" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10.894 2.553a1 1 0 00-1.788 0l-7 14a1 1 0 001.169 1.409l5-1.429A1 1 0 009 15.571V11a1 1 0 112 0v4.571a1 1 0 00.725.962l5 1.428a1 1 0 001.17-1.408l-7-14z" class="svelte-f7jodf"></path></svg>',S(n,"class","text-lg font-semibold svelte-f7jodf"),S(s,"class","flex flex-row gap-1 overflow-clip svelte-f7jodf"),S(i,"class","text-xs flex flex-col items-end mt-2 text-gray-200 gap-1 svelte-f7jodf"),S(t,"class","bg-purple-700 text-white -mx-4 -mt-5 mb-3 px-4 py-3 overflow-clip flex flex-row justify-between items-center svelte-f7jodf"),S(C,"id","messages-container-inner"),S(C,"class","flex flex-col gap-4 svelte-f7jodf"),S(x,"id","messages-container"),S(x,"class","overflow-auto -mx-4 px-4 svelte-f7jodf"),A(x,"height","50vh"),A(x,"min-height","300px"),S(P,"class","border-y border-y-slate-200 -mx-4 my-2 bg-slate-100 text-black text-sm px-4 py-2 svelte-f7jodf"),S(B,"type","text"),S(B,"id","message-input"),S(B,"class","-mb-2 p-2 w-full resize-none rounded-xl text-gray-600 border svelte-f7jodf"),S(B,"placeholder","Say hello!"),S(B,"rows","1"),S(M,"type","button"),S(M,"class","inline-flex items-center rounded-full border border-transparent bg-purple-700 p-3 text-white shadow-sm hover:bg-purple-600 focus:outline-none focus:ring-2 focus:ring-purple-500 focus:ring-offset-2 svelte-f7jodf"),S(U,"class","flex flex-row gap-2 -mx-1 svelte-f7jodf"),S(I,"class","flex flex-col svelte-f7jodf")},m(r,b){g(r,t,b),y(t,n),D&&D.m(n,null),y(t,o),y(t,i),y(i,s);for(let e=0;e<q.length;e+=1)q[e].m(s,null);y(i,a),y(i,c),y(i,u),y(i,l),y(i,h),g(r,f,b),W&&W.m(r,b),g(r,d,b),Y&&Y.m(r,b),g(r,p,b),g(r,x,b),y(x,C),J[R].m(C,null),g(r,L,b),g(r,I,b),y(I,P),ne.m(P,null),y(I,j),y(I,U),y(U,B),y(U,N),y(U,M),$=!0,z||(F=[E(B,"keydown",e[12]),E(M,"click",k(e[11]))],z=!0)},p(e,t){if(e[2]?.pubkey?D?D.p(e,t):(D=Wm(e),D.c(),D.m(n,null)):D&&(D.d(1),D=null),192&t[0]){let n;for(H=Array(e[7]),n=0;n<H.length;n+=1){const r=qm(e,H,n);q[n]?q[n].p(r,t):(q[n]=Km(r),q[n].c(),q[n].m(s,null))}for(;n<q.length;n+=1)q[n].d(1);q.length=H.length}(!$||64&t[0])&&O(c,e[6]),(!$||128&t[0])&&O(l,e[7]),e[5].name?W?W.p(e,t):(W=Gm(e),W.c(),W.m(d.parentNode,d)):W&&(W.d(1),W=null),e[9]?Y?Y.p(e,t):(Y=Ym(e),Y.c(),Y.m(p.parentNode,p)):Y&&(Y.d(1),Y=null);let r=R;R=Q(e),R===r?J[R].p(e,t):(K(),V(J[r],1,1,(()=>{J[r]=null})),G(),T=J[R],T?T.p(e,t):(T=J[R]=X[R](e),T.c()),Z(T,1),T.m(C,null)),te!==(te=ee(e))&&(ne.d(1),ne=te(e),ne&&(ne.c(),ne.m(P,null)))},i(e){$||(Z(T),$=!0)},o(e){V(T),$=!1},d(e){e&&b(t),D&&D.d(),m(q,e),e&&b(f),W&&W.d(e),e&&b(d),Y&&Y.d(e),e&&b(p),e&&b(x),J[R].d(),e&&b(L),e&&b(I),ne.d(),z=!1,r(F)}}}function aw(e,t,n){let r,o,i,s;c(e,ie,(e=>n(2,r=e))),c(e,ae,(e=>n(9,o=e))),c(e,se,(e=>n(18,i=e))),c(e,ue,(e=>n(21,s=e)));let a,l,h=[],f=[],d={},p={},{websiteOwnerPubkey:y}=t,{chatConfiguration:g}=t;function b(e){let t=h.find((t=>t.id===e));return t=t||f.find((t=>t.id===e)),t}async function m(){const e=document.getElementById("message-input"),t=e.value;e.value="";let n={tags:[],tagPubKeys:[]};!l&&y&&(n.tagPubKeys=[y]),o&&(n.tags.push(["e",o,"wss://nos.lol","root"]),n.tagPubKeys.push(b(o).pubkey));const i=await r.send(t,n);l||(l=i,localStorage.setItem("rootNoteId",l))}function w(e){let t;if(e.tags.filter((e=>"e"===e[0])).pop(),"GLOBAL"===g.chatType)t=e.tags.filter((e=>"e"===e[0])).length>=1;else if("GROUP"===g.chatType)t=e.tags.filter((e=>"e"===e[0]&&e[1]!==g.chatId)).length>=1;else{const n=e.tags.filter((e=>"p"===e[0])).map((e=>e[1]));t=new Set(n).size>=2}if(d[e.id]||n(4,d[e.id]=[],d),t){const t=e.tags.filter((e=>"e"===e[0])).pop();t&&t[1]&&(d[t[1]]||n(4,d[t[1]]=[],d),d[t[1]].push(e)),f.push(e)}else{let t=0;for(;t<h.length&&h[t].created_at<e.created_at;)t++;h.splice(t,0,e),n(3,h),n(1,g),n(15,a),n(2,r)}n(4,d),n(1,g),n(15,a),n(2,r),v()}function v(){Dm({container:document.getElementById("messages-container"),offset:999999,duration:50})}function _(e){const t=h.find((t=>t.id===e.zappedEvent));t&&(s[t.id]||u(ue,s[t.id]=[],s),s[t.id].push(e))}function x(e){const t=h.find((t=>t.id===e.id));t&&(t.reactions=t.reactions||[],t.reactions.push(e),n(3,h),n(1,g),n(15,a),n(2,r))}let E={};L((()=>{r.on("message",w),r.on("connectivity",(e=>{n(16,O=e)})),r.on("reaction",x),r.on("zap",_),r.on("deleted",(e=>{e.forEach((e=>{const t=h.findIndex((t=>t.id===e));-1!==t&&(n(3,h[t].deleted=!0,h),n(3,h),n(1,g),n(15,a),n(2,r))}))})),r.on("profile",(({pubkey:e,profile:t})=>{let n=i.profiles;n[e]=t,se.set({profiles:n,...i})})),r.on("channelMetadata",(e=>{n(5,E=JSON.parse(e.content))}))}));let k,S,O={},A=0,C=0;return e.$$set=e=>{"websiteOwnerPubkey"in e&&n(0,y=e.websiteOwnerPubkey),"chatConfiguration"in e&&n(1,g=e.chatConfiguration)},e.$$.update=()=>{32774&e.$$.dirty[0]&&(g!==a&&r&&(r.setChatConfiguration(g.chatType,g.chatTags,g.chatReferenceTags,g.chatId),n(3,h=[]),n(4,d={}),l=null,localStorage.removeItem("rootNoteId")),n(15,a=g)),262144&e.$$.dirty[0]&&n(14,p=i.profiles),81924&e.$$.dirty[0]&&(n(6,A=Object.values(O).filter((e=>"connected"===e)).length),n(7,C=Object.values(O).length),r?.pubkey&&!p[r.pubkey]&&r.reqProfile(r.pubkey)),131076&e.$$.dirty[0]&&k!==r?.chatId&&(n(17,k=r?.chatId),n(5,E={})),4&e.$$.dirty[0]&&n(8,S=r?.pubkey?function(e){let t;if(p[r.pubkey]){let e=p[r.pubkey];t=e.display_name||e.displayName||e.name||e.nip05}return t||(t=`[${e.slice(0,6)}]`),t}(r.pubkey):"")},[y,g,r,h,d,E,A,C,S,o,b,m,async function(e){"Enter"===e.key&&(m(),e.preventDefault())},function(){if("GROUP"===g.chatType)u(ae,o=null,o);else{const e=b(o).tags.filter((e=>"e"===e[0])).pop(),t=e&&e[1];u(ae,o=t,o)}v()},p,a,O,k,i]}class cw extends ne{constructor(e){super(),te(this,e,aw,sw,i,{websiteOwnerPubkey:0,chatConfiguration:1},null,[-1,-1])}}function uw(e){let t,n;return t=new cw({props:{websiteOwnerPubkey:e[1],chatConfiguration:e[2],relays:e[3]}}),{c(){X(t.$$.fragment)},m(e,r){J(t,e,r),n=!0},p(e,n){const r={};2&n&&(r.websiteOwnerPubkey=e[1]),4&n&&(r.chatConfiguration=e[2]),8&n&&(r.relays=e[3]),t.$set(r)},i(e){n||(Z(t.$$.fragment,e),n=!0)},o(e){V(t.$$.fragment,e),n=!1},d(e){Q(t,e)}}}function lw(e){let t,n;return t=new tm({props:{websiteOwnerPubkey:e[1],chatConfiguration:e[2],relays:e[3]}}),{c(){X(t.$$.fragment)},m(e,r){J(t,e,r),n=!0},p(e,n){const r={};2&n&&(r.websiteOwnerPubkey=e[1]),4&n&&(r.chatConfiguration=e[2]),8&n&&(r.relays=e[3]),t.$set(r)},i(e){n||(Z(t.$$.fragment,e),n=!0)},o(e){V(t.$$.fragment,e),n=!1},d(e){Q(t,e)}}}function hw(e){let t,n,r,o;const i=[lw,uw],s=[];function a(e,t){return e[0]?1:0}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 fw(e,t,n){let r;c(e,ie,(e=>n(4,r=e)));let{websiteOwnerPubkey:o}=t,{chatStarted:i}=t,{chatConfiguration:s}=t,{relays:a}=t;return e.$$set=e=>{"websiteOwnerPubkey"in e&&n(1,o=e.websiteOwnerPubkey),"chatStarted"in e&&n(0,i=e.chatStarted),"chatConfiguration"in e&&n(2,s=e.chatConfiguration),"relays"in e&&n(3,a=e.relays)},e.$$.update=()=>{16&e.$$.dirty&&n(0,i=!!r)},[i,o,s,a,r]}class dw extends ne{constructor(e){super(),te(this,e,fw,hw,i,{websiteOwnerPubkey:1,chatStarted:0,chatConfiguration:2,relays:3})}}function pw(e){let t,n,r,o;return n=new dw({props:{websiteOwnerPubkey:e[0],chatConfiguration:{chatType:e[1],chatTags:e[2],chatId:e[5],chatReferenceTags:e[3]},relays:e[4]}}),{c(){t=w("div"),X(n.$$.fragment),S(t,"class",r="shadow-2xl bg-white/90 backdrop-brightness-150 backdrop-blur-md mb-5 w-96 max-w-screen-sm text-black rounded-3xl p-5 overflow-auto flex flex-col justify-end "+(e[7]?"hidden":"")+" svelte-f7jodf"),A(t,"max-height","80vh")},m(e,r){g(e,t,r),J(n,t,null),o=!0},p(e,i){const s={};1&i&&(s.websiteOwnerPubkey=e[0]),46&i&&(s.chatConfiguration={chatType:e[1],chatTags:e[2],chatId:e[5],chatReferenceTags:e[3]}),16&i&&(s.relays=e[4]),n.$set(s),(!o||128&i&&r!==(r="shadow-2xl bg-white/90 backdrop-brightness-150 backdrop-blur-md mb-5 w-96 max-w-screen-sm text-black rounded-3xl p-5 overflow-auto flex flex-col justify-end "+(e[7]?"hidden":"")+" svelte-f7jodf"))&&S(t,"class",r)},i(e){o||(Z(n.$$.fragment,e),o=!0)},o(e){V(n.$$.fragment,e),o=!1},d(e){e&&b(t),Q(n)}}}function yw(e){let t,n,r,o,i,s,a,c=e[6]&&pw(e);return{c(){t=w("div"),c&&c.c(),n=_(),r=w("div"),o=w("a"),o.innerHTML='<span class="tracking-wider flex svelte-f7jodf"><span class="text-white svelte-f7jodf">Nostri</span><span class="text-purple-300 svelte-f7jodf">Chat</span></span> \n <svg fill="#ffffff" version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="25px" height="25px" viewBox="0 0 571.004 571.004" xml:space="preserve" class="svelte-f7jodf"><g class="svelte-f7jodf"><g class="svelte-f7jodf"><path d="M533.187,269.019c-1.432-1.746-2.219-3.876-1.252-5.993c1.868-4.08,0.611-7.658-0.931-11.465\n c-0.877-2.167-0.796-4.716-1.15-7.095c-0.221-1.493-0.057-3.199-0.742-4.435c-1.775-3.199-3.812-6.275-5.949-9.245\n c-2.681-3.717-5.564-7.291-8.38-10.914c-3.325-4.284-6.581-8.633-10.09-12.766c-0.706-0.833-2.604-1.42-3.607-1.085\n c-2.411,0.808-4.732,2.052-6.874,3.452c-2.771,1.812-5.435,3.317-8.928,3.713c-3.953,0.453-8.062,1.403-11.604,3.154\n c-5.189,2.562-9.747,6.401-14.924,9c-4.913,2.464-8.328,6.112-11.184,10.567c-0.783,1.22-1.705,2.371-2.685,3.444\n c-3.252,3.574-5.549,7.629-7.051,12.248c-1.154,3.554-2.378,7.226-4.373,10.322c-1.963,3.044-3.256,6.194-4.162,9.601\n c-0.285,1.065-0.44,2.167-0.656,3.251c-2.212-0.539-4.19-0.873-6.06-1.518c-1.709-0.592-3.684-1.15-4.879-2.375\n c-2.979-3.052-6.528-5.059-10.388-6.577c-3.448-1.354-6.581-3.06-9.441-5.496c-1.514-1.29-3.771-1.738-5.721-2.489\n c-1.419-0.547-3.043-0.714-4.3-1.501c-3.439-2.146-6.639-4.68-10.11-6.765c-2.256-1.359-4.737-2.542-7.271-3.166\n c-1.722-0.424-2.293-0.865-2.216-2.599c0.241-5.227-0.832-10.175-3.235-14.872c-2.855-5.582-8.723-8.625-14.777-7.589\n c-2.697,0.461-5.573,1.347-8.128,0.833c-3.329-0.669-6.516-2-10.028-1.861c-0.612,0.025-1.31-0.437-1.864-0.82\n c-4.076-2.832-8.152-5.663-12.163-8.584c-1.489-1.085-2.782-1.154-4.442-0.322c-1.221,0.612-2.705,0.955-4.08,0.967\n c-6.047,0.062-12.098-0.082-18.148-0.077c-5.173,0.004-10.498,1.815-15.377-1.399c-0.241-0.159-0.588-0.216-0.886-0.221\n c-3.023-0.028-4.488-1.632-5.096-4.524c-0.171-0.82-1.436-1.971-2.236-2c-3.986-0.143-7.984-0.041-11.971,0.139\n c-2.187,0.102-4.619,0.004-6.483,0.922c-3.941,1.942-7.556,4.533-11.355,6.773c-1.505,0.889-3.023,1.085-3.872-0.763\n c0.979-1.261,2.337-2.272,2.627-3.525c0.771-3.37-3.705-7.181-6.969-6.059c-1.498,0.514-3.003,1.208-4.272,2.138\n c-2.464,1.807-4.725,3.896-7.144,5.769c-3.011,2.33-6.055,4.655-10.449,4.737c0.983-3.753-1.718-5.104-4.108-6.597\n c-1.094-0.686-2.293-1.281-3.525-1.652c-3.276-1-6.348-0.763-8.956,1.828c-2.158,2.142-3.488,2.179-6.014,0.367\n c-3.081-2.208-3.986-2.175-7.128,0c-1.122,0.775-2.346,1.832-3.586,1.926c-4.268,0.318-6.646,3.052-8.931,6.132\n c-1.632,2.203-3.244,4.472-5.173,6.405c-4.378,4.39-8.911,8.629-13.48,12.815c-0.608,0.559-1.95,0.873-2.709,0.608\n c-3.378-1.191-5.582-3.823-6.899-7.001c-2.521-6.075-4.957-12.203-7.07-18.429c-0.816-2.399-1.11-5.165-0.865-7.687\n c0.559-5.786,1.771-11.51,2.411-17.291c1.196-10.796,3.583-21.343,7.405-31.445c6.773-17.891,13.934-35.643,21.2-53.342\n c4.619-11.249,7.817-22.852,10.167-34.75c1.644-8.319,2.477-16.63,1.901-25.137c-0.286-4.227,0.232-8.56,0.808-12.787\n c1.669-12.232-2.46-19.547-13.843-24.068c-1.403-0.559-2.766-1.228-4.149-1.844c-2.15,0-4.3,0-6.455,0\n c-2.909,0.91-5.871,1.681-8.715,2.762c-3.827,1.457-7.989,2.484-10.51,6.145c-1.701,2.472-4.088,3.5-6.916,4.06\n c-3.9,0.771-7.797,1.62-11.62,2.705c-3.378,0.959-6.369,2.709-9.135,5.872c6.863,1.652,13.211,3.305,19.617,4.692\n c7.629,1.652,14.558,4.729,20.518,9.763c2.954,2.493,5.667,5.447,6.165,9.425c0.51,4.084,0.608,8.271,0.392,12.383\n c-0.563,10.694-4.137,20.661-7.976,30.515c-2.358,6.059-5.406,11.876-7.36,18.054c-4.321,13.656-8.486,27.348-14.19,40.522\n c-3.309,7.646-6.83,15.251-8.307,23.534c-1.722,9.657-3.264,19.343-4.917,29.013c-0.845,4.958-0.877,10.049-2.864,14.819\n c-0.873,2.093-1.269,4.406-1.693,6.654c-0.975,5.182-1.832,10.379-2.733,15.573c0,7.838,0,15.675,0,23.513\n c0.632,3.905,1.363,7.801,1.877,11.722c1.481,11.232,4.773,21.955,8.825,32.489c0.816,2.121,1.322,4.378,1.783,6.613\n c0.718,3.473,1.069,7.365,4.309,9.303c2.427,1.452,2.982,3.402,3.603,5.671c1.828,6.684,1.318,13.428,0.147,20.086\n c-1.114,6.341-0.845,12.525,0.861,18.65c2.313,8.318,4.72,16.613,7.291,24.859c0.461,1.48,1.71,2.896,2.946,3.916\n c5.3,4.382,10.735,8.605,16.108,12.897c0.355,0.281,0.645,0.656,0.914,1.028c2.652,3.672,6.373,5.879,10.677,6.638\n c8.262,1.457,16.275,4.117,24.664,4.929c1.363,0.131,2.742,0.453,4.035,0.906c2.362,0.828,4.696,1.733,7.038,2.623\n c1.257,0.824,2.391,1.832,3.415,3.064c-0.698,2.239-1.901,4.234-3.199,6.164c-3.529,5.239-8.344,8.948-14.007,11.633\n c-5.818,2.754-11.975,4.442-18.242,5.744c-8.115,1.686-16.259,3.231-24.378,4.88c-6.789,1.379-13.248,3.79-19.633,6.414\n c-8.25,3.39-16.463,6.879-24.77,10.13c-6.447,2.525-13.158,4.149-20.086,4.68c-2.077,0.159-4.178,0.017-6.267,0.065\n c-0.604,0.017-1.326,0.045-1.783,0.367c-3.46,2.437-7.446,3.407-11.481,4.272c-1.607,0.347-3.203,0.742-4.802,1.117\n c-4.423,1.049-7.703,3.672-10.237,7.36c-2.481,3.619-3.827,7.691-4.762,11.914c-1.26,5.708-1.685,11.521-1.921,17.344\n c-0.306,7.405-0.526,14.814-0.828,22.22c-0.082,2.023-0.367,4.035-0.486,6.059c-0.033,0.592,0.012,1.302,0.314,1.779\n c3.525,5.654,7.299,11.126,12.276,15.643c4.251,3.859,8.993,6.769,14.819,7.557c0.171,0.024,0.326,0.175,0.485,0.265\n c1.775,0,3.55,0,5.32,0c1.032-0.253,2.085-0.444,3.097-0.767c2.216-0.702,4.415-1.461,6.663-2.212\n c-0.196-1.881-0.971-3.166-2.317-3.962c-1.236-0.734-2.595-1.301-3.958-1.771c-1.73-0.596-3.55-0.942-5.275-1.554\n c-1.114-0.396-2.208-0.968-3.174-1.648c-1.367-0.968-1.979-2.424-2.052-4.097c0.069-0.102,0.118-0.257,0.212-0.298\n c4.643-1.885,7.16-5.879,9.694-9.837c0.298-0.461,0.294-1.195,0.241-1.787c-0.445-4.696-1.775-9.184-3.354-13.599\n c-1.75-4.884-3.595-9.73-5.333-14.614c-0.551-1.547-0.836-3.183-1.326-4.749c-0.318-1.017,0.11-1.543,0.938-1.971\n c1.64-0.841,3.423-0.832,5.189-0.886c2.464-0.073,4.945,0.041,7.393-0.188c1.408-0.131,2.925-0.515,4.121-1.236\n c13.692-8.303,28.474-14.003,43.791-18.413c13.876-3.998,27.997-6.915,42.244-9.229c6.247-1.012,12.501-1.967,18.76-2.897\n c0.918-0.134,1.665-0.428,2.371-1.027c4.227-3.595,9.217-5.586,14.635-6.259c5.773-0.715,11.608-0.951,17.393-1.563\n c3.578-0.379,7.161-0.905,10.678-1.656c4.308-0.918,8.045-3.129,11.146-6.205c2.688-2.669,5.132-5.59,7.593-8.482\n c3.28-3.855,6.414-7.834,9.727-11.661c1.02-1.179,2.432-2.012,3.631-3.039c0.792-0.674,1.501-0.653,2.391-0.11\n c4.125,2.529,8.576,4.32,13.199,5.712c5.716,1.722,11.566,2.75,17.495,3.374c10.983,1.159,22,1.204,33.023,0.906\n c3.166-0.086,6.333-0.09,9.503-0.184c0.93-0.029,1.718,0.171,2.473,0.729c3.309,2.444,6.646,4.852,9.963,7.291\n c3.117,2.293,6.345,4.402,9.927,5.92c0.641,0.273,1.277,0.612,1.95,0.735c2.758,0.497,4.741,2.235,6.744,4.002\n c5.908,5.214,11.343,10.894,16.161,17.111c6.324,8.156,12.468,16.455,18.617,24.745c6.152,8.295,12.342,16.557,19.396,24.125\n c6.863,7.36,14.423,13.868,23.122,18.984c0.775,0.457,1.432,0.955,1.844,1.815c3.187,6.655,8.475,11.09,15.076,14.093\n c6.81,3.097,14.006,4.256,21.444,4.142c10.33-0.159,20.062-2.53,28.906-8.014c5.264-3.264,9.572-7.471,12.347-13.097\n c1.15-2.338,2.109-4.737,2.269-7.385c0.016-0.29,0.212-0.571,0.326-0.853c0-0.633,0-1.27,0-1.901\n c-3.488-0.6-6.802,0.208-10.045,1.362c-3.101,1.102-6.124,2.416-9.25,3.443c-2.692,0.886-5.442,1.673-8.225,2.195\n c-4.554,0.853-8.042-1.113-10.037-5.41c0.804-1.049,1.995-1.195,3.194-1.253c2.338-0.113,4.685-0.143,7.022-0.302\n c0.799-0.053,1.664-0.249,2.338-0.648c0.6-0.359,1.121-1.024,1.411-1.673c0.498-1.126,0.311-1.44-0.869-2.085\n c-3.402-1.856-6.993-3.264-10.714-4.324c-8.421-2.399-17.055-3.028-25.757-3.061c-1.836-0.008-3.677-0.004-5.513,0.082\n c-0.963,0.045-1.66-0.249-2.366-0.906c-4.843-4.5-9.094-9.53-13.166-14.721c-6.613-8.429-12.48-17.389-18.47-26.259\n c-2.836-4.198-5.786-8.319-8.769-12.411c-0.999-1.375-2.244-2.574-3.419-3.811c-0.384-0.404-0.885-0.727-1.383-0.991\n c-1.358-0.727-2.269-0.408-2.905,1.003c-0.229,0.511-0.379,1.062-0.648,1.828c-0.633-0.465-1.179-0.841-1.697-1.253\n c-5.03-4.019-8.866-9.058-11.905-14.655c-2.954-5.446-5.627-11.048-8.344-16.626c-2.607-5.353-5.092-10.767-8.438-15.712\n c-1.521-2.248-3.317-4.312-4.9-6.523c-0.783-1.094-1.709-1.229-2.949-1.094c-5.324,0.579-10.625,0.494-15.843-0.894\n c-2.591-0.689-5.035-1.718-7.1-3.488c-1.473-1.269-2.562-2.746-3.211-4.513c1.95-0.433,3.893-0.897,5.818-1.424\n c6.459-1.767,12.926-2.469,19.552-2.081c7.964,0.466,15.92,1.159,23.892,1.437c2.853,0.098,5.966-0.172,8.557-1.244\n c3.859-1.596,7.544-3.799,10.971-6.206c5.075-3.566,9.702-7.78,14.847-11.232c2.379-1.595,3.203-3.292,3.306-5.92\n c0.134-3.509,1.9-4.781,5.3-4.149c0.6,0.114,1.203,0.253,1.787,0.44c3.852,1.229,7.633,1.028,11.489-0.163\n c2.962-0.914,6.066-1.354,9.053-2.195c0.547-0.154,1.024-1.199,1.163-1.909c0.094-0.481-0.616-1.068-0.693-1.648\n c-0.127-0.922-0.384-2.402,0.057-2.705c0.854-0.575,2.154-0.656,3.265-0.636c0.881,0.016,1.733,0.62,2.627,0.729\n c2.064,0.258,3.995,0.021,5.247-1.986c1.232-1.971,1.277-3.864-0.163-5.757c-0.465-0.608-1.069-1.249-1.191-1.946\n c-0.163-0.938-0.273-2.199,0.212-2.881c1.779-2.488,3.771-4.83,5.77-7.152c1.828-2.121,4.251-3.354,6.997-3.541\n c0.967-0.065,2.158,0.742,2.966,1.465c0.633,0.562,0.686,1.729,1.261,2.407c0.674,0.795,1.628,1.347,2.465,2.007\n c0.571-0.877,1.358-1.688,1.656-2.651c0.311-0.992-0.028-2.175,0.236-3.187c0.213-0.812,0.743-1.738,1.416-2.195\n c3.591-2.439,7.442-4.524,10.861-7.177c2.574-1.991,4.508-4.786,6.944-6.98c4.182-3.771,9.526-5.097,14.789-6.472\n c3.452-0.901,4.194-1.921,3.134-5.365c-0.514-1.673-1.228-3.309-2.052-4.854c-1.062-1.987-0.531-3.362,1.297-4.402\n c0.727-0.412,1.498-0.751,2.252-1.114c2.387-1.139,4.08-2.701,4.688-5.521c0.612-2.827,1.75-5.549,2.741-8.286\n c1.339-3.692,2.432-7.65,7.34-8.144c0.147-0.017,0.294-0.061,0.441-0.094c0-1.077,0-2.15,0-3.228\n c-1.135-1.775-2.15-3.639-3.432-5.3C536.084,271.981,534.492,270.614,533.187,269.019z" class="svelte-f7jodf"></path></g></g></svg>',S(o,"href","#"),S(o,"class","text-white bg-purple-900 hover:bg-purple-700 w-full p-5 rounded-full flex-shrink-1 text-center font-semibold flex flex-row items-center gap-4 svelte-f7jodf"),S(r,"class","self-end svelte-f7jodf"),S(t,"class","fixed bottom-5 right-5 mb-5 flex flex-col item-end font-sans svelte-f7jodf")},m(u,l){g(u,t,l),c&&c.m(t,null),y(t,n),y(t,r),y(r,o),i=!0,s||(a=E(o,"click",k(e[8])),s=!0)},p(e,[r]){e[6]?c?(c.p(e,r),64&r&&Z(c,1)):(c=pw(e),c.c(),Z(c,1),c.m(t,n)):c&&(K(),V(c,1,1,(()=>{c=null})),G())},i(e){i||(Z(c),i=!0)},o(e){V(c),i=!1},d(e){e&&b(t),c&&c.d(),s=!1,a()}}}function gw(e,t,n){let{websiteOwnerPubkey:r}=t,{chatType:o}=t,{chatTags:i}=t,{chatReferenceTags:s}=t,{relays:a}=t,{chatId:c}=t,u=!1,l=!1;return e.$$set=e=>{"websiteOwnerPubkey"in e&&n(0,r=e.websiteOwnerPubkey),"chatType"in e&&n(1,o=e.chatType),"chatTags"in e&&n(2,i=e.chatTags),"chatReferenceTags"in e&&n(3,s=e.chatReferenceTags),"relays"in e&&n(4,a=e.relays),"chatId"in e&&n(5,c=e.chatId)},[r,o,i,s,a,c,u,l,function(){u?n(7,l=!l):n(6,u=!u)}]}var bw=document.createElement("DIV"),mw=document.currentScript;const ww=mw.getAttribute("data-website-owner-pubkey"),vw=mw.getAttribute("data-chat-type");let _w=mw.getAttribute("data-chat-tags");mw.getAttribute("data-chat-id");let xw=mw.getAttribute("data-chat-reference-tags"),Ew=mw.getAttribute("data-relays");mw.parentNode.insertBefore(bw,mw),Ew||(Ew="wss://relay.f7z.io,wss://nos.lol,wss://relay.nostr.info,wss://nostr-pub.wellorder.net,wss://relay.current.fyi,wss://relay.nostr.band"),Ew=Ew.split(","),_w=_w?_w.split(","):[],xw=xw?xw.split(","):[],new class extends ne{constructor(e){super(),te(this,e,gw,yw,i,{websiteOwnerPubkey:0,chatType:1,chatTags:2,chatReferenceTags:3,relays:4,chatId:5})}}({target:bw,props:{websiteOwnerPubkey:ww,chatType:vw,chatTags:_w,chatReferenceTags:xw,relays:Ew}})}();
//# sourceMappingURL=bundle.js.map