mirror of
https://github.com/ThaUnknown/miru.git
synced 2026-04-20 23:42:05 +00:00
1 line
No EOL
40 KiB
JavaScript
1 line
No EOL
40 KiB
JavaScript
!function(){var t,e,r,n=(t=function(t,r){(function(t){(function(){"use strict";function t(t){if(t>2147483647)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=n.prototype,e}function n(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return u(t)}return o(t,e,r)}function o(e,r,o){if("string"==typeof e)return function(e,r){if("string"==typeof r&&""!==r||(r="utf8"),!n.isEncoding(r))throw new TypeError("Unknown encoding: "+r);var o=0|a(e,r),i=t(o),u=i.write(e,r);return u!==o&&(i=i.slice(0,u)),i}(e,r);if(ArrayBuffer.isView(e))return s(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(j(e,ArrayBuffer)||e&&j(e.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');var o;return(o=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r)).__proto__=n.prototype,o}(e,r,o);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var i=e.valueOf&&e.valueOf();if(null!=i&&i!==e)return n.from(i,r,o);var u=function(e){if(n.isBuffer(e)){var r=0|f(e.length),o=t(r);return 0===o.length||e.copy(o,0,0,r),o}return void 0!==e.length?"number"!=typeof e.length||M(e.length)?t(0):s(e):"Buffer"===e.type&&Array.isArray(e.data)?s(e.data):void 0}(e);if(u)return u;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return n.from(e[Symbol.toPrimitive]("string"),r,o);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function i(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function u(e){return i(e),t(e<0?0:0|f(e))}function s(e){for(var r=e.length<0?0:0|f(e.length),n=t(r),o=0;o<r;o+=1)n[o]=255&e[o];return n}function f(t){if(t>=2147483647)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+2147483647..toString(16)+" bytes");return 0|t}function a(t,e){if(n.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||j(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,o=arguments.length>2&&!0===arguments[2];if(!o&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return O(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return I(t).length;default:if(i)return o?-1:O(t).length;e=(""+e).toLowerCase(),i=!0}}function h(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function c(t,e,r,o,i){if(0===t.length)return-1;if("string"==typeof r?(o=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),M(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=n.from(e,o)),n.isBuffer(e))return 0===e.length?-1:l(t,e,r,o,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):l(t,[e],r,o,i);throw new TypeError("val must be string, number or Buffer")}function l(t,e,r,n,o){var i,u=1,s=t.length,f=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;u=2,s/=2,f/=2,r/=2}function a(t,e){return 1===u?t[e]:t.readUInt16BE(e*u)}if(o){var h=-1;for(i=r;i<s;i++)if(a(t,i)===a(e,-1===h?0:i-h)){if(-1===h&&(h=i),i-h+1===f)return h*u}else-1!==h&&(i-=i-h),h=-1}else for(r+f>s&&(r=s-f),i=r;i>=0;i--){for(var c=!0,l=0;l<f;l++)if(a(t,i+l)!==a(e,l)){c=!1;break}if(c)return i}return-1}function p(t,e,r,n){r=Number(r)||0;var o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var u=0;u<n;++u){var s=parseInt(e.substr(2*u,2),16);if(M(s))return u;t[r+u]=s}return u}function y(t,e,r,n){return U(O(e,t.length-r),t,r,n)}function g(t,e,r,n){return U(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function d(t,e,r,n){return g(t,e,r,n)}function v(t,e,r,n){return U(I(e),t,r,n)}function w(t,e,r,n){return U(function(t,e){for(var r,n,o,i=[],u=0;u<t.length&&!((e-=2)<0);++u)n=(r=t.charCodeAt(u))>>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function m(t,e,r){return 0===e&&r===t.length?z.fromByteArray(t):z.fromByteArray(t.slice(e,r))}function b(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o<r;){var i,u,s,f,a=t[o],h=null,c=a>239?4:a>223?3:a>191?2:1;if(o+c<=r)switch(c){case 1:a<128&&(h=a);break;case 2:128==(192&(i=t[o+1]))&&(f=(31&a)<<6|63&i)>127&&(h=f);break;case 3:i=t[o+1],u=t[o+2],128==(192&i)&&128==(192&u)&&(f=(15&a)<<12|(63&i)<<6|63&u)>2047&&(f<55296||f>57343)&&(h=f);break;case 4:i=t[o+1],u=t[o+2],s=t[o+3],128==(192&i)&&128==(192&u)&&128==(192&s)&&(f=(15&a)<<18|(63&i)<<12|(63&u)<<6|63&s)>65535&&f<1114112&&(h=f)}null===h?(h=65533,c=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var e=t.length;if(e<=_)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=_));return r}(n)}r.Buffer=n,r.INSPECT_MAX_BYTES=50,n.TYPED_ARRAY_SUPPORT=function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()}catch(e){return!1}}(),n.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(n.prototype,"parent",{enumerable:!0,get:function(){if(n.isBuffer(this))return this.buffer}}),Object.defineProperty(n.prototype,"offset",{enumerable:!0,get:function(){if(n.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&n[Symbol.species]===n&&Object.defineProperty(n,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),n.poolSize=8192,n.from=function(t,e,r){return o(t,e,r)},n.prototype.__proto__=Uint8Array.prototype,n.__proto__=Uint8Array,n.alloc=function(e,r,n){return function(e,r,n){return i(e),e<=0?t(e):void 0!==r?"string"==typeof n?t(e).fill(r,n):t(e).fill(r):t(e)}(e,r,n)},n.allocUnsafe=function(t){return u(t)},n.allocUnsafeSlow=function(t){return u(t)},n.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==n.prototype},n.compare=function(t,e){if(j(t,Uint8Array)&&(t=n.from(t,t.offset,t.byteLength)),j(e,Uint8Array)&&(e=n.from(e,e.offset,e.byteLength)),!n.isBuffer(t)||!n.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var r=t.length,o=e.length,i=0,u=Math.min(r,o);i<u;++i)if(t[i]!==e[i]){r=t[i],o=e[i];break}return r<o?-1:o<r?1:0},n.isEncoding=function(t){switch(String(t).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}},n.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return n.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var o=n.allocUnsafe(e),i=0;for(r=0;r<t.length;++r){var u=t[r];if(j(u,Uint8Array)&&(u=n.from(u)),!n.isBuffer(u))throw new TypeError('"list" argument must be an Array of Buffers');u.copy(o,i),i+=u.length}return o},n.byteLength=a,n.prototype._isBuffer=!0,n.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)h(this,e,e+1);return this},n.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)h(this,e,e+3),h(this,e+1,e+2);return this},n.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)h(this,e,e+7),h(this,e+1,e+6),h(this,e+2,e+5),h(this,e+3,e+4);return this},n.prototype.toString=function(){var t=this.length;return 0===t?"":0===arguments.length?b(this,0,t):function(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return L(this,e,r);case"utf8":case"utf-8":return b(this,e,r);case"ascii":return E(this,e,r);case"latin1":case"binary":return A(this,e,r);case"base64":return m(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},n.prototype.toLocaleString=n.prototype.toString,n.prototype.equals=function(t){if(!n.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===n.compare(this,t)},n.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"},n.prototype.compare=function(t,e,r,o,i){if(j(t,Uint8Array)&&(t=n.from(t,t.offset,t.byteLength)),!n.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===o&&(o=0),void 0===i&&(i=this.length),e<0||r>t.length||o<0||i>this.length)throw new RangeError("out of range index");if(o>=i&&e>=r)return 0;if(o>=i)return-1;if(e>=r)return 1;if(this===t)return 0;for(var u=(i>>>=0)-(o>>>=0),s=(r>>>=0)-(e>>>=0),f=Math.min(u,s),a=this.slice(o,i),h=t.slice(e,r),c=0;c<f;++c)if(a[c]!==h[c]){u=a[c],s=h[c];break}return u<s?-1:s<u?1:0},n.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},n.prototype.indexOf=function(t,e,r){return c(this,t,e,r,!0)},n.prototype.lastIndexOf=function(t,e,r){return c(this,t,e,r,!1)},n.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return p(this,t,e,r);case"utf8":case"utf-8":return y(this,t,e,r);case"ascii":return g(this,t,e,r);case"latin1":case"binary":return d(this,t,e,r);case"base64":return v(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},n.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var _=4096;function E(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(127&t[o]);return n}function A(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function L(t,e,r){var n,o=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>o)&&(r=o);for(var i="",u=e;u<r;++u)i+=(n=t[u])<16?"0"+n.toString(16):n.toString(16);return i}function B(t,e,r){for(var n=t.slice(e,r),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function T(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function S(t,e,r,o,i,u){if(!n.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<u)throw new RangeError('"value" argument is out of bounds');if(r+o>t.length)throw new RangeError("Index out of range")}function k(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function C(t,e,r,n,o){return e=+e,r>>>=0,o||k(t,0,r,4),J.write(t,e,r,n,23,4),r+4}function P(t,e,r,n,o){return e=+e,r>>>=0,o||k(t,0,r,8),J.write(t,e,r,n,52,8),r+8}n.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);var o=this.subarray(t,e);return o.__proto__=n.prototype,o},n.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n},n.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},n.prototype.readUInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),this[t]},n.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},n.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},n.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},n.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},n.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*e)),n},n.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},n.prototype.readInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},n.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},n.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},n.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},n.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},n.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),J.read(this,t,!0,23,4)},n.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),J.read(this,t,!1,23,4)},n.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),J.read(this,t,!0,52,8)},n.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),J.read(this,t,!1,52,8)},n.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||S(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&255;return e+r},n.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||S(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},n.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,1,255,0),this[e]=255&t,e+1},n.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},n.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},n.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},n.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},n.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);S(this,t,e,r,o-1,-o)}var i=0,u=1,s=0;for(this[e]=255&t;++i<r&&(u*=256);)t<0&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/u>>0)-s&255;return e+r},n.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);S(this,t,e,r,o-1,-o)}var i=r-1,u=1,s=0;for(this[e+i]=255&t;--i>=0&&(u*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/u>>0)-s&255;return e+r},n.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},n.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},n.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},n.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},n.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},n.prototype.writeFloatLE=function(t,e,r){return C(this,t,e,!0,r)},n.prototype.writeFloatBE=function(t,e,r){return C(this,t,e,!1,r)},n.prototype.writeDoubleLE=function(t,e,r){return P(this,t,e,!0,r)},n.prototype.writeDoubleBE=function(t,e,r){return P(this,t,e,!1,r)},n.prototype.copy=function(t,e,r,o){if(!n.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),o||0===o||(o=this.length),e>=t.length&&(e=t.length),e||(e=0),o>0&&o<r&&(o=r),o===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),t.length-e<o-r&&(o=t.length-e+r);var i=o-r;if(this===t&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(e,r,o);else if(this===t&&r<e&&e<o)for(var u=i-1;u>=0;--u)t[u+e]=this[u+r];else Uint8Array.prototype.set.call(t,this.subarray(r,o),e);return i},n.prototype.fill=function(t,e,r,o){if("string"==typeof t){if("string"==typeof e?(o=e,e=0,r=this.length):"string"==typeof r&&(o=r,r=this.length),void 0!==o&&"string"!=typeof o)throw new TypeError("encoding must be a string");if("string"==typeof o&&!n.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(1===t.length){var i=t.charCodeAt(0);("utf8"===o&&i<128||"latin1"===o)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var u;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(u=e;u<r;++u)this[u]=t;else{var s=n.isBuffer(t)?t:n.from(t,o),f=s.length;if(0===f)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(u=0;u<r-e;++u)this[u+e]=s[u%f]}return this};var x=/[^+/0-9A-Za-z-_]/g;function O(t,e){var r;e=e||1/0;for(var n=t.length,o=null,i=[],u=0;u<n;++u){if((r=t.charCodeAt(u))>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(u+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function I(t){return z.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(x,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function U(t,e,r,n){for(var o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function j(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function M(t){return t!=t}}).call(this)}).call(this,n({}).Buffer)},function(r){return e||t(e={exports:{},parent:r},e.exports),e.exports}),o={},i="object"==typeof Reflect?Reflect:null,u=i&&"function"==typeof i.apply?i.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};r=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var s=Number.isNaN||function(t){return t!=t};function f(){f.init.call(this)}(o=f).once=function(t,e){return new Promise((function(r,n){function o(){void 0!==i&&t.removeListener("error",i),r([].slice.call(arguments))}var i;"error"!==e&&(i=function(r){t.removeListener(e,o),n(r)},t.once("error",i)),t.once(e,o)}))},f.EventEmitter=f,f.prototype._events=void 0,f.prototype._eventsCount=0,f.prototype._maxListeners=void 0;var a=10;function h(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function c(t){return void 0===t._maxListeners?f.defaultMaxListeners:t._maxListeners}function l(t,e,r,n){var o,i,u,s;if(h(r),void 0===(i=t._events)?(i=t._events=Object.create(null),t._eventsCount=0):(void 0!==i.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),i=t._events),u=i[e]),void 0===u)u=i[e]=r,++t._eventsCount;else if("function"==typeof u?u=i[e]=n?[r,u]:[u,r]:n?u.unshift(r):u.push(r),(o=c(t))>0&&u.length>o&&!u.warned){u.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+u.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=t,f.type=e,f.count=u.length,s=f,console&&console.warn&&console.warn(s)}return t}function p(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},o=function(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}.bind(n);return o.listener=r,n.wrapFn=o,o}function y(t,e,r){var n=t._events;if(void 0===n)return[];var o=n[e];return void 0===o?[]:"function"==typeof o?r?[o.listener||o]:[o]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(o):d(o,o.length)}function g(t){var e=this._events;if(void 0!==e){var r=e[t];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function d(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}Object.defineProperty(f,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(t){if("number"!=typeof t||t<0||s(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");a=t}}),f.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},f.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||s(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},f.prototype.getMaxListeners=function(){return c(this)},f.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var n="error"===t,o=this._events;if(void 0!==o)n=n&&void 0===o.error;else if(!n)return!1;if(n){var i;if(e.length>0&&(i=e[0]),i instanceof Error)throw i;var s=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw s.context=i,s}var f=o[t];if(void 0===f)return!1;if("function"==typeof f)u(f,this,e);else{var a=f.length,h=d(f,a);for(r=0;r<a;++r)u(h[r],this,e)}return!0},f.prototype.addListener=function(t,e){return l(this,t,e,!1)},f.prototype.on=f.prototype.addListener,f.prototype.prependListener=function(t,e){return l(this,t,e,!0)},f.prototype.once=function(t,e){return h(e),this.on(t,p(this,t,e)),this},f.prototype.prependOnceListener=function(t,e){return h(e),this.prependListener(t,p(this,t,e)),this},f.prototype.removeListener=function(t,e){var r,n,o,i,u;if(h(e),void 0===(n=this._events))return this;if(void 0===(r=n[t]))return this;if(r===e||r.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete n[t],n.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(o=-1,i=r.length-1;i>=0;i--)if(r[i]===e||r[i].listener===e){u=r[i].listener,o=i;break}if(o<0)return this;0===o?r.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(r,o),1===r.length&&(n[t]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",t,u||e)}return this},f.prototype.off=f.prototype.removeListener,f.prototype.removeAllListeners=function(t){var e,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[t]),this;if(0===arguments.length){var o,i=Object.keys(r);for(n=0;n<i.length;++n)"removeListener"!==(o=i[n])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(void 0!==e)for(n=e.length-1;n>=0;n--)this.removeListener(t,e[n]);return this},f.prototype.listeners=function(t){return y(this,t,!0)},f.prototype.rawListeners=function(t){return y(this,t,!1)},f.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):g.call(t,e)},f.prototype.listenerCount=g,f.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]};var v={};v="function"==typeof Object.create?function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}};var w=function(t){var e,r,n;if(null!=t&&"function"!=typeof t)throw new Error("cb must be a function");function o(o,i){if(e)o?n(o):r(i);else if(t)t(o,i);else if(o)throw o}return null==t&&"undefined"!=typeof Promise&&(e=new Promise((function(t,e){r=t,n=e}))),o.promise=e,o},m=A,b=o.EventEmitter,_="undefined"==typeof window?self:window,E=_.indexedDB||_.mozIndexedDB||_.webkitIndexedDB||_.msIndexedDB;function A(t,e,r){var n=this;if("string"!=typeof t)throw new Error("A name must be supplied of type string");if(!E)throw new Error("IndexedDB not supported");if("function"==typeof e)return new A(t,null,e);if(!(n instanceof A))return new A(t,e,r);if(e||(e={}),b.call(n),n._db=null,n._closed=!1,n._channel=null,n._waiters=[],!0!==e.disableBroadcast){var o=e.channel||_.BroadcastChannel;o&&(n._channel=new o(t),n._channel.onmessage=function(t){"add"===t.data.method?n.emit("add",t.data):"set"===t.data.method?n.emit("set",t.data):"remove"===t.data.method&&n.emit("remove",t.data)})}var i=E.open(t);function u(t){B(t),n._close(t.target.error)}function s(){n._close()}i.onerror=function(t){B(t),n._close(t.target.error),r&&r(t.target.error)},i.onsuccess=function(t){if(n._closed)t.target.result.close();else{for(var e in n._db=t.target.result,n._db.onclose=s,n._db.onerror=u,n._waiters)n._waiters[e]._init(null);n._waiters=null,r&&r(null),n.emit("open")}},i.onupgradeneeded=function(t){t.target.result.createObjectStore("kv",{autoIncrement:!0})},n.on("newListener",(function(t){if("add"===t||"set"===t||"remove"===t)return n._channel?void 0:n.emit("error",new Error("No BroadcastChannel support"))}))}function L(t,e,r){if("function"==typeof e)return new L(t,null,e);if(this._kvStore=t,this._mode=e||"readwrite",this._objectStore=null,this._waiters=null,this.finished=!1,this.onfinish=w(r),this.done=this.onfinish.promise,"readonly"!==this._mode&&"readwrite"!==this._mode)throw new Error('mode must be either "readonly" or "readwrite"')}function B(t,e){if(null==e)return B(null,t);e.preventDefault(),e.stopPropagation(),t&&t(e.target.error)}A.INDEXEDDB_SUPPORT=null!=E,A.BROADCAST_SUPPORT=null!=_.BroadcastChannel,v(A,b),A.prototype.get=function(t,e){return this.transaction("readonly").get(t,e)},A.prototype.getMultiple=function(t,e){return this.transaction("readonly").getMultiple(t,e)},A.prototype.set=function(t,e,r){r=w(r);var n=null;return this.transaction("readwrite",(function(t){r(n=n||t)})).set(t,e,(function(t){n=t})),r.promise},A.prototype.json=function(t,e){return this.transaction("readonly").json(t,e)},A.prototype.keys=function(t,e){return this.transaction("readonly").keys(t,e)},A.prototype.values=function(t,e){return this.transaction("readonly").values(t,e)},A.prototype.remove=function(t,e){e=w(e);var r=null;return this.transaction("readwrite",(function(t){e(r=r||t)})).remove(t,(function(t){r=t})),e.promise},A.prototype.clear=function(t){t=w(t);var e=null;return this.transaction("readwrite",(function(r){t(e=e||r)})).clear((function(t){e=t})),t.promise},A.prototype.count=function(t,e){return this.transaction("readonly").count(t,e)},A.prototype.add=function(t,e,r){r=w(r);var n=null;return this.transaction("readwrite",(function(t){r(n=n||t)})).add(t,e,(function(t){n=t})),r.promise},A.prototype.iterator=function(t,e){return this.transaction("readonly").iterator(t,e)},A.prototype.transaction=function(t,e){if(this._closed)throw new Error("Database is closed");var r=new L(this,t,e);return this._db?r._init(null):this._waiters.push(r),r},A.prototype.close=function(){this._close()},A.prototype._close=function(t){if(!this._closed){for(var e in this._closed=!0,this._db&&this._db.close(),this._channel&&this._channel.close(),this._db=null,this._channel=null,t&&this.emit("error",t),this.emit("close"),this._waiters)this._waiters[e]._init(t||new Error("Database is closed"));this._waiters=null,this.removeAllListeners()}},L.prototype._init=function(t){var e=this;if(!e.finished){if(t)return e._close(t);var r=e._kvStore._db.transaction("kv",e._mode);for(var n in r.oncomplete=function(){e._close(null)},r.onerror=o,r.onabort=o,e._objectStore=r.objectStore("kv"),e._waiters)e._waiters[n](null,e._objectStore);e._waiters=null}function o(t){B(t),e._close(t.target.error)}},L.prototype._getObjectStore=function(t){if(this.finished)throw new Error("Transaction is finished");if(this._objectStore)return t(null,this._objectStore);this._waiters=this._waiters||[],this._waiters.push(t)},L.prototype.set=function(t,r,n){var o=this;if(null==t||null==r)throw new Error("A key and value must be given");return n=w(n),o._getObjectStore((function(i,u){if(i)return n(i);try{var s=u.put(r,t)}catch(e){return n(e)}s.onerror=B.bind(this,n),s.onsuccess=function(){o._kvStore._channel&&o._kvStore._channel.postMessage({method:"set",key:t,value:r}),n(null)}})),n.promise},L.prototype.add=function(t,r,n){var o=this;if(null==r&&null!=t)return o.add(void 0,t,n);if("function"==typeof r||null==r&&null==n)return o.add(void 0,t,r);if(null==r)throw new Error("A value must be provided as an argument");return n=w(n),o._getObjectStore((function(i,u){if(i)return n(i);try{var s=null==t?u.add(r):u.add(r,t)}catch(e){return n(e)}s.onerror=B.bind(this,n),s.onsuccess=function(){o._kvStore._channel&&o._kvStore._channel.postMessage({method:"add",key:t,value:r}),n(null)}})),n.promise},L.prototype.get=function(t,r){if(null==t)throw new Error("A key must be given as an argument");return r=w(r),this._getObjectStore((function(n,o){if(n)return r(n);try{var i=o.get(t)}catch(e){return r(e)}i.onerror=B.bind(this,r),i.onsuccess=function(t){r(null,t.target.result)}})),r.promise},L.prototype.getMultiple=function(t,e){if(null==t)throw new Error("An array of keys must be given as an argument");return e=w(e),0===t.length?(e(null,[]),e.promise):(this._getObjectStore((function(r,n){if(r)return e(r);var o=t.slice().sort(),i=0,u={},s=function(){return t.map((function(t){return u[t]}))},f=n.openCursor();f.onerror=B.bind(this,e),f.onsuccess=function(t){var r=t.target.result;if(r){for(var n=r.key;n>o[i];)if(++i===o.length)return void e(null,s());n===o[i]?(u[n]=r.value,r.continue()):r.continue(o[i])}else e(null,s())}})),e.promise)},L.prototype.json=function(t,e){if("function"==typeof t)return this.json(null,t);e=w(e);var r={};return this.iterator(t,(function(t,n){if(t)return e(t);n?(r[n.key]=n.value,n.continue()):e(null,r)})),e.promise},L.prototype.keys=function(t,e){if("function"==typeof t)return this.keys(null,t);e=w(e);var r=[];return this.iterator(t,(function(t,n){if(t)return e(t);n?(r.push(n.key),n.continue()):e(null,r)})),e.promise},L.prototype.values=function(t,e){if("function"==typeof t)return this.values(null,t);e=w(e);var r=[];return this.iterator(t,(function(t,n){if(t)return e(t);n?(r.push(n.value),n.continue()):e(null,r)})),e.promise},L.prototype.remove=function(t,r){var n=this;if(null==t)throw new Error("A key must be given as an argument");return r=w(r),n._getObjectStore((function(o,i){if(o)return r(o);try{var u=i.delete(t)}catch(e){return r(e)}u.onerror=B.bind(this,r),u.onsuccess=function(){n._kvStore._channel&&n._kvStore._channel.postMessage({method:"remove",key:t}),r(null)}})),r.promise},L.prototype.clear=function(t){return t=w(t),this._getObjectStore((function(r,n){if(r)return t(r);try{var o=n.clear()}catch(e){return t(e)}o.onerror=B.bind(this,t),o.onsuccess=function(){t(null)}})),t.promise},L.prototype.count=function(t,r){return"function"==typeof t?this.count(null,t):(r=w(r),this._getObjectStore((function(n,o){if(n)return r(n);try{var i=null==t?o.count():o.count(t)}catch(e){return r(e)}i.onerror=B.bind(this,r),i.onsuccess=function(t){r(null,t.target.result)}})),r.promise)},L.prototype.iterator=function(t,r){if("function"==typeof t)return this.iterator(null,t);if("function"!=typeof r)throw new Error("A function must be given");this._getObjectStore((function(n,o){if(n)return r(n);try{var i=null==t?o.openCursor():o.openCursor(t)}catch(e){return r(e)}i.onerror=B.bind(this,r),i.onsuccess=function(t){var e=t.target.result;r(null,e)}}))},L.prototype.abort=function(){if(this.finished)throw new Error("Transaction is finished");this._objectStore&&this._objectStore.transaction.abort(),this._close(new Error("Transaction aborted"))},L.prototype._close=function(t){if(!this.finished){for(var e in this.finished=!0,this._kvStore=null,this._objectStore=null,this._waiters)this._waiters[e](t||new Error("Transaction is finished"));this._waiters=null,this.onfinish&&this.onfinish(t),this.onfinish=null}};var T,S,k,C=T={};function P(){throw new Error("setTimeout has not been defined")}function x(){throw new Error("clearTimeout has not been defined")}function O(t){if(S===setTimeout)return setTimeout(t,0);if((S===P||!S)&&setTimeout)return S=setTimeout,setTimeout(t,0);try{return S(t,0)}catch(e){try{return S.call(null,t,0)}catch(e){return S.call(this,t,0)}}}!function(){try{S="function"==typeof setTimeout?setTimeout:P}catch(e){S=P}try{k="function"==typeof clearTimeout?clearTimeout:x}catch(e){k=x}}();var I,U=[],j=!1,M=-1;function R(){j&&I&&(j=!1,I.length?U=I.concat(U):M=-1,U.length&&D())}function D(){if(!j){var t=O(R);j=!0;for(var r=U.length;r;){for(I=U,U=[];++M<r;)I&&I[M].run();M=-1,r=U.length}I=null,j=!1,function(t){if(k===clearTimeout)return clearTimeout(t);if((k===x||!k)&&clearTimeout)return k=clearTimeout,clearTimeout(t);try{k(t)}catch(e){try{return k.call(null,t)}catch(e){return k.call(this,t)}}}(t)}}function N(t,e){this.fun=t,this.array=e}function F(){}C.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];U.push(new N(t,e)),1!==U.length||j||O(D)},N.prototype.run=function(){this.fun.apply(null,this.array)},C.title="browser",C.browser=!0,C.env={},C.argv=[],C.version="",C.versions={},C.on=F,C.addListener=F,C.once=F,C.off=F,C.removeListener=F,C.removeAllListeners=F,C.emit=F,C.prependListener=F,C.prependOnceListener=F,C.listeners=function(t){return[]},C.binding=function(t){throw new Error("process.binding is not supported")},C.cwd=function(){return"/"},C.chdir=function(t){throw new Error("process.chdir is not supported")},C.umask=function(){return 0};for(var z={toByteArray:function(t){var e,r,n=K(t),o=n[0],i=n[1],u=new G(function(t,e,r){return 3*(e+r)/4-r}(0,o,i)),s=0,f=i>0?o-4:o;for(r=0;r<f;r+=4)e=q[t.charCodeAt(r)]<<18|q[t.charCodeAt(r+1)]<<12|q[t.charCodeAt(r+2)]<<6|q[t.charCodeAt(r+3)],u[s++]=e>>16&255,u[s++]=e>>8&255,u[s++]=255&e;return 2===i&&(e=q[t.charCodeAt(r)]<<2|q[t.charCodeAt(r+1)]>>4,u[s++]=255&e),1===i&&(e=q[t.charCodeAt(r)]<<10|q[t.charCodeAt(r+1)]<<4|q[t.charCodeAt(r+2)]>>2,u[s++]=e>>8&255,u[s++]=255&e),u},fromByteArray:function(t){for(var e,r=t.length,n=r%3,o=[],i=0,u=r-n;i<u;i+=16383)o.push(V(t,i,i+16383>u?u:i+16383));return 1===n?(e=t[r-1],o.push(Y[e>>2]+Y[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],o.push(Y[e>>10]+Y[e>>4&63]+Y[e<<2&63]+"=")),o.join("")}},Y=[],q=[],G="undefined"!=typeof Uint8Array?Uint8Array:Array,W="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",X=0,H=W.length;X<H;++X)Y[X]=W[X],q[W.charCodeAt(X)]=X;function K(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function V(t,e,r){for(var n,o,i=[],u=e;u<r;u+=3)n=(t[u]<<16&16711680)+(t[u+1]<<8&65280)+(255&t[u+2]),i.push(Y[(o=n)>>18&63]+Y[o>>12&63]+Y[o>>6&63]+Y[63&o]);return i.join("")}q["-".charCodeAt(0)]=62,q["_".charCodeAt(0)]=63;var J={read:function(t,e,r,n,o){var i,u,s=8*o-n-1,f=(1<<s)-1,a=f>>1,h=-7,c=r?o-1:0,l=r?-1:1,p=t[e+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=s;h>0;i=256*i+t[e+c],c+=l,h-=8);for(u=i&(1<<-h)-1,i>>=-h,h+=n;h>0;u=256*u+t[e+c],c+=l,h-=8);if(0===i)i=1-a;else{if(i===f)return u?NaN:1/0*(p?-1:1);u+=Math.pow(2,n),i-=a}return(p?-1:1)*u*Math.pow(2,i-n)},write:function(t,e,r,n,o,i){var u,s,f,a=8*i-o-1,h=(1<<a)-1,c=h>>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,y=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,u=h):(u=Math.floor(Math.log(e)/Math.LN2),e*(f=Math.pow(2,-u))<1&&(u--,f*=2),(e+=u+c>=1?l/f:l*Math.pow(2,1-c))*f>=2&&(u++,f/=2),u+c>=h?(s=0,u=h):u+c>=1?(s=(e*f-1)*Math.pow(2,o),u+=c):(s=e*Math.pow(2,c-1)*Math.pow(2,o),u=0));o>=8;t[r+p]=255&s,p+=y,s/=256,o-=8);for(u=u<<o|s,a+=o;a>0;t[r+p]=255&u,p+=y,u/=256,a-=8);t[r+p-y]|=128*g}},Z={};(function(t,e){(function(){function r(t,e,n){var o=this;if("number"!=typeof t)throw new Error("chunkLength must be a number");if("function"==typeof e)return r(t,null,e);if(!(o instanceof r))return new r(t,e,n);e||(e={}),o.chunkLength=t,o.length=Number(e.length)||1/0,o.closed=!1,o._groupPutDelay=e.groupPutDelay||10,o._groupPutCallbacks=[],o._groupPutData={},o._groupPutTimeout=null,o._lastGroupPut=0,o.length!==1/0&&(this.lastChunkLength=this.length%this.chunkLength||this.chunkLength,o.lastChunkIndex=Math.ceil(o.length/o.chunkLength)-1);var i=e.name||""+Math.round(9e16*Math.random());e.torrent&&e.torrent.infoHash&&(i=e.torrent.infoHash),o._store=new m(i,n),o._store.on("close",(function(){o._close(new Error("IndexedDB database unexpectedly closed"))})),o._store.on("error",(function(t){o._close(t)}))}function n(){null!=arguments[0]&&t.nextTick.apply(this,arguments)}function o(){}Z=r,r.prototype.put=function(t,r,o){if(this.closed)throw new Error("Store is closed");if("number"!=typeof t)throw new Error("index must be a number");e.isBuffer(r)||(r=e.from(r));var i=t===this.lastChunkIndex;if(i&&r.length!==this.lastChunkLength||!i&&r.length!==this.chunkLength)return n(o,new Error("Invalid buffer length"));this._groupPutData[t]=r,o&&this._groupPutCallbacks.push(o),this._lastGroupPut+this._groupPutDelay<Date.now()?this._groupPut():null==this._groupPutTimeout&&(this._groupPutTimeout=setTimeout(this._groupPut.bind(this),this._groupPutDelay))},r.prototype._groupPut=function(){if(!this.closed){var t=this._groupPutCallbacks,e=this._groupPutData;this._groupPutCallbacks=[],this._groupPutData={},this._lastGroupPut=Date.now(),null!=this._groupPutTimeout&&clearTimeout(this._groupPutTimeout),this._groupPutTimeout=null;var r=this._store.transaction("readwrite");for(var n in e)r.set(Number(n),e[n],o);r.onfinish=function(e){for(var r in t)t[r](e)}}},r.prototype.get=function(t,r,n){if("function"==typeof r)return this.get(t,null,r);if("function"!=typeof n)throw new Error("cb must be a function");if(this.closed)throw new Error("Store is closed");if("number"!=typeof t)throw new Error("index must be a number");r||(r={}),this._store.get(t,(function(t,o){if(t)return n(t);if(void 0===o){var i=new Error("Chunk does not exist");return i.name="MissingChunkError",n(i)}var u=r.offset||0,s=r.length||o.length-u;n(null,e.from(o).slice(u,u+s))}))},r.prototype.close=function(t){this._close(),n(t,null)},r.prototype._close=function(t){if(!this.closed){for(var e in this.closed=!0,this._store.close(),this._store=null,this._groupPutData=null,clearTimeout(this._groupPutTimeout),t=t||new Error("Store is closed"),this._groupPutCallbacks)this._groupPutCallbacks[e](t);this._groupPutCallbacks=null}},r.prototype.destroy=function(t){if(this.closed)throw new Error("Store is closed");this._store.clear(o),this.close(t)}}).call(this)}).call(this,T,n({}).Buffer),IdbChunkStore=Z}(); |