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>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;al?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<>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<>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<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()=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;as&&(i=s-l),a=i;a>=0;a--){for(var c=!0,f=0;fn&&(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;o239?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);n0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(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;hn)&&(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;rr)&&(i=r);for(var n="",a=t;ai)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||te.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>>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>>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),t0&&(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=(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=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=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=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=0;--n)e[n+t]=this[n+i];else if(a<1e3||!Buffer.TYPED_ARRAY_SUPPORT)for(n=0;n>>=0,i=void 0===i?this.length:i>>>0,e||(e=0),"number"==typeof e)for(a=t;a55295&&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>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=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<{const i=this.buffer.readUInt8(this.pos++),r=t*this.width*4+8*e*4;for(let t=0;t<8&&8*e+t>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>4),1&r&&r+1>1&1)&&this.pos++}}else for(let t=0;t>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{const i=this.buffer.readUInt8(this.pos++),r=t*this.width*4+4*e;if(i{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;ee<<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.5?l/(2-a-o):l/(a+o),a){case e:r=(t-i)/l+(t1&&(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>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;ul&&(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;t255)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<=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>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>=1;)++d;f=1<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>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;)e[t++]=255&c,c>>=8,h-=8,t===n+256&&(e[n]=255,n=t++)}function d(e){c|=e<=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<>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=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=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=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<>=l,h-=l,_!==a){if(_===o)break;for(var g=_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{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;ut 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 rt&&(r=t),r>i&&(r=i),r}function intInRange$1(e,t,i){return e>i&&(e=i),e255?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;tt(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=n&&e=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{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<>3)*_NeuQuant$1._radiusBias,l=s>>_NeuQuant$1._radiusBiasShift;l<=1&&(l=0);for(let e=0;e>>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=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>>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(;lo;){const e=this._radPower[h++]/_NeuQuant$1._alphaRadBias;if(lo){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<>_NeuQuant$1._initialBiasShift-networkBiasShift$1);f>_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<>3)*_NeuQuantFloat$1._radiusBias,l=s>>_NeuQuantFloat$1._radiusBiasShift;l<=1&&(l=0);for(let e=0;e=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{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(;lo;){const e=this._radPower[h++]/_NeuQuantFloat$1._alphaRadBias;if(lo){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<>_NeuQuantFloat$1._initialBiasShift-networkBiasShift2$1);f>_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+e))}_colorStats1D(e){const t=this._histogram,i=e.getPointArray(),r=i.length;for(let e=0;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;uthis._colors;){a.length=0;for(let e=0;e3*this._colors?this._initialDistance:this._distanceIncrement}if(ot.distance-e.distance));let e=0;for(;o=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;i0){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;i1?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;e0?(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),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;_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;tAbstractImageQuantizer$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(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=0&&i+u=0&&r+et&&(e.length=t);const i=e.length;for(let t=0;t=0&&e.x=0&&e.y{const s=i[e+n*r];let{r:l,g:u,b:h,a:c}=s;for(let e=0;essim$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;iprocess.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>8&16777215;e.add(r)}i+=4}const n=new Array(e.size),a=e.values();for(i=0;ie-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.push(new n(e))})),t},e.getColorInfo=function(e,t){let i=!1;const r=[];for(let t=0;t256)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;ee-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]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>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;ea.width)for(let t=0;t0)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{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<>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>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<0&&!e[o-1];)o--;a.push({children:[],index:0});var s,l=a[0];for(i=0;i0;){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+10)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<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<>4,0===f)a<15?(v=b(a)+(1<>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=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;w255?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>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>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>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;Qm){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=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.length0&&(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(;t0&&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>>8;return!0},n.prototype.crc32=function(){return~this._crc},n.crc32=function(e){let t=-1;for(let i=0;i>>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=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=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;a0?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;a0?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=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=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=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=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;t1){let t=1/0;for(let i=0;in?t[a-r]:0;t[a]=i+o}},o.prototype._unFilterType2=function(e,t,i){let r=this._lastLine;for(let n=0;nn?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;sa?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;o0&&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;ithis._palette.length)return void this.error(new Error("More transparent colors than palette size"));for(let t=0;t0?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=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 * @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=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=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=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-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;t0)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>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;al?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||ei.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=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.chunkSizei.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+e.chunkSize);if(e.windowBits&&(e.windowBitsi.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+e.windowBits);if(e.level&&(e.leveli.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+e.level);if(e.memLevel&&(e.memLeveli.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(ei.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=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;as&&(i=s-l),a=i;a>=0;a--){for(var c=!0,f=0;fn&&(r=n):r=n;var a=t.length;r>a/2&&(r=a/2);for(var o=0;o239?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);nt&&(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>>=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;rr)&&(i=r);for(var n="",a=t;ai)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||te.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>>=0,t>>>=0,i||O(e,t,this.length);for(var r=this[e],n=1,a=0;++a>>=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=(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>>=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>>=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=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=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>>=0,i=void 0===i?this.length:i>>>0,e||(e=0),"number"==typeof e)for(a=t;a55295&&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>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=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;r0&&(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=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=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=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;c1&&"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){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 */ i.read=function(e,t,i,r,n){var a,o,s=8*n-r-1,l=(1<>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<>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<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-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>>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>>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]&&ao){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.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=F&&(e.ins_h=(e.ins_h<=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<=F&&(e.ins_h=(e.ins_h<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<=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]&&ne.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<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.gzindexo&&(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.gzindexo&&(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<>>=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,_-=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)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,x2;)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<>3,m&=(1<<(_-=E<<3))-1,e.next_in=a,e.next_out=s,e.avail_in=a>>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.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>>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<>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++]<>>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++]<>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++]<>>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>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++]<>>=7&se,se-=7&se,i.mode=q;break}for(;se<3;){if(0===ne)break e;ne--,oe+=X[te++]<>>=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++]<>>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++]<>>=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>>=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>>16&255,ge=65535&Se,!((me=Se>>>24)<=se);){if(0===ne)break e;ne--,oe+=X[te++]<>>=me,se-=me,i.lens[i.have++]=ge;else{if(16===ge){for(ke=me+2;se>>=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>>=me)),oe>>>=3,se-=3}else{for(ke=me+7;se>>=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<>>16&255,ge=65535&Se,!((me=Se>>>24)<=se);){if(0===ne)break e;ne--,oe+=X[te++]<>be)])>>>16&255,ge=65535&Se,!(be+(me=Se>>>24)<=se);){if(0===ne)break e;ne--,oe+=X[te++]<>>=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>>=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<>>16&255,ge=65535&Se,!((me=Se>>>24)<=se);){if(0===ne)break e;ne--,oe+=X[te++]<>be)])>>>16&255,ge=65535&Se,!(be+(me=Se>>>24)<=se);){if(0===ne)break e;ne--,oe+=X[te++]<>>=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>>=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++]<=1&&0===U[C];C--);if(R>C&&(R=C),0===C)return m[_++]=20971520,m[_++]=20971520,b.bits=1,0;for(B=1;B0&&(e===s||1!==C))return-1;for(Z[1]=0,T=1;Ta||e===u&&O>o)return 1;for(;;){S=T-F,g[P]k?(A=j[G+g[P]],I=$[L+g[P]]):(A=96,I=0),y=1<>F)+(w-=y)]=S<<24|A<<16|I}while(0!==w);for(y=1<>=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+Fa||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<>v-e.bi_valid,e.bi_valid+=i-v):(e.bi_buf|=t<>>=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;ip&&(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>=7;r8?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]>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=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>>=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;t0?(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=[];++d1)for(var i=1;i */ 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;s0)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=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.length0,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=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-e0?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;a0,!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-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;t0?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 en.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;n0,(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=0?(n>0&&(e.lastNeed=n-1),n):--r=0?(n>0&&(e.lastNeed=n-2),n):--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,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}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+"�":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=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=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-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{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=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<>f-e.bi_valid,e.bi_valid+=i-f):(e.bi_buf|=t<>>=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;t8?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]>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_&&(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>=7;r0?(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=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>>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>>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]&&ao){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<=w&&(e.ins_h=(e.ins_h<=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<=w&&(e.ins_h=(e.ins_h<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<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<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.gzindexc&&(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.gzindexc&&(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]&&ae.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<=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>>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;r4)u[n++]=65533,i+=s-1;else{for(o&=2===s?31:3===s?15:7;s>1&&i1?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<>>=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,p-=w),p<15&&(d+=S[r++]<>>=w=y>>>24,p-=w,16&(w=y>>>16&255)){if(x=65535&y,p<(w&=15)&&(d+=S[r++]<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,w2;)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<>3,d&=(1<<(p-=v<<3))-1,e.next_in=r,e.next_out=a,e.avail_in=r=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;A0&&(0===o||1!==I))return-1;for(O[1]=0,k=1;k852||2===o&&C>592)return 1;for(;;){w=k-P,f[S]y?(v=D[$+f[S]],x=z[F+f[S]]):(v=96,x=0),p=1<>P)+(m-=p)]=w<<24|v<<16|x}while(0!==m);for(p=1<>=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+P852||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.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>>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<>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++]<>>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++]<>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++]<>>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>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++]<>>=7&S,S-=7&S,m.mode=27;break}for(;S<3;){if(0===w)break e;w--,x+=_[b++]<>>=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++]<>>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++]<>>=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>>=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>>16&255,R=65535&U,!((B=U>>>24)<=S);){if(0===w)break e;w--,x+=_[b++]<>>=B,S-=B,m.lens[m.have++]=R;else{if(16===R){for(L=B+2;S>>=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>>=B)),x>>>=3,S-=3}else{for(L=B+7;S>>=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<>>16&255,R=65535&U,!((B=U>>>24)<=S);){if(0===w)break e;w--,x+=_[b++]<>z)])>>>16&255,R=65535&U,!(z+(B=U>>>24)<=S);){if(0===w)break e;w--,x+=_[b++]<>>=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>>=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<>>16&255,R=65535&U,!((B=U>>>24)<=S);){if(0===w)break e;w--,x+=_[b++]<>z)])>>>16&255,R=65535&U,!(z+(B=U>>>24)<=S);){if(0===w)break e;w--,x+=_[b++]<>>=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>>=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++]<=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;i0;)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+10)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>>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<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<>4,0==(n=15&a))h<15?(B=O(h)+(1<>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;_=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=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>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>4,F=15&i[l+1];B>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>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>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;n4)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;h3&&(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>>3,w=Math.ceil(g*b*f/8);if(16==g&&!r.isLE&&null==r.t33422)for(var v=0;v>>8&255}else if(3==b)for(p=3;p>3^16368]|I[x+1]<<8)>>(7&v)&~(-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;dh&&(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>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>3-T(2)),S[u]?0!=(s=T(8))&&(k[u]-=128<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>>=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>>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>>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;W0;)Q[W++]=T,Y--;var K=(b-1)%3,J=1!=K?L:0,X=0!=K?U:0;for(Z=0;Z>>1)+J,te=Z*L;for(j=0;j>>1,re=2*L,ne=2*U;for(Z=0;Z>14-2*he&3;var ce=le[ue];if(0!=ce)for(Z=0;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>>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>>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;F1&&(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>>4),0)<<1)<>>1)&1<>>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>>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>>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]<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 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>>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>>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>>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>>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=0&&l<128)for(var u=0;u=-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>>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>>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>>3>>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=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>>3>>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>>3>>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>>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<>>----------------");for(var h=0;hr.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;w4&&(t.writeUint(r,n,l),_=l),1==f||7==f)for(var g=0;g4&&(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>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>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>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>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>>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=4)for(g=0;g1&&e.t338&&0!=e.t338[0];for(p=0;p>>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>>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;pn&&(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>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>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&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>(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<>>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>4,15&k]}}else if(65476==w)for(var S=t+v-2;t>>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;uP&&(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>>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>>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>>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<=8);t&&(i<<=t,r-=t,i|=e[e.j]>>>r&(1<f&&c>>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>>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>>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=ai;b8&&(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>>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.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<{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(;re.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.lengthr.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.lengthe.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.valuer?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.datar.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"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.valuenew 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.datar.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{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_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.valuenew 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.lengthr.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{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.lengththis._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.sizer.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;sm?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;o0?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_?0:e.bitmap.width,i+=w[f],r+=v[f],n+=x[f],a+=E[f];for(d=o<<2,s=0;s>>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;ee.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.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 */ read:function(e,t,i,r,n){var a,o,s=8*n-r-1,l=(1<>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<>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<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>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,r0&&!this.endOfStream;){const t=Math.min(n,1048576),r=await this.readFromStream(e,i+a,t);if(a+=r,r{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})t)return this.position+=t,t}return this.position+=e,e}async close(){}normalizeOptions(e,t){if(t&&void 0!==t.position&&t.position0)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)&&n0){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[...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;i127&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=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("")){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=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;e1)&&(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;r4,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;ee())),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{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""}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;e0&&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=c)){d+=h;break}f+=i,d=f,h-=c}while(h>0&&f=l)){h+=s;break}u=d,h=u,s-=l}while(s>0&&u3&&(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;e0?n[t-4]:2*n[t]-n[t+4],h=n[t],c=n[t+4],f=a0?p[t-4*c]:2*p[t]-p[t+4*c],u=p[t],h=p[t+4*c],f=n1)for(let e=0;e{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;ti)break e}f++}if(h=e.getPixelColor(s,0),!u.west)e:for(let t=0;ti)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=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;tt 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;rn?"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(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{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);si?(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{})}=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{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=0&&o.y{const o=e.bitmap.data[a]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 rt&&(r=t),r>i&&(r=i),r}function intInRange(e,t,i){return e>i&&(e=i),e255?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;tt(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=n&&e=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{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<>3)*_NeuQuant._radiusBias,l=s>>_NeuQuant._radiusBiasShift;l<=1&&(l=0);for(let e=0;e>>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=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>>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(;lo;){const e=this._radPower[h++]/_NeuQuant._alphaRadBias;if(lo){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<>_NeuQuant._initialBiasShift-networkBiasShift);f>_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<>3)*_NeuQuantFloat._radiusBias,l=s>>_NeuQuantFloat._radiusBiasShift;l<=1&&(l=0);for(let e=0;e=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{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(;lo;){const e=this._radPower[h++]/_NeuQuantFloat._alphaRadBias;if(lo){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<>_NeuQuantFloat._initialBiasShift-networkBiasShift2);f>_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+e))}_colorStats1D(e){const t=this._histogram,i=e.getPointArray(),r=i.length;for(let e=0;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;uthis._colors;){a.length=0;for(let e=0;e3*this._colors?this._initialDistance:this._distanceIncrement}if(ot.distance-e.distance));let e=0;for(;o=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;i0){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;i1?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;e0?(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),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;_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;tAbstractImageQuantizer,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(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=0&&i+u=0&&r+et&&(e.length=t);const i=e.length;for(let t=0;t=0&&e.x=0&&e.y{const s=i[e+n*r];let{r:l,g:u,b:h,a:c}=s;for(let e=0;essim});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;in.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 element");for(var n=r.getElementsByTagName("page"),a=0;a3)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=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=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{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{if(e.startsWith(""===e[t+1])return t+2;t++}}return t})(e,t)})(e),r=[];const n=()=>e[i],a=()=>t!==c&&i'"'===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=""===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""!==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;eCharacterJimp.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;eh?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