text: (this.webpackJsonppartymoji=this.webpackJsonppartymoji||[]).push([[0],{228:function(e,a){},230:function(e,a){},245:function(e,a){},256:function(e,a){},377:function(e,a,n){"use strict";n.r(a);var t=n(0),r=n.n(t),i=n(53),o=n.n(i),c=n(23),s=n(5),u=n(463),l=n(427),d=n(462),m=n(451),f=n(452),h=n(455),p=n(450),j=n(446),b=n(20),v=n.n(b),g=n(33),x=n(460),O=n(461),w=n(448),C=n(183),y=n(184),V=n.n(y),M=n(185),F=n.n(M),k=n(91),S=n.n(k),I=n(15),P=n(134),T=n(38),N=n(420),B=function(e){var a=Object(s.a)(e,3),n=a[0],t=a[1],r=a[2],i=function(e){var a=e.toString(16).toUpperCase();return 2===a.length?a:"0"+a};return"#".concat(i(n)).concat(i(t)).concat(i(r))},W=function(e){return[parseInt(e.toUpperCase().substr(1,2),16),parseInt(e.toUpperCase().substr(3,2),16),parseInt(e.toUpperCase().substr(5,2),16),255]},A=function(e){return e[3]<64},R=function(e){return[Math.floor(256*e.int32()),Math.floor(256*e.int32()),Math.floor(256*e.int32()),255]},H=function(e,a,n){return Math.max(Math.min(e,n),a)},E=function(e){var a=Object(s.a)(e,4),n=a[0],t=a[1],r=a[2],i=a[3];return[H(n,0,255),H(t,0,255),H(r,0,255),H(i,0,255)]},D=[0,0,0,0],U=function(e,a,n){var t=Object(s.a)(e,2),r=t[0],i=t[1],o=Object(s.a)(n,2),c=o[0],u=o[1];if(c<0||c>=r||u<0||u>=i)return D;var l=z(e,c,u);return[a[l],a[l+1],a[l+2],a[l+3]]};function L(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Unexpected falsy value";if(!e)throw new P.AssertionError({message:a,actual:e})}var q=function(e,a){return{dimensions:e.dimensions,frames:e.frames.map((function(n,t){return a(n,t,e.frames.length)}))}},G=function(e,a){for(var n=Object(s.a)(e,2),t=n[0],r=n[1],i=new Uint8Array(t*r*4),o=0;o<r;o+=1)for(var c=0;c<t;c+=1){var u=E(a([c,o])),l=z(e,c,o);i[l]=u[0],i[l+1]=u[1],i[l+2]=u[2],i[l+3]=u[3]}return i},_=function(e){return function(a){var n=a.image,t=a.random,r=a.parameters;return q(n,(function(a,i,o){return G(n.dimensions,(function(c){return e({image:n,dimensions:n.dimensions,random:t,parameters:r,coord:c,frameCount:o,frameIndex:i,getSrcPixel:function(e){return U(n.dimensions,a,e)}})}))}))}},z=function(e,a,n){return 4*(a+n*Object(s.a)(e,1)[0])},J=function(e){for(var a=e.image,n=e.newWidth,t=e.newHeight,r=Object(s.a)(a.dimensions,2),i=r[0]/n,o=r[1]/t,c=Y({dimensions:[n,t],frameCount:a.frames.length}),u=0;u<c.frames.length;u+=1)for(var l=0;l<t;l+=1)for(var d=0;d<n;d+=1){var m=Math.floor(d*i),f=Math.floor(l*o),h=K({image:a,frameIndex:u,coord:[m,f]});Q({image:c,frameIndex:u,color:h,coord:[d,l]})}return c},X=function(e){for(var a=e.image,n=e.newWidth,t=e.newHeight,r=Object(s.a)(a.dimensions,2),i=r[0],o=r[1],c=Math.round((n-i)/2),u=Math.round((t-o)/2),l=Y({dimensions:[n,t],frameCount:a.frames.length}),d=0;d<l.frames.length;d+=1)for(var m=0;m<t;m+=1)for(var f=0;f<n;f+=1){var h=f>c&&f<n-c&&m>u&&m<t-u?K({image:a,frameIndex:d,coord:[f-c,m-u]}):D;Q({image:l,frameIndex:d,coord:[f,m],color:h})}return l},Y=function(e){return{dimensions:e.dimensions,frames:Object(N.a)(0,e.frameCount).map((function(){return new Uint8Array(e.dimensions[0]*e.dimensions[1]*4)}))}},K=function(e){return U(e.image.dimensions,e.image.frames[e.frameIndex],e.coord)},Q=function(e){var a=z(e.image.dimensions,e.coord[0],e.coord[1]),n=e.image.frames[e.frameIndex];n[a]=e.color[0],n[a+1]=e.color[1],n[a+2]=e.color[2],n[a+3]=e.color[3]},Z=function(e,a,n){return(1-e/100)*a+e/100*n},$=function(e,a,n){var t=Object(s.a)(e,4),r=t[0],i=t[1],o=t[2],c=t[3],u=T.rgb.hsl([r,i,o]),l=Object(s.a)(u,3),d=l[1],m=l[2],f=T.hsl.rgb([a,Z(n,d,100),m]),h=Object(s.a)(f,3),p=h[0],j=h[1],b=h[2];return[Z(n,r,p),Z(n,i,j),Z(n,o,b),c]},ee=function(e,a){var n=a[0]-e[0],t=a[1]-e[1];return(360+180*Math.atan2(t,n)/Math.PI)%360},ae=function(e){return[].concat(Object(I.a)(T.hsl.rgb([e,100,50])),[255])},ne=function(e,a){var n=Object(s.a)(e,4),t=n[0],r=n[1],i=n[2],o=n[3],c=T.rgb.hsl(t,r,i),u=Object(s.a)(c,3),l=u[0],d=u[1],m=u[2],f=Z(Math.abs(a),d,a>=0?100:0),h=T.hsl.rgb([l,f,m]),p=Object(s.a)(h,3);return[p[0],p[1],p[2],o]},te=function(){var e=Object(g.a)(v.a.mark((function e(a){var n,t,r,i,o,c,s,u,l,d,m,f,h,p,j;return v.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=a.transformList,t=a.inputDataUrl,r=a.fps,i=a.onImageFinished,o=S()(t),e.next=4,oe(t);case 4:c=e.sent,s=[],u=c,l=Object(C.a)(n),e.prev=8,l.s();case 10:if((d=l.n()).done){e.next=23;break}return m=d.value,f=m.transform.fn({image:u,parameters:m.params,random:o}),h=ce(f,o),p=re(f.frames,h),e.next=17,ie(f.dimensions,p,h,r);case 17:j=e.sent,i(),u=f,s.push({gif:j,width:f.dimensions[0],height:f.dimensions[1]});case 21:e.next=10;break;case 23:e.next=28;break;case 25:e.prev=25,e.t0=e.catch(8),l.e(e.t0);case 28:return e.prev=28,l.f(),e.finish(28);case 31:return e.abrupt("return",s);case 32:case"end":return e.stop()}}),e,null,[[8,25,28,31]])})));return function(a){return e.apply(this,arguments)}}(),re=function(e,a){return e.map((function(e){for(var n=new Uint8Array(e.length),t=0;t<e.length;t+=4)a&&e[t+3]<128?(n[t]=a[0],n[t+1]=a[1],n[t+2]=a[2],n[t+3]=a[3]):(n[t]=e[t],n[t+1]=e[t+1],n[t+2]=e[t+2],n[t+3]=255);return n}))},ie=function(){var e=Object(g.a)(v.a.mark((function e(a,n,t,r){return v.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e){var i=Object(s.a)(a,2),o=i[0],c=i[1],u=new F.a(o,c);if(u.setFrameRate(r),u.setRepeat(0),t){var l=B(t).slice(1);u.setTransparent("0x".concat(l))}u.writeHeader();var d=[];u.on("data",(function(e){d.push(e)})),u.on("end",(function(){var a=URL.createObjectURL(new Blob(d,{type:"image/gif"}));e(a)})),n.forEach((function(e){u.addFrame(e)})),u.finish()})));case 1:case"end":return e.stop()}}),e)})));return function(a,n,t,r){return e.apply(this,arguments)}}(),oe=function(e){return new Promise((function(a,n){return V()(e,(function(e,t){if(e)return n(e);if(3===t.shape.length)return a({frames:[Uint8Array.from(t.data)],dimensions:[t.shape[0],t.shape[1]]});for(var r=Object(s.a)(t.shape,3),i=r[0],o=r[1],c=r[2],u=o*c*4,l=[],d=0;d<i;d+=1)l.push(t.data.subarray(d*u,(d+1)*u));return a({frames:l,dimensions:[o,c]})}))}))},ce=function(e,a){var n=!1,t=new Set,r=Object(s.a)(e.dimensions,2),i=r[0],o=r[1],c=B([0,255,0,255]);return e.frames.forEach((function(r){for(var s=0;s<o;s+=1)for(var u=0;u<i;u+=1){var l=U(e.dimensions,r,[u,s]);if(A(l))n=!0;else{var d=B(l);t.add(d),d===c&&(c=se(a,t))}}})),n?W(c):void 0},se=function e(a,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=B(R(a));return t>2e3?r:n.has(r)?e(a,n,t+1):r},ue=n(442),le=n(449),de=n(1),me=function(e){var a=e.description;return a?Object(de.jsx)(le.a,{title:a,children:Object(de.jsx)(p.a,{fontSize:"small",color:"action",children:"help"})}):null},fe=function(e){var a=e.name,n=e.value,t=e.min,r=e.max,i=e.step,o=e.description,c=e.onChange;return Object(de.jsxs)(l.a,{spacing:1,children:[Object(de.jsxs)(l.a,{direction:"row",spacing:1,children:[Object(de.jsx)(m.a,{variant:"body2",children:a}),Object(de.jsx)(me,{description:o})]}),Object(de.jsxs)(l.a,{direction:"row",spacing:2,sx:{paddingLeft:"8px",paddingRight:"8px"},children:[Object(de.jsx)(ue.a,{"aria-label":a,value:n,step:i,valueLabelDisplay:"off",getAriaValueText:function(e){return e.toString()},min:t,max:r,onChange:function(e,a){return c({valid:!0,value:a})}}),Object(de.jsx)(m.a,{variant:"body2",children:n})]})]})};function he(e){return{name:e.name,defaultValue:void 0!==e.defaultValue?{valid:!0,value:e.defaultValue}:{valid:!1},fn:function(a){return Object(de.jsx)(fe,{name:e.name,value:a.value.valid?a.value.value:void 0,onChange:a.onChange,min:e.min,max:e.max,step:e.step,description:e.description})}}}var pe=n(432),je=n(435),be=n(459),ve=function(e){var a;return{name:e.name,params:e.params,description:e.description,fn:e.fn,disabled:null!==(a=e.disabled)&&void 0!==a&&a}},ge=n(444),xe=n(437),Oe=n(453),we=function(e){var a=e.name,n=e.value,t=e.description,i=e.parse,o=e.onChange,c=r.a.useState(void 0===n?void 0:n.toString()),u=Object(s.a)(c,2),d=u[0],f=u[1],h=r.a.useState(""),p=Object(s.a)(h,2),j=p[0],b=p[1];return Object(de.jsxs)(l.a,{spacing:1,children:[Object(de.jsxs)(l.a,{direction:"row",spacing:1,children:[Object(de.jsx)(m.a,{variant:"body2",children:a}),Object(de.jsx)(me,{description:t})]}),Object(de.jsxs)(ge.a,{children:[Object(de.jsx)(xe.a,{error:!!j,value:d,onBlur:function(){if(void 0!==d&&(!n||d!==n.toString())){var e=i(d);e.valid?b(""):b(e.reason),o(e)}},onChange:function(e){f(e.target.value)}}),j&&Object(de.jsx)(Oe.a,{children:j})]})]})},Ce=function(e){return{name:e.name,defaultValue:void 0!==e.defaultValue?{valid:!0,value:e.defaultValue}:{valid:!1},fn:function(a){var n=e.min,t=e.max;return Object(de.jsx)(we,{name:e.name,description:e.description,parse:function(e){var a=parseInt(e,10);return isNaN(a)||a.toString()!==e?{valid:!1,reason:"Must be an integer"}:void 0!==n&&a<n?{valid:!1,reason:"Must be greater than or equal to ".concat(n)}:void 0!==t&&a>t?{valid:!1,reason:"Must be less than or equal to ".concat(t)}:{valid:!0,value:a}},onChange:a.onChange,value:a.value.valid?a.value.value:void 0})}}},ye=ve({name:"Adjust Image",description:"Leave a parameter at 0 if you want to not change it",params:[he({name:"Number of Frames",description:"Set how many frames of animation there will be. Leave at 0 to not change the current frame count.",defaultValue:0,min:0,max:60}),Ce({name:"Width",description:"Leave at 0 to not change the width. If height is changed, the image will keep the same aspect ratio.",defaultValue:0,min:0}),Ce({name:"Height",description:"Leave at 0 to not change the height. If width is changed, the image will keep the same aspect ratio.",defaultValue:0,min:0}),he({name:"Brightness",min:-100,max:100,step:5,defaultValue:0}),he({name:"Contrast",min:-100,max:100,step:5,defaultValue:0}),he({name:"Saturation",min:-100,max:100,step:5,defaultValue:0})],fn:function(e){var a=e.image,n=Object(s.a)(e.parameters,6),t=n[0],r=n[1],i=n[2],o=n[3],c=n[4],u=n[5],l=0!==t,d=Object(s.a)(a.dimensions,2),m=d[0],f=d[1],h=r>0||i>0,p=h&&0===r?Math.ceil(m/f*i):r,j=h&&0===i?Math.ceil(f/m*r):i;console.log({oldWidth:m,oldHeight:f,newWidth:p,newHeight:j});var b=p*j>m*f,v=a;return l&&t<a.frames.length&&(v=Ve(v,t)),h&&!b&&(v=J({image:v,newWidth:p,newHeight:j})),v=q(v,(function(e){return G(v.dimensions,(function(a){var n=U(v.dimensions,e,a);return 0!==o&&(n=function(e,a){var n=a/100*128,t=Object(s.a)(e,4),r=t[0],i=t[1],o=t[2],c=t[3];return E([r+n,i+n,o+n,c])}(n,o)),0!==c&&(n=function(e,a){var n=a/100+1,t=Object(s.a)(e,4),r=t[0],i=t[1],o=t[2],c=t[3];return E([n*(r-128)+128,n*(i-128)+128,n*(o-128)+128,c])}(n,c)),0!==u&&(n=ne(n,u)),n}))})),h&&b&&(v=J({image:v,newWidth:p,newHeight:j})),l&&t>a.frames.length&&(v=Ve(v,t)),v}}),Ve=function(e,a){var n=e.frames;return{dimensions:e.dimensions,frames:Object(N.a)(0,a).map((function(e){return n[e]?n[e]:n[n.length-1]}))}},Me=n(103),Fe=n(430),ke=n(454),Se=n(456),Ie=function(e){var a=e.mainEle,n=e.children,t=r.a.useState(!0),i=Object(s.a)(t,2),o=i[0],c=i[1];return Object(de.jsx)(Fe.a,{onClickAway:function(){return c(!0)},children:Object(de.jsxs)(ke.a,{children:[Object(de.jsx)(h.a,{onClick:function(){return c(!o)},style:{textTransform:"none",color:"black"},children:Object(de.jsxs)(l.a,{direction:"row",spacing:4,children:[Object(de.jsx)("div",{children:a}),Object(de.jsx)(p.a,{children:o?"expand_less":"expand_more"})]})}),Object(de.jsx)(Se.a,{in:!o,children:n})]})})},Pe=function(e){var a=e.color;return Object(de.jsx)("div",{style:{width:"1.5em",height:"1.5em",backgroundColor:B(a)}})},Te=function(e){var a=e.name,n=e.value,t=e.description,r=e.onChange;return Object(de.jsx)(Ie,{mainEle:Object(de.jsxs)(l.a,{direction:"row",spacing:4,children:[Object(de.jsx)(m.a,{variant:"body2",children:a}),Object(de.jsx)(me,{description:t}),n&&Object(de.jsx)(Pe,{color:n})]}),children:Object(de.jsx)(Me.b,{disableAlpha:!0,presetColors:[],color:n?B(n):void 0,onChangeComplete:function(e){return r({valid:!0,value:W(e.hex)})}})})};function Ne(e){return{name:e.name,defaultValue:e.defaultValue?{valid:!0,value:e.defaultValue}:{valid:!1},fn:function(a){return Object(de.jsx)(Te,{name:e.name,value:a.value.valid?a.value.value:void 0,onChange:a.onChange,description:e.description})}}}var Be=ve({name:"Background Color",description:"Change all transparent pixles to the given color",params:[Ne({name:"Color",defaultValue:W("#000000")})],fn:_((function(e){var a=e.coord,n=e.getSrcPixel,t=Object(s.a)(e.parameters,1)[0],r=n(a);return A(r)?t:r}))}),We=function(e){var a=e.currentImageUrl,n=e.name,t=e.onChange;return Object(de.jsxs)(l.a,{spacing:4,children:[Object(de.jsxs)(h.a,{startIcon:Object(de.jsx)(p.a,{children:"image"}),sx:{maxWidth:"300px"},variant:"contained",component:"label",children:[n,Object(de.jsx)("input",{type:"file",hidden:!0,accept:"image/png,image/jpg,image/gif",name:"source-png",onChange:function(){var e=Object(g.a)(v.a.mark((function e(a){var n,r,i,o;return v.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=Array.from(null!==(n=a.target.files)&&void 0!==n?n:[]),!(i=r[0])){e.next=7;break}return e.next=5,Ae(i);case 5:o=e.sent,t(o);case 7:case"end":return e.stop()}}),e)})));return function(a){return e.apply(this,arguments)}}()})]}),a&&Object(de.jsx)("img",{style:{maxWidth:"300px",maxHeight:"auto"},src:a,alt:"Source"})]})},Ae=function(e){return new Promise((function(a){var n=new FileReader;n.onload=function(){return a(n.result)},n.readAsDataURL(e)}))};var Re=n(447),He=n(457),Ee=n(440),De=function(e){var a=e.name,n=e.options,t=e.value,r=e.description,i=e.onChange;return Object(de.jsxs)(l.a,{spacing:1,children:[Object(de.jsxs)(l.a,{direction:"row",spacing:1,children:[Object(de.jsx)(m.a,{variant:"body2",children:a}),Object(de.jsx)(me,{description:r})]}),Object(de.jsx)(ge.a,{component:"fieldset",children:Object(de.jsx)(Re.a,{"aria-label":a,defaultValue:t,onChange:function(e){return i({valid:!0,value:e.target.value})},children:n.map((function(e){return Object(de.jsx)(He.a,{value:e.value,control:Object(de.jsx)(Ee.a,{}),label:e.name})}))})})]})};function Ue(e){return{name:e.name,defaultValue:e.defaultValue?{valid:!0,value:e.defaultValue}:{valid:!1},fn:function(a){return Object(de.jsx)(De,{name:e.name,value:a.value.valid?a.value.value:void 0,options:e.options,description:e.description,onChange:a.onChange})}}}var Le=ve({name:"Background Image",description:"Select another image to be used as a background or foreground",params:[function(e){var a=e.name;return{name:a,defaultValue:{valid:!1},fn:function(e){return Object(de.jsx)(We,{currentImageUrl:e.value.valid?e.value.value.dataUrl:void 0,name:a,width:64,height:64,onChange:function(){var a=Object(g.a)(v.a.mark((function a(n){var t;return v.a.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,oe(n);case 2:t=a.sent,e.onChange({valid:!0,value:{dataUrl:n,image:t}});case 4:case"end":return a.stop()}}),a)})));return function(e){return a.apply(this,arguments)}}()})}}}({name:"Image"}),Ue({name:"Type",defaultValue:"background",options:[{name:"Background",value:"background"},{name:"Foreground",value:"foreground"}]})],fn:function(e){var a=e.image,n=e.parameters,t=X({image:n[0].image,newWidth:a.dimensions[0],newHeight:a.dimensions[1]}),r=n[1];return q(a,(function(e,n){return G(a.dimensions,(function(e){var i=n/a.frames.length,o=Math.floor(i*t.frames.length),c=K({image:t,frameIndex:o,coord:e}),s=K({image:a,frameIndex:n,coord:e});return"background"===r?A(s)?c:s:A(c)?s:c}))}))}}),qe=ve({name:"Bounce",description:"Make the image bounce up and down",params:[Ce({name:"Bounce Speed",description:"Positive number",defaultValue:5,min:0})],fn:_((function(e){var a=Object(s.a)(e.coord,2),n=a[0],t=a[1],r=e.frameCount,i=e.frameIndex,o=e.getSrcPixel,c=Object(s.a)(e.parameters,1)[0];return o([n,t+Math.round(c*Math.sin(i/r*2*Math.PI))])}))}),Ge=n(431),_e=n(433),ze=n(434),Je=ve({name:"Bounce Animation",description:"When the animation finishes, it will be replayed in reverse",params:[],fn:function(e){var a=e.image;return{dimensions:a.dimensions,frames:Object(Ge.a)(a.frames,Object(pe.a)(a.frames,Object(_e.a)(1),Object(ze.a)(),Object(_e.a)(1)))}}}),Xe=ve({name:"Circle",description:"Make the image move in a circular pattern",params:[Ce({name:"Radius",description:"Positive number",defaultValue:10,min:0})],fn:_((function(e){var a=Object(s.a)(e.coord,2),n=a[0],t=a[1],r=e.frameCount,i=e.frameIndex,o=e.getSrcPixel,c=Object(s.a)(e.parameters,1)[0];return o([n+Math.round(c*Math.sin(-2*Math.PI*(i/r))),t+Math.round(c*Math.cos(-2*Math.PI*(i/r)))])}))}),Ye=n(458),Ke=function(e){var a=e.name,n=e.newParamText,t=e.createNewParam,i=e.value,o=e.description,c=e.onChange,u=r.a.useState(void 0===i?[]:i.map((function(e,a){return{param:t(),pValue:e}}))),d=Object(s.a)(u,2),j=d[0],b=d[1];return Object(de.jsx)(f.a,{children:Object(de.jsxs)(l.a,{spacing:1,children:[Object(de.jsxs)(l.a,{direction:"row",spacing:1,children:[Object(de.jsx)(m.a,{variant:"body2",children:a}),Object(de.jsx)(me,{description:o})]}),j.map((function(e,n){var t=e.param,r=e.pValue,i=t.fn({value:{valid:!0,value:r},onChange:function(e){if(e.valid){var a=j.map((function(a,r){return n===r?{param:t,pValue:e.value}:a}));b(a),c({valid:!0,value:a.map((function(e){return e.pValue}))})}}});return Object(de.jsxs)(l.a,{direction:"row",children:[Object(de.jsx)(Ye.a,{onClick:function(){var e=j.filter((function(e,a){return a!==n}));b(e),c({valid:!0,value:e.map((function(e){return e.pValue}))})},children:Object(de.jsx)(p.a,{children:"delete"})}),i]},"".concat(a,"-").concat(n))})),Object(de.jsx)(h.a,{variant:"contained",onClick:function(){var e=t(),a=[].concat(Object(I.a)(j),[{param:e,pValue:e.defaultValue.valid?e.defaultValue.value:void 0}]);b(a),e.defaultValue.valid&&c({valid:!0,value:a.map((function(e){return e.pValue}))})},children:n})]})})};function Qe(e){return{name:e.name,defaultValue:e.defaultValue?{valid:!0,value:e.defaultValue}:{valid:!1},fn:function(a){return Object(de.jsx)(Ke,{name:e.name,newParamText:e.newParamText,value:a.value.valid?a.value.value:void 0,createNewParam:e.createNewParam,description:e.description,onChange:a.onChange})}}}var Ze=ve({name:"Colors",description:"Make the image flash different colors",params:[Qe({name:"Colors",newParamText:"New Color",defaultValue:["#FF8D8B","#FED689","#88FF89","#87FFFF","#8BB5FE","#D78CFF","#FF8CFF","#FF68F7","#FE6CB7","#FF6968"].map(W),createNewParam:function(){return Ne({name:"Color"})}})],fn:_((function(e){var a=e.coord,n=e.frameCount,t=e.frameIndex,r=e.getSrcPixel,i=Object(s.a)(e.parameters,1)[0],o=r(a);if(A(o))return[0,0,0,0];var c=i[Math.floor(t/n*i.length)],u=function(e){var a=Object(s.a)(e,3),n=a[0],t=a[1],r=a[2];return Math.round((n+t+r)/3)}(o);return[u*c[0]/255,u*c[1]/255,u*c[2]/255,255]}))}),$e=ve({name:"Colors Background",description:"Transparent pixels will flash different colors",params:[Qe({name:"Colors",newParamText:"New Color",defaultValue:["#FF8D8B","#FED689","#88FF89","#87FFFF","#8BB5FE","#D78CFF","#FF8CFF","#FF68F7","#FE6CB7","#FF6968"].map(W),createNewParam:function(){return Ne({name:"Color"})}})],fn:_((function(e){var a=e.coord,n=e.frameCount,t=e.frameIndex,r=e.getSrcPixel,i=Object(s.a)(e.parameters,1)[0],o=r(a);return A(o)?i[Math.floor(t/n*i.length)]:o}))}),ea=function(e){var a=e.name,n=e.value,t=e.description,i=e.parse,o=e.onChange,c=r.a.useState(void 0===n?void 0:n.toString()),u=Object(s.a)(c,2),d=u[0],f=u[1],h=r.a.useState(""),p=Object(s.a)(h,2),j=p[0],b=p[1];return Object(de.jsxs)(l.a,{spacing:1,children:[Object(de.jsxs)(l.a,{direction:"row",spacing:1,children:[Object(de.jsx)(m.a,{variant:"body2",children:a}),Object(de.jsx)(me,{description:t})]}),Object(de.jsxs)(ge.a,{children:[Object(de.jsx)(xe.a,{error:!!j,value:d,onBlur:function(){if(void 0!==d&&(!n||d!==n.toString())){var e=i(d);e.valid?b(""):b(e.reason),o(e)}},onChange:function(e){f(e.target.value)}}),j&&Object(de.jsx)(Oe.a,{children:j})]})]})},aa=function(e){return{name:e.name,defaultValue:void 0!==e.defaultValue?{valid:!0,value:e.defaultValue}:{valid:!1},fn:function(a){var n=e.min,t=e.max;return Object(de.jsx)(ea,{name:e.name,description:e.description,parse:function(e){var a=parseFloat(e);return isNaN(a)||a.toString()!==e?{valid:!1,reason:"Must be a number"}:void 0!==n&&a<n?{valid:!1,reason:"Must be greater than or equal to ".concat(n)}:void 0!==t&&a>t?{valid:!1,reason:"Must be less than or equal to ".concat(t)}:{valid:!0,value:a}},onChange:a.onChange,value:a.value.valid?a.value.value:void 0})}}},na=ve({name:"Double Vision",description:"See the image in double",params:[aa({name:"Amplitude",defaultValue:10,min:0})],fn:_((function(e){var a=Object(s.a)(e.coord,2),n=a[0],t=a[1],r=e.frameCount,i=e.frameIndex,o=e.getSrcPixel,c=Object(s.a)(e.parameters,1)[0],u=n%2===0?-1:1;return o([n+Math.round(u*c*Math.sin(-2*Math.PI*(i/r))),t])}))}),ta=ve({name:"Expand",description:"Make the image grow and shrink",params:[Ce({name:"Radius",description:"Positive number",defaultValue:10,min:0})],fn:_((function(e){var a=e.dimensions,n=Object(s.a)(e.coord,2),t=n[0],r=n[1],i=e.frameCount,o=e.frameIndex,c=e.getSrcPixel,u=Object(s.a)(e.parameters,1)[0],l=o/i,d=Math.cos(2*l*Math.PI)*u,m=Object(s.a)(a,2),f=m[0],h=m[1],p=(t-f/2)/f,j=(r-h/2)/h;return c([t-Math.floor(d*p),r-Math.round(d*j)])}))}),ra=ve({disabled:!0,name:"Fill Transparent",description:"Makes transparent all pixels of similar color surrounding a point",params:[he({name:"Tolerance",defaultValue:50,min:0,max:100})],fn:_((function(e){var a=e.coord,n=e.getSrcPixel,t=(Object(s.a)(e.parameters,1)[0],n([0,0]),n(a),Object(s.a)(a,2));t[0],t[1];return[0,0,0,0]}))}),ia=ve({name:"Fisheye",description:"Make the image grow and shrink in a distorted fashion",params:[Ce({name:"Radius",description:"Positive Number",defaultValue:10,min:0})],fn:_((function(e){var a=e.dimensions,n=Object(s.a)(e.coord,2),t=n[0],r=n[1],i=e.frameCount,o=e.frameIndex,c=e.getSrcPixel,u=Object(s.a)(e.parameters,1)[0],l=o/i,d=l<.5,m=Object(s.a)(a,2),f=(d?l:1-l)*u,h=m[0]/2,p=m[1]/2,j=Math.atan2(p-r,h-t);return c([t+Math.round(f*Math.cos(j)),r+Math.round(f*Math.sin(j))])}))}),oa=ve({name:"Grid",description:"Removes the color from all pixels not aligned with a grid",params:[he({name:"Grid Size",description:"The length of each square in the grid",defaultValue:24,min:2,max:64,step:2}),he({name:"Grid Angle",defaultValue:45,min:0,max:90})],fn:_((function(e){var a=e.coord,n=e.getSrcPixel,t=Object(s.a)(e.parameters,2),r=t[0],i=t[1],o=n(a),c=Object(s.a)(a,2),u=c[0],l=c[1],d=!1;if(i%90===0)d=u%r===0||l%r===0;else{var m=(64-r)/64*.1+.03,f=function(e){var a=1/r*(l-Math.tan(ca(e))*u);return Math.abs(Math.round(a)-a)<m};d=f(i)||f(i+90)}return d?o:ne(o,-100)}))}),ca=function(e){return e*Math.PI/180},sa=function(e){var a=e.name,n=e.value,t=e.description,r=e.onChange,i=void 0===n?void 0:B([].concat(Object(I.a)(T.hsl.rgb([n,255,255])),[255]));return Object(de.jsxs)(l.a,{spacing:1,children:[Object(de.jsxs)(l.a,{direction:"row",spacing:1,children:[Object(de.jsx)(m.a,{variant:"body2",children:a}),Object(de.jsx)(me,{description:t})]}),Object(de.jsx)(Me.a,{color:i,onChangeComplete:function(e){var a=e.hsl;return r({valid:!0,value:a.h})}})]})};var ua,la=ve({name:"Hue Shift",description:"Shift the hue to some other color",params:[(ua={name:"Hue",defaultValue:180},{name:ua.name,defaultValue:ua.defaultValue?{valid:!0,value:ua.defaultValue}:{valid:!1},fn:function(e){return Object(de.jsx)(sa,{name:ua.name,value:e.value.valid?e.value.value:void 0,onChange:e.onChange})}}),he({name:"Amount",description:"How strong the effect is.",min:0,max:100,step:5,defaultValue:75})],fn:_((function(e){var a=e.coord,n=e.getSrcPixel,t=Object(s.a)(e.parameters,2),r=t[0],i=t[1];return $(n(a),r,i)}))}),da=function(e){var a=e.name,n=e.value,t=e.description,i=e.onChange,o=r.a.useState(n),c=Object(s.a)(o,2),u=c[0],d=c[1];return Object(de.jsxs)(l.a,{spacing:1,children:[Object(de.jsxs)(l.a,{direction:"row",spacing:1,children:[Object(de.jsx)(m.a,{variant:"body2",children:a}),Object(de.jsx)(me,{description:t})]}),Object(de.jsx)(ge.a,{children:Object(de.jsx)(xe.a,{value:u,onChange:function(e){return d(e.target.value)},onBlur:function(){return i(u?{valid:!0,value:u}:{valid:!1})}})})]})},ma=[[0,15,40,255],[150,150,175,255],[180,180,205,255],[210,210,235,255]],fa=ve({name:"Lightning",description:"Make the background look like a thunderstorm",params:[function(e){return{name:e.name,defaultValue:void 0!==e.defaultValue?{valid:!0,value:e.defaultValue}:{valid:!1},fn:function(a){return Object(de.jsx)(da,{name:e.name,description:e.description,onChange:a.onChange,value:a.value.valid?a.value.value:void 0})}}}({name:"Random Seed",description:"Can be anything. Will determine the randomness of the lightning.",defaultValue:"lightning"})],fn:function(e){var a=e.image,n=Object(s.a)(e.parameters,1)[0],t=S()(n);return q(a,(function(e){var n=t(),r=n<.9?0:n<.95?1:n<.98?2:3;return G(a.dimensions,(function(n){var t=U(a.dimensions,e,n);if(A(t))return ma[r];if(r>0){var i=1.02*r;return[t[0]*i,t[1]*i,t[2]*i,t[3]]}return t}))}))}}),ha=ve({name:"Nuke",description:"Oh no...",params:[],fn:_((function(e){var a=e.coord,n=e.getSrcPixel,t=e.frameCount,r=e.frameIndex/t*255,i=n(a),o=Object(s.a)(i,4),c=o[0],u=o[1],l=o[2],d=o[3],m=T.rgb.hsl(c,u,l),f=Object(s.a)(m,3),h=f[0],p=f[1],j=f[2],b=T.hsl.rgb([h,p,j>r?j:0]),v=Object(s.a)(b,3);return[v[0],v[1],v[2],j>r?d:0]}))}),pa=ve({name:"Party",description:"Party time!",params:[Ue({name:"Type",description:"Whether to apply the party to the foreground or background",defaultValue:"background",options:[{name:"Background",value:"background"},{name:"Foreground",value:"foreground"}]}),he({name:"Amount",description:"How strong the effect is",min:0,max:100,step:5,defaultValue:50}),he({name:"Shift Speed",description:"Controls how quickly it shifts through the various colors",min:1,max:12,defaultValue:1})],fn:_((function(e){var a=e.coord,n=e.getSrcPixel,t=e.frameCount,r=e.frameIndex,i=Object(s.a)(e.parameters,3),o=i[0],c=i[1],u=i[2],l=n(a),d=A(l),m=r/t*u*360%360;return d&&"background"===o?ae(m):d||"foreground"!==o?l:$(l,m,c)}))}),ja=["#FF0000","#FF9600","#FFFF00","#00FF00","#00FF96","#00FFFF","#0000FF","#B400FF"].map(W),ba=ve({name:"Pinwheel",description:"Create a pinwheel of colors",params:[he({name:"Group Count",description:"How many times each color is repeated",defaultValue:1,min:1,max:24}),Qe({name:"Colors",newParamText:"New Color",description:"Colors for the pinwheel",defaultValue:ja,createNewParam:function(){return Ne({name:"Color"})}}),Ce({name:"Offset X",description:"Change the horizontal center of the pinwheel",defaultValue:0}),Ce({name:"Offset Y",description:"Change the vertical center of the pinwheel",defaultValue:0})],fn:_((function(e){for(var a=e.coord,n=e.dimensions,t=e.frameCount,r=e.frameIndex,i=e.getSrcPixel,o=Object(s.a)(e.parameters,4),c=o[0],u=o[1],l=o[2],d=o[3],m=i(a),f=u.length*c,h=Math.round(360/f),p=u.length;"00"!==(f/p).toFixed(2).slice(-2);)p-=1;if(A(m)){var j=[n[0]/2+l,n[1]/2-d],b=ee(a,j),v=Math.floor(b/h)%p,g=r/t;return u[(Math.floor(g*p)+v)%p]}return m}))}),va=ve({name:"Pinwheel Party",description:"Create a pinwheel of party colors",params:[he({name:"Group Count",description:"How many times each rainbow is repeated",defaultValue:1,min:1,max:24}),Ue({name:"Type",description:"Whether to apply the party to the foreground or background",defaultValue:"background",options:[{name:"Background",value:"background"},{name:"Foreground",value:"foreground"}]}),he({name:"Amount",description:"How strong the effect is. Only applies when type = foreground.",min:0,max:100,step:5,defaultValue:75}),Ce({name:"Offset X",description:"Change the horizontal center of the pinwheel",defaultValue:0}),Ce({name:"Offset Y",description:"Change the vertical center of the pinwheel",defaultValue:0})],fn:_((function(e){var a=e.coord,n=e.dimensions,t=e.frameCount,r=e.frameIndex,i=e.getSrcPixel,o=Object(s.a)(e.parameters,5),c=o[0],u=o[1],l=o[2],d=o[3],m=o[4],f=i(a),h=A(f);if("foreground"===u?h:!h)return f;var p=[n[0]/2+d,n[1]/2-m],j=(ee(a,p)*c+360*(r/t))%360;return h?ae(j):$(f,j,l)}))}),xa=["#FF0000","#FF9600","#FFFF00","#00FF00","#00FF96","#00FFFF","#0000FF","#B400FF"].map(W),Oa=ve({name:"Radiance",description:"Radiate colors out in rings",params:[he({name:"Group Count",description:"How many times each color is repeated",defaultValue:1,min:1,max:24}),Qe({name:"Colors",newParamText:"New Color",description:"The colors that make up each ring",defaultValue:xa,createNewParam:function(){return Ne({name:"Color"})}}),Ce({name:"Offset X",description:"Change the horizontal center of the radiance",defaultValue:0}),Ce({name:"Offset Y",description:"Change the vertical center of the radiance",defaultValue:0})],fn:function(e){var a=e.image,n=Object(s.a)(e.parameters,4),t=n[0],r=n[1],i=n[2],o=n[3],c=Object(N.a)(0,t).flatMap((function(){return r})),u=Object(s.a)(a.dimensions,2),l=u[0],d=u[1],m=l/2,f=d/2;return q(a,(function(e,n,t){return G(a.dimensions,(function(r){var u=U(a.dimensions,e,r);if(A(u)){var h=Object(s.a)(r,2),p=h[0],j=h[1],b=p-m-i,v=j-f+o,g=Math.sqrt(l/2*(l/2)+d/2*(d/2)),x=Math.sqrt(v*v+b*b),O=Math.floor((1-x/g)*c.length)%c.length,w=n/t,C=(Math.floor(w*c.length)+O)%c.length;return c[C]}return u}))}))}}),wa=ve({name:"Radiance Party",description:"Radiate party colors out in rings",params:[he({name:"Group Count",description:"How many times each rainbow is repeated",defaultValue:1,min:1,max:24}),Ue({name:"Type",description:"Whether to apply the party to the foreground or background",defaultValue:"background",options:[{name:"Background",value:"background"},{name:"Foreground",value:"foreground"}]}),he({name:"Amount",description:"How strong the effect is. Only applies when type = foreground.",min:0,max:100,step:5,defaultValue:75}),Ce({name:"Offset X",description:"Change the horizontal center of the radiance",defaultValue:0}),Ce({name:"Offset Y",description:"Change the vertical center of the radiance",defaultValue:0})],fn:function(e){var a=e.image,n=Object(s.a)(e.parameters,5),t=n[0],r=n[1],i=n[2],o=n[3],c=n[4],u=Object(s.a)(a.dimensions,2),l=u[0],d=u[1],m=l/2,f=d/2,h=Math.sqrt(l/2*(l/2)+d/2*(d/2));return q(a,(function(e,n,u){return G(a.dimensions,(function(l){var d=Object(s.a)(l,2),p=d[0],j=d[1],b=U(a.dimensions,e,l),v=A(b);if("foreground"===r?v:!v)return b;var g=p-m-o,x=j-f+c,O=(360*(1-Math.sqrt(x*x+g*g)/h)*t+360*(n/u))%360;return v?ae(O):$(b,O,i)}))}))}}),Ca=ve({name:"Repeat Animation",description:"Repeats the current animation some number of times",params:[he({name:"Number of Repeats",defaultValue:1,min:1,max:50})],fn:function(e){var a=e.image,n=Object(s.a)(e.parameters,1)[0];return{dimensions:a.dimensions,frames:Object(N.a)(0,a.frames.length*(n+1)).map((function(e){return a.frames[e%a.frames.length]}))}}}),ya=ve({name:"Resize Image",description:"Change the dimensions of the image. If bigger than original, the extra space will be transparent. If smaller, the image will be cropped. ",params:[Ce({name:"Width",description:"Set to 0 when height is set to non-zero to keep the same aspect ratio",defaultValue:128,min:0}),Ce({name:"Height",description:"Set to 0 when width is set to non-zero to keep the same aspect ratio",defaultValue:128,min:0})],fn:function(e){var a=e.image,n=Object(s.a)(e.parameters,2),t=n[0],r=n[1],i=Object(s.a)(a.dimensions,2),o=i[0],c=i[1],u=0===t?Math.ceil(o/c*r):t,l=0===r?Math.ceil(c/o*t):r;return X({image:a,newWidth:u,newHeight:l})}}),Va=ve({name:"Reverse Animation",description:"Reverses the animation",params:[],fn:function(e){var a=e.image;return{dimensions:a.dimensions,frames:Object(ze.a)(a.frames)}}}),Ma=ve({name:"Ripple",description:"Create a ripple effect, like water",params:[aa({name:"Amplitude",defaultValue:10,description:"How strong the ripple effect should be"}),Ce({name:"Period",defaultValue:2,min:0,description:"How many ripples you want. Positive number."})],fn:function(e){var a=e.image,n=Object(s.a)(e.parameters,2),t=n[0],r=n[1];return q(a,(function(e,n,i){var o=a.dimensions[1],c=n/i*2*Math.PI;return G(a.dimensions,(function(n){var i=Object(s.a)(n,2),u=i[0],l=i[1],d=Math.round(t*Math.sin(l/o*r*Math.PI+c));return U(a.dimensions,e,[u+d,l])}))}))}}),Fa=ve({name:"Rotate",description:"Make the image rotate about the center point",params:[Ue({name:"Direction",defaultValue:-1,options:[{name:"Clockwise",value:-1},{name:"Counter-Clockwise",value:1}]})],fn:_((function(e){var a=Object(s.a)(e.dimensions,2),n=a[0],t=a[1],r=Object(s.a)(e.coord,2),i=r[0],o=r[1],c=e.frameCount,u=e.frameIndex,l=e.getSrcPixel,d=n/2,m=t/2,f=i-d,h=o-m,p=u/c*(Object(s.a)(e.parameters,1)[0]||1),j=Math.cos(2*Math.PI*p),b=Math.sin(2*Math.PI*p);return l([Math.round(d+f*j-h*b),Math.round(m+h*j+f*b)])}))}),ka=ve({name:"Roxbury",description:"Baby, don't hurt me",params:[],fn:function(e){var a=e.image;return q(a,(function(e,n,t){var r=n/t,i=Math.floor(4*r),o=4*(r-i/4),c=Math.PI/2*.2,u=0===i?0:1===i?o*c:2===i?c:(1-o)*c,l=Math.cos(1.35*-u),d=Math.sin(1.35*-u),m=.25*a.dimensions[0],f=.7*a.dimensions[1];return G(a.dimensions,(function(n){var t=Object(s.a)(n,2),r=t[0],i=t[1],o=Math.floor(r-m+8*Math.sin(u)),c=Math.floor(i-f+8*Math.cos(u)),h=[Math.round(m+o*l-c*d),Math.round(f+c*l+o*d)];return U(a.dimensions,e,h)}))}))}}),Sa=ve({name:"Shake",description:"Make the image shake back and forth",params:[aa({name:"Amplitude",defaultValue:10,min:0})],fn:_((function(e){var a=Object(s.a)(e.coord,2),n=a[0],t=a[1],r=e.frameCount,i=e.frameIndex,o=e.getSrcPixel,c=Object(s.a)(e.parameters,1)[0];return o([n+Math.round(c*Math.cos(i/r*2*Math.PI)),t])}))}),Ia=ve({name:"Slow Animation",description:"Attempts to slow the animation by adding intermediate frames",params:[Ue({name:"Interpolation Type",options:[{name:"Basic",value:"basic"},{name:"Smooth",value:"smooth"}],defaultValue:"basic",description:"With basic interpolation, frames are simply duplicated. With smooth interpolation, intermediate frames are the average of their surrounding frames."})],fn:function(e){var a=e.image,n=Object(s.a)(e.parameters,1)[0];return{dimensions:a.dimensions,frames:Object(N.a)(0,2*a.frames.length-1).map((function(e){if(e%2===0)return a.frames[e/2];var t=(e-1)/2;return"basic"===n?a.frames[t]:G(a.dimensions,(function(e){var n=U(a.dimensions,a.frames[t],e),r=Object(s.a)(n,4),i=r[0],o=r[1],c=r[2],u=r[3],l=U(a.dimensions,a.frames[t+1],e),d=Object(s.a)(l,4);return[(i+d[0])/2,(o+d[1])/2,(c+d[2])/2,(u+d[3])/2]}))}))}}}),Pa=ve({disabled:!0,name:"Spin",description:"Make the image spin in a 3D-like way",params:[],fn:_((function(e){var a=e.image,n=Object(s.a)(e.coord,2),t=n[0],r=n[1],i=e.frameCount,o=e.frameIndex,c=e.getSrcPixel,u=a.dimensions[0]/2,l=o/i,d=2*Math.PI*l;return c([Math.round(u+t*Math.cos(d)),r])}))}),Ta=ve({name:"Static",description:"Adds random static to the image",params:[Ue({name:"Type",description:"Whether to apply the party to the foreground or background",defaultValue:"background",options:[{name:"Background",value:"background"},{name:"Foreground",value:"foreground"}]}),he({name:"Strength",description:"Higher number increases the amount of static pixels",defaultValue:25,min:5,max:100,step:5})],fn:_((function(e){var a=e.coord,n=e.getSrcPixel,t=Object(s.a)(e.parameters,2),r=t[0],i=t[1],o=e.random,c=n(a),u=A(c);if("foreground"===r?u:!u)return c;if(u&&"background"===r){var l=Math.ceil(100*o())<i,d=Math.ceil(255*o());return l?[d,d,d,255]:c}var m=Math.ceil(100*o())<i,f=Math.ceil(255*o());return m?[f,f,f,c[3]]:c}))}),Na=n(443),Ba=function(e){var a=e.name,n=e.value,t=e.description,r=e.onChange;return Object(de.jsx)(l.a,{spacing:1,children:Object(de.jsxs)(l.a,{direction:"row",spacing:1,children:[Object(de.jsx)(m.a,{variant:"body2",paddingTop:"0.5rem",children:a}),Object(de.jsx)("span",{style:{paddingTop:"0.5rem"},children:Object(de.jsx)(me,{description:t})}),Object(de.jsx)(Na.a,{"aria-label":a,checked:n,onChange:function(e,a){return r({valid:!0,value:a})}})]})})};var Wa=ve({name:"Transparency",description:"Set certain pixels to be transparent",params:[function(e){return{name:e.name,defaultValue:void 0!==e.defaultValue?{valid:!0,value:e.defaultValue}:{valid:!1},fn:function(a){return Object(de.jsx)(Ba,{name:e.name,value:a.value.valid?a.value.value:void 0,onChange:a.onChange,description:e.description})}}}({name:"Matches are Transparent",description:"If checked, then pixels matching this color will be made transparent. If not checked, non-matching pixels are transparent.",defaultValue:!0}),Ne({name:"Color",defaultValue:W("#000000")}),he({name:"Tolerance",description:'A higher number will mean colors that are "close" to the chosen color will be transparent. (0 - 100)',defaultValue:10,min:0,max:100,step:5})],fn:_((function(e){var a=e.coord,n=e.getSrcPixel,t=Object(s.a)(e.parameters,3),r=t[0],i=t[1],o=t[2],c=n(a),u=100*function(e,a){var n=e[0]-a[0],t=e[1]-a[1],r=e[2]-a[2],i=(e[0]+a[0])/2,o=(2+i/256)*n*n,c=(2+(255-i)/256)*t*t,s=4*r*r;return Math.sqrt(o+c+s)/765}(c,i)<=o;return(r?u:!u)?[c[0],c[1],c[2],0]:c}))}),Aa=ve({name:"Transpose",description:"Move the image left or right, up or down",params:[Ce({name:"X",defaultValue:0}),Ce({name:"Y",defaultValue:0})],fn:_((function(e){var a=Object(s.a)(e.coord,2),n=a[0],t=a[1],r=e.getSrcPixel,i=Object(s.a)(e.parameters,2);return r([n+i[0],t+i[1]])}))}),Ra=Object(pe.a)([ye,Be,Le,qe,Je,Xe,Ze,$e,na,ta,ra,ia,oa,la,fa,ha,pa,ba,va,Oa,wa,Ca,ya,Va,Ma,Fa,ka,Sa,Ia,Pa,Ta,Wa,Aa],Object(je.a)((function(e){return e.name})),Object(be.a)((function(e){return e.disabled}))),Ha=function(e){var a=Ra.find((function(a){return a.name===e}));return L(a,"Could not find matching transform: ".concat(e)),a},Ea=he({name:"Frames per Second",defaultValue:20,min:1,max:60}),Da=function(e){var a=e.computeDisabled,n=e.appState,t=e.onFpsChange,i=e.onComputed,o=r.a.useState({loading:!1,results:[],computeTime:void 0}),c=Object(s.a)(o,2),u=c[0],f=c[1],j=r.a.useState(),b=Object(s.a)(j,2),C=b[0],y=b[1];return Object(de.jsxs)(l.a,{spacing:1,children:[Object(de.jsx)(m.a,{variant:"h5",children:"Create Gif"}),Object(de.jsx)("div",{style:{maxWidth:"300px"},children:Ea.fn({value:{valid:!0,value:n.fps},onChange:function(e){e.valid&&t(e.value)}})}),Object(de.jsx)(h.a,{variant:"contained",sx:{maxWidth:"300px"},endIcon:!u.loading&&n.dirty?Object(de.jsx)(p.a,{children:"priority_high"}):void 0,disabled:a,onClick:Object(g.a)(v.a.mark((function e(){var a;return v.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=n.transforms.map((function(e){return{transform:Ha(e.transformName),params:e.paramsValues.map((function(e){return L(e.valid,"Got non-valid when compute box was clicked"),e.value}))}})),f({loading:!0}),setTimeout(Object(g.a)(v.a.mark((function e(){var t,r,o,c,s;return v.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,L(n.baseImage,"No source image, this button should be disabled!"),t=Date.now(),r=0,o=[],y(0),e.next=8,te({inputDataUrl:n.baseImage,transformList:a,fps:n.fps,onImageFinished:function(){o[r]=Date.now()-t,y((r+=1)/a.length*100)}});case 8:c=e.sent,s=Math.ceil((Date.now()-t)/1e3),f({loading:!1,computeTime:s,results:c.map((function(e,a){return{transformName:n.transforms[a].transformName,gif:e.gif}}))}),o.forEach((function(e,a){ga("send",{hitType:"timing",timingCategory:"computeStep",timingVar:n.transforms[a].transformName,timingValue:e})})),ga("send",{hitType:"timing",timingCategory:"computeTotal",timingVar:n.transforms.length,timingValue:s}),y(void 0),i(),e.next=21;break;case 17:e.prev=17,e.t0=e.catch(0),console.error(e.t0),console.error(e.t0.stack);case 21:case"end":return e.stop()}}),e,null,[[0,17]])}))));case 3:case"end":return e.stop()}}),e)}))),children:u.loading?Object(de.jsx)(x.a,{color:"inherit"}):"Compute"}),void 0!==C&&Object(de.jsx)(O.a,{variant:"determinate",value:C}),!u.loading&&void 0!==u.computeTime&&Object(de.jsxs)(de.Fragment,{children:[Object(de.jsx)(d.a,{}),Object(de.jsxs)(m.a,{variant:"caption",children:["Compute Time: ",u.computeTime," second(s)"]})]}),!u.loading&&u.results.length>0&&Object(de.jsxs)(de.Fragment,{children:[Object(de.jsx)(d.a,{}),Object(de.jsx)(w.a,{container:!0,spacing:2,padding:1,columns:{xs:4,sm:8,md:12},children:u.results.map((function(e,a){var n=e.gif,t=e.transformName;return Object(de.jsxs)(w.a,{item:!0,xs:4,sm:4,md:4,children:[Object(de.jsx)(m.a,{variant:"subtitle2",children:t}),Object(de.jsx)("img",{src:n,alt:"gif-".concat(t,"-").concat(a),style:{maxWidth:"300px",maxHeight:"auto"}})]},"".concat(t,"-").concat(a))}))})]})]})},Ua=n(439),La=function(e){var a=e.selectedTransform,n=e.possibleTransforms,t=e.index,i=e.onSelect,o=e.onRemove,s=e.onMoveLeft,u=e.onMoveRight;return Object(de.jsx)(f.a,{style:{padding:8},elevation:3,children:Object(de.jsxs)(l.a,{spacing:1,children:[Object(de.jsxs)(l.a,{direction:"row",spacing:2,children:[Object(de.jsx)(m.a,{variant:"subtitle1",children:t+1}),Object(de.jsx)(le.a,{title:"Delete transform",children:Object(de.jsx)(Ye.a,{"aria-label":"delete",onClick:o,children:Object(de.jsx)(p.a,{children:"delete"})})}),Object(de.jsx)(le.a,{title:"Move transform left",children:Object(de.jsx)(Ye.a,{"aria-label":"delete",onClick:s,disabled:!s,children:Object(de.jsx)(p.a,{children:"chevron_left"})})}),Object(de.jsx)(le.a,{title:"Move transform right",children:Object(de.jsx)(Ye.a,{"aria-label":"delete",onClick:u,disabled:!u,children:Object(de.jsx)(p.a,{children:"chevron_right"})})})]}),Object(de.jsx)(l.a,{direction:"row",spacing:4,children:Object(de.jsx)(ge.a,{fullWidth:!0,children:Object(de.jsx)(Ua.a,{disableClearable:!0,value:a.transform.name,options:n.map((function(e){return e.name})),onChange:function(e,a){var t=n.find((function(e){return e.name===a}));i({transform:t,paramValues:t.params.map((function(e){return e.defaultValue}))})},renderInput:function(e){return Object(de.jsx)(xe.a,Object(c.a)(Object(c.a)({},e),{},{label:"Transform"}))}})})}),a.transform.description&&Object(de.jsx)(m.a,{variant:"caption",children:a.transform.description}),a.transform.params.length>0&&Object(de.jsx)(m.a,{variant:"subtitle1",children:"Parameters"}),Object(de.jsx)(l.a,{divider:Object(de.jsx)(d.a,{}),spacing:2,children:a.transform.params.map((function(e,n){var t=e.fn({value:a.paramValues[n],onChange:function(e){i(Object(c.a)(Object(c.a)({},a),{},{paramValues:a.paramValues.map((function(a,t){return t===n?e:a}))}))}});return Object(de.jsx)(r.a.Fragment,{children:t},"".concat(a.transform.name,"-").concat(e.name))}))})]})})},qa=function(e){var a=e.currentTransforms,n=e.possibleTransforms,t=e.onTransformsChange;return Object(de.jsxs)(l.a,{spacing:1,children:[Object(de.jsx)(m.a,{variant:"h5",children:"Image Transforms"}),Object(de.jsxs)(w.a,{container:!0,spacing:2,padding:1,columns:{xs:4,sm:8,md:12},rowSpacing:4,children:[a.map((function(e,r){return Object(de.jsx)(w.a,{item:!0,xs:4,sm:4,md:4,children:Object(de.jsx)(La,{index:r,possibleTransforms:n,selectedTransform:{transform:Ha(e.transformName),paramValues:e.paramsValues},onRemove:function(){return t(a.filter((function(e,a){return a!==r})))},onMoveLeft:r>0?function(){return t(a.map((function(e,n){return n===r-1?a[n+1]:r===n?a[r-1]:e})))}:void 0,onMoveRight:r<a.length-1?function(){return t(a.map((function(e,n){return n===r+1?a[n-1]:r===n?a[r+1]:e})))}:void 0,onSelect:function(e){return t(a.map((function(a,n){return r===n?{transformName:e.transform.name,paramsValues:e.paramValues,computedImage:void 0}:{transformName:a.transformName,paramsValues:a.paramsValues,computedImage:void 0}})))}})},"".concat(e.transformName,"-").concat(r))})),Object(de.jsx)(w.a,{item:!0,xs:4,sm:4,md:4,children:Object(de.jsx)(l.a,{spacing:4,children:Object(de.jsx)(h.a,{fullWidth:!1,variant:"contained",startIcon:Object(de.jsx)(p.a,{children:"add"}),onClick:function(){return t([].concat(Object(I.a)(a),[{transformName:n[0].name,paramsValues:n[0].params.map((function(e){return e.defaultValue}))}]))},children:"New Transform"})})})]})]})},Ga=n(441),_a=n(140),za=function(e){var a=e.state,n=e.onImport,t=r.a.useState(),i=Object(s.a)(t,2),o=i[0],c=i[1],u=r.a.useState(!1),d=Object(s.a)(u,2),f=d[0],j=d[1],b=function(){j(!0),setTimeout((function(){return j(!1)}),2e3)};return Object(de.jsxs)(l.a,{spacing:3,children:[Object(de.jsx)(m.a,{variant:"h5",children:"Import/Export"}),Object(de.jsxs)(h.a,{startIcon:Object(de.jsx)(p.a,{children:"file_upload"}),sx:{maxWidth:"300px"},variant:"contained",onClick:function(){var e=_a.compressToBase64(JSON.stringify(a));navigator.clipboard.writeText(e),c("Copied to clipboard"),setTimeout((function(){return c(void 0)}),2e3)},children:["Export to clipboard ",Object(de.jsx)("br",{}),"(With Source Image)"]}),Object(de.jsx)(h.a,{startIcon:Object(de.jsx)(p.a,{children:"file_download"}),sx:{maxWidth:"300px"},variant:"contained",onClick:Object(g.a)(v.a.mark((function e(){var a,t;return v.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,navigator.clipboard.readText();case 3:if(a=e.sent){e.next=7;break}return b(),e.abrupt("return");case 7:if(t=JSON.parse(_a.decompressFromBase64(a)),Array.isArray(t.transforms)){e.next=11;break}return b(),e.abrupt("return");case 11:n(t),j(!1),e.next=19;break;case 15:e.prev=15,e.t0=e.catch(0),console.error(e.t0),b();case 19:case"end":return e.stop()}}),e,null,[[0,15]])}))),children:"Import from clipboard"}),o&&Object(de.jsx)(Ga.a,{severity:"info",sx:{maxWidth:"300px"},children:o}),f&&Object(de.jsx)(Ga.a,{severity:"error",sx:{maxWidth:"300px"},children:"Error importing from clipboard"})]})},Ja="partymoji-state",Xa=function(){try{window.localStorage.removeItem(Ja)}catch(e){console.error("Error clearing state from local storage",e.stack||e)}},Ya=!1,Ka={dirty:!1,transforms:[],baseImage:void 0,fps:20},Qa=function(){var e=r.a.useState(Ka),a=Object(s.a)(e,2),n=a[0],t=a[1];r.a.useEffect((function(){var e=function(){try{var e=window.localStorage.getItem(Ja);if(e){var a=JSON.parse(e);if(Array.isArray(a.transforms))return a}}catch(n){console.error("Error loading state from local storage",n.stack||n)}}();e&&t(Object(c.a)(Object(c.a)({},e),{},{dirty:!0}))}),[]);var i=function(e){!function(e){try{window.localStorage.setItem(Ja,JSON.stringify(e))}catch(a){console.error("Error saving state to local storage",a.stack||a)}}(e),t(e)};var o=!n.baseImage||0===n.transforms.length||!n.dirty||n.transforms.some((function(e){return Ha(e.transformName).params.length>0&&e.paramsValues.every((function(e){return!1===e.valid}))}));return Object(de.jsxs)(de.Fragment,{children:[Object(de.jsx)(j.a,{}),Object(de.jsx)(u.a,{children:Object(de.jsxs)(l.a,{spacing:4,justifyContent:"space-evenly",divider:Object(de.jsx)(d.a,{}),children:[Object(de.jsx)(m.a,{variant:"h2",pt:4,children:"Partymoji"}),Object(de.jsxs)(l.a,{spacing:4,divider:Object(de.jsx)(d.a,{}),children:[Ya,Object(de.jsx)(f.a,{style:{padding:16},children:Object(de.jsxs)(l.a,{spacing:1,children:[Object(de.jsx)(m.a,{variant:"h5",children:"Source Image"}),Object(de.jsx)(We,{name:"Choose a source image",currentImageUrl:n.baseImage,onChange:function(e){i(Object(c.a)(Object(c.a)({},n),{},{baseImage:e,dirty:!0}))}})]})}),Object(de.jsx)(f.a,{style:{padding:16},children:Object(de.jsx)(qa,{currentTransforms:n.transforms,possibleTransforms:Ra,onTransformsChange:function(e){return i(Object(c.a)(Object(c.a)({},n),{},{dirty:!0,transforms:e}))}})}),Object(de.jsx)(f.a,{style:{padding:16},children:Object(de.jsx)(Da,{computeDisabled:o,appState:n,onFpsChange:function(e){return i(Object(c.a)(Object(c.a)({},n),{},{fps:e,dirty:!0}))},onComputed:function(){return i(Object(c.a)(Object(c.a)({},n),{},{dirty:!1}))}})}),Object(de.jsx)(f.a,{style:{padding:16},children:Object(de.jsx)(za,{state:n,onImport:function(e){return i(Object(c.a)(Object(c.a)({},e),{},{dirty:!0}))}})}),Object(de.jsx)(f.a,{style:{padding:16},children:Object(de.jsxs)(l.a,{spacing:3,children:[Object(de.jsx)(m.a,{variant:"h5",children:"Clear State"}),Object(de.jsx)(m.a,{variant:"body1",children:"Clicking this button will clear the source image and all transforms"}),Object(de.jsx)(h.a,{startIcon:Object(de.jsx)(p.a,{children:"clear"}),sx:{maxWidth:"300px"},variant:"contained",onClick:function(){Xa(),t(Ka)},children:"Clear State"})]})}),Ya,Object(de.jsx)("a",{href:"https://github.com/MikeyBurkman/partymoji",target:"_blank",rel:"noreferrer",children:Object(de.jsx)("img",{src:"https://upload.wikimedia.org/wikipedia/commons/9/91/Octicons-mark-github.svg",width:64,height:64,alt:"Github Link"})})]})]})})]})},Za=n(97),$a=n(98),en=n(193),an=n(192),nn=function(e){Object(en.a)(n,e);var a=Object(an.a)(n);function n(){var e;Object(Za.a)(this,n);for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return(e=a.call.apply(a,[this].concat(r))).state={hasError:!1},e}return Object($a.a)(n,[{key:"componentDidCatch",value:function(e,a){console.error("Uncaught error:",e,a)}},{key:"render",value:function(){return this.state.hasError?Object(de.jsxs)(l.a,{spacing:1,children:[Object(de.jsx)(m.a,{variant:"h2",children:"Oh no!"}),Object(de.jsx)(m.a,{variant:"body1",children:"There seems to have been an issue"}),Object(de.jsx)(m.a,{variant:"body2",children:"If refreshing the page doesn't fix things, click the below button to clear local storage"}),Object(de.jsx)(h.a,{variant:"contained",sx:{maxWidth:"300px"},endIcon:Object(de.jsx)(p.a,{children:"priority_high"}),startIcon:Object(de.jsx)(p.a,{children:"priority_high"}),onClick:this.props.onClearLocalStorage,children:"Clear storage and reload"})]}):this.props.children}}],[{key:"getDerivedStateFromError",value:function(e){return console.error(e),{hasError:!0}}}]),n}(r.a.Component);o.a.render(Object(de.jsx)(r.a.StrictMode,{children:Object(de.jsx)(nn,{onClearLocalStorage:function(){Xa(),window.location.reload()},children:Object(de.jsx)(Qa,{})})}),document.getElementById("root"))}},[[377,1,2]]]);
  //# sourceMappingURL=main.45c9eec8.chunk.js.map