@rsksmart/rif-storage
Version:
Library integrating distributed storage projects
2 lines • 459 kB
JavaScript
/*! For license information please see index.min.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.RsksmartRifStorage=t():e.RsksmartRifStorage=t()}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var s=t[r]={i:r,l:!1,exports:{}};return e[r].call(s.exports,s,s.exports,n),s.l=!0,s.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)n.d(r,s,function(t){return e[t]}.bind(null,s));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=132)}([function(e,t,n){"use strict";const r=n(232);e.exports=e=>t=>e(new r(t),t)},function(e,t,n){"use strict";const r=n(52),{mtimeToObject:s}=n(37);e.exports=({arg:e,searchParams:t,hashAlg:n,mtime:i,mode:o,...a}={})=>{t&&(a={...a,...t}),n&&(a.hash=n),null!=i&&(i=s(i),a.mtime=i.secs,a.mtimeNsecs=i.nsecs),null!=o&&(a.mode=r(o)),a.timeout&&!isNaN(a.timeout)&&(a.timeout=a.timeout+"ms"),null==e?e=[]:Array.isArray(e)||(e=[e]);const c=new URLSearchParams(a);return e.forEach(e=>c.append("arg",e)),c}},function(e,t,n){"use strict";const r=n(7),s=n(45),i=n(18),{baseTable:o}=n(29),a=n(188),c=n(189),u=n(190),l=n(191),f=Object.keys(o).reduce((e,t)=>(e[o[t]]=t,e),{}),h=Symbol.for("@ipld/js-cid/CID");class d{constructor(e,t,n,o){if(this.version,this.codec,this.multihash,Object.defineProperty(this,h,{value:!0}),d.isCID(e)){const t=e;return this.version=t.version,this.codec=t.codec,this.multihash=t.multihash,void(this.multibaseName=t.multibaseName||(0===t.version?"base58btc":"base32"))}if("string"==typeof e){const t=s.isEncoded(e);if(t){const n=s.decode(e);this.version=parseInt(n[0].toString(),16),this.codec=i.getCodec(n.slice(1)),this.multihash=i.rmPrefix(n.slice(1)),this.multibaseName=t}else this.version=0,this.codec="dag-pb",this.multihash=r.fromB58String(e),this.multibaseName="base58btc";return d.validateCID(this),void Object.defineProperty(this,"string",{value:e})}if(e instanceof Uint8Array){const t=parseInt(e[0].toString(),16);if(1===t){const n=e;this.version=t,this.codec=i.getCodec(n.slice(1)),this.multihash=i.rmPrefix(n.slice(1)),this.multibaseName="base32"}else this.version=0,this.codec="dag-pb",this.multihash=e,this.multibaseName="base58btc";d.validateCID(this)}else this.version=e,"number"==typeof t&&(t=f[t]),this.codec=t,this.multihash=n,this.multibaseName=o||(0===e?"base58btc":"base32"),d.validateCID(this)}get bytes(){let e=this._bytes;if(!e){if(0===this.version)e=this.multihash;else{if(1!==this.version)throw new Error("unsupported version");{const t=i.getCodeVarint(this.codec);e=c([[1],t,this.multihash],1+t.byteLength+this.multihash.byteLength)}}Object.defineProperty(this,"_bytes",{value:e})}return e}get prefix(){const e=i.getCodeVarint(this.codec),t=r.prefix(this.multihash);return c([[this.version],e,t],1+e.byteLength+t.byteLength)}get code(){return o[this.codec]}toV0(){if("dag-pb"!==this.codec)throw new Error("Cannot convert a non dag-pb CID to CIDv0");const{name:e,length:t}=r.decode(this.multihash);if("sha2-256"!==e)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");if(32!==t)throw new Error("Cannot convert non 32 byte multihash CID to CIDv0");return new d(0,this.codec,this.multihash)}toV1(){return new d(1,this.codec,this.multihash)}toBaseEncodedString(e=this.multibaseName){if(this.string&&0!==this.string.length&&e===this.multibaseName)return this.string;let t;if(0===this.version){if("base58btc"!==e)throw new Error("not supported with CIDv0, to support different bases, please migrate the instance do CIDv1, you can do that through cid.toV1()");t=r.toB58String(this.multihash)}else{if(1!==this.version)throw new Error("unsupported version");t=u(s.encode(e,this.bytes))}return e===this.multibaseName&&Object.defineProperty(this,"string",{value:t}),t}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}toString(e){return this.toBaseEncodedString(e)}toJSON(){return{codec:this.codec,version:this.version,hash:this.multihash}}equals(e){return this.codec===e.codec&&this.version===e.version&&l(this.multihash,e.multihash)}static validateCID(e){const t=a.checkCIDComponents(e);if(t)throw new Error(t)}static isCID(e){return e instanceof d||Boolean(e&&e[h])}}d.codecs=o,e.exports=d},function(e,t,n){"use strict";e.exports=e=>{if(null==e)return e;const t=/^[A-Z]+$/;return Object.keys(e).reduce((n,r)=>(t.test(r)?n[r.toLowerCase()]=e[r]:t.test(r[0])?n[r[0].toLowerCase()+r.slice(1)]=e[r]:n[r]=e[r],n),{})}},function(e,t,n){"use strict";(function(e){var r=n(134),s=n(135),i=n(136);function o(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(o()<t)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=c.prototype:(null===e&&(e=new c(t)),e.length=t),e}function c(e,t,n){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return f(this,e)}return u(this,e,t,n)}function u(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r);c.TYPED_ARRAY_SUPPORT?(e=t).__proto__=c.prototype:e=h(e,t);return e}(e,t,n,r):"string"==typeof t?function(e,t,n){"string"==typeof n&&""!==n||(n="utf8");if(!c.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|p(t,n),s=(e=a(e,r)).write(t,n);s!==r&&(e=e.slice(0,s));return e}(e,t,n):function(e,t){if(c.isBuffer(t)){var n=0|d(t.length);return 0===(e=a(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?a(e,0):h(e,t);if("Buffer"===t.type&&i(t.data))return h(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function l(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function f(e,t){if(l(t),e=a(e,t<0?0:0|d(t)),!c.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function h(e,t){var n=t.length<0?0:0|d(t.length);e=a(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function d(e){if(e>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|e}function p(e,t){if(c.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return F(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return z(e).length;default:if(r)return F(e).length;t=(""+t).toLowerCase(),r=!0}}function b(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return N(this,t,n);case"utf8":case"utf-8":return A(this,t,n);case"ascii":return O(this,t,n);case"latin1":case"binary":return T(this,t,n);case"base64":return x(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function g(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function m(e,t,n,r,s){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=s?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(s)return-1;n=e.length-1}else if(n<0){if(!s)return-1;n=0}if("string"==typeof t&&(t=c.from(t,r)),c.isBuffer(t))return 0===t.length?-1:y(e,t,n,r,s);if("number"==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):y(e,[t],n,r,s);throw new TypeError("val must be string, number or Buffer")}function y(e,t,n,r,s){var i,o=1,a=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;o=2,a/=2,c/=2,n/=2}function u(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(s){var l=-1;for(i=n;i<a;i++)if(u(e,i)===u(t,-1===l?0:i-l)){if(-1===l&&(l=i),i-l+1===c)return l*o}else-1!==l&&(i-=i-l),l=-1}else for(n+c>a&&(n=a-c),i=n;i>=0;i--){for(var f=!0,h=0;h<c;h++)if(u(e,i+h)!==u(t,h)){f=!1;break}if(f)return i}return-1}function k(e,t,n,r){n=Number(n)||0;var s=e.length-n;r?(r=Number(r))>s&&(r=s):r=s;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var o=0;o<r;++o){var a=parseInt(t.substr(2*o,2),16);if(isNaN(a))return o;e[n+o]=a}return o}function w(e,t,n,r){return H(F(t,e.length-n),e,n,r)}function v(e,t,n,r){return H(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function E(e,t,n,r){return v(e,t,n,r)}function _(e,t,n,r){return H(z(t),e,n,r)}function S(e,t,n,r){return H(function(e,t){for(var n,r,s,i=[],o=0;o<e.length&&!((t-=2)<0);++o)n=e.charCodeAt(o),r=n>>8,s=n%256,i.push(s),i.push(r);return i}(t,e.length-n),e,n,r)}function x(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function A(e,t,n){n=Math.min(e.length,n);for(var r=[],s=t;s<n;){var i,o,a,c,u=e[s],l=null,f=u>239?4:u>223?3:u>191?2:1;if(s+f<=n)switch(f){case 1:u<128&&(l=u);break;case 2:128==(192&(i=e[s+1]))&&(c=(31&u)<<6|63&i)>127&&(l=c);break;case 3:i=e[s+1],o=e[s+2],128==(192&i)&&128==(192&o)&&(c=(15&u)<<12|(63&i)<<6|63&o)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:i=e[s+1],o=e[s+2],a=e[s+3],128==(192&i)&&128==(192&o)&&128==(192&a)&&(c=(15&u)<<18|(63&i)<<12|(63&o)<<6|63&a)>65535&&c<1114112&&(l=c)}null===l?(l=65533,f=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),s+=f}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=4096));return n}(r)}t.Buffer=c,t.SlowBuffer=function(e){+e!=e&&(e=0);return c.alloc(+e)},t.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(t){return!1}}(),t.kMaxLength=o(),c.poolSize=8192,c._augment=function(e){return e.__proto__=c.prototype,e},c.from=function(e,t,n){return u(null,e,t,n)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(e,t,n){return function(e,t,n,r){return l(t),t<=0?a(e,t):void 0!==n?"string"==typeof r?a(e,t).fill(n,r):a(e,t).fill(n):a(e,t)}(null,e,t,n)},c.allocUnsafe=function(e){return f(null,e)},c.allocUnsafeSlow=function(e){return f(null,e)},c.isBuffer=function(e){return!(null==e||!e._isBuffer)},c.compare=function(e,t){if(!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,s=0,i=Math.min(n,r);s<i;++s)if(e[s]!==t[s]){n=e[s],r=t[s];break}return n<r?-1:r<n?1:0},c.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(e,t){if(!i(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=c.allocUnsafe(t),s=0;for(n=0;n<e.length;++n){var o=e[n];if(!c.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(r,s),s+=o.length}return r},c.byteLength=p,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)g(this,t,t+1);return this},c.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)g(this,t,t+3),g(this,t+1,t+2);return this},c.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)g(this,t,t+7),g(this,t+1,t+6),g(this,t+2,t+5),g(this,t+3,t+4);return this},c.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?A(this,0,e):b.apply(this,arguments)},c.prototype.equals=function(e){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===c.compare(this,e)},c.prototype.inspect=function(){var e="",n=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),"<Buffer "+e+">"},c.prototype.compare=function(e,t,n,r,s){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===s&&(s=this.length),t<0||n>e.length||r<0||s>this.length)throw new RangeError("out of range index");if(r>=s&&t>=n)return 0;if(r>=s)return-1;if(t>=n)return 1;if(this===e)return 0;for(var i=(s>>>=0)-(r>>>=0),o=(n>>>=0)-(t>>>=0),a=Math.min(i,o),u=this.slice(r,s),l=e.slice(t,n),f=0;f<a;++f)if(u[f]!==l[f]){i=u[f],o=l[f];break}return i<o?-1:o<i?1:0},c.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},c.prototype.indexOf=function(e,t,n){return m(this,e,t,n,!0)},c.prototype.lastIndexOf=function(e,t,n){return m(this,e,t,n,!1)},c.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var s=this.length-t;if((void 0===n||n>s)&&(n=s),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return k(this,e,t,n);case"utf8":case"utf-8":return w(this,e,t,n);case"ascii":return v(this,e,t,n);case"latin1":case"binary":return E(this,e,t,n);case"base64":return _(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function O(e,t,n){var r="";n=Math.min(e.length,n);for(var s=t;s<n;++s)r+=String.fromCharCode(127&e[s]);return r}function T(e,t,n){var r="";n=Math.min(e.length,n);for(var s=t;s<n;++s)r+=String.fromCharCode(e[s]);return r}function N(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var s="",i=t;i<n;++i)s+=B(e[i]);return s}function I(e,t,n){for(var r=e.slice(t,n),s="",i=0;i<r.length;i+=2)s+=String.fromCharCode(r[i]+256*r[i+1]);return s}function R(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function P(e,t,n,r,s,i){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>s||t<i)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function C(e,t,n,r){t<0&&(t=65535+t+1);for(var s=0,i=Math.min(e.length-n,2);s<i;++s)e[n+s]=(t&255<<8*(r?s:1-s))>>>8*(r?s:1-s)}function L(e,t,n,r){t<0&&(t=4294967295+t+1);for(var s=0,i=Math.min(e.length-n,4);s<i;++s)e[n+s]=t>>>8*(r?s:3-s)&255}function D(e,t,n,r,s,i){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function U(e,t,n,r,i){return i||D(e,0,n,4),s.write(e,t,n,r,23,4),n+4}function j(e,t,n,r,i){return i||D(e,0,n,8),s.write(e,t,n,r,52,8),n+8}c.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),c.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=c.prototype;else{var s=t-e;n=new c(s,void 0);for(var i=0;i<s;++i)n[i]=this[i+e]}return n},c.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||R(e,t,this.length);for(var r=this[e],s=1,i=0;++i<t&&(s*=256);)r+=this[e+i]*s;return r},c.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||R(e,t,this.length);for(var r=this[e+--t],s=1;t>0&&(s*=256);)r+=this[e+--t]*s;return r},c.prototype.readUInt8=function(e,t){return t||R(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||R(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||R(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||R(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||R(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||R(e,t,this.length);for(var r=this[e],s=1,i=0;++i<t&&(s*=256);)r+=this[e+i]*s;return r>=(s*=128)&&(r-=Math.pow(2,8*t)),r},c.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||R(e,t,this.length);for(var r=t,s=1,i=this[e+--r];r>0&&(s*=256);)i+=this[e+--r]*s;return i>=(s*=128)&&(i-=Math.pow(2,8*t)),i},c.prototype.readInt8=function(e,t){return t||R(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||R(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(e,t){t||R(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(e,t){return t||R(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||R(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||R(e,4,this.length),s.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||R(e,4,this.length),s.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||R(e,8,this.length),s.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||R(e,8,this.length),s.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||P(this,e,t,n,Math.pow(2,8*n)-1,0);var s=1,i=0;for(this[t]=255&e;++i<n&&(s*=256);)this[t+i]=e/s&255;return t+n},c.prototype.writeUIntBE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||P(this,e,t,n,Math.pow(2,8*n)-1,0);var s=n-1,i=1;for(this[t+s]=255&e;--s>=0&&(i*=256);)this[t+s]=e/i&255;return t+n},c.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):C(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):C(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):L(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):L(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var s=Math.pow(2,8*n-1);P(this,e,t,n,s-1,-s)}var i=0,o=1,a=0;for(this[t]=255&e;++i<n&&(o*=256);)e<0&&0===a&&0!==this[t+i-1]&&(a=1),this[t+i]=(e/o>>0)-a&255;return t+n},c.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var s=Math.pow(2,8*n-1);P(this,e,t,n,s-1,-s)}var i=n-1,o=1,a=0;for(this[t+i]=255&e;--i>=0&&(o*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/o>>0)-a&255;return t+n},c.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):C(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):C(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):L(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):L(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,n){return U(this,e,t,!0,n)},c.prototype.writeFloatBE=function(e,t,n){return U(this,e,t,!1,n)},c.prototype.writeDoubleLE=function(e,t,n){return j(this,e,t,!0,n)},c.prototype.writeDoubleBE=function(e,t,n){return j(this,e,t,!1,n)},c.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var s,i=r-n;if(this===e&&n<t&&t<r)for(s=i-1;s>=0;--s)e[s+t]=this[s+n];else if(i<1e3||!c.TYPED_ARRAY_SUPPORT)for(s=0;s<i;++s)e[s+t]=this[s+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+i),t);return i},c.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var s=e.charCodeAt(0);s<256&&(e=s)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!c.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var i;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i<n;++i)this[i]=e;else{var o=c.isBuffer(e)?e:F(new c(e,r).toString()),a=o.length;for(i=0;i<n-t;++i)this[i+t]=o[i%a]}return this};var M=/[^+\/0-9A-Za-z-_]/g;function B(e){return e<16?"0"+e.toString(16):e.toString(16)}function F(e,t){var n;t=t||1/0;for(var r=e.length,s=null,i=[],o=0;o<r;++o){if((n=e.charCodeAt(o))>55295&&n<57344){if(!s){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(o+1===r){(t-=3)>-1&&i.push(239,191,189);continue}s=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),s=n;continue}n=65536+(s-55296<<10|n-56320)}else s&&(t-=3)>-1&&i.push(239,191,189);if(s=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function z(e){return r.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(M,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function H(e,t,n,r){for(var s=0;s<r&&!(s+n>=t.length||s>=e.length);++s)t[s+n]=e[s];return s}}).call(this,n(17))},function(e,t,n){"use strict";t.TextEncoder=TextEncoder,t.TextDecoder=TextDecoder},function(e,t,n){"use strict";const r=n(192),s=n(47),i=n(36),o=n(79),a=n(50),c=n(31),u=Symbol.for("nodejs.util.inspect.custom"),l=n(10),f=n(51),h=new Map,d=a.proto((function(e){if(!(this instanceof d))return new d(e);if(null==e&&(e=""),e instanceof Uint8Array)this.bytes=r.fromBytes(e);else if("string"==typeof e||e instanceof String){if(e.length>0&&"/"!==e.charAt(0))throw new Error(`multiaddr "${e}" must start with a "/"`);this.bytes=r.fromString(e)}else{if(!(e.bytes&&e.protos&&e.protoCodes))throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=r.fromBytes(e.bytes)}}),{className:"Multiaddr",symbolName:"@multiformats/js-multiaddr/multiaddr"});d.prototype.toString=function(){return r.bytesToString(this.bytes)},d.prototype.toJSON=d.prototype.toString,d.prototype.toOptions=function(){const e={},t=this.toString().split("/");return e.family="ip4"===t[1]?"ipv4":"ipv6",e.host=t[2],e.transport=t[3],e.port=parseInt(t[4]),e},d.prototype[u]=function(){return"<Multiaddr "+l(this.bytes,"base16")+" - "+r.bytesToString(this.bytes)+">"},d.prototype.inspect=function(){return"<Multiaddr "+l(this.bytes,"base16")+" - "+r.bytesToString(this.bytes)+">"},d.prototype.protos=function(){return this.protoCodes().map(e=>Object.assign({},s(e)))},d.prototype.protoCodes=function(){const e=[],t=this.bytes;let n=0;for(;n<t.length;){const o=i.decode(t,n),a=i.decode.bytes,c=s(o);n+=r.sizeForAddr(c,t.slice(n+a))+a,e.push(o)}return e},d.prototype.protoNames=function(){return this.protos().map(e=>e.name)},d.prototype.tuples=function(){return r.bytesToTuples(this.bytes)},d.prototype.stringTuples=function(){const e=r.bytesToTuples(this.bytes);return r.tuplesToStringTuples(e)},d.prototype.encapsulate=function(e){return e=d(e),d(this.toString()+e.toString())},d.prototype.decapsulate=function(e){e=e.toString();const t=this.toString(),n=t.lastIndexOf(e);if(n<0)throw new Error("Address "+this+" does not contain subaddress: "+e);return d(t.slice(0,n))},d.prototype.decapsulateCode=function(e){const t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return d(r.tuplesToBytes(t.slice(0,n)));return this},d.prototype.getPeerId=function(){let e=null;try{e=this.stringTuples().filter(e=>{if(e[0]===s.names.ipfs.code)return!0}).pop()[1],e=l(new o(e).multihash,"base58btc")}catch(t){e=null}return e},d.prototype.getPath=function(){let e=null;try{e=this.stringTuples().filter(e=>{if(s(e[0]).path)return!0})[0][1]}catch(t){e=null}return e},d.prototype.equals=function(e){return f(this.bytes,e.bytes)},d.prototype.resolve=async function(){const e=this.protos().find(e=>e.resolvable);if(!e)return[this];const t=h.get(e.name);if(!t)throw c(new Error("no available resolver for "+e.name),"ERR_NO_AVAILABLE_RESOLVER");return(await t(this)).map(e=>d(e))},d.prototype.nodeAddress=function(){const e=this.protoCodes(),t=this.protoNames(),n=this.toString().split("/").slice(1);if(n.length<4)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6}/{address}/{tcp, udp}/{port}".');if(4!==e[0]&&41!==e[0]&&54!==e[0]&&55!==e[0])throw new Error(`no protocol with name: "'${t[0]}'". Must have a valid family name: "{ip4, ip6, dns4, dns6}".`);if("tcp"!==n[2]&&"udp"!==n[2])throw new Error(`no protocol with name: "'${t[1]}'". Must have a valid transport protocol: "{tcp, udp}".`);return{family:41===e[0]||55===e[0]?6:4,address:n[1],port:parseInt(n[3])}},d.fromNodeAddress=function(e,t){if(!e)throw new Error("requires node address object");if(!t)throw new Error("requires transport protocol");let n;switch(e.family){case"IPv4":n="ip4";break;case"IPv6":n="ip6";break;default:throw Error(`Invalid addr family. Got '${e.family}' instead of 'IPv4' or 'IPv6'`)}return d("/"+[n,e.address,t,e.port].join("/"))},d.prototype.isThinWaistAddress=function(e){const t=(e||this).protos();return 2===t.length&&((4===t[0].code||41===t[0].code)&&(6===t[1].code||273===t[1].code))},d.protocols=s,d.isName=function(e){return!!d.isMultiaddr(e)&&e.protos().some(e=>e.resolvable)},d.resolve=function(e){return d.isMultiaddr(e)&&d.isName(e)?Promise.reject(new Error("not implemented yet")):Promise.reject(Error("not a valid name"))},d.resolvers=h,e.exports=d},function(e,t,n){"use strict";const r=n(42),s=n(150),{names:i}=n(154),o=n(155),a=n(156),c=n(157),u={};for(const b in i){const e=b;u[i[e]]=e}function l(e){if(!(e instanceof Uint8Array))throw new Error("multihash must be a Uint8Array");if(e.length<2)throw new Error("multihash too short. must be > 2 bytes.");const t=s.decode(e);if(!d(t))throw new Error("multihash unknown function code: 0x"+t.toString(16));e=e.slice(s.decode.bytes);const n=s.decode(e);if(n<0)throw new Error("multihash invalid length: "+n);if((e=e.slice(s.decode.bytes)).length!==n)throw new Error("multihash length inconsistent: 0x"+o(e,"base16"));return{code:t,name:u[t],length:n,digest:e}}function f(e){let t=e;if("string"==typeof e){if(void 0===i[e])throw new Error("Unrecognized hash function named: "+e);t=i[e]}if("number"!=typeof t)throw new Error("Hash function code should be a number. Got: "+t);if(void 0===u[t]&&!h(t))throw new Error("Unrecognized function code: "+t);return t}function h(e){return e>0&&e<16}function d(e){return!!h(e)||!!u[e]}function p(e){l(e)}e.exports={names:i,codes:Object.freeze(u),toHexString:function(e){if(!(e instanceof Uint8Array))throw new Error("must be passed a Uint8Array");return o(e,"base16")},fromHexString:function(e){return a(e,"base16")},toB58String:function(e){if(!(e instanceof Uint8Array))throw new Error("must be passed a Uint8Array");return o(r.encode("base58btc",e)).slice(1)},fromB58String:function(e){const t=e instanceof Uint8Array?o(e):e;return r.decode("z"+t)},decode:l,encode:function(e,t,n){if(!e||void 0===t)throw new Error("multihash encode requires at least two args: digest, code");const r=f(t);if(!(e instanceof Uint8Array))throw new Error("digest should be a Uint8Array");if(null==n&&(n=e.length),n&&e.length!==n)throw new Error("digest length should be equal to specified length.");const i=s.encode(r),o=s.encode(n);return c([i,o,e],i.length+o.length+e.length)},coerceCode:f,isAppCode:h,validate:p,prefix:function(e){return p(e),e.subarray(0,2)},isValidCode:d}},function(e,t,n){"use strict";const{names:r}=n(75),{TextEncoder:s}=n(5),i=new s;e.exports=function(e,t="utf8"){if("utf8"===t||"utf-8"===t)return i.encode(e);if("ascii"===t)return function(e){const t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}(e);const n=r[t];if(!n)throw new Error("Unknown base");return n.decode(e)}},function(e,t,n){"use strict";var r,s,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function c(e){if(r===setTimeout)return setTimeout(e,0);if((r===o||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:o}catch(e){r=o}try{s="function"==typeof clearTimeout?clearTimeout:a}catch(e){s=a}}();var u,l=[],f=!1,h=-1;function d(){f&&u&&(f=!1,u.length?l=u.concat(l):h=-1,l.length&&p())}function p(){if(!f){var e=c(d);f=!0;for(var t=l.length;t;){for(u=l,l=[];++h<t;)u&&u[h].run();h=-1,t=l.length}u=null,f=!1,function(e){if(s===clearTimeout)return clearTimeout(e);if((s===a||!s)&&clearTimeout)return s=clearTimeout,clearTimeout(e);try{s(e)}catch(t){try{return s.call(null,e)}catch(t){return s.call(this,e)}}}(e)}}function b(e,t){this.fun=e,this.array=t}function g(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];l.push(new b(e,t)),1!==l.length||f||c(p)},b.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=g,i.addListener=g,i.once=g,i.off=g,i.removeListener=g,i.removeAllListeners=g,i.emit=g,i.prependListener=g,i.prependOnceListener=g,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(e,t,n){"use strict";const{names:r}=n(75),{TextDecoder:s}=n(5),i=new s("utf8");e.exports=function(e,t="utf8"){if("utf8"===t||"utf-8"===t)return i.decode(e);if("ascii"===t)return function(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return t}(e);const n=r[t];if(!n)throw new Error("Unknown base");return n.encode(e)}},function(e,t,n){"use strict";const r=n(85)();r.AbortController&&r.AbortSignal?(e.exports=class extends r.AbortController{},e.exports.AbortSignal=r.AbortSignal,e.exports.default=e.exports):e.exports=n(230)},function(e,t,n){"use strict";e.exports=function(e,t,n,r){return t.bytes=n.bytes=0,{type:e,encode:t,decode:n,encodingLength:r}}},function(e,t,n){"use strict";const r=n(11);function s(e){const t=new r;function n(){t.abort();for(const t of e)t&&t.removeEventListener&&t.removeEventListener("abort",n)}for(const r of e)if(r&&r.addEventListener){if(r.aborted){n();break}r.addEventListener("abort",n)}return t.signal}e.exports=s,e.exports.anySignal=s},function(e,t,n){"use strict";const r=n(237),s=n(52),{File:i,FormData:o}=n(92);e.exports=async function(e="",t,n={}){const a=[],c=new o;let u=0,l=0;for await(const{content:o,path:f,mode:h,mtime:d}of r(e)){let e="";u>0&&(e="-"+u);let t=(o?"file":"dir")+e;const n=[];if(null!=h&&n.push("mode="+s(h)),null!=d){const{secs:e,nsecs:t}=d;n.push("mtime="+e),null!=t&&n.push("mtime-nsecs="+t)}if(n.length&&(t=`${t}?${n.join("&")}`),o){c.set(t,o,encodeURIComponent(f));const e=l+o.size;a.push({name:f,start:l,end:e}),l=e}else c.set(t,new i([""],encodeURIComponent(f),{type:"application/x-directory"}));u++}return{total:l,parts:a,headers:n,body:c}}},function(e,t,n){"use strict";(t=e.exports=n(64)).Stream=t,t.Readable=t,t.Writable=n(69),t.Duplex=n(24),t.Transform=n(70),t.PassThrough=n(145),t.finished=n(41),t.pipeline=n(146)},function(e,t,n){"use strict";e.exports={encode:n(297),decode:n(298),encodingLength:n(299)}},function(e,t,n){"use strict";var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(s){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,n){"use strict";const r=n(77),s=n(184),i=n(185),o=n(78),a=n(21);const c=n(186),u=n(187);e.exports={addPrefix:function(e,t){let n;if(e instanceof Uint8Array)n=o.varintUint8ArrayEncode(e);else{if(!i[e])throw new Error("multicodec not recognized");n=i[e]}return a([n,t],n.length+t.length)},rmPrefix:function(e){return r.decode(e),e.slice(r.decode.bytes)},getCodec:function(e){const t=r.decode(e),n=s.get(t);if(void 0===n)throw new Error(`Code ${t} not found`);return n},getName:function(e){return s.get(e)},getNumber:function(e){const t=i[e];if(void 0===t)throw new Error("Codec `"+e+"` not found");return r.decode(t)},getCode:function(e){return r.decode(e)},getCodeVarint:function(e){const t=i[e];if(void 0===t)throw new Error("Codec `"+e+"` not found");return t},getVarint:function(e){return r.encode(e)},print:u,...c}},function(e,t,n){"use strict";"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 n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}},function(e,t,n){"use strict";e.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var r=0;r<e.length;r++){var s=e.charAt(r),i=s.charCodeAt(0);if(255!==t[i])throw new TypeError(s+" is ambiguous");t[i]=r}var o=e.length,a=e.charAt(0),c=Math.log(o)/Math.log(256),u=Math.log(256)/Math.log(o);function l(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var n=0;if(" "!==e[n]){for(var r=0,s=0;e[n]===a;)r++,n++;for(var i=(e.length-n)*c+1>>>0,u=new Uint8Array(i);e[n];){var l=t[e.charCodeAt(n)];if(255===l)return;for(var f=0,h=i-1;(0!==l||f<s)&&-1!==h;h--,f++)l+=o*u[h]>>>0,u[h]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");s=f,n++}if(" "!==e[n]){for(var d=i-s;d!==i&&0===u[d];)d++;for(var p=new Uint8Array(r+(i-d)),b=r;d!==i;)p[b++]=u[d++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var n=0,r=0,s=0,i=t.length;s!==i&&0===t[s];)s++,n++;for(var c=(i-s)*u+1>>>0,l=new Uint8Array(c);s!==i;){for(var f=t[s],h=0,d=c-1;(0!==f||h<r)&&-1!==d;d--,h++)f+=256*l[d]>>>0,l[d]=f%o>>>0,f=f/o>>>0;if(0!==f)throw new Error("Non-zero carry");r=h,s++}for(var p=c-r;p!==c&&0===l[p];)p++;for(var b=a.repeat(n);p<c;++p)b+=e.charAt(l[p]);return b},decodeUnsafe:l,decode:function(e){var t=l(e);if(t)return t;throw new Error("Non-base"+o+" character")}}}},function(e,t,n){"use strict";e.exports=function(e,t){t||(t=e.reduce((e,t)=>e+t.length,0));const n=new Uint8Array(t);let r=0;for(const s of e)n.set(s,r),r+=s.length;return n}},function(e,t,n){"use strict";var r;!function(s){var i,o=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,a=Math.ceil,c=Math.floor,u="[BigNumber Error] ",l=u+"Number primitive has more than 15 significant digits: ",f=1e14,h=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],d=1e9;function p(e){var t=0|e;return e>0||e===t?t:t-1}function b(e){for(var t,n,r=1,s=e.length,i=e[0]+"";r<s;){for(n=14-(t=e[r++]+"").length;n--;t="0"+t);i+=t}for(s=i.length;48===i.charCodeAt(--s););return i.slice(0,s+1||1)}function g(e,t){var n,r,s=e.c,i=t.c,o=e.s,a=t.s,c=e.e,u=t.e;if(!o||!a)return null;if(n=s&&!s[0],r=i&&!i[0],n||r)return n?r?0:-a:o;if(o!=a)return o;if(n=o<0,r=c==u,!s||!i)return r?0:!s^n?1:-1;if(!r)return c>u^n?1:-1;for(a=(c=s.length)<(u=i.length)?c:u,o=0;o<a;o++)if(s[o]!=i[o])return s[o]>i[o]^n?1:-1;return c==u?0:c>u^n?1:-1}function m(e,t,n,r){if(e<t||e>n||e!==c(e))throw Error(u+(r||"Argument")+("number"==typeof e?e<t||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function y(e){var t=e.c.length-1;return p(e.e/14)==t&&e.c[t]%2!=0}function k(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function w(e,t,n){var r,s;if(t<0){for(s=n+".";++t;s+=n);e=s+e}else if(++t>(r=e.length)){for(s=n,t-=r;--t;s+=n);e+=s}else t<r&&(e=e.slice(0,t)+"."+e.slice(t));return e}(i=function e(t){var n,r,s,i,v,E,_,S,x,A=B.prototype={constructor:B,toString:null,valueOf:null},O=new B(1),T=20,N=4,I=-7,R=21,P=-1e7,C=1e7,L=!1,D=1,U=0,j={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},M="0123456789abcdefghijklmnopqrstuvwxyz";function B(e,t){var n,i,a,u,f,h,d,p,b=this;if(!(b instanceof B))return new B(e,t);if(null==t){if(e&&!0===e._isBigNumber)return b.s=e.s,void(!e.c||e.e>C?b.c=b.e=null:e.e<P?b.c=[b.e=0]:(b.e=e.e,b.c=e.c.slice()));if((h="number"==typeof e)&&0*e==0){if(b.s=1/e<0?(e=-e,-1):1,e===~~e){for(u=0,f=e;f>=10;f/=10,u++);return void(u>C?b.c=b.e=null:(b.e=u,b.c=[e]))}p=String(e)}else{if(!o.test(p=String(e)))return s(b,p,h);b.s=45==p.charCodeAt(0)?(p=p.slice(1),-1):1}(u=p.indexOf("."))>-1&&(p=p.replace(".","")),(f=p.search(/e/i))>0?(u<0&&(u=f),u+=+p.slice(f+1),p=p.substring(0,f)):u<0&&(u=p.length)}else{if(m(t,2,M.length,"Base"),10==t)return G(b=new B(e),T+b.e+1,N);if(p=String(e),h="number"==typeof e){if(0*e!=0)return s(b,p,h,t);if(b.s=1/e<0?(p=p.slice(1),-1):1,B.DEBUG&&p.replace(/^0\.0*|\./,"").length>15)throw Error(l+e)}else b.s=45===p.charCodeAt(0)?(p=p.slice(1),-1):1;for(n=M.slice(0,t),u=f=0,d=p.length;f<d;f++)if(n.indexOf(i=p.charAt(f))<0){if("."==i){if(f>u){u=d;continue}}else if(!a&&(p==p.toUpperCase()&&(p=p.toLowerCase())||p==p.toLowerCase()&&(p=p.toUpperCase()))){a=!0,f=-1,u=0;continue}return s(b,String(e),h,t)}h=!1,(u=(p=r(p,t,10,b.s)).indexOf("."))>-1?p=p.replace(".",""):u=p.length}for(f=0;48===p.charCodeAt(f);f++);for(d=p.length;48===p.charCodeAt(--d););if(p=p.slice(f,++d)){if(d-=f,h&&B.DEBUG&&d>15&&(e>9007199254740991||e!==c(e)))throw Error(l+b.s*e);if((u=u-f-1)>C)b.c=b.e=null;else if(u<P)b.c=[b.e=0];else{if(b.e=u,b.c=[],f=(u+1)%14,u<0&&(f+=14),f<d){for(f&&b.c.push(+p.slice(0,f)),d-=14;f<d;)b.c.push(+p.slice(f,f+=14));f=14-(p=p.slice(f)).length}else f-=d;for(;f--;p+="0");b.c.push(+p)}}else b.c=[b.e=0]}function F(e,t,n,r){var s,i,o,a,c;if(null==n?n=N:m(n,0,8),!e.c)return e.toString();if(s=e.c[0],o=e.e,null==t)c=b(e.c),c=1==r||2==r&&(o<=I||o>=R)?k(c,o):w(c,o,"0");else if(i=(e=G(new B(e),t,n)).e,a=(c=b(e.c)).length,1==r||2==r&&(t<=i||i<=I)){for(;a<t;c+="0",a++);c=k(c,i)}else if(t-=o,c=w(c,i,"0"),i+1>a){if(--t>0)for(c+=".";t--;c+="0");}else if((t+=i-a)>0)for(i+1==a&&(c+=".");t--;c+="0");return e.s<0&&s?"-"+c:c}function z(e,t){for(var n,r=1,s=new B(e[0]);r<e.length;r++){if(!(n=new B(e[r])).s){s=n;break}t.call(s,n)&&(s=n)}return s}function H(e,t,n){for(var r=1,s=t.length;!t[--s];t.pop());for(s=t[0];s>=10;s/=10,r++);return(n=r+14*n-1)>C?e.c=e.e=null:n<P?e.c=[e.e=0]:(e.e=n,e.c=t),e}function G(e,t,n,r){var s,i,o,u,l,d,p,b=e.c,g=h;if(b){e:{for(s=1,u=b[0];u>=10;u/=10,s++);if((i=t-s)<0)i+=14,o=t,p=(l=b[d=0])/g[s-o-1]%10|0;else if((d=a((i+1)/14))>=b.length){if(!r)break e;for(;b.length<=d;b.push(0));l=p=0,s=1,o=(i%=14)-14+1}else{for(l=u=b[d],s=1;u>=10;u/=10,s++);p=(o=(i%=14)-14+s)<0?0:l/g[s-o-1]%10|0}if(r=r||t<0||null!=b[d+1]||(o<0?l:l%g[s-o-1]),r=n<4?(p||r)&&(0==n||n==(e.s<0?3:2)):p>5||5==p&&(4==n||r||6==n&&(i>0?o>0?l/g[s-o]:0:b[d-1])%10&1||n==(e.s<0?8:7)),t<1||!b[0])return b.length=0,r?(t-=e.e+1,b[0]=g[(14-t%14)%14],e.e=-t||0):b[0]=e.e=0,e;if(0==i?(b.length=d,u=1,d--):(b.length=d+1,u=g[14-i],b[d]=o>0?c(l/g[s-o]%g[o])*u:0),r)for(;;){if(0==d){for(i=1,o=b[0];o>=10;o/=10,i++);for(o=b[0]+=u,u=1;o>=10;o/=10,u++);i!=u&&(e.e++,b[0]==f&&(b[0]=1));break}if(b[d]+=u,b[d]!=f)break;b[d--]=0,u=1}for(i=b.length;0===b[--i];b.pop());}e.e>C?e.c=e.e=null:e.e<P&&(e.c=[e.e=0])}return e}function V(e){var t,n=e.e;return null===n?e.toString():(t=b(e.c),t=n<=I||n>=R?k(t,n):w(t,n,"0"),e.s<0?"-"+t:t)}return B.clone=e,B.ROUND_UP=0,B.ROUND_DOWN=1,B.ROUND_CEIL=2,B.ROUND_FLOOR=3,B.ROUND_HALF_UP=4,B.ROUND_HALF_DOWN=5,B.ROUND_HALF_EVEN=6,B.ROUND_HALF_CEIL=7,B.ROUND_HALF_FLOOR=8,B.EUCLID=9,B.config=B.set=function(e){var t,n;if(null!=e){if("object"!=typeof e)throw Error(u+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(m(n=e[t],0,d,t),T=n),e.hasOwnProperty(t="ROUNDING_MODE")&&(m(n=e[t],0,8,t),N=n),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((n=e[t])&&n.pop?(m(n[0],-d,0,t),m(n[1],0,d,t),I=n[0],R=n[1]):(m(n,-d,d,t),I=-(R=n<0?-n:n))),e.hasOwnProperty(t="RANGE"))if((n=e[t])&&n.pop)m(n[0],-d,-1,t),m(n[1],1,d,t),P=n[0],C=n[1];else{if(m(n,-d,d,t),!n)throw Error(u+t+" cannot be zero: "+n);P=-(C=n<0?-n:n)}if(e.hasOwnProperty(t="CRYPTO")){if((n=e[t])!==!!n)throw Error(u+t+" not true or false: "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw L=!n,Error(u+"crypto unavailable");L=n}else L=n}if(e.hasOwnProperty(t="MODULO_MODE")&&(m(n=e[t],0,9,t),D=n),e.hasOwnProperty(t="POW_PRECISION")&&(m(n=e[t],0,d,t),U=n),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(n=e[t]))throw Error(u+t+" not an object: "+n);j=n}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(n=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(n))throw Error(u+t+" invalid: "+n);M=n}}return{DECIMAL_PLACES:T,ROUNDING_MODE:N,EXPONENTIAL_AT:[I,R],RANGE:[P,C],CRYPTO:L,MODULO_MODE:D,POW_PRECISION:U,FORMAT:j,ALPHABET:M}},B.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!B.DEBUG)return!0;var t,n,r=e.c,s=e.e,i=e.s;e:if("[object Array]"=={}.toString.call(r)){if((1===i||-1===i)&&s>=-d&&s<=d&&s===c(s)){if(0===r[0]){if(0===s&&1===r.length)return!0;break e}if((t=(s+1)%14)<1&&(t+=14),String(r[0]).length==t){for(t=0;t<r.length;t++)if((n=r[t])<0||n>=f||n!==c(n))break e;if(0!==n)return!0}}}else if(null===r&&null===s&&(null===i||1===i||-1===i))return!0;throw Error(u+"Invalid BigNumber: "+e)},B.maximum=B.max=function(){return z(arguments,A.lt)},B.minimum=B.min=function(){return z(arguments,A.gt)},B.random=(i=9007199254740992*Math.random()&2097151?function(){return c(9007199254740992*Math.random())}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,n,r,s,o,l=0,f=[],p=new B(O);if(null==e?e=T:m(e,0,d),s=a(e/14),L)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(s*=2));l<s;)(o=131072*t[l]+(t[l+1]>>>11))>=9e15?(n=crypto.getRandomValues(new Uint32Array(2)),t[l]=n[0],t[l+1]=n[1]):(f.push(o%1e14),l+=2);l=s/2}else{if(!crypto.randomBytes)throw L=!1,Error(u+"crypto unavailable");for(t=crypto.randomBytes(s*=7);l<s;)(o=281474976710656*(31&t[l])+1099511627776*t[l+1]+4294967296*t[l+2]+16777216*t[l+3]+(t[l+4]<<16)+(t[l+5]<<8)+t[l+6])>=9e15?crypto.randomBytes(7).copy(t,l):(f.push(o%1e14),l+=7);l=s/7}if(!L)for(;l<s;)(o=i())<9e15&&(f[l++]=o%1e14);for(e%=14,(s=f[--l])&&e&&(o=h[14-e],f[l]=c(s/o)*o);0===f[l];f.pop(),l--);if(l<0)f=[r=0];else{for(r=-1;0===f[0];f.splice(0,1),r-=14);for(l=1,o=f[0];o>=10;o/=10,l++);l<14&&(r-=14-l)}return p.e=r,p.c=f,p}),B.sum=function(){for(var e=1,t=arguments,n=new B(t[0]);e<t.length;)n=n.plus(t[e++]);return n},r=function(){function e(e,t,n,r){for(var s,i,o=[0],a=0,c=e.length;a<c;){for(i=o.length;i--;o[i]*=t);for(o[0]+=r.indexOf(e.charAt(a++)),s=0;s<o.length;s++)o[s]>n-1&&(null==o[s+1]&&(o[s+1]=0),o[s+1]+=o[s]/n|0,o[s]%=n)}return o.reverse()}return function(t,r,s,i,o){var a,c,u,l,f,h,d,p,g=t.indexOf("."),m=T,y=N;for(g>=0&&(l=U,U=0,t=t.replace(".",""),h=(p=new B(r)).pow(t.length-g),U=l,p.c=e(w(b(h.c),h.e,"0"),10,s,"0123456789"),p.e=p.c.length),u=l=(d=e(t,r,s,o?(a=M,"0123456789"):(a="0123456789",M))).length;0==d[--l];d.pop());if(!d[0])return a.charAt(0);if(g<0?--u:(h.c=d,h.e=u,h.s=i,d=(h=n(h,p,m,y,s)).c,f=h.r,u=h.e),g=d[c=u+m+1],l=s/2,f=f||c<0||null!=d[c+1],f=y<4?(null!=g||f)&&(0==y||y==(h.s<0?3:2)):g>l||g==l&&(4==y||f||6==y&&1&d[c-1]||y==(h.s<0?8:7)),c<1||!d[0])t=f?w(a.charAt(1),-m,a.charAt(0)):a.charAt(0);else{if(d.length=c,f)for(--s;++d[--c]>s;)d[c]=0,c||(++u,d=[1].concat(d));for(l=d.length;!d[--l];);for(g=0,t="";g<=l;t+=a.charAt(d[g++]));t=w(t,u,a.charAt(0))}return t}}(),n=function(){function e(e,t,n){var r,s,i,o,a=0,c=e.length,u=t%1e7,l=t/1e7|0;for(e=e.slice();c--;)a=((s=u*(i=e[c]%1e7)+(r=l*i+(o=e[c]/1e7|0)*u)%1e7*1e7+a)/n|0)+(r/1e7|0)+l*o,e[c]=s%n;return a&&(e=[a].concat(e)),e}function t(e,t,n,r){var s,i;if(n!=r)i=n>r?1:-1;else for(s=i=0;s<n;s++)if(e[s]!=t[s]){i=e[s]>t[s]?1:-1;break}return i}function n(e,t,n,r){for(var s=0;n--;)e[n]-=s,s=e[n]<t[n]?1:0,e[n]=s*r+e[n]-t[n];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(r,s,i,o,a){var u,l,h,d,b,g,m,y,k,w,v,E,_,S,x,A,O,T=r.s==s.s?1:-1,N=r.c,I=s.c;if(!(N&&N[0]&&I&&I[0]))return new B(r.s&&s.s&&(N?!I||N[0]!=I[0]:I)?N&&0==N[0]||!I?0*T:T/0:NaN);for(k=(y=new B(T)).c=[],T=i+(l=r.e-s.e)+1,a||(a=f,l=p(r.e/14)-p(s.e/14),T=T/14|0),h=0;I[h]==(N[h]||0);h++);if(I[h]>(N[h]||0)&&l--,T<0)k.push(1),d=!0;else{for(S=N.length,A=I.length,h=0,T+=2,(b=c(a/(I[0]+1)))>1&&(I=e(I,b,a),N=e(N,b,a),A=I.length,S=N.length),_=A,v=(w=N.slice(0,A)).length;v<A;w[v++]=0);O=I.slice(),O=[0].concat(O),x=I[0],I[1]>=a/2&&x++;do{if(b=0,(u=t(I,w,A,v))<0){if(E=w[0],A!=v&&(E=E*a+(w[1]||0)),(b=c(E/x))>1)for(b>=a&&(b=a-1),m=(g=e(I,b,a)).length,v=w.length;1==t(g,w,m,v);)b--,n(g,A<m?O:I,m,a),m=g.length,u=1;else 0==b&&(u=b=1),m=(g=I.slice()).length;if(m<v&&(g=[0].concat(g)),n(w,g,v,a),v=w.length,-1==u)for(;t(I,w,A,v)<1;)b++,n(w,A<v?O:I,v,a),v=w.length}else 0===u&&(b++,w=[0]);k[h++]=b,w[0]?w[v++]=N[_]||0:(w=[N[_]],v=1)}while((_++<S||null!=w[0])&&T--);d=null!=w[0],k[0]||k.splice(0,1)}if(a==f){for(h=1,T=k[0];T>=10;T/=10,h++);G(y,i+(y.e=h+14*l-1)+1,o,d)}else y.e=l,y.r=+d;return y}}(),v=/^(-?)0([xbo])(?=\w[\w.]*$)/i,E=/^([^.]+)\.$/,_=/^\.([^.]+)$/,S=/^-?(Infinity|NaN)$/,x=/^\s*\+(?=[\w.])|^\s+|\s+$/g,s=function(e,t,n,r){var s,i=n?t:t.replace(x,"");if(S.test(i))e.s=isNaN(i)?null:i<0?-1:1;else{if(!n&&(i=i.replace(v,(function(e,t,n){return s="x"==(n=n.toLowerCase())?16:"b"==n?2:8,r&&r!=s?e:t})),r&&(s=r,i=i.replace(E,"$1").replace(_,"0.$1")),t!=i))return new B(i,s);if(B.DEBUG)throw Error(u+"Not a"+(r?" base "+r:"")+" number: "+t);e.s=null}e.c=e.e=null},A.absoluteValue=A.abs=function(){var e=new B(this);return e.s<0&&(e.s=1),e},A.comparedTo=function(e,t){return g(this,new B(e,t))},A.decimalPlaces=A.dp=function(e,t){var n,r,s,i=this;if(null!=e)return m(e,0,d),null==t?t=N:m(t,0,8),G(new B(i),e+i.e+1,t);if(!(n=i.c))return null;if(r=14*((s=n.length-1)-p(this.e/14)),s=n[s])for(;s%10==0;s/=10,r--);return r<0&&(r=0),r},A.dividedBy=A.div=function(e,t){return n(this,new B(e,t),T,N)},A.dividedToIntegerBy=A.idiv=function(e,t){return n(this,new B(e,t),0,1)},A.exponentiatedBy=A.pow=function(e,t){var n,r,s,i,o,l,f,h,d=this;if((e=new B(e)).c&&!e.isInteger())throw Error(u+"Exponent not an integer: "+V(e));if(null!=t&&(t=new B(t)),o=e.e>14,!d.c||!d.c[0]||1==d.c[0]&&!d.e&&1==d.c.length||!e.c||!e.c[0])retur