Skip to content

Instantly share code, notes, and snippets.

@shipunyc
Created November 22, 2022 17:12
Show Gist options
  • Select an option

  • Save shipunyc/f0127e82a316073de48342983cd24b11 to your computer and use it in GitHub Desktop.

Select an option

Save shipunyc/f0127e82a316073de48342983cd24b11 to your computer and use it in GitHub Desktop.
hosted xmtp.min.js
/*! For license information please see index.js.LICENSE.txt */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.xmtp=t():e.xmtp=t()}(this,(function(){return(()=>{var __webpack_modules__={9656:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.utils=t.schnorr=t.verify=t.signSync=t.sign=t.getSharedSecret=t.recoverPublicKey=t.getPublicKey=t.Signature=t.Point=t.CURVE=void 0;const i=n(r(9159)),o=BigInt(0),s=BigInt(1),a=BigInt(2),l=BigInt(3),u=BigInt(8),c=a**BigInt(256),h={a:o,b:BigInt(7),P:c-a**BigInt(32)-BigInt(977),n:c-BigInt("432420386565659656852420866394968145599"),h:s,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")};function d(e){const{a:t,b:r}=h,n=B(e*e),i=B(n*e);return B(i+t*e+r)}t.CURVE=h;const f=h.a===o;class p{constructor(e,t,r){this.x=e,this.y=t,this.z=r}static fromAffine(e){if(!(e instanceof y))throw new TypeError("JacobianPoint#fromAffine: expected Point");return new p(e.x,e.y,s)}static toAffineBatch(e){const t=function(e,t=h.P){const r=e.length,n=new Array(r);let i=s;for(let s=0;s<r;s++)e[s]!==o&&(n[s]=i,i=B(i*e[s],t));i=I(i,t);for(let s=r-1;s>=0;s--){if(e[s]===o)continue;const r=B(i*e[s],t);e[s]=B(i*n[s],t),i=r}return e}(e.map((e=>e.z)));return e.map(((e,r)=>e.toAffine(t[r])))}static normalizeZ(e){return p.toAffineBatch(e).map(p.fromAffine)}equals(e){const t=this,r=e,n=B(t.z*t.z),i=B(t.z*n),o=B(r.z*r.z),s=B(r.z*o);return B(t.x*o)===B(n*r.x)&&B(t.y*s)===B(i*r.y)}negate(){return new p(this.x,B(-this.y),this.z)}double(){const e=this.x,t=this.y,r=this.z,n=B(e**a),i=B(t**a),o=B(i**a),s=B(a*(B(B((e+i)**a))-n-o)),c=B(l*n),h=B(c**a),d=B(h-a*s),f=B(c*(s-d)-u*o),m=B(a*t*r);return new p(d,f,m)}add(e){if(!(e instanceof p))throw new TypeError("JacobianPoint#add: expected JacobianPoint");const t=this.x,r=this.y,n=this.z,i=e.x,s=e.y,l=e.z;if(i===o||s===o)return this;if(t===o||r===o)return e;const u=B(n**a),c=B(l**a),h=B(t*c),d=B(i*u),f=B(r*l*c),m=B(B(s*n)*u),y=B(d-h),g=B(m-f);if(y===o)return g===o?this.double():p.ZERO;const v=B(y**a),b=B(y*v),w=B(h*v),_=B(g**a-b-a*w),S=B(g*(w-_)-f*b),E=B(n*l*y);return new p(_,S,E)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){let t=R(e);if(!f){let e=p.ZERO,r=this;for(;t>o;)t&s&&(e=e.add(r)),r=r.double(),t>>=s;return e}let{k1neg:r,k1:n,k2neg:i,k2:a}=K(t),l=p.ZERO,u=p.ZERO,c=this;for(;n>o||a>o;)n&s&&(l=l.add(c)),a&s&&(u=u.add(c)),c=c.double(),n>>=s,a>>=s;return r&&(l=l.negate()),i&&(u=u.negate()),u=new p(B(u.x*h.beta),u.y,u.z),l.add(u)}precomputeWindow(e){const t=f?128/e+1:256/e+1,r=[];let n=this,i=n;for(let o=0;o<t;o++){i=n,r.push(i);for(let t=1;t<2**(e-1);t++)i=i.add(n),r.push(i);n=i.double()}return r}wNAF(e,t){!t&&this.equals(p.BASE)&&(t=y.BASE);const r=t&&t._WINDOW_SIZE||1;if(256%r)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let n=t&&m.get(t);n||(n=this.precomputeWindow(r),t&&1!==r&&(n=p.normalizeZ(n),m.set(t,n)));let i=p.ZERO,o=p.ZERO;const a=f?128/r+1:256/r+1,l=2**(r-1),u=BigInt(2**r-1),c=2**r,h=BigInt(r);for(let t=0;t<a;t++){const r=t*l;let a=Number(e&u);if(e>>=h,a>l&&(a-=c,e+=s),0===a){let e=n[r];t%2&&(e=e.negate()),o=o.add(e)}else{let e=n[r+Math.abs(a)-1];a<0&&(e=e.negate()),i=i.add(e)}}return{p:i,f:o}}multiply(e,t){let r,n,i=R(e);if(f){let{k1neg:e,k1:o,k2neg:s,k2:a}=K(i),{p:l,f:u}=this.wNAF(o,t),{p:c,f:d}=this.wNAF(a,t);e&&(l=l.negate()),s&&(c=c.negate()),c=new p(B(c.x*h.beta),c.y,c.z),r=l.add(c),n=u.add(d)}else{let{p:e,f:o}=this.wNAF(i,t);r=e,n=o}return p.normalizeZ([r,n])[0]}toAffine(e=I(this.z)){const t=e**a,r=B(this.x*t),n=B(this.y*t*e);return new y(r,n)}}p.BASE=new p(h.Gx,h.Gy,s),p.ZERO=new p(o,s,o);const m=new WeakMap;class y{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,m.delete(this)}static fromCompressedHex(e){const t=32===e.length,r=T(t?e:e.slice(1));if(!L(r))throw new Error("Point is not on curve");let n=function(e){const{P:t}=h,r=BigInt(6),n=BigInt(11),i=BigInt(22),o=BigInt(23),s=BigInt(44),u=BigInt(88),c=e*e*e%t,d=c*c*e%t,f=M(d,l)*d%t,p=M(f,l)*d%t,m=M(p,a)*c%t,y=M(m,n)*m%t,g=M(y,i)*y%t,v=M(g,s)*g%t,b=M(v,u)*v%t,w=M(b,s)*g%t,_=M(w,l)*d%t,S=M(_,o)*y%t,E=M(S,r)*c%t;return M(E,a)}(d(r));const i=(n&s)===s;t?i&&(n=B(-n)):1==(1&e[0])!==i&&(n=B(-n));const o=new y(r,n);return o.assertValidity(),o}static fromUncompressedHex(e){const t=T(e.slice(1,33)),r=T(e.slice(33)),n=new y(t,r);return n.assertValidity(),n}static fromHex(e){const t=N(e),r=t[0];if(32===t.length||33===t.length&&(2===r||3===r))return this.fromCompressedHex(t);if(65===t.length&&4===r)return this.fromUncompressedHex(t);throw new Error(`Point.fromHex: received invalid point. Expected 32-33 compressed bytes or 65 uncompressed bytes, not ${t.length}`)}static fromPrivateKey(e){return y.BASE.multiply(z(e))}static fromSignature(e,t,r){const n=U(e=N(e)),{r:i,s}=G(t);if(0!==r&&1!==r)throw new Error("Cannot recover signature: invalid recovery bit");if(n===o)throw new Error("Cannot recover signature: msgHash cannot be 0");const a=2+(1&r),l=y.fromHex(`0${a}${k(i)}`),u=p.fromAffine(l).multiplyUnsafe(s),c=p.BASE.multiply(n),d=I(i,h.n),f=u.subtract(c).multiplyUnsafe(d).toAffine();return f.assertValidity(),f}toRawBytes(e=!1){return C(this.toHex(e))}toHex(e=!1){const t=k(this.x);return e?`${this.y&s?"03":"02"}${t}`:`04${t}${k(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const e="Point is not on elliptic curve",{x:t,y:r}=this;if(!L(t)||!L(r))throw new Error(e);const n=B(r*r);if(B(n-d(t))!==o)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new y(this.x,B(-this.y))}double(){return p.fromAffine(this).double().toAffine()}add(e){return p.fromAffine(this).add(p.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return p.fromAffine(this).multiply(e,this).toAffine()}}function g(e){return Number.parseInt(e[0],16)>=8?"00"+e:e}function v(e){if(e.length<2||2!==e[0])throw new Error(`Invalid signature integer tag: ${E(e)}`);const t=e[1],r=e.subarray(2,t+2);if(!t||r.length!==t)throw new Error("Invalid signature integer: wrong length");if(0===r[0]&&r[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:T(r),left:e.subarray(t+2)}}t.Point=y,y.BASE=new y(h.Gx,h.Gy),y.ZERO=new y(o,o);class b{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromCompact(e){const t=_(e),r="Signature.fromCompact";if("string"!=typeof e&&!t)throw new TypeError(`${r}: Expected string or Uint8Array`);const n=t?E(e):e;if(128!==n.length)throw new Error(`${r}: Expected 64-byte hex`);return new b(x(n.slice(0,64)),x(n.slice(64,128)))}static fromDER(e){const t=_(e);if("string"!=typeof e&&!t)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r,s:n}=function(e){if(e.length<2||48!=e[0])throw new Error(`Invalid signature tag: ${E(e)}`);if(e[1]!==e.length-2)throw new Error("Invalid signature: incorrect length");const{data:t,left:r}=v(e.subarray(2)),{data:n,left:i}=v(r);if(i.length)throw new Error(`Invalid signature: left bytes after parsing: ${E(i)}`);return{r:t,s:n}}(t?e:C(e));return new b(r,n)}static fromHex(e){return this.fromDER(e)}assertValidity(){const{r:e,s:t}=this;if(!j(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!j(t))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const e=h.n>>s;return this.s>e}normalizeS(){return this.hasHighS()?new b(this.r,h.n-this.s):this}toDERRawBytes(e=!1){return C(this.toDERHex(e))}toDERHex(e=!1){const t=g(P(this.s));if(e)return t;const r=g(P(this.r)),n=P(r.length/2),i=P(t.length/2);return`30${P(r.length/2+t.length/2+4)}02${n}${r}02${i}${t}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return C(this.toCompactHex())}toCompactHex(){return k(this.r)+k(this.s)}}function w(...e){if(!e.every(_))throw new Error("Uint8Array list expected");if(1===e.length)return e[0];const t=e.reduce(((e,t)=>e+t.length),0),r=new Uint8Array(t);for(let t=0,n=0;t<e.length;t++){const i=e[t];r.set(i,n),n+=i.length}return r}function _(e){return e instanceof Uint8Array}t.Signature=b;const S=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function E(e){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");let t="";for(let r=0;r<e.length;r++)t+=S[e[r]];return t}function k(e){if(e>c)throw new Error("Expected number < 2^256");return e.toString(16).padStart(64,"0")}function A(e){return C(k(e))}function P(e){const t=e.toString(16);return 1&t.length?`0${t}`:t}function x(e){if("string"!=typeof e)throw new TypeError("hexToNumber: expected string, got "+typeof e);return BigInt(`0x${e}`)}function C(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"+e.length);const t=new Uint8Array(e.length/2);for(let r=0;r<t.length;r++){const n=2*r,i=e.slice(n,n+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");t[r]=o}return t}function T(e){return x(E(e))}function N(e){return e instanceof Uint8Array?Uint8Array.from(e):C(e)}function R(e){if("number"==typeof e&&Number.isSafeInteger(e)&&e>0)return BigInt(e);if("bigint"==typeof e&&j(e))return e;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function B(e,t=h.P){const r=e%t;return r>=0?r:t+r}function M(e,t){const{P:r}=h;let n=e;for(;t-- >o;)n*=n,n%=r;return n}function I(e,t=h.P){if(e===o||t<=o)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let r=B(e,t),n=t,i=o,a=s,l=s,u=o;for(;r!==o;){const e=n/r,t=n%r,o=i-l*e,s=a-u*e;n=r,r=t,i=l,a=u,l=o,u=s}if(n!==s)throw new Error("invert: does not exist");return B(i,t)}const O=(e,t)=>(e+t/a)/t,D=a**BigInt(128);function K(e){const{n:t}=h,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-s*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,a=O(o*e,t),l=O(-n*e,t);let u=B(e-a*r-l*i,t),c=B(-a*n-l*o,t);const d=u>D,f=c>D;if(d&&(u=t-u),f&&(c=t-c),u>D||c>D)throw new Error("splitScalarEndo: Endomorphism failed");return{k1neg:d,k1:u,k2neg:f,k2:c}}function U(e){const{n:t}=h,r=8*e.length-256;let n=T(e);return r>0&&(n>>=BigInt(r)),n>=t&&(n-=t),n}class F{constructor(){this.v=new Uint8Array(32).fill(1),this.k=new Uint8Array(32).fill(0),this.counter=0}hmac(...e){return t.utils.hmacSha256(this.k,...e)}hmacSync(...e){if("function"!=typeof t.utils.hmacSha256Sync)throw new Error("utils.hmacSha256Sync is undefined, you need to set it");const r=t.utils.hmacSha256Sync(this.k,...e);if(r instanceof Promise)throw new Error("To use sync sign(), ensure utils.hmacSha256 is sync");return r}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}async reseed(e=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),e),this.v=await this.hmac(this.v),0!==e.length&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),e),this.v=await this.hmac(this.v))}reseedSync(e=new Uint8Array){this.k=this.hmacSync(this.v,Uint8Array.from([0]),e),this.v=this.hmacSync(this.v),0!==e.length&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),e),this.v=this.hmacSync(this.v))}async generate(){return this.incr(),this.v=await this.hmac(this.v),this.v}generateSync(){return this.incr(),this.v=this.hmacSync(this.v),this.v}}function j(e){return o<e&&e<h.n}function L(e){return o<e&&e<h.P}function q(e,t,r){const n=T(e);if(!j(n))return;const{n:i}=h,a=y.BASE.multiply(n),l=B(a.x,i);if(l===o)return;const u=B(I(n,i)*B(t+r*l,i),i);if(u===o)return;const c=new b(l,u);return{sig:c,recovery:(a.x===c.r?0:2)|Number(a.y&s)}}function z(e){let t;if("bigint"==typeof e)t=e;else if("number"==typeof e&&Number.isSafeInteger(e)&&e>0)t=BigInt(e);else if("string"==typeof e){if(64!==e.length)throw new Error("Expected 32 bytes of private key");t=x(e)}else{if(!_(e))throw new TypeError("Expected valid private key");if(32!==e.length)throw new Error("Expected 32 bytes of private key");t=T(e)}if(!j(t))throw new Error("Expected private key: 0 < key < n");return t}function W(e){return e instanceof y?(e.assertValidity(),e):y.fromHex(e)}function G(e){if(e instanceof b)return e.assertValidity(),e;try{return b.fromDER(e)}catch(t){return b.fromCompact(e)}}function V(e){const t=_(e),r="string"==typeof e,n=(t||r)&&e.length;return t?33===n||65===n:r?66===n||130===n:e instanceof y}function H(e){return T(e.length>32?e.slice(0,32):e)}function J(e){const t=H(e),r=B(t,h.n);return $(r<o?t:r)}function $(e){if("bigint"!=typeof e)throw new Error("Expected bigint");return C(k(e))}function Z(e,r,n){if(null==e)throw new Error(`sign: expected valid message hash, not "${e}"`);const i=N(e),o=z(r),s=[$(o),J(i)];if(null!=n){!0===n&&(n=t.utils.randomBytes(32));const e=N(n);if(32!==e.length)throw new Error("sign: Expected 32 bytes of extra data");s.push(e)}return{seed:w(...s),m:H(i),d:o}}function X(e,t){let{sig:r,recovery:n}=e;const{canonical:i,der:o,recovered:s}=Object.assign({canonical:!0,der:!0},t);i&&r.hasHighS()&&(r=r.normalizeS(),n^=1);const a=o?r.toDERRawBytes():r.toCompactRawBytes();return s?[a,n]:a}t.getPublicKey=function(e,t=!1){return y.fromPrivateKey(e).toRawBytes(t)},t.recoverPublicKey=function(e,t,r){return y.fromSignature(e,t,r).toRawBytes()},t.getSharedSecret=function(e,t,r=!1){if(V(e))throw new TypeError("getSharedSecret: first arg must be private key");if(!V(t))throw new TypeError("getSharedSecret: second arg must be public key");const n=W(t);return n.assertValidity(),n.multiply(z(e)).toRawBytes(r)},t.sign=async function(e,t,r={}){const{seed:n,m:i,d:o}=Z(e,t,r.extraEntropy);let s;const a=new F;for(await a.reseed(n);!(s=q(await a.generate(),i,o));)await a.reseed();return X(s,r)},t.signSync=function(e,t,r={}){const{seed:n,m:i,d:o}=Z(e,t,r.extraEntropy);let s;const a=new F;for(a.reseedSync(n);!(s=q(a.generateSync(),i,o));)a.reseedSync();return X(s,r)};const Q={strict:!0};async function Y(e,...r){const n=new Uint8Array(e.split("").map((e=>e.charCodeAt(0)))),i=await t.utils.sha256(n);return T(await t.utils.sha256(w(i,i,...r)))}async function ee(e,t,r){const n=A(e);return B(await Y("BIP0340/challenge",n,t.toRawX(),r),h.n)}function te(e){return B(e.y,a)===o}t.verify=function(e,t,r,n=Q){let i;try{i=G(e),t=N(t)}catch(e){return!1}const{r:s,s:a}=i;if(n.strict&&i.hasHighS())return!1;const l=U(t);if(l===o)return!1;let u;try{u=p.fromAffine(W(r))}catch(e){return!1}const{n:c}=h,d=I(a,c),f=B(l*d,c),m=B(s*d,c),y=p.BASE.multiply(f),g=u.multiplyUnsafe(m);return B(y.add(g).toAffine().x,c)===s};class re{constructor(e,t){if(this.r=e,this.s=t,!L(e)||!j(t))throw new Error("Invalid signature")}static fromHex(e){const t=N(e);if(64!==t.length)throw new TypeError(`SchnorrSignature.fromHex: expected 64 bytes, not ${t.length}`);const r=T(t.slice(0,32)),n=T(t.slice(32,64));return new re(r,n)}toHex(){return k(this.r)+k(this.s)}toRawBytes(){return C(this.toHex())}}async function ne(e,t,r){const n=e instanceof re?e:re.fromHex(e),i=N(t),o=W(r),s=await ee(n.r,o,i),a=y.fromPrivateKey(n.s),l=o.multiply(s),u=a.subtract(l);return!(u.equals(y.BASE)||!te(u)||u.x!==n.r)}t.schnorr={Signature:re,getPublicKey:function(e){return y.fromPrivateKey(e).toRawX()},sign:async function(e,r,n=t.utils.randomBytes()){if(null==e)throw new TypeError(`sign: Expected valid message, not "${e}"`);const{n:i}=h,s=N(e),a=z(r),l=N(n);if(32!==l.length)throw new TypeError("sign: Expected 32 bytes of aux randomness");const u=y.fromPrivateKey(a),c=te(u)?a:i-a,d=c^await Y("BIP0340/aux",l),f=B(await Y("BIP0340/nonce",A(d),u.toRawX(),s),i);if(f===o)throw new Error("sign: Creation of signature failed. k is zero");const p=y.fromPrivateKey(f),m=te(p)?f:i-f,g=await ee(p.x,u,s),v=new re(p.x,B(m+g*c,i));if(!await ne(v.toRawBytes(),s,u.toRawX()))throw new Error("sign: Invalid signature produced");return v.toRawBytes()},verify:ne},y.BASE._setWindowSize(8);const ie={node:i.default,web:"object"==typeof self&&"crypto"in self?self.crypto:void 0};t.utils={isValidPrivateKey(e){try{return z(e),!0}catch(e){return!1}},randomBytes:(e=32)=>{if(ie.web)return ie.web.getRandomValues(new Uint8Array(e));if(ie.node){const{randomBytes:t}=ie.node;return Uint8Array.from(t(e))}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>{let e=8;for(;e--;){const e=t.utils.randomBytes(32),r=T(e);if(j(r)&&r!==s)return e}throw new Error("Valid private key was not found in 8 iterations. PRNG is broken")},bytesToHex:E,mod:B,sha256:async e=>{if(ie.web){const t=await ie.web.subtle.digest("SHA-256",e.buffer);return new Uint8Array(t)}if(ie.node){const{createHash:t}=ie.node;return Uint8Array.from(t("sha256").update(e).digest())}throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(e,...t)=>{if(ie.web){const r=await ie.web.subtle.importKey("raw",e,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),n=w(...t),i=await ie.web.subtle.sign("HMAC",r,n);return new Uint8Array(i)}if(ie.node){const{createHmac:r}=ie.node,n=r("sha256",e);return t.forEach((e=>n.update(e))),Uint8Array.from(n.digest())}throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,precompute(e=8,t=y.BASE){const r=t===y.BASE?t:new y(t.x,t.y);return r._setWindowSize(e),r.multiply(l),r}}},4537:e=>{"use strict";e.exports=function(e,t){for(var r=new Array(arguments.length-1),n=0,i=2,o=!0;i<arguments.length;)r[n++]=arguments[i++];return new Promise((function(i,s){r[n]=function(e){if(o)if(o=!1,e)s(e);else{for(var t=new Array(arguments.length-1),r=0;r<t.length;)t[r++]=arguments[r];i.apply(null,t)}};try{e.apply(t||null,r)}catch(e){o&&(o=!1,s(e))}}))}},7419:(e,t)=>{"use strict";var r=t;r.length=function(e){var t=e.length;if(!t)return 0;for(var r=0;--t%4>1&&"="===e.charAt(t);)++r;return Math.ceil(3*e.length)/4-r};for(var n=new Array(64),i=new Array(123),o=0;o<64;)i[n[o]=o<26?o+65:o<52?o+71:o<62?o-4:o-59|43]=o++;r.encode=function(e,t,r){for(var i,o=null,s=[],a=0,l=0;t<r;){var u=e[t++];switch(l){case 0:s[a++]=n[u>>2],i=(3&u)<<4,l=1;break;case 1:s[a++]=n[i|u>>4],i=(15&u)<<2,l=2;break;case 2:s[a++]=n[i|u>>6],s[a++]=n[63&u],l=0}a>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,s)),a=0)}return l&&(s[a++]=n[i],s[a++]=61,1===l&&(s[a++]=61)),o?(a&&o.push(String.fromCharCode.apply(String,s.slice(0,a))),o.join("")):String.fromCharCode.apply(String,s.slice(0,a))};var s="invalid encoding";r.decode=function(e,t,r){for(var n,o=r,a=0,l=0;l<e.length;){var u=e.charCodeAt(l++);if(61===u&&a>1)break;if(void 0===(u=i[u]))throw Error(s);switch(a){case 0:n=u,a=1;break;case 1:t[r++]=n<<2|(48&u)>>4,n=u,a=2;break;case 2:t[r++]=(15&n)<<4|(60&u)>>2,n=u,a=3;break;case 3:t[r++]=(3&n)<<6|u,a=0}}if(1===a)throw Error(s);return r-o},r.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}},9211:e=>{"use strict";function t(){this._listeners={}}e.exports=t,t.prototype.on=function(e,t,r){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:t,ctx:r||this}),this},t.prototype.off=function(e,t){if(void 0===e)this._listeners={};else if(void 0===t)this._listeners[e]=[];else for(var r=this._listeners[e],n=0;n<r.length;)r[n].fn===t?r.splice(n,1):++n;return this},t.prototype.emit=function(e){var t=this._listeners[e];if(t){for(var r=[],n=1;n<arguments.length;)r.push(arguments[n++]);for(n=0;n<t.length;)t[n].fn.apply(t[n++].ctx,r)}return this}},945:e=>{"use strict";function t(e){return"undefined"!=typeof Float32Array?function(){var t=new Float32Array([-0]),r=new Uint8Array(t.buffer),n=128===r[3];function i(e,n,i){t[0]=e,n[i]=r[0],n[i+1]=r[1],n[i+2]=r[2],n[i+3]=r[3]}function o(e,n,i){t[0]=e,n[i]=r[3],n[i+1]=r[2],n[i+2]=r[1],n[i+3]=r[0]}function s(e,n){return r[0]=e[n],r[1]=e[n+1],r[2]=e[n+2],r[3]=e[n+3],t[0]}function a(e,n){return r[3]=e[n],r[2]=e[n+1],r[1]=e[n+2],r[0]=e[n+3],t[0]}e.writeFloatLE=n?i:o,e.writeFloatBE=n?o:i,e.readFloatLE=n?s:a,e.readFloatBE=n?a:s}():function(){function t(e,t,r,n){var i=t<0?1:0;if(i&&(t=-t),0===t)e(1/t>0?0:2147483648,r,n);else if(isNaN(t))e(2143289344,r,n);else if(t>34028234663852886e22)e((i<<31|2139095040)>>>0,r,n);else if(t<11754943508222875e-54)e((i<<31|Math.round(t/1401298464324817e-60))>>>0,r,n);else{var o=Math.floor(Math.log(t)/Math.LN2);e((i<<31|o+127<<23|8388607&Math.round(t*Math.pow(2,-o)*8388608))>>>0,r,n)}}function s(e,t,r){var n=e(t,r),i=2*(n>>31)+1,o=n>>>23&255,s=8388607&n;return 255===o?s?NaN:i*(1/0):0===o?1401298464324817e-60*i*s:i*Math.pow(2,o-150)*(s+8388608)}e.writeFloatLE=t.bind(null,r),e.writeFloatBE=t.bind(null,n),e.readFloatLE=s.bind(null,i),e.readFloatBE=s.bind(null,o)}(),"undefined"!=typeof Float64Array?function(){var t=new Float64Array([-0]),r=new Uint8Array(t.buffer),n=128===r[7];function i(e,n,i){t[0]=e,n[i]=r[0],n[i+1]=r[1],n[i+2]=r[2],n[i+3]=r[3],n[i+4]=r[4],n[i+5]=r[5],n[i+6]=r[6],n[i+7]=r[7]}function o(e,n,i){t[0]=e,n[i]=r[7],n[i+1]=r[6],n[i+2]=r[5],n[i+3]=r[4],n[i+4]=r[3],n[i+5]=r[2],n[i+6]=r[1],n[i+7]=r[0]}function s(e,n){return r[0]=e[n],r[1]=e[n+1],r[2]=e[n+2],r[3]=e[n+3],r[4]=e[n+4],r[5]=e[n+5],r[6]=e[n+6],r[7]=e[n+7],t[0]}function a(e,n){return r[7]=e[n],r[6]=e[n+1],r[5]=e[n+2],r[4]=e[n+3],r[3]=e[n+4],r[2]=e[n+5],r[1]=e[n+6],r[0]=e[n+7],t[0]}e.writeDoubleLE=n?i:o,e.writeDoubleBE=n?o:i,e.readDoubleLE=n?s:a,e.readDoubleBE=n?a:s}():function(){function t(e,t,r,n,i,o){var s=n<0?1:0;if(s&&(n=-n),0===n)e(0,i,o+t),e(1/n>0?0:2147483648,i,o+r);else if(isNaN(n))e(0,i,o+t),e(2146959360,i,o+r);else if(n>17976931348623157e292)e(0,i,o+t),e((s<<31|2146435072)>>>0,i,o+r);else{var a;if(n<22250738585072014e-324)e((a=n/5e-324)>>>0,i,o+t),e((s<<31|a/4294967296)>>>0,i,o+r);else{var l=Math.floor(Math.log(n)/Math.LN2);1024===l&&(l=1023),e(4503599627370496*(a=n*Math.pow(2,-l))>>>0,i,o+t),e((s<<31|l+1023<<20|1048576*a&1048575)>>>0,i,o+r)}}}function s(e,t,r,n,i){var o=e(n,i+t),s=e(n,i+r),a=2*(s>>31)+1,l=s>>>20&2047,u=4294967296*(1048575&s)+o;return 2047===l?u?NaN:a*(1/0):0===l?5e-324*a*u:a*Math.pow(2,l-1075)*(u+4503599627370496)}e.writeDoubleLE=t.bind(null,r,0,4),e.writeDoubleBE=t.bind(null,n,4,0),e.readDoubleLE=s.bind(null,i,0,4),e.readDoubleBE=s.bind(null,o,4,0)}(),e}function r(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function n(e,t,r){t[r]=e>>>24,t[r+1]=e>>>16&255,t[r+2]=e>>>8&255,t[r+3]=255&e}function i(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function o(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}e.exports=t(t)},7199:module=>{"use strict";function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(e){}return null}module.exports=inquire},6662:e=>{"use strict";e.exports=function(e,t,r){var n=r||8192,i=n>>>1,o=null,s=n;return function(r){if(r<1||r>i)return e(r);s+r>n&&(o=e(n),s=0);var a=t.call(o,s,s+=r);return 7&s&&(s=1+(7|s)),a}}},4997:(e,t)=>{"use strict";var r=t;r.length=function(e){for(var t=0,r=0,n=0;n<e.length;++n)(r=e.charCodeAt(n))<128?t+=1:r<2048?t+=2:55296==(64512&r)&&56320==(64512&e.charCodeAt(n+1))?(++n,t+=4):t+=3;return t},r.read=function(e,t,r){if(r-t<1)return"";for(var n,i=null,o=[],s=0;t<r;)(n=e[t++])<128?o[s++]=n:n>191&&n<224?o[s++]=(31&n)<<6|63&e[t++]:n>239&&n<365?(n=((7&n)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,o[s++]=55296+(n>>10),o[s++]=56320+(1023&n)):o[s++]=(15&n)<<12|(63&e[t++])<<6|63&e[t++],s>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,o)),s=0);return i?(s&&i.push(String.fromCharCode.apply(String,o.slice(0,s))),i.join("")):String.fromCharCode.apply(String,o.slice(0,s))},r.write=function(e,t,r){for(var n,i,o=r,s=0;s<e.length;++s)(n=e.charCodeAt(s))<128?t[r++]=n:n<2048?(t[r++]=n>>6|192,t[r++]=63&n|128):55296==(64512&n)&&56320==(64512&(i=e.charCodeAt(s+1)))?(n=65536+((1023&n)<<10)+(1023&i),++s,t[r++]=n>>18|240,t[r++]=n>>12&63|128,t[r++]=n>>6&63|128,t[r++]=63&n|128):(t[r++]=n>>12|224,t[r++]=n>>6&63|128,t[r++]=63&n|128);return r-o}},3052:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{(function(){"use strict";const state_=Symbol("state_"),storedError_=Symbol("storedError_");function isInteger(e){if(!isFinite(e))return!1;const t=Math.abs(e);return Math.floor(t)===t}function isFiniteNonNegativeNumber(e){return!("number"!=typeof e||!isFinite(e))&&e>=0}function isAbortSignal(e){if("object"!=typeof e||null===e)return!1;try{return Object.getOwnPropertyDescriptor(AbortSignal.prototype,"aborted").get.call(e),!0}catch(e){return!1}}function invokeOrNoop(e,t,r){const n=e[t];if(void 0!==n)return Function.prototype.apply.call(n,e,r)}function cloneArrayBuffer(e,t,r,n){return e.slice(t,t+r)}function transferArrayBuffer(e){return e.slice(0)}function copyDataBlockBytes(e,t,r,n,i){new Uint8Array(e,t,i).set(new Uint8Array(r,n,i))}const objectCloneMemo=new WeakMap;let sharedArrayBufferSupported_;function supportsSharedArrayBuffer(){if(void 0===sharedArrayBufferSupported_)try{new SharedArrayBuffer(16),sharedArrayBufferSupported_=!0}catch(e){sharedArrayBufferSupported_=!1}return sharedArrayBufferSupported_}function cloneValue(e){switch(typeof e){case"number":case"string":case"boolean":case"undefined":case"bigint":return e;case"object":{if(objectCloneMemo.has(e))return objectCloneMemo.get(e);if(null===e)return e;if(e instanceof Date)return new Date(e.valueOf());if(e instanceof RegExp)return new RegExp(e);if(supportsSharedArrayBuffer()&&e instanceof SharedArrayBuffer)return e;if(e instanceof ArrayBuffer){const t=cloneArrayBuffer(e,0,e.byteLength);return objectCloneMemo.set(e,t),t}if(ArrayBuffer.isView(e)){const t=cloneValue(e.buffer);let r;return r=e instanceof DataView?e.byteLength:e.length,new e.constructor(t,e.byteOffset,r)}if(e instanceof Map){const t=new Map;return objectCloneMemo.set(e,t),e.forEach(((e,r)=>t.set(r,cloneValue(e)))),t}if(e instanceof Set){const t=new Map;return objectCloneMemo.set(e,t),e.forEach(((e,r)=>t.set(r,cloneValue(e)))),t}const t={};objectCloneMemo.set(e,t);const r=Object.getOwnPropertyNames(e);for(const n of r)t[n]=cloneValue(e[n]);return t}default:throw new DOMException("Uncloneable value in stream","DataCloneError")}}function promiseCall(e,t,r){try{const n=Function.prototype.apply.call(e,t,r);return Promise.resolve(n)}catch(e){return Promise.reject(e)}}function createAlgorithmFromUnderlyingMethod(e,t,r){const n=e[t];if(void 0===n)return()=>Promise.resolve(void 0);if("function"!=typeof n)throw new TypeError(`Field "${t}" is not a function.`);return function(...t){return promiseCall(n,e,t.concat(r))}}function validateAndNormalizeHighWaterMark(e){const t=Number(e);if(isNaN(t)||t<0)throw new RangeError("highWaterMark must be a valid, non-negative integer.");return t}function makeSizeAlgorithmFromSizeFunction(e){if("function"!=typeof e&&void 0!==e)throw new TypeError("size function must be undefined or a function");return function(t){return"function"==typeof e?e(t):1}}function createControlledPromise(){const e={state:0};return e.promise=new Promise((function(t,r){e.resolve=function(r){e.state=1,t(r)},e.reject=function(t){e.state=2,r(t)}})),e}const CHUNK_SIZE=16384;class QueueImpl{constructor(){this.chunks_=[[]],this.readChunk_=this.writeChunk_=this.chunks_[0],this.length_=0}push(e){this.writeChunk_.push(e),this.length_+=1,this.writeChunk_.length===CHUNK_SIZE&&(this.writeChunk_=[],this.chunks_.push(this.writeChunk_))}front(){if(0!==this.length_)return this.readChunk_[0]}shift(){if(0===this.length_)return;const e=this.readChunk_.shift();return this.length_-=1,0===this.readChunk_.length&&this.readChunk_!==this.writeChunk_&&(this.chunks_.shift(),this.readChunk_=this.chunks_[0]),e}get length(){return this.length_}}const queue_=Symbol("queue_"),queueTotalSize_=Symbol("queueTotalSize_");function dequeueValue(e){const t=e[queue_].shift(),r=e[queueTotalSize_]-t.size;return e[queueTotalSize_]=Math.max(0,r),t.value}function enqueueValueWithSize(e,t,r){if(!isFiniteNonNegativeNumber(r))throw new RangeError("Chunk size must be a non-negative, finite numbers");e[queue_].push({value:t,size:r}),e[queueTotalSize_]+=r}function peekQueueValue(e){return e[queue_].front().value}function resetQueue(e){e[queue_]=new QueueImpl,e[queueTotalSize_]=0}const controlledReadableStream_=Symbol("controlledReadableStream_"),pullAlgorithm_=Symbol("pullAlgorithm_"),cancelAlgorithm_=Symbol("cancelAlgorithm_"),strategySizeAlgorithm_=Symbol("strategySizeAlgorithm_"),strategyHWM_=Symbol("strategyHWM_"),started_=Symbol("started_"),closeRequested_=Symbol("closeRequested_"),pullAgain_=Symbol("pullAgain_"),pulling_=Symbol("pulling_"),cancelSteps_=Symbol("cancelSteps_"),pullSteps_=Symbol("pullSteps_"),autoAllocateChunkSize_=Symbol("autoAllocateChunkSize_"),byobRequest_=Symbol("byobRequest_"),controlledReadableByteStream_=Symbol("controlledReadableByteStream_"),pendingPullIntos_=Symbol("pendingPullIntos_"),closedPromise_=Symbol("closedPromise_"),ownerReadableStream_=Symbol("ownerReadableStream_"),readRequests_=Symbol("readRequests_"),readIntoRequests_=Symbol("readIntoRequests_"),associatedReadableByteStreamController_=Symbol("associatedReadableByteStreamController_"),view_=Symbol("view_"),reader_=Symbol("reader_"),readableStreamController_=Symbol("readableStreamController_");function initializeReadableStream(e){e[state_]="readable",e[reader_]=void 0,e[storedError_]=void 0,e[readableStreamController_]=void 0}function isReadableStream(e){return"object"==typeof e&&null!==e&&readableStreamController_ in e}function isReadableStreamLocked(e){return void 0!==e[reader_]}function readableStreamGetNumReadIntoRequests(e){const t=e[reader_];return void 0===t?0:t[readIntoRequests_].length}function readableStreamGetNumReadRequests(e){const t=e[reader_];return void 0===t?0:t[readRequests_].length}function readableStreamCreateReadResult(e,t,r){const n=r?Object.prototype:null,i=Object.create(n);return i.value=e,i.done=t,i}function readableStreamAddReadIntoRequest(e,t){const r=e[reader_],n=createControlledPromise();return n.forAuthorCode=t,r[readIntoRequests_].push(n),n.promise}function readableStreamAddReadRequest(e,t){const r=e[reader_],n=createControlledPromise();return n.forAuthorCode=t,r[readRequests_].push(n),n.promise}function readableStreamHasBYOBReader(e){return isReadableStreamBYOBReader(e[reader_])}function readableStreamHasDefaultReader(e){return isReadableStreamDefaultReader(e[reader_])}function readableStreamCancel(e,t){return"closed"===e[state_]?Promise.resolve(void 0):"errored"===e[state_]?Promise.reject(e[storedError_]):(readableStreamClose(e),e[readableStreamController_][cancelSteps_](t).then((e=>{})))}function readableStreamClose(e){e[state_]="closed";const t=e[reader_];if(void 0!==t&&(t[closedPromise_].resolve(),t[closedPromise_].promise.catch((()=>{})),isReadableStreamDefaultReader(t))){for(const e of t[readRequests_])e.resolve(readableStreamCreateReadResult(void 0,!0,e.forAuthorCode));t[readRequests_]=[]}}function readableStreamError(e,t){if("readable"!==e[state_])throw new RangeError("Stream is in an invalid state");e[state_]="errored",e[storedError_]=t;const r=e[reader_];if(void 0!==r)if(r[closedPromise_].reject(t),isReadableStreamDefaultReader(r)){for(const e of r[readRequests_])e.reject(t);r[readRequests_]=[]}else{const e=r[readIntoRequests_];for(const r of e)r.reject(t);r[readIntoRequests_]=[]}}function isReadableStreamDefaultReader(e){return"object"==typeof e&&null!==e&&readRequests_ in e}function isReadableStreamBYOBReader(e){return"object"==typeof e&&null!==e&&readIntoRequests_ in e}function readableStreamReaderGenericInitialize(e,t){e[ownerReadableStream_]=t,t[reader_]=e;const r=t[state_];e[closedPromise_]=createControlledPromise(),"readable"===r||("closed"===r?e[closedPromise_].resolve(void 0):(e[closedPromise_].reject(t[storedError_]),e[closedPromise_].promise.catch((()=>{}))))}function readableStreamReaderGenericRelease(e){const t=e[ownerReadableStream_];if(void 0===t)throw new TypeError("Reader is in an inconsistent state");"readable"===t[state_]||(e[closedPromise_]=createControlledPromise()),e[closedPromise_].reject(new TypeError),e[closedPromise_].promise.catch((()=>{})),t[reader_]=void 0,e[ownerReadableStream_]=void 0}function readableStreamBYOBReaderRead(e,t,r=!1){const n=e[ownerReadableStream_];return"errored"===n[state_]?Promise.reject(n[storedError_]):readableByteStreamControllerPullInto(n[readableStreamController_],t,r)}function readableStreamDefaultReaderRead(e,t=!1){const r=e[ownerReadableStream_];return"closed"===r[state_]?Promise.resolve(readableStreamCreateReadResult(void 0,!0,t)):"errored"===r[state_]?Promise.reject(r[storedError_]):r[readableStreamController_][pullSteps_](t)}function readableStreamFulfillReadIntoRequest(e,t,r){const n=e[reader_][readIntoRequests_].shift();n.resolve(readableStreamCreateReadResult(t,r,n.forAuthorCode))}function readableStreamFulfillReadRequest(e,t,r){const n=e[reader_][readRequests_].shift();n.resolve(readableStreamCreateReadResult(t,r,n.forAuthorCode))}function setUpReadableStreamDefaultController(e,t,r,n,i,o,s){t[controlledReadableStream_]=e,resetQueue(t),t[started_]=!1,t[closeRequested_]=!1,t[pullAgain_]=!1,t[pulling_]=!1,t[strategySizeAlgorithm_]=s,t[strategyHWM_]=o,t[pullAlgorithm_]=n,t[cancelAlgorithm_]=i,e[readableStreamController_]=t;const a=r();Promise.resolve(a).then((e=>{t[started_]=!0,readableStreamDefaultControllerCallPullIfNeeded(t)}),(e=>{readableStreamDefaultControllerError(t,e)}))}function isReadableStreamDefaultController(e){return"object"==typeof e&&null!==e&&controlledReadableStream_ in e}function readableStreamDefaultControllerHasBackpressure(e){return!readableStreamDefaultControllerShouldCallPull(e)}function readableStreamDefaultControllerCanCloseOrEnqueue(e){const t=e[controlledReadableStream_][state_];return!1===e[closeRequested_]&&"readable"===t}function readableStreamDefaultControllerGetDesiredSize(e){const t=e[controlledReadableStream_][state_];return"errored"===t?null:"closed"===t?0:e[strategyHWM_]-e[queueTotalSize_]}function readableStreamDefaultControllerClose(e){e[closeRequested_]=!0;const t=e[controlledReadableStream_];0===e[queue_].length&&(readableStreamDefaultControllerClearAlgorithms(e),readableStreamClose(t))}function readableStreamDefaultControllerEnqueue(e,t){const r=e[controlledReadableStream_];if(isReadableStreamLocked(r)&&readableStreamGetNumReadRequests(r)>0)readableStreamFulfillReadRequest(r,t,!1);else{let r;try{r=e[strategySizeAlgorithm_](t)}catch(t){throw readableStreamDefaultControllerError(e,t),t}try{enqueueValueWithSize(e,t,r)}catch(t){throw readableStreamDefaultControllerError(e,t),t}}readableStreamDefaultControllerCallPullIfNeeded(e)}function readableStreamDefaultControllerError(e,t){const r=e[controlledReadableStream_];"readable"===r[state_]&&(resetQueue(e),readableStreamDefaultControllerClearAlgorithms(e),readableStreamError(r,t))}function readableStreamDefaultControllerCallPullIfNeeded(e){if(readableStreamDefaultControllerShouldCallPull(e))if(e[pulling_])e[pullAgain_]=!0;else{if(e[pullAgain_])throw new RangeError("Stream controller is in an invalid state.");e[pulling_]=!0,e[pullAlgorithm_](e).then((t=>{e[pulling_]=!1,e[pullAgain_]&&(e[pullAgain_]=!1,readableStreamDefaultControllerCallPullIfNeeded(e))}),(t=>{readableStreamDefaultControllerError(e,t)}))}}function readableStreamDefaultControllerShouldCallPull(e){const t=e[controlledReadableStream_];if(!readableStreamDefaultControllerCanCloseOrEnqueue(e))return!1;if(!1===e[started_])return!1;if(isReadableStreamLocked(t)&&readableStreamGetNumReadRequests(t)>0)return!0;const r=readableStreamDefaultControllerGetDesiredSize(e);if(null===r)throw new RangeError("Stream is in an invalid state.");return r>0}function readableStreamDefaultControllerClearAlgorithms(e){e[pullAlgorithm_]=void 0,e[cancelAlgorithm_]=void 0,e[strategySizeAlgorithm_]=void 0}function setUpReadableByteStreamController(e,t,r,n,i,o,s){if(void 0!==e[readableStreamController_])throw new TypeError("Cannot reuse streams");if(void 0!==s&&(!isInteger(s)||s<=0))throw new RangeError("autoAllocateChunkSize must be a positive, finite integer");t[controlledReadableByteStream_]=e,t[pullAgain_]=!1,t[pulling_]=!1,readableByteStreamControllerClearPendingPullIntos(t),resetQueue(t),t[closeRequested_]=!1,t[started_]=!1,t[strategyHWM_]=validateAndNormalizeHighWaterMark(o),t[pullAlgorithm_]=n,t[cancelAlgorithm_]=i,t[autoAllocateChunkSize_]=s,t[pendingPullIntos_]=[],e[readableStreamController_]=t;const a=r();Promise.resolve(a).then((e=>{t[started_]=!0,readableByteStreamControllerCallPullIfNeeded(t)}),(e=>{readableByteStreamControllerError(t,e)}))}function isReadableStreamBYOBRequest(e){return"object"==typeof e&&null!==e&&associatedReadableByteStreamController_ in e}function isReadableByteStreamController(e){return"object"==typeof e&&null!==e&&controlledReadableByteStream_ in e}function readableByteStreamControllerCallPullIfNeeded(e){readableByteStreamControllerShouldCallPull(e)&&(e[pulling_]?e[pullAgain_]=!0:(e[pulling_]=!0,e[pullAlgorithm_](e).then((t=>{e[pulling_]=!1,e[pullAgain_]&&(e[pullAgain_]=!1,readableByteStreamControllerCallPullIfNeeded(e))}),(t=>{readableByteStreamControllerError(e,t)}))))}function readableByteStreamControllerClearAlgorithms(e){e[pullAlgorithm_]=void 0,e[cancelAlgorithm_]=void 0}function readableByteStreamControllerClearPendingPullIntos(e){readableByteStreamControllerInvalidateBYOBRequest(e),e[pendingPullIntos_]=[]}function readableByteStreamControllerClose(e){const t=e[controlledReadableByteStream_];if(e[queueTotalSize_]>0)e[closeRequested_]=!0;else{if(e[pendingPullIntos_].length>0&&e[pendingPullIntos_][0].bytesFilled>0){const t=new TypeError;throw readableByteStreamControllerError(e,t),t}readableByteStreamControllerClearAlgorithms(e),readableStreamClose(t)}}function readableByteStreamControllerCommitPullIntoDescriptor(e,t){let r=!1;"closed"===e[state_]&&(r=!0);const n=readableByteStreamControllerConvertPullIntoDescriptor(t);"default"===t.readerType?readableStreamFulfillReadRequest(e,n,r):readableStreamFulfillReadIntoRequest(e,n,r)}function readableByteStreamControllerConvertPullIntoDescriptor(e){const{bytesFilled:t,elementSize:r}=e;return new e.ctor(e.buffer,e.byteOffset,t/r)}function readableByteStreamControllerEnqueue(e,t){const r=e[controlledReadableByteStream_],{buffer:n,byteOffset:i,byteLength:o}=t,s=transferArrayBuffer(n);readableStreamHasDefaultReader(r)?0===readableStreamGetNumReadRequests(r)?readableByteStreamControllerEnqueueChunkToQueue(e,s,i,o):readableStreamFulfillReadRequest(r,new Uint8Array(s,i,o),!1):readableStreamHasBYOBReader(r)?(readableByteStreamControllerEnqueueChunkToQueue(e,s,i,o),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e)):readableByteStreamControllerEnqueueChunkToQueue(e,s,i,o),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerEnqueueChunkToQueue(e,t,r,n){e[queue_].push({buffer:t,byteOffset:r,byteLength:n}),e[queueTotalSize_]+=n}function readableByteStreamControllerError(e,t){const r=e[controlledReadableByteStream_];"readable"===r[state_]&&(readableByteStreamControllerClearPendingPullIntos(e),resetQueue(e),readableByteStreamControllerClearAlgorithms(e),readableStreamError(r,t))}function readableByteStreamControllerFillHeadPullIntoDescriptor(e,t,r){readableByteStreamControllerInvalidateBYOBRequest(e),r.bytesFilled+=t}function readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,t){const r=t.elementSize,n=t.bytesFilled-t.bytesFilled%r,i=Math.min(e[queueTotalSize_],t.byteLength-t.bytesFilled),o=t.bytesFilled+i,s=o-o%r;let a=i,l=!1;s>n&&(a=s-t.bytesFilled,l=!0);const u=e[queue_];for(;a>0;){const r=u.front(),n=Math.min(a,r.byteLength),i=t.byteOffset+t.bytesFilled;copyDataBlockBytes(t.buffer,i,r.buffer,r.byteOffset,n),r.byteLength===n?u.shift():(r.byteOffset+=n,r.byteLength-=n),e[queueTotalSize_]-=n,readableByteStreamControllerFillHeadPullIntoDescriptor(e,n,t),a-=n}return l}function readableByteStreamControllerGetDesiredSize(e){const t=e[controlledReadableByteStream_][state_];return"errored"===t?null:"closed"===t?0:e[strategyHWM_]-e[queueTotalSize_]}function readableByteStreamControllerHandleQueueDrain(e){0===e[queueTotalSize_]&&e[closeRequested_]?(readableByteStreamControllerClearAlgorithms(e),readableStreamClose(e[controlledReadableByteStream_])):readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerInvalidateBYOBRequest(e){const t=e[byobRequest_];void 0!==t&&(t[associatedReadableByteStreamController_]=void 0,t[view_]=void 0,e[byobRequest_]=void 0)}function readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e){const t=e[pendingPullIntos_];for(;t.length>0;){if(0===e[queueTotalSize_])return;const r=t[0];readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,r)&&(readableByteStreamControllerShiftPendingPullInto(e),readableByteStreamControllerCommitPullIntoDescriptor(e[controlledReadableByteStream_],r))}}function readableByteStreamControllerPullInto(e,t,r){const n=e[controlledReadableByteStream_],i=t.BYTES_PER_ELEMENT||1,o=t.constructor,s=t.byteOffset,a=t.byteLength,l={buffer:transferArrayBuffer(t.buffer),byteOffset:s,byteLength:a,bytesFilled:0,elementSize:i,ctor:o,readerType:"byob"};if(e[pendingPullIntos_].length>0)return e[pendingPullIntos_].push(l),readableStreamAddReadIntoRequest(n,r);if("closed"===n[state_]){const e=new o(l.buffer,l.byteOffset,0);return Promise.resolve(readableStreamCreateReadResult(e,!0,r))}if(e[queueTotalSize_]>0){if(readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,l)){const t=readableByteStreamControllerConvertPullIntoDescriptor(l);return readableByteStreamControllerHandleQueueDrain(e),Promise.resolve(readableStreamCreateReadResult(t,!1,r))}if(e[closeRequested_]){const t=new TypeError;return readableByteStreamControllerError(e,t),Promise.reject(t)}}e[pendingPullIntos_].push(l);const u=readableStreamAddReadIntoRequest(n,r);return readableByteStreamControllerCallPullIfNeeded(e),u}function readableByteStreamControllerRespond(e,t){if(!isFiniteNonNegativeNumber(t=Number(t)))throw new RangeError("bytesWritten must be a finite, non-negative number");readableByteStreamControllerRespondInternal(e,t)}function readableByteStreamControllerRespondInClosedState(e,t){t.buffer=transferArrayBuffer(t.buffer);const r=e[controlledReadableByteStream_];if(readableStreamHasBYOBReader(r))for(;readableStreamGetNumReadIntoRequests(r)>0;)readableByteStreamControllerCommitPullIntoDescriptor(r,readableByteStreamControllerShiftPendingPullInto(e))}function readableByteStreamControllerRespondInReadableState(e,t,r){if(r.bytesFilled+t>r.byteLength)throw new RangeError;if(readableByteStreamControllerFillHeadPullIntoDescriptor(e,t,r),r.bytesFilled<r.elementSize)return;readableByteStreamControllerShiftPendingPullInto(e);const n=r.bytesFilled%r.elementSize;if(n>0){const t=r.byteOffset+r.bytesFilled,i=cloneArrayBuffer(r.buffer,t-n,n);readableByteStreamControllerEnqueueChunkToQueue(e,i,0,i.byteLength)}r.buffer=transferArrayBuffer(r.buffer),r.bytesFilled=r.bytesFilled-n,readableByteStreamControllerCommitPullIntoDescriptor(e[controlledReadableByteStream_],r),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e)}function readableByteStreamControllerRespondInternal(e,t){const r=e[pendingPullIntos_][0];if("closed"===e[controlledReadableByteStream_][state_]){if(0!==t)throw new TypeError;readableByteStreamControllerRespondInClosedState(e,r)}else readableByteStreamControllerRespondInReadableState(e,t,r);readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerRespondWithNewView(e,t){const r=e[pendingPullIntos_][0];if(r.byteOffset+r.bytesFilled!==t.byteOffset)throw new RangeError;if(r.byteLength!==t.byteLength)throw new RangeError;r.buffer=t.buffer,readableByteStreamControllerRespondInternal(e,t.byteLength)}function readableByteStreamControllerShiftPendingPullInto(e){const t=e[pendingPullIntos_].shift();return readableByteStreamControllerInvalidateBYOBRequest(e),t}function readableByteStreamControllerShouldCallPull(e){const t=e[controlledReadableByteStream_];return"readable"===t[state_]&&!e[closeRequested_]&&!!e[started_]&&(!!(readableStreamHasDefaultReader(t)&&readableStreamGetNumReadRequests(t)>0)||!!(readableStreamHasBYOBReader(t)&&readableStreamGetNumReadIntoRequests(t)>0)||readableByteStreamControllerGetDesiredSize(e)>0)}function setUpReadableStreamBYOBRequest(e,t,r){if(!isReadableByteStreamController(t))throw new TypeError;if(!ArrayBuffer.isView(r))throw new TypeError;e[associatedReadableByteStreamController_]=t,e[view_]=r}const backpressure_=Symbol("backpressure_"),closeRequest_=Symbol("closeRequest_"),inFlightWriteRequest_=Symbol("inFlightWriteRequest_"),inFlightCloseRequest_=Symbol("inFlightCloseRequest_"),pendingAbortRequest_=Symbol("pendingAbortRequest_"),writableStreamController_=Symbol("writableStreamController_"),writer_=Symbol("writer_"),writeRequests_=Symbol("writeRequests_"),abortAlgorithm_=Symbol("abortAlgorithm_"),closeAlgorithm_=Symbol("closeAlgorithm_"),controlledWritableStream_=Symbol("controlledWritableStream_"),started_$1=Symbol("started_"),strategyHWM_$1=Symbol("strategyHWM_"),strategySizeAlgorithm_$1=Symbol("strategySizeAlgorithm_"),writeAlgorithm_=Symbol("writeAlgorithm_"),ownerWritableStream_=Symbol("ownerWritableStream_"),closedPromise_$1=Symbol("closedPromise_"),readyPromise_=Symbol("readyPromise_"),errorSteps_=Symbol("errorSteps_"),abortSteps_=Symbol("abortSteps_");function initializeWritableStream(e){e[state_]="writable",e[storedError_]=void 0,e[writer_]=void 0,e[writableStreamController_]=void 0,e[inFlightWriteRequest_]=void 0,e[closeRequest_]=void 0,e[inFlightCloseRequest_]=void 0,e[pendingAbortRequest_]=void 0,e[writeRequests_]=[],e[backpressure_]=!1}function isWritableStream(e){return"object"==typeof e&&null!==e&&writableStreamController_ in e}function isWritableStreamLocked(e){return void 0!==e[writer_]}function writableStreamAbort(e,t){const r=e[state_];if("closed"===r||"errored"===r)return Promise.resolve(void 0);let n=e[pendingAbortRequest_];if(void 0!==n)return n.promise;let i=!1;"erroring"===r&&(i=!0,t=void 0),n={reason:t,wasAlreadyErroring:i};const o=new Promise(((e,t)=>{n.resolve=e,n.reject=t}));return n.promise=o,e[pendingAbortRequest_]=n,i||writableStreamStartErroring(e,t),o}function writableStreamAddWriteRequest(e){const t=createControlledPromise();return e[writeRequests_].push(t),t.promise}function writableStreamDealWithRejection(e,t){"writable"!==e[state_]?writableStreamFinishErroring(e):writableStreamStartErroring(e,t)}function writableStreamStartErroring(e,t){const r=e[writableStreamController_];e[state_]="erroring",e[storedError_]=t;const n=e[writer_];void 0!==n&&writableStreamDefaultWriterEnsureReadyPromiseRejected(n,t),!writableStreamHasOperationMarkedInFlight(e)&&r[started_$1]&&writableStreamFinishErroring(e)}function writableStreamFinishErroring(e){e[state_]="errored";const t=e[writableStreamController_];t[errorSteps_]();const r=e[storedError_];for(const t of e[writeRequests_])t.reject(r);e[writeRequests_]=[];const n=e[pendingAbortRequest_];if(void 0!==n)return e[pendingAbortRequest_]=void 0,n.wasAlreadyErroring?(n.reject(r),void writableStreamRejectCloseAndClosedPromiseIfNeeded(e)):void t[abortSteps_](n.reason).then((t=>{n.resolve(),writableStreamRejectCloseAndClosedPromiseIfNeeded(e)}),(t=>{n.reject(t),writableStreamRejectCloseAndClosedPromiseIfNeeded(e)}));writableStreamRejectCloseAndClosedPromiseIfNeeded(e)}function writableStreamFinishInFlightWrite(e){e[inFlightWriteRequest_].resolve(void 0),e[inFlightWriteRequest_]=void 0}function writableStreamFinishInFlightWriteWithError(e,t){e[inFlightWriteRequest_].reject(t),e[inFlightWriteRequest_]=void 0,writableStreamDealWithRejection(e,t)}function writableStreamFinishInFlightClose(e){e[inFlightCloseRequest_].resolve(void 0),e[inFlightCloseRequest_]=void 0,"erroring"===e[state_]&&(e[storedError_]=void 0,void 0!==e[pendingAbortRequest_]&&(e[pendingAbortRequest_].resolve(),e[pendingAbortRequest_]=void 0)),e[state_]="closed";const t=e[writer_];void 0!==t&&t[closedPromise_$1].resolve(void 0)}function writableStreamFinishInFlightCloseWithError(e,t){e[inFlightCloseRequest_].reject(t),e[inFlightCloseRequest_]=void 0,void 0!==e[pendingAbortRequest_]&&(e[pendingAbortRequest_].reject(t),e[pendingAbortRequest_]=void 0),writableStreamDealWithRejection(e,t)}function writableStreamCloseQueuedOrInFlight(e){return void 0!==e[closeRequest_]||void 0!==e[inFlightCloseRequest_]}function writableStreamHasOperationMarkedInFlight(e){return void 0!==e[inFlightWriteRequest_]||void 0!==e[inFlightCloseRequest_]}function writableStreamMarkCloseRequestInFlight(e){e[inFlightCloseRequest_]=e[closeRequest_],e[closeRequest_]=void 0}function writableStreamMarkFirstWriteRequestInFlight(e){const t=e[writeRequests_].shift();e[inFlightWriteRequest_]=t}function writableStreamRejectCloseAndClosedPromiseIfNeeded(e){const t=e[closeRequest_];void 0!==t&&(t.reject(e[storedError_]),e[closeRequest_]=void 0);const r=e[writer_];void 0!==r&&(r[closedPromise_$1].reject(e[storedError_]),r[closedPromise_$1].promise.catch((()=>{})))}function writableStreamUpdateBackpressure(e,t){const r=e[writer_];void 0!==r&&t!==e[backpressure_]&&(t?r[readyPromise_]=createControlledPromise():r[readyPromise_].resolve(void 0)),e[backpressure_]=t}function isWritableStreamDefaultWriter(e){return"object"==typeof e&&null!==e&&ownerWritableStream_ in e}function writableStreamDefaultWriterAbort(e,t){return writableStreamAbort(e[ownerWritableStream_],t)}function writableStreamDefaultWriterClose(e){const t=e[ownerWritableStream_],r=t[state_];if("closed"===r||"errored"===r)return Promise.reject(new TypeError("Writer stream is already closed or errored"));const n=createControlledPromise();return t[closeRequest_]=n,t[backpressure_]&&"writable"===r&&e[readyPromise_].resolve(void 0),writableStreamDefaultControllerClose(t[writableStreamController_]),n.promise}function writableStreamDefaultWriterCloseWithErrorPropagation(e){const t=e[ownerWritableStream_],r=t[state_];return writableStreamCloseQueuedOrInFlight(t)||"closed"===r?Promise.resolve(void 0):"errored"===r?Promise.reject(t[storedError_]):writableStreamDefaultWriterClose(e)}function writableStreamDefaultWriterEnsureClosedPromiseRejected(e,t){const r=e[closedPromise_$1];0===r.state?r.reject(t):(e[closedPromise_$1]=createControlledPromise(),e[closedPromise_$1].reject(t)),e[closedPromise_$1].promise.catch((()=>{}))}function writableStreamDefaultWriterEnsureReadyPromiseRejected(e,t){const r=e[readyPromise_];0===r.state?r.reject(t):(e[readyPromise_]=createControlledPromise(),e[readyPromise_].reject(t)),e[readyPromise_].promise.catch((()=>{}))}function writableStreamDefaultWriterGetDesiredSize(e){const t=e[ownerWritableStream_],r=t[state_];return"errored"===r||"erroring"===r?null:"closed"===r?0:writableStreamDefaultControllerGetDesiredSize(t[writableStreamController_])}function writableStreamDefaultWriterRelease(e){const t=e[ownerWritableStream_],r=new TypeError;writableStreamDefaultWriterEnsureReadyPromiseRejected(e,r),writableStreamDefaultWriterEnsureClosedPromiseRejected(e,r),t[writer_]=void 0,e[ownerWritableStream_]=void 0}function writableStreamDefaultWriterWrite(e,t){const r=e[ownerWritableStream_],n=r[writableStreamController_],i=writableStreamDefaultControllerGetChunkSize(n,t);if(e[ownerWritableStream_]!==r)return Promise.reject(new TypeError);const o=r[state_];if("errored"===o)return Promise.reject(r[storedError_]);if(writableStreamCloseQueuedOrInFlight(r)||"closed"===o)return Promise.reject(new TypeError("Cannot write to a closing or closed stream"));if("erroring"===o)return Promise.reject(r[storedError_]);const s=writableStreamAddWriteRequest(r);return writableStreamDefaultControllerWrite(n,t,i),s}function setUpWritableStreamDefaultController(e,t,r,n,i,o,s,a){if(!isWritableStream(e))throw new TypeError;if(void 0!==e[writableStreamController_])throw new TypeError;t[controlledWritableStream_]=e,e[writableStreamController_]=t,resetQueue(t),t[started_$1]=!1,t[strategySizeAlgorithm_$1]=a,t[strategyHWM_$1]=s,t[writeAlgorithm_]=n,t[closeAlgorithm_]=i,t[abortAlgorithm_]=o;const l=writableStreamDefaultControllerGetBackpressure(t);writableStreamUpdateBackpressure(e,l);const u=r();Promise.resolve(u).then((e=>{t[started_$1]=!0,writableStreamDefaultControllerAdvanceQueueIfNeeded(t)}),(r=>{t[started_$1]=!0,writableStreamDealWithRejection(e,r)}))}function isWritableStreamDefaultController(e){return"object"==typeof e&&null!==e&&controlledWritableStream_ in e}function writableStreamDefaultControllerClearAlgorithms(e){e[writeAlgorithm_]=void 0,e[closeAlgorithm_]=void 0,e[abortAlgorithm_]=void 0,e[strategySizeAlgorithm_$1]=void 0}function writableStreamDefaultControllerClose(e){enqueueValueWithSize(e,"close",0),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)}function writableStreamDefaultControllerGetChunkSize(e,t){let r;try{r=e[strategySizeAlgorithm_$1](t)}catch(t){writableStreamDefaultControllerErrorIfNeeded(e,t),r=1}return r}function writableStreamDefaultControllerGetDesiredSize(e){return e[strategyHWM_$1]-e[queueTotalSize_]}function writableStreamDefaultControllerWrite(e,t,r){try{enqueueValueWithSize(e,{chunk:t},r)}catch(t){return void writableStreamDefaultControllerErrorIfNeeded(e,t)}const n=e[controlledWritableStream_];writableStreamCloseQueuedOrInFlight(n)||"writable"!==n[state_]||writableStreamUpdateBackpressure(n,writableStreamDefaultControllerGetBackpressure(e)),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)}function writableStreamDefaultControllerAdvanceQueueIfNeeded(e){if(!e[started_$1])return;const t=e[controlledWritableStream_];if(void 0!==t[inFlightWriteRequest_])return;const r=t[state_];if("closed"===r||"errored"===r)return;if("erroring"===r)return void writableStreamFinishErroring(t);if(0===e[queue_].length)return;const n=peekQueueValue(e);"close"===n?writableStreamDefaultControllerProcessClose(e):writableStreamDefaultControllerProcessWrite(e,n.chunk)}function writableStreamDefaultControllerErrorIfNeeded(e,t){"writable"===e[controlledWritableStream_][state_]&&writableStreamDefaultControllerError(e,t)}function writableStreamDefaultControllerProcessClose(e){const t=e[controlledWritableStream_];writableStreamMarkCloseRequestInFlight(t),dequeueValue(e);const r=e[closeAlgorithm_]();writableStreamDefaultControllerClearAlgorithms(e),r.then((e=>{writableStreamFinishInFlightClose(t)}),(e=>{writableStreamFinishInFlightCloseWithError(t,e)}))}function writableStreamDefaultControllerProcessWrite(e,t){const r=e[controlledWritableStream_];writableStreamMarkFirstWriteRequestInFlight(r),e[writeAlgorithm_](t).then((t=>{writableStreamFinishInFlightWrite(r);const n=r[state_];if(dequeueValue(e),!writableStreamCloseQueuedOrInFlight(r)&&"writable"===n){const t=writableStreamDefaultControllerGetBackpressure(e);writableStreamUpdateBackpressure(r,t)}writableStreamDefaultControllerAdvanceQueueIfNeeded(e)}),(t=>{"writable"===r[state_]&&writableStreamDefaultControllerClearAlgorithms(e),writableStreamFinishInFlightWriteWithError(r,t)}))}function writableStreamDefaultControllerGetBackpressure(e){return writableStreamDefaultControllerGetDesiredSize(e)<=0}function writableStreamDefaultControllerError(e,t){const r=e[controlledWritableStream_];writableStreamDefaultControllerClearAlgorithms(e),writableStreamStartErroring(r,t)}class ReadableStreamDefaultReader{constructor(e){if(!isReadableStream(e))throw new TypeError;if(isReadableStreamLocked(e))throw new TypeError("The stream is locked.");readableStreamReaderGenericInitialize(this,e),this[readRequests_]=[]}get closed(){return isReadableStreamDefaultReader(this)?this[closedPromise_].promise:Promise.reject(new TypeError)}cancel(e){if(!isReadableStreamDefaultReader(this))return Promise.reject(new TypeError);const t=this[ownerReadableStream_];return void 0===t?Promise.reject(new TypeError("Reader is not associated with a stream")):readableStreamCancel(t,e)}read(){return isReadableStreamDefaultReader(this)?void 0===this[ownerReadableStream_]?Promise.reject(new TypeError("Reader is not associated with a stream")):readableStreamDefaultReaderRead(this,!0):Promise.reject(new TypeError)}releaseLock(){if(!isReadableStreamDefaultReader(this))throw new TypeError;if(void 0!==this[ownerReadableStream_]){if(0!==this[readRequests_].length)throw new TypeError("Cannot release a stream with pending read requests");readableStreamReaderGenericRelease(this)}}}class WritableStreamDefaultWriter{constructor(e){if(!isWritableStream(e))throw new TypeError;if(isWritableStreamLocked(e))throw new TypeError("Stream is already locked");this[ownerWritableStream_]=e,e[writer_]=this;const t=createControlledPromise(),r=createControlledPromise();this[readyPromise_]=t,this[closedPromise_$1]=r;const n=e[state_];if("writable"===n)!writableStreamCloseQueuedOrInFlight(e)&&e[backpressure_]||t.resolve(void 0);else if("erroring"===n)t.reject(e[storedError_]),t.promise.catch((()=>{}));else if("closed"===n)t.resolve(void 0),r.resolve(void 0);else{const n=e[storedError_];t.reject(n),t.promise.catch((()=>{})),r.reject(n),r.promise.catch((()=>{}))}}abort(e){return isWritableStreamDefaultWriter(this)?void 0===this[ownerWritableStream_]?Promise.reject(new TypeError("Writer is not connected to a stream")):writableStreamDefaultWriterAbort(this,e):Promise.reject(new TypeError)}close(){if(!isWritableStreamDefaultWriter(this))return Promise.reject(new TypeError);const e=this[ownerWritableStream_];return void 0===e?Promise.reject(new TypeError("Writer is not connected to a stream")):writableStreamCloseQueuedOrInFlight(e)?Promise.reject(new TypeError):writableStreamDefaultWriterClose(this)}releaseLock(){void 0!==this[ownerWritableStream_]&&writableStreamDefaultWriterRelease(this)}write(e){return isWritableStreamDefaultWriter(this)?void 0===this[ownerWritableStream_]?Promise.reject(new TypeError("Writer is not connected to a stream")):writableStreamDefaultWriterWrite(this,e):Promise.reject(new TypeError)}get closed(){return isWritableStreamDefaultWriter(this)?this[closedPromise_$1].promise:Promise.reject(new TypeError)}get desiredSize(){if(!isWritableStreamDefaultWriter(this))throw new TypeError;if(void 0===this[ownerWritableStream_])throw new TypeError("Writer is not connected to stream");return writableStreamDefaultWriterGetDesiredSize(this)}get ready(){return isWritableStreamDefaultWriter(this)?this[readyPromise_].promise:Promise.reject(new TypeError)}}function pipeTo(e,t,r){const n=!!r.preventClose,i=!!r.preventAbort,o=!!r.preventCancel,s=r.signal;let a=!1,l=Promise.resolve();const u=createControlledPromise(),c=new ReadableStreamDefaultReader(e),h=new WritableStreamDefaultWriter(t);let d;function f(e,t,r){"errored"===e[state_]?r(e[storedError_]):t.catch(r)}if(void 0!==s&&(d=()=>{const r=new DOMException("Aborted","AbortError"),n=[];!1===i&&n.push((()=>"writable"===t[state_]?writableStreamAbort(t,r):Promise.resolve())),!1===o&&n.push((()=>"readable"===e[state_]?readableStreamCancel(e,r):Promise.resolve())),y((()=>Promise.all(n.map((e=>e()))).then((e=>{}))),{actualError:r})},!0===s.aborted?d():s.addEventListener("abort",d)),f(e,c[closedPromise_].promise,(e=>{y(i?void 0:()=>writableStreamAbort(t,e),{actualError:e})})),f(t,h[closedPromise_$1].promise,(t=>{y(o?void 0:()=>readableStreamCancel(e,t),{actualError:t})})),function(e,t,r){"closed"===e[state_]?r():t.then(r)}(e,c[closedPromise_].promise,(()=>{n?y():y((()=>writableStreamDefaultWriterCloseWithErrorPropagation(h)))})),writableStreamCloseQueuedOrInFlight(t)||"closed"===t[state_]){const t=new TypeError;y(o?void 0:()=>readableStreamCancel(e,t),{actualError:t})}function p(){const e=l;return l.then((()=>e===l?void 0:p()))}function m(){return"writable"!==t[state_]||writableStreamCloseQueuedOrInFlight(t)?void 0:p()}function y(e,t){if(a)return;function r(){e().then((e=>g(t)),(e=>g({actualError:e})))}a=!0,void 0===e&&(e=()=>Promise.resolve());const n=m();n?n.then(r):r()}function g(e){writableStreamDefaultWriterRelease(h),readableStreamReaderGenericRelease(c),s&&d&&s.removeEventListener("abort",d),e?u.reject(e.actualError):u.resolve(void 0)}return function e(){a||h[readyPromise_].promise.then((()=>{readableStreamDefaultReaderRead(c).then((({value:t,done:r})=>{r||(l=writableStreamDefaultWriterWrite(h,t).catch((()=>{})),e())}),(e=>{l=Promise.resolve()}))}))}(),u.promise}class ReadableStreamDefaultController{constructor(){throw new TypeError}get desiredSize(){return readableStreamDefaultControllerGetDesiredSize(this)}close(){if(!isReadableStreamDefaultController(this))throw new TypeError;if(!readableStreamDefaultControllerCanCloseOrEnqueue(this))throw new TypeError("Cannot close, the stream is already closing or not readable");readableStreamDefaultControllerClose(this)}enqueue(e){if(!isReadableStreamDefaultController(this))throw new TypeError;if(!readableStreamDefaultControllerCanCloseOrEnqueue(this))throw new TypeError("Cannot enqueue, the stream is closing or not readable");readableStreamDefaultControllerEnqueue(this,e)}error(e){if(!isReadableStreamDefaultController(this))throw new TypeError;readableStreamDefaultControllerError(this,e)}[cancelSteps_](e){resetQueue(this);const t=this[cancelAlgorithm_](e);return readableStreamDefaultControllerClearAlgorithms(this),t}[pullSteps_](e){const t=this[controlledReadableStream_];if(this[queue_].length>0){const r=dequeueValue(this);return this[closeRequested_]&&0===this[queue_].length?(readableStreamDefaultControllerClearAlgorithms(this),readableStreamClose(t)):readableStreamDefaultControllerCallPullIfNeeded(this),Promise.resolve(readableStreamCreateReadResult(r,!1,e))}const r=readableStreamAddReadRequest(t,e);return readableStreamDefaultControllerCallPullIfNeeded(this),r}}function setUpReadableStreamDefaultControllerFromUnderlyingSource(e,t,r,n){const i=Object.create(ReadableStreamDefaultController.prototype),o=createAlgorithmFromUnderlyingMethod(t,"pull",[i]),s=createAlgorithmFromUnderlyingMethod(t,"cancel",[]);setUpReadableStreamDefaultController(e,i,(()=>invokeOrNoop(t,"start",[i])),o,s,r,n)}class ReadableStreamBYOBRequest{constructor(){throw new TypeError}get view(){if(!isReadableStreamBYOBRequest(this))throw new TypeError;return this[view_]}respond(e){if(!isReadableStreamBYOBRequest(this))throw new TypeError;if(void 0===this[associatedReadableByteStreamController_])throw new TypeError;return readableByteStreamControllerRespond(this[associatedReadableByteStreamController_],e)}respondWithNewView(e){if(!isReadableStreamBYOBRequest(this))throw new TypeError;if(void 0===this[associatedReadableByteStreamController_])throw new TypeError;if(!ArrayBuffer.isView(e))throw new TypeError("view parameter must be a TypedArray");return readableByteStreamControllerRespondWithNewView(this[associatedReadableByteStreamController_],e)}}class ReadableByteStreamController{constructor(){throw new TypeError}get byobRequest(){if(!isReadableByteStreamController(this))throw new TypeError;if(void 0===this[byobRequest_]&&this[pendingPullIntos_].length>0){const e=this[pendingPullIntos_][0],t=new Uint8Array(e.buffer,e.byteOffset+e.bytesFilled,e.byteLength-e.bytesFilled),r=Object.create(ReadableStreamBYOBRequest.prototype);setUpReadableStreamBYOBRequest(r,this,t),this[byobRequest_]=r}return this[byobRequest_]}get desiredSize(){if(!isReadableByteStreamController(this))throw new TypeError;return readableByteStreamControllerGetDesiredSize(this)}close(){if(!isReadableByteStreamController(this))throw new TypeError;if(this[closeRequested_])throw new TypeError("Stream is already closing");if("readable"!==this[controlledReadableByteStream_][state_])throw new TypeError("Stream is closed or errored");readableByteStreamControllerClose(this)}enqueue(e){if(!isReadableByteStreamController(this))throw new TypeError;if(this[closeRequested_])throw new TypeError("Stream is already closing");if("readable"!==this[controlledReadableByteStream_][state_])throw new TypeError("Stream is closed or errored");if(!ArrayBuffer.isView(e))throw new TypeError("chunk must be a valid ArrayBufferView");return readableByteStreamControllerEnqueue(this,e)}error(e){if(!isReadableByteStreamController(this))throw new TypeError;readableByteStreamControllerError(this,e)}[cancelSteps_](e){this[pendingPullIntos_].length>0&&(this[pendingPullIntos_][0].bytesFilled=0),resetQueue(this);const t=this[cancelAlgorithm_](e);return readableByteStreamControllerClearAlgorithms(this),t}[pullSteps_](e){const t=this[controlledReadableByteStream_];if(this[queueTotalSize_]>0){const t=this[queue_].shift();this[queueTotalSize_]-=t.byteLength,readableByteStreamControllerHandleQueueDrain(this);const r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);return Promise.resolve(readableStreamCreateReadResult(r,!1,e))}const r=this[autoAllocateChunkSize_];if(void 0!==r){let e;try{e=new ArrayBuffer(r)}catch(e){return Promise.reject(e)}const t={buffer:e,byteOffset:0,byteLength:r,bytesFilled:0,elementSize:1,ctor:Uint8Array,readerType:"default"};this[pendingPullIntos_].push(t)}const n=readableStreamAddReadRequest(t,e);return readableByteStreamControllerCallPullIfNeeded(this),n}}function setUpReadableByteStreamControllerFromUnderlyingSource(e,t,r){const n=Object.create(ReadableByteStreamController.prototype),i=createAlgorithmFromUnderlyingMethod(t,"pull",[n]),o=createAlgorithmFromUnderlyingMethod(t,"cancel",[]);let s=t.autoAllocateChunkSize;if(void 0!==s&&(s=Number(s),!isInteger(s)||s<=0))throw new RangeError("autoAllocateChunkSize must be a positive, finite integer");setUpReadableByteStreamController(e,n,(()=>invokeOrNoop(t,"start",[n])),i,o,r,s)}class SDReadableStreamBYOBReader{constructor(e){if(!isReadableStream(e))throw new TypeError;if(!isReadableByteStreamController(e[readableStreamController_]))throw new TypeError;if(isReadableStreamLocked(e))throw new TypeError("The stream is locked.");readableStreamReaderGenericInitialize(this,e),this[readIntoRequests_]=[]}get closed(){return isReadableStreamBYOBReader(this)?this[closedPromise_].promise:Promise.reject(new TypeError)}cancel(e){if(!isReadableStreamBYOBReader(this))return Promise.reject(new TypeError);const t=this[ownerReadableStream_];return void 0===t?Promise.reject(new TypeError("Reader is not associated with a stream")):readableStreamCancel(t,e)}read(e){return isReadableStreamBYOBReader(this)?void 0===this[ownerReadableStream_]?Promise.reject(new TypeError("Reader is not associated with a stream")):ArrayBuffer.isView(e)?0===e.byteLength?Promise.reject(new TypeError("supplied buffer view must be > 0 bytes")):readableStreamBYOBReaderRead(this,e,!0):Promise.reject(new TypeError("view argument must be a valid ArrayBufferView")):Promise.reject(new TypeError)}releaseLock(){if(!isReadableStreamBYOBReader(this))throw new TypeError;if(void 0===this[ownerReadableStream_])throw new TypeError("Reader is not associated with a stream");if(this[readIntoRequests_].length>0)throw new TypeError;readableStreamReaderGenericRelease(this)}}class SDReadableStream{constructor(e={},t={}){initializeReadableStream(this);const r=t.size,n=t.highWaterMark,i=e.type;if(void 0===i){const t=makeSizeAlgorithmFromSizeFunction(r);setUpReadableStreamDefaultControllerFromUnderlyingSource(this,e,validateAndNormalizeHighWaterMark(void 0===n?1:n),t)}else{if("bytes"!==String(i))throw new RangeError("The underlying source's `type` field must be undefined or 'bytes'");if(void 0!==r)throw new RangeError("bytes streams cannot have a strategy with a `size` field");setUpReadableByteStreamControllerFromUnderlyingSource(this,e,validateAndNormalizeHighWaterMark(void 0===n?0:n))}}get locked(){return isReadableStreamLocked(this)}getReader(e){if(!isReadableStream(this))throw new TypeError;void 0===e&&(e={});const{mode:t}=e;if(void 0===t)return new ReadableStreamDefaultReader(this);if("byob"===String(t))return new SDReadableStreamBYOBReader(this);throw RangeError("mode option must be undefined or `byob`")}cancel(e){return isReadableStream(this)?isReadableStreamLocked(this)?Promise.reject(new TypeError("Cannot cancel a locked stream")):readableStreamCancel(this,e):Promise.reject(new TypeError)}tee(){return readableStreamTee(this,!1)}pipeThrough(e,t={}){const{readable:r,writable:n}=e;if(!isReadableStream(this))throw new TypeError;if(!isWritableStream(n))throw new TypeError("writable must be a WritableStream");if(!isReadableStream(r))throw new TypeError("readable must be a ReadableStream");if(void 0!==t.signal&&!isAbortSignal(t.signal))throw new TypeError("options.signal must be an AbortSignal instance");if(isReadableStreamLocked(this))throw new TypeError("Cannot pipeThrough on a locked stream");if(isWritableStreamLocked(n))throw new TypeError("Cannot pipeThrough to a locked stream");return pipeTo(this,n,t).catch((()=>{})),r}pipeTo(e,t={}){return isReadableStream(this)?isWritableStream(e)?void 0===t.signal||isAbortSignal(t.signal)?isReadableStreamLocked(this)?Promise.reject(new TypeError("Cannot pipe from a locked stream")):isWritableStreamLocked(e)?Promise.reject(new TypeError("Cannot pipe to a locked stream")):pipeTo(this,e,t):Promise.reject(new TypeError("options.signal must be an AbortSignal instance")):Promise.reject(new TypeError("destination must be a WritableStream")):Promise.reject(new TypeError)}}function createReadableStream(e,t,r,n,i){void 0===n&&(n=1),void 0===i&&(i=()=>1);const o=Object.create(SDReadableStream.prototype);return initializeReadableStream(o),setUpReadableStreamDefaultController(o,Object.create(ReadableStreamDefaultController.prototype),e,t,r,n,i),o}function readableStreamTee(e,t){if(!isReadableStream(e))throw new TypeError;const r=new ReadableStreamDefaultReader(e);let n,i,o,s,a,l=!1,u=!1,c=!1;const h=new Promise((e=>a=e)),d=()=>readableStreamDefaultReaderRead(r).then((({value:e,done:r})=>{if(r&&!l&&(u||readableStreamDefaultControllerClose(o[readableStreamController_]),c||readableStreamDefaultControllerClose(s[readableStreamController_]),l=!0),l)return;const n=e;let i=e;u||readableStreamDefaultControllerEnqueue(o[readableStreamController_],n),c||(t&&(i=cloneValue(i)),readableStreamDefaultControllerEnqueue(s[readableStreamController_],i))})),f=()=>{};return o=createReadableStream(f,d,(t=>{if(u=!0,n=t,c){const t=readableStreamCancel(e,[n,i]);a(t)}return h})),s=createReadableStream(f,d,(t=>{if(c=!0,i=t,u){const t=readableStreamCancel(e,[n,i]);a(t)}return h})),r[closedPromise_].promise.catch((e=>{l||(readableStreamDefaultControllerError(o[readableStreamController_],e),readableStreamDefaultControllerError(s[readableStreamController_],e),l=!0)})),[o,s]}class WritableStreamDefaultController{constructor(){throw new TypeError}error(e){if(!isWritableStreamDefaultController(this))throw new TypeError;"writable"===this[controlledWritableStream_][state_]&&writableStreamDefaultControllerError(this,e)}[abortSteps_](e){const t=this[abortAlgorithm_](e);return writableStreamDefaultControllerClearAlgorithms(this),t}[errorSteps_](){resetQueue(this)}}function setUpWritableStreamDefaultControllerFromUnderlyingSink(e,t,r,n){const i=Object.create(WritableStreamDefaultController.prototype),o=createAlgorithmFromUnderlyingMethod(t,"write",[i]),s=createAlgorithmFromUnderlyingMethod(t,"close",[]),a=createAlgorithmFromUnderlyingMethod(t,"abort",[]);setUpWritableStreamDefaultController(e,i,(function(){return invokeOrNoop(t,"start",[i])}),o,s,a,r,n)}class WritableStream{constructor(e={},t={}){initializeWritableStream(this);const r=t.size,n=t.highWaterMark;if(void 0!==e.type)throw new RangeError("The type of an underlying sink must be undefined");const i=makeSizeAlgorithmFromSizeFunction(r);setUpWritableStreamDefaultControllerFromUnderlyingSink(this,e,validateAndNormalizeHighWaterMark(void 0===n?1:n),i)}get locked(){if(!isWritableStream(this))throw new TypeError;return isWritableStreamLocked(this)}abort(e){return isWritableStream(this)?isWritableStreamLocked(this)?Promise.reject(new TypeError("Cannot abort a locked stream")):writableStreamAbort(this,e):Promise.reject(new TypeError)}getWriter(){if(!isWritableStream(this))throw new TypeError;return new WritableStreamDefaultWriter(this)}}function createWritableStream(e,t,r,n,i,o){void 0===i&&(i=1),void 0===o&&(o=()=>1);const s=Object.create(WritableStream.prototype);return initializeWritableStream(s),setUpWritableStreamDefaultController(s,Object.create(WritableStreamDefaultController.prototype),e,t,r,n,i,o),s}const backpressure_$1=Symbol("backpressure_"),backpressureChangePromise_=Symbol("backpressureChangePromise_"),readable_=Symbol("readable_"),transformStreamController_=Symbol("transformStreamController_"),writable_=Symbol("writable_"),controlledTransformStream_=Symbol("controlledTransformStream_"),flushAlgorithm_=Symbol("flushAlgorithm_"),transformAlgorithm_=Symbol("transformAlgorithm_");function isTransformStream(e){return"object"==typeof e&&null!==e&&transformStreamController_ in e}function initializeTransformStream(e,t,r,n,i,o){const s=function(){return t};e[writable_]=createWritableStream(s,(function(t){return transformStreamDefaultSinkWriteAlgorithm(e,t)}),(function(){return transformStreamDefaultSinkCloseAlgorithm(e)}),(function(t){return transformStreamDefaultSinkAbortAlgorithm(e,t)}),r,n),e[readable_]=createReadableStream(s,(function(){return transformStreamDefaultSourcePullAlgorithm(e)}),(function(t){return transformStreamErrorWritableAndUnblockWrite(e,t),Promise.resolve(void 0)}),i,o),e[backpressure_$1]=void 0,e[backpressureChangePromise_]=void 0,transformStreamSetBackpressure(e,!0),e[transformStreamController_]=void 0}function transformStreamError(e,t){readableStreamDefaultControllerError(e[readable_][readableStreamController_],t),transformStreamErrorWritableAndUnblockWrite(e,t)}function transformStreamErrorWritableAndUnblockWrite(e,t){transformStreamDefaultControllerClearAlgorithms(e[transformStreamController_]),writableStreamDefaultControllerErrorIfNeeded(e[writable_][writableStreamController_],t),e[backpressure_$1]&&transformStreamSetBackpressure(e,!1)}function transformStreamSetBackpressure(e,t){void 0!==e[backpressure_$1]&&e[backpressureChangePromise_].resolve(void 0),e[backpressureChangePromise_]=createControlledPromise(),e[backpressure_$1]=t}function isTransformStreamDefaultController(e){return"object"==typeof e&&null!==e&&controlledTransformStream_ in e}function setUpTransformStreamDefaultController(e,t,r,n){t[controlledTransformStream_]=e,e[transformStreamController_]=t,t[transformAlgorithm_]=r,t[flushAlgorithm_]=n}function transformStreamDefaultControllerClearAlgorithms(e){e[transformAlgorithm_]=void 0,e[flushAlgorithm_]=void 0}function transformStreamDefaultControllerEnqueue(e,t){const r=e[controlledTransformStream_],n=r[readable_][readableStreamController_];if(!readableStreamDefaultControllerCanCloseOrEnqueue(n))throw new TypeError;try{readableStreamDefaultControllerEnqueue(n,t)}catch(e){throw transformStreamErrorWritableAndUnblockWrite(r,e),r[readable_][storedError_]}readableStreamDefaultControllerHasBackpressure(n)!==r[backpressure_$1]&&transformStreamSetBackpressure(r,!0)}function transformStreamDefaultControllerError(e,t){transformStreamError(e[controlledTransformStream_],t)}function transformStreamDefaultControllerPerformTransform(e,t){return e[transformAlgorithm_](t).catch((t=>{throw transformStreamError(e[controlledTransformStream_],t),t}))}function transformStreamDefaultControllerTerminate(e){const t=e[controlledTransformStream_],r=t[readable_][readableStreamController_];readableStreamDefaultControllerCanCloseOrEnqueue(r)&&readableStreamDefaultControllerClose(r),transformStreamErrorWritableAndUnblockWrite(t,new TypeError("The transform stream has been terminated"))}function transformStreamDefaultSinkWriteAlgorithm(e,t){const r=e[transformStreamController_];return e[backpressure_$1]?e[backpressureChangePromise_].promise.then((n=>{const i=e[writable_];if("erroring"===i[state_])throw i[storedError_];return transformStreamDefaultControllerPerformTransform(r,t)})):transformStreamDefaultControllerPerformTransform(r,t)}function transformStreamDefaultSinkAbortAlgorithm(e,t){return transformStreamError(e,t),Promise.resolve(void 0)}function transformStreamDefaultSinkCloseAlgorithm(e){const t=e[readable_],r=e[transformStreamController_],n=r[flushAlgorithm_]();return transformStreamDefaultControllerClearAlgorithms(r),n.then((e=>{if("errored"===t[state_])throw t[storedError_];const r=t[readableStreamController_];readableStreamDefaultControllerCanCloseOrEnqueue(r)&&readableStreamDefaultControllerClose(r)}),(r=>{throw transformStreamError(e,r),t[storedError_]}))}function transformStreamDefaultSourcePullAlgorithm(e){return transformStreamSetBackpressure(e,!1),e[backpressureChangePromise_].promise}class TransformStreamDefaultController{constructor(){throw new TypeError}get desiredSize(){if(!isTransformStreamDefaultController(this))throw new TypeError;return readableStreamDefaultControllerGetDesiredSize(this[controlledTransformStream_][readable_][readableStreamController_])}enqueue(e){if(!isTransformStreamDefaultController(this))throw new TypeError;transformStreamDefaultControllerEnqueue(this,e)}error(e){if(!isTransformStreamDefaultController(this))throw new TypeError;transformStreamDefaultControllerError(this,e)}terminate(){if(!isTransformStreamDefaultController(this))throw new TypeError;transformStreamDefaultControllerTerminate(this)}}class TransformStream$1{constructor(e={},t={},r={}){const n=t.size,i=t.highWaterMark,o=r.size,s=r.highWaterMark;if(void 0!==e.writableType)throw new RangeError("The transformer's `writableType` field must be undefined");const a=makeSizeAlgorithmFromSizeFunction(n),l=validateAndNormalizeHighWaterMark(void 0===i?1:i);if(void 0!==e.readableType)throw new RangeError("The transformer's `readableType` field must be undefined");const u=makeSizeAlgorithmFromSizeFunction(o),c=validateAndNormalizeHighWaterMark(void 0===s?0:s),h=createControlledPromise();initializeTransformStream(this,h.promise,l,a,c,u),setUpTransformStreamDefaultControllerFromTransformer(this,e);const d=invokeOrNoop(e,"start",[this[transformStreamController_]]);h.resolve(d)}get readable(){if(!isTransformStream(this))throw new TypeError;return this[readable_]}get writable(){if(!isTransformStream(this))throw new TypeError;return this[writable_]}}function setUpTransformStreamDefaultControllerFromTransformer(e,t){const r=Object.create(TransformStreamDefaultController.prototype);let n;const i=t.transform;if(void 0!==i){if("function"!=typeof i)throw new TypeError("`transform` field of the transformer must be a function");n=e=>promiseCall(i,t,[e,r])}else n=function(e){try{transformStreamDefaultControllerEnqueue(r,e)}catch(e){return Promise.reject(e)}return Promise.resolve(void 0)};const o=createAlgorithmFromUnderlyingMethod(t,"flush",[r]);setUpTransformStreamDefaultController(e,r,n,o)}class ByteLengthQueuingStrategy{constructor(e){this.highWaterMark=e.highWaterMark}size(e){return e.byteLength}}class CountQueuingStrategy{constructor(e){this.highWaterMark=e.highWaterMark}size(){return 1}}function wrapReadableStream(e,t){let r;return new t({start(t){r=e.getReader(),r.closed.catch((e=>{t.error(e)}))},pull:e=>r.read().then((({value:t,done:r})=>{r?e.close():e.enqueue(t)}),(t=>{e.error(t)})),cancel(e){r.cancel(e)}})}function getMIMETypeFromHeadersInit(e){const t="Content-Type";if(void 0===e)return"";if(e instanceof Headers)return e.get(t)||"";if(Array.isArray(e)){const r=e.find((e=>Array.isArray(e)&&2===e.length&&e[0]===t));return r?r[1]:""}return e[t]||""}function resolveRequestInitStream(e,t,r){if(void 0===e)return Promise.resolve(e);const n=e.body;let i;if(n&&"object"==typeof n&&(t&&n instanceof t||n instanceof r)&&(i=n),!i)return Promise.resolve(e);const o=getMIMETypeFromHeadersInit(e.headers);return readAllBytesFromStream(i.getReader(),o).then((t=>(e.body=t,e)))}function createAdaptedFetch(e,t,r,n,i){return function(o,s){return resolveRequestInitStream(s,r,n).then((r=>e.call(void 0,o,r).then((e=>{if("body"in e){const r=e;let o,a;e=new Proxy(r,{get(l,u,c){let h;return"body"===u?(void 0===o&&(o=wrapReadableStream(r.body,n)),h=o):"clone"===u?(void 0===a&&(a=function(){const[r,n]=i(e.body,!0);return o=r,createResponseProxyWithStreamBody(t,i,n,s)}),h=a):h=l[u],"function"==typeof h?function(...e){return h.apply(l,e)}:h}})}else e.body=new n({pull:t=>e.arrayBuffer().then((e=>{t.enqueue(new Uint8Array(e)),t.close()}),(e=>{t.error(e)}))}),e.clone=function(){const[r,n]=i(e.body,!0);return e.body=r,createResponseProxyWithStreamBody(t,i,n,s)};return e}))))}}function readAllBytesFromStream(e,t){return new Promise(((r,n)=>{const i=[];!function o(){e.read().then((({value:e,done:s})=>{s?function(){0===i.length&&i.push(new Uint8Array(0));const e=new Blob(i,{type:t});r(e)}():e instanceof Uint8Array?(i.push(e),o()):n(new TypeError("A ReadableStream body must only yield Uint8Array values"))}),(e=>{n(e)}))}()}))}function createResponseProxyWithStreamBody(e,t,r,n){const i=new e("fake",n),o=getMIMETypeFromHeadersInit(i.headers);let s,a=!1;function l(){return void 0===s&&(s=new Promise(((t,i)=>{if(a=!0,r.locked)return i(new TypeError("The ReadableStream is locked"));readAllBytesFromStream(r.getReader(),o).then((r=>{t(new e(r,n))})).catch((e=>{i(e)}))}))),s}return new class{get type(){return i.type}get url(){return i.url}get redirected(){return i.redirected}get status(){return i.status}get ok(){return i.ok}get statusText(){return i.statusText}get headers(){return i.headers}clone(){const[i,o]=t(r,!0);return r=i,createResponseProxyWithStreamBody(e,t,o,n)}get body(){return r}get bodyUsed(){return a}arrayBuffer(){return l().then((e=>e.arrayBuffer()))}blob(){return l().then((e=>e.blob()))}formData(){return l().then((e=>e.formData()))}json(){return l().then((e=>e.json()))}text(){return l().then((e=>e.text()))}}}function createAdaptedResponse(e,t,r,n){const i=function(i,o){if(i instanceof r){if(void 0===t||!("body"in e))return createResponseProxyWithStreamBody(e,n,i,o);i=wrapReadableStream(i,t)}return new e(i,o)};return i.prototype=e.prototype,i}const decDecoder=Symbol("decDecoder"),decTransform=Symbol("decTransform");class TextDecodeTransformer{constructor(e){this.decoder_=e}transform(e,t){if(!(e instanceof ArrayBuffer||ArrayBuffer.isView(e)))throw new TypeError("Input data must be a BufferSource");const r=this.decoder_.decode(e,{stream:!0});0!==r.length&&t.enqueue(r)}flush(e){const t=this.decoder_.decode();0!==t.length&&e.enqueue(t)}}class TextDecoderStream{constructor(e,t){this[decDecoder]=new TextDecoder(e,t),this[decTransform]=new TransformStream(new TextDecodeTransformer(this[decDecoder]))}get encoding(){return this[decDecoder].encoding}get fatal(){return this[decDecoder].fatal}get ignoreBOM(){return this[decDecoder].ignoreBOM}get readable(){return this[decTransform].readable}get writable(){return this[decTransform].writable}}const encEncoder=Symbol("encEncoder"),encTransform=Symbol("encTransform");class TextEncodeTransformer{constructor(e){this.encoder_=e,this.partial_=void 0}transform(e,t){let r=String(e);void 0!==this.partial_&&(r=this.partial_+r,this.partial_=void 0);const n=r.length-1,i=r.charCodeAt(n);i>=55296&&i<56320&&(this.partial_=String.fromCharCode(i),r=r.substring(0,n));const o=this.encoder_.encode(r);0!==o.length&&t.enqueue(o)}flush(e){this.partial_&&(e.enqueue(this.encoder_.encode(this.partial_)),this.partial_=void 0)}}class TextEncoderStream{constructor(){this[encEncoder]=new TextEncoder,this[encTransform]=new TransformStream(new TextEncodeTransformer(this[encEncoder]))}get encoding(){return this[encEncoder].encoding}get readable(){return this[encTransform].readable}get writable(){return this[encTransform].writable}}const PRESET_DICT=32,Z_DEFLATED=8,GZIP_ID1=31,GZIP_ID2=139,inflate_mask=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],swap32=e=>(e>>>24&255|e>>>8&65280|(65280&e)<<8|(255&e)<<24)>>>0;function u8ArrayFromBufferSource(e){return e instanceof ArrayBuffer?new Uint8Array(e):ArrayBuffer.isView(e)?e instanceof Uint8Array?e:new Uint8Array(e.buffer,e.byteOffset,e.byteLength):void 0}function adler32(e,t=1){const r=u8ArrayFromBufferSource(e);if(!r)throw new TypeError("source must be a BufferSource");return computeAdler32(r,t)}const BASE=65521,NMAX=5552;function computeAdler32(e,t=1){let r=t>>>16&65535;t&=65535;let n=e.length,i=0;for(;n>=NMAX;){n-=NMAX;let o=NMAX/16;do{r+=t+=e[i++],r+=t+=e[i++],r+=t+=e[i++],r+=t+=e[i++],r+=t+=e[i++],r+=t+=e[i++],r+=t+=e[i++],r+=t+=e[i++],r+=t+=e[i++],r+=t+=e[i++],r+=t+=e[i++],r+=t+=e[i++],r+=t+=e[i++],r+=t+=e[i++],r+=t+=e[i++],r+=t+=e[i++]}while(--o);t%=BASE,r+=BASE}if(n){for(;n>=16;)n-=16,r+=t+=e[i++],r+=t+=e[i++],r+=t+=e[i++],r+=t+=e[i++],r+=t+=e[i++],r+=t+=e[i++],r+=t+=e[i++],r+=t+=e[i++],r+=t+=e[i++],r+=t+=e[i++],r+=t+=e[i++],r+=t+=e[i++],r+=t+=e[i++],r+=t+=e[i++],r+=t+=e[i++],r+=t+=e[i++];for(;n--;)r+=t+=e[i++];t%=BASE,r%=BASE}return t|r<<16}function crc32(e,t=0){const r=u8ArrayFromBufferSource(e);if(!r)throw new TypeError("source must be a BufferSource");return computeCRC32(r,t)}const endian=new Uint32Array([1]),endianCheck=new Uint8Array(endian.buffer,0,1)[0],computeCRC32=1===endianCheck?computeCRC32Little:computeCRC32Big;function computeCRC32Little(e,t=0){let r=~t,n=e.byteOffset,i=0,o=e.byteLength;const s=crcTables[0],a=crcTables[1],l=crcTables[2],u=crcTables[3];for(;o&&3&n;)r=s[255&(r^e[i++])]^r>>>8,o--,n++;const c=new Uint32Array(e.buffer,n,o>>>2);let h=0;for(;o>=32;)r^=c[h++],r=u[255&r]^l[r>>>8&255]^a[r>>>16&255]^s[r>>>24],r^=c[h++],r=u[255&r]^l[r>>>8&255]^a[r>>>16&255]^s[r>>>24],r^=c[h++],r=u[255&r]^l[r>>>8&255]^a[r>>>16&255]^s[r>>>24],r^=c[h++],r=u[255&r]^l[r>>>8&255]^a[r>>>16&255]^s[r>>>24],r^=c[h++],r=u[255&r]^l[r>>>8&255]^a[r>>>16&255]^s[r>>>24],r^=c[h++],r=u[255&r]^l[r>>>8&255]^a[r>>>16&255]^s[r>>>24],r^=c[h++],r=u[255&r]^l[r>>>8&255]^a[r>>>16&255]^s[r>>>24],r^=c[h++],r=u[255&r]^l[r>>>8&255]^a[r>>>16&255]^s[r>>>24],o-=32;for(;o>=4;)r^=c[h++],r=u[255&r]^l[r>>>8&255]^a[r>>>16&255]^s[r>>>24],o-=4;if(o){i+=4*h;do{r=s[255&(r^e[i++])]^r>>>8}while(--o)}return r=~r,r}function computeCRC32Big(e,t=0){let r=~swap32(t),n=e.byteOffset,i=0,o=e.byteLength;const s=crcTables[4],a=crcTables[5],l=crcTables[6],u=crcTables[7];for(;o&&3&n;)r=s[r>>>24^e[i++]]^r<<8,o--,n++;const c=new Uint32Array(e.buffer,n,o>>>2);let h=0;for(;o>=32;)r^=c[h++],r=s[255&r]^a[r>>>8&255]^l[r>>>16&255]^u[r>>>24],r^=c[h++],r=s[255&r]^a[r>>>8&255]^l[r>>>16&255]^u[r>>>24],r^=c[h++],r=s[255&r]^a[r>>>8&255]^l[r>>>16&255]^u[r>>>24],r^=c[h++],r=s[255&r]^a[r>>>8&255]^l[r>>>16&255]^u[r>>>24],r^=c[h++],r=s[255&r]^a[r>>>8&255]^l[r>>>16&255]^u[r>>>24],r^=c[h++],r=s[255&r]^a[r>>>8&255]^l[r>>>16&255]^u[r>>>24],r^=c[h++],r=s[255&r]^a[r>>>8&255]^l[r>>>16&255]^u[r>>>24],r^=c[h++],r=s[255&r]^a[r>>>8&255]^l[r>>>16&255]^u[r>>>24],o-=32;for(;o>=4;)r^=c[h++],r=s[255&r]^a[r>>>8&255]^l[r>>>16&255]^u[r>>>24],o-=4;if(o){i+=4*h;do{r=s[r>>>24^e[i++]]^r<<8}while(--o)}return r=~r,swap32(r)}function makeCRCTables(){const e=new ArrayBuffer(8192),t=[new Uint32Array(e,0,256),new Uint32Array(e,1024,256),new Uint32Array(e,2048,256),new Uint32Array(e,3072,256),new Uint32Array(e,4096,256),new Uint32Array(e,5120,256),new Uint32Array(e,6144,256),new Uint32Array(e,7168,256)];for(let e=0;e<256;e++){let r=e;for(let e=0;e<8;e++)r=1&r?3988292384^r>>>1:r>>>1;t[0][e]=r,t[4][e]=swap32(r)}for(let e=0;e<256;e++){let r=t[0][e];for(let n=1;n<4;n++)r=t[0][255&r]^r>>>8,t[n][e]=r,t[n+4][e]=swap32(r)}return t}const crcTables=makeCRCTables(),OUTPUT_BUFSIZE=16384;class ZStream{constructor(){this.avail_in=0,this.next_in_index=0,this.next_out=new Uint8Array(OUTPUT_BUFSIZE),this.avail_out=this.next_out.byteLength,this.next_out_index=0,this.total_in=this.total_out=0,this.msg=""}append(e){this.next_in=e,this.avail_in=e.length,this.next_in_index=0}read_buf(e,t){return this.next_in.subarray(e,e+t)}read_into_buf(e,t,r){let n=this.avail_in;return n>r&&(n=r),0===n?0:(e.set(this.next_in.subarray(this.next_in_index,this.next_in_index+n),t),this.avail_in-=n,this.next_in_index+=n,this.total_in+=n,n)}flush_pending(e){var t=e.pending;t>this.avail_out&&(t=this.avail_out),0!==t&&(this.next_out.set(e.pending_buf.subarray(e.pending_out,e.pending_out+t),this.next_out_index),this.next_out_index+=t,e.pending_out+=t,this.total_out+=t,this.avail_out-=t,e.pending-=t,0===e.pending&&(e.pending_out=0))}}function InfCodes(){let e,t,r,n,i=0,o=0,s=0,a=0,l=0,u=0,c=0,h=0,d=0,f=0;function p(e,t,r,n,i,o,s,a){let l,u,c,h,d,f,p,m,y,g,v,b,w,_,S,E;p=a.next_in_index,m=a.avail_in,d=s.bitb,f=s.bitk,y=s.write,g=y<s.read?s.read-y-1:s.end-y,v=inflate_mask[e],b=inflate_mask[t];do{for(;f<20;)m--,d|=(255&a.next_in[p++])<<f,f+=8;if(l=d&v,u=r,c=n,E=3*(c+l),h=u[E],0!==h)for(;;){if(d>>=u[E+1],f-=u[E+1],0!=(16&h)){for(h&=15,w=u[E+2]+(d&inflate_mask[h]),d>>=h,f-=h;f<15;)m--,d|=(255&a.next_in[p++])<<f,f+=8;for(l=d&b,u=i,c=o,E=3*(c+l),h=u[E];;){if(d>>=u[E+1],f-=u[E+1],0!=(16&h)){for(h&=15;f<h;)m--,d|=(255&a.next_in[p++])<<f,f+=8;if(_=u[E+2]+(d&inflate_mask[h]),d>>=h,f-=h,g-=w,y>=_)S=y-_,s.window[y++]=s.window[S++],s.window[y++]=s.window[S++],w-=2;else{S=y-_;do{S+=s.end}while(S<0);if(h=s.end-S,w>h){w-=h;do{s.window[y++]=s.window[S++]}while(0!=--h);S=0}}do{s.window[y++]=s.window[S++]}while(0!=--w);break}if(0!=(64&h))return a.msg="invalid distance code",w=a.avail_in-m,w=f>>3<w?f>>3:w,m+=w,p-=w,f-=w<<3,s.bitb=d,s.bitk=f,a.avail_in=m,a.total_in+=p-a.next_in_index,a.next_in_index=p,s.write=y,-3;l+=u[E+2],l+=d&inflate_mask[h],E=3*(c+l),h=u[E]}break}if(0!=(64&h))return 0!=(32&h)?(w=a.avail_in-m,w=f>>3<w?f>>3:w,m+=w,p-=w,f-=w<<3,s.bitb=d,s.bitk=f,a.avail_in=m,a.total_in+=p-a.next_in_index,a.next_in_index=p,s.write=y,1):(a.msg="invalid literal/length code",w=a.avail_in-m,w=f>>3<w?f>>3:w,m+=w,p-=w,f-=w<<3,s.bitb=d,s.bitk=f,a.avail_in=m,a.total_in+=p-a.next_in_index,a.next_in_index=p,s.write=y,-3);if(l+=u[E+2],l+=d&inflate_mask[h],E=3*(c+l),h=u[E],0===h){d>>=u[E+1],f-=u[E+1],s.window[y++]=u[E+2],g--;break}}else d>>=u[E+1],f-=u[E+1],s.window[y++]=u[E+2],g--}while(g>=258&&m>=10);return w=a.avail_in-m,w=f>>3<w?f>>3:w,m+=w,p-=w,f-=w<<3,s.bitb=d,s.bitk=f,a.avail_in=m,a.total_in+=p-a.next_in_index,a.next_in_index=p,s.write=y,0}return{init:function(t,i,o,s,a,l){e=0,c=t,h=i,r=o,d=s,n=a,f=l},proc:function(m,y,g){let v,b,w,_,S,E,k,A=0,P=0,x=0;for(x=y.next_in_index,_=y.avail_in,A=m.bitb,P=m.bitk,S=m.write,E=S<m.read?m.read-S-1:m.end-S;;)switch(e){case 0:if(E>=258&&_>=10&&(m.bitb=A,m.bitk=P,y.avail_in=_,y.total_in+=x-y.next_in_index,y.next_in_index=x,m.write=S,g=p(c,h,r,d,n,f,m,y),x=y.next_in_index,_=y.avail_in,A=m.bitb,P=m.bitk,S=m.write,E=S<m.read?m.read-S-1:m.end-S,0!==g)){e=1===g?7:9;break}s=c,t=r,o=d,e=1;case 1:for(v=s;P<v;){if(0===_)return m.bitb=A,m.bitk=P,y.avail_in=_,y.total_in+=x-y.next_in_index,y.next_in_index=x,m.write=S,m.inflate_flush(y,g);g=0,_--,A|=(255&y.next_in[x++])<<P,P+=8}if(b=3*(o+(A&inflate_mask[v])),A>>>=t[b+1],P-=t[b+1],w=t[b],0===w){a=t[b+2],e=6;break}if(0!=(16&w)){l=15&w,i=t[b+2],e=2;break}if(0==(64&w)){s=w,o=b/3+t[b+2];break}if(0!=(32&w)){e=7;break}return e=9,y.msg="invalid literal/length code",g=-3,m.bitb=A,m.bitk=P,y.avail_in=_,y.total_in+=x-y.next_in_index,y.next_in_index=x,m.write=S,m.inflate_flush(y,g);case 2:for(v=l;P<v;){if(0===_)return m.bitb=A,m.bitk=P,y.avail_in=_,y.total_in+=x-y.next_in_index,y.next_in_index=x,m.write=S,m.inflate_flush(y,g);g=0,_--,A|=(255&y.next_in[x++])<<P,P+=8}i+=A&inflate_mask[v],A>>=v,P-=v,s=h,t=n,o=f,e=3;case 3:for(v=s;P<v;){if(0===_)return m.bitb=A,m.bitk=P,y.avail_in=_,y.total_in+=x-y.next_in_index,y.next_in_index=x,m.write=S,m.inflate_flush(y,g);g=0,_--,A|=(255&y.next_in[x++])<<P,P+=8}if(b=3*(o+(A&inflate_mask[v])),A>>=t[b+1],P-=t[b+1],w=t[b],0!=(16&w)){l=15&w,u=t[b+2],e=4;break}if(0==(64&w)){s=w,o=b/3+t[b+2];break}return e=9,y.msg="invalid distance code",g=-3,m.bitb=A,m.bitk=P,y.avail_in=_,y.total_in+=x-y.next_in_index,y.next_in_index=x,m.write=S,m.inflate_flush(y,g);case 4:for(v=l;P<v;){if(0===_)return m.bitb=A,m.bitk=P,y.avail_in=_,y.total_in+=x-y.next_in_index,y.next_in_index=x,m.write=S,m.inflate_flush(y,g);g=0,_--,A|=(255&y.next_in[x++])<<P,P+=8}u+=A&inflate_mask[v],A>>=v,P-=v,e=5;case 5:for(k=S-u;k<0;)k+=m.end;for(;0!==i;){if(0===E&&(S===m.end&&0!==m.read&&(S=0,E=S<m.read?m.read-S-1:m.end-S),0===E&&(m.write=S,g=m.inflate_flush(y,g),S=m.write,E=S<m.read?m.read-S-1:m.end-S,S===m.end&&0!==m.read&&(S=0,E=S<m.read?m.read-S-1:m.end-S),0===E)))return m.bitb=A,m.bitk=P,y.avail_in=_,y.total_in+=x-y.next_in_index,y.next_in_index=x,m.write=S,m.inflate_flush(y,g);m.window[S++]=m.window[k++],E--,k===m.end&&(k=0),i--}e=0;break;case 6:if(0===E&&(S===m.end&&0!==m.read&&(S=0,E=S<m.read?m.read-S-1:m.end-S),0===E&&(m.write=S,g=m.inflate_flush(y,g),S=m.write,E=S<m.read?m.read-S-1:m.end-S,S===m.end&&0!==m.read&&(S=0,E=S<m.read?m.read-S-1:m.end-S),0===E)))return m.bitb=A,m.bitk=P,y.avail_in=_,y.total_in+=x-y.next_in_index,y.next_in_index=x,m.write=S,m.inflate_flush(y,g);g=0,m.window[S++]=a,E--,e=0;break;case 7:if(P>7&&(P-=8,_++,x--),m.write=S,g=m.inflate_flush(y,g),S=m.write,E=S<m.read?m.read-S-1:m.end-S,m.read!==m.write)return m.bitb=A,m.bitk=P,y.avail_in=_,y.total_in+=x-y.next_in_index,y.next_in_index=x,m.write=S,m.inflate_flush(y,g);e=8;case 8:return g=1,m.bitb=A,m.bitk=P,y.avail_in=_,y.total_in+=x-y.next_in_index,y.next_in_index=x,m.write=S,m.inflate_flush(y,g);case 9:return g=-3,m.bitb=A,m.bitk=P,y.avail_in=_,y.total_in+=x-y.next_in_index,y.next_in_index=x,m.write=S,m.inflate_flush(y,g);default:return g=-2,m.bitb=A,m.bitk=P,y.avail_in=_,y.total_in+=x-y.next_in_index,y.next_in_index=x,m.write=S,m.inflate_flush(y,g)}}}}const fixed_bl=9,fixed_bd=5,fixed_tl=[96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,192,80,7,10,0,8,96,0,8,32,0,9,160,0,8,0,0,8,128,0,8,64,0,9,224,80,7,6,0,8,88,0,8,24,0,9,144,83,7,59,0,8,120,0,8,56,0,9,208,81,7,17,0,8,104,0,8,40,0,9,176,0,8,8,0,8,136,0,8,72,0,9,240,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,200,81,7,13,0,8,100,0,8,36,0,9,168,0,8,4,0,8,132,0,8,68,0,9,232,80,7,8,0,8,92,0,8,28,0,9,152,84,7,83,0,8,124,0,8,60,0,9,216,82,7,23,0,8,108,0,8,44,0,9,184,0,8,12,0,8,140,0,8,76,0,9,248,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,196,81,7,11,0,8,98,0,8,34,0,9,164,0,8,2,0,8,130,0,8,66,0,9,228,80,7,7,0,8,90,0,8,26,0,9,148,84,7,67,0,8,122,0,8,58,0,9,212,82,7,19,0,8,106,0,8,42,0,9,180,0,8,10,0,8,138,0,8,74,0,9,244,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,204,81,7,15,0,8,102,0,8,38,0,9,172,0,8,6,0,8,134,0,8,70,0,9,236,80,7,9,0,8,94,0,8,30,0,9,156,84,7,99,0,8,126,0,8,62,0,9,220,82,7,27,0,8,110,0,8,46,0,9,188,0,8,14,0,8,142,0,8,78,0,9,252,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,194,80,7,10,0,8,97,0,8,33,0,9,162,0,8,1,0,8,129,0,8,65,0,9,226,80,7,6,0,8,89,0,8,25,0,9,146,83,7,59,0,8,121,0,8,57,0,9,210,81,7,17,0,8,105,0,8,41,0,9,178,0,8,9,0,8,137,0,8,73,0,9,242,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,202,81,7,13,0,8,101,0,8,37,0,9,170,0,8,5,0,8,133,0,8,69,0,9,234,80,7,8,0,8,93,0,8,29,0,9,154,84,7,83,0,8,125,0,8,61,0,9,218,82,7,23,0,8,109,0,8,45,0,9,186,0,8,13,0,8,141,0,8,77,0,9,250,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,198,81,7,11,0,8,99,0,8,35,0,9,166,0,8,3,0,8,131,0,8,67,0,9,230,80,7,7,0,8,91,0,8,27,0,9,150,84,7,67,0,8,123,0,8,59,0,9,214,82,7,19,0,8,107,0,8,43,0,9,182,0,8,11,0,8,139,0,8,75,0,9,246,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,206,81,7,15,0,8,103,0,8,39,0,9,174,0,8,7,0,8,135,0,8,71,0,9,238,80,7,9,0,8,95,0,8,31,0,9,158,84,7,99,0,8,127,0,8,63,0,9,222,82,7,27,0,8,111,0,8,47,0,9,190,0,8,15,0,8,143,0,8,79,0,9,254,96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,193,80,7,10,0,8,96,0,8,32,0,9,161,0,8,0,0,8,128,0,8,64,0,9,225,80,7,6,0,8,88,0,8,24,0,9,145,83,7,59,0,8,120,0,8,56,0,9,209,81,7,17,0,8,104,0,8,40,0,9,177,0,8,8,0,8,136,0,8,72,0,9,241,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,201,81,7,13,0,8,100,0,8,36,0,9,169,0,8,4,0,8,132,0,8,68,0,9,233,80,7,8,0,8,92,0,8,28,0,9,153,84,7,83,0,8,124,0,8,60,0,9,217,82,7,23,0,8,108,0,8,44,0,9,185,0,8,12,0,8,140,0,8,76,0,9,249,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,197,81,7,11,0,8,98,0,8,34,0,9,165,0,8,2,0,8,130,0,8,66,0,9,229,80,7,7,0,8,90,0,8,26,0,9,149,84,7,67,0,8,122,0,8,58,0,9,213,82,7,19,0,8,106,0,8,42,0,9,181,0,8,10,0,8,138,0,8,74,0,9,245,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,205,81,7,15,0,8,102,0,8,38,0,9,173,0,8,6,0,8,134,0,8,70,0,9,237,80,7,9,0,8,94,0,8,30,0,9,157,84,7,99,0,8,126,0,8,62,0,9,221,82,7,27,0,8,110,0,8,46,0,9,189,0,8,14,0,8,142,0,8,78,0,9,253,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,195,80,7,10,0,8,97,0,8,33,0,9,163,0,8,1,0,8,129,0,8,65,0,9,227,80,7,6,0,8,89,0,8,25,0,9,147,83,7,59,0,8,121,0,8,57,0,9,211,81,7,17,0,8,105,0,8,41,0,9,179,0,8,9,0,8,137,0,8,73,0,9,243,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,203,81,7,13,0,8,101,0,8,37,0,9,171,0,8,5,0,8,133,0,8,69,0,9,235,80,7,8,0,8,93,0,8,29,0,9,155,84,7,83,0,8,125,0,8,61,0,9,219,82,7,23,0,8,109,0,8,45,0,9,187,0,8,13,0,8,141,0,8,77,0,9,251,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,199,81,7,11,0,8,99,0,8,35,0,9,167,0,8,3,0,8,131,0,8,67,0,9,231,80,7,7,0,8,91,0,8,27,0,9,151,84,7,67,0,8,123,0,8,59,0,9,215,82,7,19,0,8,107,0,8,43,0,9,183,0,8,11,0,8,139,0,8,75,0,9,247,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,207,81,7,15,0,8,103,0,8,39,0,9,175,0,8,7,0,8,135,0,8,71,0,9,239,80,7,9,0,8,95,0,8,31,0,9,159,84,7,99,0,8,127,0,8,63,0,9,223,82,7,27,0,8,111,0,8,47,0,9,191,0,8,15,0,8,143,0,8,79,0,9,255],fixed_td=[80,5,1,87,5,257,83,5,17,91,5,4097,81,5,5,89,5,1025,85,5,65,93,5,16385,80,5,3,88,5,513,84,5,33,92,5,8193,82,5,9,90,5,2049,86,5,129,192,5,24577,80,5,2,87,5,385,83,5,25,91,5,6145,81,5,7,89,5,1537,85,5,97,93,5,24577,80,5,4,88,5,769,84,5,49,92,5,12289,82,5,13,90,5,3073,86,5,193,192,5,24577],cplens=[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],cplext=[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,112,112],cpdist=[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],cpdext=[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],BMAX=15;let v;const hn=[0],c=new Int32Array(BMAX+1),r=new Int32Array(3),u=new Int32Array(BMAX),x=new Int32Array(BMAX+1);function huft_build(e,t,n,i,o,s,a,l,h,d,f){let p,m,y,g,v,b,w,_,S,E,k,A,P,C,T;E=0,v=n;do{c[e[t+E]]++,E++,v--}while(0!==v);if(c[0]===n)return a[0]=-1,l[0]=0,0;for(_=l[0],b=1;b<=BMAX&&0===c[b];b++);for(w=b,_<b&&(_=b),v=BMAX;0!==v&&0===c[v];v--);for(y=v,_>v&&(_=v),l[0]=_,C=1<<b;b<v;b++,C<<=1)if(C-=c[b],C<0)return-3;if(C-=c[v],C<0)return-3;for(c[v]+=C,x[1]=b=0,E=1,P=2;0!=--v;)x[P]=b+=c[E],P++,E++;v=0,E=0;do{b=e[t+E],0!==b&&(f[x[b]++]=v),E++}while(++v<n);for(n=x[y],x[0]=v=0,E=0,g=-1,A=-_,u[0]=0,k=0,T=0;w<=y;w++)for(p=c[w];0!=p--;){for(;w>A+_;){if(g++,A+=_,T=y-A,T=T>_?_:T,m=1<<(b=w-A),m>p+1&&(m-=p+1,P=w,b<T))for(;++b<T&&(m<<=1,!(m<=c[++P]));)m-=c[P];if(T=1<<b,d[0]+T>1400)return-3;u[g]=k=d[0],d[0]+=T,0!==g?(x[g]=v,r[0]=b,r[1]=_,b=v>>>A-_,r[2]=k-u[g-1]-b,h.set(r,3*(u[g-1]+b))):a[0]=k}for(r[1]=w-A,E>=n?r[0]=192:f[E]<i?(r[0]=f[E]<256?0:96,r[2]=f[E++]):(r[0]=s[f[E]-i]+16+64,r[2]=o[f[E++]-i]),m=1<<w-A,b=v>>>A;b<T;b+=m)h.set(r,3*(k+b));for(b=1<<w-1;0!=(v&b);b>>>=1)v^=b;for(v^=b,S=(1<<A)-1;(v&S)!==x[g];)g--,A-=_,S=(1<<A)-1}return 0!==C&&1!==y?-5:0}function initWorkArea(e){v=new Int32Array(e);for(let e=0;e<BMAX+1;e++)c[e]=0,u[e]=0,x[e]=0;for(let e=0;e<3;e++)r[e]=0}function inflate_trees_bits(e,t,r,n,i){initWorkArea(19),hn[0]=0;let o=huft_build(e,0,19,19,null,null,r,t,n,hn,v);return-3===o?i.msg="oversubscribed dynamic bit lengths tree":-5!==o&&0!==t[0]||(i.msg="incomplete dynamic bit lengths tree",o=-3),o}function inflate_trees_dynamic(e,t,r,n,i,o,s,a,l){initWorkArea(288),hn[0]=0;let u=huft_build(r,0,e,257,cplens,cplext,o,n,a,hn,v);return 0!==u||0===n[0]?(-3===u?l.msg="oversubscribed literal/length tree":(l.msg="incomplete literal/length tree",u=-3),u):(initWorkArea(288),u=huft_build(r,e,t,0,cpdist,cpdext,s,i,a,hn,v),0!==u||0===i[0]&&e>257?(-3===u?l.msg="oversubscribed distance tree":-5===u?(l.msg="incomplete distance tree",u=-3):(l.msg="empty distance tree with lengths",u=-3),u):0)}function inflate_trees_fixed(e,t,r,n){return e[0]=fixed_bl,t[0]=fixed_bd,r[0]=fixed_tl,n[0]=fixed_td,0}const border=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];class InfBlocks{constructor(e){this.codes=InfCodes(),this.hufts=new Int32Array(4200),this.mode=0,this.bitk=0,this.bitb=0,this.read=0,this.write=0,this.last=0,this.end=e,this.window=new Uint8Array(e)}reset(){this.bitk=0,this.bitb=0,this.read=0,this.write=0,this.last=0}inflate_flush(e,t){let r,n,i;return n=e.next_out_index,i=this.read,r=(i<=this.write?this.write:this.end)-i,r>e.avail_out&&(r=e.avail_out),0!==r&&-5===t&&(t=0),e.avail_out-=r,e.total_out+=r,e.next_out.set(this.window.subarray(i,i+r),n),n+=r,i+=r,i===this.end&&(i=0,this.write===this.end&&(this.write=0),r=this.write-i,r>e.avail_out&&(r=e.avail_out),0!==r&&-5===t&&(t=0),e.avail_out-=r,e.total_out+=r,e.next_out.set(this.window.subarray(i,i+r),n),n+=r,i+=r),e.next_out_index=n,this.read=i,t}proc(e,t){let r,n,i,o,s,a,l,u,c=0,h=0,d=0;const f=new Uint8Array(320),p=[0],m=[0],y=this.codes,g=this.hufts;for(o=e.next_in_index,s=e.avail_in,n=this.bitb,i=this.bitk,a=this.write,l=a<this.read?this.read-a-1:this.end-a;;)switch(this.mode){case 0:if(this.last)return 1;for(;i<3;){if(0===s)return this.bitb=n,this.bitk=i,e.avail_in=s,e.total_in+=o-e.next_in_index,e.next_in_index=o,this.write=a,this.inflate_flush(e,t);t=0,s--,n|=(255&e.next_in[o++])<<i,i+=8}switch(r=7&n,this.last=1&r,r>>>1){case 0:n>>>=3,i-=3,r=7&i,n>>>=r,i-=r,this.mode=1;break;case 1:const l=[0],u=[0],c=[[]],h=[[]];inflate_trees_fixed(l,u,c,h),y.init(l[0],u[0],c[0],0,h[0],0),n>>>=3,i-=3,this.mode=6;break;case 2:n>>>=3,i-=3,this.mode=3;break;case 3:return n>>>=3,i-=3,this.mode=9,e.msg="invalid block type",t=-3,this.bitb=n,this.bitk=i,e.avail_in=s,e.total_in+=o-e.next_in_index,e.next_in_index=o,this.write=a,this.inflate_flush(e,t)}break;case 1:for(;i<32;){if(0===s)return this.bitb=n,this.bitk=i,e.avail_in=s,e.total_in+=o-e.next_in_index,e.next_in_index=o,this.write=a,this.inflate_flush(e,t);t=0,s--,n|=(255&e.next_in[o++])<<i,i+=8}if((~n>>>16&65535)!=(65535&n))return this.mode=9,e.msg="invalid stored block lengths",t=-3,this.bitb=n,this.bitk=i,e.avail_in=s,e.total_in+=o-e.next_in_index,e.next_in_index=o,this.write=a,this.inflate_flush(e,t);c=65535&n,n=i=0,this.mode=0!==c?2:0!==this.last?7:0;break;case 2:if(0===s)return this.bitb=n,this.bitk=i,e.avail_in=s,e.total_in+=o-e.next_in_index,e.next_in_index=o,this.write=a,this.inflate_flush(e,t);if(0===l&&(a===this.end&&0!==this.read&&(a=0,l=a<this.read?this.read-a-1:this.end-a),0===l&&(this.write=a,t=this.inflate_flush(e,t),a=this.write,l=a<this.read?this.read-a-1:this.end-a,a===this.end&&0!==this.read&&(a=0,l=a<this.read?this.read-a-1:this.end-a),0===l)))return this.bitb=n,this.bitk=i,e.avail_in=s,e.total_in+=o-e.next_in_index,e.next_in_index=o,this.write=a,this.inflate_flush(e,t);if(t=0,r=c,r>s&&(r=s),r>l&&(r=l),this.window.set(e.read_buf(o,r),a),o+=r,s-=r,a+=r,l-=r,c-=r,0!==c)break;this.mode=0!==this.last?7:0;break;case 3:for(;i<14;){if(0===s)return this.bitb=n,this.bitk=i,e.avail_in=s,e.total_in+=o-e.next_in_index,e.next_in_index=o,this.write=a,this.inflate_flush(e,t);t=0,s--,n|=(255&e.next_in[o++])<<i,i+=8}if(h=r=16383&n,(31&r)>29||(r>>5&31)>29)return this.mode=9,e.msg="too many length or distance symbols",t=-3,this.bitb=n,this.bitk=i,e.avail_in=s,e.total_in+=o-e.next_in_index,e.next_in_index=o,this.write=a,this.inflate_flush(e,t);for(r=258+(31&r)+(r>>5&31),u=0;u<r;u++)f[u]=0;for(n>>>=14,i-=14,d=0,this.mode=4;d<4+(h>>>10);){for(;i<3;){if(0===s)return this.bitb=n,this.bitk=i,e.avail_in=s,e.total_in+=o-e.next_in_index,e.next_in_index=o,this.write=a,this.inflate_flush(e,t);t=0,s--,n|=(255&e.next_in[o++])<<i,i+=8}f[border[d++]]=7&n,n>>>=3,i-=3}for(;d<19;)f[border[d++]]=0;if(p[0]=7,r=inflate_trees_bits(f,p,m,g,e),0!==r)return-3===(t=r)&&(this.mode=9),this.bitb=n,this.bitk=i,e.avail_in=s,e.total_in+=o-e.next_in_index,e.next_in_index=o,this.write=a,this.inflate_flush(e,t);for(d=0,this.mode=5;r=h,!(d>=258+(31&r)+(r>>5&31));){let l,c;for(r=p[0];i<r;){if(0===s)return this.bitb=n,this.bitk=i,e.avail_in=s,e.total_in+=o-e.next_in_index,e.next_in_index=o,this.write=a,this.inflate_flush(e,t);t=0,s--,n|=(255&e.next_in[o++])<<i,i+=8}if(r=g[3*(m[0]+(n&inflate_mask[r]))+1],c=g[3*(m[0]+(n&inflate_mask[r]))+2],c<16)n>>>=r,i-=r,f[d++]=c;else{for(u=18===c?7:c-14,l=18===c?11:3;i<r+u;){if(0===s)return this.bitb=n,this.bitk=i,e.avail_in=s,e.total_in+=o-e.next_in_index,e.next_in_index=o,this.write=a,this.inflate_flush(e,t);t=0,s--,n|=(255&e.next_in[o++])<<i,i+=8}if(n>>>=r,i-=r,l+=n&inflate_mask[u],n>>>=u,i-=u,u=d,r=h,u+l>258+(31&r)+(r>>5&31)||16===c&&u<1)return this.mode=9,e.msg="invalid bit length repeat",t=-3,this.bitb=n,this.bitk=i,e.avail_in=s,e.total_in+=o-e.next_in_index,e.next_in_index=o,this.write=a,this.inflate_flush(e,t);c=16===c?f[u-1]:0;do{f[u++]=c}while(0!=--l);d=u}}m[0]=-1;const v=[9],b=[6],w=[0],_=[0];if(r=inflate_trees_dynamic(257+(31&r),1+(r>>5&31),f,v,b,w,_,g,e),0!==r)return-3===r&&(this.mode=9),t=r,this.bitb=n,this.bitk=i,e.avail_in=s,e.total_in+=o-e.next_in_index,e.next_in_index=o,this.write=a,this.inflate_flush(e,t);y.init(v[0],b[0],g,w[0],g,_[0]),this.mode=6;case 6:if(this.bitb=n,this.bitk=i,e.avail_in=s,e.total_in+=o-e.next_in_index,e.next_in_index=o,this.write=a,1!==(t=y.proc(this,e,t)))return this.inflate_flush(e,t);if(t=0,o=e.next_in_index,s=e.avail_in,n=this.bitb,i=this.bitk,a=this.write,l=a<this.read?this.read-a-1:this.end-a,0===this.last){this.mode=0;break}this.mode=7;case 7:if(this.write=a,t=this.inflate_flush(e,t),a=this.write,l=a<this.read?this.read-a-1:this.end-a,this.read!==this.write)return this.bitb=n,this.bitk=i,e.avail_in=s,e.total_in+=o-e.next_in_index,e.next_in_index=o,this.write=a,this.inflate_flush(e,t);this.mode=8;case 8:return t=1,this.bitb=n,this.bitk=i,e.avail_in=s,e.total_in+=o-e.next_in_index,e.next_in_index=o,this.write=a,this.inflate_flush(e,t);case 9:return t=-3,this.bitb=n,this.bitk=i,e.avail_in=s,e.total_in+=o-e.next_in_index,e.next_in_index=o,this.write=a,this.inflate_flush(e,t);default:return t=-2,this.bitb=n,this.bitk=i,e.avail_in=s,e.total_in+=o-e.next_in_index,e.next_in_index=o,this.write=a,this.inflate_flush(e,t)}}set_dictionary(e,t,r){this.window.set(e.subarray(t,t+r),0),this.read=this.write=r}}class Inflate{constructor(e){this.isGZip=!1,this.method=0,this.gflags=0,this.name="",this.mtime=0,this.xlen=0,this.dictChecksum=0,this.fullChecksum=0,this.inflatedSize=0,this.wbits=0,this.wbits=15,this.blocks=new InfBlocks(1<<this.wbits),this.mode=e?22:0}get isComplete(){const{blocks:e}=this,t=(0===e.mode||8===e.mode)&&0===e.bitb&&0===e.bitk;return 31===this.mode&&t}get fileName(){return this.name}get modDate(){if(0!==this.mtime)return new Date(1e3*this.mtime)}get checksum(){return this.fullChecksum}get fullSize(){return this.inflatedSize}get containerFormat(){return this.isGZip?2:0===this.method?0:1}inflate(e){let t;if(!e||!e.next_in)return-2;let r=-5;for(;;)switch(this.mode){case 0:if(0===e.avail_in)return r;if(t=e.next_in[e.next_in_index],t!==GZIP_ID1){this.mode=2;break}this.mode=1,r=0,e.avail_in--,e.total_in++,e.next_in_index++;case 1:if(0===e.avail_in)return r;if(r=0,e.avail_in--,e.total_in++,t=e.next_in[e.next_in_index++],t!==GZIP_ID2){this.mode=32,e.msg="invalid gzip id";break}this.isGZip=!0,this.mode=2;case 2:if(0===e.avail_in)return r;if(r=0,e.avail_in--,e.total_in++,this.method=e.next_in[e.next_in_index++],(15&this.method)!==Z_DEFLATED){this.mode=32,e.msg="unknown compression method";break}if(8+(this.method>>4)>this.wbits){this.mode=32,e.msg="invalid window size";break}this.mode=3;case 3:if(0===e.avail_in)return r;if(r=0,e.avail_in--,e.total_in++,t=255&e.next_in[e.next_in_index++],this.isGZip){this.gflags=t,this.mode=9;break}if(((this.method<<8)+t)%31!=0){this.mode=32,e.msg="incorrect header check";break}if(0==(t&PRESET_DICT)){this.mode=22;break}this.mode=4;case 4:if(0===e.avail_in)return r;r=0,e.avail_in--,e.total_in++,this.dictChecksum=(255&e.next_in[e.next_in_index++])<<24&4278190080,this.mode=5;case 5:if(0===e.avail_in)return r;r=0,e.avail_in--,e.total_in++,this.dictChecksum|=(255&e.next_in[e.next_in_index++])<<16&16711680,this.mode=6;case 6:if(0===e.avail_in)return r;r=0,e.avail_in--,e.total_in++,this.dictChecksum|=(255&e.next_in[e.next_in_index++])<<8&65280,this.mode=7;case 7:return 0===e.avail_in?r:(r=0,e.avail_in--,e.total_in++,this.dictChecksum|=255&e.next_in[e.next_in_index++],this.mode=8,2);case 8:return this.mode=32,e.msg="need dictionary",-2;case 9:case 10:case 11:case 12:if(0===e.avail_in)return r;if(r=0,e.avail_in--,e.total_in++,t=255&e.next_in[e.next_in_index++],this.mtime=this.mtime>>>8|t<<24,12!==this.mode){this.mode++;break}this.mode=13;case 13:case 14:case 20:case 21:if(0===e.avail_in)return r;r=0,e.avail_in--,e.total_in++,e.next_in_index++,14===this.mode?4&this.gflags?this.mode=15:8&this.gflags?this.mode=18:16&this.gflags?this.mode=19:2&this.gflags?this.mode=20:this.mode=22:this.mode++;break;case 15:case 16:if(0===e.avail_in)return r;if(r=0,e.avail_in--,e.total_in++,t=255&e.next_in[e.next_in_index++],this.xlen=this.xlen>>>8|t<<24,15===this.mode)break;this.xlen=this.xlen>>>16;case 17:if(0===e.avail_in)return r;r=0,e.avail_in--,e.total_in++,e.next_in_index++,this.xlen--,0===this.xlen&&(8&this.gflags?this.mode=18:16&this.gflags?this.mode=19:2&this.gflags?this.mode=20:this.mode=22);break;case 18:case 19:if(0===e.avail_in)return r;r=0,e.avail_in--,e.total_in++,t=255&e.next_in[e.next_in_index++],0!==t?18===this.mode&&(this.name+=String.fromCharCode(t)):19!==this.mode&&16&this.gflags?this.mode=19:2&this.gflags?this.mode=20:this.mode=22;break;case 22:if(r=this.blocks.proc(e,r),-3===r){this.mode=32;break}if(1!==r)return r;if(r=0,this.blocks.reset(),0===this.method){this.mode=31;break}this.mode=23;case 23:case 24:case 25:case 26:if(0===e.avail_in)return r;r=0,e.avail_in--,e.total_in++,t=255&e.next_in[e.next_in_index++],this.isGZip?this.fullChecksum=this.fullChecksum>>>8|t<<24:this.fullChecksum=this.fullChecksum<<8|t,this.mode++,27!==this.mode||this.isGZip||(this.mode=31);break;case 27:case 28:case 29:case 30:if(0===e.avail_in)return r;r=0,e.avail_in--,e.total_in++,t=255&e.next_in[e.next_in_index++],this.inflatedSize=this.inflatedSize>>>8|t<<24,this.mode++;break;case 31:return 1;case 32:return-3;default:return-2}}inflateSetDictionary(e){if(8!==this.mode)return-2;const t=u8ArrayFromBufferSource(e);if(!t)return-3;let r=0,n=t.byteLength;return n>=1<<this.wbits&&(n=(1<<this.wbits)-1,r=t.byteLength-n),adler32(t)!==this.dictChecksum?-3:(this.blocks.set_dictionary(t,r,n),this.mode=22,0)}}class Inflater{constructor(e){const t=null==e?void 0:e.raw;if(void 0!==t&&!0!==t&&!1!==t)throw new TypeError("options.raw must be undefined or true or false");const r=void 0!==t&&t,n=null==e?void 0:e.dictionary;if(void 0!==n){if(r)throw new RangeError("options.dictionary cannot be set when options.raw is true");if(void 0===u8ArrayFromBufferSource(n))throw new TypeError("options.dictionary must be undefined or a buffer or a buffer view");this.customDict=n}this.inflate=new Inflate(r),this.z=new ZStream}append(e){const t=u8ArrayFromBufferSource(e);if(!(t instanceof Uint8Array))throw new TypeError("data must be an ArrayBuffer or buffer view");if(0===t.length)return[];const{inflate:r,z:n}=this,i=[];let o=!1;n.append(t);do{n.next_out_index=0,n.avail_out=OUTPUT_BUFSIZE,0!==n.avail_in||o||(n.next_in_index=0,o=!0);const e=r.inflate(n);if(o&&-5===e){if(0!==n.avail_in)throw new Error("inflate error: bad input")}else if(2===e){if(!this.customDict)throw new Error("Custom dictionary required for this data");if(0!==r.inflateSetDictionary(this.customDict))throw new Error("Custom dictionary is not valid for this data")}else if(0!==e&&1!==e)throw new Error("inflate error: "+n.msg);if((o||1===e)&&n.avail_in===t.length)throw new Error("inflate error: bad input data");if(n.next_out_index){const e=new Uint8Array(n.next_out.subarray(0,n.next_out_index)),t=2===r.containerFormat;void 0===this.checksum&&(this.checksum=t?0:1),this.checksum=t?crc32(e,this.checksum):adler32(e,this.checksum),i.push(e)}}while(n.avail_in>0||0===n.avail_out);return i}finish(){const e=this.inflate.checksum,t=this.inflate.fullSize,r=this.inflate.isComplete,n=0===e?"unchecked":e===this.checksum?"match":"mismatch",i=0===t?"unchecked":t===this.z.total_out?"match":"mismatch";return{success:r&&"mismatch"!==n&&"mismatch"!==i,complete:r,checksum:n,fileSize:i,fileName:this.inflate.fileName,modDate:this.inflate.modDate}}}const D_CODES=30,BL_CODES=19,LENGTH_CODES=29,LITERALS=256,L_CODES=LITERALS+1+LENGTH_CODES,HEAP_SIZE=2*L_CODES+1,MAX_BL_BITS=7,_dist_code=[0,1,2,3,4,4,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,0,0,16,17,18,18,19,19,20,20,20,20,21,21,21,21,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29];class Tree{constructor(e,t){this.dyn_tree=e,this.stat_desc=t,this.max_code=0}gen_bitlen(e){var t,r,n,i,o,s,a=this.dyn_tree,l=this.stat_desc.static_tree,u=this.stat_desc.extra_bits,c=this.stat_desc.extra_base,h=this.stat_desc.max_length,d=0;for(i=0;i<=15;i++)e.bl_count[i]=0;for(a[2*e.heap[e.heap_max]+1]=0,t=e.heap_max+1;t<HEAP_SIZE;t++)(i=a[2*a[2*(r=e.heap[t])+1]+1]+1)>h&&(i=h,d++),a[2*r+1]=i,r>this.max_code||(e.bl_count[i]++,o=0,r>=c&&(o=u[r-c]),s=a[2*r],e.opt_len+=s*(i+o),l&&(e.static_len+=s*(l[2*r+1]+o)));if(0!==d){do{for(i=h-1;0===e.bl_count[i];)i--;e.bl_count[i]--,e.bl_count[i+1]+=2,e.bl_count[h]--,d-=2}while(d>0);for(i=h;0!==i;i--)for(r=e.bl_count[i];0!==r;)(n=e.heap[--t])>this.max_code||(a[2*n+1]!=i&&(e.opt_len+=(i-a[2*n+1])*a[2*n],a[2*n+1]=i),r--)}}bi_reverse(e,t){let r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1}gen_codes(e,t,r){const n=new Uint16Array(16);let i=0;for(let e=1;e<=15;e++)n[e]=i=i+r[e-1]<<1;for(let r=0;r<=t;r++){const t=e[2*r+1];0!==t&&(e[2*r]=this.bi_reverse(n[t]++,t))}}build_tree(e){var t,r,n,i=this.dyn_tree,o=this.stat_desc.static_tree,s=this.stat_desc.elems,a=-1;for(e.heap_len=0,e.heap_max=HEAP_SIZE,t=0;t<s;t++)0!==i[2*t]?(e.heap[++e.heap_len]=a=t,e.depth[t]=0):i[2*t+1]=0;for(;e.heap_len<2;)i[2*(n=e.heap[++e.heap_len]=a<2?++a:0)]=1,e.depth[n]=0,e.opt_len--,o&&(e.static_len-=o[2*n+1]);for(this.max_code=a,t=Math.floor(e.heap_len/2);t>=1;t--)e.pqdownheap(i,t);n=s;do{t=e.heap[1],e.heap[1]=e.heap[e.heap_len--],e.pqdownheap(i,1),r=e.heap[1],e.heap[--e.heap_max]=t,e.heap[--e.heap_max]=r,i[2*n]=i[2*t]+i[2*r],e.depth[n]=Math.max(e.depth[t],e.depth[r])+1,i[2*t+1]=i[2*r+1]=n,e.heap[1]=n++,e.pqdownheap(i,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],this.gen_bitlen(e),this.gen_codes(i,this.max_code,e.bl_count)}static d_code(e){return e<256?_dist_code[e]:_dist_code[256+(e>>>7)]}}Tree._length_code=[0,1,2,3,4,5,6,7,8,8,9,9,10,10,11,11,12,12,12,12,13,13,13,13,14,14,14,14,15,15,15,15,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28],Tree.base_length=[0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224,0],Tree.base_dist=[0,1,2,3,4,6,8,12,16,24,32,48,64,96,128,192,256,384,512,768,1024,1536,2048,3072,4096,6144,8192,12288,16384,24576],Tree.extra_lbits=[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],Tree.extra_dbits=[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],Tree.extra_blbits=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],Tree.bl_order=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];class StaticTree{constructor(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i}}StaticTree.static_ltree=new Uint16Array([12,8,140,8,76,8,204,8,44,8,172,8,108,8,236,8,28,8,156,8,92,8,220,8,60,8,188,8,124,8,252,8,2,8,130,8,66,8,194,8,34,8,162,8,98,8,226,8,18,8,146,8,82,8,210,8,50,8,178,8,114,8,242,8,10,8,138,8,74,8,202,8,42,8,170,8,106,8,234,8,26,8,154,8,90,8,218,8,58,8,186,8,122,8,250,8,6,8,134,8,70,8,198,8,38,8,166,8,102,8,230,8,22,8,150,8,86,8,214,8,54,8,182,8,118,8,246,8,14,8,142,8,78,8,206,8,46,8,174,8,110,8,238,8,30,8,158,8,94,8,222,8,62,8,190,8,126,8,254,8,1,8,129,8,65,8,193,8,33,8,161,8,97,8,225,8,17,8,145,8,81,8,209,8,49,8,177,8,113,8,241,8,9,8,137,8,73,8,201,8,41,8,169,8,105,8,233,8,25,8,153,8,89,8,217,8,57,8,185,8,121,8,249,8,5,8,133,8,69,8,197,8,37,8,165,8,101,8,229,8,21,8,149,8,85,8,213,8,53,8,181,8,117,8,245,8,13,8,141,8,77,8,205,8,45,8,173,8,109,8,237,8,29,8,157,8,93,8,221,8,61,8,189,8,125,8,253,8,19,9,275,9,147,9,403,9,83,9,339,9,211,9,467,9,51,9,307,9,179,9,435,9,115,9,371,9,243,9,499,9,11,9,267,9,139,9,395,9,75,9,331,9,203,9,459,9,43,9,299,9,171,9,427,9,107,9,363,9,235,9,491,9,27,9,283,9,155,9,411,9,91,9,347,9,219,9,475,9,59,9,315,9,187,9,443,9,123,9,379,9,251,9,507,9,7,9,263,9,135,9,391,9,71,9,327,9,199,9,455,9,39,9,295,9,167,9,423,9,103,9,359,9,231,9,487,9,23,9,279,9,151,9,407,9,87,9,343,9,215,9,471,9,55,9,311,9,183,9,439,9,119,9,375,9,247,9,503,9,15,9,271,9,143,9,399,9,79,9,335,9,207,9,463,9,47,9,303,9,175,9,431,9,111,9,367,9,239,9,495,9,31,9,287,9,159,9,415,9,95,9,351,9,223,9,479,9,63,9,319,9,191,9,447,9,127,9,383,9,255,9,511,9,0,7,64,7,32,7,96,7,16,7,80,7,48,7,112,7,8,7,72,7,40,7,104,7,24,7,88,7,56,7,120,7,4,7,68,7,36,7,100,7,20,7,84,7,52,7,116,7,3,8,131,8,67,8,195,8,35,8,163,8,99,8,227,8]),StaticTree.static_dtree=new Uint16Array([0,5,16,5,8,5,24,5,4,5,20,5,12,5,28,5,2,5,18,5,10,5,26,5,6,5,22,5,14,5,30,5,1,5,17,5,9,5,25,5,5,5,21,5,13,5,29,5,3,5,19,5,11,5,27,5,7,5,23,5]),StaticTree.static_l_desc=new StaticTree(StaticTree.static_ltree,Tree.extra_lbits,LITERALS+1,L_CODES,15),StaticTree.static_d_desc=new StaticTree(StaticTree.static_dtree,Tree.extra_dbits,0,D_CODES,15),StaticTree.static_bl_desc=new StaticTree(null,Tree.extra_blbits,0,BL_CODES,MAX_BL_BITS);const makeConfig=(e,t,r,n,i)=>({good_length:e,max_lazy:t,nice_length:r,max_chain:n,func:i}),config_table=[makeConfig(0,0,0,0,0),makeConfig(4,4,8,4,1),makeConfig(4,5,16,8,1),makeConfig(4,6,32,32,1),makeConfig(4,4,16,16,2),makeConfig(8,16,32,32,2),makeConfig(8,16,128,128,2),makeConfig(8,32,128,256,2),makeConfig(32,128,258,1024,2),makeConfig(32,258,258,4096,2)];function smaller(e,t,r,n){const i=e[2*t],o=e[2*r];return i<o||i==o&&n[t]<=n[r]}const END_BLOCK=256,REP_3_6=16,REPZ_3_10=17,REPZ_11_138=18,STORED_BLOCK=0,STATIC_TREES=1,DYN_TREES=2,MIN_MATCH=3,MAX_MATCH=258,MIN_LOOKAHEAD=MAX_MATCH+MIN_MATCH+1,hash_bits=15,hash_size=1<<hash_bits,hash_mask=hash_size-1,hash_shift=Math.floor((hash_bits+MIN_MATCH-1)/MIN_MATCH),lit_bufsize=16384,pending_buf_size=4*lit_bufsize,d_buf=Math.floor(lit_bufsize/2),l_buf=3*lit_bufsize,window_size=65536;class Deflate{constructor(e,t=6,r=0){if(this.status=1,this.pending_buf=new Uint8Array(pending_buf_size),this.pending=0,this.pending_out=0,this.last_flush=0,this.window=new Uint8Array(window_size),this.prev=new Uint16Array(32768),this.head=new Uint16Array(hash_size),this.ins_h=0,this.block_start=0,this.match_length=MIN_MATCH-1,this.match_available=!1,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=MIN_MATCH-1,this.dyn_ltree=new Uint16Array(2*HEAP_SIZE),this.dyn_dtree=new Uint16Array(2*(2*D_CODES+1)),this.bl_tree=new Uint16Array(2*(2*BL_CODES+1)),this.l_desc=new Tree(this.dyn_ltree,StaticTree.static_l_desc),this.d_desc=new Tree(this.dyn_dtree,StaticTree.static_d_desc),this.bl_desc=new Tree(this.bl_tree,StaticTree.static_bl_desc),this.depth=new Uint16Array(2*L_CODES+1),this.last_lit=0,this.matches=0,this.opt_len=0,this.static_len=0,this.last_eob_len=8,this.bi_buf=0,this.bi_valid=0,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(2*L_CODES+1),this.heap_len=0,this.heap_max=HEAP_SIZE,t<0||t>9||r<0||r>2)throw RangeError("level or strategy is out of range");this.strm=e,this.level=t,this.strategy=r,e.msg="",e.total_in=e.total_out=0,this.init_block();for(let e=0;e<hash_size;++e)this.head[e]=0;this.max_lazy_match=config_table[t].max_lazy,this.good_match=config_table[t].good_length,this.nice_match=config_table[t].nice_length,this.max_chain_length=config_table[t].max_chain}init_block(){for(let e=0;e<L_CODES;e++)this.dyn_ltree[2*e]=0;for(let e=0;e<D_CODES;e++)this.dyn_dtree[2*e]=0;for(let e=0;e<BL_CODES;e++)this.bl_tree[2*e]=0;this.dyn_ltree[2*END_BLOCK]=1,this.opt_len=this.static_len=0,this.last_lit=this.matches=0}pqdownheap(e,t){const r=this.heap,n=r[t];let i=t<<1;for(;i<=this.heap_len&&(i<this.heap_len&&smaller(e,r[i+1],r[i],this.depth)&&i++,!smaller(e,n,r[i],this.depth));)r[t]=r[i],t=i,i<<=1;r[t]=n}scan_tree(e,t){var r,n=-1,i=e[1],o=0,s=7,a=4;0===i&&(s=138,a=3),e[2*(t+1)+1]=65535;for(let l=0;l<=t;l++)r=i,i=e[2*(l+1)+1],++o<s&&r==i||(o<a?this.bl_tree[2*r]+=o:0!==r?(r!=n&&this.bl_tree[2*r]++,this.bl_tree[2*REP_3_6]++):o<=10?this.bl_tree[2*REPZ_3_10]++:this.bl_tree[2*REPZ_11_138]++,o=0,n=r,0===i?(s=138,a=3):r==i?(s=6,a=3):(s=7,a=4))}build_bl_tree(){let e;for(this.scan_tree(this.dyn_ltree,this.l_desc.max_code),this.scan_tree(this.dyn_dtree,this.d_desc.max_code),this.bl_desc.build_tree(this),e=BL_CODES-1;e>=3&&0===this.bl_tree[2*Tree.bl_order[e]+1];e--);return this.opt_len+=3*(e+1)+5+5+4,e}put_short(e){this.pending_buf[this.pending++]=255&e,this.pending_buf[this.pending++]=e>>>8&255}send_bits(e,t){if(this.bi_valid>16-t){this.bi_buf|=e<<this.bi_valid&65535;const r=this.pending;this.pending_buf[r]=this.bi_buf,this.pending_buf[r+1]=this.bi_buf>>>8,this.pending=r+2,this.bi_buf=e>>>16-this.bi_valid,this.bi_valid+=t-16}else this.bi_buf|=e<<this.bi_valid&65535,this.bi_valid+=t}send_code(e,t){const r=2*e;this.send_bits(65535&t[r],65535&t[r+1])}send_tree(e,t){var r,n=-1,i=e[1],o=0,s=7,a=4;0===i&&(s=138,a=3);for(let l=0;l<=t;l++)if(r=i,i=e[2*(l+1)+1],!(++o<s&&r==i)){if(o<a)do{this.send_code(r,this.bl_tree)}while(0!=--o);else 0!==r?(r!=n&&(this.send_code(r,this.bl_tree),o--),this.send_code(REP_3_6,this.bl_tree),this.send_bits(o-3,2)):o<=10?(this.send_code(REPZ_3_10,this.bl_tree),this.send_bits(o-3,3)):(this.send_code(REPZ_11_138,this.bl_tree),this.send_bits(o-11,7));o=0,n=r,0===i?(s=138,a=3):r==i?(s=6,a=3):(s=7,a=4)}}send_all_trees(e,t,r){this.send_bits(e-257,5),this.send_bits(t-1,5),this.send_bits(r-4,4);for(let e=0;e<r;e++)this.send_bits(this.bl_tree[2*Tree.bl_order[e]+1],3);this.send_tree(this.dyn_ltree,e-1),this.send_tree(this.dyn_dtree,t-1)}bi_flush(){16===this.bi_valid?(this.put_short(this.bi_buf),this.bi_buf=0,this.bi_valid=0):this.bi_valid>=8&&(this.pending_buf[this.pending++]=this.bi_buf,this.bi_buf>>>=8,this.bi_valid-=8)}_tr_align(){this.send_bits(STATIC_TREES<<1,3),this.send_code(END_BLOCK,StaticTree.static_ltree),this.bi_flush(),1+this.last_eob_len+10-this.bi_valid<9&&(this.send_bits(STATIC_TREES<<1,3),this.send_code(END_BLOCK,StaticTree.static_ltree),this.bi_flush()),this.last_eob_len=7}_tr_tally(e,t){if(this.pending_buf[d_buf+2*this.last_lit]=e>>>8&255,this.pending_buf[d_buf+2*this.last_lit+1]=255&e,this.pending_buf[l_buf+this.last_lit]=255&t,this.last_lit++,0===e?this.dyn_ltree[2*t]++:(this.matches++,e--,this.dyn_ltree[2*(Tree._length_code[t]+LITERALS+1)]++,this.dyn_dtree[2*Tree.d_code(e)]++),0==(8191&this.last_lit)&&this.level>2){let e=8*this.last_lit,t=this.strstart-this.block_start;for(let t=0;t<D_CODES;t++)e+=this.dyn_dtree[2*t]*(5+Tree.extra_dbits[t]);if(e>>>=3,this.matches<Math.floor(this.last_lit/2)&&e<Math.floor(t/2))return!0}return this.last_lit===lit_bufsize-1}compress_block(e,t){let r=0;if(0!==this.last_lit)do{let n=this.pending_buf[d_buf+2*r]<<8&65280|255&this.pending_buf[d_buf+2*r+1],i=255&this.pending_buf[l_buf+r];if(r++,0===n)this.send_code(i,e);else{let r=Tree._length_code[i];this.send_code(r+LITERALS+1,e);let o=Tree.extra_lbits[r];0!==o&&(i-=Tree.base_length[r],this.send_bits(i,o)),n--,r=Tree.d_code(n),this.send_code(r,t),o=Tree.extra_dbits[r],0!==o&&(n-=Tree.base_dist[r],this.send_bits(n,o))}}while(r<this.last_lit);this.send_code(END_BLOCK,e),this.last_eob_len=e[2*END_BLOCK+1]}bi_windup(){this.bi_valid>8?this.put_short(this.bi_buf):this.bi_valid>0&&(this.pending_buf[this.pending++]=this.bi_buf),this.bi_buf=0,this.bi_valid=0}copy_block(e,t,r){this.bi_windup(),this.last_eob_len=8,r&&(this.put_short(t),this.put_short(~t)),this.pending_buf.set(this.window.subarray(e,e+t),this.pending),this.pending+=t}_tr_stored_block(e,t,r){this.send_bits((STORED_BLOCK<<1)+(r?1:0),3),this.copy_block(e,t,!0)}_tr_flush_block(e,t,r){let n,i,o=0;this.level>0?(this.l_desc.build_tree(this),this.d_desc.build_tree(this),o=this.build_bl_tree(),n=this.opt_len+3+7>>>3,i=this.static_len+3+7>>>3,i<=n&&(n=i)):n=i=t+5,t+4<=n&&-1!==e?this._tr_stored_block(e,t,r):i==n?(this.send_bits((STATIC_TREES<<1)+(r?1:0),3),this.compress_block(StaticTree.static_ltree,StaticTree.static_dtree)):(this.send_bits((DYN_TREES<<1)+(r?1:0),3),this.send_all_trees(this.l_desc.max_code+1,this.d_desc.max_code+1,o+1),this.compress_block(this.dyn_ltree,this.dyn_dtree)),this.init_block(),r&&this.bi_windup()}flush_block_only(e){this._tr_flush_block(this.block_start>=0?this.block_start:-1,this.strstart-this.block_start,e),this.block_start=this.strstart,this.strm.flush_pending(this)}fill_window(){do{let e=window_size-this.lookahead-this.strstart;if(0===e&&0===this.strstart&&0===this.lookahead)e=32768;else if(-1===e)e--;else if(this.strstart>=65536-MIN_LOOKAHEAD){this.window.set(this.window.subarray(32768,65536),0),this.match_start-=32768,this.strstart-=32768,this.block_start-=32768;let t=hash_size,r=t;do{let e=65535&this.head[--r];this.head[r]=e>=32768?e-32768:0}while(0!=--t);t=32768,r=t;do{let e=65535&this.prev[--r];this.prev[r]=e>=32768?e-32768:0}while(0!=--t);e+=32768}if(0===this.strm.avail_in)return;const t=this.strm.read_into_buf(this.window,this.strstart+this.lookahead,e);this.lookahead+=t,this.lookahead>=MIN_MATCH&&(this.ins_h=255&this.window[this.strstart],this.ins_h=(this.ins_h<<hash_shift^255&this.window[this.strstart+1])&hash_mask)}while(this.lookahead<MIN_LOOKAHEAD&&0!==this.strm.avail_in)}deflate_stored(e){let t=65535;for(t>pending_buf_size-5&&(t=pending_buf_size-5);;){if(this.lookahead<=1){if(this.fill_window(),0===this.lookahead&&0===e)return 0;if(0===this.lookahead)break}this.strstart+=this.lookahead,this.lookahead=0;let r=this.block_start+t;if((0===this.strstart||this.strstart>=r)&&(this.lookahead=this.strstart-r,this.strstart=r,this.flush_block_only(!1),0===this.strm.avail_out))return 0;if(this.strstart-this.block_start>=32768-MIN_LOOKAHEAD&&(this.flush_block_only(!1),0===this.strm.avail_out))return 0}return this.flush_block_only(4===e),0===this.strm.avail_out?4===e?2:0:4===e?3:1}longest_match(e){let t=this.max_chain_length,r=this.strstart,n=this.prev_length,i=this.strstart>32768-MIN_LOOKAHEAD?this.strstart-(32768-MIN_LOOKAHEAD):0,o=this.nice_match;const s=this.window,a=this.strstart+MAX_MATCH;let l=s[r+n-1],u=s[r+n];const c=s[r],h=s[r+1];this.prev_length>=this.good_match&&(t>>=2),o>this.lookahead&&(o=this.lookahead);do{let d=e,f=!0;for(;;){if(d=e,s[d+n]!==u||s[d+n-1]!==l){if((e=this.prev[32767&e])>i&&0!=--t)continue;f=!1}break}if(!f)break;if(s[d]!==c||s[d+1]!==h)continue;r+=2,d+=2;do{const e=(s[r]<<24|s[r+1]<<16|s[r+2]<<8|s[r+3])^(s[d]<<24|s[d+1]<<16|s[d+2]<<8|s[d+3]);if(e){const t=Math.clz32(e)>>3;r+=t,d+=t;break}r+=4,d+=4}while(r<a);r>a&&(r=a);let p=MAX_MATCH-(a-r);if(r=a-MAX_MATCH,p>n){if(this.match_start=e,n=p,p>=o)break;l=s[r+n-1],u=s[r+n]}}while((e=this.prev[32767&e])>i&&0!=--t);return n<=this.lookahead?n:this.lookahead}deflate_fast(e){let t,r=0;for(;;){if(this.lookahead<MIN_LOOKAHEAD){if(this.fill_window(),this.lookahead<MIN_LOOKAHEAD&&0===e)return 0;if(0===this.lookahead)break}if(this.lookahead>=MIN_MATCH&&(this.ins_h=(this.ins_h<<hash_shift^255&this.window[this.strstart+(MIN_MATCH-1)])&hash_mask,r=65535&this.head[this.ins_h],this.prev[32767&this.strstart]=this.head[this.ins_h],this.head[this.ins_h]=this.strstart),0!==r&&(this.strstart-r&65535)<=32768-MIN_LOOKAHEAD&&2!==this.strategy&&(this.match_length=this.longest_match(r)),this.match_length>=MIN_MATCH)if(t=this._tr_tally(this.strstart-this.match_start,this.match_length-MIN_MATCH),this.lookahead-=this.match_length,this.match_length<=this.max_lazy_match&&this.lookahead>=MIN_MATCH){this.match_length--;do{this.strstart++,this.ins_h=(this.ins_h<<hash_shift^255&this.window[this.strstart+(MIN_MATCH-1)])&hash_mask,r=65535&this.head[this.ins_h],this.prev[32767&this.strstart]=this.head[this.ins_h],this.head[this.ins_h]=this.strstart}while(0!=--this.match_length);this.strstart++}else this.strstart+=this.match_length,this.match_length=0,this.ins_h=255&this.window[this.strstart],this.ins_h=(this.ins_h<<hash_shift^255&this.window[this.strstart+1])&hash_mask;else t=this._tr_tally(0,255&this.window[this.strstart]),this.lookahead--,this.strstart++;if(t&&(this.flush_block_only(!1),0===this.strm.avail_out))return 0}return this.flush_block_only(4===e),0===this.strm.avail_out?4===e?2:0:4===e?3:1}deflate_slow(e){let t,r,n,i=0;for(;;){if(this.lookahead<MIN_LOOKAHEAD){if(this.fill_window(),this.lookahead<MIN_LOOKAHEAD&&0===e)return 0;if(0===this.lookahead)break}if(this.lookahead>=MIN_MATCH&&(this.ins_h=(this.ins_h<<hash_shift^255&this.window[this.strstart+(MIN_MATCH-1)])&hash_mask,i=65535&this.head[this.ins_h],this.prev[32767&this.strstart]=this.head[this.ins_h],this.head[this.ins_h]=this.strstart),this.prev_length=this.match_length,n=this.match_start,this.match_length=MIN_MATCH-1,0!==i&&this.prev_length<this.max_lazy_match&&(this.strstart-i&65535)<=32768-MIN_LOOKAHEAD&&(2!==this.strategy&&(this.match_length=this.longest_match(i)),this.match_length<=5&&(1===this.strategy||this.match_length===MIN_MATCH&&this.strstart-this.match_start>4096)&&(this.match_length=MIN_MATCH-1)),this.prev_length>=MIN_MATCH&&this.match_length<=this.prev_length){r=this.strstart+this.lookahead-MIN_MATCH,t=this._tr_tally(this.strstart-1-n,this.prev_length-MIN_MATCH),this.lookahead-=this.prev_length-1,this.prev_length-=2;do{++this.strstart<=r&&(this.ins_h=(this.ins_h<<hash_shift^255&this.window[this.strstart+(MIN_MATCH-1)])&hash_mask,i=65535&this.head[this.ins_h],this.prev[32767&this.strstart]=this.head[this.ins_h],this.head[this.ins_h]=this.strstart)}while(0!=--this.prev_length);if(this.match_available=!1,this.match_length=MIN_MATCH-1,this.strstart++,t&&(this.flush_block_only(!1),0===this.strm.avail_out))return 0}else if(this.match_available){if(t=this._tr_tally(0,255&this.window[this.strstart-1]),t&&this.flush_block_only(!1),this.strstart++,this.lookahead--,0===this.strm.avail_out)return 0}else this.match_available=!0,this.strstart++,this.lookahead--}return this.match_available&&(t=this._tr_tally(0,255&this.window[this.strstart-1]),this.match_available=!1),this.flush_block_only(4===e),0===this.strm.avail_out?4===e?2:0:4===e?3:1}deflateSetDictionary(e){const t=e.byteLength;let r,n=t,i=0;if(!e||1!==this.status)return-2;if(n<MIN_MATCH)return 0;for(n>32768-MIN_LOOKAHEAD&&(n=32768-MIN_LOOKAHEAD,i=t-n),this.window.set(e.subarray(i,i+n),0),this.strstart=n,this.block_start=n,this.ins_h=255&this.window[0],this.ins_h=(this.ins_h<<hash_shift^255&this.window[1])&hash_mask,r=0;r<=n-MIN_MATCH;r++)this.ins_h=(this.ins_h<<hash_shift^255&this.window[r+(MIN_MATCH-1)])&hash_mask,this.prev[32767&r]=this.head[this.ins_h],this.head[this.ins_h]=r;return 0}deflate(e){if(e>4||e<0)return-2;const{strm:t}=this;if(!t.next_out||!t.next_in&&0!==t.avail_in||3===this.status&&4!=e)return-2;if(0===t.avail_out)return-5;let r=this.last_flush;if(this.last_flush=e,1===this.status&&(this.status=2),0!==this.pending){if(t.flush_pending(this),0===t.avail_out)return this.last_flush=-1,0}else if(0===t.avail_in&&e<=r&&4!==e)return-5;if(3===this.status&&0!==t.avail_in)return-5;if(0!==t.avail_in||0!==this.lookahead||0!==e&&3!==this.status){let r;switch(config_table[this.level].func){case 0:r=this.deflate_stored(e);break;case 1:r=this.deflate_fast(e);break;default:r=this.deflate_slow(e)}if(2!=r&&3!==r||(this.status=3),0===r||2===r)return 0===t.avail_out&&(this.last_flush=-1),0;if(1===r){if(1===e)this._tr_align();else if(this._tr_stored_block(0,0,!1),3===e)for(let e=0;e<hash_size;e++)this.head[e]=0;if(t.flush_pending(this),0===t.avail_out)return this.last_flush=-1,0}}return 4!==e?0:1}}class Deflater{constructor(e){var t,r;this.checksum=1,this.origSize=0,this.dictChecksum=0;const n=null!==(t=null==e?void 0:e.level)&&void 0!==t?t:6,i=null!==(r=null==e?void 0:e.format)&&void 0!==r?r:"deflate",o=null==e?void 0:e.dictionary,s=null==e?void 0:e.fileName;if("number"!=typeof n||n<1||n>9)throw new RangeError("level must be between 1 and 9, inclusive");if("gzip"!==i&&"raw"!==i&&"deflate"!==i)throw new RangeError("container must be one of `raw`, `deflate`, `gzip`");if(void 0!==s&&"string"!=typeof s)throw new TypeError("fileName must be a string");if(this.fileName=s||"",this.z=new ZStream,this.deflate=new Deflate(this.z,n,0),o){if("deflate"!==i)throw new TypeError("Can only provide a dictionary for `deflate` containers.");const e=u8ArrayFromBufferSource(o);if(!e)throw new TypeError("dictionary must be an ArrayBuffer or buffer view");this.dictChecksum=adler32(e),this.deflate.deflateSetDictionary(e)}this.format=i,"gzip"===this.format&&(this.checksum=0)}buildZlibHeader(){let e=2,t=1;0!==this.dictChecksum&&(e+=4,t=PRESET_DICT);const r=new ArrayBuffer(e),n=new DataView(r);return n.setUint16(0,30720|t),0!==this.dictChecksum&&n.setUint32(2,this.dictChecksum),new Uint8Array(r)}buildGZipHeader(){let e=0,t=[];this.fileName.length>0&&(e|=8,t=Array.from(this.fileName).map((e=>{const t=e.charCodeAt(0);return t>255?95:t})),t.push(0));const r=new ArrayBuffer(10+t.length),n=new DataView(r);n.setUint16(0,GZIP_ID1<<8|GZIP_ID2),n.setUint16(2,Z_DEFLATED<<8|e);const i=Math.floor(Date.now()/1e3);n.setUint32(4,i,!0),n.setUint16(8,255);const o=new Uint8Array(r);return t.length&&o.set(t,10),o}buildTrailer(){const e="gzip"===this.format,t=new ArrayBuffer(e?8:4),r=new DataView(t);return r.setUint32(0,this.checksum,e),e&&r.setUint32(4,this.origSize,!0),new Uint8Array(t)}append(e){const t=[],r=u8ArrayFromBufferSource(e);if(!(r instanceof Uint8Array))throw new TypeError("data must be an ArrayBuffer or buffer view");if(!r.length)return t;"gzip"!==this.format?this.checksum=adler32(r,this.checksum):this.checksum=crc32(r,this.checksum),this.origSize+=r.length;const{deflate:n,z:i}=this;i.next_in_index=0,i.next_in=r,i.avail_in=r.length,1===n.status&&("deflate"===this.format?t.push(this.buildZlibHeader()):"gzip"===this.format&&t.push(this.buildGZipHeader()));do{if(i.next_out_index=0,i.avail_out=OUTPUT_BUFSIZE,0!==n.deflate(0))throw new Error("deflating: "+i.msg);i.next_out_index&&t.push(new Uint8Array(i.next_out.subarray(0,i.next_out_index)))}while(i.avail_in>0||0===i.avail_out);return t}finish(){const e=[],{deflate:t,z:r}=this;if(1===t.status)throw new Error("Cannot call finish before at least 1 call to append");do{r.next_out_index=0,r.avail_out=OUTPUT_BUFSIZE;const n=t.deflate(4);if(1!==n&&0!==n)throw new Error("deflating: "+r.msg);OUTPUT_BUFSIZE-r.avail_out>0&&e.push(new Uint8Array(r.next_out.subarray(0,r.next_out_index)))}while(r.avail_in>0||0===r.avail_out);return"raw"!==this.format&&e.push(this.buildTrailer()),e}}const decContext=Symbol("decContext"),decTransform$1=Symbol("decTransform");class DecompressionTransformer{constructor(e){this.inflater_=e}transform(e,t){if(!(e instanceof ArrayBuffer||ArrayBuffer.isView(e)))throw new TypeError("Input data must be a BufferSource");const r=this.inflater_.append(e);for(const e of r)t.enqueue(e)}flush(e){const t=this.inflater_.finish();if(!t.success){if(!t.complete)throw new Error("Unexpected EOF during decompression");if("mismatch"===t.checksum)throw new Error("Data integrity check failed");if("mismatch"===t.fileSize)throw new Error("Data size check failed");throw new Error("Decompression error")}}}class DecompressionStream{constructor(e){if("deflate"!==e&&"gzip"!==e)throw new TypeError("format must be one of `deflate`, `gzip`");this[decContext]=new Inflater,this[decTransform$1]=new TransformStream(new DecompressionTransformer(this[decContext]))}get readable(){return this[decTransform$1].readable}get writable(){return this[decTransform$1].writable}}const comContext=Symbol("comContext"),comTransform=Symbol("comTransform");class CompressionTransformer{constructor(e){this.deflater_=e}transform(e,t){if(!(e instanceof ArrayBuffer||ArrayBuffer.isView(e)))throw new TypeError("Input data must be a BufferSource");const r=this.deflater_.append(e);for(const e of r)t.enqueue(e)}flush(e){const t=this.deflater_.finish();for(const r of t)e.enqueue(r)}}class CompressionStream{constructor(e){if("deflate"!==e&&"gzip"!==e)throw new TypeError("format must be one of `deflate`, `gzip`");this[comContext]=new Deflater({format:e}),this[comTransform]=new TransformStream(new CompressionTransformer(this[comContext]))}get readable(){return this[comTransform].readable}get writable(){return this[comTransform].writable}}function getGlobal(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==__webpack_require__.g?__webpack_require__.g:void 0}function getGlobalValue(e){const t=getGlobal();let r;return void 0!==t&&(r=t[e]),r}function getGlobalOrContextualValue(name){const global=getGlobal();let value;if(void 0!==global&&(value=global[name]),void 0===value)try{value=eval(name)}catch(e){}return value}function hasCompleteStreamsImplementation(){const e=getGlobalValue("ReadableStream"),t=getGlobalValue("WritableStream"),r=getGlobalValue("TransformStream"),n=getGlobalValue("ByteLengthQueuingStrategy"),i=getGlobalValue("CountQueuingStrategy"),o=e=>"function"==typeof e;if(!(o(e)&&o(t)&&o(r)&&o(n)&&o(i)))return!1;try{const t=new e({type:"bytes"}).getReader({mode:"byob"});if(null==t||"object"!=typeof t)return!1}catch(e){return!1}return!0}function installStardazedStreams(){const e=getGlobal();if(!e)return!1;if(hasCompleteStreamsImplementation())return!1;const t=getGlobalOrContextualValue("fetch"),r=getGlobalOrContextualValue("Response"),n=getGlobalValue("ReadableStream");if(t&&r){const i=createAdaptedFetch(t,r,n,SDReadableStream,readableStreamTee),o=createAdaptedResponse(r,n,SDReadableStream,readableStreamTee);e.fetch=i,e.Response=o}return e.ReadableStream=SDReadableStream,e.WritableStream=WritableStream,e.TransformStream=TransformStream$1,e.ByteLengthQueuingStrategy=ByteLengthQueuingStrategy,e.CountQueuingStrategy=CountQueuingStrategy,!0}function installEncodingStreams(e){const t=getGlobal();if(!t)return;const r=getGlobalValue("TextDecoderStream");(e||"function"!=typeof r)&&(t.TextDecoderStream=TextDecoderStream);const n=getGlobalValue("TextEncoderStream");(e||"function"!=typeof n)&&(t.TextEncoderStream=TextEncoderStream)}function installCompressionStreams(e){const t=getGlobal();if(!t)return;const r=getGlobalValue("CompressionStream");(e||"function"!=typeof r)&&(t.CompressionStream=CompressionStream);const n=getGlobalValue("DecompressionStream");(e||"function"!=typeof n)&&(t.DecompressionStream=DecompressionStream)}const overwritten=installStardazedStreams();installEncodingStreams(overwritten),installCompressionStreams(overwritten)})()},930:(e,t,r)=>{"use strict";e.exports=r(3681)},3681:(e,t,r)=>{"use strict";var n=t;function i(){n.util._configure(),n.Writer._configure(n.BufferWriter),n.Reader._configure(n.BufferReader)}n.build="minimal",n.Writer=r(7768),n.BufferWriter=r(3676),n.Reader=r(5109),n.BufferReader=r(5477),n.util=r(1429),n.rpc=r(5988),n.roots=r(4508),n.configure=i,i()},5109:(e,t,r)=>{"use strict";e.exports=l;var n,i=r(1429),o=i.LongBits,s=i.utf8;function a(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function l(e){this.buf=e,this.pos=0,this.len=e.length}var u,c="undefined"!=typeof Uint8Array?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new l(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new l(e);throw Error("illegal buffer")},h=function(){return i.Buffer?function(e){return(l.create=function(e){return i.Buffer.isBuffer(e)?new n(e):c(e)})(e)}:c};function d(){var e=new o(0,0),t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw a(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw a(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}function f(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}function p(){if(this.pos+8>this.len)throw a(this,8);return new o(f(this.buf,this.pos+=4),f(this.buf,this.pos+=4))}l.create=h(),l.prototype._slice=i.Array.prototype.subarray||i.Array.prototype.slice,l.prototype.uint32=(u=4294967295,function(){if(u=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return u;if(u=(u|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return u;if(u=(u|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return u;if(u=(u|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return u;if(u=(u|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return u;if((this.pos+=5)>this.len)throw this.pos=this.len,a(this,10);return u}),l.prototype.int32=function(){return 0|this.uint32()},l.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(1&e)|0},l.prototype.bool=function(){return 0!==this.uint32()},l.prototype.fixed32=function(){if(this.pos+4>this.len)throw a(this,4);return f(this.buf,this.pos+=4)},l.prototype.sfixed32=function(){if(this.pos+4>this.len)throw a(this,4);return 0|f(this.buf,this.pos+=4)},l.prototype.float=function(){if(this.pos+4>this.len)throw a(this,4);var e=i.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e},l.prototype.double=function(){if(this.pos+8>this.len)throw a(this,4);var e=i.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e},l.prototype.bytes=function(){var e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw a(this,e);return this.pos+=e,Array.isArray(this.buf)?this.buf.slice(t,r):t===r?new this.buf.constructor(0):this._slice.call(this.buf,t,r)},l.prototype.string=function(){var e=this.bytes();return s.read(e,0,e.length)},l.prototype.skip=function(e){if("number"==typeof e){if(this.pos+e>this.len)throw a(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw a(this)}while(128&this.buf[this.pos++]);return this},l.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this},l._configure=function(e){n=e,l.create=h(),n._configure();var t=i.Long?"toLong":"toNumber";i.merge(l.prototype,{int64:function(){return d.call(this)[t](!1)},uint64:function(){return d.call(this)[t](!0)},sint64:function(){return d.call(this).zzDecode()[t](!1)},fixed64:function(){return p.call(this)[t](!0)},sfixed64:function(){return p.call(this)[t](!1)}})}},5477:(e,t,r)=>{"use strict";e.exports=o;var n=r(5109);(o.prototype=Object.create(n.prototype)).constructor=o;var i=r(1429);function o(e){n.call(this,e)}o._configure=function(){i.Buffer&&(o.prototype._slice=i.Buffer.prototype.slice)},o.prototype.string=function(){var e=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+e,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+e,this.len))},o._configure()},4508:e=>{"use strict";e.exports={}},5988:(e,t,r)=>{"use strict";t.Service=r(1365)},1365:(e,t,r)=>{"use strict";e.exports=i;var n=r(1429);function i(e,t,r){if("function"!=typeof e)throw TypeError("rpcImpl must be a function");n.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=Boolean(t),this.responseDelimited=Boolean(r)}(i.prototype=Object.create(n.EventEmitter.prototype)).constructor=i,i.prototype.rpcCall=function e(t,r,i,o,s){if(!o)throw TypeError("request must be specified");var a=this;if(!s)return n.asPromise(e,a,t,r,i,o);if(a.rpcImpl)try{return a.rpcImpl(t,r[a.requestDelimited?"encodeDelimited":"encode"](o).finish(),(function(e,r){if(e)return a.emit("error",e,t),s(e);if(null!==r){if(!(r instanceof i))try{r=i[a.responseDelimited?"decodeDelimited":"decode"](r)}catch(e){return a.emit("error",e,t),s(e)}return a.emit("data",r,t),s(null,r)}a.end(!0)}))}catch(e){return a.emit("error",e,t),void setTimeout((function(){s(e)}),0)}else setTimeout((function(){s(Error("already ended"))}),0)},i.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},9340:(e,t,r)=>{"use strict";e.exports=i;var n=r(1429);function i(e,t){this.lo=e>>>0,this.hi=t>>>0}var o=i.zero=new i(0,0);o.toNumber=function(){return 0},o.zzEncode=o.zzDecode=function(){return this},o.length=function(){return 1};var s=i.zeroHash="\0\0\0\0\0\0\0\0";i.fromNumber=function(e){if(0===e)return o;var t=e<0;t&&(e=-e);var r=e>>>0,n=(e-r)/4294967296>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new i(r,n)},i.from=function(e){if("number"==typeof e)return i.fromNumber(e);if(n.isString(e)){if(!n.Long)return i.fromNumber(parseInt(e,10));e=n.Long.fromString(e)}return e.low||e.high?new i(e.low>>>0,e.high>>>0):o},i.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var t=1+~this.lo>>>0,r=~this.hi>>>0;return t||(r=r+1>>>0),-(t+4294967296*r)}return this.lo+4294967296*this.hi},i.prototype.toLong=function(e){return n.Long?new n.Long(0|this.lo,0|this.hi,Boolean(e)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(e)}};var a=String.prototype.charCodeAt;i.fromHash=function(e){return e===s?o:new i((a.call(e,0)|a.call(e,1)<<8|a.call(e,2)<<16|a.call(e,3)<<24)>>>0,(a.call(e,4)|a.call(e,5)<<8|a.call(e,6)<<16|a.call(e,7)<<24)>>>0)},i.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},i.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this},i.prototype.zzDecode=function(){var e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this},i.prototype.length=function(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}},1429:function(e,t,r){"use strict";var n=t;function i(e,t,r){for(var n=Object.keys(t),i=0;i<n.length;++i)void 0!==e[n[i]]&&r||(e[n[i]]=t[n[i]]);return e}function o(e){function t(e,r){if(!(this instanceof t))return new t(e,r);Object.defineProperty(this,"message",{get:function(){return e}}),Error.captureStackTrace?Error.captureStackTrace(this,t):Object.defineProperty(this,"stack",{value:(new Error).stack||""}),r&&i(this,r)}return t.prototype=Object.create(Error.prototype,{constructor:{value:t,writable:!0,enumerable:!1,configurable:!0},name:{get:()=>e,set:void 0,enumerable:!1,configurable:!0},toString:{value(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),t}n.asPromise=r(4537),n.base64=r(7419),n.EventEmitter=r(9211),n.float=r(945),n.inquire=r(7199),n.utf8=r(4997),n.pool=r(6662),n.LongBits=r(9340),n.isNode=Boolean(void 0!==r.g&&r.g&&r.g.process&&r.g.process.versions&&r.g.process.versions.node),n.global=n.isNode&&r.g||"undefined"!=typeof window&&window||"undefined"!=typeof self&&self||this,n.emptyArray=Object.freeze?Object.freeze([]):[],n.emptyObject=Object.freeze?Object.freeze({}):{},n.isInteger=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},n.isString=function(e){return"string"==typeof e||e instanceof String},n.isObject=function(e){return e&&"object"==typeof e},n.isset=n.isSet=function(e,t){var r=e[t];return!(null==r||!e.hasOwnProperty(t))&&("object"!=typeof r||(Array.isArray(r)?r.length:Object.keys(r).length)>0)},n.Buffer=function(){try{var e=n.inquire("buffer").Buffer;return e.prototype.utf8Write?e:null}catch(e){return null}}(),n._Buffer_from=null,n._Buffer_allocUnsafe=null,n.newBuffer=function(e){return"number"==typeof e?n.Buffer?n._Buffer_allocUnsafe(e):new n.Array(e):n.Buffer?n._Buffer_from(e):"undefined"==typeof Uint8Array?e:new Uint8Array(e)},n.Array="undefined"!=typeof Uint8Array?Uint8Array:Array,n.Long=n.global.dcodeIO&&n.global.dcodeIO.Long||n.global.Long||n.inquire("long"),n.key2Re=/^true|false|0|1$/,n.key32Re=/^-?(?:0|[1-9][0-9]*)$/,n.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,n.longToHash=function(e){return e?n.LongBits.from(e).toHash():n.LongBits.zeroHash},n.longFromHash=function(e,t){var r=n.LongBits.fromHash(e);return n.Long?n.Long.fromBits(r.lo,r.hi,t):r.toNumber(Boolean(t))},n.merge=i,n.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)},n.newError=o,n.ProtocolError=o("ProtocolError"),n.oneOfGetter=function(e){for(var t={},r=0;r<e.length;++r)t[e[r]]=1;return function(){for(var e=Object.keys(this),r=e.length-1;r>-1;--r)if(1===t[e[r]]&&void 0!==this[e[r]]&&null!==this[e[r]])return e[r]}},n.oneOfSetter=function(e){return function(t){for(var r=0;r<e.length;++r)e[r]!==t&&delete this[e[r]]}},n.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},n._configure=function(){var e=n.Buffer;e?(n._Buffer_from=e.from!==Uint8Array.from&&e.from||function(t,r){return new e(t,r)},n._Buffer_allocUnsafe=e.allocUnsafe||function(t){return new e(t)}):n._Buffer_from=n._Buffer_allocUnsafe=null}},7768:(e,t,r)=>{"use strict";e.exports=h;var n,i=r(1429),o=i.LongBits,s=i.base64,a=i.utf8;function l(e,t,r){this.fn=e,this.len=t,this.next=void 0,this.val=r}function u(){}function c(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function h(){this.len=0,this.head=new l(u,0,0),this.tail=this.head,this.states=null}var d=function(){return i.Buffer?function(){return(h.create=function(){return new n})()}:function(){return new h}};function f(e,t,r){t[r]=255&e}function p(e,t){this.len=e,this.next=void 0,this.val=t}function m(e,t,r){for(;e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function y(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}h.create=d(),h.alloc=function(e){return new i.Array(e)},i.Array!==Array&&(h.alloc=i.pool(h.alloc,i.Array.prototype.subarray)),h.prototype._push=function(e,t,r){return this.tail=this.tail.next=new l(e,t,r),this.len+=t,this},p.prototype=Object.create(l.prototype),p.prototype.fn=function(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e},h.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new p((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this},h.prototype.int32=function(e){return e<0?this._push(m,10,o.fromNumber(e)):this.uint32(e)},h.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)},h.prototype.uint64=function(e){var t=o.from(e);return this._push(m,t.length(),t)},h.prototype.int64=h.prototype.uint64,h.prototype.sint64=function(e){var t=o.from(e).zzEncode();return this._push(m,t.length(),t)},h.prototype.bool=function(e){return this._push(f,1,e?1:0)},h.prototype.fixed32=function(e){return this._push(y,4,e>>>0)},h.prototype.sfixed32=h.prototype.fixed32,h.prototype.fixed64=function(e){var t=o.from(e);return this._push(y,4,t.lo)._push(y,4,t.hi)},h.prototype.sfixed64=h.prototype.fixed64,h.prototype.float=function(e){return this._push(i.float.writeFloatLE,4,e)},h.prototype.double=function(e){return this._push(i.float.writeDoubleLE,8,e)};var g=i.Array.prototype.set?function(e,t,r){t.set(e,r)}:function(e,t,r){for(var n=0;n<e.length;++n)t[r+n]=e[n]};h.prototype.bytes=function(e){var t=e.length>>>0;if(!t)return this._push(f,1,0);if(i.isString(e)){var r=h.alloc(t=s.length(e));s.decode(e,r,0),e=r}return this.uint32(t)._push(g,t,e)},h.prototype.string=function(e){var t=a.length(e);return t?this.uint32(t)._push(a.write,t,e):this._push(f,1,0)},h.prototype.fork=function(){return this.states=new c(this),this.head=this.tail=new l(u,0,0),this.len=0,this},h.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new l(u,0,0),this.len=0),this},h.prototype.ldelim=function(){var e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this},h.prototype.finish=function(){for(var e=this.head.next,t=this.constructor.alloc(this.len),r=0;e;)e.fn(e.val,t,r),r+=e.len,e=e.next;return t},h._configure=function(e){n=e,h.create=d(),n._configure()}},3676:(e,t,r)=>{"use strict";e.exports=o;var n=r(7768);(o.prototype=Object.create(n.prototype)).constructor=o;var i=r(1429);function o(){n.call(this)}function s(e,t,r){e.length<40?i.utf8.write(e,t,r):t.utf8Write?t.utf8Write(e,r):t.write(e,r)}o._configure=function(){o.alloc=i._Buffer_allocUnsafe,o.writeBytesBuffer=i.Buffer&&i.Buffer.prototype instanceof Uint8Array&&"set"===i.Buffer.prototype.set.name?function(e,t,r){t.set(e,r)}:function(e,t,r){if(e.copy)e.copy(t,r,0,e.length);else for(var n=0;n<e.length;)t[r++]=e[n++]}},o.prototype.bytes=function(e){i.isString(e)&&(e=i._Buffer_from(e,"base64"));var t=e.length>>>0;return this.uint32(t),t&&this._push(o.writeBytesBuffer,t,e),this},o.prototype.string=function(e){var t=i.Buffer.byteLength(e);return this.uint32(t),t&&this._push(s,t,e),this},o._configure()},6540:(e,t,r)=>{"use strict";r.r(t),r.d(t,{authn:()=>a,ciphertext:()=>l,composite:()=>c,contact:()=>d,fetcher:()=>n,invitation:()=>f,messageApi:()=>i,privateKey:()=>h,publicKey:()=>s,signature:()=>o,xmtpEnvelope:()=>u});var n={};r.r(n),r.d(n,{b64Decode:()=>b,b64Encode:()=>g,fetchReq:()=>_,fetchStreamingRequest:()=>S,renderURLSearchParams:()=>A,replacer:()=>w});var i={};r.r(i),r.d(i,{MessageApi:()=>x,SortDirection:()=>P});var o={};r.r(o),r.d(o,{Signature:()=>ne,Signature_ECDSACompact:()=>oe,Signature_WalletECDSACompact:()=>ae,protobufPackage:()=>re});var s={};r.r(s),r.d(s,{PublicKey:()=>_e,PublicKeyBundle:()=>ke,PublicKey_Secp256k1Uncompressed:()=>Ee,SignedPublicKey:()=>ve,SignedPublicKeyBundle:()=>be,UnsignedPublicKey:()=>pe,UnsignedPublicKey_Secp256k1Uncompressed:()=>ye,protobufPackage:()=>de});var a={};r.r(a),r.d(a,{AuthData:()=>Me,Token:()=>Re,protobufPackage:()=>Te});var l={};r.r(l),r.d(l,{Ciphertext:()=>Ue,Ciphertext_Aes256gcmHkdfsha256:()=>je,protobufPackage:()=>Ke});var u={};r.r(u),r.d(u,{Compression:()=>Ve,ContentTypeId:()=>$e,EncodedContent:()=>Xe,EncodedContent_ParametersEntry:()=>Qe,Message:()=>ut,MessageHeaderV1:()=>rt,MessageHeaderV2:()=>st,MessageV1:()=>it,MessageV2:()=>lt,SignedContent:()=>et,compressionFromJSON:()=>He,compressionToJSON:()=>Je,protobufPackage:()=>Ge});var c={};r.r(c),r.d(c,{Composite:()=>mt,Composite_Part:()=>yt,protobufPackage:()=>pt});var h={};r.r(h),r.d(h,{EncryptedPrivateKeyBundle:()=>Bt,EncryptedPrivateKeyBundleV1:()=>Rt,PrivateKey:()=>wt,PrivateKeyBundle:()=>Tt,PrivateKeyBundleV1:()=>Et,PrivateKeyBundleV2:()=>Ct,PrivateKey_Secp256k1:()=>St,SignedPrivateKey:()=>At,SignedPrivateKey_Secp256k1:()=>xt,protobufPackage:()=>vt});var d={};r.r(d),r.d(d,{ContactBundle:()=>jt,ContactBundleV1:()=>Ut,ContactBundleV2:()=>Ft,protobufPackage:()=>Kt});var f={};r.r(f),r.d(f,{InvitationV1:()=>zt,InvitationV1_Aes256gcmHkdfsha256:()=>Gt,InvitationV1_Context:()=>Vt,InvitationV1_Context_MetadataEntry:()=>Ht,SealedInvitation:()=>Qt,SealedInvitationHeaderV1:()=>$t,SealedInvitationV1:()=>Xt,protobufPackage:()=>qt});var p=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r};const m=new Array(64),y=new Array(123);for(let e=0;e<64;)y[m[e]=e<26?e+65:e<52?e+71:e<62?e-4:e-59|43]=e++;function g(e,t,r){let n=null;const i=[];let o,s=0,a=0;for(;t<r;){const r=e[t++];switch(a){case 0:i[s++]=m[r>>2],o=(3&r)<<4,a=1;break;case 1:i[s++]=m[o|r>>4],o=(15&r)<<2,a=2;break;case 2:i[s++]=m[o|r>>6],i[s++]=m[63&r],a=0}s>8191&&((n||(n=[])).push(String.fromCharCode.apply(String,i)),s=0)}return a&&(i[s++]=m[o],i[s++]=61,1===a&&(i[s++]=61)),n?(s&&n.push(String.fromCharCode.apply(String,i.slice(0,s))),n.join("")):String.fromCharCode.apply(String,i.slice(0,s))}const v="invalid encoding";function b(e){const t=[];let r,n=0,i=0;for(let o=0;o<e.length;){let s=e.charCodeAt(o++);if(61===s&&i>1)break;if(void 0===(s=y[s]))throw Error(v);switch(i){case 0:r=s,i=1;break;case 1:t[n++]=r<<2|(48&s)>>4,r=s,i=2;break;case 2:t[n++]=(15&r)<<4|(60&s)>>2,r=s,i=3;break;case 3:t[n++]=(3&r)<<6|s,i=0}}if(1===i)throw Error(v);return new Uint8Array(t)}function w(e,t){return t&&t.constructor===Uint8Array?g(t,0,t.length):t}function _(e,t){const r=t||{},{pathPrefix:n}=r,i=p(r,["pathPrefix"]);return fetch(n?`${n}${e}`:e,i).then((e=>e.json().then((t=>{if(!e.ok)throw t;return t}))))}function S(e,t,r){return n=this,i=void 0,s=function*(){const n=r||{},{pathPrefix:i}=n,o=p(n,["pathPrefix"]),s=i?`${i}${e}`:e,a=yield fetch(s,o);if(!a.ok){const e=yield a.json(),t=e.error&&e.error.message?e.error.message:"";throw new Error(t)}if(!a.body)throw new Error("response doesnt have a body");var l;yield a.body.pipeThrough(new TextDecoderStream).pipeThrough(new TransformStream({start(e){e.buf="",e.pos=0},transform(e,t){for(void 0===t.buf&&(t.buf=""),void 0===t.pos&&(t.pos=0),t.buf+=e;t.pos<t.buf.length;)if("\n"===t.buf[t.pos]){const e=t.buf.substring(0,t.pos),r=JSON.parse(e);t.enqueue(r.result),t.buf=t.buf.substring(t.pos+1),t.pos=0}else++t.pos}})).pipeTo((l=e=>{t&&t(e)},new WritableStream({write(e){l(e)}})))},new((o=void 0)||(o=Promise))((function(e,t){function r(e){try{l(s.next(e))}catch(e){t(e)}}function a(e){try{l(s.throw(e))}catch(e){t(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o((function(e){e(n)}))).then(r,a)}l((s=s.apply(n,i||[])).next())}));var n,i,o,s}function E(e){return["string","number","boolean"].some((t=>typeof e===t))}function k(e,t=""){return Object.keys(e).reduce(((r,n)=>{const i=e[n],o=t?[t,n].join("."):n,s=Array.isArray(i)&&i.every((e=>E(e)))&&i.length>0,a=E(i)&&!function(e){return!1===e||0===e||""===e}(i);let l={};return function(e){const t="Object"===Object.prototype.toString.call(e).slice(8,-1);if(null===e||!t||!t)return!1;const r=Object.getPrototypeOf(e);return"object"==typeof r&&r.constructor===Object.prototype.constructor}(i)?l=k(i,o):(a||s)&&(l={[o]:i}),Object.assign(Object.assign({},r),l)}),{})}function A(e,t=[]){const r=k(e),n=Object.keys(r).reduce(((e,n)=>{const i=r[n];return t.find((e=>e===n))?e:Array.isArray(i)?[...e,...i.map((e=>[n,e.toString()]))]:e=[...e,[n,i.toString()]]}),[]);return new URLSearchParams(n).toString()}var P;!function(e){e.SORT_DIRECTION_UNSPECIFIED="SORT_DIRECTION_UNSPECIFIED",e.SORT_DIRECTION_ASCENDING="SORT_DIRECTION_ASCENDING",e.SORT_DIRECTION_DESCENDING="SORT_DIRECTION_DESCENDING"}(P||(P={}));class x{static Publish(e,t){return _("/message/v1/publish",Object.assign(Object.assign({},t),{method:"POST",body:JSON.stringify(e,w)}))}static Subscribe(e,t,r){return S("/message/v1/subscribe",t,Object.assign(Object.assign({},r),{method:"POST",body:JSON.stringify(e,w)}))}static Query(e,t){return _("/message/v1/query",Object.assign(Object.assign({},t),{method:"POST",body:JSON.stringify(e,w)}))}}var C=null;try{C=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(e){}function T(e,t,r){this.low=0|e,this.high=0|t,this.unsigned=!!r}function N(e){return!0===(e&&e.__isLong__)}function R(e){var t=Math.clz32(e&-e);return e?31-t:t}T.prototype.__isLong__,Object.defineProperty(T.prototype,"__isLong__",{value:!0}),T.isLong=N;var B={},M={};function I(e,t){var r,n,i;return t?(i=0<=(e>>>=0)&&e<256)&&(n=M[e])?n:(r=D(e,0,!0),i&&(M[e]=r),r):(i=-128<=(e|=0)&&e<128)&&(n=B[e])?n:(r=D(e,e<0?-1:0,!1),i&&(B[e]=r),r)}function O(e,t){if(isNaN(e))return t?G:W;if(t){if(e<0)return G;if(e>=L)return Z}else{if(e<=-q)return X;if(e+1>=q)return $}return e<0?O(-e,t).neg():D(e%j|0,e/j|0,t)}function D(e,t,r){return new T(e,t,r)}T.fromInt=I,T.fromNumber=O,T.fromBits=D;var K=Math.pow;function U(e,t,r){if(0===e.length)throw Error("empty string");if("number"==typeof t?(r=t,t=!1):t=!!t,"NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t?G:W;if((r=r||10)<2||36<r)throw RangeError("radix");var n;if((n=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===n)return U(e.substring(1),t,r).neg();for(var i=O(K(r,8)),o=W,s=0;s<e.length;s+=8){var a=Math.min(8,e.length-s),l=parseInt(e.substring(s,s+a),r);if(a<8){var u=O(K(r,a));o=o.mul(u).add(O(l))}else o=(o=o.mul(i)).add(O(l))}return o.unsigned=t,o}function F(e,t){return"number"==typeof e?O(e,t):"string"==typeof e?U(e,t):D(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}T.fromString=U,T.fromValue=F;var j=4294967296,L=j*j,q=L/2,z=I(1<<24),W=I(0);T.ZERO=W;var G=I(0,!0);T.UZERO=G;var V=I(1);T.ONE=V;var H=I(1,!0);T.UONE=H;var J=I(-1);T.NEG_ONE=J;var $=D(-1,2147483647,!1);T.MAX_VALUE=$;var Z=D(-1,-1,!0);T.MAX_UNSIGNED_VALUE=Z;var X=D(0,-2147483648,!1);T.MIN_VALUE=X;var Q=T.prototype;Q.toInt=function(){return this.unsigned?this.low>>>0:this.low},Q.toNumber=function(){return this.unsigned?(this.high>>>0)*j+(this.low>>>0):this.high*j+(this.low>>>0)},Q.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(X)){var t=O(e),r=this.div(t),n=r.mul(t).sub(this);return r.toString(e)+n.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var i=O(K(e,6),this.unsigned),o=this,s="";;){var a=o.div(i),l=(o.sub(a.mul(i)).toInt()>>>0).toString(e);if((o=a).isZero())return l+s;for(;l.length<6;)l="0"+l;s=""+l+s}},Q.getHighBits=function(){return this.high},Q.getHighBitsUnsigned=function(){return this.high>>>0},Q.getLowBits=function(){return this.low},Q.getLowBitsUnsigned=function(){return this.low>>>0},Q.getNumBitsAbs=function(){if(this.isNegative())return this.eq(X)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&0==(e&1<<t);t--);return 0!=this.high?t+33:t+1},Q.isZero=function(){return 0===this.high&&0===this.low},Q.eqz=Q.isZero,Q.isNegative=function(){return!this.unsigned&&this.high<0},Q.isPositive=function(){return this.unsigned||this.high>=0},Q.isOdd=function(){return 1==(1&this.low)},Q.isEven=function(){return 0==(1&this.low)},Q.equals=function(e){return N(e)||(e=F(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low},Q.eq=Q.equals,Q.notEquals=function(e){return!this.eq(e)},Q.neq=Q.notEquals,Q.ne=Q.notEquals,Q.lessThan=function(e){return this.comp(e)<0},Q.lt=Q.lessThan,Q.lessThanOrEqual=function(e){return this.comp(e)<=0},Q.lte=Q.lessThanOrEqual,Q.le=Q.lessThanOrEqual,Q.greaterThan=function(e){return this.comp(e)>0},Q.gt=Q.greaterThan,Q.greaterThanOrEqual=function(e){return this.comp(e)>=0},Q.gte=Q.greaterThanOrEqual,Q.ge=Q.greaterThanOrEqual,Q.compare=function(e){if(N(e)||(e=F(e)),this.eq(e))return 0;var t=this.isNegative(),r=e.isNegative();return t&&!r?-1:!t&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},Q.comp=Q.compare,Q.negate=function(){return!this.unsigned&&this.eq(X)?X:this.not().add(V)},Q.neg=Q.negate,Q.add=function(e){N(e)||(e=F(e));var t=this.high>>>16,r=65535&this.high,n=this.low>>>16,i=65535&this.low,o=e.high>>>16,s=65535&e.high,a=e.low>>>16,l=0,u=0,c=0,h=0;return c+=(h+=i+(65535&e.low))>>>16,u+=(c+=n+a)>>>16,l+=(u+=r+s)>>>16,l+=t+o,D((c&=65535)<<16|(h&=65535),(l&=65535)<<16|(u&=65535),this.unsigned)},Q.subtract=function(e){return N(e)||(e=F(e)),this.add(e.neg())},Q.sub=Q.subtract,Q.multiply=function(e){if(this.isZero())return this;if(N(e)||(e=F(e)),C)return D(C.mul(this.low,this.high,e.low,e.high),C.get_high(),this.unsigned);if(e.isZero())return this.unsigned?G:W;if(this.eq(X))return e.isOdd()?X:W;if(e.eq(X))return this.isOdd()?X:W;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(z)&&e.lt(z))return O(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,r=65535&this.high,n=this.low>>>16,i=65535&this.low,o=e.high>>>16,s=65535&e.high,a=e.low>>>16,l=65535&e.low,u=0,c=0,h=0,d=0;return h+=(d+=i*l)>>>16,c+=(h+=n*l)>>>16,h&=65535,c+=(h+=i*a)>>>16,u+=(c+=r*l)>>>16,c&=65535,u+=(c+=n*a)>>>16,c&=65535,u+=(c+=i*s)>>>16,u+=t*l+r*a+n*s+i*o,D((h&=65535)<<16|(d&=65535),(u&=65535)<<16|(c&=65535),this.unsigned)},Q.mul=Q.multiply,Q.divide=function(e){if(N(e)||(e=F(e)),e.isZero())throw Error("division by zero");var t,r,n;if(C)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?D((this.unsigned?C.div_u:C.div_s)(this.low,this.high,e.low,e.high),C.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?G:W;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return G;if(e.gt(this.shru(1)))return H;n=G}else{if(this.eq(X))return e.eq(V)||e.eq(J)?X:e.eq(X)?V:(t=this.shr(1).div(e).shl(1)).eq(W)?e.isNegative()?V:J:(r=this.sub(e.mul(t)),n=t.add(r.div(e)));if(e.eq(X))return this.unsigned?G:W;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();n=W}for(r=this;r.gte(e);){t=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));for(var i=Math.ceil(Math.log(t)/Math.LN2),o=i<=48?1:K(2,i-48),s=O(t),a=s.mul(e);a.isNegative()||a.gt(r);)a=(s=O(t-=o,this.unsigned)).mul(e);s.isZero()&&(s=V),n=n.add(s),r=r.sub(a)}return n},Q.div=Q.divide,Q.modulo=function(e){return N(e)||(e=F(e)),C?D((this.unsigned?C.rem_u:C.rem_s)(this.low,this.high,e.low,e.high),C.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},Q.mod=Q.modulo,Q.rem=Q.modulo,Q.not=function(){return D(~this.low,~this.high,this.unsigned)},Q.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},Q.clz=Q.countLeadingZeros,Q.countTrailingZeros=function(){return this.low?R(this.low):R(this.high)+32},Q.ctz=Q.countTrailingZeros,Q.and=function(e){return N(e)||(e=F(e)),D(this.low&e.low,this.high&e.high,this.unsigned)},Q.or=function(e){return N(e)||(e=F(e)),D(this.low|e.low,this.high|e.high,this.unsigned)},Q.xor=function(e){return N(e)||(e=F(e)),D(this.low^e.low,this.high^e.high,this.unsigned)},Q.shiftLeft=function(e){return N(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?D(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):D(0,this.low<<e-32,this.unsigned)},Q.shl=Q.shiftLeft,Q.shiftRight=function(e){return N(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?D(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):D(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},Q.shr=Q.shiftRight,Q.shiftRightUnsigned=function(e){return N(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?D(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):D(32===e?this.high:this.high>>>e-32,0,this.unsigned)},Q.shru=Q.shiftRightUnsigned,Q.shr_u=Q.shiftRightUnsigned,Q.rotateLeft=function(e){var t;return N(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?D(this.high,this.low,this.unsigned):e<32?(t=32-e,D(this.low<<e|this.high>>>t,this.high<<e|this.low>>>t,this.unsigned)):(t=32-(e-=32),D(this.high<<e|this.low>>>t,this.low<<e|this.high>>>t,this.unsigned))},Q.rotl=Q.rotateLeft,Q.rotateRight=function(e){var t;return N(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?D(this.high,this.low,this.unsigned):e<32?(t=32-e,D(this.high<<t|this.low>>>e,this.low<<t|this.high>>>e,this.unsigned)):(t=32-(e-=32),D(this.low<<t|this.high>>>e,this.high<<t|this.low>>>e,this.unsigned))},Q.rotr=Q.rotateRight,Q.toSigned=function(){return this.unsigned?D(this.low,this.high,!1):this},Q.toUnsigned=function(){return this.unsigned?this:D(this.low,this.high,!0)},Q.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},Q.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},Q.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},T.fromBytes=function(e,t,r){return r?T.fromBytesLE(e,t):T.fromBytesBE(e,t)},T.fromBytesLE=function(e,t){return new T(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},T.fromBytesBE=function(e,t){return new T(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)};const Y=T;var ee=r(930),te=r.n(ee);const re="xmtp.message_contents",ne={encode:(e,t=te().Writer.create())=>(void 0!==e.ecdsaCompact&&oe.encode(e.ecdsaCompact,t.uint32(10).fork()).ldelim(),void 0!==e.walletEcdsaCompact&&ae.encode(e.walletEcdsaCompact,t.uint32(18).fork()).ldelim(),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i={ecdsaCompact:void 0,walletEcdsaCompact:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.ecdsaCompact=oe.decode(r,r.uint32());break;case 2:i.walletEcdsaCompact=ae.decode(r,r.uint32());break;default:r.skipType(7&e)}}return i},fromJSON:e=>({ecdsaCompact:he(e.ecdsaCompact)?oe.fromJSON(e.ecdsaCompact):void 0,walletEcdsaCompact:he(e.walletEcdsaCompact)?ae.fromJSON(e.walletEcdsaCompact):void 0}),toJSON(e){const t={};return void 0!==e.ecdsaCompact&&(t.ecdsaCompact=e.ecdsaCompact?oe.toJSON(e.ecdsaCompact):void 0),void 0!==e.walletEcdsaCompact&&(t.walletEcdsaCompact=e.walletEcdsaCompact?ae.toJSON(e.walletEcdsaCompact):void 0),t},fromPartial(e){const t={ecdsaCompact:void 0,walletEcdsaCompact:void 0};return t.ecdsaCompact=void 0!==e.ecdsaCompact&&null!==e.ecdsaCompact?oe.fromPartial(e.ecdsaCompact):void 0,t.walletEcdsaCompact=void 0!==e.walletEcdsaCompact&&null!==e.walletEcdsaCompact?ae.fromPartial(e.walletEcdsaCompact):void 0,t}};function ie(){return{bytes:new Uint8Array,recovery:0}}const oe={encode:(e,t=te().Writer.create())=>(0!==e.bytes.length&&t.uint32(10).bytes(e.bytes),0!==e.recovery&&t.uint32(16).uint32(e.recovery),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i=ie();for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.bytes=r.bytes();break;case 2:i.recovery=r.uint32();break;default:r.skipType(7&e)}}return i},fromJSON:e=>({bytes:he(e.bytes)?ue(e.bytes):new Uint8Array,recovery:he(e.recovery)?Number(e.recovery):0}),toJSON(e){const t={};return void 0!==e.bytes&&(t.bytes=ce(void 0!==e.bytes?e.bytes:new Uint8Array)),void 0!==e.recovery&&(t.recovery=Math.round(e.recovery)),t},fromPartial(e){var t,r;const n=ie();return n.bytes=null!==(t=e.bytes)&&void 0!==t?t:new Uint8Array,n.recovery=null!==(r=e.recovery)&&void 0!==r?r:0,n}};function se(){return{bytes:new Uint8Array,recovery:0}}const ae={encode:(e,t=te().Writer.create())=>(0!==e.bytes.length&&t.uint32(10).bytes(e.bytes),0!==e.recovery&&t.uint32(16).uint32(e.recovery),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i=se();for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.bytes=r.bytes();break;case 2:i.recovery=r.uint32();break;default:r.skipType(7&e)}}return i},fromJSON:e=>({bytes:he(e.bytes)?ue(e.bytes):new Uint8Array,recovery:he(e.recovery)?Number(e.recovery):0}),toJSON(e){const t={};return void 0!==e.bytes&&(t.bytes=ce(void 0!==e.bytes?e.bytes:new Uint8Array)),void 0!==e.recovery&&(t.recovery=Math.round(e.recovery)),t},fromPartial(e){var t,r;const n=se();return n.bytes=null!==(t=e.bytes)&&void 0!==t?t:new Uint8Array,n.recovery=null!==(r=e.recovery)&&void 0!==r?r:0,n}};var le=(()=>{if(void 0!==le)return le;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==r.g)return r.g;throw"Unable to locate global object"})();function ue(e){if(le.Buffer)return Uint8Array.from(le.Buffer.from(e,"base64"));{const t=le.atob(e),r=new Uint8Array(t.length);for(let e=0;e<t.length;++e)r[e]=t.charCodeAt(e);return r}}function ce(e){if(le.Buffer)return le.Buffer.from(e).toString("base64");{const t=[];return e.forEach((e=>{t.push(String.fromCharCode(e))})),le.btoa(t.join(""))}}function he(e){return null!=e}te().util.Long!==Y&&(te().util.Long=Y,te().configure());const de="xmtp.message_contents";function fe(){return{createdNs:Y.UZERO,secp256k1Uncompressed:void 0}}const pe={encode:(e,t=te().Writer.create())=>(e.createdNs.isZero()||t.uint32(8).uint64(e.createdNs),void 0!==e.secp256k1Uncompressed&&ye.encode(e.secp256k1Uncompressed,t.uint32(26).fork()).ldelim(),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i=fe();for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.createdNs=r.uint64();break;case 3:i.secp256k1Uncompressed=ye.decode(r,r.uint32());break;default:r.skipType(7&e)}}return i},fromJSON:e=>({createdNs:Ce(e.createdNs)?Y.fromValue(e.createdNs):Y.UZERO,secp256k1Uncompressed:Ce(e.secp256k1Uncompressed)?ye.fromJSON(e.secp256k1Uncompressed):void 0}),toJSON(e){const t={};return void 0!==e.createdNs&&(t.createdNs=(e.createdNs||Y.UZERO).toString()),void 0!==e.secp256k1Uncompressed&&(t.secp256k1Uncompressed=e.secp256k1Uncompressed?ye.toJSON(e.secp256k1Uncompressed):void 0),t},fromPartial(e){const t=fe();return t.createdNs=void 0!==e.createdNs&&null!==e.createdNs?Y.fromValue(e.createdNs):Y.UZERO,t.secp256k1Uncompressed=void 0!==e.secp256k1Uncompressed&&null!==e.secp256k1Uncompressed?ye.fromPartial(e.secp256k1Uncompressed):void 0,t}};function me(){return{bytes:new Uint8Array}}const ye={encode:(e,t=te().Writer.create())=>(0!==e.bytes.length&&t.uint32(10).bytes(e.bytes),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i=me();for(;r.pos<n;){const e=r.uint32();e>>>3==1?i.bytes=r.bytes():r.skipType(7&e)}return i},fromJSON:e=>({bytes:Ce(e.bytes)?Pe(e.bytes):new Uint8Array}),toJSON(e){const t={};return void 0!==e.bytes&&(t.bytes=xe(void 0!==e.bytes?e.bytes:new Uint8Array)),t},fromPartial(e){var t;const r=me();return r.bytes=null!==(t=e.bytes)&&void 0!==t?t:new Uint8Array,r}};function ge(){return{keyBytes:new Uint8Array,signature:void 0}}const ve={encode:(e,t=te().Writer.create())=>(0!==e.keyBytes.length&&t.uint32(10).bytes(e.keyBytes),void 0!==e.signature&&ne.encode(e.signature,t.uint32(18).fork()).ldelim(),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i=ge();for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.keyBytes=r.bytes();break;case 2:i.signature=ne.decode(r,r.uint32());break;default:r.skipType(7&e)}}return i},fromJSON:e=>({keyBytes:Ce(e.keyBytes)?Pe(e.keyBytes):new Uint8Array,signature:Ce(e.signature)?ne.fromJSON(e.signature):void 0}),toJSON(e){const t={};return void 0!==e.keyBytes&&(t.keyBytes=xe(void 0!==e.keyBytes?e.keyBytes:new Uint8Array)),void 0!==e.signature&&(t.signature=e.signature?ne.toJSON(e.signature):void 0),t},fromPartial(e){var t;const r=ge();return r.keyBytes=null!==(t=e.keyBytes)&&void 0!==t?t:new Uint8Array,r.signature=void 0!==e.signature&&null!==e.signature?ne.fromPartial(e.signature):void 0,r}},be={encode:(e,t=te().Writer.create())=>(void 0!==e.identityKey&&ve.encode(e.identityKey,t.uint32(10).fork()).ldelim(),void 0!==e.preKey&&ve.encode(e.preKey,t.uint32(18).fork()).ldelim(),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i={identityKey:void 0,preKey:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.identityKey=ve.decode(r,r.uint32());break;case 2:i.preKey=ve.decode(r,r.uint32());break;default:r.skipType(7&e)}}return i},fromJSON:e=>({identityKey:Ce(e.identityKey)?ve.fromJSON(e.identityKey):void 0,preKey:Ce(e.preKey)?ve.fromJSON(e.preKey):void 0}),toJSON(e){const t={};return void 0!==e.identityKey&&(t.identityKey=e.identityKey?ve.toJSON(e.identityKey):void 0),void 0!==e.preKey&&(t.preKey=e.preKey?ve.toJSON(e.preKey):void 0),t},fromPartial(e){const t={identityKey:void 0,preKey:void 0};return t.identityKey=void 0!==e.identityKey&&null!==e.identityKey?ve.fromPartial(e.identityKey):void 0,t.preKey=void 0!==e.preKey&&null!==e.preKey?ve.fromPartial(e.preKey):void 0,t}};function we(){return{timestamp:Y.UZERO,signature:void 0,secp256k1Uncompressed:void 0}}const _e={encode:(e,t=te().Writer.create())=>(e.timestamp.isZero()||t.uint32(8).uint64(e.timestamp),void 0!==e.signature&&ne.encode(e.signature,t.uint32(18).fork()).ldelim(),void 0!==e.secp256k1Uncompressed&&Ee.encode(e.secp256k1Uncompressed,t.uint32(26).fork()).ldelim(),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i=we();for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.timestamp=r.uint64();break;case 2:i.signature=ne.decode(r,r.uint32());break;case 3:i.secp256k1Uncompressed=Ee.decode(r,r.uint32());break;default:r.skipType(7&e)}}return i},fromJSON:e=>({timestamp:Ce(e.timestamp)?Y.fromValue(e.timestamp):Y.UZERO,signature:Ce(e.signature)?ne.fromJSON(e.signature):void 0,secp256k1Uncompressed:Ce(e.secp256k1Uncompressed)?Ee.fromJSON(e.secp256k1Uncompressed):void 0}),toJSON(e){const t={};return void 0!==e.timestamp&&(t.timestamp=(e.timestamp||Y.UZERO).toString()),void 0!==e.signature&&(t.signature=e.signature?ne.toJSON(e.signature):void 0),void 0!==e.secp256k1Uncompressed&&(t.secp256k1Uncompressed=e.secp256k1Uncompressed?Ee.toJSON(e.secp256k1Uncompressed):void 0),t},fromPartial(e){const t=we();return t.timestamp=void 0!==e.timestamp&&null!==e.timestamp?Y.fromValue(e.timestamp):Y.UZERO,t.signature=void 0!==e.signature&&null!==e.signature?ne.fromPartial(e.signature):void 0,t.secp256k1Uncompressed=void 0!==e.secp256k1Uncompressed&&null!==e.secp256k1Uncompressed?Ee.fromPartial(e.secp256k1Uncompressed):void 0,t}};function Se(){return{bytes:new Uint8Array}}const Ee={encode:(e,t=te().Writer.create())=>(0!==e.bytes.length&&t.uint32(10).bytes(e.bytes),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i=Se();for(;r.pos<n;){const e=r.uint32();e>>>3==1?i.bytes=r.bytes():r.skipType(7&e)}return i},fromJSON:e=>({bytes:Ce(e.bytes)?Pe(e.bytes):new Uint8Array}),toJSON(e){const t={};return void 0!==e.bytes&&(t.bytes=xe(void 0!==e.bytes?e.bytes:new Uint8Array)),t},fromPartial(e){var t;const r=Se();return r.bytes=null!==(t=e.bytes)&&void 0!==t?t:new Uint8Array,r}},ke={encode:(e,t=te().Writer.create())=>(void 0!==e.identityKey&&_e.encode(e.identityKey,t.uint32(10).fork()).ldelim(),void 0!==e.preKey&&_e.encode(e.preKey,t.uint32(18).fork()).ldelim(),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i={identityKey:void 0,preKey:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.identityKey=_e.decode(r,r.uint32());break;case 2:i.preKey=_e.decode(r,r.uint32());break;default:r.skipType(7&e)}}return i},fromJSON:e=>({identityKey:Ce(e.identityKey)?_e.fromJSON(e.identityKey):void 0,preKey:Ce(e.preKey)?_e.fromJSON(e.preKey):void 0}),toJSON(e){const t={};return void 0!==e.identityKey&&(t.identityKey=e.identityKey?_e.toJSON(e.identityKey):void 0),void 0!==e.preKey&&(t.preKey=e.preKey?_e.toJSON(e.preKey):void 0),t},fromPartial(e){const t={identityKey:void 0,preKey:void 0};return t.identityKey=void 0!==e.identityKey&&null!==e.identityKey?_e.fromPartial(e.identityKey):void 0,t.preKey=void 0!==e.preKey&&null!==e.preKey?_e.fromPartial(e.preKey):void 0,t}};var Ae=(()=>{if(void 0!==Ae)return Ae;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==r.g)return r.g;throw"Unable to locate global object"})();function Pe(e){if(Ae.Buffer)return Uint8Array.from(Ae.Buffer.from(e,"base64"));{const t=Ae.atob(e),r=new Uint8Array(t.length);for(let e=0;e<t.length;++e)r[e]=t.charCodeAt(e);return r}}function xe(e){if(Ae.Buffer)return Ae.Buffer.from(e).toString("base64");{const t=[];return e.forEach((e=>{t.push(String.fromCharCode(e))})),Ae.btoa(t.join(""))}}function Ce(e){return null!=e}te().util.Long!==Y&&(te().util.Long=Y,te().configure());const Te="xmtp.message_api.v1";function Ne(){return{identityKey:void 0,authDataBytes:new Uint8Array,authDataSignature:void 0}}const Re={encode:(e,t=te().Writer.create())=>(void 0!==e.identityKey&&_e.encode(e.identityKey,t.uint32(10).fork()).ldelim(),0!==e.authDataBytes.length&&t.uint32(18).bytes(e.authDataBytes),void 0!==e.authDataSignature&&ne.encode(e.authDataSignature,t.uint32(26).fork()).ldelim(),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i=Ne();for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.identityKey=_e.decode(r,r.uint32());break;case 2:i.authDataBytes=r.bytes();break;case 3:i.authDataSignature=ne.decode(r,r.uint32());break;default:r.skipType(7&e)}}return i},fromJSON:e=>({identityKey:De(e.identityKey)?_e.fromJSON(e.identityKey):void 0,authDataBytes:De(e.authDataBytes)?Oe(e.authDataBytes):new Uint8Array,authDataSignature:De(e.authDataSignature)?ne.fromJSON(e.authDataSignature):void 0}),toJSON(e){const t={};return void 0!==e.identityKey&&(t.identityKey=e.identityKey?_e.toJSON(e.identityKey):void 0),void 0!==e.authDataBytes&&(t.authDataBytes=function(e){if(Ie.Buffer)return Ie.Buffer.from(e).toString("base64");{const t=[];return e.forEach((e=>{t.push(String.fromCharCode(e))})),Ie.btoa(t.join(""))}}(void 0!==e.authDataBytes?e.authDataBytes:new Uint8Array)),void 0!==e.authDataSignature&&(t.authDataSignature=e.authDataSignature?ne.toJSON(e.authDataSignature):void 0),t},fromPartial(e){var t;const r=Ne();return r.identityKey=void 0!==e.identityKey&&null!==e.identityKey?_e.fromPartial(e.identityKey):void 0,r.authDataBytes=null!==(t=e.authDataBytes)&&void 0!==t?t:new Uint8Array,r.authDataSignature=void 0!==e.authDataSignature&&null!==e.authDataSignature?ne.fromPartial(e.authDataSignature):void 0,r}};function Be(){return{walletAddr:"",createdNs:Y.UZERO}}const Me={encode:(e,t=te().Writer.create())=>(""!==e.walletAddr&&t.uint32(10).string(e.walletAddr),e.createdNs.isZero()||t.uint32(16).uint64(e.createdNs),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i=Be();for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.walletAddr=r.string();break;case 2:i.createdNs=r.uint64();break;default:r.skipType(7&e)}}return i},fromJSON:e=>({walletAddr:De(e.walletAddr)?String(e.walletAddr):"",createdNs:De(e.createdNs)?Y.fromValue(e.createdNs):Y.UZERO}),toJSON(e){const t={};return void 0!==e.walletAddr&&(t.walletAddr=e.walletAddr),void 0!==e.createdNs&&(t.createdNs=(e.createdNs||Y.UZERO).toString()),t},fromPartial(e){var t;const r=Be();return r.walletAddr=null!==(t=e.walletAddr)&&void 0!==t?t:"",r.createdNs=void 0!==e.createdNs&&null!==e.createdNs?Y.fromValue(e.createdNs):Y.UZERO,r}};var Ie=(()=>{if(void 0!==Ie)return Ie;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==r.g)return r.g;throw"Unable to locate global object"})();function Oe(e){if(Ie.Buffer)return Uint8Array.from(Ie.Buffer.from(e,"base64"));{const t=Ie.atob(e),r=new Uint8Array(t.length);for(let e=0;e<t.length;++e)r[e]=t.charCodeAt(e);return r}}function De(e){return null!=e}te().util.Long!==Y&&(te().util.Long=Y,te().configure());const Ke="xmtp.message_contents",Ue={encode:(e,t=te().Writer.create())=>(void 0!==e.aes256GcmHkdfSha256&&je.encode(e.aes256GcmHkdfSha256,t.uint32(10).fork()).ldelim(),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i={aes256GcmHkdfSha256:void 0};for(;r.pos<n;){const e=r.uint32();e>>>3==1?i.aes256GcmHkdfSha256=je.decode(r,r.uint32()):r.skipType(7&e)}return i},fromJSON:e=>({aes256GcmHkdfSha256:We(e.aes256GcmHkdfSha256)?je.fromJSON(e.aes256GcmHkdfSha256):void 0}),toJSON(e){const t={};return void 0!==e.aes256GcmHkdfSha256&&(t.aes256GcmHkdfSha256=e.aes256GcmHkdfSha256?je.toJSON(e.aes256GcmHkdfSha256):void 0),t},fromPartial(e){const t={aes256GcmHkdfSha256:void 0};return t.aes256GcmHkdfSha256=void 0!==e.aes256GcmHkdfSha256&&null!==e.aes256GcmHkdfSha256?je.fromPartial(e.aes256GcmHkdfSha256):void 0,t}};function Fe(){return{hkdfSalt:new Uint8Array,gcmNonce:new Uint8Array,payload:new Uint8Array}}const je={encode:(e,t=te().Writer.create())=>(0!==e.hkdfSalt.length&&t.uint32(10).bytes(e.hkdfSalt),0!==e.gcmNonce.length&&t.uint32(18).bytes(e.gcmNonce),0!==e.payload.length&&t.uint32(26).bytes(e.payload),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i=Fe();for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.hkdfSalt=r.bytes();break;case 2:i.gcmNonce=r.bytes();break;case 3:i.payload=r.bytes();break;default:r.skipType(7&e)}}return i},fromJSON:e=>({hkdfSalt:We(e.hkdfSalt)?qe(e.hkdfSalt):new Uint8Array,gcmNonce:We(e.gcmNonce)?qe(e.gcmNonce):new Uint8Array,payload:We(e.payload)?qe(e.payload):new Uint8Array}),toJSON(e){const t={};return void 0!==e.hkdfSalt&&(t.hkdfSalt=ze(void 0!==e.hkdfSalt?e.hkdfSalt:new Uint8Array)),void 0!==e.gcmNonce&&(t.gcmNonce=ze(void 0!==e.gcmNonce?e.gcmNonce:new Uint8Array)),void 0!==e.payload&&(t.payload=ze(void 0!==e.payload?e.payload:new Uint8Array)),t},fromPartial(e){var t,r,n;const i=Fe();return i.hkdfSalt=null!==(t=e.hkdfSalt)&&void 0!==t?t:new Uint8Array,i.gcmNonce=null!==(r=e.gcmNonce)&&void 0!==r?r:new Uint8Array,i.payload=null!==(n=e.payload)&&void 0!==n?n:new Uint8Array,i}};var Le=(()=>{if(void 0!==Le)return Le;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==r.g)return r.g;throw"Unable to locate global object"})();function qe(e){if(Le.Buffer)return Uint8Array.from(Le.Buffer.from(e,"base64"));{const t=Le.atob(e),r=new Uint8Array(t.length);for(let e=0;e<t.length;++e)r[e]=t.charCodeAt(e);return r}}function ze(e){if(Le.Buffer)return Le.Buffer.from(e).toString("base64");{const t=[];return e.forEach((e=>{t.push(String.fromCharCode(e))})),Le.btoa(t.join(""))}}function We(e){return null!=e}te().util.Long!==Y&&(te().util.Long=Y,te().configure());const Ge="xmtp.message_contents";var Ve;function He(e){switch(e){case 0:case"COMPRESSION_DEFLATE":return Ve.COMPRESSION_DEFLATE;case 1:case"COMPRESSION_GZIP":return Ve.COMPRESSION_GZIP;default:return Ve.UNRECOGNIZED}}function Je(e){switch(e){case Ve.COMPRESSION_DEFLATE:return"COMPRESSION_DEFLATE";case Ve.COMPRESSION_GZIP:return"COMPRESSION_GZIP";case Ve.UNRECOGNIZED:default:return"UNRECOGNIZED"}}!function(e){e[e.COMPRESSION_DEFLATE=0]="COMPRESSION_DEFLATE",e[e.COMPRESSION_GZIP=1]="COMPRESSION_GZIP",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Ve||(Ve={}));const $e={encode:(e,t=te().Writer.create())=>(""!==e.authorityId&&t.uint32(10).string(e.authorityId),""!==e.typeId&&t.uint32(18).string(e.typeId),0!==e.versionMajor&&t.uint32(24).uint32(e.versionMajor),0!==e.versionMinor&&t.uint32(32).uint32(e.versionMinor),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i={authorityId:"",typeId:"",versionMajor:0,versionMinor:0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.authorityId=r.string();break;case 2:i.typeId=r.string();break;case 3:i.versionMajor=r.uint32();break;case 4:i.versionMinor=r.uint32();break;default:r.skipType(7&e)}}return i},fromJSON:e=>({authorityId:ft(e.authorityId)?String(e.authorityId):"",typeId:ft(e.typeId)?String(e.typeId):"",versionMajor:ft(e.versionMajor)?Number(e.versionMajor):0,versionMinor:ft(e.versionMinor)?Number(e.versionMinor):0}),toJSON(e){const t={};return void 0!==e.authorityId&&(t.authorityId=e.authorityId),void 0!==e.typeId&&(t.typeId=e.typeId),void 0!==e.versionMajor&&(t.versionMajor=Math.round(e.versionMajor)),void 0!==e.versionMinor&&(t.versionMinor=Math.round(e.versionMinor)),t},fromPartial(e){var t,r,n,i;const o={authorityId:"",typeId:"",versionMajor:0,versionMinor:0};return o.authorityId=null!==(t=e.authorityId)&&void 0!==t?t:"",o.typeId=null!==(r=e.typeId)&&void 0!==r?r:"",o.versionMajor=null!==(n=e.versionMajor)&&void 0!==n?n:0,o.versionMinor=null!==(i=e.versionMinor)&&void 0!==i?i:0,o}};function Ze(){return{type:void 0,parameters:{},fallback:void 0,compression:void 0,content:new Uint8Array}}const Xe={encode:(e,t=te().Writer.create())=>(void 0!==e.type&&$e.encode(e.type,t.uint32(10).fork()).ldelim(),Object.entries(e.parameters).forEach((([e,r])=>{Qe.encode({key:e,value:r},t.uint32(18).fork()).ldelim()})),void 0!==e.fallback&&t.uint32(26).string(e.fallback),void 0!==e.compression&&t.uint32(40).int32(e.compression),0!==e.content.length&&t.uint32(34).bytes(e.content),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i=Ze();for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.type=$e.decode(r,r.uint32());break;case 2:const t=Qe.decode(r,r.uint32());void 0!==t.value&&(i.parameters[t.key]=t.value);break;case 3:i.fallback=r.string();break;case 5:i.compression=r.int32();break;case 4:i.content=r.bytes();break;default:r.skipType(7&e)}}return i},fromJSON(e){return{type:ft(e.type)?$e.fromJSON(e.type):void 0,parameters:(t=e.parameters,"object"==typeof t&&null!==t?Object.entries(e.parameters).reduce(((e,[t,r])=>(e[t]=String(r),e)),{}):{}),fallback:ft(e.fallback)?String(e.fallback):void 0,compression:ft(e.compression)?He(e.compression):void 0,content:ft(e.content)?ht(e.content):new Uint8Array};var t},toJSON(e){const t={};return void 0!==e.type&&(t.type=e.type?$e.toJSON(e.type):void 0),t.parameters={},e.parameters&&Object.entries(e.parameters).forEach((([e,r])=>{t.parameters[e]=r})),void 0!==e.fallback&&(t.fallback=e.fallback),void 0!==e.compression&&(t.compression=void 0!==e.compression?Je(e.compression):void 0),void 0!==e.content&&(t.content=dt(void 0!==e.content?e.content:new Uint8Array)),t},fromPartial(e){var t,r,n,i;const o=Ze();return o.type=void 0!==e.type&&null!==e.type?$e.fromPartial(e.type):void 0,o.parameters=Object.entries(null!==(t=e.parameters)&&void 0!==t?t:{}).reduce(((e,[t,r])=>(void 0!==r&&(e[t]=String(r)),e)),{}),o.fallback=null!==(r=e.fallback)&&void 0!==r?r:void 0,o.compression=null!==(n=e.compression)&&void 0!==n?n:void 0,o.content=null!==(i=e.content)&&void 0!==i?i:new Uint8Array,o}},Qe={encode:(e,t=te().Writer.create())=>(""!==e.key&&t.uint32(10).string(e.key),""!==e.value&&t.uint32(18).string(e.value),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i={key:"",value:""};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.key=r.string();break;case 2:i.value=r.string();break;default:r.skipType(7&e)}}return i},fromJSON:e=>({key:ft(e.key)?String(e.key):"",value:ft(e.value)?String(e.value):""}),toJSON(e){const t={};return void 0!==e.key&&(t.key=e.key),void 0!==e.value&&(t.value=e.value),t},fromPartial(e){var t,r;const n={key:"",value:""};return n.key=null!==(t=e.key)&&void 0!==t?t:"",n.value=null!==(r=e.value)&&void 0!==r?r:"",n}};function Ye(){return{payload:new Uint8Array,sender:void 0,signature:void 0}}const et={encode:(e,t=te().Writer.create())=>(0!==e.payload.length&&t.uint32(10).bytes(e.payload),void 0!==e.sender&&be.encode(e.sender,t.uint32(18).fork()).ldelim(),void 0!==e.signature&&ne.encode(e.signature,t.uint32(26).fork()).ldelim(),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i=Ye();for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.payload=r.bytes();break;case 2:i.sender=be.decode(r,r.uint32());break;case 3:i.signature=ne.decode(r,r.uint32());break;default:r.skipType(7&e)}}return i},fromJSON:e=>({payload:ft(e.payload)?ht(e.payload):new Uint8Array,sender:ft(e.sender)?be.fromJSON(e.sender):void 0,signature:ft(e.signature)?ne.fromJSON(e.signature):void 0}),toJSON(e){const t={};return void 0!==e.payload&&(t.payload=dt(void 0!==e.payload?e.payload:new Uint8Array)),void 0!==e.sender&&(t.sender=e.sender?be.toJSON(e.sender):void 0),void 0!==e.signature&&(t.signature=e.signature?ne.toJSON(e.signature):void 0),t},fromPartial(e){var t;const r=Ye();return r.payload=null!==(t=e.payload)&&void 0!==t?t:new Uint8Array,r.sender=void 0!==e.sender&&null!==e.sender?be.fromPartial(e.sender):void 0,r.signature=void 0!==e.signature&&null!==e.signature?ne.fromPartial(e.signature):void 0,r}};function tt(){return{sender:void 0,recipient:void 0,timestamp:Y.UZERO}}const rt={encode:(e,t=te().Writer.create())=>(void 0!==e.sender&&ke.encode(e.sender,t.uint32(10).fork()).ldelim(),void 0!==e.recipient&&ke.encode(e.recipient,t.uint32(18).fork()).ldelim(),e.timestamp.isZero()||t.uint32(24).uint64(e.timestamp),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i=tt();for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.sender=ke.decode(r,r.uint32());break;case 2:i.recipient=ke.decode(r,r.uint32());break;case 3:i.timestamp=r.uint64();break;default:r.skipType(7&e)}}return i},fromJSON:e=>({sender:ft(e.sender)?ke.fromJSON(e.sender):void 0,recipient:ft(e.recipient)?ke.fromJSON(e.recipient):void 0,timestamp:ft(e.timestamp)?Y.fromValue(e.timestamp):Y.UZERO}),toJSON(e){const t={};return void 0!==e.sender&&(t.sender=e.sender?ke.toJSON(e.sender):void 0),void 0!==e.recipient&&(t.recipient=e.recipient?ke.toJSON(e.recipient):void 0),void 0!==e.timestamp&&(t.timestamp=(e.timestamp||Y.UZERO).toString()),t},fromPartial(e){const t=tt();return t.sender=void 0!==e.sender&&null!==e.sender?ke.fromPartial(e.sender):void 0,t.recipient=void 0!==e.recipient&&null!==e.recipient?ke.fromPartial(e.recipient):void 0,t.timestamp=void 0!==e.timestamp&&null!==e.timestamp?Y.fromValue(e.timestamp):Y.UZERO,t}};function nt(){return{headerBytes:new Uint8Array,ciphertext:void 0}}const it={encode:(e,t=te().Writer.create())=>(0!==e.headerBytes.length&&t.uint32(10).bytes(e.headerBytes),void 0!==e.ciphertext&&Ue.encode(e.ciphertext,t.uint32(18).fork()).ldelim(),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i=nt();for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.headerBytes=r.bytes();break;case 2:i.ciphertext=Ue.decode(r,r.uint32());break;default:r.skipType(7&e)}}return i},fromJSON:e=>({headerBytes:ft(e.headerBytes)?ht(e.headerBytes):new Uint8Array,ciphertext:ft(e.ciphertext)?Ue.fromJSON(e.ciphertext):void 0}),toJSON(e){const t={};return void 0!==e.headerBytes&&(t.headerBytes=dt(void 0!==e.headerBytes?e.headerBytes:new Uint8Array)),void 0!==e.ciphertext&&(t.ciphertext=e.ciphertext?Ue.toJSON(e.ciphertext):void 0),t},fromPartial(e){var t;const r=nt();return r.headerBytes=null!==(t=e.headerBytes)&&void 0!==t?t:new Uint8Array,r.ciphertext=void 0!==e.ciphertext&&null!==e.ciphertext?Ue.fromPartial(e.ciphertext):void 0,r}};function ot(){return{createdNs:Y.UZERO,topic:""}}const st={encode:(e,t=te().Writer.create())=>(e.createdNs.isZero()||t.uint32(8).uint64(e.createdNs),""!==e.topic&&t.uint32(18).string(e.topic),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i=ot();for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.createdNs=r.uint64();break;case 2:i.topic=r.string();break;default:r.skipType(7&e)}}return i},fromJSON:e=>({createdNs:ft(e.createdNs)?Y.fromValue(e.createdNs):Y.UZERO,topic:ft(e.topic)?String(e.topic):""}),toJSON(e){const t={};return void 0!==e.createdNs&&(t.createdNs=(e.createdNs||Y.UZERO).toString()),void 0!==e.topic&&(t.topic=e.topic),t},fromPartial(e){var t;const r=ot();return r.createdNs=void 0!==e.createdNs&&null!==e.createdNs?Y.fromValue(e.createdNs):Y.UZERO,r.topic=null!==(t=e.topic)&&void 0!==t?t:"",r}};function at(){return{headerBytes:new Uint8Array,ciphertext:void 0}}const lt={encode:(e,t=te().Writer.create())=>(0!==e.headerBytes.length&&t.uint32(10).bytes(e.headerBytes),void 0!==e.ciphertext&&Ue.encode(e.ciphertext,t.uint32(18).fork()).ldelim(),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i=at();for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.headerBytes=r.bytes();break;case 2:i.ciphertext=Ue.decode(r,r.uint32());break;default:r.skipType(7&e)}}return i},fromJSON:e=>({headerBytes:ft(e.headerBytes)?ht(e.headerBytes):new Uint8Array,ciphertext:ft(e.ciphertext)?Ue.fromJSON(e.ciphertext):void 0}),toJSON(e){const t={};return void 0!==e.headerBytes&&(t.headerBytes=dt(void 0!==e.headerBytes?e.headerBytes:new Uint8Array)),void 0!==e.ciphertext&&(t.ciphertext=e.ciphertext?Ue.toJSON(e.ciphertext):void 0),t},fromPartial(e){var t;const r=at();return r.headerBytes=null!==(t=e.headerBytes)&&void 0!==t?t:new Uint8Array,r.ciphertext=void 0!==e.ciphertext&&null!==e.ciphertext?Ue.fromPartial(e.ciphertext):void 0,r}},ut={encode:(e,t=te().Writer.create())=>(void 0!==e.v1&&it.encode(e.v1,t.uint32(10).fork()).ldelim(),void 0!==e.v2&&lt.encode(e.v2,t.uint32(18).fork()).ldelim(),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i={v1:void 0,v2:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.v1=it.decode(r,r.uint32());break;case 2:i.v2=lt.decode(r,r.uint32());break;default:r.skipType(7&e)}}return i},fromJSON:e=>({v1:ft(e.v1)?it.fromJSON(e.v1):void 0,v2:ft(e.v2)?lt.fromJSON(e.v2):void 0}),toJSON(e){const t={};return void 0!==e.v1&&(t.v1=e.v1?it.toJSON(e.v1):void 0),void 0!==e.v2&&(t.v2=e.v2?lt.toJSON(e.v2):void 0),t},fromPartial(e){const t={v1:void 0,v2:void 0};return t.v1=void 0!==e.v1&&null!==e.v1?it.fromPartial(e.v1):void 0,t.v2=void 0!==e.v2&&null!==e.v2?lt.fromPartial(e.v2):void 0,t}};var ct=(()=>{if(void 0!==ct)return ct;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==r.g)return r.g;throw"Unable to locate global object"})();function ht(e){if(ct.Buffer)return Uint8Array.from(ct.Buffer.from(e,"base64"));{const t=ct.atob(e),r=new Uint8Array(t.length);for(let e=0;e<t.length;++e)r[e]=t.charCodeAt(e);return r}}function dt(e){if(ct.Buffer)return ct.Buffer.from(e).toString("base64");{const t=[];return e.forEach((e=>{t.push(String.fromCharCode(e))})),ct.btoa(t.join(""))}}function ft(e){return null!=e}te().util.Long!==Y&&(te().util.Long=Y,te().configure());const pt="xmtp.message_contents",mt={encode(e,t=te().Writer.create()){for(const r of e.parts)yt.encode(r,t.uint32(10).fork()).ldelim();return t},decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i={parts:[]};for(;r.pos<n;){const e=r.uint32();e>>>3==1?i.parts.push(yt.decode(r,r.uint32())):r.skipType(7&e)}return i},fromJSON:e=>({parts:Array.isArray(null==e?void 0:e.parts)?e.parts.map((e=>yt.fromJSON(e))):[]}),toJSON(e){const t={};return e.parts?t.parts=e.parts.map((e=>e?yt.toJSON(e):void 0)):t.parts=[],t},fromPartial(e){var t;const r={parts:[]};return r.parts=(null===(t=e.parts)||void 0===t?void 0:t.map((e=>yt.fromPartial(e))))||[],r}},yt={encode:(e,t=te().Writer.create())=>(void 0!==e.part&&Xe.encode(e.part,t.uint32(10).fork()).ldelim(),void 0!==e.composite&&mt.encode(e.composite,t.uint32(18).fork()).ldelim(),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i={part:void 0,composite:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.part=Xe.decode(r,r.uint32());break;case 2:i.composite=mt.decode(r,r.uint32());break;default:r.skipType(7&e)}}return i},fromJSON:e=>({part:gt(e.part)?Xe.fromJSON(e.part):void 0,composite:gt(e.composite)?mt.fromJSON(e.composite):void 0}),toJSON(e){const t={};return void 0!==e.part&&(t.part=e.part?Xe.toJSON(e.part):void 0),void 0!==e.composite&&(t.composite=e.composite?mt.toJSON(e.composite):void 0),t},fromPartial(e){const t={part:void 0,composite:void 0};return t.part=void 0!==e.part&&null!==e.part?Xe.fromPartial(e.part):void 0,t.composite=void 0!==e.composite&&null!==e.composite?mt.fromPartial(e.composite):void 0,t}};function gt(e){return null!=e}te().util.Long!==Y&&(te().util.Long=Y,te().configure());const vt="xmtp.message_contents";function bt(){return{timestamp:Y.UZERO,secp256k1:void 0,publicKey:void 0}}const wt={encode:(e,t=te().Writer.create())=>(e.timestamp.isZero()||t.uint32(8).uint64(e.timestamp),void 0!==e.secp256k1&&St.encode(e.secp256k1,t.uint32(18).fork()).ldelim(),void 0!==e.publicKey&&_e.encode(e.publicKey,t.uint32(26).fork()).ldelim(),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i=bt();for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.timestamp=r.uint64();break;case 2:i.secp256k1=St.decode(r,r.uint32());break;case 3:i.publicKey=_e.decode(r,r.uint32());break;default:r.skipType(7&e)}}return i},fromJSON:e=>({timestamp:Dt(e.timestamp)?Y.fromValue(e.timestamp):Y.UZERO,secp256k1:Dt(e.secp256k1)?St.fromJSON(e.secp256k1):void 0,publicKey:Dt(e.publicKey)?_e.fromJSON(e.publicKey):void 0}),toJSON(e){const t={};return void 0!==e.timestamp&&(t.timestamp=(e.timestamp||Y.UZERO).toString()),void 0!==e.secp256k1&&(t.secp256k1=e.secp256k1?St.toJSON(e.secp256k1):void 0),void 0!==e.publicKey&&(t.publicKey=e.publicKey?_e.toJSON(e.publicKey):void 0),t},fromPartial(e){const t=bt();return t.timestamp=void 0!==e.timestamp&&null!==e.timestamp?Y.fromValue(e.timestamp):Y.UZERO,t.secp256k1=void 0!==e.secp256k1&&null!==e.secp256k1?St.fromPartial(e.secp256k1):void 0,t.publicKey=void 0!==e.publicKey&&null!==e.publicKey?_e.fromPartial(e.publicKey):void 0,t}};function _t(){return{bytes:new Uint8Array}}const St={encode:(e,t=te().Writer.create())=>(0!==e.bytes.length&&t.uint32(10).bytes(e.bytes),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i=_t();for(;r.pos<n;){const e=r.uint32();e>>>3==1?i.bytes=r.bytes():r.skipType(7&e)}return i},fromJSON:e=>({bytes:Dt(e.bytes)?It(e.bytes):new Uint8Array}),toJSON(e){const t={};return void 0!==e.bytes&&(t.bytes=Ot(void 0!==e.bytes?e.bytes:new Uint8Array)),t},fromPartial(e){var t;const r=_t();return r.bytes=null!==(t=e.bytes)&&void 0!==t?t:new Uint8Array,r}},Et={encode(e,t=te().Writer.create()){void 0!==e.identityKey&&wt.encode(e.identityKey,t.uint32(10).fork()).ldelim();for(const r of e.preKeys)wt.encode(r,t.uint32(18).fork()).ldelim();return t},decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i={identityKey:void 0,preKeys:[]};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.identityKey=wt.decode(r,r.uint32());break;case 2:i.preKeys.push(wt.decode(r,r.uint32()));break;default:r.skipType(7&e)}}return i},fromJSON:e=>({identityKey:Dt(e.identityKey)?wt.fromJSON(e.identityKey):void 0,preKeys:Array.isArray(null==e?void 0:e.preKeys)?e.preKeys.map((e=>wt.fromJSON(e))):[]}),toJSON(e){const t={};return void 0!==e.identityKey&&(t.identityKey=e.identityKey?wt.toJSON(e.identityKey):void 0),e.preKeys?t.preKeys=e.preKeys.map((e=>e?wt.toJSON(e):void 0)):t.preKeys=[],t},fromPartial(e){var t;const r={identityKey:void 0,preKeys:[]};return r.identityKey=void 0!==e.identityKey&&null!==e.identityKey?wt.fromPartial(e.identityKey):void 0,r.preKeys=(null===(t=e.preKeys)||void 0===t?void 0:t.map((e=>wt.fromPartial(e))))||[],r}};function kt(){return{createdNs:Y.UZERO,secp256k1:void 0,publicKey:void 0}}const At={encode:(e,t=te().Writer.create())=>(e.createdNs.isZero()||t.uint32(8).uint64(e.createdNs),void 0!==e.secp256k1&&xt.encode(e.secp256k1,t.uint32(18).fork()).ldelim(),void 0!==e.publicKey&&ve.encode(e.publicKey,t.uint32(26).fork()).ldelim(),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i=kt();for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.createdNs=r.uint64();break;case 2:i.secp256k1=xt.decode(r,r.uint32());break;case 3:i.publicKey=ve.decode(r,r.uint32());break;default:r.skipType(7&e)}}return i},fromJSON:e=>({createdNs:Dt(e.createdNs)?Y.fromValue(e.createdNs):Y.UZERO,secp256k1:Dt(e.secp256k1)?xt.fromJSON(e.secp256k1):void 0,publicKey:Dt(e.publicKey)?ve.fromJSON(e.publicKey):void 0}),toJSON(e){const t={};return void 0!==e.createdNs&&(t.createdNs=(e.createdNs||Y.UZERO).toString()),void 0!==e.secp256k1&&(t.secp256k1=e.secp256k1?xt.toJSON(e.secp256k1):void 0),void 0!==e.publicKey&&(t.publicKey=e.publicKey?ve.toJSON(e.publicKey):void 0),t},fromPartial(e){const t=kt();return t.createdNs=void 0!==e.createdNs&&null!==e.createdNs?Y.fromValue(e.createdNs):Y.UZERO,t.secp256k1=void 0!==e.secp256k1&&null!==e.secp256k1?xt.fromPartial(e.secp256k1):void 0,t.publicKey=void 0!==e.publicKey&&null!==e.publicKey?ve.fromPartial(e.publicKey):void 0,t}};function Pt(){return{bytes:new Uint8Array}}const xt={encode:(e,t=te().Writer.create())=>(0!==e.bytes.length&&t.uint32(10).bytes(e.bytes),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i=Pt();for(;r.pos<n;){const e=r.uint32();e>>>3==1?i.bytes=r.bytes():r.skipType(7&e)}return i},fromJSON:e=>({bytes:Dt(e.bytes)?It(e.bytes):new Uint8Array}),toJSON(e){const t={};return void 0!==e.bytes&&(t.bytes=Ot(void 0!==e.bytes?e.bytes:new Uint8Array)),t},fromPartial(e){var t;const r=Pt();return r.bytes=null!==(t=e.bytes)&&void 0!==t?t:new Uint8Array,r}},Ct={encode(e,t=te().Writer.create()){void 0!==e.identityKey&&At.encode(e.identityKey,t.uint32(10).fork()).ldelim();for(const r of e.preKeys)At.encode(r,t.uint32(18).fork()).ldelim();return t},decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i={identityKey:void 0,preKeys:[]};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.identityKey=At.decode(r,r.uint32());break;case 2:i.preKeys.push(At.decode(r,r.uint32()));break;default:r.skipType(7&e)}}return i},fromJSON:e=>({identityKey:Dt(e.identityKey)?At.fromJSON(e.identityKey):void 0,preKeys:Array.isArray(null==e?void 0:e.preKeys)?e.preKeys.map((e=>At.fromJSON(e))):[]}),toJSON(e){const t={};return void 0!==e.identityKey&&(t.identityKey=e.identityKey?At.toJSON(e.identityKey):void 0),e.preKeys?t.preKeys=e.preKeys.map((e=>e?At.toJSON(e):void 0)):t.preKeys=[],t},fromPartial(e){var t;const r={identityKey:void 0,preKeys:[]};return r.identityKey=void 0!==e.identityKey&&null!==e.identityKey?At.fromPartial(e.identityKey):void 0,r.preKeys=(null===(t=e.preKeys)||void 0===t?void 0:t.map((e=>At.fromPartial(e))))||[],r}},Tt={encode:(e,t=te().Writer.create())=>(void 0!==e.v1&&Et.encode(e.v1,t.uint32(10).fork()).ldelim(),void 0!==e.v2&&Ct.encode(e.v2,t.uint32(18).fork()).ldelim(),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i={v1:void 0,v2:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.v1=Et.decode(r,r.uint32());break;case 2:i.v2=Ct.decode(r,r.uint32());break;default:r.skipType(7&e)}}return i},fromJSON:e=>({v1:Dt(e.v1)?Et.fromJSON(e.v1):void 0,v2:Dt(e.v2)?Ct.fromJSON(e.v2):void 0}),toJSON(e){const t={};return void 0!==e.v1&&(t.v1=e.v1?Et.toJSON(e.v1):void 0),void 0!==e.v2&&(t.v2=e.v2?Ct.toJSON(e.v2):void 0),t},fromPartial(e){const t={v1:void 0,v2:void 0};return t.v1=void 0!==e.v1&&null!==e.v1?Et.fromPartial(e.v1):void 0,t.v2=void 0!==e.v2&&null!==e.v2?Ct.fromPartial(e.v2):void 0,t}};function Nt(){return{walletPreKey:new Uint8Array,ciphertext:void 0}}const Rt={encode:(e,t=te().Writer.create())=>(0!==e.walletPreKey.length&&t.uint32(10).bytes(e.walletPreKey),void 0!==e.ciphertext&&Ue.encode(e.ciphertext,t.uint32(18).fork()).ldelim(),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i=Nt();for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.walletPreKey=r.bytes();break;case 2:i.ciphertext=Ue.decode(r,r.uint32());break;default:r.skipType(7&e)}}return i},fromJSON:e=>({walletPreKey:Dt(e.walletPreKey)?It(e.walletPreKey):new Uint8Array,ciphertext:Dt(e.ciphertext)?Ue.fromJSON(e.ciphertext):void 0}),toJSON(e){const t={};return void 0!==e.walletPreKey&&(t.walletPreKey=Ot(void 0!==e.walletPreKey?e.walletPreKey:new Uint8Array)),void 0!==e.ciphertext&&(t.ciphertext=e.ciphertext?Ue.toJSON(e.ciphertext):void 0),t},fromPartial(e){var t;const r=Nt();return r.walletPreKey=null!==(t=e.walletPreKey)&&void 0!==t?t:new Uint8Array,r.ciphertext=void 0!==e.ciphertext&&null!==e.ciphertext?Ue.fromPartial(e.ciphertext):void 0,r}},Bt={encode:(e,t=te().Writer.create())=>(void 0!==e.v1&&Rt.encode(e.v1,t.uint32(10).fork()).ldelim(),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i={v1:void 0};for(;r.pos<n;){const e=r.uint32();e>>>3==1?i.v1=Rt.decode(r,r.uint32()):r.skipType(7&e)}return i},fromJSON:e=>({v1:Dt(e.v1)?Rt.fromJSON(e.v1):void 0}),toJSON(e){const t={};return void 0!==e.v1&&(t.v1=e.v1?Rt.toJSON(e.v1):void 0),t},fromPartial(e){const t={v1:void 0};return t.v1=void 0!==e.v1&&null!==e.v1?Rt.fromPartial(e.v1):void 0,t}};var Mt=(()=>{if(void 0!==Mt)return Mt;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==r.g)return r.g;throw"Unable to locate global object"})();function It(e){if(Mt.Buffer)return Uint8Array.from(Mt.Buffer.from(e,"base64"));{const t=Mt.atob(e),r=new Uint8Array(t.length);for(let e=0;e<t.length;++e)r[e]=t.charCodeAt(e);return r}}function Ot(e){if(Mt.Buffer)return Mt.Buffer.from(e).toString("base64");{const t=[];return e.forEach((e=>{t.push(String.fromCharCode(e))})),Mt.btoa(t.join(""))}}function Dt(e){return null!=e}te().util.Long!==Y&&(te().util.Long=Y,te().configure());const Kt="xmtp.message_contents",Ut={encode:(e,t=te().Writer.create())=>(void 0!==e.keyBundle&&ke.encode(e.keyBundle,t.uint32(10).fork()).ldelim(),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i={keyBundle:void 0};for(;r.pos<n;){const e=r.uint32();e>>>3==1?i.keyBundle=ke.decode(r,r.uint32()):r.skipType(7&e)}return i},fromJSON:e=>({keyBundle:Lt(e.keyBundle)?ke.fromJSON(e.keyBundle):void 0}),toJSON(e){const t={};return void 0!==e.keyBundle&&(t.keyBundle=e.keyBundle?ke.toJSON(e.keyBundle):void 0),t},fromPartial(e){const t={keyBundle:void 0};return t.keyBundle=void 0!==e.keyBundle&&null!==e.keyBundle?ke.fromPartial(e.keyBundle):void 0,t}},Ft={encode:(e,t=te().Writer.create())=>(void 0!==e.keyBundle&&be.encode(e.keyBundle,t.uint32(10).fork()).ldelim(),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i={keyBundle:void 0};for(;r.pos<n;){const e=r.uint32();e>>>3==1?i.keyBundle=be.decode(r,r.uint32()):r.skipType(7&e)}return i},fromJSON:e=>({keyBundle:Lt(e.keyBundle)?be.fromJSON(e.keyBundle):void 0}),toJSON(e){const t={};return void 0!==e.keyBundle&&(t.keyBundle=e.keyBundle?be.toJSON(e.keyBundle):void 0),t},fromPartial(e){const t={keyBundle:void 0};return t.keyBundle=void 0!==e.keyBundle&&null!==e.keyBundle?be.fromPartial(e.keyBundle):void 0,t}},jt={encode:(e,t=te().Writer.create())=>(void 0!==e.v1&&Ut.encode(e.v1,t.uint32(10).fork()).ldelim(),void 0!==e.v2&&Ft.encode(e.v2,t.uint32(18).fork()).ldelim(),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i={v1:void 0,v2:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.v1=Ut.decode(r,r.uint32());break;case 2:i.v2=Ft.decode(r,r.uint32());break;default:r.skipType(7&e)}}return i},fromJSON:e=>({v1:Lt(e.v1)?Ut.fromJSON(e.v1):void 0,v2:Lt(e.v2)?Ft.fromJSON(e.v2):void 0}),toJSON(e){const t={};return void 0!==e.v1&&(t.v1=e.v1?Ut.toJSON(e.v1):void 0),void 0!==e.v2&&(t.v2=e.v2?Ft.toJSON(e.v2):void 0),t},fromPartial(e){const t={v1:void 0,v2:void 0};return t.v1=void 0!==e.v1&&null!==e.v1?Ut.fromPartial(e.v1):void 0,t.v2=void 0!==e.v2&&null!==e.v2?Ft.fromPartial(e.v2):void 0,t}};function Lt(e){return null!=e}te().util.Long!==Y&&(te().util.Long=Y,te().configure());const qt="xmtp.message_contents",zt={encode:(e,t=te().Writer.create())=>(""!==e.topic&&t.uint32(10).string(e.topic),void 0!==e.context&&Vt.encode(e.context,t.uint32(18).fork()).ldelim(),void 0!==e.aes256GcmHkdfSha256&&Gt.encode(e.aes256GcmHkdfSha256,t.uint32(26).fork()).ldelim(),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i={topic:"",context:void 0,aes256GcmHkdfSha256:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.topic=r.string();break;case 2:i.context=Vt.decode(r,r.uint32());break;case 3:i.aes256GcmHkdfSha256=Gt.decode(r,r.uint32());break;default:r.skipType(7&e)}}return i},fromJSON:e=>({topic:rr(e.topic)?String(e.topic):"",context:rr(e.context)?Vt.fromJSON(e.context):void 0,aes256GcmHkdfSha256:rr(e.aes256GcmHkdfSha256)?Gt.fromJSON(e.aes256GcmHkdfSha256):void 0}),toJSON(e){const t={};return void 0!==e.topic&&(t.topic=e.topic),void 0!==e.context&&(t.context=e.context?Vt.toJSON(e.context):void 0),void 0!==e.aes256GcmHkdfSha256&&(t.aes256GcmHkdfSha256=e.aes256GcmHkdfSha256?Gt.toJSON(e.aes256GcmHkdfSha256):void 0),t},fromPartial(e){var t;const r={topic:"",context:void 0,aes256GcmHkdfSha256:void 0};return r.topic=null!==(t=e.topic)&&void 0!==t?t:"",r.context=void 0!==e.context&&null!==e.context?Vt.fromPartial(e.context):void 0,r.aes256GcmHkdfSha256=void 0!==e.aes256GcmHkdfSha256&&null!==e.aes256GcmHkdfSha256?Gt.fromPartial(e.aes256GcmHkdfSha256):void 0,r}};function Wt(){return{keyMaterial:new Uint8Array}}const Gt={encode:(e,t=te().Writer.create())=>(0!==e.keyMaterial.length&&t.uint32(10).bytes(e.keyMaterial),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i=Wt();for(;r.pos<n;){const e=r.uint32();e>>>3==1?i.keyMaterial=r.bytes():r.skipType(7&e)}return i},fromJSON:e=>({keyMaterial:rr(e.keyMaterial)?er(e.keyMaterial):new Uint8Array}),toJSON(e){const t={};return void 0!==e.keyMaterial&&(t.keyMaterial=tr(void 0!==e.keyMaterial?e.keyMaterial:new Uint8Array)),t},fromPartial(e){var t;const r=Wt();return r.keyMaterial=null!==(t=e.keyMaterial)&&void 0!==t?t:new Uint8Array,r}},Vt={encode:(e,t=te().Writer.create())=>(""!==e.conversationId&&t.uint32(10).string(e.conversationId),Object.entries(e.metadata).forEach((([e,r])=>{Ht.encode({key:e,value:r},t.uint32(18).fork()).ldelim()})),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i={conversationId:"",metadata:{}};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.conversationId=r.string();break;case 2:const t=Ht.decode(r,r.uint32());void 0!==t.value&&(i.metadata[t.key]=t.value);break;default:r.skipType(7&e)}}return i},fromJSON(e){return{conversationId:rr(e.conversationId)?String(e.conversationId):"",metadata:(t=e.metadata,"object"==typeof t&&null!==t?Object.entries(e.metadata).reduce(((e,[t,r])=>(e[t]=String(r),e)),{}):{})};var t},toJSON(e){const t={};return void 0!==e.conversationId&&(t.conversationId=e.conversationId),t.metadata={},e.metadata&&Object.entries(e.metadata).forEach((([e,r])=>{t.metadata[e]=r})),t},fromPartial(e){var t,r;const n={conversationId:"",metadata:{}};return n.conversationId=null!==(t=e.conversationId)&&void 0!==t?t:"",n.metadata=Object.entries(null!==(r=e.metadata)&&void 0!==r?r:{}).reduce(((e,[t,r])=>(void 0!==r&&(e[t]=String(r)),e)),{}),n}},Ht={encode:(e,t=te().Writer.create())=>(""!==e.key&&t.uint32(10).string(e.key),""!==e.value&&t.uint32(18).string(e.value),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i={key:"",value:""};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.key=r.string();break;case 2:i.value=r.string();break;default:r.skipType(7&e)}}return i},fromJSON:e=>({key:rr(e.key)?String(e.key):"",value:rr(e.value)?String(e.value):""}),toJSON(e){const t={};return void 0!==e.key&&(t.key=e.key),void 0!==e.value&&(t.value=e.value),t},fromPartial(e){var t,r;const n={key:"",value:""};return n.key=null!==(t=e.key)&&void 0!==t?t:"",n.value=null!==(r=e.value)&&void 0!==r?r:"",n}};function Jt(){return{sender:void 0,recipient:void 0,createdNs:Y.UZERO}}const $t={encode:(e,t=te().Writer.create())=>(void 0!==e.sender&&be.encode(e.sender,t.uint32(10).fork()).ldelim(),void 0!==e.recipient&&be.encode(e.recipient,t.uint32(18).fork()).ldelim(),e.createdNs.isZero()||t.uint32(24).uint64(e.createdNs),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i=Jt();for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.sender=be.decode(r,r.uint32());break;case 2:i.recipient=be.decode(r,r.uint32());break;case 3:i.createdNs=r.uint64();break;default:r.skipType(7&e)}}return i},fromJSON:e=>({sender:rr(e.sender)?be.fromJSON(e.sender):void 0,recipient:rr(e.recipient)?be.fromJSON(e.recipient):void 0,createdNs:rr(e.createdNs)?Y.fromValue(e.createdNs):Y.UZERO}),toJSON(e){const t={};return void 0!==e.sender&&(t.sender=e.sender?be.toJSON(e.sender):void 0),void 0!==e.recipient&&(t.recipient=e.recipient?be.toJSON(e.recipient):void 0),void 0!==e.createdNs&&(t.createdNs=(e.createdNs||Y.UZERO).toString()),t},fromPartial(e){const t=Jt();return t.sender=void 0!==e.sender&&null!==e.sender?be.fromPartial(e.sender):void 0,t.recipient=void 0!==e.recipient&&null!==e.recipient?be.fromPartial(e.recipient):void 0,t.createdNs=void 0!==e.createdNs&&null!==e.createdNs?Y.fromValue(e.createdNs):Y.UZERO,t}};function Zt(){return{headerBytes:new Uint8Array,ciphertext:void 0}}const Xt={encode:(e,t=te().Writer.create())=>(0!==e.headerBytes.length&&t.uint32(10).bytes(e.headerBytes),void 0!==e.ciphertext&&Ue.encode(e.ciphertext,t.uint32(18).fork()).ldelim(),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i=Zt();for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:i.headerBytes=r.bytes();break;case 2:i.ciphertext=Ue.decode(r,r.uint32());break;default:r.skipType(7&e)}}return i},fromJSON:e=>({headerBytes:rr(e.headerBytes)?er(e.headerBytes):new Uint8Array,ciphertext:rr(e.ciphertext)?Ue.fromJSON(e.ciphertext):void 0}),toJSON(e){const t={};return void 0!==e.headerBytes&&(t.headerBytes=tr(void 0!==e.headerBytes?e.headerBytes:new Uint8Array)),void 0!==e.ciphertext&&(t.ciphertext=e.ciphertext?Ue.toJSON(e.ciphertext):void 0),t},fromPartial(e){var t;const r=Zt();return r.headerBytes=null!==(t=e.headerBytes)&&void 0!==t?t:new Uint8Array,r.ciphertext=void 0!==e.ciphertext&&null!==e.ciphertext?Ue.fromPartial(e.ciphertext):void 0,r}},Qt={encode:(e,t=te().Writer.create())=>(void 0!==e.v1&&Xt.encode(e.v1,t.uint32(10).fork()).ldelim(),t),decode(e,t){const r=e instanceof te().Reader?e:new(te().Reader)(e);let n=void 0===t?r.len:r.pos+t;const i={v1:void 0};for(;r.pos<n;){const e=r.uint32();e>>>3==1?i.v1=Xt.decode(r,r.uint32()):r.skipType(7&e)}return i},fromJSON:e=>({v1:rr(e.v1)?Xt.fromJSON(e.v1):void 0}),toJSON(e){const t={};return void 0!==e.v1&&(t.v1=e.v1?Xt.toJSON(e.v1):void 0),t},fromPartial(e){const t={v1:void 0};return t.v1=void 0!==e.v1&&null!==e.v1?Xt.fromPartial(e.v1):void 0,t}};var Yt=(()=>{if(void 0!==Yt)return Yt;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==r.g)return r.g;throw"Unable to locate global object"})();function er(e){if(Yt.Buffer)return Uint8Array.from(Yt.Buffer.from(e,"base64"));{const t=Yt.atob(e),r=new Uint8Array(t.length);for(let e=0;e<t.length;++e)r[e]=t.charCodeAt(e);return r}}function tr(e){if(Yt.Buffer)return Yt.Buffer.from(e).toString("base64");{const t=[];return e.forEach((e=>{t.push(String.fromCharCode(e))})),Yt.btoa(t.join(""))}}function rr(e){return null!=e}te().util.Long!==Y&&(te().util.Long=Y,te().configure())},8826:function(e){"use strict";!function(t){function r(e){return parseInt(e)===e}function n(e){if(!r(e.length))return!1;for(var t=0;t<e.length;t++)if(!r(e[t])||e[t]<0||e[t]>255)return!1;return!0}function i(e,t){if(e.buffer&&ArrayBuffer.isView(e)&&"Uint8Array"===e.name)return t&&(e=e.slice?e.slice():Array.prototype.slice.call(e)),e;if(Array.isArray(e)){if(!n(e))throw new Error("Array contains invalid value: "+e);return new Uint8Array(e)}if(r(e.length)&&n(e))return new Uint8Array(e);throw new Error("unsupported array-like object")}function o(e){return new Uint8Array(e)}function s(e,t,r,n,i){null==n&&null==i||(e=e.slice?e.slice(n,i):Array.prototype.slice.call(e,n,i)),t.set(e,r)}var a,l={toBytes:function(e){var t=[],r=0;for(e=encodeURI(e);r<e.length;){var n=e.charCodeAt(r++);37===n?(t.push(parseInt(e.substr(r,2),16)),r+=2):t.push(n)}return i(t)},fromBytes:function(e){for(var t=[],r=0;r<e.length;){var n=e[r];n<128?(t.push(String.fromCharCode(n)),r++):n>191&&n<224?(t.push(String.fromCharCode((31&n)<<6|63&e[r+1])),r+=2):(t.push(String.fromCharCode((15&n)<<12|(63&e[r+1])<<6|63&e[r+2])),r+=3)}return t.join("")}},u=(a="0123456789abcdef",{toBytes:function(e){for(var t=[],r=0;r<e.length;r+=2)t.push(parseInt(e.substr(r,2),16));return t},fromBytes:function(e){for(var t=[],r=0;r<e.length;r++){var n=e[r];t.push(a[(240&n)>>4]+a[15&n])}return t.join("")}}),c={16:10,24:12,32:14},h=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],d=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],f=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],p=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],m=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],y=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],g=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],v=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],b=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],w=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],_=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],S=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],E=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],k=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],A=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function P(e){for(var t=[],r=0;r<e.length;r+=4)t.push(e[r]<<24|e[r+1]<<16|e[r+2]<<8|e[r+3]);return t}var x=function(e){if(!(this instanceof x))throw Error("AES must be instanitated with `new`");Object.defineProperty(this,"key",{value:i(e,!0)}),this._prepare()};x.prototype._prepare=function(){var e=c[this.key.length];if(null==e)throw new Error("invalid key size (must be 16, 24 or 32 bytes)");this._Ke=[],this._Kd=[];for(var t=0;t<=e;t++)this._Ke.push([0,0,0,0]),this._Kd.push([0,0,0,0]);var r,n=4*(e+1),i=this.key.length/4,o=P(this.key);for(t=0;t<i;t++)r=t>>2,this._Ke[r][t%4]=o[t],this._Kd[e-r][t%4]=o[t];for(var s,a=0,l=i;l<n;){if(s=o[i-1],o[0]^=d[s>>16&255]<<24^d[s>>8&255]<<16^d[255&s]<<8^d[s>>24&255]^h[a]<<24,a+=1,8!=i)for(t=1;t<i;t++)o[t]^=o[t-1];else{for(t=1;t<i/2;t++)o[t]^=o[t-1];for(s=o[i/2-1],o[i/2]^=d[255&s]^d[s>>8&255]<<8^d[s>>16&255]<<16^d[s>>24&255]<<24,t=i/2+1;t<i;t++)o[t]^=o[t-1]}for(t=0;t<i&&l<n;)u=l>>2,f=l%4,this._Ke[u][f]=o[t],this._Kd[e-u][f]=o[t++],l++}for(var u=1;u<e;u++)for(var f=0;f<4;f++)s=this._Kd[u][f],this._Kd[u][f]=S[s>>24&255]^E[s>>16&255]^k[s>>8&255]^A[255&s]},x.prototype.encrypt=function(e){if(16!=e.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var t=this._Ke.length-1,r=[0,0,0,0],n=P(e),i=0;i<4;i++)n[i]^=this._Ke[0][i];for(var s=1;s<t;s++){for(i=0;i<4;i++)r[i]=p[n[i]>>24&255]^m[n[(i+1)%4]>>16&255]^y[n[(i+2)%4]>>8&255]^g[255&n[(i+3)%4]]^this._Ke[s][i];n=r.slice()}var a,l=o(16);for(i=0;i<4;i++)a=this._Ke[t][i],l[4*i]=255&(d[n[i]>>24&255]^a>>24),l[4*i+1]=255&(d[n[(i+1)%4]>>16&255]^a>>16),l[4*i+2]=255&(d[n[(i+2)%4]>>8&255]^a>>8),l[4*i+3]=255&(d[255&n[(i+3)%4]]^a);return l},x.prototype.decrypt=function(e){if(16!=e.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var t=this._Kd.length-1,r=[0,0,0,0],n=P(e),i=0;i<4;i++)n[i]^=this._Kd[0][i];for(var s=1;s<t;s++){for(i=0;i<4;i++)r[i]=v[n[i]>>24&255]^b[n[(i+3)%4]>>16&255]^w[n[(i+2)%4]>>8&255]^_[255&n[(i+1)%4]]^this._Kd[s][i];n=r.slice()}var a,l=o(16);for(i=0;i<4;i++)a=this._Kd[t][i],l[4*i]=255&(f[n[i]>>24&255]^a>>24),l[4*i+1]=255&(f[n[(i+3)%4]>>16&255]^a>>16),l[4*i+2]=255&(f[n[(i+2)%4]>>8&255]^a>>8),l[4*i+3]=255&(f[255&n[(i+1)%4]]^a);return l};var C=function(e){if(!(this instanceof C))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new x(e)};C.prototype.encrypt=function(e){if((e=i(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var t=o(e.length),r=o(16),n=0;n<e.length;n+=16)s(e,r,0,n,n+16),s(r=this._aes.encrypt(r),t,n);return t},C.prototype.decrypt=function(e){if((e=i(e)).length%16!=0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var t=o(e.length),r=o(16),n=0;n<e.length;n+=16)s(e,r,0,n,n+16),s(r=this._aes.decrypt(r),t,n);return t};var T=function(e,t){if(!(this instanceof T))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Block Chaining",this.name="cbc",t){if(16!=t.length)throw new Error("invalid initialation vector size (must be 16 bytes)")}else t=o(16);this._lastCipherblock=i(t,!0),this._aes=new x(e)};T.prototype.encrypt=function(e){if((e=i(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var t=o(e.length),r=o(16),n=0;n<e.length;n+=16){s(e,r,0,n,n+16);for(var a=0;a<16;a++)r[a]^=this._lastCipherblock[a];this._lastCipherblock=this._aes.encrypt(r),s(this._lastCipherblock,t,n)}return t},T.prototype.decrypt=function(e){if((e=i(e)).length%16!=0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var t=o(e.length),r=o(16),n=0;n<e.length;n+=16){s(e,r,0,n,n+16),r=this._aes.decrypt(r);for(var a=0;a<16;a++)t[n+a]=r[a]^this._lastCipherblock[a];s(e,this._lastCipherblock,0,n,n+16)}return t};var N=function(e,t,r){if(!(this instanceof N))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Feedback",this.name="cfb",t){if(16!=t.length)throw new Error("invalid initialation vector size (must be 16 size)")}else t=o(16);r||(r=1),this.segmentSize=r,this._shiftRegister=i(t,!0),this._aes=new x(e)};N.prototype.encrypt=function(e){if(e.length%this.segmentSize!=0)throw new Error("invalid plaintext size (must be segmentSize bytes)");for(var t,r=i(e,!0),n=0;n<r.length;n+=this.segmentSize){t=this._aes.encrypt(this._shiftRegister);for(var o=0;o<this.segmentSize;o++)r[n+o]^=t[o];s(this._shiftRegister,this._shiftRegister,0,this.segmentSize),s(r,this._shiftRegister,16-this.segmentSize,n,n+this.segmentSize)}return r},N.prototype.decrypt=function(e){if(e.length%this.segmentSize!=0)throw new Error("invalid ciphertext size (must be segmentSize bytes)");for(var t,r=i(e,!0),n=0;n<r.length;n+=this.segmentSize){t=this._aes.encrypt(this._shiftRegister);for(var o=0;o<this.segmentSize;o++)r[n+o]^=t[o];s(this._shiftRegister,this._shiftRegister,0,this.segmentSize),s(e,this._shiftRegister,16-this.segmentSize,n,n+this.segmentSize)}return r};var R=function(e,t){if(!(this instanceof R))throw Error("AES must be instanitated with `new`");if(this.description="Output Feedback",this.name="ofb",t){if(16!=t.length)throw new Error("invalid initialation vector size (must be 16 bytes)")}else t=o(16);this._lastPrecipher=i(t,!0),this._lastPrecipherIndex=16,this._aes=new x(e)};R.prototype.encrypt=function(e){for(var t=i(e,!0),r=0;r<t.length;r++)16===this._lastPrecipherIndex&&(this._lastPrecipher=this._aes.encrypt(this._lastPrecipher),this._lastPrecipherIndex=0),t[r]^=this._lastPrecipher[this._lastPrecipherIndex++];return t},R.prototype.decrypt=R.prototype.encrypt;var B=function(e){if(!(this instanceof B))throw Error("Counter must be instanitated with `new`");0===e||e||(e=1),"number"==typeof e?(this._counter=o(16),this.setValue(e)):this.setBytes(e)};B.prototype.setValue=function(e){if("number"!=typeof e||parseInt(e)!=e)throw new Error("invalid counter value (must be an integer)");for(var t=15;t>=0;--t)this._counter[t]=e%256,e>>=8},B.prototype.setBytes=function(e){if(16!=(e=i(e,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=e},B.prototype.increment=function(){for(var e=15;e>=0;e--){if(255!==this._counter[e]){this._counter[e]++;break}this._counter[e]=0}};var M=function(e,t){if(!(this instanceof M))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",t instanceof B||(t=new B(t)),this._counter=t,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new x(e)};M.prototype.encrypt=function(e){for(var t=i(e,!0),r=0;r<t.length;r++)16===this._remainingCounterIndex&&(this._remainingCounter=this._aes.encrypt(this._counter._counter),this._remainingCounterIndex=0,this._counter.increment()),t[r]^=this._remainingCounter[this._remainingCounterIndex++];return t},M.prototype.decrypt=M.prototype.encrypt;var I={AES:x,Counter:B,ModeOfOperation:{ecb:C,cbc:T,cfb:N,ofb:R,ctr:M},utils:{hex:u,utf8:l},padding:{pkcs7:{pad:function(e){var t=16-(e=i(e,!0)).length%16,r=o(e.length+t);s(e,r);for(var n=e.length;n<r.length;n++)r[n]=t;return r},strip:function(e){if((e=i(e,!0)).length<16)throw new Error("PKCS#7 invalid length");var t=e[e.length-1];if(t>16)throw new Error("PKCS#7 padding byte out of range");for(var r=e.length-t,n=0;n<t;n++)if(e[r+n]!==t)throw new Error("PKCS#7 invalid padding byte");var a=o(r);return s(e,a,0,0,r),a}}},_arrayTest:{coerceArray:i,createArray:o,copyArray:s}};e.exports=I}()},2882:e=>{"use strict";for(var t="qpzry9x8gf2tvdw0s3jn54khce6mua7l",r={},n=0;n<t.length;n++){var i=t.charAt(n);if(void 0!==r[i])throw new TypeError(i+" is ambiguous");r[i]=n}function o(e){var t=e>>25;return(33554431&e)<<5^996825010&-(t>>0&1)^642813549&-(t>>1&1)^513874426&-(t>>2&1)^1027748829&-(t>>3&1)^705979059&-(t>>4&1)}function s(e){for(var t=1,r=0;r<e.length;++r){var n=e.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+e+")";t=o(t)^n>>5}for(t=o(t),r=0;r<e.length;++r){var i=e.charCodeAt(r);t=o(t)^31&i}return t}function a(e,t){if(t=t||90,e.length<8)return e+" too short";if(e.length>t)return"Exceeds length limit";var n=e.toLowerCase(),i=e.toUpperCase();if(e!==n&&e!==i)return"Mixed-case string "+e;var a=(e=n).lastIndexOf("1");if(-1===a)return"No separator character for "+e;if(0===a)return"Missing prefix for "+e;var l=e.slice(0,a),u=e.slice(a+1);if(u.length<6)return"Data too short";var c=s(l);if("string"==typeof c)return c;for(var h=[],d=0;d<u.length;++d){var f=u.charAt(d),p=r[f];if(void 0===p)return"Unknown character "+f;c=o(c)^p,d+6>=u.length||h.push(p)}return 1!==c?"Invalid checksum for "+e:{prefix:l,words:h}}function l(e,t,r,n){for(var i=0,o=0,s=(1<<r)-1,a=[],l=0;l<e.length;++l)for(i=i<<t|e[l],o+=t;o>=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<<r-o&s);else{if(o>=t)return"Excess padding";if(i<<r-o&s)return"Non-zero padding"}return a}e.exports={decodeUnsafe:function(){var e=a.apply(null,arguments);if("object"==typeof e)return e},decode:function(e){var t=a.apply(null,arguments);if("object"==typeof t)return t;throw new Error(t)},encode:function(e,r,n){if(n=n||90,e.length+7+r.length>n)throw new TypeError("Exceeds length limit");var i=s(e=e.toLowerCase());if("string"==typeof i)throw new Error(i);for(var a=e+"1",l=0;l<r.length;++l){var u=r[l];if(u>>5!=0)throw new Error("Non 5-bit word");i=o(i)^u,a+=t.charAt(u)}for(l=0;l<6;++l)i=o(i);for(i^=1,l=0;l<6;++l)a+=t.charAt(i>>5*(5-l)&31);return a},toWordsUnsafe:function(e){var t=l(e,8,5,!0);if(Array.isArray(t))return t},toWords:function(e){var t=l(e,8,5,!0);if(Array.isArray(t))return t;throw new Error(t)},fromWordsUnsafe:function(e){var t=l(e,5,8,!1);if(Array.isArray(t))return t},fromWords:function(e){var t=l(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}}},3550:function(e,t,r){!function(e,t){"use strict";function n(e,t){if(!e)throw new Error(t||"Assertion failed")}function i(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function o(e,t,r){if(o.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var s;"object"==typeof e?e.exports=o:t.BN=o,o.BN=o,o.wordSize=26;try{s="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:r(6601).Buffer}catch(e){}function a(e,t){var r=e.charCodeAt(t);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function l(e,t,r){var n=a(e,r);return r-1>=t&&(n|=a(e,r-1)<<4),n}function u(e,t,r,n){for(var i=0,o=Math.min(e.length,r),s=t;s<o;s++){var a=e.charCodeAt(s)-48;i*=n,i+=a>=49?a-49+10:a>=17?a-17+10:a}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i<e.length&&(16===t?this._parseHex(e,i,r):(this._parseBase(e,t,i),"le"===r&&this._initArray(this.toArray(),t,r)))},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var o,s,a=0;if("be"===r)for(i=e.length-1,o=0;i>=0;i-=3)s=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(i=0,o=0;i<e.length;i+=3)s=e[i]|e[i+1]<<8|e[i+2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t,r){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var i,o=0,s=0;if("be"===r)for(n=e.length-1;n>=t;n-=2)i=l(e,t,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(e.length-t)%2==0?t+1:t;n<e.length;n+=2)i=l(e,t,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;this.strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,s=o%n,a=Math.min(o,o-s)+r,l=0,c=r;c<a;c+=n)l=u(e,c,c+n,t),this.imuln(i),this.words[0]+l<67108864?this.words[0]+=l:this._iaddn(l);if(0!==s){var h=1;for(l=u(e,c,e.length,t),c=0;c<s;c++)h*=t;this.imuln(h),this.words[0]+l<67108864?this.words[0]+=l:this._iaddn(l)}this.strip()},o.prototype.copy=function(e){e.words=new Array(this.length);for(var t=0;t<this.length;t++)e.words[t]=this.words[t];e.length=this.length,e.negative=this.negative,e.red=this.red},o.prototype.clone=function(){var e=new o(null);return this.copy(e),e},o.prototype._expand=function(e){for(;this.length<e;)this.words[this.length++]=0;return this},o.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],h=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],d=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function f(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],s=i*o,a=67108863&s,l=s/67108864|0;r.words[0]=a;for(var u=1;u<n;u++){for(var c=l>>>26,h=67108863&l,d=Math.min(u,t.length-1),f=Math.max(0,u-e.length+1);f<=d;f++){var p=u-f|0;c+=(s=(i=0|e.words[p])*(o=0|t.words[f])+h)/67108864|0,h=67108863&s}r.words[u]=0|h,l=0|c}return 0!==l?r.words[u]=0|l:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,s=0;s<this.length;s++){var a=this.words[s],l=(16777215&(a<<i|o)).toString(16);r=0!=(o=a>>>24-i&16777215)||s!==this.length-1?c[6-l.length]+l+r:l+r,(i+=2)>=26&&(i-=26,s--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var u=h[e],f=d[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(f).toString(e);r=(p=p.idivn(f)).isZero()?m+r:c[u-m.length]+m+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n(void 0!==s),this.toArrayLike(s,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var s,a,l="le"===t,u=new e(o),c=this.clone();if(l){for(a=0;!c.isZero();a++)s=c.andln(255),c.iushrn(8),u[a]=s;for(;a<o;a++)u[a]=0}else{for(a=0;a<o-i;a++)u[a]=0;for(a=0;!c.isZero();a++)s=c.andln(255),c.iushrn(8),u[o-a-1]=s}return u},Math.clz32?o.prototype._countBits=function(e){return 32-Math.clz32(e)}:o.prototype._countBits=function(e){var t=e,r=0;return t>=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;t<this.length;t++){var r=this._zeroBits(this.words[t]);if(e+=r,26!==r)break}return e},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(e){return 0!==this.negative?this.abs().inotn(e).iaddn(1):this.clone()},o.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return 0!==this.negative},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var t=0;t<e.length;t++)this.words[t]=this.words[t]|e.words[t];return this.strip()},o.prototype.ior=function(e){return n(0==(this.negative|e.negative)),this.iuor(e)},o.prototype.or=function(e){return this.length>e.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;r<t.length;r++)this.words[r]=this.words[r]&e.words[r];return this.length=t.length,this.strip()},o.prototype.iand=function(e){return n(0==(this.negative|e.negative)),this.iuand(e)},o.prototype.and=function(e){return this.length>e.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;n<r.length;n++)this.words[n]=t.words[n]^r.words[n];if(this!==t)for(;n<t.length;n++)this.words[n]=t.words[n];return this.length=t.length,this.strip()},o.prototype.ixor=function(e){return n(0==(this.negative|e.negative)),this.iuxor(e)},o.prototype.xor=function(e){return this.length>e.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i<t;i++)this.words[i]=67108863&~this.words[i];return r>0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<<i:this.words[r]&~(1<<i),this.strip()},o.prototype.iadd=function(e){var t,r,n;if(0!==this.negative&&0===e.negative)return this.negative=0,t=this.isub(e),this.negative^=1,this._normSign();if(0===this.negative&&0!==e.negative)return e.negative=0,t=this.isub(e),e.negative=1,t._normSign();this.length>e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o<n.length;o++)t=(0|r.words[o])+(0|n.words[o])+i,this.words[o]=67108863&t,i=t>>>26;for(;0!==i&&o<r.length;o++)t=(0|r.words[o])+i,this.words[o]=67108863&t,i=t>>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},o.prototype.add=function(e){var t;return 0!==e.negative&&0===this.negative?(e.negative=0,t=this.sub(e),e.negative^=1,t):0===e.negative&&0!==this.negative?(this.negative=0,t=e.sub(this),this.negative=1,t):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,s=0;s<n.length;s++)o=(t=(0|r.words[s])-(0|n.words[s])+o)>>26,this.words[s]=67108863&t;for(;0!==o&&s<r.length;s++)o=(t=(0|r.words[s])+o)>>26,this.words[s]=67108863&t;if(0===o&&s<r.length&&r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this.length=Math.max(this.length,s),r!==this&&(this.negative=1),this.strip()},o.prototype.sub=function(e){return this.clone().isub(e)};var p=function(e,t,r){var n,i,o,s=e.words,a=t.words,l=r.words,u=0,c=0|s[0],h=8191&c,d=c>>>13,f=0|s[1],p=8191&f,m=f>>>13,y=0|s[2],g=8191&y,v=y>>>13,b=0|s[3],w=8191&b,_=b>>>13,S=0|s[4],E=8191&S,k=S>>>13,A=0|s[5],P=8191&A,x=A>>>13,C=0|s[6],T=8191&C,N=C>>>13,R=0|s[7],B=8191&R,M=R>>>13,I=0|s[8],O=8191&I,D=I>>>13,K=0|s[9],U=8191&K,F=K>>>13,j=0|a[0],L=8191&j,q=j>>>13,z=0|a[1],W=8191&z,G=z>>>13,V=0|a[2],H=8191&V,J=V>>>13,$=0|a[3],Z=8191&$,X=$>>>13,Q=0|a[4],Y=8191&Q,ee=Q>>>13,te=0|a[5],re=8191&te,ne=te>>>13,ie=0|a[6],oe=8191&ie,se=ie>>>13,ae=0|a[7],le=8191&ae,ue=ae>>>13,ce=0|a[8],he=8191&ce,de=ce>>>13,fe=0|a[9],pe=8191&fe,me=fe>>>13;r.negative=e.negative^t.negative,r.length=19;var ye=(u+(n=Math.imul(h,L))|0)+((8191&(i=(i=Math.imul(h,q))+Math.imul(d,L)|0))<<13)|0;u=((o=Math.imul(d,q))+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(p,L),i=(i=Math.imul(p,q))+Math.imul(m,L)|0,o=Math.imul(m,q);var ge=(u+(n=n+Math.imul(h,W)|0)|0)+((8191&(i=(i=i+Math.imul(h,G)|0)+Math.imul(d,W)|0))<<13)|0;u=((o=o+Math.imul(d,G)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(g,L),i=(i=Math.imul(g,q))+Math.imul(v,L)|0,o=Math.imul(v,q),n=n+Math.imul(p,W)|0,i=(i=i+Math.imul(p,G)|0)+Math.imul(m,W)|0,o=o+Math.imul(m,G)|0;var ve=(u+(n=n+Math.imul(h,H)|0)|0)+((8191&(i=(i=i+Math.imul(h,J)|0)+Math.imul(d,H)|0))<<13)|0;u=((o=o+Math.imul(d,J)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(w,L),i=(i=Math.imul(w,q))+Math.imul(_,L)|0,o=Math.imul(_,q),n=n+Math.imul(g,W)|0,i=(i=i+Math.imul(g,G)|0)+Math.imul(v,W)|0,o=o+Math.imul(v,G)|0,n=n+Math.imul(p,H)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(m,H)|0,o=o+Math.imul(m,J)|0;var be=(u+(n=n+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,X)|0)+Math.imul(d,Z)|0))<<13)|0;u=((o=o+Math.imul(d,X)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(E,L),i=(i=Math.imul(E,q))+Math.imul(k,L)|0,o=Math.imul(k,q),n=n+Math.imul(w,W)|0,i=(i=i+Math.imul(w,G)|0)+Math.imul(_,W)|0,o=o+Math.imul(_,G)|0,n=n+Math.imul(g,H)|0,i=(i=i+Math.imul(g,J)|0)+Math.imul(v,H)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,X)|0)+Math.imul(m,Z)|0,o=o+Math.imul(m,X)|0;var we=(u+(n=n+Math.imul(h,Y)|0)|0)+((8191&(i=(i=i+Math.imul(h,ee)|0)+Math.imul(d,Y)|0))<<13)|0;u=((o=o+Math.imul(d,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(P,L),i=(i=Math.imul(P,q))+Math.imul(x,L)|0,o=Math.imul(x,q),n=n+Math.imul(E,W)|0,i=(i=i+Math.imul(E,G)|0)+Math.imul(k,W)|0,o=o+Math.imul(k,G)|0,n=n+Math.imul(w,H)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,H)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(g,Z)|0,i=(i=i+Math.imul(g,X)|0)+Math.imul(v,Z)|0,o=o+Math.imul(v,X)|0,n=n+Math.imul(p,Y)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(m,Y)|0,o=o+Math.imul(m,ee)|0;var _e=(u+(n=n+Math.imul(h,re)|0)|0)+((8191&(i=(i=i+Math.imul(h,ne)|0)+Math.imul(d,re)|0))<<13)|0;u=((o=o+Math.imul(d,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(T,L),i=(i=Math.imul(T,q))+Math.imul(N,L)|0,o=Math.imul(N,q),n=n+Math.imul(P,W)|0,i=(i=i+Math.imul(P,G)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,G)|0,n=n+Math.imul(E,H)|0,i=(i=i+Math.imul(E,J)|0)+Math.imul(k,H)|0,o=o+Math.imul(k,J)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,X)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,X)|0,n=n+Math.imul(g,Y)|0,i=(i=i+Math.imul(g,ee)|0)+Math.imul(v,Y)|0,o=o+Math.imul(v,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(m,re)|0,o=o+Math.imul(m,ne)|0;var Se=(u+(n=n+Math.imul(h,oe)|0)|0)+((8191&(i=(i=i+Math.imul(h,se)|0)+Math.imul(d,oe)|0))<<13)|0;u=((o=o+Math.imul(d,se)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(B,L),i=(i=Math.imul(B,q))+Math.imul(M,L)|0,o=Math.imul(M,q),n=n+Math.imul(T,W)|0,i=(i=i+Math.imul(T,G)|0)+Math.imul(N,W)|0,o=o+Math.imul(N,G)|0,n=n+Math.imul(P,H)|0,i=(i=i+Math.imul(P,J)|0)+Math.imul(x,H)|0,o=o+Math.imul(x,J)|0,n=n+Math.imul(E,Z)|0,i=(i=i+Math.imul(E,X)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,X)|0,n=n+Math.imul(w,Y)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,Y)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(g,re)|0,i=(i=i+Math.imul(g,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,se)|0)+Math.imul(m,oe)|0,o=o+Math.imul(m,se)|0;var Ee=(u+(n=n+Math.imul(h,le)|0)|0)+((8191&(i=(i=i+Math.imul(h,ue)|0)+Math.imul(d,le)|0))<<13)|0;u=((o=o+Math.imul(d,ue)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(O,L),i=(i=Math.imul(O,q))+Math.imul(D,L)|0,o=Math.imul(D,q),n=n+Math.imul(B,W)|0,i=(i=i+Math.imul(B,G)|0)+Math.imul(M,W)|0,o=o+Math.imul(M,G)|0,n=n+Math.imul(T,H)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(N,H)|0,o=o+Math.imul(N,J)|0,n=n+Math.imul(P,Z)|0,i=(i=i+Math.imul(P,X)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,X)|0,n=n+Math.imul(E,Y)|0,i=(i=i+Math.imul(E,ee)|0)+Math.imul(k,Y)|0,o=o+Math.imul(k,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(g,oe)|0,i=(i=i+Math.imul(g,se)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,se)|0,n=n+Math.imul(p,le)|0,i=(i=i+Math.imul(p,ue)|0)+Math.imul(m,le)|0,o=o+Math.imul(m,ue)|0;var ke=(u+(n=n+Math.imul(h,he)|0)|0)+((8191&(i=(i=i+Math.imul(h,de)|0)+Math.imul(d,he)|0))<<13)|0;u=((o=o+Math.imul(d,de)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(U,L),i=(i=Math.imul(U,q))+Math.imul(F,L)|0,o=Math.imul(F,q),n=n+Math.imul(O,W)|0,i=(i=i+Math.imul(O,G)|0)+Math.imul(D,W)|0,o=o+Math.imul(D,G)|0,n=n+Math.imul(B,H)|0,i=(i=i+Math.imul(B,J)|0)+Math.imul(M,H)|0,o=o+Math.imul(M,J)|0,n=n+Math.imul(T,Z)|0,i=(i=i+Math.imul(T,X)|0)+Math.imul(N,Z)|0,o=o+Math.imul(N,X)|0,n=n+Math.imul(P,Y)|0,i=(i=i+Math.imul(P,ee)|0)+Math.imul(x,Y)|0,o=o+Math.imul(x,ee)|0,n=n+Math.imul(E,re)|0,i=(i=i+Math.imul(E,ne)|0)+Math.imul(k,re)|0,o=o+Math.imul(k,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,se)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,se)|0,n=n+Math.imul(g,le)|0,i=(i=i+Math.imul(g,ue)|0)+Math.imul(v,le)|0,o=o+Math.imul(v,ue)|0,n=n+Math.imul(p,he)|0,i=(i=i+Math.imul(p,de)|0)+Math.imul(m,he)|0,o=o+Math.imul(m,de)|0;var Ae=(u+(n=n+Math.imul(h,pe)|0)|0)+((8191&(i=(i=i+Math.imul(h,me)|0)+Math.imul(d,pe)|0))<<13)|0;u=((o=o+Math.imul(d,me)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(U,W),i=(i=Math.imul(U,G))+Math.imul(F,W)|0,o=Math.imul(F,G),n=n+Math.imul(O,H)|0,i=(i=i+Math.imul(O,J)|0)+Math.imul(D,H)|0,o=o+Math.imul(D,J)|0,n=n+Math.imul(B,Z)|0,i=(i=i+Math.imul(B,X)|0)+Math.imul(M,Z)|0,o=o+Math.imul(M,X)|0,n=n+Math.imul(T,Y)|0,i=(i=i+Math.imul(T,ee)|0)+Math.imul(N,Y)|0,o=o+Math.imul(N,ee)|0,n=n+Math.imul(P,re)|0,i=(i=i+Math.imul(P,ne)|0)+Math.imul(x,re)|0,o=o+Math.imul(x,ne)|0,n=n+Math.imul(E,oe)|0,i=(i=i+Math.imul(E,se)|0)+Math.imul(k,oe)|0,o=o+Math.imul(k,se)|0,n=n+Math.imul(w,le)|0,i=(i=i+Math.imul(w,ue)|0)+Math.imul(_,le)|0,o=o+Math.imul(_,ue)|0,n=n+Math.imul(g,he)|0,i=(i=i+Math.imul(g,de)|0)+Math.imul(v,he)|0,o=o+Math.imul(v,de)|0;var Pe=(u+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,me)|0)+Math.imul(m,pe)|0))<<13)|0;u=((o=o+Math.imul(m,me)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(U,H),i=(i=Math.imul(U,J))+Math.imul(F,H)|0,o=Math.imul(F,J),n=n+Math.imul(O,Z)|0,i=(i=i+Math.imul(O,X)|0)+Math.imul(D,Z)|0,o=o+Math.imul(D,X)|0,n=n+Math.imul(B,Y)|0,i=(i=i+Math.imul(B,ee)|0)+Math.imul(M,Y)|0,o=o+Math.imul(M,ee)|0,n=n+Math.imul(T,re)|0,i=(i=i+Math.imul(T,ne)|0)+Math.imul(N,re)|0,o=o+Math.imul(N,ne)|0,n=n+Math.imul(P,oe)|0,i=(i=i+Math.imul(P,se)|0)+Math.imul(x,oe)|0,o=o+Math.imul(x,se)|0,n=n+Math.imul(E,le)|0,i=(i=i+Math.imul(E,ue)|0)+Math.imul(k,le)|0,o=o+Math.imul(k,ue)|0,n=n+Math.imul(w,he)|0,i=(i=i+Math.imul(w,de)|0)+Math.imul(_,he)|0,o=o+Math.imul(_,de)|0;var xe=(u+(n=n+Math.imul(g,pe)|0)|0)+((8191&(i=(i=i+Math.imul(g,me)|0)+Math.imul(v,pe)|0))<<13)|0;u=((o=o+Math.imul(v,me)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(U,Z),i=(i=Math.imul(U,X))+Math.imul(F,Z)|0,o=Math.imul(F,X),n=n+Math.imul(O,Y)|0,i=(i=i+Math.imul(O,ee)|0)+Math.imul(D,Y)|0,o=o+Math.imul(D,ee)|0,n=n+Math.imul(B,re)|0,i=(i=i+Math.imul(B,ne)|0)+Math.imul(M,re)|0,o=o+Math.imul(M,ne)|0,n=n+Math.imul(T,oe)|0,i=(i=i+Math.imul(T,se)|0)+Math.imul(N,oe)|0,o=o+Math.imul(N,se)|0,n=n+Math.imul(P,le)|0,i=(i=i+Math.imul(P,ue)|0)+Math.imul(x,le)|0,o=o+Math.imul(x,ue)|0,n=n+Math.imul(E,he)|0,i=(i=i+Math.imul(E,de)|0)+Math.imul(k,he)|0,o=o+Math.imul(k,de)|0;var Ce=(u+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,me)|0)+Math.imul(_,pe)|0))<<13)|0;u=((o=o+Math.imul(_,me)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,n=Math.imul(U,Y),i=(i=Math.imul(U,ee))+Math.imul(F,Y)|0,o=Math.imul(F,ee),n=n+Math.imul(O,re)|0,i=(i=i+Math.imul(O,ne)|0)+Math.imul(D,re)|0,o=o+Math.imul(D,ne)|0,n=n+Math.imul(B,oe)|0,i=(i=i+Math.imul(B,se)|0)+Math.imul(M,oe)|0,o=o+Math.imul(M,se)|0,n=n+Math.imul(T,le)|0,i=(i=i+Math.imul(T,ue)|0)+Math.imul(N,le)|0,o=o+Math.imul(N,ue)|0,n=n+Math.imul(P,he)|0,i=(i=i+Math.imul(P,de)|0)+Math.imul(x,he)|0,o=o+Math.imul(x,de)|0;var Te=(u+(n=n+Math.imul(E,pe)|0)|0)+((8191&(i=(i=i+Math.imul(E,me)|0)+Math.imul(k,pe)|0))<<13)|0;u=((o=o+Math.imul(k,me)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(U,re),i=(i=Math.imul(U,ne))+Math.imul(F,re)|0,o=Math.imul(F,ne),n=n+Math.imul(O,oe)|0,i=(i=i+Math.imul(O,se)|0)+Math.imul(D,oe)|0,o=o+Math.imul(D,se)|0,n=n+Math.imul(B,le)|0,i=(i=i+Math.imul(B,ue)|0)+Math.imul(M,le)|0,o=o+Math.imul(M,ue)|0,n=n+Math.imul(T,he)|0,i=(i=i+Math.imul(T,de)|0)+Math.imul(N,he)|0,o=o+Math.imul(N,de)|0;var Ne=(u+(n=n+Math.imul(P,pe)|0)|0)+((8191&(i=(i=i+Math.imul(P,me)|0)+Math.imul(x,pe)|0))<<13)|0;u=((o=o+Math.imul(x,me)|0)+(i>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,n=Math.imul(U,oe),i=(i=Math.imul(U,se))+Math.imul(F,oe)|0,o=Math.imul(F,se),n=n+Math.imul(O,le)|0,i=(i=i+Math.imul(O,ue)|0)+Math.imul(D,le)|0,o=o+Math.imul(D,ue)|0,n=n+Math.imul(B,he)|0,i=(i=i+Math.imul(B,de)|0)+Math.imul(M,he)|0,o=o+Math.imul(M,de)|0;var Re=(u+(n=n+Math.imul(T,pe)|0)|0)+((8191&(i=(i=i+Math.imul(T,me)|0)+Math.imul(N,pe)|0))<<13)|0;u=((o=o+Math.imul(N,me)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863,n=Math.imul(U,le),i=(i=Math.imul(U,ue))+Math.imul(F,le)|0,o=Math.imul(F,ue),n=n+Math.imul(O,he)|0,i=(i=i+Math.imul(O,de)|0)+Math.imul(D,he)|0,o=o+Math.imul(D,de)|0;var Be=(u+(n=n+Math.imul(B,pe)|0)|0)+((8191&(i=(i=i+Math.imul(B,me)|0)+Math.imul(M,pe)|0))<<13)|0;u=((o=o+Math.imul(M,me)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(U,he),i=(i=Math.imul(U,de))+Math.imul(F,he)|0,o=Math.imul(F,de);var Me=(u+(n=n+Math.imul(O,pe)|0)|0)+((8191&(i=(i=i+Math.imul(O,me)|0)+Math.imul(D,pe)|0))<<13)|0;u=((o=o+Math.imul(D,me)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863;var Ie=(u+(n=Math.imul(U,pe))|0)+((8191&(i=(i=Math.imul(U,me))+Math.imul(F,pe)|0))<<13)|0;return u=((o=Math.imul(F,me))+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,l[0]=ye,l[1]=ge,l[2]=ve,l[3]=be,l[4]=we,l[5]=_e,l[6]=Se,l[7]=Ee,l[8]=ke,l[9]=Ae,l[10]=Pe,l[11]=xe,l[12]=Ce,l[13]=Te,l[14]=Ne,l[15]=Re,l[16]=Be,l[17]=Me,l[18]=Ie,0!==u&&(l[19]=u,r.length++),r};function m(e,t,r){return(new y).mulp(e,t,r)}function y(e,t){this.x=e,this.y=t}Math.imul||(p=f),o.prototype.mulTo=function(e,t){var r,n=this.length+e.length;return r=10===this.length&&10===e.length?p(this,e,t):n<63?f(this,e,t):n<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o<r.length-1;o++){var s=i;i=0;for(var a=67108863&n,l=Math.min(o,t.length-1),u=Math.max(0,o-e.length+1);u<=l;u++){var c=o-u,h=(0|e.words[c])*(0|t.words[u]),d=67108863&h;a=67108863&(d=d+a|0),i+=(s=(s=s+(h/67108864|0)|0)+(d>>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):m(this,e,t),r},y.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n<e;n++)t[n]=this.revBin(n,r,e);return t},y.prototype.revBin=function(e,t,r){if(0===e||e===r-1)return e;for(var n=0,i=0;i<t;i++)n|=(1&e)<<t-i-1,e>>=1;return n},y.prototype.permute=function(e,t,r,n,i,o){for(var s=0;s<o;s++)n[s]=t[e[s]],i[s]=r[e[s]]},y.prototype.transform=function(e,t,r,n,i,o){this.permute(o,e,t,r,n,i);for(var s=1;s<i;s<<=1)for(var a=s<<1,l=Math.cos(2*Math.PI/a),u=Math.sin(2*Math.PI/a),c=0;c<i;c+=a)for(var h=l,d=u,f=0;f<s;f++){var p=r[c+f],m=n[c+f],y=r[c+f+s],g=n[c+f+s],v=h*y-d*g;g=h*g+d*y,y=v,r[c+f]=p+y,n[c+f]=m+g,r[c+f+s]=p-y,n[c+f+s]=m-g,f!==a&&(v=l*h-u*d,d=l*d+u*h,h=v)}},y.prototype.guessLen13b=function(e,t){var r=1|Math.max(t,e),n=1&r,i=0;for(r=r/2|0;r;r>>>=1)i++;return 1<<i+1+n},y.prototype.conjugate=function(e,t,r){if(!(r<=1))for(var n=0;n<r/2;n++){var i=e[n];e[n]=e[r-n-1],e[r-n-1]=i,i=t[n],t[n]=-t[r-n-1],t[r-n-1]=-i}},y.prototype.normalize13b=function(e,t){for(var r=0,n=0;n<t/2;n++){var i=8192*Math.round(e[2*n+1]/t)+Math.round(e[2*n]/t)+r;e[n]=67108863&i,r=i<67108864?0:i/67108864|0}return e},y.prototype.convert13b=function(e,t,r,i){for(var o=0,s=0;s<t;s++)o+=0|e[s],r[2*s]=8191&o,o>>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*t;s<i;++s)r[s]=0;n(0===o),n(0==(-8192&o))},y.prototype.stub=function(e){for(var t=new Array(e),r=0;r<e;r++)t[r]=0;return t},y.prototype.mulp=function(e,t,r){var n=2*this.guessLen13b(e.length,t.length),i=this.makeRBT(n),o=this.stub(n),s=new Array(n),a=new Array(n),l=new Array(n),u=new Array(n),c=new Array(n),h=new Array(n),d=r.words;d.length=n,this.convert13b(e.words,e.length,s,n),this.convert13b(t.words,t.length,u,n),this.transform(s,o,a,l,n,i),this.transform(u,o,c,h,n,i);for(var f=0;f<n;f++){var p=a[f]*c[f]-l[f]*h[f];l[f]=a[f]*h[f]+l[f]*c[f],a[f]=p}return this.conjugate(a,l,n),this.transform(a,l,d,o,n,i),this.conjugate(d,o,n),this.normalize13b(d,n),r.negative=e.negative^t.negative,r.length=e.length+t.length,r.strip()},o.prototype.mul=function(e){var t=new o(null);return t.words=new Array(this.length+e.length),this.mulTo(e,t)},o.prototype.mulf=function(e){var t=new o(null);return t.words=new Array(this.length+e.length),m(this,e,t)},o.prototype.imul=function(e){return this.clone().mulTo(e,this)},o.prototype.imuln=function(e){n("number"==typeof e),n(e<67108864);for(var t=0,r=0;r<this.length;r++){var i=(0|this.words[r])*e,o=(67108863&i)+(67108863&t);t>>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r<t.length;r++){var n=r/26|0,i=r%26;t[r]=(e.words[n]&1<<i)>>>i}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n<t.length&&0===t[n];n++,r=r.sqr());if(++n<t.length)for(var i=r.sqr();n<t.length;n++,i=i.sqr())0!==t[n]&&(r=r.mul(i));return r},o.prototype.iushln=function(e){n("number"==typeof e&&e>=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var s=0;for(t=0;t<this.length;t++){var a=this.words[t]&o,l=(0|this.words[t])-a<<r;this.words[t]=l|s,s=a>>>26-r}s&&(this.words[t]=s,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t<i;t++)this.words[t]=0;this.length+=i}return this.strip()},o.prototype.ishln=function(e){return n(0===this.negative),this.iushln(e)},o.prototype.iushrn=function(e,t,r){var i;n("number"==typeof e&&e>=0),i=t?(t-t%26)/26:0;var o=e%26,s=Math.min((e-o)/26,this.length),a=67108863^67108863>>>o<<o,l=r;if(i-=s,i=Math.max(0,i),l){for(var u=0;u<s;u++)l.words[u]=this.words[u];l.length=s}if(0===s);else if(this.length>s)for(this.length-=s,u=0;u<this.length;u++)this.words[u]=this.words[u+s];else this.words[0]=0,this.length=1;var c=0;for(u=this.length-1;u>=0&&(0!==c||u>=i);u--){var h=0|this.words[u];this.words[u]=c<<26-o|h>>>o,c=h&a}return l&&0!==c&&(l.words[l.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<<t;return!(this.length<=r||!(this.words[r]&i))},o.prototype.imaskn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<<t;this.words[this.length-1]&=i}return this.strip()},o.prototype.maskn=function(e){return this.clone().imaskn(e)},o.prototype.iaddn=function(e){return n("number"==typeof e),n(e<67108864),e<0?this.isubn(-e):0!==this.negative?1===this.length&&(0|this.words[0])<e?(this.words[0]=e-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(e),this.negative=1,this):this._iaddn(e)},o.prototype._iaddn=function(e){this.words[0]+=e;for(var t=0;t<this.length&&this.words[t]>=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t<this.length&&this.words[t]<0;t++)this.words[t]+=67108864,this.words[t+1]-=1;return this.strip()},o.prototype.addn=function(e){return this.clone().iaddn(e)},o.prototype.subn=function(e){return this.clone().isubn(e)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(e,t,r){var i,o,s=e.length+r;this._expand(s);var a=0;for(i=0;i<e.length;i++){o=(0|this.words[i+r])+a;var l=(0|e.words[i])*t;a=((o-=67108863&l)>>26)-(l/67108864|0),this.words[i+r]=67108863&o}for(;i<this.length-r;i++)a=(o=(0|this.words[i+r])+a)>>26,this.words[i+r]=67108863&o;if(0===a)return this.strip();for(n(-1===a),a=0,i=0;i<this.length;i++)a=(o=-(0|this.words[i])+a)>>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,s=0|i.words[i.length-1];0!=(r=26-this._countBits(s))&&(i=i.ushln(r),n.iushln(r),s=0|i.words[i.length-1]);var a,l=n.length-i.length;if("mod"!==t){(a=new o(null)).length=l+1,a.words=new Array(a.length);for(var u=0;u<a.length;u++)a.words[u]=0}var c=n.clone()._ishlnsubmul(i,1,l);0===c.negative&&(n=c,a&&(a.words[l]=1));for(var h=l-1;h>=0;h--){var d=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(d=Math.min(d/s|0,67108863),n._ishlnsubmul(i,d,h);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);a&&(a.words[h]=d)}return a&&a.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(a=this.neg().divmod(e,t),"mod"!==t&&(i=a.div.neg()),"div"!==t&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(e)),{div:i,mod:s}):0===this.negative&&0!==e.negative?(a=this.divmod(e.neg(),t),"mod"!==t&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&e.negative)?(a=this.neg().divmod(e.neg(),t),"div"!==t&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(e)),{div:a.div,mod:s}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,s,a},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},o.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),s=new o(0),a=new o(0),l=new o(1),u=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++u;for(var c=r.clone(),h=t.clone();!t.isZero();){for(var d=0,f=1;0==(t.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(t.iushrn(d);d-- >0;)(i.isOdd()||s.isOdd())&&(i.iadd(c),s.isub(h)),i.iushrn(1),s.iushrn(1);for(var p=0,m=1;0==(r.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||l.isOdd())&&(a.iadd(c),l.isub(h)),a.iushrn(1),l.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(a),s.isub(l)):(r.isub(t),a.isub(i),l.isub(s))}return{a,b:l,gcd:r.iushln(u)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,s=new o(1),a=new o(0),l=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,c=1;0==(t.words[0]&c)&&u<26;++u,c<<=1);if(u>0)for(t.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(l),s.iushrn(1);for(var h=0,d=1;0==(r.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(r.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(l),a.iushrn(1);t.cmp(r)>=0?(t.isub(r),s.isub(a)):(r.isub(t),a.isub(s))}return(i=0===t.cmpn(1)?s:a).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<<t;if(this.length<=r)return this._expand(r+1),this.words[r]|=i,this;for(var o=i,s=r;0!==o&&s<this.length;s++){var a=0|this.words[s];o=(a+=o)>>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:i<e?-1:1}return 0!==this.negative?0|-t:t},o.prototype.cmp=function(e){if(0!==this.negative&&0===e.negative)return-1;if(0===this.negative&&0!==e.negative)return 1;var t=this.ucmp(e);return 0!==this.negative?0|-t:t},o.prototype.ucmp=function(e){if(this.length>e.length)return 1;if(this.length<e.length)return-1;for(var t=0,r=this.length-1;r>=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){n<i?t=-1:n>i&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new E(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var g={k256:null,p224:null,p192:null,p25519:null};function v(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function w(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function _(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function S(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function k(e){E.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}v.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},v.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t<this.n?-1:r.ucmp(this.p);return 0===n?(r.words[0]=0,r.length=1):n>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(e,t){e.iushrn(this.n,0,t)},v.prototype.imulK=function(e){return e.imul(this.k)},i(b,v),b.prototype.split=function(e,t){for(var r=4194303,n=Math.min(e.length,9),i=0;i<n;i++)t.words[i]=e.words[i];if(t.length=n,e.length<=9)return e.words[0]=0,void(e.length=1);var o=e.words[9];for(t.words[t.length++]=o&r,i=10;i<e.length;i++){var s=0|e.words[i];e.words[i-10]=(s&r)<<4|o>>>22,o=s}o>>>=22,e.words[i-10]=o,0===o&&e.length>10?e.length-=10:e.length-=9},b.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r<e.length;r++){var n=0|e.words[r];t+=977*n,e.words[r]=67108863&t,t=64*n+(t/67108864|0)}return 0===e.words[e.length-1]&&(e.length--,0===e.words[e.length-1]&&e.length--),e},i(w,v),i(_,v),i(S,v),S.prototype.imulK=function(e){for(var t=0,r=0;r<e.length;r++){var n=19*(0|e.words[r])+t,i=67108863&n;n>>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(g[e])return g[e];var t;if("k256"===e)t=new b;else if("p224"===e)t=new w;else if("p192"===e)t=new _;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new S}return g[e]=t,t},E.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},E.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},E.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},E.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},E.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},E.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},E.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},E.prototype.isqr=function(e){return this.imul(e,e.clone())},E.prototype.sqr=function(e){return this.mul(e,e)},E.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);n(!i.isZero());var a=new o(1).toRed(this),l=a.redNeg(),u=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new o(2*c*c).toRed(this);0!==this.pow(c,u).cmp(l);)c.redIAdd(l);for(var h=this.pow(c,i),d=this.pow(e,i.addn(1).iushrn(1)),f=this.pow(e,i),p=s;0!==f.cmp(a);){for(var m=f,y=0;0!==m.cmp(a);y++)m=m.redSqr();n(y<p);var g=this.pow(h,new o(1).iushln(p-y-1));d=d.redMul(g),h=g.redSqr(),f=f.redMul(h),p=y}return d},E.prototype.invm=function(e){var t=e._invmp(this.m);return 0!==t.negative?(t.negative=0,this.imod(t).redNeg()):this.imod(t)},E.prototype.pow=function(e,t){if(t.isZero())return new o(1).toRed(this);if(0===t.cmpn(1))return e.clone();var r=new Array(16);r[0]=new o(1).toRed(this),r[1]=e;for(var n=2;n<r.length;n++)r[n]=this.mul(r[n-1],e);var i=r[0],s=0,a=0,l=t.bitLength()%26;for(0===l&&(l=26),n=t.length-1;n>=0;n--){for(var u=t.words[n],c=l-1;c>=0;c--){var h=u>>c&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==s?(s<<=1,s|=h,(4==++a||0===n&&0===c)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}l=26}return i},E.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},E.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new k(e)},i(k,E),k.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},k.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},k.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},k.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},k.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e=r.nmd(e),this)},9982:(e,t,r)=>{"use strict";r.r(t),r.d(t,{BaseContract:()=>Bn,BigNumber:()=>J,Contract:()=>Mn,ContractFactory:()=>In,FixedNumber:()=>Gn,Signer:()=>lr,VoidSigner:()=>ur,Wallet:()=>bo,Wordlist:()=>_i,constants:()=>i,errors:()=>y,ethers:()=>l,getDefaultProvider:()=>Va,logger:()=>hl,providers:()=>o,utils:()=>a,version:()=>cl,wordlists:()=>Ai});var n={};r.r(n),r.d(n,{decode:()=>Pe,encode:()=>Ee});var i={};r.r(i),r.d(i,{AddressZero:()=>So,EtherSymbol:()=>ko,HashZero:()=>Eo,MaxInt256:()=>mt,MaxUint256:()=>ft,MinInt256:()=>pt,NegativeOne:()=>lt,One:()=>ct,Two:()=>ht,WeiPerEther:()=>dt,Zero:()=>ut});var o={};r.r(o),r.d(o,{AlchemyProvider:()=>na,AlchemyWebSocketProvider:()=>ra,BaseProvider:()=>Ms,CloudflareProvider:()=>oa,EtherscanProvider:()=>pa,FallbackProvider:()=>Ta,Formatter:()=>ls,InfuraProvider:()=>Ia,InfuraWebSocketProvider:()=>Ma,IpcProvider:()=>Na,JsonRpcBatchProvider:()=>Oa,JsonRpcProvider:()=>Gs,JsonRpcSigner:()=>qs,NodesmithProvider:()=>Ka,PocketProvider:()=>ja,Provider:()=>nr,Resolver:()=>Ns,StaticJsonRpcProvider:()=>Qs,UrlJsonRpcProvider:()=>Ys,Web3Provider:()=>Wa,WebSocketProvider:()=>Zs,getDefaultProvider:()=>Va,getNetwork:()=>Bo,isCommunityResourcable:()=>us,isCommunityResource:()=>cs,showThrottleMessage:()=>ds});var s={};r.r(s),r.d(s,{decode:()=>$o,encode:()=>Zo});var a={};r.r(a),r.d(a,{AbiCoder:()=>Gt,ConstructorFragment:()=>It,ErrorFragment:()=>Kt,EventFragment:()=>Nt,FormatTypes:()=>At,Fragment:()=>Tt,FunctionFragment:()=>Ot,HDNode:()=>Di,Indexed:()=>Xt,Interface:()=>er,LogDescription:()=>Jt,Logger:()=>v,ParamType:()=>xt,RLP:()=>n,SigningKey:()=>Xr,SupportedAlgorithm:()=>fi,TransactionDescription:()=>$t,TransactionTypes:()=>tn,UnicodeNormalizationForm:()=>Fe,Utf8ErrorFuncs:()=>qe,Utf8ErrorReason:()=>je,_TypedDataEncoder:()=>ci,_fetchData:()=>ts,_toEscapedUtf8String:()=>Ve,accessListify:()=>hn,arrayify:()=>A,base58:()=>di,base64:()=>s,checkProperties:()=>ne,checkResultErrors:()=>de,commify:()=>ol,computeAddress:()=>an,computeHmac:()=>vi,computePublicKey:()=>Yr,concat:()=>P,deepCopy:()=>le,defaultAbiCoder:()=>Vt,defaultPath:()=>Oi,defineReadOnly:()=>ee,entropyToMnemonic:()=>Fi,fetchJson:()=>rs,formatBytes32String:()=>tl,formatEther:()=>ll,formatUnits:()=>sl,getAccountPath:()=>Li,getAddress:()=>Me,getContractAddress:()=>De,getCreate2Address:()=>Ke,getIcapAddress:()=>Oe,getJsonWalletAddress:()=>oo,getStatic:()=>te,hashMessage:()=>Jn,hexConcat:()=>I,hexDataLength:()=>B,hexDataSlice:()=>M,hexStripZeros:()=>D,hexValue:()=>O,hexZeroPad:()=>K,hexlify:()=>R,id:()=>Ze,isAddress:()=>Ie,isBytes:()=>k,isBytesLike:()=>S,isHexString:()=>T,isValidMnemonic:()=>ji,isValidName:()=>Ho,joinSignature:()=>F,keccak256:()=>ve,mnemonicToEntropy:()=>Ui,mnemonicToSeed:()=>Ki,namehash:()=>Jo,nameprep:()=>zo,parseBytes32String:()=>rl,parseEther:()=>ul,parseTransaction:()=>gn,parseUnits:()=>al,poll:()=>ns,randomBytes:()=>Gi,recoverAddress:()=>ln,recoverPublicKey:()=>Qr,resolveProperties:()=>re,ripemd160:()=>mi,serializeTransaction:()=>mn,sha256:()=>yi,sha512:()=>gi,shallowCopy:()=>ie,shuffled:()=>ma,solidityKeccak256:()=>Ya,solidityPack:()=>Qa,soliditySha256:()=>el,splitSignature:()=>U,stripZeros:()=>x,toUtf8Bytes:()=>We,toUtf8CodePoints:()=>$e,toUtf8String:()=>Je,verifyMessage:()=>wo,verifyTypedData:()=>_o,zeroPad:()=>C});var l={};r.r(l),r.d(l,{BaseContract:()=>Bn,BigNumber:()=>J,Contract:()=>Mn,ContractFactory:()=>In,FixedNumber:()=>Gn,Signer:()=>lr,VoidSigner:()=>ur,Wallet:()=>bo,Wordlist:()=>_i,constants:()=>i,errors:()=>y,getDefaultProvider:()=>Va,logger:()=>hl,providers:()=>o,utils:()=>a,version:()=>cl,wordlists:()=>Ai});let u=!1,c=!1;const h={debug:1,default:2,info:2,warning:3,error:4,off:5};let d=h.default,f=null;const p=function(){try{const e=[];if(["NFD","NFC","NFKD","NFKC"].forEach((t=>{try{if("test"!=="test".normalize(t))throw new Error("bad normalize")}catch(r){e.push(t)}})),e.length)throw new Error("missing "+e.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(e){return e.message}return null}();var m,y;!function(e){e.DEBUG="DEBUG",e.INFO="INFO",e.WARNING="WARNING",e.ERROR="ERROR",e.OFF="OFF"}(m||(m={})),function(e){e.UNKNOWN_ERROR="UNKNOWN_ERROR",e.NOT_IMPLEMENTED="NOT_IMPLEMENTED",e.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",e.NETWORK_ERROR="NETWORK_ERROR",e.SERVER_ERROR="SERVER_ERROR",e.TIMEOUT="TIMEOUT",e.BUFFER_OVERRUN="BUFFER_OVERRUN",e.NUMERIC_FAULT="NUMERIC_FAULT",e.MISSING_NEW="MISSING_NEW",e.INVALID_ARGUMENT="INVALID_ARGUMENT",e.MISSING_ARGUMENT="MISSING_ARGUMENT",e.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",e.CALL_EXCEPTION="CALL_EXCEPTION",e.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",e.NONCE_EXPIRED="NONCE_EXPIRED",e.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",e.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",e.TRANSACTION_REPLACED="TRANSACTION_REPLACED"}(y||(y={}));const g="0123456789abcdef";class v{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){const r=e.toLowerCase();null==h[r]&&this.throwArgumentError("invalid log level name","logLevel",e),d>h[r]||console.log.apply(console,t)}debug(...e){this._log(v.levels.DEBUG,e)}info(...e){this._log(v.levels.INFO,e)}warn(...e){this._log(v.levels.WARNING,e)}makeError(e,t,r){if(c)return this.makeError("censored error",t,{});t||(t=v.errors.UNKNOWN_ERROR),r||(r={});const n=[];Object.keys(r).forEach((e=>{const t=r[e];try{if(t instanceof Uint8Array){let r="";for(let e=0;e<t.length;e++)r+=g[t[e]>>4],r+=g[15&t[e]];n.push(e+"=Uint8Array(0x"+r+")")}else n.push(e+"="+JSON.stringify(t))}catch(t){n.push(e+"="+JSON.stringify(r[e].toString()))}})),n.push(`code=${t}`),n.push(`version=${this.version}`);const i=e;n.length&&(e+=" ("+n.join(", ")+")");const o=new Error(e);return o.reason=i,o.code=t,Object.keys(r).forEach((function(e){o[e]=r[e]})),o}throwError(e,t,r){throw this.makeError(e,t,r)}throwArgumentError(e,t,r){return this.throwError(e,v.errors.INVALID_ARGUMENT,{argument:t,value:r})}assert(e,t,r,n){e||this.throwError(t,r,n)}assertArgument(e,t,r,n){e||this.throwArgumentError(t,r,n)}checkNormalize(e){null==e&&(e="platform missing String.prototype.normalize"),p&&this.throwError("platform missing String.prototype.normalize",v.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:p})}checkSafeUint53(e,t){"number"==typeof e&&(null==t&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,v.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,v.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,t,r){r=r?": "+r:"",e<t&&this.throwError("missing argument"+r,v.errors.MISSING_ARGUMENT,{count:e,expectedCount:t}),e>t&&this.throwError("too many arguments"+r,v.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})}checkNew(e,t){e!==Object&&null!=e||this.throwError("missing new",v.errors.MISSING_NEW,{name:t.name})}checkAbstract(e,t){e===t?this.throwError("cannot instantiate abstract class "+JSON.stringify(t.name)+" directly; use a sub-class",v.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):e!==Object&&null!=e||this.throwError("missing new",v.errors.MISSING_NEW,{name:t.name})}static globalLogger(){return f||(f=new v("logger/5.5.0")),f}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",v.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),u){if(!e)return;this.globalLogger().throwError("error censorship permanent",v.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}c=!!e,u=!!t}static setLogLevel(e){const t=h[e.toLowerCase()];null!=t?d=t:v.globalLogger().warn("invalid log level - "+e)}static from(e){return new v(e)}}v.errors=y,v.levels=m;const b=new v("bytes/5.5.0");function w(e){return!!e.toHexString}function _(e){return e.slice||(e.slice=function(){const t=Array.prototype.slice.call(arguments);return _(new Uint8Array(Array.prototype.slice.apply(e,t)))}),e}function S(e){return T(e)&&!(e.length%2)||k(e)}function E(e){return"number"==typeof e&&e==e&&e%1==0}function k(e){if(null==e)return!1;if(e.constructor===Uint8Array)return!0;if("string"==typeof e)return!1;if(!E(e.length)||e.length<0)return!1;for(let t=0;t<e.length;t++){const r=e[t];if(!E(r)||r<0||r>=256)return!1}return!0}function A(e,t){if(t||(t={}),"number"==typeof e){b.checkSafeUint53(e,"invalid arrayify value");const t=[];for(;e;)t.unshift(255&e),e=parseInt(String(e/256));return 0===t.length&&t.push(0),_(new Uint8Array(t))}if(t.allowMissingPrefix&&"string"==typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),w(e)&&(e=e.toHexString()),T(e)){let r=e.substring(2);r.length%2&&("left"===t.hexPad?r="0x0"+r.substring(2):"right"===t.hexPad?r+="0":b.throwArgumentError("hex data is odd-length","value",e));const n=[];for(let e=0;e<r.length;e+=2)n.push(parseInt(r.substring(e,e+2),16));return _(new Uint8Array(n))}return k(e)?_(new Uint8Array(e)):b.throwArgumentError("invalid arrayify value","value",e)}function P(e){const t=e.map((e=>A(e))),r=t.reduce(((e,t)=>e+t.length),0),n=new Uint8Array(r);return t.reduce(((e,t)=>(n.set(t,e),e+t.length)),0),_(n)}function x(e){let t=A(e);if(0===t.length)return t;let r=0;for(;r<t.length&&0===t[r];)r++;return r&&(t=t.slice(r)),t}function C(e,t){(e=A(e)).length>t&&b.throwArgumentError("value out of range","value",arguments[0]);const r=new Uint8Array(t);return r.set(e,t-e.length),_(r)}function T(e,t){return!("string"!=typeof e||!e.match(/^0x[0-9A-Fa-f]*$/)||t&&e.length!==2+2*t)}const N="0123456789abcdef";function R(e,t){if(t||(t={}),"number"==typeof e){b.checkSafeUint53(e,"invalid hexlify value");let t="";for(;e;)t=N[15&e]+t,e=Math.floor(e/16);return t.length?(t.length%2&&(t="0"+t),"0x"+t):"0x00"}if("bigint"==typeof e)return(e=e.toString(16)).length%2?"0x0"+e:"0x"+e;if(t.allowMissingPrefix&&"string"==typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),w(e))return e.toHexString();if(T(e))return e.length%2&&("left"===t.hexPad?e="0x0"+e.substring(2):"right"===t.hexPad?e+="0":b.throwArgumentError("hex data is odd-length","value",e)),e.toLowerCase();if(k(e)){let t="0x";for(let r=0;r<e.length;r++){let n=e[r];t+=N[(240&n)>>4]+N[15&n]}return t}return b.throwArgumentError("invalid hexlify value","value",e)}function B(e){if("string"!=typeof e)e=R(e);else if(!T(e)||e.length%2)return null;return(e.length-2)/2}function M(e,t,r){return"string"!=typeof e?e=R(e):(!T(e)||e.length%2)&&b.throwArgumentError("invalid hexData","value",e),t=2+2*t,null!=r?"0x"+e.substring(t,2+2*r):"0x"+e.substring(t)}function I(e){let t="0x";return e.forEach((e=>{t+=R(e).substring(2)})),t}function O(e){const t=D(R(e,{hexPad:"left"}));return"0x"===t?"0x0":t}function D(e){"string"!=typeof e&&(e=R(e)),T(e)||b.throwArgumentError("invalid hex string","value",e),e=e.substring(2);let t=0;for(;t<e.length&&"0"===e[t];)t++;return"0x"+e.substring(t)}function K(e,t){for("string"!=typeof e?e=R(e):T(e)||b.throwArgumentError("invalid hex string","value",e),e.length>2*t+2&&b.throwArgumentError("value out of range","value",arguments[1]);e.length<2*t+2;)e="0x0"+e.substring(2);return e}function U(e){const t={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0};if(S(e)){const r=A(e);65!==r.length&&b.throwArgumentError("invalid signature string; must be 65 bytes","signature",e),t.r=R(r.slice(0,32)),t.s=R(r.slice(32,64)),t.v=r[64],t.v<27&&(0===t.v||1===t.v?t.v+=27:b.throwArgumentError("signature invalid v byte","signature",e)),t.recoveryParam=1-t.v%2,t.recoveryParam&&(r[32]|=128),t._vs=R(r.slice(32,64))}else{if(t.r=e.r,t.s=e.s,t.v=e.v,t.recoveryParam=e.recoveryParam,t._vs=e._vs,null!=t._vs){const r=C(A(t._vs),32);t._vs=R(r);const n=r[0]>=128?1:0;null==t.recoveryParam?t.recoveryParam=n:t.recoveryParam!==n&&b.throwArgumentError("signature recoveryParam mismatch _vs","signature",e),r[0]&=127;const i=R(r);null==t.s?t.s=i:t.s!==i&&b.throwArgumentError("signature v mismatch _vs","signature",e)}if(null==t.recoveryParam)null==t.v?b.throwArgumentError("signature missing v and recoveryParam","signature",e):0===t.v||1===t.v?t.recoveryParam=t.v:t.recoveryParam=1-t.v%2;else if(null==t.v)t.v=27+t.recoveryParam;else{const r=0===t.v||1===t.v?t.v:1-t.v%2;t.recoveryParam!==r&&b.throwArgumentError("signature recoveryParam mismatch v","signature",e)}null!=t.r&&T(t.r)?t.r=K(t.r,32):b.throwArgumentError("signature missing or invalid r","signature",e),null!=t.s&&T(t.s)?t.s=K(t.s,32):b.throwArgumentError("signature missing or invalid s","signature",e);const r=A(t.s);r[0]>=128&&b.throwArgumentError("signature s out of range","signature",e),t.recoveryParam&&(r[0]|=128);const n=R(r);t._vs&&(T(t._vs)||b.throwArgumentError("signature invalid _vs","signature",e),t._vs=K(t._vs,32)),null==t._vs?t._vs=n:t._vs!==n&&b.throwArgumentError("signature _vs mismatch v and s","signature",e)}return t}function F(e){return R(P([(e=U(e)).r,e.s,e.recoveryParam?"0x1c":"0x1b"]))}var j=r(3550),L=r.n(j);const q="bignumber/5.5.0";var z=L().BN;const W=new v(q),G={},V=9007199254740991;let H=!1;class J{constructor(e,t){W.checkNew(new.target,J),e!==G&&W.throwError("cannot call constructor directly; use BigNumber.from",v.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=t,this._isBigNumber=!0,Object.freeze(this)}fromTwos(e){return Z(X(this).fromTwos(e))}toTwos(e){return Z(X(this).toTwos(e))}abs(){return"-"===this._hex[0]?J.from(this._hex.substring(1)):this}add(e){return Z(X(this).add(X(e)))}sub(e){return Z(X(this).sub(X(e)))}div(e){return J.from(e).isZero()&&Q("division by zero","div"),Z(X(this).div(X(e)))}mul(e){return Z(X(this).mul(X(e)))}mod(e){const t=X(e);return t.isNeg()&&Q("cannot modulo negative values","mod"),Z(X(this).umod(t))}pow(e){const t=X(e);return t.isNeg()&&Q("cannot raise to negative values","pow"),Z(X(this).pow(t))}and(e){const t=X(e);return(this.isNegative()||t.isNeg())&&Q("cannot 'and' negative values","and"),Z(X(this).and(t))}or(e){const t=X(e);return(this.isNegative()||t.isNeg())&&Q("cannot 'or' negative values","or"),Z(X(this).or(t))}xor(e){const t=X(e);return(this.isNegative()||t.isNeg())&&Q("cannot 'xor' negative values","xor"),Z(X(this).xor(t))}mask(e){return(this.isNegative()||e<0)&&Q("cannot mask negative values","mask"),Z(X(this).maskn(e))}shl(e){return(this.isNegative()||e<0)&&Q("cannot shift negative values","shl"),Z(X(this).shln(e))}shr(e){return(this.isNegative()||e<0)&&Q("cannot shift negative values","shr"),Z(X(this).shrn(e))}eq(e){return X(this).eq(X(e))}lt(e){return X(this).lt(X(e))}lte(e){return X(this).lte(X(e))}gt(e){return X(this).gt(X(e))}gte(e){return X(this).gte(X(e))}isNegative(){return"-"===this._hex[0]}isZero(){return X(this).isZero()}toNumber(){try{return X(this).toNumber()}catch(e){Q("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(e){}return W.throwError("this platform does not support BigInt",v.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?H||(H=!0,W.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?W.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",v.errors.UNEXPECTED_ARGUMENT,{}):W.throwError("BigNumber.toString does not accept parameters",v.errors.UNEXPECTED_ARGUMENT,{})),X(this).toString(10)}toHexString(){return this._hex}toJSON(e){return{type:"BigNumber",hex:this.toHexString()}}static from(e){if(e instanceof J)return e;if("string"==typeof e)return e.match(/^-?0x[0-9a-f]+$/i)?new J(G,$(e)):e.match(/^-?[0-9]+$/)?new J(G,$(new z(e))):W.throwArgumentError("invalid BigNumber string","value",e);if("number"==typeof e)return e%1&&Q("underflow","BigNumber.from",e),(e>=V||e<=-V)&&Q("overflow","BigNumber.from",e),J.from(String(e));const t=e;if("bigint"==typeof t)return J.from(t.toString());if(k(t))return J.from(R(t));if(t)if(t.toHexString){const e=t.toHexString();if("string"==typeof e)return J.from(e)}else{let e=t._hex;if(null==e&&"BigNumber"===t.type&&(e=t.hex),"string"==typeof e&&(T(e)||"-"===e[0]&&T(e.substring(1))))return J.from(e)}return W.throwArgumentError("invalid BigNumber value","value",e)}static isBigNumber(e){return!(!e||!e._isBigNumber)}}function $(e){if("string"!=typeof e)return $(e.toString(16));if("-"===e[0])return"-"===(e=e.substring(1))[0]&&W.throwArgumentError("invalid hex","value",e),"0x00"===(e=$(e))?e:"-"+e;if("0x"!==e.substring(0,2)&&(e="0x"+e),"0x"===e)return"0x00";for(e.length%2&&(e="0x0"+e.substring(2));e.length>4&&"0x00"===e.substring(0,4);)e="0x"+e.substring(4);return e}function Z(e){return J.from($(e))}function X(e){const t=J.from(e).toHexString();return"-"===t[0]?new z("-"+t.substring(3),16):new z(t.substring(2),16)}function Q(e,t,r){const n={fault:e,operation:t};return null!=r&&(n.value=r),W.throwError(e,v.errors.NUMERIC_FAULT,n)}const Y=new v("properties/5.5.0");function ee(e,t,r){Object.defineProperty(e,t,{enumerable:!0,value:r,writable:!1})}function te(e,t){for(let r=0;r<32;r++){if(e[t])return e[t];if(!e.prototype||"object"!=typeof e.prototype)break;e=Object.getPrototypeOf(e.prototype).constructor}return null}function re(e){return t=this,r=void 0,i=function*(){const t=Object.keys(e).map((t=>{const r=e[t];return Promise.resolve(r).then((e=>({key:t,value:e})))}));return(yield Promise.all(t)).reduce(((e,t)=>(e[t.key]=t.value,e)),{})},new((n=void 0)||(n=Promise))((function(e,o){function s(e){try{l(i.next(e))}catch(e){o(e)}}function a(e){try{l(i.throw(e))}catch(e){o(e)}}function l(t){var r;t.done?e(t.value):(r=t.value,r instanceof n?r:new n((function(e){e(r)}))).then(s,a)}l((i=i.apply(t,r||[])).next())}));var t,r,n,i}function ne(e,t){e&&"object"==typeof e||Y.throwArgumentError("invalid object","object",e),Object.keys(e).forEach((r=>{t[r]||Y.throwArgumentError("invalid object key - "+r,"transaction:"+r,e)}))}function ie(e){const t={};for(const r in e)t[r]=e[r];return t}const oe={bigint:!0,boolean:!0,function:!0,number:!0,string:!0};function se(e){if(null==e||oe[typeof e])return!0;if(Array.isArray(e)||"object"==typeof e){if(!Object.isFrozen(e))return!1;const t=Object.keys(e);for(let r=0;r<t.length;r++){let n=null;try{n=e[t[r]]}catch(e){continue}if(!se(n))return!1}return!0}return Y.throwArgumentError("Cannot deepCopy "+typeof e,"object",e)}function ae(e){if(se(e))return e;if(Array.isArray(e))return Object.freeze(e.map((e=>le(e))));if("object"==typeof e){const t={};for(const r in e){const n=e[r];void 0!==n&&ee(t,r,le(n))}return t}return Y.throwArgumentError("Cannot deepCopy "+typeof e,"object",e)}function le(e){return ae(e)}class ue{constructor(e){for(const t in e)this[t]=le(e[t])}}const ce="abi/5.5.0",he=new v(ce);function de(e){const t=[],r=function(e,n){if(Array.isArray(n))for(let i in n){const o=e.slice();o.push(i);try{r(o,n[i])}catch(e){t.push({path:o,error:e})}}};return r([],e),t}class fe{constructor(e,t,r,n){this.name=e,this.type=t,this.localName=r,this.dynamic=n}_throwError(e,t){he.throwArgumentError(e,this.localName,t)}}class pe{constructor(e){ee(this,"wordSize",e||32),this._data=[],this._dataLength=0,this._padding=new Uint8Array(e)}get data(){return I(this._data)}get length(){return this._dataLength}_writeData(e){return this._data.push(e),this._dataLength+=e.length,e.length}appendWriter(e){return this._writeData(P(e._data))}writeBytes(e){let t=A(e);const r=t.length%this.wordSize;return r&&(t=P([t,this._padding.slice(r)])),this._writeData(t)}_getValue(e){let t=A(J.from(e));return t.length>this.wordSize&&he.throwError("value out-of-bounds",v.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:t.length}),t.length%this.wordSize&&(t=P([this._padding.slice(t.length%this.wordSize),t])),t}writeValue(e){return this._writeData(this._getValue(e))}writeUpdatableValue(){const e=this._data.length;return this._data.push(this._padding),this._dataLength+=this.wordSize,t=>{this._data[e]=this._getValue(t)}}}class me{constructor(e,t,r,n){ee(this,"_data",A(e)),ee(this,"wordSize",t||32),ee(this,"_coerceFunc",r),ee(this,"allowLoose",n),this._offset=0}get data(){return R(this._data)}get consumed(){return this._offset}static coerce(e,t){let r=e.match("^u?int([0-9]+)$");return r&&parseInt(r[1])<=48&&(t=t.toNumber()),t}coerce(e,t){return this._coerceFunc?this._coerceFunc(e,t):me.coerce(e,t)}_peekBytes(e,t,r){let n=Math.ceil(t/this.wordSize)*this.wordSize;return this._offset+n>this._data.length&&(this.allowLoose&&r&&this._offset+t<=this._data.length?n=t:he.throwError("data out-of-bounds",v.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+n})),this._data.slice(this._offset,this._offset+n)}subReader(e){return new me(this._data.slice(this._offset+e),this.wordSize,this._coerceFunc,this.allowLoose)}readBytes(e,t){let r=this._peekBytes(0,e,!!t);return this._offset+=r.length,r.slice(0,e)}readValue(){return J.from(this.readBytes(this.wordSize))}}var ye=r(1094),ge=r.n(ye);function ve(e){return"0x"+ge().keccak_256(A(e))}const be=new v("rlp/5.5.0");function we(e){const t=[];for(;e;)t.unshift(255&e),e>>=8;return t}function _e(e,t,r){let n=0;for(let i=0;i<r;i++)n=256*n+e[t+i];return n}function Se(e){if(Array.isArray(e)){let t=[];if(e.forEach((function(e){t=t.concat(Se(e))})),t.length<=55)return t.unshift(192+t.length),t;const r=we(t.length);return r.unshift(247+r.length),r.concat(t)}S(e)||be.throwArgumentError("RLP object must be BytesLike","object",e);const t=Array.prototype.slice.call(A(e));if(1===t.length&&t[0]<=127)return t;if(t.length<=55)return t.unshift(128+t.length),t;const r=we(t.length);return r.unshift(183+r.length),r.concat(t)}function Ee(e){return R(Se(e))}function ke(e,t,r,n){const i=[];for(;r<t+1+n;){const o=Ae(e,r);i.push(o.result),(r+=o.consumed)>t+1+n&&be.throwError("child data too short",v.errors.BUFFER_OVERRUN,{})}return{consumed:1+n,result:i}}function Ae(e,t){if(0===e.length&&be.throwError("data too short",v.errors.BUFFER_OVERRUN,{}),e[t]>=248){const r=e[t]-247;t+1+r>e.length&&be.throwError("data short segment too short",v.errors.BUFFER_OVERRUN,{});const n=_e(e,t+1,r);return t+1+r+n>e.length&&be.throwError("data long segment too short",v.errors.BUFFER_OVERRUN,{}),ke(e,t,t+1+r,r+n)}if(e[t]>=192){const r=e[t]-192;return t+1+r>e.length&&be.throwError("data array too short",v.errors.BUFFER_OVERRUN,{}),ke(e,t,t+1,r)}if(e[t]>=184){const r=e[t]-183;t+1+r>e.length&&be.throwError("data array too short",v.errors.BUFFER_OVERRUN,{});const n=_e(e,t+1,r);return t+1+r+n>e.length&&be.throwError("data array too short",v.errors.BUFFER_OVERRUN,{}),{consumed:1+r+n,result:R(e.slice(t+1+r,t+1+r+n))}}if(e[t]>=128){const r=e[t]-128;return t+1+r>e.length&&be.throwError("data too short",v.errors.BUFFER_OVERRUN,{}),{consumed:1+r,result:R(e.slice(t+1,t+1+r))}}return{consumed:1,result:R(e[t])}}function Pe(e){const t=A(e),r=Ae(t,0);return r.consumed!==t.length&&be.throwArgumentError("invalid rlp data","data",e),r.result}const xe=new v("address/5.5.0");function Ce(e){T(e,20)||xe.throwArgumentError("invalid address","address",e);const t=(e=e.toLowerCase()).substring(2).split(""),r=new Uint8Array(40);for(let e=0;e<40;e++)r[e]=t[e].charCodeAt(0);const n=A(ve(r));for(let e=0;e<40;e+=2)n[e>>1]>>4>=8&&(t[e]=t[e].toUpperCase()),(15&n[e>>1])>=8&&(t[e+1]=t[e+1].toUpperCase());return"0x"+t.join("")}const Te={};for(let e=0;e<10;e++)Te[String(e)]=String(e);for(let e=0;e<26;e++)Te[String.fromCharCode(65+e)]=String(10+e);const Ne=Math.floor((Re=9007199254740991,Math.log10?Math.log10(Re):Math.log(Re)/Math.LN10));var Re;function Be(e){let t=(e=(e=e.toUpperCase()).substring(4)+e.substring(0,2)+"00").split("").map((e=>Te[e])).join("");for(;t.length>=Ne;){let e=t.substring(0,Ne);t=parseInt(e,10)%97+t.substring(e.length)}let r=String(98-parseInt(t,10)%97);for(;r.length<2;)r="0"+r;return r}function Me(e){let t=null;if("string"!=typeof e&&xe.throwArgumentError("invalid address","address",e),e.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==e.substring(0,2)&&(e="0x"+e),t=Ce(e),e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&t!==e&&xe.throwArgumentError("bad address checksum","address",e);else if(e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(e.substring(2,4)!==Be(e)&&xe.throwArgumentError("bad icap checksum","address",e),r=e.substring(4),t=new z(r,36).toString(16);t.length<40;)t="0"+t;t=Ce("0x"+t)}else xe.throwArgumentError("invalid address","address",e);var r;return t}function Ie(e){try{return Me(e),!0}catch(e){}return!1}function Oe(e){let t=(r=Me(e).substring(2),new z(r,16).toString(36)).toUpperCase();for(var r;t.length<30;)t="0"+t;return"XE"+Be("XE00"+t)+t}function De(e){let t=null;try{t=Me(e.from)}catch(t){xe.throwArgumentError("missing from address","transaction",e)}return Me(M(ve(Ee([t,x(A(J.from(e.nonce).toHexString()))])),12))}function Ke(e,t,r){return 32!==B(t)&&xe.throwArgumentError("salt must be 32 bytes","salt",t),32!==B(r)&&xe.throwArgumentError("initCodeHash must be 32 bytes","initCodeHash",r),Me(M(ve(P(["0xff",Me(e),t,r])),12))}const Ue=new v("strings/5.5.0");var Fe,je;function Le(e,t,r,n,i){if(e===je.BAD_PREFIX||e===je.UNEXPECTED_CONTINUE){let e=0;for(let n=t+1;n<r.length&&r[n]>>6==2;n++)e++;return e}return e===je.OVERRUN?r.length-t-1:0}!function(e){e.current="",e.NFC="NFC",e.NFD="NFD",e.NFKC="NFKC",e.NFKD="NFKD"}(Fe||(Fe={})),function(e){e.UNEXPECTED_CONTINUE="unexpected continuation byte",e.BAD_PREFIX="bad codepoint prefix",e.OVERRUN="string overrun",e.MISSING_CONTINUE="missing continuation byte",e.OUT_OF_RANGE="out of UTF-8 range",e.UTF16_SURROGATE="UTF-16 surrogate",e.OVERLONG="overlong representation"}(je||(je={}));const qe=Object.freeze({error:function(e,t,r,n,i){return Ue.throwArgumentError(`invalid codepoint at offset ${t}; ${e}`,"bytes",r)},ignore:Le,replace:function(e,t,r,n,i){return e===je.OVERLONG?(n.push(i),0):(n.push(65533),Le(e,t,r))}});function ze(e,t){null==t&&(t=qe.error),e=A(e);const r=[];let n=0;for(;n<e.length;){const i=e[n++];if(i>>7==0){r.push(i);continue}let o=null,s=null;if(192==(224&i))o=1,s=127;else if(224==(240&i))o=2,s=2047;else{if(240!=(248&i)){n+=t(128==(192&i)?je.UNEXPECTED_CONTINUE:je.BAD_PREFIX,n-1,e,r);continue}o=3,s=65535}if(n-1+o>=e.length){n+=t(je.OVERRUN,n-1,e,r);continue}let a=i&(1<<8-o-1)-1;for(let i=0;i<o;i++){let i=e[n];if(128!=(192&i)){n+=t(je.MISSING_CONTINUE,n,e,r),a=null;break}a=a<<6|63&i,n++}null!==a&&(a>1114111?n+=t(je.OUT_OF_RANGE,n-1-o,e,r,a):a>=55296&&a<=57343?n+=t(je.UTF16_SURROGATE,n-1-o,e,r,a):a<=s?n+=t(je.OVERLONG,n-1-o,e,r,a):r.push(a))}return r}function We(e,t=Fe.current){t!=Fe.current&&(Ue.checkNormalize(),e=e.normalize(t));let r=[];for(let t=0;t<e.length;t++){const n=e.charCodeAt(t);if(n<128)r.push(n);else if(n<2048)r.push(n>>6|192),r.push(63&n|128);else if(55296==(64512&n)){t++;const i=e.charCodeAt(t);if(t>=e.length||56320!=(64512&i))throw new Error("invalid utf-8 string");const o=65536+((1023&n)<<10)+(1023&i);r.push(o>>18|240),r.push(o>>12&63|128),r.push(o>>6&63|128),r.push(63&o|128)}else r.push(n>>12|224),r.push(n>>6&63|128),r.push(63&n|128)}return A(r)}function Ge(e){const t="0000"+e.toString(16);return"\\u"+t.substring(t.length-4)}function Ve(e,t){return'"'+ze(e,t).map((e=>{if(e<256){switch(e){case 8:return"\\b";case 9:return"\\t";case 10:return"\\n";case 13:return"\\r";case 34:return'\\"';case 92:return"\\\\"}if(e>=32&&e<127)return String.fromCharCode(e)}return e<=65535?Ge(e):Ge(55296+((e-=65536)>>10&1023))+Ge(56320+(1023&e))})).join("")+'"'}function He(e){return e.map((e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10&1023),56320+(1023&e))))).join("")}function Je(e,t){return He(ze(e,t))}function $e(e,t=Fe.current){return ze(We(e,t))}function Ze(e){return ve(We(e))}class Xe extends fe{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,t){try{t=Me(t)}catch(e){this._throwError(e.message,t)}return e.writeValue(t)}decode(e){return Me(K(e.readValue().toHexString(),20))}}class Qe extends fe{constructor(e){super(e.name,e.type,void 0,e.dynamic),this.coder=e}defaultValue(){return this.coder.defaultValue()}encode(e,t){return this.coder.encode(e,t)}decode(e){return this.coder.decode(e)}}const Ye=new v(ce);function et(e,t,r){let n=null;if(Array.isArray(r))n=r;else if(r&&"object"==typeof r){let e={};n=t.map((t=>{const n=t.localName;return n||Ye.throwError("cannot encode object for signature with missing names",v.errors.INVALID_ARGUMENT,{argument:"values",coder:t,value:r}),e[n]&&Ye.throwError("cannot encode object for signature with duplicate names",v.errors.INVALID_ARGUMENT,{argument:"values",coder:t,value:r}),e[n]=!0,r[n]}))}else Ye.throwArgumentError("invalid tuple value","tuple",r);t.length!==n.length&&Ye.throwArgumentError("types/value length mismatch","tuple",r);let i=new pe(e.wordSize),o=new pe(e.wordSize),s=[];t.forEach(((e,t)=>{let r=n[t];if(e.dynamic){let t=o.length;e.encode(o,r);let n=i.writeUpdatableValue();s.push((e=>{n(e+t)}))}else e.encode(i,r)})),s.forEach((e=>{e(i.length)}));let a=e.appendWriter(i);return a+=e.appendWriter(o),a}function tt(e,t){let r=[],n=e.subReader(0);t.forEach((t=>{let i=null;if(t.dynamic){let r=e.readValue(),o=n.subReader(r.toNumber());try{i=t.decode(o)}catch(e){if(e.code===v.errors.BUFFER_OVERRUN)throw e;i=e,i.baseType=t.name,i.name=t.localName,i.type=t.type}}else try{i=t.decode(e)}catch(e){if(e.code===v.errors.BUFFER_OVERRUN)throw e;i=e,i.baseType=t.name,i.name=t.localName,i.type=t.type}null!=i&&r.push(i)}));const i=t.reduce(((e,t)=>{const r=t.localName;return r&&(e[r]||(e[r]=0),e[r]++),e}),{});t.forEach(((e,t)=>{let n=e.localName;if(!n||1!==i[n])return;if("length"===n&&(n="_length"),null!=r[n])return;const o=r[t];o instanceof Error?Object.defineProperty(r,n,{enumerable:!0,get:()=>{throw o}}):r[n]=o}));for(let e=0;e<r.length;e++){const t=r[e];t instanceof Error&&Object.defineProperty(r,e,{enumerable:!0,get:()=>{throw t}})}return Object.freeze(r)}class rt extends fe{constructor(e,t,r){super("array",e.type+"["+(t>=0?t:"")+"]",r,-1===t||e.dynamic),this.coder=e,this.length=t}defaultValue(){const e=this.coder.defaultValue(),t=[];for(let r=0;r<this.length;r++)t.push(e);return t}encode(e,t){Array.isArray(t)||this._throwError("expected array value",t);let r=this.length;-1===r&&(r=t.length,e.writeValue(t.length)),Ye.checkArgumentCount(t.length,r,"coder array"+(this.localName?" "+this.localName:""));let n=[];for(let e=0;e<t.length;e++)n.push(this.coder);return et(e,n,t)}decode(e){let t=this.length;-1===t&&(t=e.readValue().toNumber(),32*t>e._data.length&&Ye.throwError("insufficient data length",v.errors.BUFFER_OVERRUN,{length:e._data.length,count:t}));let r=[];for(let e=0;e<t;e++)r.push(new Qe(this.coder));return e.coerce(this.name,tt(e,r))}}class nt extends fe{constructor(e){super("bool","bool",e,!1)}defaultValue(){return!1}encode(e,t){return e.writeValue(t?1:0)}decode(e){return e.coerce(this.type,!e.readValue().isZero())}}class it extends fe{constructor(e,t){super(e,e,t,!0)}defaultValue(){return"0x"}encode(e,t){t=A(t);let r=e.writeValue(t.length);return r+=e.writeBytes(t),r}decode(e){return e.readBytes(e.readValue().toNumber(),!0)}}class ot extends it{constructor(e){super("bytes",e)}decode(e){return e.coerce(this.name,R(super.decode(e)))}}class st extends fe{constructor(e,t){let r="bytes"+String(e);super(r,r,t,!1),this.size=e}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+2*this.size)}encode(e,t){let r=A(t);return r.length!==this.size&&this._throwError("incorrect data length",t),e.writeBytes(r)}decode(e){return e.coerce(this.name,R(e.readBytes(this.size)))}}class at extends fe{constructor(e){super("null","",e,!1)}defaultValue(){return null}encode(e,t){return null!=t&&this._throwError("not null",t),e.writeBytes([])}decode(e){return e.readBytes(0),e.coerce(this.name,null)}}const lt=J.from(-1),ut=J.from(0),ct=J.from(1),ht=J.from(2),dt=J.from("1000000000000000000"),ft=J.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),pt=J.from("-0x8000000000000000000000000000000000000000000000000000000000000000"),mt=J.from("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class yt extends fe{constructor(e,t,r){const n=(t?"int":"uint")+8*e;super(n,n,r,!1),this.size=e,this.signed=t}defaultValue(){return 0}encode(e,t){let r=J.from(t),n=ft.mask(8*e.wordSize);if(this.signed){let e=n.mask(8*this.size-1);(r.gt(e)||r.lt(e.add(ct).mul(lt)))&&this._throwError("value out-of-bounds",t)}else(r.lt(ut)||r.gt(n.mask(8*this.size)))&&this._throwError("value out-of-bounds",t);return r=r.toTwos(8*this.size).mask(8*this.size),this.signed&&(r=r.fromTwos(8*this.size).toTwos(8*e.wordSize)),e.writeValue(r)}decode(e){let t=e.readValue().mask(8*this.size);return this.signed&&(t=t.fromTwos(8*this.size)),e.coerce(this.name,t)}}class gt extends it{constructor(e){super("string",e)}defaultValue(){return""}encode(e,t){return super.encode(e,We(t))}decode(e){return Je(super.decode(e))}}class vt extends fe{constructor(e,t){let r=!1;const n=[];e.forEach((e=>{e.dynamic&&(r=!0),n.push(e.type)})),super("tuple","tuple("+n.join(",")+")",t,r),this.coders=e}defaultValue(){const e=[];this.coders.forEach((t=>{e.push(t.defaultValue())}));const t=this.coders.reduce(((e,t)=>{const r=t.localName;return r&&(e[r]||(e[r]=0),e[r]++),e}),{});return this.coders.forEach(((r,n)=>{let i=r.localName;i&&1===t[i]&&("length"===i&&(i="_length"),null==e[i]&&(e[i]=e[n]))})),Object.freeze(e)}encode(e,t){return et(e,this.coders,t)}decode(e){return e.coerce(this.name,tt(e,this.coders))}}const bt=new v(ce),wt={};let _t={calldata:!0,memory:!0,storage:!0},St={calldata:!0,memory:!0};function Et(e,t){if("bytes"===e||"string"===e){if(_t[t])return!0}else if("address"===e){if("payable"===t)return!0}else if((e.indexOf("[")>=0||"tuple"===e)&&St[t])return!0;return(_t[t]||"payable"===t)&&bt.throwArgumentError("invalid modifier","name",t),!1}function kt(e,t){for(let r in t)ee(e,r,t[r])}const At=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"}),Pt=new RegExp(/^(.*)\[([0-9]*)\]$/);class xt{constructor(e,t){e!==wt&&bt.throwError("use fromString",v.errors.UNSUPPORTED_OPERATION,{operation:"new ParamType()"}),kt(this,t);let r=this.type.match(Pt);kt(this,r?{arrayLength:parseInt(r[2]||"-1"),arrayChildren:xt.fromObject({type:r[1],components:this.components}),baseType:"array"}:{arrayLength:null,arrayChildren:null,baseType:null!=this.components?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}format(e){if(e||(e=At.sighash),At[e]||bt.throwArgumentError("invalid format type","format",e),e===At.json){let t={type:"tuple"===this.baseType?"tuple":this.type,name:this.name||void 0};return"boolean"==typeof this.indexed&&(t.indexed=this.indexed),this.components&&(t.components=this.components.map((t=>JSON.parse(t.format(e))))),JSON.stringify(t)}let t="";return"array"===this.baseType?(t+=this.arrayChildren.format(e),t+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):"tuple"===this.baseType?(e!==At.sighash&&(t+=this.type),t+="("+this.components.map((t=>t.format(e))).join(e===At.full?", ":",")+")"):t+=this.type,e!==At.sighash&&(!0===this.indexed&&(t+=" indexed"),e===At.full&&this.name&&(t+=" "+this.name)),t}static from(e,t){return"string"==typeof e?xt.fromString(e,t):xt.fromObject(e)}static fromObject(e){return xt.isParamType(e)?e:new xt(wt,{name:e.name||null,type:Ut(e.type),indexed:null==e.indexed?null:!!e.indexed,components:e.components?e.components.map(xt.fromObject):null})}static fromString(e,t){return r=function(e,t){let r=e;function n(t){bt.throwArgumentError(`unexpected character at position ${t}`,"param",e)}function i(e){let r={type:"",name:"",parent:e,state:{allowType:!0}};return t&&(r.indexed=!1),r}e=e.replace(/\s/g," ");let o={type:"",name:"",state:{allowType:!0}},s=o;for(let r=0;r<e.length;r++){let o=e[r];switch(o){case"(":s.state.allowType&&""===s.type?s.type="tuple":s.state.allowParams||n(r),s.state.allowType=!1,s.type=Ut(s.type),s.components=[i(s)],s=s.components[0];break;case")":delete s.state,"indexed"===s.name&&(t||n(r),s.indexed=!0,s.name=""),Et(s.type,s.name)&&(s.name=""),s.type=Ut(s.type);let e=s;s=s.parent,s||n(r),delete e.parent,s.state.allowParams=!1,s.state.allowName=!0,s.state.allowArray=!0;break;case",":delete s.state,"indexed"===s.name&&(t||n(r),s.indexed=!0,s.name=""),Et(s.type,s.name)&&(s.name=""),s.type=Ut(s.type);let a=i(s.parent);s.parent.components.push(a),delete s.parent,s=a;break;case" ":s.state.allowType&&""!==s.type&&(s.type=Ut(s.type),delete s.state.allowType,s.state.allowName=!0,s.state.allowParams=!0),s.state.allowName&&""!==s.name&&("indexed"===s.name?(t||n(r),s.indexed&&n(r),s.indexed=!0,s.name=""):Et(s.type,s.name)?s.name="":s.state.allowName=!1);break;case"[":s.state.allowArray||n(r),s.type+=o,s.state.allowArray=!1,s.state.allowName=!1,s.state.readArray=!0;break;case"]":s.state.readArray||n(r),s.type+=o,s.state.readArray=!1,s.state.allowArray=!0,s.state.allowName=!0;break;default:s.state.allowType?(s.type+=o,s.state.allowParams=!0,s.state.allowArray=!0):s.state.allowName?(s.name+=o,delete s.state.allowArray):s.state.readArray?s.type+=o:n(r)}}return s.parent&&bt.throwArgumentError("unexpected eof","param",e),delete o.state,"indexed"===s.name?(t||n(r.length-7),s.indexed&&n(r.length-7),s.indexed=!0,s.name=""):Et(s.type,s.name)&&(s.name=""),o.type=Ut(o.type),o}(e,!!t),xt.fromObject({name:r.name,type:r.type,indexed:r.indexed,components:r.components});var r}static isParamType(e){return!(null==e||!e._isParamType)}}function Ct(e,t){return function(e){e=e.trim();let t=[],r="",n=0;for(let i=0;i<e.length;i++){let o=e[i];","===o&&0===n?(t.push(r),r=""):(r+=o,"("===o?n++:")"===o&&(n--,-1===n&&bt.throwArgumentError("unbalanced parenthesis","value",e)))}return r&&t.push(r),t}(e).map((e=>xt.fromString(e,t)))}class Tt{constructor(e,t){e!==wt&&bt.throwError("use a static from method",v.errors.UNSUPPORTED_OPERATION,{operation:"new Fragment()"}),kt(this,t),this._isFragment=!0,Object.freeze(this)}static from(e){return Tt.isFragment(e)?e:"string"==typeof e?Tt.fromString(e):Tt.fromObject(e)}static fromObject(e){if(Tt.isFragment(e))return e;switch(e.type){case"function":return Ot.fromObject(e);case"event":return Nt.fromObject(e);case"constructor":return It.fromObject(e);case"error":return Kt.fromObject(e);case"fallback":case"receive":return null}return bt.throwArgumentError("invalid fragment object","value",e)}static fromString(e){return"event"===(e=(e=(e=e.replace(/\s/g," ")).replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," ")).trim()).split(" ")[0]?Nt.fromString(e.substring(5).trim()):"function"===e.split(" ")[0]?Ot.fromString(e.substring(8).trim()):"constructor"===e.split("(")[0].trim()?It.fromString(e.trim()):"error"===e.split(" ")[0]?Kt.fromString(e.substring(5).trim()):bt.throwArgumentError("unsupported fragment","value",e)}static isFragment(e){return!(!e||!e._isFragment)}}class Nt extends Tt{format(e){if(e||(e=At.sighash),At[e]||bt.throwArgumentError("invalid format type","format",e),e===At.json)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map((t=>JSON.parse(t.format(e))))});let t="";return e!==At.sighash&&(t+="event "),t+=this.name+"("+this.inputs.map((t=>t.format(e))).join(e===At.full?", ":",")+") ",e!==At.sighash&&this.anonymous&&(t+="anonymous "),t.trim()}static from(e){return"string"==typeof e?Nt.fromString(e):Nt.fromObject(e)}static fromObject(e){if(Nt.isEventFragment(e))return e;"event"!==e.type&&bt.throwArgumentError("invalid event object","value",e);const t={name:jt(e.name),anonymous:e.anonymous,inputs:e.inputs?e.inputs.map(xt.fromObject):[],type:"event"};return new Nt(wt,t)}static fromString(e){let t=e.match(Lt);t||bt.throwArgumentError("invalid event string","value",e);let r=!1;return t[3].split(" ").forEach((e=>{switch(e.trim()){case"anonymous":r=!0;break;case"":break;default:bt.warn("unknown modifier: "+e)}})),Nt.fromObject({name:t[1].trim(),anonymous:r,inputs:Ct(t[2],!0),type:"event"})}static isEventFragment(e){return e&&e._isFragment&&"event"===e.type}}function Rt(e,t){t.gas=null;let r=e.split("@");return 1!==r.length?(r.length>2&&bt.throwArgumentError("invalid human-readable ABI signature","value",e),r[1].match(/^[0-9]+$/)||bt.throwArgumentError("invalid human-readable ABI signature gas","value",e),t.gas=J.from(r[1]),r[0]):e}function Bt(e,t){t.constant=!1,t.payable=!1,t.stateMutability="nonpayable",e.split(" ").forEach((e=>{switch(e.trim()){case"constant":t.constant=!0;break;case"payable":t.payable=!0,t.stateMutability="payable";break;case"nonpayable":t.payable=!1,t.stateMutability="nonpayable";break;case"pure":t.constant=!0,t.stateMutability="pure";break;case"view":t.constant=!0,t.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+e)}}))}function Mt(e){let t={constant:!1,payable:!0,stateMutability:"payable"};return null!=e.stateMutability?(t.stateMutability=e.stateMutability,t.constant="view"===t.stateMutability||"pure"===t.stateMutability,null!=e.constant&&!!e.constant!==t.constant&&bt.throwArgumentError("cannot have constant function with mutability "+t.stateMutability,"value",e),t.payable="payable"===t.stateMutability,null!=e.payable&&!!e.payable!==t.payable&&bt.throwArgumentError("cannot have payable function with mutability "+t.stateMutability,"value",e)):null!=e.payable?(t.payable=!!e.payable,null!=e.constant||t.payable||"constructor"===e.type||bt.throwArgumentError("unable to determine stateMutability","value",e),t.constant=!!e.constant,t.constant?t.stateMutability="view":t.stateMutability=t.payable?"payable":"nonpayable",t.payable&&t.constant&&bt.throwArgumentError("cannot have constant payable function","value",e)):null!=e.constant?(t.constant=!!e.constant,t.payable=!t.constant,t.stateMutability=t.constant?"view":"payable"):"constructor"!==e.type&&bt.throwArgumentError("unable to determine stateMutability","value",e),t}class It extends Tt{format(e){if(e||(e=At.sighash),At[e]||bt.throwArgumentError("invalid format type","format",e),e===At.json)return JSON.stringify({type:"constructor",stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map((t=>JSON.parse(t.format(e))))});e===At.sighash&&bt.throwError("cannot format a constructor for sighash",v.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});let t="constructor("+this.inputs.map((t=>t.format(e))).join(e===At.full?", ":",")+") ";return this.stateMutability&&"nonpayable"!==this.stateMutability&&(t+=this.stateMutability+" "),t.trim()}static from(e){return"string"==typeof e?It.fromString(e):It.fromObject(e)}static fromObject(e){if(It.isConstructorFragment(e))return e;"constructor"!==e.type&&bt.throwArgumentError("invalid constructor object","value",e);let t=Mt(e);t.constant&&bt.throwArgumentError("constructor cannot be constant","value",e);const r={name:null,type:e.type,inputs:e.inputs?e.inputs.map(xt.fromObject):[],payable:t.payable,stateMutability:t.stateMutability,gas:e.gas?J.from(e.gas):null};return new It(wt,r)}static fromString(e){let t={type:"constructor"},r=(e=Rt(e,t)).match(Lt);return r&&"constructor"===r[1].trim()||bt.throwArgumentError("invalid constructor string","value",e),t.inputs=Ct(r[2].trim(),!1),Bt(r[3].trim(),t),It.fromObject(t)}static isConstructorFragment(e){return e&&e._isFragment&&"constructor"===e.type}}class Ot extends It{format(e){if(e||(e=At.sighash),At[e]||bt.throwArgumentError("invalid format type","format",e),e===At.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map((t=>JSON.parse(t.format(e)))),outputs:this.outputs.map((t=>JSON.parse(t.format(e))))});let t="";return e!==At.sighash&&(t+="function "),t+=this.name+"("+this.inputs.map((t=>t.format(e))).join(e===At.full?", ":",")+") ",e!==At.sighash&&(this.stateMutability?"nonpayable"!==this.stateMutability&&(t+=this.stateMutability+" "):this.constant&&(t+="view "),this.outputs&&this.outputs.length&&(t+="returns ("+this.outputs.map((t=>t.format(e))).join(", ")+") "),null!=this.gas&&(t+="@"+this.gas.toString()+" ")),t.trim()}static from(e){return"string"==typeof e?Ot.fromString(e):Ot.fromObject(e)}static fromObject(e){if(Ot.isFunctionFragment(e))return e;"function"!==e.type&&bt.throwArgumentError("invalid function object","value",e);let t=Mt(e);const r={type:e.type,name:jt(e.name),constant:t.constant,inputs:e.inputs?e.inputs.map(xt.fromObject):[],outputs:e.outputs?e.outputs.map(xt.fromObject):[],payable:t.payable,stateMutability:t.stateMutability,gas:e.gas?J.from(e.gas):null};return new Ot(wt,r)}static fromString(e){let t={type:"function"},r=(e=Rt(e,t)).split(" returns ");r.length>2&&bt.throwArgumentError("invalid function string","value",e);let n=r[0].match(Lt);if(n||bt.throwArgumentError("invalid function signature","value",e),t.name=n[1].trim(),t.name&&jt(t.name),t.inputs=Ct(n[2],!1),Bt(n[3].trim(),t),r.length>1){let n=r[1].match(Lt);""==n[1].trim()&&""==n[3].trim()||bt.throwArgumentError("unexpected tokens","value",e),t.outputs=Ct(n[2],!1)}else t.outputs=[];return Ot.fromObject(t)}static isFunctionFragment(e){return e&&e._isFragment&&"function"===e.type}}function Dt(e){const t=e.format();return"Error(string)"!==t&&"Panic(uint256)"!==t||bt.throwArgumentError(`cannot specify user defined ${t} error`,"fragment",e),e}class Kt extends Tt{format(e){if(e||(e=At.sighash),At[e]||bt.throwArgumentError("invalid format type","format",e),e===At.json)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map((t=>JSON.parse(t.format(e))))});let t="";return e!==At.sighash&&(t+="error "),t+=this.name+"("+this.inputs.map((t=>t.format(e))).join(e===At.full?", ":",")+") ",t.trim()}static from(e){return"string"==typeof e?Kt.fromString(e):Kt.fromObject(e)}static fromObject(e){if(Kt.isErrorFragment(e))return e;"error"!==e.type&&bt.throwArgumentError("invalid error object","value",e);const t={type:e.type,name:jt(e.name),inputs:e.inputs?e.inputs.map(xt.fromObject):[]};return Dt(new Kt(wt,t))}static fromString(e){let t={type:"error"},r=e.match(Lt);return r||bt.throwArgumentError("invalid error signature","value",e),t.name=r[1].trim(),t.name&&jt(t.name),t.inputs=Ct(r[2],!1),Dt(Kt.fromObject(t))}static isErrorFragment(e){return e&&e._isFragment&&"error"===e.type}}function Ut(e){return e.match(/^uint($|[^1-9])/)?e="uint256"+e.substring(4):e.match(/^int($|[^1-9])/)&&(e="int256"+e.substring(3)),e}const Ft=new RegExp("^[a-zA-Z$_][a-zA-Z0-9$_]*$");function jt(e){return e&&e.match(Ft)||bt.throwArgumentError(`invalid identifier "${e}"`,"value",e),e}const Lt=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$"),qt=new v(ce),zt=new RegExp(/^bytes([0-9]*)$/),Wt=new RegExp(/^(u?int)([0-9]*)$/);class Gt{constructor(e){qt.checkNew(new.target,Gt),ee(this,"coerceFunc",e||null)}_getCoder(e){switch(e.baseType){case"address":return new Xe(e.name);case"bool":return new nt(e.name);case"string":return new gt(e.name);case"bytes":return new ot(e.name);case"array":return new rt(this._getCoder(e.arrayChildren),e.arrayLength,e.name);case"tuple":return new vt((e.components||[]).map((e=>this._getCoder(e))),e.name);case"":return new at(e.name)}let t=e.type.match(Wt);if(t){let r=parseInt(t[2]||"256");return(0===r||r>256||r%8!=0)&&qt.throwArgumentError("invalid "+t[1]+" bit length","param",e),new yt(r/8,"int"===t[1],e.name)}if(t=e.type.match(zt),t){let r=parseInt(t[1]);return(0===r||r>32)&&qt.throwArgumentError("invalid bytes length","param",e),new st(r,e.name)}return qt.throwArgumentError("invalid type","type",e.type)}_getWordSize(){return 32}_getReader(e,t){return new me(e,this._getWordSize(),this.coerceFunc,t)}_getWriter(){return new pe(this._getWordSize())}getDefaultValue(e){const t=e.map((e=>this._getCoder(xt.from(e))));return new vt(t,"_").defaultValue()}encode(e,t){e.length!==t.length&&qt.throwError("types/values length mismatch",v.errors.INVALID_ARGUMENT,{count:{types:e.length,values:t.length},value:{types:e,values:t}});const r=e.map((e=>this._getCoder(xt.from(e)))),n=new vt(r,"_"),i=this._getWriter();return n.encode(i,t),i.data}decode(e,t,r){const n=e.map((e=>this._getCoder(xt.from(e))));return new vt(n,"_").decode(this._getReader(A(t),r))}}const Vt=new Gt,Ht=new v(ce);class Jt extends ue{}class $t extends ue{}class Zt extends ue{}class Xt extends ue{static isIndexed(e){return!(!e||!e._isIndexed)}}const Qt={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:!0},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"]}};function Yt(e,t){const r=new Error(`deferred error during ABI decoding triggered accessing ${e}`);return r.error=t,r}class er{constructor(e){Ht.checkNew(new.target,er);let t=[];t="string"==typeof e?JSON.parse(e):e,ee(this,"fragments",t.map((e=>Tt.from(e))).filter((e=>null!=e))),ee(this,"_abiCoder",te(new.target,"getAbiCoder")()),ee(this,"functions",{}),ee(this,"errors",{}),ee(this,"events",{}),ee(this,"structs",{}),this.fragments.forEach((e=>{let t=null;switch(e.type){case"constructor":return this.deploy?void Ht.warn("duplicate definition - constructor"):void ee(this,"deploy",e);case"function":t=this.functions;break;case"event":t=this.events;break;case"error":t=this.errors;break;default:return}let r=e.format();t[r]?Ht.warn("duplicate definition - "+r):t[r]=e})),this.deploy||ee(this,"deploy",It.from({payable:!1,type:"constructor"})),ee(this,"_isInterface",!0)}format(e){e||(e=At.full),e===At.sighash&&Ht.throwArgumentError("interface does not support formatting sighash","format",e);const t=this.fragments.map((t=>t.format(e)));return e===At.json?JSON.stringify(t.map((e=>JSON.parse(e)))):t}static getAbiCoder(){return Vt}static getAddress(e){return Me(e)}static getSighash(e){return M(Ze(e.format()),0,4)}static getEventTopic(e){return Ze(e.format())}getFunction(e){if(T(e)){for(const t in this.functions)if(e===this.getSighash(t))return this.functions[t];Ht.throwArgumentError("no matching function","sighash",e)}if(-1===e.indexOf("(")){const t=e.trim(),r=Object.keys(this.functions).filter((e=>e.split("(")[0]===t));return 0===r.length?Ht.throwArgumentError("no matching function","name",t):r.length>1&&Ht.throwArgumentError("multiple matching functions","name",t),this.functions[r[0]]}const t=this.functions[Ot.fromString(e).format()];return t||Ht.throwArgumentError("no matching function","signature",e),t}getEvent(e){if(T(e)){const t=e.toLowerCase();for(const e in this.events)if(t===this.getEventTopic(e))return this.events[e];Ht.throwArgumentError("no matching event","topichash",t)}if(-1===e.indexOf("(")){const t=e.trim(),r=Object.keys(this.events).filter((e=>e.split("(")[0]===t));return 0===r.length?Ht.throwArgumentError("no matching event","name",t):r.length>1&&Ht.throwArgumentError("multiple matching events","name",t),this.events[r[0]]}const t=this.events[Nt.fromString(e).format()];return t||Ht.throwArgumentError("no matching event","signature",e),t}getError(e){if(T(e)){const t=te(this.constructor,"getSighash");for(const r in this.errors)if(e===t(this.errors[r]))return this.errors[r];Ht.throwArgumentError("no matching error","sighash",e)}if(-1===e.indexOf("(")){const t=e.trim(),r=Object.keys(this.errors).filter((e=>e.split("(")[0]===t));return 0===r.length?Ht.throwArgumentError("no matching error","name",t):r.length>1&&Ht.throwArgumentError("multiple matching errors","name",t),this.errors[r[0]]}const t=this.errors[Ot.fromString(e).format()];return t||Ht.throwArgumentError("no matching error","signature",e),t}getSighash(e){if("string"==typeof e)try{e=this.getFunction(e)}catch(t){try{e=this.getError(e)}catch(e){throw t}}return te(this.constructor,"getSighash")(e)}getEventTopic(e){return"string"==typeof e&&(e=this.getEvent(e)),te(this.constructor,"getEventTopic")(e)}_decodeParams(e,t){return this._abiCoder.decode(e,t)}_encodeParams(e,t){return this._abiCoder.encode(e,t)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,t){"string"==typeof e&&(e=this.getError(e));const r=A(t);return R(r.slice(0,4))!==this.getSighash(e)&&Ht.throwArgumentError(`data signature does not match error ${e.name}.`,"data",R(r)),this._decodeParams(e.inputs,r.slice(4))}encodeErrorResult(e,t){return"string"==typeof e&&(e=this.getError(e)),R(P([this.getSighash(e),this._encodeParams(e.inputs,t||[])]))}decodeFunctionData(e,t){"string"==typeof e&&(e=this.getFunction(e));const r=A(t);return R(r.slice(0,4))!==this.getSighash(e)&&Ht.throwArgumentError(`data signature does not match function ${e.name}.`,"data",R(r)),this._decodeParams(e.inputs,r.slice(4))}encodeFunctionData(e,t){return"string"==typeof e&&(e=this.getFunction(e)),R(P([this.getSighash(e),this._encodeParams(e.inputs,t||[])]))}decodeFunctionResult(e,t){"string"==typeof e&&(e=this.getFunction(e));let r=A(t),n=null,i=null,o=null,s=null;switch(r.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(e.outputs,r)}catch(e){}break;case 4:{const e=R(r.slice(0,4)),t=Qt[e];if(t)i=this._abiCoder.decode(t.inputs,r.slice(4)),o=t.name,s=t.signature,t.reason&&(n=i[0]);else try{const t=this.getError(e);i=this._abiCoder.decode(t.inputs,r.slice(4)),o=t.name,s=t.format()}catch(e){console.log(e)}break}}return Ht.throwError("call revert exception",v.errors.CALL_EXCEPTION,{method:e.format(),errorArgs:i,errorName:o,errorSignature:s,reason:n})}encodeFunctionResult(e,t){return"string"==typeof e&&(e=this.getFunction(e)),R(this._abiCoder.encode(e.outputs,t||[]))}encodeFilterTopics(e,t){"string"==typeof e&&(e=this.getEvent(e)),t.length>e.inputs.length&&Ht.throwError("too many arguments for "+e.format(),v.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:t});let r=[];e.anonymous||r.push(this.getEventTopic(e));const n=(e,t)=>"string"===e.type?Ze(t):"bytes"===e.type?ve(R(t)):("address"===e.type&&this._abiCoder.encode(["address"],[t]),K(R(t),32));for(t.forEach(((t,i)=>{let o=e.inputs[i];o.indexed?null==t?r.push(null):"array"===o.baseType||"tuple"===o.baseType?Ht.throwArgumentError("filtering with tuples or arrays not supported","contract."+o.name,t):Array.isArray(t)?r.push(t.map((e=>n(o,e)))):r.push(n(o,t)):null!=t&&Ht.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+o.name,t)}));r.length&&null===r[r.length-1];)r.pop();return r}encodeEventLog(e,t){"string"==typeof e&&(e=this.getEvent(e));const r=[],n=[],i=[];return e.anonymous||r.push(this.getEventTopic(e)),t.length!==e.inputs.length&&Ht.throwArgumentError("event arguments/values mismatch","values",t),e.inputs.forEach(((e,o)=>{const s=t[o];if(e.indexed)if("string"===e.type)r.push(Ze(s));else if("bytes"===e.type)r.push(ve(s));else{if("tuple"===e.baseType||"array"===e.baseType)throw new Error("not implemented");r.push(this._abiCoder.encode([e.type],[s]))}else n.push(e),i.push(s)})),{data:this._abiCoder.encode(n,i),topics:r}}decodeEventLog(e,t,r){if("string"==typeof e&&(e=this.getEvent(e)),null!=r&&!e.anonymous){let t=this.getEventTopic(e);T(r[0],32)&&r[0].toLowerCase()===t||Ht.throwError("fragment/topic mismatch",v.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:t,value:r[0]}),r=r.slice(1)}let n=[],i=[],o=[];e.inputs.forEach(((e,t)=>{e.indexed?"string"===e.type||"bytes"===e.type||"tuple"===e.baseType||"array"===e.baseType?(n.push(xt.fromObject({type:"bytes32",name:e.name})),o.push(!0)):(n.push(e),o.push(!1)):(i.push(e),o.push(!1))}));let s=null!=r?this._abiCoder.decode(n,P(r)):null,a=this._abiCoder.decode(i,t,!0),l=[],u=0,c=0;e.inputs.forEach(((e,t)=>{if(e.indexed)if(null==s)l[t]=new Xt({_isIndexed:!0,hash:null});else if(o[t])l[t]=new Xt({_isIndexed:!0,hash:s[c++]});else try{l[t]=s[c++]}catch(e){l[t]=e}else try{l[t]=a[u++]}catch(e){l[t]=e}if(e.name&&null==l[e.name]){const r=l[t];r instanceof Error?Object.defineProperty(l,e.name,{enumerable:!0,get:()=>{throw Yt(`property ${JSON.stringify(e.name)}`,r)}}):l[e.name]=r}}));for(let e=0;e<l.length;e++){const t=l[e];t instanceof Error&&Object.defineProperty(l,e,{enumerable:!0,get:()=>{throw Yt(`index ${e}`,t)}})}return Object.freeze(l)}parseTransaction(e){let t=this.getFunction(e.data.substring(0,10).toLowerCase());return t?new $t({args:this._abiCoder.decode(t.inputs,"0x"+e.data.substring(10)),functionFragment:t,name:t.name,signature:t.format(),sighash:this.getSighash(t),value:J.from(e.value||"0")}):null}parseLog(e){let t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new Jt({eventFragment:t,name:t.name,signature:t.format(),topic:this.getEventTopic(t),args:this.decodeEventLog(t,e.data,e.topics)})}parseError(e){const t=R(e);let r=this.getError(t.substring(0,10).toLowerCase());return r?new Zt({args:this._abiCoder.decode(r.inputs,"0x"+t.substring(10)),errorFragment:r,name:r.name,signature:r.format(),sighash:this.getSighash(r)}):null}static isInterface(e){return!(!e||!e._isInterface)}}const tr=new v("abstract-provider/5.5.1");class rr extends ue{static isForkEvent(e){return!(!e||!e._isForkEvent)}}class nr{constructor(){tr.checkAbstract(new.target,nr),ee(this,"_isProvider",!0)}getFeeData(){return e=this,t=void 0,n=function*(){const{block:e,gasPrice:t}=yield re({block:this.getBlock("latest"),gasPrice:this.getGasPrice().catch((e=>null))});let r=null,n=null;return e&&e.baseFeePerGas&&(n=J.from("2500000000"),r=e.baseFeePerGas.mul(2).add(n)),{maxFeePerGas:r,maxPriorityFeePerGas:n,gasPrice:t}},new((r=void 0)||(r=Promise))((function(i,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((n=n.apply(e,t||[])).next())}));var e,t,r,n}addListener(e,t){return this.on(e,t)}removeListener(e,t){return this.off(e,t)}static isProvider(e){return!(!e||!e._isProvider)}}var ir=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((n=n.apply(e,t||[])).next())}))};const or=new v("abstract-signer/5.5.0"),sr=["accessList","chainId","customData","data","from","gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","nonce","to","type","value"],ar=[v.errors.INSUFFICIENT_FUNDS,v.errors.NONCE_EXPIRED,v.errors.REPLACEMENT_UNDERPRICED];class lr{constructor(){or.checkAbstract(new.target,lr),ee(this,"_isSigner",!0)}getBalance(e){return ir(this,void 0,void 0,(function*(){return this._checkProvider("getBalance"),yield this.provider.getBalance(this.getAddress(),e)}))}getTransactionCount(e){return ir(this,void 0,void 0,(function*(){return this._checkProvider("getTransactionCount"),yield this.provider.getTransactionCount(this.getAddress(),e)}))}estimateGas(e){return ir(this,void 0,void 0,(function*(){this._checkProvider("estimateGas");const t=yield re(this.checkTransaction(e));return yield this.provider.estimateGas(t)}))}call(e,t){return ir(this,void 0,void 0,(function*(){this._checkProvider("call");const r=yield re(this.checkTransaction(e));return yield this.provider.call(r,t)}))}sendTransaction(e){return ir(this,void 0,void 0,(function*(){this._checkProvider("sendTransaction");const t=yield this.populateTransaction(e),r=yield this.signTransaction(t);return yield this.provider.sendTransaction(r)}))}getChainId(){return ir(this,void 0,void 0,(function*(){return this._checkProvider("getChainId"),(yield this.provider.getNetwork()).chainId}))}getGasPrice(){return ir(this,void 0,void 0,(function*(){return this._checkProvider("getGasPrice"),yield this.provider.getGasPrice()}))}getFeeData(){return ir(this,void 0,void 0,(function*(){return this._checkProvider("getFeeData"),yield this.provider.getFeeData()}))}resolveName(e){return ir(this,void 0,void 0,(function*(){return this._checkProvider("resolveName"),yield this.provider.resolveName(e)}))}checkTransaction(e){for(const t in e)-1===sr.indexOf(t)&&or.throwArgumentError("invalid transaction key: "+t,"transaction",e);const t=ie(e);return null==t.from?t.from=this.getAddress():t.from=Promise.all([Promise.resolve(t.from),this.getAddress()]).then((t=>(t[0].toLowerCase()!==t[1].toLowerCase()&&or.throwArgumentError("from address mismatch","transaction",e),t[0]))),t}populateTransaction(e){return ir(this,void 0,void 0,(function*(){const t=yield re(this.checkTransaction(e));null!=t.to&&(t.to=Promise.resolve(t.to).then((e=>ir(this,void 0,void 0,(function*(){if(null==e)return null;const t=yield this.resolveName(e);return null==t&&or.throwArgumentError("provided ENS name resolves to null","tx.to",e),t})))),t.to.catch((e=>{})));const r=null!=t.maxFeePerGas||null!=t.maxPriorityFeePerGas;if(null==t.gasPrice||2!==t.type&&!r?0!==t.type&&1!==t.type||!r||or.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","transaction",e):or.throwArgumentError("eip-1559 transaction do not support gasPrice","transaction",e),2!==t.type&&null!=t.type||null==t.maxFeePerGas||null==t.maxPriorityFeePerGas)if(0===t.type||1===t.type)null==t.gasPrice&&(t.gasPrice=this.getGasPrice());else{const e=yield this.getFeeData();if(null==t.type)if(null!=e.maxFeePerGas&&null!=e.maxPriorityFeePerGas)if(t.type=2,null!=t.gasPrice){const e=t.gasPrice;delete t.gasPrice,t.maxFeePerGas=e,t.maxPriorityFeePerGas=e}else null==t.maxFeePerGas&&(t.maxFeePerGas=e.maxFeePerGas),null==t.maxPriorityFeePerGas&&(t.maxPriorityFeePerGas=e.maxPriorityFeePerGas);else null!=e.gasPrice?(r&&or.throwError("network does not support EIP-1559",v.errors.UNSUPPORTED_OPERATION,{operation:"populateTransaction"}),null==t.gasPrice&&(t.gasPrice=e.gasPrice),t.type=0):or.throwError("failed to get consistent fee data",v.errors.UNSUPPORTED_OPERATION,{operation:"signer.getFeeData"});else 2===t.type&&(null==t.maxFeePerGas&&(t.maxFeePerGas=e.maxFeePerGas),null==t.maxPriorityFeePerGas&&(t.maxPriorityFeePerGas=e.maxPriorityFeePerGas))}else t.type=2;return null==t.nonce&&(t.nonce=this.getTransactionCount("pending")),null==t.gasLimit&&(t.gasLimit=this.estimateGas(t).catch((e=>{if(ar.indexOf(e.code)>=0)throw e;return or.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",v.errors.UNPREDICTABLE_GAS_LIMIT,{error:e,tx:t})}))),null==t.chainId?t.chainId=this.getChainId():t.chainId=Promise.all([Promise.resolve(t.chainId),this.getChainId()]).then((t=>(0!==t[1]&&t[0]!==t[1]&&or.throwArgumentError("chainId address mismatch","transaction",e),t[0]))),yield re(t)}))}_checkProvider(e){this.provider||or.throwError("missing provider",v.errors.UNSUPPORTED_OPERATION,{operation:e||"_checkProvider"})}static isSigner(e){return!(!e||!e._isSigner)}}class ur extends lr{constructor(e,t){or.checkNew(new.target,ur),super(),ee(this,"address",e),ee(this,"provider",t||null)}getAddress(){return Promise.resolve(this.address)}_fail(e,t){return Promise.resolve().then((()=>{or.throwError(e,v.errors.UNSUPPORTED_OPERATION,{operation:t})}))}signMessage(e){return this._fail("VoidSigner cannot sign messages","signMessage")}signTransaction(e){return this._fail("VoidSigner cannot sign transactions","signTransaction")}_signTypedData(e,t,r){return this._fail("VoidSigner cannot sign typed data","signTypedData")}connect(e){return new ur(this.address,e)}}var cr=r(3715),hr=r.n(cr);function dr(e,t,r){return r={path:t,exports:{},require:function(e,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&r.path)}},e(r,r.exports),r.exports}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==r.g?r.g:"undefined"!=typeof self&&self;var fr=pr;function pr(e,t){if(!e)throw new Error(t||"Assertion failed")}pr.equal=function(e,t,r){if(e!=t)throw new Error(r||"Assertion failed: "+e+" != "+t)};var mr=dr((function(e,t){var r=t;function n(e){return 1===e.length?"0"+e:e}function i(e){for(var t="",r=0;r<e.length;r++)t+=n(e[r].toString(16));return t}r.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"!=typeof e){for(var n=0;n<e.length;n++)r[n]=0|e[n];return r}if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),n=0;n<e.length;n+=2)r.push(parseInt(e[n]+e[n+1],16));else for(n=0;n<e.length;n++){var i=e.charCodeAt(n),o=i>>8,s=255&i;o?r.push(o,s):r.push(s)}return r},r.zero2=n,r.toHex=i,r.encode=function(e,t){return"hex"===t?i(e):e}})),yr=dr((function(e,t){var r=t;r.assert=fr,r.toArray=mr.toArray,r.zero2=mr.zero2,r.toHex=mr.toHex,r.encode=mr.encode,r.getNAF=function(e,t,r){var n=new Array(Math.max(e.bitLength(),r)+1);n.fill(0);for(var i=1<<t+1,o=e.clone(),s=0;s<n.length;s++){var a,l=o.andln(i-1);o.isOdd()?(a=l>(i>>1)-1?(i>>1)-l:l,o.isubn(a)):a=0,n[s]=a,o.iushrn(1)}return n},r.getJSF=function(e,t){var r=[[],[]];e=e.clone(),t=t.clone();for(var n,i=0,o=0;e.cmpn(-i)>0||t.cmpn(-o)>0;){var s,a,l=e.andln(3)+i&3,u=t.andln(3)+o&3;3===l&&(l=-1),3===u&&(u=-1),s=0==(1&l)?0:3!=(n=e.andln(7)+i&7)&&5!==n||2!==u?l:-l,r[0].push(s),a=0==(1&u)?0:3!=(n=t.andln(7)+o&7)&&5!==n||2!==l?u:-u,r[1].push(a),2*i===s+1&&(i=1-i),2*o===a+1&&(o=1-o),e.iushrn(1),t.iushrn(1)}return r},r.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},r.parseBytes=function(e){return"string"==typeof e?r.toArray(e,"hex"):e},r.intFromLE=function(e){return new(L())(e,"hex","le")}})),gr=yr.getNAF,vr=yr.getJSF,br=yr.assert;function wr(e,t){this.type=e,this.p=new(L())(t.p,16),this.red=t.prime?L().red(t.prime):L().mont(this.p),this.zero=new(L())(0).toRed(this.red),this.one=new(L())(1).toRed(this.red),this.two=new(L())(2).toRed(this.red),this.n=t.n&&new(L())(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var _r=wr;function Sr(e,t){this.curve=e,this.type=t,this.precomputed=null}wr.prototype.point=function(){throw new Error("Not implemented")},wr.prototype.validate=function(){throw new Error("Not implemented")},wr.prototype._fixedNafMul=function(e,t){br(e.precomputed);var r=e._getDoubles(),n=gr(t,1,this._bitLength),i=(1<<r.step+1)-(r.step%2==0?2:1);i/=3;var o,s,a=[];for(o=0;o<n.length;o+=r.step){s=0;for(var l=o+r.step-1;l>=o;l--)s=(s<<1)+n[l];a.push(s)}for(var u=this.jpoint(null,null,null),c=this.jpoint(null,null,null),h=i;h>0;h--){for(o=0;o<a.length;o++)(s=a[o])===h?c=c.mixedAdd(r.points[o]):s===-h&&(c=c.mixedAdd(r.points[o].neg()));u=u.add(c)}return u.toP()},wr.prototype._wnafMul=function(e,t){var r=4,n=e._getNAFPoints(r);r=n.wnd;for(var i=n.points,o=gr(t,r,this._bitLength),s=this.jpoint(null,null,null),a=o.length-1;a>=0;a--){for(var l=0;a>=0&&0===o[a];a--)l++;if(a>=0&&l++,s=s.dblp(l),a<0)break;var u=o[a];br(0!==u),s="affine"===e.type?u>0?s.mixedAdd(i[u-1>>1]):s.mixedAdd(i[-u-1>>1].neg()):u>0?s.add(i[u-1>>1]):s.add(i[-u-1>>1].neg())}return"affine"===e.type?s.toP():s},wr.prototype._wnafMulAdd=function(e,t,r,n,i){var o,s,a,l=this._wnafT1,u=this._wnafT2,c=this._wnafT3,h=0;for(o=0;o<n;o++){var d=(a=t[o])._getNAFPoints(e);l[o]=d.wnd,u[o]=d.points}for(o=n-1;o>=1;o-=2){var f=o-1,p=o;if(1===l[f]&&1===l[p]){var m=[t[f],null,null,t[p]];0===t[f].y.cmp(t[p].y)?(m[1]=t[f].add(t[p]),m[2]=t[f].toJ().mixedAdd(t[p].neg())):0===t[f].y.cmp(t[p].y.redNeg())?(m[1]=t[f].toJ().mixedAdd(t[p]),m[2]=t[f].add(t[p].neg())):(m[1]=t[f].toJ().mixedAdd(t[p]),m[2]=t[f].toJ().mixedAdd(t[p].neg()));var y=[-3,-1,-5,-7,0,7,5,1,3],g=vr(r[f],r[p]);for(h=Math.max(g[0].length,h),c[f]=new Array(h),c[p]=new Array(h),s=0;s<h;s++){var v=0|g[0][s],b=0|g[1][s];c[f][s]=y[3*(v+1)+(b+1)],c[p][s]=0,u[f]=m}}else c[f]=gr(r[f],l[f],this._bitLength),c[p]=gr(r[p],l[p],this._bitLength),h=Math.max(c[f].length,h),h=Math.max(c[p].length,h)}var w=this.jpoint(null,null,null),_=this._wnafT4;for(o=h;o>=0;o--){for(var S=0;o>=0;){var E=!0;for(s=0;s<n;s++)_[s]=0|c[s][o],0!==_[s]&&(E=!1);if(!E)break;S++,o--}if(o>=0&&S++,w=w.dblp(S),o<0)break;for(s=0;s<n;s++){var k=_[s];0!==k&&(k>0?a=u[s][k-1>>1]:k<0&&(a=u[s][-k-1>>1].neg()),w="affine"===a.type?w.mixedAdd(a):w.add(a))}}for(o=0;o<n;o++)u[o]=null;return i?w:w.toP()},wr.BasePoint=Sr,Sr.prototype.eq=function(){throw new Error("Not implemented")},Sr.prototype.validate=function(){return this.curve.validate(this)},wr.prototype.decodePoint=function(e,t){e=yr.toArray(e,t);var r=this.p.byteLength();if((4===e[0]||6===e[0]||7===e[0])&&e.length-1==2*r)return 6===e[0]?br(e[e.length-1]%2==0):7===e[0]&&br(e[e.length-1]%2==1),this.point(e.slice(1,1+r),e.slice(1+r,1+2*r));if((2===e[0]||3===e[0])&&e.length-1===r)return this.pointFromX(e.slice(1,1+r),3===e[0]);throw new Error("Unknown point format")},Sr.prototype.encodeCompressed=function(e){return this.encode(e,!0)},Sr.prototype._encode=function(e){var t=this.curve.p.byteLength(),r=this.getX().toArray("be",t);return e?[this.getY().isEven()?2:3].concat(r):[4].concat(r,this.getY().toArray("be",t))},Sr.prototype.encode=function(e,t){return yr.encode(this._encode(t),e)},Sr.prototype.precompute=function(e){if(this.precomputed)return this;var t={doubles:null,naf:null,beta:null};return t.naf=this._getNAFPoints(8),t.doubles=this._getDoubles(4,e),t.beta=this._getBeta(),this.precomputed=t,this},Sr.prototype._hasDoubles=function(e){if(!this.precomputed)return!1;var t=this.precomputed.doubles;return!!t&&t.points.length>=Math.ceil((e.bitLength()+1)/t.step)},Sr.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i<t;i+=e){for(var o=0;o<e;o++)n=n.dbl();r.push(n)}return{step:e,points:r}},Sr.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var t=[this],r=(1<<e)-1,n=1===r?null:this.dbl(),i=1;i<r;i++)t[i]=t[i-1].add(n);return{wnd:e,points:t}},Sr.prototype._getBeta=function(){return null},Sr.prototype.dblp=function(e){for(var t=this,r=0;r<e;r++)t=t.dbl();return t};var Er=dr((function(e){"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}})),kr=yr.assert;function Ar(e){_r.call(this,"short",e),this.a=new(L())(e.a,16).toRed(this.red),this.b=new(L())(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}Er(Ar,_r);var Pr=Ar;function xr(e,t,r,n){_r.BasePoint.call(this,e,"affine"),null===t&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new(L())(t,16),this.y=new(L())(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function Cr(e,t,r,n){_r.BasePoint.call(this,e,"jacobian"),null===t&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new(L())(0)):(this.x=new(L())(t,16),this.y=new(L())(r,16),this.z=new(L())(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}Ar.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,r;if(e.beta)t=new(L())(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=(t=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(e.lambda)r=new(L())(e.lambda,16);else{var i=this._getEndoRoots(this.n);0===this.g.mul(i[0]).x.cmp(this.g.x.redMul(t))?r=i[0]:(r=i[1],kr(0===this.g.mul(r).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:r,basis:e.basis?e.basis.map((function(e){return{a:new(L())(e.a,16),b:new(L())(e.b,16)}})):this._getEndoBasis(r)}}},Ar.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:L().mont(e),r=new(L())(2).toRed(t).redInvm(),n=r.redNeg(),i=new(L())(3).toRed(t).redNeg().redSqrt().redMul(r);return[n.redAdd(i).fromRed(),n.redSub(i).fromRed()]},Ar.prototype._getEndoBasis=function(e){for(var t,r,n,i,o,s,a,l,u,c=this.n.ushrn(Math.floor(this.n.bitLength()/2)),h=e,d=this.n.clone(),f=new(L())(1),p=new(L())(0),m=new(L())(0),y=new(L())(1),g=0;0!==h.cmpn(0);){var v=d.div(h);l=d.sub(v.mul(h)),u=m.sub(v.mul(f));var b=y.sub(v.mul(p));if(!n&&l.cmp(c)<0)t=a.neg(),r=f,n=l.neg(),i=u;else if(n&&2==++g)break;a=l,d=h,h=l,m=f,f=u,y=p,p=b}o=l.neg(),s=u;var w=n.sqr().add(i.sqr());return o.sqr().add(s.sqr()).cmp(w)>=0&&(o=t,s=r),n.negative&&(n=n.neg(),i=i.neg()),o.negative&&(o=o.neg(),s=s.neg()),[{a:n,b:i},{a:o,b:s}]},Ar.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),s=i.mul(r.a),a=o.mul(n.a),l=i.mul(r.b),u=o.mul(n.b);return{k1:e.sub(s).sub(a),k2:l.add(u).neg()}},Ar.prototype.pointFromX=function(e,t){(e=new(L())(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(t&&!i||!t&&i)&&(n=n.redNeg()),this.point(e,n)},Ar.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},Ar.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o<e.length;o++){var s=this._endoSplit(t[o]),a=e[o],l=a._getBeta();s.k1.negative&&(s.k1.ineg(),a=a.neg(!0)),s.k2.negative&&(s.k2.ineg(),l=l.neg(!0)),n[2*o]=a,n[2*o+1]=l,i[2*o]=s.k1,i[2*o+1]=s.k2}for(var u=this._wnafMulAdd(1,n,i,2*o,r),c=0;c<2*o;c++)n[c]=null,i[c]=null;return u},Er(xr,_r.BasePoint),Ar.prototype.point=function(e,t,r){return new xr(this,e,t,r)},Ar.prototype.pointFromJSON=function(e,t){return xr.fromJSON(this,e,t)},xr.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var t=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var r=this.curve,n=function(e){return r.point(e.x.redMul(r.endo.beta),e.y)};e.beta=t,t.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(n)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(n)}}}return t}},xr.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},xr.fromJSON=function(e,t,r){"string"==typeof t&&(t=JSON.parse(t));var n=e.point(t[0],t[1],r);if(!t[2])return n;function i(t){return e.point(t[0],t[1],r)}var o=t[2];return n.precomputed={beta:null,doubles:o.doubles&&{step:o.doubles.step,points:[n].concat(o.doubles.points.map(i))},naf:o.naf&&{wnd:o.naf.wnd,points:[n].concat(o.naf.points.map(i))}},n},xr.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},xr.prototype.isInfinity=function(){return this.inf},xr.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},xr.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),s=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,s)},xr.prototype.getX=function(){return this.x.fromRed()},xr.prototype.getY=function(){return this.y.fromRed()},xr.prototype.mul=function(e){return e=new(L())(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},xr.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},xr.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},xr.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},xr.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},xr.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},Er(Cr,_r.BasePoint),Ar.prototype.jpoint=function(e,t,r){return new Cr(this,e,t,r)},Cr.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},Cr.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Cr.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),s=e.y.redMul(r.redMul(this.z)),a=n.redSub(i),l=o.redSub(s);if(0===a.cmpn(0))return 0!==l.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),c=u.redMul(a),h=n.redMul(u),d=l.redSqr().redIAdd(c).redISub(h).redISub(h),f=l.redMul(h.redISub(d)).redISub(o.redMul(c)),p=this.z.redMul(e.z).redMul(a);return this.curve.jpoint(d,f,p)},Cr.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),s=r.redSub(n),a=i.redSub(o);if(0===s.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var l=s.redSqr(),u=l.redMul(s),c=r.redMul(l),h=a.redSqr().redIAdd(u).redISub(c).redISub(c),d=a.redMul(c.redISub(h)).redISub(i.redMul(u)),f=this.z.redMul(s);return this.curve.jpoint(h,d,f)},Cr.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var r=this;for(t=0;t<e;t++)r=r.dbl();return r}var n=this.curve.a,i=this.curve.tinv,o=this.x,s=this.y,a=this.z,l=a.redSqr().redSqr(),u=s.redAdd(s);for(t=0;t<e;t++){var c=o.redSqr(),h=u.redSqr(),d=h.redSqr(),f=c.redAdd(c).redIAdd(c).redIAdd(n.redMul(l)),p=o.redMul(h),m=f.redSqr().redISub(p.redAdd(p)),y=p.redISub(m),g=f.redMul(y);g=g.redIAdd(g).redISub(d);var v=u.redMul(a);t+1<e&&(l=l.redMul(d)),o=m,a=v,u=g}return this.curve.jpoint(o,u.redMul(i),a)},Cr.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},Cr.prototype._zeroDbl=function(){var e,t,r;if(this.zOne){var n=this.x.redSqr(),i=this.y.redSqr(),o=i.redSqr(),s=this.x.redAdd(i).redSqr().redISub(n).redISub(o);s=s.redIAdd(s);var a=n.redAdd(n).redIAdd(n),l=a.redSqr().redISub(s).redISub(s),u=o.redIAdd(o);u=(u=u.redIAdd(u)).redIAdd(u),e=l,t=a.redMul(s.redISub(l)).redISub(u),r=this.y.redAdd(this.y)}else{var c=this.x.redSqr(),h=this.y.redSqr(),d=h.redSqr(),f=this.x.redAdd(h).redSqr().redISub(c).redISub(d);f=f.redIAdd(f);var p=c.redAdd(c).redIAdd(c),m=p.redSqr(),y=d.redIAdd(d);y=(y=y.redIAdd(y)).redIAdd(y),e=m.redISub(f).redISub(f),t=p.redMul(f.redISub(e)).redISub(y),r=(r=this.y.redMul(this.z)).redIAdd(r)}return this.curve.jpoint(e,t,r)},Cr.prototype._threeDbl=function(){var e,t,r;if(this.zOne){var n=this.x.redSqr(),i=this.y.redSqr(),o=i.redSqr(),s=this.x.redAdd(i).redSqr().redISub(n).redISub(o);s=s.redIAdd(s);var a=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),l=a.redSqr().redISub(s).redISub(s);e=l;var u=o.redIAdd(o);u=(u=u.redIAdd(u)).redIAdd(u),t=a.redMul(s.redISub(l)).redISub(u),r=this.y.redAdd(this.y)}else{var c=this.z.redSqr(),h=this.y.redSqr(),d=this.x.redMul(h),f=this.x.redSub(c).redMul(this.x.redAdd(c));f=f.redAdd(f).redIAdd(f);var p=d.redIAdd(d),m=(p=p.redIAdd(p)).redAdd(p);e=f.redSqr().redISub(m),r=this.y.redAdd(this.z).redSqr().redISub(h).redISub(c);var y=h.redSqr();y=(y=(y=y.redIAdd(y)).redIAdd(y)).redIAdd(y),t=f.redMul(p.redISub(e)).redISub(y)}return this.curve.jpoint(e,t,r)},Cr.prototype._dbl=function(){var e=this.curve.a,t=this.x,r=this.y,n=this.z,i=n.redSqr().redSqr(),o=t.redSqr(),s=r.redSqr(),a=o.redAdd(o).redIAdd(o).redIAdd(e.redMul(i)),l=t.redAdd(t),u=(l=l.redIAdd(l)).redMul(s),c=a.redSqr().redISub(u.redAdd(u)),h=u.redISub(c),d=s.redSqr();d=(d=(d=d.redIAdd(d)).redIAdd(d)).redIAdd(d);var f=a.redMul(h).redISub(d),p=r.redAdd(r).redMul(n);return this.curve.jpoint(c,f,p)},Cr.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr(),n=t.redSqr(),i=e.redAdd(e).redIAdd(e),o=i.redSqr(),s=this.x.redAdd(t).redSqr().redISub(e).redISub(n),a=(s=(s=(s=s.redIAdd(s)).redAdd(s).redIAdd(s)).redISub(o)).redSqr(),l=n.redIAdd(n);l=(l=(l=l.redIAdd(l)).redIAdd(l)).redIAdd(l);var u=i.redIAdd(s).redSqr().redISub(o).redISub(a).redISub(l),c=t.redMul(u);c=(c=c.redIAdd(c)).redIAdd(c);var h=this.x.redMul(a).redISub(c);h=(h=h.redIAdd(h)).redIAdd(h);var d=this.y.redMul(u.redMul(l.redISub(u)).redISub(s.redMul(a)));d=(d=(d=d.redIAdd(d)).redIAdd(d)).redIAdd(d);var f=this.z.redAdd(s).redSqr().redISub(r).redISub(a);return this.curve.jpoint(h,d,f)},Cr.prototype.mul=function(e,t){return e=new(L())(e,t),this.curve._wnafMul(this,e)},Cr.prototype.eq=function(e){if("affine"===e.type)return this.eq(e.toJ());if(this===e)return!0;var t=this.z.redSqr(),r=e.z.redSqr();if(0!==this.x.redMul(r).redISub(e.x.redMul(t)).cmpn(0))return!1;var n=t.redMul(this.z),i=r.redMul(e.z);return 0===this.y.redMul(i).redISub(e.y.redMul(n)).cmpn(0)},Cr.prototype.eqXToP=function(e){var t=this.z.redSqr(),r=e.toRed(this.curve.red).redMul(t);if(0===this.x.cmp(r))return!0;for(var n=e.clone(),i=this.curve.redN.redMul(t);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},Cr.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},Cr.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var Tr=dr((function(e,t){var r=t;r.base=_r,r.short=Pr,r.mont=null,r.edwards=null})),Nr=dr((function(e,t){var r,n=t,i=yr.assert;function o(e){"short"===e.type?this.curve=new Tr.short(e):"edwards"===e.type?this.curve=new Tr.edwards(e):this.curve=new Tr.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function s(e,t){Object.defineProperty(n,e,{configurable:!0,enumerable:!0,get:function(){var r=new o(t);return Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:r}),r}})}n.PresetCurve=o,s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:hr().sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:hr().sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:hr().sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:hr().sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:hr().sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:hr().sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:hr().sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=null.crash()}catch(e){r=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:hr().sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})}));function Rr(e){if(!(this instanceof Rr))return new Rr(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=mr.toArray(e.entropy,e.entropyEnc||"hex"),r=mr.toArray(e.nonce,e.nonceEnc||"hex"),n=mr.toArray(e.pers,e.persEnc||"hex");fr(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}var Br=Rr;Rr.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i<this.V.length;i++)this.K[i]=0,this.V[i]=1;this._update(n),this._reseed=1,this.reseedInterval=281474976710656},Rr.prototype._hmac=function(){return new(hr().hmac)(this.hash,this.K)},Rr.prototype._update=function(e){var t=this._hmac().update(this.V).update([0]);e&&(t=t.update(e)),this.K=t.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())},Rr.prototype.reseed=function(e,t,r,n){"string"!=typeof t&&(n=r,r=t,t=null),e=mr.toArray(e,t),r=mr.toArray(r,n),fr(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},Rr.prototype.generate=function(e,t,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=mr.toArray(r,n||"hex"),this._update(r));for(var i=[];i.length<e;)this.V=this._hmac().update(this.V).digest(),i=i.concat(this.V);var o=i.slice(0,e);return this._update(r),this._reseed++,mr.encode(o,t)};var Mr=yr.assert;function Ir(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}var Or=Ir;Ir.fromPublic=function(e,t,r){return t instanceof Ir?t:new Ir(e,{pub:t,pubEnc:r})},Ir.fromPrivate=function(e,t,r){return t instanceof Ir?t:new Ir(e,{priv:t,privEnc:r})},Ir.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},Ir.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},Ir.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},Ir.prototype._importPrivate=function(e,t){this.priv=new(L())(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},Ir.prototype._importPublic=function(e,t){if(e.x||e.y)return"mont"===this.ec.curve.type?Mr(e.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||Mr(e.x&&e.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(e.x,e.y));this.pub=this.ec.curve.decodePoint(e,t)},Ir.prototype.derive=function(e){return e.validate()||Mr(e.validate(),"public point not validated"),e.mul(this.priv).getX()},Ir.prototype.sign=function(e,t,r){return this.ec.sign(e,this,t,r)},Ir.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},Ir.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var Dr=yr.assert;function Kr(e,t){if(e instanceof Kr)return e;this._importDER(e,t)||(Dr(e.r&&e.s,"Signature without r or s"),this.r=new(L())(e.r,16),this.s=new(L())(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}var Ur=Kr;function Fr(){this.place=0}function jr(e,t){var r=e[t.place++];if(!(128&r))return r;var n=15&r;if(0===n||n>4)return!1;for(var i=0,o=0,s=t.place;o<n;o++,s++)i<<=8,i|=e[s],i>>>=0;return!(i<=127)&&(t.place=s,i)}function Lr(e){for(var t=0,r=e.length-1;!e[t]&&!(128&e[t+1])&&t<r;)t++;return 0===t?e:e.slice(t)}function qr(e,t){if(t<128)e.push(t);else{var r=1+(Math.log(t)/Math.LN2>>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}Kr.prototype._importDER=function(e,t){e=yr.toArray(e,t);var r=new Fr;if(48!==e[r.place++])return!1;var n=jr(e,r);if(!1===n)return!1;if(n+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var i=jr(e,r);if(!1===i)return!1;var o=e.slice(r.place,i+r.place);if(r.place+=i,2!==e[r.place++])return!1;var s=jr(e,r);if(!1===s)return!1;if(e.length!==s+r.place)return!1;var a=e.slice(r.place,s+r.place);if(0===o[0]){if(!(128&o[1]))return!1;o=o.slice(1)}if(0===a[0]){if(!(128&a[1]))return!1;a=a.slice(1)}return this.r=new(L())(o),this.s=new(L())(a),this.recoveryParam=null,!0},Kr.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=Lr(t),r=Lr(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];qr(n,t.length),(n=n.concat(t)).push(2),qr(n,r.length);var i=n.concat(r),o=[48];return qr(o,i.length),o=o.concat(i),yr.encode(o,e)};var zr=function(){throw new Error("unsupported")},Wr=yr.assert;function Gr(e){if(!(this instanceof Gr))return new Gr(e);"string"==typeof e&&(Wr(Object.prototype.hasOwnProperty.call(Nr,e),"Unknown curve "+e),e=Nr[e]),e instanceof Nr.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}var Vr=Gr;Gr.prototype.keyPair=function(e){return new Or(this,e)},Gr.prototype.keyFromPrivate=function(e,t){return Or.fromPrivate(this,e,t)},Gr.prototype.keyFromPublic=function(e,t){return Or.fromPublic(this,e,t)},Gr.prototype.genKeyPair=function(e){e||(e={});for(var t=new Br({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||zr(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),n=this.n.sub(new(L())(2));;){var i=new(L())(t.generate(r));if(!(i.cmp(n)>0))return i.iaddn(1),this.keyFromPrivate(i)}},Gr.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},Gr.prototype.sign=function(e,t,r,n){"object"==typeof r&&(n=r,r=null),n||(n={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new(L())(e,16));for(var i=this.n.byteLength(),o=t.getPrivate().toArray("be",i),s=e.toArray("be",i),a=new Br({hash:this.hash,entropy:o,nonce:s,pers:n.pers,persEnc:n.persEnc||"utf8"}),l=this.n.sub(new(L())(1)),u=0;;u++){var c=n.k?n.k(u):new(L())(a.generate(this.n.byteLength()));if(!((c=this._truncateToN(c,!0)).cmpn(1)<=0||c.cmp(l)>=0)){var h=this.g.mul(c);if(!h.isInfinity()){var d=h.getX(),f=d.umod(this.n);if(0!==f.cmpn(0)){var p=c.invm(this.n).mul(f.mul(t.getPrivate()).iadd(e));if(0!==(p=p.umod(this.n)).cmpn(0)){var m=(h.getY().isOdd()?1:0)|(0!==d.cmp(f)?2:0);return n.canonical&&p.cmp(this.nh)>0&&(p=this.n.sub(p),m^=1),new Ur({r:f,s:p,recoveryParam:m})}}}}}},Gr.prototype.verify=function(e,t,r,n){e=this._truncateToN(new(L())(e,16)),r=this.keyFromPublic(r,n);var i=(t=new Ur(t,"hex")).r,o=t.s;if(i.cmpn(1)<0||i.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var s,a=o.invm(this.n),l=a.mul(e).umod(this.n),u=a.mul(i).umod(this.n);return this.curve._maxwellTrick?!(s=this.g.jmulAdd(l,r.getPublic(),u)).isInfinity()&&s.eqXToP(i):!(s=this.g.mulAdd(l,r.getPublic(),u)).isInfinity()&&0===s.getX().umod(this.n).cmp(i)},Gr.prototype.recoverPubKey=function(e,t,r,n){Wr((3&r)===r,"The recovery param is more than two bits"),t=new Ur(t,n);var i=this.n,o=new(L())(e),s=t.r,a=t.s,l=1&r,u=r>>1;if(s.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");s=u?this.curve.pointFromX(s.add(this.curve.n),l):this.curve.pointFromX(s,l);var c=t.r.invm(i),h=i.sub(o).mul(c).umod(i),d=a.mul(c).umod(i);return this.g.mulAdd(h,s,d)},Gr.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new Ur(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")};var Hr=dr((function(e,t){var r=t;r.version="6.5.4",r.utils=yr,r.rand=function(){throw new Error("unsupported")},r.curve=Tr,r.curves=Nr,r.ec=Vr,r.eddsa=null})).ec;const Jr=new v("signing-key/5.5.0");let $r=null;function Zr(){return $r||($r=new Hr("secp256k1")),$r}class Xr{constructor(e){ee(this,"curve","secp256k1"),ee(this,"privateKey",R(e));const t=Zr().keyFromPrivate(A(this.privateKey));ee(this,"publicKey","0x"+t.getPublic(!1,"hex")),ee(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),ee(this,"_isSigningKey",!0)}_addPoint(e){const t=Zr().keyFromPublic(A(this.publicKey)),r=Zr().keyFromPublic(A(e));return"0x"+t.pub.add(r.pub).encodeCompressed("hex")}signDigest(e){const t=Zr().keyFromPrivate(A(this.privateKey)),r=A(e);32!==r.length&&Jr.throwArgumentError("bad digest length","digest",e);const n=t.sign(r,{canonical:!0});return U({recoveryParam:n.recoveryParam,r:K("0x"+n.r.toString(16),32),s:K("0x"+n.s.toString(16),32)})}computeSharedSecret(e){const t=Zr().keyFromPrivate(A(this.privateKey)),r=Zr().keyFromPublic(A(Yr(e)));return K("0x"+t.derive(r.getPublic()).toString(16),32)}static isSigningKey(e){return!(!e||!e._isSigningKey)}}function Qr(e,t){const r=U(t),n={r:A(r.r),s:A(r.s)};return"0x"+Zr().recoverPubKey(A(e),n,r.recoveryParam).encode("hex",!1)}function Yr(e,t){const r=A(e);if(32===r.length){const e=new Xr(r);return t?"0x"+Zr().keyFromPrivate(r).getPublic(!0,"hex"):e.publicKey}return 33===r.length?t?R(r):"0x"+Zr().keyFromPublic(r).getPublic(!1,"hex"):65===r.length?t?"0x"+Zr().keyFromPublic(r).getPublic(!0,"hex"):R(r):Jr.throwArgumentError("invalid public or private key","key","[REDACTED]")}const en=new v("transactions/5.5.0");var tn;function rn(e){return"0x"===e?null:Me(e)}function nn(e){return"0x"===e?ut:J.from(e)}!function(e){e[e.legacy=0]="legacy",e[e.eip2930=1]="eip2930",e[e.eip1559=2]="eip1559"}(tn||(tn={}));const on=[{name:"nonce",maxLength:32,numeric:!0},{name:"gasPrice",maxLength:32,numeric:!0},{name:"gasLimit",maxLength:32,numeric:!0},{name:"to",length:20},{name:"value",maxLength:32,numeric:!0},{name:"data"}],sn={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,type:!0,value:!0};function an(e){return Me(M(ve(M(Yr(e),1)),12))}function ln(e,t){return an(Qr(A(e),t))}function un(e,t){const r=x(J.from(e).toHexString());return r.length>32&&en.throwArgumentError("invalid length for "+t,"transaction:"+t,e),r}function cn(e,t){return{address:Me(e),storageKeys:(t||[]).map(((t,r)=>(32!==B(t)&&en.throwArgumentError("invalid access list storageKey",`accessList[${e}:${r}]`,t),t.toLowerCase())))}}function hn(e){if(Array.isArray(e))return e.map(((e,t)=>Array.isArray(e)?(e.length>2&&en.throwArgumentError("access list expected to be [ address, storageKeys[] ]",`value[${t}]`,e),cn(e[0],e[1])):cn(e.address,e.storageKeys)));const t=Object.keys(e).map((t=>{const r=e[t].reduce(((e,t)=>(e[t]=!0,e)),{});return cn(t,Object.keys(r).sort())}));return t.sort(((e,t)=>e.address.localeCompare(t.address))),t}function dn(e){return hn(e).map((e=>[e.address,e.storageKeys]))}function fn(e,t){if(null!=e.gasPrice){const t=J.from(e.gasPrice),r=J.from(e.maxFeePerGas||0);t.eq(r)||en.throwArgumentError("mismatch EIP-1559 gasPrice != maxFeePerGas","tx",{gasPrice:t,maxFeePerGas:r})}const r=[un(e.chainId||0,"chainId"),un(e.nonce||0,"nonce"),un(e.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),un(e.maxFeePerGas||0,"maxFeePerGas"),un(e.gasLimit||0,"gasLimit"),null!=e.to?Me(e.to):"0x",un(e.value||0,"value"),e.data||"0x",dn(e.accessList||[])];if(t){const e=U(t);r.push(un(e.recoveryParam,"recoveryParam")),r.push(x(e.r)),r.push(x(e.s))}return I(["0x02",Ee(r)])}function pn(e,t){const r=[un(e.chainId||0,"chainId"),un(e.nonce||0,"nonce"),un(e.gasPrice||0,"gasPrice"),un(e.gasLimit||0,"gasLimit"),null!=e.to?Me(e.to):"0x",un(e.value||0,"value"),e.data||"0x",dn(e.accessList||[])];if(t){const e=U(t);r.push(un(e.recoveryParam,"recoveryParam")),r.push(x(e.r)),r.push(x(e.s))}return I(["0x01",Ee(r)])}function mn(e,t){if(null==e.type||0===e.type)return null!=e.accessList&&en.throwArgumentError("untyped transactions do not support accessList; include type: 1","transaction",e),function(e,t){ne(e,sn);const r=[];on.forEach((function(t){let n=e[t.name]||[];const i={};t.numeric&&(i.hexPad="left"),n=A(R(n,i)),t.length&&n.length!==t.length&&n.length>0&&en.throwArgumentError("invalid length for "+t.name,"transaction:"+t.name,n),t.maxLength&&(n=x(n),n.length>t.maxLength&&en.throwArgumentError("invalid length for "+t.name,"transaction:"+t.name,n)),r.push(R(n))}));let n=0;if(null!=e.chainId?(n=e.chainId,"number"!=typeof n&&en.throwArgumentError("invalid transaction.chainId","transaction",e)):t&&!S(t)&&t.v>28&&(n=Math.floor((t.v-35)/2)),0!==n&&(r.push(R(n)),r.push("0x"),r.push("0x")),!t)return Ee(r);const i=U(t);let o=27+i.recoveryParam;return 0!==n?(r.pop(),r.pop(),r.pop(),o+=2*n+8,i.v>28&&i.v!==o&&en.throwArgumentError("transaction.chainId/signature.v mismatch","signature",t)):i.v!==o&&en.throwArgumentError("transaction.chainId/signature.v mismatch","signature",t),r.push(R(o)),r.push(x(A(i.r))),r.push(x(A(i.s))),Ee(r)}(e,t);switch(e.type){case 1:return pn(e,t);case 2:return fn(e,t)}return en.throwError(`unsupported transaction type: ${e.type}`,v.errors.UNSUPPORTED_OPERATION,{operation:"serializeTransaction",transactionType:e.type})}function yn(e,t,r){try{const r=nn(t[0]).toNumber();if(0!==r&&1!==r)throw new Error("bad recid");e.v=r}catch(e){en.throwArgumentError("invalid v for transaction type: 1","v",t[0])}e.r=K(t[1],32),e.s=K(t[2],32);try{const t=ve(r(e));e.from=ln(t,{r:e.r,s:e.s,recoveryParam:e.v})}catch(e){console.log(e)}}function gn(e){const t=A(e);if(t[0]>127)return function(e){const t=Pe(e);9!==t.length&&6!==t.length&&en.throwArgumentError("invalid raw transaction","rawTransaction",e);const r={nonce:nn(t[0]).toNumber(),gasPrice:nn(t[1]),gasLimit:nn(t[2]),to:rn(t[3]),value:nn(t[4]),data:t[5],chainId:0};if(6===t.length)return r;try{r.v=J.from(t[6]).toNumber()}catch(e){return console.log(e),r}if(r.r=K(t[7],32),r.s=K(t[8],32),J.from(r.r).isZero()&&J.from(r.s).isZero())r.chainId=r.v,r.v=0;else{r.chainId=Math.floor((r.v-35)/2),r.chainId<0&&(r.chainId=0);let n=r.v-27;const i=t.slice(0,6);0!==r.chainId&&(i.push(R(r.chainId)),i.push("0x"),i.push("0x"),n-=2*r.chainId+8);const o=ve(Ee(i));try{r.from=ln(o,{r:R(r.r),s:R(r.s),recoveryParam:n})}catch(e){console.log(e)}r.hash=ve(e)}return r.type=null,r}(t);switch(t[0]){case 1:return function(e){const t=Pe(e.slice(1));8!==t.length&&11!==t.length&&en.throwArgumentError("invalid component count for transaction type: 1","payload",R(e));const r={type:1,chainId:nn(t[0]).toNumber(),nonce:nn(t[1]).toNumber(),gasPrice:nn(t[2]),gasLimit:nn(t[3]),to:rn(t[4]),value:nn(t[5]),data:t[6],accessList:hn(t[7])};return 8===t.length||(r.hash=ve(e),yn(r,t.slice(8),pn)),r}(t);case 2:return function(e){const t=Pe(e.slice(1));9!==t.length&&12!==t.length&&en.throwArgumentError("invalid component count for transaction type: 2","payload",R(e));const r=nn(t[2]),n=nn(t[3]),i={type:2,chainId:nn(t[0]).toNumber(),nonce:nn(t[1]).toNumber(),maxPriorityFeePerGas:r,maxFeePerGas:n,gasPrice:null,gasLimit:nn(t[4]),to:rn(t[5]),value:nn(t[6]),data:t[7],accessList:hn(t[8])};return 9===t.length||(i.hash=ve(e),yn(i,t.slice(9),fn)),i}(t)}return en.throwError(`unsupported transaction type: ${t[0]}`,v.errors.UNSUPPORTED_OPERATION,{operation:"parseTransaction",transactionType:t[0]})}var vn=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((n=n.apply(e,t||[])).next())}))};const bn=new v("contracts/5.5.0"),wn={chainId:!0,data:!0,from:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0,type:!0,accessList:!0,maxFeePerGas:!0,maxPriorityFeePerGas:!0,customData:!0};function _n(e,t){return vn(this,void 0,void 0,(function*(){const r=yield t;"string"!=typeof r&&bn.throwArgumentError("invalid address or ENS name","name",r);try{return Me(r)}catch(e){}e||bn.throwError("a provider or signer is needed to resolve ENS names",v.errors.UNSUPPORTED_OPERATION,{operation:"resolveName"});const n=yield e.resolveName(r);return null==n&&bn.throwArgumentError("resolver or addr is not configured for ENS name","name",r),n}))}function Sn(e,t,r){return vn(this,void 0,void 0,(function*(){return Array.isArray(r)?yield Promise.all(r.map(((r,n)=>Sn(e,Array.isArray(t)?t[n]:t[r.name],r)))):"address"===r.type?yield _n(e,t):"tuple"===r.type?yield Sn(e,t,r.components):"array"===r.baseType?Array.isArray(t)?yield Promise.all(t.map((t=>Sn(e,t,r.arrayChildren)))):Promise.reject(bn.makeError("invalid value for array",v.errors.INVALID_ARGUMENT,{argument:"value",value:t})):t}))}function En(e,t,r){return vn(this,void 0,void 0,(function*(){let n={};r.length===t.inputs.length+1&&"object"==typeof r[r.length-1]&&(n=ie(r.pop())),bn.checkArgumentCount(r.length,t.inputs.length,"passed to contract"),e.signer?n.from?n.from=re({override:_n(e.signer,n.from),signer:e.signer.getAddress()}).then((e=>vn(this,void 0,void 0,(function*(){return Me(e.signer)!==e.override&&bn.throwError("Contract with a Signer cannot override from",v.errors.UNSUPPORTED_OPERATION,{operation:"overrides.from"}),e.override})))):n.from=e.signer.getAddress():n.from&&(n.from=_n(e.provider,n.from));const i=yield re({args:Sn(e.signer||e.provider,r,t.inputs),address:e.resolvedAddress,overrides:re(n)||{}}),o=e.interface.encodeFunctionData(t,i.args),s={data:o,to:i.address},a=i.overrides;if(null!=a.nonce&&(s.nonce=J.from(a.nonce).toNumber()),null!=a.gasLimit&&(s.gasLimit=J.from(a.gasLimit)),null!=a.gasPrice&&(s.gasPrice=J.from(a.gasPrice)),null!=a.maxFeePerGas&&(s.maxFeePerGas=J.from(a.maxFeePerGas)),null!=a.maxPriorityFeePerGas&&(s.maxPriorityFeePerGas=J.from(a.maxPriorityFeePerGas)),null!=a.from&&(s.from=a.from),null!=a.type&&(s.type=a.type),null!=a.accessList&&(s.accessList=hn(a.accessList)),null==s.gasLimit&&null!=t.gas){let e=21e3;const r=A(o);for(let t=0;t<r.length;t++)e+=4,r[t]&&(e+=64);s.gasLimit=J.from(t.gas).add(e)}if(a.value){const e=J.from(a.value);e.isZero()||t.payable||bn.throwError("non-payable method cannot override value",v.errors.UNSUPPORTED_OPERATION,{operation:"overrides.value",value:n.value}),s.value=e}a.customData&&(s.customData=ie(a.customData)),delete n.nonce,delete n.gasLimit,delete n.gasPrice,delete n.from,delete n.value,delete n.type,delete n.accessList,delete n.maxFeePerGas,delete n.maxPriorityFeePerGas,delete n.customData;const l=Object.keys(n).filter((e=>null!=n[e]));return l.length&&bn.throwError(`cannot override ${l.map((e=>JSON.stringify(e))).join(",")}`,v.errors.UNSUPPORTED_OPERATION,{operation:"overrides",overrides:l}),s}))}function kn(e,t){const r=t.wait.bind(t);t.wait=t=>r(t).then((t=>(t.events=t.logs.map((r=>{let n=le(r),i=null;try{i=e.interface.parseLog(r)}catch(e){}return i&&(n.args=i.args,n.decode=(t,r)=>e.interface.decodeEventLog(i.eventFragment,t,r),n.event=i.name,n.eventSignature=i.signature),n.removeListener=()=>e.provider,n.getBlock=()=>e.provider.getBlock(t.blockHash),n.getTransaction=()=>e.provider.getTransaction(t.transactionHash),n.getTransactionReceipt=()=>Promise.resolve(t),n})),t)))}function An(e,t,r){const n=e.signer||e.provider;return function(...i){return vn(this,void 0,void 0,(function*(){let o;if(i.length===t.inputs.length+1&&"object"==typeof i[i.length-1]){const e=ie(i.pop());null!=e.blockTag&&(o=yield e.blockTag),delete e.blockTag,i.push(e)}null!=e.deployTransaction&&(yield e._deployed(o));const s=yield En(e,t,i),a=yield n.call(s,o);try{let n=e.interface.decodeFunctionResult(t,a);return r&&1===t.outputs.length&&(n=n[0]),n}catch(t){throw t.code===v.errors.CALL_EXCEPTION&&(t.address=e.address,t.args=i,t.transaction=s),t}}))}}function Pn(e,t,r){return t.constant?An(e,t,r):function(e,t){return function(...r){return vn(this,void 0,void 0,(function*(){e.signer||bn.throwError("sending a transaction requires a signer",v.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction"}),null!=e.deployTransaction&&(yield e._deployed());const n=yield En(e,t,r),i=yield e.signer.sendTransaction(n);return kn(e,i),i}))}}(e,t)}function xn(e){return!e.address||null!=e.topics&&0!==e.topics.length?(e.address||"*")+"@"+(e.topics?e.topics.map((e=>Array.isArray(e)?e.join("|"):e)).join(":"):""):"*"}class Cn{constructor(e,t){ee(this,"tag",e),ee(this,"filter",t),this._listeners=[]}addListener(e,t){this._listeners.push({listener:e,once:t})}removeListener(e){let t=!1;this._listeners=this._listeners.filter((r=>!(!t&&r.listener===e&&(t=!0,1))))}removeAllListeners(){this._listeners=[]}listeners(){return this._listeners.map((e=>e.listener))}listenerCount(){return this._listeners.length}run(e){const t=this.listenerCount();return this._listeners=this._listeners.filter((t=>{const r=e.slice();return setTimeout((()=>{t.listener.apply(this,r)}),0),!t.once})),t}prepareEvent(e){}getEmit(e){return[e]}}class Tn extends Cn{constructor(){super("error",null)}}class Nn extends Cn{constructor(e,t,r,n){const i={address:e};let o=t.getEventTopic(r);n?(o!==n[0]&&bn.throwArgumentError("topic mismatch","topics",n),i.topics=n.slice()):i.topics=[o],super(xn(i),i),ee(this,"address",e),ee(this,"interface",t),ee(this,"fragment",r)}prepareEvent(e){super.prepareEvent(e),e.event=this.fragment.name,e.eventSignature=this.fragment.format(),e.decode=(e,t)=>this.interface.decodeEventLog(this.fragment,e,t);try{e.args=this.interface.decodeEventLog(this.fragment,e.data,e.topics)}catch(t){e.args=null,e.decodeError=t}}getEmit(e){const t=de(e.args);if(t.length)throw t[0].error;const r=(e.args||[]).slice();return r.push(e),r}}class Rn extends Cn{constructor(e,t){super("*",{address:e}),ee(this,"address",e),ee(this,"interface",t)}prepareEvent(e){super.prepareEvent(e);try{const t=this.interface.parseLog(e);e.event=t.name,e.eventSignature=t.signature,e.decode=(e,r)=>this.interface.decodeEventLog(t.eventFragment,e,r),e.args=t.args}catch(e){}}}class Bn{constructor(e,t,r){bn.checkNew(new.target,Mn),ee(this,"interface",te(new.target,"getInterface")(t)),null==r?(ee(this,"provider",null),ee(this,"signer",null)):lr.isSigner(r)?(ee(this,"provider",r.provider||null),ee(this,"signer",r)):nr.isProvider(r)?(ee(this,"provider",r),ee(this,"signer",null)):bn.throwArgumentError("invalid signer or provider","signerOrProvider",r),ee(this,"callStatic",{}),ee(this,"estimateGas",{}),ee(this,"functions",{}),ee(this,"populateTransaction",{}),ee(this,"filters",{});{const e={};Object.keys(this.interface.events).forEach((t=>{const r=this.interface.events[t];ee(this.filters,t,((...e)=>({address:this.address,topics:this.interface.encodeFilterTopics(r,e)}))),e[r.name]||(e[r.name]=[]),e[r.name].push(t)})),Object.keys(e).forEach((t=>{const r=e[t];1===r.length?ee(this.filters,t,this.filters[r[0]]):bn.warn(`Duplicate definition of ${t} (${r.join(", ")})`)}))}if(ee(this,"_runningEvents",{}),ee(this,"_wrappedEmits",{}),null==e&&bn.throwArgumentError("invalid contract address or ENS name","addressOrName",e),ee(this,"address",e),this.provider)ee(this,"resolvedAddress",_n(this.provider,e));else try{ee(this,"resolvedAddress",Promise.resolve(Me(e)))}catch(e){bn.throwError("provider is required to use ENS name as contract address",v.errors.UNSUPPORTED_OPERATION,{operation:"new Contract"})}const n={},i={};Object.keys(this.interface.functions).forEach((e=>{const t=this.interface.functions[e];if(i[e])bn.warn(`Duplicate ABI entry for ${JSON.stringify(e)}`);else{i[e]=!0;{const r=t.name;n[`%${r}`]||(n[`%${r}`]=[]),n[`%${r}`].push(e)}null==this[e]&&ee(this,e,Pn(this,t,!0)),null==this.functions[e]&&ee(this.functions,e,Pn(this,t,!1)),null==this.callStatic[e]&&ee(this.callStatic,e,An(this,t,!0)),null==this.populateTransaction[e]&&ee(this.populateTransaction,e,function(e,t){return function(...r){return En(e,t,r)}}(this,t)),null==this.estimateGas[e]&&ee(this.estimateGas,e,function(e,t){const r=e.signer||e.provider;return function(...n){return vn(this,void 0,void 0,(function*(){r||bn.throwError("estimate require a provider or signer",v.errors.UNSUPPORTED_OPERATION,{operation:"estimateGas"});const i=yield En(e,t,n);return yield r.estimateGas(i)}))}}(this,t))}})),Object.keys(n).forEach((e=>{const t=n[e];if(t.length>1)return;e=e.substring(1);const r=t[0];try{null==this[e]&&ee(this,e,this[r])}catch(e){}null==this.functions[e]&&ee(this.functions,e,this.functions[r]),null==this.callStatic[e]&&ee(this.callStatic,e,this.callStatic[r]),null==this.populateTransaction[e]&&ee(this.populateTransaction,e,this.populateTransaction[r]),null==this.estimateGas[e]&&ee(this.estimateGas,e,this.estimateGas[r])}))}static getContractAddress(e){return De(e)}static getInterface(e){return er.isInterface(e)?e:new er(e)}deployed(){return this._deployed()}_deployed(e){return this._deployedPromise||(this.deployTransaction?this._deployedPromise=this.deployTransaction.wait().then((()=>this)):this._deployedPromise=this.provider.getCode(this.address,e).then((e=>("0x"===e&&bn.throwError("contract not deployed",v.errors.UNSUPPORTED_OPERATION,{contractAddress:this.address,operation:"getDeployed"}),this)))),this._deployedPromise}fallback(e){this.signer||bn.throwError("sending a transactions require a signer",v.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction(fallback)"});const t=ie(e||{});return["from","to"].forEach((function(e){null!=t[e]&&bn.throwError("cannot override "+e,v.errors.UNSUPPORTED_OPERATION,{operation:e})})),t.to=this.resolvedAddress,this.deployed().then((()=>this.signer.sendTransaction(t)))}connect(e){"string"==typeof e&&(e=new ur(e,this.provider));const t=new this.constructor(this.address,this.interface,e);return this.deployTransaction&&ee(t,"deployTransaction",this.deployTransaction),t}attach(e){return new this.constructor(e,this.interface,this.signer||this.provider)}static isIndexed(e){return Xt.isIndexed(e)}_normalizeRunningEvent(e){return this._runningEvents[e.tag]?this._runningEvents[e.tag]:e}_getRunningEvent(e){if("string"==typeof e){if("error"===e)return this._normalizeRunningEvent(new Tn);if("event"===e)return this._normalizeRunningEvent(new Cn("event",null));if("*"===e)return this._normalizeRunningEvent(new Rn(this.address,this.interface));const t=this.interface.getEvent(e);return this._normalizeRunningEvent(new Nn(this.address,this.interface,t))}if(e.topics&&e.topics.length>0){try{const t=e.topics[0];if("string"!=typeof t)throw new Error("invalid topic");const r=this.interface.getEvent(t);return this._normalizeRunningEvent(new Nn(this.address,this.interface,r,e.topics))}catch(e){}const t={address:this.address,topics:e.topics};return this._normalizeRunningEvent(new Cn(xn(t),t))}return this._normalizeRunningEvent(new Rn(this.address,this.interface))}_checkRunningEvents(e){if(0===e.listenerCount()){delete this._runningEvents[e.tag];const t=this._wrappedEmits[e.tag];t&&e.filter&&(this.provider.off(e.filter,t),delete this._wrappedEmits[e.tag])}}_wrapEvent(e,t,r){const n=le(t);return n.removeListener=()=>{r&&(e.removeListener(r),this._checkRunningEvents(e))},n.getBlock=()=>this.provider.getBlock(t.blockHash),n.getTransaction=()=>this.provider.getTransaction(t.transactionHash),n.getTransactionReceipt=()=>this.provider.getTransactionReceipt(t.transactionHash),e.prepareEvent(n),n}_addEventListener(e,t,r){if(this.provider||bn.throwError("events require a provider or a signer with a provider",v.errors.UNSUPPORTED_OPERATION,{operation:"once"}),e.addListener(t,r),this._runningEvents[e.tag]=e,!this._wrappedEmits[e.tag]){const r=r=>{let n=this._wrapEvent(e,r,t);if(null==n.decodeError)try{const t=e.getEmit(n);this.emit(e.filter,...t)}catch(e){n.decodeError=e.error}null!=e.filter&&this.emit("event",n),null!=n.decodeError&&this.emit("error",n.decodeError,n)};this._wrappedEmits[e.tag]=r,null!=e.filter&&this.provider.on(e.filter,r)}}queryFilter(e,t,r){const n=this._getRunningEvent(e),i=ie(n.filter);return"string"==typeof t&&T(t,32)?(null!=r&&bn.throwArgumentError("cannot specify toBlock with blockhash","toBlock",r),i.blockHash=t):(i.fromBlock=null!=t?t:0,i.toBlock=null!=r?r:"latest"),this.provider.getLogs(i).then((e=>e.map((e=>this._wrapEvent(n,e,null)))))}on(e,t){return this._addEventListener(this._getRunningEvent(e),t,!1),this}once(e,t){return this._addEventListener(this._getRunningEvent(e),t,!0),this}emit(e,...t){if(!this.provider)return!1;const r=this._getRunningEvent(e),n=r.run(t)>0;return this._checkRunningEvents(r),n}listenerCount(e){return this.provider?null==e?Object.keys(this._runningEvents).reduce(((e,t)=>e+this._runningEvents[t].listenerCount()),0):this._getRunningEvent(e).listenerCount():0}listeners(e){if(!this.provider)return[];if(null==e){const e=[];for(let t in this._runningEvents)this._runningEvents[t].listeners().forEach((t=>{e.push(t)}));return e}return this._getRunningEvent(e).listeners()}removeAllListeners(e){if(!this.provider)return this;if(null==e){for(const e in this._runningEvents){const t=this._runningEvents[e];t.removeAllListeners(),this._checkRunningEvents(t)}return this}const t=this._getRunningEvent(e);return t.removeAllListeners(),this._checkRunningEvents(t),this}off(e,t){if(!this.provider)return this;const r=this._getRunningEvent(e);return r.removeListener(t),this._checkRunningEvents(r),this}removeListener(e,t){return this.off(e,t)}}class Mn extends Bn{}class In{constructor(e,t,r){let n=null;n="string"==typeof t?t:k(t)?R(t):t&&"string"==typeof t.object?t.object:"!","0x"!==n.substring(0,2)&&(n="0x"+n),(!T(n)||n.length%2)&&bn.throwArgumentError("invalid bytecode","bytecode",t),r&&!lr.isSigner(r)&&bn.throwArgumentError("invalid signer","signer",r),ee(this,"bytecode",n),ee(this,"interface",te(new.target,"getInterface")(e)),ee(this,"signer",r||null)}getDeployTransaction(...e){let t={};if(e.length===this.interface.deploy.inputs.length+1&&"object"==typeof e[e.length-1]){t=ie(e.pop());for(const e in t)if(!wn[e])throw new Error("unknown transaction override "+e)}return["data","from","to"].forEach((e=>{null!=t[e]&&bn.throwError("cannot override "+e,v.errors.UNSUPPORTED_OPERATION,{operation:e})})),t.value&&(J.from(t.value).isZero()||this.interface.deploy.payable||bn.throwError("non-payable constructor cannot override value",v.errors.UNSUPPORTED_OPERATION,{operation:"overrides.value",value:t.value})),bn.checkArgumentCount(e.length,this.interface.deploy.inputs.length," in Contract constructor"),t.data=R(P([this.bytecode,this.interface.encodeDeploy(e)])),t}deploy(...e){return vn(this,void 0,void 0,(function*(){let t={};e.length===this.interface.deploy.inputs.length+1&&(t=e.pop()),bn.checkArgumentCount(e.length,this.interface.deploy.inputs.length," in Contract constructor");const r=yield Sn(this.signer,e,this.interface.deploy.inputs);r.push(t);const n=this.getDeployTransaction(...r),i=yield this.signer.sendTransaction(n),o=te(this.constructor,"getContractAddress")(i),s=te(this.constructor,"getContract")(o,this.interface,this.signer);return kn(s,i),ee(s,"deployTransaction",i),s}))}attach(e){return this.constructor.getContract(e,this.interface,this.signer)}connect(e){return new this.constructor(this.interface,this.bytecode,e)}static fromSolidity(e,t){null==e&&bn.throwError("missing compiler output",v.errors.MISSING_ARGUMENT,{argument:"compilerOutput"}),"string"==typeof e&&(e=JSON.parse(e));const r=e.abi;let n=null;return e.bytecode?n=e.bytecode:e.evm&&e.evm.bytecode&&(n=e.evm.bytecode),new this(r,n,t)}static getInterface(e){return Mn.getInterface(e)}static getContractAddress(e){return De(e)}static getContract(e,t,r){return new Mn(e,t,r)}}const On=new v(q),Dn={},Kn=J.from(0),Un=J.from(-1);function Fn(e,t,r,n){const i={fault:t,operation:r};return void 0!==n&&(i.value=n),On.throwError(e,v.errors.NUMERIC_FAULT,i)}let jn="0";for(;jn.length<256;)jn+=jn;function Ln(e){if("number"!=typeof e)try{e=J.from(e).toNumber()}catch(e){}return"number"==typeof e&&e>=0&&e<=256&&!(e%1)?"1"+jn.substring(0,e):On.throwArgumentError("invalid decimal size","decimals",e)}function qn(e,t){null==t&&(t=0);const r=Ln(t),n=(e=J.from(e)).lt(Kn);n&&(e=e.mul(Un));let i=e.mod(r).toString();for(;i.length<r.length-1;)i="0"+i;i=i.match(/^([0-9]*[1-9]|0)(0*)/)[1];const o=e.div(r).toString();return e=1===r.length?o:o+"."+i,n&&(e="-"+e),e}function zn(e,t){null==t&&(t=0);const r=Ln(t);"string"==typeof e&&e.match(/^-?[0-9.]+$/)||On.throwArgumentError("invalid decimal value","value",e);const n="-"===e.substring(0,1);n&&(e=e.substring(1)),"."===e&&On.throwArgumentError("missing value","value",e);const i=e.split(".");i.length>2&&On.throwArgumentError("too many decimal points","value",e);let o=i[0],s=i[1];for(o||(o="0"),s||(s="0");"0"===s[s.length-1];)s=s.substring(0,s.length-1);for(s.length>r.length-1&&Fn("fractional component exceeds decimals","underflow","parseFixed"),""===s&&(s="0");s.length<r.length-1;)s+="0";const a=J.from(o),l=J.from(s);let u=a.mul(r).add(l);return n&&(u=u.mul(Un)),u}class Wn{constructor(e,t,r,n){e!==Dn&&On.throwError("cannot use FixedFormat constructor; use FixedFormat.from",v.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.signed=t,this.width=r,this.decimals=n,this.name=(t?"":"u")+"fixed"+String(r)+"x"+String(n),this._multiplier=Ln(n),Object.freeze(this)}static from(e){if(e instanceof Wn)return e;"number"==typeof e&&(e=`fixed128x${e}`);let t=!0,r=128,n=18;if("string"==typeof e)if("fixed"===e);else if("ufixed"===e)t=!1;else{const i=e.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);i||On.throwArgumentError("invalid fixed format","format",e),t="u"!==i[1],r=parseInt(i[2]),n=parseInt(i[3])}else if(e){const i=(t,r,n)=>null==e[t]?n:(typeof e[t]!==r&&On.throwArgumentError("invalid fixed format ("+t+" not "+r+")","format."+t,e[t]),e[t]);t=i("signed","boolean",t),r=i("width","number",r),n=i("decimals","number",n)}return r%8&&On.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",r),n>80&&On.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",n),new Wn(Dn,t,r,n)}}class Gn{constructor(e,t,r,n){On.checkNew(new.target,Gn),e!==Dn&&On.throwError("cannot use FixedNumber constructor; use FixedNumber.from",v.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=n,this._hex=t,this._value=r,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(e){this.format.name!==e.format.name&&On.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)}addUnsafe(e){this._checkFormat(e);const t=zn(this._value,this.format.decimals),r=zn(e._value,e.format.decimals);return Gn.fromValue(t.add(r),this.format.decimals,this.format)}subUnsafe(e){this._checkFormat(e);const t=zn(this._value,this.format.decimals),r=zn(e._value,e.format.decimals);return Gn.fromValue(t.sub(r),this.format.decimals,this.format)}mulUnsafe(e){this._checkFormat(e);const t=zn(this._value,this.format.decimals),r=zn(e._value,e.format.decimals);return Gn.fromValue(t.mul(r).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(e){this._checkFormat(e);const t=zn(this._value,this.format.decimals),r=zn(e._value,e.format.decimals);return Gn.fromValue(t.mul(this.format._multiplier).div(r),this.format.decimals,this.format)}floor(){const e=this.toString().split(".");1===e.length&&e.push("0");let t=Gn.from(e[0],this.format);const r=!e[1].match(/^(0*)$/);return this.isNegative()&&r&&(t=t.subUnsafe(Vn.toFormat(t.format))),t}ceiling(){const e=this.toString().split(".");1===e.length&&e.push("0");let t=Gn.from(e[0],this.format);const r=!e[1].match(/^(0*)$/);return!this.isNegative()&&r&&(t=t.addUnsafe(Vn.toFormat(t.format))),t}round(e){null==e&&(e=0);const t=this.toString().split(".");if(1===t.length&&t.push("0"),(e<0||e>80||e%1)&&On.throwArgumentError("invalid decimal count","decimals",e),t[1].length<=e)return this;const r=Gn.from("1"+jn.substring(0,e),this.format),n=Hn.toFormat(this.format);return this.mulUnsafe(r).addUnsafe(n).floor().divUnsafe(r)}isZero(){return"0.0"===this._value||"0"===this._value}isNegative(){return"-"===this._value[0]}toString(){return this._value}toHexString(e){return null==e?this._hex:(e%8&&On.throwArgumentError("invalid byte width","width",e),K(J.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString(),e/8))}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return Gn.fromString(this._value,e)}static fromValue(e,t,r){return null!=r||null==t||function(e){return null!=e&&(J.isBigNumber(e)||"number"==typeof e&&e%1==0||"string"==typeof e&&!!e.match(/^-?[0-9]+$/)||T(e)||"bigint"==typeof e||k(e))}(t)||(r=t,t=null),null==t&&(t=0),null==r&&(r="fixed"),Gn.fromString(qn(e,t),Wn.from(r))}static fromString(e,t){null==t&&(t="fixed");const r=Wn.from(t),n=zn(e,r.decimals);!r.signed&&n.lt(Kn)&&Fn("unsigned value cannot be negative","overflow","value",e);let i=null;r.signed?i=n.toTwos(r.width).toHexString():(i=n.toHexString(),i=K(i,r.width/8));const o=qn(n,r.decimals);return new Gn(Dn,i,o,r)}static fromBytes(e,t){null==t&&(t="fixed");const r=Wn.from(t);if(A(e).length>r.width/8)throw new Error("overflow");let n=J.from(e);r.signed&&(n=n.fromTwos(r.width));const i=n.toTwos((r.signed?0:1)+r.width).toHexString(),o=qn(n,r.decimals);return new Gn(Dn,i,o,r)}static from(e,t){if("string"==typeof e)return Gn.fromString(e,t);if(k(e))return Gn.fromBytes(e,t);try{return Gn.fromValue(e,0,t)}catch(e){if(e.code!==v.errors.INVALID_ARGUMENT)throw e}return On.throwArgumentError("invalid FixedNumber value","value",e)}static isFixedNumber(e){return!(!e||!e._isFixedNumber)}}const Vn=Gn.from(1),Hn=Gn.from("0.5");function Jn(e){return"string"==typeof e&&(e=We(e)),ve(P([We("Ethereum Signed Message:\n"),We(String(e.length)),e]))}const $n="hash/5.5.0";const Zn=new v($n),Xn=new Uint8Array(32);Xn.fill(0);const Qn=J.from(-1),Yn=J.from(0),ei=J.from(1),ti=J.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),ri=K(ei.toHexString(),32),ni=K(Yn.toHexString(),32),ii={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},oi=["name","version","chainId","verifyingContract","salt"];function si(e){return function(t){return"string"!=typeof t&&Zn.throwArgumentError(`invalid domain value for ${JSON.stringify(e)}`,`domain.${e}`,t),t}}const ai={name:si("name"),version:si("version"),chainId:function(e){try{return J.from(e).toString()}catch(e){}return Zn.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",e)},verifyingContract:function(e){try{return Me(e).toLowerCase()}catch(e){}return Zn.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",e)},salt:function(e){try{const t=A(e);if(32!==t.length)throw new Error("bad length");return R(t)}catch(e){}return Zn.throwArgumentError('invalid domain value "salt"',"domain.salt",e)}};function li(e){{const t=e.match(/^(u?)int(\d*)$/);if(t){const r=""===t[1],n=parseInt(t[2]||"256");(n%8!=0||n>256||t[2]&&t[2]!==String(n))&&Zn.throwArgumentError("invalid numeric width","type",e);const i=ti.mask(r?n-1:n),o=r?i.add(ei).mul(Qn):Yn;return function(t){const r=J.from(t);return(r.lt(o)||r.gt(i))&&Zn.throwArgumentError(`value out-of-bounds for ${e}`,"value",t),K(r.toTwos(256).toHexString(),32)}}}{const t=e.match(/^bytes(\d+)$/);if(t){const r=parseInt(t[1]);return(0===r||r>32||t[1]!==String(r))&&Zn.throwArgumentError("invalid bytes width","type",e),function(t){return A(t).length!==r&&Zn.throwArgumentError(`invalid length for ${e}`,"value",t),function(e){const t=A(e),r=t.length%32;return r?I([t,Xn.slice(r)]):R(t)}(t)}}}switch(e){case"address":return function(e){return K(Me(e),32)};case"bool":return function(e){return e?ri:ni};case"bytes":return function(e){return ve(e)};case"string":return function(e){return Ze(e)}}return null}function ui(e,t){return`${e}(${t.map((({name:e,type:t})=>t+" "+e)).join(",")})`}class ci{constructor(e){ee(this,"types",Object.freeze(le(e))),ee(this,"_encoderCache",{}),ee(this,"_types",{});const t={},r={},n={};Object.keys(e).forEach((e=>{t[e]={},r[e]=[],n[e]={}}));for(const n in e){const i={};e[n].forEach((o=>{i[o.name]&&Zn.throwArgumentError(`duplicate variable name ${JSON.stringify(o.name)} in ${JSON.stringify(n)}`,"types",e),i[o.name]=!0;const s=o.type.match(/^([^\x5b]*)(\x5b|$)/)[1];s===n&&Zn.throwArgumentError(`circular type reference to ${JSON.stringify(s)}`,"types",e),li(s)||(r[s]||Zn.throwArgumentError(`unknown type ${JSON.stringify(s)}`,"types",e),r[s].push(n),t[n][s]=!0)}))}const i=Object.keys(r).filter((e=>0===r[e].length));0===i.length?Zn.throwArgumentError("missing primary type","types",e):i.length>1&&Zn.throwArgumentError(`ambiguous primary types or unused types: ${i.map((e=>JSON.stringify(e))).join(", ")}`,"types",e),ee(this,"primaryType",i[0]),function i(o,s){s[o]&&Zn.throwArgumentError(`circular type reference to ${JSON.stringify(o)}`,"types",e),s[o]=!0,Object.keys(t[o]).forEach((e=>{r[e]&&(i(e,s),Object.keys(s).forEach((t=>{n[t][e]=!0})))})),delete s[o]}(this.primaryType,{});for(const t in n){const r=Object.keys(n[t]);r.sort(),this._types[t]=ui(t,e[t])+r.map((t=>ui(t,e[t]))).join("")}}getEncoder(e){let t=this._encoderCache[e];return t||(t=this._encoderCache[e]=this._getEncoder(e)),t}_getEncoder(e){{const t=li(e);if(t)return t}const t=e.match(/^(.*)(\x5b(\d*)\x5d)$/);if(t){const e=t[1],r=this.getEncoder(e),n=parseInt(t[3]);return t=>{n>=0&&t.length!==n&&Zn.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",t);let i=t.map(r);return this._types[e]&&(i=i.map(ve)),ve(I(i))}}const r=this.types[e];if(r){const t=Ze(this._types[e]);return e=>{const n=r.map((({name:t,type:r})=>{const n=this.getEncoder(r)(e[t]);return this._types[r]?ve(n):n}));return n.unshift(t),I(n)}}return Zn.throwArgumentError(`unknown type: ${e}`,"type",e)}encodeType(e){const t=this._types[e];return t||Zn.throwArgumentError(`unknown type: ${JSON.stringify(e)}`,"name",e),t}encodeData(e,t){return this.getEncoder(e)(t)}hashStruct(e,t){return ve(this.encodeData(e,t))}encode(e){return this.encodeData(this.primaryType,e)}hash(e){return this.hashStruct(this.primaryType,e)}_visit(e,t,r){if(li(e))return r(e,t);const n=e.match(/^(.*)(\x5b(\d*)\x5d)$/);if(n){const e=n[1],i=parseInt(n[3]);return i>=0&&t.length!==i&&Zn.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",t),t.map((t=>this._visit(e,t,r)))}const i=this.types[e];return i?i.reduce(((e,{name:n,type:i})=>(e[n]=this._visit(i,t[n],r),e)),{}):Zn.throwArgumentError(`unknown type: ${e}`,"type",e)}visit(e,t){return this._visit(this.primaryType,e,t)}static from(e){return new ci(e)}static getPrimaryType(e){return ci.from(e).primaryType}static hashStruct(e,t,r){return ci.from(t).hashStruct(e,r)}static hashDomain(e){const t=[];for(const r in e){const n=ii[r];n||Zn.throwArgumentError(`invalid typed-data domain key: ${JSON.stringify(r)}`,"domain",e),t.push({name:r,type:n})}return t.sort(((e,t)=>oi.indexOf(e.name)-oi.indexOf(t.name))),ci.hashStruct("EIP712Domain",{EIP712Domain:t},e)}static encode(e,t,r){return I(["0x1901",ci.hashDomain(e),ci.from(t).hash(r)])}static hash(e,t,r){return ve(ci.encode(e,t,r))}static resolveNames(e,t,r,n){return i=this,o=void 0,a=function*(){e=ie(e);const i={};e.verifyingContract&&!T(e.verifyingContract,20)&&(i[e.verifyingContract]="0x");const o=ci.from(t);o.visit(r,((e,t)=>("address"!==e||T(t,20)||(i[t]="0x"),t)));for(const e in i)i[e]=yield n(e);return e.verifyingContract&&i[e.verifyingContract]&&(e.verifyingContract=i[e.verifyingContract]),r=o.visit(r,((e,t)=>"address"===e&&i[t]?i[t]:t)),{domain:e,value:r}},new((s=void 0)||(s=Promise))((function(e,t){function r(e){try{l(a.next(e))}catch(e){t(e)}}function n(e){try{l(a.throw(e))}catch(e){t(e)}}function l(t){var i;t.done?e(t.value):(i=t.value,i instanceof s?i:new s((function(e){e(i)}))).then(r,n)}l((a=a.apply(i,o||[])).next())}));var i,o,s,a}static getPayload(e,t,r){ci.hashDomain(e);const n={},i=[];oi.forEach((t=>{const r=e[t];null!=r&&(n[t]=ai[t](r),i.push({name:t,type:ii[t]}))}));const o=ci.from(t),s=ie(t);return s.EIP712Domain?Zn.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",t):s.EIP712Domain=i,o.encode(r),{types:s,domain:n,primaryType:o.primaryType,message:o.visit(r,((e,t)=>{if(e.match(/^bytes(\d*)/))return R(A(t));if(e.match(/^u?int/))return J.from(t).toString();switch(e){case"address":return t.toLowerCase();case"bool":return!!t;case"string":return"string"!=typeof t&&Zn.throwArgumentError("invalid string","value",t),t}return Zn.throwArgumentError("unsupported type","type",e)}))}}}class hi{constructor(e){ee(this,"alphabet",e),ee(this,"base",e.length),ee(this,"_alphabetMap",{}),ee(this,"_leader",e.charAt(0));for(let t=0;t<e.length;t++)this._alphabetMap[e.charAt(t)]=t}encode(e){let t=A(e);if(0===t.length)return"";let r=[0];for(let e=0;e<t.length;++e){let n=t[e];for(let e=0;e<r.length;++e)n+=r[e]<<8,r[e]=n%this.base,n=n/this.base|0;for(;n>0;)r.push(n%this.base),n=n/this.base|0}let n="";for(let e=0;0===t[e]&&e<t.length-1;++e)n+=this._leader;for(let e=r.length-1;e>=0;--e)n+=this.alphabet[r[e]];return n}decode(e){if("string"!=typeof e)throw new TypeError("Expected String");let t=[];if(0===e.length)return new Uint8Array(t);t.push(0);for(let r=0;r<e.length;r++){let n=this._alphabetMap[e[r]];if(void 0===n)throw new Error("Non-base"+this.base+" character");let i=n;for(let e=0;e<t.length;++e)i+=t[e]*this.base,t[e]=255&i,i>>=8;for(;i>0;)t.push(255&i),i>>=8}for(let r=0;e[r]===this._leader&&r<e.length-1;++r)t.push(0);return A(new Uint8Array(t.reverse()))}}new hi("abcdefghijklmnopqrstuvwxyz234567");const di=new hi("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");var fi;!function(e){e.sha256="sha256",e.sha512="sha512"}(fi||(fi={}));const pi=new v("sha2/5.5.0");function mi(e){return"0x"+hr().ripemd160().update(A(e)).digest("hex")}function yi(e){return"0x"+hr().sha256().update(A(e)).digest("hex")}function gi(e){return"0x"+hr().sha512().update(A(e)).digest("hex")}function vi(e,t,r){return fi[e]||pi.throwError("unsupported algorithm "+e,v.errors.UNSUPPORTED_OPERATION,{operation:"hmac",algorithm:e}),"0x"+hr().hmac(hr()[e],A(t)).update(A(r)).digest("hex")}function bi(e,t,r,n,i){let o;e=A(e),t=A(t);let s=1;const a=new Uint8Array(n),l=new Uint8Array(t.length+4);let u,c;l.set(t);for(let h=1;h<=s;h++){l[t.length]=h>>24&255,l[t.length+1]=h>>16&255,l[t.length+2]=h>>8&255,l[t.length+3]=255&h;let d=A(vi(i,e,l));o||(o=d.length,c=new Uint8Array(o),s=Math.ceil(n/o),u=n-(s-1)*o),c.set(d);for(let t=1;t<r;t++){d=A(vi(i,e,d));for(let e=0;e<o;e++)c[e]^=d[e]}const f=(h-1)*o,p=h===s?u:o;a.set(A(c).slice(0,p),f)}return R(a)}const wi=new v("wordlists/5.5.0");class _i{constructor(e){wi.checkAbstract(new.target,_i),ee(this,"locale",e)}split(e){return e.toLowerCase().split(/ +/g)}join(e){return e.join(" ")}static check(e){const t=[];for(let r=0;r<2048;r++){const n=e.getWord(r);if(r!==e.getWordIndex(n))return"0x";t.push(n)}return Ze(t.join("\n")+"\n")}static register(e,t){t||(t=e.locale)}}let Si=null;function Ei(e){if(null==Si&&(Si="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo".replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),"0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"!==_i.check(e)))throw Si=null,new Error("BIP39 Wordlist for en (English) FAILED")}const ki=new class extends _i{constructor(){super("en")}getWord(e){return Ei(this),Si[e]}getWordIndex(e){return Ei(this),Si.indexOf(e)}};_i.register(ki);const Ai={en:ki},Pi=new v("hdnode/5.5.0"),xi=J.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Ci=We("Bitcoin seed"),Ti=2147483648;function Ni(e){return(1<<e)-1<<8-e}function Ri(e){return K(R(e),32)}function Bi(e){return di.encode(P([e,M(yi(yi(e)),0,4)]))}function Mi(e){if(null==e)return Ai.en;if("string"==typeof e){const t=Ai[e];return null==t&&Pi.throwArgumentError("unknown locale","wordlist",e),t}return e}const Ii={},Oi="m/44'/60'/0'/0/0";class Di{constructor(e,t,r,n,i,o,s,a){if(Pi.checkNew(new.target,Di),e!==Ii)throw new Error("HDNode constructor cannot be called directly");if(t){const e=new Xr(t);ee(this,"privateKey",e.privateKey),ee(this,"publicKey",e.compressedPublicKey)}else ee(this,"privateKey",null),ee(this,"publicKey",R(r));ee(this,"parentFingerprint",n),ee(this,"fingerprint",M(mi(yi(this.publicKey)),0,4)),ee(this,"address",an(this.publicKey)),ee(this,"chainCode",i),ee(this,"index",o),ee(this,"depth",s),null==a?(ee(this,"mnemonic",null),ee(this,"path",null)):"string"==typeof a?(ee(this,"mnemonic",null),ee(this,"path",a)):(ee(this,"mnemonic",a),ee(this,"path",a.path))}get extendedKey(){if(this.depth>=256)throw new Error("Depth too large!");return Bi(P([null!=this.privateKey?"0x0488ADE4":"0x0488B21E",R(this.depth),this.parentFingerprint,K(R(this.index),4),this.chainCode,null!=this.privateKey?P(["0x00",this.privateKey]):this.publicKey]))}neuter(){return new Di(Ii,null,this.publicKey,this.parentFingerprint,this.chainCode,this.index,this.depth,this.path)}_derive(e){if(e>4294967295)throw new Error("invalid index - "+String(e));let t=this.path;t&&(t+="/"+(2147483647&e));const r=new Uint8Array(37);if(e&Ti){if(!this.privateKey)throw new Error("cannot derive child of neutered node");r.set(A(this.privateKey),1),t&&(t+="'")}else r.set(A(this.publicKey));for(let t=24;t>=0;t-=8)r[33+(t>>3)]=e>>24-t&255;const n=A(vi(fi.sha512,this.chainCode,r)),i=n.slice(0,32),o=n.slice(32);let s=null,a=null;this.privateKey?s=Ri(J.from(i).add(this.privateKey).mod(xi)):a=new Xr(R(i))._addPoint(this.publicKey);let l=t;const u=this.mnemonic;return u&&(l=Object.freeze({phrase:u.phrase,path:t,locale:u.locale||"en"})),new Di(Ii,s,a,this.fingerprint,Ri(o),e,this.depth+1,l)}derivePath(e){const t=e.split("/");if(0===t.length||"m"===t[0]&&0!==this.depth)throw new Error("invalid path - "+e);"m"===t[0]&&t.shift();let r=this;for(let e=0;e<t.length;e++){const n=t[e];if(n.match(/^[0-9]+'$/)){const e=parseInt(n.substring(0,n.length-1));if(e>=Ti)throw new Error("invalid path index - "+n);r=r._derive(Ti+e)}else{if(!n.match(/^[0-9]+$/))throw new Error("invalid path component - "+n);{const e=parseInt(n);if(e>=Ti)throw new Error("invalid path index - "+n);r=r._derive(e)}}}return r}static _fromSeed(e,t){const r=A(e);if(r.length<16||r.length>64)throw new Error("invalid seed");const n=A(vi(fi.sha512,Ci,r));return new Di(Ii,Ri(n.slice(0,32)),null,"0x00000000",Ri(n.slice(32)),0,0,t)}static fromMnemonic(e,t,r){return e=Fi(Ui(e,r=Mi(r)),r),Di._fromSeed(Ki(e,t),{phrase:e,path:"m",locale:r.locale})}static fromSeed(e){return Di._fromSeed(e,null)}static fromExtendedKey(e){const t=di.decode(e);82===t.length&&Bi(t.slice(0,78))===e||Pi.throwArgumentError("invalid extended key","extendedKey","[REDACTED]");const r=t[4],n=R(t.slice(5,9)),i=parseInt(R(t.slice(9,13)).substring(2),16),o=R(t.slice(13,45)),s=t.slice(45,78);switch(R(t.slice(0,4))){case"0x0488b21e":case"0x043587cf":return new Di(Ii,null,R(s),n,o,i,r,null);case"0x0488ade4":case"0x04358394 ":if(0!==s[0])break;return new Di(Ii,R(s.slice(1)),null,n,o,i,r,null)}return Pi.throwArgumentError("invalid extended key","extendedKey","[REDACTED]")}}function Ki(e,t){t||(t="");const r=We("mnemonic"+t,Fe.NFKD);return bi(We(e,Fe.NFKD),r,2048,64,"sha512")}function Ui(e,t){t=Mi(t),Pi.checkNormalize();const r=t.split(e);if(r.length%3!=0)throw new Error("invalid mnemonic");const n=A(new Uint8Array(Math.ceil(11*r.length/8)));let i=0;for(let e=0;e<r.length;e++){let o=t.getWordIndex(r[e].normalize("NFKD"));if(-1===o)throw new Error("invalid mnemonic");for(let e=0;e<11;e++)o&1<<10-e&&(n[i>>3]|=1<<7-i%8),i++}const o=32*r.length/3,s=Ni(r.length/3);if((A(yi(n.slice(0,o/8)))[0]&s)!=(n[n.length-1]&s))throw new Error("invalid checksum");return R(n.slice(0,o/8))}function Fi(e,t){if(t=Mi(t),(e=A(e)).length%4!=0||e.length<16||e.length>32)throw new Error("invalid entropy");const r=[0];let n=11;for(let t=0;t<e.length;t++)n>8?(r[r.length-1]<<=8,r[r.length-1]|=e[t],n-=8):(r[r.length-1]<<=n,r[r.length-1]|=e[t]>>8-n,r.push(e[t]&(1<<8-n)-1),n+=3);const i=e.length/4,o=A(yi(e))[0]&Ni(i);return r[r.length-1]<<=i,r[r.length-1]|=o>>8-i,t.join(r.map((e=>t.getWord(e))))}function ji(e,t){try{return Ui(e,t),!0}catch(e){}return!1}function Li(e){return("number"!=typeof e||e<0||e>=Ti||e%1)&&Pi.throwArgumentError("invalid account index","index",e),`m/44'/60'/${e}'/0/0`}const qi=new v("random/5.5.1"),zi=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==r.g)return r.g;throw new Error("unable to locate global object")}();let Wi=zi.crypto||zi.msCrypto;function Gi(e){(e<=0||e>1024||e%1||e!=e)&&qi.throwArgumentError("invalid length","length",e);const t=new Uint8Array(e);return Wi.getRandomValues(t),A(t)}Wi&&Wi.getRandomValues||(qi.warn("WARNING: Missing strong random number source"),Wi={getRandomValues:function(e){return qi.throwError("no secure random source avaialble",v.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}});var Vi=r(8826),Hi=r.n(Vi);const Ji="json-wallets/5.5.0";function $i(e){return"string"==typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),A(e)}function Zi(e,t){for(e=String(e);e.length<t;)e="0"+e;return e}function Xi(e){return"string"==typeof e?We(e,Fe.NFKC):A(e)}function Qi(e,t){let r=e;const n=t.toLowerCase().split("/");for(let e=0;e<n.length;e++){let t=null;for(const i in r)if(i.toLowerCase()===n[e]){t=r[i];break}if(null===t)return null;r=t}return r}function Yi(e){const t=A(e);t[6]=15&t[6]|64,t[8]=63&t[8]|128;const r=R(t);return[r.substring(2,10),r.substring(10,14),r.substring(14,18),r.substring(18,22),r.substring(22,34)].join("-")}const eo=new v(Ji);class to extends ue{isCrowdsaleAccount(e){return!(!e||!e._isCrowdsaleAccount)}}function ro(e,t){const r=JSON.parse(e);t=Xi(t);const n=Me(Qi(r,"ethaddr")),i=$i(Qi(r,"encseed"));i&&i.length%16==0||eo.throwArgumentError("invalid encseed","json",e);const o=A(bi(t,t,2e3,32,"sha256")).slice(0,16),s=i.slice(0,16),a=i.slice(16),l=new(Hi().ModeOfOperation.cbc)(o,s),u=Hi().padding.pkcs7.strip(A(l.decrypt(a)));let c="";for(let e=0;e<u.length;e++)c+=String.fromCharCode(u[e]);const h=ve(We(c));return new to({_isCrowdsaleAccount:!0,address:n,privateKey:h})}function no(e){let t=null;try{t=JSON.parse(e)}catch(e){return!1}return t.encseed&&t.ethaddr}function io(e){let t=null;try{t=JSON.parse(e)}catch(e){return!1}return!(!t.version||parseInt(t.version)!==t.version||3!==parseInt(t.version))}function oo(e){if(no(e))try{return Me(JSON.parse(e).ethaddr)}catch(e){return null}if(io(e))try{return Me(JSON.parse(e).address)}catch(e){return null}return null}var so=r(7635),ao=r.n(so);const lo=new v(Ji);function uo(e){return null!=e&&e.mnemonic&&e.mnemonic.phrase}class co extends ue{isKeystoreAccount(e){return!(!e||!e._isKeystoreAccount)}}function ho(e,t){const r=$i(Qi(e,"crypto/ciphertext"));if(R(ve(P([t.slice(16,32),r]))).substring(2)!==Qi(e,"crypto/mac").toLowerCase())throw new Error("invalid password");const n=function(e,t,r){if("aes-128-ctr"===Qi(e,"crypto/cipher")){const n=$i(Qi(e,"crypto/cipherparams/iv")),i=new(Hi().Counter)(n);return A(new(Hi().ModeOfOperation.ctr)(t,i).decrypt(r))}return null}(e,t.slice(0,16),r);n||lo.throwError("unsupported cipher",v.errors.UNSUPPORTED_OPERATION,{operation:"decrypt"});const i=t.slice(32,64),o=an(n);if(e.address){let t=e.address.toLowerCase();if("0x"!==t.substring(0,2)&&(t="0x"+t),Me(t)!==o)throw new Error("address mismatch")}const s={_isKeystoreAccount:!0,address:o,privateKey:R(n)};if("0.1"===Qi(e,"x-ethers/version")){const t=$i(Qi(e,"x-ethers/mnemonicCiphertext")),r=$i(Qi(e,"x-ethers/mnemonicCounter")),n=new(Hi().Counter)(r),o=new(Hi().ModeOfOperation.ctr)(i,n),a=Qi(e,"x-ethers/path")||Oi,l=Qi(e,"x-ethers/locale")||"en",u=A(o.decrypt(t));try{const e=Fi(u,l),t=Di.fromMnemonic(e,null,l).derivePath(a);if(t.privateKey!=s.privateKey)throw new Error("mnemonic mismatch");s.mnemonic=t.mnemonic}catch(e){if(e.code!==v.errors.INVALID_ARGUMENT||"wordlist"!==e.argument)throw e}}return new co(s)}function fo(e,t,r,n,i){return A(bi(e,t,r,n,i))}function po(e,t,r,n,i){return Promise.resolve(fo(e,t,r,n,i))}function mo(e,t,r,n,i){const o=Xi(t),s=Qi(e,"crypto/kdf");if(s&&"string"==typeof s){const t=function(e,t){return lo.throwArgumentError("invalid key-derivation function parameters",e,t)};if("scrypt"===s.toLowerCase()){const r=$i(Qi(e,"crypto/kdfparams/salt")),a=parseInt(Qi(e,"crypto/kdfparams/n")),l=parseInt(Qi(e,"crypto/kdfparams/r")),u=parseInt(Qi(e,"crypto/kdfparams/p"));a&&l&&u||t("kdf",s),0!=(a&a-1)&&t("N",a);const c=parseInt(Qi(e,"crypto/kdfparams/dklen"));return 32!==c&&t("dklen",c),n(o,r,a,l,u,64,i)}if("pbkdf2"===s.toLowerCase()){const n=$i(Qi(e,"crypto/kdfparams/salt"));let i=null;const s=Qi(e,"crypto/kdfparams/prf");"hmac-sha256"===s?i="sha256":"hmac-sha512"===s?i="sha512":t("prf",s);const a=parseInt(Qi(e,"crypto/kdfparams/c")),l=parseInt(Qi(e,"crypto/kdfparams/dklen"));return 32!==l&&t("dklen",l),r(o,n,a,l,i)}}return lo.throwArgumentError("unsupported key-derivation function","kdf",s)}function yo(e,t,r){if(no(e)){r&&r(0);const n=ro(e,t);return r&&r(1),Promise.resolve(n)}return io(e)?function(e,t,r){return n=this,i=void 0,s=function*(){const n=JSON.parse(e);return ho(n,yield mo(n,t,po,ao().scrypt,r))},new((o=void 0)||(o=Promise))((function(e,t){function r(e){try{l(s.next(e))}catch(e){t(e)}}function a(e){try{l(s.throw(e))}catch(e){t(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o((function(e){e(n)}))).then(r,a)}l((s=s.apply(n,i||[])).next())}));var n,i,o,s}(e,t,r):Promise.reject(new Error("invalid JSON wallet"))}var go=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((n=n.apply(e,t||[])).next())}))};const vo=new v("wallet/5.5.0");class bo extends lr{constructor(e,t){if(vo.checkNew(new.target,bo),super(),null!=(r=e)&&T(r.privateKey,32)&&null!=r.address){const t=new Xr(e.privateKey);if(ee(this,"_signingKey",(()=>t)),ee(this,"address",an(this.publicKey)),this.address!==Me(e.address)&&vo.throwArgumentError("privateKey/address mismatch","privateKey","[REDACTED]"),function(e){const t=e.mnemonic;return t&&t.phrase}(e)){const t=e.mnemonic;ee(this,"_mnemonic",(()=>({phrase:t.phrase,path:t.path||Oi,locale:t.locale||"en"})));const r=this.mnemonic;an(Di.fromMnemonic(r.phrase,null,r.locale).derivePath(r.path).privateKey)!==this.address&&vo.throwArgumentError("mnemonic/address mismatch","privateKey","[REDACTED]")}else ee(this,"_mnemonic",(()=>null))}else{if(Xr.isSigningKey(e))"secp256k1"!==e.curve&&vo.throwArgumentError("unsupported curve; must be secp256k1","privateKey","[REDACTED]"),ee(this,"_signingKey",(()=>e));else{"string"==typeof e&&e.match(/^[0-9a-f]*$/i)&&64===e.length&&(e="0x"+e);const t=new Xr(e);ee(this,"_signingKey",(()=>t))}ee(this,"_mnemonic",(()=>null)),ee(this,"address",an(this.publicKey))}var r;t&&!nr.isProvider(t)&&vo.throwArgumentError("invalid provider","provider",t),ee(this,"provider",t||null)}get mnemonic(){return this._mnemonic()}get privateKey(){return this._signingKey().privateKey}get publicKey(){return this._signingKey().publicKey}getAddress(){return Promise.resolve(this.address)}connect(e){return new bo(this,e)}signTransaction(e){return re(e).then((t=>{null!=t.from&&(Me(t.from)!==this.address&&vo.throwArgumentError("transaction from address mismatch","transaction.from",e.from),delete t.from);const r=this._signingKey().signDigest(ve(mn(t)));return mn(t,r)}))}signMessage(e){return go(this,void 0,void 0,(function*(){return F(this._signingKey().signDigest(Jn(e)))}))}_signTypedData(e,t,r){return go(this,void 0,void 0,(function*(){const n=yield ci.resolveNames(e,t,r,(e=>(null==this.provider&&vo.throwError("cannot resolve ENS names without a provider",v.errors.UNSUPPORTED_OPERATION,{operation:"resolveName",value:e}),this.provider.resolveName(e))));return F(this._signingKey().signDigest(ci.hash(n.domain,t,n.value)))}))}encrypt(e,t,r){if("function"!=typeof t||r||(r=t,t={}),r&&"function"!=typeof r)throw new Error("invalid callback");return t||(t={}),function(e,t,r,n){try{if(Me(e.address)!==an(e.privateKey))throw new Error("address/privateKey mismatch");if(uo(e)){const t=e.mnemonic;if(Di.fromMnemonic(t.phrase,null,t.locale).derivePath(t.path||Oi).privateKey!=e.privateKey)throw new Error("mnemonic mismatch")}}catch(e){return Promise.reject(e)}"function"!=typeof r||n||(n=r,r={}),r||(r={});const i=A(e.privateKey),o=Xi(t);let s=null,a=null,l=null;if(uo(e)){const t=e.mnemonic;s=A(Ui(t.phrase,t.locale||"en")),a=t.path||Oi,l=t.locale||"en"}let u=r.client;u||(u="ethers.js");let c=null;c=r.salt?A(r.salt):Gi(32);let h=null;if(r.iv){if(h=A(r.iv),16!==h.length)throw new Error("invalid iv")}else h=Gi(16);let d=null;if(r.uuid){if(d=A(r.uuid),16!==d.length)throw new Error("invalid uuid")}else d=Gi(16);let f=1<<17,p=8,m=1;return r.scrypt&&(r.scrypt.N&&(f=r.scrypt.N),r.scrypt.r&&(p=r.scrypt.r),r.scrypt.p&&(m=r.scrypt.p)),ao().scrypt(o,c,f,p,m,64,n).then((t=>{const r=(t=A(t)).slice(0,16),n=t.slice(16,32),o=t.slice(32,64),y=new(Hi().Counter)(h),g=A(new(Hi().ModeOfOperation.ctr)(r,y).encrypt(i)),v=ve(P([n,g])),b={address:e.address.substring(2).toLowerCase(),id:Yi(d),version:3,Crypto:{cipher:"aes-128-ctr",cipherparams:{iv:R(h).substring(2)},ciphertext:R(g).substring(2),kdf:"scrypt",kdfparams:{salt:R(c).substring(2),n:f,dklen:32,p:m,r:p},mac:v.substring(2)}};if(s){const e=Gi(16),t=new(Hi().Counter)(e),r=A(new(Hi().ModeOfOperation.ctr)(o,t).encrypt(s)),n=new Date,i=n.getUTCFullYear()+"-"+Zi(n.getUTCMonth()+1,2)+"-"+Zi(n.getUTCDate(),2)+"T"+Zi(n.getUTCHours(),2)+"-"+Zi(n.getUTCMinutes(),2)+"-"+Zi(n.getUTCSeconds(),2)+".0Z";b["x-ethers"]={client:u,gethFilename:"UTC--"+i+"--"+b.address,mnemonicCounter:R(e).substring(2),mnemonicCiphertext:R(r).substring(2),path:a,locale:l,version:"0.1"}}return JSON.stringify(b)}))}(this,e,t,r)}static createRandom(e){let t=Gi(16);e||(e={}),e.extraEntropy&&(t=A(M(ve(P([t,e.extraEntropy])),0,16)));const r=Fi(t,e.locale);return bo.fromMnemonic(r,e.path,e.locale)}static fromEncryptedJson(e,t,r){return yo(e,t,r).then((e=>new bo(e)))}static fromEncryptedJsonSync(e,t){return new bo(function(e,t){if(no(e))return ro(e,t);if(io(e))return function(e,t){const r=JSON.parse(e);return ho(r,mo(r,t,fo,ao().syncScrypt))}(e,t);throw new Error("invalid JSON wallet")}(e,t))}static fromMnemonic(e,t,r){return t||(t=Oi),new bo(Di.fromMnemonic(e,null,r).derivePath(t))}}function wo(e,t){return ln(Jn(e),t)}function _o(e,t,r,n){return ln(ci.hash(e,t,r),n)}const So="0x0000000000000000000000000000000000000000",Eo="0x0000000000000000000000000000000000000000000000000000000000000000",ko="Ξ",Ao=new v("networks/5.5.2");function Po(e){const t=function(t,r){null==r&&(r={});const n=[];if(t.InfuraProvider)try{n.push(new t.InfuraProvider(e,r.infura))}catch(e){}if(t.EtherscanProvider)try{n.push(new t.EtherscanProvider(e,r.etherscan))}catch(e){}if(t.AlchemyProvider)try{n.push(new t.AlchemyProvider(e,r.alchemy))}catch(e){}if(t.PocketProvider){const r=["goerli","ropsten","rinkeby"];try{const i=new t.PocketProvider(e);i.network&&-1===r.indexOf(i.network.name)&&n.push(i)}catch(e){}}if(t.CloudflareProvider)try{n.push(new t.CloudflareProvider(e))}catch(e){}if(0===n.length)return null;if(t.FallbackProvider){let i=1;return null!=r.quorum?i=r.quorum:"homestead"===e&&(i=2),new t.FallbackProvider(n,i)}return n[0]};return t.renetwork=function(e){return Po(e)},t}function xo(e,t){const r=function(r,n){return r.JsonRpcProvider?new r.JsonRpcProvider(e,t):null};return r.renetwork=function(t){return xo(e,t)},r}const Co={chainId:1,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"homestead",_defaultProvider:Po("homestead")},To={chainId:3,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"ropsten",_defaultProvider:Po("ropsten")},No={chainId:63,name:"classicMordor",_defaultProvider:xo("https://www.ethercluster.com/mordor","classicMordor")},Ro={unspecified:{chainId:0,name:"unspecified"},homestead:Co,mainnet:Co,morden:{chainId:2,name:"morden"},ropsten:To,testnet:To,rinkeby:{chainId:4,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"rinkeby",_defaultProvider:Po("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:Po("kovan")},goerli:{chainId:5,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"goerli",_defaultProvider:Po("goerli")},kintsugi:{chainId:1337702,name:"kintsugi"},classic:{chainId:61,name:"classic",_defaultProvider:xo("https://www.ethercluster.com/etc","classic")},classicMorden:{chainId:62,name:"classicMorden"},classicMordor:No,classicTestnet:No,classicKotti:{chainId:6,name:"classicKotti",_defaultProvider:xo("https://www.ethercluster.com/kotti","classicKotti")},xdai:{chainId:100,name:"xdai"},matic:{chainId:137,name:"matic"},maticmum:{chainId:80001,name:"maticmum"},optimism:{chainId:10,name:"optimism"},"optimism-kovan":{chainId:69,name:"optimism-kovan"},"optimism-goerli":{chainId:420,name:"optimism-goerli"},arbitrum:{chainId:42161,name:"arbitrum"},"arbitrum-rinkeby":{chainId:421611,name:"arbitrum-rinkeby"},bnb:{chainId:56,name:"bnb"},bnbt:{chainId:97,name:"bnbt"}};function Bo(e){if(null==e)return null;if("number"==typeof e){for(const t in Ro){const r=Ro[t];if(r.chainId===e)return{name:r.name,chainId:r.chainId,ensAddress:r.ensAddress||null,_defaultProvider:r._defaultProvider||null}}return{chainId:e,name:"unknown"}}if("string"==typeof e){const t=Ro[e];return null==t?null:{name:t.name,chainId:t.chainId,ensAddress:t.ensAddress,_defaultProvider:t._defaultProvider||null}}const t=Ro[e.name];if(!t)return"number"!=typeof e.chainId&&Ao.throwArgumentError("invalid network chainId","network",e),e;0!==e.chainId&&e.chainId!==t.chainId&&Ao.throwArgumentError("network chainId mismatch","network",e);let r=e._defaultProvider||null;var n;return null==r&&t._defaultProvider&&(r=(n=t._defaultProvider)&&"function"==typeof n.renetwork?t._defaultProvider.renetwork(e):t._defaultProvider),{name:e.name,chainId:t.chainId,ensAddress:e.ensAddress||t.ensAddress||null,_defaultProvider:r}}function Mo(e,t){t||(t=function(e){return[parseInt(e,16)]});let r=0,n={};return e.split(",").forEach((e=>{let i=e.split(":");r+=parseInt(i[0],16),n[r]=t(i[1])})),n}function Io(e){let t=0;return e.split(",").map((e=>{let r=e.split("-");1===r.length?r[1]="0":""===r[1]&&(r[1]="1");let n=t+parseInt(r[0],16);return t=parseInt(r[1],16),{l:n,h:t}}))}function Oo(e,t){let r=0;for(let n=0;n<t.length;n++){let i=t[n];if(r+=i.l,e>=r&&e<=r+i.h&&(e-r)%(i.d||1)==0){if(i.e&&-1!==i.e.indexOf(e-r))continue;return i}}return null}const Do=Io("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),Ko="ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map((e=>parseInt(e,16))),Uo=[{h:25,s:32,l:65},{h:30,s:32,e:[23],l:127},{h:54,s:1,e:[48],l:64,d:2},{h:14,s:1,l:57,d:2},{h:44,s:1,l:17,d:2},{h:10,s:1,e:[2,6,8],l:61,d:2},{h:16,s:1,l:68,d:2},{h:84,s:1,e:[18,24,66],l:19,d:2},{h:26,s:32,e:[17],l:435},{h:22,s:1,l:71,d:2},{h:15,s:80,l:40},{h:31,s:32,l:16},{h:32,s:1,l:80,d:2},{h:52,s:1,l:42,d:2},{h:12,s:1,l:55,d:2},{h:40,s:1,e:[38],l:15,d:2},{h:14,s:1,l:48,d:2},{h:37,s:48,l:49},{h:148,s:1,l:6351,d:2},{h:88,s:1,l:160,d:2},{h:15,s:16,l:704},{h:25,s:26,l:854},{h:25,s:32,l:55915},{h:37,s:40,l:1247},{h:25,s:-119711,l:53248},{h:25,s:-119763,l:52},{h:25,s:-119815,l:52},{h:25,s:-119867,e:[1,4,5,7,8,11,12,17],l:52},{h:25,s:-119919,l:52},{h:24,s:-119971,e:[2,7,8,17],l:52},{h:24,s:-120023,e:[2,7,13,15,16,17],l:52},{h:25,s:-120075,l:52},{h:25,s:-120127,l:52},{h:25,s:-120179,l:52},{h:25,s:-120231,l:52},{h:25,s:-120283,l:52},{h:25,s:-120335,l:52},{h:24,s:-119543,e:[17],l:56},{h:24,s:-119601,e:[17],l:58},{h:24,s:-119659,e:[17],l:58},{h:24,s:-119717,e:[17],l:58},{h:24,s:-119775,e:[17],l:58}],Fo=Mo("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),jo=Mo("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),Lo=Mo("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",(function(e){if(e.length%4!=0)throw new Error("bad data");let t=[];for(let r=0;r<e.length;r+=4)t.push(parseInt(e.substring(r,r+4),16));return t})),qo=Io("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001");function zo(e){if(e.match(/^[a-z0-9-]*$/i)&&e.length<=59)return e.toLowerCase();let t=$e(e);var r;r=t.map((e=>{if(Ko.indexOf(e)>=0)return[];if(e>=65024&&e<=65039)return[];let t=function(e){let t=Oo(e,Uo);if(t)return[e+t.s];let r=Fo[e];if(r)return r;let n=jo[e];return n?[e+n[0]]:Lo[e]||null}(e);return t||[e]})),t=r.reduce(((e,t)=>(t.forEach((t=>{e.push(t)})),e)),[]),t=$e(He(t),Fe.NFKC),t.forEach((e=>{if(Oo(e,qo))throw new Error("STRINGPREP_CONTAINS_PROHIBITED")})),t.forEach((e=>{if(Oo(e,Do))throw new Error("STRINGPREP_CONTAINS_UNASSIGNED")}));let n=He(t);if("-"===n.substring(0,1)||"--"===n.substring(2,4)||"-"===n.substring(n.length-1))throw new Error("invalid hyphen");if(n.length>63)throw new Error("too long");return n}const Wo=new v($n),Go=new Uint8Array(32);Go.fill(0);const Vo=new RegExp("^((.*)\\.)?([^.]+)$");function Ho(e){try{const t=e.split(".");for(let e=0;e<t.length;e++)if(0===zo(t[e]).length)throw new Error("empty");return!0}catch(e){}return!1}function Jo(e){"string"!=typeof e&&Wo.throwArgumentError("invalid ENS name; not a string","name",e);let t=e,r=Go;for(;t.length;){const n=t.match(Vo);null!=n&&""!==n[2]||Wo.throwArgumentError("invalid ENS address; missing component","name",e),r=ve(P([r,ve(We(zo(n[3])))])),t=n[2]||""}return R(r)}function $o(e){e=atob(e);const t=[];for(let r=0;r<e.length;r++)t.push(e.charCodeAt(r));return A(t)}function Zo(e){e=A(e);let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function Xo(e,t){return r=this,n=void 0,o=function*(){null==t&&(t={});const r={method:t.method||"GET",headers:t.headers||{},body:t.body||void 0};!0!==t.skipFetchSetup&&(r.mode="cors",r.cache="no-cache",r.credentials="same-origin",r.redirect="follow",r.referrer="client");const n=yield fetch(e,r),i=yield n.arrayBuffer(),o={};return n.headers.forEach?n.headers.forEach(((e,t)=>{o[t.toLowerCase()]=e})):n.headers.keys().forEach((e=>{o[e.toLowerCase()]=n.headers.get(e)})),{headers:o,statusCode:n.status,statusMessage:n.statusText,body:A(new Uint8Array(i))}},new((i=void 0)||(i=Promise))((function(e,t){function s(e){try{l(o.next(e))}catch(e){t(e)}}function a(e){try{l(o.throw(e))}catch(e){t(e)}}function l(t){var r;t.done?e(t.value):(r=t.value,r instanceof i?r:new i((function(e){e(r)}))).then(s,a)}l((o=o.apply(r,n||[])).next())}));var r,n,i,o}const Qo=new v("web/5.5.1");function Yo(e){return new Promise((t=>{setTimeout(t,e)}))}function es(e,t){if(null==e)return null;if("string"==typeof e)return e;if(S(e)){if(t&&("text"===t.split("/")[0]||"application/json"===t.split(";")[0].trim()))try{return Je(e)}catch(e){}return R(e)}return e}function ts(e,t,r){const n="object"==typeof e&&null!=e.throttleLimit?e.throttleLimit:12;Qo.assertArgument(n>0&&n%1==0,"invalid connection throttle limit","connection.throttleLimit",n);const i="object"==typeof e?e.throttleCallback:null,o="object"==typeof e&&"number"==typeof e.throttleSlotInterval?e.throttleSlotInterval:100;Qo.assertArgument(o>0&&o%1==0,"invalid connection throttle slot interval","connection.throttleSlotInterval",o);const s={};let a=null;const l={method:"GET"};let u=!1,c=12e4;if("string"==typeof e)a=e;else if("object"==typeof e){if(null!=e&&null!=e.url||Qo.throwArgumentError("missing URL","connection.url",e),a=e.url,"number"==typeof e.timeout&&e.timeout>0&&(c=e.timeout),e.headers)for(const t in e.headers)s[t.toLowerCase()]={key:t,value:String(e.headers[t])},["if-none-match","if-modified-since"].indexOf(t.toLowerCase())>=0&&(u=!0);if(l.allowGzip=!!e.allowGzip,null!=e.user&&null!=e.password){"https:"!==a.substring(0,6)&&!0!==e.allowInsecureAuthentication&&Qo.throwError("basic authentication requires a secure https url",v.errors.INVALID_ARGUMENT,{argument:"url",url:a,user:e.user,password:"[REDACTED]"});const t=e.user+":"+e.password;s.authorization={key:"Authorization",value:"Basic "+Zo(We(t))}}}const h=new RegExp("^data:([a-z0-9-]+/[a-z0-9-]+);base64,(.*)$","i"),d=a?a.match(h):null;if(d)try{const e={statusCode:200,statusMessage:"OK",headers:{"content-type":d[1]},body:$o(d[2])};let t=e.body;return r&&(t=r(e.body,e)),Promise.resolve(t)}catch(e){Qo.throwError("processing response error",v.errors.SERVER_ERROR,{body:es(d[1],d[2]),error:e,requestBody:null,requestMethod:"GET",url:a})}t&&(l.method="POST",l.body=t,null==s["content-type"]&&(s["content-type"]={key:"Content-Type",value:"application/octet-stream"}),null==s["content-length"]&&(s["content-length"]={key:"Content-Length",value:String(t.length)}));const f={};Object.keys(s).forEach((e=>{const t=s[e];f[t.key]=t.value})),l.headers=f;const p=function(){let e=null;return{promise:new Promise((function(t,r){c&&(e=setTimeout((()=>{null!=e&&(e=null,r(Qo.makeError("timeout",v.errors.TIMEOUT,{requestBody:es(l.body,f["content-type"]),requestMethod:l.method,timeout:c,url:a})))}),c))})),cancel:function(){null!=e&&(clearTimeout(e),e=null)}}}(),m=function(){return e=this,t=void 0,c=function*(){for(let e=0;e<n;e++){let t=null;try{if(t=yield Xo(a,l),e<n)if(301===t.statusCode||302===t.statusCode){const e=t.headers.location||"";if("GET"===l.method&&e.match(/^https:/)){a=t.headers.location;continue}}else if(429===t.statusCode){let r=!0;if(i&&(r=yield i(e,a)),r){let r=0;const n=t.headers["retry-after"];r="string"==typeof n&&n.match(/^[1-9][0-9]*$/)?1e3*parseInt(n):o*parseInt(String(Math.random()*Math.pow(2,e))),yield Yo(r);continue}}}catch(e){t=e.response,null==t&&(p.cancel(),Qo.throwError("missing response",v.errors.SERVER_ERROR,{requestBody:es(l.body,f["content-type"]),requestMethod:l.method,serverError:e,url:a}))}let s=t.body;if(u&&304===t.statusCode?s=null:(t.statusCode<200||t.statusCode>=300)&&(p.cancel(),Qo.throwError("bad response",v.errors.SERVER_ERROR,{status:t.statusCode,headers:t.headers,body:es(s,t.headers?t.headers["content-type"]:null),requestBody:es(l.body,f["content-type"]),requestMethod:l.method,url:a})),r)try{const e=yield r(s,t);return p.cancel(),e}catch(r){if(r.throttleRetry&&e<n){let t=!0;if(i&&(t=yield i(e,a)),t){const t=o*parseInt(String(Math.random()*Math.pow(2,e)));yield Yo(t);continue}}p.cancel(),Qo.throwError("processing response error",v.errors.SERVER_ERROR,{body:es(s,t.headers?t.headers["content-type"]:null),error:r,requestBody:es(l.body,f["content-type"]),requestMethod:l.method,url:a})}return p.cancel(),s}return Qo.throwError("failed response",v.errors.SERVER_ERROR,{requestBody:es(l.body,f["content-type"]),requestMethod:l.method,url:a})},new((s=void 0)||(s=Promise))((function(r,n){function i(e){try{a(c.next(e))}catch(e){n(e)}}function o(e){try{a(c.throw(e))}catch(e){n(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(i,o)}a((c=c.apply(e,t||[])).next())}));var e,t,s,c}();return Promise.race([p.promise,m])}function rs(e,t,r){let n=null;if(null!=t){n=We(t);const r="string"==typeof e?{url:e}:ie(e);r.headers?0!==Object.keys(r.headers).filter((e=>"content-type"===e.toLowerCase())).length||(r.headers=ie(r.headers),r.headers["content-type"]="application/json"):r.headers={"content-type":"application/json"},e=r}return ts(e,n,((e,t)=>{let n=null;if(null!=e)try{n=JSON.parse(Je(e))}catch(t){Qo.throwError("invalid JSON",v.errors.SERVER_ERROR,{body:e,error:t})}return r&&(n=r(n,t)),n}))}function ns(e,t){return t||(t={}),null==(t=ie(t)).floor&&(t.floor=0),null==t.ceiling&&(t.ceiling=1e4),null==t.interval&&(t.interval=250),new Promise((function(r,n){let i=null,o=!1;const s=()=>!o&&(o=!0,i&&clearTimeout(i),!0);t.timeout&&(i=setTimeout((()=>{s()&&n(new Error("timeout"))}),t.timeout));const a=t.retryLimit;let l=0;!function i(){return e().then((function(e){if(void 0!==e)s()&&r(e);else if(t.oncePoll)t.oncePoll.once("poll",i);else if(t.onceBlock)t.onceBlock.once("block",i);else if(!o){if(l++,l>a)return void(s()&&n(new Error("retry limit reached")));let e=t.interval*parseInt(String(Math.random()*Math.pow(2,l)));e<t.floor&&(e=t.floor),e>t.ceiling&&(e=t.ceiling),setTimeout(i,e)}return null}),(function(e){s()&&n(e)}))}()}))}var is=r(2882),os=r.n(is);const ss="providers/5.5.2",as=new v(ss);class ls{constructor(){as.checkNew(new.target,ls),this.formats=this.getDefaultFormats()}getDefaultFormats(){const e={},t=this.address.bind(this),r=this.bigNumber.bind(this),n=this.blockTag.bind(this),i=this.data.bind(this),o=this.hash.bind(this),s=this.hex.bind(this),a=this.number.bind(this),l=this.type.bind(this);return e.transaction={hash:o,type:l,accessList:ls.allowNull(this.accessList.bind(this),null),blockHash:ls.allowNull(o,null),blockNumber:ls.allowNull(a,null),transactionIndex:ls.allowNull(a,null),confirmations:ls.allowNull(a,null),from:t,gasPrice:ls.allowNull(r),maxPriorityFeePerGas:ls.allowNull(r),maxFeePerGas:ls.allowNull(r),gasLimit:r,to:ls.allowNull(t,null),value:r,nonce:a,data:i,r:ls.allowNull(this.uint256),s:ls.allowNull(this.uint256),v:ls.allowNull(a),creates:ls.allowNull(t,null),raw:ls.allowNull(i)},e.transactionRequest={from:ls.allowNull(t),nonce:ls.allowNull(a),gasLimit:ls.allowNull(r),gasPrice:ls.allowNull(r),maxPriorityFeePerGas:ls.allowNull(r),maxFeePerGas:ls.allowNull(r),to:ls.allowNull(t),value:ls.allowNull(r),data:ls.allowNull((e=>this.data(e,!0))),type:ls.allowNull(a),accessList:ls.allowNull(this.accessList.bind(this),null)},e.receiptLog={transactionIndex:a,blockNumber:a,transactionHash:o,address:t,topics:ls.arrayOf(o),data:i,logIndex:a,blockHash:o},e.receipt={to:ls.allowNull(this.address,null),from:ls.allowNull(this.address,null),contractAddress:ls.allowNull(t,null),transactionIndex:a,root:ls.allowNull(s),gasUsed:r,logsBloom:ls.allowNull(i),blockHash:o,transactionHash:o,logs:ls.arrayOf(this.receiptLog.bind(this)),blockNumber:a,confirmations:ls.allowNull(a,null),cumulativeGasUsed:r,effectiveGasPrice:ls.allowNull(r),status:ls.allowNull(a),type:l},e.block={hash:o,parentHash:o,number:a,timestamp:a,nonce:ls.allowNull(s),difficulty:this.difficulty.bind(this),gasLimit:r,gasUsed:r,miner:t,extraData:i,transactions:ls.allowNull(ls.arrayOf(o)),baseFeePerGas:ls.allowNull(r)},e.blockWithTransactions=ie(e.block),e.blockWithTransactions.transactions=ls.allowNull(ls.arrayOf(this.transactionResponse.bind(this))),e.filter={fromBlock:ls.allowNull(n,void 0),toBlock:ls.allowNull(n,void 0),blockHash:ls.allowNull(o,void 0),address:ls.allowNull(t,void 0),topics:ls.allowNull(this.topics.bind(this),void 0)},e.filterLog={blockNumber:ls.allowNull(a),blockHash:ls.allowNull(o),transactionIndex:a,removed:ls.allowNull(this.boolean.bind(this)),address:t,data:ls.allowFalsish(i,"0x"),topics:ls.arrayOf(o),transactionHash:o,logIndex:a},e}accessList(e){return hn(e||[])}number(e){return"0x"===e?0:J.from(e).toNumber()}type(e){return"0x"===e||null==e?0:J.from(e).toNumber()}bigNumber(e){return J.from(e)}boolean(e){if("boolean"==typeof e)return e;if("string"==typeof e){if("true"===(e=e.toLowerCase()))return!0;if("false"===e)return!1}throw new Error("invalid boolean - "+e)}hex(e,t){return"string"==typeof e&&(t||"0x"===e.substring(0,2)||(e="0x"+e),T(e))?e.toLowerCase():as.throwArgumentError("invalid hash","value",e)}data(e,t){const r=this.hex(e,t);if(r.length%2!=0)throw new Error("invalid data; odd-length - "+e);return r}address(e){return Me(e)}callAddress(e){if(!T(e,32))return null;const t=Me(M(e,12));return t===So?null:t}contractAddress(e){return De(e)}blockTag(e){if(null==e)return"latest";if("earliest"===e)return"0x0";if("latest"===e||"pending"===e)return e;if("number"==typeof e||T(e))return O(e);throw new Error("invalid blockTag")}hash(e,t){const r=this.hex(e,t);return 32!==B(r)?as.throwArgumentError("invalid hash","value",e):r}difficulty(e){if(null==e)return null;const t=J.from(e);try{return t.toNumber()}catch(e){}return null}uint256(e){if(!T(e))throw new Error("invalid uint256");return K(e,32)}_block(e,t){null!=e.author&&null==e.miner&&(e.miner=e.author);const r=null!=e._difficulty?e._difficulty:e.difficulty,n=ls.check(t,e);return n._difficulty=null==r?null:J.from(r),n}block(e){return this._block(e,this.formats.block)}blockWithTransactions(e){return this._block(e,this.formats.blockWithTransactions)}transactionRequest(e){return ls.check(this.formats.transactionRequest,e)}transactionResponse(e){null!=e.gas&&null==e.gasLimit&&(e.gasLimit=e.gas),e.to&&J.from(e.to).isZero()&&(e.to="0x0000000000000000000000000000000000000000"),null!=e.input&&null==e.data&&(e.data=e.input),null==e.to&&null==e.creates&&(e.creates=this.contractAddress(e)),1!==e.type&&2!==e.type||null!=e.accessList||(e.accessList=[]);const t=ls.check(this.formats.transaction,e);if(null!=e.chainId){let r=e.chainId;T(r)&&(r=J.from(r).toNumber()),t.chainId=r}else{let r=e.networkId;null==r&&null==t.v&&(r=e.chainId),T(r)&&(r=J.from(r).toNumber()),"number"!=typeof r&&null!=t.v&&(r=(t.v-35)/2,r<0&&(r=0),r=parseInt(r)),"number"!=typeof r&&(r=0),t.chainId=r}return t.blockHash&&"x"===t.blockHash.replace(/0/g,"")&&(t.blockHash=null),t}transaction(e){return gn(e)}receiptLog(e){return ls.check(this.formats.receiptLog,e)}receipt(e){const t=ls.check(this.formats.receipt,e);if(null!=t.root)if(t.root.length<=4){const e=J.from(t.root).toNumber();0===e||1===e?(null!=t.status&&t.status!==e&&as.throwArgumentError("alt-root-status/status mismatch","value",{root:t.root,status:t.status}),t.status=e,delete t.root):as.throwArgumentError("invalid alt-root-status","value.root",t.root)}else 66!==t.root.length&&as.throwArgumentError("invalid root hash","value.root",t.root);return null!=t.status&&(t.byzantium=!0),t}topics(e){return Array.isArray(e)?e.map((e=>this.topics(e))):null!=e?this.hash(e,!0):null}filter(e){return ls.check(this.formats.filter,e)}filterLog(e){return ls.check(this.formats.filterLog,e)}static check(e,t){const r={};for(const n in e)try{const i=e[n](t[n]);void 0!==i&&(r[n]=i)}catch(e){throw e.checkKey=n,e.checkValue=t[n],e}return r}static allowNull(e,t){return function(r){return null==r?t:e(r)}}static allowFalsish(e,t){return function(r){return r?e(r):t}}static arrayOf(e){return function(t){if(!Array.isArray(t))throw new Error("not an array");const r=[];return t.forEach((function(t){r.push(e(t))})),r}}}function us(e){return e&&"function"==typeof e.isCommunityResource}function cs(e){return us(e)&&e.isCommunityResource()}let hs=!1;function ds(){hs||(hs=!0,console.log("========= NOTICE ========="),console.log("Request-Rate Exceeded (this message will not be repeated)"),console.log(""),console.log("The default API keys for each service are provided as a highly-throttled,"),console.log("community resource for low-traffic projects and early prototyping."),console.log(""),console.log("While your application will continue to function, we highly recommended"),console.log("signing up for your own API keys to improve performance, increase your"),console.log("request rate/limit and enable other perks, such as metrics and advanced APIs."),console.log(""),console.log("For more details: https://docs.ethers.io/api-keys/"),console.log("=========================="))}var fs=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((n=n.apply(e,t||[])).next())}))};const ps=new v(ss);function ms(e){return null==e?"null":(32!==B(e)&&ps.throwArgumentError("invalid topic","topic",e),e.toLowerCase())}function ys(e){for(e=e.slice();e.length>0&&null==e[e.length-1];)e.pop();return e.map((e=>{if(Array.isArray(e)){const t={};e.forEach((e=>{t[ms(e)]=!0}));const r=Object.keys(t);return r.sort(),r.join("|")}return ms(e)})).join("&")}function gs(e){if("string"==typeof e){if(32===B(e=e.toLowerCase()))return"tx:"+e;if(-1===e.indexOf(":"))return e}else{if(Array.isArray(e))return"filter:*:"+ys(e);if(rr.isForkEvent(e))throw ps.warn("not implemented"),new Error("not implemented");if(e&&"object"==typeof e)return"filter:"+(e.address||"*")+":"+ys(e.topics||[])}throw new Error("invalid event - "+e)}function vs(){return(new Date).getTime()}function bs(e){return new Promise((t=>{setTimeout(t,e)}))}const ws=["block","network","pending","poll"];class _s{constructor(e,t,r){ee(this,"tag",e),ee(this,"listener",t),ee(this,"once",r)}get event(){switch(this.type){case"tx":return this.hash;case"filter":return this.filter}return this.tag}get type(){return this.tag.split(":")[0]}get hash(){const e=this.tag.split(":");return"tx"!==e[0]?null:e[1]}get filter(){const e=this.tag.split(":");if("filter"!==e[0])return null;const t=e[1],r=""===(n=e[2])?[]:n.split(/&/g).map((e=>{if(""===e)return[];const t=e.split("|").map((e=>"null"===e?null:e));return 1===t.length?t[0]:t}));var n;const i={};return r.length>0&&(i.topics=r),t&&"*"!==t&&(i.address=t),i}pollable(){return this.tag.indexOf(":")>=0||ws.indexOf(this.tag)>=0}}const Ss={0:{symbol:"btc",p2pkh:0,p2sh:5,prefix:"bc"},2:{symbol:"ltc",p2pkh:48,p2sh:50,prefix:"ltc"},3:{symbol:"doge",p2pkh:30,p2sh:22},60:{symbol:"eth",ilk:"eth"},61:{symbol:"etc",ilk:"eth"},700:{symbol:"xdai",ilk:"eth"}};function Es(e){return K(J.from(e).toHexString(),32)}function ks(e){return di.encode(P([e,M(yi(yi(e)),0,4)]))}const As=new RegExp("^(ipfs)://(.*)$","i"),Ps=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),As,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")];function xs(e){try{return Je(Cs(e))}catch(e){}return null}function Cs(e){if("0x"===e)return null;const t=J.from(M(e,0,32)).toNumber(),r=J.from(M(e,t,t+32)).toNumber();return M(e,t+32,t+32+r)}function Ts(e){return`https://gateway.ipfs.io/ipfs/${e.substring(7)}`}class Ns{constructor(e,t,r,n){ee(this,"provider",e),ee(this,"name",r),ee(this,"address",e.formatter.address(t)),ee(this,"_resolvedAddress",n)}_fetchBytes(e,t){return fs(this,void 0,void 0,(function*(){const r={to:this.address,data:I([e,Jo(this.name),t||"0x"])};try{return Cs(yield this.provider.call(r))}catch(e){return e.code,v.errors.CALL_EXCEPTION,null}}))}_getAddress(e,t){const r=Ss[String(e)];if(null==r&&ps.throwError(`unsupported coin type: ${e}`,v.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${e})`}),"eth"===r.ilk)return this.provider.formatter.address(t);const n=A(t);if(null!=r.p2pkh){const e=t.match(/^0x76a9([0-9a-f][0-9a-f])([0-9a-f]*)88ac$/);if(e){const t=parseInt(e[1],16);if(e[2].length===2*t&&t>=1&&t<=75)return ks(P([[r.p2pkh],"0x"+e[2]]))}}if(null!=r.p2sh){const e=t.match(/^0xa9([0-9a-f][0-9a-f])([0-9a-f]*)87$/);if(e){const t=parseInt(e[1],16);if(e[2].length===2*t&&t>=1&&t<=75)return ks(P([[r.p2sh],"0x"+e[2]]))}}if(null!=r.prefix){const e=n[1];let t=n[0];if(0===t?20!==e&&32!==e&&(t=-1):t=-1,t>=0&&n.length===2+e&&e>=1&&e<=75){const e=os().toWords(n.slice(2));return e.unshift(t),os().encode(r.prefix,e)}}return null}getAddress(e){return fs(this,void 0,void 0,(function*(){if(null==e&&(e=60),60===e)try{const e={to:this.address,data:"0x3b3b57de"+Jo(this.name).substring(2)},t=yield this.provider.call(e);return"0x"===t||t===Eo?null:this.provider.formatter.callAddress(t)}catch(e){if(e.code===v.errors.CALL_EXCEPTION)return null;throw e}const t=yield this._fetchBytes("0xf1cb7e06",Es(e));if(null==t||"0x"===t)return null;const r=this._getAddress(e,t);return null==r&&ps.throwError("invalid or unsupported coin data",v.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${e})`,coinType:e,data:t}),r}))}getAvatar(){return fs(this,void 0,void 0,(function*(){const e=[{type:"name",content:this.name}];try{const t=yield this.getText("avatar");if(null==t)return null;for(let r=0;r<Ps.length;r++){const n=t.match(Ps[r]);if(null==n)continue;const i=n[1].toLowerCase();switch(i){case"https":return e.push({type:"url",content:t}),{linkage:e,url:t};case"data":return e.push({type:"data",content:t}),{linkage:e,url:t};case"ipfs":return e.push({type:"ipfs",content:t}),{linkage:e,url:Ts(t)};case"erc721":case"erc1155":{const r="erc721"===i?"0xc87b56dd":"0x0e89341c";e.push({type:i,content:t});const o=this._resolvedAddress||(yield this.getAddress()),s=(n[2]||"").split("/");if(2!==s.length)return null;const a=yield this.provider.formatter.address(s[0]),l=K(J.from(s[1]).toHexString(),32);if("erc721"===i){const t=this.provider.formatter.callAddress(yield this.provider.call({to:a,data:I(["0x6352211e",l])}));if(o!==t)return null;e.push({type:"owner",content:t})}else if("erc1155"===i){const t=J.from(yield this.provider.call({to:a,data:I(["0x00fdd58e",K(o,32),l])}));if(t.isZero())return null;e.push({type:"balance",content:t.toString()})}const u={to:this.provider.formatter.address(s[0]),data:I([r,l])};let c=xs(yield this.provider.call(u));if(null==c)return null;e.push({type:"metadata-url",content:c}),"erc1155"===i&&(c=c.replace("{id}",l.substring(2)),e.push({type:"metadata-url-expanded",content:c}));const h=yield rs(c);if(!h)return null;e.push({type:"metadata",content:JSON.stringify(h)});let d=h.image;if("string"!=typeof d)return null;if(d.match(/^(https:\/\/|data:)/i));else{if(null==d.match(As))return null;e.push({type:"url-ipfs",content:d}),d=Ts(d)}return e.push({type:"url",content:d}),{linkage:e,url:d}}}}}catch(e){}return null}))}getContentHash(){return fs(this,void 0,void 0,(function*(){const e=yield this._fetchBytes("0xbc1c58d1");if(null==e||"0x"===e)return null;const t=e.match(/^0xe3010170(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(t){const e=parseInt(t[3],16);if(t[4].length===2*e)return"ipfs://"+di.encode("0x"+t[1])}const r=e.match(/^0xe40101fa011b20([0-9a-f]*)$/);return r&&64===r[1].length?"bzz://"+r[1]:ps.throwError("invalid or unsupported content hash data",v.errors.UNSUPPORTED_OPERATION,{operation:"getContentHash()",data:e})}))}getText(e){return fs(this,void 0,void 0,(function*(){let t=We(e);t=P([Es(64),Es(t.length),t]),t.length%32!=0&&(t=P([t,K("0x",32-e.length%32)]));const r=yield this._fetchBytes("0x59d1d43c",R(t));return null==r||"0x"===r?null:Je(r)}))}}let Rs=null,Bs=1;class Ms extends nr{constructor(e){if(ps.checkNew(new.target,nr),super(),this._events=[],this._emitted={block:-2},this.formatter=new.target.getFormatter(),ee(this,"anyNetwork","any"===e),this.anyNetwork&&(e=this.detectNetwork()),e instanceof Promise)this._networkPromise=e,e.catch((e=>{})),this._ready().catch((e=>{}));else{const t=te(new.target,"getNetwork")(e);t?(ee(this,"_network",t),this.emit("network",t,null)):ps.throwArgumentError("invalid network","network",e)}this._maxInternalBlockNumber=-1024,this._lastBlockNumber=-2,this._pollingInterval=4e3,this._fastQueryDate=0}_ready(){return fs(this,void 0,void 0,(function*(){if(null==this._network){let e=null;if(this._networkPromise)try{e=yield this._networkPromise}catch(e){}null==e&&(e=yield this.detectNetwork()),e||ps.throwError("no network detected",v.errors.UNKNOWN_ERROR,{}),null==this._network&&(this.anyNetwork?this._network=e:ee(this,"_network",e),this.emit("network",e,null))}return this._network}))}get ready(){return ns((()=>this._ready().then((e=>e),(e=>{if(e.code!==v.errors.NETWORK_ERROR||"noNetwork"!==e.event)throw e}))))}static getFormatter(){return null==Rs&&(Rs=new ls),Rs}static getNetwork(e){return Bo(null==e?"homestead":e)}_getInternalBlockNumber(e){return fs(this,void 0,void 0,(function*(){if(yield this._ready(),e>0)for(;this._internalBlockNumber;){const t=this._internalBlockNumber;try{const r=yield t;if(vs()-r.respTime<=e)return r.blockNumber;break}catch(e){if(this._internalBlockNumber===t)break}}const t=vs(),r=re({blockNumber:this.perform("getBlockNumber",{}),networkError:this.getNetwork().then((e=>null),(e=>e))}).then((({blockNumber:e,networkError:n})=>{if(n)throw this._internalBlockNumber===r&&(this._internalBlockNumber=null),n;const i=vs();return(e=J.from(e).toNumber())<this._maxInternalBlockNumber&&(e=this._maxInternalBlockNumber),this._maxInternalBlockNumber=e,this._setFastBlockNumber(e),{blockNumber:e,reqTime:t,respTime:i}}));return this._internalBlockNumber=r,r.catch((e=>{this._internalBlockNumber===r&&(this._internalBlockNumber=null)})),(yield r).blockNumber}))}poll(){return fs(this,void 0,void 0,(function*(){const e=Bs++,t=[];let r=null;try{r=yield this._getInternalBlockNumber(100+this.pollingInterval/2)}catch(e){return void this.emit("error",e)}if(this._setFastBlockNumber(r),this.emit("poll",e,r),r!==this._lastBlockNumber){if(-2===this._emitted.block&&(this._emitted.block=r-1),Math.abs(this._emitted.block-r)>1e3)ps.warn(`network block skew detected; skipping block events (emitted=${this._emitted.block} blockNumber${r})`),this.emit("error",ps.makeError("network block skew detected",v.errors.NETWORK_ERROR,{blockNumber:r,event:"blockSkew",previousBlockNumber:this._emitted.block})),this.emit("block",r);else for(let e=this._emitted.block+1;e<=r;e++)this.emit("block",e);this._emitted.block!==r&&(this._emitted.block=r,Object.keys(this._emitted).forEach((e=>{if("block"===e)return;const t=this._emitted[e];"pending"!==t&&r-t>12&&delete this._emitted[e]}))),-2===this._lastBlockNumber&&(this._lastBlockNumber=r-1),this._events.forEach((e=>{switch(e.type){case"tx":{const r=e.hash;let n=this.getTransactionReceipt(r).then((e=>e&&null!=e.blockNumber?(this._emitted["t:"+r]=e.blockNumber,this.emit(r,e),null):null)).catch((e=>{this.emit("error",e)}));t.push(n);break}case"filter":{const n=e.filter;n.fromBlock=this._lastBlockNumber+1,n.toBlock=r;const i=this.getLogs(n).then((e=>{0!==e.length&&e.forEach((e=>{this._emitted["b:"+e.blockHash]=e.blockNumber,this._emitted["t:"+e.transactionHash]=e.blockNumber,this.emit(n,e)}))})).catch((e=>{this.emit("error",e)}));t.push(i);break}}})),this._lastBlockNumber=r,Promise.all(t).then((()=>{this.emit("didPoll",e)})).catch((e=>{this.emit("error",e)}))}else this.emit("didPoll",e)}))}resetEventsBlock(e){this._lastBlockNumber=e-1,this.polling&&this.poll()}get network(){return this._network}detectNetwork(){return fs(this,void 0,void 0,(function*(){return ps.throwError("provider does not support network detection",v.errors.UNSUPPORTED_OPERATION,{operation:"provider.detectNetwork"})}))}getNetwork(){return fs(this,void 0,void 0,(function*(){const e=yield this._ready(),t=yield this.detectNetwork();if(e.chainId!==t.chainId){if(this.anyNetwork)return this._network=t,this._lastBlockNumber=-2,this._fastBlockNumber=null,this._fastBlockNumberPromise=null,this._fastQueryDate=0,this._emitted.block=-2,this._maxInternalBlockNumber=-1024,this._internalBlockNumber=null,this.emit("network",t,e),yield bs(0),this._network;const r=ps.makeError("underlying network changed",v.errors.NETWORK_ERROR,{event:"changed",network:e,detectedNetwork:t});throw this.emit("error",r),r}return e}))}get blockNumber(){return this._getInternalBlockNumber(100+this.pollingInterval/2).then((e=>{this._setFastBlockNumber(e)}),(e=>{})),null!=this._fastBlockNumber?this._fastBlockNumber:-1}get polling(){return null!=this._poller}set polling(e){e&&!this._poller?(this._poller=setInterval((()=>{this.poll()}),this.pollingInterval),this._bootstrapPoll||(this._bootstrapPoll=setTimeout((()=>{this.poll(),this._bootstrapPoll=setTimeout((()=>{this._poller||this.poll(),this._bootstrapPoll=null}),this.pollingInterval)}),0))):!e&&this._poller&&(clearInterval(this._poller),this._poller=null)}get pollingInterval(){return this._pollingInterval}set pollingInterval(e){if("number"!=typeof e||e<=0||parseInt(String(e))!=e)throw new Error("invalid polling interval");this._pollingInterval=e,this._poller&&(clearInterval(this._poller),this._poller=setInterval((()=>{this.poll()}),this._pollingInterval))}_getFastBlockNumber(){const e=vs();return e-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=e,this._fastBlockNumberPromise=this.getBlockNumber().then((e=>((null==this._fastBlockNumber||e>this._fastBlockNumber)&&(this._fastBlockNumber=e),this._fastBlockNumber)))),this._fastBlockNumberPromise}_setFastBlockNumber(e){null!=this._fastBlockNumber&&e<this._fastBlockNumber||(this._fastQueryDate=vs(),(null==this._fastBlockNumber||e>this._fastBlockNumber)&&(this._fastBlockNumber=e,this._fastBlockNumberPromise=Promise.resolve(e)))}waitForTransaction(e,t,r){return fs(this,void 0,void 0,(function*(){return this._waitForTransaction(e,null==t?1:t,r||0,null)}))}_waitForTransaction(e,t,r,n){return fs(this,void 0,void 0,(function*(){const i=yield this.getTransactionReceipt(e);return(i?i.confirmations:0)>=t?i:new Promise(((i,o)=>{const s=[];let a=!1;const l=function(){return!!a||(a=!0,s.forEach((e=>{e()})),!1)},u=e=>{e.confirmations<t||l()||i(e)};if(this.on(e,u),s.push((()=>{this.removeListener(e,u)})),n){let r=n.startBlock,i=null;const u=s=>fs(this,void 0,void 0,(function*(){a||(yield bs(1e3),this.getTransactionCount(n.from).then((c=>fs(this,void 0,void 0,(function*(){if(!a){if(c<=n.nonce)r=s;else{{const t=yield this.getTransaction(e);if(t&&null!=t.blockNumber)return}for(null==i&&(i=r-3,i<n.startBlock&&(i=n.startBlock));i<=s;){if(a)return;const r=yield this.getBlockWithTransactions(i);for(let i=0;i<r.transactions.length;i++){const s=r.transactions[i];if(s.hash===e)return;if(s.from===n.from&&s.nonce===n.nonce){if(a)return;const r=yield this.waitForTransaction(s.hash,t);if(l())return;let i="replaced";return s.data===n.data&&s.to===n.to&&s.value.eq(n.value)?i="repriced":"0x"===s.data&&s.from===s.to&&s.value.isZero()&&(i="cancelled"),void o(ps.makeError("transaction was replaced",v.errors.TRANSACTION_REPLACED,{cancelled:"replaced"===i||"cancelled"===i,reason:i,replacement:this._wrapTransaction(s),hash:e,receipt:r}))}}i++}}a||this.once("block",u)}}))),(e=>{a||this.once("block",u)})))}));if(a)return;this.once("block",u),s.push((()=>{this.removeListener("block",u)}))}if("number"==typeof r&&r>0){const e=setTimeout((()=>{l()||o(ps.makeError("timeout exceeded",v.errors.TIMEOUT,{timeout:r}))}),r);e.unref&&e.unref(),s.push((()=>{clearTimeout(e)}))}}))}))}getBlockNumber(){return fs(this,void 0,void 0,(function*(){return this._getInternalBlockNumber(0)}))}getGasPrice(){return fs(this,void 0,void 0,(function*(){yield this.getNetwork();const e=yield this.perform("getGasPrice",{});try{return J.from(e)}catch(t){return ps.throwError("bad result from backend",v.errors.SERVER_ERROR,{method:"getGasPrice",result:e,error:t})}}))}getBalance(e,t){return fs(this,void 0,void 0,(function*(){yield this.getNetwork();const r=yield re({address:this._getAddress(e),blockTag:this._getBlockTag(t)}),n=yield this.perform("getBalance",r);try{return J.from(n)}catch(e){return ps.throwError("bad result from backend",v.errors.SERVER_ERROR,{method:"getBalance",params:r,result:n,error:e})}}))}getTransactionCount(e,t){return fs(this,void 0,void 0,(function*(){yield this.getNetwork();const r=yield re({address:this._getAddress(e),blockTag:this._getBlockTag(t)}),n=yield this.perform("getTransactionCount",r);try{return J.from(n).toNumber()}catch(e){return ps.throwError("bad result from backend",v.errors.SERVER_ERROR,{method:"getTransactionCount",params:r,result:n,error:e})}}))}getCode(e,t){return fs(this,void 0,void 0,(function*(){yield this.getNetwork();const r=yield re({address:this._getAddress(e),blockTag:this._getBlockTag(t)}),n=yield this.perform("getCode",r);try{return R(n)}catch(e){return ps.throwError("bad result from backend",v.errors.SERVER_ERROR,{method:"getCode",params:r,result:n,error:e})}}))}getStorageAt(e,t,r){return fs(this,void 0,void 0,(function*(){yield this.getNetwork();const n=yield re({address:this._getAddress(e),blockTag:this._getBlockTag(r),position:Promise.resolve(t).then((e=>O(e)))}),i=yield this.perform("getStorageAt",n);try{return R(i)}catch(e){return ps.throwError("bad result from backend",v.errors.SERVER_ERROR,{method:"getStorageAt",params:n,result:i,error:e})}}))}_wrapTransaction(e,t,r){if(null!=t&&32!==B(t))throw new Error("invalid response - sendTransaction");const n=e;return null!=t&&e.hash!==t&&ps.throwError("Transaction hash mismatch from Provider.sendTransaction.",v.errors.UNKNOWN_ERROR,{expectedHash:e.hash,returnedHash:t}),n.wait=(t,n)=>fs(this,void 0,void 0,(function*(){let i;null==t&&(t=1),null==n&&(n=0),0!==t&&null!=r&&(i={data:e.data,from:e.from,nonce:e.nonce,to:e.to,value:e.value,startBlock:r});const o=yield this._waitForTransaction(e.hash,t,n,i);return null==o&&0===t?null:(this._emitted["t:"+e.hash]=o.blockNumber,0===o.status&&ps.throwError("transaction failed",v.errors.CALL_EXCEPTION,{transactionHash:e.hash,transaction:e,receipt:o}),o)})),n}sendTransaction(e){return fs(this,void 0,void 0,(function*(){yield this.getNetwork();const t=yield Promise.resolve(e).then((e=>R(e))),r=this.formatter.transaction(e);null==r.confirmations&&(r.confirmations=0);const n=yield this._getInternalBlockNumber(100+2*this.pollingInterval);try{const e=yield this.perform("sendTransaction",{signedTransaction:t});return this._wrapTransaction(r,e,n)}catch(e){throw e.transaction=r,e.transactionHash=r.hash,e}}))}_getTransactionRequest(e){return fs(this,void 0,void 0,(function*(){const t=yield e,r={};return["from","to"].forEach((e=>{null!=t[e]&&(r[e]=Promise.resolve(t[e]).then((e=>e?this._getAddress(e):null)))})),["gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","value"].forEach((e=>{null!=t[e]&&(r[e]=Promise.resolve(t[e]).then((e=>e?J.from(e):null)))})),["type"].forEach((e=>{null!=t[e]&&(r[e]=Promise.resolve(t[e]).then((e=>null!=e?e:null)))})),t.accessList&&(r.accessList=this.formatter.accessList(t.accessList)),["data"].forEach((e=>{null!=t[e]&&(r[e]=Promise.resolve(t[e]).then((e=>e?R(e):null)))})),this.formatter.transactionRequest(yield re(r))}))}_getFilter(e){return fs(this,void 0,void 0,(function*(){e=yield e;const t={};return null!=e.address&&(t.address=this._getAddress(e.address)),["blockHash","topics"].forEach((r=>{null!=e[r]&&(t[r]=e[r])})),["fromBlock","toBlock"].forEach((r=>{null!=e[r]&&(t[r]=this._getBlockTag(e[r]))})),this.formatter.filter(yield re(t))}))}call(e,t){return fs(this,void 0,void 0,(function*(){yield this.getNetwork();const r=yield re({transaction:this._getTransactionRequest(e),blockTag:this._getBlockTag(t)}),n=yield this.perform("call",r);try{return R(n)}catch(e){return ps.throwError("bad result from backend",v.errors.SERVER_ERROR,{method:"call",params:r,result:n,error:e})}}))}estimateGas(e){return fs(this,void 0,void 0,(function*(){yield this.getNetwork();const t=yield re({transaction:this._getTransactionRequest(e)}),r=yield this.perform("estimateGas",t);try{return J.from(r)}catch(e){return ps.throwError("bad result from backend",v.errors.SERVER_ERROR,{method:"estimateGas",params:t,result:r,error:e})}}))}_getAddress(e){return fs(this,void 0,void 0,(function*(){"string"!=typeof(e=yield e)&&ps.throwArgumentError("invalid address or ENS name","name",e);const t=yield this.resolveName(e);return null==t&&ps.throwError("ENS name not configured",v.errors.UNSUPPORTED_OPERATION,{operation:`resolveName(${JSON.stringify(e)})`}),t}))}_getBlock(e,t){return fs(this,void 0,void 0,(function*(){yield this.getNetwork(),e=yield e;let r=-128;const n={includeTransactions:!!t};if(T(e,32))n.blockHash=e;else try{n.blockTag=yield this._getBlockTag(e),T(n.blockTag)&&(r=parseInt(n.blockTag.substring(2),16))}catch(t){ps.throwArgumentError("invalid block hash or block tag","blockHashOrBlockTag",e)}return ns((()=>fs(this,void 0,void 0,(function*(){const e=yield this.perform("getBlock",n);if(null==e)return null!=n.blockHash&&null==this._emitted["b:"+n.blockHash]||null!=n.blockTag&&r>this._emitted.block?null:void 0;if(t){let t=null;for(let r=0;r<e.transactions.length;r++){const n=e.transactions[r];if(null==n.blockNumber)n.confirmations=0;else if(null==n.confirmations){null==t&&(t=yield this._getInternalBlockNumber(100+2*this.pollingInterval));let e=t-n.blockNumber+1;e<=0&&(e=1),n.confirmations=e}}const r=this.formatter.blockWithTransactions(e);return r.transactions=r.transactions.map((e=>this._wrapTransaction(e))),r}return this.formatter.block(e)}))),{oncePoll:this})}))}getBlock(e){return this._getBlock(e,!1)}getBlockWithTransactions(e){return this._getBlock(e,!0)}getTransaction(e){return fs(this,void 0,void 0,(function*(){yield this.getNetwork(),e=yield e;const t={transactionHash:this.formatter.hash(e,!0)};return ns((()=>fs(this,void 0,void 0,(function*(){const r=yield this.perform("getTransaction",t);if(null==r)return null==this._emitted["t:"+e]?null:void 0;const n=this.formatter.transactionResponse(r);if(null==n.blockNumber)n.confirmations=0;else if(null==n.confirmations){let e=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-n.blockNumber+1;e<=0&&(e=1),n.confirmations=e}return this._wrapTransaction(n)}))),{oncePoll:this})}))}getTransactionReceipt(e){return fs(this,void 0,void 0,(function*(){yield this.getNetwork(),e=yield e;const t={transactionHash:this.formatter.hash(e,!0)};return ns((()=>fs(this,void 0,void 0,(function*(){const r=yield this.perform("getTransactionReceipt",t);if(null==r)return null==this._emitted["t:"+e]?null:void 0;if(null==r.blockHash)return;const n=this.formatter.receipt(r);if(null==n.blockNumber)n.confirmations=0;else if(null==n.confirmations){let e=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-n.blockNumber+1;e<=0&&(e=1),n.confirmations=e}return n}))),{oncePoll:this})}))}getLogs(e){return fs(this,void 0,void 0,(function*(){yield this.getNetwork();const t=yield re({filter:this._getFilter(e)}),r=yield this.perform("getLogs",t);return r.forEach((e=>{null==e.removed&&(e.removed=!1)})),ls.arrayOf(this.formatter.filterLog.bind(this.formatter))(r)}))}getEtherPrice(){return fs(this,void 0,void 0,(function*(){return yield this.getNetwork(),this.perform("getEtherPrice",{})}))}_getBlockTag(e){return fs(this,void 0,void 0,(function*(){if("number"==typeof(e=yield e)&&e<0){e%1&&ps.throwArgumentError("invalid BlockTag","blockTag",e);let t=yield this._getInternalBlockNumber(100+2*this.pollingInterval);return t+=e,t<0&&(t=0),this.formatter.blockTag(t)}return this.formatter.blockTag(e)}))}getResolver(e){return fs(this,void 0,void 0,(function*(){try{const t=yield this._getResolver(e);return null==t?null:new Ns(this,t,e)}catch(e){if(e.code===v.errors.CALL_EXCEPTION)return null;throw e}}))}_getResolver(e){return fs(this,void 0,void 0,(function*(){const t=yield this.getNetwork();t.ensAddress||ps.throwError("network does not support ENS",v.errors.UNSUPPORTED_OPERATION,{operation:"ENS",network:t.name});const r={to:t.ensAddress,data:"0x0178b8bf"+Jo(e).substring(2)};try{return this.formatter.callAddress(yield this.call(r))}catch(e){if(e.code===v.errors.CALL_EXCEPTION)return null;throw e}}))}resolveName(e){return fs(this,void 0,void 0,(function*(){e=yield e;try{return Promise.resolve(this.formatter.address(e))}catch(t){if(T(e))throw t}"string"!=typeof e&&ps.throwArgumentError("invalid ENS name","name",e);const t=yield this.getResolver(e);return t?yield t.getAddress():null}))}lookupAddress(e){return fs(this,void 0,void 0,(function*(){e=yield e;const t=(e=this.formatter.address(e)).substring(2).toLowerCase()+".addr.reverse",r=yield this._getResolver(t);if(!r)return null;let n=A(yield this.call({to:r,data:"0x691f3431"+Jo(t).substring(2)}));if(n.length<32||!J.from(n.slice(0,32)).eq(32))return null;if(n=n.slice(32),n.length<32)return null;const i=J.from(n.slice(0,32)).toNumber();if(n=n.slice(32),i>n.length)return null;const o=Je(n.slice(0,i));return(yield this.resolveName(o))!=e?null:o}))}getAvatar(e){return fs(this,void 0,void 0,(function*(){let t=null;if(T(e)){const r=this.formatter.address(e),n=r.substring(2).toLowerCase()+".addr.reverse",i=yield this._getResolver(n);if(!i)return null;t=new Ns(this,i,"_",r)}else if(t=yield this.getResolver(e),!t)return null;const r=yield t.getAvatar();return null==r?null:r.url}))}perform(e,t){return ps.throwError(e+" not implemented",v.errors.NOT_IMPLEMENTED,{operation:e})}_startEvent(e){this.polling=this._events.filter((e=>e.pollable())).length>0}_stopEvent(e){this.polling=this._events.filter((e=>e.pollable())).length>0}_addEventListener(e,t,r){const n=new _s(gs(e),t,r);return this._events.push(n),this._startEvent(n),this}on(e,t){return this._addEventListener(e,t,!1)}once(e,t){return this._addEventListener(e,t,!0)}emit(e,...t){let r=!1,n=[],i=gs(e);return this._events=this._events.filter((e=>e.tag!==i||(setTimeout((()=>{e.listener.apply(this,t)}),0),r=!0,!e.once||(n.push(e),!1)))),n.forEach((e=>{this._stopEvent(e)})),r}listenerCount(e){if(!e)return this._events.length;let t=gs(e);return this._events.filter((e=>e.tag===t)).length}listeners(e){if(null==e)return this._events.map((e=>e.listener));let t=gs(e);return this._events.filter((e=>e.tag===t)).map((e=>e.listener))}off(e,t){if(null==t)return this.removeAllListeners(e);const r=[];let n=!1,i=gs(e);return this._events=this._events.filter((e=>e.tag!==i||e.listener!=t||!!n||(n=!0,r.push(e),!1))),r.forEach((e=>{this._stopEvent(e)})),this}removeAllListeners(e){let t=[];if(null==e)t=this._events,this._events=[];else{const r=gs(e);this._events=this._events.filter((e=>e.tag!==r||(t.push(e),!1)))}return t.forEach((e=>{this._stopEvent(e)})),this}}var Is=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((n=n.apply(e,t||[])).next())}))};const Os=new v(ss),Ds=["call","estimateGas"];function Ks(e,t,r){if("call"===e&&t.code===v.errors.SERVER_ERROR){const e=t.error;if(e&&e.message.match("reverted")&&T(e.data))return e.data;Os.throwError("missing revert data in call exception",v.errors.CALL_EXCEPTION,{error:t,data:"0x"})}let n=t.message;t.code===v.errors.SERVER_ERROR&&t.error&&"string"==typeof t.error.message?n=t.error.message:"string"==typeof t.body?n=t.body:"string"==typeof t.responseText&&(n=t.responseText),n=(n||"").toLowerCase();const i=r.transaction||r.signedTransaction;throw n.match(/insufficient funds|base fee exceeds gas limit/)&&Os.throwError("insufficient funds for intrinsic transaction cost",v.errors.INSUFFICIENT_FUNDS,{error:t,method:e,transaction:i}),n.match(/nonce too low/)&&Os.throwError("nonce has already been used",v.errors.NONCE_EXPIRED,{error:t,method:e,transaction:i}),n.match(/replacement transaction underpriced/)&&Os.throwError("replacement fee too low",v.errors.REPLACEMENT_UNDERPRICED,{error:t,method:e,transaction:i}),n.match(/only replay-protected/)&&Os.throwError("legacy pre-eip-155 transactions not supported",v.errors.UNSUPPORTED_OPERATION,{error:t,method:e,transaction:i}),Ds.indexOf(e)>=0&&n.match(/gas required exceeds allowance|always failing transaction|execution reverted/)&&Os.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",v.errors.UNPREDICTABLE_GAS_LIMIT,{error:t,method:e,transaction:i}),t}function Us(e){return new Promise((function(t){setTimeout(t,e)}))}function Fs(e){if(e.error){const t=new Error(e.error.message);throw t.code=e.error.code,t.data=e.error.data,t}return e.result}function js(e){return e?e.toLowerCase():e}const Ls={};class qs extends lr{constructor(e,t,r){if(Os.checkNew(new.target,qs),super(),e!==Ls)throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner");ee(this,"provider",t),null==r&&(r=0),"string"==typeof r?(ee(this,"_address",this.provider.formatter.address(r)),ee(this,"_index",null)):"number"==typeof r?(ee(this,"_index",r),ee(this,"_address",null)):Os.throwArgumentError("invalid address or index","addressOrIndex",r)}connect(e){return Os.throwError("cannot alter JSON-RPC Signer connection",v.errors.UNSUPPORTED_OPERATION,{operation:"connect"})}connectUnchecked(){return new zs(Ls,this.provider,this._address||this._index)}getAddress(){return this._address?Promise.resolve(this._address):this.provider.send("eth_accounts",[]).then((e=>(e.length<=this._index&&Os.throwError("unknown account #"+this._index,v.errors.UNSUPPORTED_OPERATION,{operation:"getAddress"}),this.provider.formatter.address(e[this._index]))))}sendUncheckedTransaction(e){e=ie(e);const t=this.getAddress().then((e=>(e&&(e=e.toLowerCase()),e)));if(null==e.gasLimit){const r=ie(e);r.from=t,e.gasLimit=this.provider.estimateGas(r)}return null!=e.to&&(e.to=Promise.resolve(e.to).then((e=>Is(this,void 0,void 0,(function*(){if(null==e)return null;const t=yield this.provider.resolveName(e);return null==t&&Os.throwArgumentError("provided ENS name resolves to null","tx.to",e),t}))))),re({tx:re(e),sender:t}).then((({tx:t,sender:r})=>{null!=t.from?t.from.toLowerCase()!==r&&Os.throwArgumentError("from address mismatch","transaction",e):t.from=r;const n=this.provider.constructor.hexlifyTransaction(t,{from:!0});return this.provider.send("eth_sendTransaction",[n]).then((e=>e),(e=>Ks("sendTransaction",e,n)))}))}signTransaction(e){return Os.throwError("signing transactions is unsupported",v.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})}sendTransaction(e){return Is(this,void 0,void 0,(function*(){const t=yield this.provider._getInternalBlockNumber(100+2*this.provider.pollingInterval),r=yield this.sendUncheckedTransaction(e);try{return yield ns((()=>Is(this,void 0,void 0,(function*(){const e=yield this.provider.getTransaction(r);if(null!==e)return this.provider._wrapTransaction(e,r,t)}))),{oncePoll:this.provider})}catch(e){throw e.transactionHash=r,e}}))}signMessage(e){return Is(this,void 0,void 0,(function*(){const t="string"==typeof e?We(e):e,r=yield this.getAddress();return yield this.provider.send("personal_sign",[R(t),r.toLowerCase()])}))}_legacySignMessage(e){return Is(this,void 0,void 0,(function*(){const t="string"==typeof e?We(e):e,r=yield this.getAddress();return yield this.provider.send("eth_sign",[r.toLowerCase(),R(t)])}))}_signTypedData(e,t,r){return Is(this,void 0,void 0,(function*(){const n=yield ci.resolveNames(e,t,r,(e=>this.provider.resolveName(e))),i=yield this.getAddress();return yield this.provider.send("eth_signTypedData_v4",[i.toLowerCase(),JSON.stringify(ci.getPayload(n.domain,t,n.value))])}))}unlock(e){return Is(this,void 0,void 0,(function*(){const t=this.provider,r=yield this.getAddress();return t.send("personal_unlockAccount",[r.toLowerCase(),e,null])}))}}class zs extends qs{sendTransaction(e){return this.sendUncheckedTransaction(e).then((e=>({hash:e,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:t=>this.provider.waitForTransaction(e,t)})))}}const Ws={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0,type:!0,accessList:!0,maxFeePerGas:!0,maxPriorityFeePerGas:!0};class Gs extends Ms{constructor(e,t){Os.checkNew(new.target,Gs);let r=t;null==r&&(r=new Promise(((e,t)=>{setTimeout((()=>{this.detectNetwork().then((t=>{e(t)}),(e=>{t(e)}))}),0)}))),super(r),e||(e=te(this.constructor,"defaultUrl")()),ee(this,"connection","string"==typeof e?Object.freeze({url:e}):Object.freeze(ie(e))),this._nextId=42}get _cache(){return null==this._eventLoopCache&&(this._eventLoopCache={}),this._eventLoopCache}static defaultUrl(){return"http://localhost:8545"}detectNetwork(){return this._cache.detectNetwork||(this._cache.detectNetwork=this._uncachedDetectNetwork(),setTimeout((()=>{this._cache.detectNetwork=null}),0)),this._cache.detectNetwork}_uncachedDetectNetwork(){return Is(this,void 0,void 0,(function*(){yield Us(0);let e=null;try{e=yield this.send("eth_chainId",[])}catch(t){try{e=yield this.send("net_version",[])}catch(e){}}if(null!=e){const t=te(this.constructor,"getNetwork");try{return t(J.from(e).toNumber())}catch(t){return Os.throwError("could not detect network",v.errors.NETWORK_ERROR,{chainId:e,event:"invalidNetwork",serverError:t})}}return Os.throwError("could not detect network",v.errors.NETWORK_ERROR,{event:"noNetwork"})}))}getSigner(e){return new qs(Ls,this,e)}getUncheckedSigner(e){return this.getSigner(e).connectUnchecked()}listAccounts(){return this.send("eth_accounts",[]).then((e=>e.map((e=>this.formatter.address(e)))))}send(e,t){const r={method:e,params:t,id:this._nextId++,jsonrpc:"2.0"};this.emit("debug",{action:"request",request:le(r),provider:this});const n=["eth_chainId","eth_blockNumber"].indexOf(e)>=0;if(n&&this._cache[e])return this._cache[e];const i=rs(this.connection,JSON.stringify(r),Fs).then((e=>(this.emit("debug",{action:"response",request:r,response:e,provider:this}),e)),(e=>{throw this.emit("debug",{action:"response",error:e,request:r,provider:this}),e}));return n&&(this._cache[e]=i,setTimeout((()=>{this._cache[e]=null}),0)),i}prepareRequest(e,t){switch(e){case"getBlockNumber":return["eth_blockNumber",[]];case"getGasPrice":return["eth_gasPrice",[]];case"getBalance":return["eth_getBalance",[js(t.address),t.blockTag]];case"getTransactionCount":return["eth_getTransactionCount",[js(t.address),t.blockTag]];case"getCode":return["eth_getCode",[js(t.address),t.blockTag]];case"getStorageAt":return["eth_getStorageAt",[js(t.address),t.position,t.blockTag]];case"sendTransaction":return["eth_sendRawTransaction",[t.signedTransaction]];case"getBlock":return t.blockTag?["eth_getBlockByNumber",[t.blockTag,!!t.includeTransactions]]:t.blockHash?["eth_getBlockByHash",[t.blockHash,!!t.includeTransactions]]:null;case"getTransaction":return["eth_getTransactionByHash",[t.transactionHash]];case"getTransactionReceipt":return["eth_getTransactionReceipt",[t.transactionHash]];case"call":return["eth_call",[te(this.constructor,"hexlifyTransaction")(t.transaction,{from:!0}),t.blockTag]];case"estimateGas":return["eth_estimateGas",[te(this.constructor,"hexlifyTransaction")(t.transaction,{from:!0})]];case"getLogs":return t.filter&&null!=t.filter.address&&(t.filter.address=js(t.filter.address)),["eth_getLogs",[t.filter]]}return null}perform(e,t){return Is(this,void 0,void 0,(function*(){if("call"===e||"estimateGas"===e){const e=t.transaction;if(e&&null!=e.type&&J.from(e.type).isZero()&&null==e.maxFeePerGas&&null==e.maxPriorityFeePerGas){const r=yield this.getFeeData();null==r.maxFeePerGas&&null==r.maxPriorityFeePerGas&&((t=ie(t)).transaction=ie(e),delete t.transaction.type)}}const r=this.prepareRequest(e,t);null==r&&Os.throwError(e+" not implemented",v.errors.NOT_IMPLEMENTED,{operation:e});try{return yield this.send(r[0],r[1])}catch(r){return Ks(e,r,t)}}))}_startEvent(e){"pending"===e.tag&&this._startPending(),super._startEvent(e)}_startPending(){if(null!=this._pendingFilter)return;const e=this,t=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=t,t.then((function(r){return function n(){e.send("eth_getFilterChanges",[r]).then((function(r){if(e._pendingFilter!=t)return null;let n=Promise.resolve();return r.forEach((function(t){e._emitted["t:"+t.toLowerCase()]="pending",n=n.then((function(){return e.getTransaction(t).then((function(t){return e.emit("pending",t),null}))}))})),n.then((function(){return Us(1e3)}))})).then((function(){if(e._pendingFilter==t)return setTimeout((function(){n()}),0),null;e.send("eth_uninstallFilter",[r])})).catch((e=>{}))}(),r})).catch((e=>{}))}_stopEvent(e){"pending"===e.tag&&0===this.listenerCount("pending")&&(this._pendingFilter=null),super._stopEvent(e)}static hexlifyTransaction(e,t){const r=ie(Ws);if(t)for(const e in t)t[e]&&(r[e]=!0);ne(e,r);const n={};return["gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach((function(t){if(null==e[t])return;const r=O(e[t]);"gasLimit"===t&&(t="gas"),n[t]=r})),["from","to","data"].forEach((function(t){null!=e[t]&&(n[t]=R(e[t]))})),e.accessList&&(n.accessList=hn(e.accessList)),n}}let Vs=null;try{if(Vs=WebSocket,null==Vs)throw new Error("inject please")}catch(e){const t=new v(ss);Vs=function(){t.throwError("WebSockets not supported in this environment",v.errors.UNSUPPORTED_OPERATION,{operation:"new WebSocket()"})}}var Hs=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((n=n.apply(e,t||[])).next())}))};const Js=new v(ss);let $s=1;class Zs extends Gs{constructor(e,t){"any"===t&&Js.throwError("WebSocketProvider does not support 'any' network yet",v.errors.UNSUPPORTED_OPERATION,{operation:"network:any"}),super(e,t),this._pollingInterval=-1,this._wsReady=!1,ee(this,"_websocket",new Vs(this.connection.url)),ee(this,"_requests",{}),ee(this,"_subs",{}),ee(this,"_subIds",{}),ee(this,"_detectNetwork",super.detectNetwork()),this._websocket.onopen=()=>{this._wsReady=!0,Object.keys(this._requests).forEach((e=>{this._websocket.send(this._requests[e].payload)}))},this._websocket.onmessage=e=>{const t=e.data,r=JSON.parse(t);if(null!=r.id){const e=String(r.id),n=this._requests[e];if(delete this._requests[e],void 0!==r.result)n.callback(null,r.result),this.emit("debug",{action:"response",request:JSON.parse(n.payload),response:r.result,provider:this});else{let e=null;r.error?(e=new Error(r.error.message||"unknown error"),ee(e,"code",r.error.code||null),ee(e,"response",t)):e=new Error("unknown error"),n.callback(e,void 0),this.emit("debug",{action:"response",error:e,request:JSON.parse(n.payload),provider:this})}}else if("eth_subscription"===r.method){const e=this._subs[r.params.subscription];e&&e.processFunc(r.params.result)}else console.warn("this should not happen")};const r=setInterval((()=>{this.emit("poll")}),1e3);r.unref&&r.unref()}detectNetwork(){return this._detectNetwork}get pollingInterval(){return 0}resetEventsBlock(e){Js.throwError("cannot reset events block on WebSocketProvider",v.errors.UNSUPPORTED_OPERATION,{operation:"resetEventBlock"})}set pollingInterval(e){Js.throwError("cannot set polling interval on WebSocketProvider",v.errors.UNSUPPORTED_OPERATION,{operation:"setPollingInterval"})}poll(){return Hs(this,void 0,void 0,(function*(){return null}))}set polling(e){e&&Js.throwError("cannot set polling on WebSocketProvider",v.errors.UNSUPPORTED_OPERATION,{operation:"setPolling"})}send(e,t){const r=$s++;return new Promise(((n,i)=>{const o=JSON.stringify({method:e,params:t,id:r,jsonrpc:"2.0"});this.emit("debug",{action:"request",request:JSON.parse(o),provider:this}),this._requests[String(r)]={callback:function(e,t){return e?i(e):n(t)},payload:o},this._wsReady&&this._websocket.send(o)}))}static defaultUrl(){return"ws://localhost:8546"}_subscribe(e,t,r){return Hs(this,void 0,void 0,(function*(){let n=this._subIds[e];null==n&&(n=Promise.all(t).then((e=>this.send("eth_subscribe",e))),this._subIds[e]=n);const i=yield n;this._subs[i]={tag:e,processFunc:r}}))}_startEvent(e){switch(e.type){case"block":this._subscribe("block",["newHeads"],(e=>{const t=J.from(e.number).toNumber();this._emitted.block=t,this.emit("block",t)}));break;case"pending":this._subscribe("pending",["newPendingTransactions"],(e=>{this.emit("pending",e)}));break;case"filter":this._subscribe(e.tag,["logs",this._getFilter(e.filter)],(t=>{null==t.removed&&(t.removed=!1),this.emit(e.filter,this.formatter.filterLog(t))}));break;case"tx":{const t=e=>{const t=e.hash;this.getTransactionReceipt(t).then((e=>{e&&this.emit(t,e)}))};t(e),this._subscribe("tx",["newHeads"],(e=>{this._events.filter((e=>"tx"===e.type)).forEach(t)}));break}case"debug":case"poll":case"willPoll":case"didPoll":case"error":break;default:console.log("unhandled:",e)}}_stopEvent(e){let t=e.tag;if("tx"===e.type){if(this._events.filter((e=>"tx"===e.type)).length)return;t="tx"}else if(this.listenerCount(e.event))return;const r=this._subIds[t];r&&(delete this._subIds[t],r.then((e=>{this._subs[e]&&(delete this._subs[e],this.send("eth_unsubscribe",[e]))})))}destroy(){return Hs(this,void 0,void 0,(function*(){this._websocket.readyState===Vs.CONNECTING&&(yield new Promise((e=>{this._websocket.onopen=function(){e(!0)},this._websocket.onerror=function(){e(!1)}}))),this._websocket.close(1e3)}))}}const Xs=new v(ss);class Qs extends Gs{detectNetwork(){const e=Object.create(null,{detectNetwork:{get:()=>super.detectNetwork}});return t=this,r=void 0,i=function*(){let t=this.network;return null==t&&(t=yield e.detectNetwork.call(this),t||Xs.throwError("no network detected",v.errors.UNKNOWN_ERROR,{}),null==this._network&&(ee(this,"_network",t),this.emit("network",t,null))),t},new((n=void 0)||(n=Promise))((function(e,o){function s(e){try{l(i.next(e))}catch(e){o(e)}}function a(e){try{l(i.throw(e))}catch(e){o(e)}}function l(t){var r;t.done?e(t.value):(r=t.value,r instanceof n?r:new n((function(e){e(r)}))).then(s,a)}l((i=i.apply(t,r||[])).next())}));var t,r,n,i}}class Ys extends Qs{constructor(e,t){Xs.checkAbstract(new.target,Ys),e=te(new.target,"getNetwork")(e),t=te(new.target,"getApiKey")(t),super(te(new.target,"getUrl")(e,t),e),"string"==typeof t?ee(this,"apiKey",t):null!=t&&Object.keys(t).forEach((e=>{ee(this,e,t[e])}))}_startPending(){Xs.warn("WARNING: API provider does not support pending filters")}isCommunityResource(){return!1}getSigner(e){return Xs.throwError("API provider does not support signing",v.errors.UNSUPPORTED_OPERATION,{operation:"getSigner"})}listAccounts(){return Promise.resolve([])}static getApiKey(e){return e}static getUrl(e,t){return Xs.throwError("not implemented; sub-classes must override getUrl",v.errors.NOT_IMPLEMENTED,{operation:"getUrl"})}}const ea=new v(ss),ta="_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC";class ra extends Zs{constructor(e,t){const r=new na(e,t);super(r.connection.url.replace(/^http/i,"ws").replace(".alchemyapi.",".ws.alchemyapi."),r.network),ee(this,"apiKey",r.apiKey)}isCommunityResource(){return this.apiKey===ta}}class na extends Ys{static getWebSocketProvider(e,t){return new ra(e,t)}static getApiKey(e){return null==e?ta:(e&&"string"!=typeof e&&ea.throwArgumentError("invalid apiKey","apiKey",e),e)}static getUrl(e,t){let r=null;switch(e.name){case"homestead":r="eth-mainnet.alchemyapi.io/v2/";break;case"ropsten":r="eth-ropsten.alchemyapi.io/v2/";break;case"rinkeby":r="eth-rinkeby.alchemyapi.io/v2/";break;case"goerli":r="eth-goerli.alchemyapi.io/v2/";break;case"kovan":r="eth-kovan.alchemyapi.io/v2/";break;case"matic":r="polygon-mainnet.g.alchemy.com/v2/";break;case"maticmum":r="polygon-mumbai.g.alchemy.com/v2/";break;case"arbitrum":r="arb-mainnet.g.alchemy.com/v2/";break;case"arbitrum-rinkeby":r="arb-rinkeby.g.alchemy.com/v2/";break;case"optimism":r="opt-mainnet.g.alchemy.com/v2/";break;case"optimism-kovan":r="opt-kovan.g.alchemy.com/v2/";break;default:ea.throwArgumentError("unsupported network","network",arguments[0])}return{allowGzip:!0,url:"https://"+r+t,throttleCallback:(e,r)=>(t===ta&&ds(),Promise.resolve(!0))}}isCommunityResource(){return this.apiKey===ta}}const ia=new v(ss);class oa extends Ys{static getApiKey(e){return null!=e&&ia.throwArgumentError("apiKey not supported for cloudflare","apiKey",e),null}static getUrl(e,t){let r=null;return"homestead"===e.name?r="https://cloudflare-eth.com/":ia.throwArgumentError("unsupported network","network",arguments[0]),r}perform(e,t){const r=Object.create(null,{perform:{get:()=>super.perform}});return n=this,i=void 0,s=function*(){return"getBlockNumber"===e?(yield r.perform.call(this,"getBlock",{blockTag:"latest"})).number:r.perform.call(this,e,t)},new((o=void 0)||(o=Promise))((function(e,t){function r(e){try{l(s.next(e))}catch(e){t(e)}}function a(e){try{l(s.throw(e))}catch(e){t(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o((function(e){e(n)}))).then(r,a)}l((s=s.apply(n,i||[])).next())}));var n,i,o,s}}var sa=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((n=n.apply(e,t||[])).next())}))};const aa=new v(ss);function la(e){const t={};for(let r in e){if(null==e[r])continue;let n=e[r];"type"===r&&0===n||(n={type:!0,gasLimit:!0,gasPrice:!0,maxFeePerGs:!0,maxPriorityFeePerGas:!0,nonce:!0,value:!0}[r]?O(R(n)):"accessList"===r?"["+hn(n).map((e=>`{address:"${e.address}",storageKeys:["${e.storageKeys.join('","')}"]}`)).join(",")+"]":R(n),t[r]=n)}return t}function ua(e){if(0==e.status&&("No records found"===e.message||"No transactions found"===e.message))return e.result;if(1!=e.status||"OK"!=e.message){const t=new Error("invalid response");throw t.result=JSON.stringify(e),(e.result||"").toLowerCase().indexOf("rate limit")>=0&&(t.throttleRetry=!0),t}return e.result}function ca(e){if(e&&0==e.status&&"NOTOK"==e.message&&(e.result||"").toLowerCase().indexOf("rate limit")>=0){const t=new Error("throttled response");throw t.result=JSON.stringify(e),t.throttleRetry=!0,t}if("2.0"!=e.jsonrpc){const t=new Error("invalid response");throw t.result=JSON.stringify(e),t}if(e.error){const t=new Error(e.error.message||"unknown error");throw e.error.code&&(t.code=e.error.code),e.error.data&&(t.data=e.error.data),t}return e.result}function ha(e){if("pending"===e)throw new Error("pending not supported");return"latest"===e?e:parseInt(e.substring(2),16)}const da="9D13ZE7XSBTJ94N9BNJ2MA33VMAY2YPIRB";function fa(e,t,r){if("call"===e&&t.code===v.errors.SERVER_ERROR){const e=t.error;if(e&&(e.message.match(/reverted/i)||e.message.match(/VM execution error/i))){let r=e.data;if(r&&(r="0x"+r.replace(/^.*0x/i,"")),T(r))return r;aa.throwError("missing revert data in call exception",v.errors.CALL_EXCEPTION,{error:t,data:"0x"})}}let n=t.message;throw t.code===v.errors.SERVER_ERROR&&(t.error&&"string"==typeof t.error.message?n=t.error.message:"string"==typeof t.body?n=t.body:"string"==typeof t.responseText&&(n=t.responseText)),n=(n||"").toLowerCase(),n.match(/insufficient funds/)&&aa.throwError("insufficient funds for intrinsic transaction cost",v.errors.INSUFFICIENT_FUNDS,{error:t,method:e,transaction:r}),n.match(/same hash was already imported|transaction nonce is too low|nonce too low/)&&aa.throwError("nonce has already been used",v.errors.NONCE_EXPIRED,{error:t,method:e,transaction:r}),n.match(/another transaction with same nonce/)&&aa.throwError("replacement fee too low",v.errors.REPLACEMENT_UNDERPRICED,{error:t,method:e,transaction:r}),n.match(/execution failed due to an exception|execution reverted/)&&aa.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",v.errors.UNPREDICTABLE_GAS_LIMIT,{error:t,method:e,transaction:r}),t}class pa extends Ms{constructor(e,t){aa.checkNew(new.target,pa),super(e),ee(this,"baseUrl",this.getBaseUrl()),ee(this,"apiKey",t||da)}getBaseUrl(){switch(this.network?this.network.name:"invalid"){case"homestead":return"https://api.etherscan.io";case"ropsten":return"https://api-ropsten.etherscan.io";case"rinkeby":return"https://api-rinkeby.etherscan.io";case"kovan":return"https://api-kovan.etherscan.io";case"goerli":return"https://api-goerli.etherscan.io"}return aa.throwArgumentError("unsupported network","network",name)}getUrl(e,t){const r=Object.keys(t).reduce(((e,r)=>{const n=t[r];return null!=n&&(e+=`&${r}=${n}`),e}),""),n=this.apiKey?`&apikey=${this.apiKey}`:"";return`${this.baseUrl}/api?module=${e}${r}${n}`}getPostUrl(){return`${this.baseUrl}/api`}getPostData(e,t){return t.module=e,t.apikey=this.apiKey,t}fetch(e,t,r){return sa(this,void 0,void 0,(function*(){const n=r?this.getPostUrl():this.getUrl(e,t),i=r?this.getPostData(e,t):null,o="proxy"===e?ca:ua;this.emit("debug",{action:"request",request:n,provider:this});const s={url:n,throttleSlotInterval:1e3,throttleCallback:(e,t)=>(this.isCommunityResource()&&ds(),Promise.resolve(!0))};let a=null;i&&(s.headers={"content-type":"application/x-www-form-urlencoded; charset=UTF-8"},a=Object.keys(i).map((e=>`${e}=${i[e]}`)).join("&"));const l=yield rs(s,a,o||ca);return this.emit("debug",{action:"response",request:n,response:le(l),provider:this}),l}))}detectNetwork(){return sa(this,void 0,void 0,(function*(){return this.network}))}perform(e,t){const r=Object.create(null,{perform:{get:()=>super.perform}});return sa(this,void 0,void 0,(function*(){switch(e){case"getBlockNumber":return this.fetch("proxy",{action:"eth_blockNumber"});case"getGasPrice":return this.fetch("proxy",{action:"eth_gasPrice"});case"getBalance":return this.fetch("account",{action:"balance",address:t.address,tag:t.blockTag});case"getTransactionCount":return this.fetch("proxy",{action:"eth_getTransactionCount",address:t.address,tag:t.blockTag});case"getCode":return this.fetch("proxy",{action:"eth_getCode",address:t.address,tag:t.blockTag});case"getStorageAt":return this.fetch("proxy",{action:"eth_getStorageAt",address:t.address,position:t.position,tag:t.blockTag});case"sendTransaction":return this.fetch("proxy",{action:"eth_sendRawTransaction",hex:t.signedTransaction},!0).catch((e=>fa("sendTransaction",e,t.signedTransaction)));case"getBlock":if(t.blockTag)return this.fetch("proxy",{action:"eth_getBlockByNumber",tag:t.blockTag,boolean:t.includeTransactions?"true":"false"});throw new Error("getBlock by blockHash not implemented");case"getTransaction":return this.fetch("proxy",{action:"eth_getTransactionByHash",txhash:t.transactionHash});case"getTransactionReceipt":return this.fetch("proxy",{action:"eth_getTransactionReceipt",txhash:t.transactionHash});case"call":{if("latest"!==t.blockTag)throw new Error("EtherscanProvider does not support blockTag for call");const e=la(t.transaction);e.module="proxy",e.action="eth_call";try{return yield this.fetch("proxy",e,!0)}catch(e){return fa("call",e,t.transaction)}}case"estimateGas":{const e=la(t.transaction);e.module="proxy",e.action="eth_estimateGas";try{return yield this.fetch("proxy",e,!0)}catch(e){return fa("estimateGas",e,t.transaction)}}case"getLogs":{const e={action:"getLogs"};if(t.filter.fromBlock&&(e.fromBlock=ha(t.filter.fromBlock)),t.filter.toBlock&&(e.toBlock=ha(t.filter.toBlock)),t.filter.address&&(e.address=t.filter.address),t.filter.topics&&t.filter.topics.length>0&&(t.filter.topics.length>1&&aa.throwError("unsupported topic count",v.errors.UNSUPPORTED_OPERATION,{topics:t.filter.topics}),1===t.filter.topics.length)){const r=t.filter.topics[0];"string"==typeof r&&66===r.length||aa.throwError("unsupported topic format",v.errors.UNSUPPORTED_OPERATION,{topic0:r}),e.topic0=r}const r=yield this.fetch("logs",e);let n={};for(let e=0;e<r.length;e++){const t=r[e];if(null==t.blockHash){if(null==n[t.blockNumber]){const e=yield this.getBlock(t.blockNumber);e&&(n[t.blockNumber]=e.hash)}t.blockHash=n[t.blockNumber]}}return r}case"getEtherPrice":return"homestead"!==this.network.name?0:parseFloat((yield this.fetch("stats",{action:"ethprice"})).ethusd)}return r.perform.call(this,e,t)}))}getHistory(e,t,r){return sa(this,void 0,void 0,(function*(){const n={action:"txlist",address:yield this.resolveName(e),startblock:null==t?0:t,endblock:null==r?99999999:r,sort:"asc"};return(yield this.fetch("account",n)).map((e=>{["contractAddress","to"].forEach((function(t){""==e[t]&&delete e[t]})),null==e.creates&&null!=e.contractAddress&&(e.creates=e.contractAddress);const t=this.formatter.transactionResponse(e);return e.timeStamp&&(t.timestamp=parseInt(e.timeStamp)),t}))}))}isCommunityResource(){return this.apiKey===da}}function ma(e){for(let t=(e=e.slice()).length-1;t>0;t--){const r=Math.floor(Math.random()*(t+1)),n=e[t];e[t]=e[r],e[r]=n}return e}var ya=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((n=n.apply(e,t||[])).next())}))};const ga=new v(ss);function va(){return(new Date).getTime()}function ba(e){let t=null;for(let r=0;r<e.length;r++){const n=e[r];if(null==n)return null;t?t.name===n.name&&t.chainId===n.chainId&&(t.ensAddress===n.ensAddress||null==t.ensAddress&&null==n.ensAddress)||ga.throwArgumentError("provider mismatch","networks",e):t=n}return t}function wa(e,t){e=e.slice().sort();const r=Math.floor(e.length/2);if(e.length%2)return e[r];const n=e[r-1],i=e[r];return null!=t&&Math.abs(n-i)>t?null:(n+i)/2}function _a(e){if(null===e)return"null";if("number"==typeof e||"boolean"==typeof e)return JSON.stringify(e);if("string"==typeof e)return e;if(J.isBigNumber(e))return e.toString();if(Array.isArray(e))return JSON.stringify(e.map((e=>_a(e))));if("object"==typeof e){const t=Object.keys(e);return t.sort(),"{"+t.map((t=>{let r=e[t];return r="function"==typeof r?"[function]":_a(r),JSON.stringify(t)+":"+r})).join(",")+"}"}throw new Error("unknown value type: "+typeof e)}let Sa=1;function Ea(e){let t=null,r=null,n=new Promise((n=>{t=function(){r&&(clearTimeout(r),r=null),n()},r=setTimeout(t,e)}));return{cancel:t,getPromise:function(){return n},wait:e=>(n=n.then(e),n)}}const ka=[v.errors.CALL_EXCEPTION,v.errors.INSUFFICIENT_FUNDS,v.errors.NONCE_EXPIRED,v.errors.REPLACEMENT_UNDERPRICED,v.errors.UNPREDICTABLE_GAS_LIMIT],Aa=["address","args","errorArgs","errorSignature","method","transaction"];function Pa(e,t){const r={weight:e.weight};return Object.defineProperty(r,"provider",{get:()=>e.provider}),e.start&&(r.start=e.start),t&&(r.duration=t-e.start),e.done&&(e.error?r.error=e.error:r.result=e.result||null),r}function xa(e,t){return ya(this,void 0,void 0,(function*(){const r=e.provider;return null!=r.blockNumber&&r.blockNumber>=t||-1===t?r:ns((()=>new Promise(((n,i)=>{setTimeout((function(){return r.blockNumber>=t?n(r):e.cancelled?n(null):n(void 0)}),0)}))),{oncePoll:r})}))}function Ca(e,t,r,n){return ya(this,void 0,void 0,(function*(){let i=e.provider;switch(r){case"getBlockNumber":case"getGasPrice":return i[r]();case"getEtherPrice":if(i.getEtherPrice)return i.getEtherPrice();break;case"getBalance":case"getTransactionCount":case"getCode":return n.blockTag&&T(n.blockTag)&&(i=yield xa(e,t)),i[r](n.address,n.blockTag||"latest");case"getStorageAt":return n.blockTag&&T(n.blockTag)&&(i=yield xa(e,t)),i.getStorageAt(n.address,n.position,n.blockTag||"latest");case"getBlock":return n.blockTag&&T(n.blockTag)&&(i=yield xa(e,t)),i[n.includeTransactions?"getBlockWithTransactions":"getBlock"](n.blockTag||n.blockHash);case"call":case"estimateGas":return n.blockTag&&T(n.blockTag)&&(i=yield xa(e,t)),i[r](n.transaction);case"getTransaction":case"getTransactionReceipt":return i[r](n.transactionHash);case"getLogs":{let r=n.filter;return(r.fromBlock&&T(r.fromBlock)||r.toBlock&&T(r.toBlock))&&(i=yield xa(e,t)),i.getLogs(r)}}return ga.throwError("unknown method error",v.errors.UNKNOWN_ERROR,{method:r,params:n})}))}class Ta extends Ms{constructor(e,t){ga.checkNew(new.target,Ta),0===e.length&&ga.throwArgumentError("missing providers","providers",e);const r=e.map(((e,t)=>{if(nr.isProvider(e)){const t=cs(e)?2e3:750,r=1;return Object.freeze({provider:e,weight:1,stallTimeout:t,priority:r})}const r=ie(e);null==r.priority&&(r.priority=1),null==r.stallTimeout&&(r.stallTimeout=cs(e)?2e3:750),null==r.weight&&(r.weight=1);const n=r.weight;return(n%1||n>512||n<1)&&ga.throwArgumentError("invalid weight; must be integer in [1, 512]",`providers[${t}].weight`,n),Object.freeze(r)})),n=r.reduce(((e,t)=>e+t.weight),0);null==t?t=n/2:t>n&&ga.throwArgumentError("quorum will always fail; larger than total weight","quorum",t);let i=ba(r.map((e=>e.provider.network)));null==i&&(i=new Promise(((e,t)=>{setTimeout((()=>{this.detectNetwork().then(e,t)}),0)}))),super(i),ee(this,"providerConfigs",Object.freeze(r)),ee(this,"quorum",t),this._highestBlockNumber=-1}detectNetwork(){return ya(this,void 0,void 0,(function*(){return ba(yield Promise.all(this.providerConfigs.map((e=>e.provider.getNetwork()))))}))}perform(e,t){return ya(this,void 0,void 0,(function*(){if("sendTransaction"===e){const e=yield Promise.all(this.providerConfigs.map((e=>e.provider.sendTransaction(t.signedTransaction).then((e=>e.hash),(e=>e)))));for(let t=0;t<e.length;t++){const r=e[t];if("string"==typeof r)return r}throw e[0]}-1===this._highestBlockNumber&&"getBlockNumber"!==e&&(yield this.getBlockNumber());const r=function(e,t,r){let n=_a;switch(t){case"getBlockNumber":return function(t){const r=t.map((e=>e.result));let n=wa(t.map((e=>e.result)),2);if(null!=n)return n=Math.ceil(n),r.indexOf(n+1)>=0&&n++,n>=e._highestBlockNumber&&(e._highestBlockNumber=n),e._highestBlockNumber};case"getGasPrice":return function(e){const t=e.map((e=>e.result));return t.sort(),t[Math.floor(t.length/2)]};case"getEtherPrice":return function(e){return wa(e.map((e=>e.result)))};case"getBalance":case"getTransactionCount":case"getCode":case"getStorageAt":case"call":case"estimateGas":case"getLogs":break;case"getTransaction":case"getTransactionReceipt":n=function(e){return null==e?null:((e=ie(e)).confirmations=-1,_a(e))};break;case"getBlock":n=r.includeTransactions?function(e){return null==e?null:((e=ie(e)).transactions=e.transactions.map((e=>((e=ie(e)).confirmations=-1,e))),_a(e))}:function(e){return null==e?null:_a(e)};break;default:throw new Error("unknown method: "+t)}return function(e,t){return function(r){const n={};r.forEach((t=>{const r=e(t.result);n[r]||(n[r]={count:0,result:t.result}),n[r].count++}));const i=Object.keys(n);for(let e=0;e<i.length;e++){const r=n[i[e]];if(r.count>=t)return r.result}}}(n,e.quorum)}(this,e,t),n=ma(this.providerConfigs.map(ie));n.sort(((e,t)=>e.priority-t.priority));const i=this._highestBlockNumber;let o=0,s=!0;for(;;){const a=va();let l=n.filter((e=>e.runner&&a-e.start<e.stallTimeout)).reduce(((e,t)=>e+t.weight),0);for(;l<this.quorum&&o<n.length;){const r=n[o++],s=Sa++;r.start=va(),r.staller=Ea(r.stallTimeout),r.staller.wait((()=>{r.staller=null})),r.runner=Ca(r,i,e,t).then((n=>{r.done=!0,r.result=n,this.listenerCount("debug")&&this.emit("debug",{action:"request",rid:s,backend:Pa(r,va()),request:{method:e,params:le(t)},provider:this})}),(n=>{r.done=!0,r.error=n,this.listenerCount("debug")&&this.emit("debug",{action:"request",rid:s,backend:Pa(r,va()),request:{method:e,params:le(t)},provider:this})})),this.listenerCount("debug")&&this.emit("debug",{action:"request",rid:s,backend:Pa(r,null),request:{method:e,params:le(t)},provider:this}),l+=r.weight}const u=[];n.forEach((e=>{!e.done&&e.runner&&(u.push(e.runner),e.staller&&u.push(e.staller.getPromise()))})),u.length&&(yield Promise.race(u));const c=n.filter((e=>e.done&&null==e.error));if(c.length>=this.quorum){const e=r(c);if(void 0!==e)return n.forEach((e=>{e.staller&&e.staller.cancel(),e.cancelled=!0})),e;s||(yield Ea(100).getPromise()),s=!1}const h=n.reduce(((e,t)=>{if(!t.done||null==t.error)return e;const r=t.error.code;return ka.indexOf(r)>=0&&(e[r]||(e[r]={error:t.error,weight:0}),e[r].weight+=t.weight),e}),{});if(Object.keys(h).forEach((e=>{const t=h[e];if(t.weight<this.quorum)return;n.forEach((e=>{e.staller&&e.staller.cancel(),e.cancelled=!0}));const r=t.error,i={};Aa.forEach((e=>{null!=r[e]&&(i[e]=r[e])})),ga.throwError(r.reason||r.message,e,i)})),0===n.filter((e=>!e.done)).length)break}return n.forEach((e=>{e.staller&&e.staller.cancel(),e.cancelled=!0})),ga.throwError("failed to meet quorum",v.errors.SERVER_ERROR,{method:e,params:t,results:n.map((e=>Pa(e))),provider:this})}))}}const Na=null,Ra=new v(ss),Ba="84842078b09946638c03157f83405213";class Ma extends Zs{constructor(e,t){const r=new Ia(e,t),n=r.connection;n.password&&Ra.throwError("INFURA WebSocket project secrets unsupported",v.errors.UNSUPPORTED_OPERATION,{operation:"InfuraProvider.getWebSocketProvider()"}),super(n.url.replace(/^http/i,"ws").replace("/v3/","/ws/v3/"),e),ee(this,"apiKey",r.projectId),ee(this,"projectId",r.projectId),ee(this,"projectSecret",r.projectSecret)}isCommunityResource(){return this.projectId===Ba}}class Ia extends Ys{static getWebSocketProvider(e,t){return new Ma(e,t)}static getApiKey(e){const t={apiKey:Ba,projectId:Ba,projectSecret:null};return null==e||("string"==typeof e?t.projectId=e:null!=e.projectSecret?(Ra.assertArgument("string"==typeof e.projectId,"projectSecret requires a projectId","projectId",e.projectId),Ra.assertArgument("string"==typeof e.projectSecret,"invalid projectSecret","projectSecret","[REDACTED]"),t.projectId=e.projectId,t.projectSecret=e.projectSecret):e.projectId&&(t.projectId=e.projectId),t.apiKey=t.projectId),t}static getUrl(e,t){let r=null;switch(e?e.name:"unknown"){case"homestead":r="mainnet.infura.io";break;case"ropsten":r="ropsten.infura.io";break;case"rinkeby":r="rinkeby.infura.io";break;case"kovan":r="kovan.infura.io";break;case"goerli":r="goerli.infura.io";break;case"matic":r="polygon-mainnet.infura.io";break;case"maticmum":r="polygon-mumbai.infura.io";break;case"optimism":r="optimism-mainnet.infura.io";break;case"optimism-kovan":r="optimism-kovan.infura.io";break;case"arbitrum":r="arbitrum-mainnet.infura.io";break;case"arbitrum-rinkeby":r="arbitrum-rinkeby.infura.io";break;default:Ra.throwError("unsupported network",v.errors.INVALID_ARGUMENT,{argument:"network",value:e})}const n={allowGzip:!0,url:"https://"+r+"/v3/"+t.projectId,throttleCallback:(e,r)=>(t.projectId===Ba&&ds(),Promise.resolve(!0))};return null!=t.projectSecret&&(n.user="",n.password=t.projectSecret),n}isCommunityResource(){return this.projectId===Ba}}class Oa extends Gs{send(e,t){const r={method:e,params:t,id:this._nextId++,jsonrpc:"2.0"};null==this._pendingBatch&&(this._pendingBatch=[]);const n={request:r,resolve:null,reject:null},i=new Promise(((e,t)=>{n.resolve=e,n.reject=t}));return this._pendingBatch.push(n),this._pendingBatchAggregator||(this._pendingBatchAggregator=setTimeout((()=>{const e=this._pendingBatch;this._pendingBatch=null,this._pendingBatchAggregator=null;const t=e.map((e=>e.request));return this.emit("debug",{action:"requestBatch",request:le(t),provider:this}),rs(this.connection,JSON.stringify(t)).then((r=>{this.emit("debug",{action:"response",request:t,response:r,provider:this}),e.forEach(((e,t)=>{const n=r[t];if(n.error){const t=new Error(n.error.message);t.code=n.error.code,t.data=n.error.data,e.reject(t)}else e.resolve(n.result)}))}),(r=>{this.emit("debug",{action:"response",error:r,request:t,provider:this}),e.forEach((e=>{e.reject(r)}))}))}),10)),i}}const Da=new v(ss);class Ka extends Ys{static getApiKey(e){return e&&"string"!=typeof e&&Da.throwArgumentError("invalid apiKey","apiKey",e),e||"ETHERS_JS_SHARED"}static getUrl(e,t){Da.warn("NodeSmith will be discontinued on 2019-12-20; please migrate to another platform.");let r=null;switch(e.name){case"homestead":r="https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc";break;case"ropsten":r="https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc";break;case"rinkeby":r="https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc";break;case"goerli":r="https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc";break;case"kovan":r="https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc";break;default:Da.throwArgumentError("unsupported network","network",arguments[0])}return r+"?apiKey="+t}}const Ua=new v(ss),Fa={homestead:"6004bcd10040261633ade990",ropsten:"6004bd4d0040261633ade991",rinkeby:"6004bda20040261633ade994",goerli:"6004bd860040261633ade992"};class ja extends Ys{constructor(e,t){if(null==t){const r=te(new.target,"getNetwork")(e);if(r){const e=Fa[r.name];e&&(t={applicationId:e,loadBalancer:!0})}null==t&&Ua.throwError("unsupported network",v.errors.INVALID_ARGUMENT,{argument:"network",value:e})}super(e,t)}static getApiKey(e){null==e&&Ua.throwArgumentError("PocketProvider.getApiKey does not support null apiKey","apiKey",e);const t={applicationId:null,loadBalancer:!1,applicationSecretKey:null};return"string"==typeof e?t.applicationId=e:null!=e.applicationSecretKey?(Ua.assertArgument("string"==typeof e.applicationId,"applicationSecretKey requires an applicationId","applicationId",e.applicationId),Ua.assertArgument("string"==typeof e.applicationSecretKey,"invalid applicationSecretKey","applicationSecretKey","[REDACTED]"),t.applicationId=e.applicationId,t.applicationSecretKey=e.applicationSecretKey,t.loadBalancer=!!e.loadBalancer):e.applicationId?(Ua.assertArgument("string"==typeof e.applicationId,"apiKey.applicationId must be a string","apiKey.applicationId",e.applicationId),t.applicationId=e.applicationId,t.loadBalancer=!!e.loadBalancer):Ua.throwArgumentError("unsupported PocketProvider apiKey","apiKey",e),t}static getUrl(e,t){let r=null;switch(e?e.name:"unknown"){case"homestead":r="eth-mainnet.gateway.pokt.network";break;case"ropsten":r="eth-ropsten.gateway.pokt.network";break;case"rinkeby":r="eth-rinkeby.gateway.pokt.network";break;case"goerli":r="eth-goerli.gateway.pokt.network";break;default:Ua.throwError("unsupported network",v.errors.INVALID_ARGUMENT,{argument:"network",value:e})}let n=null;n=t.loadBalancer?`https://${r}/v1/lb/${t.applicationId}`:`https://${r}/v1/${t.applicationId}`;const i={url:n,headers:{}};return null!=t.applicationSecretKey&&(i.user="",i.password=t.applicationSecretKey),i}isCommunityResource(){return this.applicationId===Fa[this.network.name]}}const La=new v(ss);let qa=1;function za(e,t){const r="Web3LegacyFetcher";return function(e,n){const i={method:e,params:n,id:qa++,jsonrpc:"2.0"};return new Promise(((e,n)=>{this.emit("debug",{action:"request",fetcher:r,request:le(i),provider:this}),t(i,((t,o)=>{if(t)return this.emit("debug",{action:"response",fetcher:r,error:t,request:i,provider:this}),n(t);if(this.emit("debug",{action:"response",fetcher:r,request:i,response:o,provider:this}),o.error){const e=new Error(o.error.message);return e.code=o.error.code,e.data=o.error.data,n(e)}e(o.result)}))}))}}class Wa extends Gs{constructor(e,t){La.checkNew(new.target,Wa),null==e&&La.throwArgumentError("missing provider","provider",e);let r=null,n=null,i=null;"function"==typeof e?(r="unknown:",n=e):(r=e.host||e.path||"",!r&&e.isMetaMask&&(r="metamask"),i=e,e.request?(""===r&&(r="eip-1193:"),n=function(e){return function(t,r){null==r&&(r=[]);const n={method:t,params:r};return this.emit("debug",{action:"request",fetcher:"Eip1193Fetcher",request:le(n),provider:this}),e.request(n).then((e=>(this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:n,response:e,provider:this}),e)),(e=>{throw this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:n,error:e,provider:this}),e}))}}(e)):e.sendAsync?n=za(0,e.sendAsync.bind(e)):e.send?n=za(0,e.send.bind(e)):La.throwArgumentError("unsupported provider","provider",e),r||(r="unknown:")),super(r,t),ee(this,"jsonRpcFetchFunc",n),ee(this,"provider",i)}send(e,t){return this.jsonRpcFetchFunc(e,t)}}const Ga=new v(ss);function Va(e,t){if(null==e&&(e="homestead"),"string"==typeof e){const t=e.match(/^(ws|http)s?:/i);if(t)switch(t[1]){case"http":return new Gs(e);case"ws":return new Zs(e);default:Ga.throwArgumentError("unsupported URL scheme","network",e)}}const r=Bo(e);return r&&r._defaultProvider||Ga.throwError("unsupported getDefaultProvider network",v.errors.NETWORK_ERROR,{operation:"getDefaultProvider",network:e}),r._defaultProvider({FallbackProvider:Ta,AlchemyProvider:na,CloudflareProvider:oa,EtherscanProvider:pa,InfuraProvider:Ia,JsonRpcProvider:Gs,NodesmithProvider:Ka,PocketProvider:ja,Web3Provider:Wa,IpcProvider:Na},t)}const Ha=new RegExp("^bytes([0-9]+)$"),Ja=new RegExp("^(u?int)([0-9]*)$"),$a=new RegExp("^(.*)\\[([0-9]*)\\]$"),Za=new v("solidity/5.5.0");function Xa(e,t,r){switch(e){case"address":return r?C(t,32):A(t);case"string":return We(t);case"bytes":return A(t);case"bool":return t=t?"0x01":"0x00",r?C(t,32):A(t)}let n=e.match(Ja);if(n){let i=parseInt(n[2]||"256");return(n[2]&&String(i)!==n[2]||i%8!=0||0===i||i>256)&&Za.throwArgumentError("invalid number type","type",e),r&&(i=256),C(t=J.from(t).toTwos(i),i/8)}if(n=e.match(Ha),n){const i=parseInt(n[1]);return(String(i)!==n[1]||0===i||i>32)&&Za.throwArgumentError("invalid bytes type","type",e),A(t).byteLength!==i&&Za.throwArgumentError(`invalid value for ${e}`,"value",t),r?A((t+"0000000000000000000000000000000000000000000000000000000000000000").substring(0,66)):t}if(n=e.match($a),n&&Array.isArray(t)){const r=n[1];parseInt(n[2]||String(t.length))!=t.length&&Za.throwArgumentError(`invalid array length for ${e}`,"value",t);const i=[];return t.forEach((function(e){i.push(Xa(r,e,!0))})),P(i)}return Za.throwArgumentError("invalid type","type",e)}function Qa(e,t){e.length!=t.length&&Za.throwArgumentError("wrong number of values; expected ${ types.length }","values",t);const r=[];return e.forEach((function(e,n){r.push(Xa(e,t[n]))})),R(P(r))}function Ya(e,t){return ve(Qa(e,t))}function el(e,t){return yi(Qa(e,t))}function tl(e){const t=We(e);if(t.length>31)throw new Error("bytes32 string must be less than 32 bytes");return R(P([t,Eo]).slice(0,32))}function rl(e){const t=A(e);if(32!==t.length)throw new Error("invalid bytes32 - not 32 bytes long");if(0!==t[31])throw new Error("invalid bytes32 string - no null terminator");let r=31;for(;0===t[r-1];)r--;return Je(t.slice(0,r))}const nl=new v("units/5.5.0"),il=["wei","kwei","mwei","gwei","szabo","finney","ether"];function ol(e){const t=String(e).split(".");(t.length>2||!t[0].match(/^-?[0-9]*$/)||t[1]&&!t[1].match(/^[0-9]*$/)||"."===e||"-."===e)&&nl.throwArgumentError("invalid value","value",e);let r=t[0],n="";for("-"===r.substring(0,1)&&(n="-",r=r.substring(1));"0"===r.substring(0,1);)r=r.substring(1);""===r&&(r="0");let i="";for(2===t.length&&(i="."+(t[1]||"0"));i.length>2&&"0"===i[i.length-1];)i=i.substring(0,i.length-1);const o=[];for(;r.length;){if(r.length<=3){o.unshift(r);break}{const e=r.length-3;o.unshift(r.substring(e)),r=r.substring(0,e)}}return n+o.join(",")+i}function sl(e,t){if("string"==typeof t){const e=il.indexOf(t);-1!==e&&(t=3*e)}return qn(e,null!=t?t:18)}function al(e,t){if("string"!=typeof e&&nl.throwArgumentError("value must be a string","value",e),"string"==typeof t){const e=il.indexOf(t);-1!==e&&(t=3*e)}return zn(e,null!=t?t:18)}function ll(e){return sl(e,18)}function ul(e){return al(e,18)}const cl="ethers/5.5.3",hl=new v(cl);try{const e=window;null==e._ethers&&(e._ethers=l)}catch(e){}},3715:(e,t,r)=>{var n=t;n.utils=r(6436),n.common=r(5772),n.sha=r(9041),n.ripemd=r(2949),n.hmac=r(2344),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},5772:(e,t,r)=>{"use strict";var n=r(6436),i=r(9746);function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}t.BlockHash=o,o.prototype.update=function(e,t){if(e=n.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=n.join32(e,0,e.length-r,this.endian);for(var i=0;i<e.length;i+=this._delta32)this._update(e,i,i+this._delta32)}return this},o.prototype.digest=function(e){return this.update(this._pad()),i(null===this.pending),this._digest(e)},o.prototype._pad=function(){var e=this.pendingTotal,t=this._delta8,r=t-(e+this.padLength)%t,n=new Array(r+this.padLength);n[0]=128;for(var i=1;i<r;i++)n[i]=0;if(e<<=3,"big"===this.endian){for(var o=8;o<this.padLength;o++)n[i++]=0;n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=e>>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;o<this.padLength;o++)n[i++]=0;return n}},2344:(e,t,r)=>{"use strict";var n=r(6436),i=r(9746);function o(e,t,r){if(!(this instanceof o))return new o(e,t,r);this.Hash=e,this.blockSize=e.blockSize/8,this.outSize=e.outSize/8,this.inner=null,this.outer=null,this._init(n.toArray(t,r))}e.exports=o,o.prototype._init=function(e){e.length>this.blockSize&&(e=(new this.Hash).update(e).digest()),i(e.length<=this.blockSize);for(var t=e.length;t<this.blockSize;t++)e.push(0);for(t=0;t<e.length;t++)e[t]^=54;for(this.inner=(new this.Hash).update(e),t=0;t<e.length;t++)e[t]^=106;this.outer=(new this.Hash).update(e)},o.prototype.update=function(e,t){return this.inner.update(e,t),this},o.prototype.digest=function(e){return this.outer.update(this.inner.digest()),this.outer.digest(e)}},2949:(e,t,r)=>{"use strict";var n=r(6436),i=r(5772),o=n.rotl32,s=n.sum32,a=n.sum32_3,l=n.sum32_4,u=i.BlockHash;function c(){if(!(this instanceof c))return new c;u.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}function h(e,t,r,n){return e<=15?t^r^n:e<=31?t&r|~t&n:e<=47?(t|~r)^n:e<=63?t&n|r&~n:t^(r|~n)}function d(e){return e<=15?0:e<=31?1518500249:e<=47?1859775393:e<=63?2400959708:2840853838}function f(e){return e<=15?1352829926:e<=31?1548603684:e<=47?1836072691:e<=63?2053994217:0}n.inherits(c,u),t.ripemd160=c,c.blockSize=512,c.outSize=160,c.hmacStrength=192,c.padLength=64,c.prototype._update=function(e,t){for(var r=this.h[0],n=this.h[1],i=this.h[2],u=this.h[3],c=this.h[4],v=r,b=n,w=i,_=u,S=c,E=0;E<80;E++){var k=s(o(l(r,h(E,n,i,u),e[p[E]+t],d(E)),y[E]),c);r=c,c=u,u=o(i,10),i=n,n=k,k=s(o(l(v,h(79-E,b,w,_),e[m[E]+t],f(E)),g[E]),S),v=S,S=_,_=o(w,10),w=b,b=k}k=a(this.h[1],i,_),this.h[1]=a(this.h[2],u,S),this.h[2]=a(this.h[3],c,v),this.h[3]=a(this.h[4],r,b),this.h[4]=a(this.h[0],n,w),this.h[0]=k},c.prototype._digest=function(e){return"hex"===e?n.toHex32(this.h,"little"):n.split32(this.h,"little")};var p=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],m=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],y=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],g=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]},9041:(e,t,r)=>{"use strict";t.sha1=r(4761),t.sha224=r(799),t.sha256=r(9344),t.sha384=r(772),t.sha512=r(5900)},4761:(e,t,r)=>{"use strict";var n=r(6436),i=r(5772),o=r(7038),s=n.rotl32,a=n.sum32,l=n.sum32_5,u=o.ft_1,c=i.BlockHash,h=[1518500249,1859775393,2400959708,3395469782];function d(){if(!(this instanceof d))return new d;c.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}n.inherits(d,c),e.exports=d,d.blockSize=512,d.outSize=160,d.hmacStrength=80,d.padLength=64,d.prototype._update=function(e,t){for(var r=this.W,n=0;n<16;n++)r[n]=e[t+n];for(;n<r.length;n++)r[n]=s(r[n-3]^r[n-8]^r[n-14]^r[n-16],1);var i=this.h[0],o=this.h[1],c=this.h[2],d=this.h[3],f=this.h[4];for(n=0;n<r.length;n++){var p=~~(n/20),m=l(s(i,5),u(p,o,c,d),f,r[n],h[p]);f=d,d=c,c=s(o,30),o=i,i=m}this.h[0]=a(this.h[0],i),this.h[1]=a(this.h[1],o),this.h[2]=a(this.h[2],c),this.h[3]=a(this.h[3],d),this.h[4]=a(this.h[4],f)},d.prototype._digest=function(e){return"hex"===e?n.toHex32(this.h,"big"):n.split32(this.h,"big")}},799:(e,t,r)=>{"use strict";var n=r(6436),i=r(9344);function o(){if(!(this instanceof o))return new o;i.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}n.inherits(o,i),e.exports=o,o.blockSize=512,o.outSize=224,o.hmacStrength=192,o.padLength=64,o.prototype._digest=function(e){return"hex"===e?n.toHex32(this.h.slice(0,7),"big"):n.split32(this.h.slice(0,7),"big")}},9344:(e,t,r)=>{"use strict";var n=r(6436),i=r(5772),o=r(7038),s=r(9746),a=n.sum32,l=n.sum32_4,u=n.sum32_5,c=o.ch32,h=o.maj32,d=o.s0_256,f=o.s1_256,p=o.g0_256,m=o.g1_256,y=i.BlockHash,g=[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];function v(){if(!(this instanceof v))return new v;y.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=g,this.W=new Array(64)}n.inherits(v,y),e.exports=v,v.blockSize=512,v.outSize=256,v.hmacStrength=192,v.padLength=64,v.prototype._update=function(e,t){for(var r=this.W,n=0;n<16;n++)r[n]=e[t+n];for(;n<r.length;n++)r[n]=l(m(r[n-2]),r[n-7],p(r[n-15]),r[n-16]);var i=this.h[0],o=this.h[1],y=this.h[2],g=this.h[3],v=this.h[4],b=this.h[5],w=this.h[6],_=this.h[7];for(s(this.k.length===r.length),n=0;n<r.length;n++){var S=u(_,f(v),c(v,b,w),this.k[n],r[n]),E=a(d(i),h(i,o,y));_=w,w=b,b=v,v=a(g,S),g=y,y=o,o=i,i=a(S,E)}this.h[0]=a(this.h[0],i),this.h[1]=a(this.h[1],o),this.h[2]=a(this.h[2],y),this.h[3]=a(this.h[3],g),this.h[4]=a(this.h[4],v),this.h[5]=a(this.h[5],b),this.h[6]=a(this.h[6],w),this.h[7]=a(this.h[7],_)},v.prototype._digest=function(e){return"hex"===e?n.toHex32(this.h,"big"):n.split32(this.h,"big")}},772:(e,t,r)=>{"use strict";var n=r(6436),i=r(5900);function o(){if(!(this instanceof o))return new o;i.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}n.inherits(o,i),e.exports=o,o.blockSize=1024,o.outSize=384,o.hmacStrength=192,o.padLength=128,o.prototype._digest=function(e){return"hex"===e?n.toHex32(this.h.slice(0,12),"big"):n.split32(this.h.slice(0,12),"big")}},5900:(e,t,r)=>{"use strict";var n=r(6436),i=r(5772),o=r(9746),s=n.rotr64_hi,a=n.rotr64_lo,l=n.shr64_hi,u=n.shr64_lo,c=n.sum64,h=n.sum64_hi,d=n.sum64_lo,f=n.sum64_4_hi,p=n.sum64_4_lo,m=n.sum64_5_hi,y=n.sum64_5_lo,g=i.BlockHash,v=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function b(){if(!(this instanceof b))return new b;g.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=v,this.W=new Array(160)}function w(e,t,r,n,i){var o=e&r^~e&i;return o<0&&(o+=4294967296),o}function _(e,t,r,n,i,o){var s=t&n^~t&o;return s<0&&(s+=4294967296),s}function S(e,t,r,n,i){var o=e&r^e&i^r&i;return o<0&&(o+=4294967296),o}function E(e,t,r,n,i,o){var s=t&n^t&o^n&o;return s<0&&(s+=4294967296),s}function k(e,t){var r=s(e,t,28)^s(t,e,2)^s(t,e,7);return r<0&&(r+=4294967296),r}function A(e,t){var r=a(e,t,28)^a(t,e,2)^a(t,e,7);return r<0&&(r+=4294967296),r}function P(e,t){var r=a(e,t,14)^a(e,t,18)^a(t,e,9);return r<0&&(r+=4294967296),r}function x(e,t){var r=s(e,t,1)^s(e,t,8)^l(e,t,7);return r<0&&(r+=4294967296),r}function C(e,t){var r=a(e,t,1)^a(e,t,8)^u(e,t,7);return r<0&&(r+=4294967296),r}function T(e,t){var r=a(e,t,19)^a(t,e,29)^u(e,t,6);return r<0&&(r+=4294967296),r}n.inherits(b,g),e.exports=b,b.blockSize=1024,b.outSize=512,b.hmacStrength=192,b.padLength=128,b.prototype._prepareBlock=function(e,t){for(var r=this.W,n=0;n<32;n++)r[n]=e[t+n];for(;n<r.length;n+=2){var i=(y=r[n-4],g=r[n-3],v=void 0,(v=s(y,g,19)^s(g,y,29)^l(y,g,6))<0&&(v+=4294967296),v),o=T(r[n-4],r[n-3]),a=r[n-14],u=r[n-13],c=x(r[n-30],r[n-29]),h=C(r[n-30],r[n-29]),d=r[n-32],m=r[n-31];r[n]=f(i,o,a,u,c,h,d,m),r[n+1]=p(i,o,a,u,c,h,d,m)}var y,g,v},b.prototype._update=function(e,t){this._prepareBlock(e,t);var r,n,i,a=this.W,l=this.h[0],u=this.h[1],f=this.h[2],p=this.h[3],g=this.h[4],v=this.h[5],b=this.h[6],x=this.h[7],C=this.h[8],T=this.h[9],N=this.h[10],R=this.h[11],B=this.h[12],M=this.h[13],I=this.h[14],O=this.h[15];o(this.k.length===a.length);for(var D=0;D<a.length;D+=2){var K=I,U=O,F=(i=void 0,(i=s(r=C,n=T,14)^s(r,n,18)^s(n,r,9))<0&&(i+=4294967296),i),j=P(C,T),L=w(C,0,N,0,B),q=_(0,T,0,R,0,M),z=this.k[D],W=this.k[D+1],G=a[D],V=a[D+1],H=m(K,U,F,j,L,q,z,W,G,V),J=y(K,U,F,j,L,q,z,W,G,V);K=k(l,u),U=A(l,u),F=S(l,0,f,0,g),j=E(0,u,0,p,0,v);var $=h(K,U,F,j),Z=d(K,U,F,j);I=B,O=M,B=N,M=R,N=C,R=T,C=h(b,x,H,J),T=d(x,x,H,J),b=g,x=v,g=f,v=p,f=l,p=u,l=h(H,J,$,Z),u=d(H,J,$,Z)}c(this.h,0,l,u),c(this.h,2,f,p),c(this.h,4,g,v),c(this.h,6,b,x),c(this.h,8,C,T),c(this.h,10,N,R),c(this.h,12,B,M),c(this.h,14,I,O)},b.prototype._digest=function(e){return"hex"===e?n.toHex32(this.h,"big"):n.split32(this.h,"big")}},7038:(e,t,r)=>{"use strict";var n=r(6436).rotr32;function i(e,t,r){return e&t^~e&r}function o(e,t,r){return e&t^e&r^t&r}function s(e,t,r){return e^t^r}t.ft_1=function(e,t,r,n){return 0===e?i(t,r,n):1===e||3===e?s(t,r,n):2===e?o(t,r,n):void 0},t.ch32=i,t.maj32=o,t.p32=s,t.s0_256=function(e){return n(e,2)^n(e,13)^n(e,22)},t.s1_256=function(e){return n(e,6)^n(e,11)^n(e,25)},t.g0_256=function(e){return n(e,7)^n(e,18)^e>>>3},t.g1_256=function(e){return n(e,17)^n(e,19)^e>>>10}},6436:(e,t,r)=>{"use strict";var n=r(9746),i=r(5717);function o(e,t){return 55296==(64512&e.charCodeAt(t))&&!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1))}function s(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function a(e){return 1===e.length?"0"+e:e}function l(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}t.inherits=i,t.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),i=0;i<e.length;i+=2)r.push(parseInt(e[i]+e[i+1],16))}else for(var n=0,i=0;i<e.length;i++){var s=e.charCodeAt(i);s<128?r[n++]=s:s<2048?(r[n++]=s>>6|192,r[n++]=63&s|128):o(e,i)?(s=65536+((1023&s)<<10)+(1023&e.charCodeAt(++i)),r[n++]=s>>18|240,r[n++]=s>>12&63|128,r[n++]=s>>6&63|128,r[n++]=63&s|128):(r[n++]=s>>12|224,r[n++]=s>>6&63|128,r[n++]=63&s|128)}else for(i=0;i<e.length;i++)r[i]=0|e[i];return r},t.toHex=function(e){for(var t="",r=0;r<e.length;r++)t+=a(e[r].toString(16));return t},t.htonl=s,t.toHex32=function(e,t){for(var r="",n=0;n<e.length;n++){var i=e[n];"little"===t&&(i=s(i)),r+=l(i.toString(16))}return r},t.zero2=a,t.zero8=l,t.join32=function(e,t,r,i){var o=r-t;n(o%4==0);for(var s=new Array(o/4),a=0,l=t;a<s.length;a++,l+=4){var u;u="big"===i?e[l]<<24|e[l+1]<<16|e[l+2]<<8|e[l+3]:e[l+3]<<24|e[l+2]<<16|e[l+1]<<8|e[l],s[a]=u>>>0}return s},t.split32=function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n<e.length;n++,i+=4){var o=e[n];"big"===t?(r[i]=o>>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},t.rotr32=function(e,t){return e>>>t|e<<32-t},t.rotl32=function(e,t){return e<<t|e>>>32-t},t.sum32=function(e,t){return e+t>>>0},t.sum32_3=function(e,t,r){return e+t+r>>>0},t.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},t.sum32_5=function(e,t,r,n,i){return e+t+r+n+i>>>0},t.sum64=function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,s=(o<n?1:0)+r+i;e[t]=s>>>0,e[t+1]=o},t.sum64_hi=function(e,t,r,n){return(t+n>>>0<t?1:0)+e+r>>>0},t.sum64_lo=function(e,t,r,n){return t+n>>>0},t.sum64_4_hi=function(e,t,r,n,i,o,s,a){var l=0,u=t;return l+=(u=u+n>>>0)<t?1:0,l+=(u=u+o>>>0)<o?1:0,e+r+i+s+(l+=(u=u+a>>>0)<a?1:0)>>>0},t.sum64_4_lo=function(e,t,r,n,i,o,s,a){return t+n+o+a>>>0},t.sum64_5_hi=function(e,t,r,n,i,o,s,a,l,u){var c=0,h=t;return c+=(h=h+n>>>0)<t?1:0,c+=(h=h+o>>>0)<o?1:0,c+=(h=h+a>>>0)<a?1:0,e+r+i+s+l+(c+=(h=h+u>>>0)<u?1:0)>>>0},t.sum64_5_lo=function(e,t,r,n,i,o,s,a,l,u){return t+n+o+a+u>>>0},t.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},t.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},t.shr64_hi=function(e,t,r){return e>>>r},t.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},5717:e=>{"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},1094:(e,t,r)=>{var n;!function(){"use strict";var i="input is invalid type",o="object"==typeof window,s=o?window:{};s.JS_SHA3_NO_WINDOW&&(o=!1);var a=!o&&"object"==typeof self;!s.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node?s=r.g:a&&(s=self);var l=!s.JS_SHA3_NO_COMMON_JS&&e.exports,u=r.amdO,c=!s.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,h="0123456789abcdef".split(""),d=[4,1024,262144,67108864],f=[0,8,16,24],p=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],m=[224,256,384,512],y=[128,256],g=["hex","buffer","arrayBuffer","array","digest"],v={128:168,256:136};!s.JS_SHA3_NO_NODE_JS&&Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),!c||!s.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(e){return"object"==typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});for(var b=function(e,t,r){return function(n){return new I(e,t,e).update(n)[r]()}},w=function(e,t,r){return function(n,i){return new I(e,t,i).update(n)[r]()}},_=function(e,t,r){return function(t,n,i,o){return P["cshake"+e].update(t,n,i,o)[r]()}},S=function(e,t,r){return function(t,n,i,o){return P["kmac"+e].update(t,n,i,o)[r]()}},E=function(e,t,r,n){for(var i=0;i<g.length;++i){var o=g[i];e[o]=t(r,n,o)}return e},k=function(e,t){var r=b(e,t,"hex");return r.create=function(){return new I(e,t,e)},r.update=function(e){return r.create().update(e)},E(r,b,e,t)},A=[{name:"keccak",padding:[1,256,65536,16777216],bits:m,createMethod:k},{name:"sha3",padding:[6,1536,393216,100663296],bits:m,createMethod:k},{name:"shake",padding:[31,7936,2031616,520093696],bits:y,createMethod:function(e,t){var r=w(e,t,"hex");return r.create=function(r){return new I(e,t,r)},r.update=function(e,t){return r.create(t).update(e)},E(r,w,e,t)}},{name:"cshake",padding:d,bits:y,createMethod:function(e,t){var r=v[e],n=_(e,0,"hex");return n.create=function(n,i,o){return i||o?new I(e,t,n).bytepad([i,o],r):P["shake"+e].create(n)},n.update=function(e,t,r,i){return n.create(t,r,i).update(e)},E(n,_,e,t)}},{name:"kmac",padding:d,bits:y,createMethod:function(e,t){var r=v[e],n=S(e,0,"hex");return n.create=function(n,i,o){return new O(e,t,i).bytepad(["KMAC",o],r).bytepad([n],r)},n.update=function(e,t,r,i){return n.create(e,r,i).update(t)},E(n,S,e,t)}}],P={},x=[],C=0;C<A.length;++C)for(var T=A[C],N=T.bits,R=0;R<N.length;++R){var B=T.name+"_"+N[R];if(x.push(B),P[B]=T.createMethod(N[R],T.padding),"sha3"!==T.name){var M=T.name+N[R];x.push(M),P[M]=P[B]}}function I(e,t,r){this.blocks=[],this.s=[],this.padding=t,this.outputBits=r,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(e<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}function O(e,t,r){I.call(this,e,t,r)}I.prototype.update=function(e){if(this.finalized)throw new Error("finalize already called");var t,r=typeof e;if("string"!==r){if("object"!==r)throw new Error(i);if(null===e)throw new Error(i);if(c&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||c&&ArrayBuffer.isView(e)))throw new Error(i);t=!0}for(var n,o,s=this.blocks,a=this.byteCount,l=e.length,u=this.blockCount,h=0,d=this.s;h<l;){if(this.reset)for(this.reset=!1,s[0]=this.block,n=1;n<u+1;++n)s[n]=0;if(t)for(n=this.start;h<l&&n<a;++h)s[n>>2]|=e[h]<<f[3&n++];else for(n=this.start;h<l&&n<a;++h)(o=e.charCodeAt(h))<128?s[n>>2]|=o<<f[3&n++]:o<2048?(s[n>>2]|=(192|o>>6)<<f[3&n++],s[n>>2]|=(128|63&o)<<f[3&n++]):o<55296||o>=57344?(s[n>>2]|=(224|o>>12)<<f[3&n++],s[n>>2]|=(128|o>>6&63)<<f[3&n++],s[n>>2]|=(128|63&o)<<f[3&n++]):(o=65536+((1023&o)<<10|1023&e.charCodeAt(++h)),s[n>>2]|=(240|o>>18)<<f[3&n++],s[n>>2]|=(128|o>>12&63)<<f[3&n++],s[n>>2]|=(128|o>>6&63)<<f[3&n++],s[n>>2]|=(128|63&o)<<f[3&n++]);if(this.lastByteIndex=n,n>=a){for(this.start=n-a,this.block=s[u],n=0;n<u;++n)d[n]^=s[n];D(d),this.reset=!0}else this.start=n}return this},I.prototype.encode=function(e,t){var r=255&e,n=1,i=[r];for(r=255&(e>>=8);r>0;)i.unshift(r),r=255&(e>>=8),++n;return t?i.push(n):i.unshift(n),this.update(i),i.length},I.prototype.encodeString=function(e){var t,r=typeof e;if("string"!==r){if("object"!==r)throw new Error(i);if(null===e)throw new Error(i);if(c&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||c&&ArrayBuffer.isView(e)))throw new Error(i);t=!0}var n=0,o=e.length;if(t)n=o;else for(var s=0;s<e.length;++s){var a=e.charCodeAt(s);a<128?n+=1:a<2048?n+=2:a<55296||a>=57344?n+=3:(a=65536+((1023&a)<<10|1023&e.charCodeAt(++s)),n+=4)}return n+=this.encode(8*n),this.update(e),n},I.prototype.bytepad=function(e,t){for(var r=this.encode(t),n=0;n<e.length;++n)r+=this.encodeString(e[n]);var i=t-r%t,o=[];return o.length=i,this.update(o),this},I.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex,r=this.blockCount,n=this.s;if(e[t>>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t<r+1;++t)e[t]=0;for(e[r-1]|=2147483648,t=0;t<r;++t)n[t]^=e[t];D(n)}},I.prototype.toString=I.prototype.hex=function(){this.finalize();for(var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,s=0,a="";s<n;){for(o=0;o<t&&s<n;++o,++s)e=r[o],a+=h[e>>4&15]+h[15&e]+h[e>>12&15]+h[e>>8&15]+h[e>>20&15]+h[e>>16&15]+h[e>>28&15]+h[e>>24&15];s%t==0&&(D(r),o=0)}return i&&(e=r[o],a+=h[e>>4&15]+h[15&e],i>1&&(a+=h[e>>12&15]+h[e>>8&15]),i>2&&(a+=h[e>>20&15]+h[e>>16&15])),a},I.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,s=0,a=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(a);for(var l=new Uint32Array(e);s<n;){for(o=0;o<t&&s<n;++o,++s)l[s]=r[o];s%t==0&&D(r)}return i&&(l[o]=r[o],e=e.slice(0,a)),e},I.prototype.buffer=I.prototype.arrayBuffer,I.prototype.digest=I.prototype.array=function(){this.finalize();for(var e,t,r=this.blockCount,n=this.s,i=this.outputBlocks,o=this.extraBytes,s=0,a=0,l=[];a<i;){for(s=0;s<r&&a<i;++s,++a)e=a<<2,t=n[s],l[e]=255&t,l[e+1]=t>>8&255,l[e+2]=t>>16&255,l[e+3]=t>>24&255;a%r==0&&D(n)}return o&&(e=a<<2,t=n[s],l[e]=255&t,o>1&&(l[e+1]=t>>8&255),o>2&&(l[e+2]=t>>16&255)),l},O.prototype=new I,O.prototype.finalize=function(){return this.encode(this.outputBits,!0),I.prototype.finalize.call(this)};var D=function(e){var t,r,n,i,o,s,a,l,u,c,h,d,f,m,y,g,v,b,w,_,S,E,k,A,P,x,C,T,N,R,B,M,I,O,D,K,U,F,j,L,q,z,W,G,V,H,J,$,Z,X,Q,Y,ee,te,re,ne,ie,oe,se,ae,le,ue,ce;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],s=e[2]^e[12]^e[22]^e[32]^e[42],a=e[3]^e[13]^e[23]^e[33]^e[43],l=e[4]^e[14]^e[24]^e[34]^e[44],u=e[5]^e[15]^e[25]^e[35]^e[45],c=e[6]^e[16]^e[26]^e[36]^e[46],h=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(s<<1|a>>>31),r=(f=e[9]^e[19]^e[29]^e[39]^e[49])^(a<<1|s>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(l<<1|u>>>31),r=o^(u<<1|l>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=s^(c<<1|h>>>31),r=a^(h<<1|c>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=l^(d<<1|f>>>31),r=u^(f<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=c^(i<<1|o>>>31),r=h^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,m=e[0],y=e[1],H=e[11]<<4|e[10]>>>28,J=e[10]<<4|e[11]>>>28,T=e[20]<<3|e[21]>>>29,N=e[21]<<3|e[20]>>>29,ae=e[31]<<9|e[30]>>>23,le=e[30]<<9|e[31]>>>23,z=e[40]<<18|e[41]>>>14,W=e[41]<<18|e[40]>>>14,O=e[2]<<1|e[3]>>>31,D=e[3]<<1|e[2]>>>31,g=e[13]<<12|e[12]>>>20,v=e[12]<<12|e[13]>>>20,$=e[22]<<10|e[23]>>>22,Z=e[23]<<10|e[22]>>>22,R=e[33]<<13|e[32]>>>19,B=e[32]<<13|e[33]>>>19,ue=e[42]<<2|e[43]>>>30,ce=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,K=e[14]<<6|e[15]>>>26,U=e[15]<<6|e[14]>>>26,b=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,X=e[34]<<15|e[35]>>>17,Q=e[35]<<15|e[34]>>>17,M=e[45]<<29|e[44]>>>3,I=e[44]<<29|e[45]>>>3,A=e[6]<<28|e[7]>>>4,P=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,F=e[26]<<25|e[27]>>>7,j=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,S=e[37]<<21|e[36]>>>11,Y=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,G=e[8]<<27|e[9]>>>5,V=e[9]<<27|e[8]>>>5,x=e[18]<<20|e[19]>>>12,C=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,se=e[28]<<7|e[29]>>>25,L=e[38]<<8|e[39]>>>24,q=e[39]<<8|e[38]>>>24,E=e[48]<<14|e[49]>>>18,k=e[49]<<14|e[48]>>>18,e[0]=m^~g&b,e[1]=y^~v&w,e[10]=A^~x&T,e[11]=P^~C&N,e[20]=O^~K&F,e[21]=D^~U&j,e[30]=G^~H&$,e[31]=V^~J&Z,e[40]=te^~ne&oe,e[41]=re^~ie&se,e[2]=g^~b&_,e[3]=v^~w&S,e[12]=x^~T&R,e[13]=C^~N&B,e[22]=K^~F&L,e[23]=U^~j&q,e[32]=H^~$&X,e[33]=J^~Z&Q,e[42]=ne^~oe&ae,e[43]=ie^~se&le,e[4]=b^~_&E,e[5]=w^~S&k,e[14]=T^~R&M,e[15]=N^~B&I,e[24]=F^~L&z,e[25]=j^~q&W,e[34]=$^~X&Y,e[35]=Z^~Q&ee,e[44]=oe^~ae&ue,e[45]=se^~le&ce,e[6]=_^~E&m,e[7]=S^~k&y,e[16]=R^~M&A,e[17]=B^~I&P,e[26]=L^~z&O,e[27]=q^~W&D,e[36]=X^~Y&G,e[37]=Q^~ee&V,e[46]=ae^~ue&te,e[47]=le^~ce&re,e[8]=E^~m&g,e[9]=k^~y&v,e[18]=M^~A&x,e[19]=I^~P&C,e[28]=z^~O&K,e[29]=W^~D&U,e[38]=Y^~G&H,e[39]=ee^~V&J,e[48]=ue^~te&ne,e[49]=ce^~re&ie,e[0]^=p[n],e[1]^=p[n+1]};if(l)e.exports=P;else{for(C=0;C<x.length;++C)s[x[C]]=P[x[C]];u&&(void 0===(n=function(){return P}.call(t,r,t,e))||(e.exports=n))}}()},9746:e=>{function t(e,t){if(!e)throw new Error(t||"Assertion failed")}e.exports=t,t.equal=function(e,t,r){if(e!=t)throw new Error(r||"Assertion failed: "+e+" != "+t)}},7635:function(e){"use strict";!function(t){const r=2147483647;function n(e){const t=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]);let r=1779033703,n=3144134277,i=1013904242,o=2773480762,s=1359893119,a=2600822924,l=528734635,u=1541459225;const c=new Uint32Array(64);function h(e){let h=0,d=e.length;for(;d>=64;){let f,p,m,y,g,v=r,b=n,w=i,_=o,S=s,E=a,k=l,A=u;for(p=0;p<16;p++)m=h+4*p,c[p]=(255&e[m])<<24|(255&e[m+1])<<16|(255&e[m+2])<<8|255&e[m+3];for(p=16;p<64;p++)f=c[p-2],y=(f>>>17|f<<15)^(f>>>19|f<<13)^f>>>10,f=c[p-15],g=(f>>>7|f<<25)^(f>>>18|f<<14)^f>>>3,c[p]=(y+c[p-7]|0)+(g+c[p-16]|0)|0;for(p=0;p<64;p++)y=(((S>>>6|S<<26)^(S>>>11|S<<21)^(S>>>25|S<<7))+(S&E^~S&k)|0)+(A+(t[p]+c[p]|0)|0)|0,g=((v>>>2|v<<30)^(v>>>13|v<<19)^(v>>>22|v<<10))+(v&b^v&w^b&w)|0,A=k,k=E,E=S,S=_+y|0,_=w,w=b,b=v,v=y+g|0;r=r+v|0,n=n+b|0,i=i+w|0,o=o+_|0,s=s+S|0,a=a+E|0,l=l+k|0,u=u+A|0,h+=64,d-=64}}h(e);let d,f=e.length%64,p=e.length/536870912|0,m=e.length<<3,y=f<56?56:120,g=e.slice(e.length-f,e.length);for(g.push(128),d=f+1;d<y;d++)g.push(0);return g.push(p>>>24&255),g.push(p>>>16&255),g.push(p>>>8&255),g.push(p>>>0&255),g.push(m>>>24&255),g.push(m>>>16&255),g.push(m>>>8&255),g.push(m>>>0&255),h(g),[r>>>24&255,r>>>16&255,r>>>8&255,r>>>0&255,n>>>24&255,n>>>16&255,n>>>8&255,n>>>0&255,i>>>24&255,i>>>16&255,i>>>8&255,i>>>0&255,o>>>24&255,o>>>16&255,o>>>8&255,o>>>0&255,s>>>24&255,s>>>16&255,s>>>8&255,s>>>0&255,a>>>24&255,a>>>16&255,a>>>8&255,a>>>0&255,l>>>24&255,l>>>16&255,l>>>8&255,l>>>0&255,u>>>24&255,u>>>16&255,u>>>8&255,u>>>0&255]}function i(e,t,r){e=e.length<=64?e:n(e);const i=64+t.length+4,o=new Array(i),s=new Array(64);let a,l=[];for(a=0;a<64;a++)o[a]=54;for(a=0;a<e.length;a++)o[a]^=e[a];for(a=0;a<t.length;a++)o[64+a]=t[a];for(a=i-4;a<i;a++)o[a]=0;for(a=0;a<64;a++)s[a]=92;for(a=0;a<e.length;a++)s[a]^=e[a];function u(){for(let e=i-1;e>=i-4;e--){if(o[e]++,o[e]<=255)return;o[e]=0}}for(;r>=32;)u(),l=l.concat(n(s.concat(n(o)))),r-=32;return r>0&&(u(),l=l.concat(n(s.concat(n(o))).slice(0,r))),l}function o(e,t,r,n,i){let o;for(u(e,16*(2*r-1),i,0,16),o=0;o<2*r;o++)l(e,16*o,i,16),a(i,n),u(i,0,e,t+16*o,16);for(o=0;o<r;o++)u(e,t+2*o*16,e,16*o,16);for(o=0;o<r;o++)u(e,t+16*(2*o+1),e,16*(o+r),16)}function s(e,t){return e<<t|e>>>32-t}function a(e,t){u(e,0,t,0,16);for(let e=8;e>0;e-=2)t[4]^=s(t[0]+t[12],7),t[8]^=s(t[4]+t[0],9),t[12]^=s(t[8]+t[4],13),t[0]^=s(t[12]+t[8],18),t[9]^=s(t[5]+t[1],7),t[13]^=s(t[9]+t[5],9),t[1]^=s(t[13]+t[9],13),t[5]^=s(t[1]+t[13],18),t[14]^=s(t[10]+t[6],7),t[2]^=s(t[14]+t[10],9),t[6]^=s(t[2]+t[14],13),t[10]^=s(t[6]+t[2],18),t[3]^=s(t[15]+t[11],7),t[7]^=s(t[3]+t[15],9),t[11]^=s(t[7]+t[3],13),t[15]^=s(t[11]+t[7],18),t[1]^=s(t[0]+t[3],7),t[2]^=s(t[1]+t[0],9),t[3]^=s(t[2]+t[1],13),t[0]^=s(t[3]+t[2],18),t[6]^=s(t[5]+t[4],7),t[7]^=s(t[6]+t[5],9),t[4]^=s(t[7]+t[6],13),t[5]^=s(t[4]+t[7],18),t[11]^=s(t[10]+t[9],7),t[8]^=s(t[11]+t[10],9),t[9]^=s(t[8]+t[11],13),t[10]^=s(t[9]+t[8],18),t[12]^=s(t[15]+t[14],7),t[13]^=s(t[12]+t[15],9),t[14]^=s(t[13]+t[12],13),t[15]^=s(t[14]+t[13],18);for(let r=0;r<16;++r)e[r]+=t[r]}function l(e,t,r,n){for(let i=0;i<n;i++)r[i]^=e[t+i]}function u(e,t,r,n,i){for(;i--;)r[n++]=e[t++]}function c(e){if(!e||"number"!=typeof e.length)return!1;for(let t=0;t<e.length;t++){const r=e[t];if("number"!=typeof r||r%1||r<0||r>=256)return!1}return!0}function h(e,t){if("number"!=typeof e||e%1)throw new Error("invalid "+t);return e}function d(e,t,n,s,a,d,f){if(n=h(n,"N"),s=h(s,"r"),a=h(a,"p"),d=h(d,"dkLen"),0===n||0!=(n&n-1))throw new Error("N must be power of 2");if(n>r/128/s)throw new Error("N too large");if(s>r/128/a)throw new Error("r too large");if(!c(e))throw new Error("password must be an array or buffer");if(e=Array.prototype.slice.call(e),!c(t))throw new Error("salt must be an array or buffer");t=Array.prototype.slice.call(t);let p=i(e,t,128*a*s);const m=new Uint32Array(32*a*s);for(let e=0;e<m.length;e++){const t=4*e;m[e]=(255&p[t+3])<<24|(255&p[t+2])<<16|(255&p[t+1])<<8|(255&p[t+0])<<0}const y=new Uint32Array(64*s),g=new Uint32Array(32*s*n),v=32*s,b=new Uint32Array(16),w=new Uint32Array(16),_=a*n*2;let S,E,k=0,A=null,P=!1,x=0,C=0;const T=f?parseInt(1e3/s):4294967295,N="undefined"!=typeof setImmediate?setImmediate:setTimeout,R=function(){if(P)return f(new Error("cancelled"),k/_);let t;switch(x){case 0:E=32*C*s,u(m,E,y,0,v),x=1,S=0;case 1:t=n-S,t>T&&(t=T);for(let e=0;e<t;e++)u(y,0,g,(S+e)*v,v),o(y,v,s,b,w);if(S+=t,k+=t,f){const e=parseInt(1e3*k/_);if(e!==A){if(P=f(null,k/_),P)break;A=e}}if(S<n)break;S=0,x=2;case 2:t=n-S,t>T&&(t=T);for(let e=0;e<t;e++){const e=y[16*(2*s-1)]&n-1;l(g,e*v,y,v),o(y,v,s,b,w)}if(S+=t,k+=t,f){const e=parseInt(1e3*k/_);if(e!==A){if(P=f(null,k/_),P)break;A=e}}if(S<n)break;if(u(y,0,m,E,v),C++,C<a){x=0;break}p=[];for(let e=0;e<m.length;e++)p.push(m[e]>>0&255),p.push(m[e]>>8&255),p.push(m[e]>>16&255),p.push(m[e]>>24&255);const r=i(e,p,d);return f&&f(null,1,r),r}f&&N(R)};if(!f)for(;;){const e=R();if(null!=e)return e}R()}const f={scrypt:function(e,t,r,n,i,o,s){return new Promise((function(a,l){let u=0;s&&s(0),d(e,t,r,n,i,o,(function(e,t,r){if(e)l(e);else if(r)s&&1!==u&&s(1),a(new Uint8Array(r));else if(s&&t!==u)return u=t,s(t)}))}))},syncScrypt:function(e,t,r,n,i,o){return new Uint8Array(d(e,t,r,n,i,o))}};e.exports=f}()},1962:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((n=n.apply(e,t||[])).next())}))},i=this&&this.__asyncValues||function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,i){!function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)}(n,i,(t=e[r](t)).done,t.value)}))}}},o=this&&this.__await||function(e){return this instanceof o?(this.v=e,this):new o(e)},s=this&&this.__asyncGenerator||function(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,i=r.apply(e,t||[]),s=[];return n={},a("next"),a("throw"),a("return"),n[Symbol.asyncIterator]=function(){return this},n;function a(e){i[e]&&(n[e]=function(t){return new Promise((function(r,n){s.push([e,t,r,n])>1||l(e,t)}))})}function l(e,t){try{(r=i[e](t)).value instanceof o?Promise.resolve(r.value.v).then(u,c):h(s[0][2],r)}catch(e){h(s[0][3],e)}var r}function u(e){l("next",e)}function c(e){l("throw",e)}function h(e,t){e(t),s.shift(),s.length&&l(s[0][0],s[0][1])}},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ApiUrls=t.SortDirection=t.MessageApi=void 0;const l=r(6540),u=r(7867),c=a(r(4203)),h=r(4147),d=r(5592);t.MessageApi=l.messageApi.MessageApi,t.SortDirection=l.messageApi.SortDirection,t.ApiUrls={local:"http://localhost:5555",dev:"https://dev.xmtp.network",production:"https://production.xmtp.network"};const f=e=>!(e=>!(!e||16!==e.code))(e);t.default=class{constructor(e,r){this.pathPrefix=e,this.maxRetries=(null==r?void 0:r.maxRetries)||5,this.appVersion=null==r?void 0:r.appVersion,this.version="xmtp-js/"+h.version,e===t.ApiUrls.dev&&console.info(d.XMTP_DEV_WARNING)}_query(e){return(0,u.retry)(t.MessageApi.Query,[e,{pathPrefix:this.pathPrefix,mode:"cors",headers:this.headers()}],this.maxRetries,100)}_publish(e,r=0){var i;return n(this,void 0,void 0,(function*(){const n=yield this.getToken(),o=this.headers();o.set("Authorization",`Bearer ${n}`);try{return yield(0,u.retry)(t.MessageApi.Publish,[e,{pathPrefix:this.pathPrefix,mode:"cors",headers:o}],this.maxRetries,100,f)}catch(t){if(f(t)||r>=1)throw t;return yield null===(i=this.authCache)||void 0===i?void 0:i.refresh(),this._publish(e,r+1)}}))}_subscribe(e,r){let i;const o=()=>{i=new AbortController;const s=+new Date;t.MessageApi.Subscribe(e,r,{pathPrefix:this.pathPrefix,signal:i.signal,mode:"cors",headers:this.headers()}).catch((e=>n(this,void 0,void 0,(function*(){(e=>!(!e||"AbortError"!==e.name&&!e.message.includes("aborted")))(e)||(console.info("Stream connection lost. Resubscribing",e),+new Date-s<1e3&&(yield(0,u.sleep)(1e3)),o())}))))};return o(),()=>n(this,void 0,void 0,(function*(){null==i||i.abort()}))}query(e,{direction:r=t.SortDirection.SORT_DIRECTION_ASCENDING,limit:o}){var s,a;return n(this,void 0,void 0,(function*(){const t=[];try{for(var n,l=i(this.queryIteratePages(e,{direction:r,pageSize:o&&o<100?o:100}));!(n=yield l.next()).done;){const e=n.value;for(const r of e)if(t.push(r),o&&t.length===o)return t}}catch(e){s={error:e}}finally{try{n&&!n.done&&(a=l.return)&&(yield a.call(l))}finally{if(s)throw s.error}}return t}))}queryIterator(e,t){return s(this,arguments,(function*(){var r,n;try{for(var s,a=i(this.queryIteratePages(e,t));!(s=yield o(a.next())).done;){const e=s.value;for(const t of e)yield yield o(t)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=a.return)&&(yield o(n.call(a)))}finally{if(r)throw r.error}}}))}queryIteratePages({contentTopics:e,startTime:t,endTime:r},{direction:n,pageSize:i=10}){var a,l,c;return s(this,arguments,(function*(){if(!e||!e.length)throw new Error("Must specify content topics");const s=(0,u.toNanoString)(t),h=(0,u.toNanoString)(r);let d;for(;;){const t={limit:i,direction:n,cursor:d},r=yield o(this._query({contentTopics:e,startTimeNs:s,endTimeNs:h,pagingInfo:t}));if(!(null===(a=r.envelopes)||void 0===a?void 0:a.length))return yield o(void 0);if(yield yield o(r.envelopes),!(null===(l=r.pagingInfo)||void 0===l?void 0:l.cursor))return yield o(void 0);d=null===(c=r.pagingInfo)||void 0===c?void 0:c.cursor}}))}publish(e){return n(this,void 0,void 0,(function*(){const t=[];for(const{contentTopic:r,message:n,timestamp:i}of e){if(!r.length)throw new Error("Content topic cannot be empty string");if(!n.length)throw new Error("0 length messages not allowed");const e=i||new Date;t.push({contentTopic:r,timestampNs:(0,u.toNanoString)(e),message:Uint8Array.from(n)})}return this._publish({envelopes:t})}))}subscribe(e,t){if(!e.contentTopics.length)throw new Error("Must provide list of contentTopics to subscribe to");return this._subscribe(e,t)}getToken(){if(!this.authCache)throw new Error("AuthCache is not set on API Client");return this.authCache.getToken()}setAuthenticator(e,t){this.authCache=new c.default(e,t)}headers(){const e=new Headers;return e.set("X-Client-Version",this.version),this.appVersion&&e.set("X-App-Version",this.appVersion),e}}},8901:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((n=n.apply(e,t||[])).next())}))},a=this&&this.__asyncValues||function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,i){!function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)}(n,i,(t=e[r](t)).done,t.value)}))}}};Object.defineProperty(t,"__esModule",{value:!0}),t.defaultOptions=t.Compression=t.KeyStoreType=void 0;const l=r(2449),u=r(7867),c=r(9535),h=r(5880),d=r(6254),f=r(5783),p=r(6540),m=r(3374),y=o(r(1962)),g=r(9099),v=r(7915),{Compression:b}=p.xmtpEnvelope;t.Compression=b;const{b64Decode:w}=p.fetcher,_=104857600;var S;function E(e){const t={keyStoreType:S.networkTopicStoreV1,privateKeyOverride:void 0,env:"dev",apiUrl:void 0,codecs:[new d.TextCodec],maxContentSize:_};return(null==e?void 0:e.codecs)&&(e.codecs=t.codecs.concat(e.codecs)),(null==e?void 0:e.privateKeyOverride)&&!(null==e?void 0:e.keyStoreType)&&(e.keyStoreType=S.static),Object.assign(Object.assign({},t),e)}!function(e){e[e.networkTopicStoreV1=0]="networkTopicStoreV1",e[e.static=1]="static"}(S=t.KeyStoreType||(t.KeyStoreType={})),t.defaultOptions=E;class k{constructor(e,t){this.contacts=new Set,this.knownPublicKeyBundles=new Map,this.legacyKeys=e,this.keys=l.PrivateKeyBundleV2.fromLegacyBundle(e),this.address=e.identityKey.publicKey.walletSignatureAddress(),this._conversations=new h.Conversations(this),this._codecs=new Map,this._maxContentSize=_,this.apiClient=t}get conversations(){return this._conversations}static create(e,t){return s(this,void 0,void 0,(function*(){const r=E(t),n=function(e){const t=e.apiUrl||y.ApiUrls[e.env];return new y.default(t,{appVersion:e.appVersion})}(r),i=yield function(e,t,r){return s(this,void 0,void 0,(function*(){if(!e.privateKeyOverride&&!t)throw new Error("Must provide either an ethers.Signer or specify privateKeyOverride");const n=function(e,t,r){switch(e.keyStoreType){case S.networkTopicStoreV1:if(!t)throw new Error("Must provide a wallet for networkTopicStore");return function(e,t){return new c.EncryptedKeyStore(e,new c.PrivateTopicStore(t))}(t,r);case S.static:if(!e.privateKeyOverride)throw new Error("Must provide a privateKeyOverride to use static store");return n=e.privateKeyOverride,new c.StaticKeyStore(n)}var n}(e,t,r);return function(e,t){return s(this,void 0,void 0,(function*(){let r=yield t.loadPrivateKeyBundle();if(r)return r;if(!e)throw new Error("No wallet found");return r=yield l.PrivateKeyBundleV1.generate(e),yield t.storePrivateKeyBundle(r),r}))}(t,n)}))}(r,e,n);n.setAuthenticator(new g.Authenticator(i.identityKey));const o=new k(i,n);return yield o.init(r),o}))}static getKeys(e,t){return s(this,void 0,void 0,(function*(){return(yield k.create(e,t)).legacyKeys.encode()}))}init(e){return s(this,void 0,void 0,(function*(){e.codecs.forEach((e=>{this.registerCodec(e)})),this._maxContentSize=e.maxContentSize,yield this.ensureUserContactPublished(e.publishLegacyContact)}))}close(){return s(this,void 0,void 0,(function*(){}))}ensureUserContactPublished(e=!1){return s(this,void 0,void 0,(function*(){const t=yield A(this.apiClient,this.address);t&&t instanceof l.SignedPublicKeyBundle&&this.keys.getPublicKeyBundle().equals(t)||(this.publishUserContact(!0),e||this.publishUserContact(e))}))}publishUserContact(e=!1){return s(this,void 0,void 0,(function*(){const t=e?this.legacyKeys:this.keys;yield this.publishEnvelopes([{contentTopic:(0,u.buildUserContactTopic)(this.address),message:(0,m.encodeContactBundle)(t.getPublicKeyBundle())}])}))}getUserContact(e){return s(this,void 0,void 0,(function*(){const t=this.knownPublicKeyBundles.get(e);if(t)return t;const r=yield A(this.apiClient,e);return r&&this.knownPublicKeyBundles.set(e,r),r}))}forgetContact(e){this.knownPublicKeyBundles.delete(e)}canMessage(e){return s(this,void 0,void 0,(function*(){return void 0!==(yield this.getUserContact(e))}))}static canMessage(e,t){return s(this,void 0,void 0,(function*(){const r=(null==t?void 0:t.apiUrl)||y.ApiUrls[(null==t?void 0:t.env)||"dev"];return void 0!==(yield A(new y.default(r,{appVersion:null==t?void 0:t.appVersion}),e))}))}validateEnvelope(e){const t=e.message;if(!e.contentTopic)throw new Error("Missing content topic");if(!t||!t.length)throw new Error("Cannot publish empty message")}publishEnvelopes(e){return s(this,void 0,void 0,(function*(){for(const t of e)this.validateEnvelope(t);try{yield this.apiClient.publish(e)}catch(e){console.log(e)}}))}registerCodec(e){const t=e.contentType,r=`${t.authorityId}/${t.typeId}`;this._codecs.set(r,e)}codecFor(e){const t=`${e.authorityId}/${e.typeId}`,r=this._codecs.get(t);if(r&&!(e.versionMajor>r.contentType.versionMajor))return r}encodeContent(e,t){return s(this,void 0,void 0,(function*(){const r=(null==t?void 0:t.contentType)||d.ContentTypeText,n=this.codecFor(r);if(!n)throw new Error("unknown content type "+r);const i=n.encode(e,this);return(null==t?void 0:t.contentFallback)&&(i.fallback=t.contentFallback),(null==t?void 0:t.compression)&&(i.compression=t.compression),yield(0,f.compress)(i),p.xmtpEnvelope.EncodedContent.encode(i).finish()}))}listInvitations(e){return this.listEnvelopes([(0,u.buildUserInviteTopic)(this.address)],v.SealedInvitation.fromEnvelope,e)}listEnvelopes(e,t,r){return s(this,void 0,void 0,(function*(){r||(r={});const{startTime:n,endTime:i,limit:o}=r,s=yield this.apiClient.query({contentTopics:e,startTime:n,endTime:i},{direction:r.direction||p.messageApi.SortDirection.SORT_DIRECTION_ASCENDING,limit:o}),a=[];for(const e of s)if(e.message)try{const r=yield t(e);a.push(r)}catch(e){console.warn("Error in listEnvelopes mapper",e)}return a}))}listEnvelopesPaginated(e,t,r){return(0,u.mapPaginatedStream)(this.apiClient.queryIteratePages({contentTopics:e,startTime:null==r?void 0:r.startTime,endTime:null==r?void 0:r.endTime},{direction:null==r?void 0:r.direction,pageSize:(null==r?void 0:r.pageSize)||100}),t)}}function A(e,t){var r,n;return s(this,void 0,void 0,(function*(){const i=e.queryIterator({contentTopics:[(0,u.buildUserContactTopic)(t)]},{pageSize:5,direction:y.SortDirection.SORT_DIRECTION_DESCENDING});try{for(var o,s=a(i);!(o=yield s.next()).done;){const e=o.value;if(!e.message)continue;const r=(0,m.decodeContactBundle)(w(e.message.toString()));if((yield null==r?void 0:r.walletSignatureAddress())===t)return r}}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=s.return)&&(yield n.call(s))}finally{if(r)throw r.error}}}))}t.default=k},5783:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.writeStreamToBytes=t.readStreamFromBytes=t.compress=t.decompress=void 0;const i=r(6540);function o(e){if(e===i.xmtpEnvelope.Compression.COMPRESSION_GZIP)return"gzip";if(e===i.xmtpEnvelope.Compression.COMPRESSION_DEFLATE)return"deflate";throw new Error("unrecognized compression algorithm")}function s(e,t=1024){let r=0;return new ReadableStream({pull(n){if(r>=e.length)return n.close();let i=r+t;i=i<=e.length?i:e.length,n.enqueue(e.subarray(r,i)),r=i}})}function a(e,t){let r=0;return new WritableStream({write(n){const i=r+n.length;if(i>t)throw new Error("maximum output size exceeded");for(;e.bytes.length<i;)e.bytes=l(e.bytes,t);e.bytes.set(n,r),r=i},close(){r<e.bytes.length&&(e.bytes=e.bytes.subarray(0,r))}})}function l(e,t){let r=2*e.length;r>t&&(r=t);const n=new Uint8Array(r);return n.set(e),n}r(4215),t.decompress=function(e,t){return n(this,void 0,void 0,(function*(){if(void 0===e.compression)return;const r={bytes:new Uint8Array(e.content.length)};yield s(e.content).pipeThrough(new DecompressionStream(o(e.compression))).pipeTo(a(r,t)),e.content=r.bytes}))},t.compress=function(e){return n(this,void 0,void 0,(function*(){if(void 0===e.compression)return;const t={bytes:new Uint8Array(e.content.length/10)};yield s(e.content).pipeThrough(new CompressionStream(o(e.compression))).pipeTo(a(t,e.content.length+1e3)),e.content=t.bytes}))},t.readStreamFromBytes=s,t.writeStreamToBytes=a},3374:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.encodeContactBundle=t.decodeContactBundle=void 0;const n=r(6540),i=r(2449);t.decodeContactBundle=function(e){var t,r;let o;try{o=n.contact.ContactBundle.decode(e)}catch(t){const r=n.publicKey.PublicKeyBundle.decode(e);o={v1:{keyBundle:new i.PublicKeyBundle(r)},v2:void 0}}if(null===(t=o.v1)||void 0===t?void 0:t.keyBundle)return new i.PublicKeyBundle(o.v1.keyBundle);if(null===(r=o.v2)||void 0===r?void 0:r.keyBundle)return new i.SignedPublicKeyBundle(o.v2.keyBundle);throw new Error("unknown or invalid contact bundle")},t.encodeContactBundle=function(e){return e instanceof i.PublicKeyBundle?n.contact.ContactBundle.encode({v1:{keyBundle:e},v2:void 0}).finish():n.contact.ContactBundle.encode({v1:void 0,v2:{keyBundle:e}}).finish()}},7915:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((n=n.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.SealedInvitation=t.SealedInvitationV1=t.SealedInvitationHeaderV1=t.InvitationV1=void 0;const o=i(r(1583)),s=r(8245),a=r(6540),l=i(r(7527)),u=r(2449),c=r(7867),{b64Decode:h}=a.fetcher;class d{constructor({topic:e,context:t,aes256GcmHkdfSha256:r}){if(!e||!e.length)throw new Error("Missing topic");if(!r||!r.keyMaterial||!r.keyMaterial.length)throw new Error("Missing key material");this.topic=e,this.context=t,this.aes256GcmHkdfSha256=r}static createRandom(e){const t=(0,c.buildDirectMessageTopicV2)(Buffer.from(u.utils.getRandomValues(new Uint8Array(32))).toString("base64").replace(/=*$/g,"").replace("/","-")),r=u.utils.getRandomValues(new Uint8Array(32));return new d({topic:t,aes256GcmHkdfSha256:{keyMaterial:r},context:e})}toBytes(){return a.invitation.InvitationV1.encode(this).finish()}static fromBytes(e){return new d(a.invitation.InvitationV1.decode(e))}}t.InvitationV1=d;class f{constructor({sender:e,recipient:t,createdNs:r}){if(!e)throw new Error("Missing sender");if(!t)throw new Error("Missing recipient");this.sender=new s.SignedPublicKeyBundle(e),this.recipient=new s.SignedPublicKeyBundle(t),this.createdNs=r}toBytes(){return a.invitation.SealedInvitationHeaderV1.encode(this).finish()}static fromBytes(e){return new f(a.invitation.SealedInvitationHeaderV1.decode(e))}}t.SealedInvitationHeaderV1=f;class p{constructor({headerBytes:e,ciphertext:t}){if(!e||!e.length)throw new Error("Missing header bytes");if(!t)throw new Error("Missing ciphertext");this.headerBytes=e,this.ciphertext=new l.default(t)}get header(){return this._header||(this._header=f.fromBytes(this.headerBytes)),this._header}getInvitation(e){return n(this,void 0,void 0,(function*(){if(this._invitation)return this._invitation;const t=this.header;let r;r=e.identityKey.matches(this.header.sender.identityKey)?yield e.sharedSecret(t.recipient,t.sender.preKey,!1):yield e.sharedSecret(t.sender,t.recipient.preKey,!0);const n=yield(0,u.decrypt)(this.ciphertext,r,this.headerBytes);return this._invitation=d.fromBytes(n),this._invitation}))}toBytes(){return a.invitation.SealedInvitationV1.encode(this).finish()}static fromBytes(e){return new p(a.invitation.SealedInvitationV1.decode(e))}}t.SealedInvitationV1=p;class m{constructor({v1:e}){if(!e)throw new Error("Missing v1 invitation");this.v1=new p(e)}toBytes(){return a.invitation.SealedInvitation.encode(this).finish()}static fromBytes(e){return new m(a.invitation.SealedInvitation.decode(e))}static fromEnvelope(e){return n(this,void 0,void 0,(function*(){if(!e.message||!e.timestampNs)throw new Error("invalid invitation envelope");const t=m.fromBytes(h(e.message)),r=o.default.fromString(e.timestampNs);if(!t.v1.header.createdNs.equals(r))throw new Error("envelope and header timestamp mistmatch");return t}))}static createV1({sender:e,recipient:t,created:r,invitation:i}){return n(this,void 0,void 0,(function*(){const n=new f({sender:e.getPublicKeyBundle(),recipient:t,createdNs:(0,c.dateToNs)(r)}).toBytes(),o=yield e.sharedSecret(t,e.getCurrentPreKey().publicKey,!1),s=i.toBytes(),a=yield(0,u.encrypt)(s,o,n);return new m({v1:{headerBytes:n,ciphertext:a}})}))}}t.SealedInvitation=m},6044:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((n=n.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.decodeContent=t.DecodedMessage=t.MessageV2=t.MessageV1=void 0;const o=r(6540),s=i(r(1583)),a=i(r(7527)),l=r(2449),u=r(9272),c=r(6314),h=r(6397),d=r(7867),f=e=>{var t,r;if(null===(t=e.v1)||void 0===t?void 0:t.ciphertext)return[e.v1.headerBytes,new a.default(e.v1.ciphertext)];if(null===(r=e.v2)||void 0===r?void 0:r.ciphertext)return[e.v2.headerBytes,new a.default(e.v2.ciphertext)];throw new Error("unknown message version")};class p{constructor(e,t,r){[this.headerBytes,this.ciphertext]=f(r),this.id=e,this.bytes=t}toBytes(){return this.bytes}}class m extends p{constructor(e,t,r,n,i){super(e,t,r),this.conversation=void 0,this.senderAddress=i,this.header=n}static create(e,t,r){return n(this,void 0,void 0,(function*(){if(!t.sender)throw new Error("missing message sender");const n=new l.PublicKeyBundle(t.sender).walletSignatureAddress(),i=(0,u.bytesToHex)(yield(0,c.sha256)(r));return new m(i,r,e,t,n)}))}get sent(){return new Date(this.header.timestamp.toNumber())}get recipientAddress(){var e,t;if(null===(t=null===(e=this.header)||void 0===e?void 0:e.recipient)||void 0===t?void 0:t.identityKey)return new l.PublicKey(this.header.recipient.identityKey).walletSignatureAddress()}static encode(e,t,r,i){return n(this,void 0,void 0,(function*(){const n=yield e.sharedSecret(t,e.getCurrentPreKey().publicKey,!1),a={sender:e.getPublicKeyBundle(),recipient:t,timestamp:s.default.fromNumber(i.getTime())},u=o.xmtpEnvelope.MessageHeaderV1.encode(a).finish(),c={v1:{headerBytes:u,ciphertext:yield(0,l.encrypt)(r,n,u)},v2:void 0},h=o.xmtpEnvelope.Message.encode(c).finish();return m.create(c,a,h)}))}static fromBytes(e){const t=o.xmtpEnvelope.Message.decode(e),[r]=f(t),n=o.xmtpEnvelope.MessageHeaderV1.decode(r);if(!n)throw new Error("missing message header");if(!n.sender)throw new Error("missing message sender");if(!n.sender.identityKey)throw new Error("missing message sender identity key");if(!n.sender.preKey)throw new Error("missing message sender pre-key");if(!n.recipient)throw new Error("missing message recipient");if(!n.recipient.identityKey)throw new Error("missing message recipient identity-key");if(!n.recipient.preKey)throw new Error("missing message recipient pre-key");return m.create(t,n,e)}decrypt(e){var t,r;return n(this,void 0,void 0,(function*(){const n=this.header;if(!((null===(t=n.recipient)||void 0===t?void 0:t.identityKey)&&(null===(r=n.sender)||void 0===r?void 0:r.identityKey)&&n.recipient.preKey&&n.sender.preKey))throw new Error("Missing headers");const i=new l.PublicKeyBundle({identityKey:new l.PublicKey(n.recipient.identityKey),preKey:new l.PublicKey(n.recipient.preKey)}),o=new l.PublicKeyBundle({identityKey:new l.PublicKey(n.sender.identityKey),preKey:new l.PublicKey(n.sender.preKey)});let s;return s=e.identityKey.matches(o.identityKey)?yield e.sharedSecret(i,o.preKey,!1):yield e.sharedSecret(o,i.preKey,!0),(0,l.decrypt)(this.ciphertext,s,this.headerBytes)}))}}t.MessageV1=m;class y extends p{constructor(e,t,r,n,i,o){super(e,t,r),this.header=n,this.signed=i,this.senderAddress=o}static create(e,t,r,i){return n(this,void 0,void 0,(function*(){const n=(0,u.bytesToHex)(yield(0,c.sha256)(i));if(!r.sender)throw new Error("missing message sender");const o=yield new l.SignedPublicKeyBundle(r.sender).walletSignatureAddress();return new y(n,i,e,t,r,o)}))}get sent(){return(0,d.nsToDate)(this.header.createdNs)}}t.MessageV2=y;class g{constructor({id:e,messageVersion:t,senderAddress:r,recipientAddress:n,conversation:i,contentType:o,contentTopic:s,content:a,sent:l,error:u}){this.id=e,this.messageVersion=t,this.senderAddress=r,this.recipientAddress=n,this.conversation=i,this.contentType=o,this.sent=l,this.error=u,this.content=a,this.contentTopic=s}static fromV1Message(e,t,r,n,i,o){const{id:s,senderAddress:a,recipientAddress:l,sent:u}=e;if(!a)throw new Error("Sender address is required");return new g({id:s,messageVersion:"v1",senderAddress:a,recipientAddress:l,sent:u,content:t,contentType:r,contentTopic:n,conversation:i,error:o})}static fromV2Message(e,t,r,n,i,o){const{id:s,senderAddress:a,sent:l}=e;if(!a)throw new Error("Sender address is required");return new g({id:s,messageVersion:"v2",senderAddress:a,sent:l,content:t,contentType:r,contentTopic:n,conversation:i,error:o})}}t.DecodedMessage=g,t.decodeContent=function(e,t){const r=o.xmtpEnvelope.EncodedContent.decode(e);if(!r.type)throw new Error("missing content type");let n,i,s=new h.ContentTypeId(r.type);const a=t.codecFor(s);return a?n=a.decode(r,t):(i=new Error("unknown content type "+s),r.fallback&&(n=r.fallback,s=h.ContentTypeFallback)),{content:n,contentType:s,error:i}}},6397:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ContentTypeFallback=t.ContentTypeId=void 0;class r{constructor(e){this.authorityId=e.authorityId,this.typeId=e.typeId,this.versionMajor=e.versionMajor,this.versionMinor=e.versionMinor}toString(){return`${this.authorityId}/${this.typeId}:${this.versionMajor}.${this.versionMinor}`}sameAs(e){return this.authorityId===e.authorityId&&this.typeId===e.typeId}}t.ContentTypeId=r,t.ContentTypeFallback=new r({authorityId:"xmtp.org",typeId:"fallback",versionMajor:1,versionMinor:0})},4596:function(e,t){"use strict";var r=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});class n{constructor(e,t,r,n){this.messages=[],this.resolvers=[],this.topics=t,this.client=e,this.callback=this.newMessageCallback(r,n)}newMessageCallback(e,t){return n=>r(this,void 0,void 0,(function*(){if(n.message)try{const r=yield e(n);if(!r)return;if(t){const e=t(r);e&&this.resubscribeToTopics(e)}const i=this.resolvers.pop();i?i({value:r}):this.messages.unshift(r)}catch(e){console.warn(e)}}))}start(){return r(this,void 0,void 0,(function*(){if(!this.callback)throw new Error("Missing callback for stream");this.unsubscribeFn=this.client.apiClient.subscribe({contentTopics:this.topics},(e=>r(this,void 0,void 0,(function*(){this.callback&&(yield null==this?void 0:this.callback(e))}))))}))}static create(e,t,i,o){return r(this,void 0,void 0,(function*(){const r=new n(e,t,i,o);return yield r.start(),r}))}[Symbol.asyncIterator](){return this}return(){return r(this,void 0,void 0,(function*(){return this.unsubscribeFn&&(yield this.unsubscribeFn()),this.callback?(this.callback=void 0,this.resolvers.forEach((e=>e({value:void 0,done:!0}))),{value:void 0,done:!0}):{value:void 0,done:!0}}))}next(){const e=this.messages.pop();return e?Promise.resolve({value:e}):this.callback?new Promise((e=>this.resolvers.unshift(e))):Promise.resolve({value:void 0,done:!0})}resubscribeToTopics(e){return r(this,void 0,void 0,(function*(){if(!this.callback||!this.unsubscribeFn)throw new Error("Missing callback for stream");yield this.unsubscribeFn(),this.topics=e,this.unsubscribeFn=this.client.apiClient.subscribe({contentTopics:this.topics},(e=>r(this,void 0,void 0,(function*(){this.callback&&(yield null==this?void 0:this.callback(e))}))))}))}}t.default=n},4203:function(e,t){"use strict";var r=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(e,t=3590){this.authenticator=e,this.maxAgeMs=1e3*t}getToken(){return r(this,void 0,void 0,(function*(){return(!this.token||this.token.ageMs>this.maxAgeMs)&&(yield this.refresh()),this.token.toBase64()}))}refresh(){return r(this,void 0,void 0,(function*(){this.token=yield this.authenticator.createToken()}))}}},9064:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(6540),i=r(7867);class o{constructor({walletAddr:e,createdNs:t}){this.walletAddr=e,this.createdNs=t}static create(e,t){return t=t||new Date,new o({walletAddr:e,createdNs:(0,i.dateToNs)(t)})}static fromBytes(e){const t=n.authn.AuthData.decode(e);return new o(t)}toBytes(){return n.authn.AuthData.encode(this).finish()}}t.default=o},2138:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((n=n.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1094),s=r(6540),a=i(r(9064)),l=r(9272),u=i(r(8140));t.default=class{constructor(e){if(!e.publicKey.signature)throw new Error("Provided public key is not signed");this.identityKey=e}createToken(e){return n(this,void 0,void 0,(function*(){const t=a.default.create(this.identityKey.publicKey.walletSignatureAddress(),e||new Date).toBytes(),r=(0,o.keccak256)(t),n=yield this.identityKey.sign((0,l.hexToBytes)(r));return new u.default(s.authn.Token.fromPartial({identityKey:s.publicKey.PublicKey.fromPartial(this.identityKey.publicKey),authDataBytes:t,authDataSignature:s.signature.Signature.fromPartial(n)}))}))}}},8140:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=r(6540),o=n(r(9064));class s{constructor({identityKey:e,authDataBytes:t,authDataSignature:r}){if(!e)throw new Error("Missing identity key in token");if(!r)throw new Error("Missing authDataSignature in token");this.identityKey=e,this.authDataBytes=t,this.authDataSignature=r}get authData(){return this._authData||(this._authData=o.default.fromBytes(this.authDataBytes)),this._authData}get ageMs(){return(new Date).valueOf()-this.authData.createdNs.div(1e6).toNumber()}toBytes(){return i.authn.Token.encode(this).finish()}static fromBytes(e){return new s(i.authn.Token.decode(e))}toBase64(){return Buffer.from(this.toBytes()).toString("base64")}}t.default=s},9099:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Token=t.AuthData=t.Authenticator=void 0;var i=r(2138);Object.defineProperty(t,"Authenticator",{enumerable:!0,get:function(){return n(i).default}});var o=r(9064);Object.defineProperty(t,"AuthData",{enumerable:!0,get:function(){return n(o).default}});var s=r(8140);Object.defineProperty(t,"Token",{enumerable:!0,get:function(){return n(s).default}})},4196:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CompositeCodec=t.ContentTypeComposite=void 0;const n=r(6397),i=r(6540);t.ContentTypeComposite=new n.ContentTypeId({authorityId:"xmtp.org",typeId:"composite",versionMajor:1,versionMinor:0}),t.CompositeCodec=class{get contentType(){return t.ContentTypeComposite}encode(e,r){const n=this.toProto(e,r);let o;o=n.composite?n.composite:{parts:[n]};const s=i.composite.Composite.encode(o).finish();return{type:t.ContentTypeComposite,parameters:{},content:s}}decode(e,t){return this.fromProto({composite:i.composite.Composite.decode(e.content),part:void 0},t)}toProto(e,t){if("type"in e){const r=t.codecFor(e.type);if(!r)throw new Error(`missing codec for part type ${e.type}`);return{part:r.encode(e.content,t),composite:void 0}}const r=new Array;for(const n of e.parts)r.push(this.toProto(n,t));return{composite:{parts:r},part:void 0}}fromProto(e,t){if(e.part){if(!e.part.type)throw new Error("missing part content type");const r=new n.ContentTypeId(e.part.type),i=t.codecFor(r);if(!i)throw new Error(`missing codec for part type ${r}`);return{type:r,content:i.decode(e.part,t)}}if(!e.composite)throw new Error("invalid composite");const r=new Array;for(const n of e.composite.parts)r.push(this.fromProto(n,t));return{parts:r}}}},6254:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TextCodec=t.Encoding=t.ContentTypeText=void 0;const n=r(6397);var i;t.ContentTypeText=new n.ContentTypeId({authorityId:"xmtp.org",typeId:"text",versionMajor:1,versionMinor:0}),function(e){e.utf8="UTF-8"}(i=t.Encoding||(t.Encoding={})),t.TextCodec=class{get contentType(){return t.ContentTypeText}encode(e){return{type:t.ContentTypeText,parameters:{encoding:i.utf8},content:(new TextEncoder).encode(e)}}decode(e){const t=e.parameters.encoding;if(t&&t!==i.utf8)throw new Error(`unrecognized encoding ${t}`);return(new TextDecoder).decode(e.content)}}},5592:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.XMTP_DEV_WARNING=void 0,t.XMTP_DEV_WARNING="\nXX XX MM MM TTTTTT PPPPPP DDDDD EEEEEEE VV VV \n XX XX MMM MMM TT PP PP DD DD EE VV VV \n XXXX MM MM MM TT PPPPPP DD DD EEEEE VV VV \n XX XX MM MM TT PP DD DD EE VV VV \nXX XX MM MM TT PP DDDDDD EEEEEEE VVV \n\nConnected to the XMTP 'dev' network. Use 'production' for production messages.\nhttps://github.com/xmtp/xmtp-js#xmtp-production-and-dev-network-environments\n"},3937:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((n=n.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ConversationV2=t.ConversationV1=void 0;const o=r(7867),s=r(6044),a=i(r(4596)),l=r(6044),u=r(6540),c=r(2449),h=i(r(7527)),d=r(6314),f=r(7867),p=r(6254),{b64Decode:m}=u.fetcher;t.ConversationV1=class{constructor(e,t,r){this.context=null,this.peerAddress=t,this.client=e,this.createdAt=r}messages(e){return n(this,void 0,void 0,(function*(){const t=[(0,f.buildDirectMessageTopic)(this.peerAddress,this.client.address)];return this.client.listEnvelopes(t,this.decodeMessage.bind(this),e)}))}get topic(){return(0,f.buildDirectMessageTopic)(this.peerAddress,this.client.address)}messagesPaginated(e){return this.client.listEnvelopesPaginated([this.topic],this.decodeMessage.bind(this),e)}streamMessages(){return a.default.create(this.client,[this.topic],this.decodeMessage.bind(this))}decodeMessage({message:e,contentTopic:t}){return n(this,void 0,void 0,(function*(){const r=u.fetcher.b64Decode(e),n=yield l.MessageV1.fromBytes(r),{senderAddress:i,recipientAddress:o}=n;if(!i||!o||!t||(0,f.buildDirectMessageTopic)(i,o)!==this.topic)throw new Error("Headers do not match intended recipient");const a=yield n.decrypt(this.client.legacyKeys),{content:c,contentType:h,error:d}=(0,l.decodeContent)(a,this.client);return s.DecodedMessage.fromV1Message(n,c,h,t,this,d)}))}send(e,t){return n(this,void 0,void 0,(function*(){let r,n=yield this.client.getUserContact(this.peerAddress);if(!n)throw new Error(`recipient ${this.peerAddress} is not registered`);n instanceof c.PublicKeyBundle||(n=n.toLegacyBundle()),this.client.contacts.has(this.peerAddress)?r=[this.topic]:(r=[(0,o.buildUserIntroTopic)(this.peerAddress),(0,o.buildUserIntroTopic)(this.client.address),this.topic],this.client.contacts.add(this.peerAddress));const i=(null==t?void 0:t.contentType)||p.ContentTypeText,a=(null==t?void 0:t.timestamp)||new Date,u=yield this.client.encodeContent(e,t),h=yield l.MessageV1.encode(this.client.legacyKeys,n,u,a);return yield this.client.publishEnvelopes(r.map((e=>({contentTopic:e,message:h.toBytes(),timestamp:h.sent})))),s.DecodedMessage.fromV1Message(h,e,i,r[0],this)}))}};class y{constructor(e,t,r,n){this.topic=t.topic,this.keyMaterial=t.aes256GcmHkdfSha256.keyMaterial,this.context=t.context,this.client=e,this.header=r,this.peerAddress=n}static create(e,t,r){return n(this,void 0,void 0,(function*(){const n=e.keys.getPublicKeyBundle().equals(r.sender)?r.recipient:r.sender,i=yield n.walletSignatureAddress();return new y(e,t,r,i)}))}get createdAt(){return(0,f.nsToDate)(this.header.createdNs)}messages(e){return n(this,void 0,void 0,(function*(){return this.client.listEnvelopes([this.topic],this.decodeMessage.bind(this),e)}))}messagesPaginated(e){return this.client.listEnvelopesPaginated([this.topic],this.decodeMessage.bind(this),e)}streamMessages(){return a.default.create(this.client,[this.topic],this.decodeMessage.bind(this))}send(e,t){return n(this,void 0,void 0,(function*(){const r=yield this.encodeMessage(e,t);yield this.client.publishEnvelopes([{contentTopic:this.topic,message:r.toBytes(),timestamp:r.sent}]);const n=(null==t?void 0:t.contentType)||p.ContentTypeText;return s.DecodedMessage.fromV2Message(r,e,n,this.topic,this)}))}encodeMessage(e,t){return n(this,void 0,void 0,(function*(){const r=yield this.client.encodeContent(e,t),n={topic:this.topic,createdNs:(0,f.dateToNs)((null==t?void 0:t.timestamp)||new Date)},i=u.xmtpEnvelope.MessageHeaderV2.encode(n).finish(),o=yield(0,d.sha256)(g(i,r)),s={payload:r,sender:this.client.keys.getPublicKeyBundle(),signature:yield this.client.keys.getCurrentPreKey().sign(o)},a=u.xmtpEnvelope.SignedContent.encode(s).finish(),h={v1:void 0,v2:{headerBytes:i,ciphertext:yield(0,c.encrypt)(a,this.keyMaterial,i)}},p=u.xmtpEnvelope.Message.encode(h).finish();return l.MessageV2.create(h,n,s,p)}))}decodeMessage(e){var t,r,i;return n(this,void 0,void 0,(function*(){if(!e.message||!e.contentTopic)throw new Error("empty envelope");const n=m(e.message.toString()),o=u.xmtpEnvelope.Message.decode(n);if(!o.v2)throw new Error("unknown message version");const a=o.v2,f=u.xmtpEnvelope.MessageHeaderV2.decode(a.headerBytes);if(f.topic!==this.topic)throw new Error("topic mismatch");if(!a.ciphertext)throw new Error("missing ciphertext");const p=yield(0,c.decrypt)(new h.default(a.ciphertext),this.keyMaterial,a.headerBytes),y=u.xmtpEnvelope.SignedContent.decode(p);if(!(null===(t=y.sender)||void 0===t?void 0:t.identityKey)||!(null===(r=y.sender)||void 0===r?void 0:r.preKey)||!y.signature)throw new Error("incomplete signed content");const v=yield(0,d.sha256)(g(a.headerBytes,y.payload));if(!new c.SignedPublicKey(null===(i=y.sender)||void 0===i?void 0:i.preKey).verify(new c.Signature(y.signature),v))throw new Error("invalid signature");const b=yield l.MessageV2.create(o,f,y,n),{content:w,contentType:_,error:S}=(0,l.decodeContent)(y.payload,this.client);return s.DecodedMessage.fromV2Message(b,w,_,e.contentTopic,this,S)}))}}function g(e,t){const r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}t.ConversationV2=y},1851:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((n=n.apply(e,t||[])).next())}))},i=this&&this.__asyncValues||function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,i){!function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)}(n,i,(t=e[r](t)).done,t.value)}))}}},o=this&&this.__await||function(e){return this instanceof o?(this.v=e,this):new o(e)},s=this&&this.__asyncGenerator||function(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,i=r.apply(e,t||[]),s=[];return n={},a("next"),a("throw"),a("return"),n[Symbol.asyncIterator]=function(){return this},n;function a(e){i[e]&&(n[e]=function(t){return new Promise((function(r,n){s.push([e,t,r,n])>1||l(e,t)}))})}function l(e,t){try{(r=i[e](t)).value instanceof o?Promise.resolve(r.value.v).then(u,c):h(s[0][2],r)}catch(e){h(s[0][3],e)}var r}function u(e){l("next",e)}function c(e){l("throw",e)}function h(e,t){e(t),s.shift(),s.length&&l(s[0][0],s[0][1])}},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const l=r(8245),u=r(3937),c=r(6044),h=a(r(4596)),d=r(7867),f=r(7915),p=r(2449),m=r(6540),{b64Decode:y}=m.fetcher,g=e=>Boolean(e.recipientAddress&&e.senderAddress);t.default=class{constructor(e){this.client=e}list(){return n(this,void 0,void 0,(function*(){const[e,t]=yield Promise.all([this.getIntroductionPeers(),this.client.listInvitations()]),r=[];e.forEach(((e,t)=>r.push(new u.ConversationV1(this.client,t,e))));for(const e of t)try{const t=yield e.v1.getInvitation(this.client.keys);r.push(yield u.ConversationV2.create(this.client,t,e.v1.header))}catch(e){console.warn("Error decrypting invitation",e)}return r.sort(((e,t)=>e.createdAt.getTime()-t.createdAt.getTime())),r}))}stream(){return n(this,void 0,void 0,(function*(){const e=new Set,t=(0,d.buildUserIntroTopic)(this.client.address),r=(0,d.buildUserInviteTopic)(this.client.address);return h.default.create(this.client,[r,t],(i=>n(this,void 0,void 0,(function*(){if(i.contentTopic===t){const t=y(i.message),r=yield c.MessageV1.fromBytes(t);yield r.decrypt(this.client.legacyKeys);const n=this.getPeerAddress(r);if(!(t=>!e.has(t)&&(e.add(t),!0))(n))return;return new u.ConversationV1(this.client,n,r.sent)}if(i.contentTopic===r){const e=yield f.SealedInvitation.fromEnvelope(i),t=yield e.v1.getInvitation(this.client.keys);return yield u.ConversationV2.create(this.client,t,e.v1.header)}throw new Error("unrecognized invite topic")}))).bind(this))}))}streamAllMessages(){return n(this,void 0,void 0,(function*(){const e=(0,d.buildUserIntroTopic)(this.client.address),t=(0,d.buildUserInviteTopic)(this.client.address),r=new Set([e,t]),a=new Map;for(const e of yield this.list())r.add(e.topic),a.set(e.topic,e);const l=(e,t)=>!r.has(e)&&(a.set(e,t),r.add(e),!0),p=yield h.default.create(this.client,Array.from(r.values()),(r=>n(this,void 0,void 0,(function*(){const n=r.contentTopic;if(!n)return null;if(n===e){const e=y(r.message),t=yield c.MessageV1.fromBytes(e);if(!g(t))return null;yield t.decrypt(this.client.legacyKeys);const n=t.senderAddress===this.client.address?t.recipientAddress:t.senderAddress;return new u.ConversationV1(this.client,n,t.sent).decodeMessage(r)}if(n===t){const e=yield f.SealedInvitation.fromEnvelope(r),t=yield e.v1.getInvitation(this.client.keys);return u.ConversationV2.create(this.client,t,e.v1.header)}const i=a.get(n);if(i instanceof u.ConversationV1)return i.decodeMessage(r);if(i instanceof u.ConversationV2)return i.decodeMessage(r);throw console.log("Unknown topic"),new Error("Unknown topic")}))),(t=>{if(t instanceof c.DecodedMessage&&t.contentTopic===e){const e=new u.ConversationV1(this.client,t.recipientAddress===this.client.address?t.senderAddress:t.recipientAddress,t.sent);return l(e.topic,e)?Array.from(r.values()):void 0}if(t instanceof u.ConversationV2)return l(t.topic,t)?Array.from(r.values()):void 0}));return function(){return s(this,arguments,(function*(){var e,t;try{for(var r,n=i(p);!(r=yield o(n.next())).done;){const e=r.value;if(e instanceof c.DecodedMessage&&(yield yield o(e)),e instanceof u.ConversationV2)for(const t of yield o(e.messages()))yield yield o(t)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&(yield o(t.call(n)))}finally{if(e)throw e.error}}}))}()}))}getIntroductionPeers(){return n(this,void 0,void 0,(function*(){const e=yield this.client.listEnvelopes([(0,d.buildUserIntroTopic)(this.client.address)],(e=>n(this,void 0,void 0,(function*(){const t=yield c.MessageV1.fromBytes(y(e.message));return yield t.decrypt(this.client.legacyKeys),t})))),t=new Map;for(const r of e){if(!g(r))continue;const e=this.getPeerAddress(r);if(e){const n=t.get(e);(!n||n>r.sent)&&t.set(e,r.sent)}}return t}))}newConversation(e,t){return n(this,void 0,void 0,(function*(){let r=yield this.client.getUserContact(e);if(!r)throw new Error(`Recipient ${e} is not on the XMTP network`);if(r instanceof p.PublicKeyBundle&&!(null==t?void 0:t.conversationId))return new u.ConversationV1(this.client,e,new Date);if(!(null==t?void 0:t.conversationId)){const t=(yield this.getIntroductionPeers()).get(e);if(t){if(!this.client.keys.getPublicKeyBundle().isFromLegacyBundle())throw new Error("cannot resume pre-existing V1 conversation; client keys not compatible");if(!(r instanceof p.PublicKeyBundle||r.isFromLegacyBundle()))throw new Error("cannot resume pre-existing V1 conversation; peer keys not compatible");return new u.ConversationV1(this.client,e,t)}}r instanceof p.PublicKeyBundle&&(r=l.SignedPublicKeyBundle.fromLegacyBundle(r));for(const e of yield this.client.listInvitations())if(e.v1.header.recipient.equals(r)||e.v1.header.sender.equals(r))try{const r=yield e.v1.getInvitation(this.client.keys);if(n=t,i=r.context,(null==n?void 0:n.conversationId)===(null==i?void 0:i.conversationId))return yield u.ConversationV2.create(this.client,r,e.v1.header)}catch(e){console.warn("Error decoding invite",e)}var n,i;const o=f.InvitationV1.createRandom(t),s=yield this.sendInvitation(r,o,new Date);return u.ConversationV2.create(this.client,o,s.v1.header)}))}sendInvitation(e,t,r){return n(this,void 0,void 0,(function*(){const n=yield f.SealedInvitation.createV1({sender:this.client.keys,recipient:e,created:r,invitation:t}),i=yield e.walletSignatureAddress();return this.client.publishEnvelopes([{contentTopic:(0,d.buildUserInviteTopic)(i),message:n.toBytes(),timestamp:r},{contentTopic:(0,d.buildUserInviteTopic)(this.client.address),message:n.toBytes(),timestamp:r}]),n}))}getPeerAddress(e){return e.recipientAddress===this.client.address?e.senderAddress:e.recipientAddress}}},5880:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ConversationV2=t.ConversationV1=t.Conversations=void 0;var i=r(1851);Object.defineProperty(t,"Conversations",{enumerable:!0,get:function(){return n(i).default}});var o=r(3937);Object.defineProperty(t,"ConversationV1",{enumerable:!0,get:function(){return o.ConversationV1}}),Object.defineProperty(t,"ConversationV2",{enumerable:!0,get:function(){return o.ConversationV2}})},7527:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AESGCMTagLength=t.AESGCMNonceSize=t.KDFSaltSize=t.AESKeySize=void 0;const n=r(6540);t.AESKeySize=32,t.KDFSaltSize=32,t.AESGCMNonceSize=12,t.AESGCMTagLength=16;class i{constructor(e){if(!e.aes256GcmHkdfSha256)throw new Error("invalid ciphertext");if(e.aes256GcmHkdfSha256.payload.length<t.AESGCMTagLength)throw new Error(`invalid ciphertext ciphertext length: ${e.aes256GcmHkdfSha256.payload.length}`);if(e.aes256GcmHkdfSha256.hkdfSalt.length!==t.KDFSaltSize)throw new Error(`invalid ciphertext salt length: ${e.aes256GcmHkdfSha256.hkdfSalt.length}`);if(e.aes256GcmHkdfSha256.gcmNonce.length!==t.AESGCMNonceSize)throw new Error(`invalid ciphertext nonce length: ${e.aes256GcmHkdfSha256.gcmNonce.length}`);this.aes256GcmHkdfSha256=e.aes256GcmHkdfSha256}toBytes(){return n.ciphertext.Ciphertext.encode(this).finish()}static fromBytes(e){return new i(n.ciphertext.Ciphertext.decode(e))}}t.default=i},270:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((n=n.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PrivateKey=t.SignedPrivateKey=void 0;const l=r(6540),u=o(r(9656)),c=a(r(1583)),h=o(r(6002)),d=r(2940),f=r(6314),p=r(9272);function m(e){if(32!==e.bytes.length)throw new Error(`invalid private key length: ${e.bytes.length}`)}class y{constructor(e){if(!e.secp256k1)throw new Error("invalid private key");if(m(e.secp256k1),this.secp256k1=e.secp256k1,this.createdNs=e.createdNs,!e.publicKey)throw new Error("missing public key");this.publicKey=new d.SignedPublicKey(e.publicKey)}static generate(e){return s(this,void 0,void 0,(function*(){const t={bytes:u.utils.randomPrivateKey()},r=c.default.fromNumber((new Date).getTime()).mul(1e6),n=new d.UnsignedPublicKey({secp256k1Uncompressed:{bytes:u.getPublicKey(t.bytes)},createdNs:r}),i=yield e.signKey(n);return new y({secp256k1:t,createdNs:r,publicKey:i})}))}generated(){return new Date(this.createdNs.div(1e6).toNumber())}sign(e){return s(this,void 0,void 0,(function*(){const[t,r]=yield u.sign(e,this.secp256k1.bytes,{recovered:!0,der:!1});return new h.default({ecdsaCompact:{bytes:t,recovery:r}})}))}signKey(e){return s(this,void 0,void 0,(function*(){const t=e.toBytes(),r=yield(0,f.sha256)(t),n=yield this.sign(r);return new d.SignedPublicKey({keyBytes:t,signature:n})}))}static signerKey(e,t){return s(this,void 0,void 0,(function*(){const r=yield(0,f.sha256)(e.bytesToSign());return(0,h.ecdsaSignerKey)(r,t)}))}sharedSecret(e){return u.getSharedSecret(this.secp256k1.bytes,e.secp256k1Uncompressed.bytes,!1)}encrypt(e,t,r){const n=this.sharedSecret(t);return(0,f.encrypt)(e,n,r)}decrypt(e,t,r){const n=this.sharedSecret(t);return(0,f.decrypt)(e,n,r)}matches(e){return this.publicKey.equals(e)}equals(e){return(0,p.equalBytes)(this.secp256k1.bytes,e.secp256k1.bytes)&&this.publicKey.equals(e.publicKey)}toBytes(){return l.privateKey.SignedPrivateKey.encode(this).finish()}static fromBytes(e){return new y(l.privateKey.SignedPrivateKey.decode(e))}static fromLegacyKey(e,t){return new y({createdNs:e.timestamp.mul(1e6),secp256k1:e.secp256k1,publicKey:d.SignedPublicKey.fromLegacyKey(e.publicKey,t)})}}t.SignedPrivateKey=y;class g{constructor(e){if(!e.secp256k1)throw new Error("invalid private key");if(m(e.secp256k1),this.timestamp=e.timestamp,this.secp256k1=e.secp256k1,!e.publicKey)throw new Error("missing public key");this.publicKey=new d.PublicKey(e.publicKey)}static generate(){const e={bytes:u.utils.randomPrivateKey()},t=c.default.fromNumber((new Date).getTime());return new g({secp256k1:e,timestamp:t,publicKey:new d.PublicKey({secp256k1Uncompressed:{bytes:u.getPublicKey(e.bytes)},timestamp:t})})}generated(){return new Date(this.timestamp.toNumber())}sign(e){return s(this,void 0,void 0,(function*(){const[t,r]=yield u.sign(e,this.secp256k1.bytes,{recovered:!0,der:!1});return new h.default({ecdsaCompact:{bytes:t,recovery:r}})}))}signKey(e){return s(this,void 0,void 0,(function*(){const t=yield(0,f.sha256)(e.bytesToSign());return e.signature=yield this.sign(t),e}))}sharedSecret(e){return u.getSharedSecret(this.secp256k1.bytes,e.secp256k1Uncompressed.bytes,!1)}encrypt(e,t,r){const n=this.sharedSecret(t);return(0,f.encrypt)(e,n,r)}decrypt(e,t,r){const n=this.sharedSecret(t);return(0,f.decrypt)(e,n,r)}matches(e){return this.publicKey.equals(e)}toBytes(){return l.privateKey.PrivateKey.encode(this).finish()}static fromBytes(e){return new g(l.privateKey.PrivateKey.decode(e))}}t.PrivateKey=g},741:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.decodePrivateKeyBundle=t.PrivateKeyBundleV1=t.PrivateKeyBundleV2=void 0;const i=r(6540),o=r(270),s=r(6002),a=r(8245),l=r(4728);class u{constructor(e){if(this.version=2,!e.identityKey)throw new Error("missing identity key");this.identityKey=new o.SignedPrivateKey(e.identityKey),this.preKeys=(e.preKeys||[]).map((e=>new o.SignedPrivateKey(e)))}static generate(e){return n(this,void 0,void 0,(function*(){const t=yield o.SignedPrivateKey.generate(new s.WalletSigner(e)),r=new u({identityKey:t,preKeys:[]});return yield r.addPreKey(),r}))}getCurrentPreKey(){return this.preKeys[0]}findPreKey(e){const t=this.preKeys.find((t=>t.matches(e)));if(!t)throw new l.NoMatchingPreKeyError(e);return t}addPreKey(){return n(this,void 0,void 0,(function*(){this._publicKeyBundle=void 0;const e=yield o.SignedPrivateKey.generate(this.identityKey);this.preKeys.unshift(e)}))}getPublicKeyBundle(){return this._publicKeyBundle||(this._publicKeyBundle=new a.SignedPublicKeyBundle({identityKey:this.identityKey.publicKey,preKey:this.getCurrentPreKey().publicKey})),this._publicKeyBundle}sharedSecret(e,t,r){return n(this,void 0,void 0,(function*(){if(!e.identityKey||!e.preKey)throw new Error("invalid peer key bundle");if(!(yield e.identityKey.verifyKey(e.preKey)))throw new Error("peer preKey signature invalid");if(!this.identityKey)throw new Error("missing identity key");let n,i,o;r?(o=this.findPreKey(t),n=o.sharedSecret(e.identityKey),i=this.identityKey.sharedSecret(e.preKey)):(o=this.findPreKey(t),n=this.identityKey.sharedSecret(e.preKey),i=o.sharedSecret(e.identityKey));const s=o.sharedSecret(e.preKey),a=new Uint8Array(n.length+i.length+s.length);return a.set(n,0),a.set(i,n.length),a.set(s,n.length+i.length),a}))}encode(){return i.privateKey.PrivateKeyBundle.encode({v1:void 0,v2:this}).finish()}equals(e){if(this.preKeys.length!==e.preKeys.length)return!1;for(let t=0;t<this.preKeys.length;t++)if(!this.preKeys[t].equals(e.preKeys[t]))return!1;return this.identityKey.equals(e.identityKey)}static fromLegacyBundle(e){return new u({identityKey:o.SignedPrivateKey.fromLegacyKey(e.identityKey,!0),preKeys:e.preKeys.map((e=>o.SignedPrivateKey.fromLegacyKey(e)))})}}t.PrivateKeyBundleV2=u;class c{constructor(e){if(this.version=1,!e.identityKey)throw new Error("missing identity key");this.identityKey=new o.PrivateKey(e.identityKey),this.preKeys=(e.preKeys||[]).map((e=>new o.PrivateKey(e)))}static generate(e){return n(this,void 0,void 0,(function*(){const t=o.PrivateKey.generate();e&&(yield t.publicKey.signWithWallet(e));const r=new c({identityKey:t,preKeys:[]});return yield r.addPreKey(),r}))}getCurrentPreKey(){return this.preKeys[0]}findPreKey(e){const t=this.preKeys.find((t=>t.matches(e)));if(!t)throw new l.NoMatchingPreKeyError(e);return t}addPreKey(){return n(this,void 0,void 0,(function*(){this._publicKeyBundle=void 0;const e=o.PrivateKey.generate();yield this.identityKey.signKey(e.publicKey),this.preKeys.unshift(e)}))}getPublicKeyBundle(){return this._publicKeyBundle||(this._publicKeyBundle=new a.PublicKeyBundle({identityKey:this.identityKey.publicKey,preKey:this.getCurrentPreKey().publicKey})),this._publicKeyBundle}sharedSecret(e,t,r){return n(this,void 0,void 0,(function*(){if(!e.identityKey||!e.preKey)throw new Error("invalid peer key bundle");if(!(yield e.identityKey.verifyKey(e.preKey)))throw new Error("peer preKey signature invalid");if(!this.identityKey)throw new Error("missing identity key");let n,i,o;r?(o=this.findPreKey(t),n=o.sharedSecret(e.identityKey),i=this.identityKey.sharedSecret(e.preKey)):(o=this.findPreKey(t),n=this.identityKey.sharedSecret(e.preKey),i=o.sharedSecret(e.identityKey));const s=o.sharedSecret(e.preKey),a=new Uint8Array(n.length+i.length+s.length);return a.set(n,0),a.set(i,n.length),a.set(s,n.length+i.length),a}))}encode(){return i.privateKey.PrivateKeyBundle.encode({v1:this,v2:void 0}).finish()}}t.PrivateKeyBundleV1=c,t.decodePrivateKeyBundle=function(e){const t=i.privateKey.PrivateKeyBundle.decode(e);if(t.v1)return new c(t.v1);if(t.v2)return new u(t.v2);throw new Error("unknown private key bundle version")}},2940:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((n=n.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PublicKey=t.SignedPublicKey=t.UnsignedPublicKey=void 0;const l=r(6540),u=o(r(9656)),c=a(r(1583)),h=o(r(6002)),d=r(9272),f=r(9982),p=r(6314),m=new c.default(Math.pow(10,9)).mul(Math.pow(10,9));class y{constructor(e){if(!(null==e?void 0:e.secp256k1Uncompressed))throw new Error("invalid public key");!function(e){if(65!==e.bytes.length)throw new Error(`invalid public key length: ${e.bytes.length}`);if(4!==e.bytes[0])throw new Error(`unrecognized public key prefix: ${e.bytes[0]}`)}(e.secp256k1Uncompressed),this.secp256k1Uncompressed=e.secp256k1Uncompressed,this.createdNs=e.createdNs.toUnsigned()}generated(){return new Date(this.timestamp.toNumber())}isFromLegacyKey(){return this.createdNs.lessThan(m)}get timestamp(){return(this.isFromLegacyKey()?this.createdNs:this.createdNs.div(1e6)).toUnsigned()}verify(e,t){return!!e.ecdsaCompact&&u.verify(e.ecdsaCompact.bytes,t,this.secp256k1Uncompressed.bytes)}verifyKey(e){return s(this,void 0,void 0,(function*(){if(!e.signature)return!1;const t=yield(0,p.sha256)(e.bytesToSign());return this.verify(e.signature,t)}))}equals(e){return(0,d.equalBytes)(this.secp256k1Uncompressed.bytes,e.secp256k1Uncompressed.bytes)}getEthereumAddress(){return f.utils.computeAddress(this.secp256k1Uncompressed.bytes)}toBytes(){return l.publicKey.UnsignedPublicKey.encode(this).finish()}static fromBytes(e){return new y(l.publicKey.UnsignedPublicKey.decode(e))}}t.UnsignedPublicKey=y;class g extends y{constructor(e){if(!e.keyBytes)throw new Error("missing key bytes");if(super(l.publicKey.UnsignedPublicKey.decode(e.keyBytes)),this.keyBytes=e.keyBytes,!e.signature)throw new Error("missing key signature");this.signature=new h.default(e.signature)}get unsignedKey(){return new y({createdNs:this.createdNs,secp256k1Uncompressed:this.secp256k1Uncompressed})}signerKey(){return this.signature.signerKey(this)}walletSignatureAddress(){return s(this,void 0,void 0,(function*(){if(!this.signature.walletEcdsaCompact)throw new Error("key was not signed by a wallet");const e=yield this.signerKey();if(!e)throw new Error("key signature not valid");return e.getEthereumAddress()}))}equals(e){return this.unsignedKey.equals(e.unsignedKey)&&this.signature.equals(e.signature)}bytesToSign(){return this.keyBytes}toBytes(){return l.publicKey.SignedPublicKey.encode(this).finish()}static fromBytes(e){return new g(l.publicKey.SignedPublicKey.decode(e))}toLegacyKey(){if(!this.isFromLegacyKey())throw new Error("cannot be converted to legacy key");let e=this.signature;return e.walletEcdsaCompact&&(e=new h.default({ecdsaCompact:e.walletEcdsaCompact})),new v({timestamp:this.timestamp,secp256k1Uncompressed:this.secp256k1Uncompressed,signature:e})}static fromLegacyKey(e,t){if(!e.signature)throw new Error("key is not signed");let r=e.signature;return t&&(r=new h.default({walletEcdsaCompact:r.ecdsaCompact})),new g({keyBytes:e.bytesToSign(),signature:r})}}t.SignedPublicKey=g;class v extends y{constructor(e){super({createdNs:e.timestamp.mul(1e6),secp256k1Uncompressed:e.secp256k1Uncompressed}),e.signature&&(this.signature=new h.default(e.signature))}get timestamp(){return this.createdNs.div(1e6)}bytesToSign(){return l.publicKey.PublicKey.encode({timestamp:this.timestamp,secp256k1Uncompressed:this.secp256k1Uncompressed}).finish()}signWithWallet(e){return s(this,void 0,void 0,(function*(){const t=yield e.signMessage(h.WalletSigner.identitySigRequestText(this.bytesToSign())),r=f.utils.splitSignature(t),n=(0,d.hexToBytes)(r.r),i=(0,d.hexToBytes)(r.s),o=new Uint8Array(64);o.set(n),o.set(i,n.length),this.signature=new h.default({ecdsaCompact:{bytes:o,recovery:r.recoveryParam}})}))}walletSignatureAddress(){if(!this.signature)throw new Error("key is not signed");const e=(0,d.hexToBytes)(f.utils.hashMessage(h.WalletSigner.identitySigRequestText(this.bytesToSign()))),t=this.signature.getPublicKey(e);if(!t)throw new Error("key signature is malformed");return t.getEthereumAddress()}toBytes(){return l.publicKey.PublicKey.encode(this).finish()}static fromBytes(e){return new v(l.publicKey.PublicKey.decode(e))}}t.PublicKey=v},8245:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PublicKeyBundle=t.SignedPublicKeyBundle=void 0;const n=r(6540),i=r(2940);class o{constructor(e){if(!e.identityKey)throw new Error("missing identity key");if(!e.preKey)throw new Error("missing pre-key");this.identityKey=new i.SignedPublicKey(e.identityKey),this.preKey=new i.SignedPublicKey(e.preKey)}walletSignatureAddress(){return this.identityKey.walletSignatureAddress()}equals(e){return this.identityKey.equals(e.identityKey)&&this.preKey.equals(e.preKey)}toBytes(){return n.publicKey.SignedPublicKeyBundle.encode(this).finish()}isFromLegacyBundle(){return this.identityKey.isFromLegacyKey()&&this.preKey.isFromLegacyKey()}toLegacyBundle(){return new s({identityKey:this.identityKey.toLegacyKey(),preKey:this.preKey.toLegacyKey()})}static fromBytes(e){const t=n.publicKey.SignedPublicKeyBundle.decode(e);return new o(t)}static fromLegacyBundle(e){return new o({identityKey:i.SignedPublicKey.fromLegacyKey(e.identityKey,!0),preKey:i.SignedPublicKey.fromLegacyKey(e.preKey)})}}t.SignedPublicKeyBundle=o;class s{constructor(e){if(!e.identityKey)throw new Error("missing identity key");if(!e.preKey)throw new Error("missing pre-key");this.identityKey=new i.PublicKey(e.identityKey),this.preKey=new i.PublicKey(e.preKey)}equals(e){return this.identityKey.equals(e.identityKey)&&this.preKey.equals(e.preKey)}walletSignatureAddress(){return this.identityKey.walletSignatureAddress()}toBytes(){return n.publicKey.PublicKeyBundle.encode(this).finish()}static fromBytes(e){const t=n.publicKey.PublicKeyBundle.decode(e);return new s(t)}}t.PublicKeyBundle=s},6002:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((n=n.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WalletSigner=t.ecdsaSignerKey=void 0;const l=r(6540),u=a(r(1583)),c=o(r(9656)),h=r(2940),d=r(270),f=r(9982),p=r(9272);function m(e){if(64!==e.bytes.length)throw new Error(`invalid signature length: ${e.bytes.length}`);if(0!==e.recovery&&1!==e.recovery)throw new Error(`invalid recovery bit: ${e.recovery}`)}function y(e,t){return e.recovery===t.recovery&&(0,p.equalBytes)(e.bytes,t.bytes)}function g(e,t){const r=c.recoverPublicKey(e,t.bytes,t.recovery);return r?new h.UnsignedPublicKey({secp256k1Uncompressed:{bytes:r},createdNs:u.default.fromNumber(0)}):void 0}t.ecdsaSignerKey=g;class v{constructor(e){if(e.ecdsaCompact)m(e.ecdsaCompact),this.ecdsaCompact=e.ecdsaCompact;else{if(!e.walletEcdsaCompact)throw new Error("invalid signature");m(e.walletEcdsaCompact),this.walletEcdsaCompact=e.walletEcdsaCompact}}signerKey(e){return s(this,void 0,void 0,(function*(){return this.ecdsaCompact?d.SignedPrivateKey.signerKey(e,this.ecdsaCompact):this.walletEcdsaCompact?b.signerKey(e,this.walletEcdsaCompact):void 0}))}getPublicKey(e){if(!this.ecdsaCompact)throw new Error("invalid signature");const t=c.recoverPublicKey(e,this.ecdsaCompact.bytes,this.ecdsaCompact.recovery);return t?new h.PublicKey({secp256k1Uncompressed:{bytes:t},timestamp:u.default.fromNumber(0)}):void 0}equals(e){return this.ecdsaCompact&&e.ecdsaCompact?y(this.ecdsaCompact,e.ecdsaCompact):!(!this.walletEcdsaCompact||!e.walletEcdsaCompact)&&y(this.walletEcdsaCompact,e.walletEcdsaCompact)}toBytes(){return l.signature.Signature.encode(this).finish()}static fromBytes(e){return new v(l.signature.Signature.decode(e))}}t.default=v;class b{constructor(e){this.wallet=e}static identitySigRequestText(e){return`XMTP : Create Identity\n${(0,p.bytesToHex)(e)}\n\nFor more info: https://xmtp.org/signatures/`}static signerKey(e,t){return g((0,p.hexToBytes)(f.utils.hashMessage(this.identitySigRequestText(e.bytesToSign()))),t)}signKey(e){return s(this,void 0,void 0,(function*(){const t=e.toBytes(),r=yield this.wallet.signMessage(b.identitySigRequestText(t)),n=f.utils.splitSignature(r),i=(0,p.hexToBytes)(n.r),o=(0,p.hexToBytes)(n.s),s=new Uint8Array(64);s.set(i),s.set(o,i.length);const a=new v({walletEcdsaCompact:{bytes:s,recovery:n.recoveryParam}});return new h.SignedPublicKey({keyBytes:t,signature:a})}))}}t.WalletSigner=b},6314:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.decrypt=t.encrypt=t.sha256=t.crypto=void 0;const a=o(r(7527));t.crypto="undefined"!=typeof window?window.crypto:r(2114).webcrypto;const l=new ArrayBuffer(0);function u(e,t){const r={name:"AES-GCM",iv:e};return t&&(r.additionalData=t),r}function c(e,r){return s(this,void 0,void 0,(function*(){const n=yield t.crypto.subtle.importKey("raw",e,"HKDF",!1,["deriveKey"]);return t.crypto.subtle.deriveKey({name:"HKDF",hash:"SHA-256",salt:r,info:l},n,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}))}t.sha256=function(e){return s(this,void 0,void 0,(function*(){return new Uint8Array(yield t.crypto.subtle.digest("SHA-256",e))}))},t.encrypt=function(e,r,n){return s(this,void 0,void 0,(function*(){const i=t.crypto.getRandomValues(new Uint8Array(a.KDFSaltSize)),o=t.crypto.getRandomValues(new Uint8Array(a.AESGCMNonceSize)),s=yield c(r,i),l=yield t.crypto.subtle.encrypt(u(o,n),s,e);return new a.default({aes256GcmHkdfSha256:{payload:new Uint8Array(l),hkdfSalt:i,gcmNonce:o}})}))},t.decrypt=function(e,r,n){return s(this,void 0,void 0,(function*(){if(!e.aes256GcmHkdfSha256)throw new Error("invalid payload ciphertext");const i=yield c(r,e.aes256GcmHkdfSha256.hkdfSalt),o=yield t.crypto.subtle.decrypt(u(e.aes256GcmHkdfSha256.gcmNonce,n),i,e.aes256GcmHkdfSha256.payload);return new Uint8Array(o)}))}},4728:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NoMatchingPreKeyError=void 0;const n=r(9272);class i extends Error{constructor(e){super(`no pre-key matches: ${(0,n.bytesToHex)(e.secp256k1Uncompressed.bytes)}`)}}t.NoMatchingPreKeyError=i},2449:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.WalletSigner=t.Signature=t.PrivateKeyBundleV2=t.PrivateKeyBundleV1=t.decodePrivateKeyBundle=t.SignedPrivateKey=t.PrivateKey=t.PublicKeyBundle=t.PublicKey=t.SignedPublicKeyBundle=t.SignedPublicKey=t.UnsignedPublicKey=t.decrypt=t.encrypt=t.utils=void 0;const s=r(8245);Object.defineProperty(t,"PublicKeyBundle",{enumerable:!0,get:function(){return s.PublicKeyBundle}}),Object.defineProperty(t,"SignedPublicKeyBundle",{enumerable:!0,get:function(){return s.SignedPublicKeyBundle}});const a=r(270);Object.defineProperty(t,"SignedPrivateKey",{enumerable:!0,get:function(){return a.SignedPrivateKey}}),Object.defineProperty(t,"PrivateKey",{enumerable:!0,get:function(){return a.PrivateKey}});const l=r(741);Object.defineProperty(t,"PrivateKeyBundleV1",{enumerable:!0,get:function(){return l.PrivateKeyBundleV1}}),Object.defineProperty(t,"PrivateKeyBundleV2",{enumerable:!0,get:function(){return l.PrivateKeyBundleV2}}),Object.defineProperty(t,"decodePrivateKeyBundle",{enumerable:!0,get:function(){return l.decodePrivateKeyBundle}});const u=r(2940);Object.defineProperty(t,"UnsignedPublicKey",{enumerable:!0,get:function(){return u.UnsignedPublicKey}}),Object.defineProperty(t,"SignedPublicKey",{enumerable:!0,get:function(){return u.SignedPublicKey}}),Object.defineProperty(t,"PublicKey",{enumerable:!0,get:function(){return u.PublicKey}});const c=o(r(6002));t.Signature=c.default,Object.defineProperty(t,"WalletSigner",{enumerable:!0,get:function(){return c.WalletSigner}});const h=o(r(9272));t.utils=h;const d=r(6314);Object.defineProperty(t,"encrypt",{enumerable:!0,get:function(){return d.encrypt}}),Object.defineProperty(t,"decrypt",{enumerable:!0,get:function(){return d.decrypt}})},9272:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.equalBytes=t.hexToBytes=t.bytesToHex=t.getRandomValues=void 0;const s=o(r(9656)),a=r(6314);t.getRandomValues=function(e){return a.crypto.getRandomValues(e)},t.bytesToHex=s.utils.bytesToHex,t.hexToBytes=function(e){e.startsWith("0x")&&(e=e.slice(2));const t=new Uint8Array(e.length/2);for(let r=0;r<t.length;r++){const n=2*r;t[r]=Number.parseInt(e.slice(n,n+2),16)}return t},t.equalBytes=function(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}},4432:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.toNanoString=t.fromNanoString=t.dateToNs=t.nsToDate=t.SortDirection=t.ContentTypeComposite=t.CompositeCodec=t.ContentTypeText=t.TextCodec=t.ContentTypeFallback=t.ContentTypeId=t.Conversations=t.Compression=t.Client=t.Stream=t.PrivateKey=t.SignedPublicKeyBundle=t.PublicKeyBundle=t.PublicKey=t.DecodedMessage=void 0;var i=r(6044);Object.defineProperty(t,"DecodedMessage",{enumerable:!0,get:function(){return i.DecodedMessage}});var o=r(2449);Object.defineProperty(t,"PublicKey",{enumerable:!0,get:function(){return o.PublicKey}}),Object.defineProperty(t,"PublicKeyBundle",{enumerable:!0,get:function(){return o.PublicKeyBundle}}),Object.defineProperty(t,"SignedPublicKeyBundle",{enumerable:!0,get:function(){return o.SignedPublicKeyBundle}}),Object.defineProperty(t,"PrivateKey",{enumerable:!0,get:function(){return o.PrivateKey}});var s=r(4596);Object.defineProperty(t,"Stream",{enumerable:!0,get:function(){return n(s).default}});var a=r(8901);Object.defineProperty(t,"Client",{enumerable:!0,get:function(){return n(a).default}}),Object.defineProperty(t,"Compression",{enumerable:!0,get:function(){return a.Compression}});var l=r(5880);Object.defineProperty(t,"Conversations",{enumerable:!0,get:function(){return l.Conversations}});var u=r(6397);Object.defineProperty(t,"ContentTypeId",{enumerable:!0,get:function(){return u.ContentTypeId}}),Object.defineProperty(t,"ContentTypeFallback",{enumerable:!0,get:function(){return u.ContentTypeFallback}});var c=r(6254);Object.defineProperty(t,"TextCodec",{enumerable:!0,get:function(){return c.TextCodec}}),Object.defineProperty(t,"ContentTypeText",{enumerable:!0,get:function(){return c.ContentTypeText}});var h=r(4196);Object.defineProperty(t,"CompositeCodec",{enumerable:!0,get:function(){return h.CompositeCodec}}),Object.defineProperty(t,"ContentTypeComposite",{enumerable:!0,get:function(){return h.ContentTypeComposite}});var d=r(1962);Object.defineProperty(t,"SortDirection",{enumerable:!0,get:function(){return d.SortDirection}});var f=r(7867);Object.defineProperty(t,"nsToDate",{enumerable:!0,get:function(){return f.nsToDate}}),Object.defineProperty(t,"dateToNs",{enumerable:!0,get:function(){return f.dateToNs}}),Object.defineProperty(t,"fromNanoString",{enumerable:!0,get:function(){return f.fromNanoString}}),Object.defineProperty(t,"toNanoString",{enumerable:!0,get:function(){return f.toNanoString}})},4215:(e,t,r)=>{"use strict";r(3052)},7261:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((n=n.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.storageSigRequestText=void 0;const o=r(9982),s=r(2449),a=r(9099),l=r(9272),u=i(r(7527)),c=r(6540),h="key_bundle";function d(e){return`XMTP : Enable Identity\n${(0,l.bytesToHex)(e)}\n\nFor more info: https://xmtp.org/signatures/`}t.default=class{constructor(e,t){this.signer=e,this.store=t}getStorageAddress(e){return n(this,void 0,void 0,(function*(){return`${yield this.signer.getAddress()}/${e}`}))}loadPrivateKeyBundle(){return n(this,void 0,void 0,(function*(){const e=yield this.store.get(yield this.getStorageAddress(h));if(!e)return null;const[t,r]=yield this.fromEncryptedBytes(this.signer,Uint8Array.from(e));return r&&(yield this.storePrivateKeyBundle(t)),t}))}storePrivateKeyBundle(e){return n(this,void 0,void 0,(function*(){const t=yield this.getStorageAddress(h),r=yield this.toEncryptedBytes(e,this.signer);"function"==typeof this.store.setAuthenticator&&this.store.setAuthenticator(new a.Authenticator(e.identityKey)),yield this.store.set(t,Buffer.from(r))}))}toEncryptedBytes(e,t){return n(this,void 0,void 0,(function*(){const r=e.encode(),n=(0,l.getRandomValues)(new Uint8Array(32)),i=d(n),a=yield t.getAddress();let u=yield t.signMessage(i),h=o.utils.verifyMessage(i,u);if(h!==a&&(u=yield t.signMessage(i),console.log("invalid signature, retrying"),h=o.utils.verifyMessage(i,u),h!==a))throw new Error("invalid signature");const f=(0,l.hexToBytes)(u),p=yield(0,s.encrypt)(r,f);return c.privateKey.EncryptedPrivateKeyBundle.encode({v1:{walletPreKey:n,ciphertext:p}}).finish()}))}fromEncryptedBytes(e,t){var r;return n(this,void 0,void 0,(function*(){const[n,i]=function(e){try{const t=c.privateKey.EncryptedPrivateKeyBundle.decode(e);if(t.v1)return[t.v1,!1]}catch(t){return[c.privateKey.EncryptedPrivateKeyBundleV1.decode(e),!0]}throw new Error("unrecognized encrypted private key bundle version")}(t);if(!n.walletPreKey)throw new Error("missing wallet pre-key");if(!(null===(r=n.ciphertext)||void 0===r?void 0:r.aes256GcmHkdfSha256))throw new Error("missing bundle ciphertext");const o=(0,l.hexToBytes)(yield e.signMessage(d(n.walletPreKey))),a=new u.default(n.ciphertext),h=yield(0,s.decrypt)(a,o),[f,p]=function(e){try{return[(0,s.decodePrivateKeyBundle)(e),!1]}catch(t){const r=c.privateKey.PrivateKeyBundleV1.decode(e);return[new s.PrivateKeyBundleV1(r),!0]}}(h);return[f,i||p]}))}},t.storageSigRequestText=d},9185:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((n=n.apply(e,t||[])).next())}))},i=this&&this.__asyncValues||function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,i){!function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)}(n,i,(t=e[r](t)).done,t.value)}))}}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(6540),s=r(7867),a=o.fetcher.b64Decode;t.default=class{constructor(e){this.client=e}get(e){var t,r;return n(this,void 0,void 0,(function*(){try{for(var n,s=i(this.client.queryIterator({contentTopics:[this.buildTopic(e)]},{pageSize:10,direction:o.messageApi.SortDirection.SORT_DIRECTION_DESCENDING}));!(n=yield s.next()).done;){const e=n.value;if(e.message)try{const t=a(e.message.toString());return Buffer.from(t)}catch(e){console.log(e)}}}catch(e){t={error:e}}finally{try{n&&!n.done&&(r=s.return)&&(yield r.call(s))}finally{if(t)throw t.error}}return null}))}set(e,t){return n(this,void 0,void 0,(function*(){const r=Uint8Array.from(t);yield this.client.publish([{contentTopic:this.buildTopic(e),message:r}])}))}setAuthenticator(e){this.client.setAuthenticator(e)}buildTopic(e){return(0,s.buildUserPrivateStoreTopic)(e)}}},8173:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const i=r(741);t.default=class{constructor(e){this.value=e}loadPrivateKeyBundle(){return n(this,void 0,void 0,(function*(){return(0,i.decodePrivateKeyBundle)(this.value)}))}storePrivateKeyBundle(){return n(this,void 0,void 0,(function*(){throw new Error("Store is not possible with StaticStore")}))}}},9535:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.StaticKeyStore=t.PrivateTopicStore=t.storageSigRequestText=t.EncryptedKeyStore=void 0;var i=r(7261);Object.defineProperty(t,"EncryptedKeyStore",{enumerable:!0,get:function(){return n(i).default}}),Object.defineProperty(t,"storageSigRequestText",{enumerable:!0,get:function(){return i.storageSigRequestText}});var o=r(9185);Object.defineProperty(t,"PrivateTopicStore",{enumerable:!0,get:function(){return n(o).default}});var s=r(8173);Object.defineProperty(t,"StaticKeyStore",{enumerable:!0,get:function(){return n(s).default}})},7867:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((n=n.apply(e,t||[])).next())}))},i=this&&this.__asyncValues||function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,i){!function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)}(n,i,(t=e[r](t)).done,t.value)}))}}},o=this&&this.__await||function(e){return this instanceof o?(this.v=e,this):new o(e)},s=this&&this.__asyncGenerator||function(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,i=r.apply(e,t||[]),s=[];return n={},a("next"),a("throw"),a("return"),n[Symbol.asyncIterator]=function(){return this},n;function a(e){i[e]&&(n[e]=function(t){return new Promise((function(r,n){s.push([e,t,r,n])>1||l(e,t)}))})}function l(e,t){try{(r=i[e](t)).value instanceof o?Promise.resolve(r.value.v).then(u,c):h(s[0][2],r)}catch(e){h(s[0][3],e)}var r}function u(e){l("next",e)}function c(e){l("throw",e)}function h(e,t){e(t),s.shift(),s.length&&l(s[0][0],s[0][1])}},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.fromNanoString=t.toNanoString=t.nsToDate=t.dateToNs=t.mapPaginatedStream=t.retry=t.promiseWithTimeout=t.sleep=t.buildUserPrivateStoreTopic=t.buildUserInviteTopic=t.buildUserIntroTopic=t.buildUserContactTopic=t.buildDirectMessageTopicV2=t.buildDirectMessageTopic=t.buildContentTopic=void 0;const l=a(r(1583));t.buildContentTopic=e=>`/xmtp/0/${e}/proto`,t.buildDirectMessageTopic=(e,r)=>{const n=[e,r];return n.sort(),(0,t.buildContentTopic)(`dm-${n.join("-")}`)},t.buildDirectMessageTopicV2=e=>(0,t.buildContentTopic)(`m-${e}`),t.buildUserContactTopic=e=>(0,t.buildContentTopic)(`contact-${e}`),t.buildUserIntroTopic=e=>(0,t.buildContentTopic)(`intro-${e}`),t.buildUserInviteTopic=e=>(0,t.buildContentTopic)(`invite-${e}`),t.buildUserPrivateStoreTopic=e=>(0,t.buildContentTopic)(`privatestore-${e}`),t.sleep=e=>new Promise((t=>setTimeout(t,e))),t.promiseWithTimeout=(e,t,r)=>{let n;const i=new Promise(((t,i)=>{n=setTimeout((()=>i(new Error(r))),e)}));return Promise.race([t(),i]).then((e=>(clearTimeout(n),e)))};const u=e=>!!e;function c(e){return l.default.fromNumber(e.valueOf()).multiply(1e6)}function h(e){return new Date(e.divide(1e6).toNumber())}t.retry=function e(r,i,o,s,a=u,l=1){return n(this,void 0,void 0,(function*(){const n="number"==typeof l?l:1;try{return yield r(...i)}catch(l){if(!a(l)||n>o)throw l;return yield(0,t.sleep)(s),e(r,i,o,s,a,n+1)}}))},t.mapPaginatedStream=function(e,t){return s(this,arguments,(function*(){var r,n;try{for(var s,a=i(e);!(s=yield o(a.next())).done;){const e=s.value,r=yield o(Promise.allSettled(e.map(t))),n=[];for(const e of r)"fulfilled"===e.status?n.push(e.value):console.warn("Failed to process envelope due to reason: ",e.reason);yield yield o(n)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=a.return)&&(yield o(n.call(a)))}finally{if(r)throw r.error}}}))},t.dateToNs=c,t.nsToDate=h,t.toNanoString=e=>e&&c(e).toString(),t.fromNanoString=e=>{if(e)return h(l.default.fromString(e))}},9159:()=>{},6601:()=>{},2114:()=>{},1583:(e,t)=>{var r,n=function(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=null;try{t=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(e){}function r(e,t,r){this.low=0|e,this.high=0|t,this.unsigned=!!r}function n(e){return!0===(e&&e.__isLong__)}function i(e){var t=Math.clz32(e&-e);return e?31-t:t}r.prototype.__isLong__,Object.defineProperty(r.prototype,"__isLong__",{value:!0}),r.isLong=n;var o={},s={};function a(e,t){var r,n,i;return t?(i=0<=(e>>>=0)&&e<256)&&(n=s[e])?n:(r=u(e,0,!0),i&&(s[e]=r),r):(i=-128<=(e|=0)&&e<128)&&(n=o[e])?n:(r=u(e,e<0?-1:0,!1),i&&(o[e]=r),r)}function l(e,t){if(isNaN(e))return t?v:g;if(t){if(e<0)return v;if(e>=p)return E}else{if(e<=-m)return k;if(e+1>=m)return S}return e<0?l(-e,t).neg():u(e%f|0,e/f|0,t)}function u(e,t,n){return new r(e,t,n)}r.fromInt=a,r.fromNumber=l,r.fromBits=u;var c=Math.pow;function h(e,t,r){if(0===e.length)throw Error("empty string");if("number"==typeof t?(r=t,t=!1):t=!!t,"NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t?v:g;if((r=r||10)<2||36<r)throw RangeError("radix");var n;if((n=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===n)return h(e.substring(1),t,r).neg();for(var i=l(c(r,8)),o=g,s=0;s<e.length;s+=8){var a=Math.min(8,e.length-s),u=parseInt(e.substring(s,s+a),r);if(a<8){var d=l(c(r,a));o=o.mul(d).add(l(u))}else o=(o=o.mul(i)).add(l(u))}return o.unsigned=t,o}function d(e,t){return"number"==typeof e?l(e,t):"string"==typeof e?h(e,t):u(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}r.fromString=h,r.fromValue=d;var f=4294967296,p=f*f,m=p/2,y=a(1<<24),g=a(0);r.ZERO=g;var v=a(0,!0);r.UZERO=v;var b=a(1);r.ONE=b;var w=a(1,!0);r.UONE=w;var _=a(-1);r.NEG_ONE=_;var S=u(-1,2147483647,!1);r.MAX_VALUE=S;var E=u(-1,-1,!0);r.MAX_UNSIGNED_VALUE=E;var k=u(0,-2147483648,!1);r.MIN_VALUE=k;var A=r.prototype;A.toInt=function(){return this.unsigned?this.low>>>0:this.low},A.toNumber=function(){return this.unsigned?(this.high>>>0)*f+(this.low>>>0):this.high*f+(this.low>>>0)},A.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(k)){var t=l(e),r=this.div(t),n=r.mul(t).sub(this);return r.toString(e)+n.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var i=l(c(e,6),this.unsigned),o=this,s="";;){var a=o.div(i),u=(o.sub(a.mul(i)).toInt()>>>0).toString(e);if((o=a).isZero())return u+s;for(;u.length<6;)u="0"+u;s=""+u+s}},A.getHighBits=function(){return this.high},A.getHighBitsUnsigned=function(){return this.high>>>0},A.getLowBits=function(){return this.low},A.getLowBitsUnsigned=function(){return this.low>>>0},A.getNumBitsAbs=function(){if(this.isNegative())return this.eq(k)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&0==(e&1<<t);t--);return 0!=this.high?t+33:t+1},A.isZero=function(){return 0===this.high&&0===this.low},A.eqz=A.isZero,A.isNegative=function(){return!this.unsigned&&this.high<0},A.isPositive=function(){return this.unsigned||this.high>=0},A.isOdd=function(){return 1==(1&this.low)},A.isEven=function(){return 0==(1&this.low)},A.equals=function(e){return n(e)||(e=d(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low},A.eq=A.equals,A.notEquals=function(e){return!this.eq(e)},A.neq=A.notEquals,A.ne=A.notEquals,A.lessThan=function(e){return this.comp(e)<0},A.lt=A.lessThan,A.lessThanOrEqual=function(e){return this.comp(e)<=0},A.lte=A.lessThanOrEqual,A.le=A.lessThanOrEqual,A.greaterThan=function(e){return this.comp(e)>0},A.gt=A.greaterThan,A.greaterThanOrEqual=function(e){return this.comp(e)>=0},A.gte=A.greaterThanOrEqual,A.ge=A.greaterThanOrEqual,A.compare=function(e){if(n(e)||(e=d(e)),this.eq(e))return 0;var t=this.isNegative(),r=e.isNegative();return t&&!r?-1:!t&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},A.comp=A.compare,A.negate=function(){return!this.unsigned&&this.eq(k)?k:this.not().add(b)},A.neg=A.negate,A.add=function(e){n(e)||(e=d(e));var t=this.high>>>16,r=65535&this.high,i=this.low>>>16,o=65535&this.low,s=e.high>>>16,a=65535&e.high,l=e.low>>>16,c=0,h=0,f=0,p=0;return f+=(p+=o+(65535&e.low))>>>16,h+=(f+=i+l)>>>16,c+=(h+=r+a)>>>16,c+=t+s,u((f&=65535)<<16|(p&=65535),(c&=65535)<<16|(h&=65535),this.unsigned)},A.subtract=function(e){return n(e)||(e=d(e)),this.add(e.neg())},A.sub=A.subtract,A.multiply=function(e){if(this.isZero())return this;if(n(e)||(e=d(e)),t)return u(t.mul(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned);if(e.isZero())return this.unsigned?v:g;if(this.eq(k))return e.isOdd()?k:g;if(e.eq(k))return this.isOdd()?k:g;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(y)&&e.lt(y))return l(this.toNumber()*e.toNumber(),this.unsigned);var r=this.high>>>16,i=65535&this.high,o=this.low>>>16,s=65535&this.low,a=e.high>>>16,c=65535&e.high,h=e.low>>>16,f=65535&e.low,p=0,m=0,b=0,w=0;return b+=(w+=s*f)>>>16,m+=(b+=o*f)>>>16,b&=65535,m+=(b+=s*h)>>>16,p+=(m+=i*f)>>>16,m&=65535,p+=(m+=o*h)>>>16,m&=65535,p+=(m+=s*c)>>>16,p+=r*f+i*h+o*c+s*a,u((b&=65535)<<16|(w&=65535),(p&=65535)<<16|(m&=65535),this.unsigned)},A.mul=A.multiply,A.divide=function(e){if(n(e)||(e=d(e)),e.isZero())throw Error("division by zero");var r,i,o;if(t)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?u((this.unsigned?t.div_u:t.div_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?v:g;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return v;if(e.gt(this.shru(1)))return w;o=v}else{if(this.eq(k))return e.eq(b)||e.eq(_)?k:e.eq(k)?b:(r=this.shr(1).div(e).shl(1)).eq(g)?e.isNegative()?b:_:(i=this.sub(e.mul(r)),o=r.add(i.div(e)));if(e.eq(k))return this.unsigned?v:g;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();o=g}for(i=this;i.gte(e);){r=Math.max(1,Math.floor(i.toNumber()/e.toNumber()));for(var s=Math.ceil(Math.log(r)/Math.LN2),a=s<=48?1:c(2,s-48),h=l(r),f=h.mul(e);f.isNegative()||f.gt(i);)f=(h=l(r-=a,this.unsigned)).mul(e);h.isZero()&&(h=b),o=o.add(h),i=i.sub(f)}return o},A.div=A.divide,A.modulo=function(e){return n(e)||(e=d(e)),t?u((this.unsigned?t.rem_u:t.rem_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},A.mod=A.modulo,A.rem=A.modulo,A.not=function(){return u(~this.low,~this.high,this.unsigned)},A.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},A.clz=A.countLeadingZeros,A.countTrailingZeros=function(){return this.low?i(this.low):i(this.high)+32},A.ctz=A.countTrailingZeros,A.and=function(e){return n(e)||(e=d(e)),u(this.low&e.low,this.high&e.high,this.unsigned)},A.or=function(e){return n(e)||(e=d(e)),u(this.low|e.low,this.high|e.high,this.unsigned)},A.xor=function(e){return n(e)||(e=d(e)),u(this.low^e.low,this.high^e.high,this.unsigned)},A.shiftLeft=function(e){return n(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?u(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):u(0,this.low<<e-32,this.unsigned)},A.shl=A.shiftLeft,A.shiftRight=function(e){return n(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?u(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):u(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},A.shr=A.shiftRight,A.shiftRightUnsigned=function(e){return n(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?u(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):u(32===e?this.high:this.high>>>e-32,0,this.unsigned)},A.shru=A.shiftRightUnsigned,A.shr_u=A.shiftRightUnsigned,A.rotateLeft=function(e){var t;return n(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?u(this.high,this.low,this.unsigned):e<32?(t=32-e,u(this.low<<e|this.high>>>t,this.high<<e|this.low>>>t,this.unsigned)):(t=32-(e-=32),u(this.high<<e|this.low>>>t,this.low<<e|this.high>>>t,this.unsigned))},A.rotl=A.rotateLeft,A.rotateRight=function(e){var t;return n(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?u(this.high,this.low,this.unsigned):e<32?(t=32-e,u(this.high<<t|this.low>>>e,this.low<<t|this.high>>>e,this.unsigned)):(t=32-(e-=32),u(this.low<<t|this.high>>>e,this.high<<t|this.low>>>e,this.unsigned))},A.rotr=A.rotateRight,A.toSigned=function(){return this.unsigned?u(this.low,this.high,!1):this},A.toUnsigned=function(){return this.unsigned?this:u(this.low,this.high,!0)},A.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},A.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},A.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},r.fromBytes=function(e,t,n){return n?r.fromBytesLE(e,t):r.fromBytesBE(e,t)},r.fromBytesLE=function(e,t){return new r(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},r.fromBytesBE=function(e,t){return new r(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)};var P=r;return e.default=P,"default"in e?e.default:e}({});void 0===(r=function(){return n}.apply(t,[]))||(e.exports=r)},4147:e=>{"use strict";e.exports=JSON.parse('{"name":"@xmtp/xmtp-js","version":"0.0.0-development","description":"XMTP client SDK for interacting with XMTP networks.","main":"dist/cjs/src/index.js","module":"dist/esm/src/index.js","umd:main":"dist/umd/index.js","browser":"dist/umd/index.js","types":"dist/types/src/index.d.ts","scripts":{"build":"npm run build:cjs && npm run build:esm && npm run build:umd && npm run build:types","build:cjs":"node tools/cleanup cjs && tsc -p config/tsconfig.cjs.json","build:esm":"node tools/cleanup esm && tsc -p config/tsconfig.esm.json","build:umd":"node tools/cleanup umd && webpack --config config/webpack.config.js","build:types":"node tools/cleanup types && tsc -p config/tsconfig.types.json","build:docs":"rm -rf docs && mkdir -p tmp && cp README.md tmp/ && sed -i.bak \'/badge.svg/d\' tmp/README.md && typedoc --excludePrivate --readme tmp/README.md src/index.ts","clean":"node tools/cleanup && npm run clean:proto","clean:proto":"rm -rf src/proto/*.ts","package":"npm pack","prepublish":"npm run build","test":"npm run test:node","test:node":"jest --no-cache --env=\'node\' --forceExit --testTimeout=30000","test:jsdom":"jest --no-cache --env=\'./jest.jsdom.env.js\' --forceExit --testTimeout=30000","test:cov":"jest --coverage --no-cache --runInBand","lint":"prettier --check . && eslint .","autolint":"prettier --write . && eslint --fix .","semantic-release":"semantic-release"},"publishConfig":{"access":"public"},"files":["dist"],"keywords":["xmtp","messaging","web3","sdk","js","javascript","node","nodejs"],"author":"XMTP Labs <eng@xmtp.com>","license":"MIT","homepage":"https://github.com/xmtp/xmtp-js","repository":{"type":"git","url":"https:git@github.com:xmtp/xmtp-js.git"},"bugs":{"url":"https://github.com/xmtp/xmtp-js/issues"},"release":{"branches":["main",{"name":"beta","prerelease":true}]},"dependencies":{"@noble/secp256k1":"^1.5.2","@stardazed/streams-polyfill":"^2.4.0","@xmtp/proto":"^3.4.0","ethers":"^5.5.3","long":"^5.2.0"},"devDependencies":{"@commitlint/cli":"^16.1.0","@commitlint/config-conventional":"^16.0.0","@types/bl":"^5.0.2","@types/callback-to-async-iterator":"^1.1.4","@types/jest":"^27.0.1","@typescript-eslint/eslint-plugin":"^5.38.0","@typescript-eslint/parser":"^5.38.0","dd-trace":"^2.12.2","eslint":"^8.0.1","eslint-config-prettier":"^8.3.0","eslint-config-standard":"^17.0.0","eslint-plugin-import":"^2.26.0","eslint-plugin-jsdoc":"^37.9.1","eslint-plugin-node":"^11.1.0","eslint-plugin-prettier":"^4.0.0","eslint-plugin-promise":"^6.0.1","husky":"^7.0.4","jest":"^27.2.0","prettier":"^2.4.0","semantic-release":"^19.0.2","ts-jest":"^27.0.5","ts-loader":"^9.2.5","typedoc":"^0.22.11","typescript":"^4.4.3","webpack":"^5.52.1","webpack-cli":"^4.8.0"}}')}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var r=__webpack_module_cache__[e]={id:e,loaded:!1,exports:{}};return __webpack_modules__[e].call(r.exports,r,r.exports,__webpack_require__),r.loaded=!0,r.exports}__webpack_require__.amdO={},__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},__webpack_require__.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var __webpack_exports__=__webpack_require__(4432);return __webpack_exports__})()}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment