pica
Version:
High quality image resize in browser.
7 lines (5 loc) • 54 kB
JavaScript
/*!
pica
https://github.com/nodeca/pica
*/
!function(A,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):(A="undefined"!=typeof globalThis?globalThis:A||self).pica=t()}(this,function(){var A;function t(A){const t=A.replace(/[\r\n=]/g,""),e=t.length,i=new Uint8Array(3*e>>2);let n=0,a=0;for(let s=0;s<e;s++)s%4==0&&s&&(i[a++]=n>>16&255,i[a++]=n>>8&255,i[a++]=255&n),n=n<<6|"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(t.charAt(s));const r=e%4*6;return 0===r?(i[a++]=n>>16&255,i[a++]=n>>8&255,i[a++]=255&n):18===r?(i[a++]=n>>10&255,i[a++]=n>>2&255):12===r&&(i[a++]=n>>4&255),i}var e={js:!0,wasm:!0},i=class{constructor(A){const t=Object.assign({},e,A||{});if(this.options=t,this.__cache={},this.__init_promise=null,this.__modules=t.modules||{},this.__memory=null,this.__wasm={},this.__isLE=1===new Uint32Array(new Uint8Array([1,0,0,0]).buffer)[0],!this.options.js&&!this.options.wasm)throw new Error('mathlib: at least "js" or "wasm" should be enabled')}has_wasm(){return function(){if(void 0!==A)return A;if(A=!1,"undefined"==typeof WebAssembly)return A;try{const t=new Uint8Array([0,97,115,109,1,0,0,0,1,6,1,96,1,127,1,127,3,2,1,0,5,3,1,0,1,7,8,1,4,116,101,115,116,0,0,10,16,1,14,0,32,0,65,1,54,2,0,32,0,40,2,0,11]),e=new WebAssembly.Module(t);return 0!==new WebAssembly.Instance(e,{}).exports.test(4)&&(A=!0),A}catch(t){}return A}()}use(A){return this.__modules[A.name]=A,this.options.wasm&&this.has_wasm()&&A.wasm_fn?this[A.name]=A.wasm_fn:this[A.name]=A.fn,this}init(){return this.__init_promise?this.__init_promise:this.options.js||!this.options.wasm||this.has_wasm()?(this.__init_promise=Promise.all(Object.keys(this.__modules).map(A=>{const e=this.__modules[A];return this.options.wasm&&this.has_wasm()&&e.wasm_fn?this.__wasm[A]?null:WebAssembly.compile(t(e.wasm_src)).then(t=>{this.__wasm[A]=t}):null})).then(()=>this),this.__init_promise):Promise.reject(new Error('mathlib: only "wasm" was enabled, but it\'s not supported'))}__reallocate(A){if(!this.__memory)return this.__memory=new WebAssembly.Memory({initial:Math.ceil(A/65536)}),this.__memory;const t=this.__memory.buffer.byteLength;return t<A&&this.__memory.grow(Math.ceil((A-t)/65536)),this.__memory}__instance(A,e,i){if(e&&this.__reallocate(e),!this.__wasm[A]){const e=this.__modules[A];this.__wasm[A]=new WebAssembly.Module(t(e.wasm_src))}if(!this.__cache[A]){const t={memoryBase:0,memory:this.__memory,tableBase:0,table:new WebAssembly.Table({initial:0,element:"anyfunc"})};this.__cache[A]=new WebAssembly.Instance(this.__wasm[A],{env:Object.assign(t,i||{})})}return this.__cache[A]}__align(A,t){const e=A%(t=t||8);return A+(e?t-e:0)}};function n(A,t,e,i,n,a){let r,s,o,g,h,c,I,f,u,B,l,E,Q,d;for(u=0;u<a;u++){for(c=u*n,I=u,f=0,r=A[c],h=r*i[6],g=h,l=i[0],E=i[1],Q=i[4],d=i[5],B=0;B<n;B++)s=A[c],o=s*l+r*E+g*Q+h*d,h=g,g=o,r=s,e[f]=g,f++,c++;for(c--,f--,I+=a*(n-1),r=A[c],h=r*i[7],g=h,s=r,l=i[2],E=i[3],B=n-1;B>=0;B--)o=s*l+r*E+g*Q+h*d,h=g,g=o,r=s,s=A[c],t[I]=e[f]+g,c--,f--,I-=a}}function a(A,t,e,i){if(!i)return;const a=new Uint16Array(A.length),r=new Float32Array(Math.max(t,e)),s=function(A){A<.5&&(A=.5);const t=Math.exp(.527076)/A,e=Math.exp(-t),i=Math.exp(-2*t),n=(1-e)*(1-e)/(1+2*t*e-i),a=n*(t-1)*e,r=n*(t+1)*e,s=-n*i,o=2*e,g=-i;return new Float32Array([n,a,r,s,o,g,(n+a)/(1-o-g),(r+s)/(1-o-g)])}(i);n(A,a,r,s,t,e),n(a,A,r,s,e,t)}var r={name:"unsharp_mask",fn:function(A,t,e,i,n,r){let s,o,g,h,c;if(0===i||n<.5)return;n>2&&(n=2);const I=function(A,t,e){const i=t*e,n=new Uint16Array(i);let a,r,s,o;for(let g=0;g<i;g++)a=A[4*g],r=A[4*g+1],s=A[4*g+2],o=a>=r&&a>=s?a:r>=s&&r>=a?r:s,n[g]=o<<8;return n}(A,t,e),f=new Uint16Array(I);a(f,t,e,n);const u=i/100*4096+.5|0,B=r<<8,l=t*e;for(let a=0;a<l;a++)s=I[a],h=s-f[a],Math.abs(h)>=B&&(o=s+(u*h+2048>>12),o=o>65280?65280:o,o=o<0?0:o,s=0!==s?s:1,g=(o<<12)/s|0,c=4*a,A[c]=A[c]*g+2048>>12,A[c+1]=A[c+1]*g+2048>>12,A[c+2]=A[c+2]*g+2048>>12)},wasm_fn:function(A,t,e,i,n,a){if(0===i||n<.5)return;n>2&&(n=2);const r=t*e,s=4*r,o=2*r,g=2*r,h=4*Math.max(t,e),c=s,I=c+o,f=I+g,u=f+g,B=u+h,l=this.__instance("unsharp_mask",s+o+2*g+h+32,{exp:Math.exp}),E=new Uint32Array(A.buffer);new Uint32Array(this.__memory.buffer).set(E);let Q=l.exports.hsv_v16||l.exports._hsv_v16;if(!Q)throw new Error("WASM hsv_v16 function is not available");if(Q(0,c,t,e),Q=l.exports.blurMono16||l.exports._blurMono16,!Q)throw new Error("WASM blurMono16 function is not available");if(Q(c,I,f,u,B,t,e,n),Q=l.exports.unsharp||l.exports._unsharp,!Q)throw new Error("WASM unsharp function is not available");Q(0,0,c,I,t,e,i,a),E.set(new Uint32Array(this.__memory.buffer,0,r))},wasm_src:"AGFzbQEAAAAADAZkeWxpbmsAAAAAAAE0B2AAAGAEf39/fwBgBn9/f39/fwBgCH9/f39/f39/AGAIf39/f39/f30AYAJ9fwBgAXwBfAIZAgNlbnYDZXhwAAYDZW52Bm1lbW9yeQIAAAMHBgAFAgQBA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AFIAdsQYAQakEMdSABaiIHQYD+AyAHQYD+A0gbIgdBACAHQQBKG0EMdCABQQEgARtuIgEgCi0AAGxBgBBqQQx2OgAAIAAgCEEBcmoiByABIActAABsQYAQakEMdjoAACAAIAhBAnJqIgcgASAHLQAAbEGAEGpBDHY6AAALIAZBAWoiBiAERw0ACwsL"},s={filter:{box:{win:.5,fn:A=>(A<0&&(A=-A),A<.5?1:0)},hamming:{win:1,fn(A){if(A<0&&(A=-A),A>=1)return 0;if(A<1.1920929e-7)return 1;const t=A*Math.PI;return Math.sin(t)/t*(.54+.46*Math.cos(t/1))}},lanczos2:{win:2,fn(A){if(A<0&&(A=-A),A>=2)return 0;if(A<1.1920929e-7)return 1;const t=A*Math.PI;return Math.sin(t)/t*Math.sin(t/2)/(t/2)}},lanczos3:{win:3,fn(A){if(A<0&&(A=-A),A>=3)return 0;if(A<1.1920929e-7)return 1;const t=A*Math.PI;return Math.sin(t)/t*Math.sin(t/3)/(t/3)}},mks2013:{win:2.5,fn:A=>(A<0&&(A=-A),A>=2.5?0:A>=1.5?-.125*(A-2.5)*(A-2.5):A>=.5?.25*(4*A*A-11*A+7):1.0625-1.75*A*A)}}};function o(A){return Math.round(16383*A)}function g(A,t,e,i,n){const a=s.filter[A].fn,r=1/i,g=Math.min(1,i),h=s.filter[A].win/g;let c,I,f,u,B,l,E,Q,d,C,m,w,_,b,y,p,D;const v=Math.floor(2*(h+1)),M=new Int16Array((v+2)*e);let k=0;const G=!M.subarray||!M.set;for(c=0;c<e;c++){for(I=(c+.5)*r+n,f=Math.max(0,Math.floor(I-h)),u=Math.min(t-1,Math.ceil(I+h)),B=u-f+1,l=new Float32Array(B),E=new Int16Array(B),Q=0,d=f,C=0;d<=u;d++,C++)m=a((d+.5-I)*g),Q+=m,l[C]=m;for(w=0,C=0;C<l.length;C++)_=l[C]/Q,w+=_,E[C]=o(_);for(E[e>>1]+=o(1-w),b=0;b<E.length&&0===E[b];)b++;if(b<E.length){for(y=E.length-1;y>0&&0===E[y];)y--;if(p=f+b,D=y-b+1,M[k++]=p,M[k++]=D,G)for(C=b;C<=y;C++)M[k++]=E[C];else M.set(E.subarray(b,y+1),k),k+=D}else M[k++]=0,M[k++]=0}return M}function h(A){return A<0?0:A>255?255:A}function c(A){return A>=0?A:0}var I=!0;try{I=1===new Uint32Array(new Uint8Array([1,0,0,0]).buffer)[0]}catch(z){}function f(A,t,e){if(I)t.set(function(A){return new Uint8Array(A.buffer,0,A.byteLength)}(A),e);else for(let i=e,n=0;n<A.length;n++){const e=A[n];t[i++]=255&e,t[i++]=e>>8&255}}var u={name:"resize",fn:function(A){const t=A.src,e=A.width,i=A.height,n=A.toWidth,a=A.toHeight,r=A.scaleX||A.toWidth/A.width,s=A.scaleY||A.toHeight/A.height,o=A.offsetX||0,I=A.offsetY||0,f=A.dest||new Uint8Array(n*a*4),u=void 0===A.filter?"mks2013":A.filter,B=g(u,e,n,r,o),l=g(u,i,a,s,I),E=new Uint16Array(n*i*4);return!function(A,t,e){let i=3;const n=t*e*4|0;for(;i<n;){if(255!==A[i])return!0;i=i+4|0}return!1}(t,e,i)?(function(A,t,e,i,n,a){let r,s,o,g,h,I,f,u,B,l,E,Q=0,d=0;for(B=0;B<i;B++){for(h=0,l=0;l<n;l++){for(I=a[h++],f=a[h++],u=Q+4*I|0,r=s=o=g=0;f>0;f--)E=a[h++],g=g+E*A[u+3]|0,o=o+E*A[u+2]|0,s=s+E*A[u+1]|0,r=r+E*A[u]|0,u=u+4|0;t[d+3]=c(g>>7),t[d+2]=c(o>>7),t[d+1]=c(s>>7),t[d]=c(r>>7),d=d+4*i|0}d=4*(B+1)|0,Q=(B+1)*e*4|0}}(t,E,e,i,n,B),function(A,t,e,i,n,a){let r,s,o,g,c,I,f,u,B,l,E,Q=0,d=0;for(B=0;B<i;B++){for(c=0,l=0;l<n;l++){for(I=a[c++],f=a[c++],u=Q+4*I|0,r=s=o=g=0;f>0;f--)E=a[c++],g=g+E*A[u+3]|0,o=o+E*A[u+2]|0,s=s+E*A[u+1]|0,r=r+E*A[u]|0,u=u+4|0;r>>=7,s>>=7,o>>=7,g>>=7,t[d+3]=h(g+8192>>14),t[d+2]=h(o+8192>>14),t[d+1]=h(s+8192>>14),t[d]=h(r+8192>>14),d=d+4*i|0}d=4*(B+1)|0,Q=(B+1)*e*4|0}}(E,f,i,n,a,l),function(A,t,e){let i=3;const n=t*e*4|0;for(;i<n;)A[i]=255,i=i+4|0}(f,n,a)):(function(A,t,e,i,n,a){let r,s,o,g,h,I,f,u,B,l,E,Q,d=0,C=0;for(l=0;l<i;l++){for(I=0,E=0;E<n;E++){for(f=a[I++],u=a[I++],B=d+4*f|0,r=s=o=g=0;u>0;u--)Q=a[I++],h=A[B+3],g=g+Q*h|0,o=o+Q*A[B+2]*h|0,s=s+Q*A[B+1]*h|0,r=r+Q*A[B]*h|0,B=B+4|0;o=o/255|0,s=s/255|0,r=r/255|0,t[C+3]=c(g>>7),t[C+2]=c(o>>7),t[C+1]=c(s>>7),t[C]=c(r>>7),C=C+4*i|0}C=4*(l+1)|0,d=(l+1)*e*4|0}}(t,E,e,i,n,B),function(A,t,e,i,n,a){let r,s,o,g,c,I,f,u,B,l,E,Q=0,d=0;for(B=0;B<i;B++){for(c=0,l=0;l<n;l++){for(I=a[c++],f=a[c++],u=Q+4*I|0,r=s=o=g=0;f>0;f--)E=a[c++],g=g+E*A[u+3]|0,o=o+E*A[u+2]|0,s=s+E*A[u+1]|0,r=r+E*A[u]|0,u=u+4|0;r>>=7,s>>=7,o>>=7,g>>=7,g=h(g+8192>>14),g>0&&(r=255*r/g|0,s=255*s/g|0,o=255*o/g|0),t[d+3]=g,t[d+2]=h(o+8192>>14),t[d+1]=h(s+8192>>14),t[d]=h(r+8192>>14),d=d+4*i|0}d=4*(B+1)|0,Q=(B+1)*e*4|0}}(E,f,i,n,a,l)),f},wasm_fn:function(A){const t=A.src,e=A.width,i=A.height,n=A.toWidth,a=A.toHeight,r=A.scaleX||A.toWidth/A.width,s=A.scaleY||A.toHeight/A.height,o=A.offsetX||0,h=A.offsetY||0,c=A.dest||new Uint8Array(n*a*4),I=void 0===A.filter?"mks2013":A.filter,u=g(I,e,n,r,o),B=g(I,i,a,s,h),l=Math.max(t.byteLength,c.byteLength),E=this.__align(0+l),Q=i*n*4*2,d=this.__align(E+Q),C=this.__align(d+u.byteLength),m=C+B.byteLength,w=this.__instance("resize",m),_=new Uint8Array(this.__memory.buffer),b=new Uint32Array(this.__memory.buffer),y=new Uint32Array(t.buffer);b.set(y),f(u,_,d),f(B,_,C);const p=w.exports.convolveHV||w.exports._convolveHV;if(!p)throw new Error("WASM resize function is not available");return!function(A,t,e){let i=3;const n=t*e*4|0;for(;i<n;){if(255!==A[i])return!0;i=i+4|0}return!1}(t,e,i)?(p(d,C,E,e,i,n,a,0),function(A,t,e){let i=3;const n=t*e*4|0;for(;i<n;)A[i]=255,i=i+4|0}(c,n,a)):p(d,C,E,e,i,n,a,1),new Uint32Array(c.buffer).set(new Uint32Array(this.__memory.buffer,0,a*n)),c},wasm_src:"AGFzbQEAAAAADAZkeWxpbmsAAAAAAAEYA2AGf39/f39/AGAAAGAIf39/f39/f38AAg8BA2VudgZtZW1vcnkCAAADBwYBAAAAAAIGBgF/AEEACweUAQgRX193YXNtX2NhbGxfY3RvcnMAAAtjb252b2x2ZUhvcgABDGNvbnZvbHZlVmVydAACEmNvbnZvbHZlSG9yV2l0aFByZQADE2NvbnZvbHZlVmVydFdpdGhQcmUABApjb252b2x2ZUhWAAUMX19kc29faGFuZGxlAwAYX193YXNtX2FwcGx5X2RhdGFfcmVsb2NzAAAKyA4GAwABC4wDARB/AkAgA0UNACAERQ0AIANBAnQhFQNAQQAhE0EAIQsDQCALQQJqIQcCfyALQQF0IAVqIgYuAQIiC0UEQEEAIQhBACEGQQAhCUEAIQogBwwBCyASIAYuAQBqIQhBACEJQQAhCiALIRRBACEOIAchBkEAIQ8DQCAFIAZBAXRqLgEAIhAgACAIQQJ0aigCACIRQRh2bCAPaiEPIBFB/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BaiILbCERIAMgC0cNAAsLC0AAIAcEQEEAIAIgAyAEIAUgABADIAJBACAEIAUgBiABEAQPC0EAIAIgAyAEIAUgABABIAJBACAEIAUgBiABEAIL"},B=class extends i{constructor(A){const t=A||[],e={js:t.indexOf("js")>=0,wasm:t.indexOf("wasm")>=0};super(e),this.features={js:e.js,wasm:e.wasm&&this.has_wasm()},this.use(r),this.use(u)}resizeAndUnsharp(A){const t=this.resize(A);return A.unsharpAmount&&this.unsharp_mask(t,A.toWidth,A.toHeight,A.unsharpAmount,A.unsharpRadius,A.unsharpThreshold),t}};function l(A){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(A){return typeof A}:function(A){return A&&"function"==typeof Symbol&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A},l(A)}function E(A){var t=function(A,t){if("object"!=l(A)||!A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var i=e.call(A,t||"default");if("object"!=l(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==l(t)?t:t+""}function Q(A,t,e){return(t=E(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}function d(A,t){var e=Object.keys(A);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(A);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(A,t).enumerable})),e.push.apply(e,i)}return e}function C(A){for(var t=1;t<arguments.length;t++){var e=null!=arguments[t]?arguments[t]:{};t%2?d(Object(e),!0).forEach(function(t){Q(A,t,e[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(A,Object.getOwnPropertyDescriptors(e)):d(Object(e)).forEach(function(t){Object.defineProperty(A,t,Object.getOwnPropertyDescriptor(e,t))})}return A}var m=class{constructor(A,t){Q(this,"create",void 0),Q(this,"available",void 0),Q(this,"acquired",void 0),Q(this,"lastId",void 0),Q(this,"timeoutId",void 0),Q(this,"idle",void 0),this.create=A,this.available=[],this.acquired={},this.lastId=1,this.timeoutId=0,this.idle=t||2e3}acquire(){let A;return A=0!==this.available.length?this.available.pop():C(C({},this.create()),{},{id:this.lastId++,lastUsed:0}),this.acquired[A.id]=A,{value:A.value,release:()=>this.release(A)}}release(A){delete this.acquired[A.id],A.lastUsed=Date.now(),this.available.push(A),0===this.timeoutId&&(this.timeoutId=setTimeout(()=>this.gc(),100))}gc(){const A=Date.now();this.available=this.available.filter(t=>!(A-t.lastUsed>this.idle)||(t.destroy(),!1)),0!==this.available.length?this.timeoutId=setTimeout(()=>this.gc(),100):this.timeoutId=0}};function w(A){var t,e;return null!==(t=null==A||null===(e=A.constructor)||void 0===e?void 0:e.name)&&void 0!==t?t:""}function _(A){const t=w(A);return"HTMLCanvasElement"===t||"OffscreenCanvas"===t||"Canvas"===t||"CanvasElement"===t}function b(A){return"HTMLImageElement"===w(A)}function y(A){return"ImageBitmap"===w(A)}function p(A){switch(A){case 0:return"pixelated";case 1:return"low";case 2:return"medium"}return"high"}var D=["box","hamming","lanczos2","lanczos3"];function v(A){return D[A]}function M(A){return D.indexOf(A)>=0}function k(A){const t=D.indexOf(A);return t>=0?t:void 0}var G=1e-5;function U(A){const t=Math.round(A);return Math.abs(A-t)<G?t:Math.floor(A)}function R(A){const t=Math.round(A);return Math.abs(A-t)<G?t:Math.ceil(A)}var H="/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/4AAQskZJRgABAQAAAQABAAD/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/wAALCAACAAMBAREA/8QAFAABAAAAAAAAAAAAAAAAAAAACf/EABsQAAMBAQADAAAAAAAAAAAAAAECAwQFABEx/9oACAEBAAA/AC06fW6va0ps7PT179E88MiV02arrCEkjGQZiSEnKc5ovxURVHoADz//2Q==",F={canvas:!1,offscreen_canvas:!1,may_be_worker:!1,create_image_bitmap:!1,safari_put_image_data_fix:!1,bug_canvas_orientation_region:!0,bug_image_bitmap_orientation_region:!0,cib_resize:!1},x=!1,W=null;function O(){if("undefined"==typeof document||!document.createElement)return!1;try{const A=document.createElement("canvas");A.width=2,A.height=1;const t=A.getContext("2d");let e=t.createImageData(2,1);return e.data[0]=12,e.data[1]=23,e.data[2]=34,e.data[3]=255,e.data[4]=45,e.data[5]=56,e.data[6]=67,e.data[7]=255,t.putImageData(e,0,0),e=t.getImageData(0,0,2,1),12===e.data[0]&&23===e.data[1]&&34===e.data[2]&&255===e.data[3]&&45===e.data[4]&&56===e.data[5]&&67===e.data[6]&&255===e.data[7]}catch(z){return!1}}function S(){if("undefined"==typeof OffscreenCanvas)return!1;try{const A=new OffscreenCanvas(2,1).getContext("2d");let t=A.createImageData(2,1);return t.data[0]=12,t.data[1]=23,t.data[2]=34,t.data[3]=255,t.data[4]=45,t.data[5]=56,t.data[6]=67,t.data[7]=255,A.putImageData(t,0,0),t=A.getImageData(0,0,2,1),12===t.data[0]&&23===t.data[1]&&34===t.data[2]&&255===t.data[3]&&45===t.data[4]&&56===t.data[5]&&67===t.data[6]&&255===t.data[7]}catch(z){return!1}}function j(){return"undefined"!=typeof createImageBitmap}function Y(){if(x)return Promise.resolve(Object.assign({},F));if(W)return W.then(()=>Object.assign({},F));F.canvas=O(),F.offscreen_canvas=S(),F.may_be_worker="undefined"!=typeof Worker&&"undefined"!=typeof URL&&!!URL.createObjectURL,F.create_image_bitmap=j(),F.safari_put_image_data_fix=function(){try{return!!("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.indexOf("Safari")>=0&&navigator.userAgent.indexOf("Chrome")<0)}catch(z){return!1}}();const A=Promise.resolve().then(()=>{if(S()&&j()&&"undefined"!=typeof Blob&&"undefined"!=typeof atob){const A=atob(H),t=new Uint8Array(A.length);for(let e=0;e<A.length;e++)t[e]=A.charCodeAt(e);return createImageBitmap(new Blob([t],{type:"image/jpeg"})).then(A=>{const t=new OffscreenCanvas(1,1);try{const e=t.getContext("2d");return e.drawImage(A,1,1,1,1,0,0,1,1),e.getImageData(0,0,1,1).data[0]<240}finally{A.close()}})}return!O()||"undefined"==typeof Image||new Promise(A=>{const t=new Image;t.onload=()=>{try{const e=document.createElement("canvas");e.width=1,e.height=1;const i=e.getContext("2d");i.drawImage(t,1,1,1,1,0,0,1,1),A(i.getImageData(0,0,1,1).data[0]<240)}catch(z){A(!0)}},t.onerror=()=>A(!0),t.src=`data:image/jpeg;base64,${H}`})}).catch(()=>!0).then(A=>{F.bug_canvas_orientation_region=A}).catch(()=>{}),t=Promise.resolve().then(()=>{if(!F.create_image_bitmap&&!j())return!0;if("undefined"==typeof Blob||"undefined"==typeof atob)return!0;const A=S(),t=O();if(!A&&!t)return!0;const e=atob(H),i=new Uint8Array(e.length);for(let n=0;n<e.length;n++)i[n]=e.charCodeAt(n);return createImageBitmap(new Blob([i],{type:"image/jpeg"})).then(t=>createImageBitmap(t,1,1,1,1).then(e=>{let i;A?i=new OffscreenCanvas(1,1):(i=document.createElement("canvas"),i.width=1,i.height=1);try{const A=i.getContext("2d");return A.drawImage(e,0,0),1!==e.width||1!==e.height||A.getImageData(0,0,1,1).data[0]<240}finally{t.close(),e.close()}},()=>(t.close(),!0)))}).catch(()=>!0).then(A=>{F.bug_image_bitmap_orientation_region=A}).catch(()=>{}),e=Promise.resolve().then(()=>{if(!j())return!1;const A=20;let t;if(F.canvas||O())t=document.createElement("canvas"),t.width=A,t.height=A;else{if(!F.offscreen_canvas&&!S())return!1;t=new OffscreenCanvas(A,A),t.getContext("2d").clearRect(0,0,A,A)}return createImageBitmap(t,0,0,A,A,{resizeWidth:5,resizeHeight:5,resizeQuality:"high"}).then(A=>{const e=5===A.width&&!!A.close;return A.close&&A.close(),t=null,e})}).catch(()=>!1).then(A=>{F.cib_resize=A}).catch(()=>{});return W=Promise.all([A,t,e]).then(()=>(x=!0,W=null,Object.assign({},F)),A=>{throw W=null,A})}function L(A,t,e,i,n,a,r){try{var s=A[a](r),o=s.value}catch(A){return void e(A)}s.done?t(o):Promise.resolve(o).then(i,n)}function J(A){return function(){var t=this,e=arguments;return new Promise(function(i,n){var a=A.apply(t,e);function r(A){L(a,i,n,r,s,"next",A)}function s(A){L(a,i,n,r,s,"throw",A)}r(void 0)})}}var q='/*!\n\npica\nhttps://github.com/nodeca/pica\n\n*/\n!function(){var A;function t(A){const t=A.replace(/[\\r\\n=]/g,""),e=t.length,n=new Uint8Array(3*e>>2);let a=0,i=0;for(let s=0;s<e;s++)s%4==0&&s&&(n[i++]=a>>16&255,n[i++]=a>>8&255,n[i++]=255&a),a=a<<6|"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(t.charAt(s));const r=e%4*6;return 0===r?(n[i++]=a>>16&255,n[i++]=a>>8&255,n[i++]=255&a):18===r?(n[i++]=a>>10&255,n[i++]=a>>2&255):12===r&&(n[i++]=a>>4&255),n}var e={js:!0,wasm:!0},n=class{constructor(A){const t=Object.assign({},e,A||{});if(this.options=t,this.__cache={},this.__init_promise=null,this.__modules=t.modules||{},this.__memory=null,this.__wasm={},this.__isLE=1===new Uint32Array(new Uint8Array([1,0,0,0]).buffer)[0],!this.options.js&&!this.options.wasm)throw new Error(\'mathlib: at least "js" or "wasm" should be enabled\')}has_wasm(){return function(){if(void 0!==A)return A;if(A=!1,"undefined"==typeof WebAssembly)return A;try{const t=new Uint8Array([0,97,115,109,1,0,0,0,1,6,1,96,1,127,1,127,3,2,1,0,5,3,1,0,1,7,8,1,4,116,101,115,116,0,0,10,16,1,14,0,32,0,65,1,54,2,0,32,0,40,2,0,11]),e=new WebAssembly.Module(t);return 0!==new WebAssembly.Instance(e,{}).exports.test(4)&&(A=!0),A}catch(t){}return A}()}use(A){return this.__modules[A.name]=A,this.options.wasm&&this.has_wasm()&&A.wasm_fn?this[A.name]=A.wasm_fn:this[A.name]=A.fn,this}init(){return this.__init_promise?this.__init_promise:this.options.js||!this.options.wasm||this.has_wasm()?(this.__init_promise=Promise.all(Object.keys(this.__modules).map(A=>{const e=this.__modules[A];return this.options.wasm&&this.has_wasm()&&e.wasm_fn?this.__wasm[A]?null:WebAssembly.compile(t(e.wasm_src)).then(t=>{this.__wasm[A]=t}):null})).then(()=>this),this.__init_promise):Promise.reject(new Error(\'mathlib: only "wasm" was enabled, but it\\\'s not supported\'))}__reallocate(A){if(!this.__memory)return this.__memory=new WebAssembly.Memory({initial:Math.ceil(A/65536)}),this.__memory;const t=this.__memory.buffer.byteLength;return t<A&&this.__memory.grow(Math.ceil((A-t)/65536)),this.__memory}__instance(A,e,n){if(e&&this.__reallocate(e),!this.__wasm[A]){const e=this.__modules[A];this.__wasm[A]=new WebAssembly.Module(t(e.wasm_src))}if(!this.__cache[A]){const t={memoryBase:0,memory:this.__memory,tableBase:0,table:new WebAssembly.Table({initial:0,element:"anyfunc"})};this.__cache[A]=new WebAssembly.Instance(this.__wasm[A],{env:Object.assign(t,n||{})})}return this.__cache[A]}__align(A,t){const e=A%(t=t||8);return A+(e?t-e:0)}};function a(A,t,e,n,a,i){let r,s,o,g,I,h,B,Q,E,C,c,f,u,m;for(E=0;E<i;E++){for(h=E*a,B=E,Q=0,r=A[h],I=r*n[6],g=I,c=n[0],f=n[1],u=n[4],m=n[5],C=0;C<a;C++)s=A[h],o=s*c+r*f+g*u+I*m,I=g,g=o,r=s,e[Q]=g,Q++,h++;for(h--,Q--,B+=i*(a-1),r=A[h],I=r*n[7],g=I,s=r,c=n[2],f=n[3],C=a-1;C>=0;C--)o=s*c+r*f+g*u+I*m,I=g,g=o,r=s,s=A[h],t[B]=e[Q]+g,h--,Q--,B-=i}}function i(A,t,e,n){if(!n)return;const i=new Uint16Array(A.length),r=new Float32Array(Math.max(t,e)),s=function(A){A<.5&&(A=.5);const t=Math.exp(.527076)/A,e=Math.exp(-t),n=Math.exp(-2*t),a=(1-e)*(1-e)/(1+2*t*e-n),i=a*(t-1)*e,r=a*(t+1)*e,s=-a*n,o=2*e,g=-n;return new Float32Array([a,i,r,s,o,g,(a+i)/(1-o-g),(r+s)/(1-o-g)])}(n);a(A,i,r,s,t,e),a(i,A,r,s,e,t)}var r={name:"unsharp_mask",fn:function(A,t,e,n,a,r){let s,o,g,I,h;if(0===n||a<.5)return;a>2&&(a=2);const B=function(A,t,e){const n=t*e,a=new Uint16Array(n);let i,r,s,o;for(let g=0;g<n;g++)i=A[4*g],r=A[4*g+1],s=A[4*g+2],o=i>=r&&i>=s?i:r>=s&&r>=i?r:s,a[g]=o<<8;return a}(A,t,e),Q=new Uint16Array(B);i(Q,t,e,a);const E=n/100*4096+.5|0,C=r<<8,c=t*e;for(let i=0;i<c;i++)s=B[i],I=s-Q[i],Math.abs(I)>=C&&(o=s+(E*I+2048>>12),o=o>65280?65280:o,o=o<0?0:o,s=0!==s?s:1,g=(o<<12)/s|0,h=4*i,A[h]=A[h]*g+2048>>12,A[h+1]=A[h+1]*g+2048>>12,A[h+2]=A[h+2]*g+2048>>12)},wasm_fn:function(A,t,e,n,a,i){if(0===n||a<.5)return;a>2&&(a=2);const r=t*e,s=4*r,o=2*r,g=2*r,I=4*Math.max(t,e),h=s,B=h+o,Q=B+g,E=Q+g,C=E+I,c=this.__instance("unsharp_mask",s+o+2*g+I+32,{exp:Math.exp}),f=new Uint32Array(A.buffer);new Uint32Array(this.__memory.buffer).set(f);let u=c.exports.hsv_v16||c.exports._hsv_v16;if(!u)throw new Error("WASM hsv_v16 function is not available");if(u(0,h,t,e),u=c.exports.blurMono16||c.exports._blurMono16,!u)throw new Error("WASM blurMono16 function is not available");if(u(h,B,Q,E,C,t,e,a),u=c.exports.unsharp||c.exports._unsharp,!u)throw new Error("WASM unsharp function is not available");u(0,0,h,B,t,e,n,i),f.set(new Uint32Array(this.__memory.buffer,0,r))},wasm_src:"AGFzbQEAAAAADAZkeWxpbmsAAAAAAAE0B2AAAGAEf39/fwBgBn9/f39/fwBgCH9/f39/f39/AGAIf39/f39/f30AYAJ9fwBgAXwBfAIZAgNlbn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BrIgcgB0EfdSIIaiAIc00EQCAAIAZBAnQiCGoiCiAFIAdsQYAQakEMdSABaiIHQYD+AyAHQYD+A0gbIgdBACAHQQBKG0EMdCABQQEgARtuIgEgCi0AAGxBgBBqQQx2OgAAIAAgCEEBcmoiByABIActAABsQYAQakEMdjoAACAAIAhBAnJqIgcgASAHLQAAbEGAEGpBDHY6AAALIAZBAWoiBiAERw0ACwsL"},s={filter:{box:{win:.5,fn:A=>(A<0&&(A=-A),A<.5?1:0)},hamming:{win:1,fn(A){if(A<0&&(A=-A),A>=1)return 0;if(A<1.1920929e-7)return 1;const t=A*Math.PI;return Math.sin(t)/t*(.54+.46*Math.cos(t/1))}},lanczos2:{win:2,fn(A){if(A<0&&(A=-A),A>=2)return 0;if(A<1.1920929e-7)return 1;const t=A*Math.PI;return Math.sin(t)/t*Math.sin(t/2)/(t/2)}},lanczos3:{win:3,fn(A){if(A<0&&(A=-A),A>=3)return 0;if(A<1.1920929e-7)return 1;const t=A*Math.PI;return Math.sin(t)/t*Math.sin(t/3)/(t/3)}},mks2013:{win:2.5,fn:A=>(A<0&&(A=-A),A>=2.5?0:A>=1.5?-.125*(A-2.5)*(A-2.5):A>=.5?.25*(4*A*A-11*A+7):1.0625-1.75*A*A)}}};function o(A){return Math.round(16383*A)}function g(A,t,e,n,a){const i=s.filter[A].fn,r=1/n,g=Math.min(1,n),I=s.filter[A].win/g;let h,B,Q,E,C,c,f,u,m,d,w,l,y,_,b,D,M;const p=Math.floor(2*(I+1)),G=new Int16Array((p+2)*e);let U=0;const k=!G.subarray||!G.set;for(h=0;h<e;h++){for(B=(h+.5)*r+a,Q=Math.max(0,Math.floor(B-I)),E=Math.min(t-1,Math.ceil(B+I)),C=E-Q+1,c=new Float32Array(C),f=new Int16Array(C),u=0,m=Q,d=0;m<=E;m++,d++)w=i((m+.5-B)*g),u+=w,c[d]=w;for(l=0,d=0;d<c.length;d++)y=c[d]/u,l+=y,f[d]=o(y);for(f[e>>1]+=o(1-l),_=0;_<f.length&&0===f[_];)_++;if(_<f.length){for(b=f.length-1;b>0&&0===f[b];)b--;if(D=Q+_,M=b-_+1,G[U++]=D,G[U++]=M,k)for(d=_;d<=b;d++)G[U++]=f[d];else G.set(f.subarray(_,b+1),U),U+=M}else G[U++]=0,G[U++]=0}return G}function I(A){return A<0?0:A>255?255:A}function h(A){return A>=0?A:0}var B=!0;try{B=1===new Uint32Array(new Uint8Array([1,0,0,0]).buffer)[0]}catch(p){}function Q(A,t,e){if(B)t.set(function(A){return new Uint8Array(A.buffer,0,A.byteLength)}(A),e);else for(let n=e,a=0;a<A.length;a++){const e=A[a];t[n++]=255&e,t[n++]=e>>8&255}}var E={name:"resize",fn:function(A){const t=A.src,e=A.width,n=A.height,a=A.toWidth,i=A.toHeight,r=A.scaleX||A.toWidth/A.width,s=A.scaleY||A.toHeight/A.height,o=A.offsetX||0,B=A.offsetY||0,Q=A.dest||new Uint8Array(a*i*4),E=void 0===A.filter?"mks2013":A.filter,C=g(E,e,a,r,o),c=g(E,n,i,s,B),f=new Uint16Array(a*n*4);return!function(A,t,e){let n=3;const a=t*e*4|0;for(;n<a;){if(255!==A[n])return!0;n=n+4|0}return!1}(t,e,n)?(function(A,t,e,n,a,i){let r,s,o,g,I,B,Q,E,C,c,f,u=0,m=0;for(C=0;C<n;C++){for(I=0,c=0;c<a;c++){for(B=i[I++],Q=i[I++],E=u+4*B|0,r=s=o=g=0;Q>0;Q--)f=i[I++],g=g+f*A[E+3]|0,o=o+f*A[E+2]|0,s=s+f*A[E+1]|0,r=r+f*A[E]|0,E=E+4|0;t[m+3]=h(g>>7),t[m+2]=h(o>>7),t[m+1]=h(s>>7),t[m]=h(r>>7),m=m+4*n|0}m=4*(C+1)|0,u=(C+1)*e*4|0}}(t,f,e,n,a,C),function(A,t,e,n,a,i){let r,s,o,g,h,B,Q,E,C,c,f,u=0,m=0;for(C=0;C<n;C++){for(h=0,c=0;c<a;c++){for(B=i[h++],Q=i[h++],E=u+4*B|0,r=s=o=g=0;Q>0;Q--)f=i[h++],g=g+f*A[E+3]|0,o=o+f*A[E+2]|0,s=s+f*A[E+1]|0,r=r+f*A[E]|0,E=E+4|0;r>>=7,s>>=7,o>>=7,g>>=7,t[m+3]=I(g+8192>>14),t[m+2]=I(o+8192>>14),t[m+1]=I(s+8192>>14),t[m]=I(r+8192>>14),m=m+4*n|0}m=4*(C+1)|0,u=(C+1)*e*4|0}}(f,Q,n,a,i,c),function(A,t,e){let n=3;const a=t*e*4|0;for(;n<a;)A[n]=255,n=n+4|0}(Q,a,i)):(function(A,t,e,n,a,i){let r,s,o,g,I,B,Q,E,C,c,f,u,m=0,d=0;for(c=0;c<n;c++){for(B=0,f=0;f<a;f++){for(Q=i[B++],E=i[B++],C=m+4*Q|0,r=s=o=g=0;E>0;E--)u=i[B++],I=A[C+3],g=g+u*I|0,o=o+u*A[C+2]*I|0,s=s+u*A[C+1]*I|0,r=r+u*A[C]*I|0,C=C+4|0;o=o/255|0,s=s/255|0,r=r/255|0,t[d+3]=h(g>>7),t[d+2]=h(o>>7),t[d+1]=h(s>>7),t[d]=h(r>>7),d=d+4*n|0}d=4*(c+1)|0,m=(c+1)*e*4|0}}(t,f,e,n,a,C),function(A,t,e,n,a,i){let r,s,o,g,h,B,Q,E,C,c,f,u=0,m=0;for(C=0;C<n;C++){for(h=0,c=0;c<a;c++){for(B=i[h++],Q=i[h++],E=u+4*B|0,r=s=o=g=0;Q>0;Q--)f=i[h++],g=g+f*A[E+3]|0,o=o+f*A[E+2]|0,s=s+f*A[E+1]|0,r=r+f*A[E]|0,E=E+4|0;r>>=7,s>>=7,o>>=7,g>>=7,g=I(g+8192>>14),g>0&&(r=255*r/g|0,s=255*s/g|0,o=255*o/g|0),t[m+3]=g,t[m+2]=I(o+8192>>14),t[m+1]=I(s+8192>>14),t[m]=I(r+8192>>14),m=m+4*n|0}m=4*(C+1)|0,u=(C+1)*e*4|0}}(f,Q,n,a,i,c)),Q},wasm_fn:function(A){const t=A.src,e=A.width,n=A.height,a=A.toWidth,i=A.toHeight,r=A.scaleX||A.toWidth/A.width,s=A.scaleY||A.toHeight/A.height,o=A.offsetX||0,I=A.offsetY||0,h=A.dest||new Uint8Array(a*i*4),B=void 0===A.filter?"mks2013":A.filter,E=g(B,e,a,r,o),C=g(B,n,i,s,I),c=Math.max(t.byteLength,h.byteLength),f=this.__align(0+c),u=n*a*4*2,m=this.__align(f+u),d=this.__align(m+E.byteLength),w=d+C.byteLength,l=this.__instance("resize",w),y=new Uint8Array(this.__memory.buffer),_=new Uint32Array(this.__memory.buffer),b=new Uint32Array(t.buffer);_.set(b),Q(E,y,m),Q(C,y,d);const D=l.exports.convolveHV||l.exports._convolveHV;if(!D)throw new Error("WASM resize function is not available");return!function(A,t,e){let n=3;const a=t*e*4|0;for(;n<a;){if(255!==A[n])return!0;n=n+4|0}return!1}(t,e,n)?(D(m,d,f,e,n,a,i,0),function(A,t,e){let n=3;const a=t*e*4|0;for(;n<a;)A[n]=255,n=n+4|0}(h,a,i)):D(m,d,f,e,n,a,i,1),new Uint32Array(h.buffer).set(new Uint32Array(this.__memory.buffer,0,i*a)),h},wasm_src:"AGFzbQEAAAAADAZkeWxpbmsAAAAAAAEYA2AGf39/f39/AGAAAGAIf39/f39/f38AAg8BA2VudgZtZW1vcnkCAAADBwYBAAAAAAIGBgF/AEEACweUAQgRX193YXNtX2NhbGxfY3RvcnMAAAtjb252b2x2ZUhvcgABDGNvbnZvbHZlVmVydAACEmNvbnZvbHZlSG9yV2l0aFByZQADE2NvbnZvbHZlVmVydFdpdGhQcmUABApjb252b2x2ZUhWAAUMX19kc29faGFuZGxlAwAYX193YXNtX2FwcGx5X2RhdGFfcmVsb2NzAAAKyA4GAwABC4wDARB/AkAgA0UNACAERQ0AIANBAnQhFQNAQQAhE0EAIQsDQCALQQJqIQcCfyALQQF0IAVqIgYuAQIiC0UEQEEAIQhBACEGQQAhCUEAIQogBwwBCyASIAYuAQBqIQhBACEJQQAhCiALIRRBACEOIAchBkEAIQ8DQCAFI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yICQQAgAkEAShtycjYCACADIAxqIQwgEkEBaiISIARHDQALIBQgC0EBaiILbCERIAMgC0cNAAsLC0AAIAcEQEEAIAIgAyAEIAUgABADIAJBACAEIAUgBiABEAQPC0EAIAIgAyAEIAUgABABIAJBACAEIAUgBiABEAIL"},C=class extends n{constructor(A){const t=A||[],e={js:t.indexOf("js")>=0,wasm:t.indexOf("wasm")>=0};super(e),this.features={js:e.js,wasm:e.wasm&&this.has_wasm()},this.use(r),this.use(E)}resizeAndUnsharp(A){const t=this.resize(A);return A.unsharpAmount&&this.unsharp_mask(t,A.toWidth,A.toHeight,A.unsharpAmount,A.unsharpRadius,A.unsharpThreshold),t}},c="/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/4AAQskZJRgABAQAAAQABAAD/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/wAALCAACAAMBAREA/8QAFAABAAAAAAAAAAAAAAAAAAAACf/EABsQAAMBAQADAAAAAAAAAAAAAAECAwQFABEx/9oACAEBAAA/AC06fW6va0ps7PT179E88MiV02arrCEkjGQZiSEnKc5ovxURVHoADz//2Q==",f={canvas:!1,offscreen_canvas:!1,may_be_worker:!1,create_image_bitmap:!1,safari_put_image_data_fix:!1,bug_canvas_orientation_region:!0,bug_image_bitmap_orientation_region:!0,cib_resize:!1},u=!1,m=null;function d(){if("undefined"==typeof document||!document.createElement)return!1;try{const A=document.createElement("canvas");A.width=2,A.height=1;const t=A.getContext("2d");let e=t.createImageData(2,1);return e.data[0]=12,e.data[1]=23,e.data[2]=34,e.data[3]=255,e.data[4]=45,e.data[5]=56,e.data[6]=67,e.data[7]=255,t.putImageData(e,0,0),e=t.getImageData(0,0,2,1),12===e.data[0]&&23===e.data[1]&&34===e.data[2]&&255===e.data[3]&&45===e.data[4]&&56===e.data[5]&&67===e.data[6]&&255===e.data[7]}catch(p){return!1}}function w(){if("undefined"==typeof OffscreenCanvas)return!1;try{const A=new OffscreenCanvas(2,1).getContext("2d");let t=A.createImageData(2,1);return t.data[0]=12,t.data[1]=23,t.data[2]=34,t.data[3]=255,t.data[4]=45,t.data[5]=56,t.data[6]=67,t.data[7]=255,A.putImageData(t,0,0),t=A.getImageData(0,0,2,1),12===t.data[0]&&23===t.data[1]&&34===t.data[2]&&255===t.data[3]&&45===t.data[4]&&56===t.data[5]&&67===t.data[6]&&255===t.data[7]}catch(p){return!1}}function l(){return"undefined"!=typeof createImageBitmap}function y(){if(u)return Promise.resolve(Object.assign({},f));if(m)return m.then(()=>Object.assign({},f));f.canvas=d(),f.offscreen_canvas=w(),f.may_be_worker="undefined"!=typeof Worker&&"undefined"!=typeof URL&&!!URL.createObjectURL,f.create_image_bitmap=l(),f.safari_put_image_data_fix=function(){try{return!!("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.indexOf("Safari")>=0&&navigator.userAgent.indexOf("Chrome")<0)}catch(p){return!1}}();const A=Promise.resolve().then(()=>{if(w()&&l()&&"undefined"!=typeof Blob&&"undefined"!=typeof atob){const A=atob(c),t=new Uint8Array(A.length);for(let e=0;e<A.length;e++)t[e]=A.charCodeAt(e);return createImageBitmap(new Blob([t],{type:"image/jpeg"})).then(A=>{const t=new OffscreenCanvas(1,1);try{const e=t.getContext("2d");return e.drawImage(A,1,1,1,1,0,0,1,1),e.getImageData(0,0,1,1).data[0]<240}finally{A.close()}})}return!d()||"undefined"==typeof Image||new Promise(A=>{const t=new Image;t.onload=()=>{try{const e=document.createElement("canvas");e.width=1,e.height=1;const n=e.getContext("2d");n.drawImage(t,1,1,1,1,0,0,1,1),A(n.getImageData(0,0,1,1).data[0]<240)}catch(p){A(!0)}},t.onerror=()=>A(!0),t.src=`data:image/jpeg;base64,${c}`})}).catch(()=>!0).then(A=>{f.bug_canvas_orientation_region=A}).catch(()=>{}),t=Promise.resolve().then(()=>{if(!f.create_image_bitmap&&!l())return!0;if("undefined"==typeof Blob||"undefined"==typeof atob)return!0;const A=w(),t=d();if(!A&&!t)return!0;const e=atob(c),n=new Uint8Array(e.length);for(let a=0;a<e.length;a++)n[a]=e.charCodeAt(a);return createImageBitmap(new Blob([n],{type:"image/jpeg"})).then(t=>createImageBitmap(t,1,1,1,1).then(e=>{let n;A?n=new OffscreenCanvas(1,1):(n=document.createElement("canvas"),n.width=1,n.height=1);try{const A=n.getContext("2d");return A.drawImage(e,0,0),1!==e.width||1!==e.height||A.getImageData(0,0,1,1).data[0]<240}finally{t.close(),e.close()}},()=>(t.close(),!0)))}).catch(()=>!0).then(A=>{f.bug_image_bitmap_orientation_region=A}).catch(()=>{}),e=Promise.resolve().then(()=>{if(!l())return!1;const A=20;let t;if(f.canvas||d())t=document.createElement("canvas"),t.width=A,t.height=A;else{if(!f.offscreen_canvas&&!w())return!1;t=new OffscreenCanvas(A,A),t.getContext("2d").clearRect(0,0,A,A)}return createImageBitmap(t,0,0,A,A,{resizeWidth:5,resizeHeight:5,resizeQuality:"high"}).then(A=>{const e=5===A.width&&!!A.close;return A.close&&A.close(),t=null,e})}).catch(()=>!1).then(A=>{f.cib_resize=A}).catch(()=>{});return m=Promise.all([A,t,e]).then(()=>(u=!0,m=null,Object.assign({},f)),A=>{throw m=null,A})}var _=self,b=null;function D(A,t){return b||(b=new C(A.features)),b.resizeAndUnsharp(t)}function M(A){if("bitmap"===A.job.kind)return void function(A,t){let e=new OffscreenCanvas(t.width,t.height);const n=e.getContext("2d");n.drawImage(t.src,0,0);const a=n.getImageData(0,0,t.width,t.height).data;e.width=e.height=0,e=null,t.src.close();const i=D(A,{src:a,width:t.width,height:t.height,toWidth:t.toWidth,toHeight:t.toHeight,scaleX:t.scaleX,scaleY:t.scaleY,offsetX:t.offsetX,offsetY:t.offsetY,filter:t.filter,unsharpAmount:t.unsharpAmount,unsharpRadius:t.unsharpRadius,unsharpThreshold:t.unsharpThreshold}),r=new OffscreenCanvas(t.toWidth,t.toHeight),s=r.getContext("2d"),o=s.createImageData(t.toWidth,t.toHeight);o.data.set(i),s.putImageData(o,0,0);const g=r.transferToImageBitmap();_.postMessage({kind:"bitmap",data:g},[g])}(A,A.job);const t=D(A,A.job);_.postMessage({kind:"array",data:t},[t.buffer])}_.onmessage=function(A){Promise.resolve().then(()=>function(A){switch(A.method){case"get_supported_features":return y().then(A=>{_.postMessage({data:A})});case"resize":return M(A),Promise.resolve();default:return Promise.reject(new Error(`Unknown worker method: ${A.method}`))}}(A.data)).catch(A=>{_.postMessage({err:A})})}}();\n//# sourceURL=pica-inline-worker.js',P=1;"undefined"!=typeof navigator&&(P=Math.min(navigator.hardwareConcurrency||1,4));var K={tile:1024,concurrency:P,features:["js","wasm","ww"],idle:2e3},Z={filter:"mks2013",unsharpAmount:0,unsharpRadius:0,unsharpThreshold:0},N=class{constructor(A){Q(this,"options",void 0),Q(this,"__limit",void 0),Q(this,"resize_features",void 0),Q(this,"__workersPool",void 0),Q(this,"capabilities",void 0),Q(this,"__requested_features",void 0),Q(this,"__mathlib",void 0),Q(this,"__initPromise",void 0),this.options=Object.assign({},K,A||{}),(this.options.features.indexOf("ww")>=0||this.options.features.indexOf("all")>=0)&&this.options.workerURL,this.__limit=function(A){let t=0;const e=[];function i(){var i;t<A&&e.length&&(t++,null===(i=e.shift())||void 0===i||i())}return function(A){return new Promise((n,a)=>{e.push(()=>{A().then(A=>{n(A),t--,i()},A=>{a(A),t--,i()})}),i()})}}(this.options.concurrency),this.resize_features={js:!1,wasm:!1,cib:!1,ww:!1},this.__workersPool=null,this.capabilities={worker:!1,ww_offscreen_canvas:!1,canvas:!1,offscreen_canvas:!1,may_be_worker:!1,create_image_bitmap:!1,safari_put_image_data_fix:!1,bug_canvas_orientation_region:!0,bug_image_bitmap_orientation_region:!0,cib_resize:!1},this.__requested_features=[],this.__mathlib=null}init(){return this.__initPromise||(this.__initPromise=this.__init()),this.__initPromise}__init(){var A=this;return J(function*(){let t=A.options.features.slice();t.indexOf("all")>=0&&(t=["cib","wasm","js","ww"]),A.__requested_features=t,A.__mathlib=new B(t);const e=yield Y();if(Object.assign(A.capabilities,e),A.capabilities.cib_resize&&t.indexOf("cib")>=0&&(A.resize_features.cib=!0),A.capabilities.may_be_worker&&t.indexOf("ww")>=0&&q&&(A.__workersPool=new m(()=>A.__createWorkerSlot(),A.options.idle)),A.__workersPool)try{const t=yield A.__invokeWorker("get_supported_features"),e=t&&t.data;e&&(A.capabilities.worker=!0,A.resize_features.ww=!0,A.capabilities.ww_offscreen_canvas=!!e.offscreen_canvas)}catch(z){}const i=yield A.__mathlib.init();return Object.assign(A.resize_features,i.features),A})()}createCanvas(A,t,e){if(e&&this.capabilities.offscreen_canvas)return new OffscreenCanvas(A,t);if(this.capabilities.canvas){const e=document.createElement("canvas");return e.width=A,e.height=t,e}if(this.capabilities.ww_offscreen_canvas)return new OffscreenCanvas(A,t);throw new Error("Pica: cannot create canvas")}__createWorkerSlot(){if(this.options.workerURL){const A=new Worker(String(this.options.workerURL));return{value:A,destroy(){A.terminate()}}}{const A=window.URL.createObjectURL(new Blob([q],{type:"text/javascript"})),t=new Worker(A);return{value:t,destroy(){var e,i;(t.terminate(),"undefined"!=typeof window)&&(null===(e=window.URL)||void 0===e||null===(i=e.revokeObjectURL)||void 0===i||i.call(e,A))}}}}__invokeWorker(A,t,e,i){return new Promise((n,a)=>{const r=this.__workersPool.acquire();i&&i.cancelToken&&i.cancelToken.catch(A=>a(A)),r.value.onmessage=A=>{r.release(),A.data.err?a(A.data.err):n(A.data)},r.value.postMessage(Object.assign({method:A},t||{}),e||[])})}__invokeResize(A,t){var e=this;return J(function*(){if(yield Promise.resolve(),!e.resize_features.ww){if("array"!==A.kind)throw new Error("Pica: resize tile data is missing");const t={src:A.src,width:A.width,height:A.height,toWidth:A.toWidth,toHeight:A.toHeight,scaleX:A.scaleX,scaleY:A.scaleY,offsetX:A.offsetX,offsetY:A.offsetY,filter:A.filter,unsharpAmount:A.unsharpAmount,unsharpRadius:A.unsharpRadius,unsharpThreshold:A.unsharpThreshold};return{kind:"array",data:e.__mathlib.resizeAndUnsharp(t)}}const i=[];return"array"===A.kind?i.push(A.src.buffer):i.push(A.src),e.__invokeWorker("resize",{job:A,features:e.__requested_features},i,t)})()}__extractTileData(A,t,e,i){if(this.resize_features.ww&&this.capabilities.ww_offscreen_canvas){this.debug("Create tile imageBitmap");const n=this.createCanvas(A.width,A.height,{preferOffscreen:!0});if(n.getContext("2d").drawImage(e.srcImageBitmap||t,A.x,A.y,A.width,A.height,0,0,A.width,A.height),!("transferToImageBitmap"in n))throw new Error("Pica: offscreen canvas is not available for worker transfer");return Object.assign({},i,{kind:"bitmap",src:n.transferToImageBitmap()})}if(_(t))return e.srcCtx||(e.srcCtx=t.getContext("2d")),this.debug("Get tile pixel data"),Object.assign({},i,{kind:"array",src:e.srcCtx.getImageData(A.x,A.y,A.width,A.height).data});this.debug("Draw tile imageBitmap/image to temporary canvas");const n=this.createCanvas(A.width,A.height,{preferOffscreen:!0}),a=n.getContext("2d");a.globalCompositeOperation="copy",a.drawImage(e.srcImageBitmap||t,A.x,A.y,A.width,A.height,0,0,A.width,A.height),this.debug("Get tile pixel data");const r=a.getImageData(0,0,A.width,A.height).data;return n.width=n.height=0,Object.assign({},i,{kind:"array",src:r})}__landTileData(A,t,e){if("bitmap"===t.kind)return e.toCtx.drawImage(t.data,A.toX,A.toY),t.data.close(),null;this.debug("Draw tile");const i=e.toCtx.createImageData(A.toWidth,A.toHeight);return i.data.set(t.data),this.capabilities.safari_put_image_data_fix?e.toCtx.putImageData(i,A.toX,A.toY,A.toInnerX-A.toX,A.toInnerY-A.toY,A.toInnerWidth+1e-5,A.toInnerHeight+1e-5):e.toCtx.putImageData(i,A.toX,A.toY,A.toInnerX-A.toX,A.toInnerY-A.toY,A.toInnerWidth,A.toInnerHeight),null}__tileAndResize(A,t,e,i){var n=this;return J(function*(){const a={srcCtx:null,srcImageBitmap:null,isImageBitmapReused:!1,toCtx:null};if(yield Promise.resolve(),a.toCtx=t.getContext("2d"),_(A));else if(y(A))a.srcImageBitmap=A,a.isImageBitmapReused=!0;else{if(!b(A))throw new Error('Pica: ".from" should be Image, Canvas or ImageBitmap');if(n.capabilities.create_image_bitmap){n.debug("Decode image via createImageBitmap");try{a.srcImageBitmap=yield createImageBitmap(A)}catch(z){}}}if(i.canceled)return i.cancelToken;n.debug("Calculate tiles");const r=function(A){const t=A.toWidth/A.width,e=A.toHeight/A.height,i=U(A.srcTileSize*t)-2*A.destTileBorder,n=U(A.srcTileSize*e)-2*A.destTileBorder;if(i<1||n<1)throw new Error("Internal error in pica: target tile width/height is too small.");let a,r,s,o,g,h;const c=[];let I;for(o=0;o<A.toHeight;o+=n)for(s=0;s<A.toWidth;s+=i)a=s-A.destTileBorder,a<0&&(a=0),g=s+i+A.destTileBorder-a,a+g>=A.toWidth&&(g=A.toWidth-a),r=o-A.destTileBorder,r<0&&(r=0),h=o+n+A.destTileBorder-r,r+h>=A.toHeight&&(h=A.toHeight-r),I={toX:a,toY:r,toWidth:g,toHeight:h,toInnerX:s,toInnerY:o,toInnerWidth:i,toInnerHeight:n,offsetX:a/t-U(a/t),offsetY:r/e-U(r/e),scaleX:t,scaleY:e,x:U(a/t),y:U(r/e),width:R(g/t),height:R(h/e)},c.push(I);return c}({width:e.width,height:e.height,srcTileSize:n.options.tile,toWidth:e.toWidth,toHeight:e.toHeight,destTileBorder:Math.ceil(Math.max(3,2.5*e.unsharpRadius|0))}).map(t=>(t=>n.__limit(J(function*(){if(i.canceled)return i.cancelToken;const r={width:t.width,height:t.height,toWidth:t.toWidth,toHeight:t.toHeight,scaleX:t.scaleX,scaleY:t.scaleY,offsetX:t.offsetX,offsetY:t.offsetY,filter:e.filter,unsharpAmount:e.unsharpAmount,unsharpRadius:e.unsharpRadius,unsharpThreshold:e.unsharpThreshold};n.debug("Invoke resize math");const s=yield n.__extractTileData(t,A,a,r);n.debug("Invoke resize math");const o=yield n.__invokeResize(s,i);return i.canceled?i.cancelToken:n.__landTileData(t,o,a)})))(t));function s(A){A.srcImageBitmap&&(A.isImageBitmapReused||A.srcImageBitmap.close(),A.srcImageBitmap=null)}n.debug("Process tiles");try{return yield Promise.all(r),n.debug("Finished!"),s(a),t}catch(o){throw s(a),o}})()}__planStagesAndResize(A,t,e,i){var n=this;return J(function*(){let a=A,r=e.width,s=e.height;const o=function(A,t,e,i,n){const a=e/A,r=i/t,s=9/n;if(s>.5)return[[e,i]];const o=Math.ceil(Math.log(Math.min(a,r))/Math.log(s));if(o<=1)return[[