-
Notifications
You must be signed in to change notification settings - Fork 2
/
imagerot.min.js
1 lines (1 loc) · 34.4 KB
/
imagerot.min.js
1
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("imagerot",[],t):"object"==typeof exports?exports.imagerot=t():e.imagerot=t()}(this,(()=>(()=>{"use strict";var e={517:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PI=t.pow=t.random=t.floor=t.sin=t.max=t.min=void 0;const n=Math.min;t.min=n;const o=Math.max;t.max=o;const r=Math.sin;t.sin=r;const i=Math.floor;t.floor=i;const a=Math.random;t.random=a;const c=Math.pow;t.pow=c;const u=Math.PI;t.PI=u},295:function(e,t,n){var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return r(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.effectPool=void 0;const a=i(n(871)),c=i(n(186)),u=Object.values(Object.assign(Object.assign({},a),c));t.effectPool=u.reduce(((e,t)=>(t.hasOwnProperty("browser")&&(e[t.name]={method:t.browser},t.hasOwnProperty("pixelOp")&&(e[t.name].pixelOp=t.pixelOp)),e)),{})},216:function(e,t){var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function c(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.blur=void 0;const o="horizontal",r=5,i=({data:e,width:t,height:i},a=null)=>n(void 0,void 0,void 0,(function*(){const{direction:n=o,intensity:c=r}=a||{},u=new Uint8Array(e.length);u.set(e);for(let o=0;o<i;o++)for(let r=0;r<t;r++){let a=4*(o*t+r),f=0,d=0,l=0,s=0;for(let a=1;a<=c;a++)if("horizontal"===n){if(r+a<t){let n=4*(o*t+r+a);f+=e[n],d+=e[n+1],l+=e[n+2],s++}}else if("vertical"===n&&o+a<i){let n=4*((o+a)*t+r);f+=e[n],d+=e[n+1],l+=e[n+2],s++}u[a]=f/s,u[a+1]=d/s,u[a+2]=l/s}return u})),a={name:"blur",browser:i,node:i};t.blur=a},452:function(e,t){var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function c(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.borders=void 0;const o=10,r=[0,0,0],i=1,a=({data:e,width:t,height:a},c=null)=>n(void 0,void 0,void 0,(function*(){const{size:n=o,color:u=r,opacity:f=i}=c||{};for(let o=0;o<e.length;o+=4){let r=o/4%t,i=Math.floor(o/4/t);(r<n||r>=t-n||i<n||i>=a-n)&&(e[o]=e[o]*(1-f)+u[0]*f,e[o+1]=e[o+1]*(1-f)+u[1]*f,e[o+2]=e[o+2]*(1-f)+u[2]*f)}return e})),c={name:"borders",browser:a,node:a};t.borders=c},758:function(e,t){var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function c(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.brightness=void 0;const o=10,r=({index:e,data:t},n=null)=>{let{brightness:r=o}=n||{};r*=2.55;for(let n=0;n<3;n++){let o=t[e+n]+r;t[e+n]=Math.max(0,Math.min(255,o))}},i=({data:e},t=null)=>n(void 0,void 0,void 0,(function*(){let{brightness:n=o}=t||{};n*=2.55;for(let t=0;t<e.length;t+=4)r({index:t,data:e},{brightness:n});return e})),a={name:"brightness",browser:i,node:i,pixelOp:r};t.brightness=a},499:function(e,t){var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function c(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.chromaticAberration=void 0;const o=5,r=({data:e,width:t},r=null)=>n(void 0,void 0,void 0,(function*(){const{intensity:n=o}=r||{},i=new Uint8Array(e.length),a=new Uint8Array(e.length),c=new Uint8Array(e.length);for(let t=0;t<e.length;t+=4)i[t]=e[t],a[t+1]=e[t+1],c[t+2]=e[t+2],i[t+3]=a[t+3]=c[t+3]=e[t+3];const u=(e,n)=>{const o=new Uint8Array(e.length);for(let r=0;r<e.length;r+=4){const i=r/4%t,a=Math.floor(r/4/t),c=4*(Math.max(0,Math.min(t-1,i+n))+a*t);o[c]=e[r],o[c+1]=e[r+1],o[c+2]=e[r+2],o[c+3]=e[r+3]}return o},f=Math.floor((2*Math.random()-1)*n),d=Math.floor((2*Math.random()-1)*n),l=Math.floor((2*Math.random()-1)*n),s=u(i,f),h=u(a,d),v=u(c,l);for(let t=0;t<e.length;t+=4)e[t]=s[t],e[t+1]=h[t+1],e[t+2]=v[t+2],e[t+3]=e[t+3];return e})),i={name:"chromaticAberration",browser:r,node:r};t.chromaticAberration=i},888:function(e,t){var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function c(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.dither=void 0;const o=.5,r=({data:e,width:t,height:r},i=null)=>n(void 0,void 0,void 0,(function*(){const{intensity:n=o}=i||{};for(let t=0;t<e.length;t+=4){const n=(e[t]+e[t+1]+e[t+2])/3;e[t]=e[t+1]=e[t+2]=n}for(let o=0;o<e.length;o+=4){const r=e[o]>255*n?255:0,i=e[o]-r;e[o]=r,o+4<e.length&&(e[o+4]=e[o+4]+7*i/16),o+4*t<e.length&&(e[o+4*t]=e[o+4*t]+5*i/16),o+4*t+4<e.length&&(e[o+4*t+4]=e[o+4*t+4]+1*i/16),o+4*t-4>=0&&(e[o+4*t-4]=e[o+4*t-4]+3*i/16),e[o+1]=e[o+2]=e[o]}return new Uint8Array(e)})),i={name:"dither",browser:r,node:r};t.dither=i},626:function(e,t){var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function c(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.grayscale=void 0;const o=1,r=({data:e},t=null)=>n(void 0,void 0,void 0,(function*(){const{intensity:n=o}=t||{};for(let t=0;t<e.length;t+=4){let o=e[t],r=e[t+1],i=e[t+2],a=.299*o+.587*r+.114*i;e[t]=o*(1-n)+a*n,e[t+1]=r*(1-n)+a*n,e[t+2]=i*(1-n)+a*n}return e})),i={name:"grayscale",browser:r,node:r};t.grayscale=i},281:function(e,t){var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function c(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.heatmap=void 0;const o=.8,r=[{stop:0,color:{r:0,g:0,b:255}},{stop:.1,color:{r:0,g:255,b:0}},{stop:.3,color:{r:255,g:255,b:0}},{stop:.5,color:{r:255,g:165,b:0}},{stop:.7,color:{r:255,g:0,b:0}},{stop:1,color:{r:128,g:0,b:128}}],i=(e,t)=>{if(t<=0)return e[0].color;if(t>=1)return e[e.length-1].color;let n=1;for(;n<e.length-1&&!(t<e[n].stop);n++);const o=e[n-1].stop,r=(t-o)/(e[n].stop-o);return{r:Math.round(e[n-1].color.r*(1-r)+e[n].color.r*r),g:Math.round(e[n-1].color.g*(1-r)+e[n].color.g*r),b:Math.round(e[n-1].color.b*(1-r)+e[n].color.b*r),a:255}},a=({data:e,width:t,height:a},c=null)=>n(void 0,void 0,void 0,(function*(){const{intensity:n=o,controlPoints:u=r}=c||{},f=t*a*4;for(let t=0;t<f;t+=4){const o=(e[t]+e[t+1]+e[t+2])/765,r=i(u,o*n);e[t]=r.r,e[t+1]=r.g,e[t+2]=r.b,e[t+3]=r.a||e[t+3]}return e})),c={name:"heatmap",browser:a,node:a};t.heatmap=c},934:function(e,t,n){var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function c(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.hueShift=void 0;const r=n(513),i=180,a=({data:e},t=null)=>o(void 0,void 0,void 0,(function*(){const{shift:n=i}=t||{};for(let t=0;t<e.length;t+=4){let o=(0,r.rgbToHsv)(e[t],e[t+1],e[t+2]);o[0]=(o[0]+n/360)%1;let i=(0,r.hsvToRgb)(o[0],o[1],o[2]);e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=e[t+3]}return e})),c={name:"hueShift",browser:a,node:a};t.hueShift=c},871:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.heatmap=t.borders=t.chromaticAberration=t.solarize=t.scanlines=t.hueShift=t.sharpen=t.brightness=t.noise=t.grayscale=t.rainbow=t.rectangles=t.dither=t.blur=void 0;var o=n(216);Object.defineProperty(t,"blur",{enumerable:!0,get:function(){return o.blur}});var r=n(888);Object.defineProperty(t,"dither",{enumerable:!0,get:function(){return r.dither}});var i=n(164);Object.defineProperty(t,"rectangles",{enumerable:!0,get:function(){return i.rectangles}});var a=n(466);Object.defineProperty(t,"rainbow",{enumerable:!0,get:function(){return a.rainbow}});var c=n(626);Object.defineProperty(t,"grayscale",{enumerable:!0,get:function(){return c.grayscale}});var u=n(930);Object.defineProperty(t,"noise",{enumerable:!0,get:function(){return u.noise}});var f=n(758);Object.defineProperty(t,"brightness",{enumerable:!0,get:function(){return f.brightness}});var d=n(291);Object.defineProperty(t,"sharpen",{enumerable:!0,get:function(){return d.sharpen}});var l=n(934);Object.defineProperty(t,"hueShift",{enumerable:!0,get:function(){return l.hueShift}});var s=n(471);Object.defineProperty(t,"scanlines",{enumerable:!0,get:function(){return s.scanlines}});var h=n(54);Object.defineProperty(t,"solarize",{enumerable:!0,get:function(){return h.solarize}});var v=n(499);Object.defineProperty(t,"chromaticAberration",{enumerable:!0,get:function(){return v.chromaticAberration}});var w=n(452);Object.defineProperty(t,"borders",{enumerable:!0,get:function(){return w.borders}});var p=n(281);Object.defineProperty(t,"heatmap",{enumerable:!0,get:function(){return p.heatmap}})},930:function(e,t){var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function c(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.noise=void 0;const o=10,r=({index:e,data:t},n=null)=>{const{intensity:r=o,ratio:i=null}=n||{},a=i||r/100;for(let n=0;n<3;n++){const o=(2*Math.random()-1)*a,r=t[e+n]+255*o;t[e+n]=Math.max(0,Math.min(255,r))}},i=({data:e},t=null)=>n(void 0,void 0,void 0,(function*(){const{intensity:n=o,ratio:i=null}=t||{},a=i||n/100;for(let t=0;t<e.length;t+=4)r({index:t,data:e},{ratio:a});return e})),a={name:"noise",browser:i,node:i,pixelOp:r};t.noise=a},466:function(e,t,n){var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function c(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.rainbow=void 0;const r=n(517),i=({data:e,width:t,height:n})=>o(void 0,void 0,void 0,(function*(){const o=2*(0,r.random)()*r.PI,i=2*(0,r.random)()*r.PI,a=2*(0,r.random)()*r.PI;for(let c=0;c<e.length;c+=4){const u=c/4%t,f=(0,r.floor)(c/4/t),d=e[c],l=d*(.75+.25*(0,r.sin)(2*r.PI*(u/t)+o)),s=d*(.75+.25*(0,r.sin)(2*r.PI*(f/n)+i)),h=d*(.75+.25*(0,r.sin)(2*r.PI*(u/t+f/n+a)));e[c]=255*(0,r.pow)(l/255,.75),e[c+1]=255*(0,r.pow)(s/255,.75),e[c+2]=255*(0,r.pow)(h/255,.75)}return e})),a={name:"rainbow",browser:i,node:i};t.rainbow=a},164:function(e,t,n){var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function c(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.rectangles=void 0;const r=n(517),i=5,a=10,c=1,u=.15,f=({data:e,width:t,height:n},f=null)=>o(void 0,void 0,void 0,(function*(){const{offset:o=i,intensity:d=a,sizeModifier:l=c,invertChance:s=u}=f||{},h=new Uint8Array(e),v=d,w=(0,r.floor)((0,r.max)(20,(0,r.min)(t,n)/10)*l);for(let i=0;i<v;i++){let i,a;do{i=(0,r.floor)(.25*w+.75*(0,r.random)()*w),a=(0,r.floor)(.25*w+.75*(0,r.random)()*w)}while((0,r.max)(i,a)/(0,r.min)(i,a)<1.5);const c=(0,r.floor)((0,r.random)()*(t-i)),u=(0,r.floor)((0,r.random)()*(n-a)),f=(0,r.floor)(2*((0,r.random)()-.5)*o),d=(0,r.floor)(2*((0,r.random)()-.5)*o),l=5+(0,r.floor)(15*(0,r.random)())*((0,r.random)()>.5?1:-1),v=(0,r.random)()<s;for(let o=u;o<u+a;o++)for(let a=c;a<c+i;a++){const i=4*(o*t+a),c=4*((o+d+n)%n*t+(a+f+t)%t);for(let t=0;t<3;t++){let n=e[c+t]+l;v&&(n=255-n),n=(0,r.max)(0,(0,r.min)(255,n)),v&&n<50||(h[i+t]=n)}h[i+3]=e[c+3]}}return h})),d={name:"rectangles",browser:f,node:f};t.rectangles=d},471:function(e,t){var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function c(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.scanlines=void 0;const o=.5,r=1,i=10,a=({data:e,width:t,height:a},c=null)=>n(void 0,void 0,void 0,(function*(){const{opacity:n=o,thickness:u=r,lines:f=i}=c||{},d=Math.floor(a/f);for(let o=0;o<e.length;o+=4)Math.floor(o/4/t)%d<u&&(e[o]=e[o]*(1-n),e[o+1]=e[o+1]*(1-n),e[o+2]=e[o+2]*(1-n));return e})),c={name:"scanlines",browser:a,node:a};t.scanlines=c},291:function(e,t){var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function c(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.sharpen=void 0;const o=({data:e,width:t,height:o})=>n(void 0,void 0,void 0,(function*(){const n=[0,-1,0,-1,5,-1,0,-1,0],r=new Uint8Array(e.length);for(let i=0;i<o;i++)for(let a=0;a<t;a++){const c=4*(i*t+a);let u=0,f=0,d=0;for(let r=-1;r<=1;r++)for(let c=-1;c<=1;c++){const l=Math.max(0,Math.min(t-1,a+c)),s=4*(Math.max(0,Math.min(o-1,i+r))*t+l),h=3*(r+1)+(c+1);u+=e[s+0]*n[h],f+=e[s+1]*n[h],d+=e[s+2]*n[h]}r[c+0]=Math.min(255,Math.max(0,u)),r[c+1]=Math.min(255,Math.max(0,f)),r[c+2]=Math.min(255,Math.max(0,d)),r[c+3]=e[c+3]}return e.set(r),e})),r={name:"sharpen",browser:o,node:o};t.sharpen=r},54:function(e,t){var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function c(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.solarize=void 0;const o=.5,r=(e,t)=>e<Math.floor(255*t)?e:255-e,i=({index:e,data:t},n=null)=>{const{intensity:i=o}=n||{},a=t[e],c=t[e+1],u=t[e+2];t[e]=r(a,i),t[e+1]=r(c,i),t[e+2]=r(u,i),t[e+3]=t[e+3]},a=({data:e},t=null)=>n(void 0,void 0,void 0,(function*(){const{intensity:n=o}=t||{};for(let t=0;t<e.length;t+=4)i({index:t,data:e},{intensity:n});return e})),c={name:"solarize",browser:a,node:a,pixelOp:i};t.solarize=c},186:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.degrade=t.pixelate=void 0;var o=n(449);Object.defineProperty(t,"pixelate",{enumerable:!0,get:function(){return o.pixelate}});var r=n(61);Object.defineProperty(t,"degrade",{enumerable:!0,get:function(){return r.degrade}})},61:function(e,t){var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function c(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.degrade=void 0;const o=.075,r={name:"degrade",browser:({data:e,width:t,height:r},i=null)=>n(void 0,void 0,void 0,(function*(){const{quality:n=o}=i||{},a="undefined"!=typeof window?window:self,c=new OffscreenCanvas(t,r),u=c.getContext("2d");if(!u)throw new Error("Failed to obtain context");const f=new ImageData(new Uint8ClampedArray(e.buffer),t,r);u.putImageData(f,0,0);const d=yield c.convertToBlob({type:"image/jpeg",quality:n}),l=yield a.createImageBitmap(d);u.clearRect(0,0,c.width,c.height),u.drawImage(l,0,0);const s=u.getImageData(0,0,t,r);return new Uint8Array(s.data.buffer)}))};t.degrade=r},449:function(e,t,n){var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function c(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.pixelate=void 0;const r=n(513),i=8,a={name:"pixelate",browser:({data:e,width:t,height:n},a=null)=>o(void 0,void 0,void 0,(function*(){const{intensity:o=i}=a||{},c=new OffscreenCanvas(t,n),u=c.getContext("2d"),f=new ImageData(new Uint8ClampedArray(e),t,n);null==u||u.putImageData(f,0,0);const d=new OffscreenCanvas(t,n),l=d.getContext("2d");if(!u||!l)throw new Error("Failed to obtain context");l.imageSmoothingEnabled=!1,l.drawImage(c,0,0,t/o,n/o),l.drawImage(d,0,0,t/o,n/o,0,0,t,n);const s=l.getImageData(0,0,t,n).data;return(0,r.removeAlphaChannel)(new Uint8Array(s.buffer))}))};t.pixelate=a},564:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.arrayPick=void 0,t.arrayPick=e=>e[Math.floor(Math.random()*e.length)]},347:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getPixelOps=void 0,t.getPixelOps=e=>Object.entries(e).reduce(((e,[t,n])=>(void 0!==n.pixelOp&&(e[t]=n.pixelOp),e)),{})},63:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.hsvToRgb=void 0,t.hsvToRgb=(e,t,n)=>{let o=0,r=0,i=0,a=Math.floor(6*e),c=6*e-a,u=n*(1-t),f=n*(1-c*t),d=n*(1-(1-c)*t);switch(a%6){case 0:o=n,r=d,i=u;break;case 1:o=f,r=n,i=u;break;case 2:o=u,r=n,i=d;break;case 3:o=u,r=f,i=n;break;case 4:o=d,r=u,i=n;break;case 5:o=n,r=u,i=f}return[Math.round(255*o),Math.round(255*r),Math.round(255*i)]}},513:function(e,t,n){var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),r(n(749),t),r(n(564),t),r(n(380),t),r(n(627),t),r(n(63),t),r(n(737),t),r(n(347),t)},380:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isBrowser=void 0,t.isBrowser=()=>"undefined"!=typeof self||"undefined"!=typeof window},749:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.randomize=void 0,t.randomize=(e,t)=>Math.floor(Math.random()*(t-e+1)+e)},627:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.removeAlphaChannel=void 0,t.removeAlphaChannel=e=>{for(let t=0;t<e.length;t+=4)e[t+3]=255;return e}},737:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rgbToHsv=void 0,t.rgbToHsv=(e,t,n)=>{e/=255,t/=255,n/=255;let o=Math.max(e,t,n),r=Math.min(e,t,n),i=0,a=o,c=o-r,u=0===o?0:c/o;if(o!==r){switch(o){case e:i=(t-n)/c+(t<n?6:0);break;case t:i=(n-e)/c+2;break;case n:i=(e-t)/c+4}i/=6}return[i,u||0,a||0]}},641:function(e,t){var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function c(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.bufferToBitmap=void 0,t.bufferToBitmap=({data:e,width:t,height:o})=>n(void 0,void 0,void 0,(function*(){const n=new ImageData(new Uint8ClampedArray(e),t,o),r=new OffscreenCanvas(t,o),i=r.getContext("2d");if(!i)throw new Error("Unable to get canvas context");return i.putImageData(n,0,0),createImageBitmap(r)}))},433:function(e,t){var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function c(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.bufferToBlob=void 0,t.bufferToBlob=({data:e,width:t,height:o})=>n(void 0,void 0,void 0,(function*(){const n=new OffscreenCanvas(t,o),r=n.getContext("2d"),i=new Uint8ClampedArray(e.buffer),a=new ImageData(i,t,o);return null==r||r.putImageData(a,0,0),n.convertToBlob().then((e=>{if(e)return URL.createObjectURL(e);throw new Error("Failed to create Blob from canvas image")}))}))},111:function(e,t){var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function c(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.fileToBuffer=void 0,t.fileToBuffer=e=>n(void 0,void 0,void 0,(function*(){return new Promise(((t,o)=>{const r=new FileReader;r.onload=()=>n(void 0,void 0,void 0,(function*(){const e=r.result,n=new Blob([e]),i=yield createImageBitmap(n),a=new OffscreenCanvas(i.width,i.height).getContext("2d");if(a){a.drawImage(i,0,0,i.width,i.height);const e=a.getImageData(0,0,i.width,i.height);t([new Uint8Array(e.data.buffer),i.width,i.height])}else o(new Error("Failed to get context"))})),r.onerror=()=>{o(new Error("Failed to read file"))},r.readAsArrayBuffer(e)}))}))},532:function(e,t,n){var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return r(t,e),t},a=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function c(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.rgbToHsv=t.hsvToRgb=t.urlToBuffer=t.fileToBuffer=t.bufferToBitmap=t.bufferToBlob=t.useMode=t.useEffect=t.listEffects=t.listModes=t.stage=void 0;const c=n(468);Object.defineProperty(t,"urlToBuffer",{enumerable:!0,get:function(){return c.urlToBuffer}});const u=n(951),f=n(641);Object.defineProperty(t,"bufferToBitmap",{enumerable:!0,get:function(){return f.bufferToBitmap}});const d=n(111);Object.defineProperty(t,"fileToBuffer",{enumerable:!0,get:function(){return d.fileToBuffer}});const l=n(433);Object.defineProperty(t,"bufferToBlob",{enumerable:!0,get:function(){return l.bufferToBlob}});const s=n(513);Object.defineProperty(t,"hsvToRgb",{enumerable:!0,get:function(){return s.hsvToRgb}}),Object.defineProperty(t,"rgbToHsv",{enumerable:!0,get:function(){return s.rgbToHsv}});const h=i(n(961)),v=n(295);t.stage=({data:e,url:t})=>a(void 0,void 0,void 0,(function*(){let[n,o,r]=[null,0,0];if(e){if(e instanceof File)[n,o,r]=yield(0,d.fileToBuffer)(e);else if(Array.isArray(e)&&e[0]instanceof Uint8Array)[n,o,r]=[...e];else if("object"==typeof e){let t=e;t.data instanceof Uint8Array&&t.width&&t.height&&([n,o,r]=[t.data,t.width,t.height])}}else t&&"string"==typeof t&&([n,o,r]=yield(0,c.urlToBuffer)(t));if(!n||!o||!r)throw new Error("Failed to load image data");return{data:n,width:o,height:r}})),t.listModes=()=>Object.keys(h),t.listEffects=()=>Object.keys(v.effectPool),t.useEffect=({data:e,width:t,height:n},o,r)=>a(void 0,void 0,void 0,(function*(){return(0,u.useEffect)({data:e,width:t,height:n},v.effectPool,o,r||{})})),t.useMode=({data:e,width:t,height:n},o)=>a(void 0,void 0,void 0,(function*(){return(0,u.useMode)({data:e,width:t,height:n},v.effectPool,o)}))},468:function(e,t){var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function c(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.urlToBuffer=void 0,t.urlToBuffer=e=>n(void 0,void 0,void 0,(function*(){const t=yield fetch(e),n=yield t.blob(),o=yield createImageBitmap(n),r=new OffscreenCanvas(o.width,o.height).getContext("2d");if(r){r.drawImage(o,0,0,o.width,o.height);const e=r.getImageData(0,0,o.width,o.height);return[new Uint8Array(e.data.buffer),o.width,o.height]}throw new Error("Failed to get context")}))},858:function(e,t){var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function c(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.applyEffect=void 0,t.applyEffect=({data:e,width:t,height:o,effectPool:r,effect:i,options:a=null})=>n(void 0,void 0,void 0,(function*(){return new Promise(((c,u)=>n(void 0,void 0,void 0,(function*(){try{const n=yield((e,t)=>{for(let[n,o]of Object.entries(e))if(n===t)return o.method;return null})(r,i)({data:e,width:t,height:o},a);n?c({data:n,width:t,height:o}):u("Buffer is null")}catch(e){u(e)}}))))}))},221:function(e,t,n){var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return r(t,e),t},a=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function c(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.applyMode=void 0;const c=i(n(961));t.applyMode=({data:e,width:t,height:n,mode:o,effectPool:r})=>a(void 0,void 0,void 0,(function*(){return new Promise(((i,u)=>a(void 0,void 0,void 0,(function*(){try{const a=yield(e=>{for(let[t,n]of Object.entries(c))if(t===e)return n;return null})(o)({data:e,width:t,height:n,effects:r});i({data:a,width:t,height:n})}catch(e){u(e)}}))))}))},951:function(e,t,n){var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),r(n(236),t),r(n(831),t),r(n(221),t),r(n(858),t)},236:function(e,t,n){var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function c(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.useEffect=void 0;const r=n(858);t.useEffect=({data:e,width:t,height:n},i,a,c)=>o(void 0,void 0,void 0,(function*(){const o=Array.isArray(a)?a:[a];if(Array.isArray(c)&&c.length!==o.length)throw new Error("Invalid options length");let u=0;for(let a of o){if(!i[a])throw new Error(`Invalid effect: ${a}`);const o=yield(0,r.applyEffect)({data:e,width:t,height:n,effectPool:i,effect:a,options:Array.isArray(c)?c[u]:c});[e,t,n]=[o.data,o.width,o.height],u++}return{data:e,width:t,height:n}}))},831:function(e,t,n){var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return r(t,e),t},a=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function c(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.useMode=void 0;const c=n(221),u=i(n(961));t.useMode=({data:e,width:t,height:n},o,r)=>a(void 0,void 0,void 0,(function*(){const i=Array.isArray(r)?r:[r];for(let r of i){if(!u.hasOwnProperty(r))throw new Error(`Invalid mode: ${r}`);const i=yield(0,c.applyMode)({data:e,width:t,height:n,effectPool:o,mode:r});[e,t,n]=[i.data,i.width,i.height]}return{data:e,width:t,height:n}}))},352:function(e,t,n){var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function c(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.acid=void 0;const r=n(513);t.acid=({data:e,width:t,height:n,effects:i})=>o(void 0,void 0,void 0,(function*(){const o=(0,r.getPixelOps)(i);e=(yield i.scanlines.method({data:e,width:t,height:n},{opacity:.1,thickness:2,lines:100}))||e,e=(yield i.rainbow.method({data:e,width:t,height:n}))||e,e=(yield i.rectangles.method({data:e,width:t,height:n},{offset:20,intensity:15,sizeModifier:3,invertChance:.1}))||e;for(let t=0;t<e.length;t+=4)o.solarize({index:t,data:e},{intensity:.4}),o.brightness({index:t,data:e},{brightness:-4}),o.noise({index:t,data:e},{ratio:.1});return e=(yield i.chromaticAberration.method({data:e,width:t,height:n},{intensity:5}))||e}))},53:function(e,t,n){var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function c(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.chimera=void 0;const r=n(517),i=n(513),a=[.25,.5];t.chimera=({data:e,width:t,height:n,effects:c})=>o(void 0,void 0,void 0,(function*(){const u=(0,r.random)()>=.5?"horizontal":"vertical",f=(0,i.randomize)(5,10);e=(yield c.blur.method({data:e,width:t,height:n},{direction:u,intensity:f}))||e,e=yield(({data:e,width:t,height:n})=>o(void 0,void 0,void 0,(function*(){for(let o=0;o<n;o++)for(let n=0;n<t;n++){let r=4*(o*t+n),i=e[r],c=e[r+1],u=e[r+2];e[r+0]=i+c*a[1]+u*a[0],e[r+1]=i*a[1]+c+u*a[0],e[r+2]=i*a[0]+c*a[1]+u}return e})))({data:e,width:t,height:n});for(let t=0;t<e.length;t+=4){const n=(0,r.random)()<.2,o=(0,r.random)()<.4?(0,r.floor)(50*(0,r.random)()):0;for(let a=0;a<3;a++)e[t+a]=n?(0,r.min)(e[t+a]+(0,i.randomize)(1,0===a?15:10),255):e[t+a],e[t+a]=(0,r.min)(255,(0,r.max)(0,e[t+a]+((0,r.floor)(20*(0,r.random)())-30))),e[t+a]=o?(0,r.min)(255,(0,r.max)(0,e[t+a]+o)):e[t+a]}return e=(yield c.rectangles.method({data:e,width:t,height:n},{offset:10,intensity:15,sizeModifier:1.25}))||e}))},961:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.acid=t.lacunae=t.chimera=void 0;var o=n(53);Object.defineProperty(t,"chimera",{enumerable:!0,get:function(){return o.chimera}});var r=n(450);Object.defineProperty(t,"lacunae",{enumerable:!0,get:function(){return r.lacunae}});var i=n(352);Object.defineProperty(t,"acid",{enumerable:!0,get:function(){return i.acid}})},450:function(e,t,n){var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function c(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.lacunae=void 0;const r=n(513),i=n(517);t.lacunae=({data:e})=>o(void 0,void 0,void 0,(function*(){for(let t=0;t<e.length;t+=4){const n=(0,i.random)()<.2,o=(0,i.random)()<.4?(0,i.floor)(50*(0,i.random)()):0;for(let a=0;a<3;a++)e[t+a]=e[t+a]-(0,r.randomize)(1,15),e[t+a]=e[t+a]<0?e[t+a]+255:e[t+a],e[t+a]=n?(0,i.min)(e[t+a]+(0,r.randomize)(1,0===a?15:10),255):e[t+a],e[t+a]=(0,i.min)(255,(0,i.max)(0,e[t+a]+(0,i.floor)(20*(0,i.random)()-40))),e[t+a]=o?(0,i.min)(255,(0,i.max)(0,e[t+a]+o)):e[t+a]}return e}))}},t={};return function n(o){var r=t[o];if(void 0!==r)return r.exports;var i=t[o]={exports:{}};return e[o].call(i.exports,i,i.exports,n),i.exports}(532)})()));