UNPKG

jimp

Version:

An image processing library written entirely in JavaScript.

233 lines • 730 kB
var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}"undefined"==typeof self&&"object"==typeof t&&(t.self=t);for(var n={},i={byteLength:function(t){var e=c(t),n=e[0],i=e[1];return 3*(n+i)/4-i},toByteArray:function(t){var e,n,i=c(t),r=i[0],s=i[1],h=new o(function(t,e,n){return 3*(e+n)/4-n}(0,r,s)),l=0,f=s>0?r-4:r;for(n=0;n<f;n+=4)e=a[t.charCodeAt(n)]<<18|a[t.charCodeAt(n+1)]<<12|a[t.charCodeAt(n+2)]<<6|a[t.charCodeAt(n+3)],h[l++]=e>>16&255,h[l++]=e>>8&255,h[l++]=255&e;2===s&&(e=a[t.charCodeAt(n)]<<2|a[t.charCodeAt(n+1)]>>4,h[l++]=255&e);1===s&&(e=a[t.charCodeAt(n)]<<10|a[t.charCodeAt(n+1)]<<4|a[t.charCodeAt(n+2)]>>2,h[l++]=e>>8&255,h[l++]=255&e);return h},fromByteArray:function(t){for(var e,n=t.length,i=n%3,a=[],o=16383,s=0,h=n-i;s<h;s+=o)a.push(f(t,s,s+o>h?h:s+o));1===i?(e=t[n-1],a.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],a.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"="));return a.join("")}},r=[],a=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",h=0;h<64;++h)r[h]=s[h],a[s.charCodeAt(h)]=h;function c(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function l(t){return r[t>>18&63]+r[t>>12&63]+r[t>>6&63]+r[63&t]}function f(t,e,n){for(var i,r=[],a=e;a<n;a+=3)i=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),r.push(l(i));return r.join("")}a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63;var u,d,p={};
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */p.read=function(t,e,n,i,r){var a,o,s=8*r-i-1,h=(1<<s)-1,c=h>>1,l=-7,f=n?r-1:0,u=n?-1:1,d=t[e+f];for(f+=u,a=d&(1<<-l)-1,d>>=-l,l+=s;l>0;a=256*a+t[e+f],f+=u,l-=8);for(o=a&(1<<-l)-1,a>>=-l,l+=i;l>0;o=256*o+t[e+f],f+=u,l-=8);if(0===a)a=1-c;else{if(a===h)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,i),a-=c}return(d?-1:1)*o*Math.pow(2,a-i)},p.write=function(t,e,n,i,r,a){var o,s,h,c=8*a-r-1,l=(1<<c)-1,f=l>>1,u=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:a-1,p=i?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=l):(o=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-o))<1&&(o--,h*=2),(e+=o+f>=1?u/h:u*Math.pow(2,1-f))*h>=2&&(o++,h/=2),o+f>=l?(s=0,o=l):o+f>=1?(s=(e*h-1)*Math.pow(2,r),o+=f):(s=e*Math.pow(2,f-1)*Math.pow(2,r),o=0));r>=8;t[n+d]=255&s,d+=p,s/=256,r-=8);for(o=o<<r|s,c+=r;c>0;t[n+d]=255&o,d+=p,o/=256,c-=8);t[n+d-p]|=128*m},
/*!
 * The buffer module from node.js, for the browser.
 *
 * @author   Feross Aboukhadijeh <https://feross.org>
 * @license  MIT
 */
function(t){const e=i,n=p,r="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=s,t.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},t.INSPECT_MAX_BYTES=50;const a=2147483647;function o(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,s.prototype),e}function s(t,e,n){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return l(t)}return h(t,e,n)}function h(t,e,n){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const n=0|m(t,e);let i=o(n);const r=i.write(t,e);r!==n&&(i=i.slice(0,r));return i}(t,e);if(ArrayBuffer.isView(t))return function(t){if(J(t,Uint8Array)){const e=new Uint8Array(t);return u(e.buffer,e.byteOffset,e.byteLength)}return f(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(J(t,ArrayBuffer)||t&&J(t.buffer,ArrayBuffer))return u(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(J(t,SharedArrayBuffer)||t&&J(t.buffer,SharedArrayBuffer)))return u(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const i=t.valueOf&&t.valueOf();if(null!=i&&i!==t)return s.from(i,e,n);const r=function(t){if(s.isBuffer(t)){const e=0|d(t.length),n=o(e);return 0===n.length||t.copy(n,0,0,e),n}if(void 0!==t.length)return"number"!=typeof t.length||Y(t.length)?o(0):f(t);if("Buffer"===t.type&&Array.isArray(t.data))return f(t.data)}(t);if(r)return r;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return s.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function c(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function l(t){return c(t),o(t<0?0:0|d(t))}function f(t){const e=t.length<0?0:0|d(t.length),n=o(e);for(let i=0;i<e;i+=1)n[i]=255&t[i];return n}function u(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');let i;return i=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n),Object.setPrototypeOf(i,s.prototype),i}function d(t){if(t>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function m(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||J(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const n=t.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===n)return 0;let r=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return W(t).length;default:if(r)return i?-1:q(t).length;e=(""+e).toLowerCase(),r=!0}}function g(t,e,n){let i=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return B(this,e,n);case"utf8":case"utf-8":return E(this,e,n);case"ascii":return S(this,e,n);case"latin1":case"binary":return z(this,e,n);case"base64":return M(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,n);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}function b(t,e,n){const i=t[e];t[e]=t[n],t[n]=i}function w(t,e,n,i,r){if(0===t.length)return-1;if("string"==typeof n?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),Y(n=+n)&&(n=r?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(r)return-1;n=t.length-1}else if(n<0){if(!r)return-1;n=0}if("string"==typeof e&&(e=s.from(e,i)),s.isBuffer(e))return 0===e.length?-1:y(t,e,n,i,r);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):y(t,[e],n,i,r);throw new TypeError("val must be string, number or Buffer")}function y(t,e,n,i,r){let a,o=1,s=t.length,h=e.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(t.length<2||e.length<2)return-1;o=2,s/=2,h/=2,n/=2}function c(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(r){let i=-1;for(a=n;a<s;a++)if(c(t,a)===c(e,-1===i?0:a-i)){if(-1===i&&(i=a),a-i+1===h)return i*o}else-1!==i&&(a-=a-i),i=-1}else for(n+h>s&&(n=s-h),a=n;a>=0;a--){let n=!0;for(let i=0;i<h;i++)if(c(t,a+i)!==c(e,i)){n=!1;break}if(n)return a}return-1}function _(t,e,n,i){n=Number(n)||0;const r=t.length-n;i?(i=Number(i))>r&&(i=r):i=r;const a=e.length;let o;for(i>a/2&&(i=a/2),o=0;o<i;++o){const i=parseInt(e.substr(2*o,2),16);if(Y(i))return o;t[n+o]=i}return o}function v(t,e,n,i){return V(q(e,t.length-n),t,n,i)}function x(t,e,n,i){return V(function(t){const e=[];for(let n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,i)}function k(t,e,n,i){return V(W(e),t,n,i)}function A(t,e,n,i){return V(function(t,e){let n,i,r;const a=[];for(let o=0;o<t.length&&!((e-=2)<0);++o)n=t.charCodeAt(o),i=n>>8,r=n%256,a.push(r),a.push(i);return a}(e,t.length-n),t,n,i)}function M(t,n,i){return 0===n&&i===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(n,i))}function E(t,e,n){n=Math.min(t.length,n);const i=[];let r=e;for(;r<n;){const e=t[r];let a=null,o=e>239?4:e>223?3:e>191?2:1;if(r+o<=n){let n,i,s,h;switch(o){case 1:e<128&&(a=e);break;case 2:n=t[r+1],128==(192&n)&&(h=(31&e)<<6|63&n,h>127&&(a=h));break;case 3:n=t[r+1],i=t[r+2],128==(192&n)&&128==(192&i)&&(h=(15&e)<<12|(63&n)<<6|63&i,h>2047&&(h<55296||h>57343)&&(a=h));break;case 4:n=t[r+1],i=t[r+2],s=t[r+3],128==(192&n)&&128==(192&i)&&128==(192&s)&&(h=(15&e)<<18|(63&n)<<12|(63&i)<<6|63&s,h>65535&&h<1114112&&(a=h))}}null===a?(a=65533,o=1):a>65535&&(a-=65536,i.push(a>>>10&1023|55296),a=56320|1023&a),i.push(a),r+=o}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let n="",i=0;for(;i<e;)n+=String.fromCharCode.apply(String,t.slice(i,i+=I));return n}(i)}t.kMaxLength=a,s.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),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}}),s.poolSize=8192,s.from=function(t,e,n){return h(t,e,n)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array),s.alloc=function(t,e,n){return function(t,e,n){return c(t),t<=0?o(t):void 0!==e?"string"==typeof n?o(t).fill(e,n):o(t).fill(e):o(t)}(t,e,n)},s.allocUnsafe=function(t){return l(t)},s.allocUnsafeSlow=function(t){return l(t)},s.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==s.prototype},s.compare=function(t,e){if(J(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),J(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(t)||!s.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let n=t.length,i=e.length;for(let r=0,a=Math.min(n,i);r<a;++r)if(t[r]!==e[r]){n=t[r],i=e[r];break}return n<i?-1:i<n?1:0},s.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},s.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return s.alloc(0);let n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;const i=s.allocUnsafe(e);let r=0;for(n=0;n<t.length;++n){let e=t[n];if(J(e,Uint8Array))r+e.length>i.length?(s.isBuffer(e)||(e=s.from(e)),e.copy(i,r)):Uint8Array.prototype.set.call(i,e,r);else{if(!s.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(i,r)}r+=e.length}return i},s.byteLength=m,s.prototype._isBuffer=!0,s.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)b(this,e,e+1);return this},s.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)b(this,e,e+3),b(this,e+1,e+2);return this},s.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)b(this,e,e+7),b(this,e+1,e+6),b(this,e+2,e+5),b(this,e+3,e+4);return this},s.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?E(this,0,t):g.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){let e="";const n=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(e+=" ... "),"<Buffer "+e+">"},r&&(s.prototype[r]=s.prototype.inspect),s.prototype.compare=function(t,e,n,i,r){if(J(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===i&&(i=0),void 0===r&&(r=this.length),e<0||n>t.length||i<0||r>this.length)throw new RangeError("out of range index");if(i>=r&&e>=n)return 0;if(i>=r)return-1;if(e>=n)return 1;if(this===t)return 0;let a=(r>>>=0)-(i>>>=0),o=(n>>>=0)-(e>>>=0);const h=Math.min(a,o),c=this.slice(i,r),l=t.slice(e,n);for(let t=0;t<h;++t)if(c[t]!==l[t]){a=c[t],o=l[t];break}return a<o?-1:o<a?1:0},s.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},s.prototype.indexOf=function(t,e,n){return w(this,t,e,n,!0)},s.prototype.lastIndexOf=function(t,e,n){return w(this,t,e,n,!1)},s.prototype.write=function(t,e,n,i){if(void 0===e)i="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)i=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(n)?(n>>>=0,void 0===i&&(i="utf8")):(i=n,n=void 0)}const r=this.length-e;if((void 0===n||n>r)&&(n=r),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let a=!1;for(;;)switch(i){case"hex":return _(this,t,e,n);case"utf8":case"utf-8":return v(this,t,e,n);case"ascii":case"latin1":case"binary":return x(this,t,e,n);case"base64":return k(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,n);default:if(a)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),a=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function S(t,e,n){let i="";n=Math.min(t.length,n);for(let r=e;r<n;++r)i+=String.fromCharCode(127&t[r]);return i}function z(t,e,n){let i="";n=Math.min(t.length,n);for(let r=e;r<n;++r)i+=String.fromCharCode(t[r]);return i}function B(t,e,n){const i=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>i)&&(n=i);let r="";for(let i=e;i<n;++i)r+=X[t[i]];return r}function C(t,e,n){const i=t.slice(e,n);let r="";for(let t=0;t<i.length-1;t+=2)r+=String.fromCharCode(i[t]+256*i[t+1]);return r}function P(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,n,i,r,a){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||e<a)throw new RangeError('"value" argument is out of bounds');if(n+i>t.length)throw new RangeError("Index out of range")}function U(t,e,n,i,r){j(e,i,r,t,n,7);let a=Number(e&BigInt(4294967295));t[n++]=a,a>>=8,t[n++]=a,a>>=8,t[n++]=a,a>>=8,t[n++]=a;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o,n}function O(t,e,n,i,r){j(e,i,r,t,n,7);let a=Number(e&BigInt(4294967295));t[n+7]=a,a>>=8,t[n+6]=a,a>>=8,t[n+5]=a,a>>=8,t[n+4]=a;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[n+3]=o,o>>=8,t[n+2]=o,o>>=8,t[n+1]=o,o>>=8,t[n]=o,n+8}function L(t,e,n,i,r,a){if(n+i>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function R(t,e,i,r,a){return e=+e,i>>>=0,a||L(t,0,i,4),n.write(t,e,i,r,23,4),i+4}function F(t,e,i,r,a){return e=+e,i>>>=0,a||L(t,0,i,8),n.write(t,e,i,r,52,8),i+8}s.prototype.slice=function(t,e){const n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t);const i=this.subarray(t,e);return Object.setPrototypeOf(i,s.prototype),i},s.prototype.readUintLE=s.prototype.readUIntLE=function(t,e,n){t>>>=0,e>>>=0,n||P(t,e,this.length);let i=this[t],r=1,a=0;for(;++a<e&&(r*=256);)i+=this[t+a]*r;return i},s.prototype.readUintBE=s.prototype.readUIntBE=function(t,e,n){t>>>=0,e>>>=0,n||P(t,e,this.length);let i=this[t+--e],r=1;for(;e>0&&(r*=256);)i+=this[t+--e]*r;return i},s.prototype.readUint8=s.prototype.readUInt8=function(t,e){return t>>>=0,e||P(t,1,this.length),this[t]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||P(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||P(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||P(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||P(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readBigUInt64LE=K(function(t){G(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||H(t,this.length-8);const i=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,r=this[++t]+256*this[++t]+65536*this[++t]+n*2**24;return BigInt(i)+(BigInt(r)<<BigInt(32))}),s.prototype.readBigUInt64BE=K(function(t){G(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||H(t,this.length-8);const i=e*2**24+65536*this[++t]+256*this[++t]+this[++t],r=this[++t]*2**24+65536*this[++t]+256*this[++t]+n;return(BigInt(i)<<BigInt(32))+BigInt(r)}),s.prototype.readIntLE=function(t,e,n){t>>>=0,e>>>=0,n||P(t,e,this.length);let i=this[t],r=1,a=0;for(;++a<e&&(r*=256);)i+=this[t+a]*r;return r*=128,i>=r&&(i-=Math.pow(2,8*e)),i},s.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||P(t,e,this.length);let i=e,r=1,a=this[t+--i];for(;i>0&&(r*=256);)a+=this[t+--i]*r;return r*=128,a>=r&&(a-=Math.pow(2,8*e)),a},s.prototype.readInt8=function(t,e){return t>>>=0,e||P(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||P(t,2,this.length);const n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt16BE=function(t,e){t>>>=0,e||P(t,2,this.length);const n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||P(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||P(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readBigInt64LE=K(function(t){G(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||H(t,this.length-8);const i=this[t+4]+256*this[t+5]+65536*this[t+6]+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)}),s.prototype.readBigInt64BE=K(function(t){G(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||H(t,this.length-8);const i=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+n)}),s.prototype.readFloatLE=function(t,e){return t>>>=0,e||P(t,4,this.length),n.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||P(t,4,this.length),n.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||P(t,8,this.length),n.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||P(t,8,this.length),n.read(this,t,!1,52,8)},s.prototype.writeUintLE=s.prototype.writeUIntLE=function(t,e,n,i){if(t=+t,e>>>=0,n>>>=0,!i){T(this,t,e,n,Math.pow(2,8*n)-1,0)}let r=1,a=0;for(this[e]=255&t;++a<n&&(r*=256);)this[e+a]=t/r&255;return e+n},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(t,e,n,i){if(t=+t,e>>>=0,n>>>=0,!i){T(this,t,e,n,Math.pow(2,8*n)-1,0)}let r=n-1,a=1;for(this[e+r]=255&t;--r>=0&&(a*=256);)this[e+r]=t/a&255;return e+n},s.prototype.writeUint8=s.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||T(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||T(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeBigUInt64LE=K(function(t,e=0){return U(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeBigUInt64BE=K(function(t,e=0){return O(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeIntLE=function(t,e,n,i){if(t=+t,e>>>=0,!i){const i=Math.pow(2,8*n-1);T(this,t,e,n,i-1,-i)}let r=0,a=1,o=0;for(this[e]=255&t;++r<n&&(a*=256);)t<0&&0===o&&0!==this[e+r-1]&&(o=1),this[e+r]=(t/a|0)-o&255;return e+n},s.prototype.writeIntBE=function(t,e,n,i){if(t=+t,e>>>=0,!i){const i=Math.pow(2,8*n-1);T(this,t,e,n,i-1,-i)}let r=n-1,a=1,o=0;for(this[e+r]=255&t;--r>=0&&(a*=256);)t<0&&0===o&&0!==this[e+r+1]&&(o=1),this[e+r]=(t/a|0)-o&255;return e+n},s.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||T(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||T(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeBigInt64LE=K(function(t,e=0){return U(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),s.prototype.writeBigInt64BE=K(function(t,e=0){return O(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),s.prototype.writeFloatLE=function(t,e,n){return R(this,t,e,!0,n)},s.prototype.writeFloatBE=function(t,e,n){return R(this,t,e,!1,n)},s.prototype.writeDoubleLE=function(t,e,n){return F(this,t,e,!0,n)},s.prototype.writeDoubleBE=function(t,e,n){return F(this,t,e,!1,n)},s.prototype.copy=function(t,e,n,i){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),i||0===i||(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<n&&(i=n),i===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-n&&(i=t.length-e+n);const r=i-n;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),e),r},s.prototype.fill=function(t,e,n,i){if("string"==typeof t){if("string"==typeof e?(i=e,e=0,n=this.length):"string"==typeof n&&(i=n,n=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!s.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===t.length){const e=t.charCodeAt(0);("utf8"===i&&e<128||"latin1"===i)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;let r;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(r=e;r<n;++r)this[r]=t;else{const a=s.isBuffer(t)?t:s.from(t,i),o=a.length;if(0===o)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(r=0;r<n-e;++r)this[r+e]=a[r%o]}return this};const D={};function N(t,e,n){D[t]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function $(t){let e="",n=t.length;const i="-"===t[0]?1:0;for(;n>=i+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function j(t,e,n,i,r,a){if(t>n||t<e){const n="bigint"==typeof e?"n":"";let i;throw i=0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(a+1)}${n}`:`>= -(2${n} ** ${8*(a+1)-1}${n}) and < 2 ** ${8*(a+1)-1}${n}`,new D.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,n){G(e,"offset"),void 0!==t[e]&&void 0!==t[e+n]||H(e,t.length-(n+1))}(i,r,a)}function G(t,e){if("number"!=typeof t)throw new D.ERR_INVALID_ARG_TYPE(e,"number",t)}function H(t,e,n){if(Math.floor(t)!==t)throw G(t,n),new D.ERR_OUT_OF_RANGE("offset","an integer",t);if(e<0)throw new D.ERR_BUFFER_OUT_OF_BOUNDS;throw new D.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${e}`,t)}N("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),N("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),N("ERR_OUT_OF_RANGE",function(t,e,n){let i=`The value of "${t}" is out of range.`,r=n;return Number.isInteger(n)&&Math.abs(n)>2**32?r=$(String(n)):"bigint"==typeof n&&(r=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(r=$(r)),r+="n"),i+=` It must be ${e}. Received ${r}`,i},RangeError);const Z=/[^+/0-9A-Za-z-_]/g;function q(t,e){let n;e=e||1/0;const i=t.length;let r=null;const a=[];for(let o=0;o<i;++o){if(n=t.charCodeAt(o),n>55295&&n<57344){if(!r){if(n>56319){(e-=3)>-1&&a.push(239,191,189);continue}if(o+1===i){(e-=3)>-1&&a.push(239,191,189);continue}r=n;continue}if(n<56320){(e-=3)>-1&&a.push(239,191,189),r=n;continue}n=65536+(r-55296<<10|n-56320)}else r&&(e-=3)>-1&&a.push(239,191,189);if(r=null,n<128){if((e-=1)<0)break;a.push(n)}else if(n<2048){if((e-=2)<0)break;a.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;a.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return a}function W(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(Z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function V(t,e,n,i){let r;for(r=0;r<i&&!(r+n>=e.length||r>=t.length);++r)e[r+n]=t[r];return r}function J(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Y(t){return t!=t}const X=function(){const t="0123456789abcdef",e=new Array(256);for(let n=0;n<16;++n){const i=16*n;for(let r=0;r<16;++r)e[i+r]=t[n]+t[r]}return e}();function K(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}}(n),function(t){t[t.BITMAP_INFO_HEADER=40]="BITMAP_INFO_HEADER",t[t.BITMAP_V2_INFO_HEADER=52]="BITMAP_V2_INFO_HEADER",t[t.BITMAP_V3_INFO_HEADER=56]="BITMAP_V3_INFO_HEADER",t[t.BITMAP_V4_HEADER=108]="BITMAP_V4_HEADER",t[t.BITMAP_V5_HEADER=124]="BITMAP_V5_HEADER"}(u||(u={})),function(t){t[t.NONE=0]="NONE",t[t.BI_RLE8=1]="BI_RLE8",t[t.BI_RLE4=2]="BI_RLE4",t[t.BI_BIT_FIELDS=3]="BI_BIT_FIELDS",t[t.BI_ALPHA_BIT_FIELDS=6]="BI_ALPHA_BIT_FIELDS"}(d||(d={}));const m=[1,4,8,16,24,32];class g{constructor(t,{toRGBA:e,maxResolutionInMP:n=100}={toRGBA:!1}){if(this.buffer=t,this.toRGBA=!!e,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.pos=Math.max(this.pos,this.offset),this.validate(n),this.parseRGBA()}validate(t){const{width:e,height:n,bitPP:i}=this;if(0===e||e>2147483647||0===n)throw new Error(`Invalid BMP dimensions ${e}x${n}`);if(!m.includes(i))throw new Error(`Unsupported BMP bit depth ${i}`);if(e*n>1e6*t)throw new Error(`BMP dimensions ${e}x${n} exceed the maximum resolution of ${t} megapixels`);if(this.offset>this.buffer.length)throw new Error(`BMP pixel data offset ${this.offset} is past the end of the file`);const r=Math.max(this.buffer.length-this.pos,0);if(this.compression===d.BI_RLE8&&8===i||this.compression===d.BI_RLE4&&4===i){if(e*n>255*Math.ceil(r/2))throw new Error(`BMP data is too short for an RLE image of ${e}x${n}`)}else{if(4*Math.ceil(e*i/32)*(n-1)+Math.ceil(e*i/8)>r)throw new Error(`BMP data is too short for an image of ${e}x${n} at ${i} bits per pixel`)}}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 u))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>u.BITMAP_INFO_HEADER||this.compression===d.BI_BIT_FIELDS||this.compression===d.BI_ALPHA_BIT_FIELDS)&&(this.maskRed=this.readUInt32LE(),this.maskGreen=this.readUInt32LE(),this.maskBlue=this.readUInt32LE()),(this.headerSize>u.BITMAP_V2_INFO_HEADER||this.compression===d.BI_ALPHA_BIT_FIELDS)&&(this.maskAlpha=this.readUInt32LE()),this.headerSize>u.BITMAP_V3_INFO_HEADER&&(this.pos+=u.BITMAP_V4_HEADER-u.BITMAP_V3_INFO_HEADER),this.headerSize>u.BITMAP_V4_HEADER&&(this.pos+=u.BITMAP_V5_HEADER-u.BITMAP_V4_HEADER),this.bitPP<=8||this.colors>0){const t=0===this.colors?1<<this.bitPP:this.colors;this.palette=new Array(t);for(let e=0;e<t;e++){const t=this.buffer.readUInt8(this.pos++),n=this.buffer.readUInt8(this.pos++),i=this.buffer.readUInt8(this.pos++),r=this.buffer.readUInt8(this.pos++);this.palette[e]={red:i,green:n,blue:t,quad:r}}}this.height<0&&(this.height*=-1,this.bottomUp=!1);const t=function(t,e,n,i){const r=1+~t&t,a=1+~e&e,o=1+~n&n,s=1+~i&i,h=t/r+1,c=e/a+1,l=n/o+1,f=i/s+1;return{shiftRed:e=>(e&t)/r*256/h,shiftGreen:t=>(t&e)/a*256/c,shiftBlue:t=>(t&n)/o*256/l,shiftAlpha:0!==i?t=>(t&i)/s*256/f:()=>255}}(this.maskRed,this.maskGreen,this.maskBlue,this.maskAlpha);this.shiftRed=t.shiftRed,this.shiftGreen=t.shiftGreen,this.shiftBlue=t.shiftBlue,this.shiftAlpha=t.shiftAlpha}parseRGBA(){switch(this.data=n.Buffer.alloc(this.width*this.height*4),this.bitPP){case 1:this.bit1();break;case 4:this.bit4();break;case 8:this.bit8();break;case 16:this.bit16();break;case 24:this.bit24();break;default:this.bit32()}}bit1(){const t=Math.ceil(this.width/8),e=t%4,n=0!==e?4-e:0;this.scanImage(n,t,(t,e)=>{const n=this.buffer.readUInt8(this.pos++),i=e*this.width*4+8*t*4;for(let e=0;e<8&&8*t+e<this.width;e++)this.setPixelData(i+4*e,n>>7-e&1)})}bit4(){if(this.compression===d.BI_RLE4)return void this.rle(4);const t=Math.ceil(this.width/2),e=t%4,n=0!==e?4-e:0;this.scanImage(n,t,(t,e)=>{const n=this.buffer.readUInt8(this.pos++),i=e*this.width*4+2*t*4;this.setPixelData(i,n>>4),2*t+1<this.width&&this.setPixelData(i+4,15&n)})}bit8(){if(this.compression===d.BI_RLE8)return void this.rle(8);const t=this.width%4,e=0!==t?4-t:0;this.scanImage(e,this.width,(t,e)=>{const n=this.buffer.readUInt8(this.pos++);this.setPixelData(e*this.width*4+4*t,n)})}rle(t){for(let t=0;t<this.data.length;t+=4)this.setPixelData(t,0);const e=this.bottomUp?-1:1;let n=this.bottomUp?this.height-1:0,i=0;const r=(e,n)=>8===t?e:1&n?15&e:e>>4,a=t=>{i<this.width&&this.setPixelData(4*(n*this.width+i),t),i++};for(;n>=0&&n<this.height&&this.pos+1<this.buffer.length;){const o=this.buffer.readUInt8(this.pos++),s=this.buffer.readUInt8(this.pos++);if(0!==o)for(let t=0;t<o;t++)a(r(s,t));else if(0===s)n+=e,i=0;else{if(1===s)break;if(2===s){if(this.pos+1>=this.buffer.length)break;i+=this.buffer.readUInt8(this.pos++),n+=e*this.buffer.readUInt8(this.pos++)}else{const e=8===t?s:Math.ceil(s/2);if(this.pos+e>this.buffer.length)break;for(let e=0;e<s;e++){a(r(this.buffer.readUInt8(this.pos+(8===t?e:e>>1)),e))}this.pos+=e+(1&e)}}}}bit16(){const t=this.width%2*2;this.scanImage(t,this.width,(t,e)=>{const n=e*this.width*4+4*t,i=this.buffer.readUInt16LE(this.pos);this.pos+=2,this.data[n+this.locRed]=this.shiftRed(i),this.data[n+this.locGreen]=this.shiftGreen(i),this.data[n+this.locBlue]=this.shiftBlue(i),this.data[n+this.locAlpha]=this.shiftAlpha(i)})}bit24(){const t=this.width%4;this.scanImage(t,this.width,(t,e)=>{const n=e*this.width*4+4*t,i=this.buffer.readUInt8(this.pos++),r=this.buffer.readUInt8(this.pos++),a=this.buffer.readUInt8(this.pos++);this.data[n+this.locRed]=a,this.data[n+this.locGreen]=r,this.data[n+this.locBlue]=i,this.data[n+this.locAlpha]=0})}bit32(){this.scanImage(0,this.width,(t,e)=>{const n=e*this.width*4+4*t,i=this.readUInt32LE();this.data[n+this.locRed]=this.shiftRed(i),this.data[n+this.locGreen]=this.shiftGreen(i),this.data[n+this.locBlue]=this.shiftBlue(i),this.data[n+this.locAlpha]=this.shiftAlpha(i)})}scanImage(t=0,e=this.width,n){for(let i=this.height-1;i>=0;i--){const r=this.bottomUp?i:this.height-1-i;for(let t=0;t<e;t++)n.call(this,t,r);this.pos+=t}}readUInt32LE(){const t=this.buffer.readUInt32LE(this.pos);return this.pos+=4,t}setPixelData(t,e){var n;const{blue:i,green:r,red:a}=null!==(n=this.palette[e])&&void 0!==n?n:{blue:255,green:255,red:255};this.data[t+this.locAlpha]=0,this.data[t+this.locBlue]=i,this.data[t+this.locGreen]=r,this.data[t+this.locRed]=a}}function b(t){return t.reduce((t,e)=>t<<1|e,0)}function w(t){return(t.quad<<24|t.red<<16|t.green<<8|t.blue)>>>0}class y{constructor(t){if(this.buffer=t.data,this.width=t.width,this.height=t.height,this.headerSize=u.BITMAP_INFO_HEADER,this.flag="BM",this.bitPP=t.bitPP||24,this.offset=54,this.reserved1=t.reserved1||0,this.reserved2=t.reserved2||0,this.planes=1,this.compress=0,this.hr=t.hr||0,this.vr=t.vr||0,this.importantColors=t.importantColors||0,this.palette=t.palette||[],1===this.bitPP||4===this.bitPP||8===this.bitPP){const e=this.palette.length?Math.min(2**this.bitPP,this.palette.length):2;this.colors=Math.min(e,t.colors||e),this.offset+=4*this.colors}else this.colors=0;switch(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 e=this.width*this.bitPP/32,i=Math.ceil(e);this.extraBytes=4*(i-e),this.rawSize=this.height*i*4+2,this.fileSize=this.rawSize+this.offset,this.data=n.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.data.writeUInt16LE(this.reserved1,this.pos),this.pos+=2,this.data.writeUInt16LE(this.reserved2,this.pos),this.pos+=2,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(){let t;this.palette.length?t=this.initColors(1):(this.writeUInt32LE(16777215),this.writeUInt32LE(0),t=(t,e,n)=>.2126*t+.7152*e+.0722*n>127?0:1),this.pos+=1;let e=[];this.writeImage((n,i,r)=>{let a=i;a++;const o=this.buffer[a++],s=this.buffer[a++],h=this.buffer[a++];return e.push(t(h,s,o)),(r+1)%8==0?(this.data[n-1]=b(e),e=[]):r===this.width-1&&e.length>0&&(this.data[n-1]=b(e)<<8-e.length,e=[]),a})}bit4(){const t=this.initColors(4);let e=[];this.writeImage((n,i,r)=>{const a=i+1;return e.push(t(this.buffer[a+2],this.buffer[a+1],this.buffer[a])),(r+1)%2==0?(this.data[n]=e[0]<<4|e[1],e=[]):r===this.width-1&&(this.data[n]=e[0]<<4,e=[]),a+3})}bit8(){const t=this.initColors(8);this.writeImage((e,n)=>{const i=n+1;return this.data[e]=t(this.buffer[i+2],this.buffer[i+1],this.buffer[i]),i+3})}bit16(){this.writeImage((t,e)=>{let n=e+1;const i=this.buffer[n++]/8,r=this.buffer[n++]/8,a=this.buffer[n++]/8<<10|r<<5|i;return this.data[t]=255&a,this.data[t+1]=(65280&a)>>8,n})}bit24(){this.writeImage((t,e)=>{let n=e+1;return this.data[t]=this.buffer[n++],this.data[t+1]=this.buffer[n++],this.data[t+2]=this.buffer[n++],n})}bit32(){this.writeImage((t,e)=>{let n=e;return this.data[t+3]=this.buffer[n++],this.data[t]=this.buffer[n++],this.data[t+1]=this.buffer[n++],this.data[t+2]=this.buffer[n++],n})}writeImage(t){const e=this.extraBytes+this.width*this.bytesInColor;let n=0;for(let i=0;i<this.height;i++)for(let r=0;r<this.width;r++){const a=Math.floor(this.pos+(this.height-1-i)*e+r*this.bytesInColor);n=t.call(this,a,n,r,i)}}initColors(t){if(!this.palette.length)throw new Error(`To encode ${t}-bit BMPs a palette is needed. Please choose up to ${2**t} colors.`);const e=this.palette.slice(0,this.colors);for(const t of e)this.writeUInt32LE(w(t));return function(t){const e=new Map;return(n,i,r)=>{const a=n<<16|i<<8|r;let o=e.get(a);if(void 0===o){let s=1/0;o=0;for(let e=0;e<t.length&&s>0;e++){const a=(t[e].red-n)**2+(t[e].green-i)**2+(t[e].blue-r)**2;a<s&&(s=a,o=e)}e.set(a,o)}return o}}(e)}writeUInt32LE(t){this.data.writeUInt32LE(t,this.pos),this.pos+=4}}function _(t,e){return new g(t,e)}var v=Object.defineProperty,x=(t,e)=>{for(var n in e)v(t,n,{get:e[n],enumerable:!0})},k=(t,e,n)=>(((t,e,n)=>{e in t?v(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n})(t,"symbol"!=typeof e?e+"":e,n),n);x({},{bt709:()=>A});var A={};x(A,{Y:()=>M,x:()=>E,y:()=>I});var M=(t=>(t[t.RED=.2126]="RED",t[t.GREEN=.7152]="GREEN",t[t.BLUE=.0722]="BLUE",t[t.WHITE=1]="WHITE",t))(M||{}),E=(t=>(t[t.RED=.64]="RED",t[t.GREEN=.3]="GREEN",t[t.BLUE=.15]="BLUE",t[t.WHITE=.3127]="WHITE",t))(E||{}),I=(t=>(t[t.RED=.33]="RED",t[t.GREEN=.6]="GREEN",t[t.BLUE=.06]="BLUE",t[t.WHITE=.329]="WHITE",t))(I||{});function S(t){return t>.04045?((t+.055)/1.055)**2.4:t/12.92}function z(t,e,n){return{x:.4124*(t=S(t/255))+.3576*(e=S(e/255))+.1805*(n=S(n/255)),y:.2126*t+.7152*e+.0722*n,z:.0193*t+.1192*e+.9505*n}}x({},{lab2rgb:()=>K,lab2xyz:()=>J,rgb2hsl:()=>F,rgb2lab:()=>H,rgb2xyz:()=>z,xyz2lab:()=>G,xyz2rgb:()=>X});var B={};function C(t){return t*(Math.PI/180)}function P(t,e,n){let i=t;return i<e&&(i=e),i<n&&(i=n),i}function T(t,e,n){let i=t;return i>e&&(i=e),i>n&&(i=n),i}function U(t,e,n){return t>n&&(t=n),t<e&&(t=e),0|t}function O(t){return(t=Math.round(t))>255?t=255:t<0&&(t=0),t}function L(t){return t>255?t=255:t<0&&(t=0),t}function R(t,e){const n=typeof t[0];let i;if("number"===n||"string"===n){const n=Object.create(null);for(let e=0,i=t.length;e<i;e++){const i=t[e];n[i]||0===n[i]||(n[i]=e)}i=t.sort((t,i)=>e(t,i)||n[t]-n[i])}else{const n=t.slice(0);i=t.sort((t,i)=>e(t,i)||n.indexOf(t)-n.indexOf(i))}return i}function F(t,e,n){const i=T(t,e,n),r=P(t,e,n),a=r-i,o=(i+r)/510;let s=0;o>0&&o<1&&(s=a/(o<.5?r+i:510-r-i));let h=0;return a>0&&(h=r===t?(e-n)/a:r===e?2+(n-t)/a:4+(t-e)/a,h*=60,h<0&&(h+=360)),{h:h,s:s,l:o}}x(B,{degrees2radians:()=>C,inRange0to255:()=>L,inRange0to255Rounded:()=>O,intInRange:()=>U,max3:()=>P,min3:()=>T,stableSort:()=>R});var D=.95047,N=1,$=1.08883;function j(t){return t>.008856?t**(1/3):7.787*t+16/116}function G(t,e,n){if(t=j(t/D),e=j(e/N),n=j(n/$),116*e-16<0)throw new Error("xxx");return{L:Math.max(0,116*e-16),a:500*(t-e),b:200*(e-n)}}function H(t,e,n){const i=z(t,e,n);return G(i.x,i.y,i.z)}var Z=.95047,q=1,W=1.08883;function V(t){return t>.206893034?t**3:(t-16/116)/7.787}function J(t,e,n){const i=(t+16)/116,r=i-n/200;return{x:Z*V(e/500+i),y:q*V(i),z:W*V(r)}}function Y(t){return t>.0031308?1.055*t**(1/2.4)-.055:12.92*t}function X(t,e,n){const i=Y(3.2406*t+-1.5372*e+-.4986*n),r=Y(-.9689*t+1.8758*e+.0415*n),a=Y(.0557*t+-.204*e+1.057*n);return{r:O(255*i),g:O(255*r),b:O(255*a)}}function K(t,e,n){const i=J(t,e,n);return X(i.x,i.y,i.z)}var Q={};x(Q,{AbstractDistanceCalculator:()=>tt,AbstractEuclidean:()=>st,AbstractManhattan:()=>ft,CIE94GraphicArts:()=>it,CIE94Textiles:()=>nt,CIEDE2000:()=>at,CMetric:()=>ot,Euclidean:()=>ht,EuclideanBT709:()=>ct,EuclideanBT709NoAlpha:()=>lt,Manhattan:()=>ut,ManhattanBT709:()=>pt,ManhattanNommyde:()=>dt,PNGQuant:()=>mt});var tt=class{constructor(){k(this,"_maxDistance"),k(this,"_whitePoint"),this._setDefaults(),this.setWhitePoint(255,255,255,255)}setWhitePoint(t,e,n,i){this._whitePoint={r:t>0?255/t:0,g:e>0?255/e:0,b:n>0?255/n:0,a:i>0?255/i:0},this._maxDistance=this.calculateRaw(t,e,n,i,0,0,0,0)}calculateNormalized(t,e){return this.calculateRaw(t.r,t.g,t.b,t.a,e.r,e.g,e.b,e.a)/this._maxDistance}},et=class extends tt{calculateRaw(t,e,n,i,r,a,o,s){const h=H(L(t*this._whitePoint.r),L(e*this._whitePoint.g),L(n*this._whitePoint.b)),c=H(L(r*this._whitePoint.r),L(a*this._whitePoint.g),L(o*this._whitePoint.b)),l=h.L-c.L,f=h.a-c.a,u=h.b-c.b,d=Math.sqrt(h.a*h.a+h.b*h.b),p=d-Math.sqrt(c.a*c.a+c.b*c.b);let m=f*f+u*u-p*p;m=m<0?0:Math.sqrt(m);const g=(s-i)*this._whitePoint.a*this._kA;return Math.sqrt((l/this._Kl)**2+(p/(1+this._K1*d))**2+(m/(1+this._K2*d))**2+g**2)}},nt=class extends et{_setDefaults(){this._Kl=2,this._K1=.048,this._K2=.014,this._kA=12.5/255}},it=class extends et{_setDefaults(){this._Kl=1,this._K1=.045,this._K2=.015,this._kA=25/255}},rt=class extends tt{_setDefaults(){}static _calculatehp(t,e){const n=Math.atan2(t,e);return n>=0?n:n+rt._deg360InRad}static _calculateRT(t,e){const n=e**7,i=2*Math.sqrt(n/(n+rt._pow25to7)),r=rt._deg30InRad*Math.exp(-(((t-rt._deg275InRad)/rt._deg25InRad)**2));return-Math.sin(2*r)*i}static _calculateT(t){return 1-.17*Math.cos(t-rt._deg30InRad)+.24*Math.cos(2*t)+.32*Math.cos(3*t+rt._deg6InRad)-.2*Math.cos(4*t-rt._deg63InRad)}static _calculate_ahp(t,e,n,i){const r=n+i;return 0===t?r:e<=rt._deg180InRad?r/2:r<rt._deg360InRad?(r+rt._deg360InRad)/2:(r-rt._deg360InRad)/2}static _calculate_dHp(t,e,n,i){let r;return r=0===t?0:e<=rt._deg180InRad?n-i:n<=i?n-i+rt._deg360InRad:n-i-rt._deg360InRad,2*Math.sqrt(t)*Math.sin(r/2)}calculateRaw(t,e,n,i,r,a,o,s){const h=H(L(t*this._whitePoint.r),L(e*this._whitePoint.g),L(n*this._whitePoint.b)),c=H(L(r*this._whitePoint.r),L(a*this._whitePoint.g),L(o*this._whitePoint.b)),l=(s-i)*this._whitePoint.a*rt._kA,f=this.calculateRawInLab(h,c);return Math.sqrt(f+l*l)}calculateRawInLab(t,e){const n=t.L,i=t.a,r=t.b,a=e.L,o=e.a,s=e.b,h=((Math.sqrt(i*i+r*r)+Math.sqrt(o*o+s*s))/2)**7,c=.5*(1-Math.sqrt(h/(h+rt._pow25to7))),l=(1+c)*i,f=(1+c)*o,u=Math.sqrt(l*l+r*r),d=Math.sqrt(f*f+s*s),p=u*d,m=rt._calculatehp(r,l),g=rt._calculatehp(s,f),b=Math.abs(m-g),w=a-n,y=d-u,_=rt._calculate_dHp(p,b,g,m),v=rt._calculate_ahp(p,b,m,g),x=(u+d)/2,k=((n+a)/2-50)**2,A=y/(1+.045*x),M=_/(1+.015*rt._calculateT(v)*x);return(w/(1+.015*k/Math.sqrt(20+k)))**2+A**2+M**2+rt._calculateRT(v,x)*A*M}},at=rt;k(at,"_kA",25/255),k(at,"_pow25to7",25**7),k(at,"_deg360InRad",C(360)),k(at,"_deg180InRad",C(180)),k(at,"_deg30InRad",C(30)),k(at,"_deg6InRad",C(6)),k(at,"_deg63InRad",C(63)),k(at,"_deg275InRad",C(275)),k(at,"_deg25InRad",C(25));var ot=class extends tt{calculateRaw(t,e,n,i,r,a,o,s){const h=(t+r)/2*this._whitePoint.r,c=(t-r)*this._whitePoint.r,l=(e-a)*this._whitePoint.g,f=(n-o)*this._whitePoint.b,u=((512+h)*c*c>>8)+4*l*l+((767-h)*f*f>>8),d=(s-i)*this._whitePoint.a;return Math.sqrt(u+d*d)}_setDefaults(){}},st=class extends tt{calculateRaw(t,e,n,i,r,a,o,s){const h=r-t,c=a-e,l=o-n,f=s-i;return Math.sqrt(this._kR*h*h+this._kG*c*c+this._kB*l*l+this._kA*f*f)}},ht=class extends st{_setDefaults(){this._kR=1,this._kG=1,this._kB=1,this._kA=1}},ct=class extends st{_setDefaults(){this._kR=.2126,this._kG=.7152,this._kB=.0722,this._kA=1}},lt=class extends st{_setDefaults(){this._kR=.2126,this._kG=.7152,this._kB=.0722,this._kA=0}},ft=class extends tt{calculateRaw(t,e,n,i,r,a,o,s){let h=r-t,c=a-e,l=o-n,f=s-i;return h<0&&(h=0-h),c<0&&(c=0-c),l<0&&(l=0-l),f<0&&(f=0-f),this._kR*h+this._kG*c+this._kB*l+this._kA*f}},ut=class extends ft{_setDefaults(){this._kR=1,this._kG=1,this._kB=1,this._kA=1}},dt=class extends ft{_setDefaults(){this._kR=.4984,this._kG=.8625,this._kB=.2979,this._kA=1}},pt=class extends ft{_setDefaults(){this._kR=.2126,this._kG=.7152,this._kB=.0722,this._kA=1}},mt=class extends tt{calculateRaw(t,e,n,i,r,a,o,s){const h=(s-i)*this._whitePoint.a;return this._colordifferenceCh(t*this._whitePoint.r,r*this._whitePoint.r,h)+this._colordifferenceCh(e*this._whitePoint.g,a*this._whitePoint.g,h)+this._colordifferenceCh(n*this._whitePoint.b,o*this._whitePoint.b,h)}_colordifferenceCh(t,e,n){const i=t-e,r=i+n;return i*i+r*r}_setDefaults(){}},gt={};x(gt,{AbstractPaletteQuantizer:()=>bt,ColorHistogram:()=>Ut,NeuQuant:()=>zt,NeuQuantFloat:()=>Pt,RGBQuant:()=>Lt,WuColorCube:()=>jt,WuQuant:()=>Ht});var bt=class{quantizeSync(){for(const t of this.quantize())if(t.palette)return t.palette;throw new Error("unreachable")}},wt=class{constructor(){k(this,"r"),k(this,"g"),k(this,"b"),k(this,"a"),k(this,"uint32"),k(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(t){const e=new wt;return e.r=0|t[0],e.g=0|t[1],e.b=0|t[2],e.a=0|t[3],e._loadUINT32(),e._loadQuadruplet(),e}static createByRGBA(t,e,n,i){const r=new wt;return r.r=0|t,r.g=0|e,r.b=0|n,r.a=0|i,r._loadUINT32(),r._loadQuadruplet(),r}static createByUint32(t){const e=new wt;return e.uint32=t>>>0,e._loadRGBA(),e._loadQuadruplet(),e}from(t){this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a,this.uint32=t.uint32,this.rgba[0]=t.r,this.rgba[1]=t.g,this.rgba[2]=t.b,this.rgba[3]=t.a}getLuminosity(t){let e=this.r,n=this.g,i=this.b;return t&&(e=Math.min(255,255-this.a+this.a*e/255),n=Math.min(255,255-this.a+this.a*n/255),i=Math.min(255,255-this.a+this.a*i/255)),.2126*e+.7152*n+.0722*i}_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}},yt=class{constructor(){k(this,"_pointArray"),k(this,"_width"),k(this,"_height"),this._width=0,this._height=0,this._pointArray=[]}getWidth(){return this._width}getHeight(){return this._height}setWidth(t){this._width=t}setHeight(t){this._height=t}getPointArray(){return this._pointArray}clone(){const t=new yt;t._width=this._width,t._height=this._height;for(let e=0,n=this._pointArray.length;e<n;e++)t._pointArray[e]=wt.createByUint32(0|this._pointArray[e].uint32);return t}toUint32Array(){const t=this._pointArray.length,e=new Uint32Array(t);for(let n=0;n<t;n++)e[n]=this._pointArray[n].uint32;return e}toUint8Array(){return new Uint8Array(this.toUint32Array().buffer)}static fromHTMLImageElement(t){const e=t.naturalWidth,n=t.naturalHeight,i=document.createElement("canvas");i.width=e,i.height=n;return i.getContext("2d").drawImage(t,0,0,e,n,0,0,e,n),yt.fromHTMLCanvasElement(i)}static fromHTMLCanvasElement(t){const e=t.width,n=t.height,i=t.getContext("2d").getImageData(0,0,e,n);return yt.fromImageData(i)}static fromImageData(t){const e=t.width,n=t.height;return yt.fromUint8Array(t.data,e,n)}static fromUint8Array(t,e,n){switch(Object.prototype.toString.call(t)){case"[object Uint8ClampedArray]":case"[object Uint8Array]":break;default:t=new Uint8Array(t)}const i=new Uint32Array(t.buffer);return yt.fromUint32Array(i,e,n)}static fromUint32Array(t,e,n){const i=new yt;i._width=e,i._height=n;for(let e=0,n=t.length;e<n;e++)i._pointArray[e]=wt.createByUint32(0|t[e]);return i}static fromBuffer(t,e,n){const i=new Uint32Array(t.buffer,t.byteOffset,t.byteLength/Uint32Array.BYTES_PER_ELEMENT);return yt.fromUint32Array(i,e,n)}};function _t(t,e){const n=360/e;for(let i=1,r=n-n/2;i<e;i++,r+=n)if(t>=r&&t<r+n)return i;return 0}var vt=class{constructor(){k(this,"_pointContainer"),k(this,"_pointArray",[]),k(this,"_i32idx",{}),this._pointContainer=new yt,this._pointContainer.setHeight(1),this._pointArray=this._pointContainer.getPointArray()}add(t){this._pointArray.push(t),this._pointContainer.setWidth(this._pointArray.length)}has(t){for(let e=this._pointArray.length-1;e>=0;e--)if(t.uint32===this._pointArray[e].uint32)return!0;return!1}getNearestColor(t,e){return this._pointArray[0|this._getNearestIndex(t,e)]}getPointContainer(){return this._pointContainer}_nearestPointFromCache(t){return"number"==typeof this._i32idx[t]?this._i32idx[t]:-1}_getNearestIndex(t,e){let n=this._nearestPointFromCache(""+e.uint32);if(n>=0)return n;let i=Number.MAX_VALUE;n=0;for(let r=0,a=this._pointArray.length;r<a;r++){const a=this._pointArray[r],o=t.calculateRaw(e.r,e.g,e.b,e.a,a.r,a.g,a.b,a.a);o<i&&(i=o,n=r)}return this._i32idx[e.uint32]=n,n}sort(){this._i32idx={},this._pointArray.sort((t,e)=>{const n=F(t.r,t.g,t.b),i=F(e.r,e.g,e.b),r=t.r===t.g&&t.g===t.b?0:1+_t(n.h,10),a=(e.r===e.g&&e.g===e.b?0:1+_t(i.h,10))-r;if(a)return-a;const o=t.getLuminosity(!0),s=e.getLuminosity(!0);if(s-o!==0)return s-o;const h=(100*i.s|0)-(100*n.s|0);return h?-h:0})}},xt={};x(xt,{HueStatistics:()=>At,Palette:()=>vt,Point:()=>wt,PointContainer:()=>yt,ProgressTracker:()=>Et,arithmetic:()=>B});var kt=class{constructor(){k(this,"num",0),k(this,"cols",[])}},At=class{constructor(t,e){k(this,"_numGroups"),k(this,"_minCols"),k(this,"_stats"),k(this,"_groupsFull"),this._numGroups=t,this._minCols=e,this._stats=[];for(let e=0;e<=t;e++)this._stats[e]=new kt;this._groupsFull=0}check(t){this._groupsFull===this._numGroups+1&&(this.check=()=>{});const e=255&t,n=t>>>8&255,i=t>>>16&255,r=e===n&&n===i?0:1+_t(F(e,n,i).h,this._numGroups),a=this._stats[r],o=this._minCols;a.num++,a.num>o||(a.num===o&&this._groupsFull++,a.num<=o&&this._stats[r].cols.push(t))}injectIntoDictionary(t){for(let e=0;e<=this._numGroups;e++)this._stats[e].num<=this._minCols&&this._stats[e].cols.forEach(e=>{t[e]?t[e]++:t[e]=1})}injectIntoArray(t){for(let e=0;e<=this._numGroups;e++)this._stats[e].num<=this._minCols&&this._stats[e].cols.forEach(e=>{-1===t.indexOf(e)&&t.push(e)})}},Mt=class{constructor(t,e){k(this,"progress"),k(this,"_step"),k(this,"_range"),k(this,"_last"),k(this,"_progressRange"),this._range=t,this._progressRange=e,this._step=Math.max(1,this._range/(Mt.steps+1)|0),this._last=-this._step,this.progress=0}shouldNotify(t){return t-this._last>=this._step&&(this._last=t,this.progress=Math.min(this._progressRange*this._last/this._range,this._progressRange),!0)}},Et=Mt;k(Et,"steps",100);var It=class{constructor(t){k(this,"r"),k(this,"g"),k(this,"b"),k(this,"a"),this.r=this.g=this.b=this.a=t}toPoint(){return wt.createByRGBA(this.r>>3,this.g>>3,this.b>>3,this.a>>3)}subtract(t,e,n,i){this.r-=0|t,this.g-=0|e,this.b-=0|n,this.a-=0|i}},St=class extends bt{constructor(t,e=256){super(),k(this,"_pointArray"),k(this,"_networkSize"),k(this,"_network"),k(this,"_sampleFactor"),k(this,"_radPower"),k(this,"_freq"),k(this,"_bias"),k(this,"_distance"),this._distance=t,this._pointArray=[],this._sampleFactor=1,this._networkSize=e,this._distance.setWhitePoint(2040,2040,2040,2040)}sample(t){this._pointArray=this._pointArray.concat(t.getPointArray())}*quantize(){this._init(),yield*this._learn(),yield{palette:this._buildPalette(),progress:100}}_init(){this._freq=[],this._bias=[],this._radPower=[],this._network=[];for(let t=0;t<this._networkSize;t++)this._network[t]=new It((t<<11)/this._networkSize|0),this._freq[t]=St._initialBias/this._networkSize|0,this._bias[t]=0}*_learn(){let t=this._sampleFactor;const e=this._pointArray.length;e<St._minpicturebytes&&(t=1);const n=30+(t-1)/3|0,i=e/t|0;let r,a=i/St._nCycles|0,o=St._initAlpha,s=(this._networkSize>>3)*St._radiusBias,h=s>>St._radiusBiasShift;h<=1&&(h=0);for(let t=0;t<h;t++)this._radPower[t]=o*((h*h-t*t)*St._radBias/(h*h))>>>0;r=e<St._minpicturebytes?1:e%St._prime1!==0?St._prime1:e%St._prime2!==0?St._prime2:e%St._prime3!==0?St._prime3:St._prime4;const c=new Et(i,99);for(let t=0,l=0;t<i;){c.shouldNotify(t)&&(yield{progress:c.progress});const i=this._pointArray[l],f=i.b<<3,u=i.g<<3,d=i.r<<3,p=i.a<<3,m=this._contest(f,u,d,p);if(this._alterSingle(o,m,f,u,d,p),0!==h&&this._alterNeighbour(h,m,f,u,d,p),l+=r,l>=e&&(l-=e),t++,0===a&&(a=1),t%a===0){o-=o/n|0,s-=s/St._radiusDecrease|0,h=s>>St._radiusBiasShift,h<=1&&(h=0);for(let t=0;t<h;t++)this._radPower[t]=o*((h*h-t*t)*St._radBias/(h*h))>>>0}}}_buildPalette(){const t=new vt;return this._network.forEach(e=>{t.add(e.toPoint())}),t.sort(),t}_alterNeighbour(t,e,n,i,r,a){let o=e-t;o<-1&&(o=-1);let s=e+t;s>this._networkSize&&(s=this._networkSize);let h=e+1,c=e-1,l=1;for(;h<s||c>o;){const t=this._radPower[l++]/St._alphaRadBias;if(h<s){const e=this._network[h++];e.subtract(t*(e.r-r),t*(e.g-i),t*(e.b-n),t*(e.a-a))}if(c>o){const e=this._network[c--];e.subtract(t*(e.r-r),t*(e.g-i),t*(e.b-n),t*(e.a-a))}}}_alterSingle(t,e,n,i,r,a){t/=St._initAlpha;const o=this._network[e];o.subtract(t*(o.r-r),t*(o.g-i),t*(o.b-n),t*(o.a-a))}_contest(t,e,n,i){let r=2147483647,a=r,o=-1,s=o;for(let h=0;h<this._networkSize;h++){const c=this._network[h],l=8160*this._distance.calculateNormalized(c,{r:n,g:e,b:t,a:i})|0;l<r&&(r=l,o=h);const f=l-(this._bias[h]>>St._initialBiasShift-3);f<a&&(a=f,s=h);const u=this._freq[h]>>St._betaShift;this._freq[h]-=u,this._bias[h]+=u<<St._gammaShift}return this._freq[o]+=St._beta,this._bias[o]-=St._betaGamma,s}},zt=St;k(zt,"_prime1",499),k(zt,"_prime2",491),k(zt,"_prime3",487),k(zt,"_prime4",503),k(zt,"_minpicturebytes",St._prime4),k(zt,"_nCycles",100),k(zt,"_initialBiasShift",16),k(zt,"_initialBias",1<<St._initialBiasShift),k(zt,"_gammaShift",10),k(zt,"_betaShift",10),k(zt,"_beta",St._initialBias>>St._betaShift),k(zt,"_betaGamma",St._initialBias<<St._gammaShift-St._betaShift),k(zt,"_radiusBiasShift",6),k(zt,"_radiusBias",1<<St._radiusBiasShift),k(zt,"_radiusDecrease",30),k(zt,"_alphaBiasShift",10),k(zt,"_initAlpha",1<<St._alphaBiasShift),k(zt,"_radBiasShift",8),k(zt,"_radBias",1<<St._radBiasShift),k(zt,"_alphaRadBiasShift",St._alphaBiasShift+St._radBiasShift),k(zt,"_alphaRadBias",1<<St._alphaRadBiasShift);var Bt=class{constructor(t){k(this,"r"),k(this,"g"),k(this,"b"),k(this,"a"),this.r=this.g=this.b=this.a=t}toPoint(){return wt.createByRGBA(this.r>>3,this.g>>3,this.b>>3,this.a>>3)}subtract(t,e,n,i){this.r-=t,this.g-=e,this.b-=n,this.a-=i}},Ct=class extends bt{constructor(t,e=256){super(),k(this,"_pointArray"),k(this,"_networkSize"),k(this,"_network"),k(this,"_sampleFactor"),k(this,"_radPower"),k(this,"_freq"),k(this,"_bias"),k(this,"_distance"),this._distance=t,this._pointArray=[],this._sampleFactor=1,this._networkSize=e,this._distance.setWhitePoint(2040,2040,2040,2040)}sample(t){this._pointArray=this._pointArray.concat(t.getPointArray())}*quantize(){this._init(),yield*this._learn(),yield{palette:this._buildPalette(),progress:100}}_init(){this._freq=[],this._bias=[],this._radPower=[],this._network=[];for(let t=0;t<this._networkSize;t++)this._network[t]=new Bt((t<<11)/this._networkSize),this._freq[t]=Ct._initialBias/this._networkSize,this._bias[t]=0}*_learn(){let t=this._sampleFactor;const e=this._pointArray.length;e<Ct._minpicturebytes&&(t=1);const n=30+(t-1)/3,i=e/t;let r,a=i/Ct._nCycles|0,o=Ct._initAlpha,s=(this._networkSize>>3)*Ct._radiusBias,h=s>>Ct._radiusBiasShift;h<=1&&(h=0);for(let t=0;t<h;t++)this._radPower[t]=o*((h*h-t*t)*Ct._radBias/(h*h));r=e<Ct._minpicturebytes?1:e%Ct._prime1!==0?Ct._prime1:e%Ct._prime2!==0?Ct._prime2:e%Ct._prime3!==0?Ct._prime3:Ct._prime4;const c=new Et(i,99);for(let t=0,l=0;t<i;){c.shouldNotify(t)&&(yield{progress:c.progress});const i=this._pointArray[l],f=i.b<<3,u=i.g<<3,d=i.r<<3,p=i.a<<3,m=this._contest(f,u,d,p);if(this._alterSingle(o,m,f,u,d,p),0!==h&&this._alterNeighbour(h,m,f,u,d,p),l+=r,l>=e&&(l-=e),t++,0===a&&(a=1),t%a===0){o-=o/n,s-=s/Ct._radiusDecrease,h=s>>Ct._radiusBiasShift,h<=1&&(h=0);for(let t=0;t<h;t++)this._radPower[t]=o*((h*h-t*t)*Ct._radBias/(h*h))}}}_buildPalette(){const t=new vt;return this._network.forEach(e=>{t.add(e.toPoint())}),t.sort(),t}_alterNeighbour(t,e,n,i,r,a){let o=e-t;o<-1&&(o=-1);let s=e+t;s>this._networkSize&&(s=this._networkSize);let h=e+1,c=e-1,l=1;for(;h<s||c>o;){const t=this._radPower[l++]/Ct._alphaRadBias;if(h<s){const e=this._network[h++];e.subtract(t*(e.r-r),t*(e.g-i),t*(e.b-n),t*(e.a-a))}if(c>o){const e=this._network[c--];e.subtract(t*(e.r-r),t*(e.g-i),t*(e.b-n),t*(e.a-a))}}}_alterSingle(t,e,n,i,r,a){t/=Ct._initAlpha;const o=this._network[e];o.subtract(t*(o.r-r),t*(o.g-i),t*(o.b-n),t*(o.a-a))}_contest(t,e,n,i){let r=2147483647,a=r,o=-1,s=o;for(let h=0;h<this._networkSize;h++){const c=this._network[h],l=8160*this._distance.calculateNormalized(c,{r:n,g:e,b:t,a:i});l<r&&(r=l,o=h);const f=l-(this._bias[h]>>Ct._initialBiasShift-3);f<a&&(a=f,s=h);const u=this._freq[h]>>Ct._betaShift;this._freq[h]-=u,this._bias[h]+=u<<Ct._gammaShift}return this._freq[o]+=Ct._beta,this._bias[o]-=Ct._betaGamma,s}},Pt=Ct;k(Pt,"_prime1",499),k(Pt,"_prime2",491),k(Pt,"_prime3",487),k(Pt,"_prime4",503),k(Pt,"_minpicturebytes",Ct._prime4),k(Pt,"_nCycles",100),k(Pt,"_initialBiasShift",16),k(Pt,"_initialBias",1<<Ct._initialBiasShift),k(Pt,"_gammaShift",10),k(Pt,"_betaShift",10),k(Pt,"_beta",Ct._initialBias>>Ct._betaShift),k(Pt,"_betaGamma",Ct._initialBias<<Ct._gammaShift-Ct._betaShift),k(Pt,"_radiusBiasShift",6),k(Pt,"_radiusBias",1<<Ct._radiusBiasShift),k(Pt,"_radiusDecrease",30),k(Pt,"_alphaBiasShift",10),k(Pt,"_initAlpha",1<<Ct._alphaBiasShift),k(Pt,"_radBiasShift",8),k(Pt,"_radBias",1<<Ct._radBiasShift),k(Pt,"_alphaRadBiasShift",Ct._alphaBiasShift+Ct._radBiasShift),k(Pt,"_alphaRadBias",1<<Ct._alphaRadBiasShift);var Tt=class{constructor(t,e){k(this,"_method"),k(this,"_hueStats"),k(this,"_histogram"),k(this,"_initColors"),k(this,"_minHueCols"),this._method=t,this._minHueCols=e<<2,this._initColors=e<<2,this._hueStats=new At(Tt._hueGroups,this._minHueCols),this._histogram=Object.create(null)}sample(t){switch(this._method){case 1:this._colorStats1D(t);break;case 2:this._colorStats2D(t)}}getImportanceSortedColorsIDXI32(){const t=R(Object.keys(this._histogram),(t,e)=>this._histogram[e]-this._histogram[t]);if(0===t.length)return[];let e;switch(this._method){case 1:const n=Math.min(t.length,this._initColors),i=t[n-1],r=this._histogram[i];e=t.slice(0,n);let a=n;const o=t.length;for(;a<o&&this._histogram[t[a]]===r;)e.push(t[a++]);this._hueStats.injectIntoArray(e);break;case 2:e=t;break;default:throw new Error("Incorrect method")}return e.map(t=>+t)}_colorStats1D(t){const e=this._histogram,n=t.getPointArray(),i=n.length;for(let t=0;t<i;t++){const i=n[t].uint32;this._hueStats.check(i),i in e?e[i]++:e[i]=1}}_colorStats2D(t){const e=t.getWidth(),n=t.getHeight(),i=t.getPointArray(),r=Tt._boxSize[0],a=Tt._boxSize[1],o=r*a,s=this._makeBoxes(e,n,r,a),h=this._histogram;s.forEach(t=>{let n=Math.round(t.w*t.h/o)*Tt._boxPixels;n<2&&(n=2);const r={};this._iterateBox(t,e,t=>{const e=i[t].uint32;this._hueStats.check(e),e in h?h[e]++:e in r?++r[e]>=n&&(h[e]=r[e]):r[e]=1})}),this._hueStats.injectIntoDictionary(h)}_iterateBox(t,e,n){const i=t,r=i.y*e+i.x,a=(i.y+i.h-1)*e+(i.x+i.w-1),o=e-i.w+1;let s=0,h=r;do{n.call(this,h),h+=++s%i.w===0?o:1}while(h<=a)}_makeBoxes(t,e,n,i){const r=t%n,a=e%i,o=t-r,s=e-a,h=[];for(let c=0;c<e;c+=i)for(let e=0;e<t;e+=n)h.push({x:e,y:c,w:e===o?r:n,h:c===s?a:i});return h}},Ut=Tt;k(Ut,"_boxSize",[64,64]),k(Ut,"_boxPixels",2),k(Ut,"_hueGroups",10);var Ot=class{constructor(t,e,n){k(this,"index"),k(this,"color"),k(this,"distance"),this.index=t,this.color=e,this.distance=n}},Lt=class extends bt{constructor(t,e=256,n=2){super(),k(this,"_colors"),k(this,"_initialDistance"),k(this,"_distanceIncrement"),k(this,"_histogram"),k(this,"_distance"),this._distance=t,this._colors=e,this._histogram=new Ut(n,e),this._initialDistance=.01,this._distanceIncrement=.005}sample(t){this._histogram.sample(t)}*quantize(){const t=this._histogram.getImportanceSortedColorsIDXI32();if(0===t.length)throw new Error("No colors in image");yield*this._buildPalette(t)}*_buildPalette(t){const e=new vt,n=e.getPointContainer().getPointArray(),i=new Array(t.length);for(let e=0;e<t.length;e++)n.push(wt.createByUint32(t[e])),i[e]=1;const r=n.length,a=[];let o=r,s=this._initialDistance;const h=new Et(o-this._colors,99);for(;o>this._colors;){a.length=0;for(let t=0;t<r;t++){if(h.shouldNotify(r-o)&&(yield{progress:h.progress}),0===i[t])continue;const e=n[t];for(let h=t+1;h<r;h++){if(0===i[h])continue;const t=n[h],r=this._distance.calculateNormalized(e,t);r<s&&(a.push(new Ot(h,t,r)),i[h]=0,o--)}}s+=o>3*this._colors?this._initialDistance:this._distanceIncrement}if(o<this._colors){R(a,(t,e)=>e.distance-t.distance);let t=0;for(;o<this._colors&&t<a.length;){i[a[t].index]=1,o++,t++}}let c=n.length;for(let t=c-1;t>=0;t--)0===i[t]&&(t!==c-1&&(n[t]=n[c-1]),--c);n.length=c,e.sort(),yield{palette:e,progress:100}}};function Rt(t){const e=[];for(let n=0;n<t;n++)e[n]=0;return e}function Ft(t,e,n,i){const r=new Array(t);for(let a=0;a<t;a++){r[a]=new Array(e);for(let t=0;t<e;t++){r[a][t]=new Array(n);for(let e=0;e<n;e++){r[a][t][e]=new Array(i);for(let n=0;n<i;n++)r[a][t][e][n]=0}}}return r}function Dt(t,e,n){const i=new Array(t);for(let r=0;r<t;r++){i[r]=new Array(e);for(let t=0;t<e;t++){i[r][t]=new Array(n);for(let e=0;e<n;e++)i[r][t][e]=0}}return i}function Nt(t,e,n,i,r){for(let a=0;a<e;a++){t[a]=[];for(let e=0;e<n;e++){t[a][e]=[];for(let n=0;n<i;n++)t[a][e][n]=r}}}function $t(t,e,n){for(let i=0;i<e;i++)t[i]=n}var jt=class{constructor(){k(this,"redMinimum"),k(this,"redMaximum"),k(this,"greenMinimum"),k(this,"greenMaximum"),k(this,"blueMinimum"),k(this,"blueMaximum"),k(this,"volume"),k(this,"alphaMinimum"),k(this,"alphaMaximum")}},Gt=class extends bt{constructor(t,e=256,n=5){super(),k(this,"_reds"),k(this,"_greens"),k(this,"_blues"),k(this,"_alphas"),k(this,"_sums"),k(this,"_weights"),k(this,"_momentsRed"),k(this,"_momentsGreen"),k(this,"_momentsBlue"),k(this,"_momentsAlpha"),k(this,"_moments"),k(this,"_table"),k(this,"_pixels"),k(this,"_cubes"),k(this,"_colors"),k(this,"_significantBitsPerChannel"),k(this,"_maxSideIndex"),k(this,"_alphaMaxSideIndex"),k(this,"_sideSize"),k(this,"_alphaSideSize"),k(this,"_distance"),this._distance=t,this._setQuality(n),this._initialize(e)}sample(t){const e=t.getPointArray();for(let t=0,n=e.length;t<n;t++)this._addColor(e[t]);this._pixels=this._pixels.concat(e)}*quantize(){yield*this._preparePalette();const t=new vt;for(let e=0;e<this._colors;e++)if(this._sums[e]>0){const n=this._sums[e],i=this._reds[e]/n,r=this._greens[e]/n,a=this._blues[e]/n,o=this._alphas[e]/n,s=wt.createByRGBA(0|i,0|r,0|a,0|o);t.add(s)}t.sort(),yield{palette:t,progress:100}}*_preparePalette(){yield*this._calculateMoments();let t=0;const e=Rt(this._colors);for(let n=1;n<this._colors;++n){this._cut(this._cubes[t],this._cubes[n])?(e[t]=this._cubes[t].volume>1?this._calculateVariance(this._cubes[t]):0,e[n]=this._cubes[n].volume>1?this._calculateVariance(this._cubes[n]):0):(e[t]=0,n--),t=0;let i=e[0];for(let r=1;r<=n;++r)e[r]>i&&(i=e[r],t=r);if(i<=0){this._colors=n+1;break}}const n=[],i=[],r=[],a=[];for(let t=0;t<this._colors;++t){const e=Gt._volume(this._cubes[t],this._weights);e>0?(n[t]=Gt._volume(this._cubes[t],this._momentsRed)/e|0,i[t]=Gt._volume(this._cubes[t],this._momentsGreen)/e|0,r[t]=Gt._volume(this._cubes[t],this._momentsBlue)/e|0,a[t]=Gt._volume(this._cubes[t],this._momentsAlpha)/e|0):(n[t]=0,i[t]=0,r[t]=0,a[t]=0)}this._reds=Rt(this._colors+1),this._greens=Rt(this._colors+1),this._blues=Rt(this._colors+1),this._alphas=Rt(this._colors+1),this._sums=Rt(this._colors+1);for(let t=0,e=this._pixels.length;t<e;t++){const e=this._pixels[t];let o=-1,s=Number.MAX_VALUE;for(let t=0;t<this._colors;t++){const h=n[t],c=i[t],l=r[t],f=a[t],u=this._distance.calculateRaw(h,c,l,f,e.r,e.g,e.b,e.a);u<s&&(s=u,o=t)}this._reds[o]+=e.r,this._greens[o]+=e.g,this._blues[o]+=e.b,this._alphas[o]+=e.a,this._sums[o]++}}_addColor(t){const e=8-this._significantBitsPerChannel,n=1+(t.r>>e),i=1+(t.g>>e),r=1+(t.b>>e),a=1+(t.a>>e);this._weights[a][n][i][r]++,this._momentsRed[a][n][i][r]+=t.r,this._momentsGreen[a][n][i][r]+=t.g,this._momentsBlue[a][n][i][r]+=t.b,this._momentsAlpha[a][n][i][r]+=t.a,this._moments[a][n][i][r]+=this._table[t.r]+this._table[t.g]+this._table[t.b]+this._table[t.a]}*_calculateMoments(){const t=[],e=[],n=[],i=[],r=[],a=[],o=Dt(this._sideSize,this._sideSize,this._sideSize),s=Dt(this._sideSize,this._sideSize,this._sideSize),h=Dt(this._sideSize,this._sideSize,this._sideSize),c=Dt(this._sideSize,this._sideSize,this._sideSize),l=Dt(this._sideSize,this._sideSize,this._sideSize),f=Dt(this._sideSize,this._sideSize,this._sideSize);let u=0;const d=new Et(this._alphaMaxSideIndex*this._maxSideIndex,99);for(let p=1;p<=this._alphaMaxSideIndex;++p){Nt(o,this._sideSize,this._sideSize,this._sideSize,0),Nt(s,this._sideSize,this._sideSize,this._sideSize,0),Nt(h,this._sideSize,this._sideSize,this._sideSize,0),Nt(c,this._sideSize,this._sideSize,this._sideSize,0),Nt(l,this._sideSize,this._sideSize,this._sideSize,0),Nt(f,this._sideSize,this._sideSize,this._sideSize,0);for(let m=1;m<=this._maxSideIndex;++m,++u){d.shouldNotify(u)&&(yield{progress:d.progress}),$t(t,this._sideSize,0),$t(e,this._sideSize,0),$t(n,this._sideSize,0),$t(i,this._sideSize,0),$t(r,this._sideSize,0),$t(a,this._sideSize,0);for(let u=1;u<=this._maxSideIndex;++u){let d=0,g=0,b=0,w=0,y=0,_=0;for(let v=1;v<=this._maxSideIndex;++v)d+=this._weights[p][m][u][v],g+=this._momentsRed[p][m][u][v],b+=this._momentsGreen[p][m][u][v],w+=this._momentsBlue[p][m][u][v],y+=this._momentsAlpha[p][m][u][v],_+=this._moments[p][m][u][v],t[v]+=d,e[v]+=g,n[v]+=b,i[v]+=w,r[v]+=y,a[v]+=_,o[m][u][v]=o[m-1][u][v]+t[v],s[m][u][v]=s[m-1][u][v]+e[v],h[m][u][v]=h[m-1][u][v]+n[v],c[m][u][v]=c[m-1][u][v]+i[v],l[m][u][v]=l[m-1][u][v]+r[v],f[m][u][v]=f[m-1][u][v]+a[v],this._weights[p][m][u][v]=this._weights[p-1][m][u][v]+o[m][u][v],this._momentsRed[p][m][u][v]=this._momentsRed[p-1][m][u][v]+s[m][u][v],this._momentsGreen[p][m][u][v]=this._momentsGreen[p-1][m][u][v]+h[m][u][v],this._momentsBlue[p][m][u][v]=this._momentsBlue[p-1][m][u][v]+c[m][u][v],this._momentsAlpha[p][m][u][v]=this._momentsAlpha[p-1][m][u][v]+l[m][u][v],this._moments[p][m][u][v]=this._moments[p-1][m][u][v]+f[m][u][v]}}}}static _volumeFloat(t,e){return e[t.alphaMaximum][t.redMaximum][t.greenMaximum][t.blueMaximum]-e[t.alphaMaximum][t.redMaximum][t.greenMinimum][t.blueMaximum]-e[t.alphaMaximum][t.redMinimum][t.greenMaximum][t.blueMaximum]+e[t.alphaMaximum][t.redMinimum][t.greenMinimum][t.blueMaximum]-e[t.alphaMinimum][t.redMaximum][t.greenMaximum][t.blueMaximum]+e[t.alphaMinimum][t.redMaximum][t.greenMinimum][t.blueMaximum]+e[t.alphaMinimum][t.redMinimum][t.greenMaximum][t.blueMaximum]-e[t.alphaMinimum][t.redMinimum][t.greenMinimum][t.blueMaximum]-(e[t.alphaMaximum][t.redMaximum][t.greenMaximum][t.blueMinimum]-e[t.alphaMinimum][t.redMaximum][t.greenMaximum][t.blueMinimum]-e[t.alphaMaximum][t.redMaximum][t.greenMinimum][t.blueMinimum]+e[t.alphaMinimum][t.redMaximum][t.greenMinimum][t.blueMinimum]-e[t.alphaMaximum][t.redMinimum][t.greenMaximum][t.blueMinimum]+e[t.alphaMinimum][t.redMinimum][t.greenMaximum][t.blueMinimum]+e[t.alphaMaximum][t.redMinimum][t.greenMinimum][t.blueMinimum]-e[t.alphaMinimum][t.redMinimum][t.greenMinimum][t.blueMinimum])}static _volume(t,e){return 0|Gt._volumeFloat(t,e)}static _top(t,e,n,i){let r;switch(e){case Gt._alpha:r=i[n][t.redMaximum][t.greenMaximum][t.blueMaximum]-i[n][t.redMaximum][t.greenMinimum][t.blueMaximum]-i[n][t.redMinimum][t.greenMaximum][t.blueMaximum]+i[n][t.redMinimum][t.greenMinimum][t.blueMaximum]-(i[n][t.redMaximum][t.greenMaximum][t.blueMinimum]-i[n][t.redMaximum][t.greenMinimum][t.blueMinimum]-i[n][t.redMinimum][t.greenMaximum][t.blueMinimum]+i[n][t.redMinimum][t.greenMinimum][t.blueMinimum]);break;case Gt._red:r=i[t.alphaMaximum][n][t.greenMaximum][t.blueMaximum]-i[t.alphaMaximum][n][t.greenMinimum][t.blueMaximum]-i[t.alphaMinimum][n][t.greenMaximum][t.blueMaximum]+i[t.alphaMinimum][n][t.greenMinimum][t.blueMaximum]-(i[t.alphaMaximum][n][t.greenMaximum][t.blueMinimum]-i[t.alphaMaximum][n][t.greenMinimum][t.blueMinimum]-i[t.alphaMinimum][n][t.greenMaximum][t.blueMinimum]+i[t.alphaMinimum][n][t.greenMinimum][t.blueMinimum]);break;case Gt._green:r=i[t.alphaMaximum][t.redMaximum][n][t.blueMaximum]-i[t.alphaMaximum][t.redMinimum][n][t.blueMaximum]-i[t.alphaMinimum][t.redMaximum][n][t.blueMaximum]+i[t.alphaMinimum][t.redMinimum][n][t.blueMaximum]-(i[t.alphaMaximum][t.redMaximum][n][t.blueMinimum]-i[t.alphaMaximum][t.redMinimum][n][t.blueMinimum]-i[t.alphaMinimum][t.redMaximum][n][t.blueMinimum]+i[t.alphaMinimum][t.redMinimum][n][t.blueMinimum]);break;case Gt._blue:r=i[t.alphaMaximum][t.redMaximum][t.greenMaximum][n]-i[t.alphaMaximum][t.redMaximum][t.greenMinimum][n]-i[t.alphaMaximum][t.redMinimum][t.greenMaximum][n]+i[t.alphaMaximum][t.redMinimum][t.greenMinimum][n]-(i[t.alphaMinimum][t.redMaximum][t.greenMaximum][n]-i[t.alphaMinimum][t.redMaximum][t.greenMinimum][n]-i[t.alphaMinimum][t.redMinimum][t.greenMaximum][n]+i[t.alphaMinimum][t.redMinimum][t.greenMinimum][n]);break;default:throw new Error("impossible")}return 0|r}static _bottom(t,e,n){switch(e){case Gt._alpha:return-n[t.alphaMinimum][t.redMaximum][t.greenMaximum][t.blueMaximum]+n[t.alphaMinimum][t.redMaximum][t.greenMinimum][t.blueMaximum]+n[t.alphaMinimum][t.redMinimum][t.greenMaximum][t.blueMaximum]-n[t.alphaMinimum][t.redMinimum][t.greenMinimum][t.blueMaximum]-(-n[t.alphaMinimum][t.redMaximum][t.greenMaximum][t.blueMinimum]+n[t.alphaMinimum][t.redMaximum][t.greenMinimum][t.blueMinimum]+n[t.alphaMinimum][t.redMinimum][t.greenMaximum][t.blueMinimum]-n[t.alphaMinimum][t.redMinimum][t.greenMinimum][t.blueMinimum]);case Gt._red:return-n[t.alphaMaximum][t.redMinimum][t.greenMaximum][t.blueMaximum]+n[t.alphaMaximum][t.redMinimum][t.greenMinimum][t.blueMaximum]+n[t.alphaMinimum][t.redMinimum][t.greenMaximum][t.blueMaximum]-n[t.alphaMinimum][t.redMinimum][t.greenMinimum][t.blueMaximum]-(-n[t.alphaMaximum][t.redMinimum][t.greenMaximum][t.blueMinimum]+n[t.alphaMaximum][t.redMinimum][t.greenMinimum][t.blueMinimum]+n[t.alphaMinimum][t.redMinimum][t.greenMaximum][t.blueMinimum]-n[t.alphaMinimum][t.redMinimum][t.greenMinimum][t.blueMinimum]);case Gt._green:return-n[t.alphaMaximum][t.redMaximum][t.greenMinimum][t.blueMaximum]+n[t.alphaMaximum][t.redMinimum][t.greenMinimum][t.blueMaximum]+n[t.alphaMinimum][t.redMaximum][t.greenMinimum][t.blueMaximum]-n[t.alphaMinimum][t.redMinimum][t.greenMinimum][t.blueMaximum]-(-n[t.alphaMaximum][t.redMaximum][t.greenMinimum][t.blueMinimum]+n[t.alphaMaximum][t.redMinimum][t.greenMinimum][t.blueMinimum]+n[t.alphaMinimum][t.redMaximum][t.greenMinimum][t.blueMinimum]-n[t.alphaMinimum][t.redMinimum][t.greenMinimum][t.blueMinimum]);case Gt._blue:return-n[t.alphaMaximum][t.redMaximum][t.greenMaximum][t.blueMinimum]+n[t.alphaMaximum][t.redMaximum][t.greenMinimum][t.blueMinimum]+n[t.alphaMaximum][t.redMinimum][t.greenMaximum][t.blueMinimum]-n[t.alphaMaximum][t.redMinimum][t.greenMinimum][t.blueMinimum]-(-n[t.alphaMinimum][t.redMaximum][t.greenMaximum][t.blueMinimum]+n[t.alphaMinimum][t.redMaximum][t.greenMinimum][t.blueMinimum]+n[t.alphaMinimum][t.redMinimum][t.greenMaximum][t.blueMinimum]-n[t.alphaMinimum][t.redMinimum][t.greenMinimum][t.blueMinimum]);default:return 0}}_calculateVariance(t){const e=Gt._volume(t,this._momentsRed),n=Gt._volume(t,this._momentsGreen),i=Gt._volume(t,this._momentsBlue),r=Gt._volume(t,this._momentsAlpha);return Gt._volumeFloat(t,this._moments)-(e*e+n*n+i*i+r*r)/Gt._volume(t,this._weights)}_maximize(t,e,n,i,r,a,o,s,h){const c=0|Gt._bottom(t,e,this._momentsRed),l=0|Gt._bottom(t,e,this._momentsGreen),f=0|Gt._bottom(t,e,this._momentsBlue),u=0|Gt._bottom(t,e,this._momentsAlpha),d=0|Gt._bottom(t,e,this._weights);let p=0,m=-1;for(let g=n;g<i;++g){let n=c+Gt._top(t,e,g,this._momentsRed),i=l+Gt._top(t,e,g,this._momentsGreen),b=f+Gt._top(t,e,g,this._momentsBlue),w=u+Gt._top(t,e,g,this._momentsAlpha),y=d+Gt._top(t,e,g,this._weights);if(0!==y){let t=n*n+i*i+b*b+w*w,e=t/y;n=r-n,i=a-i,b=o-b,w=s-w,y=h-y,0!==y&&(t=n*n+i*i+b*b+w*w,e+=t/y,e>p&&(p=e,m=g))}}return{max:p,position:m}}_cut(t,e){let n;const i=Gt._volume(t,this._momentsRed),r=Gt._volume(t,this._momentsGreen),a=Gt._volume(t,this._momentsBlue),o=Gt._volume(t,this._momentsAlpha),s=Gt._volume(t,this._weights),h=this._maximize(t,Gt._red,t.redMinimum+1,t.redMaximum,i,r,a,o,s),c=this._maximize(t,Gt._green,t.greenMinimum+1,t.greenMaximum,i,r,a,o,s),l=this._maximize(t,Gt._blue,t.blueMinimum+1,t.blueMaximum,i,r,a,o,s),f=this._maximize(t,Gt._alpha,t.alphaMinimum+1,t.alphaMaximum,i,r,a,o,s);if(f.max>=h.max&&f.max>=c.max&&f.max>=l.max){if(n=Gt._alpha,f.position<0)return!1}else n=h.max>=f.max&&h.max>=c.max&&h.max>=l.max?Gt._red:c.max>=f.max&&c.max>=h.max&&c.max>=l.max?Gt._green:Gt._blue;switch(e.redMaximum=t.redMaximum,e.greenMaximum=t.greenMaximum,e.blueMaximum=t.blueMaximum,e.alphaMaximum=t.alphaMaximum,n){case Gt._red:e.redMinimum=t.redMaximum=h.position,e.greenMinimum=t.greenMinimum,e.blueMinimum=t.blueMinimum,e.alphaMinimum=t.alphaMinimum;break;case Gt._green:e.greenMinimum=t.greenMaximum=c.position,e.redMinimum=t.redMinimum,e.blueMinimum=t.blueMinimum,e.alphaMinimum=t.alphaMinimum;break;case Gt._blue:e.blueMinimum=t.blueMaximum=l.position,e.redMinimum=t.redMinimum,e.greenMinimum=t.greenMinimum,e.alphaMinimum=t.alphaMinimum;break;case Gt._alpha:e.alphaMinimum=t.alphaMaximum=f.position,e.blueMinimum=t.blueMinimum,e.redMinimum=t.redMinimum,e.greenMinimum=t.greenMinimum}return t.volume=(t.redMaximum-t.redMinimum)*(t.greenMaximum-t.greenMinimum)*(t.blueMaximum-t.blueMinimum)*(t.alphaMaximum-t.alphaMinimum),e.volume=(e.redMaximum-e.redMinimum)*(e.greenMaximum-e.greenMinimum)*(e.blueMaximum-e.blueMinimum)*(e.alphaMaximum-e.alphaMinimum),!0}_initialize(t){this._colors=t,this._cubes=[];for(let e=0;e<t;e++)this._cubes[e]=new jt;this._cubes[0].redMinimum=0,this._cubes[0].greenMinimum=0,this._cubes[0].blueMinimum=0,this._cubes[0].alphaMinimum=0,this._cubes[0].redMaximum=this._maxSideIndex,this._cubes[0].greenMaximum=this._maxSideIndex,this._cubes[0].blueMaximum=this._maxSideIndex,this._cubes[0].alphaMaximum=this._alphaMaxSideIndex,this._weights=Ft(this._alphaSideSize,this._sideSize,this._sideSize,this._sideSize),this._momentsRed=Ft(this._alphaSideSize,this._sideSize,this._sideSize,this._sideSize),this._momentsGreen=Ft(this._alphaSideSize,this._sideSize,this._sideSize,this._sideSize),this._momentsBlue=Ft(this._alphaSideSize,this._sideSize,this._sideSize,this._sideSize),this._momentsAlpha=Ft(this._alphaSideSize,this._sideSize,this._sideSize,this._sideSize),this._moments=Ft(this._alphaSideSize,this._sideSize,this._sideSize,this._sideSize),this._table=[];for(let t=0;t<256;++t)this._table[t]=t*t;this._pixels=[]}_setQuality(t=5){this._significantBitsPerChannel=t,this._maxSideIndex=1<<this._significantBitsPerChannel,this._alphaMaxSideIndex=this._maxSideIndex,this._sideSize=this._maxSideIndex+1,this._alphaSideSize=this._alphaMaxSideIndex+1}},Ht=Gt;k(Ht,"_alpha",3),k(Ht,"_red",2),k(Ht,"_green",1),k(Ht,"_blue",0);x({},{AbstractImageQuantizer:()=>Zt,ErrorDiffusionArray:()=>Vt,ErrorDiffusionArrayKernel:()=>Wt,ErrorDiffusionRiemersma:()=>Kt,NearestColor:()=>qt});var Zt=class{quantizeSync(t,e){for(const n of this.quantize(t,e))if(n.pointContainer)return n.pointContainer;throw new Error("unreachable")}},qt=class extends Zt{constructor(t){super(),k(this,"_distance"),this._distance=t}*quantize(t,e){const n=t.getPointArray(),i=t.getWidth(),r=t.getHeight(),a=new Et(r,99);for(let t=0;t<r;t++){a.shouldNotify(t)&&(yield{progress:a.progress});for(let r=0,a=t*i;r<i;r++,a++){const t=n[a];t.from(e.getNearestColor(this._distance,t))}}yield{pointContainer:t,progress:100}}},Wt=(t=>(t[t.FloydSteinberg=0]="FloydSteinberg",t[t.FalseFloydSteinberg=1]="FalseFloydSteinberg",t[t.Stucki=2]="Stucki",t[t.Atkinson=3]="Atkinson",t[t.Jarvis=4]="Jarvis",t[t.Burkes=5]="Burkes",t[t.Sierra=6]="Sierra",t[t.TwoSierra=7]="TwoSierra",t[t.SierraLite=8]="SierraLite",t))(Wt||{}),Vt=class extends Zt{constructor(t,e,n=!0,i=0,r=!1){super(),k(this,"_minColorDistance"),k(this,"_serpentine"),k(this,"_kernel"),k(this,"_calculateErrorLikeGIMP"),k(this,"_distance"),this._setKernel(e),this._distance=t,this._minColorDistance=i,this._serpentine=n,this._calculateErrorLikeGIMP=r}*quantize(t,e){const n=t.getPointArray(),i=new wt,r=t.getWidth(),a=t.getHeight(),o=[];let s=1,h=1;for(const t of this._kernel){const e=t[2]+1;h<e&&(h=e)}for(let t=0;t<h;t++)this._fillErrorLine(o[t]=[],r);const c=new Et(a,99);for(let t=0;t<a;t++){c.shouldNotify(t)&&(yield{progress:c.progress}),this._serpentine&&(s*=-1);const h=t*r,l=1===s?0:r-1,f=1===s?r:-1;this._fillErrorLine(o[0],r),o.push(o.shift());const u=o[0];for(let c=l,d=h+l;c!==f;c+=s,d+=s){const h=n[d],l=u[c];i.from(h);const f=wt.createByRGBA(O(h.r+l[0]),O(h.g+l[1]),O(h.b+l[2]),O(h.a+l[3])),p=e.getNearestColor(this._distance,f);if(h.from(p),this._minColorDistance){if(this._distance.calculateNormalized(i,p)<this._minColorDistance)continue}let m,g,b,w;this._calculateErrorLikeGIMP?(m=f.r-p.r,g=f.g-p.g,b=f.b-p.b,w=f.a-p.a):(m=i.r-p.r,g=i.g-p.g,b=i.b-p.b,w=i.a-p.a);const y=1===s?0:this._kernel.length-1,_=1===s?this._kernel.length:-1;for(let e=y;e!==_;e+=s){const n=this._kernel[e][1]*s,i=this._kernel[e][2];if(n+c>=0&&n+c<r&&i+t>=0&&i+t<a){const t=this._kernel[e][0],r=o[i][n+c];r[0]+=m*t,r[1]+=g*t,r[2]+=b*t,r[3]+=w*t}}}}yield{pointContainer:t,progress:100}}_fillErrorLine(t,e){t.length>e&&(t.length=e);const n=t.length;for(let e=0;e<n;e++){const n=t[e];n[0]=n[1]=n[2]=n[3]=0}for(let i=n;i<e;i++)t[i]=[0,0,0,0]}_setKernel(t){switch(t){case 0:this._kernel=[[7/16,1,0],[3/16,-1,1],[5/16,0,1],[1/16,1,1]];break;case 1:this._kernel=[[3/8,1,0],[3/8,0,1],[2/8,1,1]];break;case 2:this._kernel=[[8/42,1,0],[4/42,2,0],[2/42,-2,1],[4/42,-1,1],[8/42,0,1],[4/42,1,1],[2/42,2,1],[1/42,-2,2],[2/42,-1,2],[4/42,0,2],[2/42,1,2],[1/42,2,2]];break;case 3:this._kernel=[[1/8,1,0],[1/8,2,0],[1/8,-1,1],[1/8,0,1],[1/8,1,1],[1/8,0,2]];break;case 4:this._kernel=[[7/48,1,0],[5/48,2,0],[3/48,-2,1],[5/48,-1,1],[7/48,0,1],[5/48,1,1],[3/48,2,1],[1/48,-2,2],[3/48,-1,2],[5/48,0,2],[3/48,1,2],[1/48,2,2]];break;case 5:this._kernel=[[.25,1,0],[4/32,2,0],[2/32,-2,1],[4/32,-1,1],[.25,0,1],[4/32,1,1],[2/32,2,1]];break;case 6:this._kernel=[[5/32,1,0],[3/32,2,0],[2/32,-2,1],[4/32,-1,1],[5/32,0,1],[4/32,1,1],[2/32,2,1],[2/32,-1,2],[3/32,0,2],[2/32,1,2]];break;case 7:this._kernel=[[.25,1,0],[3/16,2,0],[1/16,-2,1],[2/16,-1,1],[3/16,0,1],[2/16,1,1],[1/16,2,1]];break;case 8:this._kernel=[[.5,1,0],[1/4,-1,1],[1/4,0,1]];break;default:throw new Error(`ErrorDiffusionArray: unknown kernel = ${t}`)}}};function*Jt(t,e,n){const i=Math.max(t,e),r={width:t,height:e,level:Math.floor(Math.log(i)/Math.log(2)+1),callback:n,tracker:new Et(t*e,99),index:0,x:0,y:0};yield*Yt(r,1),Xt(r,0)}function*Yt(t,e){if(!(t.level<1)){switch(t.tracker.shouldNotify(t.index)&&(yield{progress:t.tracker.progress}),t.level--,e){case 2:yield*Yt(t,1),Xt(t,3),yield*Yt(t,2),Xt(t,4),yield*Yt(t,2),Xt(t,2),yield*Yt(t,4);break;case 3:yield*Yt(t,4),Xt(t,2),yield*Yt(t,3),Xt(t,1),yield*Yt(t,3),Xt(t,3),yield*Yt(t,1);break;case 1:yield*Yt(t,2),Xt(t,4),yield*Yt(t,1),Xt(t,3),yield*Yt(t,1),Xt(t,1),yield*Yt(t,3);break;case 4:yield*Yt(t,3),Xt(t,1),yield*Yt(t,4),Xt(t,2),yield*Yt(t,4),Xt(t,4),yield*Yt(t,2)}t.level++}}function Xt(t,e){switch(t.x>=0&&t.x<t.width&&t.y>=0&&t.y<t.height&&(t.callback(t.x,t.y),t.index++),e){case 2:t.x--;break;case 3:t.x++;break;case 1:t.y--;break;case 4:t.y++}}var Kt=class extends Zt{constructor(t,e=16,n=1){super(),k(this,"_distance"),k(this,"_weights"),k(this,"_errorQueueSize"),this._distance=t,this._errorQueueSize=e,this._weights=Kt._createWeights(n,e)}*quantize(t,e){const n=t.getPointArray(),i=t.getWidth(),r=t.getHeight(),a=[];let o=0;for(let t=0;t<this._errorQueueSize;t++)a[t]={r:0,g:0,b:0,a:0};yield*Jt(i,r,(t,r)=>{const s=n[t+r*i];let{r:h,g:c,b:l,a:f}=s;for(let t=0;t<this._errorQueueSize;t++){const e=this._weights[t],n=a[(t+o)%this._errorQueueSize];h+=n.r*e,c+=n.g*e,l+=n.b*e,f+=n.a*e}const u=wt.createByRGBA(O(h),O(c),O(l),O(f)),d=e.getNearestColor(this._distance,u);o=(o+1)%this._errorQueueSize;const p=(o+this._errorQueueSize-1)%this._errorQueueSize;a[p].r=s.r-d.r,a[p].g=s.g-d.g,a[p].b=s.b-d.b,a[p].a=s.a-d.a,s.from(d)}),yield{pointContainer:t,progress:100}}static _createWeights(t,e){const n=[],i=Math.exp(Math.log(e)/(e-1));for(let r=0,a=1;r<e;r++)n[r]=(a+.5|0)/e*t,a*=i;return n}};x({},{ssim:()=>ee});var Qt=.01,te=.03;function ee(t,e){if(t.getHeight()!==e.getHeight()||t.getWidth()!==e.getWidth())throw new Error("Images have different sizes!");const n=(255*Qt)**2,i=(255*te)**2;let r=0,a=0;return function(t,e,n){const i=8,r=t.getWidth(),a=t.getHeight();for(let o=0;o<a;o+=i)for(let s=0;s<r;s+=i){const h=Math.min(i,r-s),c=Math.min(i,a-o),l=ne(t,s,o,h,c),f=ne(e,s,o,h,c);n(l,f,ie(l),ie(f))}}(t,e,(t,e,o,s)=>{let h=0,c=0,l=0;for(let n=0;n<t.length;n++)c+=(t[n]-o)**2,l+=(e[n]-s)**2,h+=(t[n]-o)*(e[n]-s);const f=t.length-1;c/=f,l/=f,h/=f;a+=(2*o*s+n)*(2*h+i)/((o**2+s**2+n)*(c+l+i)),r++}),a/r}function ne(t,e,n,i,r){const a=t.getPointArray(),o=[];let s=0;for(let h=n;h<n+r;h++){const n=h*t.getWidth();for(let t=e;t<e+i;t++){const e=a[n+t];o[s]=.2126*e.r+.7152*e.g+.0722*e.b,s++}}return o}function ie(t){let e=0;for(const n of t)e+=n;return e/t.length}function re(t,{colorDistanceFormula:e,paletteQuantization:n,colors:i}={}){const r=function(t,e="wuquant",n=256){switch(e){case"neuquant":return new zt(t,n);case"rgbquant":return new Lt(t,n);case"wuquant":return new Ht(t,n);case"neuquant-float":return new Pt(t,n);default:throw new Error(`Unknown paletteQuantization ${e}`)}}
/**
 * @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
 */(oe(e),n,i);return t.forEach(t=>r.sample(t)),r.quantizeSync()}function ae(t,e,{colorDistanceFormula:n,imageQuantization:i}={}){const r=function(t,e="floyd-steinberg"){switch(e){case"nearest":return new qt(t);case"riemersma":return new Kt(t);case"floyd-steinberg":return new Vt(t,0);case"false-floyd-steinberg":return new Vt(t,1);case"stucki":return new Vt(t,2);case"atkinson":return new Vt(t,3);case"jarvis":return new Vt(t,4);case"burkes":return new Vt(t,5);case"sierra":return new Vt(t,6);case"two-sierra":return new Vt(t,7);case"sierra-lite":return new Vt(t,8);default:throw new Error(`Unknown imageQuantization ${e}`)}}(oe(n),i);return r.quantizeSync(t,e)}function oe(t="euclidean-bt709"){switch(t){case"cie94-graphic-arts":return new it;case"cie94-textiles":return new nt;case"ciede2000":return new at;case"color-metric":return new ot;case"euclidean":return new ht;case"euclidean-bt709":return new ct;case"euclidean-bt709-noalpha":return new lt;case"manhattan":return new ut;case"manhattan-bt709":return new pt;case"manhattan-nommyde":return new dt;case"pngquant":return new mt;default:throw new Error(`Unknown colorDistanceFormula ${t}`)}}function se(t){return se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},se(t)}"function"==typeof setImmediate?setImmediate:"undefined"!=typeof process&&(null==process||process.nextTick);var he=/^\s+/,ce=/\s+$/;function le(t,e){if(e=e||{},(t=t||"")instanceof le)return t;if(!(this instanceof le))return new le(t,e);var n=function(t){var e={r:0,g:0,b:0},n=1,i=null,r=null,a=null,o=!1,s=!1;"string"==typeof t&&(t=function(t){t=t.replace(he,"").replace(ce,"").toLowerCase();var e,n=!1;if(Ie[t])t=Ie[t],n=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};if(e=Ne.rgb.exec(t))return{r:e[1],g:e[2],b:e[3]};if(e=Ne.rgba.exec(t))return{r:e[1],g:e[2],b:e[3],a:e[4]};if(e=Ne.hsl.exec(t))return{h:e[1],s:e[2],l:e[3]};if(e=Ne.hsla.exec(t))return{h:e[1],s:e[2],l:e[3],a:e[4]};if(e=Ne.hsv.exec(t))return{h:e[1],s:e[2],v:e[3]};if(e=Ne.hsva.exec(t))return{h:e[1],s:e[2],v:e[3],a:e[4]};if(e=Ne.hex8.exec(t))return{r:Pe(e[1]),g:Pe(e[2]),b:Pe(e[3]),a:Le(e[4]),format:n?"name":"hex8"};if(e=Ne.hex6.exec(t))return{r:Pe(e[1]),g:Pe(e[2]),b:Pe(e[3]),format:n?"name":"hex"};if(e=Ne.hex4.exec(t))return{r:Pe(e[1]+""+e[1]),g:Pe(e[2]+""+e[2]),b:Pe(e[3]+""+e[3]),a:Le(e[4]+""+e[4]),format:n?"name":"hex8"};if(e=Ne.hex3.exec(t))return{r:Pe(e[1]+""+e[1]),g:Pe(e[2]+""+e[2]),b:Pe(e[3]+""+e[3]),format:n?"name":"hex"};return!1}(t));"object"==se(t)&&($e(t.r)&&$e(t.g)&&$e(t.b)?(e=function(t,e,n){return{r:255*Be(t,255),g:255*Be(e,255),b:255*Be(n,255)}}(t.r,t.g,t.b),o=!0,s="%"===String(t.r).substr(-1)?"prgb":"rgb"):$e(t.h)&&$e(t.s)&&$e(t.v)?(i=Ue(t.s),r=Ue(t.v),e=function(t,e,n){t=6*Be(t,360),e=Be(e,100),n=Be(n,100);var i=Math.floor(t),r=t-i,a=n*(1-e),o=n*(1-r*e),s=n*(1-(1-r)*e),h=i%6,c=[n,o,a,a,s,n][h],l=[s,n,n,o,a,a][h],f=[a,a,s,n,n,o][h];return{r:255*c,g:255*l,b:255*f}}(t.h,i,r),o=!0,s="hsv"):$e(t.h)&&$e(t.s)&&$e(t.l)&&(i=Ue(t.s),a=Ue(t.l),e=function(t,e,n){var i,r,a;function o(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t}if(t=Be(t,360),e=Be(e,100),n=Be(n,100),0===e)i=r=a=n;else{var s=n<.5?n*(1+e):n+e-n*e,h=2*n-s;i=o(h,s,t+1/3),r=o(h,s,t),a=o(h,s,t-1/3)}return{r:255*i,g:255*r,b:255*a}}(t.h,i,a),o=!0,s="hsl"),t.hasOwnProperty("a")&&(n=t.a));return n=ze(n),{ok:o,format:t.format||s,r:Math.min(255,Math.max(e.r,0)),g:Math.min(255,Math.max(e.g,0)),b:Math.min(255,Math.max(e.b,0)),a:n}}(t);this._originalInput=t,this._r=n.r,this._g=n.g,this._b=n.b,this._a=n.a,this._roundA=Math.round(100*this._a)/100,this._format=e.format||n.format,this._gradientType=e.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=n.ok}function fe(t,e,n){t=Be(t,255),e=Be(e,255),n=Be(n,255);var i,r,a=Math.max(t,e,n),o=Math.min(t,e,n),s=(a+o)/2;if(a==o)i=r=0;else{var h=a-o;switch(r=s>.5?h/(2-a-o):h/(a+o),a){case t:i=(e-n)/h+(e<n?6:0);break;case e:i=(n-t)/h+2;break;case n:i=(t-e)/h+4}i/=6}return{h:i,s:r,l:s}}function ue(t,e,n){t=Be(t,255),e=Be(e,255),n=Be(n,255);var i,r,a=Math.max(t,e,n),o=Math.min(t,e,n),s=a,h=a-o;if(r=0===a?0:h/a,a==o)i=0;else{switch(a){case t:i=(e-n)/h+(e<n?6:0);break;case e:i=(n-t)/h+2;break;case n:i=(t-e)/h+4}i/=6}return{h:i,s:r,v:s}}function de(t,e,n,i){var r=[Te(Math.round(t).toString(16)),Te(Math.round(e).toString(16)),Te(Math.round(n).toString(16))];return i&&r[0].charAt(0)==r[0].charAt(1)&&r[1].charAt(0)==r[1].charAt(1)&&r[2].charAt(0)==r[2].charAt(1)?r[0].charAt(0)+r[1].charAt(0)+r[2].charAt(0):r.join("")}function pe(t,e,n,i){return[Te(Oe(i)),Te(Math.round(t).toString(16)),Te(Math.round(e).toString(16)),Te(Math.round(n).toString(16))].join("")}function me(t,e){e=0===e?0:e||10;var n=le(t).toHsl();return n.s-=e/100,n.s=Ce(n.s),le(n)}function ge(t,e){e=0===e?0:e||10;var n=le(t).toHsl();return n.s+=e/100,n.s=Ce(n.s),le(n)}function be(t){return le(t).desaturate(100)}function we(t,e){e=0===e?0:e||10;var n=le(t).toHsl();return n.l+=e/100,n.l=Ce(n.l),le(n)}function ye(t,e){e=0===e?0:e||10;var n=le(t).toRgb();return n.r=Math.max(0,Math.min(255,n.r-Math.round(-e/100*255))),n.g=Math.max(0,Math.min(255,n.g-Math.round(-e/100*255))),n.b=Math.max(0,Math.min(255,n.b-Math.round(-e/100*255))),le(n)}function _e(t,e){e=0===e?0:e||10;var n=le(t).toHsl();return n.l-=e/100,n.l=Ce(n.l),le(n)}function ve(t,e){var n=le(t).toHsl(),i=(n.h+e)%360;return n.h=i<0?360+i:i,le(n)}function xe(t){var e=le(t).toHsl();return e.h=(e.h+180)%360,le(e)}function ke(t,e){if(isNaN(e)||e<=0)throw new Error("Argument to polyad must be a positive number");for(var n=le(t).toHsl(),i=[le(t)],r=360/e,a=1;a<e;a++)i.push(le({h:(n.h+a*r)%360,s:n.s,l:n.l}));return i}function Ae(t){var e=le(t).toHsl(),n=e.h;return[le(t),le({h:(n+72)%360,s:e.s,l:e.l}),le({h:(n+216)%360,s:e.s,l:e.l})]}function Me(t,e,n){e=e||6,n=n||30;var i=le(t).toHsl(),r=360/n,a=[le(t)];for(i.h=(i.h-(r*e>>1)+720)%360;--e;)i.h=(i.h+r)%360,a.push(le(i));return a}function Ee(t,e){e=e||6;for(var n=le(t).toHsv(),i=n.h,r=n.s,a=n.v,o=[],s=1/e;e--;)o.push(le({h:i,s:r,v:a})),a=(a+s)%1;return o}le.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 t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var t,e,n,i=this.toRgb();return t=i.r/255,e=i.g/255,n=i.b/255,.2126*(t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4))+.7152*(e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))+.0722*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))},setAlpha:function(t){return this._a=ze(t),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var t=ue(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=ue(this._r,this._g,this._b),e=Math.round(360*t.h),n=Math.round(100*t.s),i=Math.round(100*t.v);return 1==this._a?"hsv("+e+", "+n+"%, "+i+"%)":"hsva("+e+", "+n+"%, "+i+"%, "+this._roundA+")"},toHsl:function(){var t=fe(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=fe(this._r,this._g,this._b),e=Math.round(360*t.h),n=Math.round(100*t.s),i=Math.round(100*t.l);return 1==this._a?"hsl("+e+", "+n+"%, "+i+"%)":"hsla("+e+", "+n+"%, "+i+"%, "+this._roundA+")"},toHex:function(t){return de(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return function(t,e,n,i,r){var a=[Te(Math.round(t).toString(16)),Te(Math.round(e).toString(16)),Te(Math.round(n).toString(16)),Te(Oe(i))];if(r&&a[0].charAt(0)==a[0].charAt(1)&&a[1].charAt(0)==a[1].charAt(1)&&a[2].charAt(0)==a[2].charAt(1)&&a[3].charAt(0)==a[3].charAt(1))return a[0].charAt(0)+a[1].charAt(0)+a[2].charAt(0)+a[3].charAt(0);return a.join("")}(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},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*Be(this._r,255))+"%",g:Math.round(100*Be(this._g,255))+"%",b:Math.round(100*Be(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+Math.round(100*Be(this._r,255))+"%, "+Math.round(100*Be(this._g,255))+"%, "+Math.round(100*Be(this._b,255))+"%)":"rgba("+Math.round(100*Be(this._r,255))+"%, "+Math.round(100*Be(this._g,255))+"%, "+Math.round(100*Be(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(Se[de(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+pe(this._r,this._g,this._b,this._a),n=e,i=this._gradientType?"GradientType = 1, ":"";if(t){var r=le(t);n="#"+pe(r._r,r._g,r._b,r._a)}return"progid:DXImageTransform.Microsoft.gradient("+i+"startColorstr="+e+",endColorstr="+n+")"},toString:function(t){var e=!!t;t=t||this._format;var n=!1,i=this._a<1&&this._a>=0;return e||!i||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"hex4"!==t&&"hex8"!==t&&"name"!==t?("rgb"===t&&(n=this.toRgbString()),"prgb"===t&&(n=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(n=this.toHexString()),"hex3"===t&&(n=this.toHexString(!0)),"hex4"===t&&(n=this.toHex8String(!0)),"hex8"===t&&(n=this.toHex8String()),"name"===t&&(n=this.toName()),"hsl"===t&&(n=this.toHslString()),"hsv"===t&&(n=this.toHsvString()),n||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},clone:function(){return le(this.toString())},_applyModification:function(t,e){var n=t.apply(null,[this].concat([].slice.call(e)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(we,arguments)},brighten:function(){return this._applyModification(ye,arguments)},darken:function(){return this._applyModification(_e,arguments)},desaturate:function(){return this._applyModification(me,arguments)},saturate:function(){return this._applyModification(ge,arguments)},greyscale:function(){return this._applyModification(be,arguments)},spin:function(){return this._applyModification(ve,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(Me,arguments)},complement:function(){return this._applyCombination(xe,arguments)},monochromatic:function(){return this._applyCombination(Ee,arguments)},splitcomplement:function(){return this._applyCombination(Ae,arguments)},triad:function(){return this._applyCombination(ke,[3])},tetrad:function(){return this._applyCombination(ke,[4])}},le.fromRatio=function(t,e){if("object"==se(t)){var n={};for(var i in t)t.hasOwnProperty(i)&&(n[i]="a"===i?t[i]:Ue(t[i]));t=n}return le(t,e)},le.equals=function(t,e){return!(!t||!e)&&le(t).toRgbString()==le(e).toRgbString()},le.random=function(){return le.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})},le.mix=function(t,e,n){n=0===n?0:n||50;var i=le(t).toRgb(),r=le(e).toRgb(),a=n/100;return le({r:(r.r-i.r)*a+i.r,g:(r.g-i.g)*a+i.g,b:(r.b-i.b)*a+i.b,a:(r.a-i.a)*a+i.a})},le.readability=function(t,e){var n=le(t),i=le(e);return(Math.max(n.getLuminance(),i.getLuminance())+.05)/(Math.min(n.getLuminance(),i.getLuminance())+.05)},le.isReadable=function(t,e,n){var i,r,a=le.readability(t,e);switch(r=!1,(i=function(t){var e,n;e=((t=t||{level:"AA",size:"small"}).level||"AA").toUpperCase(),n=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA");"small"!==n&&"large"!==n&&(n="small");return{level:e,size:n}}(n)).level+i.size){case"AAsmall":case"AAAlarge":r=a>=4.5;break;case"AAlarge":r=a>=3;break;case"AAAsmall":r=a>=7}return r},le.mostReadable=function(t,e,n){var i,r,a,o,s=null,h=0;r=(n=n||{}).includeFallbackColors,a=n.level,o=n.size;for(var c=0;c<e.length;c++)(i=le.readability(t,e[c]))>h&&(h=i,s=le(e[c]));return le.isReadable(t,s,{level:a,size:o})||!r?s:(n.includeFallbackColors=!1,le.mostReadable(t,["#fff","#000"],n))};var Ie=le.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"},Se=le.hexNames=function(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[t[n]]=n);return e}(Ie);function ze(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function Be(t,e){(function(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)})(t)&&(t="100%");var n=function(t){return"string"==typeof t&&-1!=t.indexOf("%")}(t);return t=Math.min(e,Math.max(0,parseFloat(t))),n&&(t=parseInt(t*e,10)/100),Math.abs(t-e)<1e-6?1:t%e/parseFloat(e)}function Ce(t){return Math.min(1,Math.max(0,t))}function Pe(t){return parseInt(t,16)}function Te(t){return 1==t.length?"0"+t:""+t}function Ue(t){return t<=1&&(t=100*t+"%"),t}function Oe(t){return Math.round(255*parseFloat(t)).toString(16)}function Le(t){return Pe(t)/255}var Re,Fe,De,Ne=(Fe="[\\s|\\(]+("+(Re="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+Re+")[,|\\s]+("+Re+")\\s*\\)?",De="[\\s|\\(]+("+Re+")[,|\\s]+("+Re+")[,|\\s]+("+Re+")[,|\\s]+("+Re+")\\s*\\)?",{CSS_UNIT:new RegExp(Re),rgb:new RegExp("rgb"+Fe),rgba:new RegExp("rgba"+De),hsl:new RegExp("hsl"+Fe),hsla:new RegExp("hsla"+De),hsv:new RegExp("hsv"+Fe),hsva:new RegExp("hsva"+De),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})$/});function $e(t){return!!Ne.CSS_UNIT.exec(t)}function je(t,e){const[n,i,r]=e;return t.map(([t,e,a])=>n.map((o,s)=>t*n[s]+e*i[s]+a*r[s]))}function Ge(t,[e,n,i]){return t.map(t=>t[0]*e+t[1]*n+t[2]*i)}function He(t){const[[e,n,i],[r,a,o],[s,h,c]]=t,l=e*(a*c-o*h)-n*(r*c-o*s)+i*(r*h-a*s);return[[a*c-o*h,i*h-n*c,n*o-i*a],[o*s-r*c,e*c-i*s,i*r-e*o],[r*h-a*s,n*s-e*h,e*a-n*r]].map(t=>t.map(t=>t/l))}const Ze=[.9642,1,.8249],qe=[[.8951,.2664,-.1614],[-.7502,1.7135,.0367],[.0389,-.0685,1.0296]];function We(t,e){const n=([t,e])=>[t/e,1,(1-t-e)/e],i=n(e),r=[0,1,2].map(e=>t.map(t=>n(t)[e])),a=Ge(He(r),i),o=r.map(t=>t.map((t,e)=>t*a[e])),s=Ge(qe,i),h=Ge(qe,Ze),c=je(He(qe),je((([t,e,n])=>[[t,0,0],[0,e,0],[0,0,n]])(h.map((t,e)=>t/s[e])),qe));return je(c,o)}const Ve=t=>t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4),Je=[.3127,.329],Ye={name:"srgb",toXyz:We([[.64,.33],[.3,.6],[.15,.06]],Je),curves:[Ve,Ve,Ve]},Xe={name:"display-p3",toXyz:We([[.68,.32],[.265,.69],[.15,.06]],Je),curves:[Ve,Ve,Ve]},Ke={srgb:Ye,"display-p3":Xe},Qe=n.Buffer.from("AAACVAAAAAAEMAAAbW50clJHQiBYWVogB+oAAQABAAAAAAAAYWNzcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPbWAAEAAAAA0y0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKZGVzYwAAAPwAAAAwY3BydAAAASwAAABMd3RwdAAAAXgAAAAUclhZWgAAAYwAAAAUZ1hZWgAAAaAAAAAUYlhZWgAAAbQAAAAUclRSQwAAAcgAAAAgZ1RSQwAAAegAAAAgYlRSQwAAAggAAAAgY2hhZAAAAigAAAAsbWx1YwAAAAAAAAABAAAADGVuVVMAAAAUAAAAHABEAGkAcwBwAGwAYQB5ACAAUAAzbWx1YwAAAAAAAAABAAAADGVuVVMAAAAwAAAAHABOAG8AIABjAG8AcAB5AHIAaQBnAGgAdAAsACAAdQBzAGUAIABmAHIAZQBlAGwAeVhZWiAAAAAAAAD21gABAAAAANMtWFlaIAAAAAAAAIPhAAA9wP///7tYWVogAAAAAAAASr0AALE2AAAKuVhZWiAAAAAAAAAoNwAAEQoAAMi5cGFyYQAAAAAAAwAAAAJmZgAA8qcAAA1ZAAAT0AAACltwYXJhAAAAAAADAAAAAmZmAADypwAADVkAABPQAAAKW3BhcmEAAAAAAAMAAAACZmYAAPKnAAANWQAAE9AAAApbc2YzMgAAAAAAAQw/AAAF3f//8ycAAAeRAAD9kf//+6L///2iAAAD2wAAwHk=","base64"),tn={name:"custom"},en=t=>t<0?0:t>1?1:t;const nn=Array.from({length:17},(t,e)=>e/16);function rn(t,e,n){return e.every((e,n)=>e.every((e,i)=>Math.abs(e-t.toXyz[n][i])<.002))&&n.every((e,n)=>nn.every(i=>Math.abs(e(i)-t.curves[n](i))<.002))}function an(t){try{if("RGB "!==t.toString("latin1",16,20)||"XYZ "!==t.toString("latin1",20,24))return tn;const e=new Map,n=t.readUInt32BE(128);for(let i=0;i<n;i++){const n=132+12*i,r=t.readUInt32BE(n+4);e.set(t.toString("latin1",n,n+4),t.subarray(r,r+t.readUInt32BE(n+8)))}const i=["rXYZ","gXYZ","bXYZ"].map(t=>{const n=e.get(t);if("XYZ "!==n?.toString("latin1",0,4))throw new Error(`Missing ${t}`);return[8,12,16].map(t=>n.readInt32BE(t)/65536)}),r=[0,1,2].map(t=>i.map(e=>e[t])),a=["rTRC","gTRC","bTRC"].map(t=>function(t){const e=t?.toString("latin1",0,4);if(t&&"curv"===e){const e=t.readUInt32BE(8);if(0===e)return t=>t;if(1===e){const e=t.readUInt16BE(12)/256;return t=>Math.pow(t,e)}const n=Array.from({length:e},(e,n)=>t.readUInt16BE(12+2*n)/65535);return t=>{const i=en(t)*(e-1),r=Math.min(Math.floor(i),e-2);return n[r]+(n[r+1]-n[r])*(i-r)}}if(t&&"para"===e){const e=t.readUInt16BE(8),n=[1,3,4,5,7][e];if(!n)throw new Error(`Unknown parametric curve type ${e}`);const[i=1,r=1,a=0,o=0,s=0,h=0,c=0]=Array.from({length:n},(e,n)=>t.readInt32BE(12+4*n)/65536),l=t=>Math.pow(Math.max(r*t+a,0),i);switch(e){case 0:return t=>Math.pow(t,i);case 1:return t=>t>=-a/r?l(t):0;case 2:return t=>t>=-a/r?l(t)+o:o;case 3:return t=>t>=s?l(t):o*t;default:return t=>t>=s?l(t)+h:o*t+c}}throw new Error("Unsupported tone curve")}(e.get(t)));for(const t of[Ye,Xe])if(rn(t,r,a))return t;return{name:"custom",toXyz:r,curves:a}}catch{return tn}}const on=new WeakMap;function sn(t){return function(t){if(!t)return Ye;let e=on.get(t);return e||(e=an(n.Buffer.from(t.buffer,t.byteOffset,t.byteLength)),on.set(t,e)),e}(t.iccProfile)}function hn(t,e){return t!==e&&void 0!==t.toXyz&&void 0!==e.toXyz&&!(t.name===e.name&&"custom"!==t.name)}function cn(t,e,n){if(!hn(e,n))return t;const i=t.map((t,n)=>e.curves[n](en(t)));return Ge(je(He(n.toXyz),e.toXyz),i).map((t,e)=>function(t,e){let n=0,i=1;for(let r=0;r<32;r++){const r=(n+i)/2;t(r)<e?n=r:i=r}return(n+i)/2}(n.curves[e],en(t)))}const ln=65536;function fn(t){const e=new Uint8Array(ln),n=Array.from({length:255},(e,n)=>t((n+.5)/255));let i=0;for(let t=0;t<ln;t++){const r=t/65535;for(;i<255&&r>n[i];)i++;e[t]=i}return e}function un(t,e){if(!hn(t,e))return;const[n,i,r]=je(He(e.toXyz),t.toXyz),[a,o,s]=t.curves.map(t=>Float32Array.from({length:256},(e,n)=>t(n/255))),[h,c,l]=e.curves.map(fn),f=t=>t<=0?0:t>=1?65535:65535*t+.5|0;return t=>{for(let e=0;e<t.length;e+=4){const u=a[t[e]],d=o[t[e+1]],p=s[t[e+2]];t[e]=h[f(n[0]*u+n[1]*d+n[2]*p)],t[e+1]=c[f(i[0]*u+i[1]*d+i[2]*p)],t[e+2]=l[f(r[0]*u+r[1]*d+r[2]*p)]}}}function dn(t,e){const i=un(sn(t),sn(e));if(!i)return t.bitmap.data;const r=n.Buffer.from(t.bitmap.data);return i(r),r}const pn=/^color\(\s*(srgb|display-p3)\s+([^\s/)]+)\s+([^\s/)]+)\s+([^\s/)]+)\s*(?:\/\s*([^\s)]+)\s*)?\)$/i;function mn(t,e){if("none"===t)return 0;const n=t.endsWith("%")?parseFloat(t)/100:parseFloat(t);if(Number.isNaN(n))throw new Error(`Invalid color "${e}": bad channel "${t}"`);return en(n)}function gn(t){const e=Object.values(t).filter(t=>"number"==typeof t);return Object.entries(t).filter(([t,n])=>-1===e.indexOf(+t)).map(([t,e])=>e)}function bn(t,e="|"){return t.map(t=>Dn(t)).join(e)}function wn(t,e){return"bigint"==typeof e?e.toString():e}class yn{constructor(t){this._getter=t,this._value=void 0}get value(){const t=this._getter;return void 0!==t&&(this._value=t(),this._getter=void 0),this._value}}function _n(t){return new yn(t)}function vn(t){const e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}function xn(t,e,n){Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0})}function kn(t){const e=Object.getOwnPropertyDescriptor(t,"shape");return e?.get?e.get.raw:e?.value}function An(t){return kn(t._zod.def)??t._zod.def.shape}function Mn(t,e,n){Object.defineProperty(t,e,{get(){const t=n();return xn(this,e,t),t},enumerable:!0,configurable:!0})}function En(t,e,n){e in t?xn(t,e,n):t[e]=n}function In(t,e,n,i){const r=An(e);for(const a of n){const n=Object.getOwnPropertyDescriptor(r,a);n.enumerable&&(n.get?Mn(t,a,()=>{const t=e._zod.def.shape[a];return i?i(t,a):t}):En(t,a,i?i(n.value,a):n.value))}}function Sn(...t){const e={};for(const n of t){const t=Object.getOwnPropertyDescriptors(n);Object.assign(e,t)}return Object.defineProperties({},e)}function zn(t){return JSON.stringify(t)}const Bn="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function Cn(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}const Pn=_n(()=>{if(wi.jitless)return!1;if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(t){return!1}});function Tn(t){if(!1===Cn(t))return!1;const e=t.constructor;if(void 0===e)return!0;if("function"!=typeof e)return!0;const n=e.prototype;return!1!==Cn(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function Un(t){return Tn(t)?{...t}:Array.isArray(t)?[...t]:t instanceof Map?new Map(t):t instanceof Set?new Set(t):t}const On=new Set(["string","number","symbol"]);function Ln(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Rn(t,e,n){const i=new t._zod.constr(e??t._zod.def);return e&&!n?.parent||(i._zod.parent=t),i}function Fn(t){const e=t;if(!e)return{};if("string"==typeof e)return{error:()=>e};if(void 0!==e?.message){if(void 0!==e?.error)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,"string"==typeof e.error?{...e,error:()=>e.error}:e}function Dn(t){return"bigint"==typeof t?t.toString()+"n":"string"==typeof t?`"${t}"`:`${t}`}const Nn=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),$n={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function jn(t,e){const n=An(t),i=[];for(const t of Reflect.ownKeys(e)){if(!Object.getOwnPropertyDescriptor(n,t)?.enumerable)throw new Error(`Unrecognized key: "${String(t)}"`);e[t]&&i.push(t)}return i}function Gn(t,e){const n={};return In(n,t,Reflect.ownKeys(An(t))),function(t,e){for(const n of Reflect.ownKeys(e)){const i=Object.getOwnPropertyDescriptor(e,n);i.enumerable&&(i.get?Mn(t,n,()=>e[n]):En(t,n,i.value))}}(n,e),n}function Hn(t,e,n,i="partial"){const r=e._zod.def.checks;if(r&&r.length>0)throw new Error(`.${i}() cannot be used on object schemas containing refinements`);const a=n?new Set(jn(e,n)):void 0,o={};return In(o,e,Reflect.ownKeys(An(e)),t&&((e,n)=>a&&!a.has(n)?e:new t({type:"optional",innerType:e}))),Rn(e,Sn(e._zod.def,{shape:o,checks:[]}))}function Zn(t,e=0){if(!0===t.aborted)return!0;for(let n=e;n<t.issues.length;n++)if(!0!==t.issues[n]?.continue)return!0;return!1}function qn(t,e=0){if(!0===t.aborted)return!0;for(let n=e;n<t.issues.length;n++)if(!1===t.issues[n]?.continue)return!0;return!1}function Wn(t,e){return e.map(e=>{var n;return(n=e).path??(n.path=[]),e.path.unshift(t),e})}function Vn(t){return"string"==typeof t?t:t?.message}function Jn(t){const e=[];for(const n of t??[]){const t=n._zod.def;if(!/_(length|size)$|_equals$/.test(t.check))break;const i=t.maximum??t.length??t.size;i>=0&&e.push([i,n])}return e}function Yn(t,e,n){var i;for(let r=e;r<t.length;r++)(i=t[r]).schema??(i.schema=n)}function Xn(t,e,n){var i;const r=t.inst?._zod?.traits;r?.has("$ZodType")&&(r.has("$ZodCheck")?(i=t).schema??(i.schema=t.inst):t.schema=t.inst);const a=t.schema!==t.inst?t.schema?._zod.def?.error:void 0,o=t.message?t.message:Vn(t.inst?._zod.def?.error?.(t))??Vn(a?.(t))??Vn(e?.error?.(t))??Vn(n.customError?.(t))??Vn(n.localeError?.(t))??"Invalid input",s={};for(const e of Object.keys(t))"inst"!==e&&"schema"!==e&&"continue"!==e&&"input"!==e&&"__proto__"!==e&&(s[e]=t[e]);return s.path??(s.path=[]),s.message=o,e?.reportInput&&(s.input=t.input),s}const Kn=/[\uD800-\uDBFF]/;function Qn(t){const e=t.length;if(!Kn.test(t))return e;let n=e;for(let i=0;i<e-1;i++)55296==(64512&t.charCodeAt(i))&&56320==(64512&t.charCodeAt(i+1))&&(n--,i++);return n}function ti(t){return Array.isArray(t)?"array":"string"==typeof t?"string":"unknown"}function ei(...t){const[e,n,i]=t;return"string"==typeof e?{message:e,code:"custom",input:n,inst:i}:{...e}}function ni(t,e,n,i=!0){return Object.defineProperty(t,e,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function ii(t,e,n){return ni(t,e,n,!1)}function ri(t,e){for(const n in t){const i=t[n];Object.defineProperty(e,n,{configurable:!0,enumerable:!0,get(){return ni(this,n,i(this))},set(t){ni(this,n,t)}})}return e}function ai(t,e,n){Object.defineProperty(t,e,{configurable:!0,get(){return null==this?n:ni(this,e,n.bind(this))},set(t){ni(this,e,t)}})}let oi,si=!1;const hi={configurable:!0,get(){si=!0}};function ci(t,e,n){const i=Object.getPrototypeOf(t._zod);e in i&&oi!==t._zod?oi=void 0:(oi=t._zod,Object.defineProperty(i,e,{configurable:!0,get(){Object.defineProperty(this,e,hi);const t=si;si=!1;try{const i=n(this);return si?delete this[e]:Object.defineProperty(this,e,{configurable:!0,writable:!0,value:i}),si=si||t,i}catch(n){throw delete this[e],si=si||t,n}},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}}))}function li(t,e,n,i){const r=function(t,e){const n=Object.getPrototypeOf(t);return e in n?void 0:n}(t,e);r&&Object.defineProperty(r,e,{configurable:!0,get(){const t={configurable:!0,writable:!0,enumerable:i,value:void 0};return Object.defineProperty(this,e,t),t.value=n(this),Object.defineProperty(this,e,t),t.value},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:i,value:t})}})}function fi(t){const e=()=>t;return e["~constantCatch"]=!0,e}var ui;const di={value:void 0,enumerable:!1};let pi="captureStackTrace"in Error?Error:null;function mi(t,e,n,i){function r(t){this.def=t,this.constr=l,this.traits=new Set}r.prototype={};const a=n,o=a&&new WeakSet;function s(n,i){if(n._zod){if(n._zod.traits.has(t))return}else{di.value=new r(i);try{Object.defineProperty(n,"_zod",di)}finally{di.value=void 0}}if(n._zod.traits.add(t),e(n,i),o){const t=Object.getPrototypeOf(n),e=n._zod.constr.prototype;let i=t;for(;i&&i!==e;)i=Object.getPrototypeOf(i);const r=i??t;o.has(r)||(o.add(r),function(t,e){for(const n in e){const i=Object.getOwnPropertyDescriptor(e,n);i.get?Object.defineProperty(t,n,{...i,enumerable:!1}):ai(t,n,i.value)}}(r,a))}const s=l.prototype;for(const t in s)Object.prototype.hasOwnProperty.call(s,t)&&(t in n||(n[t]=s[t].bind(n)))}const h=i?.Parent??Object;class c extends h{}function l(t){const e=i?.Parent?function(t){const e=pi;if(e){const n=e.stackTraceLimit;if("number"==typeof n){try{e.stackTraceLimit=0}catch{return pi=null,new t}try{return new t}finally{e.stackTraceLimit=n}}}return new t}(c):this;s(e,t);const n=e._zod.deferred;if(n){for(const t of n)t();e._zod.deferred=void 0}const r=globalThis.__zod_globalConfig?.postProcessor;return r&&r(e),e}return Object.defineProperty(c,"name",{value:t}),Object.defineProperty(l,"init",{value:s}),Object.defineProperty(l,Symbol.hasInstance,{value:e=>!!(i?.Parent&&e instanceof i.Parent)||e?._zod?.traits?.has(t)}),Object.defineProperty(l,"name",{value:t}),l}class gi extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class bi extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(ui=globalThis).__zod_globalConfig??(ui.__zod_globalConfig={});const wi=globalThis.__zod_globalConfig;function yi(t){return t&&Object.assign(wi,t),wi}const _i={get:function(){const t=this._zod;return t.message??(t.message=JSON.stringify(t.def,wn,2)),t.message},set:function(t){this._zod.message=t},enumerable:!0,configurable:!0},vi={value:void 0,enumerable:!1},xi=new WeakSet([Object.prototype,Error.prototype]),ki=(t,e)=>{t.name="$ZodError",vi.value=e,Object.defineProperty(t,"issues",vi),vi.value=void 0,Object.defineProperty(t,"message",_i);const n=Object.getPrototypeOf(t);xi.has(n)||(xi.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){const t=()=>this.message;return Object.defineProperty(this,"toString",{value:t,configurable:!0,writable:!0}),t},set(t){Object.defineProperty(this,"toString",{value:t,configurable:!0,writable:!0})}}))},Ai=mi("$ZodError",ki),Mi=mi("$ZodError",ki,void 0,{Parent:Error});function Ei(t,e,n){return Object.prototype.hasOwnProperty.call(t,e)||("__proto__"===e?Object.defineProperty(t,e,{value:n(),writable:!0,enumerable:!0,configurable:!0}):t[e]=n()),t[e]}function Ii(t,e){return{callee:e?.callee??t,Err:e?.Err}}const Si=t=>{const e=(n,i,r,a)=>{const o=r?{...r,async:!1}:{async:!1},s=n._zod.run({value:i,issues:[]},o);if(s instanceof Promise)throw new gi;if(s.issues.length){const n=new(a?.Err??t)(s.issues.map(t=>Xn(t,o,yi())));throw Bn(n,a?.callee??e),n}return s.value};return e},zi=Si(Mi),Bi=t=>{const e=async(n,i,r,a)=>{const o=r?{...r,async:!0}:{async:!0};let s=n._zod.run({value:i,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){const n=new(a?.Err??t)(s.issues.map(t=>Xn(t,o,yi())));throw Bn(n,a?.callee??e),n}return s.value};return e},Ci=Bi(Mi),Pi=t=>(e,n,i)=>{const r=i?{...i,async:!1}:{async:!1},a=e._zod.run({value:n,issues:[]},r);if(a instanceof Promise)throw new gi;return a.issues.length?Ti(t,a.issues,r):{success:!0,data:a.value}};function Ti(t,e,n){let i;return{success:!1,get error(){return i||(i=new t(e.map(t=>Xn(t,n,yi()))),e=void 0,n=void 0),i},set error(t){i=t,e=void 0,n=void 0}}}const Ui=t=>async(e,n,i)=>{const r=i?{...i,async:!0}:{async:!0};let a=e._zod.run({value:n,issues:[]},r);return a instanceof Promise&&(a=await a),a.issues.length?Ti(t,a.issues,r):{success:!0,data:a.value}},Oi=Symbol.for("zod.compile.invalid"),Li=Symbol.for("zod.compile.fallback"),Ri=(t,e,n)=>{const i=t._zod.bag.validator;if(void 0!==i){if(i(e)!==Oi)return!0;if(!0===i.definite&&void 0===n)return!1}return function(t,e,n){const i=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=t._zod.bag.fallbackRun;let a;r?(i[Li]=!0,a=r({value:e,issues:[]},i)):a=t._zod.run({value:e,issues:[]},i);if(a instanceof Promise)throw new gi;return 0===a.issues.length}(t,e,n)};const Fi=t=>{const e=Si(t),n=(t,i,r,a)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return e(t,i,o,Ii(n,a))};return n},Di=t=>{const e=Si(t),n=(t,i,r,a)=>e(t,i,r,Ii(n,a));return n},Ni=t=>{const e=Bi(t),n=async(t,i,r,a)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return await e(t,i,o,Ii(n,a))};return n},$i=t=>{const e=Bi(t),n=async(t,i,r,a)=>await e(t,i,r,Ii(n,a));return n},ji=t=>(e,n,i)=>{const r=i?{...i,direction:"backward"}:{direction:"backward"};return Pi(t)(e,n,r)},Gi=t=>(e,n,i)=>Pi(t)(e,n,i),Hi=t=>async(e,n,i)=>{const r=i?{...i,direction:"backward"}:{direction:"backward"};return Ui(t)(e,n,r)},Zi=t=>async(e,n,i)=>Ui(t)(e,n,i),qi=/^[cC][0-9a-z]{6,}$/,Wi=/^[0-9a-z]+$/,Vi=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Ji=/^[0-9a-vA-V]{20}$/,Yi=/^[A-Za-z0-9]{27}$/,Xi=/^[a-zA-Z0-9_-]{21}$/;const Ki=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Qi=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,tr=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,er=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;const nr=/^(?:(?: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])$/,ir=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,rr=/^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/,ar=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,or=/^https?$/,sr=/^\+[1-9]\d{6,14}$/,hr="(?:(?:\\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])))";function cr(t){return new RegExp(`^${t}$`)}const lr=cr(hr);function fr(t){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof t.precision?-1===t.precision?`${e}`:0===t.precision?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:t.seconds?`${e}:[0-5]\\d(?:\\.\\d+)?`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}const ur=/^[\s\S]{0,}$/,dr=/^-?\d+(?:\.\d+)?$/,pr=/^(?:true|false)$/i,mr=/^[^A-Z]*$/,gr=/^[^a-z]*$/,br=mi("$ZodCheck",(t,e)=>{var n;t._zod??(t._zod={}),t._zod.def=e,(n=t._zod).onattach??(n.onattach=[])}),wr=t=>{const e=t.value;return!(n=e,null==n||void 0===e.length);var n},yr={number:"number",bigint:"bigint",object:"date"},_r=mi("$ZodCheckLessThan",(t,e)=>{br.init(t,e);const n=yr[typeof e.value];t._zod.check=i=>{(e.inclusive?i.value<=e.value:i.value<e.value)||i.issues.push({origin:yr[typeof i.value]??n,code:"too_big",maximum:"object"==typeof e.value?e.value.getTime():e.value,input:i.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),vr=mi("$ZodCheckGreaterThan",(t,e)=>{br.init(t,e);const n=yr[typeof e.value];t._zod.check=i=>{(e.inclusive?i.value>=e.value:i.value>e.value)||i.issues.push({origin:yr[typeof i.value]??n,code:"too_small",minimum:"object"==typeof e.value?e.value.getTime():e.value,input:i.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),xr=mi("$ZodCheckMultipleOf",(t,e)=>{br.init(t,e),t._zod.check=n=>{if(typeof n.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof n.value?e.value!==BigInt(0)&&n.value%e.value===BigInt(0):0===function(t,e){const n=t/e,i=Math.round(n),r=4*Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-i)<r?0:n-i}(n.value,e.value))||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:e.value,input:n.value,inst:t,continue:!e.abort})}}),kr=mi("$ZodCheckNumberFormat",(t,e)=>{br.init(t,e),e.format=e.format||"float64";const n=e.format?.includes("int"),i=n?"int":"number",[r,a]=Nn[e.format];t._zod.check=o=>{const s=o.value;if(n){if(!Number.isInteger(s))return void o.issues.push({expected:i,format:e.format,code:"invalid_type",continue:!1,input:s,inst:t});if(!Number.isSafeInteger(s))return void(s>0?o.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:i,inclusive:!0,continue:!e.abort}):o.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:i,inclusive:!0,continue:!e.abort}))}s<r&&o.issues.push({origin:"number",input:s,code:"too_small",minimum:r,inclusive:!0,inst:t,continue:!e.abort}),s>a&&o.issues.push({origin:"number",input:s,code:"too_big",maximum:a,inclusive:!0,inst:t,continue:!e.abort})}}),Ar=mi("$ZodCheckMaxLength",(t,e)=>{var n;br.init(t,e),(n=t._zod.def).when??(n.when=wr),t._zod.check=n=>{const i=n.value,r=i.length;if(("string"==typeof i&&r>e.maximum?Qn(i):r)<=e.maximum)return;const a=ti(i);n.issues.push({origin:a,code:"too_big",maximum:e.maximum,inclusive:!0,input:i,inst:t,continue:!e.abort})}}),Mr=mi("$ZodCheckMinLength",(t,e)=>{var n;br.init(t,e),(n=t._zod.def).when??(n.when=wr),t._zod.check=n=>{const i=n.value,r=i.length;if(("string"==typeof i&&r>=e.minimum&&r<2*e.minimum?Qn(i):r)>=e.minimum)return;const a=ti(i);n.issues.push({origin:a,code:"too_small",minimum:e.minimum,inclusive:!0,input:i,inst:t,continue:!e.abort})}}),Er=mi("$ZodCheckLengthEquals",(t,e)=>{var n;br.init(t,e),(n=t._zod.def).when??(n.when=wr),t._zod.check=n=>{const i=n.value,r=i.length,a="string"==typeof i&&r>=e.length&&r<=2*e.length?Qn(i):r;if(a===e.length)return;const o=ti(i),s=a>e.length;n.issues.push({origin:o,...s?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:n.value,inst:t,continue:!e.abort})}}),Ir=mi("$ZodCheckStringFormat",(t,e)=>{var n,i;br.init(t,e),e.pattern?(n=t._zod).check??(n.check=n=>{e.pattern.lastIndex=0,e.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:e.format,input:n.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(i=t._zod).check??(i.check=()=>{})}),Sr=mi("$ZodCheckRegex",(t,e)=>{Ir.init(t,e),t._zod.check=n=>{e.pattern.lastIndex=0,e.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),zr=mi("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=mr),Ir.init(t,e)}),Br=mi("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=gr),Ir.init(t,e)}),Cr=mi("$ZodCheckIncludes",(t,e)=>{br.init(t,e);const n=Ln(e.includes),i=new RegExp("number"==typeof e.position?`^.{${e.position},}${n}`:n);e.pattern=i,t._zod.check=n=>{n.value.includes(e.includes,e.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:n.value,inst:t,continue:!e.abort})}}),Pr=mi("$ZodCheckStartsWith",(t,e)=>{br.init(t,e);const n=new RegExp(`^${Ln(e.prefix)}.*`);e.pattern??(e.pattern=n),t._zod.check=n=>{n.value.startsWith(e.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:n.value,inst:t,continue:!e.abort})}}),Tr=mi("$ZodCheckEndsWith",(t,e)=>{br.init(t,e);const n=new RegExp(`.*${Ln(e.suffix)}$`);e.pattern??(e.pattern=n),t._zod.check=n=>{n.value.endsWith(e.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:n.value,inst:t,continue:!e.abort})}});function Ur(t,e,n){t.issues.length&&e.issues.push(...Wn(n,t.issues))}const Or=mi("$ZodCheckProperties",(t,e)=>{let n;br.init(t,e),ii(t,Symbol.iterator,function*(){yield t}),t._zod.check=i=>{if(null==i.value)return void i.issues.push({expected:"object",code:"invalid_type",input:i.value,inst:t});n??(n=Reflect.ownKeys(e.shape).map(t=>[t,e.shape[t]]));const r=i.value;let a;for(const[t,e]of n){const n=e._zod.run({value:r[t],issues:[]},{});n instanceof Promise?(a??(a=[]),a.push(n.then(e=>Ur(e,i,t)))):Ur(n,i,t)}return a?Promise.all(a).then(()=>{}):void 0}}),Lr=mi("$ZodCheckOverwrite",(t,e)=>{br.init(t,e),t._zod.check=t=>{t.value=e.tx(t.value)}});class Rr{constructor(t=[],e={}){this.content=[],this.indent=0,this.args=t,this.closed=e}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if("function"==typeof t)return t(this,{execution:"sync"}),void t(this,{execution:"async"});const e=t.split("\n").filter(t=>t),n=Math.min(...e.map(t=>t.length-t.trimStart().length)),i=e.map(t=>t.slice(n)).map(t=>" ".repeat(2*this.indent)+t);for(const t of i)this.content.push(t)}compile(){const t=Function,e=this?.content??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {\n${e.join("\n")}\n};`)(...Object.values(this.closed))}}const Fr={major:4,minor:6,patch:7},Dr=mi("$ZodType",(t,e)=>{var n;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=Fr;const i=t._zod.def.checks,r=t._zod.traits.has("$ZodCheck")?[t,...i??[]]:i?.length?[...i]:[];for(const e of r)for(const n of e._zod.onattach)n(t);if(0===r.length)(n=t._zod).deferred??(n.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{const e=(e,n,i)=>{if(e.memo)return e;let r,a=Zn(e);for(const o of n){if(o._zod.def.when){if(qn(e))continue;if(!o._zod.def.when(e))continue}else if(a)continue;const n=e.issues.length,s=o._zod.check(e);if(s instanceof Promise&&!1===i?.async)throw new gi;if(r||s instanceof Promise)r=(r??Promise.resolve()).then(async()=>{await s;e.issues.length!==n&&(Yn(e.issues,n,t),a||(a=Zn(e,n)))});else{if(e.issues.length===n)continue;Yn(e.issues,n,t),a||(a=Zn(e,n))}}return r?r.then(()=>e):e},n=(n,i,a)=>{if(Zn(n))return n.aborted=!0,n;const o=e(i,r,a);if(o instanceof Promise){if(!1===a.async)throw new gi;return o.then(e=>t._zod.parse(e,a))}return t._zod.parse(o,a)};t._zod.run=(i,a)=>{if(a.skipChecks)return t._zod.parse(i,a);if("backward"===a.direction){const e=t._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return e instanceof Promise?e.then(t=>n(t,i,a)):n(e,i,a)}const o=t._zod.parse(i,a);if(o instanceof Promise){if(!1===a.async)throw new gi;return o.then(t=>e(t,r,a))}return e(o,r,a)}}},{get"~standard"(){return ii(this,"~standard",$r(this))},set"~standard"(t){ni(this,"~standard",t)}}),Nr=(t,e)=>t.issues.length?{issues:t.issues.map(t=>Xn(t,e,yi()))}:{value:t.value};function $r(t){return{validate:e=>{const n={async:!1};try{const i=t._zod.run({value:e,issues:[]},n);if(!(i instanceof Promise))return Nr(i,n)}catch(t){}return async function(t,e){const n={async:!0};return Nr(await t._zod.run({value:e,issues:[]},n),n)}(t,e)},vendor:"zod",version:1}}const jr=mi("$ZodString",(t,e)=>{Dr.init(t,e),t._zod.pattern=e.pattern??ur,t._zod.parse=(n,i)=>{if(e.coerce)try{n.value=String(n.value)}catch(i){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:t}),n}}),Gr=mi("$ZodStringFormat",(t,e)=>{Ir.init(t,e),jr.init(t,e)}),Hr=mi("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=Qi),Gr.init(t,e)}),Zr=mi("$ZodUUID",(t,e)=>{if(e.version){const t={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(void 0===t)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=tr(t))}else e.pattern??(e.pattern=tr());Gr.init(t,e)}),qr=mi("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=er),Gr.init(t,e)});function Wr(t){try{return"undefined"!=typeof URL&&"function"==typeof URL.canParse?URL.canParse(t):(new URL(t),!0)}catch{return!1}}function Vr(t,e){return"normalize"in e||"hostname"in e||"protocol"in e?function(t,e){if(!e.normalize&&e.protocol?.source===or.source&&!/^https?:\/\//i.test(t))return 1;try{if("undefined"!=typeof URL){const e=URL;if("function"==typeof e.parse)return e.parse(t)??2}return new URL(t)}catch{return 2}}(t,e):Wr(t)||2}const Jr=/[\t\n\r]/g;function Yr(t){return t.replace(Jr,"")}const Xr=mi("$ZodURL",(t,e)=>{Gr.init(t,e),t._zod.check=n=>{try{const i=n.value.trim(),r=Vr(i,e);return 1===r?void n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:t,continue:!e.abort}):2===r?void n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:t,continue:!e.abort}):!0===r?void(n.value=Yr(i)):(e.hostname&&!function(t,e){return e.lastIndex=0,e.test(t.hostname)}(r,e.hostname)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:n.value,inst:t,continue:!e.abort}),e.protocol&&!function(t,e){return e.lastIndex=0,e.test(t.protocol.endsWith(":")?t.protocol.slice(0,-1):t.protocol)}(r,e.protocol)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:n.value,inst:t,continue:!e.abort}),void(n.value=e.normalize?r.href:Yr(i)))}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:t,continue:!e.abort})}}}),Kr=mi("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=new RegExp("^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$","u")),Gr.init(t,e)}),Qr=mi("$ZodNanoID",(t,e)=>{if(void 0!==e.length&&(!Number.isInteger(e.length)||e.length<1))throw new Error(`Invalid nanoid length: ${e.length}`);var n;e.pattern??(e.pattern=void 0===e.length?Xi:(n=e.length,new RegExp(`^[a-zA-Z0-9_-]{${n}}$`))),Gr.init(t,e)}),ta=mi("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=qi),Gr.init(t,e)}),ea=mi("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=Wi),Gr.init(t,e)}),na=mi("$ZodULID",(t,e)=>{e.pattern??(e.pattern=Vi),Gr.init(t,e)}),ia=mi("$ZodXID",(t,e)=>{e.pattern??(e.pattern=Ji),Gr.init(t,e)}),ra=mi("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=Yi),Gr.init(t,e)}),aa=mi("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=function(t){const e=["Z"];t.offset&&e.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${fr({precision:t.precision,seconds:!0})}(?:${e.join("|")})`,i=t.local?`${n}|${fr({precision:t.precision})}`:n;return new RegExp(`^${hr}T(?:${i})$`)}(e)),Gr.init(t,e)}),oa=mi("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=lr),Gr.init(t,e)}),sa=mi("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=new RegExp(`^${fr(e)}$`)),Gr.init(t,e)}),ha=mi("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=Ki),Gr.init(t,e)}),ca=mi("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=nr),Gr.init(t,e)}),la=/^[0-9a-fA-F:.]+$/;function fa(t){return!!la.test(t)&&Wr(`http://[${t}]`)}const ua=mi("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=ir),Gr.init(t,e),t._zod.check=n=>{fa(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:t,continue:!e.abort})}}),da=mi("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=rr),Gr.init(t,e)});const pa=mi("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=ar),Gr.init(t,e),t._zod.check=n=>{(function(t){const e=t.split("/");if(2!==e.length)return!1;const[n,i]=e;if(!i)return!1;const r=Number(i);return`${r}`===i&&!(r<0||r>128)&&fa(n)})(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:t,continue:!e.abort})}});function ma(t){if(""===t)return!0;if(/\s/.test(t))return!1;if(t.length%4!=0)return!1;try{return atob(t),!0}catch{return!1}}const ga=/^[0-9a-zA-Z+/]*={0,2}$/,ba=mi("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=ga),Gr.init(t,e),t._zod.check=n=>{ma(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:t,continue:!e.abort})}}),wa=/^[A-Za-z0-9_-]*$/;const ya=mi("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=wa),Gr.init(t,e),t._zod.check=n=>{(function(t){if(!wa.test(t))return!1;const e=t.replace(/[-_]/g,t=>"-"===t?"+":"/");return ma(e.padEnd(4*Math.ceil(e.length/4),"="))})(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:t,continue:!e.abort})}}),_a=mi("$ZodE164",(t,e)=>{e.pattern??(e.pattern=sr),Gr.init(t,e)});const va=mi("$ZodJWT",(t,e)=>{Gr.init(t,e),t._zod.check=n=>{(function(t,e=null){try{const n=t.split(".");if(3!==n.length)return!1;const[i]=n;if(!i)return!1;const r=JSON.parse(atob(i));return!("typ"in r&&"JWT"!==r?.typ||!r.alg||e&&(!("alg"in r)||r.alg!==e))}catch{return!1}})(n.value,e.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:t,continue:!e.abort})}}),xa=mi("$ZodNumber",(t,e)=>{Dr.init(t,e),t._zod.pattern=dr,t._zod.parse=(n,i)=>{if(e.coerce)try{n.value=Number(n.value)}catch(t){}const r=n.value;if("number"==typeof r&&!Number.isNaN(r)&&Number.isFinite(r))return n;const a="number"==typeof r?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:String(r):void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:t,...a?{received:a}:{}}),n}}),ka=mi("$ZodNumberFormat",(t,e)=>{kr.init(t,e),xa.init(t,e)}),Aa=mi("$ZodBoolean",(t,e)=>{Dr.init(t,e),t._zod.pattern=pr,t._zod.parse=(n,i)=>{if(e.coerce)try{n.value=Boolean(n.value)}catch(t){}const r=n.value;return"boolean"==typeof r||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:t}),n}}),Ma=mi("$ZodUnknown",(t,e)=>{Dr.init(t,e),t._zod.parse=t=>t}),Ea=mi("$ZodNever",(t,e)=>{Dr.init(t,e),t._zod.parse=(e,n)=>(e.issues.push({expected:"never",code:"invalid_type",input:e.value,inst:t}),e)});const Ia=t=>Array.isArray(t)?t.length:-1;function Sa(t,e,n){t.issues.length&&e.issues.push(...Wn(n,t.issues)),e.value[n]=t.value}const za=mi("$ZodArray",(t,e)=>{Dr.init(t,e);const n=wi.memoizer;n?.attach(t),t._zod.parse=(i,r)=>{const a=i.value;if(!Array.isArray(a))return i.issues.push({expected:"array",code:"invalid_type",input:a,inst:t}),i;i.value=n?n.alloc(t,i,Array(a.length),r):Array(a.length);const o=[],s=r?.abortEarly;for(let t=0;t<a.length;t++){const n=a[t],h=e.element._zod.run({value:n,issues:[]},r);if(h instanceof Promise)o.push(h.then(e=>Sa(e,i,t)));else if(Sa(h,i,t),s&&0!==h.issues.length&&Zn(h))break}return o.length?Promise.all(o).then(()=>i):i},function(t,e){const n=Jn(t._zod.def.checks);if(!n.length)return;const i=Math.min(...n.map(t=>t[0])),r=t._zod.parse;t._zod.parse=(n,a)=>{const o=e(n.value);if(o>i&&!a?.skipChecks&&"backward"!==a?.direction)for(const[e,i]of Jn(t._zod.def.checks))if(o>e&&i._zod.def.when(n)){const e=n.issues.length;return i._zod.check(n),n.issues[e].continue=!1,Yn(n.issues,e,t),n}return r(n,a)}}(t,Ia)});function Ba(t,e,n,i,r,a){const o=n in i,s="optional"===a;if(o||!s||"optional"!==r){if(t.issues.length){if(void 0!==r&&s&&!o)return;e.issues.push(...Wn(n,t.issues))}o||void 0!==r?void 0===t.value?(o||"defaulted"===r&&!s)&&(e.value[n]=void 0):e.value[n]=t.value:t.issues.length||e.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]})}}const Ca=[];function Pa(t){const e=Object.keys(t.shape),n=Object.getOwnPropertySymbols(t.shape),i=n.length?n:Ca,r=i.length?[...e,...i]:e;for(const e of r)if(!t.shape?.[e]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(e)}": expected a Zod schema`);const a=(o=t.shape,Object.keys(o).filter(t=>void 0!==o[t]._zod.optin&&"optional"===o[t]._zod.optout));var o;return{...t,allKeys:r,symbolKeys:i,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(a)}}function Ta(t,e,n,i,r,a,o){const s=[],h=r.keySet,c=r.catchall._zod,l=c.def.type,f=c.optin,u=c.optout;let d=0;for(const r in e){if(o&&n.issues.length!==d){if(Zn(n,d))break;d=n.issues.length}if(h.has(r))continue;if("__proto__"===r){"never"===l&&s.push(r);continue}if("never"===l){s.push(r);continue}const a=c.run({value:e[r],issues:[]},i);a instanceof Promise?t.push(a.then(t=>Ba(t,n,r,e,f,u))):Ba(a,n,r,e,f,u)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:e,inst:a,continue:!0}),t.length?Promise.all(t).then(()=>n):n}const Ua=mi("$ZodObject",(t,e)=>{Dr.init(t,e);const n=Object.getOwnPropertyDescriptor(e,"shape"),i=n?.get?n.get.raw:e.shape??{};if(i){const t=()=>{const n={...i};return Object.defineProperty(e,"shape",{value:n}),t.raw=n,n};t.raw=i,Object.defineProperty(e,"shape",{get:t})}const r=_n(()=>Pa(e));ci(t,"propValues",t=>{const e=t.def.shape,n={};for(const t in e){const i=e[t]._zod;if(i.values){Object.prototype.hasOwnProperty.call(n,t)||xn(n,t,new Set);for(const e of i.values)n[t].add(e);void 0!==i.optin&&n[t].add(void 0)}}return n});const a=Cn,o=e.catchall;let s;const h=wi.memoizer;h?.attach(t),t._zod.parse=(e,n)=>{s??(s=r.value);const i=e.value;if(!a(i))return e.issues.push({expected:"object",code:"invalid_type",input:i,inst:t}),e;e.value=h?h.alloc(t,e,{},n):{};const c=[],l=s.shape,f=n?.abortEarly;let u=e.issues.length;for(const t of s.allKeys){if(f&&e.issues.length!==u){if(Zn(e,u))break;u=e.issues.length}if("__proto__"===t)continue;const r=l[t],a=r._zod.optin,o=r._zod.optout,s=r._zod.run({value:i[t],issues:[]},n);s instanceof Promise?c.push(s.then(n=>Ba(n,e,t,i,a,o))):Ba(s,e,t,i,a,o)}return o?Ta(c,i,e,n,r.value,t,!0===f):c.length?Promise.all(c).then(()=>e):e}}),Oa=mi("$ZodObjectJIT",(t,e)=>{Ua.init(t,e);const n=t._zod.parse,i=_n(()=>Pa(e)),r=wi.memoizer;let a;const o=Cn,s=!wi.jitless,h=s&&Pn.value,c=e.catchall;let l;t._zod.parse=(f,u)=>{l??(l=i.value);const d=f.value;return o(d)?s&&h&&!1===u?.async&&!0!==u.jitless?(a||(a=(e=>{const n=i.value,a=n.symbolKeys,o=new Rr(["payload","ctx"],{shape:e,inst:t,memo:r,syms:a}),s=t=>`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`,h=(t,e)=>`\n          let ${t}_ab = false;\n          for (let i = 0; i < ${t}.issues.length; i++) {\n            const iss = ${t}.issues[i];\n            iss.path = iss.path ? [${e}, ...iss.path] : [${e}];\n            payload.issues.push(iss);\n            if (iss.continue !== true) ${t}_ab = true;\n          }\n          if (${t}_ab && ctx && ctx.abortEarly) {\n            payload.value = newResult;\n            return payload;\n          }`;o.write("const input = payload.value;");const c=Object.create(null);let l=0;for(const t of n.allKeys)c[t]="key_"+l++;o.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const t of n.allKeys){if("__proto__"===t)continue;const n=c[t],i="symbol"==typeof t?`syms[${a.indexOf(t)}]`:zn(t),r=`${i} in input`,l=e[t],f=l?._zod?.optin,u=void 0!==f,d="optional"===l?._zod?.optout;if(o.write(`const ${n} = ${s(i)};`),u&&d){const t="optional"===f?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`\n        const ${n}_present = ${r};\n        if (!${n}.issues.length || ${n}_present) {\n          if (${n}.issues.length) {${h(n,i)}\n          }\n\n          if (${t}) {\n            newResult[${i}] = ${n}.value;\n          }\n        }\n\n      `)}else u?(o.write(`\n        if (${n}.issues.length) {${h(n,i)}\n        }\n      `),"defaulted"===f?o.write(`newResult[${i}] = ${n}.value;`):o.write(`\n        if (${n}.value !== undefined || ${r}) {\n          newResult[${i}] = ${n}.value;\n        }\n      `)):o.write(`\n        const ${n}_present = ${r};\n        if (${n}.issues.length) {${h(n,i)}\n        }\n        if (!${n}_present && !${n}.issues.length) {\n          payload.issues.push({\n            code: "invalid_type",\n            expected: "nonoptional",\n            input: undefined,\n            path: [${i}]\n          });\n          if (ctx && ctx.abortEarly) {\n            payload.value = newResult;\n            return payload;\n          }\n        }\n\n        if (${n}_present) {\n          newResult[${i}] = ${n}.value;\n        }\n\n      `)}return o.write("payload.value = newResult;"),o.write("return payload;"),o.compile()})(e.shape)),f=a(f,u),c?Ta([],d,f,u,l,t,!0===u?.abortEarly):f):n(f,u):(f.issues.push({expected:"object",code:"invalid_type",input:d,inst:t}),f)}});function La(t,e,n,i){for(const n of t)if(0===n.issues.length)return e.value=n.value,e;const r=t.filter(t=>!Zn(t));return 1===r.length?(e.value=r[0].value,r[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:n,errors:t.map(t=>t.issues.map(t=>Xn(t,i,yi())))}),e)}const Ra=mi("$ZodUnion",(t,e)=>{Dr.init(t,e),ci(t,"optin",t=>t.def.options.some(t=>"defaulted"===t._zod.optin)?"defaulted":t.def.options.some(t=>void 0!==t._zod.optin)?"optional":void 0),ci(t,"optout",t=>t.def.options.some(t=>"optional"===t._zod.optout)?"optional":void 0),ci(t,"values",t=>{if(t.def.options.every(t=>t._zod.values))return new Set(t.def.options.flatMap(t=>Array.from(t._zod.values)))}),ci(t,"pattern",t=>{if(t.def.options.every(t=>t._zod.pattern)){const e=t.def.options.map(t=>t._zod.pattern);return new RegExp(`^(${e.map(t=>vn(t.source)).join("|")})$`)}});const n=1===e.options.length?e.options[0]._zod.run:null;t._zod.parse=(i,r)=>{if(n)return n(i,r);let a=!1;const o=[];for(const t of e.options){const e=t._zod.run({value:i.value,issues:[]},r);if(e instanceof Promise)o.push(e),a=!0;else{if(0===e.issues.length)return e;o.push(e)}}return a?Promise.all(o).then(e=>La(e,i,t,r)):La(o,i,t,r)}});const Fa=mi("$ZodDiscriminatedUnion",(t,e)=>{e.inclusive=!1,Ra.init(t,e);const n=t._zod.parse;ci(t,"propValues",t=>{const e={};let n=0;for(const i of t.def.options){const r=i._zod.propValues;if(!r||0===Object.keys(r).length)throw new Error(`Invalid discriminated union option at index "${t.def.options.indexOf(i)}"`);r[t.def.discriminator]?.has(void 0)&&n++;for(const[t,n]of Object.entries(r)){Object.prototype.hasOwnProperty.call(e,t)||xn(e,t,new Set);for(const i of n)e[t].add(i)}}return!t.def.unionFallback&&n>1&&e[t.def.discriminator]?.delete(void 0),e}),e.options.forEach((t,n)=>{const i=kn(t._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,e.discriminator))throw new Error(`Invalid discriminated union option at index "${n}"`)});const i=_n(()=>function(t){const e=new Map;for(const n of t.options){const i=n._zod.propValues?.[t.discriminator];if(!i||0===i.size)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(const t of i)if(e.has(t)){if(void 0!==t)throw new Error(`Duplicate discriminator value "${String(t)}"`);e.set(t,null)}else e.set(t,n)}return e}(e));t._zod.parse=(r,a)=>{const o=r.value;if(!Cn(o))return r.issues.push({code:"invalid_type",expected:"object",input:o,inst:t}),r;const s=o?.[e.discriminator],h=i.value.get(s);return!h||void 0===s&&"backward"===a.direction?e.unionFallback||"backward"===a.direction?n(r,a):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:e.discriminator,options:Array.from(i.value.keys()).filter(t=>null!==i.value.get(t)),input:o,path:[e.discriminator],inst:t}),r):h._zod.run(r,a)}}),Da=mi("$ZodIntersection",(t,e)=>{Dr.init(t,e),t._zod.parse=(t,n)=>{const i=t.value,r=e.left._zod.run({value:i,issues:[]},n),a=e.right._zod.run({value:i,issues:[]},n);return r instanceof Promise||a instanceof Promise?Promise.all([r,a]).then(([e,n])=>$a(t,e,n)):$a(t,r,a)}});function Na(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t===+e)return{valid:!0,data:t};if(Tn(t)&&Tn(e)){const n=Object.keys(e),i=Object.keys(t).filter(t=>-1!==n.indexOf(t)),r={...t,...e};Object.prototype.hasOwnProperty.call(r,"__proto__")&&delete r.__proto__;for(const n of i){if("__proto__"===n)continue;const i=Na(t[n],e[n]);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r[n]=i.data}return{valid:!0,data:r}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let i=0;i<t.length;i++){const r=Na(t[i],e[i]);if(!r.valid)return{valid:!1,mergeErrorPath:[i,...r.mergeErrorPath]};n.push(r.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function $a(t,e,n){const i=new Map;let r;const a=new Map,o=(t,e)=>{let n;if("unrecognized_keys"!==t.code||t.path?.length){if("invalid_key"!==t.code||"record"!==t.origin||1!==t.path?.length)return!1;{const e=String(t.path[0]);a.has(e)||a.set(e,t),n=[e]}}else r??(r=t),n=t.keys;for(const t of n)i.has(t)||i.set(t,{}),i.get(t)[e]=!0;return!0};for(const n of e.issues)o(n,"l")||t.issues.push(n);for(const e of n.issues)o(e,"r")||t.issues.push(e);const s=[...i].filter(([,t])=>t.l&&t.r).map(([t])=>t);if(s.length){const e=r?s.filter(t=>r.keys.includes(t)):[];e.length&&t.issues.push({...r,keys:e});for(const n of s)!e.includes(n)&&a.has(n)&&t.issues.push(a.get(n))}const h=Na(e.value,n.value);if(!h.valid){if(Zn(t))return t;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(h.mergeErrorPath)}`)}return t.value=h.data,t}const ja=mi("$ZodTuple",(t,e)=>{Dr.init(t,e);const n=e.items,i=wi.memoizer;i?.attach(t),t._zod.parse=(r,a)=>{const o=r.value;if(!Array.isArray(o))return r.issues.push({input:o,inst:t,expected:"tuple",code:"invalid_type"}),r;r.value=i?i.alloc(t,r,[],a):[];const s=[],h=Ga(n,"optin"),c=Ga(n,"optout");if(!e.rest){if(o.length<h)return r.issues.push({code:"too_small",minimum:h,inclusive:!0,input:o,inst:t,origin:"array"}),r;o.length>n.length&&r.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:o,inst:t,origin:"array"})}const l=new Array(n.length),f=e.rest?a?.abortEarly:void 0;let u=!1;for(let t=0;t<n.length;t++){const e=n[t]._zod.run({value:o[t],issues:[]},a);e instanceof Promise?s.push(e.then(e=>{l[t]=e})):(l[t]=e,f&&!u&&e.issues.length&&(u=Zn(e)))}if(e.rest&&!u){let t=n.length-1;const i=o.slice(n.length);let h=r.issues.length;for(const n of i){if(f&&r.issues.length!==h){if(Zn(r,h))break;h=r.issues.length}t++;const i=e.rest._zod.run({value:n,issues:[]},a);i instanceof Promise?s.push(i.then(e=>Ha(e,r,t))):Ha(i,r,t)}}return s.length?Promise.all(s).then(()=>Za(l,r,n,o,c)):Za(l,r,n,o,c)}});function Ga(t,e){for(let n=t.length-1;n>=0;n--){if(!("optin"===e?void 0!==t[n]._zod.optin:"optional"===t[n]._zod.optout))return n+1}return 0}function Ha(t,e,n){t.issues.length&&e.issues.push(...Wn(n,t.issues)),e.value[n]=t.value}function Za(t,e,n,i,r){for(let a=0;a<n.length;a++){const o=t[a],s=a<i.length;if(!s&&a>=r&&"optional"===n[a]._zod.optin){e.value.length=a;break}if(o.issues.length){if(!s&&a>=r){e.value.length=a;break}e.issues.push(...Wn(a,o.issues))}e.value[a]=o.value}for(let t=e.value.length-1;t>=i.length&&("optional"===n[t]._zod.optout&&void 0===e.value[t]);t--)e.value.length=t;return e}const qa=mi("$ZodEnum",(t,e)=>{Dr.init(t,e);const n=gn(e.entries),i=new Set(n);t._zod.values=i,ci(t,"pattern",t=>{const e=gn(t.def.entries).filter(t=>On.has(typeof t));return new RegExp(e.length?`^(${e.map(t=>Ln(t.toString())).join("|")})$`:"^[^\\s\\S]$")}),t._zod.parse=(e,r)=>{const a=e.value;return i.has(a)||e.issues.push({code:"invalid_value",values:n,input:a,inst:t}),e}}),Wa=mi("$ZodLiteral",(t,e)=>{Dr.init(t,e);const n=new Set(e.values);t._zod.values=n,ci(t,"pattern",t=>{const e=t.def.values;return new RegExp(e.length?`^(${e.map(t=>"string"==typeof t?Ln(t):t?Ln(t.toString()):String(t)).join("|")})$`:"^[^\\s\\S]$")}),t._zod.parse=(i,r)=>{const a=i.value;return n.has(a)||i.issues.push({code:"invalid_value",values:e.values,input:a,inst:t}),i}}),Va=mi("$ZodTransform",(t,e)=>{Dr.init(t,e),t._zod.optin="optional",wi.memoizer?.guard(t),t._zod.parse=(n,i)=>{if("backward"===i.direction)throw new bi(t.constructor.name);const r=e.transform(n.value,n);if(i.async){return(r instanceof Promise?r:Promise.resolve(r)).then(t=>(n.value=t,n))}if(r instanceof Promise)throw new gi;return n.value=r,n}});function Ja(t,e){return t.value=e.issues.length?void 0:e.value,t}const Ya=mi("$ZodOptional",(t,e)=>{Dr.init(t,e),ci(t,"optin",t=>"defaulted"===t.def.innerType._zod.optin?"defaulted":"optional"),t._zod.optout="optional",ci(t,"values",t=>{const e=t.def.innerType._zod.values;return e?new Set([...e,void 0]):void 0}),ci(t,"pattern",t=>{const e=t.def.innerType._zod.pattern;return e?new RegExp(`^(${vn(e.source)})?$`):void 0}),t._zod.parse=(t,n)=>{if(void 0===t.value){if("defaulted"!==e.innerType._zod.optin)return t;const i=e.innerType._zod.run({value:t.value,issues:[]},n);return i instanceof Promise?i.then(e=>Ja(t,e)):Ja(t,i)}return e.innerType._zod.run(t,n)}}),Xa=mi("$ZodExactOptional",(t,e)=>{Ya.init(t,e),ci(t,"values",t=>t.def.innerType._zod.values),ci(t,"pattern",t=>t.def.innerType._zod.pattern),t._zod.parse=(t,n)=>e.innerType._zod.run(t,n)}),Ka=mi("$ZodNullable",(t,e)=>{Dr.init(t,e),ci(t,"optin",t=>t.def.innerType._zod.optin),ci(t,"optout",t=>t.def.innerType._zod.optout),ci(t,"pattern",t=>{const e=t.def.innerType._zod.pattern;return e?new RegExp(`^(${vn(e.source)}|null)$`):void 0}),ci(t,"values",t=>t.def.innerType._zod.values?new Set([...t.def.innerType._zod.values,null]):void 0),t._zod.parse=(t,n)=>null===t.value?t:e.innerType._zod.run(t,n)}),Qa=mi("$ZodDefault",(t,e)=>{Dr.init(t,e),t._zod.optin="defaulted",ci(t,"values",t=>t.def.innerType._zod.values),t._zod.parse=(t,n)=>{if("backward"===n.direction)return e.innerType._zod.run(t,n);if(void 0===t.value)return t.value=e.defaultValue,t;const i=e.innerType._zod.run(t,n);return i instanceof Promise?i.then(t=>to(t,e)):to(i,e)}});function to(t,e){return void 0===t.value&&(t.value=e.defaultValue),t}const eo=mi("$ZodPrefault",(t,e)=>{Dr.init(t,e),t._zod.optin="defaulted",ci(t,"values",t=>t.def.innerType._zod.values),t._zod.parse=(t,n)=>("backward"===n.direction||void 0===t.value&&(t.value=e.defaultValue),e.innerType._zod.run(t,n))}),no=mi("$ZodNonOptional",(t,e)=>{Dr.init(t,e),ci(t,"values",t=>{const e=t.def.innerType._zod.values;return e?new Set([...e].filter(t=>void 0!==t)):void 0}),t._zod.parse=(n,i)=>{const r=e.innerType._zod.run(n,i);return r instanceof Promise?r.then(e=>io(e,t)):io(r,t)}});function io(t,e){return t.issues.length||void 0!==t.value||t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}function ro(t,e,n,i){return e.issues.length?(t.value=n.catchValue({...e,value:t.value,error:{issues:e.issues.map(t=>Xn(t,i,yi()))},input:t.value}),t):(t.value=e.value,e.memo&&(t.memo=!0),t)}const ao=mi("$ZodCatch",(t,e)=>{Dr.init(t,e),ci(t,"optin",t=>"defaulted"===t.def.innerType._zod.optin?"defaulted":"optional"),ci(t,"optout",t=>t.def.innerType._zod.optout),ci(t,"values",t=>t.def.innerType._zod.values),t._zod.parse=(t,n)=>{if("backward"===n.direction)return e.innerType._zod.run(t,n);const i=e.innerType._zod.run({value:t.value,issues:[]},n);return i instanceof Promise?i.then(i=>ro(t,i,e,n)):ro(t,i,e,n)}}),oo=mi("$ZodPipe",(t,e)=>{Dr.init(t,e),ci(t,"values",t=>t.def.in._zod.values),ci(t,"optin",t=>t.def.in._zod.optin),ci(t,"optout",t=>t.def.out._zod.optout),ci(t,"propValues",t=>t.def.in._zod.propValues),t._zod.parse=(t,n)=>{if("backward"===n.direction){const i=e.out._zod.run(t,n);return i instanceof Promise?i.then(t=>so(t,e.in,n)):so(i,e.in,n)}const i=e.in._zod.run(t,n);return i instanceof Promise?i.then(t=>so(t,e.out,n)):so(i,e.out,n)}});function so(t,e,n){return t.issues.some(t=>"unrecognized_keys"!==t.code)?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues},n)}const ho=mi("$ZodReadonly",(t,e)=>{Dr.init(t,e),ci(t,"propValues",t=>t.def.innerType._zod.propValues),ci(t,"values",t=>t.def.innerType._zod.values),ci(t,"optin",t=>t.def.innerType?._zod?.optin),ci(t,"optout",t=>t.def.innerType?._zod?.optout),t._zod.parse=(t,n)=>{if("backward"===n.direction)return e.innerType._zod.run(t,n);const i=e.innerType._zod.run(t,n);return i instanceof Promise?i.then(co):co(i)}});function co(t){return t.memo||(t.value=Object.freeze(t.value)),t}const lo=mi("$ZodFunction",(t,e)=>(Dr.init(t,e),Object.defineProperty(t,"_def",{value:e}),t._zod.def=e,t.implement=e=>{if("function"!=typeof e)throw new Error("implement() must be called with a function");return Object.defineProperty(function(...n){const i=t._def.input?zi(t._def.input,n):n,r=Reflect.apply(e,this,i);return t._def.output?zi(t._def.output,r):r},"_zod",{value:t._zod,enumerable:!1})},t.implementAsync=e=>{if("function"!=typeof e)throw new Error("implementAsync() must be called with a function");return Object.defineProperty(async function(...n){const i=t._def.input?await Ci(t._def.input,n):n,r=await Reflect.apply(e,this,i);return t._def.output?await Ci(t._def.output,r):r},"_zod",{value:t._zod,enumerable:!1})},t._zod.parse=(e,n)=>{if("function"!=typeof e.value)return e.issues.push({code:"invalid_type",expected:"function",input:e.value,inst:t}),e;const i=t._def.output&&"promise"===t._def.output._zod.def.type;return e.value=i?t.implementAsync(e.value):t.implement(e.value),e},t.input=(...e)=>{const n=t.constructor;return Array.isArray(e[0])?new n({type:"function",input:new ja({type:"tuple",items:e[0],rest:e[1]}),output:t._def.output}):new n({type:"function",input:e[0],output:t._def.output})},t.output=e=>new(0,t.constructor)({type:"function",input:t._def.input,output:e}),t)),fo=mi("$ZodCustom",(t,e)=>{br.init(t,e),Dr.init(t,e),t._zod.parse=(t,e)=>t,t._zod.check=n=>{const i=n.value,r=e.fn(i);if(r instanceof Promise)return r.then(e=>uo(e,n,i,t));uo(r,n,i,t)}});function uo(t,e,n,i){if(!t){const t={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(t.params=i._zod.def.params),e.issues.push(ei(t))}}class po extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const mo="~memo",go=[];function bo(t){return null!==t&&"object"==typeof t}function wo(t){return t.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const yo=new WeakMap;function _o(t,e,n){const i=yo.get(t);if(void 0!==i)return i?2:0;if(e.has(t))return 2;e.add(t);let r=0;const a=t=>{if(2!==r&&t?._zod){const n=_o(t,e);n>r&&(r=n)}},o=t=>{t>r&&(r=t)},s=t._zod.def;switch(s.type){case"object":{const t=kn(s);o(t?(t=>{let n=0;for(const i of Reflect.ownKeys(t)){const r=Object.getOwnPropertyDescriptor(t,i);if(!r.enumerable)continue;const a=r.get?1:r.value?._zod?_o(r.value,e):0;a>n&&(n=a)}return n})(t):1),a(s.catchall);break}case"array":a(s.element);break;case"tuple":for(const t of s.items)a(t);a(s.rest);break;case"record":case"map":a(s.keyType),a(s.valueType);break;case"set":a(s.valueType);break;case"union":for(const t of s.options)a(t);break;case"intersection":a(s.left),a(s.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":a(s.innerType);break;case"pipe":a(s.in),a(s.out);break;case"function":a(s.input),a(s.output);break;case"lazy":{const t=s._cachedInner??void 0;o(t?_o(t,e):1);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(const t in s){const e=Object.getOwnPropertyDescriptor(s,t);if(!e||e.get)continue;const n=e.value;if(n&&"object"==typeof n)if(n._zod)a(n);else if(Array.isArray(n))for(const t of n)a(t)}}return e.delete(t),function(t,e){1!==e&&yo.set(t,2===e);return e}(t,r)}let vo;const xo=[],ko={alloc(t,e,n){const i=vo;if(!i)return n;vo=void 0;const r={value:n,issues:null};return i.set(e.value,r),xo.push(r),n},guard(t){var e;(e=t._zod).deferred??(e.deferred=[]),t._zod.deferred.push(()=>{const e=t._zod.parse,n=(t,n)=>{if("backward"!==n.direction&&function(t,e){const n=t[mo]?.backEdges;return void 0!==n&&bo(e)&&n.has(e)}(n,t.value))throw new po;return e(t,n)};t._zod.parse=n,t._zod.run===e&&(t._zod.run=n)})},attach(t){var e;let n,i,r,a=!1;(e=t._zod).deferred??(e.deferred=[]),t._zod.deferred.push(()=>{const e=t._zod.parse,o=(s,h)=>{if(void 0===n){const i=_o(t,new Set);if(0===i)return t._zod.parse=e,t._zod.run===o&&(t._zod.run=e),e(s,h);2===i||a?n=!0:a=!0}const c=s.value;if(!bo(c))return e(s,h);let l,f=h[mo];f||(f={buckets:new WeakMap,backEdges:void 0},h[mo]=f),i===h?l=r:(l=function(t,e){let n=t.buckets.get(e);return n||(n=new WeakMap,t.buckets.set(e,n)),n}(f,t),i=h,r=l);const u=l.get(c);if(u)return s.value=u.value,u.issues?u.issues.length&&s.issues.push(...wo(u.issues)):(s.memo=!0,f.backEdges??(f.backEdges=new WeakSet),f.backEdges.add(u.value)),s;vo=l;const d=xo.length,p=e(s,h);vo=void 0;const m=xo.length>d?xo.pop():void 0;return p instanceof Promise?p.then(t=>(m&&(m.issues=t.issues.length?wo(t.issues):go),t)):(m&&(m.issues=p.issues.length?wo(p.issues):go),p)};t._zod.parse=o,t._zod.run===e&&(t._zod.run=o)})}};const Ao=()=>{const t={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function e(e){return t[e]??null}const n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};function r(t,e){return"number"!==t||"number"!=typeof e||Number.isFinite(e)?i[t]??t:String(e)}return t=>{switch(t.code){case"invalid_type":{const e=r(t.expected),n=function(t){const e=typeof t;switch(e){case"number":return Number.isNaN(t)?"nan":"number";case"object":{if(null===t)return"null";if(Array.isArray(t))return"array";const e=t;if(e&&Object.getPrototypeOf(e)!==Object.prototype&&"constructor"in e&&e.constructor)return e.constructor.name}}return e}(t.input);return`Invalid input: expected ${e}, received ${r(n,t.input)}`}case"invalid_value":return 1===t.values.length?`Invalid input: expected ${Dn(t.values[0])}`:`Invalid option: expected one of ${bn(t.values,"|")}`;case"too_big":{const n=t.exact?"exactly ":t.inclusive?"<=":"<",i=e(t.origin);return i?`Too big: expected ${t.origin??"value"} to have ${n}${t.maximum.toString()} ${i.unit??"elements"}`:`Too big: expected ${t.origin??"value"} to be ${n}${t.maximum.toString()}`}case"too_small":{const n=t.exact?"exactly ":t.inclusive?">=":">",i=e(t.origin);return i?`Too small: expected ${t.origin} to have ${n}${t.minimum.toString()} ${i.unit}`:`Too small: expected ${t.origin} to be ${n}${t.minimum.toString()}`}case"invalid_format":{const e=t;return"starts_with"===e.format?`Invalid string: must start with "${e.prefix}"`:"ends_with"===e.format?`Invalid string: must end with "${e.suffix}"`:"includes"===e.format?`Invalid string: must include "${e.includes}"`:"regex"===e.format?`Invalid string: must match pattern ${e.pattern}`:`Invalid ${n[e.format]??t.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${t.divisor}`;case"unrecognized_keys":return`Unrecognized key${t.keys.length>1?"s":""}: ${bn(t.keys,", ")}`;case"invalid_key":return`Invalid key in ${t.origin}`;case"invalid_union":if(t.options&&Array.isArray(t.options)&&t.options.length>0){const e=t.options.map(t=>`'${t}'`).join(" | ");return`Invalid discriminator value. Expected ${e}`}return!1===t.inclusive?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${t.origin}`;default:return"Invalid input"}}};var Mo;class Eo{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...e){const n=e[0];return this._map.set(t,n),n&&"object"==typeof n&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const e=this._map.get(t);return e&&"object"==typeof e&&"id"in e&&this._idmap.delete(e.id),this._map.delete(t),this}get(t){const e=t._zod.parent;if(e){const n={...this.get(e)??{}};delete n.id;const i={...n,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}(Mo=globalThis).__zod_globalRegistry??(Mo.__zod_globalRegistry=new Eo);const Io=globalThis.__zod_globalRegistry;function So(t){return t.checks&&(t.checks=[...t.checks]),t}function zo(t,e){return new _r({check:"less_than",...Fn(e),value:t,inclusive:!1})}function Bo(t,e){return new _r({check:"less_than",...Fn(e),value:t,inclusive:!0})}function Co(t,e){return new vr({check:"greater_than",...Fn(e),value:t,inclusive:!1})}function Po(t,e){return new vr({check:"greater_than",...Fn(e),value:t,inclusive:!0})}function To(t,e){return new xr({check:"multiple_of",...Fn(e),value:t})}function Uo(t,e){return new Ar({check:"max_length",...Fn(e),maximum:t})}function Oo(t,e){return new Mr({check:"min_length",...Fn(e),minimum:t})}function Lo(t,e){return new Er({check:"length_equals",...Fn(e),length:t})}function Ro(t){return new Lr({check:"overwrite",tx:t})}function Fo(t,e){const n=function(t,e){const n=new br({check:"custom",...Fn(e)});return n._zod.check=t,n}(e=>(e.addIssue=t=>{if("string"==typeof t)e.issues.push(ei(t,e.value,n._zod.def));else{const i=t;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=e.value),i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),e.issues.push(ei(i))}},t(e.value,e)),e);return n}function Do(t,...e){for(const n of e)for(const e of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,e)&&xn(t,e,n[e]);return t}function No(t){let e=t?.target??"draft-2020-12";return"draft-4"===e&&(e="draft-04"),"draft-7"===e&&(e="draft-07"),{processors:t.processors??{},metadataRegistry:t?.metadata??Io,target:e,unrepresentable:t?.unrepresentable??"throw",override:t?.override??(()=>{}),io:t?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:t?.cycles??"ref",reused:t?.reused??"inline",intersections:[],deferred:[],external:t?.external??void 0}}function $o(t,e,n,i,r){const a="function"==typeof e.unrepresentable?e.unrepresentable({zodSchema:t,path:i.path,message:r}):e.unrepresentable;if("any"===a)return!1;if(void 0===a||"throw"===a)throw new Error(r);return Object.assign(n,a),!0}function jo(t,e,n={path:[],schemaPath:[]}){var i;const r=t._zod.def,a=e.seen.get(t);if(a){a.count++;return n.schemaPath.includes(t)&&(a.cycle=n.path),a.schema}const o={schema:{},count:1,cycle:void 0,path:n.path};e.seen.set(t,o),e.sharedDefsExtractedFor=void 0,e.sharedEmitDoneFor=void 0;const s=t._zod.toJSONSchema?.();if(s)o.schema=s;else{const i={...n,schemaPath:[...n.schemaPath,t],path:n.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(e,o.schema,i);else{const n=o.schema,a=e.processors[r.type];if(!a)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);a(t,e,n,i)}const a=t._zod.parent;a&&(o.ref||(o.ref=a),jo(a,e,i),e.seen.get(a).isParent=!0)}const h=e.metadataRegistry.get(t);h&&Do(o.schema,h),"input"===e.io&&Ko(t)&&(delete o.schema.examples,delete o.schema.default),"input"===e.io&&"_prefault"in o.schema&&((i=o.schema).default??(i.default=o.schema._prefault)),delete o.schema._prefault;return e.seen.get(t).schema}function Go(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}function Ho(t,e){const n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");if(t.external&&t.sharedDefsExtractedFor===t.external)return;const i=new Map;for(const e of t.seen.entries()){const n=t.metadataRegistry.get(e[0])?.id;if(n){const t=i.get(n);if(t&&t!==e[0])throw new Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(n,e[0])}}const r=e=>{if(e[1].schema.$ref)return;const i=e[1],{ref:r,defId:a}=(e=>{const i="draft-2020-12"===t.target?"$defs":"definitions";if(t.external){const n=t.external.registry.get(e[0])?.id,r=t.external.uri??(t=>t);if(n)return{ref:r(n)};const a=e[1].defId??e[1].schema.id??"schema"+t.counter++;return e[1].defId=a,{defId:a,ref:`${r("__shared")}#/${i}/${Go(a)}`}}const r=`#/${i}/`;if(e[1]===n&&!e[1].schema.id)return{ref:"#"};const a=e[1].schema.id??"__schema"+t.counter++;return{defId:a,ref:r+Go(a)}})(e);i.def={...i.schema},a&&(i.defId=a);const o=i.schema;for(const t in o)delete o[t];o.$ref=r};if("throw"===t.cycles)for(const e of t.seen.entries()){const t=e[1];if(t.cycle)throw new Error(`Cycle detected: #/${t.cycle?.join("/")}/<root>\n\nSet the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const n of t.seen.entries()){const i=n[1];if(e===n[0]){r(n);continue}if(t.external){const i=t.external.registry.get(n[0])?.id;if(e!==n[0]&&i){r(n);continue}}const a=t.metadataRegistry.get(n[0])?.id;a?r(n):(i.cycle||i.count>1&&"ref"===t.reused)&&r(n)}t.external&&(t.sharedDefsExtractedFor=t.external)}function Zo(t){const e=t.anyOf;if(!Array.isArray(e)||0===e.length||void 0!==t.type)return;const n=[];for(const t of e){if(!t||"object"!=typeof t)return;Zo(t);const e=Object.keys(t);if(1!==e.length||"type"!==e[0])return;const i=t.type;for(const t of Array.isArray(i)?i:[i]){if("string"!=typeof t)return;n.includes(t)||n.push(t)}}delete t.anyOf,t.type=1===n.length?n[0]:n}const qo=new Set(["type","properties","required","additionalProperties"]),Wo=["oneOf","anyOf"];function Vo(t){const e=t.additionalProperties;return void 0===e||!1===e||"object"!=typeof e||null===e?null:Object.keys(e).length?e:null}function Jo(t){const e=[];for(const n of t){if("object"!=typeof n||"object"!==n.type)return null;for(const t in n)if(!qo.has(t))return null;e.push(n)}const n={},i=new Set;for(const t of e){for(const i in t.properties){if(Object.prototype.hasOwnProperty.call(n,i))continue;const t=[];for(const n of e){const e=n.properties?.[i]??Vo(n);null!=e&&(t.some(t=>JSON.stringify(t)===JSON.stringify(e))||t.push(e))}xn(n,i,1===t.length?t[0]:Jo(t)??{allOf:t})}for(const e of t.required??[])i.add(e)}const r={type:"object",properties:n};if(i.size&&(r.required=[...i]),e.every(t=>!1===t.additionalProperties))r.additionalProperties=!1;else{const t=[];for(const n of e){const e=Vo(n);e&&!t.some(t=>JSON.stringify(t)===JSON.stringify(e))&&t.push(e)}1===t.length?r.additionalProperties=t[0]:t.length>1&&(r.additionalProperties={allOf:t})}return r}function Yo(t){const e=t.allOf;if(!Array.isArray(e)||e.length<2)return;for(const e of qo)if(e in t)return;const n=e.filter(t=>Wo.some(e=>Array.isArray(t[e])));let i=null;if(n.length){const t=n[0],r=Wo.find(e=>Array.isArray(t[e]));if(1!==Object.keys(t).length)return;const a=e.filter(e=>e!==t),o=t[r].map(t=>Jo([...a,t]));if(o.some(t=>!t))return;i={[r]:o}}else i=Jo(e);i&&(delete t.allOf,Do(t,i))}function Xo(t,e){const n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=e=>{const n=t.seen.get(e);if(null===n.ref)return;const r=n.def??n.schema,a={...r},o=n.ref;if(n.ref=null,o){i(o);const n=t.seen.get(o),s=n.schema;!s.$ref||"draft-07"!==t.target&&"draft-04"!==t.target&&"openapi-3.0"!==t.target?Do(r,s):(r.allOf=r.allOf??[],r.allOf.push(s)),Do(r,a);if(e._zod.parent===o)for(const t in r)"$ref"!==t&&"allOf"!==t&&(t in a||delete r[t]);if(s.$ref&&n.def)for(const t in r)"$ref"!==t&&"allOf"!==t&&t in n.def&&JSON.stringify(r[t])===JSON.stringify(n.def[t])&&delete r[t]}const s=e._zod.parent;if(s&&s!==o){i(s);const e=t.seen.get(s);if(e?.schema.$ref&&(r.$ref=e.schema.$ref,e.def))for(const t in r)"$ref"!==t&&"allOf"!==t&&t in e.def&&JSON.stringify(r[t])===JSON.stringify(e.def[t])&&delete r[t]}t.override({zodSchema:e,jsonSchema:r,path:n.path??[]})};if(!t.external||t.sharedEmitDoneFor!==t.external){for(const e of[...t.seen.entries()].reverse())i(e[0]);if("openapi-3.0"!==t.target)for(const e of t.seen.entries())Zo(e[1].def??e[1].schema);for(const e of t.deferred)e();if(t.intersections.length){const e=new Map;for(const n of t.seen.values())for(const t of[n.schema,n.def]){const n=t?.allOf;if(!Array.isArray(n))continue;const i=e.get(n);i?i.push(t):e.set(n,[t])}for(const n of t.intersections)for(const t of e.get(n)??[])Yo(t)}}const r={};if("draft-2020-12"===t.target?r.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===t.target?r.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===t.target?r.$schema="http://json-schema.org/draft-04/schema#":t.target,t.external?.uri){const n=t.external.registry.get(e)?.id;if(!n)throw new Error("Schema is missing an `id` property");r.$id=t.external.uri(n)}Do(r,n.defId?n.schema:n.def??n.schema);const a=t.metadataRegistry.get(e)?.id;void 0!==a&&r.id===a&&delete r.id;const o=t.external?.defs??{};if(!t.external||t.sharedEmitDoneFor!==t.external)for(const e of t.seen.entries()){const t=e[1];t.def&&t.defId&&(t.def.id===t.defId&&delete t.def.id,xn(o,t.defId,t.def))}t.external&&(t.sharedEmitDoneFor=t.external),t.external||Object.keys(o).length>0&&("draft-2020-12"===t.target?r.$defs=o:r.definitions=o);try{const n=JSON.parse(JSON.stringify(r));return Object.defineProperty(n,"~standard",{value:{...e["~standard"],jsonSchema:{input:Qo(e,"input",t.processors),output:Qo(e,"output",t.processors)}},enumerable:!1,writable:!1}),n}catch(t){throw new Error("Error converting schema to JSON.")}}function Ko(t,e){const n=e??{seen:new Set};if(n.seen.has(t))return!1;n.seen.add(t);const i=t._zod.def;if("transform"===i.type)return!0;if("array"===i.type)return Ko(i.element,n);if("set"===i.type)return Ko(i.valueType,n);if("lazy"===i.type)return Ko(i.getter(),n);if("promise"===i.type||"optional"===i.type||"nonoptional"===i.type||"nullable"===i.type||"readonly"===i.type||"default"===i.type||"prefault"===i.type||"catch"===i.type)return Ko(i.innerType,n);if("intersection"===i.type)return Ko(i.left,n)||Ko(i.right,n);if("record"===i.type||"map"===i.type)return Ko(i.keyType,n)||Ko(i.valueType,n);if("pipe"===i.type)return!!t._zod.traits.has("$ZodCodec")||(Ko(i.in,n)||Ko(i.out,n));if("object"===i.type){for(const t in i.shape)if(Ko(i.shape[t],n))return!0;return!1}if("union"===i.type){for(const t of i.options)if(Ko(t,n))return!0;return!1}if("tuple"===i.type){for(const t of i.items)if(Ko(t,n))return!0;return!(!i.rest||!Ko(i.rest,n))}return!1}const Qo=(t,e,n={})=>i=>{const{libraryOptions:r,target:a}=i??{},o=No({...r??{},target:a,io:e,processors:n});return jo(t,o),Ho(o,t),Xo(o,t)},ts=(t,e,n)=>{(void 0===t[e]||n>t[e])&&(t[e]=n)},es=(t,e,n)=>{(void 0===t[e]||n<t[e])&&(t[e]=n)},ns=(t,e)=>{ts(t,"minimum",e),es(t,"maximum",e)},is=(t,e)=>{t.multipleOf??(t.multipleOf=[]),t.multipleOf.includes(e)||t.multipleOf.push(e)},rs=(t,e)=>{t.patterns??(t.patterns=new Set),t.patterns.add(e)},as=(t,e)=>{t.mime=t.mime?t.mime.filter(t=>e.includes(t)):[...e]},os=(t,e)=>{t.format=e,e.includes("int")&&(t.isInt=!0)},ss=(t,e)=>ts(t,"minimum",e.minimum),hs=(t,e)=>es(t,"maximum",e.maximum),cs=t=>(e,n)=>{os(e,n.format);const[i,r]=t[n.format];ts(e,"minimum",i),es(e,"maximum",r)},ls={greater_than:(t,e)=>ts(t,e.inclusive?"minimum":"exclusiveMinimum",e.value),less_than:(t,e)=>es(t,e.inclusive?"maximum":"exclusiveMaximum",e.value),multiple_of:(t,e)=>is(t,e.value),number_format:cs(Nn),bigint_format:cs($n),min_length:ss,max_length:hs,length_equals:(t,e)=>ns(t,e.length),min_size:ss,max_size:hs,size_equals:(t,e)=>ns(t,e.size),string_format:(t,e)=>{os(t,e.format),e.pattern&&rs(t,e.pattern),"base64"!==e.format&&"base64url"!==e.format||(t.contentEncoding=e.format),(e.local||-1===e.precision)&&(t.laxFormat=!0)},mime_type:(t,e)=>as(t,e.mime)};function fs(t){const e={},n=t._zod.def,i=t._zod.traits.has("$ZodCheck")?[t,...n.checks??[]]:n.checks??[];for(const t of i)ls[t._zod.def.check]?.(e,t._zod.def);const r=t._zod.bag;void 0!==r.minimum&&ts(e,"minimum",r.minimum),void 0!==r.exclusiveMinimum&&ts(e,"exclusiveMinimum",r.exclusiveMinimum),void 0!==r.maximum&&es(e,"maximum",r.maximum),void 0!==r.exclusiveMaximum&&es(e,"exclusiveMaximum",r.exclusiveMaximum),void 0!==r.multipleOf&&is(e,r.multipleOf),void 0!==r.format&&(e.format??(e.format=r.format),r.format.includes("int")&&(e.isInt=!0)),r.mime&&as(e,r.mime);for(const t of r.patterns??[])rs(e,t);return e}const us={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},ds=new Map([[ga,/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/],[wa,/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/]]),ps=t=>ds.get(t)??t;function ms(t){const e=t._zod.def;return"pipe"===e.type&&e.in._zod.traits.has("$ZodTransform")?ms(e.out):"catch"===e.type?ms(e.innerType):t._zod.optin}const gs=Symbol();function bs(t,e,n,i,r){let a=!1;const o=JSON.stringify(t,(t,e)=>"bigint"!=typeof e?e:(a=!0,null));return a?($o(e,n,i,r,"BigInt defaults cannot be represented in JSON Schema"),gs):JSON.parse(o)}const ws=(t,e,n,i)=>{const r=t._zod.def;jo(r.innerType,e,i);e.seen.get(t).ref=r.innerType},ys=new WeakSet([Object.prototype,Error.prototype]);function _s(t,e,n){Object.defineProperty(t,e,{configurable:!0,enumerable:!1,get(){const t=n(this);return Object.defineProperty(this,e,{value:t,configurable:!0,writable:!0}),t},set(t){Object.defineProperty(this,e,{value:t,configurable:!0,writable:!0})}})}const vs=(t,e)=>{Ai.init(t,e),t.name="ZodError";const n=Object.getPrototypeOf(t);ys.has(n)||(ys.add(n),_s(n,"format",t=>e=>function(t,e=t=>t.message){const n={_errors:[]},i=(t,r=[])=>{for(const a of t.issues)if("invalid_union"===a.code&&a.errors.length)a.errors.map(t=>i({issues:t},[...r,...a.path]));else if("invalid_key"===a.code)i({issues:a.issues},[...r,...a.path]);else if("invalid_element"===a.code)i({issues:a.issues},[...r,...a.path]);else{const t=[...r,...a.path];if(0===t.length)n._errors.push(e(a));else{let i=n,r=0;for(;r<t.length;){const n=t[r],o=r===t.length-1;if("_errors"===n){o&&i._errors.push(e(a)),r++;continue}Object.prototype.hasOwnProperty.call(i,n)||Object.defineProperty(i,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const s=i[n];o&&s._errors.push(e(a)),i=s,r++}}}};return i(t),n}(t,e)),_s(n,"flatten",t=>e=>function(t,e=t=>t.message){const n={},i=[];for(const r of t.issues)r.path.length>0?Ei(n,r.path[0],()=>[]).push(e(r)):i.push(e(r));return{formErrors:i,fieldErrors:n}}(t,e)),_s(n,"addIssue",t=>e=>{t.issues.push(e),t.message=JSON.stringify(t.issues,wn,2)}),_s(n,"addIssues",t=>e=>{t.issues.push(...e),t.message=JSON.stringify(t.issues,wn,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return 0===this.issues.length}}))},xs=mi("ZodError",vs,void 0,{Parent:Error}),ks=Si(xs),As=Bi(xs),Ms=Pi(xs),Es=Ui(xs),Is=Fi(xs),Ss=Di(xs),zs=Ni(xs),Bs=$i(xs),Cs=ji(xs),Ps=Gi(xs),Ts=Hi(xs),Us=Zi(xs);function Os(){wi.localeError||yi({localeError:Ao()})}function Ls(){wi.memoizer||yi({memoizer:ko})}const Rs=mi("ZodType",(t,e)=>(Os(),Dr.init(t,e),t.def=e,t.type=e.type,t),{check(...t){const e=this.def;return this.clone(Sn(e,{checks:[...e.checks??[],...t.map(t=>"function"==typeof t?{_zod:{check:t,def:{check:"custom"},onattach:[]}}:t)]}),{parent:!0})},with(...t){return this.check(...t)},clone(t,e){return Rn(this,t,e)},brand(){return this},register(t,e){return t.add(this,e),this},refine(t,e){return this.check(function(t,e={}){return function(t,e,n){return new t({type:"custom",check:"custom",fn:e,...Fn(n)})}(Kh,t,e)}(t,e))},superRefine(t,e){return this.check(function(t,e){return Fo(t,e)}(t,e))},overwrite(t){return this.check(Ro(t))},optional(){return Nh(this)},exactOptional(){return new $h({type:"optional",innerType:this})},nullable(){return Gh(this)},nullish(){return Nh(Gh(this))},nonoptional(t){return function(t,e){return new qh({type:"nonoptional",innerType:t,...Fn(e)})}(this,t)},array(){return xh(this)},or(t){return Ih([this,t])},and(t){return new Bh({type:"intersection",left:this,right:t})},transform(t){return Jh(this,new Fh({type:"transform",transform:t}))},default(t){return e=t,new Hh({type:"default",innerType:this,get defaultValue(){return"function"==typeof e?e():Un(e)}});var e},prefault(t){return e=t,new Zh({type:"prefault",innerType:this,get defaultValue(){return"function"==typeof e?e():Un(e)}});var e},catch(t){return new Wh({type:"catch",innerType:this,catchValue:"function"==typeof(e=t)?e:fi(e)});var e},pipe(t){return Jh(this,t)},readonly(){return new Yh({type:"readonly",innerType:this})},describe(t){const e=this.clone();return Io.add(e,{description:t}),e},meta(...t){if(0===t.length)return Io.get(this);const e=this.clone();return Io.add(e,t[0]),e},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(t,...e){return 0===e.length?t(this):t(this,...e)},get"~standard"(){return ii(this,"~standard",{...$r(this),jsonSchema:{input:Qo(this,"input"),output:Qo(this,"output")}})},set"~standard"(t){ni(this,"~standard",t)},parse:function t(e,n){return ks(this,e,n,{callee:t})},parseAsync:async function t(e,n){return await As(this,e,n,{callee:t})},safeParse(t,e){return Ms(this,t,e)},async safeParseAsync(t,e){return Es(this,t,e)},get spa(){return this?.safeParseAsync},set spa(t){ni(this,"spa",t)},validate(t,e){return Ri(this,t,e)},validateAsync(t,e){return(async(t,e,n)=>{const i=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0};let r=t._zod.run({value:e,issues:[]},i);return r instanceof Promise&&(r=await r),0===r.issues.length})(this,t,e)},encode:function t(e,n){return Is(this,e,n,{callee:t})},decode:function t(e,n){return Ss(this,e,n,{callee:t})},encodeAsync:async function t(e,n){return await zs(this,e,n,{callee:t})},decodeAsync:async function t(e,n){return await Bs(this,e,n,{callee:t})},safeEncode(t,e){return Cs(this,t,e)},safeDecode(t,e){return Ps(this,t,e)},async safeEncodeAsync(t,e){return Ts(this,t,e)},async safeDecodeAsync(t,e){return Us(this,t,e)},toJSONSchema(t){return((t,e={})=>n=>{const i=No({...n,processors:e});return jo(t,i),Ho(i,t),Xo(i,t)})(this,{})(t)},get description(){return Io.get(this)?.description},get _def(){return this._zod.def}}),Fs=mi("_ZodString",(t,e)=>{jr.init(t,e),Rs.init(t,e),t._zod.processJSONSchema=(e,n,i)=>((t,e,n)=>{const i=n;i.type="string";const{minimum:r,maximum:a,format:o,patterns:s,contentEncoding:h,laxFormat:c}=fs(t);if("number"==typeof r&&(i.minLength=r),"number"==typeof a&&(i.maxLength=a),o&&(i.format=us[o]??o,""===i.format&&delete i.format,("time"===o||c)&&delete i.format),h&&(i.contentEncoding=h),s&&s.size>0){const t=[...s].map(ps);1===t.length?i.pattern=t[0].source:t.length>1&&(i.allOf=[...t.map(t=>({..."draft-07"===e.target||"draft-04"===e.target||"openapi-3.0"===e.target?{type:"string"}:{},pattern:t.source}))])}})(t,e,n)},ri({format:t=>fs(t).format??null,minLength:t=>fs(t).minimum??null,maxLength:t=>fs(t).maximum??null},{regex(...t){return this.check(function(t,e){return new Sr({check:"string_format",format:"regex",...Fn(e),pattern:t})}(...t))},includes(...t){return this.check(function(t,e){return new Cr({check:"string_format",format:"includes",...Fn(e),includes:t})}(...t))},startsWith(...t){return this.check(function(t,e){return new Pr({check:"string_format",format:"starts_with",...Fn(e),prefix:t})}(...t))},endsWith(...t){return this.check(function(t,e){return new Tr({check:"string_format",format:"ends_with",...Fn(e),suffix:t})}(...t))},min(...t){return this.check(Oo(...t))},max(...t){return this.check(Uo(...t))},length(...t){return this.check(Lo(...t))},nonempty(...t){return this.check(Oo(1,...t))},lowercase(t){return this.check(function(t){return new zr({check:"string_format",format:"lowercase",...Fn(t)})}(t))},uppercase(t){return this.check(function(t){return new Br({check:"string_format",format:"uppercase",...Fn(t)})}(t))},trim(){return this.check(Ro(t=>t.trim()))},normalize(...t){return this.check(function(t){return Ro(e=>e.normalize(t))}(...t))},toLowerCase(){return this.check(Ro(t=>t.toLowerCase()))},toUpperCase(){return this.check(Ro(t=>t.toUpperCase()))},slugify(){return this.check(Ro(t=>function(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(t)))}})),Ds=mi("ZodString",(t,e)=>{jr.init(t,e),Fs.init(t,e)},{email(t){return this.check(function(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...Fn(e)})}(qs,t))},url(t){return this.check(function(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...Fn(e)})}(Js,t))},jwt(t){return this.check(function(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...Fn(e)})}(lh,t))},emoji(t){return this.check(function(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...Fn(e)})}(Ys,t))},guid(t){return this.check(function(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...Fn(e)})}(Ws,t))},uuid(t){return this.check(function(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...Fn(e)})}(Vs,t))},uuidv4(t){return this.check(function(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Fn(e)})}(Vs,t))},uuidv6(t){return this.check(function(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Fn(e)})}(Vs,t))},uuidv7(t){return this.check(function(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Fn(e)})}(Vs,t))},nanoid(t){return this.check(function(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...Fn(e)})}(Xs,t))},cuid(t){return this.check(function(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...Fn(e)})}(Ks,t))},cuid2(t){return this.check(function(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...Fn(e)})}(Qs,t))},ulid(t){return this.check(function(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...Fn(e)})}(th,t))},base64(t){return this.check(function(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...Fn(e)})}(sh,t))},base64url(t){return this.check(function(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...Fn(e)})}(hh,t))},xid(t){return this.check(function(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...Fn(e)})}(eh,t))},ksuid(t){return this.check(function(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...Fn(e)})}(nh,t))},ipv4(t){return this.check(function(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...Fn(e)})}(ih,t))},ipv6(t){return this.check(function(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...Fn(e)})}(rh,t))},cidrv4(t){return this.check(function(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Fn(e)})}(ah,t))},cidrv6(t){return this.check(function(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Fn(e)})}(oh,t))},e164(t){return this.check(function(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...Fn(e)})}(ch,t))},datetime(t){return this.check(function(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Fn(e)})}(js,t))},date(t){return this.check(function(t,e){return new t({type:"string",format:"date",check:"string_format",...Fn(e)})}(Gs,t))},time(t){return this.check(function(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...Fn(e)})}(Hs,t))},duration(t){return this.check(function(t,e){return new t({type:"string",format:"duration",check:"string_format",...Fn(e)})}(Zs,t))}});function Ns(t){return function(t,e){return new t(So({type:"string",...Fn(e)}))}(Ds,t)}const $s=mi("ZodStringFormat",(t,e)=>{Gr.init(t,e),Fs.init(t,e)}),js=mi("ZodISODateTime",(t,e)=>{aa.init(t,e),$s.init(t,e)}),Gs=mi("ZodISODate",(t,e)=>{oa.init(t,e),$s.init(t,e)}),Hs=mi("ZodISOTime",(t,e)=>{sa.init(t,e),$s.init(t,e)}),Zs=mi("ZodISODuration",(t,e)=>{ha.init(t,e),$s.init(t,e)}),qs=mi("ZodEmail",(t,e)=>{qr.init(t,e),$s.init(t,e)}),Ws=mi("ZodGUID",(t,e)=>{Hr.init(t,e),$s.init(t,e)}),Vs=mi("ZodUUID",(t,e)=>{Zr.init(t,e),$s.init(t,e)}),Js=mi("ZodURL",(t,e)=>{Xr.init(t,e),$s.init(t,e)}),Ys=mi("ZodEmoji",(t,e)=>{Kr.init(t,e),$s.init(t,e)}),Xs=mi("ZodNanoID",(t,e)=>{Qr.init(t,e),$s.init(t,e)}),Ks=mi("ZodCUID",(t,e)=>{ta.init(t,e),$s.init(t,e)}),Qs=mi("ZodCUID2",(t,e)=>{ea.init(t,e),$s.init(t,e)}),th=mi("ZodULID",(t,e)=>{na.init(t,e),$s.init(t,e)}),eh=mi("ZodXID",(t,e)=>{ia.init(t,e),$s.init(t,e)}),nh=mi("ZodKSUID",(t,e)=>{ra.init(t,e),$s.init(t,e)}),ih=mi("ZodIPv4",(t,e)=>{ca.init(t,e),$s.init(t,e)}),rh=mi("ZodIPv6",(t,e)=>{ua.init(t,e),$s.init(t,e)}),ah=mi("ZodCIDRv4",(t,e)=>{da.init(t,e),$s.init(t,e)}),oh=mi("ZodCIDRv6",(t,e)=>{pa.init(t,e),$s.init(t,e)}),sh=mi("ZodBase64",(t,e)=>{ba.init(t,e),$s.init(t,e)}),hh=mi("ZodBase64URL",(t,e)=>{ya.init(t,e),$s.init(t,e)}),ch=mi("ZodE164",(t,e)=>{_a.init(t,e),$s.init(t,e)}),lh=mi("ZodJWT",(t,e)=>{va.init(t,e),$s.init(t,e)}),fh=mi("ZodNumber",(t,e)=>{xa.init(t,e),Rs.init(t,e),t._zod.processJSONSchema=(e,n,i)=>((t,e,n,i)=>{const r=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:h,exclusiveMinimum:c,isInt:l}=fs(t);r.type=l?"integer":"number";const f="number"==typeof c&&c>=(a??Number.NEGATIVE_INFINITY),u="number"==typeof h&&h<=(o??Number.POSITIVE_INFINITY),d="draft-04"===e.target||"openapi-3.0"===e.target;if(f?d?(r.minimum=c,r.exclusiveMinimum=!0):r.exclusiveMinimum=c:"number"==typeof a&&(r.minimum=a),u?d?(r.maximum=h,r.exclusiveMaximum=!0):r.exclusiveMaximum=h:"number"==typeof o&&(r.maximum=o),s){const n=new Set;for(const a of s)Number.isFinite(a)&&0!==a?n.add(Math.abs(a)):$o(t,e,r,i,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);const[a,...o]=n;void 0!==a&&(r.multipleOf=a),o.length&&(r.allOf=[...r.allOf??[],...o.map(t=>({multipleOf:t}))])}})(t,e,n,i),t.isFinite=!0},ri({minValue:t=>{const{minimum:e,exclusiveMinimum:n}=fs(t);return Math.max(e??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:t=>{const{maximum:e,exclusiveMaximum:n}=fs(t);return Math.min(e??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:t=>{const{isInt:e,multipleOf:n}=fs(t);return!!e||!!n?.some(Number.isSafeInteger)},format:t=>fs(t).format??null},{gt(t,e){return this.check(Co(t,e))},gte(t,e){return this.check(Po(t,e))},min(t,e){return this.check(Po(t,e))},lt(t,e){return this.check(zo(t,e))},lte(t,e){return this.check(Bo(t,e))},max(t,e){return this.check(Bo(t,e))},int(t){return this.check(ph(t))},safe(t){return this.check(ph(t))},positive(t){return this.check(Co(0,t))},nonnegative(t){return this.check(Po(0,t))},negative(t){return this.check(zo(0,t))},nonpositive(t){return this.check(Bo(0,t))},multipleOf(t,e){return this.check(To(t,e))},step(t,e){return this.check(To(t,e))},finite(){return this}}));function uh(t){return function(t,e){return new t(So({type:"number",checks:[],...Fn(e)}))}(fh,t)}const dh=mi("ZodNumberFormat",(t,e)=>{ka.init(t,e),fh.init(t,e)});function ph(t){return function(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...Fn(e)})}(dh,t)}const mh=mi("ZodBoolean",(t,e)=>{Aa.init(t,e),Rs.init(t,e),t._zod.processJSONSchema=(t,e,n)=>((t,e,n)=>{n.type="boolean"})(0,0,e)});function gh(t){return function(t,e){return new t({type:"boolean",...Fn(e)})}(mh,t)}const bh=mi("ZodUnknown",(t,e)=>{Ma.init(t,e),Rs.init(t,e),t._zod.processJSONSchema=(t,e,n)=>{}});function wh(){return new bh({type:"unknown"})}const yh=mi("ZodNever",(t,e)=>{Ea.init(t,e),Rs.init(t,e),t._zod.processJSONSchema=(t,e,n)=>((t,e,n)=>{n.not={}})(0,0,e)});function _h(t){return function(t,e){return new t({type:"never",...Fn(e)})}(yh,t)}const vh=mi("ZodArray",(t,e)=>{Ls(),za.init(t,e),Rs.init(t,e),t._zod.processJSONSchema=(e,n,i)=>((t,e,n,i)=>{const r=n,a=t._zod.def,{minimum:o,maximum:s}=fs(t);"number"==typeof o&&(r.minItems=o),"number"==typeof s&&(r.maxItems=s),r.type="array",r.items=jo(a.element,e,{...i,path:[...i.path,"items"]})})(t,e,n,i),t.element=e.element},{min(t,e){return this.check(Oo(t,e))},nonempty(t){return this.check(Oo(1,t))},max(t,e){return this.check(Uo(t,e))},length(t,e){return this.check(Lo(t,e))},unwrap(){return this.element}});function xh(t,e){return function(t,e,n){return new t({type:"array",element:e,...Fn(n)})}(vh,t,e)}const kh=mi("ZodObject",(t,e)=>{Ls(),Oa.init(t,e),Rs.init(t,e),t._zod.processJSONSchema=(e,n,i)=>((t,e,n,i)=>{const r=n,a=t._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&$o(t,e,r,i,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(const t in o)xn(r.properties,t,jo(o[t],e,{...i,path:[...i.path,"properties",t]}));const s=[];for(const t of Object.keys(o)){const n=a.shape[t];("input"===e.io?void 0===ms(n):void 0===n._zod.optout)&&s.push(t)}s.length>0&&(r.required=s),"never"===a.catchall?._zod.def.type?r.additionalProperties=!1:a.catchall?a.catchall&&(r.additionalProperties=jo(a.catchall,e,{...i,path:[...i.path,"additionalProperties"]})):"output"===e.io&&(r.additionalProperties=!1)})(t,e,n,i),li(t,"shape",t=>t._zod.def.shape,!1)},{keyof(){return Uh(Object.keys(this._zod.def.shape))},catchall(t){return this.clone(Sn(this._zod.def,{catchall:t}))},passthrough(){return this.clone(Sn(this._zod.def,{catchall:wh()}))},loose(){return this.clone(Sn(this._zod.def,{catchall:wh()}))},strict(){return this.clone(Sn(this._zod.def,{catchall:_h()}))},strip(){return this.clone(Sn(this._zod.def,{catchall:void 0}))},extend(t){return function(t,e){if(!Tn(e))throw new Error("Invalid input to extend: expected a plain object");const n=t._zod.def.checks;if(n&&n.length>0){const n=An(t);for(const t of Reflect.ownKeys(e))if(void 0!==Object.getOwnPropertyDescriptor(n,t))throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Rn(t,Sn(t._zod.def,{shape:Gn(t,e)}))}(this,t)},safeExtend(t){return function(t,e){if(!Tn(e))throw new Error("Invalid input to safeExtend: expected a plain object");return Rn(t,Sn(t._zod.def,{shape:Gn(t,e)}))}(this,t)},merge(t){return function(t,e){if(!e?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(t._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n={};return In(n,t,Reflect.ownKeys(An(t))),In(n,e,Reflect.ownKeys(An(e))),Rn(t,Sn(t._zod.def,{shape:n,get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]}))}(this,t)},pick(t){return function(t,e){const n=t._zod.def,i=n.checks;if(i&&i.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const r={};return In(r,t,jn(t,e)),Rn(t,Sn(n,{shape:r,checks:[]}))}(this,t)},omit(t){return function(t,e){const n=t._zod.def,i=n.checks;if(i&&i.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const r=new Set(jn(t,e)),a={};return In(a,t,Reflect.ownKeys(An(t)).filter(t=>!r.has(t))),Rn(t,Sn(n,{shape:a,checks:[]}))}(this,t)},partial(...t){return Hn(Dh,this,t[0])},exactPartial(...t){return Hn($h,this,t[0],"exactPartial")},required(...t){return function(t,e,n){const i=n?new Set(jn(e,n)):void 0,r={};return In(r,e,Reflect.ownKeys(An(e)),(e,n)=>i&&!i.has(n)?e:new t({type:"nonoptional",innerType:e})),Rn(e,Sn(e._zod.def,{shape:r}))}(qh,this,t[0])}});function Ah(t,e){const n={type:"object",shape:t??{},...Fn(e)};return new kh(n)}function Mh(t,e){return new kh({type:"object",shape:t,catchall:_h(),...Fn(e)})}const Eh=mi("ZodUnion",(t,e)=>{Ra.init(t,e),Rs.init(t,e),t._zod.processJSONSchema=(e,n,i)=>((t,e,n,i)=>{const r=t._zod.def,a=!1===r.inclusive,o=r.options.map((t,n)=>jo(t,e,{...i,path:[...i.path,a?"oneOf":"anyOf",n]}));a?n.oneOf=o:n.anyOf=o})(t,e,n,i),t.options=e.options});function Ih(t,e){return new Eh({type:"union",options:t,...Fn(e)})}const Sh=mi("ZodDiscriminatedUnion",(t,e)=>{Eh.init(t,e),Fa.init(t,e)});function zh(t,e,n){return new Sh({type:"union",options:e,discriminator:t,...Fn(n)})}const Bh=mi("ZodIntersection",(t,e)=>{Da.init(t,e),Rs.init(t,e),t._zod.processJSONSchema=(e,n,i)=>((t,e,n,i)=>{const r=t._zod.def,a=jo(r.left,e,{...i,path:[...i.path,"allOf",0]}),o=jo(r.right,e,{...i,path:[...i.path,"allOf",1]}),s=t=>"allOf"in t&&1===Object.keys(t).length,h=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=h,e.intersections.push(h)})(t,e,n,i)});const Ch=mi("ZodTuple",(t,e)=>{Ls(),ja.init(t,e),Rs.init(t,e),t._zod.processJSONSchema=(e,n,i)=>((t,e,n,i)=>{const r=n,a=t._zod.def;r.type="array";const o="draft-2020-12"===e.target?"prefixItems":"items",s="draft-2020-12"===e.target||"openapi-3.0"===e.target?"items":"additionalItems",h=a.items.map((t,n)=>jo(t,e,{...i,path:[...i.path,o,n]})),c=a.rest?jo(a.rest,e,{...i,path:[...i.path,s,..."openapi-3.0"===e.target?[a.items.length]:[]]}):null;let l=a.items.length;for(;l>0;){const t=a.items[l-1];if(!("input"===e.io?void 0!==ms(t):"optional"===t._zod.optout))break;l--}const f=a.items.length,u=!a.rest;"draft-2020-12"===e.target?(r.prefixItems=h,u?r.items=!1:c&&(r.items=c),l>0&&(r.minItems=l),u&&(r.maxItems=f)):"openapi-3.0"===e.target?(r.items={anyOf:h},c&&r.items.anyOf.push(c),l>0&&(r.minItems=l),u&&(r.maxItems=f)):(r.items=h,u?r.additionalItems=!1:c&&(r.additionalItems=c),l>0&&(r.minItems=l),u&&(r.maxItems=f));const{minimum:d,maximum:p}=fs(t);"number"==typeof d&&(r.minItems=d),"number"==typeof p&&(r.maxItems=p)})(t,e,n,i)},{rest(t){return this.clone({...this._zod.def,rest:t})},partial(){const t=this._zod.def;if(t.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...t,items:t.items.map(t=>new Dh({type:"optional",innerType:t}))})}});function Ph(t,e,n){const i=e instanceof Dr;return new Ch({type:"tuple",items:t,rest:i?e:null,...Fn(i?n:e)})}const Th=mi("ZodEnum",(t,e)=>{qa.init(t,e),Rs.init(t,e),t._zod.processJSONSchema=(e,n,i)=>((t,e,n)=>{const i=gn(t._zod.def.entries);0!==i.length?(i.every(t=>"number"==typeof t)&&(n.type="number"),i.every(t=>"string"==typeof t)&&(n.type="string"),n.enum=i):n.not={}})(t,0,n),t.enum=e.entries,t.options=[...t._zod.values];const n=new Set(Object.keys(e.entries));t.extract=(t,i)=>{const r={};for(const i of t){if(!n.has(i))throw new Error(`Key ${i} not found in enum`);r[i]=e.entries[i]}return new Th({...e,checks:[],...Fn(i),entries:r})},t.exclude=(t,i)=>{const r={...e.entries};for(const e of t){if(!n.has(e))throw new Error(`Key ${e} not found in enum`);delete r[e]}return new Th({...e,checks:[],...Fn(i),entries:r})}});function Uh(t,e){const n=Array.isArray(t)?Object.fromEntries(t.map(t=>[t,t])):t;return new Th({type:"enum",entries:n,...Fn(e)})}function Oh(t,e){return new Th({type:"enum",entries:t,...Fn(e)})}const Lh=mi("ZodLiteral",(t,e)=>{Wa.init(t,e),Rs.init(t,e),t._zod.processJSONSchema=(e,n,i)=>((t,e,n,i)=>{const r=t._zod.def;if(0===r.values.length)return void(n.not={});const a=[];for(const o of r.values)if(void 0===o){if($o(t,e,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if("bigint"==typeof o){if($o(t,e,n,i,"BigInt literals cannot be represented in JSON Schema"))return;a.push(Number(o))}else a.push(o);if(0===a.length);else if(1===a.length){const t=a[0];n.type=null===t?"null":typeof t,"draft-04"===e.target||"openapi-3.0"===e.target?n.enum=[t]:n.const=t}else a.every(t=>"number"==typeof t)&&(n.type="number"),a.every(t=>"string"==typeof t)&&(n.type="string"),a.every(t=>"boolean"==typeof t)&&(n.type="boolean"),a.every(t=>null===t)&&(n.type="null"),n.enum=a})(t,e,n,i),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function Rh(t,e){return new Lh({type:"literal",values:Array.isArray(t)?t:[t],...Fn(e)})}const Fh=mi("ZodTransform",(t,e)=>{Ls(),Va.init(t,e),Rs.init(t,e),t._zod.processJSONSchema=(e,n,i)=>((t,e,n,i)=>{$o(t,e,n,i,"Transforms cannot be represented in JSON Schema")})(t,e,n,i),t._zod.parse=(n,i)=>{if("backward"===i.direction)throw new bi(t.constructor.name);n.addIssue=i=>{if("string"==typeof i)n.issues.push(ei(i,n.value,e));else{const e=i;e.fatal&&(e.continue=!1),e.code??(e.code="custom"),"input"in e||(e.input=n.value),e.inst??(e.inst=t),n.issues.push(ei(e))}};const r=e.transform(n.value,n);return r instanceof Promise?r.then(t=>(n.value=t,n)):(n.value=r,n)}});const Dh=mi("ZodOptional",(t,e)=>{Ya.init(t,e),Rs.init(t,e),t._zod.processJSONSchema=(e,n,i)=>ws(t,e,0,i),t.unwrap=()=>t._zod.def.innerType});function Nh(t){return new Dh({type:"optional",innerType:t})}const $h=mi("ZodExactOptional",(t,e)=>{Xa.init(t,e),Rs.init(t,e),t._zod.processJSONSchema=(e,n,i)=>ws(t,e,0,i),t.unwrap=()=>t._zod.def.innerType});const jh=mi("ZodNullable",(t,e)=>{Ka.init(t,e),Rs.init(t,e),t._zod.processJSONSchema=(e,n,i)=>((t,e,n,i)=>{const r=t._zod.def,a=jo(r.innerType,e,i),o=e.seen.get(t);"openapi-3.0"===e.target?(o.ref=r.innerType,n.nullable=!0):n.anyOf=[a,{type:"null"}]})(t,e,n,i),t.unwrap=()=>t._zod.def.innerType});function Gh(t){return new jh({type:"nullable",innerType:t})}const Hh=mi("ZodDefault",(t,e)=>{Qa.init(t,e),Rs.init(t,e),t._zod.processJSONSchema=(e,n,i)=>((t,e,n,i)=>{const r=t._zod.def;jo(r.innerType,e,i),e.seen.get(t).ref=r.innerType;const a=bs(r.defaultValue,t,e,n,i);a!==gs&&(n.default=a)})(t,e,n,i),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});const Zh=mi("ZodPrefault",(t,e)=>{eo.init(t,e),Rs.init(t,e),t._zod.processJSONSchema=(e,n,i)=>((t,e,n,i)=>{const r=t._zod.def;if(jo(r.innerType,e,i),e.seen.get(t).ref=r.innerType,"input"!==e.io)return;const a=bs(r.defaultValue,t,e,n,i);a!==gs&&(n._prefault=a)})(t,e,n,i),t.unwrap=()=>t._zod.def.innerType});const qh=mi("ZodNonOptional",(t,e)=>{no.init(t,e),Rs.init(t,e),t._zod.processJSONSchema=(e,n,i)=>((t,e,n,i)=>{const r=t._zod.def;jo(r.innerType,e,i),e.seen.get(t).ref=r.innerType})(t,e,0,i),t.unwrap=()=>t._zod.def.innerType});const Wh=mi("ZodCatch",(t,e)=>{ao.init(t,e),Rs.init(t,e),t._zod.processJSONSchema=(e,n,i)=>((t,e,n,i)=>{const r=t._zod.def;let a;jo(r.innerType,e,i),e.seen.get(t).ref=r.innerType;try{a=r.catchValue(void 0)}catch{return void $o(t,e,n,i,"Dynamic catch values are not supported in JSON Schema")}n.default=a})(t,e,n,i),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});const Vh=mi("ZodPipe",(t,e)=>{oo.init(t,e),Rs.init(t,e),t._zod.processJSONSchema=(e,n,i)=>((t,e,n,i)=>{const r=t._zod.def,a=r.in._zod.traits.has("$ZodTransform"),o="input"===e.io?a?r.out:r.in:r.out;jo(o,e,i),e.seen.get(t).ref=o})(t,e,0,i),t.in=e.in,t.out=e.out});function Jh(t,e){return new Vh({type:"pipe",in:t,out:e})}const Yh=mi("ZodReadonly",(t,e)=>{ho.init(t,e),Rs.init(t,e),t._zod.processJSONSchema=(e,n,i)=>((t,e,n,i)=>{const r=t._zod.def;jo(r.innerType,e,i),e.seen.get(t).ref=r.innerType,n.readOnly=!0})(t,e,n,i),t.unwrap=()=>t._zod.def.innerType});const Xh=mi("ZodFunction",(t,e)=>{lo.init(t,e),Rs.init(t,e),t._zod.processJSONSchema=(e,n,i)=>((t,e,n,i)=>{$o(t,e,n,i,"Function types cannot be represented in JSON Schema")})(t,e,n,i)});const Kh=mi("ZodCustom",(t,e)=>{fo.init(t,e),Rs.init(t,e),t._zod.processJSONSchema=(e,n,i)=>((t,e,n,i)=>{$o(t,e,n,i,"Custom types cannot be represented in JSON Schema")})(t,e,n,i)});const Qh=mi("ZodInstanceOf",(t,e)=>{Kh.init(t,e)},{properties(t,e){return this.check(function(t,e){return new Or({check:"properties",shape:t,...Fn(e)})}(t,e))}});const tc=Ih([uh().int().min(0).max(4294967295),Ns(),Ah({r:uh(),g:uh(),b:uh(),a:uh().optional()})]),ec=xh(Ih([Ah({offset:uh(),color:tc}),tc])).min(1);function nc(t){const e=t.length-1;return t.map((t,n)=>"object"==typeof t&&"offset"in t?t:{offset:0===e?0:n/e,color:t})}function ic(t,e,n){return t<e?e:t>n?n:t}function rc(t,e){if("object"==typeof t){const e=t=>Math.round(ic(t,0,255));return[e(t.r),e(t.g),e(t.b),e(t.a??255)]}const{r:n,g:i,b:r,a:a}=lc(pc(t,e));return[n,i,r,a]}function ac(t,e,n=1024){let i=0;const r=t.map(({offset:t,color:n})=>{const[r,a,o,s]=rc(n,e),h=Math.max(i,ic(t,0,1)),c=s/255;return i=h,{position:h,color:[r*c,a*c,o*c,s]}}),a=new Float32Array(4*n);let o=0;for(let t=0;t<n;t++){const e=n>1?t/(n-1):0;for(;o<r.length&&r[o].position<=e;)o++;const i=r[Math.max(0,o-1)],s=r[Math.min(r.length-1,o)],h=s.position-i.position,c=h>0?ic((e-i.position)/h,0,1):0,l=i.color.map((t,e)=>t+(s.color[e]-t)*c),f=l[3],u=f/255;for(let e=0;e<3;e++)a[4*t+e]=u>0?l[e]/u:0;a[4*t+3]=f}return a}function oc(t,e,n=0){let i=Math.imul(0|t,2376512323)+Math.imul(0|e,3625334849)+Math.imul(0|n,3407524639)|0;return i=Math.imul(i^i>>>16,2246822507),i=Math.imul(i^i>>>13,3266489909),i^=i>>>16,(i>>>0)/4294967296}function sc(t){const e={width:t.bitmap.width,height:t.bitmap.height,data:n.Buffer.from(t.bitmap.data)},i=new t.constructor(e);return i.iccProfile=t.iccProfile,i}function hc(t,e,n,i,r){const{width:a,height:o}=t.bitmap;e=Math.round(e),n=Math.round(n),i=Math.round(i),r=Math.round(r);const s=Math.min(Math.max(e,0),a),h=Math.min(Math.max(n,0),o);return{x:s,y:h,w:Math.min(Math.max(e+i,s),a)-s,h:Math.min(Math.max(n+r,h),o)-h}}function cc(t,e,n,i,r,a){let o,s,h,c,l;if("function"==typeof e)l=e,o=0,s=0,h=t.bitmap.width,c=t.bitmap.height;else{if(o=e,"number"!=typeof n)throw new Error("y must be a number");if(s=n,"number"!=typeof i)throw new Error("w must be a number");if(h=i,"number"!=typeof r)throw new Error("h must be a number");if(c=r,"function"!=typeof a)throw new Error("cb must be a function");l=a}({x:o,y:s,w:h,h:c}=hc(t,o,s,h,c));const f=l.bind(t);for(let e=s;e<s+c;e++)for(let n=o;n<o+h;n++){f(n,e,t.bitmap.width*e+n<<2)}return t}function lc(t){if("number"!=typeof t)throw new Error("i must be a number");const e={r:0,g:0,b:0,a:0};return e.r=Math.floor(t/Math.pow(256,3)),e.g=Math.floor((t-e.r*Math.pow(256,3))/Math.pow(256,2)),e.b=Math.floor((t-e.r*Math.pow(256,3)-e.g*Math.pow(256,2))/Math.pow(256,1)),e.a=Math.floor((t-e.r*Math.pow(256,3)-e.g*Math.pow(256,2)-e.b*Math.pow(256,1))/Math.pow(256,0)),e}function fc(t,e,n,i){if("number"!=typeof t||"number"!=typeof e||"number"!=typeof n||"number"!=typeof i)throw new Error("r, g, b and a must be numbers");if(t<0||t>255)throw new Error("r must be between 0 and 255");if(e<0||e>255)throw new Error("g must be between 0 and 255");if(n<0||n>255)throw new Error("b must be between 0 and 255");if(i<0||i>255)throw new Error("a must be between 0 and 255");let r=255&t;return r<<=8,r|=255&e,r<<=8,r|=255&n,r<<=8,r|=255&i,r>>>=0,r}function uc(t,e){const n=t=>Math.pow(t,2),{max:i}=Math,r="a"in t?t.a:255,a="a"in e?e.a:255;return(i(n(t.r-e.r),n(t.r-e.r-r+a))+i(n(t.g-e.g),n(t.g-e.g-r+a))+i(n(t.b-e.b),n(t.b-e.b-r+a)))/195075}function dc(t){return t=Math.max(t,0),t=Math.min(t,255)}function pc(t,e=Ye){if("number"==typeof t)return t;const n=function(t){const e=pn.exec(t.trim());if(!e)return;const[,n,i,r,a,o]=e;return{colorSpace:Ke[n.toLowerCase()],rgb:[i,r,a].map(e=>mn(e,t)),alpha:void 0===o?1:mn(o,t)}}(t);let i,r;if(n)i=cn(n.rgb,n.colorSpace,e),r=n.alpha;else{const n=le(t);if(!n.isValid())throw new Error(`Invalid color "${t}"`);if(e===Ye)return parseInt(n.toHex8(),16);const{r:a,g:o,b:s,a:h}=n.toRgb();i=cn([a/255,o/255,s/255],Ye,e),r=h}const[a,o,s]=i.map(t=>Math.round(255*t));return(a<<24|o<<16|s<<8|Math.round(255*r))>>>0}const mc=[1,4,8,16,24,32];function gc(t){return{red:t>>>16&255,green:t>>>8&255,blue:255&t,quad:0}}function bc(t,{bitPP:e=24,palette:n,hr:i,vr:r,reserved1:a,reserved2:o}={}){if(!mc.includes(e))throw new Error(`Unsupported BMP bit depth ${e}, use ${mc.join(", ")}`);const s=e<=8?function(t,e,n){const i=2**e;if(n){if(n.length<1||n.length>i)throw new Error(`A ${e}-bit BMP palette needs 1 to ${i} colours, got ${n.length}`);return n.map(t=>pc(t)>>>8)}const r=new Set;for(let e=0;e<t.data.length&&r.size<=i;e+=4)r.add(t.data[e]<<16|t.data[e+1]<<8|t.data[e+2]);if(r.size<=i)return[...r].sort((t,e)=>t-e);if(1===e)return;return re([xt.PointContainer.fromUint8Array(new Uint8Array(t.data),t.width,t.height)],{colors:i}).getPointContainer().getPointArray().map(({r:t,g:e,b:n})=>t<<16|e<<8|n)}(t,e,n):void 0,h=1===e&&!s;return cc({bitmap:t},0,0,t.width,t.height,function(e,n,i){let r=t.data[i+0],a=t.data[i+1],o=t.data[i+2];const s=t.data[i+3];if(h){r=a=o=.2126*r+.7152*a+.0722*o>127.5?255:0}t.data[i+0]=s,t.data[i+1]=o,t.data[i+2]=a,t.data[i+3]=r}),(c={data:t.data,width:t.width,height:t.height,bitPP:e,palette:(h?[0,16777215]:s)?.map(gc),hr:i,vr:r,reserved1:a,reserved2:o},new y(c)).data;var c}function wc(t,e){const n=_(t,e),i=16===n.bitPP||32===n.bitPP;return cc({bitmap:n},0,0,n.width,n.height,function(t,e,r){const a=n.data[r+0],o=n.data[r+1],s=n.data[r+2],h=n.data[r+3];n.data[r+0]=h,n.data[r+1]=s,n.data[r+2]=o,n.data[r+3]=i?a:255}),n}function yc(){return{mime:"image/bmp",encode:bc,decode:wc}}const _c=65,vc=4225,xc=274625,kc=1024;function Ac(t,e){let n=Math.imul(e,2654435761)>>>22;for(;-1!==t[n]&&t[n]!==e;)n=n+1&1023;return n}function Mc(t,e,n){const i=e*n*4,r=new Int32Array(kc).fill(-1);let a=0,o=!1,s=-1;for(let e=0;e<i;e+=4){if(0===t[e+3]){o=!0;continue}const n=t[e]<<16|t[e+1]<<8|t[e+2];if(n===s||a>256)continue;s=n;const i=Ac(r,n);-1===r[i]&&(r[i]=n,a++)}const h=o?255:256,c=new Uint8Array(e*n);let l;a<=h?l=function(t,e,n,i){const r=Array.from(n.filter(t=>-1!==t)).sort((t,e)=>t-e),a=new Uint8Array(kc);for(let t=0;t<r.length;t++)a[Ac(n,r[t])]=t;for(let r=0,o=0;r<e;r+=4,o++)if(0!==t[r+3]){const e=t[r]<<16|t[r+1]<<8|t[r+2];i[o]=a[Ac(n,e)]}return r}(t,i,r,c):(l=function(t,e,n){const i=new Float64Array(xc),r=new Float64Array(xc),a=new Float64Array(xc),o=new Float64Array(xc),s=new Float64Array(xc);for(let n=0;n<e;n+=4){if(0===t[n+3])continue;const e=t[n],h=t[n+1],c=t[n+2],l=(1+(e>>2))*vc+(1+(h>>2))*_c+(c>>2)+1;i[l]=i[l]+1,r[l]=r[l]+e,a[l]=a[l]+h,o[l]=o[l]+c,s[l]=s[l]+e*e+h*h+c*c}!function(t,e,n,i,r){const a=new Float64Array(_c),o=new Float64Array(_c),s=new Float64Array(_c),h=new Float64Array(_c),c=new Float64Array(_c);for(let l=1;l<_c;l++){a.fill(0),o.fill(0),s.fill(0),h.fill(0),c.fill(0);for(let f=1;f<_c;f++){let u=0,d=0,p=0,m=0,g=0;for(let b=1;b<_c;b++){const w=l*vc+f*_c+b,y=w-vc;u+=t[w],d+=e[w],p+=n[w],m+=i[w],g+=r[w],a[b]=a[b]+u,o[b]=o[b]+d,s[b]=s[b]+p,h[b]=h[b]+m,c[b]=c[b]+g,t[w]=t[y]+a[b],e[w]=e[y]+o[b],n[w]=n[y]+s[b],i[w]=i[y]+h[b],r[w]=r[y]+c[b]}}}}(i,r,a,o,s);const h=64,c=[{r0:0,r1:h,g0:0,g1:h,b0:0,b1:h,vol:h**3}],l=new Float64Array(n),f=t=>{if(t.vol<=1)return 0;const e=Cc(t,r),n=Cc(t,a),h=Cc(t,o);return Cc(t,s)-(e*e+n*n+h*h)/Cc(t,i)};let u=0;for(let t=1;t<n;t++){const e={r0:0,r1:0,g0:0,g1:0,b0:0,b1:0,vol:0};Oc(c[u],e,i,r,a,o)?(c[t]=e,l[u]=f(c[u]),l[t]=f(e)):(l[u]=0,t--),u=0;for(let e=1;e<=t;e++)l[e]>l[u]&&(u=e);if(l[u]<=0)break}const d=new Set;for(const t of c){const e=Cc(t,i);if(e>0){const n=Math.round(Cc(t,r)/e),i=Math.round(Cc(t,a)/e),s=Math.round(Cc(t,o)/e);d.add(n<<16|i<<8|s)}}return Array.from(d).sort((t,e)=>t-e)}(t,i,h),Lc(t,i,l,c),l=function(t,e,n,i){const r=new Float64Array(4*n);for(let n=0,a=0;n<e;n+=4,a++){if(0===t[n+3])continue;const e=4*i[a];r[e]=r[e]+1,r[e+1]=r[e+1]+t[n],r[e+2]=r[e+2]+t[n+1],r[e+3]=r[e+3]+t[n+2]}const a=new Set;for(let t=0;t<r.length;t+=4){const e=r[t];if(e>0){const n=Math.round(r[t+1]/e),i=Math.round(r[t+2]/e),o=Math.round(r[t+3]/e);a.add(n<<16|i<<8|o)}}return Array.from(a).sort((t,e)=>t-e)}(t,i,l.length,c),Lc(t,i,l,c));let f=null;if(o){f=l.length;for(let e=3,n=0;e<i;e+=4,n++)0===t[e]&&(c[n]=f)}return{palette:Ec(l,o),indexes:c,transparentIndex:f}}function Ec(t,e){const n=t.length+(e?1:0);let i=2;for(;i<n;)i<<=1;const r=t.slice();for(;r.length<i;)r.push(0);return r}const Ic=0,Sc=1,zc=2;function Bc(t,e,n){return t*vc+e*_c+n}function Cc({r0:t,r1:e,g0:n,g1:i,b0:r,b1:a},o){return o[Bc(e,i,a)]-o[Bc(e,i,r)]-o[Bc(e,n,a)]+o[Bc(e,n,r)]-o[Bc(t,i,a)]+o[Bc(t,i,r)]+o[Bc(t,n,a)]-o[Bc(t,n,r)]}function Pc({r0:t,r1:e,g0:n,g1:i,b0:r,b1:a},o,s){switch(o){case Ic:return-s[Bc(t,i,a)]+s[Bc(t,i,r)]+s[Bc(t,n,a)]-s[Bc(t,n,r)];case Sc:return-s[Bc(e,n,a)]+s[Bc(e,n,r)]+s[Bc(t,n,a)]-s[Bc(t,n,r)];default:return-s[Bc(e,i,r)]+s[Bc(e,n,r)]+s[Bc(t,i,r)]-s[Bc(t,n,r)]}}function Tc({r0:t,r1:e,g0:n,g1:i,b0:r,b1:a},o,s,h){switch(o){case Ic:return h[Bc(s,i,a)]-h[Bc(s,i,r)]-h[Bc(s,n,a)]+h[Bc(s,n,r)];case Sc:return h[Bc(e,s,a)]-h[Bc(e,s,r)]-h[Bc(t,s,a)]+h[Bc(t,s,r)];default:return h[Bc(e,i,s)]-h[Bc(e,n,s)]-h[Bc(t,i,s)]+h[Bc(t,n,s)]}}function Uc(t,e,n,i,r,a,o,s,h){const[c,l,f,u]=r,d=Pc(t,e,a),p=Pc(t,e,o),m=Pc(t,e,s),g=Pc(t,e,h);let b=0,w=-1;for(let r=n;r<i;r++){let n=d+Tc(t,e,r,a);if(0===n)continue;let i=p+Tc(t,e,r,o),y=m+Tc(t,e,r,s),_=g+Tc(t,e,r,h),v=(i*i+y*y+_*_)/n;n=c-n,0!==n&&(i=l-i,y=f-y,_=u-_,v+=(i*i+y*y+_*_)/n,v>b&&(b=v,w=r))}return{max:b,position:w}}function Oc(t,e,n,i,r,a){const o=[Cc(t,n),Cc(t,i),Cc(t,r),Cc(t,a)],s=Uc(t,Ic,t.r0+1,t.r1,o,n,i,r,a),h=Uc(t,Sc,t.g0+1,t.g1,o,n,i,r,a),c=Uc(t,zc,t.b0+1,t.b1,o,n,i,r,a);if(e.r1=t.r1,e.g1=t.g1,e.b1=t.b1,s.max>=h.max&&s.max>=c.max){if(s.position<0)return!1;e.r0=t.r1=s.position,e.g0=t.g0,e.b0=t.b0}else h.max>=s.max&&h.max>=c.max?(e.g0=t.g1=h.position,e.r0=t.r0,e.b0=t.b0):(e.b0=t.b1=c.position,e.r0=t.r0,e.g0=t.g0);return t.vol=(t.r1-t.r0)*(t.g1-t.g0)*(t.b1-t.b0),e.vol=(e.r1-e.r0)*(e.g1-e.g0)*(e.b1-e.b0),!0}function Lc(t,e,n,i){const r=n.length,a=new Int32Array(r),o=new Int32Array(r),s=new Int32Array(r);for(let t=0;t<r;t++)a[t]=n[t]>>16&255,o[t]=n[t]>>8&255,s[t]=255&n[t];const h=new Int32Array(1<<18).fill(-1),c=new Uint16Array(1<<18),l=new Float64Array(r);let f=new Uint8Array(4096),u=0;const d=(t,e,n,i)=>{const d=-4&e,p=-4&n,m=-4&i,g=d+4-1,b=p+4-1,w=m+4-1;let y=1/0;for(let t=0;t<r;t++){const e=a[t]<d?d-a[t]:a[t]>g?a[t]-g:0,n=o[t]<p?p-o[t]:o[t]>b?o[t]-b:0,i=s[t]<m?m-s[t]:s[t]>w?s[t]-w:0,r=Math.max(a[t]-d,g-a[t]),h=Math.max(o[t]-p,b-o[t]),c=Math.max(s[t]-m,w-s[t]);l[t]=e*e+n*n+i*i,y=Math.min(y,r*r+h*h+c*c)}if(u+r>f.length){const t=new Uint8Array(2*f.length);t.set(f),f=t}h[t]=u;for(let t=0;t<r;t++)l[t]<=y&&(f[u++]=t);c[t]=u-h[t]};let p=-1,m=0;for(let n=0,r=0;n<e;n+=4,r++){if(0===t[n+3])continue;const e=t[n],l=t[n+1],u=t[n+2],g=e<<16|l<<8|u;if(g!==p){const t=e>>2<<12|l>>2<<6|u>>2;-1===h[t]&&d(t,e,l,u);const n=h[t],i=n+c[t];let r=1/0;for(let t=n;t<i;t++){const n=f[t],i=e-a[n],h=l-o[n],c=u-s[n],d=i*i+h*h+c*c;d<r&&(r=d,m=n)}p=g}i[r]=m}}function Rc(t){return 4===t?3:t}const Fc=4096;function Dc(t,e,n,i){const r=i[0];return{width:r?Math.max(t,r.x+r.width):t,height:r?Math.max(e,r.y+r.height):e,loop:n,frames:i}}const Nc="NETSCAPE2.0",$c="ANIMEXTS1.0";function jc(t,e){const n=n=>{for(let i=0;i<n.length;i++)if(t[e+i]!==n.charCodeAt(i))return!1;return!0};return n(Nc)||n($c)}function Gc(t,e){for(;e<t.length;){const n=t[e];if(0===n)break;if(n>=3&&1===t[e+1]&&e+3<t.length)return t[e+2]|t[e+3]<<8;e+=n+1}return null}function Hc(t,e){let n=0;for(;e<t.length;){const i=t[e];if(0===i)break;n+=Math.min(i,t.length-e-1),e+=i+1}return n}const Zc=new Uint16Array(Fc),qc=new Uint8Array(Fc),Wc=new Uint8Array(Fc),Vc=new Uint16Array(Fc);function Jc(t,e,n){const{minCodeSize:i}=e,r=n.length;if(i<1||i>11||0===r)return 0;const a=1<<i,o=a+1,s=t=>t<a?t:Wc[t],h=t=>t<a?1:Vc[t];let c=i+1,l=(1<<c)-1,f=o+1,u=-1,d=0;const p=t.length;let m=e.dataStart,g=m,b=0,w=0;for(;d<r;){for(;w<c;){if(m>=g){const e=m<p?t[m]:0;if(0===e)return d;if(m++,g=Math.min(m+e,p),m>=g)return d}b|=t[m++]<<w,w+=8}const e=b&l;if(b>>>=c,w-=c,e===a){c=i+1,l=(1<<c)-1,f=o+1,u=-1;continue}if(e===o)break;if(-1===u?e>a:e>f)break;-1!==u&&f<Fc&&(Zc[f]=u,qc[f]=s(e===f?u:e),Wc[f]=s(u),Vc[f]=h(u)+1,f++,f>l&&c<12&&(c++,l=(1<<c)-1));let y=e,_=d+h(e)-1;const v=Math.min(_+1,r);for(;_>=r;)y=Zc[y],_--;for(;y>=a;)n[_--]=qc[y],y=Zc[y];n[_]=y,d=v,u=e}return d}const Yc=32768/12,Xc=[[0,8],[4,8],[2,4],[1,2]];function Kc(t,e,n){const i={x:t.x,y:t.y,width:Math.max(0,Math.min(t.width,e-t.x)),height:Math.max(0,Math.min(t.height,n-t.y))};return i.width>0&&i.height>0?i:{x:0,y:0,width:0,height:0}}function Qc(t,e,n){const i=new Uint32Array(n.width*n.height);for(let r=0;r<n.height;r++){const a=(n.y+r)*e+n.x;i.set(t.subarray(a,a+n.width),r*n.width)}return i}function tl(t,e,n,i){for(let r=0;r<n.height;r++){const a=(n.y+r)*e+n.x;i?t.set(i.subarray(r*n.width,(r+1)*n.width),a):t.fill(0,a,a+n.width)}}function el(t,e){if(e<=0)return 0;if(!t.interlaced)return e;let n=0,i=0;for(const[r,a]of Xc)r<e&&(i=n+Math.ceil((e-r)/a)),n+=Math.max(0,Math.ceil((t.height-r)/a));return i}function nl(t,e){const n=e?Math.floor(e.length/3):0;for(let i=0;i<256;i++){const r=4*i;i<n?(t[r]=e[3*i],t[r+1]=e[3*i+1],t[r+2]=e[3*i+2]):(t[r]=0,t[r+1]=0,t[r+2]=0),t[r+3]=255}}function il(t,e,n,i,r,a,o){if(0===i.width||0===i.height||0===a)return;const s=n.transparentIndex??-1,h=Math.ceil(a/n.width),c=(h,c)=>{const l=h*n.width,f=Math.min(i.width,a-l);if(c>=i.height)return;const u=(i.y+c)*e+i.x;for(let e=0;e<f;e++){const n=r[l+e];n!==s&&(t[u+e]=o[n])}};if(n.interlaced){let t=0;for(const[e,i]of Xc)for(let r=e;r<n.height&&t<h;r+=i)c(t++,r)}else for(let t=0;t<Math.min(h,i.height);t++)c(t,t)}const rl=8192;function al(t){const e=t+Math.ceil(t/3838)+2,n=Math.ceil(12*e/8);return n+Math.ceil(n/255)+1024}function ol(t){let e=0;for(;1<<e+1<=t.length;)e++;return e}function sl(t,e){return t.length===e.length&&t.every((t,n)=>t===e[n])}function hl(t,e,n,i){const r=[];let a=new Uint8Array(800),o=0;const s=t=>{a[o++]=255&t,a[o++]=t>>8&255},h=t=>{for(const e of t)a[o++]=e>>16&255,a[o++]=e>>8&255,a[o++]=255&e},c=n[0].image.palette,l=ol(c);a.set([71,73,70,56,57,97],o),o+=6,s(t),s(e),a[o++]=128|l-1,a[o++]=0,a[o++]=0,h(c),null!==i&&(a.set([33,255,11,78,69,84,83,67,65,80,69,50,46,48,3,1],o),o+=16,s(i),a[o++]=0);for(const{image:i,delay:f}of n){r.push(a.subarray(0,o)),a=new Uint8Array(al(t*e)),o=0;const{palette:n,indexes:u,transparentIndex:d}=i,p=!sl(n,c),m=p?ol(n):l;a[o++]=33,a[o++]=249,a[o++]=4,a[o++]=8|(null===d?0:1),s(f),a[o++]=d??0,a[o++]=0,a[o++]=44,s(0),s(0),s(t),s(e),p?(a[o++]=128|m-1,h(n)):a[o++]=0,o=cl(a,o,Math.max(2,m),u)}a[o++]=59,r.push(a.subarray(0,o));const f=r.reduce((t,e)=>t+e.length,0),u=new Uint8Array(f);let d=0;for(const t of r)u.set(t,d),d+=t.length;return u}function cl(t,e,n,i){const r=1<<n,a=r+1,o=new Int32Array(rl).fill(-1),s=new Uint16Array(rl);let h=a+1,c=n+1,l=0,f=0;t[e++]=n;let u=e++;const d=n=>{for(l|=n<<f,f+=c;f>=8;)t[e++]=255&l,l>>=8,f-=8,e===u+256&&(t[u]=255,u=e++)};d(r);let p=i[0]&r-1;for(let t=1;t<i.length;t++){const e=i[t]&r-1,l=p<<8|e;let f=Math.imul(l,2654435761)>>>19;for(;-1!==o[f]&&o[f]!==l;)f=f+1&8191;o[f]!==l?(d(p),4096===h?(d(r),o.fill(-1),h=a+1,c=n+1):(h>=1<<c&&c++,o[f]=l,s[f]=h++),p=e):p=s[f]}return d(p),d(a),f>0&&(t[e++]=255&l,e===u+256&&(t[u]=255,u=e++)),u+1===e?t[u]=0:(t[u]=e-u-1,t[e++]=0),e}const ll=65535;function fl(t,e,i){const r=function(t,e=1/0){const n=t.length;if(n<13||71!==t[0]||73!==t[1]||70!==t[2]||56!==t[3]||55!==t[4]&&57!==t[4]||97!==t[5])throw new Error("Invalid GIF file: missing GIF87a or GIF89a header");const i=e=>t[e]|t[e+1]<<8,r=i(6),a=i(8),o=t[10];let s,h=13;if(128&o){const e=3<<1+(7&o);if(h+e>n)return Dc(r,a,null,[]);s=t.subarray(h,h+e),h+=e}const c=[];let l=null,f={delay:0,disposal:0,transparentIndex:null},u=!1;const d=()=>{let e=0;for(;h<n;){const n=t[h++];if(0===n)return e;h+=n,e+=n}return-1};for(;h<n;){const r=t[h++];if(33===r){const e=t[h++],n=h;if(d()<0)break;const r=t[n];if(249===e&&r>=4){const e=t[n+1];f={disposal:Rc(e>>2&7),delay:i(n+2),transparentIndex:1&e?t[n+4]:null},u=!0}else 255===e&&11===r&&jc(t,n+1)&&(l=Gc(t,n+12)??l)}else{if(44!==r)break;{if(h+9>n)break;const r=t[h+8];let a=s,o=h+9;if(128&r){const e=3<<1+(7&r);a=t.subarray(o,o+e),o+=e}const l=o>=n;if(l&&0===c.length)break;const p={x:i(h),y:i(h+2),width:i(h+4),height:i(h+6),interlaced:!!(64&r),palette:a,...u?f:{delay:0,disposal:0,transparentIndex:null},minCodeSize:l?0:t[o],dataStart:o+1,dataLength:0};h=o+1,u=!1;const m=d();if(c.length<e&&(p.dataLength=m<0?Hc(t,p.dataStart):m,c.push(p)),m<0)break}}}return Dc(r,a,l,c)}(t,i),{width:a,height:o,frames:s}=r,h=1e6*e;if(a<=0||o<=0)throw new Error(`Invalid GIF dimensions ${a}x${o}`);for(const t of s)if(t.width*t.height>h)throw new Error(`GIF frame dimensions ${t.width}x${t.height} exceed the maximum resolution of ${e} megapixels`);if(a*o>h)throw new Error(`GIF dimensions ${a}x${o} exceed the maximum resolution of ${e} megapixels`);if(0===s.length)throw new Error("Invalid GIF file: no frames found");if(s.length*a*o>h)throw new Error(`GIF has ${s.length} frames of ${a}x${o}, which together exceed the maximum resolution of ${e} megapixels. Decode fewer frames with maxFrames, or raise maxResolutionInMP`);const c=[];for(const e of function*(t,e){const{width:n,height:i}=e,r=new Uint8Array(n*i*4),a=new Uint32Array(r.buffer),o=new Uint32Array(256),s=new Uint8Array(o.buffer);let h,c=new Uint8Array(0),l=0,f={x:0,y:0,width:0,height:0};for(const u of e.frames){2===l?tl(a,n,f):3===l&&h&&tl(a,n,f,h);const e=Kc(u,n,i);l=u.disposal,f=e,h=3===l?Qc(a,n,e):void 0;const d=u.width*el(u,e.height),p=Math.min(d,Math.ceil(u.dataLength*Yc));c.length<p&&(c=new Uint8Array(p));const m=Jc(t,u,c.subarray(0,p));m<d&&null===u.transparentIndex&&0===e.x&&0===e.y&&e.width===n&&e.height===i&&a.fill(0),nl(s,u.palette),il(a,n,u,e,c,m,o),yield r}}(t,r)){const t=s[c.length],i=c.length===s.length-1;c.push({bitmap:{data:i?n.Buffer.from(e.buffer,e.byteOffset,e.byteLength):n.Buffer.from(e),width:a,height:o},delay:10*t.delay})}return{frames:c,loop:r.loop}}function ul(t,e){if(t<=0||e<=0)throw new Error(`Invalid GIF dimensions ${t}x${e}`);if(t>ll||e>ll)throw new Error(`GIF dimensions ${t}x${e} exceed the maximum of 65535x65535`)}function dl(){return{mime:"image/gif",encode:t=>{const{width:e,height:i,data:r}=t;ul(e,i);const a=hl(e,i,[{image:Mc(r,e,i),delay:8}],0);return n.Buffer.from(a.buffer,a.byteOffset,a.byteLength)},decode:(t,{maxResolutionInMP:e=100}={})=>fl(t,e,1).frames[0].bitmap,decodeFrames:(t,{maxResolutionInMP:e=100}={},{maxFrames:n=1/0}={})=>fl(t,e,n),encodeFrames:(t,{loop:e=0}={})=>{const i=t[0];if(!i)throw new Error("Can't encode a GIF without frames");const{width:r,height:a}=i.bitmap;if(ul(r,a),null!==e&&("number"!=typeof e||Number.isNaN(e)))throw new Error("loop must be a number, or null to play once");const o=t.map(({bitmap:t,delay:e=100},n)=>{if(t.width!==r||t.height!==a)throw new Error(`Every frame of a GIF must be the same size, but frame ${n} is ${t.width}x${t.height} and frame 0 is ${r}x${a}`);return{image:Mc(t.data,r,a),delay:pl(Math.round(e/10),0,65535)}}),s=hl(r,a,o,null===e?null:pl(Math.round(e),0,65535));return n.Buffer.from(s.buffer,s.byteOffset,s.byteLength)}}}function pl(t,e,n){return Math.min(Math.max(t,e),n)}function ml(t){return t}function gl(t){return t instanceof Uint8Array?t:new Uint8Array(t)}const bl=new Uint8Array([137,80,78,71,13,10,26,10]);var wl,yl,_l,vl;(yl=wl||(wl={}))[yl.GRAYSCALE=0]="GRAYSCALE",yl[yl.COLOR=2]="COLOR",yl[yl.PALETTE=3]="PALETTE",yl[yl.GRAYSCALE_ALPHA=4]="GRAYSCALE_ALPHA",yl[yl.COLOR_ALPHA=6]="COLOR_ALPHA",(vl=_l||(_l={}))[vl.AUTO=-1]="AUTO",vl[vl.NONE=0]="NONE",vl[vl.SUB=1]="SUB",vl[vl.UP=2]="UP",vl[vl.AVERAGE=3]="AVERAGE",vl[vl.PAETH=4]="PAETH";const xl={[wl.GRAYSCALE]:[1,2,4,8,16],[wl.COLOR]:[8,16],[wl.PALETTE]:[1,2,4,8],[wl.GRAYSCALE_ALPHA]:[8,16],[wl.COLOR_ALPHA]:[8,16]},kl={[wl.GRAYSCALE]:1,[wl.COLOR]:3,[wl.PALETTE]:1,[wl.GRAYSCALE_ALPHA]:2,[wl.COLOR_ALPHA]:4},Al=1e5,Ml=2147483647;function El(t,e,n){const i=Math.abs(e-n),r=Math.abs(t-n),a=Math.abs(t+e-n-n);return i<=r&&i<=a?t:r<=a?e:n}function Il(t,e,n,i,r){let a=-1;for(let o=0;o<i;o++){const i=t[e],o=e+1,s=o+n;switch(i){case 0:break;case 1:for(let e=o+r;e<s;e++)t[e]=t[e]+t[e-r];break;case 2:if(a>=0)for(let e=o,n=a;e<s;e++,n++)t[e]=t[e]+t[n];break;case 3:if(a<0)for(let e=o+r;e<s;e++)t[e]=t[e]+(t[e-r]>>1);else{const e=Math.min(o+r,s);let n=o,i=a;for(;n<e;n++,i++)t[n]=t[n]+(t[i]>>1);for(;n<s;n++,i++)t[n]=t[n]+(t[n-r]+t[i]>>1)}break;case 4:if(a<0)for(let e=o+r;e<s;e++)t[e]=t[e]+t[e-r];else{const e=Math.min(o+r,s);let n=o,i=a;for(;n<e;n++,i++)t[n]=t[n]+t[i];for(;n<s;n++,i++){const e=t[n-r],a=t[i],o=t[i-r],s=e+a-o,h=s>e?s-e:e-s,c=s>a?s-a:a-s,l=s>o?s-o:o-s;t[n]=t[n]+(h<=c&&h<=l?e:c<=l?a:o)}}break;default:throw new Error(`Invalid filter type ${i}`)}a=o,e=s}}function Sl(t,e,n,i,r,a,o,s){const h=[0,0,0,0,0],c=1===a.length?a[0]:-1;for(let l=0;l<i;l++){const i=e+l*n,f=i+n,u=l>0?i-n:-1;let d=c;if(d<0){let e=0,o=0,s=0,c=0,l=0;for(let a=i,h=0;a<f;a++,h++){const i=t[a],f=h>=r?t[a-r]:0,d=u>=0?t[a-n]:0,p=u>=0&&h>=r?t[a-n-r]:0;e+=i,o+=Math.abs(i-f),s+=Math.abs(i-d),c+=Math.abs(i-(f+d>>1)),l+=Math.abs(i-El(f,d,p))}h[0]=e,h[1]=o,h[2]=s,h[3]=c,h[4]=l;let p=1/0;for(const t of a)h[t]<p&&(p=h[t],d=t)}switch(o[s++]=d,d){case 0:o.set(t.subarray(i,f),s);break;case 1:for(let e=i,n=0;e<f;e++,n++)o[s+n]=t[e]-(n>=r?t[e-r]:0);break;case 2:for(let e=i,r=0;e<f;e++,r++)o[s+r]=t[e]-(u>=0?t[e-n]:0);break;case 3:for(let e=i,a=0;e<f;e++,a++){const i=a>=r?t[e-r]:0,h=u>=0?t[e-n]:0;o[s+a]=t[e]-(i+h>>1)}break;case 4:for(let e=i,a=0;e<f;e++,a++){const i=a>=r?t[e-r]:0,h=u>=0?t[e-n]:0,c=u>=0&&a>=r?t[e-n-r]:0;o[s+a]=t[e]-El(i,h,c)}break;default:throw new Error(`Invalid filter type ${d}`)}s+=n}}const zl=[{x:0,y:0,xStep:8,yStep:8},{x:4,y:0,xStep:8,yStep:8},{x:0,y:4,xStep:4,yStep:8},{x:2,y:0,xStep:4,yStep:4},{x:0,y:2,xStep:2,yStep:4},{x:1,y:0,xStep:2,yStep:2},{x:0,y:1,xStep:1,yStep:2}];function Bl(t,e,n){if(!n)return[{width:t,height:e,x:0,y:0,xStep:1,yStep:1}];const i=[];for(const n of zl){const r=Math.ceil((t-n.x)/n.xStep),a=Math.ceil((e-n.y)/n.yStep);r>0&&a>0&&i.push({...n,width:r,height:a})}return i}function Cl(t,e){return Math.ceil(e*kl[t.colorType]*t.depth/8)}function Pl(t){return Math.max(1,kl[t.colorType]*t.depth>>3)}function Tl(t){let e=t.length;for(;--e>=0;)t[e]=0}var Ul=30,Ol=new Uint8Array([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]),Ll=new Uint8Array([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]),Rl=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Fl=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Dl=new Array(576);Tl(Dl);var Nl=new Array(60);Tl(Nl);var $l=new Array(512);Tl($l);var jl=new Array(256);Tl(jl);var Gl=new Array(29);Tl(Gl);var Hl=new Array(Ul);Tl(Hl);var Zl,ql,Wl,Vl=class{constructor(t,e,n,i,r){this.static_tree=t,this.extra_bits=e,this.extra_base=n,this.elems=i,this.max_length=r,this.has_stree=t&&t.length}},Jl=class{constructor(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}},Yl=t=>t<256?$l[t]:$l[256+(t>>>7)],Xl=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},Kl=(t,e,n)=>{t.bi_valid>16-n?(t.bi_buf|=e<<t.bi_valid&65535,Xl(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=n-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=n)},Ql=(t,e,n)=>{Kl(t,n[2*e],n[2*e+1])},tf=(t,e)=>{let n=0;do{n|=1&t,t>>>=1,n<<=1}while(--e>0);return n>>>1},ef=(t,e,n)=>{const i=new Array(16);let r,a,o=0;for(r=1;r<=15;r++)o=o+n[r-1]<<1,i[r]=o;for(a=0;a<=e;a++){let e=t[2*a+1];0!==e&&(t[2*a]=tf(i[e]++,e))}},nf=t=>{let e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<Ul;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.sym_next=t.matches=0},rf=t=>{t.bi_valid>8?Xl(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},af=(t,e,n,i)=>{const r=2*e,a=2*n;return t[r]<t[a]||t[r]===t[a]&&i[e]<=i[n]},of=(t,e,n)=>{const i=t.heap[n];let r=n<<1;for(;r<=t.heap_len&&(r<t.heap_len&&af(e,t.heap[r+1],t.heap[r],t.depth)&&r++,!af(e,i,t.heap[r],t.depth));)t.heap[n]=t.heap[r],n=r,r<<=1;t.heap[n]=i},sf=(t,e,n)=>{let i,r,a,o,s=0;if(0!==t.sym_next)do{i=255&t.pending_buf[t.sym_buf+s++],i+=(255&t.pending_buf[t.sym_buf+s++])<<8,r=t.pending_buf[t.sym_buf+s++],0===i?Ql(t,r,e):(a=jl[r],Ql(t,a+256+1,e),o=Ol[a],0!==o&&(r-=Gl[a],Kl(t,r,o)),i--,a=Yl(i),Ql(t,a,n),o=Ll[a],0!==o&&(i-=Hl[a],Kl(t,i,o)))}while(s<t.sym_next);Ql(t,256,e)},hf=(t,e)=>{const n=e.dyn_tree,i=e.stat_desc.static_tree,r=e.stat_desc.has_stree,a=e.stat_desc.elems;let o,s,h,c=-1;for(t.heap_len=0,t.heap_max=573,o=0;o<a;o++)0!==n[2*o]?(t.heap[++t.heap_len]=c=o,t.depth[o]=0):n[2*o+1]=0;for(;t.heap_len<2;)h=t.heap[++t.heap_len]=c<2?++c:0,n[2*h]=1,t.depth[h]=0,t.opt_len--,r&&(t.static_len-=i[2*h+1]);for(e.max_code=c,o=t.heap_len>>1;o>=1;o--)of(t,n,o);h=a;do{o=t.heap[1],t.heap[1]=t.heap[t.heap_len--],of(t,n,1),s=t.heap[1],t.heap[--t.heap_max]=o,t.heap[--t.heap_max]=s,n[2*h]=n[2*o]+n[2*s],t.depth[h]=(t.depth[o]>=t.depth[s]?t.depth[o]:t.depth[s])+1,n[2*o+1]=n[2*s+1]=h,t.heap[1]=h++,of(t,n,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const n=e.dyn_tree,i=e.max_code,r=e.stat_desc.static_tree,a=e.stat_desc.has_stree,o=e.stat_desc.extra_bits,s=e.stat_desc.extra_base,h=e.stat_desc.max_length;let c,l,f,u,d,p,m=0;for(u=0;u<=15;u++)t.bl_count[u]=0;for(n[2*t.heap[t.heap_max]+1]=0,c=t.heap_max+1;c<573;c++)l=t.heap[c],u=n[2*n[2*l+1]+1]+1,u>h&&(u=h,m++),n[2*l+1]=u,l>i||(t.bl_count[u]++,d=0,l>=s&&(d=o[l-s]),p=n[2*l],t.opt_len+=p*(u+d),a&&(t.static_len+=p*(r[2*l+1]+d)));if(0!==m){do{for(u=h-1;0===t.bl_count[u];)u--;t.bl_count[u]--,t.bl_count[u+1]+=2,t.bl_count[h]--,m-=2}while(m>0);for(u=h;0!==u;u--)for(l=t.bl_count[u];0!==l;)f=t.heap[--c],f>i||(n[2*f+1]!==u&&(t.opt_len+=(u-n[2*f+1])*n[2*f],n[2*f+1]=u),l--)}})(t,e),ef(n,c,t.bl_count)},cf=(t,e,n)=>{let i,r,a=-1,o=e[1],s=0,h=7,c=4;for(0===o&&(h=138,c=3),e[2*(n+1)+1]=65535,i=0;i<=n;i++)r=o,o=e[2*(i+1)+1],++s<h&&r===o||(s<c?t.bl_tree[2*r]+=s:0!==r?(r!==a&&t.bl_tree[2*r]++,t.bl_tree[32]++):s<=10?t.bl_tree[34]++:t.bl_tree[36]++,s=0,a=r,0===o?(h=138,c=3):r===o?(h=6,c=3):(h=7,c=4))},lf=(t,e,n)=>{let i,r,a=-1,o=e[1],s=0,h=7,c=4;for(0===o&&(h=138,c=3),i=0;i<=n;i++)if(r=o,o=e[2*(i+1)+1],!(++s<h&&r===o)){if(s<c)do{Ql(t,r,t.bl_tree)}while(0!==--s);else 0!==r?(r!==a&&(Ql(t,r,t.bl_tree),s--),Ql(t,16,t.bl_tree),Kl(t,s-3,2)):s<=10?(Ql(t,17,t.bl_tree),Kl(t,s-3,3)):(Ql(t,18,t.bl_tree),Kl(t,s-11,7));s=0,a=r,0===o?(h=138,c=3):r===o?(h=6,c=3):(h=7,c=4)}},ff=!1,uf=t=>{ff||((()=>{let t,e,n,i,r;const a=new Array(16);for(n=0,i=0;i<28;i++)for(Gl[i]=n,t=0;t<1<<Ol[i];t++)jl[n++]=i;for(jl[n-1]=i,r=0,i=0;i<16;i++)for(Hl[i]=r,t=0;t<1<<Ll[i];t++)$l[r++]=i;for(r>>=7;i<Ul;i++)for(Hl[i]=r<<7,t=0;t<1<<Ll[i]-7;t++)$l[256+r++]=i;for(e=0;e<=15;e++)a[e]=0;for(t=0;t<=143;)Dl[2*t+1]=8,t++,a[8]++;for(;t<=255;)Dl[2*t+1]=9,t++,a[9]++;for(;t<=279;)Dl[2*t+1]=7,t++,a[7]++;for(;t<=287;)Dl[2*t+1]=8,t++,a[8]++;for(ef(Dl,287,a),t=0;t<Ul;t++)Nl[2*t+1]=5,Nl[2*t]=tf(t,5);Zl=new Vl(Dl,Ol,257,286,15),ql=new Vl(Nl,Ll,0,Ul,15),Wl=new Vl(new Array(0),Rl,0,19,7)})(),ff=!0),t.l_desc=new Jl(t.dyn_ltree,Zl),t.d_desc=new Jl(t.dyn_dtree,ql),t.bl_desc=new Jl(t.bl_tree,Wl),t.bi_buf=0,t.bi_valid=0,nf(t)},df=(t,e,n,i)=>{Kl(t,0+(i?1:0),3),rf(t),Xl(t,n),Xl(t,~n),n&&t.pending_buf.set(t.window.subarray(e,e+n),t.pending),t.pending+=n},pf=t=>{Kl(t,2,3),Ql(t,256,Dl),(t=>{16===t.bi_valid?(Xl(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)},mf=(t,e,n,i)=>{let r,a,o=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,n=4093624447;for(e=0;e<=31;e++,n>>>=1)if(1&n&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),hf(t,t.l_desc),hf(t,t.d_desc),o=(t=>{let e;for(cf(t,t.dyn_ltree,t.l_desc.max_code),cf(t,t.dyn_dtree,t.d_desc.max_code),hf(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*Fl[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),r=t.opt_len+3+7>>>3,a=t.static_len+3+7>>>3,(a<=r||4===t.strategy)&&(r=a)):r=a=n+5,n+4<=r&&-1!==e?df(t,e,n,i):4===t.strategy||a===r?(Kl(t,2+(i?1:0),3),sf(t,Dl,Nl)):(Kl(t,4+(i?1:0),3),((t,e,n,i)=>{let r;for(Kl(t,e-257,5),Kl(t,n-1,5),Kl(t,i-4,4),r=0;r<i;r++)Kl(t,t.bl_tree[2*Fl[r]+1],3);lf(t,t.dyn_ltree,e-1),lf(t,t.dyn_dtree,n-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,o+1),sf(t,t.dyn_ltree,t.dyn_dtree)),nf(t),i&&rf(t)},gf=(t,e,n)=>(t.pending_buf[t.sym_buf+t.sym_next++]=e,t.pending_buf[t.sym_buf+t.sym_next++]=e>>8,t.pending_buf[t.sym_buf+t.sym_next++]=n,0===e?t.dyn_ltree[2*n]++:(t.matches++,e--,t.dyn_ltree[2*(jl[n]+256+1)]++,t.dyn_dtree[2*Yl(e)]++),t.sym_next===t.sym_end),bf=(t,e,n,i)=>{let r=65535&t,a=t>>>16&65535,o=0;for(;0!==n;){o=n>2e3?2e3:n,n-=o;do{r=r+e[i++]|0,a=a+r|0}while(--o);r%=65521,a%=65521}return r|a<<16},wf=(()=>{const t=new Uint32Array(2048);let e;for(let n=0;n<256;n++){e=n;for(let t=0;t<8;t++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}for(let n=0;n<256;n++){e=t[n];for(let i=256;i<2048;i+=256)e=t[255&e]^e>>>8,t[i+n]=e}return t})(),yf=(t,e,n,i)=>{const r=wf,a=i+n;let o=i;t^=-1;for(const n=a-7;o<n;o+=8)t=r[1792+(255&(t^=e[o]|e[o+1]<<8|e[o+2]<<16|e[o+3]<<24))]^r[1536+(t>>>8&255)]^r[1280+(t>>>16&255)]^r[1024+(t>>>24)]^r[768+e[o+4]]^r[512+e[o+5]]^r[256+e[o+6]]^r[e[o+7]];for(;o<a;o++)t=t>>>8^r[255&(t^e[o])];return-1^t},_f={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"},vf=258,xf=262,kf=42,Af=113,Mf=666,Ef=(t,e)=>(t.msg=_f[e],e),If=t=>2*t-(t>4?9:0),Sf=t=>{let e=t.length;for(;--e>=0;)t[e]=0},zf=t=>{let e,n,i,r=t.w_size;e=t.hash_size,i=e;do{n=t.head[--i],t.head[i]=n>=r?n-r:0}while(--e);e=r,i=e;do{n=t.prev[--i],t.prev[i]=n>=r?n-r:0}while(--e)},Bf=(t,e,n)=>(e<<t.hash_shift^n)&t.hash_mask,Cf=(t,e)=>{let n;if(t.legacy_hash)n=t.ins_h=Bf(t,t.ins_h,t.window[e+3-1]);else{const i=t.window,r=i[e]|i[e+1]<<8|i[e+2]<<16|i[e+3]<<24;n=t.ins_h=Math.imul(r,66521)+66521>>>16&t.hash_mask}const i=t.prev[e&t.w_mask]=t.head[n];return t.head[n]=e,i},Pf=t=>{const e=t.state;let n=e.pending;n>t.avail_out&&(n=t.avail_out),0!==n&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+n),t.next_out),t.next_out+=n,e.pending_out+=n,t.total_out+=n,t.avail_out-=n,e.pending-=n,0===e.pending&&(e.pending_out=0))},Tf=(t,e)=>{mf(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,Pf(t.strm)},Uf=(t,e)=>{t.pending_buf[t.pending++]=e},Of=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},Lf=(t,e,n,i)=>{let r=t.avail_in;return r>i&&(r=i),0===r?0:(t.avail_in-=r,e.set(t.input.subarray(t.next_in,t.next_in+r),n),1===t.state.wrap?t.adler=bf(t.adler,e,r,n):2===t.state.wrap&&(t.adler=yf(t.adler,e,r,n)),t.next_in+=r,t.total_in+=r,r)},Rf=(t,e)=>{let n,i,r=t.max_chain_length,a=t.strstart,o=t.prev_length,s=t.nice_match;const h=t.strstart>t.w_size-xf?t.strstart-(t.w_size-xf):0,c=t.window,l=t.w_mask,f=t.prev,u=t.strstart+vf;let d=c[a+o-1],p=c[a+o];t.prev_length>=t.good_match&&(r>>=2),s>t.lookahead&&(s=t.lookahead);do{if(n=e,c[n+o]===p&&c[n+o-1]===d&&c[n]===c[a]&&c[++n]===c[a+1]){a+=2,n++;do{}while(c[++a]===c[++n]&&c[++a]===c[++n]&&c[++a]===c[++n]&&c[++a]===c[++n]&&c[++a]===c[++n]&&c[++a]===c[++n]&&c[++a]===c[++n]&&c[++a]===c[++n]&&a<u);if(i=vf-(u-a),a=u-vf,i>o){if(t.match_start=e,o=i,i>=s)break;d=c[a+o-1],p=c[a+o]}}}while((e=f[e&l])>h&&0!==--r);return o<=t.lookahead?o:t.lookahead},Ff=t=>{const e=t.w_size;let n,i,r;do{if(i=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-xf)&&(t.window.set(t.window.subarray(e,e+e-i),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,t.insert>t.strstart&&(t.insert=t.strstart),zf(t),i+=e),0===t.strm.avail_in)break;if(n=Lf(t.strm,t.window,t.strstart+t.lookahead,i),t.lookahead+=n,t.legacy_hash){if(t.lookahead+t.insert>=3)for(r=t.strstart-t.insert,t.ins_h=t.window[r],t.ins_h=Bf(t,t.ins_h,t.window[r+1]);t.insert&&(Cf(t,r),r++,t.insert--,!(t.lookahead+t.insert<3)););}else if(t.lookahead+t.insert>3)for(r=t.strstart-t.insert;t.insert&&(Cf(t,r),r++,t.insert--,!(t.lookahead+t.insert<=3)););}while(t.lookahead<xf&&0!==t.strm.avail_in)},Df=(t,e)=>{let n,i,r,a=t.pending_buf_size-5>t.w_size?t.w_size:t.pending_buf_size-5,o=0,s=t.strm.avail_in;do{if(n=65535,r=t.bi_valid+42>>3,t.strm.avail_out<r)break;if(r=t.strm.avail_out-r,i=t.strstart-t.block_start,n>i+t.strm.avail_in&&(n=i+t.strm.avail_in),n>r&&(n=r),n<a&&(0===n&&4!==e||0===e||n!==i+t.strm.avail_in))break;o=4===e&&n===i+t.strm.avail_in?1:0,df(t,0,0,o),t.pending_buf[t.pending-4]=n,t.pending_buf[t.pending-3]=n>>8,t.pending_buf[t.pending-2]=~n,t.pending_buf[t.pending-1]=~n>>8,Pf(t.strm),i&&(i>n&&(i=n),t.strm.output.set(t.window.subarray(t.block_start,t.block_start+i),t.strm.next_out),t.strm.next_out+=i,t.strm.avail_out-=i,t.strm.total_out+=i,t.block_start+=i,n-=i),n&&(Lf(t.strm,t.strm.output,t.strm.next_out,n),t.strm.next_out+=n,t.strm.avail_out-=n,t.strm.total_out+=n)}while(0===o);return s-=t.strm.avail_in,s&&(s>=t.w_size?(t.matches=2,t.window.set(t.strm.input.subarray(t.strm.next_in-t.w_size,t.strm.next_in),0),t.strstart=t.w_size,t.insert=t.strstart):(t.window_size-t.strstart<=s&&(t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,t.insert>t.strstart&&(t.insert=t.strstart)),t.window.set(t.strm.input.subarray(t.strm.next_in-s,t.strm.next_in),t.strstart),t.strstart+=s,t.insert+=s>t.w_size-t.insert?t.w_size-t.insert:s),t.block_start=t.strstart),t.high_water<t.strstart&&(t.high_water=t.strstart),o?4:0!==e&&4!==e&&0===t.strm.avail_in&&t.strstart===t.block_start?2:(r=t.window_size-t.strstart,t.strm.avail_in>r&&t.block_start>=t.w_size&&(t.block_start-=t.w_size,t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,r+=t.w_size,t.insert>t.strstart&&(t.insert=t.strstart)),r>t.strm.avail_in&&(r=t.strm.avail_in),r&&(Lf(t.strm,t.window,t.strstart,r),t.strstart+=r,t.insert+=r>t.w_size-t.insert?t.w_size-t.insert:r),t.high_water<t.strstart&&(t.high_water=t.strstart),r=t.bi_valid+42>>3,r=t.pending_buf_size-r>65535?65535:t.pending_buf_size-r,a=r>t.w_size?t.w_size:r,i=t.strstart-t.block_start,(i>=a||(i||4===e)&&0!==e&&0===t.strm.avail_in&&i<=r)&&(n=i>r?r:i,o=4===e&&0===t.strm.avail_in&&n===i?1:0,df(t,t.block_start,n,o),t.block_start+=n,Pf(t.strm)),o?3:1)},Nf=(t,e)=>{let n,i;for(;;){if(t.lookahead<xf){if(Ff(t),t.lookahead<xf&&0===e)return 1;if(0===t.lookahead)break}if(n=0,t.lookahead>=3&&(n=Cf(t,t.strstart)),0!==n&&t.strstart-n<=t.w_size-xf&&(t.match_length=Rf(t,n)),t.match_length>=3)if(i=gf(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,n=Cf(t,t.strstart)}while(0!==--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.legacy_hash&&(t.ins_h=t.window[t.strstart],t.ins_h=Bf(t,t.ins_h,t.window[t.strstart+1]));else i=gf(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(i&&(Tf(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,4===e?(Tf(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(Tf(t,!1),0===t.strm.avail_out)?1:2},$f=(t,e)=>{let n,i,r;for(;;){if(t.lookahead<xf){if(Ff(t),t.lookahead<xf&&0===e)return 1;if(0===t.lookahead)break}if(n=0,t.lookahead>=3&&(n=Cf(t,t.strstart)),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==n&&t.prev_length<t.max_lazy_match&&t.strstart-n<=t.w_size-xf&&(t.match_length=Rf(t,n),t.match_length<=5&&(1===t.strategy||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){r=t.strstart+t.lookahead-3,i=gf(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=r&&(n=Cf(t,t.strstart))}while(0!==--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,i&&(Tf(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(i=gf(t,0,t.window[t.strstart-1]),i&&Tf(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(i=gf(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,4===e?(Tf(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(Tf(t,!1),0===t.strm.avail_out)?1:2},jf=class{constructor(t,e,n,i,r){this.good_length=t,this.max_lazy=e,this.nice_length=n,this.max_chain=i,this.func=r}},Gf=[new jf(0,0,0,0,Df),new jf(4,4,8,4,Nf),new jf(4,5,16,8,Nf),new jf(4,6,32,32,Nf),new jf(4,4,16,16,$f),new jf(8,16,32,32,$f),new jf(8,16,128,128,$f),new jf(8,32,128,256,$f),new jf(32,128,258,1024,$f),new jf(32,258,258,4096,$f)],Hf=class{constructor(){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=8,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.legacy_hash=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 Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),Sf(this.dyn_ltree),Sf(this.dyn_dtree),Sf(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),Sf(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Sf(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}},Zf=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.status!==kf&&57!==e.status&&69!==e.status&&73!==e.status&&91!==e.status&&103!==e.status&&e.status!==Af&&e.status!==Mf?1:0},qf=t=>{const e=(t=>{if(Zf(t))return Ef(t,-2);t.total_in=t.total_out=0,t.data_type=2;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=2===e.wrap?57:e.wrap?kf:Af,t.adler=2===e.wrap?0:1,e.last_flush=-2,uf(e),0})(t);return 0===e&&(t=>{t.window_size=2*t.w_size,Sf(t.head),t.max_lazy_match=Gf[t.level].max_lazy,t.good_match=Gf[t.level].good_length,t.nice_match=Gf[t.level].nice_length,t.max_chain_length=Gf[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0})(t.state),e},Wf=(t,e)=>{if(Zf(t)||e>5||e<0)return t?Ef(t,-2):-2;const n=t.state;if(!t.output||0!==t.avail_in&&!t.input||n.status===Mf&&4!==e)return Ef(t,0===t.avail_out?-5:-2);const i=n.last_flush;if(n.last_flush=e,0!==n.pending){if(Pf(t),0===t.avail_out)return n.last_flush=-1,0}else if(0===t.avail_in&&If(e)<=If(i)&&4!==e)return Ef(t,-5);if(n.status===Mf&&0!==t.avail_in)return Ef(t,-5);if(n.status===kf&&0===n.wrap&&(n.status=Af),n.status===kf){let e=8+(n.w_bits-8<<4)<<8,i=-1;if(i=n.strategy>=2||n.level<2?0:n.level<6?1:6===n.level?2:3,e|=i<<6,0!==n.strstart&&(e|=32),e+=31-e%31,Of(n,e),0!==n.strstart&&(Of(n,t.adler>>>16),Of(n,65535&t.adler)),t.adler=1,n.status=Af,Pf(t),0!==n.pending)return n.last_flush=-1,0}if(57===n.status)if(t.adler=0,Uf(n,31),Uf(n,139),Uf(n,8),n.gzhead)Uf(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)),Uf(n,255&n.gzhead.time),Uf(n,n.gzhead.time>>8&255),Uf(n,n.gzhead.time>>16&255),Uf(n,n.gzhead.time>>24&255),Uf(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),Uf(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(Uf(n,255&n.gzhead.extra.length),Uf(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(t.adler=yf(t.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(Uf(n,0),Uf(n,0),Uf(n,0),Uf(n,0),Uf(n,0),Uf(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),Uf(n,3),n.status=Af,Pf(t),0!==n.pending)return n.last_flush=-1,0;if(69===n.status){if(n.gzhead.extra){let e=n.pending,i=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+i>n.pending_buf_size;){let r=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>e&&(t.adler=yf(t.adler,n.pending_buf,n.pending-e,e)),n.gzindex+=r,Pf(t),0!==n.pending)return n.last_flush=-1,0;e=0,i-=r}let r=new Uint8Array(n.gzhead.extra);n.pending_buf.set(r.subarray(n.gzindex,n.gzindex+i),n.pending),n.pending+=i,n.gzhead.hcrc&&n.pending>e&&(t.adler=yf(t.adler,n.pending_buf,n.pending-e,e)),n.gzindex=0}n.status=73}if(73===n.status){if(n.gzhead.name){let e,i=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(t.adler=yf(t.adler,n.pending_buf,n.pending-i,i)),Pf(t),0!==n.pending)return n.last_flush=-1,0;i=0}e=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,Uf(n,e)}while(0!==e);n.gzhead.hcrc&&n.pending>i&&(t.adler=yf(t.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let e,i=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(t.adler=yf(t.adler,n.pending_buf,n.pending-i,i)),Pf(t),0!==n.pending)return n.last_flush=-1,0;i=0}e=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,Uf(n,e)}while(0!==e);n.gzhead.hcrc&&n.pending>i&&(t.adler=yf(t.adler,n.pending_buf,n.pending-i,i))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(Pf(t),0!==n.pending))return n.last_flush=-1,0;Uf(n,255&t.adler),Uf(n,t.adler>>8&255),t.adler=0}if(n.status=Af,Pf(t),0!==n.pending)return n.last_flush=-1,0}if(0!==t.avail_in||0!==n.lookahead||0!==e&&n.status!==Mf){let i=0===n.level?Df(n,e):2===n.strategy?((t,e)=>{let n;for(;;){if(0===t.lookahead&&(Ff(t),0===t.lookahead)){if(0===e)return 1;break}if(t.match_length=0,n=gf(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,n&&(Tf(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(Tf(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(Tf(t,!1),0===t.strm.avail_out)?1:2})(n,e):3===n.strategy?((t,e)=>{let n,i,r,a;const o=t.window;for(;;){if(t.lookahead<=vf){if(Ff(t),t.lookahead<=vf&&0===e)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(r=t.strstart-1,i=o[r],i===o[++r]&&i===o[++r]&&i===o[++r])){a=t.strstart+vf;do{}while(i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&r<a);t.match_length=vf-(a-r),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(n=gf(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(n=gf(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),n&&(Tf(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(Tf(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(Tf(t,!1),0===t.strm.avail_out)?1:2})(n,e):Gf[n.level].func(n,e);if(3!==i&&4!==i||(n.status=Mf),1===i||3===i)return 0===t.avail_out&&(n.last_flush=-1),0;if(2===i&&(1===e?pf(n):5!==e&&(df(n,0,0,!1),3===e&&(Sf(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),Pf(t),0===t.avail_out))return n.last_flush=-1,0}return 4!==e?0:n.wrap<=0?1:(2===n.wrap?(Uf(n,255&t.adler),Uf(n,t.adler>>8&255),Uf(n,t.adler>>16&255),Uf(n,t.adler>>24&255),Uf(n,255&t.total_in),Uf(n,t.total_in>>8&255),Uf(n,t.total_in>>16&255),Uf(n,t.total_in>>24&255)):(Of(n,t.adler>>>16),Of(n,65535&t.adler)),Pf(t),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?0:1)},Vf=t=>{if(Zf(t))return-2;const e=t.state.status;return t.state=null,e===Af?Ef(t,-3):0},Jf=16209;function Yf(t,e){let n,i,r,a,o,s,h,c,l,f,u,d,p,m,g,b,w,y,_,v,x,k,A,M;const E=t.state;n=t.next_in,A=t.input,i=n+(t.avail_in-5),r=t.next_out,M=t.output,a=r-(e-t.avail_out),o=r+(t.avail_out-257),s=E.dmax,h=E.wsize,c=E.whave,l=E.wnext,f=E.window,u=E.hold,d=E.bits,p=E.lencode,m=E.distcode,g=(1<<E.lenbits)-1,b=(1<<E.distbits)-1;t:do{d<15&&(u+=A[n++]<<d,d+=8,u+=A[n++]<<d,d+=8),w=p[u&g];e:for(;;){if(y=w>>>24,u>>>=y,d-=y,y=w>>>16&255,0===y)M[r++]=65535&w;else{if(!(16&y)){if(64&y){if(32&y){E.mode=16191;break t}t.msg="invalid literal/length code",E.mode=Jf;break t}w=p[(65535&w)+(u&(1<<y)-1)];continue e}for(_=65535&w,y&=15,y&&(d<y&&(u+=A[n++]<<d,d+=8),_+=u&(1<<y)-1,u>>>=y,d-=y),d<15&&(u+=A[n++]<<d,d+=8,u+=A[n++]<<d,d+=8),w=m[u&b];;){if(y=w>>>24,u>>>=y,d-=y,y=w>>>16&255,16&y){if(v=65535&w,y&=15,d<y&&(u+=A[n++]<<d,d+=8,d<y&&(u+=A[n++]<<d,d+=8)),v+=u&(1<<y)-1,v>s){t.msg="invalid distance too far back",E.mode=Jf;break t}if(u>>>=y,d-=y,y=r-a,v>y){if(y=v-y,y>c&&E.sane){t.msg="invalid distance too far back",E.mode=Jf;break t}if(x=0,k=f,0===l){if(x+=h-y,y<_){_-=y;do{M[r++]=f[x++]}while(--y);x=r-v,k=M}}else if(l<y){if(x+=h+l-y,y-=l,y<_){_-=y;do{M[r++]=f[x++]}while(--y);if(x=0,l<_){y=l,_-=y;do{M[r++]=f[x++]}while(--y);x=r-v,k=M}}}else if(x+=l-y,y<_){_-=y;do{M[r++]=f[x++]}while(--y);x=r-v,k=M}for(;_>2;)M[r++]=k[x++],M[r++]=k[x++],M[r++]=k[x++],_-=3;_&&(M[r++]=k[x++],_>1&&(M[r++]=k[x++]))}else{x=r-v;do{M[r++]=M[x++],M[r++]=M[x++],M[r++]=M[x++],_-=3}while(_>2);_&&(M[r++]=M[x++],_>1&&(M[r++]=M[x++]))}break}if(64&y){t.msg="invalid distance code",E.mode=Jf;break t}w=m[(65535&w)+(u&(1<<y)-1)]}}break}}while(n<i&&r<o);_=d>>3,n-=_,d-=_<<3,u&=(1<<d)-1,t.next_in=n,t.next_out=r,t.avail_in=n<i?i-n+5:5-(n-i),t.avail_out=r<o?o-r+257:257-(r-o),E.hold=u,E.bits=d}var Xf,Kf,Qf=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),tu=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,199,75]),eu=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),nu=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),iu=(t,e,n,i,r,a,o,s)=>{const h=s.bits;let c,l,f,u,d,p,m=0,g=0,b=0,w=0,y=0,_=0,v=0,x=0,k=0,A=0,M=null;const E=new Uint16Array(16),I=new Uint16Array(16);let S,z,B,C=null;for(m=0;m<=15;m++)E[m]=0;for(g=0;g<i;g++)E[e[n+g]]++;for(y=h,w=15;w>=1&&0===E[w];w--);if(y>w&&(y=w),0===w)return r[a++]=20971520,r[a++]=20971520,s.bits=1,0;for(b=1;b<w&&0===E[b];b++);for(y<b&&(y=b),x=1,m=1;m<=15;m++)if(x<<=1,x-=E[m],x<0)return-1;if(x>0&&(0===t||1!==w))return-1;for(I[1]=0,m=1;m<15;m++)I[m+1]=I[m]+E[m];for(g=0;g<i;g++)0!==e[n+g]&&(o[I[e[n+g]]++]=g);if(0===t?(M=C=o,p=20):1===t?(M=Qf,C=tu,p=257):(M=eu,C=nu,p=0),A=0,g=0,m=b,d=a,_=y,v=0,f=-1,k=1<<y,u=k-1,1===t&&k>852||2===t&&k>592)return 1;for(;;){S=m-v,o[g]+1<p?(z=0,B=o[g]):o[g]>=p?(z=C[o[g]-p],B=M[o[g]-p]):(z=96,B=0),c=1<<m-v,l=1<<_,b=l;do{l-=c,r[d+(A>>v)+l]=S<<24|z<<16|B}while(0!==l);for(c=1<<m-1;A&c;)c>>=1;if(0!==c?(A&=c-1,A+=c):A=0,g++,0===--E[m]){if(m===w)break;m=e[n+o[g]]}if(m>y&&(A&u)!==f){for(0===v&&(v=y),d+=b,_=m-v,x=1<<_;_+v<w&&(x-=E[_+v],!(x<=0));)_++,x<<=1;if(k+=1<<_,1===t&&k>852||2===t&&k>592)return 1;f=A&u,r[f]=y<<24|_<<16|d-a}}return 0!==A&&(r[d+A]=m-v<<24|4194304),s.bits=y,0},ru=16180,au=16191,ou=16192,su=16194,hu=16199,cu=16200,lu=16206,fu=16209,uu=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24),du=class{constructor(){this.strm=null,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 Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}},pu=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.mode<ru||e.mode>16211?1:0},mu=t=>{if(pu(t))return-2;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,(t=>{if(pu(t))return-2;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=ru,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,0})(t)},gu=(t,e)=>{if(!t)return-2;const n=new du;t.state=n,n.strm=t,n.window=null,n.mode=ru;const i=((t,e)=>{let n;if(pu(t))return-2;const i=t.state;return e<0?(n=0,e=-e):(n=5+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?-2:(null!==i.window&&i.wbits!==e&&(i.window=null),i.wrap=n,i.wbits=e,mu(t))})(t,e);return 0!==i&&(t.state=null),i},bu=!0,wu=t=>{if(bu){Xf=new Int32Array(512),Kf=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(iu(1,t.lens,0,288,Xf,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;iu(2,t.lens,0,32,Kf,0,t.work,{bits:5}),bu=!1}t.lencode=Xf,t.lenbits=9,t.distcode=Kf,t.distbits=5},yu=(t,e)=>{let n,i,r,a,o,s,h,c,l,f,u,d,p,m,g,b,w,y,_,v,x,k,A=0;const M=new Uint8Array(4);let E,I;const S=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(pu(t)||!t.output||!t.input&&0!==t.avail_in)return-2;n=t.state,n.mode===au&&(n.mode=ou),o=t.next_out,r=t.output,h=t.avail_out,a=t.next_in,i=t.input,s=t.avail_in,c=n.hold,l=n.bits,f=s,u=h,k=0;t:for(;;)switch(n.mode){case ru:if(0===n.wrap){n.mode=ou;break}for(;l<16;){if(0===s)break t;s--,c+=i[a++]<<l,l+=8}if(2&n.wrap&&35615===c){0===n.wbits&&(n.wbits=15),n.check=0,M[0]=255&c,M[1]=c>>>8&255,n.check=yf(n.check,M,2,0),c=0,l=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&c)<<8)+(c>>8))%31){t.msg="incorrect header check",n.mode=fu;break}if(8!=(15&c)){t.msg="unknown compression method",n.mode=fu;break}if(c>>>=4,l-=4,x=8+(15&c),0===n.wbits&&(n.wbits=x),x>15||x>n.wbits){t.msg="invalid window size",n.mode=fu;break}n.dmax=1<<n.wbits,n.flags=0,t.adler=n.check=1,n.mode=512&c?16189:au,c=0,l=0;break;case 16181:for(;l<16;){if(0===s)break t;s--,c+=i[a++]<<l,l+=8}if(n.flags=c,8!=(255&n.flags)){t.msg="unknown compression method",n.mode=fu;break}if(57344&n.flags){t.msg="unknown header flags set",n.mode=fu;break}n.head&&(n.head.text=c>>8&1),512&n.flags&&4&n.wrap&&(M[0]=255&c,M[1]=c>>>8&255,n.check=yf(n.check,M,2,0)),c=0,l=0,n.mode=16182;case 16182:for(;l<32;){if(0===s)break t;s--,c+=i[a++]<<l,l+=8}n.head&&(n.head.time=c>>>0),512&n.flags&&4&n.wrap&&(M[0]=255&c,M[1]=c>>>8&255,M[2]=c>>>16&255,M[3]=c>>>24&255,n.check=yf(n.check,M,4,0)),c=0,l=0,n.mode=16183;case 16183:for(;l<16;){if(0===s)break t;s--,c+=i[a++]<<l,l+=8}n.head&&(n.head.xflags=255&c,n.head.os=c>>8),512&n.flags&&4&n.wrap&&(M[0]=255&c,M[1]=c>>>8&255,n.check=yf(n.check,M,2,0)),c=0,l=0,n.mode=16184;case 16184:if(1024&n.flags){for(;l<16;){if(0===s)break t;s--,c+=i[a++]<<l,l+=8}n.length=c,n.head&&(n.head.extra_len=c),512&n.flags&&4&n.wrap&&(M[0]=255&c,M[1]=c>>>8&255,n.check=yf(n.check,M,2,0)),c=0,l=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&(d=n.length,d>s&&(d=s),d&&(n.head&&(x=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(i.subarray(a,a+d),x)),512&n.flags&&4&n.wrap&&(n.check=yf(n.check,i,d,a)),s-=d,a+=d,n.length-=d),n.length))break t;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===s)break t;d=0;do{x=i[a+d++],n.head&&x&&n.length<65536&&(n.head.name+=String.fromCharCode(x),n.length++)}while(x&&d<s);if(512&n.flags&&4&n.wrap&&(n.check=yf(n.check,i,d,a)),s-=d,a+=d,x)break t}else n.head&&(n.head.name=null);n.length=0,n.mode=16187;case 16187:if(4096&n.flags){if(0===s)break t;d=0;do{x=i[a+d++],n.head&&x&&n.length<65536&&(n.head.comment+=String.fromCharCode(x),n.length++)}while(x&&d<s);if(512&n.flags&&4&n.wrap&&(n.check=yf(n.check,i,d,a)),s-=d,a+=d,x)break t}else n.head&&(n.head.comment=null);n.mode=16188;case 16188:if(512&n.flags){for(;l<16;){if(0===s)break t;s--,c+=i[a++]<<l,l+=8}if(4&n.wrap&&c!==(65535&n.check)){t.msg="header crc mismatch",n.mode=fu;break}c=0,l=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),t.adler=n.check=0,n.mode=au;break;case 16189:for(;l<32;){if(0===s)break t;s--,c+=i[a++]<<l,l+=8}t.adler=n.check=uu(c),c=0,l=0,n.mode=16190;case 16190:if(0===n.havedict)return t.next_out=o,t.avail_out=h,t.next_in=a,t.avail_in=s,n.hold=c,n.bits=l,2;t.adler=n.check=1,n.mode=au;case au:case ou:if(n.last){c>>>=7&l,l-=7&l,n.mode=lu;break}for(;l<3;){if(0===s)break t;s--,c+=i[a++]<<l,l+=8}switch(n.last=1&c,c>>>=1,l-=1,3&c){case 0:n.mode=16193;break;case 1:wu(n),n.mode=hu;break;case 2:n.mode=16196;break;case 3:t.msg="invalid block type",n.mode=fu}c>>>=2,l-=2;break;case 16193:for(c>>>=7&l,l-=7&l;l<32;){if(0===s)break t;s--,c+=i[a++]<<l,l+=8}if((65535&c)!=(c>>>16^65535)){t.msg="invalid stored block lengths",n.mode=fu;break}n.length=65535&c,c=0,l=0,n.mode=su;case su:n.mode=16195;case 16195:if(d=n.length,d){if(d>s&&(d=s),d>h&&(d=h),0===d)break t;r.set(i.subarray(a,a+d),o),s-=d,a+=d,h-=d,o+=d,n.length-=d;break}n.mode=au;break;case 16196:for(;l<14;){if(0===s)break t;s--,c+=i[a++]<<l,l+=8}if(n.nlen=257+(31&c),c>>>=5,l-=5,n.ndist=1+(31&c),c>>>=5,l-=5,n.ncode=4+(15&c),c>>>=4,l-=4,n.nlen>286||n.ndist>30){t.msg="too many length or distance symbols",n.mode=fu;break}n.have=0,n.mode=16197;case 16197:for(;n.have<n.ncode;){for(;l<3;){if(0===s)break t;s--,c+=i[a++]<<l,l+=8}n.lens[S[n.have++]]=7&c,c>>>=3,l-=3}for(;n.have<19;)n.lens[S[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,E={bits:n.lenbits},k=iu(0,n.lens,0,19,n.lencode,0,n.work,E),n.lenbits=E.bits,k){t.msg="invalid code lengths set",n.mode=fu;break}n.have=0,n.mode=16198;case 16198:for(;n.have<n.nlen+n.ndist;){for(;A=n.lencode[c&(1<<n.lenbits)-1],g=A>>>24,b=A>>>16&255,w=65535&A,!(g<=l);){if(0===s)break t;s--,c+=i[a++]<<l,l+=8}if(w<16)c>>>=g,l-=g,n.lens[n.have++]=w;else{if(16===w){for(I=g+2;l<I;){if(0===s)break t;s--,c+=i[a++]<<l,l+=8}if(c>>>=g,l-=g,0===n.have){t.msg="invalid bit length repeat",n.mode=fu;break}x=n.lens[n.have-1],d=3+(3&c),c>>>=2,l-=2}else if(17===w){for(I=g+3;l<I;){if(0===s)break t;s--,c+=i[a++]<<l,l+=8}c>>>=g,l-=g,x=0,d=3+(7&c),c>>>=3,l-=3}else{for(I=g+7;l<I;){if(0===s)break t;s--,c+=i[a++]<<l,l+=8}c>>>=g,l-=g,x=0,d=11+(127&c),c>>>=7,l-=7}if(n.have+d>n.nlen+n.ndist){t.msg="invalid bit length repeat",n.mode=fu;break}for(;d--;)n.lens[n.have++]=x}}if(n.mode===fu)break;if(0===n.lens[256]){t.msg="invalid code -- missing end-of-block",n.mode=fu;break}if(n.lenbits=9,E={bits:n.lenbits},k=iu(1,n.lens,0,n.nlen,n.lencode,0,n.work,E),n.lenbits=E.bits,k){t.msg="invalid literal/lengths set",n.mode=fu;break}if(n.distbits=6,n.distcode=n.distdyn,E={bits:n.distbits},k=iu(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,E),n.distbits=E.bits,k){t.msg="invalid distances set",n.mode=fu;break}n.mode=hu;case hu:n.mode=cu;case cu:if(s>=6&&h>=258){t.next_out=o,t.avail_out=h,t.next_in=a,t.avail_in=s,n.hold=c,n.bits=l,Yf(t,u),o=t.next_out,r=t.output,h=t.avail_out,a=t.next_in,i=t.input,s=t.avail_in,c=n.hold,l=n.bits,n.mode===au&&(n.back=-1);break}for(n.back=0;A=n.lencode[c&(1<<n.lenbits)-1],g=A>>>24,b=A>>>16&255,w=65535&A,!(g<=l);){if(0===s)break t;s--,c+=i[a++]<<l,l+=8}if(b&&!(240&b)){for(y=g,_=b,v=w;A=n.lencode[v+((c&(1<<y+_)-1)>>y)],g=A>>>24,b=A>>>16&255,w=65535&A,!(y+g<=l);){if(0===s)break t;s--,c+=i[a++]<<l,l+=8}c>>>=y,l-=y,n.back+=y}if(c>>>=g,l-=g,n.back+=g,n.length=w,0===b){n.mode=16205;break}if(32&b){n.back=-1,n.mode=au;break}if(64&b){t.msg="invalid literal/length code",n.mode=fu;break}n.extra=15&b,n.mode=16201;case 16201:if(n.extra){for(I=n.extra;l<I;){if(0===s)break t;s--,c+=i[a++]<<l,l+=8}n.length+=c&(1<<n.extra)-1,c>>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;A=n.distcode[c&(1<<n.distbits)-1],g=A>>>24,b=A>>>16&255,w=65535&A,!(g<=l);){if(0===s)break t;s--,c+=i[a++]<<l,l+=8}if(!(240&b)){for(y=g,_=b,v=w;A=n.distcode[v+((c&(1<<y+_)-1)>>y)],g=A>>>24,b=A>>>16&255,w=65535&A,!(y+g<=l);){if(0===s)break t;s--,c+=i[a++]<<l,l+=8}c>>>=y,l-=y,n.back+=y}if(c>>>=g,l-=g,n.back+=g,64&b){t.msg="invalid distance code",n.mode=fu;break}n.offset=w,n.extra=15&b,n.mode=16203;case 16203:if(n.extra){for(I=n.extra;l<I;){if(0===s)break t;s--,c+=i[a++]<<l,l+=8}n.offset+=c&(1<<n.extra)-1,c>>>=n.extra,l-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){t.msg="invalid distance too far back",n.mode=fu;break}n.mode=16204;case 16204:if(0===h)break t;if(d=u-h,n.offset>d){if(d=n.offset-d,d>n.whave&&n.sane){t.msg="invalid distance too far back",n.mode=fu;break}d>n.wnext?(d-=n.wnext,p=n.wsize-d):p=n.wnext-d,d>n.length&&(d=n.length),m=n.window}else m=r,p=o-n.offset,d=n.length;d>h&&(d=h),h-=d,n.length-=d;do{r[o++]=m[p++]}while(--d);0===n.length&&(n.mode=cu);break;case 16205:if(0===h)break t;r[o++]=n.length,h--,n.mode=cu;break;case lu:if(n.wrap){for(;l<32;){if(0===s)break t;s--,c|=i[a++]<<l,l+=8}if(u-=h,t.total_out+=u,n.total+=u,4&n.wrap&&u&&(t.adler=n.check=n.flags?yf(n.check,r,u,o-u):bf(n.check,r,u,o-u)),u=h,4&n.wrap&&(n.flags?c:uu(c))!==n.check){t.msg="incorrect data check",n.mode=fu;break}c=0,l=0}n.mode=16207;case 16207:if(n.wrap&&n.flags){for(;l<32;){if(0===s)break t;s--,c+=i[a++]<<l,l+=8}if(4&n.wrap&&c!==(4294967295&n.total)){t.msg="incorrect length check",n.mode=fu;break}c=0,l=0}n.mode=16208;case 16208:k=1;break t;case fu:k=-3;break t;case 16210:return-4;default:return-2}return t.next_out=o,t.avail_out=h,t.next_in=a,t.avail_in=s,n.hold=c,n.bits=l,(n.wsize||u!==t.avail_out&&n.mode<fu&&(n.mode<lu||4!==e))&&((t,e,n,i)=>{let r;const a=t.state;null===a.window&&(a.window=new Uint8Array(1<<a.wbits)),0===a.wsize&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0),i>=a.wsize?(a.window.set(e.subarray(n-a.wsize,n),0),a.wnext=0,a.whave=a.wsize):(r=a.wsize-a.wnext,r>i&&(r=i),a.window.set(e.subarray(n-i,n-i+r),a.wnext),(i-=r)?(a.window.set(e.subarray(n-i,n),0),a.wnext=i,a.whave=a.wsize):(a.wnext+=r,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=r)))})(t,t.output,t.next_out,u-t.avail_out),f-=t.avail_in,u-=t.avail_out,t.total_in+=f,t.total_out+=u,n.total+=u,4&n.wrap&&u&&(t.adler=n.check=n.flags?yf(n.check,r,u,t.next_out-u):bf(n.check,r,u,t.next_out-u)),t.data_type=n.bits+(n.last?64:0)+(n.mode===au?128:0)+(n.mode===hu||n.mode===su?256:0),(0===f&&0===u||4===e)&&0===k&&(k=-5),k},_u=class{constructor(){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}},vu=Object.prototype.toString,xu={level:-1,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,raw:!1,gzip:!1,legacyHash:!1,dictionary:new Uint8Array(0)},ku=class{options;err;msg;ended;started;chunks;strm;result;constructor(t={}){this.options=Object.assign({},xu,t);const e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.started=!1,this.chunks=[],this.result=new Uint8Array(0),this.strm=new _u,this.strm.avail_out=0;let n=((t,e,n,i,r,a,o)=>{if(!t)return-2;let s=1;if(-1===e&&(e=6),i<0?(s=0,i=-i):i>15&&(s=2,i-=16),r<1||r>9||8!==n||i<8||i>15||e<0||e>9||a<0||a>4||8===i&&1!==s)return Ef(t,-2);8===i&&(i=9);const h=new Hf;return t.state=h,h.strm=t,h.status=kf,h.wrap=s,h.gzhead=null,h.w_bits=i,h.w_size=1<<h.w_bits,h.w_mask=h.w_size-1,h.legacy_hash=o?1:0,h.hash_bits=r+7,!h.legacy_hash&&h.hash_bits<15&&(h.hash_bits=15),h.hash_size=1<<h.hash_bits,h.hash_mask=h.hash_size-1,h.hash_shift=~~((h.hash_bits+3-1)/3),h.window=new Uint8Array(2*h.w_size),h.head=new Uint16Array(h.hash_size),h.prev=new Uint16Array(h.w_size),h.lit_bufsize=1<<r+6,h.pending_buf_size=4*h.lit_bufsize,h.pending_buf=new Uint8Array(h.pending_buf_size),h.sym_buf=h.lit_bufsize,h.sym_end=3*(h.lit_bufsize-1),h.level=e,h.strategy=a,h.method=n,qf(t)})(this.strm,e.level,8,e.windowBits,e.memLevel,e.strategy,e.legacyHash);if(0!==n)throw new Error(_f[n]);"[object ArrayBuffer]"===vu.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary));const i=e.dictionary;if(i.length){if(e.gzip)throw new Error("dictionary is not supported with gzip");if(n=((t,e)=>{let n=e.length;if(Zf(t))return-2;const i=t.state,r=i.wrap;if(2===r||1===r&&i.status!==kf||i.lookahead)return-2;if(1===r&&(t.adler=bf(t.adler,e,n,0)),i.wrap=0,n>=i.w_size){0===r&&(Sf(i.head),i.strstart=0,i.block_start=0,i.insert=0);let t=new Uint8Array(i.w_size);t.set(e.subarray(n-i.w_size,n),0),e=t,n=i.w_size}const a=t.avail_in,o=t.next_in,s=t.input;for(t.avail_in=n,t.next_in=0,t.input=e,Ff(i);i.lookahead>=3;){let t=i.strstart,e=i.lookahead-2;do{Cf(i,t),t++}while(--e);i.strstart=t,i.lookahead=2,Ff(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=2,i.match_available=0,t.next_in=o,t.input=s,t.avail_in=a,i.wrap=r,0})(this.strm,i),0!==n)throw new Error(_f[n])}}push(t,e=!1){const n=this.strm,i=this.options.chunkSize;let r,a;if(this.ended)return!1;for(a="number"==typeof e?e:!0===e?4:0,"string"==typeof t?n.input=(new TextEncoder).encode(t):"[object ArrayBuffer]"===vu.call(t)?n.input=new Uint8Array(t):n.input=t,n.next_in=0,n.avail_in=n.input.length,this.started||(this.started=!0,this.onStart(n));;)if(0===n.avail_out&&(n.output=new Uint8Array(i),n.next_out=0,n.avail_out=i),(2===a||3===a)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(r=Wf(n,a),-2===r)break;if(1===r){n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),r=Vf(this.strm);break}if(0!==n.avail_out){if(a>0&&n.next_out>0)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else if(0===n.avail_in)return!0}else this.onData(n.output)}return this.err=r,this.msg=n.msg||_f[r],this.ended=!0,this.onEnd(r),0===r}onStart(t){}onData(t){this.chunks.push(t)}onEnd(t){0===t&&(this.result=(t=>{const e=new Uint8Array(t.reduce((t,e)=>t+e.length,0));let n=0;for(const i of t)e.set(i,n),n+=i.length;return e})(this.chunks)),this.chunks=[]}};let Au;const Mu=function(t,e=0){const n=function(){if(!Au){Au=new Uint32Array(256);for(let t=0;t<256;t++){let e=t;for(let t=0;t<8;t++)e=1&e?3988292384^e>>>1:e>>>1;Au[t]=e}}return Au}();let i=~e;for(let e=0;e<t.length;e++)i=n[255&(i^t[e])]^i>>>8;return~i>>>0},Eu=function(t,e,n=e){const i=new _u;gu(i,-15),i.input=t,i.next_in=0,i.avail_in=t.length;let r=new Uint8Array(Math.max(Math.min(n,e),1));i.output=r,i.next_out=0,i.avail_out=r.length;try{for(;;){const t=yu(i,2);if(0!==t&&1!==t&&-5!==t)throw new Error(i.msg||`zlib error ${t}`);if(1===t||i.avail_out>0||r.length>=e)break;const n=new Uint8Array(Math.min(2*r.length,e));n.set(r),r=n,i.output=r,i.avail_out=r.length-i.next_out}}finally{(t=>{if(pu(t))return-2;let e=t.state;e.window&&(e.window=null),t.state=null})(i)}return i.next_out===r.length?r:r.subarray(0,i.next_out)};function Iu(t,e){const{level:n,strategy:i,windowBits:r,memLevel:a,chunkSize:o}=e;return function(t,e={}){const n=new ku(e);if(n.push(t,!0),n.err)throw new Error(n.msg);return n.result}(t,Object.fromEntries(Object.entries({level:n,strategy:i,windowBits:r,memLevel:a,chunkSize:o}).filter(([,t])=>void 0!==t)))}const Su=16777216;function zu(t,e){if(t.length<2)throw new Error("Invalid compressed data: too short");const n=t[0],i=t[1];if(8!=(15&n)||n>>4>7||(n<<8|i)%31!=0)throw new Error("Invalid compressed data: bad zlib header");if(32&i)throw new Error("Invalid compressed data: zlib preset dictionary");const r=Math.min(e,1032*t.length+1024);try{return Eu(t.subarray(2),e,r)}catch(t){throw new Error(`Invalid compressed data: ${t instanceof Error?t.message:String(t)}`,{cause:t})}}function Bu(t,e){return 16===e||"raw"===e?t:(t+128)/257|0}function Cu(t,e){const{colorType:n,depth:i}=t,r=t.transparentColor;if(n===wl.PALETTE&&"indexed"===e){const t=8/i,e=(1<<i)-1;return(n,r,a,o,s,h)=>{o>>=2,s>>=2;for(let c=0;c<h;c++,o+=s)a[o]=8===i?n[r+c]:n[r+Math.floor(c/t)]>>8-i-c%t*i&e}}if(n===wl.PALETTE){const n=new Uint16Array(1024);for(let i=0;i<256;i++){const r=t.palette?.[i]??[0,0,0,255],a=16===e?257:1;n[4*i]=r[0]*a,n[4*i+1]=r[1]*a,n[4*i+2]=r[2]*a,n[4*i+3]=r[3]*a}const r=8/i,a=(1<<i)-1;return(t,e,o,s,h,c)=>{for(let l=0;l<c;l++,s+=h){const h=4*(8===i?t[e+l]:t[e+Math.floor(l/r)]>>8-i-l%r*i&a);o[s]=n[h],o[s+1]=n[h+1],o[s+2]=n[h+2],o[s+3]=n[h+3]}}}if(16===i){const t=16===e||"raw"===e?65535:255;switch(n){case wl.GRAYSCALE:{const n=r?r[0]:-1;return(i,r,a,o,s,h)=>{for(let c=0,l=r;c<h;c++,l+=2,o+=s){const r=i[l]<<8|i[l+1],s=Bu(r,e);a[o]=s,a[o+1]=s,a[o+2]=s,a[o+3]=r===n?0:t}}}case wl.COLOR:{const[n=-1,i=-1,a=-1]=r??[];return(r,o,s,h,c,l)=>{for(let f=0,u=o;f<l;f++,u+=6,h+=c){const o=r[u]<<8|r[u+1],c=r[u+2]<<8|r[u+3],l=r[u+4]<<8|r[u+5];s[h]=Bu(o,e),s[h+1]=Bu(c,e),s[h+2]=Bu(l,e),s[h+3]=o===n&&c===i&&l===a?0:t}}}case wl.GRAYSCALE_ALPHA:return(t,n,i,r,a,o)=>{for(let s=0,h=n;s<o;s++,h+=4,r+=a){const n=Bu(t[h]<<8|t[h+1],e);i[r]=n,i[r+1]=n,i[r+2]=n,i[r+3]=Bu(t[h+2]<<8|t[h+3],e)}};default:return(t,n,i,r,a,o)=>{for(let s=0,h=n;s<o;s++,h+=8,r+=a)i[r]=Bu(t[h]<<8|t[h+1],e),i[r+1]=Bu(t[h+2]<<8|t[h+3],e),i[r+2]=Bu(t[h+4]<<8|t[h+5],e),i[r+3]=Bu(t[h+6]<<8|t[h+7],e)}}}const a=function(t,e){const n=(1<<t)-1,i=new Uint16Array(n+1);for(let t=0;t<=n;t++)i[t]="raw"===e?t:16===e?65535*t/n:Math.round(255*t/n);return i}(i,e),o=a[(1<<i)-1],s=16===e;switch(n){case wl.GRAYSCALE:{const t=r?r[0]:-1;if(8===i)return(e,n,i,r,s,h)=>{for(let c=0;c<h;c++,r+=s){const s=e[n+c],h=a[s];i[r]=h,i[r+1]=h,i[r+2]=h,i[r+3]=s===t?0:o}};const e=8/i,n=(1<<i)-1;return(r,s,h,c,l,f)=>{for(let u=0;u<f;u++,c+=l){const l=r[s+Math.floor(u/e)]>>8-i-u%e*i&n,f=a[l];h[c]=f,h[c+1]=f,h[c+2]=f,h[c+3]=l===t?0:o}}}case wl.COLOR:{const[t=-1,e=-1,n=-1]=r??[];return(i,r,s,h,c,l)=>{for(let f=0,u=r;f<l;f++,u+=3,h+=c){const r=i[u],c=i[u+1],l=i[u+2];s[h]=a[r],s[h+1]=a[c],s[h+2]=a[l],s[h+3]=r===t&&c===e&&l===n?0:o}}}case wl.GRAYSCALE_ALPHA:return(t,e,n,i,r,o)=>{for(let s=0,h=e;s<o;s++,h+=2,i+=r){const e=a[t[h]];n[i]=e,n[i+1]=e,n[i+2]=e,n[i+3]=a[t[h+1]]}};default:return(t,e,n,i,r,o)=>{if(4!==r||s)for(let s=0,h=e;s<o;s++,h+=4,i+=r)n[i]=a[t[h]],n[i+1]=a[t[h+1]],n[i+2]=a[t[h+2]],n[i+3]=a[t[h+3]];else n.set(t.subarray(e,e+4*o),i)}}}function Pu(t,e,n){const{width:i,height:r}=t,a=function(t){let e=0;for(const n of Bl(t.width,t.height,t.interlace))e+=(Cl(t,n.width)+1)*n.height;return e}(t),o=zu(function(t){if(1===t.length)return t[0];let e=0;for(const n of t)e+=n.length;const n=new Uint8Array(e);let i=0;for(const e of t)n.set(e,i),i+=e.length;return n}(e),a);if(o.length<a)throw new Error(`Not enough image data: expected ${a} bytes, got ${o.length}`);const s="indexed"===n&&t.colorType===wl.PALETTE?new Uint8Array(i*r):function(t,e,n){const i=t*e*4;try{if(i>2**32)throw new RangeError;return n?new Uint16Array(i):new Uint8Array(i)}catch{throw new Error(`Image is too large to decode: ${t}x${e} pixels`)}}(i,r,16===n||"raw"===n&&16===t.depth),h=Cu(t,n),c=Pl(t);let l=0;for(const e of Bl(i,r,t.interlace)){const n=Cl(t,e.width);Il(o,l,n,e.height,c);for(let t=0;t<e.height;t++)h(o,l+1,s,4*((e.y+t*e.yStep)*i+e.x),4*e.xStep,e.width),l+=n+1}return s}function Tu(t){let e="";for(let n=0;n<t.length;n+=8192)e+=String.fromCharCode(...t.subarray(n,n+8192));return e}function Uu(t){const e=new Uint8Array(t.length);for(let n=0;n<t.length;n++){const i=t.charCodeAt(n);if(i>255)return;e[n]=i}return e}const Ou=new TextDecoder,Lu=new TextEncoder;function Ru(t){return Ou.decode(t)}function Fu(t){return Lu.encode(t)}function Du(t,e){return 16777216*t[e]+(t[e+1]<<16|t[e+2]<<8|t[e+3])}function Nu(t,e){return t[e]<<8|t[e+1]}function $u(t,e){return String.fromCharCode(t[e],t[e+1],t[e+2],t[e+3])}function ju(t){return t>=65&&t<=90||t>=97&&t<=122}function Gu(t){if(t.length<bl.length)return!1;for(let e=0;e<bl.length;e++)if(t[e]!==bl[e])return!1;return!0}function Hu(t){if(13!==t.length)throw new Error(`Invalid IHDR chunk: length ${t.length}, expected 13`);const e=Du(t,0),n=Du(t,4),i=t[8],r=t[9],a=t[10],o=t[11],s=t[12];if(0===e||0===n)throw new Error(`Invalid image size ${e}x${n}`);if(e>Ml||n>Ml)throw new Error(`Invalid image size ${e}x${n}: too large`);if(!(r in kl))throw new Error(`Unsupported color type ${r}`);if(!xl[r].includes(i))throw new Error(`Unsupported bit depth ${i} for color type ${r}`);if(0!==a)throw new Error(`Unsupported compression method ${a}`);if(0!==o)throw new Error(`Unsupported filter method ${o}`);if(0!==s&&1!==s)throw new Error(`Unsupported interlace method ${s}`);return{width:e,height:n,depth:i,colorType:r,interlace:1===s}}function Zu(t){const e=t.indexOf(0);if(e<1||e>79)throw new Error("Invalid keyword");return{keyword:Tu(t.subarray(0,e)),rest:e+1}}function qu(t,e){if(26!==t.length)throw new Error("Invalid fcTL chunk");const n={width:Du(t,4),height:Du(t,8),x:Du(t,12),y:Du(t,16),delay:0,dispose:t[24],blend:t[25]},i=Nu(t,20),r=Nu(t,22)||100;if(n.delay=i/r*1e3,0===n.width||0===n.height||n.x+n.width>e.width||n.y+n.height>e.height||n.dispose>2||n.blend>1)throw new Error("Invalid APNG frame");return n}function Wu(t,e,n,i){const{colorType:r}=n.header;switch(t){case"tRNS":if(i||n.trns)return;return void(r===wl.PALETTE?n.plte&&(n.trns=e.subarray(0,n.plte.length/3)):r===wl.GRAYSCALE&&2===e.length?(n.trns=e,n.transparentColor=[Nu(e,0)]):r===wl.COLOR&&6===e.length&&(n.trns=e,n.transparentColor=[Nu(e,0),Nu(e,2),Nu(e,4)]));case"gAMA":{const t=4===e.length?Du(e,0):0;return void(t>0&&void 0===n.gamma&&(n.gamma=t/Al))}case"sRGB":return void(1===e.length&&e[0]<=3&&(n.srgb=e[0]));case"iCCP":return void(n.iccProfile||(n.iccProfile=function(t){const{keyword:e,rest:n}=Zu(t);if(0!==t[n])throw new Error("Unknown compression method");return{name:e,data:zu(t.subarray(n+1),Su)}}(e)));case"pHYs":return void(9===e.length&&e[8]<=1&&(n.physical={x:Du(e,0),y:Du(e,4),unit:1===e[8]?"meter":"unknown"}));case"tEXt":case"zTXt":case"iTXt":return void n.text.push(function(t,e){const{keyword:n,rest:i}=Zu(e);if("tEXt"===t)return{keyword:n,text:Tu(e.subarray(i))};if("zTXt"===t){if(0!==e[i])throw new Error("Unknown compression method");return{keyword:n,text:Tu(zu(e.subarray(i+1),Su)),compressed:!0}}const r=1===e[i];if(r&&0!==e[i+1])throw new Error("Unknown compression method");const a=e.indexOf(0,i+2),o=a<0?-1:e.indexOf(0,a+1);if(i+2>e.length||a<0||o<0)throw new Error("Invalid iTXt chunk");const s=e.subarray(o+1);return{keyword:n,text:Ru(r?zu(s,Su):s),compressed:r,language:Tu(e.subarray(i+2,a)),translatedKeyword:Ru(e.subarray(a+1,o))}}(t,e));case"eXIf":return void(n.exif||(n.exif=e.slice()))}}function Vu(t,e){if(!Gu(t))throw new Error("Invalid file signature: not a PNG file");let n,i,r=!1,a=bl.length;for(;;){const o=t=>{if(n&&r||e.headersOnly)return!0;throw new Error(t)};if(a===t.length&&o("Unexpected end of file: no image data"))break;if(a+12>t.length&&o("Unexpected end of file"))break;const s=Du(t,a),h=a+4,c=$u(t,h);if(!(ju(t[h])&&ju(t[h+1])&&ju(t[h+2])&&ju(t[h+3]))&&o("Invalid chunk type"))break;if(e.headersOnly&&n&&"IDAT"===c){r=!0;break}if((s>Ml||h+8+s>t.length)&&o(`Unexpected end of file in ${c} chunk`))break;const l=h+4,f=l+s,u=t.subarray(l,f),d=!(32&t[h]);if(a=f+4,e.checkCRC){if(Mu(t.subarray(h,f))!==Du(t,f)){if(d)throw new Error(`CRC error in ${c} chunk`);continue}}if(n)if("IDAT"!==c){if("IEND"===c)break;switch(c){case"IHDR":throw new Error("Duplicate IHDR chunk");case"PLTE":{if(n.plte||r)continue;const t=n.header.colorType===wl.PALETTE,e=s/3;if(s%3!=0||e<1||e>256){if(t)throw new Error(`Invalid palette with ${s} bytes`);continue}t&&(n.plte=u.subarray(0,3*Math.min(e,2**n.header.depth)));continue}case"acTL":e.frames&&8===u.length&&!r&&(n.animation={frames:Du(u,0),loops:Du(u,4)});continue;case"fcTL":if(e.frames&&n.animation){try{i={control:qu(u,n.header),data:[]}}catch{n.animation=void 0,n.frames=[],i=void 0;continue}if(!r&&(i.control.width!==n.header.width||i.control.height!==n.header.height||0!==i.control.x||0!==i.control.y)){n.animation=void 0,i=void 0;continue}n.frames.push(i)}continue;case"fdAT":e.frames&&i&&r&&s>4&&i.data.push(u.subarray(4));continue}if(d)throw new Error(`Unsupported critical chunk ${c}`);try{Wu(c,u,n,r)}catch{}}else r=!0,n.idat.push(u),i&&1===n.frames.length&&n.frames[0]===i&&(i.data.push(u),n.idatIsFrame=!0);else{if("IHDR"!==c)throw new Error(`IHDR must be the first chunk, found ${c}`);n={header:Hu(u),text:[],idat:[],frames:[],idatIsFrame:!1}}}if(!e.headersOnly||n&&r){if(!n)throw new Error("Unexpected end of file: no IHDR chunk");if(!r)throw new Error("No image data: the file has no IDAT chunk");if(n.header.colorType===wl.PALETTE){if(!n.plte)throw new Error("Missing palette: palette images need a PLTE chunk");const{plte:t,trns:e}=n,i=[];for(let n=0;n<t.length/3;n++)i.push([t[3*n],t[3*n+1],t[3*n+2],e&&n<e.length?e[n]:255]);n.palette=i}return n}}function Ju(t){return{...t.header,palette:t.palette,transparentColor:t.transparentColor,gamma:t.gamma,srgb:t.srgb,iccProfile:t.iccProfile,physical:t.physical,text:t.text,exif:t.exif}}function Yu(t,e={}){return function(t,e,{checkCRC:n=!0}){const i=Vu(gl(t),{checkCRC:n}),r=Pu({...i.header,palette:i.palette,transparentColor:i.transparentColor},i.idat,e);return{...Ju(i),data:(Uint8Array,r)}}(t,16===e.outputDepth?16:8,e)}function Xu(t){const e=gl(t);if(!Gu(e))throw new Error("Invalid file signature: not a PNG file");if(e.length<33||"IHDR"!==function(t,e){return String.fromCharCode(...t.subarray(e,e+4))}(e,12))throw new Error("IHDR must be the first chunk");return Hu(e.subarray(16,29))}function Ku(t){const{data:e,depth:n}=t,i=t.width*t.height*4;let r=!0,a=!0,o=8===n,s=7,h=new Map,c=-1;const l=16===n?65535:255;if(16===n){o=!0;for(let t=0;t<i;t++)if(e[t]%257!=0){o=!1;break}}const f=16===n?8:0;16!==n||o||(h=void 0);for(let t=0;t<i;t+=4){const i=e[t],o=e[t+1],u=e[t+2],d=e[t+3];if(d!==l&&(a=!1),r&&(i!==o||i!==u?r=!1:s&&8===n&&(i%17!=0?s=0:i%85!=0?s&=4:0!==i&&255!==i&&(s&=6))),h){const t=(i>>f<<24|o>>f<<16|u>>f<<8|d>>f)>>>0;t!==c&&(c=t,h.has(t)||(256===h.size?h=void 0:h.set(t,h.size)))}if(!r&&!a&&!h)break}let u=16!==n||o?8:16;return(8===n||o)&&(1&s?u=1:2&s?u=2:4&s&&(u=4)),16===n&&o&&r&&(u=function(t,e){let n=7;for(let i=0;i<e&&n;i+=4){const e=t[i]/257;e%17!=0?n=0:e%85!=0?n&=4:0!==e&&255!==e&&(n&=6)}return 1&n?1:2&n?2:4&n?4:8}(e,i)),{gray:r,opaque:a,fits8:o,grayDepth:u,colors:h}}function Qu(t,e,n,i){const{gray:r,opaque:a,colors:o}=e,s=16===t.depth&&!e.fits8;if(void 0===n){const t=r?a?wl.GRAYSCALE:wl.GRAYSCALE_ALPHA:a?wl.COLOR:wl.COLOR_ALPHA;if(16===i||s)n=t;else if(r&&a&&e.grayDepth<=(i??8))n=wl.GRAYSCALE;else if(o&&o.size<=2**(i??8))n=wl.PALETTE;else{if(void 0!==i&&8!==i)throw new Error(`The image can't be stored with a bit depth of ${i} without loss. Set colorType to convert it.`);n=t}}if(void 0===i)if(n===wl.PALETTE){if(!o)throw new Error("The image has more than 256 colors, so it can't be written as a palette image");i=(h=o.size)<=2?1:h<=4?2:h<=16?4:8}else i=s?16:n===wl.GRAYSCALE&&r&&a?e.grayDepth:8;var h;if(!xl[n]?.includes(i))throw new Error(`Bit depth ${i} isn't allowed for color type ${n}`);if(n===wl.PALETTE&&(!o||o.size>2**i))throw new Error(`The image has more than ${2**i} colors, so it can't be written as a palette image with a bit depth of ${i}`);return{colorType:n,depth:i}}function td(t){const e=[...t.keys()],n=[...e.filter(t=>!!(255&~t)),...e.filter(t=>!(255&~t))],i=new Uint8Array(3*n.length),r=[],a=new Map;return n.forEach((t,e)=>{i[3*e]=t>>>24,i[3*e+1]=t>>>16&255,i[3*e+2]=t>>>8&255,255&~t&&r.push(255&t),a.set(t,e)}),{plte:i,trns:r.length?new Uint8Array(r):void 0,indices:a}}function ed(t,e,n){return Math.round((t+e+n)/3)}function nd(t,e,n,i){const{data:r,width:a}=t,{colorType:o,depth:s}=e,h=Cl(e,n.width),c=4*n.xStep;if(o===wl.COLOR_ALPHA&&8===s&&8===t.depth&&1===n.xStep&&1===n.yStep)return r.subarray(0,h*n.height);const l=new Uint8Array(h*n.height),f=16===s?16:8,u=16===f?65535:255,d=t.depth===f?void 0:8===t.depth?t=>257*t:t=>(t+128)/257|0,p=i.background,m=o===wl.COLOR_ALPHA||o===wl.GRAYSCALE_ALPHA,g=i.toGray??ed,b=i.palette?.indices,w=(1<<s)-1;let y=0;for(let e=0;e<n.height;e++){let i=4*((n.y+e*n.yStep)*a+n.x),h=0,f=0;for(let e=0;e<n.width;e++,i+=c){if(b){const e=16===t.depth?8:0,n=(r[i]>>e<<24|r[i+1]>>e<<16|r[i+2]>>e<<8|r[i+3]>>e)>>>0,a=b.get(n);if(void 0===a)throw new Error("The palette doesn't have every color of the image");8===s?l[y++]=a:(h=h<<s|a,f+=s,8===f&&(l[y++]=h,h=0,f=0));continue}let e=r[i],n=r[i+1],a=r[i+2],c=r[i+3];if(d&&(e=d(e),n=d(n),a=d(a),c=d(c)),!m&&c!==u){const t=c/u;e=Math.round((1-t)*p.red+t*e),n=Math.round((1-t)*p.green+t*n),a=Math.round((1-t)*p.blue+t*a)}switch(o){case wl.GRAYSCALE:case wl.GRAYSCALE_ALPHA:{let t=e===n&&e===a?e:g(e,n,a);t<0?t=0:t>u&&(t=u),s<8?(h=h<<s|Math.round(t*w/255),f+=s,8===f&&(l[y++]=h,h=0,f=0)):8===s?(l[y++]=t,m&&(l[y++]=c)):(l[y++]=t>>8,l[y++]=255&t,m&&(l[y++]=c>>8,l[y++]=255&c));break}default:8===s?(l[y++]=e,l[y++]=n,l[y++]=a,m&&(l[y++]=c)):(l[y++]=e>>8,l[y++]=255&e,l[y++]=n>>8,l[y++]=255&n,l[y++]=a>>8,l[y++]=255&a,m&&(l[y++]=c>>8,l[y++]=255&c))}}f>0&&(l[y++]=h<<8-f)}return l}const id=[0,1,2,3,4];function rd(t,e,n){t[e]=n>>>24,t[e+1]=n>>>16&255,t[e+2]=n>>>8&255,t[e+3]=255&n}function ad(t,e){const n=e?.length??0,i=new Uint8Array(n+12);rd(i,0,n);for(let e=0;e<4;e++)i[4+e]=t.charCodeAt(e);return e&&i.set(e,8),rd(i,n+8,Mu(i.subarray(4,n+8))),i}function od(t){let e=0;for(const n of t)e+=n.length;const n=new Uint8Array(e);let i=0;for(const e of t)n.set(e,i),i+=e.length;return n}function sd(t){const e=Uu(t);if(!e||e.length<1||e.length>79||e.includes(0))throw new Error(`Invalid keyword "${t}": it must be 1-79 Latin-1 characters`);return e}function hd(t,e){try{return Iu(t,{level:e.deflateLevel??9,strategy:e.deflateStrategy??3,chunkSize:e.deflateChunkSize})}catch(t){throw new Error(`Compression failed: ${t instanceof Error?t.message:String(t)}`,{cause:t})}}function cd(t,e){const n=sd(t.keyword),i=Uu(t.text);if(!(!i||void 0!==t.language||void 0!==t.translatedKeyword))return t.compressed?ad("zTXt",od([n,new Uint8Array([0,0]),hd(i,e)])):ad("tEXt",od([n,new Uint8Array([0]),i]));const r=Fu(t.text);return ad("iTXt",od([n,new Uint8Array([0,t.compressed?1:0,0]),Uu(t.language??"")??new Uint8Array,new Uint8Array([0]),Fu(t.translatedKeyword??""),new Uint8Array([0]),t.compressed?hd(r,e):r]))}function ld(t,e){const n=[];if(t.gamma){const e=new Uint8Array(4);rd(e,0,Math.round(t.gamma*Al)),n.push(ad("gAMA",e))}return void 0!==t.srgb&&n.push(ad("sRGB",new Uint8Array([t.srgb]))),t.iccProfile&&n.push(ad("iCCP",od([sd(t.iccProfile.name),new Uint8Array([0,0]),hd(t.iccProfile.data,e)]))),n}function fd(t,e,n,i,r){const{width:a,height:o}=e,s=function(t,e){if(void 0===t)return e.colorType===wl.PALETTE||e.depth<8?[0]:id;const n=Array.isArray(t)?t:-1===t?id:[t];if(0===n.length||n.some(t=>!Number.isInteger(t)||t<0||t>4))throw new Error(`Invalid filterType ${JSON.stringify(t)}: use -1 or filter types 0-4`);return n}(r.filterType,e),h=Pl(e),c=Bl(a,o,e.interlace);let l=0;for(const t of c)l+=(Cl(e,t.width)+1)*t.height;const f=new Uint8Array(l);let u=0;for(const i of c){const r=Cl(e,i.width);Sl(nd(t,e,i,n),0,r,i.height,h,s,f,u),u+=(r+1)*i.height}const d=new Uint8Array(13);rd(d,0,a),rd(d,4,o),d[8]=e.depth,d[9]=e.colorType,d[12]=e.interlace?1:0;const p=[bl,ad("IHDR",d),...ld(i,r)];return n.palette&&(p.push(ad("PLTE",n.palette.plte)),n.palette.trns&&p.push(ad("tRNS",n.palette.trns))),p.push(...function(t,e){const n=[];if(t.physical){const e=new Uint8Array(9);rd(e,0,t.physical.x),rd(e,4,t.physical.y),e[8]="meter"===t.physical.unit?1:0,n.push(ad("pHYs",e))}t.exif&&n.push(ad("eXIf",t.exif));for(const i of t.text??[])n.push(cd(i,e));return n}(i,r)),{head:p,filtered:f}}function ud(t,e){const n=Math.min(e&&e>0?Math.ceil(e):1/0,Ml),i=[];for(let e=0;e<t.length;e+=n)i.push(ad("IDAT",t.subarray(e,e+n)));return i}function dd(t,e,n,i,r){const{head:a,filtered:o}=fd(t,e,n,i,r);return od([...a,...ud(hd(o,r),r.idatChunkSize),ad("IEND")])}function pd(t){const{width:e,height:n,data:i}=t;if(!Number.isInteger(e)||!Number.isInteger(n)||e<1||n<1||e>Ml||n>Ml)throw new Error(`Invalid image size ${e}x${n}`);if(!i||i.length<e*n*4)throw new Error(`Not enough pixel data: a ${e}x${n} image needs ${e*n*4} RGBA samples, got ${i?.length??0}`)}function md(t,e,n,i,r,a,o,s,h){for(let c=0;c<s;c++){const s=4*((a+c)*(h?i:e)+r),l=c*o*4;h?n.set(t.subarray(l,l+4*o),s):n.set(t.subarray(s,s+4*o),l)}}function gd(t,e,n,i,r){for(let a=0;a<i.height;a++){let o=a*i.width*4,s=4*((i.y+a)*n+i.x);for(let n=0;n<i.width;n++,o+=4,s+=4){const n=t[o+3];if(n===r)e[s]=t[o],e[s+1]=t[o+1],e[s+2]=t[o+2],e[s+3]=r;else if(n>0){const i=e[s+3]*(r-n)/r,a=n+i;e[s]=Math.round((t[o]*n+e[s]*i)/a),e[s+1]=Math.round((t[o+1]*n+e[s+1]*i)/a),e[s+2]=Math.round((t[o+2]*n+e[s+2]*i)/a),e[s+3]=Math.round(a)}}}}function bd(t,e=2.2){if(!t.gamma)return;const{data:n}=t,i=n instanceof Uint16Array?65535:255,r=1/e/t.gamma,a=new(255===i?Uint8Array:Uint16Array)(i+1);for(let t=0;t<=i;t++)a[t]=Math.round(Math.pow(t/i,r)*i);const o=Math.min(n.length,t.width*t.height*4);for(let t=0;t<o;t+=4)n[t]=a[n[t]],n[t+1]=a[n[t+1]],n[t+2]=a[n[t+2]];t.gamma=0}function wd(t,e){const{colorType:n}=t;return{width:t.width,height:t.height,depth:t.depth,interlace:t.interlace,palette:n===wl.PALETTE,color:!!(2&n),alpha:!!(4&n)||e,bpp:kl[n],colorType:n}}function yd(t,e={}){const n=Vu("string"==typeof t?(new TextEncoder).encode(t):gl(t),{checkCRC:!1!==e.checkCRC}),i=e.keepIndexed&&n.header.colorType===wl.PALETTE,r=Pu({...n.header,palette:n.palette,transparentColor:n.transparentColor},n.idat,i?"indexed":e.skipRescale?"raw":8);return{...Ju(n),...wd(n.header,void 0!==n.trns),data:(Uint8Array,r),gamma:n.gamma??0,palette:n.palette??!1,transColor:n.transparentColor}}const _d=[0,2,4,6],vd=[0,2,3,4,6];function xd(t,e,n,i){const{width:r,height:a}=t,o=i?function(t){return t instanceof Uint16Array?t:t.byteOffset%2==0?new Uint16Array(t.buffer,t.byteOffset,t.byteLength>>1):new Uint16Array(t.slice().buffer,0,t.byteLength>>1)}(t.data):t.data,s=i?65535:255;let h=kl[e];if(6!==e||n||(h=3),o.length<r*a*h)throw new Error(`Not enough pixel data: a ${r}x${a} image needs ${r*a*h} samples, got ${o.length}`);if(4===h)return{width:r,height:a,data:o,depth:i?16:8};const c=r*a,l=i?new Uint16Array(4*c):new Uint8Array(4*c);for(let t=0,e=0,n=0;t<c;t++,e+=h,n+=4)switch(h){case 1:l[n]=l[n+1]=l[n+2]=o[e],l[n+3]=s;break;case 2:l[n]=l[n+1]=l[n+2]=o[e],l[n+3]=o[e+1];break;default:l[n]=o[e],l[n+1]=o[e+1],l[n+2]=o[e+2],l[n+3]=s}return{width:r,height:a,data:l,depth:i?16:8}}function kd(t,e={}){const{colorType:n=6,inputColorType:i=6,inputHasAlpha:r=!0,bitDepth:a=8}=e;if(!vd.includes(n))throw new Error(`option color type:${n} is not supported at present`);if(!_d.includes(i))throw new Error(`option input color type:${i} is not supported at present`);if(![1,2,4,8,16].includes(a))throw new Error(`option bit depth:${a} is not supported at present`);const o=16===a,s=xd(t,i,r,o);pd(s);let h,c=a;if(n===wl.PALETTE){const t=Ku(s);c=Qu(s,t,n,e.bitDepth).depth,h=td(t.colors)}else if(!xl[n].includes(a))throw new Error(`option bit depth:${a} is not supported for color type ${n}`);const l=o?65535:255,f=e.bgColor??{};return{source:s,header:{width:t.width,height:t.height,depth:c,colorType:n,interlace:!1},pack:{background:{red:f.red??l,green:f.green??l,blue:f.blue??l},palette:h},metadata:{gamma:t.gamma||void 0}}}function Ad(t,e={}){const{source:n,header:i,pack:r,metadata:a}=kd(t,e);return dd(n,i,r,a,e)}var Md,Ed=t=>{throw TypeError(t)},Id=(t,e,n)=>(((t,e,n)=>{e.has(t)||Ed("Cannot "+n)})(t,e,"read from private field"),n?n.call(t):e.get(t));class Sd{constructor(){var t,e,n;t=this,e=Md,n=new Map,e.has(t)?Ed("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n)}on(t,e){const n=Id(this,Md).get(t)??[];return n.push(e),Id(this,Md).set(t,n),this}addListener(t,e){return this.on(t,e)}once(t,e){const n=(...i)=>{this.removeListener(t,n),e.apply(this,i)};return n.listener=e,this.on(t,n)}removeListener(t,e){const n=Id(this,Md).get(t);if(n){const t=n.findIndex(t=>t===e||t.listener===e);t>=0&&n.splice(t,1)}return this}off(t,e){return this.removeListener(t,e)}removeAllListeners(t){return void 0===t?Id(this,Md).clear():Id(this,Md).delete(t),this}listeners(t){return[...Id(this,Md).get(t)??[]]}listenerCount(t){return Id(this,Md).get(t)?.length??0}emit(t,...e){const n=Id(this,Md).get(t);if(!n?.length){if("error"===t)throw e[0]instanceof Error?e[0]:new Error(String(e[0]));return!1}for(const t of[...n])t.apply(this,e);return!0}pipe(t){return this.on("data",e=>t.write(e)),this.on("end",()=>t.end()),t}}Md=new WeakMap;var zd,Bd,Cd,Pd,Td,Ud,Od,Ld,Rd,Fd,Dd,Nd,$d=Object.defineProperty,jd=t=>{throw TypeError(t)},Gd=(t,e,n)=>((t,e,n)=>e in t?$d(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n)(t,"symbol"!=typeof e?e+"":e,n),Hd=(t,e,n)=>e.has(t)||jd("Cannot "+n),Zd=(t,e,n)=>(Hd(t,e,"read from private field"),e.get(t)),qd=(t,e,n)=>e.has(t)?jd("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),Wd=(t,e,n,i)=>(Hd(t,e,"write to private field"),e.set(t,n),n),Vd=(t,e,n)=>(Hd(t,e,"access private method"),n);function Jd(t,e){if(1===t.length)return t[0];const n=new Uint8Array(e);let i=0;for(const e of t)n.set(e,i),i+=e.length;return n}function Yd(t){return t instanceof Error?t:new Error(String(t))}const Xd=class t extends Sd{constructor(t={}){super(),qd(this,Ud),Gd(this,"width"),Gd(this,"height"),Gd(this,"data"),Gd(this,"gamma",0),Gd(this,"readable",!0),Gd(this,"writable",!0),Gd(this,"palette"),Gd(this,"transColor"),Gd(this,"iccProfile"),Gd(this,"physical"),Gd(this,"text"),qd(this,zd),qd(this,Bd,[]),qd(this,Cd,0),qd(this,Pd,!1),qd(this,Td,!1),Wd(this,zd,t),this.width=0|(t.width??0),this.height=0|(t.height??0);const e=16===t.bitDepth?8:4;this.data=this.width>0&&this.height>0?new Uint8Array(e*this.width*this.height):null}static bitblt(t,e,n=0,i=0,r=0,a=0,o=0,s=0){if(i|=0,r|=0,a|=0,o|=0,s|=0,(n|=0)<0||i<0||r<0||a<0||n+r>t.width||i+a>t.height)throw new Error("bitblt reading outside image");if(o<0||s<0||o+r>e.width||s+a>e.height)throw new Error("bitblt writing outside image");for(let h=0;h<a;h++){const a=4*((i+h)*t.width+n);e.data.set(t.data.subarray(a,a+4*r),4*((s+h)*e.width+o))}}static adjustGamma(t,e){bd(t,e)}on(t,e){return super.on(t,e)}parse(t,e){if(e){const t=()=>{this.removeListener("error",n),e(null,this)},n=n=>{this.removeListener("parsed",t),e(n,null)};this.once("parsed",t),this.once("error",n)}return this.end(t),this}write(t){if(!this.writable)return Vd(this,Ud,Od).call(this,"error",new Error("Stream not writable")),!1;if(Zd(this,Td))return!0;const e="string"==typeof t?(new TextEncoder).encode(t):gl(t);return Zd(this,Bd).push(e),Wd(this,Cd,Zd(this,Cd)+e.length),Vd(this,Ud,Rd).call(this),!0}end(t){return null!=t&&this.write(t),this.writable?(this.writable=!1,queueMicrotask(()=>Vd(this,Ud,Dd).call(this)),this):this}pack(){return this.data&&this.data.length?(queueMicrotask(()=>Vd(this,Ud,Nd).call(this)),this):(this.emit("error",new Error("No data provided")),this)}bitblt(e,n,i,r,a,o,s){return t.bitblt(this,e,n,i,r,a,o,s),this}adjustGamma(t){bd(this,t)}async*[Symbol.asyncIterator](){const t=[];let e,n,i=!1;const r=()=>{n?.(),n=void 0},a=e=>{t.push(e),r()},o=()=>{i=!0,r()},s=t=>{e=t,r()};this.on("data",a),this.on("end",o),this.on("error",s);try{for(;;)if(t.length)yield t.shift();else{if(e)throw e;if(i)return;await new Promise(t=>{n=t})}}finally{this.removeListener("data",a),this.removeListener("end",o),this.removeListener("error",s)}}};zd=new WeakMap,Bd=new WeakMap,Cd=new WeakMap,Pd=new WeakMap,Td=new WeakMap,Ud=new WeakSet,Od=function(t,...e){queueMicrotask(()=>this.emit(t,...e))},Ld=function(t){Wd(this,Td,!0),Wd(this,Bd,[]),Vd(this,Ud,Od).call(this,"error",Yd(t)),Vd(this,Ud,Od).call(this,"close")},Rd=function(){if(Zd(this,Pd)||Zd(this,Cd)>4194304)return;const t=Jd(Zd(this,Bd),Zd(this,Cd));Wd(this,Bd,[t]);try{const e=Vu(t,{checkCRC:!1!==Zd(this,zd).checkCRC,headersOnly:!0});e&&Vd(this,Ud,Fd).call(this,wd(e.header,void 0!==e.trns))}catch(t){Vd(this,Ud,Ld).call(this,t)}},Fd=function(t){Wd(this,Pd,!0),this.width=t.width,this.height=t.height,Vd(this,Ud,Od).call(this,"metadata",t)},Dd=function(){if(Zd(this,Td))return;const t=Jd(Zd(this,Bd),Zd(this,Cd));let e;Wd(this,Bd,[]),Wd(this,Cd,0);try{e=yd(t,Zd(this,zd))}catch(t){return Wd(this,Td,!0),this.emit("error",Yd(t)),void this.emit("close")}Zd(this,Pd)||(Wd(this,Pd,!0),this.emit("metadata",wd(e,e.alpha))),this.width=e.width,this.height=e.height,this.gamma=e.gamma,this.data=e.data,this.palette=e.palette||void 0,this.transColor=e.transColor,this.iccProfile=e.iccProfile,this.physical=e.physical,this.text=e.text,this.emit("parsed",e.data),this.emit("finish"),this.emit("close")},Nd=function(){const t=Zd(this,zd);try{if(!t.deflateFactory)return this.emit("data",Ad(this,t)),void this.emit("end");const{source:e,header:n,pack:i,metadata:r}=kd(this,t),{head:a,filtered:o}=fd(e,n,i,r,t),s=t.deflateFactory({chunkSize:t.deflateChunkSize??32768,level:t.deflateLevel??9,strategy:t.deflateStrategy??3});for(const t of a)this.emit("data",ml(t));s.on("error",t=>this.emit("error",t)),s.on("data",e=>{for(const n of ud(e,t.idatChunkSize))this.emit("data",ml(n))}),s.on("end",()=>{this.emit("data",ad("IEND")),this.emit("end")}),s.end(o)}catch(t){this.emit("error",Yd(t))}},Gd(Xd,"sync",{read:yd,write:Ad});let Kd=Xd;var Qd,tp,ep,np,ip,rp;function ap(t,e){if(void 0===e)return;const{width:n,height:i}=Xu(t);if(n*i>1e6*e)throw new Error(`PNG dimensions ${n}x${i} exceed the maximum resolution of ${e} megapixels`)}function op(t){return n.Buffer.isBuffer(t)?t:n.Buffer.from(t.buffer,t.byteOffset,t.byteLength)}function sp(t){return 0===t?0:1===t?null:t-1}function hp(){return{mime:"image/png",hasAlpha:!0,detect:t=>{try{return Xu(t),!0}catch{return!1}},encode:(t,{deflateLevel:e=9,deflateStrategy:n=3,filterType:i,colorType:r,inputColorType:a,inputHasAlpha:o,bitDepth:s,bgColor:h}={})=>{if(void 0!==a){const o=new Kd({width:t.width,height:t.height});return o.data=t.data,Kd.sync.write(o,{inputColorType:a,bitDepth:s,bgColor:h,deflateLevel:e,deflateStrategy:n,filterType:i,colorType:r??ep.COLOR_ALPHA,inputHasAlpha:!0})}return op(function(t,e={}){pd(t);const n={width:t.width,height:t.height,data:t.data,depth:t.data instanceof Uint16Array?16:8},i=Ku(n),{colorType:r,depth:a}=Qu(n,i,e.colorType,e.bitDepth),o=16===a?65535:255;let s;return r===wl.PALETTE&&(s=td(i.colors)),dd(n,{width:t.width,height:t.height,depth:a,colorType:r,interlace:e.interlace??!1},{background:e.background??{red:o,green:o,blue:o},palette:s},e,e)}(t,{deflateLevel:e,deflateStrategy:n,filterType:i,colorType:r??(!1===o?ep.COLOR:void 0),bitDepth:s,background:h}))},decode:(t,e)=>{ap(t,e?.maxResolutionInMP);const n=Yu(t,{checkCRC:e?.checkCRC});return{data:op(n.data),width:n.width,height:n.height}},decodeFrames:(t,e,{maxFrames:n=1/0}={})=>{ap(t,e?.maxResolutionInMP);const{width:i,height:r,frames:a,plays:o}=function(t,{checkCRC:e=!0,outputDepth:n=8,maxFrames:i=1/0}={}){const r=Vu(gl(t),{checkCRC:e,frames:!0}),a=16===n?16:8,o={...r.header,palette:r.palette,transparentColor:r.transparentColor},s=t=>(Uint8Array,t);if(!r.animation||0===r.frames.length)return{...r.header,frames:[{data:s(Pu(o,r.idat,a)),delay:0}]};const{width:h,height:c}=r.header,l=16===a?65535:255,f=16===a?new Uint16Array(h*c*4):new Uint8Array(h*c*4),u=[];for(const[t,e]of r.frames.entries()){if(u.length>=i)break;const{control:n}=e;let r;try{r=Pu({...o,width:n.width,height:n.height},e.data,a)}catch(e){if(0===t)throw e;break}const c=0===t&&2===n.dispose?1:n.dispose;let d;2===c&&(d=f.slice(0,n.width*n.height*4),md(f,h,d,n.width,n.x,n.y,n.width,n.height,!1)),1===n.blend?gd(r,f,h,n,l):md(r,n.width,f,h,n.x,n.y,n.width,n.height,!0),u.push({data:s(f.slice()),delay:n.delay}),1===c?md(new Uint8Array(n.width*n.height*4),n.width,f,h,n.x,n.y,n.width,n.height,!0):d&&md(d,n.width,f,h,n.x,n.y,n.width,n.height,!0)}return{...r.header,frames:u,plays:r.animation.loops}}(t,{checkCRC:e?.checkCRC,maxFrames:n});return void 0===o?{frames:[{bitmap:{data:op(a[0].data),width:i,height:r}}]}:{frames:a.map(t=>({bitmap:{data:op(t.data),width:i,height:r},delay:t.delay})),loop:sp(o)}}}}function cp(t,e,n,i,r,a,o){this.widthOriginal=Math.abs(Math.floor(t)||0),this.heightOriginal=Math.abs(Math.floor(e)||0),this.targetWidth=Math.abs(Math.floor(n)||0),this.targetHeight=Math.abs(Math.floor(i)||0),this.colorChannels=r?4:3,this.interpolationPass=Boolean(a),this.resizeCallback="function"==typeof o?o:function(){},this.targetWidthMultipliedByChannels=this.targetWidth*this.colorChannels,this.originalWidthMultipliedByChannels=this.widthOriginal*this.colorChannels,this.originalHeightMultipliedByChannels=this.heightOriginal*this.colorChannels,this.widthPassResultSize=this.targetWidthMultipliedByChannels*this.heightOriginal,this.finalResultSize=this.targetWidthMultipliedByChannels*this.targetHeight,this.initialize()}function lp(t,e){const n=3&e;return 3===n?t[e]:t[e]*t[e-n+3]/255}function fp(t,e){return t[e]}function up(t,e,n,i,r){if(i)for(let i=0;i<n;i+=4){const n=t[e+i+3];r[i]=t[e+i]*n/255,r[i+1]=t[e+i+1]*n/255,r[i+2]=t[e+i+2]*n/255,r[i+3]=n}else for(let i=0;i<n;i++)r[i]=t[e+i]}function dp(t){for(let e=0;e<t.length;e+=4){const n=t[e+3];if(255!==n)for(let i=0;i<3;i++)t[e+i]=n?Math.min(255,Math.round(255*t[e+i]/n)):0}}function pp(t){return 0===t?1:(t*=Math.PI,Math.sin(t)/t)}function mp(t){return{support:t,kernel:e=>e>-t&&e<t?pp(e)*pp(e/t):0}}(tp=Qd||(Qd={}))[tp.AUTO=-1]="AUTO",tp[tp.NONE=0]="NONE",tp[tp.SUB=1]="SUB",tp[tp.UP=2]="UP",tp[tp.AVERAGE=3]="AVERAGE",tp[tp.PATH=4]="PATH",(np=ep||(ep={}))[np.GRAYSCALE=0]="GRAYSCALE",np[np.COLOR=2]="COLOR",np[np.PALETTE=3]="PALETTE",np[np.GRAYSCALE_ALPHA=4]="GRAYSCALE_ALPHA",np[np.COLOR_ALPHA=6]="COLOR_ALPHA",(rp=ip||(ip={})).NEAREST_NEIGHBOR="nearestNeighbor",rp.BILINEAR="bilinearInterpolation",rp.BICUBIC="bicubicInterpolation",rp.HERMITE="hermiteInterpolation",rp.BEZIER="bezierInterpolation",rp.LANCZOS="lanczosInterpolation",rp.LANCZOS2="lanczos2Interpolation",rp.MITCHELL="mitchellInterpolation",cp.prototype.initialize=function(){if(!(this.widthOriginal>0&&this.heightOriginal>0&&this.targetWidth>0&&this.targetHeight>0))throw console.log(this),new Error("Invalid settings specified for the resizer.");this.configurePasses()},cp.prototype.configurePasses=function(){this.widthOriginal===this.targetWidth?this.resizeWidth=this.bypassResizer:(this.ratioWeightWidthPass=this.widthOriginal/this.targetWidth,this.ratioWeightWidthPass<1&&this.interpolationPass?(this.initializeFirstPassBuffers(),this.resizeWidth=4===this.colorChannels?this.resizeWidthInterpolatedRGBA:this.resizeWidthInterpolatedRGB):(this.initializeFirstPassBuffers(),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))},cp.prototype._resizeWidthInterpolatedRGBChannels=function(t,e){const n=e?4:3,i=this.ratioWeightWidthPass,r=this.widthBuffer,a=this.targetWidth,o=new Int32Array(a),s=new Int32Array(a),h=new Float64Array(a).fill(1),c=new Float64Array(a);let l=0,f=0;for(;l<1/3;f++,l+=i)o[f]=0;l-=1/3;for(const t=this.widthOriginal-1;l<t;f++,l+=i)c[f]=l%1,h[f]=1-c[f],o[f]=Math.floor(l)*n,s[f]=n;for(;f<a;f++)o[f]=this.originalWidthMultipliedByChannels-n;for(let n=0,i=0;i<this.widthPassResultSize;n+=this.originalWidthMultipliedByChannels)for(f=0;f<a;f++){const a=n+o[f],l=a+s[f],u=h[f],d=c[f];r[i++]=t[a]*u+t[l]*d,r[i++]=t[a+1]*u+t[l+1]*d,r[i++]=t[a+2]*u+t[l+2]*d,e&&(r[i++]=t[a+3]*u+t[l+3]*d)}return r},cp.prototype._resizeWidthRGBChannels=function(t,e){const n=e?4:3,i=this.ratioWeightWidthPass,r=1/i,a=this.widthBuffer,o=[],s=[],h=new Int32Array(this.targetWidth);let c=0,l=0,f=0,u=0,d=0,p=0;do{c=i;do{if(l=1+f-u,o.push(f),s.push(Math.min(c,l)),!(c>=l)){u+=c;break}f+=n,u=f,c-=l}while(c>0&&f<this.originalWidthMultipliedByChannels);h[p++]=o.length,d+=n}while(d<this.targetWidthMultipliedByChannels);for(let n=0,i=0;i<this.widthPassResultSize;n+=this.originalWidthMultipliedByChannels)for(let c=0,l=0;c<h.length;c++){let f=0,u=0,d=0,p=0;for(;l<h[c];l++){const i=n+o[l],r=s[l];f=Math.fround(f+t[i]*r),u=Math.fround(u+t[i+1]*r),d=Math.fround(d+t[i+2]*r),e&&(p=Math.fround(p+t[i+3]*r))}a[i++]=f*r,a[i++]=u*r,a[i++]=d*r,e&&(a[i++]=p*r)}return a},cp.prototype._resizeHeightRGBChannels=function(t,e){const n=this.ratioWeightHeightPass,i=1/n,r=this.outputHeightWorkBench,a=this.heightBuffer;let o=0,s=0,h=0,c=0,l=0,f=0,u=0,d=1,p=0,m=0,g=0,b=0;do{for(l=0;l<this.targetWidthMultipliedByChannels;)r[l++]=0,r[l++]=0,r[l++]=0,e&&(r[l++]=0);o=n;do{for(s=1+h-c,d=Math.min(o,s),u=h,l=0;l<this.targetWidthMultipliedByChannels;)p=t[u++],m=t[u++],g=t[u++],r[l++]+=p*d,r[l++]+=m*d,r[l++]+=g*d,e&&(b=t[u++],r[l++]+=b*d);if(!(o>=s)){c+=o;break}h=u,c=h,o-=s}while(o>0&&h<this.widthPassResultSize);for(l=0;l<this.targetWidthMultipliedByChannels;)a[f++]=Math.round(r[l++]*i),a[f++]=Math.round(r[l++]*i),a[f++]=Math.round(r[l++]*i),e&&(a[f++]=Math.round(r[l++]*i))}while(f<this.finalResultSize);return a},cp.prototype.resizeWidthInterpolatedRGB=function(t){return this._resizeWidthInterpolatedRGBChannels(t,!1)},cp.prototype.resizeWidthInterpolatedRGBA=function(t){return this._resizeWidthInterpolatedRGBChannels(t,!0)},cp.prototype.resizeWidthRGB=function(t){return this._resizeWidthRGBChannels(t,!1)},cp.prototype.resizeWidthRGBA=function(t){return this._resizeWidthRGBChannels(t,!0)},cp.prototype.resizeHeightInterpolated=function(t){const e=this.ratioWeightHeightPass,n=this.heightBuffer;let i,r=0,a=0,o=0,s=0,h=0,c=0,l=0;for(;r<1/3;r+=e)for(o=0;o<this.targetWidthMultipliedByChannels;)n[a++]=Math.round(t[o++]);for(r-=1/3,i=this.heightOriginal-1;r<i;r+=e)for(l=r%1,c=1-l,s=Math.floor(r)*this.targetWidthMultipliedByChannels,h=s+this.targetWidthMultipliedByChannels,o=0;o<this.targetWidthMultipliedByChannels;++o)n[a++]=Math.round(t[s++]*c+t[h++]*l);for(;a<this.finalResultSize;)for(o=0,s=i*this.targetWidthMultipliedByChannels;o<this.targetWidthMultipliedByChannels;++o)n[a++]=Math.round(t[s++]);return n},cp.prototype.resizeHeightRGB=function(t){return this._resizeHeightRGBChannels(t,!1)},cp.prototype.resizeHeightRGBA=function(t){return this._resizeHeightRGBChannels(t,!0)},cp.prototype.resize=function(t){this.resizeCallback(this.resizeHeight(this.resizeWidth(t)))},cp.prototype.bypassResizer=function(t){return t},cp.prototype.initializeFirstPassBuffers=function(){this.widthBuffer=this.generateFloatBuffer(this.widthPassResultSize)},cp.prototype.initializeSecondPassBuffers=function(t){this.heightBuffer=this.generateUint8Buffer(this.finalResultSize),t||(this.outputHeightWorkBench=this.generateFloatBuffer(this.targetWidthMultipliedByChannels))},cp.prototype.generateFloatBuffer=function(t){try{return new Float32Array(t)}catch(t){return console.error(t),[]}},cp.prototype.generateUint8Buffer=function(t){try{return new Uint8Array(t)}catch(t){return console.error(t),[]}};const gp={support:2,kernel(t){const e=1/3;return(t=Math.abs(t))<1?(7*t*t*t+-12*t*t+(6-2*e))/6:t<2?((-e-2)*t*t*t+12*t*t+-20*t+(8*e+8))/6:0}};function bp(t,e,n){const i=t/e,r=Math.max(i,1),a=n.support*r,o=Math.ceil(2*a)+1,s=new Int32Array(e),h=new Int32Array(e),c=new Float64Array(e*o);for(let l=0;l<e;l++){const e=(l+.5)*i,f=Math.max(0,Math.floor(e-a+.5)),u=Math.min(t,Math.floor(e+a+.5));let d=0;for(let t=f;t<u;t++){const i=n.kernel((t+.5-e)/r);c[l*o+t-f]=i,d+=i}if(0!==d)for(let t=0;t<u-f;t++)c[l*o+t]/=d;s[l]=f,h[l]=u-f}return{start:s,count:h,taps:o,weights:c}}function wp(t,e,n,i){const r=t.width,a=t.height,o=e.width,s=e.height,h=t.data,c=e.data,l=new Float32Array(o).fill(255),f=new Float32Array(o*a*4);if(o===r){const t=i?lp:fp;for(let e=0;e<f.length;e++)f[e]=t(h,e)}else{const{start:t,count:e,taps:s,weights:c}=bp(r,o,n);for(let t=0;t<o;t++){let n=0;for(let i=0;i<e[t];i++)n+=255*c[t*s+i];l[t]=n}for(let n=0;n<a;n++)for(let a=0;a<o;a++){let l=0,u=0,d=0,p=0,m=4*(n*r+t[a]);for(let t=0;t<e[a];t++,m+=4){const e=c[a*s+t],n=h[m+3],r=e*(i?n:255);l+=r*h[m],u+=r*h[m+1],d+=r*h[m+2],p+=e*n}const g=4*(n*o+a);f[g]=l/255,f[g+1]=u/255,f[g+2]=d/255,f[g+3]=p}}const u=(t,e,n,r,a,o)=>{const s=Math.max(0,Math.min(255,Math.round(a)));c[t+3]=s;const h=i?s?255/a:0:255/o;c[t]=Math.max(0,Math.min(255,Math.round(e*h))),c[t+1]=Math.max(0,Math.min(255,Math.round(n*h))),c[t+2]=Math.max(0,Math.min(255,Math.round(r*h)))};if(s===a){for(let t=0;t<f.length;t+=4){const e=l[t/4%o];u(t,f[t],f[t+1],f[t+2],f[t+3],e)}return}const{start:d,count:p,taps:m,weights:g}=bp(a,s,n),b=4*o;for(let t=0;t<s;t++)for(let e=0;e<o;e++){let n=0,i=0,r=0,a=0,s=0,h=d[t]*b+4*e;for(let o=0;o<p[t];o++,h+=b){const c=g[t*m+o];n+=c*f[h],i+=c*f[h+1],r+=c*f[h+2],a+=c*f[h+3],s+=c*l[e]}u(4*(t*o+e),n,i,r,a,s)}}const yp=mp(3),_p=mp(2);function vp(t,e){const n=new Int32Array(e),i=new Int32Array(e),r=new Float64Array(e),a=new Float64Array(e);for(let o=0;o<e;o++){const s=o*t/e,h=Math.floor(s),c=Math.min(Math.ceil(s),t-1);n[o]=h,i[o]=c,r[o]=s-h,a[o]=c-s}return{min:n,max:i,toMin:r,toMax:a}}function xp(t,e,n,i,r,a){return"cubic"===t?function(t,e,n,i,r){const a=i-n-t+e,o=t-e-a,s=n-t,h=e;return Math.max(0,Math.min(255,a*(r*r*r)+o*(r*r)+s*r+h))}(e,n,i,r,a):"hermite"===t?function(t,e,n,i,r){const a=e,o=.5*(n-t),s=t-2.5*e+2*n-.5*i,h=.5*(i-t)+1.5*(e-n);return Math.max(0,Math.min(255,Math.round(((h*r+s)*r+o)*r+a)))}(e,n,i,r,a):function(t,e,n,i,r){const a=1-r,o=e*a*a*a,s=3*(e+(n-t)/4)*a*a*r,h=3*(n-(i-e)/4)*a*r*r,c=n*r*r*r;return Math.max(0,Math.min(255,Math.round(o+s+h+c)))}(e,n,i,r,a)}function kp(t,e,n,i,r,a,o){const s="cubic"!==t;for(let h=0;h<i.length;h++,o+=4){const c=r[h],l=4*i[h];if(0!==c)for(let i=0;i<4;i++){const r=e[l+i],s=e[l+i+4],h=l>0?e[l+i-4]:2*r-s,f=l<4*(n-2)?e[l+i+8]:2*s-r;a[o+i]=xp(t,h,r,s,f,c)}else for(let t=0;t<4;t++)a[o+t]=s?Math.round(e[l+t]):e[l+t]}}function Ap(t,e,n,i,r,a,o,s,h){const c=i+a;for(let l=0;l<a;l++){const a=e[i+l],f=e[c+l],u=n>=0?e[n+l]:2*a-f,d=r>=0?e[r+l]:2*f-a;s[h+l]=xp(t,u,a,f,d,o)}}function Mp(t,e,n,i,r,a,o,s,h){const c=i*r;o.fill(0);for(let a=0;a<r;a++,e+=n){let n=e;for(let e=0;e<o.length;e+=4)for(let r=0;r<i;r++,n+=4)o[e]+=t[n],o[e+1]+=t[n+1],o[e+2]+=t[n+2],o[e+3]+=t[n+3]}for(let t=0;t<o.length;t+=4,h+=4){const e=o[t],n=o[t+1],i=o[t+2],r=o[t+3];a?(s[h]=r?Math.min(255,Math.round(255*e/r)):0,s[h+1]=r?Math.min(255,Math.round(255*n/r)):0,s[h+2]=r?Math.min(255,Math.round(255*i/r)):0):(s[h]=Math.round(e/c),s[h+1]=Math.round(n/c),s[h+2]=Math.round(i/c)),s[h+3]=Math.round(r/c)}}function Ep(t,e,i,r){const a=t.data,o=e.data,s=t.width,h=t.height,c=e.width,l=e.height,f=Math.max(1,Math.floor(s/c)),u=c*f,d=Math.max(1,Math.floor(h/l)),p=l*d,m=new Uint8Array(u*h*4),g=new Float64Array(4*s),b=new Int32Array(u),w=new Float64Array(u);for(let t=0;t<u;t++){const e=Math.min(t*s/u,s-1);b[t]=Math.floor(e),w[t]=e-b[t]}for(let t=0;t<h;t++)up(a,t*s*4,4*s,i,g),kp(r,g,s,b,w,m,t*u*4);const y=4*u,_=n.Buffer.alloc(y*p);for(let t=0;t<p;t++){const e=Math.min(t*h/p,h-1),n=Math.floor(e),i=e-n,a=n*y,o=t*y;0!==i?Ap(r,m,n>0?a-y:-1,a,n<h-2?a+2*y:-1,y,i,_,o):_.set(m.subarray(a,a+y),o)}if(f*d===1)return i&&dp(_),void(e.data=_);const v=new Float64Array(4*c);for(let t=0;t<l;t++)Mp(_,t*d*y,y,f,d,i,v,o,t*c*4)}const Ip={nearestNeighbor(t,e){const n=t.width,i=t.height,r=e.width,a=e.height,o=t.data,s=e.data;for(let t=0;t<a;t++)for(let e=0;e<r;e++){let h=4*(t*r+e);let c=4*(Math.floor(t*i/a)*n+Math.floor(e*n/r));s[h++]=o[c++],s[h++]=o[c++],s[h++]=o[c++],s[h]=o[c]}},bilinearInterpolation(t,e,n=!0){const i=t.width,r=e.width,a=e.height,o=t.data,s=e.data,h=vp(i,r),c=vp(t.height,a),l=new Float64Array(4*i),f=(t,e)=>{up(o,t*i*4,4*i,n,l);for(let t=0;t<r;t++){const n=4*h.min[t],i=4*h.max[t],r=h.toMin[t],a=h.toMax[t];for(let o=0;o<4;o++)e[4*t+o]=n===i?Math.round(l[n+o]):Math.round(r*l[i+o]+a*l[n+o])}};let u=new Float64Array(4*r),d=new Float64Array(4*r),p=-1,m=-1;for(let t=0;t<a;t++){const e=c.min[t],n=c.max[t];e!==p&&(e===m?([u,d]=[d,u],[p,m]=[m,p]):(f(e,u),p=e));const i=t*r*4;if(e===n){s.set(u,i);continue}n!==m&&(f(n,d),m=n);const a=c.toMin[t],o=c.toMax[t];for(let t=0;t<4*r;t++)s[i+t]=Math.round(a*d[t]+o*u[t])}n&&dp(s)},bicubicInterpolation(t,e,n=!0){Ep(t,e,n,"cubic")},hermiteInterpolation(t,e,n=!0){Ep(t,e,n,"hermite")},bezierInterpolation(t,e,n=!0){Ep(t,e,n,"bezier")},lanczosInterpolation(t,e,n=!0){wp(t,e,yp,n)},lanczos2Interpolation(t,e,n=!0){wp(t,e,_p,n)},mitchellInterpolation(t,e,n=!0){wp(t,e,gp,n)}},Sp=Ih([Ah({w:uh().min(0),h:uh().min(0).optional(),mode:Oh(ip).optional(),premultiplyAlpha:gh().optional()}),Ah({w:uh().min(0).optional(),h:uh().min(0),mode:Oh(ip).optional(),premultiplyAlpha:gh().optional()})]),zp=Ah({w:uh().min(0),h:uh().min(0),mode:Oh(ip).optional(),premultiplyAlpha:gh().optional()}),Bp=Ah({f:uh().min(0),mode:Oh(ip).optional(),premultiplyAlpha:gh().optional()});function Cp(t){if(t instanceof Uint8Array)return n.Buffer.from(t);const e=n.Buffer.alloc(t.length);for(let n=0;n<t.length;n++)e[n]=Math.round(t[n]);return e}function Pp(t){const e=n.Buffer.alloc(t.length);for(let n=0;n<t.length;n+=4){const i=Math.min(255,Math.max(0,Math.round(t[n+3])));if(e[n+3]=i,0!==i)for(let i=0;i<3;i++)e[n+i]=Math.min(255,Math.max(0,Math.round(255*t[n+i]/t[n+3])))}return e}const Tp={resize(t,e){const{mode:i,premultiplyAlpha:r=!0}=Sp.parse(e);let a,o;if("number"==typeof e.w)a=e.w,o=e.h??t.bitmap.height*(a/t.bitmap.width);else{if("number"!=typeof e.h)throw new Error("w must be a number");o=e.h,a=e.w??t.bitmap.width*(o/t.bitmap.height)}if(a=Math.round(a)||1,o=Math.round(o)||1,i&&"function"==typeof Ip[i]){const e={data:n.Buffer.alloc(a*o*4),width:a,height:o};Ip[i](t.bitmap,e,r),t.bitmap=e}else{const{data:e}=t.bitmap,n=r&&function(t){for(let e=3;e<t.length;e+=4)if(255!==t[e])return!0;return!1}(e),i=new cp(t.bitmap.width,t.bitmap.height,a,o,!0,!0,e=>{t.bitmap.data=n?Pp(e):Cp(e),t.bitmap.width=a,t.bitmap.height=o});i.resize(n?function(t){const e=new Float32Array(t.length);for(let n=0;n<t.length;n+=4){const i=t[n+3];e[n]=t[n]*i/255,e[n+1]=t[n+1]*i/255,e[n+2]=t[n+2]*i/255,e[n+3]=i}return e}(e):e)}return t},scale(t,e){const{f:n,mode:i,premultiplyAlpha:r}="number"==typeof e?{f:e}:Bp.parse(e),a=t.bitmap.width*n,o=t.bitmap.height*n;return this.resize(t,{w:a,h:o,mode:i,premultiplyAlpha:r})},scaleToFit(t,e){const{h:n,w:i,mode:r,premultiplyAlpha:a}=zp.parse(e),o=i/n>t.bitmap.width/t.bitmap.height?n/t.bitmap.height:i/t.bitmap.width;return this.scale(t,{f:o,mode:r,premultiplyAlpha:a})}},Up=n.Buffer.from([137,80,78,71,13,10,26,10]),Op=256,Lp=[1,4,8,16,24,32],Rp={0:1,2:3,3:1,4:2,6:4};function Fp(t){const e=t.length>=6?t.readUInt16LE(2):0;if(t.length<6||0!==t.readUInt16LE(0)||!e)throw new Error("Invalid ICO file: it doesn't start with an ICO header");if(e>2)throw new Error(`Invalid ICO file: unknown image type ${e}`);const n=t.readUInt16LE(4);if(0===n)throw new Error("Invalid ICO file: it contains no images");if(6+16*n>t.length)throw new Error(`Invalid ICO file: the directory of ${n} images is truncated`);return Array.from({length:n},(e,n)=>{const i=6+16*n,r=t.readUInt32LE(i+8),a=t.readUInt32LE(i+12);if(a+r>t.length)throw new Error(`Invalid ICO file: image ${n} is past the end of the file`);const o=t.subarray(a,a+r);if(function(t){return t.length>=Up.length&&Up.equals(t.subarray(0,Up.length))}(o)){if(o.length<26)throw new Error(`Invalid ICO file: image ${n} is truncated`);return{index:n,width:o.readUInt32BE(16),height:o.readUInt32BE(20),bitDepth:o[24]*(Rp[o[25]]??1),format:"png",data:o}}if(o.length<40)throw new Error(`Invalid ICO file: image ${n} is truncated`);return{index:n,width:o.readInt32LE(4),height:Math.floor(o.readInt32LE(8)/2),bitDepth:o.readUInt16LE(14),format:"bmp",data:o}})}function Dp(t,e={}){const i=function(t,{index:e,size:n}){if(void 0!==e){const n=t[e];if(!n)throw new Error(`ICO image index ${e} is out of range, the file has ${t.length} images`);return n}const i=t=>Math.max(t.width,t.height),r=void 0===n?[]:t.filter(t=>i(t)>=n);return 0===r.length?t.reduce((t,e)=>function(t,e){const n=t.width*t.height-e.width*e.height;return n>0||0===n&&t.bitDepth>e.bitDepth}(e,t)?e:t):r.reduce((t,e)=>{const n=i(e)-i(t);return n<0||0===n&&e.bitDepth>t.bitDepth?e:t})}(Fp(t),e),{maxResolutionInMP:r}=e;if(void 0!==r&&Math.abs(i.width*i.height)>1e6*r)throw new Error(`ICO dimensions ${i.width}x${Math.abs(i.height)} exceed the maximum resolution of ${r} megapixels`);return"png"===i.format?hp().decode(i.data):function({data:t,index:e,width:i,height:r,bitDepth:a}){if(!Lp.includes(a))throw new Error(`Unsupported BMP bit depth ${a}`);const o=t.readUInt32LE(0),s=t.readUInt32LE(16),h=t.readUInt32LE(32),c=o+(40===o&&s===d.BI_BIT_FIELDS?12:40===o&&s===d.BI_ALPHA_BIT_FIELDS?16:0)+4*(a<=8||h>0?h||1<<a:0);if(c>t.length)throw new Error(`Invalid ICO file: image ${e} is truncated`);const l=4*Math.ceil(i*a/32),f=c+l*r,u=4*Math.ceil(i/32),p=n.Buffer.alloc(14+t.length);p.write("BM",0,"latin1"),p.writeUInt32LE(p.length,2),p.writeUInt32LE(14+c,10),t.copy(p,14),p.writeInt32LE(r,22);const m=_(p,{toRGBA:!0});let g=!1;if(32===a)for(let e=0;e<r;e++){const n=c+(r-1-e)*l;for(let r=0;r<i;r++){const a=t[n+4*r+3];m.data[4*(e*i+r)+3]=a,g||(g=0!==a)}}if(!g)for(let e=0;e<r;e++){const n=f+(r-1-e)*u;for(let r=0;r<i;r++){const a=n+(r>>3),o=a<t.length&&t[a]>>7-(7&r)&1;m.data[4*(e*i+r)+3]=o?0:255}}return{data:m.data,width:i,height:r}}(i)}function Np(t,e){const i=e/Math.max(t.width,t.height);if(1===i)return t;const r={bitmap:{...t,data:n.Buffer.from(t.data)}};return Tp.resize(r,{w:Math.max(1,Math.round(t.width*i)),h:Math.max(1,Math.round(t.height*i))}),r.bitmap}function $p(t,{sizes:e}={}){const i=e?.length?[...new Set(e.map(t=>Math.min(Math.max(Math.round(t),1),Op)))].map(e=>Np(t,e)):[Math.max(t.width,t.height)>Op?Np(t,Op):t],r=i.map(t=>hp().encode(t,{colorType:ep.COLOR_ALPHA})),a=n.Buffer.alloc(6+16*i.length);let o=a.length;return a.writeUInt16LE(1,2),a.writeUInt16LE(i.length,4),i.forEach((t,e)=>{const n=6+16*e,i=r[e];a[n]=t.width%Op,a[n+1]=t.height%Op,a.writeUInt16LE(1,n+4),a.writeUInt16LE(32,n+6),a.writeUInt32LE(i.length,n+8),a.writeUInt32LE(o,n+12),o+=i.length}),n.Buffer.concat([a,...r])}function jp(){return{mime:"image/x-icon",hasAlpha:!0,encode:$p,decode:Dp}}class Gp extends Error{constructor(t,e){super(t,e),this.name=new.target.name}}class Hp extends Gp{}class Zp extends Gp{}class qp extends Gp{}var Wp=Object.defineProperty,Vp=(t,e,n)=>((t,e,n)=>e in t?Wp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n)(t,"symbol"!=typeof e?e+"":e,n);function Jp(t,e,n){const i=new Uint8Array(257),r=new Int32Array(257);let a=0;for(let e=1;e<=16;e++){const n=t[e-1];if(a+n>256)throw new Hp("Bogus Huffman table definition");for(let t=0;t<n;t++)i[a++]=e}const o=a;let s=0,h=i[0];for(a=0;i[a];){for(;i[a]===h;)r[a++]=s++;if(s>=1<<h)throw new Hp("Bogus Huffman table definition");s<<=1,h++}const c=new Int32Array(18),l=new Int32Array(18);a=0;for(let e=1;e<=16;e++){const n=t[e-1];n?(l[e]=a-r[a],a+=n,c[e]=r[a-1]):c[e]=-1}c[17]=1048575;const f=new Uint16Array(512);a=0;for(let n=1;n<=9;n++)for(let i=0;i<t[n-1];i++,a++){let t=r[a]<<9-n;for(let i=1<<9-n;i>0;i--)f[t++]=n<<8|e[a]}const u=new Uint8Array(256);if(u.set(e.subarray(0,o)),n)for(let t=0;t<o;t++)if(u[t]>15)throw new Hp("Bogus Huffman table definition");return{lookup:f,maxcode:c,valoffset:l,values:u}}const Yp=256;class Xp{constructor(t,e){Vp(this,"data"),Vp(this,"offset"),Vp(this,"buf",0),Vp(this,"bits",0),Vp(this,"padBits",0),Vp(this,"marker",-1),Vp(this,"markerOffset",0),this.data=t,this.offset=e}fill(){const t=this.data,e=t.length;for(;this.bits<=24;){let n=0;if(-1!==this.marker)this.padBits+=8;else if(this.offset>=e)this.marker=Yp,this.markerOffset=e,this.padBits+=8;else if(n=t[this.offset],255===n){let i=this.offset+1;for(;i<e&&255===t[i];)i++;i>=e?(this.marker=Yp,this.markerOffset=e,this.padBits+=8,n=0):0===t[i]?this.offset=i+1:(this.marker=t[i],this.markerOffset=i-1,this.padBits+=8,n=0)}else this.offset++;this.buf=this.buf<<8|n,this.bits+=8}}get overrun(){return this.bits<this.padBits}getBits(t){return this.bits<t&&this.fill(),this.bits-=t,this.buf>>>this.bits&(1<<t)-1}getBit(){return this.bits<1&&this.fill(),this.bits--,this.buf>>>this.bits&1}decode(t){this.bits<17&&this.fill();const e=t.lookup[this.buf>>>this.bits-9&511];if(0!==e)return this.bits-=e>>8,255&e;const n=t.maxcode;let i=10,r=this.buf>>>this.bits-i&(1<<i)-1;for(;r>n[i];)i++,r=this.buf>>>this.bits-i&(1<<i)-1;return i>16?(this.bits-=16,-1):(this.bits-=i,t.values[t.valoffset[i]+r&255])}discardBits(){this.bits=0,this.padBits=0}findMarker(){if(-1!==this.marker)return;const t=this.data,e=t.length;let n=this.offset;for(;n<e;){if(255!==t[n]){n++;continue}let i=n+1;for(;i<e&&255===t[i];)i++;if(i>=e)break;if(0!==t[i])return this.marker=t[i],void(this.markerOffset=i-1);n=i+1}this.marker=Yp,this.markerOffset=e}skipMarker(){this.marker!==Yp&&(this.offset=this.markerOffset+2,this.marker=-1)}get atMarker(){return-1!==this.marker}}const Kp=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,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63]);var Qp=Object.defineProperty,tm=(t,e,n)=>((t,e,n)=>e in t?Qp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n)(t,"symbol"!=typeof e?e+"":e,n);const em=(()=>{const t=(t,e,n,i)=>65536*t+(n<<8)+(i<<7)+e;return Int32Array.from([t(23069,1,1,1),t(9606,14,2,0),t(4372,16,3,0),t(2059,18,4,0),t(984,20,5,0),t(474,23,6,0),t(229,25,7,0),t(111,28,8,0),t(54,30,9,0),t(26,33,10,0),t(13,35,11,0),t(6,9,12,0),t(3,10,13,0),t(1,12,13,0),t(23167,15,15,1),t(16165,36,16,0),t(11506,38,17,0),t(8316,39,18,0),t(6073,40,19,0),t(4482,42,20,0),t(3311,43,21,0),t(2465,45,22,0),t(1839,46,23,0),t(1372,48,24,0),t(1030,49,25,0),t(771,51,26,0),t(576,52,27,0),t(433,54,28,0),t(324,56,29,0),t(245,57,30,0),t(183,59,31,0),t(138,60,32,0),t(104,62,33,0),t(78,63,34,0),t(59,32,35,0),t(44,33,9,0),t(23265,37,37,1),t(18508,64,38,0),t(14861,65,39,0),t(12017,67,40,0),t(9759,68,41,0),t(7987,69,42,0),t(6568,70,43,0),t(5400,72,44,0),t(4471,73,45,0),t(3700,74,46,0),t(3067,75,47,0),t(2552,77,48,0),t(2145,78,49,0),t(1798,79,50,0),t(1485,48,51,0),t(1246,50,52,0),t(1039,50,53,0),t(867,51,54,0),t(724,52,55,0),t(604,53,56,0),t(504,54,57,0),t(420,55,58,0),t(352,56,59,0),t(293,57,60,0),t(246,58,61,0),t(203,59,62,0),t(171,61,63,0),t(143,61,32,0),t(23314,65,65,1),t(19716,80,66,0),t(16684,81,67,0),t(14296,82,68,0),t(12264,83,69,0),t(10556,84,70,0),t(9081,86,71,0),t(7903,87,72,0),t(6825,87,73,0),t(5966,72,74,0),t(5156,72,75,0),t(4508,74,76,0),t(3947,74,77,0),t(3409,75,78,0),t(2998,77,79,0),t(2624,77,48,0),t(22578,80,81,1),t(19740,88,82,0),t(17294,89,83,0),t(15325,90,84,0),t(13550,91,85,0),t(11950,92,86,0),t(10650,93,87,0),t(9494,86,71,0),t(21872,88,89,1),t(19625,95,90,0),t(17625,96,91,0),t(15906,97,92,0),t(14372,99,93,0),t(12980,99,94,0),t(11799,93,86,0),t(22184,95,96,1),t(20294,101,97,0),t(18405,102,98,0),t(16847,103,99,0),t(15421,104,100,0),t(14174,99,93,0),t(21041,105,102,0),t(19471,106,103,0),t(17977,107,104,0),t(16734,103,99,0),t(22055,105,106,1),t(20711,108,107,0),t(19333,109,103,0),t(21911,110,109,0),t(20559,111,107,0),t(23056,110,111,1),t(21794,112,109,0),t(23019,112,111,1),t(23069,113,113,0)])})();class nm extends Xp{constructor(){super(...arguments),tm(this,"c",0),tm(this,"a",0),tm(this,"ct",-16),tm(this,"failed",!1),tm(this,"dcStats",Array.from({length:4},()=>new Uint8Array(64))),tm(this,"acStats",Array.from({length:4},()=>new Uint8Array(256))),tm(this,"fixed",Uint8Array.of(113))}readByte(){const t=this.data;if(this.atMarker)return 0;if(this.offset>=t.length)return this.marker=256,this.markerOffset=t.length,0;const e=t[this.offset++];if(255!==e)return e;let n=this.offset;for(;n<t.length&&255===t[n];)n++;return n<t.length&&0===t[n]?(this.offset=n+1,255):(this.marker=n<t.length?t[n]:256,this.markerOffset=n<t.length?n-1:t.length,this.offset=this.markerOffset,0)}decodeBit(t,e){for(;this.a<32768;)--this.ct<0&&(this.c=256*this.c+this.readByte(),this.ct+=8,this.ct<0&&0===++this.ct&&(this.a=32768)),this.a*=2;const n=t[e];let i=em[127&n];const r=255&i,a=i>>8&255;i>>>=16;const o=this.a-i;this.a=o;const s=o*2**this.ct;let h=n>>7;return this.c>=s?(this.c-=s,this.a<i?(this.a=i,t[e]=128&n^a):(this.a=i,t[e]=128&n^r,h^=1)):this.a<32768&&(this.a<i?(t[e]=128&n^r,h^=1):t[e]=128&n^a),h}reset(){this.c=0,this.a=0,this.ct=-16,this.failed=!1}}class im{constructor(t,e,n,i,r,a){tm(this,"reader"),tm(this,"conditioning"),tm(this,"spectralStart"),tm(this,"spectralEnd"),tm(this,"approxLow"),tm(this,"tolerant"),this.reader=t,this.conditioning=e,this.spectralStart=n,this.spectralEnd=i,this.approxLow=r,this.tolerant=a}fail(){if(!this.tolerant)throw new Hp("Corrupt JPEG data: bad arithmetic code");this.reader.failed=!0}decodeDC(t){const e=this.reader,n=t.dcArithmetic,i=e.dcStats[n];let r=t.dcContext;if(0===e.decodeBit(i,r))return t.dcContext=0,!0;const a=e.decodeBit(i,r+1);r+=2+a;let o=e.decodeBit(i,r);if(0!==o)for(r=20;e.decodeBit(i,r);){if(32768==(o<<=1))return this.fail(),!1;r++}const{dcLower:s,dcUpper:h}=this.conditioning;o<1<<s[n]>>1?t.dcContext=0:o>1<<h[n]>>1?t.dcContext=12+4*a:t.dcContext=4+4*a;let c=o;for(r+=14;o>>=1;)e.decodeBit(i,r)&&(c|=o);return c+=1,t.pred=t.pred+(a?-c:c)&65535,!0}decodeAC(t,e,n,i,r){const a=this.reader,o=t.acArithmetic,s=a.acStats[o],h=t.coefficients;for(let t=n;t<=i;t++){let n=3*(t-1);if(a.decodeBit(s,n))break;for(;0===a.decodeBit(s,n+1);)if(n+=3,++t>i)return void this.fail();const c=a.decodeBit(a.fixed,0);n+=2;let l=a.decodeBit(s,n);if(0!==l&&a.decodeBit(s,n))for(l<<=1,n=t<=this.conditioning.acK[o]?189:217;a.decodeBit(s,n);){if(32768==(l<<=1))return void this.fail();n++}let f=l;for(n+=14;l>>=1;)a.decodeBit(s,n)&&(f|=l);f+=1,h[e+Kp[t]]=(c?-f:f)*(1<<r)}}decodeBaseline(t,e){!this.reader.failed&&this.decodeDC(t)&&(t.coefficients[e]=t.pred,this.decodeAC(t,e,1,63,0))}decodeDCFirst(t,e){!this.reader.failed&&this.decodeDC(t)&&(t.coefficients[e]=t.pred*(1<<this.approxLow))}decodeDCRefine(t,e){this.reader.decodeBit(this.reader.fixed,0)&&(t.coefficients[e]|=1<<this.approxLow)}decodeACFirst(t,e){this.reader.failed||this.decodeAC(t,e,this.spectralStart,this.spectralEnd,this.approxLow)}decodeACRefine(t,e){const n=this.reader;if(n.failed)return;const i=n.acStats[t.acArithmetic],r=t.coefficients,a=this.spectralEnd,o=1<<this.approxLow,s=-1<<this.approxLow;let h=a;for(;h>0&&!r[e+Kp[h]];h--);for(let t=this.spectralStart;t<=a;t++){let c=3*(t-1);if(t>h&&n.decodeBit(i,c))break;for(;;){const h=e+Kp[t],l=r[h];if(l){n.decodeBit(i,c+2)&&(r[h]=l<0?l+s:l+o);break}if(n.decodeBit(i,c+1)){r[h]=n.decodeBit(n.fixed,0)?s:o;break}if(c+=3,++t>a)return void this.fail()}}}resetStatistics(t,e,n){const i=this.reader;for(const r of t)(!e||0===this.spectralStart&&0===n)&&(i.dcStats[r.dcArithmetic].fill(0),r.pred=0,r.dcContext=0),(!e||this.spectralStart>0)&&i.acStats[r.acArithmetic].fill(0);i.reset()}}const rm=13;function am(t,e,n,i,r,a,o){const s=t.workspace,h=t.rangeLimit,c=t.rangeMask,l=t.pass1Bits,f=rm-l,u=1<<f-1,d=rm+l+3,p=1<<d-1,m=l+3,g=1<<m-1;let b,w,y,_,v,x,k,A,M,E,I,S,z;for(let t=0;t<8;t++){const r=n+t;if(0===e[r+8]&&0===e[r+16]&&0===e[r+24]&&0===e[r+32]&&0===e[r+40]&&0===e[r+48]&&0===e[r+56]){const n=e[r]*i[t]<<l;s[t]=n,s[t+8]=n,s[t+16]=n,s[t+24]=n,s[t+32]=n,s[t+40]=n,s[t+48]=n,s[t+56]=n;continue}E=e[r+16]*i[t+16],I=e[r+48]*i[t+48],M=4433*(E+I),y=M-15137*I,_=M+6270*E,E=e[r]*i[t],I=e[r+32]*i[t+32],b=E+I<<rm,w=E-I<<rm,v=b+_,A=b-_,x=w+y,k=w-y,b=e[r+56]*i[t+56],w=e[r+40]*i[t+40],y=e[r+24]*i[t+24],_=e[r+8]*i[t+8],M=b+_,E=w+y,I=b+y,S=w+_,z=9633*(I+S),b*=2446,w*=16819,y*=25172,_*=12299,M*=-7373,E*=-20995,I=-16069*I+z,S=-3196*S+z,b+=M+I,w+=E+S,y+=E+I,_+=M+S,s[t]=v+_+u>>f,s[t+56]=v-_+u>>f,s[t+8]=x+y+u>>f,s[t+48]=x-y+u>>f,s[t+16]=k+w+u>>f,s[t+40]=k-w+u>>f,s[t+24]=A+b+u>>f,s[t+32]=A-b+u>>f}for(let t=0;t<64;t+=8){const e=a;if(a+=o,0===s[t+1]&&0===s[t+2]&&0===s[t+3]&&0===s[t+4]&&0===s[t+5]&&0===s[t+6]&&0===s[t+7]){const n=h[s[t]+g>>m&c];r[e]=n,r[e+1]=n,r[e+2]=n,r[e+3]=n,r[e+4]=n,r[e+5]=n,r[e+6]=n,r[e+7]=n;continue}E=s[t+2],I=s[t+6],M=4433*(E+I),y=M-15137*I,_=M+6270*E,b=s[t]+s[t+4]<<rm,w=s[t]-s[t+4]<<rm,v=b+_,A=b-_,x=w+y,k=w-y,b=s[t+7],w=s[t+5],y=s[t+3],_=s[t+1],M=b+_,E=w+y,I=b+y,S=w+_,z=9633*(I+S),b*=2446,w*=16819,y*=25172,_*=12299,M*=-7373,E*=-20995,I=-16069*I+z,S=-3196*S+z,b+=M+I,w+=E+S,y+=E+I,_+=M+S,r[e]=h[v+_+p>>d&c],r[e+7]=h[v-_+p>>d&c],r[e+1]=h[x+y+p>>d&c],r[e+6]=h[x-y+p>>d&c],r[e+2]=h[k+w+p>>d&c],r[e+5]=h[k-w+p>>d&c],r[e+3]=h[A+b+p>>d&c],r[e+4]=h[A-b+p>>d&c]}}var om,sm;function hm(t,e,n){const{component:i,buffer:r}=t,{plane:a,stride:o,width:s,height:h}=i;switch(t.method){case om.Full:return t.array=a,void(t.offset=e*o);case om.H2V1Fancy:{let t=e*o,n=0,i=a[t++];r[n++]=i,r[n++]=3*i+a[t]+2>>2;for(let e=s-2;e>0;e--)i=3*a[t++],r[n++]=i+a[t-2]+1>>2,r[n++]=i+a[t]+2>>2;i=a[t],r[n++]=3*i+a[t-1]+1>>2,r[n]=i;break}case om.H1V2Fancy:{const t=e>>1,n=1&e,i=n?2:1,c=t*o,l=Math.min(Math.max(n?t+1:t-1,0),h-1)*o;for(let t=0;t<s;t++)r[t]=3*a[c+t]+a[l+t]+i>>2;break}case om.H2V2Fancy:{const t=e>>1,n=1&e;let i,c=t*o,l=Math.min(Math.max(n?t+1:t-1,0),h-1)*o,f=0,u=3*a[c++]+a[l++],d=3*a[c++]+a[l++];r[f++]=4*u+8>>4,r[f++]=3*u+d+7>>4,i=u,u=d;for(let t=s-2;t>0;t--)d=3*a[c++]+a[l++],r[f++]=3*u+i+8>>4,r[f++]=3*u+d+7>>4,i=u,u=d;r[f++]=3*u+i+8>>4,r[f]=4*u+7>>4;break}case om.Integral:{const i=t.hExpand,s=Math.floor(e/t.vExpand)*o;for(let t=0,e=0;e<n;t++){const n=a[s+t];for(let t=0;t<i;t++)r[e++]=n}break}case om.Nearest:{const{h:c,v:l}=i,f=Math.min(Math.floor(e*l/t.maxV),h-1)*o;for(let e=0;e<n;e++)r[e]=a[f+Math.min(Math.floor(e*c/t.maxH),s-1)];break}}t.array=r,t.offset=0}function cm(t){const e=(1<<t)-1,n=1<<t-1,i=new Int32Array(e+1),r=new Int32Array(e+1),a=new Int32Array(e+1),o=new Int32Array(e+1),s=t=>Math.floor(65536*t+.5),h=32768;for(let t=0,c=-n;t<=e;t++,c++)i[t]=s(1.402)*c+h>>16,r[t]=s(1.772)*c+h>>16,a[t]=-s(.71414)*c,o[t]=-s(.34414)*c+h;return{crR:i,cbB:r,crG:a,cbG:o}}function lm(t,e){const n=(1<<t)-1,i=n+1,r=t<=8||e?new Uint8Array(3*i):new Uint16Array(3*i);for(let t=0;t<r.length;t++){const a=Math.min(Math.max(t-i,0),n);r[t]=e?e[a]:a}return{table:r,offset:i}}function fm(t,e,n,i,r,a,o){let s=1,h=1;for(const e of t)s=Math.max(s,e.h),h=Math.max(h,e.v);const c=t.map(t=>function(t,e,n,i){const{h:r,v:a,width:o}=t;let s;s=r===e&&a===n?om.Full:2*r===e&&a===n&&o>2?om.H2V1Fancy:r===e&&2*a===n?om.H1V2Fancy:2*r===e&&2*a===n&&o>2?om.H2V2Fancy:e%r===0&&n%a===0?om.Integral:om.Nearest;const h=Math.max(i,2*o)+8;return{component:t,method:s,hExpand:e/r,vExpand:n/a,maxH:e,maxV:n,buffer:t.plane instanceof Uint8Array?new Uint8Array(h):new Uint16Array(h),array:t.plane,offset:0}}(t,s,h,n)),l=r>8?function(t){const e=(1<<t)-1,n=new Uint8Array(e+1);for(let t=0;t<=e;t++)n[t]=Math.floor((255*t*2+e)/(2*e));return n}(r):null,f=(1<<r)-1,u=4===a;let d=0;if("grayscale"===e){const t=c[0];for(let e=0;e<i;e++){hm(t,e,n);const i=t.array,r=t.offset;for(let t=0;t<n;t++){let e=i[r+t];l&&(e=l[e]),o[d++]=e,o[d++]=e,o[d++]=e,u&&(o[d++]=255)}}return}const[p,m,g]=c,b=c[3];if("ycbcr"===e){const{crR:t,cbB:e,crG:a,cbG:s}=cm(r),{table:h,offset:c}=lm(r,l);for(let r=0;r<i;r++){hm(p,r,n),hm(m,r,n),hm(g,r,n);const i=p.array,l=m.array,f=g.array;let b=p.offset,w=m.offset,y=g.offset;for(let r=0;r<n;r++){const n=i[b++]+c,r=l[w++],p=f[y++];o[d++]=h[n+t[p]],o[d++]=h[n+(s[r]+a[p]>>16)],o[d++]=h[n+e[r]],u&&(o[d++]=255)}}return}if("rgb"===e){for(let t=0;t<i;t++){hm(p,t,n),hm(m,t,n),hm(g,t,n);const e=p.array,i=m.array,r=g.array;let a=p.offset,s=m.offset,h=g.offset;for(let t=0;t<n;t++)l?(o[d++]=l[e[a++]],o[d++]=l[i[s++]],o[d++]=l[r[h++]]):(o[d++]=e[a++],o[d++]=i[s++],o[d++]=r[h++]),u&&(o[d++]=255)}return}const w="ycck"===e,{crR:y,cbB:_,crG:v,cbG:x}=cm(r),{table:k,offset:A}=lm(r,null),M=2*f;for(let t=0;t<i;t++){hm(p,t,n),hm(m,t,n),hm(g,t,n),hm(b,t,n);const e=p.array,i=m.array,r=g.array,a=b.array;let s=p.offset,h=m.offset,c=g.offset,E=b.offset;for(let t=0;t<n;t++){let t=e[s++],n=i[h++],p=r[c++];const m=a[E++];if(w){const e=t,i=n,r=p;t=k[A+f-(e+y[r])],n=k[A+f-(e+(x[i]+v[r]>>16))],p=k[A+f-(e+_[i])]}let g=Math.floor((t*m*2+f)/M),b=Math.floor((n*m*2+f)/M),I=Math.floor((p*m*2+f)/M);l&&(g=l[g],b=l[b],I=l[I]),o[d++]=g,o[d++]=b,o[d++]=I,u&&(o[d++]=255)}}}(sm=om||(om={}))[sm.Full=0]="Full",sm[sm.H2V1Fancy=1]="H2V1Fancy",sm[sm.H1V2Fancy=2]="H1V2Fancy",sm[sm.H2V2Fancy=3]="H2V2Fancy",sm[sm.Integral=4]="Integral",sm[sm.Nearest=5]="Nearest";var um=Object.defineProperty,dm=(t,e,n)=>((t,e,n)=>e in t?um(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n)(t,"symbol"!=typeof e?e+"":e,n);function pm(t,e){return t<1<<e-1?t-(1<<e)+1:t}class mm{constructor(t,e,n){dm(this,"reader"),dm(this,"scan"),dm(this,"options"),dm(this,"eobrun",0),dm(this,"insufficient",!1),this.reader=t,this.scan=e,this.options=n}badCode(){if(!this.options.tolerant)throw new Hp("Corrupt JPEG data: bad Huffman code");return 0}decodeBaseline(t,e){const n=this.reader,i=t.coefficients;let r=n.decode(t.dcTable);r<0&&(r=this.badCode()),r&&(t.pred+=pm(n.getBits(r),r)),i[e]=t.pred;const a=t.acTable;for(let t=1;t<64;t++){let o=n.decode(a);o<0&&(o=this.badCode());const s=o>>4;if(r=15&o,r)t+=s,i[e+Kp[t]]=pm(n.getBits(r),r);else{if(15!==s)break;t+=15}}}decodeDCFirst(t,e){const n=this.reader;let i=n.decode(t.dcTable);i<0&&(i=this.badCode()),i&&(t.pred+=pm(n.getBits(i),i)),t.coefficients[e]=t.pred*(1<<this.scan.approxLow)}decodeDCRefine(t,e){this.reader.getBit()&&(t.coefficients[e]|=1<<this.scan.approxLow)}decodeACFirst(t,e){if(this.eobrun>0)return void this.eobrun--;const n=this.reader,i=t.coefficients,r=t.acTable,a=this.scan.spectralEnd,o=this.scan.approxLow;for(let t=this.scan.spectralStart;t<=a;t++){let a=n.decode(r);a<0&&(a=this.badCode());const s=a>>4,h=15&a;if(h)t+=s,i[e+Kp[t]]=pm(n.getBits(h),h)*(1<<o);else{if(15!==s){let t=1<<s;s&&(t+=n.getBits(s)),this.eobrun=t-1;break}t+=15}}}decodeACRefine(t,e){const n=this.reader,i=t.coefficients,r=t.acTable,a=this.scan.spectralEnd,o=1<<this.scan.approxLow,s=-1<<this.scan.approxLow;let h=this.scan.spectralStart;if(0===this.eobrun)for(;h<=a;h++){let t=n.decode(r);t<0&&(t=this.badCode());let c=t>>4,l=15&t;if(l)l=n.getBit()?o:s;else if(15!==c){this.eobrun=1<<c,c&&(this.eobrun+=n.getBits(c));break}do{const t=e+Kp[h],r=i[t];if(0!==r)n.getBit()&&0===(r&o)&&(i[t]=r>=0?r+o:r+s);else if(--c<0)break;h++}while(h<=a);l&&(i[e+Kp[h]]=l)}if(this.eobrun>0){for(;h<=a;h++){const t=e+Kp[h],r=i[t];0!==r&&n.getBit()&&0===(r&o)&&(i[t]=r>=0?r+o:r+s)}this.eobrun--}}processRestart(t){const e=this.reader;for(e.discardBits(),e.findMarker();;){const n=e.marker;if(n===208+t)return e.skipMarker(),void(this.insufficient=!1);if(!this.options.tolerant)throw new Hp(`Corrupt JPEG data: found ${gm(n)} instead of restart marker ${t}`);let i;if(i=n===Yp?3:n<192?2:n<208||n>215||n===208+(t+1&7)||n===208+(t+2&7)?3:n===208+(t-1&7)||n===208+(t-2&7)?2:1,1===i)return e.skipMarker(),void(this.insufficient=!1);if(3===i)return void(this.insufficient=!0);e.skipMarker(),e.findMarker()}}}function gm(t){return t===Yp?"the end of the data":`marker 0xFF${t.toString(16).toUpperCase().padStart(2,"0")}`}function bm(t,e,n,i){const{components:r,progressive:a,restartInterval:o,onRow:s}=n,h=n.arithmetic?new im(new nm(t,e),n.arithmetic,n.spectralStart,n.spectralEnd,n.approxLow,i.tolerant):null,c=new mm(h?h.reader:new Xp(t,e),n,i),l=c.reader,f=1===r.length,u=r[0],d=f?u.blocksPerLine:n.mcusPerLine,p=d*(f?u.blocksPerColumn:n.mcusPerColumn),m=h??c;let g;g=a?0===n.spectralStart?0===n.approxHigh?m.decodeDCFirst:m.decodeDCRefine:0===n.approxHigh?m.decodeACFirst:m.decodeACRefine:m.decodeBaseline,g=g.bind(m),h?.resetStatistics(r,a,n.approxHigh);for(const t of r)t.pred=0;let b=o,w=0,y=0,_=0,v=0;const x=f?u.v:1;for(let t=0;t<p;t++){if(o){if(0===b){c.processRestart(w),w=w+1&7,b=o;for(const t of r)t.pred=0;c.eobrun=0,h?.resetStatistics(r,a,n.approxHigh),c.insufficient&&wm(l,i,p-t,d)}b--}if(!c.insufficient||h){v=Math.floor(y/x);const e=s?0:y;if(f)g(u,e*u.blocksPerLineMcu+_<<6>>>0);else for(let t=0;t<r.length;t++){const n=r[t],{h:i,v:a,blocksPerLineMcu:o}=n;for(let t=0;t<a;t++){const r=e*a+t;for(let t=0;t<i;t++)g(n,64*(r*o+_*i+t))}}if(h)l.atMarker&&wm(l,i,p-t-1,d);else if(l.overrun){if(c.insufficient=!0,!i.tolerant)throw new Hp(`Corrupt JPEG data: scan data ends early at ${gm(l.marker)}`);wm(l,i,p-t-1,d)}}++_===d&&(s?.(y),_=0,y++)}for(l.discardBits(),l.findMarker();l.marker>=208&&l.marker<=215;)l.skipMarker(),l.findMarker();return{offset:l.markerOffset,lastGoodRow:v}}function wm(t,e,n,i){if(!e.allowTruncated&&(t.marker===Yp||217===t.marker)&&n>i)throw new Hp("JPEG data is truncated: the image data ends before the image is complete")}function ym(t,e,n){let i=Math.trunc(((e<<7)+Math.abs(t))/(e<<8));return n>0&&i>=1<<n&&(i=(1<<n)-1),t>=0?i:-i}function _m(t,e,n,i,r,a){const{v:o,blocksPerLine:s,blocksPerColumn:h,blocksPerLineMcu:c,coefficients:l,quantTable:f}=e,u=8*s,d=new Int16Array(64),p=s-1,m=Int8Array.from(e.coefBits.subarray(0,10)),g=new Int8Array(10);for(let t=1;t<10;t++)g[t]=i>1?e.previousCoefBits[t]:-1;const b=f[0],w=f[1],y=f[8],_=f[16],v=f[9],x=f[2],k=f[3],A=f[10],M=f[17],E=f[24],I=(t,e)=>l[64*(t*c+e)];for(let e=0;e<a;e++){let i=o;e===a-1&&(i=h%o||o);const s=e>r?g:m;let S=!0;for(let t=1;t<10;t++)-1!==s[t]&&(S=!1);const z=i*a;for(let r=0;r<i;r++){const a=e*i+r,m=e*o+r,g=a>0?m-1:m,B=a>1?m-2:g,C=a<z-1?m+1:m,P=a<z-2?m+2:C;let T,U,O,L,R,F,D,N,$,j,G,H,Z,q,W,V,J,Y,X,K,Q,tt,et,nt,it;T=U=O=L=R=I(B,0),F=D=N=$=j=I(g,0),G=H=Z=q=W=I(m,0),V=J=Y=X=K=I(C,0),Q=tt=et=nt=it=I(P,0);for(let e=0;e<=p;e++){const i=64*(m*c+e);let r;if(d.set(l.subarray(i,i+64)),0===e&&e<p&&(L=R=I(B,1),$=j=I(g,1),q=W=I(m,1),X=K=I(C,1),nt=it=I(P,1)),e+1<p&&(R=I(B,e+2),j=I(g,e+2),W=I(m,e+2),K=I(C,e+2),it=I(P,e+2)),0!==(r=s[1])&&0===d[1]){const t=b*(S?-T-U+L+R-3*F+13*D-13*$+3*j-3*G+38*H-38*q+3*W-3*V+13*J-13*X+3*K-Q-tt+nt+it:-7*G+50*H-50*q+7*W);d[1]=ym(t,w,r)}if(0!==(r=s[2])&&0===d[8]){const t=b*(S?-T-3*U-3*O-3*L-R-F+13*D+38*N+13*$-j+V-13*J-38*Y-13*X+K+Q+3*tt+3*et+3*nt+it:-7*O+50*N-50*Y+7*et);d[8]=ym(t,y,r)}if(0!==(r=s[3])&&0===d[16]){const t=b*(S?O+2*D+7*N+2*$-5*H-14*Z-5*q+2*J+7*Y+2*X+et:13*N-O-24*Z+13*Y-et);d[16]=ym(t,_,r)}if(0!==(r=s[4])&&0===d[9]){const t=b*(S?-T+R+9*D-9*$-9*J+9*X+Q-it:j+V-10*J+10*X-U-K+tt-nt+L-F+10*D-10*$);d[9]=ym(t,v,r)}if(0!==(r=s[5])&&0===d[2]){const t=b*(S?2*D-5*N+2*$+G+7*H-14*Z+7*q+W+2*J-5*Y+2*X:13*H-G-24*Z+13*q-W);d[2]=ym(t,x,r)}if(S){if(0!==(r=s[6])&&0===d[3]){const t=b*(D-$+2*H-2*q+J-X);d[3]=ym(t,k,r)}if(0!==(r=s[7])&&0===d[10]){const t=b*(D-3*N+$-J+3*Y-X);d[10]=ym(t,A,r)}if(0!==(r=s[8])&&0===d[17]){const t=b*(D-$-3*H+3*q+J-X);d[17]=ym(t,M,r)}if(0!==(r=s[9])&&0===d[24]){const t=b*(D+2*N+$-J-2*Y-X);d[24]=ym(t,E,r)}const t=b*(-2*T-6*U-8*O-6*L-2*R-6*F+6*D+42*N+6*$-6*j-8*G+42*H+152*Z+42*q-8*W-6*V+6*J+42*Y+6*X-6*K-2*Q-6*tt-8*et-6*nt-2*it);d[0]=ym(t,b,0)}m<h&&am(t,d,0,f,n,8*m*u+8*e,u),T=U,U=O,O=L,L=R,F=D,D=N,N=$,$=j,G=H,H=Z,Z=q,q=W,V=J,J=Y,Y=X,X=K,Q=tt,tt=et,et=nt,nt=it}}}}function vm(t,e){return{counts:new Uint8Array(t),symbols:new Uint8Array(e)}}const xm=[0,1,2,3,4,5,6,7,8,9,10,11],km=vm([0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0],xm),Am=vm([0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0],xm),Mm=vm([0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125],[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]),Em=vm([0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,119],[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]),Im={dc:[km,Am],ac:[Mm,Em]};var Sm=Object.defineProperty,zm=(t,e,n)=>((t,e,n)=>e in t?Sm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n)(t,"symbol"!=typeof e?e+"":e,n);const Bm={195:"lossless",197:"differential sequential (hierarchical)",198:"differential progressive (hierarchical)",199:"differential lossless (hierarchical)",203:"arithmetic-coded lossless",205:"arithmetic-coded differential sequential (hierarchical)",206:"arithmetic-coded differential progressive (hierarchical)",207:"arithmetic-coded differential lossless (hierarchical)"};function Cm(t){return t.toString(16).toUpperCase().padStart(2,"0")}function Pm(t){return void 0!==t&&t>=192&&t<=254}function Tm(t){return!(t>=208&&t<=217)&&1!==t}class Um{constructor(t){zm(this,"options"),zm(this,"width",0),zm(this,"height",0),zm(this,"jfif",!1),zm(this,"adobe",null),zm(this,"exif"),zm(this,"comments",[]),zm(this,"frame",null),zm(this,"quantTables",[]),zm(this,"dcTables",[]),zm(this,"acTables",[]),zm(this,"restartInterval",0),zm(this,"conditioning",{dcLower:[0,0,0,0],dcUpper:[1,1,1,1],acK:[5,5,5,5]}),zm(this,"streaming",!1),zm(this,"scans",0),zm(this,"idct",null),zm(this,"memoryUsed",0),zm(this,"lastGoodRow",0),this.options=t}get tolerant(){return this.options.tolerantDecoding}corrupt(t){if(!this.tolerant)throw new Hp(t)}requestMemory(t){const e=1024*this.options.maxMemoryUsageInMB*1024;if(this.memoryUsed+=t,this.memoryUsed>e){const t=Math.ceil((this.memoryUsed-e)/1024/1024);throw new qp(`maxMemoryUsageInMB limit exceeded by at least ${t}MB`)}}parse(t){this.options.tables&&this.parseMarkers(this.options.tables,!0),this.parseMarkers(t,!1);const e=this.frame;if(!e)throw new Hp("JPEG data contains no image (no SOF marker)");if(0===this.scans)throw new Hp("JPEG data contains no image data (no SOS marker)");this.streaming||this.finishCoefficients(e)}parseMarkers(t,e){const n=t.length;if(n<2||255!==t[0]||216!==t[1])throw new Hp(e?"JPEG tables don't start with an SOI marker":"SOI not found: the data is not a JPEG");let i=2;for(;i<n;){if(255!==t[i]||!Pm(t[i+1])){if(255===t[i]&&255===t[i+1]){i++;continue}const e=this.recoverMarker(t,i);if(e<0)break;if(e!==i){i=e;continue}}const r=t[i+1];let a=i+2;if(Tm(r)){if(i+4>n){this.corrupt("JPEG data ends inside a marker segment");break}const e=t[i+2]<<8|t[i+3];if(a=i+2+e,e<2||a>n){if(r>=224||254===r){this.corrupt(`Bad length of ${this.describe(r)}`);break}throw new Hp(`Bad length of ${this.describe(r)}`)}}const o=i+4;if(217===r)break;if(e&&219!==r&&196!==r&&221!==r&&204!==r&&!(r>=224&&r<=239)&&254!==r)throw new Hp(`JPEG tables can only contain DQT, DHT and DRI markers, not ${this.describe(r)}`);switch(r){case 224:case 225:case 226:case 227:case 228:case 229:case 230:case 231:case 232:case 233:case 234:case 235:case 236:case 237:case 238:case 239:case 254:a=this.fixSegmentEnd(t,o,a),e||this.readAppSegment(r,t.subarray(o,a)),i=a;break;case 219:this.readQuantTables(t,o,a),i=a;break;case 196:this.readHuffmanTables(t,o,a),i=a;break;case 221:if(a-o<2)throw new Hp("Bad length of DRI marker");this.restartInterval=t[o]<<8|t[o+1],i=a;break;case 192:case 193:case 194:case 201:case 202:this.readFrame(r,t,o,a),i=a;break;case 195:case 197:case 198:case 199:case 203:case 205:case 206:case 207:throw new Zp(`Unsupported JPEG process: ${Bm[r]} (SOF${r-192}) JPEGs are not supported`);case 218:i=this.readScan(t,o,a);break;case 216:case 208:case 209:case 210:case 211:case 212:case 213:case 214:case 215:i+=2;break;case 204:this.readConditioning(t,o,a),i=a;break;case 220:i=a;break;default:this.corrupt(`Unsupported JPEG marker ${this.describe(r)}`),i=this.fixSegmentEnd(t,o,a)}}}describe(t){return`marker 0xFF${Cm(t)}`}recoverMarker(t,e){const n=t.length;this.corrupt(`Corrupt JPEG data: expected a marker at offset ${e}, found 0x${Cm(t[e])}`);const i=t[e+1];if(Pm(i)&&Tm(i)&&e+4<=n&&this.segmentEndsWell(t,e+2+(t[e+2]<<8|t[e+3])))return e;for(let i=e+1;i+1<n;i++){if(255!==t[i])continue;const e=t[i+1];if(Pm(e)&&255!==e&&(!Tm(e)||218===e||i+4<=n&&this.segmentEndsWell(t,i+2+(t[i+2]<<8|t[i+3]))))return i}return-1}segmentEndsWell(t,e){return e===t.length||e<t.length&&255===t[e]}fixSegmentEnd(t,e,n){if(this.segmentEndsWell(t,n))return n;this.corrupt("Corrupt JPEG data: bad marker segment length");for(let n=e;n+1<t.length;n++)if(255===t[n]&&Pm(t[n+1])&&255!==t[n+1])return n;return t.length}readAppSegment(t,e){const n=(...t)=>t.every((t,n)=>e[n]===t);if(254===t){let t="";for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));this.comments.push(t)}else 224===t&&n(74,70,73,70,0)?this.jfif=!0:225===t&&n(69,120,105,102,0)?this.exif=e.slice(5):238===t&&n(65,100,111,98,101)&&(this.adobe={transformCode:e[11]??0})}readQuantTables(t,e,n){for(;e<n;){const i=t[e++],r=i>>4;if(r>1)throw new Hp("Bogus DQT: invalid table precision");if(e+64*(r+1)>n)throw new Hp("Bad length of DQT marker");const a=new Uint16Array(64);for(let n=0;n<64;n++)0===r?a[Kp[n]]=t[e++]:(a[Kp[n]]=t[e]<<8|t[e+1],e+=2);this.quantTables[15&i]=a}}readHuffmanTables(t,e,n){for(;e<n;){const i=t[e++],r=i>>4;if(r>1||e+16>n)throw new Hp("Bogus DHT: invalid table");const a=t.subarray(e,e+16);let o=0;for(let t=0;t<16;t++)o+=a[t];if(e+=16,o>256||e+o>n)throw new Hp("Bogus DHT: invalid table");const s=Jp(a,t.subarray(e,e+o),0===r);e+=o,(0===r?this.dcTables:this.acTables)[15&i]=s}}readConditioning(t,e,n){if((n-e)%2!=0)throw new Hp("Bad length of DAC marker");for(;e<n;e+=2){const n=t[e],i=t[e+1],r=15&n;if(n>=32||r>3)throw new Hp(`Bogus DAC index ${n}`);if(n>=16)this.conditioning.acK[r]=i;else if(this.conditioning.dcLower[r]=15&i,this.conditioning.dcUpper[r]=i>>4,(15&i)>i>>4)throw new Hp(`Bogus DAC value 0x${Cm(i)}`)}}readFrame(t,e,n,i){if(this.frame)throw new Hp("JPEG data has more than one frame (SOF marker)");if(i-n<6)throw new Hp("Bad length of SOF marker");const r=e[n];let a=e[n+1]<<8|e[n+2];const o=e[n+3]<<8|e[n+4],s=e[n+5];if(8!==r&&12!==r)throw new Zp(`Unsupported JPEG data precision: ${r} bits (only 8 and 12 are supported)`);if(0===s||i-n<6+3*s)throw new Hp("Bad length of SOF marker");if(1!==s&&3!==s&&4!==s)throw new Zp(`Unsupported JPEG colour format: ${s} components`);if(0===o)throw new Hp("Empty JPEG image (width is 0)");0===a&&(a=this.findDnlHeight(e,i));const h=o*a/1e6;if(h>this.options.maxResolutionInMP){const t=Math.ceil(h-this.options.maxResolutionInMP);throw new qp(`maxResolutionInMP limit exceeded by ${t}MP`)}const c=[];let l=1,f=1;for(let t=0;t<s;t++){const i=n+6+3*t,r=e[i],a=e[i+1]>>4,o=15&e[i+1];if(a<1||a>4||o<1||o>4)throw new Hp("Invalid sampling factor, expected values above 0 and up to 4");l=Math.max(l,a),f=Math.max(f,o),c.push({id:r,h:a,v:o,quantId:e[i+2],quantTable:null,blocksPerLine:0,blocksPerColumn:0,blocksPerLineMcu:0,blocksPerColumnMcu:0,width:0,height:0,coefficients:new Int16Array(0),plane:null,dcTable:null,acTable:null,pred:0,dcArithmetic:0,acArithmetic:0,dcContext:0,scanned:!1,coefBits:new Int8Array(64).fill(-1),previousCoefBits:new Int8Array(64)})}const u=Math.ceil(o/(8*l)),d=Math.ceil(a/(8*f)),p=r>8?2:1;let m=0,g=0;for(const t of c)t.width=Math.ceil(o*t.h/l),t.height=Math.ceil(a*t.v/f),t.blocksPerLine=Math.ceil(t.width/8),t.blocksPerColumn=Math.ceil(t.height/8),t.blocksPerLineMcu=u*t.h,t.blocksPerColumnMcu=d*t.v,m+=t.blocksPerLine*t.blocksPerColumn*64*p,g+=t.blocksPerLineMcu*t.blocksPerColumnMcu*128;this.width=o,this.height=a;const b=194===t||202===t;this.frame={progressive:b,arithmetic:201===t||202===t,precision:r,width:o,height:a,components:c,maxH:l,maxV:f,mcusPerLine:u,mcusPerColumn:d},this.requestMemory(m+o*a*4),b&&this.requestMemory(g)}findDnlHeight(t,e){for(let n=e;n+5<t.length;n++)if(255===t[n]&&220===t[n+1]){const e=t[n+4]<<8|t[n+5];if(e>0)return e}throw new Hp("Empty JPEG image (height is 0 and there is no DNL marker)")}readScan(t,e,n){const i=this.frame;if(!i)throw new Hp("Corrupt JPEG data: SOS marker before SOF marker");if(++this.scans>1e3)throw new qp("JPEG has more than 1000 scans");const r=t[e++];if(r<1||r>4||n-e!==2*r+3)throw new Hp("Bad length of SOS marker");const a=[];for(let n=0;n<r;n++){const n=t[e++],r=t[e++],o=i.components.find(t=>t.id===n);if(!o||a.includes(o))throw new Hp(`Invalid component ID ${n} in SOS marker`);if(i.arithmetic){if(r>>4>3||(15&r)>3)throw new Hp("Invalid arithmetic table in SOS marker");o.dcArithmetic=r>>4,o.acArithmetic=15&r}else o.dcTable=this.huffmanTable(this.dcTables,r>>4,!0,i.progressive),o.acTable=this.huffmanTable(this.acTables,15&r,!1,i.progressive);a.push(o)}const o=t[e++],s=t[e++],h=t[e]>>4,c=15&t[e];if(i.progressive){if((0===o?0!==s:o>s||s>63||1!==r)||0!==h&&c!==h-1||c>13)throw new Hp(`Invalid progressive parameters Ss=${o} Se=${s} Ah=${h} Al=${c}`)}const l=!i.progressive||0===o&&0===h,f=!i.progressive||o>0;for(const t of a){if(i.arithmetic)break;if(l&&!t.dcTable||f&&!t.acTable)throw new Hp("Huffman table missing for SOS component")}if(r>1){let t=0;for(const e of a)t+=e.h*e.v;if(t>10)throw new Hp("Sampling factors too large for interleaved scan")}const u=n;if(!i.progressive&&this.streaming)return this.skipScan(t,u);for(const t of a)if(!t.quantTable&&(t.quantTable=this.quantTables[t.quantId]??null,!t.quantTable&&!i.progressive&&r===i.components.length))throw new Hp(`Quantization table ${t.quantId} is missing`);this.checkEnoughData(i,t,u,a,l?i.progressive?1:2:0);if(1===this.scans&&(this.idct=function(t){const e=(1<<t)-1,n=1<<t-1,i=4*(e+1),r=t<=8?new Uint8Array(i):new Uint16Array(i);for(let t=0;t<i;t++)r[t]=t<e+1-n?t+n:t<2*(e+1)?e:t<i-n?0:t-(i-n);return{pass1Bits:t<=8?2:1,rangeLimit:r,rangeMask:i-1,workspace:new Int32Array(64)}}(i.precision),this.streaming=!i.progressive&&r===i.components.length),this.streaming)return this.decodeStreamingScan(i,t,u,a);if(i.progressive)for(const{coefBits:t,previousCoefBits:e}of a){const n=Math.min(o,1),i=Math.max(s,9);for(let r=n;r<=i;r++)e[r]=this.scans>1?t[r]:0;for(let e=o;e<=s;e++)t[e]=c}for(const t of a)0===t.coefficients.length&&(i.progressive||this.requestMemory(t.blocksPerLineMcu*t.blocksPerColumnMcu*128),t.coefficients=this.allocate(()=>new Int16Array(t.blocksPerLineMcu*t.blocksPerColumnMcu*64))),t.scanned=!0;const d=bm(t,u,{components:a,progressive:i.progressive,spectralStart:o,spectralEnd:s,approxHigh:h,approxLow:c,mcusPerLine:i.mcusPerLine,mcusPerColumn:i.mcusPerColumn,restartInterval:this.restartInterval,arithmetic:i.arithmetic?this.conditioning:void 0},this.scanOptions());return this.lastGoodRow=d.lastGoodRow,d.offset}scanOptions(){return{tolerant:this.tolerant,allowTruncated:this.options.allowTruncated}}huffmanTable(t,e,n,i){let r=t[e];if(!r&&!i&&e<2){const i=Im[n?"dc":"ac"][e];r=Jp(i.counts,i.symbols,n),t[e]=r}return r??null}checkEnoughData(t,e,n,i,r){if(this.options.allowTruncated||0===r||t.arithmetic)return;let a=0;for(const e of i)a+=1===i.length?e.blocksPerLine*e.blocksPerColumn:t.mcusPerLine*t.mcusPerColumn*e.h*e.v;if((a-t.mcusPerLine*t.maxH*t.maxV*i.length)*r/8>e.length-n)throw new Hp("JPEG data is truncated: the image data ends before the image is complete")}allocate(t){try{return t()}catch(t){if(t instanceof RangeError)throw new qp("Could not allocate enough memory for the image");throw t}}createPlane(t,e){const n=e.blocksPerLine*e.blocksPerColumn*64;e.plane=this.allocate(()=>t.precision>8?new Uint16Array(n):new Uint8Array(n))}decodeStreamingScan(t,e,n,i){const r=1===i.length,a=this.idct;for(const e of i){const n=r?1:e.v;e.coefficients=new Int16Array(e.blocksPerLineMcu*n*64),this.createPlane(t,e),e.scanned=!0}return bm(e,n,{components:i,progressive:!1,spectralStart:0,spectralEnd:63,approxHigh:0,approxLow:0,mcusPerLine:t.mcusPerLine,mcusPerColumn:t.mcusPerColumn,restartInterval:this.restartInterval,arithmetic:t.arithmetic?this.conditioning:void 0,onRow:t=>{for(const e of i){const n=r?1:e.v,{blocksPerLine:i,blocksPerColumn:o,blocksPerLineMcu:s,coefficients:h}=e,c=e.plane,l=8*i,f=e.quantTable;for(let e=0;e<n;e++){const r=t*n+e;if(r>=o)break;for(let t=0;t<i;t++)am(a,h,64*(e*s+t),f,c,8*r*l+8*t,l)}h.fill(0)}}},this.scanOptions()).offset}skipScan(t,e){for(let n=e;n+1<t.length;n++){const e=t[n+1];if(255===t[n]&&0!==e&&255!==e&&!(e>=208&&e<=215))return n}return t.length}finishCoefficients(t){const e=this.idct,n=t.components.every(t=>t.quantTable),i=t.progressive&&n&&function(t){let e=!1;for(const{quantTable:n,coefBits:i}of t){if(!(n[0]&&n[1]&&n[8]&&n[16]&&n[9]&&n[2]&&n[3]&&n[10]&&n[17]&&n[24]))return!1;if(i[0]<0)return!1;for(let t=1;t<10;t++)0!==i[t]&&(e=!0)}return e}(t.components.map(t=>({...t,quantTable:t.quantTable})));for(const n of t.components){n.scanned||this.corrupt("JPEG data is missing a colour component");const r=n.quantTable??this.quantTables[n.quantId];if(!r)throw new Hp(`Quantization table ${n.quantId} is missing`);if(this.createPlane(t,n),!n.scanned)continue;if(i){_m(e,{...n,quantTable:r},n.plane,this.scans,this.lastGoodRow,t.mcusPerColumn),n.coefficients=new Int16Array(0);continue}const{blocksPerLine:a,blocksPerColumn:o,blocksPerLineMcu:s,coefficients:h}=n,c=n.plane,l=8*a;for(let t=0;t<o;t++)for(let n=0;n<a;n++)am(e,h,64*(t*s+n),r,c,8*t*l+8*n,l);n.coefficients=new Int16Array(0)}}get colorSpace(){const t=this.frame,e=t.components.length,n=this.options.colorTransform;if(1===e)return"grayscale";if(3===e){if(void 0!==n)return n?"ycbcr":"rgb";if(this.jfif)return"ycbcr";if(this.adobe)return 0===this.adobe.transformCode?"rgb":"ycbcr";const[e,i,r]=t.components;return 82===e.id&&71===i.id&&66===r.id?"rgb":"ycbcr"}return void 0!==n?n?"ycck":"cmyk":this.adobe&&0!==this.adobe.transformCode?"ycck":"cmyk"}getPixels(t,e){const n=this.frame,i=n.components.map(t=>({plane:t.plane,stride:8*t.blocksPerLine,width:t.width,height:t.height,h:t.h,v:t.v}));fm(i,this.colorSpace,n.width,n.height,n.precision,e,t)}}function Om(t,e="data"){if(t instanceof Uint8Array)return t;if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);if(t instanceof ArrayBuffer)return new Uint8Array(t);if(null!==t&&"object"==typeof t&&"number"==typeof t.length)return Uint8Array.from(t);throw new TypeError(`Expected the ${e} to be a Uint8Array, ArrayBuffer, typed array or array of bytes`)}const Lm={formatAsRGBA:!0,tolerantDecoding:!0,allowTruncated:!1,maxResolutionInMP:100,maxMemoryUsageInMB:512};function Rm({counts:t,symbols:e}){const n=new Uint16Array(256),i=new Uint8Array(256);let r=0,a=0;for(let o=1;o<=16;o++){for(let s=0;s<t[o-1];s++)n[e[a]]=r++,i[e[a]]=o,a++;r<<=1}return{codes:n,lengths:i}}function Fm(t){const e=new Uint8Array(34),n=new Int32Array(257),i=new Int32Array(257).fill(-1),r=new Int32Array(257),a=new Float64Array(257);let o=0;t[256]=1;for(let e=0;e<257;e++)t[e]&&(r[o]=e,a[o]=t[e],o++);for(;;){let t=-1,e=-1,r=Number.MAX_VALUE,s=Number.MAX_VALUE;for(let n=0;n<o;n++)a[n]<=s&&(a[n]<=r?(e=t,s=r,r=a[n],t=n):(s=a[n],e=n));if(e<0)break;for(a[t]+=a[e],a[e]=1/0,n[t]++;i[t]>=0;)t=i[t],n[t]++;for(i[t]=e,n[e]++;i[e]>=0;)e=i[e],n[e]++}for(let i=0;i<o;i++){if(n[i]>32)return Fm(t.map(t=>t?Math.max(1,Math.floor(t/2)):0));e[n[i]]++}for(let t=32;t>16;t--)for(;e[t]>0;){let n=t-2;for(;0===e[n];)n--;e[t]-=2,e[t-1]++,e[n+1]+=2,e[n]--}let s=16;for(;0===e[s];)s--;e[s]--;const h=[];for(let t=1;t<=32;t++)for(let e=0;e<o;e++)n[e]===t&&256!==r[e]&&h.push(r[e]);return{counts:e.slice(1,17),symbols:Uint8Array.from(h)}}var Dm=Object.defineProperty,Nm=(t,e,n)=>((t,e,n)=>e in t?Dm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n)(t,"symbol"!=typeof e?e+"":e,n);const $m=(t,e,n,i,r)=>({components:t,ss:e,se:n,ah:i,al:r});function jm(t){return 0===t?0:32-Math.clz32(t)}class Gm{constructor(t,e,n,i,r){Nm(this,"writer"),Nm(this,"scan"),Nm(this,"frequencies"),Nm(this,"codes"),Nm(this,"eobrun",0),Nm(this,"correctionBits",new Uint8Array(1e3)),Nm(this,"correctionCount",0),Nm(this,"lastDC"),this.writer=t,this.scan=e,this.frequencies=n,this.codes=i,this.lastDC=new Int32Array(r)}symbol(t,e){if(this.writer){const n=this.codes[t];this.writer.writeBits(n.codes[e],n.lengths[e])}else this.frequencies[t][e]++}bits(t,e){this.writer&&e&&this.writer.writeBits(t,e)}bufferedBits(t,e,n){if(this.writer)for(let i=0;i<n;i++)this.writer.writeBits(t[e+i],1)}emitEobrun(t){if(this.eobrun>0){const e=jm(this.eobrun)-1;this.symbol(t,e<<4),this.bits(this.eobrun,e),this.eobrun=0,this.bufferedBits(this.correctionBits,0,this.correctionCount),this.correctionCount=0}}dcFirst(t,e,n,i){const r=t[e]>>this.scan.al,a=r-this.lastDC[n];this.lastDC[n]=r;const o=jm(a<0?-a:a);this.symbol(i,o),this.bits(a<0?a-1:a,o)}dcRefine(t,e){this.bits(t[e]>>this.scan.al&1,1)}acFirst(t,e,n){const{ss:i,se:r,al:a}=this.scan;let o=0;for(let s=i;s<=r;s++){let i,r=t[e+s];if(0===r){o++;continue}if(r<0?(r=-r>>a,i=~r):(r>>=a,i=r),0===r){o++;continue}for(this.emitEobrun(n);o>15;)this.symbol(n,240),o-=16;const h=jm(r);this.symbol(n,(o<<4)+h),this.bits(i,h),o=0}o>0&&(this.eobrun++,32767===this.eobrun&&this.emitEobrun(n))}acRefine(t,e,n){const{ss:i,se:r,al:a}=this.scan,o=new Int32Array(64);let s=0;for(let n=i;n<=r;n++){let i=t[e+n];i<0&&(i=-i),i>>=a,o[n]=i,1===i&&(s=n)}let h=0,c=this.correctionCount,l=0;const f=this.correctionBits;for(let a=i;a<=r;a++){const i=o[a];if(0!==i){for(;h>15&&a<=s;)this.emitEobrun(n),this.symbol(n,240),h-=16,this.bufferedBits(f,c,l),c=0,l=0;i>1?f[c+l++]=1&i:(this.emitEobrun(n),this.symbol(n,1+(h<<4)),this.bits(t[e+a]<0?0:1,1),this.bufferedBits(f,c,l),c=0,l=0,h=0)}else h++}(h>0||l>0)&&(this.eobrun++,this.correctionCount=c+l,(32767===this.eobrun||this.correctionCount>937)&&this.emitEobrun(n))}run(t){const{scan:e}=this,n=e.components.map(e=>t.components[e]),i=0===e.ss,r=(t,n,r)=>{const a=t.table;i?0===e.ah?this.dcFirst(t.coefficients,r,n,a):this.dcRefine(t.coefficients,r):0===e.ah?this.acFirst(t.coefficients,r,a):this.acRefine(t.coefficients,r,a)};if(1===n.length){const t=n[0];for(let e=0;e<t.blocksPerColumn;e++)for(let n=0;n<t.blocksPerLine;n++)r(t,0,64*(e*t.blocksPerLineMcu+n))}else for(let e=0;e<t.mcusPerColumn;e++)for(let i=0;i<t.mcusPerLine;i++)n.forEach((t,n)=>{const{h:a,v:o,blocksPerLineMcu:s}=t;for(let h=0;h<o;h++)for(let c=0;c<a;c++)r(t,n,64*((e*o+h)*s+i*a+c))});i||this.emitEobrun(n[0].table)}}function Hm(t,e){for(const n of 3===e.components.length?[$m([0,1,2],0,0,0,1),$m([0],1,5,0,2),$m([2],1,63,0,1),$m([1],1,63,0,1),$m([0],6,63,0,2),$m([0],1,63,2,1),$m([0,1,2],0,0,1,0),$m([2],1,63,1,0),$m([1],1,63,1,0),$m([0],1,63,1,0)]:[$m([0],0,0,0,1),$m([0],1,5,0,2),$m([0],6,63,0,2),$m([0],1,63,2,1),$m([0],0,0,1,0),$m([0],1,63,1,0)]){const i=n.components.map(t=>e.components[t]),r=0===n.ss,a=[...new Set(i.map(t=>t.table))];let o=[];if(!(r&&n.ah>0)){const s=[new Float64Array(257),new Float64Array(257)];new Gm(null,n,s,[],i.length).run(e);const h=a.map(t=>Fm(s[t]));o=[],t.writeUint16(65476),t.writeUint16(2+h.reduce((t,e)=>t+17+e.symbols.length,0)),a.forEach((e,n)=>{const i=h[n];o[e]=Rm(i),t.writeByte((r?0:16)|e),t.writeBytes(i.counts),t.writeBytes(i.symbols)})}t.writeUint16(65498),t.writeUint16(6+2*i.length),t.writeByte(i.length);for(const{id:e,table:n}of i)t.writeBytes([e,n<<4|n]);t.writeBytes([n.ss,n.se,n.ah<<4|n.al]),new Gm(t,n,[],o,i.length).run(e),t.flushBits()}}var Zm=Object.defineProperty,qm=(t,e,n)=>((t,e,n)=>e in t?Zm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n)(t,"symbol"!=typeof e?e+"":e,n);class Wm{constructor(t=1024){qm(this,"buffer"),qm(this,"length",0),qm(this,"bitBuffer",0),qm(this,"bitCount",0),this.buffer=new Uint8Array(t)}reserve(t){if(this.length+t<=this.buffer.length)return;const e=new Uint8Array(Math.max(2*this.buffer.length,this.length+t));e.set(this.buffer.subarray(0,this.length)),this.buffer=e}writeByte(t){this.reserve(1),this.buffer[this.length++]=t}writeUint16(t){this.reserve(2),this.buffer[this.length++]=t>>8,this.buffer[this.length++]=t}writeBytes(t){if(this.reserve(t.length),t instanceof Uint8Array)this.buffer.set(t,this.length),this.length+=t.length;else for(let e=0;e<t.length;e++)this.buffer[this.length++]=t[e]}writeBits(t,e){if(this.bitBuffer=this.bitBuffer<<e|t&(1<<e)-1,this.bitCount+=e,this.bitCount<8)return;this.reserve(6);const n=this.buffer;for(;this.bitCount>=8;){this.bitCount-=8;const t=this.bitBuffer>>this.bitCount&255;n[this.length++]=t,255===t&&(n[this.length++]=0)}this.bitBuffer&=(1<<this.bitCount)-1}flushBits(){this.bitCount>0&&this.writeBits(127,8-this.bitCount),this.bitBuffer=0,this.bitCount=0}result(){return this.buffer.slice(0,this.length)}}var Vm=Object.defineProperty,Jm=(t,e,n)=>((t,e,n)=>e in t?Vm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n)(t,"symbol"!=typeof e?e+"":e,n);const Ym=new Uint8Array([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]),Xm=[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],Km=[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],Qm=[1,1.387039845,1.306562965,1.175875602,1,.785694958,.5411961,.275899379];function tg(t,e){const n=e<50?Math.floor(5e3/e):200-2*e,i=new Uint8Array(64),r=new Float64Array(64);for(let e=0;e<64;e++)i[Ym[e]]=Math.min(Math.max(Math.floor((t[e]*n+50)/100),1),255);for(let t=0,e=0;t<8;t++)for(let n=0;n<8;n++,e++)r[e]=1/(i[Ym[e]]*Qm[t]*Qm[n]*8);return{table:i,divisors:r}}function eg(t){return 0===t?0:32-Math.clz32(t<0?-t:t)}function ng(t,e,n,i){for(let e=0;e<64;e+=8){const n=t[e],i=t[e+1],r=t[e+2],a=t[e+3],o=t[e+4],s=t[e+5],h=t[e+6],c=t[e+7],l=n+c,f=n-c,u=i+h,d=i-h,p=r+s,m=r-s,g=a+o,b=a-o;let w=l+g;const y=l-g;let _=u+p,v=u-p;t[e]=w+_,t[e+4]=w-_;const x=.707106781*(v+y);t[e+2]=y+x,t[e+6]=y-x,w=b+m,_=m+d,v=d+f;const k=.382683433*(w-v),A=.5411961*w+k,M=1.306562965*v+k,E=.707106781*_,I=f+E,S=f-E;t[e+5]=S+A,t[e+3]=S-A,t[e+1]=I+M,t[e+7]=I-M}for(let e=0;e<8;e++){const n=t[e],i=t[e+8],r=t[e+16],a=t[e+24],o=t[e+32],s=t[e+40],h=t[e+48],c=t[e+56],l=n+c,f=n-c,u=i+h,d=i-h,p=r+s,m=r-s,g=a+o,b=a-o;let w=l+g;const y=l-g;let _=u+p,v=u-p;t[e]=w+_,t[e+32]=w-_;const x=.707106781*(v+y);t[e+16]=y+x,t[e+48]=y-x,w=b+m,_=m+d,v=d+f;const k=.382683433*(w-v),A=.5411961*w+k,M=1.306562965*v+k,E=.707106781*_,I=f+E,S=f-E;t[e+40]=S+A,t[e+24]=S-A,t[e+8]=I+M,t[e+56]=I-M}for(let r=0;r<64;r++){const a=t[r]*e[r];n[i+Ym[r]]=a>0?a+.5|0:a-.5|0}}class ig{constructor(t,e,n){Jm(this,"writer"),Jm(this,"dc"),Jm(this,"ac"),this.writer=t,this.dc=e.map(Rm),this.ac=n.map(Rm)}encode(t,e,n,i){const r=this.writer,a=this.dc[i],o=this.ac[i],s=t[e]-n;let h=eg(s);r.writeBits(a.codes[h],a.lengths[h]),h&&r.writeBits(s<0?s+(1<<h)-1:s,h);let c=63;for(;c>0&&0===t[e+c];)c--;let l=0;for(let n=1;n<=c;n++){const i=t[e+n];if(0===i){l++;continue}for(;l>15;)r.writeBits(o.codes[240],o.lengths[240]),l-=16;h=eg(i);const a=l<<4|h;r.writeBits(o.codes[a],o.lengths[a]),r.writeBits(i<0?i+(1<<h)-1:i,h),l=0}63!==c&&r.writeBits(o.codes[0],o.lengths[0])}}class rg{constructor(t){Jm(this,"bytes"),Jm(this,"length",0),Jm(this,"dcFrequencies",[new Float64Array(257),new Float64Array(257)]),Jm(this,"acFrequencies",[new Float64Array(257),new Float64Array(257)]),this.bytes=new Uint8Array(Math.max(t,1024))}record(t,e,n,i){if(this.length+192>this.bytes.length){const t=new Uint8Array(2*this.bytes.length);t.set(this.bytes.subarray(0,this.length)),this.bytes=t}const r=this.bytes;let a=this.length;const o=this.dcFrequencies[i],s=this.acFrequencies[i],h=t[e]-n;let c=eg(h);if(o[c]++,r[a++]=c,c){const t=h<0?h+(1<<c)-1:h;r[a++]=t,c>8&&(r[a++]=t>>8)}let l=e+63;for(;l>e&&0===t[l];)l--;let f=0;for(let n=e+1;n<=l;n++){const e=t[n];if(0===e){f++;continue}for(;f>15;)s[240]++,r[a++]=240,f-=16;c=eg(e);const i=f<<4|c,o=e<0?e+(1<<c)-1:e;s[i]++,r[a++]=i,r[a++]=o,c>8&&(r[a++]=o>>8),f=0}l!==e+63&&(s[0]++,r[a++]=0),this.length=a}replay(t,e,n,i){const r=this.bytes,a=this.length;let o=0,s=0;for(;o<a;){const a=i[s++%i.length],h=e[a],c=n[a];let l=r[o++];if(t.writeBits(h.codes[l],h.lengths[l]),l){let e=r[o++];l>8&&(e|=r[o++]<<8),t.writeBits(e,l)}for(let e=1;e<64;){const n=r[o++];if(t.writeBits(c.codes[n],c.lengths[n]),0===n)break;if(240===n){e+=16;continue}l=15&n;let i=r[o++];l>8&&(i|=r[o++]<<8),t.writeBits(i,l),e+=1+(n>>4)}}}}function ag(t,e){let n=2;for(const{spec:t}of e)n+=17+t.symbols.length;t.writeUint16(65476),t.writeUint16(n);for(const{id:n,spec:i}of e)t.writeByte(n),t.writeBytes(i.counts),t.writeBytes(i.symbols)}const og={"4:4:4":[1,1],"4:2:2":[2,1],"4:2:0":[2,2]};function sg(t,e,n){const{width:i,height:r,data:a,channels:o}=t,{components:s,maxH:h,maxV:c}=e,[l,f,u]=s,d=8*c,p=n*d,m=l.samplesWidth,g=i*o,b=l.samples;if(!f||!u){for(let t=0;t<d;t++){const e=Math.min(p+t,r-1)*g,n=t*m;for(let t=0;t<i;t++)b[n+t]=a[e+t]-128;const o=b[n+i-1];b.fill(o,n+i,n+m)}return}const w=f.samplesWidth,y=f.samples,_=u.samples,v=h>1||c>1;v&&(y.fill(0),_.fill(0));const x=1/(h*c),k=h-1;for(let t=0;t<d;t++){const e=t*m,n=(t/c|0)*w;let s=0,h=0,l=0;for(let c=0,f=Math.min(p+t,r-1)*g;c<m;c++){c<i&&(s=a[f],h=a[f+1],l=a[f+2],f+=o),b[e+c]=.299*s+.587*h+.114*l-128;const t=-.168735892*s+-.331264108*h+.5*l,r=.5*s+-.418687589*h+-.081312411*l;if(v){const e=n+(c>>k);y[e]+=t*x,_[e]+=r*x}else y[e+c]=t,_[e+c]=r}}}function hg(t,e,n,i,r){const{components:a,mcusPerLine:o}=t,s=new Float64Array(64),h=new Int16Array(a.length);for(let t=0;t<o;t++)for(let o=0;o<a.length;o++){const c=a[o],{h:l,v:f,samples:u,samplesWidth:d}=c,p=i(c);for(let i=0;i<f;i++){const a=e*f+i;for(let e=0;e<l;e++){const f=t*l+e,m=n(c,a,f);if(a>=c.blocksPerColumn||f>=c.blocksPerLine)p.fill(0,m,m+64),p[m]=h[o];else{let t=8*i*d+8*f;for(let e=0;e<64;e+=8,t+=d)s[e]=u[t],s[e+1]=u[t+1],s[e+2]=u[t+2],s[e+3]=u[t+3],s[e+4]=u[t+4],s[e+5]=u[t+5],s[e+6]=u[t+6],s[e+7]=u[t+7];ng(s,c.divisors,p,m)}h[o]=p[m],r?.(c,m,o)}}}}function cg(t,e,n,i,r){const{width:a,height:o}=e;t.writeUint16(65496),t.writeUint16(65504),t.writeUint16(16),t.writeBytes([74,70,73,70,0,1,1,0]),t.writeUint16(1),t.writeUint16(1),t.writeBytes([0,0]);for(const e of n.comments??[]){if("string"!=typeof e)continue;const n=e.slice(0,65533);t.writeUint16(65534),t.writeUint16(n.length+2);for(let e=0;e<n.length;e++)t.writeByte(255&n.charCodeAt(e))}const s=n.exif;if(s){const e=69===s[0]&&120===s[1]&&105===s[2]&&102===s[3],n=s.length+(e?2:7);if(n>65535)throw new RangeError(`EXIF data is ${s.length} bytes, more than a JPEG APP1 segment can hold`);t.writeUint16(65505),t.writeUint16(n),e||t.writeBytes([69,120,105,102,0]),t.writeBytes(s)}t.writeUint16(65499),t.writeUint16(2+65*i.quantTables.length),i.quantTables.forEach((e,n)=>{t.writeByte(n),t.writeBytes(e)});const{components:h}=i;t.writeUint16(r),t.writeUint16(8+3*h.length),t.writeByte(8),t.writeUint16(o),t.writeUint16(a),t.writeByte(h.length);for(const{id:e,h:n,v:i,table:r}of h)t.writeBytes([e,n<<4|i,r])}function lg(t,e,n=0,i=63,r=0){t.writeUint16(65498),t.writeUint16(6+2*e.length),t.writeByte(e.length);for(const{id:n,table:i}of e)t.writeBytes([n,i<<4|i]);t.writeBytes([n,i,r])}function fg(t,e){const{width:n,height:i}=t,r=function(t,e){const{width:n,height:i}=t,r=1===t.channels,[a,o]=r?[1,1]:og[e.subsampling],s=tg(Xm,e.quality),h=tg(Km,e.quality),c=8*a,l=8*o,f=Math.ceil(n/c),u=Math.ceil(i/l),d=(r?[[1,1,1,0]]:[[1,a,o,0],[2,1,1,1],[3,1,1,1]]).map(([t,e,r,a])=>{const o=8*f*e;return{id:t,h:e,v:r,table:a,divisors:0===a?s.divisors:h.divisors,blocksPerLine:Math.ceil(n*e/c),blocksPerColumn:Math.ceil(i*r/l),blocksPerLineMcu:f*e,coefficients:null,samples:new Float32Array(8*o*r),samplesWidth:o}});return{components:d,quantTables:r?[s.table]:[s.table,h.table],maxH:a,maxV:o,mcusPerLine:f,mcusPerColumn:u}}(t,e),{components:a,mcusPerColumn:o}=r,s=a.length>1?2:1,h=new Wm(Math.max(1024,n*i>>3));if(e.progressive)!function(t,e){for(const t of e.components)t.coefficients=new Int16Array(t.blocksPerLineMcu*e.mcusPerColumn*t.v*64);for(let n=0;n<e.mcusPerColumn;n++)sg(t,e,n),hg(e,n,(t,e,n)=>64*(e*t.blocksPerLineMcu+n),t=>t.coefficients,null)}(t,r),cg(h,t,e,r,65474),Hm(h,{components:a.map(t=>({...t,coefficients:t.coefficients})),mcusPerLine:r.mcusPerLine,mcusPerColumn:o});else{const c=new Int16Array(64),l=new Int16Array(a.length),f=e.optimizeHuffman?null:new ig(h,[km,Am].slice(0,s),[Mm,Em].slice(0,s)),u=e.optimizeHuffman?new rg(n*i>>3):null;f&&(cg(h,t,e,r,65472),ag(h,[{id:0,spec:km},{id:16,spec:Mm},...s>1?[{id:1,spec:Am},{id:17,spec:Em}]:[]]),lg(h,a));for(let e=0;e<o;e++)sg(t,r,e),hg(r,e,()=>0,()=>c,(t,e,n)=>{f?f.encode(c,0,l[n],t.table):u.record(c,0,l[n],t.table),l[n]=c[0]});if(u){const n=u.dcFrequencies.slice(0,s).map(Fm),i=u.acFrequencies.slice(0,s).map(Fm),o=Uint8Array.from(a.flatMap(t=>Array(t.h*t.v).fill(t.table)));cg(h,t,e,r,65472),ag(h,[...n.map((t,e)=>({id:e,spec:t})),...i.map((t,e)=>({id:16|e,spec:t}))]),lg(h,a),u.replay(h,n.map(Rm),i.map(Rm),o)}}return h.flushBits(),h.writeUint16(65497),h.result()}function ug(t,e,n){const i=t*e;for(const t of[4,3,1])if(n===i*t)return t;if(n>4*i)return 4;throw new RangeError(`Expected ${4*i} (RGBA), ${3*i} (RGB) or ${i} (greyscale) bytes of pixel data for a ${t}x${e} image, got ${n}`)}function dg(t,e){if("number"!=typeof e||!Number.isInteger(e)||e<1||e>65535)throw new RangeError(`The ${t} of a JPEG must be an integer from 1 to 65535, got ${String(e)}`)}function pg(t){return n.Buffer.from(t.buffer,t.byteOffset,t.byteLength)}function mg(){return{mime:"image/jpeg",encode:(t,{quality:e=100,chromaSubsampling:n,progressive:i}={})=>pg(function(t,e={}){if(!t||"object"!=typeof t)throw new TypeError("Expected an image with width, height and data");const{width:n,height:i}=t;dg("width",n),dg("height",i);const r=Om(t.data,"image data"),a=e.quality??75;if("number"!=typeof a||Number.isNaN(a))throw new TypeError(`Expected the quality to be a number, got ${String(a)}`);const o=Math.min(Math.max(Math.round(a),1),100),s=e.chromaSubsampling??(o>=90?"4:4:4":"4:2:0");if(!["4:4:4","4:2:2","4:2:0"].includes(s))throw new RangeError(`Expected chromaSubsampling to be "4:4:4", "4:2:2" or "4:2:0", got ${String(s)}`);return fg({width:n,height:i,data:r,channels:ug(n,i,r.length)},{quality:o,subsampling:s,optimizeHuffman:e.optimizeHuffman??!0,progressive:e.progressive??!1,comments:e.comments,exif:void 0===e.exif?void 0:Om(e.exif,"EXIF data")})}(t,{quality:e,chromaSubsampling:n,progressive:i})),decode:(t,e)=>{const n=function(t,e={}){const n={...Lm};for(const[t,i]of Object.entries(e))void 0!==i&&(n[t]=i);const i=Om(t),r=new Um({...n,colorTransform:e.colorTransform,tables:void 0===e.tables?void 0:Om(e.tables,"tables")});try{r.parse(i);const t=n.formatAsRGBA?4:3,e=r.width*r.height*t;let a;try{a=new Uint8Array(e)}catch{throw new qp(`Could not allocate enough memory for the image. Required: ${e}`)}r.getPixels(a,t);const o={width:r.width,height:r.height,exifBuffer:r.exif,data:a};return r.comments.length>0&&(o.comments=r.comments),o}catch(t){if(t instanceof Gp)throw t;throw new Hp(`Failed to decode JPEG: ${t instanceof Error?t.message:String(t)}`,{cause:t})}}(t,e);return{...n,data:pg(n.data)}}}}var gg,bg={exports:{}},wg={};function yg(){return gg||(gg=1,function(t){var e="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.assign=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var i=e.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(var r in i)n(i,r)&&(t[r]=i[r])}}return t},t.shrinkBuf=function(t,e){return t.length===e?t:t.subarray?t.subarray(0,e):(t.length=e,t)};var i={arraySet:function(t,e,n,i,r){if(e.subarray&&t.subarray)t.set(e.subarray(n,n+i),r);else for(var a=0;a<i;a++)t[r+a]=e[n+a]},flattenChunks:function(t){var e,n,i,r,a,o;for(i=0,e=0,n=t.length;e<n;e++)i+=t[e].length;for(o=new Uint8Array(i),r=0,e=0,n=t.length;e<n;e++)a=t[e],o.set(a,r),r+=a.length;return o}},r={arraySet:function(t,e,n,i,r){for(var a=0;a<i;a++)t[r+a]=e[n+a]},flattenChunks:function(t){return[].concat.apply([],t)}};t.setTyped=function(e){e?(t.Buf8=Uint8Array,t.Buf16=Uint16Array,t.Buf32=Int32Array,t.assign(t,i)):(t.Buf8=Array,t.Buf16=Array,t.Buf32=Array,t.assign(t,r))},t.setTyped(e)}(wg)),wg}var _g,vg,xg,kg,Ag,Mg,Eg,Ig,Sg={},zg={},Bg={};function Cg(){if(_g)return Bg;_g=1;var t=yg();function e(t){for(var e=t.length;--e>=0;)t[e]=0}var n=256,i=286,r=30,a=15,o=[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],s=[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],h=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],c=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],l=new Array(576);e(l);var f=new Array(60);e(f);var u=new Array(512);e(u);var d=new Array(256);e(d);var p=new Array(29);e(p);var m,g,b,w=new Array(r);function y(t,e,n,i,r){this.static_tree=t,this.extra_bits=e,this.extra_base=n,this.elems=i,this.max_length=r,this.has_stree=t&&t.length}function _(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}function v(t){return t<256?u[t]:u[256+(t>>>7)]}function x(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255}function k(t,e,n){t.bi_valid>16-n?(t.bi_buf|=e<<t.bi_valid&65535,x(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=n-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=n)}function A(t,e,n){k(t,n[2*e],n[2*e+1])}function M(t,e){var n=0;do{n|=1&t,t>>>=1,n<<=1}while(--e>0);return n>>>1}function E(t,e,n){var i,r,o=new Array(16),s=0;for(i=1;i<=a;i++)o[i]=s=s+n[i-1]<<1;for(r=0;r<=e;r++){var h=t[2*r+1];0!==h&&(t[2*r]=M(o[h]++,h))}}function I(t){var e;for(e=0;e<i;e++)t.dyn_ltree[2*e]=0;for(e=0;e<r;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0}function S(t){t.bi_valid>8?x(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0}function z(t,e,n,i){var r=2*e,a=2*n;return t[r]<t[a]||t[r]===t[a]&&i[e]<=i[n]}function B(t,e,n){for(var i=t.heap[n],r=n<<1;r<=t.heap_len&&(r<t.heap_len&&z(e,t.heap[r+1],t.heap[r],t.depth)&&r++,!z(e,i,t.heap[r],t.depth));)t.heap[n]=t.heap[r],n=r,r<<=1;t.heap[n]=i}function C(t,e,i){var r,a,h,c,l=0;if(0!==t.last_lit)do{r=t.pending_buf[t.d_buf+2*l]<<8|t.pending_buf[t.d_buf+2*l+1],a=t.pending_buf[t.l_buf+l],l++,0===r?A(t,a,e):(A(t,(h=d[a])+n+1,e),0!==(c=o[h])&&k(t,a-=p[h],c),A(t,h=v(--r),i),0!==(c=s[h])&&k(t,r-=w[h],c))}while(l<t.last_lit);A(t,256,e)}function P(t,e){var n,i,r,o=e.dyn_tree,s=e.stat_desc.static_tree,h=e.stat_desc.has_stree,c=e.stat_desc.elems,l=-1;for(t.heap_len=0,t.heap_max=573,n=0;n<c;n++)0!==o[2*n]?(t.heap[++t.heap_len]=l=n,t.depth[n]=0):o[2*n+1]=0;for(;t.heap_len<2;)o[2*(r=t.heap[++t.heap_len]=l<2?++l:0)]=1,t.depth[r]=0,t.opt_len--,h&&(t.static_len-=s[2*r+1]);for(e.max_code=l,n=t.heap_len>>1;n>=1;n--)B(t,o,n);r=c;do{n=t.heap[1],t.heap[1]=t.heap[t.heap_len--],B(t,o,1),i=t.heap[1],t.heap[--t.heap_max]=n,t.heap[--t.heap_max]=i,o[2*r]=o[2*n]+o[2*i],t.depth[r]=(t.depth[n]>=t.depth[i]?t.depth[n]:t.depth[i])+1,o[2*n+1]=o[2*i+1]=r,t.heap[1]=r++,B(t,o,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],function(t,e){var n,i,r,o,s,h,c=e.dyn_tree,l=e.max_code,f=e.stat_desc.static_tree,u=e.stat_desc.has_stree,d=e.stat_desc.extra_bits,p=e.stat_desc.extra_base,m=e.stat_desc.max_length,g=0;for(o=0;o<=a;o++)t.bl_count[o]=0;for(c[2*t.heap[t.heap_max]+1]=0,n=t.heap_max+1;n<573;n++)(o=c[2*c[2*(i=t.heap[n])+1]+1]+1)>m&&(o=m,g++),c[2*i+1]=o,i>l||(t.bl_count[o]++,s=0,i>=p&&(s=d[i-p]),h=c[2*i],t.opt_len+=h*(o+s),u&&(t.static_len+=h*(f[2*i+1]+s)));if(0!==g){do{for(o=m-1;0===t.bl_count[o];)o--;t.bl_count[o]--,t.bl_count[o+1]+=2,t.bl_count[m]--,g-=2}while(g>0);for(o=m;0!==o;o--)for(i=t.bl_count[o];0!==i;)(r=t.heap[--n])>l||(c[2*r+1]!==o&&(t.opt_len+=(o-c[2*r+1])*c[2*r],c[2*r+1]=o),i--)}}(t,e),E(o,l,t.bl_count)}function T(t,e,n){var i,r,a=-1,o=e[1],s=0,h=7,c=4;for(0===o&&(h=138,c=3),e[2*(n+1)+1]=65535,i=0;i<=n;i++)r=o,o=e[2*(i+1)+1],++s<h&&r===o||(s<c?t.bl_tree[2*r]+=s:0!==r?(r!==a&&t.bl_tree[2*r]++,t.bl_tree[32]++):s<=10?t.bl_tree[34]++:t.bl_tree[36]++,s=0,a=r,0===o?(h=138,c=3):r===o?(h=6,c=3):(h=7,c=4))}function U(t,e,n){var i,r,a=-1,o=e[1],s=0,h=7,c=4;for(0===o&&(h=138,c=3),i=0;i<=n;i++)if(r=o,o=e[2*(i+1)+1],!(++s<h&&r===o)){if(s<c)do{A(t,r,t.bl_tree)}while(0!==--s);else 0!==r?(r!==a&&(A(t,r,t.bl_tree),s--),A(t,16,t.bl_tree),k(t,s-3,2)):s<=10?(A(t,17,t.bl_tree),k(t,s-3,3)):(A(t,18,t.bl_tree),k(t,s-11,7));s=0,a=r,0===o?(h=138,c=3):r===o?(h=6,c=3):(h=7,c=4)}}e(w);var O=!1;function L(e,n,i,r){k(e,0+(r?1:0),3),function(e,n,i){S(e),x(e,i),x(e,~i),t.arraySet(e.pending_buf,e.window,n,i,e.pending),e.pending+=i}(e,n,i)}return Bg._tr_init=function(t){O||(!function(){var t,e,n,c,_,v=new Array(16);for(n=0,c=0;c<28;c++)for(p[c]=n,t=0;t<1<<o[c];t++)d[n++]=c;for(d[n-1]=c,_=0,c=0;c<16;c++)for(w[c]=_,t=0;t<1<<s[c];t++)u[_++]=c;for(_>>=7;c<r;c++)for(w[c]=_<<7,t=0;t<1<<s[c]-7;t++)u[256+_++]=c;for(e=0;e<=a;e++)v[e]=0;for(t=0;t<=143;)l[2*t+1]=8,t++,v[8]++;for(;t<=255;)l[2*t+1]=9,t++,v[9]++;for(;t<=279;)l[2*t+1]=7,t++,v[7]++;for(;t<=287;)l[2*t+1]=8,t++,v[8]++;for(E(l,287,v),t=0;t<r;t++)f[2*t+1]=5,f[2*t]=M(t,5);m=new y(l,o,257,i,a),g=new y(f,s,0,r,a),b=new y(new Array(0),h,0,19,7)}(),O=!0),t.l_desc=new _(t.dyn_ltree,m),t.d_desc=new _(t.dyn_dtree,g),t.bl_desc=new _(t.bl_tree,b),t.bi_buf=0,t.bi_valid=0,I(t)},Bg._tr_stored_block=L,Bg._tr_flush_block=function(t,e,i,r){var a,o,s=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=function(t){var e,i=4093624447;for(e=0;e<=31;e++,i>>>=1)if(1&i&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<n;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0}(t)),P(t,t.l_desc),P(t,t.d_desc),s=function(t){var e;for(T(t,t.dyn_ltree,t.l_desc.max_code),T(t,t.dyn_dtree,t.d_desc.max_code),P(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*c[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}(t),a=t.opt_len+3+7>>>3,(o=t.static_len+3+7>>>3)<=a&&(a=o)):a=o=i+5,i+4<=a&&-1!==e?L(t,e,i,r):4===t.strategy||o===a?(k(t,2+(r?1:0),3),C(t,l,f)):(k(t,4+(r?1:0),3),function(t,e,n,i){var r;for(k(t,e-257,5),k(t,n-1,5),k(t,i-4,4),r=0;r<i;r++)k(t,t.bl_tree[2*c[r]+1],3);U(t,t.dyn_ltree,e-1),U(t,t.dyn_dtree,n-1)}(t,t.l_desc.max_code+1,t.d_desc.max_code+1,s+1),C(t,t.dyn_ltree,t.dyn_dtree)),I(t),r&&S(t)},Bg._tr_tally=function(t,e,i){return t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&i,t.last_lit++,0===e?t.dyn_ltree[2*i]++:(t.matches++,e--,t.dyn_ltree[2*(d[i]+n+1)]++,t.dyn_dtree[2*v(e)]++),t.last_lit===t.lit_bufsize-1},Bg._tr_align=function(t){k(t,2,3),A(t,256,l),function(t){16===t.bi_valid?(x(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(t)},Bg}function Pg(){if(xg)return vg;return xg=1,vg=function(t,e,n,i){for(var r=65535&t,a=t>>>16&65535,o=0;0!==n;){n-=o=n>2e3?2e3:n;do{a=a+(r=r+e[i++]|0)|0}while(--o);r%=65521,a%=65521}return r|a<<16},vg}function Tg(){if(Ag)return kg;Ag=1;var t=function(){for(var t,e=[],n=0;n<256;n++){t=n;for(var i=0;i<8;i++)t=1&t?3988292384^t>>>1:t>>>1;e[n]=t}return e}();return kg=function(e,n,i,r){var a=t,o=r+i;e^=-1;for(var s=r;s<o;s++)e=e>>>8^a[255&(e^n[s])];return-1^e},kg}function Ug(){return Eg?Mg:(Eg=1,Mg={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 Og(){if(Ig)return zg;Ig=1;var t,e=yg(),n=Cg(),i=Pg(),r=Tg(),a=Ug(),o=-2,s=258,h=262,c=103,l=113,f=666;function u(t,e){return t.msg=a[e],e}function d(t){return(t<<1)-(t>4?9:0)}function p(t){for(var e=t.length;--e>=0;)t[e]=0}function m(t){var n=t.state,i=n.pending;i>t.avail_out&&(i=t.avail_out),0!==i&&(e.arraySet(t.output,n.pending_buf,n.pending_out,i,t.next_out),t.next_out+=i,n.pending_out+=i,t.total_out+=i,t.avail_out-=i,n.pending-=i,0===n.pending&&(n.pending_out=0))}function g(t,e){n._tr_flush_block(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,m(t.strm)}function b(t,e){t.pending_buf[t.pending++]=e}function w(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e}function y(t,n,a,o){var s=t.avail_in;return s>o&&(s=o),0===s?0:(t.avail_in-=s,e.arraySet(n,t.input,t.next_in,s,a),1===t.state.wrap?t.adler=i(t.adler,n,s,a):2===t.state.wrap&&(t.adler=r(t.adler,n,s,a)),t.next_in+=s,t.total_in+=s,s)}function _(t,e){var n,i,r=t.max_chain_length,a=t.strstart,o=t.prev_length,c=t.nice_match,l=t.strstart>t.w_size-h?t.strstart-(t.w_size-h):0,f=t.window,u=t.w_mask,d=t.prev,p=t.strstart+s,m=f[a+o-1],g=f[a+o];t.prev_length>=t.good_match&&(r>>=2),c>t.lookahead&&(c=t.lookahead);do{if(f[(n=e)+o]===g&&f[n+o-1]===m&&f[n]===f[a]&&f[++n]===f[a+1]){a+=2,n++;do{}while(f[++a]===f[++n]&&f[++a]===f[++n]&&f[++a]===f[++n]&&f[++a]===f[++n]&&f[++a]===f[++n]&&f[++a]===f[++n]&&f[++a]===f[++n]&&f[++a]===f[++n]&&a<p);if(i=s-(p-a),a=p-s,i>o){if(t.match_start=e,o=i,i>=c)break;m=f[a+o-1],g=f[a+o]}}}while((e=d[e&u])>l&&0!==--r);return o<=t.lookahead?o:t.lookahead}function v(t){var n,i,r,a,o,s=t.w_size;do{if(a=t.window_size-t.lookahead-t.strstart,t.strstart>=s+(s-h)){e.arraySet(t.window,t.window,s,s,0),t.match_start-=s,t.strstart-=s,t.block_start-=s,n=i=t.hash_size;do{r=t.head[--n],t.head[n]=r>=s?r-s:0}while(--i);n=i=s;do{r=t.prev[--n],t.prev[n]=r>=s?r-s:0}while(--i);a+=s}if(0===t.strm.avail_in)break;if(i=y(t.strm,t.window,t.strstart+t.lookahead,a),t.lookahead+=i,t.lookahead+t.insert>=3)for(o=t.strstart-t.insert,t.ins_h=t.window[o],t.ins_h=(t.ins_h<<t.hash_shift^t.window[o+1])&t.hash_mask;t.insert&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[o+3-1])&t.hash_mask,t.prev[o&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=o,o++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<h&&0!==t.strm.avail_in)}function x(t,e){for(var i,r;;){if(t.lookahead<h){if(v(t),t.lookahead<h&&0===e)return 1;if(0===t.lookahead)break}if(i=0,t.lookahead>=3&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==i&&t.strstart-i<=t.w_size-h&&(t.match_length=_(t,i)),t.match_length>=3)if(r=n._tr_tally(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!==--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+1])&t.hash_mask;else r=n._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(r&&(g(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,4===e?(g(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(g(t,!1),0===t.strm.avail_out)?1:2}function k(t,e){for(var i,r,a;;){if(t.lookahead<h){if(v(t),t.lookahead<h&&0===e)return 1;if(0===t.lookahead)break}if(i=0,t.lookahead>=3&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==i&&t.prev_length<t.max_lazy_match&&t.strstart-i<=t.w_size-h&&(t.match_length=_(t,i),t.match_length<=5&&(1===t.strategy||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){a=t.strstart+t.lookahead-3,r=n._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=a&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!==--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,r&&(g(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if((r=n._tr_tally(t,0,t.window[t.strstart-1]))&&g(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(r=n._tr_tally(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,4===e?(g(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(g(t,!1),0===t.strm.avail_out)?1:2}function A(t,e,n,i,r){this.good_length=t,this.max_lazy=e,this.nice_length=n,this.max_chain=i,this.func=r}function M(){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=8,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 e.Buf16(1146),this.dyn_dtree=new e.Buf16(122),this.bl_tree=new e.Buf16(78),p(this.dyn_ltree),p(this.dyn_dtree),p(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new e.Buf16(16),this.heap=new e.Buf16(573),p(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new e.Buf16(573),p(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 E(t){var e;return t&&t.state?(t.total_in=t.total_out=0,t.data_type=2,(e=t.state).pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:l,t.adler=2===e.wrap?0:1,e.last_flush=0,n._tr_init(e),0):u(t,o)}function I(e){var n=E(e);return 0===n&&function(e){e.window_size=2*e.w_size,p(e.head),e.max_lazy_match=t[e.level].max_lazy,e.good_match=t[e.level].good_length,e.nice_match=t[e.level].nice_length,e.max_chain_length=t[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=2,e.match_available=0,e.ins_h=0}(e.state),n}function S(t,n,i,r,a,s){if(!t)return o;var h=1;if(-1===n&&(n=6),r<0?(h=0,r=-r):r>15&&(h=2,r-=16),a<1||a>9||8!==i||r<8||r>15||n<0||n>9||s<0||s>4)return u(t,o);8===r&&(r=9);var c=new M;return t.state=c,c.strm=t,c.wrap=h,c.gzhead=null,c.w_bits=r,c.w_size=1<<c.w_bits,c.w_mask=c.w_size-1,c.hash_bits=a+7,c.hash_size=1<<c.hash_bits,c.hash_mask=c.hash_size-1,c.hash_shift=~~((c.hash_bits+3-1)/3),c.window=new e.Buf8(2*c.w_size),c.head=new e.Buf16(c.hash_size),c.prev=new e.Buf16(c.w_size),c.lit_bufsize=1<<a+6,c.pending_buf_size=4*c.lit_bufsize,c.pending_buf=new e.Buf8(c.pending_buf_size),c.d_buf=1*c.lit_bufsize,c.l_buf=3*c.lit_bufsize,c.level=n,c.strategy=s,c.method=i,I(t)}return t=[new A(0,0,0,0,function(t,e){var n=65535;for(n>t.pending_buf_size-5&&(n=t.pending_buf_size-5);;){if(t.lookahead<=1){if(v(t),0===t.lookahead&&0===e)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var i=t.block_start+n;if((0===t.strstart||t.strstart>=i)&&(t.lookahead=t.strstart-i,t.strstart=i,g(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-h&&(g(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(g(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(g(t,!1),t.strm.avail_out),1)}),new A(4,4,8,4,x),new A(4,5,16,8,x),new A(4,6,32,32,x),new A(4,4,16,16,k),new A(8,16,32,32,k),new A(8,16,128,128,k),new A(8,32,128,256,k),new A(32,128,258,1024,k),new A(32,258,258,4096,k)],zg.deflateInit=function(t,e){return S(t,e,8,15,8,0)},zg.deflateInit2=S,zg.deflateReset=I,zg.deflateResetKeep=E,zg.deflateSetHeader=function(t,e){return t&&t.state?2!==t.state.wrap?o:(t.state.gzhead=e,0):o},zg.deflate=function(e,i){var a,h,y,_;if(!e||!e.state||i>5||i<0)return e?u(e,o):o;if(h=e.state,!e.output||!e.input&&0!==e.avail_in||h.status===f&&4!==i)return u(e,0===e.avail_out?-5:o);if(h.strm=e,a=h.last_flush,h.last_flush=i,42===h.status)if(2===h.wrap)e.adler=0,b(h,31),b(h,139),b(h,8),h.gzhead?(b(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)),b(h,255&h.gzhead.time),b(h,h.gzhead.time>>8&255),b(h,h.gzhead.time>>16&255),b(h,h.gzhead.time>>24&255),b(h,9===h.level?2:h.strategy>=2||h.level<2?4:0),b(h,255&h.gzhead.os),h.gzhead.extra&&h.gzhead.extra.length&&(b(h,255&h.gzhead.extra.length),b(h,h.gzhead.extra.length>>8&255)),h.gzhead.hcrc&&(e.adler=r(e.adler,h.pending_buf,h.pending,0)),h.gzindex=0,h.status=69):(b(h,0),b(h,0),b(h,0),b(h,0),b(h,0),b(h,9===h.level?2:h.strategy>=2||h.level<2?4:0),b(h,3),h.status=l);else{var x=8+(h.w_bits-8<<4)<<8;x|=(h.strategy>=2||h.level<2?0:h.level<6?1:6===h.level?2:3)<<6,0!==h.strstart&&(x|=32),x+=31-x%31,h.status=l,w(h,x),0!==h.strstart&&(w(h,e.adler>>>16),w(h,65535&e.adler)),e.adler=1}if(69===h.status)if(h.gzhead.extra){for(y=h.pending;h.gzindex<(65535&h.gzhead.extra.length)&&(h.pending!==h.pending_buf_size||(h.gzhead.hcrc&&h.pending>y&&(e.adler=r(e.adler,h.pending_buf,h.pending-y,y)),m(e),y=h.pending,h.pending!==h.pending_buf_size));)b(h,255&h.gzhead.extra[h.gzindex]),h.gzindex++;h.gzhead.hcrc&&h.pending>y&&(e.adler=r(e.adler,h.pending_buf,h.pending-y,y)),h.gzindex===h.gzhead.extra.length&&(h.gzindex=0,h.status=73)}else h.status=73;if(73===h.status)if(h.gzhead.name){y=h.pending;do{if(h.pending===h.pending_buf_size&&(h.gzhead.hcrc&&h.pending>y&&(e.adler=r(e.adler,h.pending_buf,h.pending-y,y)),m(e),y=h.pending,h.pending===h.pending_buf_size)){_=1;break}_=h.gzindex<h.gzhead.name.length?255&h.gzhead.name.charCodeAt(h.gzindex++):0,b(h,_)}while(0!==_);h.gzhead.hcrc&&h.pending>y&&(e.adler=r(e.adler,h.pending_buf,h.pending-y,y)),0===_&&(h.gzindex=0,h.status=91)}else h.status=91;if(91===h.status)if(h.gzhead.comment){y=h.pending;do{if(h.pending===h.pending_buf_size&&(h.gzhead.hcrc&&h.pending>y&&(e.adler=r(e.adler,h.pending_buf,h.pending-y,y)),m(e),y=h.pending,h.pending===h.pending_buf_size)){_=1;break}_=h.gzindex<h.gzhead.comment.length?255&h.gzhead.comment.charCodeAt(h.gzindex++):0,b(h,_)}while(0!==_);h.gzhead.hcrc&&h.pending>y&&(e.adler=r(e.adler,h.pending_buf,h.pending-y,y)),0===_&&(h.status=c)}else h.status=c;if(h.status===c&&(h.gzhead.hcrc?(h.pending+2>h.pending_buf_size&&m(e),h.pending+2<=h.pending_buf_size&&(b(h,255&e.adler),b(h,e.adler>>8&255),e.adler=0,h.status=l)):h.status=l),0!==h.pending){if(m(e),0===e.avail_out)return h.last_flush=-1,0}else if(0===e.avail_in&&d(i)<=d(a)&&4!==i)return u(e,-5);if(h.status===f&&0!==e.avail_in)return u(e,-5);if(0!==e.avail_in||0!==h.lookahead||0!==i&&h.status!==f){var k=2===h.strategy?function(t,e){for(var i;;){if(0===t.lookahead&&(v(t),0===t.lookahead)){if(0===e)return 1;break}if(t.match_length=0,i=n._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,i&&(g(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(g(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(g(t,!1),0===t.strm.avail_out)?1:2}(h,i):3===h.strategy?function(t,e){for(var i,r,a,o,h=t.window;;){if(t.lookahead<=s){if(v(t),t.lookahead<=s&&0===e)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(r=h[a=t.strstart-1])===h[++a]&&r===h[++a]&&r===h[++a]){o=t.strstart+s;do{}while(r===h[++a]&&r===h[++a]&&r===h[++a]&&r===h[++a]&&r===h[++a]&&r===h[++a]&&r===h[++a]&&r===h[++a]&&a<o);t.match_length=s-(o-a),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(i=n._tr_tally(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(i=n._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),i&&(g(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(g(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(g(t,!1),0===t.strm.avail_out)?1:2}(h,i):t[h.level].func(h,i);if(3!==k&&4!==k||(h.status=f),1===k||3===k)return 0===e.avail_out&&(h.last_flush=-1),0;if(2===k&&(1===i?n._tr_align(h):5!==i&&(n._tr_stored_block(h,0,0,!1),3===i&&(p(h.head),0===h.lookahead&&(h.strstart=0,h.block_start=0,h.insert=0))),m(e),0===e.avail_out))return h.last_flush=-1,0}return 4!==i?0:h.wrap<=0?1:(2===h.wrap?(b(h,255&e.adler),b(h,e.adler>>8&255),b(h,e.adler>>16&255),b(h,e.adler>>24&255),b(h,255&e.total_in),b(h,e.total_in>>8&255),b(h,e.total_in>>16&255),b(h,e.total_in>>24&255)):(w(h,e.adler>>>16),w(h,65535&e.adler)),m(e),h.wrap>0&&(h.wrap=-h.wrap),0!==h.pending?0:1)},zg.deflateEnd=function(t){var e;return t&&t.state?42!==(e=t.state.status)&&69!==e&&73!==e&&91!==e&&e!==c&&e!==l&&e!==f?u(t,o):(t.state=null,e===l?u(t,-3):0):o},zg.deflateSetDictionary=function(t,n){var r,a,s,h,c,l,f,u,d=n.length;if(!t||!t.state)return o;if(2===(h=(r=t.state).wrap)||1===h&&42!==r.status||r.lookahead)return o;for(1===h&&(t.adler=i(t.adler,n,d,0)),r.wrap=0,d>=r.w_size&&(0===h&&(p(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new e.Buf8(r.w_size),e.arraySet(u,n,d-r.w_size,r.w_size,0),n=u,d=r.w_size),c=t.avail_in,l=t.next_in,f=t.input,t.avail_in=d,t.next_in=0,t.input=n,v(r);r.lookahead>=3;){a=r.strstart,s=r.lookahead-2;do{r.ins_h=(r.ins_h<<r.hash_shift^r.window[a+3-1])&r.hash_mask,r.prev[a&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=a,a++}while(--s);r.strstart=a,r.lookahead=2,v(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,t.next_in=l,t.input=f,t.avail_in=c,r.wrap=h,0},zg.deflateInfo="pako deflate (from Nodeca project)",zg}var Lg,Rg,Fg,Dg,Ng={};function $g(){if(Lg)return Ng;Lg=1;var t=yg(),e=!0,n=!0;try{String.fromCharCode.apply(null,[0])}catch(t){e=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){n=!1}for(var i=new t.Buf8(256),r=0;r<256;r++)i[r]=r>=252?6:r>=248?5:r>=240?4:r>=224?3:r>=192?2:1;function a(i,r){if(r<65534&&(i.subarray&&n||!i.subarray&&e))return String.fromCharCode.apply(null,t.shrinkBuf(i,r));for(var a="",o=0;o<r;o++)a+=String.fromCharCode(i[o]);return a}return i[254]=i[254]=1,Ng.string2buf=function(e){var n,i,r,a,o,s=e.length,h=0;for(a=0;a<s;a++)55296==(64512&(i=e.charCodeAt(a)))&&a+1<s&&56320==(64512&(r=e.charCodeAt(a+1)))&&(i=65536+(i-55296<<10)+(r-56320),a++),h+=i<128?1:i<2048?2:i<65536?3:4;for(n=new t.Buf8(h),o=0,a=0;o<h;a++)55296==(64512&(i=e.charCodeAt(a)))&&a+1<s&&56320==(64512&(r=e.charCodeAt(a+1)))&&(i=65536+(i-55296<<10)+(r-56320),a++),i<128?n[o++]=i:i<2048?(n[o++]=192|i>>>6,n[o++]=128|63&i):i<65536?(n[o++]=224|i>>>12,n[o++]=128|i>>>6&63,n[o++]=128|63&i):(n[o++]=240|i>>>18,n[o++]=128|i>>>12&63,n[o++]=128|i>>>6&63,n[o++]=128|63&i);return n},Ng.buf2binstring=function(t){return a(t,t.length)},Ng.binstring2buf=function(e){for(var n=new t.Buf8(e.length),i=0,r=n.length;i<r;i++)n[i]=e.charCodeAt(i);return n},Ng.buf2string=function(t,e){var n,r,o,s,h=e||t.length,c=new Array(2*h);for(r=0,n=0;n<h;)if((o=t[n++])<128)c[r++]=o;else if((s=i[o])>4)c[r++]=65533,n+=s-1;else{for(o&=2===s?31:3===s?15:7;s>1&&n<h;)o=o<<6|63&t[n++],s--;s>1?c[r++]=65533:o<65536?c[r++]=o:(o-=65536,c[r++]=55296|o>>10&1023,c[r++]=56320|1023&o)}return a(c,r)},Ng.utf8border=function(t,e){var n;for((e=e||t.length)>t.length&&(e=t.length),n=e-1;n>=0&&128==(192&t[n]);)n--;return n<0||0===n?e:n+i[t[n]]>e?n:e},Ng}function jg(){if(Fg)return Rg;return Fg=1,Rg=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}}var Gg,Hg,Zg,qg,Wg,Vg,Jg,Yg,Xg,Kg,Qg,tb,eb,nb={},ib={};function rb(){if(Wg)return ib;Wg=1;var t=yg(),e=Pg(),n=Tg(),i=(Hg||(Hg=1,Gg=function(t,e){var n,i,r,a,o,s,h,c,l,f,u,d,p,m,g,b,w,y,_,v,x,k,A,M,E;n=t.state,i=t.next_in,M=t.input,r=i+(t.avail_in-5),a=t.next_out,E=t.output,o=a-(e-t.avail_out),s=a+(t.avail_out-257),h=n.dmax,c=n.wsize,l=n.whave,f=n.wnext,u=n.window,d=n.hold,p=n.bits,m=n.lencode,g=n.distcode,b=(1<<n.lenbits)-1,w=(1<<n.distbits)-1;t:do{p<15&&(d+=M[i++]<<p,p+=8,d+=M[i++]<<p,p+=8),y=m[d&b];e:for(;;){if(d>>>=_=y>>>24,p-=_,0==(_=y>>>16&255))E[a++]=65535&y;else{if(!(16&_)){if(64&_){if(32&_){n.mode=12;break t}t.msg="invalid literal/length code",n.mode=30;break t}y=m[(65535&y)+(d&(1<<_)-1)];continue e}for(v=65535&y,(_&=15)&&(p<_&&(d+=M[i++]<<p,p+=8),v+=d&(1<<_)-1,d>>>=_,p-=_),p<15&&(d+=M[i++]<<p,p+=8,d+=M[i++]<<p,p+=8),y=g[d&w];;){if(d>>>=_=y>>>24,p-=_,16&(_=y>>>16&255)){if(x=65535&y,p<(_&=15)&&(d+=M[i++]<<p,(p+=8)<_&&(d+=M[i++]<<p,p+=8)),(x+=d&(1<<_)-1)>h){t.msg="invalid distance too far back",n.mode=30;break t}if(d>>>=_,p-=_,x>(_=a-o)){if((_=x-_)>l&&n.sane){t.msg="invalid distance too far back",n.mode=30;break t}if(k=0,A=u,0===f){if(k+=c-_,_<v){v-=_;do{E[a++]=u[k++]}while(--_);k=a-x,A=E}}else if(f<_){if(k+=c+f-_,(_-=f)<v){v-=_;do{E[a++]=u[k++]}while(--_);if(k=0,f<v){v-=_=f;do{E[a++]=u[k++]}while(--_);k=a-x,A=E}}}else if(k+=f-_,_<v){v-=_;do{E[a++]=u[k++]}while(--_);k=a-x,A=E}for(;v>2;)E[a++]=A[k++],E[a++]=A[k++],E[a++]=A[k++],v-=3;v&&(E[a++]=A[k++],v>1&&(E[a++]=A[k++]))}else{k=a-x;do{E[a++]=E[k++],E[a++]=E[k++],E[a++]=E[k++],v-=3}while(v>2);v&&(E[a++]=E[k++],v>1&&(E[a++]=E[k++]))}break}if(64&_){t.msg="invalid distance code",n.mode=30;break t}y=g[(65535&y)+(d&(1<<_)-1)]}}break}}while(i<r&&a<s);i-=v=p>>3,d&=(1<<(p-=v<<3))-1,t.next_in=i,t.next_out=a,t.avail_in=i<r?r-i+5:5-(i-r),t.avail_out=a<s?s-a+257:257-(a-s),n.hold=d,n.bits=p}),Gg),r=function(){if(qg)return Zg;qg=1;var t=yg(),e=15,n=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],i=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],r=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],a=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];return Zg=function(o,s,h,c,l,f,u,d){var p,m,g,b,w,y,_,v,x,k=d.bits,A=0,M=0,E=0,I=0,S=0,z=0,B=0,C=0,P=0,T=0,U=null,O=0,L=new t.Buf16(16),R=new t.Buf16(16),F=null,D=0;for(A=0;A<=e;A++)L[A]=0;for(M=0;M<c;M++)L[s[h+M]]++;for(S=k,I=e;I>=1&&0===L[I];I--);if(S>I&&(S=I),0===I)return l[f++]=20971520,l[f++]=20971520,d.bits=1,0;for(E=1;E<I&&0===L[E];E++);for(S<E&&(S=E),C=1,A=1;A<=e;A++)if(C<<=1,(C-=L[A])<0)return-1;if(C>0&&(0===o||1!==I))return-1;for(R[1]=0,A=1;A<e;A++)R[A+1]=R[A]+L[A];for(M=0;M<c;M++)0!==s[h+M]&&(u[R[s[h+M]]++]=M);if(0===o?(U=F=u,y=19):1===o?(U=n,O-=257,F=i,D-=257,y=256):(U=r,F=a,y=-1),T=0,M=0,A=E,w=f,z=S,B=0,g=-1,b=(P=1<<S)-1,1===o&&P>852||2===o&&P>592)return 1;for(;;){_=A-B,u[M]<y?(v=0,x=u[M]):u[M]>y?(v=F[D+u[M]],x=U[O+u[M]]):(v=96,x=0),p=1<<A-B,E=m=1<<z;do{l[w+(T>>B)+(m-=p)]=_<<24|v<<16|x}while(0!==m);for(p=1<<A-1;T&p;)p>>=1;if(0!==p?(T&=p-1,T+=p):T=0,M++,0===--L[A]){if(A===I)break;A=s[h+u[M]]}if(A>S&&(T&b)!==g){for(0===B&&(B=S),w+=E,C=1<<(z=A-B);z+B<I&&!((C-=L[z+B])<=0);)z++,C<<=1;if(P+=1<<z,1===o&&P>852||2===o&&P>592)return 1;l[g=T&b]=S<<24|z<<16|w-f}}return 0!==T&&(l[w+T]=A-B<<24|64<<16),d.bits=S,0},Zg}(),a=-2,o=12,s=30;function h(t){return(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function c(){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 t.Buf16(320),this.work=new t.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function l(e){var n;return e&&e.state?(n=e.state,e.total_in=e.total_out=n.total=0,e.msg="",n.wrap&&(e.adler=1&n.wrap),n.mode=1,n.last=0,n.havedict=0,n.dmax=32768,n.head=null,n.hold=0,n.bits=0,n.lencode=n.lendyn=new t.Buf32(852),n.distcode=n.distdyn=new t.Buf32(592),n.sane=1,n.back=-1,0):a}function f(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,l(t)):a}function u(t,e){var n,i;return t&&t.state?(i=t.state,e<0?(n=0,e=-e):(n=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?a:(null!==i.window&&i.wbits!==e&&(i.window=null),i.wrap=n,i.wbits=e,f(t))):a}function d(t,e){var n,i;return t?(i=new c,t.state=i,i.window=null,0!==(n=u(t,e))&&(t.state=null),n):a}var p,m,g=!0;function b(e){if(g){var n;for(p=new t.Buf32(512),m=new t.Buf32(32),n=0;n<144;)e.lens[n++]=8;for(;n<256;)e.lens[n++]=9;for(;n<280;)e.lens[n++]=7;for(;n<288;)e.lens[n++]=8;for(r(1,e.lens,0,288,p,0,e.work,{bits:9}),n=0;n<32;)e.lens[n++]=5;r(2,e.lens,0,32,m,0,e.work,{bits:5}),g=!1}e.lencode=p,e.lenbits=9,e.distcode=m,e.distbits=5}function w(e,n,i,r){var a,o=e.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new t.Buf8(o.wsize)),r>=o.wsize?(t.arraySet(o.window,n,i-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):((a=o.wsize-o.wnext)>r&&(a=r),t.arraySet(o.window,n,i-r,a,o.wnext),(r-=a)?(t.arraySet(o.window,n,i-r,r,0),o.wnext=r,o.whave=o.wsize):(o.wnext+=a,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=a))),0}return ib.inflateReset=f,ib.inflateReset2=u,ib.inflateResetKeep=l,ib.inflateInit=function(t){return d(t,15)},ib.inflateInit2=d,ib.inflate=function(c,l){var f,u,d,p,m,g,y,_,v,x,k,A,M,E,I,S,z,B,C,P,T,U,O,L,R=0,F=new t.Buf8(4),D=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!c||!c.state||!c.output||!c.input&&0!==c.avail_in)return a;(f=c.state).mode===o&&(f.mode=13),m=c.next_out,d=c.output,y=c.avail_out,p=c.next_in,u=c.input,g=c.avail_in,_=f.hold,v=f.bits,x=g,k=y,U=0;t:for(;;)switch(f.mode){case 1:if(0===f.wrap){f.mode=13;break}for(;v<16;){if(0===g)break t;g--,_+=u[p++]<<v,v+=8}if(2&f.wrap&&35615===_){f.check=0,F[0]=255&_,F[1]=_>>>8&255,f.check=n(f.check,F,2,0),_=0,v=0,f.mode=2;break}if(f.flags=0,f.head&&(f.head.done=!1),!(1&f.wrap)||(((255&_)<<8)+(_>>8))%31){c.msg="incorrect header check",f.mode=s;break}if(8!=(15&_)){c.msg="unknown compression method",f.mode=s;break}if(v-=4,T=8+(15&(_>>>=4)),0===f.wbits)f.wbits=T;else if(T>f.wbits){c.msg="invalid window size",f.mode=s;break}f.dmax=1<<T,c.adler=f.check=1,f.mode=512&_?10:o,_=0,v=0;break;case 2:for(;v<16;){if(0===g)break t;g--,_+=u[p++]<<v,v+=8}if(f.flags=_,8!=(255&f.flags)){c.msg="unknown compression method",f.mode=s;break}if(57344&f.flags){c.msg="unknown header flags set",f.mode=s;break}f.head&&(f.head.text=_>>8&1),512&f.flags&&(F[0]=255&_,F[1]=_>>>8&255,f.check=n(f.check,F,2,0)),_=0,v=0,f.mode=3;case 3:for(;v<32;){if(0===g)break t;g--,_+=u[p++]<<v,v+=8}f.head&&(f.head.time=_),512&f.flags&&(F[0]=255&_,F[1]=_>>>8&255,F[2]=_>>>16&255,F[3]=_>>>24&255,f.check=n(f.check,F,4,0)),_=0,v=0,f.mode=4;case 4:for(;v<16;){if(0===g)break t;g--,_+=u[p++]<<v,v+=8}f.head&&(f.head.xflags=255&_,f.head.os=_>>8),512&f.flags&&(F[0]=255&_,F[1]=_>>>8&255,f.check=n(f.check,F,2,0)),_=0,v=0,f.mode=5;case 5:if(1024&f.flags){for(;v<16;){if(0===g)break t;g--,_+=u[p++]<<v,v+=8}f.length=_,f.head&&(f.head.extra_len=_),512&f.flags&&(F[0]=255&_,F[1]=_>>>8&255,f.check=n(f.check,F,2,0)),_=0,v=0}else f.head&&(f.head.extra=null);f.mode=6;case 6:if(1024&f.flags&&((A=f.length)>g&&(A=g),A&&(f.head&&(T=f.head.extra_len-f.length,f.head.extra||(f.head.extra=new Array(f.head.extra_len)),t.arraySet(f.head.extra,u,p,A,T)),512&f.flags&&(f.check=n(f.check,u,A,p)),g-=A,p+=A,f.length-=A),f.length))break t;f.length=0,f.mode=7;case 7:if(2048&f.flags){if(0===g)break t;A=0;do{T=u[p+A++],f.head&&T&&f.length<65536&&(f.head.name+=String.fromCharCode(T))}while(T&&A<g);if(512&f.flags&&(f.check=n(f.check,u,A,p)),g-=A,p+=A,T)break t}else f.head&&(f.head.name=null);f.length=0,f.mode=8;case 8:if(4096&f.flags){if(0===g)break t;A=0;do{T=u[p+A++],f.head&&T&&f.length<65536&&(f.head.comment+=String.fromCharCode(T))}while(T&&A<g);if(512&f.flags&&(f.check=n(f.check,u,A,p)),g-=A,p+=A,T)break t}else f.head&&(f.head.comment=null);f.mode=9;case 9:if(512&f.flags){for(;v<16;){if(0===g)break t;g--,_+=u[p++]<<v,v+=8}if(_!==(65535&f.check)){c.msg="header crc mismatch",f.mode=s;break}_=0,v=0}f.head&&(f.head.hcrc=f.flags>>9&1,f.head.done=!0),c.adler=f.check=0,f.mode=o;break;case 10:for(;v<32;){if(0===g)break t;g--,_+=u[p++]<<v,v+=8}c.adler=f.check=h(_),_=0,v=0,f.mode=11;case 11:if(0===f.havedict)return c.next_out=m,c.avail_out=y,c.next_in=p,c.avail_in=g,f.hold=_,f.bits=v,2;c.adler=f.check=1,f.mode=o;case o:if(5===l||6===l)break t;case 13:if(f.last){_>>>=7&v,v-=7&v,f.mode=27;break}for(;v<3;){if(0===g)break t;g--,_+=u[p++]<<v,v+=8}switch(f.last=1&_,v-=1,3&(_>>>=1)){case 0:f.mode=14;break;case 1:if(b(f),f.mode=20,6===l){_>>>=2,v-=2;break t}break;case 2:f.mode=17;break;case 3:c.msg="invalid block type",f.mode=s}_>>>=2,v-=2;break;case 14:for(_>>>=7&v,v-=7&v;v<32;){if(0===g)break t;g--,_+=u[p++]<<v,v+=8}if((65535&_)!=(_>>>16^65535)){c.msg="invalid stored block lengths",f.mode=s;break}if(f.length=65535&_,_=0,v=0,f.mode=15,6===l)break t;case 15:f.mode=16;case 16:if(A=f.length){if(A>g&&(A=g),A>y&&(A=y),0===A)break t;t.arraySet(d,u,p,A,m),g-=A,p+=A,y-=A,m+=A,f.length-=A;break}f.mode=o;break;case 17:for(;v<14;){if(0===g)break t;g--,_+=u[p++]<<v,v+=8}if(f.nlen=257+(31&_),_>>>=5,v-=5,f.ndist=1+(31&_),_>>>=5,v-=5,f.ncode=4+(15&_),_>>>=4,v-=4,f.nlen>286||f.ndist>30){c.msg="too many length or distance symbols",f.mode=s;break}f.have=0,f.mode=18;case 18:for(;f.have<f.ncode;){for(;v<3;){if(0===g)break t;g--,_+=u[p++]<<v,v+=8}f.lens[D[f.have++]]=7&_,_>>>=3,v-=3}for(;f.have<19;)f.lens[D[f.have++]]=0;if(f.lencode=f.lendyn,f.lenbits=7,O={bits:f.lenbits},U=r(0,f.lens,0,19,f.lencode,0,f.work,O),f.lenbits=O.bits,U){c.msg="invalid code lengths set",f.mode=s;break}f.have=0,f.mode=19;case 19:for(;f.have<f.nlen+f.ndist;){for(;S=(R=f.lencode[_&(1<<f.lenbits)-1])>>>16&255,z=65535&R,!((I=R>>>24)<=v);){if(0===g)break t;g--,_+=u[p++]<<v,v+=8}if(z<16)_>>>=I,v-=I,f.lens[f.have++]=z;else{if(16===z){for(L=I+2;v<L;){if(0===g)break t;g--,_+=u[p++]<<v,v+=8}if(_>>>=I,v-=I,0===f.have){c.msg="invalid bit length repeat",f.mode=s;break}T=f.lens[f.have-1],A=3+(3&_),_>>>=2,v-=2}else if(17===z){for(L=I+3;v<L;){if(0===g)break t;g--,_+=u[p++]<<v,v+=8}v-=I,T=0,A=3+(7&(_>>>=I)),_>>>=3,v-=3}else{for(L=I+7;v<L;){if(0===g)break t;g--,_+=u[p++]<<v,v+=8}v-=I,T=0,A=11+(127&(_>>>=I)),_>>>=7,v-=7}if(f.have+A>f.nlen+f.ndist){c.msg="invalid bit length repeat",f.mode=s;break}for(;A--;)f.lens[f.have++]=T}}if(f.mode===s)break;if(0===f.lens[256]){c.msg="invalid code -- missing end-of-block",f.mode=s;break}if(f.lenbits=9,O={bits:f.lenbits},U=r(1,f.lens,0,f.nlen,f.lencode,0,f.work,O),f.lenbits=O.bits,U){c.msg="invalid literal/lengths set",f.mode=s;break}if(f.distbits=6,f.distcode=f.distdyn,O={bits:f.distbits},U=r(2,f.lens,f.nlen,f.ndist,f.distcode,0,f.work,O),f.distbits=O.bits,U){c.msg="invalid distances set",f.mode=s;break}if(f.mode=20,6===l)break t;case 20:f.mode=21;case 21:if(g>=6&&y>=258){c.next_out=m,c.avail_out=y,c.next_in=p,c.avail_in=g,f.hold=_,f.bits=v,i(c,k),m=c.next_out,d=c.output,y=c.avail_out,p=c.next_in,u=c.input,g=c.avail_in,_=f.hold,v=f.bits,f.mode===o&&(f.back=-1);break}for(f.back=0;S=(R=f.lencode[_&(1<<f.lenbits)-1])>>>16&255,z=65535&R,!((I=R>>>24)<=v);){if(0===g)break t;g--,_+=u[p++]<<v,v+=8}if(S&&!(240&S)){for(B=I,C=S,P=z;S=(R=f.lencode[P+((_&(1<<B+C)-1)>>B)])>>>16&255,z=65535&R,!(B+(I=R>>>24)<=v);){if(0===g)break t;g--,_+=u[p++]<<v,v+=8}_>>>=B,v-=B,f.back+=B}if(_>>>=I,v-=I,f.back+=I,f.length=z,0===S){f.mode=26;break}if(32&S){f.back=-1,f.mode=o;break}if(64&S){c.msg="invalid literal/length code",f.mode=s;break}f.extra=15&S,f.mode=22;case 22:if(f.extra){for(L=f.extra;v<L;){if(0===g)break t;g--,_+=u[p++]<<v,v+=8}f.length+=_&(1<<f.extra)-1,_>>>=f.extra,v-=f.extra,f.back+=f.extra}f.was=f.length,f.mode=23;case 23:for(;S=(R=f.distcode[_&(1<<f.distbits)-1])>>>16&255,z=65535&R,!((I=R>>>24)<=v);){if(0===g)break t;g--,_+=u[p++]<<v,v+=8}if(!(240&S)){for(B=I,C=S,P=z;S=(R=f.distcode[P+((_&(1<<B+C)-1)>>B)])>>>16&255,z=65535&R,!(B+(I=R>>>24)<=v);){if(0===g)break t;g--,_+=u[p++]<<v,v+=8}_>>>=B,v-=B,f.back+=B}if(_>>>=I,v-=I,f.back+=I,64&S){c.msg="invalid distance code",f.mode=s;break}f.offset=z,f.extra=15&S,f.mode=24;case 24:if(f.extra){for(L=f.extra;v<L;){if(0===g)break t;g--,_+=u[p++]<<v,v+=8}f.offset+=_&(1<<f.extra)-1,_>>>=f.extra,v-=f.extra,f.back+=f.extra}if(f.offset>f.dmax){c.msg="invalid distance too far back",f.mode=s;break}f.mode=25;case 25:if(0===y)break t;if(A=k-y,f.offset>A){if((A=f.offset-A)>f.whave&&f.sane){c.msg="invalid distance too far back",f.mode=s;break}A>f.wnext?(A-=f.wnext,M=f.wsize-A):M=f.wnext-A,A>f.length&&(A=f.length),E=f.window}else E=d,M=m-f.offset,A=f.length;A>y&&(A=y),y-=A,f.length-=A;do{d[m++]=E[M++]}while(--A);0===f.length&&(f.mode=21);break;case 26:if(0===y)break t;d[m++]=f.length,y--,f.mode=21;break;case 27:if(f.wrap){for(;v<32;){if(0===g)break t;g--,_|=u[p++]<<v,v+=8}if(k-=y,c.total_out+=k,f.total+=k,k&&(c.adler=f.check=f.flags?n(f.check,d,k,m-k):e(f.check,d,k,m-k)),k=y,(f.flags?_:h(_))!==f.check){c.msg="incorrect data check",f.mode=s;break}_=0,v=0}f.mode=28;case 28:if(f.wrap&&f.flags){for(;v<32;){if(0===g)break t;g--,_+=u[p++]<<v,v+=8}if(_!==(4294967295&f.total)){c.msg="incorrect length check",f.mode=s;break}_=0,v=0}f.mode=29;case 29:U=1;break t;case s:U=-3;break t;case 31:return-4;default:return a}return c.next_out=m,c.avail_out=y,c.next_in=p,c.avail_in=g,f.hold=_,f.bits=v,(f.wsize||k!==c.avail_out&&f.mode<s&&(f.mode<27||4!==l))&&w(c,c.output,c.next_out,k-c.avail_out),x-=c.avail_in,k-=c.avail_out,c.total_in+=x,c.total_out+=k,f.total+=k,f.wrap&&k&&(c.adler=f.check=f.flags?n(f.check,d,k,c.next_out-k):e(f.check,d,k,c.next_out-k)),c.data_type=f.bits+(f.last?64:0)+(f.mode===o?128:0)+(20===f.mode||15===f.mode?256:0),(0===x&&0===k||4===l)&&0===U&&(U=-5),U},ib.inflateEnd=function(t){if(!t||!t.state)return a;var e=t.state;return e.window&&(e.window=null),t.state=null,0},ib.inflateGetHeader=function(t,e){var n;return t&&t.state&&2&(n=t.state).wrap?(n.head=e,e.done=!1,0):a},ib.inflateSetDictionary=function(t,n){var i,r=n.length;return t&&t.state?0!==(i=t.state).wrap&&11!==i.mode?a:11===i.mode&&e(1,n,r,0)!==i.check?-3:w(t,n,r,r)?(i.mode=31,-4):(i.havedict=1,0):a},ib.inflateInfo="pako inflate (from Nodeca project)",ib}function ab(){return Jg?Vg:(Jg=1,Vg={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8})}function ob(){if(Kg)return nb;Kg=1;var t=rb(),e=yg(),n=$g(),i=ab(),r=Ug(),a=jg(),o=Xg?Yg:(Xg=1,Yg=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}),s=Object.prototype.toString;function h(c){if(!(this instanceof h))return new h(c);this.options=e.assign({chunkSize:16384,windowBits:0,to:""},c||{});var l=this.options;l.raw&&l.windowBits>=0&&l.windowBits<16&&(l.windowBits=-l.windowBits,0===l.windowBits&&(l.windowBits=-15)),!(l.windowBits>=0&&l.windowBits<16)||c&&c.windowBits||(l.windowBits+=32),l.windowBits>15&&l.windowBits<48&&(15&l.windowBits||(l.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new a,this.strm.avail_out=0;var f=t.inflateInit2(this.strm,l.windowBits);if(f!==i.Z_OK)throw new Error(r[f]);if(this.header=new o,t.inflateGetHeader(this.strm,this.header),l.dictionary&&("string"==typeof l.dictionary?l.dictionary=n.string2buf(l.dictionary):"[object ArrayBuffer]"===s.call(l.dictionary)&&(l.dictionary=new Uint8Array(l.dictionary)),l.raw&&(f=t.inflateSetDictionary(this.strm,l.dictionary))!==i.Z_OK))throw new Error(r[f])}function c(t,e){var n=new h(e);if(n.push(t,!0),n.err)throw n.msg||r[n.err];return n.result}return h.prototype.push=function(r,a){var o,h,c,l,f,u=this.strm,d=this.options.chunkSize,p=this.options.dictionary,m=!1;if(this.ended)return!1;h=a===~~a?a:!0===a?i.Z_FINISH:i.Z_NO_FLUSH,"string"==typeof r?u.input=n.binstring2buf(r):"[object ArrayBuffer]"===s.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 e.Buf8(d),u.next_out=0,u.avail_out=d),(o=t.inflate(u,i.Z_NO_FLUSH))===i.Z_NEED_DICT&&p&&(o=t.inflateSetDictionary(this.strm,p)),o===i.Z_BUF_ERROR&&!0===m&&(o=i.Z_OK,m=!1),o!==i.Z_STREAM_END&&o!==i.Z_OK)return this.onEnd(o),this.ended=!0,!1;u.next_out&&(0!==u.avail_out&&o!==i.Z_STREAM_END&&(0!==u.avail_in||h!==i.Z_FINISH&&h!==i.Z_SYNC_FLUSH)||("string"===this.options.to?(c=n.utf8border(u.output,u.next_out),l=u.next_out-c,f=n.buf2string(u.output,c),u.next_out=l,u.avail_out=d-l,l&&e.arraySet(u.output,u.output,c,l,0),this.onData(f)):this.onData(e.shrinkBuf(u.output,u.next_out)))),0===u.avail_in&&0===u.avail_out&&(m=!0)}while((u.avail_in>0||0===u.avail_out)&&o!==i.Z_STREAM_END);return o===i.Z_STREAM_END&&(h=i.Z_FINISH),h===i.Z_FINISH?(o=t.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,o===i.Z_OK):h!==i.Z_SYNC_FLUSH||(this.onEnd(i.Z_OK),u.avail_out=0,!0)},h.prototype.onData=function(t){this.chunks.push(t)},h.prototype.onEnd=function(t){t===i.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=e.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},nb.Inflate=h,nb.inflate=c,nb.inflateRaw=function(t,e){return(e=e||{}).raw=!0,c(t,e)},nb.ungzip=c,nb}function sb(){if(tb)return Qg;tb=1;var t=yg().assign,e=function(){if(Dg)return Sg;Dg=1;var t=Og(),e=yg(),n=$g(),i=Ug(),r=jg(),a=Object.prototype.toString;function o(s){if(!(this instanceof o))return new o(s);this.options=e.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},s||{});var h=this.options;h.raw&&h.windowBits>0?h.windowBits=-h.windowBits:h.gzip&&h.windowBits>0&&h.windowBits<16&&(h.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new r,this.strm.avail_out=0;var c=t.deflateInit2(this.strm,h.level,h.method,h.windowBits,h.memLevel,h.strategy);if(0!==c)throw new Error(i[c]);if(h.header&&t.deflateSetHeader(this.strm,h.header),h.dictionary){var l;if(l="string"==typeof h.dictionary?n.string2buf(h.dictionary):"[object ArrayBuffer]"===a.call(h.dictionary)?new Uint8Array(h.dictionary):h.dictionary,0!==(c=t.deflateSetDictionary(this.strm,l)))throw new Error(i[c]);this._dict_set=!0}}function s(t,e){var n=new o(e);if(n.push(t,!0),n.err)throw n.msg||i[n.err];return n.result}return o.prototype.push=function(i,r){var o,s,h=this.strm,c=this.options.chunkSize;if(this.ended)return!1;s=r===~~r?r:!0===r?4:0,"string"==typeof i?h.input=n.string2buf(i):"[object ArrayBuffer]"===a.call(i)?h.input=new Uint8Array(i):h.input=i,h.next_in=0,h.avail_in=h.input.length;do{if(0===h.avail_out&&(h.output=new e.Buf8(c),h.next_out=0,h.avail_out=c),1!==(o=t.deflate(h,s))&&0!==o)return this.onEnd(o),this.ended=!0,!1;0!==h.avail_out&&(0!==h.avail_in||4!==s&&2!==s)||("string"===this.options.to?this.onData(n.buf2binstring(e.shrinkBuf(h.output,h.next_out))):this.onData(e.shrinkBuf(h.output,h.next_out)))}while((h.avail_in>0||0===h.avail_out)&&1!==o);return 4===s?(o=t.deflateEnd(this.strm),this.onEnd(o),this.ended=!0,0===o):2!==s||(this.onEnd(0),h.avail_out=0,!0)},o.prototype.onData=function(t){this.chunks.push(t)},o.prototype.onEnd=function(t){0===t&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=e.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},Sg.Deflate=o,Sg.deflate=s,Sg.deflateRaw=function(t,e){return(e=e||{}).raw=!0,s(t,e)},Sg.gzip=function(t,e){return(e=e||{}).gzip=!0,s(t,e)},Sg}(),n={};return t(n,e,ob(),ab()),Qg=n}eb=bg,function(){var t={};function e(){"undefined"!=typeof process&&"development"!=process.env.NODE_ENV||console.log.apply(console,arguments)}eb.exports=t,function(t,n){var i;!function(){var e=function(){function t(t){this.message="JPEG error: "+t}return t.prototype=new Error,t.prototype.name="JpegError",t.constructor=t,t}(),n=function(){var t=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]),n=4017,r=799,a=3406,o=2276,s=1567,h=3784,c=5793,l=2896;function f(t){null==t&&(t={}),null==t.w&&(t.w=-1),this.V=t.n,this.N=t.w}function u(t,e){for(var n,i,r,a=0,o=[],s=16;s>0&&!t[s-1];)s--;o.push({children:[],index:0});var h=o[0];for(n=0;n<s;n++){for(i=0;i<t[n];i++){for((h=o.pop()).children[h.index]=e[a];h.index>0;)h=o.pop();for(h.index++,o.push(h);o.length<=n;)o.push(r={children:[],index:0}),h.children[h.index]=r.children,h=r;a++}n+1<s&&(o.push(r={children:[],index:0}),h.children[h.index]=r.children,h=r)}return o[0].children}function d(t,e,n){return 64*((t.P+1)*e+n)}function p(n,r,a,o,s,h,c,l,f,u){null==u&&(u=!1);var p,m,g,w,y,_,v,x,k,A,M,E=a.m,I=a.Z,S=r,z=0,B=0,C=0,P=0,T=0,U=0;function O(){if(B>0)return B--,z>>B&1;if(255===(z=n[r++])){var t=n[r++];if(t){if(220===t&&u){var o=i(n,r+=2);if(r+=2,o>0&&o!==a.s)throw new DNLMarkerError("Found DNL marker (0xFFDC) while parsing scan data",o)}else if(217===t){if(u){var s=8*T;if(s>0&&s<a.s/10)throw new DNLMarkerError("Found EOI marker (0xFFD9) while parsing scan data, possibly caused by incorrect `scanLines` parameter",s)}throw new EOIMarkerError("Found EOI marker (0xFFD9) while parsing scan data")}throw new e("unexpected marker")}}return B=7,z>>>7}function L(t){for(var n=t;;){switch(typeof(n=n[O()])){case"number":return n;case"object":continue}throw new e("invalid huffman sequence")}}function R(t){for(var e=0;t>0;)e=e<<1|O(),t--;return e}function F(t){if(1===t)return 1===O()?1:-1;var e=R(t);return e>=1<<t-1?e:e+(-1<<t)+1}function D(t,e,n,i,r){var a=n%E;T=(n/E|0)*t.A+i;var o=a*t.h+r;e(t,d(t,T,o))}function N(t,e,n){T=n/t.P|0;var i=n%t.P;e(t,d(t,T,i))}var $=o.length;for(v=I?0===h?0===l?function(t,e){var n=L(t.J),i=0===n?0:F(n)<<f;t.D[e]=t.Q+=i}:function(t,e){t.D[e]|=O()<<f}:0===l?function(e,n){if(C>0)C--;else for(var i=h,r=c;i<=r;){var a=L(e.i),o=15&a,s=a>>4;if(0!==o){var l=t[i+=s];e.D[n+l]=F(o)*(1<<f),i++}else{if(s<15){C=R(s)+(1<<s)-1;break}i+=16}}}:function(n,i){for(var r,a,o=h,s=c,l=0;o<=s;){var u=i+t[o],d=n.D[u]<0?-1:1;switch(P){case 0:if(l=(a=L(n.i))>>4,0==(r=15&a))l<15?(C=R(l)+(1<<l),P=4):(l=16,P=1);else{if(1!==r)throw new e("invalid ACn encoding");p=F(r),P=l?2:3}continue;case 1:case 2:n.D[u]?n.D[u]+=d*(O()<<f):0===--l&&(P=2===P?3:0);break;case 3:n.D[u]?n.D[u]+=d*(O()<<f):(n.D[u]=p<<f,P=0);break;case 4:n.D[u]&&(n.D[u]+=d*(O()<<f))}o++}4===P&&0===--C&&(P=0)}:function(e,n){var i=L(e.J),r=0===i?0:F(i),a=1;for(e.D[n]=e.Q+=r;a<64;){var o=L(e.i),s=15&o,h=o>>4;if(0!==s){var c=t[a+=h];e.D[n+c]=F(s),a++}else{if(h<15)break;a+=16}}},k=1===$?o[0].P*o[0].c:E*a.R;U<=k;){var j=s?Math.min(k-U,s):k;if(j>0){for(g=0;g<$;g++)o[g].Q=0;if(C=0,1===$)for(m=o[0],_=0;_<j;_++)N(m,v,U),U++;else for(_=0;_<j;_++){for(g=0;g<$;g++)for(A=(m=o[g]).h,M=m.A,w=0;w<M;w++)for(y=0;y<A;y++)D(m,v,U,w,y);U++}}if(B=0,!(x=b(n,r)))break;if(x.u&&(r=x.offset),!(x.M>=65488&&x.M<=65495))break;r+=2}return r-S}function m(t,i,f){var u,d,p,m,g,b,w,y,_,v,x,k,A,M,E,I,S,z=t.$,B=t.D;if(!z)throw new e("missing required Quantization Table.");for(var C=0;C<64;C+=8)_=B[i+C],v=B[i+C+1],x=B[i+C+2],k=B[i+C+3],A=B[i+C+4],M=B[i+C+5],E=B[i+C+6],I=B[i+C+7],_*=z[C],0!==(v|x|k|A|M|E|I)?(v*=z[C+1],x*=z[C+2],k*=z[C+3],A*=z[C+4],M*=z[C+5],E*=z[C+6],I*=z[C+7],d=(u=(u=c*_+128>>8)+(d=c*A+128>>8)+1>>1)-d,S=(p=x)*h+(m=E)*s+128>>8,p=p*s-m*h+128>>8,w=(g=(g=l*(v-I)+128>>8)+(w=M<<4)+1>>1)-w,b=(y=(y=l*(v+I)+128>>8)+(b=k<<4)+1>>1)-b,m=(u=u+(m=S)+1>>1)-m,p=(d=d+p+1>>1)-p,S=g*o+y*a+2048>>12,g=g*a-y*o+2048>>12,y=S,S=b*r+w*n+2048>>12,b=b*n-w*r+2048>>12,w=S,f[C]=u+y,f[C+7]=u-y,f[C+1]=d+w,f[C+6]=d-w,f[C+2]=p+b,f[C+5]=p-b,f[C+3]=m+g,f[C+4]=m-g):(S=c*_+512>>10,f[C]=S,f[C+1]=S,f[C+2]=S,f[C+3]=S,f[C+4]=S,f[C+5]=S,f[C+6]=S,f[C+7]=S);for(var P=0;P<8;++P)_=f[P],0!==((v=f[P+8])|(x=f[P+16])|(k=f[P+24])|(A=f[P+32])|(M=f[P+40])|(E=f[P+48])|(I=f[P+56]))?(d=(u=4112+((u=c*_+2048>>12)+(d=c*A+2048>>12)+1>>1))-d,S=(p=x)*h+(m=E)*s+2048>>12,p=p*s-m*h+2048>>12,m=S,w=(g=(g=l*(v-I)+2048>>12)+(w=M)+1>>1)-w,b=(y=(y=l*(v+I)+2048>>12)+(b=k)+1>>1)-b,S=g*o+y*a+2048>>12,g=g*a-y*o+2048>>12,y=S,S=b*r+w*n+2048>>12,b=b*n-w*r+2048>>12,(_=(u=u+m+1>>1)+y)<16?_=0:_>=4080?_=255:_>>=4,(v=(d=d+p+1>>1)+(w=S))<16?v=0:v>=4080?v=255:v>>=4,(x=(p=d-p)+b)<16?x=0:x>=4080?x=255:x>>=4,(k=(m=u-m)+g)<16?k=0:k>=4080?k=255:k>>=4,(A=m-g)<16?A=0:A>=4080?A=255:A>>=4,(M=p-b)<16?M=0:M>=4080?M=255:M>>=4,(E=d-w)<16?E=0:E>=4080?E=255:E>>=4,(I=u-y)<16?I=0:I>=4080?I=255:I>>=4,B[i+P]=_,B[i+P+8]=v,B[i+P+16]=x,B[i+P+24]=k,B[i+P+32]=A,B[i+P+40]=M,B[i+P+48]=E,B[i+P+56]=I):(S=(S=c*_+8192>>14)<-2040?0:S>=2024?255:S+2056>>4,B[i+P]=S,B[i+P+8]=S,B[i+P+16]=S,B[i+P+24]=S,B[i+P+32]=S,B[i+P+40]=S,B[i+P+48]=S,B[i+P+56]=S)}function g(t,e){for(var n=e.P,i=e.c,r=new Int16Array(64),a=0;a<i;a++)for(var o=0;o<n;o++)m(e,d(e,a,o),r);return e.D}function b(t,e,n){null==n&&(n=e);var r=t.length-1,a=n<e?n:e;if(e>=r)return null;var o=i(t,e);if(o>=65472&&o<=65534)return{u:null,M:o,offset:e};for(var s=i(t,a);!(s>=65472&&s<=65534);){if(++a>=r)return null;s=i(t,a)}return{u:o.toString(16),M:s,offset:a}}return f.prototype={parse(n,r){null==r&&(r={});var a,o,s=r.F,h=0,c=null,l=null,f=0;function d(){var t=i(n,h),e=(h+=2)+t-2,r=b(n,e,h);r&&r.u&&(e=r.offset);var a=n.subarray(h,e);return h+=a.length,a}function m(t){for(var e=Math.ceil(t.o/8/t.X),n=Math.ceil(t.s/8/t.B),i=0;i<t.W.length;i++){j=t.W[i];var r=Math.ceil(Math.ceil(t.o/8)*j.h/t.X),a=Math.ceil(Math.ceil(t.s/8)*j.A/t.B),o=e*j.h,s=n*j.A*64*(o+1);j.D=new Int16Array(s),j.P=r,j.c=a}t.m=e,t.R=n}var w=[],y=[],_=[],v=i(n,h);if(h+=2,65496!==v)throw new e("SOI not found");v=i(n,h),h+=2;t:for(;65497!==v;){var x,k,A;switch(v){case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:case 65534:var M=d();65504===v&&74===M[0]&&70===M[1]&&73===M[2]&&70===M[3]&&0===M[4]&&(c={version:{d:M[5],T:M[6]},K:M[7],j:M[8]<<8|M[9],H:M[10]<<8|M[11],S:M[12],I:M[13],C:M.subarray(14,14+3*M[12]*M[13])}),65518===v&&65===M[0]&&100===M[1]&&111===M[2]&&98===M[3]&&101===M[4]&&(l={version:M[5]<<8|M[6],k:M[7]<<8|M[8],q:M[9]<<8|M[10],a:M[11]});break;case 65499:for(var E=i(n,h)+(h+=2)-2;h<E;){var I=n[h++],S=new Uint16Array(64);if(I>>4){if(I>>4!=1)throw new e("DQT - invalid table spec");for(k=0;k<64;k++)S[t[k]]=i(n,h),h+=2}else for(k=0;k<64;k++)S[t[k]]=n[h++];w[15&I]=S}break;case 65472:case 65473:case 65474:if(a)throw new e("Only single frame JPEGs supported");h+=2,(a={}).G=65473===v,a.Z=65474===v,a.precision=n[h++];var z,B=i(n,h),C=0,P=0;h+=2,a.s=s||B,a.o=i(n,h),h+=2,a.W=[],a._={};var T=n[h++];for(x=0;x<T;x++){z=n[h];var U=n[h+1]>>4,O=15&n[h+1];C<U&&(C=U),P<O&&(P=O);var L=n[h+2];A=a.W.push({h:U,A:O,L:L,$:null}),a._[z]=A-1,h+=3}a.X=C,a.B=P,m(a);break;case 65476:var R=i(n,h);for(h+=2,x=2;x<R;){var F=n[h++],D=new Uint8Array(16),N=0;for(k=0;k<16;k++,h++)N+=D[k]=n[h];var $=new Uint8Array(N);for(k=0;k<N;k++,h++)$[k]=n[h];x+=17+N,(F>>4?y:_)[15&F]=u(D,$)}break;case 65501:o=i(n,h+=2),h+=2;break;case 65498:var j,G=1===++f&&!s;h+=2;var H=n[h++],Z=[];for(x=0;x<H;x++){var q=n[h++],W=a._[q];(j=a.W[W]).index=q;var V=n[h++];j.J=_[V>>4],j.i=y[15&V],Z.push(j)}var J=n[h++],Y=n[h++],X=n[h++];try{var K=p(n,h,a,Z,o,J,Y,X>>4,15&X,G);h+=K}catch(t){if(t instanceof DNLMarkerError)return this.parse(n,{F:t.s});if(t instanceof EOIMarkerError)break t;throw t}break;case 65500:h+=4;break;case 65535:255!==n[h]&&h--;break;default:var Q=b(n,h-2,h-3);if(Q&&Q.u){h=Q.offset;break}if(h>=n.length-1)break t;throw new e("JpegImage.parse - unknown marker: "+v.toString(16))}v=i(n,h),h+=2}for(this.width=a.o,this.height=a.s,this.g=c,this.b=l,this.W=[],x=0;x<a.W.length;x++){var tt=w[(j=a.W[x]).L];tt&&(j.$=tt),this.W.push({index:j.index,e:g(0,j),l:j.h/a.X,t:j.A/a.B,P:j.P,c:j.c})}this.p=this.W.length},Y(t,e,n){null==n&&(n=!1);var i,r,a,o,s,h,c,l,f,u,d,p,m=this.width/t,g=this.height/e,b=0,w=this.W.length,y=t*e*w,_=new Uint8ClampedArray(y),v=new Uint32Array(t),x=4294967288;for(c=0;c<w;c++){if(r=(i=this.W[c]).l*m,a=i.t*g,b=c,d=i.e,o=i.P+1<<3,r!==p){for(s=0;s<t;s++)l=0|s*r,v[s]=(l&x)<<3|7&l;p=r}for(h=0;h<e;h++)for(u=o*((l=0|h*a)&x)|(7&l)<<3,s=0;s<t;s++)_[b]=d[u+v[s]],b+=w}var k=this.V;if(n||4!==w||k||(k=new Int32Array([-256,255,-256,255,-256,255,-256,255])),k)for(c=0;c<y;)for(l=0,f=0;l<w;l++,c++,f+=2)_[c]=(_[c]*k[f]>>8)+k[f+1];return _},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(t){for(var e,n,i,r=0,a=t.length;r<a;r+=3)e=t[r],n=t[r+1],i=t[r+2],t[r]=e-179.456+1.402*i,t[r+1]=e+135.459-.344*n-.714*i,t[r+2]=e-226.816+1.772*n;return t},O:function(t){for(var e,n,i,r,a=0,o=0,s=t.length;o<s;o+=4)e=t[o],n=t[o+1],i=t[o+2],r=t[o+3],t[a++]=n*(-660635669420364e-19*n+.000437130475926232*i-54080610064599e-18*e+.00048449797120281*r-.154362151871126)-122.67195406894+i*(-.000957964378445773*i+.000817076911346625*e-.00477271405408747*r+1.53380253221734)+e*(.000961250184130688*e-.00266257332283933*r+.48357088451265)+r*(-.000336197177618394*r+.484791561490776),t[a++]=107.268039397724+n*(219927104525741e-19*n-.000640992018297945*i+.000659397001245577*e+.000426105652938837*r-.176491792462875)+i*(-.000778269941513683*i+.00130872261408275*e+.000770482631801132*r-.151051492775562)+e*(.00126935368114843*e-.00265090189010898*r+.25802910206845)+r*(-.000318913117588328*r-.213742400323665),t[a++]=n*(-.000570115196973677*n-263409051004589e-19*i+.0020741088115012*e-.00288260236853442*r+.814272968359295)-20.810012546947+i*(-153496057440975e-19*i-.000132689043961446*e+.000560833691242812*r-.195152027534049)+e*(.00174418132927582*e-.00255243321439347*r+.116935020465145)+r*(-.000343531996510555*r+.24165260232407);return t.subarray(0,a)},r:function(t){for(var e,n,i,r=0,a=t.length;r<a;r+=4)e=t[r],n=t[r+1],i=t[r+2],t[r]=434.456-e-1.402*i,t[r+1]=119.541-e+.344*n+.714*i,t[r+2]=481.816-e-1.772*n;return t},U:function(t){for(var e,n,i,r,a=0,o=0,s=t.length;o<s;o+=4)e=t[o],n=t[o+1],i=t[o+2],r=t[o+3],t[a++]=255+e*(-6747147073602441e-20*e+.0008379262121013727*n+.0002894718188643294*i+.003264231057537806*r-1.1185611867203937)+n*(26374107616089405e-21*n-8626949158638572e-20*i-.0002748769067499491*r-.02155688794978967)+i*(-3878099212869363e-20*i-.0003267808279485286*r+.0686742238595345)-r*(.0003361971776183937*r+.7430659151342254),t[a++]=255+e*(.00013596372813588848*e+.000924537132573585*n+.00010567359618683593*i+.0004791864687436512*r-.3109689587515875)+n*(-.00023545346108370344*n+.0002702845253534714*i+.0020200308977307156*r-.7488052167015494)+i*(6834815998235662e-20*i+.00015168452363460973*r-.09751927774728933)-r*(.0003189131175883281*r+.7364883807733168),t[a++]=255+e*(13598650411385307e-21*e+.00012423956175490851*n+.0004751985097583589*i-36729317476630422e-22*r-.05562186980264034)+n*(.00016141380598724676*n+.0009692239130725186*i+.0007782692450036253*r-.44015232367526463)+i*(5.068882914068769e-7*i+.0017778369011375071*r-.7591454649749609)-r*(.0003435319965105553*r+.7063770186160144);return t.subarray(0,a)},getData:function(t){var n=t.width,i=t.height,r=t.forceRGB,a=t.isSourcePDF;if(this.p>4)throw new e("Unsupported color mode");var o=this.Y(n,i,a);if(1===this.p&&r){for(var s=o.length,h=new Uint8ClampedArray(3*s),c=0,l=0;l<s;l++){var f=o[l];h[c++]=f,h[c++]=f,h[c++]=f}return h}if(3===this.p&&this.f)return this.z(o);if(4===this.p){if(this.f)return r?this.O(o):this.r(o);if(r)return this.U(o)}return o}},f}();function i(t,e){return t[e]<<8|t[e+1]}t.JpegDecoder=n}(),t.encodeImage=function(e,n,i,r){var a={t256:[n],t257:[i],t258:[8,8,8,8],t259:[1],t262:[2],t273:[1e3],t277:[4],t278:[i],t279:[n*i*4],t282:[[72,1]],t283:[[72,1]],t284:[1],t286:[[0,1]],t287:[[0,1]],t296:[1],t305:["Photopea (UTIF.js)"],t338:[1]};if(r)for(var o in r)a[o]=r[o];var s=new Uint8Array(t.encode([a])),h=new Uint8Array(e),c=new Uint8Array(1e3+n*i*4);for(o=0;o<s.length;o++)c[o]=s[o];for(o=0;o<h.length;o++)c[1e3+o]=h[o];return c.buffer},t.encode=function(e){var n=new Uint8Array(2e4),i=4,r=t._binBE;n[0]=n[1]=77,r.writeUshort(n,2,42);var a=8;r.writeUint(n,i,a),i+=4;for(var o=0;o<e.length;o++){var s=t._writeIFD(r,t._types.basic,n,a,e[o]);a=s[1],o<e.length-1&&(3&a&&(a+=4-(3&a)),r.writeUint(n,s[0],a))}return n.slice(0,a).buffer},t.decode=function(n,i){null==i&&(i={parseMN:!0,debug:!1});var r=new Uint8Array(n),a=0,o=t._binBE.readASCII(r,a,2);a+=2;var s="II"==o?t._binLE:t._binBE;s.readUshort(r,a),a+=2;var h=s.readUint(r,a);a+=4;for(var c=[];;){var l=s.readUshort(r,h),f=s.readUshort(r,h+4);if(0!=l&&(f<1||13<f)){e("error in TIFF");break}if(t._readIFD(s,r,h,c,0,i),0==(h=s.readUint(r,h+2+12*l)))break}return c},t.decodeImage=function(n,i,r){if(!i.data){var a=new Uint8Array(n),o=t._binBE.readASCII(a,0,2);if(null!=i.t256){i.isLE="II"==o,i.width=i.t256[0],i.height=i.t257[0];var s=i.t259?i.t259[0]:1,h=i.t266?i.t266[0]:1;i.t284&&2==i.t284[0]&&e("PlanarConfiguration 2 should not be used!"),7==s&&i.t258&&i.t258.length>3&&(i.t258=i.t258.slice(0,3));var c=i.t277?i.t277[0]:1,l=(i.t258?i.t258[0]:1)*c;1==s&&null!=i.t279&&i.t278&&32803==i.t262[0]&&(l=Math.round(8*i.t279[0]/(i.width*i.t278[0]))),i.t50885&&4==i.t50885[0]&&(l=3*i.t258[0]);var f=8*Math.ceil(i.width*l/8),u=i.t273;(null==u||i.t322)&&(u=i.t324);var d=i.t279;1==s&&1==u.length&&(d=[i.height*(f>>>3)]),(null==d||i.t322)&&(d=i.t325);var p=new Uint8Array(i.height*(f>>>3)),m=0;if(null!=i.t322){var g=i.t322[0],b=i.t323[0],w=Math.floor((i.width+g-1)/g),y=Math.floor((i.height+b-1)/b),_=new Uint8Array(0|Math.ceil(g*b*l/8));console.log("====",w,y);for(var v=0;v<y;v++)for(var x=0;x<w;x++){var k=v*w+x;_.fill(0),t.decode._decompress(i,r,a,u[k],d[k],s,_,0,h,g,b),6==s?p=_:t._copyTile(_,0|Math.ceil(g*l/8),b,p,0|Math.ceil(i.width*l/8),i.height,0|Math.ceil(x*g*l/8),v*b)}m=8*p.length}else{if(null==u)return;var A=i.t278?i.t278[0]:i.height;for(A=Math.min(A,i.height),k=0;k<u.length;k++)t.decode._decompress(i,r,a,u[k],d[k],s,p,0|Math.ceil(m/8),h,i.width,A),m+=f*A;m=Math.min(m,8*p.length)}i.data=new Uint8Array(p.buffer,0,0|Math.ceil(m/8))}}},t.decode._decompress=function(i,r,a,o,s,h,c,l,f,u,d){if(i.t271&&"Panasonic"==i.t271[0]&&i.t45&&6==i.t45[0]&&(h=34316),1==h)for(var p=0;p<s;p++)c[l+p]=a[o+p];else if(2==h)t.decode._decodeG2(a,o,s,c,l,u,f);else if(3==h)t.decode._decodeG3(a,o,s,c,l,u,f,!(!i.t292||1&~i.t292[0]));else if(4==h)t.decode._decodeG4(a,o,s,c,l,u,f);else if(5==h)t.decode._decodeLZW(a,o,s,c,l,8);else if(6==h)t.decode._decodeOldJPEG(i,a,o,s,c,l);else if(7==h||34892==h)t.decode._decodeNewJPEG(i,a,o,s,c,l);else if(8==h||32946==h){var m=new Uint8Array(a.buffer,o+2,s-6),g=n.inflateRaw(m);l+g.length<=c.length&&c.set(g,l)}else 9==h?t.decode._decodeVC5(a,o,s,c,l,i.t33422):32767==h?t.decode._decodeARW(i,a,o,s,c,l):32773==h?t.decode._decodePackBits(a,o,s,c,l):32809==h?t.decode._decodeThunder(a,o,s,c,l):34316==h?t.decode._decodePanasonic(i,a,o,s,c,l):34713==h?t.decode._decodeNikon(i,r,a,o,s,c,l):34676==h?t.decode._decodeLogLuv32(i,a,o,s,c,l):e("Unknown compression",h);var b=i.t258?Math.min(32,i.t258[0]):1,w=i.t277?i.t277[0]:1,y=b*w>>>3,_=Math.ceil(b*w*u/8);if(16==b&&!i.isLE&&null==i.t33422)for(var v=0;v<d;v++)for(var x=l+v*_,k=1;k<_;k+=2){var A=c[x+k];c[x+k]=c[x+k-1],c[x+k-1]=A}if(i.t317&&2==i.t317[0])for(v=0;v<d;v++){var M=l+v*_;if(16==b)for(p=y;p<_;p+=2){var E=(c[M+p+1]<<8|c[M+p])+(c[M+p-y+1]<<8|c[M+p-y]);c[M+p]=255&E,c[M+p+1]=E>>>8&255}else if(3==w)for(p=3;p<_;p+=3)c[M+p]=c[M+p]+c[M+p-3]&255,c[M+p+1]=c[M+p+1]+c[M+p-2]&255,c[M+p+2]=c[M+p+2]+c[M+p-1]&255;else for(p=y;p<_;p++)c[M+p]=c[M+p]+c[M+p-y]&255}},t.decode._decodePanasonic=function(t,e,n,i,r,a){var o,s,h,c,l,f,u,d,p=e.buffer,m=t.t2[0],g=t.t3[0],b=t.t10[0],w=t.t45[0],y=0,_=0,v=0,x=0,k=6==w?new Uint32Array(18):new Uint8Array(16),A=[0,0],M=[0,0],E=0,I=new Uint8Array(16384),S=new Uint16Array(r.buffer);function z(t){if(0==v){var e=new Uint8Array(p,n+_+8184,8200),i=new Uint8Array(p,n+_,8184);I.set(e),I.set(i,e.length),_+=16384}if(5!=w)return(I[x=(v=v-t&131071)>>3^16368]|I[x+1]<<8)>>(7&v)&~(-1<<t);for(o=0;o<16;o++)k[o]=I[v++],v&=16383}function B(t){return I[v+15-t]}function C(){A[0]=0,A[1]=0,M[0]=0,M[1]=0}if(7==w)throw w;if(6==w){var P=12==b,T=P?function(){k[0]=B(0)<<4|B(1)>>4,k[1]=4095&((15&B(1))<<8|B(2)),k[2]=B(3)>>6&3,k[3]=(63&B(3))<<2|B(4)>>6,k[4]=(63&B(4))<<2|B(5)>>6,k[5]=(63&B(5))<<2|B(6)>>6,k[6]=B(6)>>4&3,k[7]=(15&B(6))<<4|B(7)>>4,k[8]=(15&B(7))<<4|B(8)>>4,k[9]=(15&B(8))<<4|B(9)>>4,k[10]=B(9)>>2&3,k[11]=(3&B(9))<<6|B(10)>>2,k[12]=(3&B(10))<<6|B(11)>>2,k[13]=(3&B(11))<<6|B(12)>>2,k[14]=3&B(12),k[15]=B(13),k[16]=B(14),k[17]=B(15),v+=16,x=0}:function(){k[0]=B(0)<<6|B(1)>>2,k[1]=16383&((3&B(1))<<12|B(2)<<4|B(3)>>4),k[2]=B(3)>>2&3,k[3]=(3&B(3))<<8|B(4),k[4]=B(5)<<2|B(6)>>6,k[5]=(63&B(6))<<4|B(7)>>4,k[6]=B(7)>>2&3,k[7]=(3&B(7))<<8|B(8),k[8]=B(9)<<2&1020|B(10)>>6,k[9]=1023&(B(10)<<4|B(11)>>4),k[10]=B(11)>>2&3,k[11]=(3&B(11))<<8|B(12),k[12]=1023&(B(13)<<2&1020|B(14)>>6),k[13]=1023&(B(14)<<4|B(15)>>4),v+=16,x=0},U=P?14:11,O=P?128:512,L=P?2048:8192,R=P?16383:65535,F=P?4095:16383,D=m/U,N=16*D,$=P?18:14;for(f=0;f<g-15;f+=16){var j=Math.min(16,g-f),G=N*j;for(I=new Uint8Array(p,n+y,G),v=0,y+=G,d=0,u=0;d<j;d++,u=0){E=(f+d)*m;for(var H=0;H<D;H++)for(T(),C(),h=0,l=0,o=0;o<U;o++){if(c=1&o,o%3==2){var Z=x<$?k[x++]:0;3==Z&&(Z=4),l=O<<Z,h=1<<Z}var q=x<$?k[x++]:0;A[c]?(q*=h,l<L&&M[c]>l&&(q+=M[c]-l),M[c]=q):(A[c]=q,q?M[c]=q:q=M[c]),S[E+u++]=q-15<=R?q-15&R:q+2147483633>>31&F}}}}else if(5==w){var W=12==b?10:9;for(f=0;f<g;f++)for(u=0;u<m;u+=W)z(0),12==b?(S[E++]=((15&k[1])<<8)+k[0],S[E++]=16*k[2]+(k[1]>>4),S[E++]=((15&k[4])<<8)+k[3],S[E++]=16*k[5]+(k[4]>>4),S[E++]=((15&k[7])<<8)+k[6],S[E++]=16*k[8]+(k[7]>>4),S[E++]=((15&k[10])<<8)+k[9],S[E++]=16*k[11]+(k[10]>>4),S[E++]=((15&k[13])<<8)+k[12],S[E++]=16*k[14]+(k[13]>>4)):14==b&&(S[E++]=k[0]+((63&k[1])<<8),S[E++]=(k[1]>>6)+4*k[2]+((15&k[3])<<10),S[E++]=(k[3]>>4)+16*k[4]+((3&k[5])<<12),S[E++]=((252&k[5])>>2)+(k[6]<<6),S[E++]=k[7]+((63&k[8])<<8),S[E++]=(k[8]>>6)+4*k[9]+((15&k[10])<<10),S[E++]=(k[10]>>4)+16*k[11]+((3&k[12])<<12),S[E++]=((252&k[12])>>2)+(k[13]<<6),S[E++]=k[14]+((63&k[15])<<8))}else{if(4!=w)throw w;for(f=0;f<g;f++)for(u=0;u<m;u++)c=1&(o=u%14),0==o&&C(),o%3==2&&(h=4>>3-z(2)),M[c]?0!=(s=z(8))&&(A[c]-=128<<h,(A[c]<0||4==h)&&(A[c]&=~(-1<<h)),A[c]+=s<<h):(M[c]=z(8),(M[c]||o>11)&&(A[c]=M[c]<<4|z(4))),S[E++]=A[1&u]}},t.decode._decodeVC5=function(){var e,n,i,r=[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(t){var e=t[1],n=t[0][e>>>3]>>>7-(7&e)&1;return t[1]++,n}function s(t,n){if(null==e){e={};for(var i=0;i<r.length;i+=4)e[r[i+1]]=r.slice(i,i+4)}for(var a=o(t),s=e[a];null==s;)a=a<<1|o(t),s=e[a];var h=s[3];0!=h&&(h=0==o(t)?h:-h),n[0]=s[2],n[1]=h}function h(t,e){for(var n=0;n<e;n++)1&~t||t++,t>>>=1;return t}function c(t,e){return t>>e}function l(t,e,n,i,r,a){e[n]=c(c(11*t[r]-4*t[r+a]+t[r+a+a]+4,3)+t[i],1),e[n+a]=c(c(5*t[r]+4*t[r+a]-t[r+a+a]+4,3)-t[i],1)}function f(t,e,n,i,r,a){var o=t[r-a]-t[r+a],s=t[r],h=t[i];e[n]=c(c(o+4,3)+s+h,1),e[n+a]=c(c(4-o,3)+s-h,1)}function u(t,e,n,i,r,a){e[n]=c(c(5*t[r]+4*t[r-a]-t[r-a-a]+4,3)+t[i],1),e[n+a]=c(c(11*t[r]-4*t[r-a]+t[r-a-a]+4,3)-t[i],1)}function d(t){return t=i[t=t<0?0:t>4095?4095:t]>>>2}return function(e,r,o,c,p,m){c=new Uint16Array(c.buffer);var g,b,w,y,_,v,x,k,A=Date.now(),M=t._binBE,E=r+o;r+=4;for(var I=1==m[0];r<E;){var S=M.readShort(e,r),z=M.readUshort(e,r+2);if(r+=4,12==S)L=z;else if(20==S)g=z;else if(21==S)b=z;else if(48==S)w=z;else if(53==S)y=z;else if(35==S);else if(62==S)_=z;else if(101==S);else if(109==S)v=z;else if(84==S);else if(106==S);else if(107==S);else if(108==S);else if(102==S);else if(104==S)nt=z;else if(105==S);else{var B=S<0?-S:S,C=65280&B,P=0;if(24576&B&&(8192&B?(P=65535&z,P+=(255&B)<<16):P=65535&z),24576&~B){if(16388==B)r+=4*P;else if(8192!=C&&8448!=C&&9216!=C)throw B.toString(16)}else{if(null==x){x=[];for(var T=0;T<4;T++)x[T]=new Int16Array((g>>>1)*(b>>>1));for(k=new Int16Array((g>>>1)*(b>>>1)),n=new Int16Array(1024),T=0;T<1024;T++){var U=T-512,O=Math.abs(U),L=Math.floor(768*O*O*O/16581375)+O;n[T]=Math.sign(U)*L}for(i=new Uint16Array(4096),T=0;T<4096;T++){var R=T,F=65535*(Math.pow(113,R/4095)-1)/112;i[T]=Math.min(F,65535)}}var D=x[_],N=h(g,1+a[w]),$=h(b,1+a[w]);if(0==w)for(var j=0;j<$;j++)for(var G=0;G<N;G++){var H=r+2*(j*N+G);D[j*(g>>>1)+G]=e[H]<<8|e[H+1]}else{var Z=[e,8*r],q=[],W=0,V=N*$,J=[0,0],Y=0;for(z=0;W<V;)for(s(Z,J),Y=J[0],z=J[1];Y>0;)q[W++]=z,Y--;var X=(w-1)%3,K=1!=X?N:0,Q=0!=X?$:0;for(j=0;j<$;j++){var tt=(j+Q)*(g>>>1)+K,et=j*N;for(G=0;G<N;G++)D[tt+G]=n[q[et+G]+512]*y}if(2==X){var nt=g>>>1,it=2*N,rt=2*$;for(j=0;j<$;j++)for(G=0;G<it;G++){T=2*j*nt+G;var at=$*nt+(st=j*nt+G);0==j?l(D,k,T,at,st,nt):j==$-1?u(D,k,T,at,st,nt):f(D,k,T,at,st,nt)}var ot=D;for(D=k,k=ot,j=0;j<rt;j++)for(G=0;G<N;G++){var st;T=j*nt+2*G,at=N+(st=j*nt+G),0==G?l(D,k,T,at,st,1):G==N-1?u(D,k,T,at,st,1):f(D,k,T,at,st,1)}ot=D,D=k,k=ot;for(var ht=[],ct=2-~~((w-1)/3),lt=0;lt<3;lt++)ht[lt]=v>>14-2*lt&3;var ft=ht[ct];if(0!=ft)for(j=0;j<rt;j++)for(G=0;G<it;G++)D[T=j*nt+G]=D[T]<<ft}}if(9==w&&3==_){var ut=x[0],dt=x[1],pt=x[2],mt=x[3];for(j=0;j<b;j+=2)for(G=0;G<g;G+=2){var gt=j*g+G,bt=ut[H=(j>>>1)*(g>>>1)+(G>>>1)],wt=dt[H]-2048,yt=pt[H]-2048,_t=mt[H]-2048,vt=(wt<<1)+bt,xt=(yt<<1)+bt,kt=bt+_t,At=bt-_t;I?(c[gt]=d(kt),c[gt+1]=d(xt),c[gt+g]=d(vt),c[gt+g+1]=d(At)):(c[gt]=d(vt),c[gt+1]=d(kt),c[gt+g]=d(At),c[gt+g+1]=d(xt))}}r+=4*P}}}console.log(Date.now()-A)}}(),t.decode._decodeLogLuv32=function(t,e,n,i,r,a){for(var o=t.width,s=4*o,h=0,c=new Uint8Array(s);h<i;){for(var l=0;l<s;){var f=e[n+h];if(h++,f<128){for(var u=0;u<f;u++)c[l+u]=e[n+h+u];l+=f,h+=f}else{for(f-=126,u=0;u<f;u++)c[l+u]=e[n+h];l+=f,h++}}for(var d=0;d<o;d++)r[a+0]=c[d],r[a+1]=c[d+o],r[a+2]=c[d+2*o],r[a+4]=c[d+3*o],a+=6}},t.decode._ljpeg_diff=function(e,n,i){var r,a,o=t.decode._getbithuff;return r=o(e,n,i[0],i),(a=o(e,n,r,0))&1<<r-1||(a-=(1<<r)-1),a},t.decode._decodeARW=function(e,n,i,r,a,o){var s=e.t256[0],h=e.t257[0],c=e.t258[0],l=e.isLE?t._binLE:t._binBE;if(s*h==r||s*h*1.5==r)if(s*h*1.5!=r){var f,u,d,p,m,g,b,w,y=new Uint16Array(16),_=new Uint8Array(s+1);for(S=0;S<h;S++){for(var v=0;v<s;v++)_[v]=n[i++];for(w=0,I=0;I<s-30;w+=16){for(u=2047&(f=l.readUint(_,w)),d=2047&f>>>11,p=15&f>>>22,m=15&f>>>26,g=0;g<4&&128<<g<=u-d;g++);for(b=30,x=0;x<16;x++)x==p?y[x]=u:x==m?y[x]=d:(y[x]=((l.readUshort(_,w+(b>>3))>>>(7&b)&127)<<g)+d,y[x]>2047&&(y[x]=2047),b+=7);for(x=0;x<16;x++,I+=2)L=y[x]<<1,t.decode._putsF(a,(S*s+I)*c,L<<16-c);I-=1&I?1:31}}}else for(var x=0;x<r;x+=3){var k=n[i+x+0],A=n[i+x+1],M=n[i+x+2];a[o+x]=A<<4|k>>>4,a[o+x+1]=k<<4|M>>>4,a[o+x+2]=M<<4|A>>>4}else{h+=8;var E,I,S,z=[i,0,0,0],B=new Uint16Array(32770),C=[3857,3856,3599,3342,3085,2828,2571,2314,2057,1800,1543,1286,1029,772,771,768,514,513],P=0,T=t.decode._ljpeg_diff;for(B[0]=15,E=x=0;x<18;x++)for(var U=32768>>>(C[x]>>>8),O=0;O<U;O++)B[++E]=C[x];for(I=s;I--;)for(S=0;S<h+1;S+=2)if(S==h&&(S=1),P+=T(n,z,B),S<h){var L=4095&P;t.decode._putsF(a,(S*s+I)*c,L<<16-c)}}},t.decode._decodeNikon=function(e,n,i,r,a,o,s){var h=[[0,0,1,5,1,1,1,1,1,1,2,0,0,0,0,0,0,5,4,3,6,2,7,1,0,8,9,11,10,12],[0,0,1,5,1,1,1,1,1,1,2,0,0,0,0,0,0,57,90,56,39,22,5,4,3,2,1,0,11,12,12],[0,0,1,4,2,3,1,2,0,0,0,0,0,0,0,0,0,5,4,6,3,7,2,8,1,9,0,10,11,12],[0,0,1,4,3,1,1,1,1,1,2,0,0,0,0,0,0,5,6,4,7,8,3,9,2,1,0,10,11,12,13,14],[0,0,1,5,1,1,1,1,1,1,1,2,0,0,0,0,0,8,92,75,58,41,7,6,5,4,3,2,1,0,13,14],[0,0,1,4,2,2,3,1,2,0,0,0,0,0,0,0,0,7,6,8,5,9,4,10,3,11,12,2,0,1,13,14]],c=e.t256[0],l=e.t257[0],f=e.t258[0],u=0,d=0,p=t.decode._make_decoder,m=t.decode._getbithuff,g=n[0].exifIFD.makerNote,b=g.t150?g.t150:g.t140,w=0,y=b[w++],_=b[w++];73!=y&&88!=_||(w+=2110),70==y&&(u=2),14==f&&(u+=3);for(var v=[[0,0],[0,0]],x=e.isLE?t._binLE:t._binBE,k=0;k<2;k++)for(var A=0;A<2;A++)v[k][A]=x.readShort(b,w),w+=2;var M,E,I,S,z,B=1<<f&32767,C=0,P=x.readShort(b,w);w+=2,P>1&&(C=Math.floor(B/(P-1))),68==y&&32==_&&C>0&&(d=x.readShort(b,562));var T=[0,0],U=p(h[u]),O=[r,0,0,0];for(M=0;M<l;M++)for(d&&M==d&&(U=p(h[u+1])),E=0;E<c;E++){k=m(i,O,U[0],U),(z=1+(m(i,O,(I=15&k)-(S=k>>>4),0)<<1)<<S>>>1)&1<<I-1||(z-=(1<<I)-(0==S?1:0)),E<2?T[E]=v[1&M][E]+=z:T[1&E]+=z;var L=Math.min(Math.max(T[1&E],0),(1<<f)-1),R=(M*c+E)*f;t.decode._putsF(o,R,L<<16-f)}},t.decode._putsF=function(t,e,n){n<<=8-(7&e);var i=e>>>3;t[i]|=n>>>16,t[i+1]|=n>>>8,t[i+2]|=n},t.decode._getbithuff=function(e,n,i,r){var a;t.decode._get_byte;var o=n[0],s=n[1],h=n[2],c=n[3];if(0==i||h<0)return 0;for(;!c&&h<i&&-1!=(a=e[o++])&&!(c=0);)s=(s<<8)+a,h+=8;if(a=s<<32-h>>>32-i,r?(h-=r[a+1]>>>8,a=255&r[a+1]):h-=i,h<0)throw"e";return n[0]=o,n[1]=s,n[2]=h,n[3]=c,a},t.decode._make_decoder=function(t){var e,n,i,r,a,o=[];for(e=16;0!=e&&!t[e];e--);var s=17;for(o[0]=e,i=n=1;n<=e;n++)for(r=0;r<t[n];r++,++s)for(a=0;a<1<<e-n;a++)i<=1<<e&&(o[i++]=n<<8|t[s]);return o},t.decode._decodeNewJPEG=function(e,n,i,r,a,o){r=Math.min(r,n.length-i);var s=e.t347,h=s?s.length:0,c=new Uint8Array(h+r);if(s){for(var l=0,f=0;f<h-1&&(255!=s[f]||217!=s[f+1]);f++)c[l++]=s[f];var u=n[i],d=n[i+1];for(255==u&&216==d||(c[l++]=u,c[l++]=d),f=2;f<r;f++)c[l++]=n[i+f]}else for(f=0;f<r;f++)c[f]=n[i+f];if(32803==e.t262[0]||7==e.t259[0]&&34892==e.t262[0]){var p=e.t258[0],m=t.LosslessJpegDecode(c),g=m.length;if(16==p)if(e.isLE)for(f=0;f<g;f++)a[o+(f<<1)]=255&m[f],a[o+(f<<1)+1]=m[f]>>>8;else for(f=0;f<g;f++)a[o+(f<<1)]=m[f]>>>8,a[o+(f<<1)+1]=255&m[f];else if(14==p||12==p||10==p){var b=16-p;for(f=0;f<g;f++)t.decode._putsF(a,f*p,m[f]<<b)}else{if(8!=p)throw new Error("unsupported bit depth "+p);for(f=0;f<g;f++)a[o+f]=m[f]}}else{var w=new t.JpegDecoder;w.parse(c);var y=w.getData({width:w.width,height:w.height,forceRGB:!0,isSourcePDF:!1});for(f=0;f<y.length;f++)a[o+f]=y[f]}6==e.t262[0]&&(e.t262[0]=2)},t.decode._decodeOldJPEGInit=function(t,n,i,r){var a,o,s,h,c,l=216,f=0,u=0,d=!1,p=t.t513,m=p?p[0]:0,g=t.t514,b=g?g[0]:0,w=t.t324||t.t273||p,y=t.t530,_=0,v=0,x=t.t277?t.t277[0]:1,k=t.t515;if(w&&(u=w[0],d=w.length>1),!d){if(255==n[i]&&n[i+1]==l)return{jpegOffset:i};if(null!=p&&(255==n[i+m]&&n[i+m+1]==l?f=i+m:e("JPEGInterchangeFormat does not point to SOI"),null==g?e("JPEGInterchangeFormatLength field is missing"):(m>=u||m+b<=u)&&e("JPEGInterchangeFormatLength field value is invalid"),null!=f))return{jpegOffset:f}}if(null!=y&&(_=y[0],v=y[1]),null!=p&&null!=g)if(b>=2&&m+b<=u){for(a=255==n[i+m+b-2]&&n[i+m+b-1]==l?new Uint8Array(b-2):new Uint8Array(b),s=0;s<a.length;s++)a[s]=n[i+m+s];e("Incorrect JPEG interchange format: using JPEGInterchangeFormat offset to derive tables")}else e("JPEGInterchangeFormat+JPEGInterchangeFormatLength > offset to first strip or tile");if(null==a){var A=0,M=[];M[A++]=255,M[A++]=l;var E=t.t519;if(null==E)throw new Error("JPEGQTables tag is missing");for(s=0;s<E.length;s++)for(M[A++]=255,M[A++]=219,M[A++]=0,M[A++]=67,M[A++]=s,h=0;h<64;h++)M[A++]=n[i+E[s]+h];for(c=0;c<2;c++){var I=t[0==c?"t520":"t521"];if(null==I)throw new Error((0==c?"JPEGDCTables":"JPEGACTables")+" tag is missing");for(s=0;s<I.length;s++){M[A++]=255,M[A++]=196;var S=19;for(h=0;h<16;h++)S+=n[i+I[s]+h];for(M[A++]=S>>>8,M[A++]=255&S,M[A++]=s|c<<4,h=0;h<16;h++)M[A++]=n[i+I[s]+h];for(h=0;h<S;h++)M[A++]=n[i+I[s]+16+h]}}if(M[A++]=255,M[A++]=192,M[A++]=0,M[A++]=8+3*x,M[A++]=8,M[A++]=t.height>>>8&255,M[A++]=255&t.height,M[A++]=t.width>>>8&255,M[A++]=255&t.width,M[A++]=x,1==x)M[A++]=1,M[A++]=17,M[A++]=0;else for(s=0;s<3;s++)M[A++]=s+1,M[A++]=0!=s?17:(15&_)<<4|15&v,M[A++]=s;null!=k&&0!=k[0]&&(M[A++]=255,M[A++]=221,M[A++]=0,M[A++]=4,M[A++]=k[0]>>>8&255,M[A++]=255&k[0]),a=new Uint8Array(M)}var z=-1;for(s=0;s<a.length-1;){if(255==a[s]&&192==a[s+1]){z=s;break}s++}if(-1==z){var B=new Uint8Array(a.length+10+3*x);B.set(a);var C=a.length;if(z=a.length,(a=B)[C++]=255,a[C++]=192,a[C++]=0,a[C++]=8+3*x,a[C++]=8,a[C++]=t.height>>>8&255,a[C++]=255&t.height,a[C++]=t.width>>>8&255,a[C++]=255&t.width,a[C++]=x,1==x)a[C++]=1,a[C++]=17,a[C++]=0;else for(s=0;s<3;s++)a[C++]=s+1,a[C++]=0!=s?17:(15&_)<<4|15&v,a[C++]=s}if(255==n[u]&&218==n[u+1]){var P=n[u+2]<<8|n[u+3];for((o=new Uint8Array(P+2))[0]=n[u],o[1]=n[u+1],o[2]=n[u+2],o[3]=n[u+3],s=0;s<P-2;s++)o[s+4]=n[u+s+4]}else{var T=0;if((o=new Uint8Array(8+2*x))[T++]=255,o[T++]=218,o[T++]=0,o[T++]=6+2*x,o[T++]=x,1==x)o[T++]=1,o[T++]=0;else for(s=0;s<3;s++)o[T++]=s+1,o[T++]=s<<4|s;o[T++]=0,o[T++]=63,o[T++]=0}return{jpegOffset:i,tables:a,sosMarker:o,sofPosition:z}},t.decode._decodeOldJPEG=function(e,n,i,r,a,o){var s,h,c,l,f=t.decode._decodeOldJPEGInit(e,n,i,r);if(null!=f.jpegOffset)for(s=i+r-f.jpegOffset,c=new Uint8Array(s),p=0;p<s;p++)c[p]=n[f.jpegOffset+p];else{for(h=f.tables.length,(c=new Uint8Array(h+f.sosMarker.length+r+2)).set(f.tables),l=h,c[f.sofPosition+5]=e.height>>>8&255,c[f.sofPosition+6]=255&e.height,c[f.sofPosition+7]=e.width>>>8&255,c[f.sofPosition+8]=255&e.width,255==n[i]&&n[i+1]==SOS||(c.set(f.sosMarker,l),l+=sosMarker.length),p=0;p<r;p++)c[l++]=n[i+p];c[l++]=255,c[l++]=EOI}var u=new t.JpegDecoder;u.parse(c);for(var d=u.getData({width:u.width,height:u.height,forceRGB:!0,isSourcePDF:!1}),p=0;p<d.length;p++)a[o+p]=d[p];e.t262&&6==e.t262[0]&&(e.t262[0]=2)},t.decode._decodePackBits=function(t,e,n,i,r){for(var a=new Int8Array(t.buffer),o=new Int8Array(i.buffer),s=e+n;e<s;){var h=a[e];if(e++,h>=0&&h<128)for(var c=0;c<h+1;c++)o[r]=a[e],r++,e++;if(h>=-127&&h<0){for(c=0;c<1-h;c++)o[r]=a[e],r++;e++}}return r},t.decode._decodeThunder=function(t,e,n,i,r){for(var a=[0,1,0,-1],o=[0,1,2,3,0,-3,-2,-1],s=e+n,h=2*r,c=0;e<s;){var l=t[e],f=l>>>6,u=63&l;if(e++,3==f&&(c=15&u,i[h>>>1]|=c<<4*(1-h&1),h++),0==f)for(var d=0;d<u;d++)i[h>>>1]|=c<<4*(1-h&1),h++;if(2==f)for(d=0;d<2;d++)4!=(p=u>>>3*(1-d)&7)&&(c+=o[p],i[h>>>1]|=c<<4*(1-h&1),h++);if(1==f)for(d=0;d<3;d++){var p;2!=(p=u>>>2*(2-d)&3)&&(c+=a[p],i[h>>>1]|=c<<4*(1-h&1),h++)}}},t.decode._dmap={1:0,"011":1,"000011":2,"0000011":3,"010":-1,"000010":-2,"0000010":-3},t.decode._lens=function(){var t=function(t,e,n,i){for(var r=0;r<e.length;r++)t[e[r]]=n+r*i},e="00110101,000111,0111,1000,1011,1100,1110,1111,10011,10100,00111,01000,001000,000011,110100,110101,101010,101011,0100111,0001100,0001000,0010111,0000011,0000100,0101000,0101011,0010011,0100100,0011000,00000010,00000011,00011010,00011011,00010010,00010011,00010100,00010101,00010110,00010111,00101000,00101001,00101010,00101011,00101100,00101101,00000100,00000101,00001010,00001011,01010010,01010011,01010100,01010101,00100100,00100101,01011000,01011001,01011010,01011011,01001010,01001011,00110010,00110011,00110100",n="0000110111,010,11,10,011,0011,0010,00011,000101,000100,0000100,0000101,0000111,00000100,00000111,000011000,0000010111,0000011000,0000001000,00001100111,00001101000,00001101100,00000110111,00000101000,00000010111,00000011000,000011001010,000011001011,000011001100,000011001101,000001101000,000001101001,000001101010,000001101011,000011010010,000011010011,000011010100,000011010101,000011010110,000011010111,000001101100,000001101101,000011011010,000011011011,000001010100,000001010101,000001010110,000001010111,000001100100,000001100101,000001010010,000001010011,000000100100,000000110111,000000111000,000000100111,000000101000,000001011000,000001011001,000000101011,000000101100,000001011010,000001100110,000001100111",i="11011,10010,010111,0110111,00110110,00110111,01100100,01100101,01101000,01100111,011001100,011001101,011010010,011010011,011010100,011010101,011010110,011010111,011011000,011011001,011011010,011011011,010011000,010011001,010011010,011000,010011011",r="0000001111,000011001000,000011001001,000001011011,000000110011,000000110100,000000110101,0000001101100,0000001101101,0000001001010,0000001001011,0000001001100,0000001001101,0000001110010,0000001110011,0000001110100,0000001110101,0000001110110,0000001110111,0000001010010,0000001010011,0000001010100,0000001010101,0000001011010,0000001011011,0000001100100,0000001100101",a="00000001000,00000001100,00000001101,000000010010,000000010011,000000010100,000000010101,000000010110,000000010111,000000011100,000000011101,000000011110,000000011111";e=e.split(","),n=n.split(","),i=i.split(","),r=r.split(","),a=a.split(",");var o={},s={};return t(o,e,0,1),t(o,i,64,64),t(o,a,1792,64),t(s,n,0,1),t(s,r,64,64),t(s,a,1792,64),[o,s]}(),t.decode._decodeG4=function(e,n,i,r,a,o,s){for(var h=t.decode,c=n<<3,l=0,f="",u=[],d=[],p=0;p<o;p++)d.push(0);d=h._makeDiff(d);for(var m=0,g=0,b=0,w=0,y=0,_=0,v="",x=0,k=8*Math.ceil(o/8);c>>>3<n+i;){b=h._findDiff(d,m+(0==m?0:1),1-y),w=h._findDiff(d,b,y);var A=0;if(1==s&&(A=e[c>>>3]>>>7-(7&c)&1),2==s&&(A=e[c>>>3]>>>(7&c)&1),c++,f+=A,"H"==v){if(null!=h._lens[y][f]){var M=h._lens[y][f];f="",l+=M,M<64&&(h._addNtimes(u,l,y),m+=l,y=1-y,l=0,0==--x&&(v=""))}}else"0001"==f&&(f="",h._addNtimes(u,w-m,y),m=w),"001"==f&&(f="",v="H",x=2),null!=h._dmap[f]&&(g=b+h._dmap[f],h._addNtimes(u,g-m,y),m=g,f="",y=1-y);u.length==o&&""==v&&(h._writeBits(u,r,8*a+_*k),y=0,_++,m=0,d=h._makeDiff(u),u=[])}},t.decode._findDiff=function(t,e,n){for(var i=0;i<t.length;i+=2)if(t[i]>=e&&t[i+1]==n)return t[i]},t.decode._makeDiff=function(t){var e=[];1==t[0]&&e.push(0,1);for(var n=1;n<t.length;n++)t[n-1]!=t[n]&&e.push(n,t[n]);return e.push(t.length,0,t.length,1),e},t.decode._decodeG2=function(e,n,i,r,a,o,s){for(var h=t.decode,c=n<<3,l=0,f="",u=[],d=0,p=0,m=8*Math.ceil(o/8);c>>>3<n+i;){var g=0;1==s&&(g=e[c>>>3]>>>7-(7&c)&1),2==s&&(g=e[c>>>3]>>>(7&c)&1),c++,f+=g,null!=(l=h._lens[d][f])&&(h._addNtimes(u,l,d),f="",l<64&&(d=1-d),u.length==o&&(h._writeBits(u,r,8*a+p*m),u=[],p++,d=0,7&c&&(c+=8-(7&c)),l>=64&&(c+=8)))}},t.decode._decodeG3=function(e,n,i,r,a,o,s,h){for(var c=t.decode,l=n<<3,f=0,u="",d=[],p=[],m=0;m<o;m++)d.push(0);for(var g=0,b=0,w=0,y=0,_=0,v=-1,x="",k=0,A=!0,M=8*Math.ceil(o/8);l>>>3<n+i;){w=c._findDiff(p,g+(0==g?0:1),1-_),y=c._findDiff(p,w,_);var E=0;if(1==s&&(E=e[l>>>3]>>>7-(7&l)&1),2==s&&(E=e[l>>>3]>>>(7&l)&1),l++,u+=E,A){if(null!=c._lens[_][u]){var I=c._lens[_][u];u="",f+=I,I<64&&(c._addNtimes(d,f,_),_=1-_,f=0)}}else"H"==x?null!=c._lens[_][u]&&(I=c._lens[_][u],u="",f+=I,I<64&&(c._addNtimes(d,f,_),g+=f,_=1-_,f=0,0==--k&&(x=""))):("0001"==u&&(u="",c._addNtimes(d,y-g,_),g=y),"001"==u&&(u="",x="H",k=2),null!=c._dmap[u]&&(b=w+c._dmap[u],c._addNtimes(d,b-g,_),g=b,u="",_=1-_));u.endsWith("000000000001")&&(v>=0&&c._writeBits(d,r,8*a+v*M),h&&(1==s&&(A=1==(e[l>>>3]>>>7-(7&l)&1)),2==s&&(A=1==(e[l>>>3]>>>(7&l)&1)),l++),u="",_=0,v++,g=0,p=c._makeDiff(d),d=[])}d.length==o&&c._writeBits(d,r,8*a+v*M)},t.decode._addNtimes=function(t,e,n){for(var i=0;i<e;i++)t.push(n)},t.decode._writeBits=function(t,e,n){for(var i=0;i<t.length;i++)e[n+i>>>3]|=t[i]<<7-(n+i&7)},t.decode._decodeLZW=t.decode._decodeLZW=function(){var t,e,n,i,r=0,a=0,o=0,s=0,h=function(){var n=t>>>3,i=(e[n]<<16|e[n+1]<<8|e[n+2])>>>24-(7&t)-a&(1<<a)-1;return t+=a,i},c=new Uint32Array(16384),l=0,f=function(t){a=t+1,r=s+1},u=function(t){for(var e=t<<2,r=c[e+2],a=i+r-1;65535!=e;)n[a--]=c[e],e=c[e+1];i+=r},d=function(t,e){var n=r<<2,i=t<<2;c[n]=c[3+(e<<2)],c[n+1]=i,c[n+2]=c[i+2]+1,c[n+3]=c[i+3],1+ ++r==1<<a&&12!=a&&a++};return function(a,p,m,g,b,w){t=p<<3,e=a,n=g,i=b;var y=p+m<<3,_=0,v=0;for(function(t){if(t!=l){l=t,s=1+(o=1<<t);for(var e=0;e<s+1;e++)c[4*e]=c[4*e+3]=e,c[4*e+1]=65535,c[4*e+2]=1}}(w),f(w);t<y&&(_=h())!=s;){if(_==o){if(f(w),(_=h())==s)break;u(_)}else _<r?(u(_),d(v,_)):(d(v,v),u(r-1));v=_}return i}}(),t.tags={},t._types=((i=new Array(250)).fill(0),{basic:{main:i=i.concat([0,0,0,0,4,3,3,3,3,3,0,0,3,0,0,0,3,0,0,2,2,2,2,4,3,0,0,3,4,4,3,3,5,5,3,2,5,5,0,0,0,0,4,4,0,0,3,3,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,2,2,3,5,5,3,0,3,3,4,4,4,3,4,0,0,0,0,0,0,0,0,0,3,3,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),rest:{33432:2,33434:5,33437:5,34665:4,34850:3,34853:4,34855:3,34864:3,34866:4,36864:7,36867:2,36868:2,37121:7,37377:10,37378:5,37380:10,37381:5,37383:3,37384:3,37385:3,37386:5,37510:7,37520:2,37521:2,37522:2,40960:7,40961:3,40962:4,40963:4,40965:4,41486:5,41487:5,41488:3,41985:3,41986:3,41987:3,41988:5,41989:3,41990:3,41993:3,41994:3,41995:7,41996:3,42032:2,42033:2,42034:5,42036:2,42037:2,59932:7}},gps:{main:[1,2,5,2,5,1,5,5,0,9],rest:{18:2,29:2}}}),t._readIFD=function(n,i,r,a,o,s){var h=n.readUshort(i,r);r+=2;var c={};s.debug&&e("   ".repeat(o),a.length-1,">>>----------------");for(var l=0;l<h;l++){var f=n.readUshort(i,r);r+=2;var u=n.readUshort(i,r);r+=2;var d=n.readUint(i,r);r+=4;var p=n.readUint(i,r);r+=4;var m=[];if(1==u||7==u){var g=d<5?r-4:p;g+d>i.buffer.byteLength&&(d=i.buffer.byteLength-g),m=new Uint8Array(i.buffer,g,d)}if(2==u){var b=d<5?r-4:p,w=i[b],y=Math.max(0,Math.min(d-1,i.length-b));w<128||0==y?m.push(n.readASCII(i,b,y)):m=new Uint8Array(i.buffer,b,y)}if(3==u)for(var _=0;_<d;_++)m.push(n.readUshort(i,(d<3?r-4:p)+2*_));if(4==u||13==u)for(_=0;_<d;_++)m.push(n.readUint(i,(d<2?r-4:p)+4*_));if(5==u||10==u){var v=5==u?n.readUint:n.readInt;for(_=0;_<d;_++)m.push([v(i,p+8*_),v(i,p+8*_+4)])}if(8==u)for(_=0;_<d;_++)m.push(n.readShort(i,(d<3?r-4:p)+2*_));if(9==u)for(_=0;_<d;_++)m.push(n.readInt(i,(d<2?r-4:p)+4*_));if(11==u)for(_=0;_<d;_++)m.push(n.readFloat(i,p+4*_));if(12==u)for(_=0;_<d;_++)m.push(n.readDouble(i,p+8*_));if(0==d||0!=m.length){if(s.debug&&e("   ".repeat(o),f,u,t.tags[f],m),c["t"+f]=m,330==f&&c.t272&&"DSLR-A100"==c.t272[0]);else if(330==f||34665==f||34853==f||50740==f&&n.readUshort(i,n.readUint(m,0))<300||61440==f){var x=50740==f?[n.readUint(m,0)]:m,k=[];for(_=0;_<x.length;_++)t._readIFD(n,i,x[_],k,o+1,s);330==f&&(c.subIFD=k),34665==f&&(c.exifIFD=k[0]),34853==f&&(c.gpsiIFD=k[0]),50740==f&&(c.dngPrvt=k[0]),61440==f&&(c.fujiIFD=k[0])}if(37500==f&&s.parseMN){var A=m;if("Nikon"==n.readASCII(A,0,5))c.makerNote=t.decode(A.slice(10).buffer)[0];else if("OLYMP"==n.readASCII(A,0,5)||"OM SYSTEM"==n.readASCII(A,0,9)){var M=[8208,8224,8240,8256,8272],E=[];t._readIFD(n,A,77==A[1]?16:85==A[5]?12:8,E,o+1,s);var I=c.makerNote=E.pop();for(_=0;_<M.length;_++){var S="t"+M[_];null!=I[S]&&(t._readIFD(n,A,I[S][0],E,o+1,s),I[S]=E.pop())}I.t12288&&(t._readIFD(n,I.t12288,0,E,o+1,s),I.t12288=E.pop())}else n.readUshort(i,p)<300&&n.readUshort(i,p+4)<=12&&(E=[],t._readIFD(n,i,p,E,o+1,s),c.makerNote=E[0])}}else if(e(f,"unknown TIFF tag type: ",u,"num:",d),0==l)return}return a.push(c),s.debug&&e("   ".repeat(o),"<<<---------------"),r},t._writeIFD=function(e,n,i,r,a){var o=Object.keys(a),s=o.length;a.exifIFD&&s--,a.gpsiIFD&&s--,e.writeUshort(i,r,s);for(var h=(r+=2)+12*s+4,c=0;c<o.length;c++){var l=o[c];if("t34665"!=l&&"t34853"!=l){"exifIFD"==l&&(l="t34665"),"gpsiIFD"==l&&(l="t34853");var f=parseInt(l.slice(1)),u=n.main[f];if(null==u&&(u=n.rest[f]),null==u||0==u)throw new Error("unknown type of tag: "+f);var d=a[l];34665==f&&(d=[h],h=t._writeIFD(e,n,i,h,a.exifIFD)[1]),34853==f&&(d=[h],h=t._writeIFD(e,t._types.gps,i,h,a.gpsiIFD)[1]),2==u&&(d=d[0]+"\0");var p=d.length;e.writeUshort(i,r,f),r+=2,e.writeUshort(i,r,u),r+=2,e.writeUint(i,r,p);var m=[-1,1,1,2,4,8,0,1,0,4,8,0,8][u]*p,g=r+=4;if(m>4&&(e.writeUint(i,r,h),g=h),1==u||7==u)for(var b=0;b<p;b++)i[g+b]=d[b];else if(2==u)e.writeASCII(i,g,d);else if(3==u)for(b=0;b<p;b++)e.writeUshort(i,g+2*b,d[b]);else if(4==u)for(b=0;b<p;b++)e.writeUint(i,g+4*b,d[b]);else if(5==u||10==u){var w=5==u?e.writeUint:e.writeInt;for(b=0;b<p;b++){var y=d[b],_=y[0],v=y[1];if(null==_)throw"e";w(i,g+8*b,_),w(i,g+8*b+4,v)}}else if(9==u)for(b=0;b<p;b++)e.writeInt(i,g+4*b,d[b]);else{if(12!=u)throw u;for(b=0;b<p;b++)e.writeDouble(i,g+8*b,d[b])}m>4&&(h+=m+=1&m),r+=4}}return[r,h]},t.toRGBA8=function(t,n){function i(t){return t<.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055}var r=t.width,a=t.height,o=r*a,s=t.data,h=new Uint8Array(4*o),c=t.t262?t.t262[0]:2,l=t.t258?Math.min(32,t.t258[0]):1;null==t.t262&&1==l&&(c=0);var f=t.t277?t.t277[0]:t.t258?t.t258.length:[1,1,3,1,1,4,3][c],u=t.t339?t.t339[0]:null;if(1==c&&32==l&&3!=u)throw"e";var d=Math.ceil(f*l*r/8);if(0==c){n=1/256;for(var p=0;p<a;p++){var m=p*d,g=p*r;if(1==l)for(var b=0;b<r;b++){var w=g+b<<2,y=s[m+(b>>3)]>>7-(7&b)&1;h[w]=h[w+1]=h[w+2]=255*(1-y),h[w+3]=255}if(4==l)for(b=0;b<r;b++)w=g+b<<2,y=s[m+(b>>1)]>>4-4*(1&b)&15,h[w]=h[w+1]=h[w+2]=17*(15-y),h[w+3]=255;if(8==l)for(b=0;b<r;b++)w=g+b<<2,y=s[m+b],h[w]=h[w+1]=h[w+2]=255-y,h[w+3]=255;if(16==l)for(b=0;b<r;b++)w=g+b<<2,y=s[(v=m+2*b)+1]<<8|s[v],h[w]=h[w+1]=h[w+2]=Math.min(255,255-~~(y*n)),h[w+3]=255}}else if(1==c){null==n&&(n=1/256);var _=3&s.length?null:new Float32Array(s.buffer);for(p=0;p<a;p++){if(m=p*d,g=p*r,1==l)for(b=0;b<r;b++)w=g+b<<2,y=s[m+(b>>3)]>>7-(7&b)&1,h[w]=h[w+1]=h[w+2]=255*y,h[w+3]=255;if(2==l)for(b=0;b<r;b++)w=g+b<<2,y=s[m+(b>>2)]>>6-2*(3&b)&3,h[w]=h[w+1]=h[w+2]=85*y,h[w+3]=255;if(8==l)for(b=0;b<r;b++)w=g+b<<2,y=s[m+b*f],h[w]=h[w+1]=h[w+2]=y,h[w+3]=255;if(16==l)for(b=0;b<r;b++)w=g+b<<2,y=s[(v=m+2*b)+1]<<8|s[v],h[w]=h[w+1]=h[w+2]=Math.min(255,~~(y*n)),h[w+3]=255;if(32==l)for(b=0;b<r;b++){var v;w=g+b<<2,y=_[v=(m>>>2)+b],h[w]=h[w+1]=h[w+2]=~~(.5+255*y),h[w+3]=255}}}else if(2==c)if(8==l){if(1==f)for(b=0;b<o;b++)h[4*b]=h[4*b+1]=h[4*b+2]=s[b],h[4*b+3]=255;if(3==f)for(b=0;b<o;b++){var x=3*b;h[w=b<<2]=s[x],h[w+1]=s[x+1],h[w+2]=s[x+2],h[w+3]=255}if(f>=4)for(b=0;b<o;b++)x=b*f,h[w=b<<2]=s[x],h[w+1]=s[x+1],h[w+2]=s[x+2],h[w+3]=s[x+3]}else if(16==l){if(4==f)for(b=0;b<o;b++)x=8*b+1,h[w=b<<2]=s[x],h[w+1]=s[x+2],h[w+2]=s[x+4],h[w+3]=s[x+6];if(3==f)for(b=0;b<o;b++)x=6*b+1,h[w=b<<2]=s[x],h[w+1]=s[x+2],h[w+2]=s[x+4],h[w+3]=255}else{if(32!=l)throw l;var k=new Float32Array(s.buffer),A=0;for(b=0;b<k.length;b++)A=Math.min(A,k[b]);if(A<0)for(b=0;b<s.length;b+=4){var M=s[b];s[b]=s[b+3],s[b+3]=M,M=s[b+1],s[b+1]=s[b+2],s[b+2]=M}var E=[];for(b=0;b<65536;b++)E.push(i(b/65535));for(b=0;b<k.length;b++){var I=Math.max(0,Math.min(1,k[b]));k[b]=E[~~(.5+65535*I)]}if(3==f)for(b=0;b<o;b++)x=3*b,h[w=b<<2]=~~(.5+255*k[x]),h[w+1]=~~(.5+255*k[x+1]),h[w+2]=~~(.5+255*k[x+2]),h[w+3]=255;else{if(4!=f)throw f;for(b=0;b<o;b++)x=4*b,h[w=b<<2]=~~(.5+255*k[x]),h[w+1]=~~(.5+255*k[x+1]),h[w+2]=~~(.5+255*k[x+2]),h[w+3]=~~(.5+255*k[x+3])}}else if(3==c){var S=t.t320,z=1<<l,B=8==l&&f>1&&t.t338&&0!=t.t338[0];for(p=0;p<a;p++)for(var C=0;C<r;C++){w=(b=p*r+C)<<2;var P=0,T=p*d;if(1==l)P=s[T+(C>>>3)]>>>7-(7&C)&1;else if(2==l)P=s[T+(C>>>2)]>>>6-2*(3&C)&3;else if(4==l)P=s[T+(C>>>1)]>>>4-4*(1&C)&15;else{if(8!=l)throw l;P=s[T+C*f]}h[w]=S[P]>>8,h[w+1]=S[z+P]>>8,h[w+2]=S[z+z+P]>>8,h[w+3]=B?s[T+C*f+1]:255}}else if(5==c){var U=f>4?1:0;for(b=0;b<o;b++){w=b<<2;var O=b*f;if(window.UDOC){var L=s[O],R=s[O+1],F=s[O+2],D=s[O+3],N=UDOC.C.cmykToRgb([L*(1/255),R*(1/255),F*(1/255),D*(1/255)]);h[w]=~~(.5+255*N[0]),h[w+1]=~~(.5+255*N[1]),h[w+2]=~~(.5+255*N[2])}else L=255-s[O],R=255-s[O+1],F=255-s[O+2],D=(255-s[O+3])*(1/255),h[w]=~~(L*D+.5),h[w+1]=~~(R*D+.5),h[w+2]=~~(F*D+.5);h[w+3]=255*(1-U)+s[O+4]*U}}else if(6==c&&t.t278){var $=t.t278[0];for(p=0;p<a;p+=$){b=p*r;for(var j=$*r,G=0;G<j;G++){w=4*(b+G),F=s[(O=3*b+4*(G>>>1))+(1&G)];var H=s[O+2]-128,Z=s[O+3]-128,q=F+((Z>>2)+(Z>>3)+(Z>>5)),W=F-((H>>2)+(H>>4)+(H>>5))-((Z>>1)+(Z>>3)+(Z>>4)+(Z>>5)),V=F+(H+(H>>1)+(H>>2)+(H>>6));h[w]=Math.max(0,Math.min(255,q)),h[w+1]=Math.max(0,Math.min(255,W)),h[w+2]=Math.max(0,Math.min(255,V)),h[w+3]=255}}}else if(32845==c)for(p=0;p<a;p++)for(C=0;C<r;C++){w=4*(p*r+C);var J=s[1+(O=6*(p*r+C))]<<8|s[O],Y=(J=Math.pow(2,(J+.5)/256-64),(s[O+3]+.5)/410),X=(s[O+5]+.5)/410,K=9*Y/(6*Y-16*X+12),Q=4*X/(6*Y-16*X+12),tt=K*J/Q,et=(1-K-Q)*J/Q;q=2.69*tt-1.276*(F=J)-.414*et,W=-1.022*tt+1.978*F+.044*et,V=.061*tt-.224*F+1.163*et,h[w]=255*i(Math.min(q,1)),h[w+1]=255*i(Math.min(W,1)),h[w+2]=255*i(Math.min(V,1)),h[w+3]=255}else e("Unknown Photometric interpretation: "+c);return h},t.replaceIMG=function(e){null==e&&(e=document.getElementsByTagName("img"));for(var n=["tif","tiff","dng","cr2","nef"],i=0;i<e.length;i++){var r=e[i],a=r.getAttribute("src");if(null!=a){var o=a.split(".").pop().toLowerCase();if(-1!=n.indexOf(o)){var s=new XMLHttpRequest;t._xhrs.push(s),t._imgs.push(r),s.open("GET",a),s.responseType="arraybuffer",s.onload=t._imgLoaded,s.send()}}}},t._xhrs=[],t._imgs=[],t._imgLoaded=function(e){var n=t._xhrs.indexOf(e.target),i=t._imgs[n];t._xhrs.splice(n,1),t._imgs.splice(n,1),i.setAttribute("src",t.bufferToURI(e.target.response))},t.bufferToURI=function(e){var n=t.decode(e),i=n,r=0,a=i[0];n[0].subIFD&&(i=i.concat(n[0].subIFD));for(var o=0;o<i.length;o++){var s=i[o];if(!(null==s.t258||s.t258.length<3)){var h=s.t256*s.t257;h>r&&(r=h,a=s)}}t.decodeImage(e,a,n);var c=t.toRGBA8(a),l=a.width,f=a.height,u=document.createElement("canvas");u.width=l,u.height=f;var d=u.getContext("2d"),p=new ImageData(new Uint8ClampedArray(c.buffer),l,f);return d.putImageData(p,0,0),u.toDataURL()},t._binBE={nextZero:function(t,e){for(;0!=t[e];)e++;return e},readUshort:function(t,e){return t[e]<<8|t[e+1]},readShort:function(e,n){var i=t._binBE.ui8;return i[0]=e[n+1],i[1]=e[n+0],t._binBE.i16[0]},readInt:function(e,n){var i=t._binBE.ui8;return i[0]=e[n+3],i[1]=e[n+2],i[2]=e[n+1],i[3]=e[n+0],t._binBE.i32[0]},readUint:function(e,n){var i=t._binBE.ui8;return i[0]=e[n+3],i[1]=e[n+2],i[2]=e[n+1],i[3]=e[n+0],t._binBE.ui32[0]},readASCII:function(t,e,n){for(var i="",r=0;r<n;r++)i+=String.fromCharCode(t[e+r]);return i},readFloat:function(e,n){for(var i=t._binBE.ui8,r=0;r<4;r++)i[r]=e[n+3-r];return t._binBE.fl32[0]},readDouble:function(e,n){for(var i=t._binBE.ui8,r=0;r<8;r++)i[r]=e[n+7-r];return t._binBE.fl64[0]},writeUshort:function(t,e,n){t[e]=n>>8&255,t[e+1]=255&n},writeInt:function(e,n,i){var r=t._binBE.ui8;t._binBE.i32[0]=i,e[n+3]=r[0],e[n+2]=r[1],e[n+1]=r[2],e[n+0]=r[3]},writeUint:function(t,e,n){t[e]=n>>24&255,t[e+1]=n>>16&255,t[e+2]=n>>8&255,t[e+3]=255&n},writeASCII:function(t,e,n){for(var i=0;i<n.length;i++)t[e+i]=n.charCodeAt(i)},writeDouble:function(e,n,i){t._binBE.fl64[0]=i;for(var r=0;r<8;r++)e[n+r]=t._binBE.ui8[7-r]}},t._binBE.ui8=new Uint8Array(8),t._binBE.i16=new Int16Array(t._binBE.ui8.buffer),t._binBE.i32=new Int32Array(t._binBE.ui8.buffer),t._binBE.ui32=new Uint32Array(t._binBE.ui8.buffer),t._binBE.fl32=new Float32Array(t._binBE.ui8.buffer),t._binBE.fl64=new Float64Array(t._binBE.ui8.buffer),t._binLE={nextZero:t._binBE.nextZero,readUshort:function(t,e){return t[e+1]<<8|t[e]},readShort:function(e,n){var i=t._binBE.ui8;return i[0]=e[n+0],i[1]=e[n+1],t._binBE.i16[0]},readInt:function(e,n){var i=t._binBE.ui8;return i[0]=e[n+0],i[1]=e[n+1],i[2]=e[n+2],i[3]=e[n+3],t._binBE.i32[0]},readUint:function(e,n){var i=t._binBE.ui8;return i[0]=e[n+0],i[1]=e[n+1],i[2]=e[n+2],i[3]=e[n+3],t._binBE.ui32[0]},readASCII:t._binBE.readASCII,readFloat:function(e,n){for(var i=t._binBE.ui8,r=0;r<4;r++)i[r]=e[n+r];return t._binBE.fl32[0]},readDouble:function(e,n){for(var i=t._binBE.ui8,r=0;r<8;r++)i[r]=e[n+r];return t._binBE.fl64[0]},writeUshort:function(t,e,n){t[e]=255&n,t[e+1]=n>>8&255},writeInt:function(e,n,i){var r=t._binBE.ui8;t._binBE.i32[0]=i,e[n+0]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3]},writeUint:function(t,e,n){t[e]=n>>>0&255,t[e+1]=n>>>8&255,t[e+2]=n>>>16&255,t[e+3]=n>>>24&255},writeASCII:t._binBE.writeASCII},t._copyTile=function(t,e,n,i,r,a,o,s){for(var h=Math.min(e,r-o),c=Math.min(n,a-s),l=0;l<c;l++)for(var f=(s+l)*r+o,u=l*e,d=0;d<h;d++)i[f+d]=t[u+d]},t.LosslessJpegDecode=function(){var t,e;function n(){return t[e++]}function i(){return t[e++]<<8|t[e++]}function r(t){for(var e=n(),i=[0,0,0,255],r=[],o=0;o<16;o++)r[o]=n();for(o=0;o<16;o++)for(var s=0;s<r[o];s++)i[a(i,0,o+1,1)+3]=n();var h=new Uint8Array(256);for(t[e]=[new Uint8Array(i),h],o=0;o<256;o++){for(var c=8,l=o,f=0;255==i[f+3]&&0!=c;)f=i[f+(l>>--c&1)];h[o]=f}}function a(t,e,n,i){if(255!=t[e+3])return 0;if(0==n)return e;for(var r=0;r<2;r++){0==t[e+r]&&(t[e+r]=t.length,t.push(0,0,i,255));var o=a(t,t[e+r],n-1,i+1);if(0!=o)return o}return 0}function o(t){for(var e=t.b,n=t.f;e<25&&t.a<t.d;){var i=t.data[t.a++];255!=i||t.c||t.a++,n=n<<8|i,e+=8}if(e<0)throw"e";t.b=e,t.f=n}function s(t,e){return e.b<t&&o(e),e.f>>(e.b-=t)&65535>>16-t}function h(t,e){var n=t[0],i=0,r=255;e.b<16&&o(e);var a=e.f>>e.b-8&255;for(r=n[(i=t[1][a])+3],e.b-=n[i+2];255==r;)r=n[(i=n[i+(e.f>>--e.b&1)])+3];return r}function c(t,e){return t<32768>>16-e&&(t+=1-(1<<e)),t}function l(t,e){var n=h(t,e);return 0==n?0:16==n?-32768:c(s(n,e),n)}function f(t,e,n,i,r,a){for(var o=0,s=0;s<a;s++){for(var h=s*e,c=0;c<e;c+=r){o++;for(var f=0;f<r;f++)t[h+c+f]=l(i[f],n)}if(0!=n.e&&o%n.e==0&&0!=s){for(var u=n.a,d=n.data;255!=d[u]||!(208<=d[u+1]&&d[u+1]<=215);)u--;n.a=u+2,n.f=0,n.b=0}}}function u(t,e){return c(s(t,e),t)}function d(t,e,n,i,r,a,o,s){for(var h=n*o,c=r;c<a;c++)t[c]+=1<<s-1;for(var l=o;l<h;l+=o)for(c=r;c<a;c++)t[l+c]+=t[l+c-o];for(var f=1;f<i;f++){var u=f*h;for(c=r;c<a;c++)t[u+c]+=t[u+c-h];for(l=o;l<h;l+=o)for(c=r;c<a;c++){var d=u+l+c,p=d-h,m=t[d-o],g=0;if(0==e)g=0;else if(1==e)g=m;else if(2==e)g=t[p];else if(3==e)g=t[p-o];else if(4==e)g=m+(t[p]-t[p-o]);else if(5==e)g=m+(t[p]-t[p-o]>>>1);else if(6==e)g=t[p]+(m-t[p-o]>>>1);else{if(7!=e)throw e;g=m+t[p]>>>1}t[d]+=g}}}return function(a){if(t=a,e=0,65496!=i())throw"e";for(var o=[],s=0,c=0,l=0,p=[],m=[],g=[],b=0,w=0,y=0;;){var _=i();if(65535!=_){var v=i();if(65475==_){c=n(),w=i(),y=i(),b=n();for(var x=0;x<b;x++){var k=n(),A=n();if(0!=n())throw"e";o[k]=[x,A>>4,15&A]}}else if(65476==_)for(var M=e+v-2;e<M;)r(m);else{if(65498==_){for(e++,x=0;x<b;x++){var E=o[n()];g[E[0]]=m[n()>>>4],p[E[0]]=E.slice(1)}s=n(),e+=2;break}65501==_?l=i():e+=v-2}}else e--}var I=new(c>8?Uint16Array:Uint8Array)(w*y*b),S={b:0,f:0,c:8==s,a:e,data:t,d:t.length,e:l};if(S.c)!function(n,i,r,a,o){for(var s=t.length-e,c=0;c<s;c+=4){var l=t[e+c];t[e+c]=t[e+c+3],t[e+c+3]=l,l=t[e+c+1],t[e+c+1]=t[e+c+2],t[e+c+2]=l}for(var f=0;f<o;f++)for(var d=32768,p=32768,m=0;m<i;m+=2){var g=h(a,r),b=h(a,r);0!=g&&(d+=u(g,r)),0!=b&&(p+=u(b,r)),n[f*i+m]=65535&d,n[f*i+m+1]=65535&p}}(I,y*b,S,g[0],w);else{var z=[],B=0,C=0;for(x=0;x<b;x++){var P=p[x];(j=P[0])>B&&(B=j),($=P[1])>C&&(C=$),z.push(j*$)}if(1!=B||1!=C){if(3!=b||1!=z[1]||1!=z[2])throw"e";if(2!=B||1!=C&&2!=C)throw"e";var T=[],U=0;for(x=0;x<b;x++){for(var O=0;O<z[x];O++)T.push(g[x]);U+=z[x]}var L=y/B,R=w/C,F=L*R;f(I,L*U,S,T,U,R),d(I,s,L,R,U-2,U,U,c);var D=new Uint16Array(F*z[0]);if(2==B&&2==C){for(x=0;x<F;x++)D[4*x]=I[6*x],D[4*x+1]=I[6*x+1],D[4*x+2]=I[6*x+2],D[4*x+3]=I[6*x+3];for(d(D,s,4*L,R,0,1,1,c),x=0;x<F;x++)I[6*x]=D[4*x],I[6*x+1]=D[4*x+1],I[6*x+2]=D[4*x+2],I[6*x+3]=D[4*x+3]}if(2==B&&1==C){for(x=0;x<F;x++)D[2*x]=I[4*x],D[2*x+1]=I[4*x+1];for(d(D,s,2*L,R,0,1,1,c),x=0;x<F;x++)I[4*x]=D[2*x],I[4*x+1]=D[2*x+1]}for(var N=I.slice(0),$=0;$<w;$++)if(2==C)for(var j=0;j<y;j++){var G=(($>>>1)*L+(j>>>1))*U,H=2*(1&$)+(1&j);I[Z=($*y+j)*b]=N[G+H],I[Z+1]=N[G+4],I[Z+2]=N[G+5]}else for(j=0;j<y;j++){var Z;G=($*L+(j>>>1))*U,H=1&j,I[Z=($*y+j)*b]=N[G+H],I[Z+1]=N[G+2],I[Z+2]=N[G+3]}}else if(f(I,y*b,S,g,b,w),0==l)d(I,s,y,w,0,b,b,c);else{var q=Math.floor(l/y);for($=0;$<w;$+=q){var W=I.slice($*y*b,($+q)*y*b);d(W,s,y,q,0,b,b,c),I.set(W,$*y*b)}}}return I}}(),function(){var e=5,n=6,i=13,r=14;function a(t){var e={c:new Int8Array(2<<t.u)};return function(t,e,n){var i=[e,3*e+18,5*e+67,7*e+276,n];t.o=e,t.w=(i[4]+2*e)/(2*e+1)+1|0,t.v=Math.ceil(Math.log2(t.w)),t.t=9,function(t,e){for(var n=-e[4],i=0;n<=e[4];i++,n++)t[i]=n<=-276?-4:n<=-67?-3:n<=-18?-2:n<-0?-1:n<=e[0]?0:n<e[1]?1:n<e[2]?2:n<e[3]?3:4}(t.c,i)}(e,0,t.g),e}function o(t){for(var e=[[],[],[]],n=Math.max(2,t.w+32>>>6),i=0;i<3;i++)for(var r=0;r<41;r++)e[i][r]=[n,1];return e}function s(t,e){var n=0,i=8-t.a;if(t.j,t.a,e){if(e>=i)do{n<<=i,e-=i,n|=t[t.j]&(1<<i)-1,t.j++,i=8}while(e>=8);e&&(n<<=e,i-=e,n|=t[t.j]>>>i&(1<<e)-1),t.a=8-i}return n}function h(t,e,n,i,r,a,o,h){null==h&&(h=0);var c,l,f,u,d,p,m=a+1,g=m%2,b=0,w=i[r],y=i[r-1],_=i[r-2][m],v=y[m-1],x=y[m],k=y[m+1],A=w[m-1],M=w[m+1],E=Math.abs;if(g&&(f=E(k-x),u=E(_-x),d=E(v-x)),g){if(p=(p=f>d&&u<f?_+v:f<d&&u<d?_+k:k+v)+2*x>>>2,h)return void(w[m]=p);c=e.t*e.c[t.g+x-_]+e.c[t.g+v-x]}else p=x>v&&x>k||x<v&&x<k?M+A+2*x>>>2:A+M>>>1,c=e.t*e.c[t.g+x-v]+e.c[t.g+v-A];l=E(c);var I=function(t){for(var e=-1,n=0;!n;e++)n=t[t.j]>>>7-t.a&1,t.a++,t.a&=7,t.a||t.j++;return e}(n);if(I<t.n-e.v-1){var S=function(t,e){var n=0;if(e<t)for(;n<=14&&e<<++n<t;);return n}(o[l][0],o[l][1]);b=s(n,S)+(I<<S)}else b=s(n,e.v)+1;b=1&b?-1-(b>>>1):b>>>1,o[l][0]+=E(b),o[l][1]==t.f&&(o[l][0]>>>=1,o[l][1]>>>=1),o[l][1]++,p=c<0?p-b:p+b,t.i&&(p<0?p+=e.w:p>t.g&&(p-=e.w)),w[m]=p>=0?Math.min(p,t.g):0}function c(t,e,n){for(var i=t[0].length,r=e;r<=n;r++)t[r][0]=t[r-1][1],t[r][i-1]=t[r-1][i-2]}function l(t){c(t,7,12),c(t,2,4),c(t,15,17)}function f(t,e,n,r,a,o,s,c,f,u,d,p,m){for(var g=0,b=1,w=a<i&&a>4;b<t.m;)g<t.m&&(h(t,e,n,r,a,g,s[f],t.h&&(w&&u||!w&&(d||(g&p)==m))),h(t,e,n,r,o,g,s[f],t.h&&(!w&&u||w&&(d||(g&p)==m))),g+=2),g>8&&(h(t,e,n,r,a,b,c[f]),h(t,e,n,r,o,b,c[f]),b+=2);l(r)}function u(t,e,n,i,r,a){f(t,e,n,i,2,7,r,a,0,0,1,0,8),f(t,e,n,i,8,15,r,a,1,0,1,0,8),f(t,e,n,i,3,9,r,a,2,1,0,3,0),f(t,e,n,i,10,16,r,a,0,0,0,3,2),f(t,e,n,i,4,11,r,a,1,0,0,3,2),f(t,e,n,i,12,17,r,a,2,1,0,3,0)}function d(t,e,n,i,r,a){var o=a.length,s=t.l;r+1==t.s&&(s=t.e-r*t.l);for(var h=6*t.e*i+r*t.l,c=0;c<6;c++){for(var l=0;l<s;l++){var f,u=a[c%o][l%o];f=0==u?2+(c>>>1):2==u?15+(c>>>1):7+c;var d=t.h?(2*l/3&2147483646|l%3&1)+(l%3>>>1):l>>>1;e[h+l]=n[f][d+1]}h+=t.e}}t._decompressRAF=function(s,h){var c=function(e){var n=t._binBE.readUshort,i={b:n(e,0),i:e[2],C:e[3],u:e[4],q:n(e,5),k:n(e,7),e:n(e,9),l:n(e,11),s:e[13],d:n(e,14)};if(18771!=i.b||i.i>1||i.q<6||i.q%6||i.e<768||i.e%24||768!=i.l||i.k<i.l||i.k%i.l||i.k-i.e>=i.l||i.s>16||i.s!=i.k/i.l||i.s!=Math.ceil(i.e/i.l)||i.d!=i.q/6||12!=i.u&&14!=i.u&&16!=i.u||16!=i.C&&0!=i.C)throw"Invalid data";if(0==i.i)throw"Not implemented. We need this file!";return i.h=16==i.C,i.m=0|(i.h?2*i.l/3:i.l>>>1),i.A=i.m+2,i.f=64,i.g=(1<<i.u)-1,i.n=4*i.u,i}(s),f=function(e,n){var i=new Array(n.s),r=4*n.s,a=16+r;12&r&&(a+=16-(12&r));for(var o=0,s=16;o<n.s;s+=4){var h=t._binBE.readUint(e,s);i[o]=e.slice(a,a+h),i[o].j=0,i[o].a=0,a+=h,o++}if(a!=e.length)throw"Invalid data";return i}(s,c),p=a(c),m=new Int16Array(c.e*c.q);null==h&&(h=c.h?[[1,1,0,1,1,2],[1,1,2,1,1,0],[2,0,1,0,2,1],[1,1,2,1,1,0],[1,1,0,1,1,2],[0,2,1,2,0,1]]:[[0,1],[3,2]]);for(var g=[[0,3],[1,4],[e,11],[n,12],[i,16],[r,17]],b=[],w=0;w<18;w++)b[w]=new Uint16Array(c.A);for(var y=0;y<c.s;y++){var _=o(p),v=o(p);for(w=0;w<18;w++)for(var x=0;x<c.A;x++)b[w][x]=0;for(var k=0;k<c.d;k++){for(u(c,p,f[y],b,_,v),w=0;w<6;w++)for(x=0;x<c.A;x++)b[g[w][0]][x]=b[g[w][1]][x];for(d(c,m,b,k,y,h),w=2;w<18;w++)if(-1==[e,n,i,r].indexOf(w))for(x=0;x<c.A;x++)b[w][x]=0;l(b)}}return m}}()}(t,sb())}();var hb=e(bg.exports);const cb=3,lb=4,fb=5,ub={[cb]:2,[lb]:4,[fb]:8};function db({type:t,values:e}){return ub[t]*(5===t?e.length/2:e.length)}function pb({width:t,height:e},n,i,r){return[{tag:254,type:4,values:[i>1?2:0]},{tag:256,type:4,values:[t]},{tag:257,type:4,values:[e]},{tag:258,type:3,values:[8,8,8,8]},{tag:259,type:3,values:[1]},{tag:262,type:3,values:[2]},{tag:273,type:4,values:[r]},{tag:277,type:3,values:[4]},{tag:278,type:4,values:[e]},{tag:279,type:4,values:[t*e*4]},{tag:282,type:5,values:[72,1]},{tag:283,type:5,values:[72,1]},{tag:284,type:3,values:[1]},{tag:296,type:3,values:[2]},{tag:297,type:3,values:[n,i]},{tag:338,type:3,values:[2]}]}function mb(t){const e=8+t.map(e=>function(t){let e=2+12*t.length+4;for(const n of t){const t=db(n);t>4&&(e+=t)}return e}(pb(e,0,t.length,0))+e.width*e.height*4).reduce((t,e)=>t+e,0);if(e>4294967295)throw new Error(`A TIFF can't be larger than 4 GB, but these pages need ${e} bytes`);const n=new Uint8Array(e),i=new DataView(n.buffer);let r=0;return n.set([73,73,42,0],0),i.setUint32(4,8,!0),r=8,t.forEach((e,a)=>{const o=r,s=pb(e,a,t.length,0),h=o+2+12*s.length+4;let c=h;for(const t of s){const e=db(t);e>4&&(c+=e)}const l=c,f=pb(e,a,t.length,l);i.setUint16(r,f.length,!0),r+=2,c=h;for(const t of f){const{tag:e,type:n,values:a}=t,o=db(t);i.setUint16(r,e,!0),i.setUint16(r+2,n,!0),i.setUint32(r+4,5===n?a.length/2:a.length,!0);let s=r+8;o>4&&(i.setUint32(r+8,c,!0),s=c,c+=o);for(const t of a)3===n?(i.setUint16(s,t,!0),s+=2):(i.setUint32(s,t,!0),s+=4);r+=12}const u=a===t.length-1,d=l+e.width*e.height*4;i.setUint32(r,u?0:d,!0),n.set(e.data.subarray(0,e.width*e.height*4),l),r=d}),n}const gb={1:1,2:1,3:2,4:4,5:8,7:1,8:2,9:4,10:8,11:4,12:8,13:4},bb=[330,34665,34853,61440];function wb(t){return"number"==typeof t?t:t instanceof Uint8Array?t[0]:"string"==typeof t[0]?parseInt(t[0]):t[0]}function yb(t){return Number.isInteger(t)&&t>0}function _b(t,e){const n=t[`t${e}`];return void 0===n?void 0:wb(n)}function vb(t,e,n,i,r){const a=1e6*r;if(!yb(n)||!yb(i))throw new Error(`Invalid TIFF dimensions ${n}x${i}`);if(n*i>a)throw new Error(`TIFF dimensions ${n}x${i} exceed the maximum resolution of ${r} megapixels`);const o=_b(e,259)??1,s=_b(e,258)??1,h=_b(e,279),c=_b(e,278);let l=s*(_b(e,277)??1);if(1===o&&void 0!==h&&void 0!==c&&32803===_b(e,262)&&(l=Math.round(8*h/(n*c))),4===_b(e,50885)&&(l=3*s),!yb(l)||l>128)throw new Error(`Unsupported TIFF bits per pixel ${l}`);if(void 0!==e.t322){const t=_b(e,322),n=_b(e,323);if(!yb(t)||!yb(n))throw new Error(`Invalid TIFF tile size ${t}x${n}`);if(t*n>a)throw new Error(`TIFF tile size ${t}x${n} exceeds the maximum resolution of ${r} megapixels`)}else if(1===o&&i*Math.ceil(n*l/8)>t.length)throw new Error(`TIFF data is too short for an uncompressed image of ${n}x${i} at ${l} bits per pixel`)}function xb(t){if(!t.t256)throw new Error("No image width found in TIFF");if(!t.t257)throw new Error("No image height found in TIFF");return{width:wb(t.t256),height:wb(t.t257)}}function kb(t,e){const{width:i,height:r}=xb(e);hb.decodeImage(t,e);const a=5===_b(e,262)?function(t){const e=_b(t,258)??1,n=_b(t,277)??1;if(8!==e&&16!==e)throw new Error(`Unsupported CMYK TIFF bits per sample ${e}, only 8 and 16 are supported`);if(n<4)throw new Error(`Invalid CMYK TIFF: expected at least 4 samples per pixel, got ${n}`);const i=t.data,r=e/8,a=2**e-1,o=255/(a*a),s=n>4,h=t.width*t.height,c=new Uint8Array(4*h),l=t=>1===r?i[t]:i[2*t]|i[2*t+1]<<8;for(let t=0;t<h;t++){const e=t*n,i=a-l(e+3);c[4*t]=Math.round((a-l(e))*i*o),c[4*t+1]=Math.round((a-l(e+1))*i*o),c[4*t+2]=Math.round((a-l(e+2))*i*o),c[4*t+3]=s?Math.round(255*l(e+4)/a):255}return c}(e):hb.toRGBA8(e);return{data:n.Buffer.from(a),width:i,height:r}}function Ab(t,e,i){!function(t){if(t.length<8)throw new Error("Invalid TIFF file: header is truncated");const e=73===t[0]&&73===t[1],i=77===t[0]&&77===t[1];if(!e&&!i)throw new Error("Invalid TIFF file: unknown byte order");const r=e=>t[e]??0,a=t=>e?r(t)|r(t+1)<<8:r(t)<<8|r(t+1),o=t=>e?a(t)+65536*a(t+2)>>>0:65536*a(t)+a(t+2)>>>0,s=new Set;let h=0;const c=e=>{if(h+=e,h>t.length)throw new Error("Invalid TIFF file: IFDs declare more data than the file holds")};function l(t,i){if(i>16)throw new Error("Invalid TIFF file: IFDs are nested too deeply");if(s.has(t))throw new Error(`Invalid TIFF file: IFD at offset ${t} is referenced more than once`);s.add(t);const h=a(t);c(2+12*h+4);for(let s=0;s<h;s++){const h=t+2+12*s,f=a(h),u=a(h+2),d=o(h+4),p=gb[u];if(!p){if(0===s&&0!==d)return;continue}const m=d*p<=4,g=m?h+8:o(h+8);if(m||c(d*p),50740===f){if(1!==u&&7!==u)throw new Error(`Invalid TIFF file: tag ${f} has type ${u}`);const t=n.Buffer.alloc(4);for(let e=0;e<Math.min(4,d);e++)t[e]=r(g+e);const o=e?t.readUInt32LE(0):t.readUInt32BE(0);a(o)<300&&l(o,i+1)}else if(bb.includes(f)){if(3!==u&&4!==u&&13!==u)throw new Error(`Invalid TIFF file: tag ${f} has type ${u}`);for(let t=0;t<d;t++)l(3===u?a(g+2*t):o(g+4*t),i+1)}}}let f=o(4);for(;;){const t=a(f),e=a(f+4);if(0!==t&&(e<1||e>13))break;if(l(f,0),f=o(f+2+12*t),0===f)break}}(t);const r=hb.decode(t,{parseMN:!1,debug:!1}).slice(0,i);if(!r[0])throw new Error("No page found in TIFF");let a=0;for(const n of r){const{width:i,height:r}=xb(n);if(vb(t,n,i,r,e),a+=i*r,a>1e6*e)throw new Error(`TIFF pages together exceed the maximum resolution of ${e} megapixels. Decode fewer pages with maxFrames, or raise maxResolutionInMP`)}return r}function Mb(){return{mime:"image/tiff",encode:t=>{const e=hb.encodeImage(t.data,t.width,t.height);return n.Buffer.from(e)},decode:(t,{maxResolutionInMP:e=100}={})=>kb(t,Ab(t,e,1)[0]),decodeFrames:(t,{maxResolutionInMP:e=100}={},{maxFrames:n=1/0}={})=>({frames:Ab(t,e,n).map(e=>({bitmap:kb(t,e)}))}),encodeFrames:t=>{if(0===t.length)throw new Error("Can't encode a TIFF without pages");for(const{bitmap:e}of t)if(e.width<=0||e.height<=0)throw new Error(`Invalid TIFF dimensions ${e.width}x${e.height}`);const e=mb(t.map(({bitmap:t})=>t));return n.Buffer.from(e.buffer,e.byteOffset,e.byteLength)}}}var Eb,Ib;(Ib=Eb||(Eb={}))[Ib.EXTEND=1]="EXTEND",Ib[Ib.WRAP=2]="WRAP",Ib[Ib.CROP=3]="CROP";const Sb=function(t,e={}){const n=new Qh({type:"custom",check:"custom",fn:e=>e instanceof t,abort:!0,...Fn(e)});return n._zod.bag.Class=t,n._zod.check=e=>{e.value instanceof t||e.issues.push({code:"invalid_type",expected:t.name,input:e.value,inst:n,path:[...n._zod.def.path??[]]})},n}(Uint8Array),zb=Ah({bitmap:Ah({data:Sb,width:uh(),height:uh()}),iccProfile:Sb.optional()}),Bb=Ah({src:zb,x:uh().optional(),y:uh().optional(),srcX:uh().optional(),srcY:uh().optional(),srcW:uh().optional(),srcH:uh().optional()}),Cb=Ih([zb,Bb]),Pb={blit(t,e){const n=Cb.parse(e);let{src:i,x:r=0,y:a=0,srcX:o=0,srcY:s=0,srcW:h=i.bitmap.width,srcH:c=i.bitmap.height}="bitmap"in n?{src:n}:n;if(!("bitmap"in i))throw new Error("The source must be a Jimp image");if("number"!=typeof r||"number"!=typeof a)throw new Error("x and y must be numbers");r=Math.round(r),a=Math.round(a),o=Math.round(o),s=Math.round(s),h=Math.round(h),c=Math.round(c);const l=t.bitmap.width,f=t.bitmap.height,u=dn(i,t);return cc(i,o,s,h,c,function(e,n,i){const h=r+e-o,c=a+n-s;if(h>=0&&c>=0&&l-h>0&&f-c>0){const e=t.getPixelIndex(h,c),n={r:u[i]||0,g:u[i+1]||0,b:u[i+2]||0,a:u[i+3]||0};if(0===n.a)return;const r={r:t.bitmap.data[e]||0,g:t.bitmap.data[e+1]||0,b:t.bitmap.data[e+2]||0,a:t.bitmap.data[e+3]||0},a=n.a/255,o=r.a/255,s=a+o-a*o,l=(t,e)=>Math.round(dc((t*a+e*o*(1-a))/s));t.bitmap.data[e]=l(n.r,r.r),t.bitmap.data[e+1]=l(n.g,r.g),t.bitmap.data[e+2]=l(n.b,r.b),t.bitmap.data[e+3]=Math.round(dc(255*s))}}),t}},Tb=[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],Ub=[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],Ob=195075;const Lb=Ah({amount:uh().min(0),radius:uh().gt(0).optional(),threshold:uh().min(0).max(255).optional()}),Rb=uh().gt(0),Fb=Ah({radius:uh().gt(0).max(5).optional(),tolerance:uh().gt(0).max(255).optional()}),Db=Tb.length-1;function Nb(t,e,n){const{width:i,height:r,data:a}=t.bitmap,o=Math.ceil(2.57*e),s=2*o+1,h=e*e*2,c=new Float64Array(s);let l=0;for(let t=0;t<s;t++)c[t]=Math.exp(-((t-o)**2)/h),l+=c[t];for(let t=0;t<s;t++)c[t]=c[t]/l;const f=new Float32Array(a.length);for(let t=0;t<r;t++)for(let e=0;e<i;e++){let n=0,r=0,h=0,l=0;for(let f=0;f<s;f++){const s=t*i+Math.min(i-1,Math.max(0,e+f-o))<<2,u=a[s+3]*c[f];n+=a[s]*u,r+=a[s+1]*u,h+=a[s+2]*u,l+=u}const u=t*i+e<<2;f[u]=n,f[u+1]=r,f[u+2]=h,f[u+3]=l}for(let t=0;t<r;t++)for(let e=0;e<i;e++){let a=0,h=0,l=0,u=0;for(let n=0;n<s;n++){const s=Math.min(r-1,Math.max(0,t+n-o))*i+e<<2,d=c[n];a+=f[s]*d,h+=f[s+1]*d,l+=f[s+2]*d,u+=f[s+3]*d}n(t*i+e<<2,a,h,l,u)}}const $b={blur(t,e){if("number"!=typeof e)throw new Error("r must be a number");if(!(e>0))throw new Error("r must be greater than 0");let n,i,r,a,o,s,h,c,l,f,u,d,p;e=Math.min(Db,Math.max(1,Math.round(e)));const m=t.bitmap.width-1,g=t.bitmap.height-1,b=e+1,w=Tb[e],y=2**Ub[e],_=[],v=[],x=[],k=[],A=[],M=[];!function(t){for(let e=0;e<t.length;e+=4){const n=t[e+3];255!==n&&(t[e]=Math.round(t[e]*n/255),t[e+1]=Math.round(t[e+1]*n/255),t[e+2]=Math.round(t[e+2]*n/255))}}(t.bitmap.data);let E=2;for(;E-- >0;){for(d=0,p=0,s=0;s<t.bitmap.height;s++){for(n=t.bitmap.data[p]*b,i=t.bitmap.data[p+1]*b,r=t.bitmap.data[p+2]*b,a=t.bitmap.data[p+3]*b,h=1;h<=e;h++)c=p+((h>m?m:h)<<2),n+=t.bitmap.data[c++],i+=t.bitmap.data[c++],r+=t.bitmap.data[c++],a+=t.bitmap.data[c];for(o=0;o<t.bitmap.width;o++)_[d]=n,v[d]=i,x[d]=r,k[d]=a,0===s&&(A[o]=((c=o+b)<m?c:m)<<2,M[o]=(c=o-e)>0?c<<2:0),l=p+A[o],f=p+M[o],n+=t.bitmap.data[l++]-t.bitmap.data[f++],i+=t.bitmap.data[l++]-t.bitmap.data[f++],r+=t.bitmap.data[l++]-t.bitmap.data[f++],a+=t.bitmap.data[l]-t.bitmap.data[f],d++;p+=t.bitmap.width<<2}for(o=0;o<t.bitmap.width;o++){for(u=o,n=_[u]*b,i=v[u]*b,r=x[u]*b,a=k[u]*b,h=1;h<=e;h++)u+=h>g?0:t.bitmap.width,n+=_[u],i+=v[u],r+=x[u],a+=k[u];for(d=o<<2,s=0;s<t.bitmap.height;s++)t.bitmap.data[d]=dc(Math.floor(n*w/y)),t.bitmap.data[d+1]=dc(Math.floor(i*w/y)),t.bitmap.data[d+2]=dc(Math.floor(r*w/y)),t.bitmap.data[d+3]=dc(Math.floor(a*w/y)),0===o&&(A[s]=((c=s+b)<g?c:g)*t.bitmap.width,M[s]=(c=s-e)>0?c*t.bitmap.width:0),l=o+A[s],f=o+M[s],n+=_[l]-_[f],i+=v[l]-v[f],r+=x[l]-x[f],a+=k[l]-k[f],d+=t.bitmap.width<<2}}return function(t){for(let e=0;e<t.length;e+=4){const n=t[e+3];255!==n&&(0!==n?(t[e]=dc(Math.round(255*t[e]/n)),t[e+1]=dc(Math.round(255*t[e+1]/n)),t[e+2]=dc(Math.round(255*t[e+2]/n))):(t[e]=0,t[e+1]=0,t[e+2]=0))}}(t.bitmap.data),t},gaussian(t,e){if("number"!=typeof e)throw new Error("r must be a number");if(!(e>0))throw new Error("r must be greater than 0");const{data:n}=t.bitmap;return Nb(t,e,(t,e,i,r,a)=>{const o=dc(Math.round(a));if(n[t+3]=o,0===o)return n[t]=0,n[t+1]=0,void(n[t+2]=0);n[t]=dc(Math.round(e/a)),n[t+1]=dc(Math.round(i/a)),n[t+2]=dc(Math.round(r/a))}),t},sharpen(t,e){const{amount:n,radius:i=1,threshold:r=0}=Lb.parse(e),{data:a}=t.bitmap;return Nb(t,i,(t,e,i,o,s)=>{if(0===a[t+3]||0===s)return;const h=[e/s,i/s,o/s];for(let e=0;e<3;e++){const i=a[t+e],o=i-h[e];Math.abs(o)<r||(a[t+e]=dc(Math.round(i+n*o)))}}),t},median:(t,e)=>(function(t,e){const{width:n,height:i,data:r}=t.bitmap,a=new Uint8Array(r);let o=!0;for(let t=3;t<a.length;t+=4)if(255!==a[t]){o=!1;break}const s=new Int32Array(1024),h=new Int32Array(4),c=new Int32Array(4);let l=0;const f=2*e+1,u=new Int32Array(f);function d(t,e){t=t<0?0:t>=n?n-1:t;const i=h[0],r=h[1],d=h[2],p=h[3];let m=0,g=0,b=0,w=0;for(let n=0;n<f;n++){const h=u[n]+t<<2,c=a[h],f=a[h+1],y=a[h+2],_=a[h+3],v=_*e;s[c]+=v,s[256+f]+=v,s[512+y]+=v,l+=v,m+=v&c-i>>31,g+=v&f-r>>31,b+=v&y-d>>31,o||(s[768+_]+=e,w+=e&_-p>>31)}c[0]+=m,c[1]+=g,c[2]+=b,c[3]+=w}function p(t,e){const n=t<<8;let i=h[t],r=c[t];for(;2*r>e;)i--,r-=s[n+i];for(;2*(r+s[n+i])<=e;)r+=s[n+i],i++;return h[t]=i,c[t]=r,i}for(let t=0;t<i;t++){for(let r=0;r<f;r++){const a=t+r-e;u[r]=(a<0?0:a>=i?i-1:a)*n}s.fill(0),h.fill(0),c.fill(0),l=0;for(let t=-e;t<=e;t++)d(t,1);for(let i=0;i<n;i++){i>0&&(d(i-e-1,-1),d(i+e,1));const a=t*n+i<<2,s=o?255:p(3,f*f);0!==s&&0!==l?(r[a]=p(0,l),r[a+1]=p(1,l),r[a+2]=p(2,l),r[a+3]=s):(r[a]=0,r[a+1]=0,r[a+2]=0,r[a+3]=0)}}}(t,Math.min(Db,Math.max(1,Math.round(Rb.parse(e))))),t),bilateral(t,e={}){const{radius:n=2,tolerance:i=30}=Fb.parse(e);return function(t,e,n){const{width:i,height:r,data:a}=t.bitmap,o=Math.max(1,Math.ceil(2*e)),s=i+2*o,h=r+2*o,c=s*h,l=new Float32Array(c),f=new Float32Array(c),u=new Float32Array(c),d=new Float32Array(c);for(let t=0;t<h;t++){const e=Math.min(r-1,Math.max(0,t-o));for(let n=0;n<s;n++){const r=e*i+Math.min(i-1,Math.max(0,n-o))<<2,h=t*s+n;l[h]=a[r],f[h]=a[r+1],u[h]=a[r+2],d[h]=a[r+3]}}const p=[],m=[];for(let t=-o;t<=o;t++)for(let n=-o;n<=o;n++){const i=n*n+t*t;i<=o*o&&(p.push(t*s+n),m.push(Math.exp(-i/(2*e*e))))}const g=p.length,b=Int32Array.from(p),w=Float32Array.from(m),y=new Float32Array(195076),_=1/(2*n*n);for(let t=0;t<=Ob;t++){const e=Math.exp(-t*_);if(e<1e-7)break;y[t]=e}for(let t=0;t<r;t++)for(let e=0;e<i;e++){const n=t*i+e<<2;if(0===a[n+3])continue;const r=(t+o)*s+e+o,h=l[r],c=f[r],p=u[r];let m=0,_=0,v=0,x=0;for(let t=0;t<g;t++){const e=r+b[t],n=l[e],i=f[e],a=u[e],o=n-h,s=i-c,g=a-p,k=w[t]*y[o*o+s*s+g*g]*d[e];m+=n*k,_+=i*k,v+=a*k,x+=k}a[n]=Math.round(m/x),a[n+1]=Math.round(_/x),a[n+2]=Math.round(v/x)}}(t,n,i),t}},jb=Ah({topLeft:uh().min(0).optional(),topRight:uh().min(0).optional(),bottomRight:uh().min(0).optional(),bottomLeft:uh().min(0).optional()}),Gb=Ih([uh().min(0),jb]),Hb=Ih([uh(),Ns()]),Zb=Ah({radius:Gb}),qb=Ah({width:uh().int().min(0),color:Hb.optional(),radius:Gb.optional()}),Wb=Ah({x:uh().optional(),y:uh().optional(),blur:uh().min(0).optional(),spread:uh().optional(),color:Hb.optional(),radius:Gb.optional()});function Vb(t=0){return"number"==typeof t?[t,t,t,t]:[t.topLeft??0,t.topRight??0,t.bottomRight??0,t.bottomLeft??0]}function Jb(t,e,n){const[i,r,a,o]=t,s=Math.min(1,e/(i+r),e/(o+a),n/(i+o),n/(r+a));return s<1?[i*s,r*s,a*s,o*s]:t}function Yb(t){return t<0?0:t>1?1:t}function Xb(t,e,n,i,r){return Yb(t-Math.hypot(i-e,r-n)+.5)}function Kb(t,e,n){const{x:i,y:r,w:a,h:o}=t,[s,h,c,l]=t.radii;let f=Yb(Math.min(e-i,i+a-e,n-r,r+o-n)+.5);return 0===f?0:(s>0&&e<i+s&&n<r+s&&(f=Math.min(f,Xb(s,i+s,r+s,e,n))),h>0&&e>i+a-h&&n<r+h&&(f=Math.min(f,Xb(h,i+a-h,r+h,e,n))),c>0&&e>i+a-c&&n>r+o-c&&(f=Math.min(f,Xb(c,i+a-c,r+o-c,e,n))),l>0&&e<i+l&&n>r+o-l&&(f=Math.min(f,Xb(l,i+l,r+o-l,e,n))),f)}function Qb(t,e,n,i,r,a,o){const s=1/(2*o+1);for(let h=0;h<n;h++){const n=h*r;let c=0;for(let e=0;e<=o&&e<i;e++)c+=t[n+e*a];for(let r=0;r<i;r++)e[n+r*a]=c*s,r+o+1<i&&(c+=t[n+(r+o+1)*a]),r-o>=0&&(c-=t[n+(r-o)*a])}}function tw(t,e,n,i){const r=new Float32Array(t.length);for(const a of function(t){const e=Math.sqrt(12*t*t/3+1);let n=Math.floor(e);n%2==0&&n--;const i=(12*t*t-3*n*n-12*n-9)/(-4*n-4),r=Math.round(i);return Array.from({length:3},(t,e)=>e<r?n:n+2)}(i)){const i=(a-1)/2;i<1||(Qb(t,r,n,e,e,1,i),Qb(r,t,e,n,1,e,i))}}function ew(t,e,n,i){t.bitmap.data=e,t.bitmap.width=n,t.bitmap.height=i}const nw={roundCorners(t,e){const{radius:n}=Zb.parse(e),{width:i,height:r,data:a}=t.bitmap,o={x:0,y:0,w:i,h:r,radii:Jb(Vb(n),i,r)};return t.scan((t,e,n)=>{const i=Kb(o,t+.5,e+.5);i<1&&(a[n+3]=Math.round(a[n+3]*i))}),t},border(t,e){const{width:i,color:r=255,radius:a}=qb.parse(e),{width:o,height:s,data:h}=t.bitmap,c=o+2*i,l=s+2*i,f=Jb(Vb(a),c,l),u={x:0,y:0,w:c,h:l,radii:f},d={x:i,y:i,w:o,h:s,radii:f.map(t=>Math.max(0,t-i))},p=lc(pc(r,sn(t))),m=n.Buffer.alloc(c*l*4);for(let t=0;t<l;t++)for(let e=0;e<c;e++){const n=Kb(u,e+.5,t+.5);if(0===n)continue;const r=Kb(d,e+.5,t+.5),a=4*(t*c+e),s=p.a/255*Math.max(0,n-r);let l=0,f=0;r>0&&(f=4*((t-i)*o+(e-i)),l=h[f+3]/255*r);const g=s+l;0!==g&&(m[a]=Math.round((p.r*s+h[f]*l)/g),m[a+1]=Math.round((p.g*s+h[f+1]*l)/g),m[a+2]=Math.round((p.b*s+h[f+2]*l)/g),m[a+3]=Math.round(255*Math.min(1,g)))}return ew(t,m,c,l),t},boxShadow(t,e={}){const{x:i=0,y:r=4,blur:a=12,spread:o=0,color:s=128,radius:h}=Wb.parse(e),{width:c,height:l,data:f}=t.bitmap,u=a+o,d=Math.max(0,Math.ceil(u-i)),p=Math.max(0,Math.ceil(u+i)),m=Math.max(0,Math.ceil(u-r)),g=c+d+p,b=l+m+Math.max(0,Math.ceil(u+r)),w=new Float32Array(g*b),y=c+2*o,_=l+2*o;if(y>0&&_>0){const t=Jb(Vb(h),c,l),e={x:d+i-o,y:m+r-o,w:y,h:_,radii:Jb(t.map(t=>t>0?Math.max(0,t+o):0),y,_)};for(let t=0;t<b;t++)for(let n=0;n<g;n++)w[t*g+n]=Kb(e,n+.5,t+.5);a>0&&tw(w,g,b,a/2)}const v=lc(pc(s,sn(t))),x=n.Buffer.alloc(g*b*4);for(let t=0;t<b;t++)for(let e=0;e<g;e++){const n=4*(t*g+e),i=v.a/255*Yb(w[t*g+e]),r=e-d,a=t-m;let o=0,s=0;r>=0&&r<c&&a>=0&&a<l&&(s=4*(a*c+r),o=f[s+3]/255);const h=i*(1-o),u=o+h;0!==u&&(x[n]=Math.round((f[s]*o+v.r*h)/u),x[n+1]=Math.round((f[s+1]*o+v.g*h)/u),x[n+2]=Math.round((f[s+2]*o+v.b*h)/u),x[n+3]=Math.round(255*u))}return ew(t,x,g,b),t}},iw=Ah({x:uh().optional(),y:uh().optional(),radius:uh().min(0).optional()}),rw={circle(t,e={}){const n=iw.parse(e),i=n.radius??(t.bitmap.width>t.bitmap.height?t.bitmap.height:t.bitmap.width)/2,r="number"==typeof n.x?n.x:t.bitmap.width/2,a="number"==typeof n.y?n.y:t.bitmap.height/2;return t.scan((e,n,o)=>{const s=Math.sqrt(Math.pow(e-r,2)+Math.pow(n-a,2));i-s<=0?t.bitmap.data[o+3]=0:i-s<1&&(t.bitmap.data[o+3]=255*(i-s))}),t}},aw=xh(uh()).min(1,"kernel rows must not be empty").array().min(1,"kernel must be a matrix").refine(t=>t.every(e=>e.length===t[0].length),"kernel rows must all have the same length"),ow=uh().refine(t=>0!==t,"divisor must not be 0"),sw=Ih([aw,Ah({kernel:aw,edgeHandling:Oh(Eb).optional(),divisor:ow.optional(),bias:uh().optional()})]),hw=Ih([aw,Ah({kernel:aw,x:uh().optional(),y:uh().optional(),w:uh().optional(),h:uh().optional(),divisor:ow.optional(),bias:uh().optional(),preserveAlpha:gh().optional()})]),cw=uh().min(1).max(1/0),lw=Ih([cw,Ah({size:cw,x:uh().optional(),y:uh().optional(),w:uh().optional(),h:uh().optional()})]),fw=Ih([ec,Ah({stops:ec,amount:uh().optional()})]);function uw(t,e,n,i){const r=[0,0,0,0],a=e.length,o=e[0].length,s=Math.floor((a-1)/2),h=Math.floor((o-1)/2);for(let c=0;c<o;c+=1)for(let o=0;o<a;o+=1){const a=t.getPixelIndex(n+c-h,i+o-s),l=e[o][c];r[0]+=t.bitmap.data[a]*l,r[1]+=t.bitmap.data[a+1]*l,r[2]+=t.bitmap.data[a+2]*l,r[3]+=t.bitmap.data[a+3]*l}return r}function dw(t){const e=Math.min(255,Math.max(0,t)),n=Math.abs(e-255)<1e-6?255:e/255*255;return n<1?Math.round(n):n}function pw(t){if(t>1){const e=Math.min(100,t);return Math.abs(e-100)<1e-6?1:e/100}const e=100*Math.min(100,Math.max(0,100*t)),n=(e>0&&e<1e-6?parseInt(String(e),10):Math.floor(e))/100;return Math.abs(n-100)<1e-6?1:n/100}function mw(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t}const gw=new Float64Array(3),bw=new Float64Array(3);function ww(t,e,n){const i=dw(t),r=dw(e),a=dw(n),o=Math.abs(i-255)<1e-6?1:i/255,s=Math.abs(r-255)<1e-6?1:r/255,h=Math.abs(a-255)<1e-6?1:a/255,c=Math.max(o,s,h),l=Math.min(o,s,h),f=(c+l)/2;if(gw[2]=f,c===l)return gw[0]=0,void(gw[1]=0);const u=c-l;let d;gw[1]=f>.5?u/(2-c-l):u/(c+l),d=c===o?(s-h)/u+(s<h?6:0):c===s?(h-o)/u+2:(o-s)/u+4,gw[0]=d/6*360}function yw(t,e,n){const i=Math.min(360,Math.max(0,t)),r=Math.abs(i-360)<1e-6?1:i/360,a=pw(e),o=pw(n);let s,h,c;if(0===a)s=h=c=o;else{const t=o<.5?o*(1+a):o+a-o*a,e=2*o-t;s=mw(e,t,r+1/3),h=mw(e,t,r),c=mw(e,t,r-1/3)}bw[0]=Math.round(Math.min(255,Math.max(255*s,0))),bw[1]=Math.round(Math.min(255,Math.max(255*h,0))),bw[2]=Math.round(Math.min(255,Math.max(255*c,0)))}function _w(t,e,n){return Math.round(.2126*t+.7152*e+.0722*n)}function vw(t,e){const n=Math.max(0,Math.min(255,Math.round(dw(t))-e));return Math.round(dw(n))}const xw=Ah({apply:Rh("hue"),params:Ph([uh().min(-360).max(360)])}),kw=Ah({apply:Rh("spin"),params:Ph([uh().min(-360).max(360)])}),Aw=Ah({apply:Rh("lighten"),params:Ph([uh().min(0).max(100)]).optional()}),Mw=Ih([Ah({r:uh().min(0).max(255),g:uh().min(0).max(255),b:uh().min(0).max(255)}),Ns()]),Ew=Ah({apply:Rh("mix"),params:Ih([Ph([Mw]),Ph([Mw,uh().min(0).max(100)])])}),Iw=Ah({apply:Rh("multiply"),params:Ih([Ph([uh(),uh(),uh()]),Ph([Mw])])}),Sw=Ih([xw,kw,Aw,Ew,Iw,Ah({apply:Rh("tint"),params:Ph([uh().min(0).max(100)]).optional()}),Ah({apply:Rh("shade"),params:Ph([uh().min(0).max(100)]).optional()}),Ah({apply:Rh("xor"),params:Ph([Mw])}),Ah({apply:Rh("red"),params:Ph([uh().min(-255).max(255)])}),Ah({apply:Rh("green"),params:Ph([uh().min(-255).max(255)])}),Ah({apply:Rh("blue"),params:Ph([uh().min(-255).max(255)])}),Ah({apply:Rh("brighten"),params:Ph([uh().min(0).max(100)]).optional()}),Ah({apply:Rh("darken"),params:Ph([uh().min(0).max(100)]).optional()}),Ah({apply:Rh("desaturate"),params:Ph([uh().min(0).max(100)]).optional()}),Ah({apply:Rh("saturate"),params:Ph([uh().min(0).max(100)]).optional()}),Ah({apply:Rh("greyscale"),params:Ph([]).optional()})]),zw=Object.freeze({LIGHTEN:"lighten",BRIGHTEN:"brighten",DARKEN:"darken",DESATURATE:"desaturate",SATURATE:"saturate",GREYSCALE:"greyscale",SPIN:"spin",HUE:"hue",MIX:"mix",MULTIPLY:"multiply",TINT:"tint",SHADE:"shade",XOR:"xor",RED:"red",GREEN:"green",BLUE:"blue"}),Bw=0,Cw=1,Pw=2,Tw=3,Uw=4,Ow=5,Lw=6,Rw=7,Fw=8,Dw=9,Nw=10;const $w={r:0,g:0,b:0},jw={r:255,g:255,b:255};function Gw(t,e=0,n=$w){return{op:t,r:n.r,g:n.g,b:n.b,amount:e}}function Hw(t,e){return function(t){return{r:Math.round(dw(t.r)),g:Math.round(dw(t.g)),b:Math.round(dw(t.b))}}("string"==typeof t?lc(pc(t,e)):t)}const Zw=function(t,e,n){return e===n?t:255*(t-e)/(n-e)},qw=function(t){return[t.findIndex(t=>t>0),255-t.slice().reverse().findIndex(t=>t>0)]},Ww=Ah({amount:uh().min(0).max(1).optional(),size:uh().min(1).max(16).optional(),monochrome:gh().optional(),seed:uh().int().optional()});function Vw(t,e,n,i){const r=new Float32Array(t*e);if(n<=1){for(let n=0,a=0;n<e;n++)for(let e=0;e<t;e++,a++)r[a]=oc(e,n,2*i)+oc(e,n,2*i+1)-1;return r}const a=(n-1)/2,o=Math.ceil(3*a),s=[];for(let t=-o;t<=o;t++)s.push(Math.exp(-t*t/(2*a*a)));const h=s.reduce((t,e)=>t+e,0),c=s.map(t=>t/h),l=Math.SQRT2/c.reduce((t,e)=>t+e*e,0),f=t+2*o,u=e+2*o,d=new Float32Array(f*u);for(let t=0,e=0;t<u;t++)for(let n=0;n<f;n++,e++)d[e]=oc(n-o,t-o,2*i)-.5;const p=new Float32Array(t*u);for(let e=0;e<u;e++)for(let n=0;n<t;n++){const i=e*f+n;let r=0;for(let t=0;t<c.length;t++)r+=c[t]*d[i+t];p[e*t+n]=r}for(let n=0;n<e;n++)for(let e=0;e<t;e++){let i=0;for(let r=0;r<c.length;r++)i+=c[r]*p[(n+r)*t+e];r[n*t+e]=Math.max(-1,Math.min(1,i*l))}return r}const Jw={normalize(t){const e=function(t){const e={r:new Array(256).fill(0),g:new Array(256).fill(0),b:new Array(256).fill(0)};return t.scan((n,i,r)=>{e.r[t.bitmap.data[r+0]]++,e.g[t.bitmap.data[r+1]]++,e.b[t.bitmap.data[r+2]]++}),e}(t),n={r:qw(e.r),g:qw(e.g),b:qw(e.b)};return t.scan((e,i,r)=>{const a=t.bitmap.data[r+0],o=t.bitmap.data[r+1],s=t.bitmap.data[r+2];t.bitmap.data[r+0]=Zw(a,n.r[0],n.r[1]),t.bitmap.data[r+1]=Zw(o,n.g[0],n.g[1]),t.bitmap.data[r+2]=Zw(s,n.b[0],n.b[1])}),t},invert:t=>(t.scan((e,n,i)=>{t.bitmap.data[i]=255-t.bitmap.data[i],t.bitmap.data[i+1]=255-t.bitmap.data[i+1],t.bitmap.data[i+2]=255-t.bitmap.data[i+2]}),t),brightness(t,e){if("number"!=typeof e)throw new Error("val must be numbers");return t.scan((n,i,r)=>{t.bitmap.data[r]=dc(t.bitmap.data[r]*e),t.bitmap.data[r+1]=dc(t.bitmap.data[r+1]*e),t.bitmap.data[r+2]=dc(t.bitmap.data[r+2]*e)}),t},contrast(t,e){if("number"!=typeof e)throw new Error("val must be numbers");if(e<-1||e>1)throw new Error("val must be a number between -1 and +1");const n=(e+1)/(1-e);function i(t){const e=n*(t-127.5);return dc(e<0?255-Math.round(127.5-e):Math.round(127.5+e))}return t.scan((e,n,r)=>{t.bitmap.data[r]=i(t.bitmap.data[r]),t.bitmap.data[r+1]=i(t.bitmap.data[r+1]),t.bitmap.data[r+2]=i(t.bitmap.data[r+2])}),t},exposure(t,e){const n=2**uh().parse(e),i=sn(t).curves??Ye.curves,[r,a,o]=i.map(t=>function(t,e){const n=Array.from({length:255},(e,n)=>t((n+.5)/255));return Uint8Array.from({length:256},(i,r)=>{const a=t(r/255)*e;let o=0;for(;o<255&&a>n[o];)o++;return o})}(t,n));return t.scan((e,n,i)=>{t.bitmap.data[i]=r[t.bitmap.data[i]],t.bitmap.data[i+1]=a[t.bitmap.data[i+1]],t.bitmap.data[i+2]=o[t.bitmap.data[i+2]]}),t},vibrance:(t,e)=>(0===(e=Math.min(1,Math.max(-1,uh().parse(e))))||t.scan((n,i,r)=>{const a=t.bitmap.data[r],o=t.bitmap.data[r+1],s=t.bitmap.data[r+2],h=(Math.max(a,o,s)-Math.min(a,o,s))/255;ww(a,o,s),yw(gw[0],Math.min(1,gw[1]*(1+e*(1-h))),gw[2]),t.bitmap.data[r]=bw[0],t.bitmap.data[r+1]=bw[1],t.bitmap.data[r+2]=bw[2]}),t),posterize(t,e){if("number"!=typeof e)throw new Error("n must be numbers");const n=255/((e=Math.min(256,Math.max(2,Math.round(e))))-1);function i(t){return Math.round(Math.round(t/n)*n)}return t.scan((e,n,r)=>{t.bitmap.data[r]=i(t.bitmap.data[r]),t.bitmap.data[r+1]=i(t.bitmap.data[r+1]),t.bitmap.data[r+2]=i(t.bitmap.data[r+2])}),t},greyscale:t=>(t.scan((e,n,i)=>{const r=_w(t.bitmap.data[i],t.bitmap.data[i+1],t.bitmap.data[i+2]);t.bitmap.data[i]=r,t.bitmap.data[i+1]=r,t.bitmap.data[i+2]=r}),t),opacity(t,e){if("number"!=typeof e)throw new Error("f must be a number");if(e<0||e>1)throw new Error("f must be a number from 0 to 1");return t.scan((n,i,r)=>{const a=t.bitmap.data[r+3]*e;t.bitmap.data[r+3]=a}),t},sepia(t,e=1){const n=Math.min(1,Math.max(0,uh().parse(e)));return t.scan((e,i,r)=>{const a=t.bitmap.data[r],o=t.bitmap.data[r+1],s=t.bitmap.data[r+2],h=.393*a+.769*o+.189*s,c=.349*a+.686*o+.168*s,l=.272*a+.534*o+.131*s;t.bitmap.data[r]=(h<255?h:255)*n+a*(1-n),t.bitmap.data[r+1]=(c<255?c:255)*n+o*(1-n),t.bitmap.data[r+2]=(l<255?l:255)*n+s*(1-n)}),t},gradientMap(t,e){const n=fw.parse(e),{stops:i,amount:r=1}=Array.isArray(n)?{stops:n}:n,a=Math.min(1,Math.max(0,r)),o=ac(nc(i),sn(t),256),s=t.bitmap.data;return t.scan((t,e,n)=>{const i=s[n],r=s[n+1],h=s[n+2],c=s[n+3],l=4*_w(i,r,h);s[n]=Math.round(o[l]*a+i*(1-a)),s[n+1]=Math.round(o[l+1]*a+r*(1-a)),s[n+2]=Math.round(o[l+2]*a+h*(1-a)),s[n+3]=Math.round(c*(1-a+a*o[l+3]/255))}),t},fade(t,e){if("number"!=typeof e)throw new Error("f must be a number");if(e<0||e>1)throw new Error("f must be a number from 0 to 1");return this.opacity(t,1-e)},convolution(t,e){const i=sw.parse(e),{kernel:r,edgeHandling:a=Eb.EXTEND,divisor:o=1,bias:s=0}="kernel"in i?i:{kernel:i},h=n.Buffer.from(t.bitmap.data),c=r.length,l=r[0].length,f=-Math.floor((c-1)/2),u=-Math.floor((l-1)/2),d=c-1+f,p=l-1+u;let m,g,b,w,y,_,v,x,k,A;return t.scan((e,n,i)=>{w=0,b=0,g=0;for(let i=f;i<=d;i++)for(let o=u;o<=p;o++)x=e+o,k=n+i,m=r[i-f][o-u],A=t.getPixelIndex(x,k,a),-1===A?(v=0,_=0,y=0):(y=t.bitmap.data[A+0],_=t.bitmap.data[A+1],v=t.bitmap.data[A+2]),g+=m*y,b+=m*_,w+=m*v;g=g/o+s,b=b/o+s,w=w/o+s,g<0&&(g=0),b<0&&(b=0),w<0&&(w=0),g>255&&(g=255),b>255&&(b=255),w>255&&(w=255),h[i+0]=g,h[i+1]=b,h[i+2]=w}),t.bitmap.data=h,t},opaque:t=>(t.scan((e,n,i)=>{t.bitmap.data[i+3]=255}),t),pixelate(t,e){const n=lw.parse(e),{size:i,x:r=0,y:a=0,w:o=t.bitmap.width-r,h:s=t.bitmap.height-a}="number"==typeof n?{size:n}:n,h=[[1/16,2/16,1/16],[2/16,.25,2/16],[1/16,2/16,1/16]],c=sc(t);return cc(c,r,a,o,s,(e,n,r)=>{e=i*Math.floor(e/i),n=i*Math.floor(n/i);const a=uw(c,h,e,n);t.bitmap.data[r]=a[0],t.bitmap.data[r+1]=a[1],t.bitmap.data[r+2]=a[2],t.bitmap.data[r+3]=a[3]}),t},convolute(t,e){const n=hw.parse(e),{kernel:i,x:r=0,y:a=0,w:o=t.bitmap.width-r,h:s=t.bitmap.height-a,divisor:h=1,bias:c=0,preserveAlpha:l=!1}="kernel"in n?n:{kernel:n},f=sc(t);return cc(f,r,a,o,s,(e,n,r)=>{const a=uw(f,i,e,n);t.bitmap.data[r]=dc(a[0]/h+c),t.bitmap.data[r+1]=dc(a[1]/h+c),t.bitmap.data[r+2]=dc(a[2]/h+c),l||(t.bitmap.data[r+3]=dc(a[3]/h))}),t},color(t,e){if(!e||!Array.isArray(e))throw new Error("actions must be an array");e.forEach(t=>Sw.parse(t));const n=sn(t),i=e.map(t=>function(t,e){switch(t.apply){case"mix":return Gw(Bw,(t.params[1]??50)/100,Hw(t.params[0],e));case"multiply":{if(3===t.params.length){const[e,n,i]=t.params;return Gw(Nw,0,{r:e,g:n,b:i})}const{r:n,g:i,b:r}=Hw(t.params[0],e);return Gw(Nw,0,{r:n/255,g:i/255,b:r/255})}case"tint":return Gw(Bw,(t.params?.[0]??50)/100,jw);case"shade":return Gw(Bw,(t.params?.[0]??50)/100,$w);case"lighten":return Gw(Cw,(t.params?.[0]??10)/100,jw);case"darken":return Gw(Cw,(t.params?.[0]??10)/100,$w);case"xor":return Gw(Pw,0,Hw(t.params[0],e));case"red":return Gw(Tw,t.params[0]);case"green":return Gw(Uw,t.params[0]);case"blue":return Gw(Ow,t.params[0]);case"saturate":return Gw(Lw,1+(t.params?.[0]??10)/100);case"desaturate":return Gw(Lw,1-(t.params?.[0]??10)/100);case"greyscale":return Gw(Rw);case"hue":case"spin":return Gw(Fw,t.params[0]);case"brighten":return Gw(Dw,Math.round(-(t.params?.[0]??10)/100*255))}}(t,n)),r=t.bitmap.data,a=t.bitmap.width*t.bitmap.height*4;for(let t=0;t<a;t+=4){let e=r[t],n=r[t+1],a=r[t+2];for(let t=0;t<i.length;t++){const r=i[t];switch(r.op){case Bw:e=(r.r-e)*r.amount+e,n=(r.g-n)*r.amount+n,a=(r.b-a)*r.amount+a;break;case Cw:e=Math.round((r.r-e)*r.amount+e),n=Math.round((r.g-n)*r.amount+n),a=Math.round((r.b-a)*r.amount+a);break;case Nw:e=Math.round(dc(e*r.r)),n=Math.round(dc(n*r.g)),a=Math.round(dc(a*r.b));break;case Pw:e^=r.r,n^=r.g,a^=r.b;break;case Tw:e=dc(e+r.amount);break;case Uw:n=dc(n+r.amount);break;case Ow:a=dc(a+r.amount);break;case Lw:ww(e,n,a),yw(gw[0],Math.min(1,gw[1]*r.amount),gw[2]),e=bw[0],n=bw[1],a=bw[2];break;case Rw:e=n=a=dc(_w(e,n,a));break;case Fw:{ww(e,n,a);const t=(gw[0]+r.amount)%360;yw(t<0?360+t:t,gw[1],gw[2]),e=bw[0],n=bw[1],a=bw[2];break}case Dw:e=vw(e,r.amount),n=vw(n,r.amount),a=vw(a,r.amount)}}r[t]=e,r[t+1]=n,r[t+2]=a}return t},grain(t,e={}){const{amount:n=.1,size:i=1,monochrome:r=!0,seed:a=0}=Ww.parse(e),{width:o,height:s,data:h}=t.bitmap;if(0===n)return t;const c=r?[Vw(o,s,i,3*a)]:[0,1,2].map(t=>Vw(o,s,i,3*a+t)),l=255*n;for(let t=0,e=0;e<o*s;t+=4,e++)if(0!==h[t+3])for(let n=0;n<3;n++){const i=h[t+n]+c[r?0:n][e]*l;h[t+n]=i<0?0:i>255?255:Math.round(i)}return t}};function Yw(t,e){return t.then(function(t){return[null,t]}).catch(function(t){return[t,void 0]})}const Xw=async()=>{throw new Error("Jimp.write cannot write directly to a local path in the browser. Use getBuffer to retrieve the encoded image bytes.")};function Kw(){this._types=Object.create(null),this._extensions=Object.create(null);for(let t=0;t<arguments.length;t++)this.define(arguments[t]);this.define=this.define.bind(this),this.getType=this.getType.bind(this),this.getExtension=this.getExtension.bind(this)}Kw.prototype.define=function(t,e){for(let n in t){let i=t[n].map(function(t){return t.toLowerCase()});n=n.toLowerCase();for(let t=0;t<i.length;t++){const r=i[t];if("*"!==r[0]){if(!e&&r in this._types)throw new Error('Attempt to change mapping for "'+r+'" extension from "'+this._types[r]+'" to "'+n+'". Pass `force=true` to allow this, otherwise remove "'+r+'" from the list of extensions for "'+n+'".');this._types[r]=n}}if(e||!this._extensions[n]){const t=i[0];this._extensions[n]="*"!==t[0]?t:t.substr(1)}}},Kw.prototype.getType=function(t){let e=(t=String(t)).replace(/^.*[/\\]/,"").toLowerCase(),n=e.replace(/^.*\./,"").toLowerCase(),i=e.length<t.length;return(n.length<e.length-1||!i)&&this._types[n]||null},Kw.prototype.getExtension=function(t){return(t=/^\s*([^;\s]*)/.test(t)&&RegExp.$1)&&this._extensions[t.toLowerCase()]||null};var Qw=Kw,ty=e(Qw);var ey,ny,iy,ry,ay,oy,sy=e(new Qw({"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mpd"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["es","ecma"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/express":["exp"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js","mjs"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/trig":["trig"],"application/ttml+xml":["ttml"],"application/ubjson":["ubj"],"application/urc-ressheet+xml":["rsheet"],"application/urc-targetdesc+xml":["td"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["*xsl","xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["*3gpp"],"audio/adpcm":["adp"],"audio/amr":["amr"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx","opus"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/avif":["avif"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/hsj2":["hsj2"],"image/ief":["ief"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm"],"image/jpx":["jpx","jpf"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/ktx2":["ktx2"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/step+xml":["stpx"],"model/step+zip":["stpz"],"model/step-xml+zip":["stpxz"],"model/stl":["stl"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["markdown","md"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/spdx":["spdx"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/iso.segment":["m4s"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]}));function hy(t,e,n=1){t.a*=n;const i=e.a+t.a-e.a*t.a;return{r:(t.r*t.a+e.r*e.a*(1-t.a))/i,g:(t.g*t.a+e.g*e.a*(1-t.a))/i,b:(t.b*t.a+e.b*e.a*(1-t.a))/i,a:i}}function cy(t,e,n=1){t.a*=n;const i=e.a+t.a-e.a*t.a;return{r:(e.r*e.a+t.r*t.a*(1-e.a))/i,g:(e.g*e.a+t.g*t.a*(1-e.a))/i,b:(e.b*e.a+t.b*t.a*(1-e.a))/i,a:i}}function ly(t,e,n=1){t.a*=n;const i=e.a+t.a-e.a*t.a,r=t.r*t.a,a=t.g*t.a,o=t.b*t.a,s=e.r*e.a,h=e.g*e.a,c=e.b*e.a;return{r:(r*s+r*(1-e.a)+s*(1-t.a))/i,g:(a*h+a*(1-e.a)+h*(1-t.a))/i,b:(o*c+o*(1-e.a)+c*(1-t.a))/i,a:i}}function fy(t,e,n=1){t.a*=n;const i=e.a+t.a-e.a*t.a,r=t.r*t.a,a=t.g*t.a,o=t.b*t.a;return{r:(r+e.r*e.a)/i,g:(a+e.g*e.a)/i,b:(o+e.b*e.a)/i,a:i}}function uy(t,e,n=1){t.a*=n;const i=e.a+t.a-e.a*t.a,r=t.r*t.a,a=t.g*t.a,o=t.b*t.a,s=e.r*e.a,h=e.g*e.a,c=e.b*e.a;return{r:(r*e.a+s*t.a-r*s+r*(1-e.a)+s*(1-t.a))/i,g:(a*e.a+h*t.a-a*h+a*(1-e.a)+h*(1-t.a))/i,b:(o*e.a+c*t.a-o*c+o*(1-e.a)+c*(1-t.a))/i,a:i}}function dy(t,e,n=1){t.a*=n;const i=e.a+t.a-e.a*t.a,r=t.r*t.a,a=t.g*t.a,o=t.b*t.a,s=e.r*e.a,h=e.g*e.a,c=e.b*e.a;return{r:(2*s<=e.a?2*r*s+r*(1-e.a)+s*(1-t.a):r*(1+e.a)+s*(1+t.a)-2*s*r-e.a*t.a)/i,g:(2*h<=e.a?2*a*h+a*(1-e.a)+h*(1-t.a):a*(1+e.a)+h*(1+t.a)-2*h*a-e.a*t.a)/i,b:(2*c<=e.a?2*o*c+o*(1-e.a)+c*(1-t.a):o*(1+e.a)+c*(1+t.a)-2*c*o-e.a*t.a)/i,a:i}}function py(t,e,n=1){t.a*=n;const i=e.a+t.a-e.a*t.a,r=t.r*t.a,a=t.g*t.a,o=t.b*t.a,s=e.r*e.a,h=e.g*e.a,c=e.b*e.a;return{r:(Math.min(r*e.a,s*t.a)+r*(1-e.a)+s*(1-t.a))/i,g:(Math.min(a*e.a,h*t.a)+a*(1-e.a)+h*(1-t.a))/i,b:(Math.min(o*e.a,c*t.a)+o*(1-e.a)+c*(1-t.a))/i,a:i}}function my(t,e,n=1){t.a*=n;const i=e.a+t.a-e.a*t.a,r=t.r*t.a,a=t.g*t.a,o=t.b*t.a,s=e.r*e.a,h=e.g*e.a,c=e.b*e.a;return{r:(Math.max(r*e.a,s*t.a)+r*(1-e.a)+s*(1-t.a))/i,g:(Math.max(a*e.a,h*t.a)+a*(1-e.a)+h*(1-t.a))/i,b:(Math.max(o*e.a,c*t.a)+o*(1-e.a)+c*(1-t.a))/i,a:i}}function gy(t,e,n=1){t.a*=n;const i=e.a+t.a-e.a*t.a,r=t.r*t.a,a=t.g*t.a,o=t.b*t.a,s=e.r*e.a,h=e.g*e.a,c=e.b*e.a;return{r:(2*r<=t.a?2*r*s+r*(1-e.a)+s*(1-t.a):r*(1+e.a)+s*(1+t.a)-2*s*r-e.a*t.a)/i,g:(2*a<=t.a?2*a*h+a*(1-e.a)+h*(1-t.a):a*(1+e.a)+h*(1+t.a)-2*h*a-e.a*t.a)/i,b:(2*o<=t.a?2*o*c+o*(1-e.a)+c*(1-t.a):o*(1+e.a)+c*(1+t.a)-2*c*o-e.a*t.a)/i,a:i}}function by(t,e,n=1){t.a*=n;const i=e.a+t.a-e.a*t.a,r=t.r*t.a,a=t.g*t.a,o=t.b*t.a,s=e.r*e.a,h=e.g*e.a,c=e.b*e.a;return{r:(r+s-2*Math.min(r*e.a,s*t.a))/i,g:(a+h-2*Math.min(a*e.a,h*t.a))/i,b:(o+c-2*Math.min(o*e.a,c*t.a))/i,a:i}}function wy(t,e,n=1){t.a*=n;const i=e.a+t.a-e.a*t.a,r=t.r*t.a,a=t.g*t.a,o=t.b*t.a,s=e.r*e.a,h=e.g*e.a,c=e.b*e.a;return{r:(r*e.a+s*t.a-2*r*s+r*(1-e.a)+s*(1-t.a))/i,g:(a*e.a+h*t.a-2*a*h+a*(1-e.a)+h*(1-t.a))/i,b:(o*e.a+c*t.a-2*o*c+o*(1-e.a)+c*(1-t.a))/i,a:i}}function yy(t,e,n,i){t.a*=n;const r=e.a+t.a-e.a*t.a,a=i(e,t);return{r:(t.a*((1-e.a)*t.r+e.a*a.r)+e.r*e.a*(1-t.a))/r,g:(t.a*((1-e.a)*t.g+e.a*a.g)+e.g*e.a*(1-t.a))/r,b:(t.a*((1-e.a)*t.b+e.a*a.b)+e.b*e.a*(1-t.a))/r,a:r}}function _y(t){return(e,n)=>({r:t(e.r,n.r),g:t(e.g,n.g),b:t(e.b,n.b)})}(ny=ey||(ey={}))[ny.LEFT=1]="LEFT",ny[ny.CENTER=2]="CENTER",ny[ny.RIGHT=4]="RIGHT",(ry=iy||(iy={}))[ry.TOP=8]="TOP",ry[ry.MIDDLE=16]="MIDDLE",ry[ry.BOTTOM=32]="BOTTOM",(oy=ay||(ay={})).SRC_OVER="srcOver",oy.DST_OVER="dstOver",oy.MULTIPLY="multiply",oy.ADD="add",oy.SCREEN="screen",oy.OVERLAY="overlay",oy.DARKEN="darken",oy.LIGHTEN="lighten",oy.HARD_LIGHT="hardLight",oy.DIFFERENCE="difference",oy.EXCLUSION="exclusion",oy.COLOR_DODGE="colorDodge",oy.COLOR_BURN="colorBurn",oy.SOFT_LIGHT="softLight",oy.HUE="hue",oy.SATURATION="saturation",oy.COLOR="color",oy.LUMINOSITY="luminosity";const vy=_y((t,e)=>0===t?0:1===e?1:Math.min(1,t/(1-e)));function xy(t,e,n=1){return yy(t,e,n,vy)}const ky=_y((t,e)=>1===t?1:0===e?0:1-Math.min(1,(1-t)/e));function Ay(t,e,n=1){return yy(t,e,n,ky)}const My=_y((t,e)=>{if(e<=.5)return t-(1-2*e)*t*(1-t);return t+(2*e-1)*((t<=.25?((16*t-12)*t+4)*t:Math.sqrt(t))-t)});function Ey(t,e,n=1){return yy(t,e,n,My)}function Iy({r:t,g:e,b:n}){return.3*t+.59*e+.11*n}function Sy(t,e){const n=e-Iy(t);return function(t){const e=Iy(t),n=Math.min(t.r,t.g,t.b),i=Math.max(t.r,t.g,t.b);let{r:r,g:a,b:o}=t;return n<0&&(r=e+(r-e)*e/(e-n),a=e+(a-e)*e/(e-n),o=e+(o-e)*e/(e-n)),i>1&&(r=e+(r-e)*(1-e)/(i-e),a=e+(a-e)*(1-e)/(i-e),o=e+(o-e)*(1-e)/(i-e)),{r:r,g:a,b:o}}({r:t.r+n,g:t.g+n,b:t.b+n})}function zy({r:t,g:e,b:n}){return Math.max(t,e,n)-Math.min(t,e,n)}function By(t,e){const[n,i,r]=["r","g","b"].sort((e,n)=>t[e]-t[n]),a={r:0,g:0,b:0};return t[r]>t[n]&&(a[i]=(t[i]-t[n])*e/(t[r]-t[n]),a[r]=e),a}function Cy(t,e,n=1){return yy(t,e,n,(t,e)=>Sy(By(e,zy(t)),Iy(t)))}function Py(t,e,n=1){return yy(t,e,n,(t,e)=>Sy(By(t,zy(e)),Iy(t)))}function Ty(t,e,n=1){return yy(t,e,n,(t,e)=>Sy(e,Iy(t)))}function Uy(t,e,n=1){return yy(t,e,n,(t,e)=>Sy(t,Iy(e)))}const Oy=[hy,cy,ly,fy,uy,dy,py,my,gy,by,wy,xy,Ay,Ey,Cy,Py,Ty,Uy];var Ly=Object.freeze({__proto__:null,add:fy,color:Ty,colorBurn:Ay,colorDodge:xy,darken:py,difference:by,dstOver:cy,exclusion:wy,hardLight:gy,hue:Cy,lighten:my,luminosity:Uy,multiply:ly,names:Oy,overlay:dy,saturation:Py,screen:uy,softLight:Ey,srcOver:hy});const Ry=Object.values(ay);function Fy(t){return"number"!=typeof t||Number.isNaN(t)?1:Math.min(Math.max(t,0),1)}function Dy(t,e,n=0,i=0,r={}){if(!zb.safeParse(e).success)throw new Error("The source must be a Jimp image: an object with a bitmap of width, height and data");if("number"!=typeof n||"number"!=typeof i)throw new Error("x and y must be numbers");const{mode:a=ay.SRC_OVER}=r,o=Fy(r.opacitySource??1),s=Fy(r.opacityDest??1);if(!Ry.includes(a))throw new Error(`Unknown blend mode "${a}", expected one of: ${Ry.join(", ")}`);const h=Ly[a];n=Math.round(n),i=Math.round(i),1!==s&&t.scan((e,n,i)=>{const r=t.bitmap.data[i+3]*s;t.bitmap.data[i+3]=Math.round(r)});const c=dn(e,t),{width:l,height:f}=e.bitmap;return cc(e,0,0,l,f,(e,r,a)=>{const s=t.getPixelIndex(n+e,i+r,Eb.CROP);if(-1===s)return;const l=h({r:c[a+0]/255,g:c[a+1]/255,b:c[a+2]/255,a:c[a+3]/255},{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},o);t.bitmap.data[s+0]=Math.round(dc(255*l.r)),t.bitmap.data[s+1]=Math.round(dc(255*l.g)),t.bitmap.data[s+2]=Math.round(dc(255*l.b)),t.bitmap.data[s+3]=Math.round(dc(255*l.a))}),t}var Ny={parseSections:function(t,e){var n,i;for(t.setBigEndian(!0);t.remainingLength()>0&&218!==i;){if(255!==t.nextUInt8())throw new Error("Invalid JPEG section offset");n=(i=t.nextUInt8())>=208&&i<=217||218===i?0:t.nextUInt16()-2,e(i,t.branch(0,n)),t.skip(n)}},getSizeFromSOFSection:function(t){return t.skip(1),{height:t.nextUInt16(),width:t.nextUInt16()}},getSectionName:function(t){var e,n;switch(t){case 216:e="SOI";break;case 196:e="DHT";break;case 219:e="DQT";break;case 221:e="DRI";break;case 218:e="SOS";break;case 254:e="COM";break;case 217:e="EOI";break;default:t>=224&&t<=239?(e="APP",n=t-224):t>=192&&t<=207&&196!==t&&200!==t&&204!==t?(e="SOF",n=t-192):t>=208&&t<=215&&(e="RST",n=t-208)}var i={name:e};return"number"==typeof n&&(i.index=n),i}};function $y(t,e){switch(t){case 1:return e.nextUInt8();case 3:case 8:return e.nextUInt16();case 4:case 9:return e.nextUInt32();case 5:return[e.nextUInt32(),e.nextUInt32()];case 6:return e.nextInt8();case 10:return[e.nextInt32(),e.nextInt32()];case 11:return e.nextFloat();case 12:return e.nextDouble();default:throw new Error("Invalid format while decoding: "+t)}}function jy(t,e){var n,i,r=e.nextUInt16(),a=e.nextUInt16(),o=function(t){switch(t){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}}(a),s=e.nextUInt32(),h=o*s;if(h>4&&(e=t.openWithOffset(e.nextUInt32())),2===a){var c=(n=e.nextString(s)).indexOf("\0");-1!==c&&(n=n.substr(0,c))}else if(7===a)n=e.nextBuffer(s);else if(0!==a)for(n=[],i=0;i<s;++i)n.push($y(a,e));return h<4&&e.skip(4-h),[r,n,a]}function Gy(t,e,n){var i,r,a=e.nextUInt16();for(r=0;r<a;++r)n((i=jy(t,e))[0],i[1],i[2])}var Hy={IFD0:1,IFD1:2,GPSIFD:3,SubIFD:4,InteropIFD:5,parseTags:function(t,e){var n,i,r,a;try{n=function(t){if("Exif\0\0"!==t.nextString(6))throw new Error("Invalid EXIF header");var e=t.mark(),n=t.nextUInt16();if(18761===n)t.setBigEndian(!1);else{if(19789!==n)throw new Error("Invalid TIFF header");t.setBigEndian(!0)}if(42!==t.nextUInt16())throw new Error("Invalid TIFF data");return e}(t)}catch(t){return!1}var o=n.openWithOffset(t.nextUInt32()),s=this.IFD0;Gy(n,o,function(t,n,a){switch(t){case 34853:r=n[0];break;case 34665:i=n[0];break;default:e(s,t,n,a)}});var h=o.nextUInt32();if(0!==h){var c=n.openWithOffset(h);Gy(n,c,e.bind(null,this.IFD1))}if(r){var l=n.openWithOffset(r);Gy(n,l,e.bind(null,this.GPSIFD))}if(i){var f=n.openWithOffset(i),u=this.InteropIFD;Gy(n,f,function(t,n,i){40965===t?a=n[0]:e(u,t,n,i)})}if(a){var d=n.openWithOffset(a);Gy(n,d,e.bind(null,this.InteropIFD))}return!0}};function Zy(t){return parseInt(t,10)}function qy(t,e){t=t.map(Zy),e=e.map(Zy);var n=t[0],i=t[1]-1,r=t[2],a=e[0],o=e[1],s=e[2];return Date.UTC(n,i,r,a,o,s,0)/1e3}function Wy(t){var e=t.substr(0,10).split("-"),n=t.substr(11,8).split(":"),i=t.substr(19,6).split(":").map(Zy),r=3600*i[0]+60*i[1],a=qy(e,n);if("number"==typeof(a-=r)&&!isNaN(a))return a}function Vy(t){var e=t.split(" "),n=qy(e[0].split(":"),e[1].split(":"));if("number"==typeof n&&!isNaN(n))return n}var Jy,Yy,Xy={parseDateWithSpecFormat:Vy,parseDateWithTimezoneFormat:Wy,parseExifDate:function(t){var e=19===t.length&&":"===t.charAt(4);return 25===t.length&&"T"===t.charAt(10)?Wy(t):e?Vy(t):void 0}},Ky=[{section:Hy.GPSIFD,type:2,name:"GPSLatitude",refType:1,refName:"GPSLatitudeRef",posVal:"N"},{section:Hy.GPSIFD,type:4,name:"GPSLongitude",refType:3,refName:"GPSLongitudeRef",posVal:"E"}],Qy=[{section:Hy.SubIFD,type:306,name:"ModifyDate"},{section:Hy.SubIFD,type:36867,name:"DateTimeOriginal"},{section:Hy.SubIFD,type:36868,name:"CreateDate"},{section:Hy.SubIFD,type:306,name:"ModifyDate"}],t_={castDegreeValues:function(t,e){Ky.forEach(function(n){var i=t(n);if(i){var r=t({section:n.section,type:n.refType,name:n.refName})===n.posVal?1:-1,a=(i[0]+i[1]/60+i[2]/3600)*r;e(n,a)}})},castDateValues:function(t,e){Qy.forEach(function(n){var i=t(n);if(i){var r=Xy.parseExifDate(i);void 0!==r&&e(n,r)}})},simplifyValue:function(t,e){return Array.isArray(t)&&1===(t=t.map(function(t){return 10===e||5===e?t[0]/t[1]:t})).length&&(t=t[0]),t}};var e_,n_,i_,r_,a_=Ny,o_=Hy,s_=t_;function h_(t,e,n,i,r,a,o){this.startMarker=t,this.tags=e,this.imageSize=n,this.thumbnailOffset=i,this.thumbnailLength=r,this.thumbnailType=a,this.app1Offset=o}function c_(t){this.stream=t,this.flags={readBinaryTags:!1,resolveTagNames:!0,simplifyValues:!0,imageSize:!0,hidePointers:!0,returnTags:!0}}h_.prototype={hasThumbnail:function(t){return!(!this.thumbnailOffset||!this.thumbnailLength)&&("string"!=typeof t||("image/jpeg"===t.toLowerCase().trim()?6===this.thumbnailType:"image/tiff"===t.toLowerCase().trim()&&1===this.thumbnailType))},getThumbnailOffset:function(){return this.app1Offset+6+this.thumbnailOffset},getThumbnailLength:function(){return this.thumbnailLength},getThumbnailBuffer:function(){return this._getThumbnailStream().nextBuffer(this.thumbnailLength)},_getThumbnailStream:function(){return this.startMarker.openWithOffset(this.getThumbnailOffset())},getImageSize:function(){return this.imageSize},getThumbnailSize:function(){var t,e=this._getThumbnailStream();return a_.parseSections(e,function(e,n){"SOF"===a_.getSectionName(e).name&&(t=a_.getSizeFromSOFSection(n))}),t}},c_.prototype={enableBinaryFields:function(t){return this.flags.readBinaryTags=!!t,this},enablePointers:function(t){return this.flags.hidePointers=!t,this},enableTagNames:function(t){return this.flags.resolveTagNames=!!t,this},enableImageSize:function(t){return this.flags.imageSize=!!t,this},enableReturnTags:function(t){return this.flags.returnTags=!!t,this},enableSimpleValues:function(t){return this.flags.simplifyValues=!!t,this},parse:function(){var t,e,n,i,r,a,o,s,h,c=this.stream.mark(),l=c.openWithOffset(0),f=this.flags;return f.resolveTagNames&&(o=Yy?Jy:(Yy=1,Jy={exif:{1:"InteropIndex",2:"InteropVersion",11:"ProcessingSoftware",254:"SubfileType",255:"OldSubfileType",256:"ImageWidth",257:"ImageHeight",258:"BitsPerSample",259:"Compression",262:"PhotometricInterpretation",263:"Thresholding",264:"CellWidth",265:"CellLength",266:"FillOrder",269:"DocumentName",270:"ImageDescription",271:"Make",272:"Model",273:"StripOffsets",274:"Orientation",277:"SamplesPerPixel",278:"RowsPerStrip",279:"StripByteCounts",280:"MinSampleValue",281:"MaxSampleValue",282:"XResolution",283:"YResolution",284:"PlanarConfiguration",285:"PageName",286:"XPosition",287:"YPosition",288:"FreeOffsets",289:"FreeByteCounts",290:"GrayResponseUnit",291:"GrayResponseCurve",292:"T4Options",293:"T6Options",296:"ResolutionUnit",297:"PageNumber",300:"ColorResponseUnit",301:"TransferFunction",305:"Software",306:"ModifyDate",315:"Artist",316:"HostComputer",317:"Predictor",318:"WhitePoint",319:"PrimaryChromaticities",320:"ColorMap",321:"HalftoneHints",322:"TileWidth",323:"TileLength",324:"TileOffsets",325:"TileByteCounts",326:"BadFaxLines",327:"CleanFaxData",328:"ConsecutiveBadFaxLines",330:"SubIFD",332:"InkSet",333:"InkNames",334:"NumberofInks",336:"DotRange",337:"TargetPrinter",338:"ExtraSamples",339:"SampleFormat",340:"SMinSampleValue",341:"SMaxSampleValue",342:"TransferRange",343:"ClipPath",344:"XClipPathUnits",345:"YClipPathUnits",346:"Indexed",347:"JPEGTables",351:"OPIProxy",400:"GlobalParametersIFD",401:"ProfileType",402:"FaxProfile",403:"CodingMethods",404:"VersionYear",405:"ModeNumber",433:"Decode",434:"DefaultImageColor",435:"T82Options",437:"JPEGTables",512:"JPEGProc",513:"ThumbnailOffset",514:"ThumbnailLength",515:"JPEGRestartInterval",517:"JPEGLosslessPredictors",518:"JPEGPointTransforms",519:"JPEGQTables",520:"JPEGDCTables",521:"JPEGACTables",529:"YCbCrCoefficients",530:"YCbCrSubSampling",531:"YCbCrPositioning",532:"ReferenceBlackWhite",559:"StripRowCounts",700:"ApplicationNotes",999:"USPTOMiscellaneous",4096:"RelatedImageFileFormat",4097:"RelatedImageWidth",4098:"RelatedImageHeight",18246:"Rating",18247:"XP_DIP_XML",18248:"StitchInfo",18249:"RatingPercent",32781:"ImageID",32931:"WangTag1",32932:"WangAnnotation",32933:"WangTag3",32934:"WangTag4",32995:"Matteing",32996:"DataType",32997:"ImageDepth",32998:"TileDepth",33405:"Model2",33421:"CFARepeatPatternDim",33422:"CFAPattern2",33423:"BatteryLevel",33424:"KodakIFD",33432:"Copyright",33434:"ExposureTime",33437:"FNumber",33445:"MDFileTag",33446:"MDScalePixel",33447:"MDColorTable",33448:"MDLabName",33449:"MDSampleInfo",33450:"MDPrepDate",33451:"MDPrepTime",33452:"MDFileUnits",33550:"PixelScale",33589:"AdventScale",33590:"AdventRevision",33628:"UIC1Tag",33629:"UIC2Tag",33630:"UIC3Tag",33631:"UIC4Tag",33723:"IPTC-NAA",33918:"IntergraphPacketData",33919:"IntergraphFlagRegisters",33920:"IntergraphMatrix",33921:"INGRReserved",33922:"ModelTiePoint",34016:"Site",34017:"ColorSequence",34018:"IT8Header",34019:"RasterPadding",34020:"BitsPerRunLength",34021:"BitsPerExtendedRunLength",34022:"ColorTable",34023:"ImageColorIndicator",34024:"BackgroundColorIndicator",34025:"ImageColorValue",34026:"BackgroundColorValue",34027:"PixelIntensityRange",34028:"TransparencyIndicator",34029:"ColorCharacterization",34030:"HCUsage",34031:"TrapIndicator",34032:"CMYKEquivalent",34118:"SEMInfo",34152:"AFCP_IPTC",34232:"PixelMagicJBIGOptions",34264:"ModelTransform",34306:"WB_GRGBLevels",34310:"LeafData",34377:"PhotoshopSettings",34665:"ExifOffset",34675:"ICC_Profile",34687:"TIFF_FXExtensions",34688:"MultiProfiles",34689:"SharedData",34690:"T88Options",34732:"ImageLayer",34735:"GeoTiffDirectory",34736:"GeoTiffDoubleParams",34737:"GeoTiffAsciiParams",34850:"ExposureProgram",34852:"SpectralSensitivity",34853:"GPSInfo",34855:"ISO",34856:"Opto-ElectricConvFactor",34857:"Interlace",34858:"TimeZoneOffset",34859:"SelfTimerMode",34864:"SensitivityType",34865:"StandardOutputSensitivity",34866:"RecommendedExposureIndex",34867:"ISOSpeed",34868:"ISOSpeedLatitudeyyy",34869:"ISOSpeedLatitudezzz",34908:"FaxRecvParams",34909:"FaxSubAddress",34910:"FaxRecvTime",34954:"LeafSubIFD",36864:"ExifVersion",36867:"DateTimeOriginal",36868:"CreateDate",37121:"ComponentsConfiguration",37122:"CompressedBitsPerPixel",37377:"ShutterSpeedValue",37378:"ApertureValue",37379:"BrightnessValue",37380:"ExposureCompensation",37381:"MaxApertureValue",37382:"SubjectDistance",37383:"MeteringMode",37384:"LightSource",37385:"Flash",37386:"FocalLength",37387:"FlashEnergy",37388:"SpatialFrequencyResponse",37389:"Noise",37390:"FocalPlaneXResolution",37391:"FocalPlaneYResolution",37392:"FocalPlaneResolutionUnit",37393:"ImageNumber",37394:"SecurityClassification",37395:"ImageHistory",37396:"SubjectArea",37397:"ExposureIndex",37398:"TIFF-EPStandardID",37399:"SensingMethod",37434:"CIP3DataFile",37435:"CIP3Sheet",37436:"CIP3Side",37439:"StoNits",37500:"MakerNote",37510:"UserComment",37520:"SubSecTime",37521:"SubSecTimeOriginal",37522:"SubSecTimeDigitized",37679:"MSDocumentText",37680:"MSPropertySetStorage",37681:"MSDocumentTextPosition",37724:"ImageSourceData",40091:"XPTitle",40092:"XPComment",40093:"XPAuthor",40094:"XPKeywords",40095:"XPSubject",40960:"FlashpixVersion",40961:"ColorSpace",40962:"ExifImageWidth",40963:"ExifImageHeight",40964:"RelatedSoundFile",40965:"InteropOffset",41483:"FlashEnergy",41484:"SpatialFrequencyResponse",41485:"Noise",41486:"FocalPlaneXResolution",41487:"FocalPlaneYResolution",41488:"FocalPlaneResolutionUnit",41489:"ImageNumber",41490:"SecurityClassification",41491:"ImageHistory",41492:"SubjectLocation",41493:"ExposureIndex",41494:"TIFF-EPStandardID",41495:"SensingMethod",41728:"FileSource",41729:"SceneType",41730:"CFAPattern",41985:"CustomRendered",41986:"ExposureMode",41987:"WhiteBalance",41988:"DigitalZoomRatio",41989:"FocalLengthIn35mmFormat",41990:"SceneCaptureType",41991:"GainControl",41992:"Contrast",41993:"Saturation",41994:"Sharpness",41995:"DeviceSettingDescription",41996:"SubjectDistanceRange",42016:"ImageUniqueID",42032:"OwnerName",42033:"SerialNumber",42034:"LensInfo",42035:"LensMake",42036:"LensModel",42037:"LensSerialNumber",42112:"GDALMetadata",42113:"GDALNoData",42240:"Gamma",44992:"ExpandSoftware",44993:"ExpandLens",44994:"ExpandFilm",44995:"ExpandFilterLens",44996:"ExpandScanner",44997:"ExpandFlashLamp",48129:"PixelFormat",48130:"Transformation",48131:"Uncompressed",48132:"ImageType",48256:"ImageWidth",48257:"ImageHeight",48258:"WidthResolution",48259:"HeightResolution",48320:"ImageOffset",48321:"ImageByteCount",48322:"AlphaOffset",48323:"AlphaByteCount",48324:"ImageDataDiscard",48325:"AlphaDataDiscard",50215:"OceScanjobDesc",50216:"OceApplicationSelector",50217:"OceIDNumber",50218:"OceImageLogic",50255:"Annotations",50341:"PrintIM",50560:"USPTOOriginalContentType",50706:"DNGVersion",50707:"DNGBackwardVersion",50708:"UniqueCameraModel",50709:"LocalizedCameraModel",50710:"CFAPlaneColor",50711:"CFALayout",50712:"LinearizationTable",50713:"BlackLevelRepeatDim",50714:"BlackLevel",50715:"BlackLevelDeltaH",50716:"BlackLevelDeltaV",50717:"WhiteLevel",50718:"DefaultScale",50719:"DefaultCropOrigin",50720:"DefaultCropSize",50721:"ColorMatrix1",50722:"ColorMatrix2",50723:"CameraCalibration1",50724:"CameraCalibration2",50725:"ReductionMatrix1",50726:"ReductionMatrix2",50727:"AnalogBalance",50728:"AsShotNeutral",50729:"AsShotWhiteXY",50730:"BaselineExposure",50731:"BaselineNoise",50732:"BaselineSharpness",50733:"BayerGreenSplit",50734:"LinearResponseLimit",50735:"CameraSerialNumber",50736:"DNGLensInfo",50737:"ChromaBlurRadius",50738:"AntiAliasStrength",50739:"ShadowScale",50740:"DNGPrivateData",50741:"MakerNoteSafety",50752:"RawImageSegmentation",50778:"CalibrationIlluminant1",50779:"CalibrationIlluminant2",50780:"BestQualityScale",50781:"RawDataUniqueID",50784:"AliasLayerMetadata",50827:"OriginalRawFileName",50828:"OriginalRawFileData",50829:"ActiveArea",50830:"MaskedAreas",50831:"AsShotICCProfile",50832:"AsShotPreProfileMatrix",50833:"CurrentICCProfile",50834:"CurrentPreProfileMatrix",50879:"ColorimetricReference",50898:"PanasonicTitle",50899:"PanasonicTitle2",50931:"CameraCalibrationSig",50932:"ProfileCalibrationSig",50933:"ProfileIFD",50934:"AsShotProfileName",50935:"NoiseReductionApplied",50936:"ProfileName",50937:"ProfileHueSatMapDims",50938:"ProfileHueSatMapData1",50939:"ProfileHueSatMapData2",50940:"ProfileToneCurve",50941:"ProfileEmbedPolicy",50942:"ProfileCopyright",50964:"ForwardMatrix1",50965:"ForwardMatrix2",50966:"PreviewApplicationName",50967:"PreviewApplicationVersion",50968:"PreviewSettingsName",50969:"PreviewSettingsDigest",50970:"PreviewColorSpace",50971:"PreviewDateTime",50972:"RawImageDigest",50973:"OriginalRawFileDigest",50974:"SubTileBlockSize",50975:"RowInterleaveFactor",50981:"ProfileLookTableDims",50982:"ProfileLookTableData",51008:"OpcodeList1",51009:"OpcodeList2",51022:"OpcodeList3",51041:"NoiseProfile",51043:"TimeCodes",51044:"FrameRate",51058:"TStop",51081:"ReelName",51089:"OriginalDefaultFinalSize",51090:"OriginalBestQualitySize",51091:"OriginalDefaultCropSize",51105:"CameraLabel",51107:"ProfileHueSatMapEncoding",51108:"ProfileLookTableEncoding",51109:"BaselineExposureOffset",51110:"DefaultBlackRender",51111:"NewRawImageDigest",51112:"RawToPreviewGain",51125:"DefaultUserCrop",59932:"Padding",59933:"OffsetSchema",65e3:"OwnerName",65001:"SerialNumber",65002:"Lens",65024:"KDC_IFD",65100:"RawFile",65101:"Converter",65102:"WhiteBalance",65105:"Exposure",65106:"Shadows",65107:"Brightness",65108:"Contrast",65109:"Saturation",65110:"Sharpness",65111:"Smoothness",65112:"MoireFilter"},gps:{0:"GPSVersionID",1:"GPSLatitudeRef",2:"GPSLatitude",3:"GPSLongitudeRef",4:"GPSLongitude",5:"GPSAltitudeRef",6:"GPSAltitude",7:"GPSTimeStamp",8:"GPSSatellites",9:"GPSStatus",10:"GPSMeasureMode",11:"GPSDOP",12:"GPSSpeedRef",13:"GPSSpeed",14:"GPSTrackRef",15:"GPSTrack",16:"GPSImgDirectionRef",17:"GPSImgDirection",18:"GPSMapDatum",19:"GPSDestLatitudeRef",20:"GPSDestLatitude",21:"GPSDestLongitudeRef",22:"GPSDestLongitude",23:"GPSDestBearingRef",24:"GPSDestBearing",25:"GPSDestDistanceRef",26:"GPSDestDistance",27:"GPSProcessingMethod",28:"GPSAreaInformation",29:"GPSDateStamp",30:"GPSDifferential",31:"GPSHPositioningError"}})),f.resolveTagNames?(t={},s=function(e){return t[e.name]},h=function(e,n){t[e.name]=n}):(t=[],s=function(e){var n;for(n=0;n<t.length;++n)if(t[n].type===e.type&&t[n].section===e.section)return t.value},h=function(e,n){var i;for(i=0;i<t.length;++i)if(t[i].type===e.type&&t[i].section===e.section)return void(t.value=n)}),a_.parseSections(l,function(s,h){var l,u=h.offsetFrom(c);225===s?(l=o_.parseTags(h,function(e,a,s,h){if(f.readBinaryTags||7!==h){if(513===a){if(n=s[0],f.hidePointers)return}else if(514===a){if(i=s[0],f.hidePointers)return}else if(259===a&&(r=s[0],f.hidePointers))return;if(f.returnTags)if(f.simplifyValues&&(s=s_.simplifyValue(s,h)),f.resolveTagNames){var c=(e===o_.GPSIFD?o.gps:o.exif)[a];c||(c=o.exif[a]),t.hasOwnProperty(c)||(t[c]=s)}else t.push({section:e,type:a,value:s})}}),l&&(a=u)):f.imageSize&&"SOF"===a_.getSectionName(s).name&&(e=a_.getSizeFromSOFSection(h))}),f.simplifyValues&&(s_.castDegreeValues(s,h),s_.castDateValues(s,h)),new h_(c,t,e,n,i,r,a)}};var l_=c_;var f_={create:function(t,e){if(t instanceof(e=e||(0,eval)("this")).ArrayBuffer){var n=function(){if(n_)return e_;function t(t,e,n,i,r,a){this.global=r,e=e||0,n=n||t.byteLength-e,this.arrayBuffer=t.slice(e,e+n),this.view=new r.DataView(this.arrayBuffer,0,this.arrayBuffer.byteLength),this.setBigEndian(i),this.offset=0,this.parentOffset=(a||0)+e}return n_=1,t.prototype={setBigEndian:function(t){this.littleEndian=!t},nextUInt8:function(){var t=this.view.getUint8(this.offset);return this.offset+=1,t},nextInt8:function(){var t=this.view.getInt8(this.offset);return this.offset+=1,t},nextUInt16:function(){var t=this.view.getUint16(this.offset,this.littleEndian);return this.offset+=2,t},nextUInt32:function(){var t=this.view.getUint32(this.offset,this.littleEndian);return this.offset+=4,t},nextInt16:function(){var t=this.view.getInt16(this.offset,this.littleEndian);return this.offset+=2,t},nextInt32:function(){var t=this.view.getInt32(this.offset,this.littleEndian);return this.offset+=4,t},nextFloat:function(){var t=this.view.getFloat32(this.offset,this.littleEndian);return this.offset+=4,t},nextDouble:function(){var t=this.view.getFloat64(this.offset,this.littleEndian);return this.offset+=8,t},nextBuffer:function(t){var e=this.arrayBuffer.slice(this.offset,this.offset+t);return this.offset+=t,e},remainingLength:function(){return this.arrayBuffer.byteLength-this.offset},nextString:function(t){var e=this.arrayBuffer.slice(this.offset,this.offset+t);return e=String.fromCharCode.apply(null,new this.global.Uint8Array(e)),this.offset+=t,e},mark:function(){var e=this;return{openWithOffset:function(n){return n=(n||0)+this.offset,new t(e.arrayBuffer,n,e.arrayBuffer.byteLength-n,!e.littleEndian,e.global,e.parentOffset)},offset:this.offset,getParentOffset:function(){return e.parentOffset}}},offsetFrom:function(t){return this.parentOffset+this.offset-(t.offset+t.getParentOffset())},skip:function(t){this.offset+=t},branch:function(e,n){return n="number"==typeof n?n:this.arrayBuffer.byteLength-(this.offset+e),new t(this.arrayBuffer,this.offset+e,n,!this.littleEndian,this.global,this.parentOffset)}},e_=t}();return new l_(new n(t,0,t.byteLength,!0,e))}var i=function(){if(r_)return i_;function t(t,e,n,i){this.buffer=t,this.offset=e||0,n="number"==typeof n?n:t.length,this.endPosition=this.offset+n,this.setBigEndian(i)}return r_=1,t.prototype={setBigEndian:function(t){this.bigEndian=!!t},nextUInt8:function(){var t=this.buffer.readUInt8(this.offset);return this.offset+=1,t},nextInt8:function(){var t=this.buffer.readInt8(this.offset);return this.offset+=1,t},nextUInt16:function(){var t=this.bigEndian?this.buffer.readUInt16BE(this.offset):this.buffer.readUInt16LE(this.offset);return this.offset+=2,t},nextUInt32:function(){var t=this.bigEndian?this.buffer.readUInt32BE(this.offset):this.buffer.readUInt32LE(this.offset);return this.offset+=4,t},nextInt16:function(){var t=this.bigEndian?this.buffer.readInt16BE(this.offset):this.buffer.readInt16LE(this.offset);return this.offset+=2,t},nextInt32:function(){var t=this.bigEndian?this.buffer.readInt32BE(this.offset):this.buffer.readInt32LE(this.offset);return this.offset+=4,t},nextFloat:function(){var t=this.bigEndian?this.buffer.readFloatBE(this.offset):this.buffer.readFloatLE(this.offset);return this.offset+=4,t},nextDouble:function(){var t=this.bigEndian?this.buffer.readDoubleBE(this.offset):this.buffer.readDoubleLE(this.offset);return this.offset+=8,t},nextBuffer:function(t){var e=this.buffer.slice(this.offset,this.offset+t);return this.offset+=t,e},remainingLength:function(){return this.endPosition-this.offset},nextString:function(t){var e=this.buffer.toString("utf8",this.offset,this.offset+t);return this.offset+=t,e},mark:function(){var e=this;return{openWithOffset:function(n){return n=(n||0)+this.offset,new t(e.buffer,n,e.endPosition-n,e.bigEndian)},offset:this.offset}},offsetFrom:function(t){return this.offset-t.offset},skip:function(t){this.offset+=t},branch:function(e,n){return n="number"==typeof n?n:this.endPosition-(this.offset+e),new t(this.buffer,this.offset+e,n,this.bigEndian)}},i_=t}();return new l_(new i(t,0,t.length,!0))}},u_=e(f_);const d_=n.Buffer.from("Exif\0\0","latin1"),p_=65533-d_.length,m_=Symbol.for("jimp.rawExif"),g_=t=>t[m_],b_=(t,e)=>Object.defineProperty(t,m_,{value:e,configurable:!0,writable:!0});function w_(t){const e=[];if(255!==t[0]||216!==t[1])return e;let n=2;for(;n+3<t.length&&255===t[n];){const i=t[n+1];if(255===i){n++;continue}if(218===i||217===i)break;const r=n+2+t.readUInt16BE(n+2);if(r>t.length)break;e.push({marker:i,start:n,end:r}),n=r}return e}function y_(t,e,n){const i=t.u16(n),r=n+2+12*i;if(r+4>e.length)throw new Error("EXIF IFD is truncated");const a=[];for(let e=0;e<i;e++){const i=n+2+12*e;a.push({tag:t.u16(i),type:t.u16(i+2),count:t.u32(i+4),offset:i})}return{entries:a,next:r}}function __(t,e){if(5!==e.type||1!==e.count)return;const n=t.u32(e.offset+8),i=t.u32(n+4);return i?t.u32(n)/i:void 0}function v_(t,e,n){1===e.count&&(3===e.type&&n<=65535?t.w16(e.offset+8,n):3!==e.type&&4!==e.type||(t.w16(e.offset+2,4),t.w32(e.offset+8,n)))}function x_(t,{width:e,height:n,orientation:i}){const r=function(t){const e=t.toString("latin1",0,2);if("II"!==e&&"MM"!==e)throw new Error("EXIF data has an unknown byte order");const n="II"===e;return{u16:e=>n?t.readUInt16LE(e):t.readUInt16BE(e),u32:e=>n?t.readUInt32LE(e):t.readUInt32BE(e),w16:(e,i)=>n?t.writeUInt16LE(i,e):t.writeUInt16BE(i,e),w32:(e,i)=>n?t.writeUInt32LE(i,e):t.writeUInt32BE(i,e)}}(t);if(42!==r.u16(2))throw new Error("EXIF data is not a TIFF structure");const a=y_(r,t,r.u32(4));let o,s,h=2;for(const c of a.entries)switch(c.tag){case 274:if(3===c.type)r.w16(c.offset+8,i);else{if(4!==c.type)throw new Error("EXIF orientation has an unexpected type");r.w32(c.offset+8,i)}break;case 256:v_(r,c,e);break;case 257:v_(r,c,n);break;case 282:o=__(r,c);break;case 283:s=__(r,c);break;case 296:h=r.u16(c.offset+8);break;case 34665:{const i=y_(r,t,r.u32(c.offset+8));for(const t of i.entries)40962===t.tag?v_(r,t,e):40963===t.tag&&v_(r,t,n);break}}const c=r.u32(a.next);if(!c)return{tiff:t,unit:h,xResolution:o,yResolution:s};let l,f;r.w32(a.next,0);try{for(const e of y_(r,t,c).entries)513===e.tag?l=r.u32(e.offset+8):514===e.tag&&(f=r.u32(e.offset+8))}catch{}if(void 0!==l&&void 0!==f&&l+f<=t.length){const e=l+f;t.fill(0,l,e),e===t.length&&(t=t.subarray(0,l))}return{tiff:t,unit:h,xResolution:o,yResolution:s}}function k_(t,e){for(const{marker:i,start:r,end:a}of w_(e)){const o=r+4;if(225!==i||!e.subarray(o,o+d_.length).equals(d_))continue;const s=n.Buffer.from(e.subarray(o+d_.length,a));try{x_(n.Buffer.from(s),{width:1,height:1,orientation:1}),b_(t,s)}catch{}return}}const A_={2:1,3:2};function M_(t){const e=t._exif;return e&&e.tags&&e.tags.Orientation||1}function E_(t){if(M_(t)<2)return;const e=function(t){const e=t.bitmap.width,n=t.bitmap.height;switch(M_(t)){case 1:default:return null;case 2:return function(t,n){return[e-t-1,n]};case 3:return function(t,i){return[e-t-1,n-i-1]};case 4:return function(t,e){return[t,n-e-1]};case 5:return function(t,e){return[e,t]};case 6:return function(t,e){return[e,n-t-1]};case 7:return function(t,i){return[e-i-1,n-t-1]};case 8:return function(t,n){return[e-n-1,t]}}}(t),i=M_(t)>4,r=i?t.bitmap.height:t.bitmap.width,a=i?t.bitmap.width:t.bitmap.height;e&&function(t,e,i,r){const a=t.bitmap.data,o=t.bitmap.width,s=n.Buffer.alloc(a.length);for(let t=0;t<e;t++)for(let n=0;n<i;n++){const[i,h]=r(t,n),c=e*n+t<<2,l=o*h+i<<2,f=a.readUInt32BE(l);s.writeUInt32BE(f,c)}t.bitmap.data=s,t.bitmap.width=e,t.bitmap.height=i,t._exif.tags.Orientation=1}(t,r,a,e)}var I_=Uint8Array,S_=Uint16Array,z_=Int32Array,B_=new 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,0,0,0]),C_=new I_([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,0,0]),P_=new I_([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),T_=function(t,e){for(var n=new S_(31),i=0;i<31;++i)n[i]=e+=1<<t[i-1];var r=new z_(n[30]);for(i=1;i<30;++i)for(var a=n[i];a<n[i+1];++a)r[a]=a-n[i]<<5|i;return{b:n,r:r}},U_=T_(B_,2),O_=U_.b,L_=U_.r;O_[28]=258,L_[258]=28;for(var R_=T_(C_,0),F_=R_.b,D_=R_.r,N_=new S_(32768),$_=0;$_<32768;++$_){var j_=(43690&$_)>>1|(21845&$_)<<1;j_=(61680&(j_=(52428&j_)>>2|(13107&j_)<<2))>>4|(3855&j_)<<4,N_[$_]=((65280&j_)>>8|(255&j_)<<8)>>1}var G_=function(t,e,n){for(var i=t.length,r=0,a=new S_(e);r<i;++r)t[r]&&++a[t[r]-1];var o,s=new S_(e);for(r=1;r<e;++r)s[r]=s[r-1]+a[r-1]<<1;if(n){o=new S_(1<<e);var h=15-e;for(r=0;r<i;++r)if(t[r])for(var c=r<<4|t[r],l=e-t[r],f=s[t[r]-1]++<<l,u=f|(1<<l)-1;f<=u;++f)o[N_[f]>>h]=c}else for(o=new S_(i),r=0;r<i;++r)t[r]&&(o[r]=N_[s[t[r]-1]++]>>15-t[r]);return o},H_=new I_(288);for($_=0;$_<144;++$_)H_[$_]=8;for($_=144;$_<256;++$_)H_[$_]=9;for($_=256;$_<280;++$_)H_[$_]=7;for($_=280;$_<288;++$_)H_[$_]=8;var Z_=new I_(32);for($_=0;$_<32;++$_)Z_[$_]=5;var q_=G_(H_,9,0),W_=G_(H_,9,1),V_=G_(Z_,5,0),J_=G_(Z_,5,1),Y_=function(t){for(var e=t[0],n=1;n<t.length;++n)t[n]>e&&(e=t[n]);return e},X_=function(t,e,n){var i=e/8|0;return(t[i]|t[i+1]<<8)>>(7&e)&n},K_=function(t,e){var n=e/8|0;return(t[n]|t[n+1]<<8|t[n+2]<<16)>>(7&e)},Q_=function(t){return(t+7)/8|0},tv=function(t,e,n){return(null==n||n>t.length)&&(n=t.length),new I_(t.subarray(e,n))},ev=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],nv=function(t,e,n){var i=new Error(e||ev[t]);if(i.code=t,Error.captureStackTrace&&Error.captureStackTrace(i,nv),!n)throw i;return i},iv=function(t,e,n){n<<=7&e;var i=e/8|0;t[i]|=n,t[i+1]|=n>>8},rv=function(t,e,n){n<<=7&e;var i=e/8|0;t[i]|=n,t[i+1]|=n>>8,t[i+2]|=n>>16},av=function(t,e){for(var n=[],i=0;i<t.length;++i)t[i]&&n.push({s:i,f:t[i]});var r=n.length,a=n.slice();if(!r)return{t:uv,l:0};if(1==r){var o=new I_(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(t,e){return t.f-e.f}),n.push({s:-1,f:25001});var s=n[0],h=n[1],c=0,l=1,f=2;for(n[0]={s:-1,f:s.f+h.f,l:s,r:h};l!=r-1;)s=n[n[c].f<n[f].f?c++:f++],h=n[c!=l&&n[c].f<n[f].f?c++:f++],n[l++]={s:-1,f:s.f+h.f,l:s,r:h};var u=a[0].s;for(i=1;i<r;++i)a[i].s>u&&(u=a[i].s);var d=new S_(u+1),p=ov(n[l-1],d,0);if(p>e){i=0;var m=0,g=p-e,b=1<<g;for(a.sort(function(t,e){return d[e.s]-d[t.s]||t.f-e.f});i<r;++i){var w=a[i].s;if(!(d[w]>e))break;m+=b-(1<<p-d[w]),d[w]=e}for(m>>=g;m>0;){var y=a[i].s;d[y]<e?m-=1<<e-d[y]++-1:++i}for(;i>=0&&m;--i){var _=a[i].s;d[_]==e&&(--d[_],++m)}p=e}return{t:new I_(d),l:p}},ov=function(t,e,n){return-1==t.s?Math.max(ov(t.l,e,n+1),ov(t.r,e,n+1)):e[t.s]=n},sv=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new S_(++e),i=0,r=t[0],a=1,o=function(t){n[i++]=t},s=1;s<=e;++s)if(t[s]==r&&s!=e)++a;else{if(!r&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(r),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(r);a=1,r=t[s]}return{c:n.subarray(0,i),n:e}},hv=function(t,e){for(var n=0,i=0;i<e.length;++i)n+=t[i]*e[i];return n},cv=function(t,e,n){var i=n.length,r=Q_(e+2);t[r]=255&i,t[r+1]=i>>8,t[r+2]=255^t[r],t[r+3]=255^t[r+1];for(var a=0;a<i;++a)t[r+a+4]=n[a];return 8*(r+4+i)},lv=function(t,e,n,i,r,a,o,s,h,c,l){iv(e,l++,n),++r[256];for(var f=av(r,15),u=f.t,d=f.l,p=av(a,15),m=p.t,g=p.l,b=sv(u),w=b.c,y=b.n,_=sv(m),v=_.c,x=_.n,k=new S_(19),A=0;A<w.length;++A)++k[31&w[A]];for(A=0;A<v.length;++A)++k[31&v[A]];for(var M=av(k,7),E=M.t,I=M.l,S=19;S>4&&!E[P_[S-1]];--S);var z,B,C,P,T=c+5<<3,U=hv(r,H_)+hv(a,Z_)+o,O=hv(r,u)+hv(a,m)+o+14+3*S+hv(k,E)+2*k[16]+3*k[17]+7*k[18];if(h>=0&&T<=U&&T<=O)return cv(e,l,t.subarray(h,h+c));if(iv(e,l,1+(O<U)),l+=2,O<U){z=G_(u,d,0),B=u,C=G_(m,g,0),P=m;var L=G_(E,I,0);iv(e,l,y-257),iv(e,l+5,x-1),iv(e,l+10,S-4),l+=14;for(A=0;A<S;++A)iv(e,l+3*A,E[P_[A]]);l+=3*S;for(var R=[w,v],F=0;F<2;++F){var D=R[F];for(A=0;A<D.length;++A){var N=31&D[A];iv(e,l,L[N]),l+=E[N],N>15&&(iv(e,l,D[A]>>5&127),l+=D[A]>>12)}}}else z=q_,B=H_,C=V_,P=Z_;for(A=0;A<s;++A){var $=i[A];if($>255){rv(e,l,z[(N=$>>18&31)+257]),l+=B[N+257],N>7&&(iv(e,l,$>>23&31),l+=B_[N]);var j=31&$;rv(e,l,C[j]),l+=P[j],j>3&&(rv(e,l,$>>5&8191),l+=C_[j])}else rv(e,l,z[$]),l+=B[$]}return rv(e,l,z[256]),l+B[256]},fv=new z_([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),uv=new I_(0),dv=function(){var t=1,e=0;return{p:function(n){for(var i=t,r=e,a=0|n.length,o=0;o!=a;){for(var s=Math.min(o+2655,a);o<s;++o)r+=i+=n[o];i=(65535&i)+15*(i>>16),r=(65535&r)+15*(r>>16)}t=i,e=r},d:function(){return(255&(t%=65521))<<24|(65280&t)<<8|(255&(e%=65521))<<8|e>>8}}},pv=function(t,e,n,i,r){if(!r&&(r={l:1},e.dictionary)){var a=e.dictionary.subarray(-32768),o=new I_(a.length+t.length);o.set(a),o.set(t,a.length),t=o,r.w=a.length}return function(t,e,n,i,r,a){var o=a.z||t.length,s=new I_(i+o+5*(1+Math.ceil(o/7e3))+r),h=s.subarray(i,s.length-r),c=a.l,l=7&(a.r||0);if(e){l&&(h[0]=a.r>>3);for(var f=fv[e-1],u=f>>13,d=8191&f,p=(1<<n)-1,m=a.p||new S_(32768),g=a.h||new S_(p+1),b=Math.ceil(n/3),w=2*b,y=function(e){return(t[e]^t[e+1]<<b^t[e+2]<<w)&p},_=new z_(25e3),v=new S_(288),x=new S_(32),k=0,A=0,M=a.i||0,E=0,I=a.w||0,S=0;M+2<o;++M){var z=y(M),B=32767&M,C=g[z];if(m[B]=C,g[z]=B,I<=M){var P=o-M;if((k>7e3||E>24576)&&(P>423||!c)){l=lv(t,h,0,_,v,x,A,E,S,M-S,l),E=k=A=0,S=M;for(var T=0;T<286;++T)v[T]=0;for(T=0;T<30;++T)x[T]=0}var U=2,O=0,L=d,R=B-C&32767;if(P>2&&z==y(M-R))for(var F=Math.min(u,P)-1,D=Math.min(32767,M),N=Math.min(258,P);R<=D&&--L&&B!=C;){if(t[M+U]==t[M+U-R]){for(var $=0;$<N&&t[M+$]==t[M+$-R];++$);if($>U){if(U=$,O=R,$>F)break;var j=Math.min(R,$-2),G=0;for(T=0;T<j;++T){var H=M-R+T&32767,Z=H-m[H]&32767;Z>G&&(G=Z,C=H)}}}R+=(B=C)-(C=m[B])&32767}if(O){_[E++]=268435456|L_[U]<<18|D_[O];var q=31&L_[U],W=31&D_[O];A+=B_[q]+C_[W],++v[257+q],++x[W],I=M+U,++k}else _[E++]=t[M],++v[t[M]]}}for(M=Math.max(M,I);M<o;++M)_[E++]=t[M],++v[t[M]];l=lv(t,h,c,_,v,x,A,E,S,M-S,l),c||(a.r=7&l|h[l/8|0]<<3,l-=7,a.h=g,a.p=m,a.i=M,a.w=I)}else{for(M=a.w||0;M<o+c;M+=65535){var V=M+65535;V>=o&&(h[l/8|0]=c,V=o),l=cv(h,l+1,t.subarray(M,V))}a.i=o}return tv(s,0,i+Q_(l)+r)}(t,null==e.level?6:e.level,null==e.mem?r.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):20:12+e.mem,n,i,r)},mv=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8};function gv(t,e){e||(e={});var n=dv();n.p(t);var i=pv(t,e,e.dictionary?6:2,4);return function(t,e){var n=e.level,i=0==n?0:n<6?1:9==n?3:2;if(t[0]=120,t[1]=i<<6|(e.dictionary&&32),t[1]|=31-(t[0]<<8|t[1])%31,e.dictionary){var r=dv();r.p(e.dictionary),mv(t,2,r.d())}}(i,e),mv(i,i.length-4,n.d()),i}function bv(t,e){return function(t,e,n,i){var r=t.length;if(!r||e.f&&!e.l)return n||new I_(0);var a=!n,o=a||2!=e.i,s=e.i;a&&(n=new I_(3*r));var h=function(t){var e=n.length;if(t>e){var i=new I_(Math.max(2*e,t));i.set(n),n=i}},c=e.f||0,l=e.p||0,f=e.b||0,u=e.l,d=e.d,p=e.m,m=e.n,g=8*r;do{if(!u){c=X_(t,l,1);var b=X_(t,l+1,3);if(l+=3,!b){var w=t[(z=Q_(l)+4)-4]|t[z-3]<<8,y=z+w;if(y>r){s&&nv(0);break}o&&h(f+w),n.set(t.subarray(z,y),f),e.b=f+=w,e.p=l=8*y,e.f=c;continue}if(1==b)u=W_,d=J_,p=9,m=5;else if(2==b){var _=X_(t,l,31)+257,v=X_(t,l+10,15)+4,x=_+X_(t,l+5,31)+1;l+=14;for(var k=new I_(x),A=new I_(19),M=0;M<v;++M)A[P_[M]]=X_(t,l+3*M,7);l+=3*v;var E=Y_(A),I=(1<<E)-1,S=G_(A,E,1);for(M=0;M<x;){var z,B=S[X_(t,l,I)];if(l+=15&B,(z=B>>4)<16)k[M++]=z;else{var C=0,P=0;for(16==z?(P=3+X_(t,l,3),l+=2,C=k[M-1]):17==z?(P=3+X_(t,l,7),l+=3):18==z&&(P=11+X_(t,l,127),l+=7);P--;)k[M++]=C}}var T=k.subarray(0,_),U=k.subarray(_);p=Y_(T),m=Y_(U),u=G_(T,p,1),d=G_(U,m,1)}else nv(1);if(l>g){s&&nv(0);break}}o&&h(f+131072);for(var O=(1<<p)-1,L=(1<<m)-1,R=l;;R=l){var F=(C=u[K_(t,l)&O])>>4;if((l+=15&C)>g){s&&nv(0);break}if(C||nv(2),F<256)n[f++]=F;else{if(256==F){R=l,u=null;break}var D=F-254;if(F>264){var N=B_[M=F-257];D=X_(t,l,(1<<N)-1)+O_[M],l+=N}var $=d[K_(t,l)&L],j=$>>4;if($||nv(3),l+=15&$,U=F_[j],j>3&&(N=C_[j],U+=K_(t,l)&(1<<N)-1,l+=N),l>g){s&&nv(0);break}o&&h(f+131072);var G=f+D;if(f<U){var H=0-U,Z=Math.min(U,G);for(H+f<0&&nv(3);f<Z;++f)n[f]=i[H+f]}for(;f<G;++f)n[f]=n[f-U]}}e.l=u,e.p=R,e.b=f,e.f=c,u&&(c=1,e.m=p,e.d=d,e.n=m)}while(!c);return f!=n.length&&a?tv(n,0,f):n.subarray(0,f)}(t.subarray(((8!=(15&(n=t)[0])||n[0]>>4>7||(n[0]<<8|n[1])%31)&&nv(6,"invalid zlib data"),1==(n[1]>>5&1)&&nv(6,"invalid zlib data: "+(32&n[1]?"need":"unexpected")+" dictionary"),2+(n[1]>>3&4)),-4),{i:2},e,e);var n}var wv="undefined"!=typeof TextDecoder&&new TextDecoder;try{wv.decode(uv,{stream:!0})}catch(t){}const yv=n.Buffer.from("ICC_PROFILE\0","latin1"),_v=65533-yv.length-2,vv=new Set([192,193,194,195,197,198,199,201,202,203,205,206,207]),xv=n.Buffer.from([137,80,78,71,13,10,26,10]),kv=n.Buffer.from([0,0,0,12,106,80,32,32,13,10,135,10]);function Av(t){if(t.length<128||"acsp"!==t.toString("latin1",36,40))return;const e=t.toString("latin1",16,20);return"RGB "===e||"GRAY"===e?e:void 0}function Mv(t){const e=[];if(!t.subarray(0,8).equals(xv))return e;let n=8;for(;n+12<=t.length;){const i=t.readUInt32BE(n),r=n+12+i;if(r>t.length)break;e.push({type:t.toString("latin1",n+4,n+8),data:t.subarray(n+8,n+8+i),start:n,end:r}),n=r}return e}function Ev(t){const e=[];if("RIFF"!==t.toString("latin1",0,4)||"WEBP"!==t.toString("latin1",8,12))return e;let n=12;for(;n+8<=t.length;){const i=t.readUInt32LE(n+4);if(n+8+i>t.length)break;e.push({type:t.toString("latin1",n,n+4),data:t.subarray(n+8,n+8+i),start:n,end:Math.min(n+8+i+(1&i),t.length)}),n+=8+i+(1&i)}return e}function Iv(t){const e=[];let n=0;for(;n+8<=t.length;){let i=t.readUInt32BE(n),r=8;if(1===i&&n+16<=t.length?(i=Number(t.readBigUInt64BE(n+8)),r=16):0===i&&(i=t.length-n),i<r||n+i>t.length)break;e.push({type:t.toString("latin1",n+4,n+8),data:t.subarray(n+r,n+i)}),n+=i}return e}function Sv(t){try{const e=t.subarray(0,8).equals(xv)?function(t){for(const{type:e,data:i}of Mv(t)){if("IDAT"===e)return;if("iCCP"!==e)continue;const t=i.indexOf(0);if(t<1||0!==i[t+1])return;return n.Buffer.from(bv(i.subarray(t+2)))}}(t):"RIFF"===t.toString("latin1",0,4)?function(t){const e=Ev(t).find(({type:t})=>"ICCP"===t);return e?n.Buffer.from(e.data):void 0}(t):t.subarray(0,12).equals(kv)?function(t){const e=Iv(t).find(({type:t})=>"jp2h"===t),i=e?Iv(e.data).find(({type:t})=>"colr"===t):void 0,r=i?.data[0];return!i||2!==r&&3!==r?void 0:n.Buffer.from(i.data.subarray(3))}(t):function(t){const e=[];let i=0;for(const{marker:n,start:r,end:a}of w_(t)){const o=r+4;if(226!==n||!t.subarray(o,o+yv.length).equals(yv))continue;const s=t[o+yv.length],h=t[o+yv.length+1];if(!s||s>h||i&&h!==i||e[s-1])return;i=h,e[s-1]=t.subarray(o+yv.length+2,a)}for(let t=0;t<i;t++)if(!e[t])return;return i?n.Buffer.concat(e):void 0}(t);return e&&Av(e)?e:void 0}catch{return}}let zv;function Bv(t,e){const i=Mv(e),[r]=i;if("IHDR"!==r?.type)return e;const a=r.data[9],o=0===a||4===a?"GRAY":"RGB ";if(Av(t)!==o)return e;const s=n.Buffer.concat([n.Buffer.from("iCCP","latin1"),n.Buffer.from("ICC Profile\0\0","latin1"),gv(t)]),h=n.Buffer.alloc(s.length+8);h.writeUInt32BE(s.length-4,0),s.copy(h,4),h.writeUInt32BE(function(t){if(!zv){zv=new Uint32Array(256);for(let t=0;t<256;t++){let e=t;for(let t=0;t<8;t++)e=1&e?3988292384^e>>>1:e>>>1;zv[t]=e>>>0}}let e=4294967295;for(const n of t)e=zv[255&(e^n)]^e>>>8;return(4294967295^e)>>>0}(s),s.length+4);const c=[e.subarray(0,r.end),h];for(const{type:t,start:n,end:r}of i.slice(1))"sRGB"!==t&&"iCCP"!==t&&c.push(e.subarray(n,r));return c.push(e.subarray(i[i.length-1].end)),n.Buffer.concat(c)}function Cv(t,e){const i=n.Buffer.alloc(8);return i.write(t,0,"latin1"),i.writeUInt32LE(e.length,4),n.Buffer.concat([i,e,n.Buffer.alloc(1&e.length)])}const Pv=new Set(["image/jpeg","image/png","image/webp"]);function Tv(t,e,i,r,a){return"image/jpeg"===e?function(t,e){const i=w_(e),r=i.find(({marker:t})=>vv.has(t)),a=r?e[r.start+9]:void 0,o=1===a?"GRAY":3===a?"RGB ":void 0,s=Math.ceil(t.length/_v);if(Av(t)!==o||s>255)return e;let h=2;for(const{marker:t,end:e}of i){if(224!==t&&225!==t)break;h=e}const c=[e.subarray(0,h)];for(let e=0;e<s;e++){const i=t.subarray(e*_v,(e+1)*_v),r=n.Buffer.alloc(4);r.writeUInt16BE(65506,0),r.writeUInt16BE(2+yv.length+2+i.length,2),c.push(r,yv,n.Buffer.from([e+1,s]),i)}return c.push(e.subarray(h)),n.Buffer.concat(c)}(t,i):"image/png"===e?Bv(t,i):"image/webp"===e?function(t,e,i,r){const a=Ev(e);if(!a.length||"RGB "!==Av(t))return e;const o=a.find(({type:t})=>"VP8X"===t);let s;if(o)s=n.Buffer.from(e.subarray(o.start,o.end)),s[8]|=32;else{const t=n.Buffer.alloc(10),e=a.find(({type:t})=>"VP8L"===t),o=e&&e.data.length>=5&&e.data.readUInt32LE(1)>>>28&1;t[0]=32|(o?16:0),t.writeUIntLE(i-1,4,3),t.writeUIntLE(r-1,7,3),s=Cv("VP8X",t)}const h=n.Buffer.concat([n.Buffer.from("WEBP","latin1"),s,Cv("ICCP",t),...a.filter(({type:t})=>"VP8X"!==t&&"ICCP"!==t).map(({start:t,end:n})=>e.subarray(t,n))]),c=n.Buffer.alloc(8);return c.write("RIFF",0,"latin1"),c.writeUInt32LE(h.length,4),n.Buffer.concat([c,h])}(t,i,r,a):i}var Uv=Object.defineProperty,Ov=(t,e,n)=>((t,e,n)=>e in t?Uv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n)(t,"symbol"!=typeof e?e+"":e,n);const Lv={data:n.Buffer.alloc(0),width:0,height:0};function Rv(t){const e=n.Buffer.alloc(t.byteLength),i=new Uint8Array(t);for(let t=0;t<e.length;++t)e[t]=i[t];return e}async function Fv(t){if(n.Buffer.isBuffer(t))return t;if(t instanceof ArrayBuffer)return Rv(t);if(ArrayBuffer.isView(t))return n.Buffer.from(t.buffer,t.byteOffset,t.byteLength);if("undefined"!=typeof Blob&&t instanceof Blob)return Rv(await t.arrayBuffer());throw new Error("Expected image data as a Buffer, ArrayBuffer, Uint8Array (or other ArrayBuffer view) or Blob")}const Dv=new ty({"image/x-icon":["ico"],"image/jxl":["jxl"]});async function Nv(t){if("string"!=typeof t)return t;const[e,n]=await Yw(fetch(t));if(e)throw new Error(`Could not load Buffer from URL: ${t}`);if(!n.ok)throw new Error(`HTTP Status ${n.status} for url ${t}`);const[i,r]=await Yw(n.arrayBuffer());if(i)throw new Error(`Could not load Buffer from ${t}`);return Rv(r)}function $v(t,e){const{width:i,height:r}=t;if("number"!=typeof r||"number"!=typeof i)throw new Error("bitmap must have width and height");const a=function(t,e){if(n.Buffer.isBuffer(t))return e?n.Buffer.from(t):t;if(t instanceof Uint8Array||t instanceof Uint8ClampedArray)return n.Buffer.from(new Uint8Array(t.buffer,t.byteOffset,t.byteLength));if(Array.isArray(t))return n.Buffer.concat(t.map(t=>n.Buffer.from(t.toString(16).padStart(8,"0"),"hex")));throw new Error("data must be a Buffer, Uint8Array, Uint8ClampedArray or an array of numbers")}(t.data,e),o=i*r*4;if(a.length!==o)throw new Error(`bitmap data is ${a.length} bytes, but a ${i}x${r} RGBA image needs exactly ${o} (width * height * 4)`);return a===t.data?t:{data:a,width:i,height:r}}function jv(t="srgb"){if(!(t in Ke))throw new Error(`Unknown color space "${t}", expected "srgb" or "display-p3"`);return"display-p3"===t?Qe:void 0}function Gv(t,e,n){const i=new Error(e,void 0===n?void 0:{cause:n});return i.editIndex=t,i}function Hv({plugins:t,formats:e}={}){const i=t||[],r=(e||[]).map(t=>t()),a=new Set(i.flatMap(Object.keys));async function o(t){const e=(await async function(t){const{fileTypeFromBuffer:e}=await Promise.resolve().then(function(){return FS});return e(t instanceof ArrayBuffer?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}(t))?.mime,n=r.find(t=>t.mime===e)??r.find(e=>e.detect?.(t));if(!n&&!e)throw new Error("Could not find MIME for Buffer");if(!n||!n.decode)throw new Error(`Mime type ${e} does not support decoding`);return n}function s(t,e,n,i){t.mime=e.mime,function(t,e,{rotate:n}){try{t._exif=u_.create(e).parse(),k_(t,e),n&&E_(t)}catch{}}(t,n,{rotate:i?.exifRotate??!0}),t.iccProfile=Sv(n)}function h(t,e,i){let r=t.bitmap;if(!e.hasAlpha){const e=new c({width:r.width,height:r.height,color:t.background});e.iccProfile=t.iccProfile,Dy(e,t),r=e.bitmap}const a=i?void 0:un(sn(t),Ye);return a&&(r===t.bitmap&&(r={...r,data:n.Buffer.from(r.data)}),a(r.data)),r}const c=class{constructor(t=Lv){if(Ov(this,"bitmap",Lv),Ov(this,"background",0),Ov(this,"formats",[]),Ov(this,"mime"),Ov(this,"iccProfile"),this.formats=r,this.iccProfile=jv(t.colorSpace),"data"in t)this.bitmap=$v(t,!1);else if(this.bitmap={data:n.Buffer.alloc(t.width*t.height*4),width:t.width,height:t.height},t.color){this.background="string"==typeof t.color?pc(t.color,sn(this)):t.color;for(let t=0;t<this.bitmap.data.length;t+=4)this.bitmap.data.writeUInt32BE(this.background,t)}for(const t of i)for(const e in t)this[e]=(...n)=>{const i=t[e]?.(this,...n);return"object"==typeof i&&"bitmap"in i?(this.bitmap=i.bitmap,this):i}}static async read(t,e){return this.fromBuffer(await Nv(t),e)}static async readFrames(t,e){return this.fromBufferFrames(await Nv(t),e)}static async fromBufferFrames(t,e){const n=Math.floor(e?.maxFrames??1/0);if(!(n>=1))throw new Error("maxFrames must be at least 1");const i=await Fv(t),r=await o(i),a=e?.[r.mime];if(!r.decodeFrames)return{frames:[{image:await this.fromBuffer(i,e)}]};const{frames:h,loop:l}=await r.decodeFrames(i,a,{maxFrames:n});return{frames:h.map(({bitmap:t,delay:n})=>{const a=new c(t);return s(a,r,i,e),void 0===n?{image:a}:{image:a,delay:n}}),...void 0===l?{}:{loop:l}}}static fromBitmap(t){return new c({...$v(t,!0),colorSpace:t.colorSpace})}static async fromBuffer(t,e){const n=await Fv(t),i=await o(n),r=new c(await i.decode(n,e?.[i.mime]));return s(r,i,n,e),r}static async encodeFrames(t,e,i){const a=r.find(e=>e.mime===t);if(!a||!a.encode)throw new Error(`Unsupported MIME type: ${t}`);const o=function(t){if(!Array.isArray(t)||0===t.length)throw new Error("encodeFrames needs an array of at least one frame");return t.map((t,e)=>{const n="object"==typeof t&&null!==t?t:{},{image:i,delay:r}="bitmap"in n?{image:n}:n;if(!i||!i.bitmap)throw new Error(`Frame ${e} must be a Jimp image or an object with an image and an optional delay`);if(void 0!==r&&("number"!=typeof r||Number.isNaN(r)))throw new Error(`Frame ${e}'s delay must be a number of milliseconds`);return{image:i,delay:r}})}(e);if(!a.encodeFrames){if(o.length>1){const e=r.filter(t=>t.encodeFrames).map(t=>t.mime);throw new Error(`${t} can't hold more than one frame, but got ${o.length}. Formats that can: ${e.join(", ")||"none"}`)}const{image:e}=o[0];return(e instanceof c?e:Object.assign(new c(e.bitmap),{background:e.background,iccProfile:e.iccProfile})).getBuffer(t,i)}const s=await a.encodeFrames(o.map(({image:t,delay:e})=>({bitmap:h(t,a,!1),delay:e})),i);return n.Buffer.isBuffer(s)?s:n.Buffer.from(s.buffer,s.byteOffset,s.byteLength)}static async writeFrames(t,e,n){const i=sy.getType(t)??Dv.getType(t);if(!i)throw new Error(`Cannot write "${t}": the path has no recognisable file extension to determine the image format`);await Xw(await this.encodeFrames(i,e,n))}inspect(){return"<Jimp "+(this.bitmap===Lv?"pending...":this.bitmap.width+"x"+this.bitmap.height)+">"}toString(){return"[object Jimp]"}get width(){return this.bitmap.width}get height(){return this.bitmap.height}get colorSpace(){return sn(this).name}toColorSpace(t){const e=jv(t),n=sn(this),i=Ke[t];if(n===i)return this;if(!n.toXyz)throw new Error("Can't convert from the image's ICC profile: only RGB profiles with primaries and tone curves are supported");return un(n,i)?.(this.bitmap.data),this.iccProfile=e,this}async getBuffer(t,e){const i=this.formats.find(e=>e.mime===t);if(!i||!i.encode)throw new Error(`Unsupported MIME type: ${t}`);const{exif:r,icc:a}=e??{},o=void 0!==this.iccProfile&&!1!==a&&Pv.has(t),s=await i.encode(h(this,i,o),e);let c=n.Buffer.isBuffer(s)?s:n.Buffer.from(s.buffer,s.byteOffset,s.byteLength);return"image/jpeg"===t&&r&&(c=function(t,e,i){const r=g_(t);if(!r)return e;const{tiff:a,unit:o,xResolution:s,yResolution:h}=x_(n.Buffer.from(r),i);if(a.length>p_)throw new Error(`EXIF data is ${a.length} bytes, more than the ${p_} a JPEG APP1 segment can hold`);const[c]=w_(e),l=224===c?.marker?c:void 0,f=n.Buffer.from(e.subarray(0,l?l.end:2)),u=A_[o],d=Math.round(s??0),p=Math.round(h??0);l&&l.end-l.start>=16&&"JFIF\0"===f.toString("latin1",l.start+4,l.start+9)&&u&&d>=1&&d<=65535&&p>=1&&p<=65535&&(f[l.start+11]=u,f.writeUInt16BE(d,l.start+12),f.writeUInt16BE(p,l.start+14));const m=n.Buffer.alloc(4);return m.writeUInt16BE(65505,0),m.writeUInt16BE(2+d_.length+a.length,2),n.Buffer.concat([f,m,d_,a,e.subarray(f.length)])}(this,c,{width:this.bitmap.width,height:this.bitmap.height,orientation:M_(this)})),o&&(c=Tv(this.iccProfile,t,c,this.bitmap.width,this.bitmap.height)),c}async getBase64(t,e){return"data:"+t+";base64,"+(await this.getBuffer(t,e)).toString("base64")}async write(t,e){const n=sy.getType(t)??Dv.getType(t);if(!n)throw new Error(`Cannot write "${t}": the path has no recognisable file extension to determine the image format`);await Xw(await this.getBuffer(n,e))}clone(){const t=new c({...this.bitmap,data:n.Buffer.from(this.bitmap.data)}),{_exif:e}=this;return e&&(t._exif={...e,tags:{...e.tags}}),function(t,e){const n=g_(t);n&&b_(e,n)}(this,t),t.iccProfile=this.iccProfile,t.background=this.background,t.mime=this.mime,t}apply(t){if(!Array.isArray(t))throw new Error("apply needs an array of edits");return t.forEach((t,e)=>{if(!Array.isArray(t)||"string"!=typeof t[0])throw Gv(e,`Edit ${e} must be an array of a method name and its arguments, like ["resize", { w: 100 }]`);if(!a.has(t[0]))throw Gv(e,`Edit ${e}: "${t[0]}" isn't a plugin method of this Jimp class`)}),t.forEach((t,e)=>{const[n,...i]=t;let r;try{r=this[n](...i)}catch(t){throw Gv(e,`Edit ${e} (${n}) failed: ${t.message}`,t)}if(r!==this)throw Gv(e,`Edit ${e}: "${n}" returns a value instead of changing the image, so it can't be used in apply`)}),this}getPixelIndex(t,e,n){if(n||(n=Eb.EXTEND),"number"!=typeof t||"number"!=typeof e||Number.isNaN(t)||Number.isNaN(e))throw new Error("x and y must be numbers");const{width:i,height:r}=this.bitmap;let a=Math.round(t),o=Math.round(e);return n===Eb.EXTEND?(a=Math.min(Math.max(a,0),i-1),o=Math.min(Math.max(o,0),r-1)):n===Eb.WRAP&&(a=(a%i+i)%i,o=(o%r+r)%r),a>=0&&a<i&&o>=0&&o<r?i*o+a<<2:-1}getPixelColor(t,e){const n=this.getPixelIndex(t,e);return this.bitmap.data.readUInt32BE(n)}setPixelColor(t,e,n){if("number"!=typeof t||"number"!=typeof e||"number"!=typeof n||Number.isNaN(e)||Number.isNaN(n))throw new Error("hex, x and y must be numbers");const i=this.getPixelIndex(e,n,Eb.CROP);return-1!==i&&this.bitmap.data.writeUInt32BE(t,i),this}hasAlpha(){const{width:t,height:e,data:n}=this.bitmap,i=t*e<<2;for(let t=3;t<i;t+=4)if(255!==n[t])return!0;return!1}composite(t,e=0,n=0,i={}){return Dy(this,t,e,n,i),this}scan(t,e,n,i,r){return cc(this,t,e,n,i,r)}scanIterator(t=0,e=0,n=this.bitmap.width-t,i=this.bitmap.height-e){if("number"!=typeof t||"number"!=typeof e)throw new Error("x and y must be numbers");if("number"!=typeof n||"number"!=typeof i)throw new Error("w and h must be numbers");return function*(t,e,n,i,r){({x:e,y:n,w:i,h:r}=hc(t,e,n,i,r));for(let a=n;a<n+r;a++)for(let n=e;n<e+i;n++){const e=t.bitmap.width*a+n<<2;yield{x:n,y:a,idx:e,image:t}}}(this,t,e,n,i)}};return c}const Zv=Ah({w:uh(),h:uh(),align:Ih([uh(),Ah({x:uh().optional(),y:uh().optional()})]).optional(),mode:Oh(ip).optional(),premultiplyAlpha:gh().optional()});const qv={contain(t,e){const{w:n,h:i,align:r=ey.CENTER|iy.MIDDLE,mode:a,premultiplyAlpha:o}=Zv.parse(e),{alignX:s,alignY:h}=function(t){if("object"==typeof t){const e=(t=.5)=>Math.min(1,Math.max(0,t));return{alignX:e(t.x),alignY:e(t.y)}}const e=7&t,n=t>>3&7;if(!Number.isInteger(t)||t!==(e|n<<3)||e&e-1||n&n-1)throw new Error("align must combine at most one HorizontalAlign and one VerticalAlign flag");return{alignX:e?(e>>1)/2:.5,alignY:n?(n>>1)/2:.5}}(r),c=n/i>t.bitmap.width/t.bitmap.height?i/t.bitmap.height:n/t.bitmap.width,l=Tp.scale(sc(t),{f:c,mode:a,premultiplyAlpha:o});(t=Tp.resize(t,{w:n,h:i,mode:a})).scan((e,n,i)=>{t.bitmap.data.writeUInt32BE(t.background,i)});const f=Math.round((t.bitmap.width-l.bitmap.width)*s),u=Math.round((t.bitmap.height-l.bitmap.height)*h);if(!1===o){const e=4*l.bitmap.width;for(let n=0;n<l.bitmap.height;n++)l.bitmap.data.copy(t.bitmap.data,4*((u+n)*t.bitmap.width+f),n*e,(n+1)*e);return t}return Pb.blit(t,{src:l,x:f,y:u})}},Wv=Ah({x:uh(),y:uh(),w:uh(),h:uh()}),Vv=Ah({tolerance:uh().min(0).max(1).optional(),cropOnlyFrames:gh().optional(),cropSymmetric:gh().optional(),leaveBorder:uh().optional(),ignoreSides:Ah({north:gh().optional(),south:gh().optional(),east:gh().optional(),west:gh().optional()}).optional()});function Jv(t,e){return 0===t.a&&0===e.a?0:uc(t,e)}const Yv={crop(t,e){const i=Wv.parse(e),{x:r,y:a,w:o,h:s}=hc(t,i.x,i.y,i.w,i.h);if(0===o||0===s)throw new Error(`The crop region (x: ${i.x}, y: ${i.y}, w: ${i.w}, h: ${i.h}) doesn't overlap the ${t.bitmap.width}x${t.bitmap.height} image, so the result would be empty`);if(0===r&&o===t.bitmap.width){const e=o*a+r<<2,n=e+(s*o<<2);t.bitmap.data=t.bitmap.data.slice(e,n)}else{const{data:e,width:i}=t.bitmap,h=o<<2,c=n.Buffer.allocUnsafe(s*h);for(let t=0;t<s;t++){const n=(a+t)*i+r<<2;e.copy(c,t*h,n,n+h)}t.bitmap.data=c}return t.bitmap.width=o,t.bitmap.height=s,t},autocropRect:(t,e={})=>function(t,e={}){const{tolerance:n=2e-4,cropOnlyFrames:i=!0,cropSymmetric:r=!1,leaveBorder:a=0,ignoreSides:o}="number"==typeof e?{tolerance:e}:Vv.parse(e),s=t.bitmap.width,h=t.bitmap.height,c={north:!1,south:!1,east:!1,west:!1,...o},l=lc(t.getPixelColor(0,0));let f=0,u=0,d=0,p=0;if(!c.north)t:for(let e=0;e<h-1;e++){for(let i=0;i<s;i++)if(Jv(l,lc(t.getPixelColor(i,e)))>n)break t;f++}if(!c.west)t:for(let e=0;e<s-1;e++){for(let i=0+f;i<h;i++)if(Jv(l,lc(t.getPixelColor(e,i)))>n)break t;p++}if(!c.south)t:for(let e=h-1;e>=f+1;e--){for(let i=s-u-1;i>=0;i--)if(Jv(l,lc(t.getPixelColor(i,e)))>n)break t;d++}if(!c.east)t:for(let e=s-1;e>=0+p+1;e--){for(let i=h-1;i>=0+f;i--)if(Jv(l,lc(t.getPixelColor(e,i)))>n)break t;u++}const m=(c.north||f>0)&&(c.east||u>0)&&(c.south||d>0)&&(c.west||p>0);if(p-=a,u-=a,f-=a,d-=a,r){const t=Math.min(u,p),e=Math.min(f,d);p=t,u=t,f=e,d=e}return p=p>=0?p:0,u=u>=0?u:0,f=f>=0?f:0,d=d>=0?d:0,i&&!m?{x:0,y:0,w:s,h:h}:{x:p,y:f,w:s-(p+u),h:h-(d+f)}}(t,e),autocrop(t,e={}){const n=this.autocropRect(t,e);return 0===n.x&&0===n.y&&n.w===t.bitmap.width&&n.h===t.bitmap.height||this.crop(t,n),t}},Xv=64;function Kv(t,e){const n=Math.min(4,e-t),i=[];for(let r=0;r<n;r++)i.push(t+Math.floor((r+.5)*(e-t)/n));return i}function Qv(t,e){return.299*t[e]+.587*t[e+1]+.114*t[e+2]}function tx(t,e){const n=Math.max(...t);let i=0,r=1/0;return t.forEach((t,a)=>{if(t>=n-.01*Math.abs(n)){const t=e(a);t<r&&(i=a,r=t)}}),i}function ex(t,e,n){const i=e.w/t.width<e.h/t.height,r=function(t){const{width:e,height:n,data:i}=t,r=Math.min(1,256/Math.max(e,n)),a=Math.max(1,Math.round(e*r)),o=Math.max(1,Math.round(n*r)),s=[],h=[];for(let t=0;t<a;t++){const n=Math.floor(t*e/a);s.push(Kv(n,Math.max(n+1,Math.floor((t+1)*e/a))))}for(let t=0;t<o;t++){const e=Math.floor(t*n/o);h.push(Kv(e,Math.max(e+1,Math.floor((t+1)*n/o))))}const c=new Float64Array(a*o*4);for(let t=0;t<o;t++)for(let n=0;n<a;n++){let r=0,o=0,l=0,f=0,u=0;for(const a of h[t])for(const t of s[n]){const n=a*e+t<<2,s=i[n+3];r+=i[n]*s,o+=i[n+1]*s,l+=i[n+2]*s,f+=s,u++}const d=t*a+n<<2;f>0&&(c[d]=r/f/255,c[d+1]=o/f/255,c[d+2]=l/f/255),c[d+3]=f/u/255}return{width:a,height:o,data:c}}(t),a=i?r.width:r.height,o=Math.max(1,Math.round(i?e.w*r.width/t.width:e.h*r.height/t.height)),s=a-o;if(s<=0)return{alignX:.5,alignY:.5};let h;if("entropy"===n)h=tx(function(t,e,n){const{width:i,height:r,data:a}=t,o=e?i:r,s=e?r:i,h=new Float64Array(o*Xv);for(let t=0;t<o;t++)for(let n=0;n<s;n++){const r=(e?n*i+t:t*i+n)<<2,o=Math.min(63,Math.floor(Qv(a,r)*Xv)),s=t*Xv+o;h[s]=h[s]+a[r+3]}const c=new Float64Array(Xv),l=[];for(let t=0;t<o;t++){for(let e=0;e<Xv;e++){let i=c[e]+h[t*Xv+e];t>=n&&(i-=h[(t-n)*Xv+e]),c[e]=i}if(t>=n-1){let t=0,e=0;for(const e of c)t+=e;for(const n of c)if(n>1e-9){const i=n/t;e-=i*Math.log2(i)}l.push(e)}}return l}(r,i,o),t=>Math.abs(t-s/2));else{const t=function({width:t,height:e,data:n}){const i=new Float64Array(t*e);for(let t=0;t<i.length;t++)i[t]=Qv(n,t<<2);const r=(n,r)=>i[Math.min(e-1,Math.max(0,r))*t+Math.min(t-1,Math.max(0,n))],a=new Float64Array(t*e);for(let o=0;o<e;o++)for(let e=0;e<t;e++){const s=o*t+e,h=s<<2,c=n[h+3];if(0===c)continue;const l=r(e+1,o-1)+2*r(e+1,o)+r(e+1,o+1)-r(e-1,o-1)-2*r(e-1,o)-r(e-1,o+1),f=r(e-1,o+1)+2*r(e,o+1)+r(e+1,o+1)-r(e-1,o-1)-2*r(e,o-1)-r(e+1,o-1),u=Math.min(1,Math.sqrt(l*l+f*f)/2),d=n[h],p=n[h+1],m=n[h+2],g=Math.max(d,p,m)-Math.min(d,p,m),b=Math.max(0,g-.25)/.75,w=128+255*(-.168736*d-.331264*p+.5*m),y=128+255*(.5*d-.418688*p-.081312*m),_=Math.hypot((w-102)/25,(y-153)/20),v=i[s],x=v>.2&&v<.95?Math.min(1,Math.max(0,(.9-_)/.4)):0;a[s]=c*(u+b+3*x)}return a}(r),e=i?r.height:r.width,n=new Float64Array(a);for(let o=0;o<a;o++)for(let a=0;a<e;a++)n[o]=n[o]+t[i?a*r.width+o:o*r.width+a];const c=new Float64Array(o);for(let t=0;t<o;t++)c[t]=1-.75*Math.abs((2*t+1)/o-1);const l=[];for(let t=0;t<=s;t++){let e=0;for(let i=0;i<o;i++)e+=n[t+i]*c[i];l.push(e)}h=tx(l,t=>Math.abs(t-s/2))}const c=h/s;return i?{alignX:c,alignY:.5}:{alignX:.5,alignY:c}}const nx=Ah({w:uh(),h:uh(),align:Ih([uh(),Ah({x:uh().optional(),y:uh().optional()}),Uh(["entropy","attention"])]).optional(),mode:Oh(ip).optional(),premultiplyAlpha:gh().optional()}),ix=nx.pick({w:!0,h:!0,align:!0});function rx(t,e,n){if("string"==typeof t)return ex(e.bitmap,n,t);if("object"==typeof t){const e=(t=.5)=>Math.min(1,Math.max(0,t));return{alignX:e(t.x),alignY:e(t.y)}}const i=7&t,r=t>>3&7;if(!Number.isInteger(t)||t!==(i|r<<3)||i&i-1||r&r-1)throw new Error("align must combine at most one HorizontalAlign and one VerticalAlign flag");return{alignX:i?(i>>1)/2:.5,alignY:r?(r>>1)/2:.5}}function ax(t,e,n){return e/n>t.bitmap.width/t.bitmap.height?e/t.bitmap.width:n/t.bitmap.height}const ox={cover(t,e){const{w:n,h:i,align:r=ey.CENTER|iy.MIDDLE,mode:a,premultiplyAlpha:o}=nx.parse(e),s=ax(t,n,i),{alignX:h,alignY:c}=rx(r,t,{w:n/s,h:i/s});return t=Tp.scale(t,{f:s,mode:a,premultiplyAlpha:o}),t=Yv.crop(t,{x:(t.bitmap.width-n)*h,y:(t.bitmap.height-i)*c,w:n,h:i})},coverRect(t,e){const{w:n,h:i,align:r=ey.CENTER|iy.MIDDLE}=ix.parse(e),{width:a,height:o}=t.bitmap,s=ax(t,n,i),{alignX:h,alignY:c}=rx(r,t,{w:n/s,h:i/s}),l=Math.min(a,Math.max(1,Math.round(n/s))),f=Math.min(o,Math.max(1,Math.round(i/s)));return{x:Math.round((a-l)*h),y:Math.round((o-f)*c),w:l,h:f}}},sx=Ah({map:zb,offset:Ih([uh(),Ah({x:uh().optional(),y:uh().optional()})])}),hx={displace(t,e){const{map:n,offset:i}=sx.parse(e),{x:r=0,y:a=0}="number"==typeof i?{x:i}:i,o=sc(t),{width:s,height:h}=t.bitmap;return t.scan((e,i,c)=>{const l=Math.floor(e*n.bitmap.width/s),f=Math.floor(i*n.bitmap.height/h)*n.bitmap.width+l<<2,u=Math.round(n.bitmap.data[f]/256*r),d=Math.round(n.bitmap.data[f+1]/256*a),p=t.getPixelIndex(e+u,i+d);t.bitmap.data[p]=o.bitmap.data[c],t.bitmap.data[p+1]=o.bitmap.data[c+1],t.bitmap.data[p+2]=o.bitmap.data[c+2],t.bitmap.data[p+3]=o.bitmap.data[c+3]}),t}},cx=Ih([Rh("bw"),Rh("rgb565"),uh().int().min(2).max(256)]),lx=zh("type",[Mh({type:Rh("rgb565").default("rgb565")}),Mh({type:Uh(["floyd-steinberg","atkinson","bayer4","bayer8"]),palette:cx.optional()})]),fx=[[1,0,7/16],[-1,1,3/16],[0,1,5/16],[1,1,1/16]],ux=[[1,0,1/8],[2,0,1/8],[-1,1,1/8],[0,1,1/8],[1,1,1/8],[0,2,1/8]];function dx(t){if(1===t)return[[0]];const e=dx(t/2),n=[[0,2],[3,1]];return Array.from({length:t},(i,r)=>Array.from({length:t},(i,a)=>4*e[r%(t/2)][a%(t/2)]+n[Math.floor(r/(t/2))][Math.floor(a/(t/2))]))}function px(t){return Array.from({length:t},(e,n)=>Math.round(255*n/(t-1)))}function mx(t){return Array.from({length:2**t},(e,n)=>n<<8-t|n>>2*t-8)}function gx(t,e){const n=e.length-1;let i=Math.round(Math.min(Math.max(t,0),255)*n/255);for(;i>0&&t<(e[i-1]+e[i])/2;)i--;for(;i<n&&t>=(e[i]+e[i+1])/2;)i++;return e[i]}function bx(t,e){return.2126*t[e]+.7152*t[e+1]+.0722*t[e+2]}const wx={dither(t,e={}){const n=lx.parse(e);if("rgb565"===n.type)return function(t){const e=[1,9,3,11,13,5,15,7,4,12,2,10,16,8,14,6];return t.scan((n,i,r)=>{const a=e[((3&i)<<2)+n%4];t.bitmap.data[r]=Math.min(t.bitmap.data[r]+a,255),t.bitmap.data[r+1]=Math.min(t.bitmap.data[r+1]+a,255),t.bitmap.data[r+2]=Math.min(t.bitmap.data[r+2]+a,255)}),t}(t);const{type:i,palette:r="bw"}=n,{data:a,width:o,height:s}=t.bitmap,h="bw"===r,c="bw"===r?[px(2)]:"rgb565"===r?[mx(5),mx(6),mx(5)]:[px(r),px(r),px(r)],l=c.length,f=(t,e)=>0!==a[4*(e*o+t)+3],u=new Float32Array(o*s*l);for(let t=0;t<o*s;t++)h?u[t]=bx(a,4*t):(u[3*t]=a[4*t],u[3*t+1]=a[4*t+1],u[3*t+2]=a[4*t+2]);const d=(t,e,n)=>{const i=4*(e*o+t);a[i]=n[0],a[i+1]=n[h?0:1],a[i+2]=n[h?0:2]};if("bayer4"===i||"bayer8"===i){const e="bayer4"===i?4:8,n=dx(e);for(let t=0;t<s;t++)for(let i=0;i<o;i++){if(!f(i,t))continue;const r=(n[t%e][i%e]+.5)/e**2-.5,a=(t*o+i)*l;d(i,t,c.map((t,e)=>gx(u[a+e]+255*r/(t.length-1),t)))}return t}const p="atkinson"===i?ux:fx;for(let t=0;t<s;t++)for(let e=0;e<o;e++){if(!f(e,t))continue;const n=(t*o+e)*l,i=c.map((t,e)=>gx(u[n+e],t));d(e,t,i);for(const[r,a,h]of p){const c=e+r,d=t+a;if(c<0||c>=o||d>=s||!f(c,d))continue;const p=(d*o+c)*l;for(let t=0;t<l;t++)u[p+t]+=(u[n+t]-i[t])*h}}return t}};var yx=Object.defineProperty,_x=(t,e,n)=>((t,e,n)=>e in t?yx(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n)(t,"symbol"!=typeof e?e+"":e,n);const vx=/[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/y,xx=/[\s,]*/y,kx=/[MmLlHhVvCcSsQqTtAaZz]/y;class Ax{constructor(t){_x(this,"data"),_x(this,"index",0),this.data=t}match(t){t.lastIndex=this.index;const e=t.exec(this.data);return e&&(this.index=t.lastIndex),e?.[0]}skipSeparators(){this.match(xx)}done(){return this.skipSeparators(),this.index>=this.data.length}command(){return this.skipSeparators(),this.match(kx)}numberNext(){return this.skipSeparators(),vx.lastIndex=this.index,vx.test(this.data)}number(){this.skipSeparators();const t=this.match(vx);return void 0===t&&this.fail("a number"),Number(t)}flag(){this.skipSeparators();const t=this.data[this.index];return"0"!==t&&"1"!==t&&this.fail("a flag (0 or 1)"),this.index++,"1"===t}fail(t){const e=this.index<this.data.length?`"${this.data[this.index]}"`:"the end of the path";throw new Error(`Invalid path data: expected ${t} at position ${this.index} but found ${e}`)}}function Mx(t,e,n,i,r,a,o,s,h,c){if(e===h&&n===c)return;if(i=Math.abs(i),r=Math.abs(r),0===i||0===r)return void t.push({type:"L",x:h,y:c});const l=a*Math.PI/180,f=Math.cos(l),u=Math.sin(l),d=(e-h)/2,p=(n-c)/2,m=f*d+u*p,g=-u*d+f*p,b=m*m/(i*i)+g*g/(r*r);b>1&&(i*=Math.sqrt(b),r*=Math.sqrt(b));const w=i*i,y=r*r,_=w*y-w*g*g-y*m*m,v=w*g*g+y*m*m,x=(o===s?-1:1)*Math.sqrt(Math.max(0,_/v)),k=x*i*g/r,A=-x*r*m/i,M=f*k-u*A+(e+h)/2,E=u*k+f*A+(n+c)/2,I=Math.atan2((g-A)/r,(m-k)/i);let S=Math.atan2((-g-A)/r,(-m-k)/i)-I;s&&S<0?S+=2*Math.PI:!s&&S>0&&(S-=2*Math.PI);const z=Math.max(1,Math.ceil(Math.abs(S)/(Math.PI/2)-1e-9)),B=S/z,C=4/3*Math.tan(B/4),P=(t,e)=>[M+f*i*t-u*r*e,E+u*i*t+f*r*e];for(let e=0;e<z;e++){const n=I+e*B,i=n+B,r=Math.cos(n),a=Math.sin(n),o=Math.cos(i),s=Math.sin(i),[l,f]=P(r-C*a,a+C*r),[u,d]=P(o+C*s,s-C*o),[p,m]=e===z-1?[h,c]:P(o,s);t.push({type:"C",x1:l,y1:f,x2:u,y2:d,x:p,y:m})}}var Ex=Object.defineProperty,Ix=(t,e,n)=>((t,e,n)=>e in t?Ex(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n)(t,"symbol"!=typeof e?e+"":e,n);const Sx=.1;class zx{constructor(){Ix(this,"polylines",[]),Ix(this,"points",[])}moveTo(t,e){this.end(!1),this.points.push(t,e)}lineTo(t,e){const{points:n}=this,i=n.length;0!==i&&n[i-2]===t&&n[i-1]===e||n.push(t,e)}end(t){const{points:e}=this;t&&e.length>2&&e[0]===e[e.length-2]&&e[1]===e[e.length-1]&&(e.length-=2),e.length>0&&this.polylines.push({points:e,closed:t}),this.points=[]}finish(){return this.end(!1),this.polylines}}function Bx(t,e){return Math.min(1e4,Math.max(1,Math.ceil(Math.sqrt(t/e))))}function Cx(t,e,n,i,r,a,o,s){const h=Bx(Math.hypot(e-2*i+a,n-2*r+o)/4,s);for(let s=1;s<h;s++){const c=s/h,l=1-c;t.lineTo(l*l*e+2*l*c*i+c*c*a,l*l*n+2*l*c*r+c*c*o)}t.lineTo(a,o)}function Px(t,e,n,i,r,a,o,s,h,c){const l=Bx(3*Math.max(Math.hypot(e-2*i+a,n-2*r+o),Math.hypot(i-2*a+s,r-2*o+h))/4,c);for(let c=1;c<l;c++){const f=c/l,u=1-f,d=u*u*u,p=3*u*u*f,m=3*u*f*f,g=f*f*f;t.lineTo(d*e+p*i+m*a+g*s,d*n+p*r+m*o+g*h)}t.lineTo(s,h)}function Tx(t,e,n){const i=Math.PI/4,r=Math.min(i,t>n?Math.max(2*Math.acos(1-n/t),2*Math.PI/1e4):i),a=Math.round(Math.abs(e)/i);return a>0&&Math.abs(Math.abs(e)-a*i)<1e-9?a*Math.ceil(i/r-1e-9):Math.ceil(Math.abs(e)/r-1e-9)}function Ux(t,e,n,i,r,a,o,s){const h=Tx(Math.max(i,r),o,s);if(h<1)return;const c=Math.abs(o)/h,l=Math.sin(c);let f=1;if(2===h)f=c/l;else if(h>2){const t=(h-2)*l;f=(-l+Math.sqrt(l*l+t*h*c))/t}for(let s=1;s<=h;s++){const c=a+o*s/h,l=s===h?1:f;t(e+i*l*Math.cos(c),n+r*l*Math.sin(c))}}function Ox(t,e,n,i,r,a){const o=Tx(Math.max(i,r),2*Math.PI,a),s=2*Math.PI/o,h=Math.sqrt(s/Math.sin(s));for(let a=0;a<o;a++){const o=s*a;t(e+i*h*Math.cos(o),n+r*h*Math.sin(o))}}const Lx={M:["x","y"],L:["x","y"],Q:["x1","y1","x","y"],C:["x1","y1","x2","y2","x","y"],Z:[]};function Rx(t,e){const n=Lx[t?.type];if(!n)throw new Error(`Unknown path command ${JSON.stringify(t?.type)} at index ${e}, expected M, L, Q, C or Z`);for(const i of n){const n=t[i];if("number"!=typeof n||!Number.isFinite(n))throw new Error(`Path command ${e} (${t.type}) needs ${i} to be a finite number, got ${String(n)}`)}}function Fx(t,e={}){const n="string"==typeof t?function(t){const e=new Ax(t),n=[];let i=0,r=0,a=0,o=0,s=0,h=0,c="";for(;!e.done();){const t=e.command();if(t||e.fail("a command"),0===n.length&&"M"!==t&&"m"!==t)throw new Error(`Invalid path data: it must start with a move command (M or m), not "${t}"`);const l=t.toLowerCase(),f=t===l;let u=!0;do{const t=f?i:0,d=f?r:0;switch(l){case"m":i=t+e.number(),r=d+e.number(),n.push({type:u?"M":"L",x:i,y:r}),u&&(a=i,o=r);break;case"l":i=t+e.number(),r=d+e.number(),n.push({type:"L",x:i,y:r});break;case"h":i=t+e.number(),n.push({type:"L",x:i,y:r});break;case"v":r=d+e.number(),n.push({type:"L",x:i,y:r});break;case"c":case"s":{let a,o;"c"===l?(a=t+e.number(),o=d+e.number()):"C"===c?(a=2*i-s,o=2*r-h):(a=i,o=r);const f=t+e.number(),u=d+e.number();i=t+e.number(),r=d+e.number(),n.push({type:"C",x1:a,y1:o,x2:f,y2:u,x:i,y:r}),s=f,h=u;break}case"q":case"t":{let a,o;"q"===l?(a=t+e.number(),o=d+e.number()):"Q"===c?(a=2*i-s,o=2*r-h):(a=i,o=r),i=t+e.number(),r=d+e.number(),n.push({type:"Q",x1:a,y1:o,x:i,y:r}),s=a,h=o;break}case"a":{const a=e.number(),o=e.number(),s=e.number(),h=e.flag(),c=e.flag(),l=t+e.number(),f=d+e.number();Mx(n,i,r,a,o,s,h,c,l,f),i=l,r=f;break}case"z":n.push({type:"Z"}),i=a,r=o}c="c"===l||"s"===l?"C":"q"===l||"t"===l?"Q":"",u=!1}while("z"!==l&&e.numberNext())}return n}(t):t,i=e.tolerance&&e.tolerance>0?e.tolerance:Sx,[r,a,o,s,h,c]=e.transform??[1,0,0,1,0,0],l=(t,e)=>r*t+o*e+h,f=(t,e)=>a*t+s*e+c,u=new zx;let d=0,p=0,m=0,g=0,b=!1;const w=()=>{b||(u.moveTo(d,p),m=d,g=p,b=!0)};for(let t=0;t<n.length;t++){const e=n[t];switch(Rx(e,t),e.type){case"M":d=l(e.x,e.y),p=f(e.x,e.y),b=!1,w();break;case"L":w(),d=l(e.x,e.y),p=f(e.x,e.y),u.lineTo(d,p);break;case"Q":{w();const t=l(e.x,e.y),n=f(e.x,e.y);Cx(u,d,p,l(e.x1,e.y1),f(e.x1,e.y1),t,n,i),d=t,p=n;break}case"C":{w();const t=l(e.x,e.y),n=f(e.x,e.y);Px(u,d,p,l(e.x1,e.y1),f(e.x1,e.y1),l(e.x2,e.y2),f(e.x2,e.y2),t,n,i),d=t,p=n;break}case"Z":b&&(u.end(!0),b=!1),d=m,p=g}}return u.finish()}const Dx=gh().optional(),Nx=Ih([tc,Ah({type:Rh("linear"),x1:uh(),y1:uh(),x2:uh(),y2:uh(),stops:ec,dither:Dx}),Ah({type:Rh("radial"),cx:uh(),cy:uh(),r:uh().min(0),stops:ec,dither:Dx})]);function $x(t,e){const n=sn(e);if("object"!=typeof t||!("type"in t))return{color:rc(t,n)};const i=ac(nc(t.stops),n,1024),r=t.dither??!1;if(!r)for(let t=0;t<i.length;t+=4)i[t]=Math.round(i[t]),i[t+1]=Math.round(i[t+1]),i[t+2]=Math.round(i[t+2]);if("linear"===t.type){const{x1:e,y1:n}=t,a=t.x2-e,o=t.y2-n,s=a*a+o*o;return 0===s?{lut:i,dither:r,at:()=>1}:{lut:i,dither:r,at:(t,i)=>((t-e)*a+(i-n)*o)/s}}const{cx:a,cy:o,r:s}=t;return 0===s?{lut:i,dither:r,at:()=>1}:{lut:i,dither:r,at:(t,e)=>Math.hypot(t-a,e-o)/s}}function jx(t,e,n,i,r,a,o=0){if(a>=1)return t[e]=Math.round(n+o),t[e+1]=Math.round(i+o),t[e+2]=Math.round(r+o),void(t[e+3]=255);if(a<=0)return;const s=t[e+3]/255*(1-a),h=a+s;t[e]=Math.round((n*a+t[e]*s)/h+o),t[e+1]=Math.round((i*a+t[e+1]*s)/h+o),t[e+2]=Math.round((r*a+t[e+2]*s)/h+o),t[e+3]=Math.round(255*h+o)}function Gx(t,e,n,i,r,a,o){const{color:s,lut:h,at:c,dither:l}=n;let f=4*(i*e+r);if(s){const[e,n,i,h]=s,c=h/255;for(let s=r;s<a;s++,f+=4){const r=o[s];r>0&&jx(t,f,e,n,i,c*r)}return}const u=i+.5;for(let e=r;e<a;e++,f+=4){const n=o[e];if(n>0){const r=c(e+.5,u),a=4*Math.round(1023*(r<0?0:r>1?1:r));jx(t,f,h[a],h[a+1],h[a+2],h[a+3]/255*n,l?oc(e,i)-.5:0)}}}var Hx=Object.defineProperty,Zx=(t,e,n)=>((t,e,n)=>e in t?Hx(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n)(t,"symbol"!=typeof e?e+"":e,n);class qx{constructor(t,e){Zx(this,"width"),Zx(this,"height"),Zx(this,"data",new Float64Array(320)),Zx(this,"length",0),Zx(this,"minY",1/0),Zx(this,"maxY",-1/0),this.width=t,this.height=e}add(t,e,n,i){if(e===i||!Number.isFinite(t+e+n+i))return;let r=1;e>i&&(r=-1,[t,e,n,i]=[n,i,t,e]);const{height:a,width:o}=this;if(i<=0||e>=a)return;const s=(n-t)/(i-e);if(e<0&&(t+=(0-e)*s,e=0),i>a&&(n=t+(a-e)*s,i=a),t>=0&&t<=o&&n>=0&&n<=o)return void this.push(t,e,i,s,r);const h=n=>e+(n-t)/s;let c=e,l=t;const f=[];for(const e of[0,o])(t<e&&n>e||t>e&&n<e)&&f.push(h(e));f.sort((t,e)=>t-e),f.push(i);for(const a of f){const h=a===i?n:t+(a-e)*s,f=(l+h)/2;f<=0||f>=o?this.push(f<=0?0:o,c,a,0,r):this.push(Wx(l,0,o),c,a,s,r),c=a,l=h}}push(t,e,n,i,r){if(n<=e)return;if(this.data.length<5*(this.length+1)){const t=new Float64Array(2*this.data.length);t.set(this.data),this.data=t}const a=5*this.length;this.data[a]=t,this.data[a+1]=e,this.data[a+2]=n,this.data[a+3]=i,this.data[a+4]=r,this.length++,this.minY=Math.min(this.minY,e),this.maxY=Math.max(this.maxY,n)}}function Wx(t,e,n){return t<e?e:t>n?n:t}function Vx(t,e,n){const[i,r,a,o]=t,s=Math.min(1,e/(i+r),e/(o+a),n/(i+o),n/(r+a));return s<1?[i*s,r*s,a*s,o*s]:t}function Jx(t,e,n,i,r,a){const[o,s,h,c]=Vx(r,n,i),l=new zx,f=(t,e)=>l.lineTo(t,e),u=t+n,d=e+i,p=(t,e,n,i,r,o)=>{t>0?(l.lineTo(e+t*Math.cos(i),n+t*Math.sin(i)),Ux(f,e,n,t,t,i,Math.PI/2,a)):l.lineTo(r,o)};return l.moveTo(t+o,e),p(s,u-s,e+s,-Math.PI/2,u,e),p(h,u-h,d-h,0,u,d),p(c,t+c,d-c,Math.PI/2,t,d),p(o,t+o,e+o,Math.PI,t,e),l.end(!0),l.polylines[0]}function Yx(t,e,n,i,r){const a=[];return Ox((t,e)=>a.push(t,e),t,e,n,i,r),{points:a,closed:!0}}var Xx=Object.defineProperty,Kx=(t,e,n)=>((t,e,n)=>e in t?Xx(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n)(t,"symbol"!=typeof e?e+"":e,n);const Qx=1e-6;function tk(t,e,n,i){return Math.abs(t[e]-n)<Qx&&Math.abs(t[e+1]-i)<Qx}class ek{constructor(t){Kx(this,"hw"),Kx(this,"cap"),Kx(this,"join"),Kx(this,"miterLimit"),Kx(this,"tolerance"),Kx(this,"polygons",[]),this.hw=(t.width??1)/2,this.cap=t.cap??"butt",this.join=t.join??"miter",this.miterLimit=t.miterLimit??10,this.tolerance=t.tolerance&&t.tolerance>0?t.tolerance:Sx}arc(t,e,n,i,r,a){const{hw:o}=this;Ux((e,n)=>t.push(e,n),e,n,o,o,Math.atan2(r,i),a,this.tolerance)}outerSweep(t,e,n,i,r,a){const o=t*i-e*n,s=t*n+e*i;return Math.abs(o)<=1e-12*this.hw*this.hw&&s<0?t*a-e*r>0?Math.PI:-Math.PI:Math.atan2(o,s)}outerJoin(t,e,n,i,r,a,o,s,h){const{hw:c}=this;if(t.push(e+i,n+r),"round"!==this.join){if("miter"===this.join){const s=i+a,h=r+o,l=s*s+h*h;if(l>0&&2*c/Math.sqrt(l)<=this.miterLimit){const i=2*c*c/l;t.push(e+s*i,n+h*i)}}t.push(e+a,n+o)}else this.arc(t,e,n,i,r,this.outerSweep(i,r,a,o,s,h))}addCap(t,e,n,i,r,a,o){const{hw:s}=this;"square"===this.cap?(t.push(e+i+a*s,n+r+o*s),t.push(e-i+a*s,n-r+o*s)):"round"===this.cap&&(this.arc(t,e,n,i,r,this.outerSweep(i,r,-i,-r,a,o)),t.length-=2)}dot(t,e){const{hw:n}=this;if("round"===this.cap){const i=[];Ox((t,e)=>i.push(t,e),t,e,n,n,this.tolerance),this.polygons.push({points:i,closed:!0})}else"square"===this.cap&&this.polygons.push({points:[t-n,e-n,t+n,e-n,t+n,e+n,t-n,e+n],closed:!0})}add(t){const e=function({points:t,closed:e}){const n=[];for(let e=0;e+1<t.length;e+=2){const i=t[e],r=t[e+1];!Number.isFinite(i+r)||0!==n.length&&tk(n,n.length-2,i,r)||n.push(i,r)}return e&&n.length>2&&tk(n,n.length-2,n[0],n[1])&&(n.length-=2),n}(t),n=e.length/2,i=t.closed&&n>1;if(0===n)return;if(1===n)return void this.dot(e[0],e[1]);const{hw:r}=this,a=i?n:n-1,o=new Float64Array(2*a);for(let t=0;t<a;t++){const i=(t+1)%n,r=e[2*i]-e[2*t],a=e[2*i+1]-e[2*t+1],s=Math.hypot(r,a);o[2*t]=r/s,o[2*t+1]=a/s}const s=[],h=[],c=(t,n,i)=>{const a=e[2*t],c=e[2*t+1],l=o[2*n],f=o[2*n+1],u=o[2*i],d=o[2*i+1],p=-f*r,m=l*r,g=-d*r,b=u*r,w=l*d-f*u;w>0?(s.push(a+p,c+m,a,c,a+g,c+b),this.outerJoin(h,a,c,-p,-m,-g,-b,l,f)):w<0||l*u+f*d<0?(this.outerJoin(s,a,c,p,m,g,b,l,f),h.push(a-p,c-m,a,c,a-g,c-b)):(s.push(a+p,c+m),h.push(a-p,c-m))};if(i){for(let t=0;t<n;t++)c(t,(t-1+a)%a,t);return this.polygons.push({points:s,closed:!0}),void this.polygons.push({points:nk(h),closed:!0})}const l=a-1,f=e[0],u=e[1],d=e[2*(n-1)],p=e[2*(n-1)+1],m=-o[1]*r,g=o[0]*r,b=-o[2*l+1]*r,w=o[2*l]*r;s.push(f+m,u+g),h.push(f-m,u-g);for(let t=1;t<n-1;t++)c(t,t-1,t);s.push(d+b,p+w),h.push(d-b,p-w);const y=s;this.addCap(y,d,p,b,w,o[2*l],o[2*l+1]);for(let t=h.length-2;t>=0;t-=2)y.push(h[t],h[t+1]);this.addCap(y,f,u,-m,-g,-o[0],-o[1]),this.polygons.push({points:y,closed:!0})}}function nk(t){const e=new Array(t.length);for(let n=0;n<t.length;n+=2)e[t.length-2-n]=t[n],e[t.length-1-n]=t[n+1];return e}function ik(t,e,n,i="nonzero"){const{width:r,height:a,data:o}=t.bitmap;!function(t,e,n){const i=Math.floor(e.width),r=Math.floor(e.height),a="evenodd"===e.fillRule;if(!(i>0&&r>0))return;const o=new qx(i,r);for(const{points:e}of t){const t=e.length>>1;if(t<2)continue;let n=e[2*(t-1)],i=e[2*(t-1)+1];for(let r=0;r<t;r++){const t=e[2*r],a=e[2*r+1];o.add(n,i,t,a),n=t,i=a}}if(0===o.length)return;const s=o.data,h=new Uint32Array(o.length);for(let t=0;t<h.length;t++)h[t]=t;h.sort((t,e)=>s[5*t+1]-s[5*e+1]);const c=new Float64Array(i+2),l=(t,e)=>{c[t]=c[t]+e},f=new Float32Array(i),u=new Uint32Array(o.length);let d=0,p=0;const m=Math.min(r,Math.ceil(o.maxY));for(let t=Math.max(0,Math.floor(o.minY));t<m;t++){const e=t+1;for(;p<h.length&&s[5*h[p]+1]<e;)u[d++]=h[p++];let r=i+2,o=-1;for(let n=0;n<d;n++){const a=5*u[n],h=s[a],c=s[a+1],f=s[a+2];if(f<=t){u[n--]=u[--d];continue}const p=s[a+3],m=c>t?c:t,g=f<e?f:e,b=(g-m)*s[a+4],w=Wx(h+(m-c)*p,0,i),y=Wx(h+(g-c)*p,0,i),_=w<y?w:y,v=w<y?y:w,x=Math.floor(_),k=Math.ceil(v);if(k<=x+1){const t=.5*(w+y)-x;l(x,b-b*t),l(x+1,b*t),r=x<r?x:r,o=x+1>o?x+1:o}else{const t=1/(v-_),e=_-x,n=.5*t*(1-e)*(1-e),i=v-k+1,a=.5*t*i*i;if(l(x,b*n),k===x+2)l(x+1,b*(1-n-a));else{const i=t*(1.5-e);l(x+1,b*(i-n));for(let e=x+2;e<k-1;e++)l(e,b*t);l(k-1,b*(1-(i+(k-x-3)*t)-a))}l(k,b*a),r=x<r?x:r,o=k>o?k:o}}if(o<0)continue;const m=o<i?o:i;let g=0,b=-1,w=-1;for(let t=r;t<m;t++){g+=c[t],c[t]=0;let e=g<0?-g:g;a?(e-=2*Math.floor(e/2),e=e>1?2-e:e):e>1&&(e=1),e<1e-9?e=0:e>1-1e-9&&(e=1),f[t]=e,e>0&&(b<0&&(b=t),w=t)}for(let t=m;t<=o;t++)c[t]=0;b>=0&&n(t,b,w+1,f)}}(e,{width:r,height:a,fillRule:i},(t,e,i,a)=>{Gx(o,r,n,t,e,i,a)})}const rk=Ih([Ph([uh(),uh()]),Ah({x:uh(),y:uh()})]),ak=Uh(["butt","round","square"]),ok=Uh(["miter","round","bevel"]),sk=Uh(["nonzero","evenodd"]),hk=Ah({fill:Nx.optional(),stroke:Nx.optional(),strokeWidth:uh().min(0).optional()}),ck=Ah({join:ok.optional(),miterLimit:uh().min(1).optional()}),lk=ck.extend({cap:ak.optional(),fillRule:sk.optional()}),fk=Ah({x1:uh(),y1:uh(),x2:uh(),y2:uh(),color:Nx,width:uh().min(0).optional(),cap:ak.optional()}),uk=Ah({topLeft:uh().min(0).optional(),topRight:uh().min(0).optional(),bottomRight:uh().min(0).optional(),bottomLeft:uh().min(0).optional()}),dk=Uh(["center","inside","outside"]),pk=hk.extend(ck.shape).extend({x:uh(),y:uh(),w:uh(),h:uh(),radius:Ih([uh().min(0),uk]).optional(),strokeAlign:dk.optional()}),mk=hk.extend({cx:uh(),cy:uh(),rx:uh().min(0),ry:uh().min(0)}),gk=hk.extend(lk.shape).extend({points:xh(rk),closed:gh().optional()}),bk=zh("type",[Ah({type:Rh("M"),x:uh(),y:uh()}),Ah({type:Rh("L"),x:uh(),y:uh()}),Ah({type:Rh("Q"),x1:uh(),y1:uh(),x:uh(),y:uh()}),Ah({type:Rh("C"),x1:uh(),y1:uh(),x2:uh(),y2:uh(),x:uh(),y:uh()}),Ah({type:Rh("Z")})]),wk=hk.extend(lk.shape).extend({path:Ih([Ns(),xh(bk)])}),yk=Ah({x:uh(),y:uh(),color:Nx,tolerance:uh().min(0).max(1).optional()});function _k(t,e,n){return vk(t,e,n,()=>function(t,e={}){const n=new ek(e);if(!((e.width??1)>0))return[];for(const e of t)n.add(e);return n.polygons}(e,{width:n.strokeWidth??1,cap:n.cap,join:n.join,miterLimit:n.miterLimit}))}function vk(t,e,n,i,r){const{stroke:a}=n,o=n.fill??(void 0===a?255:void 0),s=void 0===o?void 0:$x(o,t),h=void 0===a?void 0:$x(a,t);return s&&ik(t,e,s,n.fillRule),h&&ik(t,i(),h,r),t}const xk={drawLine(t,e){const{x1:n,y1:i,x2:r,y2:a,color:o,width:s=1,cap:h}=fk.parse(e);return _k(t,[{points:[n,i,r,a],closed:!1}],{stroke:o,strokeWidth:s,cap:h})},drawRect(t,e){const n=pk.parse(e);let{x:i,y:r,w:a,h:o}=n;a<0&&(i+=a,a=-a),o<0&&(r+=o,o=-o);const s=Vx(function(t=0){return"number"==typeof t?[t,t,t,t]:[t.topLeft??0,t.topRight??0,t.bottomRight??0,t.bottomLeft??0]}(n.radius),a,o),h=Jx(i,r,a,o,s,Sx),{strokeAlign:c="center",strokeWidth:l=1}=n;return"center"===c?_k(t,[h],n):vk(t,[h],n,()=>{if("outside"===c){const t=s.map(t=>t>0?t+l:0);return[Jx(i-l,r-l,a+2*l,o+2*l,t,Sx),h]}const t=a-2*l,e=o-2*l;if(t<=0||e<=0)return[h];const n=s.map(t=>Math.max(0,t-l));return[h,Jx(i+l,r+l,t,e,n,Sx)]},"evenodd")},drawEllipse(t,e){const n=mk.parse(e),{cx:i,cy:r,rx:a,ry:o}=n;return _k(t,[Yx(i,r,a,o,Sx)],n)},drawPolygon(t,e){const n=gk.parse(e),i=[];for(const t of n.points)Array.isArray(t)?i.push(t[0],t[1]):i.push(t.x,t.y);return _k(t,[{points:i,closed:n.closed??!0}],n)},drawPath(t,e){const n=wk.parse(e);return _k(t,Fx(n.path,{tolerance:Sx}),n)},floodFill(t,e){const{x:n,y:i,color:r,tolerance:a=0}=yk.parse(e),o=$x(r,t),{width:s,data:h}=t.bitmap,c=function(t,e,n,i){const{width:r,height:a,data:o}=t;if(!(e>=0&&e<r&&n>=0&&n<a))return;const s=4*(n*r+e),h=o[s+3]/255,c=o[s]*h,l=o[s+1]*h,f=o[s+2]*h,u=o[s+3],d=255*i,p=new Uint8Array(r*a),m=t=>{if(p[t])return!1;const e=4*t,n=o[e+3],i=n/255;return Math.abs(n-u)<=d&&Math.abs(o[e]*i-c)<=d&&Math.abs(o[e+1]*i-l)<=d&&Math.abs(o[e+2]*i-f)<=d},g=[e,n];for(;g.length>0;){const t=g.pop(),e=g.pop(),n=t*r;if(!m(n+e))continue;let i=e,o=e;for(;i>0&&m(n+i-1);)i--;for(;o<r-1&&m(n+o+1);)o++;p.fill(1,n+i,n+o+1);for(const e of[t-1,t+1]){if(e<0||e>=a)continue;let t=!1;for(let n=i;n<=o;n++)m(e*r+n)?t||(g.push(n,e),t=!0):t=!1}}return p}(t.bitmap,Math.floor(n),Math.floor(i),a);if(!c)return t;const l=new Float32Array(s).fill(1);for(let e=0;e<t.bitmap.height;e++){const t=e*s;let n=-1;for(let i=0;i<=s;i++){const r=i<s&&1===c[t+i];r&&n<0?n=i:!r&&n>=0&&(Gx(h,s,o,e,n,i,l),n=-1)}}return t}},kk=Ah({radius:uh().min(0).optional()}),Ak={fisheye(t,e={}){const{radius:n=2.5}=kk.parse(e),i=sc(t),{width:r,height:a}=i.bitmap;return i.scan((e,o)=>{const s=e/r,h=o/a,c=Math.sqrt(Math.pow(s-.5,2)+Math.pow(h-.5,2));if(0===c)return;const l=2*Math.pow(c,n),f=(s-.5)/c,u=(h-.5)/c,d=Math.round((l*f+.5)*r),p=Math.round((l*u+.5)*a),m=i.getPixelColor(d,p);t.setPixelColor(m,e,o)}),t.setPixelColor(i.getPixelColor(r/2,a/2),r/2,a/2),t}},Mk=Ah({horizontal:gh().optional(),vertical:gh().optional()}),Ek={flip(t,e){const{horizontal:i,vertical:r}=Mk.parse(e),a=n.Buffer.alloc(t.bitmap.data.length);return t.scan((e,n,o)=>{const s=i?t.bitmap.width-1-e:e,h=r?t.bitmap.height-1-n:n,c=t.bitmap.width*h+s<<2,l=t.bitmap.data.readUInt32BE(o);a.writeUInt32BE(l,c)}),t.bitmap.data=n.Buffer.from(a),t}};function Ik(t,e){if(!(t&&e&&t.length&&e.length))throw new Error("Bad alphabet");this.srcAlphabet=t,this.dstAlphabet=e}Ik.prototype.convert=function(t){var e,n,i,r={},a=this.srcAlphabet.length,o=this.dstAlphabet.length,s=t.length,h="string"==typeof t?"":[];if(!this.isValid(t))throw new Error('Number "'+t+'" contains of non-alphabetic digits ('+this.srcAlphabet+")");if(this.srcAlphabet===this.dstAlphabet)return t;for(e=0;e<s;e++)r[e]=this.srcAlphabet.indexOf(t[e]);do{for(n=0,i=0,e=0;e<s;e++)(n=n*a+r[e])>=o?(r[i++]=parseInt(n/o,10),n%=o):i>0&&(r[i++]=0);s=i,h=this.dstAlphabet.slice(n,n+1).concat(h)}while(0!==i);return h},Ik.prototype.isValid=function(t){for(var e=0;e<t.length;++e)if(-1===this.srcAlphabet.indexOf(t[e]))return!1;return!0};var Sk=Ik;function zk(t,e){var n=new Sk(t,e);return function(t){return n.convert(t)}}zk.BIN="01",zk.OCT="01234567",zk.DEC="0123456789",zk.HEX="0123456789abcdef";var Bk=e(zk);const Ck="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~";function Pk(t,e){let n="";for(let i=1;i<=e;i++){const r=Math.floor(t)/Math.pow(83,e-i)%83;n+=Ck[Math.floor(r)]}return n}function Tk(t){let e=0;for(const n of t)e=83*e+Ck.indexOf(n);return e}let Uk;function Ok(){return Uk||(Uk=Float64Array.from({length:256},(t,e)=>{const n=e/255;return n<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)})),Uk}function Lk(t){const e=Math.max(0,Math.min(1,t));return e<=.0031308?Math.trunc(12.92*e*255+.5):Math.trunc(255*(1.055*Math.pow(e,1/2.4)-.055)+.5)}function Rk(t,e){return(t<0?-1:1)*Math.pow(Math.abs(t),e)}function Fk(t,e,n){const i=new Float64Array(t*e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)i[r*e+t]=n?Math.cos(Math.PI*r*t/e):Math.cos(Math.PI*t*r/e);return i}function Dk(t,e,n,i){const{componentsX:r,componentsY:a}=function(t){if("string"!=typeof t||t.length<6)throw new Error("A BlurHash must be at least 6 characters");for(const e of t)if(!Ck.includes(e))throw new Error(`"${e}" isn't a BlurHash character`);const e=Tk(t[0]),n=Math.floor(e/9)+1,i=e%9+1,r=4+2*i*n;if(t.length!==r)throw new Error(`This BlurHash has ${i}x${n} components, so it should be ${r} characters, not ${t.length}`);return{componentsX:i,componentsY:n}}(t),o=Ok(),s=(Tk(t[1])+1)/166*i,h=r*a,c=new Float64Array(3*h),l=Tk(t.substring(2,6));c[0]=o[l>>16],c[1]=o[l>>8&255],c[2]=o[255&l];for(let e=1;e<h;e++){const n=Tk(t.substring(4+2*e,6+2*e)),i=Math.floor(n/361),r=Math.floor(n/19)%19,a=n%19;c[3*e]=Rk((i-9)/9,2)*s,c[3*e+1]=Rk((r-9)/9,2)*s,c[3*e+2]=Rk((a-9)/9,2)*s}const f=Fk(r,e,!1),u=Fk(a,n,!1),d=new Uint8ClampedArray(e*n*4);for(let t=0;t<n;t++)for(let i=0;i<e;i++){let o=0,s=0,h=0;for(let l=0;l<a;l++){const a=u[l*n+t];for(let t=0;t<r;t++){const n=f[t*e+i]*a,u=3*(t+l*r);o+=c[u]*n,s+=c[u+1]*n,h+=c[u+2]*n}}const l=4*(i+t*e);d[l]=Lk(o),d[l+1]=Lk(s),d[l+2]=Lk(h),d[l+3]=255}return d}var Nk=Object.defineProperty,$k=(t,e,n)=>((t,e,n)=>e in t?Nk(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n)(t,"symbol"!=typeof e?e+"":e,n);class jk{constructor(t,e){$k(this,"size"),$k(this,"smallerSize"),this.size=t||32,this.smallerSize=e||8}distance(t,e){if(t.length!==e.length)throw new Error(`Can't compare hashes of different lengths (${t.length} and ${e.length}). Both hashes must be made with the same size and smallerSize options (and, for hash(), the same base).`);let n=0;for(let i=0;i<t.length;i++)t[i]!==e[i]&&n++;return n/t.length}getHash(t){t=function(t,e){const n=t.bitmap.data;for(let t=0;t<n.length;t+=4){const i=n[t+3];if(255===i)continue;const r=i/255;n[t]=Math.round(e+(n[t]-e)*r),n[t+1]=Math.round(e+(n[t+1]-e)*r),n[t+2]=Math.round(e+(n[t+2]-e)*r),n[t+3]=255}return t}(sc(t),Hk),t=Tp.resize(t,{w:this.size,h:this.size});const e=[];for(let n=0;n<t.bitmap.width;n++){const i=[];for(let e=0;e<t.bitmap.height;e++)i[e]=Gk(t,n,e);e[n]=i}const n=function(t,e,n){const i=e,r=[],a=[];for(let t=0;t<n;t++){const e=[];for(let n=0;n<i;n++)e[n]=Math.cos((2*n+1)/(2*i)*t*Math.PI);a[t]=e}for(let e=0;e<n;e++){const o=[];for(let r=0;r<n;r++){let n=0;for(let o=0;o<i;o++)for(let s=0;s<i;s++)n+=a[e][o]*a[r][s]*t[o][s];n*=2/i*Zk(e)*Zk(r),o[r]=n}r[e]=o}return r}(e,this.size,this.smallerSize);let i=0;for(let t=0;t<this.smallerSize;t++)for(let e=0;e<this.smallerSize;e++)0===t&&0===e||(i+=n[t][e]);const r=i/(this.smallerSize*this.smallerSize-1);let a="";for(let t=0;t<this.smallerSize;t++)for(let e=0;e<this.smallerSize;e++)a+=n[t][e]>r?"1":"0";return a}}function Gk(t,e,n){const{data:i}=t.bitmap,r=t.getPixelIndex(e,n);return Math.floor(.2126*i[r]+.7152*i[r+1]+.0722*i[r+2])}const Hk=128;function Zk(t){return 0===t?1/Math.sqrt(2):1}const qk="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_";const Wk=function(){const t=[NaN,NaN];for(let e=2;e<65;e++){const n=Bk(Bk.BIN,qk.slice(0,e))(new Array(65).join("1"));t.push(n.length)}return t}();function Vk(t,e){return 64===e?Wk[t]:Bk(Bk.BIN,qk.slice(0,t))("1".repeat(e)).length}const Jk=Ah({size:uh().int().min(2).max(256).optional(),smallerSize:uh().int().min(2).max(64).optional()}).refine(({size:t=32,smallerSize:e=8})=>e<=t,{message:"smallerSize must not be larger than size"});function Yk(t={}){const{size:e,smallerSize:n}=Jk.parse(t);return new jk(e,n)}const Xk=Ah({componentsX:uh().int().min(1).max(9).optional(),componentsY:uh().int().min(1).max(9).optional()}),Kk=Ah({w:uh().int().min(1),h:uh().int().min(1),punch:uh().min(0).optional()});const Qk={pHash:(t,e)=>Yk(e).getHash(t),hash(t,e=64,n){if(e<2||e>64)throw new Error("base must be a number between 2 and 64");const i=qk.slice(0,e),r=this.pHash(t,n),a=Vk(e,r.length);return Bk(Bk.BIN,i)(r).padStart(a,"0")},distanceFromHash(t,e,n){const i=Yk(n),r=i.getHash(t);return i.distance(r,e)},blurhash(t,e={}){const{componentsX:n=4,componentsY:i=3}=Xk.parse(e),{data:r,width:a,height:o}=function(t){let{bitmap:e}=t;if(Math.max(e.width,e.height)>64){const t={bitmap:{...e}};Tp.resize(t,e.width>=e.height?{w:64}:{h:64}),e=t.bitmap}const n=Uint8Array.from(e.data),i=lc(t.background),r=i.a/255;for(let t=0;t<n.length;t+=4){const e=n[t+3]/255;if(1===e)continue;const a=r+e-r*e,o=(t,n)=>0===a?0:Math.round((t*e+n*r*(1-e))/a);n[t]=o(n[t],i.r),n[t+1]=o(n[t+1],i.g),n[t+2]=o(n[t+2],i.b),n[t+3]=255}return un(sn(t),Ye)?.(n),{data:n,width:e.width,height:e.height}}(t);return function(t,e,n,i,r){const a=Ok(),o=Fk(i,e,!0),s=Fk(r,n,!0),h=i*r,c=new Float64Array(3*h);for(let h=0;h<e;h++)for(let l=0;l<n;l++){const f=4*(h+l*e),u=a[t[f]],d=a[t[f+1]],p=a[t[f+2]];for(let t=0;t<r;t++){const r=s[t*n+l];for(let n=0;n<i;n++){const a=(0===n&&0===t?1:2)*o[n*e+h]*r,s=3*(n+t*i);c[s]=c[s]+a*u,c[s+1]=c[s+1]+a*d,c[s+2]=c[s+2]+a*p}}}const l=1/(e*n);for(let t=0;t<c.length;t++)c[t]=c[t]*l;let f=Pk(i-1+9*(r-1),1),u=1;if(h>1){let t=-1/0;for(let e=3;e<c.length;e++)t=Math.max(t,c[e]);const e=Math.floor(Math.max(0,Math.min(82,Math.floor(166*t-.5))));u=(e+1)/166,f+=Pk(e,1)}else f+=Pk(0,1);f+=Pk((Lk(c[0])<<16)+(Lk(c[1])<<8)+Lk(c[2]),4);const d=t=>Math.floor(Math.max(0,Math.min(18,Math.floor(9*Rk(t/u,.5)+9.5))));for(let t=3;t<c.length;t+=3)f+=Pk(19*d(c[t])*19+19*d(c[t+1])+d(c[t+2]),2);return f}(r,a,o,n,i)}};function tA(t,e){const{w:n,h:i,punch:r=1}=Kk.parse(e);return{data:Dk(t,n,i,r),width:n,height:i}}function eA(t,e,n){const i=Yk(n),r=i.getHash(t),a=i.getHash(e);return i.distance(r,a)}function nA(t,e){const n=qk.slice(0,e);if(2===e)return t;if([...t].every(t=>n.includes(t)))for(let i=2;i<=64;i++){const r=i*i,a=Vk(e,r);if(a===t.length)return Bk(n,Bk.BIN)(t).padStart(r,"0");if(a>t.length)break}throw new Error(`"${t}" isn't a base ${e} hash. Pass the base the hashes were made with to compareHashes, e.g. compareHashes(hash1, hash2, 16).`)}function iA(t,e,n){const i=new jk;if(t.length!==e.length)return i.distance(t,e);const r=/^[01]*$/.test(t)&&/^[01]*$/.test(e),a=n??(r?2:64);if(a<2||a>64)throw new Error("base must be a number between 2 and 64");return i.distance(nA(t,a),nA(e,a))}const rA=/^[-+]?(\d+\.?\d*|\.\d+)([eE][-+]?\d+)?$/;function aA(t,e){return new Error(`Invalid .cube LUT, line ${t}: ${e}`)}function oA(t,e,n,i){if(t.length!==e)throw aA(n,`${i} needs ${e} number${1===e?"":"s"}, got ${t.length}`);return t.map(t=>{if(!rA.test(t))throw aA(n,`"${t}" isn't a number`);return Number(t)})}function sA(t){if("string"!=typeof t)throw new Error("parseCubeLut needs the text of a .cube file");const e=t.replace(/^\uFEFF/,"").split(/\r\n|\r|\n/);let n,i,r,a=[0,0,0],o=[1,1,1],s=0;for(let t=0;t<e.length;t++){const h=t+1,c=e[t].trim();if(""===c||c.startsWith("#"))continue;if(/^[A-Za-z]/.test(c)){if(r)throw aA(h,"keywords must come before the LUT data, found more after it");const[t,...e]=c.split(/\s+/);switch(t){case"TITLE":{const t=/^TITLE\s+"(.*)"\s*$/.exec(c);if(!t)throw aA(h,'TITLE must be in quotes, like TITLE "Film"');n=t[1];break}case"LUT_1D_SIZE":case"LUT_1D_INPUT_RANGE":throw aA(h,`${t} is for 1D LUTs, which aren't supported. Only 3D LUTs (LUT_3D_SIZE) can be applied.`);case"LUT_3D_SIZE":{if(void 0!==i)throw aA(h,"LUT_3D_SIZE is given more than once");const[n]=oA(e,1,h,t);if(!Number.isInteger(n)||n<2||n>256)throw aA(h,`LUT_3D_SIZE must be a whole number from 2 to 256, got ${e[0]}`);i=n;break}case"DOMAIN_MIN":a=oA(e,3,h,t);break;case"DOMAIN_MAX":o=oA(e,3,h,t);break;case"LUT_3D_INPUT_RANGE":{const[n,i]=oA(e,2,h,t);a=[n,n,n],o=[i,i,i];break}}continue}if(void 0===i)throw aA(h,"LUT_3D_SIZE must come before the LUT data");if(r??(r=new Float32Array(i**3*3)),s===i**3)throw aA(h,`too many data lines: LUT_3D_SIZE ${i} needs ${i**3}`);const l=oA(c.split(/\s+/),3,h,"A data line");r[3*s]=l[0],r[3*s+1]=l[1],r[3*s+2]=l[2],s++}if(void 0===i)throw new Error("Invalid .cube LUT: it has no LUT_3D_SIZE");if(s!==i**3)throw new Error(`Invalid .cube LUT: LUT_3D_SIZE ${i} needs ${i**3} data lines, found ${s}`);for(let t=0;t<3;t++)if(!(a[t]<o[t]))throw new Error(`Invalid .cube LUT: DOMAIN_MIN must be less than DOMAIN_MAX in each channel, got ${a.join(" ")} and ${o.join(" ")}`);return{...void 0===n?{}:{title:n},size:i,domainMin:a,domainMax:o,data:r}}const hA=Ph([uh(),uh(),uh()]),cA=Ah({title:Ns().optional(),size:uh().int().min(2).max(256),domainMin:hA.optional(),domainMax:hA.optional(),data:(lA=t=>t instanceof Float32Array||t instanceof Float64Array||Array.isArray(t),fA="data must be a Float32Array, a Float64Array or an array of numbers",function(t,e,n){const i=Fn(n);return i.abort??(i.abort=!0),new t({type:"custom",check:"custom",fn:e,...i})}(Kh,lA??(()=>!0),fA))}).superRefine((t,e)=>{t.data.length!==t.size**3*3&&e.addIssue({code:"custom",path:["data"],message:`data must have size³ × 3 = ${t.size**3*3} numbers, got ${t.data.length}`});const n=t.domainMin??[0,0,0],i=t.domainMax??[1,1,1];n.some((t,e)=>!(t<i[e]))&&e.addIssue({code:"custom",path:["domainMax"],message:"domainMin must be less than domainMax in each channel"})});var lA,fA;function uA(t,e,n){const i=new Int32Array(256),r=new Float32Array(256);for(let a=0;a<256;a++){const o=Math.min(1,Math.max(0,(a/255-e)/(n-e)))*(t-1),s=Math.min(Math.floor(o),t-2);i[a]=s,r[a]=o-s}return{index:i,fraction:r}}const dA=Ah({strength:uh().optional()});const pA={colorGrade(t,e,n={}){const{strength:i=1}=dA.parse(n),r=Math.min(1,Math.max(0,i));let a;if("object"==typeof e&&null!==e&&"bitmap"in e)a=function(t){const{width:e,height:n,data:i}=t.bitmap,r=Math.round(Math.cbrt(e));if(e!==n||r**3!==e||r<2)throw new Error(`A Hald CLUT image must be square, with a side of level³ pixels, like 512 × 512 for level 8. This one is ${e} × ${n}.`);return{size:r*r,data:i,channels:4,scale:1/255,domainMin:[0,0,0],domainMax:[1,1,1]}}(zb.parse(e)),a.data===t.bitmap.data&&(a.data=Uint8Array.from(t.bitmap.data));else{const t=cA.parse(e);a={size:t.size,data:t.data,channels:3,scale:1,domainMin:t.domainMin??[0,0,0],domainMax:t.domainMax??[1,1,1]}}return r>0&&function(t,e,n){const{size:i,data:r,channels:a,scale:o}=e,s=uA(i,e.domainMin[0],e.domainMax[0]),h=uA(i,e.domainMin[1],e.domainMax[1]),c=uA(i,e.domainMin[2],e.domainMax[2]),l=a,f=a*i,u=a*i*i,d=t.bitmap.data,p=255*o;for(let t=0;t<d.length;t+=4){const e=d[t],i=d[t+1],a=d[t+2],o=s.fraction[e],m=h.fraction[i],g=c.fraction[a],b=s.index[e]*l+h.index[i]*f+c.index[a]*u;let w=g,y=m,_=o,v=u,x=f;o>=m?m>=g?(w=o,v=l,y=m,x=f,_=g):o>=g?(w=o,v=l,y=g,x=u,_=m):(w=g,v=u,y=o,x=l,_=m):o>=g?(w=m,v=f,y=o,x=l,_=g):m>=g&&(w=m,v=f,y=g,x=u,_=o);const k=b+v,A=k+x,M=b+l+f+u,E=1-w,I=w-y,S=y-_;for(let e=0;e<3;e++){const i=(r[b+e]*E+r[k+e]*I+r[A+e]*S+r[M+e]*_)*p,a=d[t+e],o=a+(i-a)*n;d[t+e]=o<=0?0:o>=255?255:Math.round(o)}}}(t,a,r),t}},mA=Ah({src:zb,x:uh().optional(),y:uh().optional()}),gA=Ih([zb,mA]),bA=Array.from({length:256},(t,e)=>{const n=e/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4});function wA(t,e,n){return t===e&&e===n?t:function(t){const e=t<=.0031308?12.92*t:1.055*t**(1/2.4)-.055;return Math.min(255,Math.max(0,Math.round(255*e)))}(.2224879*bA[t]+.7169038*bA[e]+.0606083*bA[n])}const yA={mask(t,e){let n,i,r;gA.parse(e),"bitmap"in e?(n=e,i=0,r=0):(n=e.src,i=e.x??0,r=e.y??0),i=Math.round(i),r=Math.round(r);const a=t.bitmap.width,o=t.bitmap.height,s=Math.max(0,-i),h=Math.max(0,-r),c=Math.min(n.bitmap.width,a-i),l=Math.min(n.bitmap.height,o-r),{data:f}=n.bitmap;for(let e=h;e<l;e++)for(let a=s;a<c;a++){const o=n.getPixelIndex(a,e),s=t.getPixelIndex(i+a,r+e),h=wA(f[o],f[o+1],f[o+2]),c=t.bitmap.data[s+3];t.bitmap.data[s+3]=Math.round(c*h*f[o+3]/65025)}return t}},_A=Ah({radius:uh(),shape:Uh(["square","disk"]).optional()});function vA(t,e,n,i,r,a,o){for(let s=0;s<o;s++){const o=n[i+s],h=r[a+s];t[e+s]=o>h?o:h}}function xA(t,e,n,i,r,a,o,s){const h=2*a+1;for(let e=0,a=0;e<i;e++,a+=r){const i=e%h===0;for(let e=a;e<a+r;e++){const a=t[n+e],s=i?0:o[e-r];o[e]=a>s?a:s}}for(let e=i-1,a=e*r;e>=0;e--,a-=r){const o=e===i-1||(e+1)%h===0;for(let e=a;e<a+r;e++){const i=t[n+e],a=o?0:s[e+r];s[e]=i>a?i:a}}for(let t=0,c=0;t<i;t++,c+=r){const l=Math.max(0,t-a),f=Math.min(i-1,t+a),u=l-l%h!==f-f%h,d=u||l%h!==0,p=u||l%h===0,m=l*r-c,g=f*r-c;for(let t=c;t<c+r;t++){const i=d?s[t+m]:0,r=p?o[t+g]:0;e[n+t]=i>r?i:r}}}function kA(t,e,n,i){const r=4*e,a=new Uint8Array(r),o=new Uint8Array(r);for(let s=0;s<n;s++)xA(t,t,s*r,e,4,i,a,o)}function AA(t){for(let e=0;e<t.length;e++)t[e]=255-t[e]}function MA(t,e,n){const{radius:i,shape:r="square"}=_A.parse(e),{data:a,width:o,height:s}=t.bitmap,h=Math.min(Math.max(0,Math.round(i)),o+s);return 0===h||(n&&AA(a),"disk"===r?function(t,e,n,i){const r=4*e,a=new Uint8Array(t.length),o=new Uint8Array(t.length);let s=-1;for(let h=0;h<=Math.min(i,n-1);h++){const c=Math.floor(Math.sqrt(i*i-h*h));c!==s&&(o.set(t),kA(o,e,n,c),s=c);for(let t=0;t<n;t++){const e=t*r;t-h>=0&&vA(a,e,a,e,o,(t-h)*r,r),h>0&&t+h<n&&vA(a,e,a,e,o,(t+h)*r,r)}}t.set(a)}(a,o,s,h):function(t,e,n,i){kA(t,e,n,i),xA(t,t,0,n,4*e,i,new Uint8Array(t.length),new Uint8Array(t.length))}(a,o,s,h),n&&AA(a)),t}const EA={erode:(t,e)=>MA(t,e,!0),dilate:(t,e)=>MA(t,e,!1),open:(t,e)=>(MA(t,e,!0),MA(t,e,!1)),close:(t,e)=>(MA(t,e,!1),MA(t,e,!0))},IA=/\r\n?|\n/;function SA(t,e,{size:n,letterSpacing:i=0}){const{opentype:r}=t,a=n/r.unitsPerEm,o=r.stringToGlyphs(e,0===i?void 0:{features:{rlig:!0}}),s=[];let h=0;for(let e=0;e<o.length;e++){const n=o[e],r=o[e+1];s.push(h),h+=(n.advanceWidth??0)*a,r&&(h+=t.kerning(n.index,r.index)*a+i)}return{glyphs:o,positions:s,width:h}}const zA=Ah({size:uh().min(0),lineHeight:uh().min(0).optional(),letterSpacing:uh().optional()}),BA=zA.extend({color:Nx.optional(),stroke:Nx.optional(),strokeWidth:uh().min(0).optional()});function CA(t){return"object"==typeof t&&null!==t&&"opentype"in t&&"kerning"in t&&"function"==typeof t.kerning}function PA(t,e,n,i){const r=zA.parse(i),a=r.lineHeight??function(t,e){const{ascender:n,descender:i,tables:r,unitsPerEm:a}=t.opentype;return(n-i+(r.hhea?.lineGap??0))*e/a}(t,r.size),o=function(t,e,n,i){const r=e=>SA(t,e,i).width;return e.split(IA).flatMap(t=>function(t,e,n){if(n===1/0)return[e];const i=e=>t(e)<=n+1e-6,r=e.split(" "),a=[];let o=[],s=!1;const h=()=>{for(;o.length>0&&""===o[o.length-1];)o.pop();o.length>0&&a.push(o.join(" ")),o=[],s=!0};for(const t of r){if(""===t&&s&&0===o.length)continue;if(i([...o,t].join(" "))){o.push(t);continue}if(""===t||i(t)){h(),""!==t&&o.push(t);continue}let e=o.length>0?`${o.join(" ")} `:"";for(const n of t)""===e||i(e+n)?e+=n:(o=[e.replace(/ +$/,"")],h(),e=n);o=[e]}return(o.length>0||0===a.length)&&a.push(o.join(" ")),a}(r,t,n))}(t,e,n,r).map(e=>SA(t,e,r));return{lines:o,lineHeight:a,width:o.reduce((t,e)=>Math.max(t,e.width),0),height:o.length*a}}const TA=/\r\n?|\n/;function UA(t){const e=t.slice(-2);return 2===e.length&&e.codePointAt(0)>65535?e:t.slice(-1)||void 0}function OA(t,e){return t.chars[e]?e:!/\s/.test(e)&&t.chars["?"]?"?":void 0}function LA(t,e,n){const i=e&&OA(t,e),r=n&&(OA(t,n)??n);return i&&r&&t.kernings[i]?.[r]||0}function RA(t,e){const n=Array.from(e);let i=0;for(let e=0;e<n.length;e++){const r=OA(t,n[e]);r&&(i+=(t.chars[r].xadvance||0)+LA(t,r,n[e+1]))}return i}function FA(t,e,n){return CA(t)?PA(t,e,1/0,n).width:e.split(TA).reduce((e,n)=>Math.max(e,RA(t,n)),0)}function DA(t,e,n,i){const[r]=i;return e+LA(t,n,r)+RA(t,i)}function NA(t,e,n){const i=e.split(TA).flatMap(e=>function(t,e,n){const i=e.split(" "),r=[];let a,o=[],s=0;i.forEach(e=>{const i=RA(t,e);if(i>n){const i=e[Symbol.iterator]();let h,c="",l=0;o.length>0&&(l=DA(t,s,a," "),h=" ");for(const e of i){const i=DA(t,l,h,e);i<n?(c+=e,l=i,h=e):i>n?(r.push([...o,c]),o=[],c=e,l=RA(t,e),h=e):(r.push([...o,c+e]),o=[],c="",l=0,h=void 0)}return void(c?(o.push(c),s=l,a=h):0===o.length&&(s=0,a=void 0))}const h=o.length>0?` ${e}`:e,c=DA(t,s,a,h);c<=n?(o.push(e),s=c,a=UA(h)):($A(o)||r.push(o),o=[e],s=i,a=UA(e))}),0!==r.length&&$A(o)||r.push(o);return r}(t,e,n)),r=i.reduce((e,n)=>Math.max(e,RA(t,n.join(" "))),0);return{lines:i,longestLine:r}}function $A(t){return t.every(t=>""===t)}function jA(t,e,n=1/0,i){if(CA(t))return PA(t,e,n,i).height;const{lines:r}=NA(t,e,n);return r.length*t.common.lineHeight}const GA=Ah({x:uh(),y:uh(),text:Ih([Ih([Ns(),uh()]),Ah({text:Ih([Ns(),uh()]),alignmentX:Oh(ey).optional(),alignmentY:Oh(iy).optional()})]),maxWidth:uh().optional(),maxHeight:uh().optional(),cb:(HA={input:Ph([Ah({x:uh(),y:uh()})])},new Xh({type:"function",input:Array.isArray(HA?.input)?Ph(HA?.input):HA?.input??xh(wh()),output:HA?.output??wh()})).optional()});var HA;const ZA=Object.keys(BA.shape);function qA(t,e,n,i,r){if(r.width>0&&r.height>0){const a=e.pages[r.page];a&&(t=Pb.blit(t,{src:a,x:n+r.xoffset,y:i+r.yoffset,srcX:r.x,srcY:r.y,srcW:r.width,srcH:r.height}))}return t}const WA={print(t,e){const{font:n,...i}=e;let r,a,{x:o,y:s,text:h,maxWidth:c=1/0,maxHeight:l=1/0,cb:f=()=>{}}=GA.parse(i);"object"==typeof h&&null!==h.text&&void 0!==h.text?(r=h.alignmentX||ey.LEFT,a=h.alignmentY||iy.TOP,({text:h}=h)):(r=ey.LEFT,a=iy.TOP,h=h.toString()),"number"==typeof h&&(h=h.toString());const u=c===1/0?Math.max(0,t.bitmap.width-o):c,d=l===1/0?Math.max(0,t.bitmap.height-s):l;if(CA(n)){const e=function(t,e,n,i){const{size:r,color:a,stroke:o,strokeWidth:s}=BA.parse(i),{x:h,boxWidth:c,boxHeight:l,alignmentX:f,alignmentY:u}=n;let{y:d}=n;const{lines:p,lineHeight:m,width:g,height:b}=PA(e,n.text,n.maxWidth,i);u===iy.BOTTOM?d+=l-b:u===iy.MIDDLE&&(d+=(l-b)/2);const{ascender:w,descender:y,unitsPerEm:_}=e.opentype,v=r/_,x=(m-(w-y)*v)/2+w*v,k=[];return p.forEach((t,e)=>{let n=h;f===ey.CENTER?n+=(c-t.width)/2:f===ey.RIGHT&&(n+=c-t.width);const i=Math.round(d+e*m+x);t.glyphs.forEach((e,r)=>{const{commands:a}=e.path;a.length>0&&k.push(...Fx(a,{transform:[v,0,0,-v,n+t.positions[r],i]}))})}),_k(t,k,{fill:a,stroke:o,strokeWidth:s,join:"round"}),{x:h+g,y:d+b}}(t,n,{x:o,y:s,text:h,maxWidth:c,boxWidth:u,boxHeight:d,alignmentX:r,alignmentY:a},i);return f.bind(t)(e),t}const p=ZA.filter(t=>void 0!==i[t]);if(p.length>0)throw new Error(`print: ${p.join(", ")} can only be used with fonts loaded with loadTTF. Bitmap fonts from loadFont are drawn at the size and in the color they were made with.`);a===iy.BOTTOM?s+=d-jA(n,h,c):a===iy.MIDDLE&&(s+=d/2-jA(n,h,c)/2);const m=Object.entries(n.chars).find(t=>t[1].xadvance)?.[1].xadvance;if("number"!=typeof m)throw new Error("Could not find default character width");const{lines:g,longestLine:b}=NA(n,h,c);return g.forEach(e=>{const i=e.join(" "),a=function(t,e,n,i){return i===ey.LEFT?0:i===ey.CENTER?(n-FA(t,e))/2:n-FA(t,e)}(n,i,u,r);!function(t,e,n,i,r,a){const o=Array.from(r);for(let r=0;r<o.length;r++){const s=OA(e,o[r]),h=s?e.chars[s]:void 0;h&&qA(t,e,n,i,h),n+=LA(e,s,o[r+1])+(h?.xadvance||a)}}(t,n,o+a,s,i,m),s+=n.common.lineHeight}),f.bind(t)({x:o+b,y:s}),t}};function VA(t){return 0===t?1:(t*=Math.PI,Math.sin(t)/t)}function JA(t){return{support:t,weight:e=>e>-t&&e<t?VA(e)*VA(e/t):0}}function YA(t){return{support:2,weight:e=>(e=Math.abs(e))<1?(t+2)*e*e*e-(t+3)*e*e+1:e<2?t*e*e*e-5*t*e*e+8*t*e-4*t:0}}const XA={[ip.BILINEAR]:{support:1,weight:t=>Math.max(0,1-Math.abs(t))},[ip.BICUBIC]:YA(-1),[ip.HERMITE]:YA(-.5),[ip.BEZIER]:{support:2,weight(t){if((t=Math.abs(t))<1){const e=1-t;return e*e*e+3*e*e*t+.75*e*t*t}if(t<2){const e=t-1;return-.75*e*(1-e)*(1-e)}return 0}},[ip.LANCZOS]:JA(3),[ip.LANCZOS2]:JA(2),[ip.MITCHELL]:{support:2,weight(t){const e=1/3;return(t=Math.abs(t))<1?(7*t*t*t+-12*t*t+(6-2*e))/6:t<2?((-e-2)*t*t*t+12*t*t+-20*t+(8*e+8))/6:0}}};function KA(t,e){const n=Math.round(t);return Math.abs(t-n)<e?n:t}function QA(t){const e=sc(t);t.scan((e,n,i)=>{t.bitmap.data.writeUInt32BE(t.background,i)}),Dy(t,e)}function tM(t,e){const n=t.bitmap.data,i=t.bitmap.width,r=t.bitmap.height,a=e&&e!==ip.NEAREST_NEIGHBOR?XA[e]:void 0,o=255&t.background,s=[(t.background>>>24&255)*o/255,(t.background>>>16&255)*o/255,(t.background>>>8&255)*o/255,o];return(e,o,h,c)=>{if(a){const l=function(t,e,n,i,r,a,o,s,h){const c=i-.5,l=r-.5,f=Math.ceil(c-a.support),u=Math.floor(c+a.support),d=Math.ceil(l-a.support),p=Math.floor(l+a.support);if(u<0||p<0||f>=e||d>=n)return!1;let m=0,g=0,b=0,w=0,y=0;for(let i=d;i<=p;i++){const r=a.weight(l-i);if(0!==r)for(let s=f;s<=u;s++){const h=r*a.weight(c-s);if(0===h)continue;if(y+=h,s<0||i<0||s>=e||i>=n){m+=h*o[0],g+=h*o[1],b+=h*o[2],w+=h*o[3];continue}const l=e*i+s<<2,f=t[l+3],u=h*f/255;m+=u*t[l],g+=u*t[l+1],b+=u*t[l+2],w+=h*f}}const _=Math.min(255,Math.max(0,Math.round(w/y))),v=_?1/w:0;return s[h]=Math.min(255,Math.max(0,Math.round(m*v*255))),s[h+1]=Math.min(255,Math.max(0,Math.round(g*v*255))),s[h+2]=Math.min(255,Math.max(0,Math.round(b*v*255))),s[h+3]=_,!0}(n,i,r,e,o,a,s,h,c);l||h.writeUInt32BE(t.background,c)}else if(e>=0&&e<i&&o>=0&&o<r){const t=i*(0|o)+(0|e)<<2;h.writeUInt32BE(n.readUInt32BE(t),c)}else h.writeUInt32BE(t.background,c)}}const eM=Ah({matrix:Ph([uh(),uh(),uh(),uh(),uh(),uh()]).readonly().refine(t=>!function([t,e,n,i]){const r=t*i,a=e*n;return Math.abs(r-a)<=8*Math.max(Math.abs(r),Math.abs(a))*Number.EPSILON}(t),{message:"The matrix can't be inverted (a * d - b * c is 0), so it would flatten the image into a line or a point"}),mode:Oh(ip).optional(),fit:gh().optional()}),nM=uh().refine(t=>Math.abs(Math.cos(t*Math.PI/180))>1e-10,{message:"Skew angles can't be 90 degrees (or 90 plus a multiple of 180), it would make the image infinitely long"}),iM=Ah({x:nM.optional(),y:nM.optional(),mode:eM.shape.mode,fit:eM.shape.fit});function rM(t,e){const{matrix:i,mode:r,fit:a=!0}=eM.parse(e),[o,s,h,c,l,f]=i;if(1===o&&0===s&&0===h&&1===c&&(a||!l&&!f))return t;const u=t.bitmap.width,d=t.bitmap.height,p=o*c-s*h,m=c/p,g=-s/p,b=-h/p,w=o/p,y=(u+d+Math.abs(l)+Math.abs(f))*Math.max(1,...[o,s,h,c,m,g,b,w].map(Math.abs))*Number.EPSILON*8,_=(t,e,n=0,i=0)=>{const r=.5-t/2+n-l,a=.5-e/2+i-f;return[m*r+b*a+u/2,g*r+w*a+d/2]},v=t=>{const e=KA(t,y);return Math.abs(e-Math.round(e))};let x=u,k=d,[A,M]=_(x,k);if(a){const e=Math.max(1,Math.ceil(Math.abs(o)*u+Math.abs(h)*d-y)),n=Math.max(1,Math.ceil(Math.abs(s)*u+Math.abs(c)*d-y));let i=-1;for(const[t,r]of[[e,n],[e+1,n],[e,n+1],[e+1,n+1]]){const[e,n]=_(t,r,l,f);let a=1/0;for(let i=(r>>1)-2;i<=2+(r>>1);i++)for(let r=(t>>1)-2;r<=2+(t>>1);r++)a=Math.min(a,v(e+m*r+b*i),v(n+g*r+w*i));a>i+y&&(i=a,x=t,k=r,A=e,M=n)}QA(t)}const E=[m,g,b,w].every(t=>{const e=KA(t,y);return e%1==0&&Math.abs(e)<=1})&&.5===v(A)&&.5===v(M),I=n.Buffer.alloc(x*k*4),S=tM(t,E?void 0:r);for(let t=0;t<k;t++)for(let e=0;e<x;e++){S(KA(A+m*e+b*t,y),KA(M+g*e+w*t,y),I,x*t+e<<2)}return t.bitmap.data=I,t.bitmap.width=x,t.bitmap.height=k,t}function aM(t){return KA(Math.tan(t*Math.PI/180),4*Number.EPSILON)}const oM=Ih([uh(),Ah({deg:uh(),mode:Ih([gh(),Oh(ip)]).optional()})]);function sM(t){return function(e,n){return n*t+e<<2}}function hM(t,e,n){const i=Math.ceil(t-n);return(i-e)%2==0?i:i+1}const cM={rotate(t,e){const i=oM.parse(e),r="number"==typeof i?{deg:i}:i,{mode:a=!0}=r;let{deg:o}=r;if(o%=360,o%360==0)return t;return o%90==0&&(a||t.bitmap.width===t.bitmap.height||o%180==0)?function(t,e){if(Math.abs(e)%90!=0)throw new Error("Unsupported matrix rotation degree");const i=t.bitmap.width,r=t.bitmap.height;let a;switch(e){case 90:case-270:a=90;break;case 180:case-180:a=180;break;case 270:case-90:a=-90;break;default:throw new Error("Unsupported matrix rotation degree")}const o=180===a?i:r,s=180===a?r:i,h=n.Buffer.alloc(t.bitmap.data.length),c=sM(i),l=sM(o);for(let e=0;e<i;e++)for(let n=0;n<r;n++){const o=c(e,n),s=t.bitmap.data.readUInt32BE(o);let f;switch(a){case 90:f=l(n,i-e-1);break;case-90:f=l(r-n-1,e);break;case 180:f=l(i-e-1,r-n-1);break;default:throw new Error("Unsupported matrix rotation angle")}h.writeUInt32BE(s,f)}t.bitmap.data=h,t.bitmap.width=o,t.bitmap.height=s}(t,o):function(t,e,i){const r=e*Math.PI/180,a=Math.cos(r),o=Math.sin(r),s=t.bitmap.width,h=t.bitmap.height,c=(s+h)*Number.EPSILON*4;let l=s,f=h;if(!0===i||"string"==typeof i){const e=Math.abs(a)>=Math.abs(o);l=hM(Math.abs(s*a)+Math.abs(h*o),e?s:h,c),f=hM(Math.abs(s*o)+Math.abs(h*a),e?h:s,c),QA(t)}const u=n.Buffer.alloc(l*f*4),d=tM(t,"string"==typeof i?i:void 0);for(let t=0;t<f;t++)for(let e=0;e<l;e++){const n=e+.5-l/2,i=t+.5-f/2;d(KA(a*n-o*i+s/2,c),KA(a*i+o*n+h/2,c),u,l*t+e<<2)}t.bitmap.data=u,t.bitmap.width=l,t.bitmap.height=f}(t,o,a),t},affine:(t,e)=>rM(t,e),skew:(t,e)=>function(t,e){const{x:n=0,y:i=0,mode:r,fit:a}=iM.parse(e);return rM(t,{matrix:[1,aM(i),aM(n),1,0,0],mode:r,fit:a})}(t,e)},lM=Ah({max:Ih([uh().min(0).max(255),Rh("otsu")]),replace:uh().min(0).max(255).optional(),autoGreyscale:gh().optional()}),fM=lM.pick({autoGreyscale:!0});function uM(t,e={}){const{autoGreyscale:n=!0}=fM.parse(e),{data:i}=t.bitmap,r=new Array(256).fill(0);t.scan((t,e,a)=>{const o=i[a+3];if(0===o)return;const s=n?Math.round(.2126*i[a]+.7152*i[a+1]+.0722*i[a+2]):i[a];r[dc(s)]+=o});let a=0,o=0;for(let t=0;t<256;t++)a+=r[t],o+=t*r[t];let s=0,h=0,c=0,l=255;for(let t=0;t<255;t++){s+=r[t],h+=t*r[t];const e=a-s;if(0===s||0===e)continue;const n=h/s-(o-h)/e,i=s*e*n*n;i>c&&(c=i,l=t+1)}return l}const dM={threshold(t,e){const n=lM.parse(e);let{replace:i=255}=n;const{autoGreyscale:r=!0}=n;i=dc(i),r&&Jw.greyscale(t);const a="otsu"===n.max?uM(t,{autoGreyscale:!1}):dc(n.max);return t.scan((e,n,r)=>{for(let e=r;e<r+3;e++)t.bitmap.data[e]>=a&&(t.bitmap.data[e]=i)}),t}},pM=Ah({colors:uh().min(1,"colors must be at least 1").optional(),colorDistanceFormula:Ih([Rh("cie94-textiles"),Rh("cie94-graphic-arts"),Rh("ciede2000"),Rh("color-metric"),Rh("euclidean"),Rh("euclidean-bt709-noalpha"),Rh("euclidean-bt709"),Rh("manhattan"),Rh("manhattan-bt709"),Rh("manhattan-nommyde"),Rh("pngquant")]).optional(),paletteQuantization:Ih([Rh("neuquant"),Rh("neuquant-float"),Rh("rgbquant"),Rh("wuquant")]).optional(),imageQuantization:Ih([Rh("nearest"),Rh("riemersma"),Rh("floyd-steinberg"),Rh("false-floyd-steinberg"),Rh("stucki"),Rh("atkinson"),Rh("jarvis"),Rh("burkes"),Rh("sierra"),Rh("two-sierra"),Rh("sierra-lite")]).optional()}).refine(t=>"rgbquant"!==t.paletteQuantization||void 0===t.colors||t.colors>=2,{message:"colors must be at least 2 for rgbquant",path:["colors"]}),mM=Ah({sampleSize:uh().min(1,"sampleSize must be at least 1").optional()}),gM=uh().int("count must be a whole number").min(1,"count must be at least 1").max(256,"count must be at most 256");function bM(t,e,{sampleSize:n=1e4}){const i=function(t,e){const{width:n,height:i,data:r}=t.bitmap,a=Math.max(1,Math.sqrt(n*i/e)),o=new Uint8Array(Math.ceil(n/a)*Math.ceil(i/a)*4);let s=0;for(let t=a/2;t<i;t+=a)for(let e=a/2;e<n;e+=a){const i=n*Math.floor(t)+Math.floor(e)<<2;r[i+3]>0&&(o[s++]=r[i],o[s++]=r[i+1],o[s++]=r[i+2],o[s++]=r[i+3])}return o.subarray(0,s)}(t,n);if(0===i.length)return[];const r=new gt.WuQuant(new Q.EuclideanBT709,e,4);r.sample(function(t){const e=e=>Math.ceil(t[e+3]/64);let n=0;for(let i=0;i<t.length;i+=4)n+=4*e(i);const i=new Uint8Array(n);let r=0;for(let n=0;n<t.length;n+=4)for(let a=e(n);a>0;a--)i[r++]=t[n],i[r++]=t[n+1],i[r++]=t[n+2],i[r++]=255;return xt.PointContainer.fromUint8Array(i,n/4,1)}(i));const a=r.quantizeSync().getPointContainer().getPointArray(),o=a.map(()=>[0,0,0,0]);for(let t=0;t<i.length;t+=4){const e=i[t],n=i[t+1],r=i[t+2],s=i[t+3]/255;let h=0,c=1/0;a.forEach((t,i)=>{const a=.2126*(e-t.r)**2+.7152*(n-t.g)**2+.0722*(r-t.b)**2;a<c&&(h=i,c=a)});const l=o[h];l[0]+=e*s,l[1]+=n*s,l[2]+=r*s,l[3]+=s}let s=0;const h=new Map;for(const[t,e,n,i]of o){if(0===i)continue;const r=(Math.round(t/i)<<24|Math.round(e/i)<<16|Math.round(n/i)<<8|255)>>>0;h.set(r,(h.get(r)??0)+i),s+=i}return[...h].map(([t,e])=>({color:t,weight:e/s})).sort((t,e)=>e.weight-t.weight)}const wM={quantize(t,e){const{colors:i,colorDistanceFormula:r,paletteQuantization:a,imageQuantization:o}=pM.parse(e),s=xt.PointContainer.fromUint8Array(new Uint8Array(t.bitmap.data),t.bitmap.width,t.bitmap.height),h=ae(s,re([s],{colors:i,colorDistanceFormula:r,paletteQuantization:a}),{colorDistanceFormula:r,imageQuantization:o});return t.bitmap.data=n.Buffer.from(h.toUint8Array()),t},palette:(t,e,n={})=>bM(t,gM.parse(e),mM.parse(n)),dominantColor:(t,e={})=>bM(t,5,mM.parse(e))[0]?.color};var yM=function(t){if(!t)throw new Error("no data provided");var e={pages:[],chars:[],kernings:[]},n=(t=t.toString().trim()).split(/\r\n?|\n/g);if(0===n.length)throw new Error("no data in BMFont file");for(var i=0;i<n.length;i++){var r=_M(n[i],i);if(r)if("page"===r.key){if("number"!=typeof r.data.id)throw new Error("malformed file at line "+i+" -- needs page id=N");if("string"!=typeof r.data.file)throw new Error("malformed file at line "+i+' -- needs page file="path"');e.pages[r.data.id]=r.data.file}else"chars"===r.key||"kernings"===r.key||("char"===r.key?e.chars.push(r.data):"kerning"===r.key?e.kernings.push(r.data):e[r.key]=r.data)}return e};function _M(t,e){if(!(t=t.replace(/\t+/g," ").trim()))return null;var n=t.indexOf(" ");if(-1===n)throw new Error("no named row at line "+e);var i=t.substring(0,n);t=(t=(t=(t=t.substring(n+1)).replace(/letter=[\'\"]\S+[\'\"]/gi,"")).split("=")).map(function(t){return t.trim().match(/(".*?"|[^"\s]+)+(?=\s*|\s*$)/g)});for(var r=[],a=0;a<t.length;a++){var o=t[a];0===a?r.push({key:o[0],data:""}):a===t.length-1?r[r.length-1].data=vM(o[0]):(r[r.length-1].data=vM(o[0]),r.push({key:o[1],data:""}))}var s={key:i,data:{}};return r.forEach(function(t){s.data[t.key]=t.data}),s}function vM(t){return t&&0!==t.length?0===t.indexOf('"')||0===t.indexOf("'")?t.substring(1,t.length-1):-1!==t.indexOf(",")?function(t){return t.split(",").map(function(t){return parseInt(t,10)})}(t):parseInt(t,10):""}var xM=e(yM),kM="chasrset";function AM(t){return t.split(",").map(function(t){return parseInt(t,10)})}var MM=void 0!==self.DOMParser?function(t){return(new self.DOMParser).parseFromString(t,"application/xml")}:void 0!==self.ActiveXObject&&new self.ActiveXObject("Microsoft.XMLDOM")?function(t){var e=new self.ActiveXObject("Microsoft.XMLDOM");return e.async="false",e.loadXML(t),e}:function(t){var e=document.createElement("div");return e.innerHTML=t,e},EM=function(t){for(var e in t=Object.assign({},t),kM in t&&(t.charset=t[kM],delete t[kM]),t)"face"!==e&&"charset"!==e&&(t[e]="padding"===e||"spacing"===e?AM(t[e]):parseInt(t[e],10));return t},IM=MM,SM={scaleh:"scaleH",scalew:"scaleW",stretchh:"stretchH",lineheight:"lineHeight",alphachnl:"alphaChnl",redchnl:"redChnl",greenchnl:"greenChnl",bluechnl:"blueChnl"},zM=function(t){t=t.toString();var e=IM(t),n={pages:[],chars:[],kernings:[]};["info","common"].forEach(function(t){var i=e.getElementsByTagName(t)[0];i&&(n[t]=EM(BM(i)))});var i=e.getElementsByTagName("pages")[0];if(!i)throw new Error("malformed file -- no <pages> element");for(var r=i.getElementsByTagName("page"),a=0;a<r.length;a++){var o=r[a],s=parseInt(o.getAttribute("id"),10),h=o.getAttribute("file");if(isNaN(s))throw new Error('malformed file -- page "id" attribute is NaN');if(!h)throw new Error('malformed file -- needs page "file" attribute');n.pages[parseInt(s,10)]=h}return["chars","kernings"].forEach(function(t){var i=e.getElementsByTagName(t)[0];if(i)for(var r=t.substring(0,t.length-1),a=i.getElementsByTagName(r),o=0;o<a.length;o++){var s=a[o];n[t].push(EM(BM(s)))}}),n};function BM(t){var e=function(t){for(var e=[],n=0;n<t.attributes.length;n++)e.push(t.attributes[n]);return e}(t);return e.reduce(function(t,e){var n;return t[n=e.nodeName,SM[n.toLowerCase()]||n]=e.nodeValue,t},{})}var CM=e(zM),PM=[66,77,70],TM=function(t){if(t.length<6)throw new Error("invalid buffer length for BMFont");var e=PM.every(function(e,n){return t.readUInt8(n)===e});if(!e)throw new Error("BMFont missing BMF byte header");var n=3;if(t.readUInt8(n++)>3)throw new Error("Only supports BMFont Binary v3 (BMFont App v1.10)");for(var i={kernings:[],chars:[]},r=0;r<5;r++)n+=UM(i,t,n);return i};function UM(t,e,n){if(n>e.length-1)return 0;var i=e.readUInt8(n++),r=e.readInt32LE(n);switch(n+=4,i){case 1:t.info=function(t,e){var n={};n.size=t.readInt16LE(e);var i=t.readUInt8(e+2);n.smooth=i>>7&1,n.unicode=i>>6&1,n.italic=i>>5&1,n.bold=i>>4&1,i>>3&1&&(n.fixedHeight=1);return n.charset=t.readUInt8(e+3)||"",n.stretchH=t.readUInt16LE(e+4),n.aa=t.readUInt8(e+6),n.padding=[t.readInt8(e+7),t.readInt8(e+8),t.readInt8(e+9),t.readInt8(e+10)],n.spacing=[t.readInt8(e+11),t.readInt8(e+12)],n.outline=t.readUInt8(e+13),n.face=function(t,e){return OM(t,e).toString("utf8")}(t,e+14),n}(e,n);break;case 2:t.common=function(t,e){var n={};return n.lineHeight=t.readUInt16LE(e),n.base=t.readUInt16LE(e+2),n.scaleW=t.readUInt16LE(e+4),n.scaleH=t.readUInt16LE(e+6),n.pages=t.readUInt16LE(e+8),t.readUInt8(e+10),n.packed=0,n.alphaChnl=t.readUInt8(e+11),n.redChnl=t.readUInt8(e+12),n.greenChnl=t.readUInt8(e+13),n.blueChnl=t.readUInt8(e+14),n}(e,n);break;case 3:t.pages=function(t,e,n){for(var i=[],r=OM(t,e),a=r.length+1,o=n/a,s=0;s<o;s++)i[s]=t.slice(e,e+r.length).toString("utf8"),e+=a;return i}(e,n,r);break;case 4:t.chars=function(t,e,n){for(var i=[],r=n/20,a=0;a<r;a++){var o={},s=20*a;o.id=t.readUInt32LE(e+0+s),o.x=t.readUInt16LE(e+4+s),o.y=t.readUInt16LE(e+6+s),o.width=t.readUInt16LE(e+8+s),o.height=t.readUInt16LE(e+10+s),o.xoffset=t.readInt16LE(e+12+s),o.yoffset=t.readInt16LE(e+14+s),o.xadvance=t.readInt16LE(e+16+s),o.page=t.readUInt8(e+18+s),o.chnl=t.readUInt8(e+19+s),i[a]=o}return i}(e,n,r);break;case 5:t.kernings=function(t,e,n){for(var i=[],r=n/10,a=0;a<r;a++){var o={},s=10*a;o.first=t.readUInt32LE(e+0+s),o.second=t.readUInt32LE(e+4+s),o.amount=t.readInt16LE(e+8+s),i[a]=o}return i}(e,n,r)}return 5+r}function OM(t,e){for(var n=e;n<t.length&&0!==t[n];n++);return t.slice(e,n)}var LM=e(TM);function RM(t,e){for(var n=0,i=t.length-1;i>=0;i--){var r=t[i];"."===r?t.splice(i,1):".."===r?(t.splice(i,1),n++):n&&(t.splice(i,1),n--)}if(e)for(;n--;n)t.unshift("..");return t}var FM=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,DM=function(t){return FM.exec(t).slice(1)};function NM(){for(var t="",e=!1,n=arguments.length-1;n>=-1&&!e;n--){var i=n>=0?arguments[n]:"/";if("string"!=typeof i)throw new TypeError("Arguments to path.resolve must be strings");i&&(t=i+"/"+t,e="/"===i.charAt(0))}return t=RM(HM(t.split("/"),function(t){return!!t}),!e).join("/"),(e?"/":"")+t||"."}function $M(t){var e=jM(t),n="/"===iE(t,-1);return t=RM(HM(t.split("/"),function(t){return!!t}),!e).join("/"),t||e||(t="."),t&&n&&(t+="/"),(e?"/":"")+t}function jM(t){return"/"===t.charAt(0)}var GM={extname:function(t){return DM(t)[3]},basename:function(t,e){var n=DM(t)[2];return e&&n.substr(-1*e.length)===e&&(n=n.substr(0,n.length-e.length)),n},dirname:function(t){var e=DM(t),n=e[0],i=e[1];return n||i?(i&&(i=i.substr(0,i.length-1)),n+i):"."},sep:"/",delimiter:":",relative:function(t,e){function n(t){for(var e=0;e<t.length&&""===t[e];e++);for(var n=t.length-1;n>=0&&""===t[n];n--);return e>n?[]:t.slice(e,n-e+1)}t=NM(t).substr(1),e=NM(e).substr(1);for(var i=n(t.split("/")),r=n(e.split("/")),a=Math.min(i.length,r.length),o=a,s=0;s<a;s++)if(i[s]!==r[s]){o=s;break}var h=[];for(s=o;s<i.length;s++)h.push("..");return(h=h.concat(r.slice(o))).join("/")},join:function(){return $M(HM(Array.prototype.slice.call(arguments,0),function(t,e){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))},isAbsolute:jM,normalize:$M,resolve:NM};function HM(t,e){if(t.filter)return t.filter(e);for(var n=[],i=0;i<t.length;i++)e(t[i],i,t)&&n.push(t[i]);return n}var ZM,qM,WM,VM,JM,YM,XM,KM,QM,tE,eE,nE,iE="b"==="ab".substr(-1)?function(t,e,n){return t.substr(e,n)}:function(t,e,n){return e<0&&(e=t.length+e),t.substr(e,n)};function rE(){return qM?ZM:(qM=1,ZM={BUILD:{COMPTIME:!0},NODE_TYPE:{ATTRIBUTE:"ATTRIBUTE",CONTENT:"CONTENT",ELEMENT:"ELEMENT",ROOT:"ROOT"},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"}})}function aE(){return YM?JM:(YM=1,JM={Token:(t,e)=>({type:t,value:e})})}function oE(){if(KM)return XM;KM=1;const{BUILD:t,TOKEN_TYPE:e}=rE(),{Token:n}=aE(),i=n("EOF"),r=t=>" "===t||"\n"===t||"\r"===t||"\t"===t,a=t=>t.replace(/'/g,"'");return XM={createLexer:function(t){let e=null,o=(t=>{let e=0;for(;e<t.length&&r(t[e]);)e++;return((t,e)=>{if(t.startsWith("<?xml",e)){const n=t.length;for(;e<n;)if("?"!==t[e])e++;else{if(">"===t[e+1])return e+2;e++}}return e})(t,e)})(t),s=[];const h=()=>t[o],c=()=>e!==i&&o<t.length,l=()=>{for(;c()&&r(t[o]);)o++},f=e=>{if(c()){if("<"===t[o]){let e="<";return o++,c()&&"/"===t[o]?(o++,e="</"):c()&&"!"===t[o]&&"-"===t[o+1]&&"-"===t[o+2]&&(o++,o++,o++,e="\x3c!--"),e}if("/"===h()){let t="/";return o++,c()&&">"===h()&&(o++,t="/>"),t}if("="===t[o]||">"===t[o]){const e=t[o];return o++,e}}return u(!!e)},u=e=>{const n=e?/[^>=<]/u:/[a-zA-Z0-9_:-]/;let i=o;for(;c()&&t[o].match(n);)o++;return a(t.substring(i,o))},d=()=>{const r=o;l();const p=o-r;if(c())if(e&&"OPEN_BRACKET"===e.type){l();const t=f(!1);e=n("ELEMENT_TYPE",t),s.push(t)}else if(e&&"ASSIGN"===e.type){c()&&(t=>'"'===t||"'"===t)(h())&&o++;const i=t[o-1];let r=o;for(;c()&&h()!==i;)o++;const s=a(t.substring(r,o));o++,e=n("ATTRIB_VALUE",s)}else{l();let i=f(!0);switch(i){case"=":e="ATTRIB_NAME"===e.type?n("ASSIGN"):n("CONTENT",i);break;case"</":{const i=o;for(;">"!==t[o];)o++;e=n("CLOSE_ELEMENT",t.substring(i,o)),o++,s.pop();break}case"/>":{const t=s.pop();e=n("CLOSE_ELEMENT",t);break}case"\x3c!--":{const e=["!","-","-"];for(;c()&&(">"!==e[2]||"-"!==e[1]||"-"!==e[0]);)e.shift(),e.push(t[o]),o++;return d()}case">":e=n("CLOSE_BRACKET");break;case"<":e=n("OPEN_BRACKET");break;default:if(i&&i.length>0){if("CLOSE_BRACKET"===e.type){let t="";"<"!==h()&&(t=u(!0)),e=n("CONTENT",i+t)}else if("ATTRIB_NAME"!==e.type&&"CONTENT"!==e.type)"CLOSE_ELEMENT"===e.type?(i=" ".repeat(p)+i,e=n("CONTENT",i)):e=n("ATTRIB_NAME",i);else{const t=" ".repeat(p)+i;e=n("CONTENT",t)}break}{const e='Unknown Syntax : "'+t[o]+'"';throw new Error(e)}}}else e=i;return e};return{peek:h,next:d,hasNext:c}}}}var sE=function(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}(function(){if(nE)return eE;nE=1;const t=function(){if(VM)return WM;VM=1;const{NODE_TYPE:t}=rE(),e=t=>{if(!t)return null;const i={};switch(t.type){case"ELEMENT":{let a={};const o=r(t.value.attributes),s=e(t.value.children);if(o&&(a=Object.assign(a,o)),s){const e=n(t.value.children);a=Object.assign(a,e)}i[t.value.type]=a;break}case"ATTRIBUTE":{const e=t.value;i[e.name]=e.value;break}case"CONTENT":return{content:t.value}}return i},n=t=>t&&Array.isArray(t)&&0!==t.length?i(t)?{content:t[0].value}:{children:t.map(e)}:null,i=t=>t&&Array.isArray(t)&&1===t.length&&"CONTENT"===t[0].type,r=t=>t&&Array.isArray(t)?t.map(e).reduce((t,e)=>Object.assign(t,e),{}):null;return WM={convert:t=>e(t.value.children[0])}}(),{transpile:e}=function(){if(tE)return QM;tE=1;const{TOKEN_TYPE:t}=rE(),{createLexer:e}=oE(),{Token:n}=aE(),[i,r,a,o]=["ROOT","ELEMENT","ATTRIBUTE","CONTENT"],s=(t,e)=>({type:t,value:e}),h=t=>s(o,t),c=(t,e,n)=>s(r,{type:t,attributes:e,children:n}),l=(t,e)=>s(a,{name:t,value:e}),f=(t,e)=>{const n=[];for(;t.hasNext();){const i=t.next();switch(i.type){case"OPEN_BRACKET":{const e=t.next(),[i,r]=u(t);let a=[];"CLOSE_ELEMENT"!==r.type&&(a=f(t,e)),a&&a.length>0&&"CONTENT"===a[0].type&&(a=d(a)),n.push(c(e.value,i,a));break}case"CLOSE_ELEMENT":if(i.value===e.value)return n;break;case"CONTENT":n.push(h(i.value));break;case"EOF":return n;default:throw new Error(`Unknown Lexem type: ${i.type} "${i.value}, scoping element: ${e.value}"`)}}return n},u=t=>{const e=[];let n=t.peek();if(!t.hasNext()||n&&"CLOSE_BRACKET"===n.type||n&&"CLOSE_ELEMENT"===n.type)return[e,n];for(n=t.next();t.hasNext()&&n&&"CLOSE_BRACKET"!==n.type&&"CLOSE_ELEMENT"!==n.type;){const i=n;"content"===i.value&&(i.value="@content"),t.next();const r=t.next(),a=l(i.value,r.value);e.push(a),n=t.next()}return[e,n]};function d(t){let e=[],n="";return t.forEach(t=>{"CONTENT"===t.type?n+=t.value:(n.length&&(e.push(h(n)),n=""),e.push(t))}),n.length&&e.push(h(n)),e}return QM={AttribNode:l,ContentNode:h,ElementNode:c,Node:s,transpile:function(t,r){const a=(t=>s(i,{children:f(t,n(i,"ROOT"))}))(e(t));return r?r.convert(a):a}},QM}();return eE={convertXML:function(n,i){return e(n,i||t)},createAST:function(t){return e(t)}}}());sE.convertXML,sE.createAST;const{convertXML:hE}=sE,cE="undefined"!=typeof self&&void 0===self.document,lE=Hv({formats:[hp]}),fE=n.Buffer.from([66,77,70,3]);function uE(t,e){if(function(t){if("string"==typeof t)return"BMF"===t.substring(0,3);const e=t.slice(0,4);return t.length>4&&e[0]===fE[0]&&e[1]===fE[1]&&e[2]===fE[2]}(e))return"string"==typeof e&&(e=n.Buffer.from(e,"binary")),LM(e);if(e=e.toString().trim(),/.json$/.test(t)||"{"===e.charAt(0))return JSON.parse(e);if(/.xml$/.test(t)||"<"===e.charAt(0)){if(!cE)return CM(e);const t=hE(e).font.children.reduce((t,e)=>({...t,...e}),{}),n=[],i=[],r=[];for(let e=0;e<t.pages.children.length;e++){const i=t.pages.children[e].page;n[parseInt(i.id,10)]=dE(i.file)}for(let e=0;e<t.chars.children.length;e++)i.push(dE(t.chars.children[e].char));for(let e=0;e<t.kernings.children.length;e++)r.push(dE(t.kernings.children[e].kerning));return{info:t.info,common:t.common,pages:n,chars:i,kernings:r}}return xM(e)}function dE(t){for(const e in t){try{t[e]=parseInt(t[e],10)}catch{}"object"==typeof t[e]&&dE(t[e])}return t}async function pE(t){if("string"==typeof t){if("function"!=typeof globalThis.fetch)throw new Error(`loadFont: can't load ${JSON.stringify(t)} because this runtime has no global fetch. Pass a path to the .fnt file instead (it and its pages are read from disk), or install a fetch polyfill.`);let e;try{e=await fetch(t)}catch(e){throw new Error(`loadFont: couldn't fetch ${JSON.stringify(t)}: ${e.message}`,{cause:e})}if(!e.ok)throw new Error(`loadFont: couldn't load ${JSON.stringify(t)}: HTTP ${e.status}${e.statusText?` ${e.statusText}`:""}`);return uE(t,await e.text())}return uE("",t)}const mE=/^[a-z][a-z\d+.-]+:/i,gE=/^[a-z][a-z\d+.-]+:\/\//i;function bE(t,e){const n=new Error(`Font page is outside of the font directory: ${e}`);if(gE.test(t)){const i=new URL(".",t),r=new URL(e,t);if(r.protocol!==i.protocol||r.host!==i.host||!r.pathname.startsWith(i.pathname)||/%2f|%5c/i.test(r.pathname.slice(i.pathname.length)))throw n;return r.href}const i=GM.join(".",e.replace(/\\/g,"/").replace(/%2e/gi,"."));if(".."===i||i.startsWith(`..${GM.sep}`))throw n;const r=GM.join(GM.dirname(t),e);if(mE.test(r)||"."===GM.dirname(t)&&mE.test(e))throw n;return r}async function wE(t,e){const n={},i={};for(let t=0;t<e.chars.length;t++){const i=e.chars[t];n[String.fromCodePoint(i.id)]=i}for(let t=0;t<e.kernings.length;t++){const n=String.fromCodePoint(e.kernings[t].first);i[n]=i[n]||{},i[n][String.fromCodePoint(e.kernings[t].second)]=e.kernings[t].amount}return{...e,chars:n,kernings:i,pages:await Promise.all(e.pages.map(e=>async function(t){try{return await lE.read(t)}catch(e){const{message:n}=e;if(!n.startsWith("Could not find MIME")&&!n.endsWith("does not support decoding"))throw e;const i=GM.extname(t.replace(/[?#].*$/,"")).slice(1).toUpperCase(),r=i&&"PNG"!==i?`is a ${i} image`:"isn't a PNG image";throw new Error(`loadFont: font page ${JSON.stringify(t)} ${r}; ${yE}`,{cause:e})}}(bE(t,e))))}}const yE="Jimp fonts need PNG pages. In BMFont, set the texture format to png when exporting.";const _E=/^(https?|data|blob):/i;function vE(t,e){return JSON.stringify(t.length>e?`${t.slice(0,e)}...`:t)}async function xE(t){if("string"!=typeof t)throw new Error(`loadFont expects a path or URL to a font file, but received ${null===t?"null":typeof t}. Fonts are named exports of "jimp/fonts" in v1, for example: import { SANS_32_BLACK } from "jimp/fonts";`);if("undefined"==typeof window&&!cE){const{existsSync:e,promises:n}=await Promise.resolve().then(function(){return DS});if(/^file:/i.test(t)){const{fileURLToPath:e}=await Promise.resolve().then(function(){return vz});t=e(t)}if(e(t)){const i=await pE(await n.readFile(t));for(const n of i.pages){const i=bE(t,n);if(!e(i))throw new Error(`loadFont: font page not found: ${JSON.stringify(i)}. Keep the .png pages next to the .fnt file.`)}return wE(t,i)}if(function(t){return/[\r\n]/.test(t)||/^\s*(<|\{|BMF|(info|common|pages?|chars?|kernings?)\s+\w+=)/.test(t)}(t))throw new Error(`loadFont expects a path or URL to a font file, but received the contents of one: ${vE(t,80)}. Pass the path to the .fnt file instead, its .png pages are loaded from the same directory.`);if(!_E.test(t))throw new Error(`loadFont: font file not found: ${vE(t,200)}. Pass a path to a .fnt file, a URL, or a SANS_* constant from jimp/fonts.`)}return wE(t,await pE(t))}var kE=function(t,e,n,i,r,a){if(!ME(t)||!ME(e)||n&&!ME(n))throw new Error("Image data: Uint8Array, Uint8ClampedArray or Buffer expected.");if(t.length!==e.length||n&&n.length!==t.length)throw new Error("Image sizes do not match.");if(t.length!==i*r*4)throw new Error("Image data size does not match width/height.");a=Object.assign({},AE,a);const o=i*r,s=new Uint32Array(t.buffer,t.byteOffset,o),h=new Uint32Array(e.buffer,e.byteOffset,o);let c=!0;for(let t=0;t<o;t++)if(s[t]!==h[t]){c=!1;break}if(c){if(n&&!a.diffMask)for(let e=0;e<o;e++)UE(t,4*e,a.alpha,n);return 0}const l=35215*a.threshold*a.threshold;let f=0;for(let o=0;o<r;o++)for(let s=0;s<i;s++){const h=4*(o*i+s),c=SE(t,e,h,h);Math.abs(c)>l?a.includeAA||!EE(t,s,o,i,r,e)&&!EE(e,s,o,i,r,t)?(n&&TE(n,h,...c<0&&a.diffColorAlt||a.diffColor),f++):n&&!a.diffMask&&TE(n,h,...a.aaColor):n&&(a.diffMask||UE(t,h,a.alpha,n))}return f};const AE={threshold:.1,includeAA:!1,alpha:.1,aaColor:[255,255,0],diffColor:[255,0,0],diffColorAlt:null,diffMask:!1};function ME(t){return ArrayBuffer.isView(t)&&1===t.constructor.BYTES_PER_ELEMENT}function EE(t,e,n,i,r,a){const o=Math.max(e-1,0),s=Math.max(n-1,0),h=Math.min(e+1,i-1),c=Math.min(n+1,r-1),l=4*(n*i+e);let f,u,d,p,m=e===o||e===h||n===s||n===c?1:0,g=0,b=0;for(let r=o;r<=h;r++)for(let a=s;a<=c;a++){if(r===e&&a===n)continue;const o=SE(t,t,l,4*(a*i+r),!0);if(0===o){if(m++,m>2)return!1}else o<g?(g=o,f=r,u=a):o>b&&(b=o,d=r,p=a)}return 0!==g&&0!==b&&(IE(t,f,u,i,r)&&IE(a,f,u,i,r)||IE(t,d,p,i,r)&&IE(a,d,p,i,r))}function IE(t,e,n,i,r){const a=Math.max(e-1,0),o=Math.max(n-1,0),s=Math.min(e+1,i-1),h=Math.min(n+1,r-1),c=4*(n*i+e);let l=e===a||e===s||n===o||n===h?1:0;for(let r=a;r<=s;r++)for(let a=o;a<=h;a++){if(r===e&&a===n)continue;const o=4*(a*i+r);if(t[c]===t[o]&&t[c+1]===t[o+1]&&t[c+2]===t[o+2]&&t[c+3]===t[o+3]&&l++,l>2)return!0}return!1}function SE(t,e,n,i,r){let a=t[n+0],o=t[n+1],s=t[n+2],h=t[n+3],c=e[i+0],l=e[i+1],f=e[i+2],u=e[i+3];if(h===u&&a===c&&o===l&&s===f)return 0;h<255&&(h/=255,a=PE(a,h),o=PE(o,h),s=PE(s,h)),u<255&&(u/=255,c=PE(c,u),l=PE(l,u),f=PE(f,u));const d=zE(a,o,s),p=zE(c,l,f),m=d-p;if(r)return m;const g=BE(a,o,s)-BE(c,l,f),b=CE(a,o,s)-CE(c,l,f),w=.5053*m*m+.299*g*g+.1957*b*b;return d>p?-w:w}function zE(t,e,n){return.29889531*t+.58662247*e+.11448223*n}function BE(t,e,n){return.59597799*t-.2741761*e-.32180189*n}function CE(t,e,n){return.21147017*t-.52261711*e+.31114694*n}function PE(t,e){return 255+(t-255)*e}function TE(t,e,n,i,r){t[e+0]=n,t[e+1]=i,t[e+2]=r,t[e+3]=255}function UE(t,e,n,i){const r=PE(zE(t[e+0],t[e+1],t[e+2]),n*t[e+3]/255);TE(i,e,r,r,r)}var OE=e(kE);const LE="threshold must be a number between 0 and 1",RE=Ih([uh(),Ns(),Ah({r:uh().min(0).max(255),g:uh().min(0).max(255),b:uh().min(0).max(255)})]),FE=Ah({threshold:uh(LE).min(0,LE).max(1,LE).optional(),alpha:uh().optional(),includeAA:gh().optional(),aaColor:RE.optional(),diffColor:RE.optional(),diffColorAlt:RE.optional(),diffMask:gh().optional()});function DE(t,e){const{r:n,g:i,b:r}="object"==typeof t?t:lc(pc(t,sn(e)));return[Math.round(n),Math.round(i),Math.round(r)]}function NE(t,e,n={}){const{threshold:i=.1,alpha:r=.1,includeAA:a=!1,aaColor:o,diffColor:s,diffColorAlt:h,diffMask:c=!1}=FE.parse("number"==typeof n?{threshold:n}:n);let l=t.bitmap,f=e.bitmap;l.width===f.width&&l.height===f.height||(l.width*l.height>f.width*f.height?l=Tp.resize(sc(t),{w:f.width,h:f.height}).bitmap:f=Tp.resize(sc(e),{w:l.width,h:l.height}).bitmap);const u=new t.constructor({width:l.width,height:l.height,color:0});return{percent:OE(l.data,f.data,u.bitmap.data,u.bitmap.width,u.bitmap.height,{threshold:i,alpha:Math.min(Math.max(r,0),1),includeAA:a,diffMask:c,...void 0!==o&&{aaColor:DE(o,u)},...void 0!==s&&{diffColor:DE(s,u)},...void 0!==h&&{diffColorAlt:DE(h,u)}})/(u.bitmap.width*u.bitmap.height),image:u}}const $E=[Pb,$b,nw,rw,Jw,qv,ox,Yv,hx,wx,xk,Ak,Ek,Qk,pA,yA,EA,WA,Tp,cM,dM,wM],jE=[yc,function(){return{mime:"image/x-ms-bmp",encode:bc,decode:wc}},dl,jp,function(){return{mime:"image/vnd.microsoft.icon",hasAlpha:!0,encode:$p,decode:Dp}},mg,hp,Mb],GE={bmp:yc().mime,gif:dl().mime,ico:jp().mime,jpeg:mg().mime,png:hp().mime,tiff:Mb().mime},HE=Hv({formats:jE,plugins:$E}),ZE={128:"€",130:"‚",131:"ƒ",132:"„",133:"…",134:"†",135:"‡",136:"ˆ",137:"‰",138:"Š",139:"‹",140:"Œ",142:"Ž",145:"‘",146:"’",147:"“",148:"”",149:"•",150:"–",151:"—",152:"˜",153:"™",154:"š",155:"›",156:"œ",158:"ž",159:"Ÿ"},qE={};for(const[t,e]of Object.entries(ZE))qE[e]=Number.parseInt(t,10);let WE,VE;const JE=32768,YE=65533;function XE(t,e="utf-8"){switch(e.toLowerCase()){case"utf-8":case"utf8":{const e=function(){if(void 0===WE)try{WE=void 0===globalThis.TextDecoder?null:new globalThis.TextDecoder("utf-8")}catch{WE=null}return null!=WE?WE:void 0}();return e?e.decode(t):function(t){const e=[],n=[];let i=0;t.length>=3&&239===t[0]&&187===t[1]&&191===t[2]&&(i=3);for(;i<t.length;){const r=t[i];if(r<=127){tI(e,n,r),i++;continue}if(r<194||r>244){tI(e,n,YE),i++;continue}const a=r<=223?2:r<=239?3:4;let o=r&127>>a,s=224===r?160:240===r?144:128,h=237===r?159:244===r?143:191,c=1;for(i++;c<a&&i<t.length;){const e=t[i];if(e<s||e>h)break;o=o<<6|63&e,c++,i++,s=128,h=191}eI(e,n,c===a?o:YE)}return QE(e,n),e.join("")}(t)}case"utf-16le":return function(t){const e=[],n=[],i=t.length;let r=0;i>=2&&255===t[0]&&254===t[1]&&(r=2);for(;r+1<i;){const a=t[r]|t[r+1]<<8;if(r+=2,a>=55296&&a<=56319)if(r+1<i){const i=t[r]|t[r+1]<<8;i>=56320&&i<=57343?(tI(e,n,a),tI(e,n,i),r+=2):tI(e,n,YE)}else tI(e,n,YE);else tI(e,n,a>=56320&&a<=57343?YE:a)}r<i&&tI(e,n,YE);return QE(e,n),e.join("")}(t);case"us-ascii":case"ascii":return function(t){const e=[];for(let n=0;n<t.length;n+=JE){const i=Math.min(t.length,n+JE),r=new Array(i-n);for(let e=n,a=0;e<i;e++,a++)r[a]=127&t[e];e.push(String.fromCharCode.apply(null,r))}return e.join("")}(t);case"latin1":case"iso-8859-1":return function(t){const e=[];for(let n=0;n<t.length;n+=JE){const i=Math.min(t.length,n+JE),r=new Array(i-n);for(let e=n,a=0;e<i;e++,a++)r[a]=t[e];e.push(String.fromCharCode.apply(null,r))}return e.join("")}(t);case"windows-1252":return function(t){const e=[];let n="";for(let i=0;i<t.length;i++){const r=t[i],a=r>=128&&r<=159?ZE[r]:void 0;n+=null!=a?a:String.fromCharCode(r),n.length>=JE&&(e.push(n),n="")}n&&e.push(n);return e.join("")}(t);default:throw new RangeError(`Encoding '${e}' not supported`)}}function KE(t="",e="utf-8"){switch(e.toLowerCase()){case"utf-8":case"utf8":{const e=function(){if(void 0===VE)try{VE=void 0===globalThis.TextEncoder?null:new globalThis.TextEncoder}catch{VE=null}return null!=VE?VE:void 0}();return e?e.encode(t):function(t){const e=[];for(let n=0;n<t.length;n++){let i=t.charCodeAt(n);if(i>=55296&&i<=56319)if(n+1<t.length){const e=t.charCodeAt(n+1);e>=56320&&e<=57343?(i=65536+(i-55296<<10)+(e-56320),n++):i=YE}else i=YE;else i>=56320&&i<=57343&&(i=YE);i<128?e.push(i):i<2048?e.push(192|i>>6,128|63&i):i<65536?e.push(224|i>>12,128|i>>6&63,128|63&i):e.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|63&i)}return new Uint8Array(e)}(t)}case"utf-16le":return function(t){const e=[];for(let n=0;n<t.length;n++){const i=t.charCodeAt(n);if(i>=55296&&i<=56319)if(n+1<t.length){const r=t.charCodeAt(n+1);r>=56320&&r<=57343?(e.push(i,r),n++):e.push(YE)}else e.push(YE);else i>=56320&&i<=57343?e.push(YE):e.push(i)}const n=new Uint8Array(2*e.length);for(let t=0;t<e.length;t++){const i=e[t],r=2*t;n[r]=255&i,n[r+1]=i>>>8}return n}(t);case"us-ascii":case"ascii":return function(t){const e=new Uint8Array(t.length);for(let n=0;n<t.length;n++)e[n]=127&t.charCodeAt(n);return e}(t);case"latin1":case"iso-8859-1":return function(t){const e=new Uint8Array(t.length);for(let n=0;n<t.length;n++)e[n]=255&t.charCodeAt(n);return e}(t);case"windows-1252":return function(t){const e=new Uint8Array(t.length);for(let n=0;n<t.length;n++){const i=t[n],r=i.charCodeAt(0);void 0===qE[i]?e[n]=r>=0&&r<=127||r>=160&&r<=255?r:63:e[n]=qE[i]}return e}(t);default:throw new RangeError(`Encoding '${e}' not supported`)}}function QE(t,e){0!==e.length&&(t.push(String.fromCharCode.apply(null,e)),e.length=0)}function tI(t,e,n){e.push(n),e.length>=JE&&QE(t,e)}function eI(t,e,n){n<=65535?tI(t,e,n):(tI(t,e,55296+((n-=65536)>>10)),tI(t,e,56320+(1023&n)))}function nI(t){return new DataView(t.buffer,t.byteOffset)}const iI={len:1,get:(t,e)=>nI(t).getUint8(e),put:(t,e,n)=>(nI(t).setUint8(e,n),e+1)},rI={len:2,get:(t,e)=>nI(t).getUint16(e,!0),put:(t,e,n)=>(nI(t).setUint16(e,n,!0),e+2)},aI={len:2,get:(t,e)=>nI(t).getUint16(e),put:(t,e,n)=>(nI(t).setUint16(e,n),e+2)},oI={len:4,get:(t,e)=>nI(t).getUint32(e,!0),put:(t,e,n)=>(nI(t).setUint32(e,n,!0),e+4)},sI={len:4,get:(t,e)=>nI(t).getUint32(e),put:(t,e,n)=>(nI(t).setUint32(e,n),e+4)},hI={len:4,get:(t,e)=>nI(t).getInt32(e),put:(t,e,n)=>(nI(t).setInt32(e,n),e+4)},cI={len:8,get:(t,e)=>nI(t).getBigUint64(e,!0),put:(t,e,n)=>(nI(t).setBigUint64(e,n,!0),e+8)};class lI{constructor(t,e){this.len=t,this.encoding=e}get(t,e=0){return XE(t.subarray(e,e+this.len),this.encoding)}put(t,e,n){const i=KE(n,this.encoding);if(i.length!==this.len)throw new RangeError(`Expected an encoded value of ${this.len} byte(s), got ${i.length}`);return t.set(i,e),e+this.len}}class fI extends Error{constructor(){super("End-Of-Stream"),this.name="EndOfStreamError"}}class uI extends Error{constructor(t="The operation was aborted"){super(t),this.name="AbortError"}}function dI(t){if(t?.aborted)throw new uI}class pI extends RangeError{constructor(t,e){super(`Requested buffer size ${t} exceeds maxBufferSize ${e}`),this.requestedSize=t,this.maxBufferSize=e,this.name="BufferSizeError"}}function mI(t){const e=t?.maxBufferSize??Number.POSITIVE_INFINITY;if(e!==Number.POSITIVE_INFINITY&&(!Number.isSafeInteger(e)||e<=0))throw new RangeError("maxBufferSize must be a positive safe integer or Infinity");return e}class gI{constructor(t){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[],this.onCloseCallback=t?.onClose}async peek(t,e=!1){const n=await this.read(t,e);return this.peekQueue.push(t.subarray(0,n)),n}async read(t,e=!1){if(0===t.length)return 0;let n=this.readFromPeekBuffer(t);if(this.endOfStream||(n+=await this.readRemainderFromStream(t.subarray(n),e)),0===n&&!e)throw new fI;return n}readFromPeekBuffer(t){let e=t.length,n=0;for(;this.peekQueue.length>0&&e>0;){const i=this.peekQueue.pop();if(!i)throw new Error("peekData should be defined");const r=Math.min(i.length,e);t.set(i.subarray(0,r),n),n+=r,e-=r,r<i.length&&this.peekQueue.push(i.subarray(r))}return n}async readRemainderFromStream(t,e){let n=0;for(;n<t.length&&!this.endOfStream;){if(this.interrupted)throw new uI;const i=await this.readFromStream(t.subarray(n),e);if(0===i)break;n+=i}if(!e&&n<t.length)throw new fI;return n}close(){return this.closePromise??(this.closePromise=Promise.resolve().then(async()=>{await this.closeResource(),await(this.onCloseCallback?.())})),this.closePromise}closeResource(){return this.abort()}}class bI extends gI{constructor(t,e){super(e),this.reader=t,this.released=!1}async abort(){this.released||(this.reader.releaseLock(),this.released=!0)}}class wI extends bI{async readFromStream(t,e){if(0===t.length)return 0;const n=await this.reader.read(new Uint8Array(t.length),{min:e?void 0:t.length});return n.done&&(this.endOfStream=n.done),n.value?(t.set(n.value),n.value.length):0}}class yI extends gI{constructor(t,e){super(e),this.reader=t,this.buffer=null}writeChunk(t,e){const n=Math.min(e.length,t.length);return t.set(e.subarray(0,n)),n<e.length?this.buffer=e.subarray(n):this.buffer=null,n}async readFromStream(t,e){if(0===t.length)return 0;let n=0;for(this.buffer&&(n+=this.writeChunk(t,this.buffer));n<t.length&&!this.endOfStream;){const e=await this.reader.read();if(e.done){this.endOfStream=!0;break}e.value&&(n+=this.writeChunk(t.subarray(n),e.value))}if(!e&&0===n&&this.endOfStream)throw new fI;return n}abort(){return this.interrupted=!0,this.reader.cancel()}async closeResource(){try{await this.abort()}finally{this.reader.releaseLock()}}}class _I{constructor(t){this.numBuffer=new Uint8Array(10),this.position=0,this.maxBufferSize=mI(t),dI(t?.abortSignal),this.onClose=t?.onClose,t?.abortSignal&&this.addAbortListener(t.abortSignal,()=>{this.abort().catch(()=>{})})}addAbortListener(t,e){this.abortSignal=t,this.abortListener=e,t.addEventListener("abort",e,{once:!0})}removeAbortListener(){this.abortListener&&this.abortSignal?.removeEventListener("abort",this.abortListener),this.abortSignal=void 0,this.abortListener=void 0}async readToken(t,e=this.position){this.validateTokenRead(t.len,e);const n=new Uint8Array(t.len);if(await this.readBuffer(n,{position:e})<t.len)throw new fI;return t.get(n,0)}async peekToken(t,e=this.position){const n=e??this.position;this.validateTokenRead(t.len,n,!0);const i=new Uint8Array(t.len);if(await this.peekBuffer(i,{position:n})<t.len)throw new fI;return t.get(i,0)}async readNumber(t){if(await this.readBuffer(this.numBuffer,{length:t.len})<t.len)throw new fI;return t.get(this.numBuffer,0)}async peekNumber(t){if(await this.peekBuffer(this.numBuffer,{length:t.len})<t.len)throw new fI;return t.get(this.numBuffer,0)}async ignore(t){if(t<0)throw new RangeError("ignore length must be ≥ 0 bytes");if(this.validateLength(t,"ignore length"),this.validateLength(this.position+t,"end position"),void 0!==this.fileInfo.size){const e=Math.max(0,this.fileInfo.size-this.position);if(t>e)return this.position+=e,e}return this.position+=t,t}close(){return this.closePromise||(this.removeAbortListener(),this.closePromise=Promise.resolve().then(()=>this.closeOnce())),this.closePromise}async closeOnce(){await this.abort(),await(this.onClose?.())}validateLength(t,e){if(!Number.isSafeInteger(t)||t<0)throw new RangeError(`${e} must be a non-negative safe integer`)}validateBufferSize(t){if(this.validateLength(t,"buffer length"),t>this.maxBufferSize)throw new pI(t,this.maxBufferSize)}validateTokenRead(t,e,n=!1){if(this.validateBufferSize(t),this.validateLength(e,"position"),this.validateLength(e+t,"end position"),!this.supportsRandomAccess()&&e<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(n&&!this.supportsRandomAccess()&&this.validateBufferSize(t+e-this.position),void 0!==this.fileInfo.size&&t>this.fileInfo.size-e)throw new fI}normalizeOptions(t,e){const n=e?.length??t.length,i=e?.position??this.position;if(this.validateLength(n,"length"),this.validateLength(i,"position"),this.validateLength(i+n,"end position"),n>t.length)throw new RangeError("length must not exceed the target buffer length");if(!this.supportsRandomAccess()&&i<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");return{length:n,position:i,mayBeLess:e?.mayBeLess??!1}}abort(){return this.removeAbortListener(),Promise.resolve()}}class vI extends _I{constructor(t,e){super(e),this.blob=t,this.fileInfo={...e?.fileInfo??{},size:t.size,mimeType:t.type}}async readBuffer(t,e){const n=this.normalizeOptions(t,e),i=await this.peekBuffer(t,n);return this.position=n.position+i,i}async peekBuffer(t,e){const n=this.normalizeOptions(t,e),i=Math.max(0,Math.min(this.blob.size-n.position,n.length));if(!n.mayBeLess&&i<n.length)throw new fI;for(let e=0;e<i;){const r=Math.min(this.maxBufferSize,i-e),a=n.position+e,o=await this.blob.slice(a,a+r).arrayBuffer();t.set(new Uint8Array(o),e),e+=r}return i}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(t){this.validateLength(t,"position"),this.position=t}}class xI extends _I{constructor(t,e){super(e),this.uint8Array=t,this.fileInfo={...e?.fileInfo??{},size:t.length}}async readBuffer(t,e){const n=this.normalizeOptions(t,e),i=await this.peekBuffer(t,n);return this.position=n.position+i,i}async peekBuffer(t,e){const n=this.normalizeOptions(t,e),i=Math.max(0,Math.min(this.uint8Array.length-n.position,n.length));if(!n.mayBeLess&&i<n.length)throw new fI;return t.set(this.uint8Array.subarray(n.position,n.position+i)),i}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(t){this.validateLength(t,"position"),this.position=t}}class kI extends _I{constructor(t,e){super(e),this.streamReader=t,this.fileInfo=e?.fileInfo??{}}async readBuffer(t,e){const n=this.normalizeOptions(t,e),i=n.position-this.position;if(i>0)return await this.ignore(i),this.readBuffer(t,e);if(i<0)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(0===n.length)return 0;let r=0;for(;r<n.length;){const e=Math.min(this.maxBufferSize,n.length-r),i=await this.streamReader.read(t.subarray(r,r+e),!0);if(r+=i,this.position+=i,i<e)break}if(!n.mayBeLess&&r<n.length)throw new fI;return r}async peekBuffer(t,e){const n=this.normalizeOptions(t,e);if(0===n.length)return 0;if(void 0!==this.fileInfo.size&&n.position>=this.fileInfo.size){if(n.mayBeLess)return 0;throw new fI}const i=n.length+n.position-this.position;this.validateBufferSize(i);let r=0;if(n.position){const e=n.position-this.position;if(e>0){const i=new Uint8Array(n.length+e);r=await this.peekBuffer(i,{mayBeLess:n.mayBeLess});const a=Math.max(0,r-e);return t.set(i.subarray(e,e+a)),a}if(e<0)throw new Error("Cannot peek from a negative offset in a stream")}if(n.length>0){try{const e=new Uint8Array(n.length);r=await this.streamReader.peek(e,!0),t.set(e.subarray(0,r))}catch(t){if(e?.mayBeLess&&t instanceof fI)return 0;throw t}if(!n.mayBeLess&&r<n.length)throw new fI}return r}async ignore(t){if(t<0)throw new RangeError("ignore length must be ≥ 0 bytes");if(this.validateLength(t,"ignore length"),this.validateLength(this.position+t,"end position"),t>0&&void 0!==this.fileInfo.size&&t>this.fileInfo.size-this.position)throw new fI;const e=Math.min(256e3,this.maxBufferSize,t),n=new Uint8Array(e);let i=0;for(;i<t;){const r=t-i,a=await this.readBuffer(n,{length:Math.min(e,r)});if(a<0)return a;i+=a}return i}abort(){return this.removeAbortListener(),this.streamReader.abort()}async close(){return this.removeAbortListener(),this.streamReader.close()}supportsRandomAccess(){return!1}}function AI(t){return t.supportsRandomAccess()&&"setPosition"in t&&"function"==typeof t.setPosition&&"number"==typeof t.fileInfo.size}class MI extends RangeError{constructor(t,e,n){super(`Range at position ${t} with length ${e} exceeds tokenizer view size ${n}`),this.position=t,this.length=e,this.size=n,this.name="TokenizerBoundaryError"}}function EI(t,e){if(!Number.isSafeInteger(t)||t<0)throw new RangeError(`${e} must be a non-negative safe integer`)}function II(t,e){return AI(t)?new zI(t,e):new SI(t,e)}class SI{constructor(t,e){this.source=t,this.size=e,this.closed=!1,this.closedPosition=0,this.busy=!1,EI(e,"length"),EI(t.position,"source position"),EI(t.position+e,"end position"),t instanceof SI&&(t.assertAvailable(),t.translateRange(e,t.position)),this.start=t.position,this.fileInfo={size:e}}get position(){return this.closed?this.closedPosition:this.source.position-this.start}get remaining(){return this.size-this.position}supportsRandomAccess(){return!1}createView(t){return this.assertAvailable(),II(this,t)}async readBuffer(t,e){return this.bufferOperation("readBuffer",t,e)}async peekBuffer(t,e){return this.bufferOperation("peekBuffer",t,e)}async bufferOperation(t,e,n){this.assertAvailable();const i=n?.length??e.length,r=n?.position??this.position,a=this.translateRange(i,r);if(i>e.length)throw new RangeError("length must not exceed the target buffer length");return this.run(()=>this.source[t](e,{...n,length:i,position:a}))}async readToken(t,e=this.position){this.assertAvailable();const n=this.translateRange(t.len,e);return this.run(()=>this.source.readToken(t,n))}async peekToken(t,e=this.position){this.assertAvailable();const n=this.translateRange(t.len,e??this.position);return this.run(()=>this.source.peekToken(t,n))}async readNumber(t){return this.assertAvailable(),this.translateRange(t.len,this.position),this.run(()=>this.source.readNumber(t))}async peekNumber(t){return this.assertAvailable(),this.translateRange(t.len,this.position),this.run(()=>this.source.peekNumber(t))}async ignore(t){return this.assertAvailable(),this.translateRange(t,this.position),this.run(()=>this.source.ignore(t))}async consumeRemainder(){this.assertAvailable();const t=this.remaining,e=this.translateRange(t,this.position)+t;return this.run(async()=>{if(0===t)return 0;if(AI(this.source)){if(1!==await this.source.peekBuffer(new Uint8Array(1),{position:e-1}))throw new fI;this.source.setPosition(e)}else{if(await this.source.ignore(t)!==t)throw new fI}return t})}async close(){if(!this.closed){if(this.busy)throw new Error("Cannot close a tokenizer view during an active operation");this.closedPosition=this.position,this.closed=!0}}async abort(){if(!this.closed)try{await this.source.abort()}finally{this.closedPosition=this.position,this.closed=!0}}assertAvailable(){if(this.closed)throw new Error("Tokenizer view is closed");if(this.busy)throw new Error("Tokenizer views require sequential operations");this.source instanceof SI&&this.source.assertAvailable()}translateRange(t,e){if(EI(t,"length"),EI(e,"position"),EI(e+t,"end position"),e>this.size||t>this.size-e)throw new MI(e,t,this.size);if(!this.supportsRandomAccess()&&e<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");return this.start+e}async run(t){this.busy=!0;try{return await t()}finally{this.busy=!1}}}class zI extends SI{constructor(t,e){super(t,e)}supportsRandomAccess(){return!0}setPosition(t){this.assertAvailable(),this.source.setPosition(this.translateRange(0,t))}createView(t){return this.assertAvailable(),II(this,t)}}function BI(t,e){mI(e),dI(e?.abortSignal);const n=function(t,e){try{const n=t.getReader({mode:"byob"});return n instanceof ReadableStreamDefaultReader?new yI(n,e):new wI(n,e)}catch(n){if(n instanceof TypeError)return new yI(t.getReader(),e);throw n}}(t);return new kI(n,e)}class CI{constructor(t){this.tokenizer=t}inflate(){const t=this.tokenizer;return new ReadableStream({async pull(e){const n=new Uint8Array(1024),i=await t.readBuffer(n,{mayBeLess:!0});0!==i?e.enqueue(n.subarray(0,i)):e.close()}}).pipeThrough(new DecompressionStream("gzip"))}}var PI,TI,UI={exports:{}};function OI(){if(TI)return PI;TI=1;var t=1e3,e=60*t,n=60*e,i=24*n,r=7*i,a=365.25*i;function o(t,e,n,i){var r=e>=1.5*n;return Math.round(t/n)+" "+i+(r?"s":"")}return PI=function(s,h){h=h||{};var c=typeof s;if("string"===c&&s.length>0)return function(o){if((o=String(o)).length>100)return;var s=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(o);if(!s)return;var h=parseFloat(s[1]);switch((s[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return h*a;case"weeks":case"week":case"w":return h*r;case"days":case"day":case"d":return h*i;case"hours":case"hour":case"hrs":case"hr":case"h":return h*n;case"minutes":case"minute":case"mins":case"min":case"m":return h*e;case"seconds":case"second":case"secs":case"sec":case"s":return h*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return h;default:return}}(s);if("number"===c&&isFinite(s))return h.long?function(r){var a=Math.abs(r);if(a>=i)return o(r,a,i,"day");if(a>=n)return o(r,a,n,"hour");if(a>=e)return o(r,a,e,"minute");if(a>=t)return o(r,a,t,"second");return r+" ms"}(s):function(r){var a=Math.abs(r);if(a>=i)return Math.round(r/i)+"d";if(a>=n)return Math.round(r/n)+"h";if(a>=e)return Math.round(r/e)+"m";if(a>=t)return Math.round(r/t)+"s";return r+"ms"}(s);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(s))},PI}var LI=function(t){function e(t){let i,r,a,o=null;function s(...t){if(!s.enabled)return;const n=s,r=Number(new Date),a=r-(i||r);n.diff=a,n.prev=i,n.curr=r,i=r,t[0]=e.coerce(t[0]),"string"!=typeof t[0]&&t.unshift("%O");let o=0;t[0]=t[0].replace(/%([a-zA-Z%])/g,(i,r)=>{if("%%"===i)return"%";o++;const a=e.formatters[r];if("function"==typeof a){const e=t[o];i=a.call(n,e),t.splice(o,1),o--}return i}),e.formatArgs.call(n,t);(n.log||e.log).apply(n,t)}return s.namespace=t,s.useColors=e.useColors(),s.color=e.selectColor(t),s.extend=n,s.destroy=e.destroy,Object.defineProperty(s,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(r!==e.namespaces&&(r=e.namespaces,a=e.enabled(t)),a),set:t=>{o=t}}),"function"==typeof e.init&&e.init(s),s}function n(t,n){const i=e(this.namespace+(void 0===n?":":n)+t);return i.log=this.log,i}function i(t,e){let n=0,i=0,r=-1,a=0;for(;n<t.length;)if(i<e.length&&(e[i]===t[n]||"*"===e[i]))"*"===e[i]?(r=i,a=n,i++):(n++,i++);else{if(-1===r)return!1;i=r+1,a++,n=a}for(;i<e.length&&"*"===e[i];)i++;return i===e.length}return e.debug=e,e.default=e,e.coerce=function(t){if(t instanceof Error)return t.stack||t.message;return t},e.disable=function(){const t=[...e.names,...e.skips.map(t=>"-"+t)].join(",");return e.enable(""),t},e.enable=function(t){e.save(t),e.namespaces=t,e.names=[],e.skips=[];const n=("string"==typeof t?t:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const t of n)"-"===t[0]?e.skips.push(t.slice(1)):e.names.push(t)},e.enabled=function(t){for(const n of e.skips)if(i(t,n))return!1;for(const n of e.names)if(i(t,n))return!0;return!1},e.humanize=OI(),e.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(t).forEach(n=>{e[n]=t[n]}),e.names=[],e.skips=[],e.formatters={},e.selectColor=function(t){let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n|=0;return e.colors[Math.abs(n)%e.colors.length]},e.enable(e.load()),e};!function(t,e){e.formatArgs=function(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;e.splice(1,0,n,"color: inherit");let i=0,r=0;e[0].replace(/%[a-zA-Z%]/g,t=>{"%%"!==t&&(i++,"%c"===t&&(r=i))}),e.splice(r,0,n)},e.save=function(t){try{t?e.storage.setItem("debug",t):e.storage.removeItem("debug")}catch(t){}},e.load=function(){let t;try{t=e.storage.getItem("debug")||e.storage.getItem("DEBUG")}catch(t){}!t&&"undefined"!=typeof process&&"env"in process&&(t=process.env.DEBUG);return t},e.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let t;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(t=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(t[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},e.storage=function(){try{return localStorage}catch(t){}}(),e.destroy=(()=>{let t=!1;return()=>{t||(t=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.log=console.debug||console.log||(()=>{}),t.exports=LI(e);const{formatters:n}=t.exports;n.j=function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}}(UI,UI.exports);var RI=e(UI.exports);class FI extends RangeError{constructor(t,e,n){super(`ZIP ${t} exceeded: ${e} exceeds limit of ${n}`),this.limit=t,this.requestedSize=e,this.maxSize=n,this.name="ZipLimitError"}}const DI=67324752,NI=134695760,$I=33639248,jI=101010256,GI={get:t=>({signature:oI.get(t,0),compressedSize:oI.get(t,8),uncompressedSize:oI.get(t,12)}),len:16},HI={get(t){const e=rI.get(t,6);return{signature:oI.get(t,0),minVersion:rI.get(t,4),dataDescriptor:!!(8&e),compressedMethod:rI.get(t,8),compressedSize:oI.get(t,18),uncompressedSize:oI.get(t,22),filenameLength:rI.get(t,26),extraFieldLength:rI.get(t,28),filename:null}},len:30},ZI={get:t=>({signature:oI.get(t,0),nrOfThisDisk:rI.get(t,4),nrOfThisDiskWithTheStart:rI.get(t,6),nrOfEntriesOnThisDisk:rI.get(t,8),nrOfEntriesOfSize:rI.get(t,10),sizeOfCd:oI.get(t,12),offsetOfStartOfCd:oI.get(t,16),zipFileCommentLength:rI.get(t,20)}),len:22},qI={get(t){const e=rI.get(t,8);return{signature:oI.get(t,0),minVersion:rI.get(t,6),dataDescriptor:!!(8&e),compressedMethod:rI.get(t,10),compressedSize:oI.get(t,20),uncompressedSize:oI.get(t,24),filenameLength:rI.get(t,28),extraFieldLength:rI.get(t,30),fileCommentLength:rI.get(t,32),relativeOffsetOfLocalHeader:oI.get(t,42),filename:null}},len:46};const WI=RI("tokenizer:inflate"),VI=262144,JI=function(t){const e=new Uint8Array(oI.len);return oI.put(e,0,t),e}(jI);class YI{constructor(t,e={}){if(this.tokenizer=t,this.syncBuffer=new Uint8Array(VI),this.scannedBytes=0,this.descriptorScannedBytes=0,this.limits={maxEntryCount:e.maxEntryCount??Number.POSITIVE_INFINITY,maxTotalScanBytes:e.maxTotalScanBytes??Number.POSITIVE_INFINITY,maxTotalDataDescriptorScanBytes:e.maxTotalDataDescriptorScanBytes??Number.POSITIVE_INFINITY,maxSkippedEntrySize:e.maxSkippedEntrySize??Number.POSITIVE_INFINITY,maxDataDescriptorScanBytes:e.maxDataDescriptorScanBytes??Number.POSITIVE_INFINITY,maxCompressedSize:e.maxCompressedSize??Number.POSITIVE_INFINITY,maxUncompressedSize:e.maxUncompressedSize??Number.POSITIVE_INFINITY},this.useCentralDirectory=e.useCentralDirectory??!0,this.allowTruncatedDataDescriptor=e.allowTruncatedDataDescriptor??!1,"boolean"!=typeof this.useCentralDirectory)throw new TypeError("useCentralDirectory must be a boolean");if("boolean"!=typeof this.allowTruncatedDataDescriptor)throw new TypeError("allowTruncatedDataDescriptor must be a boolean");for(const[t,e]of Object.entries(this.limits))if(e!==Number.POSITIVE_INFINITY&&(!Number.isSafeInteger(e)||e<=0))throw new RangeError(`${t} must be a positive safe integer or Infinity`)}checkLimit(t,e){if(e>this.limits[t])throw new FI(t,e,this.limits[t])}resetTraversal(){this.scannedBytes=0,this.descriptorScannedBytes=0}consumeBytes(t){this.checkLimit("maxTotalScanBytes",this.scannedBytes+t),this.scannedBytes+=t}readToken(t,e=this.tokenizer){return this.consumeBytes(t.len),e.readToken(t)}ignore(t,e=this.tokenizer){return this.consumeBytes(t),e.ignore(t)}readData(t){this.consumeBytes(t);const e=new Uint8Array(t);return this.tokenizer.readBuffer(e).then(()=>e)}checkEntrySize(t){this.checkLimit("maxCompressedSize",t.compressedSize),this.checkLimit("maxUncompressedSize",t.uncompressedSize),0===t.compressedMethod&&this.checkLimit("maxUncompressedSize",t.compressedSize)}async isZip(){const t=await this.peekSignature();return t===DI||t===jI}peekSignature(){return this.tokenizer.peekToken(oI)}async findEndOfCentralDirectoryLocator(){const t=this.tokenizer,e=Math.min(16384,t.fileInfo.size),n=this.syncBuffer.subarray(0,e);this.consumeBytes(e),await this.tokenizer.readBuffer(n,{position:t.fileInfo.size-e});for(let i=n.length-4;i>=0;i--)if(n[i]===JI[0]&&n[i+1]===JI[1]&&n[i+2]===JI[2]&&n[i+3]===JI[3])return t.fileInfo.size-e+i;return-1}async readCentralDirectory(){this.resetTraversal();const t=await this.centralDirectoryEntries();if(!t)return;const e=[];for await(const n of t)e.push(n);return e}async centralDirectoryEntries(){if(!this.tokenizer.supportsRandomAccess())return void WI("Cannot reading central-directory without random-read support");WI("Reading central-directory...");const t=this.tokenizer.position;try{const t=await this.findEndOfCentralDirectoryLocator();if(t>=0){WI("Central-directory 32-bit signature found"),this.tokenizer.setPosition(t);const e=await this.readToken(ZI);return this.iterateDirectory(e.offsetOfStartOfCd,e.sizeOfCd,e.nrOfEntriesOfSize)}}finally{this.tokenizer.setPosition(t)}}async*iterateDirectory(t,e,n){const i=this.tokenizer,r=i.position;let a,o=0;try{i.setPosition(t),a=II(i,e);for(let t=0;t<n;++t){this.checkLimit("maxEntryCount",t+1),a.setPosition(o);const e=await this.readToken(qI,a);if(e.signature!==$I)throw new Error("Expected Central-File-Header signature");e.filename=await this.readToken(new lI(e.filenameLength,"utf-8"),a),await this.ignore(e.extraFieldLength,a),await this.ignore(e.fileCommentLength,a),o=a.position,yield e}}finally{try{await(a?.close())}finally{i.setPosition(r)}}}async unzip(t){this.resetTraversal();const e=this.useCentralDirectory?await this.centralDirectoryEntries():void 0;if(e)return this.iterateOverCentralDirectory(e,t);let n=!1,i=0;do{const e=await this.readLocalFileHeader();if(!e)break;this.checkLimit("maxEntryCount",++i);const r=t(e);let a;if(n=!!r.stop,await this.ignore(e.extraFieldLength),r.handler?this.checkEntrySize(e):this.checkLimit("maxSkippedEntrySize",e.compressedSize),e.dataDescriptor&&0===e.compressedSize){const t=[];let n=0;const i=Math.min(this.limits.maxDataDescriptorScanBytes,this.limits.maxTotalDataDescriptorScanBytes-this.descriptorScannedBytes,this.limits.maxTotalScanBytes-this.scannedBytes,r.handler?Number.POSITIVE_INFINITY:this.limits.maxSkippedEntrySize,r.handler?this.limits.maxCompressedSize:Number.POSITIVE_INFINITY,r.handler&&0===e.compressedMethod?this.limits.maxUncompressedSize:Number.POSITIVE_INFINITY);for(WI("Compressed-file-size unknown, scanning for next data-descriptor-signature....");;){const a=Math.min(VI,i-n+GI.len),o=await this.tokenizer.peekBuffer(this.syncBuffer.subarray(0,a),{mayBeLess:!0}),s=this.allowTruncatedDataDescriptor&&o<a,h=XI(this.syncBuffer.subarray(0,o),n,s);if(h<0&&o<GI.len&&!s)throw new Error("Expected data-descriptor-signature before end of input");const c=h>=0?h:s?o:o-GI.len+1;if(0===c)break;if(this.checkLimit("maxDataDescriptorScanBytes",n+c),this.checkLimit("maxTotalDataDescriptorScanBytes",this.descriptorScannedBytes+c),r.handler||this.checkLimit("maxSkippedEntrySize",n+c),r.handler){if(this.checkLimit("maxCompressedSize",n+c),0===e.compressedMethod&&this.checkLimit("maxUncompressedSize",n+c),c>0){const e=await this.readData(c);t.push(e)}}else await this.ignore(c);if(n+=c,this.descriptorScannedBytes+=c,h>=0)break}WI(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),r.handler&&(this.checkLimit("maxCompressedSize",n),await this.inflate(e,KI(t),r.handler))}else r.handler?(WI(`Reading compressed-file-data: ${e.compressedSize} bytes`),a=await this.readData(e.compressedSize),await this.inflate(e,a,r.handler)):(WI(`Ignoring compressed-file-data: ${e.compressedSize} bytes`),await this.ignore(e.compressedSize));if(WI(`Reading data-descriptor at pos=${this.tokenizer.position}`),e.dataDescriptor){if(134695760!==(await this.readToken(GI)).signature)throw new Error("Expected data-descriptor-signature at position "+(this.tokenizer.position-GI.len))}}while(!n)}async iterateOverCentralDirectory(t,e){for await(const n of t){const t=e(n);if(t.handler){this.tokenizer.setPosition(n.relativeOffsetOfLocalHeader);const e=await this.readLocalFileHeader();if(!e)throw new Error(`Expected local-file-header at offset ${n.relativeOffsetOfLocalHeader}`);await this.ignore(e.extraFieldLength),this.checkEntrySize(n),this.checkEntrySize(e);const i=await this.readData(n.compressedSize);await this.inflate(e,i,t.handler)}if(t.stop)break}}async inflate(t,e,n){if(0===t.compressedMethod)return this.checkLimit("maxUncompressedSize",e.length),n(e);if(8!==t.compressedMethod)throw new Error(`Unsupported ZIP compression method: ${t.compressedMethod}`);WI(`Decompress filename=${t.filename}, compressed-size=${e.length}`);return n(await this.decompressDeflateRaw(e))}async decompressDeflateRaw(t){const e=new ReadableStream({start(e){e.enqueue(t),e.close()}}),n=new DecompressionStream("deflate-raw"),i=e.pipeThrough(n).getReader(),r=[];let a=0;try{for(;;){const{done:t,value:e}=await i.read();if(t)break;this.checkLimit("maxUncompressedSize",a+e.length),a+=e.length,r.push(e)}return this.checkLimit("maxUncompressedSize",a),KI(r)}catch(t){if(await i.cancel(t).catch(()=>{}),t instanceof FI)throw t;if(t instanceof Error&&"code"in t&&"ERR_TRAILING_JUNK_AFTER_STREAM_END"===t.code)return KI(r);const e=t instanceof Error?`Failed to deflate ZIP entry: ${t.message}`:"Unknown decompression error in ZIP entry";throw new TypeError(e)}finally{i.releaseLock()}}async readLocalFileHeader(){const t=await this.tokenizer.peekToken(oI);if(t===DI){const t=await this.readToken(HI);return t.filename=await this.readToken(new lI(t.filenameLength,"utf-8")),t}if(t===$I||t===jI)return!1;if(3759263696===t)throw new Error("Encrypted ZIP");throw new Error("Unexpected signature")}}function XI(t,e,n){for(let i=0;i<=t.length-(n?4:GI.len);i++)if(oI.get(t,i)===NI&&(t.length-i<12||oI.get(t,i+8)===e+i))return i;return-1}function KI(t){const e=t.reduce((t,e)=>t+e.length,0),n=new Uint8Array(e);let i=0;for(const e of t)n.set(e,i),i+=e.length;return n}const QI=Object.prototype.toString;function tS(t,e,n){return!!t&&(t.constructor===e||QI.call(t)===n)}function eS(t){return tS(t,ArrayBuffer,"[object ArrayBuffer]")}function nS(t){return function(t){return tS(t,Uint8Array,"[object Uint8Array]")}(t)||eS(t)}function iS(t){return eS(t)?new Uint8Array(t):t}function rS(t){if(!nS(t))throw new TypeError(`Expected \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof t}\``)}function aS(t){const{byteLength:e}=t;return 6===e?t.getUint16(0)*2**32+t.getUint32(2):5===e?t.getUint8(0)*2**32+t.getUint32(1):4===e?t.getUint32(0):3===e?65536*t.getUint8(0)+t.getUint16(1):2===e?t.getUint16(0):1===e?t.getUint8(0):void 0}function oS(t,e){if("utf-16le"===e){const e=[];for(let n=0;n<t.length;n++){const i=t.charCodeAt(n);e.push(255&i,i>>8&255)}return e}if("utf-16be"===e){const e=[];for(let n=0;n<t.length;n++){const i=t.charCodeAt(n);e.push(i>>8&255,255&i)}return e}return[...t].map(t=>t.charCodeAt(0))}new globalThis.TextDecoder("utf8"),new globalThis.TextEncoder,Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));const sS={get:(t,e)=>127&t[e+3]|(127&t[e+2])<<7|(127&t[e+1])<<14|(127&t[e])<<21,len:4},hS=16777216;class cS extends Error{}function lS(t,e,n){if(!Number.isFinite(t)||t<0||t>e)throw new cS(`${n} has invalid size ${t} (maximum ${e} bytes)`);return t}async function fS(t,e,{maximumLength:n=16777216,reason:i="skip"}={}){const r=lS(e,n,i);await t.ignore(r)}async function uS(t,e,n,{maximumLength:i=e.length,reason:r="read"}={}){const a=lS(e.length,i,r);return t.readBuffer(e,{...n,length:a})}function dS(t,e,n){n={offset:0,...n};for(const[i,r]of e.entries())if(n.mask){if(r!==(n.mask[i]&t[i+n.offset]))return!1}else if(r!==t[i+n.offset])return!1;return!0}function pS(t){const e=t.fileInfo.size;return!Number.isFinite(e)||e===Number.MAX_SAFE_INTEGER}function mS(t,e,n){return pS(t)&&t.position-e>n}const gS=1048576,bS=gS,wS=new Set(["Unexpected signature","Encrypted ZIP","Expected Central-File-Header signature"]),yS=["Unsupported ZIP compression method:","Expected data-descriptor-signature at position "],_S=new Set(["Z_BUF_ERROR","Z_DATA_ERROR","ERR_INVALID_STATE"]);function vS(t,e=1048576){const n=[t.compressedSize,t.uncompressedSize];for(const t of n)if(!Number.isFinite(t)||t<0||t>e)return!1;return!0}function xS(t){if(t.hasDocumentEntry)return t.hasMasterSlideEntry?{ext:"key",mime:"application/vnd.apple.keynote"}:t.hasTablesEntry?{ext:"numbers",mime:"application/vnd.apple.numbers"}:{ext:"pages",mime:"application/vnd.apple.pages"}}function kS(t){switch(t=t.toLowerCase()){case"application/epub+zip":return{ext:"epub",mime:t};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:t};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:t};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:t};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:t};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:t};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:t};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:t};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:t};case"application/vnd.openxmlformats-officedocument.presentationml.slideshow":return{ext:"ppsx",mime:t};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:t};case"application/vnd.ms-excel.sheet.macroenabled":return{ext:"xlsm",mime:"application/vnd.ms-excel.sheet.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.spreadsheetml.template":return{ext:"xltx",mime:t};case"application/vnd.ms-excel.template.macroenabled":return{ext:"xltm",mime:"application/vnd.ms-excel.template.macroenabled.12"};case"application/vnd.ms-powerpoint.slideshow.macroenabled":return{ext:"ppsm",mime:"application/vnd.ms-powerpoint.slideshow.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return{ext:"docx",mime:t};case"application/vnd.ms-word.document.macroenabled":return{ext:"docm",mime:"application/vnd.ms-word.document.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.template":return{ext:"dotx",mime:t};case"application/vnd.ms-word.template.macroenabledtemplate":return{ext:"dotm",mime:"application/vnd.ms-word.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.template":return{ext:"potx",mime:t};case"application/vnd.ms-powerpoint.template.macroenabled":return{ext:"potm",mime:"application/vnd.ms-powerpoint.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.presentation":return{ext:"pptx",mime:t};case"application/vnd.ms-powerpoint.presentation.macroenabled":return{ext:"pptm",mime:"application/vnd.ms-powerpoint.presentation.macroenabled.12"};case"application/vnd.ms-visio.drawing":return{ext:"vsdx",mime:"application/vnd.visio"};case"application/vnd.ms-package.3dmanufacturing-3dmodel+xml":return{ext:"3mf",mime:"model/3mf"}}}function AS(t){return t.hasWordDirectory?{ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}:t.hasPresentationDirectory?{ext:"pptx",mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation"}:t.hasSpreadsheetDirectory?{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}:t.hasThreeDimensionalModelEntry?{ext:"3mf",mime:"model/3mf"}:void 0}function MS(t){if(t.hasContentTypesEntry&&!t.hasUnparseableContentTypes&&!t.isParsingContentTypes&&!t.hasParsedContentTypesEntry)return AS(t)}async function ES(t){let e;const n={hasContentTypesEntry:!1,hasParsedContentTypesEntry:!1,isParsingContentTypes:!1,hasUnparseableContentTypes:!1,hasWordDirectory:!1,hasPresentationDirectory:!1,hasSpreadsheetDirectory:!1,hasThreeDimensionalModelEntry:!1},i={hasDocumentEntry:!1,hasMasterSlideEntry:!1,hasTablesEntry:!1,hasCalculationEngineEntry:!1};try{await new YI(t,{useCentralDirectory:!1,allowTruncatedDataDescriptor:!0,maxEntryCount:1024,maxTotalScanBytes:pS(t)?hS:1/0,maxTotalDataDescriptorScanBytes:pS(t)?1/0:gS,maxSkippedEntrySize:pS(t)?gS:1/0,maxDataDescriptorScanBytes:gS,maxCompressedSize:bS,maxUncompressedSize:bS}).unzip(t=>{if(function(t,e){e.startsWith("word/")&&(t.hasWordDirectory=!0),e.startsWith("ppt/")&&(t.hasPresentationDirectory=!0),e.startsWith("xl/")&&(t.hasSpreadsheetDirectory=!0),e.startsWith("3D/")&&e.endsWith(".model")&&(t.hasThreeDimensionalModelEntry=!0)}(n,t.filename),function(t,e){"Index/Document.iwa"===e&&(t.hasDocumentEntry=!0),e.startsWith("Index/MasterSlide")&&(t.hasMasterSlideEntry=!0),e.startsWith("Index/Tables/")&&(t.hasTablesEntry=!0),"Index/CalculationEngine.iwa"===e&&(t.hasCalculationEngineEntry=!0)}(i,t.filename),i.hasDocumentEntry&&(i.hasMasterSlideEntry||i.hasTablesEntry))return e=xS(i),{stop:!0};const r="[Content_Types].xml"===t.filename,a=MS(n);if(!r&&a)return e=a,{stop:!0};switch(t.filename){case"META-INF/mozilla.rsa":return e={ext:"xpi",mime:"application/x-xpinstall"},{stop:!0};case"META-INF/MANIFEST.MF":return e={ext:"jar",mime:"application/java-archive"},{stop:!0};case"mimetype":return vS(t,bS)?{async handler(t){const n=new TextDecoder("utf-8").decode(t).trim();e=kS(n)},stop:!0}:{};case"[Content_Types].xml":return n.hasContentTypesEntry=!0,vS(t,bS)?(n.isParsingContentTypes=!0,{async handler(t){const i=function(t){const e=t.indexOf('.main+xml"');if(-1===e){const e="application/vnd.ms-package.3dmanufacturing-3dmodel+xml";return t.includes(`ContentType="${e}"`)?e:void 0}const n=t.slice(0,e),i=n.lastIndexOf('"');return n.slice(i+1)}(new TextDecoder("utf-8").decode(t));i&&(e=kS(i)),n.hasParsedContentTypesEntry=!0,n.isParsingContentTypes=!1},stop:!0}):(n.hasUnparseableContentTypes=!0,{});default:return/classes\d*\.dex/v.test(t.filename)?(e={ext:"apk",mime:"application/vnd.android.package-archive"},{stop:!0}):{}}})}catch(t){if(!function(t){if(t instanceof fI)return!0;if(t instanceof cS||t instanceof FI)return!0;if(!(t instanceof Error))return!1;if(t instanceof TypeError&&t.message.startsWith("Failed to deflate ZIP entry:"))return!0;if(wS.has(t.message))return!0;if(_S.has(t.code))return!0;for(const e of yS)if(t.message.startsWith(e))return!0;return!1}(t))throw t;n.isParsingContentTypes&&(n.isParsingContentTypes=!1,n.hasUnparseableContentTypes=!0),e||!(t instanceof fI||t instanceof cS||function(t){return t instanceof FI&&["maxTotalScanBytes","maxTotalDataDescriptorScanBytes","maxDataDescriptorScanBytes","maxSkippedEntrySize"].includes(t.limit)}(t))||n.hasContentTypesEntry||(e=AS(n))}const r=!pS(t)||!i.hasDocumentEntry||i.hasMasterSlideEntry||i.hasTablesEntry||i.hasCalculationEngineEntry?xS(i):void 0;return e??MS(n)??r??{ext:"zip",mime:"application/zip"}}const IS=1048576;const SS=1048576;function zS(t){return!!(32&t.codePointAt(0))}const BS=1048576;const CS=4100,PS=hS,TS=hS,US=hS;function OS(t){return Number.isFinite(t)?Math.max(1,Math.trunc(t)):CS}function LS(t,e){return void 0===e?t.read():(e.throwIfAborted(),Promise.race([t.read(),new Promise((n,i)=>{e.addEventListener("abort",()=>{i(e.reason),t.cancel(e.reason).catch(()=>{})},{once:!0})})]))}class RS{buffer;tokenizer;detectionReentryCount;constructor(t){const e=(n=t?.mpegOffsetTolerance,Number.isFinite(n)?Math.max(0,Math.min(4096,Math.trunc(n))):0);var n;const i=t?.maxBufferSize??1/0;if(i!==1/0&&(!Number.isSafeInteger(i)||i<=0))throw new RangeError("maxBufferSize must be a positive safe integer or Infinity");this.options={...t,mpegOffsetTolerance:e},this.detectors=[...this.options.customDetectors??[],{id:"core",detect:t=>this.detectConfident(t)},{id:"core.imprecise",detect:t=>this.detectImprecise(t)}],this.tokenizerOptions={abortSignal:this.options.signal,maxBufferSize:i},this.gzipProbeDepth=0}getTokenizerOptions(){return{...this.tokenizerOptions}}createTokenizerFromWebStream(t){return BI(function(t){return t.pipeThrough(new TransformStream)}(t),this.getTokenizerOptions())}async parseTokenizer(t,e=0){this.detectionReentryCount=e;const n=t.position;for(const e of this.detectors){let i;try{i=await e.detect(t)}catch(t){if(t instanceof fI)return;if(t instanceof cS)return;throw t}if(i)return i;if(n!==t.position)return}}async fromTokenizer(t){try{return await this.parseTokenizer(t)}finally{await t.close()}}async fromBuffer(t){if(!(t instanceof Uint8Array||t instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof t}\``);const e=t instanceof Uint8Array?t:new Uint8Array(t);var n,i;if(e?.length>1)return this.fromTokenizer((n=e,i=this.getTokenizerOptions(),new xI(n,i)))}async fromBlob(t){this.options.signal?.throwIfAborted();const e=function(t,e){return new vI(t,e)}(t,this.getTokenizerOptions());return this.fromTokenizer(e)}async fromStream(t){this.options.signal?.throwIfAborted();const e=this.createTokenizerFromWebStream(t);return this.fromTokenizer(e)}async fromFile(t){this.options.signal?.throwIfAborted();const{fromFile:e,NotRegularFileError:n}=await(i="strtok3",import(i));var i;let r;try{r=await e(t,{...this.getTokenizerOptions(),regularFileOnly:!0})}catch(t){if(t instanceof n)return;throw t}return this.fromTokenizer(r)}async toDetectionStream(t,e){this.options.signal?.throwIfAborted();const n=OS(e?.sampleSize??CS);let i,r=!1;const a=t.getReader(),o=[];let s=0;try{for(;s<n;){const{value:t,done:e}=await LS(a,this.options.signal);if(e||!t){r=!0;break}o.push(t),s+=t.length}if(!r&&s===n){const{value:t,done:e}=await LS(a,this.options.signal);e||!t?r=!0:(o.push(t),s+=t.length)}}finally{a.releaseLock()}if(s>0){const t=1===o.length?o[0]:function(t,e){if(0===t.length)return new Uint8Array(0);e??=t.reduce((t,e)=>t+e.byteLength,0);const n=new Uint8Array(e);let i=0;for(let e of t)rS(e),e=iS(e),n.set(e,i),i+=e.length;return n}(o);try{i=await this.fromBuffer(t.subarray(0,n))}catch(t){if(!(t instanceof fI))throw t;i=void 0}r||"pages"!==i?.ext||(i={ext:"zip",mime:"application/zip"})}const h=new TransformStream({start(t){for(const e of o)t.enqueue(e)},transform(t,e){e.enqueue(t)}}),c=t.pipeThrough(h);return c.fileType=i,c}async detectGzip(t){if(this.gzipProbeDepth>=1)return{ext:"gz",mime:"application/gzip"};const e=function(t,e){const n=t.getReader();let i=0,r=!1,a=!1;const o=async t=>{r||a||(a=!0,await n.cancel(t))};return new ReadableStream({async pull(t){if(i>=e)return t.close(),void await o();const{done:a,value:s}=await n.read();if(a||!s)return r=!0,void t.close();const h=e-i;if(s.length>h)return t.enqueue(s.subarray(0,h)),i+=h,t.close(),void await o();t.enqueue(s),i+=s.length},async cancel(t){await o(t)}})}(new CI(t).inflate(),PS),n=pS(t);let i,r,a,o;if(n){const t=new AbortController;i=setTimeout(()=>{t.abort(new DOMException("Operation timed out after 100 ms","TimeoutError"))},100),r=void 0===this.options.signal?t.signal:AbortSignal.any([this.options.signal,t.signal]),a=new RS({...this.options,signal:r}),a.gzipProbeDepth=this.gzipProbeDepth+1}else this.gzipProbeDepth++;try{o=await(a??this).fromStream(e)}catch(t){if("AbortError"===t?.name&&"TimeoutError"!==r?.reason?.name)throw t}finally{clearTimeout(i),n||this.gzipProbeDepth--}return"tar"===o?.ext?{ext:"tar.gz",mime:"application/gzip"}:{ext:"gz",mime:"application/gzip"}}check(t,e){return dS(this.buffer,t,e)}checkString(t,e){return this.check(oS(t,e?.encoding),e)}async detectConfident(t){if(this.buffer=new Uint8Array(CS),void 0===t.fileInfo.size&&(t.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=t,pS(t)&&(await t.peekBuffer(this.buffer,{length:3,mayBeLess:!0}),this.check([31,139,8])))return this.detectGzip(t);if(await t.peekBuffer(this.buffer,{length:32,mayBeLess:!0}),this.check([66,77]))return{ext:"bmp",mime:"image/bmp"};if(this.check([11,119]))return{ext:"ac3",mime:"audio/vnd.dolby.dd-raw"};if(this.check([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(this.check([77,90]))return{ext:"exe",mime:"application/x-msdownload"};if(this.check([37,33]))return await t.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString("PS-Adobe-",{offset:2})&&this.checkString(" EPSF-",{offset:14})?{ext:"eps",mime:"application/eps"}:{ext:"ps",mime:"application/postscript"};if(this.check([31,160])||this.check([31,157]))return{ext:"Z",mime:"application/x-compress"};if(this.check([199,113]))return{ext:"cpio",mime:"application/x-cpio"};if(this.check([96,234]))return{ext:"arj",mime:"application/x-arj"};if(this.check([239,187,191])){if(this.detectionReentryCount>=256)return;return this.detectionReentryCount++,await this.tokenizer.ignore(3),this.detectConfident(t)}if(this.check([71,73,70]))return{ext:"gif",mime:"image/gif"};if(this.check([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(this.check([31,139,8]))return this.detectGzip(t);if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await fS(t,6,{maximumLength:6,reason:"ID3 header prefix"});const e=await t.readToken(sS),n=pS(t);if(!Number.isFinite(e)||e<0||n&&(e>TS||t.position+e>TS))return;if(t.position+e>t.fileInfo.size){if(n)return;return{ext:"mp3",mime:"audio/mpeg"}}try{await fS(t,e,{maximumLength:n?TS:t.fileInfo.size,reason:"ID3 payload"})}catch(t){if(t instanceof fI)return;throw t}if(this.detectionReentryCount>=256)return;return this.detectionReentryCount++,this.parseTokenizer(t,this.detectionReentryCount)}if(this.checkString("MP+"))return{ext:"mpc",mime:"audio/x-musepack"};if((67===this.buffer[0]||70===this.buffer[0])&&this.check([87,83],{offset:1}))return{ext:"swf",mime:"application/x-shockwave-flash"};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:"jls",mime:"image/jls"}:{ext:"jpg",mime:"image/jpeg"};if(this.check([79,98,106,1]))return{ext:"avro",mime:"application/avro"};if(this.checkString("FLIF"))return{ext:"flif",mime:"image/flif"};if(this.checkString("8BPS"))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(this.checkString("MPCK"))return{ext:"mpc",mime:"audio/x-musepack"};if(this.checkString("FORM"))return{ext:"aif",mime:"audio/aiff"};if(this.checkString("caff")&&this.check([0,1],{offset:4})&&this.checkString("desc",{offset:8}))return{ext:"caf",mime:"audio/x-caf"};if(this.checkString("icns",{offset:0}))return{ext:"icns",mime:"image/icns"};if(this.check([80,75,3,4]))return ES(t);if(this.checkString("OggS")){await t.ignore(28);const e=new Uint8Array(8);return await t.readBuffer(e),dS(e,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:dS(e,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:dS(e,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:dS(e,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:dS(e,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:dS(e,[1,118,111,114,98,105,115])?{ext:"ogg",mime:"audio/ogg"}:{ext:"ogx",mime:"application/ogg"}}if(this.check([80,75])&&[3,5,7].includes(this.buffer[2])&&[4,6,8].includes(this.buffer[3]))return{ext:"zip",mime:"application/zip"};if(this.checkString("MThd"))return{ext:"mid",mime:"audio/midi"};if(this.checkString("wOFF")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff",mime:"font/woff"};if(this.checkString("wOF2")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff2",mime:"font/woff2"};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:"pcap",mime:"application/vnd.tcpdump.pcap"};if(this.checkString("DSD "))return{ext:"dsf",mime:"audio/x-dsf"};if(this.checkString("LZIP"))return{ext:"lz",mime:"application/lzip"};if(this.checkString("fLaC"))return{ext:"flac",mime:"audio/flac"};if(this.check([66,80,71,251]))return{ext:"bpg",mime:"image/bpg"};if(this.checkString("wvpk"))return{ext:"wv",mime:"audio/wavpack"};if(this.checkString("%PDF"))return{ext:"pdf",mime:"application/pdf"};if(this.check([0,97,115,109]))return{ext:"wasm",mime:"application/wasm"};if(this.check([73,73])){const t=await this.readTiffHeader(!1);if(t)return t}if(this.check([77,77])){const t=await this.readTiffHeader(!0);if(t)return t}if(this.checkString("MAC "))return{ext:"ape",mime:"audio/ape"};if(this.check([26,69,223,163]))return async function(t){async function e(t){const e=await t.peekNumber(iI);let n=128,i=0;for(;0!==n&&0===(e&n);)++i,n>>=1;const r=new Uint8Array(i+1);return await uS(t,r,void 0,{maximumLength:r.length,reason:"EBML field"}),r}async function n(t){const n=await e(t),i=await e(t);i[0]^=128>>i.length-1;const r=Math.min(6,i.length),a=new DataView(n.buffer),o=new DataView(i.buffer,i.length-r,r);return{id:aS(a),len:aS(o)}}const i=pS(t),r=await n(t),a=t.position,o=II(t,r.len);let s;try{s=await async function(e){let r=0;for(;e.remaining>0;){if(r++,r>256)return;if(mS(t,a,hS))return;const o=t.position,s=await n(e);if(17026===s.id){if(s.len>64)return;const t=lS(s.len,64,"EBML DocType");return(await e.readToken(new lI(t))).split("\0",1)[0]}if(i&&(!Number.isFinite(s.len)||s.len<0||s.len>IS))return;if(await fS(e,s.len,{maximumLength:i?IS:t.fileInfo.size,reason:"EBML payload"}),t.position<=o)return}}(o)}catch(t){if(t instanceof MI)return;throw t}finally{await o.close()}switch(s){case"webm":return{ext:"webm",mime:"video/webm"};case"matroska":return{ext:"mkv",mime:"video/matroska"}}}(t);if(this.checkString("SQLi"))return{ext:"sqlite",mime:"application/x-sqlite3"};if(this.check([78,69,83,26]))return{ext:"nes",mime:"application/x-nintendo-nes-rom"};if(this.checkString("Cr24"))return{ext:"crx",mime:"application/x-google-chrome-extension"};if(this.checkString("MSCF")||this.checkString("ISc("))return{ext:"cab",mime:"application/vnd.ms-cab-compressed"};if(this.check([237,171,238,219]))return{ext:"rpm",mime:"application/x-rpm"};if(this.check([197,208,211,198]))return{ext:"eps",mime:"application/eps"};if(this.check([40,181,47,253]))return{ext:"zst",mime:"application/zstd"};if(this.check([127,69,76,70]))return{ext:"elf",mime:"application/x-elf"};if(this.check([33,66,68,78]))return{ext:"pst",mime:"application/vnd.ms-outlook"};if(this.checkString("PAR1")||this.checkString("PARE"))return{ext:"parquet",mime:"application/vnd.apache.parquet"};if(this.checkString("ttcf"))return{ext:"ttc",mime:"font/collection"};if(this.check([254,237,250,206])||this.check([254,237,250,207])||this.check([206,250,237,254])||this.check([207,250,237,254]))return{ext:"macho",mime:"application/x-mach-binary"};if(this.check([4,34,77,24]))return{ext:"lz4",mime:"application/x-lz4"};if(this.checkString("regf"))return{ext:"dat",mime:"application/x-ft-windows-registry-hive"};if(this.checkString("$FL2")||this.checkString("$FL3"))return{ext:"sav",mime:"application/x-spss-sav"};if(this.check([79,84,84,79,0]))return{ext:"otf",mime:"font/otf"};if(this.checkString("#!AMR"))return{ext:"amr",mime:"audio/amr"};if(this.checkString(String.raw`{\rtf`))return{ext:"rtf",mime:"application/rtf"};if(this.check([70,76,86,1]))return{ext:"flv",mime:"video/x-flv"};if(this.checkString("IMPM"))return{ext:"it",mime:"audio/x-it"};if(this.checkString("-lh0-",{offset:2})||this.checkString("-lh1-",{offset:2})||this.checkString("-lh2-",{offset:2})||this.checkString("-lh3-",{offset:2})||this.checkString("-lh4-",{offset:2})||this.checkString("-lh5-",{offset:2})||this.checkString("-lh6-",{offset:2})||this.checkString("-lh7-",{offset:2})||this.checkString("-lzs-",{offset:2})||this.checkString("-lz4-",{offset:2})||this.checkString("-lz5-",{offset:2})||this.checkString("-lhd-",{offset:2}))return{ext:"lzh",mime:"application/x-lzh-compressed"};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:"mpg",mime:"video/MP1S"};if(this.check([68],{offset:4,mask:[196]}))return{ext:"mpg",mime:"video/MP2P"}}if(this.checkString("ITSF"))return{ext:"chm",mime:"application/vnd.ms-htmlhelp"};if(this.check([202,254,186,190])){const t=sI.get(this.buffer,4);if(t>0&&t<=30)return{ext:"macho",mime:"application/x-mach-binary"};if(aI.get(this.buffer,6)>30)return{ext:"class",mime:"application/java-vm"}}if(this.checkString(".RMF"))return{ext:"rm",mime:"application/vnd.rn-realmedia"};if(this.checkString("DRACO"))return{ext:"drc",mime:"application/x-ft-draco"};if(this.check([253,55,122,88,90,0]))return{ext:"xz",mime:"application/x-xz"};if(this.checkString("<?xml "))return{ext:"xml",mime:"application/xml"};if(this.check([55,122,188,175,39,28]))return{ext:"7z",mime:"application/x-7z-compressed"};if(this.check([82,97,114,33,26,7])&&(0===this.buffer[6]||1===this.buffer[6]))return{ext:"rar",mime:"application/x-rar-compressed"};if(this.checkString("solid "))return{ext:"stl",mime:"model/stl"};if(this.checkString("AC")){const t=new lI(4,"latin1").get(this.buffer,2);if(/^\d+$/v.test(t)&&t>=1e3&&t<=1050)return{ext:"dwg",mime:"image/vnd.dwg"}}if(this.checkString("070707"))return{ext:"cpio",mime:"application/x-cpio"};if(this.checkString("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(this.checkString("!<arch>")){await t.ignore(8);return"debian-binary"===await t.readToken(new lI(13,"ascii"))?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"}}if(this.checkString("WEBVTT")&&["\n","\r","\t"," ","\0"].some(t=>this.checkString(t,{offset:6})))return{ext:"vtt",mime:"text/vtt"};if(this.check([137,80,78,71,13,10,26,10]))return async function(t){const e={ext:"png",mime:"image/png"},n={ext:"apng",mime:"image/apng"};async function i(){return{length:await t.readToken(hI),type:await t.readToken(new lI(4,"latin1"))}}await t.ignore(8);const r=pS(t),a=t.position;let o=0,s=!1;do{if(o++,o>512)break;if(mS(t,a,16777216))break;const h=t.position,c=await i();if(c.length<0)return;if("IHDR"===c.type){if(13!==c.length)return;s=!0}switch(c.type){case"IDAT":return e;case"acTL":return n;default:if(!s&&"CgBI"!==c.type)return;if(r&&c.length>SS)return s&&zS(c.type)?e:void 0;try{await fS(t,c.length+4,{maximumLength:r?1048580:t.fileInfo.size,reason:"PNG chunk payload"})}catch(t){if(!r&&(t instanceof cS||t instanceof fI))return e;throw t}}if(t.position<=h)break}while(t.position+8<t.fileInfo.size);return e}(t);if(this.check([65,82,82,79,87,49,0,0]))return{ext:"arrow",mime:"application/vnd.apache.arrow.file"};if(this.check([103,108,84,70,2,0,0,0]))return{ext:"glb",mime:"model/gltf-binary"};if(this.check([102,114,101,101],{offset:4})||this.check([109,100,97,116],{offset:4})||this.check([109,111,111,118],{offset:4})||this.check([119,105,100,101],{offset:4}))return{ext:"mov",mime:"video/quicktime"};if(this.check([73,73,82,79,8,0,0,0,24]))return{ext:"orf",mime:"image/x-olympus-orf"};if(this.checkString("gimp xcf "))return{ext:"xcf",mime:"image/x-xcf"};if(this.checkString("ftyp",{offset:4})&&96&this.buffer[8]){const t=new lI(4,"latin1").get(this.buffer,8).replace("\0"," ").trim();switch(t){case"avif":case"avis":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 t.startsWith("3g")?t.startsWith("3g2")?{ext:"3g2",mime:"video/3gpp2"}:{ext:"3gp",mime:"video/3gpp"}:{ext:"mp4",mime:"video/mp4"}}}if(this.checkString("REGEDIT4\r\n"))return{ext:"reg",mime:"application/x-ms-regedit"};if(this.check([82,73,70,70])){if(this.checkString("WEBP",{offset:8}))return{ext:"webp",mime:"image/webp"};if(this.check([65,86,73],{offset:8}))return{ext:"avi",mime:"video/vnd.avi"};if(this.check([87,65,86,69],{offset:8}))return{ext:"wav",mime:"audio/wav"};if(this.check([81,76,67,77],{offset:8}))return{ext:"qcp",mime:"audio/qcelp"}}if(this.check([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:"rw2",mime:"image/x-panasonic-rw2"};if(this.check([48,38,178,117,142,102,207,17,166,217]))return async function(t){let e=!1;try{async function n(){const e=new Uint8Array(16);return await uS(t,e,void 0,{maximumLength:e.length,reason:"ASF header GUID"}),{id:e,size:Number(await t.readToken(cI))}}await fS(t,30,{maximumLength:30,reason:"ASF header prelude"});const i=pS(t),r=t.position;let a=0;for(;t.position+24<t.fileInfo.size&&(a++,!(a>512))&&!mS(t,r,hS);){const o=t.position,s=await n();let h=s.size-24;if(!Number.isFinite(h)||h<0){e=!0;break}if(dS(s.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){const c=new Uint8Array(16);if(h-=await uS(t,c,void 0,{maximumLength:c.length,reason:"ASF stream type GUID"}),dS(c,[64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"audio/x-ms-asf"};if(dS(c,[192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"video/x-ms-asf"};break}if(i&&h>BS){e=!0;break}if(await fS(t,h,{maximumLength:i?BS:t.fileInfo.size,reason:"ASF header payload"}),t.position<=o){e=!0;break}}}catch(l){if(!(l instanceof fI||l instanceof cS))throw l;pS(t)&&(e=!0)}if(!e)return{ext:"asf",mime:"application/vnd.ms-asf"}}(t);if(this.check([171,75,84,88,32,49,49,187,13,10,26,10]))return{ext:"ktx",mime:"image/ktx"};if((this.check([126,16,4])||this.check([126,24,4]))&&this.check([48,77,73,69],{offset:4}))return{ext:"mie",mime:"application/x-mie"};if(this.check([39,10,0,0,0,0,0,0,0,0,0,0],{offset:2}))return{ext:"shp",mime:"application/x-esri-shape"};if(this.check([255,79,255,81]))return{ext:"j2c",mime:"image/j2c"};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10])){await t.ignore(20);switch(await t.readToken(new lI(4,"ascii"))){case"jp2 ":return{ext:"jp2",mime:"image/jp2"};case"jpx ":return{ext:"jpx",mime:"image/jpx"};case"jpm ":return{ext:"jpm",mime:"image/jpm"};case"mjp2":return{ext:"mj2",mime:"image/mj2"};default:return}}if(this.check([255,10])||this.check([0,0,0,12,74,88,76,32,13,10,135,10]))return{ext:"jxl",mime:"image/jxl"};if(this.check([254,255]))return this.checkString("<?xml ",{offset:2,encoding:"utf-16be"})?{ext:"xml",mime:"application/xml"}:void 0;if(this.check([208,207,17,224,161,177,26,225]))return{ext:"cfb",mime:"application/x-cfb"};if(this.checkString("FRM8")&&this.checkString("DSD ",{offset:12}))return{ext:"dff",mime:"audio/x-dff"};if(await t.peekBuffer(this.buffer,{length:Math.min(256,t.fileInfo.size),mayBeLess:!0}),this.check([97,99,115,112],{offset:36}))return{ext:"icc",mime:"application/vnd.iccprofile"};if(this.checkString("**ACE",{offset:7})&&this.checkString("**",{offset:12}))return{ext:"ace",mime:"application/x-ace-compressed"};if(this.checkString("BEGIN:")){if(this.checkString("VCARD",{offset:6}))return{ext:"vcf",mime:"text/vcard"};if(this.checkString("VCALENDAR",{offset:6}))return{ext:"ics",mime:"text/calendar"}}if(this.checkString("FUJIFILMCCD-RAW"))return{ext:"raf",mime:"image/x-fujifilm-raf"};if(this.checkString("Extended Module:"))return{ext:"xm",mime:"audio/x-xm"};if(this.checkString("Creative Voice File"))return{ext:"voc",mime:"audio/x-voc"};if(this.check([4,0,0,0])&&this.buffer.length>=16){const t=new DataView(this.buffer.buffer).getUint32(12,!0);if(t>12&&this.buffer.length>=t+16)try{const e=(new TextDecoder).decode(this.buffer.subarray(16,t+16));if(JSON.parse(e).files)return{ext:"asar",mime:"application/x-asar"}}catch{}}if(this.check([6,14,43,52,2,5,1,1,13,1,2,1,1,2]))return{ext:"mxf",mime:"application/mxf"};if(this.checkString("SCRM",{offset:44}))return{ext:"s3m",mime:"audio/x-s3m"};if(this.check([71])&&this.check([71],{offset:188}))return{ext:"mts",mime:"video/mp2t"};if(this.check([71],{offset:4})&&this.check([71],{offset:196}))return{ext:"mts",mime:"video/mp2t"};if(this.check([66,79,79,75,77,79,66,73],{offset:60}))return{ext:"mobi",mime:"application/x-mobipocket-ebook"};if(this.check([68,73,67,77],{offset:128}))return{ext:"dcm",mime:"application/dicom"};if(this.check([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(this.check([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0]))return{ext:"alias",mime:"application/x-ft-apple.alias"};if(this.checkString("Kaydara FBX Binary  \0"))return{ext:"fbx",mime:"application/x-ft-fbx"};if(this.check([76,80],{offset:34})&&(this.check([0,0,1],{offset:8})||this.check([1,0,2],{offset:8})||this.check([2,0,2],{offset:8})))return{ext:"eot",mime:"application/vnd.ms-fontobject"};if(this.check([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29]))return{ext:"indd",mime:"application/x-indesign"};if(this.check([255,255,0,0,7,0,0,0,4,0,0,0,1,0,1,0])||this.check([0,0,255,255,0,0,0,7,0,0,0,4,0,1,0,1]))return{ext:"jmp",mime:"application/x-jmp-data"};if(await t.peekBuffer(this.buffer,{length:Math.min(512,t.fileInfo.size),mayBeLess:!0}),this.checkString("ustar",{offset:257})&&(this.checkString("\0",{offset:262})||this.checkString(" ",{offset:262}))||this.check([0,0,0,0,0,0],{offset:257})&&function(t,e=0){const n=Number.parseInt(new lI(6).get(t,148),8);if(Number.isNaN(n))return!1;let i=256;for(let n=e;n<e+148;n++)i+=t[n];for(let n=e+156;n<e+512;n++)i+=t[n];return n===i}(this.buffer))return{ext:"tar",mime:"application/x-tar"};if(this.check([255,254])){const t="utf-16le";return this.checkString("<?xml ",{offset:2,encoding:t})?{ext:"xml",mime:"application/xml"}:this.check([255,14],{offset:2})&&this.checkString("SketchUp Model",{offset:4,encoding:t})?{ext:"skp",mime:"application/vnd.sketchup.skp"}:this.checkString("Windows Registry Editor Version 5.00\r\n",{offset:2,encoding:t})?{ext:"reg",mime:"application/x-ms-regedit"}:void 0}if(this.checkString("-----BEGIN PGP MESSAGE-----"))return{ext:"pgp",mime:"application/pgp-encrypted"};if(t.supportsRandomAccess()&&t.fileInfo.size>=32774){const e=new Uint8Array(5);if(await t.peekBuffer(e,{position:32769,length:5,mayBeLess:!0}),dS(e,oS("CD001")))return{ext:"iso",mime:"application/x-iso9660-image"}}}async detectImprecise(t){this.buffer=new Uint8Array(CS);const e=function(t){return Number.isFinite(t)?Math.max(0,t):Number.MAX_SAFE_INTEGER}(t.fileInfo.size);if(await t.peekBuffer(this.buffer,{length:Math.min(8,e),mayBeLess:!0}),this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};if(this.check([0,1,0,0,0]))return{ext:"ttf",mime:"font/ttf"};if(this.check([0,0,1,0]))return{ext:"ico",mime:"image/x-icon"};if(this.check([0,0,2,0]))return{ext:"cur",mime:"image/x-icon"};if(await t.peekBuffer(this.buffer,{length:Math.min(4+this.options.mpegOffsetTolerance,e),mayBeLess:!0}),this.buffer.length>=4+this.options.mpegOffsetTolerance)for(let t=0;t<=this.options.mpegOffsetTolerance;++t){const e=this.scanMpeg(t);if(e)return e}}async readTiffTag(t){const e=await this.tokenizer.readToken(t?aI:rI);switch(await this.tokenizer.ignore(10),e){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"}}}async readTiffIFD(t){const e=await this.tokenizer.readToken(t?aI:rI);if(!(e>512||pS(this.tokenizer)&&2+12*e>US))for(let n=0;n<e;++n){const e=await this.readTiffTag(t);if(e)return e}}async readTiffHeader(t){const e={ext:"tif",mime:"image/tiff"},n=(t?aI:rI).get(this.buffer,2),i=(t?sI:oI).get(this.buffer,4);if(42===n){if(i>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(i>=8){const e=(t?aI:rI).get(this.buffer,8),n=(t?aI:rI).get(this.buffer,10);if(28===e&&254===n||31===e&&11===n)return{ext:"nef",mime:"image/x-nikon-nef"}}}if(pS(this.tokenizer)&&i>1048576)return e;const n=pS(this.tokenizer)?US:this.tokenizer.fileInfo.size;try{await fS(this.tokenizer,i,{maximumLength:n,reason:"TIFF IFD offset"})}catch(t){if(t instanceof fI)return;throw t}let r;try{r=await this.readTiffIFD(t)}catch(t){if(t instanceof fI)return;throw t}return r??e}if(43===n)return e}scanMpeg(t){if(this.check([255,224],{offset:t,mask:[255,224]})){if(this.check([16],{offset:t+1,mask:[22]}))return{ext:"aac",mime:"audio/aac"};if(this.check([255,254],{offset:t}))return;if(this.check([8],{offset:t+1,mask:[24]}))return;if(this.check([240],{offset:t+2,mask:[240]}))return;if(this.check([12],{offset:t+2,mask:[12]}))return;if(this.check([2],{offset:t+1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:t+1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:t+1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}}new Set(["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","elf","macho","exe","swf","rtf","wasm","woff","woff2","eot","ttf","otf","ttc","ico","flv","ps","xz","sqlite","nes","crx","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","blend","bpg","docx","pptx","xlsx","3gp","3g2","j2c","jp2","jpm","jpx","mj2","aif","caf","qcp","odt","ods","odp","xml","mobi","heic","cur","ktx","ape","wv","dcm","ics","glb","pcap","dsf","dff","lnk","alias","voc","ac3","m4v","m4p","m4b","f4v","f4p","f4b","f4a","mie","asf","ogm","ogx","mpc","arrow","shp","aac","mp1","it","s3m","xm","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf","jls","pst","dwg","parquet","class","arj","cpio","ace","avro","icc","fbx","vsdx","vtt","apk","drc","lz4","potx","xltx","dotx","xltm","ott","ots","otp","odg","otg","xlsm","docm","dotm","potm","pptm","jar","jmp","rm","sav","ppsm","ppsx","tar.gz","reg","dat","key","numbers","pages","iso"]),new Set(["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.ms-powerpoint.slideshow.macroenabled.12","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/vnd.openxmlformats-officedocument.presentationml.slideshow","application/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","application/vnd.apache.arrow.file","video/mp4","audio/midi","video/matroska","video/webm","video/quicktime","video/vnd.avi","audio/wav","audio/qcelp","audio/x-ms-asf","video/x-ms-asf","application/vnd.ms-asf","video/mpeg","video/3gpp","audio/mpeg","audio/mp4","video/ogg","audio/ogg","audio/ogg; codecs=opus","application/ogg","audio/flac","audio/ape","audio/wavpack","audio/amr","application/pdf","application/x-elf","application/x-mach-binary","application/x-msdownload","application/x-shockwave-flash","application/rtf","application/wasm","font/woff","font/woff2","application/vnd.ms-fontobject","font/ttf","font/otf","font/collection","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/lzip","application/x-cfb","application/x-mie","application/mxf","video/mp2t","application/x-blender","image/bpg","image/j2c","image/jp2","image/jpx","image/jpm","image/mj2","audio/aiff","audio/x-caf","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","text/vtt","model/gltf-binary","application/vnd.tcpdump.pcap","audio/x-dsf","audio/x-dff","application/x-ms-shortcut","application/x-ft-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","image/jls","application/vnd.ms-outlook","image/vnd.dwg","application/vnd.apache.parquet","application/java-vm","application/x-arj","application/x-cpio","application/x-ace-compressed","application/avro","application/vnd.iccprofile","application/x-ft-fbx","application/vnd.visio","application/vnd.android.package-archive","application/x-ft-draco","application/x-lz4","application/vnd.openxmlformats-officedocument.presentationml.template","application/vnd.openxmlformats-officedocument.spreadsheetml.template","application/vnd.openxmlformats-officedocument.wordprocessingml.template","application/vnd.ms-excel.template.macroenabled.12","application/vnd.oasis.opendocument.text-template","application/vnd.oasis.opendocument.spreadsheet-template","application/vnd.oasis.opendocument.presentation-template","application/vnd.oasis.opendocument.graphics","application/vnd.oasis.opendocument.graphics-template","application/vnd.ms-excel.sheet.macroenabled.12","application/vnd.ms-word.document.macroenabled.12","application/vnd.ms-word.template.macroenabled.12","application/vnd.ms-powerpoint.template.macroenabled.12","application/vnd.ms-powerpoint.presentation.macroenabled.12","application/java-archive","application/vnd.rn-realmedia","application/x-spss-sav","application/x-ms-regedit","application/x-ft-windows-registry-hive","application/x-jmp-data","application/vnd.apple.keynote","application/vnd.apple.numbers","application/vnd.apple.pages","application/x-iso9660-image"]);var FS=Object.freeze({__proto__:null,FileTypeParser:RS,fileTypeFromBuffer:async function(t,e){return new RS(e).fromBuffer(t)},normalizeSampleSize:OS,reasonableDetectionSizeInBytes:CS}),DS=Object.freeze({__proto__:null}),NS=2147483647,$S=/[^\x20-\x7E]/,jS=/[\x2E\u3002\uFF0E\uFF61]/g,GS={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},HS=Math.floor,ZS=String.fromCharCode;function qS(t){throw new RangeError(GS[t])}function WS(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function VS(t,e,n){var i=0;for(t=n?HS(t/700):t>>1,t+=HS(t/e);t>455;i+=36)t=HS(t/35);return HS(i+36*t/(t+38))}function JS(t){return function(t,e){var n=t.split("@"),i="";n.length>1&&(i=n[0]+"@",t=n[1]);var r=function(t,e){for(var n=t.length,i=[];n--;)i[n]=e(t[n]);return i}((t=t.replace(jS,".")).split("."),e).join(".");return i+r}(t,function(t){return $S.test(t)?"xn--"+function(t){var e,n,i,r,a,o,s,h,c,l,f,u,d,p,m,g=[];for(t=function(t){for(var e,n,i=[],r=0,a=t.length;r<a;)(e=t.charCodeAt(r++))>=55296&&e<=56319&&r<a?56320==(64512&(n=t.charCodeAt(r++)))?i.push(((1023&e)<<10)+(1023&n)+65536):(i.push(e),r--):i.push(e);return i}(t),u=t.length,e=128,n=0,a=72,o=0;o<u;++o)(f=t[o])<128&&g.push(ZS(f));for(i=r=g.length,r&&g.push("-");i<u;){for(s=NS,o=0;o<u;++o)(f=t[o])>=e&&f<s&&(s=f);for(s-e>HS((NS-n)/(d=i+1))&&qS("overflow"),n+=(s-e)*d,e=s,o=0;o<u;++o)if((f=t[o])<e&&++n>NS&&qS("overflow"),f==e){for(h=n,c=36;!(h<(l=c<=a?1:c>=a+26?26:c-a));c+=36)m=h-l,p=36-l,g.push(ZS(WS(l+m%p,0))),h=HS(m/p);g.push(ZS(WS(h,0))),a=VS(n,d,i==r),n=0,++i}++n,++e}return g.join("")}(t):t})}function YS(t){return null===t}function XS(t){return"string"==typeof t}function KS(t){return"object"==typeof t&&null!==t}function QS(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var tz=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function ez(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}}function nz(t,e){if(t.map)return t.map(e);for(var n=[],i=0;i<t.length;i++)n.push(e(t[i],i));return n}var iz=Object.keys||function(t){var e=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.push(n);return e};function rz(t,e,n,i){e=e||"&",n=n||"=";var r={};if("string"!=typeof t||0===t.length)return r;var a=/\+/g;t=t.split(e);var o=1e3;i&&"number"==typeof i.maxKeys&&(o=i.maxKeys);var s=t.length;o>0&&s>o&&(s=o);for(var h=0;h<s;++h){var c,l,f,u,d=t[h].replace(a,"%20"),p=d.indexOf(n);p>=0?(c=d.substr(0,p),l=d.substr(p+1)):(c=d,l=""),f=decodeURIComponent(c),u=decodeURIComponent(l),QS(r,f)?tz(r[f])?r[f].push(u):r[f]=[r[f],u]:r[f]=u}return r}function az(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var oz=/^([a-z0-9.+-]+:)/i,sz=/:[0-9]*$/,hz=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,cz=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),lz=["'"].concat(cz),fz=["%","/","?",";","#"].concat(lz),uz=["/","?","#"],dz=/^[+a-z0-9A-Z_-]{0,63}$/,pz=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,mz={javascript:!0,"javascript:":!0},gz={javascript:!0,"javascript:":!0},bz={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function wz(t,e,n){if(t&&KS(t)&&t instanceof az)return t;var i=new az;return i.parse(t,e,n),i}function yz(t){var e=t.auth||"";e&&(e=(e=encodeURIComponent(e)).replace(/%3A/i,":"),e+="@");var n=t.protocol||"",i=t.pathname||"",r=t.hash||"",a=!1,o="";t.host?a=e+t.host:t.hostname&&(a=e+(-1===t.hostname.indexOf(":")?t.hostname:"["+this.hostname+"]"),t.port&&(a+=":"+t.port)),t.query&&KS(t.query)&&Object.keys(t.query).length&&(o=function(t,e,n,i){return e=e||"&",n=n||"=",null===t&&(t=void 0),"object"==typeof t?nz(iz(t),function(i){var r=encodeURIComponent(ez(i))+n;return tz(t[i])?nz(t[i],function(t){return r+encodeURIComponent(ez(t))}).join(e):r+encodeURIComponent(ez(t[i]))}).join(e):i?encodeURIComponent(ez(i))+n+encodeURIComponent(ez(t)):""}(t.query));var s=t.search||o&&"?"+o||"";return n&&":"!==n.substr(-1)&&(n+=":"),t.slashes||(!n||bz[n])&&!1!==a?(a="//"+(a||""),i&&"/"!==i.charAt(0)&&(i="/"+i)):a||(a=""),r&&"#"!==r.charAt(0)&&(r="#"+r),s&&"?"!==s.charAt(0)&&(s="?"+s),n+a+(i=i.replace(/[?#]/g,function(t){return encodeURIComponent(t)}))+(s=s.replace("#","%23"))+r}function _z(t){var e=t.host,n=sz.exec(e);n&&(":"!==(n=n[0])&&(t.port=n.substr(1)),e=e.substr(0,e.length-n.length)),e&&(t.hostname=e)}az.prototype.parse=function(t,e,n){return function(t,e,n,i){if(!XS(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var r=e.indexOf("?"),a=-1!==r&&r<e.indexOf("#")?"?":"#",o=e.split(a),s=/\\/g;o[0]=o[0].replace(s,"/"),e=o.join(a);var h=e;if(h=h.trim(),!i&&1===e.split("#").length){var c=hz.exec(h);if(c)return t.path=h,t.href=h,t.pathname=c[1],c[2]?(t.search=c[2],t.query=n?rz(t.search.substr(1)):t.search.substr(1)):n&&(t.search="",t.query={}),t}var l,f,u,d,p=oz.exec(h);if(p){var m=(p=p[0]).toLowerCase();t.protocol=m,h=h.substr(p.length)}if(i||p||h.match(/^\/\/[^@\/]+@[^@\/]+/)){var g="//"===h.substr(0,2);!g||p&&gz[p]||(h=h.substr(2),t.slashes=!0)}if(!gz[p]&&(g||p&&!bz[p])){var b,w,y=-1;for(l=0;l<uz.length;l++)-1!==(f=h.indexOf(uz[l]))&&(-1===y||f<y)&&(y=f);for(-1!==(w=-1===y?h.lastIndexOf("@"):h.lastIndexOf("@",y))&&(b=h.slice(0,w),h=h.slice(w+1),t.auth=decodeURIComponent(b)),y=-1,l=0;l<fz.length;l++)-1!==(f=h.indexOf(fz[l]))&&(-1===y||f<y)&&(y=f);-1===y&&(y=h.length),t.host=h.slice(0,y),h=h.slice(y),_z(t),t.hostname=t.hostname||"";var _="["===t.hostname[0]&&"]"===t.hostname[t.hostname.length-1];if(!_){var v=t.hostname.split(/\./);for(l=0,u=v.length;l<u;l++){var x=v[l];if(x&&!x.match(dz)){for(var k="",A=0,M=x.length;A<M;A++)x.charCodeAt(A)>127?k+="x":k+=x[A];if(!k.match(dz)){var E=v.slice(0,l),I=v.slice(l+1),S=x.match(pz);S&&(E.push(S[1]),I.unshift(S[2])),I.length&&(h="/"+I.join(".")+h),t.hostname=E.join(".");break}}}}t.hostname.length>255?t.hostname="":t.hostname=t.hostname.toLowerCase(),_||(t.hostname=JS(t.hostname)),d=t.port?":"+t.port:"";var z=t.hostname||"";t.host=z+d,t.href+=t.host,_&&(t.hostname=t.hostname.substr(1,t.hostname.length-2),"/"!==h[0]&&(h="/"+h))}if(!mz[m])for(l=0,u=lz.length;l<u;l++){var B=lz[l];if(-1!==h.indexOf(B)){var C=encodeURIComponent(B);C===B&&(C=escape(B)),h=h.split(B).join(C)}}var P=h.indexOf("#");-1!==P&&(t.hash=h.substr(P),h=h.slice(0,P));var T=h.indexOf("?");-1!==T?(t.search=h.substr(T),t.query=h.substr(T+1),n&&(t.query=rz(t.query)),h=h.slice(0,T)):n&&(t.search="",t.query={});h&&(t.pathname=h);bz[m]&&t.hostname&&!t.pathname&&(t.pathname="/");if(t.pathname||t.search){d=t.pathname||"";var U=t.search||"";t.path=d+U}return t.href=yz(t),t}(this,t,e,n)},az.prototype.format=function(){return yz(this)},az.prototype.resolve=function(t){return this.resolveObject(wz(t,!1,!0)).format()},az.prototype.resolveObject=function(t){if(XS(t)){var e=new az;e.parse(t,!1,!0),t=e}for(var n,i=new az,r=Object.keys(this),a=0;a<r.length;a++){var o=r[a];i[o]=this[o]}if(i.hash=t.hash,""===t.href)return i.href=i.format(),i;if(t.slashes&&!t.protocol){for(var s=Object.keys(t),h=0;h<s.length;h++){var c=s[h];"protocol"!==c&&(i[c]=t[c])}return bz[i.protocol]&&i.hostname&&!i.pathname&&(i.path=i.pathname="/"),i.href=i.format(),i}if(t.protocol&&t.protocol!==i.protocol){if(!bz[t.protocol]){for(var l=Object.keys(t),f=0;f<l.length;f++){var u=l[f];i[u]=t[u]}return i.href=i.format(),i}if(i.protocol=t.protocol,t.host||gz[t.protocol])i.pathname=t.pathname;else{for(n=(t.pathname||"").split("/");n.length&&!(t.host=n.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==n[0]&&n.unshift(""),n.length<2&&n.unshift(""),i.pathname=n.join("/")}if(i.search=t.search,i.query=t.query,i.host=t.host||"",i.auth=t.auth,i.hostname=t.hostname||t.host,i.port=t.port,i.pathname||i.search){var d=i.pathname||"",p=i.search||"";i.path=d+p}return i.slashes=i.slashes||t.slashes,i.href=i.format(),i}var m,g=i.pathname&&"/"===i.pathname.charAt(0),b=t.host||t.pathname&&"/"===t.pathname.charAt(0),w=b||g||i.host&&t.pathname,y=w,_=i.pathname&&i.pathname.split("/")||[],v=i.protocol&&!bz[i.protocol];if(n=t.pathname&&t.pathname.split("/")||[],v&&(i.hostname="",i.port=null,i.host&&(""===_[0]?_[0]=i.host:_.unshift(i.host)),i.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===n[0]?n[0]=t.host:n.unshift(t.host)),t.host=null),w=w&&(""===n[0]||""===_[0])),b)i.host=t.host||""===t.host?t.host:i.host,i.hostname=t.hostname||""===t.hostname?t.hostname:i.hostname,i.search=t.search,i.query=t.query,_=n;else if(n.length)_||(_=[]),_.pop(),_=_.concat(n),i.search=t.search,i.query=t.query;else if(null!=t.search)return v&&(i.hostname=i.host=_.shift(),(m=!!(i.host&&i.host.indexOf("@")>0)&&i.host.split("@"))&&(i.auth=m.shift(),i.host=i.hostname=m.shift())),i.search=t.search,i.query=t.query,YS(i.pathname)&&YS(i.search)||(i.path=(i.pathname?i.pathname:"")+(i.search?i.search:"")),i.href=i.format(),i;if(!_.length)return i.pathname=null,i.search?i.path="/"+i.search:i.path=null,i.href=i.format(),i;for(var x=_.slice(-1)[0],k=(i.host||t.host||_.length>1)&&("."===x||".."===x)||""===x,A=0,M=_.length;M>=0;M--)"."===(x=_[M])?_.splice(M,1):".."===x?(_.splice(M,1),A++):A&&(_.splice(M,1),A--);if(!w&&!y)for(;A--;A)_.unshift("..");!w||""===_[0]||_[0]&&"/"===_[0].charAt(0)||_.unshift(""),k&&"/"!==_.join("/").substr(-1)&&_.push("");var E=""===_[0]||_[0]&&"/"===_[0].charAt(0);return v&&(i.hostname=i.host=E?"":_.length?_.shift():"",(m=!!(i.host&&i.host.indexOf("@")>0)&&i.host.split("@"))&&(i.auth=m.shift(),i.host=i.hostname=m.shift())),(w=w||i.host&&_.length)&&!E&&_.unshift(""),_.length?i.pathname=_.join("/"):(i.pathname=null,i.path=null),YS(i.pathname)&&YS(i.search)||(i.path=(i.pathname?i.pathname:"")+(i.search?i.search:"")),i.auth=t.auth||i.auth,i.slashes=i.slashes||t.slashes,i.href=i.format(),i},az.prototype.parseHost=function(){return _z(this)};var vz=Object.freeze({__proto__:null,Url:az,fileURLToPath:function(t){if("string"==typeof t)t=(new az).parse(t);else if(!(t instanceof az))throw new TypeError('The "path" argument must be of type string or an instance of URL. Received type '+typeof t+String(t));if("file:"!==t.protocol)throw new TypeError("The URL must be of scheme file");return function(t){const e=t.pathname;for(let t=0;t<e.length;t++)if("%"===e[t]){const n=32|e.codePointAt(t+2);if("2"===e[t+1]&&102===n)throw new TypeError("must not include encoded / characters")}return decodeURIComponent(e)}(t)},parse:wz});export{ay as BlendMode,d as BmpCompression,zw as ColorActionName,Eb as Edge,ey as HorizontalAlign,HE as Jimp,GE as JimpMime,ep as PNGColorType,Qd as PNGFilterType,ip as ResizeStrategy,iy as VerticalAlign,uc as colorDiff,iA as compareHashes,pc as cssColorToHex,tA as decodeBlurhash,jE as defaultFormats,$E as defaultPlugins,NE as diff,eA as distance,lc as intToRGBA,dc as limit255,xE as loadFont,FA as measureText,jA as measureTextHeight,uM as otsuThreshold,sA as parseCubeLut,fc as rgbaToInt};
//# sourceMappingURL=index.js.map