template-project/node_modules/jimp/dist/browser/index.js
2025-05-30 18:13:30 +08:00

237 lines
711 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

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

var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function getAugmentedNamespace(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var i=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};i.prototype=t.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(i,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),i}"undefined"==typeof self&&"object"==typeof commonjsGlobal&&(commonjsGlobal.self=commonjsGlobal);var global$1="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},lookup=[],revLookup=[],Arr="undefined"!=typeof Uint8Array?Uint8Array:Array,inited=!1;function init(){inited=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)lookup[t]=e[t],revLookup[e.charCodeAt(t)]=t;revLookup["-".charCodeAt(0)]=62,revLookup["_".charCodeAt(0)]=63}function toByteArray(e){var t,i,r,n,a,o;inited||init();var s=e.length;if(s%4>0)throw new Error("Invalid string. Length must be a multiple of 4");a="="===e[s-2]?2:"="===e[s-1]?1:0,o=new Arr(3*s/4-a),r=a>0?s-4:s;var l=0;for(t=0,i=0;t<r;t+=4,i+=3)n=revLookup[e.charCodeAt(t)]<<18|revLookup[e.charCodeAt(t+1)]<<12|revLookup[e.charCodeAt(t+2)]<<6|revLookup[e.charCodeAt(t+3)],o[l++]=n>>16&255,o[l++]=n>>8&255,o[l++]=255&n;return 2===a?(n=revLookup[e.charCodeAt(t)]<<2|revLookup[e.charCodeAt(t+1)]>>4,o[l++]=255&n):1===a&&(n=revLookup[e.charCodeAt(t)]<<10|revLookup[e.charCodeAt(t+1)]<<4|revLookup[e.charCodeAt(t+2)]>>2,o[l++]=n>>8&255,o[l++]=255&n),o}function tripletToBase64(e){return lookup[e>>18&63]+lookup[e>>12&63]+lookup[e>>6&63]+lookup[63&e]}function encodeChunk(e,t,i){for(var r,n=[],a=t;a<i;a+=3)r=(e[a]<<16)+(e[a+1]<<8)+e[a+2],n.push(tripletToBase64(r));return n.join("")}function fromByteArray(e){var t;inited||init();for(var i=e.length,r=i%3,n="",a=[],o=16383,s=0,l=i-r;s<l;s+=o)a.push(encodeChunk(e,s,s+o>l?l:s+o));return 1===r?(t=e[i-1],n+=lookup[t>>2],n+=lookup[t<<4&63],n+="=="):2===r&&(t=(e[i-2]<<8)+e[i-1],n+=lookup[t>>10],n+=lookup[t>>4&63],n+=lookup[t<<2&63],n+="="),a.push(n),a.join("")}function read(e,t,i,r,n){var a,o,s=8*n-r-1,l=(1<<s)-1,u=l>>1,h=-7,c=i?n-1:0,f=i?-1:1,d=e[t+c];for(c+=f,a=d&(1<<-h)-1,d>>=-h,h+=s;h>0;a=256*a+e[t+c],c+=f,h-=8);for(o=a&(1<<-h)-1,a>>=-h,h+=r;h>0;o=256*o+e[t+c],c+=f,h-=8);if(0===a)a=1-u;else{if(a===l)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,r),a-=u}return(d?-1:1)*o*Math.pow(2,a-r)}function write(e,t,i,r,n,a){var o,s,l,u=8*a-n-1,h=(1<<u)-1,c=h>>1,f=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:a-1,p=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,o=h):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),(t+=o+c>=1?f/l:f*Math.pow(2,1-c))*l>=2&&(o++,l/=2),o+c>=h?(s=0,o=h):o+c>=1?(s=(t*l-1)*Math.pow(2,n),o+=c):(s=t*Math.pow(2,c-1)*Math.pow(2,n),o=0));n>=8;e[i+d]=255&s,d+=p,s/=256,n-=8);for(o=o<<n|s,u+=n;u>0;e[i+d]=255&o,d+=p,o/=256,u-=8);e[i+d-p]|=128*m}var toString={}.toString,isArray=Array.isArray||function(e){return"[object Array]"==toString.call(e)},INSPECT_MAX_BYTES=50;function kMaxLength(){return Buffer.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function createBuffer(e,t){if(kMaxLength()<t)throw new RangeError("Invalid typed array length");return Buffer.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=Buffer.prototype:(null===e&&(e=new Buffer(t)),e.length=t),e}function Buffer(e,t,i){if(!(Buffer.TYPED_ARRAY_SUPPORT||this instanceof Buffer))return new Buffer(e,t,i);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return allocUnsafe(this,e)}return from(this,e,t,i)}function from(e,t,i,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?fromArrayBuffer(e,t,i,r):"string"==typeof t?fromString(e,t,i):fromObject(e,t)}function assertSize(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 alloc(e,t,i,r){return assertSize(t),t<=0?createBuffer(e,t):void 0!==i?"string"==typeof r?createBuffer(e,t).fill(i,r):createBuffer(e,t).fill(i):createBuffer(e,t)}function allocUnsafe(e,t){if(assertSize(t),e=createBuffer(e,t<0?0:0|checked(t)),!Buffer.TYPED_ARRAY_SUPPORT)for(var i=0;i<t;++i)e[i]=0;return e}function fromString(e,t,i){if("string"==typeof i&&""!==i||(i="utf8"),!Buffer.isEncoding(i))throw new TypeError('"encoding" must be a valid string encoding');var r=0|byteLength(t,i),n=(e=createBuffer(e,r)).write(t,i);return n!==r&&(e=e.slice(0,n)),e}function fromArrayLike(e,t){var i=t.length<0?0:0|checked(t.length);e=createBuffer(e,i);for(var r=0;r<i;r+=1)e[r]=255&t[r];return e}function fromArrayBuffer(e,t,i,r){if(t.byteLength,i<0||t.byteLength<i)throw new RangeError("'offset' is out of bounds");if(t.byteLength<i+(r||0))throw new RangeError("'length' is out of bounds");return t=void 0===i&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,i):new Uint8Array(t,i,r),Buffer.TYPED_ARRAY_SUPPORT?(e=t).__proto__=Buffer.prototype:e=fromArrayLike(e,t),e}function fromObject(e,t){if(internalIsBuffer(t)){var i=0|checked(t.length);return 0===(e=createBuffer(e,i)).length||t.copy(e,0,0,i),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||isnan(t.length)?createBuffer(e,0):fromArrayLike(e,t);if("Buffer"===t.type&&isArray(t.data))return fromArrayLike(e,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function checked(e){if(e>=kMaxLength())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+kMaxLength().toString(16)+" bytes");return 0|e}function internalIsBuffer(e){return!(null==e||!e._isBuffer)}function byteLength(e,t){if(internalIsBuffer(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 i=e.length;if(0===i)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return utf8ToBytes(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return base64ToBytes(e).length;default:if(r)return utf8ToBytes(e).length;t=(""+t).toLowerCase(),r=!0}}function slowToString(e,t,i){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return hexSlice(this,t,i);case"utf8":case"utf-8":return utf8Slice(this,t,i);case"ascii":return asciiSlice(this,t,i);case"latin1":case"binary":return latin1Slice(this,t,i);case"base64":return base64Slice(this,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,t,i);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function swap(e,t,i){var r=e[t];e[t]=e[i],e[i]=r}function bidirectionalIndexOf(e,t,i,r,n){if(0===e.length)return-1;if("string"==typeof i?(r=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=n?0:e.length-1),i<0&&(i=e.length+i),i>=e.length){if(n)return-1;i=e.length-1}else if(i<0){if(!n)return-1;i=0}if("string"==typeof t&&(t=Buffer.from(t,r)),internalIsBuffer(t))return 0===t.length?-1:arrayIndexOf(e,t,i,r,n);if("number"==typeof t)return t&=255,Buffer.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(e,t,i):Uint8Array.prototype.lastIndexOf.call(e,t,i):arrayIndexOf(e,[t],i,r,n);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(e,t,i,r,n){var a,o=1,s=e.length,l=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,s/=2,l/=2,i/=2}function u(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(n){var h=-1;for(a=i;a<s;a++)if(u(e,a)===u(t,-1===h?0:a-h)){if(-1===h&&(h=a),a-h+1===l)return h*o}else-1!==h&&(a-=a-h),h=-1}else for(i+l>s&&(i=s-l),a=i;a>=0;a--){for(var c=!0,f=0;f<l;f++)if(u(e,a+f)!==u(t,f)){c=!1;break}if(c)return a}return-1}function hexWrite(e,t,i,r){i=Number(i)||0;var n=e.length-i;r?(r=Number(r))>n&&(r=n):r=n;var a=t.length;if(a%2!=0)throw new TypeError("Invalid hex string");r>a/2&&(r=a/2);for(var o=0;o<r;++o){var s=parseInt(t.substr(2*o,2),16);if(isNaN(s))return o;e[i+o]=s}return o}function utf8Write(e,t,i,r){return blitBuffer(utf8ToBytes(t,e.length-i),e,i,r)}function asciiWrite(e,t,i,r){return blitBuffer(asciiToBytes(t),e,i,r)}function latin1Write(e,t,i,r){return asciiWrite(e,t,i,r)}function base64Write(e,t,i,r){return blitBuffer(base64ToBytes(t),e,i,r)}function ucs2Write(e,t,i,r){return blitBuffer(utf16leToBytes(t,e.length-i),e,i,r)}function base64Slice(e,t,i){return 0===t&&i===e.length?fromByteArray(e):fromByteArray(e.slice(t,i))}function utf8Slice(e,t,i){i=Math.min(e.length,i);for(var r=[],n=t;n<i;){var a,o,s,l,u=e[n],h=null,c=u>239?4:u>223?3:u>191?2:1;if(n+c<=i)switch(c){case 1:u<128&&(h=u);break;case 2:128==(192&(a=e[n+1]))&&(l=(31&u)<<6|63&a)>127&&(h=l);break;case 3:a=e[n+1],o=e[n+2],128==(192&a)&&128==(192&o)&&(l=(15&u)<<12|(63&a)<<6|63&o)>2047&&(l<55296||l>57343)&&(h=l);break;case 4:a=e[n+1],o=e[n+2],s=e[n+3],128==(192&a)&&128==(192&o)&&128==(192&s)&&(l=(15&u)<<18|(63&a)<<12|(63&o)<<6|63&s)>65535&&l<1114112&&(h=l)}null===h?(h=65533,c=1):h>65535&&(h-=65536,r.push(h>>>10&1023|55296),h=56320|1023&h),r.push(h),n+=c}return decodeCodePointsArray(r)}Buffer.TYPED_ARRAY_SUPPORT=void 0===global$1.TYPED_ARRAY_SUPPORT||global$1.TYPED_ARRAY_SUPPORT,kMaxLength(),Buffer.poolSize=8192,Buffer._augment=function(e){return e.__proto__=Buffer.prototype,e},Buffer.from=function(e,t,i){return from(null,e,t,i)},Buffer.TYPED_ARRAY_SUPPORT&&(Buffer.prototype.__proto__=Uint8Array.prototype,Buffer.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&Buffer[Symbol.species]),Buffer.alloc=function(e,t,i){return alloc(null,e,t,i)},Buffer.allocUnsafe=function(e){return allocUnsafe(null,e)},Buffer.allocUnsafeSlow=function(e){return allocUnsafe(null,e)},Buffer.isBuffer=isBuffer,Buffer.compare=function(e,t){if(!internalIsBuffer(e)||!internalIsBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var i=e.length,r=t.length,n=0,a=Math.min(i,r);n<a;++n)if(e[n]!==t[n]){i=e[n],r=t[n];break}return i<r?-1:r<i?1:0},Buffer.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}},Buffer.concat=function(e,t){if(!isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return Buffer.alloc(0);var i;if(void 0===t)for(t=0,i=0;i<e.length;++i)t+=e[i].length;var r=Buffer.allocUnsafe(t),n=0;for(i=0;i<e.length;++i){var a=e[i];if(!internalIsBuffer(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(r,n),n+=a.length}return r},Buffer.byteLength=byteLength,Buffer.prototype._isBuffer=!0,Buffer.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)swap(this,t,t+1);return this},Buffer.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)swap(this,t,t+3),swap(this,t+1,t+2);return this},Buffer.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)swap(this,t,t+7),swap(this,t+1,t+6),swap(this,t+2,t+5),swap(this,t+3,t+4);return this},Buffer.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?utf8Slice(this,0,e):slowToString.apply(this,arguments)},Buffer.prototype.equals=function(e){if(!internalIsBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===Buffer.compare(this,e)},Buffer.prototype.inspect=function(){var e="",t=INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),"<Buffer "+e+">"},Buffer.prototype.compare=function(e,t,i,r,n){if(!internalIsBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===i&&(i=e?e.length:0),void 0===r&&(r=0),void 0===n&&(n=this.length),t<0||i>e.length||r<0||n>this.length)throw new RangeError("out of range index");if(r>=n&&t>=i)return 0;if(r>=n)return-1;if(t>=i)return 1;if(this===e)return 0;for(var a=(n>>>=0)-(r>>>=0),o=(i>>>=0)-(t>>>=0),s=Math.min(a,o),l=this.slice(r,n),u=e.slice(t,i),h=0;h<s;++h)if(l[h]!==u[h]){a=l[h],o=u[h];break}return a<o?-1:o<a?1:0},Buffer.prototype.includes=function(e,t,i){return-1!==this.indexOf(e,t,i)},Buffer.prototype.indexOf=function(e,t,i){return bidirectionalIndexOf(this,e,t,i,!0)},Buffer.prototype.lastIndexOf=function(e,t,i){return bidirectionalIndexOf(this,e,t,i,!1)},Buffer.prototype.write=function(e,t,i,r){if(void 0===t)r="utf8",i=this.length,t=0;else if(void 0===i&&"string"==typeof t)r=t,i=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(i)?(i|=0,void 0===r&&(r="utf8")):(r=i,i=void 0)}var n=this.length-t;if((void 0===i||i>n)&&(i=n),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var a=!1;;)switch(r){case"hex":return hexWrite(this,e,t,i);case"utf8":case"utf-8":return utf8Write(this,e,t,i);case"ascii":return asciiWrite(this,e,t,i);case"latin1":case"binary":return latin1Write(this,e,t,i);case"base64":return base64Write(this,e,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,e,t,i);default:if(a)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),a=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(e){var t=e.length;if(t<=MAX_ARGUMENTS_LENGTH)return String.fromCharCode.apply(String,e);for(var i="",r=0;r<t;)i+=String.fromCharCode.apply(String,e.slice(r,r+=MAX_ARGUMENTS_LENGTH));return i}function asciiSlice(e,t,i){var r="";i=Math.min(e.length,i);for(var n=t;n<i;++n)r+=String.fromCharCode(127&e[n]);return r}function latin1Slice(e,t,i){var r="";i=Math.min(e.length,i);for(var n=t;n<i;++n)r+=String.fromCharCode(e[n]);return r}function hexSlice(e,t,i){var r=e.length;(!t||t<0)&&(t=0),(!i||i<0||i>r)&&(i=r);for(var n="",a=t;a<i;++a)n+=toHex(e[a]);return n}function utf16leSlice(e,t,i){for(var r=e.slice(t,i),n="",a=0;a<r.length;a+=2)n+=String.fromCharCode(r[a]+256*r[a+1]);return n}function checkOffset(e,t,i){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>i)throw new RangeError("Trying to access beyond buffer length")}function checkInt(e,t,i,r,n,a){if(!internalIsBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||t<a)throw new RangeError('"value" argument is out of bounds');if(i+r>e.length)throw new RangeError("Index out of range")}function objectWriteUInt16(e,t,i,r){t<0&&(t=65535+t+1);for(var n=0,a=Math.min(e.length-i,2);n<a;++n)e[i+n]=(t&255<<8*(r?n:1-n))>>>8*(r?n:1-n)}function objectWriteUInt32(e,t,i,r){t<0&&(t=4294967295+t+1);for(var n=0,a=Math.min(e.length-i,4);n<a;++n)e[i+n]=t>>>8*(r?n:3-n)&255}function checkIEEE754(e,t,i,r,n,a){if(i+r>e.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function writeFloat(e,t,i,r,n){return n||checkIEEE754(e,t,i,4),write(e,t,i,r,23,4),i+4}function writeDouble(e,t,i,r,n){return n||checkIEEE754(e,t,i,8),write(e,t,i,r,52,8),i+8}Buffer.prototype.slice=function(e,t){var i,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),Buffer.TYPED_ARRAY_SUPPORT)(i=this.subarray(e,t)).__proto__=Buffer.prototype;else{var n=t-e;i=new Buffer(n,void 0);for(var a=0;a<n;++a)i[a]=this[a+e]}return i},Buffer.prototype.readUIntLE=function(e,t,i){e|=0,t|=0,i||checkOffset(e,t,this.length);for(var r=this[e],n=1,a=0;++a<t&&(n*=256);)r+=this[e+a]*n;return r},Buffer.prototype.readUIntBE=function(e,t,i){e|=0,t|=0,i||checkOffset(e,t,this.length);for(var r=this[e+--t],n=1;t>0&&(n*=256);)r+=this[e+--t]*n;return r},Buffer.prototype.readUInt8=function(e,t){return t||checkOffset(e,1,this.length),this[e]},Buffer.prototype.readUInt16LE=function(e,t){return t||checkOffset(e,2,this.length),this[e]|this[e+1]<<8},Buffer.prototype.readUInt16BE=function(e,t){return t||checkOffset(e,2,this.length),this[e]<<8|this[e+1]},Buffer.prototype.readUInt32LE=function(e,t){return t||checkOffset(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Buffer.prototype.readUInt32BE=function(e,t){return t||checkOffset(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Buffer.prototype.readIntLE=function(e,t,i){e|=0,t|=0,i||checkOffset(e,t,this.length);for(var r=this[e],n=1,a=0;++a<t&&(n*=256);)r+=this[e+a]*n;return r>=(n*=128)&&(r-=Math.pow(2,8*t)),r},Buffer.prototype.readIntBE=function(e,t,i){e|=0,t|=0,i||checkOffset(e,t,this.length);for(var r=t,n=1,a=this[e+--r];r>0&&(n*=256);)a+=this[e+--r]*n;return a>=(n*=128)&&(a-=Math.pow(2,8*t)),a},Buffer.prototype.readInt8=function(e,t){return t||checkOffset(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Buffer.prototype.readInt16LE=function(e,t){t||checkOffset(e,2,this.length);var i=this[e]|this[e+1]<<8;return 32768&i?4294901760|i:i},Buffer.prototype.readInt16BE=function(e,t){t||checkOffset(e,2,this.length);var i=this[e+1]|this[e]<<8;return 32768&i?4294901760|i:i},Buffer.prototype.readInt32LE=function(e,t){return t||checkOffset(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Buffer.prototype.readInt32BE=function(e,t){return t||checkOffset(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Buffer.prototype.readFloatLE=function(e,t){return t||checkOffset(e,4,this.length),read(this,e,!0,23,4)},Buffer.prototype.readFloatBE=function(e,t){return t||checkOffset(e,4,this.length),read(this,e,!1,23,4)},Buffer.prototype.readDoubleLE=function(e,t){return t||checkOffset(e,8,this.length),read(this,e,!0,52,8)},Buffer.prototype.readDoubleBE=function(e,t){return t||checkOffset(e,8,this.length),read(this,e,!1,52,8)},Buffer.prototype.writeUIntLE=function(e,t,i,r){(e=+e,t|=0,i|=0,r)||checkInt(this,e,t,i,Math.pow(2,8*i)-1,0);var n=1,a=0;for(this[t]=255&e;++a<i&&(n*=256);)this[t+a]=e/n&255;return t+i},Buffer.prototype.writeUIntBE=function(e,t,i,r){(e=+e,t|=0,i|=0,r)||checkInt(this,e,t,i,Math.pow(2,8*i)-1,0);var n=i-1,a=1;for(this[t+n]=255&e;--n>=0&&(a*=256);)this[t+n]=e/a&255;return t+i},Buffer.prototype.writeUInt8=function(e,t,i){return e=+e,t|=0,i||checkInt(this,e,t,1,255,0),Buffer.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Buffer.prototype.writeUInt16LE=function(e,t,i){return e=+e,t|=0,i||checkInt(this,e,t,2,65535,0),Buffer.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):objectWriteUInt16(this,e,t,!0),t+2},Buffer.prototype.writeUInt16BE=function(e,t,i){return e=+e,t|=0,i||checkInt(this,e,t,2,65535,0),Buffer.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):objectWriteUInt16(this,e,t,!1),t+2},Buffer.prototype.writeUInt32LE=function(e,t,i){return e=+e,t|=0,i||checkInt(this,e,t,4,4294967295,0),Buffer.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):objectWriteUInt32(this,e,t,!0),t+4},Buffer.prototype.writeUInt32BE=function(e,t,i){return e=+e,t|=0,i||checkInt(this,e,t,4,4294967295,0),Buffer.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):objectWriteUInt32(this,e,t,!1),t+4},Buffer.prototype.writeIntLE=function(e,t,i,r){if(e=+e,t|=0,!r){var n=Math.pow(2,8*i-1);checkInt(this,e,t,i,n-1,-n)}var a=0,o=1,s=0;for(this[t]=255&e;++a<i&&(o*=256);)e<0&&0===s&&0!==this[t+a-1]&&(s=1),this[t+a]=(e/o|0)-s&255;return t+i},Buffer.prototype.writeIntBE=function(e,t,i,r){if(e=+e,t|=0,!r){var n=Math.pow(2,8*i-1);checkInt(this,e,t,i,n-1,-n)}var a=i-1,o=1,s=0;for(this[t+a]=255&e;--a>=0&&(o*=256);)e<0&&0===s&&0!==this[t+a+1]&&(s=1),this[t+a]=(e/o|0)-s&255;return t+i},Buffer.prototype.writeInt8=function(e,t,i){return e=+e,t|=0,i||checkInt(this,e,t,1,127,-128),Buffer.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Buffer.prototype.writeInt16LE=function(e,t,i){return e=+e,t|=0,i||checkInt(this,e,t,2,32767,-32768),Buffer.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):objectWriteUInt16(this,e,t,!0),t+2},Buffer.prototype.writeInt16BE=function(e,t,i){return e=+e,t|=0,i||checkInt(this,e,t,2,32767,-32768),Buffer.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):objectWriteUInt16(this,e,t,!1),t+2},Buffer.prototype.writeInt32LE=function(e,t,i){return e=+e,t|=0,i||checkInt(this,e,t,4,2147483647,-2147483648),Buffer.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):objectWriteUInt32(this,e,t,!0),t+4},Buffer.prototype.writeInt32BE=function(e,t,i){return e=+e,t|=0,i||checkInt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Buffer.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):objectWriteUInt32(this,e,t,!1),t+4},Buffer.prototype.writeFloatLE=function(e,t,i){return writeFloat(this,e,t,!0,i)},Buffer.prototype.writeFloatBE=function(e,t,i){return writeFloat(this,e,t,!1,i)},Buffer.prototype.writeDoubleLE=function(e,t,i){return writeDouble(this,e,t,!0,i)},Buffer.prototype.writeDoubleBE=function(e,t,i){return writeDouble(this,e,t,!1,i)},Buffer.prototype.copy=function(e,t,i,r){if(i||(i=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<i&&(r=i),r===i)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=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-i&&(r=e.length-t+i);var n,a=r-i;if(this===e&&i<t&&t<r)for(n=a-1;n>=0;--n)e[n+t]=this[n+i];else if(a<1e3||!Buffer.TYPED_ARRAY_SUPPORT)for(n=0;n<a;++n)e[n+t]=this[n+i];else Uint8Array.prototype.set.call(e,this.subarray(i,i+a),t);return a},Buffer.prototype.fill=function(e,t,i,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,i=this.length):"string"==typeof i&&(r=i,i=this.length),1===e.length){var n=e.charCodeAt(0);n<256&&(e=n)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!Buffer.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<i)throw new RangeError("Out of range index");if(i<=t)return this;var a;if(t>>>=0,i=void 0===i?this.length:i>>>0,e||(e=0),"number"==typeof e)for(a=t;a<i;++a)this[a]=e;else{var o=internalIsBuffer(e)?e:utf8ToBytes(new Buffer(e,r).toString()),s=o.length;for(a=0;a<i-t;++a)this[a+t]=o[a%s]}return this};var INVALID_BASE64_RE=/[^+\/0-9A-Za-z-_]/g,HeaderTypes;function base64clean(e){if((e=stringtrim(e).replace(INVALID_BASE64_RE,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}function stringtrim(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function toHex(e){return e<16?"0"+e.toString(16):e.toString(16)}function utf8ToBytes(e,t){var i;t=t||1/0;for(var r=e.length,n=null,a=[],o=0;o<r;++o){if((i=e.charCodeAt(o))>55295&&i<57344){if(!n){if(i>56319){(t-=3)>-1&&a.push(239,191,189);continue}if(o+1===r){(t-=3)>-1&&a.push(239,191,189);continue}n=i;continue}if(i<56320){(t-=3)>-1&&a.push(239,191,189),n=i;continue}i=65536+(n-55296<<10|i-56320)}else n&&(t-=3)>-1&&a.push(239,191,189);if(n=null,i<128){if((t-=1)<0)break;a.push(i)}else if(i<2048){if((t-=2)<0)break;a.push(i>>6|192,63&i|128)}else if(i<65536){if((t-=3)<0)break;a.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;a.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return a}function asciiToBytes(e){for(var t=[],i=0;i<e.length;++i)t.push(255&e.charCodeAt(i));return t}function utf16leToBytes(e,t){for(var i,r,n,a=[],o=0;o<e.length&&!((t-=2)<0);++o)r=(i=e.charCodeAt(o))>>8,n=i%256,a.push(n),a.push(r);return a}function base64ToBytes(e){return toByteArray(base64clean(e))}function blitBuffer(e,t,i,r){for(var n=0;n<r&&!(n+i>=t.length||n>=e.length);++n)t[n+i]=e[n];return n}function isnan(e){return e!=e}function isBuffer(e){return null!=e&&(!!e._isBuffer||isFastBuffer(e)||isSlowBuffer(e))}function isFastBuffer(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function isSlowBuffer(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&isFastBuffer(e.slice(0,0))}!function(e){e[e.BITMAP_INFO_HEADER=40]="BITMAP_INFO_HEADER",e[e.BITMAP_V2_INFO_HEADER=52]="BITMAP_V2_INFO_HEADER",e[e.BITMAP_V3_INFO_HEADER=56]="BITMAP_V3_INFO_HEADER",e[e.BITMAP_V4_HEADER=108]="BITMAP_V4_HEADER",e[e.BITMAP_V5_HEADER=124]="BITMAP_V5_HEADER"}(HeaderTypes||(HeaderTypes={}));var HeaderTypes$1=HeaderTypes,BmpCompression;function maskColor(e,t,i,r){const n=1+~e&e,a=1+~t&t,o=1+~i&i,s=1+~r&r,l=e/n+1,u=t/a+1,h=i/o+1,c=r/s+1;return{shiftRed:t=>(t&e)/n*256/l,shiftGreen:e=>(e&t)/a*256/u,shiftBlue:e=>(e&i)/o*256/h,shiftAlpha:0!==r?e=>(e&r)/s*256/c:()=>255}}!function(e){e[e.NONE=0]="NONE",e[e.BI_RLE8=1]="BI_RLE8",e[e.BI_RLE4=2]="BI_RLE4",e[e.BI_BIT_FIELDS=3]="BI_BIT_FIELDS",e[e.BI_ALPHA_BIT_FIELDS=6]="BI_ALPHA_BIT_FIELDS"}(BmpCompression||(BmpCompression={}));class BmpDecoder{flag;fileSize;reserved1;reserved2;offset;headerSize;width;height;planes;bitPP;compression;rawSize;hr;vr;colors;importantColors;palette;data;maskRed;maskGreen;maskBlue;maskAlpha;toRGBA;pos;bottomUp;buffer;locRed;locGreen;locBlue;locAlpha;shiftRed;shiftGreen;shiftBlue;shiftAlpha;constructor(e,{toRGBA:t}={toRGBA:!1}){if(this.buffer=e,this.toRGBA=!!t,this.pos=0,this.bottomUp=!0,this.flag=this.buffer.toString("utf-8",0,this.pos+=2),"BM"!==this.flag)throw new Error("Invalid BMP File");this.locRed=this.toRGBA?0:3,this.locGreen=this.toRGBA?1:2,this.locBlue=this.toRGBA?2:1,this.locAlpha=this.toRGBA?3:0,this.parseHeader(),this.parseRGBA()}parseHeader(){if(this.fileSize=this.readUInt32LE(),this.reserved1=this.buffer.readUInt16LE(this.pos),this.pos+=2,this.reserved2=this.buffer.readUInt16LE(this.pos),this.pos+=2,this.offset=this.readUInt32LE(),this.headerSize=this.readUInt32LE(),!(this.headerSize in HeaderTypes$1))throw new Error(`Unsupported BMP header size ${this.headerSize}`);if(this.width=this.readUInt32LE(),this.height=this.readUInt32LE(),this.height=this.height>2147483647?this.height-4294967296:this.height,this.planes=this.buffer.readUInt16LE(this.pos),this.pos+=2,this.bitPP=this.buffer.readUInt16LE(this.pos),this.pos+=2,this.compression=this.readUInt32LE(),this.rawSize=this.readUInt32LE(),this.hr=this.readUInt32LE(),this.vr=this.readUInt32LE(),this.colors=this.readUInt32LE(),this.importantColors=this.readUInt32LE(),32===this.bitPP?(this.maskAlpha=0,this.maskRed=16711680,this.maskGreen=65280,this.maskBlue=255):16===this.bitPP&&(this.maskAlpha=0,this.maskRed=31744,this.maskGreen=992,this.maskBlue=31),(this.headerSize>HeaderTypes$1.BITMAP_INFO_HEADER||this.compression===BmpCompression.BI_BIT_FIELDS||this.compression===BmpCompression.BI_ALPHA_BIT_FIELDS)&&(this.maskRed=this.readUInt32LE(),this.maskGreen=this.readUInt32LE(),this.maskBlue=this.readUInt32LE()),(this.headerSize>HeaderTypes$1.BITMAP_V2_INFO_HEADER||this.compression===BmpCompression.BI_ALPHA_BIT_FIELDS)&&(this.maskAlpha=this.readUInt32LE()),this.headerSize>HeaderTypes$1.BITMAP_V3_INFO_HEADER&&(this.pos+=HeaderTypes$1.BITMAP_V4_HEADER-HeaderTypes$1.BITMAP_V3_INFO_HEADER),this.headerSize>HeaderTypes$1.BITMAP_V4_HEADER&&(this.pos+=HeaderTypes$1.BITMAP_V5_HEADER-HeaderTypes$1.BITMAP_V4_HEADER),this.bitPP<=8||this.colors>0){const e=0===this.colors?1<<this.bitPP:this.colors;this.palette=new Array(e);for(let t=0;t<e;t++){const e=this.buffer.readUInt8(this.pos++),i=this.buffer.readUInt8(this.pos++),r=this.buffer.readUInt8(this.pos++),n=this.buffer.readUInt8(this.pos++);this.palette[t]={red:r,green:i,blue:e,quad:n}}}this.height<0&&(this.height*=-1,this.bottomUp=!1);const e=maskColor(this.maskRed,this.maskGreen,this.maskBlue,this.maskAlpha);this.shiftRed=e.shiftRed,this.shiftGreen=e.shiftGreen,this.shiftBlue=e.shiftBlue,this.shiftAlpha=e.shiftAlpha}parseRGBA(){switch(this.data=Buffer.alloc(this.width*this.height*4),this.bitPP){case 1:this.bit1();break;case 4:this.bit4();break;case 8:this.bit8();break;case 16:this.bit16();break;case 24:this.bit24();break;default:this.bit32()}}bit1(){const e=Math.ceil(this.width/8),t=e%4,i=0!==t?4-t:0;this.scanImage(i,e,((e,t)=>{const i=this.buffer.readUInt8(this.pos++),r=t*this.width*4+8*e*4;for(let t=0;t<8&&8*e+t<this.width;t++){const e=this.palette[i>>7-t&1];this.data[r+t*this.locAlpha]=0,this.data[r+4*t+this.locBlue]=e.blue,this.data[r+4*t+this.locGreen]=e.green,this.data[r+4*t+this.locRed]=e.red}}))}bit4(){if(this.compression===BmpCompression.BI_RLE4){this.data.fill(0);let e=!1,t=this.bottomUp?this.height-1:0,i=0;for(;i<this.data.length;){const r=this.buffer.readUInt8(this.pos++),n=this.buffer.readUInt8(this.pos++);if(0===r){if(0===n){t+=this.bottomUp?-1:1,i=t*this.width*4,e=!1;continue}if(1===n)break;if(2===n){const e=this.buffer.readUInt8(this.pos++),r=this.buffer.readUInt8(this.pos++);t+=this.bottomUp?-r:r,i+=r*this.width*4+4*e}else{let t=this.buffer.readUInt8(this.pos++);for(let r=0;r<n;r++)i=this.setPixelData(i,e?15&t:(240&t)>>4),1&r&&r+1<n&&(t=this.buffer.readUInt8(this.pos++)),e=!e;1==(n+1>>1&1)&&this.pos++}}else for(let t=0;t<r;t++)i=this.setPixelData(i,e?15&n:(240&n)>>4),e=!e}}else{const e=Math.ceil(this.width/2),t=e%4,i=0!==t?4-t:0;this.scanImage(i,e,((e,t)=>{const i=this.buffer.readUInt8(this.pos++),r=t*this.width*4+2*e*4,n=i>>4;let a=this.palette[n];if(this.data[r]=0,this.data[r+1]=a.blue,this.data[r+2]=a.green,this.data[r+3]=a.red,2*e+1>=this.width)return!1;const o=15&i;a=this.palette[o],this.data[r+4]=0,this.data[r+4+1]=a.blue,this.data[r+4+2]=a.green,this.data[r+4+3]=a.red}))}}bit8(){if(this.compression===BmpCompression.BI_RLE8){this.data.fill(0);let e=this.bottomUp?this.height-1:0,t=0;for(;t<this.data.length;){const i=this.buffer.readUInt8(this.pos++),r=this.buffer.readUInt8(this.pos++);if(0===i){if(0===r){e+=this.bottomUp?-1:1,t=e*this.width*4;continue}if(1===r)break;if(2===r){const i=this.buffer.readUInt8(this.pos++),r=this.buffer.readUInt8(this.pos++);e+=this.bottomUp?-r:r,t+=r*this.width*4+4*i}else{for(let e=0;e<r;e++){const e=this.buffer.readUInt8(this.pos++);t=this.setPixelData(t,e)}!0&r&&this.pos++}}else for(let e=0;e<i;e++)t=this.setPixelData(t,r)}}else{const e=this.width%4,t=0!==e?4-e:0;this.scanImage(t,this.width,((e,t)=>{const i=this.buffer.readUInt8(this.pos++),r=t*this.width*4+4*e;if(i<this.palette.length){const e=this.palette[i];this.data[r]=0,this.data[r+1]=e.blue,this.data[r+2]=e.green,this.data[r+3]=e.red}else this.data[r]=0,this.data[r+1]=255,this.data[r+2]=255,this.data[r+3]=255}))}}bit16(){const e=this.width%2*2;this.scanImage(e,this.width,((e,t)=>{const i=t*this.width*4+4*e,r=this.buffer.readUInt16LE(this.pos);this.pos+=2,this.data[i+this.locRed]=this.shiftRed(r),this.data[i+this.locGreen]=this.shiftGreen(r),this.data[i+this.locBlue]=this.shiftBlue(r),this.data[i+this.locAlpha]=this.shiftAlpha(r)}))}bit24(){const e=this.width%4;this.scanImage(e,this.width,((e,t)=>{const i=t*this.width*4+4*e,r=this.buffer.readUInt8(this.pos++),n=this.buffer.readUInt8(this.pos++),a=this.buffer.readUInt8(this.pos++);this.data[i+this.locRed]=a,this.data[i+this.locGreen]=n,this.data[i+this.locBlue]=r,this.data[i+this.locAlpha]=0}))}bit32(){this.scanImage(0,this.width,((e,t)=>{const i=t*this.width*4+4*e,r=this.readUInt32LE();this.data[i+this.locRed]=this.shiftRed(r),this.data[i+this.locGreen]=this.shiftGreen(r),this.data[i+this.locBlue]=this.shiftBlue(r),this.data[i+this.locAlpha]=this.shiftAlpha(r)}))}scanImage(e=0,t=this.width,i){for(let r=this.height-1;r>=0;r--){const n=this.bottomUp?r:this.height-1-r;for(let e=0;e<t;e++){if(!1===i.call(this,e,n))return}this.pos+=e}}readUInt32LE(){const e=this.buffer.readUInt32LE(this.pos);return this.pos+=4,e}setPixelData(e,t){const{blue:i,green:r,red:n}=this.palette[t];return this.data[e+this.locAlpha]=0,this.data[e+1+this.locBlue]=i,this.data[e+2+this.locGreen]=r,this.data[e+3+this.locRed]=n,e+4}}function createInteger(e){return e.reduce(((e,t)=>e<<1|t),0)}function createColor(e){return e.quad<<24|e.red<<16|e.green<<8|e.blue}class BmpEncoder{fileSize;reserved1;reserved2;offset;width;flag;height;planes;bitPP;compress;hr;vr;colors;importantColors;rawSize;headerSize;data;palette;extraBytes;buffer;bytesInColor;pos;constructor(e){switch(this.buffer=e.data,this.width=e.width,this.height=e.height,this.headerSize=HeaderTypes$1.BITMAP_INFO_HEADER,this.flag="BM",this.bitPP=e.bitPP||24,this.offset=54,this.reserved1=e.reserved1||0,this.reserved2=e.reserved2||0,this.planes=1,this.compress=0,this.hr=e.hr||0,this.vr=e.vr||0,this.importantColors=e.importantColors||0,this.colors=Math.min(2**(this.bitPP-1||1),e.colors||1/0),this.palette=e.palette||[],this.colors&&this.bitPP<16?this.offset+=4*this.colors:this.colors=0,this.bitPP){case 32:this.bytesInColor=4;break;case 16:this.bytesInColor=2;break;case 8:this.bytesInColor=1;break;case 4:this.bytesInColor=.5;break;case 1:this.bytesInColor=1/8;break;default:this.bytesInColor=3,this.bitPP=24}const t=this.width*this.bitPP/32,i=Math.ceil(t);this.extraBytes=4*(i-t),this.rawSize=this.height*i*4+2,this.fileSize=this.rawSize+this.offset,this.data=Buffer.alloc(this.fileSize,1),this.pos=0,this.encode()}encode(){switch(this.pos=0,this.writeHeader(),this.bitPP){case 32:this.bit32();break;case 16:this.bit16();break;case 8:this.bit8();break;case 4:this.bit4();break;case 1:this.bit1();break;default:this.bit24()}}writeHeader(){this.data.write(this.flag,this.pos,2),this.pos+=2,this.writeUInt32LE(this.fileSize),this.writeUInt32LE(this.reserved1<<16|this.reserved2),this.writeUInt32LE(this.offset),this.writeUInt32LE(this.headerSize),this.writeUInt32LE(this.width),this.writeUInt32LE(this.height),this.data.writeUInt16LE(this.planes,this.pos),this.pos+=2,this.data.writeUInt16LE(this.bitPP,this.pos),this.pos+=2,this.writeUInt32LE(this.compress),this.writeUInt32LE(this.rawSize),this.writeUInt32LE(this.hr),this.writeUInt32LE(this.vr),this.writeUInt32LE(this.colors),this.writeUInt32LE(this.importantColors)}bit1(){this.palette.length&&2===this.colors?this.initColors(1):(this.writeUInt32LE(16777215),this.writeUInt32LE(0)),this.pos+=1;let e=[];this.writeImage(((t,i,r)=>{let n=i;n++;const a=this.buffer[n++],o=this.buffer[n++],s=.2126*this.buffer[n++]+.7152*o+.0722*a;return e.push(s>127?0:1),(r+1)%8==0?(this.data[t-1]=createInteger(e),e=[]):r===this.width-1&&e.length>0&&(this.data[t-1]=createInteger(e)<<4,e=[]),n}))}bit4(){const e=this.initColors(4);let t=[];this.writeImage(((i,r,n)=>{let a=r;const o=createColor({quad:this.buffer[a++],blue:this.buffer[a++],green:this.buffer[a++],red:this.buffer[a++]}),s=e.findIndex((e=>e===o));return-1!==s?t.push(s):t.push(0),(n+1)%2==0&&(this.data[i]=t[0]<<4|t[1],t=[]),a}))}bit8(){const e=this.initColors(8);this.writeImage(((t,i)=>{let r=i;const n=createColor({quad:this.buffer[r++],blue:this.buffer[r++],green:this.buffer[r++],red:this.buffer[r++]}),a=e.findIndex((e=>e===n));return this.data[t]=-1!==a?a:0,r}))}bit16(){this.writeImage(((e,t)=>{let i=t+1;const r=this.buffer[i++]/8,n=this.buffer[i++]/8,a=this.buffer[i++]/8<<10|n<<5|r;return this.data[e]=255&a,this.data[e+1]=(65280&a)>>8,i}))}bit24(){this.writeImage(((e,t)=>{let i=t+1;return this.data[e]=this.buffer[i++],this.data[e+1]=this.buffer[i++],this.data[e+2]=this.buffer[i++],i}))}bit32(){this.writeImage(((e,t)=>{let i=t;return this.data[e+3]=this.buffer[i++],this.data[e]=this.buffer[i++],this.data[e+1]=this.buffer[i++],this.data[e+2]=this.buffer[i++],i}))}writeImage(e){const t=this.extraBytes+this.width*this.bytesInColor;let i=0;for(let r=0;r<this.height;r++)for(let n=0;n<this.width;n++){const a=Math.floor(this.pos+(this.height-1-r)*t+n*this.bytesInColor);i=e.call(this,a,i,n,r)}}initColors(e){const t=[];if(!this.palette.length)throw new Error(`To encode ${e}-bit BMPs a pallette is needed. Please choose up to ${this.colors} colors. Colors must be 32-bit integers.`);for(let e=0;e<this.colors;e++){const i=createColor(this.palette[e]);this.writeUInt32LE(i),t.push(i)}return t}writeUInt32LE(e){this.data.writeUInt32LE(e,this.pos),this.pos+=4}}function decode$2(e,t){return new BmpDecoder(e,t)}function encode$2(e){return new BmpEncoder(e)}function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}var trimLeft=/^\s+/,trimRight=/\s+$/;function tinycolor(e,t){if(t=t||{},(e=e||"")instanceof tinycolor)return e;if(!(this instanceof tinycolor))return new tinycolor(e,t);var i=inputToRGB(e);this._originalInput=e,this._r=i.r,this._g=i.g,this._b=i.b,this._a=i.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||i.format,this._gradientType=t.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=i.ok}function inputToRGB(e){var t={r:0,g:0,b:0},i=1,r=null,n=null,a=null,o=!1,s=!1;return"string"==typeof e&&(e=stringInputToObject(e)),"object"==_typeof(e)&&(isValidCSSUnit(e.r)&&isValidCSSUnit(e.g)&&isValidCSSUnit(e.b)?(t=rgbToRgb(e.r,e.g,e.b),o=!0,s="%"===String(e.r).substr(-1)?"prgb":"rgb"):isValidCSSUnit(e.h)&&isValidCSSUnit(e.s)&&isValidCSSUnit(e.v)?(r=convertToPercentage(e.s),n=convertToPercentage(e.v),t=hsvToRgb(e.h,r,n),o=!0,s="hsv"):isValidCSSUnit(e.h)&&isValidCSSUnit(e.s)&&isValidCSSUnit(e.l)&&(r=convertToPercentage(e.s),a=convertToPercentage(e.l),t=hslToRgb(e.h,r,a),o=!0,s="hsl"),e.hasOwnProperty("a")&&(i=e.a)),i=boundAlpha(i),{ok:o,format:e.format||s,r:Math.min(255,Math.max(t.r,0)),g:Math.min(255,Math.max(t.g,0)),b:Math.min(255,Math.max(t.b,0)),a:i}}function rgbToRgb(e,t,i){return{r:255*bound01(e,255),g:255*bound01(t,255),b:255*bound01(i,255)}}function rgbToHsl(e,t,i){e=bound01(e,255),t=bound01(t,255),i=bound01(i,255);var r,n,a=Math.max(e,t,i),o=Math.min(e,t,i),s=(a+o)/2;if(a==o)r=n=0;else{var l=a-o;switch(n=s>.5?l/(2-a-o):l/(a+o),a){case e:r=(t-i)/l+(t<i?6:0);break;case t:r=(i-e)/l+2;break;case i:r=(e-t)/l+4}r/=6}return{h:r,s:n,l:s}}function hslToRgb(e,t,i){var r,n,a;function o(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+(t-e)*(2/3-i)*6:e}if(e=bound01(e,360),t=bound01(t,100),i=bound01(i,100),0===t)r=n=a=i;else{var s=i<.5?i*(1+t):i+t-i*t,l=2*i-s;r=o(l,s,e+1/3),n=o(l,s,e),a=o(l,s,e-1/3)}return{r:255*r,g:255*n,b:255*a}}function rgbToHsv(e,t,i){e=bound01(e,255),t=bound01(t,255),i=bound01(i,255);var r,n,a=Math.max(e,t,i),o=Math.min(e,t,i),s=a,l=a-o;if(n=0===a?0:l/a,a==o)r=0;else{switch(a){case e:r=(t-i)/l+(t<i?6:0);break;case t:r=(i-e)/l+2;break;case i:r=(e-t)/l+4}r/=6}return{h:r,s:n,v:s}}function hsvToRgb(e,t,i){e=6*bound01(e,360),t=bound01(t,100),i=bound01(i,100);var r=Math.floor(e),n=e-r,a=i*(1-t),o=i*(1-n*t),s=i*(1-(1-n)*t),l=r%6;return{r:255*[i,o,a,a,s,i][l],g:255*[s,i,i,o,a,a][l],b:255*[a,a,s,i,i,o][l]}}function rgbToHex(e,t,i,r){var n=[pad2(Math.round(e).toString(16)),pad2(Math.round(t).toString(16)),pad2(Math.round(i).toString(16))];return r&&n[0].charAt(0)==n[0].charAt(1)&&n[1].charAt(0)==n[1].charAt(1)&&n[2].charAt(0)==n[2].charAt(1)?n[0].charAt(0)+n[1].charAt(0)+n[2].charAt(0):n.join("")}function rgbaToHex(e,t,i,r,n){var a=[pad2(Math.round(e).toString(16)),pad2(Math.round(t).toString(16)),pad2(Math.round(i).toString(16)),pad2(convertDecimalToHex(r))];return n&&a[0].charAt(0)==a[0].charAt(1)&&a[1].charAt(0)==a[1].charAt(1)&&a[2].charAt(0)==a[2].charAt(1)&&a[3].charAt(0)==a[3].charAt(1)?a[0].charAt(0)+a[1].charAt(0)+a[2].charAt(0)+a[3].charAt(0):a.join("")}function rgbaToArgbHex(e,t,i,r){return[pad2(convertDecimalToHex(r)),pad2(Math.round(e).toString(16)),pad2(Math.round(t).toString(16)),pad2(Math.round(i).toString(16))].join("")}function _desaturate(e,t){t=0===t?0:t||10;var i=tinycolor(e).toHsl();return i.s-=t/100,i.s=clamp01(i.s),tinycolor(i)}function _saturate(e,t){t=0===t?0:t||10;var i=tinycolor(e).toHsl();return i.s+=t/100,i.s=clamp01(i.s),tinycolor(i)}function _greyscale(e){return tinycolor(e).desaturate(100)}function _lighten(e,t){t=0===t?0:t||10;var i=tinycolor(e).toHsl();return i.l+=t/100,i.l=clamp01(i.l),tinycolor(i)}function _brighten(e,t){t=0===t?0:t||10;var i=tinycolor(e).toRgb();return i.r=Math.max(0,Math.min(255,i.r-Math.round(-t/100*255))),i.g=Math.max(0,Math.min(255,i.g-Math.round(-t/100*255))),i.b=Math.max(0,Math.min(255,i.b-Math.round(-t/100*255))),tinycolor(i)}function _darken(e,t){t=0===t?0:t||10;var i=tinycolor(e).toHsl();return i.l-=t/100,i.l=clamp01(i.l),tinycolor(i)}function _spin(e,t){var i=tinycolor(e).toHsl(),r=(i.h+t)%360;return i.h=r<0?360+r:r,tinycolor(i)}function _complement(e){var t=tinycolor(e).toHsl();return t.h=(t.h+180)%360,tinycolor(t)}function polyad(e,t){if(isNaN(t)||t<=0)throw new Error("Argument to polyad must be a positive number");for(var i=tinycolor(e).toHsl(),r=[tinycolor(e)],n=360/t,a=1;a<t;a++)r.push(tinycolor({h:(i.h+a*n)%360,s:i.s,l:i.l}));return r}function _splitcomplement(e){var t=tinycolor(e).toHsl(),i=t.h;return[tinycolor(e),tinycolor({h:(i+72)%360,s:t.s,l:t.l}),tinycolor({h:(i+216)%360,s:t.s,l:t.l})]}function _analogous(e,t,i){t=t||6,i=i||30;var r=tinycolor(e).toHsl(),n=360/i,a=[tinycolor(e)];for(r.h=(r.h-(n*t>>1)+720)%360;--t;)r.h=(r.h+n)%360,a.push(tinycolor(r));return a}function _monochromatic(e,t){t=t||6;for(var i=tinycolor(e).toHsv(),r=i.h,n=i.s,a=i.v,o=[],s=1/t;t--;)o.push(tinycolor({h:r,s:n,v:a})),a=(a+s)%1;return o}tinycolor.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(299*e.r+587*e.g+114*e.b)/1e3},getLuminance:function(){var e,t,i,r=this.toRgb();return e=r.r/255,t=r.g/255,i=r.b/255,.2126*(e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))+.7152*(t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4))+.0722*(i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4))},setAlpha:function(e){return this._a=boundAlpha(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=rgbToHsv(this._r,this._g,this._b);return{h:360*e.h,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=rgbToHsv(this._r,this._g,this._b),t=Math.round(360*e.h),i=Math.round(100*e.s),r=Math.round(100*e.v);return 1==this._a?"hsv("+t+", "+i+"%, "+r+"%)":"hsva("+t+", "+i+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var e=rgbToHsl(this._r,this._g,this._b);return{h:360*e.h,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=rgbToHsl(this._r,this._g,this._b),t=Math.round(360*e.h),i=Math.round(100*e.s),r=Math.round(100*e.l);return 1==this._a?"hsl("+t+", "+i+"%, "+r+"%)":"hsla("+t+", "+i+"%, "+r+"%, "+this._roundA+")"},toHex:function(e){return rgbToHex(this._r,this._g,this._b,e)},toHexString:function(e){return"#"+this.toHex(e)},toHex8:function(e){return rgbaToHex(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return"#"+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(100*bound01(this._r,255))+"%",g:Math.round(100*bound01(this._g,255))+"%",b:Math.round(100*bound01(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+Math.round(100*bound01(this._r,255))+"%, "+Math.round(100*bound01(this._g,255))+"%, "+Math.round(100*bound01(this._b,255))+"%)":"rgba("+Math.round(100*bound01(this._r,255))+"%, "+Math.round(100*bound01(this._g,255))+"%, "+Math.round(100*bound01(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(hexNames[rgbToHex(this._r,this._g,this._b,!0)]||!1)},toFilter:function(e){var t="#"+rgbaToArgbHex(this._r,this._g,this._b,this._a),i=t,r=this._gradientType?"GradientType = 1, ":"";if(e){var n=tinycolor(e);i="#"+rgbaToArgbHex(n._r,n._g,n._b,n._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+t+",endColorstr="+i+")"},toString:function(e){var t=!!e;e=e||this._format;var i=!1,r=this._a<1&&this._a>=0;return t||!r||"hex"!==e&&"hex6"!==e&&"hex3"!==e&&"hex4"!==e&&"hex8"!==e&&"name"!==e?("rgb"===e&&(i=this.toRgbString()),"prgb"===e&&(i=this.toPercentageRgbString()),"hex"!==e&&"hex6"!==e||(i=this.toHexString()),"hex3"===e&&(i=this.toHexString(!0)),"hex4"===e&&(i=this.toHex8String(!0)),"hex8"===e&&(i=this.toHex8String()),"name"===e&&(i=this.toName()),"hsl"===e&&(i=this.toHslString()),"hsv"===e&&(i=this.toHsvString()),i||this.toHexString()):"name"===e&&0===this._a?this.toName():this.toRgbString()},clone:function(){return tinycolor(this.toString())},_applyModification:function(e,t){var i=e.apply(null,[this].concat([].slice.call(t)));return this._r=i._r,this._g=i._g,this._b=i._b,this.setAlpha(i._a),this},lighten:function(){return this._applyModification(_lighten,arguments)},brighten:function(){return this._applyModification(_brighten,arguments)},darken:function(){return this._applyModification(_darken,arguments)},desaturate:function(){return this._applyModification(_desaturate,arguments)},saturate:function(){return this._applyModification(_saturate,arguments)},greyscale:function(){return this._applyModification(_greyscale,arguments)},spin:function(){return this._applyModification(_spin,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(_analogous,arguments)},complement:function(){return this._applyCombination(_complement,arguments)},monochromatic:function(){return this._applyCombination(_monochromatic,arguments)},splitcomplement:function(){return this._applyCombination(_splitcomplement,arguments)},triad:function(){return this._applyCombination(polyad,[3])},tetrad:function(){return this._applyCombination(polyad,[4])}},tinycolor.fromRatio=function(e,t){if("object"==_typeof(e)){var i={};for(var r in e)e.hasOwnProperty(r)&&(i[r]="a"===r?e[r]:convertToPercentage(e[r]));e=i}return tinycolor(e,t)},tinycolor.equals=function(e,t){return!(!e||!t)&&tinycolor(e).toRgbString()==tinycolor(t).toRgbString()},tinycolor.random=function(){return tinycolor.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})},tinycolor.mix=function(e,t,i){i=0===i?0:i||50;var r=tinycolor(e).toRgb(),n=tinycolor(t).toRgb(),a=i/100;return tinycolor({r:(n.r-r.r)*a+r.r,g:(n.g-r.g)*a+r.g,b:(n.b-r.b)*a+r.b,a:(n.a-r.a)*a+r.a})},tinycolor.readability=function(e,t){var i=tinycolor(e),r=tinycolor(t);return(Math.max(i.getLuminance(),r.getLuminance())+.05)/(Math.min(i.getLuminance(),r.getLuminance())+.05)},tinycolor.isReadable=function(e,t,i){var r,n,a=tinycolor.readability(e,t);switch(n=!1,(r=validateWCAG2Parms(i)).level+r.size){case"AAsmall":case"AAAlarge":n=a>=4.5;break;case"AAlarge":n=a>=3;break;case"AAAsmall":n=a>=7}return n},tinycolor.mostReadable=function(e,t,i){var r,n,a,o,s=null,l=0;n=(i=i||{}).includeFallbackColors,a=i.level,o=i.size;for(var u=0;u<t.length;u++)(r=tinycolor.readability(e,t[u]))>l&&(l=r,s=tinycolor(t[u]));return tinycolor.isReadable(e,s,{level:a,size:o})||!n?s:(i.includeFallbackColors=!1,tinycolor.mostReadable(e,["#fff","#000"],i))};var names$1=tinycolor.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},hexNames=tinycolor.hexNames=flip(names$1);function flip(e){var t={};for(var i in e)e.hasOwnProperty(i)&&(t[e[i]]=i);return t}function boundAlpha(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function bound01(e,t){isOnePointZero(e)&&(e="100%");var i=isPercentage(e);return e=Math.min(t,Math.max(0,parseFloat(e))),i&&(e=parseInt(e*t,10)/100),Math.abs(e-t)<1e-6?1:e%t/parseFloat(t)}function clamp01(e){return Math.min(1,Math.max(0,e))}function parseIntFromHex(e){return parseInt(e,16)}function isOnePointZero(e){return"string"==typeof e&&-1!=e.indexOf(".")&&1===parseFloat(e)}function isPercentage(e){return"string"==typeof e&&-1!=e.indexOf("%")}function pad2(e){return 1==e.length?"0"+e:""+e}function convertToPercentage(e){return e<=1&&(e=100*e+"%"),e}function convertDecimalToHex(e){return Math.round(255*parseFloat(e)).toString(16)}function convertHexToDecimal(e){return parseIntFromHex(e)/255}var matchers=(CSS_UNIT="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)",PERMISSIVE_MATCH3="[\\s|\\(]+("+CSS_UNIT+")[,|\\s]+("+CSS_UNIT+")[,|\\s]+("+CSS_UNIT+")\\s*\\)?",PERMISSIVE_MATCH4="[\\s|\\(]+("+CSS_UNIT+")[,|\\s]+("+CSS_UNIT+")[,|\\s]+("+CSS_UNIT+")[,|\\s]+("+CSS_UNIT+")\\s*\\)?",{CSS_UNIT:new RegExp(CSS_UNIT),rgb:new RegExp("rgb"+PERMISSIVE_MATCH3),rgba:new RegExp("rgba"+PERMISSIVE_MATCH4),hsl:new RegExp("hsl"+PERMISSIVE_MATCH3),hsla:new RegExp("hsla"+PERMISSIVE_MATCH4),hsv:new RegExp("hsv"+PERMISSIVE_MATCH3),hsva:new RegExp("hsva"+PERMISSIVE_MATCH4),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}),CSS_UNIT,PERMISSIVE_MATCH3,PERMISSIVE_MATCH4;function isValidCSSUnit(e){return!!matchers.CSS_UNIT.exec(e)}function stringInputToObject(e){e=e.replace(trimLeft,"").replace(trimRight,"").toLowerCase();var t,i=!1;if(names$1[e])e=names$1[e],i=!0;else if("transparent"==e)return{r:0,g:0,b:0,a:0,format:"name"};return(t=matchers.rgb.exec(e))?{r:t[1],g:t[2],b:t[3]}:(t=matchers.rgba.exec(e))?{r:t[1],g:t[2],b:t[3],a:t[4]}:(t=matchers.hsl.exec(e))?{h:t[1],s:t[2],l:t[3]}:(t=matchers.hsla.exec(e))?{h:t[1],s:t[2],l:t[3],a:t[4]}:(t=matchers.hsv.exec(e))?{h:t[1],s:t[2],v:t[3]}:(t=matchers.hsva.exec(e))?{h:t[1],s:t[2],v:t[3],a:t[4]}:(t=matchers.hex8.exec(e))?{r:parseIntFromHex(t[1]),g:parseIntFromHex(t[2]),b:parseIntFromHex(t[3]),a:convertHexToDecimal(t[4]),format:i?"name":"hex8"}:(t=matchers.hex6.exec(e))?{r:parseIntFromHex(t[1]),g:parseIntFromHex(t[2]),b:parseIntFromHex(t[3]),format:i?"name":"hex"}:(t=matchers.hex4.exec(e))?{r:parseIntFromHex(t[1]+""+t[1]),g:parseIntFromHex(t[2]+""+t[2]),b:parseIntFromHex(t[3]+""+t[3]),a:convertHexToDecimal(t[4]+""+t[4]),format:i?"name":"hex8"}:!!(t=matchers.hex3.exec(e))&&{r:parseIntFromHex(t[1]+""+t[1]),g:parseIntFromHex(t[2]+""+t[2]),b:parseIntFromHex(t[3]+""+t[3]),format:i?"name":"hex"}}function validateWCAG2Parms(e){var t,i;return"AA"!==(t=((e=e||{level:"AA",size:"small"}).level||"AA").toUpperCase())&&"AAA"!==t&&(t="AA"),"small"!==(i=(e.size||"small").toLowerCase())&&"large"!==i&&(i="small"),{level:t,size:i}}function clone(e){const t={width:e.bitmap.width,height:e.bitmap.height,data:Buffer.from(e.bitmap.data)};return new e.constructor(t)}function scan(e,t,i,r,n,a){let o,s,l,u,h;if("function"==typeof t)h=t,o=0,s=0,l=e.bitmap.width,u=e.bitmap.height;else{if(o=t,"number"!=typeof i)throw new Error("y must be a number");if(s=i,"number"!=typeof r)throw new Error("w must be a number");if(l=r,"number"!=typeof n)throw new Error("h must be a number");if(u=n,"function"!=typeof a)throw new Error("cb must be a function");h=a}o=Math.round(o),s=Math.round(s),l=Math.round(l),u=Math.round(u);const c=h.bind(e);for(let t=s;t<s+u;t++)for(let i=o;i<o+l;i++){c(i,t,e.bitmap.width*t+i<<2)}return e}function*scanIterator(e,t,i,r,n){t=Math.round(t),i=Math.round(i),r=Math.round(r),n=Math.round(n);for(let a=i;a<i+n;a++)for(let i=t;i<t+r;i++){const t=e.bitmap.width*a+i<<2;yield{x:i,y:a,idx:t,image:e}}}function intToRGBA$1(e){if("number"!=typeof e)throw new Error("i must be a number");const t={r:0,g:0,b:0,a:0};return t.r=Math.floor(e/Math.pow(256,3)),t.g=Math.floor((e-t.r*Math.pow(256,3))/Math.pow(256,2)),t.b=Math.floor((e-t.r*Math.pow(256,3)-t.g*Math.pow(256,2))/Math.pow(256,1)),t.a=Math.floor((e-t.r*Math.pow(256,3)-t.g*Math.pow(256,2)-t.b*Math.pow(256,1))/Math.pow(256,0)),t}function rgbaToInt(e,t,i,r){if("number"!=typeof e||"number"!=typeof t||"number"!=typeof i||"number"!=typeof r)throw new Error("r, g, b and a must be numbers");if(e<0||e>255)throw new Error("r must be between 0 and 255");if(t<0||t>255)throw new Error("g must be between 0 and 255");if(i<0||i>255)throw new Error("b must be between 0 and 255");if(r<0||r>255)throw new Error("a must be between 0 and 255");let n=255&e;return n<<=8,n|=255&t,n<<=8,n|=255&i,n<<=8,n|=255&r,n>>>=0,n}function colorDiff(e,t){const i=e=>Math.pow(e,2),{max:r}=Math,n="a"in e?e.a:255,a="a"in t?t.a:255;return(r(i(e.r-t.r),i(e.r-t.r-n+a))+r(i(e.g-t.g),i(e.g-t.g-n+a))+r(i(e.b-t.b),i(e.b-t.b-n+a)))/195075}function limit255(e){return e=Math.max(e,0),e=Math.min(e,255)}function cssColorToHex(e){return"number"==typeof e?e:parseInt(tinycolor(e).toHex8(),16)}function encode$1(e,t={}){return scan({bitmap:e},0,0,e.width,e.height,(function(t,i,r){const n=e.data[r+0],a=e.data[r+1],o=e.data[r+2],s=e.data[r+3];e.data[r+0]=s,e.data[r+1]=o,e.data[r+2]=a,e.data[r+3]=n})),encode$2({...e,...t}).data}function decode$1(e,t){const i=decode$2(e,t);return scan({bitmap:i},0,0,i.width,i.height,(function(e,t,r){const n=i.data[r+1],a=i.data[r+2],o=i.data[r+3];i.data[r+0]=o,i.data[r+1]=a,i.data[r+2]=n,i.data[r+3]=255})),i}function msBmp(){return{mime:"image/x-ms-bmp",encode:encode$1,decode:decode$1}}function bmp(){return{mime:"image/bmp",encode:encode$1,decode:decode$1}}var omggif={},GifReader_1,GifWriter_1;function GifWriter(e,t,i,r){var n=0,a=void 0===(r=void 0===r?{}:r).loop?null:r.loop,o=void 0===r.palette?null:r.palette;if(t<=0||i<=0||t>65535||i>65535)throw new Error("Width/Height invalid.");function s(e){var t=e.length;if(t<2||t>256||t&t-1)throw new Error("Invalid code/color length, must be power of 2 and 2 .. 256.");return t}e[n++]=71,e[n++]=73,e[n++]=70,e[n++]=56,e[n++]=57,e[n++]=97;var l=0,u=0;if(null!==o){for(var h=s(o);h>>=1;)++l;if(h=1<<l,--l,void 0!==r.background){if((u=r.background)>=h)throw new Error("Background index out of range.");if(0===u)throw new Error("Background index explicitly passed as 0.")}}if(e[n++]=255&t,e[n++]=t>>8&255,e[n++]=255&i,e[n++]=i>>8&255,e[n++]=(null!==o?128:0)|l,e[n++]=u,e[n++]=0,null!==o)for(var c=0,f=o.length;c<f;++c){var d=o[c];e[n++]=d>>16&255,e[n++]=d>>8&255,e[n++]=255&d}if(null!==a){if(a<0||a>65535)throw new Error("Loop count invalid.");e[n++]=33,e[n++]=255,e[n++]=11,e[n++]=78,e[n++]=69,e[n++]=84,e[n++]=83,e[n++]=67,e[n++]=65,e[n++]=80,e[n++]=69,e[n++]=50,e[n++]=46,e[n++]=48,e[n++]=3,e[n++]=1,e[n++]=255&a,e[n++]=a>>8&255,e[n++]=0}var p=!1;this.addFrame=function(t,i,r,a,l,u){if(!0===p&&(--n,p=!1),u=void 0===u?{}:u,t<0||i<0||t>65535||i>65535)throw new Error("x/y invalid.");if(r<=0||a<=0||r>65535||a>65535)throw new Error("Width/Height invalid.");if(l.length<r*a)throw new Error("Not enough pixels for the frame size.");var h=!0,c=u.palette;if(null==c&&(h=!1,c=o),null==c)throw new Error("Must supply either a local or global palette.");for(var f=s(c),d=0;f>>=1;)++d;f=1<<d;var m=void 0===u.delay?0:u.delay,_=void 0===u.disposal?0:u.disposal;if(_<0||_>3)throw new Error("Disposal out of range.");var g=!1,b=0;if(void 0!==u.transparent&&null!==u.transparent&&(g=!0,(b=u.transparent)<0||b>=f))throw new Error("Transparent color index.");if((0!==_||g||0!==m)&&(e[n++]=33,e[n++]=249,e[n++]=4,e[n++]=_<<2|(!0===g?1:0),e[n++]=255&m,e[n++]=m>>8&255,e[n++]=b,e[n++]=0),e[n++]=44,e[n++]=255&t,e[n++]=t>>8&255,e[n++]=255&i,e[n++]=i>>8&255,e[n++]=255&r,e[n++]=r>>8&255,e[n++]=255&a,e[n++]=a>>8&255,e[n++]=!0===h?128|d-1:0,!0===h)for(var y=0,w=c.length;y<w;++y){var v=c[y];e[n++]=v>>16&255,e[n++]=v>>8&255,e[n++]=255&v}return n=GifWriterOutputLZWCodeStream(e,n,d<2?2:d,l)},this.end=function(){return!1===p&&(e[n++]=59,p=!0),n},this.getOutputBuffer=function(){return e},this.setOutputBuffer=function(t){e=t},this.getOutputBufferPosition=function(){return n},this.setOutputBufferPosition=function(e){n=e}}function GifWriterOutputLZWCodeStream(e,t,i,r){e[t++]=i;var n=t++,a=1<<i,o=a-1,s=a+1,l=s+1,u=i+1,h=0,c=0;function f(i){for(;h>=i;)e[t++]=255&c,c>>=8,h-=8,t===n+256&&(e[n]=255,n=t++)}function d(e){c|=e<<h,h+=u,f(8)}var p=r[0]&o,m={};d(a);for(var _=1,g=r.length;_<g;++_){var b=r[_]&o,y=p<<8|b,w=m[y];if(void 0===w){for(c|=p<<h,h+=u;h>=8;)e[t++]=255&c,c>>=8,h-=8,t===n+256&&(e[n]=255,n=t++);4096===l?(d(a),l=s+1,u=i+1,m={}):(l>=1<<u&&++u,m[y]=l++),p=b}else p=w}return d(p),d(s),f(1),n+1===t?e[n]=0:(e[n]=t-n-1,e[t++]=0),t}function GifReader(e){var t=0;if(71!==e[t++]||73!==e[t++]||70!==e[t++]||56!==e[t++]||56!=(e[t++]+1&253)||97!==e[t++])throw new Error("Invalid GIF 87a/89a header.");var i=e[t++]|e[t++]<<8,r=e[t++]|e[t++]<<8,n=e[t++],a=n>>7,o=1<<(7&n)+1;e[t++],e[t++];var s=null,l=null;a&&(s=t,l=o,t+=3*o);var u=!0,h=[],c=0,f=null,d=0,p=null;for(this.width=i,this.height=r;u&&t<e.length;)switch(e[t++]){case 33:switch(e[t++]){case 255:if(11!==e[t]||78==e[t+1]&&69==e[t+2]&&84==e[t+3]&&83==e[t+4]&&67==e[t+5]&&65==e[t+6]&&80==e[t+7]&&69==e[t+8]&&50==e[t+9]&&46==e[t+10]&&48==e[t+11]&&3==e[t+12]&&1==e[t+13]&&0==e[t+16])t+=14,p=e[t++]|e[t++]<<8,t++;else for(t+=12;;){if(!((I=e[t++])>=0))throw Error("Invalid block size");if(0===I)break;t+=I}break;case 249:if(4!==e[t++]||0!==e[t+4])throw new Error("Invalid graphics extension block.");var m=e[t++];c=e[t++]|e[t++]<<8,f=e[t++],1&m||(f=null),d=m>>2&7,t++;break;case 254:for(;;){if(!((I=e[t++])>=0))throw Error("Invalid block size");if(0===I)break;t+=I}break;default:throw new Error("Unknown graphic control label: 0x"+e[t-1].toString(16))}break;case 44:var _=e[t++]|e[t++]<<8,g=e[t++]|e[t++]<<8,b=e[t++]|e[t++]<<8,y=e[t++]|e[t++]<<8,w=e[t++],v=w>>6&1,x=1<<(7&w)+1,E=s,k=l,S=!1;if(w>>7){S=!0;E=t,k=x,t+=3*x}var A=t;for(t++;;){var I;if(!((I=e[t++])>=0))throw Error("Invalid block size");if(0===I)break;t+=I}h.push({x:_,y:g,width:b,height:y,has_local_palette:S,palette_offset:E,palette_size:k,data_offset:A,data_length:t-A,transparent_index:f,interlaced:!!v,delay:c,disposal:d});break;case 59:u=!1;break;default:throw new Error("Unknown gif block: 0x"+e[t-1].toString(16))}this.numFrames=function(){return h.length},this.loopCount=function(){return p},this.frameInfo=function(e){if(e<0||e>=h.length)throw new Error("Frame index out of range.");return h[e]},this.decodeAndBlitFrameBGRA=function(t,r){var n=this.frameInfo(t),a=n.width*n.height,o=new Uint8Array(a);GifReaderLZWOutputIndexStream(e,n.data_offset,o,a);var s=n.palette_offset,l=n.transparent_index;null===l&&(l=256);var u=n.width,h=i-u,c=u,f=4*(n.y*i+n.x),d=4*((n.y+n.height)*i+n.x),p=f,m=4*h;!0===n.interlaced&&(m+=4*i*7);for(var _=8,g=0,b=o.length;g<b;++g){var y=o[g];if(0===c&&(c=u,(p+=m)>=d&&(m=4*h+4*i*(_-1),p=f+(u+h)*(_<<1),_>>=1)),y===l)p+=4;else{var w=e[s+3*y],v=e[s+3*y+1],x=e[s+3*y+2];r[p++]=x,r[p++]=v,r[p++]=w,r[p++]=255}--c}},this.decodeAndBlitFrameRGBA=function(t,r){var n=this.frameInfo(t),a=n.width*n.height,o=new Uint8Array(a);GifReaderLZWOutputIndexStream(e,n.data_offset,o,a);var s=n.palette_offset,l=n.transparent_index;null===l&&(l=256);var u=n.width,h=i-u,c=u,f=4*(n.y*i+n.x),d=4*((n.y+n.height)*i+n.x),p=f,m=4*h;!0===n.interlaced&&(m+=4*i*7);for(var _=8,g=0,b=o.length;g<b;++g){var y=o[g];if(0===c&&(c=u,(p+=m)>=d&&(m=4*h+4*i*(_-1),p=f+(u+h)*(_<<1),_>>=1)),y===l)p+=4;else{var w=e[s+3*y],v=e[s+3*y+1],x=e[s+3*y+2];r[p++]=w,r[p++]=v,r[p++]=x,r[p++]=255}--c}}}function GifReaderLZWOutputIndexStream(e,t,i,r){for(var n=e[t++],a=1<<n,o=a+1,s=o+1,l=n+1,u=(1<<l)-1,h=0,c=0,f=0,d=e[t++],p=new Int32Array(4096),m=null;;){for(;h<16&&0!==d;)c|=e[t++]<<h,h+=8,1===d?d=e[t++]:--d;if(h<l)break;var _=c&u;if(c>>=l,h-=l,_!==a){if(_===o)break;for(var g=_<s?_:m,b=0,y=g;y>a;)y=p[y]>>8,++b;var w=y;if(f+b+(g!==_?1:0)>r)return void console.log("Warning, gif stream longer than expected.");i[f++]=w;var v=f+=b;for(g!==_&&(i[f++]=w),y=g;b--;)y=p[y],i[--v]=255&y,y>>=8;null!==m&&s<4096&&(p[s++]=m<<8|w,s>=u+1&&l<12&&(++l,u=u<<1|1)),m=_}else s=o+1,u=(1<<(l=n+1))-1,m=null}return f!==r&&console.log("Warning, gif stream shorter than expected."),i}try{GifWriter_1=omggif.GifWriter=GifWriter,GifReader_1=omggif.GifReader=GifReader}catch(e){}let BitmapImage$2=class e{constructor(...t){if(0===t.length)throw new Error("constructor requires parameters");const i=t[0];if(null!==i&&"object"==typeof i)if(i instanceof e){const e=i.bitmap;this.bitmap={width:e.width,height:e.height,data:new Buffer(e.width*e.height*4)},e.data.copy(this.bitmap.data)}else{if(!(i.width&&i.height&&i.data))throw new Error("unrecognized constructor parameters");this.bitmap=i}else{if("number"!=typeof i||"number"!=typeof t[1])throw new Error("unrecognized constructor parameters");{const e=i,r=t[1],n=t[2];this.bitmap={width:e,height:r},Buffer.isBuffer(n)?this.bitmap.data=n:(this.bitmap.data=new Buffer(e*r*4),"number"==typeof n&&this.fillRGBA(n))}}}blit(e,t,i,r,n,a,o){if(r+a>this.bitmap.width)throw new Error("copy exceeds width of source bitmap");if(t+a>e.bitmap.width)throw new Error("copy exceeds width of target bitmap");if(n+o>this.bitmap.height)throw new Error("copy exceeds height of source bitmap");if(i+o>e.bitmap.height)throw new Erro("copy exceeds height of target bitmap");const s=this.bitmap.data,l=e.bitmap.data,u=4*this.bitmap.width,h=4*e.bitmap.width,c=4*a;let f=n*u+4*r,d=i*h+4*t;for(;--o>=0;)s.copy(l,d,f,f+c),f+=u,d+=h;return this}fillRGBA(e){const t=this.bitmap.data,i=4*this.bitmap.height;let r=0;for(;r<i;)t.writeUInt32BE(e,r),r+=4;for(;r<t.length;)t.copy(t,r,0,i),r+=i;return this}getRGBA(e,t){const i=4*(t*this.bitmap.width+e);return this.bitmap.data.readUInt32BE(i)}getRGBASet(){const e=new Set,t=this.bitmap.data;for(let i=0;i<t.length;i+=4)e.add(t.readUInt32BE(i,!0));return e}greyscale(){const e=this.bitmap.data;return this.scan(0,0,this.bitmap.width,this.bitmap.height,((t,i,r)=>{const n=Math.round(.299*e[r]+.587*e[r+1]+.114*e[r+2]);e[r]=n,e[r+1]=n,e[r+2]=n})),this}reframe(t,i,r,n,a){const o=t<0?0:t,s=i<0?0:i,l=r+o>this.bitmap.width?this.bitmap.width-o:r,u=n+s>this.bitmap.height?this.bitmap.height-s:n,h=t<0?-t:0,c=i<0?-i:0;let f;if(void 0===a){if(o!==t||s!=i||l!==r||u!==n)throw new GifError("fillRGBA required for this reframing");f=new e(r,n)}else f=new e(r,n,a);return this.blit(f,h,c,o,s,l,u),this.bitmap=f.bitmap,this}scale(e){if(1===e)return;if(!Number.isInteger(e)||e<1)throw new Error("the scale must be an integer >= 1");const t=this.bitmap.width,i=this.bitmap.height,r=t*e*4,n=this.bitmap.data,a=new Buffer(i*r*e);let o,s=0,l=0;for(let u=0;u<i;++u){o=l;for(let i=0;i<t;++i){const t=n.readUInt32BE(s,!0);for(let i=0;i<e;++i)a.writeUInt32BE(t,l),l+=4;s+=4}for(let t=1;t<e;++t)a.copy(a,l,o,l),l+=r,o+=r}return this.bitmap={width:t*e,height:i*e,data:a},this}scanAllCoords(e){const t=this.bitmap.width,i=this.bitmap.data.length;let r=0,n=0;for(let a=0;a<i;a+=4)e(r,n,a),++r===t&&(r=0,++n)}scanAllIndexes(e){const t=this.bitmap.data.length;for(let i=0;i<t;i+=4)e(i)}};var bitmapimage=BitmapImage$2,gif$1={};let Gif$1=class{constructor(e,t,i){this.width=i.width,this.height=i.height,this.loops=i.loops,this.usesTransparency=i.usesTransparency,this.colorScope=i.colorScope,this.frames=t,this.buffer=e}};Gif$1.GlobalColorsPreferred=0,Gif$1.GlobalColorsOnly=1,Gif$1.LocalColorsOnly=2;let GifError$2=class extends Error{constructor(e){super(e),e instanceof Error&&(this.stack="Gif"+e.stack)}};gif$1.Gif=Gif$1,gif$1.GifError=GifError$2;var gifcodec={},gifutil={},_polyfillNode_fs={},_polyfillNode_fs$1=Object.freeze({__proto__:null,default:_polyfillNode_fs}),require$$0=getAugmentedNamespace(_polyfillNode_fs$1),__defProp$3=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__defNormalProp$3=(e,t,i)=>t in e?__defProp$3(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,__markAsModule=e=>__defProp$3(e,"__esModule",{value:!0}),__export$1=(e,t)=>{for(var i in t)__defProp$3(e,i,{get:t[i],enumerable:!0})},__reExport=(e,t,i,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let n of __getOwnPropNames(t))!__hasOwnProp.call(e,n)&&i&&__defProp$3(e,n,{get:()=>t[n],enumerable:!(r=__getOwnPropDesc(t,n))||r.enumerable});return e},__toCommonJS=(e=>(t,i)=>e&&e.get(t)||(i=__reExport(__markAsModule({}),t,1),e&&e.set(t,i),i))("undefined"!=typeof WeakMap?new WeakMap:0),__publicField$3=(e,t,i)=>(__defNormalProp$3(e,"symbol"!=typeof t?t+"":t,i),i),src_exports={};__export$1(src_exports,{applyPalette:()=>applyPalette,applyPaletteSync:()=>applyPaletteSync$1,buildPalette:()=>buildPalette,buildPaletteSync:()=>buildPaletteSync$1,constants:()=>constants_exports$1,conversion:()=>conversion_exports$1,distance:()=>distance_exports$1,image:()=>image_exports$1,palette:()=>palette_exports$1,quality:()=>quality_exports$1,utils:()=>utils_exports$1});var constants_exports$1={};__export$1(constants_exports$1,{bt709:()=>bt709_exports$1});var bt709_exports$1={};__export$1(bt709_exports$1,{Y:()=>Y$1,x:()=>x$2,y:()=>y$2});var Y$1=(e=>(e[e.RED=.2126]="RED",e[e.GREEN=.7152]="GREEN",e[e.BLUE=.0722]="BLUE",e[e.WHITE=1]="WHITE",e))(Y$1||{}),x$2=(e=>(e[e.RED=.64]="RED",e[e.GREEN=.3]="GREEN",e[e.BLUE=.15]="BLUE",e[e.WHITE=.3127]="WHITE",e))(x$2||{}),y$2=(e=>(e[e.RED=.33]="RED",e[e.GREEN=.6]="GREEN",e[e.BLUE=.06]="BLUE",e[e.WHITE=.329]="WHITE",e))(y$2||{}),conversion_exports$1={};function correctGamma$1(e){return e>.04045?((e+.055)/1.055)**2.4:e/12.92}function rgb2xyz$1(e,t,i){return{x:.4124*(e=correctGamma$1(e/255))+.3576*(t=correctGamma$1(t/255))+.1805*(i=correctGamma$1(i/255)),y:.2126*e+.7152*t+.0722*i,z:.0193*e+.1192*t+.9505*i}}__export$1(conversion_exports$1,{lab2rgb:()=>lab2rgb$1,lab2xyz:()=>lab2xyz$1,rgb2hsl:()=>rgb2hsl$1,rgb2lab:()=>rgb2lab$1,rgb2xyz:()=>rgb2xyz$1,xyz2lab:()=>xyz2lab$1,xyz2rgb:()=>xyz2rgb$1});var arithmetic_exports$1={};function degrees2radians$1(e){return e*(Math.PI/180)}function max3$1(e,t,i){let r=e;return r<t&&(r=t),r<i&&(r=i),r}function min3$1(e,t,i){let r=e;return r>t&&(r=t),r>i&&(r=i),r}function intInRange$1(e,t,i){return e>i&&(e=i),e<t&&(e=t),0|e}function inRange0to255Rounded$1(e){return(e=Math.round(e))>255?e=255:e<0&&(e=0),e}function inRange0to255$1(e){return e>255?e=255:e<0&&(e=0),e}function stableSort$1(e,t){const i=typeof e[0];let r;if("number"===i||"string"===i){const i=Object.create(null);for(let t=0,r=e.length;t<r;t++){const r=e[t];i[r]||0===i[r]||(i[r]=t)}r=e.sort(((e,r)=>t(e,r)||i[e]-i[r]))}else{const i=e.slice(0);r=e.sort(((e,r)=>t(e,r)||i.indexOf(e)-i.indexOf(r)))}return r}function rgb2hsl$1(e,t,i){const r=min3$1(e,t,i),n=max3$1(e,t,i),a=n-r,o=(r+n)/510;let s=0;o>0&&o<1&&(s=a/(o<.5?n+r:510-n-r));let l=0;return a>0&&(l=n===e?(t-i)/a:n===t?2+(i-e)/a:4+(e-t)/a,l*=60,l<0&&(l+=360)),{h:l,s:s,l:o}}__export$1(arithmetic_exports$1,{degrees2radians:()=>degrees2radians$1,inRange0to255:()=>inRange0to255$1,inRange0to255Rounded:()=>inRange0to255Rounded$1,intInRange:()=>intInRange$1,max3:()=>max3$1,min3:()=>min3$1,stableSort:()=>stableSort$1});var refX$1=.95047,refY$1=1,refZ$1=1.08883;function pivot$1(e){return e>.008856?e**(1/3):7.787*e+16/116}function xyz2lab$1(e,t,i){if(e=pivot$1(e/refX$1),t=pivot$1(t/refY$1),i=pivot$1(i/refZ$1),116*t-16<0)throw new Error("xxx");return{L:Math.max(0,116*t-16),a:500*(e-t),b:200*(t-i)}}function rgb2lab$1(e,t,i){const r=rgb2xyz$1(e,t,i);return xyz2lab$1(r.x,r.y,r.z)}var refX2$1=.95047,refY2$1=1,refZ2$1=1.08883;function pivot2$1(e){return e>.206893034?e**3:(e-16/116)/7.787}function lab2xyz$1(e,t,i){const r=(e+16)/116,n=r-i/200;return{x:refX2$1*pivot2$1(t/500+r),y:refY2$1*pivot2$1(r),z:refZ2$1*pivot2$1(n)}}function correctGamma2$1(e){return e>.0031308?1.055*e**(1/2.4)-.055:12.92*e}function xyz2rgb$1(e,t,i){const r=correctGamma2$1(3.2406*e+-1.5372*t+-.4986*i),n=correctGamma2$1(-.9689*e+1.8758*t+.0415*i),a=correctGamma2$1(.0557*e+-.204*t+1.057*i);return{r:inRange0to255Rounded$1(255*r),g:inRange0to255Rounded$1(255*n),b:inRange0to255Rounded$1(255*a)}}function lab2rgb$1(e,t,i){const r=lab2xyz$1(e,t,i);return xyz2rgb$1(r.x,r.y,r.z)}var distance_exports$1={};__export$1(distance_exports$1,{AbstractDistanceCalculator:()=>AbstractDistanceCalculator$1,AbstractEuclidean:()=>AbstractEuclidean$1,AbstractManhattan:()=>AbstractManhattan$1,CIE94GraphicArts:()=>CIE94GraphicArts$1,CIE94Textiles:()=>CIE94Textiles$1,CIEDE2000:()=>CIEDE2000$1,CMetric:()=>CMetric$1,Euclidean:()=>Euclidean$1,EuclideanBT709:()=>EuclideanBT709$1,EuclideanBT709NoAlpha:()=>EuclideanBT709NoAlpha$1,Manhattan:()=>Manhattan$1,ManhattanBT709:()=>ManhattanBT709$1,ManhattanNommyde:()=>ManhattanNommyde$1,PNGQuant:()=>PNGQuant$1});var AbstractDistanceCalculator$1=class{constructor(){__publicField$3(this,"_maxDistance"),__publicField$3(this,"_whitePoint"),this._setDefaults(),this.setWhitePoint(255,255,255,255)}setWhitePoint(e,t,i,r){this._whitePoint={r:e>0?255/e:0,g:t>0?255/t:0,b:i>0?255/i:0,a:r>0?255/r:0},this._maxDistance=this.calculateRaw(e,t,i,r,0,0,0,0)}calculateNormalized(e,t){return this.calculateRaw(e.r,e.g,e.b,e.a,t.r,t.g,t.b,t.a)/this._maxDistance}},AbstractCIE94$1=class extends AbstractDistanceCalculator$1{calculateRaw(e,t,i,r,n,a,o,s){const l=rgb2lab$1(inRange0to255$1(e*this._whitePoint.r),inRange0to255$1(t*this._whitePoint.g),inRange0to255$1(i*this._whitePoint.b)),u=rgb2lab$1(inRange0to255$1(n*this._whitePoint.r),inRange0to255$1(a*this._whitePoint.g),inRange0to255$1(o*this._whitePoint.b)),h=l.L-u.L,c=l.a-u.a,f=l.b-u.b,d=Math.sqrt(l.a*l.a+l.b*l.b),p=d-Math.sqrt(u.a*u.a+u.b*u.b);let m=c*c+f*f-p*p;m=m<0?0:Math.sqrt(m);const _=(s-r)*this._whitePoint.a*this._kA;return Math.sqrt((h/this._Kl)**2+(p/(1+this._K1*d))**2+(m/(1+this._K2*d))**2+_**2)}},CIE94Textiles$1=class extends AbstractCIE94$1{_setDefaults(){this._Kl=2,this._K1=.048,this._K2=.014,this._kA=12.5/255}},CIE94GraphicArts$1=class extends AbstractCIE94$1{_setDefaults(){this._Kl=1,this._K1=.045,this._K2=.015,this._kA=25/255}},_CIEDE2000$1=class extends AbstractDistanceCalculator$1{_setDefaults(){}static _calculatehp(e,t){const i=Math.atan2(e,t);return i>=0?i:i+_CIEDE2000$1._deg360InRad}static _calculateRT(e,t){const i=t**7,r=2*Math.sqrt(i/(i+_CIEDE2000$1._pow25to7)),n=_CIEDE2000$1._deg30InRad*Math.exp(-(((e-_CIEDE2000$1._deg275InRad)/_CIEDE2000$1._deg25InRad)**2));return-Math.sin(2*n)*r}static _calculateT(e){return 1-.17*Math.cos(e-_CIEDE2000$1._deg30InRad)+.24*Math.cos(2*e)+.32*Math.cos(3*e+_CIEDE2000$1._deg6InRad)-.2*Math.cos(4*e-_CIEDE2000$1._deg63InRad)}static _calculate_ahp(e,t,i,r){const n=i+r;return 0===e?n:t<=_CIEDE2000$1._deg180InRad?n/2:n<_CIEDE2000$1._deg360InRad?(n+_CIEDE2000$1._deg360InRad)/2:(n-_CIEDE2000$1._deg360InRad)/2}static _calculate_dHp(e,t,i,r){let n;return n=0===e?0:t<=_CIEDE2000$1._deg180InRad?i-r:i<=r?i-r+_CIEDE2000$1._deg360InRad:i-r-_CIEDE2000$1._deg360InRad,2*Math.sqrt(e)*Math.sin(n/2)}calculateRaw(e,t,i,r,n,a,o,s){const l=rgb2lab$1(inRange0to255$1(e*this._whitePoint.r),inRange0to255$1(t*this._whitePoint.g),inRange0to255$1(i*this._whitePoint.b)),u=rgb2lab$1(inRange0to255$1(n*this._whitePoint.r),inRange0to255$1(a*this._whitePoint.g),inRange0to255$1(o*this._whitePoint.b)),h=(s-r)*this._whitePoint.a*_CIEDE2000$1._kA,c=this.calculateRawInLab(l,u);return Math.sqrt(c+h*h)}calculateRawInLab(e,t){const i=e.L,r=e.a,n=e.b,a=t.L,o=t.a,s=t.b,l=((Math.sqrt(r*r+n*n)+Math.sqrt(o*o+s*s))/2)**7,u=.5*(1-Math.sqrt(l/(l+_CIEDE2000$1._pow25to7))),h=(1+u)*r,c=(1+u)*o,f=Math.sqrt(h*h+n*n),d=Math.sqrt(c*c+s*s),p=f*d,m=_CIEDE2000$1._calculatehp(n,h),_=_CIEDE2000$1._calculatehp(s,c),g=Math.abs(m-_),b=a-i,y=d-f,w=_CIEDE2000$1._calculate_dHp(p,g,_,m),v=_CIEDE2000$1._calculate_ahp(p,g,m,_),x=(f+d)/2,E=((i+a)/2-50)**2,k=y/(1+.045*x),S=w/(1+.015*_CIEDE2000$1._calculateT(v)*x);return(b/(1+.015*E/Math.sqrt(20+E)))**2+k**2+S**2+_CIEDE2000$1._calculateRT(v,x)*k*S}},CIEDE2000$1=_CIEDE2000$1;__publicField$3(CIEDE2000$1,"_kA",25/255),__publicField$3(CIEDE2000$1,"_pow25to7",25**7),__publicField$3(CIEDE2000$1,"_deg360InRad",degrees2radians$1(360)),__publicField$3(CIEDE2000$1,"_deg180InRad",degrees2radians$1(180)),__publicField$3(CIEDE2000$1,"_deg30InRad",degrees2radians$1(30)),__publicField$3(CIEDE2000$1,"_deg6InRad",degrees2radians$1(6)),__publicField$3(CIEDE2000$1,"_deg63InRad",degrees2radians$1(63)),__publicField$3(CIEDE2000$1,"_deg275InRad",degrees2radians$1(275)),__publicField$3(CIEDE2000$1,"_deg25InRad",degrees2radians$1(25));var CMetric$1=class extends AbstractDistanceCalculator$1{calculateRaw(e,t,i,r,n,a,o,s){const l=(e+n)/2*this._whitePoint.r,u=(e-n)*this._whitePoint.r,h=(t-a)*this._whitePoint.g,c=(i-o)*this._whitePoint.b,f=((512+l)*u*u>>8)+4*h*h+((767-l)*c*c>>8),d=(s-r)*this._whitePoint.a;return Math.sqrt(f+d*d)}_setDefaults(){}},AbstractEuclidean$1=class extends AbstractDistanceCalculator$1{calculateRaw(e,t,i,r,n,a,o,s){const l=n-e,u=a-t,h=o-i,c=s-r;return Math.sqrt(this._kR*l*l+this._kG*u*u+this._kB*h*h+this._kA*c*c)}},Euclidean$1=class extends AbstractEuclidean$1{_setDefaults(){this._kR=1,this._kG=1,this._kB=1,this._kA=1}},EuclideanBT709$1=class extends AbstractEuclidean$1{_setDefaults(){this._kR=.2126,this._kG=.7152,this._kB=.0722,this._kA=1}},EuclideanBT709NoAlpha$1=class extends AbstractEuclidean$1{_setDefaults(){this._kR=.2126,this._kG=.7152,this._kB=.0722,this._kA=0}},AbstractManhattan$1=class extends AbstractDistanceCalculator$1{calculateRaw(e,t,i,r,n,a,o,s){let l=n-e,u=a-t,h=o-i,c=s-r;return l<0&&(l=0-l),u<0&&(u=0-u),h<0&&(h=0-h),c<0&&(c=0-c),this._kR*l+this._kG*u+this._kB*h+this._kA*c}},Manhattan$1=class extends AbstractManhattan$1{_setDefaults(){this._kR=1,this._kG=1,this._kB=1,this._kA=1}},ManhattanNommyde$1=class extends AbstractManhattan$1{_setDefaults(){this._kR=.4984,this._kG=.8625,this._kB=.2979,this._kA=1}},ManhattanBT709$1=class extends AbstractManhattan$1{_setDefaults(){this._kR=.2126,this._kG=.7152,this._kB=.0722,this._kA=1}},PNGQuant$1=class extends AbstractDistanceCalculator$1{calculateRaw(e,t,i,r,n,a,o,s){const l=(s-r)*this._whitePoint.a;return this._colordifferenceCh(e*this._whitePoint.r,n*this._whitePoint.r,l)+this._colordifferenceCh(t*this._whitePoint.g,a*this._whitePoint.g,l)+this._colordifferenceCh(i*this._whitePoint.b,o*this._whitePoint.b,l)}_colordifferenceCh(e,t,i){const r=e-t,n=r+i;return r*r+n*n}_setDefaults(){}},palette_exports$1={};__export$1(palette_exports$1,{AbstractPaletteQuantizer:()=>AbstractPaletteQuantizer$1,ColorHistogram:()=>ColorHistogram$1,NeuQuant:()=>NeuQuant$1,NeuQuantFloat:()=>NeuQuantFloat$1,RGBQuant:()=>RGBQuant$1,WuColorCube:()=>WuColorCube$1,WuQuant:()=>WuQuant$1});var AbstractPaletteQuantizer$1=class{quantizeSync(){for(const e of this.quantize())if(e.palette)return e.palette;throw new Error("unreachable")}},Point$1=class{constructor(){__publicField$3(this,"r"),__publicField$3(this,"g"),__publicField$3(this,"b"),__publicField$3(this,"a"),__publicField$3(this,"uint32"),__publicField$3(this,"rgba"),this.uint32=-1>>>0,this.r=this.g=this.b=this.a=0,this.rgba=new Array(4),this.rgba[0]=0,this.rgba[1]=0,this.rgba[2]=0,this.rgba[3]=0}static createByQuadruplet(e){const t=new Point$1;return t.r=0|e[0],t.g=0|e[1],t.b=0|e[2],t.a=0|e[3],t._loadUINT32(),t._loadQuadruplet(),t}static createByRGBA(e,t,i,r){const n=new Point$1;return n.r=0|e,n.g=0|t,n.b=0|i,n.a=0|r,n._loadUINT32(),n._loadQuadruplet(),n}static createByUint32(e){const t=new Point$1;return t.uint32=e>>>0,t._loadRGBA(),t._loadQuadruplet(),t}from(e){this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a,this.uint32=e.uint32,this.rgba[0]=e.r,this.rgba[1]=e.g,this.rgba[2]=e.b,this.rgba[3]=e.a}getLuminosity(e){let t=this.r,i=this.g,r=this.b;return e&&(t=Math.min(255,255-this.a+this.a*t/255),i=Math.min(255,255-this.a+this.a*i/255),r=Math.min(255,255-this.a+this.a*r/255)),.2126*t+.7152*i+.0722*r}_loadUINT32(){this.uint32=(this.a<<24|this.b<<16|this.g<<8|this.r)>>>0}_loadRGBA(){this.r=255&this.uint32,this.g=this.uint32>>>8&255,this.b=this.uint32>>>16&255,this.a=this.uint32>>>24&255}_loadQuadruplet(){this.rgba[0]=this.r,this.rgba[1]=this.g,this.rgba[2]=this.b,this.rgba[3]=this.a}},PointContainer$1=class{constructor(){__publicField$3(this,"_pointArray"),__publicField$3(this,"_width"),__publicField$3(this,"_height"),this._width=0,this._height=0,this._pointArray=[]}getWidth(){return this._width}getHeight(){return this._height}setWidth(e){this._width=e}setHeight(e){this._height=e}getPointArray(){return this._pointArray}clone(){const e=new PointContainer$1;e._width=this._width,e._height=this._height;for(let t=0,i=this._pointArray.length;t<i;t++)e._pointArray[t]=Point$1.createByUint32(0|this._pointArray[t].uint32);return e}toUint32Array(){const e=this._pointArray.length,t=new Uint32Array(e);for(let i=0;i<e;i++)t[i]=this._pointArray[i].uint32;return t}toUint8Array(){return new Uint8Array(this.toUint32Array().buffer)}static fromHTMLImageElement(e){const t=e.naturalWidth,i=e.naturalHeight,r=document.createElement("canvas");r.width=t,r.height=i;return r.getContext("2d").drawImage(e,0,0,t,i,0,0,t,i),PointContainer$1.fromHTMLCanvasElement(r)}static fromHTMLCanvasElement(e){const t=e.width,i=e.height,r=e.getContext("2d").getImageData(0,0,t,i);return PointContainer$1.fromImageData(r)}static fromImageData(e){const t=e.width,i=e.height;return PointContainer$1.fromUint8Array(e.data,t,i)}static fromUint8Array(e,t,i){switch(Object.prototype.toString.call(e)){case"[object Uint8ClampedArray]":case"[object Uint8Array]":break;default:e=new Uint8Array(e)}const r=new Uint32Array(e.buffer);return PointContainer$1.fromUint32Array(r,t,i)}static fromUint32Array(e,t,i){const r=new PointContainer$1;r._width=t,r._height=i;for(let t=0,i=e.length;t<i;t++)r._pointArray[t]=Point$1.createByUint32(0|e[t]);return r}static fromBuffer(e,t,i){const r=new Uint32Array(e.buffer,e.byteOffset,e.byteLength/Uint32Array.BYTES_PER_ELEMENT);return PointContainer$1.fromUint32Array(r,t,i)}},hueGroups$1=10;function hueGroup$1(e,t){const i=360/t;for(let r=1,n=i-i/2;r<t;r++,n+=i)if(e>=n&&e<n+i)return r;return 0}var Palette$1=class{constructor(){__publicField$3(this,"_pointContainer"),__publicField$3(this,"_pointArray",[]),__publicField$3(this,"_i32idx",{}),this._pointContainer=new PointContainer$1,this._pointContainer.setHeight(1),this._pointArray=this._pointContainer.getPointArray()}add(e){this._pointArray.push(e),this._pointContainer.setWidth(this._pointArray.length)}has(e){for(let t=this._pointArray.length-1;t>=0;t--)if(e.uint32===this._pointArray[t].uint32)return!0;return!1}getNearestColor(e,t){return this._pointArray[0|this._getNearestIndex(e,t)]}getPointContainer(){return this._pointContainer}_nearestPointFromCache(e){return"number"==typeof this._i32idx[e]?this._i32idx[e]:-1}_getNearestIndex(e,t){let i=this._nearestPointFromCache(""+t.uint32);if(i>=0)return i;let r=Number.MAX_VALUE;i=0;for(let n=0,a=this._pointArray.length;n<a;n++){const a=this._pointArray[n],o=e.calculateRaw(t.r,t.g,t.b,t.a,a.r,a.g,a.b,a.a);o<r&&(r=o,i=n)}return this._i32idx[t.uint32]=i,i}sort(){this._i32idx={},this._pointArray.sort(((e,t)=>{const i=rgb2hsl$1(e.r,e.g,e.b),r=rgb2hsl$1(t.r,t.g,t.b),n=e.r===e.g&&e.g===e.b?0:1+hueGroup$1(i.h,hueGroups$1),a=(t.r===t.g&&t.g===t.b?0:1+hueGroup$1(r.h,hueGroups$1))-n;if(a)return-a;const o=e.getLuminosity(!0),s=t.getLuminosity(!0);if(s-o!=0)return s-o;const l=(100*r.s|0)-(100*i.s|0);return l?-l:0}))}},utils_exports$1={};__export$1(utils_exports$1,{HueStatistics:()=>HueStatistics$1,Palette:()=>Palette$1,Point:()=>Point$1,PointContainer:()=>PointContainer$1,ProgressTracker:()=>ProgressTracker$1,arithmetic:()=>arithmetic_exports$1});var HueGroup$1=class{constructor(){__publicField$3(this,"num",0),__publicField$3(this,"cols",[])}},HueStatistics$1=class{constructor(e,t){__publicField$3(this,"_numGroups"),__publicField$3(this,"_minCols"),__publicField$3(this,"_stats"),__publicField$3(this,"_groupsFull"),this._numGroups=e,this._minCols=t,this._stats=[];for(let t=0;t<=e;t++)this._stats[t]=new HueGroup$1;this._groupsFull=0}check(e){this._groupsFull===this._numGroups+1&&(this.check=()=>{});const t=255&e,i=e>>>8&255,r=e>>>16&255,n=t===i&&i===r?0:1+hueGroup$1(rgb2hsl$1(t,i,r).h,this._numGroups),a=this._stats[n],o=this._minCols;a.num++,a.num>o||(a.num===o&&this._groupsFull++,a.num<=o&&this._stats[n].cols.push(e))}injectIntoDictionary(e){for(let t=0;t<=this._numGroups;t++)this._stats[t].num<=this._minCols&&this._stats[t].cols.forEach((t=>{e[t]?e[t]++:e[t]=1}))}injectIntoArray(e){for(let t=0;t<=this._numGroups;t++)this._stats[t].num<=this._minCols&&this._stats[t].cols.forEach((t=>{-1===e.indexOf(t)&&e.push(t)}))}},_ProgressTracker$1=class{constructor(e,t){__publicField$3(this,"progress"),__publicField$3(this,"_step"),__publicField$3(this,"_range"),__publicField$3(this,"_last"),__publicField$3(this,"_progressRange"),this._range=e,this._progressRange=t,this._step=Math.max(1,this._range/(_ProgressTracker$1.steps+1)|0),this._last=-this._step,this.progress=0}shouldNotify(e){return e-this._last>=this._step&&(this._last=e,this.progress=Math.min(this._progressRange*this._last/this._range,this._progressRange),!0)}},ProgressTracker$1=_ProgressTracker$1;__publicField$3(ProgressTracker$1,"steps",100);var networkBiasShift$1=3,Neuron$1=class{constructor(e){__publicField$3(this,"r"),__publicField$3(this,"g"),__publicField$3(this,"b"),__publicField$3(this,"a"),this.r=this.g=this.b=this.a=e}toPoint(){return Point$1.createByRGBA(this.r>>networkBiasShift$1,this.g>>networkBiasShift$1,this.b>>networkBiasShift$1,this.a>>networkBiasShift$1)}subtract(e,t,i,r){this.r-=0|e,this.g-=0|t,this.b-=0|i,this.a-=0|r}},_NeuQuant$1=class extends AbstractPaletteQuantizer$1{constructor(e,t=256){super(),__publicField$3(this,"_pointArray"),__publicField$3(this,"_networkSize"),__publicField$3(this,"_network"),__publicField$3(this,"_sampleFactor"),__publicField$3(this,"_radPower"),__publicField$3(this,"_freq"),__publicField$3(this,"_bias"),__publicField$3(this,"_distance"),this._distance=e,this._pointArray=[],this._sampleFactor=1,this._networkSize=t,this._distance.setWhitePoint(255<<networkBiasShift$1,255<<networkBiasShift$1,255<<networkBiasShift$1,255<<networkBiasShift$1)}sample(e){this._pointArray=this._pointArray.concat(e.getPointArray())}*quantize(){this._init(),yield*this._learn(),yield{palette:this._buildPalette(),progress:100}}_init(){this._freq=[],this._bias=[],this._radPower=[],this._network=[];for(let e=0;e<this._networkSize;e++)this._network[e]=new Neuron$1((e<<networkBiasShift$1+8)/this._networkSize|0),this._freq[e]=_NeuQuant$1._initialBias/this._networkSize|0,this._bias[e]=0}*_learn(){let e=this._sampleFactor;const t=this._pointArray.length;t<_NeuQuant$1._minpicturebytes&&(e=1);const i=30+(e-1)/3|0,r=t/e|0;let n,a=r/_NeuQuant$1._nCycles|0,o=_NeuQuant$1._initAlpha,s=(this._networkSize>>3)*_NeuQuant$1._radiusBias,l=s>>_NeuQuant$1._radiusBiasShift;l<=1&&(l=0);for(let e=0;e<l;e++)this._radPower[e]=o*((l*l-e*e)*_NeuQuant$1._radBias/(l*l))>>>0;n=t<_NeuQuant$1._minpicturebytes?1:t%_NeuQuant$1._prime1!=0?_NeuQuant$1._prime1:t%_NeuQuant$1._prime2!=0?_NeuQuant$1._prime2:t%_NeuQuant$1._prime3!=0?_NeuQuant$1._prime3:_NeuQuant$1._prime4;const u=new ProgressTracker$1(r,99);for(let e=0,h=0;e<r;){u.shouldNotify(e)&&(yield{progress:u.progress});const r=this._pointArray[h],c=r.b<<networkBiasShift$1,f=r.g<<networkBiasShift$1,d=r.r<<networkBiasShift$1,p=r.a<<networkBiasShift$1,m=this._contest(c,f,d,p);if(this._alterSingle(o,m,c,f,d,p),0!==l&&this._alterNeighbour(l,m,c,f,d,p),h+=n,h>=t&&(h-=t),e++,0===a&&(a=1),e%a==0){o-=o/i|0,s-=s/_NeuQuant$1._radiusDecrease|0,l=s>>_NeuQuant$1._radiusBiasShift,l<=1&&(l=0);for(let e=0;e<l;e++)this._radPower[e]=o*((l*l-e*e)*_NeuQuant$1._radBias/(l*l))>>>0}}}_buildPalette(){const e=new Palette$1;return this._network.forEach((t=>{e.add(t.toPoint())})),e.sort(),e}_alterNeighbour(e,t,i,r,n,a){let o=t-e;o<-1&&(o=-1);let s=t+e;s>this._networkSize&&(s=this._networkSize);let l=t+1,u=t-1,h=1;for(;l<s||u>o;){const e=this._radPower[h++]/_NeuQuant$1._alphaRadBias;if(l<s){const t=this._network[l++];t.subtract(e*(t.r-n),e*(t.g-r),e*(t.b-i),e*(t.a-a))}if(u>o){const t=this._network[u--];t.subtract(e*(t.r-n),e*(t.g-r),e*(t.b-i),e*(t.a-a))}}}_alterSingle(e,t,i,r,n,a){e/=_NeuQuant$1._initAlpha;const o=this._network[t];o.subtract(e*(o.r-n),e*(o.g-r),e*(o.b-i),e*(o.a-a))}_contest(e,t,i,r){const n=1020<<networkBiasShift$1;let a=~(1<<31),o=a,s=-1,l=s;for(let u=0;u<this._networkSize;u++){const h=this._network[u],c=this._distance.calculateNormalized(h,{r:i,g:t,b:e,a:r})*n|0;c<a&&(a=c,s=u);const f=c-(this._bias[u]>>_NeuQuant$1._initialBiasShift-networkBiasShift$1);f<o&&(o=f,l=u);const d=this._freq[u]>>_NeuQuant$1._betaShift;this._freq[u]-=d,this._bias[u]+=d<<_NeuQuant$1._gammaShift}return this._freq[s]+=_NeuQuant$1._beta,this._bias[s]-=_NeuQuant$1._betaGamma,l}},NeuQuant$1=_NeuQuant$1;__publicField$3(NeuQuant$1,"_prime1",499),__publicField$3(NeuQuant$1,"_prime2",491),__publicField$3(NeuQuant$1,"_prime3",487),__publicField$3(NeuQuant$1,"_prime4",503),__publicField$3(NeuQuant$1,"_minpicturebytes",_NeuQuant$1._prime4),__publicField$3(NeuQuant$1,"_nCycles",100),__publicField$3(NeuQuant$1,"_initialBiasShift",16),__publicField$3(NeuQuant$1,"_initialBias",1<<_NeuQuant$1._initialBiasShift),__publicField$3(NeuQuant$1,"_gammaShift",10),__publicField$3(NeuQuant$1,"_betaShift",10),__publicField$3(NeuQuant$1,"_beta",_NeuQuant$1._initialBias>>_NeuQuant$1._betaShift),__publicField$3(NeuQuant$1,"_betaGamma",_NeuQuant$1._initialBias<<_NeuQuant$1._gammaShift-_NeuQuant$1._betaShift),__publicField$3(NeuQuant$1,"_radiusBiasShift",6),__publicField$3(NeuQuant$1,"_radiusBias",1<<_NeuQuant$1._radiusBiasShift),__publicField$3(NeuQuant$1,"_radiusDecrease",30),__publicField$3(NeuQuant$1,"_alphaBiasShift",10),__publicField$3(NeuQuant$1,"_initAlpha",1<<_NeuQuant$1._alphaBiasShift),__publicField$3(NeuQuant$1,"_radBiasShift",8),__publicField$3(NeuQuant$1,"_radBias",1<<_NeuQuant$1._radBiasShift),__publicField$3(NeuQuant$1,"_alphaRadBiasShift",_NeuQuant$1._alphaBiasShift+_NeuQuant$1._radBiasShift),__publicField$3(NeuQuant$1,"_alphaRadBias",1<<_NeuQuant$1._alphaRadBiasShift);var networkBiasShift2$1=3,NeuronFloat$1=class{constructor(e){__publicField$3(this,"r"),__publicField$3(this,"g"),__publicField$3(this,"b"),__publicField$3(this,"a"),this.r=this.g=this.b=this.a=e}toPoint(){return Point$1.createByRGBA(this.r>>networkBiasShift2$1,this.g>>networkBiasShift2$1,this.b>>networkBiasShift2$1,this.a>>networkBiasShift2$1)}subtract(e,t,i,r){this.r-=e,this.g-=t,this.b-=i,this.a-=r}},_NeuQuantFloat$1=class extends AbstractPaletteQuantizer$1{constructor(e,t=256){super(),__publicField$3(this,"_pointArray"),__publicField$3(this,"_networkSize"),__publicField$3(this,"_network"),__publicField$3(this,"_sampleFactor"),__publicField$3(this,"_radPower"),__publicField$3(this,"_freq"),__publicField$3(this,"_bias"),__publicField$3(this,"_distance"),this._distance=e,this._pointArray=[],this._sampleFactor=1,this._networkSize=t,this._distance.setWhitePoint(255<<networkBiasShift2$1,255<<networkBiasShift2$1,255<<networkBiasShift2$1,255<<networkBiasShift2$1)}sample(e){this._pointArray=this._pointArray.concat(e.getPointArray())}*quantize(){this._init(),yield*this._learn(),yield{palette:this._buildPalette(),progress:100}}_init(){this._freq=[],this._bias=[],this._radPower=[],this._network=[];for(let e=0;e<this._networkSize;e++)this._network[e]=new NeuronFloat$1((e<<networkBiasShift2$1+8)/this._networkSize),this._freq[e]=_NeuQuantFloat$1._initialBias/this._networkSize,this._bias[e]=0}*_learn(){let e=this._sampleFactor;const t=this._pointArray.length;t<_NeuQuantFloat$1._minpicturebytes&&(e=1);const i=30+(e-1)/3,r=t/e;let n,a=r/_NeuQuantFloat$1._nCycles|0,o=_NeuQuantFloat$1._initAlpha,s=(this._networkSize>>3)*_NeuQuantFloat$1._radiusBias,l=s>>_NeuQuantFloat$1._radiusBiasShift;l<=1&&(l=0);for(let e=0;e<l;e++)this._radPower[e]=o*((l*l-e*e)*_NeuQuantFloat$1._radBias/(l*l));n=t<_NeuQuantFloat$1._minpicturebytes?1:t%_NeuQuantFloat$1._prime1!=0?_NeuQuantFloat$1._prime1:t%_NeuQuantFloat$1._prime2!=0?_NeuQuantFloat$1._prime2:t%_NeuQuantFloat$1._prime3!=0?_NeuQuantFloat$1._prime3:_NeuQuantFloat$1._prime4;const u=new ProgressTracker$1(r,99);for(let e=0,h=0;e<r;){u.shouldNotify(e)&&(yield{progress:u.progress});const r=this._pointArray[h],c=r.b<<networkBiasShift2$1,f=r.g<<networkBiasShift2$1,d=r.r<<networkBiasShift2$1,p=r.a<<networkBiasShift2$1,m=this._contest(c,f,d,p);if(this._alterSingle(o,m,c,f,d,p),0!==l&&this._alterNeighbour(l,m,c,f,d,p),h+=n,h>=t&&(h-=t),e++,0===a&&(a=1),e%a==0){o-=o/i,s-=s/_NeuQuantFloat$1._radiusDecrease,l=s>>_NeuQuantFloat$1._radiusBiasShift,l<=1&&(l=0);for(let e=0;e<l;e++)this._radPower[e]=o*((l*l-e*e)*_NeuQuantFloat$1._radBias/(l*l))}}}_buildPalette(){const e=new Palette$1;return this._network.forEach((t=>{e.add(t.toPoint())})),e.sort(),e}_alterNeighbour(e,t,i,r,n,a){let o=t-e;o<-1&&(o=-1);let s=t+e;s>this._networkSize&&(s=this._networkSize);let l=t+1,u=t-1,h=1;for(;l<s||u>o;){const e=this._radPower[h++]/_NeuQuantFloat$1._alphaRadBias;if(l<s){const t=this._network[l++];t.subtract(e*(t.r-n),e*(t.g-r),e*(t.b-i),e*(t.a-a))}if(u>o){const t=this._network[u--];t.subtract(e*(t.r-n),e*(t.g-r),e*(t.b-i),e*(t.a-a))}}}_alterSingle(e,t,i,r,n,a){e/=_NeuQuantFloat$1._initAlpha;const o=this._network[t];o.subtract(e*(o.r-n),e*(o.g-r),e*(o.b-i),e*(o.a-a))}_contest(e,t,i,r){const n=1020<<networkBiasShift2$1;let a=~(1<<31),o=a,s=-1,l=s;for(let u=0;u<this._networkSize;u++){const h=this._network[u],c=this._distance.calculateNormalized(h,{r:i,g:t,b:e,a:r})*n;c<a&&(a=c,s=u);const f=c-(this._bias[u]>>_NeuQuantFloat$1._initialBiasShift-networkBiasShift2$1);f<o&&(o=f,l=u);const d=this._freq[u]>>_NeuQuantFloat$1._betaShift;this._freq[u]-=d,this._bias[u]+=d<<_NeuQuantFloat$1._gammaShift}return this._freq[s]+=_NeuQuantFloat$1._beta,this._bias[s]-=_NeuQuantFloat$1._betaGamma,l}},NeuQuantFloat$1=_NeuQuantFloat$1;__publicField$3(NeuQuantFloat$1,"_prime1",499),__publicField$3(NeuQuantFloat$1,"_prime2",491),__publicField$3(NeuQuantFloat$1,"_prime3",487),__publicField$3(NeuQuantFloat$1,"_prime4",503),__publicField$3(NeuQuantFloat$1,"_minpicturebytes",_NeuQuantFloat$1._prime4),__publicField$3(NeuQuantFloat$1,"_nCycles",100),__publicField$3(NeuQuantFloat$1,"_initialBiasShift",16),__publicField$3(NeuQuantFloat$1,"_initialBias",1<<_NeuQuantFloat$1._initialBiasShift),__publicField$3(NeuQuantFloat$1,"_gammaShift",10),__publicField$3(NeuQuantFloat$1,"_betaShift",10),__publicField$3(NeuQuantFloat$1,"_beta",_NeuQuantFloat$1._initialBias>>_NeuQuantFloat$1._betaShift),__publicField$3(NeuQuantFloat$1,"_betaGamma",_NeuQuantFloat$1._initialBias<<_NeuQuantFloat$1._gammaShift-_NeuQuantFloat$1._betaShift),__publicField$3(NeuQuantFloat$1,"_radiusBiasShift",6),__publicField$3(NeuQuantFloat$1,"_radiusBias",1<<_NeuQuantFloat$1._radiusBiasShift),__publicField$3(NeuQuantFloat$1,"_radiusDecrease",30),__publicField$3(NeuQuantFloat$1,"_alphaBiasShift",10),__publicField$3(NeuQuantFloat$1,"_initAlpha",1<<_NeuQuantFloat$1._alphaBiasShift),__publicField$3(NeuQuantFloat$1,"_radBiasShift",8),__publicField$3(NeuQuantFloat$1,"_radBias",1<<_NeuQuantFloat$1._radBiasShift),__publicField$3(NeuQuantFloat$1,"_alphaRadBiasShift",_NeuQuantFloat$1._alphaBiasShift+_NeuQuantFloat$1._radBiasShift),__publicField$3(NeuQuantFloat$1,"_alphaRadBias",1<<_NeuQuantFloat$1._alphaRadBiasShift);var _ColorHistogram$1=class{constructor(e,t){__publicField$3(this,"_method"),__publicField$3(this,"_hueStats"),__publicField$3(this,"_histogram"),__publicField$3(this,"_initColors"),__publicField$3(this,"_minHueCols"),this._method=e,this._minHueCols=t<<2,this._initColors=t<<2,this._hueStats=new HueStatistics$1(_ColorHistogram$1._hueGroups,this._minHueCols),this._histogram=Object.create(null)}sample(e){switch(this._method){case 1:this._colorStats1D(e);break;case 2:this._colorStats2D(e)}}getImportanceSortedColorsIDXI32(){const e=stableSort$1(Object.keys(this._histogram),((e,t)=>this._histogram[t]-this._histogram[e]));if(0===e.length)return[];let t;switch(this._method){case 1:const i=Math.min(e.length,this._initColors),r=e[i-1],n=this._histogram[r];t=e.slice(0,i);let a=i;const o=e.length;for(;a<o&&this._histogram[e[a]]===n;)t.push(e[a++]);this._hueStats.injectIntoArray(t);break;case 2:t=e;break;default:throw new Error("Incorrect method")}return t.map((e=>+e))}_colorStats1D(e){const t=this._histogram,i=e.getPointArray(),r=i.length;for(let e=0;e<r;e++){const r=i[e].uint32;this._hueStats.check(r),r in t?t[r]++:t[r]=1}}_colorStats2D(e){const t=e.getWidth(),i=e.getHeight(),r=e.getPointArray(),n=_ColorHistogram$1._boxSize[0],a=_ColorHistogram$1._boxSize[1],o=n*a,s=this._makeBoxes(t,i,n,a),l=this._histogram;s.forEach((e=>{let i=Math.round(e.w*e.h/o)*_ColorHistogram$1._boxPixels;i<2&&(i=2);const n={};this._iterateBox(e,t,(e=>{const t=r[e].uint32;this._hueStats.check(t),t in l?l[t]++:t in n?++n[t]>=i&&(l[t]=n[t]):n[t]=1}))})),this._hueStats.injectIntoDictionary(l)}_iterateBox(e,t,i){const r=e,n=r.y*t+r.x,a=(r.y+r.h-1)*t+(r.x+r.w-1),o=t-r.w+1;let s=0,l=n;do{i.call(this,l),l+=++s%r.w==0?o:1}while(l<=a)}_makeBoxes(e,t,i,r){const n=e%i,a=t%r,o=e-n,s=t-a,l=[];for(let u=0;u<t;u+=r)for(let t=0;t<e;t+=i)l.push({x:t,y:u,w:t===o?n:i,h:u===s?a:r});return l}},ColorHistogram$1=_ColorHistogram$1;__publicField$3(ColorHistogram$1,"_boxSize",[64,64]),__publicField$3(ColorHistogram$1,"_boxPixels",2),__publicField$3(ColorHistogram$1,"_hueGroups",10);var RemovedColor$1=class{constructor(e,t,i){__publicField$3(this,"index"),__publicField$3(this,"color"),__publicField$3(this,"distance"),this.index=e,this.color=t,this.distance=i}},RGBQuant$1=class extends AbstractPaletteQuantizer$1{constructor(e,t=256,i=2){super(),__publicField$3(this,"_colors"),__publicField$3(this,"_initialDistance"),__publicField$3(this,"_distanceIncrement"),__publicField$3(this,"_histogram"),__publicField$3(this,"_distance"),this._distance=e,this._colors=t,this._histogram=new ColorHistogram$1(i,t),this._initialDistance=.01,this._distanceIncrement=.005}sample(e){this._histogram.sample(e)}*quantize(){const e=this._histogram.getImportanceSortedColorsIDXI32();if(0===e.length)throw new Error("No colors in image");yield*this._buildPalette(e)}*_buildPalette(e){const t=new Palette$1,i=t.getPointContainer().getPointArray(),r=new Array(e.length);for(let t=0;t<e.length;t++)i.push(Point$1.createByUint32(e[t])),r[t]=1;const n=i.length,a=[];let o=n,s=this._initialDistance;const l=new ProgressTracker$1(o-this._colors,99);for(;o>this._colors;){a.length=0;for(let e=0;e<n;e++){if(l.shouldNotify(n-o)&&(yield{progress:l.progress}),0===r[e])continue;const t=i[e];for(let l=e+1;l<n;l++){if(0===r[l])continue;const e=i[l],n=this._distance.calculateNormalized(t,e);n<s&&(a.push(new RemovedColor$1(l,e,n)),r[l]=0,o--)}}s+=o>3*this._colors?this._initialDistance:this._distanceIncrement}if(o<this._colors){stableSort$1(a,((e,t)=>t.distance-e.distance));let e=0;for(;o<this._colors&&e<a.length;){r[a[e].index]=1,o++,e++}}let u=i.length;for(let e=u-1;e>=0;e--)0===r[e]&&(e!==u-1&&(i[e]=i[u-1]),--u);i.length=u,t.sort(),yield{palette:t,progress:100}}};function createArray1D$1(e){const t=[];for(let i=0;i<e;i++)t[i]=0;return t}function createArray4D$1(e,t,i,r){const n=new Array(e);for(let a=0;a<e;a++){n[a]=new Array(t);for(let e=0;e<t;e++){n[a][e]=new Array(i);for(let t=0;t<i;t++){n[a][e][t]=new Array(r);for(let i=0;i<r;i++)n[a][e][t][i]=0}}}return n}function createArray3D$1(e,t,i){const r=new Array(e);for(let n=0;n<e;n++){r[n]=new Array(t);for(let e=0;e<t;e++){r[n][e]=new Array(i);for(let t=0;t<i;t++)r[n][e][t]=0}}return r}function fillArray3D$1(e,t,i,r,n){for(let a=0;a<t;a++){e[a]=[];for(let t=0;t<i;t++){e[a][t]=[];for(let i=0;i<r;i++)e[a][t][i]=n}}}function fillArray1D$1(e,t,i){for(let r=0;r<t;r++)e[r]=i}var WuColorCube$1=class{constructor(){__publicField$3(this,"redMinimum"),__publicField$3(this,"redMaximum"),__publicField$3(this,"greenMinimum"),__publicField$3(this,"greenMaximum"),__publicField$3(this,"blueMinimum"),__publicField$3(this,"blueMaximum"),__publicField$3(this,"volume"),__publicField$3(this,"alphaMinimum"),__publicField$3(this,"alphaMaximum")}},_WuQuant$1=class extends AbstractPaletteQuantizer$1{constructor(e,t=256,i=5){super(),__publicField$3(this,"_reds"),__publicField$3(this,"_greens"),__publicField$3(this,"_blues"),__publicField$3(this,"_alphas"),__publicField$3(this,"_sums"),__publicField$3(this,"_weights"),__publicField$3(this,"_momentsRed"),__publicField$3(this,"_momentsGreen"),__publicField$3(this,"_momentsBlue"),__publicField$3(this,"_momentsAlpha"),__publicField$3(this,"_moments"),__publicField$3(this,"_table"),__publicField$3(this,"_pixels"),__publicField$3(this,"_cubes"),__publicField$3(this,"_colors"),__publicField$3(this,"_significantBitsPerChannel"),__publicField$3(this,"_maxSideIndex"),__publicField$3(this,"_alphaMaxSideIndex"),__publicField$3(this,"_sideSize"),__publicField$3(this,"_alphaSideSize"),__publicField$3(this,"_distance"),this._distance=e,this._setQuality(i),this._initialize(t)}sample(e){const t=e.getPointArray();for(let e=0,i=t.length;e<i;e++)this._addColor(t[e]);this._pixels=this._pixels.concat(t)}*quantize(){yield*this._preparePalette();const e=new Palette$1;for(let t=0;t<this._colors;t++)if(this._sums[t]>0){const i=this._sums[t],r=this._reds[t]/i,n=this._greens[t]/i,a=this._blues[t]/i,o=this._alphas[t]/i,s=Point$1.createByRGBA(0|r,0|n,0|a,0|o);e.add(s)}e.sort(),yield{palette:e,progress:100}}*_preparePalette(){yield*this._calculateMoments();let e=0;const t=createArray1D$1(this._colors);for(let i=1;i<this._colors;++i){this._cut(this._cubes[e],this._cubes[i])?(t[e]=this._cubes[e].volume>1?this._calculateVariance(this._cubes[e]):0,t[i]=this._cubes[i].volume>1?this._calculateVariance(this._cubes[i]):0):(t[e]=0,i--),e=0;let r=t[0];for(let n=1;n<=i;++n)t[n]>r&&(r=t[n],e=n);if(r<=0){this._colors=i+1;break}}const i=[],r=[],n=[],a=[];for(let e=0;e<this._colors;++e){const t=_WuQuant$1._volume(this._cubes[e],this._weights);t>0?(i[e]=_WuQuant$1._volume(this._cubes[e],this._momentsRed)/t|0,r[e]=_WuQuant$1._volume(this._cubes[e],this._momentsGreen)/t|0,n[e]=_WuQuant$1._volume(this._cubes[e],this._momentsBlue)/t|0,a[e]=_WuQuant$1._volume(this._cubes[e],this._momentsAlpha)/t|0):(i[e]=0,r[e]=0,n[e]=0,a[e]=0)}this._reds=createArray1D$1(this._colors+1),this._greens=createArray1D$1(this._colors+1),this._blues=createArray1D$1(this._colors+1),this._alphas=createArray1D$1(this._colors+1),this._sums=createArray1D$1(this._colors+1);for(let e=0,t=this._pixels.length;e<t;e++){const t=this._pixels[e];let o=-1,s=Number.MAX_VALUE;for(let e=0;e<this._colors;e++){const l=i[e],u=r[e],h=n[e],c=a[e],f=this._distance.calculateRaw(l,u,h,c,t.r,t.g,t.b,t.a);f<s&&(s=f,o=e)}this._reds[o]+=t.r,this._greens[o]+=t.g,this._blues[o]+=t.b,this._alphas[o]+=t.a,this._sums[o]++}}_addColor(e){const t=8-this._significantBitsPerChannel,i=1+(e.r>>t),r=1+(e.g>>t),n=1+(e.b>>t),a=1+(e.a>>t);this._weights[a][i][r][n]++,this._momentsRed[a][i][r][n]+=e.r,this._momentsGreen[a][i][r][n]+=e.g,this._momentsBlue[a][i][r][n]+=e.b,this._momentsAlpha[a][i][r][n]+=e.a,this._moments[a][i][r][n]+=this._table[e.r]+this._table[e.g]+this._table[e.b]+this._table[e.a]}*_calculateMoments(){const e=[],t=[],i=[],r=[],n=[],a=[],o=createArray3D$1(this._sideSize,this._sideSize,this._sideSize),s=createArray3D$1(this._sideSize,this._sideSize,this._sideSize),l=createArray3D$1(this._sideSize,this._sideSize,this._sideSize),u=createArray3D$1(this._sideSize,this._sideSize,this._sideSize),h=createArray3D$1(this._sideSize,this._sideSize,this._sideSize),c=createArray3D$1(this._sideSize,this._sideSize,this._sideSize);let f=0;const d=new ProgressTracker$1(this._alphaMaxSideIndex*this._maxSideIndex,99);for(let p=1;p<=this._alphaMaxSideIndex;++p){fillArray3D$1(o,this._sideSize,this._sideSize,this._sideSize,0),fillArray3D$1(s,this._sideSize,this._sideSize,this._sideSize,0),fillArray3D$1(l,this._sideSize,this._sideSize,this._sideSize,0),fillArray3D$1(u,this._sideSize,this._sideSize,this._sideSize,0),fillArray3D$1(h,this._sideSize,this._sideSize,this._sideSize,0),fillArray3D$1(c,this._sideSize,this._sideSize,this._sideSize,0);for(let m=1;m<=this._maxSideIndex;++m,++f){d.shouldNotify(f)&&(yield{progress:d.progress}),fillArray1D$1(e,this._sideSize,0),fillArray1D$1(t,this._sideSize,0),fillArray1D$1(i,this._sideSize,0),fillArray1D$1(r,this._sideSize,0),fillArray1D$1(n,this._sideSize,0),fillArray1D$1(a,this._sideSize,0);for(let f=1;f<=this._maxSideIndex;++f){let d=0,_=0,g=0,b=0,y=0,w=0;for(let v=1;v<=this._maxSideIndex;++v)d+=this._weights[p][m][f][v],_+=this._momentsRed[p][m][f][v],g+=this._momentsGreen[p][m][f][v],b+=this._momentsBlue[p][m][f][v],y+=this._momentsAlpha[p][m][f][v],w+=this._moments[p][m][f][v],e[v]+=d,t[v]+=_,i[v]+=g,r[v]+=b,n[v]+=y,a[v]+=w,o[m][f][v]=o[m-1][f][v]+e[v],s[m][f][v]=s[m-1][f][v]+t[v],l[m][f][v]=l[m-1][f][v]+i[v],u[m][f][v]=u[m-1][f][v]+r[v],h[m][f][v]=h[m-1][f][v]+n[v],c[m][f][v]=c[m-1][f][v]+a[v],this._weights[p][m][f][v]=this._weights[p-1][m][f][v]+o[m][f][v],this._momentsRed[p][m][f][v]=this._momentsRed[p-1][m][f][v]+s[m][f][v],this._momentsGreen[p][m][f][v]=this._momentsGreen[p-1][m][f][v]+l[m][f][v],this._momentsBlue[p][m][f][v]=this._momentsBlue[p-1][m][f][v]+u[m][f][v],this._momentsAlpha[p][m][f][v]=this._momentsAlpha[p-1][m][f][v]+h[m][f][v],this._moments[p][m][f][v]=this._moments[p-1][m][f][v]+c[m][f][v]}}}}static _volumeFloat(e,t){return t[e.alphaMaximum][e.redMaximum][e.greenMaximum][e.blueMaximum]-t[e.alphaMaximum][e.redMaximum][e.greenMinimum][e.blueMaximum]-t[e.alphaMaximum][e.redMinimum][e.greenMaximum][e.blueMaximum]+t[e.alphaMaximum][e.redMinimum][e.greenMinimum][e.blueMaximum]-t[e.alphaMinimum][e.redMaximum][e.greenMaximum][e.blueMaximum]+t[e.alphaMinimum][e.redMaximum][e.greenMinimum][e.blueMaximum]+t[e.alphaMinimum][e.redMinimum][e.greenMaximum][e.blueMaximum]-t[e.alphaMinimum][e.redMinimum][e.greenMinimum][e.blueMaximum]-(t[e.alphaMaximum][e.redMaximum][e.greenMaximum][e.blueMinimum]-t[e.alphaMinimum][e.redMaximum][e.greenMaximum][e.blueMinimum]-t[e.alphaMaximum][e.redMaximum][e.greenMinimum][e.blueMinimum]+t[e.alphaMinimum][e.redMaximum][e.greenMinimum][e.blueMinimum]-t[e.alphaMaximum][e.redMinimum][e.greenMaximum][e.blueMinimum]+t[e.alphaMinimum][e.redMinimum][e.greenMaximum][e.blueMinimum]+t[e.alphaMaximum][e.redMinimum][e.greenMinimum][e.blueMinimum]-t[e.alphaMinimum][e.redMinimum][e.greenMinimum][e.blueMinimum])}static _volume(e,t){return 0|_WuQuant$1._volumeFloat(e,t)}static _top(e,t,i,r){let n;switch(t){case _WuQuant$1._alpha:n=r[i][e.redMaximum][e.greenMaximum][e.blueMaximum]-r[i][e.redMaximum][e.greenMinimum][e.blueMaximum]-r[i][e.redMinimum][e.greenMaximum][e.blueMaximum]+r[i][e.redMinimum][e.greenMinimum][e.blueMaximum]-(r[i][e.redMaximum][e.greenMaximum][e.blueMinimum]-r[i][e.redMaximum][e.greenMinimum][e.blueMinimum]-r[i][e.redMinimum][e.greenMaximum][e.blueMinimum]+r[i][e.redMinimum][e.greenMinimum][e.blueMinimum]);break;case _WuQuant$1._red:n=r[e.alphaMaximum][i][e.greenMaximum][e.blueMaximum]-r[e.alphaMaximum][i][e.greenMinimum][e.blueMaximum]-r[e.alphaMinimum][i][e.greenMaximum][e.blueMaximum]+r[e.alphaMinimum][i][e.greenMinimum][e.blueMaximum]-(r[e.alphaMaximum][i][e.greenMaximum][e.blueMinimum]-r[e.alphaMaximum][i][e.greenMinimum][e.blueMinimum]-r[e.alphaMinimum][i][e.greenMaximum][e.blueMinimum]+r[e.alphaMinimum][i][e.greenMinimum][e.blueMinimum]);break;case _WuQuant$1._green:n=r[e.alphaMaximum][e.redMaximum][i][e.blueMaximum]-r[e.alphaMaximum][e.redMinimum][i][e.blueMaximum]-r[e.alphaMinimum][e.redMaximum][i][e.blueMaximum]+r[e.alphaMinimum][e.redMinimum][i][e.blueMaximum]-(r[e.alphaMaximum][e.redMaximum][i][e.blueMinimum]-r[e.alphaMaximum][e.redMinimum][i][e.blueMinimum]-r[e.alphaMinimum][e.redMaximum][i][e.blueMinimum]+r[e.alphaMinimum][e.redMinimum][i][e.blueMinimum]);break;case _WuQuant$1._blue:n=r[e.alphaMaximum][e.redMaximum][e.greenMaximum][i]-r[e.alphaMaximum][e.redMaximum][e.greenMinimum][i]-r[e.alphaMaximum][e.redMinimum][e.greenMaximum][i]+r[e.alphaMaximum][e.redMinimum][e.greenMinimum][i]-(r[e.alphaMinimum][e.redMaximum][e.greenMaximum][i]-r[e.alphaMinimum][e.redMaximum][e.greenMinimum][i]-r[e.alphaMinimum][e.redMinimum][e.greenMaximum][i]+r[e.alphaMinimum][e.redMinimum][e.greenMinimum][i]);break;default:throw new Error("impossible")}return 0|n}static _bottom(e,t,i){switch(t){case _WuQuant$1._alpha:return-i[e.alphaMinimum][e.redMaximum][e.greenMaximum][e.blueMaximum]+i[e.alphaMinimum][e.redMaximum][e.greenMinimum][e.blueMaximum]+i[e.alphaMinimum][e.redMinimum][e.greenMaximum][e.blueMaximum]-i[e.alphaMinimum][e.redMinimum][e.greenMinimum][e.blueMaximum]-(-i[e.alphaMinimum][e.redMaximum][e.greenMaximum][e.blueMinimum]+i[e.alphaMinimum][e.redMaximum][e.greenMinimum][e.blueMinimum]+i[e.alphaMinimum][e.redMinimum][e.greenMaximum][e.blueMinimum]-i[e.alphaMinimum][e.redMinimum][e.greenMinimum][e.blueMinimum]);case _WuQuant$1._red:return-i[e.alphaMaximum][e.redMinimum][e.greenMaximum][e.blueMaximum]+i[e.alphaMaximum][e.redMinimum][e.greenMinimum][e.blueMaximum]+i[e.alphaMinimum][e.redMinimum][e.greenMaximum][e.blueMaximum]-i[e.alphaMinimum][e.redMinimum][e.greenMinimum][e.blueMaximum]-(-i[e.alphaMaximum][e.redMinimum][e.greenMaximum][e.blueMinimum]+i[e.alphaMaximum][e.redMinimum][e.greenMinimum][e.blueMinimum]+i[e.alphaMinimum][e.redMinimum][e.greenMaximum][e.blueMinimum]-i[e.alphaMinimum][e.redMinimum][e.greenMinimum][e.blueMinimum]);case _WuQuant$1._green:return-i[e.alphaMaximum][e.redMaximum][e.greenMinimum][e.blueMaximum]+i[e.alphaMaximum][e.redMinimum][e.greenMinimum][e.blueMaximum]+i[e.alphaMinimum][e.redMaximum][e.greenMinimum][e.blueMaximum]-i[e.alphaMinimum][e.redMinimum][e.greenMinimum][e.blueMaximum]-(-i[e.alphaMaximum][e.redMaximum][e.greenMinimum][e.blueMinimum]+i[e.alphaMaximum][e.redMinimum][e.greenMinimum][e.blueMinimum]+i[e.alphaMinimum][e.redMaximum][e.greenMinimum][e.blueMinimum]-i[e.alphaMinimum][e.redMinimum][e.greenMinimum][e.blueMinimum]);case _WuQuant$1._blue:return-i[e.alphaMaximum][e.redMaximum][e.greenMaximum][e.blueMinimum]+i[e.alphaMaximum][e.redMaximum][e.greenMinimum][e.blueMinimum]+i[e.alphaMaximum][e.redMinimum][e.greenMaximum][e.blueMinimum]-i[e.alphaMaximum][e.redMinimum][e.greenMinimum][e.blueMinimum]-(-i[e.alphaMinimum][e.redMaximum][e.greenMaximum][e.blueMinimum]+i[e.alphaMinimum][e.redMaximum][e.greenMinimum][e.blueMinimum]+i[e.alphaMinimum][e.redMinimum][e.greenMaximum][e.blueMinimum]-i[e.alphaMinimum][e.redMinimum][e.greenMinimum][e.blueMinimum]);default:return 0}}_calculateVariance(e){const t=_WuQuant$1._volume(e,this._momentsRed),i=_WuQuant$1._volume(e,this._momentsGreen),r=_WuQuant$1._volume(e,this._momentsBlue),n=_WuQuant$1._volume(e,this._momentsAlpha);return _WuQuant$1._volumeFloat(e,this._moments)-(t*t+i*i+r*r+n*n)/_WuQuant$1._volume(e,this._weights)}_maximize(e,t,i,r,n,a,o,s,l){const u=0|_WuQuant$1._bottom(e,t,this._momentsRed),h=0|_WuQuant$1._bottom(e,t,this._momentsGreen),c=0|_WuQuant$1._bottom(e,t,this._momentsBlue),f=0|_WuQuant$1._bottom(e,t,this._momentsAlpha),d=0|_WuQuant$1._bottom(e,t,this._weights);let p=0,m=-1;for(let _=i;_<r;++_){let i=u+_WuQuant$1._top(e,t,_,this._momentsRed),r=h+_WuQuant$1._top(e,t,_,this._momentsGreen),g=c+_WuQuant$1._top(e,t,_,this._momentsBlue),b=f+_WuQuant$1._top(e,t,_,this._momentsAlpha),y=d+_WuQuant$1._top(e,t,_,this._weights);if(0!==y){let e=i*i+r*r+g*g+b*b,t=e/y;i=n-i,r=a-r,g=o-g,b=s-b,y=l-y,0!==y&&(e=i*i+r*r+g*g+b*b,t+=e/y,t>p&&(p=t,m=_))}}return{max:p,position:m}}_cut(e,t){let i;const r=_WuQuant$1._volume(e,this._momentsRed),n=_WuQuant$1._volume(e,this._momentsGreen),a=_WuQuant$1._volume(e,this._momentsBlue),o=_WuQuant$1._volume(e,this._momentsAlpha),s=_WuQuant$1._volume(e,this._weights),l=this._maximize(e,_WuQuant$1._red,e.redMinimum+1,e.redMaximum,r,n,a,o,s),u=this._maximize(e,_WuQuant$1._green,e.greenMinimum+1,e.greenMaximum,r,n,a,o,s),h=this._maximize(e,_WuQuant$1._blue,e.blueMinimum+1,e.blueMaximum,r,n,a,o,s),c=this._maximize(e,_WuQuant$1._alpha,e.alphaMinimum+1,e.alphaMaximum,r,n,a,o,s);if(c.max>=l.max&&c.max>=u.max&&c.max>=h.max){if(i=_WuQuant$1._alpha,c.position<0)return!1}else i=l.max>=c.max&&l.max>=u.max&&l.max>=h.max?_WuQuant$1._red:u.max>=c.max&&u.max>=l.max&&u.max>=h.max?_WuQuant$1._green:_WuQuant$1._blue;switch(t.redMaximum=e.redMaximum,t.greenMaximum=e.greenMaximum,t.blueMaximum=e.blueMaximum,t.alphaMaximum=e.alphaMaximum,i){case _WuQuant$1._red:t.redMinimum=e.redMaximum=l.position,t.greenMinimum=e.greenMinimum,t.blueMinimum=e.blueMinimum,t.alphaMinimum=e.alphaMinimum;break;case _WuQuant$1._green:t.greenMinimum=e.greenMaximum=u.position,t.redMinimum=e.redMinimum,t.blueMinimum=e.blueMinimum,t.alphaMinimum=e.alphaMinimum;break;case _WuQuant$1._blue:t.blueMinimum=e.blueMaximum=h.position,t.redMinimum=e.redMinimum,t.greenMinimum=e.greenMinimum,t.alphaMinimum=e.alphaMinimum;break;case _WuQuant$1._alpha:t.alphaMinimum=e.alphaMaximum=c.position,t.blueMinimum=e.blueMinimum,t.redMinimum=e.redMinimum,t.greenMinimum=e.greenMinimum}return e.volume=(e.redMaximum-e.redMinimum)*(e.greenMaximum-e.greenMinimum)*(e.blueMaximum-e.blueMinimum)*(e.alphaMaximum-e.alphaMinimum),t.volume=(t.redMaximum-t.redMinimum)*(t.greenMaximum-t.greenMinimum)*(t.blueMaximum-t.blueMinimum)*(t.alphaMaximum-t.alphaMinimum),!0}_initialize(e){this._colors=e,this._cubes=[];for(let t=0;t<e;t++)this._cubes[t]=new WuColorCube$1;this._cubes[0].redMinimum=0,this._cubes[0].greenMinimum=0,this._cubes[0].blueMinimum=0,this._cubes[0].alphaMinimum=0,this._cubes[0].redMaximum=this._maxSideIndex,this._cubes[0].greenMaximum=this._maxSideIndex,this._cubes[0].blueMaximum=this._maxSideIndex,this._cubes[0].alphaMaximum=this._alphaMaxSideIndex,this._weights=createArray4D$1(this._alphaSideSize,this._sideSize,this._sideSize,this._sideSize),this._momentsRed=createArray4D$1(this._alphaSideSize,this._sideSize,this._sideSize,this._sideSize),this._momentsGreen=createArray4D$1(this._alphaSideSize,this._sideSize,this._sideSize,this._sideSize),this._momentsBlue=createArray4D$1(this._alphaSideSize,this._sideSize,this._sideSize,this._sideSize),this._momentsAlpha=createArray4D$1(this._alphaSideSize,this._sideSize,this._sideSize,this._sideSize),this._moments=createArray4D$1(this._alphaSideSize,this._sideSize,this._sideSize,this._sideSize),this._table=[];for(let e=0;e<256;++e)this._table[e]=e*e;this._pixels=[]}_setQuality(e=5){this._significantBitsPerChannel=e,this._maxSideIndex=1<<this._significantBitsPerChannel,this._alphaMaxSideIndex=this._maxSideIndex,this._sideSize=this._maxSideIndex+1,this._alphaSideSize=this._alphaMaxSideIndex+1}},WuQuant$1=_WuQuant$1;__publicField$3(WuQuant$1,"_alpha",3),__publicField$3(WuQuant$1,"_red",2),__publicField$3(WuQuant$1,"_green",1),__publicField$3(WuQuant$1,"_blue",0);var image_exports$1={};__export$1(image_exports$1,{AbstractImageQuantizer:()=>AbstractImageQuantizer$1,ErrorDiffusionArray:()=>ErrorDiffusionArray$1,ErrorDiffusionArrayKernel:()=>ErrorDiffusionArrayKernel$1,ErrorDiffusionRiemersma:()=>ErrorDiffusionRiemersma$1,NearestColor:()=>NearestColor$1});var AbstractImageQuantizer$1=class{quantizeSync(e,t){for(const i of this.quantize(e,t))if(i.pointContainer)return i.pointContainer;throw new Error("unreachable")}},NearestColor$1=class extends AbstractImageQuantizer$1{constructor(e){super(),__publicField$3(this,"_distance"),this._distance=e}*quantize(e,t){const i=e.getPointArray(),r=e.getWidth(),n=e.getHeight(),a=new ProgressTracker$1(n,99);for(let e=0;e<n;e++){a.shouldNotify(e)&&(yield{progress:a.progress});for(let n=0,a=e*r;n<r;n++,a++){const e=i[a];e.from(t.getNearestColor(this._distance,e))}}yield{pointContainer:e,progress:100}}},ErrorDiffusionArrayKernel$1=(e=>(e[e.FloydSteinberg=0]="FloydSteinberg",e[e.FalseFloydSteinberg=1]="FalseFloydSteinberg",e[e.Stucki=2]="Stucki",e[e.Atkinson=3]="Atkinson",e[e.Jarvis=4]="Jarvis",e[e.Burkes=5]="Burkes",e[e.Sierra=6]="Sierra",e[e.TwoSierra=7]="TwoSierra",e[e.SierraLite=8]="SierraLite",e))(ErrorDiffusionArrayKernel$1||{}),ErrorDiffusionArray$1=class extends AbstractImageQuantizer$1{constructor(e,t,i=!0,r=0,n=!1){super(),__publicField$3(this,"_minColorDistance"),__publicField$3(this,"_serpentine"),__publicField$3(this,"_kernel"),__publicField$3(this,"_calculateErrorLikeGIMP"),__publicField$3(this,"_distance"),this._setKernel(t),this._distance=e,this._minColorDistance=r,this._serpentine=i,this._calculateErrorLikeGIMP=n}*quantize(e,t){const i=e.getPointArray(),r=new Point$1,n=e.getWidth(),a=e.getHeight(),o=[];let s=1,l=1;for(const e of this._kernel){const t=e[2]+1;l<t&&(l=t)}for(let e=0;e<l;e++)this._fillErrorLine(o[e]=[],n);const u=new ProgressTracker$1(a,99);for(let e=0;e<a;e++){u.shouldNotify(e)&&(yield{progress:u.progress}),this._serpentine&&(s*=-1);const l=e*n,h=1===s?0:n-1,c=1===s?n:-1;this._fillErrorLine(o[0],n),o.push(o.shift());const f=o[0];for(let u=h,d=l+h;u!==c;u+=s,d+=s){const l=i[d],h=f[u];r.from(l);const c=Point$1.createByRGBA(inRange0to255Rounded$1(l.r+h[0]),inRange0to255Rounded$1(l.g+h[1]),inRange0to255Rounded$1(l.b+h[2]),inRange0to255Rounded$1(l.a+h[3])),p=t.getNearestColor(this._distance,c);if(l.from(p),this._minColorDistance){if(this._distance.calculateNormalized(r,p)<this._minColorDistance)continue}let m,_,g,b;this._calculateErrorLikeGIMP?(m=c.r-p.r,_=c.g-p.g,g=c.b-p.b,b=c.a-p.a):(m=r.r-p.r,_=r.g-p.g,g=r.b-p.b,b=r.a-p.a);const y=1===s?0:this._kernel.length-1,w=1===s?this._kernel.length:-1;for(let t=y;t!==w;t+=s){const i=this._kernel[t][1]*s,r=this._kernel[t][2];if(i+u>=0&&i+u<n&&r+e>=0&&r+e<a){const e=this._kernel[t][0],n=o[r][i+u];n[0]+=m*e,n[1]+=_*e,n[2]+=g*e,n[3]+=b*e}}}}yield{pointContainer:e,progress:100}}_fillErrorLine(e,t){e.length>t&&(e.length=t);const i=e.length;for(let t=0;t<i;t++){const i=e[t];i[0]=i[1]=i[2]=i[3]=0}for(let r=i;r<t;r++)e[r]=[0,0,0,0]}_setKernel(e){switch(e){case 0:this._kernel=[[7/16,1,0],[3/16,-1,1],[5/16,0,1],[1/16,1,1]];break;case 1:this._kernel=[[3/8,1,0],[3/8,0,1],[2/8,1,1]];break;case 2:this._kernel=[[8/42,1,0],[4/42,2,0],[2/42,-2,1],[4/42,-1,1],[8/42,0,1],[4/42,1,1],[2/42,2,1],[1/42,-2,2],[2/42,-1,2],[4/42,0,2],[2/42,1,2],[1/42,2,2]];break;case 3:this._kernel=[[1/8,1,0],[1/8,2,0],[1/8,-1,1],[1/8,0,1],[1/8,1,1],[1/8,0,2]];break;case 4:this._kernel=[[7/48,1,0],[5/48,2,0],[3/48,-2,1],[5/48,-1,1],[7/48,0,1],[5/48,1,1],[3/48,2,1],[1/48,-2,2],[3/48,-1,2],[5/48,0,2],[3/48,1,2],[1/48,2,2]];break;case 5:this._kernel=[[.25,1,0],[4/32,2,0],[2/32,-2,1],[4/32,-1,1],[.25,0,1],[4/32,1,1],[2/32,2,1]];break;case 6:this._kernel=[[5/32,1,0],[3/32,2,0],[2/32,-2,1],[4/32,-1,1],[5/32,0,1],[4/32,1,1],[2/32,2,1],[2/32,-1,2],[3/32,0,2],[2/32,1,2]];break;case 7:this._kernel=[[.25,1,0],[3/16,2,0],[1/16,-2,1],[2/16,-1,1],[3/16,0,1],[2/16,1,1],[1/16,2,1]];break;case 8:this._kernel=[[.5,1,0],[1/4,-1,1],[1/4,0,1]];break;default:throw new Error(`ErrorDiffusionArray: unknown kernel = ${e}`)}}};function*hilbertCurve$1(e,t,i){const r=Math.max(e,t),n={width:e,height:t,level:Math.floor(Math.log(r)/Math.log(2)+1),callback:i,tracker:new ProgressTracker$1(e*t,99),index:0,x:0,y:0};yield*walkHilbert$1(n,1),visit$1(n,0)}function*walkHilbert$1(e,t){if(!(e.level<1)){switch(e.tracker.shouldNotify(e.index)&&(yield{progress:e.tracker.progress}),e.level--,t){case 2:yield*walkHilbert$1(e,1),visit$1(e,3),yield*walkHilbert$1(e,2),visit$1(e,4),yield*walkHilbert$1(e,2),visit$1(e,2),yield*walkHilbert$1(e,4);break;case 3:yield*walkHilbert$1(e,4),visit$1(e,2),yield*walkHilbert$1(e,3),visit$1(e,1),yield*walkHilbert$1(e,3),visit$1(e,3),yield*walkHilbert$1(e,1);break;case 1:yield*walkHilbert$1(e,2),visit$1(e,4),yield*walkHilbert$1(e,1),visit$1(e,3),yield*walkHilbert$1(e,1),visit$1(e,1),yield*walkHilbert$1(e,3);break;case 4:yield*walkHilbert$1(e,3),visit$1(e,1),yield*walkHilbert$1(e,4),visit$1(e,2),yield*walkHilbert$1(e,4),visit$1(e,4),yield*walkHilbert$1(e,2)}e.level++}}function visit$1(e,t){switch(e.x>=0&&e.x<e.width&&e.y>=0&&e.y<e.height&&(e.callback(e.x,e.y),e.index++),t){case 2:e.x--;break;case 3:e.x++;break;case 1:e.y--;break;case 4:e.y++}}var ErrorDiffusionRiemersma$1=class extends AbstractImageQuantizer$1{constructor(e,t=16,i=1){super(),__publicField$3(this,"_distance"),__publicField$3(this,"_weights"),__publicField$3(this,"_errorQueueSize"),this._distance=e,this._errorQueueSize=t,this._weights=ErrorDiffusionRiemersma$1._createWeights(i,t)}*quantize(e,t){const i=e.getPointArray(),r=e.getWidth(),n=e.getHeight(),a=[];let o=0;for(let e=0;e<this._errorQueueSize;e++)a[e]={r:0,g:0,b:0,a:0};yield*hilbertCurve$1(r,n,((e,n)=>{const s=i[e+n*r];let{r:l,g:u,b:h,a:c}=s;for(let e=0;e<this._errorQueueSize;e++){const t=this._weights[e],i=a[(e+o)%this._errorQueueSize];l+=i.r*t,u+=i.g*t,h+=i.b*t,c+=i.a*t}const f=Point$1.createByRGBA(inRange0to255Rounded$1(l),inRange0to255Rounded$1(u),inRange0to255Rounded$1(h),inRange0to255Rounded$1(c)),d=t.getNearestColor(this._distance,f);o=(o+1)%this._errorQueueSize;const p=(o+this._errorQueueSize-1)%this._errorQueueSize;a[p].r=s.r-d.r,a[p].g=s.g-d.g,a[p].b=s.b-d.b,a[p].a=s.a-d.a,s.from(d)})),yield{pointContainer:e,progress:100}}static _createWeights(e,t){const i=[],r=Math.exp(Math.log(t)/(t-1));for(let n=0,a=1;n<t;n++)i[n]=(a+.5|0)/t*e,a*=r;return i}},quality_exports$1={};__export$1(quality_exports$1,{ssim:()=>ssim$1});var K1$1=.01,K2$1=.03;function ssim$1(e,t){if(e.getHeight()!==t.getHeight()||e.getWidth()!==t.getWidth())throw new Error("Images have different sizes!");const i=(255*K1$1)**2,r=(255*K2$1)**2;let n=0,a=0;return iterate$1(e,t,((e,t,o,s)=>{let l=0,u=0,h=0;for(let i=0;i<e.length;i++)u+=(e[i]-o)**2,h+=(t[i]-s)**2,l+=(e[i]-o)*(t[i]-s);const c=e.length-1;u/=c,h/=c,l/=c;a+=(2*o*s+i)*(2*l+r)/((o**2+s**2+i)*(u+h+r)),n++})),a/n}function iterate$1(e,t,i){const r=e.getWidth(),n=e.getHeight();for(let a=0;a<n;a+=8)for(let o=0;o<r;o+=8){const s=Math.min(8,r-o),l=Math.min(8,n-a),u=calculateLumaValuesForWindow$1(e,o,a,s,l),h=calculateLumaValuesForWindow$1(t,o,a,s,l);i(u,h,calculateAverageLuma$1(u),calculateAverageLuma$1(h))}}function calculateLumaValuesForWindow$1(e,t,i,r,n){const a=e.getPointArray(),o=[];let s=0;for(let l=i;l<i+n;l++){const i=l*e.getWidth();for(let e=t;e<t+r;e++){const t=a[i+e];o[s]=.2126*t.r+.7152*t.g+.0722*t.b,s++}}return o}function calculateAverageLuma$1(e){let t=0;for(const i of e)t+=i;return t/e.length}var setImmediateImpl="function"==typeof setImmediate?setImmediate:"undefined"!=typeof process&&"function"==typeof(null==process?void 0:process.nextTick)?e=>process.nextTick(e):e=>setTimeout(e,0);function buildPaletteSync$1(e,{colorDistanceFormula:t,paletteQuantization:i,colors:r}={}){const n=paletteQuantizationToPaletteQuantizer$1(colorDistanceFormulaToColorDistance$1(t),i,r);return e.forEach((e=>n.sample(e))),n.quantizeSync()}async function buildPalette(e,{colorDistanceFormula:t,paletteQuantization:i,colors:r,onProgress:n}={}){return new Promise(((a,o)=>{const s=paletteQuantizationToPaletteQuantizer$1(colorDistanceFormulaToColorDistance$1(t),i,r);let l;e.forEach((e=>s.sample(e)));const u=s.quantize(),h=()=>{try{const e=u.next();e.done?a(l):(e.value.palette&&(l=e.value.palette),n&&n(e.value.progress),setImmediateImpl(h))}catch(e){o(e)}};setImmediateImpl(h)}))}function applyPaletteSync$1(e,t,{colorDistanceFormula:i,imageQuantization:r}={}){return imageQuantizationToImageQuantizer$1(colorDistanceFormulaToColorDistance$1(i),r).quantizeSync(e,t)}async function applyPalette(e,t,{colorDistanceFormula:i,imageQuantization:r,onProgress:n}={}){return new Promise(((a,o)=>{let s;const l=imageQuantizationToImageQuantizer$1(colorDistanceFormulaToColorDistance$1(i),r).quantize(e,t),u=()=>{try{const e=l.next();e.done?a(s):(e.value.pointContainer&&(s=e.value.pointContainer),n&&n(e.value.progress),setImmediateImpl(u))}catch(e){o(e)}};setImmediateImpl(u)}))}function colorDistanceFormulaToColorDistance$1(e="euclidean-bt709"){switch(e){case"cie94-graphic-arts":return new CIE94GraphicArts$1;case"cie94-textiles":return new CIE94Textiles$1;case"ciede2000":return new CIEDE2000$1;case"color-metric":return new CMetric$1;case"euclidean":return new Euclidean$1;case"euclidean-bt709":return new EuclideanBT709$1;case"euclidean-bt709-noalpha":return new EuclideanBT709NoAlpha$1;case"manhattan":return new Manhattan$1;case"manhattan-bt709":return new ManhattanBT709$1;case"manhattan-nommyde":return new ManhattanNommyde$1;case"pngquant":return new PNGQuant$1;default:throw new Error(`Unknown colorDistanceFormula ${e}`)}}function imageQuantizationToImageQuantizer$1(e,t="floyd-steinberg"){switch(t){case"nearest":return new NearestColor$1(e);case"riemersma":return new ErrorDiffusionRiemersma$1(e);case"floyd-steinberg":return new ErrorDiffusionArray$1(e,0);case"false-floyd-steinberg":return new ErrorDiffusionArray$1(e,1);case"stucki":return new ErrorDiffusionArray$1(e,2);case"atkinson":return new ErrorDiffusionArray$1(e,3);case"jarvis":return new ErrorDiffusionArray$1(e,4);case"burkes":return new ErrorDiffusionArray$1(e,5);case"sierra":return new ErrorDiffusionArray$1(e,6);case"two-sierra":return new ErrorDiffusionArray$1(e,7);case"sierra-lite":return new ErrorDiffusionArray$1(e,8);default:throw new Error(`Unknown imageQuantization ${t}`)}}function paletteQuantizationToPaletteQuantizer$1(e,t="wuquant",i=256){switch(t){case"neuquant":return new NeuQuant$1(e,i);case"rgbquant":return new RGBQuant$1(e,i);case"wuquant":return new WuQuant$1(e,i);case"neuquant-float":return new NeuQuantFloat$1(e,i);default:throw new Error(`Unknown paletteQuantization ${t}`)}}var imageQ=__toCommonJS(src_exports),gifframe={};const BitmapImage$1=bitmapimage;let GifFrame$1=class e extends BitmapImage$1{constructor(...t){if(super(...t),t[0]instanceof e){const e=t[0];this.xOffset=e.xOffset,this.yOffset=e.yOffset,this.disposalMethod=e.disposalMethod,this.delayCentisecs=e.delayCentisecs,this.interlaced=e.interlaced}else{const i=t[t.length-1];let r={};"object"!=typeof i||i instanceof BitmapImage$1||(r=i),this.xOffset=r.xOffset||0,this.yOffset=r.yOffset||0,this.disposalMethod=void 0!==r.disposalMethod?r.disposalMethod:e.DisposeToBackgroundColor,this.delayCentisecs=r.delayCentisecs||8,this.interlaced=r.interlaced||!1}}getPalette(){const e=new Set,t=this.bitmap.data;let i=0,r=!1;for(;i<t.length;){if(0===t[i+3])r=!0;else{const r=t.readUInt32BE(i,!0)>>8&16777215;e.add(r)}i+=4}const n=new Array(e.size),a=e.values();for(i=0;i<n.length;++i)n[i]=a.next().value;n.sort(((e,t)=>e-t));let o=n.length;return r&&++o,{colors:n,usesTransparency:r,indexCount:o}}};var hasRequiredGifutil,hasRequiredGifcodec;function requireGifutil(){return hasRequiredGifutil||(hasRequiredGifutil=1,function(e){const t=require$$0,i=imageQ,r=bitmapimage,{GifFrame:n}=gifframe,{GifError:a}=gif$1,{GifCodec:o}=requireGifcodec(),s=[".jpg",".jpeg",".png",".bmp"],l=new o;function u(e,t,r,n,a){const o=Array.isArray(e)?e:[e];if(a){if(["FloydSteinberg","FalseFloydSteinberg","Stucki","Atkinson","Jarvis","Burkes","Sierra","TwoSierra","SierraLite"].indexOf(a.ditherAlgorithm)<0)throw new Error(`Invalid ditherAlgorithm '${a.ditherAlgorithm}'`);void 0===a.serpentine&&(a.serpentine=!0),void 0===a.minimumColorDistanceToDither&&(a.minimumColorDistanceToDither=0),void 0===a.calculateErrorLikeGIMP&&(a.calculateErrorLikeGIMP=!1)}const s=new i.distance.Euclidean,l=new i.palette[t](s,r,n);let u;u=a?new i.image.ErrorDiffusionArray(s,i.image.ErrorDiffusionArrayKernel[a.ditherAlgorithm],a.serpentine,a.minimumColorDistanceToDither,a.calculateErrorLikeGIMP):new i.image.NearestColor(s);const h=[];o.forEach((e=>{const t=e.bitmap.data,r=new ArrayBuffer(t.length),n=new Uint32Array(r);for(let e=0,i=0;e<t.length;e+=4,++i)n[i]=t.readUInt32LE(e,!0);const a=i.utils.PointContainer.fromUint32Array(n,e.bitmap.width,e.bitmap.height);l.sample(a),h.push(a)}));const c=l.quantizeSync();for(let e=0;e<o.length;++e){const t=o[e].bitmap.data,i=u.quantizeSync(h[e],c).toUint32Array();for(let e=0,r=0;e<t.length;e+=4,++r)t.writeUInt32LE(i[r],e)}}e.cloneFrames=function(e){let t=[];return e.forEach((e=>{t.push(new n(e))})),t},e.getColorInfo=function(e,t){let i=!1;const r=[];for(let t=0;t<e.length;++t){let n=e[t].getPalette();if(n.usesTransparency&&(i=!0),n.indexCount>256)throw new a(`Frame ${t} uses more than 256 color indexes`);r.push(n)}if(0===t)return{usesTransparency:i,palettes:r};const n=new Set;r.forEach((e=>{e.colors.forEach((e=>{n.add(e)}))}));let o=n.size;if(i&&++o,t&&o>t)return{usesTransparency:i,palettes:r};const s=new Array(n.size),l=n.values();for(let e=0;e<s.length;++e)s[e]=l.next().value;return s.sort(((e,t)=>e-t)),{colors:s,indexCount:o,usesTransparency:i,palettes:r}},e.copyAsJimp=function(t,i){return e.shareAsJimp(t,new r(i))},e.getMaxDimensions=function(e){let t=0,i=0;return e.forEach((e=>{const r=e.xOffset+e.bitmap.width;r>t&&(t=r);const n=e.yOffset+e.bitmap.height;n>i&&(i=n)})),{maxWidth:t,maxHeight:i}},e.quantizeDekker=function(e,t,i){u(e,"NeuQuantFloat",t=t||256,0,i)},e.quantizeSorokin=function(e,t,i,r){let n;switch(t=t||256,i=i||"min-pop"){case"min-pop":n=2;break;case"top-pop":n=1;break;default:throw new Error(`Invalid quantizeSorokin histogram '${i}'`)}u(e,"RGBQuant",t,n,r)},e.quantizeWu=function(e,t,i,r){if(t=t||256,(i=i||5)<1||i>8)throw new Error("Invalid quantization quality");u(e,"WuQuant",t,i,r)},e.read=function(e,i){return i=i||l,Buffer.isBuffer(e)?i.decodeGif(e):function(e){return new Promise(((i,r)=>{t.readFile(e,((e,t)=>e?r(e):i(t)))}))}(e).then((e=>i.decodeGif(e)))},e.shareAsJimp=function(e,t){const i=new e(t.bitmap.width,t.bitmap.height,0);return i.bitmap.data=t.bitmap.data,i},e.write=function(e,i,r,n){n=n||l;const a=e.match(/\.[a-zA-Z]+$/);if(null!==a&&s.includes(a[0].toLowerCase()))throw new Error(`GIF '${e}' has an unexpected suffix`);return n.encodeGif(i,r).then((i=>function(e,i){return new Promise(((r,n)=>{t.writeFile(e,i,(e=>e?n(e):r()))}))}(e,i.buffer).then((()=>i))))}}(gifutil)),gifutil}function requireGifcodec(){if(hasRequiredGifcodec)return gifcodec;hasRequiredGifcodec=1;const e=omggif,{Gif:t,GifError:i}=gif$1;function r(){const e=requireGifutil();return r=function(){return e},e}const{GifFrame:n}=gifframe;function a(e,t){const i=e.indexOf(t);return-1===i?null:i}function o(e,t){for(var i,r=0,n=e.length-1;r<=n;)if(e[i=Math.floor((r+n)/2)]>t)n=i-1;else{if(!(e[i]<t))return i;r=i+1}return null}function s(e){const t=e.colors;e.usesTransparency&&t.push(0);const i=t.length;let r=2;for(;i>r;)r<<=1;t.length=r,t.fill(0,i)}function l(e,t){let i=e.bitmap.width*e.bitmap.height;return i=Math.ceil(i*t/8),i+=Math.ceil(i/255),100+i+768}function u(e){let t=e.indexCount,i=0;for(--t;t;)++i,t>>=1;return i>0?i:1}function h(e,t,r,n,l){if(r.interlaced)throw new i("writing interlaced GIFs is not supported");const u=function(e,t,r){const n=r.colors,s=n.length<=8?a:o,l=t.bitmap.data,u=new Buffer(l.length/4);let h=n.length,c=0,f=0;for(;c<l.length;){if(0!==l[c+3]){const e=l.readUInt32BE(c,!0)>>8&16777215;u[f]=s(n,e)}else u[f]=h;c+=4,++f}if(r.usesTransparency){if(256===h)throw new i(`Frame ${e} already has 256 colorsand so can't use transparency`)}else h=null;return{buffer:u,transparentIndex:h}}(t,r,n),h={delay:r.delayCentisecs,disposal:r.disposalMethod,transparent:u.transparentIndex};l&&(s(n),h.palette=n.colors);try{let t,i=e.getOutputBuffer(),n=e.getOutputBufferPosition(),a=!0;for(;a;)if(t=e.addFrame(r.xOffset,r.yOffset,r.bitmap.width,r.bitmap.height,u.buffer,h),a=!1,t>=i.length-1){const t=new Buffer(1.5*i.length);i.copy(t),e.setOutputBuffer(t),e.setOutputBufferPosition(n),i=t,a=!0}return i}catch(e){throw new i(e)}}return gifcodec.GifCodec=class{constructor(e={}){this._transparentRGB=null,"number"==typeof e.transparentRGB&&0!==e.transparentRGB&&(this._transparentRGBA=256*e.transparentRGB),this._testInitialBufferSize=0}decodeGif(r){try{let n;try{n=new e.GifReader(r)}catch(e){throw new i(e)}const a=n.numFrames(),o=[],s={width:n.width,height:n.height,loops:n.loopCount(),usesTransparency:!1};for(let e=0;e<a;++e){const t=this._decodeFrame(n,e,s.usesTransparency);o.push(t.frame),t.usesTransparency&&(s.usesTransparency=!0)}return Promise.resolve(new t(r,o,s))}catch(e){return Promise.reject(e)}}encodeGif(e,n={}){try{if(null===e||0===e.length)throw new i("there are no frames");const a=r().getMaxDimensions(e);return(n=Object.assign({},n)).width=a.maxWidth,n.height=a.maxHeight,void 0===n.loops&&(n.loops=0),n.colorScope=n.colorScope||t.GlobalColorsPreferred,Promise.resolve(this._encodeGif(e,n))}catch(e){return Promise.reject(e)}}_decodeFrame(e,t,r){let a,o;try{if(a=e.frameInfo(t),o=new Buffer(e.width*e.height*4),e.decodeAndBlitFrameRGBA(t,o),a.width!==e.width||a.height!==e.height){if(a.y&&(o=o.slice(a.y*e.width*4)),e.width>a.width)for(let t=0;t<a.height;++t)o.copy(o,t*a.width*4,4*(a.x+t*e.width),4*(a.x+t*e.width)+4*a.width);o=o.slice(0,a.width*a.height*4)}}catch(e){throw new i(e)}let s=!1;if(null===this._transparentRGBA){if(!r)for(let e=3;e<o.length;e+=4)0===o[e]&&(s=!0,e=o.length)}else for(let e=3;e<o.length;e+=4)0===o[e]&&(o.writeUInt32BE(this._transparentRGBA,e-3),s=!0);return{frame:new n(a.width,a.height,o,{xOffset:a.x,yOffset:a.y,disposalMethod:a.disposal,interlaced:a.interlaced,delayCentisecs:a.delay}),usesTransparency:s}}_encodeGif(n,a){let o;if(a.colorScope===t.LocalColorsOnly)o=r().getColorInfo(n,0);else if(o=r().getColorInfo(n,256),!o.colors){if(a.colorScope===t.GlobalColorsOnly)throw new i("Too many color indexes for global color table");a.colorScope=t.LocalColorsOnly}a.usesTransparency=o.usesTransparency;const l=o.palettes;if(a.colorScope===t.LocalColorsOnly){return function(r,n,a,o){const s={loop:n.loops};let l,u=new Buffer(a);try{l=new e.GifWriter(u,n.width,n.height,s)}catch(e){throw new i(e)}for(let e=0;e<r.length;++e)u=h(l,e,r[e],o[e],!0);return new t(u.slice(0,l.end()),r,n)}(n,a,2e3,l)}return function(r,n,a,o){const l={colors:o.colors.slice(),usesTransparency:o.usesTransparency};s(l);const u={palette:l.colors,loop:n.loops};let c,f=new Buffer(a);try{c=new e.GifWriter(f,n.width,n.height,u)}catch(e){throw new i(e)}for(let e=0;e<r.length;++e)f=h(c,e,r[e],o,!1);return new t(f.slice(0,c.end()),r,n)}(n,a,2e3,o)}_getSizeEstimateGlobal(e,t){if(this._testInitialBufferSize>0)return this._testInitialBufferSize;let i=968;const r=u(e);return t.forEach((e=>{i+=l(e,r)})),i}_getSizeEstimateLocal(e,t){if(this._testInitialBufferSize>0)return this._testInitialBufferSize;let i=200;for(let r=0;r<t.length;++r){const n=u(e[r]);i+=l(t[r],n)}return i}},gifcodec}GifFrame$1.DisposeToAnything=0,GifFrame$1.DisposeNothing=1,GifFrame$1.DisposeToBackgroundColor=2,GifFrame$1.DisposeToPrevious=3,gifframe.GifFrame=GifFrame$1;const BitmapImage=bitmapimage,{Gif:Gif,GifError:GifError$1}=gif$1,{GifCodec:GifCodec}=requireGifcodec(),{GifFrame:GifFrame}=gifframe,GifUtil=requireGifutil();var src={BitmapImage:BitmapImage,Gif:Gif,GifCodec:GifCodec,GifFrame:GifFrame,GifUtil:GifUtil,GifError:GifError$1};function gif(){return{mime:"image/gif",encode:async e=>{const t=new src.BitmapImage(e);src.GifUtil.quantizeDekker(t,256);const i=new src.GifFrame(e),r=new src.GifCodec;return(await r.encodeGif([i],{})).buffer},decode:e=>{const t=new omggif.GifReader(e),i=Buffer.alloc(t.width*t.height*4);return t.decodeAndBlitFrameRGBA(0,i),{data:i,width:t.width,height:t.height}}}}var encoder={exports:{}};!function(e){function t(e){var t,i,r,n,a,o=Math.floor,s=new Array(64),l=new Array(64),u=new Array(64),h=new Array(64),c=new Array(65535),f=new Array(65535),d=new Array(64),p=new Array(64),m=[],_=0,g=7,b=new Array(64),y=new Array(64),w=new Array(64),v=new Array(256),x=new Array(2048),E=[0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63],k=[0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0],S=[0,1,2,3,4,5,6,7,8,9,10,11],A=[0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125],I=[1,2,3,0,4,17,5,18,33,49,65,6,19,81,97,7,34,113,20,50,129,145,161,8,35,66,177,193,21,82,209,240,36,51,98,114,130,9,10,22,23,24,25,26,37,38,39,40,41,42,52,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,225,226,227,228,229,230,231,232,233,234,241,242,243,244,245,246,247,248,249,250],M=[0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0],T=[0,1,2,3,4,5,6,7,8,9,10,11],P=[0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,119],B=[0,1,2,3,17,4,5,33,49,6,18,65,81,7,97,113,19,34,50,129,8,20,66,145,161,177,193,9,35,51,82,240,21,98,114,209,10,22,36,52,225,37,241,23,24,25,26,38,39,40,41,42,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,130,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,226,227,228,229,230,231,232,233,234,242,243,244,245,246,247,248,249,250];function C(e,t){for(var i=0,r=0,n=new Array,a=1;a<=16;a++){for(var o=1;o<=e[a];o++)n[t[r]]=[],n[t[r]][0]=i,n[t[r]][1]=a,r++,i++;i*=2}return n}function R(e){for(var t=e[0],i=e[1]-1;i>=0;)t&1<<i&&(_|=1<<g),i--,--g<0&&(255==_?(z(255),z(0)):z(_),g=7,_=0)}function z(e){m.push(e)}function F(e){z(e>>8&255),z(255&e)}function N(e,t,i,r,n){for(var a,o=n[0],s=n[240],l=function(e,t){var i,r,n,a,o,s,l,u,h,c,f=0;for(h=0;h<8;++h){i=e[f],r=e[f+1],n=e[f+2],a=e[f+3],o=e[f+4],s=e[f+5],l=e[f+6];var p=i+(u=e[f+7]),m=i-u,_=r+l,g=r-l,b=n+s,y=n-s,w=a+o,v=a-o,x=p+w,E=p-w,k=_+b,S=_-b;e[f]=x+k,e[f+4]=x-k;var A=.707106781*(S+E);e[f+2]=E+A,e[f+6]=E-A;var I=.382683433*((x=v+y)-(S=g+m)),M=.5411961*x+I,T=1.306562965*S+I,P=.707106781*(k=y+g),B=m+P,C=m-P;e[f+5]=C+M,e[f+3]=C-M,e[f+1]=B+T,e[f+7]=B-T,f+=8}for(f=0,h=0;h<8;++h){i=e[f],r=e[f+8],n=e[f+16],a=e[f+24],o=e[f+32],s=e[f+40],l=e[f+48];var R=i+(u=e[f+56]),z=i-u,F=r+l,N=r-l,O=n+s,D=n-s,$=a+o,L=a-o,U=R+$,Z=R-$,j=F+O,G=F-O;e[f]=U+j,e[f+32]=U-j;var H=.707106781*(G+Z);e[f+16]=Z+H,e[f+48]=Z-H;var Q=.382683433*((U=L+D)-(G=N+z)),W=.5411961*U+Q,q=1.306562965*G+Q,V=.707106781*(j=D+N),Y=z+V,K=z-V;e[f+40]=K+W,e[f+24]=K-W,e[f+8]=Y+q,e[f+56]=Y-q,f++}for(h=0;h<64;++h)c=e[h]*t[h],d[h]=c>0?c+.5|0:c-.5|0;return d}(e,t),u=0;u<64;++u)p[E[u]]=l[u];var h=p[0]-i;i=p[0],0==h?R(r[0]):(R(r[f[a=32767+h]]),R(c[a]));for(var m=63;m>0&&0==p[m];m--);if(0==m)return R(o),i;for(var _,g=1;g<=m;){for(var b=g;0==p[g]&&g<=m;++g);var y=g-b;if(y>=16){_=y>>4;for(var w=1;w<=_;++w)R(s);y&=15}a=32767+p[g],R(n[(y<<4)+f[a]]),R(c[a]),g++}return 63!=m&&R(o),i}function O(e){if(e<=0&&(e=1),e>100&&(e=100),a!=e){(function(e){for(var t=[16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22,37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99],i=0;i<64;i++){var r=o((t[i]*e+50)/100);r<1?r=1:r>255&&(r=255),s[E[i]]=r}for(var n=[17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99],a=0;a<64;a++){var c=o((n[a]*e+50)/100);c<1?c=1:c>255&&(c=255),l[E[a]]=c}for(var f=[1,1.387039845,1.306562965,1.175875602,1,.785694958,.5411961,.275899379],d=0,p=0;p<8;p++)for(var m=0;m<8;m++)u[d]=1/(s[E[d]]*f[p]*f[m]*8),h[d]=1/(l[E[d]]*f[p]*f[m]*8),d++})(e<50?Math.floor(5e3/e):Math.floor(200-2*e)),a=e}}this.encode=function(e,a){var o;(new Date).getTime(),a&&O(a),m=new Array,_=0,g=7,F(65496),F(65504),F(16),z(74),z(70),z(73),z(70),z(0),z(1),z(1),z(0),F(1),F(1),z(0),z(0),void 0!==(o=e.comments)&&o.constructor===Array&&o.forEach((e=>{if("string"==typeof e){F(65534);var t,i=e.length;for(F(i+2),t=0;t<i;t++)z(e.charCodeAt(t))}})),function(e){if(e){F(65505),69===e[0]&&120===e[1]&&105===e[2]&&102===e[3]?F(e.length+2):(F(e.length+5+2),z(69),z(120),z(105),z(102),z(0));for(var t=0;t<e.length;t++)z(e[t])}}(e.exifBuffer),function(){F(65499),F(132),z(0);for(var e=0;e<64;e++)z(s[e]);z(1);for(var t=0;t<64;t++)z(l[t])}(),function(e,t){F(65472),F(17),z(8),F(t),F(e),z(3),z(1),z(17),z(0),z(2),z(17),z(1),z(3),z(17),z(1)}(e.width,e.height),function(){F(65476),F(418),z(0);for(var e=0;e<16;e++)z(k[e+1]);for(var t=0;t<=11;t++)z(S[t]);z(16);for(var i=0;i<16;i++)z(A[i+1]);for(var r=0;r<=161;r++)z(I[r]);z(1);for(var n=0;n<16;n++)z(M[n+1]);for(var a=0;a<=11;a++)z(T[a]);z(17);for(var o=0;o<16;o++)z(P[o+1]);for(var s=0;s<=161;s++)z(B[s])}(),F(65498),F(12),z(3),z(1),z(0),z(2),z(17),z(3),z(17),z(0),z(63),z(0);var c=0,f=0,d=0;_=0,g=7,this.encode.displayName="_encode_";for(var p,v,E,C,D,$,L,U,Z,j=e.data,G=e.width,H=e.height,Q=4*G,W=0;W<H;){for(p=0;p<Q;){for($=D=Q*W+p,L=-1,U=0,Z=0;Z<64;Z++)$=D+(U=Z>>3)*Q+(L=4*(7&Z)),W+U>=H&&($-=Q*(W+1+U-H)),p+L>=Q&&($-=p+L-Q+4),v=j[$++],E=j[$++],C=j[$++],b[Z]=(x[v]+x[E+256|0]+x[C+512|0]>>16)-128,y[Z]=(x[v+768|0]+x[E+1024|0]+x[C+1280|0]>>16)-128,w[Z]=(x[v+1280|0]+x[E+1536|0]+x[C+1792|0]>>16)-128;c=N(b,u,c,t,r),f=N(y,h,f,i,n),d=N(w,h,d,i,n),p+=32}W+=8}if(g>=0){var q=[];q[1]=g+1,q[0]=(1<<g+1)-1,R(q)}return F(65497),Buffer.from(m)},(new Date).getTime(),e||(e=50),function(){for(var e=String.fromCharCode,t=0;t<256;t++)v[t]=e(t)}(),t=C(k,S),i=C(M,T),r=C(A,I),n=C(P,B),function(){for(var e=1,t=2,i=1;i<=15;i++){for(var r=e;r<t;r++)f[32767+r]=i,c[32767+r]=[],c[32767+r][1]=i,c[32767+r][0]=r;for(var n=-(t-1);n<=-e;n++)f[32767+n]=i,c[32767+n]=[],c[32767+n][1]=i,c[32767+n][0]=t-1+n;e<<=1,t<<=1}}(),function(){for(var e=0;e<256;e++)x[e]=19595*e,x[e+256|0]=38470*e,x[e+512|0]=7471*e+32768,x[e+768|0]=-11059*e,x[e+1024|0]=-21709*e,x[e+1280|0]=32768*e+8421375,x[e+1536|0]=-27439*e,x[e+1792|0]=-5329*e}(),O(e),(new Date).getTime()}encoder.exports=function(e,i){void 0===i&&(i=50);var r=new t(i),n=r.encode(e,i);return{data:n,width:e.width,height:e.height}}}();var encoderExports=encoder.exports,decoder={exports:{}},module,JpegImage;module=decoder,JpegImage=function(){var e=new Int32Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),t=4017,i=799,r=3406,n=2276,a=1567,o=3784,s=5793,l=2896;function u(){}function h(e,t){for(var i,r,n=0,a=[],o=16;o>0&&!e[o-1];)o--;a.push({children:[],index:0});var s,l=a[0];for(i=0;i<o;i++){for(r=0;r<e[i];r++){for((l=a.pop()).children[l.index]=t[n];l.index>0;){if(0===a.length)throw new Error("Could not recreate Huffman Table");l=a.pop()}for(l.index++,a.push(l);a.length<=i;)a.push(s={children:[],index:0}),l.children[l.index]=s.children,l=s;n++}i+1<o&&(a.push(s={children:[],index:0}),l.children[l.index]=s.children,l=s)}return a[0].children}function c(t,i,r,n,a,o,s,l,u,h){r.precision,r.samplesPerLine,r.scanLines;var c=r.mcusPerLine,f=r.progressive;r.maxH,r.maxV;var d=i,p=0,m=0;function _(){if(m>0)return m--,p>>m&1;if(255==(p=t[i++])){var e=t[i++];if(e)throw new Error("unexpected marker: "+(p<<8|e).toString(16))}return m=7,p>>>7}function g(e){for(var t,i=e;null!==(t=_());){if("number"==typeof(i=i[t]))return i;if("object"!=typeof i)throw new Error("invalid huffman sequence")}return null}function b(e){for(var t=0;e>0;){var i=_();if(null===i)return;t=t<<1|i,e--}return t}function y(e){var t=b(e);return t>=1<<e-1?t:t+(-1<<e)+1}var w,v=0,x=0;function E(e,t,i,r,n){var a=i%c,o=(i/c|0)*e.v+r,s=a*e.h+n;void 0===e.blocks[o]&&h.tolerantDecoding||t(e,e.blocks[o][s])}function k(e,t,i){var r=i/e.blocksPerLine|0,n=i%e.blocksPerLine;void 0===e.blocks[r]&&h.tolerantDecoding||t(e,e.blocks[r][n])}var S,A,I,M,T,P,B=n.length;P=f?0===o?0===l?function(e,t){var i=g(e.huffmanTableDC),r=0===i?0:y(i)<<u;t[0]=e.pred+=r}:function(e,t){t[0]|=_()<<u}:0===l?function(t,i){if(v>0)v--;else for(var r=o,n=s;r<=n;){var a=g(t.huffmanTableAC),l=15&a,h=a>>4;if(0!==l)i[e[r+=h]]=y(l)*(1<<u),r++;else{if(h<15){v=b(h)+(1<<h)-1;break}r+=16}}}:function(t,i){for(var r=o,n=s,a=0;r<=n;){var l=e[r],h=i[l]<0?-1:1;switch(x){case 0:var c=g(t.huffmanTableAC),f=15&c;if(a=c>>4,0===f)a<15?(v=b(a)+(1<<a),x=4):(a=16,x=1);else{if(1!==f)throw new Error("invalid ACn encoding");w=y(f),x=a?2:3}continue;case 1:case 2:i[l]?i[l]+=(_()<<u)*h:0==--a&&(x=2==x?3:0);break;case 3:i[l]?i[l]+=(_()<<u)*h:(i[l]=w<<u,x=0);break;case 4:i[l]&&(i[l]+=(_()<<u)*h)}r++}4===x&&0==--v&&(x=0)}:function(t,i){var r=g(t.huffmanTableDC),n=0===r?0:y(r);i[0]=t.pred+=n;for(var a=1;a<64;){var o=g(t.huffmanTableAC),s=15&o,l=o>>4;if(0!==s)i[e[a+=l]]=y(s),a++;else{if(l<15)break;a+=16}}};var C,R,z,F,N=0;for(R=1==B?n[0].blocksPerLine*n[0].blocksPerColumn:c*r.mcusPerColumn,a||(a=R);N<R;){for(A=0;A<B;A++)n[A].pred=0;if(v=0,1==B)for(S=n[0],T=0;T<a;T++)k(S,P,N),N++;else for(T=0;T<a;T++){for(A=0;A<B;A++)for(z=(S=n[A]).h,F=S.v,I=0;I<F;I++)for(M=0;M<z;M++)E(S,P,N,I,M);if(++N===R)break}if(N===R)do{if(255===t[i]&&0!==t[i+1])break;i+=1}while(i<t.length-2);if(m=0,(C=t[i]<<8|t[i+1])<65280)throw new Error("marker was not found");if(!(C>=65488&&C<=65495))break;i+=2}return i-d}function f(e,u){var h,c,f=[],d=u.blocksPerLine,p=u.blocksPerColumn,m=d<<3,g=new Int32Array(64),b=new Uint8Array(64);function y(e,h,c){var f,d,p,m,_,g,b,y,w,v,x=u.quantizationTable,E=c;for(v=0;v<64;v++)E[v]=e[v]*x[v];for(v=0;v<8;++v){var k=8*v;0!=E[1+k]||0!=E[2+k]||0!=E[3+k]||0!=E[4+k]||0!=E[5+k]||0!=E[6+k]||0!=E[7+k]?(f=s*E[0+k]+128>>8,d=s*E[4+k]+128>>8,p=E[2+k],m=E[6+k],_=l*(E[1+k]-E[7+k])+128>>8,y=l*(E[1+k]+E[7+k])+128>>8,g=E[3+k]<<4,b=E[5+k]<<4,w=f-d+1>>1,f=f+d+1>>1,d=w,w=p*o+m*a+128>>8,p=p*a-m*o+128>>8,m=w,w=_-b+1>>1,_=_+b+1>>1,b=w,w=y+g+1>>1,g=y-g+1>>1,y=w,w=f-m+1>>1,f=f+m+1>>1,m=w,w=d-p+1>>1,d=d+p+1>>1,p=w,w=_*n+y*r+2048>>12,_=_*r-y*n+2048>>12,y=w,w=g*i+b*t+2048>>12,g=g*t-b*i+2048>>12,b=w,E[0+k]=f+y,E[7+k]=f-y,E[1+k]=d+b,E[6+k]=d-b,E[2+k]=p+g,E[5+k]=p-g,E[3+k]=m+_,E[4+k]=m-_):(w=s*E[0+k]+512>>10,E[0+k]=w,E[1+k]=w,E[2+k]=w,E[3+k]=w,E[4+k]=w,E[5+k]=w,E[6+k]=w,E[7+k]=w)}for(v=0;v<8;++v){var S=v;0!=E[8+S]||0!=E[16+S]||0!=E[24+S]||0!=E[32+S]||0!=E[40+S]||0!=E[48+S]||0!=E[56+S]?(f=s*E[0+S]+2048>>12,d=s*E[32+S]+2048>>12,p=E[16+S],m=E[48+S],_=l*(E[8+S]-E[56+S])+2048>>12,y=l*(E[8+S]+E[56+S])+2048>>12,g=E[24+S],b=E[40+S],w=f-d+1>>1,f=f+d+1>>1,d=w,w=p*o+m*a+2048>>12,p=p*a-m*o+2048>>12,m=w,w=_-b+1>>1,_=_+b+1>>1,b=w,w=y+g+1>>1,g=y-g+1>>1,y=w,w=f-m+1>>1,f=f+m+1>>1,m=w,w=d-p+1>>1,d=d+p+1>>1,p=w,w=_*n+y*r+2048>>12,_=_*r-y*n+2048>>12,y=w,w=g*i+b*t+2048>>12,g=g*t-b*i+2048>>12,b=w,E[0+S]=f+y,E[56+S]=f-y,E[8+S]=d+b,E[48+S]=d-b,E[16+S]=p+g,E[40+S]=p-g,E[24+S]=m+_,E[32+S]=m-_):(w=s*c[v+0]+8192>>14,E[0+S]=w,E[8+S]=w,E[16+S]=w,E[24+S]=w,E[32+S]=w,E[40+S]=w,E[48+S]=w,E[56+S]=w)}for(v=0;v<64;++v){var A=128+(E[v]+8>>4);h[v]=A<0?0:A>255?255:A}}_(m*p*8);for(var w=0;w<p;w++){var v=w<<3;for(h=0;h<8;h++)f.push(new Uint8Array(m));for(var x=0;x<d;x++){y(u.blocks[w][x],b,g);var E=0,k=x<<3;for(c=0;c<8;c++){var S=f[v+c];for(h=0;h<8;h++)S[k+h]=b[E++]}}}return f}function d(e){return e<0?0:e>255?255:e}u.prototype={load:function(e){var t=new XMLHttpRequest;t.open("GET",e,!0),t.responseType="arraybuffer",t.onload=function(){var e=new Uint8Array(t.response||t.mozResponseArrayBuffer);this.parse(e),this.onload&&this.onload()}.bind(this),t.send(null)},parse:function(t){var i=1e3*this.opts.maxResolutionInMP*1e3,r=0;function n(){var e=t[r]<<8|t[r+1];return r+=2,e}function a(e){var t,i,r=1,n=1;for(i in e.components)e.components.hasOwnProperty(i)&&(r<(t=e.components[i]).h&&(r=t.h),n<t.v&&(n=t.v));var a=Math.ceil(e.samplesPerLine/8/r),o=Math.ceil(e.scanLines/8/n);for(i in e.components)if(e.components.hasOwnProperty(i)){t=e.components[i];var s=Math.ceil(Math.ceil(e.samplesPerLine/8)*t.h/r),l=Math.ceil(Math.ceil(e.scanLines/8)*t.v/n),u=a*t.h,h=o*t.v,c=[];_(h*u*256);for(var f=0;f<h;f++){for(var d=[],p=0;p<u;p++)d.push(new Int32Array(64));c.push(d)}t.blocksPerLine=s,t.blocksPerColumn=l,t.blocks=c}e.maxH=r,e.maxV=n,e.mcusPerLine=a,e.mcusPerColumn=o}t.length;var o,s,l,u,d=null,p=null,m=[],g=[],b=[],y=[],w=n(),v=-1;if(this.comments=[],65496!=w)throw new Error("SOI not found");for(w=n();65497!=w;){switch(w){case 65280:break;case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:case 65534:var x=(l=void 0,u=void 0,l=n(),u=t.subarray(r,r+l-2),r+=u.length,u);if(65534===w){var E=String.fromCharCode.apply(null,x);this.comments.push(E)}65504===w&&74===x[0]&&70===x[1]&&73===x[2]&&70===x[3]&&0===x[4]&&(d={version:{major:x[5],minor:x[6]},densityUnits:x[7],xDensity:x[8]<<8|x[9],yDensity:x[10]<<8|x[11],thumbWidth:x[12],thumbHeight:x[13],thumbData:x.subarray(14,14+3*x[12]*x[13])}),65505===w&&69===x[0]&&120===x[1]&&105===x[2]&&102===x[3]&&0===x[4]&&(this.exifBuffer=x.subarray(5,x.length)),65518===w&&65===x[0]&&100===x[1]&&111===x[2]&&98===x[3]&&101===x[4]&&0===x[5]&&(p={version:x[6],flags0:x[7]<<8|x[8],flags1:x[9]<<8|x[10],transformCode:x[11]});break;case 65499:for(var k=n()+r-2;r<k;){var S=t[r++];_(256);var A=new Int32Array(64);if(S>>4){if(S>>4!=1)throw new Error("DQT: invalid table spec");for(q=0;q<64;q++)A[e[q]]=n()}else for(q=0;q<64;q++)A[e[q]]=t[r++];m[15&S]=A}break;case 65472:case 65473:case 65474:n(),(o={}).extended=65473===w,o.progressive=65474===w,o.precision=t[r++],o.scanLines=n(),o.samplesPerLine=n(),o.components={},o.componentsOrder=[];var I=o.scanLines*o.samplesPerLine;if(I>i){var M=Math.ceil((I-i)/1e6);throw new Error(`maxResolutionInMP limit exceeded by ${M}MP`)}var T,P=t[r++];for(Q=0;Q<P;Q++){T=t[r];var B=t[r+1]>>4,C=15&t[r+1],R=t[r+2];if(B<=0||C<=0)throw new Error("Invalid sampling factor, expected values above 0");o.componentsOrder.push(T),o.components[T]={h:B,v:C,quantizationIdx:R},r+=3}a(o),g.push(o);break;case 65476:var z=n();for(Q=2;Q<z;){var F=t[r++],N=new Uint8Array(16),O=0;for(q=0;q<16;q++,r++)O+=N[q]=t[r];_(16+O);var D=new Uint8Array(O);for(q=0;q<O;q++,r++)D[q]=t[r];Q+=17+O,(F>>4?b:y)[15&F]=h(N,D)}break;case 65501:n(),s=n();break;case 65500:n(),n();break;case 65498:n();var $=t[r++],L=[];for(Q=0;Q<$;Q++){V=o.components[t[r++]];var U=t[r++];V.huffmanTableDC=y[U>>4],V.huffmanTableAC=b[15&U],L.push(V)}var Z=t[r++],j=t[r++],G=t[r++],H=c(t,r,o,L,s,Z,j,G>>4,15&G,this.opts);r+=H;break;case 65535:255!==t[r]&&r--;break;default:if(255==t[r-3]&&t[r-2]>=192&&t[r-2]<=254){r-=3;break}if(224===w||225==w){if(-1!==v)throw new Error(`first unknown JPEG marker at offset ${v.toString(16)}, second unknown JPEG marker ${w.toString(16)} at offset ${(r-1).toString(16)}`);v=r-1;const e=n();if(255===t[r+e-2]){r+=e-2;break}}throw new Error("unknown JPEG marker "+w.toString(16))}w=n()}if(1!=g.length)throw new Error("only single frame JPEGs supported");for(var Q=0;Q<g.length;Q++){var W=g[Q].components;for(var q in W)W[q].quantizationTable=m[W[q].quantizationIdx],delete W[q].quantizationIdx}for(this.width=o.samplesPerLine,this.height=o.scanLines,this.jfif=d,this.adobe=p,this.components=[],Q=0;Q<o.componentsOrder.length;Q++){var V=o.components[o.componentsOrder[Q]];this.components.push({lines:f(0,V),scaleX:V.h/o.maxH,scaleY:V.v/o.maxV})}},getData:function(e,t){var i,r,n,a,o,s,l,u,h,c,f,p,m,g,b,y,w,v,x,E,k,S=this.width/e,A=this.height/t,I=0,M=e*t*this.components.length;_(M);var T=new Uint8Array(M);switch(this.components.length){case 1:for(i=this.components[0],c=0;c<t;c++)for(o=i.lines[0|c*i.scaleY*A],h=0;h<e;h++)f=o[0|h*i.scaleX*S],T[I++]=f;break;case 2:for(i=this.components[0],r=this.components[1],c=0;c<t;c++)for(o=i.lines[0|c*i.scaleY*A],s=r.lines[0|c*r.scaleY*A],h=0;h<e;h++)f=o[0|h*i.scaleX*S],T[I++]=f,f=s[0|h*r.scaleX*S],T[I++]=f;break;case 3:for(k=!0,this.adobe&&this.adobe.transformCode?k=!0:void 0!==this.opts.colorTransform&&(k=!!this.opts.colorTransform),i=this.components[0],r=this.components[1],n=this.components[2],c=0;c<t;c++)for(o=i.lines[0|c*i.scaleY*A],s=r.lines[0|c*r.scaleY*A],l=n.lines[0|c*n.scaleY*A],h=0;h<e;h++)k?(f=o[0|h*i.scaleX*S],p=s[0|h*r.scaleX*S],v=d(f+1.402*((m=l[0|h*n.scaleX*S])-128)),x=d(f-.3441363*(p-128)-.71413636*(m-128)),E=d(f+1.772*(p-128))):(v=o[0|h*i.scaleX*S],x=s[0|h*r.scaleX*S],E=l[0|h*n.scaleX*S]),T[I++]=v,T[I++]=x,T[I++]=E;break;case 4:if(!this.adobe)throw new Error("Unsupported color mode (4 components)");for(k=!1,this.adobe&&this.adobe.transformCode?k=!0:void 0!==this.opts.colorTransform&&(k=!!this.opts.colorTransform),i=this.components[0],r=this.components[1],n=this.components[2],a=this.components[3],c=0;c<t;c++)for(o=i.lines[0|c*i.scaleY*A],s=r.lines[0|c*r.scaleY*A],l=n.lines[0|c*n.scaleY*A],u=a.lines[0|c*a.scaleY*A],h=0;h<e;h++)k?(f=o[0|h*i.scaleX*S],p=s[0|h*r.scaleX*S],m=l[0|h*n.scaleX*S],g=u[0|h*a.scaleX*S],b=255-d(f+1.402*(m-128)),y=255-d(f-.3441363*(p-128)-.71413636*(m-128)),w=255-d(f+1.772*(p-128))):(b=o[0|h*i.scaleX*S],y=s[0|h*r.scaleX*S],w=l[0|h*n.scaleX*S],g=u[0|h*a.scaleX*S]),T[I++]=255-b,T[I++]=255-y,T[I++]=255-w,T[I++]=255-g;break;default:throw new Error("Unsupported color mode")}return T},copyToImageData:function(e,t){var i,r,n,a,o,s,l,u,h,c=e.width,f=e.height,p=e.data,m=this.getData(c,f),_=0,g=0;switch(this.components.length){case 1:for(r=0;r<f;r++)for(i=0;i<c;i++)n=m[_++],p[g++]=n,p[g++]=n,p[g++]=n,t&&(p[g++]=255);break;case 3:for(r=0;r<f;r++)for(i=0;i<c;i++)l=m[_++],u=m[_++],h=m[_++],p[g++]=l,p[g++]=u,p[g++]=h,t&&(p[g++]=255);break;case 4:for(r=0;r<f;r++)for(i=0;i<c;i++)o=m[_++],s=m[_++],n=m[_++],l=255-d(o*(1-(a=m[_++])/255)+a),u=255-d(s*(1-a/255)+a),h=255-d(n*(1-a/255)+a),p[g++]=l,p[g++]=u,p[g++]=h,t&&(p[g++]=255);break;default:throw new Error("Unsupported color mode")}}};var p=0,m=0;function _(e=0){var t=p+e;if(t>m){var i=Math.ceil((t-m)/1024/1024);throw new Error(`maxMemoryUsageInMB limit exceeded by at least ${i}MB`)}p=t}return u.resetMaxMemoryUsage=function(e){p=0,m=e},u.getBytesAllocated=function(){return p},u.requestMemoryAllocation=_,u}(),module.exports=function(e,t={}){var i={colorTransform:void 0,useTArray:!1,formatAsRGBA:!0,tolerantDecoding:!0,maxResolutionInMP:100,maxMemoryUsageInMB:512,...t},r=new Uint8Array(e),n=new JpegImage;n.opts=i,JpegImage.resetMaxMemoryUsage(1024*i.maxMemoryUsageInMB*1024),n.parse(r);var a=i.formatAsRGBA?4:3,o=n.width*n.height*a;try{JpegImage.requestMemoryAllocation(o);var s={width:n.width,height:n.height,exifBuffer:n.exifBuffer,data:i.useTArray?new Uint8Array(o):Buffer.alloc(o)};n.comments.length>0&&(s.comments=n.comments)}catch(e){if(e instanceof RangeError)throw new Error("Could not allocate enough memory for the image. Required: "+o);if(e instanceof ReferenceError&&"Buffer is not defined"===e.message)throw new Error("Buffer is not globally defined in this environment. Consider setting useTArray to true");throw e}return n.copyToImageData(s,i.formatAsRGBA),s};var decoderExports=decoder.exports,encode=encoderExports,decode=decoderExports,jpegJs={encode:encode,decode:decode},JPEG=getDefaultExportFromCjs(jpegJs);function jpeg$2(){return{mime:"image/jpeg",encode:(e,{quality:t=100}={})=>JPEG.encode(e,t).data,decode:(e,t)=>JPEG.decode(e,t)}}function commonjsRequire(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var browser$1={exports:{}};browser$1.exports=function(){function e(t,i,r){function n(o,s){if(!i[o]){if(!t[o]){var l="function"==typeof commonjsRequire&&commonjsRequire;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var h=i[o]={exports:{}};t[o][0].call(h.exports,(function(e){return n(t[o][1][e]||e)}),h,h.exports,e,t,i,r)}return i[o].exports}for(var a="function"==typeof commonjsRequire&&commonjsRequire,o=0;o<r.length;o++)n(r[o]);return n}return e}()({1:[function(e,t,i){(function(t){(function(){let r=e("./interlace"),n=[function(){},function(e,t,i,r){if(r===t.length)throw new Error("Ran out of data");let n=t[r];e[i]=n,e[i+1]=n,e[i+2]=n,e[i+3]=255},function(e,t,i,r){if(r+1>=t.length)throw new Error("Ran out of data");let n=t[r];e[i]=n,e[i+1]=n,e[i+2]=n,e[i+3]=t[r+1]},function(e,t,i,r){if(r+2>=t.length)throw new Error("Ran out of data");e[i]=t[r],e[i+1]=t[r+1],e[i+2]=t[r+2],e[i+3]=255},function(e,t,i,r){if(r+3>=t.length)throw new Error("Ran out of data");e[i]=t[r],e[i+1]=t[r+1],e[i+2]=t[r+2],e[i+3]=t[r+3]}],a=[function(){},function(e,t,i,r){let n=t[0];e[i]=n,e[i+1]=n,e[i+2]=n,e[i+3]=r},function(e,t,i){let r=t[0];e[i]=r,e[i+1]=r,e[i+2]=r,e[i+3]=t[1]},function(e,t,i,r){e[i]=t[0],e[i+1]=t[1],e[i+2]=t[2],e[i+3]=r},function(e,t,i){e[i]=t[0],e[i+1]=t[1],e[i+2]=t[2],e[i+3]=t[3]}];function o(e,t){let i=[],r=0;function n(){if(r===e.length)throw new Error("Ran out of data");let n,a,o,s,l,u,h,c,f=e[r];switch(r++,t){default:throw new Error("unrecognised depth");case 16:h=e[r],r++,i.push((f<<8)+h);break;case 4:h=15&f,c=f>>4,i.push(c,h);break;case 2:l=3&f,u=f>>2&3,h=f>>4&3,c=f>>6&3,i.push(c,h,u,l);break;case 1:n=1&f,a=f>>1&1,o=f>>2&1,s=f>>3&1,l=f>>4&1,u=f>>5&1,h=f>>6&1,c=f>>7&1,i.push(c,h,u,l,s,o,a,n)}}return{get:function(e){for(;i.length<e;)n();let t=i.slice(0,e);return i=i.slice(e),t},resetAfterLine:function(){i.length=0},end:function(){if(r!==e.length)throw new Error("extra data found")}}}function s(e,t,i,r,a,o){let s=e.width,l=e.height,u=e.index;for(let e=0;e<l;e++)for(let l=0;l<s;l++){let s=i(l,e,u);n[r](t,a,s,o),o+=r}return o}function l(e,t,i,r,n,o){let s=e.width,l=e.height,u=e.index;for(let e=0;e<l;e++){for(let l=0;l<s;l++){let s=n.get(r),h=i(l,e,u);a[r](t,s,h,o)}n.resetAfterLine()}}i.dataToBitMap=function(e,i){let n,a,u=i.width,h=i.height,c=i.depth,f=i.bpp,d=i.interlace;8!==c&&(n=o(e,c)),a=c<=8?t.alloc(u*h*4):new Uint16Array(u*h*4);let p,m,_=Math.pow(2,c)-1,g=0;if(d)p=r.getImagePasses(u,h),m=r.getInterlaceIterator(u,h);else{let e=0;m=function(){let t=e;return e+=4,t},p=[{width:u,height:h}]}for(let t=0;t<p.length;t++)8===c?g=s(p[t],a,m,f,e,g):l(p[t],a,m,f,n,_);if(8===c){if(g!==e.length)throw new Error("extra data found")}else n.end();return a}}).call(this)}).call(this,e("buffer").Buffer)},{"./interlace":11,buffer:32}],2:[function(e,t,i){(function(i){(function(){let r=e("./constants");t.exports=function(e,t,n,a){let o=-1!==[r.COLORTYPE_COLOR_ALPHA,r.COLORTYPE_ALPHA].indexOf(a.colorType);if(a.colorType===a.inputColorType){let t=function(){let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),256!==new Int16Array(e)[0]}();if(8===a.bitDepth||16===a.bitDepth&&t)return e}let s=16!==a.bitDepth?e:new Uint16Array(e.buffer),l=255,u=r.COLORTYPE_TO_BPP_MAP[a.inputColorType];4!==u||a.inputHasAlpha||(u=3);let h=r.COLORTYPE_TO_BPP_MAP[a.colorType];16===a.bitDepth&&(l=65535,h*=2);let c=i.alloc(t*n*h),f=0,d=0,p=a.bgColor||{};function m(){let e,t,i,n=l;switch(a.inputColorType){case r.COLORTYPE_COLOR_ALPHA:n=s[f+3],e=s[f],t=s[f+1],i=s[f+2];break;case r.COLORTYPE_COLOR:e=s[f],t=s[f+1],i=s[f+2];break;case r.COLORTYPE_ALPHA:n=s[f+1],e=s[f],t=e,i=e;break;case r.COLORTYPE_GRAYSCALE:e=s[f],t=e,i=e;break;default:throw new Error("input color type:"+a.inputColorType+" is not supported at present")}return a.inputHasAlpha&&(o||(n/=l,e=Math.min(Math.max(Math.round((1-n)*p.red+n*e),0),l),t=Math.min(Math.max(Math.round((1-n)*p.green+n*t),0),l),i=Math.min(Math.max(Math.round((1-n)*p.blue+n*i),0),l))),{red:e,green:t,blue:i,alpha:n}}void 0===p.red&&(p.red=l),void 0===p.green&&(p.green=l),void 0===p.blue&&(p.blue=l);for(let e=0;e<n;e++)for(let e=0;e<t;e++){let e=m();switch(a.colorType){case r.COLORTYPE_COLOR_ALPHA:case r.COLORTYPE_COLOR:8===a.bitDepth?(c[d]=e.red,c[d+1]=e.green,c[d+2]=e.blue,o&&(c[d+3]=e.alpha)):(c.writeUInt16BE(e.red,d),c.writeUInt16BE(e.green,d+2),c.writeUInt16BE(e.blue,d+4),o&&c.writeUInt16BE(e.alpha,d+6));break;case r.COLORTYPE_ALPHA:case r.COLORTYPE_GRAYSCALE:{let t=(e.red+e.green+e.blue)/3;8===a.bitDepth?(c[d]=t,o&&(c[d+1]=e.alpha)):(c.writeUInt16BE(t,d),o&&c.writeUInt16BE(e.alpha,d+2));break}default:throw new Error("unrecognised color Type "+a.colorType)}f+=u,d+=h}return c}}).call(this)}).call(this,e("buffer").Buffer)},{"./constants":4,buffer:32}],3:[function(e,t,i){(function(i,r){(function(){let n=e("util"),a=e("stream"),o=t.exports=function(){a.call(this),this._buffers=[],this._buffered=0,this._reads=[],this._paused=!1,this._encoding="utf8",this.writable=!0};n.inherits(o,a),o.prototype.read=function(e,t){this._reads.push({length:Math.abs(e),allowLess:e<0,func:t}),i.nextTick(function(){this._process(),this._paused&&this._reads&&this._reads.length>0&&(this._paused=!1,this.emit("drain"))}.bind(this))},o.prototype.write=function(e,t){if(!this.writable)return this.emit("error",new Error("Stream not writable")),!1;let i;return i=r.isBuffer(e)?e:r.from(e,t||this._encoding),this._buffers.push(i),this._buffered+=i.length,this._process(),this._reads&&0===this._reads.length&&(this._paused=!0),this.writable&&!this._paused},o.prototype.end=function(e,t){e&&this.write(e,t),this.writable=!1,this._buffers&&(0===this._buffers.length?this._end():(this._buffers.push(null),this._process()))},o.prototype.destroySoon=o.prototype.end,o.prototype._end=function(){this._reads.length>0&&this.emit("error",new Error("Unexpected end of input")),this.destroy()},o.prototype.destroy=function(){this._buffers&&(this.writable=!1,this._reads=null,this._buffers=null,this.emit("close"))},o.prototype._processReadAllowingLess=function(e){this._reads.shift();let t=this._buffers[0];t.length>e.length?(this._buffered-=e.length,this._buffers[0]=t.slice(e.length),e.func.call(this,t.slice(0,e.length))):(this._buffered-=t.length,this._buffers.shift(),e.func.call(this,t))},o.prototype._processRead=function(e){this._reads.shift();let t=0,i=0,n=r.alloc(e.length);for(;t<e.length;){let r=this._buffers[i++],a=Math.min(r.length,e.length-t);r.copy(n,t,0,a),t+=a,a!==r.length&&(this._buffers[--i]=r.slice(a))}i>0&&this._buffers.splice(0,i),this._buffered-=e.length,e.func.call(this,n)},o.prototype._process=function(){try{for(;this._buffered>0&&this._reads&&this._reads.length>0;){let e=this._reads[0];if(e.allowLess)this._processReadAllowingLess(e);else{if(!(this._buffered>=e.length))break;this._processRead(e)}}this._buffers&&!this.writable&&this._end()}catch(e){this.emit("error",e)}}}).call(this)}).call(this,e("_process"),e("buffer").Buffer)},{_process:63,buffer:32,stream:65,util:84}],4:[function(e,t,i){t.exports={PNG_SIGNATURE:[137,80,78,71,13,10,26,10],TYPE_IHDR:1229472850,TYPE_IEND:1229278788,TYPE_IDAT:1229209940,TYPE_PLTE:1347179589,TYPE_tRNS:1951551059,TYPE_gAMA:1732332865,COLORTYPE_GRAYSCALE:0,COLORTYPE_PALETTE:1,COLORTYPE_COLOR:2,COLORTYPE_ALPHA:4,COLORTYPE_PALETTE_COLOR:3,COLORTYPE_COLOR_ALPHA:6,COLORTYPE_TO_BPP_MAP:{0:1,2:3,3:1,4:2,6:4},GAMMA_DIVISION:1e5}},{}],5:[function(e,t,i){let r=[];!function(){for(let e=0;e<256;e++){let t=e;for(let e=0;e<8;e++)1&t?t=3988292384^t>>>1:t>>>=1;r[e]=t}}();let n=t.exports=function(){this._crc=-1};n.prototype.write=function(e){for(let t=0;t<e.length;t++)this._crc=r[255&(this._crc^e[t])]^this._crc>>>8;return!0},n.prototype.crc32=function(){return~this._crc},n.crc32=function(e){let t=-1;for(let i=0;i<e.length;i++)t=r[255&(t^e[i])]^t>>>8;return~t}},{}],6:[function(e,t,i){(function(i){(function(){let r=e("./paeth-predictor");function n(e,t,i,r,n){for(let a=0;a<i;a++)r[n+a]=e[t+a]}function a(e,t,i){let r=0,n=t+i;for(let i=t;i<n;i++)r+=Math.abs(e[i]);return r}function o(e,t,i,r,n,a){for(let o=0;o<i;o++){let i=o>=a?e[t+o-a]:0,s=e[t+o]-i;r[n+o]=s}}function s(e,t,i,r){let n=0;for(let a=0;a<i;a++){let i=a>=r?e[t+a-r]:0,o=e[t+a]-i;n+=Math.abs(o)}return n}function l(e,t,i,r,n){for(let a=0;a<i;a++){let o=t>0?e[t+a-i]:0,s=e[t+a]-o;r[n+a]=s}}function u(e,t,i){let r=0,n=t+i;for(let a=t;a<n;a++){let n=t>0?e[a-i]:0,o=e[a]-n;r+=Math.abs(o)}return r}function h(e,t,i,r,n,a){for(let o=0;o<i;o++){let s=o>=a?e[t+o-a]:0,l=t>0?e[t+o-i]:0,u=e[t+o]-(s+l>>1);r[n+o]=u}}function c(e,t,i,r){let n=0;for(let a=0;a<i;a++){let o=a>=r?e[t+a-r]:0,s=t>0?e[t+a-i]:0,l=e[t+a]-(o+s>>1);n+=Math.abs(l)}return n}function f(e,t,i,n,a,o){for(let s=0;s<i;s++){let l=s>=o?e[t+s-o]:0,u=t>0?e[t+s-i]:0,h=t>0&&s>=o?e[t+s-(i+o)]:0,c=e[t+s]-r(l,u,h);n[a+s]=c}}function d(e,t,i,n){let a=0;for(let o=0;o<i;o++){let s=o>=n?e[t+o-n]:0,l=t>0?e[t+o-i]:0,u=t>0&&o>=n?e[t+o-(i+n)]:0,h=e[t+o]-r(s,l,u);a+=Math.abs(h)}return a}let p={0:n,1:o,2:l,3:h,4:f},m={0:a,1:s,2:u,3:c,4:d};t.exports=function(e,t,r,n,a){let o;if("filterType"in n&&-1!==n.filterType){if("number"!=typeof n.filterType)throw new Error("unrecognised filter types");o=[n.filterType]}else o=[0,1,2,3,4];16===n.bitDepth&&(a*=2);let s=t*a,l=0,u=0,h=i.alloc((s+1)*r),c=o[0];for(let t=0;t<r;t++){if(o.length>1){let t=1/0;for(let i=0;i<o.length;i++){let r=m[o[i]](e,u,s,a);r<t&&(c=o[i],t=r)}}h[l]=c,l++,p[c](e,u,s,h,l,a),l+=s,u+=s}return h}}).call(this)}).call(this,e("buffer").Buffer)},{"./paeth-predictor":15,buffer:32}],7:[function(e,t,i){(function(i){(function(){let r=e("util"),n=e("./chunkstream"),a=e("./filter-parse"),o=t.exports=function(e){n.call(this);let t=[],r=this;this._filter=new a(e,{read:this.read.bind(this),write:function(e){t.push(e)},complete:function(){r.emit("complete",i.concat(t))}}),this._filter.start()};r.inherits(o,n)}).call(this)}).call(this,e("buffer").Buffer)},{"./chunkstream":3,"./filter-parse":9,buffer:32,util:84}],8:[function(e,t,i){(function(t){(function(){let r=e("./sync-reader"),n=e("./filter-parse");i.process=function(e,i){let a=[],o=new r(e);return new n(i,{read:o.read.bind(o),write:function(e){a.push(e)},complete:function(){}}).start(),o.process(),t.concat(a)}}).call(this)}).call(this,e("buffer").Buffer)},{"./filter-parse":9,"./sync-reader":22,buffer:32}],9:[function(e,t,i){(function(i){(function(){let r=e("./interlace"),n=e("./paeth-predictor");function a(e,t,i){let r=e*t;return 8!==i&&(r=Math.ceil(r/(8/i))),r}let o=t.exports=function(e,t){let i=e.width,n=e.height,o=e.interlace,s=e.bpp,l=e.depth;if(this.read=t.read,this.write=t.write,this.complete=t.complete,this._imageIndex=0,this._images=[],o){let e=r.getImagePasses(i,n);for(let t=0;t<e.length;t++)this._images.push({byteWidth:a(e[t].width,s,l),height:e[t].height,lineIndex:0})}else this._images.push({byteWidth:a(i,s,l),height:n,lineIndex:0});this._xComparison=8===l?s:16===l?2*s:1};o.prototype.start=function(){this.read(this._images[this._imageIndex].byteWidth+1,this._reverseFilterLine.bind(this))},o.prototype._unFilterType1=function(e,t,i){let r=this._xComparison,n=r-1;for(let a=0;a<i;a++){let i=e[1+a],o=a>n?t[a-r]:0;t[a]=i+o}},o.prototype._unFilterType2=function(e,t,i){let r=this._lastLine;for(let n=0;n<i;n++){let i=e[1+n],a=r?r[n]:0;t[n]=i+a}},o.prototype._unFilterType3=function(e,t,i){let r=this._xComparison,n=r-1,a=this._lastLine;for(let o=0;o<i;o++){let i=e[1+o],s=a?a[o]:0,l=o>n?t[o-r]:0,u=Math.floor((l+s)/2);t[o]=i+u}},o.prototype._unFilterType4=function(e,t,i){let r=this._xComparison,a=r-1,o=this._lastLine;for(let s=0;s<i;s++){let i=e[1+s],l=o?o[s]:0,u=s>a?t[s-r]:0,h=s>a&&o?o[s-r]:0,c=n(u,l,h);t[s]=i+c}},o.prototype._reverseFilterLine=function(e){let t,r=e[0],n=this._images[this._imageIndex],a=n.byteWidth;if(0===r)t=e.slice(1,a+1);else switch(t=i.alloc(a),r){case 1:this._unFilterType1(e,t,a);break;case 2:this._unFilterType2(e,t,a);break;case 3:this._unFilterType3(e,t,a);break;case 4:this._unFilterType4(e,t,a);break;default:throw new Error("Unrecognised filter type - "+r)}this.write(t),n.lineIndex++,n.lineIndex>=n.height?(this._lastLine=null,this._imageIndex++,n=this._images[this._imageIndex]):this._lastLine=t,n?this.read(n.byteWidth+1,this._reverseFilterLine.bind(this)):(this._lastLine=null,this.complete())}}).call(this)}).call(this,e("buffer").Buffer)},{"./interlace":11,"./paeth-predictor":15,buffer:32}],10:[function(e,t,i){(function(e){(function(){function i(e,t,i,r,n){let a=0;for(let o=0;o<r;o++)for(let r=0;r<i;r++){let i=n[e[a]];if(!i)throw new Error("index "+e[a]+" not in palette");for(let e=0;e<4;e++)t[a+e]=i[e];a+=4}}function r(e,t,i,r,n){let a=0;for(let o=0;o<r;o++)for(let r=0;r<i;r++){let i=!1;if(1===n.length?n[0]===e[a]&&(i=!0):n[0]===e[a]&&n[1]===e[a+1]&&n[2]===e[a+2]&&(i=!0),i)for(let e=0;e<4;e++)t[a+e]=0;a+=4}}function n(e,t,i,r,n){let a=255,o=Math.pow(2,n)-1,s=0;for(let n=0;n<r;n++)for(let r=0;r<i;r++){for(let i=0;i<4;i++)t[s+i]=Math.floor(e[s+i]*a/o+.5);s+=4}}t.exports=function(t,a,o=!1){let s=a.depth,l=a.width,u=a.height,h=a.colorType,c=a.transColor,f=a.palette,d=t;return 3===h?i(t,d,l,u,f):(c&&r(t,d,l,u,c),8===s||o||(16===s&&(d=e.alloc(l*u*4)),n(t,d,l,u,s))),d}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:32}],11:[function(e,t,i){let r=[{x:[0],y:[0]},{x:[4],y:[0]},{x:[0,4],y:[4]},{x:[2,6],y:[0,4]},{x:[0,2,4,6],y:[2,6]},{x:[1,3,5,7],y:[0,2,4,6]},{x:[0,1,2,3,4,5,6,7],y:[1,3,5,7]}];i.getImagePasses=function(e,t){let i=[],n=e%8,a=t%8,o=(e-n)/8,s=(t-a)/8;for(let e=0;e<r.length;e++){let t=r[e],l=o*t.x.length,u=s*t.y.length;for(let e=0;e<t.x.length&&t.x[e]<n;e++)l++;for(let e=0;e<t.y.length&&t.y[e]<a;e++)u++;l>0&&u>0&&i.push({width:l,height:u,index:e})}return i},i.getInterlaceIterator=function(e){return function(t,i,n){let a=t%r[n].x.length,o=(t-a)/r[n].x.length*8+r[n].x[a],s=i%r[n].y.length;return 4*o+((i-s)/r[n].y.length*8+r[n].y[s])*e*4}}},{}],12:[function(e,t,i){(function(i){(function(){let r=e("util"),n=e("stream"),a=e("./constants"),o=e("./packer"),s=t.exports=function(e){n.call(this);let t=e||{};this._packer=new o(t),this._deflate=this._packer.createDeflate(),this.readable=!0};r.inherits(s,n),s.prototype.pack=function(e,t,r,n){this.emit("data",i.from(a.PNG_SIGNATURE)),this.emit("data",this._packer.packIHDR(t,r)),n&&this.emit("data",this._packer.packGAMA(n));let o=this._packer.filterData(e,t,r);this._deflate.on("error",this.emit.bind(this,"error")),this._deflate.on("data",function(e){this.emit("data",this._packer.packIDAT(e))}.bind(this)),this._deflate.on("end",function(){this.emit("data",this._packer.packIEND()),this.emit("end")}.bind(this)),this._deflate.end(o)}}).call(this)}).call(this,e("buffer").Buffer)},{"./constants":4,"./packer":14,buffer:32,stream:65,util:84}],13:[function(e,t,i){(function(i){(function(){let r=!0,n=e("zlib");n.deflateSync||(r=!1);let a=e("./constants"),o=e("./packer");t.exports=function(e,t){if(!r)throw new Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let s=new o(t||{}),l=[];l.push(i.from(a.PNG_SIGNATURE)),l.push(s.packIHDR(e.width,e.height)),e.gamma&&l.push(s.packGAMA(e.gamma));let u=s.filterData(e.data,e.width,e.height),h=n.deflateSync(u,s.getDeflateOptions());if(u=null,!h||!h.length)throw new Error("bad png - invalid compressed data response");return l.push(s.packIDAT(h)),l.push(s.packIEND()),i.concat(l)}}).call(this)}).call(this,e("buffer").Buffer)},{"./constants":4,"./packer":14,buffer:32,zlib:31}],14:[function(e,t,i){(function(i){(function(){let r=e("./constants"),n=e("./crc"),a=e("./bitpacker"),o=e("./filter-pack"),s=e("zlib"),l=t.exports=function(e){if(this._options=e,e.deflateChunkSize=e.deflateChunkSize||32768,e.deflateLevel=null!=e.deflateLevel?e.deflateLevel:9,e.deflateStrategy=null!=e.deflateStrategy?e.deflateStrategy:3,e.inputHasAlpha=null==e.inputHasAlpha||e.inputHasAlpha,e.deflateFactory=e.deflateFactory||s.createDeflate,e.bitDepth=e.bitDepth||8,e.colorType="number"==typeof e.colorType?e.colorType:r.COLORTYPE_COLOR_ALPHA,e.inputColorType="number"==typeof e.inputColorType?e.inputColorType:r.COLORTYPE_COLOR_ALPHA,-1===[r.COLORTYPE_GRAYSCALE,r.COLORTYPE_COLOR,r.COLORTYPE_COLOR_ALPHA,r.COLORTYPE_ALPHA].indexOf(e.colorType))throw new Error("option color type:"+e.colorType+" is not supported at present");if(-1===[r.COLORTYPE_GRAYSCALE,r.COLORTYPE_COLOR,r.COLORTYPE_COLOR_ALPHA,r.COLORTYPE_ALPHA].indexOf(e.inputColorType))throw new Error("option input color type:"+e.inputColorType+" is not supported at present");if(8!==e.bitDepth&&16!==e.bitDepth)throw new Error("option bit depth:"+e.bitDepth+" is not supported at present")};l.prototype.getDeflateOptions=function(){return{chunkSize:this._options.deflateChunkSize,level:this._options.deflateLevel,strategy:this._options.deflateStrategy}},l.prototype.createDeflate=function(){return this._options.deflateFactory(this.getDeflateOptions())},l.prototype.filterData=function(e,t,i){let n=a(e,t,i,this._options),s=r.COLORTYPE_TO_BPP_MAP[this._options.colorType];return o(n,t,i,this._options,s)},l.prototype._packChunk=function(e,t){let r=t?t.length:0,a=i.alloc(r+12);return a.writeUInt32BE(r,0),a.writeUInt32BE(e,4),t&&t.copy(a,8),a.writeInt32BE(n.crc32(a.slice(4,a.length-4)),a.length-4),a},l.prototype.packGAMA=function(e){let t=i.alloc(4);return t.writeUInt32BE(Math.floor(e*r.GAMMA_DIVISION),0),this._packChunk(r.TYPE_gAMA,t)},l.prototype.packIHDR=function(e,t){let n=i.alloc(13);return n.writeUInt32BE(e,0),n.writeUInt32BE(t,4),n[8]=this._options.bitDepth,n[9]=this._options.colorType,n[10]=0,n[11]=0,n[12]=0,this._packChunk(r.TYPE_IHDR,n)},l.prototype.packIDAT=function(e){return this._packChunk(r.TYPE_IDAT,e)},l.prototype.packIEND=function(){return this._packChunk(r.TYPE_IEND,null)}}).call(this)}).call(this,e("buffer").Buffer)},{"./bitpacker":2,"./constants":4,"./crc":5,"./filter-pack":6,buffer:32,zlib:31}],15:[function(e,t,i){t.exports=function(e,t,i){let r=e+t-i,n=Math.abs(r-e),a=Math.abs(r-t),o=Math.abs(r-i);return n<=a&&n<=o?e:a<=o?t:i}},{}],16:[function(e,t,i){let r=e("util"),n=e("zlib"),a=e("./chunkstream"),o=e("./filter-parse-async"),s=e("./parser"),l=e("./bitmapper"),u=e("./format-normaliser"),h=t.exports=function(e){a.call(this),this._parser=new s(e,{read:this.read.bind(this),error:this._handleError.bind(this),metadata:this._handleMetaData.bind(this),gamma:this.emit.bind(this,"gamma"),palette:this._handlePalette.bind(this),transColor:this._handleTransColor.bind(this),finished:this._finished.bind(this),inflateData:this._inflateData.bind(this),simpleTransparency:this._simpleTransparency.bind(this),headersFinished:this._headersFinished.bind(this)}),this._options=e,this.writable=!0,this._parser.start()};r.inherits(h,a),h.prototype._handleError=function(e){this.emit("error",e),this.writable=!1,this.destroy(),this._inflate&&this._inflate.destroy&&this._inflate.destroy(),this._filter&&(this._filter.destroy(),this._filter.on("error",(function(){}))),this.errord=!0},h.prototype._inflateData=function(e){if(!this._inflate)if(this._bitmapInfo.interlace)this._inflate=n.createInflate(),this._inflate.on("error",this.emit.bind(this,"error")),this._filter.on("complete",this._complete.bind(this)),this._inflate.pipe(this._filter);else{let e=(1+(this._bitmapInfo.width*this._bitmapInfo.bpp*this._bitmapInfo.depth+7>>3))*this._bitmapInfo.height,t=Math.max(e,n.Z_MIN_CHUNK);this._inflate=n.createInflate({chunkSize:t});let i=e,r=this.emit.bind(this,"error");this._inflate.on("error",(function(e){i&&r(e)})),this._filter.on("complete",this._complete.bind(this));let a=this._filter.write.bind(this._filter);this._inflate.on("data",(function(e){i&&(e.length>i&&(e=e.slice(0,i)),i-=e.length,a(e))})),this._inflate.on("end",this._filter.end.bind(this._filter))}this._inflate.write(e)},h.prototype._handleMetaData=function(e){this._metaData=e,this._bitmapInfo=Object.create(e),this._filter=new o(this._bitmapInfo)},h.prototype._handleTransColor=function(e){this._bitmapInfo.transColor=e},h.prototype._handlePalette=function(e){this._bitmapInfo.palette=e},h.prototype._simpleTransparency=function(){this._metaData.alpha=!0},h.prototype._headersFinished=function(){this.emit("metadata",this._metaData)},h.prototype._finished=function(){this.errord||(this._inflate?this._inflate.end():this.emit("error","No Inflate block"))},h.prototype._complete=function(e){if(this.errord)return;let t;try{let i=l.dataToBitMap(e,this._bitmapInfo);t=u(i,this._bitmapInfo,this._options.skipRescale),i=null}catch(e){return void this._handleError(e)}this.emit("parsed",t)}},{"./bitmapper":1,"./chunkstream":3,"./filter-parse-async":7,"./format-normaliser":10,"./parser":18,util:84,zlib:31}],17:[function(e,t,i){(function(i){(function(){let r=!0,n=e("zlib"),a=e("./sync-inflate");n.deflateSync||(r=!1);let o=e("./sync-reader"),s=e("./filter-parse-sync"),l=e("./parser"),u=e("./bitmapper"),h=e("./format-normaliser");t.exports=function(e,t){if(!r)throw new Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let c,f,d;function p(e){c=e}function m(e){f=e}function _(e){f.transColor=e}function g(e){f.palette=e}function b(){f.alpha=!0}function y(e){d=e}let w=[];function v(e){w.push(e)}let x=new o(e);if(new l(t,{read:x.read.bind(x),error:p,metadata:m,gamma:y,palette:g,transColor:_,inflateData:v,simpleTransparency:b}).start(),x.process(),c)throw c;let E,k=i.concat(w);if(w.length=0,f.interlace)E=n.inflateSync(k);else{let e=(1+(f.width*f.bpp*f.depth+7>>3))*f.height;E=a(k,{chunkSize:e,maxLength:e})}if(k=null,!E||!E.length)throw new Error("bad png - invalid inflate data response");let S=s.process(E,f);k=null;let A=u.dataToBitMap(S,f);S=null;let I=h(A,f,t.skipRescale);return f.data=I,f.gamma=d||0,f}}).call(this)}).call(this,e("buffer").Buffer)},{"./bitmapper":1,"./filter-parse-sync":8,"./format-normaliser":10,"./parser":18,"./sync-inflate":21,"./sync-reader":22,buffer:32,zlib:31}],18:[function(e,t,i){(function(i){(function(){let r=e("./constants"),n=e("./crc"),a=t.exports=function(e,t){this._options=e,e.checkCRC=!1!==e.checkCRC,this._hasIHDR=!1,this._hasIEND=!1,this._emittedHeadersFinished=!1,this._palette=[],this._colorType=0,this._chunks={},this._chunks[r.TYPE_IHDR]=this._handleIHDR.bind(this),this._chunks[r.TYPE_IEND]=this._handleIEND.bind(this),this._chunks[r.TYPE_IDAT]=this._handleIDAT.bind(this),this._chunks[r.TYPE_PLTE]=this._handlePLTE.bind(this),this._chunks[r.TYPE_tRNS]=this._handleTRNS.bind(this),this._chunks[r.TYPE_gAMA]=this._handleGAMA.bind(this),this.read=t.read,this.error=t.error,this.metadata=t.metadata,this.gamma=t.gamma,this.transColor=t.transColor,this.palette=t.palette,this.parsed=t.parsed,this.inflateData=t.inflateData,this.finished=t.finished,this.simpleTransparency=t.simpleTransparency,this.headersFinished=t.headersFinished||function(){}};a.prototype.start=function(){this.read(r.PNG_SIGNATURE.length,this._parseSignature.bind(this))},a.prototype._parseSignature=function(e){let t=r.PNG_SIGNATURE;for(let i=0;i<t.length;i++)if(e[i]!==t[i])return void this.error(new Error("Invalid file signature"));this.read(8,this._parseChunkBegin.bind(this))},a.prototype._parseChunkBegin=function(e){let t=e.readUInt32BE(0),a=e.readUInt32BE(4),o="";for(let t=4;t<8;t++)o+=String.fromCharCode(e[t]);let s=Boolean(32&e[4]);if(this._hasIHDR||a===r.TYPE_IHDR){if(this._crc=new n,this._crc.write(i.from(o)),this._chunks[a])return this._chunks[a](t);s?this.read(t+4,this._skipChunk.bind(this)):this.error(new Error("Unsupported critical chunk type "+o))}else this.error(new Error("Expected IHDR on beggining"))},a.prototype._skipChunk=function(){this.read(8,this._parseChunkBegin.bind(this))},a.prototype._handleChunkEnd=function(){this.read(4,this._parseChunkEnd.bind(this))},a.prototype._parseChunkEnd=function(e){let t=e.readInt32BE(0),i=this._crc.crc32();this._options.checkCRC&&i!==t?this.error(new Error("Crc error - "+t+" - "+i)):this._hasIEND||this.read(8,this._parseChunkBegin.bind(this))},a.prototype._handleIHDR=function(e){this.read(e,this._parseIHDR.bind(this))},a.prototype._parseIHDR=function(e){this._crc.write(e);let t=e.readUInt32BE(0),i=e.readUInt32BE(4),n=e[8],a=e[9],o=e[10],s=e[11],l=e[12];if(8!==n&&4!==n&&2!==n&&1!==n&&16!==n)return void this.error(new Error("Unsupported bit depth "+n));if(!(a in r.COLORTYPE_TO_BPP_MAP))return void this.error(new Error("Unsupported color type"));if(0!==o)return void this.error(new Error("Unsupported compression method"));if(0!==s)return void this.error(new Error("Unsupported filter method"));if(0!==l&&1!==l)return void this.error(new Error("Unsupported interlace method"));this._colorType=a;let u=r.COLORTYPE_TO_BPP_MAP[this._colorType];this._hasIHDR=!0,this.metadata({width:t,height:i,depth:n,interlace:Boolean(l),palette:Boolean(a&r.COLORTYPE_PALETTE),color:Boolean(a&r.COLORTYPE_COLOR),alpha:Boolean(a&r.COLORTYPE_ALPHA),bpp:u,colorType:a}),this._handleChunkEnd()},a.prototype._handlePLTE=function(e){this.read(e,this._parsePLTE.bind(this))},a.prototype._parsePLTE=function(e){this._crc.write(e);let t=Math.floor(e.length/3);for(let i=0;i<t;i++)this._palette.push([e[3*i],e[3*i+1],e[3*i+2],255]);this.palette(this._palette),this._handleChunkEnd()},a.prototype._handleTRNS=function(e){this.simpleTransparency(),this.read(e,this._parseTRNS.bind(this))},a.prototype._parseTRNS=function(e){if(this._crc.write(e),this._colorType===r.COLORTYPE_PALETTE_COLOR){if(0===this._palette.length)return void this.error(new Error("Transparency chunk must be after palette"));if(e.length>this._palette.length)return void this.error(new Error("More transparent colors than palette size"));for(let t=0;t<e.length;t++)this._palette[t][3]=e[t];this.palette(this._palette)}this._colorType===r.COLORTYPE_GRAYSCALE&&this.transColor([e.readUInt16BE(0)]),this._colorType===r.COLORTYPE_COLOR&&this.transColor([e.readUInt16BE(0),e.readUInt16BE(2),e.readUInt16BE(4)]),this._handleChunkEnd()},a.prototype._handleGAMA=function(e){this.read(e,this._parseGAMA.bind(this))},a.prototype._parseGAMA=function(e){this._crc.write(e),this.gamma(e.readUInt32BE(0)/r.GAMMA_DIVISION),this._handleChunkEnd()},a.prototype._handleIDAT=function(e){this._emittedHeadersFinished||(this._emittedHeadersFinished=!0,this.headersFinished()),this.read(-e,this._parseIDAT.bind(this,e))},a.prototype._parseIDAT=function(e,t){if(this._crc.write(t),this._colorType===r.COLORTYPE_PALETTE_COLOR&&0===this._palette.length)throw new Error("Expected palette not found");this.inflateData(t);let i=e-t.length;i>0?this._handleIDAT(i):this._handleChunkEnd()},a.prototype._handleIEND=function(e){this.read(e,this._parseIEND.bind(this))},a.prototype._parseIEND=function(e){this._crc.write(e),this._hasIEND=!0,this._handleChunkEnd(),this.finished&&this.finished()}}).call(this)}).call(this,e("buffer").Buffer)},{"./constants":4,"./crc":5,buffer:32}],19:[function(e,t,i){let r=e("./parser-sync"),n=e("./packer-sync");i.read=function(e,t){return r(e,t||{})},i.write=function(e,t){return n(e,t)}},{"./packer-sync":13,"./parser-sync":17}],20:[function(e,t,i){(function(t,r){(function(){let n=e("util"),a=e("stream"),o=e("./parser-async"),s=e("./packer-async"),l=e("./png-sync"),u=i.PNG=function(e){a.call(this),e=e||{},this.width=0|e.width,this.height=0|e.height,this.data=this.width>0&&this.height>0?r.alloc(4*this.width*this.height):null,e.fill&&this.data&&this.data.fill(0),this.gamma=0,this.readable=this.writable=!0,this._parser=new o(e),this._parser.on("error",this.emit.bind(this,"error")),this._parser.on("close",this._handleClose.bind(this)),this._parser.on("metadata",this._metadata.bind(this)),this._parser.on("gamma",this._gamma.bind(this)),this._parser.on("parsed",function(e){this.data=e,this.emit("parsed",e)}.bind(this)),this._packer=new s(e),this._packer.on("data",this.emit.bind(this,"data")),this._packer.on("end",this.emit.bind(this,"end")),this._parser.on("close",this._handleClose.bind(this)),this._packer.on("error",this.emit.bind(this,"error"))};n.inherits(u,a),u.sync=l,u.prototype.pack=function(){return this.data&&this.data.length?(t.nextTick(function(){this._packer.pack(this.data,this.width,this.height,this.gamma)}.bind(this)),this):(this.emit("error","No data provided"),this)},u.prototype.parse=function(e,t){if(t){let e,i;e=function(e){this.removeListener("error",i),this.data=e,t(null,this)}.bind(this),i=function(i){this.removeListener("parsed",e),t(i,null)}.bind(this),this.once("parsed",e),this.once("error",i)}return this.end(e),this},u.prototype.write=function(e){return this._parser.write(e),!0},u.prototype.end=function(e){this._parser.end(e)},u.prototype._metadata=function(e){this.width=e.width,this.height=e.height,this.emit("metadata",e)},u.prototype._gamma=function(e){this.gamma=e},u.prototype._handleClose=function(){this._parser.writable||this._packer.readable||this.emit("close")},u.bitblt=function(e,t,i,r,n,a,o,s){if(r|=0,n|=0,a|=0,o|=0,s|=0,(i|=0)>e.width||r>e.height||i+n>e.width||r+a>e.height)throw new Error("bitblt reading outside image");if(o>t.width||s>t.height||o+n>t.width||s+a>t.height)throw new Error("bitblt writing outside image");for(let l=0;l<a;l++)e.data.copy(t.data,(s+l)*t.width+o<<2,(r+l)*e.width+i<<2,(r+l)*e.width+i+n<<2)},u.prototype.bitblt=function(e,t,i,r,n,a,o){return u.bitblt(this,e,t,i,r,n,a,o),this},u.adjustGamma=function(e){if(e.gamma){for(let t=0;t<e.height;t++)for(let i=0;i<e.width;i++){let r=e.width*t+i<<2;for(let t=0;t<3;t++){let i=e.data[r+t]/255;i=Math.pow(i,1/2.2/e.gamma),e.data[r+t]=Math.round(255*i)}}e.gamma=0}},u.prototype.adjustGamma=function(){u.adjustGamma(this)}}).call(this)}).call(this,e("_process"),e("buffer").Buffer)},{"./packer-async":12,"./parser-async":16,"./png-sync":19,_process:63,buffer:32,stream:65,util:84}],21:[function(e,t,i){(function(r,n){(function(){let r=e("assert").ok,a=e("zlib"),o=e("util"),s=e("buffer").kMaxLength;function l(e){if(!(this instanceof l))return new l(e);e&&e.chunkSize<a.Z_MIN_CHUNK&&(e.chunkSize=a.Z_MIN_CHUNK),a.Inflate.call(this,e),this._offset=void 0===this._offset?this._outOffset:this._offset,this._buffer=this._buffer||this._outBuffer,e&&null!=e.maxLength&&(this._maxLength=e.maxLength)}function u(e){return new l(e)}function h(e,t){e._handle&&(e._handle.close(),e._handle=null)}function c(e,t){if("string"==typeof t&&(t=n.from(t)),!(t instanceof n))throw new TypeError("Not a string or buffer");let i=e._finishFlushFlag;return null==i&&(i=a.Z_FINISH),e._processChunk(t,i)}function f(e,t){return c(new l(t),e)}l.prototype._processChunk=function(e,t,i){if("function"==typeof i)return a.Inflate._processChunk.call(this,e,t,i);let o,l,u=this,c=e&&e.length,f=this._chunkSize-this._offset,d=this._maxLength,p=0,m=[],_=0;function g(e,t){if(u._hadError)return;let i=f-t;if(r(i>=0,"have should not go down"),i>0){let e=u._buffer.slice(u._offset,u._offset+i);if(u._offset+=i,e.length>d&&(e=e.slice(0,d)),m.push(e),_+=e.length,d-=e.length,0===d)return!1}return(0===t||u._offset>=u._chunkSize)&&(f=u._chunkSize,u._offset=0,u._buffer=n.allocUnsafe(u._chunkSize)),0===t&&(p+=c-e,c=e,!0)}this.on("error",(function(e){o=e})),r(this._handle,"zlib binding closed");do{l=this._handle.writeSync(t,e,p,c,this._buffer,this._offset,f),l=l||this._writeState}while(!this._hadError&&g(l[0],l[1]));if(this._hadError)throw o;if(_>=s)throw h(this),new RangeError("Cannot create final Buffer. It would be larger than 0x"+s.toString(16)+" bytes");let b=n.concat(m,_);return h(this),b},o.inherits(l,a.Inflate),t.exports=i=f,i.Inflate=l,i.createInflate=u,i.inflateSync=f}).call(this)}).call(this,e("_process"),e("buffer").Buffer)},{_process:63,assert:23,buffer:32,util:84,zlib:31}],22:[function(e,t,i){let r=t.exports=function(e){this._buffer=e,this._reads=[]};r.prototype.read=function(e,t){this._reads.push({length:Math.abs(e),allowLess:e<0,func:t})},r.prototype.process=function(){for(;this._reads.length>0&&this._buffer.length;){let e=this._reads[0];if(!this._buffer.length||!(this._buffer.length>=e.length||e.allowLess))break;{this._reads.shift();let t=this._buffer;this._buffer=t.slice(e.length),e.func.call(this,t.slice(0,e.length))}}if(this._reads.length>0)throw new Error("There are some read requests waitng on finished stream");if(this._buffer.length>0)throw new Error("unrecognised content at end of stream")}},{}],23:[function(e,t,i){(function(i){(function(){var r=e("object-assign");
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
* @license MIT
*/function n(e,t){if(e===t)return 0;for(var i=e.length,r=t.length,n=0,a=Math.min(i,r);n<a;++n)if(e[n]!==t[n]){i=e[n],r=t[n];break}return i<r?-1:r<i?1:0}function a(e){return i.Buffer&&"function"==typeof i.Buffer.isBuffer?i.Buffer.isBuffer(e):!(null==e||!e._isBuffer)}var o=e("util/"),s=Object.prototype.hasOwnProperty,l=Array.prototype.slice,u="foo"===function(){}.name;function h(e){return Object.prototype.toString.call(e)}function c(e){return!a(e)&&"function"==typeof i.ArrayBuffer&&("function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):!!e&&(e instanceof DataView||!!(e.buffer&&e.buffer instanceof ArrayBuffer)))}var f=t.exports=y,d=/\s*function\s+([^\(\s]*)\s*/;function p(e){if(o.isFunction(e)){if(u)return e.name;var t=e.toString().match(d);return t&&t[1]}}function m(e,t){return"string"==typeof e?e.length<t?e:e.slice(0,t):e}function _(e){if(u||!o.isFunction(e))return o.inspect(e);var t=p(e);return"[Function"+(t?": "+t:"")+"]"}function g(e){return m(_(e.actual),128)+" "+e.operator+" "+m(_(e.expected),128)}function b(e,t,i,r,n){throw new f.AssertionError({message:i,actual:e,expected:t,operator:r,stackStartFunction:n})}function y(e,t){e||b(e,!0,t,"==",f.ok)}function w(e,t,i,r){if(e===t)return!0;if(a(e)&&a(t))return 0===n(e,t);if(o.isDate(e)&&o.isDate(t))return e.getTime()===t.getTime();if(o.isRegExp(e)&&o.isRegExp(t))return e.source===t.source&&e.global===t.global&&e.multiline===t.multiline&&e.lastIndex===t.lastIndex&&e.ignoreCase===t.ignoreCase;if(null!==e&&"object"==typeof e||null!==t&&"object"==typeof t){if(c(e)&&c(t)&&h(e)===h(t)&&!(e instanceof Float32Array||e instanceof Float64Array))return 0===n(new Uint8Array(e.buffer),new Uint8Array(t.buffer));if(a(e)!==a(t))return!1;var s=(r=r||{actual:[],expected:[]}).actual.indexOf(e);return-1!==s&&s===r.expected.indexOf(t)||(r.actual.push(e),r.expected.push(t),x(e,t,i,r))}return i?e===t:e==t}function v(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function x(e,t,i,r){if(null==e||null==t)return!1;if(o.isPrimitive(e)||o.isPrimitive(t))return e===t;if(i&&Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;var n=v(e),a=v(t);if(n&&!a||!n&&a)return!1;if(n)return w(e=l.call(e),t=l.call(t),i);var s,u,h=M(e),c=M(t);if(h.length!==c.length)return!1;for(h.sort(),c.sort(),u=h.length-1;u>=0;u--)if(h[u]!==c[u])return!1;for(u=h.length-1;u>=0;u--)if(!w(e[s=h[u]],t[s],i,r))return!1;return!0}function E(e,t,i){w(e,t,!0)&&b(e,t,i,"notDeepStrictEqual",E)}function k(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function S(e){var t;try{e()}catch(e){t=e}return t}function A(e,t,i,r){var n;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof i&&(r=i,i=null),n=S(t),r=(i&&i.name?" ("+i.name+").":".")+(r?" "+r:"."),e&&!n&&b(n,i,"Missing expected exception"+r);var a="string"==typeof r,s=!e&&n&&!i;if((!e&&o.isError(n)&&a&&k(n,i)||s)&&b(n,i,"Got unwanted exception"+r),e&&n&&i&&!k(n,i)||!e&&n)throw n}function I(e,t){e||b(e,!0,t,"==",I)}f.AssertionError=function(e){this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=g(this),this.generatedMessage=!0);var t=e.stackStartFunction||b;if(Error.captureStackTrace)Error.captureStackTrace(this,t);else{var i=new Error;if(i.stack){var r=i.stack,n=p(t),a=r.indexOf("\n"+n);if(a>=0){var o=r.indexOf("\n",a+1);r=r.substring(o+1)}this.stack=r}}},o.inherits(f.AssertionError,Error),f.fail=b,f.ok=y,f.equal=function(e,t,i){e!=t&&b(e,t,i,"==",f.equal)},f.notEqual=function(e,t,i){e==t&&b(e,t,i,"!=",f.notEqual)},f.deepEqual=function(e,t,i){w(e,t,!1)||b(e,t,i,"deepEqual",f.deepEqual)},f.deepStrictEqual=function(e,t,i){w(e,t,!0)||b(e,t,i,"deepStrictEqual",f.deepStrictEqual)},f.notDeepEqual=function(e,t,i){w(e,t,!1)&&b(e,t,i,"notDeepEqual",f.notDeepEqual)},f.notDeepStrictEqual=E,f.strictEqual=function(e,t,i){e!==t&&b(e,t,i,"===",f.strictEqual)},f.notStrictEqual=function(e,t,i){e===t&&b(e,t,i,"!==",f.notStrictEqual)},f.throws=function(e,t,i){A(!0,e,t,i)},f.doesNotThrow=function(e,t,i){A(!1,e,t,i)},f.ifError=function(e){if(e)throw e},f.strict=r(I,f,{equal:f.strictEqual,deepEqual:f.deepStrictEqual,notEqual:f.notStrictEqual,notDeepEqual:f.notDeepStrictEqual}),f.strict.strict=f.strict;var M=Object.keys||function(e){var t=[];for(var i in e)s.call(e,i)&&t.push(i);return t}}).call(this)}).call(this,void 0!==commonjsGlobal?commonjsGlobal:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"object-assign":51,"util/":26}],24:[function(e,t,i){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e}},{}],25:[function(e,t,i){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],26:[function(e,t,i){(function(t,r){(function(){var n=/%[sdj%]/g;i.format=function(e){if(!x(e)){for(var t=[],i=0;i<arguments.length;i++)t.push(s(arguments[i]));return t.join(" ")}i=1;for(var r=arguments,a=r.length,o=String(e).replace(n,(function(e){if("%%"===e)return"%";if(i>=a)return e;switch(e){case"%s":return String(r[i++]);case"%d":return Number(r[i++]);case"%j":try{return JSON.stringify(r[i++])}catch(e){return"[Circular]"}default:return e}})),l=r[i];i<a;l=r[++i])y(l)||!A(l)?o+=" "+l:o+=" "+s(l);return o},i.deprecate=function(e,n){if(k(r.process))return function(){return i.deprecate(e,n).apply(this,arguments)};if(!0===t.noDeprecation)return e;var a=!1;function o(){if(!a){if(t.throwDeprecation)throw new Error(n);t.traceDeprecation?console.trace(n):console.error(n),a=!0}return e.apply(this,arguments)}return o};var a,o={};function s(e,t){var r={seen:[],stylize:u};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),b(t)?r.showHidden=t:t&&i._extend(r,t),k(r.showHidden)&&(r.showHidden=!1),k(r.depth)&&(r.depth=2),k(r.colors)&&(r.colors=!1),k(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=l),c(r,e,r.depth)}function l(e,t){var i=s.styles[t];return i?"["+s.colors[i][0]+"m"+e+"["+s.colors[i][1]+"m":e}function u(e,t){return e}function h(e){var t={};return e.forEach((function(e,i){t[e]=!0})),t}function c(e,t,r){if(e.customInspect&&t&&T(t.inspect)&&t.inspect!==i.inspect&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return x(n)||(n=c(e,n,r)),n}var a=f(e,t);if(a)return a;var o=Object.keys(t),s=h(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),M(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return d(t);if(0===o.length){if(T(t)){var l=t.name?": "+t.name:"";return e.stylize("[Function"+l+"]","special")}if(S(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(I(t))return e.stylize(Date.prototype.toString.call(t),"date");if(M(t))return d(t)}var u,b="",y=!1,w=["{","}"];return g(t)&&(y=!0,w=["[","]"]),T(t)&&(b=" [Function"+(t.name?": "+t.name:"")+"]"),S(t)&&(b=" "+RegExp.prototype.toString.call(t)),I(t)&&(b=" "+Date.prototype.toUTCString.call(t)),M(t)&&(b=" "+d(t)),0!==o.length||y&&0!=t.length?r<0?S(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),u=y?p(e,t,r,s,o):o.map((function(i){return m(e,t,r,s,i,y)})),e.seen.pop(),_(u,b,w)):w[0]+b+w[1]}function f(e,t){if(k(t))return e.stylize("undefined","undefined");if(x(t)){var i="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(i,"string")}return v(t)?e.stylize(""+t,"number"):b(t)?e.stylize(""+t,"boolean"):y(t)?e.stylize("null","null"):void 0}function d(e){return"["+Error.prototype.toString.call(e)+"]"}function p(e,t,i,r,n){for(var a=[],o=0,s=t.length;o<s;++o)F(t,String(o))?a.push(m(e,t,i,r,String(o),!0)):a.push("");return n.forEach((function(n){n.match(/^\d+$/)||a.push(m(e,t,i,r,n,!0))})),a}function m(e,t,i,r,n,a){var o,s,l;if((l=Object.getOwnPropertyDescriptor(t,n)||{value:t[n]}).get?s=l.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):l.set&&(s=e.stylize("[Setter]","special")),F(r,n)||(o="["+n+"]"),s||(e.seen.indexOf(l.value)<0?(s=y(i)?c(e,l.value,null):c(e,l.value,i-1)).indexOf("\n")>-1&&(s=a?s.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+s.split("\n").map((function(e){return" "+e})).join("\n")):s=e.stylize("[Circular]","special")),k(o)){if(a&&n.match(/^\d+$/))return s;(o=JSON.stringify(""+n)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=e.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=e.stylize(o,"string"))}return o+": "+s}function _(e,t,i){return e.reduce((function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60?i[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+i[1]:i[0]+t+" "+e.join(", ")+" "+i[1]}function g(e){return Array.isArray(e)}function b(e){return"boolean"==typeof e}function y(e){return null===e}function w(e){return null==e}function v(e){return"number"==typeof e}function x(e){return"string"==typeof e}function E(e){return"symbol"==typeof e}function k(e){return void 0===e}function S(e){return A(e)&&"[object RegExp]"===B(e)}function A(e){return"object"==typeof e&&null!==e}function I(e){return A(e)&&"[object Date]"===B(e)}function M(e){return A(e)&&("[object Error]"===B(e)||e instanceof Error)}function T(e){return"function"==typeof e}function P(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e}function B(e){return Object.prototype.toString.call(e)}function C(e){return e<10?"0"+e.toString(10):e.toString(10)}i.debuglog=function(e){if(k(a)&&(a=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!o[e])if(new RegExp("\\b"+e+"\\b","i").test(a)){var r=t.pid;o[e]=function(){var t=i.format.apply(i,arguments);console.error("%s %d: %s",e,r,t)}}else o[e]=function(){};return o[e]},i.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},i.isArray=g,i.isBoolean=b,i.isNull=y,i.isNullOrUndefined=w,i.isNumber=v,i.isString=x,i.isSymbol=E,i.isUndefined=k,i.isRegExp=S,i.isObject=A,i.isDate=I,i.isError=M,i.isFunction=T,i.isPrimitive=P,i.isBuffer=e("./support/isBuffer");var R=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function z(){var e=new Date,t=[C(e.getHours()),C(e.getMinutes()),C(e.getSeconds())].join(":");return[e.getDate(),R[e.getMonth()],t].join(" ")}function F(e,t){return Object.prototype.hasOwnProperty.call(e,t)}i.log=function(){console.log("%s - %s",z(),i.format.apply(i,arguments))},i.inherits=e("inherits"),i._extend=function(e,t){if(!t||!A(t))return e;for(var i=Object.keys(t),r=i.length;r--;)e[i[r]]=t[i[r]];return e}}).call(this)}).call(this,e("_process"),void 0!==commonjsGlobal?commonjsGlobal:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":25,_process:63,inherits:24}],27:[function(e,t,i){(function(e){(function(){var i=["BigInt64Array","BigUint64Array","Float32Array","Float64Array","Int16Array","Int32Array","Int8Array","Uint16Array","Uint32Array","Uint8Array","Uint8ClampedArray"],r="undefined"==typeof globalThis?e:globalThis;t.exports=function(){for(var e=[],t=0;t<i.length;t++)"function"==typeof r[i[t]]&&(e[e.length]=i[t]);return e}}).call(this)}).call(this,void 0!==commonjsGlobal?commonjsGlobal:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],28:[function(e,t,i){i.byteLength=h,i.toByteArray=f,i.fromByteArray=m;for(var r=[],n=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,l=o.length;s<l;++s)r[s]=o[s],n[o.charCodeAt(s)]=s;function u(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var i=e.indexOf("=");return-1===i&&(i=t),[i,i===t?0:4-i%4]}function h(e){var t=u(e),i=t[0],r=t[1];return 3*(i+r)/4-r}function c(e,t,i){return 3*(t+i)/4-i}function f(e){var t,i,r=u(e),o=r[0],s=r[1],l=new a(c(e,o,s)),h=0,f=s>0?o-4:o;for(i=0;i<f;i+=4)t=n[e.charCodeAt(i)]<<18|n[e.charCodeAt(i+1)]<<12|n[e.charCodeAt(i+2)]<<6|n[e.charCodeAt(i+3)],l[h++]=t>>16&255,l[h++]=t>>8&255,l[h++]=255&t;return 2===s&&(t=n[e.charCodeAt(i)]<<2|n[e.charCodeAt(i+1)]>>4,l[h++]=255&t),1===s&&(t=n[e.charCodeAt(i)]<<10|n[e.charCodeAt(i+1)]<<4|n[e.charCodeAt(i+2)]>>2,l[h++]=t>>8&255,l[h++]=255&t),l}function d(e){return r[e>>18&63]+r[e>>12&63]+r[e>>6&63]+r[63&e]}function p(e,t,i){for(var r,n=[],a=t;a<i;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),n.push(d(r));return n.join("")}function m(e){for(var t,i=e.length,n=i%3,a=[],o=16383,s=0,l=i-n;s<l;s+=o)a.push(p(e,s,s+o>l?l:s+o));return 1===n?(t=e[i-1],a.push(r[t>>2]+r[t<<4&63]+"==")):2===n&&(t=(e[i-2]<<8)+e[i-1],a.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),a.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},{}],29:[function(e,t,i){},{}],30:[function(e,t,i){(function(t,r){(function(){var n=e("assert"),a=e("pako/lib/zlib/zstream"),o=e("pako/lib/zlib/deflate.js"),s=e("pako/lib/zlib/inflate.js"),l=e("pako/lib/zlib/constants");for(var u in l)i[u]=l[u];i.NONE=0,i.DEFLATE=1,i.INFLATE=2,i.GZIP=3,i.GUNZIP=4,i.DEFLATERAW=5,i.INFLATERAW=6,i.UNZIP=7;var h=31,c=139;function f(e){if("number"!=typeof e||e<i.DEFLATE||e>i.UNZIP)throw new TypeError("Bad argument");this.dictionary=null,this.err=0,this.flush=0,this.init_done=!1,this.level=0,this.memLevel=0,this.mode=e,this.strategy=0,this.windowBits=0,this.write_in_progress=!1,this.pending_close=!1,this.gzip_id_bytes_read=0}f.prototype.close=function(){this.write_in_progress?this.pending_close=!0:(this.pending_close=!1,n(this.init_done,"close before init"),n(this.mode<=i.UNZIP),this.mode===i.DEFLATE||this.mode===i.GZIP||this.mode===i.DEFLATERAW?o.deflateEnd(this.strm):this.mode!==i.INFLATE&&this.mode!==i.GUNZIP&&this.mode!==i.INFLATERAW&&this.mode!==i.UNZIP||s.inflateEnd(this.strm),this.mode=i.NONE,this.dictionary=null)},f.prototype.write=function(e,t,i,r,n,a,o){return this._write(!0,e,t,i,r,n,a,o)},f.prototype.writeSync=function(e,t,i,r,n,a,o){return this._write(!1,e,t,i,r,n,a,o)},f.prototype._write=function(e,a,o,s,l,u,h,c){if(n.equal(arguments.length,8),n(this.init_done,"write before init"),n(this.mode!==i.NONE,"already finalized"),n.equal(!1,this.write_in_progress,"write already in progress"),n.equal(!1,this.pending_close,"close is pending"),this.write_in_progress=!0,n.equal(!1,void 0===a,"must provide flush value"),this.write_in_progress=!0,a!==i.Z_NO_FLUSH&&a!==i.Z_PARTIAL_FLUSH&&a!==i.Z_SYNC_FLUSH&&a!==i.Z_FULL_FLUSH&&a!==i.Z_FINISH&&a!==i.Z_BLOCK)throw new Error("Invalid flush value");if(null==o&&(o=r.alloc(0),l=0,s=0),this.strm.avail_in=l,this.strm.input=o,this.strm.next_in=s,this.strm.avail_out=c,this.strm.output=u,this.strm.next_out=h,this.flush=a,!e)return this._process(),this._checkError()?this._afterSync():void 0;var f=this;return t.nextTick((function(){f._process(),f._after()})),this},f.prototype._afterSync=function(){var e=this.strm.avail_out,t=this.strm.avail_in;return this.write_in_progress=!1,[t,e]},f.prototype._process=function(){var e=null;switch(this.mode){case i.DEFLATE:case i.GZIP:case i.DEFLATERAW:this.err=o.deflate(this.strm,this.flush);break;case i.UNZIP:switch(this.strm.avail_in>0&&(e=this.strm.next_in),this.gzip_id_bytes_read){case 0:if(null===e)break;if(this.strm.input[e]!==h){this.mode=i.INFLATE;break}if(this.gzip_id_bytes_read=1,e++,1===this.strm.avail_in)break;case 1:if(null===e)break;this.strm.input[e]===c?(this.gzip_id_bytes_read=2,this.mode=i.GUNZIP):this.mode=i.INFLATE;break;default:throw new Error("invalid number of gzip magic number bytes read")}case i.INFLATE:case i.GUNZIP:case i.INFLATERAW:for(this.err=s.inflate(this.strm,this.flush),this.err===i.Z_NEED_DICT&&this.dictionary&&(this.err=s.inflateSetDictionary(this.strm,this.dictionary),this.err===i.Z_OK?this.err=s.inflate(this.strm,this.flush):this.err===i.Z_DATA_ERROR&&(this.err=i.Z_NEED_DICT));this.strm.avail_in>0&&this.mode===i.GUNZIP&&this.err===i.Z_STREAM_END&&0!==this.strm.next_in[0];)this.reset(),this.err=s.inflate(this.strm,this.flush);break;default:throw new Error("Unknown mode "+this.mode)}},f.prototype._checkError=function(){switch(this.err){case i.Z_OK:case i.Z_BUF_ERROR:if(0!==this.strm.avail_out&&this.flush===i.Z_FINISH)return this._error("unexpected end of file"),!1;break;case i.Z_STREAM_END:break;case i.Z_NEED_DICT:return null==this.dictionary?this._error("Missing dictionary"):this._error("Bad dictionary"),!1;default:return this._error("Zlib error"),!1}return!0},f.prototype._after=function(){if(this._checkError()){var e=this.strm.avail_out,t=this.strm.avail_in;this.write_in_progress=!1,this.callback(t,e),this.pending_close&&this.close()}},f.prototype._error=function(e){this.strm.msg&&(e=this.strm.msg),this.onerror(e,this.err),this.write_in_progress=!1,this.pending_close&&this.close()},f.prototype.init=function(e,t,r,a,o){n(4===arguments.length||5===arguments.length,"init(windowBits, level, memLevel, strategy, [dictionary])"),n(e>=8&&e<=15,"invalid windowBits"),n(t>=-1&&t<=9,"invalid compression level"),n(r>=1&&r<=9,"invalid memlevel"),n(a===i.Z_FILTERED||a===i.Z_HUFFMAN_ONLY||a===i.Z_RLE||a===i.Z_FIXED||a===i.Z_DEFAULT_STRATEGY,"invalid strategy"),this._init(t,e,r,a,o),this._setDictionary()},f.prototype.params=function(){throw new Error("deflateParams Not supported")},f.prototype.reset=function(){this._reset(),this._setDictionary()},f.prototype._init=function(e,t,r,n,l){switch(this.level=e,this.windowBits=t,this.memLevel=r,this.strategy=n,this.flush=i.Z_NO_FLUSH,this.err=i.Z_OK,this.mode!==i.GZIP&&this.mode!==i.GUNZIP||(this.windowBits+=16),this.mode===i.UNZIP&&(this.windowBits+=32),this.mode!==i.DEFLATERAW&&this.mode!==i.INFLATERAW||(this.windowBits=-1*this.windowBits),this.strm=new a,this.mode){case i.DEFLATE:case i.GZIP:case i.DEFLATERAW:this.err=o.deflateInit2(this.strm,this.level,i.Z_DEFLATED,this.windowBits,this.memLevel,this.strategy);break;case i.INFLATE:case i.GUNZIP:case i.INFLATERAW:case i.UNZIP:this.err=s.inflateInit2(this.strm,this.windowBits);break;default:throw new Error("Unknown mode "+this.mode)}this.err!==i.Z_OK&&this._error("Init error"),this.dictionary=l,this.write_in_progress=!1,this.init_done=!0},f.prototype._setDictionary=function(){if(null!=this.dictionary){switch(this.err=i.Z_OK,this.mode){case i.DEFLATE:case i.DEFLATERAW:this.err=o.deflateSetDictionary(this.strm,this.dictionary)}this.err!==i.Z_OK&&this._error("Failed to set dictionary")}},f.prototype._reset=function(){switch(this.err=i.Z_OK,this.mode){case i.DEFLATE:case i.DEFLATERAW:case i.GZIP:this.err=o.deflateReset(this.strm);break;case i.INFLATE:case i.INFLATERAW:case i.GUNZIP:this.err=s.inflateReset(this.strm)}this.err!==i.Z_OK&&this._error("Failed to reset stream")},i.Zlib=f}).call(this)}).call(this,e("_process"),e("buffer").Buffer)},{_process:63,assert:23,buffer:32,"pako/lib/zlib/constants":54,"pako/lib/zlib/deflate.js":56,"pako/lib/zlib/inflate.js":58,"pako/lib/zlib/zstream":62}],31:[function(e,t,i){(function(t){(function(){var r=e("buffer").Buffer,n=e("stream").Transform,a=e("./binding"),o=e("util"),s=e("assert").ok,l=e("buffer").kMaxLength,u="Cannot create final Buffer. It would be larger than 0x"+l.toString(16)+" bytes";a.Z_MIN_WINDOWBITS=8,a.Z_MAX_WINDOWBITS=15,a.Z_DEFAULT_WINDOWBITS=15,a.Z_MIN_CHUNK=64,a.Z_MAX_CHUNK=1/0,a.Z_DEFAULT_CHUNK=16384,a.Z_MIN_MEMLEVEL=1,a.Z_MAX_MEMLEVEL=9,a.Z_DEFAULT_MEMLEVEL=8,a.Z_MIN_LEVEL=-1,a.Z_MAX_LEVEL=9,a.Z_DEFAULT_LEVEL=a.Z_DEFAULT_COMPRESSION;for(var h=Object.keys(a),c=0;c<h.length;c++){var f=h[c];f.match(/^Z/)&&Object.defineProperty(i,f,{enumerable:!0,value:a[f],writable:!1})}for(var d={Z_OK:a.Z_OK,Z_STREAM_END:a.Z_STREAM_END,Z_NEED_DICT:a.Z_NEED_DICT,Z_ERRNO:a.Z_ERRNO,Z_STREAM_ERROR:a.Z_STREAM_ERROR,Z_DATA_ERROR:a.Z_DATA_ERROR,Z_MEM_ERROR:a.Z_MEM_ERROR,Z_BUF_ERROR:a.Z_BUF_ERROR,Z_VERSION_ERROR:a.Z_VERSION_ERROR},p=Object.keys(d),m=0;m<p.length;m++){var _=p[m];d[d[_]]=_}function g(e,t,i){var n=[],a=0;function o(){for(var t;null!==(t=e.read());)n.push(t),a+=t.length;e.once("readable",o)}function s(t){e.removeListener("end",h),e.removeListener("readable",o),i(t)}function h(){var t,o=null;a>=l?o=new RangeError(u):t=r.concat(n,a),n=[],e.close(),i(o,t)}e.on("error",s),e.on("end",h),e.end(t),o()}function b(e,t){if("string"==typeof t&&(t=r.from(t)),!r.isBuffer(t))throw new TypeError("Not a string or buffer");var i=e._finishFlushFlag;return e._processChunk(t,i)}function y(e){if(!(this instanceof y))return new y(e);I.call(this,e,a.DEFLATE)}function w(e){if(!(this instanceof w))return new w(e);I.call(this,e,a.INFLATE)}function v(e){if(!(this instanceof v))return new v(e);I.call(this,e,a.GZIP)}function x(e){if(!(this instanceof x))return new x(e);I.call(this,e,a.GUNZIP)}function E(e){if(!(this instanceof E))return new E(e);I.call(this,e,a.DEFLATERAW)}function k(e){if(!(this instanceof k))return new k(e);I.call(this,e,a.INFLATERAW)}function S(e){if(!(this instanceof S))return new S(e);I.call(this,e,a.UNZIP)}function A(e){return e===a.Z_NO_FLUSH||e===a.Z_PARTIAL_FLUSH||e===a.Z_SYNC_FLUSH||e===a.Z_FULL_FLUSH||e===a.Z_FINISH||e===a.Z_BLOCK}function I(e,t){var o=this;if(this._opts=e=e||{},this._chunkSize=e.chunkSize||i.Z_DEFAULT_CHUNK,n.call(this,e),e.flush&&!A(e.flush))throw new Error("Invalid flush flag: "+e.flush);if(e.finishFlush&&!A(e.finishFlush))throw new Error("Invalid flush flag: "+e.finishFlush);if(this._flushFlag=e.flush||a.Z_NO_FLUSH,this._finishFlushFlag=void 0!==e.finishFlush?e.finishFlush:a.Z_FINISH,e.chunkSize&&(e.chunkSize<i.Z_MIN_CHUNK||e.chunkSize>i.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+e.chunkSize);if(e.windowBits&&(e.windowBits<i.Z_MIN_WINDOWBITS||e.windowBits>i.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+e.windowBits);if(e.level&&(e.level<i.Z_MIN_LEVEL||e.level>i.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+e.level);if(e.memLevel&&(e.memLevel<i.Z_MIN_MEMLEVEL||e.memLevel>i.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+e.memLevel);if(e.strategy&&e.strategy!=i.Z_FILTERED&&e.strategy!=i.Z_HUFFMAN_ONLY&&e.strategy!=i.Z_RLE&&e.strategy!=i.Z_FIXED&&e.strategy!=i.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+e.strategy);if(e.dictionary&&!r.isBuffer(e.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._handle=new a.Zlib(t);var s=this;this._hadError=!1,this._handle.onerror=function(e,t){M(s),s._hadError=!0;var r=new Error(e);r.errno=t,r.code=i.codes[t],s.emit("error",r)};var l=i.Z_DEFAULT_COMPRESSION;"number"==typeof e.level&&(l=e.level);var u=i.Z_DEFAULT_STRATEGY;"number"==typeof e.strategy&&(u=e.strategy),this._handle.init(e.windowBits||i.Z_DEFAULT_WINDOWBITS,l,e.memLevel||i.Z_DEFAULT_MEMLEVEL,u,e.dictionary),this._buffer=r.allocUnsafe(this._chunkSize),this._offset=0,this._level=l,this._strategy=u,this.once("end",this.close),Object.defineProperty(this,"_closed",{get:function(){return!o._handle},configurable:!0,enumerable:!0})}function M(e,i){i&&t.nextTick(i),e._handle&&(e._handle.close(),e._handle=null)}function T(e){e.emit("close")}Object.defineProperty(i,"codes",{enumerable:!0,value:Object.freeze(d),writable:!1}),i.Deflate=y,i.Inflate=w,i.Gzip=v,i.Gunzip=x,i.DeflateRaw=E,i.InflateRaw=k,i.Unzip=S,i.createDeflate=function(e){return new y(e)},i.createInflate=function(e){return new w(e)},i.createDeflateRaw=function(e){return new E(e)},i.createInflateRaw=function(e){return new k(e)},i.createGzip=function(e){return new v(e)},i.createGunzip=function(e){return new x(e)},i.createUnzip=function(e){return new S(e)},i.deflate=function(e,t,i){return"function"==typeof t&&(i=t,t={}),g(new y(t),e,i)},i.deflateSync=function(e,t){return b(new y(t),e)},i.gzip=function(e,t,i){return"function"==typeof t&&(i=t,t={}),g(new v(t),e,i)},i.gzipSync=function(e,t){return b(new v(t),e)},i.deflateRaw=function(e,t,i){return"function"==typeof t&&(i=t,t={}),g(new E(t),e,i)},i.deflateRawSync=function(e,t){return b(new E(t),e)},i.unzip=function(e,t,i){return"function"==typeof t&&(i=t,t={}),g(new S(t),e,i)},i.unzipSync=function(e,t){return b(new S(t),e)},i.inflate=function(e,t,i){return"function"==typeof t&&(i=t,t={}),g(new w(t),e,i)},i.inflateSync=function(e,t){return b(new w(t),e)},i.gunzip=function(e,t,i){return"function"==typeof t&&(i=t,t={}),g(new x(t),e,i)},i.gunzipSync=function(e,t){return b(new x(t),e)},i.inflateRaw=function(e,t,i){return"function"==typeof t&&(i=t,t={}),g(new k(t),e,i)},i.inflateRawSync=function(e,t){return b(new k(t),e)},o.inherits(I,n),I.prototype.params=function(e,r,n){if(e<i.Z_MIN_LEVEL||e>i.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+e);if(r!=i.Z_FILTERED&&r!=i.Z_HUFFMAN_ONLY&&r!=i.Z_RLE&&r!=i.Z_FIXED&&r!=i.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+r);if(this._level!==e||this._strategy!==r){var o=this;this.flush(a.Z_SYNC_FLUSH,(function(){s(o._handle,"zlib binding closed"),o._handle.params(e,r),o._hadError||(o._level=e,o._strategy=r,n&&n())}))}else t.nextTick(n)},I.prototype.reset=function(){return s(this._handle,"zlib binding closed"),this._handle.reset()},I.prototype._flush=function(e){this._transform(r.alloc(0),"",e)},I.prototype.flush=function(e,i){var n=this,o=this._writableState;("function"==typeof e||void 0===e&&!i)&&(i=e,e=a.Z_FULL_FLUSH),o.ended?i&&t.nextTick(i):o.ending?i&&this.once("end",i):o.needDrain?i&&this.once("drain",(function(){return n.flush(e,i)})):(this._flushFlag=e,this.write(r.alloc(0),"",i))},I.prototype.close=function(e){M(this,e),t.nextTick(T,this)},I.prototype._transform=function(e,t,i){var n,o=this._writableState,s=(o.ending||o.ended)&&(!e||o.length===e.length);return null===e||r.isBuffer(e)?this._handle?(s?n=this._finishFlushFlag:(n=this._flushFlag,e.length>=o.length&&(this._flushFlag=this._opts.flush||a.Z_NO_FLUSH)),void this._processChunk(e,n,i)):i(new Error("zlib binding closed")):i(new Error("invalid input"))},I.prototype._processChunk=function(e,t,i){var n=e&&e.length,a=this._chunkSize-this._offset,o=0,h=this,c="function"==typeof i;if(!c){var f,d=[],p=0;this.on("error",(function(e){f=e})),s(this._handle,"zlib binding closed");do{var m=this._handle.writeSync(t,e,o,n,this._buffer,this._offset,a)}while(!this._hadError&&b(m[0],m[1]));if(this._hadError)throw f;if(p>=l)throw M(this),new RangeError(u);var _=r.concat(d,p);return M(this),_}s(this._handle,"zlib binding closed");var g=this._handle.write(t,e,o,n,this._buffer,this._offset,a);function b(l,u){if(this&&(this.buffer=null,this.callback=null),!h._hadError){var f=a-u;if(s(f>=0,"have should not go down"),f>0){var m=h._buffer.slice(h._offset,h._offset+f);h._offset+=f,c?h.push(m):(d.push(m),p+=m.length)}if((0===u||h._offset>=h._chunkSize)&&(a=h._chunkSize,h._offset=0,h._buffer=r.allocUnsafe(h._chunkSize)),0===u){if(o+=n-l,n=l,!c)return!0;var _=h._handle.write(t,e,o,n,h._buffer,h._offset,h._chunkSize);return _.callback=b,void(_.buffer=e)}if(!c)return!1;i()}}g.buffer=e,g.callback=b},o.inherits(y,I),o.inherits(w,I),o.inherits(v,I),o.inherits(x,I),o.inherits(E,I),o.inherits(k,I),o.inherits(S,I)}).call(this)}).call(this,e("_process"))},{"./binding":30,_process:63,assert:23,buffer:32,stream:65,util:84}],32:[function(e,t,i){(function(t){(function(){var t=e("base64-js"),r=e("ieee754");i.Buffer=s,i.SlowBuffer=g,i.INSPECT_MAX_BYTES=50;var n=2147483647;function a(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(e){return!1}}function o(e){if(e>n)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return t.__proto__=s.prototype,t}function s(e,t,i){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return c(e)}return l(e,t,i)}function l(e,t,i){if("string"==typeof e)return f(e,t);if(ArrayBuffer.isView(e))return d(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(Y(e,ArrayBuffer)||e&&Y(e.buffer,ArrayBuffer))return p(e,t,i);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var r=e.valueOf&&e.valueOf();if(null!=r&&r!==e)return s.from(r,t,i);var n=m(e);if(n)return n;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return s.from(e[Symbol.toPrimitive]("string"),t,i);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function u(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function h(e,t,i){return u(e),e<=0?o(e):void 0!==t?"string"==typeof i?o(e).fill(t,i):o(e).fill(t):o(e)}function c(e){return u(e),o(e<0?0:0|_(e))}function f(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!s.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var i=0|b(e,t),r=o(i),n=r.write(e,t);return n!==i&&(r=r.slice(0,n)),r}function d(e){for(var t=e.length<0?0:0|_(e.length),i=o(t),r=0;r<t;r+=1)i[r]=255&e[r];return i}function p(e,t,i){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(i||0))throw new RangeError('"length" is outside of buffer bounds');var r;return(r=void 0===t&&void 0===i?new Uint8Array(e):void 0===i?new Uint8Array(e,t):new Uint8Array(e,t,i)).__proto__=s.prototype,r}function m(e){if(s.isBuffer(e)){var t=0|_(e.length),i=o(t);return 0===i.length||e.copy(i,0,0,t),i}return void 0!==e.length?"number"!=typeof e.length||K(e.length)?o(0):d(e):"Buffer"===e.type&&Array.isArray(e.data)?d(e.data):void 0}function _(e){if(e>=n)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n.toString(16)+" bytes");return 0|e}function g(e){return+e!=e&&(e=0),s.alloc(+e)}function b(e,t){if(s.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Y(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var i=e.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===i)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":return H(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return q(e).length;default:if(n)return r?-1:H(e).length;t=(""+t).toLowerCase(),n=!0}}function y(e,t,i){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return F(this,t,i);case"utf8":case"utf-8":return P(this,t,i);case"ascii":return R(this,t,i);case"latin1":case"binary":return z(this,t,i);case"base64":return T(this,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,t,i);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function w(e,t,i){var r=e[t];e[t]=e[i],e[i]=r}function v(e,t,i,r,n){if(0===e.length)return-1;if("string"==typeof i?(r=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),K(i=+i)&&(i=n?0:e.length-1),i<0&&(i=e.length+i),i>=e.length){if(n)return-1;i=e.length-1}else if(i<0){if(!n)return-1;i=0}if("string"==typeof t&&(t=s.from(t,r)),s.isBuffer(t))return 0===t.length?-1:x(e,t,i,r,n);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(e,t,i):Uint8Array.prototype.lastIndexOf.call(e,t,i):x(e,[t],i,r,n);throw new TypeError("val must be string, number or Buffer")}function x(e,t,i,r,n){var a,o=1,s=e.length,l=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,s/=2,l/=2,i/=2}function u(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(n){var h=-1;for(a=i;a<s;a++)if(u(e,a)===u(t,-1===h?0:a-h)){if(-1===h&&(h=a),a-h+1===l)return h*o}else-1!==h&&(a-=a-h),h=-1}else for(i+l>s&&(i=s-l),a=i;a>=0;a--){for(var c=!0,f=0;f<l;f++)if(u(e,a+f)!==u(t,f)){c=!1;break}if(c)return a}return-1}function E(e,t,i,r){i=Number(i)||0;var n=e.length-i;r?(r=Number(r))>n&&(r=n):r=n;var a=t.length;r>a/2&&(r=a/2);for(var o=0;o<r;++o){var s=parseInt(t.substr(2*o,2),16);if(K(s))return o;e[i+o]=s}return o}function k(e,t,i,r){return V(H(t,e.length-i),e,i,r)}function S(e,t,i,r){return V(Q(t),e,i,r)}function A(e,t,i,r){return S(e,t,i,r)}function I(e,t,i,r){return V(q(t),e,i,r)}function M(e,t,i,r){return V(W(t,e.length-i),e,i,r)}function T(e,i,r){return 0===i&&r===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(i,r))}function P(e,t,i){i=Math.min(e.length,i);for(var r=[],n=t;n<i;){var a,o,s,l,u=e[n],h=null,c=u>239?4:u>223?3:u>191?2:1;if(n+c<=i)switch(c){case 1:u<128&&(h=u);break;case 2:128==(192&(a=e[n+1]))&&(l=(31&u)<<6|63&a)>127&&(h=l);break;case 3:a=e[n+1],o=e[n+2],128==(192&a)&&128==(192&o)&&(l=(15&u)<<12|(63&a)<<6|63&o)>2047&&(l<55296||l>57343)&&(h=l);break;case 4:a=e[n+1],o=e[n+2],s=e[n+3],128==(192&a)&&128==(192&o)&&128==(192&s)&&(l=(15&u)<<18|(63&a)<<12|(63&o)<<6|63&s)>65535&&l<1114112&&(h=l)}null===h?(h=65533,c=1):h>65535&&(h-=65536,r.push(h>>>10&1023|55296),h=56320|1023&h),r.push(h),n+=c}return C(r)}i.kMaxLength=n,s.TYPED_ARRAY_SUPPORT=a(),s.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(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&s[Symbol.species]===s&&Object.defineProperty(s,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),s.poolSize=8192,s.from=function(e,t,i){return l(e,t,i)},s.prototype.__proto__=Uint8Array.prototype,s.__proto__=Uint8Array,s.alloc=function(e,t,i){return h(e,t,i)},s.allocUnsafe=function(e){return c(e)},s.allocUnsafeSlow=function(e){return c(e)},s.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==s.prototype},s.compare=function(e,t){if(Y(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),Y(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(e)||!s.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var i=e.length,r=t.length,n=0,a=Math.min(i,r);n<a;++n)if(e[n]!==t[n]){i=e[n],r=t[n];break}return i<r?-1:r<i?1:0},s.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}},s.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return s.alloc(0);var i;if(void 0===t)for(t=0,i=0;i<e.length;++i)t+=e[i].length;var r=s.allocUnsafe(t),n=0;for(i=0;i<e.length;++i){var a=e[i];if(Y(a,Uint8Array)&&(a=s.from(a)),!s.isBuffer(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(r,n),n+=a.length}return r},s.byteLength=b,s.prototype._isBuffer=!0,s.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)w(this,t,t+1);return this},s.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)w(this,t,t+3),w(this,t+1,t+2);return this},s.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)w(this,t,t+7),w(this,t+1,t+6),w(this,t+2,t+5),w(this,t+3,t+4);return this},s.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?P(this,0,e):y.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(e){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===s.compare(this,e)},s.prototype.inspect=function(){var e="",t=i.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},s.prototype.compare=function(e,t,i,r,n){if(Y(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===i&&(i=e?e.length:0),void 0===r&&(r=0),void 0===n&&(n=this.length),t<0||i>e.length||r<0||n>this.length)throw new RangeError("out of range index");if(r>=n&&t>=i)return 0;if(r>=n)return-1;if(t>=i)return 1;if(this===e)return 0;for(var a=(n>>>=0)-(r>>>=0),o=(i>>>=0)-(t>>>=0),l=Math.min(a,o),u=this.slice(r,n),h=e.slice(t,i),c=0;c<l;++c)if(u[c]!==h[c]){a=u[c],o=h[c];break}return a<o?-1:o<a?1:0},s.prototype.includes=function(e,t,i){return-1!==this.indexOf(e,t,i)},s.prototype.indexOf=function(e,t,i){return v(this,e,t,i,!0)},s.prototype.lastIndexOf=function(e,t,i){return v(this,e,t,i,!1)},s.prototype.write=function(e,t,i,r){if(void 0===t)r="utf8",i=this.length,t=0;else if(void 0===i&&"string"==typeof t)r=t,i=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(i)?(i>>>=0,void 0===r&&(r="utf8")):(r=i,i=void 0)}var n=this.length-t;if((void 0===i||i>n)&&(i=n),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var a=!1;;)switch(r){case"hex":return E(this,e,t,i);case"utf8":case"utf-8":return k(this,e,t,i);case"ascii":return S(this,e,t,i);case"latin1":case"binary":return A(this,e,t,i);case"base64":return I(this,e,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,e,t,i);default:if(a)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),a=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var B=4096;function C(e){var t=e.length;if(t<=B)return String.fromCharCode.apply(String,e);for(var i="",r=0;r<t;)i+=String.fromCharCode.apply(String,e.slice(r,r+=B));return i}function R(e,t,i){var r="";i=Math.min(e.length,i);for(var n=t;n<i;++n)r+=String.fromCharCode(127&e[n]);return r}function z(e,t,i){var r="";i=Math.min(e.length,i);for(var n=t;n<i;++n)r+=String.fromCharCode(e[n]);return r}function F(e,t,i){var r=e.length;(!t||t<0)&&(t=0),(!i||i<0||i>r)&&(i=r);for(var n="",a=t;a<i;++a)n+=G(e[a]);return n}function N(e,t,i){for(var r=e.slice(t,i),n="",a=0;a<r.length;a+=2)n+=String.fromCharCode(r[a]+256*r[a+1]);return n}function O(e,t,i){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>i)throw new RangeError("Trying to access beyond buffer length")}function D(e,t,i,r,n,a){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||t<a)throw new RangeError('"value" argument is out of bounds');if(i+r>e.length)throw new RangeError("Index out of range")}function $(e,t,i,r,n,a){if(i+r>e.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function L(e,t,i,n,a){return t=+t,i>>>=0,a||$(e,t,i,4),r.write(e,t,i,n,23,4),i+4}function U(e,t,i,n,a){return t=+t,i>>>=0,a||$(e,t,i,8),r.write(e,t,i,n,52,8),i+8}s.prototype.slice=function(e,t){var i=this.length;(e=~~e)<0?(e+=i)<0&&(e=0):e>i&&(e=i),(t=void 0===t?i:~~t)<0?(t+=i)<0&&(t=0):t>i&&(t=i),t<e&&(t=e);var r=this.subarray(e,t);return r.__proto__=s.prototype,r},s.prototype.readUIntLE=function(e,t,i){e>>>=0,t>>>=0,i||O(e,t,this.length);for(var r=this[e],n=1,a=0;++a<t&&(n*=256);)r+=this[e+a]*n;return r},s.prototype.readUIntBE=function(e,t,i){e>>>=0,t>>>=0,i||O(e,t,this.length);for(var r=this[e+--t],n=1;t>0&&(n*=256);)r+=this[e+--t]*n;return r},s.prototype.readUInt8=function(e,t){return e>>>=0,t||O(e,1,this.length),this[e]},s.prototype.readUInt16LE=function(e,t){return e>>>=0,t||O(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUInt16BE=function(e,t){return e>>>=0,t||O(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUInt32LE=function(e,t){return e>>>=0,t||O(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},s.prototype.readUInt32BE=function(e,t){return e>>>=0,t||O(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readIntLE=function(e,t,i){e>>>=0,t>>>=0,i||O(e,t,this.length);for(var r=this[e],n=1,a=0;++a<t&&(n*=256);)r+=this[e+a]*n;return r>=(n*=128)&&(r-=Math.pow(2,8*t)),r},s.prototype.readIntBE=function(e,t,i){e>>>=0,t>>>=0,i||O(e,t,this.length);for(var r=t,n=1,a=this[e+--r];r>0&&(n*=256);)a+=this[e+--r]*n;return a>=(n*=128)&&(a-=Math.pow(2,8*t)),a},s.prototype.readInt8=function(e,t){return e>>>=0,t||O(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},s.prototype.readInt16LE=function(e,t){e>>>=0,t||O(e,2,this.length);var i=this[e]|this[e+1]<<8;return 32768&i?4294901760|i:i},s.prototype.readInt16BE=function(e,t){e>>>=0,t||O(e,2,this.length);var i=this[e+1]|this[e]<<8;return 32768&i?4294901760|i:i},s.prototype.readInt32LE=function(e,t){return e>>>=0,t||O(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e>>>=0,t||O(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readFloatLE=function(e,t){return e>>>=0,t||O(e,4,this.length),r.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e>>>=0,t||O(e,4,this.length),r.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e>>>=0,t||O(e,8,this.length),r.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e>>>=0,t||O(e,8,this.length),r.read(this,e,!1,52,8)},s.prototype.writeUIntLE=function(e,t,i,r){e=+e,t>>>=0,i>>>=0,r||D(this,e,t,i,Math.pow(2,8*i)-1,0);var n=1,a=0;for(this[t]=255&e;++a<i&&(n*=256);)this[t+a]=e/n&255;return t+i},s.prototype.writeUIntBE=function(e,t,i,r){e=+e,t>>>=0,i>>>=0,r||D(this,e,t,i,Math.pow(2,8*i)-1,0);var n=i-1,a=1;for(this[t+n]=255&e;--n>=0&&(a*=256);)this[t+n]=e/a&255;return t+i},s.prototype.writeUInt8=function(e,t,i){return e=+e,t>>>=0,i||D(this,e,t,1,255,0),this[t]=255&e,t+1},s.prototype.writeUInt16LE=function(e,t,i){return e=+e,t>>>=0,i||D(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeUInt16BE=function(e,t,i){return e=+e,t>>>=0,i||D(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeUInt32LE=function(e,t,i){return e=+e,t>>>=0,i||D(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},s.prototype.writeUInt32BE=function(e,t,i){return e=+e,t>>>=0,i||D(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeIntLE=function(e,t,i,r){if(e=+e,t>>>=0,!r){var n=Math.pow(2,8*i-1);D(this,e,t,i,n-1,-n)}var a=0,o=1,s=0;for(this[t]=255&e;++a<i&&(o*=256);)e<0&&0===s&&0!==this[t+a-1]&&(s=1),this[t+a]=(e/o|0)-s&255;return t+i},s.prototype.writeIntBE=function(e,t,i,r){if(e=+e,t>>>=0,!r){var n=Math.pow(2,8*i-1);D(this,e,t,i,n-1,-n)}var a=i-1,o=1,s=0;for(this[t+a]=255&e;--a>=0&&(o*=256);)e<0&&0===s&&0!==this[t+a+1]&&(s=1),this[t+a]=(e/o|0)-s&255;return t+i},s.prototype.writeInt8=function(e,t,i){return e=+e,t>>>=0,i||D(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},s.prototype.writeInt16LE=function(e,t,i){return e=+e,t>>>=0,i||D(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,i){return e=+e,t>>>=0,i||D(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeInt32LE=function(e,t,i){return e=+e,t>>>=0,i||D(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,i){return e=+e,t>>>=0,i||D(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeFloatLE=function(e,t,i){return L(this,e,t,!0,i)},s.prototype.writeFloatBE=function(e,t,i){return L(this,e,t,!1,i)},s.prototype.writeDoubleLE=function(e,t,i){return U(this,e,t,!0,i)},s.prototype.writeDoubleBE=function(e,t,i){return U(this,e,t,!1,i)},s.prototype.copy=function(e,t,i,r){if(!s.isBuffer(e))throw new TypeError("argument should be a Buffer");if(i||(i=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<i&&(r=i),r===i)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-i&&(r=e.length-t+i);var n=r-i;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(t,i,r);else if(this===e&&i<t&&t<r)for(var a=n-1;a>=0;--a)e[a+t]=this[a+i];else Uint8Array.prototype.set.call(e,this.subarray(i,r),t);return n},s.prototype.fill=function(e,t,i,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,i=this.length):"string"==typeof i&&(r=i,i=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!s.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===e.length){var n=e.charCodeAt(0);("utf8"===r&&n<128||"latin1"===r)&&(e=n)}}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<i)throw new RangeError("Out of range index");if(i<=t)return this;var a;if(t>>>=0,i=void 0===i?this.length:i>>>0,e||(e=0),"number"==typeof e)for(a=t;a<i;++a)this[a]=e;else{var o=s.isBuffer(e)?e:s.from(e,r),l=o.length;if(0===l)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(a=0;a<i-t;++a)this[a+t]=o[a%l]}return this};var Z=/[^+/0-9A-Za-z-_]/g;function j(e){if((e=(e=e.split("=")[0]).trim().replace(Z,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}function G(e){return e<16?"0"+e.toString(16):e.toString(16)}function H(e,t){var i;t=t||1/0;for(var r=e.length,n=null,a=[],o=0;o<r;++o){if((i=e.charCodeAt(o))>55295&&i<57344){if(!n){if(i>56319){(t-=3)>-1&&a.push(239,191,189);continue}if(o+1===r){(t-=3)>-1&&a.push(239,191,189);continue}n=i;continue}if(i<56320){(t-=3)>-1&&a.push(239,191,189),n=i;continue}i=65536+(n-55296<<10|i-56320)}else n&&(t-=3)>-1&&a.push(239,191,189);if(n=null,i<128){if((t-=1)<0)break;a.push(i)}else if(i<2048){if((t-=2)<0)break;a.push(i>>6|192,63&i|128)}else if(i<65536){if((t-=3)<0)break;a.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;a.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return a}function Q(e){for(var t=[],i=0;i<e.length;++i)t.push(255&e.charCodeAt(i));return t}function W(e,t){for(var i,r,n,a=[],o=0;o<e.length&&!((t-=2)<0);++o)r=(i=e.charCodeAt(o))>>8,n=i%256,a.push(n),a.push(r);return a}function q(e){return t.toByteArray(j(e))}function V(e,t,i,r){for(var n=0;n<r&&!(n+i>=t.length||n>=e.length);++n)t[n+i]=e[n];return n}function Y(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function K(e){return e!=e}}).call(this)}).call(this,e("buffer").Buffer)},{"base64-js":28,buffer:32,ieee754:45}],33:[function(e,t,i){var r=e("get-intrinsic"),n=e("./"),a=n(r("String.prototype.indexOf"));t.exports=function(e,t){var i=r(e,!!t);return"function"==typeof i&&a(e,".prototype.")>-1?n(i):i}},{"./":34,"get-intrinsic":39}],34:[function(e,t,i){var r=e("function-bind"),n=e("get-intrinsic"),a=n("%Function.prototype.apply%"),o=n("%Function.prototype.call%"),s=n("%Reflect.apply%",!0)||r.call(o,a),l=n("%Object.getOwnPropertyDescriptor%",!0),u=n("%Object.defineProperty%",!0),h=n("%Math.max%");if(u)try{u({},"a",{value:1})}catch(e){u=null}t.exports=function(e){var t=s(r,o,arguments);return l&&u&&l(t,"length").configurable&&u(t,"length",{value:1+h(0,e.length-(arguments.length-1))}),t};var c=function(){return s(r,a,arguments)};u?u(t.exports,"apply",{value:c}):t.exports.apply=c},{"function-bind":38,"get-intrinsic":39}],35:[function(e,t,i){var r,n="object"==typeof Reflect?Reflect:null,a=n&&"function"==typeof n.apply?n.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)};function o(e){console&&console.warn&&console.warn(e)}r=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function l(){l.init.call(this)}t.exports=l,t.exports.once=w,l.EventEmitter=l,l.prototype._events=void 0,l.prototype._eventsCount=0,l.prototype._maxListeners=void 0;var u=10;function h(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?l.defaultMaxListeners:e._maxListeners}function f(e,t,i,r){var n,a,s;if(h(i),void 0===(a=e._events)?(a=e._events=Object.create(null),e._eventsCount=0):(void 0!==a.newListener&&(e.emit("newListener",t,i.listener?i.listener:i),a=e._events),s=a[t]),void 0===s)s=a[t]=i,++e._eventsCount;else if("function"==typeof s?s=a[t]=r?[i,s]:[s,i]:r?s.unshift(i):s.push(i),(n=c(e))>0&&s.length>n&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=s.length,o(l)}return e}function d(){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)}function p(e,t,i){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:i},n=d.bind(r);return n.listener=i,r.wrapFn=n,n}function m(e,t,i){var r=e._events;if(void 0===r)return[];var n=r[t];return void 0===n?[]:"function"==typeof n?i?[n.listener||n]:[n]:i?y(n):g(n,n.length)}function _(e){var t=this._events;if(void 0!==t){var i=t[e];if("function"==typeof i)return 1;if(void 0!==i)return i.length}return 0}function g(e,t){for(var i=new Array(t),r=0;r<t;++r)i[r]=e[r];return i}function b(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function y(e){for(var t=new Array(e.length),i=0;i<t.length;++i)t[i]=e[i].listener||e[i];return t}function w(e,t){return new Promise((function(i,r){function n(i){e.removeListener(t,a),r(i)}function a(){"function"==typeof e.removeListener&&e.removeListener("error",n),i([].slice.call(arguments))}x(e,t,a,{once:!0}),"error"!==t&&v(e,n,{once:!0})}))}function v(e,t,i){"function"==typeof e.on&&x(e,"error",t,i)}function x(e,t,i,r){if("function"==typeof e.on)r.once?e.once(t,i):e.on(t,i);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function n(a){r.once&&e.removeEventListener(t,n),i(a)}))}}Object.defineProperty(l,"defaultMaxListeners",{enumerable:!0,get:function(){return u},set:function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");u=e}}),l.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},l.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},l.prototype.getMaxListeners=function(){return c(this)},l.prototype.emit=function(e){for(var t=[],i=1;i<arguments.length;i++)t.push(arguments[i]);var r="error"===e,n=this._events;if(void 0!==n)r=r&&void 0===n.error;else if(!r)return!1;if(r){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var s=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw s.context=o,s}var l=n[e];if(void 0===l)return!1;if("function"==typeof l)a(l,this,t);else{var u=l.length,h=g(l,u);for(i=0;i<u;++i)a(h[i],this,t)}return!0},l.prototype.addListener=function(e,t){return f(this,e,t,!1)},l.prototype.on=l.prototype.addListener,l.prototype.prependListener=function(e,t){return f(this,e,t,!0)},l.prototype.once=function(e,t){return h(t),this.on(e,p(this,e,t)),this},l.prototype.prependOnceListener=function(e,t){return h(t),this.prependListener(e,p(this,e,t)),this},l.prototype.removeListener=function(e,t){var i,r,n,a,o;if(h(t),void 0===(r=this._events))return this;if(void 0===(i=r[e]))return this;if(i===t||i.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,i.listener||t));else if("function"!=typeof i){for(n=-1,a=i.length-1;a>=0;a--)if(i[a]===t||i[a].listener===t){o=i[a].listener,n=a;break}if(n<0)return this;0===n?i.shift():b(i,n),1===i.length&&(r[e]=i[0]),void 0!==r.removeListener&&this.emit("removeListener",e,o||t)}return this},l.prototype.off=l.prototype.removeListener,l.prototype.removeAllListeners=function(e){var t,i,r;if(void 0===(i=this._events))return this;if(void 0===i.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==i[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete i[e]),this;if(0===arguments.length){var n,a=Object.keys(i);for(r=0;r<a.length;++r)"removeListener"!==(n=a[r])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=i[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},l.prototype.listeners=function(e){return m(this,e,!0)},l.prototype.rawListeners=function(e){return m(this,e,!1)},l.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):_.call(e,t)},l.prototype.listenerCount=_,l.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}},{}],36:[function(e,t,i){var r=e("is-callable"),n=Object.prototype.toString,a=Object.prototype.hasOwnProperty,o=function(e,t,i){for(var r=0,n=e.length;r<n;r++)a.call(e,r)&&(null==i?t(e[r],r,e):t.call(i,e[r],r,e))},s=function(e,t,i){for(var r=0,n=e.length;r<n;r++)null==i?t(e.charAt(r),r,e):t.call(i,e.charAt(r),r,e)},l=function(e,t,i){for(var r in e)a.call(e,r)&&(null==i?t(e[r],r,e):t.call(i,e[r],r,e))},u=function(e,t,i){if(!r(t))throw new TypeError("iterator must be a function");var a;arguments.length>=3&&(a=i),"[object Array]"===n.call(e)?o(e,t,a):"string"==typeof e?s(e,t,a):l(e,t,a)};t.exports=u},{"is-callable":48}],37:[function(e,t,i){var r="Function.prototype.bind called on incompatible ",n=Array.prototype.slice,a=Object.prototype.toString,o="[object Function]";t.exports=function(e){var t=this;if("function"!=typeof t||a.call(t)!==o)throw new TypeError(r+t);for(var i,s=n.call(arguments,1),l=function(){if(this instanceof i){var r=t.apply(this,s.concat(n.call(arguments)));return Object(r)===r?r:this}return t.apply(e,s.concat(n.call(arguments)))},u=Math.max(0,t.length-s.length),h=[],c=0;c<u;c++)h.push("$"+c);if(i=Function("binder","return function ("+h.join(",")+"){ return binder.apply(this,arguments); }")(l),t.prototype){var f=function(){};f.prototype=t.prototype,i.prototype=new f,f.prototype=null}return i}},{}],38:[function(e,t,i){var r=e("./implementation");t.exports=Function.prototype.bind||r},{"./implementation":37}],39:[function(e,t,i){var r,n=SyntaxError,a=Function,o=TypeError,s=function(e){try{return a('"use strict"; return ('+e+").constructor;")()}catch(e){}},l=Object.getOwnPropertyDescriptor;if(l)try{l({},"")}catch(e){l=null}var u=function(){throw new o},h=l?function(){try{return u}catch(e){try{return l(arguments,"callee").get}catch(e){return u}}}():u,c=e("has-symbols")(),f=Object.getPrototypeOf||function(e){return e.__proto__},d={},p="undefined"==typeof Uint8Array?r:f(Uint8Array),m={"%AggregateError%":"undefined"==typeof AggregateError?r:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?r:ArrayBuffer,"%ArrayIteratorPrototype%":c?f([][Symbol.iterator]()):r,"%AsyncFromSyncIteratorPrototype%":r,"%AsyncFunction%":d,"%AsyncGenerator%":d,"%AsyncGeneratorFunction%":d,"%AsyncIteratorPrototype%":d,"%Atomics%":"undefined"==typeof Atomics?r:Atomics,"%BigInt%":"undefined"==typeof BigInt?r:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?r:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?r:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?r:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":"undefined"==typeof Float32Array?r:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?r:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?r:FinalizationRegistry,"%Function%":a,"%GeneratorFunction%":d,"%Int8Array%":"undefined"==typeof Int8Array?r:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?r:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?r:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":c?f(f([][Symbol.iterator]())):r,"%JSON%":"object"==typeof JSON?JSON:r,"%Map%":"undefined"==typeof Map?r:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&c?f((new Map)[Symbol.iterator]()):r,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?r:Promise,"%Proxy%":"undefined"==typeof Proxy?r:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":"undefined"==typeof Reflect?r:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?r:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&c?f((new Set)[Symbol.iterator]()):r,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?r:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":c?f(""[Symbol.iterator]()):r,"%Symbol%":c?Symbol:r,"%SyntaxError%":n,"%ThrowTypeError%":h,"%TypedArray%":p,"%TypeError%":o,"%Uint8Array%":"undefined"==typeof Uint8Array?r:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?r:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?r:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?r:Uint32Array,"%URIError%":URIError,"%WeakMap%":"undefined"==typeof WeakMap?r:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?r:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?r:WeakSet};try{null.error}catch(e){var _=f(f(e));m["%Error.prototype%"]=_}var g=function e(t){var i;if("%AsyncFunction%"===t)i=s("async function () {}");else if("%GeneratorFunction%"===t)i=s("function* () {}");else if("%AsyncGeneratorFunction%"===t)i=s("async function* () {}");else if("%AsyncGenerator%"===t){var r=e("%AsyncGeneratorFunction%");r&&(i=r.prototype)}else if("%AsyncIteratorPrototype%"===t){var n=e("%AsyncGenerator%");n&&(i=f(n.prototype))}return m[t]=i,i},b={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},y=e("function-bind"),w=e("has"),v=y.call(Function.call,Array.prototype.concat),x=y.call(Function.apply,Array.prototype.splice),E=y.call(Function.call,String.prototype.replace),k=y.call(Function.call,String.prototype.slice),S=y.call(Function.call,RegExp.prototype.exec),A=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,I=/\\(\\)?/g,M=function(e){var t=k(e,0,1),i=k(e,-1);if("%"===t&&"%"!==i)throw new n("invalid intrinsic syntax, expected closing `%`");if("%"===i&&"%"!==t)throw new n("invalid intrinsic syntax, expected opening `%`");var r=[];return E(e,A,(function(e,t,i,n){r[r.length]=i?E(n,I,"$1"):t||e})),r},T=function(e,t){var i,r=e;if(w(b,r)&&(r="%"+(i=b[r])[0]+"%"),w(m,r)){var a=m[r];if(a===d&&(a=g(r)),void 0===a&&!t)throw new o("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:r,value:a}}throw new n("intrinsic "+e+" does not exist!")};t.exports=function(e,t){if("string"!=typeof e||0===e.length)throw new o("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new o('"allowMissing" argument must be a boolean');if(null===S(/^%?[^%]*%?$/,e))throw new n("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=M(e),r=i.length>0?i[0]:"",a=T("%"+r+"%",t),s=a.name,u=a.value,h=!1,c=a.alias;c&&(r=c[0],x(i,v([0,1],c)));for(var f=1,d=!0;f<i.length;f+=1){var p=i[f],_=k(p,0,1),g=k(p,-1);if(('"'===_||"'"===_||"`"===_||'"'===g||"'"===g||"`"===g)&&_!==g)throw new n("property names with quotes must have matching quotes");if("constructor"!==p&&d||(h=!0),w(m,s="%"+(r+="."+p)+"%"))u=m[s];else if(null!=u){if(!(p in u)){if(!t)throw new o("base intrinsic for "+e+" exists, but the property is not available.");return}if(l&&f+1>=i.length){var b=l(u,p);u=(d=!!b)&&"get"in b&&!("originalValue"in b.get)?b.get:u[p]}else d=w(u,p),u=u[p];d&&!h&&(m[s]=u)}}return u}},{"function-bind":38,has:44,"has-symbols":41}],40:[function(e,t,i){var r=e("get-intrinsic")("%Object.getOwnPropertyDescriptor%",!0);if(r)try{r([],"length")}catch(e){r=null}t.exports=r},{"get-intrinsic":39}],41:[function(e,t,i){var r="undefined"!=typeof Symbol&&Symbol,n=e("./shams");t.exports=function(){return"function"==typeof r&&"function"==typeof Symbol&&"symbol"==typeof r("foo")&&"symbol"==typeof Symbol("bar")&&n()}},{"./shams":42}],42:[function(e,t,i){t.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),i=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(i))return!1;var r=42;for(t in e[t]=r,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var n=Object.getOwnPropertySymbols(e);if(1!==n.length||n[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var a=Object.getOwnPropertyDescriptor(e,t);if(a.value!==r||!0!==a.enumerable)return!1}return!0}},{}],43:[function(e,t,i){var r=e("has-symbols/shams");t.exports=function(){return r()&&!!Symbol.toStringTag}},{"has-symbols/shams":42}],44:[function(e,t,i){var r=e("function-bind");t.exports=r.call(Function.call,Object.prototype.hasOwnProperty)},{"function-bind":38}],45:[function(e,t,i){
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
i.read=function(e,t,i,r,n){var a,o,s=8*n-r-1,l=(1<<s)-1,u=l>>1,h=-7,c=i?n-1:0,f=i?-1:1,d=e[t+c];for(c+=f,a=d&(1<<-h)-1,d>>=-h,h+=s;h>0;a=256*a+e[t+c],c+=f,h-=8);for(o=a&(1<<-h)-1,a>>=-h,h+=r;h>0;o=256*o+e[t+c],c+=f,h-=8);if(0===a)a=1-u;else{if(a===l)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,r),a-=u}return(d?-1:1)*o*Math.pow(2,a-r)},i.write=function(e,t,i,r,n,a){var o,s,l,u=8*a-n-1,h=(1<<u)-1,c=h>>1,f=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:a-1,p=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,o=h):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),(t+=o+c>=1?f/l:f*Math.pow(2,1-c))*l>=2&&(o++,l/=2),o+c>=h?(s=0,o=h):o+c>=1?(s=(t*l-1)*Math.pow(2,n),o+=c):(s=t*Math.pow(2,c-1)*Math.pow(2,n),o=0));n>=8;e[i+d]=255&s,d+=p,s/=256,n-=8);for(o=o<<n|s,u+=n;u>0;e[i+d]=255&o,d+=p,o/=256,u-=8);e[i+d-p]|=128*m}},{}],46:[function(e,t,i){"function"==typeof Object.create?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e}}},{}],47:[function(e,t,i){var r=e("has-tostringtag/shams")(),n=e("call-bind/callBound")("Object.prototype.toString"),a=function(e){return!(r&&e&&"object"==typeof e&&Symbol.toStringTag in e)&&"[object Arguments]"===n(e)},o=function(e){return!!a(e)||null!==e&&"object"==typeof e&&"number"==typeof e.length&&e.length>=0&&"[object Array]"!==n(e)&&"[object Function]"===n(e.callee)},s=function(){return a(arguments)}();a.isLegacyArguments=o,t.exports=s?a:o},{"call-bind/callBound":33,"has-tostringtag/shams":43}],48:[function(e,t,i){var r,n,a=Function.prototype.toString,o="object"==typeof Reflect&&null!==Reflect&&Reflect.apply;if("function"==typeof o&&"function"==typeof Object.defineProperty)try{r=Object.defineProperty({},"length",{get:function(){throw n}}),n={},o((function(){throw 42}),null,r)}catch(e){e!==n&&(o=null)}else o=null;var s=/^\s*class\b/,l=function(e){try{var t=a.call(e);return s.test(t)}catch(e){return!1}},u=function(e){try{return!l(e)&&(a.call(e),!0)}catch(e){return!1}},h=Object.prototype.toString,c="[object Object]",f="[object Function]",d="[object GeneratorFunction]",p="[object HTMLAllCollection]",m="[object HTML document.all class]",_="[object HTMLCollection]",g="function"==typeof Symbol&&!!Symbol.toStringTag,b=!(0 in[,]),y=function(){return!1};if("object"==typeof document){var w=document.all;h.call(w)===h.call(document.all)&&(y=function(e){if((b||!e)&&(void 0===e||"object"==typeof e))try{var t=h.call(e);return(t===p||t===m||t===_||t===c)&&null==e("")}catch(e){}return!1})}t.exports=o?function(e){if(y(e))return!0;if(!e)return!1;if("function"!=typeof e&&"object"!=typeof e)return!1;try{o(e,null,r)}catch(e){if(e!==n)return!1}return!l(e)&&u(e)}:function(e){if(y(e))return!0;if(!e)return!1;if("function"!=typeof e&&"object"!=typeof e)return!1;if(g)return u(e);if(l(e))return!1;var t=h.call(e);return!(t!==f&&t!==d&&!/^\[object HTML/.test(t))&&u(e)}},{}],49:[function(e,t,i){var r,n=Object.prototype.toString,a=Function.prototype.toString,o=/^\s*(?:function)?\*/,s=e("has-tostringtag/shams")(),l=Object.getPrototypeOf,u=function(){if(!s)return!1;try{return Function("return function*() {}")()}catch(e){}};t.exports=function(e){if("function"!=typeof e)return!1;if(o.test(a.call(e)))return!0;if(!s)return"[object GeneratorFunction]"===n.call(e);if(!l)return!1;if(void 0===r){var t=u();r=!!t&&l(t)}return l(e)===r}},{"has-tostringtag/shams":43}],50:[function(e,t,i){(function(i){(function(){var r=e("for-each"),n=e("available-typed-arrays"),a=e("call-bind/callBound"),o=a("Object.prototype.toString"),s=e("has-tostringtag/shams")(),l=e("gopd"),u="undefined"==typeof globalThis?i:globalThis,h=n(),c=a("Array.prototype.indexOf",!0)||function(e,t){for(var i=0;i<e.length;i+=1)if(e[i]===t)return i;return-1},f=a("String.prototype.slice"),d={},p=Object.getPrototypeOf;s&&l&&p&&r(h,(function(e){var t=new u[e];if(Symbol.toStringTag in t){var i=p(t),r=l(i,Symbol.toStringTag);if(!r){var n=p(i);r=l(n,Symbol.toStringTag)}d[e]=r.get}}));var m=function(e){var t=!1;return r(d,(function(i,r){if(!t)try{t=i.call(e)===r}catch(e){}})),t};t.exports=function(e){if(!e||"object"!=typeof e)return!1;if(!s||!(Symbol.toStringTag in e)){var t=f(o(e),8,-1);return c(h,t)>-1}return!!l&&m(e)}}).call(this)}).call(this,void 0!==commonjsGlobal?commonjsGlobal:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"available-typed-arrays":27,"call-bind/callBound":33,"for-each":36,gopd:40,"has-tostringtag/shams":43}],51:[function(e,t,i){var r=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable;function o(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}function s(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},i=0;i<10;i++)t["_"+String.fromCharCode(i)]=i;var r=Object.getOwnPropertyNames(t).map((function(e){return t[e]}));if("0123456789"!==r.join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach((function(e){n[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}t.exports=s()?Object.assign:function(e,t){for(var i,s,l=o(e),u=1;u<arguments.length;u++){for(var h in i=Object(arguments[u]))n.call(i,h)&&(l[h]=i[h]);if(r){s=r(i);for(var c=0;c<s.length;c++)a.call(i,s[c])&&(l[s[c]]=i[s[c]])}}return l}},{}],52:[function(e,t,i){var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}i.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var i=t.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(var r in i)n(i,r)&&(e[r]=i[r])}}return e},i.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var a={arraySet:function(e,t,i,r,n){if(t.subarray&&e.subarray)e.set(t.subarray(i,i+r),n);else for(var a=0;a<r;a++)e[n+a]=t[i+a]},flattenChunks:function(e){var t,i,r,n,a,o;for(r=0,t=0,i=e.length;t<i;t++)r+=e[t].length;for(o=new Uint8Array(r),n=0,t=0,i=e.length;t<i;t++)a=e[t],o.set(a,n),n+=a.length;return o}},o={arraySet:function(e,t,i,r,n){for(var a=0;a<r;a++)e[n+a]=t[i+a]},flattenChunks:function(e){return[].concat.apply([],e)}};i.setTyped=function(e){e?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,a)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,o))},i.setTyped(r)},{}],53:[function(e,t,i){function r(e,t,i,r){for(var n=65535&e,a=e>>>16&65535,o=0;0!==i;){i-=o=i>2e3?2e3:i;do{a=a+(n=n+t[r++]|0)|0}while(--o);n%=65521,a%=65521}return n|a<<16}t.exports=r},{}],54:[function(e,t,i){t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],55:[function(e,t,i){function r(){for(var e,t=[],i=0;i<256;i++){e=i;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t}var n=r();function a(e,t,i,r){var a=n,o=r+i;e^=-1;for(var s=r;s<o;s++)e=e>>>8^a[255&(e^t[s])];return~e}t.exports=a},{}],56:[function(e,t,i){var r,n=e("../utils/common"),a=e("./trees"),o=e("./adler32"),s=e("./crc32"),l=e("./messages"),u=0,h=1,c=3,f=4,d=5,p=0,m=1,_=-2,g=-3,b=-5,y=-1,w=1,v=2,x=3,E=4,k=0,S=2,A=8,I=9,M=15,T=8,P=286,B=30,C=19,R=2*P+1,z=15,F=3,N=258,O=N+F+1,D=32,$=42,L=69,U=73,Z=91,j=103,G=113,H=666,Q=1,W=2,q=3,V=4,Y=3;function K(e,t){return e.msg=l[t],t}function J(e){return(e<<1)-(e>4?9:0)}function X(e){for(var t=e.length;--t>=0;)e[t]=0}function ee(e){var t=e.state,i=t.pending;i>e.avail_out&&(i=e.avail_out),0!==i&&(n.arraySet(e.output,t.pending_buf,t.pending_out,i,e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,0===t.pending&&(t.pending_out=0))}function te(e,t){a._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,ee(e.strm)}function ie(e,t){e.pending_buf[e.pending++]=t}function re(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function ne(e,t,i,r){var a=e.avail_in;return a>r&&(a=r),0===a?0:(e.avail_in-=a,n.arraySet(t,e.input,e.next_in,a,i),1===e.state.wrap?e.adler=o(e.adler,t,a,i):2===e.state.wrap&&(e.adler=s(e.adler,t,a,i)),e.next_in+=a,e.total_in+=a,a)}function ae(e,t){var i,r,n=e.max_chain_length,a=e.strstart,o=e.prev_length,s=e.nice_match,l=e.strstart>e.w_size-O?e.strstart-(e.w_size-O):0,u=e.window,h=e.w_mask,c=e.prev,f=e.strstart+N,d=u[a+o-1],p=u[a+o];e.prev_length>=e.good_match&&(n>>=2),s>e.lookahead&&(s=e.lookahead);do{if(u[(i=t)+o]===p&&u[i+o-1]===d&&u[i]===u[a]&&u[++i]===u[a+1]){a+=2,i++;do{}while(u[++a]===u[++i]&&u[++a]===u[++i]&&u[++a]===u[++i]&&u[++a]===u[++i]&&u[++a]===u[++i]&&u[++a]===u[++i]&&u[++a]===u[++i]&&u[++a]===u[++i]&&a<f);if(r=N-(f-a),a=f-N,r>o){if(e.match_start=t,o=r,r>=s)break;d=u[a+o-1],p=u[a+o]}}}while((t=c[t&h])>l&&0!=--n);return o<=e.lookahead?o:e.lookahead}function oe(e){var t,i,r,a,o,s=e.w_size;do{if(a=e.window_size-e.lookahead-e.strstart,e.strstart>=s+(s-O)){n.arraySet(e.window,e.window,s,s,0),e.match_start-=s,e.strstart-=s,e.block_start-=s,t=i=e.hash_size;do{r=e.head[--t],e.head[t]=r>=s?r-s:0}while(--i);t=i=s;do{r=e.prev[--t],e.prev[t]=r>=s?r-s:0}while(--i);a+=s}if(0===e.strm.avail_in)break;if(i=ne(e.strm,e.window,e.strstart+e.lookahead,a),e.lookahead+=i,e.lookahead+e.insert>=F)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+F-1])&e.hash_mask,e.prev[o&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=o,o++,e.insert--,!(e.lookahead+e.insert<F)););}while(e.lookahead<O&&0!==e.strm.avail_in)}function se(e,t){var i=65535;for(i>e.pending_buf_size-5&&(i=e.pending_buf_size-5);;){if(e.lookahead<=1){if(oe(e),0===e.lookahead&&t===u)return Q;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+i;if((0===e.strstart||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,te(e,!1),0===e.strm.avail_out))return Q;if(e.strstart-e.block_start>=e.w_size-O&&(te(e,!1),0===e.strm.avail_out))return Q}return e.insert=0,t===f?(te(e,!0),0===e.strm.avail_out?q:V):(e.strstart>e.block_start&&(te(e,!1),e.strm.avail_out),Q)}function le(e,t){for(var i,r;;){if(e.lookahead<O){if(oe(e),e.lookahead<O&&t===u)return Q;if(0===e.lookahead)break}if(i=0,e.lookahead>=F&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+F-1])&e.hash_mask,i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==i&&e.strstart-i<=e.w_size-O&&(e.match_length=ae(e,i)),e.match_length>=F)if(r=a._tr_tally(e,e.strstart-e.match_start,e.match_length-F),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=F){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+F-1])&e.hash_mask,i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else r=a._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(te(e,!1),0===e.strm.avail_out))return Q}return e.insert=e.strstart<F-1?e.strstart:F-1,t===f?(te(e,!0),0===e.strm.avail_out?q:V):e.last_lit&&(te(e,!1),0===e.strm.avail_out)?Q:W}function ue(e,t){for(var i,r,n;;){if(e.lookahead<O){if(oe(e),e.lookahead<O&&t===u)return Q;if(0===e.lookahead)break}if(i=0,e.lookahead>=F&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+F-1])&e.hash_mask,i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=F-1,0!==i&&e.prev_length<e.max_lazy_match&&e.strstart-i<=e.w_size-O&&(e.match_length=ae(e,i),e.match_length<=5&&(e.strategy===w||e.match_length===F&&e.strstart-e.match_start>4096)&&(e.match_length=F-1)),e.prev_length>=F&&e.match_length<=e.prev_length){n=e.strstart+e.lookahead-F,r=a._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-F),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=n&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+F-1])&e.hash_mask,i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=F-1,e.strstart++,r&&(te(e,!1),0===e.strm.avail_out))return Q}else if(e.match_available){if((r=a._tr_tally(e,0,e.window[e.strstart-1]))&&te(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return Q}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=a._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<F-1?e.strstart:F-1,t===f?(te(e,!0),0===e.strm.avail_out?q:V):e.last_lit&&(te(e,!1),0===e.strm.avail_out)?Q:W}function he(e,t){for(var i,r,n,o,s=e.window;;){if(e.lookahead<=N){if(oe(e),e.lookahead<=N&&t===u)return Q;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=F&&e.strstart>0&&(r=s[n=e.strstart-1])===s[++n]&&r===s[++n]&&r===s[++n]){o=e.strstart+N;do{}while(r===s[++n]&&r===s[++n]&&r===s[++n]&&r===s[++n]&&r===s[++n]&&r===s[++n]&&r===s[++n]&&r===s[++n]&&n<o);e.match_length=N-(o-n),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=F?(i=a._tr_tally(e,1,e.match_length-F),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=a._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(te(e,!1),0===e.strm.avail_out))return Q}return e.insert=0,t===f?(te(e,!0),0===e.strm.avail_out?q:V):e.last_lit&&(te(e,!1),0===e.strm.avail_out)?Q:W}function ce(e,t){for(var i;;){if(0===e.lookahead&&(oe(e),0===e.lookahead)){if(t===u)return Q;break}if(e.match_length=0,i=a._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(te(e,!1),0===e.strm.avail_out))return Q}return e.insert=0,t===f?(te(e,!0),0===e.strm.avail_out?q:V):e.last_lit&&(te(e,!1),0===e.strm.avail_out)?Q:W}function fe(e,t,i,r,n){this.good_length=e,this.max_lazy=t,this.nice_length=i,this.max_chain=r,this.func=n}function de(e){e.window_size=2*e.w_size,X(e.head),e.max_lazy_match=r[e.level].max_lazy,e.good_match=r[e.level].good_length,e.nice_match=r[e.level].nice_length,e.max_chain_length=r[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=F-1,e.match_available=0,e.ins_h=0}function pe(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=A,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new n.Buf16(2*R),this.dyn_dtree=new n.Buf16(2*(2*B+1)),this.bl_tree=new n.Buf16(2*(2*C+1)),X(this.dyn_ltree),X(this.dyn_dtree),X(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new n.Buf16(z+1),this.heap=new n.Buf16(2*P+1),X(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new n.Buf16(2*P+1),X(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function me(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=S,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?$:G,e.adler=2===t.wrap?0:1,t.last_flush=u,a._tr_init(t),p):K(e,_)}function _e(e){var t=me(e);return t===p&&de(e.state),t}function ge(e,t){return e&&e.state?2!==e.state.wrap?_:(e.state.gzhead=t,p):_}function be(e,t,i,r,a,o){if(!e)return _;var s=1;if(t===y&&(t=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),a<1||a>I||i!==A||r<8||r>15||t<0||t>9||o<0||o>E)return K(e,_);8===r&&(r=9);var l=new pe;return e.state=l,l.strm=e,l.wrap=s,l.gzhead=null,l.w_bits=r,l.w_size=1<<l.w_bits,l.w_mask=l.w_size-1,l.hash_bits=a+7,l.hash_size=1<<l.hash_bits,l.hash_mask=l.hash_size-1,l.hash_shift=~~((l.hash_bits+F-1)/F),l.window=new n.Buf8(2*l.w_size),l.head=new n.Buf16(l.hash_size),l.prev=new n.Buf16(l.w_size),l.lit_bufsize=1<<a+6,l.pending_buf_size=4*l.lit_bufsize,l.pending_buf=new n.Buf8(l.pending_buf_size),l.d_buf=1*l.lit_bufsize,l.l_buf=3*l.lit_bufsize,l.level=t,l.strategy=o,l.method=i,_e(e)}function ye(e,t){return be(e,t,A,M,T,k)}function we(e,t){var i,n,o,l;if(!e||!e.state||t>d||t<0)return e?K(e,_):_;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||n.status===H&&t!==f)return K(e,0===e.avail_out?b:_);if(n.strm=e,i=n.last_flush,n.last_flush=t,n.status===$)if(2===n.wrap)e.adler=0,ie(n,31),ie(n,139),ie(n,8),n.gzhead?(ie(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),ie(n,255&n.gzhead.time),ie(n,n.gzhead.time>>8&255),ie(n,n.gzhead.time>>16&255),ie(n,n.gzhead.time>>24&255),ie(n,9===n.level?2:n.strategy>=v||n.level<2?4:0),ie(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(ie(n,255&n.gzhead.extra.length),ie(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=s(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=L):(ie(n,0),ie(n,0),ie(n,0),ie(n,0),ie(n,0),ie(n,9===n.level?2:n.strategy>=v||n.level<2?4:0),ie(n,Y),n.status=G);else{var g=A+(n.w_bits-8<<4)<<8;g|=(n.strategy>=v||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(g|=D),g+=31-g%31,n.status=G,re(n,g),0!==n.strstart&&(re(n,e.adler>>>16),re(n,65535&e.adler)),e.adler=1}if(n.status===L)if(n.gzhead.extra){for(o=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>o&&(e.adler=s(e.adler,n.pending_buf,n.pending-o,o)),ee(e),o=n.pending,n.pending!==n.pending_buf_size));)ie(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>o&&(e.adler=s(e.adler,n.pending_buf,n.pending-o,o)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=U)}else n.status=U;if(n.status===U)if(n.gzhead.name){o=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>o&&(e.adler=s(e.adler,n.pending_buf,n.pending-o,o)),ee(e),o=n.pending,n.pending===n.pending_buf_size)){l=1;break}l=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,ie(n,l)}while(0!==l);n.gzhead.hcrc&&n.pending>o&&(e.adler=s(e.adler,n.pending_buf,n.pending-o,o)),0===l&&(n.gzindex=0,n.status=Z)}else n.status=Z;if(n.status===Z)if(n.gzhead.comment){o=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>o&&(e.adler=s(e.adler,n.pending_buf,n.pending-o,o)),ee(e),o=n.pending,n.pending===n.pending_buf_size)){l=1;break}l=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,ie(n,l)}while(0!==l);n.gzhead.hcrc&&n.pending>o&&(e.adler=s(e.adler,n.pending_buf,n.pending-o,o)),0===l&&(n.status=j)}else n.status=j;if(n.status===j&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&ee(e),n.pending+2<=n.pending_buf_size&&(ie(n,255&e.adler),ie(n,e.adler>>8&255),e.adler=0,n.status=G)):n.status=G),0!==n.pending){if(ee(e),0===e.avail_out)return n.last_flush=-1,p}else if(0===e.avail_in&&J(t)<=J(i)&&t!==f)return K(e,b);if(n.status===H&&0!==e.avail_in)return K(e,b);if(0!==e.avail_in||0!==n.lookahead||t!==u&&n.status!==H){var y=n.strategy===v?ce(n,t):n.strategy===x?he(n,t):r[n.level].func(n,t);if(y!==q&&y!==V||(n.status=H),y===Q||y===q)return 0===e.avail_out&&(n.last_flush=-1),p;if(y===W&&(t===h?a._tr_align(n):t!==d&&(a._tr_stored_block(n,0,0,!1),t===c&&(X(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),ee(e),0===e.avail_out))return n.last_flush=-1,p}return t!==f?p:n.wrap<=0?m:(2===n.wrap?(ie(n,255&e.adler),ie(n,e.adler>>8&255),ie(n,e.adler>>16&255),ie(n,e.adler>>24&255),ie(n,255&e.total_in),ie(n,e.total_in>>8&255),ie(n,e.total_in>>16&255),ie(n,e.total_in>>24&255)):(re(n,e.adler>>>16),re(n,65535&e.adler)),ee(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?p:m)}function ve(e){var t;return e&&e.state?(t=e.state.status)!==$&&t!==L&&t!==U&&t!==Z&&t!==j&&t!==G&&t!==H?K(e,_):(e.state=null,t===G?K(e,g):p):_}function xe(e,t){var i,r,a,s,l,u,h,c,f=t.length;if(!e||!e.state)return _;if(2===(s=(i=e.state).wrap)||1===s&&i.status!==$||i.lookahead)return _;for(1===s&&(e.adler=o(e.adler,t,f,0)),i.wrap=0,f>=i.w_size&&(0===s&&(X(i.head),i.strstart=0,i.block_start=0,i.insert=0),c=new n.Buf8(i.w_size),n.arraySet(c,t,f-i.w_size,i.w_size,0),t=c,f=i.w_size),l=e.avail_in,u=e.next_in,h=e.input,e.avail_in=f,e.next_in=0,e.input=t,oe(i);i.lookahead>=F;){r=i.strstart,a=i.lookahead-(F-1);do{i.ins_h=(i.ins_h<<i.hash_shift^i.window[r+F-1])&i.hash_mask,i.prev[r&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=r,r++}while(--a);i.strstart=r,i.lookahead=F-1,oe(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=F-1,i.match_available=0,e.next_in=u,e.input=h,e.avail_in=l,i.wrap=s,p}r=[new fe(0,0,0,0,se),new fe(4,4,8,4,le),new fe(4,5,16,8,le),new fe(4,6,32,32,le),new fe(4,4,16,16,ue),new fe(8,16,32,32,ue),new fe(8,16,128,128,ue),new fe(8,32,128,256,ue),new fe(32,128,258,1024,ue),new fe(32,258,258,4096,ue)],i.deflateInit=ye,i.deflateInit2=be,i.deflateReset=_e,i.deflateResetKeep=me,i.deflateSetHeader=ge,i.deflate=we,i.deflateEnd=ve,i.deflateSetDictionary=xe,i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":52,"./adler32":53,"./crc32":55,"./messages":60,"./trees":61}],57:[function(e,t,i){var r=30,n=12;t.exports=function(e,t){var i,a,o,s,l,u,h,c,f,d,p,m,_,g,b,y,w,v,x,E,k,S,A,I,M;i=e.state,a=e.next_in,I=e.input,o=a+(e.avail_in-5),s=e.next_out,M=e.output,l=s-(t-e.avail_out),u=s+(e.avail_out-257),h=i.dmax,c=i.wsize,f=i.whave,d=i.wnext,p=i.window,m=i.hold,_=i.bits,g=i.lencode,b=i.distcode,y=(1<<i.lenbits)-1,w=(1<<i.distbits)-1;e:do{_<15&&(m+=I[a++]<<_,_+=8,m+=I[a++]<<_,_+=8),v=g[m&y];t:for(;;){if(m>>>=x=v>>>24,_-=x,0==(x=v>>>16&255))M[s++]=65535&v;else{if(!(16&x)){if(64&x){if(32&x){i.mode=n;break e}e.msg="invalid literal/length code",i.mode=r;break e}v=g[(65535&v)+(m&(1<<x)-1)];continue t}for(E=65535&v,(x&=15)&&(_<x&&(m+=I[a++]<<_,_+=8),E+=m&(1<<x)-1,m>>>=x,_-=x),_<15&&(m+=I[a++]<<_,_+=8,m+=I[a++]<<_,_+=8),v=b[m&w];;){if(m>>>=x=v>>>24,_-=x,16&(x=v>>>16&255)){if(k=65535&v,_<(x&=15)&&(m+=I[a++]<<_,(_+=8)<x&&(m+=I[a++]<<_,_+=8)),(k+=m&(1<<x)-1)>h){e.msg="invalid distance too far back",i.mode=r;break e}if(m>>>=x,_-=x,k>(x=s-l)){if((x=k-x)>f&&i.sane){e.msg="invalid distance too far back",i.mode=r;break e}if(S=0,A=p,0===d){if(S+=c-x,x<E){E-=x;do{M[s++]=p[S++]}while(--x);S=s-k,A=M}}else if(d<x){if(S+=c+d-x,(x-=d)<E){E-=x;do{M[s++]=p[S++]}while(--x);if(S=0,d<E){E-=x=d;do{M[s++]=p[S++]}while(--x);S=s-k,A=M}}}else if(S+=d-x,x<E){E-=x;do{M[s++]=p[S++]}while(--x);S=s-k,A=M}for(;E>2;)M[s++]=A[S++],M[s++]=A[S++],M[s++]=A[S++],E-=3;E&&(M[s++]=A[S++],E>1&&(M[s++]=A[S++]))}else{S=s-k;do{M[s++]=M[S++],M[s++]=M[S++],M[s++]=M[S++],E-=3}while(E>2);E&&(M[s++]=M[S++],E>1&&(M[s++]=M[S++]))}break}if(64&x){e.msg="invalid distance code",i.mode=r;break e}v=b[(65535&v)+(m&(1<<x)-1)]}}break}}while(a<o&&s<u);a-=E=_>>3,m&=(1<<(_-=E<<3))-1,e.next_in=a,e.next_out=s,e.avail_in=a<o?o-a+5:5-(a-o),e.avail_out=s<u?u-s+257:257-(s-u),i.hold=m,i.bits=_}},{}],58:[function(e,t,i){var r=e("../utils/common"),n=e("./adler32"),a=e("./crc32"),o=e("./inffast"),s=e("./inftrees"),l=0,u=1,h=2,c=4,f=5,d=6,p=0,m=1,_=2,g=-2,b=-3,y=-4,w=-5,v=8,x=1,E=2,k=3,S=4,A=5,I=6,M=7,T=8,P=9,B=10,C=11,R=12,z=13,F=14,N=15,O=16,D=17,$=18,L=19,U=20,Z=21,j=22,G=23,H=24,Q=25,W=26,q=27,V=28,Y=29,K=30,J=31,X=852,ee=592,te=15;function ie(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function re(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function ne(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=x,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new r.Buf32(X),t.distcode=t.distdyn=new r.Buf32(ee),t.sane=1,t.back=-1,p):g}function ae(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,ne(e)):g}function oe(e,t){var i,r;return e&&e.state?(r=e.state,t<0?(i=0,t=-t):(i=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?g:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=i,r.wbits=t,ae(e))):g}function se(e,t){var i,r;return e?(r=new re,e.state=r,r.window=null,(i=oe(e,t))!==p&&(e.state=null),i):g}function le(e){return se(e,te)}var ue,he,ce=!0;function fe(e){if(ce){var t;for(ue=new r.Buf32(512),he=new r.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(s(u,e.lens,0,288,ue,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;s(h,e.lens,0,32,he,0,e.work,{bits:5}),ce=!1}e.lencode=ue,e.lenbits=9,e.distcode=he,e.distbits=5}function de(e,t,i,n){var a,o=e.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new r.Buf8(o.wsize)),n>=o.wsize?(r.arraySet(o.window,t,i-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):((a=o.wsize-o.wnext)>n&&(a=n),r.arraySet(o.window,t,i-n,a,o.wnext),(n-=a)?(r.arraySet(o.window,t,i-n,n,0),o.wnext=n,o.whave=o.wsize):(o.wnext+=a,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=a))),0}function pe(e,t){var i,X,ee,te,re,ne,ae,oe,se,le,ue,he,ce,pe,me,_e,ge,be,ye,we,ve,xe,Ee,ke,Se=0,Ae=new r.Buf8(4),Ie=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return g;(i=e.state).mode===R&&(i.mode=z),re=e.next_out,ee=e.output,ae=e.avail_out,te=e.next_in,X=e.input,ne=e.avail_in,oe=i.hold,se=i.bits,le=ne,ue=ae,xe=p;e:for(;;)switch(i.mode){case x:if(0===i.wrap){i.mode=z;break}for(;se<16;){if(0===ne)break e;ne--,oe+=X[te++]<<se,se+=8}if(2&i.wrap&&35615===oe){i.check=0,Ae[0]=255&oe,Ae[1]=oe>>>8&255,i.check=a(i.check,Ae,2,0),oe=0,se=0,i.mode=E;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&oe)<<8)+(oe>>8))%31){e.msg="incorrect header check",i.mode=K;break}if((15&oe)!==v){e.msg="unknown compression method",i.mode=K;break}if(se-=4,ve=8+(15&(oe>>>=4)),0===i.wbits)i.wbits=ve;else if(ve>i.wbits){e.msg="invalid window size",i.mode=K;break}i.dmax=1<<ve,e.adler=i.check=1,i.mode=512&oe?B:R,oe=0,se=0;break;case E:for(;se<16;){if(0===ne)break e;ne--,oe+=X[te++]<<se,se+=8}if(i.flags=oe,(255&i.flags)!==v){e.msg="unknown compression method",i.mode=K;break}if(57344&i.flags){e.msg="unknown header flags set",i.mode=K;break}i.head&&(i.head.text=oe>>8&1),512&i.flags&&(Ae[0]=255&oe,Ae[1]=oe>>>8&255,i.check=a(i.check,Ae,2,0)),oe=0,se=0,i.mode=k;case k:for(;se<32;){if(0===ne)break e;ne--,oe+=X[te++]<<se,se+=8}i.head&&(i.head.time=oe),512&i.flags&&(Ae[0]=255&oe,Ae[1]=oe>>>8&255,Ae[2]=oe>>>16&255,Ae[3]=oe>>>24&255,i.check=a(i.check,Ae,4,0)),oe=0,se=0,i.mode=S;case S:for(;se<16;){if(0===ne)break e;ne--,oe+=X[te++]<<se,se+=8}i.head&&(i.head.xflags=255&oe,i.head.os=oe>>8),512&i.flags&&(Ae[0]=255&oe,Ae[1]=oe>>>8&255,i.check=a(i.check,Ae,2,0)),oe=0,se=0,i.mode=A;case A:if(1024&i.flags){for(;se<16;){if(0===ne)break e;ne--,oe+=X[te++]<<se,se+=8}i.length=oe,i.head&&(i.head.extra_len=oe),512&i.flags&&(Ae[0]=255&oe,Ae[1]=oe>>>8&255,i.check=a(i.check,Ae,2,0)),oe=0,se=0}else i.head&&(i.head.extra=null);i.mode=I;case I:if(1024&i.flags&&((he=i.length)>ne&&(he=ne),he&&(i.head&&(ve=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),r.arraySet(i.head.extra,X,te,he,ve)),512&i.flags&&(i.check=a(i.check,X,he,te)),ne-=he,te+=he,i.length-=he),i.length))break e;i.length=0,i.mode=M;case M:if(2048&i.flags){if(0===ne)break e;he=0;do{ve=X[te+he++],i.head&&ve&&i.length<65536&&(i.head.name+=String.fromCharCode(ve))}while(ve&&he<ne);if(512&i.flags&&(i.check=a(i.check,X,he,te)),ne-=he,te+=he,ve)break e}else i.head&&(i.head.name=null);i.length=0,i.mode=T;case T:if(4096&i.flags){if(0===ne)break e;he=0;do{ve=X[te+he++],i.head&&ve&&i.length<65536&&(i.head.comment+=String.fromCharCode(ve))}while(ve&&he<ne);if(512&i.flags&&(i.check=a(i.check,X,he,te)),ne-=he,te+=he,ve)break e}else i.head&&(i.head.comment=null);i.mode=P;case P:if(512&i.flags){for(;se<16;){if(0===ne)break e;ne--,oe+=X[te++]<<se,se+=8}if(oe!==(65535&i.check)){e.msg="header crc mismatch",i.mode=K;break}oe=0,se=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=R;break;case B:for(;se<32;){if(0===ne)break e;ne--,oe+=X[te++]<<se,se+=8}e.adler=i.check=ie(oe),oe=0,se=0,i.mode=C;case C:if(0===i.havedict)return e.next_out=re,e.avail_out=ae,e.next_in=te,e.avail_in=ne,i.hold=oe,i.bits=se,_;e.adler=i.check=1,i.mode=R;case R:if(t===f||t===d)break e;case z:if(i.last){oe>>>=7&se,se-=7&se,i.mode=q;break}for(;se<3;){if(0===ne)break e;ne--,oe+=X[te++]<<se,se+=8}switch(i.last=1&oe,se-=1,3&(oe>>>=1)){case 0:i.mode=F;break;case 1:if(fe(i),i.mode=U,t===d){oe>>>=2,se-=2;break e}break;case 2:i.mode=D;break;case 3:e.msg="invalid block type",i.mode=K}oe>>>=2,se-=2;break;case F:for(oe>>>=7&se,se-=7&se;se<32;){if(0===ne)break e;ne--,oe+=X[te++]<<se,se+=8}if((65535&oe)!=(oe>>>16^65535)){e.msg="invalid stored block lengths",i.mode=K;break}if(i.length=65535&oe,oe=0,se=0,i.mode=N,t===d)break e;case N:i.mode=O;case O:if(he=i.length){if(he>ne&&(he=ne),he>ae&&(he=ae),0===he)break e;r.arraySet(ee,X,te,he,re),ne-=he,te+=he,ae-=he,re+=he,i.length-=he;break}i.mode=R;break;case D:for(;se<14;){if(0===ne)break e;ne--,oe+=X[te++]<<se,se+=8}if(i.nlen=257+(31&oe),oe>>>=5,se-=5,i.ndist=1+(31&oe),oe>>>=5,se-=5,i.ncode=4+(15&oe),oe>>>=4,se-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=K;break}i.have=0,i.mode=$;case $:for(;i.have<i.ncode;){for(;se<3;){if(0===ne)break e;ne--,oe+=X[te++]<<se,se+=8}i.lens[Ie[i.have++]]=7&oe,oe>>>=3,se-=3}for(;i.have<19;)i.lens[Ie[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,Ee={bits:i.lenbits},xe=s(l,i.lens,0,19,i.lencode,0,i.work,Ee),i.lenbits=Ee.bits,xe){e.msg="invalid code lengths set",i.mode=K;break}i.have=0,i.mode=L;case L:for(;i.have<i.nlen+i.ndist;){for(;_e=(Se=i.lencode[oe&(1<<i.lenbits)-1])>>>16&255,ge=65535&Se,!((me=Se>>>24)<=se);){if(0===ne)break e;ne--,oe+=X[te++]<<se,se+=8}if(ge<16)oe>>>=me,se-=me,i.lens[i.have++]=ge;else{if(16===ge){for(ke=me+2;se<ke;){if(0===ne)break e;ne--,oe+=X[te++]<<se,se+=8}if(oe>>>=me,se-=me,0===i.have){e.msg="invalid bit length repeat",i.mode=K;break}ve=i.lens[i.have-1],he=3+(3&oe),oe>>>=2,se-=2}else if(17===ge){for(ke=me+3;se<ke;){if(0===ne)break e;ne--,oe+=X[te++]<<se,se+=8}se-=me,ve=0,he=3+(7&(oe>>>=me)),oe>>>=3,se-=3}else{for(ke=me+7;se<ke;){if(0===ne)break e;ne--,oe+=X[te++]<<se,se+=8}se-=me,ve=0,he=11+(127&(oe>>>=me)),oe>>>=7,se-=7}if(i.have+he>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=K;break}for(;he--;)i.lens[i.have++]=ve}}if(i.mode===K)break;if(0===i.lens[256]){e.msg="invalid code -- missing end-of-block",i.mode=K;break}if(i.lenbits=9,Ee={bits:i.lenbits},xe=s(u,i.lens,0,i.nlen,i.lencode,0,i.work,Ee),i.lenbits=Ee.bits,xe){e.msg="invalid literal/lengths set",i.mode=K;break}if(i.distbits=6,i.distcode=i.distdyn,Ee={bits:i.distbits},xe=s(h,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,Ee),i.distbits=Ee.bits,xe){e.msg="invalid distances set",i.mode=K;break}if(i.mode=U,t===d)break e;case U:i.mode=Z;case Z:if(ne>=6&&ae>=258){e.next_out=re,e.avail_out=ae,e.next_in=te,e.avail_in=ne,i.hold=oe,i.bits=se,o(e,ue),re=e.next_out,ee=e.output,ae=e.avail_out,te=e.next_in,X=e.input,ne=e.avail_in,oe=i.hold,se=i.bits,i.mode===R&&(i.back=-1);break}for(i.back=0;_e=(Se=i.lencode[oe&(1<<i.lenbits)-1])>>>16&255,ge=65535&Se,!((me=Se>>>24)<=se);){if(0===ne)break e;ne--,oe+=X[te++]<<se,se+=8}if(_e&&!(240&_e)){for(be=me,ye=_e,we=ge;_e=(Se=i.lencode[we+((oe&(1<<be+ye)-1)>>be)])>>>16&255,ge=65535&Se,!(be+(me=Se>>>24)<=se);){if(0===ne)break e;ne--,oe+=X[te++]<<se,se+=8}oe>>>=be,se-=be,i.back+=be}if(oe>>>=me,se-=me,i.back+=me,i.length=ge,0===_e){i.mode=W;break}if(32&_e){i.back=-1,i.mode=R;break}if(64&_e){e.msg="invalid literal/length code",i.mode=K;break}i.extra=15&_e,i.mode=j;case j:if(i.extra){for(ke=i.extra;se<ke;){if(0===ne)break e;ne--,oe+=X[te++]<<se,se+=8}i.length+=oe&(1<<i.extra)-1,oe>>>=i.extra,se-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=G;case G:for(;_e=(Se=i.distcode[oe&(1<<i.distbits)-1])>>>16&255,ge=65535&Se,!((me=Se>>>24)<=se);){if(0===ne)break e;ne--,oe+=X[te++]<<se,se+=8}if(!(240&_e)){for(be=me,ye=_e,we=ge;_e=(Se=i.distcode[we+((oe&(1<<be+ye)-1)>>be)])>>>16&255,ge=65535&Se,!(be+(me=Se>>>24)<=se);){if(0===ne)break e;ne--,oe+=X[te++]<<se,se+=8}oe>>>=be,se-=be,i.back+=be}if(oe>>>=me,se-=me,i.back+=me,64&_e){e.msg="invalid distance code",i.mode=K;break}i.offset=ge,i.extra=15&_e,i.mode=H;case H:if(i.extra){for(ke=i.extra;se<ke;){if(0===ne)break e;ne--,oe+=X[te++]<<se,se+=8}i.offset+=oe&(1<<i.extra)-1,oe>>>=i.extra,se-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=K;break}i.mode=Q;case Q:if(0===ae)break e;if(he=ue-ae,i.offset>he){if((he=i.offset-he)>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=K;break}he>i.wnext?(he-=i.wnext,ce=i.wsize-he):ce=i.wnext-he,he>i.length&&(he=i.length),pe=i.window}else pe=ee,ce=re-i.offset,he=i.length;he>ae&&(he=ae),ae-=he,i.length-=he;do{ee[re++]=pe[ce++]}while(--he);0===i.length&&(i.mode=Z);break;case W:if(0===ae)break e;ee[re++]=i.length,ae--,i.mode=Z;break;case q:if(i.wrap){for(;se<32;){if(0===ne)break e;ne--,oe|=X[te++]<<se,se+=8}if(ue-=ae,e.total_out+=ue,i.total+=ue,ue&&(e.adler=i.check=i.flags?a(i.check,ee,ue,re-ue):n(i.check,ee,ue,re-ue)),ue=ae,(i.flags?oe:ie(oe))!==i.check){e.msg="incorrect data check",i.mode=K;break}oe=0,se=0}i.mode=V;case V:if(i.wrap&&i.flags){for(;se<32;){if(0===ne)break e;ne--,oe+=X[te++]<<se,se+=8}if(oe!==(4294967295&i.total)){e.msg="incorrect length check",i.mode=K;break}oe=0,se=0}i.mode=Y;case Y:xe=m;break e;case K:xe=b;break e;case J:return y;default:return g}return e.next_out=re,e.avail_out=ae,e.next_in=te,e.avail_in=ne,i.hold=oe,i.bits=se,(i.wsize||ue!==e.avail_out&&i.mode<K&&(i.mode<q||t!==c))&&de(e,e.output,e.next_out,ue-e.avail_out),le-=e.avail_in,ue-=e.avail_out,e.total_in+=le,e.total_out+=ue,i.total+=ue,i.wrap&&ue&&(e.adler=i.check=i.flags?a(i.check,ee,ue,e.next_out-ue):n(i.check,ee,ue,e.next_out-ue)),e.data_type=i.bits+(i.last?64:0)+(i.mode===R?128:0)+(i.mode===U||i.mode===N?256:0),(0===le&&0===ue||t===c)&&xe===p&&(xe=w),xe}function me(e){if(!e||!e.state)return g;var t=e.state;return t.window&&(t.window=null),e.state=null,p}function _e(e,t){var i;return e&&e.state&&2&(i=e.state).wrap?(i.head=t,t.done=!1,p):g}function ge(e,t){var i,r=t.length;return e&&e.state?0!==(i=e.state).wrap&&i.mode!==C?g:i.mode===C&&n(1,t,r,0)!==i.check?b:de(e,t,r,r)?(i.mode=J,y):(i.havedict=1,p):g}i.inflateReset=ae,i.inflateReset2=oe,i.inflateResetKeep=ne,i.inflateInit=le,i.inflateInit2=se,i.inflate=pe,i.inflateEnd=me,i.inflateGetHeader=_e,i.inflateSetDictionary=ge,i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":52,"./adler32":53,"./crc32":55,"./inffast":57,"./inftrees":59}],59:[function(e,t,i){var r=e("../utils/common"),n=15,a=852,o=592,s=0,l=1,u=2,h=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],c=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],f=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],d=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];t.exports=function(e,t,i,p,m,_,g,b){var y,w,v,x,E,k,S,A,I,M=b.bits,T=0,P=0,B=0,C=0,R=0,z=0,F=0,N=0,O=0,D=0,$=null,L=0,U=new r.Buf16(n+1),Z=new r.Buf16(n+1),j=null,G=0;for(T=0;T<=n;T++)U[T]=0;for(P=0;P<p;P++)U[t[i+P]]++;for(R=M,C=n;C>=1&&0===U[C];C--);if(R>C&&(R=C),0===C)return m[_++]=20971520,m[_++]=20971520,b.bits=1,0;for(B=1;B<C&&0===U[B];B++);for(R<B&&(R=B),N=1,T=1;T<=n;T++)if(N<<=1,(N-=U[T])<0)return-1;if(N>0&&(e===s||1!==C))return-1;for(Z[1]=0,T=1;T<n;T++)Z[T+1]=Z[T]+U[T];for(P=0;P<p;P++)0!==t[i+P]&&(g[Z[t[i+P]]++]=P);if(e===s?($=j=g,k=19):e===l?($=h,L-=257,j=c,G-=257,k=256):($=f,j=d,k=-1),D=0,P=0,T=B,E=_,z=R,F=0,v=-1,x=(O=1<<R)-1,e===l&&O>a||e===u&&O>o)return 1;for(;;){S=T-F,g[P]<k?(A=0,I=g[P]):g[P]>k?(A=j[G+g[P]],I=$[L+g[P]]):(A=96,I=0),y=1<<T-F,B=w=1<<z;do{m[E+(D>>F)+(w-=y)]=S<<24|A<<16|I}while(0!==w);for(y=1<<T-1;D&y;)y>>=1;if(0!==y?(D&=y-1,D+=y):D=0,P++,0==--U[T]){if(T===C)break;T=t[i+g[P]]}if(T>R&&(D&x)!==v){for(0===F&&(F=R),E+=B,N=1<<(z=T-F);z+F<C&&!((N-=U[z+F])<=0);)z++,N<<=1;if(O+=1<<z,e===l&&O>a||e===u&&O>o)return 1;m[v=D&x]=R<<24|z<<16|E-_}}return 0!==D&&(m[E+D]=T-F<<24|64<<16),b.bits=R,0}},{"../utils/common":52}],60:[function(e,t,i){t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],61:[function(e,t,i){var r=e("../utils/common"),n=4,a=0,o=1,s=2;function l(e){for(var t=e.length;--t>=0;)e[t]=0}var u=0,h=1,c=2,f=3,d=258,p=29,m=256,_=m+1+p,g=30,b=19,y=2*_+1,w=15,v=16,x=7,E=256,k=16,S=17,A=18,I=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],M=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],T=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],P=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],B=512,C=new Array(2*(_+2));l(C);var R=new Array(2*g);l(R);var z=new Array(B);l(z);var F=new Array(d-f+1);l(F);var N=new Array(p);l(N);var O,D,$,L=new Array(g);function U(e,t,i,r,n){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=r,this.max_length=n,this.has_stree=e&&e.length}function Z(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function j(e){return e<256?z[e]:z[256+(e>>>7)]}function G(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function H(e,t,i){e.bi_valid>v-i?(e.bi_buf|=t<<e.bi_valid&65535,G(e,e.bi_buf),e.bi_buf=t>>v-e.bi_valid,e.bi_valid+=i-v):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=i)}function Q(e,t,i){H(e,i[2*t],i[2*t+1])}function W(e,t){var i=0;do{i|=1&e,e>>>=1,i<<=1}while(--t>0);return i>>>1}function q(e){16===e.bi_valid?(G(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}function V(e,t){var i,r,n,a,o,s,l=t.dyn_tree,u=t.max_code,h=t.stat_desc.static_tree,c=t.stat_desc.has_stree,f=t.stat_desc.extra_bits,d=t.stat_desc.extra_base,p=t.stat_desc.max_length,m=0;for(a=0;a<=w;a++)e.bl_count[a]=0;for(l[2*e.heap[e.heap_max]+1]=0,i=e.heap_max+1;i<y;i++)(a=l[2*l[2*(r=e.heap[i])+1]+1]+1)>p&&(a=p,m++),l[2*r+1]=a,r>u||(e.bl_count[a]++,o=0,r>=d&&(o=f[r-d]),s=l[2*r],e.opt_len+=s*(a+o),c&&(e.static_len+=s*(h[2*r+1]+o)));if(0!==m){do{for(a=p-1;0===e.bl_count[a];)a--;e.bl_count[a]--,e.bl_count[a+1]+=2,e.bl_count[p]--,m-=2}while(m>0);for(a=p;0!==a;a--)for(r=e.bl_count[a];0!==r;)(n=e.heap[--i])>u||(l[2*n+1]!==a&&(e.opt_len+=(a-l[2*n+1])*l[2*n],l[2*n+1]=a),r--)}}function Y(e,t,i){var r,n,a=new Array(w+1),o=0;for(r=1;r<=w;r++)a[r]=o=o+i[r-1]<<1;for(n=0;n<=t;n++){var s=e[2*n+1];0!==s&&(e[2*n]=W(a[s]++,s))}}function K(){var e,t,i,r,n,a=new Array(w+1);for(i=0,r=0;r<p-1;r++)for(N[r]=i,e=0;e<1<<I[r];e++)F[i++]=r;for(F[i-1]=r,n=0,r=0;r<16;r++)for(L[r]=n,e=0;e<1<<M[r];e++)z[n++]=r;for(n>>=7;r<g;r++)for(L[r]=n<<7,e=0;e<1<<M[r]-7;e++)z[256+n++]=r;for(t=0;t<=w;t++)a[t]=0;for(e=0;e<=143;)C[2*e+1]=8,e++,a[8]++;for(;e<=255;)C[2*e+1]=9,e++,a[9]++;for(;e<=279;)C[2*e+1]=7,e++,a[7]++;for(;e<=287;)C[2*e+1]=8,e++,a[8]++;for(Y(C,_+1,a),e=0;e<g;e++)R[2*e+1]=5,R[2*e]=W(e,5);O=new U(C,I,m+1,_,w),D=new U(R,M,0,g,w),$=new U(new Array(0),T,0,b,x)}function J(e){var t;for(t=0;t<_;t++)e.dyn_ltree[2*t]=0;for(t=0;t<g;t++)e.dyn_dtree[2*t]=0;for(t=0;t<b;t++)e.bl_tree[2*t]=0;e.dyn_ltree[2*E]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function X(e){e.bi_valid>8?G(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function ee(e,t,i,n){X(e),G(e,i),G(e,~i),r.arraySet(e.pending_buf,e.window,t,i,e.pending),e.pending+=i}function te(e,t,i,r){var n=2*t,a=2*i;return e[n]<e[a]||e[n]===e[a]&&r[t]<=r[i]}function ie(e,t,i){for(var r=e.heap[i],n=i<<1;n<=e.heap_len&&(n<e.heap_len&&te(t,e.heap[n+1],e.heap[n],e.depth)&&n++,!te(t,r,e.heap[n],e.depth));)e.heap[i]=e.heap[n],i=n,n<<=1;e.heap[i]=r}function re(e,t,i){var r,n,a,o,s=0;if(0!==e.last_lit)do{r=e.pending_buf[e.d_buf+2*s]<<8|e.pending_buf[e.d_buf+2*s+1],n=e.pending_buf[e.l_buf+s],s++,0===r?Q(e,n,t):(Q(e,(a=F[n])+m+1,t),0!==(o=I[a])&&H(e,n-=N[a],o),Q(e,a=j(--r),i),0!==(o=M[a])&&H(e,r-=L[a],o))}while(s<e.last_lit);Q(e,E,t)}function ne(e,t){var i,r,n,a=t.dyn_tree,o=t.stat_desc.static_tree,s=t.stat_desc.has_stree,l=t.stat_desc.elems,u=-1;for(e.heap_len=0,e.heap_max=y,i=0;i<l;i++)0!==a[2*i]?(e.heap[++e.heap_len]=u=i,e.depth[i]=0):a[2*i+1]=0;for(;e.heap_len<2;)a[2*(n=e.heap[++e.heap_len]=u<2?++u:0)]=1,e.depth[n]=0,e.opt_len--,s&&(e.static_len-=o[2*n+1]);for(t.max_code=u,i=e.heap_len>>1;i>=1;i--)ie(e,a,i);n=l;do{i=e.heap[1],e.heap[1]=e.heap[e.heap_len--],ie(e,a,1),r=e.heap[1],e.heap[--e.heap_max]=i,e.heap[--e.heap_max]=r,a[2*n]=a[2*i]+a[2*r],e.depth[n]=(e.depth[i]>=e.depth[r]?e.depth[i]:e.depth[r])+1,a[2*i+1]=a[2*r+1]=n,e.heap[1]=n++,ie(e,a,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],V(e,t),Y(a,u,e.bl_count)}function ae(e,t,i){var r,n,a=-1,o=t[1],s=0,l=7,u=4;for(0===o&&(l=138,u=3),t[2*(i+1)+1]=65535,r=0;r<=i;r++)n=o,o=t[2*(r+1)+1],++s<l&&n===o||(s<u?e.bl_tree[2*n]+=s:0!==n?(n!==a&&e.bl_tree[2*n]++,e.bl_tree[2*k]++):s<=10?e.bl_tree[2*S]++:e.bl_tree[2*A]++,s=0,a=n,0===o?(l=138,u=3):n===o?(l=6,u=3):(l=7,u=4))}function oe(e,t,i){var r,n,a=-1,o=t[1],s=0,l=7,u=4;for(0===o&&(l=138,u=3),r=0;r<=i;r++)if(n=o,o=t[2*(r+1)+1],!(++s<l&&n===o)){if(s<u)do{Q(e,n,e.bl_tree)}while(0!=--s);else 0!==n?(n!==a&&(Q(e,n,e.bl_tree),s--),Q(e,k,e.bl_tree),H(e,s-3,2)):s<=10?(Q(e,S,e.bl_tree),H(e,s-3,3)):(Q(e,A,e.bl_tree),H(e,s-11,7));s=0,a=n,0===o?(l=138,u=3):n===o?(l=6,u=3):(l=7,u=4)}}function se(e){var t;for(ae(e,e.dyn_ltree,e.l_desc.max_code),ae(e,e.dyn_dtree,e.d_desc.max_code),ne(e,e.bl_desc),t=b-1;t>=3&&0===e.bl_tree[2*P[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}function le(e,t,i,r){var n;for(H(e,t-257,5),H(e,i-1,5),H(e,r-4,4),n=0;n<r;n++)H(e,e.bl_tree[2*P[n]+1],3);oe(e,e.dyn_ltree,t-1),oe(e,e.dyn_dtree,i-1)}function ue(e){var t,i=4093624447;for(t=0;t<=31;t++,i>>>=1)if(1&i&&0!==e.dyn_ltree[2*t])return a;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return o;for(t=32;t<m;t++)if(0!==e.dyn_ltree[2*t])return o;return a}l(L);var he=!1;function ce(e){he||(K(),he=!0),e.l_desc=new Z(e.dyn_ltree,O),e.d_desc=new Z(e.dyn_dtree,D),e.bl_desc=new Z(e.bl_tree,$),e.bi_buf=0,e.bi_valid=0,J(e)}function fe(e,t,i,r){H(e,(u<<1)+(r?1:0),3),ee(e,t,i)}function de(e){H(e,h<<1,3),Q(e,E,C),q(e)}function pe(e,t,i,r){var a,o,l=0;e.level>0?(e.strm.data_type===s&&(e.strm.data_type=ue(e)),ne(e,e.l_desc),ne(e,e.d_desc),l=se(e),a=e.opt_len+3+7>>>3,(o=e.static_len+3+7>>>3)<=a&&(a=o)):a=o=i+5,i+4<=a&&-1!==t?fe(e,t,i,r):e.strategy===n||o===a?(H(e,(h<<1)+(r?1:0),3),re(e,C,R)):(H(e,(c<<1)+(r?1:0),3),le(e,e.l_desc.max_code+1,e.d_desc.max_code+1,l+1),re(e,e.dyn_ltree,e.dyn_dtree)),J(e),r&&X(e)}function me(e,t,i){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&i,e.last_lit++,0===t?e.dyn_ltree[2*i]++:(e.matches++,t--,e.dyn_ltree[2*(F[i]+m+1)]++,e.dyn_dtree[2*j(t)]++),e.last_lit===e.lit_bufsize-1}i._tr_init=ce,i._tr_stored_block=fe,i._tr_flush_block=pe,i._tr_tally=me,i._tr_align=de},{"../utils/common":52}],62:[function(e,t,i){function r(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}t.exports=r},{}],63:[function(e,t,i){var r,n,a=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function l(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 u(e){if(n===clearTimeout)return clearTimeout(e);if((n===s||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{return n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:o}catch(e){r=o}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(e){n=s}}();var h,c=[],f=!1,d=-1;function p(){f&&h&&(f=!1,h.length?c=h.concat(c):d=-1,c.length&&m())}function m(){if(!f){var e=l(p);f=!0;for(var t=c.length;t;){for(h=c,c=[];++d<t;)h&&h[d].run();d=-1,t=c.length}h=null,f=!1,u(e)}}function _(e,t){this.fun=e,this.array=t}function g(){}a.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)t[i-1]=arguments[i];c.push(new _(e,t)),1!==c.length||f||l(m)},_.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=g,a.addListener=g,a.once=g,a.off=g,a.removeListener=g,a.removeAllListeners=g,a.emit=g,a.prependListener=g,a.prependOnceListener=g,a.listeners=function(e){return[]},a.binding=function(e){throw new Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(e){throw new Error("process.chdir is not supported")},a.umask=function(){return 0}},{}],64:[function(e,t,i){
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
var r=e("buffer"),n=r.Buffer;function a(e,t){for(var i in e)t[i]=e[i]}function o(e,t,i){return n(e,t,i)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?t.exports=r:(a(r,i),i.Buffer=o),o.prototype=Object.create(n.prototype),a(n,o),o.from=function(e,t,i){if("number"==typeof e)throw new TypeError("Argument must not be a number");return n(e,t,i)},o.alloc=function(e,t,i){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=n(e);return void 0!==t?"string"==typeof i?r.fill(t,i):r.fill(t):r.fill(0),r},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},{buffer:32}],65:[function(e,t,i){t.exports=n;var r=e("events").EventEmitter;function n(){r.call(this)}e("inherits")(n,r),n.Readable=e("readable-stream/lib/_stream_readable.js"),n.Writable=e("readable-stream/lib/_stream_writable.js"),n.Duplex=e("readable-stream/lib/_stream_duplex.js"),n.Transform=e("readable-stream/lib/_stream_transform.js"),n.PassThrough=e("readable-stream/lib/_stream_passthrough.js"),n.finished=e("readable-stream/lib/internal/streams/end-of-stream.js"),n.pipeline=e("readable-stream/lib/internal/streams/pipeline.js"),n.Stream=n,n.prototype.pipe=function(e,t){var i=this;function n(t){e.writable&&!1===e.write(t)&&i.pause&&i.pause()}function a(){i.readable&&i.resume&&i.resume()}i.on("data",n),e.on("drain",a),e._isStdio||t&&!1===t.end||(i.on("end",s),i.on("close",l));var o=!1;function s(){o||(o=!0,e.end())}function l(){o||(o=!0,"function"==typeof e.destroy&&e.destroy())}function u(e){if(h(),0===r.listenerCount(this,"error"))throw e}function h(){i.removeListener("data",n),e.removeListener("drain",a),i.removeListener("end",s),i.removeListener("close",l),i.removeListener("error",u),e.removeListener("error",u),i.removeListener("end",h),i.removeListener("close",h),e.removeListener("close",h)}return i.on("error",u),e.on("error",u),i.on("end",h),i.on("close",h),e.on("close",h),e.emit("pipe",i),e}},{events:35,inherits:46,"readable-stream/lib/_stream_duplex.js":67,"readable-stream/lib/_stream_passthrough.js":68,"readable-stream/lib/_stream_readable.js":69,"readable-stream/lib/_stream_transform.js":70,"readable-stream/lib/_stream_writable.js":71,"readable-stream/lib/internal/streams/end-of-stream.js":75,"readable-stream/lib/internal/streams/pipeline.js":77}],66:[function(e,t,i){function r(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var n={};function a(e,t,i){function a(e,i,r){return"string"==typeof t?t:t(e,i,r)}i||(i=Error);var o=function(e){function t(t,i,r){return e.call(this,a(t,i,r))||this}return r(t,e),t}(i);o.prototype.name=i.name,o.prototype.code=e,n[e]=o}function o(e,t){if(Array.isArray(e)){var i=e.length;return e=e.map((function(e){return String(e)})),i>2?"one of ".concat(t," ").concat(e.slice(0,i-1).join(", "),", or ")+e[i-1]:2===i?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}function s(e,t,i){return e.substr(0,t.length)===t}function l(e,t,i){return(void 0===i||i>e.length)&&(i=e.length),e.substring(i-t.length,i)===t}function u(e,t,i){return"number"!=typeof i&&(i=0),!(i+t.length>e.length)&&-1!==e.indexOf(t,i)}a("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),a("ERR_INVALID_ARG_TYPE",(function(e,t,i){var r,n;if("string"==typeof t&&s(t,"not ")?(r="must not be",t=t.replace(/^not /,"")):r="must be",l(e," argument"))n="The ".concat(e," ").concat(r," ").concat(o(t,"type"));else{var a=u(e,".")?"property":"argument";n='The "'.concat(e,'" ').concat(a," ").concat(r," ").concat(o(t,"type"))}return n+=". Received type ".concat(typeof i)}),TypeError),a("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),a("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),a("ERR_STREAM_PREMATURE_CLOSE","Premature close"),a("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),a("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),a("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),a("ERR_STREAM_WRITE_AFTER_END","write after end"),a("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),a("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),a("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.codes=n},{}],67:[function(e,t,i){(function(i){(function(){var r=Object.keys||function(e){var t=[];for(var i in e)t.push(i);return t};t.exports=u;var n=e("./_stream_readable"),a=e("./_stream_writable");e("inherits")(u,n);for(var o=r(a.prototype),s=0;s<o.length;s++){var l=o[s];u.prototype[l]||(u.prototype[l]=a.prototype[l])}function u(e){if(!(this instanceof u))return new u(e);n.call(this,e),a.call(this,e),this.allowHalfOpen=!0,e&&(!1===e.readable&&(this.readable=!1),!1===e.writable&&(this.writable=!1),!1===e.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",h)))}function h(){this._writableState.ended||i.nextTick(c,this)}function c(e){e.end()}Object.defineProperty(u.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(u.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(u.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(u.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}})}).call(this)}).call(this,e("_process"))},{"./_stream_readable":69,"./_stream_writable":71,_process:63,inherits:46}],68:[function(e,t,i){t.exports=n;var r=e("./_stream_transform");function n(e){if(!(this instanceof n))return new n(e);r.call(this,e)}e("inherits")(n,r),n.prototype._transform=function(e,t,i){i(null,e)}},{"./_stream_transform":70,inherits:46}],69:[function(e,t,i){(function(i,r){(function(){var n;t.exports=M,M.ReadableState=I,e("events").EventEmitter;var a=function(e,t){return e.listeners(t).length},o=e("./internal/streams/stream"),s=e("buffer").Buffer,l=r.Uint8Array||function(){};function u(e){return s.from(e)}function h(e){return s.isBuffer(e)||e instanceof l}var c,f=e("util");c=f&&f.debuglog?f.debuglog("stream"):function(){};var d,p,m,_=e("./internal/streams/buffer_list"),g=e("./internal/streams/destroy"),b=e("./internal/streams/state").getHighWaterMark,y=e("../errors").codes,w=y.ERR_INVALID_ARG_TYPE,v=y.ERR_STREAM_PUSH_AFTER_EOF,x=y.ERR_METHOD_NOT_IMPLEMENTED,E=y.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;e("inherits")(M,o);var k=g.errorOrDestroy,S=["error","close","destroy","pause","resume"];function A(e,t,i){if("function"==typeof e.prependListener)return e.prependListener(t,i);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(i):e._events[t]=[i,e._events[t]]:e.on(t,i)}function I(t,i,r){n=n||e("./_stream_duplex"),t=t||{},"boolean"!=typeof r&&(r=i instanceof n),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=b(this,t,"readableHighWaterMark",r),this.buffer=new _,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(d||(d=e("string_decoder/").StringDecoder),this.decoder=new d(t.encoding),this.encoding=t.encoding)}function M(t){if(n=n||e("./_stream_duplex"),!(this instanceof M))return new M(t);var i=this instanceof n;this._readableState=new I(t,this,i),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),o.call(this)}function T(e,t,i,r,n){c("readableAddChunk",t);var a,o=e._readableState;if(null===t)o.reading=!1,F(e,o);else if(n||(a=B(o,t)),a)k(e,a);else if(o.objectMode||t&&t.length>0)if("string"==typeof t||o.objectMode||Object.getPrototypeOf(t)===s.prototype||(t=u(t)),r)o.endEmitted?k(e,new E):P(e,o,t,!0);else if(o.ended)k(e,new v);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!i?(t=o.decoder.write(t),o.objectMode||0!==t.length?P(e,o,t,!1):D(e,o)):P(e,o,t,!1)}else r||(o.reading=!1,D(e,o));return!o.ended&&(o.length<o.highWaterMark||0===o.length)}function P(e,t,i,r){t.flowing&&0===t.length&&!t.sync?(t.awaitDrain=0,e.emit("data",i)):(t.length+=t.objectMode?1:i.length,r?t.buffer.unshift(i):t.buffer.push(i),t.needReadable&&N(e)),D(e,t)}function B(e,t){var i;return h(t)||"string"==typeof t||void 0===t||e.objectMode||(i=new w("chunk",["string","Buffer","Uint8Array"],t)),i}Object.defineProperty(M.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),M.prototype.destroy=g.destroy,M.prototype._undestroy=g.undestroy,M.prototype._destroy=function(e,t){t(e)},M.prototype.push=function(e,t){var i,r=this._readableState;return r.objectMode?i=!0:"string"==typeof e&&((t=t||r.defaultEncoding)!==r.encoding&&(e=s.from(e,t),t=""),i=!0),T(this,e,t,!1,i)},M.prototype.unshift=function(e){return T(this,e,null,!0,!1)},M.prototype.isPaused=function(){return!1===this._readableState.flowing},M.prototype.setEncoding=function(t){d||(d=e("string_decoder/").StringDecoder);var i=new d(t);this._readableState.decoder=i,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,n="";null!==r;)n+=i.write(r.data),r=r.next;return this._readableState.buffer.clear(),""!==n&&this._readableState.buffer.push(n),this._readableState.length=n.length,this};var C=1073741824;function R(e){return e>=C?e=C:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function z(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=R(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function F(e,t){if(c("onEofChunk"),!t.ended){if(t.decoder){var i=t.decoder.end();i&&i.length&&(t.buffer.push(i),t.length+=t.objectMode?1:i.length)}t.ended=!0,t.sync?N(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,O(e)))}}function N(e){var t=e._readableState;c("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(c("emitReadable",t.flowing),t.emittedReadable=!0,i.nextTick(O,e))}function O(e){var t=e._readableState;c("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,H(e)}function D(e,t){t.readingMore||(t.readingMore=!0,i.nextTick($,e,t))}function $(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&0===t.length);){var i=t.length;if(c("maybeReadMore read 0"),e.read(0),i===t.length)break}t.readingMore=!1}function L(e){return function(){var t=e._readableState;c("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&a(e,"data")&&(t.flowing=!0,H(e))}}function U(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function Z(e){c("readable nexttick read 0"),e.read(0)}function j(e,t){t.resumeScheduled||(t.resumeScheduled=!0,i.nextTick(G,e,t))}function G(e,t){c("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),H(e),t.flowing&&!t.reading&&e.read(0)}function H(e){var t=e._readableState;for(c("flow",t.flowing);t.flowing&&null!==e.read(););}function Q(e,t){return 0===t.length?null:(t.objectMode?i=t.buffer.shift():!e||e>=t.length?(i=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):i=t.buffer.consume(e,t.decoder),i);var i}function W(e){var t=e._readableState;c("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,i.nextTick(q,t,e))}function q(e,t){if(c("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var i=t._writableState;(!i||i.autoDestroy&&i.finished)&&t.destroy()}}function V(e,t){for(var i=0,r=e.length;i<r;i++)if(e[i]===t)return i;return-1}M.prototype.read=function(e){c("read",e),e=parseInt(e,10);var t=this._readableState,i=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&((0!==t.highWaterMark?t.length>=t.highWaterMark:t.length>0)||t.ended))return c("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?W(this):N(this),null;if(0===(e=z(e,t))&&t.ended)return 0===t.length&&W(this),null;var r,n=t.needReadable;return c("need readable",n),(0===t.length||t.length-e<t.highWaterMark)&&c("length less than watermark",n=!0),t.ended||t.reading?c("reading or ended",n=!1):n&&(c("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=z(i,t))),null===(r=e>0?Q(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),i!==e&&t.ended&&W(this)),null!==r&&this.emit("data",r),r},M.prototype._read=function(e){k(this,new x("_read()"))},M.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,c("pipe count=%d opts=%j",n.pipesCount,t);var o=t&&!1===t.end||e===i.stdout||e===i.stderr?g:l;function s(e,t){c("onunpipe"),e===r&&t&&!1===t.hasUnpiped&&(t.hasUnpiped=!0,f())}function l(){c("onend"),e.end()}n.endEmitted?i.nextTick(o):r.once("end",o),e.on("unpipe",s);var u=L(r);e.on("drain",u);var h=!1;function f(){c("cleanup"),e.removeListener("close",m),e.removeListener("finish",_),e.removeListener("drain",u),e.removeListener("error",p),e.removeListener("unpipe",s),r.removeListener("end",l),r.removeListener("end",g),r.removeListener("data",d),h=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||u()}function d(t){c("ondata");var i=e.write(t);c("dest.write",i),!1===i&&((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==V(n.pipes,e))&&!h&&(c("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function p(t){c("onerror",t),g(),e.removeListener("error",p),0===a(e,"error")&&k(e,t)}function m(){e.removeListener("finish",_),g()}function _(){c("onfinish"),e.removeListener("close",m),g()}function g(){c("unpipe"),r.unpipe(e)}return r.on("data",d),A(e,"error",p),e.once("close",m),e.once("finish",_),e.emit("pipe",r),n.flowing||(c("pipe resume"),r.resume()),e},M.prototype.unpipe=function(e){var t=this._readableState,i={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,i)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var a=0;a<n;a++)r[a].emit("unpipe",this,{hasUnpiped:!1});return this}var o=V(t.pipes,e);return-1===o||(t.pipes.splice(o,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,i)),this},M.prototype.on=function(e,t){var r=o.prototype.on.call(this,e,t),n=this._readableState;return"data"===e?(n.readableListening=this.listenerCount("readable")>0,!1!==n.flowing&&this.resume()):"readable"===e&&(n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,c("on readable",n.length,n.reading),n.length?N(this):n.reading||i.nextTick(Z,this))),r},M.prototype.addListener=M.prototype.on,M.prototype.removeListener=function(e,t){var r=o.prototype.removeListener.call(this,e,t);return"readable"===e&&i.nextTick(U,this),r},M.prototype.removeAllListeners=function(e){var t=o.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||i.nextTick(U,this),t},M.prototype.resume=function(){var e=this._readableState;return e.flowing||(c("resume"),e.flowing=!e.readableListening,j(this,e)),e.paused=!1,this},M.prototype.pause=function(){return c("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(c("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},M.prototype.wrap=function(e){var t=this,i=this._readableState,r=!1;for(var n in e.on("end",(function(){if(c("wrapped end"),i.decoder&&!i.ended){var e=i.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(n){c("wrapped data"),i.decoder&&(n=i.decoder.write(n)),i.objectMode&&null==n||(i.objectMode||n&&n.length)&&(t.push(n)||(r=!0,e.pause()))})),e)void 0===this[n]&&"function"==typeof e[n]&&(this[n]=function(t){return function(){return e[t].apply(e,arguments)}}(n));for(var a=0;a<S.length;a++)e.on(S[a],this.emit.bind(this,S[a]));return this._read=function(t){c("wrapped _read",t),r&&(r=!1,e.resume())},this},"function"==typeof Symbol&&(M.prototype[Symbol.asyncIterator]=function(){return void 0===p&&(p=e("./internal/streams/async_iterator")),p(this)}),Object.defineProperty(M.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(M.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(M.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),M._fromList=Q,Object.defineProperty(M.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(M.from=function(t,i){return void 0===m&&(m=e("./internal/streams/from")),m(M,t,i)})}).call(this)}).call(this,e("_process"),void 0!==commonjsGlobal?commonjsGlobal:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":66,"./_stream_duplex":67,"./internal/streams/async_iterator":72,"./internal/streams/buffer_list":73,"./internal/streams/destroy":74,"./internal/streams/from":76,"./internal/streams/state":78,"./internal/streams/stream":79,_process:63,buffer:32,events:35,inherits:46,"string_decoder/":80,util:29}],70:[function(e,t,i){t.exports=h;var r=e("../errors").codes,n=r.ERR_METHOD_NOT_IMPLEMENTED,a=r.ERR_MULTIPLE_CALLBACK,o=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=r.ERR_TRANSFORM_WITH_LENGTH_0,l=e("./_stream_duplex");function u(e,t){var i=this._transformState;i.transforming=!1;var r=i.writecb;if(null===r)return this.emit("error",new a);i.writechunk=null,i.writecb=null,null!=t&&this.push(t),r(e);var n=this._readableState;n.reading=!1,(n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}function h(e){if(!(this instanceof h))return new h(e);l.call(this,e),this._transformState={afterTransform:u.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",c)}function c(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?f(this,null,null):this._flush((function(t,i){f(e,t,i)}))}function f(e,t,i){if(t)return e.emit("error",t);if(null!=i&&e.push(i),e._writableState.length)throw new s;if(e._transformState.transforming)throw new o;return e.push(null)}e("inherits")(h,l),h.prototype.push=function(e,t){return this._transformState.needTransform=!1,l.prototype.push.call(this,e,t)},h.prototype._transform=function(e,t,i){i(new n("_transform()"))},h.prototype._write=function(e,t,i){var r=this._transformState;if(r.writecb=i,r.writechunk=e,r.writeencoding=t,!r.transforming){var n=this._readableState;(r.needTransform||n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}},h.prototype._read=function(e){var t=this._transformState;null===t.writechunk||t.transforming?t.needTransform=!0:(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform))},h.prototype._destroy=function(e,t){l.prototype._destroy.call(this,e,(function(e){t(e)}))}},{"../errors":66,"./_stream_duplex":67,inherits:46}],71:[function(e,t,i){(function(i,r){(function(){function n(e){var t=this;this.next=null,this.entry=null,this.finish=function(){G(t,e)}}var a;t.exports=I,I.WritableState=A;var o={deprecate:e("util-deprecate")},s=e("./internal/streams/stream"),l=e("buffer").Buffer,u=r.Uint8Array||function(){};function h(e){return l.from(e)}function c(e){return l.isBuffer(e)||e instanceof u}var f,d=e("./internal/streams/destroy"),p=e("./internal/streams/state").getHighWaterMark,m=e("../errors").codes,_=m.ERR_INVALID_ARG_TYPE,g=m.ERR_METHOD_NOT_IMPLEMENTED,b=m.ERR_MULTIPLE_CALLBACK,y=m.ERR_STREAM_CANNOT_PIPE,w=m.ERR_STREAM_DESTROYED,v=m.ERR_STREAM_NULL_VALUES,x=m.ERR_STREAM_WRITE_AFTER_END,E=m.ERR_UNKNOWN_ENCODING,k=d.errorOrDestroy;function S(){}function A(t,i,r){a=a||e("./_stream_duplex"),t=t||{},"boolean"!=typeof r&&(r=i instanceof a),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=p(this,t,"writableHighWaterMark",r),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var o=!1===t.decodeStrings;this.decodeStrings=!o,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){F(i,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new n(this)}function I(t){var i=this instanceof(a=a||e("./_stream_duplex"));if(!i&&!f.call(I,this))return new I(t);this._writableState=new A(t,this,i),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),s.call(this)}function M(e,t){var r=new x;k(e,r),i.nextTick(t,r)}function T(e,t,r,n){var a;return null===r?a=new v:"string"==typeof r||t.objectMode||(a=new _("chunk",["string","Buffer"],r)),!a||(k(e,a),i.nextTick(n,a),!1)}function P(e,t,i){return e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=l.from(t,i)),t}function B(e,t,i,r,n,a){if(!i){var o=P(t,r,n);r!==o&&(i=!0,n="buffer",r=o)}var s=t.objectMode?1:r.length;t.length+=s;var l=t.length<t.highWaterMark;if(l||(t.needDrain=!0),t.writing||t.corked){var u=t.lastBufferedRequest;t.lastBufferedRequest={chunk:r,encoding:n,isBuf:i,callback:a,next:null},u?u.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else C(e,t,!1,s,r,n,a);return l}function C(e,t,i,r,n,a,o){t.writelen=r,t.writecb=o,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new w("write")):i?e._writev(n,t.onwrite):e._write(n,a,t.onwrite),t.sync=!1}function R(e,t,r,n,a){--t.pendingcb,r?(i.nextTick(a,n),i.nextTick(Z,e,t),e._writableState.errorEmitted=!0,k(e,n)):(a(n),e._writableState.errorEmitted=!0,k(e,n),Z(e,t))}function z(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function F(e,t){var r=e._writableState,n=r.sync,a=r.writecb;if("function"!=typeof a)throw new b;if(z(r),t)R(e,r,n,t,a);else{var o=$(r)||e.destroyed;o||r.corked||r.bufferProcessing||!r.bufferedRequest||D(e,r),n?i.nextTick(N,e,r,o,a):N(e,r,o,a)}}function N(e,t,i,r){i||O(e,t),t.pendingcb--,r(),Z(e,t)}function O(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function D(e,t){t.bufferProcessing=!0;var i=t.bufferedRequest;if(e._writev&&i&&i.next){var r=t.bufferedRequestCount,a=new Array(r),o=t.corkedRequestsFree;o.entry=i;for(var s=0,l=!0;i;)a[s]=i,i.isBuf||(l=!1),i=i.next,s+=1;a.allBuffers=l,C(e,t,!0,t.length,a,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new n(t),t.bufferedRequestCount=0}else{for(;i;){var u=i.chunk,h=i.encoding,c=i.callback;if(C(e,t,!1,t.objectMode?1:u.length,u,h,c),i=i.next,t.bufferedRequestCount--,t.writing)break}null===i&&(t.lastBufferedRequest=null)}t.bufferedRequest=i,t.bufferProcessing=!1}function $(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function L(e,t){e._final((function(i){t.pendingcb--,i&&k(e,i),t.prefinished=!0,e.emit("prefinish"),Z(e,t)}))}function U(e,t){t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=!0,e.emit("prefinish")):(t.pendingcb++,t.finalCalled=!0,i.nextTick(L,e,t)))}function Z(e,t){var i=$(t);if(i&&(U(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var r=e._readableState;(!r||r.autoDestroy&&r.endEmitted)&&e.destroy()}return i}function j(e,t,r){t.ending=!0,Z(e,t),r&&(t.finished?i.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function G(e,t,i){var r=e.entry;for(e.entry=null;r;){var n=r.callback;t.pendingcb--,n(i),r=r.next}t.corkedRequestsFree.next=e}e("inherits")(I,s),A.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(A.prototype,"buffer",{get:o.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(f=Function.prototype[Symbol.hasInstance],Object.defineProperty(I,Symbol.hasInstance,{value:function(e){return!!f.call(this,e)||this===I&&e&&e._writableState instanceof A}})):f=function(e){return e instanceof this},I.prototype.pipe=function(){k(this,new y)},I.prototype.write=function(e,t,i){var r=this._writableState,n=!1,a=!r.objectMode&&c(e);return a&&!l.isBuffer(e)&&(e=h(e)),"function"==typeof t&&(i=t,t=null),a?t="buffer":t||(t=r.defaultEncoding),"function"!=typeof i&&(i=S),r.ending?M(this,i):(a||T(this,r,e,i))&&(r.pendingcb++,n=B(this,r,a,e,t,i)),n},I.prototype.cork=function(){this._writableState.corked++},I.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||D(this,e))},I.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new E(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(I.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(I.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),I.prototype._write=function(e,t,i){i(new g("_write()"))},I.prototype._writev=null,I.prototype.end=function(e,t,i){var r=this._writableState;return"function"==typeof e?(i=e,e=null,t=null):"function"==typeof t&&(i=t,t=null),null!=e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||j(this,r,i),this},Object.defineProperty(I.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(I.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),I.prototype.destroy=d.destroy,I.prototype._undestroy=d.undestroy,I.prototype._destroy=function(e,t){t(e)}}).call(this)}).call(this,e("_process"),void 0!==commonjsGlobal?commonjsGlobal:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":66,"./_stream_duplex":67,"./internal/streams/destroy":74,"./internal/streams/state":78,"./internal/streams/stream":79,_process:63,buffer:32,inherits:46,"util-deprecate":81}],72:[function(e,t,i){(function(i){(function(){var r;function n(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}var a=e("./end-of-stream"),o=Symbol("lastResolve"),s=Symbol("lastReject"),l=Symbol("error"),u=Symbol("ended"),h=Symbol("lastPromise"),c=Symbol("handlePromise"),f=Symbol("stream");function d(e,t){return{value:e,done:t}}function p(e){var t=e[o];if(null!==t){var i=e[f].read();null!==i&&(e[h]=null,e[o]=null,e[s]=null,t(d(i,!1)))}}function m(e){i.nextTick(p,e)}function _(e,t){return function(i,r){e.then((function(){t[u]?i(d(void 0,!0)):t[c](i,r)}),r)}}var g=Object.getPrototypeOf((function(){})),b=Object.setPrototypeOf((r={get stream(){return this[f]},next:function(){var e=this,t=this[l];if(null!==t)return Promise.reject(t);if(this[u])return Promise.resolve(d(void 0,!0));if(this[f].destroyed)return new Promise((function(t,r){i.nextTick((function(){e[l]?r(e[l]):t(d(void 0,!0))}))}));var r,n=this[h];if(n)r=new Promise(_(n,this));else{var a=this[f].read();if(null!==a)return Promise.resolve(d(a,!1));r=new Promise(this[c])}return this[h]=r,r}},n(r,Symbol.asyncIterator,(function(){return this})),n(r,"return",(function(){var e=this;return new Promise((function(t,i){e[f].destroy(null,(function(e){e?i(e):t(d(void 0,!0))}))}))})),r),g),y=function(e){var t,i=Object.create(b,(n(t={},f,{value:e,writable:!0}),n(t,o,{value:null,writable:!0}),n(t,s,{value:null,writable:!0}),n(t,l,{value:null,writable:!0}),n(t,u,{value:e._readableState.endEmitted,writable:!0}),n(t,c,{value:function(e,t){var r=i[f].read();r?(i[h]=null,i[o]=null,i[s]=null,e(d(r,!1))):(i[o]=e,i[s]=t)},writable:!0}),t));return i[h]=null,a(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=i[s];return null!==t&&(i[h]=null,i[o]=null,i[s]=null,t(e)),void(i[l]=e)}var r=i[o];null!==r&&(i[h]=null,i[o]=null,i[s]=null,r(d(void 0,!0))),i[u]=!0})),e.on("readable",m.bind(null,i)),i};t.exports=y}).call(this)}).call(this,e("_process"))},{"./end-of-stream":75,_process:63}],73:[function(e,t,i){function r(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,r)}return i}function n(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?r(Object(i),!0).forEach((function(t){a(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):r(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function a(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function l(e,t,i){return t&&s(e.prototype,t),e}var u=e("buffer").Buffer,h=e("util").inspect,c=h&&h.custom||"inspect";function f(e,t,i){u.prototype.copy.call(e,t,i)}t.exports=function(){function e(){o(this,e),this.head=null,this.tail=null,this.length=0}return l(e,[{key:"push",value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,i=""+t.data;t=t.next;)i+=e+t.data;return i}},{key:"concat",value:function(e){if(0===this.length)return u.alloc(0);for(var t=u.allocUnsafe(e>>>0),i=this.head,r=0;i;)f(i.data,t,r),r+=i.data.length,i=i.next;return t}},{key:"consume",value:function(e,t){var i;return e<this.head.data.length?(i=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):i=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),i}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(e){var t=this.head,i=1,r=t.data;for(e-=r.length;t=t.next;){var n=t.data,a=e>n.length?n.length:e;if(a===n.length?r+=n:r+=n.slice(0,e),0==(e-=a)){a===n.length?(++i,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=n.slice(a));break}++i}return this.length-=i,r}},{key:"_getBuffer",value:function(e){var t=u.allocUnsafe(e),i=this.head,r=1;for(i.data.copy(t),e-=i.data.length;i=i.next;){var n=i.data,a=e>n.length?n.length:e;if(n.copy(t,t.length-e,0,a),0==(e-=a)){a===n.length?(++r,i.next?this.head=i.next:this.head=this.tail=null):(this.head=i,i.data=n.slice(a));break}++r}return this.length-=r,t}},{key:c,value:function(e,t){return h(this,n({},t,{depth:0,customInspect:!1}))}}]),e}()},{buffer:32,util:29}],74:[function(e,t,i){(function(e){(function(){function i(t,i){var a=this,s=this._readableState&&this._readableState.destroyed,l=this._writableState&&this._writableState.destroyed;return s||l?(i?i(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,e.nextTick(o,this,t)):e.nextTick(o,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!i&&t?a._writableState?a._writableState.errorEmitted?e.nextTick(n,a):(a._writableState.errorEmitted=!0,e.nextTick(r,a,t)):e.nextTick(r,a,t):i?(e.nextTick(n,a),i(t)):e.nextTick(n,a)})),this)}function r(e,t){o(e,t),n(e)}function n(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function a(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function o(e,t){e.emit("error",t)}function s(e,t){var i=e._readableState,r=e._writableState;i&&i.autoDestroy||r&&r.autoDestroy?e.destroy(t):e.emit("error",t)}t.exports={destroy:i,undestroy:a,errorOrDestroy:s}}).call(this)}).call(this,e("_process"))},{_process:63}],75:[function(e,t,i){var r=e("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;function n(e){var t=!1;return function(){if(!t){t=!0;for(var i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];e.apply(this,r)}}}function a(){}function o(e){return e.setHeader&&"function"==typeof e.abort}function s(e,t,i){if("function"==typeof t)return s(e,null,t);t||(t={}),i=n(i||a);var l=t.readable||!1!==t.readable&&e.readable,u=t.writable||!1!==t.writable&&e.writable,h=function(){e.writable||f()},c=e._writableState&&e._writableState.finished,f=function(){u=!1,c=!0,l||i.call(e)},d=e._readableState&&e._readableState.endEmitted,p=function(){l=!1,d=!0,u||i.call(e)},m=function(t){i.call(e,t)},_=function(){var t;return l&&!d?(e._readableState&&e._readableState.ended||(t=new r),i.call(e,t)):u&&!c?(e._writableState&&e._writableState.ended||(t=new r),i.call(e,t)):void 0},g=function(){e.req.on("finish",f)};return o(e)?(e.on("complete",f),e.on("abort",_),e.req?g():e.on("request",g)):u&&!e._writableState&&(e.on("end",h),e.on("close",h)),e.on("end",p),e.on("finish",f),!1!==t.error&&e.on("error",m),e.on("close",_),function(){e.removeListener("complete",f),e.removeListener("abort",_),e.removeListener("request",g),e.req&&e.req.removeListener("finish",f),e.removeListener("end",h),e.removeListener("close",h),e.removeListener("finish",f),e.removeListener("end",p),e.removeListener("error",m),e.removeListener("close",_)}}t.exports=s},{"../../../errors":66}],76:[function(e,t,i){t.exports=function(){throw new Error("Readable.from is not available in the browser")}},{}],77:[function(e,t,i){var r;function n(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var a=e("../../../errors").codes,o=a.ERR_MISSING_ARGS,s=a.ERR_STREAM_DESTROYED;function l(e){if(e)throw e}function u(e){return e.setHeader&&"function"==typeof e.abort}function h(t,i,a,o){o=n(o);var l=!1;t.on("close",(function(){l=!0})),void 0===r&&(r=e("./end-of-stream")),r(t,{readable:i,writable:a},(function(e){if(e)return o(e);l=!0,o()}));var h=!1;return function(e){if(!l&&!h)return h=!0,u(t)?t.abort():"function"==typeof t.destroy?t.destroy():void o(e||new s("pipe"))}}function c(e){e()}function f(e,t){return e.pipe(t)}function d(e){return e.length?"function"!=typeof e[e.length-1]?l:e.pop():l}function p(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];var r,n=d(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new o("streams");var a=t.map((function(e,i){var o=i<t.length-1;return h(e,o,i>0,(function(e){r||(r=e),e&&a.forEach(c),o||(a.forEach(c),n(r))}))}));return t.reduce(f)}t.exports=p},{"../../../errors":66,"./end-of-stream":75}],78:[function(e,t,i){var r=e("../../../errors").codes.ERR_INVALID_OPT_VALUE;function n(e,t,i){return null!=e.highWaterMark?e.highWaterMark:t?e[i]:null}function a(e,t,i,a){var o=n(t,a,i);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new r(a?i:"highWaterMark",o);return Math.floor(o)}return e.objectMode?16:16384}t.exports={getHighWaterMark:a}},{"../../../errors":66}],79:[function(e,t,i){t.exports=e("events").EventEmitter},{events:35}],80:[function(e,t,i){var r=e("safe-buffer").Buffer,n=r.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function a(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}function o(e){var t=a(e);if("string"!=typeof t&&(r.isEncoding===n||!n(e)))throw new Error("Unknown encoding: "+e);return t||e}function s(e){var t;switch(this.encoding=o(e),this.encoding){case"utf16le":this.text=p,this.end=m,t=4;break;case"utf8":this.fillLast=c,t=4;break;case"base64":this.text=_,this.end=g,t=3;break;default:return this.write=b,void(this.end=y)}this.lastNeed=0,this.lastTotal=0,this.lastChar=r.allocUnsafe(t)}function l(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function u(e,t,i){var r=t.length-1;if(r<i)return 0;var n=l(t[r]);return n>=0?(n>0&&(e.lastNeed=n-1),n):--r<i||-2===n?0:(n=l(t[r]))>=0?(n>0&&(e.lastNeed=n-2),n):--r<i||-2===n?0:(n=l(t[r]))>=0?(n>0&&(2===n?n=0:e.lastNeed=n-3),n):0}function h(e,t,i){if(128!=(192&t[0]))return e.lastNeed=0,"<22>";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"<22>";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"<22>"}}function c(e){var t=this.lastTotal-this.lastNeed,i=h(this,e);return void 0!==i?i:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function f(e,t){var i=u(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=i;var r=e.length-(i-this.lastNeed);return e.copy(this.lastChar,0,r),e.toString("utf8",t,r)}function d(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"<22>":t}function p(e,t){if((e.length-t)%2==0){var i=e.toString("utf16le",t);if(i){var r=i.charCodeAt(i.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],i.slice(0,-1)}return i}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function m(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var i=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,i)}return t}function _(e,t){var i=(e.length-t)%3;return 0===i?e.toString("base64",t):(this.lastNeed=3-i,this.lastTotal=3,1===i?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-i))}function g(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function b(e){return e.toString(this.encoding)}function y(e){return e&&e.length?this.write(e):""}i.StringDecoder=s,s.prototype.write=function(e){if(0===e.length)return"";var t,i;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";i=this.lastNeed,this.lastNeed=0}else i=0;return i<e.length?t?t+this.text(e,i):this.text(e,i):t||""},s.prototype.end=d,s.prototype.text=f,s.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":64}],81:[function(e,t,i){(function(e){(function(){function i(e,t){if(r("noDeprecation"))return e;var i=!1;function n(){if(!i){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),i=!0}return e.apply(this,arguments)}return n}function r(t){try{if(!e.localStorage)return!1}catch(e){return!1}var i=e.localStorage[t];return null!=i&&"true"===String(i).toLowerCase()}t.exports=i}).call(this)}).call(this,void 0!==commonjsGlobal?commonjsGlobal:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],82:[function(e,t,i){arguments[4][25][0].apply(i,arguments)},{dup:25}],83:[function(e,t,i){var r=e("is-arguments"),n=e("is-generator-function"),a=e("which-typed-array"),o=e("is-typed-array");function s(e){return e.call.bind(e)}var l="undefined"!=typeof BigInt,u="undefined"!=typeof Symbol,h=s(Object.prototype.toString),c=s(Number.prototype.valueOf),f=s(String.prototype.valueOf),d=s(Boolean.prototype.valueOf);if(l)var p=s(BigInt.prototype.valueOf);if(u)var m=s(Symbol.prototype.valueOf);function _(e,t){if("object"!=typeof e)return!1;try{return t(e),!0}catch(e){return!1}}function g(e){return"undefined"!=typeof Promise&&e instanceof Promise||null!==e&&"object"==typeof e&&"function"==typeof e.then&&"function"==typeof e.catch}function b(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):o(e)||U(e)}function y(e){return"Uint8Array"===a(e)}function w(e){return"Uint8ClampedArray"===a(e)}function v(e){return"Uint16Array"===a(e)}function x(e){return"Uint32Array"===a(e)}function E(e){return"Int8Array"===a(e)}function k(e){return"Int16Array"===a(e)}function S(e){return"Int32Array"===a(e)}function A(e){return"Float32Array"===a(e)}function I(e){return"Float64Array"===a(e)}function M(e){return"BigInt64Array"===a(e)}function T(e){return"BigUint64Array"===a(e)}function P(e){return"[object Map]"===h(e)}function B(e){return"undefined"!=typeof Map&&(P.working?P(e):e instanceof Map)}function C(e){return"[object Set]"===h(e)}function R(e){return"undefined"!=typeof Set&&(C.working?C(e):e instanceof Set)}function z(e){return"[object WeakMap]"===h(e)}function F(e){return"undefined"!=typeof WeakMap&&(z.working?z(e):e instanceof WeakMap)}function N(e){return"[object WeakSet]"===h(e)}function O(e){return N(e)}function D(e){return"[object ArrayBuffer]"===h(e)}function $(e){return"undefined"!=typeof ArrayBuffer&&(D.working?D(e):e instanceof ArrayBuffer)}function L(e){return"[object DataView]"===h(e)}function U(e){return"undefined"!=typeof DataView&&(L.working?L(e):e instanceof DataView)}i.isArgumentsObject=r,i.isGeneratorFunction=n,i.isTypedArray=o,i.isPromise=g,i.isArrayBufferView=b,i.isUint8Array=y,i.isUint8ClampedArray=w,i.isUint16Array=v,i.isUint32Array=x,i.isInt8Array=E,i.isInt16Array=k,i.isInt32Array=S,i.isFloat32Array=A,i.isFloat64Array=I,i.isBigInt64Array=M,i.isBigUint64Array=T,P.working="undefined"!=typeof Map&&P(new Map),i.isMap=B,C.working="undefined"!=typeof Set&&C(new Set),i.isSet=R,z.working="undefined"!=typeof WeakMap&&z(new WeakMap),i.isWeakMap=F,N.working="undefined"!=typeof WeakSet&&N(new WeakSet),i.isWeakSet=O,D.working="undefined"!=typeof ArrayBuffer&&D(new ArrayBuffer),i.isArrayBuffer=$,L.working="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView&&L(new DataView(new ArrayBuffer(1),0,1)),i.isDataView=U;var Z="undefined"!=typeof SharedArrayBuffer?SharedArrayBuffer:void 0;function j(e){return"[object SharedArrayBuffer]"===h(e)}function G(e){return void 0!==Z&&(void 0===j.working&&(j.working=j(new Z)),j.working?j(e):e instanceof Z)}function H(e){return"[object AsyncFunction]"===h(e)}function Q(e){return"[object Map Iterator]"===h(e)}function W(e){return"[object Set Iterator]"===h(e)}function q(e){return"[object Generator]"===h(e)}function V(e){return"[object WebAssembly.Module]"===h(e)}function Y(e){return _(e,c)}function K(e){return _(e,f)}function J(e){return _(e,d)}function X(e){return l&&_(e,p)}function ee(e){return u&&_(e,m)}function te(e){return Y(e)||K(e)||J(e)||X(e)||ee(e)}function ie(e){return"undefined"!=typeof Uint8Array&&($(e)||G(e))}i.isSharedArrayBuffer=G,i.isAsyncFunction=H,i.isMapIterator=Q,i.isSetIterator=W,i.isGeneratorObject=q,i.isWebAssemblyCompiledModule=V,i.isNumberObject=Y,i.isStringObject=K,i.isBooleanObject=J,i.isBigIntObject=X,i.isSymbolObject=ee,i.isBoxedPrimitive=te,i.isAnyArrayBuffer=ie,["isProxy","isExternal","isModuleNamespaceObject"].forEach((function(e){Object.defineProperty(i,e,{enumerable:!1,value:function(){throw new Error(e+" is not supported in userland")}})}))},{"is-arguments":47,"is-generator-function":49,"is-typed-array":50,"which-typed-array":85}],84:[function(e,t,i){(function(t){(function(){var r=Object.getOwnPropertyDescriptors||function(e){for(var t=Object.keys(e),i={},r=0;r<t.length;r++)i[t[r]]=Object.getOwnPropertyDescriptor(e,t[r]);return i},n=/%[sdj%]/g;i.format=function(e){if(!E(e)){for(var t=[],i=0;i<arguments.length;i++)t.push(l(arguments[i]));return t.join(" ")}i=1;for(var r=arguments,a=r.length,o=String(e).replace(n,(function(e){if("%%"===e)return"%";if(i>=a)return e;switch(e){case"%s":return String(r[i++]);case"%d":return Number(r[i++]);case"%j":try{return JSON.stringify(r[i++])}catch(e){return"[Circular]"}default:return e}})),s=r[i];i<a;s=r[++i])w(s)||!I(s)?o+=" "+s:o+=" "+l(s);return o},i.deprecate=function(e,r){if(void 0!==t&&!0===t.noDeprecation)return e;if(void 0===t)return function(){return i.deprecate(e,r).apply(this,arguments)};var n=!1;function a(){if(!n){if(t.throwDeprecation)throw new Error(r);t.traceDeprecation?console.trace(r):console.error(r),n=!0}return e.apply(this,arguments)}return a};var a={},o=/^$/;if(t.env.NODE_DEBUG){var s=t.env.NODE_DEBUG;s=s.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),o=new RegExp("^"+s+"$","i")}function l(e,t){var r={seen:[],stylize:h};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),y(t)?r.showHidden=t:t&&i._extend(r,t),S(r.showHidden)&&(r.showHidden=!1),S(r.depth)&&(r.depth=2),S(r.colors)&&(r.colors=!1),S(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=u),f(r,e,r.depth)}function u(e,t){var i=l.styles[t];return i?"["+l.colors[i][0]+"m"+e+"["+l.colors[i][1]+"m":e}function h(e,t){return e}function c(e){var t={};return e.forEach((function(e,i){t[e]=!0})),t}function f(e,t,r){if(e.customInspect&&t&&P(t.inspect)&&t.inspect!==i.inspect&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return E(n)||(n=f(e,n,r)),n}var a=d(e,t);if(a)return a;var o=Object.keys(t),s=c(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),T(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return p(t);if(0===o.length){if(P(t)){var l=t.name?": "+t.name:"";return e.stylize("[Function"+l+"]","special")}if(A(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(M(t))return e.stylize(Date.prototype.toString.call(t),"date");if(T(t))return p(t)}var u,h="",y=!1,w=["{","}"];return b(t)&&(y=!0,w=["[","]"]),P(t)&&(h=" [Function"+(t.name?": "+t.name:"")+"]"),A(t)&&(h=" "+RegExp.prototype.toString.call(t)),M(t)&&(h=" "+Date.prototype.toUTCString.call(t)),T(t)&&(h=" "+p(t)),0!==o.length||y&&0!=t.length?r<0?A(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),u=y?m(e,t,r,s,o):o.map((function(i){return _(e,t,r,s,i,y)})),e.seen.pop(),g(u,h,w)):w[0]+h+w[1]}function d(e,t){if(S(t))return e.stylize("undefined","undefined");if(E(t)){var i="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(i,"string")}return x(t)?e.stylize(""+t,"number"):y(t)?e.stylize(""+t,"boolean"):w(t)?e.stylize("null","null"):void 0}function p(e){return"["+Error.prototype.toString.call(e)+"]"}function m(e,t,i,r,n){for(var a=[],o=0,s=t.length;o<s;++o)N(t,String(o))?a.push(_(e,t,i,r,String(o),!0)):a.push("");return n.forEach((function(n){n.match(/^\d+$/)||a.push(_(e,t,i,r,n,!0))})),a}function _(e,t,i,r,n,a){var o,s,l;if((l=Object.getOwnPropertyDescriptor(t,n)||{value:t[n]}).get?s=l.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):l.set&&(s=e.stylize("[Setter]","special")),N(r,n)||(o="["+n+"]"),s||(e.seen.indexOf(l.value)<0?(s=w(i)?f(e,l.value,null):f(e,l.value,i-1)).indexOf("\n")>-1&&(s=a?s.split("\n").map((function(e){return" "+e})).join("\n").slice(2):"\n"+s.split("\n").map((function(e){return" "+e})).join("\n")):s=e.stylize("[Circular]","special")),S(o)){if(a&&n.match(/^\d+$/))return s;(o=JSON.stringify(""+n)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.slice(1,-1),o=e.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=e.stylize(o,"string"))}return o+": "+s}function g(e,t,i){return e.reduce((function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60?i[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+i[1]:i[0]+t+" "+e.join(", ")+" "+i[1]}function b(e){return Array.isArray(e)}function y(e){return"boolean"==typeof e}function w(e){return null===e}function v(e){return null==e}function x(e){return"number"==typeof e}function E(e){return"string"==typeof e}function k(e){return"symbol"==typeof e}function S(e){return void 0===e}function A(e){return I(e)&&"[object RegExp]"===C(e)}function I(e){return"object"==typeof e&&null!==e}function M(e){return I(e)&&"[object Date]"===C(e)}function T(e){return I(e)&&("[object Error]"===C(e)||e instanceof Error)}function P(e){return"function"==typeof e}function B(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e}function C(e){return Object.prototype.toString.call(e)}function R(e){return e<10?"0"+e.toString(10):e.toString(10)}i.debuglog=function(e){if(e=e.toUpperCase(),!a[e])if(o.test(e)){var r=t.pid;a[e]=function(){var t=i.format.apply(i,arguments);console.error("%s %d: %s",e,r,t)}}else a[e]=function(){};return a[e]},i.inspect=l,l.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},l.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},i.types=e("./support/types"),i.isArray=b,i.isBoolean=y,i.isNull=w,i.isNullOrUndefined=v,i.isNumber=x,i.isString=E,i.isSymbol=k,i.isUndefined=S,i.isRegExp=A,i.types.isRegExp=A,i.isObject=I,i.isDate=M,i.types.isDate=M,i.isError=T,i.types.isNativeError=T,i.isFunction=P,i.isPrimitive=B,i.isBuffer=e("./support/isBuffer");var z=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function F(){var e=new Date,t=[R(e.getHours()),R(e.getMinutes()),R(e.getSeconds())].join(":");return[e.getDate(),z[e.getMonth()],t].join(" ")}function N(e,t){return Object.prototype.hasOwnProperty.call(e,t)}i.log=function(){console.log("%s - %s",F(),i.format.apply(i,arguments))},i.inherits=e("inherits"),i._extend=function(e,t){if(!t||!I(t))return e;for(var i=Object.keys(t),r=i.length;r--;)e[i[r]]=t[i[r]];return e};var O="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function D(e,t){if(!e){var i=new Error("Promise was rejected with a falsy value");i.reason=e,e=i}return t(e)}function $(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');function i(){for(var i=[],r=0;r<arguments.length;r++)i.push(arguments[r]);var n=i.pop();if("function"!=typeof n)throw new TypeError("The last argument must be of type Function");var a=this,o=function(){return n.apply(a,arguments)};e.apply(this,i).then((function(e){t.nextTick(o.bind(null,null,e))}),(function(e){t.nextTick(D.bind(null,e,o))}))}return Object.setPrototypeOf(i,Object.getPrototypeOf(e)),Object.defineProperties(i,r(e)),i}i.promisify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(O&&e[O]){var t;if("function"!=typeof(t=e[O]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,O,{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(){for(var t,i,r=new Promise((function(e,r){t=e,i=r})),n=[],a=0;a<arguments.length;a++)n.push(arguments[a]);n.push((function(e,r){e?i(e):t(r)}));try{e.apply(this,n)}catch(e){i(e)}return r}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),O&&Object.defineProperty(t,O,{value:t,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(t,r(e))},i.promisify.custom=O,i.callbackify=$}).call(this)}).call(this,e("_process"))},{"./support/isBuffer":82,"./support/types":83,_process:63,inherits:46}],85:[function(e,t,i){(function(i){(function(){var r=e("for-each"),n=e("available-typed-arrays"),a=e("call-bind/callBound"),o=e("gopd"),s=a("Object.prototype.toString"),l=e("has-tostringtag/shams")(),u="undefined"==typeof globalThis?i:globalThis,h=n(),c=a("String.prototype.slice"),f={},d=Object.getPrototypeOf;l&&o&&d&&r(h,(function(e){if("function"==typeof u[e]){var t=new u[e];if(Symbol.toStringTag in t){var i=d(t),r=o(i,Symbol.toStringTag);if(!r){var n=d(i);r=o(n,Symbol.toStringTag)}f[e]=r.get}}}));var p=function(e){var t=!1;return r(f,(function(i,r){if(!t)try{var n=i.call(e);n===r&&(t=n)}catch(e){}})),t},m=e("is-typed-array");t.exports=function(e){return!!m(e)&&(l&&Symbol.toStringTag in e?p(e):c(s(e),8,-1))}}).call(this)}).call(this,void 0!==commonjsGlobal?commonjsGlobal:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"available-typed-arrays":27,"call-bind/callBound":33,"for-each":36,gopd:40,"has-tostringtag/shams":43,"is-typed-array":50}]},{},[20])(20);var browserExports=browser$1.exports,PNGFilterType,PNGFilterType2,PNGColorType,PNGColorType2;function png(){return{mime:"image/png",hasAlpha:!0,encode:(e,{deflateLevel:t=9,deflateStrategy:i=3,filterType:r=PNGFilterType.AUTO,colorType:n,inputHasAlpha:a=!0,...o}={})=>{const s=new browserExports.PNG({width:e.width,height:e.height});return s.data=e.data,browserExports.PNG.sync.write(s,{...o,deflateLevel:t,deflateStrategy:i,filterType:r,colorType:void 0!==n?n:a?PNGColorType.COLOR_ALPHA:PNGColorType.COLOR,inputHasAlpha:a})},decode:(e,t)=>{const i=browserExports.PNG.sync.read(e,t);return{data:i.data,width:i.width,height:i.height}}}}PNGFilterType2=PNGFilterType||(PNGFilterType={}),PNGFilterType2[PNGFilterType2.AUTO=-1]="AUTO",PNGFilterType2[PNGFilterType2.NONE=0]="NONE",PNGFilterType2[PNGFilterType2.SUB=1]="SUB",PNGFilterType2[PNGFilterType2.UP=2]="UP",PNGFilterType2[PNGFilterType2.AVERAGE=3]="AVERAGE",PNGFilterType2[PNGFilterType2.PATH=4]="PATH",PNGColorType2=PNGColorType||(PNGColorType={}),PNGColorType2[PNGColorType2.GRAYSCALE=0]="GRAYSCALE",PNGColorType2[PNGColorType2.COLOR=2]="COLOR",PNGColorType2[PNGColorType2.GRAYSCALE_ALPHA=4]="GRAYSCALE_ALPHA",PNGColorType2[PNGColorType2.COLOR_ALPHA=6]="COLOR_ALPHA";var UTIF={exports:{}},common={},hasRequiredCommon;function requireCommon(){return hasRequiredCommon||(hasRequiredCommon=1,function(e){var t="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function i(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var r=t.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(var n in r)i(r,n)&&(e[n]=r[n])}}return e},e.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var r={arraySet:function(e,t,i,r,n){if(t.subarray&&e.subarray)e.set(t.subarray(i,i+r),n);else for(var a=0;a<r;a++)e[n+a]=t[i+a]},flattenChunks:function(e){var t,i,r,n,a,o;for(r=0,t=0,i=e.length;t<i;t++)r+=e[t].length;for(o=new Uint8Array(r),n=0,t=0,i=e.length;t<i;t++)a=e[t],o.set(a,n),n+=a.length;return o}},n={arraySet:function(e,t,i,r,n){for(var a=0;a<r;a++)e[n+a]=t[i+a]},flattenChunks:function(e){return[].concat.apply([],e)}};e.setTyped=function(t){t?(e.Buf8=Uint8Array,e.Buf16=Uint16Array,e.Buf32=Int32Array,e.assign(e,r)):(e.Buf8=Array,e.Buf16=Array,e.Buf32=Array,e.assign(e,n))},e.setTyped(t)}(common)),common}var deflate$1={},deflate={},trees={},hasRequiredTrees,adler32_1,hasRequiredAdler32,crc32_1,hasRequiredCrc32,messages,hasRequiredMessages,hasRequiredDeflate$1;function requireTrees(){if(hasRequiredTrees)return trees;hasRequiredTrees=1;var e=requireCommon(),t=0,i=1;function r(e){for(var t=e.length;--t>=0;)e[t]=0}var n=0,a=29,o=256,s=o+1+a,l=30,u=19,h=2*s+1,c=15,f=16,d=7,p=256,m=16,_=17,g=18,b=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],y=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],w=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],v=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],x=new Array(2*(s+2));r(x);var E=new Array(2*l);r(E);var k=new Array(512);r(k);var S=new Array(256);r(S);var A=new Array(a);r(A);var I,M,T,P=new Array(l);function B(e,t,i,r,n){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=r,this.max_length=n,this.has_stree=e&&e.length}function C(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function R(e){return e<256?k[e]:k[256+(e>>>7)]}function z(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function F(e,t,i){e.bi_valid>f-i?(e.bi_buf|=t<<e.bi_valid&65535,z(e,e.bi_buf),e.bi_buf=t>>f-e.bi_valid,e.bi_valid+=i-f):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=i)}function N(e,t,i){F(e,i[2*t],i[2*t+1])}function O(e,t){var i=0;do{i|=1&e,e>>>=1,i<<=1}while(--t>0);return i>>>1}function D(e,t,i){var r,n,a=new Array(c+1),o=0;for(r=1;r<=c;r++)a[r]=o=o+i[r-1]<<1;for(n=0;n<=t;n++){var s=e[2*n+1];0!==s&&(e[2*n]=O(a[s]++,s))}}function $(e){var t;for(t=0;t<s;t++)e.dyn_ltree[2*t]=0;for(t=0;t<l;t++)e.dyn_dtree[2*t]=0;for(t=0;t<u;t++)e.bl_tree[2*t]=0;e.dyn_ltree[2*p]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function L(e){e.bi_valid>8?z(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function U(e,t,i,r){var n=2*t,a=2*i;return e[n]<e[a]||e[n]===e[a]&&r[t]<=r[i]}function Z(e,t,i){for(var r=e.heap[i],n=i<<1;n<=e.heap_len&&(n<e.heap_len&&U(t,e.heap[n+1],e.heap[n],e.depth)&&n++,!U(t,r,e.heap[n],e.depth));)e.heap[i]=e.heap[n],i=n,n<<=1;e.heap[i]=r}function j(e,t,i){var r,n,a,s,l=0;if(0!==e.last_lit)do{r=e.pending_buf[e.d_buf+2*l]<<8|e.pending_buf[e.d_buf+2*l+1],n=e.pending_buf[e.l_buf+l],l++,0===r?N(e,n,t):(N(e,(a=S[n])+o+1,t),0!==(s=b[a])&&F(e,n-=A[a],s),N(e,a=R(--r),i),0!==(s=y[a])&&F(e,r-=P[a],s))}while(l<e.last_lit);N(e,p,t)}function G(e,t){var i,r,n,a=t.dyn_tree,o=t.stat_desc.static_tree,s=t.stat_desc.has_stree,l=t.stat_desc.elems,u=-1;for(e.heap_len=0,e.heap_max=h,i=0;i<l;i++)0!==a[2*i]?(e.heap[++e.heap_len]=u=i,e.depth[i]=0):a[2*i+1]=0;for(;e.heap_len<2;)a[2*(n=e.heap[++e.heap_len]=u<2?++u:0)]=1,e.depth[n]=0,e.opt_len--,s&&(e.static_len-=o[2*n+1]);for(t.max_code=u,i=e.heap_len>>1;i>=1;i--)Z(e,a,i);n=l;do{i=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Z(e,a,1),r=e.heap[1],e.heap[--e.heap_max]=i,e.heap[--e.heap_max]=r,a[2*n]=a[2*i]+a[2*r],e.depth[n]=(e.depth[i]>=e.depth[r]?e.depth[i]:e.depth[r])+1,a[2*i+1]=a[2*r+1]=n,e.heap[1]=n++,Z(e,a,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var i,r,n,a,o,s,l=t.dyn_tree,u=t.max_code,f=t.stat_desc.static_tree,d=t.stat_desc.has_stree,p=t.stat_desc.extra_bits,m=t.stat_desc.extra_base,_=t.stat_desc.max_length,g=0;for(a=0;a<=c;a++)e.bl_count[a]=0;for(l[2*e.heap[e.heap_max]+1]=0,i=e.heap_max+1;i<h;i++)(a=l[2*l[2*(r=e.heap[i])+1]+1]+1)>_&&(a=_,g++),l[2*r+1]=a,r>u||(e.bl_count[a]++,o=0,r>=m&&(o=p[r-m]),s=l[2*r],e.opt_len+=s*(a+o),d&&(e.static_len+=s*(f[2*r+1]+o)));if(0!==g){do{for(a=_-1;0===e.bl_count[a];)a--;e.bl_count[a]--,e.bl_count[a+1]+=2,e.bl_count[_]--,g-=2}while(g>0);for(a=_;0!==a;a--)for(r=e.bl_count[a];0!==r;)(n=e.heap[--i])>u||(l[2*n+1]!==a&&(e.opt_len+=(a-l[2*n+1])*l[2*n],l[2*n+1]=a),r--)}}(e,t),D(a,u,e.bl_count)}function H(e,t,i){var r,n,a=-1,o=t[1],s=0,l=7,u=4;for(0===o&&(l=138,u=3),t[2*(i+1)+1]=65535,r=0;r<=i;r++)n=o,o=t[2*(r+1)+1],++s<l&&n===o||(s<u?e.bl_tree[2*n]+=s:0!==n?(n!==a&&e.bl_tree[2*n]++,e.bl_tree[2*m]++):s<=10?e.bl_tree[2*_]++:e.bl_tree[2*g]++,s=0,a=n,0===o?(l=138,u=3):n===o?(l=6,u=3):(l=7,u=4))}function Q(e,t,i){var r,n,a=-1,o=t[1],s=0,l=7,u=4;for(0===o&&(l=138,u=3),r=0;r<=i;r++)if(n=o,o=t[2*(r+1)+1],!(++s<l&&n===o)){if(s<u)do{N(e,n,e.bl_tree)}while(0!=--s);else 0!==n?(n!==a&&(N(e,n,e.bl_tree),s--),N(e,m,e.bl_tree),F(e,s-3,2)):s<=10?(N(e,_,e.bl_tree),F(e,s-3,3)):(N(e,g,e.bl_tree),F(e,s-11,7));s=0,a=n,0===o?(l=138,u=3):n===o?(l=6,u=3):(l=7,u=4)}}r(P);var W=!1;function q(t,i,r,a){F(t,(n<<1)+(a?1:0),3),function(t,i,r,n){L(t),z(t,r),z(t,~r),e.arraySet(t.pending_buf,t.window,i,r,t.pending),t.pending+=r}(t,i,r)}return trees._tr_init=function(e){W||(!function(){var e,t,i,r,n,h=new Array(c+1);for(i=0,r=0;r<a-1;r++)for(A[r]=i,e=0;e<1<<b[r];e++)S[i++]=r;for(S[i-1]=r,n=0,r=0;r<16;r++)for(P[r]=n,e=0;e<1<<y[r];e++)k[n++]=r;for(n>>=7;r<l;r++)for(P[r]=n<<7,e=0;e<1<<y[r]-7;e++)k[256+n++]=r;for(t=0;t<=c;t++)h[t]=0;for(e=0;e<=143;)x[2*e+1]=8,e++,h[8]++;for(;e<=255;)x[2*e+1]=9,e++,h[9]++;for(;e<=279;)x[2*e+1]=7,e++,h[7]++;for(;e<=287;)x[2*e+1]=8,e++,h[8]++;for(D(x,s+1,h),e=0;e<l;e++)E[2*e+1]=5,E[2*e]=O(e,5);I=new B(x,b,o+1,s,c),M=new B(E,y,0,l,c),T=new B(new Array(0),w,0,u,d)}(),W=!0),e.l_desc=new C(e.dyn_ltree,I),e.d_desc=new C(e.dyn_dtree,M),e.bl_desc=new C(e.bl_tree,T),e.bi_buf=0,e.bi_valid=0,$(e)},trees._tr_stored_block=q,trees._tr_flush_block=function(e,r,n,a){var s,l,h=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=function(e){var r,n=4093624447;for(r=0;r<=31;r++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*r])return t;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return i;for(r=32;r<o;r++)if(0!==e.dyn_ltree[2*r])return i;return t}(e)),G(e,e.l_desc),G(e,e.d_desc),h=function(e){var t;for(H(e,e.dyn_ltree,e.l_desc.max_code),H(e,e.dyn_dtree,e.d_desc.max_code),G(e,e.bl_desc),t=u-1;t>=3&&0===e.bl_tree[2*v[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),s=e.opt_len+3+7>>>3,(l=e.static_len+3+7>>>3)<=s&&(s=l)):s=l=n+5,n+4<=s&&-1!==r?q(e,r,n,a):4===e.strategy||l===s?(F(e,2+(a?1:0),3),j(e,x,E)):(F(e,4+(a?1:0),3),function(e,t,i,r){var n;for(F(e,t-257,5),F(e,i-1,5),F(e,r-4,4),n=0;n<r;n++)F(e,e.bl_tree[2*v[n]+1],3);Q(e,e.dyn_ltree,t-1),Q(e,e.dyn_dtree,i-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,h+1),j(e,e.dyn_ltree,e.dyn_dtree)),$(e),a&&L(e)},trees._tr_tally=function(e,t,i){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&i,e.last_lit++,0===t?e.dyn_ltree[2*i]++:(e.matches++,t--,e.dyn_ltree[2*(S[i]+o+1)]++,e.dyn_dtree[2*R(t)]++),e.last_lit===e.lit_bufsize-1},trees._tr_align=function(e){F(e,2,3),N(e,p,x),function(e){16===e.bi_valid?(z(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)},trees}function requireAdler32(){if(hasRequiredAdler32)return adler32_1;return hasRequiredAdler32=1,adler32_1=function(e,t,i,r){for(var n=65535&e,a=e>>>16&65535,o=0;0!==i;){i-=o=i>2e3?2e3:i;do{a=a+(n=n+t[r++]|0)|0}while(--o);n%=65521,a%=65521}return n|a<<16},adler32_1}function requireCrc32(){if(hasRequiredCrc32)return crc32_1;hasRequiredCrc32=1;var e=function(){for(var e,t=[],i=0;i<256;i++){e=i;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t}();return crc32_1=function(t,i,r,n){var a=e,o=n+r;t^=-1;for(var s=n;s<o;s++)t=t>>>8^a[255&(t^i[s])];return~t},crc32_1}function requireMessages(){return hasRequiredMessages?messages:(hasRequiredMessages=1,messages={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"})}function requireDeflate$1(){if(hasRequiredDeflate$1)return deflate;hasRequiredDeflate$1=1;var e,t=requireCommon(),i=requireTrees(),r=requireAdler32(),n=requireCrc32(),a=requireMessages(),o=0,s=4,l=0,u=-2,h=-1,c=4,f=2,d=8,p=9,m=286,_=30,g=19,b=2*m+1,y=15,w=3,v=258,x=v+w+1,E=42,k=103,S=113,A=666,I=1,M=2,T=3,P=4;function B(e,t){return e.msg=a[t],t}function C(e){return(e<<1)-(e>4?9:0)}function R(e){for(var t=e.length;--t>=0;)e[t]=0}function z(e){var i=e.state,r=i.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(t.arraySet(e.output,i.pending_buf,i.pending_out,r,e.next_out),e.next_out+=r,i.pending_out+=r,e.total_out+=r,e.avail_out-=r,i.pending-=r,0===i.pending&&(i.pending_out=0))}function F(e,t){i._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,z(e.strm)}function N(e,t){e.pending_buf[e.pending++]=t}function O(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function D(e,t){var i,r,n=e.max_chain_length,a=e.strstart,o=e.prev_length,s=e.nice_match,l=e.strstart>e.w_size-x?e.strstart-(e.w_size-x):0,u=e.window,h=e.w_mask,c=e.prev,f=e.strstart+v,d=u[a+o-1],p=u[a+o];e.prev_length>=e.good_match&&(n>>=2),s>e.lookahead&&(s=e.lookahead);do{if(u[(i=t)+o]===p&&u[i+o-1]===d&&u[i]===u[a]&&u[++i]===u[a+1]){a+=2,i++;do{}while(u[++a]===u[++i]&&u[++a]===u[++i]&&u[++a]===u[++i]&&u[++a]===u[++i]&&u[++a]===u[++i]&&u[++a]===u[++i]&&u[++a]===u[++i]&&u[++a]===u[++i]&&a<f);if(r=v-(f-a),a=f-v,r>o){if(e.match_start=t,o=r,r>=s)break;d=u[a+o-1],p=u[a+o]}}}while((t=c[t&h])>l&&0!=--n);return o<=e.lookahead?o:e.lookahead}function $(e){var i,a,o,s,l,u,h,c,f,d,p=e.w_size;do{if(s=e.window_size-e.lookahead-e.strstart,e.strstart>=p+(p-x)){t.arraySet(e.window,e.window,p,p,0),e.match_start-=p,e.strstart-=p,e.block_start-=p,i=a=e.hash_size;do{o=e.head[--i],e.head[i]=o>=p?o-p:0}while(--a);i=a=p;do{o=e.prev[--i],e.prev[i]=o>=p?o-p:0}while(--a);s+=p}if(0===e.strm.avail_in)break;if(u=e.strm,h=e.window,c=e.strstart+e.lookahead,f=s,d=void 0,(d=u.avail_in)>f&&(d=f),a=0===d?0:(u.avail_in-=d,t.arraySet(h,u.input,u.next_in,d,c),1===u.state.wrap?u.adler=r(u.adler,h,d,c):2===u.state.wrap&&(u.adler=n(u.adler,h,d,c)),u.next_in+=d,u.total_in+=d,d),e.lookahead+=a,e.lookahead+e.insert>=w)for(l=e.strstart-e.insert,e.ins_h=e.window[l],e.ins_h=(e.ins_h<<e.hash_shift^e.window[l+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[l+w-1])&e.hash_mask,e.prev[l&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=l,l++,e.insert--,!(e.lookahead+e.insert<w)););}while(e.lookahead<x&&0!==e.strm.avail_in)}function L(e,t){for(var r,n;;){if(e.lookahead<x){if($(e),e.lookahead<x&&t===o)return I;if(0===e.lookahead)break}if(r=0,e.lookahead>=w&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+w-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-x&&(e.match_length=D(e,r)),e.match_length>=w)if(n=i._tr_tally(e,e.strstart-e.match_start,e.match_length-w),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=w){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+w-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else n=i._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(F(e,!1),0===e.strm.avail_out))return I}return e.insert=e.strstart<w-1?e.strstart:w-1,t===s?(F(e,!0),0===e.strm.avail_out?T:P):e.last_lit&&(F(e,!1),0===e.strm.avail_out)?I:M}function U(e,t){for(var r,n,a;;){if(e.lookahead<x){if($(e),e.lookahead<x&&t===o)return I;if(0===e.lookahead)break}if(r=0,e.lookahead>=w&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+w-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=w-1,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-x&&(e.match_length=D(e,r),e.match_length<=5&&(1===e.strategy||e.match_length===w&&e.strstart-e.match_start>4096)&&(e.match_length=w-1)),e.prev_length>=w&&e.match_length<=e.prev_length){a=e.strstart+e.lookahead-w,n=i._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-w),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=a&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+w-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=w-1,e.strstart++,n&&(F(e,!1),0===e.strm.avail_out))return I}else if(e.match_available){if((n=i._tr_tally(e,0,e.window[e.strstart-1]))&&F(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return I}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=i._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<w-1?e.strstart:w-1,t===s?(F(e,!0),0===e.strm.avail_out?T:P):e.last_lit&&(F(e,!1),0===e.strm.avail_out)?I:M}function Z(e,t,i,r,n){this.good_length=e,this.max_lazy=t,this.nice_length=i,this.max_chain=r,this.func=n}function j(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=d,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new t.Buf16(2*b),this.dyn_dtree=new t.Buf16(2*(2*_+1)),this.bl_tree=new t.Buf16(2*(2*g+1)),R(this.dyn_ltree),R(this.dyn_dtree),R(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new t.Buf16(y+1),this.heap=new t.Buf16(2*m+1),R(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new t.Buf16(2*m+1),R(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function G(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=f,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?E:S,e.adler=2===t.wrap?0:1,t.last_flush=o,i._tr_init(t),l):B(e,u)}function H(t){var i=G(t);return i===l&&function(t){t.window_size=2*t.w_size,R(t.head),t.max_lazy_match=e[t.level].max_lazy,t.good_match=e[t.level].good_length,t.nice_match=e[t.level].nice_length,t.max_chain_length=e[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=w-1,t.match_available=0,t.ins_h=0}(t.state),i}function Q(e,i,r,n,a,o){if(!e)return u;var s=1;if(i===h&&(i=6),n<0?(s=0,n=-n):n>15&&(s=2,n-=16),a<1||a>p||r!==d||n<8||n>15||i<0||i>9||o<0||o>c)return B(e,u);8===n&&(n=9);var l=new j;return e.state=l,l.strm=e,l.wrap=s,l.gzhead=null,l.w_bits=n,l.w_size=1<<l.w_bits,l.w_mask=l.w_size-1,l.hash_bits=a+7,l.hash_size=1<<l.hash_bits,l.hash_mask=l.hash_size-1,l.hash_shift=~~((l.hash_bits+w-1)/w),l.window=new t.Buf8(2*l.w_size),l.head=new t.Buf16(l.hash_size),l.prev=new t.Buf16(l.w_size),l.lit_bufsize=1<<a+6,l.pending_buf_size=4*l.lit_bufsize,l.pending_buf=new t.Buf8(l.pending_buf_size),l.d_buf=1*l.lit_bufsize,l.l_buf=3*l.lit_bufsize,l.level=i,l.strategy=o,l.method=r,H(e)}return e=[new Z(0,0,0,0,(function(e,t){var i=65535;for(i>e.pending_buf_size-5&&(i=e.pending_buf_size-5);;){if(e.lookahead<=1){if($(e),0===e.lookahead&&t===o)return I;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+i;if((0===e.strstart||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,F(e,!1),0===e.strm.avail_out))return I;if(e.strstart-e.block_start>=e.w_size-x&&(F(e,!1),0===e.strm.avail_out))return I}return e.insert=0,t===s?(F(e,!0),0===e.strm.avail_out?T:P):(e.strstart>e.block_start&&(F(e,!1),e.strm.avail_out),I)})),new Z(4,4,8,4,L),new Z(4,5,16,8,L),new Z(4,6,32,32,L),new Z(4,4,16,16,U),new Z(8,16,32,32,U),new Z(8,16,128,128,U),new Z(8,32,128,256,U),new Z(32,128,258,1024,U),new Z(32,258,258,4096,U)],deflate.deflateInit=function(e,t){return Q(e,t,d,15,8,0)},deflate.deflateInit2=Q,deflate.deflateReset=H,deflate.deflateResetKeep=G,deflate.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?u:(e.state.gzhead=t,l):u},deflate.deflate=function(t,r){var a,h,c,f;if(!t||!t.state||r>5||r<0)return t?B(t,u):u;if(h=t.state,!t.output||!t.input&&0!==t.avail_in||h.status===A&&r!==s)return B(t,0===t.avail_out?-5:u);if(h.strm=t,a=h.last_flush,h.last_flush=r,h.status===E)if(2===h.wrap)t.adler=0,N(h,31),N(h,139),N(h,8),h.gzhead?(N(h,(h.gzhead.text?1:0)+(h.gzhead.hcrc?2:0)+(h.gzhead.extra?4:0)+(h.gzhead.name?8:0)+(h.gzhead.comment?16:0)),N(h,255&h.gzhead.time),N(h,h.gzhead.time>>8&255),N(h,h.gzhead.time>>16&255),N(h,h.gzhead.time>>24&255),N(h,9===h.level?2:h.strategy>=2||h.level<2?4:0),N(h,255&h.gzhead.os),h.gzhead.extra&&h.gzhead.extra.length&&(N(h,255&h.gzhead.extra.length),N(h,h.gzhead.extra.length>>8&255)),h.gzhead.hcrc&&(t.adler=n(t.adler,h.pending_buf,h.pending,0)),h.gzindex=0,h.status=69):(N(h,0),N(h,0),N(h,0),N(h,0),N(h,0),N(h,9===h.level?2:h.strategy>=2||h.level<2?4:0),N(h,3),h.status=S);else{var p=d+(h.w_bits-8<<4)<<8;p|=(h.strategy>=2||h.level<2?0:h.level<6?1:6===h.level?2:3)<<6,0!==h.strstart&&(p|=32),p+=31-p%31,h.status=S,O(h,p),0!==h.strstart&&(O(h,t.adler>>>16),O(h,65535&t.adler)),t.adler=1}if(69===h.status)if(h.gzhead.extra){for(c=h.pending;h.gzindex<(65535&h.gzhead.extra.length)&&(h.pending!==h.pending_buf_size||(h.gzhead.hcrc&&h.pending>c&&(t.adler=n(t.adler,h.pending_buf,h.pending-c,c)),z(t),c=h.pending,h.pending!==h.pending_buf_size));)N(h,255&h.gzhead.extra[h.gzindex]),h.gzindex++;h.gzhead.hcrc&&h.pending>c&&(t.adler=n(t.adler,h.pending_buf,h.pending-c,c)),h.gzindex===h.gzhead.extra.length&&(h.gzindex=0,h.status=73)}else h.status=73;if(73===h.status)if(h.gzhead.name){c=h.pending;do{if(h.pending===h.pending_buf_size&&(h.gzhead.hcrc&&h.pending>c&&(t.adler=n(t.adler,h.pending_buf,h.pending-c,c)),z(t),c=h.pending,h.pending===h.pending_buf_size)){f=1;break}f=h.gzindex<h.gzhead.name.length?255&h.gzhead.name.charCodeAt(h.gzindex++):0,N(h,f)}while(0!==f);h.gzhead.hcrc&&h.pending>c&&(t.adler=n(t.adler,h.pending_buf,h.pending-c,c)),0===f&&(h.gzindex=0,h.status=91)}else h.status=91;if(91===h.status)if(h.gzhead.comment){c=h.pending;do{if(h.pending===h.pending_buf_size&&(h.gzhead.hcrc&&h.pending>c&&(t.adler=n(t.adler,h.pending_buf,h.pending-c,c)),z(t),c=h.pending,h.pending===h.pending_buf_size)){f=1;break}f=h.gzindex<h.gzhead.comment.length?255&h.gzhead.comment.charCodeAt(h.gzindex++):0,N(h,f)}while(0!==f);h.gzhead.hcrc&&h.pending>c&&(t.adler=n(t.adler,h.pending_buf,h.pending-c,c)),0===f&&(h.status=k)}else h.status=k;if(h.status===k&&(h.gzhead.hcrc?(h.pending+2>h.pending_buf_size&&z(t),h.pending+2<=h.pending_buf_size&&(N(h,255&t.adler),N(h,t.adler>>8&255),t.adler=0,h.status=S)):h.status=S),0!==h.pending){if(z(t),0===t.avail_out)return h.last_flush=-1,l}else if(0===t.avail_in&&C(r)<=C(a)&&r!==s)return B(t,-5);if(h.status===A&&0!==t.avail_in)return B(t,-5);if(0!==t.avail_in||0!==h.lookahead||r!==o&&h.status!==A){var m=2===h.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&($(e),0===e.lookahead)){if(t===o)return I;break}if(e.match_length=0,r=i._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(F(e,!1),0===e.strm.avail_out))return I}return e.insert=0,t===s?(F(e,!0),0===e.strm.avail_out?T:P):e.last_lit&&(F(e,!1),0===e.strm.avail_out)?I:M}(h,r):3===h.strategy?function(e,t){for(var r,n,a,l,u=e.window;;){if(e.lookahead<=v){if($(e),e.lookahead<=v&&t===o)return I;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=w&&e.strstart>0&&(n=u[a=e.strstart-1])===u[++a]&&n===u[++a]&&n===u[++a]){l=e.strstart+v;do{}while(n===u[++a]&&n===u[++a]&&n===u[++a]&&n===u[++a]&&n===u[++a]&&n===u[++a]&&n===u[++a]&&n===u[++a]&&a<l);e.match_length=v-(l-a),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=w?(r=i._tr_tally(e,1,e.match_length-w),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=i._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(F(e,!1),0===e.strm.avail_out))return I}return e.insert=0,t===s?(F(e,!0),0===e.strm.avail_out?T:P):e.last_lit&&(F(e,!1),0===e.strm.avail_out)?I:M}(h,r):e[h.level].func(h,r);if(m!==T&&m!==P||(h.status=A),m===I||m===T)return 0===t.avail_out&&(h.last_flush=-1),l;if(m===M&&(1===r?i._tr_align(h):5!==r&&(i._tr_stored_block(h,0,0,!1),3===r&&(R(h.head),0===h.lookahead&&(h.strstart=0,h.block_start=0,h.insert=0))),z(t),0===t.avail_out))return h.last_flush=-1,l}return r!==s?l:h.wrap<=0?1:(2===h.wrap?(N(h,255&t.adler),N(h,t.adler>>8&255),N(h,t.adler>>16&255),N(h,t.adler>>24&255),N(h,255&t.total_in),N(h,t.total_in>>8&255),N(h,t.total_in>>16&255),N(h,t.total_in>>24&255)):(O(h,t.adler>>>16),O(h,65535&t.adler)),z(t),h.wrap>0&&(h.wrap=-h.wrap),0!==h.pending?l:1)},deflate.deflateEnd=function(e){var t;return e&&e.state?(t=e.state.status)!==E&&69!==t&&73!==t&&91!==t&&t!==k&&t!==S&&t!==A?B(e,u):(e.state=null,t===S?B(e,-3):l):u},deflate.deflateSetDictionary=function(e,i){var n,a,o,s,h,c,f,d,p=i.length;if(!e||!e.state)return u;if(2===(s=(n=e.state).wrap)||1===s&&n.status!==E||n.lookahead)return u;for(1===s&&(e.adler=r(e.adler,i,p,0)),n.wrap=0,p>=n.w_size&&(0===s&&(R(n.head),n.strstart=0,n.block_start=0,n.insert=0),d=new t.Buf8(n.w_size),t.arraySet(d,i,p-n.w_size,n.w_size,0),i=d,p=n.w_size),h=e.avail_in,c=e.next_in,f=e.input,e.avail_in=p,e.next_in=0,e.input=i,$(n);n.lookahead>=w;){a=n.strstart,o=n.lookahead-(w-1);do{n.ins_h=(n.ins_h<<n.hash_shift^n.window[a+w-1])&n.hash_mask,n.prev[a&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=a,a++}while(--o);n.strstart=a,n.lookahead=w-1,$(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=w-1,n.match_available=0,e.next_in=c,e.input=f,e.avail_in=h,n.wrap=s,l},deflate.deflateInfo="pako deflate (from Nodeca project)",deflate}var strings={},hasRequiredStrings,zstream,hasRequiredZstream,hasRequiredDeflate;function requireStrings(){if(hasRequiredStrings)return strings;hasRequiredStrings=1;var e=requireCommon(),t=!0,i=!0;try{String.fromCharCode.apply(null,[0])}catch(e){t=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){i=!1}for(var r=new e.Buf8(256),n=0;n<256;n++)r[n]=n>=252?6:n>=248?5:n>=240?4:n>=224?3:n>=192?2:1;function a(r,n){if(n<65534&&(r.subarray&&i||!r.subarray&&t))return String.fromCharCode.apply(null,e.shrinkBuf(r,n));for(var a="",o=0;o<n;o++)a+=String.fromCharCode(r[o]);return a}return r[254]=r[254]=1,strings.string2buf=function(t){var i,r,n,a,o,s=t.length,l=0;for(a=0;a<s;a++)55296==(64512&(r=t.charCodeAt(a)))&&a+1<s&&56320==(64512&(n=t.charCodeAt(a+1)))&&(r=65536+(r-55296<<10)+(n-56320),a++),l+=r<128?1:r<2048?2:r<65536?3:4;for(i=new e.Buf8(l),o=0,a=0;o<l;a++)55296==(64512&(r=t.charCodeAt(a)))&&a+1<s&&56320==(64512&(n=t.charCodeAt(a+1)))&&(r=65536+(r-55296<<10)+(n-56320),a++),r<128?i[o++]=r:r<2048?(i[o++]=192|r>>>6,i[o++]=128|63&r):r<65536?(i[o++]=224|r>>>12,i[o++]=128|r>>>6&63,i[o++]=128|63&r):(i[o++]=240|r>>>18,i[o++]=128|r>>>12&63,i[o++]=128|r>>>6&63,i[o++]=128|63&r);return i},strings.buf2binstring=function(e){return a(e,e.length)},strings.binstring2buf=function(t){for(var i=new e.Buf8(t.length),r=0,n=i.length;r<n;r++)i[r]=t.charCodeAt(r);return i},strings.buf2string=function(e,t){var i,n,o,s,l=t||e.length,u=new Array(2*l);for(n=0,i=0;i<l;)if((o=e[i++])<128)u[n++]=o;else if((s=r[o])>4)u[n++]=65533,i+=s-1;else{for(o&=2===s?31:3===s?15:7;s>1&&i<l;)o=o<<6|63&e[i++],s--;s>1?u[n++]=65533:o<65536?u[n++]=o:(o-=65536,u[n++]=55296|o>>10&1023,u[n++]=56320|1023&o)}return a(u,n)},strings.utf8border=function(e,t){var i;for((t=t||e.length)>e.length&&(t=e.length),i=t-1;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+r[e[i]]>t?i:t},strings}function requireZstream(){if(hasRequiredZstream)return zstream;return hasRequiredZstream=1,zstream=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}}function requireDeflate(){if(hasRequiredDeflate)return deflate$1;hasRequiredDeflate=1;var e=requireDeflate$1(),t=requireCommon(),i=requireStrings(),r=requireMessages(),n=requireZstream(),a=Object.prototype.toString,o=0,s=-1,l=0,u=8;function h(c){if(!(this instanceof h))return new h(c);this.options=t.assign({level:s,method:u,chunkSize:16384,windowBits:15,memLevel:8,strategy:l,to:""},c||{});var f=this.options;f.raw&&f.windowBits>0?f.windowBits=-f.windowBits:f.gzip&&f.windowBits>0&&f.windowBits<16&&(f.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new n,this.strm.avail_out=0;var d=e.deflateInit2(this.strm,f.level,f.method,f.windowBits,f.memLevel,f.strategy);if(d!==o)throw new Error(r[d]);if(f.header&&e.deflateSetHeader(this.strm,f.header),f.dictionary){var p;if(p="string"==typeof f.dictionary?i.string2buf(f.dictionary):"[object ArrayBuffer]"===a.call(f.dictionary)?new Uint8Array(f.dictionary):f.dictionary,(d=e.deflateSetDictionary(this.strm,p))!==o)throw new Error(r[d]);this._dict_set=!0}}function c(e,t){var i=new h(t);if(i.push(e,!0),i.err)throw i.msg||r[i.err];return i.result}return h.prototype.push=function(r,n){var s,l,u=this.strm,h=this.options.chunkSize;if(this.ended)return!1;l=n===~~n?n:!0===n?4:0,"string"==typeof r?u.input=i.string2buf(r):"[object ArrayBuffer]"===a.call(r)?u.input=new Uint8Array(r):u.input=r,u.next_in=0,u.avail_in=u.input.length;do{if(0===u.avail_out&&(u.output=new t.Buf8(h),u.next_out=0,u.avail_out=h),1!==(s=e.deflate(u,l))&&s!==o)return this.onEnd(s),this.ended=!0,!1;0!==u.avail_out&&(0!==u.avail_in||4!==l&&2!==l)||("string"===this.options.to?this.onData(i.buf2binstring(t.shrinkBuf(u.output,u.next_out))):this.onData(t.shrinkBuf(u.output,u.next_out)))}while((u.avail_in>0||0===u.avail_out)&&1!==s);return 4===l?(s=e.deflateEnd(this.strm),this.onEnd(s),this.ended=!0,s===o):2!==l||(this.onEnd(o),u.avail_out=0,!0)},h.prototype.onData=function(e){this.chunks.push(e)},h.prototype.onEnd=function(e){e===o&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=t.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},deflate$1.Deflate=h,deflate$1.deflate=c,deflate$1.deflateRaw=function(e,t){return(t=t||{}).raw=!0,c(e,t)},deflate$1.gzip=function(e,t){return(t=t||{}).gzip=!0,c(e,t)},deflate$1}var inflate$1={},inflate={},inffast,hasRequiredInffast,inftrees,hasRequiredInftrees,hasRequiredInflate$1,constants,hasRequiredConstants,gzheader,hasRequiredGzheader,hasRequiredInflate,pako_1,hasRequiredPako;function requireInffast(){if(hasRequiredInffast)return inffast;hasRequiredInffast=1;return inffast=function(e,t){var i,r,n,a,o,s,l,u,h,c,f,d,p,m,_,g,b,y,w,v,x,E,k,S,A;i=e.state,r=e.next_in,S=e.input,n=r+(e.avail_in-5),a=e.next_out,A=e.output,o=a-(t-e.avail_out),s=a+(e.avail_out-257),l=i.dmax,u=i.wsize,h=i.whave,c=i.wnext,f=i.window,d=i.hold,p=i.bits,m=i.lencode,_=i.distcode,g=(1<<i.lenbits)-1,b=(1<<i.distbits)-1;e:do{p<15&&(d+=S[r++]<<p,p+=8,d+=S[r++]<<p,p+=8),y=m[d&g];t:for(;;){if(d>>>=w=y>>>24,p-=w,0===(w=y>>>16&255))A[a++]=65535&y;else{if(!(16&w)){if(64&w){if(32&w){i.mode=12;break e}e.msg="invalid literal/length code",i.mode=30;break e}y=m[(65535&y)+(d&(1<<w)-1)];continue t}for(v=65535&y,(w&=15)&&(p<w&&(d+=S[r++]<<p,p+=8),v+=d&(1<<w)-1,d>>>=w,p-=w),p<15&&(d+=S[r++]<<p,p+=8,d+=S[r++]<<p,p+=8),y=_[d&b];;){if(d>>>=w=y>>>24,p-=w,16&(w=y>>>16&255)){if(x=65535&y,p<(w&=15)&&(d+=S[r++]<<p,(p+=8)<w&&(d+=S[r++]<<p,p+=8)),(x+=d&(1<<w)-1)>l){e.msg="invalid distance too far back",i.mode=30;break e}if(d>>>=w,p-=w,x>(w=a-o)){if((w=x-w)>h&&i.sane){e.msg="invalid distance too far back",i.mode=30;break e}if(E=0,k=f,0===c){if(E+=u-w,w<v){v-=w;do{A[a++]=f[E++]}while(--w);E=a-x,k=A}}else if(c<w){if(E+=u+c-w,(w-=c)<v){v-=w;do{A[a++]=f[E++]}while(--w);if(E=0,c<v){v-=w=c;do{A[a++]=f[E++]}while(--w);E=a-x,k=A}}}else if(E+=c-w,w<v){v-=w;do{A[a++]=f[E++]}while(--w);E=a-x,k=A}for(;v>2;)A[a++]=k[E++],A[a++]=k[E++],A[a++]=k[E++],v-=3;v&&(A[a++]=k[E++],v>1&&(A[a++]=k[E++]))}else{E=a-x;do{A[a++]=A[E++],A[a++]=A[E++],A[a++]=A[E++],v-=3}while(v>2);v&&(A[a++]=A[E++],v>1&&(A[a++]=A[E++]))}break}if(64&w){e.msg="invalid distance code",i.mode=30;break e}y=_[(65535&y)+(d&(1<<w)-1)]}}break}}while(r<n&&a<s);r-=v=p>>3,d&=(1<<(p-=v<<3))-1,e.next_in=r,e.next_out=a,e.avail_in=r<n?n-r+5:5-(r-n),e.avail_out=a<s?s-a+257:257-(a-s),i.hold=d,i.bits=p},inffast}function requireInftrees(){if(hasRequiredInftrees)return inftrees;hasRequiredInftrees=1;var e=requireCommon(),t=15,i=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],r=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],n=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],a=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];return inftrees=function(o,s,l,u,h,c,f,d){var p,m,_,g,b,y,w,v,x,E=d.bits,k=0,S=0,A=0,I=0,M=0,T=0,P=0,B=0,C=0,R=0,z=null,F=0,N=new e.Buf16(16),O=new e.Buf16(16),D=null,$=0;for(k=0;k<=t;k++)N[k]=0;for(S=0;S<u;S++)N[s[l+S]]++;for(M=E,I=t;I>=1&&0===N[I];I--);if(M>I&&(M=I),0===I)return h[c++]=20971520,h[c++]=20971520,d.bits=1,0;for(A=1;A<I&&0===N[A];A++);for(M<A&&(M=A),B=1,k=1;k<=t;k++)if(B<<=1,(B-=N[k])<0)return-1;if(B>0&&(0===o||1!==I))return-1;for(O[1]=0,k=1;k<t;k++)O[k+1]=O[k]+N[k];for(S=0;S<u;S++)0!==s[l+S]&&(f[O[s[l+S]]++]=S);if(0===o?(z=D=f,y=19):1===o?(z=i,F-=257,D=r,$-=257,y=256):(z=n,D=a,y=-1),R=0,S=0,k=A,b=c,T=M,P=0,_=-1,g=(C=1<<M)-1,1===o&&C>852||2===o&&C>592)return 1;for(;;){w=k-P,f[S]<y?(v=0,x=f[S]):f[S]>y?(v=D[$+f[S]],x=z[F+f[S]]):(v=96,x=0),p=1<<k-P,A=m=1<<T;do{h[b+(R>>P)+(m-=p)]=w<<24|v<<16|x}while(0!==m);for(p=1<<k-1;R&p;)p>>=1;if(0!==p?(R&=p-1,R+=p):R=0,S++,0==--N[k]){if(k===I)break;k=s[l+f[S]]}if(k>M&&(R&g)!==_){for(0===P&&(P=M),b+=A,B=1<<(T=k-P);T+P<I&&!((B-=N[T+P])<=0);)T++,B<<=1;if(C+=1<<T,1===o&&C>852||2===o&&C>592)return 1;h[_=R&g]=M<<24|T<<16|b-c}}return 0!==R&&(h[b+R]=k-P<<24|64<<16),d.bits=M,0}}function requireInflate$1(){if(hasRequiredInflate$1)return inflate;hasRequiredInflate$1=1;var e=requireCommon(),t=requireAdler32(),i=requireCrc32(),r=requireInffast(),n=requireInftrees(),a=1,o=2,s=0,l=-2,u=1,h=12,c=30,f=852,d=592;function p(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function m(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new e.Buf16(320),this.work=new e.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function _(t){var i;return t&&t.state?(i=t.state,t.total_in=t.total_out=i.total=0,t.msg="",i.wrap&&(t.adler=1&i.wrap),i.mode=u,i.last=0,i.havedict=0,i.dmax=32768,i.head=null,i.hold=0,i.bits=0,i.lencode=i.lendyn=new e.Buf32(f),i.distcode=i.distdyn=new e.Buf32(d),i.sane=1,i.back=-1,s):l}function g(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,_(e)):l}function b(e,t){var i,r;return e&&e.state?(r=e.state,t<0?(i=0,t=-t):(i=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?l:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=i,r.wbits=t,g(e))):l}function y(e,t){var i,r;return e?(r=new m,e.state=r,r.window=null,(i=b(e,t))!==s&&(e.state=null),i):l}var w,v,x=!0;function E(t){if(x){var i;for(w=new e.Buf32(512),v=new e.Buf32(32),i=0;i<144;)t.lens[i++]=8;for(;i<256;)t.lens[i++]=9;for(;i<280;)t.lens[i++]=7;for(;i<288;)t.lens[i++]=8;for(n(a,t.lens,0,288,w,0,t.work,{bits:9}),i=0;i<32;)t.lens[i++]=5;n(o,t.lens,0,32,v,0,t.work,{bits:5}),x=!1}t.lencode=w,t.lenbits=9,t.distcode=v,t.distbits=5}function k(t,i,r,n){var a,o=t.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new e.Buf8(o.wsize)),n>=o.wsize?(e.arraySet(o.window,i,r-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):((a=o.wsize-o.wnext)>n&&(a=n),e.arraySet(o.window,i,r-n,a,o.wnext),(n-=a)?(e.arraySet(o.window,i,r-n,n,0),o.wnext=n,o.whave=o.wsize):(o.wnext+=a,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=a))),0}return inflate.inflateReset=g,inflate.inflateReset2=b,inflate.inflateResetKeep=_,inflate.inflateInit=function(e){return y(e,15)},inflate.inflateInit2=y,inflate.inflate=function(f,d){var m,_,g,b,y,w,v,x,S,A,I,M,T,P,B,C,R,z,F,N,O,D,$,L,U=0,Z=new e.Buf8(4),j=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!f||!f.state||!f.output||!f.input&&0!==f.avail_in)return l;(m=f.state).mode===h&&(m.mode=13),y=f.next_out,g=f.output,v=f.avail_out,b=f.next_in,_=f.input,w=f.avail_in,x=m.hold,S=m.bits,A=w,I=v,D=s;e:for(;;)switch(m.mode){case u:if(0===m.wrap){m.mode=13;break}for(;S<16;){if(0===w)break e;w--,x+=_[b++]<<S,S+=8}if(2&m.wrap&&35615===x){m.check=0,Z[0]=255&x,Z[1]=x>>>8&255,m.check=i(m.check,Z,2,0),x=0,S=0,m.mode=2;break}if(m.flags=0,m.head&&(m.head.done=!1),!(1&m.wrap)||(((255&x)<<8)+(x>>8))%31){f.msg="incorrect header check",m.mode=c;break}if(8!=(15&x)){f.msg="unknown compression method",m.mode=c;break}if(S-=4,O=8+(15&(x>>>=4)),0===m.wbits)m.wbits=O;else if(O>m.wbits){f.msg="invalid window size",m.mode=c;break}m.dmax=1<<O,f.adler=m.check=1,m.mode=512&x?10:h,x=0,S=0;break;case 2:for(;S<16;){if(0===w)break e;w--,x+=_[b++]<<S,S+=8}if(m.flags=x,8!=(255&m.flags)){f.msg="unknown compression method",m.mode=c;break}if(57344&m.flags){f.msg="unknown header flags set",m.mode=c;break}m.head&&(m.head.text=x>>8&1),512&m.flags&&(Z[0]=255&x,Z[1]=x>>>8&255,m.check=i(m.check,Z,2,0)),x=0,S=0,m.mode=3;case 3:for(;S<32;){if(0===w)break e;w--,x+=_[b++]<<S,S+=8}m.head&&(m.head.time=x),512&m.flags&&(Z[0]=255&x,Z[1]=x>>>8&255,Z[2]=x>>>16&255,Z[3]=x>>>24&255,m.check=i(m.check,Z,4,0)),x=0,S=0,m.mode=4;case 4:for(;S<16;){if(0===w)break e;w--,x+=_[b++]<<S,S+=8}m.head&&(m.head.xflags=255&x,m.head.os=x>>8),512&m.flags&&(Z[0]=255&x,Z[1]=x>>>8&255,m.check=i(m.check,Z,2,0)),x=0,S=0,m.mode=5;case 5:if(1024&m.flags){for(;S<16;){if(0===w)break e;w--,x+=_[b++]<<S,S+=8}m.length=x,m.head&&(m.head.extra_len=x),512&m.flags&&(Z[0]=255&x,Z[1]=x>>>8&255,m.check=i(m.check,Z,2,0)),x=0,S=0}else m.head&&(m.head.extra=null);m.mode=6;case 6:if(1024&m.flags&&((M=m.length)>w&&(M=w),M&&(m.head&&(O=m.head.extra_len-m.length,m.head.extra||(m.head.extra=new Array(m.head.extra_len)),e.arraySet(m.head.extra,_,b,M,O)),512&m.flags&&(m.check=i(m.check,_,M,b)),w-=M,b+=M,m.length-=M),m.length))break e;m.length=0,m.mode=7;case 7:if(2048&m.flags){if(0===w)break e;M=0;do{O=_[b+M++],m.head&&O&&m.length<65536&&(m.head.name+=String.fromCharCode(O))}while(O&&M<w);if(512&m.flags&&(m.check=i(m.check,_,M,b)),w-=M,b+=M,O)break e}else m.head&&(m.head.name=null);m.length=0,m.mode=8;case 8:if(4096&m.flags){if(0===w)break e;M=0;do{O=_[b+M++],m.head&&O&&m.length<65536&&(m.head.comment+=String.fromCharCode(O))}while(O&&M<w);if(512&m.flags&&(m.check=i(m.check,_,M,b)),w-=M,b+=M,O)break e}else m.head&&(m.head.comment=null);m.mode=9;case 9:if(512&m.flags){for(;S<16;){if(0===w)break e;w--,x+=_[b++]<<S,S+=8}if(x!==(65535&m.check)){f.msg="header crc mismatch",m.mode=c;break}x=0,S=0}m.head&&(m.head.hcrc=m.flags>>9&1,m.head.done=!0),f.adler=m.check=0,m.mode=h;break;case 10:for(;S<32;){if(0===w)break e;w--,x+=_[b++]<<S,S+=8}f.adler=m.check=p(x),x=0,S=0,m.mode=11;case 11:if(0===m.havedict)return f.next_out=y,f.avail_out=v,f.next_in=b,f.avail_in=w,m.hold=x,m.bits=S,2;f.adler=m.check=1,m.mode=h;case h:if(5===d||6===d)break e;case 13:if(m.last){x>>>=7&S,S-=7&S,m.mode=27;break}for(;S<3;){if(0===w)break e;w--,x+=_[b++]<<S,S+=8}switch(m.last=1&x,S-=1,3&(x>>>=1)){case 0:m.mode=14;break;case 1:if(E(m),m.mode=20,6===d){x>>>=2,S-=2;break e}break;case 2:m.mode=17;break;case 3:f.msg="invalid block type",m.mode=c}x>>>=2,S-=2;break;case 14:for(x>>>=7&S,S-=7&S;S<32;){if(0===w)break e;w--,x+=_[b++]<<S,S+=8}if((65535&x)!=(x>>>16^65535)){f.msg="invalid stored block lengths",m.mode=c;break}if(m.length=65535&x,x=0,S=0,m.mode=15,6===d)break e;case 15:m.mode=16;case 16:if(M=m.length){if(M>w&&(M=w),M>v&&(M=v),0===M)break e;e.arraySet(g,_,b,M,y),w-=M,b+=M,v-=M,y+=M,m.length-=M;break}m.mode=h;break;case 17:for(;S<14;){if(0===w)break e;w--,x+=_[b++]<<S,S+=8}if(m.nlen=257+(31&x),x>>>=5,S-=5,m.ndist=1+(31&x),x>>>=5,S-=5,m.ncode=4+(15&x),x>>>=4,S-=4,m.nlen>286||m.ndist>30){f.msg="too many length or distance symbols",m.mode=c;break}m.have=0,m.mode=18;case 18:for(;m.have<m.ncode;){for(;S<3;){if(0===w)break e;w--,x+=_[b++]<<S,S+=8}m.lens[j[m.have++]]=7&x,x>>>=3,S-=3}for(;m.have<19;)m.lens[j[m.have++]]=0;if(m.lencode=m.lendyn,m.lenbits=7,$={bits:m.lenbits},D=n(0,m.lens,0,19,m.lencode,0,m.work,$),m.lenbits=$.bits,D){f.msg="invalid code lengths set",m.mode=c;break}m.have=0,m.mode=19;case 19:for(;m.have<m.nlen+m.ndist;){for(;C=(U=m.lencode[x&(1<<m.lenbits)-1])>>>16&255,R=65535&U,!((B=U>>>24)<=S);){if(0===w)break e;w--,x+=_[b++]<<S,S+=8}if(R<16)x>>>=B,S-=B,m.lens[m.have++]=R;else{if(16===R){for(L=B+2;S<L;){if(0===w)break e;w--,x+=_[b++]<<S,S+=8}if(x>>>=B,S-=B,0===m.have){f.msg="invalid bit length repeat",m.mode=c;break}O=m.lens[m.have-1],M=3+(3&x),x>>>=2,S-=2}else if(17===R){for(L=B+3;S<L;){if(0===w)break e;w--,x+=_[b++]<<S,S+=8}S-=B,O=0,M=3+(7&(x>>>=B)),x>>>=3,S-=3}else{for(L=B+7;S<L;){if(0===w)break e;w--,x+=_[b++]<<S,S+=8}S-=B,O=0,M=11+(127&(x>>>=B)),x>>>=7,S-=7}if(m.have+M>m.nlen+m.ndist){f.msg="invalid bit length repeat",m.mode=c;break}for(;M--;)m.lens[m.have++]=O}}if(m.mode===c)break;if(0===m.lens[256]){f.msg="invalid code -- missing end-of-block",m.mode=c;break}if(m.lenbits=9,$={bits:m.lenbits},D=n(a,m.lens,0,m.nlen,m.lencode,0,m.work,$),m.lenbits=$.bits,D){f.msg="invalid literal/lengths set",m.mode=c;break}if(m.distbits=6,m.distcode=m.distdyn,$={bits:m.distbits},D=n(o,m.lens,m.nlen,m.ndist,m.distcode,0,m.work,$),m.distbits=$.bits,D){f.msg="invalid distances set",m.mode=c;break}if(m.mode=20,6===d)break e;case 20:m.mode=21;case 21:if(w>=6&&v>=258){f.next_out=y,f.avail_out=v,f.next_in=b,f.avail_in=w,m.hold=x,m.bits=S,r(f,I),y=f.next_out,g=f.output,v=f.avail_out,b=f.next_in,_=f.input,w=f.avail_in,x=m.hold,S=m.bits,m.mode===h&&(m.back=-1);break}for(m.back=0;C=(U=m.lencode[x&(1<<m.lenbits)-1])>>>16&255,R=65535&U,!((B=U>>>24)<=S);){if(0===w)break e;w--,x+=_[b++]<<S,S+=8}if(C&&!(240&C)){for(z=B,F=C,N=R;C=(U=m.lencode[N+((x&(1<<z+F)-1)>>z)])>>>16&255,R=65535&U,!(z+(B=U>>>24)<=S);){if(0===w)break e;w--,x+=_[b++]<<S,S+=8}x>>>=z,S-=z,m.back+=z}if(x>>>=B,S-=B,m.back+=B,m.length=R,0===C){m.mode=26;break}if(32&C){m.back=-1,m.mode=h;break}if(64&C){f.msg="invalid literal/length code",m.mode=c;break}m.extra=15&C,m.mode=22;case 22:if(m.extra){for(L=m.extra;S<L;){if(0===w)break e;w--,x+=_[b++]<<S,S+=8}m.length+=x&(1<<m.extra)-1,x>>>=m.extra,S-=m.extra,m.back+=m.extra}m.was=m.length,m.mode=23;case 23:for(;C=(U=m.distcode[x&(1<<m.distbits)-1])>>>16&255,R=65535&U,!((B=U>>>24)<=S);){if(0===w)break e;w--,x+=_[b++]<<S,S+=8}if(!(240&C)){for(z=B,F=C,N=R;C=(U=m.distcode[N+((x&(1<<z+F)-1)>>z)])>>>16&255,R=65535&U,!(z+(B=U>>>24)<=S);){if(0===w)break e;w--,x+=_[b++]<<S,S+=8}x>>>=z,S-=z,m.back+=z}if(x>>>=B,S-=B,m.back+=B,64&C){f.msg="invalid distance code",m.mode=c;break}m.offset=R,m.extra=15&C,m.mode=24;case 24:if(m.extra){for(L=m.extra;S<L;){if(0===w)break e;w--,x+=_[b++]<<S,S+=8}m.offset+=x&(1<<m.extra)-1,x>>>=m.extra,S-=m.extra,m.back+=m.extra}if(m.offset>m.dmax){f.msg="invalid distance too far back",m.mode=c;break}m.mode=25;case 25:if(0===v)break e;if(M=I-v,m.offset>M){if((M=m.offset-M)>m.whave&&m.sane){f.msg="invalid distance too far back",m.mode=c;break}M>m.wnext?(M-=m.wnext,T=m.wsize-M):T=m.wnext-M,M>m.length&&(M=m.length),P=m.window}else P=g,T=y-m.offset,M=m.length;M>v&&(M=v),v-=M,m.length-=M;do{g[y++]=P[T++]}while(--M);0===m.length&&(m.mode=21);break;case 26:if(0===v)break e;g[y++]=m.length,v--,m.mode=21;break;case 27:if(m.wrap){for(;S<32;){if(0===w)break e;w--,x|=_[b++]<<S,S+=8}if(I-=v,f.total_out+=I,m.total+=I,I&&(f.adler=m.check=m.flags?i(m.check,g,I,y-I):t(m.check,g,I,y-I)),I=v,(m.flags?x:p(x))!==m.check){f.msg="incorrect data check",m.mode=c;break}x=0,S=0}m.mode=28;case 28:if(m.wrap&&m.flags){for(;S<32;){if(0===w)break e;w--,x+=_[b++]<<S,S+=8}if(x!==(4294967295&m.total)){f.msg="incorrect length check",m.mode=c;break}x=0,S=0}m.mode=29;case 29:D=1;break e;case c:D=-3;break e;case 31:return-4;default:return l}return f.next_out=y,f.avail_out=v,f.next_in=b,f.avail_in=w,m.hold=x,m.bits=S,(m.wsize||I!==f.avail_out&&m.mode<c&&(m.mode<27||4!==d))&&k(f,f.output,f.next_out,I-f.avail_out),A-=f.avail_in,I-=f.avail_out,f.total_in+=A,f.total_out+=I,m.total+=I,m.wrap&&I&&(f.adler=m.check=m.flags?i(m.check,g,I,f.next_out-I):t(m.check,g,I,f.next_out-I)),f.data_type=m.bits+(m.last?64:0)+(m.mode===h?128:0)+(20===m.mode||15===m.mode?256:0),(0===A&&0===I||4===d)&&D===s&&(D=-5),D},inflate.inflateEnd=function(e){if(!e||!e.state)return l;var t=e.state;return t.window&&(t.window=null),e.state=null,s},inflate.inflateGetHeader=function(e,t){var i;return e&&e.state&&2&(i=e.state).wrap?(i.head=t,t.done=!1,s):l},inflate.inflateSetDictionary=function(e,i){var r,n=i.length;return e&&e.state?0!==(r=e.state).wrap&&11!==r.mode?l:11===r.mode&&t(1,i,n,0)!==r.check?-3:k(e,i,n,n)?(r.mode=31,-4):(r.havedict=1,s):l},inflate.inflateInfo="pako inflate (from Nodeca project)",inflate}function requireConstants(){return hasRequiredConstants?constants:(hasRequiredConstants=1,constants={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8})}function requireGzheader(){if(hasRequiredGzheader)return gzheader;return hasRequiredGzheader=1,gzheader=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}}function requireInflate(){if(hasRequiredInflate)return inflate$1;hasRequiredInflate=1;var e=requireInflate$1(),t=requireCommon(),i=requireStrings(),r=requireConstants(),n=requireMessages(),a=requireZstream(),o=requireGzheader(),s=Object.prototype.toString;function l(u){if(!(this instanceof l))return new l(u);this.options=t.assign({chunkSize:16384,windowBits:0,to:""},u||{});var h=this.options;h.raw&&h.windowBits>=0&&h.windowBits<16&&(h.windowBits=-h.windowBits,0===h.windowBits&&(h.windowBits=-15)),!(h.windowBits>=0&&h.windowBits<16)||u&&u.windowBits||(h.windowBits+=32),h.windowBits>15&&h.windowBits<48&&(15&h.windowBits||(h.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new a,this.strm.avail_out=0;var c=e.inflateInit2(this.strm,h.windowBits);if(c!==r.Z_OK)throw new Error(n[c]);if(this.header=new o,e.inflateGetHeader(this.strm,this.header),h.dictionary&&("string"==typeof h.dictionary?h.dictionary=i.string2buf(h.dictionary):"[object ArrayBuffer]"===s.call(h.dictionary)&&(h.dictionary=new Uint8Array(h.dictionary)),h.raw&&(c=e.inflateSetDictionary(this.strm,h.dictionary))!==r.Z_OK))throw new Error(n[c])}function u(e,t){var i=new l(t);if(i.push(e,!0),i.err)throw i.msg||n[i.err];return i.result}return l.prototype.push=function(n,a){var o,l,u,h,c,f=this.strm,d=this.options.chunkSize,p=this.options.dictionary,m=!1;if(this.ended)return!1;l=a===~~a?a:!0===a?r.Z_FINISH:r.Z_NO_FLUSH,"string"==typeof n?f.input=i.binstring2buf(n):"[object ArrayBuffer]"===s.call(n)?f.input=new Uint8Array(n):f.input=n,f.next_in=0,f.avail_in=f.input.length;do{if(0===f.avail_out&&(f.output=new t.Buf8(d),f.next_out=0,f.avail_out=d),(o=e.inflate(f,r.Z_NO_FLUSH))===r.Z_NEED_DICT&&p&&(o=e.inflateSetDictionary(this.strm,p)),o===r.Z_BUF_ERROR&&!0===m&&(o=r.Z_OK,m=!1),o!==r.Z_STREAM_END&&o!==r.Z_OK)return this.onEnd(o),this.ended=!0,!1;f.next_out&&(0!==f.avail_out&&o!==r.Z_STREAM_END&&(0!==f.avail_in||l!==r.Z_FINISH&&l!==r.Z_SYNC_FLUSH)||("string"===this.options.to?(u=i.utf8border(f.output,f.next_out),h=f.next_out-u,c=i.buf2string(f.output,u),f.next_out=h,f.avail_out=d-h,h&&t.arraySet(f.output,f.output,u,h,0),this.onData(c)):this.onData(t.shrinkBuf(f.output,f.next_out)))),0===f.avail_in&&0===f.avail_out&&(m=!0)}while((f.avail_in>0||0===f.avail_out)&&o!==r.Z_STREAM_END);return o===r.Z_STREAM_END&&(l=r.Z_FINISH),l===r.Z_FINISH?(o=e.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,o===r.Z_OK):l!==r.Z_SYNC_FLUSH||(this.onEnd(r.Z_OK),f.avail_out=0,!0)},l.prototype.onData=function(e){this.chunks.push(e)},l.prototype.onEnd=function(e){e===r.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=t.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},inflate$1.Inflate=l,inflate$1.inflate=u,inflate$1.inflateRaw=function(e,t){return(t=t||{}).raw=!0,u(e,t)},inflate$1.ungzip=u,inflate$1}function requirePako(){if(hasRequiredPako)return pako_1;hasRequiredPako=1;var e={};return(0,requireCommon().assign)(e,requireDeflate(),requireInflate(),requireConstants()),pako_1=e}!function(e){!function(){var t={};function i(){"undefined"!=typeof process&&"development"!=process.env.NODE_ENV||console.log.apply(console,arguments)}e.exports=t,function(e,t){!function(){var t=function(){function e(e){this.message="JPEG error: "+e}return e.prototype=new Error,e.prototype.name="JpegError",e.constructor=e,e}(),i=function(){var e=new Uint8Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),i=4017,n=799,a=3406,o=2276,s=1567,l=3784,u=5793,h=2896;function c(e){null==e&&(e={}),null==e.w&&(e.w=-1),this.V=e.n,this.N=e.w}function f(e,t){for(var i,r,n,a=0,o=[],s=16;s>0&&!e[s-1];)s--;o.push({children:[],index:0});var l=o[0];for(i=0;i<s;i++){for(r=0;r<e[i];r++){for((l=o.pop()).children[l.index]=t[a];l.index>0;)l=o.pop();for(l.index++,o.push(l);o.length<=i;)o.push(n={children:[],index:0}),l.children[l.index]=n.children,l=n;a++}i+1<s&&(o.push(n={children:[],index:0}),l.children[l.index]=n.children,l=n)}return o[0].children}function d(e,t,i){return 64*((e.P+1)*t+i)}function p(i,n,a,o,s,l,u,h,c,f){null==f&&(f=!1);var p,m,_,b,y,w,v,x,E,k,S,A=a.m,I=a.Z,M=n,T=0,P=0,B=0,C=0,R=0,z=0;function F(){if(P>0)return P--,T>>P&1;if(255===(T=i[n++])){var e=i[n++];if(e){if(220===e&&f){var o=r(i,n+=2);if(n+=2,o>0&&o!==a.s)throw new DNLMarkerError("Found DNL marker (0xFFDC) while parsing scan data",o)}else if(217===e){if(f){var s=8*R;if(s>0&&s<a.s/10)throw new DNLMarkerError("Found EOI marker (0xFFD9) while parsing scan data, possibly caused by incorrect `scanLines` parameter",s)}throw new EOIMarkerError("Found EOI marker (0xFFD9) while parsing scan data")}throw new t("unexpected marker")}}return P=7,T>>>7}function N(e){for(var i=e;;){switch(typeof(i=i[F()])){case"number":return i;case"object":continue}throw new t("invalid huffman sequence")}}function O(e){for(var t=0;e>0;)t=t<<1|F(),e--;return t}function D(e){if(1===e)return 1===F()?1:-1;var t=O(e);return t>=1<<e-1?t:t+(-1<<e)+1}function $(e,t,i,r,n){var a=i%A;R=(i/A|0)*e.A+r;var o=a*e.h+n;t(e,d(e,R,o))}function L(e,t,i){R=i/e.P|0;var r=i%e.P;t(e,d(e,R,r))}var U=o.length;for(v=I?0===l?0===h?function(e,t){var i=N(e.J),r=0===i?0:D(i)<<c;e.D[t]=e.Q+=r}:function(e,t){e.D[t]|=F()<<c}:0===h?function(t,i){if(B>0)B--;else for(var r=l,n=u;r<=n;){var a=N(t.i),o=15&a,s=a>>4;if(0!==o){var h=e[r+=s];t.D[i+h]=D(o)*(1<<c),r++}else{if(s<15){B=O(s)+(1<<s)-1;break}r+=16}}}:function(i,r){for(var n,a,o=l,s=u,h=0;o<=s;){var f=r+e[o],d=i.D[f]<0?-1:1;switch(C){case 0:if(h=(a=N(i.i))>>4,0==(n=15&a))h<15?(B=O(h)+(1<<h),C=4):(h=16,C=1);else{if(1!==n)throw new t("invalid ACn encoding");p=D(n),C=h?2:3}continue;case 1:case 2:i.D[f]?i.D[f]+=d*(F()<<c):0==--h&&(C=2===C?3:0);break;case 3:i.D[f]?i.D[f]+=d*(F()<<c):(i.D[f]=p<<c,C=0);break;case 4:i.D[f]&&(i.D[f]+=d*(F()<<c))}o++}4===C&&0==--B&&(C=0)}:function(t,i){var r=N(t.J),n=0===r?0:D(r),a=1;for(t.D[i]=t.Q+=n;a<64;){var o=N(t.i),s=15&o,l=o>>4;if(0!==s){var u=e[a+=l];t.D[i+u]=D(s),a++}else{if(l<15)break;a+=16}}},E=1===U?o[0].P*o[0].c:A*a.R;z<=E;){var Z=s?Math.min(E-z,s):E;if(Z>0){for(_=0;_<U;_++)o[_].Q=0;if(B=0,1===U)for(m=o[0],w=0;w<Z;w++)L(m,v,z),z++;else for(w=0;w<Z;w++){for(_=0;_<U;_++)for(k=(m=o[_]).h,S=m.A,b=0;b<S;b++)for(y=0;y<k;y++)$(m,v,z,b,y);z++}}if(P=0,!(x=g(i,n)))break;if(x.u&&(n=x.offset),!(x.M>=65488&&x.M<=65495))break;n+=2}return n-M}function m(e,r,c){var f,d,p,m,_,g,b,y,w,v,x,E,k,S,A,I,M,T=e.$,P=e.D;if(!T)throw new t("missing required Quantization Table.");for(var B=0;B<64;B+=8)w=P[r+B],v=P[r+B+1],x=P[r+B+2],E=P[r+B+3],k=P[r+B+4],S=P[r+B+5],A=P[r+B+6],I=P[r+B+7],w*=T[B],v|x|E|k|S|A|I?(v*=T[B+1],x*=T[B+2],E*=T[B+3],k*=T[B+4],S*=T[B+5],A*=T[B+6],I*=T[B+7],d=(f=(f=u*w+128>>8)+(d=u*k+128>>8)+1>>1)-d,M=(p=x)*l+(m=A)*s+128>>8,p=p*s-m*l+128>>8,b=(_=(_=h*(v-I)+128>>8)+(b=S<<4)+1>>1)-b,g=(y=(y=h*(v+I)+128>>8)+(g=E<<4)+1>>1)-g,m=(f=f+(m=M)+1>>1)-m,p=(d=d+p+1>>1)-p,M=_*o+y*a+2048>>12,_=_*a-y*o+2048>>12,y=M,M=g*n+b*i+2048>>12,g=g*i-b*n+2048>>12,b=M,c[B]=f+y,c[B+7]=f-y,c[B+1]=d+b,c[B+6]=d-b,c[B+2]=p+g,c[B+5]=p-g,c[B+3]=m+_,c[B+4]=m-_):(M=u*w+512>>10,c[B]=M,c[B+1]=M,c[B+2]=M,c[B+3]=M,c[B+4]=M,c[B+5]=M,c[B+6]=M,c[B+7]=M);for(var C=0;C<8;++C)w=c[C],(v=c[C+8])|(x=c[C+16])|(E=c[C+24])|(k=c[C+32])|(S=c[C+40])|(A=c[C+48])|(I=c[C+56])?(d=(f=4112+((f=u*w+2048>>12)+(d=u*k+2048>>12)+1>>1))-d,M=(p=x)*l+(m=A)*s+2048>>12,p=p*s-m*l+2048>>12,m=M,b=(_=(_=h*(v-I)+2048>>12)+(b=S)+1>>1)-b,g=(y=(y=h*(v+I)+2048>>12)+(g=E)+1>>1)-g,M=_*o+y*a+2048>>12,_=_*a-y*o+2048>>12,y=M,M=g*n+b*i+2048>>12,g=g*i-b*n+2048>>12,(w=(f=f+m+1>>1)+y)<16?w=0:w>=4080?w=255:w>>=4,(v=(d=d+p+1>>1)+(b=M))<16?v=0:v>=4080?v=255:v>>=4,(x=(p=d-p)+g)<16?x=0:x>=4080?x=255:x>>=4,(E=(m=f-m)+_)<16?E=0:E>=4080?E=255:E>>=4,(k=m-_)<16?k=0:k>=4080?k=255:k>>=4,(S=p-g)<16?S=0:S>=4080?S=255:S>>=4,(A=d-b)<16?A=0:A>=4080?A=255:A>>=4,(I=f-y)<16?I=0:I>=4080?I=255:I>>=4,P[r+C]=w,P[r+C+8]=v,P[r+C+16]=x,P[r+C+24]=E,P[r+C+32]=k,P[r+C+40]=S,P[r+C+48]=A,P[r+C+56]=I):(M=(M=u*w+8192>>14)<-2040?0:M>=2024?255:M+2056>>4,P[r+C]=M,P[r+C+8]=M,P[r+C+16]=M,P[r+C+24]=M,P[r+C+32]=M,P[r+C+40]=M,P[r+C+48]=M,P[r+C+56]=M)}function _(e,t){for(var i=t.P,r=t.c,n=new Int16Array(64),a=0;a<r;a++)for(var o=0;o<i;o++){m(t,d(t,a,o),n)}return t.D}function g(e,t,i){null==i&&(i=t);var n=e.length-1,a=i<t?i:t;if(t>=n)return null;var o=r(e,t);if(o>=65472&&o<=65534)return{u:null,M:o,offset:t};for(var s=r(e,a);!(s>=65472&&s<=65534);){if(++a>=n)return null;s=r(e,a)}return{u:o.toString(16),M:s,offset:a}}return c.prototype={parse(i,n){null==n&&(n={});var a,o,s=n.F,l=0,u=null,h=null,c=0;function d(){var e=r(i,l),t=(l+=2)+e-2,n=g(i,t,l);n&&n.u&&(t=n.offset);var a=i.subarray(l,t);return l+=a.length,a}function m(e){for(var t=Math.ceil(e.o/8/e.X),i=Math.ceil(e.s/8/e.B),r=0;r<e.W.length;r++){Z=e.W[r];var n=Math.ceil(Math.ceil(e.o/8)*Z.h/e.X),a=Math.ceil(Math.ceil(e.s/8)*Z.A/e.B),o=t*Z.h,s=64*(i*Z.A)*(o+1);Z.D=new Int16Array(s),Z.P=n,Z.c=a}e.m=t,e.R=i}var b=[],y=[],w=[],v=r(i,l);if(l+=2,65496!==v)throw new t("SOI not found");v=r(i,l),l+=2;e:for(;65497!==v;){var x,E,k;switch(v){case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:case 65534:var S=d();65504===v&&74===S[0]&&70===S[1]&&73===S[2]&&70===S[3]&&0===S[4]&&(u={version:{d:S[5],T:S[6]},K:S[7],j:S[8]<<8|S[9],H:S[10]<<8|S[11],S:S[12],I:S[13],C:S.subarray(14,14+3*S[12]*S[13])}),65518===v&&65===S[0]&&100===S[1]&&111===S[2]&&98===S[3]&&101===S[4]&&(h={version:S[5]<<8|S[6],k:S[7]<<8|S[8],q:S[9]<<8|S[10],a:S[11]});break;case 65499:for(var A=r(i,l)+(l+=2)-2;l<A;){var I=i[l++],M=new Uint16Array(64);if(I>>4){if(I>>4!=1)throw new t("DQT - invalid table spec");for(E=0;E<64;E++)M[e[E]]=r(i,l),l+=2}else for(E=0;E<64;E++)M[e[E]]=i[l++];b[15&I]=M}break;case 65472:case 65473:case 65474:if(a)throw new t("Only single frame JPEGs supported");l+=2,(a={}).G=65473===v,a.Z=65474===v,a.precision=i[l++];var T,P=r(i,l),B=0,C=0;l+=2,a.s=s||P,a.o=r(i,l),l+=2,a.W=[],a._={};var R=i[l++];for(x=0;x<R;x++){T=i[l];var z=i[l+1]>>4,F=15&i[l+1];B<z&&(B=z),C<F&&(C=F);var N=i[l+2];k=a.W.push({h:z,A:F,L:N,$:null}),a._[T]=k-1,l+=3}a.X=B,a.B=C,m(a);break;case 65476:var O=r(i,l);for(l+=2,x=2;x<O;){var D=i[l++],$=new Uint8Array(16),L=0;for(E=0;E<16;E++,l++)L+=$[E]=i[l];var U=new Uint8Array(L);for(E=0;E<L;E++,l++)U[E]=i[l];x+=17+L,(D>>4?y:w)[15&D]=f($,U)}break;case 65501:o=r(i,l+=2),l+=2;break;case 65498:var Z,j=1==++c&&!s;l+=2;var G=i[l++],H=[];for(x=0;x<G;x++){var Q=i[l++],W=a._[Q];(Z=a.W[W]).index=Q;var q=i[l++];Z.J=w[q>>4],Z.i=y[15&q],H.push(Z)}var V=i[l++],Y=i[l++],K=i[l++];try{var J=p(i,l,a,H,o,V,Y,K>>4,15&K,j);l+=J}catch(e){if(e instanceof DNLMarkerError)return this.parse(i,{F:e.s});if(e instanceof EOIMarkerError)break e;throw e}break;case 65500:l+=4;break;case 65535:255!==i[l]&&l--;break;default:var X=g(i,l-2,l-3);if(X&&X.u){l=X.offset;break}if(l>=i.length-1)break e;throw new t("JpegImage.parse - unknown marker: "+v.toString(16))}v=r(i,l),l+=2}for(this.width=a.o,this.height=a.s,this.g=u,this.b=h,this.W=[],x=0;x<a.W.length;x++){var ee=b[(Z=a.W[x]).L];ee&&(Z.$=ee),this.W.push({index:Z.index,e:_(0,Z),l:Z.h/a.X,t:Z.A/a.B,P:Z.P,c:Z.c})}this.p=this.W.length},Y(e,t,i){null==i&&(i=!1);var r,n,a,o,s,l,u,h,c,f,d,p,m=this.width/e,_=this.height/t,g=0,b=this.W.length,y=e*t*b,w=new Uint8ClampedArray(y),v=new Uint32Array(e),x=4294967288;for(u=0;u<b;u++){if(n=(r=this.W[u]).l*m,a=r.t*_,g=u,d=r.e,o=r.P+1<<3,n!==p){for(s=0;s<e;s++)h=0|s*n,v[s]=(h&x)<<3|7&h;p=n}for(l=0;l<t;l++)for(f=o*((h=0|l*a)&x)|(7&h)<<3,s=0;s<e;s++)w[g]=d[f+v[s]],g+=b}var E=this.V;if(i||4!==b||E||(E=new Int32Array([-256,255,-256,255,-256,255,-256,255])),E)for(u=0;u<y;)for(h=0,c=0;h<b;h++,u++,c+=2)w[u]=(w[u]*E[c]>>8)+E[c+1];return w},get f(){return this.b?!!this.b.a:3===this.p?0!==this.N&&(82!==this.W[0].index||71!==this.W[1].index||66!==this.W[2].index):1===this.N},z:function(e){for(var t,i,r,n=0,a=e.length;n<a;n+=3)t=e[n],i=e[n+1],r=e[n+2],e[n]=t-179.456+1.402*r,e[n+1]=t+135.459-.344*i-.714*r,e[n+2]=t-226.816+1.772*i;return e},O:function(e){for(var t,i,r,n,a=0,o=0,s=e.length;o<s;o+=4)t=e[o],i=e[o+1],r=e[o+2],n=e[o+3],e[a++]=i*(-660635669420364e-19*i+.000437130475926232*r-54080610064599e-18*t+.00048449797120281*n-.154362151871126)-122.67195406894+r*(-.000957964378445773*r+.000817076911346625*t-.00477271405408747*n+1.53380253221734)+t*(.000961250184130688*t-.00266257332283933*n+.48357088451265)+n*(-.000336197177618394*n+.484791561490776),e[a++]=107.268039397724+i*(219927104525741e-19*i-.000640992018297945*r+.000659397001245577*t+.000426105652938837*n-.176491792462875)+r*(-.000778269941513683*r+.00130872261408275*t+.000770482631801132*n-.151051492775562)+t*(.00126935368114843*t-.00265090189010898*n+.25802910206845)+n*(-.000318913117588328*n-.213742400323665),e[a++]=i*(-.000570115196973677*i-263409051004589e-19*r+.0020741088115012*t-.00288260236853442*n+.814272968359295)-20.810012546947+r*(-153496057440975e-19*r-.000132689043961446*t+.000560833691242812*n-.195152027534049)+t*(.00174418132927582*t-.00255243321439347*n+.116935020465145)+n*(-.000343531996510555*n+.24165260232407);return e.subarray(0,a)},r:function(e){for(var t,i,r,n=0,a=e.length;n<a;n+=4)t=e[n],i=e[n+1],r=e[n+2],e[n]=434.456-t-1.402*r,e[n+1]=119.541-t+.344*i+.714*r,e[n+2]=481.816-t-1.772*i;return e},U:function(e){for(var t,i,r,n,a=0,o=0,s=e.length;o<s;o+=4)t=e[o],i=e[o+1],r=e[o+2],n=e[o+3],e[a++]=255+t*(-6747147073602441e-20*t+.0008379262121013727*i+.0002894718188643294*r+.003264231057537806*n-1.1185611867203937)+i*(26374107616089405e-21*i-8626949158638572e-20*r-.0002748769067499491*n-.02155688794978967)+r*(-3878099212869363e-20*r-.0003267808279485286*n+.0686742238595345)-n*(.0003361971776183937*n+.7430659151342254),e[a++]=255+t*(.00013596372813588848*t+.000924537132573585*i+.00010567359618683593*r+.0004791864687436512*n-.3109689587515875)+i*(-.00023545346108370344*i+.0002702845253534714*r+.0020200308977307156*n-.7488052167015494)+r*(6834815998235662e-20*r+.00015168452363460973*n-.09751927774728933)-n*(.0003189131175883281*n+.7364883807733168),e[a++]=255+t*(13598650411385307e-21*t+.00012423956175490851*i+.0004751985097583589*r-36729317476630422e-22*n-.05562186980264034)+i*(.00016141380598724676*i+.0009692239130725186*r+.0007782692450036253*n-.44015232367526463)+r*(5.068882914068769e-7*r+.0017778369011375071*n-.7591454649749609)-n*(.0003435319965105553*n+.7063770186160144);return e.subarray(0,a)},getData:function(e){var i=e.width,r=e.height,n=e.forceRGB,a=e.isSourcePDF;if(this.p>4)throw new t("Unsupported color mode");var o=this.Y(i,r,a);if(1===this.p&&n){for(var s=o.length,l=new Uint8ClampedArray(3*s),u=0,h=0;h<s;h++){var c=o[h];l[u++]=c,l[u++]=c,l[u++]=c}return l}if(3===this.p&&this.f)return this.z(o);if(4===this.p){if(this.f)return n?this.O(o):this.r(o);if(n)return this.U(o)}return o}},c}();function r(e,t){return e[t]<<8|e[t+1]}e.JpegDecoder=i}(),e.encodeImage=function(t,i,r,n){var a={t256:[i],t257:[r],t258:[8,8,8,8],t259:[1],t262:[2],t273:[1e3],t277:[4],t278:[r],t279:[i*r*4],t282:[[72,1]],t283:[[72,1]],t284:[1],t286:[[0,1]],t287:[[0,1]],t296:[1],t305:["Photopea (UTIF.js)"],t338:[1]};if(n)for(var o in n)a[o]=n[o];var s=new Uint8Array(e.encode([a])),l=new Uint8Array(t),u=new Uint8Array(1e3+i*r*4);for(o=0;o<s.length;o++)u[o]=s[o];for(o=0;o<l.length;o++)u[1e3+o]=l[o];return u.buffer},e.encode=function(t){var i=new Uint8Array(2e4),r=4,n=e._binBE;i[0]=i[1]=77,n.writeUshort(i,2,42);var a=8;n.writeUint(i,r,a),r+=4;for(var o=0;o<t.length;o++){var s=e._writeIFD(n,e._types.basic,i,a,t[o]);a=s[1],o<t.length-1&&(3&a&&(a+=4-(3&a)),n.writeUint(i,s[0],a))}return i.slice(0,a).buffer},e.decode=function(t,r){null==r&&(r={parseMN:!0,debug:!1});var n=new Uint8Array(t),a=0,o=e._binBE.readASCII(n,a,2);a+=2;var s="II"==o?e._binLE:e._binBE;s.readUshort(n,a),a+=2;var l=s.readUint(n,a);a+=4;for(var u=[];;){var h=s.readUshort(n,l),c=s.readUshort(n,l+4);if(0!=h&&(c<1||13<c)){i("error in TIFF");break}if(e._readIFD(s,n,l,u,0,r),0==(l=s.readUint(n,l+2+12*h)))break}return u},e.decodeImage=function(t,r,n){if(!r.data){var a=new Uint8Array(t),o=e._binBE.readASCII(a,0,2);if(null!=r.t256){r.isLE="II"==o,r.width=r.t256[0],r.height=r.t257[0];var s=r.t259?r.t259[0]:1,l=r.t266?r.t266[0]:1;r.t284&&2==r.t284[0]&&i("PlanarConfiguration 2 should not be used!"),7==s&&r.t258&&r.t258.length>3&&(r.t258=r.t258.slice(0,3));var u=r.t277?r.t277[0]:1,h=(r.t258?r.t258[0]:1)*u;1==s&&null!=r.t279&&r.t278&&32803==r.t262[0]&&(h=Math.round(8*r.t279[0]/(r.width*r.t278[0]))),r.t50885&&4==r.t50885[0]&&(h=3*r.t258[0]);var c=8*Math.ceil(r.width*h/8),f=r.t273;(null==f||r.t322)&&(f=r.t324);var d=r.t279;1==s&&1==f.length&&(d=[r.height*(c>>>3)]),(null==d||r.t322)&&(d=r.t325);var p=new Uint8Array(r.height*(c>>>3)),m=0;if(null!=r.t322){var _=r.t322[0],g=r.t323[0],b=Math.floor((r.width+_-1)/_),y=Math.floor((r.height+g-1)/g),w=new Uint8Array(0|Math.ceil(_*g*h/8));console.log("====",b,y);for(var v=0;v<y;v++)for(var x=0;x<b;x++){var E=v*b+x;w.fill(0),e.decode._decompress(r,n,a,f[E],d[E],s,w,0,l,_,g),6==s?p=w:e._copyTile(w,0|Math.ceil(_*h/8),g,p,0|Math.ceil(r.width*h/8),r.height,0|Math.ceil(x*_*h/8),v*g)}m=8*p.length}else{if(null==f)return;var k=r.t278?r.t278[0]:r.height;k=Math.min(k,r.height);for(E=0;E<f.length;E++)e.decode._decompress(r,n,a,f[E],d[E],s,p,0|Math.ceil(m/8),l,r.width,k),m+=c*k;m=Math.min(m,8*p.length)}r.data=new Uint8Array(p.buffer,0,0|Math.ceil(m/8))}}},e.decode._decompress=function(r,n,a,o,s,l,u,h,c,f,d){if(r.t271&&"Panasonic"==r.t271[0]&&r.t45&&6==r.t45[0]&&(l=34316),1==l)for(var p=0;p<s;p++)u[h+p]=a[o+p];else if(2==l)e.decode._decodeG2(a,o,s,u,h,f,c);else if(3==l)e.decode._decodeG3(a,o,s,u,h,f,c,!!r.t292&&!(1&~r.t292[0]));else if(4==l)e.decode._decodeG4(a,o,s,u,h,f,c);else if(5==l)e.decode._decodeLZW(a,o,s,u,h,8);else if(6==l)e.decode._decodeOldJPEG(r,a,o,s,u,h);else if(7==l||34892==l)e.decode._decodeNewJPEG(r,a,o,s,u,h);else if(8==l||32946==l){var m=new Uint8Array(a.buffer,o+2,s-6),_=t.inflateRaw(m);h+_.length<=u.length&&u.set(_,h)}else 9==l?e.decode._decodeVC5(a,o,s,u,h,r.t33422):32767==l?e.decode._decodeARW(r,a,o,s,u,h):32773==l?e.decode._decodePackBits(a,o,s,u,h):32809==l?e.decode._decodeThunder(a,o,s,u,h):34316==l?e.decode._decodePanasonic(r,a,o,s,u,h):34713==l?e.decode._decodeNikon(r,n,a,o,s,u,h):34676==l?e.decode._decodeLogLuv32(r,a,o,s,u,h):i("Unknown compression",l);var g=r.t258?Math.min(32,r.t258[0]):1,b=r.t277?r.t277[0]:1,y=g*b>>>3,w=Math.ceil(g*b*f/8);if(16==g&&!r.isLE&&null==r.t33422)for(var v=0;v<d;v++)for(var x=h+v*w,E=1;E<w;E+=2){var k=u[x+E];u[x+E]=u[x+E-1],u[x+E-1]=k}if(r.t317&&2==r.t317[0])for(v=0;v<d;v++){var S=h+v*w;if(16==g)for(p=y;p<w;p+=2){var A=(u[S+p+1]<<8|u[S+p])+(u[S+p-y+1]<<8|u[S+p-y]);u[S+p]=255&A,u[S+p+1]=A>>>8&255}else if(3==b)for(p=3;p<w;p+=3)u[S+p]=u[S+p]+u[S+p-3]&255,u[S+p+1]=u[S+p+1]+u[S+p-2]&255,u[S+p+2]=u[S+p+2]+u[S+p-1]&255;else for(p=y;p<w;p++)u[S+p]=u[S+p]+u[S+p-y]&255}},e.decode._decodePanasonic=function(e,t,i,r,n,a){var o,s,l,u,h,c,f,d,p=t.buffer,m=e.t2[0],_=e.t3[0],g=e.t10[0],b=e.t45[0],y=0,w=0,v=0,x=0,E=6==b?new Uint32Array(18):new Uint8Array(16),k=[0,0],S=[0,0],A=0,I=new Uint8Array(16384),M=new Uint16Array(n.buffer);function T(e){if(0==v){var t=new Uint8Array(p,i+w+8184,8200),r=new Uint8Array(p,i+w,8184);I.set(t),I.set(r,t.length),w+=16384}if(5!=b)return(I[x=(v=v-e&131071)>>3^16368]|I[x+1]<<8)>>(7&v)&~(-1<<e);for(o=0;o<16;o++)E[o]=I[v++],v&=16383}function P(e){return I[v+15-e]}function B(){k[0]=0,k[1]=0,S[0]=0,S[1]=0}if(7==b)throw b;if(6==b){var C=12==g,R=C?function(){E[0]=P(0)<<4|P(1)>>4,E[1]=4095&((15&P(1))<<8|P(2)),E[2]=P(3)>>6&3,E[3]=(63&P(3))<<2|P(4)>>6,E[4]=(63&P(4))<<2|P(5)>>6,E[5]=(63&P(5))<<2|P(6)>>6,E[6]=P(6)>>4&3,E[7]=(15&P(6))<<4|P(7)>>4,E[8]=(15&P(7))<<4|P(8)>>4,E[9]=(15&P(8))<<4|P(9)>>4,E[10]=P(9)>>2&3,E[11]=(3&P(9))<<6|P(10)>>2,E[12]=(3&P(10))<<6|P(11)>>2,E[13]=(3&P(11))<<6|P(12)>>2,E[14]=3&P(12),E[15]=P(13),E[16]=P(14),E[17]=P(15),v+=16,x=0}:function(){E[0]=P(0)<<6|P(1)>>2,E[1]=16383&((3&P(1))<<12|P(2)<<4|P(3)>>4),E[2]=P(3)>>2&3,E[3]=(3&P(3))<<8|P(4),E[4]=P(5)<<2|P(6)>>6,E[5]=(63&P(6))<<4|P(7)>>4,E[6]=P(7)>>2&3,E[7]=(3&P(7))<<8|P(8),E[8]=P(9)<<2&1020|P(10)>>6,E[9]=1023&(P(10)<<4|P(11)>>4),E[10]=P(11)>>2&3,E[11]=(3&P(11))<<8|P(12),E[12]=1023&(P(13)<<2&1020|P(14)>>6),E[13]=1023&(P(14)<<4|P(15)>>4),v+=16,x=0},z=C?14:11,F=C?128:512,N=C?2048:8192,O=C?16383:65535,D=C?4095:16383,$=m/z,L=16*$,U=C?18:14;for(c=0;c<_-15;c+=16){var Z=Math.min(16,_-c),j=L*Z;for(I=new Uint8Array(p,i+y,j),v=0,y+=j,d=0,f=0;d<Z;d++,f=0){A=(c+d)*m;for(var G=0;G<$;G++)for(R(),B(),l=0,h=0,o=0;o<z;o++){if(u=1&o,o%3==2){var H=x<U?E[x++]:0;3==H&&(H=4),h=F<<H,l=1<<H}var Q=x<U?E[x++]:0;k[u]?(Q*=l,h<N&&S[u]>h&&(Q+=S[u]-h),S[u]=Q):(k[u]=Q,Q?S[u]=Q:Q=S[u]),M[A+f++]=Q-15<=O?Q-15&O:Q+2147483633>>31&D}}}}else if(5==b){var W=12==g?10:9;for(c=0;c<_;c++)for(f=0;f<m;f+=W)T(0),12==g?(M[A++]=((15&E[1])<<8)+E[0],M[A++]=16*E[2]+(E[1]>>4),M[A++]=((15&E[4])<<8)+E[3],M[A++]=16*E[5]+(E[4]>>4),M[A++]=((15&E[7])<<8)+E[6],M[A++]=16*E[8]+(E[7]>>4),M[A++]=((15&E[10])<<8)+E[9],M[A++]=16*E[11]+(E[10]>>4),M[A++]=((15&E[13])<<8)+E[12],M[A++]=16*E[14]+(E[13]>>4)):14==g&&(M[A++]=E[0]+((63&E[1])<<8),M[A++]=(E[1]>>6)+4*E[2]+((15&E[3])<<10),M[A++]=(E[3]>>4)+16*E[4]+((3&E[5])<<12),M[A++]=((252&E[5])>>2)+(E[6]<<6),M[A++]=E[7]+((63&E[8])<<8),M[A++]=(E[8]>>6)+4*E[9]+((15&E[10])<<10),M[A++]=(E[10]>>4)+16*E[11]+((3&E[12])<<12),M[A++]=((252&E[12])>>2)+(E[13]<<6),M[A++]=E[14]+((63&E[15])<<8))}else{if(4!=b)throw b;for(c=0;c<_;c++)for(f=0;f<m;f++)u=1&(o=f%14),0==o&&B(),o%3==2&&(l=4>>3-T(2)),S[u]?0!=(s=T(8))&&(k[u]-=128<<l,(k[u]<0||4==l)&&(k[u]&=~(-1<<l)),k[u]+=s<<l):(S[u]=T(8),(S[u]||o>11)&&(k[u]=S[u]<<4|T(4))),M[A++]=k[1&f]}},e.decode._decodeVC5=function(){var t,i,r,n=[1,0,1,0,2,2,1,1,3,7,1,2,5,25,1,3,6,48,1,4,6,54,1,5,7,111,1,8,7,99,1,6,7,105,12,0,7,107,1,7,8,209,20,0,8,212,1,9,8,220,1,10,9,393,1,11,9,394,32,0,9,416,1,12,9,427,1,13,10,887,1,18,10,784,1,14,10,790,1,15,10,835,60,0,10,852,1,16,10,885,1,17,11,1571,1,19,11,1668,1,20,11,1669,100,0,11,1707,1,21,11,1772,1,22,12,3547,1,29,12,3164,1,24,12,3166,1,25,12,3140,1,23,12,3413,1,26,12,3537,1,27,12,3539,1,28,13,7093,1,35,13,6283,1,30,13,6331,1,31,13,6335,180,0,13,6824,1,32,13,7072,1,33,13,7077,320,0,13,7076,1,34,14,12565,1,36,14,12661,1,37,14,12669,1,38,14,13651,1,39,14,14184,1,40,15,28295,1,46,15,28371,1,47,15,25320,1,42,15,25336,1,43,15,25128,1,41,15,27300,1,44,15,28293,1,45,16,50259,1,48,16,50643,1,49,16,50675,1,50,16,56740,1,53,16,56584,1,51,16,56588,1,52,17,113483,1,61,17,113482,1,60,17,101285,1,55,17,101349,1,56,17,109205,1,57,17,109207,1,58,17,100516,1,54,17,113171,1,59,18,202568,1,62,18,202696,1,63,18,218408,1,64,18,218412,1,65,18,226340,1,66,18,226356,1,67,18,226358,1,68,19,402068,1,69,19,405138,1,70,19,405394,1,71,19,436818,1,72,19,436826,1,73,19,452714,1,75,19,452718,1,76,19,452682,1,74,20,804138,1,77,20,810279,1,78,20,810790,1,79,20,873638,1,80,20,873654,1,81,20,905366,1,82,20,905430,1,83,20,905438,1,84,21,1608278,1,85,21,1620557,1,86,21,1621582,1,87,21,1621583,1,88,21,1747310,1,89,21,1810734,1,90,21,1810735,1,91,21,1810863,1,92,21,1810879,1,93,22,3621725,1,99,22,3621757,1,100,22,3241112,1,94,22,3494556,1,95,22,3494557,1,96,22,3494622,1,97,22,3494623,1,98,23,6482227,1,102,23,6433117,1,101,23,6989117,1,103,23,6989119,1,105,23,6989118,1,104,23,7243449,1,106,23,7243512,1,107,24,13978233,1,111,24,12964453,1,109,24,12866232,1,108,24,14486897,1,113,24,13978232,1,110,24,14486896,1,112,24,14487026,1,114,24,14487027,1,115,25,25732598,1,225,25,25732597,1,189,25,25732596,1,188,25,25732595,1,203,25,25732594,1,202,25,25732593,1,197,25,25732592,1,207,25,25732591,1,169,25,25732590,1,223,25,25732589,1,159,25,25732522,1,235,25,25732579,1,152,25,25732575,1,192,25,25732489,1,179,25,25732573,1,201,25,25732472,1,172,25,25732576,1,149,25,25732488,1,178,25,25732566,1,120,25,25732571,1,219,25,25732577,1,150,25,25732487,1,127,25,25732506,1,211,25,25732548,1,125,25,25732588,1,158,25,25732486,1,247,25,25732467,1,238,25,25732508,1,163,25,25732552,1,228,25,25732603,1,183,25,25732513,1,217,25,25732587,1,168,25,25732520,1,122,25,25732484,1,128,25,25732562,1,249,25,25732505,1,187,25,25732504,1,186,25,25732483,1,136,25,25928905,1,181,25,25732560,1,255,25,25732500,1,230,25,25732482,1,135,25,25732555,1,233,25,25732568,1,222,25,25732583,1,145,25,25732481,1,134,25,25732586,1,167,25,25732521,1,248,25,25732518,1,209,25,25732480,1,243,25,25732512,1,216,25,25732509,1,164,25,25732547,1,140,25,25732479,1,157,25,25732544,1,239,25,25732574,1,191,25,25732564,1,251,25,25732478,1,156,25,25732546,1,139,25,25732498,1,242,25,25732557,1,133,25,25732477,1,162,25,25732515,1,213,25,25732584,1,165,25,25732514,1,212,25,25732476,1,227,25,25732494,1,198,25,25732531,1,236,25,25732530,1,234,25,25732529,1,117,25,25732528,1,215,25,25732527,1,124,25,25732526,1,123,25,25732525,1,254,25,25732524,1,253,25,25732523,1,148,25,25732570,1,218,25,25732580,1,146,25,25732581,1,147,25,25732569,1,224,25,25732533,1,143,25,25732540,1,184,25,25732541,1,185,25,25732585,1,166,25,25732556,1,132,25,25732485,1,129,25,25732563,1,250,25,25732578,1,151,25,25732501,1,119,25,25732502,1,193,25,25732536,1,176,25,25732496,1,245,25,25732553,1,229,25,25732516,1,206,25,25732582,1,144,25,25732517,1,208,25,25732558,1,137,25,25732543,1,241,25,25732466,1,237,25,25732507,1,190,25,25732542,1,240,25,25732551,1,131,25,25732554,1,232,25,25732565,1,252,25,25732475,1,171,25,25732493,1,205,25,25732492,1,204,25,25732491,1,118,25,25732490,1,214,25,25928904,1,180,25,25732549,1,126,25,25732602,1,182,25,25732539,1,175,25,25732545,1,141,25,25732559,1,138,25,25732537,1,177,25,25732534,1,153,25,25732503,1,194,25,25732606,1,160,25,25732567,1,121,25,25732538,1,174,25,25732497,1,246,25,25732550,1,130,25,25732572,1,200,25,25732474,1,170,25,25732511,1,221,25,25732601,1,196,25,25732532,1,142,25,25732519,1,210,25,25732495,1,199,25,25732605,1,155,25,25732535,1,154,25,25732499,1,244,25,25732510,1,220,25,25732600,1,195,25,25732607,1,161,25,25732604,1,231,25,25732473,1,173,25,25732599,1,226,26,51465122,1,116,26,51465123,0,1],a=[3,3,3,3,2,2,2,1,1,1];function o(e){var t=e[1],i=e[0][t>>>3]>>>7-(7&t)&1;return e[1]++,i}function s(e,i){if(null==t){t={};for(var r=0;r<n.length;r+=4)t[n[r+1]]=n.slice(r,r+4)}for(var a=o(e),s=t[a];null==s;)a=a<<1|o(e),s=t[a];var l=s[3];0!=l&&(l=0==o(e)?l:-l),i[0]=s[2],i[1]=l}function l(e,t){for(var i=0;i<t;i++)1&~e||e++,e>>>=1;return e}function u(e,t){return e>>t}function h(e,t,i,r,n,a){t[i]=u(u(11*e[n]-4*e[n+a]+e[n+a+a]+4,3)+e[r],1),t[i+a]=u(u(5*e[n]+4*e[n+a]-e[n+a+a]+4,3)-e[r],1)}function c(e,t,i,r,n,a){var o=e[n-a]-e[n+a],s=e[n],l=e[r];t[i]=u(u(o+4,3)+s+l,1),t[i+a]=u(u(4-o,3)+s-l,1)}function f(e,t,i,r,n,a){t[i]=u(u(5*e[n]+4*e[n-a]-e[n-a-a]+4,3)+e[r],1),t[i+a]=u(u(11*e[n]-4*e[n-a]+e[n-a-a]+4,3)-e[r],1)}function d(e){return e=r[e=e<0?0:e>4095?4095:e]>>>2}return function(t,n,o,u,p,m){u=new Uint16Array(u.buffer);var _,g,b,y,w,v,x,E,k=Date.now(),S=e._binBE,A=n+o;n+=4;for(var I=1==m[0];n<A;){var M=S.readShort(t,n),T=S.readUshort(t,n+2);if(n+=4,12==M)N=T;else if(20==M)_=T;else if(21==M)g=T;else if(48==M)b=T;else if(53==M)y=T;else if(35==M);else if(62==M)w=T;else if(101==M);else if(109==M)v=T;else if(84==M);else if(106==M);else if(107==M);else if(108==M);else if(102==M);else if(104==M)ie=T;else if(105==M);else{var P=M<0?-M:M,B=65280&P,C=0;if(24576&P&&(8192&P?(C=65535&T,C+=(255&P)<<16):C=65535&T),24576&~P){if(16388==P)n+=4*C;else if(8192!=B&&8448!=B&&9216!=B)throw P.toString(16)}else{if(null==x){x=[];for(var R=0;R<4;R++)x[R]=new Int16Array((_>>>1)*(g>>>1));E=new Int16Array((_>>>1)*(g>>>1)),i=new Int16Array(1024);for(R=0;R<1024;R++){var z=R-512,F=Math.abs(z),N=Math.floor(768*F*F*F/16581375)+F;i[R]=Math.sign(z)*N}r=new Uint16Array(4096);for(R=0;R<4096;R++){var O=R,D=65535*(Math.pow(113,O/4095)-1)/112;r[R]=Math.min(D,65535)}}var $=x[w],L=l(_,1+a[b]),U=l(g,1+a[b]);if(0==b)for(var Z=0;Z<U;Z++)for(var j=0;j<L;j++){var G=n+2*(Z*L+j);$[Z*(_>>>1)+j]=t[G]<<8|t[G+1]}else{var H=[t,8*n],Q=[],W=0,q=L*U,V=[0,0],Y=0;for(T=0;W<q;)for(s(H,V),Y=V[0],T=V[1];Y>0;)Q[W++]=T,Y--;var K=(b-1)%3,J=1!=K?L:0,X=0!=K?U:0;for(Z=0;Z<U;Z++){var ee=(Z+X)*(_>>>1)+J,te=Z*L;for(j=0;j<L;j++)$[ee+j]=i[Q[te+j]+512]*y}if(2==K){var ie=_>>>1,re=2*L,ne=2*U;for(Z=0;Z<U;Z++)for(j=0;j<re;j++){R=2*Z*ie+j;var ae=U*ie+(se=Z*ie+j);0==Z?h($,E,R,ae,se,ie):Z==U-1?f($,E,R,ae,se,ie):c($,E,R,ae,se,ie)}var oe=$;$=E,E=oe;for(Z=0;Z<ne;Z++)for(j=0;j<L;j++){var se;R=Z*ie+2*j,ae=L+(se=Z*ie+j);0==j?h($,E,R,ae,se,1):j==L-1?f($,E,R,ae,se,1):c($,E,R,ae,se,1)}oe=$;$=E,E=oe;for(var le=[],ue=2-~~((b-1)/3),he=0;he<3;he++)le[he]=v>>14-2*he&3;var ce=le[ue];if(0!=ce)for(Z=0;Z<ne;Z++)for(j=0;j<re;j++){$[R=Z*ie+j]=$[R]<<ce}}}if(9==b&&3==w){var fe=x[0],de=x[1],pe=x[2],me=x[3];for(Z=0;Z<g;Z+=2)for(j=0;j<_;j+=2){var _e=Z*_+j,ge=fe[G=(Z>>>1)*(_>>>1)+(j>>>1)],be=de[G]-2048,ye=pe[G]-2048,we=me[G]-2048,ve=(be<<1)+ge,xe=(ye<<1)+ge,Ee=ge+we,ke=ge-we;I?(u[_e]=d(Ee),u[_e+1]=d(xe),u[_e+_]=d(ve),u[_e+_+1]=d(ke)):(u[_e]=d(ve),u[_e+1]=d(Ee),u[_e+_]=d(ke),u[_e+_+1]=d(xe))}}n+=4*C}}}console.log(Date.now()-k)}}(),e.decode._decodeLogLuv32=function(e,t,i,r,n,a){for(var o=e.width,s=4*o,l=0,u=new Uint8Array(s);l<r;){for(var h=0;h<s;){var c=t[i+l];if(l++,c<128){for(var f=0;f<c;f++)u[h+f]=t[i+l+f];h+=c,l+=c}else{c-=126;for(f=0;f<c;f++)u[h+f]=t[i+l];h+=c,l++}}for(var d=0;d<o;d++)n[a+0]=u[d],n[a+1]=u[d+o],n[a+2]=u[d+2*o],n[a+4]=u[d+3*o],a+=6}},e.decode._ljpeg_diff=function(t,i,r){var n,a,o=e.decode._getbithuff;return n=o(t,i,r[0],r),(a=o(t,i,n,0))&1<<n-1||(a-=(1<<n)-1),a},e.decode._decodeARW=function(t,i,r,n,a,o){var s=t.t256[0],l=t.t257[0],u=t.t258[0],h=t.isLE?e._binLE:e._binBE;if(s*l==n||s*l*1.5==n)if(s*l*1.5!=n){var c,f,d,p,m,_,g,b,y=new Uint16Array(16),w=new Uint8Array(s+1);for(M=0;M<l;M++){for(var v=0;v<s;v++)w[v]=i[r++];for(b=0,I=0;I<s-30;b+=16){for(f=2047&(c=h.readUint(w,b)),d=2047&c>>>11,p=15&c>>>22,m=15&c>>>26,_=0;_<4&&128<<_<=f-d;_++);for(g=30,x=0;x<16;x++)x==p?y[x]=f:x==m?y[x]=d:(y[x]=((h.readUshort(w,b+(g>>3))>>>(7&g)&127)<<_)+d,y[x]>2047&&(y[x]=2047),g+=7);for(x=0;x<16;x++,I+=2){N=y[x]<<1;e.decode._putsF(a,(M*s+I)*u,N<<16-u)}I-=1&I?1:31}}}else for(var x=0;x<n;x+=3){var E=i[r+x+0],k=i[r+x+1],S=i[r+x+2];a[o+x]=k<<4|E>>>4,a[o+x+1]=E<<4|S>>>4,a[o+x+2]=S<<4|k>>>4}else{l+=8;var A,I,M,T=[r,0,0,0],P=new Uint16Array(32770),B=[3857,3856,3599,3342,3085,2828,2571,2314,2057,1800,1543,1286,1029,772,771,768,514,513],C=0,R=e.decode._ljpeg_diff;for(P[0]=15,A=x=0;x<18;x++)for(var z=32768>>>(B[x]>>>8),F=0;F<z;F++)P[++A]=B[x];for(I=s;I--;)for(M=0;M<l+1;M+=2)if(M==l&&(M=1),C+=R(i,T,P),M<l){var N=4095&C;e.decode._putsF(a,(M*s+I)*u,N<<16-u)}}},e.decode._decodeNikon=function(t,i,r,n,a,o,s){var l=[[0,0,1,5,1,1,1,1,1,1,2,0,0,0,0,0,0,5,4,3,6,2,7,1,0,8,9,11,10,12],[0,0,1,5,1,1,1,1,1,1,2,0,0,0,0,0,0,57,90,56,39,22,5,4,3,2,1,0,11,12,12],[0,0,1,4,2,3,1,2,0,0,0,0,0,0,0,0,0,5,4,6,3,7,2,8,1,9,0,10,11,12],[0,0,1,4,3,1,1,1,1,1,2,0,0,0,0,0,0,5,6,4,7,8,3,9,2,1,0,10,11,12,13,14],[0,0,1,5,1,1,1,1,1,1,1,2,0,0,0,0,0,8,92,75,58,41,7,6,5,4,3,2,1,0,13,14],[0,0,1,4,2,2,3,1,2,0,0,0,0,0,0,0,0,7,6,8,5,9,4,10,3,11,12,2,0,1,13,14]],u=t.t256[0],h=t.t257[0],c=t.t258[0],f=0,d=0,p=e.decode._make_decoder,m=e.decode._getbithuff,_=i[0].exifIFD.makerNote,g=_.t150?_.t150:_.t140,b=0,y=g[b++],w=g[b++];73!=y&&88!=w||(b+=2110),70==y&&(f=2),14==c&&(f+=3);for(var v=[[0,0],[0,0]],x=t.isLE?e._binLE:e._binBE,E=0;E<2;E++)for(var k=0;k<2;k++)v[E][k]=x.readShort(g,b),b+=2;var S,A,I,M,T,P=1<<c&32767,B=0,C=x.readShort(g,b);b+=2,C>1&&(B=Math.floor(P/(C-1))),68==y&&32==w&&B>0&&(d=x.readShort(g,562));var R=[0,0],z=p(l[f]),F=[n,0,0,0];for(S=0;S<h;S++)for(d&&S==d&&(z=p(l[f+1])),A=0;A<u;A++){E=m(r,F,z[0],z),(T=1+(m(r,F,(I=15&E)-(M=E>>>4),0)<<1)<<M>>>1)&1<<I-1||(T-=(1<<I)-(0==M?1:0)),A<2?R[A]=v[1&S][A]+=T:R[1&A]+=T;var N=Math.min(Math.max(R[1&A],0),(1<<c)-1),O=(S*u+A)*c;e.decode._putsF(o,O,N<<16-c)}},e.decode._putsF=function(e,t,i){i<<=8-(7&t);var r=t>>>3;e[r]|=i>>>16,e[r+1]|=i>>>8,e[r+2]|=i},e.decode._getbithuff=function(t,i,r,n){var a;e.decode._get_byte;var o=i[0],s=i[1],l=i[2],u=i[3];if(0==r||l<0)return 0;for(;!u&&l<r&&-1!=(a=t[o++])&&!(u=0);)s=(s<<8)+a,l+=8;if(a=s<<32-l>>>32-r,n?(l-=n[a+1]>>>8,a=255&n[a+1]):l-=r,l<0)throw"e";return i[0]=o,i[1]=s,i[2]=l,i[3]=u,a},e.decode._make_decoder=function(e){var t,i,r,n,a,o=[];for(t=16;0!=t&&!e[t];t--);var s=17;for(o[0]=t,r=i=1;i<=t;i++)for(n=0;n<e[i];n++,++s)for(a=0;a<1<<t-i;a++)r<=1<<t&&(o[r++]=i<<8|e[s]);return o},e.decode._decodeNewJPEG=function(t,i,r,n,a,o){n=Math.min(n,i.length-r);var s=t.t347,l=s?s.length:0,u=new Uint8Array(l+n);if(s){for(var h=0,c=0;c<l-1&&(255!=s[c]||217!=s[c+1]);c++)u[h++]=s[c];var f=i[r],d=i[r+1];255==f&&216==d||(u[h++]=f,u[h++]=d);for(c=2;c<n;c++)u[h++]=i[r+c]}else for(c=0;c<n;c++)u[c]=i[r+c];if(32803==t.t262[0]||7==t.t259[0]&&34892==t.t262[0]){var p=t.t258[0],m=e.LosslessJpegDecode(u),_=m.length;if(16==p)if(t.isLE)for(c=0;c<_;c++)a[o+(c<<1)]=255&m[c],a[o+(c<<1)+1]=m[c]>>>8;else for(c=0;c<_;c++)a[o+(c<<1)]=m[c]>>>8,a[o+(c<<1)+1]=255&m[c];else if(14==p||12==p||10==p){var g=16-p;for(c=0;c<_;c++)e.decode._putsF(a,c*p,m[c]<<g)}else{if(8!=p)throw new Error("unsupported bit depth "+p);for(c=0;c<_;c++)a[o+c]=m[c]}}else{var b=new e.JpegDecoder;b.parse(u);var y=b.getData({width:b.width,height:b.height,forceRGB:!0,isSourcePDF:!1});for(c=0;c<y.length;c++)a[o+c]=y[c]}6==t.t262[0]&&(t.t262[0]=2)},e.decode._decodeOldJPEGInit=function(e,t,r,n){var a,o,s,l,u,h=216,c=0,f=0,d=!1,p=e.t513,m=p?p[0]:0,_=e.t514,g=_?_[0]:0,b=e.t324||e.t273||p,y=e.t530,w=0,v=0,x=e.t277?e.t277[0]:1,E=e.t515;if(b&&(f=b[0],d=b.length>1),!d){if(255==t[r]&&t[r+1]==h)return{jpegOffset:r};if(null!=p&&(255==t[r+m]&&t[r+m+1]==h?c=r+m:i("JPEGInterchangeFormat does not point to SOI"),null==_?i("JPEGInterchangeFormatLength field is missing"):(m>=f||m+g<=f)&&i("JPEGInterchangeFormatLength field value is invalid"),null!=c))return{jpegOffset:c}}if(null!=y&&(w=y[0],v=y[1]),null!=p&&null!=_)if(g>=2&&m+g<=f){for(a=255==t[r+m+g-2]&&t[r+m+g-1]==h?new Uint8Array(g-2):new Uint8Array(g),s=0;s<a.length;s++)a[s]=t[r+m+s];i("Incorrect JPEG interchange format: using JPEGInterchangeFormat offset to derive tables")}else i("JPEGInterchangeFormat+JPEGInterchangeFormatLength > offset to first strip or tile");if(null==a){var k=0,S=[];S[k++]=255,S[k++]=h;var A=e.t519;if(null==A)throw new Error("JPEGQTables tag is missing");for(s=0;s<A.length;s++)for(S[k++]=255,S[k++]=219,S[k++]=0,S[k++]=67,S[k++]=s,l=0;l<64;l++)S[k++]=t[r+A[s]+l];for(u=0;u<2;u++){var I=e[0==u?"t520":"t521"];if(null==I)throw new Error((0==u?"JPEGDCTables":"JPEGACTables")+" tag is missing");for(s=0;s<I.length;s++){S[k++]=255,S[k++]=196;var M=19;for(l=0;l<16;l++)M+=t[r+I[s]+l];for(S[k++]=M>>>8,S[k++]=255&M,S[k++]=s|u<<4,l=0;l<16;l++)S[k++]=t[r+I[s]+l];for(l=0;l<M;l++)S[k++]=t[r+I[s]+16+l]}}if(S[k++]=255,S[k++]=192,S[k++]=0,S[k++]=8+3*x,S[k++]=8,S[k++]=e.height>>>8&255,S[k++]=255&e.height,S[k++]=e.width>>>8&255,S[k++]=255&e.width,S[k++]=x,1==x)S[k++]=1,S[k++]=17,S[k++]=0;else for(s=0;s<3;s++)S[k++]=s+1,S[k++]=0!=s?17:(15&w)<<4|15&v,S[k++]=s;null!=E&&0!=E[0]&&(S[k++]=255,S[k++]=221,S[k++]=0,S[k++]=4,S[k++]=E[0]>>>8&255,S[k++]=255&E[0]),a=new Uint8Array(S)}var T=-1;for(s=0;s<a.length-1;){if(255==a[s]&&192==a[s+1]){T=s;break}s++}if(-1==T){var P=new Uint8Array(a.length+10+3*x);P.set(a);var B=a.length;if(T=a.length,(a=P)[B++]=255,a[B++]=192,a[B++]=0,a[B++]=8+3*x,a[B++]=8,a[B++]=e.height>>>8&255,a[B++]=255&e.height,a[B++]=e.width>>>8&255,a[B++]=255&e.width,a[B++]=x,1==x)a[B++]=1,a[B++]=17,a[B++]=0;else for(s=0;s<3;s++)a[B++]=s+1,a[B++]=0!=s?17:(15&w)<<4|15&v,a[B++]=s}if(255==t[f]&&218==t[f+1]){var C=t[f+2]<<8|t[f+3];for((o=new Uint8Array(C+2))[0]=t[f],o[1]=t[f+1],o[2]=t[f+2],o[3]=t[f+3],s=0;s<C-2;s++)o[s+4]=t[f+s+4]}else{var R=0;if((o=new Uint8Array(8+2*x))[R++]=255,o[R++]=218,o[R++]=0,o[R++]=6+2*x,o[R++]=x,1==x)o[R++]=1,o[R++]=0;else for(s=0;s<3;s++)o[R++]=s+1,o[R++]=s<<4|s;o[R++]=0,o[R++]=63,o[R++]=0}return{jpegOffset:r,tables:a,sosMarker:o,sofPosition:T}},e.decode._decodeOldJPEG=function(t,i,r,n,a,o){var s,l,u,h,c=e.decode._decodeOldJPEGInit(t,i,r,n);if(null!=c.jpegOffset)for(s=r+n-c.jpegOffset,u=new Uint8Array(s),p=0;p<s;p++)u[p]=i[c.jpegOffset+p];else{for(l=c.tables.length,(u=new Uint8Array(l+c.sosMarker.length+n+2)).set(c.tables),h=l,u[c.sofPosition+5]=t.height>>>8&255,u[c.sofPosition+6]=255&t.height,u[c.sofPosition+7]=t.width>>>8&255,u[c.sofPosition+8]=255&t.width,255==i[r]&&i[r+1]==SOS||(u.set(c.sosMarker,h),h+=sosMarker.length),p=0;p<n;p++)u[h++]=i[r+p];u[h++]=255,u[h++]=EOI}var f=new e.JpegDecoder;f.parse(u);for(var d=f.getData({width:f.width,height:f.height,forceRGB:!0,isSourcePDF:!1}),p=0;p<d.length;p++)a[o+p]=d[p];t.t262&&6==t.t262[0]&&(t.t262[0]=2)},e.decode._decodePackBits=function(e,t,i,r,n){for(var a=new Int8Array(e.buffer),o=new Int8Array(r.buffer),s=t+i;t<s;){var l=a[t];if(t++,l>=0&&l<128)for(var u=0;u<l+1;u++)o[n]=a[t],n++,t++;if(l>=-127&&l<0){for(u=0;u<1-l;u++)o[n]=a[t],n++;t++}}return n},e.decode._decodeThunder=function(e,t,i,r,n){for(var a=[0,1,0,-1],o=[0,1,2,3,0,-3,-2,-1],s=t+i,l=2*n,u=0;t<s;){var h=e[t],c=h>>>6,f=63&h;if(t++,3==c&&(u=15&f,r[l>>>1]|=u<<4*(1-l&1),l++),0==c)for(var d=0;d<f;d++)r[l>>>1]|=u<<4*(1-l&1),l++;if(2==c)for(d=0;d<2;d++){4!=(p=f>>>3*(1-d)&7)&&(u+=o[p],r[l>>>1]|=u<<4*(1-l&1),l++)}if(1==c)for(d=0;d<3;d++){var p;2!=(p=f>>>2*(2-d)&3)&&(u+=a[p],r[l>>>1]|=u<<4*(1-l&1),l++)}}},e.decode._dmap={1:0,"011":1,"000011":2,"0000011":3,"010":-1,"000010":-2,"0000010":-3},e.decode._lens=function(){var e=function(e,t,i,r){for(var n=0;n<t.length;n++)e[t[n]]=i+n*r},t="00110101,000111,0111,1000,1011,1100,1110,1111,10011,10100,00111,01000,001000,000011,110100,110101,101010,101011,0100111,0001100,0001000,0010111,0000011,0000100,0101000,0101011,0010011,0100100,0011000,00000010,00000011,00011010,00011011,00010010,00010011,00010100,00010101,00010110,00010111,00101000,00101001,00101010,00101011,00101100,00101101,00000100,00000101,00001010,00001011,01010010,01010011,01010100,01010101,00100100,00100101,01011000,01011001,01011010,01011011,01001010,01001011,00110010,00110011,00110100",i="0000110111,010,11,10,011,0011,0010,00011,000101,000100,0000100,0000101,0000111,00000100,00000111,000011000,0000010111,0000011000,0000001000,00001100111,00001101000,00001101100,00000110111,00000101000,00000010111,00000011000,000011001010,000011001011,000011001100,000011001101,000001101000,000001101001,000001101010,000001101011,000011010010,000011010011,000011010100,000011010101,000011010110,000011010111,000001101100,000001101101,000011011010,000011011011,000001010100,000001010101,000001010110,000001010111,000001100100,000001100101,000001010010,000001010011,000000100100,000000110111,000000111000,000000100111,000000101000,000001011000,000001011001,000000101011,000000101100,000001011010,000001100110,000001100111",r="11011,10010,010111,0110111,00110110,00110111,01100100,01100101,01101000,01100111,011001100,011001101,011010010,011010011,011010100,011010101,011010110,011010111,011011000,011011001,011011010,011011011,010011000,010011001,010011010,011000,010011011",n="0000001111,000011001000,000011001001,000001011011,000000110011,000000110100,000000110101,0000001101100,0000001101101,0000001001010,0000001001011,0000001001100,0000001001101,0000001110010,0000001110011,0000001110100,0000001110101,0000001110110,0000001110111,0000001010010,0000001010011,0000001010100,0000001010101,0000001011010,0000001011011,0000001100100,0000001100101",a="00000001000,00000001100,00000001101,000000010010,000000010011,000000010100,000000010101,000000010110,000000010111,000000011100,000000011101,000000011110,000000011111";t=t.split(","),i=i.split(","),r=r.split(","),n=n.split(","),a=a.split(",");var o={},s={};return e(o,t,0,1),e(o,r,64,64),e(o,a,1792,64),e(s,i,0,1),e(s,n,64,64),e(s,a,1792,64),[o,s]}(),e.decode._decodeG4=function(t,i,r,n,a,o,s){for(var l=e.decode,u=i<<3,h=0,c="",f=[],d=[],p=0;p<o;p++)d.push(0);d=l._makeDiff(d);for(var m=0,_=0,g=0,b=0,y=0,w=0,v="",x=0,E=8*Math.ceil(o/8);u>>>3<i+r;){g=l._findDiff(d,m+(0==m?0:1),1-y),b=l._findDiff(d,g,y);var k=0;if(1==s&&(k=t[u>>>3]>>>7-(7&u)&1),2==s&&(k=t[u>>>3]>>>(7&u)&1),u++,c+=k,"H"==v){if(null!=l._lens[y][c]){var S=l._lens[y][c];c="",h+=S,S<64&&(l._addNtimes(f,h,y),m+=h,y=1-y,h=0,0==--x&&(v=""))}}else"0001"==c&&(c="",l._addNtimes(f,b-m,y),m=b),"001"==c&&(c="",v="H",x=2),null!=l._dmap[c]&&(_=g+l._dmap[c],l._addNtimes(f,_-m,y),m=_,c="",y=1-y);f.length==o&&""==v&&(l._writeBits(f,n,8*a+w*E),y=0,w++,m=0,d=l._makeDiff(f),f=[])}},e.decode._findDiff=function(e,t,i){for(var r=0;r<e.length;r+=2)if(e[r]>=t&&e[r+1]==i)return e[r]},e.decode._makeDiff=function(e){var t=[];1==e[0]&&t.push(0,1);for(var i=1;i<e.length;i++)e[i-1]!=e[i]&&t.push(i,e[i]);return t.push(e.length,0,e.length,1),t},e.decode._decodeG2=function(t,i,r,n,a,o,s){for(var l=e.decode,u=i<<3,h=0,c="",f=[],d=0,p=0,m=8*Math.ceil(o/8);u>>>3<i+r;){var _=0;1==s&&(_=t[u>>>3]>>>7-(7&u)&1),2==s&&(_=t[u>>>3]>>>(7&u)&1),u++,c+=_,null!=(h=l._lens[d][c])&&(l._addNtimes(f,h,d),c="",h<64&&(d=1-d),f.length==o&&(l._writeBits(f,n,8*a+p*m),f=[],p++,d=0,7&u&&(u+=8-(7&u)),h>=64&&(u+=8)))}},e.decode._decodeG3=function(t,i,r,n,a,o,s,l){for(var u=e.decode,h=i<<3,c=0,f="",d=[],p=[],m=0;m<o;m++)d.push(0);for(var _=0,g=0,b=0,y=0,w=0,v=-1,x="",E=0,k=!0,S=8*Math.ceil(o/8);h>>>3<i+r;){b=u._findDiff(p,_+(0==_?0:1),1-w),y=u._findDiff(p,b,w);var A=0;if(1==s&&(A=t[h>>>3]>>>7-(7&h)&1),2==s&&(A=t[h>>>3]>>>(7&h)&1),h++,f+=A,k){if(null!=u._lens[w][f]){var I=u._lens[w][f];f="",c+=I,I<64&&(u._addNtimes(d,c,w),w=1-w,c=0)}}else if("H"==x){if(null!=u._lens[w][f]){I=u._lens[w][f];f="",c+=I,I<64&&(u._addNtimes(d,c,w),_+=c,w=1-w,c=0,0==--E&&(x=""))}}else"0001"==f&&(f="",u._addNtimes(d,y-_,w),_=y),"001"==f&&(f="",x="H",E=2),null!=u._dmap[f]&&(g=b+u._dmap[f],u._addNtimes(d,g-_,w),_=g,f="",w=1-w);f.endsWith("000000000001")&&(v>=0&&u._writeBits(d,n,8*a+v*S),l&&(1==s&&(k=1==(t[h>>>3]>>>7-(7&h)&1)),2==s&&(k=1==(t[h>>>3]>>>(7&h)&1)),h++),f="",w=0,v++,_=0,p=u._makeDiff(d),d=[])}d.length==o&&u._writeBits(d,n,8*a+v*S)},e.decode._addNtimes=function(e,t,i){for(var r=0;r<t;r++)e.push(i)},e.decode._writeBits=function(e,t,i){for(var r=0;r<e.length;r++)t[i+r>>>3]|=e[r]<<7-(i+r&7)},e.decode._decodeLZW=e.decode._decodeLZW=function(){var e,t,i,r,n=0,a=0,o=0,s=0,l=function(){var i=e>>>3,r=(t[i]<<16|t[i+1]<<8|t[i+2])>>>24-(7&e)-a&(1<<a)-1;return e+=a,r},u=new Uint32Array(16384),h=0,c=function(e){a=e+1,n=s+1},f=function(e){for(var t=e<<2,n=u[t+2],a=r+n-1;65535!=t;)i[a--]=u[t],t=u[t+1];r+=n},d=function(e,t){var i=n<<2,r=e<<2;u[i]=u[3+(t<<2)],u[i+1]=r,u[i+2]=u[r+2]+1,u[i+3]=u[r+3],++n+1==1<<a&&12!=a&&a++};return function(a,p,m,_,g,b){e=p<<3,t=a,i=_,r=g;var y=p+m<<3,w=0,v=0;for(!function(e){if(e!=h){h=e,s=1+(o=1<<e);for(var t=0;t<s+1;t++)u[4*t]=u[4*t+3]=t,u[4*t+1]=65535,u[4*t+2]=1}}(b),c(b);e<y&&(w=l())!=s;){if(w==o){if(c(b),(w=l())==s)break;f(w)}else w<n?(f(w),d(v,w)):(d(v,v),f(n-1));v=w}return r}}(),e.tags={},e._types=function(){var e=new Array(250);e.fill(0);return{basic:{main:e=e.concat([0,0,0,0,4,3,3,3,3,3,0,0,3,0,0,0,3,0,0,2,2,2,2,4,3,0,0,3,4,4,3,3,5,5,3,2,5,5,0,0,0,0,4,4,0,0,3,3,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,2,2,3,5,5,3,0,3,3,4,4,4,3,4,0,0,0,0,0,0,0,0,0,3,3,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),rest:{33432:2,33434:5,33437:5,34665:4,34850:3,34853:4,34855:3,34864:3,34866:4,36864:7,36867:2,36868:2,37121:7,37377:10,37378:5,37380:10,37381:5,37383:3,37384:3,37385:3,37386:5,37510:7,37520:2,37521:2,37522:2,40960:7,40961:3,40962:4,40963:4,40965:4,41486:5,41487:5,41488:3,41985:3,41986:3,41987:3,41988:5,41989:3,41990:3,41993:3,41994:3,41995:7,41996:3,42032:2,42033:2,42034:5,42036:2,42037:2,59932:7}},gps:{main:[1,2,5,2,5,1,5,5,0,9],rest:{18:2,29:2}}}}(),e._readIFD=function(t,r,n,a,o,s){var l=t.readUshort(r,n);n+=2;var u={};s.debug&&i(" ".repeat(o),a.length-1,">>>----------------");for(var h=0;h<l;h++){var c=t.readUshort(r,n);n+=2;var f=t.readUshort(r,n);n+=2;var d=t.readUint(r,n);n+=4;var p=t.readUint(r,n);n+=4;var m=[];if(1==f||7==f){var _=d<5?n-4:p;_+d>r.buffer.byteLength&&(d=r.buffer.byteLength-_),m=new Uint8Array(r.buffer,_,d)}if(2==f){var g=d<5?n-4:p,b=r[g],y=Math.max(0,Math.min(d-1,r.length-g));b<128||0==y?m.push(t.readASCII(r,g,y)):m=new Uint8Array(r.buffer,g,y)}if(3==f)for(var w=0;w<d;w++)m.push(t.readUshort(r,(d<3?n-4:p)+2*w));if(4==f||13==f)for(w=0;w<d;w++)m.push(t.readUint(r,(d<2?n-4:p)+4*w));if(5==f||10==f){var v=5==f?t.readUint:t.readInt;for(w=0;w<d;w++)m.push([v(r,p+8*w),v(r,p+8*w+4)])}if(8==f)for(w=0;w<d;w++)m.push(t.readShort(r,(d<3?n-4:p)+2*w));if(9==f)for(w=0;w<d;w++)m.push(t.readInt(r,(d<2?n-4:p)+4*w));if(11==f)for(w=0;w<d;w++)m.push(t.readFloat(r,p+4*w));if(12==f)for(w=0;w<d;w++)m.push(t.readDouble(r,p+8*w));if(0==d||0!=m.length){if(s.debug&&i(" ".repeat(o),c,f,e.tags[c],m),u["t"+c]=m,330==c&&u.t272&&"DSLR-A100"==u.t272[0]);else if(330==c||34665==c||34853==c||50740==c&&t.readUshort(r,t.readUint(m,0))<300||61440==c){var x=50740==c?[t.readUint(m,0)]:m,E=[];for(w=0;w<x.length;w++)e._readIFD(t,r,x[w],E,o+1,s);330==c&&(u.subIFD=E),34665==c&&(u.exifIFD=E[0]),34853==c&&(u.gpsiIFD=E[0]),50740==c&&(u.dngPrvt=E[0]),61440==c&&(u.fujiIFD=E[0])}if(37500==c&&s.parseMN){var k=m;if("Nikon"==t.readASCII(k,0,5))u.makerNote=e.decode(k.slice(10).buffer)[0];else if("OLYMP"==t.readASCII(k,0,5)||"OM SYSTEM"==t.readASCII(k,0,9)){var S=[8208,8224,8240,8256,8272],A=[];e._readIFD(t,k,77==k[1]?16:85==k[5]?12:8,A,o+1,s);var I=u.makerNote=A.pop();for(w=0;w<S.length;w++){var M="t"+S[w];null!=I[M]&&(e._readIFD(t,k,I[M][0],A,o+1,s),I[M]=A.pop())}I.t12288&&(e._readIFD(t,I.t12288,0,A,o+1,s),I.t12288=A.pop())}else if(t.readUshort(r,p)<300&&t.readUshort(r,p+4)<=12){A=[];e._readIFD(t,r,p,A,o+1,s),u.makerNote=A[0]}}}else if(i(c,"unknown TIFF tag type: ",f,"num:",d),0==h)return}return a.push(u),s.debug&&i(" ".repeat(o),"<<<---------------"),n},e._writeIFD=function(t,i,r,n,a){var o=Object.keys(a),s=o.length;a.exifIFD&&s--,a.gpsiIFD&&s--,t.writeUshort(r,n,s);for(var l=(n+=2)+12*s+4,u=0;u<o.length;u++){var h=o[u];if("t34665"!=h&&"t34853"!=h){"exifIFD"==h&&(h="t34665"),"gpsiIFD"==h&&(h="t34853");var c=parseInt(h.slice(1)),f=i.main[c];if(null==f&&(f=i.rest[c]),null==f||0==f)throw new Error("unknown type of tag: "+c);var d=a[h];if(34665==c)d=[l],l=e._writeIFD(t,i,r,l,a.exifIFD)[1];if(34853==c)d=[l],l=e._writeIFD(t,e._types.gps,r,l,a.gpsiIFD)[1];2==f&&(d=d[0]+"\0");var p=d.length;t.writeUshort(r,n,c),n+=2,t.writeUshort(r,n,f),n+=2,t.writeUint(r,n,p);var m=[-1,1,1,2,4,8,0,1,0,4,8,0,8][f]*p,_=n+=4;if(m>4&&(t.writeUint(r,n,l),_=l),1==f||7==f)for(var g=0;g<p;g++)r[_+g]=d[g];else if(2==f)t.writeASCII(r,_,d);else if(3==f)for(g=0;g<p;g++)t.writeUshort(r,_+2*g,d[g]);else if(4==f)for(g=0;g<p;g++)t.writeUint(r,_+4*g,d[g]);else if(5==f||10==f){var b=5==f?t.writeUint:t.writeInt;for(g=0;g<p;g++){var y=d[g],w=y[0],v=y[1];if(null==w)throw"e";b(r,_+8*g,w),b(r,_+8*g+4,v)}}else if(9==f)for(g=0;g<p;g++)t.writeInt(r,_+4*g,d[g]);else{if(12!=f)throw f;for(g=0;g<p;g++)t.writeDouble(r,_+8*g,d[g])}m>4&&(l+=m+=1&m),n+=4}}return[n,l]},e.toRGBA8=function(e,t){function r(e){return e<.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055}var n=e.width,a=e.height,o=n*a,s=e.data,l=new Uint8Array(4*o),u=e.t262?e.t262[0]:2,h=e.t258?Math.min(32,e.t258[0]):1;null==e.t262&&1==h&&(u=0);var c=e.t277?e.t277[0]:e.t258?e.t258.length:[1,1,3,1,1,4,3][u],f=e.t339?e.t339[0]:null;if(1==u&&32==h&&3!=f)throw"e";var d=Math.ceil(c*h*n/8);if(0==u){t=1/256;for(var p=0;p<a;p++){var m=p*d,_=p*n;if(1==h)for(var g=0;g<n;g++){var b=_+g<<2,y=s[m+(g>>3)]>>7-(7&g)&1;l[b]=l[b+1]=l[b+2]=255*(1-y),l[b+3]=255}if(4==h)for(g=0;g<n;g++){b=_+g<<2,y=s[m+(g>>1)]>>4-4*(1&g)&15;l[b]=l[b+1]=l[b+2]=17*(15-y),l[b+3]=255}if(8==h)for(g=0;g<n;g++){b=_+g<<2,y=s[m+g];l[b]=l[b+1]=l[b+2]=255-y,l[b+3]=255}if(16==h)for(g=0;g<n;g++){b=_+g<<2,y=s[(v=m+2*g)+1]<<8|s[v];l[b]=l[b+1]=l[b+2]=Math.min(255,255-~~(y*t)),l[b+3]=255}}}else if(1==u){null==t&&(t=1/256);var w=3&s.length?null:new Float32Array(s.buffer);for(p=0;p<a;p++){m=p*d,_=p*n;if(1==h)for(g=0;g<n;g++){b=_+g<<2,y=s[m+(g>>3)]>>7-(7&g)&1;l[b]=l[b+1]=l[b+2]=255*y,l[b+3]=255}if(2==h)for(g=0;g<n;g++){b=_+g<<2,y=s[m+(g>>2)]>>6-2*(3&g)&3;l[b]=l[b+1]=l[b+2]=85*y,l[b+3]=255}if(8==h)for(g=0;g<n;g++){b=_+g<<2,y=s[m+g*c];l[b]=l[b+1]=l[b+2]=y,l[b+3]=255}if(16==h)for(g=0;g<n;g++){b=_+g<<2,y=s[(v=m+2*g)+1]<<8|s[v];l[b]=l[b+1]=l[b+2]=Math.min(255,~~(y*t)),l[b+3]=255}if(32==h)for(g=0;g<n;g++){var v;b=_+g<<2,y=w[v=(m>>>2)+g];l[b]=l[b+1]=l[b+2]=~~(.5+255*y),l[b+3]=255}}}else if(2==u)if(8==h){if(1==c)for(g=0;g<o;g++)l[4*g]=l[4*g+1]=l[4*g+2]=s[g],l[4*g+3]=255;if(3==c)for(g=0;g<o;g++){var x=3*g;l[b=g<<2]=s[x],l[b+1]=s[x+1],l[b+2]=s[x+2],l[b+3]=255}if(c>=4)for(g=0;g<o;g++){x=g*c;l[b=g<<2]=s[x],l[b+1]=s[x+1],l[b+2]=s[x+2],l[b+3]=s[x+3]}}else if(16==h){if(4==c)for(g=0;g<o;g++){x=8*g+1;l[b=g<<2]=s[x],l[b+1]=s[x+2],l[b+2]=s[x+4],l[b+3]=s[x+6]}if(3==c)for(g=0;g<o;g++){x=6*g+1;l[b=g<<2]=s[x],l[b+1]=s[x+2],l[b+2]=s[x+4],l[b+3]=255}}else{if(32!=h)throw h;var E=new Float32Array(s.buffer),k=0;for(g=0;g<E.length;g++)k=Math.min(k,E[g]);if(k<0)for(g=0;g<s.length;g+=4){var S=s[g];s[g]=s[g+3],s[g+3]=S,S=s[g+1],s[g+1]=s[g+2],s[g+2]=S}var A=[];for(g=0;g<65536;g++)A.push(r(g/65535));for(g=0;g<E.length;g++){var I=Math.max(0,Math.min(1,E[g]));E[g]=A[~~(.5+65535*I)]}if(3==c)for(g=0;g<o;g++){x=3*g;l[b=g<<2]=~~(.5+255*E[x]),l[b+1]=~~(.5+255*E[x+1]),l[b+2]=~~(.5+255*E[x+2]),l[b+3]=255}else{if(4!=c)throw c;for(g=0;g<o;g++){x=4*g;l[b=g<<2]=~~(.5+255*E[x]),l[b+1]=~~(.5+255*E[x+1]),l[b+2]=~~(.5+255*E[x+2]),l[b+3]=~~(.5+255*E[x+3])}}}else if(3==u){var M=e.t320,T=1<<h,P=8==h&&c>1&&e.t338&&0!=e.t338[0];for(p=0;p<a;p++)for(var B=0;B<n;B++){b=(g=p*n+B)<<2;var C=0,R=p*d;if(1==h)C=s[R+(B>>>3)]>>>7-(7&B)&1;else if(2==h)C=s[R+(B>>>2)]>>>6-2*(3&B)&3;else if(4==h)C=s[R+(B>>>1)]>>>4-4*(1&B)&15;else{if(8!=h)throw h;C=s[R+B*c]}l[b]=M[C]>>8,l[b+1]=M[T+C]>>8,l[b+2]=M[T+T+C]>>8,l[b+3]=P?s[R+B*c+1]:255}}else if(5==u){var z=c>4?1:0;for(g=0;g<o;g++){b=g<<2;var F=g*c;if(window.UDOC){var N=s[F],O=s[F+1],D=s[F+2],$=s[F+3],L=UDOC.C.cmykToRgb([N*(1/255),O*(1/255),D*(1/255),$*(1/255)]);l[b]=~~(.5+255*L[0]),l[b+1]=~~(.5+255*L[1]),l[b+2]=~~(.5+255*L[2])}else{N=255-s[F],O=255-s[F+1],D=255-s[F+2],$=(255-s[F+3])*(1/255);l[b]=~~(N*$+.5),l[b+1]=~~(O*$+.5),l[b+2]=~~(D*$+.5)}l[b+3]=255*(1-z)+s[F+4]*z}}else if(6==u&&e.t278){var U=e.t278[0];for(p=0;p<a;p+=U){g=p*n;for(var Z=U*n,j=0;j<Z;j++){b=4*(g+j),D=s[(F=3*g+4*(j>>>1))+(1&j)];var G=s[F+2]-128,H=s[F+3]-128,Q=D+((H>>2)+(H>>3)+(H>>5)),W=D-((G>>2)+(G>>4)+(G>>5))-((H>>1)+(H>>3)+(H>>4)+(H>>5)),q=D+(G+(G>>1)+(G>>2)+(G>>6));l[b]=Math.max(0,Math.min(255,Q)),l[b+1]=Math.max(0,Math.min(255,W)),l[b+2]=Math.max(0,Math.min(255,q)),l[b+3]=255}}}else if(32845==u)for(p=0;p<a;p++)for(B=0;B<n;B++){b=4*(p*n+B);var V=s[(F=6*(p*n+B))+1]<<8|s[F],Y=(V=Math.pow(2,(V+.5)/256-64),(s[F+3]+.5)/410),K=(s[F+5]+.5)/410,J=9*Y/(6*Y-16*K+12),X=4*K/(6*Y-16*K+12),ee=J*V/X,te=(1-J-X)*V/X;Q=2.69*ee-1.276*(D=V)-.414*te,W=-1.022*ee+1.978*D+.044*te,q=.061*ee-.224*D+1.163*te;l[b]=255*r(Math.min(Q,1)),l[b+1]=255*r(Math.min(W,1)),l[b+2]=255*r(Math.min(q,1)),l[b+3]=255}else i("Unknown Photometric interpretation: "+u);return l},e.replaceIMG=function(t){null==t&&(t=document.getElementsByTagName("img"));for(var i=["tif","tiff","dng","cr2","nef"],r=0;r<t.length;r++){var n=t[r],a=n.getAttribute("src");if(null!=a){var o=a.split(".").pop().toLowerCase();if(-1!=i.indexOf(o)){var s=new XMLHttpRequest;e._xhrs.push(s),e._imgs.push(n),s.open("GET",a),s.responseType="arraybuffer",s.onload=e._imgLoaded,s.send()}}}},e._xhrs=[],e._imgs=[],e._imgLoaded=function(t){var i=e._xhrs.indexOf(t.target),r=e._imgs[i];e._xhrs.splice(i,1),e._imgs.splice(i,1),r.setAttribute("src",e.bufferToURI(t.target.response))},e.bufferToURI=function(t){var i=e.decode(t),r=i,n=0,a=r[0];i[0].subIFD&&(r=r.concat(i[0].subIFD));for(var o=0;o<r.length;o++){var s=r[o];if(!(null==s.t258||s.t258.length<3)){var l=s.t256*s.t257;l>n&&(n=l,a=s)}}e.decodeImage(t,a,i);var u=e.toRGBA8(a),h=a.width,c=a.height,f=document.createElement("canvas");f.width=h,f.height=c;var d=f.getContext("2d"),p=new ImageData(new Uint8ClampedArray(u.buffer),h,c);return d.putImageData(p,0,0),f.toDataURL()},e._binBE={nextZero:function(e,t){for(;0!=e[t];)t++;return t},readUshort:function(e,t){return e[t]<<8|e[t+1]},readShort:function(t,i){var r=e._binBE.ui8;return r[0]=t[i+1],r[1]=t[i+0],e._binBE.i16[0]},readInt:function(t,i){var r=e._binBE.ui8;return r[0]=t[i+3],r[1]=t[i+2],r[2]=t[i+1],r[3]=t[i+0],e._binBE.i32[0]},readUint:function(t,i){var r=e._binBE.ui8;return r[0]=t[i+3],r[1]=t[i+2],r[2]=t[i+1],r[3]=t[i+0],e._binBE.ui32[0]},readASCII:function(e,t,i){for(var r="",n=0;n<i;n++)r+=String.fromCharCode(e[t+n]);return r},readFloat:function(t,i){for(var r=e._binBE.ui8,n=0;n<4;n++)r[n]=t[i+3-n];return e._binBE.fl32[0]},readDouble:function(t,i){for(var r=e._binBE.ui8,n=0;n<8;n++)r[n]=t[i+7-n];return e._binBE.fl64[0]},writeUshort:function(e,t,i){e[t]=i>>8&255,e[t+1]=255&i},writeInt:function(t,i,r){var n=e._binBE.ui8;e._binBE.i32[0]=r,t[i+3]=n[0],t[i+2]=n[1],t[i+1]=n[2],t[i+0]=n[3]},writeUint:function(e,t,i){e[t]=i>>24&255,e[t+1]=i>>16&255,e[t+2]=i>>8&255,e[t+3]=255&i},writeASCII:function(e,t,i){for(var r=0;r<i.length;r++)e[t+r]=i.charCodeAt(r)},writeDouble:function(t,i,r){e._binBE.fl64[0]=r;for(var n=0;n<8;n++)t[i+n]=e._binBE.ui8[7-n]}},e._binBE.ui8=new Uint8Array(8),e._binBE.i16=new Int16Array(e._binBE.ui8.buffer),e._binBE.i32=new Int32Array(e._binBE.ui8.buffer),e._binBE.ui32=new Uint32Array(e._binBE.ui8.buffer),e._binBE.fl32=new Float32Array(e._binBE.ui8.buffer),e._binBE.fl64=new Float64Array(e._binBE.ui8.buffer),e._binLE={nextZero:e._binBE.nextZero,readUshort:function(e,t){return e[t+1]<<8|e[t]},readShort:function(t,i){var r=e._binBE.ui8;return r[0]=t[i+0],r[1]=t[i+1],e._binBE.i16[0]},readInt:function(t,i){var r=e._binBE.ui8;return r[0]=t[i+0],r[1]=t[i+1],r[2]=t[i+2],r[3]=t[i+3],e._binBE.i32[0]},readUint:function(t,i){var r=e._binBE.ui8;return r[0]=t[i+0],r[1]=t[i+1],r[2]=t[i+2],r[3]=t[i+3],e._binBE.ui32[0]},readASCII:e._binBE.readASCII,readFloat:function(t,i){for(var r=e._binBE.ui8,n=0;n<4;n++)r[n]=t[i+n];return e._binBE.fl32[0]},readDouble:function(t,i){for(var r=e._binBE.ui8,n=0;n<8;n++)r[n]=t[i+n];return e._binBE.fl64[0]},writeUshort:function(e,t,i){e[t]=255&i,e[t+1]=i>>8&255},writeInt:function(t,i,r){var n=e._binBE.ui8;e._binBE.i32[0]=r,t[i+0]=n[0],t[i+1]=n[1],t[i+2]=n[2],t[i+3]=n[3]},writeUint:function(e,t,i){e[t]=i>>>0&255,e[t+1]=i>>>8&255,e[t+2]=i>>>16&255,e[t+3]=i>>>24&255},writeASCII:e._binBE.writeASCII},e._copyTile=function(e,t,i,r,n,a,o,s){for(var l=Math.min(t,n-o),u=Math.min(i,a-s),h=0;h<u;h++)for(var c=(s+h)*n+o,f=h*t,d=0;d<l;d++)r[c+d]=e[f+d]},e.LosslessJpegDecode=function(){var e,t;function i(){return e[t++]}function r(){return e[t++]<<8|e[t++]}function n(e){for(var t=i(),r=[0,0,0,255],n=[],o=0;o<16;o++)n[o]=i();for(o=0;o<16;o++)for(var s=0;s<n[o];s++){r[a(r,0,o+1,1)+3]=i()}var l=new Uint8Array(256);e[t]=[new Uint8Array(r),l];for(o=0;o<256;o++){for(var u=8,h=o,c=0;255==r[c+3]&&0!=u;)c=r[c+(h>>--u&1)];l[o]=c}}function a(e,t,i,r){if(255!=e[t+3])return 0;if(0==i)return t;for(var n=0;n<2;n++){0==e[t+n]&&(e[t+n]=e.length,e.push(0,0,r,255));var o=a(e,e[t+n],i-1,r+1);if(0!=o)return o}return 0}function o(e){for(var t=e.b,i=e.f;t<25&&e.a<e.d;){var r=e.data[e.a++];255!=r||e.c||e.a++,i=i<<8|r,t+=8}if(t<0)throw"e";e.b=t,e.f=i}function s(e,t){return t.b<e&&o(t),t.f>>(t.b-=e)&65535>>16-e}function l(e,t){var i=e[0],r=0,n=255;t.b<16&&o(t);var a=t.f>>t.b-8&255;for(n=i[(r=e[1][a])+3],t.b-=i[r+2];255==n;)n=i[(r=i[r+(t.f>>--t.b&1)])+3];return n}function u(e,t){return e<32768>>16-t&&(e+=1-(1<<t)),e}function h(e,t){var i=l(e,t);return 0==i?0:16==i?-32768:u(s(i,t),i)}function c(e,t,i,r,n,a){for(var o=0,s=0;s<a;s++){for(var l=s*t,u=0;u<t;u+=n){o++;for(var c=0;c<n;c++)e[l+u+c]=h(r[c],i)}if(0!=i.e&&o%i.e==0&&0!=s){for(var f=i.a,d=i.data;255!=d[f]||!(208<=d[f+1]&&d[f+1]<=215);)f--;i.a=f+2,i.f=0,i.b=0}}}function f(e,t){return u(s(e,t),e)}function d(e,t,i,r,n,a,o,s){for(var l=i*o,u=n;u<a;u++)e[u]+=1<<s-1;for(var h=o;h<l;h+=o)for(u=n;u<a;u++)e[h+u]+=e[h+u-o];for(var c=1;c<r;c++){var f=c*l;for(u=n;u<a;u++)e[f+u]+=e[f+u-l];for(h=o;h<l;h+=o)for(u=n;u<a;u++){var d=f+h+u,p=d-l,m=e[d-o],_=0;if(0==t)_=0;else if(1==t)_=m;else if(2==t)_=e[p];else if(3==t)_=e[p-o];else if(4==t)_=m+(e[p]-e[p-o]);else if(5==t)_=m+(e[p]-e[p-o]>>>1);else if(6==t)_=e[p]+(m-e[p-o]>>>1);else{if(7!=t)throw t;_=m+e[p]>>>1}e[d]+=_}}}return function(a){if(e=a,t=0,65496!=r())throw"e";for(var o=[],s=0,u=0,h=0,p=[],m=[],_=[],g=0,b=0,y=0;;){var w=r();if(65535!=w){var v=r();if(65475==w){u=i(),b=r(),y=r(),g=i();for(var x=0;x<g;x++){var E=i(),k=i();if(0!=i())throw"e";o[E]=[x,k>>4,15&k]}}else if(65476==w)for(var S=t+v-2;t<S;)n(m);else{if(65498==w){t++;for(x=0;x<g;x++){var A=o[i()];_[A[0]]=m[i()>>>4],p[A[0]]=A.slice(1)}s=i(),t+=2;break}65501==w?h=r():t+=v-2}}else t--}var I=new(u>8?Uint16Array:Uint8Array)(b*y*g),M={b:0,f:0,c:8==s,a:t,data:e,d:e.length,e:h};if(M.c)!function(i,r,n,a,o){for(var s=e.length-t,u=0;u<s;u+=4){var h=e[t+u];e[t+u]=e[t+u+3],e[t+u+3]=h,h=e[t+u+1],e[t+u+1]=e[t+u+2],e[t+u+2]=h}for(var c=0;c<o;c++)for(var d=32768,p=32768,m=0;m<r;m+=2){var _=l(a,n),g=l(a,n);0!=_&&(d+=f(_,n)),0!=g&&(p+=f(g,n)),i[c*r+m]=65535&d,i[c*r+m+1]=65535&p}}(I,y*g,M,_[0],b);else{var T=[],P=0,B=0;for(x=0;x<g;x++){var C=p[x];(Z=C[0])>P&&(P=Z),(U=C[1])>B&&(B=U),T.push(Z*U)}if(1!=P||1!=B){if(3!=g||1!=T[1]||1!=T[2])throw"e";if(2!=P||1!=B&&2!=B)throw"e";var R=[],z=0;for(x=0;x<g;x++){for(var F=0;F<T[x];F++)R.push(_[x]);z+=T[x]}var N=y/P,O=b/B,D=N*O;c(I,N*z,M,R,z,O),d(I,s,N,O,z-2,z,z,u);var $=new Uint16Array(D*T[0]);if(2==P&&2==B){for(x=0;x<D;x++)$[4*x]=I[6*x],$[4*x+1]=I[6*x+1],$[4*x+2]=I[6*x+2],$[4*x+3]=I[6*x+3];d($,s,4*N,O,0,1,1,u);for(x=0;x<D;x++)I[6*x]=$[4*x],I[6*x+1]=$[4*x+1],I[6*x+2]=$[4*x+2],I[6*x+3]=$[4*x+3]}if(2==P&&1==B){for(x=0;x<D;x++)$[2*x]=I[4*x],$[2*x+1]=I[4*x+1];d($,s,2*N,O,0,1,1,u);for(x=0;x<D;x++)I[4*x]=$[2*x],I[4*x+1]=$[2*x+1]}for(var L=I.slice(0),U=0;U<b;U++)if(2==B)for(var Z=0;Z<y;Z++){var j=((U>>>1)*N+(Z>>>1))*z,G=2*(1&U)+(1&Z);I[H=(U*y+Z)*g]=L[j+G],I[H+1]=L[j+4],I[H+2]=L[j+5]}else for(Z=0;Z<y;Z++){var H;j=(U*N+(Z>>>1))*z,G=1&Z;I[H=(U*y+Z)*g]=L[j+G],I[H+1]=L[j+2],I[H+2]=L[j+3]}}else if(c(I,y*g,M,_,g,b),0==h)d(I,s,y,b,0,g,g,u);else{var Q=Math.floor(h/y);for(U=0;U<b;U+=Q){var W=I.slice(U*y*g,(U+Q)*y*g);d(W,s,y,Q,0,g,g,u),I.set(W,U*y*g)}}}return I}}(),function(){var t=2,i=4,r=5,n=6,a=7,o=12,s=13,l=14,u=15,h=17;function c(e){var t={c:new Int8Array(2<<e.u)};return function(e,t,i){var r=[t,3*t+18,5*t+67,7*t+276,i];e.o=t,e.w=(r[4]+2*t)/(2*t+1)+1|0,e.v=Math.ceil(Math.log2(e.w)),e.t=9,function(e,t){for(var i=-t[4],r=0;i<=t[4];r++,i++)e[r]=i<=-t[3]?-4:i<=-t[2]?-3:i<=-t[1]?-2:i<-t[0]?-1:i<=t[0]?0:i<t[1]?1:i<t[2]?2:i<t[3]?3:4}(e.c,r)}(t,0,e.g),t}function f(e){for(var t=[[],[],[]],i=Math.max(2,e.w+32>>>6),r=0;r<3;r++)for(var n=0;n<41;n++)t[r][n]=[i,1];return t}function d(e,t){var i=0,r=8-e.a;if(e.j,e.a,t){if(t>=r)do{i<<=r,t-=r,i|=e[e.j]&(1<<r)-1,e.j++,r=8}while(t>=8);t&&(i<<=t,r-=t,i|=e[e.j]>>>r&(1<<t)-1),e.a=8-r}return i}function p(e,t,i,r,n,a,o,s){null==s&&(s=0);var l,u,h,c,f,p,m=a+1,_=m%2,g=0,b=r[n],y=r[n-1],w=r[n-2][m],v=y[m-1],x=y[m],E=y[m+1],k=b[m-1],S=b[m+1],A=Math.abs;if(_&&(h=A(E-x),c=A(w-x),f=A(v-x)),_){if(p=(p=h>f&&c<h?w+v:h<f&&c<f?w+E:E+v)+2*x>>>2,s)return void(b[m]=p);l=t.t*t.c[e.g+x-w]+t.c[e.g+v-x]}else p=x>v&&x>E||x<v&&x<E?S+k+2*x>>>2:k+S>>>1,l=t.t*t.c[e.g+x-v]+t.c[e.g+v-k];u=A(l);var I=function(e){for(var t=-1,i=0;!i;t++)i=e[e.j]>>>7-e.a&1,e.a++,e.a&=7,e.a||e.j++;return t}(i);if(I<e.n-t.v-1){var M=function(e,t){var i=0;if(t<e)for(;i<=14&&t<<++i<e;);return i}(o[u][0],o[u][1]);g=d(i,M)+(I<<M)}else g=d(i,t.v)+1;g=1&g?-1-(g>>>1):g>>>1,o[u][0]+=A(g),o[u][1]==e.f&&(o[u][0]>>>=1,o[u][1]>>>=1),o[u][1]++,p=l<0?p-g:p+g,e.i&&(p<0?p+=t.w:p>e.g&&(p-=t.w)),b[m]=p>=0?Math.min(p,e.g):0}function m(e,t,i){for(var r=e[0].length,n=t;n<=i;n++)e[n][0]=e[n-1][1],e[n][r-1]=e[n-1][r-2]}function _(e){m(e,a,o),m(e,t,i),m(e,u,h)}function g(e,t,r,n,a,o,l,u,h,c,f,d,m){for(var g=0,b=1,y=a<s&&a>i;b<e.m;)g<e.m&&(p(e,t,r,n,a,g,l[h],e.h&&(y&&c||!y&&(f||(g&d)==m))),p(e,t,r,n,o,g,l[h],e.h&&(!y&&c||y&&(f||(g&d)==m))),g+=2),g>8&&(p(e,t,r,n,a,b,u[h]),p(e,t,r,n,o,b,u[h]),b+=2);_(n)}function b(e,r,n,s,l,c){g(e,r,n,s,t,a,l,c,0,0,1,0,8),g(e,r,n,s,8,u,l,c,1,0,1,0,8),g(e,r,n,s,3,9,l,c,2,1,0,3,0),g(e,r,n,s,10,16,l,c,0,0,0,3,2),g(e,r,n,s,i,11,l,c,1,0,0,3,2),g(e,r,n,s,o,h,l,c,2,1,0,3,0)}function y(e,i,r,n,o,s){var l=s.length,h=e.l;o+1==e.s&&(h=e.e-o*e.l);for(var c=6*e.e*n+o*e.l,f=0;f<6;f++){for(var d=0;d<h;d++){var p,m=s[f%l][d%l];p=0==m?t+(f>>>1):2==m?u+(f>>>1):a+f;var _=e.h?(2*d/3&2147483646|d%3&1)+(d%3>>>1):d>>>1;i[c+d]=r[p][_+1]}c+=e.e}}e._decompressRAF=function(a,u){var d=function(t){var i=e._binBE.readUshort,r={b:i(t,0),i:t[2],C:t[3],u:t[4],q:i(t,5),k:i(t,7),e:i(t,9),l:i(t,11),s:t[13],d:i(t,14)};if(18771!=r.b||r.i>1||r.q<6||r.q%6||r.e<768||r.e%24||768!=r.l||r.k<r.l||r.k%r.l||r.k-r.e>=r.l||r.s>16||r.s!=r.k/r.l||r.s!=Math.ceil(r.e/r.l)||r.d!=r.q/6||12!=r.u&&14!=r.u&&16!=r.u||16!=r.C&&0!=r.C)throw"Invalid data";if(0==r.i)throw"Not implemented. We need this file!";return r.h=16==r.C,r.m=0|(r.h?2*r.l/3:r.l>>>1),r.A=r.m+2,r.f=64,r.g=(1<<r.u)-1,r.n=4*r.u,r}(a),p=function(t,i){var r=new Array(i.s),n=4*i.s,a=16+n;12&n&&(a+=16-(12&n));for(var o=0,s=16;o<i.s;s+=4){var l=e._binBE.readUint(t,s);r[o]=t.slice(a,a+l),r[o].j=0,r[o].a=0,a+=l,o++}if(a!=t.length)throw"Invalid data";return r}(a,d),m=c(d),g=new Int16Array(d.e*d.q);null==u&&(u=d.h?[[1,1,0,1,1,2],[1,1,2,1,1,0],[2,0,1,0,2,1],[1,1,2,1,1,0],[1,1,0,1,1,2],[0,2,1,2,0,1]]:[[0,1],[3,2]]);for(var w=[[0,3],[1,i],[r,11],[n,o],[s,16],[l,h]],v=[],x=0;x<18;x++)v[x]=new Uint16Array(d.A);for(var E=0;E<d.s;E++){var k=f(m),S=f(m);for(x=0;x<18;x++)for(var A=0;A<d.A;A++)v[x][A]=0;for(var I=0;I<d.d;I++){b(d,m,p[E],v,k,S);for(x=0;x<6;x++)for(A=0;A<d.A;A++)v[w[x][0]][A]=v[w[x][1]][A];y(d,g,v,I,E,u);for(x=t;x<18;x++)if(-1==[r,n,s,l].indexOf(x))for(A=0;A<d.A;A++)v[x][A]=0;_(v)}}return g}}()}(t,"function"==typeof commonjsRequire?requirePako():self.pako)}()}(UTIF);var UTIFExports=UTIF.exports,utif=getDefaultExportFromCjs(UTIFExports),util$1,objectUtil;function getDimensionValue(e){return"number"==typeof e?e:e instanceof Uint8Array?e[0]:"string"==typeof e[0]?parseInt(e[0]):e[0]}function tiff(){return{mime:"image/tiff",encode:e=>{const t=utif.encodeImage(e.data,e.width,e.height);return Buffer.from(t)},decode:e=>{const t=utif.decode(e),i=t[0];if(!i)throw new Error("No page found in TIFF");if(!i.t256)throw new Error("No image width found in TIFF");if(!i.t257)throw new Error("No image height found in TIFF");t.forEach((t=>{utif.decodeImage(e,t)}));const r=utif.toRGBA8(i);return{data:Buffer.from(r),width:getDimensionValue(i.t256),height:getDimensionValue(i.t257)}}}}!function(e){e.assertEqual=e=>e,e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=e=>{const t={};for(const i of e)t[i]=i;return t},e.getValidEnumValues=t=>{const i=e.objectKeys(t).filter((e=>"number"!=typeof t[t[e]])),r={};for(const e of i)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map((function(e){return t[e]})),e.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.push(i);return t},e.find=(e,t)=>{for(const i of e)if(t(i))return i},e.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&isFinite(e)&&Math.floor(e)===e,e.joinValues=function(e,t=" | "){return e.map((e=>"string"==typeof e?`'${e}'`:e)).join(t)},e.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t}(util$1||(util$1={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(objectUtil||(objectUtil={}));const ZodParsedType=util$1.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),getParsedType=e=>{switch(typeof e){case"undefined":return ZodParsedType.undefined;case"string":return ZodParsedType.string;case"number":return isNaN(e)?ZodParsedType.nan:ZodParsedType.number;case"boolean":return ZodParsedType.boolean;case"function":return ZodParsedType.function;case"bigint":return ZodParsedType.bigint;case"symbol":return ZodParsedType.symbol;case"object":return Array.isArray(e)?ZodParsedType.array:null===e?ZodParsedType.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?ZodParsedType.promise:"undefined"!=typeof Map&&e instanceof Map?ZodParsedType.map:"undefined"!=typeof Set&&e instanceof Set?ZodParsedType.set:"undefined"!=typeof Date&&e instanceof Date?ZodParsedType.date:ZodParsedType.object;default:return ZodParsedType.unknown}},ZodIssueCode=util$1.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),quotelessJson=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class ZodError extends Error{constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(e){return e.message},i={_errors:[]},r=e=>{for(const n of e.issues)if("invalid_union"===n.code)n.unionErrors.map(r);else if("invalid_return_type"===n.code)r(n.returnTypeError);else if("invalid_arguments"===n.code)r(n.argumentsError);else if(0===n.path.length)i._errors.push(t(n));else{let e=i,r=0;for(;r<n.path.length;){const i=n.path[r];r===n.path.length-1?(e[i]=e[i]||{_errors:[]},e[i]._errors.push(t(n))):e[i]=e[i]||{_errors:[]},e=e[i],r++}}};return r(this),i}static assert(e){if(!(e instanceof ZodError))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,util$1.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=(e=>e.message)){const t={},i=[];for(const r of this.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(e(r))):i.push(e(r));return{formErrors:i,fieldErrors:t}}get formErrors(){return this.flatten()}}ZodError.create=e=>new ZodError(e);const errorMap=(e,t)=>{let i;switch(e.code){case ZodIssueCode.invalid_type:i=e.received===ZodParsedType.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case ZodIssueCode.invalid_literal:i=`Invalid literal value, expected ${JSON.stringify(e.expected,util$1.jsonStringifyReplacer)}`;break;case ZodIssueCode.unrecognized_keys:i=`Unrecognized key(s) in object: ${util$1.joinValues(e.keys,", ")}`;break;case ZodIssueCode.invalid_union:i="Invalid input";break;case ZodIssueCode.invalid_union_discriminator:i=`Invalid discriminator value. Expected ${util$1.joinValues(e.options)}`;break;case ZodIssueCode.invalid_enum_value:i=`Invalid enum value. Expected ${util$1.joinValues(e.options)}, received '${e.received}'`;break;case ZodIssueCode.invalid_arguments:i="Invalid function arguments";break;case ZodIssueCode.invalid_return_type:i="Invalid function return type";break;case ZodIssueCode.invalid_date:i="Invalid date";break;case ZodIssueCode.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(i=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(i=`${i} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?i=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?i=`Invalid input: must end with "${e.validation.endsWith}"`:util$1.assertNever(e.validation):i="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case ZodIssueCode.too_small:i="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case ZodIssueCode.too_big:i="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case ZodIssueCode.custom:i="Invalid input";break;case ZodIssueCode.invalid_intersection_types:i="Intersection results could not be merged";break;case ZodIssueCode.not_multiple_of:i=`Number must be a multiple of ${e.multipleOf}`;break;case ZodIssueCode.not_finite:i="Number must be finite";break;default:i=t.defaultError,util$1.assertNever(e)}return{message:i}};let overrideErrorMap=errorMap;function setErrorMap(e){overrideErrorMap=e}function getErrorMap(){return overrideErrorMap}const makeIssue=e=>{const{data:t,path:i,errorMaps:r,issueData:n}=e,a=[...i,...n.path||[]],o={...n,path:a};if(void 0!==n.message)return{...n,path:a,message:n.message};let s="";const l=r.filter((e=>!!e)).slice().reverse();for(const e of l)s=e(o,{data:t,defaultError:s}).message;return{...n,path:a,message:s}},EMPTY_PATH=[];function addIssueToContext(e,t){const i=getErrorMap(),r=makeIssue({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,i,i===errorMap?void 0:errorMap].filter((e=>!!e))});e.common.issues.push(r)}class ParseStatus{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const i=[];for(const r of t){if("aborted"===r.status)return INVALID;"dirty"===r.status&&e.dirty(),i.push(r.value)}return{status:e.value,value:i}}static async mergeObjectAsync(e,t){const i=[];for(const e of t){const t=await e.key,r=await e.value;i.push({key:t,value:r})}return ParseStatus.mergeObjectSync(e,i)}static mergeObjectSync(e,t){const i={};for(const r of t){const{key:t,value:n}=r;if("aborted"===t.status)return INVALID;if("aborted"===n.status)return INVALID;"dirty"===t.status&&e.dirty(),"dirty"===n.status&&e.dirty(),"__proto__"===t.value||void 0===n.value&&!r.alwaysSet||(i[t.value]=n.value)}return{status:e.value,value:i}}}const INVALID=Object.freeze({status:"aborted"}),DIRTY=e=>({status:"dirty",value:e}),OK=e=>({status:"valid",value:e}),isAborted=e=>"aborted"===e.status,isDirty=e=>"dirty"===e.status,isValid=e=>"valid"===e.status,isAsync=e=>"undefined"!=typeof Promise&&e instanceof Promise;function __classPrivateFieldGet(e,t,i,r){if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t.get(e)}function __classPrivateFieldSet(e,t,i,r,n){if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,i),i}var errorUtil,_ZodEnum_cache,_ZodNativeEnum_cache;"function"==typeof SuppressedError&&SuppressedError,function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:null==e?void 0:e.message}(errorUtil||(errorUtil={}));class ParseInputLazyPath{constructor(e,t,i,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=i,this._key=r}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const handleResult=(e,t)=>{if(isValid(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new ZodError(e.common.issues);return this._error=t,this._error}}};function processCreateParams(e){if(!e)return{};const{errorMap:t,invalid_type_error:i,required_error:r,description:n}=e;if(t&&(i||r))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:n};return{errorMap:(t,n)=>{var a,o;const{message:s}=e;return"invalid_enum_value"===t.code?{message:null!=s?s:n.defaultError}:void 0===n.data?{message:null!==(a=null!=s?s:r)&&void 0!==a?a:n.defaultError}:"invalid_type"!==t.code?{message:n.defaultError}:{message:null!==(o=null!=s?s:i)&&void 0!==o?o:n.defaultError}},description:n}}class ZodType{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return getParsedType(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:getParsedType(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ParseStatus,ctx:{common:e.parent.common,data:e.data,parsedType:getParsedType(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(isAsync(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const i=this.safeParse(e,t);if(i.success)return i.data;throw i.error}safeParse(e,t){var i;const r={common:{issues:[],async:null!==(i=null==t?void 0:t.async)&&void 0!==i&&i,contextualErrorMap:null==t?void 0:t.errorMap},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:getParsedType(e)},n=this._parseSync({data:e,path:r.path,parent:r});return handleResult(r,n)}async parseAsync(e,t){const i=await this.safeParseAsync(e,t);if(i.success)return i.data;throw i.error}async safeParseAsync(e,t){const i={common:{issues:[],contextualErrorMap:null==t?void 0:t.errorMap,async:!0},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:getParsedType(e)},r=this._parse({data:e,path:i.path,parent:i}),n=await(isAsync(r)?r:Promise.resolve(r));return handleResult(i,n)}refine(e,t){const i=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement(((t,r)=>{const n=e(t),a=()=>r.addIssue({code:ZodIssueCode.custom,...i(t)});return"undefined"!=typeof Promise&&n instanceof Promise?n.then((e=>!!e||(a(),!1))):!!n||(a(),!1)}))}refinement(e,t){return this._refinement(((i,r)=>!!e(i)||(r.addIssue("function"==typeof t?t(i,r):t),!1)))}_refinement(e){return new ZodEffects({schema:this,typeName:ZodFirstPartyTypeKind.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ZodOptional.create(this,this._def)}nullable(){return ZodNullable.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ZodArray.create(this,this._def)}promise(){return ZodPromise.create(this,this._def)}or(e){return ZodUnion.create([this,e],this._def)}and(e){return ZodIntersection.create(this,e,this._def)}transform(e){return new ZodEffects({...processCreateParams(this._def),schema:this,typeName:ZodFirstPartyTypeKind.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new ZodDefault({...processCreateParams(this._def),innerType:this,defaultValue:t,typeName:ZodFirstPartyTypeKind.ZodDefault})}brand(){return new ZodBranded({typeName:ZodFirstPartyTypeKind.ZodBranded,type:this,...processCreateParams(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new ZodCatch({...processCreateParams(this._def),innerType:this,catchValue:t,typeName:ZodFirstPartyTypeKind.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return ZodPipeline.create(this,e)}readonly(){return ZodReadonly.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const cuidRegex=/^c[^\s-]{8,}$/i,cuid2Regex=/^[0-9a-z]+$/,ulidRegex=/^[0-9A-HJKMNP-TV-Z]{26}$/,uuidRegex=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,nanoidRegex=/^[a-z0-9_-]{21}$/i,durationRegex=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,emailRegex=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,_emojiRegex="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let emojiRegex;const ipv4Regex=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv6Regex=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,base64Regex=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,dateRegexSource="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",dateRegex=new RegExp(`^${dateRegexSource}$`);function timeRegexSource(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`),t}function timeRegex(e){return new RegExp(`^${timeRegexSource(e)}$`)}function datetimeRegex(e){let t=`${dateRegexSource}T${timeRegexSource(e)}`;const i=[];return i.push(e.local?"Z?":"Z"),e.offset&&i.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${i.join("|")})`,new RegExp(`^${t}$`)}function isValidIP(e,t){return!("v4"!==t&&t||!ipv4Regex.test(e))||!("v6"!==t&&t||!ipv6Regex.test(e))}class ZodString extends ZodType{_parse(e){this._def.coerce&&(e.data=String(e.data));if(this._getType(e)!==ZodParsedType.string){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.string,received:t.parsedType}),INVALID}const t=new ParseStatus;let i;for(const r of this._def.checks)if("min"===r.kind)e.data.length<r.value&&(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{code:ZodIssueCode.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if("max"===r.kind)e.data.length>r.value&&(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{code:ZodIssueCode.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if("length"===r.kind){const n=e.data.length>r.value,a=e.data.length<r.value;(n||a)&&(i=this._getOrReturnCtx(e,i),n?addIssueToContext(i,{code:ZodIssueCode.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):a&&addIssueToContext(i,{code:ZodIssueCode.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if("email"===r.kind)emailRegex.test(e.data)||(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{validation:"email",code:ZodIssueCode.invalid_string,message:r.message}),t.dirty());else if("emoji"===r.kind)emojiRegex||(emojiRegex=new RegExp(_emojiRegex,"u")),emojiRegex.test(e.data)||(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{validation:"emoji",code:ZodIssueCode.invalid_string,message:r.message}),t.dirty());else if("uuid"===r.kind)uuidRegex.test(e.data)||(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{validation:"uuid",code:ZodIssueCode.invalid_string,message:r.message}),t.dirty());else if("nanoid"===r.kind)nanoidRegex.test(e.data)||(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{validation:"nanoid",code:ZodIssueCode.invalid_string,message:r.message}),t.dirty());else if("cuid"===r.kind)cuidRegex.test(e.data)||(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{validation:"cuid",code:ZodIssueCode.invalid_string,message:r.message}),t.dirty());else if("cuid2"===r.kind)cuid2Regex.test(e.data)||(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{validation:"cuid2",code:ZodIssueCode.invalid_string,message:r.message}),t.dirty());else if("ulid"===r.kind)ulidRegex.test(e.data)||(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{validation:"ulid",code:ZodIssueCode.invalid_string,message:r.message}),t.dirty());else if("url"===r.kind)try{new URL(e.data)}catch(n){i=this._getOrReturnCtx(e,i),addIssueToContext(i,{validation:"url",code:ZodIssueCode.invalid_string,message:r.message}),t.dirty()}else if("regex"===r.kind){r.regex.lastIndex=0;r.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{validation:"regex",code:ZodIssueCode.invalid_string,message:r.message}),t.dirty())}else if("trim"===r.kind)e.data=e.data.trim();else if("includes"===r.kind)e.data.includes(r.value,r.position)||(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{code:ZodIssueCode.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty());else if("toLowerCase"===r.kind)e.data=e.data.toLowerCase();else if("toUpperCase"===r.kind)e.data=e.data.toUpperCase();else if("startsWith"===r.kind)e.data.startsWith(r.value)||(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{code:ZodIssueCode.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty());else if("endsWith"===r.kind)e.data.endsWith(r.value)||(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{code:ZodIssueCode.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty());else if("datetime"===r.kind){datetimeRegex(r).test(e.data)||(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{code:ZodIssueCode.invalid_string,validation:"datetime",message:r.message}),t.dirty())}else if("date"===r.kind){dateRegex.test(e.data)||(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{code:ZodIssueCode.invalid_string,validation:"date",message:r.message}),t.dirty())}else if("time"===r.kind){timeRegex(r).test(e.data)||(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{code:ZodIssueCode.invalid_string,validation:"time",message:r.message}),t.dirty())}else"duration"===r.kind?durationRegex.test(e.data)||(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{validation:"duration",code:ZodIssueCode.invalid_string,message:r.message}),t.dirty()):"ip"===r.kind?isValidIP(e.data,r.version)||(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{validation:"ip",code:ZodIssueCode.invalid_string,message:r.message}),t.dirty()):"base64"===r.kind?base64Regex.test(e.data)||(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{validation:"base64",code:ZodIssueCode.invalid_string,message:r.message}),t.dirty()):util$1.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,i){return this.refinement((t=>e.test(t)),{validation:t,code:ZodIssueCode.invalid_string,...errorUtil.errToObj(i)})}_addCheck(e){return new ZodString({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...errorUtil.errToObj(e)})}url(e){return this._addCheck({kind:"url",...errorUtil.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...errorUtil.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...errorUtil.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...errorUtil.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...errorUtil.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...errorUtil.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...errorUtil.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...errorUtil.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...errorUtil.errToObj(e)})}datetime(e){var t,i;return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,offset:null!==(t=null==e?void 0:e.offset)&&void 0!==t&&t,local:null!==(i=null==e?void 0:e.local)&&void 0!==i&&i,...errorUtil.errToObj(null==e?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,...errorUtil.errToObj(null==e?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...errorUtil.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...errorUtil.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:null==t?void 0:t.position,...errorUtil.errToObj(null==t?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...errorUtil.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...errorUtil.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...errorUtil.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...errorUtil.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...errorUtil.errToObj(t)})}nonempty(e){return this.min(1,errorUtil.errToObj(e))}trim(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((e=>"datetime"===e.kind))}get isDate(){return!!this._def.checks.find((e=>"date"===e.kind))}get isTime(){return!!this._def.checks.find((e=>"time"===e.kind))}get isDuration(){return!!this._def.checks.find((e=>"duration"===e.kind))}get isEmail(){return!!this._def.checks.find((e=>"email"===e.kind))}get isURL(){return!!this._def.checks.find((e=>"url"===e.kind))}get isEmoji(){return!!this._def.checks.find((e=>"emoji"===e.kind))}get isUUID(){return!!this._def.checks.find((e=>"uuid"===e.kind))}get isNANOID(){return!!this._def.checks.find((e=>"nanoid"===e.kind))}get isCUID(){return!!this._def.checks.find((e=>"cuid"===e.kind))}get isCUID2(){return!!this._def.checks.find((e=>"cuid2"===e.kind))}get isULID(){return!!this._def.checks.find((e=>"ulid"===e.kind))}get isIP(){return!!this._def.checks.find((e=>"ip"===e.kind))}get isBase64(){return!!this._def.checks.find((e=>"base64"===e.kind))}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}function floatSafeRemainder(e,t){const i=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,n=i>r?i:r;return parseInt(e.toFixed(n).replace(".",""))%parseInt(t.toFixed(n).replace(".",""))/Math.pow(10,n)}ZodString.create=e=>{var t;return new ZodString({checks:[],typeName:ZodFirstPartyTypeKind.ZodString,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...processCreateParams(e)})};class ZodNumber extends ZodType{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){this._def.coerce&&(e.data=Number(e.data));if(this._getType(e)!==ZodParsedType.number){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.number,received:t.parsedType}),INVALID}let t;const i=new ParseStatus;for(const r of this._def.checks)if("int"===r.kind)util$1.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:"integer",received:"float",message:r.message}),i.dirty());else if("min"===r.kind){(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:ZodIssueCode.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),i.dirty())}else if("max"===r.kind){(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:ZodIssueCode.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),i.dirty())}else"multipleOf"===r.kind?0!==floatSafeRemainder(e.data,r.value)&&(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:ZodIssueCode.not_multiple_of,multipleOf:r.value,message:r.message}),i.dirty()):"finite"===r.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:ZodIssueCode.not_finite,message:r.message}),i.dirty()):util$1.assertNever(r);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,errorUtil.toString(t))}gt(e,t){return this.setLimit("min",e,!1,errorUtil.toString(t))}lte(e,t){return this.setLimit("max",e,!0,errorUtil.toString(t))}lt(e,t){return this.setLimit("max",e,!1,errorUtil.toString(t))}setLimit(e,t,i,r){return new ZodNumber({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:i,message:errorUtil.toString(r)}]})}_addCheck(e){return new ZodNumber({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:errorUtil.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:errorUtil.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:errorUtil.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:errorUtil.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:errorUtil.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:errorUtil.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:errorUtil.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find((e=>"int"===e.kind||"multipleOf"===e.kind&&util$1.isInteger(e.value)))}get isFinite(){let e=null,t=null;for(const i of this._def.checks){if("finite"===i.kind||"int"===i.kind||"multipleOf"===i.kind)return!0;"min"===i.kind?(null===t||i.value>t)&&(t=i.value):"max"===i.kind&&(null===e||i.value<e)&&(e=i.value)}return Number.isFinite(t)&&Number.isFinite(e)}}ZodNumber.create=e=>new ZodNumber({checks:[],typeName:ZodFirstPartyTypeKind.ZodNumber,coerce:(null==e?void 0:e.coerce)||!1,...processCreateParams(e)});class ZodBigInt extends ZodType{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){this._def.coerce&&(e.data=BigInt(e.data));if(this._getType(e)!==ZodParsedType.bigint){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.bigint,received:t.parsedType}),INVALID}let t;const i=new ParseStatus;for(const r of this._def.checks)if("min"===r.kind){(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:ZodIssueCode.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),i.dirty())}else if("max"===r.kind){(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:ZodIssueCode.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),i.dirty())}else"multipleOf"===r.kind?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:ZodIssueCode.not_multiple_of,multipleOf:r.value,message:r.message}),i.dirty()):util$1.assertNever(r);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,errorUtil.toString(t))}gt(e,t){return this.setLimit("min",e,!1,errorUtil.toString(t))}lte(e,t){return this.setLimit("max",e,!0,errorUtil.toString(t))}lt(e,t){return this.setLimit("max",e,!1,errorUtil.toString(t))}setLimit(e,t,i,r){return new ZodBigInt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:i,message:errorUtil.toString(r)}]})}_addCheck(e){return new ZodBigInt({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:errorUtil.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:errorUtil.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:errorUtil.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}ZodBigInt.create=e=>{var t;return new ZodBigInt({checks:[],typeName:ZodFirstPartyTypeKind.ZodBigInt,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...processCreateParams(e)})};class ZodBoolean extends ZodType{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==ZodParsedType.boolean){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.boolean,received:t.parsedType}),INVALID}return OK(e.data)}}ZodBoolean.create=e=>new ZodBoolean({typeName:ZodFirstPartyTypeKind.ZodBoolean,coerce:(null==e?void 0:e.coerce)||!1,...processCreateParams(e)});class ZodDate extends ZodType{_parse(e){this._def.coerce&&(e.data=new Date(e.data));if(this._getType(e)!==ZodParsedType.date){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.date,received:t.parsedType}),INVALID}if(isNaN(e.data.getTime())){return addIssueToContext(this._getOrReturnCtx(e),{code:ZodIssueCode.invalid_date}),INVALID}const t=new ParseStatus;let i;for(const r of this._def.checks)"min"===r.kind?e.data.getTime()<r.value&&(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{code:ZodIssueCode.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),t.dirty()):"max"===r.kind?e.data.getTime()>r.value&&(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{code:ZodIssueCode.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),t.dirty()):util$1.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ZodDate({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:errorUtil.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:errorUtil.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}ZodDate.create=e=>new ZodDate({checks:[],coerce:(null==e?void 0:e.coerce)||!1,typeName:ZodFirstPartyTypeKind.ZodDate,...processCreateParams(e)});class ZodSymbol extends ZodType{_parse(e){if(this._getType(e)!==ZodParsedType.symbol){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.symbol,received:t.parsedType}),INVALID}return OK(e.data)}}ZodSymbol.create=e=>new ZodSymbol({typeName:ZodFirstPartyTypeKind.ZodSymbol,...processCreateParams(e)});class ZodUndefined extends ZodType{_parse(e){if(this._getType(e)!==ZodParsedType.undefined){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.undefined,received:t.parsedType}),INVALID}return OK(e.data)}}ZodUndefined.create=e=>new ZodUndefined({typeName:ZodFirstPartyTypeKind.ZodUndefined,...processCreateParams(e)});class ZodNull extends ZodType{_parse(e){if(this._getType(e)!==ZodParsedType.null){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.null,received:t.parsedType}),INVALID}return OK(e.data)}}ZodNull.create=e=>new ZodNull({typeName:ZodFirstPartyTypeKind.ZodNull,...processCreateParams(e)});class ZodAny extends ZodType{constructor(){super(...arguments),this._any=!0}_parse(e){return OK(e.data)}}ZodAny.create=e=>new ZodAny({typeName:ZodFirstPartyTypeKind.ZodAny,...processCreateParams(e)});class ZodUnknown extends ZodType{constructor(){super(...arguments),this._unknown=!0}_parse(e){return OK(e.data)}}ZodUnknown.create=e=>new ZodUnknown({typeName:ZodFirstPartyTypeKind.ZodUnknown,...processCreateParams(e)});class ZodNever extends ZodType{_parse(e){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.never,received:t.parsedType}),INVALID}}ZodNever.create=e=>new ZodNever({typeName:ZodFirstPartyTypeKind.ZodNever,...processCreateParams(e)});class ZodVoid extends ZodType{_parse(e){if(this._getType(e)!==ZodParsedType.undefined){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.void,received:t.parsedType}),INVALID}return OK(e.data)}}ZodVoid.create=e=>new ZodVoid({typeName:ZodFirstPartyTypeKind.ZodVoid,...processCreateParams(e)});class ZodArray extends ZodType{_parse(e){const{ctx:t,status:i}=this._processInputParams(e),r=this._def;if(t.parsedType!==ZodParsedType.array)return addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.array,received:t.parsedType}),INVALID;if(null!==r.exactLength){const e=t.data.length>r.exactLength.value,n=t.data.length<r.exactLength.value;(e||n)&&(addIssueToContext(t,{code:e?ZodIssueCode.too_big:ZodIssueCode.too_small,minimum:n?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),i.dirty())}if(null!==r.minLength&&t.data.length<r.minLength.value&&(addIssueToContext(t,{code:ZodIssueCode.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),i.dirty()),null!==r.maxLength&&t.data.length>r.maxLength.value&&(addIssueToContext(t,{code:ZodIssueCode.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),i.dirty()),t.common.async)return Promise.all([...t.data].map(((e,i)=>r.type._parseAsync(new ParseInputLazyPath(t,e,t.path,i))))).then((e=>ParseStatus.mergeArray(i,e)));const n=[...t.data].map(((e,i)=>r.type._parseSync(new ParseInputLazyPath(t,e,t.path,i))));return ParseStatus.mergeArray(i,n)}get element(){return this._def.type}min(e,t){return new ZodArray({...this._def,minLength:{value:e,message:errorUtil.toString(t)}})}max(e,t){return new ZodArray({...this._def,maxLength:{value:e,message:errorUtil.toString(t)}})}length(e,t){return new ZodArray({...this._def,exactLength:{value:e,message:errorUtil.toString(t)}})}nonempty(e){return this.min(1,e)}}function deepPartialify(e){if(e instanceof ZodObject){const t={};for(const i in e.shape){const r=e.shape[i];t[i]=ZodOptional.create(deepPartialify(r))}return new ZodObject({...e._def,shape:()=>t})}return e instanceof ZodArray?new ZodArray({...e._def,type:deepPartialify(e.element)}):e instanceof ZodOptional?ZodOptional.create(deepPartialify(e.unwrap())):e instanceof ZodNullable?ZodNullable.create(deepPartialify(e.unwrap())):e instanceof ZodTuple?ZodTuple.create(e.items.map((e=>deepPartialify(e)))):e}ZodArray.create=(e,t)=>new ZodArray({type:e,minLength:null,maxLength:null,exactLength:null,typeName:ZodFirstPartyTypeKind.ZodArray,...processCreateParams(t)});class ZodObject extends ZodType{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const e=this._def.shape(),t=util$1.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==ZodParsedType.object){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.object,received:t.parsedType}),INVALID}const{status:t,ctx:i}=this._processInputParams(e),{shape:r,keys:n}=this._getCached(),a=[];if(!(this._def.catchall instanceof ZodNever&&"strip"===this._def.unknownKeys))for(const e in i.data)n.includes(e)||a.push(e);const o=[];for(const e of n){const t=r[e],n=i.data[e];o.push({key:{status:"valid",value:e},value:t._parse(new ParseInputLazyPath(i,n,i.path,e)),alwaysSet:e in i.data})}if(this._def.catchall instanceof ZodNever){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of a)o.push({key:{status:"valid",value:e},value:{status:"valid",value:i.data[e]}});else if("strict"===e)a.length>0&&(addIssueToContext(i,{code:ZodIssueCode.unrecognized_keys,keys:a}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of a){const r=i.data[t];o.push({key:{status:"valid",value:t},value:e._parse(new ParseInputLazyPath(i,r,i.path,t)),alwaysSet:t in i.data})}}return i.common.async?Promise.resolve().then((async()=>{const e=[];for(const t of o){const i=await t.key,r=await t.value;e.push({key:i,value:r,alwaysSet:t.alwaysSet})}return e})).then((e=>ParseStatus.mergeObjectSync(t,e))):ParseStatus.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return errorUtil.errToObj,new ZodObject({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,i)=>{var r,n,a,o;const s=null!==(a=null===(n=(r=this._def).errorMap)||void 0===n?void 0:n.call(r,t,i).message)&&void 0!==a?a:i.defaultError;return"unrecognized_keys"===t.code?{message:null!==(o=errorUtil.errToObj(e).message)&&void 0!==o?o:s}:{message:s}}}:{}})}strip(){return new ZodObject({...this._def,unknownKeys:"strip"})}passthrough(){return new ZodObject({...this._def,unknownKeys:"passthrough"})}extend(e){return new ZodObject({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ZodObject({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:ZodFirstPartyTypeKind.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ZodObject({...this._def,catchall:e})}pick(e){const t={};return util$1.objectKeys(e).forEach((i=>{e[i]&&this.shape[i]&&(t[i]=this.shape[i])})),new ZodObject({...this._def,shape:()=>t})}omit(e){const t={};return util$1.objectKeys(this.shape).forEach((i=>{e[i]||(t[i]=this.shape[i])})),new ZodObject({...this._def,shape:()=>t})}deepPartial(){return deepPartialify(this)}partial(e){const t={};return util$1.objectKeys(this.shape).forEach((i=>{const r=this.shape[i];e&&!e[i]?t[i]=r:t[i]=r.optional()})),new ZodObject({...this._def,shape:()=>t})}required(e){const t={};return util$1.objectKeys(this.shape).forEach((i=>{if(e&&!e[i])t[i]=this.shape[i];else{let e=this.shape[i];for(;e instanceof ZodOptional;)e=e._def.innerType;t[i]=e}})),new ZodObject({...this._def,shape:()=>t})}keyof(){return createZodEnum(util$1.objectKeys(this.shape))}}ZodObject.create=(e,t)=>new ZodObject({shape:()=>e,unknownKeys:"strip",catchall:ZodNever.create(),typeName:ZodFirstPartyTypeKind.ZodObject,...processCreateParams(t)}),ZodObject.strictCreate=(e,t)=>new ZodObject({shape:()=>e,unknownKeys:"strict",catchall:ZodNever.create(),typeName:ZodFirstPartyTypeKind.ZodObject,...processCreateParams(t)}),ZodObject.lazycreate=(e,t)=>new ZodObject({shape:e,unknownKeys:"strip",catchall:ZodNever.create(),typeName:ZodFirstPartyTypeKind.ZodObject,...processCreateParams(t)});class ZodUnion extends ZodType{_parse(e){const{ctx:t}=this._processInputParams(e),i=this._def.options;if(t.common.async)return Promise.all(i.map((async e=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}}))).then((function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const i of e)if("dirty"===i.result.status)return t.common.issues.push(...i.ctx.common.issues),i.result;const i=e.map((e=>new ZodError(e.ctx.common.issues)));return addIssueToContext(t,{code:ZodIssueCode.invalid_union,unionErrors:i}),INVALID}));{let e;const r=[];for(const n of i){const i={...t,common:{...t.common,issues:[]},parent:null},a=n._parseSync({data:t.data,path:t.path,parent:i});if("valid"===a.status)return a;"dirty"!==a.status||e||(e={result:a,ctx:i}),i.common.issues.length&&r.push(i.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const n=r.map((e=>new ZodError(e)));return addIssueToContext(t,{code:ZodIssueCode.invalid_union,unionErrors:n}),INVALID}}get options(){return this._def.options}}ZodUnion.create=(e,t)=>new ZodUnion({options:e,typeName:ZodFirstPartyTypeKind.ZodUnion,...processCreateParams(t)});const getDiscriminator=e=>e instanceof ZodLazy?getDiscriminator(e.schema):e instanceof ZodEffects?getDiscriminator(e.innerType()):e instanceof ZodLiteral?[e.value]:e instanceof ZodEnum?e.options:e instanceof ZodNativeEnum?util$1.objectValues(e.enum):e instanceof ZodDefault?getDiscriminator(e._def.innerType):e instanceof ZodUndefined?[void 0]:e instanceof ZodNull?[null]:e instanceof ZodOptional?[void 0,...getDiscriminator(e.unwrap())]:e instanceof ZodNullable?[null,...getDiscriminator(e.unwrap())]:e instanceof ZodBranded||e instanceof ZodReadonly?getDiscriminator(e.unwrap()):e instanceof ZodCatch?getDiscriminator(e._def.innerType):[];class ZodDiscriminatedUnion extends ZodType{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ZodParsedType.object)return addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.object,received:t.parsedType}),INVALID;const i=this.discriminator,r=t.data[i],n=this.optionsMap.get(r);return n?t.common.async?n._parseAsync({data:t.data,path:t.path,parent:t}):n._parseSync({data:t.data,path:t.path,parent:t}):(addIssueToContext(t,{code:ZodIssueCode.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[i]}),INVALID)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,i){const r=new Map;for(const i of t){const t=getDiscriminator(i.shape[e]);if(!t.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const n of t){if(r.has(n))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(n)}`);r.set(n,i)}}return new ZodDiscriminatedUnion({typeName:ZodFirstPartyTypeKind.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...processCreateParams(i)})}}function mergeValues(e,t){const i=getParsedType(e),r=getParsedType(t);if(e===t)return{valid:!0,data:e};if(i===ZodParsedType.object&&r===ZodParsedType.object){const i=util$1.objectKeys(t),r=util$1.objectKeys(e).filter((e=>-1!==i.indexOf(e))),n={...e,...t};for(const i of r){const r=mergeValues(e[i],t[i]);if(!r.valid)return{valid:!1};n[i]=r.data}return{valid:!0,data:n}}if(i===ZodParsedType.array&&r===ZodParsedType.array){if(e.length!==t.length)return{valid:!1};const i=[];for(let r=0;r<e.length;r++){const n=mergeValues(e[r],t[r]);if(!n.valid)return{valid:!1};i.push(n.data)}return{valid:!0,data:i}}return i===ZodParsedType.date&&r===ZodParsedType.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class ZodIntersection extends ZodType{_parse(e){const{status:t,ctx:i}=this._processInputParams(e),r=(e,r)=>{if(isAborted(e)||isAborted(r))return INVALID;const n=mergeValues(e.value,r.value);return n.valid?((isDirty(e)||isDirty(r))&&t.dirty(),{status:t.value,value:n.data}):(addIssueToContext(i,{code:ZodIssueCode.invalid_intersection_types}),INVALID)};return i.common.async?Promise.all([this._def.left._parseAsync({data:i.data,path:i.path,parent:i}),this._def.right._parseAsync({data:i.data,path:i.path,parent:i})]).then((([e,t])=>r(e,t))):r(this._def.left._parseSync({data:i.data,path:i.path,parent:i}),this._def.right._parseSync({data:i.data,path:i.path,parent:i}))}}ZodIntersection.create=(e,t,i)=>new ZodIntersection({left:e,right:t,typeName:ZodFirstPartyTypeKind.ZodIntersection,...processCreateParams(i)});class ZodTuple extends ZodType{_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==ZodParsedType.array)return addIssueToContext(i,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.array,received:i.parsedType}),INVALID;if(i.data.length<this._def.items.length)return addIssueToContext(i,{code:ZodIssueCode.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),INVALID;!this._def.rest&&i.data.length>this._def.items.length&&(addIssueToContext(i,{code:ZodIssueCode.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...i.data].map(((e,t)=>{const r=this._def.items[t]||this._def.rest;return r?r._parse(new ParseInputLazyPath(i,e,i.path,t)):null})).filter((e=>!!e));return i.common.async?Promise.all(r).then((e=>ParseStatus.mergeArray(t,e))):ParseStatus.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new ZodTuple({...this._def,rest:e})}}ZodTuple.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ZodTuple({items:e,typeName:ZodFirstPartyTypeKind.ZodTuple,rest:null,...processCreateParams(t)})};class ZodRecord extends ZodType{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==ZodParsedType.object)return addIssueToContext(i,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.object,received:i.parsedType}),INVALID;const r=[],n=this._def.keyType,a=this._def.valueType;for(const e in i.data)r.push({key:n._parse(new ParseInputLazyPath(i,e,i.path,e)),value:a._parse(new ParseInputLazyPath(i,i.data[e],i.path,e)),alwaysSet:e in i.data});return i.common.async?ParseStatus.mergeObjectAsync(t,r):ParseStatus.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,i){return new ZodRecord(t instanceof ZodType?{keyType:e,valueType:t,typeName:ZodFirstPartyTypeKind.ZodRecord,...processCreateParams(i)}:{keyType:ZodString.create(),valueType:e,typeName:ZodFirstPartyTypeKind.ZodRecord,...processCreateParams(t)})}}class ZodMap extends ZodType{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==ZodParsedType.map)return addIssueToContext(i,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.map,received:i.parsedType}),INVALID;const r=this._def.keyType,n=this._def.valueType,a=[...i.data.entries()].map((([e,t],a)=>({key:r._parse(new ParseInputLazyPath(i,e,i.path,[a,"key"])),value:n._parse(new ParseInputLazyPath(i,t,i.path,[a,"value"]))})));if(i.common.async){const e=new Map;return Promise.resolve().then((async()=>{for(const i of a){const r=await i.key,n=await i.value;if("aborted"===r.status||"aborted"===n.status)return INVALID;"dirty"!==r.status&&"dirty"!==n.status||t.dirty(),e.set(r.value,n.value)}return{status:t.value,value:e}}))}{const e=new Map;for(const i of a){const r=i.key,n=i.value;if("aborted"===r.status||"aborted"===n.status)return INVALID;"dirty"!==r.status&&"dirty"!==n.status||t.dirty(),e.set(r.value,n.value)}return{status:t.value,value:e}}}}ZodMap.create=(e,t,i)=>new ZodMap({valueType:t,keyType:e,typeName:ZodFirstPartyTypeKind.ZodMap,...processCreateParams(i)});class ZodSet extends ZodType{_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==ZodParsedType.set)return addIssueToContext(i,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.set,received:i.parsedType}),INVALID;const r=this._def;null!==r.minSize&&i.data.size<r.minSize.value&&(addIssueToContext(i,{code:ZodIssueCode.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),null!==r.maxSize&&i.data.size>r.maxSize.value&&(addIssueToContext(i,{code:ZodIssueCode.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const n=this._def.valueType;function a(e){const i=new Set;for(const r of e){if("aborted"===r.status)return INVALID;"dirty"===r.status&&t.dirty(),i.add(r.value)}return{status:t.value,value:i}}const o=[...i.data.values()].map(((e,t)=>n._parse(new ParseInputLazyPath(i,e,i.path,t))));return i.common.async?Promise.all(o).then((e=>a(e))):a(o)}min(e,t){return new ZodSet({...this._def,minSize:{value:e,message:errorUtil.toString(t)}})}max(e,t){return new ZodSet({...this._def,maxSize:{value:e,message:errorUtil.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ZodSet.create=(e,t)=>new ZodSet({valueType:e,minSize:null,maxSize:null,typeName:ZodFirstPartyTypeKind.ZodSet,...processCreateParams(t)});class ZodFunction extends ZodType{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ZodParsedType.function)return addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.function,received:t.parsedType}),INVALID;function i(e,i){return makeIssue({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,getErrorMap(),errorMap].filter((e=>!!e)),issueData:{code:ZodIssueCode.invalid_arguments,argumentsError:i}})}function r(e,i){return makeIssue({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,getErrorMap(),errorMap].filter((e=>!!e)),issueData:{code:ZodIssueCode.invalid_return_type,returnTypeError:i}})}const n={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof ZodPromise){const e=this;return OK((async function(...t){const o=new ZodError([]),s=await e._def.args.parseAsync(t,n).catch((e=>{throw o.addIssue(i(t,e)),o})),l=await Reflect.apply(a,this,s),u=await e._def.returns._def.type.parseAsync(l,n).catch((e=>{throw o.addIssue(r(l,e)),o}));return u}))}{const e=this;return OK((function(...t){const o=e._def.args.safeParse(t,n);if(!o.success)throw new ZodError([i(t,o.error)]);const s=Reflect.apply(a,this,o.data),l=e._def.returns.safeParse(s,n);if(!l.success)throw new ZodError([r(s,l.error)]);return l.data}))}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ZodFunction({...this._def,args:ZodTuple.create(e).rest(ZodUnknown.create())})}returns(e){return new ZodFunction({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,i){return new ZodFunction({args:e||ZodTuple.create([]).rest(ZodUnknown.create()),returns:t||ZodUnknown.create(),typeName:ZodFirstPartyTypeKind.ZodFunction,...processCreateParams(i)})}}class ZodLazy extends ZodType{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ZodLazy.create=(e,t)=>new ZodLazy({getter:e,typeName:ZodFirstPartyTypeKind.ZodLazy,...processCreateParams(t)});class ZodLiteral extends ZodType{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{received:t.data,code:ZodIssueCode.invalid_literal,expected:this._def.value}),INVALID}return{status:"valid",value:e.data}}get value(){return this._def.value}}function createZodEnum(e,t){return new ZodEnum({values:e,typeName:ZodFirstPartyTypeKind.ZodEnum,...processCreateParams(t)})}ZodLiteral.create=(e,t)=>new ZodLiteral({value:e,typeName:ZodFirstPartyTypeKind.ZodLiteral,...processCreateParams(t)});class ZodEnum extends ZodType{constructor(){super(...arguments),_ZodEnum_cache.set(this,void 0)}_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),i=this._def.values;return addIssueToContext(t,{expected:util$1.joinValues(i),received:t.parsedType,code:ZodIssueCode.invalid_type}),INVALID}if(__classPrivateFieldGet(this,_ZodEnum_cache)||__classPrivateFieldSet(this,_ZodEnum_cache,new Set(this._def.values)),!__classPrivateFieldGet(this,_ZodEnum_cache).has(e.data)){const t=this._getOrReturnCtx(e),i=this._def.values;return addIssueToContext(t,{received:t.data,code:ZodIssueCode.invalid_enum_value,options:i}),INVALID}return OK(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return ZodEnum.create(e,{...this._def,...t})}exclude(e,t=this._def){return ZodEnum.create(this.options.filter((t=>!e.includes(t))),{...this._def,...t})}}_ZodEnum_cache=new WeakMap,ZodEnum.create=createZodEnum;class ZodNativeEnum extends ZodType{constructor(){super(...arguments),_ZodNativeEnum_cache.set(this,void 0)}_parse(e){const t=util$1.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(e);if(i.parsedType!==ZodParsedType.string&&i.parsedType!==ZodParsedType.number){const e=util$1.objectValues(t);return addIssueToContext(i,{expected:util$1.joinValues(e),received:i.parsedType,code:ZodIssueCode.invalid_type}),INVALID}if(__classPrivateFieldGet(this,_ZodNativeEnum_cache)||__classPrivateFieldSet(this,_ZodNativeEnum_cache,new Set(util$1.getValidEnumValues(this._def.values))),!__classPrivateFieldGet(this,_ZodNativeEnum_cache).has(e.data)){const e=util$1.objectValues(t);return addIssueToContext(i,{received:i.data,code:ZodIssueCode.invalid_enum_value,options:e}),INVALID}return OK(e.data)}get enum(){return this._def.values}}_ZodNativeEnum_cache=new WeakMap,ZodNativeEnum.create=(e,t)=>new ZodNativeEnum({values:e,typeName:ZodFirstPartyTypeKind.ZodNativeEnum,...processCreateParams(t)});class ZodPromise extends ZodType{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ZodParsedType.promise&&!1===t.common.async)return addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.promise,received:t.parsedType}),INVALID;const i=t.parsedType===ZodParsedType.promise?t.data:Promise.resolve(t.data);return OK(i.then((e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap}))))}}ZodPromise.create=(e,t)=>new ZodPromise({type:e,typeName:ZodFirstPartyTypeKind.ZodPromise,...processCreateParams(t)});class ZodEffects extends ZodType{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ZodFirstPartyTypeKind.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:i}=this._processInputParams(e),r=this._def.effect||null,n={addIssue:e=>{addIssueToContext(i,e),e.fatal?t.abort():t.dirty()},get path(){return i.path}};if(n.addIssue=n.addIssue.bind(n),"preprocess"===r.type){const e=r.transform(i.data,n);if(i.common.async)return Promise.resolve(e).then((async e=>{if("aborted"===t.value)return INVALID;const r=await this._def.schema._parseAsync({data:e,path:i.path,parent:i});return"aborted"===r.status?INVALID:"dirty"===r.status||"dirty"===t.value?DIRTY(r.value):r}));{if("aborted"===t.value)return INVALID;const r=this._def.schema._parseSync({data:e,path:i.path,parent:i});return"aborted"===r.status?INVALID:"dirty"===r.status||"dirty"===t.value?DIRTY(r.value):r}}if("refinement"===r.type){const e=e=>{const t=r.refinement(e,n);if(i.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===i.common.async){const r=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});return"aborted"===r.status?INVALID:("dirty"===r.status&&t.dirty(),e(r.value),{status:t.value,value:r.value})}return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then((i=>"aborted"===i.status?INVALID:("dirty"===i.status&&t.dirty(),e(i.value).then((()=>({status:t.value,value:i.value}))))))}if("transform"===r.type){if(!1===i.common.async){const e=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});if(!isValid(e))return e;const a=r.transform(e.value,n);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then((e=>isValid(e)?Promise.resolve(r.transform(e.value,n)).then((e=>({status:t.value,value:e}))):e))}util$1.assertNever(r)}}ZodEffects.create=(e,t,i)=>new ZodEffects({schema:e,typeName:ZodFirstPartyTypeKind.ZodEffects,effect:t,...processCreateParams(i)}),ZodEffects.createWithPreprocess=(e,t,i)=>new ZodEffects({schema:t,effect:{type:"preprocess",transform:e},typeName:ZodFirstPartyTypeKind.ZodEffects,...processCreateParams(i)});class ZodOptional extends ZodType{_parse(e){return this._getType(e)===ZodParsedType.undefined?OK(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ZodOptional.create=(e,t)=>new ZodOptional({innerType:e,typeName:ZodFirstPartyTypeKind.ZodOptional,...processCreateParams(t)});class ZodNullable extends ZodType{_parse(e){return this._getType(e)===ZodParsedType.null?OK(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ZodNullable.create=(e,t)=>new ZodNullable({innerType:e,typeName:ZodFirstPartyTypeKind.ZodNullable,...processCreateParams(t)});class ZodDefault extends ZodType{_parse(e){const{ctx:t}=this._processInputParams(e);let i=t.data;return t.parsedType===ZodParsedType.undefined&&(i=this._def.defaultValue()),this._def.innerType._parse({data:i,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ZodDefault.create=(e,t)=>new ZodDefault({innerType:e,typeName:ZodFirstPartyTypeKind.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...processCreateParams(t)});class ZodCatch extends ZodType{_parse(e){const{ctx:t}=this._processInputParams(e),i={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:i.data,path:i.path,parent:{...i}});return isAsync(r)?r.then((e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new ZodError(i.common.issues)},input:i.data})}))):{status:"valid",value:"valid"===r.status?r.value:this._def.catchValue({get error(){return new ZodError(i.common.issues)},input:i.data})}}removeCatch(){return this._def.innerType}}ZodCatch.create=(e,t)=>new ZodCatch({innerType:e,typeName:ZodFirstPartyTypeKind.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...processCreateParams(t)});class ZodNaN extends ZodType{_parse(e){if(this._getType(e)!==ZodParsedType.nan){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.nan,received:t.parsedType}),INVALID}return{status:"valid",value:e.data}}}ZodNaN.create=e=>new ZodNaN({typeName:ZodFirstPartyTypeKind.ZodNaN,...processCreateParams(e)});const BRAND=Symbol("zod_brand");class ZodBranded extends ZodType{_parse(e){const{ctx:t}=this._processInputParams(e),i=t.data;return this._def.type._parse({data:i,path:t.path,parent:t})}unwrap(){return this._def.type}}class ZodPipeline extends ZodType{_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.common.async){return(async()=>{const e=await this._def.in._parseAsync({data:i.data,path:i.path,parent:i});return"aborted"===e.status?INVALID:"dirty"===e.status?(t.dirty(),DIRTY(e.value)):this._def.out._parseAsync({data:e.value,path:i.path,parent:i})})()}{const e=this._def.in._parseSync({data:i.data,path:i.path,parent:i});return"aborted"===e.status?INVALID:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:i.path,parent:i})}}static create(e,t){return new ZodPipeline({in:e,out:t,typeName:ZodFirstPartyTypeKind.ZodPipeline})}}class ZodReadonly extends ZodType{_parse(e){const t=this._def.innerType._parse(e),i=e=>(isValid(e)&&(e.value=Object.freeze(e.value)),e);return isAsync(t)?t.then((e=>i(e))):i(t)}unwrap(){return this._def.innerType}}function custom(e,t={},i){return e?ZodAny.create().superRefine(((r,n)=>{var a,o;if(!e(r)){const e="function"==typeof t?t(r):"string"==typeof t?{message:t}:t,s=null===(o=null!==(a=e.fatal)&&void 0!==a?a:i)||void 0===o||o,l="string"==typeof e?{message:e}:e;n.addIssue({code:"custom",...l,fatal:s})}})):ZodAny.create()}ZodReadonly.create=(e,t)=>new ZodReadonly({innerType:e,typeName:ZodFirstPartyTypeKind.ZodReadonly,...processCreateParams(t)});const late={object:ZodObject.lazycreate};var ZodFirstPartyTypeKind;!function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"}(ZodFirstPartyTypeKind||(ZodFirstPartyTypeKind={}));const instanceOfType=(e,t={message:`Input not instance of ${e.name}`})=>custom((t=>t instanceof e),t),stringType=ZodString.create,numberType=ZodNumber.create,nanType=ZodNaN.create,bigIntType=ZodBigInt.create,booleanType=ZodBoolean.create,dateType=ZodDate.create,symbolType=ZodSymbol.create,undefinedType=ZodUndefined.create,nullType=ZodNull.create,anyType=ZodAny.create,unknownType=ZodUnknown.create,neverType=ZodNever.create,voidType=ZodVoid.create,arrayType=ZodArray.create,objectType=ZodObject.create,strictObjectType=ZodObject.strictCreate,unionType=ZodUnion.create,discriminatedUnionType=ZodDiscriminatedUnion.create,intersectionType=ZodIntersection.create,tupleType=ZodTuple.create,recordType=ZodRecord.create,mapType=ZodMap.create,setType=ZodSet.create,functionType=ZodFunction.create,lazyType=ZodLazy.create,literalType=ZodLiteral.create,enumType=ZodEnum.create,nativeEnumType=ZodNativeEnum.create,promiseType=ZodPromise.create,effectsType=ZodEffects.create,optionalType=ZodOptional.create,nullableType=ZodNullable.create,preprocessType=ZodEffects.createWithPreprocess,pipelineType=ZodPipeline.create,ostring=()=>stringType().optional(),onumber=()=>numberType().optional(),oboolean=()=>booleanType().optional(),coerce={string:e=>ZodString.create({...e,coerce:!0}),number:e=>ZodNumber.create({...e,coerce:!0}),boolean:e=>ZodBoolean.create({...e,coerce:!0}),bigint:e=>ZodBigInt.create({...e,coerce:!0}),date:e=>ZodDate.create({...e,coerce:!0})},NEVER=INVALID;var z=Object.freeze({__proto__:null,defaultErrorMap:errorMap,setErrorMap:setErrorMap,getErrorMap:getErrorMap,makeIssue:makeIssue,EMPTY_PATH:EMPTY_PATH,addIssueToContext:addIssueToContext,ParseStatus:ParseStatus,INVALID:INVALID,DIRTY:DIRTY,OK:OK,isAborted:isAborted,isDirty:isDirty,isValid:isValid,isAsync:isAsync,get util(){return util$1},get objectUtil(){return objectUtil},ZodParsedType:ZodParsedType,getParsedType:getParsedType,ZodType:ZodType,datetimeRegex:datetimeRegex,ZodString:ZodString,ZodNumber:ZodNumber,ZodBigInt:ZodBigInt,ZodBoolean:ZodBoolean,ZodDate:ZodDate,ZodSymbol:ZodSymbol,ZodUndefined:ZodUndefined,ZodNull:ZodNull,ZodAny:ZodAny,ZodUnknown:ZodUnknown,ZodNever:ZodNever,ZodVoid:ZodVoid,ZodArray:ZodArray,ZodObject:ZodObject,ZodUnion:ZodUnion,ZodDiscriminatedUnion:ZodDiscriminatedUnion,ZodIntersection:ZodIntersection,ZodTuple:ZodTuple,ZodRecord:ZodRecord,ZodMap:ZodMap,ZodSet:ZodSet,ZodFunction:ZodFunction,ZodLazy:ZodLazy,ZodLiteral:ZodLiteral,ZodEnum:ZodEnum,ZodNativeEnum:ZodNativeEnum,ZodPromise:ZodPromise,ZodEffects:ZodEffects,ZodTransformer:ZodEffects,ZodOptional:ZodOptional,ZodNullable:ZodNullable,ZodDefault:ZodDefault,ZodCatch:ZodCatch,ZodNaN:ZodNaN,BRAND:BRAND,ZodBranded:ZodBranded,ZodPipeline:ZodPipeline,ZodReadonly:ZodReadonly,custom:custom,Schema:ZodType,ZodSchema:ZodType,late:late,get ZodFirstPartyTypeKind(){return ZodFirstPartyTypeKind},coerce:coerce,any:anyType,array:arrayType,bigint:bigIntType,boolean:booleanType,date:dateType,discriminatedUnion:discriminatedUnionType,effect:effectsType,enum:enumType,function:functionType,instanceof:instanceOfType,intersection:intersectionType,lazy:lazyType,literal:literalType,map:mapType,nan:nanType,nativeEnum:nativeEnumType,never:neverType,null:nullType,nullable:nullableType,number:numberType,object:objectType,oboolean:oboolean,onumber:onumber,optional:optionalType,ostring:ostring,pipeline:pipelineType,preprocess:preprocessType,promise:promiseType,record:recordType,set:setType,strictObject:strictObjectType,string:stringType,symbol:symbolType,transformer:effectsType,tuple:tupleType,undefined:undefinedType,union:unionType,unknown:unknownType,void:voidType,NEVER:NEVER,ZodIssueCode:ZodIssueCode,quotelessJson:quotelessJson,ZodError:ZodError}),Edge,Edge2;Edge2=Edge||(Edge={}),Edge2[Edge2.EXTEND=1]="EXTEND",Edge2[Edge2.WRAP=2]="WRAP",Edge2[Edge2.CROP=3]="CROP";const JimpClassSchema=z.object({bitmap:z.object({data:z.union([z.instanceof(Buffer),z.instanceof(Uint8Array)]),width:z.number(),height:z.number()})}),BlitOptionsSchemaComplex=z.object({src:JimpClassSchema,x:z.number().optional(),y:z.number().optional(),srcX:z.number().optional(),srcY:z.number().optional(),srcW:z.number().optional(),srcH:z.number().optional()}),BlitOptionsSchema=z.union([JimpClassSchema,BlitOptionsSchemaComplex]),methods$h={blit(e,t){const i=BlitOptionsSchema.parse(t);let{src:r,x:n=0,y:a=0,srcX:o=0,srcY:s=0,srcW:l=r.bitmap.width,srcH:u=r.bitmap.height}="bitmap"in i?{src:i}:i;if(!("bitmap"in r))throw new Error("The source must be a Jimp image");if("number"!=typeof n||"number"!=typeof a)throw new Error("x and y must be numbers");n=Math.round(n),a=Math.round(a),o=Math.round(o),s=Math.round(s),l=Math.round(l),u=Math.round(u);const h=e.bitmap.width,c=e.bitmap.height;return scan(r,o,s,l,u,(function(t,i,l){const u=n+t-o,f=a+i-s;if(u>=0&&f>=0&&h-u>0&&c-f>0){const t=e.getPixelIndex(u,f),i={r:r.bitmap.data[l]||0,g:r.bitmap.data[l+1]||0,b:r.bitmap.data[l+2]||0,a:r.bitmap.data[l+3]||0},n={r:e.bitmap.data[t]||0,g:e.bitmap.data[t+1]||0,b:e.bitmap.data[t+2]||0,a:e.bitmap.data[t+3]||0};e.bitmap.data[t]=(i.a*(i.r-n.r)-n.r+255>>8)+n.r,e.bitmap.data[t+1]=(i.a*(i.g-n.g)-n.g+255>>8)+n.g,e.bitmap.data[t+2]=(i.a*(i.b-n.b)-n.b+255>>8)+n.b,e.bitmap.data[t+3]=limit255(n.a+i.a)}})),e}},mulTable=[1,57,41,21,203,34,97,73,227,91,149,62,105,45,39,137,241,107,3,173,39,71,65,238,219,101,187,87,81,151,141,133,249,117,221,209,197,187,177,169,5,153,73,139,133,127,243,233,223,107,103,99,191,23,177,171,165,159,77,149,9,139,135,131,253,245,119,231,224,109,211,103,25,195,189,23,45,175,171,83,81,79,155,151,147,9,141,137,67,131,129,251,123,30,235,115,113,221,217,53,13,51,50,49,193,189,185,91,179,175,43,169,83,163,5,79,155,19,75,147,145,143,35,69,17,67,33,65,255,251,247,243,239,59,29,229,113,111,219,27,213,105,207,51,201,199,49,193,191,47,93,183,181,179,11,87,43,85,167,165,163,161,159,157,155,77,19,75,37,73,145,143,141,35,138,137,135,67,33,131,129,255,63,250,247,61,121,239,237,117,29,229,227,225,111,55,109,216,213,211,209,207,205,203,201,199,197,195,193,48,190,47,93,185,183,181,179,178,176,175,173,171,85,21,167,165,41,163,161,5,79,157,78,154,153,19,75,149,74,147,73,144,143,71,141,140,139,137,17,135,134,133,66,131,65,129,1],shgTable=[0,9,10,10,14,12,14,14,16,15,16,15,16,15,15,17,18,17,12,18,16,17,17,19,19,18,19,18,18,19,19,19,20,19,20,20,20,20,20,20,15,20,19,20,20,20,21,21,21,20,20,20,21,18,21,21,21,21,20,21,17,21,21,21,22,22,21,22,22,21,22,21,19,22,22,19,20,22,22,21,21,21,22,22,22,18,22,22,21,22,22,23,22,20,23,22,22,23,23,21,19,21,21,21,23,23,23,22,23,23,21,23,22,23,18,22,23,20,22,23,23,23,21,22,20,22,21,22,24,24,24,24,24,22,21,24,23,23,24,21,24,23,24,22,24,24,22,24,24,22,23,24,24,24,20,23,22,23,24,24,24,24,24,24,24,23,21,23,22,23,24,24,24,22,24,24,24,23,22,24,24,25,23,25,25,23,24,25,25,24,22,25,25,25,24,23,24,25,25,25,25,25,25,25,25,25,25,25,25,23,25,23,24,25,25,25,25,25,25,25,25,25,24,22,25,25,23,25,25,20,24,25,24,25,25,22,24,25,24,25,24,25,25,24,25,25,25,25,22,25,25,25,24,25,24,25,18],methods$g={blur(e,t){if("number"!=typeof t)throw new Error("r must be a number");if(t<1)throw new Error("r must be greater than 0");let i,r,n,a,o,s,l,u,h,c,f,d,p;const m=e.bitmap.width-1,_=e.bitmap.height-1,g=t+1,b=mulTable[t],y=shgTable[t],w=[],v=[],x=[],E=[],k=[],S=[];let A=2;for(;A-- >0;){for(d=0,p=0,s=0;s<e.bitmap.height;s++){for(i=e.bitmap.data[p]*g,r=e.bitmap.data[p+1]*g,n=e.bitmap.data[p+2]*g,a=e.bitmap.data[p+3]*g,l=1;l<=t;l++)u=p+((l>m?m:l)<<2),i+=e.bitmap.data[u++],r+=e.bitmap.data[u++],n+=e.bitmap.data[u++],a+=e.bitmap.data[u];for(o=0;o<e.bitmap.width;o++)w[d]=i,v[d]=r,x[d]=n,E[d]=a,0===s&&(k[o]=((u=o+g)<m?u:m)<<2,S[o]=(u=o-t)>0?u<<2:0),h=p+k[o],c=p+S[o],i+=e.bitmap.data[h++]-e.bitmap.data[c++],r+=e.bitmap.data[h++]-e.bitmap.data[c++],n+=e.bitmap.data[h++]-e.bitmap.data[c++],a+=e.bitmap.data[h]-e.bitmap.data[c++],d++;p+=e.bitmap.width<<2}for(o=0;o<e.bitmap.width;o++){for(f=o,i=w[f]*g,r=v[f]*g,n=x[f]*g,a=E[f]*g,l=1;l<=t;l++)f+=l>_?0:e.bitmap.width,i+=w[f],r+=v[f],n+=x[f],a+=E[f];for(d=o<<2,s=0;s<e.bitmap.height;s++)e.bitmap.data[d]=limit255(i*b>>>y),e.bitmap.data[d+1]=limit255(r*b>>>y),e.bitmap.data[d+2]=limit255(n*b>>>y),e.bitmap.data[d+3]=limit255(a*b>>>y),0===o&&(k[s]=((u=s+g)<_?u:_)*e.bitmap.width,S[s]=(u=s-t)>0?u*e.bitmap.width:0),h=o+k[s],c=o+S[s],i+=w[h]-w[c],r+=v[h]-v[c],n+=x[h]-x[c],a+=E[h]-E[c],d+=e.bitmap.width<<2}}return e},gaussian(e,t){if("number"!=typeof t)throw new Error("r must be a number");if(t<1)throw new Error("r must be greater than 0");const i=Math.ceil(2.57*t),r=2*i+1,n=t*t*2,a=n*Math.PI,o=[];for(let e=0;e<r;e++){const t=[];for(let o=0;o<r;o++){const r=(o-i)**2+(e-i)**2;t[o]=Math.exp(-r/n)/a}o.push(t)}for(let t=0;t<e.bitmap.height;t++)for(let n=0;n<e.bitmap.width;n++){let a=0,s=0,l=0,u=0,h=0;for(let c=0;c<r;c++){for(let f=0;f<r;f++){const r=Math.min(e.bitmap.width-1,Math.max(0,f+n-i)),d=Math.min(e.bitmap.height-1,Math.max(0,c+t-i)),p=o[c][f],m=d*e.bitmap.width+r<<2;a+=e.bitmap.data[m]*p,s+=e.bitmap.data[m+1]*p,l+=e.bitmap.data[m+2]*p,u+=e.bitmap.data[m+3]*p,h+=p}const f=t*e.bitmap.width+n<<2;e.bitmap.data[f]=Math.round(a/h),e.bitmap.data[f+1]=Math.round(s/h),e.bitmap.data[f+2]=Math.round(l/h),e.bitmap.data[f+3]=Math.round(u/h)}}return e}},CircleOptionsSchema=z.object({x:z.number().optional(),y:z.number().optional(),radius:z.number().min(0).optional()}),methods$f={circle(e,t={}){const i=CircleOptionsSchema.parse(t),r=i.radius||(e.bitmap.width>e.bitmap.height?e.bitmap.height:e.bitmap.width)/2,n="number"==typeof i.x?i.x:e.bitmap.width/2,a="number"==typeof i.y?i.y:e.bitmap.height/2;return e.scan(((t,i,o)=>{const s=Math.sqrt(Math.pow(t-n,2)+Math.pow(i-a,2));r-s<=0?e.bitmap.data[o+3]=0:r-s<1&&(e.bitmap.data[o+3]=255*(r-s))})),e}},ConvolutionMatrixSchema=z.array(z.number()).min(1).array(),ConvolutionComplexOptionsSchema=z.object({kernel:ConvolutionMatrixSchema,edgeHandling:z.nativeEnum(Edge).optional()}),ConvolutionOptionsSchema=z.union([ConvolutionMatrixSchema,ConvolutionComplexOptionsSchema]),ConvoluteComplexOptionsSchema=z.object({kernel:ConvolutionMatrixSchema,x:z.number().optional(),y:z.number().optional(),w:z.number().optional(),h:z.number().optional()}),ConvoluteOptionsSchema=z.union([ConvolutionMatrixSchema,ConvoluteComplexOptionsSchema]),PixelateSize=z.number().min(1).max(1/0),PixelateComplexOptionsSchema=z.object({size:PixelateSize,x:z.number().optional(),y:z.number().optional(),w:z.number().optional(),h:z.number().optional()}),PixelateOptionsSchema=z.union([PixelateSize,PixelateComplexOptionsSchema]);function applyKernel(e,t,i,r){const n=[0,0,0,0],a=(t.length-1)/2;for(let o=0;o<t.length;o+=1)for(let s=0;s<t[o].length;s+=1){const l=e.getPixelIndex(i+o-a,r+s-a);n[0]+=e.bitmap.data[l]*t[o][s],n[1]+=e.bitmap.data[l+1]*t[o][s],n[2]+=e.bitmap.data[l+2]*t[o][s],n[3]+=e.bitmap.data[l+3]*t[o][s]}return n}function mix(e,t,i=50){return{r:(t.r-e.r)*(i/100)+e.r,g:(t.g-e.g)*(i/100)+e.g,b:(t.b-e.b)*(i/100)+e.b}}const HueActionSchema=z.object({apply:z.literal("hue"),params:z.tuple([z.number().min(-360).max(360)])}),SpinActionSchema=z.object({apply:z.literal("spin"),params:z.tuple([z.number().min(-360).max(360)])}),LightenActionSchema=z.object({apply:z.literal("lighten"),params:z.tuple([z.number().min(0).max(100)]).optional()}),RGBColorSchema=z.object({r:z.number().min(0).max(255),g:z.number().min(0).max(255),b:z.number().min(0).max(255)}),MixActionSchema=z.object({apply:z.literal("mix"),params:z.union([z.tuple([RGBColorSchema]),z.tuple([RGBColorSchema,z.number().min(0).max(100)])])}),TintActionSchema=z.object({apply:z.literal("tint"),params:z.tuple([z.number().min(0).max(100)]).optional()}),ShadeActionSchema=z.object({apply:z.literal("shade"),params:z.tuple([z.number().min(0).max(100)]).optional()}),XorActionSchema=z.object({apply:z.literal("xor"),params:z.tuple([RGBColorSchema])}),RedActionSchema=z.object({apply:z.literal("red"),params:z.tuple([z.number().min(-255).max(255)])}),GreenActionSchema=z.object({apply:z.literal("green"),params:z.tuple([z.number().min(-255).max(255)])}),BlueActionSchema=z.object({apply:z.literal("blue"),params:z.tuple([z.number().min(-255).max(255)])}),BrightenActionSchema=z.object({apply:z.literal("brighten"),params:z.tuple([z.number().min(0).max(100)]).optional()}),DarkenActionSchema=z.object({apply:z.literal("darken"),params:z.tuple([z.number().min(0).max(100)]).optional()}),DesaturateActionSchema=z.object({apply:z.literal("desaturate"),params:z.tuple([z.number().min(0).max(100)]).optional()}),SaturateActionSchema=z.object({apply:z.literal("saturate"),params:z.tuple([z.number().min(0).max(100)]).optional()}),GrayscaleActionSchema=z.object({apply:z.literal("greyscale"),params:z.tuple([]).optional()}),ColorActionNameSchema=z.union([HueActionSchema,SpinActionSchema,LightenActionSchema,MixActionSchema,TintActionSchema,ShadeActionSchema,XorActionSchema,RedActionSchema,GreenActionSchema,BlueActionSchema,BrightenActionSchema,DarkenActionSchema,DesaturateActionSchema,SaturateActionSchema,GrayscaleActionSchema]);function histogram(e){const t={r:new Array(256).fill(0),g:new Array(256).fill(0),b:new Array(256).fill(0)};return e.scan(((i,r,n)=>{t.r[e.bitmap.data[n+0]]++,t.g[e.bitmap.data[n+1]]++,t.b[e.bitmap.data[n+2]]++})),t}const normalizeValue=function(e,t,i){return 255*(e-t)/(i-t)},getBounds=function(e){return[e.findIndex((e=>e>0)),255-e.slice().reverse().findIndex((e=>e>0))]},methods$e={normalize(e){const t=histogram(e),i={r:getBounds(t.r),g:getBounds(t.g),b:getBounds(t.b)};return e.scan(((t,r,n)=>{const a=e.bitmap.data[n+0],o=e.bitmap.data[n+1],s=e.bitmap.data[n+2];e.bitmap.data[n+0]=normalizeValue(a,i.r[0],i.r[1]),e.bitmap.data[n+1]=normalizeValue(o,i.g[0],i.g[1]),e.bitmap.data[n+2]=normalizeValue(s,i.b[0],i.b[1])})),e},invert:e=>(e.scan(((t,i,r)=>{e.bitmap.data[r]=255-e.bitmap.data[r],e.bitmap.data[r+1]=255-e.bitmap.data[r+1],e.bitmap.data[r+2]=255-e.bitmap.data[r+2]})),e),brightness(e,t){if("number"!=typeof t)throw new Error("val must be numbers");return e.scan(((i,r,n)=>{e.bitmap.data[n]=limit255(e.bitmap.data[n]*t),e.bitmap.data[n+1]=limit255(e.bitmap.data[n+1]*t),e.bitmap.data[n+2]=limit255(e.bitmap.data[n+2]*t)})),e},contrast(e,t){if("number"!=typeof t)throw new Error("val must be numbers");if(t<-1||t>1)throw new Error("val must be a number between -1 and +1");const i=(t+1)/(1-t);function r(e){return(e=Math.floor(i*(e-127)+127))<0?0:e>255?255:e}return e.scan(((t,i,n)=>{e.bitmap.data[n]=r(e.bitmap.data[n]),e.bitmap.data[n+1]=r(e.bitmap.data[n+1]),e.bitmap.data[n+2]=r(e.bitmap.data[n+2])})),e},posterize(e,t){if("number"!=typeof t)throw new Error("n must be numbers");return t<2&&(t=2),e.scan(((i,r,n)=>{const a=e.bitmap.data[n],o=e.bitmap.data[n+1],s=e.bitmap.data[n+2];e.bitmap.data[n]=Math.floor(a/255*(t-1))/(t-1)*255,e.bitmap.data[n+1]=Math.floor(o/255*(t-1))/(t-1)*255,e.bitmap.data[n+2]=Math.floor(s/255*(t-1))/(t-1)*255})),e},greyscale:e=>(e.scan(((t,i,r)=>{const n=.2126*e.bitmap.data[r]+.7152*e.bitmap.data[r+1]+.0722*e.bitmap.data[r+2];e.bitmap.data[r]=n,e.bitmap.data[r+1]=n,e.bitmap.data[r+2]=n})),e),opacity(e,t){if("number"!=typeof t)throw new Error("f must be a number");if(t<0||t>1)throw new Error("f must be a number from 0 to 1");return e.scan(((i,r,n)=>{const a=e.bitmap.data[n+3]*t;e.bitmap.data[n+3]=a})),e},sepia:e=>(e.scan(((t,i,r)=>{let n=e.bitmap.data[r],a=e.bitmap.data[r+1],o=e.bitmap.data[r+2];n=.393*n+.769*a+.189*o,a=.349*n+.686*a+.168*o,o=.272*n+.534*a+.131*o,e.bitmap.data[r]=n<255?n:255,e.bitmap.data[r+1]=a<255?a:255,e.bitmap.data[r+2]=o<255?o:255})),e),fade(e,t){if("number"!=typeof t)throw new Error("f must be a number");if(t<0||t>1)throw new Error("f must be a number from 0 to 1");return this.opacity(e,1-t)},convolution(e,t){const i=ConvolutionOptionsSchema.parse(t),{kernel:r,edgeHandling:n=Edge.EXTEND}="kernel"in i?i:{kernel:i,edgeHandling:void 0};if(!r[0])throw new Error("kernel must be a matrix");const a=Buffer.from(e.bitmap.data),o=r.length,s=r[0].length,l=Math.floor(o/2),u=Math.floor(s/2),h=-l,c=-u;let f,d,p,m,_,g,b,y,w,v;return e.scan(((t,i,o)=>{m=0,p=0,d=0;for(let a=h;a<=l;a++)for(let o=c;o<=u;o++)y=t+o,w=i+a,f=r[a+l][o+u],v=e.getPixelIndex(y,w,n),-1===v?(b=0,g=0,_=0):(_=e.bitmap.data[v+0],g=e.bitmap.data[v+1],b=e.bitmap.data[v+2]),d+=f*_,p+=f*g,m+=f*b;d<0&&(d=0),p<0&&(p=0),m<0&&(m=0),d>255&&(d=255),p>255&&(p=255),m>255&&(m=255),a[o+0]=d,a[o+1]=p,a[o+2]=m})),e.bitmap.data=a,e},opaque:e=>(e.scan(((t,i,r)=>{e.bitmap.data[r+3]=255})),e),pixelate(e,t){const i=PixelateOptionsSchema.parse(t),{size:r,x:n=0,y:a=0,w:o=e.bitmap.width-n,h:s=e.bitmap.height-a}="number"==typeof i?{size:i}:i,l=[[1/16,2/16,1/16],[2/16,.25,2/16],[1/16,2/16,1/16]],u=clone(e);return scan(u,n,a,o,s,((t,i,n)=>{t=r*Math.floor(t/r),i=r*Math.floor(i/r);const a=applyKernel(u,l,t,i);e.bitmap.data[n]=a[0],e.bitmap.data[n+1]=a[1],e.bitmap.data[n+2]=a[2],e.bitmap.data[n+3]=a[3]})),e},convolute(e,t){const i=ConvoluteOptionsSchema.parse(t),{kernel:r,x:n=0,y:a=0,w:o=e.bitmap.width-n,h:s=e.bitmap.height-a}="kernel"in i?i:{kernel:i},l=clone(e);return scan(l,n,a,o,s,((t,i,n)=>{const a=applyKernel(l,r,t,i);e.bitmap.data[n]=limit255(a[0]),e.bitmap.data[n+1]=limit255(a[1]),e.bitmap.data[n+2]=limit255(a[2]),e.bitmap.data[n+3]=limit255(a[3])})),e},color(e,t){if(!t||!Array.isArray(t))throw new Error("actions must be an array");return t.forEach((e=>ColorActionNameSchema.parse(e))),t=t.map((e=>("xor"!==e.apply&&"mix"!==e.apply||(e.params[0]=tinycolor(e.params[0]).toRgb()),e))),e.scan(((i,r,n)=>{let a={r:e.bitmap.data[n],g:e.bitmap.data[n+1],b:e.bitmap.data[n+2]};const o=(e,t)=>limit255(a[e]+t);t.forEach((e=>{if("mix"===e.apply)a=mix(a,e.params[0],e.params[1]);else if("tint"===e.apply)a=mix(a,{r:255,g:255,b:255},e.params?.[0]);else if("shade"===e.apply)a=mix(a,{r:0,g:0,b:0},e.params?.[0]);else if("xor"===e.apply)a={r:a.r^e.params[0].r,g:a.g^e.params[0].g,b:a.b^e.params[0].b};else if("red"===e.apply)a.r=o("r",e.params[0]);else if("green"===e.apply)a.g=o("g",e.params[0]);else if("blue"===e.apply)a.b=o("b",e.params[0]);else{"hue"===e.apply&&(e.apply="spin");const t=tinycolor(a),i=t[e.apply].bind(t);if(!i)throw new Error("action "+e.apply+" not supported");a=i(...e.params||[]).toRgb()}})),e.bitmap.data[n]=a.r,e.bitmap.data[n+1]=a.g,e.bitmap.data[n+2]=a.b})),e}};var lib$1={},ieee754={
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
read:function(e,t,i,r,n){var a,o,s=8*n-r-1,l=(1<<s)-1,u=l>>1,h=-7,c=i?n-1:0,f=i?-1:1,d=e[t+c];for(c+=f,a=d&(1<<-h)-1,d>>=-h,h+=s;h>0;a=256*a+e[t+c],c+=f,h-=8);for(o=a&(1<<-h)-1,a>>=-h,h+=r;h>0;o=256*o+e[t+c],c+=f,h-=8);if(0===a)a=1-u;else{if(a===l)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,r),a-=u}return(d?-1:1)*o*Math.pow(2,a-r)},write:function(e,t,i,r,n,a){var o,s,l,u=8*a-n-1,h=(1<<u)-1,c=h>>1,f=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:a-1,p=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,o=h):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),(t+=o+c>=1?f/l:f*Math.pow(2,1-c))*l>=2&&(o++,l/=2),o+c>=h?(s=0,o=h):o+c>=1?(s=(t*l-1)*Math.pow(2,n),o+=c):(s=t*Math.pow(2,c-1)*Math.pow(2,n),o=0));n>=8;e[i+d]=255&s,d+=p,s/=256,n-=8);for(o=o<<n|s,u+=n;u>0;e[i+d]=255&o,d+=p,o/=256,u-=8);e[i+d-p]|=128*m}};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.AnsiStringType=e.StringType=e.BufferType=e.Uint8ArrayType=e.IgnoreType=e.Float80_LE=e.Float80_BE=e.Float64_LE=e.Float64_BE=e.Float32_LE=e.Float32_BE=e.Float16_LE=e.Float16_BE=e.INT64_BE=e.UINT64_BE=e.INT64_LE=e.UINT64_LE=e.INT32_LE=e.INT32_BE=e.INT24_BE=e.INT24_LE=e.INT16_LE=e.INT16_BE=e.INT8=e.UINT32_BE=e.UINT32_LE=e.UINT24_BE=e.UINT24_LE=e.UINT16_BE=e.UINT16_LE=e.UINT8=void 0;const t=ieee754;function i(e){return new DataView(e.buffer,e.byteOffset)}e.UINT8={len:1,get:(e,t)=>i(e).getUint8(t),put:(e,t,r)=>(i(e).setUint8(t,r),t+1)},e.UINT16_LE={len:2,get:(e,t)=>i(e).getUint16(t,!0),put:(e,t,r)=>(i(e).setUint16(t,r,!0),t+2)},e.UINT16_BE={len:2,get:(e,t)=>i(e).getUint16(t),put:(e,t,r)=>(i(e).setUint16(t,r),t+2)},e.UINT24_LE={len:3,get(e,t){const r=i(e);return r.getUint8(t)+(r.getUint16(t+1,!0)<<8)},put(e,t,r){const n=i(e);return n.setUint8(t,255&r),n.setUint16(t+1,r>>8,!0),t+3}},e.UINT24_BE={len:3,get(e,t){const r=i(e);return(r.getUint16(t)<<8)+r.getUint8(t+2)},put(e,t,r){const n=i(e);return n.setUint16(t,r>>8),n.setUint8(t+2,255&r),t+3}},e.UINT32_LE={len:4,get:(e,t)=>i(e).getUint32(t,!0),put:(e,t,r)=>(i(e).setUint32(t,r,!0),t+4)},e.UINT32_BE={len:4,get:(e,t)=>i(e).getUint32(t),put:(e,t,r)=>(i(e).setUint32(t,r),t+4)},e.INT8={len:1,get:(e,t)=>i(e).getInt8(t),put:(e,t,r)=>(i(e).setInt8(t,r),t+1)},e.INT16_BE={len:2,get:(e,t)=>i(e).getInt16(t),put:(e,t,r)=>(i(e).setInt16(t,r),t+2)},e.INT16_LE={len:2,get:(e,t)=>i(e).getInt16(t,!0),put:(e,t,r)=>(i(e).setInt16(t,r,!0),t+2)},e.INT24_LE={len:3,get(t,i){const r=e.UINT24_LE.get(t,i);return r>8388607?r-16777216:r},put(e,t,r){const n=i(e);return n.setUint8(t,255&r),n.setUint16(t+1,r>>8,!0),t+3}},e.INT24_BE={len:3,get(t,i){const r=e.UINT24_BE.get(t,i);return r>8388607?r-16777216:r},put(e,t,r){const n=i(e);return n.setUint16(t,r>>8),n.setUint8(t+2,255&r),t+3}},e.INT32_BE={len:4,get:(e,t)=>i(e).getInt32(t),put:(e,t,r)=>(i(e).setInt32(t,r),t+4)},e.INT32_LE={len:4,get:(e,t)=>i(e).getInt32(t,!0),put:(e,t,r)=>(i(e).setInt32(t,r,!0),t+4)},e.UINT64_LE={len:8,get:(e,t)=>i(e).getBigUint64(t,!0),put:(e,t,r)=>(i(e).setBigUint64(t,r,!0),t+8)},e.INT64_LE={len:8,get:(e,t)=>i(e).getBigInt64(t,!0),put:(e,t,r)=>(i(e).setBigInt64(t,r,!0),t+8)},e.UINT64_BE={len:8,get:(e,t)=>i(e).getBigUint64(t),put:(e,t,r)=>(i(e).setBigUint64(t,r),t+8)},e.INT64_BE={len:8,get:(e,t)=>i(e).getBigInt64(t),put:(e,t,r)=>(i(e).setBigInt64(t,r),t+8)},e.Float16_BE={len:2,get(e,i){return t.read(e,i,!1,10,this.len)},put(e,i,r){return t.write(e,r,i,!1,10,this.len),i+this.len}},e.Float16_LE={len:2,get(e,i){return t.read(e,i,!0,10,this.len)},put(e,i,r){return t.write(e,r,i,!0,10,this.len),i+this.len}},e.Float32_BE={len:4,get:(e,t)=>i(e).getFloat32(t),put:(e,t,r)=>(i(e).setFloat32(t,r),t+4)},e.Float32_LE={len:4,get:(e,t)=>i(e).getFloat32(t,!0),put:(e,t,r)=>(i(e).setFloat32(t,r,!0),t+4)},e.Float64_BE={len:8,get:(e,t)=>i(e).getFloat64(t),put:(e,t,r)=>(i(e).setFloat64(t,r),t+8)},e.Float64_LE={len:8,get:(e,t)=>i(e).getFloat64(t,!0),put:(e,t,r)=>(i(e).setFloat64(t,r,!0),t+8)},e.Float80_BE={len:10,get(e,i){return t.read(e,i,!1,63,this.len)},put(e,i,r){return t.write(e,r,i,!1,63,this.len),i+this.len}},e.Float80_LE={len:10,get(e,i){return t.read(e,i,!0,63,this.len)},put(e,i,r){return t.write(e,r,i,!0,63,this.len),i+this.len}};e.IgnoreType=class{constructor(e){this.len=e}get(e,t){}};e.Uint8ArrayType=class{constructor(e){this.len=e}get(e,t){return e.subarray(t,t+this.len)}};e.BufferType=class{constructor(e){this.len=e}get(e,t){return Buffer.from(e.subarray(t,t+this.len))}};e.StringType=class{constructor(e,t){this.len=e,this.encoding=t}get(e,t){return Buffer.from(e).toString(this.encoding,t,t+this.len)}};class r{constructor(e){this.len=e}static decode(e,t,i){let n="";for(let a=t;a<i;++a)n+=r.codePointToString(r.singleByteDecoder(e[a]));return n}static inRange(e,t,i){return t<=e&&e<=i}static codePointToString(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}static singleByteDecoder(e){if(r.inRange(e,0,127))return e;const t=r.windows1252[e-128];if(null===t)throw Error("invaliding encoding");return t}get(e,t=0){return r.decode(e,t,t+this.len)}}e.AnsiStringType=r,r.windows1252=[8364,129,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,141,381,143,144,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,157,382,376,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255]}(lib$1);var core$1={},ReadStreamTokenizer$1={},AbstractTokenizer$1={},lib={},EndOfFileStream={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.EndOfStreamError=e.defaultMessages=void 0,e.defaultMessages="End-Of-Stream";class t extends Error{constructor(){super(e.defaultMessages)}}e.EndOfStreamError=t}(EndOfFileStream);var StreamReader={},Deferred$1={};Object.defineProperty(Deferred$1,"__esModule",{value:!0}),Deferred$1.Deferred=void 0;class Deferred{constructor(){this.resolve=()=>null,this.reject=()=>null,this.promise=new Promise(((e,t)=>{this.reject=t,this.resolve=e}))}}Deferred$1.Deferred=Deferred,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.StreamReader=e.EndOfStreamError=void 0;const t=EndOfFileStream,i=Deferred$1;var r=EndOfFileStream;Object.defineProperty(e,"EndOfStreamError",{enumerable:!0,get:function(){return r.EndOfStreamError}});e.StreamReader=class{constructor(e){if(this.s=e,this.deferred=null,this.endOfStream=!1,this.peekQueue=[],!e.read||!e.once)throw new Error("Expected an instance of stream.Readable");this.s.once("end",(()=>this.reject(new t.EndOfStreamError))),this.s.once("error",(e=>this.reject(e))),this.s.once("close",(()=>this.reject(new Error("Stream closed"))))}async peek(e,t,i){const r=await this.read(e,t,i);return this.peekQueue.push(e.subarray(t,t+r)),r}async read(e,i,r){if(0===r)return 0;if(0===this.peekQueue.length&&this.endOfStream)throw new t.EndOfStreamError;let n=r,a=0;for(;this.peekQueue.length>0&&n>0;){const t=this.peekQueue.pop();if(!t)throw new Error("peekData should be defined");const r=Math.min(t.length,n);e.set(t.subarray(0,r),i+a),a+=r,n-=r,r<t.length&&this.peekQueue.push(t.subarray(r))}for(;n>0&&!this.endOfStream;){const t=Math.min(n,1048576),r=await this.readFromStream(e,i+a,t);if(a+=r,r<t)break;n-=r}return a}async readFromStream(e,t,r){const n=this.s.read(r);if(n)return e.set(n,t),n.length;{const n={buffer:e,offset:t,length:r,deferred:new i.Deferred};return this.deferred=n.deferred,this.s.once("readable",(()=>{this.readDeferred(n)})),n.deferred.promise}}readDeferred(e){const t=this.s.read(e.length);t?(e.buffer.set(t,e.offset),e.deferred.resolve(t.length),this.deferred=null):this.s.once("readable",(()=>{this.readDeferred(e)}))}reject(e){this.endOfStream=!0,this.deferred&&(this.deferred.reject(e),this.deferred=null)}}}(StreamReader),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.StreamReader=e.EndOfStreamError=void 0;var t=EndOfFileStream;Object.defineProperty(e,"EndOfStreamError",{enumerable:!0,get:function(){return t.EndOfStreamError}});var i=StreamReader;Object.defineProperty(e,"StreamReader",{enumerable:!0,get:function(){return i.StreamReader}})}(lib),Object.defineProperty(AbstractTokenizer$1,"__esModule",{value:!0}),AbstractTokenizer$1.AbstractTokenizer=void 0;const peek_readable_1$2=lib;class AbstractTokenizer{constructor(e){this.position=0,this.numBuffer=new Uint8Array(8),this.fileInfo=e||{}}async readToken(e,t=this.position){const i=Buffer.alloc(e.len);if(await this.readBuffer(i,{position:t})<e.len)throw new peek_readable_1$2.EndOfStreamError;return e.get(i,0)}async peekToken(e,t=this.position){const i=Buffer.alloc(e.len);if(await this.peekBuffer(i,{position:t})<e.len)throw new peek_readable_1$2.EndOfStreamError;return e.get(i,0)}async readNumber(e){if(await this.readBuffer(this.numBuffer,{length:e.len})<e.len)throw new peek_readable_1$2.EndOfStreamError;return e.get(this.numBuffer,0)}async peekNumber(e){if(await this.peekBuffer(this.numBuffer,{length:e.len})<e.len)throw new peek_readable_1$2.EndOfStreamError;return e.get(this.numBuffer,0)}async ignore(e){if(void 0!==this.fileInfo.size){const t=this.fileInfo.size-this.position;if(e>t)return this.position+=t,t}return this.position+=e,e}async close(){}normalizeOptions(e,t){if(t&&void 0!==t.position&&t.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");return t?{mayBeLess:!0===t.mayBeLess,offset:t.offset?t.offset:0,length:t.length?t.length:e.length-(t.offset?t.offset:0),position:t.position?t.position:this.position}:{mayBeLess:!1,offset:0,length:e.length,position:this.position}}}AbstractTokenizer$1.AbstractTokenizer=AbstractTokenizer,Object.defineProperty(ReadStreamTokenizer$1,"__esModule",{value:!0}),ReadStreamTokenizer$1.ReadStreamTokenizer=void 0;const AbstractTokenizer_1$1=AbstractTokenizer$1,peek_readable_1$1=lib,maxBufferSize=256e3;class ReadStreamTokenizer extends AbstractTokenizer_1$1.AbstractTokenizer{constructor(e,t){super(t),this.streamReader=new peek_readable_1$1.StreamReader(e)}async getFileInfo(){return this.fileInfo}async readBuffer(e,t){const i=this.normalizeOptions(e,t),r=i.position-this.position;if(r>0)return await this.ignore(r),this.readBuffer(e,t);if(r<0)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(0===i.length)return 0;const n=await this.streamReader.read(e,i.offset,i.length);if(this.position+=n,(!t||!t.mayBeLess)&&n<i.length)throw new peek_readable_1$1.EndOfStreamError;return n}async peekBuffer(e,t){const i=this.normalizeOptions(e,t);let r=0;if(i.position){const t=i.position-this.position;if(t>0){const n=new Uint8Array(i.length+t);return r=await this.peekBuffer(n,{mayBeLess:i.mayBeLess}),e.set(n.subarray(t),i.offset),r-t}if(t<0)throw new Error("Cannot peek from a negative offset in a stream")}if(i.length>0){try{r=await this.streamReader.peek(e,i.offset,i.length)}catch(e){if(t&&t.mayBeLess&&e instanceof peek_readable_1$1.EndOfStreamError)return 0;throw e}if(!i.mayBeLess&&r<i.length)throw new peek_readable_1$1.EndOfStreamError}return r}async ignore(e){const t=Math.min(maxBufferSize,e),i=new Uint8Array(t);let r=0;for(;r<e;){const n=e-r,a=await this.readBuffer(i,{length:Math.min(t,n)});if(a<0)return a;r+=a}return r}}ReadStreamTokenizer$1.ReadStreamTokenizer=ReadStreamTokenizer;var BufferTokenizer$1={};Object.defineProperty(BufferTokenizer$1,"__esModule",{value:!0}),BufferTokenizer$1.BufferTokenizer=void 0;const peek_readable_1=lib,AbstractTokenizer_1=AbstractTokenizer$1;class BufferTokenizer extends AbstractTokenizer_1.AbstractTokenizer{constructor(e,t){super(t),this.uint8Array=e,this.fileInfo.size=this.fileInfo.size?this.fileInfo.size:e.length}async readBuffer(e,t){if(t&&t.position){if(t.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");this.position=t.position}const i=await this.peekBuffer(e,t);return this.position+=i,i}async peekBuffer(e,t){const i=this.normalizeOptions(e,t),r=Math.min(this.uint8Array.length-i.position,i.length);if(!i.mayBeLess&&r<i.length)throw new peek_readable_1.EndOfStreamError;return e.set(this.uint8Array.subarray(i.position,i.position+r),i.offset),r}async close(){}}BufferTokenizer$1.BufferTokenizer=BufferTokenizer,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.fromBuffer=e.fromStream=e.EndOfStreamError=void 0;const t=ReadStreamTokenizer$1,i=BufferTokenizer$1;var r=lib;Object.defineProperty(e,"EndOfStreamError",{enumerable:!0,get:function(){return r.EndOfStreamError}}),e.fromStream=function(e,i){return i=i||{},new t.ReadStreamTokenizer(e,i)},e.fromBuffer=function(e,t){return new i.BufferTokenizer(e,t)}}(core$1);var util={stringToBytes:e=>[...e].map((e=>e.charCodeAt(0))),tarHeaderChecksumMatches:(e,t=0)=>{const i=parseInt(e.toString("utf8",148,154).replace(/\0.*$/,"").trim(),8);if(isNaN(i))return!1;let r=256;for(let i=t;i<t+148;i++)r+=e[i];for(let i=t+156;i<t+512;i++)r+=e[i];return i===r},uint32SyncSafeToken:{get:(e,t)=>127&e[t+3]|e[t+2]<<7|e[t+1]<<14|e[t]<<21,len:4}},supported$1={extensions:["jpg","png","apng","gif","webp","flif","xcf","cr2","cr3","orf","arw","dng","nef","rw2","raf","tif","bmp","icns","jxr","psd","indd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","oga","ogg","ogv","opus","flac","wav","spx","amr","pdf","epub","exe","swf","rtf","wasm","woff","woff2","eot","ttf","otf","ico","flv","ps","xz","sqlite","nes","crx","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","blend","bpg","docx","pptx","xlsx","3gp","3g2","jp2","jpm","jpx","mj2","aif","qcp","odt","ods","odp","xml","mobi","heic","cur","ktx","ape","wv","dcm","ics","glb","pcap","dsf","lnk","alias","voc","ac3","m4v","m4p","m4b","f4v","f4p","f4b","f4a","mie","asf","ogm","ogx","mpc","arrow","shp","aac","mp1","it","s3m","xm","ai","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf"],mimeTypes:["image/jpeg","image/png","image/gif","image/webp","image/flif","image/x-xcf","image/x-canon-cr2","image/x-canon-cr3","image/tiff","image/bmp","image/vnd.ms-photo","image/vnd.adobe.photoshop","application/x-indesign","application/epub+zip","application/x-xpinstall","application/vnd.oasis.opendocument.text","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","application/x-apache-arrow","video/mp4","audio/midi","video/x-matroska","video/webm","video/quicktime","video/vnd.avi","audio/vnd.wave","audio/qcelp","audio/x-ms-asf","video/x-ms-asf","application/vnd.ms-asf","video/mpeg","video/3gpp","audio/mpeg","audio/mp4","audio/opus","video/ogg","audio/ogg","application/ogg","audio/x-flac","audio/ape","audio/wavpack","audio/amr","application/pdf","application/x-msdownload","application/x-shockwave-flash","application/rtf","application/wasm","font/woff","font/woff2","application/vnd.ms-fontobject","font/ttf","font/otf","image/x-icon","video/x-flv","application/postscript","application/eps","application/x-xz","application/x-sqlite3","application/x-nintendo-nes-rom","application/x-google-chrome-extension","application/vnd.ms-cab-compressed","application/x-deb","application/x-unix-archive","application/x-rpm","application/x-compress","application/x-lzip","application/x-cfb","application/x-mie","application/mxf","video/mp2t","application/x-blender","image/bpg","image/jp2","image/jpx","image/jpm","image/mj2","audio/aiff","application/xml","application/x-mobipocket-ebook","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/icns","image/ktx","application/dicom","audio/x-musepack","text/calendar","text/vcard","model/gltf-binary","application/vnd.tcpdump.pcap","audio/x-dsf","application/x.ms.shortcut","application/x.apple.alias","audio/x-voc","audio/vnd.dolby.dd-raw","audio/x-m4a","image/apng","image/x-olympus-orf","image/x-sony-arw","image/x-adobe-dng","image/x-nikon-nef","image/x-panasonic-rw2","image/x-fujifilm-raf","video/x-m4v","video/3gpp2","application/x-esri-shape","audio/aac","audio/x-it","audio/x-s3m","audio/x-xm","video/MP1S","video/MP2P","application/vnd.sketchup.skp","image/avif","application/x-lzh-compressed","application/pgp-encrypted","application/x-asar","model/stl","application/vnd.ms-htmlhelp","model/3mf","image/jxl","application/zstd"]};const Token=lib$1,strtok3=core$1,{stringToBytes:stringToBytes,tarHeaderChecksumMatches:tarHeaderChecksumMatches,uint32SyncSafeToken:uint32SyncSafeToken}=util,supported=supported$1,minimumBytes=4100;async function fromStream(e){const t=await strtok3.fromStream(e);try{return await fromTokenizer(t)}finally{await t.close()}}async function fromBuffer(e){if(!(e instanceof Uint8Array||e instanceof ArrayBuffer||Buffer.isBuffer(e)))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`Buffer\` or \`ArrayBuffer\`, got \`${typeof e}\``);const t=e instanceof Buffer?e:Buffer.from(e);if(!(t&&t.length>1))return;return fromTokenizer(strtok3.fromBuffer(t))}function _check(e,t,i){i={offset:0,...i};for(const[r,n]of t.entries())if(i.mask){if(n!==(i.mask[r]&e[r+i.offset]))return!1}else if(n!==e[r+i.offset])return!1;return!0}async function fromTokenizer(e){try{return _fromTokenizer(e)}catch(e){if(!(e instanceof strtok3.EndOfStreamError))throw e}}async function _fromTokenizer(e){let t=Buffer.alloc(minimumBytes);const i=(e,i)=>_check(t,e,i),r=(e,t)=>i(stringToBytes(e),t);if(e.fileInfo.size||(e.fileInfo.size=Number.MAX_SAFE_INTEGER),await e.peekBuffer(t,{length:12,mayBeLess:!0}),i([66,77]))return{ext:"bmp",mime:"image/bmp"};if(i([11,119]))return{ext:"ac3",mime:"audio/vnd.dolby.dd-raw"};if(i([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(i([77,90]))return{ext:"exe",mime:"application/x-msdownload"};if(i([37,33]))return await e.peekBuffer(t,{length:24,mayBeLess:!0}),r("PS-Adobe-",{offset:2})&&r(" EPSF-",{offset:14})?{ext:"eps",mime:"application/eps"}:{ext:"ps",mime:"application/postscript"};if(i([31,160])||i([31,157]))return{ext:"Z",mime:"application/x-compress"};if(i([255,216,255]))return{ext:"jpg",mime:"image/jpeg"};if(i([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(i([31,139,8]))return{ext:"gz",mime:"application/gzip"};if(i([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(r("ID3")){await e.ignore(6);const n=await e.readToken(uint32SyncSafeToken);return e.position+n>e.fileInfo.size?{ext:"mp3",mime:"audio/mpeg"}:(await e.ignore(n),fromTokenizer(e))}if(r("MP+"))return{ext:"mpc",mime:"audio/x-musepack"};if((67===t[0]||70===t[0])&&i([87,83],{offset:1}))return{ext:"swf",mime:"application/x-shockwave-flash"};if(i([71,73,70]))return{ext:"gif",mime:"image/gif"};if(r("FLIF"))return{ext:"flif",mime:"image/flif"};if(r("8BPS"))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(r("WEBP",{offset:8}))return{ext:"webp",mime:"image/webp"};if(r("MPCK"))return{ext:"mpc",mime:"audio/x-musepack"};if(r("FORM"))return{ext:"aif",mime:"audio/aiff"};if(r("icns",{offset:0}))return{ext:"icns",mime:"image/icns"};if(i([80,75,3,4])){try{for(;e.position+30<e.fileInfo.size;){await e.readBuffer(t,{length:30});const a={compressedSize:t.readUInt32LE(18),uncompressedSize:t.readUInt32LE(22),filenameLength:t.readUInt16LE(26),extraFieldLength:t.readUInt16LE(28)};if(a.filename=await e.readToken(new Token.StringType(a.filenameLength,"utf-8")),await e.ignore(a.extraFieldLength),"META-INF/mozilla.rsa"===a.filename)return{ext:"xpi",mime:"application/x-xpinstall"};if(a.filename.endsWith(".rels")||a.filename.endsWith(".xml")){switch(a.filename.split("/")[0]){case"_rels":default:break;case"word":return{ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"};case"ppt":return{ext:"pptx",mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation"};case"xl":return{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}}}if(a.filename.startsWith("xl/"))return{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};if(a.filename.startsWith("3D/")&&a.filename.endsWith(".model"))return{ext:"3mf",mime:"model/3mf"};if("mimetype"===a.filename&&a.compressedSize===a.uncompressedSize){switch(await e.readToken(new Token.StringType(a.compressedSize,"utf-8"))){case"application/epub+zip":return{ext:"epub",mime:"application/epub+zip"};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:"application/vnd.oasis.opendocument.text"};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:"application/vnd.oasis.opendocument.spreadsheet"};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:"application/vnd.oasis.opendocument.presentation"}}}if(0===a.compressedSize){let o=-1;for(;o<0&&e.position<e.fileInfo.size;)await e.peekBuffer(t,{mayBeLess:!0}),o=t.indexOf("504B0304",0,"hex"),await e.ignore(o>=0?o:t.length)}else await e.ignore(a.compressedSize)}}catch(s){if(!(s instanceof strtok3.EndOfStreamError))throw s}return{ext:"zip",mime:"application/zip"}}if(r("OggS")){await e.ignore(28);const l=Buffer.alloc(8);return await e.readBuffer(l),_check(l,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/opus"}:_check(l,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:_check(l,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:_check(l,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:_check(l,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:_check(l,[1,118,111,114,98,105,115])?{ext:"ogg",mime:"audio/ogg"}:{ext:"ogx",mime:"application/ogg"}}if(i([80,75])&&(3===t[2]||5===t[2]||7===t[2])&&(4===t[3]||6===t[3]||8===t[3]))return{ext:"zip",mime:"application/zip"};if(r("ftyp",{offset:4})&&96&t[8]){const u=t.toString("binary",8,12).replace("\0"," ").trim();switch(u){case"avif":return{ext:"avif",mime:"image/avif"};case"mif1":return{ext:"heic",mime:"image/heif"};case"msf1":return{ext:"heic",mime:"image/heif-sequence"};case"heic":case"heix":return{ext:"heic",mime:"image/heic"};case"hevc":case"hevx":return{ext:"heic",mime:"image/heic-sequence"};case"qt":return{ext:"mov",mime:"video/quicktime"};case"M4V":case"M4VH":case"M4VP":return{ext:"m4v",mime:"video/x-m4v"};case"M4P":return{ext:"m4p",mime:"video/mp4"};case"M4B":return{ext:"m4b",mime:"audio/mp4"};case"M4A":return{ext:"m4a",mime:"audio/x-m4a"};case"F4V":return{ext:"f4v",mime:"video/mp4"};case"F4P":return{ext:"f4p",mime:"video/mp4"};case"F4A":return{ext:"f4a",mime:"audio/mp4"};case"F4B":return{ext:"f4b",mime:"audio/mp4"};case"crx":return{ext:"cr3",mime:"image/x-canon-cr3"};default:return u.startsWith("3g")?u.startsWith("3g2")?{ext:"3g2",mime:"video/3gpp2"}:{ext:"3gp",mime:"video/3gpp"}:{ext:"mp4",mime:"video/mp4"}}}if(r("MThd"))return{ext:"mid",mime:"audio/midi"};if(r("wOFF")&&(i([0,1,0,0],{offset:4})||r("OTTO",{offset:4})))return{ext:"woff",mime:"font/woff"};if(r("wOF2")&&(i([0,1,0,0],{offset:4})||r("OTTO",{offset:4})))return{ext:"woff2",mime:"font/woff2"};if(i([212,195,178,161])||i([161,178,195,212]))return{ext:"pcap",mime:"application/vnd.tcpdump.pcap"};if(r("DSD "))return{ext:"dsf",mime:"audio/x-dsf"};if(r("LZIP"))return{ext:"lz",mime:"application/x-lzip"};if(r("fLaC"))return{ext:"flac",mime:"audio/x-flac"};if(i([66,80,71,251]))return{ext:"bpg",mime:"image/bpg"};if(r("wvpk"))return{ext:"wv",mime:"audio/wavpack"};if(r("%PDF")){await e.ignore(1350);const h=10485760,c=Buffer.alloc(Math.min(h,e.fileInfo.size));return await e.readBuffer(c,{mayBeLess:!0}),c.includes(Buffer.from("AIPrivateData"))?{ext:"ai",mime:"application/postscript"}:{ext:"pdf",mime:"application/pdf"}}if(i([0,97,115,109]))return{ext:"wasm",mime:"application/wasm"};if(i([73,73,42,0]))return r("CR",{offset:8})?{ext:"cr2",mime:"image/x-canon-cr2"}:i([28,0,254,0],{offset:8})||i([31,0,11,0],{offset:8})?{ext:"nef",mime:"image/x-nikon-nef"}:i([8,0,0,0],{offset:4})&&(i([45,0,254,0],{offset:8})||i([39,0,254,0],{offset:8}))?{ext:"dng",mime:"image/x-adobe-dng"}:(t=Buffer.alloc(24),await e.peekBuffer(t),(i([16,251,134,1],{offset:4})||i([8,0,0,0],{offset:4}))&&i([0,254,0,4,0,1,0,0,0,1,0,0,0,3,1],{offset:9})?{ext:"arw",mime:"image/x-sony-arw"}:{ext:"tif",mime:"image/tiff"});if(i([77,77,0,42]))return{ext:"tif",mime:"image/tiff"};if(r("MAC "))return{ext:"ape",mime:"audio/ape"};if(i([26,69,223,163])){async function f(){const t=await e.peekNumber(Token.UINT8);let i=128,r=0;for(;!(t&i)&&0!==i;)++r,i>>=1;const n=Buffer.alloc(r+1);return await e.readBuffer(n),n}async function d(){const e=await f(),t=await f();t[0]^=128>>t.length-1;const i=Math.min(6,t.length);return{id:e.readUIntBE(0,e.length),len:t.readUIntBE(t.length-i,i)}}async function p(t,i){for(;i>0;){const t=await d();if(17026===t.id)return e.readToken(new Token.StringType(t.len,"utf-8"));await e.ignore(t.len),--i}}const m=await d();switch(await p(0,m.len)){case"webm":return{ext:"webm",mime:"video/webm"};case"matroska":return{ext:"mkv",mime:"video/x-matroska"};default:return}}if(i([82,73,70,70])){if(i([65,86,73],{offset:8}))return{ext:"avi",mime:"video/vnd.avi"};if(i([87,65,86,69],{offset:8}))return{ext:"wav",mime:"audio/vnd.wave"};if(i([81,76,67,77],{offset:8}))return{ext:"qcp",mime:"audio/qcelp"}}if(r("SQLi"))return{ext:"sqlite",mime:"application/x-sqlite3"};if(i([78,69,83,26]))return{ext:"nes",mime:"application/x-nintendo-nes-rom"};if(r("Cr24"))return{ext:"crx",mime:"application/x-google-chrome-extension"};if(r("MSCF")||r("ISc("))return{ext:"cab",mime:"application/vnd.ms-cab-compressed"};if(i([237,171,238,219]))return{ext:"rpm",mime:"application/x-rpm"};if(i([197,208,211,198]))return{ext:"eps",mime:"application/eps"};if(i([40,181,47,253]))return{ext:"zst",mime:"application/zstd"};if(i([79,84,84,79,0]))return{ext:"otf",mime:"font/otf"};if(r("#!AMR"))return{ext:"amr",mime:"audio/amr"};if(r("{\\rtf"))return{ext:"rtf",mime:"application/rtf"};if(i([70,76,86,1]))return{ext:"flv",mime:"video/x-flv"};if(r("IMPM"))return{ext:"it",mime:"audio/x-it"};if(r("-lh0-",{offset:2})||r("-lh1-",{offset:2})||r("-lh2-",{offset:2})||r("-lh3-",{offset:2})||r("-lh4-",{offset:2})||r("-lh5-",{offset:2})||r("-lh6-",{offset:2})||r("-lh7-",{offset:2})||r("-lzs-",{offset:2})||r("-lz4-",{offset:2})||r("-lz5-",{offset:2})||r("-lhd-",{offset:2}))return{ext:"lzh",mime:"application/x-lzh-compressed"};if(i([0,0,1,186])){if(i([33],{offset:4,mask:[241]}))return{ext:"mpg",mime:"video/MP1S"};if(i([68],{offset:4,mask:[196]}))return{ext:"mpg",mime:"video/MP2P"}}if(r("ITSF"))return{ext:"chm",mime:"application/vnd.ms-htmlhelp"};if(i([253,55,122,88,90,0]))return{ext:"xz",mime:"application/x-xz"};if(r("<?xml "))return{ext:"xml",mime:"application/xml"};if(i([55,122,188,175,39,28]))return{ext:"7z",mime:"application/x-7z-compressed"};if(i([82,97,114,33,26,7])&&(0===t[6]||1===t[6]))return{ext:"rar",mime:"application/x-rar-compressed"};if(r("solid "))return{ext:"stl",mime:"model/stl"};if(r("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(r("!<arch>")){await e.ignore(8);return"debian-binary"===await e.readToken(new Token.StringType(13,"ascii"))?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"}}if(i([137,80,78,71,13,10,26,10])){async function _(){return{length:await e.readToken(Token.INT32_BE),type:await e.readToken(new Token.StringType(4,"binary"))}}await e.ignore(8);do{const g=await _();if(g.length<0)return;switch(g.type){case"IDAT":return{ext:"png",mime:"image/png"};case"acTL":return{ext:"apng",mime:"image/apng"};default:await e.ignore(g.length+4)}}while(e.position+8<e.fileInfo.size);return{ext:"png",mime:"image/png"}}if(i([65,82,82,79,87,49,0,0]))return{ext:"arrow",mime:"application/x-apache-arrow"};if(i([103,108,84,70,2,0,0,0]))return{ext:"glb",mime:"model/gltf-binary"};if(i([102,114,101,101],{offset:4})||i([109,100,97,116],{offset:4})||i([109,111,111,118],{offset:4})||i([119,105,100,101],{offset:4}))return{ext:"mov",mime:"video/quicktime"};if(i([73,73,82,79,8,0,0,0,24]))return{ext:"orf",mime:"image/x-olympus-orf"};if(r("gimp xcf "))return{ext:"xcf",mime:"image/x-xcf"};if(i([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:"rw2",mime:"image/x-panasonic-rw2"};if(i([48,38,178,117,142,102,207,17,166,217])){async function b(){const t=Buffer.alloc(16);return await e.readBuffer(t),{id:t,size:Number(await e.readToken(Token.UINT64_LE))}}for(await e.ignore(30);e.position+24<e.fileInfo.size;){const y=await b();let w=y.size-24;if(_check(y.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){const v=Buffer.alloc(16);if(w-=await e.readBuffer(v),_check(v,[64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"audio/x-ms-asf"};if(_check(v,[192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"video/x-ms-asf"};break}await e.ignore(w)}return{ext:"asf",mime:"application/vnd.ms-asf"}}if(i([171,75,84,88,32,49,49,187,13,10,26,10]))return{ext:"ktx",mime:"image/ktx"};if((i([126,16,4])||i([126,24,4]))&&i([48,77,73,69],{offset:4}))return{ext:"mie",mime:"application/x-mie"};if(i([39,10,0,0,0,0,0,0,0,0,0,0],{offset:2}))return{ext:"shp",mime:"application/x-esri-shape"};if(i([0,0,0,12,106,80,32,32,13,10,135,10])){await e.ignore(20);switch(await e.readToken(new Token.StringType(4,"ascii"))){case"jp2 ":return{ext:"jp2",mime:"image/jp2"};case"jpx ":return{ext:"jpx",mime:"image/jpx"};case"jpm ":return{ext:"jpm",mime:"image/jpm"};case"mjp2":return{ext:"mj2",mime:"image/mj2"};default:return}}if(i([255,10])||i([0,0,0,12,74,88,76,32,13,10,135,10]))return{ext:"jxl",mime:"image/jxl"};if(i([0,0,1,186])||i([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};if(i([0,1,0,0,0]))return{ext:"ttf",mime:"font/ttf"};if(i([0,0,1,0]))return{ext:"ico",mime:"image/x-icon"};if(i([0,0,2,0]))return{ext:"cur",mime:"image/x-icon"};if(i([208,207,17,224,161,177,26,225]))return{ext:"cfb",mime:"application/x-cfb"};if(await e.peekBuffer(t,{length:Math.min(256,e.fileInfo.size),mayBeLess:!0}),r("BEGIN:")){if(r("VCARD",{offset:6}))return{ext:"vcf",mime:"text/vcard"};if(r("VCALENDAR",{offset:6}))return{ext:"ics",mime:"text/calendar"}}if(r("FUJIFILMCCD-RAW"))return{ext:"raf",mime:"image/x-fujifilm-raf"};if(r("Extended Module:"))return{ext:"xm",mime:"audio/x-xm"};if(r("Creative Voice File"))return{ext:"voc",mime:"audio/x-voc"};if(i([4,0,0,0])&&t.length>=16){const x=t.readUInt32LE(12);if(x>12&&t.length>=x+16)try{const E=t.slice(16,x+16).toString();if(JSON.parse(E).files)return{ext:"asar",mime:"application/x-asar"}}catch(k){}}if(i([6,14,43,52,2,5,1,1,13,1,2,1,1,2]))return{ext:"mxf",mime:"application/mxf"};if(r("SCRM",{offset:44}))return{ext:"s3m",mime:"audio/x-s3m"};if(i([71],{offset:4})&&(i([71],{offset:192})||i([71],{offset:196})))return{ext:"mts",mime:"video/mp2t"};if(i([66,79,79,75,77,79,66,73],{offset:60}))return{ext:"mobi",mime:"application/x-mobipocket-ebook"};if(i([68,73,67,77],{offset:128}))return{ext:"dcm",mime:"application/dicom"};if(i([76,0,0,0,1,20,2,0,0,0,0,0,192,0,0,0,0,0,0,70]))return{ext:"lnk",mime:"application/x.ms.shortcut"};if(i([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0]))return{ext:"alias",mime:"application/x.apple.alias"};if(i([76,80],{offset:34})&&(i([0,0,1],{offset:8})||i([1,0,2],{offset:8})||i([2,0,2],{offset:8})))return{ext:"eot",mime:"application/vnd.ms-fontobject"};if(i([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29]))return{ext:"indd",mime:"application/x-indesign"};if(await e.peekBuffer(t,{length:Math.min(512,e.fileInfo.size),mayBeLess:!0}),tarHeaderChecksumMatches(t))return{ext:"tar",mime:"application/x-tar"};if(i([255,254,255,14,83,0,107,0,101,0,116,0,99,0,104,0,85,0,112,0,32,0,77,0,111,0,100,0,101,0,108,0]))return{ext:"skp",mime:"application/vnd.sketchup.skp"};if(r("-----BEGIN PGP MESSAGE-----"))return{ext:"pgp",mime:"application/pgp-encrypted"};if(t.length>=2&&i([255,224],{offset:0,mask:[255,224]})){if(i([16],{offset:1,mask:[22]}))return i([8],{offset:1,mask:[8]}),{ext:"aac",mime:"audio/aac"};if(i([2],{offset:1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(i([4],{offset:1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(i([6],{offset:1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}const stream=readableStream=>new Promise(((resolve,reject)=>{const stream=eval("require")("stream");readableStream.on("error",reject),readableStream.once("readable",(async()=>{const e=new stream.PassThrough;let t;t=stream.pipeline?stream.pipeline(readableStream,e,(()=>{})):readableStream.pipe(e);const i=readableStream.read(minimumBytes)||readableStream.read()||Buffer.alloc(0);try{const t=await fromBuffer(i);e.fileType=t}catch(e){reject(e)}resolve(t)}))})),fileType={fromStream:fromStream,fromTokenizer:fromTokenizer,fromBuffer:fromBuffer,stream:stream};Object.defineProperty(fileType,"extensions",{get:()=>new Set(supported.extensions)}),Object.defineProperty(fileType,"mimeTypes",{get:()=>new Set(supported.mimeTypes)});var core=fileType,fileType$1=getDefaultExportFromCjs(core);function to(e,t){return e.then((function(e){return[null,e]})).catch((function(e){return[e,void 0]}))}const writeFile=async()=>{throw new Error("Not supported")};function Mime$1(){this._types=Object.create(null),this._extensions=Object.create(null);for(let e=0;e<arguments.length;e++)this.define(arguments[e]);this.define=this.define.bind(this),this.getType=this.getType.bind(this),this.getExtension=this.getExtension.bind(this)}Mime$1.prototype.define=function(e,t){for(let i in e){let r=e[i].map((function(e){return e.toLowerCase()}));i=i.toLowerCase();for(let e=0;e<r.length;e++){const n=r[e];if("*"!==n[0]){if(!t&&n in this._types)throw new Error('Attempt to change mapping for "'+n+'" extension from "'+this._types[n]+'" to "'+i+'". Pass `force=true` to allow this, otherwise remove "'+n+'" from the list of extensions for "'+i+'".');this._types[n]=i}}if(t||!this._extensions[i]){const e=r[0];this._extensions[i]="*"!==e[0]?e:e.substr(1)}}},Mime$1.prototype.getType=function(e){let t=(e=String(e)).replace(/^.*[/\\]/,"").toLowerCase(),i=t.replace(/^.*\./,"").toLowerCase(),r=t.length<e.length;return(i.length<t.length-1||!r)&&this._types[i]||null},Mime$1.prototype.getExtension=function(e){return(e=/^\s*([^;\s]*)/.test(e)&&RegExp.$1)&&this._extensions[e.toLowerCase()]||null};var Mime_1=Mime$1,standard={"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mpd"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["es","ecma"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/express":["exp"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js","mjs"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/trig":["trig"],"application/ttml+xml":["ttml"],"application/ubjson":["ubj"],"application/urc-ressheet+xml":["rsheet"],"application/urc-targetdesc+xml":["td"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["*xsl","xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["*3gpp"],"audio/adpcm":["adp"],"audio/amr":["amr"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx","opus"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/avif":["avif"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/hsj2":["hsj2"],"image/ief":["ief"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm"],"image/jpx":["jpx","jpf"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/ktx2":["ktx2"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/step+xml":["stpx"],"model/step+zip":["stpz"],"model/step-xml+zip":["stpxz"],"model/stl":["stl"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["markdown","md"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/spdx":["spdx"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/iso.segment":["m4s"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]};let Mime=Mime_1;var lite=new Mime(standard),mime=getDefaultExportFromCjs(lite),HorizontalAlign,HorizontalAlign2,VerticalAlign,VerticalAlign2,BlendMode,BlendMode2;function srcOver(e,t,i=1){e.a*=i;const r=t.a+e.a-t.a*e.a;return{r:(e.r*e.a+t.r*t.a*(1-e.a))/r,g:(e.g*e.a+t.g*t.a*(1-e.a))/r,b:(e.b*e.a+t.b*t.a*(1-e.a))/r,a:r}}function dstOver(e,t,i=1){e.a*=i;const r=t.a+e.a-t.a*e.a;return{r:(t.r*t.a+e.r*e.a*(1-t.a))/r,g:(t.g*t.a+e.g*e.a*(1-t.a))/r,b:(t.b*t.a+e.b*e.a*(1-t.a))/r,a:r}}function multiply(e,t,i=1){e.a*=i;const r=t.a+e.a-t.a*e.a,n=e.r*e.a,a=e.g*e.a,o=e.b*e.a,s=t.r*t.a,l=t.g*t.a,u=t.b*t.a;return{r:(n*s+n*(1-t.a)+s*(1-e.a))/r,g:(a*l+a*(1-t.a)+l*(1-e.a))/r,b:(o*u+o*(1-t.a)+u*(1-e.a))/r,a:r}}function add(e,t,i=1){e.a*=i;const r=t.a+e.a-t.a*e.a,n=e.r*e.a,a=e.g*e.a,o=e.b*e.a;return{r:(n+t.r*t.a)/r,g:(a+t.g*t.a)/r,b:(o+t.b*t.a)/r,a:r}}function screen(e,t,i=1){e.a*=i;const r=t.a+e.a-t.a*e.a,n=e.r*e.a,a=e.g*e.a,o=e.b*e.a,s=t.r*t.a,l=t.g*t.a,u=t.b*t.a;return{r:(n*t.a+s*e.a-n*s+n*(1-t.a)+s*(1-e.a))/r,g:(a*t.a+l*e.a-a*l+a*(1-t.a)+l*(1-e.a))/r,b:(o*t.a+u*e.a-o*u+o*(1-t.a)+u*(1-e.a))/r,a:r}}function overlay(e,t,i=1){e.a*=i;const r=t.a+e.a-t.a*e.a,n=e.r*e.a,a=e.g*e.a,o=e.b*e.a,s=t.r*t.a,l=t.g*t.a,u=t.b*t.a;return{r:(2*s<=t.a?2*n*s+n*(1-t.a)+s*(1-e.a):n*(1+t.a)+s*(1+e.a)-2*s*n-t.a*e.a)/r,g:(2*l<=t.a?2*a*l+a*(1-t.a)+l*(1-e.a):a*(1+t.a)+l*(1+e.a)-2*l*a-t.a*e.a)/r,b:(2*u<=t.a?2*o*u+o*(1-t.a)+u*(1-e.a):o*(1+t.a)+u*(1+e.a)-2*u*o-t.a*e.a)/r,a:r}}function darken(e,t,i=1){e.a*=i;const r=t.a+e.a-t.a*e.a,n=e.r*e.a,a=e.g*e.a,o=e.b*e.a,s=t.r*t.a,l=t.g*t.a,u=t.b*t.a;return{r:(Math.min(n*t.a,s*e.a)+n*(1-t.a)+s*(1-e.a))/r,g:(Math.min(a*t.a,l*e.a)+a*(1-t.a)+l*(1-e.a))/r,b:(Math.min(o*t.a,u*e.a)+o*(1-t.a)+u*(1-e.a))/r,a:r}}function lighten(e,t,i=1){e.a*=i;const r=t.a+e.a-t.a*e.a,n=e.r*e.a,a=e.g*e.a,o=e.b*e.a,s=t.r*t.a,l=t.g*t.a,u=t.b*t.a;return{r:(Math.max(n*t.a,s*e.a)+n*(1-t.a)+s*(1-e.a))/r,g:(Math.max(a*t.a,l*e.a)+a*(1-t.a)+l*(1-e.a))/r,b:(Math.max(o*t.a,u*e.a)+o*(1-t.a)+u*(1-e.a))/r,a:r}}function hardLight(e,t,i=1){e.a*=i;const r=t.a+e.a-t.a*e.a,n=e.r*e.a,a=e.g*e.a,o=e.b*e.a,s=t.r*t.a,l=t.g*t.a,u=t.b*t.a;return{r:(2*n<=e.a?2*n*s+n*(1-t.a)+s*(1-e.a):n*(1+t.a)+s*(1+e.a)-2*s*n-t.a*e.a)/r,g:(2*a<=e.a?2*a*l+a*(1-t.a)+l*(1-e.a):a*(1+t.a)+l*(1+e.a)-2*l*a-t.a*e.a)/r,b:(2*o<=e.a?2*o*u+o*(1-t.a)+u*(1-e.a):o*(1+t.a)+u*(1+e.a)-2*u*o-t.a*e.a)/r,a:r}}function difference(e,t,i=1){e.a*=i;const r=t.a+e.a-t.a*e.a,n=e.r*e.a,a=e.g*e.a,o=e.b*e.a,s=t.r*t.a,l=t.g*t.a,u=t.b*t.a;return{r:(n+s-2*Math.min(n*t.a,s*e.a))/r,g:(a+l-2*Math.min(a*t.a,l*e.a))/r,b:(o+u-2*Math.min(o*t.a,u*e.a))/r,a:r}}function exclusion(e,t,i=1){e.a*=i;const r=t.a+e.a-t.a*e.a,n=e.r*e.a,a=e.g*e.a,o=e.b*e.a,s=t.r*t.a,l=t.g*t.a,u=t.b*t.a;return{r:(n*t.a+s*e.a-2*n*s+n*(1-t.a)+s*(1-e.a))/r,g:(a*t.a+l*e.a-2*a*l+a*(1-t.a)+l*(1-e.a))/r,b:(o*t.a+u*e.a-2*o*u+o*(1-t.a)+u*(1-e.a))/r,a:r}}HorizontalAlign2=HorizontalAlign||(HorizontalAlign={}),HorizontalAlign2[HorizontalAlign2.LEFT=1]="LEFT",HorizontalAlign2[HorizontalAlign2.CENTER=2]="CENTER",HorizontalAlign2[HorizontalAlign2.RIGHT=4]="RIGHT",VerticalAlign2=VerticalAlign||(VerticalAlign={}),VerticalAlign2[VerticalAlign2.TOP=8]="TOP",VerticalAlign2[VerticalAlign2.MIDDLE=16]="MIDDLE",VerticalAlign2[VerticalAlign2.BOTTOM=32]="BOTTOM",BlendMode2=BlendMode||(BlendMode={}),BlendMode2.SRC_OVER="srcOver",BlendMode2.DST_OVER="dstOver",BlendMode2.MULTIPLY="multiply",BlendMode2.ADD="add",BlendMode2.SCREEN="screen",BlendMode2.OVERLAY="overlay",BlendMode2.DARKEN="darken",BlendMode2.LIGHTEN="lighten",BlendMode2.HARD_LIGHT="hardLight",BlendMode2.DIFFERENCE="difference",BlendMode2.EXCLUSION="exclusion";const names=[srcOver,dstOver,multiply,add,screen,overlay,darken,lighten,hardLight,difference,exclusion];var compositeModes=Object.freeze({__proto__:null,add:add,darken:darken,difference:difference,dstOver:dstOver,exclusion:exclusion,hardLight:hardLight,lighten:lighten,multiply:multiply,names:names,overlay:overlay,screen:screen,srcOver:srcOver});function composite(e,t,i=0,r=0,n={}){if(!(t instanceof e.constructor))throw new Error("The source must be a Jimp image");if("number"!=typeof i||"number"!=typeof r)throw new Error("x and y must be numbers");const{mode:a=BlendMode.SRC_OVER}=n;let{opacitySource:o=1,opacityDest:s=1}=n;("number"!=typeof o||o<0||o>1)&&(o=1),("number"!=typeof s||s<0||s>1)&&(s=1);const l=compositeModes[a];return i=Math.round(i),r=Math.round(r),1!==s&&e.scan(((t,i,r)=>{const n=e.bitmap.data[r+3]*s;e.bitmap.data[r+3]=n})),t.scan(((n,a,s)=>{const u=e.getPixelIndex(i+n,r+a,Edge.CROP);if(-1===u)return;const h=l({r:t.bitmap.data[s+0]/255,g:t.bitmap.data[s+1]/255,b:t.bitmap.data[s+2]/255,a:t.bitmap.data[s+3]/255},{r:e.bitmap.data[u+0]/255,g:e.bitmap.data[u+1]/255,b:e.bitmap.data[u+2]/255,a:e.bitmap.data[u+3]/255},o);e.bitmap.data[u+0]=limit255(255*h.r),e.bitmap.data[u+1]=limit255(255*h.g),e.bitmap.data[u+2]=limit255(255*h.b),e.bitmap.data[u+3]=limit255(255*h.a)})),e}var jpeg$1={parseSections:function(e,t){var i,r;for(e.setBigEndian(!0);e.remainingLength()>0&&218!==r;){if(255!==e.nextUInt8())throw new Error("Invalid JPEG section offset");i=(r=e.nextUInt8())>=208&&r<=217||218===r?0:e.nextUInt16()-2,t(r,e.branch(0,i)),e.skip(i)}},getSizeFromSOFSection:function(e){return e.skip(1),{height:e.nextUInt16(),width:e.nextUInt16()}},getSectionName:function(e){var t,i;switch(e){case 216:t="SOI";break;case 196:t="DHT";break;case 219:t="DQT";break;case 221:t="DRI";break;case 218:t="SOS";break;case 254:t="COM";break;case 217:t="EOI";break;default:e>=224&&e<=239?(t="APP",i=e-224):e>=192&&e<=207&&196!==e&&200!==e&&204!==e?(t="SOF",i=e-192):e>=208&&e<=215&&(t="RST",i=e-208)}var r={name:t};return"number"==typeof i&&(r.index=i),r}};function readExifValue(e,t){switch(e){case 1:return t.nextUInt8();case 3:case 8:return t.nextUInt16();case 4:case 9:return t.nextUInt32();case 5:return[t.nextUInt32(),t.nextUInt32()];case 6:return t.nextInt8();case 10:return[t.nextInt32(),t.nextInt32()];case 11:return t.nextFloat();case 12:return t.nextDouble();default:throw new Error("Invalid format while decoding: "+e)}}function getBytesPerComponent(e){switch(e){case 1:case 2:case 6:case 7:return 1;case 3:case 8:return 2;case 4:case 9:case 11:return 4;case 5:case 10:case 12:return 8;default:return 0}}function readExifTag(e,t){var i,r,n=t.nextUInt16(),a=t.nextUInt16(),o=getBytesPerComponent(a),s=t.nextUInt32(),l=o*s;if(l>4&&(t=e.openWithOffset(t.nextUInt32())),2===a){var u=(i=t.nextString(s)).indexOf("\0");-1!==u&&(i=i.substr(0,u))}else if(7===a)i=t.nextBuffer(s);else if(0!==a)for(i=[],r=0;r<s;++r)i.push(readExifValue(a,t));return l<4&&t.skip(4-l),[n,i,a]}function readIFDSection(e,t,i){var r,n,a=t.nextUInt16();for(n=0;n<a;++n)i((r=readExifTag(e,t))[0],r[1],r[2])}function readHeader(e){if("Exif\0\0"!==e.nextString(6))throw new Error("Invalid EXIF header");var t=e.mark(),i=e.nextUInt16();if(18761===i)e.setBigEndian(!1);else{if(19789!==i)throw new Error("Invalid TIFF header");e.setBigEndian(!0)}if(42!==e.nextUInt16())throw new Error("Invalid TIFF data");return t}var exif$2={IFD0:1,IFD1:2,GPSIFD:3,SubIFD:4,InteropIFD:5,parseTags:function(e,t){var i,r,n,a;try{i=readHeader(e)}catch(e){return!1}var o=i.openWithOffset(e.nextUInt32()),s=this.IFD0;readIFDSection(i,o,(function(e,i,a){switch(e){case 34853:n=i[0];break;case 34665:r=i[0];break;default:t(s,e,i,a)}}));var l=o.nextUInt32();if(0!==l){var u=i.openWithOffset(l);readIFDSection(i,u,t.bind(null,this.IFD1))}if(n){var h=i.openWithOffset(n);readIFDSection(i,h,t.bind(null,this.GPSIFD))}if(r){var c=i.openWithOffset(r),f=this.InteropIFD;readIFDSection(i,c,(function(e,i,r){40965===e?a=i[0]:t(f,e,i,r)}))}if(a){var d=i.openWithOffset(a);readIFDSection(i,d,t.bind(null,this.InteropIFD))}return!0}};function parseNumber(e){return parseInt(e,10)}var hours=3600,minutes=60;function parseDateTimeParts(e,t){e=e.map(parseNumber),t=t.map(parseNumber);var i=e[0],r=e[1]-1,n=e[2],a=t[0],o=t[1],s=t[2];return Date.UTC(i,r,n,a,o,s,0)/1e3}function parseDateWithTimezoneFormat(e){var t=e.substr(0,10).split("-"),i=e.substr(11,8).split(":"),r=e.substr(19,6).split(":").map(parseNumber),n=r[0]*hours+r[1]*minutes,a=parseDateTimeParts(t,i);if("number"==typeof(a-=n)&&!isNaN(a))return a}function parseDateWithSpecFormat(e){var t=e.split(" "),i=parseDateTimeParts(t[0].split(":"),t[1].split(":"));if("number"==typeof i&&!isNaN(i))return i}function parseExifDate(e){var t=19===e.length&&":"===e.charAt(4);return 25===e.length&&"T"===e.charAt(10)?parseDateWithTimezoneFormat(e):t?parseDateWithSpecFormat(e):void 0}var date$1={parseDateWithSpecFormat:parseDateWithSpecFormat,parseDateWithTimezoneFormat:parseDateWithTimezoneFormat,parseExifDate:parseExifDate},exif$1=exif$2,date=date$1,degreeTags=[{section:exif$1.GPSIFD,type:2,name:"GPSLatitude",refType:1,refName:"GPSLatitudeRef",posVal:"N"},{section:exif$1.GPSIFD,type:4,name:"GPSLongitude",refType:3,refName:"GPSLongitudeRef",posVal:"E"}],dateTags=[{section:exif$1.SubIFD,type:306,name:"ModifyDate"},{section:exif$1.SubIFD,type:36867,name:"DateTimeOriginal"},{section:exif$1.SubIFD,type:36868,name:"CreateDate"},{section:exif$1.SubIFD,type:306,name:"ModifyDate"}],simplify$1={castDegreeValues:function(e,t){degreeTags.forEach((function(i){var r=e(i);if(r){var n=e({section:i.section,type:i.refType,name:i.refName})===i.posVal?1:-1,a=(r[0]+r[1]/60+r[2]/3600)*n;t(i,a)}}))},castDateValues:function(e,t){dateTags.forEach((function(i){var r=e(i);if(r){var n=date.parseExifDate(r);void 0!==n&&t(i,n)}}))},simplifyValue:function(e,t){return Array.isArray(e)&&1===(e=e.map((function(e){return 10===t||5===t?e[0]/e[1]:e}))).length&&(e=e[0]),e}},exifTags,hasRequiredExifTags;function requireExifTags(){return hasRequiredExifTags?exifTags:(hasRequiredExifTags=1,exifTags={exif:{1:"InteropIndex",2:"InteropVersion",11:"ProcessingSoftware",254:"SubfileType",255:"OldSubfileType",256:"ImageWidth",257:"ImageHeight",258:"BitsPerSample",259:"Compression",262:"PhotometricInterpretation",263:"Thresholding",264:"CellWidth",265:"CellLength",266:"FillOrder",269:"DocumentName",270:"ImageDescription",271:"Make",272:"Model",273:"StripOffsets",274:"Orientation",277:"SamplesPerPixel",278:"RowsPerStrip",279:"StripByteCounts",280:"MinSampleValue",281:"MaxSampleValue",282:"XResolution",283:"YResolution",284:"PlanarConfiguration",285:"PageName",286:"XPosition",287:"YPosition",288:"FreeOffsets",289:"FreeByteCounts",290:"GrayResponseUnit",291:"GrayResponseCurve",292:"T4Options",293:"T6Options",296:"ResolutionUnit",297:"PageNumber",300:"ColorResponseUnit",301:"TransferFunction",305:"Software",306:"ModifyDate",315:"Artist",316:"HostComputer",317:"Predictor",318:"WhitePoint",319:"PrimaryChromaticities",320:"ColorMap",321:"HalftoneHints",322:"TileWidth",323:"TileLength",324:"TileOffsets",325:"TileByteCounts",326:"BadFaxLines",327:"CleanFaxData",328:"ConsecutiveBadFaxLines",330:"SubIFD",332:"InkSet",333:"InkNames",334:"NumberofInks",336:"DotRange",337:"TargetPrinter",338:"ExtraSamples",339:"SampleFormat",340:"SMinSampleValue",341:"SMaxSampleValue",342:"TransferRange",343:"ClipPath",344:"XClipPathUnits",345:"YClipPathUnits",346:"Indexed",347:"JPEGTables",351:"OPIProxy",400:"GlobalParametersIFD",401:"ProfileType",402:"FaxProfile",403:"CodingMethods",404:"VersionYear",405:"ModeNumber",433:"Decode",434:"DefaultImageColor",435:"T82Options",437:"JPEGTables",512:"JPEGProc",513:"ThumbnailOffset",514:"ThumbnailLength",515:"JPEGRestartInterval",517:"JPEGLosslessPredictors",518:"JPEGPointTransforms",519:"JPEGQTables",520:"JPEGDCTables",521:"JPEGACTables",529:"YCbCrCoefficients",530:"YCbCrSubSampling",531:"YCbCrPositioning",532:"ReferenceBlackWhite",559:"StripRowCounts",700:"ApplicationNotes",999:"USPTOMiscellaneous",4096:"RelatedImageFileFormat",4097:"RelatedImageWidth",4098:"RelatedImageHeight",18246:"Rating",18247:"XP_DIP_XML",18248:"StitchInfo",18249:"RatingPercent",32781:"ImageID",32931:"WangTag1",32932:"WangAnnotation",32933:"WangTag3",32934:"WangTag4",32995:"Matteing",32996:"DataType",32997:"ImageDepth",32998:"TileDepth",33405:"Model2",33421:"CFARepeatPatternDim",33422:"CFAPattern2",33423:"BatteryLevel",33424:"KodakIFD",33432:"Copyright",33434:"ExposureTime",33437:"FNumber",33445:"MDFileTag",33446:"MDScalePixel",33447:"MDColorTable",33448:"MDLabName",33449:"MDSampleInfo",33450:"MDPrepDate",33451:"MDPrepTime",33452:"MDFileUnits",33550:"PixelScale",33589:"AdventScale",33590:"AdventRevision",33628:"UIC1Tag",33629:"UIC2Tag",33630:"UIC3Tag",33631:"UIC4Tag",33723:"IPTC-NAA",33918:"IntergraphPacketData",33919:"IntergraphFlagRegisters",33920:"IntergraphMatrix",33921:"INGRReserved",33922:"ModelTiePoint",34016:"Site",34017:"ColorSequence",34018:"IT8Header",34019:"RasterPadding",34020:"BitsPerRunLength",34021:"BitsPerExtendedRunLength",34022:"ColorTable",34023:"ImageColorIndicator",34024:"BackgroundColorIndicator",34025:"ImageColorValue",34026:"BackgroundColorValue",34027:"PixelIntensityRange",34028:"TransparencyIndicator",34029:"ColorCharacterization",34030:"HCUsage",34031:"TrapIndicator",34032:"CMYKEquivalent",34118:"SEMInfo",34152:"AFCP_IPTC",34232:"PixelMagicJBIGOptions",34264:"ModelTransform",34306:"WB_GRGBLevels",34310:"LeafData",34377:"PhotoshopSettings",34665:"ExifOffset",34675:"ICC_Profile",34687:"TIFF_FXExtensions",34688:"MultiProfiles",34689:"SharedData",34690:"T88Options",34732:"ImageLayer",34735:"GeoTiffDirectory",34736:"GeoTiffDoubleParams",34737:"GeoTiffAsciiParams",34850:"ExposureProgram",34852:"SpectralSensitivity",34853:"GPSInfo",34855:"ISO",34856:"Opto-ElectricConvFactor",34857:"Interlace",34858:"TimeZoneOffset",34859:"SelfTimerMode",34864:"SensitivityType",34865:"StandardOutputSensitivity",34866:"RecommendedExposureIndex",34867:"ISOSpeed",34868:"ISOSpeedLatitudeyyy",34869:"ISOSpeedLatitudezzz",34908:"FaxRecvParams",34909:"FaxSubAddress",34910:"FaxRecvTime",34954:"LeafSubIFD",36864:"ExifVersion",36867:"DateTimeOriginal",36868:"CreateDate",37121:"ComponentsConfiguration",37122:"CompressedBitsPerPixel",37377:"ShutterSpeedValue",37378:"ApertureValue",37379:"BrightnessValue",37380:"ExposureCompensation",37381:"MaxApertureValue",37382:"SubjectDistance",37383:"MeteringMode",37384:"LightSource",37385:"Flash",37386:"FocalLength",37387:"FlashEnergy",37388:"SpatialFrequencyResponse",37389:"Noise",37390:"FocalPlaneXResolution",37391:"FocalPlaneYResolution",37392:"FocalPlaneResolutionUnit",37393:"ImageNumber",37394:"SecurityClassification",37395:"ImageHistory",37396:"SubjectArea",37397:"ExposureIndex",37398:"TIFF-EPStandardID",37399:"SensingMethod",37434:"CIP3DataFile",37435:"CIP3Sheet",37436:"CIP3Side",37439:"StoNits",37500:"MakerNote",37510:"UserComment",37520:"SubSecTime",37521:"SubSecTimeOriginal",37522:"SubSecTimeDigitized",37679:"MSDocumentText",37680:"MSPropertySetStorage",37681:"MSDocumentTextPosition",37724:"ImageSourceData",40091:"XPTitle",40092:"XPComment",40093:"XPAuthor",40094:"XPKeywords",40095:"XPSubject",40960:"FlashpixVersion",40961:"ColorSpace",40962:"ExifImageWidth",40963:"ExifImageHeight",40964:"RelatedSoundFile",40965:"InteropOffset",41483:"FlashEnergy",41484:"SpatialFrequencyResponse",41485:"Noise",41486:"FocalPlaneXResolution",41487:"FocalPlaneYResolution",41488:"FocalPlaneResolutionUnit",41489:"ImageNumber",41490:"SecurityClassification",41491:"ImageHistory",41492:"SubjectLocation",41493:"ExposureIndex",41494:"TIFF-EPStandardID",41495:"SensingMethod",41728:"FileSource",41729:"SceneType",41730:"CFAPattern",41985:"CustomRendered",41986:"ExposureMode",41987:"WhiteBalance",41988:"DigitalZoomRatio",41989:"FocalLengthIn35mmFormat",41990:"SceneCaptureType",41991:"GainControl",41992:"Contrast",41993:"Saturation",41994:"Sharpness",41995:"DeviceSettingDescription",41996:"SubjectDistanceRange",42016:"ImageUniqueID",42032:"OwnerName",42033:"SerialNumber",42034:"LensInfo",42035:"LensMake",42036:"LensModel",42037:"LensSerialNumber",42112:"GDALMetadata",42113:"GDALNoData",42240:"Gamma",44992:"ExpandSoftware",44993:"ExpandLens",44994:"ExpandFilm",44995:"ExpandFilterLens",44996:"ExpandScanner",44997:"ExpandFlashLamp",48129:"PixelFormat",48130:"Transformation",48131:"Uncompressed",48132:"ImageType",48256:"ImageWidth",48257:"ImageHeight",48258:"WidthResolution",48259:"HeightResolution",48320:"ImageOffset",48321:"ImageByteCount",48322:"AlphaOffset",48323:"AlphaByteCount",48324:"ImageDataDiscard",48325:"AlphaDataDiscard",50215:"OceScanjobDesc",50216:"OceApplicationSelector",50217:"OceIDNumber",50218:"OceImageLogic",50255:"Annotations",50341:"PrintIM",50560:"USPTOOriginalContentType",50706:"DNGVersion",50707:"DNGBackwardVersion",50708:"UniqueCameraModel",50709:"LocalizedCameraModel",50710:"CFAPlaneColor",50711:"CFALayout",50712:"LinearizationTable",50713:"BlackLevelRepeatDim",50714:"BlackLevel",50715:"BlackLevelDeltaH",50716:"BlackLevelDeltaV",50717:"WhiteLevel",50718:"DefaultScale",50719:"DefaultCropOrigin",50720:"DefaultCropSize",50721:"ColorMatrix1",50722:"ColorMatrix2",50723:"CameraCalibration1",50724:"CameraCalibration2",50725:"ReductionMatrix1",50726:"ReductionMatrix2",50727:"AnalogBalance",50728:"AsShotNeutral",50729:"AsShotWhiteXY",50730:"BaselineExposure",50731:"BaselineNoise",50732:"BaselineSharpness",50733:"BayerGreenSplit",50734:"LinearResponseLimit",50735:"CameraSerialNumber",50736:"DNGLensInfo",50737:"ChromaBlurRadius",50738:"AntiAliasStrength",50739:"ShadowScale",50740:"DNGPrivateData",50741:"MakerNoteSafety",50752:"RawImageSegmentation",50778:"CalibrationIlluminant1",50779:"CalibrationIlluminant2",50780:"BestQualityScale",50781:"RawDataUniqueID",50784:"AliasLayerMetadata",50827:"OriginalRawFileName",50828:"OriginalRawFileData",50829:"ActiveArea",50830:"MaskedAreas",50831:"AsShotICCProfile",50832:"AsShotPreProfileMatrix",50833:"CurrentICCProfile",50834:"CurrentPreProfileMatrix",50879:"ColorimetricReference",50898:"PanasonicTitle",50899:"PanasonicTitle2",50931:"CameraCalibrationSig",50932:"ProfileCalibrationSig",50933:"ProfileIFD",50934:"AsShotProfileName",50935:"NoiseReductionApplied",50936:"ProfileName",50937:"ProfileHueSatMapDims",50938:"ProfileHueSatMapData1",50939:"ProfileHueSatMapData2",50940:"ProfileToneCurve",50941:"ProfileEmbedPolicy",50942:"ProfileCopyright",50964:"ForwardMatrix1",50965:"ForwardMatrix2",50966:"PreviewApplicationName",50967:"PreviewApplicationVersion",50968:"PreviewSettingsName",50969:"PreviewSettingsDigest",50970:"PreviewColorSpace",50971:"PreviewDateTime",50972:"RawImageDigest",50973:"OriginalRawFileDigest",50974:"SubTileBlockSize",50975:"RowInterleaveFactor",50981:"ProfileLookTableDims",50982:"ProfileLookTableData",51008:"OpcodeList1",51009:"OpcodeList2",51022:"OpcodeList3",51041:"NoiseProfile",51043:"TimeCodes",51044:"FrameRate",51058:"TStop",51081:"ReelName",51089:"OriginalDefaultFinalSize",51090:"OriginalBestQualitySize",51091:"OriginalDefaultCropSize",51105:"CameraLabel",51107:"ProfileHueSatMapEncoding",51108:"ProfileLookTableEncoding",51109:"BaselineExposureOffset",51110:"DefaultBlackRender",51111:"NewRawImageDigest",51112:"RawToPreviewGain",51125:"DefaultUserCrop",59932:"Padding",59933:"OffsetSchema",65e3:"OwnerName",65001:"SerialNumber",65002:"Lens",65024:"KDC_IFD",65100:"RawFile",65101:"Converter",65102:"WhiteBalance",65105:"Exposure",65106:"Shadows",65107:"Brightness",65108:"Contrast",65109:"Saturation",65110:"Sharpness",65111:"Smoothness",65112:"MoireFilter"},gps:{0:"GPSVersionID",1:"GPSLatitudeRef",2:"GPSLatitude",3:"GPSLongitudeRef",4:"GPSLongitude",5:"GPSAltitudeRef",6:"GPSAltitude",7:"GPSTimeStamp",8:"GPSSatellites",9:"GPSStatus",10:"GPSMeasureMode",11:"GPSDOP",12:"GPSSpeedRef",13:"GPSSpeed",14:"GPSTrackRef",15:"GPSTrack",16:"GPSImgDirectionRef",17:"GPSImgDirection",18:"GPSMapDatum",19:"GPSDestLatitudeRef",20:"GPSDestLatitude",21:"GPSDestLongitudeRef",22:"GPSDestLongitude",23:"GPSDestBearingRef",24:"GPSDestBearing",25:"GPSDestDistanceRef",26:"GPSDestDistance",27:"GPSProcessingMethod",28:"GPSAreaInformation",29:"GPSDateStamp",30:"GPSDifferential",31:"GPSHPositioningError"}})}var jpeg=jpeg$1,exif=exif$2,simplify=simplify$1;function ExifResult(e,t,i,r,n,a,o){this.startMarker=e,this.tags=t,this.imageSize=i,this.thumbnailOffset=r,this.thumbnailLength=n,this.thumbnailType=a,this.app1Offset=o}function Parser$1(e){this.stream=e,this.flags={readBinaryTags:!1,resolveTagNames:!0,simplifyValues:!0,imageSize:!0,hidePointers:!0,returnTags:!0}}ExifResult.prototype={hasThumbnail:function(e){return!(!this.thumbnailOffset||!this.thumbnailLength)&&("string"!=typeof e||("image/jpeg"===e.toLowerCase().trim()?6===this.thumbnailType:"image/tiff"===e.toLowerCase().trim()&&1===this.thumbnailType))},getThumbnailOffset:function(){return this.app1Offset+6+this.thumbnailOffset},getThumbnailLength:function(){return this.thumbnailLength},getThumbnailBuffer:function(){return this._getThumbnailStream().nextBuffer(this.thumbnailLength)},_getThumbnailStream:function(){return this.startMarker.openWithOffset(this.getThumbnailOffset())},getImageSize:function(){return this.imageSize},getThumbnailSize:function(){var e,t=this._getThumbnailStream();return jpeg.parseSections(t,(function(t,i){"SOF"===jpeg.getSectionName(t).name&&(e=jpeg.getSizeFromSOFSection(i))})),e}},Parser$1.prototype={enableBinaryFields:function(e){return this.flags.readBinaryTags=!!e,this},enablePointers:function(e){return this.flags.hidePointers=!e,this},enableTagNames:function(e){return this.flags.resolveTagNames=!!e,this},enableImageSize:function(e){return this.flags.imageSize=!!e,this},enableReturnTags:function(e){return this.flags.returnTags=!!e,this},enableSimpleValues:function(e){return this.flags.simplifyValues=!!e,this},parse:function(){var e,t,i,r,n,a,o,s,l,u=this.stream.mark(),h=u.openWithOffset(0),c=this.flags;return c.resolveTagNames&&(o=requireExifTags()),c.resolveTagNames?(e={},s=function(t){return e[t.name]},l=function(t,i){e[t.name]=i}):(e=[],s=function(t){var i;for(i=0;i<e.length;++i)if(e[i].type===t.type&&e[i].section===t.section)return e.value},l=function(t,i){var r;for(r=0;r<e.length;++r)if(e[r].type===t.type&&e[r].section===t.section)return void(e.value=i)}),jpeg.parseSections(h,(function(s,l){var h=l.offsetFrom(u);225===s?exif.parseTags(l,(function(t,a,s,l){if(c.readBinaryTags||7!==l){if(513===a){if(i=s[0],c.hidePointers)return}else if(514===a){if(r=s[0],c.hidePointers)return}else if(259===a&&(n=s[0],c.hidePointers))return;if(c.returnTags)if(c.simplifyValues&&(s=simplify.simplifyValue(s,l)),c.resolveTagNames){var u=(t===exif.GPSIFD?o.gps:o.exif)[a];u||(u=o.exif[a]),e.hasOwnProperty(u)||(e[u]=s)}else e.push({section:t,type:a,value:s})}}))&&(a=h):c.imageSize&&"SOF"===jpeg.getSectionName(s).name&&(t=jpeg.getSizeFromSOFSection(l))})),c.simplifyValues&&(simplify.castDegreeValues(s,l),simplify.castDateValues(s,l)),new ExifResult(u,e,t,i,r,n,a)}};var parser=Parser$1,domBufferstream,hasRequiredDomBufferstream,bufferstream,hasRequiredBufferstream;function requireDomBufferstream(){if(hasRequiredDomBufferstream)return domBufferstream;function e(e,t,i,r,n,a){this.global=n,t=t||0,i=i||e.byteLength-t,this.arrayBuffer=e.slice(t,t+i),this.view=new n.DataView(this.arrayBuffer,0,this.arrayBuffer.byteLength),this.setBigEndian(r),this.offset=0,this.parentOffset=(a||0)+t}return hasRequiredDomBufferstream=1,e.prototype={setBigEndian:function(e){this.littleEndian=!e},nextUInt8:function(){var e=this.view.getUint8(this.offset);return this.offset+=1,e},nextInt8:function(){var e=this.view.getInt8(this.offset);return this.offset+=1,e},nextUInt16:function(){var e=this.view.getUint16(this.offset,this.littleEndian);return this.offset+=2,e},nextUInt32:function(){var e=this.view.getUint32(this.offset,this.littleEndian);return this.offset+=4,e},nextInt16:function(){var e=this.view.getInt16(this.offset,this.littleEndian);return this.offset+=2,e},nextInt32:function(){var e=this.view.getInt32(this.offset,this.littleEndian);return this.offset+=4,e},nextFloat:function(){var e=this.view.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e},nextDouble:function(){var e=this.view.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e},nextBuffer:function(e){var t=this.arrayBuffer.slice(this.offset,this.offset+e);return this.offset+=e,t},remainingLength:function(){return this.arrayBuffer.byteLength-this.offset},nextString:function(e){var t=this.arrayBuffer.slice(this.offset,this.offset+e);return t=String.fromCharCode.apply(null,new this.global.Uint8Array(t)),this.offset+=e,t},mark:function(){var t=this;return{openWithOffset:function(i){return i=(i||0)+this.offset,new e(t.arrayBuffer,i,t.arrayBuffer.byteLength-i,!t.littleEndian,t.global,t.parentOffset)},offset:this.offset,getParentOffset:function(){return t.parentOffset}}},offsetFrom:function(e){return this.parentOffset+this.offset-(e.offset+e.getParentOffset())},skip:function(e){this.offset+=e},branch:function(t,i){return i="number"==typeof i?i:this.arrayBuffer.byteLength-(this.offset+t),new e(this.arrayBuffer,this.offset+t,i,!this.littleEndian,this.global,this.parentOffset)}},domBufferstream=e}function requireBufferstream(){if(hasRequiredBufferstream)return bufferstream;function e(e,t,i,r){this.buffer=e,this.offset=t||0,i="number"==typeof i?i:e.length,this.endPosition=this.offset+i,this.setBigEndian(r)}return hasRequiredBufferstream=1,e.prototype={setBigEndian:function(e){this.bigEndian=!!e},nextUInt8:function(){var e=this.buffer.readUInt8(this.offset);return this.offset+=1,e},nextInt8:function(){var e=this.buffer.readInt8(this.offset);return this.offset+=1,e},nextUInt16:function(){var e=this.bigEndian?this.buffer.readUInt16BE(this.offset):this.buffer.readUInt16LE(this.offset);return this.offset+=2,e},nextUInt32:function(){var e=this.bigEndian?this.buffer.readUInt32BE(this.offset):this.buffer.readUInt32LE(this.offset);return this.offset+=4,e},nextInt16:function(){var e=this.bigEndian?this.buffer.readInt16BE(this.offset):this.buffer.readInt16LE(this.offset);return this.offset+=2,e},nextInt32:function(){var e=this.bigEndian?this.buffer.readInt32BE(this.offset):this.buffer.readInt32LE(this.offset);return this.offset+=4,e},nextFloat:function(){var e=this.bigEndian?this.buffer.readFloatBE(this.offset):this.buffer.readFloatLE(this.offset);return this.offset+=4,e},nextDouble:function(){var e=this.bigEndian?this.buffer.readDoubleBE(this.offset):this.buffer.readDoubleLE(this.offset);return this.offset+=8,e},nextBuffer:function(e){var t=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t},remainingLength:function(){return this.endPosition-this.offset},nextString:function(e){var t=this.buffer.toString("utf8",this.offset,this.offset+e);return this.offset+=e,t},mark:function(){var t=this;return{openWithOffset:function(i){return i=(i||0)+this.offset,new e(t.buffer,i,t.endPosition-i,t.bigEndian)},offset:this.offset}},offsetFrom:function(e){return this.offset-e.offset},skip:function(e){this.offset+=e},branch:function(t,i){return i="number"==typeof i?i:this.endPosition-(this.offset+t),new e(this.buffer,this.offset+t,i,this.bigEndian)}},bufferstream=e}var Parser=parser;function getGlobal(){return(0,eval)("this")}var exifParser={create:function(e,t){if(e instanceof(t=t||getGlobal()).ArrayBuffer){var i=requireDomBufferstream();return new Parser(new i(e,0,e.byteLength,!0,t))}var r=requireBufferstream();return new Parser(new r(e,0,e.length,!0))}},EXIFParser=getDefaultExportFromCjs(exifParser);function getExifOrientation(e){const t=e._exif;return t&&t.tags&&t.tags.Orientation||1}function getExifOrientationTransformation(e){const t=e.bitmap.width,i=e.bitmap.height;switch(getExifOrientation(e)){case 1:default:return null;case 2:return function(e,i){return[t-e-1,i]};case 3:return function(e,r){return[t-e-1,i-r-1]};case 4:return function(e,t){return[e,i-t-1]};case 5:return function(e,t){return[t,e]};case 6:return function(e,t){return[t,i-e-1]};case 7:return function(e,r){return[t-r-1,i-e-1]};case 8:return function(e,i){return[t-i-1,e]}}}function transformBitmap(e,t,i,r){const n=e.bitmap.data,a=e.bitmap.width,o=Buffer.alloc(n.length);for(let e=0;e<t;e++)for(let s=0;s<i;s++){const[i,l]=r(e,s),u=t*s+e<<2,h=a*l+i<<2,c=n.readUInt32BE(h);o.writeUInt32BE(c,u)}e.bitmap.data=o,e.bitmap.width=t,e.bitmap.height=i,e._exif.tags.Orientation=1}function exifRotate(e){if(getExifOrientation(e)<2)return;const t=getExifOrientationTransformation(e),i=getExifOrientation(e)>4,r=i?e.bitmap.height:e.bitmap.width,n=i?e.bitmap.width:e.bitmap.height;t&&transformBitmap(e,r,n,t)}async function attemptExifRotate(e,t){try{e._exif=EXIFParser.create(t).parse(),exifRotate(e)}catch{}}var __defProp$2=Object.defineProperty,__defNormalProp$2=(e,t,i)=>t in e?__defProp$2(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,__publicField$2=(e,t,i)=>__defNormalProp$2(e,"symbol"!=typeof t?t+"":t,i);const emptyBitmap={data:Buffer.alloc(0),width:0,height:0};function bufferFromArrayBuffer(e){const t=Buffer.alloc(e.byteLength),i=new Uint8Array(e);for(let e=0;e<t.length;++e)t[e]=i[e];return t}function createJimp({plugins:e,formats:t}={}){const i=e||[],r=(t||[]).map((e=>e())),n=class{constructor(e=emptyBitmap){if(__publicField$2(this,"bitmap",emptyBitmap),__publicField$2(this,"background",0),__publicField$2(this,"formats",[]),__publicField$2(this,"mime"),this.formats=r,"data"in e)this.bitmap=e;else if(this.bitmap={data:Buffer.alloc(e.width*e.height*4),width:e.width,height:e.height},e.color){this.background="string"==typeof e.color?cssColorToHex(e.color):e.color;for(let e=0;e<this.bitmap.data.length;e+=4)this.bitmap.data.writeUInt32BE(this.background,e)}for(const e of i)for(const t in e)this[t]=(...i)=>{const r=e[t]?.(this,...i);return"object"==typeof r&&"bitmap"in r?(this.bitmap=r.bitmap,this):r}}static async read(e,t){if(Buffer.isBuffer(e)||e instanceof ArrayBuffer)return this.fromBuffer(e);const[i,r]=await to(fetch(e));if(i)throw new Error(`Could not load Buffer from URL: ${e}`);if(!r.ok)throw new Error(`HTTP Status ${r.status} for url ${e}`);const[n,a]=await to(r.arrayBuffer());if(n)throw new Error(`Could not load Buffer from ${e}`);const o=bufferFromArrayBuffer(a);return this.fromBuffer(o,t)}static fromBitmap(e){let t;if(e.data instanceof Buffer&&(t=Buffer.from(e.data)),(e.data instanceof Uint8Array||e.data instanceof Uint8ClampedArray)&&(t=Buffer.from(e.data.buffer)),Array.isArray(e.data)&&(t=Buffer.concat(e.data.map((e=>Buffer.from(e.toString(16).padStart(8,"0"),"hex"))))),!t)throw new Error("data must be a Buffer");if("number"!=typeof e.height||"number"!=typeof e.width)throw new Error("bitmap must have width and height");return new n({height:e.height,width:e.width,data:t})}static async fromBuffer(e,t){const i=e instanceof ArrayBuffer?bufferFromArrayBuffer(e):e,a=await fileType$1.fromBuffer(i);if(!a||!a.mime)throw new Error("Could not find MIME for Buffer");const o=r.find((e=>e.mime===a.mime));if(!o||!o.decode)throw new Error(`Mime type ${a.mime} does not support decoding`);const s=new n(await o.decode(i,t?.[o.mime]));return s.mime=a.mime,attemptExifRotate(s,i),s}inspect(){return"<Jimp "+(this.bitmap===emptyBitmap?"pending...":this.bitmap.width+"x"+this.bitmap.height)+">"}toString(){return"[object Jimp]"}get width(){return this.bitmap.width}get height(){return this.bitmap.height}async getBuffer(e,t){const i=this.formats.find((t=>t.mime===e));if(!i||!i.encode)throw new Error(`Unsupported MIME type: ${e}`);let r;return i.hasAlpha?r=this:(r=new n({width:this.bitmap.width,height:this.bitmap.height,color:this.background}),composite(r,this)),i.encode(r.bitmap,t)}async getBase64(e,t){return"data:"+e+";base64,"+(await this.getBuffer(e,t)).toString("base64")}async write(e,t){const i=mime.getType(e);await writeFile(e,await this.getBuffer(i,t))}clone(){return new n({...this.bitmap,data:Buffer.from(this.bitmap.data)})}getPixelIndex(e,t,i){let r,n;if(i||(i=Edge.EXTEND),"number"!=typeof e||"number"!=typeof t)throw new Error("x and y must be numbers");r=e=Math.round(e),n=t=Math.round(t),i===Edge.EXTEND&&(e<0&&(r=0),e>=this.bitmap.width&&(r=this.bitmap.width-1),t<0&&(n=0),t>=this.bitmap.height&&(n=this.bitmap.height-1)),i===Edge.WRAP&&(e<0&&(r=this.bitmap.width+e),e>=this.bitmap.width&&(r=e%this.bitmap.width),t<0&&(n=this.bitmap.height+t),t>=this.bitmap.height&&(n=t%this.bitmap.height));let a=this.bitmap.width*n+r<<2;return(r<0||r>=this.bitmap.width)&&(a=-1),(n<0||n>=this.bitmap.height)&&(a=-1),a}getPixelColor(e,t){if("number"!=typeof e||"number"!=typeof t)throw new Error("x and y must be numbers");const i=this.getPixelIndex(e,t);return this.bitmap.data.readUInt32BE(i)}setPixelColor(e,t,i){if("number"!=typeof e||"number"!=typeof t||"number"!=typeof i)throw new Error("hex, x and y must be numbers");const r=this.getPixelIndex(t,i);return this.bitmap.data.writeUInt32BE(e,r),this}hasAlpha(){const{width:e,height:t,data:i}=this.bitmap,r=e*t<<2;for(let e=3;e<r;e+=4)if(255!==i[e])return!0;return!1}composite(e,t=0,i=0,r={}){return composite(this,e,t,i,r)}scan(e,t,i,r,n){return scan(this,e,t,i,r,n)}scanIterator(e=0,t=0,i=this.bitmap.width,r=this.bitmap.height){if("number"!=typeof e||"number"!=typeof t)throw new Error("x and y must be numbers");if("number"!=typeof i||"number"!=typeof r)throw new Error("w and h must be numbers");return scanIterator(this,e,t,i,r)}};return n}var ResizeStrategy,ResizeStrategy2;function Resize(e,t,i,r,n,a,o){this.widthOriginal=Math.abs(Math.floor(e)||0),this.heightOriginal=Math.abs(Math.floor(t)||0),this.targetWidth=Math.abs(Math.floor(i)||0),this.targetHeight=Math.abs(Math.floor(r)||0),this.colorChannels=n?4:3,this.interpolationPass=Boolean(a),this.resizeCallback="function"==typeof o?o:function(){},this.targetWidthMultipliedByChannels=this.targetWidth*this.colorChannels,this.originalWidthMultipliedByChannels=this.widthOriginal*this.colorChannels,this.originalHeightMultipliedByChannels=this.heightOriginal*this.colorChannels,this.widthPassResultSize=this.targetWidthMultipliedByChannels*this.heightOriginal,this.finalResultSize=this.targetWidthMultipliedByChannels*this.targetHeight,this.initialize()}ResizeStrategy2=ResizeStrategy||(ResizeStrategy={}),ResizeStrategy2.NEAREST_NEIGHBOR="nearestNeighbor",ResizeStrategy2.BILINEAR="bilinearInterpolation",ResizeStrategy2.BICUBIC="bicubicInterpolation",ResizeStrategy2.HERMITE="hermiteInterpolation",ResizeStrategy2.BEZIER="bezierInterpolation",Resize.prototype.initialize=function(){if(!(this.widthOriginal>0&&this.heightOriginal>0&&this.targetWidth>0&&this.targetHeight>0))throw console.log(this),new Error("Invalid settings specified for the resizer.");this.configurePasses()},Resize.prototype.configurePasses=function(){this.widthOriginal===this.targetWidth?this.resizeWidth=this.bypassResizer:(this.ratioWeightWidthPass=this.widthOriginal/this.targetWidth,this.ratioWeightWidthPass<1&&this.interpolationPass?(this.initializeFirstPassBuffers(!0),this.resizeWidth=4===this.colorChannels?this.resizeWidthInterpolatedRGBA:this.resizeWidthInterpolatedRGB):(this.initializeFirstPassBuffers(!1),this.resizeWidth=4===this.colorChannels?this.resizeWidthRGBA:this.resizeWidthRGB)),this.heightOriginal===this.targetHeight?this.resizeHeight=this.bypassResizer:(this.ratioWeightHeightPass=this.heightOriginal/this.targetHeight,this.ratioWeightHeightPass<1&&this.interpolationPass?(this.initializeSecondPassBuffers(!0),this.resizeHeight=this.resizeHeightInterpolated):(this.initializeSecondPassBuffers(!1),this.resizeHeight=4===this.colorChannels?this.resizeHeightRGBA:this.resizeHeightRGB))},Resize.prototype._resizeWidthInterpolatedRGBChannels=function(e,t){const i=t?4:3,r=this.ratioWeightWidthPass,n=this.widthBuffer;let a,o,s=0,l=0,u=0,h=0,c=0;for(a=0;s<1/3;a+=i,s+=r)for(l=a,u=0;l<this.widthPassResultSize;u+=this.originalWidthMultipliedByChannels,l+=this.targetWidthMultipliedByChannels)n[l]=e[u],n[l+1]=e[u+1],n[l+2]=e[u+2],t&&(n[l+3]=e[u+3]);for(s-=1/3,o=this.widthOriginal-1;s<o;a+=i,s+=r)for(c=s%1,h=1-c,l=a,u=Math.floor(s)*i;l<this.widthPassResultSize;u+=this.originalWidthMultipliedByChannels,l+=this.targetWidthMultipliedByChannels)n[l+0]=e[u+0]*h+e[u+i+0]*c,n[l+1]=e[u+1]*h+e[u+i+1]*c,n[l+2]=e[u+2]*h+e[u+i+2]*c,t&&(n[l+3]=e[u+3]*h+e[u+i+3]*c);for(o=this.originalWidthMultipliedByChannels-i;a<this.targetWidthMultipliedByChannels;a+=i)for(l=a,u=o;l<this.widthPassResultSize;u+=this.originalWidthMultipliedByChannels,l+=this.targetWidthMultipliedByChannels)n[l]=e[u],n[l+1]=e[u+1],n[l+2]=e[u+2],t&&(n[l+3]=e[u+3]);return n},Resize.prototype._resizeWidthRGBChannels=function(e,t){const i=t?4:3,r=this.ratioWeightWidthPass,n=1/r,a=this.originalWidthMultipliedByChannels-i+1,o=this.targetWidthMultipliedByChannels-i+1,s=this.outputWidthWorkBench,l=this.widthBuffer,u=this.outputWidthWorkBenchOpaquePixelsCount;let h=0,c=0,f=0,d=0,p=0,m=0,_=0,g=1,b=0,y=0,w=0,v=0;do{for(p=0;p<this.originalHeightMultipliedByChannels;)s[p++]=0,s[p++]=0,s[p++]=0,t&&(s[p++]=0,u[p/i-1]=0);h=r;do{for(c=1+f-d,g=Math.min(h,c),p=0,m=f;p<this.originalHeightMultipliedByChannels;m+=a)b=e[m],y=e[++m],w=e[++m],v=t?e[++m]:255,s[p++]+=(v?b:0)*g,s[p++]+=(v?y:0)*g,s[p++]+=(v?w:0)*g,t&&(s[p++]+=v*g,u[p/i-1]+=v?g:0);if(!(h>=c)){d+=h;break}f+=i,d=f,h-=c}while(h>0&&f<this.originalWidthMultipliedByChannels);for(p=0,m=_;p<this.originalHeightMultipliedByChannels;m+=o)h=t?u[p/i]:1,g=t?h?1/h:0:n,l[m]=s[p++]*g,l[++m]=s[p++]*g,l[++m]=s[p++]*g,t&&(l[++m]=s[p++]*n);_+=i}while(_<this.targetWidthMultipliedByChannels);return l},Resize.prototype._resizeHeightRGBChannels=function(e,t){const i=this.ratioWeightHeightPass,r=1/i,n=this.outputHeightWorkBench,a=this.heightBuffer,o=this.outputHeightWorkBenchOpaquePixelsCount;let s=0,l=0,u=0,h=0,c=0,f=0,d=0,p=1,m=0,_=0,g=0,b=0;do{for(c=0;c<this.targetWidthMultipliedByChannels;)n[c++]=0,n[c++]=0,n[c++]=0,t&&(n[c++]=0,o[c/4-1]=0);s=i;do{for(l=1+u-h,p=Math.min(s,l),d=u,c=0;c<this.targetWidthMultipliedByChannels;)m=e[d++],_=e[d++],g=e[d++],b=t?e[d++]:255,n[c++]+=(b?m:0)*p,n[c++]+=(b?_:0)*p,n[c++]+=(b?g:0)*p,t&&(n[c++]+=b*p,o[c/4-1]+=b?p:0);if(!(s>=l)){h+=s;break}u=d,h=u,s-=l}while(s>0&&u<this.widthPassResultSize);for(c=0;c<this.targetWidthMultipliedByChannels;)s=t?o[c/4]:1,p=t?s?1/s:0:r,a[f++]=Math.round(n[c++]*p),a[f++]=Math.round(n[c++]*p),a[f++]=Math.round(n[c++]*p),t&&(a[f++]=Math.round(n[c++]*r))}while(f<this.finalResultSize);return a},Resize.prototype.resizeWidthInterpolatedRGB=function(e){return this._resizeWidthInterpolatedRGBChannels(e,!1)},Resize.prototype.resizeWidthInterpolatedRGBA=function(e){return this._resizeWidthInterpolatedRGBChannels(e,!0)},Resize.prototype.resizeWidthRGB=function(e){return this._resizeWidthRGBChannels(e,!1)},Resize.prototype.resizeWidthRGBA=function(e){return this._resizeWidthRGBChannels(e,!0)},Resize.prototype.resizeHeightInterpolated=function(e){const t=this.ratioWeightHeightPass,i=this.heightBuffer;let r,n=0,a=0,o=0,s=0,l=0,u=0,h=0;for(;n<1/3;n+=t)for(o=0;o<this.targetWidthMultipliedByChannels;)i[a++]=Math.round(e[o++]);for(n-=1/3,r=this.heightOriginal-1;n<r;n+=t)for(h=n%1,u=1-h,s=Math.floor(n)*this.targetWidthMultipliedByChannels,l=s+this.targetWidthMultipliedByChannels,o=0;o<this.targetWidthMultipliedByChannels;++o)i[a++]=Math.round(e[s++]*u+e[l++]*h);for(;a<this.finalResultSize;)for(o=0,s=r*this.targetWidthMultipliedByChannels;o<this.targetWidthMultipliedByChannels;++o)i[a++]=Math.round(e[s++]);return i},Resize.prototype.resizeHeightRGB=function(e){return this._resizeHeightRGBChannels(e,!1)},Resize.prototype.resizeHeightRGBA=function(e){return this._resizeHeightRGBChannels(e,!0)},Resize.prototype.resize=function(e){this.resizeCallback(this.resizeHeight(this.resizeWidth(e)))},Resize.prototype.bypassResizer=function(e){return e},Resize.prototype.initializeFirstPassBuffers=function(e){this.widthBuffer=this.generateFloatBuffer(this.widthPassResultSize),e||(this.outputWidthWorkBench=this.generateFloatBuffer(this.originalHeightMultipliedByChannels),this.colorChannels>3&&(this.outputWidthWorkBenchOpaquePixelsCount=this.generateFloat64Buffer(this.heightOriginal)))},Resize.prototype.initializeSecondPassBuffers=function(e){this.heightBuffer=this.generateUint8Buffer(this.finalResultSize),e||(this.outputHeightWorkBench=this.generateFloatBuffer(this.targetWidthMultipliedByChannels),this.colorChannels>3&&(this.outputHeightWorkBenchOpaquePixelsCount=this.generateFloat64Buffer(this.targetWidth)))},Resize.prototype.generateFloatBuffer=function(e){try{return new Float32Array(e)}catch(e){return console.error(e),[]}},Resize.prototype.generateFloat64Buffer=function(e){try{return new Float64Array(e)}catch(e){return console.error(e),[]}},Resize.prototype.generateUint8Buffer=function(e){try{return new Uint8Array(e)}catch(e){return console.error(e),[]}};const operations={nearestNeighbor(e,t){const i=e.width,r=e.height,n=t.width,a=t.height,o=e.data,s=t.data;for(let e=0;e<a;e++)for(let t=0;t<n;t++){let l=4*(e*n+t);let u=4*(Math.floor(e*r/a)*i+Math.floor(t*i/n));s[l++]=o[u++],s[l++]=o[u++],s[l++]=o[u++],s[l++]=o[u++]}},bilinearInterpolation(e,t){const i=e.width,r=e.height,n=t.width,a=t.height,o=e.data,s=t.data,l=function(e,t,i,r,n){return t===r?i:Math.round((e-t)*n+(r-e)*i)},u=function(e,t,r,n,a,u,h,c){let f=4*(h*i+n)+t,d=4*(h*i+a)+t;const p=l(r,n,o[f],a,o[d]);if(c===h)s[e+t]=p;else{f=4*(c*i+n)+t,d=4*(c*i+a)+t;const m=l(r,n,o[f],a,o[d]);s[e+t]=l(u,h,p,c,m)}};for(let e=0;e<a;e++)for(let t=0;t<n;t++){const o=4*(e*n+t),s=t*i/n,l=Math.floor(s),h=Math.min(Math.ceil(s),i-1),c=e*r/a,f=Math.floor(c),d=Math.min(Math.ceil(c),r-1);u(o,0,s,l,h,c,f,d),u(o,1,s,l,h,c,f,d),u(o,2,s,l,h,c,f,d),u(o,3,s,l,h,c,f,d)}},_interpolate2D(e,t,i,r){const n=e.data,a=t.data,o=e.width,s=e.height,l=t.width,u=t.height,h=Math.max(1,Math.floor(o/l)),c=l*h,f=Math.max(1,Math.floor(s/u)),d=u*f,p=Buffer.alloc(c*s*4);for(let e=0;e<s;e++)for(let t=0;t<c;t++){const i=t*(o-1)/c,a=Math.floor(i),s=i-a,l=4*(e*o+a),u=4*(e*c+t);for(let e=0;e<4;e++){const t=l+e,i=a>0?n[t-4]:2*n[t]-n[t+4],h=n[t],c=n[t+4],f=a<o-2?n[t+8]:2*n[t+4]-n[t];p[u+e]=r(i,h,c,f,s)}}const m=Buffer.alloc(c*d*4);for(let e=0;e<d;e++)for(let t=0;t<c;t++){const i=e*(s-1)/d,n=Math.floor(i),a=i-n,o=4*(n*c+t),l=4*(e*c+t);for(let e=0;e<4;e++){const t=o+e,i=n>0?p[t-4*c]:2*p[t]-p[t+4*c],u=p[t],h=p[t+4*c],f=n<s-2?p[t+8*c]:2*p[t+4*c]-p[t];m[l+e]=r(i,u,h,f,a)}}const _=h*f;if(_>1)for(let e=0;e<u;e++)for(let t=0;t<l;t++){let i=0,r=0,n=0,o=0,s=0;for(let a=0;a<f;a++){const l=e*f+a;for(let e=0;e<h;e++){const a=4*(l*c+(t*h+e)),u=m[a+3];u&&(i+=m[a],r+=m[a+1],n+=m[a+2],s++),o+=u}}const u=4*(e*l+t);a[u]=s?Math.round(i/s):0,a[u+1]=s?Math.round(r/s):0,a[u+2]=s?Math.round(n/s):0,a[u+3]=Math.round(o/_)}else t.data=m},bicubicInterpolation(e,t,i){return this._interpolate2D(e,t,i,(function(e,t,i,r,n){const a=r-i-e+t,o=e-t-a,s=i-e,l=t;return Math.max(0,Math.min(255,a*(n*n*n)+o*(n*n)+s*n+l))}))},hermiteInterpolation(e,t,i){return this._interpolate2D(e,t,i,(function(e,t,i,r,n){const a=t,o=.5*(i-e),s=e-2.5*t+2*i-.5*r,l=.5*(r-e)+1.5*(t-i);return Math.max(0,Math.min(255,Math.round(((l*n+s)*n+o)*n+a)))}))},bezierInterpolation(e,t,i){return this._interpolate2D(e,t,i,(function(e,t,i,r,n){const a=1-n,o=t*a*a*a,s=3*(t+(i-e)/4)*a*a*n,l=3*(i-(r-t)/4)*a*n*n,u=i*n*n*n;return Math.max(0,Math.min(255,Math.round(o+s+l+u)))}))}},ResizeOptionsSchema=z.union([z.object({w:z.number().min(0),h:z.number().min(0).optional(),mode:z.nativeEnum(ResizeStrategy).optional()}),z.object({w:z.number().min(0).optional(),h:z.number().min(0),mode:z.nativeEnum(ResizeStrategy).optional()})]),ScaleToFitOptionsSchema=z.object({w:z.number().min(0),h:z.number().min(0),mode:z.nativeEnum(ResizeStrategy).optional()}),ScaleComplexOptionsSchema=z.object({f:z.number().min(0),mode:z.nativeEnum(ResizeStrategy).optional()}),methods$d={resize(e,t){const{mode:i}=ResizeOptionsSchema.parse(t);let r,n;if("number"==typeof t.w)r=t.w,n=t.h??e.bitmap.height*(r/e.bitmap.width);else{if("number"!=typeof t.h)throw new Error("w must be a number");n=t.h,r=t.w??e.bitmap.width*(n/e.bitmap.height)}if(r=Math.round(r)||1,n=Math.round(n)||1,i&&"function"==typeof operations[i]){const t={data:Buffer.alloc(r*n*4),width:r,height:n};operations[i](e.bitmap,t),e.bitmap=t}else{new Resize(e.bitmap.width,e.bitmap.height,r,n,!0,!0,(t=>{e.bitmap.data=Buffer.from(t),e.bitmap.width=r,e.bitmap.height=n})).resize(e.bitmap.data)}return e},scale(e,t){const{f:i,mode:r}="number"==typeof t?{f:t}:ScaleComplexOptionsSchema.parse(t),n=e.bitmap.width*i,a=e.bitmap.height*i;return this.resize(e,{w:n,h:a,mode:r})},scaleToFit(e,t){const{h:i,w:r,mode:n}=ScaleToFitOptionsSchema.parse(t),a=r/i>e.bitmap.width/e.bitmap.height?i/e.bitmap.height:r/e.bitmap.width;return this.scale(e,{f:a,mode:n})}},ContainOptionsSchema=z.object({w:z.number(),h:z.number(),align:z.number().optional(),mode:z.nativeEnum(ResizeStrategy).optional()}),methods$c={contain(e,t){const{w:i,h:r,align:n=HorizontalAlign.CENTER|VerticalAlign.MIDDLE,mode:a}=ContainOptionsSchema.parse(t),o=7&n,s=n>>3;if((0===o||o&o-1)&&(0===s||s&s-1))throw new Error("only use one flag per alignment direction");const l=o>>1,u=s>>1,h=i/r>e.bitmap.width/e.bitmap.height?r/e.bitmap.height:i/e.bitmap.width,c=methods$d.scale(clone(e),{f:h,mode:a});return(e=methods$d.resize(e,{w:i,h:r,mode:a})).scan(((t,i,r)=>{e.bitmap.data.writeUInt32BE(e.background,r)})),e=methods$h.blit(e,{src:c,x:(e.bitmap.width-c.bitmap.width)/2*l,y:(e.bitmap.height-c.bitmap.height)/2*u})}},CropOptionsSchema=z.object({x:z.number(),y:z.number(),w:z.number(),h:z.number()}),AutocropComplexOptionsSchema=z.object({tolerance:z.number().min(0).max(1).optional(),cropOnlyFrames:z.boolean().optional(),cropSymmetric:z.boolean().optional(),leaveBorder:z.number().optional(),ignoreSides:z.object({north:z.boolean().optional(),south:z.boolean().optional(),east:z.boolean().optional(),west:z.boolean().optional()}).optional()}),methods$b={crop(e,t){let{x:i,y:r,w:n,h:a}=CropOptionsSchema.parse(t);if(i=Math.round(i),r=Math.round(r),n=Math.round(n),a=Math.round(a),0===i&&n===e.bitmap.width){const t=n*r+i<<2,o=t+(a*n<<2);e.bitmap.data=e.bitmap.data.slice(t,o)}else{const t=Buffer.allocUnsafe(n*a*4);let o=0;scan(e,i,r,n,a,(function(i,r,n){const a=e.bitmap.data.readUInt32BE(n);t.writeUInt32BE(a,o),o+=4})),e.bitmap.data=t}return e.bitmap.width=n,e.bitmap.height=a,e},autocrop(e,t={}){const{tolerance:i=2e-4,cropOnlyFrames:r=!0,cropSymmetric:n=!1,leaveBorder:a=0,ignoreSides:o}="number"==typeof t?{tolerance:t}:AutocropComplexOptionsSchema.parse(t),s=e.bitmap.width,l=e.bitmap.height,u={north:!1,south:!1,east:!1,west:!1,...o};let h=e.getPixelColor(0,0);const c=intToRGBA$1(h);let f=0,d=0,p=0,m=0;if(h=e.getPixelColor(0,0),!u.north)e:for(let t=0;t<l-1;t++){for(let r=0;r<s;r++){if(colorDiff(c,intToRGBA$1(e.getPixelColor(r,t)))>i)break e}f++}if(h=e.getPixelColor(s,0),!u.west)e:for(let t=0;t<s-1;t++){for(let r=0+f;r<l;r++){if(colorDiff(c,intToRGBA$1(e.getPixelColor(t,r)))>i)break e}m++}if(h=e.getPixelColor(0,l),!u.south)e:for(let t=l-1;t>=f+1;t--){for(let r=s-d-1;r>=0;r--){if(colorDiff(c,intToRGBA$1(e.getPixelColor(r,t)))>i)break e}p++}if(h=e.getPixelColor(s,l),!u.east)e:for(let t=s-1;t>=0+m+1;t--){for(let r=l-1;r>=0+f;r--){if(colorDiff(c,intToRGBA$1(e.getPixelColor(t,r)))>i)break e}d++}let _=!1;if(m-=a,d-=a,f-=a,p-=a,n){const e=Math.min(d,m),t=Math.min(f,p);m=e,d=e,f=t,p=t}m=m>=0?m:0,d=d>=0?d:0,f=f>=0?f:0,p=p>=0?p:0;const g=s-(m+d),b=l-(p+f);return _=r?0!==d&&0!==f&&0!==m&&0!==p:0!==d||0!==f||0!==m||0!==p,_&&this.crop(e,{x:m,y:f,w:g,h:b}),e}},CoverOptionsSchema=z.object({w:z.number(),h:z.number(),align:z.number().optional(),mode:z.nativeEnum(ResizeStrategy).optional()}),methods$a={cover(e,t){const{w:i,h:r,align:n=HorizontalAlign.CENTER|VerticalAlign.MIDDLE,mode:a}=CoverOptionsSchema.parse(t),o=7&n,s=n>>3;if((0===o||o&o-1)&&(0===s||s&s-1))throw new Error("only use one flag per alignment direction");const l=o>>1,u=s>>1,h=i/r>e.bitmap.width/e.bitmap.height?i/e.bitmap.width:r/e.bitmap.height;return e=methods$d.scale(e,{f:h,mode:a}),e=methods$b.crop(e,{x:(e.bitmap.width-i)/2*l,y:(e.bitmap.height-r)/2*u,w:i,h:r})}},DisplaceOptionsSchema=z.object({map:JimpClassSchema,offset:z.number()}),methods$9={displace(e,t){const{map:i,offset:r}=DisplaceOptionsSchema.parse(t),n=clone(e);return e.scan(((t,a,o)=>{let s=i.bitmap.data[o]/256*r;s=Math.round(s);const l=e.getPixelIndex(t+s,a);e.bitmap.data[l]=n.bitmap.data[o],e.bitmap.data[l+1]=n.bitmap.data[o+1],e.bitmap.data[l+2]=n.bitmap.data[o+2]})),e}},methods$8={dither(e){const t=[1,9,3,11,13,5,15,7,4,12,2,10,16,8,14,6];return e.scan(((i,r,n)=>{const a=t[((3&r)<<2)+i%4];e.bitmap.data[n]=Math.min(e.bitmap.data[n]+a,255),e.bitmap.data[n+1]=Math.min(e.bitmap.data[n+1]+a,255),e.bitmap.data[n+2]=Math.min(e.bitmap.data[n+2]+a,255)})),e}},FisheyeOptionsSchema=z.object({radius:z.number().min(0).optional()}),methods$7={fisheye(e,t={}){const{radius:i=2.5}=FisheyeOptionsSchema.parse(t),r=clone(e),{width:n,height:a}=r.bitmap;return r.scan(((t,o)=>{const s=t/n,l=o/a,u=Math.sqrt(Math.pow(s-.5,2)+Math.pow(l-.5,2)),h=2*Math.pow(u,i),c=(s-.5)/u,f=(l-.5)/u,d=Math.round((h*c+.5)*n),p=Math.round((h*f+.5)*a),m=r.getPixelColor(d,p);e.setPixelColor(m,t,o)})),e.setPixelColor(r.getPixelColor(n/2,a/2),n/2,a/2),e}},FlipOptionsSchema=z.object({horizontal:z.boolean().optional(),vertical:z.boolean().optional()}),methods$6={flip(e,t){const{horizontal:i,vertical:r}=FlipOptionsSchema.parse(t),n=Buffer.alloc(e.bitmap.data.length);return e.scan(((t,a,o)=>{const s=i?e.bitmap.width-1-t:t,l=r?e.bitmap.height-1-a:a,u=e.bitmap.width*l+s<<2,h=e.bitmap.data.readUInt32BE(o);n.writeUInt32BE(h,u)})),e.bitmap.data=Buffer.from(n),e}};function Converter$1(e,t){if(!(e&&t&&e.length&&t.length))throw new Error("Bad alphabet");this.srcAlphabet=e,this.dstAlphabet=t}Converter$1.prototype.convert=function(e){var t,i,r,n={},a=this.srcAlphabet.length,o=this.dstAlphabet.length,s=e.length,l="string"==typeof e?"":[];if(!this.isValid(e))throw new Error('Number "'+e+'" contains of non-alphabetic digits ('+this.srcAlphabet+")");if(this.srcAlphabet===this.dstAlphabet)return e;for(t=0;t<s;t++)n[t]=this.srcAlphabet.indexOf(e[t]);do{for(i=0,r=0,t=0;t<s;t++)(i=i*a+n[t])>=o?(n[r++]=parseInt(i/o,10),i%=o):r>0&&(n[r++]=0);s=r,l=this.dstAlphabet.slice(i,i+1).concat(l)}while(0!==r);return l},Converter$1.prototype.isValid=function(e){for(var t=0;t<e.length;++t)if(-1===this.srcAlphabet.indexOf(e[t]))return!1;return!0};var converter=Converter$1,Converter=converter;function anyBase(e,t){var i=new Converter(e,t);return function(e){return i.convert(e)}}anyBase.BIN="01",anyBase.OCT="01234567",anyBase.DEC="0123456789",anyBase.HEX="0123456789abcdef";var anyBase_1=anyBase,anyBase$1=getDefaultExportFromCjs(anyBase_1),__defProp$1=Object.defineProperty,__defNormalProp$1=(e,t,i)=>t in e?__defProp$1(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,__publicField$1=(e,t,i)=>__defNormalProp$1(e,"symbol"!=typeof t?t+"":t,i);class ImagePHash{constructor(e,t){__publicField$1(this,"size"),__publicField$1(this,"smallerSize"),this.size=e||32,this.smallerSize=t||8,initCoefficients(this.size)}distance(e,t){let i=0;for(let r=0;r<e.length;r++)e[r]!==t[r]&&i++;return i/e.length}getHash(e){e=methods$d.resize(clone(e),{w:this.size,h:this.size}),e=methods$e.greyscale(e);const t=[];for(let i=0;i<e.bitmap.width;i++){const r=[];for(let t=0;t<e.bitmap.height;t++)r[t]=intToRGBA(e.getPixelColor(i,t)).b;t[i]=r}const i=applyDCT(t,this.size);let r=0;for(let e=0;e<this.smallerSize;e++)for(let t=0;t<this.smallerSize;t++)r+=i[e][t];const n=r/(this.smallerSize*this.smallerSize);let a="";for(let e=0;e<this.smallerSize;e++)for(let t=0;t<this.smallerSize;t++)a+=i[e][t]>n?"1":"0";return a}}function intToRGBA(e){const t=255&e,i=255&(e>>>=8),r=255&(e>>>=8);return{r:255&(e>>>=8),g:r,b:i,a:t}}const c$1=[];function initCoefficients(e){for(let t=1;t<e;t++)c$1[t]=1;c$1[0]=1/Math.sqrt(2)}function applyDCT(e,t){const i=t,r=[];for(let t=0;t<i;t++){const n=[];for(let a=0;a<i;a++){let o=0;for(let r=0;r<i;r++)for(let n=0;n<i;n++)o+=Math.cos((2*r+1)/(2*i)*t*Math.PI)*Math.cos((2*n+1)/(2*i)*a*Math.PI)*e[r][n];o*=c$1[t]*c$1[a]/4,n[a]=o,r[t]=n}}return r}const alphabet="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",maxHashLength=[NaN,NaN];for(let e=2;e<65;e++){const t=anyBase$1(anyBase$1.BIN,alphabet.slice(0,e))(new Array(65).join("1"));maxHashLength.push(t.length)}const methods$5={pHash:e=>(new ImagePHash).getHash(e),hash(e,t=64){if(t<2||t>64)throw new Error("base must be a number between 2 and 64");const i=alphabet.slice(0,t),r=this.pHash(e),n=maxHashLength[t];return anyBase$1(anyBase$1.BIN,i)(r).padStart(n,"0")},distanceFromHash(e,t){const i=new ImagePHash,r=i.getHash(e);return i.distance(r,t)}};function distance(e,t){const i=new ImagePHash,r=i.getHash(e),n=i.getHash(t);return i.distance(r,n)}function compareHashes(e,t){return(new ImagePHash).distance(e,t)}const MaskOptionsObjectSchema=z.object({src:JimpClassSchema,x:z.number().optional(),y:z.number().optional()}),MaskOptionsSchema=z.union([JimpClassSchema,MaskOptionsObjectSchema]),methods$4={mask(e,t){let i,r,n;MaskOptionsSchema.parse(t),"bitmap"in t?(i=t,r=0,n=0):(i=t.src,r=t.x??0,n=t.y??0),r=Math.round(r),n=Math.round(n);const a=e.bitmap.width,o=e.bitmap.height;return i.scan((function(t,s,l){const u=r+t,h=n+s;if(u>=0&&h>=0&&u<a&&h<o){const t=e.getPixelIndex(u,h),{data:r}=i.bitmap,n=(r[l+0]+r[l+1]+r[l+2])/3;e.bitmap.data[t+3]*=n/255}})),e}};function measureText(e,t){let i=0;for(let r=0;r<t.length;r++){const n=t[r],a=e.chars[n];if(a){const o=e.kernings[n],s=t[r+1],l=o&&s&&o[s]&&o[s]||0;i+=(a.xadvance||0)+l}}return i}function splitLines(e,t,i){const r=t.replace(/[\r\n]+/g," \n").split(" "),n=[];let a=[],o=0;return r.forEach((t=>{if(measureText(e,t+(r.length>1?" ":""))>i){const r=t[Symbol.iterator]();let o="";for(const t of r){const r=[...a,o+t].join(" "),s=measureText(e,r);s<i?o+=t:s>i?(n.push([...a,o]),a=[],o=t):(n.push([...a,o+t]),a=[],o="")}return}const s=[...a,t].join(" "),l=measureText(e,s);l<=i&&!t.includes("\n")?(l>o&&(o=l),a.push(t)):(n.push(a),a=[t.replace("\n","")])})),n.push(a),{lines:n,longestLine:o}}function measureTextHeight(e,t,i){const{lines:r}=splitLines(e,t,i);return r.length*e.common.lineHeight}const PrintOptionsSchema=z.object({x:z.number(),y:z.number(),text:z.union([z.union([z.string(),z.number()]),z.object({text:z.union([z.string(),z.number()]),alignmentX:z.nativeEnum(HorizontalAlign).optional(),alignmentY:z.nativeEnum(VerticalAlign).optional()})]),maxWidth:z.number().optional(),maxHeight:z.number().optional(),cb:z.function(z.tuple([z.object({x:z.number(),y:z.number()})])).optional()});function xOffsetBasedOnAlignment(e,t,i,r){return r===HorizontalAlign.LEFT?0:r===HorizontalAlign.CENTER?(i-measureText(e,t))/2:i-measureText(e,t)}function drawCharacter(e,t,i,r,n){if(n.width>0&&n.height>0){const a=t.pages[n.page];a&&(e=methods$h.blit(e,{src:a,x:i+n.xoffset,y:r+n.yoffset,srcX:n.x,srcY:n.y,srcW:n.width,srcH:n.height}))}return e}function printText(e,t,i,r,n,a){for(let o=0;o<n.length;o++){const s=n[o];let l;l=t.chars[s]?s:/\s/.test(s)?"":"?";const u=t.chars[l]||{xadvance:void 0},h=t.kernings[l];u&&drawCharacter(e,t,i,r,u);const c=n[o+1];i+=(h&&c&&h[c]&&h[c]||0)+(u.xadvance||a)}}const methods$3={print(e,{font:t,...i}){let r,n,{x:a,y:o,text:s,maxWidth:l=1/0,maxHeight:u=1/0,cb:h=(()=>{})}=PrintOptionsSchema.parse(i);"object"==typeof s&&null!==s.text&&void 0!==s.text?(r=s.alignmentX||HorizontalAlign.LEFT,n=s.alignmentY||VerticalAlign.TOP,({text:s}=s)):(r=HorizontalAlign.LEFT,n=VerticalAlign.TOP,s=s.toString()),"number"==typeof s&&(s=s.toString()),u!==1/0&&n===VerticalAlign.BOTTOM?o+=u-measureTextHeight(t,s,l):u!==1/0&&n===VerticalAlign.MIDDLE&&(o+=u/2-measureTextHeight(t,s,l)/2);const c=Object.entries(t.chars).find((e=>e[1].xadvance))?.[1].xadvance;if("number"!=typeof c)throw new Error("Could not find default character width");const{lines:f,longestLine:d}=splitLines(t,s,l);return f.forEach((i=>{const n=i.join(" "),s=xOffsetBasedOnAlignment(t,n,l,r);printText(e,t,a+s,o,n,c),o+=t.common.lineHeight})),h.bind(e)({x:a+d,y:o}),e}},RotateOptionsSchema=z.union([z.number(),z.object({deg:z.number(),mode:z.union([z.boolean(),z.nativeEnum(ResizeStrategy)]).optional()})]);function createIdxTranslationFunction(e){return function(t,i){return i*e+t<<2}}function matrixRotate(e,t){if(Math.abs(t)%90!=0)throw new Error("Unsupported matrix rotation degree");const i=e.bitmap.width,r=e.bitmap.height;let n;switch(t){case 90:case-270:n=90;break;case 180:case-180:n=180;break;case 270:case-90:n=-90;break;default:throw new Error("Unsupported matrix rotation degree")}const a=180===n?i:r,o=180===n?r:i,s=Buffer.alloc(e.bitmap.data.length),l=createIdxTranslationFunction(i),u=createIdxTranslationFunction(a);for(let t=0;t<i;t++)for(let a=0;a<r;a++){const o=l(t,a),h=e.bitmap.data.readUInt32BE(o);let c;switch(n){case 90:c=u(a,i-t-1);break;case-90:c=u(r-a-1,t);break;case 180:c=u(i-t-1,r-a-1);break;default:throw new Error("Unsupported matrix rotation angle")}s.writeUInt32BE(h,c)}e.bitmap.data=s,e.bitmap.width=a,e.bitmap.height=o}function createTranslationFunction(e,t){return function(i,r){return{x:i+e,y:r+t}}}function advancedRotate(e,t,i){const r=t*Math.PI/180,n=Math.cos(r),a=Math.sin(r);let o=e.bitmap.width,s=e.bitmap.height;if(!0===i||"string"==typeof i){o=Math.ceil(Math.abs(e.bitmap.width*n)+Math.abs(e.bitmap.height*a))+1,s=Math.ceil(Math.abs(e.bitmap.width*a)+Math.abs(e.bitmap.height*n))+1,o%2!=0&&o++,s%2!=0&&s++;const t=clone(e);e.scan(((t,i,r)=>{e.bitmap.data.writeUInt32BE(e.background,r)}));const r=Math.max(o,s,e.bitmap.width,e.bitmap.height);e=composite(e=methods$d.resize(e,{h:r,w:r,mode:!0===i?void 0:i}),t,e.bitmap.width/2-t.bitmap.width/2,e.bitmap.height/2-t.bitmap.height/2)}const l=e.bitmap.width,u=e.bitmap.height,h=Buffer.alloc(e.bitmap.data.length),c=createTranslationFunction(-l/2,-u/2),f=createTranslationFunction(l/2+.5,u/2+.5);for(let t=1;t<=u;t++)for(let i=1;i<=l;i++){const r=c(i,t),o=f(n*r.x-a*r.y,n*r.y+a*r.x),s=l*(t-1)+i-1<<2;if(o.x>=0&&o.x<l&&o.y>=0&&o.y<u){const t=l*(0|o.y)+o.x<<2,i=e.bitmap.data.readUInt32BE(t);h.writeUInt32BE(i,s)}else h.writeUInt32BE(e.background,s)}if(e.bitmap.data=h,!0===i||"string"==typeof i){const t=Math.max(l/2-o/2,0),i=Math.max(u/2-s/2,0);e=methods$b.crop(e,{x:t,y:i,w:o,h:s})}}const methods$2={rotate(e,t){const i=RotateOptionsSchema.parse(t),r="number"==typeof i?{deg:i}:i,{mode:n=!0}=r;let{deg:a}=r;if(a%=360,a%360==0)return e;return a%90==0&&(n||e.bitmap.width===e.bitmap.height||a%180==0)?matrixRotate(e,a):advancedRotate(e,a,n),e}},ThresholdOptionsSchema=z.object({max:z.number().min(0).max(255),replace:z.number().min(0).max(255).optional(),autoGreyscale:z.boolean().optional()}),methods$1={threshold(e,t){let{max:i,replace:r=255,autoGreyscale:n=!0}=ThresholdOptionsSchema.parse(t);return i=limit255(i),r=limit255(r),n&&methods$e.greyscale(e),e.scan(((t,n,a)=>{const o=e.bitmap.data[a]<i?e.bitmap.data[a]:r;e.bitmap.data[a]=o,e.bitmap.data[a+1]=o,e.bitmap.data[a+2]=o})),e}};var __defProp=Object.defineProperty,__defNormalProp=(e,t,i)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,__export=(e,t)=>{for(var i in t)__defProp(e,i,{get:t[i],enumerable:!0})},__publicField=(e,t,i)=>(__defNormalProp(e,"symbol"!=typeof t?t+"":t,i),i),constants_exports={};__export(constants_exports,{bt709:()=>bt709_exports});var bt709_exports={};__export(bt709_exports,{Y:()=>Y,x:()=>x$1,y:()=>y$1});var Y=(e=>(e[e.RED=.2126]="RED",e[e.GREEN=.7152]="GREEN",e[e.BLUE=.0722]="BLUE",e[e.WHITE=1]="WHITE",e))(Y||{}),x$1=(e=>(e[e.RED=.64]="RED",e[e.GREEN=.3]="GREEN",e[e.BLUE=.15]="BLUE",e[e.WHITE=.3127]="WHITE",e))(x$1||{}),y$1=(e=>(e[e.RED=.33]="RED",e[e.GREEN=.6]="GREEN",e[e.BLUE=.06]="BLUE",e[e.WHITE=.329]="WHITE",e))(y$1||{}),conversion_exports={};function correctGamma(e){return e>.04045?((e+.055)/1.055)**2.4:e/12.92}function rgb2xyz(e,t,i){return{x:.4124*(e=correctGamma(e/255))+.3576*(t=correctGamma(t/255))+.1805*(i=correctGamma(i/255)),y:.2126*e+.7152*t+.0722*i,z:.0193*e+.1192*t+.9505*i}}__export(conversion_exports,{lab2rgb:()=>lab2rgb,lab2xyz:()=>lab2xyz,rgb2hsl:()=>rgb2hsl,rgb2lab:()=>rgb2lab,rgb2xyz:()=>rgb2xyz,xyz2lab:()=>xyz2lab,xyz2rgb:()=>xyz2rgb});var arithmetic_exports={};function degrees2radians(e){return e*(Math.PI/180)}function max3(e,t,i){let r=e;return r<t&&(r=t),r<i&&(r=i),r}function min3(e,t,i){let r=e;return r>t&&(r=t),r>i&&(r=i),r}function intInRange(e,t,i){return e>i&&(e=i),e<t&&(e=t),0|e}function inRange0to255Rounded(e){return(e=Math.round(e))>255?e=255:e<0&&(e=0),e}function inRange0to255(e){return e>255?e=255:e<0&&(e=0),e}function stableSort(e,t){const i=typeof e[0];let r;if("number"===i||"string"===i){const i=Object.create(null);for(let t=0,r=e.length;t<r;t++){const r=e[t];i[r]||0===i[r]||(i[r]=t)}r=e.sort(((e,r)=>t(e,r)||i[e]-i[r]))}else{const i=e.slice(0);r=e.sort(((e,r)=>t(e,r)||i.indexOf(e)-i.indexOf(r)))}return r}function rgb2hsl(e,t,i){const r=min3(e,t,i),n=max3(e,t,i),a=n-r,o=(r+n)/510;let s=0;o>0&&o<1&&(s=a/(o<.5?n+r:510-n-r));let l=0;return a>0&&(l=n===e?(t-i)/a:n===t?2+(i-e)/a:4+(e-t)/a,l*=60,l<0&&(l+=360)),{h:l,s:s,l:o}}__export(arithmetic_exports,{degrees2radians:()=>degrees2radians,inRange0to255:()=>inRange0to255,inRange0to255Rounded:()=>inRange0to255Rounded,intInRange:()=>intInRange,max3:()=>max3,min3:()=>min3,stableSort:()=>stableSort});var refX=.95047,refY=1,refZ=1.08883;function pivot(e){return e>.008856?e**(1/3):7.787*e+16/116}function xyz2lab(e,t,i){if(e=pivot(e/refX),t=pivot(t/refY),i=pivot(i/refZ),116*t-16<0)throw new Error("xxx");return{L:Math.max(0,116*t-16),a:500*(e-t),b:200*(t-i)}}function rgb2lab(e,t,i){const r=rgb2xyz(e,t,i);return xyz2lab(r.x,r.y,r.z)}var refX2=.95047,refY2=1,refZ2=1.08883;function pivot2(e){return e>.206893034?e**3:(e-16/116)/7.787}function lab2xyz(e,t,i){const r=(e+16)/116,n=r-i/200;return{x:refX2*pivot2(t/500+r),y:refY2*pivot2(r),z:refZ2*pivot2(n)}}function correctGamma2(e){return e>.0031308?1.055*e**(1/2.4)-.055:12.92*e}function xyz2rgb(e,t,i){const r=correctGamma2(3.2406*e+-1.5372*t+-.4986*i),n=correctGamma2(-.9689*e+1.8758*t+.0415*i),a=correctGamma2(.0557*e+-.204*t+1.057*i);return{r:inRange0to255Rounded(255*r),g:inRange0to255Rounded(255*n),b:inRange0to255Rounded(255*a)}}function lab2rgb(e,t,i){const r=lab2xyz(e,t,i);return xyz2rgb(r.x,r.y,r.z)}var distance_exports={};__export(distance_exports,{AbstractDistanceCalculator:()=>AbstractDistanceCalculator,AbstractEuclidean:()=>AbstractEuclidean,AbstractManhattan:()=>AbstractManhattan,CIE94GraphicArts:()=>CIE94GraphicArts,CIE94Textiles:()=>CIE94Textiles,CIEDE2000:()=>CIEDE2000,CMetric:()=>CMetric,Euclidean:()=>Euclidean,EuclideanBT709:()=>EuclideanBT709,EuclideanBT709NoAlpha:()=>EuclideanBT709NoAlpha,Manhattan:()=>Manhattan,ManhattanBT709:()=>ManhattanBT709,ManhattanNommyde:()=>ManhattanNommyde,PNGQuant:()=>PNGQuant});var AbstractDistanceCalculator=class{constructor(){__publicField(this,"_maxDistance"),__publicField(this,"_whitePoint"),this._setDefaults(),this.setWhitePoint(255,255,255,255)}setWhitePoint(e,t,i,r){this._whitePoint={r:e>0?255/e:0,g:t>0?255/t:0,b:i>0?255/i:0,a:r>0?255/r:0},this._maxDistance=this.calculateRaw(e,t,i,r,0,0,0,0)}calculateNormalized(e,t){return this.calculateRaw(e.r,e.g,e.b,e.a,t.r,t.g,t.b,t.a)/this._maxDistance}},AbstractCIE94=class extends AbstractDistanceCalculator{calculateRaw(e,t,i,r,n,a,o,s){const l=rgb2lab(inRange0to255(e*this._whitePoint.r),inRange0to255(t*this._whitePoint.g),inRange0to255(i*this._whitePoint.b)),u=rgb2lab(inRange0to255(n*this._whitePoint.r),inRange0to255(a*this._whitePoint.g),inRange0to255(o*this._whitePoint.b)),h=l.L-u.L,c=l.a-u.a,f=l.b-u.b,d=Math.sqrt(l.a*l.a+l.b*l.b),p=d-Math.sqrt(u.a*u.a+u.b*u.b);let m=c*c+f*f-p*p;m=m<0?0:Math.sqrt(m);const _=(s-r)*this._whitePoint.a*this._kA;return Math.sqrt((h/this._Kl)**2+(p/(1+this._K1*d))**2+(m/(1+this._K2*d))**2+_**2)}},CIE94Textiles=class extends AbstractCIE94{_setDefaults(){this._Kl=2,this._K1=.048,this._K2=.014,this._kA=12.5/255}},CIE94GraphicArts=class extends AbstractCIE94{_setDefaults(){this._Kl=1,this._K1=.045,this._K2=.015,this._kA=25/255}},_CIEDE2000=class extends AbstractDistanceCalculator{_setDefaults(){}static _calculatehp(e,t){const i=Math.atan2(e,t);return i>=0?i:i+_CIEDE2000._deg360InRad}static _calculateRT(e,t){const i=t**7,r=2*Math.sqrt(i/(i+_CIEDE2000._pow25to7)),n=_CIEDE2000._deg30InRad*Math.exp(-(((e-_CIEDE2000._deg275InRad)/_CIEDE2000._deg25InRad)**2));return-Math.sin(2*n)*r}static _calculateT(e){return 1-.17*Math.cos(e-_CIEDE2000._deg30InRad)+.24*Math.cos(2*e)+.32*Math.cos(3*e+_CIEDE2000._deg6InRad)-.2*Math.cos(4*e-_CIEDE2000._deg63InRad)}static _calculate_ahp(e,t,i,r){const n=i+r;return 0===e?n:t<=_CIEDE2000._deg180InRad?n/2:n<_CIEDE2000._deg360InRad?(n+_CIEDE2000._deg360InRad)/2:(n-_CIEDE2000._deg360InRad)/2}static _calculate_dHp(e,t,i,r){let n;return n=0===e?0:t<=_CIEDE2000._deg180InRad?i-r:i<=r?i-r+_CIEDE2000._deg360InRad:i-r-_CIEDE2000._deg360InRad,2*Math.sqrt(e)*Math.sin(n/2)}calculateRaw(e,t,i,r,n,a,o,s){const l=rgb2lab(inRange0to255(e*this._whitePoint.r),inRange0to255(t*this._whitePoint.g),inRange0to255(i*this._whitePoint.b)),u=rgb2lab(inRange0to255(n*this._whitePoint.r),inRange0to255(a*this._whitePoint.g),inRange0to255(o*this._whitePoint.b)),h=(s-r)*this._whitePoint.a*_CIEDE2000._kA,c=this.calculateRawInLab(l,u);return Math.sqrt(c+h*h)}calculateRawInLab(e,t){const i=e.L,r=e.a,n=e.b,a=t.L,o=t.a,s=t.b,l=((Math.sqrt(r*r+n*n)+Math.sqrt(o*o+s*s))/2)**7,u=.5*(1-Math.sqrt(l/(l+_CIEDE2000._pow25to7))),h=(1+u)*r,c=(1+u)*o,f=Math.sqrt(h*h+n*n),d=Math.sqrt(c*c+s*s),p=f*d,m=_CIEDE2000._calculatehp(n,h),_=_CIEDE2000._calculatehp(s,c),g=Math.abs(m-_),b=a-i,y=d-f,w=_CIEDE2000._calculate_dHp(p,g,_,m),v=_CIEDE2000._calculate_ahp(p,g,m,_),x=(f+d)/2,E=((i+a)/2-50)**2,k=y/(1+.045*x),S=w/(1+.015*_CIEDE2000._calculateT(v)*x);return(b/(1+.015*E/Math.sqrt(20+E)))**2+k**2+S**2+_CIEDE2000._calculateRT(v,x)*k*S}},CIEDE2000=_CIEDE2000;__publicField(CIEDE2000,"_kA",25/255),__publicField(CIEDE2000,"_pow25to7",25**7),__publicField(CIEDE2000,"_deg360InRad",degrees2radians(360)),__publicField(CIEDE2000,"_deg180InRad",degrees2radians(180)),__publicField(CIEDE2000,"_deg30InRad",degrees2radians(30)),__publicField(CIEDE2000,"_deg6InRad",degrees2radians(6)),__publicField(CIEDE2000,"_deg63InRad",degrees2radians(63)),__publicField(CIEDE2000,"_deg275InRad",degrees2radians(275)),__publicField(CIEDE2000,"_deg25InRad",degrees2radians(25));var CMetric=class extends AbstractDistanceCalculator{calculateRaw(e,t,i,r,n,a,o,s){const l=(e+n)/2*this._whitePoint.r,u=(e-n)*this._whitePoint.r,h=(t-a)*this._whitePoint.g,c=(i-o)*this._whitePoint.b,f=((512+l)*u*u>>8)+4*h*h+((767-l)*c*c>>8),d=(s-r)*this._whitePoint.a;return Math.sqrt(f+d*d)}_setDefaults(){}},AbstractEuclidean=class extends AbstractDistanceCalculator{calculateRaw(e,t,i,r,n,a,o,s){const l=n-e,u=a-t,h=o-i,c=s-r;return Math.sqrt(this._kR*l*l+this._kG*u*u+this._kB*h*h+this._kA*c*c)}},Euclidean=class extends AbstractEuclidean{_setDefaults(){this._kR=1,this._kG=1,this._kB=1,this._kA=1}},EuclideanBT709=class extends AbstractEuclidean{_setDefaults(){this._kR=.2126,this._kG=.7152,this._kB=.0722,this._kA=1}},EuclideanBT709NoAlpha=class extends AbstractEuclidean{_setDefaults(){this._kR=.2126,this._kG=.7152,this._kB=.0722,this._kA=0}},AbstractManhattan=class extends AbstractDistanceCalculator{calculateRaw(e,t,i,r,n,a,o,s){let l=n-e,u=a-t,h=o-i,c=s-r;return l<0&&(l=0-l),u<0&&(u=0-u),h<0&&(h=0-h),c<0&&(c=0-c),this._kR*l+this._kG*u+this._kB*h+this._kA*c}},Manhattan=class extends AbstractManhattan{_setDefaults(){this._kR=1,this._kG=1,this._kB=1,this._kA=1}},ManhattanNommyde=class extends AbstractManhattan{_setDefaults(){this._kR=.4984,this._kG=.8625,this._kB=.2979,this._kA=1}},ManhattanBT709=class extends AbstractManhattan{_setDefaults(){this._kR=.2126,this._kG=.7152,this._kB=.0722,this._kA=1}},PNGQuant=class extends AbstractDistanceCalculator{calculateRaw(e,t,i,r,n,a,o,s){const l=(s-r)*this._whitePoint.a;return this._colordifferenceCh(e*this._whitePoint.r,n*this._whitePoint.r,l)+this._colordifferenceCh(t*this._whitePoint.g,a*this._whitePoint.g,l)+this._colordifferenceCh(i*this._whitePoint.b,o*this._whitePoint.b,l)}_colordifferenceCh(e,t,i){const r=e-t,n=r+i;return r*r+n*n}_setDefaults(){}},palette_exports={};__export(palette_exports,{AbstractPaletteQuantizer:()=>AbstractPaletteQuantizer,ColorHistogram:()=>ColorHistogram,NeuQuant:()=>NeuQuant,NeuQuantFloat:()=>NeuQuantFloat,RGBQuant:()=>RGBQuant,WuColorCube:()=>WuColorCube,WuQuant:()=>WuQuant});var AbstractPaletteQuantizer=class{quantizeSync(){for(const e of this.quantize())if(e.palette)return e.palette;throw new Error("unreachable")}},Point=class{constructor(){__publicField(this,"r"),__publicField(this,"g"),__publicField(this,"b"),__publicField(this,"a"),__publicField(this,"uint32"),__publicField(this,"rgba"),this.uint32=-1>>>0,this.r=this.g=this.b=this.a=0,this.rgba=new Array(4),this.rgba[0]=0,this.rgba[1]=0,this.rgba[2]=0,this.rgba[3]=0}static createByQuadruplet(e){const t=new Point;return t.r=0|e[0],t.g=0|e[1],t.b=0|e[2],t.a=0|e[3],t._loadUINT32(),t._loadQuadruplet(),t}static createByRGBA(e,t,i,r){const n=new Point;return n.r=0|e,n.g=0|t,n.b=0|i,n.a=0|r,n._loadUINT32(),n._loadQuadruplet(),n}static createByUint32(e){const t=new Point;return t.uint32=e>>>0,t._loadRGBA(),t._loadQuadruplet(),t}from(e){this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a,this.uint32=e.uint32,this.rgba[0]=e.r,this.rgba[1]=e.g,this.rgba[2]=e.b,this.rgba[3]=e.a}getLuminosity(e){let t=this.r,i=this.g,r=this.b;return e&&(t=Math.min(255,255-this.a+this.a*t/255),i=Math.min(255,255-this.a+this.a*i/255),r=Math.min(255,255-this.a+this.a*r/255)),.2126*t+.7152*i+.0722*r}_loadUINT32(){this.uint32=(this.a<<24|this.b<<16|this.g<<8|this.r)>>>0}_loadRGBA(){this.r=255&this.uint32,this.g=this.uint32>>>8&255,this.b=this.uint32>>>16&255,this.a=this.uint32>>>24&255}_loadQuadruplet(){this.rgba[0]=this.r,this.rgba[1]=this.g,this.rgba[2]=this.b,this.rgba[3]=this.a}},PointContainer=class{constructor(){__publicField(this,"_pointArray"),__publicField(this,"_width"),__publicField(this,"_height"),this._width=0,this._height=0,this._pointArray=[]}getWidth(){return this._width}getHeight(){return this._height}setWidth(e){this._width=e}setHeight(e){this._height=e}getPointArray(){return this._pointArray}clone(){const e=new PointContainer;e._width=this._width,e._height=this._height;for(let t=0,i=this._pointArray.length;t<i;t++)e._pointArray[t]=Point.createByUint32(0|this._pointArray[t].uint32);return e}toUint32Array(){const e=this._pointArray.length,t=new Uint32Array(e);for(let i=0;i<e;i++)t[i]=this._pointArray[i].uint32;return t}toUint8Array(){return new Uint8Array(this.toUint32Array().buffer)}static fromHTMLImageElement(e){const t=e.naturalWidth,i=e.naturalHeight,r=document.createElement("canvas");r.width=t,r.height=i;return r.getContext("2d").drawImage(e,0,0,t,i,0,0,t,i),PointContainer.fromHTMLCanvasElement(r)}static fromHTMLCanvasElement(e){const t=e.width,i=e.height,r=e.getContext("2d").getImageData(0,0,t,i);return PointContainer.fromImageData(r)}static fromImageData(e){const t=e.width,i=e.height;return PointContainer.fromUint8Array(e.data,t,i)}static fromUint8Array(e,t,i){switch(Object.prototype.toString.call(e)){case"[object Uint8ClampedArray]":case"[object Uint8Array]":break;default:e=new Uint8Array(e)}const r=new Uint32Array(e.buffer);return PointContainer.fromUint32Array(r,t,i)}static fromUint32Array(e,t,i){const r=new PointContainer;r._width=t,r._height=i;for(let t=0,i=e.length;t<i;t++)r._pointArray[t]=Point.createByUint32(0|e[t]);return r}static fromBuffer(e,t,i){const r=new Uint32Array(e.buffer,e.byteOffset,e.byteLength/Uint32Array.BYTES_PER_ELEMENT);return PointContainer.fromUint32Array(r,t,i)}},hueGroups=10;function hueGroup(e,t){const i=360/t;for(let r=1,n=i-i/2;r<t;r++,n+=i)if(e>=n&&e<n+i)return r;return 0}var Palette=class{constructor(){__publicField(this,"_pointContainer"),__publicField(this,"_pointArray",[]),__publicField(this,"_i32idx",{}),this._pointContainer=new PointContainer,this._pointContainer.setHeight(1),this._pointArray=this._pointContainer.getPointArray()}add(e){this._pointArray.push(e),this._pointContainer.setWidth(this._pointArray.length)}has(e){for(let t=this._pointArray.length-1;t>=0;t--)if(e.uint32===this._pointArray[t].uint32)return!0;return!1}getNearestColor(e,t){return this._pointArray[0|this._getNearestIndex(e,t)]}getPointContainer(){return this._pointContainer}_nearestPointFromCache(e){return"number"==typeof this._i32idx[e]?this._i32idx[e]:-1}_getNearestIndex(e,t){let i=this._nearestPointFromCache(""+t.uint32);if(i>=0)return i;let r=Number.MAX_VALUE;i=0;for(let n=0,a=this._pointArray.length;n<a;n++){const a=this._pointArray[n],o=e.calculateRaw(t.r,t.g,t.b,t.a,a.r,a.g,a.b,a.a);o<r&&(r=o,i=n)}return this._i32idx[t.uint32]=i,i}sort(){this._i32idx={},this._pointArray.sort(((e,t)=>{const i=rgb2hsl(e.r,e.g,e.b),r=rgb2hsl(t.r,t.g,t.b),n=e.r===e.g&&e.g===e.b?0:1+hueGroup(i.h,hueGroups),a=(t.r===t.g&&t.g===t.b?0:1+hueGroup(r.h,hueGroups))-n;if(a)return-a;const o=e.getLuminosity(!0),s=t.getLuminosity(!0);if(s-o!=0)return s-o;const l=(100*r.s|0)-(100*i.s|0);return l?-l:0}))}},utils_exports={};__export(utils_exports,{HueStatistics:()=>HueStatistics,Palette:()=>Palette,Point:()=>Point,PointContainer:()=>PointContainer,ProgressTracker:()=>ProgressTracker,arithmetic:()=>arithmetic_exports});var HueGroup=class{constructor(){__publicField(this,"num",0),__publicField(this,"cols",[])}},HueStatistics=class{constructor(e,t){__publicField(this,"_numGroups"),__publicField(this,"_minCols"),__publicField(this,"_stats"),__publicField(this,"_groupsFull"),this._numGroups=e,this._minCols=t,this._stats=[];for(let t=0;t<=e;t++)this._stats[t]=new HueGroup;this._groupsFull=0}check(e){this._groupsFull===this._numGroups+1&&(this.check=()=>{});const t=255&e,i=e>>>8&255,r=e>>>16&255,n=t===i&&i===r?0:1+hueGroup(rgb2hsl(t,i,r).h,this._numGroups),a=this._stats[n],o=this._minCols;a.num++,a.num>o||(a.num===o&&this._groupsFull++,a.num<=o&&this._stats[n].cols.push(e))}injectIntoDictionary(e){for(let t=0;t<=this._numGroups;t++)this._stats[t].num<=this._minCols&&this._stats[t].cols.forEach((t=>{e[t]?e[t]++:e[t]=1}))}injectIntoArray(e){for(let t=0;t<=this._numGroups;t++)this._stats[t].num<=this._minCols&&this._stats[t].cols.forEach((t=>{-1===e.indexOf(t)&&e.push(t)}))}},_ProgressTracker=class{constructor(e,t){__publicField(this,"progress"),__publicField(this,"_step"),__publicField(this,"_range"),__publicField(this,"_last"),__publicField(this,"_progressRange"),this._range=e,this._progressRange=t,this._step=Math.max(1,this._range/(_ProgressTracker.steps+1)|0),this._last=-this._step,this.progress=0}shouldNotify(e){return e-this._last>=this._step&&(this._last=e,this.progress=Math.min(this._progressRange*this._last/this._range,this._progressRange),!0)}},ProgressTracker=_ProgressTracker;__publicField(ProgressTracker,"steps",100);var networkBiasShift=3,Neuron=class{constructor(e){__publicField(this,"r"),__publicField(this,"g"),__publicField(this,"b"),__publicField(this,"a"),this.r=this.g=this.b=this.a=e}toPoint(){return Point.createByRGBA(this.r>>networkBiasShift,this.g>>networkBiasShift,this.b>>networkBiasShift,this.a>>networkBiasShift)}subtract(e,t,i,r){this.r-=0|e,this.g-=0|t,this.b-=0|i,this.a-=0|r}},_NeuQuant=class extends AbstractPaletteQuantizer{constructor(e,t=256){super(),__publicField(this,"_pointArray"),__publicField(this,"_networkSize"),__publicField(this,"_network"),__publicField(this,"_sampleFactor"),__publicField(this,"_radPower"),__publicField(this,"_freq"),__publicField(this,"_bias"),__publicField(this,"_distance"),this._distance=e,this._pointArray=[],this._sampleFactor=1,this._networkSize=t,this._distance.setWhitePoint(255<<networkBiasShift,255<<networkBiasShift,255<<networkBiasShift,255<<networkBiasShift)}sample(e){this._pointArray=this._pointArray.concat(e.getPointArray())}*quantize(){this._init(),yield*this._learn(),yield{palette:this._buildPalette(),progress:100}}_init(){this._freq=[],this._bias=[],this._radPower=[],this._network=[];for(let e=0;e<this._networkSize;e++)this._network[e]=new Neuron((e<<networkBiasShift+8)/this._networkSize|0),this._freq[e]=_NeuQuant._initialBias/this._networkSize|0,this._bias[e]=0}*_learn(){let e=this._sampleFactor;const t=this._pointArray.length;t<_NeuQuant._minpicturebytes&&(e=1);const i=30+(e-1)/3|0,r=t/e|0;let n,a=r/_NeuQuant._nCycles|0,o=_NeuQuant._initAlpha,s=(this._networkSize>>3)*_NeuQuant._radiusBias,l=s>>_NeuQuant._radiusBiasShift;l<=1&&(l=0);for(let e=0;e<l;e++)this._radPower[e]=o*((l*l-e*e)*_NeuQuant._radBias/(l*l))>>>0;n=t<_NeuQuant._minpicturebytes?1:t%_NeuQuant._prime1!=0?_NeuQuant._prime1:t%_NeuQuant._prime2!=0?_NeuQuant._prime2:t%_NeuQuant._prime3!=0?_NeuQuant._prime3:_NeuQuant._prime4;const u=new ProgressTracker(r,99);for(let e=0,h=0;e<r;){u.shouldNotify(e)&&(yield{progress:u.progress});const r=this._pointArray[h],c=r.b<<networkBiasShift,f=r.g<<networkBiasShift,d=r.r<<networkBiasShift,p=r.a<<networkBiasShift,m=this._contest(c,f,d,p);if(this._alterSingle(o,m,c,f,d,p),0!==l&&this._alterNeighbour(l,m,c,f,d,p),h+=n,h>=t&&(h-=t),e++,0===a&&(a=1),e%a==0){o-=o/i|0,s-=s/_NeuQuant._radiusDecrease|0,l=s>>_NeuQuant._radiusBiasShift,l<=1&&(l=0);for(let e=0;e<l;e++)this._radPower[e]=o*((l*l-e*e)*_NeuQuant._radBias/(l*l))>>>0}}}_buildPalette(){const e=new Palette;return this._network.forEach((t=>{e.add(t.toPoint())})),e.sort(),e}_alterNeighbour(e,t,i,r,n,a){let o=t-e;o<-1&&(o=-1);let s=t+e;s>this._networkSize&&(s=this._networkSize);let l=t+1,u=t-1,h=1;for(;l<s||u>o;){const e=this._radPower[h++]/_NeuQuant._alphaRadBias;if(l<s){const t=this._network[l++];t.subtract(e*(t.r-n),e*(t.g-r),e*(t.b-i),e*(t.a-a))}if(u>o){const t=this._network[u--];t.subtract(e*(t.r-n),e*(t.g-r),e*(t.b-i),e*(t.a-a))}}}_alterSingle(e,t,i,r,n,a){e/=_NeuQuant._initAlpha;const o=this._network[t];o.subtract(e*(o.r-n),e*(o.g-r),e*(o.b-i),e*(o.a-a))}_contest(e,t,i,r){const n=1020<<networkBiasShift;let a=~(1<<31),o=a,s=-1,l=s;for(let u=0;u<this._networkSize;u++){const h=this._network[u],c=this._distance.calculateNormalized(h,{r:i,g:t,b:e,a:r})*n|0;c<a&&(a=c,s=u);const f=c-(this._bias[u]>>_NeuQuant._initialBiasShift-networkBiasShift);f<o&&(o=f,l=u);const d=this._freq[u]>>_NeuQuant._betaShift;this._freq[u]-=d,this._bias[u]+=d<<_NeuQuant._gammaShift}return this._freq[s]+=_NeuQuant._beta,this._bias[s]-=_NeuQuant._betaGamma,l}},NeuQuant=_NeuQuant;__publicField(NeuQuant,"_prime1",499),__publicField(NeuQuant,"_prime2",491),__publicField(NeuQuant,"_prime3",487),__publicField(NeuQuant,"_prime4",503),__publicField(NeuQuant,"_minpicturebytes",_NeuQuant._prime4),__publicField(NeuQuant,"_nCycles",100),__publicField(NeuQuant,"_initialBiasShift",16),__publicField(NeuQuant,"_initialBias",1<<_NeuQuant._initialBiasShift),__publicField(NeuQuant,"_gammaShift",10),__publicField(NeuQuant,"_betaShift",10),__publicField(NeuQuant,"_beta",_NeuQuant._initialBias>>_NeuQuant._betaShift),__publicField(NeuQuant,"_betaGamma",_NeuQuant._initialBias<<_NeuQuant._gammaShift-_NeuQuant._betaShift),__publicField(NeuQuant,"_radiusBiasShift",6),__publicField(NeuQuant,"_radiusBias",1<<_NeuQuant._radiusBiasShift),__publicField(NeuQuant,"_radiusDecrease",30),__publicField(NeuQuant,"_alphaBiasShift",10),__publicField(NeuQuant,"_initAlpha",1<<_NeuQuant._alphaBiasShift),__publicField(NeuQuant,"_radBiasShift",8),__publicField(NeuQuant,"_radBias",1<<_NeuQuant._radBiasShift),__publicField(NeuQuant,"_alphaRadBiasShift",_NeuQuant._alphaBiasShift+_NeuQuant._radBiasShift),__publicField(NeuQuant,"_alphaRadBias",1<<_NeuQuant._alphaRadBiasShift);var networkBiasShift2=3,NeuronFloat=class{constructor(e){__publicField(this,"r"),__publicField(this,"g"),__publicField(this,"b"),__publicField(this,"a"),this.r=this.g=this.b=this.a=e}toPoint(){return Point.createByRGBA(this.r>>networkBiasShift2,this.g>>networkBiasShift2,this.b>>networkBiasShift2,this.a>>networkBiasShift2)}subtract(e,t,i,r){this.r-=e,this.g-=t,this.b-=i,this.a-=r}},_NeuQuantFloat=class extends AbstractPaletteQuantizer{constructor(e,t=256){super(),__publicField(this,"_pointArray"),__publicField(this,"_networkSize"),__publicField(this,"_network"),__publicField(this,"_sampleFactor"),__publicField(this,"_radPower"),__publicField(this,"_freq"),__publicField(this,"_bias"),__publicField(this,"_distance"),this._distance=e,this._pointArray=[],this._sampleFactor=1,this._networkSize=t,this._distance.setWhitePoint(255<<networkBiasShift2,255<<networkBiasShift2,255<<networkBiasShift2,255<<networkBiasShift2)}sample(e){this._pointArray=this._pointArray.concat(e.getPointArray())}*quantize(){this._init(),yield*this._learn(),yield{palette:this._buildPalette(),progress:100}}_init(){this._freq=[],this._bias=[],this._radPower=[],this._network=[];for(let e=0;e<this._networkSize;e++)this._network[e]=new NeuronFloat((e<<networkBiasShift2+8)/this._networkSize),this._freq[e]=_NeuQuantFloat._initialBias/this._networkSize,this._bias[e]=0}*_learn(){let e=this._sampleFactor;const t=this._pointArray.length;t<_NeuQuantFloat._minpicturebytes&&(e=1);const i=30+(e-1)/3,r=t/e;let n,a=r/_NeuQuantFloat._nCycles|0,o=_NeuQuantFloat._initAlpha,s=(this._networkSize>>3)*_NeuQuantFloat._radiusBias,l=s>>_NeuQuantFloat._radiusBiasShift;l<=1&&(l=0);for(let e=0;e<l;e++)this._radPower[e]=o*((l*l-e*e)*_NeuQuantFloat._radBias/(l*l));n=t<_NeuQuantFloat._minpicturebytes?1:t%_NeuQuantFloat._prime1!=0?_NeuQuantFloat._prime1:t%_NeuQuantFloat._prime2!=0?_NeuQuantFloat._prime2:t%_NeuQuantFloat._prime3!=0?_NeuQuantFloat._prime3:_NeuQuantFloat._prime4;const u=new ProgressTracker(r,99);for(let e=0,h=0;e<r;){u.shouldNotify(e)&&(yield{progress:u.progress});const r=this._pointArray[h],c=r.b<<networkBiasShift2,f=r.g<<networkBiasShift2,d=r.r<<networkBiasShift2,p=r.a<<networkBiasShift2,m=this._contest(c,f,d,p);if(this._alterSingle(o,m,c,f,d,p),0!==l&&this._alterNeighbour(l,m,c,f,d,p),h+=n,h>=t&&(h-=t),e++,0===a&&(a=1),e%a==0){o-=o/i,s-=s/_NeuQuantFloat._radiusDecrease,l=s>>_NeuQuantFloat._radiusBiasShift,l<=1&&(l=0);for(let e=0;e<l;e++)this._radPower[e]=o*((l*l-e*e)*_NeuQuantFloat._radBias/(l*l))}}}_buildPalette(){const e=new Palette;return this._network.forEach((t=>{e.add(t.toPoint())})),e.sort(),e}_alterNeighbour(e,t,i,r,n,a){let o=t-e;o<-1&&(o=-1);let s=t+e;s>this._networkSize&&(s=this._networkSize);let l=t+1,u=t-1,h=1;for(;l<s||u>o;){const e=this._radPower[h++]/_NeuQuantFloat._alphaRadBias;if(l<s){const t=this._network[l++];t.subtract(e*(t.r-n),e*(t.g-r),e*(t.b-i),e*(t.a-a))}if(u>o){const t=this._network[u--];t.subtract(e*(t.r-n),e*(t.g-r),e*(t.b-i),e*(t.a-a))}}}_alterSingle(e,t,i,r,n,a){e/=_NeuQuantFloat._initAlpha;const o=this._network[t];o.subtract(e*(o.r-n),e*(o.g-r),e*(o.b-i),e*(o.a-a))}_contest(e,t,i,r){const n=1020<<networkBiasShift2;let a=~(1<<31),o=a,s=-1,l=s;for(let u=0;u<this._networkSize;u++){const h=this._network[u],c=this._distance.calculateNormalized(h,{r:i,g:t,b:e,a:r})*n;c<a&&(a=c,s=u);const f=c-(this._bias[u]>>_NeuQuantFloat._initialBiasShift-networkBiasShift2);f<o&&(o=f,l=u);const d=this._freq[u]>>_NeuQuantFloat._betaShift;this._freq[u]-=d,this._bias[u]+=d<<_NeuQuantFloat._gammaShift}return this._freq[s]+=_NeuQuantFloat._beta,this._bias[s]-=_NeuQuantFloat._betaGamma,l}},NeuQuantFloat=_NeuQuantFloat;__publicField(NeuQuantFloat,"_prime1",499),__publicField(NeuQuantFloat,"_prime2",491),__publicField(NeuQuantFloat,"_prime3",487),__publicField(NeuQuantFloat,"_prime4",503),__publicField(NeuQuantFloat,"_minpicturebytes",_NeuQuantFloat._prime4),__publicField(NeuQuantFloat,"_nCycles",100),__publicField(NeuQuantFloat,"_initialBiasShift",16),__publicField(NeuQuantFloat,"_initialBias",1<<_NeuQuantFloat._initialBiasShift),__publicField(NeuQuantFloat,"_gammaShift",10),__publicField(NeuQuantFloat,"_betaShift",10),__publicField(NeuQuantFloat,"_beta",_NeuQuantFloat._initialBias>>_NeuQuantFloat._betaShift),__publicField(NeuQuantFloat,"_betaGamma",_NeuQuantFloat._initialBias<<_NeuQuantFloat._gammaShift-_NeuQuantFloat._betaShift),__publicField(NeuQuantFloat,"_radiusBiasShift",6),__publicField(NeuQuantFloat,"_radiusBias",1<<_NeuQuantFloat._radiusBiasShift),__publicField(NeuQuantFloat,"_radiusDecrease",30),__publicField(NeuQuantFloat,"_alphaBiasShift",10),__publicField(NeuQuantFloat,"_initAlpha",1<<_NeuQuantFloat._alphaBiasShift),__publicField(NeuQuantFloat,"_radBiasShift",8),__publicField(NeuQuantFloat,"_radBias",1<<_NeuQuantFloat._radBiasShift),__publicField(NeuQuantFloat,"_alphaRadBiasShift",_NeuQuantFloat._alphaBiasShift+_NeuQuantFloat._radBiasShift),__publicField(NeuQuantFloat,"_alphaRadBias",1<<_NeuQuantFloat._alphaRadBiasShift);var _ColorHistogram=class{constructor(e,t){__publicField(this,"_method"),__publicField(this,"_hueStats"),__publicField(this,"_histogram"),__publicField(this,"_initColors"),__publicField(this,"_minHueCols"),this._method=e,this._minHueCols=t<<2,this._initColors=t<<2,this._hueStats=new HueStatistics(_ColorHistogram._hueGroups,this._minHueCols),this._histogram=Object.create(null)}sample(e){switch(this._method){case 1:this._colorStats1D(e);break;case 2:this._colorStats2D(e)}}getImportanceSortedColorsIDXI32(){const e=stableSort(Object.keys(this._histogram),((e,t)=>this._histogram[t]-this._histogram[e]));if(0===e.length)return[];let t;switch(this._method){case 1:const i=Math.min(e.length,this._initColors),r=e[i-1],n=this._histogram[r];t=e.slice(0,i);let a=i;const o=e.length;for(;a<o&&this._histogram[e[a]]===n;)t.push(e[a++]);this._hueStats.injectIntoArray(t);break;case 2:t=e;break;default:throw new Error("Incorrect method")}return t.map((e=>+e))}_colorStats1D(e){const t=this._histogram,i=e.getPointArray(),r=i.length;for(let e=0;e<r;e++){const r=i[e].uint32;this._hueStats.check(r),r in t?t[r]++:t[r]=1}}_colorStats2D(e){const t=e.getWidth(),i=e.getHeight(),r=e.getPointArray(),n=_ColorHistogram._boxSize[0],a=_ColorHistogram._boxSize[1],o=n*a,s=this._makeBoxes(t,i,n,a),l=this._histogram;s.forEach((e=>{let i=Math.round(e.w*e.h/o)*_ColorHistogram._boxPixels;i<2&&(i=2);const n={};this._iterateBox(e,t,(e=>{const t=r[e].uint32;this._hueStats.check(t),t in l?l[t]++:t in n?++n[t]>=i&&(l[t]=n[t]):n[t]=1}))})),this._hueStats.injectIntoDictionary(l)}_iterateBox(e,t,i){const r=e,n=r.y*t+r.x,a=(r.y+r.h-1)*t+(r.x+r.w-1),o=t-r.w+1;let s=0,l=n;do{i.call(this,l),l+=++s%r.w==0?o:1}while(l<=a)}_makeBoxes(e,t,i,r){const n=e%i,a=t%r,o=e-n,s=t-a,l=[];for(let u=0;u<t;u+=r)for(let t=0;t<e;t+=i)l.push({x:t,y:u,w:t===o?n:i,h:u===s?a:r});return l}},ColorHistogram=_ColorHistogram;__publicField(ColorHistogram,"_boxSize",[64,64]),__publicField(ColorHistogram,"_boxPixels",2),__publicField(ColorHistogram,"_hueGroups",10);var RemovedColor=class{constructor(e,t,i){__publicField(this,"index"),__publicField(this,"color"),__publicField(this,"distance"),this.index=e,this.color=t,this.distance=i}},RGBQuant=class extends AbstractPaletteQuantizer{constructor(e,t=256,i=2){super(),__publicField(this,"_colors"),__publicField(this,"_initialDistance"),__publicField(this,"_distanceIncrement"),__publicField(this,"_histogram"),__publicField(this,"_distance"),this._distance=e,this._colors=t,this._histogram=new ColorHistogram(i,t),this._initialDistance=.01,this._distanceIncrement=.005}sample(e){this._histogram.sample(e)}*quantize(){const e=this._histogram.getImportanceSortedColorsIDXI32();if(0===e.length)throw new Error("No colors in image");yield*this._buildPalette(e)}*_buildPalette(e){const t=new Palette,i=t.getPointContainer().getPointArray(),r=new Array(e.length);for(let t=0;t<e.length;t++)i.push(Point.createByUint32(e[t])),r[t]=1;const n=i.length,a=[];let o=n,s=this._initialDistance;const l=new ProgressTracker(o-this._colors,99);for(;o>this._colors;){a.length=0;for(let e=0;e<n;e++){if(l.shouldNotify(n-o)&&(yield{progress:l.progress}),0===r[e])continue;const t=i[e];for(let l=e+1;l<n;l++){if(0===r[l])continue;const e=i[l],n=this._distance.calculateNormalized(t,e);n<s&&(a.push(new RemovedColor(l,e,n)),r[l]=0,o--)}}s+=o>3*this._colors?this._initialDistance:this._distanceIncrement}if(o<this._colors){stableSort(a,((e,t)=>t.distance-e.distance));let e=0;for(;o<this._colors&&e<a.length;){r[a[e].index]=1,o++,e++}}let u=i.length;for(let e=u-1;e>=0;e--)0===r[e]&&(e!==u-1&&(i[e]=i[u-1]),--u);i.length=u,t.sort(),yield{palette:t,progress:100}}};function createArray1D(e){const t=[];for(let i=0;i<e;i++)t[i]=0;return t}function createArray4D(e,t,i,r){const n=new Array(e);for(let a=0;a<e;a++){n[a]=new Array(t);for(let e=0;e<t;e++){n[a][e]=new Array(i);for(let t=0;t<i;t++){n[a][e][t]=new Array(r);for(let i=0;i<r;i++)n[a][e][t][i]=0}}}return n}function createArray3D(e,t,i){const r=new Array(e);for(let n=0;n<e;n++){r[n]=new Array(t);for(let e=0;e<t;e++){r[n][e]=new Array(i);for(let t=0;t<i;t++)r[n][e][t]=0}}return r}function fillArray3D(e,t,i,r,n){for(let a=0;a<t;a++){e[a]=[];for(let t=0;t<i;t++){e[a][t]=[];for(let i=0;i<r;i++)e[a][t][i]=n}}}function fillArray1D(e,t,i){for(let r=0;r<t;r++)e[r]=i}var WuColorCube=class{constructor(){__publicField(this,"redMinimum"),__publicField(this,"redMaximum"),__publicField(this,"greenMinimum"),__publicField(this,"greenMaximum"),__publicField(this,"blueMinimum"),__publicField(this,"blueMaximum"),__publicField(this,"volume"),__publicField(this,"alphaMinimum"),__publicField(this,"alphaMaximum")}},_WuQuant=class extends AbstractPaletteQuantizer{constructor(e,t=256,i=5){super(),__publicField(this,"_reds"),__publicField(this,"_greens"),__publicField(this,"_blues"),__publicField(this,"_alphas"),__publicField(this,"_sums"),__publicField(this,"_weights"),__publicField(this,"_momentsRed"),__publicField(this,"_momentsGreen"),__publicField(this,"_momentsBlue"),__publicField(this,"_momentsAlpha"),__publicField(this,"_moments"),__publicField(this,"_table"),__publicField(this,"_pixels"),__publicField(this,"_cubes"),__publicField(this,"_colors"),__publicField(this,"_significantBitsPerChannel"),__publicField(this,"_maxSideIndex"),__publicField(this,"_alphaMaxSideIndex"),__publicField(this,"_sideSize"),__publicField(this,"_alphaSideSize"),__publicField(this,"_distance"),this._distance=e,this._setQuality(i),this._initialize(t)}sample(e){const t=e.getPointArray();for(let e=0,i=t.length;e<i;e++)this._addColor(t[e]);this._pixels=this._pixels.concat(t)}*quantize(){yield*this._preparePalette();const e=new Palette;for(let t=0;t<this._colors;t++)if(this._sums[t]>0){const i=this._sums[t],r=this._reds[t]/i,n=this._greens[t]/i,a=this._blues[t]/i,o=this._alphas[t]/i,s=Point.createByRGBA(0|r,0|n,0|a,0|o);e.add(s)}e.sort(),yield{palette:e,progress:100}}*_preparePalette(){yield*this._calculateMoments();let e=0;const t=createArray1D(this._colors);for(let i=1;i<this._colors;++i){this._cut(this._cubes[e],this._cubes[i])?(t[e]=this._cubes[e].volume>1?this._calculateVariance(this._cubes[e]):0,t[i]=this._cubes[i].volume>1?this._calculateVariance(this._cubes[i]):0):(t[e]=0,i--),e=0;let r=t[0];for(let n=1;n<=i;++n)t[n]>r&&(r=t[n],e=n);if(r<=0){this._colors=i+1;break}}const i=[],r=[],n=[],a=[];for(let e=0;e<this._colors;++e){const t=_WuQuant._volume(this._cubes[e],this._weights);t>0?(i[e]=_WuQuant._volume(this._cubes[e],this._momentsRed)/t|0,r[e]=_WuQuant._volume(this._cubes[e],this._momentsGreen)/t|0,n[e]=_WuQuant._volume(this._cubes[e],this._momentsBlue)/t|0,a[e]=_WuQuant._volume(this._cubes[e],this._momentsAlpha)/t|0):(i[e]=0,r[e]=0,n[e]=0,a[e]=0)}this._reds=createArray1D(this._colors+1),this._greens=createArray1D(this._colors+1),this._blues=createArray1D(this._colors+1),this._alphas=createArray1D(this._colors+1),this._sums=createArray1D(this._colors+1);for(let e=0,t=this._pixels.length;e<t;e++){const t=this._pixels[e];let o=-1,s=Number.MAX_VALUE;for(let e=0;e<this._colors;e++){const l=i[e],u=r[e],h=n[e],c=a[e],f=this._distance.calculateRaw(l,u,h,c,t.r,t.g,t.b,t.a);f<s&&(s=f,o=e)}this._reds[o]+=t.r,this._greens[o]+=t.g,this._blues[o]+=t.b,this._alphas[o]+=t.a,this._sums[o]++}}_addColor(e){const t=8-this._significantBitsPerChannel,i=1+(e.r>>t),r=1+(e.g>>t),n=1+(e.b>>t),a=1+(e.a>>t);this._weights[a][i][r][n]++,this._momentsRed[a][i][r][n]+=e.r,this._momentsGreen[a][i][r][n]+=e.g,this._momentsBlue[a][i][r][n]+=e.b,this._momentsAlpha[a][i][r][n]+=e.a,this._moments[a][i][r][n]+=this._table[e.r]+this._table[e.g]+this._table[e.b]+this._table[e.a]}*_calculateMoments(){const e=[],t=[],i=[],r=[],n=[],a=[],o=createArray3D(this._sideSize,this._sideSize,this._sideSize),s=createArray3D(this._sideSize,this._sideSize,this._sideSize),l=createArray3D(this._sideSize,this._sideSize,this._sideSize),u=createArray3D(this._sideSize,this._sideSize,this._sideSize),h=createArray3D(this._sideSize,this._sideSize,this._sideSize),c=createArray3D(this._sideSize,this._sideSize,this._sideSize);let f=0;const d=new ProgressTracker(this._alphaMaxSideIndex*this._maxSideIndex,99);for(let p=1;p<=this._alphaMaxSideIndex;++p){fillArray3D(o,this._sideSize,this._sideSize,this._sideSize,0),fillArray3D(s,this._sideSize,this._sideSize,this._sideSize,0),fillArray3D(l,this._sideSize,this._sideSize,this._sideSize,0),fillArray3D(u,this._sideSize,this._sideSize,this._sideSize,0),fillArray3D(h,this._sideSize,this._sideSize,this._sideSize,0),fillArray3D(c,this._sideSize,this._sideSize,this._sideSize,0);for(let m=1;m<=this._maxSideIndex;++m,++f){d.shouldNotify(f)&&(yield{progress:d.progress}),fillArray1D(e,this._sideSize,0),fillArray1D(t,this._sideSize,0),fillArray1D(i,this._sideSize,0),fillArray1D(r,this._sideSize,0),fillArray1D(n,this._sideSize,0),fillArray1D(a,this._sideSize,0);for(let f=1;f<=this._maxSideIndex;++f){let d=0,_=0,g=0,b=0,y=0,w=0;for(let v=1;v<=this._maxSideIndex;++v)d+=this._weights[p][m][f][v],_+=this._momentsRed[p][m][f][v],g+=this._momentsGreen[p][m][f][v],b+=this._momentsBlue[p][m][f][v],y+=this._momentsAlpha[p][m][f][v],w+=this._moments[p][m][f][v],e[v]+=d,t[v]+=_,i[v]+=g,r[v]+=b,n[v]+=y,a[v]+=w,o[m][f][v]=o[m-1][f][v]+e[v],s[m][f][v]=s[m-1][f][v]+t[v],l[m][f][v]=l[m-1][f][v]+i[v],u[m][f][v]=u[m-1][f][v]+r[v],h[m][f][v]=h[m-1][f][v]+n[v],c[m][f][v]=c[m-1][f][v]+a[v],this._weights[p][m][f][v]=this._weights[p-1][m][f][v]+o[m][f][v],this._momentsRed[p][m][f][v]=this._momentsRed[p-1][m][f][v]+s[m][f][v],this._momentsGreen[p][m][f][v]=this._momentsGreen[p-1][m][f][v]+l[m][f][v],this._momentsBlue[p][m][f][v]=this._momentsBlue[p-1][m][f][v]+u[m][f][v],this._momentsAlpha[p][m][f][v]=this._momentsAlpha[p-1][m][f][v]+h[m][f][v],this._moments[p][m][f][v]=this._moments[p-1][m][f][v]+c[m][f][v]}}}}static _volumeFloat(e,t){return t[e.alphaMaximum][e.redMaximum][e.greenMaximum][e.blueMaximum]-t[e.alphaMaximum][e.redMaximum][e.greenMinimum][e.blueMaximum]-t[e.alphaMaximum][e.redMinimum][e.greenMaximum][e.blueMaximum]+t[e.alphaMaximum][e.redMinimum][e.greenMinimum][e.blueMaximum]-t[e.alphaMinimum][e.redMaximum][e.greenMaximum][e.blueMaximum]+t[e.alphaMinimum][e.redMaximum][e.greenMinimum][e.blueMaximum]+t[e.alphaMinimum][e.redMinimum][e.greenMaximum][e.blueMaximum]-t[e.alphaMinimum][e.redMinimum][e.greenMinimum][e.blueMaximum]-(t[e.alphaMaximum][e.redMaximum][e.greenMaximum][e.blueMinimum]-t[e.alphaMinimum][e.redMaximum][e.greenMaximum][e.blueMinimum]-t[e.alphaMaximum][e.redMaximum][e.greenMinimum][e.blueMinimum]+t[e.alphaMinimum][e.redMaximum][e.greenMinimum][e.blueMinimum]-t[e.alphaMaximum][e.redMinimum][e.greenMaximum][e.blueMinimum]+t[e.alphaMinimum][e.redMinimum][e.greenMaximum][e.blueMinimum]+t[e.alphaMaximum][e.redMinimum][e.greenMinimum][e.blueMinimum]-t[e.alphaMinimum][e.redMinimum][e.greenMinimum][e.blueMinimum])}static _volume(e,t){return 0|_WuQuant._volumeFloat(e,t)}static _top(e,t,i,r){let n;switch(t){case _WuQuant._alpha:n=r[i][e.redMaximum][e.greenMaximum][e.blueMaximum]-r[i][e.redMaximum][e.greenMinimum][e.blueMaximum]-r[i][e.redMinimum][e.greenMaximum][e.blueMaximum]+r[i][e.redMinimum][e.greenMinimum][e.blueMaximum]-(r[i][e.redMaximum][e.greenMaximum][e.blueMinimum]-r[i][e.redMaximum][e.greenMinimum][e.blueMinimum]-r[i][e.redMinimum][e.greenMaximum][e.blueMinimum]+r[i][e.redMinimum][e.greenMinimum][e.blueMinimum]);break;case _WuQuant._red:n=r[e.alphaMaximum][i][e.greenMaximum][e.blueMaximum]-r[e.alphaMaximum][i][e.greenMinimum][e.blueMaximum]-r[e.alphaMinimum][i][e.greenMaximum][e.blueMaximum]+r[e.alphaMinimum][i][e.greenMinimum][e.blueMaximum]-(r[e.alphaMaximum][i][e.greenMaximum][e.blueMinimum]-r[e.alphaMaximum][i][e.greenMinimum][e.blueMinimum]-r[e.alphaMinimum][i][e.greenMaximum][e.blueMinimum]+r[e.alphaMinimum][i][e.greenMinimum][e.blueMinimum]);break;case _WuQuant._green:n=r[e.alphaMaximum][e.redMaximum][i][e.blueMaximum]-r[e.alphaMaximum][e.redMinimum][i][e.blueMaximum]-r[e.alphaMinimum][e.redMaximum][i][e.blueMaximum]+r[e.alphaMinimum][e.redMinimum][i][e.blueMaximum]-(r[e.alphaMaximum][e.redMaximum][i][e.blueMinimum]-r[e.alphaMaximum][e.redMinimum][i][e.blueMinimum]-r[e.alphaMinimum][e.redMaximum][i][e.blueMinimum]+r[e.alphaMinimum][e.redMinimum][i][e.blueMinimum]);break;case _WuQuant._blue:n=r[e.alphaMaximum][e.redMaximum][e.greenMaximum][i]-r[e.alphaMaximum][e.redMaximum][e.greenMinimum][i]-r[e.alphaMaximum][e.redMinimum][e.greenMaximum][i]+r[e.alphaMaximum][e.redMinimum][e.greenMinimum][i]-(r[e.alphaMinimum][e.redMaximum][e.greenMaximum][i]-r[e.alphaMinimum][e.redMaximum][e.greenMinimum][i]-r[e.alphaMinimum][e.redMinimum][e.greenMaximum][i]+r[e.alphaMinimum][e.redMinimum][e.greenMinimum][i]);break;default:throw new Error("impossible")}return 0|n}static _bottom(e,t,i){switch(t){case _WuQuant._alpha:return-i[e.alphaMinimum][e.redMaximum][e.greenMaximum][e.blueMaximum]+i[e.alphaMinimum][e.redMaximum][e.greenMinimum][e.blueMaximum]+i[e.alphaMinimum][e.redMinimum][e.greenMaximum][e.blueMaximum]-i[e.alphaMinimum][e.redMinimum][e.greenMinimum][e.blueMaximum]-(-i[e.alphaMinimum][e.redMaximum][e.greenMaximum][e.blueMinimum]+i[e.alphaMinimum][e.redMaximum][e.greenMinimum][e.blueMinimum]+i[e.alphaMinimum][e.redMinimum][e.greenMaximum][e.blueMinimum]-i[e.alphaMinimum][e.redMinimum][e.greenMinimum][e.blueMinimum]);case _WuQuant._red:return-i[e.alphaMaximum][e.redMinimum][e.greenMaximum][e.blueMaximum]+i[e.alphaMaximum][e.redMinimum][e.greenMinimum][e.blueMaximum]+i[e.alphaMinimum][e.redMinimum][e.greenMaximum][e.blueMaximum]-i[e.alphaMinimum][e.redMinimum][e.greenMinimum][e.blueMaximum]-(-i[e.alphaMaximum][e.redMinimum][e.greenMaximum][e.blueMinimum]+i[e.alphaMaximum][e.redMinimum][e.greenMinimum][e.blueMinimum]+i[e.alphaMinimum][e.redMinimum][e.greenMaximum][e.blueMinimum]-i[e.alphaMinimum][e.redMinimum][e.greenMinimum][e.blueMinimum]);case _WuQuant._green:return-i[e.alphaMaximum][e.redMaximum][e.greenMinimum][e.blueMaximum]+i[e.alphaMaximum][e.redMinimum][e.greenMinimum][e.blueMaximum]+i[e.alphaMinimum][e.redMaximum][e.greenMinimum][e.blueMaximum]-i[e.alphaMinimum][e.redMinimum][e.greenMinimum][e.blueMaximum]-(-i[e.alphaMaximum][e.redMaximum][e.greenMinimum][e.blueMinimum]+i[e.alphaMaximum][e.redMinimum][e.greenMinimum][e.blueMinimum]+i[e.alphaMinimum][e.redMaximum][e.greenMinimum][e.blueMinimum]-i[e.alphaMinimum][e.redMinimum][e.greenMinimum][e.blueMinimum]);case _WuQuant._blue:return-i[e.alphaMaximum][e.redMaximum][e.greenMaximum][e.blueMinimum]+i[e.alphaMaximum][e.redMaximum][e.greenMinimum][e.blueMinimum]+i[e.alphaMaximum][e.redMinimum][e.greenMaximum][e.blueMinimum]-i[e.alphaMaximum][e.redMinimum][e.greenMinimum][e.blueMinimum]-(-i[e.alphaMinimum][e.redMaximum][e.greenMaximum][e.blueMinimum]+i[e.alphaMinimum][e.redMaximum][e.greenMinimum][e.blueMinimum]+i[e.alphaMinimum][e.redMinimum][e.greenMaximum][e.blueMinimum]-i[e.alphaMinimum][e.redMinimum][e.greenMinimum][e.blueMinimum]);default:return 0}}_calculateVariance(e){const t=_WuQuant._volume(e,this._momentsRed),i=_WuQuant._volume(e,this._momentsGreen),r=_WuQuant._volume(e,this._momentsBlue),n=_WuQuant._volume(e,this._momentsAlpha);return _WuQuant._volumeFloat(e,this._moments)-(t*t+i*i+r*r+n*n)/_WuQuant._volume(e,this._weights)}_maximize(e,t,i,r,n,a,o,s,l){const u=0|_WuQuant._bottom(e,t,this._momentsRed),h=0|_WuQuant._bottom(e,t,this._momentsGreen),c=0|_WuQuant._bottom(e,t,this._momentsBlue),f=0|_WuQuant._bottom(e,t,this._momentsAlpha),d=0|_WuQuant._bottom(e,t,this._weights);let p=0,m=-1;for(let _=i;_<r;++_){let i=u+_WuQuant._top(e,t,_,this._momentsRed),r=h+_WuQuant._top(e,t,_,this._momentsGreen),g=c+_WuQuant._top(e,t,_,this._momentsBlue),b=f+_WuQuant._top(e,t,_,this._momentsAlpha),y=d+_WuQuant._top(e,t,_,this._weights);if(0!==y){let e=i*i+r*r+g*g+b*b,t=e/y;i=n-i,r=a-r,g=o-g,b=s-b,y=l-y,0!==y&&(e=i*i+r*r+g*g+b*b,t+=e/y,t>p&&(p=t,m=_))}}return{max:p,position:m}}_cut(e,t){let i;const r=_WuQuant._volume(e,this._momentsRed),n=_WuQuant._volume(e,this._momentsGreen),a=_WuQuant._volume(e,this._momentsBlue),o=_WuQuant._volume(e,this._momentsAlpha),s=_WuQuant._volume(e,this._weights),l=this._maximize(e,_WuQuant._red,e.redMinimum+1,e.redMaximum,r,n,a,o,s),u=this._maximize(e,_WuQuant._green,e.greenMinimum+1,e.greenMaximum,r,n,a,o,s),h=this._maximize(e,_WuQuant._blue,e.blueMinimum+1,e.blueMaximum,r,n,a,o,s),c=this._maximize(e,_WuQuant._alpha,e.alphaMinimum+1,e.alphaMaximum,r,n,a,o,s);if(c.max>=l.max&&c.max>=u.max&&c.max>=h.max){if(i=_WuQuant._alpha,c.position<0)return!1}else i=l.max>=c.max&&l.max>=u.max&&l.max>=h.max?_WuQuant._red:u.max>=c.max&&u.max>=l.max&&u.max>=h.max?_WuQuant._green:_WuQuant._blue;switch(t.redMaximum=e.redMaximum,t.greenMaximum=e.greenMaximum,t.blueMaximum=e.blueMaximum,t.alphaMaximum=e.alphaMaximum,i){case _WuQuant._red:t.redMinimum=e.redMaximum=l.position,t.greenMinimum=e.greenMinimum,t.blueMinimum=e.blueMinimum,t.alphaMinimum=e.alphaMinimum;break;case _WuQuant._green:t.greenMinimum=e.greenMaximum=u.position,t.redMinimum=e.redMinimum,t.blueMinimum=e.blueMinimum,t.alphaMinimum=e.alphaMinimum;break;case _WuQuant._blue:t.blueMinimum=e.blueMaximum=h.position,t.redMinimum=e.redMinimum,t.greenMinimum=e.greenMinimum,t.alphaMinimum=e.alphaMinimum;break;case _WuQuant._alpha:t.alphaMinimum=e.alphaMaximum=c.position,t.blueMinimum=e.blueMinimum,t.redMinimum=e.redMinimum,t.greenMinimum=e.greenMinimum}return e.volume=(e.redMaximum-e.redMinimum)*(e.greenMaximum-e.greenMinimum)*(e.blueMaximum-e.blueMinimum)*(e.alphaMaximum-e.alphaMinimum),t.volume=(t.redMaximum-t.redMinimum)*(t.greenMaximum-t.greenMinimum)*(t.blueMaximum-t.blueMinimum)*(t.alphaMaximum-t.alphaMinimum),!0}_initialize(e){this._colors=e,this._cubes=[];for(let t=0;t<e;t++)this._cubes[t]=new WuColorCube;this._cubes[0].redMinimum=0,this._cubes[0].greenMinimum=0,this._cubes[0].blueMinimum=0,this._cubes[0].alphaMinimum=0,this._cubes[0].redMaximum=this._maxSideIndex,this._cubes[0].greenMaximum=this._maxSideIndex,this._cubes[0].blueMaximum=this._maxSideIndex,this._cubes[0].alphaMaximum=this._alphaMaxSideIndex,this._weights=createArray4D(this._alphaSideSize,this._sideSize,this._sideSize,this._sideSize),this._momentsRed=createArray4D(this._alphaSideSize,this._sideSize,this._sideSize,this._sideSize),this._momentsGreen=createArray4D(this._alphaSideSize,this._sideSize,this._sideSize,this._sideSize),this._momentsBlue=createArray4D(this._alphaSideSize,this._sideSize,this._sideSize,this._sideSize),this._momentsAlpha=createArray4D(this._alphaSideSize,this._sideSize,this._sideSize,this._sideSize),this._moments=createArray4D(this._alphaSideSize,this._sideSize,this._sideSize,this._sideSize),this._table=[];for(let e=0;e<256;++e)this._table[e]=e*e;this._pixels=[]}_setQuality(e=5){this._significantBitsPerChannel=e,this._maxSideIndex=1<<this._significantBitsPerChannel,this._alphaMaxSideIndex=this._maxSideIndex,this._sideSize=this._maxSideIndex+1,this._alphaSideSize=this._alphaMaxSideIndex+1}},WuQuant=_WuQuant;__publicField(WuQuant,"_alpha",3),__publicField(WuQuant,"_red",2),__publicField(WuQuant,"_green",1),__publicField(WuQuant,"_blue",0);var image_exports={};__export(image_exports,{AbstractImageQuantizer:()=>AbstractImageQuantizer,ErrorDiffusionArray:()=>ErrorDiffusionArray,ErrorDiffusionArrayKernel:()=>ErrorDiffusionArrayKernel,ErrorDiffusionRiemersma:()=>ErrorDiffusionRiemersma,NearestColor:()=>NearestColor});var AbstractImageQuantizer=class{quantizeSync(e,t){for(const i of this.quantize(e,t))if(i.pointContainer)return i.pointContainer;throw new Error("unreachable")}},NearestColor=class extends AbstractImageQuantizer{constructor(e){super(),__publicField(this,"_distance"),this._distance=e}*quantize(e,t){const i=e.getPointArray(),r=e.getWidth(),n=e.getHeight(),a=new ProgressTracker(n,99);for(let e=0;e<n;e++){a.shouldNotify(e)&&(yield{progress:a.progress});for(let n=0,a=e*r;n<r;n++,a++){const e=i[a];e.from(t.getNearestColor(this._distance,e))}}yield{pointContainer:e,progress:100}}},ErrorDiffusionArrayKernel=(e=>(e[e.FloydSteinberg=0]="FloydSteinberg",e[e.FalseFloydSteinberg=1]="FalseFloydSteinberg",e[e.Stucki=2]="Stucki",e[e.Atkinson=3]="Atkinson",e[e.Jarvis=4]="Jarvis",e[e.Burkes=5]="Burkes",e[e.Sierra=6]="Sierra",e[e.TwoSierra=7]="TwoSierra",e[e.SierraLite=8]="SierraLite",e))(ErrorDiffusionArrayKernel||{}),ErrorDiffusionArray=class extends AbstractImageQuantizer{constructor(e,t,i=!0,r=0,n=!1){super(),__publicField(this,"_minColorDistance"),__publicField(this,"_serpentine"),__publicField(this,"_kernel"),__publicField(this,"_calculateErrorLikeGIMP"),__publicField(this,"_distance"),this._setKernel(t),this._distance=e,this._minColorDistance=r,this._serpentine=i,this._calculateErrorLikeGIMP=n}*quantize(e,t){const i=e.getPointArray(),r=new Point,n=e.getWidth(),a=e.getHeight(),o=[];let s=1,l=1;for(const e of this._kernel){const t=e[2]+1;l<t&&(l=t)}for(let e=0;e<l;e++)this._fillErrorLine(o[e]=[],n);const u=new ProgressTracker(a,99);for(let e=0;e<a;e++){u.shouldNotify(e)&&(yield{progress:u.progress}),this._serpentine&&(s*=-1);const l=e*n,h=1===s?0:n-1,c=1===s?n:-1;this._fillErrorLine(o[0],n),o.push(o.shift());const f=o[0];for(let u=h,d=l+h;u!==c;u+=s,d+=s){const l=i[d],h=f[u];r.from(l);const c=Point.createByRGBA(inRange0to255Rounded(l.r+h[0]),inRange0to255Rounded(l.g+h[1]),inRange0to255Rounded(l.b+h[2]),inRange0to255Rounded(l.a+h[3])),p=t.getNearestColor(this._distance,c);if(l.from(p),this._minColorDistance){if(this._distance.calculateNormalized(r,p)<this._minColorDistance)continue}let m,_,g,b;this._calculateErrorLikeGIMP?(m=c.r-p.r,_=c.g-p.g,g=c.b-p.b,b=c.a-p.a):(m=r.r-p.r,_=r.g-p.g,g=r.b-p.b,b=r.a-p.a);const y=1===s?0:this._kernel.length-1,w=1===s?this._kernel.length:-1;for(let t=y;t!==w;t+=s){const i=this._kernel[t][1]*s,r=this._kernel[t][2];if(i+u>=0&&i+u<n&&r+e>=0&&r+e<a){const e=this._kernel[t][0],n=o[r][i+u];n[0]+=m*e,n[1]+=_*e,n[2]+=g*e,n[3]+=b*e}}}}yield{pointContainer:e,progress:100}}_fillErrorLine(e,t){e.length>t&&(e.length=t);const i=e.length;for(let t=0;t<i;t++){const i=e[t];i[0]=i[1]=i[2]=i[3]=0}for(let r=i;r<t;r++)e[r]=[0,0,0,0]}_setKernel(e){switch(e){case 0:this._kernel=[[7/16,1,0],[3/16,-1,1],[5/16,0,1],[1/16,1,1]];break;case 1:this._kernel=[[3/8,1,0],[3/8,0,1],[2/8,1,1]];break;case 2:this._kernel=[[8/42,1,0],[4/42,2,0],[2/42,-2,1],[4/42,-1,1],[8/42,0,1],[4/42,1,1],[2/42,2,1],[1/42,-2,2],[2/42,-1,2],[4/42,0,2],[2/42,1,2],[1/42,2,2]];break;case 3:this._kernel=[[1/8,1,0],[1/8,2,0],[1/8,-1,1],[1/8,0,1],[1/8,1,1],[1/8,0,2]];break;case 4:this._kernel=[[7/48,1,0],[5/48,2,0],[3/48,-2,1],[5/48,-1,1],[7/48,0,1],[5/48,1,1],[3/48,2,1],[1/48,-2,2],[3/48,-1,2],[5/48,0,2],[3/48,1,2],[1/48,2,2]];break;case 5:this._kernel=[[.25,1,0],[4/32,2,0],[2/32,-2,1],[4/32,-1,1],[.25,0,1],[4/32,1,1],[2/32,2,1]];break;case 6:this._kernel=[[5/32,1,0],[3/32,2,0],[2/32,-2,1],[4/32,-1,1],[5/32,0,1],[4/32,1,1],[2/32,2,1],[2/32,-1,2],[3/32,0,2],[2/32,1,2]];break;case 7:this._kernel=[[.25,1,0],[3/16,2,0],[1/16,-2,1],[2/16,-1,1],[3/16,0,1],[2/16,1,1],[1/16,2,1]];break;case 8:this._kernel=[[.5,1,0],[1/4,-1,1],[1/4,0,1]];break;default:throw new Error(`ErrorDiffusionArray: unknown kernel = ${e}`)}}};function*hilbertCurve(e,t,i){const r=Math.max(e,t),n={width:e,height:t,level:Math.floor(Math.log(r)/Math.log(2)+1),callback:i,tracker:new ProgressTracker(e*t,99),index:0,x:0,y:0};yield*walkHilbert(n,1),visit(n,0)}function*walkHilbert(e,t){if(!(e.level<1)){switch(e.tracker.shouldNotify(e.index)&&(yield{progress:e.tracker.progress}),e.level--,t){case 2:yield*walkHilbert(e,1),visit(e,3),yield*walkHilbert(e,2),visit(e,4),yield*walkHilbert(e,2),visit(e,2),yield*walkHilbert(e,4);break;case 3:yield*walkHilbert(e,4),visit(e,2),yield*walkHilbert(e,3),visit(e,1),yield*walkHilbert(e,3),visit(e,3),yield*walkHilbert(e,1);break;case 1:yield*walkHilbert(e,2),visit(e,4),yield*walkHilbert(e,1),visit(e,3),yield*walkHilbert(e,1),visit(e,1),yield*walkHilbert(e,3);break;case 4:yield*walkHilbert(e,3),visit(e,1),yield*walkHilbert(e,4),visit(e,2),yield*walkHilbert(e,4),visit(e,4),yield*walkHilbert(e,2)}e.level++}}function visit(e,t){switch(e.x>=0&&e.x<e.width&&e.y>=0&&e.y<e.height&&(e.callback(e.x,e.y),e.index++),t){case 2:e.x--;break;case 3:e.x++;break;case 1:e.y--;break;case 4:e.y++}}var ErrorDiffusionRiemersma=class extends AbstractImageQuantizer{constructor(e,t=16,i=1){super(),__publicField(this,"_distance"),__publicField(this,"_weights"),__publicField(this,"_errorQueueSize"),this._distance=e,this._errorQueueSize=t,this._weights=ErrorDiffusionRiemersma._createWeights(i,t)}*quantize(e,t){const i=e.getPointArray(),r=e.getWidth(),n=e.getHeight(),a=[];let o=0;for(let e=0;e<this._errorQueueSize;e++)a[e]={r:0,g:0,b:0,a:0};yield*hilbertCurve(r,n,((e,n)=>{const s=i[e+n*r];let{r:l,g:u,b:h,a:c}=s;for(let e=0;e<this._errorQueueSize;e++){const t=this._weights[e],i=a[(e+o)%this._errorQueueSize];l+=i.r*t,u+=i.g*t,h+=i.b*t,c+=i.a*t}const f=Point.createByRGBA(inRange0to255Rounded(l),inRange0to255Rounded(u),inRange0to255Rounded(h),inRange0to255Rounded(c)),d=t.getNearestColor(this._distance,f);o=(o+1)%this._errorQueueSize;const p=(o+this._errorQueueSize-1)%this._errorQueueSize;a[p].r=s.r-d.r,a[p].g=s.g-d.g,a[p].b=s.b-d.b,a[p].a=s.a-d.a,s.from(d)})),yield{pointContainer:e,progress:100}}static _createWeights(e,t){const i=[],r=Math.exp(Math.log(t)/(t-1));for(let n=0,a=1;n<t;n++)i[n]=(a+.5|0)/t*e,a*=r;return i}},quality_exports={};__export(quality_exports,{ssim:()=>ssim});var K1=.01,K2=.03;function ssim(e,t){if(e.getHeight()!==t.getHeight()||e.getWidth()!==t.getWidth())throw new Error("Images have different sizes!");const i=(255*K1)**2,r=(255*K2)**2;let n=0,a=0;return iterate(e,t,((e,t,o,s)=>{let l=0,u=0,h=0;for(let i=0;i<e.length;i++)u+=(e[i]-o)**2,h+=(t[i]-s)**2,l+=(e[i]-o)*(t[i]-s);const c=e.length-1;u/=c,h/=c,l/=c;a+=(2*o*s+i)*(2*l+r)/((o**2+s**2+i)*(u+h+r)),n++})),a/n}function iterate(e,t,i){const r=e.getWidth(),n=e.getHeight();for(let a=0;a<n;a+=8)for(let o=0;o<r;o+=8){const s=Math.min(8,r-o),l=Math.min(8,n-a),u=calculateLumaValuesForWindow(e,o,a,s,l),h=calculateLumaValuesForWindow(t,o,a,s,l);i(u,h,calculateAverageLuma(u),calculateAverageLuma(h))}}function calculateLumaValuesForWindow(e,t,i,r,n){const a=e.getPointArray(),o=[];let s=0;for(let l=i;l<i+n;l++){const i=l*e.getWidth();for(let e=t;e<t+r;e++){const t=a[i+e];o[s]=.2126*t.r+.7152*t.g+.0722*t.b,s++}}return o}function calculateAverageLuma(e){let t=0;for(const i of e)t+=i;return t/e.length}function buildPaletteSync(e,{colorDistanceFormula:t,paletteQuantization:i,colors:r}={}){const n=paletteQuantizationToPaletteQuantizer(colorDistanceFormulaToColorDistance(t),i,r);return e.forEach((e=>n.sample(e))),n.quantizeSync()}function applyPaletteSync(e,t,{colorDistanceFormula:i,imageQuantization:r}={}){return imageQuantizationToImageQuantizer(colorDistanceFormulaToColorDistance(i),r).quantizeSync(e,t)}function colorDistanceFormulaToColorDistance(e="euclidean-bt709"){switch(e){case"cie94-graphic-arts":return new CIE94GraphicArts;case"cie94-textiles":return new CIE94Textiles;case"ciede2000":return new CIEDE2000;case"color-metric":return new CMetric;case"euclidean":return new Euclidean;case"euclidean-bt709":return new EuclideanBT709;case"euclidean-bt709-noalpha":return new EuclideanBT709NoAlpha;case"manhattan":return new Manhattan;case"manhattan-bt709":return new ManhattanBT709;case"manhattan-nommyde":return new ManhattanNommyde;case"pngquant":return new PNGQuant;default:throw new Error(`Unknown colorDistanceFormula ${e}`)}}function imageQuantizationToImageQuantizer(e,t="floyd-steinberg"){switch(t){case"nearest":return new NearestColor(e);case"riemersma":return new ErrorDiffusionRiemersma(e);case"floyd-steinberg":return new ErrorDiffusionArray(e,0);case"false-floyd-steinberg":return new ErrorDiffusionArray(e,1);case"stucki":return new ErrorDiffusionArray(e,2);case"atkinson":return new ErrorDiffusionArray(e,3);case"jarvis":return new ErrorDiffusionArray(e,4);case"burkes":return new ErrorDiffusionArray(e,5);case"sierra":return new ErrorDiffusionArray(e,6);case"two-sierra":return new ErrorDiffusionArray(e,7);case"sierra-lite":return new ErrorDiffusionArray(e,8);default:throw new Error(`Unknown imageQuantization ${t}`)}}function paletteQuantizationToPaletteQuantizer(e,t="wuquant",i=256){switch(t){case"neuquant":return new NeuQuant(e,i);case"rgbquant":return new RGBQuant(e,i);case"wuquant":return new WuQuant(e,i);case"neuquant-float":return new NeuQuantFloat(e,i);default:throw new Error(`Unknown paletteQuantization ${t}`)}}
/**
* @preserve
* Copyright 2015-2018 Igor Bezkrovnyi
* All rights reserved. (MIT Licensed)
*
* cie94.ts - part of Image Quantization Library
*/
/**
* @preserve
* Copyright 2015-2018 Igor Bezkrovnyi
* All rights reserved. (MIT Licensed)
*
* ciede2000.ts - part of Image Quantization Library
*/
/**
* @preserve
* Copyright 2015-2018 Igor Bezkrovnyi
* All rights reserved. (MIT Licensed)
*
* cmetric.ts - part of Image Quantization Library
*/
/**
* @preserve
* Copyright 2015-2018 Igor Bezkrovnyi
* All rights reserved. (MIT Licensed)
*
* common.ts - part of Image Quantization Library
*/
/**
* @preserve
* Copyright 2015-2018 Igor Bezkrovnyi
* All rights reserved. (MIT Licensed)
*
* constants.ts - part of Image Quantization Library
*/
/**
* @preserve
* Copyright 2015-2018 Igor Bezkrovnyi
* All rights reserved. (MIT Licensed)
*
* ditherErrorDiffusionArray.ts - part of Image Quantization Library
*/
/**
* @preserve
* Copyright 2015-2018 Igor Bezkrovnyi
* All rights reserved. (MIT Licensed)
*
* euclidean.ts - part of Image Quantization Library
*/
/**
* @preserve
* Copyright 2015-2018 Igor Bezkrovnyi
* All rights reserved. (MIT Licensed)
*
* helper.ts - part of Image Quantization Library
*/
/**
* @preserve
* Copyright 2015-2018 Igor Bezkrovnyi
* All rights reserved. (MIT Licensed)
*
* hueStatistics.ts - part of Image Quantization Library
*/
/**
* @preserve
* Copyright 2015-2018 Igor Bezkrovnyi
* All rights reserved. (MIT Licensed)
*
* iq.ts - Image Quantization Library
*/
/**
* @preserve
* Copyright 2015-2018 Igor Bezkrovnyi
* All rights reserved. (MIT Licensed)
*
* lab2rgb.ts - part of Image Quantization Library
*/
/**
* @preserve
* Copyright 2015-2018 Igor Bezkrovnyi
* All rights reserved. (MIT Licensed)
*
* lab2xyz.ts - part of Image Quantization Library
*/
/**
* @preserve
* Copyright 2015-2018 Igor Bezkrovnyi
* All rights reserved. (MIT Licensed)
*
* manhattanNeuQuant.ts - part of Image Quantization Library
*/
/**
* @preserve
* Copyright 2015-2018 Igor Bezkrovnyi
* All rights reserved. (MIT Licensed)
*
* nearestColor.ts - part of Image Quantization Library
*/
/**
* @preserve
* Copyright 2015-2018 Igor Bezkrovnyi
* All rights reserved. (MIT Licensed)
*
* palette.ts - part of Image Quantization Library
*/
/**
* @preserve
* Copyright 2015-2018 Igor Bezkrovnyi
* All rights reserved. (MIT Licensed)
*
* pngQuant.ts - part of Image Quantization Library
*/
/**
* @preserve
* Copyright 2015-2018 Igor Bezkrovnyi
* All rights reserved. (MIT Licensed)
*
* point.ts - part of Image Quantization Library
*/
/**
* @preserve
* Copyright 2015-2018 Igor Bezkrovnyi
* All rights reserved. (MIT Licensed)
*
* pointContainer.ts - part of Image Quantization Library
*/
/**
* @preserve
* Copyright 2015-2018 Igor Bezkrovnyi
* All rights reserved. (MIT Licensed)
*
* rgb2hsl.ts - part of Image Quantization Library
*/
/**
* @preserve
* Copyright 2015-2018 Igor Bezkrovnyi
* All rights reserved. (MIT Licensed)
*
* rgb2lab.ts - part of Image Quantization Library
*/
/**
* @preserve
* Copyright 2015-2018 Igor Bezkrovnyi
* All rights reserved. (MIT Licensed)
*
* rgb2xyz.ts - part of Image Quantization Library
*/
/**
* @preserve
* Copyright 2015-2018 Igor Bezkrovnyi
* All rights reserved. (MIT Licensed)
*
* ssim.ts - part of Image Quantization Library
*/
/**
* @preserve
* Copyright 2015-2018 Igor Bezkrovnyi
* All rights reserved. (MIT Licensed)
*
* wuQuant.ts - part of Image Quantization Library
*/
/**
* @preserve
* Copyright 2015-2018 Igor Bezkrovnyi
* All rights reserved. (MIT Licensed)
*
* xyz2lab.ts - part of Image Quantization Library
*/
/**
* @preserve
* Copyright 2015-2018 Igor Bezkrovnyi
* All rights reserved. (MIT Licensed)
*
* xyz2rgb.ts - part of Image Quantization Library
*/
/**
* @preserve
* MIT License
*
* Copyright 2015-2018 Igor Bezkrovnyi
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
* riemersma.ts - part of Image Quantization Library
*/
/**
* @preserve TypeScript port:
* Copyright 2015-2018 Igor Bezkrovnyi
* All rights reserved. (MIT Licensed)
*
* colorHistogram.ts - part of Image Quantization Library
*/
/**
* @preserve TypeScript port:
* Copyright 2015-2018 Igor Bezkrovnyi
* All rights reserved. (MIT Licensed)
*
* neuquant.ts - part of Image Quantization Library
*/
/**
* @preserve TypeScript port:
* Copyright 2015-2018 Igor Bezkrovnyi
* All rights reserved. (MIT Licensed)
*
* rgbquant.ts - part of Image Quantization Library
*/"function"==typeof setImmediate?setImmediate:"undefined"!=typeof process&&(null==process||process.nextTick);const QuantizeOptionsSchema=z.object({colors:z.number().optional(),colorDistanceFormula:z.union([z.literal("cie94-textiles"),z.literal("cie94-graphic-arts"),z.literal("ciede2000"),z.literal("color-metric"),z.literal("euclidean"),z.literal("euclidean-bt709-noalpha"),z.literal("euclidean-bt709"),z.literal("manhattan"),z.literal("manhattan-bt709"),z.literal("manhattan-nommyde"),z.literal("pngquant")]).optional(),paletteQuantization:z.union([z.literal("neuquant"),z.literal("neuquant-float"),z.literal("rgbquant"),z.literal("wuquant")]).optional(),imageQuantization:z.union([z.literal("nearest"),z.literal("riemersma"),z.literal("floyd-steinberg"),z.literal("false-floyd-steinberg"),z.literal("stucki"),z.literal("atkinson"),z.literal("jarvis"),z.literal("burkes"),z.literal("sierra"),z.literal("two-sierra"),z.literal("sierra-lite")]).optional()}),methods={quantize(e,t){const{colors:i,colorDistanceFormula:r,paletteQuantization:n,imageQuantization:a}=QuantizeOptionsSchema.parse(t),o=utils_exports.PointContainer.fromUint8Array(e.bitmap.data,e.bitmap.width,e.bitmap.height),s=applyPaletteSync(o,buildPaletteSync([o],{colors:i,colorDistanceFormula:r,paletteQuantization:n}),{colorDistanceFormula:r,imageQuantization:a});return e.bitmap.data=Buffer.from(s.toUint8Array()),e}};var parseBmfontAscii=function(e){if(!e)throw new Error("no data provided");var t={pages:[],chars:[],kernings:[]},i=(e=e.toString().trim()).split(/\r\n?|\n/g);if(0===i.length)throw new Error("no data in BMFont file");for(var r=0;r<i.length;r++){var n=splitLine(i[r],r);if(n)if("page"===n.key){if("number"!=typeof n.data.id)throw new Error("malformed file at line "+r+" -- needs page id=N");if("string"!=typeof n.data.file)throw new Error("malformed file at line "+r+' -- needs page file="path"');t.pages[n.data.id]=n.data.file}else"chars"===n.key||"kernings"===n.key||("char"===n.key?t.chars.push(n.data):"kerning"===n.key?t.kernings.push(n.data):t[n.key]=n.data)}return t};function splitLine(e,t){if(!(e=e.replace(/\t+/g," ").trim()))return null;var i=e.indexOf(" ");if(-1===i)throw new Error("no named row at line "+t);var r=e.substring(0,i);e=(e=(e=(e=e.substring(i+1)).replace(/letter=[\'\"]\S+[\'\"]/gi,"")).split("=")).map((function(e){return e.trim().match(/(".*?"|[^"\s]+)+(?=\s*|\s*$)/g)}));for(var n=[],a=0;a<e.length;a++){var o=e[a];0===a?n.push({key:o[0],data:""}):a===e.length-1?n[n.length-1].data=parseData(o[0]):(n[n.length-1].data=parseData(o[0]),n.push({key:o[1],data:""}))}var s={key:r,data:{}};return n.forEach((function(e){s.data[e.key]=e.data})),s}function parseData(e){return e&&0!==e.length?0===e.indexOf('"')||0===e.indexOf("'")?e.substring(1,e.length-1):-1!==e.indexOf(",")?parseIntList$1(e):parseInt(e,10):""}function parseIntList$1(e){return e.split(",").map((function(e){return parseInt(e,10)}))}var parseASCII=getDefaultExportFromCjs(parseBmfontAscii),GLYPH_DESIGNER_ERROR="chasrset",parseAttribs=function(e){for(var t in e=Object.assign({},e),GLYPH_DESIGNER_ERROR in e&&(e.charset=e[GLYPH_DESIGNER_ERROR],delete e[GLYPH_DESIGNER_ERROR]),e)"face"!==t&&"charset"!==t&&(e[t]="padding"===t||"spacing"===t?parseIntList(e[t]):parseInt(e[t],10));return e};function parseIntList(e){return e.split(",").map((function(e){return parseInt(e,10)}))}var xmlParseFromString=void 0!==self.DOMParser?function(e){return(new self.DOMParser).parseFromString(e,"application/xml")}:void 0!==self.ActiveXObject&&new self.ActiveXObject("Microsoft.XMLDOM")?function(e){var t=new self.ActiveXObject("Microsoft.XMLDOM");return t.async="false",t.loadXML(e),t}:function(e){var t=document.createElement("div");return t.innerHTML=e,t},parseAttributes=parseAttribs,parseFromString=xmlParseFromString,NAME_MAP={scaleh:"scaleH",scalew:"scaleW",stretchh:"stretchH",lineheight:"lineHeight",alphachnl:"alphaChnl",redchnl:"redChnl",greenchnl:"greenChnl",bluechnl:"blueChnl"},browser=function(e){e=e.toString();var t=parseFromString(e),i={pages:[],chars:[],kernings:[]};["info","common"].forEach((function(e){var r=t.getElementsByTagName(e)[0];r&&(i[e]=parseAttributes(getAttribs(r)))}));var r=t.getElementsByTagName("pages")[0];if(!r)throw new Error("malformed file -- no <pages> element");for(var n=r.getElementsByTagName("page"),a=0;a<n.length;a++){var o=n[a],s=parseInt(o.getAttribute("id"),10),l=o.getAttribute("file");if(isNaN(s))throw new Error('malformed file -- page "id" attribute is NaN');if(!l)throw new Error('malformed file -- needs page "file" attribute');i.pages[parseInt(s,10)]=l}return["chars","kernings"].forEach((function(e){var r=t.getElementsByTagName(e)[0];if(r)for(var n=e.substring(0,e.length-1),a=r.getElementsByTagName(n),o=0;o<a.length;o++){var s=a[o];i[e].push(parseAttributes(getAttribs(s)))}})),i};function getAttribs(e){return getAttribList(e).reduce((function(e,t){return e[mapName(t.nodeName)]=t.nodeValue,e}),{})}function getAttribList(e){for(var t=[],i=0;i<e.attributes.length;i++)t.push(e.attributes[i]);return t}function mapName(e){return NAME_MAP[e.toLowerCase()]||e}var parseXML=getDefaultExportFromCjs(browser),HEADER$1=[66,77,70],parseBmfontBinary=function(e){if(e.length<6)throw new Error("invalid buffer length for BMFont");var t=HEADER$1.every((function(t,i){return e.readUInt8(i)===t}));if(!t)throw new Error("BMFont missing BMF byte header");var i=3;if(e.readUInt8(i++)>3)throw new Error("Only supports BMFont Binary v3 (BMFont App v1.10)");for(var r={kernings:[],chars:[]},n=0;n<5;n++)i+=readBlock(r,e,i);return r};function readBlock(e,t,i){if(i>t.length-1)return 0;var r=t.readUInt8(i++),n=t.readInt32LE(i);switch(i+=4,r){case 1:e.info=readInfo(t,i);break;case 2:e.common=readCommon(t,i);break;case 3:e.pages=readPages(t,i,n);break;case 4:e.chars=readChars(t,i,n);break;case 5:e.kernings=readKernings(t,i,n)}return 5+n}function readInfo(e,t){var i={};i.size=e.readInt16LE(t);var r=e.readUInt8(t+2);return i.smooth=r>>7&1,i.unicode=r>>6&1,i.italic=r>>5&1,i.bold=r>>4&1,r>>3&1&&(i.fixedHeight=1),i.charset=e.readUInt8(t+3)||"",i.stretchH=e.readUInt16LE(t+4),i.aa=e.readUInt8(t+6),i.padding=[e.readInt8(t+7),e.readInt8(t+8),e.readInt8(t+9),e.readInt8(t+10)],i.spacing=[e.readInt8(t+11),e.readInt8(t+12)],i.outline=e.readUInt8(t+13),i.face=readStringNT(e,t+14),i}function readCommon(e,t){var i={};return i.lineHeight=e.readUInt16LE(t),i.base=e.readUInt16LE(t+2),i.scaleW=e.readUInt16LE(t+4),i.scaleH=e.readUInt16LE(t+6),i.pages=e.readUInt16LE(t+8),e.readUInt8(t+10),i.packed=0,i.alphaChnl=e.readUInt8(t+11),i.redChnl=e.readUInt8(t+12),i.greenChnl=e.readUInt8(t+13),i.blueChnl=e.readUInt8(t+14),i}function readPages(e,t,i){for(var r=[],n=readNameNT(e,t),a=n.length+1,o=i/a,s=0;s<o;s++)r[s]=e.slice(t,t+n.length).toString("utf8"),t+=a;return r}function readChars(e,t,i){for(var r=[],n=i/20,a=0;a<n;a++){var o={},s=20*a;o.id=e.readUInt32LE(t+0+s),o.x=e.readUInt16LE(t+4+s),o.y=e.readUInt16LE(t+6+s),o.width=e.readUInt16LE(t+8+s),o.height=e.readUInt16LE(t+10+s),o.xoffset=e.readInt16LE(t+12+s),o.yoffset=e.readInt16LE(t+14+s),o.xadvance=e.readInt16LE(t+16+s),o.page=e.readUInt8(t+18+s),o.chnl=e.readUInt8(t+19+s),r[a]=o}return r}function readKernings(e,t,i){for(var r=[],n=i/10,a=0;a<n;a++){var o={},s=10*a;o.first=e.readUInt32LE(t+0+s),o.second=e.readUInt32LE(t+4+s),o.amount=e.readInt16LE(t+8+s),r[a]=o}return r}function readNameNT(e,t){for(var i=t;i<e.length&&0!==e[i];i++);return e.slice(t,i)}function readStringNT(e,t){return readNameNT(e,t).toString("utf8")}var readBinary=getDefaultExportFromCjs(parseBmfontBinary);function normalizeArray(e,t){for(var i=0,r=e.length-1;r>=0;r--){var n=e[r];"."===n?e.splice(r,1):".."===n?(e.splice(r,1),i++):i&&(e.splice(r,1),i--)}if(t)for(;i--;i)e.unshift("..");return e}var splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,splitPath=function(e){return splitPathRe.exec(e).slice(1)};function resolve(){for(var e="",t=!1,i=arguments.length-1;i>=-1&&!t;i--){var r=i>=0?arguments[i]:"/";if("string"!=typeof r)throw new TypeError("Arguments to path.resolve must be strings");r&&(e=r+"/"+e,t="/"===r.charAt(0))}return e=normalizeArray(filter(e.split("/"),(function(e){return!!e})),!t).join("/"),(t?"/":"")+e||"."}function normalize(e){var t=isAbsolute(e),i="/"===substr(e,-1);return e=normalizeArray(filter(e.split("/"),(function(e){return!!e})),!t).join("/"),e||t||(e="."),e&&i&&(e+="/"),(t?"/":"")+e}function isAbsolute(e){return"/"===e.charAt(0)}function join(){return normalize(filter(Array.prototype.slice.call(arguments,0),(function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e})).join("/"))}function relative(e,t){function i(e){for(var t=0;t<e.length&&""===e[t];t++);for(var i=e.length-1;i>=0&&""===e[i];i--);return t>i?[]:e.slice(t,i-t+1)}e=resolve(e).substr(1),t=resolve(t).substr(1);for(var r=i(e.split("/")),n=i(t.split("/")),a=Math.min(r.length,n.length),o=a,s=0;s<a;s++)if(r[s]!==n[s]){o=s;break}var l=[];for(s=o;s<r.length;s++)l.push("..");return(l=l.concat(n.slice(o))).join("/")}var sep="/",delimiter=":";function dirname(e){var t=splitPath(e),i=t[0],r=t[1];return i||r?(r&&(r=r.substr(0,r.length-1)),i+r):"."}function basename(e,t){var i=splitPath(e)[2];return t&&i.substr(-1*t.length)===t&&(i=i.substr(0,i.length-t.length)),i}function extname(e){return splitPath(e)[3]}var path={extname:extname,basename:basename,dirname:dirname,sep:sep,delimiter:delimiter,relative:relative,join:join,isAbsolute:isAbsolute,normalize:normalize,resolve:resolve};function filter(e,t){if(e.filter)return e.filter(t);for(var i=[],r=0;r<e.length;r++)t(e[r],r,e)&&i.push(e[r]);return i}var substr="b"==="ab".substr(-1)?function(e,t,i){return e.substr(t,i)}:function(e,t,i){return t<0&&(t=e.length+t),e.substr(t,i)};function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}const t=e=>{if(!e)return null;const i={};switch(e.type){case"ELEMENT":{let n={};const a=E(e.value.attributes),o=t(e.value.children);if(a&&(n=Object.assign(n,a)),o){const t=r(e.value.children);n=Object.assign(n,t)}i[e.value.type]=n;break}case"ATTRIBUTE":{const t=e.value;i[t.name]=t.value;break}case"CONTENT":return{content:e.value}}return i},r=e=>e&&Array.isArray(e)&&0!==e.length?n(e)?{content:e[0].value}:{children:e.map(t)}:null,n=e=>e&&Array.isArray(e)&&1===e.length&&"CONTENT"===e[0].type,E=e=>e&&Array.isArray(e)?e.map(t).reduce(((e,t)=>Object.assign(e,t)),{}):null;var s={convert:e=>t(e.value.children[0])},a={Token:(e,t)=>({type:e,value:t}),TOKEN_TYPE:{OPEN_BRACKET:"OPEN_BRACKET",ELEMENT_TYPE:"ELEMENT_TYPE",CLOSE_ELEMENT:"CLOSE_ELEMENT",ATTRIB_NAME:"ATTRIB_NAME",ATTRIB_VALUE:"ATTRIB_VALUE",ASSIGN:"ASSIGN",CLOSE_BRACKET:"CLOSE_BRACKET",CONTENT:"CONTENT",EOF:"EOF"}};const{Token:T,TOKEN_TYPE:u}=a,c=T("EOF"),l=e=>" "===e||"\n"===e||"\r"===e||"\t"===e,o=e=>e.replace(/'/g,'"');var N={createLexer:function(e){let t=null,i=(e=>{let t=0;for(;t<e.length&&l(e[t]);)t++;return((e,t)=>{if(e.startsWith("<?xml",t)){const i=e.length;for(;t<i;)if("?"!==e[t])t++;else{if(">"===e[t+1])return t+2;t++}}return t})(e,t)})(e),r=[];const n=()=>e[i],a=()=>t!==c&&i<e.length,s=e=>'"'===e||"'"===e,h=()=>{for(;a()&&l(e[i]);)i++},f=t=>{if(a()){if("<"===e[i]){let t="<";return i++,a()&&"/"===e[i]?(i++,t="</"):a()&&"!"===e[i]&&"-"===e[i+1]&&"-"===e[i+2]&&(i++,i++,i++,t="\x3c!--"),t}if("/"===n()){let e="/";return i++,a()&&">"===n()&&(i++,e="/>"),e}if("="===e[i]||">"===e[i]){const t=e[i];return i++,t}}return d(!!t)},d=t=>{const r=t?/[^>=<]/u:/[a-zA-Z0-9_:-]/;let n=i;for(;a()&&e[i].match(r);)i++;return o(e.substring(n,i))},p=()=>{const l=i;h();const m=i-l;if(a())if(t&&t.type===u.OPEN_BRACKET){h();const e=f(!1);t=T(u.ELEMENT_TYPE,e),r.push(e)}else if(t&&t.type===u.ASSIGN){a()&&s(n())&&i++;let r=i;for(;a()&&!s(n());)i++;const l=o(e.substring(r,i));i++,t=T(u.ATTRIB_VALUE,l)}else{h();let o=f(!0);switch(o){case"=":t=t.type===u.ATTRIB_NAME?T(u.ASSIGN):T(u.CONTENT,o);break;case"</":{const n=i;for(;">"!==e[i];)i++;t=T(u.CLOSE_ELEMENT,e.substring(n,i)),i++,r.pop();break}case"/>":{const e=r.pop();t=T(u.CLOSE_ELEMENT,e);break}case"\x3c!--":{const t=["!","-","-"];for(;a()&&(">"!==t[2]||"-"!==t[1]||"-"!==t[0]);)t.shift(),t.push(e[i]),i++;return p()}case">":t=T(u.CLOSE_BRACKET);break;case"<":t=T(u.OPEN_BRACKET);break;default:if(o&&o.length>0){if(t.type===u.CLOSE_BRACKET){let e="";"<"!==n()&&(e=d(!0)),t=T(u.CONTENT,o+e)}else if(t.type!==u.ATTRIB_NAME&&t.type!==u.CONTENT)t.type===u.CLOSE_ELEMENT?(o=" ".repeat(m)+o,t=T(u.CONTENT,o)):t=T(u.ATTRIB_NAME,o);else{const e=" ".repeat(m)+o;t=T(u.CONTENT,e)}break}{const t='Unknown Syntax : "'+e[i]+'"';throw new Error(t)}}}else t=c;return t};return{peek:n,next:p,hasNext:a}}};const{createLexer:i}=N,{Token:p,TOKEN_TYPE:O}=a,[A,f,C,h]=["ROOT","ELEMENT","ATTRIBUTE","CONTENT"],_=(e,t)=>({type:e,value:t}),L=e=>_(h,e),y=(e,t,i)=>_(f,{type:e,attributes:t,children:i}),v=(e,t)=>_(C,{name:e,value:t}),S=(e,t)=>{const i=[];for(;e.hasNext();){const r=e.next();switch(r.type){case O.OPEN_BRACKET:{const t=e.next(),[r,n]=R(e);let a=[];n.type!==O.CLOSE_ELEMENT&&(a=S(e,t)),a&&a.length>0&&a[0].type===O.CONTENT&&(a=b(a)),i.push(y(t.value,r,a));break}case O.CLOSE_ELEMENT:if(r.value===t.value)return i;break;case O.CONTENT:i.push(L(r.value));break;case O.EOF:return i;default:throw new Error(`Unknown Lexem type: ${r.type} "${r.value}, scoping element: ${t.value}"`)}}return i},R=e=>{const t=[];let i=e.peek();if(!e.hasNext()||i&&i.type===O.CLOSE_BRACKET||i&&i.type===O.CLOSE_ELEMENT)return[t,i];for(i=e.next();e.hasNext()&&i&&i.type!==O.CLOSE_BRACKET&&i.type!==O.CLOSE_ELEMENT;){const r=i;e.next();const n=e.next(),a=v(r.value,n.value);t.push(a),i=e.next()}return[t,i]};function b(e){let t=[],i="";return e.forEach((e=>{e.type===O.CONTENT?i+=e.value:(i.length&&(t.push(L(i)),i=""),t.push(e))})),i.length&&t.push(L(i)),t}var B={transpile:function(e,t){const r=(e=>_(A,{children:S(e,p(A,"ROOT"))}))(i(e));return t?t.convert(r):r},Node:_,ElementNode:y,AttribNode:v};const M=s,{transpile:x}=B;var k=e({convertXML:function(e,t){return x(e,t||M)},createAST:function(e){return x(e)}}),simpleXmlToJson_min=k,xmlPackage=getDefaultExportFromCjs(simpleXmlToJson_min);const{convertXML:convertXML}=xmlPackage,isWebWorker="undefined"!=typeof self&&void 0===self.document,CharacterJimp=createJimp({formats:[png]}),HEADER=Buffer.from([66,77,70,3]);function isBinary(e){if("string"==typeof e)return"BMF"===e.substring(0,3);const t=e.slice(0,4);return e.length>4&&t[0]===HEADER[0]&&t[1]===HEADER[1]&&t[2]===HEADER[2]}function parseFont(e,t){return isBinary(t)?("string"==typeof t&&(t=Buffer.from(t,"binary")),readBinary(t)):(t=t.toString().trim(),/.json$/.test(e)||"{"===t.charAt(0)?JSON.parse(t):/.xml$/.test(e)||"<"===t.charAt(0)?parseXML(t):parseASCII(t))}function parseNumbersInObject(e){for(const t in e){try{e[t]=parseInt(e[t],10)}catch{}"object"==typeof e[t]&&parseNumbersInObject(e[t])}return e}async function loadBitmapFontData(e){if(isWebWorker&&"string"==typeof e){const t=await fetch(e),i=await t.text(),r=convertXML(i).font.children.reduce(((e,t)=>({...e,...t})),{}),n=[],a=[],o=[];for(let e=0;e<r.pages.children.length;e++){const t=r.pages.children[e].page;n[parseInt(t.id,10)]=parseNumbersInObject(t.file)}for(let e=0;e<r.chars.children.length;e++)a.push(parseNumbersInObject(r.chars.children[e].char));for(let e=0;e<r.kernings.children.length;e++)o.push(parseNumbersInObject(r.kernings.children[e].kerning));return{info:r.info,common:r.common,pages:n,chars:a,kernings:o}}if("string"==typeof e){const t=await fetch(e);return parseFont(e,await t.text())}return parseFont("",e)}async function processBitmapFont(e,t){const i={},r={};for(let e=0;e<t.chars.length;e++){const r=t.chars[e];i[String.fromCharCode(r.id)]=r}for(let e=0;e<t.kernings.length;e++){const i=String.fromCharCode(t.kernings[e].first);r[i]=r[i]||{},r[i][String.fromCharCode(t.kernings[e].second)]=t.kernings[e].amount}return{...t,chars:i,kernings:r,pages:await Promise.all(t.pages.map((async t=>CharacterJimp.read(path.join(path.dirname(e),t)))))}}async function loadFont(e){let t=e;if("undefined"==typeof window&&!isWebWorker){const{existsSync:i,promises:r}=await Promise.resolve().then((function(){return _polyfillNode_fs$1}));i(e)&&(t=await r.readFile(e))}return processBitmapFont(e,await loadBitmapFontData(t))}var pixelmatch_1=pixelmatch;const defaultOptions={threshold:.1,includeAA:!1,alpha:.1,aaColor:[255,255,0],diffColor:[255,0,0],diffColorAlt:null,diffMask:!1};function pixelmatch(e,t,i,r,n,a){if(!isPixelData(e)||!isPixelData(t)||i&&!isPixelData(i))throw new Error("Image data: Uint8Array, Uint8ClampedArray or Buffer expected.");if(e.length!==t.length||i&&i.length!==e.length)throw new Error("Image sizes do not match.");if(e.length!==r*n*4)throw new Error("Image data size does not match width/height.");a=Object.assign({},defaultOptions,a);const o=r*n,s=new Uint32Array(e.buffer,e.byteOffset,o),l=new Uint32Array(t.buffer,t.byteOffset,o);let u=!0;for(let e=0;e<o;e++)if(s[e]!==l[e]){u=!1;break}if(u){if(i&&!a.diffMask)for(let t=0;t<o;t++)drawGrayPixel(e,4*t,a.alpha,i);return 0}const h=35215*a.threshold*a.threshold;let c=0;for(let o=0;o<n;o++)for(let s=0;s<r;s++){const l=4*(o*r+s),u=colorDelta(e,t,l,l);Math.abs(u)>h?a.includeAA||!antialiased(e,s,o,r,n,t)&&!antialiased(t,s,o,r,n,e)?(i&&drawPixel(i,l,...u<0&&a.diffColorAlt||a.diffColor),c++):i&&!a.diffMask&&drawPixel(i,l,...a.aaColor):i&&(a.diffMask||drawGrayPixel(e,l,a.alpha,i))}return c}function isPixelData(e){return ArrayBuffer.isView(e)&&1===e.constructor.BYTES_PER_ELEMENT}function antialiased(e,t,i,r,n,a){const o=Math.max(t-1,0),s=Math.max(i-1,0),l=Math.min(t+1,r-1),u=Math.min(i+1,n-1),h=4*(i*r+t);let c,f,d,p,m=t===o||t===l||i===s||i===u?1:0,_=0,g=0;for(let n=o;n<=l;n++)for(let a=s;a<=u;a++){if(n===t&&a===i)continue;const o=colorDelta(e,e,h,4*(a*r+n),!0);if(0===o){if(m++,m>2)return!1}else o<_?(_=o,c=n,f=a):o>g&&(g=o,d=n,p=a)}return 0!==_&&0!==g&&(hasManySiblings(e,c,f,r,n)&&hasManySiblings(a,c,f,r,n)||hasManySiblings(e,d,p,r,n)&&hasManySiblings(a,d,p,r,n))}function hasManySiblings(e,t,i,r,n){const a=Math.max(t-1,0),o=Math.max(i-1,0),s=Math.min(t+1,r-1),l=Math.min(i+1,n-1),u=4*(i*r+t);let h=t===a||t===s||i===o||i===l?1:0;for(let n=a;n<=s;n++)for(let a=o;a<=l;a++){if(n===t&&a===i)continue;const o=4*(a*r+n);if(e[u]===e[o]&&e[u+1]===e[o+1]&&e[u+2]===e[o+2]&&e[u+3]===e[o+3]&&h++,h>2)return!0}return!1}function colorDelta(e,t,i,r,n){let a=e[i+0],o=e[i+1],s=e[i+2],l=e[i+3],u=t[r+0],h=t[r+1],c=t[r+2],f=t[r+3];if(l===f&&a===u&&o===h&&s===c)return 0;l<255&&(l/=255,a=blend(a,l),o=blend(o,l),s=blend(s,l)),f<255&&(f/=255,u=blend(u,f),h=blend(h,f),c=blend(c,f));const d=rgb2y(a,o,s),p=rgb2y(u,h,c),m=d-p;if(n)return m;const _=rgb2i(a,o,s)-rgb2i(u,h,c),g=rgb2q(a,o,s)-rgb2q(u,h,c),b=.5053*m*m+.299*_*_+.1957*g*g;return d>p?-b:b}function rgb2y(e,t,i){return.29889531*e+.58662247*t+.11448223*i}function rgb2i(e,t,i){return.59597799*e-.2741761*t-.32180189*i}function rgb2q(e,t,i){return.21147017*e-.52261711*t+.31114694*i}function blend(e,t){return 255+(e-255)*t}function drawPixel(e,t,i,r,n){e[t+0]=i,e[t+1]=r,e[t+2]=n,e[t+3]=255}function drawGrayPixel(e,t,i,r){const n=blend(rgb2y(e[t+0],e[t+1],e[t+2]),i*e[t+3]/255);drawPixel(r,t,n,n,n)}var pixelMatch=getDefaultExportFromCjs(pixelmatch_1);function diff(e,t,i=.1){let r=e.bitmap,n=t.bitmap;if(r.width===n.width&&r.height===n.height||(r.width*r.height>n.width*n.height?r=methods$d.resize(clone(e),{w:n.width,h:n.height}).bitmap:n=methods$d.resize(clone(t),{w:r.width,h:r.height}).bitmap),"number"!=typeof i||i<0||i>1)throw new Error("threshold must be a number between 0 and 1");const a=new e.constructor({width:r.width,height:r.height,color:4294967295});return{percent:pixelMatch(r.data,n.data,a.bitmap.data,a.bitmap.width,a.bitmap.height,{threshold:i})/(a.bitmap.width*a.bitmap.height),image:a}}const defaultPlugins=[methods$h,methods$g,methods$f,methods$e,methods$c,methods$a,methods$b,methods$9,methods$8,methods$7,methods$6,methods$5,methods$4,methods$3,methods$d,methods$2,methods$1,methods],defaultFormats=[bmp,msBmp,gif,jpeg$2,png,tiff],JimpMime={bmp:bmp().mime,gif:gif().mime,jpeg:jpeg$2().mime,png:png().mime,tiff:tiff().mime},Jimp=createJimp({formats:defaultFormats,plugins:defaultPlugins});export{BlendMode,BmpCompression,HorizontalAlign,Jimp,JimpMime,PNGColorType,PNGFilterType,ResizeStrategy,VerticalAlign,colorDiff,compareHashes,cssColorToHex,defaultFormats,defaultPlugins,diff,distance,intToRGBA$1 as intToRGBA,limit255,loadFont,measureText,measureTextHeight,rgbaToInt};
//# sourceMappingURL=index.js.map