From 9545e8378ffa8491401e2710b44367790b97995c Mon Sep 17 00:00:00 2001 From: satopian Date: Wed, 16 Oct 2024 18:32:07 +0900 Subject: [PATCH] chickenpaint.js --- petitnote/app/chickenpaint/js/chickenpaint.js | 1145 +++++++++-------- .../app/chickenpaint/js/chickenpaint.min.js | 1145 +++++++++-------- 2 files changed, 1146 insertions(+), 1144 deletions(-) diff --git a/petitnote/app/chickenpaint/js/chickenpaint.js b/petitnote/app/chickenpaint/js/chickenpaint.js index c6d8302..e1321f1 100644 --- a/petitnote/app/chickenpaint/js/chickenpaint.js +++ b/petitnote/app/chickenpaint/js/chickenpaint.js @@ -48,14 +48,14 @@ Dual licensed under the MIT and GPL licenses. http://benalman.com/about/license/ */ -!function(){function X(a){return a&&a.__esModule?a.default:a}function ld(a,c,d,b){Object.defineProperty(a,c,{get:d,set:b,enumerable:!0,configurable:!0})}function Ca(a){for(var c in Ca.DEFAULTS)Ca.DEFAULTS.hasOwnProperty(c)&&(this[c]=Ca.DEFAULTS[c]);for(c in a)a.hasOwnProperty(c)&&(this[c]=a[c])}function Ha(a,c,d,b){this.left=a;this.top=c;this.right=d;this.bottom=b}function xd(a,c){this.width=0|a;this.height=0|c}function Yc(a,c){var d=document.createElement("canvas");return d.width=a,d.height=c,d} -function kf(a,c){return document.createElement("canvas").getContext("2d").createImageData(a,c)}function H(a,c){"number"==typeof a?(xd.call(this,a,c),this.imageData=kf(this.width,this.height)):(xd.call(this,a.width,a.height),this.imageData=a);this.data=this.imageData.data}function hg(a,c,d,b){var k,p=0,h=[0,0,0,0];var e=0;for(k=0;km.alpha||m.mask)){let r=m;(m=new de(c,d)).blendMode=Array.isArray(r)?S.LM_NORMAL:r.blendMode;m.alpha=100;m.image=k();m.addChildren(r)}}else(m=new de(c,d,{image:k(),blendMode:S.LM_NORMAL,alpha:100,getEffectiveMask:()=> +!function(){function X(a){return a&&a.__esModule?a.default:a}function md(a,c,d,b){Object.defineProperty(a,c,{get:d,set:b,enumerable:!0,configurable:!0})}function Ca(a){for(var c in Ca.DEFAULTS)Ca.DEFAULTS.hasOwnProperty(c)&&(this[c]=Ca.DEFAULTS[c]);for(c in a)a.hasOwnProperty(c)&&(this[c]=a[c])}function Ha(a,c,d,b){this.left=a;this.top=c;this.right=d;this.bottom=b}function yd(a,c){this.width=0|a;this.height=0|c}function Zc(a,c){var d=document.createElement("canvas");return d.width=a,d.height=c,d} +function lf(a,c){return document.createElement("canvas").getContext("2d").createImageData(a,c)}function H(a,c){"number"==typeof a?(yd.call(this,a,c),this.imageData=lf(this.width,this.height)):(yd.call(this,a.width,a.height),this.imageData=a);this.data=this.imageData.data}function ig(a,c,d,b){var k,p=0,h=[0,0,0,0];var e=0;for(k=0;km.alpha||m.mask)){let r=m;(m=new ee(c,d)).blendMode=Array.isArray(r)?S.LM_NORMAL:r.blendMode;m.alpha=100;m.image=k();m.addChildren(r)}}else(m=new ee(c,d,{image:k(),blendMode:S.LM_NORMAL,alpha:100,getEffectiveMask:()=> null,visible:!0})).image.clearAll(0);l=[]}};this.resetTree=function(){m&&(function u(r){if(r.isGroup)for(let v of(r.image&&l.push(r.image),r.layers))u(v)}(m),m=null,g.clear())};this.layerPropertyChanged=function(n,r){let u=g.get(n);u&&u.visible==n.visible&&u.alpha==n.alpha&&null==u.mask==(null==n.getEffectiveMask())&&u.blendMode==S.LM_PASSTHROUGH==(n.blendMode==S.LM_PASSTHROUGH)&&"clip"!==r?(u.blendMode=n.blendMode,e(u,new Ha(0,0,c,d))):this.resetTree()};this.blendTree=function(){return function u(r){if(!r|| !r.isGroup)return r;let v=r.dirtyRect;var x=!0,C=!0;if(r.blendMode==S.LM_PASSTHROUGH&&r.parent&&v.union(r.parent.dirtyRect),v.isEmpty())return r;if(r.blendMode==S.LM_PASSTHROUGH&&r.parent){x=!1;var K=r.image;var I=r.parent.image;v.getWidth()==K.width&&v.getHeight()==K.height?K.copyPixelsFrom(I):S.replaceOntoFusionWithOpaqueLayer(K,I,100,v)}for(K=0;KC.alpha?C.mask?S.replaceAlphaOntoFusionWithTransparentLayerMasked(r.image,C.image,C.alpha,v,C.mask):S.replaceAlphaOntoFusionWithTransparentLayer(r.image,C.image,C.alpha,v):C.mask?S.replaceAlphaOntoFusionWithOpaqueLayerMasked(r.image,C.image, @@ -66,176 +66,176 @@ Fa;Fa++)(ra=((ea=Y+.25*Fa-v)*G-(ja=T+.25*V-v)*r)*I)*ra+(Na=ja*G+ea*r)*Na<=x&&(U+ g);break;case Ca.TIP_SQUARE_PIXEL:!function(n,r){let u=Math.ceil(r.curSize),v=u/2;var x=r.curSize*Math.sin(Math.PI/4);let C=x/2/(1+10*r.curSqueeze);x/=2;let K=Math.cos(r.curAngle);r=Math.sin(r.curAngle);let I=0;for(let G=0;GL&&(L+=G.width);0>U&&(U+=G.height);for(let ja=0;jaXa.invalidateLayerRect(N,P));let F=!1;if(da)for(let N of(Fb.union(P),D))N instanceof Ma&&(Va.add(N),F=!0);fa&&(La.union(P),D.forEach(N=>{ec.add(N);Ia&&Ia.layer==N&&Ia.invalidateRect(P)}),F=!0);F&&(eb&&(clearTimeout(eb),eb=null),Hc||(eb=setTimeout(e,1E3)));k(P)}function l(D,P){m(D,P,!Ta,Ta)}function g(){return Ta?pa.mask:pa.image}function n(){if(!Ba.isEmpty()){if(Ta){var D=pa.mask;hb.brushMode==Ca.BRUSH_MODE_ERASE? +eb&&(clearTimeout(eb),eb=null)}function m(D,P,da,fa){Array.isArray(D)||(D=[D]);D.forEach(N=>Xa.invalidateLayerRect(N,P));let F=!1;if(da)for(let N of(Fb.union(P),D))N instanceof Ma&&(Va.add(N),F=!0);fa&&(La.union(P),D.forEach(N=>{ec.add(N);Ia&&Ia.layer==N&&Ia.invalidateRect(P)}),F=!0);F&&(eb&&(clearTimeout(eb),eb=null),Ic||(eb=setTimeout(e,1E3)));k(P)}function l(D,P){m(D,P,!Ta,Ta)}function g(){return Ta?pa.mask:pa.image}function n(){if(!Ba.isEmpty()){if(Ta){var D=pa.mask;hb.brushMode==Ca.BRUSH_MODE_ERASE? Oa[Ca.BRUSH_MODE_PAINT].mergeOntoMask(D,Ja,4278190080):Oa[hb.brushMode].mergeOntoMask(D,Ja,255&Yb)}else{D=pa.image;let P=pa.getLockAlpha();hb.brushMode==Ca.BRUSH_MODE_ERASE&&P?Oa[Ca.BRUSH_MODE_PAINT].mergeOntoImage(D,Lb,16777215):Oa[hb.brushMode].mergeOntoImage(D,Lb,Yb);P&&D.copyAlphaFrom(Lb,Ba)}Ba.makeEmpty()}}function r(){pa instanceof Ma&&!Fb.isEmpty()&&(Lb.copyBitmapRect(pa.image,Fb.left,Fb.top,Fb),Fb.makeEmpty())}function u(){pa.mask&&!La.isEmpty()&&(Ja.copyBitmapRect(pa.mask,La.left,La.top, La),La.makeEmpty())}function v(){Ta?u():r()}function x(){let D=ha.getBounds();Fb.set(D);La.set(D)}function C(D){ha.setHasUnsavedChanges(!0);0N.getMemoryUsed()).reduce(Ce,0)};this.redo()}function ra(D,P,da){let fa=D.parent,F=D.parent.indexOf(D),N=Ta,ca=fa.layers[fa.indexOf(D)+1],ka=P.layers[da],xa=D instanceof Ma&&D.clip,za=!!xa&&D.getClippingBase(),cb=0,gb=0;if(D instanceof Ma&&!D.clip)for(var Da=F+1;DaN.getMemoryUsed()).reduce(De,0)};this.redo()}function ra(D,P,da){let fa=D.parent,F=D.parent.indexOf(D),N=Ta,ca=fa.layers[fa.indexOf(D)+1],ka=P.layers[da],xa=D instanceof Ma&&D.clip,za=!!xa&&D.getClippingBase(),cb=0,gb=0;if(D instanceof Ma&&!D.clip)for(var Da=F+1;Daca["get"+da]());this.to=N;this.redo()};return fa.prototype=Object.create(yc.prototype),fa.prototype.constructor=fa,fa.prototype.undo=function(){this.layers.forEach((F,N)=> +(D.clip&&D.getClippingBase()!=za&&(D.clip=!1),ka instanceof Ma&&ka.clip&&(D.clip=!0));for(Vb=0;Vbca["get"+da]());this.to=N;this.redo()};return fa.prototype=Object.create(zc.prototype),fa.prototype.constructor=fa,fa.prototype.undo=function(){this.layers.forEach((F,N)=> F["set"+da](this.from[N]));this.layers.forEach(F=>h(F,D,!P))},fa.prototype.redo=function(){this.layers.forEach(F=>F["set"+da](this.to));this.layers.forEach(F=>h(F,D,!P))},fa.prototype.merge=function(F){var N;if(N=F instanceof fa)a:{N=this.layers;var ca=F.layers;if(N.length!=ca.length)N=!1;else{for(let ka=0;kaP.addLayer(F));this.addLayerObject(D,P)};this.isRemoveLayerAllowed=function(){return pa instanceof Ma?mb.getLinearizedLayerList(!1).some(D=>D instanceof Ma&&D!=pa):pa instanceof ob&&mb.getLinearizedLayerList(!1).some(D=>D instanceof Ma&&!D.hasAncestor(pa))};this.removeLayer=function(){return!!this.isRemoveLayerAllowed()&&(C(new T(pa)),!0)};this.duplicateLayer=function(){C(new U(pa))};this.isMergeDownAllowed=function(){let D=pa.parent.indexOf(pa);return 0S.LM_LAST_CHIBIPAINT)throw Error("Bad layer type during multiply upgrade");F.blendMode===S.LM_MULTIPLY&&(da=fa)}if(-1!==da){fa=new H(this.width,this.height);let N=F=!0,ca=this.getBounds();fa.clearAll(ca,16777215);for(let ka=0;ka<=da;ka++){let xa=P[ka];N||(F=F&&fa.hasAlphaInRect(ca));xa.blendMode===S.LM_MULTIPLY&&("bake"===D?!F&&0F){let N=Tb,ca=vb,ka=Rb;fa=(F-.001)/fa;for(F=fa;1>=F;F+=fa)N=F*D+(1-F)*Tb,ca=F*P+(1-F)*vb,ka=F*da+(1-F)*Rb,this.paintDab(N,ca,ka);Tb=N;vb=ca;Rb=ka}}};this.endStroke=function(){null!=hb&&(n(),Oa[hb.brushMode].endStroke(),lb.clipTo(this.getBounds()),lb.isEmpty()||(C(new K),v()),d(!1))};this.hasAlpha=function(){return Nb.hasAlpha()};this.getFlatPNG=function(D){return this.fusionLayers(),Nb.getAsPNG(D)};this.getFlatPNGBuffer=function(D){return this.fusionLayers(), -Nb.getAsPNGBuffer(D)};this.isSimpleDrawing=function(){return 1==mb.layers.length&&mb.layers[0]instanceof Ma&&!mb.layers[0].mask&&100==mb.layers[0].getEffectiveAlpha()};K.prototype=Object.create(yc.prototype);K.prototype.constructor=K;I.prototype=Object.create(yc.prototype);I.prototype.constructor=I;G.prototype=Object.create(yc.prototype);G.prototype.constructor=G;L.prototype=Object.create(yc.prototype);L.prototype.constructor=L;U.prototype=Object.create(yc.prototype);U.prototype.constructor=U;T.prototype= -Object.create(yc.prototype);T.prototype.constructor=T;Y.prototype=Object.create(yc.prototype);Y.prototype.constructor=Y;ea.prototype=Object.create(yc.prototype);ea.prototype.constructor=ea;ja.prototype=Object.create(yc.prototype);ja.prototype.constructor=ja;ra.prototype=Object.create(yc.prototype);ra.prototype.constructor=ra;let Qc=Na("alpha",!0),Rc=Na("blendMode",!0),A=Na("visible",!0),ua=Na("clip",!0),tc=Na("maskVisible",!0),Mc=Na("name",!1),Xb=Na("lockAlpha",!1),Zc=Na("maskLinked",!1);V.prototype= -Object.create(yc.prototype);V.prototype.constructor=V;class va extends yc{undo(){let D=[];this.dstRect.isEmpty()||D.push(this.dstRect);this.erasesSourceRect&&(D.push(this.srcRect),D=Ha.union(D));this.movingLayers.forEach(P=>{this.hasFullUndo?D.forEach(da=>{P.moveImage&&P.layer.image.copyBitmapRect(P.imageUndo,da.left,da.top,da);P.moveMask&&P.layer.mask.copyBitmapRect(P.maskUndo,da.left,da.top,da)}):(P.moveImage&&P.imageRect.forEach((da,fa)=>{P.layer.image.copyBitmapRect(da,fa.left,fa.top,da.getBounds())}), -P.moveMask&&P.maskRect.forEach((da,fa)=>{P.layer.mask.copyBitmapRect(da,fa.left,fa.top,da.getBounds())}))});m(this.movingLayers.map(P=>P.layer),D.reduce((P,da)=>P.getUnion(da),new Ha(0,0,0,0)),!0,!0);this.dstRect.makeEmpty();ha.setSelection(this.fromSelection);ha.setActiveLayer(this.layer,this.fromMaskMode);b()}getMemoryUsed(D,P){return this.movingLayers.map(function(da){return[da.imageUndo,da.maskUndo,da.imageRect,da.maskRect].map(fa=>fa?fa.getMemorySize():0).reduce(Ce,0)}).reduce(Ce,0)}buildFullUndo(){this.hasFullUndo|| +Nb.getAsPNGBuffer(D)};this.isSimpleDrawing=function(){return 1==mb.layers.length&&mb.layers[0]instanceof Ma&&!mb.layers[0].mask&&100==mb.layers[0].getEffectiveAlpha()};K.prototype=Object.create(zc.prototype);K.prototype.constructor=K;I.prototype=Object.create(zc.prototype);I.prototype.constructor=I;G.prototype=Object.create(zc.prototype);G.prototype.constructor=G;L.prototype=Object.create(zc.prototype);L.prototype.constructor=L;U.prototype=Object.create(zc.prototype);U.prototype.constructor=U;T.prototype= +Object.create(zc.prototype);T.prototype.constructor=T;Y.prototype=Object.create(zc.prototype);Y.prototype.constructor=Y;ea.prototype=Object.create(zc.prototype);ea.prototype.constructor=ea;ja.prototype=Object.create(zc.prototype);ja.prototype.constructor=ja;ra.prototype=Object.create(zc.prototype);ra.prototype.constructor=ra;let Rc=Na("alpha",!0),Sc=Na("blendMode",!0),A=Na("visible",!0),ua=Na("clip",!0),uc=Na("maskVisible",!0),Nc=Na("name",!1),Xb=Na("lockAlpha",!1),$c=Na("maskLinked",!1);V.prototype= +Object.create(zc.prototype);V.prototype.constructor=V;class va extends zc{undo(){let D=[];this.dstRect.isEmpty()||D.push(this.dstRect);this.erasesSourceRect&&(D.push(this.srcRect),D=Ha.union(D));this.movingLayers.forEach(P=>{this.hasFullUndo?D.forEach(da=>{P.moveImage&&P.layer.image.copyBitmapRect(P.imageUndo,da.left,da.top,da);P.moveMask&&P.layer.mask.copyBitmapRect(P.maskUndo,da.left,da.top,da)}):(P.moveImage&&P.imageRect.forEach((da,fa)=>{P.layer.image.copyBitmapRect(da,fa.left,fa.top,da.getBounds())}), +P.moveMask&&P.maskRect.forEach((da,fa)=>{P.layer.mask.copyBitmapRect(da,fa.left,fa.top,da.getBounds())}))});m(this.movingLayers.map(P=>P.layer),D.reduce((P,da)=>P.getUnion(da),new Ha(0,0,0,0)),!0,!0);this.dstRect.makeEmpty();ha.setSelection(this.fromSelection);ha.setActiveLayer(this.layer,this.fromMaskMode);b()}getMemoryUsed(D,P){return this.movingLayers.map(function(da){return[da.imageUndo,da.maskUndo,da.imageRect,da.maskRect].map(fa=>fa?fa.getMemorySize():0).reduce(De,0)}).reduce(De,0)}buildFullUndo(){this.hasFullUndo|| (this.movingLayers.forEach(function(D){D.moveImage&&(D.imageUndo=D.layer.image.clone());D.moveMask&&(D.maskUndo=D.layer.mask.clone());D.imageRect.clear();D.maskRect.clear()}),this.hasFullUndo=!0)}compact(){if(this.hasFullUndo){let D=[];this.dstRect.isEmpty()||D.push(this.dstRect);this.erasesSourceRect&&(D.push(this.srcRect),D=Ha.union(D));this.movingLayers.forEach(P=>{P.imageRect.clear();P.maskRect.clear();D.forEach(da=>{P.moveImage&&P.imageRect.set(da,P.imageUndo.cloneRect(da));P.moveMask&&P.maskRect.set(da, P.maskUndo.cloneRect(da))});P.imageUndo=null;P.maskUndo=null});this.hasFullUndo=!1}}constructor(){super();this.layer=pa;this.fromSelection=ha.getSelection();this.fromMaskMode=Ta;this.movingWholeLayer=this.fromSelection.isEmpty();this.movingImage=!Ta||this.movingWholeLayer&&this.layer.maskLinked;this.movingMask=Ta||this.movingWholeLayer&&this.layer.maskLinked;this.erasesSourceRect=this.hasFullUndo=!1;this.dstRect=new Ha(0,0,0,0);this.movingLayers=[{layer:this.layer,moveImage:this.layer instanceof Ma&& this.movingImage,moveMask:null!==this.layer.mask&&this.movingMask,imageRect:new Map,maskRect:new Map}];this.layer instanceof ob&&this.movingImage&&this.movingWholeLayer&&(this.movingLayers=this.movingLayers.concat(this.layer.getLinearizedLayerList(!1).map(fa=>({layer:fa,moveImage:fa instanceof Ma,moveMask:null!==fa.mask&&fa.maskLinked,imageRect:new Map,maskRect:new Map}))));let D=new Ha(0,0,0,0);if(this.movingWholeLayer){this.srcRect=ha.getBounds();for(var P=0;P{if(D.moveImage){var P=Yc(this.srcRect.getWidth(),this.srcRect.getHeight());P.getContext("2d").putImageData(D.layer.image.getImageData(),-this.srcRect.left,-this.srcRect.top,this.srcRect.left,this.srcRect.top,this.srcRect.getWidth(),this.srcRect.getHeight());D.imageSourceCanvas=P}D.moveMask&&(P=Yc(this.srcRect.getWidth(),this.srcRect.getHeight()),P.getContext("2d").putImageData(D.layer.mask.getImageData(this.srcRect.left,this.srcRect.top,this.srcRect.getWidth(), -this.srcRect.getHeight()),0,0),D.maskSourceCanvas=P)}),this.composeCanvas=Yc(ha.width,ha.height),this.composeCanvasContext=this.composeCanvas.getContext("2d",{willReadFrequently:!0}),nf(this.composeCanvasContext,"smooth"==this.interpolation),this.junk=this.composeCanvasContext.getImageData(0,0,1,1))}redo(){this.buildFullUndo();var D=this.dstRect.clone();let P=this.srcRect.toPoints();this.affineTransform.transformPoints(P);this.dstRect.set(Ha.createBoundingBox(P).roundContain().clipTo(ha.getBounds())); +(super.buildFullUndo(),this.movingLayers.forEach(D=>{if(D.moveImage){var P=Zc(this.srcRect.getWidth(),this.srcRect.getHeight());P.getContext("2d").putImageData(D.layer.image.getImageData(),-this.srcRect.left,-this.srcRect.top,this.srcRect.left,this.srcRect.top,this.srcRect.getWidth(),this.srcRect.getHeight());D.imageSourceCanvas=P}D.moveMask&&(P=Zc(this.srcRect.getWidth(),this.srcRect.getHeight()),P.getContext("2d").putImageData(D.layer.mask.getImageData(this.srcRect.left,this.srcRect.top,this.srcRect.getWidth(), +this.srcRect.getHeight()),0,0),D.maskSourceCanvas=P)}),this.composeCanvas=Zc(ha.width,ha.height),this.composeCanvasContext=this.composeCanvas.getContext("2d",{willReadFrequently:!0}),of(this.composeCanvasContext,"smooth"==this.interpolation),this.junk=this.composeCanvasContext.getImageData(0,0,1,1))}redo(){this.buildFullUndo();var D=this.dstRect.clone();let P=this.srcRect.toPoints();this.affineTransform.transformPoints(P);this.dstRect.set(Ha.createBoundingBox(P).roundContain().clipTo(ha.getBounds())); let da=Ha.subtract(this.dstRect,this.srcRect),fa=Ha.subtract(D.isEmpty()?this.srcRect:this.srcRect.getIntersection(D),this.dstRect),F=this.srcRect.getIntersection(this.dstRect),N=Ha.subtract(D,[this.dstRect,this.srcRect]);D=this.srcRect.getUnion(this.dstRect).getUnion(D);(this.movingLayers.forEach(ca=>{if(fa.forEach(ka=>{ca.moveImage&&ca.layer.image.clearRect(ka,16777215);ca.moveMask&&(this.movingWholeLayer?ca.layer.mask.clearRect(ka,255):ca.layer.mask.clearRect(ka,0))}),!this.dstRect.isEmpty()){if(ca.moveImage){let ka= ca.imageUndo.getImageData();da.forEach(xa=>{this.composeCanvasContext.putImageData(ka,0,0,xa.left,xa.top,xa.getWidth(),xa.getHeight())});this.composeCanvasContext.clearRect(F.left,F.top,F.getWidth(),F.getHeight());this.composeCanvasContext.save();this.composeCanvasContext.setTransform(this.affineTransform.m[0],this.affineTransform.m[1],this.affineTransform.m[2],this.affineTransform.m[3],this.affineTransform.m[4],this.affineTransform.m[5]);this.composeCanvasContext.drawImage(ca.imageSourceCanvas,this.srcRect.left, this.srcRect.top);this.composeCanvasContext.restore();ca.layer.image.copyBitmapRect(new H(this.composeCanvasContext.getImageData(this.dstRect.left,this.dstRect.top,this.dstRect.getWidth(),this.dstRect.getHeight())),this.dstRect.left,this.dstRect.top,new Ha(0,0,this.dstRect.getWidth(),this.dstRect.getHeight()))}ca.moveMask&&(da.forEach(ka=>{this.composeCanvasContext.putImageData(ca.layer.mask.getImageData(ka.left,ka.top,ka.getWidth(),ka.getHeight()),ka.left,ka.top)}),this.movingWholeLayer?this.composeCanvasContext.fillStyle= "#FFF":this.composeCanvasContext.fillStyle="#000",this.composeCanvasContext.fillRect(F.left,F.top,F.getWidth(),F.getHeight()),this.composeCanvasContext.save(),this.composeCanvasContext.setTransform(this.affineTransform.m[0],this.affineTransform.m[1],this.affineTransform.m[2],this.affineTransform.m[3],this.affineTransform.m[4],this.affineTransform.m[5]),this.composeCanvasContext.drawImage(ca.maskSourceCanvas,this.srcRect.left,this.srcRect.top),this.composeCanvasContext.restore(),ca.layer.mask.pasteImageData(this.composeCanvasContext.getImageData(this.dstRect.left, this.dstRect.top,this.dstRect.getWidth(),this.dstRect.getHeight()),this.dstRect.left,this.dstRect.top))}N.forEach(ka=>{ca.moveImage&&ca.layer.image.copyBitmapRect(ca.imageUndo,ka.left,ka.top,ka);ca.moveMask&&ca.layer.mask.copyBitmapRect(ca.maskUndo,ka.left,ka.top,ka)})}),m(this.movingLayers.map(ca=>ca.layer),D,!0,!0),this.fromSelection.isEmpty())||(D=this.fromSelection.toPoints(),this.affineTransform.transformPoints(D),(D=Ha.createBoundingBox(D)).roundNearest(),ha.setSelection(D),b());ha.setActiveLayer(this.layer, -this.fromMaskMode)}amend(D){this.hasFullUndo||this.undo();this.affineTransform=D.clone();this.redo()}setInterpolation(D){D!=this.interpolation&&(this.interpolation=D,this.composeCanvasContext&&nf(this.composeCanvasContext,"smooth"==this.interpolation),this.undo(),this.redo())}compact(){super.compact();this.composeCanvasContext=this.composeCanvas=null;this.movingLayers.forEach(D=>D.imageSourceCanvas=null)}getMemoryUsed(D,P){D=super.getMemoryUsed(D,P);return D+=og(this.composeCanvas),D+=this.movingLayers.map(da=> -og(da.imageSourceCanvas)).reduce(Ce,0)}getTransform(){return this.affineTransform.clone()}getInitialTransformRect(){return this.srcRect.clone()}getInitialSelectionRect(){return this.fromSelection.clone()}constructor(D,P){super();this.erasesSourceRect=!0;this.affineTransform=D.clone();this.interpolation=P||"smooth";this.composeCanvasContext=this.composeCanvas=null}}class uc extends va{redo(){var D=this.dstRect.clone();let P,da,fa=D.clone(),F=null;(this.buildFullUndo(),this.dstRect.set(this.srcRect), +this.fromMaskMode)}amend(D){this.hasFullUndo||this.undo();this.affineTransform=D.clone();this.redo()}setInterpolation(D){D!=this.interpolation&&(this.interpolation=D,this.composeCanvasContext&&of(this.composeCanvasContext,"smooth"==this.interpolation),this.undo(),this.redo())}compact(){super.compact();this.composeCanvasContext=this.composeCanvas=null;this.movingLayers.forEach(D=>D.imageSourceCanvas=null)}getMemoryUsed(D,P){D=super.getMemoryUsed(D,P);return D+=pg(this.composeCanvas),D+=this.movingLayers.map(da=> +pg(da.imageSourceCanvas)).reduce(De,0)}getTransform(){return this.affineTransform.clone()}getInitialTransformRect(){return this.srcRect.clone()}getInitialSelectionRect(){return this.fromSelection.clone()}constructor(D,P){super();this.erasesSourceRect=!0;this.affineTransform=D.clone();this.interpolation=P||"smooth";this.composeCanvasContext=this.composeCanvas=null}}class vc extends va{redo(){var D=this.dstRect.clone();let P,da,fa=D.clone(),F=null;(this.buildFullUndo(),this.dstRect.set(this.srcRect), this.dstRect.translate(this.offsetX,this.offsetY),P=this.dstRect.clone(),this.dstRect.clipTo(ha.getBounds()),this.erasesSourceRect?(F=D.isEmpty()?this.srcRect:this.srcRect.getIntersection(D),fa.union(F),da=D.subtract(this.srcRect)):da=[D],this.movingLayers.forEach(N=>{F&&(N.moveImage&&N.layer.image.clearRect(F,16777215),N.moveMask&&N.layer.mask.clearRect(F,this.movingWholeLayer?255:0));da.forEach(function(ca){N.moveImage&&N.layer.image.copyBitmapRect(N.imageUndo,ca.left,ca.top,ca);N.moveMask&&N.layer.mask.copyBitmapRect(N.maskUndo, ca.left,ca.top,ca)});N.moveImage&&S.normalFuseImageOntoImageAtPosition(N.layer.image,N.imageUndo,P.left,P.top,this.srcRect);N.moveMask&&N.layer.mask.copyBitmapRect(N.maskUndo,P.left,P.top,this.srcRect)}),fa.union(this.dstRect),m(this.movingLayers.map(N=>N.layer),fa,!0,!0),this.fromSelection.isEmpty())||(D=this.fromSelection.clone(),D.translate(this.offsetX,this.offsetY),ha.setSelection(D),b())}amend(D,P){this.hasFullUndo||this.undo();this.offsetX+=D;this.offsetY+=P;this.redo()}constructor(D,P,da){super(); -this.offsetX=D;this.offsetY=P;this.erasesSourceRect=!da}}Fa.prototype=Object.create(yc.prototype);Fa.prototype.constructor=Fa;qa.prototype=Object.create(yc.prototype);qa.prototype.constructor=qa;Oa=[Md,xh,yh,zh,ee,Ah,Bh,Ch].map(D=>new D(la,Ba));this.width=a;this.height=c}function wb(a,c,d){this.data=a;this.eof=!1;this.start=void 0===c?0:c;this.end=void 0===d?a.length:d;this.pos=this.start}function Nd(a){for(var c=a.length;0<=--c;)a[c]=0}function of(a,c,d,b,k){this.static_tree=a;this.extra_bits=c; -this.extra_base=d;this.elems=b;this.max_length=k;this.has_stree=a&&a.length}function pf(a,c){this.dyn_tree=a;this.max_code=0;this.stat_desc=c}function pg(a){return 256>a?fe[a]:fe[256+(a>>>7)]}function ge(a,c){a.pending_buf[a.pending++]=255&c;a.pending_buf[a.pending++]=c>>>8&255}function Dc(a,c,d){a.bi_valid>16-d?(a.bi_buf|=c<>16-a.bi_valid,a.bi_valid+=d-16):(a.bi_buf|=c<>>=1,d<<=1;while(0<--c);return d>>>1}function rg(a,c,d){var b,k=Array(16),p=0;for(b=1;15>=b;b++)k[b]=p=p+d[b-1]<<1;for(d=0;d<=c;d++)b=a[2*d+1],0!==b&&(a[2*d]=qg(k[b]++,b))}function sg(a){var c;for(c=0;286>c;c++)a.dyn_ltree[2*c]=0;for(c=0;30>c;c++)a.dyn_dtree[2*c]=0;for(c=0;19>c;c++)a.bl_tree[2*c]=0;a.dyn_ltree[512]=1;a.opt_len=a.static_len=0;a.last_lit=a.matches=0}function tg(a){8a.heap_len;)b[2*(d=a.heap[++a.heap_len]=2>e?++e:0)]=1,a.depth[d]=0,a.opt_len--,p&&(a.static_len-=k[2*d+1]);c.max_code=e;for(m=a.heap_len>>1;1<=m;m--)qf(a,b,m);d=h;do m=a.heap[1],a.heap[1]=a.heap[a.heap_len--], -qf(a,b,1),k=a.heap[1],a.heap[--a.heap_max]=m,a.heap[--a.heap_max]=k,b[2*d]=b[2*m]+b[2*k],a.depth[d]=(a.depth[m]>=a.depth[k]?a.depth[m]:a.depth[k])+1,b[2*m+1]=b[2*k+1]=d,a.heap[1]=d++,qf(a,b,1);while(2<=a.heap_len);a.heap[--a.heap_max]=a.heap[1];var l,g,n,r,u;m=c.dyn_tree;d=c.max_code;k=c.stat_desc.static_tree;p=c.stat_desc.has_stree;h=c.stat_desc.extra_bits;var v=c.stat_desc.extra_base,x=c.stat_desc.max_length,C=0;for(n=0;15>=n;n++)a.bl_count[n]=0;m[2*a.heap[a.heap_max]+1]=0;for(c=a.heap_max+1;573> -c;c++)(n=m[2*m[2*(l=a.heap[c])+1]+1]+1)>x&&(n=x,C++),m[2*l+1]=n,l>d||(a.bl_count[n]++,r=0,l>=v&&(r=h[l-v]),u=m[2*l],a.opt_len+=u*(n+r),!p||(a.static_len+=u*(k[2*l+1]+r)));if(0!==C){do{for(n=x-1;0===a.bl_count[n];)n--;a.bl_count[n]--;a.bl_count[n+1]+=2;a.bl_count[x]--;C-=2}while(0d||(m[2*g+1]!==n&&(a.opt_len+=(n-m[2*g+1])*m[2*g],m[2*g+1]=n),l--)}rg(b,e,a.bl_count)}function wg(a,c,d){var b,k=-1,p=c[1],h=0,e=7,m=4;0===p&&(e=138,m=3);c[2* -(d+1)+1]=65535;for(b=0;b<=d;b++){var l=p;p=c[2*(b+1)+1];++h=h?a.bl_tree[34]++:a.bl_tree[36]++,h=0,k=l,0===p?(e=138,m=3):l===p?(e=6,m=3):(e=7,m=4))}}function xg(a,c,d){var b,k,p=-1,h=c[1],e=0,m=7,l=4;0===h&&(m=138,l=3);for(b=0;b<=d;b++)if(k=h,h=c[2*(b+1)+1],!(++e=e?($c(a,17,a.bl_tree), -Dc(a,e-3,3)):($c(a,18,a.bl_tree),Dc(a,e-11,7));e=0;p=k;0===h?(m=138,l=3):k===h?(m=6,l=3):(m=7,l=4)}}function yg(a,c,d,b){Dc(a,b?1:0,3);tg(a);ge(a,d);ge(a,~d);$a.arraySet(a.pending_buf,a.window,c,d,a.pending);a.pending+=d}function md(a,c){return a.msg=yd[c],c}function nd(a){for(var c=a.length;0<=--c;)a[c]=0}function od(a){var c=a.state,d=c.pending;d>a.avail_out&&(d=a.avail_out);0!==d&&($a.arraySet(a.output,c.pending_buf,c.pending_out,d,a.next_out),a.next_out+=d,c.pending_out+=d,a.total_out+=d,a.avail_out-= -d,c.pending-=d,0===c.pending&&(c.pending_out=0))}function mc(a,c){Dh(a,0<=a.block_start?a.block_start:-1,a.strstart-a.block_start,c);a.block_start=a.strstart;od(a.strm)}function Eb(a,c){a.pending_buf[a.pending++]=c}function ie(a,c){a.pending_buf[a.pending++]=c>>>8&255;a.pending_buf[a.pending++]=255&c}function zg(a,c){var d,b,k=a.max_chain_length,p=a.strstart,h=a.prev_length,e=a.nice_match,m=a.strstart>a.w_size-262?a.strstart-(a.w_size-262):0,l=a.window,g=a.w_mask,n=a.prev,r=a.strstart+258,u=l[p+h- -1],v=l[p+h];a.prev_length>=a.good_match&&(k>>=2);e>a.lookahead&&(e=a.lookahead);do if(l[(d=c)+h]===v&&l[d+h-1]===u&&l[d]===l[p]&&l[++d]===l[p+1]){p+=2;for(d++;l[++p]===l[++d]&&l[++p]===l[++d]&&l[++p]===l[++d]&&l[++p]===l[++d]&&l[++p]===l[++d]&&l[++p]===l[++d]&&l[++p]===l[++d]&&l[++p]===l[++d]&&ph){if(a.match_start=c,h=b,b>=e)break;u=l[p+h-1];v=l[p+h]}}while((c=n[c&g])>m&&0!=--k);return h<=a.lookahead?h:a.lookahead}function zd(a){var c,d,b=a.w_size;do{if(d=a.window_size- -a.lookahead-a.strstart,a.strstart>=b+(b-262)){$a.arraySet(a.window,a.window,b,b,0);a.match_start-=b;a.strstart-=b;a.block_start-=b;var k=c=a.hash_size;do{var p=a.head[--k];a.head[k]=p>=b?p-b:0}while(--c);k=c=b;do p=a.prev[--k],a.prev[k]=p>=b?p-b:0;while(--c);d+=b}if(0===a.strm.avail_in)break;k=a.strm;p=a.window;var h=a.strstart+a.lookahead,e=k.avail_in;if(c=(e>d&&(e=d),0===e)?0:(k.avail_in-=e,$a.arraySet(p,k.input,k.next_in,e,h),1===k.state.wrap?k.adler=Od(k.adler,p,e,h):2===k.state.wrap&&(k.adler= -gc(k.adler,p,e,h)),k.next_in+=e,k.total_in+=e,e),a.lookahead+=c,3<=a.lookahead+a.insert)for(d=a.strstart-a.insert,a.ins_h=a.window[d],a.ins_h=(a.ins_h<a.lookahead+a.insert)););}while(262>a.lookahead&&0!==a.strm.avail_in)}function uf(a,c){for(var d,b;;){if(262>a.lookahead){if(zd(a),262>a.lookahead&&0===c)return 1;if(0=== -a.lookahead)break}if(d=0,3<=a.lookahead&&(a.ins_h=(a.ins_h<a.strstart?a.strstart:2,4===c)?(mc(a,!0),0===a.strm.avail_out)?3:4:a.last_lit&&(mc(a,!1),0===a.strm.avail_out)?1:2}function Pd(a,c){for(var d, -b,k;;){if(262>a.lookahead){if(zd(a),262>a.lookahead&&0===c)return 1;if(0===a.lookahead)break}if(d=0,3<=a.lookahead&&(a.ins_h=(a.ins_h<=a.match_length&&(1===a.strategy||3===a.match_length&&4096a.strstart?a.strstart:2,4===c)?(mc(a,!0),0===a.strm.avail_out)?3:4:a.last_lit&&(mc(a,!1),0===a.strm.avail_out)?1:2}function ad(a,c,d,b,k){this.good_length=a;this.max_lazy=c;this.nice_length=d;this.max_chain=b;this.func=k}function Eh(){this.strm=null;this.status=0;this.pending_buf= +this.offsetX=D;this.offsetY=P;this.erasesSourceRect=!da}}Fa.prototype=Object.create(zc.prototype);Fa.prototype.constructor=Fa;qa.prototype=Object.create(zc.prototype);qa.prototype.constructor=qa;Oa=[Nd,xh,yh,zh,fe,Ah,Bh,Ch].map(D=>new D(la,Ba));this.width=a;this.height=c}function wb(a,c,d){this.data=a;this.eof=!1;this.start=void 0===c?0:c;this.end=void 0===d?a.length:d;this.pos=this.start}function Od(a){for(var c=a.length;0<=--c;)a[c]=0}function pf(a,c,d,b,k){this.static_tree=a;this.extra_bits=c; +this.extra_base=d;this.elems=b;this.max_length=k;this.has_stree=a&&a.length}function qf(a,c){this.dyn_tree=a;this.max_code=0;this.stat_desc=c}function qg(a){return 256>a?ge[a]:ge[256+(a>>>7)]}function he(a,c){a.pending_buf[a.pending++]=255&c;a.pending_buf[a.pending++]=c>>>8&255}function Ec(a,c,d){a.bi_valid>16-d?(a.bi_buf|=c<>16-a.bi_valid,a.bi_valid+=d-16):(a.bi_buf|=c<>>=1,d<<=1;while(0<--c);return d>>>1}function sg(a,c,d){var b,k=Array(16),p=0;for(b=1;15>=b;b++)k[b]=p=p+d[b-1]<<1;for(d=0;d<=c;d++)b=a[2*d+1],0!==b&&(a[2*d]=rg(k[b]++,b))}function tg(a){var c;for(c=0;286>c;c++)a.dyn_ltree[2*c]=0;for(c=0;30>c;c++)a.dyn_dtree[2*c]=0;for(c=0;19>c;c++)a.bl_tree[2*c]=0;a.dyn_ltree[512]=1;a.opt_len=a.static_len=0;a.last_lit=a.matches=0}function ug(a){8a.heap_len;)b[2*(d=a.heap[++a.heap_len]=2>e?++e:0)]=1,a.depth[d]=0,a.opt_len--,p&&(a.static_len-=k[2*d+1]);c.max_code=e;for(m=a.heap_len>>1;1<=m;m--)rf(a,b,m);d=h;do m=a.heap[1],a.heap[1]=a.heap[a.heap_len--], +rf(a,b,1),k=a.heap[1],a.heap[--a.heap_max]=m,a.heap[--a.heap_max]=k,b[2*d]=b[2*m]+b[2*k],a.depth[d]=(a.depth[m]>=a.depth[k]?a.depth[m]:a.depth[k])+1,b[2*m+1]=b[2*k+1]=d,a.heap[1]=d++,rf(a,b,1);while(2<=a.heap_len);a.heap[--a.heap_max]=a.heap[1];var l,g,n,r,u;m=c.dyn_tree;d=c.max_code;k=c.stat_desc.static_tree;p=c.stat_desc.has_stree;h=c.stat_desc.extra_bits;var v=c.stat_desc.extra_base,x=c.stat_desc.max_length,C=0;for(n=0;15>=n;n++)a.bl_count[n]=0;m[2*a.heap[a.heap_max]+1]=0;for(c=a.heap_max+1;573> +c;c++)(n=m[2*m[2*(l=a.heap[c])+1]+1]+1)>x&&(n=x,C++),m[2*l+1]=n,l>d||(a.bl_count[n]++,r=0,l>=v&&(r=h[l-v]),u=m[2*l],a.opt_len+=u*(n+r),!p||(a.static_len+=u*(k[2*l+1]+r)));if(0!==C){do{for(n=x-1;0===a.bl_count[n];)n--;a.bl_count[n]--;a.bl_count[n+1]+=2;a.bl_count[x]--;C-=2}while(0d||(m[2*g+1]!==n&&(a.opt_len+=(n-m[2*g+1])*m[2*g],m[2*g+1]=n),l--)}sg(b,e,a.bl_count)}function xg(a,c,d){var b,k=-1,p=c[1],h=0,e=7,m=4;0===p&&(e=138,m=3);c[2* +(d+1)+1]=65535;for(b=0;b<=d;b++){var l=p;p=c[2*(b+1)+1];++h=h?a.bl_tree[34]++:a.bl_tree[36]++,h=0,k=l,0===p?(e=138,m=3):l===p?(e=6,m=3):(e=7,m=4))}}function yg(a,c,d){var b,k,p=-1,h=c[1],e=0,m=7,l=4;0===h&&(m=138,l=3);for(b=0;b<=d;b++)if(k=h,h=c[2*(b+1)+1],!(++e=e?(ad(a,17,a.bl_tree), +Ec(a,e-3,3)):(ad(a,18,a.bl_tree),Ec(a,e-11,7));e=0;p=k;0===h?(m=138,l=3):k===h?(m=6,l=3):(m=7,l=4)}}function zg(a,c,d,b){Ec(a,b?1:0,3);ug(a);he(a,d);he(a,~d);$a.arraySet(a.pending_buf,a.window,c,d,a.pending);a.pending+=d}function nd(a,c){return a.msg=zd[c],c}function od(a){for(var c=a.length;0<=--c;)a[c]=0}function pd(a){var c=a.state,d=c.pending;d>a.avail_out&&(d=a.avail_out);0!==d&&($a.arraySet(a.output,c.pending_buf,c.pending_out,d,a.next_out),a.next_out+=d,c.pending_out+=d,a.total_out+=d,a.avail_out-= +d,c.pending-=d,0===c.pending&&(c.pending_out=0))}function mc(a,c){Dh(a,0<=a.block_start?a.block_start:-1,a.strstart-a.block_start,c);a.block_start=a.strstart;pd(a.strm)}function Eb(a,c){a.pending_buf[a.pending++]=c}function je(a,c){a.pending_buf[a.pending++]=c>>>8&255;a.pending_buf[a.pending++]=255&c}function Ag(a,c){var d,b,k=a.max_chain_length,p=a.strstart,h=a.prev_length,e=a.nice_match,m=a.strstart>a.w_size-262?a.strstart-(a.w_size-262):0,l=a.window,g=a.w_mask,n=a.prev,r=a.strstart+258,u=l[p+h- +1],v=l[p+h];a.prev_length>=a.good_match&&(k>>=2);e>a.lookahead&&(e=a.lookahead);do if(l[(d=c)+h]===v&&l[d+h-1]===u&&l[d]===l[p]&&l[++d]===l[p+1]){p+=2;for(d++;l[++p]===l[++d]&&l[++p]===l[++d]&&l[++p]===l[++d]&&l[++p]===l[++d]&&l[++p]===l[++d]&&l[++p]===l[++d]&&l[++p]===l[++d]&&l[++p]===l[++d]&&ph){if(a.match_start=c,h=b,b>=e)break;u=l[p+h-1];v=l[p+h]}}while((c=n[c&g])>m&&0!=--k);return h<=a.lookahead?h:a.lookahead}function Ad(a){var c,d,b=a.w_size;do{if(d=a.window_size- +a.lookahead-a.strstart,a.strstart>=b+(b-262)){$a.arraySet(a.window,a.window,b,b,0);a.match_start-=b;a.strstart-=b;a.block_start-=b;var k=c=a.hash_size;do{var p=a.head[--k];a.head[k]=p>=b?p-b:0}while(--c);k=c=b;do p=a.prev[--k],a.prev[k]=p>=b?p-b:0;while(--c);d+=b}if(0===a.strm.avail_in)break;k=a.strm;p=a.window;var h=a.strstart+a.lookahead,e=k.avail_in;if(c=(e>d&&(e=d),0===e)?0:(k.avail_in-=e,$a.arraySet(p,k.input,k.next_in,e,h),1===k.state.wrap?k.adler=Pd(k.adler,p,e,h):2===k.state.wrap&&(k.adler= +gc(k.adler,p,e,h)),k.next_in+=e,k.total_in+=e,e),a.lookahead+=c,3<=a.lookahead+a.insert)for(d=a.strstart-a.insert,a.ins_h=a.window[d],a.ins_h=(a.ins_h<a.lookahead+a.insert)););}while(262>a.lookahead&&0!==a.strm.avail_in)}function vf(a,c){for(var d,b;;){if(262>a.lookahead){if(Ad(a),262>a.lookahead&&0===c)return 1;if(0=== +a.lookahead)break}if(d=0,3<=a.lookahead&&(a.ins_h=(a.ins_h<a.strstart?a.strstart:2,4===c)?(mc(a,!0),0===a.strm.avail_out)?3:4:a.last_lit&&(mc(a,!1),0===a.strm.avail_out)?1:2}function Qd(a,c){for(var d, +b,k;;){if(262>a.lookahead){if(Ad(a),262>a.lookahead&&0===c)return 1;if(0===a.lookahead)break}if(d=0,3<=a.lookahead&&(a.ins_h=(a.ins_h<=a.match_length&&(1===a.strategy||3===a.match_length&&4096a.strstart?a.strstart:2,4===c)?(mc(a,!0),0===a.strm.avail_out)?3:4:a.last_lit&&(mc(a,!1),0===a.strm.avail_out)?1:2}function bd(a,c,d,b,k){this.good_length=a;this.max_lazy=c;this.nice_length=d;this.max_chain=b;this.func=k}function Eh(){this.strm=null;this.status=0;this.pending_buf= null;this.wrap=this.pending=this.pending_out=this.pending_buf_size=0;this.gzhead=null;this.gzindex=0;this.method=8;this.last_flush=-1;this.w_mask=this.w_bits=this.w_size=0;this.window=null;this.window_size=0;this.head=this.prev=null;this.nice_match=this.good_match=this.strategy=this.level=this.max_lazy_match=this.max_chain_length=this.prev_length=this.lookahead=this.match_start=this.strstart=this.match_available=this.prev_match=this.match_length=this.block_start=this.hash_shift=this.hash_mask=this.hash_bits= -this.hash_size=this.ins_h=0;this.dyn_ltree=new $a.Buf16(1146);this.dyn_dtree=new $a.Buf16(122);this.bl_tree=new $a.Buf16(78);nd(this.dyn_ltree);nd(this.dyn_dtree);nd(this.bl_tree);this.bl_desc=this.d_desc=this.l_desc=null;this.bl_count=new $a.Buf16(16);this.heap=new $a.Buf16(573);nd(this.heap);this.heap_max=this.heap_len=0;this.depth=new $a.Buf16(573);nd(this.depth);this.bi_valid=this.bi_buf=this.insert=this.matches=this.static_len=this.opt_len=this.d_buf=this.last_lit=this.lit_bufsize=this.l_buf= -0}function Ag(a,c){if(65534>c&&(a.subarray&&Bg||!a.subarray&&Cg))return String.fromCharCode.apply(null,$a.shrinkBuf(a,c));for(var d="",b=0;ba.windowBits&&(a.windowBits+=16);this.err=0;this.msg=""; -this.ended=!1;this.chunks=[];this.strm=new vf;this.strm.avail_out=0;var d=this.strm;var b=a.level;var k=a.method,p=a.windowBits,h=a.memLevel,e=a.strategy;if(d){var m,l,g,n=1;if(-1===b&&(b=6),0>p?(n=0,p=-p):15h||9p||15b||9e||4m.wrap&&(m.wrap=-m.wrap),m.status=m.wrap?42:113,d.adler=2===m.wrap?0:1,m.last_flush=0,Fh(m),0):md(d,-2))&&((l=d.state).window_size= -2*l.w_size,nd(l.head),l.max_lazy_match=je[l.level].max_lazy,l.good_match=je[l.level].good_length,l.nice_match=je[l.level].nice_length,l.max_chain_length=je[l.level].max_chain,l.strstart=0,l.block_start=0,l.lookahead=0,l.insert=0,l.match_length=l.prev_length=2,l.match_available=0,l.ins_h=0),g)}}else b=-2;if(0!==b)throw Error(yd[b]);if(a.header&&Gh(this.strm,a.header),a.dictionary){if(c="string"==typeof a.dictionary?wf(a.dictionary):"[object ArrayBuffer]"===Dg.call(a.dictionary)?new Uint8Array(a.dictionary): -a.dictionary,0!==(b=Hh(this.strm,c)))throw Error(yd[b]);this._dict_set=!0}}function xf(a,c){c=new Ad(c);if(c.push(a,!0),c.err)throw c.msg||yd[c.err];return c.result}function Eg(a){return(a>>>24&255)+(a>>>8&65280)+((65280&a)<<8)+((255&a)<<24)}function Ih(){this.mode=0;this.last=!1;this.wrap=0;this.havedict=!1;this.total=this.check=this.dmax=this.flags=0;this.head=null;this.wnext=this.whave=this.wsize=this.wbits=0;this.window=null;this.extra=this.offset=this.length=this.bits=this.hold=0;this.distcode= -this.lencode=null;this.have=this.ndist=this.nlen=this.ncode=this.distbits=this.lenbits=0;this.next=null;this.lens=new $a.Buf16(320);this.work=new $a.Buf16(288);this.distdyn=this.lendyn=null;this.was=this.back=this.sane=0}function Fg(a,c,d,b){var k;a=a.state;return null===a.window&&(a.wsize=1<=a.wsize?($a.arraySet(a.window,c,d-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):((k=a.wsize-a.wnext)>b&&(k=b),$a.arraySet(a.window,c,d-b,k,a.wnext), -(b-=k)?($a.arraySet(a.window,c,d-b,b,0),a.wnext=b,a.whave=a.wsize):(a.wnext+=k,a.wnext===a.wsize&&(a.wnext=0),a.whaveg.windowBits&&(g.windowBits=-g.windowBits,0===g.windowBits&&(g.windowBits=-15));0<=g.windowBits&&16>g.windowBits&&(!a||!a.windowBits)&&(g.windowBits+=32);15g.windowBits&&0==(15&g.windowBits)&&(g.windowBits|=15);this.err=0;this.msg="";this.ended=!1;this.chunks=[];this.strm=new vf;this.strm.avail_out=0;a=(b=this.strm,k=g.windowBits,b?(h=new Ih,b.state=h,h.window=null,e=k,0!=(p=b&&b.state?(l=b.state,0>e?(m=0,e=-e):(m=(e>>4)+1,48>e&&(e&=15)),e&&(8>e||15>16&65535,minor:65535&a}}function Af(a,c){let d=new wb(new Uint8Array(Fe.HEADER_LENGTH+ -c));return d.writeString(a),d.writeU32BE(c),d}function Qd(){}function Ge(a){function c(p,h){null===h?k.emitEvent("loadingProgress",[1,"Loading your "+p.friendly+"..."]):k.emitEvent("loadingProgress",[h,"Loading your "+p.friendly+" ("+Math.round(100*h)+"%)..."])}var d=[],b={},k=this;a.loadChibiFileUrl&&0<(""+a.loadChibiFileUrl).length?d.push({url:a.loadChibiFileUrl,friendly:"drawing layers",name:"layers",required:!0}):a.loadImageUrl&&0<(""+a.loadImageUrl).length&&d.push({url:a.loadImageUrl,friendly:"drawing", +this.hash_size=this.ins_h=0;this.dyn_ltree=new $a.Buf16(1146);this.dyn_dtree=new $a.Buf16(122);this.bl_tree=new $a.Buf16(78);od(this.dyn_ltree);od(this.dyn_dtree);od(this.bl_tree);this.bl_desc=this.d_desc=this.l_desc=null;this.bl_count=new $a.Buf16(16);this.heap=new $a.Buf16(573);od(this.heap);this.heap_max=this.heap_len=0;this.depth=new $a.Buf16(573);od(this.depth);this.bi_valid=this.bi_buf=this.insert=this.matches=this.static_len=this.opt_len=this.d_buf=this.last_lit=this.lit_bufsize=this.l_buf= +0}function Bg(a,c){if(65534>c&&(a.subarray&&Cg||!a.subarray&&Dg))return String.fromCharCode.apply(null,$a.shrinkBuf(a,c));for(var d="",b=0;ba.windowBits&&(a.windowBits+=16);this.err=0;this.msg=""; +this.ended=!1;this.chunks=[];this.strm=new wf;this.strm.avail_out=0;var d=this.strm;var b=a.level;var k=a.method,p=a.windowBits,h=a.memLevel,e=a.strategy;if(d){var m,l,g,n=1;if(-1===b&&(b=6),0>p?(n=0,p=-p):15h||9p||15b||9e||4m.wrap&&(m.wrap=-m.wrap),m.status=m.wrap?42:113,d.adler=2===m.wrap?0:1,m.last_flush=0,Fh(m),0):nd(d,-2))&&((l=d.state).window_size= +2*l.w_size,od(l.head),l.max_lazy_match=ke[l.level].max_lazy,l.good_match=ke[l.level].good_length,l.nice_match=ke[l.level].nice_length,l.max_chain_length=ke[l.level].max_chain,l.strstart=0,l.block_start=0,l.lookahead=0,l.insert=0,l.match_length=l.prev_length=2,l.match_available=0,l.ins_h=0),g)}}else b=-2;if(0!==b)throw Error(zd[b]);if(a.header&&Gh(this.strm,a.header),a.dictionary){if(c="string"==typeof a.dictionary?xf(a.dictionary):"[object ArrayBuffer]"===Eg.call(a.dictionary)?new Uint8Array(a.dictionary): +a.dictionary,0!==(b=Hh(this.strm,c)))throw Error(zd[b]);this._dict_set=!0}}function yf(a,c){c=new Bd(c);if(c.push(a,!0),c.err)throw c.msg||zd[c.err];return c.result}function Fg(a){return(a>>>24&255)+(a>>>8&65280)+((65280&a)<<8)+((255&a)<<24)}function Ih(){this.mode=0;this.last=!1;this.wrap=0;this.havedict=!1;this.total=this.check=this.dmax=this.flags=0;this.head=null;this.wnext=this.whave=this.wsize=this.wbits=0;this.window=null;this.extra=this.offset=this.length=this.bits=this.hold=0;this.distcode= +this.lencode=null;this.have=this.ndist=this.nlen=this.ncode=this.distbits=this.lenbits=0;this.next=null;this.lens=new $a.Buf16(320);this.work=new $a.Buf16(288);this.distdyn=this.lendyn=null;this.was=this.back=this.sane=0}function Gg(a,c,d,b){var k;a=a.state;return null===a.window&&(a.wsize=1<=a.wsize?($a.arraySet(a.window,c,d-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):((k=a.wsize-a.wnext)>b&&(k=b),$a.arraySet(a.window,c,d-b,k,a.wnext), +(b-=k)?($a.arraySet(a.window,c,d-b,b,0),a.wnext=b,a.whave=a.wsize):(a.wnext+=k,a.wnext===a.wsize&&(a.wnext=0),a.whaveg.windowBits&&(g.windowBits=-g.windowBits,0===g.windowBits&&(g.windowBits=-15));0<=g.windowBits&&16>g.windowBits&&(!a||!a.windowBits)&&(g.windowBits+=32);15g.windowBits&&0==(15&g.windowBits)&&(g.windowBits|=15);this.err=0;this.msg="";this.ended=!1;this.chunks=[];this.strm=new wf;this.strm.avail_out=0;a=(b=this.strm,k=g.windowBits,b?(h=new Ih,b.state=h,h.window=null,e=k,0!=(p=b&&b.state?(l=b.state,0>e?(m=0,e=-e):(m=(e>>4)+1,48>e&&(e&=15)),e&&(8>e||15>16&65535,minor:65535&a}}function Bf(a,c){let d=new wb(new Uint8Array(Ge.HEADER_LENGTH+ +c));return d.writeString(a),d.writeU32BE(c),d}function Rd(){}function He(a){function c(p,h){null===h?k.emitEvent("loadingProgress",[1,"Loading your "+p.friendly+"..."]):k.emitEvent("loadingProgress",[h,"Loading your "+p.friendly+" ("+Math.round(100*h)+"%)..."])}var d=[],b={},k=this;a.loadChibiFileUrl&&0<(""+a.loadChibiFileUrl).length?d.push({url:a.loadChibiFileUrl,friendly:"drawing layers",name:"layers",required:!0}):a.loadImageUrl&&0<(""+a.loadImageUrl).length&&d.push({url:a.loadImageUrl,friendly:"drawing", name:"flat",required:!0});a.loadSwatchesUrl&&d.push({url:a.loadSwatchesUrl,friendly:"color swatches",name:"swatches",required:!1,noProgress:!0});this.load=function(){function p(){h.required?k.emitEvent("loadingFailure",["Failed to load your "+h.friendly+", please try again later."]):k.load()}if(0==d.length)k.emitEvent("loadingComplete",[b]);else{var h=d.shift(),e=new XMLHttpRequest;e.addEventListener("progress",function(m){c(h,m.lengthComputable&&!h.noProgress?m.loaded/m.total:null)},!1);e.addEventListener("load", -function(m){if(200==this.status){let l=this.response;k.emitEvent("loadingProgress",[1,"Starting ChickenPaint..."]);setTimeout(function(){(function(g,n){switch(g.name){case "flat":return new Promise(function(r,u){let v=new Blob([n],{type:"image/png"}),x=window.URL.createObjectURL(v);if(x){let C=new Image;C.onload=function(){let K=new Cc(this.width,this.height),I=new Ma(0,0,"Layer 1");I.image=H.createFromImage(C);K.addLayerObject(K.getLayersRoot(),I);C=null;window.URL.revokeObjectURL(x);r(K)};C.src= -x}else u(null)});case "swatches":return(g=(new Qd).read(n))?Promise.resolve(g):Promise.reject(null);case "layers":return function(r,u){function v(ea){let ja;var ra=Y;if(null!==ra&&0!==ra.length)if(null===ea||0===ea.length)ea=ra;else{var Na=new Uint8Array(ra.length+ea.length);ea=(Na.set(ra,0),Na.set(ea,ra.length),Na)}for(Y=ea;Y;){if(Lnew Promise(function(ja,ra){let Na=new Uint8Array(ea);(function(V){for(let Fa=0;8>Fa;Fa++)if(V[Fa]!="CHIBIOEK".charCodeAt(Fa))return!1; +function(m){if(200==this.status){let l=this.response;k.emitEvent("loadingProgress",[1,"Starting ChickenPaint..."]);setTimeout(function(){(function(g,n){switch(g.name){case "flat":return new Promise(function(r,u){let v=new Blob([n],{type:"image/png"}),x=window.URL.createObjectURL(v);if(x){let C=new Image;C.onload=function(){let K=new Dc(this.width,this.height),I=new Ma(0,0,"Layer 1");I.image=H.createFromImage(C);K.addLayerObject(K.getLayersRoot(),I);C=null;window.URL.revokeObjectURL(x);r(K)};C.src= +x}else u(null)});case "swatches":return(g=(new Rd).read(n))?Promise.resolve(g):Promise.reject(null);case "layers":return function(r,u){function v(ea){let ja;var ra=Y;if(null!==ra&&0!==ra.length)if(null===ea||0===ea.length)ea=ra;else{var Na=new Uint8Array(ra.length+ea.length);ea=(Na.set(ra,0),Na.set(ea,ra.length),Na)}for(Y=ea;Y;){if(Lnew Promise(function(ja,ra){let Na=new Uint8Array(ea);(function(V){for(let Fa=0;8>Fa;Fa++)if(V[Fa]!="CHIBIOEK".charCodeAt(Fa))return!1; return!0})(Na)?(Na=Na.subarray(8),x.onData=v,x.onEnd=function(V){0===V&&45==C?(!1!==u.upgradeMultiplyLayers&&10>U.version&&K.upgradeMultiplyLayers(u.upgradeMultiplyLayers),K.selectTopmostVisibleLayer(),ja(K)):ra("Fatal error decoding ChibiFile: "+V)},x.push(Na,!0)):ra("This doesn't appear to be a ChibiPaint layers file, is it damaged?")}))}(n);default:return Promise.reject("Unexpected resource type '"+g.name+"'")}})(h,l).then(function(g){b[h.name]=g;k.load()},function(){k.emitEvent("loadingFailure", -["Failed to read your "+h.friendly])})},0)}else p()},!1);e.addEventListener("error",p);c(h,h.noProgress?null:0);e.open("GET",h.url,!0);e.responseType="arraybuffer";e.send()}}}function Cf(a){(a=a.split(/[-_]/,1)[0].toLowerCase())in Df?(He=Df[a],Ef=a):(He=Ie,Ef="en")}function ma(a){return a in He?He[a]:a}function ke(a){function c(k){null===k?d.emitEvent("savingProgress",[1,ma("Saving drawing...")]):d.emitEvent("savingProgress",[k,ma("Saving drawing...")+" ("+Math.round(100*k)+"%)"])}var d=this,b=!1; -a.rotation=a.rotation||0;this.save=function(){var k,p,h,e,m;(k=new Blob([function(l){for(var g=new Uint8Array(l.length),n=0;n{var l,g;let n,r=new (X(Bf).Deflate)({level:7}),u=[],v=new Uint8Array(8),x=e.getLayersRoot().getLinearizedLayerList(!1),C=m.forceOldVersion?0:function(I){for(let G of I.getLayersRoot().getLinearizedLayerList(!1))if(G instanceof -ob||G.mask||G.clip||G.blendMode>S.LM_LAST_CHIBIPAINT||G.blendMode===S.LM_MULTIPLY)return 10;return 0}(e),K=0===(g=Jg(C)).major&&0===g.minor?"ChibiPaint v0.0":"ChickenPaint v"+g.major+"."+g.minor;g=Promise.resolve();r.onData=function(I){u.push(I)};for(let I=0;8>I;I++)v[I]="CHIBIOEK".charCodeAt(I);for(let I of(u.push(v),r.push((l=x.length,(n=Af("HEAD",zf.FIXED_HEADER_LENGTH)).writeU32BE(C),n.writeU32BE(e.width),n.writeU32BE(e.height),n.writeU32BE(l),n.getAsDataArray()),!1),x))g=g.then(()=>new Promise(function(G){var L= -r.push,U=I,T=U instanceof Ma,Y=4*(T?5:6),ea=U.name.length;var ja=Af(T?"LAYR":"GRUP",Y+ea+((T?U.image.data.length:0)+(U.mask?U.mask.data.length:0)));var ra=0;let Na;U.visible&&(ra|=1);T&&U.clip&&(ra|=2);U.mask&&(ra|=4);U.maskLinked&&(ra|=8);U.maskVisible&&(ra|=16);U.lockAlpha&&(ra|=64);!T&&U.expanded&&(ra|=32);U.blendMode===S.LM_MULTIPLY2?(Na=S.LM_MULTIPLY,ra|=128):Na=U.blendMode;ja.writeU32BE(Y+ea);ja.writeU32BE(Na);ja.writeU32BE(U.alpha);ja.writeU32BE(ra);ja.writeU32BE(U.name.length);T||ja.writeU32BE(U.layers.length); +["Failed to read your "+h.friendly])})},0)}else p()},!1);e.addEventListener("error",p);c(h,h.noProgress?null:0);e.open("GET",h.url,!0);e.responseType="arraybuffer";e.send()}}}function Df(a){(a=a.split(/[-_]/,1)[0].toLowerCase())in Ef?(Ie=Ef[a],Ff=a):(Ie=Je,Ff="en")}function ma(a){return a in Ie?Ie[a]:a}function le(a){function c(k){null===k?d.emitEvent("savingProgress",[1,ma("Saving drawing...")]):d.emitEvent("savingProgress",[k,ma("Saving drawing...")+" ("+Math.round(100*k)+"%)"])}var d=this,b=!1; +a.rotation=a.rotation||0;this.save=function(){var k,p,h,e,m;(k=new Blob([function(l){for(var g=new Uint8Array(l.length),n=0;n{var l,g;let n,r=new (X(Cf).Deflate)({level:7}),u=[],v=new Uint8Array(8),x=e.getLayersRoot().getLinearizedLayerList(!1),C=m.forceOldVersion?0:function(I){for(let G of I.getLayersRoot().getLinearizedLayerList(!1))if(G instanceof +ob||G.mask||G.clip||G.blendMode>S.LM_LAST_CHIBIPAINT||G.blendMode===S.LM_MULTIPLY)return 10;return 0}(e),K=0===(g=Kg(C)).major&&0===g.minor?"ChibiPaint v0.0":"ChickenPaint v"+g.major+"."+g.minor;g=Promise.resolve();r.onData=function(I){u.push(I)};for(let I=0;8>I;I++)v[I]="CHIBIOEK".charCodeAt(I);for(let I of(u.push(v),r.push((l=x.length,(n=Bf("HEAD",Af.FIXED_HEADER_LENGTH)).writeU32BE(C),n.writeU32BE(e.width),n.writeU32BE(e.height),n.writeU32BE(l),n.getAsDataArray()),!1),x))g=g.then(()=>new Promise(function(G){var L= +r.push,U=I,T=U instanceof Ma,Y=4*(T?5:6),ea=U.name.length;var ja=Bf(T?"LAYR":"GRUP",Y+ea+((T?U.image.data.length:0)+(U.mask?U.mask.data.length:0)));var ra=0;let Na;U.visible&&(ra|=1);T&&U.clip&&(ra|=2);U.mask&&(ra|=4);U.maskLinked&&(ra|=8);U.maskVisible&&(ra|=16);U.lockAlpha&&(ra|=64);!T&&U.expanded&&(ra|=32);U.blendMode===S.LM_MULTIPLY2?(Na=S.LM_MULTIPLY,ra|=128):Na=U.blendMode;ja.writeU32BE(Y+ea);ja.writeU32BE(Na);ja.writeU32BE(U.alpha);ja.writeU32BE(ra);ja.writeU32BE(U.name.length);T||ja.writeU32BE(U.layers.length); ja.writeString(U.name);if(T){T=ja.pos;Y=ja.data;ea=U.image.data;for(ra=0;ranew Promise((I,G)=>{r.onEnd=function(L){if(0===L)if("undefined"!=typeof Blob)I({bytes:new Blob(u,{type:"application/octet-stream"}), -version:K});else{L=new Uint8Array(u.map(T=>T.byteLength).reduce((T,Y)=>T+Y,0));let U=0;for(let T of u)L.set(T,U),U+=T.byteLength;I({bytes:L,version:K})}else G(L)};r.push(Af("ZEND",0).getAsDataArray(),!0)}))}));h.then(function(l){if(b)d.emitEvent("savingFailure");else if(p=a.swatches?new Blob([(new Qd).write(a.swatches)],{type:"application/octet-stream"}):null,a.url){var g=new FormData;g.append("beginMarker","This marker ensures the upload wasn't truncated");g.append("painter","ChickenPaint v2.0"); +version:K});else{L=new Uint8Array(u.map(T=>T.byteLength).reduce((T,Y)=>T+Y,0));let U=0;for(let T of u)L.set(T,U),U+=T.byteLength;I({bytes:L,version:K})}else G(L)};r.push(Bf("ZEND",0).getAsDataArray(),!0)}))}));h.then(function(l){if(b)d.emitEvent("savingFailure");else if(p=a.swatches?new Blob([(new Rd).write(a.swatches)],{type:"application/octet-stream"}):null,a.url){var g=new FormData;g.append("beginMarker","This marker ensures the upload wasn't truncated");g.append("painter","ChickenPaint v2.0"); g.append("picture",k);k=null;l?(g.append("chibifileFormat",l.version),g.append("chibifile",l.bytes),l=null,g.append("rotation",""+a.rotation)):g.append("rotation","0");p&&(g.append("swatches",p),p=null);g.append("endMarker","This marker ensures the upload wasn't truncated");c(.5);fetch(a.url,{method:"POST",mode:"same-origin",headers:{"X-Requested-With":"chickenpaint"},body:g}).then(n=>{if(!n.ok)throw Error("Network response was not ok (".concat(n.status,")"));return n.text()}).then(n=>{/^CHIBIOK/.test(n)? -(c(1),d.emitEvent("savingComplete")):d.emitEvent("savingFailure",[n])}).catch(n=>{d.emitEvent("savingFailure",[n.message])})}else g="oekaki_"+(new Date).toISOString().split(".")[0].replace(/[^0-9]/g,"_"),X(le).saveAs(k,g+".png"),l&&X(le).saveAs(l.bytes,g+".chi"),p&&X(le).saveAs(p,g+".aco")}).catch(function(l){d.emitEvent("savingFailure")})};this.cancel=function(){b=!0}}function Mh(a,c,d){function b(){var Y=l.width/2,ea=l.height/2;if(g.fillStyle="white",g.fillRect(0,0,l.width,l.height),G==I.length){var ja= +(c(1),d.emitEvent("savingComplete")):d.emitEvent("savingFailure",[n])}).catch(n=>{d.emitEvent("savingFailure",[n.message])})}else g="oekaki_"+(new Date).toISOString().split(".")[0].replace(/[^0-9]/g,"_"),X(me).saveAs(k,g+".png"),l&&X(me).saveAs(l.bytes,g+".chi"),p&&X(me).saveAs(p,g+".aco")}).catch(function(l){d.emitEvent("savingFailure")})};this.cancel=function(){b=!0}}function Mh(a,c,d){function b(){var Y=l.width/2,ea=l.height/2;if(g.fillStyle="white",g.fillRect(0,0,l.width,l.height),G==I.length){var ja= v.width,ra=v.height,Na=Math.round(Y-ja/2),V=Math.round(ea-ra/2);g.drawImage(v,Na,V);var Fa=L;p||((p=document.createElement("canvas")).width=ja,p.height=ra,e=p.getContext("2d"));e.globalCompositeOperation="copy";e.drawImage(n,0,0);h||((h=document.createElement("canvas")).width=ja,h.height=ra,m=h.getContext("2d"));m.globalCompositeOperation="copy";m.drawImage(K,0,0);m.globalCompositeOperation="source-in";m.drawImage(K,0,Math.round(170*Fa));e.globalCompositeOperation="source-over";e.drawImage(h,0,0); e.drawImage(r,0,0);e.globalCompositeOperation="screen";e.drawImage(C,0,0);e.globalCompositeOperation="multiply";e.drawImage(x,0,0);g.globalAlpha=.88;g.drawImage(p,Na,V);g.globalAlpha=1;g.drawImage(u,Na,V);ea=Math.round(ea+ra/2+2)}if(""!=U)for(g.fillStyle="black",Fa=U.split("\n"),ja=0;ja=d;d++)c[String.fromCharCode(d)]=d;if((a=a.toUpperCase())in c)return c[a]} -function dd(){var a,c=null,d=this;this.isPen=function(){var b;return!!c&&(1==(b=c.pointerType)||3==b)};this.getPressure=function(){return c?c.pressure:1};this.pluginLoaded=function(){console.log("Wacom tablet support loaded!");c=a.penAPI};this.isTabletPresent=function(){return!!c};this.detectTablet=function(){if(/Chrome/i.test(navigator.userAgent)&&!/OPR/.test(navigator.userAgent))console.log("Not attempting to load Wacom tablet plugin, since this is Chrome");else{if(console.log("Attempting to load Wacom tablet support..."), -"classid"in(a=document.createElement("object")))a.classid="CLSID:092dfa86-5807-5a94-bf3b-5a53ba9e5308";else{var b=document.createElement("param");b.name="onload";b.value="onWacomPluginLoaded";a.appendChild(b);a.type="application/x-wacomtabletplugin"}a.style.position="absolute";a.style.visibility="hidden";a.onload="onWacomPluginLoaded";document.body.appendChild(a);setTimeout(function(){d.isTabletPresent()||console.log("Looks like the Wacom plugin isn't installed, or failed to load.")},5E3)}}}function Lg(){let a, -c,d,b,k,p,h,e;this.x0=this.y0=this.x1=this.y1=this.x2=this.y2=this.x3=this.y3=0;let m=l=>{let g=3*l,n=g*l;l*=l*l;let r=2*n,u=6*l,v=this.x0-2*this.x1+this.x2,x=this.y0-2*this.y1+this.y2,C=3*(this.x1-this.x2)-this.x0+this.x3,K=3*(this.y1-this.y2)-this.y0+this.y3;a=this.x0;k=this.y0;c=(this.x1-this.x0)*g+v*n+C*l;p=(this.y1-this.y0)*g+x*n+K*l;d=v*r+C*u;h=x*r+K*u;b=C*u;e=K*u};this.compute=(l,g,n)=>{m(1/n);l[0]=a;g[0]=k;for(let r=1;ra?h():!0!==c&&(k=setTimeout(b?function(){k=void 0}:h,void 0===b?a-m:a))}}function Cd(a){this.points=a||[]}function Mb(a,c){this.x=a;this.y=c}function Ng(a){for(var c=document.createElement("canvas"),d=c.getContext("2d"),b=d.createImageData(64,64),k=b.data,p=0,h=0;64>h;h++)for(var e=0;64>e;e++)0!=(8&e)^0!=(8&h)? -(k[p++]=255,k[p++]=255,k[p++]=255):(k[p++]=204,k[p++]=204,k[p++]=204),k[p++]=255;return c.width=64,c.height=64,d.putImageData(b,0,0),a.createPattern(c,"repeat")}function Je(a,c){c+="Style";a.globalCompositeOperation="exclusion";"exclusion"==a.globalCompositeOperation?a[c]="white":(a.globalCompositeOperation="difference",a[c]="#888","difference"!=a.globalCompositeOperation&&(a[c]="black"))}function me(a){function c(){var x=a?X(ia)(d).height():X(ia)(d).width();n=m/(h-p)*x;x=(e-p)/(h-p)*(x-n);k.style[a? +k);a.removeChild(l)});window.addEventListener("resize",k);l.className="chickenpaint-splash-screen";a.appendChild(l);k()}function Lg(a){for(var c={DELETE:46,BACKSPACE:8,TAB:9,ENTER:13,ESCAPE:27," ":32,ARROWLEFT:37,ARROWUP:38,ARROWRIGHT:39,ARROWDOWN:40,SHIFT:16,"[":219,"]":221,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,0:48,"-":189,"=":187,"+":187,";":187,META:91,LEFTMETA:91,RIGHTMETA:91,ALT:18,ALTGRAPH:18,OPTION:18,CONTROL:17},d=65;90>=d;d++)c[String.fromCharCode(d)]=d;if((a=a.toUpperCase())in c)return c[a]} +function ed(){var a,c=null,d=this;this.isPen=function(){var b;return!!c&&(1==(b=c.pointerType)||3==b)};this.getPressure=function(){return c?c.pressure:1};this.pluginLoaded=function(){console.log("Wacom tablet support loaded!");c=a.penAPI};this.isTabletPresent=function(){return!!c};this.detectTablet=function(){if(/Chrome/i.test(navigator.userAgent)&&!/OPR/.test(navigator.userAgent))console.log("Not attempting to load Wacom tablet plugin, since this is Chrome");else{if(console.log("Attempting to load Wacom tablet support..."), +"classid"in(a=document.createElement("object")))a.classid="CLSID:092dfa86-5807-5a94-bf3b-5a53ba9e5308";else{var b=document.createElement("param");b.name="onload";b.value="onWacomPluginLoaded";a.appendChild(b);a.type="application/x-wacomtabletplugin"}a.style.position="absolute";a.style.visibility="hidden";a.onload="onWacomPluginLoaded";document.body.appendChild(a);setTimeout(function(){d.isTabletPresent()||console.log("Looks like the Wacom plugin isn't installed, or failed to load.")},5E3)}}}function Mg(){let a, +c,d,b,k,p,h,e;this.x0=this.y0=this.x1=this.y1=this.x2=this.y2=this.x3=this.y3=0;let m=l=>{let g=3*l,n=g*l;l*=l*l;let r=2*n,u=6*l,v=this.x0-2*this.x1+this.x2,x=this.y0-2*this.y1+this.y2,C=3*(this.x1-this.x2)-this.x0+this.x3,K=3*(this.y1-this.y2)-this.y0+this.y3;a=this.x0;k=this.y0;c=(this.x1-this.x0)*g+v*n+C*l;p=(this.y1-this.y0)*g+x*n+K*l;d=v*r+C*u;h=x*r+K*u;b=C*u;e=K*u};this.compute=(l,g,n)=>{m(1/n);l[0]=a;g[0]=k;for(let r=1;ra?h():!0!==c&&(k=setTimeout(b?function(){k=void 0}:h,void 0===b?a-m:a))}}function Dd(a){this.points=a||[]}function Mb(a,c){this.x=a;this.y=c}function Og(a){for(var c=document.createElement("canvas"),d=c.getContext("2d"),b=d.createImageData(64,64),k=b.data,p=0,h=0;64>h;h++)for(var e=0;64>e;e++)0!=(8&e)^0!=(8&h)? +(k[p++]=255,k[p++]=255,k[p++]=255):(k[p++]=204,k[p++]=204,k[p++]=204),k[p++]=255;return c.width=64,c.height=64,d.putImageData(b,0,0),a.createPattern(c,"repeat")}function Ke(a,c){c+="Style";a.globalCompositeOperation="exclusion";"exclusion"==a.globalCompositeOperation?a[c]="white":(a.globalCompositeOperation="difference",a[c]="#888","difference"!=a.globalCompositeOperation&&(a[c]="black"))}function ne(a){function c(){var x=a?X(ia)(d).height():X(ia)(d).width();n=m/(h-p)*x;x=(e-p)/(h-p)*(x-n);k.style[a? "height":"width"]=n+"px";b.style[a?"height":"width"]=n+"px";b.style[a?"top":"left"]=x+"px"}let d=document.createElement("div"),b=document.createElement("div"),k=document.createElement("div"),p=0,h=1,e=0,m=1,l=10,g=!1,n=1,r=!1,u,v=this;this.setValues=function(x,C,K,I){e=x;m=C;p=K;h=I;c()};this.setBlockIncrement=function(x){l=x};this.setUnitIncrement=function(x){};this.getElement=function(){return d};this.getValueIsAdjusting=function(){return g};d.className="chickenpaint-scrollbar "+(a?"chickenpaint-scrollbar-vertical": "chickenpaint-scrollbar-horizontal");b.className="chickenpaint-scrollbar-handle";b.setAttribute("touch-action","none");k.className="chickenpaint-scrollbar-handle-inner";b.appendChild(k);d.appendChild(b);b.addEventListener("pointerdown",function(x){x.stopPropagation();u=a?x.pageY-X(ia)(d).offset().top:x.pageX-X(ia)(d).offset().left;b.setPointerCapture(x.pointerId);X(ia)(b).addClass("dragging");r=!0});b.addEventListener("pointermove",function(x){if(r){g=!0;let C=a?X(ia)(d).height():X(ia)(d).width(); x=a?x.pageY-X(ia)(d).offset().top:x.pageX-X(ia)(d).offset().left;e+=(x-u)*(h-p)/(C-n);e=Math.min(Math.max(e,p),h);u=x;v.emitEvent("valueChanged",[e]);c();g=!1}});b.addEventListener("pointerup",function(x){if(x.stopPropagation(),r){try{b.releasePointerCapture(x.pointerId)}catch(C){}X(ia)(b).removeClass("dragging");r=!1}});b.addEventListener("click",function(x){x.stopPropagation()});d.addEventListener("click",function(x){this==d&&((a?x.pageY-X(ia)(d).offset().top:x.pageX-X(ia)(d).offset().left)za;za++)Ia.continueStroke(cb[za],gb[za],1);Ia.endStroke();Ja.repaintAll()}return!0}};this.mouseMove=function(za,cb){if(this.capture)return za=L({x:rb,y:hb}),1==F?ca=za:2==F&&(ka=za),Ja.repaintAll(),!0;b.prototype.mouseMove.call(this,za,cb)};this.paint=function(){if(this.capture){var za=new Lg;let cb=T(N),gb=T(ca),Da=T(ka),jb=T(xa);za.x0=cb.x;za.y0=cb.y;za.x1=gb.x;za.y1=gb.y;za.x2=Da.x;za.y2=Da.y; +0==cb&&!za.altKey&&!X(Sb).isPressed("space")&&K())return za=L({x:rb,y:hb}),F=0,N=ca=ka=xa=za,this.capture=!0,this.eraseBrushPreview(),!0};this.mouseDrag=function(za){if(this.capture&&0===F)return ka=xa=L({x:rb,y:hb}),Ja.repaintAll(),!0;this.mouseMove.call(this,za)};this.mouseUp=function(za,cb,gb){if(this.capture&&0==cb){switch(F){case 0:F=1;break;case 1:F=2;break;case 2:this.capture=!1;cb=N;gb=ca;let Da=ka,jb=xa;za=new Mg;za.x0=cb.x;za.y0=cb.y;za.x1=gb.x;za.y1=gb.y;za.x2=Da.x;za.y2=Da.y;za.x3=jb.x; +za.y3=jb.y;cb=Array(500);gb=Array(500);za.compute(cb,gb,500);Ia.beginStroke(cb[0],gb[0],1);for(za=1;500>za;za++)Ia.continueStroke(cb[za],gb[za],1);Ia.endStroke();Ja.repaintAll()}return!0}};this.mouseMove=function(za,cb){if(this.capture)return za=L({x:rb,y:hb}),1==F?ca=za:2==F&&(ka=za),Ja.repaintAll(),!0;b.prototype.mouseMove.call(this,za,cb)};this.paint=function(){if(this.capture){var za=new Mg;let cb=T(N),gb=T(ca),Da=T(ka),jb=T(xa);za.x0=cb.x;za.y0=cb.y;za.x1=gb.x;za.y1=gb.y;za.x2=Da.x;za.y2=Da.y; za.x3=jb.x;za.y3=jb.y;let Vb=Array(100),kc=Array(100);za.compute(Vb,kc,100);ha.beginPath();ha.moveTo(Vb[0],kc[0]);for(za=1;100>za;za++)ha.lineTo(Vb[za],kc[za]);ha.moveTo(~~cb.x,~~cb.y);ha.lineTo(~~gb.x,~~gb.y);ha.moveTo(~~Da.x,~~Da.y);ha.lineTo(~~jb.x,~~jb.y);ha.stroke()}else b.prototype.paint.call(this)};b.call(this)}function e(){var F;this.mouseDown=function(N,ca,ka){return!!this.capture||(X(Sb).isPressed("space")||(0!=ca||this.transient&&!N.altKey)&&2!=ca?void(this.transient&&va.pop()):(F=ca,this.capture= !0,x("crosshair"),this.mouseDrag(N),!0))};this.mouseDrag=function(N){if(this.capture)return N=L({x:rb,y:hb}),Ia.isPointWithin(N.x,N.y)&&a.setCurColor(new Bb(Ia.colorPicker(N.x,N.y))),!0};this.mouseUp=function(N,ca,ka){if(this.capture&&ca==F)return F=-1,this.capture=!1,x("default"),this.transient&&va.pop(),!0};this.enter=function(){c.prototype.enter.call(this);F=-1}}function m(){var F,N,ca,ka;this.keyDown=function(xa){if(" "===xa.key)return this.capture||x("grab"),!0};this.keyUp=function(xa){if(this.transient&& 1!=ka&&" "===xa.key)return x("default"),va.pop(),!0};this.mouseDown=function(xa,za,cb){return!!this.capture||(1==za||X(Sb).isPressed("space")&&0==za||!this.transient&&0==za?(this.capture=!0,ka=za,F=xa.pageX,N=xa.pageY,ca=Ja.getOffset(),x("grabbing"),!0):void(this.transient&&va.pop()))};this.mouseDrag=function(xa){if(this.capture)return Ja.setOffset(ca.x+xa.pageX-F,ca.y+xa.pageY-N),!0};this.mouseUp=function(xa,za,cb){if(this.capture&&za==ka)return ka=-1,this.capture=!1,this.transient&&!X(Sb).isPressed("space")&& (x("default"),va.pop()),!0};this.enter=function(){x("grab")}}function l(){}function g(){var F,N=new Ha(0,0,0,0),ca=-1;this.mouseDown=function(ka,xa,za){if(!this.capture&&0==xa&&!ka.altKey&&!X(Sb).isPressed("space"))return ka=U({x:rb,y:hb}),ca=xa,N.makeEmpty(),F=ka,Ja.repaintAll(),this.capture=!0,!0};this.mouseDrag=function(ka){if(!this.capture)return!1;var xa=U({x:rb,y:hb});ka=ka.shiftKey;var za=~~Math.max(Math.abs(xa.x-F.x),Math.abs(xa.y-F.y));return xa.x>=F.x?(N.left=F.x,N.right=(ka?F.x+za:xa.x)+ 1):(N.left=ka?F.x-za:xa.x,N.right=F.x+1),xa.y>=F.y?(N.top=F.y,N.bottom=(ka?F.y+za:xa.y)+1):(N.top=ka?F.y-za:xa.y,N.bottom=F.y+1),Ja.repaintAll(),!0};this.mouseUp=function(ka,xa,za){if(this.capture&&xa==ca)return Ia.rectangleSelection(N),N.makeEmpty(),Ja.repaintAll(),this.capture=!1,ca=-1,!0};this.paint=function(){N.isEmpty()||(ha.lineWidth=1,ja(ha,N))}}function n(){var F,N,ca=!1;this.mouseDown=function(ka,xa,za){if(!this.capture&&0==xa&&!X(Sb).isPressed("space")&&C())return F=L({x:rb,y:hb}),N=ka.altKey, -ca=!0,this.capture=!0,!0};this.mouseDrag=Mg(25,function(ka){if(this.capture){ka=L({x:rb,y:hb});var xa=ka.x-F.x,za=ka.y-F.y,cb=~~xa,gb=~~za;return(0!=cb||0!=gb)&&(Ia.move(cb,gb,N&&ca),ca=!1),F.x=ka.x-(xa-cb),F.y=ka.y-(za-gb),!0}});this.mouseUp=function(ka,xa,za){if(this.capture&&0==xa)return this.capture=!1,this.transient&&va.pop(),!0}}function r(){function F(Ea,Ka){return{x:(Ea.x+Ka.x)/2,y:(Ea.y+Ka.y)/2}}function N(Ea){return{x:Math.round(Ea.x),y:Math.round(Ea.y)}}function ca(Ea,Ka){for(var Ra=0;Ra< -Ea.points.length;Ra++)if(49>=(Ka.x-Ea.points[Ra].x)*(Ka.x-Ea.points[Ra].x)+(Ka.y-Ea.points[Ra].y)*(Ka.y-Ea.points[Ra].y))return 2*Ra;for(Ra=0;Ra=zc&&(pb.scale(zc),49>=(pb.x-nb.x)*(pb.x-nb.x)+(pb.y-nb.y)*(pb.y-nb.y)))return 2*Ra+1}return Ea.containsPoint(Ka)? +ca=!0,this.capture=!0,!0};this.mouseDrag=Ng(25,function(ka){if(this.capture){ka=L({x:rb,y:hb});var xa=ka.x-F.x,za=ka.y-F.y,cb=~~xa,gb=~~za;return(0!=cb||0!=gb)&&(Ia.move(cb,gb,N&&ca),ca=!1),F.x=ka.x-(xa-cb),F.y=ka.y-(za-gb),!0}});this.mouseUp=function(ka,xa,za){if(this.capture&&0==xa)return this.capture=!1,this.transient&&va.pop(),!0}}function r(){function F(Ea,Ka){return{x:(Ea.x+Ka.x)/2,y:(Ea.y+Ka.y)/2}}function N(Ea){return{x:Math.round(Ea.x),y:Math.round(Ea.y)}}function ca(Ea,Ka){for(var Ra=0;Ra< +Ea.points.length;Ra++)if(49>=(Ka.x-Ea.points[Ra].x)*(Ka.x-Ea.points[Ra].x)+(Ka.y-Ea.points[Ra].y)*(Ka.y-Ea.points[Ra].y))return 2*Ra;for(Ra=0;Ra=Ac&&(pb.scale(Ac),49>=(pb.x-nb.x)*(pb.x-nb.x)+(pb.y-nb.y)*(pb.y-nb.y)))return 2*Ra+1}return Ea.containsPoint(Ka)? -3:-2}function ka(){var Ea=gb.getTransformed(Db),Ka=ca(Ea,{x:rb,y:hb});switch(Ka){case 0:case 2:case 4:case 6:Ka=~~(Ka/2);let Ra=Ea.points[Ka],nb=Ea.points[(Ka+1)%4];xa(Mb.subtractPoints(Ea.points[(Ka+3)%4],Ra).normalize().add(Mb.subtractPoints(nb,Ra).normalize()));break;case 1:case 3:case 5:case 7:xa(Mb.subtractPoints(Ea.points[(~~(Ka/2)+1)%4],Ea.points[~~(Ka/2)]).getPerpendicular());break;case -3:x("move");break;default:x("default")}}function xa(Ea){Ea=Math.floor(Math.atan2(-Ea.y,Ea.x)/(Math.PI/ -4)+.5);switch(0>Ea&&(Ea+=4),Ea){default:Ea="ew-resize";break;case 1:Ea="nesw-resize";break;case 2:Ea="ns-resize";break;case 3:Ea="nwse-resize"}x(Ea)}var za,cb,gb,Da,jb,Vb,kc=-1;this.mouseDown=function(Ea,Ka,Ra){if(!this.capture&&0==Ka&&!Ea.altKey&&!X(Sb).isPressed("space"))return kc=ca(gb.getTransformed(Db),{x:rb,y:hb}),jb=L(Da={x:rb,y:hb}),this.capture=!0,ka(),!0};this.mouseDrag=Mg(40,function(Ea){if(this.capture){var Ka={x:rb,y:hb};switch(kc){case -3:Ea=N(L(Ka));var Ra=Mb.subtractPoints(Ea,jb); -Ka=Ra.getTruncated();Ra=Ra.subtract(Ka);var nb=new Kb;nb.translate(Ka.x,Ka.y);za.preMultiply(nb);jb=Mb.subtractPoints(Ea,Ra);break;case -2:nb=Math.PI/4;Ra=gb.getCenter();var pb=T(Ra),vc=Math.atan2(Ka.y-pb.y,Ka.x-pb.x)-Math.atan2(Da.y-pb.y,Da.x-pb.x);pb=new Kb;Vb+=vc;Ea=Ea.shiftKey?-za.decompose().rotate+Math.round(Vb/nb)*nb:vc;pb.rotateAroundPoint(Ea,Ra.x,Ra.y);za.preMultiply(pb);Da=Ka;break;case 0:case 2:case 4:case 6:nb=~~(kc/2);Ra=cb.points[nb];pb=za.getInverted().getTransformedPoint(N(L(Ka))); -Ka=cb.points[(nb+2)%4];nb=(pb.x-Ka.x)/(Ra.x-Ka.x);Ra=(pb.y-Ka.y)/(Ra.y-Ka.y);if(.001>Math.abs(nb)||.001>Math.abs(Ra)||isNaN(nb)||isNaN(Ra))return!0;Ea.shiftKey&&(Ra=nb=Ea=Math.max(nb,Ra));za.scaleAroundPoint(nb,Ra,Ka.x,Ka.y);break;case 1:case 5:case 3:case 7:Ea=~~(kc/2);pb=F(cb.points[Ea],cb.points[(Ea+1)%4]);Ka=za.getInverted().getTransformedPoint(N(L(Ka)));Ea=F(cb.points[(Ea+2)%4],cb.points[(Ea+3)%4]);pb=Mb.subtractPoints(pb,Ea);Ka=Mb.subtractPoints(Ka,Ea);vc=pb.getLength();Ka=pb.getDotProduct(Ka)/ -vc/vc;if(.001>Math.abs(Ka)||isNaN(Ka))return!0;1==kc||5==kc?(Ra=1,nb=Ka):(Ra=Ka,nb=1);za.scaleAroundPoint(Ra,nb,Ea.x,Ea.y)}return gb=cb.getTransformed(za),Ia.transformAffineAmend(za),Ja.repaintAll(),!0}});this.mouseUp=function(Ea,Ka,Ra){if(this.capture&&0==Ka)return this.capture=!1,kc=-1,!0};this.mouseMove=function(){this.capture||ka()};this.paint=function(){var Ea=gb.getTransformed(Db).points,Ka=Array(2*Ea.length);for(var Ra=0;RaEa&&(Ea+=4),Ea){default:Ea="ew-resize";break;case 1:Ea="nesw-resize";break;case 2:Ea="ns-resize";break;case 3:Ea="nwse-resize"}x(Ea)}var za,cb,gb,Da,jb,Vb,kc=-1;this.mouseDown=function(Ea,Ka,Ra){if(!this.capture&&0==Ka&&!Ea.altKey&&!X(Sb).isPressed("space"))return kc=ca(gb.getTransformed(Db),{x:rb,y:hb}),jb=L(Da={x:rb,y:hb}),this.capture=!0,ka(),!0};this.mouseDrag=Ng(40,function(Ea){if(this.capture){var Ka={x:rb,y:hb};switch(kc){case -3:Ea=N(L(Ka));var Ra=Mb.subtractPoints(Ea,jb); +Ka=Ra.getTruncated();Ra=Ra.subtract(Ka);var nb=new Kb;nb.translate(Ka.x,Ka.y);za.preMultiply(nb);jb=Mb.subtractPoints(Ea,Ra);break;case -2:nb=Math.PI/4;Ra=gb.getCenter();var pb=T(Ra),wc=Math.atan2(Ka.y-pb.y,Ka.x-pb.x)-Math.atan2(Da.y-pb.y,Da.x-pb.x);pb=new Kb;Vb+=wc;Ea=Ea.shiftKey?-za.decompose().rotate+Math.round(Vb/nb)*nb:wc;pb.rotateAroundPoint(Ea,Ra.x,Ra.y);za.preMultiply(pb);Da=Ka;break;case 0:case 2:case 4:case 6:nb=~~(kc/2);Ra=cb.points[nb];pb=za.getInverted().getTransformedPoint(N(L(Ka))); +Ka=cb.points[(nb+2)%4];nb=(pb.x-Ka.x)/(Ra.x-Ka.x);Ra=(pb.y-Ka.y)/(Ra.y-Ka.y);if(.001>Math.abs(nb)||.001>Math.abs(Ra)||isNaN(nb)||isNaN(Ra))return!0;Ea.shiftKey&&(Ra=nb=Ea=Math.max(nb,Ra));za.scaleAroundPoint(nb,Ra,Ka.x,Ka.y);break;case 1:case 5:case 3:case 7:Ea=~~(kc/2);pb=F(cb.points[Ea],cb.points[(Ea+1)%4]);Ka=za.getInverted().getTransformedPoint(N(L(Ka)));Ea=F(cb.points[(Ea+2)%4],cb.points[(Ea+3)%4]);pb=Mb.subtractPoints(pb,Ea);Ka=Mb.subtractPoints(Ka,Ea);wc=pb.getLength();Ka=pb.getDotProduct(Ka)/ +wc/wc;if(.001>Math.abs(Ka)||isNaN(Ka))return!0;1==kc||5==kc?(Ra=1,nb=Ka):(Ra=Ka,nb=1);za.scaleAroundPoint(Ra,nb,Ea.x,Ea.y)}return gb=cb.getTransformed(za),Ia.transformAffineAmend(za),Ja.repaintAll(),!0}});this.mouseUp=function(Ea,Ka,Ra){if(this.capture&&0==Ka)return this.capture=!1,kc=-1,!0};this.mouseMove=function(){this.capture||ka()};this.paint=function(){var Ea=gb.getTransformed(Db).points,Ka=Array(2*Ea.length);for(var Ra=0;RaMath.abs(ka-1)?F=1:.2>Math.abs(ka-2)?F=2:.08>Math.abs(ka-.5)&&(F=.5);V(F,N/2,ca/2)}function qa(F){return Rb?P.getPressure():"mouse"===F.pointerType&&0!==F.buttons&&0===F.pressure? -1:"touch"===F.pointerType?(0!==F.pressure&&(Hc=!0),Hc)?2*F.pressure:1:2*F.pressure}function mb(){eb||(eb=!0,window.requestAnimationFrame(function(){Ja.paint()}))}function Xa(F){Va.union(F);mb()}function Lb(){ec=Ia.getBounds();Ja.repaintAll()}let Fb,Ja=this,La=document.createElement("div"),la=document.createElement("div"),Ba=document.createElement("div"),ya=document.createElement("canvas"),ha=ya.getContext("2d"),Oa=document.createElement("canvas"),pa=Oa.getContext("2d"),Ta=Ng(ha),Ia=a.getArtwork(), -lb=1,bc=0,jc=0,Nb=0,Db=new Kb,sb=!1,Wb=!1,kb=32,rb=0,hb=0,Tb=!1,vb=[!1,!1,!1],Rb=!1,Ib=!1,Hc=!1,ec=Ia.getBounds(),Va=new Ha(0,0,0,0),eb=!1,Yb;let Ya,Qc,Rc,A,ua,tc,Mc,Xb,Zc=[],va=new nc,fc,uc=new me(!1),D=new me(!0),P=dd.getRef();Math.sign=Math.sign||function(F){return 0==(F=+F)||isNaN(F)?F:0navigator.maxTouchPoints)&&b.prototype.mouseMove.call(this,F,N),this.capture){F=L({x:rb,y:hb});var ca=Math.min(.999,Math.pow(a.getBrushInfo().smoothing,.3));let ka=1-ca;return this.smoothMouse.x=ka*F.x+ca*this.smoothMouse.x,this.smoothMouse.y=ka*F.y+ca*this.smoothMouse.y,Ia.continueStroke(this.smoothMouse.x, this.smoothMouse.y,N),!0}this.mouseMove(F)};k.prototype.mouseUp=function(F,N,ca){if(this.capture)return 0==N&&(this.capture=!1,Ia.endStroke()),!0};p.prototype=Object.create(b.prototype);p.prototype.constructor=p;p.prototype.drawLine=function(F,N){Ia.beginStroke(F.x,F.y,1);Ia.continueStroke(N.x,N.y,1);Ia.endStroke()};h.prototype=Object.create(b.prototype);h.prototype.constructor=h;e.prototype=Object.create(c.prototype);e.prototype.constructor=e;m.prototype=Object.create(c.prototype);m.prototype.constructor= m;l.prototype=Object.create(c.prototype);l.prototype.constructor=l;l.prototype.mouseDown=function(F,N,ca){if(0==N&&!F.altKey&&!X(Sb).isPressed("space")&&K())return F=L({x:rb,y:hb}),Ia.isPointWithin(F.x,F.y)&&(Ia.floodFill(F.x,F.y),Ja.repaintAll()),!0};g.prototype=Object.create(c.prototype);g.prototype.constructor=g;n.prototype=Object.create(c.prototype);n.prototype.constructor=n;n.prototype.mouseMove=function(F){if(!X(Sb).isPressed("r"))return x("move"),!0};n.prototype.enter=function(){x("move")}; r.prototype=Object.create(c.prototype);r.prototype.constructor=r;u.prototype=Object.create(c.prototype);u.prototype.constructor=u;v.prototype=Object.create(p.prototype);v.prototype.constructor=v;v.prototype.drawLine=function(F,N){Ia.gradientFill(Math.round(F.x),Math.round(F.y),Math.round(N.x),Math.round(N.y),a.getCurGradient())};v.prototype.queueBrushPreview=function(){};this.setZoom=function(F){lb=F;G()};this.getZoom=function(){return lb};this.setGridSize=function(F){kb=Math.max(Math.round(F),1); -this.repaintAll()};this.getGridSize=function(){return kb};this.setOffset=function(F,N){isNaN(F)||isNaN(N)?console.log("Bad offset"):(bc=F,jc=N,G())};this.getOffset=function(){return{x:bc,y:jc}};this.setInterpolation=function(F){sb=F;nf(ha,F);this.repaintAll()};this.setRotation=function(F){Nb=F%(2*Math.PI);G()};this.getRotation=function(){return Nb};this.getRotation90=function(){var F=Math.round(this.getRotation()/Math.PI*2);return 0>(F%=4)&&(F+=4),F};this.zoomIn=function(){Fa(1.41*this.getZoom())}; +this.repaintAll()};this.getGridSize=function(){return kb};this.setOffset=function(F,N){isNaN(F)||isNaN(N)?console.log("Bad offset"):(bc=F,jc=N,G())};this.getOffset=function(){return{x:bc,y:jc}};this.setInterpolation=function(F){sb=F;of(ha,F);this.repaintAll()};this.setRotation=function(F){Nb=F%(2*Math.PI);G()};this.getRotation=function(){return Nb};this.getRotation90=function(){var F=Math.round(this.getRotation()/Math.PI*2);return 0>(F%=4)&&(F+=4),F};this.zoomIn=function(){Fa(1.41*this.getZoom())}; this.zoomOut=function(){Fa(.7092*this.getZoom())};this.zoom100=function(){Fa(1);Na()};this.resetRotation=function(){var F=ya.width/2,N=ya.height/2,ca=new Kb;ca.rotateAroundPoint(-this.getRotation(),F,N);ca.multiply(Db);this.setOffset(~~ca.getTranslateX(),~~ca.getTranslateY());this.setRotation(0);Ja.emitEvent("canvasRotated90",[0])};let da=!1;this.getElement=function(){return La};this.repaintAll=function(){Va.left=0;Va.top=0;Va.right=ya.width;Va.bottom=ya.height;mb()};this.paint=function(){var F=!1; if(eb=!1,Va.isEmpty()||(ha.save(),ha.clipTo&&(ha.beginPath(),Va.left|=0,Va.top|=0,ha.rect(Va.left,Va.top,Math.ceil(Va.getWidth()),Math.ceil(Va.getHeight())),ha.clip()),F=!0),!ec.isEmpty()){var N=Yb&&Yb.isOpen()?Yb.getImageData():Ia.fusionLayers().getImageData();pa.putImageData(N,0,0,ec.left,ec.top,ec.getWidth(),ec.getHeight());ec.makeEmpty()}if(ha.fillStyle="#606060",ha.fillRect(0,0,ya.width,ya.height),ha.save(),ha.setTransform(Db.m[0],Db.m[1],Db.m[2],Db.m[3],Db.m[4],Db.m[5]),ha.fillStyle=Ta,ha.fillRect(0, -0,Ia.width,Ia.height),ha.drawImage(Oa,0,0,Oa.width,Oa.height),ha.restore(),Je(ha,"stroke"),ha.lineWidth=1,Ia.getSelection().isEmpty()||va.peek()instanceof g&&va.peek().capture||(ha.setLineDash([3,2]),ja(ha,Ia.getSelection()),ha.setLineDash([])),Wb)if(N=Ia.getBounds(),2K&&this.setLocation(this.getX(),Math.max(K-x,0))) "modal-header";v.className="modal-title";v.appendChild(document.createTextNode(this.title));v.appendChild(p);c.appendChild(v);c.appendChild(h);d.appendChild(c);e.className="chickenpaint-palette-body";k.appendChild(d);k.appendChild(e);this.resizeVert&&((m=document.createElement("div")).className="chickenpaint-resize-handle-vert",m.addEventListener("pointerdown",function(x){n="vertResize";m.setPointerCapture(x.pointerId)}),m.addEventListener("pointermove",function(x){"vertResize"==n&&u.setHeight(x.pageY- X(ia)(k).offset().top)}),m.addEventListener("pointerup",function(x){m.releasePointerCapture(x.pointerId);n=!1}),k.appendChild(m));this.resizeHorz&&((l=document.createElement("div")).className="chickenpaint-resize-handle-horz",l.addEventListener("pointerdown",function(x){n="horzResize";l.setPointerCapture(x.pointerId)}),l.addEventListener("pointermove",function(x){"horzResize"==n&&u.setWidth(x.pageX-X(ia)(k).offset().left)}),l.addEventListener("pointerup",function(x){l.releasePointerCapture(x.pointerId); n=!1}),k.appendChild(l));d.addEventListener("pointerdown",function(x){0==x.button&&(x.stopPropagation(),x.preventDefault(),"BUTTON"==x.target.nodeName?u.emitEvent("paletteVisChange",[u,!1]):(g={x:parseInt(k.style.left,10)||0,y:parseInt(k.style.top,10)||0},r={x:x.pageX-X(ia)(k).position().left,y:x.pageY-X(ia)(k).position().top},n=a.getSmallScreenMode()?"dragStart":"dragging",x.target.setPointerCapture(x.pointerId)))});d.addEventListener("pointermove",function(x){if(("dragStart"===n||"dragging"===n)&& -0!==x.buttons){let I=x.pageX-r.x,G=x.pageY-r.y;if("dragStart"==n){x=I;var C=G;var K=g;25<(x-K.x)*(x-K.x)+(C-K.y)*(C-K.y)&&(n="dragging")}"dragging"==n&&u.setLocation(I,G)}});d.addEventListener("pointerup",function(x){if("dragging"===n||"dragStart"===n){"dragStart"===n&&(x.stopPropagation(),x.preventDefault(),setTimeout(()=>{u.setLocation(g.x,g.y);u.toggleCollapse()},100));n=!1;try{x.target.releasePointerCapture(x.pointerId)}catch(C){console.error(C)}}})}function Le(a){function c(p){"LI"==this.nodeName&& +0!==x.buttons){let I=x.pageX-r.x,G=x.pageY-r.y;if("dragStart"==n){x=I;var C=G;var K=g;25<(x-K.x)*(x-K.x)+(C-K.y)*(C-K.y)&&(n="dragging")}"dragging"==n&&u.setLocation(I,G)}});d.addEventListener("pointerup",function(x){if("dragging"===n||"dragStart"===n){"dragStart"===n&&(x.stopPropagation(),x.preventDefault(),setTimeout(()=>{u.setLocation(g.x,g.y);u.toggleCollapse()},100));n=!1;try{x.target.releasePointerCapture(x.pointerId)}catch(C){console.error(C)}}})}function Me(a){function c(p){"LI"==this.nodeName&& (p=b[parseInt(this.getAttribute("data-buttonIndex"),10)],a.actionPerformed({action:p.command}))}lc.call(this,a,"tool","Tools");let d=this,b=[{className:"chickenpaint-tool-rect-selection",command:"CPRectSelection",toolTip:"Marquee",shortcut:"m",mode:na.M_RECT_SELECTION},{className:"chickenpaint-tool-move",command:"CPMoveTool",toolTip:"Move tool",shortcut:"v",mode:na.M_MOVE_TOOL},{className:"chickenpaint-tool-flood-fill",command:"CPFloodFill",toolTip:"Flood fill",shortcut:"f",mode:na.M_FLOODFILL},{className:"chickenpaint-tool-gradient-fill", command:"CPGradientFill",toolTip:"Gradient fill",shortcut:"g",mode:na.M_GRADIENTFILL},{className:"chickenpaint-tool-color-picker",command:"CPColorPicker",toolTip:"Color picker",shortcut:"i",mode:na.M_COLOR_PICKER},{className:"chickenpaint-tool-blur",command:"CPBlur",toolTip:"Blur",shortcut:"u",mode:na.M_DRAW,tool:na.T_BLUR},{className:"chickenpaint-tool-pencil",command:"CPPencil",toolTip:"Pencil",shortcut:"n",mode:na.M_DRAW,tool:na.T_PENCIL},{className:"chickenpaint-tool-pen",command:"CPPen",toolTip:"Pen", selected:!0,shortcut:"b",mode:na.M_DRAW,tool:na.T_PEN},{className:"chickenpaint-tool-airbrush",command:"CPAirbrush",toolTip:"Airbrush",shortcut:"a",mode:na.M_DRAW,tool:na.T_AIRBRUSH},{className:"chickenpaint-tool-water",command:"CPWater",toolTip:"Waterpaint",shortcut:"w",mode:na.M_DRAW,tool:na.T_WATER},{className:"chickenpaint-tool-eraser",command:"CPEraser",toolTip:"Eraser",shortcut:"e",mode:na.M_DRAW,tool:na.T_ERASER},{className:"chickenpaint-tool-soft-eraser",command:"CPSoftEraser",toolTip:"Soft eraser", @@ -251,38 +251,38 @@ shortcut:"s",mode:na.M_DRAW,tool:na.T_SOFTERASER},{className:"chickenpaint-tool- mode:na.M_DRAW,tool:na.T_BURN},{className:"chickenpaint-tool-rotate-canvas",command:"CPRotateCanvas",commandDoubleClick:"CPResetCanvasRotation",toolTip:"Rotate canvas",mode:na.M_ROTATE_CANVAS},{className:"chickenpaint-tool-pan-canvas",command:"CPPanCanvas",toolTip:"Grab canvas",mode:na.M_PAN_CANVAS}],k=document.createElement("ul");a.on("modeChange",function(p){let h=d.getBodyElement();X(ia)("li",h).removeClass("selected");p==na.M_DRAW?X(ia)("li[data-tool="+a.getCurTool()+"]",h).addClass("selected"): X(ia)("li[data-mode="+p+"]",h).addClass("selected")});a.on("toolChange",function(p){let h=d.getBodyElement();a.getCurMode()==na.M_DRAW&&(X(ia)("li",h).removeClass("selected"),X(ia)("li[data-tool="+p+"]",h).addClass("selected"))});(function(){let p=d.getBodyElement();for(let h in k.className="chickenpaint-tools list-unstyled",b)!function(e){let m=b[e],l=document.createElement("li"),g=document.createElement("div");l.className="chickenpaint-toolbar-button "+m.className;l.setAttribute("data-buttonIndex", e);l.setAttribute("data-mode",m.mode);void 0!==m.tool&&l.setAttribute("data-tool",m.tool);l.title=ma(m.toolTip);m.shortcut&&(l.title+=" ("+m.shortcut.toUpperCase()+")",X(Sb)(m.shortcut,function(){return c.call(l),!1}));m.selected&&(l.className+=" selected");g.className="chickenpaint-toolbar-button-icon";l.appendChild(g);k.appendChild(l)}(h);X(ia)(k).on("click","li",c).on("dblclick","li",function(h){h=b[parseInt(this.getAttribute("data-buttonIndex"),10)];h.commandDoubleClick&&a.actionPerformed({action:h.commandDoubleClick})}); -p.appendChild(k)})()}function Me(a){lc.call(this,a,"misc","Misc");let c=this,d=[{className:"chickenpaint-tool-zoom-in",command:"CPZoomIn",toolTip:"Zoom in"},{className:"chickenpaint-tool-zoom-out",command:"CPZoomOut",toolTip:"Zoom out"},{className:"chickenpaint-tool-zoom-100",command:"CPZoom100",toolTip:"Zoom 100%"},{className:"chickenpaint-tool-flip-horizontal",command:"CPHFlip",toolTip:"Flip horizontal"},{className:"chickenpaint-tool-undo",command:"CPUndo",toolTip:"Undo"},{className:"chickenpaint-tool-redo", +p.appendChild(k)})()}function Ne(a){lc.call(this,a,"misc","Misc");let c=this,d=[{className:"chickenpaint-tool-zoom-in",command:"CPZoomIn",toolTip:"Zoom in"},{className:"chickenpaint-tool-zoom-out",command:"CPZoomOut",toolTip:"Zoom out"},{className:"chickenpaint-tool-zoom-100",command:"CPZoom100",toolTip:"Zoom 100%"},{className:"chickenpaint-tool-flip-horizontal",command:"CPHFlip",toolTip:"Flip horizontal"},{className:"chickenpaint-tool-undo",command:"CPUndo",toolTip:"Undo"},{className:"chickenpaint-tool-redo", command:"CPRedo",toolTip:"Redo"},{className:"chickenpaint-tool-send",command:"CPSend",toolTip:"Save Oekaki"}];!function(){let b=c.getBodyElement(),k=document.createElement("ul");for(let p in k.className="chickenpaint-misc-tools list-unstyled",d){let h=d[p],e=document.createElement("li"),m=document.createElement("div");"CPSend"!=h.command||a.isActionSupported("CPContinue")||(h.toolTip="Post Oekaki",h.className="chickenpaint-tool-send-and-end");e.className="chickenpaint-toolbar-button "+h.className; -e.setAttribute("data-buttonIndex",p);e.setAttribute("title",ma(h.toolTip));m.className="chickenpaint-toolbar-button-icon";e.appendChild(m);k.appendChild(e)}X(ia)(k).on("mousedown","li",function(p){X(ia)(this).addClass("selected")}).on("mouseup","li",function(p){X(ia)(this).removeClass("selected")}).on("click","li",function(p){p=d[parseInt(this.getAttribute("data-buttonIndex"),10)];a.actionPerformed({action:p.command})});b.appendChild(k)}()}function Ne(a){lc.call(this,a,"stroke","Stroke");let c=[{className:"chickenpaint-tool-freehand", +e.setAttribute("data-buttonIndex",p);e.setAttribute("title",ma(h.toolTip));m.className="chickenpaint-toolbar-button-icon";e.appendChild(m);k.appendChild(e)}X(ia)(k).on("mousedown","li",function(p){X(ia)(this).addClass("selected")}).on("mouseup","li",function(p){X(ia)(this).removeClass("selected")}).on("click","li",function(p){p=d[parseInt(this.getAttribute("data-buttonIndex"),10)];a.actionPerformed({action:p.command})});b.appendChild(k)}()}function Oe(a){lc.call(this,a,"stroke","Stroke");let c=[{className:"chickenpaint-tool-freehand", command:"CPFreeHand",toolTip:ma("Free-hand"),selected:!0},{className:"chickenpaint-tool-line",command:"CPLine",toolTip:ma("Straight line")},{className:"chickenpaint-tool-bezier",command:"CPBezier",toolTip:ma("Bezier curve")}],d=this.getBodyElement();!function(){let b=document.createElement("ul");for(let k in b.className="chickenpaint-stroke-tools list-unstyled",c){let p=c[k],h=document.createElement("li"),e=document.createElement("div");h.className="chickenpaint-toolbar-button "+p.className;h.setAttribute("data-buttonIndex", k);h.setAttribute("title",p.toolTip);p.selected&&(h.className+=" selected");e.className="chickenpaint-toolbar-button-icon";h.appendChild(e);b.appendChild(h)}X(ia)(b).on("click","li",function(k){k=c[parseInt(this.getAttribute("data-buttonIndex"),10)];X(ia)("li",b).removeClass("selected");X(ia)(this).addClass("selected");a.actionPerformed({action:k.command})});d.appendChild(b)}();a.on("toolChange",function(b,k){X(ia)(".chickenpaint-tool-freehand",d).toggleClass("selected",k.strokeMode==Ca.STROKE_MODE_FREEHAND); -X(ia)(".chickenpaint-tool-line",d).toggleClass("selected",k.strokeMode==Ca.STROKE_MODE_LINE);X(ia)(".chickenpaint-tool-bezier",d).toggleClass("selected",k.strokeMode==Ca.STROKE_MODE_BEZIER)})}function Ac(a,c,d){return c in a?Object.defineProperty(a,c,{value:d,enumerable:!0,configurable:!0,writable:!0}):a[c]=d,a}function Oe(a){lc.call(this,a,"color","Color (picker)");let c=new Og(a),d=new Pg(a,c);a=new Nh(a);let b=this.getBodyElement(),k=document.createElement("div");k.className="chickenpaint-colorpicker-top"; +X(ia)(".chickenpaint-tool-line",d).toggleClass("selected",k.strokeMode==Ca.STROKE_MODE_LINE);X(ia)(".chickenpaint-tool-bezier",d).toggleClass("selected",k.strokeMode==Ca.STROKE_MODE_BEZIER)})}function Bc(a,c,d){return c in a?Object.defineProperty(a,c,{value:d,enumerable:!0,configurable:!0,writable:!0}):a[c]=d,a}function Pe(a){lc.call(this,a,"color","Color (picker)");let c=new Pg(a),d=new Qg(a,c);a=new Nh(a);let b=this.getBodyElement(),k=document.createElement("div");k.className="chickenpaint-colorpicker-top"; k.appendChild(c.getElement());k.appendChild(d.getElement());b.appendChild(k);b.appendChild(a.getElement())}function Nh(a){function c(p,h,e){for(;p.length=g/2?l.rect(x/2,0,(v.value-g/2)*x/g,C):l.rect(v.value*x/g,0,(g/2-v.value)*x/g,C),l.fill(),l.clip(),l.fillStyle="white";else{var L=(v.value-a)/g;b&&(L=Math.pow(L,.6666666666666666));L*=x;l.save();l.save();l.fillStyle="black";l.beginPath();l.rect(0,0,L,C);l.fill();l.clip();l.fillStyle="white";l.fillText(K,I,G);l.restore();l.fillStyle="white";l.beginPath();l.rect(L,0,x,C);l.fill();l.clip();l.fillStyle="black"}l.fillText(K,I,G);l.restore()}function h(x){let C=X(ia)(m).width(),K=X(ia)(m).offset().left; x=(x.pageX-K)/C;b&&(x=Math.pow(Math.max(x,0),1.5));v.setValue(x*g+a)}function e(x){switch(n){case 1:return h(x);case 2:var C=v.title();if(!C.includes(ma("Brush size"))&&!C.includes(ma("Opacity")))return h(x);C=(x.pageX-r)/4;if(0!==C){C=v.value+C;let K=Math.floor(C);v.setValue(K);r=x.pageX-4*(C-K)}}}let m=document.createElement("canvas"),l=m.getContext("2d"),g=c-a,n=0,r,u=!1,v=this;this.value=void 0;this.title="";d=d||!1;m.addEventListener("pointerup",x=>{if(0===n)return m.releasePointerCapture(x.pointerId), m.removeEventListener("pointermove",e);if(0!==n)switch(n){case 1:0!==x.button||x.shiftKey||(n=0);break;case 2:(2==x.button||0===x.button&&x.shiftKey)&&(n=0);break;default:return}return m.releasePointerCapture(x.pointerId),m.removeEventListener("pointermove",e)});this.setValue=function(x){x=~~Math.max(a,Math.min(c,x));this.value!=x&&(this.value=x,this.emitEvent("valueChange",[this.value]),u?p():(u=!0,this.resize()))};this.getElement=function(){return m};this.resize=function(){m.width=X(ia)(m).width()|| k;m.height=X(ia)(m).height()||20;1n.length;)n="0"+n;g.backgroundColor="#"+n}let k=this,p=new Bb(0),h=255,e=document.createElement("div");this.getElement=function(){return e};this.setColor=function(g){p.isEqual(g)||(p.copyFrom(g),b(),this.emitEvent("colorChange",[p]))};this.setAlpha=function(g){g!=h&&(h=g,b(),this.emitEvent("alphaChange",[h]))};this.getColorRgb=function(){return p.getRgb()}; -this.getAlpha=function(){return h};this.setCurColor=this.setColor;e.className="chickenpaint-color-pick-swatch";a&&p.copyFrom(a);c&&(h=c);let m=new bootstrap.Popover(e,{html:!0,content:function(){return window.addEventListener("mousedown",l),function(){let g=document.createElement("div"),n=document.createElement("div"),r=new Og(k,p),u=new Pg(k,r,p.getHue()),v=new Ec(0,255);return g.className="chickenpaint-color-pick-panel",n.className="chickenpaint-colorpicker-top",n.appendChild(r.getElement()),n.appendChild(u.getElement()), +"chickenpaint-slider";"devicePixelRatio"in window||(window.devicePixelRatio=1)}function oe(a,c,d){function b(){for(var g=e.style,n=Number(p.getRgb()).toString(16);6>n.length;)n="0"+n;g.backgroundColor="#"+n}let k=this,p=new Bb(0),h=255,e=document.createElement("div");this.getElement=function(){return e};this.setColor=function(g){p.isEqual(g)||(p.copyFrom(g),b(),this.emitEvent("colorChange",[p]))};this.setAlpha=function(g){g!=h&&(h=g,b(),this.emitEvent("alphaChange",[h]))};this.getColorRgb=function(){return p.getRgb()}; +this.getAlpha=function(){return h};this.setCurColor=this.setColor;e.className="chickenpaint-color-pick-swatch";a&&p.copyFrom(a);c&&(h=c);let m=new oc.Popover(e,{html:!0,content:function(){return window.addEventListener("mousedown",l),function(){let g=document.createElement("div"),n=document.createElement("div"),r=new Pg(k,p),u=new Qg(k,r,p.getHue()),v=new Fc(0,255);return g.className="chickenpaint-color-pick-panel",n.className="chickenpaint-colorpicker-top",n.appendChild(r.getElement()),n.appendChild(u.getElement()), g.appendChild(n),v.value=h,v.title=function(x){return ma("Opacity: ")+x},v.on("valueChange",function(x){k.setAlpha(x)}),g.appendChild(v.getElement()),setTimeout(function(){v.resize()},0),g}()},trigger:"manual",placement:"bottom",container:d||!1}),l=function(g){var n=g.target;n=n.closest(".popover-body")||n.classList.contains("chickenpaint-color-pick-panel")||n.classList.contains("chickenpaint-colorpicker-select")||n.classList.contains("chickenpaint-colorpicker-slider");g.preventDefault();n||m.hide()}; -e.addEventListener("click",function(g){g.preventDefault();m.toggle()});e.addEventListener("hidden.bs.popover",function(){window.removeEventListener("mousedown",l)});b()}function Ff(a,c){let d=document.createElement("div");return d.className="chickenpaint-checkbox-slider-group",d.appendChild(a.getElement()),d.appendChild(c.getElement()),d}function Qg(a,c){for(let d in c)if(c.hasOwnProperty(d)){let b=document.createElement("option");b.appendChild(document.createTextNode(ma(c[d])));b.value=d;a.appendChild(b)}} -function Oh(a){function c(){p.gradient(p.getBounds(),0,0,p.width,0,m,!0);e.putImageData(p.imageData,0,0,0,0,150,32);b.fillRect(0,0,d.width,d.height);b.drawImage(h,0,0)}let d=document.createElement("canvas"),b=d.getContext("2d"),k=Ng(b),p=new H(150,32),h=document.createElement("canvas"),e=h.getContext("2d"),m=a.getCurGradient();this.getElement=function(){return d};a.on("gradientChange",function(l){m=l;c()});d.width=h.width=150;d.height=h.height=32;d.className="chickenpaint-gradient-preview";b.fillStyle= -k;c()}function Sd(a){lc.call(this,a,"brush","Tool options");let c=new Ph(a),d=new Qh(a),b=new Rh(a),k=this.getBodyElement();k.appendChild(c.getElement());k.appendChild(d.getElement());k.appendChild(b.getElement());a.on("modeChange",function(p){switch(c.getElement().style.display="none",d.getElement().style.display="none",b.getElement().style.display="none",p){case na.M_GRADIENTFILL:d.getElement().style.display="block";break;case na.M_TRANSFORM:b.getElement().style.display="block";break;default:c.getElement().style.display= -"block"}})}function Ph(a){let c=[1,2,3,4,5,6,7,8,9,10,15,20,25,30,35,40,45,50,60,70,80,90,100,125,150,175,200],d=document.createElement("div"),b=document.createElement("select"),k=new Rd(!1,ma("Control brush opacity with pen pressure")),p=new Ec(1,255),h=new Rd(!0,ma("Control brush size with pen pressure")),e=new Ec(1,200,!1,!0),m=new Rd(!1,ma("Control brush scattering with pen pressure")),l=new Ec(0,1E3,!1,!0),g=new Ec(0,100,!1,!0),n=new Ec(0,100,!1,!0),r=new Ec(0,100,!1,!0),u=new Ec(0,100,!1,!0), -v=new Sd.CPBrushPreview(a);this.getElement=function(){return d};p.title=function(x){return ma("Opacity")+": "+x};p.on("valueChange",function(x){a.setAlpha(x)});e.title=function(x){return ma("Brush size")+": "+x};e.on("valueChange",function(x){a.setBrushSize(x)});g.title=function(x){return ma("Color")+": "+x+"%"};g.on("valueChange",function(x){a.getBrushInfo().resat=x/100;a.callToolListeners()});n.title=function(x){return ma("Blend")+": "+x+"%"};n.on("valueChange",function(x){a.getBrushInfo().bleed= +e.addEventListener("click",function(g){g.preventDefault();m.toggle()});e.addEventListener("hidden.bs.popover",function(){window.removeEventListener("mousedown",l)});b()}function Gf(a,c){let d=document.createElement("div");return d.className="chickenpaint-checkbox-slider-group",d.appendChild(a.getElement()),d.appendChild(c.getElement()),d}function Rg(a,c){for(let d in c)if(c.hasOwnProperty(d)){let b=document.createElement("option");b.appendChild(document.createTextNode(ma(c[d])));b.value=d;a.appendChild(b)}} +function Oh(a){function c(){p.gradient(p.getBounds(),0,0,p.width,0,m,!0);e.putImageData(p.imageData,0,0,0,0,150,32);b.fillRect(0,0,d.width,d.height);b.drawImage(h,0,0)}let d=document.createElement("canvas"),b=d.getContext("2d"),k=Og(b),p=new H(150,32),h=document.createElement("canvas"),e=h.getContext("2d"),m=a.getCurGradient();this.getElement=function(){return d};a.on("gradientChange",function(l){m=l;c()});d.width=h.width=150;d.height=h.height=32;d.className="chickenpaint-gradient-preview";b.fillStyle= +k;c()}function Td(a){lc.call(this,a,"brush","Tool options");let c=new Ph(a),d=new Qh(a),b=new Rh(a),k=this.getBodyElement();k.appendChild(c.getElement());k.appendChild(d.getElement());k.appendChild(b.getElement());a.on("modeChange",function(p){switch(c.getElement().style.display="none",d.getElement().style.display="none",b.getElement().style.display="none",p){case na.M_GRADIENTFILL:d.getElement().style.display="block";break;case na.M_TRANSFORM:b.getElement().style.display="block";break;default:c.getElement().style.display= +"block"}})}function Ph(a){let c=[1,2,3,4,5,6,7,8,9,10,15,20,25,30,35,40,45,50,60,70,80,90,100,125,150,175,200],d=document.createElement("div"),b=document.createElement("select"),k=new Sd(!1,ma("Control brush opacity with pen pressure")),p=new Fc(1,255),h=new Sd(!0,ma("Control brush size with pen pressure")),e=new Fc(1,200,!1,!0),m=new Sd(!1,ma("Control brush scattering with pen pressure")),l=new Fc(0,1E3,!1,!0),g=new Fc(0,100,!1,!0),n=new Fc(0,100,!1,!0),r=new Fc(0,100,!1,!0),u=new Fc(0,100,!1,!0), +v=new Td.CPBrushPreview(a);this.getElement=function(){return d};p.title=function(x){return ma("Opacity")+": "+x};p.on("valueChange",function(x){a.setAlpha(x)});e.title=function(x){return ma("Brush size")+": "+x};e.on("valueChange",function(x){a.setBrushSize(x)});g.title=function(x){return ma("Color")+": "+x+"%"};g.on("valueChange",function(x){a.getBrushInfo().resat=x/100;a.callToolListeners()});n.title=function(x){return ma("Blend")+": "+x+"%"};n.on("valueChange",function(x){a.getBrushInfo().bleed= x/100;a.callToolListeners()});r.title=function(x){return ma("Spacing")+": "+x+"%"};r.on("valueChange",function(x){a.getBrushInfo().spacing=x/100;a.callToolListeners()});l.title=function(x){return ma("Scattering")+": "+x+"%"};l.on("valueChange",function(x){a.getBrushInfo().scattering=x/100;a.callToolListeners()});u.title=function(x){return ma("Smoothing")+": "+x+"%"};u.on("valueChange",function(x){a.getBrushInfo().smoothing=x/100;a.callToolListeners()});m.on("valueChange",function(x){a.getBrushInfo().pressureScattering= -x;a.callToolListeners()});k.on("valueChange",function(x){a.getBrushInfo().pressureAlpha=x;a.callToolListeners()});h.on("valueChange",function(x){a.getBrushInfo().pressureSize=x;a.callToolListeners()});b.addEventListener("change",function(x){a.getBrushInfo().tip=parseInt(b.value,10);b.blur()});b.className="form-control form-control-sm";b.tabIndex=-1;Qg(b,["Round Pixelated","Round Hard Edge","Round Soft","Square Pixelated","Square Hard Edge"]);d.appendChild(b);d.appendChild(v.getElement());d.appendChild(Ff(h, -e));d.appendChild(Ff(k,p));d.appendChild(g.getElement());d.appendChild(n.getElement());d.appendChild(r.getElement());d.appendChild(Ff(m,l));d.appendChild(u.getElement());k.setValue(a.getBrushInfo().pressureAlpha);p.setValue(a.getAlpha());h.setValue(a.getBrushInfo().pressureSize);e.setValue(a.getBrushSize());m.setValue(a.getBrushInfo().pressureScattering);l.setValue(~~(100*a.getBrushInfo().scattering));b.value=a.getBrushInfo().tip;g.setValue(~~(100*a.getBrushInfo().resat));n.setValue(~~(100*a.getBrushInfo().bleed)); +x;a.callToolListeners()});k.on("valueChange",function(x){a.getBrushInfo().pressureAlpha=x;a.callToolListeners()});h.on("valueChange",function(x){a.getBrushInfo().pressureSize=x;a.callToolListeners()});b.addEventListener("change",function(x){a.getBrushInfo().tip=parseInt(b.value,10);b.blur()});b.className="form-control form-control-sm";b.tabIndex=-1;Rg(b,["Round Pixelated","Round Hard Edge","Round Soft","Square Pixelated","Square Hard Edge"]);d.appendChild(b);d.appendChild(v.getElement());d.appendChild(Gf(h, +e));d.appendChild(Gf(k,p));d.appendChild(g.getElement());d.appendChild(n.getElement());d.appendChild(r.getElement());d.appendChild(Gf(m,l));d.appendChild(u.getElement());k.setValue(a.getBrushInfo().pressureAlpha);p.setValue(a.getAlpha());h.setValue(a.getBrushInfo().pressureSize);e.setValue(a.getBrushSize());m.setValue(a.getBrushInfo().pressureScattering);l.setValue(~~(100*a.getBrushInfo().scattering));b.value=a.getBrushInfo().tip;g.setValue(~~(100*a.getBrushInfo().resat));n.setValue(~~(100*a.getBrushInfo().bleed)); r.setValue(~~(100*a.getBrushInfo().spacing));u.setValue(~~(100*a.getBrushInfo().smoothing));a.on("toolChange",function(x,C){p.setValue(C.alpha);e.setValue(C.size);h.setValue(C.pressureSize);k.setValue(C.pressureAlpha);b.value=C.tip;m.setValue(C.pressureScattering);~~(100*C.resat)!=g.value&&g.setValue(~~(100*C.resat));~~(100*C.bleed)!=n.value&&n.setValue(~~(100*C.bleed));~~(100*C.spacing)!=r.value&&r.setValue(~~(100*C.spacing));~~(100*C.scattering)!=l.value&&l.setValue(~~(100*C.scattering));~~(100* C.smoothing)!=u.value&&u.setValue(~~(100*C.smoothing))});X(Sb)("1,2,3,4,5,6,7,8,9,0",function(x,C){x=parseInt(C.shortcut,10);0==x&&(x=10);a.setAlpha(Math.round(x/10*255))});X(Sb)("{,[",function(){let x=a.getBrushSize();for(let C=c.length-1;0<=C;C--)if(x>c[C]){a.setBrushSize(c[C]);break}});X(Sb)("},]",function(){let x=a.getBrushSize();for(let C=0;C>>24,b),h=new ne(new Bb(16777215&a.getCurGradient()[1]),a.getCurGradient()[1]>>>24,b);this.getElement=function(){return b};b.className="chickenpaint-gradient-panel";b.style.display="none";p.on("colorChange",c);p.on("alphaChange",c);h.on("colorChange",c);h.on("alphaChange",c);(d=document.createElement("p")).textContent=ma("Gradient");b.appendChild(d); +a.setCurGradient(e)}var d;let b=document.createElement("div");var k=new Oh(a);let p=new oe(new Bb(16777215&a.getCurGradient()[0]),a.getCurGradient()[0]>>>24,b),h=new oe(new Bb(16777215&a.getCurGradient()[1]),a.getCurGradient()[1]>>>24,b);this.getElement=function(){return b};b.className="chickenpaint-gradient-panel";b.style.display="none";p.on("colorChange",c);p.on("alphaChange",c);h.on("colorChange",c);h.on("alphaChange",c);(d=document.createElement("p")).textContent=ma("Gradient");b.appendChild(d); b.appendChild(k.getElement());(d=document.createElement("div")).className="chickenpaint-gradient-colors";(k=document.createElement("div")).className="chickenpaint-gradient-start-color";k.appendChild(p.getElement());d.appendChild(k);(k=document.createElement("div")).className="chickenpaint-gradient-end-color";k.appendChild(h.getElement());d.appendChild(k);b.appendChild(d)}function Rh(a){var c={smooth:ma("Smooth"),sharp:ma("Sharp")};let d=document.createElement("div"),b=document.createElement("button"), -k=document.createElement("button");var p=document.createElement("select");if(this.getElement=function(){return d},d.className="chickenpaint-transform-panel",d.style.display="none",b.type="button",k.type="button",b.className="btn btn-primary btn-block",k.className="btn btn-light btn-block",b.textContent=ma("Apply transform"),k.textContent=ma("Cancel"),p.addEventListener("change",function(h){a.setTransformInterpolation(this.value)}),p.className="form-control chickenpaint-transform-interpolation",Qg(p, -c),mf(Yc(0,0).getContext("2d"))){c=document.createElement("div");let h=document.createElement("label");h.textContent=ma("Transform style");c.className="form-group";c.appendChild(h);c.appendChild(p);d.appendChild(c)}p=document.createElement("div");p.appendChild(b);p.appendChild(k);p.className="form-group";d.appendChild(p);b.addEventListener("click",function(h){a.actionPerformed({action:"CPTransformAccept"});h.preventDefault()});k.addEventListener("click",function(h){a.actionPerformed({action:"CPTransformReject"}); -h.preventDefault()})}function Sh(a){a.preventDefault();a.stopPropagation()}function Ic(a){let c=document.createElement("span");return c.className="fa "+a,c}function Gf(a){let c=document.createElement("span");return c.className="chickenpaint-icon chickenpaint-icon-"+a,c}function Rg(a,c){let d=document.createElement("div"),b=document.createElement("label");return b.tabIndex=-1,a.tabIndex=-1,d.className="form-check",a.className="form-check-input",b.className="form-check-label",b.setAttribute("for",a.id), -b.appendChild(a),b.appendChild(document.createTextNode(c)),d.appendChild(a),d.appendChild(b),d}function Pe(a){function c(){let G=k.getActiveLayer();G.getAlpha()!=l.value&&l.setValue(G.getAlpha());(function(){let L=k.getActiveLayer();for(;g.lastChild;)g.removeChild(g.lastChild);for(let U=S.LM_FIRST;U<=S.LM_LAST;U++)if(U!=S.LM_MULTIPLY2&&(U==L.blendMode||U===S.LM_PASSTHROUGH&&L instanceof ob||U<=S.LM_LAST_CHIBIPAINT)){let T=document.createElement("option");T.appendChild(document.createTextNode(ma(S.BLEND_MODE_DISPLAY_NAMES[U]))); +k=document.createElement("button");var p=document.createElement("select");if(this.getElement=function(){return d},d.className="chickenpaint-transform-panel",d.style.display="none",b.type="button",k.type="button",b.className="btn btn-primary btn-block",k.className="btn btn-light btn-block",b.textContent=ma("Apply transform"),k.textContent=ma("Cancel"),p.addEventListener("change",function(h){a.setTransformInterpolation(this.value)}),p.className="form-control chickenpaint-transform-interpolation",Rg(p, +c),nf(Zc(0,0).getContext("2d"))){c=document.createElement("div");let h=document.createElement("label");h.textContent=ma("Transform style");c.className="form-group";c.appendChild(h);c.appendChild(p);d.appendChild(c)}p=document.createElement("div");p.appendChild(b);p.appendChild(k);p.className="form-group";d.appendChild(p);b.addEventListener("click",function(h){a.actionPerformed({action:"CPTransformAccept"});h.preventDefault()});k.addEventListener("click",function(h){a.actionPerformed({action:"CPTransformReject"}); +h.preventDefault()})}function Sh(a){a.preventDefault();a.stopPropagation()}function Jc(a){let c=document.createElement("span");return c.className="fa "+a,c}function Hf(a){let c=document.createElement("span");return c.className="chickenpaint-icon chickenpaint-icon-"+a,c}function Sg(a,c){let d=document.createElement("div"),b=document.createElement("label");return b.tabIndex=-1,a.tabIndex=-1,d.className="form-check",a.className="form-check-input",b.className="form-check-label",b.setAttribute("for",a.id), +b.appendChild(a),b.appendChild(document.createTextNode(c)),d.appendChild(a),d.appendChild(b),d}function Qe(a){function c(){let G=k.getActiveLayer();G.getAlpha()!=l.value&&l.setValue(G.getAlpha());(function(){let L=k.getActiveLayer();for(;g.lastChild;)g.removeChild(g.lastChild);for(let U=S.LM_FIRST;U<=S.LM_LAST;U++)if(U!=S.LM_MULTIPLY2&&(U==L.blendMode||U===S.LM_PASSTHROUGH&&L instanceof ob||U<=S.LM_LAST_CHIBIPAINT)){let T=document.createElement("option");T.appendChild(document.createTextNode(ma(S.BLEND_MODE_DISPLAY_NAMES[U]))); U!==S.LM_MULTIPLY||L.blendMode===U||L.useLegacyMultiply?T.value=U:T.value=S.LM_MULTIPLY2;g.appendChild(T)}})();G.getBlendMode()!=parseInt(g.value,10)&&(g.value=G.getBlendMode());G.getLockAlpha()!=u.checked&&(u.checked=G.getLockAlpha());(function(){var L;let U={"image-layer":(L=k.getActiveLayer())instanceof Ma,"layer-group":L instanceof ob,"clipping-mask":L instanceof Ma&&L.clip,"no-clipping-mask":L instanceof Ma&&!L.clip,"no-clipping-mask-or-is-group":!(L instanceof Ma)||!L.clip,mask:L&&null!==L.mask, "no-mask":L&&null===L.mask,"mask-enabled":L&&null!==L.mask&&L.maskVisible,"mask-disabled":L&&null!==L.mask&&!L.maskVisible};for(let T of"mask no-mask clipping-mask no-clipping-mask-or-is-group image-layer layer-group".split(" "))for(let Y of x.getElementsByClassName("chickenpaint-action-require-"+T))Y.style.display=U[T]?"inline-block":"none";x.querySelectorAll("[data-action]").forEach(function(T){let Y=T.getAttribute("data-action");T.classList.toggle("disabled",!a.isActionAllowed(Y))})})()}function d(){k= this;m.resize();c()}lc.call(this,a,"layers","Layers",{resizeHorz:!0,resizeVert:!0});let b=this,k=a.getArtwork(),p=null,h=this.getBodyElement(),e=this.getElement(),m=new function(){function G(La){let la=X(ia)(".chickenpaint-layer",Xa);return la.get(la.length-1-La)}function L(La){La=X(ia)(La).closest(".chickenpaint-layer");if(!La.length)return-1;let la=X(ia)(".chickenpaint-layer",Xa);return la.length-1-la.index(La)}function U(){if(2===qa.state){let ya=e.getBoundingClientRect();var La=!0;let ha=!0;if(qa.dropTarget= @@ -293,8 +293,8 @@ qa.dropTarget.displayIndex-1;0<=Ba&&p[Ba].hasAncestor(qa.dropTarget.layer);Ba--) X(ia)(".chickenpaint-layer",Xa);Oa.each(function(pa){X(ia)(this).toggleClass("chickenpaint-layer-drop-target",Oa.length-1-pa==qa.dropTarget.displayIndex)});ha=!1}}ha&&X(ia)(".chickenpaint-layer-drop-target",Xa).removeClass("chickenpaint-layer-drop-target");La&&X(ia)(qa.dropBetweenMarkerElem).remove();qa.frameElem.style.top=qa.dragY-ya.top-parseInt(qa.frameElem.style.height,10)/2+"px"}else X(ia)(qa.dropBetweenMarkerElem).remove(),X(ia)(qa.frameElem).remove()}function T(La){let la=La.getImageThumbnail().getAsCanvas(Lb); return la.title=ma("Image"),la.className="chickenpaint-layer-thumbnail chickenpaint-layer-image-thumbnail",la.style.maxWidth=la.width/la.height*25+"px",La!=k.getActiveLayer()||k.isEditingMask()||(la.className+=" active"),la}function Y(La){let la=La.getMaskThumbnail().getAsCanvas(Lb);la.title=ma("Layer mask");la.className="chickenpaint-layer-thumbnail chickenpaint-layer-mask-thumbnail";la.style.maxWidth=la.width/la.height*25+"px";La==k.getActiveLayer()&&k.isEditingMask()&&(la.className+=" active"); La.maskVisible||(la.className+=" disabled",La=la.getContext("2d"),La.strokeStyle="red",La.lineWidth=3,La.moveTo(5,5),La.lineTo(la.width-5,la.height-5),La.moveTo(la.width-5,5),La.lineTo(5,la.height-5),La.stroke());return la}function ea(La,la){let Ba=document.createElement("div");var ya=document.createElement("div");let ha=document.createElement("div");var Oa=document.createElement("div");let pa=document.createElement("div"),Ta=document.createElement("div"),Ia=document.createElement("div");if(Ba.className= -"chickenpaint-layer list-group-item",la==k.getActiveLayer()&&(Ba.className+=" active"),ya.className="chickenpaint-layer-eye",la.ancestorsAreVisible()||(ya.className+=" chickenpaint-layer-eye-hidden-ancestors"),ya.style.marginRight=2+16*(la.getDepth()-1)+"px",la.visible?(Ba.className+=" chickenpaint-layer-visible",ya.appendChild(Ic("icon-eye"))):(Ba.className+=" chickenpaint-layer-hidden",ya.appendChild(Ic("icon-eye-slash"))),Ba.appendChild(ya),ha.className="chickenpaint-layer-description",la instanceof -Ma){if(la.clip&&(Ba.className+=" chickenpaint-layer-clipped",Oa.appendChild(Ic("icon-level-down-alt fa-flip-horizontal"))),la.lockAlpha)ya=Gf("lock-alpha"),ya.title=ma("Transparency locked"),Ta.appendChild(ya)}else la instanceof ob&&(Ba.className+=" chickenpaint-layer-group",la.expanded?(Ba.className+=" chickenpaint-layer-group-expanded",Oa.appendChild(Ic("icon-folder-open chickenpaint-layer-group-toggle"))):(Ba.className+=" chickenpaint-layer-group-collapsed",Oa.appendChild(Ic("icon-folder chickenpaint-layer-group-toggle")))); +"chickenpaint-layer list-group-item",la==k.getActiveLayer()&&(Ba.className+=" active"),ya.className="chickenpaint-layer-eye",la.ancestorsAreVisible()||(ya.className+=" chickenpaint-layer-eye-hidden-ancestors"),ya.style.marginRight=2+16*(la.getDepth()-1)+"px",la.visible?(Ba.className+=" chickenpaint-layer-visible",ya.appendChild(Jc("icon-eye"))):(Ba.className+=" chickenpaint-layer-hidden",ya.appendChild(Jc("icon-eye-slash"))),Ba.appendChild(ya),ha.className="chickenpaint-layer-description",la instanceof +Ma){if(la.clip&&(Ba.className+=" chickenpaint-layer-clipped",Oa.appendChild(Jc("icon-level-down-alt fa-flip-horizontal"))),la.lockAlpha)ya=Hf("lock-alpha"),ya.title=ma("Transparency locked"),Ta.appendChild(ya)}else la instanceof ob&&(Ba.className+=" chickenpaint-layer-group",la.expanded?(Ba.className+=" chickenpaint-layer-group-expanded",Oa.appendChild(Jc("icon-folder-open chickenpaint-layer-group-toggle"))):(Ba.className+=" chickenpaint-layer-group-collapsed",Oa.appendChild(Jc("icon-folder chickenpaint-layer-group-toggle")))); Oa.childNodes.length&&(Oa.className="chickenpaint-layer-icons",Ba.appendChild(Oa));try{la instanceof Ma&&Ba.appendChild(T(la)),la.mask&&Ba.appendChild(Y(la))}catch(lb){console.log("Failed to create layer thumb")}Oa=la.name&&0{3===qa.state&&(Na(),qa.dragY=la.clientY,U())},800)):qa.state=1,qa.dropTarget=null,qa.layer=ya,qa.layerElem=G(Ba),qa.dragX=la.clientX,qa.dragY=la.clientY,Xa.setPointerCapture(la.pointerId),Xa.addEventListener("pointermove",V),Xa.addEventListener("pointerup",ra)):2==la.button&&!ha&&(la.preventDefault(),-1!=L(la.target)&&(ja(L(la.target)),la.preventDefault()))}}}}), -Xa.setAttribute("touch-action","none"),["ontouchstart","ontouchmove","ontouchend","ontouchcancel"]))Xa.addEventListener(La,Sh);mb.appendChild(Xa)},l=new Ec(0,100,!1,!1,208),g=document.createElement("select"),n=new function(){let G=null,L="",U=document.createElement("input"),T=this;this.hide=function(){G=null;let Y=X(ia)(U).parent();Y&&(X(ia)(U).remove(),Y.text(L))};this.renameAndHide=function(){G&&G.name!=U.value&&a.actionPerformed({action:"CPSetLayerName",layer:G,name:U.value});this.hide()};this.show= +Xa.setAttribute("touch-action","none"),["ontouchstart","ontouchmove","ontouchend","ontouchcancel"]))Xa.addEventListener(La,Sh);mb.appendChild(Xa)},l=new Fc(0,100,!1,!1,208),g=document.createElement("select"),n=new function(){let G=null,L="",U=document.createElement("input"),T=this;this.hide=function(){G=null;let Y=X(ia)(U).parent();Y&&(X(ia)(U).remove(),Y.text(L))};this.renameAndHide=function(){G&&G.name!=U.value&&a.actionPerformed({action:"CPSetLayerName",layer:G,name:U.value});this.hide()};this.show= function(Y,ea){L=(G=Y).name;U.value=L;(Y=ea.querySelector(".chickenpaint-layer-name"))&&Y.parentNode&&(ea=Y.firstChild)&&ea.nodeType===Node.TEXT_NODE&&(Y.removeChild(ea),Y.appendChild(U));U.select()};U.type="text";U.className="chickenpaint-layer-rename form-control input-sm";U.addEventListener("keydown",function(Y){Y.stopPropagation()});U.addEventListener("keydown",function(Y){"Enter"===Y.key&&T.renameAndHide();Y.stopPropagation()});U.addEventListener("keyup",function(Y){"Escape"===Y.key&&T.hide(); Y.stopPropagation()});U.addEventListener("blur",function(Y){G&&T.renameAndHide()})},r=document.createElement("input"),u=document.createElement("input"),v=!1,x,C=this.setSize,K=this.setWidth,I=this.setHeight;this.setSize=function(G,L){C.call(this,G,L);this.dismissNotification();l.resize()};this.setWidth=function(G){K.call(this,G);l.resize();m.resize()};this.setHeight=function(G){I.call(this,G);m.resize()};this.setRotation90=function(G){m.setRotation90(G)};this.dismissNotification=function(){X(ia)(".chickenpaint-layer[aria-describedby],.chickenpaint-slider[aria-describedby]", -h).each((G,L)=>{L=X(ia)(L);(G=bootstrap.Popover.getInstance(L[0]))&&G.dispose()});v&&(clearTimeout(v),v=!1)};this.showNotification=(G,L,U)=>{let T=p.indexOf(G);G=k.getActiveLayer()==G&&"opacity"==U?l.getElement():m.revealLayer(T);this.dismissNotification();(new bootstrap.Popover(G,{html:!1,content:L,placement:"left",trigger:"manual",fallbackPlacement:[],boundary:"window",container:b.getElement()})).show();v=setTimeout(()=>{v=!1;this.dismissNotification()},Math.max(Math.round(70*L.length),3E3))};g.className= -"form-control form-control-sm";g.tabIndex=-1;g.title=ma("Layer blending mode");g.addEventListener("change",function(G){a.actionPerformed({action:"CPSetLayerBlendMode",blendMode:parseInt(g.value,10)});g.blur()});h.appendChild(g);l.title=function(G){return ma("Opacity")+": "+G+"%"};l.on("valueChange",function(G){a.actionPerformed({action:"CPSetLayerAlpha",alpha:G})});h.appendChild(l.getElement());r.id="chickenpaint-chk-sample-all-layers";r.type="checkbox";r.addEventListener("click",function(G){k.setSampleAllLayers(r.checked); -document.activeElement.blur()});h.appendChild(Rg(r,ma("Sample all layers")));u.id="chickenpaint-chk-lock-alpha";u.type="checkbox";u.addEventListener("click",function(G){a.actionPerformed({action:"CPSetLayerLockAlpha",lock:u.checked});document.activeElement.blur()});h.appendChild(Rg(u,ma("Lock transparency")));h.appendChild(m.getElement());x=function(){var G=[{title:"Add layer",icon:Ic("icon-file"),action:"CPAddLayer"},{title:"Add group",icon:Ic("icon-folder"),action:"CPAddGroup"},{title:"Merge down", -icon:Ic("icon-download_FILL"),action:"CPLayerMergeDown",require:["image-layer"]},{title:"Merge group",icon:Ic("icon-collapse_all_FILL"),action:"CPGroupMerge",require:["layer-group"]},{title:"Clip to the layer below",icon:Ic("icon-level-down-alt fa-flip-horizontal"),action:"CPCreateClippingMask",require:"no-clipping-mask-or-is-group"},{title:"Unclip from the layer below",icon:Ic("icon-level-down-alt fa-flip-horizontal"),action:"CPReleaseClippingMask",require:"clipping-mask"},{title:"Add layer mask", -icon:Gf("mask"),action:"CPAddLayerMask",require:["no-mask"]},{title:"Apply mask",icon:Gf("mask"),action:"CPApplyLayerMask",require:["mask"]},{title:"Duplicate",icon:Ic("icon-clone"),action:"CPLayerDuplicate"},{title:"Delete layer",icon:Ic("icon-trash"),action:"CPRemoveLayer"}];let L=document.createElement("ul");for(let U of(L.className="chickenpaint-layer-buttons list-unstyled",G))G=document.createElement("li"),G.setAttribute("data-action",U.action),G.className="chickenpaint-small-toolbar-button "+ -(U.require?"chickenpaint-action-require-"+U.require:""),G.title=ma(U.title),G.appendChild(U.icon),G.addEventListener("click",function(){a.actionPerformed({action:U.action})}),L.appendChild(G);return L}();h.appendChild(x);k.on("changeActiveLayer",function(G,L,U){m.activeLayerChanged(L,U);c()});k.on("changeLayer",function(G){k=this;b.dismissNotification();m.layerChanged(G);c()});k.on("changeStructure",d);k.on("changeLayerMaskThumb",function(G){k=this;m.layerMaskThumbChanged(G)});k.on("changeLayerImageThumb", -function(G){k=this;m.layerImageThumbChanged(G)});a.on("layerNotification",this.showNotification.bind(this));d.call(k)}function Th(){this.table=new Uint8Array(256);this.loadIdentity=function(){for(var a=0;256>a;a++)this.table[a]=a};this.loadBrightnessContrast=function(a,c){c=0d;d++)this.table[d]=Math.min(255,Math.max(~~(255*(d/255*c+a)),0))};this.invert=function(){for(var a=0;256>a;a++)this.table[a]=255-this.table[a]}}function Sg(a,c){let d=document.createElement("div"), -b=document.createElement("label");return d.className="form-check",a.className="form-check-input",b.className="form-check-label",b.setAttribute("for",a.id),b.appendChild(a),b.appendChild(document.createTextNode(c)),d.appendChild(a),d.appendChild(b),d}function Qe(a){function c(T){for(let Y=0;Y=T&&(ea.data[ja]=255);return ea}function p(T,Y){let ea=new fb(Y,Y,8);for(let ja=0;ja=T&&(ea.data[ja]=255);return ea}function h(){if(null!=r){u=r.clone();v&&u.mirrorHorizontally();let T=new Th;T.loadBrightnessContrast(C,K);x&&T.invert();u.applyLUT(T)}else u=null;a.getArtwork().setBrushTexture(u); -null!=I&&I.updateTexture()}function e(T,Y,ea){let ja=document.createElement("canvas"),ra=ja.getContext("2d"),Na=this;this.setTexture=function(V){this.texture=V;this.paint()};this.getElement=function(){return ja};this.paint=function(){null!=this.texture?ra.fillStyle=ra.createPattern(this.texture.getAsCanvas(),"repeat"):ra.fillStyle="white";ra.fillRect(0,0,ja.width,ja.height)};ja.addEventListener("click",function(){Na.emit("click")});ja.width=Y;ja.height=ea;this.setTexture(T)}var m;let l,g,n;lc.call(this, -a,"textures","Textures");let r,u,v=!1,x=!1,C=0,K=0,I,G=document.createElement("div"),L=this.getBodyElement();e.prototype=Object.create(X(Zb).prototype);e.prototype.constructor=e;I=new function(){function T(){Na.checked=x;V.checked=v;Fa.setValue(100*C+100);qa.setValue(100*K+100)}let Y,ea,ja,ra=document.createElement("div"),Na=document.createElement("input"),V=document.createElement("input"),Fa=new Ec(0,200,!0),qa=new Ec(0,200,!0),mb=new e(null,64,64),Xa=document.createElement("button"),Lb,Fb=new bootstrap.Popover(Xa, -{html:!0,content:()=>Lb,trigger:"manual",placement:"right",container:L});this.updateTexture=function(){Xa.disabled=null==u;mb.setTexture(u)};this.getElement=function(){return ra};ra.className="chickenpaint-texture-options";ra.appendChild(mb.getElement());Xa.type="button";Xa.className="btn btn-light btn-sm";Xa.setAttribute("data-bs-toggle","popover");Xa.setAttribute("data-bs-placement","right");Xa.textContent=ma("Customize");(Y=document.createElement("div")).className="chickenpaint-texture-controls"; -Na.id="chickenpaint-chk-texture-invert";Na.type="checkbox";Na.addEventListener("click",function(Ja){x=this.checked;h()});Y.appendChild(Sg(Na,ma("Inverse")));V.id="chickenpaint-chk-texture-mirror";V.type="checkbox";V.addEventListener("click",function(Ja){v=this.checked;h()});Y.appendChild(Sg(V,ma("Mirror")));Fa.title=function(Ja){return ma("Brightness")+": "+(Ja-100)+"%"};Fa.on("valueChange",function(Ja){C=(Ja-100)/100;h()});Y.appendChild(Fa.getElement());qa.title=function(Ja){return ma("Contrast")+ -": "+(Ja-100)+"%"};qa.on("valueChange",function(Ja){K=(Ja-100)/100;h()});Y.appendChild(qa.getElement());ea=document.createElement("button");ja=document.createElement("button");ea.textContent="Ok";ea.className="btn btn-primary btn-sm";ea.type="button";ea.addEventListener("click",function(Ja){Fb.hide()});Y.appendChild(ea);Y.appendChild(document.createTextNode(" "));ja.textContent="Reset";ja.className="btn btn-secondary btn-sm";ja.type="button";ja.addEventListener("click",function(Ja){K=C=0;x=v=!1;T(); -h()});Y.appendChild(ja);T();Lb=Y;Xa.addEventListener("click",function(){Fb.toggle()});ra.appendChild(Xa);this.updateTexture()};L.appendChild(I.getElement());G.className="chickenpaint-texture-swatches";L.appendChild(G);c((m=[null],(l=new fb(2,2,8)).data[0]=255,l.data[3]=255,m.push(l),m.push(d(2)),m.push(d(3)),m.push(d(4)),m.push(d(6)),m.push(d(8)),m.push(k(1,2)),m.push(k(2,4)),m.push(p(1,2)),m.push(p(2,4)),m.push(b(2)),m.push(b(4)),m.push(b(8)),m.push(b(16)),m));m=a.getResourcesRoot()+"gfx/textures32.png"; -var U=function(T){c(T)};g=new Image;n=[];g.onload=function(){var T=document.createElement("canvas");let Y=T.getContext("2d",{willReadFrequently:!0});T.width=g.width;T.height=g.height;for(T=0;2>T;T++){Y.drawImage(g,0,32*T,32,32,0,0,32,32);try{let ea=Y.getImageData(0,0,32,32),ja=new fb(32,32,8);for(let ra=0;1024>ra;ra++)ja.data[ra]=ea.data[4*ra];n.push(ja)}catch(ea){console.log(ea)}}U(n)};g.src=m}function Re(a){function c(K){let I=document.createElement("div"),G=document.createElement("a"),L=document.createElement("ul"), -U=document.createElement("a"),T=document.createElement("a"),Y=this;this.getElement=function(){return I};this.setColor=function(ja){G.setAttribute("data-color",ja);var ra=G.style;for(ja=""+Number(ja).toString(16);6>ja.length;)ja="0"+ja;ra.backgroundColor="#"+ja};this.setColor(K);G.href="#";G.className="chickenpaint-color-swatch dropdown-toggle";U.className="dropdown-item";U.href="#";U.textContent=ma("Remove");U.addEventListener("click",function(ja){ja.preventDefault();X(ia)(I).remove();n=!0});T.className= -"dropdown-item";T.href="#";T.textContent=ma("Replace with current color");T.addEventListener("click",function(ja){ja.preventDefault();Y.setColor(a.getCurColor().getRgb());n=!0});L.className="dropdown-menu";K=document.createElement("li");let ea=document.createElement("li");K.appendChild(U);ea.appendChild(T);L.appendChild(K);L.appendChild(ea);I.className="chickenpaint-color-swatch-wrapper";I.appendChild(G);I.appendChild(L)}function d(K){K=new c(K);r.appendChild(K.getElement())}function b(K){let I=document.createElement("span"); -return I.className="fa icon-"+K,I}let k,p,h;let e,m,l;lc.call(this,a,"swatches","Color swatches");let g=[16777215,0,16711680,65280,255,16776960],n=!1,r=document.createElement("ul"),u=document.createElement("div"),v,x=this;this.getSwatches=function(){let K=X(ia)(".chickenpaint-color-swatch",r),I=Array(K.length);for(let G=0;GI.length)){I=I[0];var G=new FileReader;G.onload=function(){let L=(new Qd).read(this.result);null!=L&&0 .chickenpaint-palette",h).each(function(){e.showPaletteByName(this.getAttribute("data-paletteName"),!1);l.push(this)});else{for(let n=0;nn.width&&u.setLocation(n.width-u.getWidth(),u.getY());u.getY()+u.getHeight()/2>n.height&&u.setLocation(u.getX(),n.height-u.getHeight())}r=0Math.abs(b.swatches.getY()-b.brush.getY())&&b.swatches.setLocation(b.brush.getX()- -b.swatches.getWidth()-(r?5:1),0);b.layers.getY()+b.layers.getHeight()>n.height&&b.layers.setHeight(Math.max(n.height-b.layers.getY(),200))},this.arrangePalettes=function(){let n=c();if(a.getSmallScreenMode()){b.tool.setLocation(0,0);b.misc.setLocation(b.tool.getX()+b.tool.getWidth()+1,0);var r=16>=n.width-(b.tool.getWidth()+b.misc.getWidth()+b.brush.getWidth())?b.misc.getY()+b.misc.getHeight()+1:0;b.brush.setLocation(n.width-b.brush.getWidth()-15,r);b.textures.setWidth(n.width-b.textures.getX()); -b.layers.setLocation(b.brush.getX()+b.brush.getWidth()-b.layers.getWidth(),b.textures.getY()-b.layers.getHeight());r=Math.max(b.textures.getY()-330-1,370);b.layers.setHeight(r);b.layers.setWidth(218);b.stroke.setLocation(b.misc.getX(),b.misc.getY()+b.misc.getHeight()+1);b.swatches.setLocation(b.stroke.getX(),b.stroke.getY()+b.stroke.getHeight()+1)}else{r=0
'), +h).each((G,L)=>{L=X(ia)(L);(G=oc.Popover.getInstance(L[0]))&&G.dispose()});v&&(clearTimeout(v),v=!1)};this.showNotification=(G,L,U)=>{let T=p.indexOf(G);G=k.getActiveLayer()==G&&"opacity"==U?l.getElement():m.revealLayer(T);this.dismissNotification();(new oc.Popover(G,{html:!1,content:L,placement:"left",trigger:"manual",fallbackPlacement:[],boundary:"window",container:b.getElement()})).show();v=setTimeout(()=>{v=!1;this.dismissNotification()},Math.max(Math.round(70*L.length),3E3))};g.className="form-control form-control-sm"; +g.tabIndex=-1;g.title=ma("Layer blending mode");g.addEventListener("change",function(G){a.actionPerformed({action:"CPSetLayerBlendMode",blendMode:parseInt(g.value,10)});g.blur()});h.appendChild(g);l.title=function(G){return ma("Opacity")+": "+G+"%"};l.on("valueChange",function(G){a.actionPerformed({action:"CPSetLayerAlpha",alpha:G})});h.appendChild(l.getElement());r.id="chickenpaint-chk-sample-all-layers";r.type="checkbox";r.addEventListener("click",function(G){k.setSampleAllLayers(r.checked);document.activeElement.blur()}); +h.appendChild(Sg(r,ma("Sample all layers")));u.id="chickenpaint-chk-lock-alpha";u.type="checkbox";u.addEventListener("click",function(G){a.actionPerformed({action:"CPSetLayerLockAlpha",lock:u.checked});document.activeElement.blur()});h.appendChild(Sg(u,ma("Lock transparency")));h.appendChild(m.getElement());x=function(){var G=[{title:"Add layer",icon:Jc("icon-file"),action:"CPAddLayer"},{title:"Add group",icon:Jc("icon-folder"),action:"CPAddGroup"},{title:"Merge down",icon:Jc("icon-download_FILL"), +action:"CPLayerMergeDown",require:["image-layer"]},{title:"Merge group",icon:Jc("icon-collapse_all_FILL"),action:"CPGroupMerge",require:["layer-group"]},{title:"Clip to the layer below",icon:Jc("icon-level-down-alt fa-flip-horizontal"),action:"CPCreateClippingMask",require:"no-clipping-mask-or-is-group"},{title:"Unclip from the layer below",icon:Jc("icon-level-down-alt fa-flip-horizontal"),action:"CPReleaseClippingMask",require:"clipping-mask"},{title:"Add layer mask",icon:Hf("mask"),action:"CPAddLayerMask", +require:["no-mask"]},{title:"Apply mask",icon:Hf("mask"),action:"CPApplyLayerMask",require:["mask"]},{title:"Duplicate",icon:Jc("icon-clone"),action:"CPLayerDuplicate"},{title:"Delete layer",icon:Jc("icon-trash"),action:"CPRemoveLayer"}];let L=document.createElement("ul");for(let U of(L.className="chickenpaint-layer-buttons list-unstyled",G))G=document.createElement("li"),G.setAttribute("data-action",U.action),G.className="chickenpaint-small-toolbar-button "+(U.require?"chickenpaint-action-require-"+ +U.require:""),G.title=ma(U.title),G.appendChild(U.icon),G.addEventListener("click",function(){a.actionPerformed({action:U.action})}),L.appendChild(G);return L}();h.appendChild(x);k.on("changeActiveLayer",function(G,L,U){m.activeLayerChanged(L,U);c()});k.on("changeLayer",function(G){k=this;b.dismissNotification();m.layerChanged(G);c()});k.on("changeStructure",d);k.on("changeLayerMaskThumb",function(G){k=this;m.layerMaskThumbChanged(G)});k.on("changeLayerImageThumb",function(G){k=this;m.layerImageThumbChanged(G)}); +a.on("layerNotification",this.showNotification.bind(this));d.call(k)}function Th(){this.table=new Uint8Array(256);this.loadIdentity=function(){for(var a=0;256>a;a++)this.table[a]=a};this.loadBrightnessContrast=function(a,c){c=0d;d++)this.table[d]=Math.min(255,Math.max(~~(255*(d/255*c+a)),0))};this.invert=function(){for(var a=0;256>a;a++)this.table[a]=255-this.table[a]}}function Tg(a,c){let d=document.createElement("div"),b=document.createElement("label"); +return d.className="form-check",a.className="form-check-input",b.className="form-check-label",b.setAttribute("for",a.id),b.appendChild(a),b.appendChild(document.createTextNode(c)),d.appendChild(a),d.appendChild(b),d}function Re(a){function c(T){for(let Y=0;Y=T&&(ea.data[ja]=255);return ea}function p(T,Y){let ea=new fb(Y,Y,8);for(let ja=0;ja=T&&(ea.data[ja]=255);return ea}function h(){if(null!=r){u=r.clone();v&&u.mirrorHorizontally();let T=new Th;T.loadBrightnessContrast(C,K);x&&T.invert();u.applyLUT(T)}else u=null;a.getArtwork().setBrushTexture(u);null!=I&&I.updateTexture()} +function e(T,Y,ea){let ja=document.createElement("canvas"),ra=ja.getContext("2d"),Na=this;this.setTexture=function(V){this.texture=V;this.paint()};this.getElement=function(){return ja};this.paint=function(){null!=this.texture?ra.fillStyle=ra.createPattern(this.texture.getAsCanvas(),"repeat"):ra.fillStyle="white";ra.fillRect(0,0,ja.width,ja.height)};ja.addEventListener("click",function(){Na.emit("click")});ja.width=Y;ja.height=ea;this.setTexture(T)}var m;let l,g,n;lc.call(this,a,"textures","Textures"); +let r,u,v=!1,x=!1,C=0,K=0,I,G=document.createElement("div"),L=this.getBodyElement();e.prototype=Object.create(X(Zb).prototype);e.prototype.constructor=e;I=new function(){function T(){Na.checked=x;V.checked=v;Fa.setValue(100*C+100);qa.setValue(100*K+100)}let Y,ea,ja,ra=document.createElement("div"),Na=document.createElement("input"),V=document.createElement("input"),Fa=new Fc(0,200,!0),qa=new Fc(0,200,!0),mb=new e(null,64,64),Xa=document.createElement("button"),Lb,Fb=new oc.Popover(Xa,{html:!0,content:()=> +Lb,trigger:"manual",placement:"right",container:L});this.updateTexture=function(){Xa.disabled=null==u;mb.setTexture(u)};this.getElement=function(){return ra};ra.className="chickenpaint-texture-options";ra.appendChild(mb.getElement());Xa.type="button";Xa.className="btn btn-light btn-sm";Xa.setAttribute("data-bs-toggle","popover");Xa.setAttribute("data-bs-placement","right");Xa.textContent=ma("Customize");(Y=document.createElement("div")).className="chickenpaint-texture-controls";Na.id="chickenpaint-chk-texture-invert"; +Na.type="checkbox";Na.addEventListener("click",function(Ja){x=this.checked;h()});Y.appendChild(Tg(Na,ma("Inverse")));V.id="chickenpaint-chk-texture-mirror";V.type="checkbox";V.addEventListener("click",function(Ja){v=this.checked;h()});Y.appendChild(Tg(V,ma("Mirror")));Fa.title=function(Ja){return ma("Brightness")+": "+(Ja-100)+"%"};Fa.on("valueChange",function(Ja){C=(Ja-100)/100;h()});Y.appendChild(Fa.getElement());qa.title=function(Ja){return ma("Contrast")+": "+(Ja-100)+"%"};qa.on("valueChange", +function(Ja){K=(Ja-100)/100;h()});Y.appendChild(qa.getElement());ea=document.createElement("button");ja=document.createElement("button");ea.textContent="Ok";ea.className="btn btn-primary btn-sm";ea.type="button";ea.addEventListener("click",function(Ja){Fb.hide()});Y.appendChild(ea);Y.appendChild(document.createTextNode(" "));ja.textContent="Reset";ja.className="btn btn-secondary btn-sm";ja.type="button";ja.addEventListener("click",function(Ja){K=C=0;x=v=!1;T();h()});Y.appendChild(ja);T();Lb=Y;Xa.addEventListener("click", +function(){Fb.toggle()});ra.appendChild(Xa);this.updateTexture()};L.appendChild(I.getElement());G.className="chickenpaint-texture-swatches";L.appendChild(G);c((m=[null],(l=new fb(2,2,8)).data[0]=255,l.data[3]=255,m.push(l),m.push(d(2)),m.push(d(3)),m.push(d(4)),m.push(d(6)),m.push(d(8)),m.push(k(1,2)),m.push(k(2,4)),m.push(p(1,2)),m.push(p(2,4)),m.push(b(2)),m.push(b(4)),m.push(b(8)),m.push(b(16)),m));m=a.getResourcesRoot()+"gfx/textures32.png";var U=function(T){c(T)};g=new Image;n=[];g.onload=function(){var T= +document.createElement("canvas");let Y=T.getContext("2d",{willReadFrequently:!0});T.width=g.width;T.height=g.height;for(T=0;2>T;T++){Y.drawImage(g,0,32*T,32,32,0,0,32,32);try{let ea=Y.getImageData(0,0,32,32),ja=new fb(32,32,8);for(let ra=0;1024>ra;ra++)ja.data[ra]=ea.data[4*ra];n.push(ja)}catch(ea){console.log(ea)}}U(n)};g.src=m}function Se(a){function c(K){let I=document.createElement("div"),G=document.createElement("a"),L=document.createElement("ul"),U=document.createElement("a"),T=document.createElement("a"), +Y=this;this.getElement=function(){return I};this.setColor=function(ja){G.setAttribute("data-color",ja);var ra=G.style;for(ja=""+Number(ja).toString(16);6>ja.length;)ja="0"+ja;ra.backgroundColor="#"+ja};this.setColor(K);G.href="#";G.className="chickenpaint-color-swatch dropdown-toggle";U.className="dropdown-item";U.href="#";U.textContent=ma("Remove");U.addEventListener("click",function(ja){ja.preventDefault();X(ia)(I).remove();n=!0});T.className="dropdown-item";T.href="#";T.textContent=ma("Replace with current color"); +T.addEventListener("click",function(ja){ja.preventDefault();Y.setColor(a.getCurColor().getRgb());n=!0});L.className="dropdown-menu";K=document.createElement("li");let ea=document.createElement("li");K.appendChild(U);ea.appendChild(T);L.appendChild(K);L.appendChild(ea);I.className="chickenpaint-color-swatch-wrapper";I.appendChild(G);I.appendChild(L)}function d(K){K=new c(K);r.appendChild(K.getElement())}function b(K){let I=document.createElement("span");return I.className="fa icon-"+K,I}let k,p,h; +let e,m,l;lc.call(this,a,"swatches","Color swatches");let g=[16777215,0,16711680,65280,255,16776960],n=!1,r=document.createElement("ul"),u=document.createElement("div"),v,x=this;this.getSwatches=function(){let K=X(ia)(".chickenpaint-color-swatch",r),I=Array(K.length);for(let G=0;GI.length)){I=I[0];var G=new FileReader;G.onload=function(){let L=(new Rd).read(this.result);null!=L&&0 .chickenpaint-palette",h).each(function(){e.showPaletteByName(this.getAttribute("data-paletteName"),!1);l.push(this)});else{for(let n=0;nn.width&&u.setLocation(n.width-u.getWidth(),u.getY());u.getY()+u.getHeight()/2>n.height&&u.setLocation(u.getX(),n.height-u.getHeight())}r=0Math.abs(b.swatches.getY()-b.brush.getY())&&b.swatches.setLocation(b.brush.getX()-b.swatches.getWidth()-(r? +5:1),0);b.layers.getY()+b.layers.getHeight()>n.height&&b.layers.setHeight(Math.max(n.height-b.layers.getY(),200))},this.arrangePalettes=function(){let n=c();if(a.getSmallScreenMode()){b.tool.setLocation(0,0);b.misc.setLocation(b.tool.getX()+b.tool.getWidth()+1,0);var r=16>=n.width-(b.tool.getWidth()+b.misc.getWidth()+b.brush.getWidth())?b.misc.getY()+b.misc.getHeight()+1:0;b.brush.setLocation(n.width-b.brush.getWidth()-15,r);b.textures.setWidth(n.width-b.textures.getX());b.layers.setLocation(b.brush.getX()+ +b.brush.getWidth()-b.layers.getWidth(),b.textures.getY()-b.layers.getHeight());r=Math.max(b.textures.getY()-330-1,370);b.layers.setHeight(r);b.layers.setWidth(218);b.stroke.setLocation(b.misc.getX(),b.misc.getY()+b.misc.getHeight()+1);b.swatches.setLocation(b.stroke.getX(),b.stroke.getY()+b.stroke.getHeight()+1)}else{r=0
'), k=navigator.userAgent.toLowerCase().includes("mac os");this.getElement=function(){return b[0]};(function(e,m){e.append(m.map(l=>{let g=X(ia)(''),n=X(ia)(".dropdown-toggle",g),r=X(ia)(".dropdown-menu",g);return n[0].addEventListener("show.bs.dropdown",u=>{!function(v){X(ia)("[data-action]", v).each(function(){let C=X(ia)(this);var K=this.getAttribute("data-action");K=a.isActionAllowed(K);C.toggleClass("disabled",!K).toggleClass("hidden",!K&&!0===C.data("hideIfNotAvailable"))});X(ia)(".dropdown-divider",v).removeClass("hidden");v=X(ia)(".dropdown-item:not(.hidden),.dropdown-divider:not(.hidden)",v);let x=null;for(let C=0;C{let v; if(!u.action||a.isActionSupported(u.action)){if("CPSend"!=u.action||a.isActionSupported("CPContinue")||(u.name=ma("Post Oekaki"),u.shortcut="ctrl+p"),"-"==u.name?v=X(ia)(''):(v=X(ia)(''+ma(u.name)+""),u.checkbox&&X(ia)(v).data("checkbox",!0).toggleClass("selected",!!u.checked),u.hideIfNotAvailable&&v.data("hideIfNotAvailable",!0)),u.title&&v.attr("title",ma(u.title)),u.shortcut){var x;let C= v,K=document.createElement("small");k&&(u.shortcut=u.shortcut.replace(/SHIFT/im,"\u21e7"),u.shortcut=u.shortcut.replace(/ALT/im,"\u2325"),u.shortcut=u.shortcut.replace(/CTRL/im,"\u2318"));K.className="chickenpaint-shortcut";K.textContent=(x=(x=(x=(x=u.shortcut).toUpperCase()).replace(/(,.+)$/,"")).replace("=","+"),x=k?x.replace(/([^+])\+/g,"$1"):x.replace(/([^+])\+/g,"$1 "));C.append(K);X(Sb)(u.shortcut,function(I){return d(C),I.preventDefault(),I.stopPropagation(),!1})}return X(ia)("
  • ").append(v)}})), -g}))})(X(ia)(".navbar-nav",b),Tg);(function(e,m){e.append(m.filter(l=>!!l.mnemonic&&a.isActionSupported(l.action)).map(l=>{let g=X(ia)(`");return g.on("click",n=>{d(g);n.preventDefault()}),g}))})(X(ia)(".widget-nav",b),Tg[5].children);X(ia)(b).on("click","a:not(.dropdown-toggle)",function(e){d(X(ia)(this));e.preventDefault()});X(ia)(".navbar-toggler", +g}))})(X(ia)(".navbar-nav",b),Ug);(function(e,m){e.append(m.filter(l=>!!l.mnemonic&&a.isActionSupported(l.action)).map(l=>{let g=X(ia)(`");return g.on("click",n=>{d(g);n.preventDefault()}),g}))})(X(ia)(".widget-nav",b),Ug[5].children);X(ia)(b).on("click","a:not(.dropdown-toggle)",function(e){d(X(ia)(this));e.preventDefault()});X(ia)(".navbar-toggler", b).on("click",e=>{e.preventDefault()});c.getPaletteManager().on("paletteVisChange",function(e,m){X(ia)('[data-action="CPPal'+e.substring(0,1).toUpperCase()+e.substring(1)+'"]',b).toggleClass("selected",m)});let p=X(ia)(".dropdown-item[data-action=CPFullScreen]",b),h=X(ia)(".dropdown-item[data-action=CPToolbarStyle]",b);a.on("fullScreen",e=>p.toggleClass("selected",e));p.toggleClass("selected",a.isFullScreen());a.on("toolbarStyleChange",e=>h.toggleClass("selected","old"===e));h.toggleClass("selected", -"old"===a.getToolbarStyle())}function Te(a,c){let d=document.createElement("div"),b=new Ke(a),k=new Se(a),p,h=!1,e=this;this.togglePalettes=function(){k.togglePalettes()};this.arrangePalettes=function(){setTimeout(k.arrangePalettes.bind(k),0)};this.constrainPalettes=function(){k.constrainPalettes()};this.showPalette=function(l,g){k.showPaletteByName(l,g)};this.getSwatches=function(){return k.palettes.swatches.getSwatches()};this.setSwatches=function(l){k.palettes.swatches.setSwatches(l)};this.getPaletteManager= +"old"===a.getToolbarStyle())}function Ue(a,c){let d=document.createElement("div"),b=new Le(a),k=new Te(a),p,h=!1,e=this;this.togglePalettes=function(){k.togglePalettes()};this.arrangePalettes=function(){setTimeout(k.arrangePalettes.bind(k),0)};this.constrainPalettes=function(){k.constrainPalettes()};this.showPalette=function(l,g){k.showPaletteByName(l,g)};this.getSwatches=function(){return k.palettes.swatches.getSwatches()};this.setSwatches=function(l){k.palettes.swatches.setSwatches(l)};this.getPaletteManager= function(){return k};this.setRotation90=function(l){b.setRotation(l*Math.PI/2);k.palettes.layers.setRotation90(l)};this.setFullScreenMode=function(l){h!==l&&(h=l,e.resize(),e.arrangePalettes())};this.resize=function(){let l=window.innerHeight,g=p.getElement().getBoundingClientRect().height;b.resize(h?l-g:Math.min(Math.max(l-g-65,500),850),!1);e.constrainPalettes()};p=new Uh(a,this);c.appendChild(p.getElement());d.className="chickenpaint-main-section";d.appendChild(b.getElement());d.appendChild(k.getElement()); c.appendChild(d);b.on("canvasRotated90",function(l){k.palettes.layers.setRotation90(l)});screen.orientation&&screen.orientation.addEventListener("change",l=>{this.resize();a.actionPerformed({action:"CPArrangePalettes"});setTimeout(()=>{this.resize();a.actionPerformed({action:"CPArrangePalettes"})},10);Promise.resolve().then(()=>{this.resize()}).then(()=>{a.actionPerformed({action:"CPArrangePalettes"})})});let m=document.getElementById("chickenpaint-main-menu-content");if(document.addEventListener("show.bs.modal", -()=>{m&&m.classList.contains("show")&&(new bootstrap.Collapse(m,{toggle:!1})).hide()}),m){let l=document.querySelector(".chickenpaint .widget-nav");l&&(m.addEventListener("show.bs.collapse",g=>{l.classList.add("hidden")}),m.addEventListener("hidden.bs.collapse",g=>{l.classList.remove("hidden")}));window.addEventListener("resize",()=>{l.classList.remove("hidden")})}document.addEventListener("hidden.bs.collapse",this.resize.bind(this));window.addEventListener("resize",this.resize.bind(this));a.on("fullScreen", +()=>{m&&m.classList.contains("show")&&(new oc.Collapse(m,{toggle:!1})).hide()}),m){let l=document.querySelector(".chickenpaint .widget-nav");l&&(m.addEventListener("show.bs.collapse",g=>{l.classList.add("hidden")}),m.addEventListener("hidden.bs.collapse",g=>{l.classList.remove("hidden")}));window.addEventListener("resize",()=>{l.classList.remove("hidden")})}document.addEventListener("hidden.bs.collapse",this.resize.bind(this));window.addEventListener("resize",this.resize.bind(this));a.on("fullScreen", l=>this.setFullScreenMode(l));a.on("toolbarStyleChange",l=>{X(ia)(c).toggleClass("chickenpaint-toolbar-style-old","old"===l)});a.on("unsavedChanges",l=>{X(ia)(c).toggleClass("chickenpaint-unsaved",l)});setTimeout(this.resize.bind(this),0)}function Vh(a){var c=X(ia)('