mirror of
https://github.com/ThaUnknown/miru.git
synced 2026-04-20 05:52:06 +00:00
1 line
No EOL
24 KiB
JavaScript
1 line
No EOL
24 KiB
JavaScript
!function(){for(var t,r,e=(t=function(t,i){(function(t){"use strict";function e(r){if(r>2147483647)throw new RangeError('The value "'+r+'" is invalid for option "size"');var e=new Uint8Array(r);return e.__proto__=t.prototype,e}function t(t,r,e){if("number"==typeof t){if("string"==typeof r)throw new TypeError('The "string" argument must be of type string. Received type number');return u(t)}return o(t,r,e)}function o(r,n,i){if("string"==typeof r)return function(r,n){if("string"==typeof n&&""!==n||(n="utf8"),!t.isEncoding(n))throw new TypeError("Unknown encoding: "+n);var i=0|a(r,n),o=e(i),s=o.write(r,n);return s!==i&&(o=o.slice(0,s)),o}(r,n);if(ArrayBuffer.isView(r))return f(r);if(null==r)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(N(r,ArrayBuffer)||r&&N(r.buffer,ArrayBuffer))return function(r,e,n){if(e<0||r.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');var i;return(i=void 0===e&&void 0===n?new Uint8Array(r):void 0===n?new Uint8Array(r,e):new Uint8Array(r,e,n)).__proto__=t.prototype,i}(r,n,i);if("number"==typeof r)throw new TypeError('The "value" argument must not be of type number. Received type number');var o=r.valueOf&&r.valueOf();if(null!=o&&o!==r)return t.from(o,n,i);var s=function(r){if(t.isBuffer(r)){var n=0|h(r.length),i=e(n);return 0===i.length||r.copy(i,0,0,n),i}return void 0!==r.length?"number"!=typeof r.length||j(r.length)?e(0):f(r):"Buffer"===r.type&&Array.isArray(r.data)?f(r.data):void 0}(r);if(s)return s;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof r[Symbol.toPrimitive])return t.from(r[Symbol.toPrimitive]("string"),n,i);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}function s(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(t){return s(t),e(t<0?0:0|h(t))}function f(t){for(var r=t.length<0?0:0|h(t.length),n=e(r),i=0;i<r;i+=1)n[i]=255&t[i];return n}function h(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(r,e){if(t.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||N(r,ArrayBuffer))return r.byteLength;if("string"!=typeof r)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);var n=r.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===n)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return M(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return P(r).length;default:if(o)return i?-1:M(r).length;e=(""+e).toLowerCase(),o=!0}}function c(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function p(r,e,n,i,o){if(0===r.length)return-1;if("string"==typeof n?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),j(n=+n)&&(n=o?0:r.length-1),n<0&&(n=r.length+n),n>=r.length){if(o)return-1;n=r.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof e&&(e=t.from(e,i)),t.isBuffer(e))return 0===e.length?-1:y(r,e,n,i,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(r,e,n):Uint8Array.prototype.lastIndexOf.call(r,e,n):y(r,[e],n,i,o);throw new TypeError("val must be string, number or Buffer")}function y(t,r,e,n,i){var o,s=1,u=t.length,f=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;s=2,u/=2,f/=2,e/=2}function h(t,r){return 1===s?t[r]:t.readUInt16BE(r*s)}if(i){var a=-1;for(o=e;o<u;o++)if(h(t,o)===h(r,-1===a?0:o-a)){if(-1===a&&(a=o),o-a+1===f)return a*s}else-1!==a&&(o-=o-a),a=-1}else for(e+f>u&&(e=u-f),o=e;o>=0;o--){for(var c=!0,l=0;l<f;l++)if(h(t,o+l)!==h(r,l)){c=!1;break}if(c)return o}return-1}function g(t,r,e,n){e=Number(e)||0;var i=t.length-e;n?(n=Number(n))>i&&(n=i):n=i;var o=r.length;n>o/2&&(n=o/2);for(var s=0;s<n;++s){var u=parseInt(r.substr(2*s,2),16);if(j(u))return s;t[e+s]=u}return s}function d(t,r,e,n){return O(M(r,t.length-e),t,e,n)}function w(t,r,e,n){return O(function(t){for(var r=[],e=0;e<t.length;++e)r.push(255&t.charCodeAt(e));return r}(r),t,e,n)}function v(t,r,e,n){return w(t,r,e,n)}function m(t,r,e,n){return O(P(r),t,e,n)}function b(t,r,e,n){return O(function(t,r){for(var e,n,i,o=[],s=0;s<t.length&&!((r-=2)<0);++s)n=(e=t.charCodeAt(s))>>8,i=e%256,o.push(i),o.push(n);return o}(r,t.length-e),t,e,n)}function E(t,r,e){return 0===r&&e===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(r,e))}function A(t,r,e){e=Math.min(t.length,e);for(var n=[],i=r;i<e;){var o,s,u,f,h=t[i],a=null,c=h>239?4:h>223?3:h>191?2:1;if(i+c<=e)switch(c){case 1:h<128&&(a=h);break;case 2:128==(192&(o=t[i+1]))&&(f=(31&h)<<6|63&o)>127&&(a=f);break;case 3:o=t[i+1],s=t[i+2],128==(192&o)&&128==(192&s)&&(f=(15&h)<<12|(63&o)<<6|63&s)>2047&&(f<55296||f>57343)&&(a=f);break;case 4:o=t[i+1],s=t[i+2],u=t[i+3],128==(192&o)&&128==(192&s)&&128==(192&u)&&(f=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&u)>65535&&f<1114112&&(a=f)}null===a?(a=65533,c=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|1023&a),n.push(a),i+=c}return function(t){var r=t.length;if(r<=B)return String.fromCharCode.apply(String,t);for(var e="",n=0;n<r;)e+=String.fromCharCode.apply(String,t.slice(n,n+=B));return e}(n)}i.Buffer=t,i.INSPECT_MAX_BYTES=50,t.TYPED_ARRAY_SUPPORT=function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()}catch(r){return!1}}(),t.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(t.prototype,"parent",{enumerable:!0,get:function(){if(t.isBuffer(this))return this.buffer}}),Object.defineProperty(t.prototype,"offset",{enumerable:!0,get:function(){if(t.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&t[Symbol.species]===t&&Object.defineProperty(t,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),t.poolSize=8192,t.from=function(t,r,e){return o(t,r,e)},t.prototype.__proto__=Uint8Array.prototype,t.__proto__=Uint8Array,t.alloc=function(t,r,n){return function(t,r,n){return s(t),t<=0?e(t):void 0!==r?"string"==typeof n?e(t).fill(r,n):e(t).fill(r):e(t)}(t,r,n)},t.allocUnsafe=function(t){return u(t)},t.allocUnsafeSlow=function(t){return u(t)},t.isBuffer=function(r){return null!=r&&!0===r._isBuffer&&r!==t.prototype},t.compare=function(r,e){if(N(r,Uint8Array)&&(r=t.from(r,r.offset,r.byteLength)),N(e,Uint8Array)&&(e=t.from(e,e.offset,e.byteLength)),!t.isBuffer(r)||!t.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===e)return 0;for(var n=r.length,i=e.length,o=0,s=Math.min(n,i);o<s;++o)if(r[o]!==e[o]){n=r[o],i=e[o];break}return n<i?-1:i<n?1:0},t.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}},t.concat=function(r,e){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(0===r.length)return t.alloc(0);var n;if(void 0===e)for(e=0,n=0;n<r.length;++n)e+=r[n].length;var i=t.allocUnsafe(e),o=0;for(n=0;n<r.length;++n){var s=r[n];if(N(s,Uint8Array)&&(s=t.from(s)),!t.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(i,o),o+=s.length}return i},t.byteLength=a,t.prototype._isBuffer=!0,t.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 r=0;r<t;r+=2)c(this,r,r+1);return this},t.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 r=0;r<t;r+=4)c(this,r,r+3),c(this,r+1,r+2);return this},t.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 r=0;r<t;r+=8)c(this,r,r+7),c(this,r+1,r+6),c(this,r+2,r+5),c(this,r+3,r+4);return this},t.prototype.toString=function(){var t=this.length;return 0===t?"":0===arguments.length?A(this,0,t):function(t,r,e){var n=!1;if((void 0===r||r<0)&&(r=0),r>this.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return I(this,r,e);case"utf8":case"utf-8":return A(this,r,e);case"ascii":return _(this,r,e);case"latin1":case"binary":return k(this,r,e);case"base64":return E(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},t.prototype.toLocaleString=t.prototype.toString,t.prototype.equals=function(r){if(!t.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r||0===t.compare(this,r)},t.prototype.inspect=function(){var t="",r=i.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},t.prototype.compare=function(r,e,n,i,o){if(N(r,Uint8Array)&&(r=t.from(r,r.offset,r.byteLength)),!t.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(void 0===e&&(e=0),void 0===n&&(n=r?r.length:0),void 0===i&&(i=0),void 0===o&&(o=this.length),e<0||n>r.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&e>=n)return 0;if(i>=o)return-1;if(e>=n)return 1;if(this===r)return 0;for(var s=(o>>>=0)-(i>>>=0),u=(n>>>=0)-(e>>>=0),f=Math.min(s,u),h=this.slice(i,o),a=r.slice(e,n),c=0;c<f;++c)if(h[c]!==a[c]){s=h[c],u=a[c];break}return s<u?-1:u<s?1:0},t.prototype.includes=function(t,r,e){return-1!==this.indexOf(t,r,e)},t.prototype.indexOf=function(t,r,e){return p(this,t,r,e,!0)},t.prototype.lastIndexOf=function(t,r,e){return p(this,t,r,e,!1)},t.prototype.write=function(t,r,e,n){if(void 0===r)n="utf8",e=this.length,r=0;else if(void 0===e&&"string"==typeof r)n=r,e=this.length,r=0;else{if(!isFinite(r))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");r>>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var i=this.length-r;if((void 0===e||e>i)&&(e=i),t.length>0&&(e<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return g(this,t,r,e);case"utf8":case"utf-8":return d(this,t,r,e);case"ascii":return w(this,t,r,e);case"latin1":case"binary":return v(this,t,r,e);case"base64":return m(this,t,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return b(this,t,r,e);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},t.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var B=4096;function _(t,r,e){var n="";e=Math.min(t.length,e);for(var i=r;i<e;++i)n+=String.fromCharCode(127&t[i]);return n}function k(t,r,e){var n="";e=Math.min(t.length,e);for(var i=r;i<e;++i)n+=String.fromCharCode(t[i]);return n}function I(t,r,e){var n,i=t.length;(!r||r<0)&&(r=0),(!e||e<0||e>i)&&(e=i);for(var o="",s=r;s<e;++s)o+=(n=t[s])<16?"0"+n.toString(16):n.toString(16);return o}function U(t,r,e){for(var n=t.slice(r,e),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function S(t,r,e){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+r>e)throw new RangeError("Trying to access beyond buffer length")}function C(r,e,n,i,o,s){if(!t.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<s)throw new RangeError('"value" argument is out of bounds');if(n+i>r.length)throw new RangeError("Index out of range")}function T(t,r,e,n,i,o){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function L(t,r,e,n,i){return r=+r,e>>>=0,i||T(t,0,e,4),l.write(t,r,e,n,23,4),e+4}function x(t,r,e,n,i){return r=+r,e>>>=0,i||T(t,0,e,8),l.write(t,r,e,n,52,8),e+8}t.prototype.slice=function(r,e){var n=this.length;(r=~~r)<0?(r+=n)<0&&(r=0):r>n&&(r=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<r&&(e=r);var i=this.subarray(r,e);return i.__proto__=t.prototype,i},t.prototype.readUIntLE=function(t,r,e){t>>>=0,r>>>=0,e||S(t,r,this.length);for(var n=this[t],i=1,o=0;++o<r&&(i*=256);)n+=this[t+o]*i;return n},t.prototype.readUIntBE=function(t,r,e){t>>>=0,r>>>=0,e||S(t,r,this.length);for(var n=this[t+--r],i=1;r>0&&(i*=256);)n+=this[t+--r]*i;return n},t.prototype.readUInt8=function(t,r){return t>>>=0,r||S(t,1,this.length),this[t]},t.prototype.readUInt16LE=function(t,r){return t>>>=0,r||S(t,2,this.length),this[t]|this[t+1]<<8},t.prototype.readUInt16BE=function(t,r){return t>>>=0,r||S(t,2,this.length),this[t]<<8|this[t+1]},t.prototype.readUInt32LE=function(t,r){return t>>>=0,r||S(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},t.prototype.readUInt32BE=function(t,r){return t>>>=0,r||S(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},t.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||S(t,r,this.length);for(var n=this[t],i=1,o=0;++o<r&&(i*=256);)n+=this[t+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*r)),n},t.prototype.readIntBE=function(t,r,e){t>>>=0,r>>>=0,e||S(t,r,this.length);for(var n=r,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*r)),o},t.prototype.readInt8=function(t,r){return t>>>=0,r||S(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},t.prototype.readInt16LE=function(t,r){t>>>=0,r||S(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},t.prototype.readInt16BE=function(t,r){t>>>=0,r||S(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},t.prototype.readInt32LE=function(t,r){return t>>>=0,r||S(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},t.prototype.readInt32BE=function(t,r){return t>>>=0,r||S(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},t.prototype.readFloatLE=function(t,r){return t>>>=0,r||S(t,4,this.length),l.read(this,t,!0,23,4)},t.prototype.readFloatBE=function(t,r){return t>>>=0,r||S(t,4,this.length),l.read(this,t,!1,23,4)},t.prototype.readDoubleLE=function(t,r){return t>>>=0,r||S(t,8,this.length),l.read(this,t,!0,52,8)},t.prototype.readDoubleBE=function(t,r){return t>>>=0,r||S(t,8,this.length),l.read(this,t,!1,52,8)},t.prototype.writeUIntLE=function(t,r,e,n){t=+t,r>>>=0,e>>>=0,n||C(this,t,r,e,Math.pow(2,8*e)-1,0);var i=1,o=0;for(this[r]=255&t;++o<e&&(i*=256);)this[r+o]=t/i&255;return r+e},t.prototype.writeUIntBE=function(t,r,e,n){t=+t,r>>>=0,e>>>=0,n||C(this,t,r,e,Math.pow(2,8*e)-1,0);var i=e-1,o=1;for(this[r+i]=255&t;--i>=0&&(o*=256);)this[r+i]=t/o&255;return r+e},t.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||C(this,t,r,1,255,0),this[r]=255&t,r+1},t.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||C(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},t.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||C(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},t.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||C(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},t.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||C(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},t.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var i=Math.pow(2,8*e-1);C(this,t,r,e,i-1,-i)}var o=0,s=1,u=0;for(this[r]=255&t;++o<e&&(s*=256);)t<0&&0===u&&0!==this[r+o-1]&&(u=1),this[r+o]=(t/s>>0)-u&255;return r+e},t.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var i=Math.pow(2,8*e-1);C(this,t,r,e,i-1,-i)}var o=e-1,s=1,u=0;for(this[r+o]=255&t;--o>=0&&(s*=256);)t<0&&0===u&&0!==this[r+o+1]&&(u=1),this[r+o]=(t/s>>0)-u&255;return r+e},t.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||C(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},t.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||C(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},t.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||C(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},t.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||C(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},t.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||C(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},t.prototype.writeFloatLE=function(t,r,e){return L(this,t,r,!0,e)},t.prototype.writeFloatBE=function(t,r,e){return L(this,t,r,!1,e)},t.prototype.writeDoubleLE=function(t,r,e){return x(this,t,r,!0,e)},t.prototype.writeDoubleBE=function(t,r,e){return x(this,t,r,!1,e)},t.prototype.copy=function(r,e,n,i){if(!t.isBuffer(r))throw new TypeError("argument should be a Buffer");if(n||(n=0),i||0===i||(i=this.length),e>=r.length&&(e=r.length),e||(e=0),i>0&&i<n&&(i=n),i===n)return 0;if(0===r.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),r.length-e<i-n&&(i=r.length-e+n);var o=i-n;if(this===r&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(e,n,i);else if(this===r&&n<e&&e<i)for(var s=o-1;s>=0;--s)r[s+e]=this[s+n];else Uint8Array.prototype.set.call(r,this.subarray(n,i),e);return o},t.prototype.fill=function(r,e,n,i){if("string"==typeof r){if("string"==typeof e?(i=e,e=0,n=this.length):"string"==typeof n&&(i=n,n=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!t.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===r.length){var o=r.charCodeAt(0);("utf8"===i&&o<128||"latin1"===i)&&(r=o)}}else"number"==typeof r&&(r&=255);if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;var s;if(e>>>=0,n=void 0===n?this.length:n>>>0,r||(r=0),"number"==typeof r)for(s=e;s<n;++s)this[s]=r;else{var u=t.isBuffer(r)?r:t.from(r,i),f=u.length;if(0===f)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(s=0;s<n-e;++s)this[s+e]=u[s%f]}return this};var R=/[^+/0-9A-Za-z-_]/g;function M(t,r){var e;r=r||1/0;for(var n=t.length,i=null,o=[],s=0;s<n;++s){if((e=t.charCodeAt(s))>55295&&e<57344){if(!i){if(e>56319){(r-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(r-=3)>-1&&o.push(239,191,189);continue}i=e;continue}if(e<56320){(r-=3)>-1&&o.push(239,191,189),i=e;continue}e=65536+(i-55296<<10|e-56320)}else i&&(r-=3)>-1&&o.push(239,191,189);if(i=null,e<128){if((r-=1)<0)break;o.push(e)}else if(e<2048){if((r-=2)<0)break;o.push(e>>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;o.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;o.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return o}function P(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(R,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function O(t,r,e,n){for(var i=0;i<n&&!(i+e>=r.length||i>=t.length);++i)r[i+e]=t[i];return i}function N(t,r){return t instanceof r||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===r.name}function j(t){return t!=t}}).call(this,e({}).Buffer)},function(e){return r||t(r={exports:{},parent:e},r.exports),r.exports}),n={toByteArray:function(t){var r,e,n=a(t),i=n[0],u=n[1],f=new s(function(t,r,e){return 3*(r+e)/4-e}(0,i,u)),h=0,c=u>0?i-4:i;for(e=0;e<c;e+=4)r=o[t.charCodeAt(e)]<<18|o[t.charCodeAt(e+1)]<<12|o[t.charCodeAt(e+2)]<<6|o[t.charCodeAt(e+3)],f[h++]=r>>16&255,f[h++]=r>>8&255,f[h++]=255&r;return 2===u&&(r=o[t.charCodeAt(e)]<<2|o[t.charCodeAt(e+1)]>>4,f[h++]=255&r),1===u&&(r=o[t.charCodeAt(e)]<<10|o[t.charCodeAt(e+1)]<<4|o[t.charCodeAt(e+2)]>>2,f[h++]=r>>8&255,f[h++]=255&r),f},fromByteArray:function(t){for(var r,e=t.length,n=e%3,o=[],s=0,u=e-n;s<u;s+=16383)o.push(c(t,s,s+16383>u?u:s+16383));return 1===n?(r=t[e-1],o.push(i[r>>2]+i[r<<4&63]+"==")):2===n&&(r=(t[e-2]<<8)+t[e-1],o.push(i[r>>10]+i[r>>4&63]+i[r<<2&63]+"=")),o.join("")}},i=[],o=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=0,h=u.length;f<h;++f)i[f]=u[f],o[u.charCodeAt(f)]=f;function a(t){var r=t.length;if(r%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=t.indexOf("=");return-1===e&&(e=r),[e,e===r?0:4-e%4]}function c(t,r,e){for(var n,o,s=[],u=r;u<e;u+=3)n=(t[u]<<16&16711680)+(t[u+1]<<8&65280)+(255&t[u+2]),s.push(i[(o=n)>>18&63]+i[o>>12&63]+i[o>>6&63]+i[63&o]);return s.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63;var l={read:function(t,r,e,n,i){var o,s,u=8*i-n-1,f=(1<<u)-1,h=f>>1,a=-7,c=e?i-1:0,l=e?-1:1,p=t[r+c];for(c+=l,o=p&(1<<-a)-1,p>>=-a,a+=u;a>0;o=256*o+t[r+c],c+=l,a-=8);for(s=o&(1<<-a)-1,o>>=-a,a+=n;a>0;s=256*s+t[r+c],c+=l,a-=8);if(0===o)o=1-h;else{if(o===f)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=h}return(p?-1:1)*s*Math.pow(2,o-n)},write:function(t,r,e,n,i,o){var s,u,f,h=8*o-i-1,a=(1<<h)-1,c=a>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,y=n?1:-1,g=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(u=isNaN(r)?1:0,s=a):(s=Math.floor(Math.log(r)/Math.LN2),r*(f=Math.pow(2,-s))<1&&(s--,f*=2),(r+=s+c>=1?l/f:l*Math.pow(2,1-c))*f>=2&&(s++,f/=2),s+c>=a?(u=0,s=a):s+c>=1?(u=(r*f-1)*Math.pow(2,i),s+=c):(u=r*Math.pow(2,c-1)*Math.pow(2,i),s=0));i>=8;t[e+p]=255&u,p+=y,u/=256,i-=8);for(s=s<<i|u,h+=i;h>0;t[e+p]=255&s,p+=y,s/=256,h-=8);t[e+p-y]|=128*g}},p={};(function(t){function r(){}p=class{constructor(t,{length:r=1/0,name:e="idbkv-chunk-store",batchInterval:n=10}={}){this._idbkvStore=new class{constructor(t,{batchInterval:r=10}={}){this.storeName="idb-kv",this.batchInterval=r,this.db=new Promise((r,e)=>{const n=indexedDB.open(t,1);n.onsuccess=()=>r(n.result),n.onerror=()=>{e(new Error(`error opening the indexedDB database named ${t}: ${n.error}`))},n.onupgradeneeded=()=>n.result.createObjectStore(this.storeName)}),this._actions=[],this._commitPromise=null}async get(t){const r=new Promise((r,e)=>{this._actions.push({type:"get",key:t,resolve:r,reject:e})});return await Promise.race([r,this._getOrStartCommit()]),r}async set(t,r){return this._actions.push({type:"set",key:t,value:r}),this._getOrStartCommit()}async delete(t){return this._actions.push({type:"delete",key:t}),this._getOrStartCommit()}async destroy(){const t=await this.db;t.close();const r=indexedDB.deleteDatabase(t.name);return this.db=Promise.reject(new Error("This idb-kv instance has been destroyed")),new Promise((t,e)=>{r.onsuccess=()=>t(),r.onerror=()=>e(r.error)})}_getOrStartCommit(){return this._commitPromise||(this._commitPromise=this._commit()),this._commitPromise}async _commit(){await new Promise(t=>setTimeout(t,this.batchInterval));const t=(await this.db).transaction(this.storeName,"readwrite"),r=t.objectStore(this.storeName);for(const e of this._actions)switch(e.type){case"get":{const t=r.get(e.key);t.onsuccess=()=>e.resolve(t.result),t.onerror=()=>e.reject(t.error);break}case"set":r.put(e.value,e.key);break;case"delete":r.delete(e.key)}return this._actions=[],this._commitPromise=null,new Promise((r,e)=>{t.oncomplete=()=>r(),t.onabort=t=>e(t.target.error),t.onerror=()=>{t.error&&e(t.error)}})}}(e,{batchInterval:n}),this.chunkLength=t,r!==1/0&&(this.lastChunkLength=r%this.chunkLength||this.chunkLength,this.lastChunkIndex=Math.ceil(r/this.chunkLength)-1)}put(t,e,n=r){if(t===this.lastChunkIndex){if(e.length!==this.lastChunkLength)return n(new Error("Last chunk's length must be "+this.lastChunkLength))}else if(e.length!==this.chunkLength)return n(new Error("Chunk length must be "+this.chunkLength));this._idbkvStore.set(t,e).then(n).catch(n)}get(r,e,n){if("function"==typeof e)return this.get(r,{},e);this._idbkvStore.get(r).then(r=>{if(void 0===r)return n(new Error("Index does not exist in storage"));const i=t.from(r),o=e&&e.offset||0,s=e&&e.length||i.length-o;n(null,i.slice(o,o+s))}).catch(n)}close(t=r){this._idbkvStore.db.then(r=>{r.close(),t()}).catch(t)}destroy(t=r){this._idbkvStore.destroy().then(t).catch(t)}}}).call(this,e({}).Buffer),function(t){t.window.IdbkvChunkStore=p}.call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})}(); |