forked from nodeca/image-blob-reduce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage-blob-reduce.min.js
8 lines (6 loc) · 48.3 KB
/
image-blob-reduce.min.js
1
2
3
4
5
6
7
8
/*! image-blob-reduce 4.1.0 https://github.com/nodeca/image-blob-reduce @license MIT */
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).ImageBlobReduce=e()}(this,(function(){"use strict";function t(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var e={};function r(t,e){var r={};return e.forEach((function(e){Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=t[e])})),r}e.assign=function(t){for(var e,r=1;r<arguments.length;r++)for(var i in e=Object(arguments[r]))Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},e.pick=r,e.pick_pica_resize_options=function(t){return r(t,["alpha","unsharpAmount","unsharpRadius","unsharpThreshold","cancelToken"])};var i={exports:{}};
/*!
pica
https://github.com/nodeca/pica
*/!function(e,r){e.exports=function(){function e(r,i,n){function a(A,s){if(!i[A]){if(!r[A]){var u="function"==typeof t&&t;if(!s&&u)return u(A,!0);if(o)return o(A,!0);var h=new Error("Cannot find module '"+A+"'");throw h.code="MODULE_NOT_FOUND",h}var f=i[A]={exports:{}};r[A][0].call(f.exports,(function(t){return a(r[A][1][t]||t)}),f,f.exports,e,r,i,n)}return i[A].exports}for(var o="function"==typeof t&&t,A=0;A<n.length;A++)a(n[A]);return a}return e}()({1:[function(t,e,r){var i=t("multimath"),n=t("./mm_unsharp_mask"),a=t("./mm_resize");function o(t){var e=t||[],r={js:e.indexOf("js")>=0,wasm:e.indexOf("wasm")>=0};i.call(this,r),this.features={js:r.js,wasm:r.wasm&&this.has_wasm()},this.use(n),this.use(a)}o.prototype=Object.create(i.prototype),o.prototype.constructor=o,o.prototype.resizeAndUnsharp=function(t,e){var r=this.resize(t,e);return t.unsharpAmount&&this.unsharp_mask(r,t.toWidth,t.toHeight,t.unsharpAmount,t.unsharpRadius,t.unsharpThreshold),r},e.exports=o},{"./mm_resize":4,"./mm_unsharp_mask":9,multimath:19}],2:[function(t,e,r){function i(t){return t<0?0:t>255?255:t}function n(t){return t>=0?t:0}function a(t,e,r,i,a,o){var A,s,u,h,f,c,g,l,d,p,I,m=0,_=0;for(d=0;d<i;d++){for(f=0,p=0;p<a;p++){for(c=o[f++],g=o[f++],l=m+4*c|0,A=s=u=h=0;g>0;g--)h=h+(I=o[f++])*t[l+3]|0,u=u+I*t[l+2]|0,s=s+I*t[l+1]|0,A=A+I*t[l]|0,l=l+4|0;e[_+3]=n(h>>7),e[_+2]=n(u>>7),e[_+1]=n(s>>7),e[_]=n(A>>7),_=_+4*i|0}_=4*(d+1)|0,m=(d+1)*r*4|0}}function o(t,e,r,n,a,o){var A,s,u,h,f,c,g,l,d,p,I,m=0,_=0;for(d=0;d<n;d++){for(f=0,p=0;p<a;p++){for(c=o[f++],g=o[f++],l=m+4*c|0,A=s=u=h=0;g>0;g--)h=h+(I=o[f++])*t[l+3]|0,u=u+I*t[l+2]|0,s=s+I*t[l+1]|0,A=A+I*t[l]|0,l=l+4|0;A>>=7,s>>=7,u>>=7,h>>=7,e[_+3]=i(h+(1<<13)>>14),e[_+2]=i(u+(1<<13)>>14),e[_+1]=i(s+(1<<13)>>14),e[_]=i(A+(1<<13)>>14),_=_+4*n|0}_=4*(d+1)|0,m=(d+1)*r*4|0}}function A(t,e,r,i,a,o){var A,s,u,h,f,c,g,l,d,p,I,m,_=0,w=0;for(p=0;p<i;p++){for(c=0,I=0;I<a;I++){for(g=o[c++],l=o[c++],d=_+4*g|0,A=s=u=h=0;l>0;l--)h=h+(m=o[c++])*(f=t[d+3])|0,u=u+m*t[d+2]*f|0,s=s+m*t[d+1]*f|0,A=A+m*t[d]*f|0,d=d+4|0;u=u/255|0,s=s/255|0,A=A/255|0,e[w+3]=n(h>>7),e[w+2]=n(u>>7),e[w+1]=n(s>>7),e[w]=n(A>>7),w=w+4*i|0}w=4*(p+1)|0,_=(p+1)*r*4|0}}function s(t,e,r,n,a,o){var A,s,u,h,f,c,g,l,d,p,I,m=0,_=0;for(d=0;d<n;d++){for(f=0,p=0;p<a;p++){for(c=o[f++],g=o[f++],l=m+4*c|0,A=s=u=h=0;g>0;g--)h=h+(I=o[f++])*t[l+3]|0,u=u+I*t[l+2]|0,s=s+I*t[l+1]|0,A=A+I*t[l]|0,l=l+4|0;A>>=7,s>>=7,u>>=7,(h=i((h>>=7)+(1<<13)>>14))>0&&(A=255*A/h|0,s=255*s/h|0,u=255*u/h|0),e[_+3]=h,e[_+2]=i(u+(1<<13)>>14),e[_+1]=i(s+(1<<13)>>14),e[_]=i(A+(1<<13)>>14),_=_+4*n|0}_=4*(d+1)|0,m=(d+1)*r*4|0}}e.exports={convolveHor:a,convolveVert:o,convolveHorWithPre:A,convolveVertWithPre:s}},{}],3:[function(t,e,r){e.exports="AGFzbQEAAAAADAZkeWxpbmsAAAAAAAEYA2AGf39/f39/AGAAAGAIf39/f39/f38AAg8BA2VudgZtZW1vcnkCAAADBwYBAAAAAAIGBgF/AEEACweUAQgRX193YXNtX2NhbGxfY3RvcnMAAAtjb252b2x2ZUhvcgABDGNvbnZvbHZlVmVydAACEmNvbnZvbHZlSG9yV2l0aFByZQADE2NvbnZvbHZlVmVydFdpdGhQcmUABApjb252b2x2ZUhWAAUMX19kc29faGFuZGxlAwAYX193YXNtX2FwcGx5X2RhdGFfcmVsb2NzAAAKyA4GAwABC4wDARB/AkAgA0UNACAERQ0AIANBAnQhFQNAQQAhE0EAIQsDQCALQQJqIQcCfyALQQF0IAVqIgYuAQIiC0UEQEEAIQhBACEGQQAhCUEAIQogBwwBCyASIAYuAQBqIQhBACEJQQAhCiALIRRBACEOIAchBkEAIQ8DQCAFIAZBAXRqLgEAIhAgACAIQQJ0aigCACIRQRh2bCAPa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ALIBQgC0EBaiILbCERIAMgC0cNAAsLC0AAIAcEQEEAIAIgAyAEIAUgABADIAJBACAEIAUgBiABEAQPC0EAIAIgAyAEIAUgABABIAJBACAEIAUgBiABEAIL"},{}],4:[function(t,e,r){e.exports={name:"resize",fn:t("./resize"),wasm_fn:t("./resize_wasm"),wasm_src:t("./convolve_wasm_base64")}},{"./convolve_wasm_base64":3,"./resize":5,"./resize_wasm":8}],5:[function(t,e,r){var i=t("./resize_filter_gen"),n=t("./convolve"),a=n.convolveHor,o=n.convolveVert,A=n.convolveHorWithPre,s=n.convolveVertWithPre;function u(t,e,r){for(var i=3,n=e*r*4|0;i<n;){if(255!==t[i])return!0;i=i+4|0}return!1}function h(t,e,r){for(var i=3,n=e*r*4|0;i<n;)t[i]=255,i=i+4|0}e.exports=function(t){var e=t.src,r=t.width,n=t.height,f=t.toWidth,c=t.toHeight,g=t.scaleX||t.toWidth/t.width,l=t.scaleY||t.toHeight/t.height,d=t.offsetX||0,p=t.offsetY||0,I=t.dest||new Uint8Array(f*c*4),m=void 0===t.filter?"mks2013":t.filter,_=i(m,r,f,g,d),w=i(m,n,c,l,p),B=new Uint16Array(f*n*4);return u(e,r,n)?(A(e,B,r,n,f,_),s(B,I,n,f,c,w)):(a(e,B,r,n,f,_),o(B,I,n,f,c,w),h(I,f,c)),I}},{"./convolve":2,"./resize_filter_gen":6}],6:[function(t,e,r){var i=t("./resize_filter_info"),n=14;function a(t){return Math.round(t*((1<<n)-1))}e.exports=function(t,e,r,n,o){var A,s,u,h,f,c,g,l,d,p,I,m,_,w,B,E,b,Q=i.filter[t].fn,v=1/n,y=Math.min(1,n),C=i.filter[t].win/y,x=Math.floor(2*(C+1)),D=new Int16Array((x+2)*r),M=0,U=!D.subarray||!D.set;for(A=0;A<r;A++){for(s=(A+.5)*v+o,u=Math.max(0,Math.floor(s-C)),f=(h=Math.min(e-1,Math.ceil(s+C)))-u+1,c=new Float32Array(f),g=new Int16Array(f),l=0,d=u,p=0;d<=h;d++,p++)l+=I=Q((d+.5-s)*y),c[p]=I;for(m=0,p=0;p<c.length;p++)m+=_=c[p]/l,g[p]=a(_);for(g[r>>1]+=a(1-m),w=0;w<g.length&&0===g[w];)w++;if(w<g.length){for(B=g.length-1;B>0&&0===g[B];)B--;if(E=u+w,b=B-w+1,D[M++]=E,D[M++]=b,U)for(p=w;p<=B;p++)D[M++]=g[p];else D.set(g.subarray(w,B+1),M),M+=b}else D[M++]=0,D[M++]=0}return D}},{"./resize_filter_info":7}],7:[function(t,e,r){var i={box:{win:.5,fn:function(t){return t<0&&(t=-t),t<.5?1:0}},hamming:{win:1,fn:function(t){if(t<0&&(t=-t),t>=1)return 0;if(t<1.1920929e-7)return 1;var e=t*Math.PI;return Math.sin(e)/e*(.54+.46*Math.cos(e/1))}},lanczos2:{win:2,fn:function(t){if(t<0&&(t=-t),t>=2)return 0;if(t<1.1920929e-7)return 1;var e=t*Math.PI;return Math.sin(e)/e*Math.sin(e/2)/(e/2)}},lanczos3:{win:3,fn:function(t){if(t<0&&(t=-t),t>=3)return 0;if(t<1.1920929e-7)return 1;var e=t*Math.PI;return Math.sin(e)/e*Math.sin(e/3)/(e/3)}},mks2013:{win:2.5,fn:function(t){return t<0&&(t=-t),t>=2.5?0:t>=1.5?-.125*(t-2.5)*(t-2.5):t>=.5?.25*(4*t*t-11*t+7):1.0625-1.75*t*t}}};e.exports={filter:i,f2q:{box:0,hamming:1,lanczos2:2,lanczos3:3},q2f:["box","hamming","lanczos2","lanczos3"]}},{}],8:[function(t,e,r){var i=t("./resize_filter_gen");function n(t,e,r){for(var i=3,n=e*r*4|0;i<n;){if(255!==t[i])return!0;i=i+4|0}return!1}function a(t,e,r){for(var i=3,n=e*r*4|0;i<n;)t[i]=255,i=i+4|0}function o(t){return new Uint8Array(t.buffer,0,t.byteLength)}var A=!0;try{A=1===new Uint32Array(new Uint8Array([1,0,0,0]).buffer)[0]}catch(t){}function s(t,e,r){if(A)e.set(o(t),r);else for(var i=r,n=0;n<t.length;n++){var a=t[n];e[i++]=255&a,e[i++]=a>>8&255}}e.exports=function(t){var e=t.src,r=t.width,o=t.height,A=t.toWidth,u=t.toHeight,h=t.scaleX||t.toWidth/t.width,f=t.scaleY||t.toHeight/t.height,c=t.offsetX||0,g=t.offsetY||0,l=t.dest||new Uint8Array(A*u*4),d=void 0===t.filter?"mks2013":t.filter,p=i(d,r,A,h,c),I=i(d,o,u,f,g),m=0,_=Math.max(e.byteLength,l.byteLength),w=this.__align(m+_),B=o*A*4*2,E=this.__align(w+B),b=this.__align(E+p.byteLength),Q=b+I.byteLength,v=this.__instance("resize",Q),y=new Uint8Array(this.__memory.buffer),C=new Uint32Array(this.__memory.buffer),x=new Uint32Array(e.buffer);C.set(x),s(p,y,E),s(I,y,b);var D=v.exports.convolveHV||v.exports._convolveHV;return n(e,r,o)?D(E,b,w,r,o,A,u,1):(D(E,b,w,r,o,A,u,0),a(l,A,u)),new Uint32Array(l.buffer).set(new Uint32Array(this.__memory.buffer,0,u*A)),l}},{"./resize_filter_gen":6}],9:[function(t,e,r){e.exports={name:"unsharp_mask",fn:t("./unsharp_mask"),wasm_fn:t("./unsharp_mask_wasm"),wasm_src:t("./unsharp_mask_wasm_base64")}},{"./unsharp_mask":10,"./unsharp_mask_wasm":11,"./unsharp_mask_wasm_base64":12}],10:[function(t,e,r){var i=t("glur/mono16");function n(t,e,r){for(var i,n,a,o,A=e*r,s=new Uint16Array(A),u=0;u<A;u++)i=t[4*u],n=t[4*u+1],a=t[4*u+2],o=i>=n&&i>=a?i:n>=a&&n>=i?n:a,s[u]=o<<8;return s}e.exports=function(t,e,r,a,o,A){var s,u,h,f,c;if(!(0===a||o<.5)){o>2&&(o=2);var g=n(t,e,r),l=new Uint16Array(g);i(l,e,r,o);for(var d=a/100*4096+.5|0,p=A<<8,I=e*r,m=0;m<I;m++)f=(s=g[m])-l[m],Math.abs(f)>=p&&(h=((u=(u=(u=s+(d*f+2048>>12))>65280?65280:u)<0?0:u)<<12)/(s=0!==s?s:1)|0,t[c=4*m]=t[c]*h+2048>>12,t[c+1]=t[c+1]*h+2048>>12,t[c+2]=t[c+2]*h+2048>>12)}}},{"glur/mono16":18}],11:[function(t,e,r){e.exports=function(t,e,r,i,n,a){if(!(0===i||n<.5)){n>2&&(n=2);var o=e*r,A=4*o,s=2*o,u=2*o,h=4*Math.max(e,r),f=8*4,c=0,g=A,l=g+s,d=l+u,p=d+u,I=p+h,m=this.__instance("unsharp_mask",A+s+2*u+h+f,{exp:Math.exp}),_=new Uint32Array(t.buffer);new Uint32Array(this.__memory.buffer).set(_);var w=m.exports.hsv_v16||m.exports._hsv_v16;w(c,g,e,r),(w=m.exports.blurMono16||m.exports._blurMono16)(g,l,d,p,I,e,r,n),(w=m.exports.unsharp||m.exports._unsharp)(c,c,g,l,e,r,i,a),_.set(new Uint32Array(this.__memory.buffer,0,o))}}},{}],12:[function(t,e,r){e.exports="AGFzbQEAAAAADAZkeWxpbmsAAAAAAAE0B2AAAGAEf39/fwBgBn9/f39/fwBgCH9/f39/f39/AGAIf39/f39/f30AYAJ9fwBgAXwBfAIZAgNlbnYDZXhwAAYDZW52Bm1lbW9yeQIAAAMHBgAFAgQBAwYGAX8AQQALB4oBCBFfX3dhc21fY2FsbF9jdG9ycwABFl9fYnVpbGRfZ2F1c3NpYW5fY29lZnMAAg5fX2dhdXNzMTZfbGluZQADCmJsdXJNb25vMTYABAdoc3ZfdjE2AAUHdW5zaGFycAAGDF9fZHNvX2hhbmRsZQMAGF9fd2FzbV9hcHBseV9kYXRhX3JlbG9jcwABCsUMBgMAAQvWAQEHfCABRNuGukOCGvs/IAC7oyICRAAAAAAAAADAohAAIgW2jDgCFCABIAKaEAAiAyADoCIGtjgCECABRAAAAAAAAPA/IAOhIgQgBKIgAyACIAKgokQAAAAAAADwP6AgBaGjIgS2OAIAIAEgBSAEmqIiB7Y4AgwgASADIAJEAAAAAAAA8D+gIASioiIItjgCCCABIAMgAkQAAAAAAADwv6AgBKKiIgK2OAIEIAEgByAIoCAF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IAuaoiIOtjgCDCAEIAogCUQAAAAAAADwP6AgC6KiIg+2OAIIIAQgCiAJRAAAAAAAAPC/oCALoqIiCbY4AgQgBCAOIA+gIAxEAAAAAAAA8D8gDaGgIgqjtjgCHCAEIAsgCaAgCqO2OAIYIAYEQANAIAAgBSAIbEEBdGogAiAIQQF0aiADIAQgBSAGEAMgCEEBaiIIIAZHDQALCyAFRQ0AQQAhCANAIAIgBiAIbEEBdGogASAIQQF0aiADIAQgBiAFEAMgCEEBaiIIIAVHDQALCwtxAQN/IAIgA2wiBQRAA0AgASAAKAIAIgRBEHZB/wFxIgIgAiAEQQh2Qf8BcSIDIAMgBEH/AXEiBEkbIAIgA0sbIgYgBiAEIAIgBEsbIAMgBEsbQQh0OwEAIAFBAmohASAAQQRqIQAgBUEBayIFDQALCwuZAgIDfwF8IAQgBWwhBAJ/IAazQwAAgEWUQwAAyEKVu0QAAAAAAADgP6AiC5lEAAAAAAAA4EFjBEAgC6oMAQtBgICAgHgLIQUgBARAIAdBCHQhCUEAIQYDQCAJIAIgBkEBdCIHai8BACIBIAMgB2ovAQBrIgcgB0EfdSIIaiAIc00EQCAAIAZBAnQiCGoiCiAFIAdsQYAQakEMdSABaiIHQYD+AyAHQYD+A0gbIgdBACAHQQBKG0EMdCABQQEgARtuIgEgCi0AAGxBgBBqQQx2OgAAIAAgCEEBcmoiByABIActAABsQYAQakEMdjoAACAAIAhBAnJqIgcgASAHLQAAbEGAEGpBDHY6AAALIAZBAWoiBiAERw0ACwsL"},{}],13:[function(t,e,r){var i=100;function n(t,e){this.create=t,this.available=[],this.acquired={},this.lastId=1,this.timeoutId=0,this.idle=e||2e3}n.prototype.acquire=function(){var t,e=this;return 0!==this.available.length?t=this.available.pop():((t=this.create()).id=this.lastId++,t.release=function(){return e.release(t)}),this.acquired[t.id]=t,t},n.prototype.release=function(t){var e=this;delete this.acquired[t.id],t.lastUsed=Date.now(),this.available.push(t),0===this.timeoutId&&(this.timeoutId=setTimeout((function(){return e.gc()}),i))},n.prototype.gc=function(){var t=this,e=Date.now();this.available=this.available.filter((function(r){return!(e-r.lastUsed>t.idle&&(r.destroy(),1))})),0!==this.available.length?this.timeoutId=setTimeout((function(){return t.gc()}),i):this.timeoutId=0},e.exports=n},{}],14:[function(t,e,r){var i=2;e.exports=function(t,e,r,n,a,o){var A=r/t,s=n/e,u=(2*o+i+1)/a;if(u>.5)return[[r,n]];var h=Math.ceil(Math.log(Math.min(A,s))/Math.log(u));if(h<=1)return[[r,n]];for(var f=[],c=0;c<h;c++){var g=Math.round(Math.pow(Math.pow(t,h-c-1)*Math.pow(r,c+1),1/h)),l=Math.round(Math.pow(Math.pow(e,h-c-1)*Math.pow(n,c+1),1/h));f.push([g,l])}return f}},{}],15:[function(t,e,r){var i=1e-5;function n(t){var e=Math.round(t);return Math.abs(t-e)<i?e:Math.floor(t)}function a(t){var e=Math.round(t);return Math.abs(t-e)<i?e:Math.ceil(t)}e.exports=function(t){var e,r,i,o,A,s,u=t.toWidth/t.width,h=t.toHeight/t.height,f=n(t.srcTileSize*u)-2*t.destTileBorder,c=n(t.srcTileSize*h)-2*t.destTileBorder;if(f<1||c<1)throw new Error("Internal error in pica: target tile width/height is too small.");var g,l=[];for(o=0;o<t.toHeight;o+=c)for(i=0;i<t.toWidth;i+=f)(e=i-t.destTileBorder)<0&&(e=0),e+(A=i+f+t.destTileBorder-e)>=t.toWidth&&(A=t.toWidth-e),(r=o-t.destTileBorder)<0&&(r=0),r+(s=o+c+t.destTileBorder-r)>=t.toHeight&&(s=t.toHeight-r),g={toX:e,toY:r,toWidth:A,toHeight:s,toInnerX:i,toInnerY:o,toInnerWidth:f,toInnerHeight:c,offsetX:e/u-n(e/u),offsetY:r/h-n(r/h),scaleX:u,scaleY:h,x:n(e/u),y:n(r/h),width:a(A/u),height:a(s/h)},l.push(g);return l}},{}],16:[function(t,e,r){function i(t){return Object.prototype.toString.call(t)}e.exports.isCanvas=function(t){var e=i(t);return"[object HTMLCanvasElement]"===e||"[object OffscreenCanvas]"===e||"[object Canvas]"===e},e.exports.isImage=function(t){return"[object HTMLImageElement]"===i(t)},e.exports.isImageBitmap=function(t){return"[object ImageBitmap]"===i(t)},e.exports.limiter=function(t){var e=0,r=[];function i(){e<t&&r.length&&(e++,r.shift()())}return function(t){return new Promise((function(n,a){r.push((function(){t().then((function(t){n(t),e--,i()}),(function(t){a(t),e--,i()}))})),i()}))}},e.exports.cib_quality_name=function(t){switch(t){case 0:return"pixelated";case 1:return"low";case 2:return"medium"}return"high"},e.exports.cib_support=function(t){return Promise.resolve().then((function(){if("undefined"==typeof createImageBitmap)return!1;var e=t(100,100);return createImageBitmap(e,0,0,100,100,{resizeWidth:10,resizeHeight:10,resizeQuality:"high"}).then((function(t){var r=10===t.width;return t.close(),e=null,r}))}))["catch"]((function(){return!1}))},e.exports.worker_offscreen_canvas_support=function(){return new Promise((function(t,e){if("undefined"!=typeof OffscreenCanvas){var r=btoa("(".concat(n.toString(),")(self);")),i=new Worker("data:text/javascript;base64,".concat(r));i.onmessage=function(e){return t(e.data)},i.onerror=e}else t(!1);function n(t){"undefined"!=typeof createImageBitmap?Promise.resolve().then((function(){var t=new OffscreenCanvas(10,10);return t.getContext("2d").rect(0,0,1,1),createImageBitmap(t,0,0,1,1)})).then((function(){return t.postMessage(!0)}),(function(){return t.postMessage(!1)})):t.postMessage(!1)}})).then((function(t){return t}),(function(){return!1}))},e.exports.can_use_canvas=function(t){var e=!1;try{var r=t(2,1).getContext("2d"),i=r.createImageData(2,1);i.data[0]=12,i.data[1]=23,i.data[2]=34,i.data[3]=255,i.data[4]=45,i.data[5]=56,i.data[6]=67,i.data[7]=255,r.putImageData(i,0,0),i=null,12===(i=r.getImageData(0,0,2,1)).data[0]&&23===i.data[1]&&34===i.data[2]&&255===i.data[3]&&45===i.data[4]&&56===i.data[5]&&67===i.data[6]&&255===i.data[7]&&(e=!0)}catch(t){}return e},e.exports.cib_can_use_region=function(){return new Promise((function(t){if("undefined"!=typeof createImageBitmap){var e=new Image;e.src="data:image/jpeg;base64,"+"/9j/4QBiRXhpZgAATU0AKgAAAAgABQESAAMAAAABAAYAAAEaAAUAAAABAAAASgEbAAUAA"+"AABAAAAUgEoAAMAAAABAAIAAAITAAMAAAABAAEAAAAAAAAAAABIAAAAAQAAAEgAAAAB/9"+"sAQwAEAwMEAwMEBAMEBQQEBQYKBwYGBgYNCQoICg8NEBAPDQ8OERMYFBESFxIODxUcFRc"+"ZGRsbGxAUHR8dGh8YGhsa/9sAQwEEBQUGBQYMBwcMGhEPERoaGhoaGhoaGhoaGhoaGhoa"+"GhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoa/8IAEQgAAQACAwERAAIRAQMRA"+"f/EABQAAQAAAAAAAAAAAAAAAAAAAAf/xAAUAQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAA"+"IQAxAAAAF/P//EABQQAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQEAAQUCf//EABQRAQAAAAA"+"AAAAAAAAAAAAAAAD/2gAIAQMBAT8Bf//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQIB"+"AT8Bf//EABQQAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQEABj8Cf//EABQQAQAAAAAAAAAAA"+"AAAAAAAAAD/2gAIAQEAAT8hf//aAAwDAQACAAMAAAAQH//EABQRAQAAAAAAAAAAAAAAAA"+"AAAAD/2gAIAQMBAT8Qf//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQIBAT8Qf//EABQ"+"QAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQEAAT8Qf//Z",e.onload=function(){createImageBitmap(e,0,0,e.width,e.height).then((function(r){r.width===e.width&&r.height===e.height?t(!0):t(!1)}),(function(){return t(!1)}))},e.onerror=function(){return t(!1)}}else t(!1)}))}},{}],17:[function(t,e,r){e.exports=function(){var e,r=t("./mathlib");onmessage=function(t){var i=t.data.opts;if(!i.src&&i.srcBitmap){var n=new OffscreenCanvas(i.width,i.height),a=n.getContext("2d");a.drawImage(i.srcBitmap,0,0),i.src=a.getImageData(0,0,i.width,i.height).data,n.width=n.height=0,n=null,i.srcBitmap.close(),i.srcBitmap=null}e||(e=new r(t.data.features));var o=e.resizeAndUnsharp(i);postMessage({data:o},[o.buffer])}}},{"./mathlib":1}],18:[function(t,e,r){var i,n,a,o,A,s;function u(t){t<.5&&(t=.5);var e=Math.exp(.726*.726)/t,r=Math.exp(-e),u=Math.exp(-2*e),h=(1-r)*(1-r)/(1+2*e*r-u);return i=h,n=h*(e-1)*r,a=h*(e+1)*r,o=-h*u,A=2*r,s=-u,new Float32Array([i,n,a,o,A,s,(i+n)/(1-A-s),(a+o)/(1-A-s)])}function h(t,e,r,i,n,a){var o,A,s,u,h,f,c,g,l,d,p,I,m,_;for(l=0;l<a;l++){for(c=l,g=0,u=h=(o=t[f=l*n])*i[6],p=i[0],I=i[1],m=i[4],_=i[5],d=0;d<n;d++)s=(A=t[f])*p+o*I+u*m+h*_,h=u,u=s,o=A,r[g]=u,g++,f++;for(g--,c+=a*(n-1),u=h=(o=t[--f])*i[7],A=o,p=i[2],I=i[3],d=n-1;d>=0;d--)s=A*p+o*I+u*m+h*_,h=u,u=s,o=A,A=t[f],e[c]=r[g]+u,f--,g--,c-=a}}function f(t,e,r,i){if(i){var n=new Uint16Array(t.length),a=new Float32Array(Math.max(e,r)),o=u(i);h(t,n,a,o,e,r),h(n,t,a,o,r,e)}}e.exports=f},{}],19:[function(t,e,r){var i=t("object-assign"),n=t("./lib/base64decode"),a=t("./lib/wa_detect"),o={js:!0,wasm:!0};function A(t){if(!(this instanceof A))return new A(t);var e=i({},o,t||{});if(this.options=e,this.__cache={},this.__init_promise=null,this.__modules=e.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')}A.prototype.has_wasm=a,A.prototype.use=function(t){return this.__modules[t.name]=t,this.options.wasm&&this.has_wasm()&&t.wasm_fn?this[t.name]=t.wasm_fn:this[t.name]=t.fn,this},A.prototype.init=function(){if(this.__init_promise)return this.__init_promise;if(!this.options.js&&this.options.wasm&&!this.has_wasm())return Promise.reject(new Error('mathlib: only "wasm" was enabled, but it\'s not supported'));var t=this;return this.__init_promise=Promise.all(Object.keys(t.__modules).map((function(e){var r=t.__modules[e];return t.options.wasm&&t.has_wasm()&&r.wasm_fn?t.__wasm[e]?null:WebAssembly.compile(t.__base64decode(r.wasm_src)).then((function(r){t.__wasm[e]=r})):null}))).then((function(){return t})),this.__init_promise},A.prototype.__base64decode=n,A.prototype.__reallocate=function(t){if(!this.__memory)return this.__memory=new WebAssembly.Memory({initial:Math.ceil(t/(64*1024))}),this.__memory;var e=this.__memory.buffer.byteLength;return e<t&&this.__memory.grow(Math.ceil((t-e)/(64*1024))),this.__memory},A.prototype.__instance=function(t,e,r){if(e&&this.__reallocate(e),!this.__wasm[t]){var n=this.__modules[t];this.__wasm[t]=new WebAssembly.Module(this.__base64decode(n.wasm_src))}if(!this.__cache[t]){var a={memoryBase:0,memory:this.__memory,tableBase:0,table:new WebAssembly.Table({initial:0,element:"anyfunc"})};this.__cache[t]=new WebAssembly.Instance(this.__wasm[t],{env:i(a,r||{})})}return this.__cache[t]},A.prototype.__align=function(t,e){var r=t%(e=e||8);return t+(r?e-r:0)},e.exports=A},{"./lib/base64decode":20,"./lib/wa_detect":21,"object-assign":22}],20:[function(t,e,r){var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";e.exports=function(t){for(var e=t.replace(/[\r\n=]/g,""),r=e.length,n=new Uint8Array(3*r>>2),a=0,o=0,A=0;A<r;A++)A%4==0&&A&&(n[o++]=a>>16&255,n[o++]=a>>8&255,n[o++]=255&a),a=a<<6|i.indexOf(e.charAt(A));var s=r%4*6;return 0===s?(n[o++]=a>>16&255,n[o++]=a>>8&255,n[o++]=255&a):18===s?(n[o++]=a>>10&255,n[o++]=a>>2&255):12===s&&(n[o++]=a>>4&255),n}},{}],21:[function(t,e,r){var i;e.exports=function(){if(void 0!==i)return i;if(i=!1,"undefined"==typeof WebAssembly)return i;try{var 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)&&(i=!0),i}catch(t){}return i}},{}],22:[function(t,e,r){var i=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable;function o(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}function A(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},r=0;r<10;r++)e["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(e).map((function(t){return e[t]})).join(""))return!1;var i={};return"abcdefghijklmnopqrst".split("").forEach((function(t){i[t]=t})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},i)).join("")}catch(t){return!1}}e.exports=A()?Object.assign:function(t,e){for(var r,A,s=o(t),u=1;u<arguments.length;u++){for(var h in r=Object(arguments[u]))n.call(r,h)&&(s[h]=r[h]);if(i){A=i(r);for(var f=0;f<A.length;f++)a.call(r,A[f])&&(s[A[f]]=r[A[f]])}}return s}},{}],23:[function(t,e,r){var i=arguments[3],n=arguments[4],a=arguments[5],o=JSON.stringify;e.exports=function(t,e){for(var r,A=Object.keys(a),s=0,u=A.length;s<u;s++){var h=A[s],f=a[h].exports;if(f===t||f&&f.default===t){r=h;break}}if(!r){r=Math.floor(Math.pow(16,8)*Math.random()).toString(16);var c={};for(s=0,u=A.length;s<u;s++)c[h=A[s]]=h;n[r]=["function(require,module,exports){"+t+"(self); }",c]}var g=Math.floor(Math.pow(16,8)*Math.random()).toString(16),l={};l[r]=r,n[g]=["function(require,module,exports){"+"var f = require("+o(r)+");"+"(f.default ? f.default : f)(self);"+"}",l];var d={};function p(t){for(var e in d[t]=!0,n[t][1]){var r=n[t][1][e];d[r]||p(r)}}p(g);var I="("+i+")({"+Object.keys(d).map((function(t){return o(t)+":["+n[t][0]+","+o(n[t][1])+"]"})).join(",")+"},{},["+o(g)+"])",m=window.URL||window.webkitURL||window.mozURL||window.msURL,_=new Blob([I],{type:"text/javascript"});if(e&&e.bare)return _;var w=m.createObjectURL(_),B=new Worker(w);return B.objectURL=w,B}},{}],"/index.js":[function(t,e,r){function i(t,e){return s(t)||A(t,e)||a(t,e)||n()}function n(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function a(t,e){if(t){if("string"==typeof t)return o(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(t,e):void 0}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=new Array(e);r<e;r++)i[r]=t[r];return i}function A(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var i,n,a=[],o=!0,A=!1;try{for(r=r.call(t);!(o=(i=r.next()).done)&&(a.push(i.value),!e||a.length!==e);o=!0);}catch(t){A=!0,n=t}finally{try{o||null==r["return"]||r["return"]()}finally{if(A)throw n}}return a}}function s(t){if(Array.isArray(t))return t}var u=t("object-assign"),h=t("webworkify"),f=t("./lib/mathlib"),c=t("./lib/pool"),g=t("./lib/utils"),l=t("./lib/worker"),d=t("./lib/stepper"),p=t("./lib/tiler"),I=t("./lib/mm_resize/resize_filter_info"),m={},_=!1;try{"undefined"!=typeof navigator&&navigator.userAgent&&(_=navigator.userAgent.indexOf("Safari")>=0)}catch(t){}var w=1;"undefined"!=typeof navigator&&(w=Math.min(navigator.hardwareConcurrency||1,4));var B={tile:1024,concurrency:w,features:["js","wasm","ww"],idle:2e3,createCanvas:function(t,e){var r=document.createElement("canvas");return r.width=t,r.height=e,r}},E={filter:"mks2013",unsharpAmount:0,unsharpRadius:0,unsharpThreshold:0},b=!1,Q=!1,v=!1,y=!1,C=!1;function x(){return{value:h(l),destroy:function(){if(this.value.terminate(),"undefined"!=typeof window){var t=window.URL||window.webkitURL||window.mozURL||window.msURL;t&&t.revokeObjectURL&&this.value.objectURL&&t.revokeObjectURL(this.value.objectURL)}}}}function D(t){if(!(this instanceof D))return new D(t);this.options=u({},B,t||{});var e="lk_".concat(this.options.concurrency);this.__limit=m[e]||g.limiter(this.options.concurrency),m[e]||(m[e]=this.__limit),this.features={js:!1,wasm:!1,cib:!1,ww:!1},this.__workersPool=null,this.__requested_features=[],this.__mathlib=null}D.prototype.init=function(){var e=this;if(this.__initPromise)return this.__initPromise;if("undefined"!=typeof ImageData&&"undefined"!=typeof Uint8ClampedArray)try{new ImageData(new Uint8ClampedArray(400),10,10),b=!0}catch(t){}"undefined"!=typeof ImageBitmap&&(ImageBitmap.prototype&&ImageBitmap.prototype.close?Q=!0:this.debug("ImageBitmap does not support .close(), disabled"));var r=this.options.features.slice();if(r.indexOf("all")>=0&&(r=["cib","wasm","js","ww"]),this.__requested_features=r,this.__mathlib=new f(r),r.indexOf("ww")>=0&&"undefined"!=typeof window&&"Worker"in window)try{t("webworkify")((function(){})).terminate(),this.features.ww=!0;var i="wp_".concat(JSON.stringify(this.options));m[i]?this.__workersPool=m[i]:(this.__workersPool=new c(x,this.options.idle),m[i]=this.__workersPool)}catch(t){}var n,a,o=this.__mathlib.init().then((function(t){u(e.features,t.features)}));n=Q?g.cib_support(this.options.createCanvas).then((function(t){e.features.cib&&r.indexOf("cib")<0?e.debug("createImageBitmap() resize supported, but disabled by config"):r.indexOf("cib")>=0&&(e.features.cib=t)})):Promise.resolve(!1),v=g.can_use_canvas(this.options.createCanvas),a=(a=Q&&b&&-1!==r.indexOf("ww")?g.worker_offscreen_canvas_support():Promise.resolve(!1)).then((function(t){y=t}));var A=g.cib_can_use_region().then((function(t){C=t}));return this.__initPromise=Promise.all([o,n,a,A]).then((function(){return e})),this.__initPromise},D.prototype.__invokeResize=function(t,e){var r=this;return e.__mathCache=e.__mathCache||{},Promise.resolve().then((function(){return r.features.ww?new Promise((function(i,n){var a=r.__workersPool.acquire();e.cancelToken&&e.cancelToken["catch"]((function(t){return n(t)})),a.value.onmessage=function(t){a.release(),t.data.err?n(t.data.err):i(t.data)};var o=[];t.src&&o.push(t.src.buffer),t.srcBitmap&&o.push(t.srcBitmap),a.value.postMessage({opts:t,features:r.__requested_features,preload:{wasm_nodule:r.__mathlib.__}},o)})):{data:r.__mathlib.resizeAndUnsharp(t,e.__mathCache)}}))},D.prototype.__extractTileData=function(t,e,r,i,n){if(this.features.ww&&y&&(g.isCanvas(e)||C))return this.debug("Create tile for OffscreenCanvas"),createImageBitmap(i.srcImageBitmap||e,t.x,t.y,t.width,t.height).then((function(t){return n.srcBitmap=t,n}));if(g.isCanvas(e))return i.srcCtx||(i.srcCtx=e.getContext("2d")),this.debug("Get tile pixel data"),n.src=i.srcCtx.getImageData(t.x,t.y,t.width,t.height).data,n;this.debug("Draw tile imageBitmap/image to temporary canvas");var a=this.options.createCanvas(t.width,t.height),o=a.getContext("2d");return o.globalCompositeOperation="copy",o.drawImage(i.srcImageBitmap||e,t.x,t.y,t.width,t.height,0,0,t.width,t.height),this.debug("Get tile pixel data"),n.src=o.getImageData(0,0,t.width,t.height).data,a.width=a.height=0,n},D.prototype.__landTileData=function(t,e,r){var i;if(this.debug("Convert raw rgba tile result to ImageData"),e.bitmap)return r.toCtx.drawImage(e.bitmap,t.toX,t.toY),null;if(b)i=new ImageData(new Uint8ClampedArray(e.data),t.toWidth,t.toHeight);else if((i=r.toCtx.createImageData(t.toWidth,t.toHeight)).data.set)i.data.set(e.data);else for(var n=i.data.length-1;n>=0;n--)i.data[n]=e.data[n];return this.debug("Draw tile"),_?r.toCtx.putImageData(i,t.toX,t.toY,t.toInnerX-t.toX,t.toInnerY-t.toY,t.toInnerWidth+1e-5,t.toInnerHeight+1e-5):r.toCtx.putImageData(i,t.toX,t.toY,t.toInnerX-t.toX,t.toInnerY-t.toY,t.toInnerWidth,t.toInnerHeight),null},D.prototype.__tileAndResize=function(t,e,r){var i=this,n={srcCtx:null,srcImageBitmap:null,isImageBitmapReused:!1,toCtx:null},a=function(e){return i.__limit((function(){if(r.canceled)return r.cancelToken;var a={width:e.width,height:e.height,toWidth:e.toWidth,toHeight:e.toHeight,scaleX:e.scaleX,scaleY:e.scaleY,offsetX:e.offsetX,offsetY:e.offsetY,filter:r.filter,unsharpAmount:r.unsharpAmount,unsharpRadius:r.unsharpRadius,unsharpThreshold:r.unsharpThreshold};return i.debug("Invoke resize math"),Promise.resolve(a).then((function(a){return i.__extractTileData(e,t,r,n,a)})).then((function(t){return i.debug("Invoke resize math"),i.__invokeResize(t,r)})).then((function(t){return r.canceled?r.cancelToken:(n.srcImageData=null,i.__landTileData(e,t,n))}))}))};return Promise.resolve().then((function(){if(n.toCtx=e.getContext("2d"),g.isCanvas(t))return null;if(g.isImageBitmap(t))return n.srcImageBitmap=t,n.isImageBitmapReused=!0,null;if(g.isImage(t))return Q?(i.debug("Decode image via createImageBitmap"),createImageBitmap(t).then((function(t){n.srcImageBitmap=t}))["catch"]((function(t){return null}))):null;throw new Error('Pica: ".from" should be Image, Canvas or ImageBitmap')})).then((function(){if(r.canceled)return r.cancelToken;i.debug("Calculate tiles");var t=p({width:r.width,height:r.height,srcTileSize:i.options.tile,toWidth:r.toWidth,toHeight:r.toHeight,destTileBorder:r.__destTileBorder}).map((function(t){return a(t)}));function o(t){t.srcImageBitmap&&(t.isImageBitmapReused||t.srcImageBitmap.close(),t.srcImageBitmap=null)}return i.debug("Process tiles"),Promise.all(t).then((function(){return i.debug("Finished!"),o(n),e}),(function(t){throw o(n),t}))}))},D.prototype.__processStages=function(t,e,r,n){var a=this;if(n.canceled)return n.cancelToken;var o,A,s=i(t.shift(),2),h=s[0],f=s[1],c=0===t.length;return o=c||I.q2f.indexOf(n.filter)<0?n.filter:"box"===n.filter?"box":"hamming",n=u({},n,{toWidth:h,toHeight:f,filter:o}),c||(A=this.options.createCanvas(h,f)),this.__tileAndResize(e,c?r:A,n).then((function(){return c?r:(n.width=h,n.height=f,a.__processStages(t,A,r,n))})).then((function(t){return A&&(A.width=A.height=0),t}))},D.prototype.__resizeViaCreateImageBitmap=function(t,e,r){var i=this,n=e.getContext("2d");return this.debug("Resize via createImageBitmap()"),createImageBitmap(t,{resizeWidth:r.toWidth,resizeHeight:r.toHeight,resizeQuality:g.cib_quality_name(I.f2q[r.filter])}).then((function(t){if(r.canceled)return r.cancelToken;if(!r.unsharpAmount)return n.drawImage(t,0,0),t.close(),n=null,i.debug("Finished!"),e;i.debug("Unsharp result");var a=i.options.createCanvas(r.toWidth,r.toHeight),o=a.getContext("2d");o.drawImage(t,0,0),t.close();var A=o.getImageData(0,0,r.toWidth,r.toHeight);return i.__mathlib.unsharp_mask(A.data,r.toWidth,r.toHeight,r.unsharpAmount,r.unsharpRadius,r.unsharpThreshold),n.putImageData(A,0,0),a.width=a.height=0,A=o=a=n=null,i.debug("Finished!"),e}))},D.prototype.resize=function(t,e,r){var i=this;this.debug("Start resize...");var n=u({},E);if(isNaN(r)?r&&(n=u(n,r)):n=u(n,{quality:r}),n.toWidth=e.width,n.toHeight=e.height,n.width=t.naturalWidth||t.width,n.height=t.naturalHeight||t.height,Object.prototype.hasOwnProperty.call(n,"quality")){if(n.quality<0||n.quality>3)throw new Error("Pica: .quality should be [0..3], got ".concat(n.quality));n.filter=I.q2f[n.quality]}if(0===e.width||0===e.height)return Promise.reject(new Error("Invalid output size: ".concat(e.width,"x").concat(e.height)));n.unsharpRadius>2&&(n.unsharpRadius=2),n.canceled=!1,n.cancelToken&&(n.cancelToken=n.cancelToken.then((function(t){throw n.canceled=!0,t}),(function(t){throw n.canceled=!0,t})));var a=3;return n.__destTileBorder=Math.ceil(Math.max(a,2.5*n.unsharpRadius|0)),this.init().then((function(){if(n.canceled)return n.cancelToken;if(i.features.cib){if(I.q2f.indexOf(n.filter)>=0)return i.__resizeViaCreateImageBitmap(t,e,n);i.debug("cib is enabled, but not supports provided filter, fallback to manual math")}if(!v){var r=new Error("Pica: cannot use getImageData on canvas, "+"make sure fingerprinting protection isn't enabled");throw r.code="ERR_GET_IMAGE_DATA",r}var a=d(n.width,n.height,n.toWidth,n.toHeight,i.options.tile,n.__destTileBorder);return i.__processStages(a,t,e,n)}))},D.prototype.resizeBuffer=function(t){var e=this,r=u({},E,t);if(Object.prototype.hasOwnProperty.call(r,"quality")){if(r.quality<0||r.quality>3)throw new Error("Pica: .quality should be [0..3], got ".concat(r.quality));r.filter=I.q2f[r.quality]}return this.init().then((function(){return e.__mathlib.resizeAndUnsharp(r)}))},D.prototype.toBlob=function(t,e,r){return e=e||"image/png",new Promise((function(i){if(t.toBlob)t.toBlob((function(t){return i(t)}),e,r);else if(t.convertToBlob)i(t.convertToBlob({type:e,quality:r}));else{for(var n=atob(t.toDataURL(e,r).split(",")[1]),a=n.length,o=new Uint8Array(a),A=0;A<a;A++)o[A]=n.charCodeAt(A);i(new Blob([o],{type:e}))}}))},D.prototype.debug=function(){},e.exports=D},{"./lib/mathlib":1,"./lib/mm_resize/resize_filter_info":7,"./lib/pool":13,"./lib/stepper":14,"./lib/tiler":15,"./lib/utils":16,"./lib/worker":17,"object-assign":22,webworkify:23}]},{},[])("/index.js")}(i);var n={},a={exports:{}};!function(t){function e(t,e){var r=new Error(t);return r.code=e,r}function r(t){for(var e=t.toString(16).toUpperCase(),r=2-e.length;r>0;r--)e="0"+e;return"0x"+e}function i(t){try{return decodeURIComponent(escape(t))}catch(e){return t}}function n(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)}function a(t,r,i){this.input=t.subarray(r,i),this.start=r;var n=String.fromCharCode.apply(null,this.input.subarray(0,4));if("II*\0"!==n&&"MM\0*"!==n)throw e("invalid TIFF signature","EBADDATA");this.big_endian="M"===n[0]}a.prototype.each=function(t){this.aborted=!1;var e=this.read_uint32(4);for(this.ifds_to_read=[{id:0,offset:e}];this.ifds_to_read.length>0&&!this.aborted;){var r=this.ifds_to_read.shift();r.offset&&this.scan_ifd(r.id,r.offset,t)}},a.prototype.filter=function(t){var r={ifd0:{id:0,entries:[]}};this.each((function(e){(!1!==t(e)||e.is_subifd_link)&&(e.is_subifd_link&&1!==e.count&&4!==e.format||(r["ifd"+e.ifd]||(r["ifd"+e.ifd]={id:e.ifd,entries:[]}),r["ifd"+e.ifd].entries.push(e)))})),delete r.ifd1;var i=8;Object.keys(r).forEach((function(t){i+=2,r[t].entries.forEach((function(t){i+=12+(t.data_length>4?2*Math.ceil(t.data_length/2):0)})),i+=4})),this.output=new Uint8Array(i),this.output[0]=this.output[1]=(this.big_endian?"M":"I").charCodeAt(0),this.write_uint16(2,42);var n=8,a=this;if(this.write_uint32(4,n),Object.keys(r).forEach((function(t){r[t].written_offset=n;var e=n,i=e+2+12*r[t].entries.length+4;n=i,a.write_uint16(e,r[t].entries.length),r[t].entries.sort((function(t,e){return t.tag-e.tag})).forEach((function(t,i){var o=e+2+12*i;a.write_uint16(o,t.tag),a.write_uint16(o+2,t.format),a.write_uint32(o+4,t.count),t.is_subifd_link?r["ifd"+t.tag]&&(r["ifd"+t.tag].link_offset=o+8):t.data_length<=4?a.output.set(a.input.subarray(t.data_offset-a.start,t.data_offset-a.start+4),o+8):(a.write_uint32(o+8,n),a.output.set(a.input.subarray(t.data_offset-a.start,t.data_offset-a.start+t.data_length),n),n+=2*Math.ceil(t.data_length/2))}));var o=r["ifd"+(r[t].id+1)];o&&(o.link_offset=i-4)})),Object.keys(r).forEach((function(t){r[t].written_offset&&r[t].link_offset&&a.write_uint32(r[t].link_offset,r[t].written_offset)})),this.output.length!==n)throw e("internal error: incorrect buffer size allocated");return this.output},a.prototype.read_uint16=function(t){var r=this.input;if(t+2>r.length)throw e("unexpected EOF","EBADDATA");return this.big_endian?256*r[t]+r[t+1]:r[t]+256*r[t+1]},a.prototype.read_uint32=function(t){var r=this.input;if(t+4>r.length)throw e("unexpected EOF","EBADDATA");return this.big_endian?16777216*r[t]+65536*r[t+1]+256*r[t+2]+r[t+3]:r[t]+256*r[t+1]+65536*r[t+2]+16777216*r[t+3]},a.prototype.write_uint16=function(t,e){var r=this.output;this.big_endian?(r[t]=e>>>8&255,r[t+1]=255&e):(r[t]=255&e,r[t+1]=e>>>8&255)},a.prototype.write_uint32=function(t,e){var r=this.output;this.big_endian?(r[t]=e>>>24&255,r[t+1]=e>>>16&255,r[t+2]=e>>>8&255,r[t+3]=255&e):(r[t]=255&e,r[t+1]=e>>>8&255,r[t+2]=e>>>16&255,r[t+3]=e>>>24&255)},a.prototype.is_subifd_link=function(t,e){return 0===t&&34665===e||0===t&&34853===e||34665===t&&40965===e},a.prototype.exif_format_length=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.prototype.exif_format_read=function(t,e){var r;switch(t){case 1:case 2:return r=this.input[e];case 6:return(r=this.input[e])|33554430*(128&r);case 3:return r=this.read_uint16(e);case 8:return(r=this.read_uint16(e))|131070*(32768&r);case 4:return r=this.read_uint32(e);case 9:return 0|(r=this.read_uint32(e));default:return null}},a.prototype.scan_ifd=function(t,r,n){var a=this.read_uint16(r);r+=2;for(var o=0;o<a;o++){var A=this.read_uint16(r),s=this.read_uint16(r+2),u=this.read_uint32(r+4),h=this.exif_format_length(s),f=u*h,c=f<=4?r+8:this.read_uint32(r+8),g=!1;if(c+f>this.input.length)throw e("unexpected EOF","EBADDATA");for(var l=[],d=c,p=0;p<u;p++,d+=h){var I=this.exif_format_read(s,d);if(null===I){l=null;break}l.push(I)}if(Array.isArray(l)&&2===s){try{l=i(String.fromCharCode.apply(null,l))}catch(t){l=null}l&&"\0"===l[l.length-1]&&(l=l.slice(0,-1))}if(this.is_subifd_link(t,A)&&Array.isArray(l)&&Number.isInteger(l[0])&&l[0]>0&&(this.ifds_to_read.push({id:A,offset:l[0]}),g=!0),!1===n({is_big_endian:this.big_endian,ifd:t,tag:A,format:s,count:u,entry_offset:r+this.start,data_length:f,data_offset:c+this.start,value:l,is_subifd_link:g}))return void(this.aborted=!0);r+=12}0===t&&this.ifds_to_read.push({id:1,offset:this.read_uint32(r)})},t.exports.is_jpeg=function(t){return t.length>=4&&255===t[0]&&216===t[1]&&255===t[2]},t.exports.jpeg_segments_each=function(i,a){if(!n(i))throw e("Invalid argument (jpeg_bin), Uint8Array expected","EINVAL");if("function"!=typeof a)throw e("Invalid argument (on_segment), Function expected","EINVAL");if(!t.exports.is_jpeg(i))throw e("Unknown file format","ENOTJPEG");for(var o=0,A=i.length,s=!1;;){var u,h;if(o+1>=A)throw e("Unexpected EOF","EBADDATA");var f=i[o],c=i[o+1];if(255===f&&255===c)u=255,h=1;else if(255===f&&0!==c){if(h=2,208<=(u=c)&&u<=217||1===u);else{if(o+3>=A)throw e("Unexpected EOF","EBADDATA");if((h+=256*i[o+2]+i[o+3])<2)throw e("Invalid segment length","EBADDATA");if(o+h-1>=A)throw e("Unexpected EOF","EBADDATA")}s&&(u>=208&&u<=215||(s=!1)),218===u&&(s=!0)}else{if(!s)throw e("Unexpected byte at segment start: "+r(f)+" (offset "+r(o)+")","EBADDATA");for(var g=o+1;;g++){if(g>=A)throw e("Unexpected EOF","EBADDATA");if(255===i[g]){if(g+1>=A)throw e("Unexpected EOF","EBADDATA");if(0!==i[g+1]){u=0,h=g-o;break}}}}if(!1===a({code:u,offset:o,length:h}))break;if(217===u)break;o+=h}},t.exports.jpeg_segments_filter=function(r,i){if(!n(r))throw e("Invalid argument (jpeg_bin), Uint8Array expected","EINVAL");if("function"!=typeof i)throw e("Invalid argument (on_segment), Function expected","EINVAL");var a=[],o=0;t.exports.jpeg_segments_each(r,(function(t){var e=i(t);if(n(e))a.push({data:e}),o+=e.length;else if(Array.isArray(e))e.filter(n).forEach((function(t){a.push({data:t}),o+=t.length}));else if(!1!==e){var r={start:t.offset,end:t.offset+t.length};a.length>0&&a[a.length-1].end===r.start?a[a.length-1].end=r.end:a.push(r),o+=t.length}}));var A=new Uint8Array(o),s=0;return a.forEach((function(t){var e=t.data||r.subarray(t.start,t.end);A.set(e,s),s+=e.length})),A},t.exports.jpeg_exif_tags_each=function(r,i){if(!n(r))throw e("Invalid argument (jpeg_bin), Uint8Array expected","EINVAL");if("function"!=typeof i)throw e("Invalid argument (on_exif_entry), Function expected","EINVAL");t.exports.jpeg_segments_each(r,(function(t){return 218!==t.code&&(225===t.code&&t.length>=10&&69===r[t.offset+4]&&120===r[t.offset+5]&&105===r[t.offset+6]&&102===r[t.offset+7]&&0===r[t.offset+8]&&0===r[t.offset+9]?(new a(r,t.offset+10,t.offset+t.length).each(i),!1):void 0)}))},t.exports.jpeg_exif_tags_filter=function(r,i){if(!n(r))throw e("Invalid argument (jpeg_bin), Uint8Array expected","EINVAL");if("function"!=typeof i)throw e("Invalid argument (on_exif_entry), Function expected","EINVAL");var o=!1;return t.exports.jpeg_segments_filter(r,(function(t){if(!o&&(218===t.code&&(o=!0),225===t.code&&t.length>=10&&69===r[t.offset+4]&&120===r[t.offset+5]&&105===r[t.offset+6]&&102===r[t.offset+7]&&0===r[t.offset+8]&&0===r[t.offset+9])){var e=new a(r,t.offset+10,t.offset+t.length).filter(i);if(!e)return!1;var n=new Uint8Array(10);return n.set(r.slice(t.offset,t.offset+10)),n[2]=e.length+8>>>8&255,n[3]=e.length+8&255,o=!0,[n,e]}}))},t.exports.jpeg_add_comment=function(e,r){var i=!1,n=0;return t.exports.jpeg_segments_filter(e,(function(t){if(!(1===++n&&216===t.code||2===n&&224===t.code||i)){r=function(t){try{return unescape(encodeURIComponent(t))}catch(e){return t}}(r);var a=new Uint8Array(5+r.length),o=0;return a[o++]=255,a[o++]=254,a[o++]=r.length+3>>>8&255,a[o++]=r.length+3&255,r.split("").forEach((function(t){a[o++]=255&t.charCodeAt(0)})),a[o++]=0,i=!0,[a,e.subarray(t.offset,t.offset+t.length)]}}))}}(a);var o=a.exports;function A(t){return this._getUint8Array(t.blob).then((function(e){if(t.is_jpeg=o.is_jpeg(e),!t.is_jpeg)return Promise.resolve(t);t.orig_blob=t.blob;try{var r,i;if(o.jpeg_exif_tags_each(e,(function(e){if(0===e.ifd&&274===e.tag&&Array.isArray(e.value))return t.orientation=e.value[0]||1,r=e.is_big_endian,i=e.data_offset,!1})),i){var n=r?new Uint8Array([0,1]):new Uint8Array([1,0]);t.blob=new Blob([e.slice(0,i),n,e.slice(i+2)],{type:"image/jpeg"})}}catch(t){}return t}))}function s(t){if(!t.is_jpeg)return Promise.resolve(t);var e,r=t.orientation-1;if(!r)return Promise.resolve(t);var i=(e=4&r?this.pica.options.createCanvas(t.out_canvas.height,t.out_canvas.width):this.pica.options.createCanvas(t.out_canvas.width,t.out_canvas.height)).getContext("2d");return i.save(),1&r&&i.transform(-1,0,0,1,e.width,0),2&r&&i.transform(-1,0,0,-1,e.width,e.height),4&r&&i.transform(0,1,1,0,0,0),i.drawImage(t.out_canvas,0,0),i.restore(),t.out_canvas.width=t.out_canvas.height=0,t.out_canvas=e,Promise.resolve(t)}function u(t){return t.is_jpeg?Promise.all([this._getUint8Array(t.blob),this._getUint8Array(t.out_blob)]).then((function(e){var r=e[0],i=e[1];if(!o.is_jpeg(r))return Promise.resolve(t);var n=[];return o.jpeg_segments_each(r,(function(t){if(218===t.code)return!1;n.push(t)})),n=n.filter((function(t){return 226!==t.code&&(t.code>=224&&t.code<240||254===t.code)})).map((function(t){return r.slice(t.offset,t.offset+t.length)})),t.out_blob=new Blob([i.slice(0,2)].concat(n).concat([i.slice(20)]),{type:"image/jpeg"}),t})):Promise.resolve(t)}n.jpeg_patch_exif=A,n.jpeg_rotate_canvas=s,n.jpeg_attach_orig_segments=u,n.assign=function(t){t.before("_blob_to_image",A),t.after("_transform",s),t.after("_create_blob",u)};var h=e,f=i.exports;function c(t){if(!(this instanceof c))return new c(t);t=t||{},this.pica=t.pica||f({}),this.initialized=!1,this.utils=h}return c.prototype.use=function(t){var e=[this].concat(Array.prototype.slice.call(arguments,1));return t.apply(t,e),this},c.prototype.init=function(){this.use(n.assign)},c.prototype.toBlob=function(t,e){var r={blob:t,opts:h.assign({max:1/0},e)};return this.initialized||(this.init(),this.initialized=!0),Promise.resolve(r).then(this._blob_to_image).then(this._calculate_size).then(this._transform).then(this._cleanup).then(this._create_blob).then((function(t){return t.out_canvas.width=t.out_canvas.height=0,t.out_blob}))},c.prototype.toCanvas=function(t,e){var r={blob:t,opts:h.assign({max:1/0},e)};return this.initialized||(this.init(),this.initialized=!0),Promise.resolve(r).then(this._blob_to_image).then(this._calculate_size).then(this._transform).then(this._cleanup).then((function(t){return t.out_canvas}))},c.prototype.before=function(t,e){if(!this[t])throw new Error('Method "'+t+'" does not exist');if("function"!=typeof e)throw new Error('Invalid argument "fn", function expected');var r=this[t],i=this;return this[t]=function(t){return e.call(i,t).then((function(t){return r.call(i,t)}))},this},c.prototype.after=function(t,e){if(!this[t])throw new Error('Method "'+t+'" does not exist');if("function"!=typeof e)throw new Error('Invalid argument "fn", function expected');var r=this[t],i=this;return this[t]=function(t){return r.call(i,t).then((function(t){return e.call(i,t)}))},this},c.prototype._blob_to_image=function(t){var e=window.URL||window.webkitURL||window.mozURL||window.msURL;return t.image=document.createElement("img"),t.image_url=e.createObjectURL(t.blob),t.image.src=t.image_url,new Promise((function(e,r){t.image.onerror=function(){r(new Error("ImageBlobReduce: failed to create Image() from blob"))},t.image.onload=function(){e(t)}}))},c.prototype._calculate_size=function(t){var e=t.opts.max/Math.max(t.image.width,t.image.height);return e>1&&(e=1),t.transform_width=Math.max(Math.round(t.image.width*e),1),t.transform_height=Math.max(Math.round(t.image.height*e),1),t.scale_factor=e,Promise.resolve(t)},c.prototype._transform=function(t){t.out_canvas=this.pica.options.createCanvas(t.transform_width,t.transform_height),t.transform_width=null,t.transform_height=null;var e={alpha:"image/png"===t.blob.type};return this.utils.assign(e,this.utils.pick_pica_resize_options(t.opts)),this.pica.resize(t.image,t.out_canvas,e).then((function(){return t}))},c.prototype._cleanup=function(t){t.image.src="",t.image=null;var e=window.URL||window.webkitURL||window.mozURL||window.msURL;return e.revokeObjectURL&&e.revokeObjectURL(t.image_url),t.image_url=null,Promise.resolve(t)},c.prototype._create_blob=function(t){return this.pica.toBlob(t.out_canvas,t.blob.type).then((function(e){return t.out_blob=e,t}))},c.prototype._getUint8Array=function(t){return t.arrayBuffer?t.arrayBuffer().then((function(t){return new Uint8Array(t)})):new Promise((function(e,r){var i=new FileReader;i.readAsArrayBuffer(t),i.onload=function(){e(new Uint8Array(i.result))},i.onerror=function(){r(new Error("ImageBlobReduce: failed to load data from input blob")),i.abort()},i.onabort=function(){r(new Error("ImageBlobReduce: failed to load data from input blob (aborted)"))}}))},c.pica=f,c}));