From 9492e586536c34d2eafc67aab6eeb09aa4be2109 Mon Sep 17 00:00:00 2001 From: satopian Date: Tue, 3 Dec 2024 10:50:05 +0900 Subject: [PATCH] =?UTF-8?q?v1.60.6=20ChickenPaint=20Be=E3=81=AB=EF=BD=A2?= =?UTF-8?q?=E8=BC=9D=E5=BA=A6=E3=82=92=E9=80=8F=E6=98=8E=E5=BA=A6=E3=81=AB?= =?UTF-8?q?=E5=A4=89=E6=8F=9B=EF=BD=A3=E6=A9=9F=E8=83=BD=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- petitnote/app/chickenpaint/js/chickenpaint.js | 1577 +++++++++-------- .../app/chickenpaint/js/chickenpaint.min.js | 1577 +++++++++-------- petitnote/index.php | 4 +- 3 files changed, 1582 insertions(+), 1576 deletions(-) diff --git a/petitnote/app/chickenpaint/js/chickenpaint.js b/petitnote/app/chickenpaint/js/chickenpaint.js index 740090a..2803b3a 100644 --- a/petitnote/app/chickenpaint/js/chickenpaint.js +++ b/petitnote/app/chickenpaint/js/chickenpaint.js @@ -49,313 +49,314 @@ http://benalman.com/about/license/ */ !function(){function Y(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 Da(a){for(var c in Da.DEFAULTS)Da.DEFAULTS.hasOwnProperty(c)&&(this[c]=Da.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 m,p=0,g=[0,0,0,0];var e=0;for(m=0;mk.alpha||k.mask)){let r=k;(k=new ee(c,d)).blendMode=Array.isArray(r)?T.LM_NORMAL:r.blendMode;k.alpha=100;k.image=m();k.addChildren(r)}}else(k=new ee(c,d,{image:m(),blendMode:T.LM_NORMAL,alpha:100,getEffectiveMask:()=> -null,visible:!0})).image.clearAll(0);l=[]}};this.resetTree=function(){k&&(function u(r){if(r.isGroup)for(let v of(r.image&&l.push(r.image),r.layers))u(v)}(k),k=null,h.clear())};this.layerPropertyChanged=function(n,r){let u=h.get(n);u&&u.visible==n.visible&&u.alpha==n.alpha&&null==u.mask==(null==n.getEffectiveMask())&&u.blendMode==T.LM_PASSTHROUGH==(n.blendMode==T.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|| +this.dirtyRect=new Ha(0,0,a,c);this.layers=[];this.parent=null;this.clip=!1}function lg(a,c,d,b){function l(){return 0k.alpha||k.mask)){let r=k;(k=new ee(c,d)).blendMode=Array.isArray(r)?T.LM_NORMAL:r.blendMode;k.alpha=100;k.image=l();k.addChildren(r)}}else(k=new ee(c,d,{image:l(),blendMode:T.LM_NORMAL,alpha:100,getEffectiveMask:()=> +null,visible:!0})).image.clearAll(0);m=[]}};this.resetTree=function(){k&&(function u(r){if(r.isGroup)for(let v of(r.image&&m.push(r.image),r.layers))u(v)}(k),k=null,h.clear())};this.layerPropertyChanged=function(n,r){let u=h.get(n);u&&u.visible==n.visible&&u.alpha==n.alpha&&null==u.mask==(null==n.getEffectiveMask())&&u.blendMode==T.LM_PASSTHROUGH==(n.blendMode==T.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==T.LM_PASSTHROUGH&&r.parent&&v.union(r.parent.dirtyRect),v.isEmpty())return r;if(r.blendMode==T.LM_PASSTHROUGH&&r.parent){x=!1;var K=r.image;var J=r.parent.image;v.getWidth()==K.width&&v.getHeight()==K.height?K.copyPixelsFrom(J):T.replaceOntoFusionWithOpaqueLayer(K,J,100,v)}for(K=0;KC.alpha?C.mask?T.replaceAlphaOntoFusionWithTransparentLayerMasked(r.image,C.image,C.alpha,v,C.mask):T.replaceAlphaOntoFusionWithTransparentLayer(r.image,C.image,C.alpha,v):C.mask?T.replaceAlphaOntoFusionWithOpaqueLayerMasked(r.image,C.image, -100,v,C.mask):T.replaceAlphaOntoFusionWithOpaqueLayer(r.image,C.image,100,v));return r.dirtyRect.makeEmpty(),r}(k)}}function uh(){function a(h){if(null!=m&&h.curSize==p&&h.curSqueeze==g&&h.curAngle==e&&h.tip==k)return m;switch(h.tip){case Da.TIP_ROUND_AIRBRUSH:!function(n,r){let u=Math.ceil(r.curSize),v=u/2,x=r.curSize/2*(r.curSize/2),C=1+10*r.curSqueeze,K=Math.cos(r.curAngle);r=Math.sin(r.curAngle);let J=0;for(let W=0;WK)n[L++]=0;else{W=0;for(let S=0;4>S;S++)for(let za=0;4> za;za++)(wa=((Z=X+.25*za-v)*G-(ia=U+.25*S-v)*r)*J)*wa+(Ia=ia*G+Z*r)*Ia<=x&&(W+=1);n[L++]=Math.min(16*W,255)}}}(c,h);break;case Da.TIP_ROUND_PIXEL:!function(n,r){let u=Math.ceil(r.curSize),v=u/2,x=r.curSize/2*(r.curSize/2),C=1+10*r.curSqueeze,K=Math.cos(r.curAngle);r=Math.sin(r.curAngle);let J=0;for(let L=0;LG||X>L)n[U++]=0;else{let S=0;for(let za=0;4>za;za++)for(let na=0;4>na;na++)Ia=Math.abs((X=ia+.25*na-v)*W-(wa=Z+.25*za-v)*r),X=Math.abs(wa*W+X*r),Ia<=C&&X<=x&&S++;n[U++]=Math.min(16*S,255)}}}(c,h); -break;case Da.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 J=0;for(let G=0;GL&&(L+=G.width);0>W&&(W+=G.height);for(let ia=0;iaXa.invalidateLayerRect(N,P));let F=!1;if(ea)for(let N of(Fb.union(P),D))N instanceof Na&&(Va.add(N),F=!0);fa&&(Ma.union(P),D.forEach(N=>{ec.add(N);Ja&&Ja.layer==N&&Ja.invalidateRect(P)}),F=!0);F&&(fb&&(clearTimeout(fb),fb=null),Ic||(fb=setTimeout(e,1E3)));m(P)}function l(D,P){k(D,P,!Ta,Ta)}function h(){return Ta?qa.mask:qa.image}function n(){if(!Ca.isEmpty()){if(Ta){var D=qa.mask;hb.brushMode==Da.BRUSH_MODE_ERASE?Oa[Da.BRUSH_MODE_PAINT].mergeOntoMask(D, -Ka,4278190080):Oa[hb.brushMode].mergeOntoMask(D,Ka,255&Yb)}else{D=qa.image;let P=qa.getLockAlpha();hb.brushMode==Da.BRUSH_MODE_ERASE&&P?Oa[Da.BRUSH_MODE_PAINT].mergeOntoImage(D,Lb,16777215):Oa[hb.brushMode].mergeOntoImage(D,Lb,Yb);P&&D.copyAlphaFrom(Lb,Ca)}Ca.makeEmpty()}}function r(){qa instanceof Na&&!Fb.isEmpty()&&(Lb.copyBitmapRect(qa.image,Fb.left,Fb.top,Fb),Fb.makeEmpty())}function u(){qa.mask&&!Ma.isEmpty()&&(Ka.copyBitmapRect(qa.mask,Ma.left,Ma.top,Ma),Ma.makeEmpty())}function v(){Ta?u(): -r()}function x(){let D=ha.getBounds();Fb.set(D);Ma.set(D)}function C(D){ha.setHasUnsavedChanges(!0);0L&&(L+=G.width);0>W&&(W+=G.height);for(let ia=0;iaYa.invalidateLayerRect(N,P));let F=!1;if(ea)for(let N of(Fb.union(P),D))N instanceof Na&&(Wa.add(N),F=!0);fa&&(Ma.union(P),D.forEach(N=>{ec.add(N);Ja&&Ja.layer==N&&Ja.invalidateRect(P)}),F=!0);F&&(fb&&(clearTimeout(fb),fb=null),Ic||(fb=setTimeout(e,1E3)));l(P)}function m(D,P){k(D,P,!Ua,Ua)}function h(){return Ua?qa.mask:qa.image}function n(){if(!Ca.isEmpty()){if(Ua){var D=qa.mask;hb.brushMode==Da.BRUSH_MODE_ERASE?Oa[Da.BRUSH_MODE_PAINT].mergeOntoMask(D, +Ka,4278190080):Oa[hb.brushMode].mergeOntoMask(D,Ka,255&Yb)}else{D=qa.image;let P=qa.getLockAlpha();hb.brushMode==Da.BRUSH_MODE_ERASE&&P?Oa[Da.BRUSH_MODE_PAINT].mergeOntoImage(D,Lb,16777215):Oa[hb.brushMode].mergeOntoImage(D,Lb,Yb);P&&D.copyAlphaFrom(Lb,Ca)}Ca.makeEmpty()}}function r(){qa instanceof Na&&!Fb.isEmpty()&&(Lb.copyBitmapRect(qa.image,Fb.left,Fb.top,Fb),Fb.makeEmpty())}function u(){qa.mask&&!Ma.isEmpty()&&(Ka.copyBitmapRect(qa.mask,Ma.left,Ma.top,Ma),Ma.makeEmpty())}function v(){Ua?u(): +r()}function x(){let D=ha.getBounds();Fb.set(D);Ma.set(D)}function C(D){ha.setHasUnsavedChanges(!0);0N.getMemoryUsed()).reduce(De,0)};this.redo()}function wa(D,P,ea){let fa=D.parent,F=D.parent.indexOf(D),N=Ta,da=fa.layers[fa.indexOf(D)+1],la=P.layers[ea],xa=D instanceof Na&&D.clip,Aa=!!xa&&D.getClippingBase(),cb=0,gb=0;if(D instanceof Na&&!D.clip)for(var Ea=F+1;EaN.getMemoryUsed()).reduce(De,0)};this.redo()}function wa(D,P,ea){let fa=D.parent,F=D.parent.indexOf(D),N=Ua,da=fa.layers[fa.indexOf(D)+1],la=P.layers[ea],xa=D instanceof Na&&D.clip,Aa=!!xa&&D.getClippingBase(),db=0,gb=0;if(D instanceof Na&&!D.clip)for(var Ea=F+1;Eada["get"+ea]());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"+ea](this.from[N]));this.layers.forEach(F=>g(F,D,!P))},fa.prototype.redo=function(){this.layers.forEach(F=>F["set"+ea](this.to));this.layers.forEach(F=>g(F,D,!P))},fa.prototype.merge=function(F){var N;if(N=F instanceof fa)a:{N=this.layers;var da=F.layers;if(N.length!=da.length)N=!1;else{for(let la=0;laP.addLayer(F));this.addLayerObject(D,P)};this.isRemoveLayerAllowed=function(){return qa instanceof Na?mb.getLinearizedLayerList(!1).some(D=>D instanceof Na&&D!=qa):qa instanceof ob&&mb.getLinearizedLayerList(!1).some(D=>D instanceof Na&&!D.hasAncestor(qa))};this.removeLayer=function(){return!!this.isRemoveLayerAllowed()&&(C(new U(qa)),!0)};this.duplicateLayer=function(){C(new W(qa))};this.isMergeDownAllowed=function(){let D=qa.parent.indexOf(qa);return 0T.LM_LAST_CHIBIPAINT)throw Error("Bad layer type during multiply upgrade");F.blendMode===T.LM_MULTIPLY&&(ea=fa)}if(-1!==ea){fa=new H(this.width,this.height);let N=F=!0,da=this.getBounds();fa.clearAll(da,16777215);for(let la=0;la<=ea;la++){let xa=P[la];N||(F=F&&fa.hasAlphaInRect(da));xa.blendMode===T.LM_MULTIPLY&&("bake"===D?!F&&0F){let N=Tb,da=vb,la=Rb;fa=(F-.001)/fa;for(F=fa;1>=F;F+=fa)N=F*D+(1-F)*Tb,da=F*P+(1-F)*vb,la=F*ea+(1-F)*Rb,this.paintDab(N,da,la);Tb=N;vb=da;Rb=la}}};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 Na&&!mb.layers[0].mask&&100==mb.layers[0].getEffectiveAlpha()};K.prototype=Object.create(zc.prototype);K.prototype.constructor=K;J.prototype=Object.create(zc.prototype);J.prototype.constructor=J;G.prototype=Object.create(zc.prototype);G.prototype.constructor=G;L.prototype=Object.create(zc.prototype);L.prototype.constructor=L;W.prototype=Object.create(zc.prototype);W.prototype.constructor=W;U.prototype= -Object.create(zc.prototype);U.prototype.constructor=U;X.prototype=Object.create(zc.prototype);X.prototype.constructor=X;Z.prototype=Object.create(zc.prototype);Z.prototype.constructor=Z;ia.prototype=Object.create(zc.prototype);ia.prototype.constructor=ia;wa.prototype=Object.create(zc.prototype);wa.prototype.constructor=wa;let Rc=Ia("alpha",!0),Sc=Ia("blendMode",!0),A=Ia("visible",!0),ta=Ia("clip",!0),uc=Ia("maskVisible",!0),Nc=Ia("name",!1),Xb=Ia("lockAlpha",!1),$c=Ia("maskLinked",!1);S.prototype= -Object.create(zc.prototype);S.prototype.constructor=S;class ua 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(ea=>{P.moveImage&&P.layer.image.copyBitmapRect(P.imageUndo,ea.left,ea.top,ea);P.moveMask&&P.layer.mask.copyBitmapRect(P.maskUndo,ea.left,ea.top,ea)}):(P.moveImage&&P.imageRect.forEach((ea,fa)=>{P.layer.image.copyBitmapRect(ea,fa.left,fa.top,ea.getBounds())}), -P.moveMask&&P.maskRect.forEach((ea,fa)=>{P.layer.mask.copyBitmapRect(ea,fa.left,fa.top,ea.getBounds())}))});k(this.movingLayers.map(P=>P.layer),D.reduce((P,ea)=>P.getUnion(ea),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(ea){return[ea.imageUndo,ea.maskUndo,ea.imageRect,ea.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(ea=>{P.moveImage&&P.imageRect.set(ea,P.imageUndo.cloneRect(ea));P.moveMask&&P.maskRect.set(ea, -P.maskUndo.cloneRect(ea))});P.imageUndo=null;P.maskUndo=null});this.hasFullUndo=!1}}constructor(){super();this.layer=qa;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 Na&& -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 Na,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=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 ea=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(da=>{if(fa.forEach(la=>{da.moveImage&&da.layer.image.clearRect(la,16777215);da.moveMask&&(this.movingWholeLayer?da.layer.mask.clearRect(la,255):da.layer.mask.clearRect(la,0))}),!this.dstRect.isEmpty()){if(da.moveImage){let la= -da.imageUndo.getImageData();ea.forEach(xa=>{this.composeCanvasContext.putImageData(la,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(da.imageSourceCanvas,this.srcRect.left, -this.srcRect.top);this.composeCanvasContext.restore();da.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()))}da.moveMask&&(ea.forEach(la=>{this.composeCanvasContext.putImageData(da.layer.mask.getImageData(la.left,la.top,la.getWidth(),la.getHeight()),la.left,la.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(da.maskSourceCanvas,this.srcRect.left,this.srcRect.top),this.composeCanvasContext.restore(),da.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(la=>{da.moveImage&&da.layer.image.copyBitmapRect(da.imageUndo,la.left,la.top,la);da.moveMask&&da.layer.mask.copyBitmapRect(da.maskUndo,la.left,la.top,la)})}),k(this.movingLayers.map(da=>da.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&&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(ea=> -pg(ea.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 ua{redo(){var D=this.dstRect.clone();let P,ea,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),ea=D.subtract(this.srcRect)):ea=[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));ea.forEach(function(da){N.moveImage&&N.layer.image.copyBitmapRect(N.imageUndo,da.left,da.top,da);N.moveMask&&N.layer.mask.copyBitmapRect(N.maskUndo, -da.left,da.top,da)});N.moveImage&&T.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),k(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,ea){super(); -this.offsetX=D;this.offsetY=P;this.erasesSourceRect=!ea}}za.prototype=Object.create(zc.prototype);za.prototype.constructor=za;na.prototype=Object.create(zc.prototype);na.prototype.constructor=na;Oa=[Nd,xh,yh,zh,fe,Ah,Bh,Ch].map(D=>new D(ma,Ca));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,m){this.static_tree=a;this.extra_bits=c; -this.extra_base=d;this.elems=b;this.max_length=m;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,m=Array(16),p=0;for(b=1;15>=b;b++)m[b]=p=p+d[b-1]<<1;for(d=0;d<=c;d++)b=a[2*d+1],0!==b&&(a[2*d]=rg(m[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-=m[2*d+1]);c.max_code=e;for(k=a.heap_len>>1;1<=k;k--)rf(a,b,k);d=g;do k=a.heap[1],a.heap[1]=a.heap[a.heap_len--], -rf(a,b,1),m=a.heap[1],a.heap[--a.heap_max]=k,a.heap[--a.heap_max]=m,b[2*d]=b[2*k]+b[2*m],a.depth[d]=(a.depth[k]>=a.depth[m]?a.depth[k]:a.depth[m])+1,b[2*k+1]=b[2*m+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,h,n,r,u;k=c.dyn_tree;d=c.max_code;m=c.stat_desc.static_tree;p=c.stat_desc.has_stree;g=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;k[2*a.heap[a.heap_max]+1]=0;for(c=a.heap_max+1;573> -c;c++)(n=k[2*k[2*(l=a.heap[c])+1]+1]+1)>x&&(n=x,C++),k[2*l+1]=n,l>d||(a.bl_count[n]++,r=0,l>=v&&(r=g[l-v]),u=k[2*l],a.opt_len+=u*(n+r),!p||(a.static_len+=u*(m[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||(k[2*h+1]!==n&&(a.opt_len+=(n-k[2*h+1])*k[2*h],k[2*h+1]=n),l--)}sg(b,e,a.bl_count)}function xg(a,c,d){var b,m=-1,p=c[1],g=0,e=7,k=4;0===p&&(e=138,k=3);c[2* -(d+1)+1]=65535;for(b=0;b<=d;b++){var l=p;p=c[2*(b+1)+1];++g=g?a.bl_tree[34]++:a.bl_tree[36]++,g=0,m=l,0===p?(e=138,k=3):l===p?(e=6,k=3):(e=7,k=4))}}function yg(a,c,d){var b,m,p=-1,g=c[1],e=0,k=7,l=4;0===g&&(k=138,l=3);for(b=0;b<=d;b++)if(m=g,g=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=m;0===g?(k=138,l=3):m===g?(k=6,l=3):(k=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,m=a.max_chain_length,p=a.strstart,g=a.prev_length,e=a.nice_match,k=a.strstart>a.w_size-262?a.strstart-(a.w_size-262):0,l=a.window,h=a.w_mask,n=a.prev,r=a.strstart+258,u=l[p+g- -1],v=l[p+g];a.prev_length>=a.good_match&&(m>>=2);e>a.lookahead&&(e=a.lookahead);do if(l[(d=c)+g]===v&&l[d+g-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]&&pg){if(a.match_start=c,g=b,b>=e)break;u=l[p+g-1];v=l[p+g]}}while((c=n[c&h])>k&&0!=--m);return g<=a.lookahead?g: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 m=c=a.hash_size;do{var p=a.head[--m];a.head[m]=p>=b?p-b:0}while(--c);m=c=b;do p=a.prev[--m],a.prev[m]=p>=b?p-b:0;while(--c);d+=b}if(0===a.strm.avail_in)break;m=a.strm;p=a.window;var g=a.strstart+a.lookahead,e=m.avail_in;if(c=(e>d&&(e=d),0===e)?0:(m.avail_in-=e,$a.arraySet(p,m.input,m.next_in,e,g),1===m.state.wrap?m.adler=Pd(m.adler,p,e,g):2===m.state.wrap&&(m.adler= -gc(m.adler,p,e,g)),m.next_in+=e,m.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,m;;){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,m){this.good_length=a;this.max_lazy=c;this.nice_length=d;this.max_chain=b;this.func=m}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);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 m=a.method,p=a.windowBits,g=a.memLevel,e=a.strategy;if(d){var k,l,h,n=1;if(-1===b&&(b=6),0>p?(n=0,p=-p):15g||9p||15b||9e||4k.wrap&&(k.wrap=-k.wrap),k.status=k.wrap?42:113,d.adler=2===k.wrap?0:1,k.last_flush=0,Fh(k),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),h)}}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 m;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):((m=a.wsize-a.wnext)>b&&(m=b),$a.arraySet(a.window,c,d-b,m,a.wnext), -(b-=m)?($a.arraySet(a.window,c,d-b,b,0),a.wnext=b,a.whave=a.wsize):(a.wnext+=m,a.wnext===a.wsize&&(a.wnext=0),a.whaveh.windowBits&&(h.windowBits=-h.windowBits,0===h.windowBits&&(h.windowBits=-15));0<=h.windowBits&&16>h.windowBits&&(!a||!a.windowBits)&&(h.windowBits+=32);15h.windowBits&&0==(15&h.windowBits)&&(h.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,m=h.windowBits,b?(g=new Ih,b.state=g,g.window=null,e=m,0!=(p=b&&b.state?(l=b.state,0>e?(k=0,e=-e):(k=(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,g){null===g?m.emitEvent("loadingProgress",[1,"Loading your "+p.friendly+"..."]):m.emitEvent("loadingProgress",[g,"Loading your "+p.friendly+" ("+Math.round(100*g)+"%)..."])}var d=[],b={},m=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(){g.required?m.emitEvent("loadingFailure",["Failed to load your "+g.friendly+", please try again later."]):m.load()}if(0==d.length)m.emitEvent("loadingComplete",[b]);else{var g=d.shift(),e=new XMLHttpRequest;e.addEventListener("progress",function(k){c(g,k.lengthComputable&&!g.noProgress?k.loaded/k.total:null)},!1);e.addEventListener("load", -function(k){if(200==this.status){let l=this.response;m.emitEvent("loadingProgress",[1,"Starting ChickenPaint..."]);setTimeout(function(){(function(h,n){switch(h.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),J=new Na(0,0,"Layer 1");J.image=H.createFromImage(C);K.addLayerObject(K.getLayersRoot(),J);C=null;window.URL.revokeObjectURL(x);r(K)};C.src= -x}else u(null)});case "swatches":return(h=(new Rd).read(n))?Promise.resolve(h):Promise.reject(null);case "layers":return function(r,u){function v(Z){let ia;var wa=X;if(null!==wa&&0!==wa.length)if(null===Z||0===Z.length)Z=wa;else{var Ia=new Uint8Array(wa.length+Z.length);Z=(Ia.set(wa,0),Ia.set(Z,wa.length),Ia)}for(X=Z;X;){if(Lnew Promise(function(ia,wa){let Ia=new Uint8Array(Z);(function(S){for(let za=0;8>za;za++)if(S[za]!="CHIBIOEK".charCodeAt(za))return!1;return!0})(Ia)? -(Ia=Ia.subarray(8),x.onData=v,x.onEnd=function(S){0===S&&45==C?(!1!==u.upgradeMultiplyLayers&&10>W.version&&K.upgradeMultiplyLayers(u.upgradeMultiplyLayers),K.selectTopmostVisibleLayer(),ia(K)):wa("Fatal error decoding ChibiFile: "+S)},x.push(Ia,!0)):wa("This doesn't appear to be a ChibiPaint layers file, is it damaged?")}))}(n);default:return Promise.reject("Unexpected resource type '"+h.name+"'")}})(g,l).then(function(h){b[g.name]=h;m.load()},function(){m.emitEvent("loadingFailure",["Failed to read your "+ -g.friendly])})},0)}else p()},!1);e.addEventListener("error",p);c(g,g.noProgress?null:0);e.open("GET",g.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 ka(a){return a in Ie?Ie[a]:a}function le(a){function c(e){null===e?p.emitEvent("savingProgress",[1,ka("Saving drawing...")]):p.emitEvent("savingProgress",[e,ka("Saving drawing...")+" ("+Math.round(100*e)+"%)"])}function d(e){p.emitEvent("savingFailure", -[e])}async function b(e){try{let k=await m(e),l=`${(k/1024/1024).toFixed(3)}MB`,h=`${a.post_max_size}MB`;if(console.log("Total size of FormData:",l),console.log("post_max_size:",h),a&&a.post_max_size&&k&&!isNaN(k)&&k>1048576*a.post_max_size){d(`${ka("The file size exceeds the server limit.")} +function(){return qa instanceof Na&&qa.clip};this.releaseClippingMask=function(){this.isReleaseClippingMaskAllowed()&&C(new ta(qa,!1))};this.setActiveLayer=function(D,P){if(D){let ea=(P=D.mask&&P)!=Ua;if(qa!=D||ea){let fa=qa;qa=D;Ua=P;x();this.emitEvent("changeActiveLayer",[fa,D,Ua]);ea&&this.emitEvent("editModeChanged",[Ua?Dc.EDITING_MODE_MASK:Dc.EDITING_MODE_IMAGE]);Ja&&Ja.layer==fa&&(P?Ja.setLayer(D):this.closeMaskView())}}};this.closeMaskView=function(){Ja.close();Ja=null};this.toggleMaskView= +function(){return null!=Ja&&Ja.isOpen()?this.closeMaskView():Ja=qa.mask?new wh(qa,n):null,Ja};this.selectTopmostVisibleLayer=function(){let D=mb.getLinearizedLayerList(!1);for(var P=D.length-1;0<=P;P--)if(D[P]instanceof Na&&0F){let N=Tb,da=vb,la=Rb;fa=(F-.001)/fa;for(F=fa;1>=F;F+=fa)N=F*D+(1-F)*Tb,da=F*P+(1-F)*vb,la=F*ea+(1-F)*Rb,this.paintDab(N,da,la);Tb=N;vb=da;Rb=la}}};this.endStroke=function(){null!=hb&&(n(),Oa[hb.brushMode].endStroke(),kb.clipTo(this.getBounds()),kb.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 Na&&!mb.layers[0].mask&&100==mb.layers[0].getEffectiveAlpha()};K.prototype=Object.create(zc.prototype);K.prototype.constructor=K;J.prototype=Object.create(zc.prototype);J.prototype.constructor=J;G.prototype=Object.create(zc.prototype); +G.prototype.constructor=G;L.prototype=Object.create(zc.prototype);L.prototype.constructor=L;W.prototype=Object.create(zc.prototype);W.prototype.constructor=W;U.prototype=Object.create(zc.prototype);U.prototype.constructor=U;X.prototype=Object.create(zc.prototype);X.prototype.constructor=X;Z.prototype=Object.create(zc.prototype);Z.prototype.constructor=Z;ia.prototype=Object.create(zc.prototype);ia.prototype.constructor=ia;wa.prototype=Object.create(zc.prototype);wa.prototype.constructor=wa;let Rc= +Ia("alpha",!0),Sc=Ia("blendMode",!0),A=Ia("visible",!0),ta=Ia("clip",!0),uc=Ia("maskVisible",!0),Nc=Ia("name",!1),Xb=Ia("lockAlpha",!1),$c=Ia("maskLinked",!1);S.prototype=Object.create(zc.prototype);S.prototype.constructor=S;class ua 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(ea=>{P.moveImage&&P.layer.image.copyBitmapRect(P.imageUndo,ea.left,ea.top,ea); +P.moveMask&&P.layer.mask.copyBitmapRect(P.maskUndo,ea.left,ea.top,ea)}):(P.moveImage&&P.imageRect.forEach((ea,fa)=>{P.layer.image.copyBitmapRect(ea,fa.left,fa.top,ea.getBounds())}),P.moveMask&&P.maskRect.forEach((ea,fa)=>{P.layer.mask.copyBitmapRect(ea,fa.left,fa.top,ea.getBounds())}))});k(this.movingLayers.map(P=>P.layer),D.reduce((P,ea)=>P.getUnion(ea),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(ea){return[ea.imageUndo,ea.maskUndo,ea.imageRect,ea.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(ea=>{P.moveImage&&P.imageRect.set(ea,P.imageUndo.cloneRect(ea));P.moveMask&&P.maskRect.set(ea,P.maskUndo.cloneRect(ea))});P.imageUndo=null;P.maskUndo=null});this.hasFullUndo=!1}}constructor(){super();this.layer=qa;this.fromSelection=ha.getSelection();this.fromMaskMode=Ua;this.movingWholeLayer=this.fromSelection.isEmpty();this.movingImage=!Ua||this.movingWholeLayer&&this.layer.maskLinked; +this.movingMask=Ua||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 Na&&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 +Na,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=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 ea=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(da=> +{if(fa.forEach(la=>{da.moveImage&&da.layer.image.clearRect(la,16777215);da.moveMask&&(this.movingWholeLayer?da.layer.mask.clearRect(la,255):da.layer.mask.clearRect(la,0))}),!this.dstRect.isEmpty()){if(da.moveImage){let la=da.imageUndo.getImageData();ea.forEach(xa=>{this.composeCanvasContext.putImageData(la,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(da.imageSourceCanvas,this.srcRect.left,this.srcRect.top);this.composeCanvasContext.restore();da.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()))}da.moveMask&& +(ea.forEach(la=>{this.composeCanvasContext.putImageData(da.layer.mask.getImageData(la.left,la.top,la.getWidth(),la.getHeight()),la.left,la.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(da.maskSourceCanvas,this.srcRect.left,this.srcRect.top),this.composeCanvasContext.restore(),da.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(la=>{da.moveImage&&da.layer.image.copyBitmapRect(da.imageUndo,la.left,la.top,la);da.moveMask&&da.layer.mask.copyBitmapRect(da.maskUndo, +la.left,la.top,la)})}),k(this.movingLayers.map(da=>da.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&&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(ea=>pg(ea.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 ua{redo(){var D=this.dstRect.clone();let P,ea,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),ea=D.subtract(this.srcRect)): +ea=[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));ea.forEach(function(da){N.moveImage&&N.layer.image.copyBitmapRect(N.imageUndo,da.left,da.top,da);N.moveMask&&N.layer.mask.copyBitmapRect(N.maskUndo,da.left,da.top,da)});N.moveImage&&T.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),k(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,ea){super();this.offsetX=D;this.offsetY=P;this.erasesSourceRect=!ea}}za.prototype=Object.create(zc.prototype);za.prototype.constructor=za;na.prototype=Object.create(zc.prototype);na.prototype.constructor=na; +Oa=[Nd,xh,yh,zh,fe,Ah,Bh,Ch].map(D=>new D(ma,Ca));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,l){this.static_tree=a;this.extra_bits=c;this.extra_base=d;this.elems=b;this.max_length=l;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,l=Array(16),p=0;for(b=1;15>=b;b++)l[b]=p=p+d[b-1]<<1;for(d=0;d<=c;d++)b=a[2*d+1],0!==b&&(a[2*d]=rg(l[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-=l[2*d+1]);c.max_code=e;for(k=a.heap_len>>1;1<=k;k--)rf(a,b,k);d=g;do k=a.heap[1],a.heap[1]=a.heap[a.heap_len--],rf(a,b,1),l=a.heap[1],a.heap[--a.heap_max]=k,a.heap[--a.heap_max]=l,b[2*d]=b[2*k]+b[2*l],a.depth[d]=(a.depth[k]>=a.depth[l]?a.depth[k]:a.depth[l])+1,b[2*k+1]=b[2*l+1]=d,a.heap[1]=d++,rf(a,b,1);while(2<=a.heap_len); +a.heap[--a.heap_max]=a.heap[1];var m,h,n,r,u;k=c.dyn_tree;d=c.max_code;l=c.stat_desc.static_tree;p=c.stat_desc.has_stree;g=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;k[2*a.heap[a.heap_max]+1]=0;for(c=a.heap_max+1;573>c;c++)(n=k[2*k[2*(m=a.heap[c])+1]+1]+1)>x&&(n=x,C++),k[2*m+1]=n,m>d||(a.bl_count[n]++,r=0,m>=v&&(r=g[m-v]),u=k[2*m],a.opt_len+=u*(n+r),!p||(a.static_len+=u*(l[2*m+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||(k[2*h+1]!==n&&(a.opt_len+=(n-k[2*h+1])*k[2*h],k[2*h+1]=n),m--)}sg(b,e,a.bl_count)}function xg(a,c,d){var b,l=-1,p=c[1],g=0,e=7,k=4;0===p&&(e=138,k=3);c[2*(d+1)+1]=65535;for(b=0;b<=d;b++){var m=p;p=c[2*(b+1)+1];++g=g?a.bl_tree[34]++:a.bl_tree[36]++,g=0,l=m,0===p?(e=138,k=3):m===p?(e=6, +k=3):(e=7,k=4))}}function yg(a,c,d){var b,l,p=-1,g=c[1],e=0,k=7,m=4;0===g&&(k=138,m=3);for(b=0;b<=d;b++)if(l=g,g=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=l;0===g?(k=138,m=3):l===g?(k=6,m=3):(k=7,m=4)}}function zg(a,c,d,b){Ec(a,b?1:0,3);ug(a);he(a,d);he(a,~d);ab.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&&(ab.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,l=a.max_chain_length,p=a.strstart,g=a.prev_length,e=a.nice_match,k=a.strstart>a.w_size-262?a.strstart-(a.w_size-262):0,m=a.window,h=a.w_mask,n=a.prev,r=a.strstart+258,u=m[p+g-1],v=m[p+g];a.prev_length>=a.good_match&&(l>>=2);e>a.lookahead&&(e=a.lookahead);do if(m[(d=c)+g]===v&&m[d+g-1]===u&&m[d]===m[p]&&m[++d]===m[p+1]){p+=2;for(d++;m[++p]===m[++d]&&m[++p]===m[++d]&&m[++p]===m[++d]&&m[++p]=== +m[++d]&&m[++p]===m[++d]&&m[++p]===m[++d]&&m[++p]===m[++d]&&m[++p]===m[++d]&&pg){if(a.match_start=c,g=b,b>=e)break;u=m[p+g-1];v=m[p+g]}}while((c=n[c&h])>k&&0!=--l);return g<=a.lookahead?g: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)){ab.arraySet(a.window,a.window,b,b,0);a.match_start-=b;a.strstart-=b;a.block_start-=b;var l=c=a.hash_size;do{var p=a.head[--l];a.head[l]=p>=b?p-b:0}while(--c);l=c=b;do p=a.prev[--l], +a.prev[l]=p>=b?p-b:0;while(--c);d+=b}if(0===a.strm.avail_in)break;l=a.strm;p=a.window;var g=a.strstart+a.lookahead,e=l.avail_in;if(c=(e>d&&(e=d),0===e)?0:(l.avail_in-=e,ab.arraySet(p,l.input,l.next_in,e,g),1===l.state.wrap?l.adler=Pd(l.adler,p,e,g):2===l.state.wrap&&(l.adler=gc(l.adler,p,e,g)),l.next_in+=e,l.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,l;;){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,l){this.good_length=a;this.max_lazy=c;this.nice_length=d;this.max_chain=b;this.func=l}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 ab.Buf16(1146);this.dyn_dtree=new ab.Buf16(122);this.bl_tree=new ab.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 ab.Buf16(16);this.heap=new ab.Buf16(573);od(this.heap);this.heap_max=this.heap_len=0;this.depth=new ab.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,ab.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 l=a.method,p=a.windowBits,g=a.memLevel,e=a.strategy;if(d){var k,m,h,n=1;if(-1===b&& +(b=6),0>p?(n=0,p=-p):15g||9p||15b||9e||4k.wrap&&(k.wrap=-k.wrap),k.status=k.wrap?42:113,d.adler=2===k.wrap?0:1,k.last_flush=0,Fh(k),0):nd(d,-2))&&((m=d.state).window_size=2*m.w_size,od(m.head),m.max_lazy_match=ke[m.level].max_lazy,m.good_match=ke[m.level].good_length,m.nice_match=ke[m.level].nice_length,m.max_chain_length=ke[m.level].max_chain,m.strstart=0,m.block_start= +0,m.lookahead=0,m.insert=0,m.match_length=m.prev_length=2,m.match_available=0,m.ins_h=0),h)}}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 ab.Buf16(320);this.work=new ab.Buf16(288);this.distdyn=this.lendyn=null;this.was= +this.back=this.sane=0}function Gg(a,c,d,b){var l;a=a.state;return null===a.window&&(a.wsize=1<=a.wsize?(ab.arraySet(a.window,c,d-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):((l=a.wsize-a.wnext)>b&&(l=b),ab.arraySet(a.window,c,d-b,l,a.wnext),(b-=l)?(ab.arraySet(a.window,c,d-b,b,0),a.wnext=b,a.whave=a.wsize):(a.wnext+=l,a.wnext===a.wsize&&(a.wnext=0),a.whaveh.windowBits&&(h.windowBits=-h.windowBits,0===h.windowBits&&(h.windowBits=-15));0<=h.windowBits&&16>h.windowBits&&(!a||!a.windowBits)&&(h.windowBits+=32);15h.windowBits&&0==(15&h.windowBits)&&(h.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,l=h.windowBits,b?(g=new Ih,b.state= +g,g.window=null,e=l,0!=(p=b&&b.state?(m=b.state,0>e?(k=0,e=-e):(k=(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,g){null===g?l.emitEvent("loadingProgress",[1,"Loading your "+p.friendly+"..."]):l.emitEvent("loadingProgress", +[g,"Loading your "+p.friendly+" ("+Math.round(100*g)+"%)..."])}var d=[],b={},l=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(){g.required? +l.emitEvent("loadingFailure",["Failed to load your "+g.friendly+", please try again later."]):l.load()}if(0==d.length)l.emitEvent("loadingComplete",[b]);else{var g=d.shift(),e=new XMLHttpRequest;e.addEventListener("progress",function(k){c(g,k.lengthComputable&&!g.noProgress?k.loaded/k.total:null)},!1);e.addEventListener("load",function(k){if(200==this.status){let m=this.response;l.emitEvent("loadingProgress",[1,"Starting ChickenPaint..."]);setTimeout(function(){(function(h,n){switch(h.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),J=new Na(0,0,"Layer 1");J.image=H.createFromImage(C);K.addLayerObject(K.getLayersRoot(),J);C=null;window.URL.revokeObjectURL(x);r(K)};C.src=x}else u(null)});case "swatches":return(h=(new Rd).read(n))?Promise.resolve(h):Promise.reject(null);case "layers":return function(r,u){function v(Z){let ia;var wa=X;if(null!==wa&&0!==wa.length)if(null===Z||0=== +Z.length)Z=wa;else{var Ia=new Uint8Array(wa.length+Z.length);Z=(Ia.set(wa,0),Ia.set(Z,wa.length),Ia)}for(X=Z;X;){if(Lnew Promise(function(ia,wa){let Ia=new Uint8Array(Z);(function(S){for(let za=0;8>za;za++)if(S[za]!="CHIBIOEK".charCodeAt(za))return!1;return!0})(Ia)?(Ia=Ia.subarray(8),x.onData=v,x.onEnd=function(S){0===S&&45==C?(!1!==u.upgradeMultiplyLayers&&10>W.version&&K.upgradeMultiplyLayers(u.upgradeMultiplyLayers),K.selectTopmostVisibleLayer(),ia(K)):wa("Fatal error decoding ChibiFile: "+S)}, +x.push(Ia,!0)):wa("This doesn't appear to be a ChibiPaint layers file, is it damaged?")}))}(n);default:return Promise.reject("Unexpected resource type '"+h.name+"'")}})(g,m).then(function(h){b[g.name]=h;l.load()},function(){l.emitEvent("loadingFailure",["Failed to read your "+g.friendly])})},0)}else p()},!1);e.addEventListener("error",p);c(g,g.noProgress?null:0);e.open("GET",g.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 ka(a){return a in Ie?Ie[a]:a}function le(a){function c(e){null===e?p.emitEvent("savingProgress",[1,ka("Saving drawing...")]):p.emitEvent("savingProgress",[e,ka("Saving drawing...")+" ("+Math.round(100*e)+"%)"])}function d(e){p.emitEvent("savingFailure",[e])}async function b(e){try{let k=await l(e),m=`${(k/1024/1024).toFixed(3)}MB`,h=`${a.post_max_size}MB`;if(console.log("Total size of FormData:",m),console.log("post_max_size:",h),a&&a.post_max_size&&k&&!isNaN(k)&&k>1048576* +a.post_max_size){d(`${ka("The file size exceeds the server limit.")} ${ka("Limit size")}:${h} -${ka("Current size")}:${l}`);return}console.log(ka("The total size of FormData is within the acceptable range."))}catch(k){console.error("Error details:",k);d("An error occurred in the getFormDataSize function.");return}c(.5);fetch(a.url,{method:"POST",mode:"same-origin",headers:{"X-Requested-With":"chickenpaint"},body:e}).then(k=>{if(!k.ok)throw Error("Network response was not ok (".concat(k.status,")"));return k.text()}).then(k=>{/^CHIBIOK/.test(k)?(c(1),p.emitEvent("savingComplete")):d(k)}).catch(k=> -{d(k.message)})}async function m(e){if(a.post_max_size)return e=Array.from(e.entries()).map(([k,l])=>"string"==typeof l?new Blob([`${k}=${l}`]):l),(new Blob(e)).size}var p=this,g=!1;a.rotation=a.rotation||0;this.save=function(){var e,k,l,h,n;(e=new Blob([function(r){for(var u=new Uint8Array(r.length),v=0;v +${ka("Current size")}:${m}`);return}console.log(ka("The total size of FormData is within the acceptable range."))}catch(k){console.error("Error details:",k);d("An error occurred in the getFormDataSize function.");return}c(.5);fetch(a.url,{method:"POST",mode:"same-origin",headers:{"X-Requested-With":"chickenpaint"},body:e}).then(k=>{if(!k.ok)throw Error("Network response was not ok (".concat(k.status,")"));return k.text()}).then(k=>{/^CHIBIOK/.test(k)?(c(1),p.emitEvent("savingComplete")):d(k)}).catch(k=> +{d(k.message)})}async function l(e){if(a.post_max_size)return e=Array.from(e.entries()).map(([k,m])=>"string"==typeof m?new Blob([`${k}=${m}`]):m),(new Blob(e)).size}var p=this,g=!1;a.rotation=a.rotation||0;this.save=function(){var e,k,m,h,n;(e=new Blob([function(r){for(var u=new Uint8Array(r.length),v=0;v {var r,u;let v,x=new (Y(Cf).Deflate)({level:7}),C=[],K=new Uint8Array(8),J=h.getLayersRoot().getLinearizedLayerList(!1),G=n.forceOldVersion?0:function(W){for(let U of W.getLayersRoot().getLinearizedLayerList(!1))if(U instanceof ob||U.mask||U.clip||U.blendMode>T.LM_LAST_CHIBIPAINT||U.blendMode===T.LM_MULTIPLY)return 10;return 0}(h),L=0===(u=Kg(G)).major&&0===u.minor?"ChibiPaint v0.0":"ChickenPaint v"+u.major+"."+u.minor;u=Promise.resolve();x.onData=function(W){C.push(W)};for(let W=0;8>W;W++)K[W]="CHIBIOEK".charCodeAt(W); for(let W of(C.push(K),x.push((r=J.length,(v=Bf("HEAD",Af.FIXED_HEADER_LENGTH)).writeU32BE(G),v.writeU32BE(h.width),v.writeU32BE(h.height),v.writeU32BE(r),v.getAsDataArray()),!1),J))u=u.then(()=>new Promise(function(U){var X=x.push,Z=W,ia=Z instanceof Na,wa=4*(ia?5:6),Ia=Z.name.length;var S=Bf(ia?"LAYR":"GRUP",wa+Ia+((ia?Z.image.data.length:0)+(Z.mask?Z.mask.data.length:0)));var za=0;let na;Z.visible&&(za|=1);ia&&Z.clip&&(za|=2);Z.mask&&(za|=4);Z.maskLinked&&(za|=8);Z.maskVisible&&(za|=16);Z.lockAlpha&& (za|=64);!ia&&Z.expanded&&(za|=32);Z.blendMode===T.LM_MULTIPLY2?(na=T.LM_MULTIPLY,za|=128):na=Z.blendMode;S.writeU32BE(wa+Ia);S.writeU32BE(na);S.writeU32BE(Z.alpha);S.writeU32BE(za);S.writeU32BE(Z.name.length);ia||S.writeU32BE(Z.layers.length);S.writeString(Z.name);if(ia){ia=S.pos;wa=S.data;Ia=Z.image.data;for(za=0;zanew Promise((W,U)=>{x.onEnd=function(X){if(0===X)if("undefined"!=typeof Blob)W({bytes:new Blob(C,{type:"application/octet-stream"}),version:L});else{X=new Uint8Array(C.map(ia=>ia.byteLength).reduce((ia,wa)=>ia+wa,0));let Z=0;for(let ia of C)X.set(ia,Z),Z+=ia.byteLength;W({bytes:X,version:L})}else U(X)};x.push(Bf("ZEND",0).getAsDataArray(),!0)}))}));l.then(function(r){if(g)p.emitEvent("savingFailure"); +(Z=Z.mask,S.data.set(Z.data,S.pos),S.pos+=Z.data.length);S=S.getAsDataArray();X.call(x,S,!1);setTimeout(U,10)}));return u.then(()=>new Promise((W,U)=>{x.onEnd=function(X){if(0===X)if("undefined"!=typeof Blob)W({bytes:new Blob(C,{type:"application/octet-stream"}),version:L});else{X=new Uint8Array(C.map(ia=>ia.byteLength).reduce((ia,wa)=>ia+wa,0));let Z=0;for(let ia of C)X.set(ia,Z),Z+=ia.byteLength;W({bytes:X,version:L})}else U(X)};x.push(Bf("ZEND",0).getAsDataArray(),!0)}))}));m.then(function(r){if(g)p.emitEvent("savingFailure"); else if(k=a.swatches?new Blob([(new Rd).write(a.swatches)],{type:"application/octet-stream"}):null,a.url){var u=new FormData;u.append("beginMarker","This marker ensures the upload wasn't truncated");u.append("painter","ChickenPaint v2.0");u.append("picture",e);e=null;r?(u.append("chibifileFormat",r.version),u.append("chibifile",r.bytes),u.append("rotation",""+a.rotation)):u.append("rotation","0");k&&(u.append("swatches",k),k=null);u.append("endMarker","This marker ensures the upload wasn't truncated"); -b(u)}else u="oekaki_"+(new Date).toISOString().split(".")[0].replace(/[^0-9]/g,"_"),Y(me).saveAs(e,u+".png"),r&&Y(me).saveAs(r.bytes,u+".chi"),k&&Y(me).saveAs(k,u+".aco")}).catch(function(r){p.emitEvent("savingFailure")})};this.cancel=function(){g=!0}}function Mh(a,c,d){function b(){var X=l.width/2,Z=l.height/2;if(h.fillStyle="white",h.fillRect(0,0,l.width,l.height),G==J.length){var ia=v.width,wa=v.height,Ia=Math.round(X-ia/2),S=Math.round(Z-wa/2);h.drawImage(v,Ia,S);var za=L;p||((p=document.createElement("canvas")).width= +b(u)}else u="oekaki_"+(new Date).toISOString().split(".")[0].replace(/[^0-9]/g,"_"),Y(me).saveAs(e,u+".png"),r&&Y(me).saveAs(r.bytes,u+".chi"),k&&Y(me).saveAs(k,u+".aco")}).catch(function(r){p.emitEvent("savingFailure")})};this.cancel=function(){g=!0}}function Mh(a,c,d){function b(){var X=m.width/2,Z=m.height/2;if(h.fillStyle="white",h.fillRect(0,0,m.width,m.height),G==J.length){var ia=v.width,wa=v.height,Ia=Math.round(X-ia/2),S=Math.round(Z-wa/2);h.drawImage(v,Ia,S);var za=L;p||((p=document.createElement("canvas")).width= ia,p.height=wa,e=p.getContext("2d"));e.globalCompositeOperation="copy";e.drawImage(n,0,0);g||((g=document.createElement("canvas")).width=ia,g.height=wa,k=g.getContext("2d"));k.globalCompositeOperation="copy";k.drawImage(K,0,0);k.globalCompositeOperation="source-in";k.drawImage(K,0,Math.round(170*za));e.globalCompositeOperation="source-over";e.drawImage(g,0,0);e.drawImage(r,0,0);e.globalCompositeOperation="screen";e.drawImage(C,0,0);e.globalCompositeOperation="multiply";e.drawImage(x,0,0);h.globalAlpha= -.88;h.drawImage(p,Ia,S);h.globalAlpha=1;h.drawImage(u,Ia,S);Z=Math.round(Z+wa/2+2)}if(""!=W)for(h.fillStyle="black",za=W.split("\n"),ia=0;ia=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,m,p,g,e;this.x0=this.y0=this.x1=this.y1=this.x2=this.y2=this.x3=this.y3=0;let k=l=> -{let h=3*l,n=h*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;m=this.y0;c=(this.x1-this.x0)*h+v*n+C*l;p=(this.y1-this.y0)*h+x*n+K*l;d=v*r+C*u;g=x*r+K*u;b=C*u;e=K*u};this.compute=(l,h,n)=>{k(1/n);l[0]=a;h[0]=m;for(let r=1;ra?g():!0!==c&&(m=setTimeout(b?function(){m=void 0}:g,void 0===b?a-k: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),m=b.data,p=0,g=0;64>g;g++)for(var e=0;64>e;e++)0!=(8&e)^0!=(8&g)?(m[p++]=255,m[p++]=255,m[p++]=255):(m[p++]=204,m[p++]=204,m[p++]=204),m[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?Y(ja)(d).height():Y(ja)(d).width();n=k/(g-p)*x;x=(e-p)/(g-p)*(x-n);m.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"),m=document.createElement("div"),p=0,g=1,e=0,k=1,l=10,h=!1,n=1,r=!1,u,v=this;this.setValues=function(x,C,K,J){e=x;k=C;p=K;g=J;c()};this.setBlockIncrement=function(x){l=x};this.setUnitIncrement=function(x){};this.getElement=function(){return d};this.getValueIsAdjusting=function(){return h};d.className="chickenpaint-scrollbar "+(a?"chickenpaint-scrollbar-vertical":"chickenpaint-scrollbar-horizontal");b.className="chickenpaint-scrollbar-handle"; -b.setAttribute("touch-action","none");m.className="chickenpaint-scrollbar-handle-inner";b.appendChild(m);d.appendChild(b);b.addEventListener("pointerdown",function(x){x.stopPropagation();u=a?x.pageY-Y(ja)(d).offset().top:x.pageX-Y(ja)(d).offset().left;b.setPointerCapture(x.pointerId);Y(ja)(b).addClass("dragging");r=!0});b.addEventListener("pointermove",function(x){if(r){h=!0;let C=a?Y(ja)(d).height():Y(ja)(d).width();x=a?x.pageY-Y(ja)(d).offset().top:x.pageX-Y(ja)(d).offset().left;e+=(x-u)*(g-p)/ -(C-n);e=Math.min(Math.max(e,p),g);u=x;v.emitEvent("valueChanged",[e]);c();h=!1}});b.addEventListener("pointerup",function(x){if(x.stopPropagation(),r){try{b.releasePointerCapture(x.pointerId)}catch(C){}Y(ja)(b).removeClass("dragging");r=!1}});b.addEventListener("click",function(x){x.stopPropagation()});d.addEventListener("click",function(x){this==d&&((a?x.pageY-Y(ja)(d).offset().top:x.pageX-Y(ja)(d).offset().left)Aa;Aa++)Ja.continueStroke(cb[Aa],gb[Aa],1);Ja.endStroke();Ka.repaintAll()}return!0}};this.mouseMove=function(Aa,cb){if(this.capture)return Aa=L({x:rb,y:hb}),1==F?da=Aa:2==F&&(la=Aa),Ka.repaintAll(),!0;b.prototype.mouseMove.call(this,Aa,cb)};this.paint=function(){if(this.capture){var Aa=new Mg;let cb=U(N),gb=U(da),Ea=U(la),jb=U(xa);Aa.x0=cb.x;Aa.y0=cb.y;Aa.x1=gb.x;Aa.y1=gb.y;Aa.x2=Ea.x;Aa.y2=Ea.y;Aa.x3=jb.x;Aa.y3=jb.y;let Vb=Array(100),kc=Array(100);Aa.compute(Vb, -kc,100);ha.beginPath();ha.moveTo(Vb[0],kc[0]);for(Aa=1;100>Aa;Aa++)ha.lineTo(Vb[Aa],kc[Aa]);ha.moveTo(~~cb.x,~~cb.y);ha.lineTo(~~gb.x,~~gb.y);ha.moveTo(~~Ea.x,~~Ea.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,da,la){return!!this.capture||(Y(Sb).isPressed("space")||(0!=da||this.transient&&!N.altKey)&&2!=da?void(this.transient&&ua.pop()):(F=da,this.capture=!0,x("crosshair"),this.mouseDrag(N),!0))};this.mouseDrag= +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,l,p,g,e;this.x0=this.y0=this.x1=this.y1=this.x2=this.y2=this.x3=this.y3=0;let k=m=> +{let h=3*m,n=h*m;m*=m*m;let r=2*n,u=6*m,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;l=this.y0;c=(this.x1-this.x0)*h+v*n+C*m;p=(this.y1-this.y0)*h+x*n+K*m;d=v*r+C*u;g=x*r+K*u;b=C*u;e=K*u};this.compute=(m,h,n)=>{k(1/n);m[0]=a;h[0]=l;for(let r=1;ra?g():!0!==c&&(l=setTimeout(b?function(){l=void 0}:g,void 0===b?a-k: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),l=b.data,p=0,g=0;64>g;g++)for(var e=0;64>e;e++)0!=(8&e)^0!=(8&g)?(l[p++]=255,l[p++]=255,l[p++]=255):(l[p++]=204,l[p++]=204,l[p++]=204),l[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?Y(ja)(d).height():Y(ja)(d).width();n=k/(g-p)*x;x=(e-p)/(g-p)*(x-n);l.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"),l=document.createElement("div"),p=0,g=1,e=0,k=1,m=10,h=!1,n=1,r=!1,u,v=this;this.setValues=function(x,C,K,J){e=x;k=C;p=K;g=J;c()};this.setBlockIncrement=function(x){m=x};this.setUnitIncrement=function(x){};this.getElement=function(){return d};this.getValueIsAdjusting=function(){return h};d.className="chickenpaint-scrollbar "+(a?"chickenpaint-scrollbar-vertical":"chickenpaint-scrollbar-horizontal");b.className="chickenpaint-scrollbar-handle"; +b.setAttribute("touch-action","none");l.className="chickenpaint-scrollbar-handle-inner";b.appendChild(l);d.appendChild(b);b.addEventListener("pointerdown",function(x){x.stopPropagation();u=a?x.pageY-Y(ja)(d).offset().top:x.pageX-Y(ja)(d).offset().left;b.setPointerCapture(x.pointerId);Y(ja)(b).addClass("dragging");r=!0});b.addEventListener("pointermove",function(x){if(r){h=!0;let C=a?Y(ja)(d).height():Y(ja)(d).width();x=a?x.pageY-Y(ja)(d).offset().top:x.pageX-Y(ja)(d).offset().left;e+=(x-u)*(g-p)/ +(C-n);e=Math.min(Math.max(e,p),g);u=x;v.emitEvent("valueChanged",[e]);c();h=!1}});b.addEventListener("pointerup",function(x){if(x.stopPropagation(),r){try{b.releasePointerCapture(x.pointerId)}catch(C){}Y(ja)(b).removeClass("dragging");r=!1}});b.addEventListener("click",function(x){x.stopPropagation()});d.addEventListener("click",function(x){this==d&&((a?x.pageY-Y(ja)(d).offset().top:x.pageX-Y(ja)(d).offset().left)Aa;Aa++)Ja.continueStroke(db[Aa],gb[Aa],1);Ja.endStroke();Ka.repaintAll()}return!0}};this.mouseMove=function(Aa,db){if(this.capture)return Aa=L({x:rb,y:hb}),1==F?da=Aa:2==F&&(la=Aa),Ka.repaintAll(),!0;b.prototype.mouseMove.call(this,Aa,db)};this.paint=function(){if(this.capture){var Aa=new Mg;let db=U(N),gb=U(da),Ea=U(la),jb=U(xa);Aa.x0=db.x;Aa.y0=db.y;Aa.x1=gb.x;Aa.y1=gb.y;Aa.x2=Ea.x;Aa.y2=Ea.y;Aa.x3=jb.x;Aa.y3=jb.y;let Vb=Array(100),kc=Array(100);Aa.compute(Vb, +kc,100);ha.beginPath();ha.moveTo(Vb[0],kc[0]);for(Aa=1;100>Aa;Aa++)ha.lineTo(Vb[Aa],kc[Aa]);ha.moveTo(~~db.x,~~db.y);ha.lineTo(~~gb.x,~~gb.y);ha.moveTo(~~Ea.x,~~Ea.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,da,la){return!!this.capture||(Y(Sb).isPressed("space")||(0!=da||this.transient&&!N.altKey)&&2!=da?void(this.transient&&ua.pop()):(F=da,this.capture=!0,x("crosshair"),this.mouseDrag(N),!0))};this.mouseDrag= function(N){if(this.capture)return N=L({x:rb,y:hb}),Ja.isPointWithin(N.x,N.y)&&a.setCurColor(new Bb(Ja.colorPicker(N.x,N.y))),!0};this.mouseUp=function(N,da,la){if(this.capture&&da==F)return F=-1,this.capture=!1,x("default"),this.transient&&ua.pop(),!0};this.enter=function(){c.prototype.enter.call(this);F=-1}}function k(){var F,N,da,la;this.keyDown=function(xa){if(" "===xa.key)return this.capture||x("grab"),!0};this.keyUp=function(xa){if(this.transient&&1!=la&&" "===xa.key)return x("default"),ua.pop(), -!0};this.mouseDown=function(xa,Aa,cb){return!!this.capture||(1==Aa||Y(Sb).isPressed("space")&&0==Aa||!this.transient&&0==Aa?(this.capture=!0,la=Aa,F=xa.pageX,N=xa.pageY,da=Ka.getOffset(),x("grabbing"),!0):void(this.transient&&ua.pop()))};this.mouseDrag=function(xa){if(this.capture)return Ka.setOffset(da.x+xa.pageX-F,da.y+xa.pageY-N),!0};this.mouseUp=function(xa,Aa,cb){if(this.capture&&Aa==la)return la=-1,this.capture=!1,this.transient&&!Y(Sb).isPressed("space")&&(x("default"),ua.pop()),!0};this.enter= -function(){x("grab")}}function l(){}function h(){var F,N=new Ha(0,0,0,0),da=-1;this.mouseDown=function(la,xa,Aa){if(!this.capture&&0==xa&&!la.altKey&&!Y(Sb).isPressed("space"))return la=W({x:rb,y:hb}),da=xa,N.makeEmpty(),F=la,Ka.repaintAll(),this.capture=!0,!0};this.mouseDrag=function(la){if(!this.capture)return!1;var xa=W({x:rb,y:hb});la=la.shiftKey;var Aa=~~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=(la?F.x+Aa:xa.x)+1):(N.left=la?F.x-Aa:xa.x,N.right=F.x+ +!0};this.mouseDown=function(xa,Aa,db){return!!this.capture||(1==Aa||Y(Sb).isPressed("space")&&0==Aa||!this.transient&&0==Aa?(this.capture=!0,la=Aa,F=xa.pageX,N=xa.pageY,da=Ka.getOffset(),x("grabbing"),!0):void(this.transient&&ua.pop()))};this.mouseDrag=function(xa){if(this.capture)return Ka.setOffset(da.x+xa.pageX-F,da.y+xa.pageY-N),!0};this.mouseUp=function(xa,Aa,db){if(this.capture&&Aa==la)return la=-1,this.capture=!1,this.transient&&!Y(Sb).isPressed("space")&&(x("default"),ua.pop()),!0};this.enter= +function(){x("grab")}}function m(){}function h(){var F,N=new Ha(0,0,0,0),da=-1;this.mouseDown=function(la,xa,Aa){if(!this.capture&&0==xa&&!la.altKey&&!Y(Sb).isPressed("space"))return la=W({x:rb,y:hb}),da=xa,N.makeEmpty(),F=la,Ka.repaintAll(),this.capture=!0,!0};this.mouseDrag=function(la){if(!this.capture)return!1;var xa=W({x:rb,y:hb});la=la.shiftKey;var Aa=~~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=(la?F.x+Aa:xa.x)+1):(N.left=la?F.x-Aa:xa.x,N.right=F.x+ 1),xa.y>=F.y?(N.top=F.y,N.bottom=(la?F.y+Aa:xa.y)+1):(N.top=la?F.y-Aa:xa.y,N.bottom=F.y+1),Ka.repaintAll(),!0};this.mouseUp=function(la,xa,Aa){if(this.capture&&xa==da)return Ja.rectangleSelection(N),N.makeEmpty(),Ka.repaintAll(),this.capture=!1,da=-1,!0};this.paint=function(){N.isEmpty()||(ha.lineWidth=1,ia(ha,N))}}function n(){var F,N,da=!1;this.mouseDown=function(la,xa,Aa){if(!this.capture&&0==xa&&!Y(Sb).isPressed("space")&&C())return F=L({x:rb,y:hb}),N=la.altKey,da=!0,this.capture=!0,!0};this.mouseDrag= -Ng(25,function(la){if(this.capture){la=L({x:rb,y:hb});var xa=la.x-F.x,Aa=la.y-F.y,cb=~~xa,gb=~~Aa;return(0!=cb||0!=gb)&&(Ja.move(cb,gb,N&&da),da=!1),F.x=la.x-(xa-cb),F.y=la.y-(Aa-gb),!0}});this.mouseUp=function(la,xa,Aa){if(this.capture&&0==xa)return this.capture=!1,this.transient&&ua.pop(),!0}}function r(){function F(Fa,La){return{x:(Fa.x+La.x)/2,y:(Fa.y+La.y)/2}}function N(Fa){return{x:Math.round(Fa.x),y:Math.round(Fa.y)}}function da(Fa,La){for(var Ra=0;Ra=(La.x-Fa.points[Ra].x)* +Ng(25,function(la){if(this.capture){la=L({x:rb,y:hb});var xa=la.x-F.x,Aa=la.y-F.y,db=~~xa,gb=~~Aa;return(0!=db||0!=gb)&&(Ja.move(db,gb,N&&da),da=!1),F.x=la.x-(xa-db),F.y=la.y-(Aa-gb),!0}});this.mouseUp=function(la,xa,Aa){if(this.capture&&0==xa)return this.capture=!1,this.transient&&ua.pop(),!0}}function r(){function F(Fa,La){return{x:(Fa.x+La.x)/2,y:(Fa.y+La.y)/2}}function N(Fa){return{x:Math.round(Fa.x),y:Math.round(Fa.y)}}function da(Fa,La){for(var Ra=0;Ra=(La.x-Fa.points[Ra].x)* (La.x-Fa.points[Ra].x)+(La.y-Fa.points[Ra].y)*(La.y-Fa.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 Fa.containsPoint(La)?-3:-2}function la(){var Fa=gb.getTransformed(Db), La=da(Fa,{x:rb,y:hb});switch(La){case 0:case 2:case 4:case 6:La=~~(La/2);let Ra=Fa.points[La],nb=Fa.points[(La+1)%4];xa(Mb.subtractPoints(Fa.points[(La+3)%4],Ra).normalize().add(Mb.subtractPoints(nb,Ra).normalize()));break;case 1:case 3:case 5:case 7:xa(Mb.subtractPoints(Fa.points[(~~(La/2)+1)%4],Fa.points[~~(La/2)]).getPerpendicular());break;case -3:x("move");break;default:x("default")}}function xa(Fa){Fa=Math.floor(Math.atan2(-Fa.y,Fa.x)/(Math.PI/4)+.5);switch(0>Fa&&(Fa+=4),Fa){default:Fa="ew-resize"; -break;case 1:Fa="nesw-resize";break;case 2:Fa="ns-resize";break;case 3:Fa="nwse-resize"}x(Fa)}var Aa,cb,gb,Ea,jb,Vb,kc=-1;this.mouseDown=function(Fa,La,Ra){if(!this.capture&&0==La&&!Fa.altKey&&!Y(Sb).isPressed("space"))return kc=da(gb.getTransformed(Db),{x:rb,y:hb}),jb=L(Ea={x:rb,y:hb}),this.capture=!0,la(),!0};this.mouseDrag=Ng(40,function(Fa){if(this.capture){var La={x:rb,y:hb};switch(kc){case -3:Fa=N(L(La));var Ra=Mb.subtractPoints(Fa,jb);La=Ra.getTruncated();Ra=Ra.subtract(La);var nb=new Kb;nb.translate(La.x, -La.y);Aa.preMultiply(nb);jb=Mb.subtractPoints(Fa,Ra);break;case -2:nb=Math.PI/4;Ra=gb.getCenter();var pb=U(Ra),wc=Math.atan2(La.y-pb.y,La.x-pb.x)-Math.atan2(Ea.y-pb.y,Ea.x-pb.x);pb=new Kb;Vb+=wc;Fa=Fa.shiftKey?-Aa.decompose().rotate+Math.round(Vb/nb)*nb:wc;pb.rotateAroundPoint(Fa,Ra.x,Ra.y);Aa.preMultiply(pb);Ea=La;break;case 0:case 2:case 4:case 6:nb=~~(kc/2);Ra=cb.points[nb];pb=Aa.getInverted().getTransformedPoint(N(L(La)));La=cb.points[(nb+2)%4];nb=(pb.x-La.x)/(Ra.x-La.x);Ra=(pb.y-La.y)/(Ra.y- -La.y);if(.001>Math.abs(nb)||.001>Math.abs(Ra)||isNaN(nb)||isNaN(Ra))return!0;Fa.shiftKey&&(Ra=nb=Fa=Math.max(nb,Ra));Aa.scaleAroundPoint(nb,Ra,La.x,La.y);break;case 1:case 5:case 3:case 7:Fa=~~(kc/2);pb=F(cb.points[Fa],cb.points[(Fa+1)%4]);La=Aa.getInverted().getTransformedPoint(N(L(La)));Fa=F(cb.points[(Fa+2)%4],cb.points[(Fa+3)%4]);pb=Mb.subtractPoints(pb,Fa);La=Mb.subtractPoints(La,Fa);wc=pb.getLength();La=pb.getDotProduct(La)/wc/wc;if(.001>Math.abs(La)||isNaN(La))return!0;1==kc||5==kc?(Ra=1,nb= -La):(Ra=La,nb=1);Aa.scaleAroundPoint(Ra,nb,Fa.x,Fa.y)}return gb=cb.getTransformed(Aa),Ja.transformAffineAmend(Aa),Ka.repaintAll(),!0}});this.mouseUp=function(Fa,La,Ra){if(this.capture&&0==La)return this.capture=!1,kc=-1,!0};this.mouseMove=function(){this.capture||la()};this.paint=function(){var Fa=gb.getTransformed(Db).points,La=Array(2*Fa.length);for(var Ra=0;RaMath.abs(nb)||.001>Math.abs(Ra)||isNaN(nb)||isNaN(Ra))return!0;Fa.shiftKey&&(Ra=nb=Fa=Math.max(nb,Ra));Aa.scaleAroundPoint(nb,Ra,La.x,La.y);break;case 1:case 5:case 3:case 7:Fa=~~(kc/2);pb=F(db.points[Fa],db.points[(Fa+1)%4]);La=Aa.getInverted().getTransformedPoint(N(L(La)));Fa=F(db.points[(Fa+2)%4],db.points[(Fa+3)%4]);pb=Mb.subtractPoints(pb,Fa);La=Mb.subtractPoints(La,Fa);wc=pb.getLength();La=pb.getDotProduct(La)/wc/wc;if(.001>Math.abs(La)||isNaN(La))return!0;1==kc||5==kc?(Ra=1,nb= +La):(Ra=La,nb=1);Aa.scaleAroundPoint(Ra,nb,Fa.x,Fa.y)}return gb=db.getTransformed(Aa),Ja.transformAffineAmend(Aa),Ka.repaintAll(),!0}});this.mouseUp=function(Fa,La,Ra){if(this.capture&&0==La)return this.capture=!1,kc=-1,!0};this.mouseMove=function(){this.capture||la()};this.paint=function(){var Fa=gb.getTransformed(Db).points,La=Array(2*Fa.length);for(var Ra=0;RaMath.abs(la-1)?F=1:.2>Math.abs(la-2)?F=2:.08>Math.abs(la-.5)&&(F=.5);S(F,N/2,da/2)}function na(F){return Rb?P.getPressure():"mouse"===F.pointerType&&0!==F.buttons&&0===F.pressure?1:"touch"===F.pointerType?(0!==F.pressure&&(Ic=!0), -Ic)?2*F.pressure:1:2*F.pressure}function mb(){fb||(fb=!0,window.requestAnimationFrame(function(){Ka.paint()}))}function Xa(F){Va.union(F);mb()}function Lb(){ec=Ja.getBounds();Ka.repaintAll()}let Fb,Ka=this,Ma=document.createElement("div"),ma=document.createElement("div"),Ca=document.createElement("div"),ya=document.createElement("canvas"),ha=ya.getContext("2d"),Oa=document.createElement("canvas"),qa=Oa.getContext("2d"),Ta=Og(ha),Ja=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,Ic=!1,ec=Ja.getBounds(),Va=new Ha(0,0,0,0),fb=!1,Yb;let Ya,Rc,Sc,A,ta,uc,Nc,Xb,$c=[],ua=new nc,fc,vc=new ne(!1),D=new ne(!0),P=ed.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 da=Math.min(.999,Math.pow(a.getBrushInfo().smoothing,.3));let la=1-da;return this.smoothMouse.x=la*F.x+da*this.smoothMouse.x,this.smoothMouse.y=la*F.y+da*this.smoothMouse.y,Ja.continueStroke(this.smoothMouse.x,this.smoothMouse.y,N),!0}this.mouseMove(F)}; -m.prototype.mouseUp=function(F,N,da){if(this.capture)return 0==N&&(this.capture=!1,Ja.endStroke()),!0};p.prototype=Object.create(b.prototype);p.prototype.constructor=p;p.prototype.drawLine=function(F,N){Ja.beginStroke(F.x,F.y,1);Ja.continueStroke(N.x,N.y,1);Ja.endStroke()};g.prototype=Object.create(b.prototype);g.prototype.constructor=g;e.prototype=Object.create(c.prototype);e.prototype.constructor=e;k.prototype=Object.create(c.prototype);k.prototype.constructor=k;l.prototype=Object.create(c.prototype); -l.prototype.constructor=l;l.prototype.mouseDown=function(F,N,da){if(0==N&&!F.altKey&&!Y(Sb).isPressed("space")&&K())return F=L({x:rb,y:hb}),Ja.isPointWithin(F.x,F.y)&&(Ja.floodFill(F.x,F.y),Ka.repaintAll()),!0};h.prototype=Object.create(c.prototype);h.prototype.constructor=h;n.prototype=Object.create(c.prototype);n.prototype.constructor=n;n.prototype.mouseMove=function(F){if(!Y(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){Ja.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= +Ic)?2*F.pressure:1:2*F.pressure}function mb(){fb||(fb=!0,window.requestAnimationFrame(function(){Ka.paint()}))}function Ya(F){Wa.union(F);mb()}function Lb(){ec=Ja.getBounds();Ka.repaintAll()}let Fb,Ka=this,Ma=document.createElement("div"),ma=document.createElement("div"),Ca=document.createElement("div"),ya=document.createElement("canvas"),ha=ya.getContext("2d"),Oa=document.createElement("canvas"),qa=Oa.getContext("2d"),Ua=Og(ha),Ja=a.getArtwork(),kb=1,bc=0,jc=0,Nb=0,Db=new Kb,sb=!1,Wb=!1,lb=32,rb= +0,hb=0,Tb=!1,vb=[!1,!1,!1],Rb=!1,Ib=!1,Ic=!1,ec=Ja.getBounds(),Wa=new Ha(0,0,0,0),fb=!1,Yb;let Za,Rc,Sc,A,ta,uc,Nc,Xb,$c=[],ua=new nc,fc,vc=new ne(!1),D=new ne(!0),P=ed.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 da=Math.min(.999,Math.pow(a.getBrushInfo().smoothing,.3));let la=1-da;return this.smoothMouse.x=la*F.x+da*this.smoothMouse.x,this.smoothMouse.y=la*F.y+da*this.smoothMouse.y,Ja.continueStroke(this.smoothMouse.x,this.smoothMouse.y,N),!0}this.mouseMove(F)}; +l.prototype.mouseUp=function(F,N,da){if(this.capture)return 0==N&&(this.capture=!1,Ja.endStroke()),!0};p.prototype=Object.create(b.prototype);p.prototype.constructor=p;p.prototype.drawLine=function(F,N){Ja.beginStroke(F.x,F.y,1);Ja.continueStroke(N.x,N.y,1);Ja.endStroke()};g.prototype=Object.create(b.prototype);g.prototype.constructor=g;e.prototype=Object.create(c.prototype);e.prototype.constructor=e;k.prototype=Object.create(c.prototype);k.prototype.constructor=k;m.prototype=Object.create(c.prototype); +m.prototype.constructor=m;m.prototype.mouseDown=function(F,N,da){if(0==N&&!F.altKey&&!Y(Sb).isPressed("space")&&K())return F=L({x:rb,y:hb}),Ja.isPointWithin(F.x,F.y)&&(Ja.floodFill(F.x,F.y),Ka.repaintAll()),!0};h.prototype=Object.create(c.prototype);h.prototype.constructor=h;n.prototype=Object.create(c.prototype);n.prototype.constructor=n;n.prototype.mouseMove=function(F){if(!Y(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){Ja.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){kb=F;G()};this.getZoom=function(){return kb};this.setGridSize=function(F){lb=Math.max(Math.round(F),1);this.repaintAll()};this.getGridSize=function(){return lb};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(){za(1.41*this.getZoom())};this.zoomOut=function(){za(.7092*this.getZoom())};this.zoom100=function(){za(1); -Ia()};this.resetRotation=function(){var F=ya.width/2,N=ya.height/2,da=new Kb;da.rotateAroundPoint(-this.getRotation(),F,N);da.multiply(Db);this.setOffset(~~da.getTranslateX(),~~da.getTranslateY());this.setRotation(0);Ka.emitEvent("canvasRotated90",[0])};let ea=!1;this.getElement=function(){return Ma};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(fb=!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():Ja.fusionLayers().getImageData();qa.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,Ja.width,Ja.height),ha.drawImage(Oa,0,0,Oa.width,Oa.height),ha.restore(), -Ke(ha,"stroke"),ha.lineWidth=1,Ja.getSelection().isEmpty()||ua.peek()instanceof h&&ua.peek().capture||(ha.setLineDash([3,2]),ia(ha,Ja.getSelection()),ha.setLineDash([])),Wb)if(N=Ja.getBounds(),2K&&this.setLocation(this.getX(),Math.max(K-x,0)))};this.userIsDoneWithUs=function(){a.getSmallScreenMode()&& -this.toggleCollapse(!0)};p.className="collapse-icon fas icon-angle-down";g.type="button";g.className="btn btn-close";g.textContent="";g.tabIndex=-1;m.className="chickenpaint-palette chickenpaint-palette-"+c;d.className="chickenpaint-palette-head";d.setAttribute("touch-action","none");c=document.createElement("div");let v=document.createElement("h5");c.className="modal-header";v.className="modal-title";v.appendChild(document.createTextNode(this.title));v.appendChild(p);c.appendChild(v);c.appendChild(g); -d.appendChild(c);e.className="chickenpaint-palette-body";m.appendChild(d);m.appendChild(e);this.resizeVert&&((k=document.createElement("div")).className="chickenpaint-resize-handle-vert",k.addEventListener("pointerdown",function(x){n="vertResize";k.setPointerCapture(x.pointerId)}),k.addEventListener("pointermove",function(x){"vertResize"==n&&u.setHeight(x.pageY-Y(ja)(m).offset().top)}),k.addEventListener("pointerup",function(x){k.releasePointerCapture(x.pointerId);n=!1}),m.appendChild(k));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-Y(ja)(m).offset().left)}),l.addEventListener("pointerup",function(x){l.releasePointerCapture(x.pointerId);n=!1}),m.appendChild(l));d.addEventListener("pointerdown",function(x){0==x.button&&(x.stopPropagation(),x.preventDefault(),"BUTTON"==x.target.nodeName? -u.emitEvent("paletteVisChange",[u,!1]):(h={x:parseInt(m.style.left,10)||0,y:parseInt(m.style.top,10)||0},r={x:x.pageX-Y(ja)(m).position().left,y:x.pageY-Y(ja)(m).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 J=x.pageX-r.x,G=x.pageY-r.y;if("dragStart"==n){x=J;var C=G;var K=h;25<(x-K.x)*(x-K.x)+(C-K.y)*(C-K.y)&&(n="dragging")}"dragging"== +this.toggleCollapse(!0)};p.className="collapse-icon fas icon-angle-down";g.type="button";g.className="btn btn-close";g.textContent="";g.tabIndex=-1;l.className="chickenpaint-palette chickenpaint-palette-"+c;d.className="chickenpaint-palette-head";d.setAttribute("touch-action","none");c=document.createElement("div");let v=document.createElement("h5");c.className="modal-header";v.className="modal-title";v.appendChild(document.createTextNode(this.title));v.appendChild(p);c.appendChild(v);c.appendChild(g); +d.appendChild(c);e.className="chickenpaint-palette-body";l.appendChild(d);l.appendChild(e);this.resizeVert&&((k=document.createElement("div")).className="chickenpaint-resize-handle-vert",k.addEventListener("pointerdown",function(x){n="vertResize";k.setPointerCapture(x.pointerId)}),k.addEventListener("pointermove",function(x){"vertResize"==n&&u.setHeight(x.pageY-Y(ja)(l).offset().top)}),k.addEventListener("pointerup",function(x){k.releasePointerCapture(x.pointerId);n=!1}),l.appendChild(k));this.resizeHorz&& +((m=document.createElement("div")).className="chickenpaint-resize-handle-horz",m.addEventListener("pointerdown",function(x){n="horzResize";m.setPointerCapture(x.pointerId)}),m.addEventListener("pointermove",function(x){"horzResize"==n&&u.setWidth(x.pageX-Y(ja)(l).offset().left)}),m.addEventListener("pointerup",function(x){m.releasePointerCapture(x.pointerId);n=!1}),l.appendChild(m));d.addEventListener("pointerdown",function(x){0==x.button&&(x.stopPropagation(),x.preventDefault(),"BUTTON"==x.target.nodeName? +u.emitEvent("paletteVisChange",[u,!1]):(h={x:parseInt(l.style.left,10)||0,y:parseInt(l.style.top,10)||0},r={x:x.pageX-Y(ja)(l).position().left,y:x.pageY-Y(ja)(l).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 J=x.pageX-r.x,G=x.pageY-r.y;if("dragStart"==n){x=J;var C=G;var K=h;25<(x-K.x)*(x-K.x)+(C-K.y)*(C-K.y)&&(n="dragging")}"dragging"== n&&u.setLocation(J,G)}});d.addEventListener("pointerup",function(x){if("dragging"===n||"dragStart"===n){"dragStart"===n&&(x.stopPropagation(),x.preventDefault(),setTimeout(()=>{u.setLocation(h.x,h.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:oa.M_RECT_SELECTION},{className:"chickenpaint-tool-move",command:"CPMoveTool",toolTip:"Move tool",shortcut:"v",mode:oa.M_MOVE_TOOL},{className:"chickenpaint-tool-flood-fill",command:"CPFloodFill",toolTip:"Flood fill",shortcut:"f",mode:oa.M_FLOODFILL},{className:"chickenpaint-tool-gradient-fill",command:"CPGradientFill",toolTip:"Gradient fill",shortcut:"g",mode:oa.M_GRADIENTFILL},{className:"chickenpaint-tool-color-picker",command:"CPColorPicker", toolTip:"Color picker",shortcut:"i",mode:oa.M_COLOR_PICKER},{className:"chickenpaint-tool-blur",command:"CPBlur",toolTip:"Blur",shortcut:"u",mode:oa.M_DRAW,tool:oa.T_BLUR},{className:"chickenpaint-tool-pencil",command:"CPPencil",toolTip:"Pencil",shortcut:"n",mode:oa.M_DRAW,tool:oa.T_PENCIL},{className:"chickenpaint-tool-pen",command:"CPPen",toolTip:"Pen",selected:!0,shortcut:"b",mode:oa.M_DRAW,tool:oa.T_PEN},{className:"chickenpaint-tool-airbrush",command:"CPAirbrush",toolTip:"Airbrush",shortcut:"a", mode:oa.M_DRAW,tool:oa.T_AIRBRUSH},{className:"chickenpaint-tool-water",command:"CPWater",toolTip:"Waterpaint",shortcut:"w",mode:oa.M_DRAW,tool:oa.T_WATER},{className:"chickenpaint-tool-eraser",command:"CPEraser",toolTip:"Eraser",shortcut:"e",mode:oa.M_DRAW,tool:oa.T_ERASER},{className:"chickenpaint-tool-soft-eraser",command:"CPSoftEraser",toolTip:"Soft eraser",shortcut:"s",mode:oa.M_DRAW,tool:oa.T_SOFTERASER},{className:"chickenpaint-tool-smudge",command:"CPSmudge",toolTip:"Smudge",shortcut:"d", mode:oa.M_DRAW,tool:oa.T_SMUDGE},{className:"chickenpaint-tool-blender",command:"CPBlender",toolTip:"Blender",shortcut:"c",mode:oa.M_DRAW,tool:oa.T_BLENDER},{className:"chickenpaint-tool-dodge",command:"CPDodge",toolTip:"Dodge (tool)",shortcut:"o",mode:oa.M_DRAW,tool:oa.T_DODGE},{className:"chickenpaint-tool-burn",command:"CPBurn",toolTip:"Burn (tool)",shortcut:"p",mode:oa.M_DRAW,tool:oa.T_BURN},{className:"chickenpaint-tool-rotate-canvas",command:"CPRotateCanvas",commandDoubleClick:"CPResetCanvasRotation", -toolTip:"Rotate canvas",mode:oa.M_ROTATE_CANVAS},{className:"chickenpaint-tool-pan-canvas",command:"CPPanCanvas",toolTip:"Grab canvas",mode:oa.M_PAN_CANVAS}],m=document.createElement("ul");a.on("modeChange",function(p){let g=d.getBodyElement();Y(ja)("li",g).removeClass("selected");p==oa.M_DRAW?Y(ja)("li[data-tool="+a.getCurTool()+"]",g).addClass("selected"):Y(ja)("li[data-mode="+p+"]",g).addClass("selected")});a.on("toolChange",function(p){let g=d.getBodyElement();a.getCurMode()==oa.M_DRAW&&(Y(ja)("li", -g).removeClass("selected"),Y(ja)("li[data-tool="+p+"]",g).addClass("selected"))});(function(){let p=d.getBodyElement();for(let g in m.className="chickenpaint-tools list-unstyled",b)!function(e){let k=b[e],l=document.createElement("li"),h=document.createElement("div");l.className="chickenpaint-toolbar-button "+k.className;l.setAttribute("data-buttonIndex",e);l.setAttribute("data-mode",k.mode);void 0!==k.tool&&l.setAttribute("data-tool",k.tool);l.title=ka(k.toolTip);k.shortcut&&(l.title+=" ("+k.shortcut.toUpperCase()+ -")",Y(Sb)(k.shortcut,function(){return c.call(l),!1}));k.selected&&(l.className+=" selected");h.className="chickenpaint-toolbar-button-icon";l.appendChild(h);m.appendChild(l)}(g);Y(ja)(m).on("click","li",c).on("dblclick","li",function(g){g=b[parseInt(this.getAttribute("data-buttonIndex"),10)];g.commandDoubleClick&&a.actionPerformed({action:g.commandDoubleClick})});p.appendChild(m)})()}function Ne(a){lc.call(this,a,"misc","Misc");let c=this,d=[{className:"chickenpaint-tool-zoom-in",command:"CPZoomIn", +toolTip:"Rotate canvas",mode:oa.M_ROTATE_CANVAS},{className:"chickenpaint-tool-pan-canvas",command:"CPPanCanvas",toolTip:"Grab canvas",mode:oa.M_PAN_CANVAS}],l=document.createElement("ul");a.on("modeChange",function(p){let g=d.getBodyElement();Y(ja)("li",g).removeClass("selected");p==oa.M_DRAW?Y(ja)("li[data-tool="+a.getCurTool()+"]",g).addClass("selected"):Y(ja)("li[data-mode="+p+"]",g).addClass("selected")});a.on("toolChange",function(p){let g=d.getBodyElement();a.getCurMode()==oa.M_DRAW&&(Y(ja)("li", +g).removeClass("selected"),Y(ja)("li[data-tool="+p+"]",g).addClass("selected"))});(function(){let p=d.getBodyElement();for(let g in l.className="chickenpaint-tools list-unstyled",b)!function(e){let k=b[e],m=document.createElement("li"),h=document.createElement("div");m.className="chickenpaint-toolbar-button "+k.className;m.setAttribute("data-buttonIndex",e);m.setAttribute("data-mode",k.mode);void 0!==k.tool&&m.setAttribute("data-tool",k.tool);m.title=ka(k.toolTip);k.shortcut&&(m.title+=" ("+k.shortcut.toUpperCase()+ +")",Y(Sb)(k.shortcut,function(){return c.call(m),!1}));k.selected&&(m.className+=" selected");h.className="chickenpaint-toolbar-button-icon";m.appendChild(h);l.appendChild(m)}(g);Y(ja)(l).on("click","li",c).on("dblclick","li",function(g){g=b[parseInt(this.getAttribute("data-buttonIndex"),10)];g.commandDoubleClick&&a.actionPerformed({action:g.commandDoubleClick})});p.appendChild(l)})()}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(),m=document.createElement("ul");for(let p in m.className="chickenpaint-misc-tools list-unstyled",d){let g=d[p],e=document.createElement("li"),k=document.createElement("div");"CPSend"!=g.command||a.isActionSupported("CPContinue")||(g.toolTip="Post Oekaki",g.className="chickenpaint-tool-send-and-end");e.className="chickenpaint-toolbar-button "+g.className;e.setAttribute("data-buttonIndex",p);e.setAttribute("title",ka(g.toolTip));k.className="chickenpaint-toolbar-button-icon";e.appendChild(k); -m.appendChild(e)}Y(ja)(m).on("mousedown","li",function(p){Y(ja)(this).addClass("selected")}).on("mouseup","li",function(p){Y(ja)(this).removeClass("selected")}).on("click","li",function(p){p=d[parseInt(this.getAttribute("data-buttonIndex"),10)];a.actionPerformed({action:p.command})});b.appendChild(m)}()}function Oe(a){lc.call(this,a,"stroke","Stroke");let c=[{className:"chickenpaint-tool-freehand",command:"CPFreeHand",toolTip:ka("Free-hand"),selected:!0},{className:"chickenpaint-tool-line",command:"CPLine", -toolTip:ka("Straight line")},{className:"chickenpaint-tool-bezier",command:"CPBezier",toolTip:ka("Bezier curve")}],d=this.getBodyElement();!function(){let b=document.createElement("ul");for(let m in b.className="chickenpaint-stroke-tools list-unstyled",c){let p=c[m],g=document.createElement("li"),e=document.createElement("div");g.className="chickenpaint-toolbar-button "+p.className;g.setAttribute("data-buttonIndex",m);g.setAttribute("title",p.toolTip);p.selected&&(g.className+=" selected");e.className= -"chickenpaint-toolbar-button-icon";g.appendChild(e);b.appendChild(g)}Y(ja)(b).on("click","li",function(m){m=c[parseInt(this.getAttribute("data-buttonIndex"),10)];Y(ja)("li",b).removeClass("selected");Y(ja)(this).addClass("selected");a.actionPerformed({action:m.command})});d.appendChild(b)}();a.on("toolChange",function(b,m){Y(ja)(".chickenpaint-tool-freehand",d).toggleClass("selected",m.strokeMode==Da.STROKE_MODE_FREEHAND);Y(ja)(".chickenpaint-tool-line",d).toggleClass("selected",m.strokeMode==Da.STROKE_MODE_LINE); -Y(ja)(".chickenpaint-tool-bezier",d).toggleClass("selected",m.strokeMode==Da.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(),m=document.createElement("div");m.className="chickenpaint-colorpicker-top";m.appendChild(c.getElement());m.appendChild(d.getElement());b.appendChild(m);b.appendChild(a.getElement())} -function Nh(a){function c(p,g,e){for(;p.length=h/2?l.rect(x/2,0,(v.value-h/2)*x/h,C):l.rect(v.value*x/h,0,(h/2-v.value)*x/h,C),l.fill(),l.clip(),l.fillStyle= -"white";else{var L=(v.value-a)/h;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,J,G);l.restore();l.fillStyle="white";l.beginPath();l.rect(L,0,x,C);l.fill();l.clip();l.fillStyle="black"}l.fillText(K,J,G);l.restore()}function g(x){let C=k.clientWidth,K=k.getBoundingClientRect().left+window.scrollX;proportion=(x.pageX-K)/C;b&&(proportion=Math.pow(Math.max(proportion,0),1.5));v.setValue(proportion* -h+a)}function e(x){switch(n){case 1:return g(x);case 2:var C=v.title();if(!C.includes(ka("Brush size"))&&!C.includes(ka("Opacity")))return g(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 k=document.createElement("canvas"),l=k.getContext("2d"),h=c-a,n=0,r,u=!1,v=this;this.value=void 0;this.title="";d=d||!1;k.addEventListener("pointerup",x=>{if(0===n)return k.releasePointerCapture(x.pointerId),k.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 k.releasePointerCapture(x.pointerId),k.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 k};this.resize=function(){k.width=k.clientWidth||m;k.height=k.clientHeight||20;1n.length;)n="0"+n;h.backgroundColor="#"+n}let m=this,p=new Bb(0),g=255,e=document.createElement("div");this.getElement=function(){return e};this.setColor=function(h){p.isEqual(h)||(p.copyFrom(h),b(),this.emitEvent("colorChange",[p]))};this.setAlpha=function(h){h!=g&&(g=h,b(),this.emitEvent("alphaChange",[g]))};this.getColorRgb=function(){return p.getRgb()};this.getAlpha=function(){return g};this.setCurColor=this.setColor; -e.className="chickenpaint-color-pick-swatch";a&&p.copyFrom(a);c&&(g=c);let k=new oc.Popover(e,{html:!0,content:function(){return window.addEventListener("mousedown",l),function(){let h=document.createElement("div"),n=document.createElement("div"),r=new Pg(m,p),u=new Qg(m,r,p.getHue()),v=new Fc(0,255);return h.className="chickenpaint-color-pick-panel",n.className="chickenpaint-colorpicker-top",n.appendChild(r.getElement()),n.appendChild(u.getElement()),h.appendChild(n),v.value=g,v.title=function(x){return ka("Opacity: ")+ -x},v.on("valueChange",function(x){m.setAlpha(x)}),h.appendChild(v.getElement()),setTimeout(function(){v.resize()},0),h}()},trigger:"manual",placement:"bottom",container:d||!1}),l=function(h){var n=h.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");h.preventDefault();n||k.hide()};e.addEventListener("click",function(h){h.preventDefault();k.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(ka(c[d])));b.value=d;a.appendChild(b)}}function Oh(a){function c(){p.gradient(p.getBounds(),0,0,p.width, -0,k,!0);e.putImageData(p.imageData,0,0,0,0,150,32);b.fillRect(0,0,d.width,d.height);b.drawImage(g,0,0)}let d=document.createElement("canvas"),b=d.getContext("2d"),m=Og(b),p=new H(150,32),g=document.createElement("canvas"),e=g.getContext("2d"),k=a.getCurGradient();this.getElement=function(){return d};a.on("gradientChange",function(l){k=l;c()});d.width=g.width=150;d.height=g.height=32;d.className="chickenpaint-gradient-preview";b.fillStyle=m;c()}function Td(a){lc.call(this,a,"brush","Tool options"); -let c=new Ph(a),d=new Qh(a),b=new Rh(a),m=this.getBodyElement();m.addEventListener("touchmove",p=>{p.preventDefault()},{passive:!1});m.appendChild(c.getElement());m.appendChild(d.getElement());m.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 oa.M_GRADIENTFILL:d.getElement().style.display="block";break;case oa.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"),m=new Sd(!1,ka("Control brush opacity with pen pressure")),p=new Fc(1,255),g=new Sd(!0,ka("Control brush size with pen pressure")),e=new Fc(1,200,!1,!0),k=new Sd(!1,ka("Control brush scattering with pen pressure")),l=new Fc(0,1E3,!1,!0),h=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), +c.getBodyElement(),l=document.createElement("ul");for(let p in l.className="chickenpaint-misc-tools list-unstyled",d){let g=d[p],e=document.createElement("li"),k=document.createElement("div");"CPSend"!=g.command||a.isActionSupported("CPContinue")||(g.toolTip="Post Oekaki",g.className="chickenpaint-tool-send-and-end");e.className="chickenpaint-toolbar-button "+g.className;e.setAttribute("data-buttonIndex",p);e.setAttribute("title",ka(g.toolTip));k.className="chickenpaint-toolbar-button-icon";e.appendChild(k); +l.appendChild(e)}Y(ja)(l).on("mousedown","li",function(p){Y(ja)(this).addClass("selected")}).on("mouseup","li",function(p){Y(ja)(this).removeClass("selected")}).on("click","li",function(p){p=d[parseInt(this.getAttribute("data-buttonIndex"),10)];a.actionPerformed({action:p.command})});b.appendChild(l)}()}function Oe(a){lc.call(this,a,"stroke","Stroke");let c=[{className:"chickenpaint-tool-freehand",command:"CPFreeHand",toolTip:ka("Free-hand"),selected:!0},{className:"chickenpaint-tool-line",command:"CPLine", +toolTip:ka("Straight line")},{className:"chickenpaint-tool-bezier",command:"CPBezier",toolTip:ka("Bezier curve")}],d=this.getBodyElement();!function(){let b=document.createElement("ul");for(let l in b.className="chickenpaint-stroke-tools list-unstyled",c){let p=c[l],g=document.createElement("li"),e=document.createElement("div");g.className="chickenpaint-toolbar-button "+p.className;g.setAttribute("data-buttonIndex",l);g.setAttribute("title",p.toolTip);p.selected&&(g.className+=" selected");e.className= +"chickenpaint-toolbar-button-icon";g.appendChild(e);b.appendChild(g)}Y(ja)(b).on("click","li",function(l){l=c[parseInt(this.getAttribute("data-buttonIndex"),10)];Y(ja)("li",b).removeClass("selected");Y(ja)(this).addClass("selected");a.actionPerformed({action:l.command})});d.appendChild(b)}();a.on("toolChange",function(b,l){Y(ja)(".chickenpaint-tool-freehand",d).toggleClass("selected",l.strokeMode==Da.STROKE_MODE_FREEHAND);Y(ja)(".chickenpaint-tool-line",d).toggleClass("selected",l.strokeMode==Da.STROKE_MODE_LINE); +Y(ja)(".chickenpaint-tool-bezier",d).toggleClass("selected",l.strokeMode==Da.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(),l=document.createElement("div");l.className="chickenpaint-colorpicker-top";l.appendChild(c.getElement());l.appendChild(d.getElement());b.appendChild(l);b.appendChild(a.getElement())} +function Nh(a){function c(p,g,e){for(;p.length=h/2?m.rect(x/2,0,(v.value-h/2)*x/h,C):m.rect(v.value*x/h,0,(h/2-v.value)*x/h,C),m.fill(),m.clip(),m.fillStyle= +"white";else{var L=(v.value-a)/h;b&&(L=Math.pow(L,.6666666666666666));L*=x;m.save();m.save();m.fillStyle="black";m.beginPath();m.rect(0,0,L,C);m.fill();m.clip();m.fillStyle="white";m.fillText(K,J,G);m.restore();m.fillStyle="white";m.beginPath();m.rect(L,0,x,C);m.fill();m.clip();m.fillStyle="black"}m.fillText(K,J,G);m.restore()}function g(x){let C=k.clientWidth,K=k.getBoundingClientRect().left+window.scrollX;proportion=(x.pageX-K)/C;b&&(proportion=Math.pow(Math.max(proportion,0),1.5));v.setValue(proportion* +h+a)}function e(x){switch(n){case 1:return g(x);case 2:var C=v.title();if(!C.includes(ka("Brush size"))&&!C.includes(ka("Opacity")))return g(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 k=document.createElement("canvas"),m=k.getContext("2d"),h=c-a,n=0,r,u=!1,v=this;this.value=void 0;this.title="";d=d||!1;k.addEventListener("pointerup",x=>{if(0===n)return k.releasePointerCapture(x.pointerId),k.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 k.releasePointerCapture(x.pointerId),k.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 k};this.resize=function(){k.width=k.clientWidth||l;k.height=k.clientHeight||20;1n.length;)n="0"+n;h.backgroundColor="#"+n}let l=this,p=new Bb(0),g=255,e=document.createElement("div");this.getElement=function(){return e};this.setColor=function(h){p.isEqual(h)||(p.copyFrom(h),b(),this.emitEvent("colorChange",[p]))};this.setAlpha=function(h){h!=g&&(g=h,b(),this.emitEvent("alphaChange",[g]))};this.getColorRgb=function(){return p.getRgb()};this.getAlpha=function(){return g};this.setCurColor=this.setColor; +e.className="chickenpaint-color-pick-swatch";a&&p.copyFrom(a);c&&(g=c);let k=new oc.Popover(e,{html:!0,content:function(){return window.addEventListener("mousedown",m),function(){let h=document.createElement("div"),n=document.createElement("div"),r=new Pg(l,p),u=new Qg(l,r,p.getHue()),v=new Fc(0,255);return h.className="chickenpaint-color-pick-panel",n.className="chickenpaint-colorpicker-top",n.appendChild(r.getElement()),n.appendChild(u.getElement()),h.appendChild(n),v.value=g,v.title=function(x){return ka("Opacity: ")+ +x},v.on("valueChange",function(x){l.setAlpha(x)}),h.appendChild(v.getElement()),setTimeout(function(){v.resize()},0),h}()},trigger:"manual",placement:"bottom",container:d||!1}),m=function(h){var n=h.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");h.preventDefault();n||k.hide()};e.addEventListener("click",function(h){h.preventDefault();k.toggle()}); +e.addEventListener("hidden.bs.popover",function(){window.removeEventListener("mousedown",m)});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(ka(c[d])));b.value=d;a.appendChild(b)}}function Oh(a){function c(){p.gradient(p.getBounds(),0,0,p.width, +0,k,!0);e.putImageData(p.imageData,0,0,0,0,150,32);b.fillRect(0,0,d.width,d.height);b.drawImage(g,0,0)}let d=document.createElement("canvas"),b=d.getContext("2d"),l=Og(b),p=new H(150,32),g=document.createElement("canvas"),e=g.getContext("2d"),k=a.getCurGradient();this.getElement=function(){return d};a.on("gradientChange",function(m){k=m;c()});d.width=g.width=150;d.height=g.height=32;d.className="chickenpaint-gradient-preview";b.fillStyle=l;c()}function Td(a){lc.call(this,a,"brush","Tool options"); +let c=new Ph(a),d=new Qh(a),b=new Rh(a),l=this.getBodyElement();l.addEventListener("touchmove",p=>{p.preventDefault()},{passive:!1});l.appendChild(c.getElement());l.appendChild(d.getElement());l.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 oa.M_GRADIENTFILL:d.getElement().style.display="block";break;case oa.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"),l=new Sd(!1,ka("Control brush opacity with pen pressure")),p=new Fc(1,255),g=new Sd(!0,ka("Control brush size with pen pressure")),e=new Fc(1,200,!1,!0),k=new Sd(!1,ka("Control brush scattering with pen pressure")),m=new Fc(0,1E3,!1,!0),h=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 ka("Opacity")+": "+x};p.on("valueChange",function(x){a.setAlpha(x)});e.title=function(x){return ka("Brush size")+": "+x};e.on("valueChange",function(x){a.setBrushSize(x)});h.title=function(x){return ka("Color")+": "+x+"%"};h.on("valueChange",function(x){a.getBrushInfo().resat=x/100;a.callToolListeners()});n.title=function(x){return ka("Blend")+": "+x+"%"};n.on("valueChange",function(x){a.getBrushInfo().bleed= -x/100;a.callToolListeners()});r.title=function(x){return ka("Spacing")+": "+x+"%"};r.on("valueChange",function(x){a.getBrushInfo().spacing=x/100;a.callToolListeners()});l.title=function(x){return ka("Scattering")+": "+x+"%"};l.on("valueChange",function(x){a.getBrushInfo().scattering=x/100;a.callToolListeners()});u.title=function(x){return ka("Smoothing")+": "+x+"%"};u.on("valueChange",function(x){a.getBrushInfo().smoothing=x/100;a.callToolListeners()});k.on("valueChange",function(x){a.getBrushInfo().pressureScattering= -x;a.callToolListeners()});m.on("valueChange",function(x){a.getBrushInfo().pressureAlpha=x;a.callToolListeners()});g.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(g, -e));d.appendChild(Gf(m,p));d.appendChild(h.getElement());d.appendChild(n.getElement());d.appendChild(r.getElement());d.appendChild(Gf(k,l));d.appendChild(u.getElement());m.setValue(a.getBrushInfo().pressureAlpha);p.setValue(a.getAlpha());g.setValue(a.getBrushInfo().pressureSize);e.setValue(a.getBrushSize());k.setValue(a.getBrushInfo().pressureScattering);l.setValue(~~(100*a.getBrushInfo().scattering));b.value=a.getBrushInfo().tip;h.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);g.setValue(C.pressureSize);m.setValue(C.pressureAlpha);b.value=C.tip;k.setValue(C.pressureScattering);~~(100*C.resat)!=h.value&&h.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* +x/100;a.callToolListeners()});r.title=function(x){return ka("Spacing")+": "+x+"%"};r.on("valueChange",function(x){a.getBrushInfo().spacing=x/100;a.callToolListeners()});m.title=function(x){return ka("Scattering")+": "+x+"%"};m.on("valueChange",function(x){a.getBrushInfo().scattering=x/100;a.callToolListeners()});u.title=function(x){return ka("Smoothing")+": "+x+"%"};u.on("valueChange",function(x){a.getBrushInfo().smoothing=x/100;a.callToolListeners()});k.on("valueChange",function(x){a.getBrushInfo().pressureScattering= +x;a.callToolListeners()});l.on("valueChange",function(x){a.getBrushInfo().pressureAlpha=x;a.callToolListeners()});g.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(g, +e));d.appendChild(Gf(l,p));d.appendChild(h.getElement());d.appendChild(n.getElement());d.appendChild(r.getElement());d.appendChild(Gf(k,m));d.appendChild(u.getElement());l.setValue(a.getBrushInfo().pressureAlpha);p.setValue(a.getAlpha());g.setValue(a.getBrushInfo().pressureSize);e.setValue(a.getBrushSize());k.setValue(a.getBrushInfo().pressureScattering);m.setValue(~~(100*a.getBrushInfo().scattering));b.value=a.getBrushInfo().tip;h.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);g.setValue(C.pressureSize);l.setValue(C.pressureAlpha);b.value=C.tip;k.setValue(C.pressureScattering);~~(100*C.resat)!=h.value&&h.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)!=m.value&&m.setValue(~~(100*C.scattering));~~(100* C.smoothing)!=u.value&&u.setValue(~~(100*C.smoothing))});Y(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))});Y(Sb)("{,[",function(){let x=a.getBrushSize();for(let C=c.length-1;0<=C;C--)if(x>c[C]){a.setBrushSize(c[C]);break}});Y(Sb)("},]",function(){let x=a.getBrushSize();for(let C=0;C>>24,b),g=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);g.on("colorChange",c);g.on("alphaChange",c);(d=document.createElement("p")).textContent=ka("Gradient");b.appendChild(d); -b.appendChild(m.getElement());(d=document.createElement("div")).className="chickenpaint-gradient-colors";(m=document.createElement("div")).className="chickenpaint-gradient-start-color";m.appendChild(p.getElement());d.appendChild(m);(m=document.createElement("div")).className="chickenpaint-gradient-end-color";m.appendChild(g.getElement());d.appendChild(m);b.appendChild(d)}function Rh(a){var c={smooth:ka("Smooth"),sharp:ka("Sharp")};let d=document.createElement("div"),b=document.createElement("button"), -m=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",m.type="button",b.className="btn btn-primary btn-block",m.className="btn btn-light btn-block",b.textContent=ka("Apply transform"),m.textContent=ka("Cancel"),p.addEventListener("change",function(g){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 g=document.createElement("label");g.textContent=ka("Transform style");c.className="form-group";c.appendChild(g);c.appendChild(p);d.appendChild(c)}p=document.createElement("div");p.appendChild(b);p.appendChild(m);p.className="form-group";d.appendChild(p);b.addEventListener("click",function(g){a.actionPerformed({action:"CPTransformAccept"});g.preventDefault()});m.addEventListener("click",function(g){a.actionPerformed({action:"CPTransformReject"}); +a.setCurGradient(e)}var d;let b=document.createElement("div");var l=new Oh(a);let p=new oe(new Bb(16777215&a.getCurGradient()[0]),a.getCurGradient()[0]>>>24,b),g=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);g.on("colorChange",c);g.on("alphaChange",c);(d=document.createElement("p")).textContent=ka("Gradient");b.appendChild(d); +b.appendChild(l.getElement());(d=document.createElement("div")).className="chickenpaint-gradient-colors";(l=document.createElement("div")).className="chickenpaint-gradient-start-color";l.appendChild(p.getElement());d.appendChild(l);(l=document.createElement("div")).className="chickenpaint-gradient-end-color";l.appendChild(g.getElement());d.appendChild(l);b.appendChild(d)}function Rh(a){var c={smooth:ka("Smooth"),sharp:ka("Sharp")};let d=document.createElement("div"),b=document.createElement("button"), +l=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",l.type="button",b.className="btn btn-primary btn-block",l.className="btn btn-light btn-block",b.textContent=ka("Apply transform"),l.textContent=ka("Cancel"),p.addEventListener("change",function(g){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 g=document.createElement("label");g.textContent=ka("Transform style");c.className="form-group";c.appendChild(g);c.appendChild(p);d.appendChild(c)}p=document.createElement("div");p.appendChild(b);p.appendChild(l);p.className="form-group";d.appendChild(p);b.addEventListener("click",function(g){a.actionPerformed({action:"CPTransformAccept"});g.preventDefault()});l.addEventListener("click",function(g){a.actionPerformed({action:"CPTransformReject"}); g.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=m.getActiveLayer();G.getAlpha()!=l.value&&l.setValue(G.getAlpha());(function(){let L=m.getActiveLayer();for(;h.lastChild;)h.removeChild(h.lastChild);for(let W=T.LM_FIRST;W<=T.LM_LAST;W++)if(W!=T.LM_MULTIPLY2&&(W==L.blendMode||W===T.LM_PASSTHROUGH&&L instanceof ob||W<=T.LM_LAST_CHIBIPAINT)){let U=document.createElement("option");U.appendChild(document.createTextNode(ka(T.BLEND_MODE_DISPLAY_NAMES[W]))); -W!==T.LM_MULTIPLY||L.blendMode===W||L.useLegacyMultiply?U.value=W:U.value=T.LM_MULTIPLY2;h.appendChild(U)}})();G.getBlendMode()!=parseInt(h.value,10)&&(h.value=G.getBlendMode());G.getLockAlpha()!=u.checked&&(u.checked=G.getLockAlpha());(function(){var L;let W={"image-layer":(L=m.getActiveLayer())instanceof Na,"layer-group":L instanceof ob,"clipping-mask":L instanceof Na&&L.clip,"no-clipping-mask":L instanceof Na&&!L.clip,"no-clipping-mask-or-is-group":!(L instanceof Na)||!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 U of"mask no-mask clipping-mask no-clipping-mask-or-is-group image-layer layer-group".split(" "))for(let X of x.getElementsByClassName("chickenpaint-action-require-"+U))X.style.display=W[U]?"inline-block":"none";x.querySelectorAll("[data-action]").forEach(function(U){let X=U.getAttribute("data-action");U.classList.toggle("disabled",!a.isActionAllowed(X))})})()}function d(){m= -this;k.resize();c()}lc.call(this,a,"layers","Layers",{resizeHorz:!0,resizeVert:!0});let b=this,m=a.getArtwork(),p=null,g=this.getBodyElement(),e=this.getElement(),k=new function(){function G(Ma){let ma=Y(ja)(".chickenpaint-layer",Xa);return ma.get(ma.length-1-Ma)}function L(Ma){Ma=Y(ja)(Ma).closest(".chickenpaint-layer");if(!Ma.length)return-1;let ma=Y(ja)(".chickenpaint-layer",Xa);return ma.length-1-ma.index(Ma)}function W(){if(2===na.state){let ya=e.getBoundingClientRect();var Ma=!0;let ha=!0;if(na.dropTarget= -function(Oa,qa){var Ta=Y(ja)(".chickenpaint-layer",Xa);Oa={layer:p[p.length-1],displayIndex:p.length-1,direction:"over"};for(var Ja=0;Jalb.bottom){Oa=m.getLayersRoot().layers[0];Oa={layer:Oa,displayIndex:p.indexOf(Oa),direction:"under"};break}if(qa>=lb.top){Ta=p[Ja];let bc=lb.bottom-lb.top;Oa={layer:Ta,displayIndex:Ja};Ta instanceof ob?qa>=lb.top+.75*bc?Ta.expanded&&0=lb.top+.25*bc?Ta.expanded&&0=lb.top+.5*bc?Oa.direction="under":Oa.direction="over";break}}return Oa.layer.parent==na.layer.parent&&("over"==Oa.direction||"under"==Oa.direction)&&(qa=Oa.layer.parent,Ja=qa.indexOf(Oa.layer),"over"==Oa.direction&&qa.layers[Ja+1]==na.layer||"under"==Oa.direction&& -qa.layers[Ja-1]==na.layer||Oa.layer==na.layer)?null:na.layer instanceof ob&&(Oa.layer==na.layer&&"inside"==Oa.direction||Oa.layer.hasAncestor(na.layer))?null:Oa}(na.dragX,na.dragY),na.dropTarget){var ma=G(na.dropTarget.displayIndex);switch(na.dropTarget.direction){case "over":case "under":Xa.appendChild(na.dropBetweenMarkerElem);Ma=na.dropTarget.layer.getDepth()-1;var Ca;if(ma=ma.getBoundingClientRect(),"under"==na.dropTarget.direction&&na.dropTarget.layer instanceof ob&&na.dropTarget.layer.expanded){for(Ca= -na.dropTarget.displayIndex-1;0<=Ca&&p[Ca].hasAncestor(na.dropTarget.layer);Ca--);Ca=G(Ca+1).getBoundingClientRect().bottom}else Ca=ma.bottom;Ma=ma.left-ya.left+(0Z(ha,ya)),Ca=document.createDocumentFragment();Y(ja)(Xa).empty();for(let ya=ma.length-1;0<=ya;ya--)Ca.appendChild(ma[ya]);Xa.appendChild(Ca);W()},this.layerChanged=function(ma){let Ca=p.indexOf(ma),ya=Y(ja)(G(Ca));0===ya.length||ma instanceof ob&&(ma.expanded!=Y(ja)(ya).hasClass("chickenpaint-layer-group-expanded")||ma.visible!=Y(ja)(ya).hasClass("chickenpaint-layer-visible"))?this.buildLayers():ya.replaceWith(Z(Ca,ma))},this.setRotation90= -function(ma){if(Lb!=ma)for(Lb=ma,ma=0;mama.preventDefault(),!0),Xa.className="list-group",Xa.addEventListener("dblclick",function(ma){0===ma.button&&0{3===na.state&&(Ia(),na.dragY=ma.clientY,W())},800)):na.state=1,na.dropTarget=null,na.layer=ya,na.layerElem=G(Ca),na.dragX=ma.clientX,na.dragY=ma.clientY,Xa.setPointerCapture(ma.pointerId),Xa.addEventListener("pointermove",S),Xa.addEventListener("pointerup",wa)):2==ma.button&&!ha&&(ma.preventDefault(),-1!=L(ma.target)&&(ia(L(ma.target)),ma.preventDefault()))}}}}), -Xa.setAttribute("touch-action","none"),["ontouchstart","ontouchmove","ontouchend","ontouchcancel"]))Xa.addEventListener(Ma,Sh);mb.appendChild(Xa)},l=new Fc(0,100,!1,!1,208),h=document.createElement("select"),n=new function(){let G=null,L="",W=document.createElement("input"),U=this;this.hide=function(){G=null;let X=Y(ja)(W).parent();X&&(Y(ja)(W).remove(),X.text(L))};this.renameAndHide=function(){G&&G.name!=W.value&&a.actionPerformed({action:"CPSetLayerName",layer:G,name:W.value});this.hide()};this.show= +b.appendChild(a),b.appendChild(document.createTextNode(c)),d.appendChild(a),d.appendChild(b),d}function Qe(a){function c(){let G=l.getActiveLayer();G.getAlpha()!=m.value&&m.setValue(G.getAlpha());(function(){let L=l.getActiveLayer();for(;h.lastChild;)h.removeChild(h.lastChild);for(let W=T.LM_FIRST;W<=T.LM_LAST;W++)if(W!=T.LM_MULTIPLY2&&(W==L.blendMode||W===T.LM_PASSTHROUGH&&L instanceof ob||W<=T.LM_LAST_CHIBIPAINT)){let U=document.createElement("option");U.appendChild(document.createTextNode(ka(T.BLEND_MODE_DISPLAY_NAMES[W]))); +W!==T.LM_MULTIPLY||L.blendMode===W||L.useLegacyMultiply?U.value=W:U.value=T.LM_MULTIPLY2;h.appendChild(U)}})();G.getBlendMode()!=parseInt(h.value,10)&&(h.value=G.getBlendMode());G.getLockAlpha()!=u.checked&&(u.checked=G.getLockAlpha());(function(){var L;let W={"image-layer":(L=l.getActiveLayer())instanceof Na,"layer-group":L instanceof ob,"clipping-mask":L instanceof Na&&L.clip,"no-clipping-mask":L instanceof Na&&!L.clip,"no-clipping-mask-or-is-group":!(L instanceof Na)||!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 U of"mask no-mask clipping-mask no-clipping-mask-or-is-group image-layer layer-group".split(" "))for(let X of x.getElementsByClassName("chickenpaint-action-require-"+U))X.style.display=W[U]?"inline-block":"none";x.querySelectorAll("[data-action]").forEach(function(U){let X=U.getAttribute("data-action");U.classList.toggle("disabled",!a.isActionAllowed(X))})})()}function d(){l= +this;k.resize();c()}lc.call(this,a,"layers","Layers",{resizeHorz:!0,resizeVert:!0});let b=this,l=a.getArtwork(),p=null,g=this.getBodyElement(),e=this.getElement(),k=new function(){function G(Ma){let ma=Y(ja)(".chickenpaint-layer",Ya);return ma.get(ma.length-1-Ma)}function L(Ma){Ma=Y(ja)(Ma).closest(".chickenpaint-layer");if(!Ma.length)return-1;let ma=Y(ja)(".chickenpaint-layer",Ya);return ma.length-1-ma.index(Ma)}function W(){if(2===na.state){let ya=e.getBoundingClientRect();var Ma=!0;let ha=!0;if(na.dropTarget= +function(Oa,qa){var Ua=Y(ja)(".chickenpaint-layer",Ya);Oa={layer:p[p.length-1],displayIndex:p.length-1,direction:"over"};for(var Ja=0;Jakb.bottom){Oa=l.getLayersRoot().layers[0];Oa={layer:Oa,displayIndex:p.indexOf(Oa),direction:"under"};break}if(qa>=kb.top){Ua=p[Ja];let bc=kb.bottom-kb.top;Oa={layer:Ua,displayIndex:Ja};Ua instanceof ob?qa>=kb.top+.75*bc?Ua.expanded&&0=kb.top+.25*bc?Ua.expanded&&0=kb.top+.5*bc?Oa.direction="under":Oa.direction="over";break}}return Oa.layer.parent==na.layer.parent&&("over"==Oa.direction||"under"==Oa.direction)&&(qa=Oa.layer.parent,Ja=qa.indexOf(Oa.layer),"over"==Oa.direction&&qa.layers[Ja+1]==na.layer||"under"==Oa.direction&& +qa.layers[Ja-1]==na.layer||Oa.layer==na.layer)?null:na.layer instanceof ob&&(Oa.layer==na.layer&&"inside"==Oa.direction||Oa.layer.hasAncestor(na.layer))?null:Oa}(na.dragX,na.dragY),na.dropTarget){var ma=G(na.dropTarget.displayIndex);switch(na.dropTarget.direction){case "over":case "under":Ya.appendChild(na.dropBetweenMarkerElem);Ma=na.dropTarget.layer.getDepth()-1;var Ca;if(ma=ma.getBoundingClientRect(),"under"==na.dropTarget.direction&&na.dropTarget.layer instanceof ob&&na.dropTarget.layer.expanded){for(Ca= +na.dropTarget.displayIndex-1;0<=Ca&&p[Ca].hasAncestor(na.dropTarget.layer);Ca--);Ca=G(Ca+1).getBoundingClientRect().bottom}else Ca=ma.bottom;Ma=ma.left-ya.left+(0Z(ha,ya)),Ca=document.createDocumentFragment();Y(ja)(Ya).empty();for(let ya=ma.length-1;0<=ya;ya--)Ca.appendChild(ma[ya]);Ya.appendChild(Ca);W()},this.layerChanged=function(ma){let Ca=p.indexOf(ma),ya=Y(ja)(G(Ca));0===ya.length||ma instanceof ob&&(ma.expanded!=Y(ja)(ya).hasClass("chickenpaint-layer-group-expanded")||ma.visible!=Y(ja)(ya).hasClass("chickenpaint-layer-visible"))?this.buildLayers():ya.replaceWith(Z(Ca,ma))},this.setRotation90= +function(ma){if(Lb!=ma)for(Lb=ma,ma=0;mama.preventDefault(),!0),Ya.className="list-group",Ya.addEventListener("dblclick",function(ma){0===ma.button&&0{3===na.state&&(Ia(),na.dragY=ma.clientY,W())},800)):na.state=1,na.dropTarget=null,na.layer=ya,na.layerElem=G(Ca),na.dragX=ma.clientX,na.dragY=ma.clientY,Ya.setPointerCapture(ma.pointerId),Ya.addEventListener("pointermove",S),Ya.addEventListener("pointerup",wa)):2==ma.button&&!ha&&(ma.preventDefault(),-1!=L(ma.target)&&(ia(L(ma.target)),ma.preventDefault()))}}}}), +Ya.setAttribute("touch-action","none"),["ontouchstart","ontouchmove","ontouchend","ontouchcancel"]))Ya.addEventListener(Ma,Sh);mb.appendChild(Ya)},m=new Fc(0,100,!1,!1,208),h=document.createElement("select"),n=new function(){let G=null,L="",W=document.createElement("input"),U=this;this.hide=function(){G=null;let X=Y(ja)(W).parent();X&&(Y(ja)(W).remove(),X.text(L))};this.renameAndHide=function(){G&&G.name!=W.value&&a.actionPerformed({action:"CPSetLayerName",layer:G,name:W.value});this.hide()};this.show= function(X,Z){L=(G=X).name;W.value=L;(X=Z.querySelector(".chickenpaint-layer-name"))&&X.parentNode&&(Z=X.firstChild)&&Z.nodeType===Node.TEXT_NODE&&(X.removeChild(Z),X.appendChild(W));W.select()};W.type="text";W.className="chickenpaint-layer-rename form-control input-sm";W.addEventListener("keydown",function(X){X.stopPropagation()});W.addEventListener("keydown",function(X){"Enter"===X.key&&U.renameAndHide();X.stopPropagation()});W.addEventListener("keyup",function(X){"Escape"===X.key&&U.hide();X.stopPropagation()}); -W.addEventListener("blur",function(X){G&&U.renameAndHide()})},r=document.createElement("input"),u=document.createElement("input"),v=!1,x,C=this.setSize,K=this.setWidth,J=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();k.resize()};this.setHeight=function(G){J.call(this,G);k.resize()};this.setRotation90=function(G){k.setRotation90(G)};this.dismissNotification=function(){Y(ja)(".chickenpaint-layer[aria-describedby],.chickenpaint-slider[aria-describedby]", -g).each((G,L)=>{L=Y(ja)(L);(G=oc.Popover.getInstance(L[0]))&&G.dispose()});v&&(clearTimeout(v),v=!1)};this.showNotification=(G,L,W)=>{let U=p.indexOf(G);G=m.getActiveLayer()==G&&"opacity"==W?l.getElement():k.revealLayer(U);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))};h.className="form-control form-control-sm"; -h.tabIndex=-1;h.title=ka("Layer blending mode");h.addEventListener("change",function(G){a.actionPerformed({action:"CPSetLayerBlendMode",blendMode:parseInt(h.value,10)});h.blur()});g.appendChild(h);l.title=function(G){return ka("Opacity")+": "+G+"%"};l.on("valueChange",function(G){a.actionPerformed({action:"CPSetLayerAlpha",alpha:G})});g.appendChild(l.getElement());r.id="chickenpaint-chk-sample-all-layers";r.type="checkbox";r.addEventListener("click",function(G){m.setSampleAllLayers(r.checked);document.activeElement.blur()}); +W.addEventListener("blur",function(X){G&&U.renameAndHide()})},r=document.createElement("input"),u=document.createElement("input"),v=!1,x,C=this.setSize,K=this.setWidth,J=this.setHeight;this.setSize=function(G,L){C.call(this,G,L);this.dismissNotification();m.resize()};this.setWidth=function(G){K.call(this,G);m.resize();k.resize()};this.setHeight=function(G){J.call(this,G);k.resize()};this.setRotation90=function(G){k.setRotation90(G)};this.dismissNotification=function(){Y(ja)(".chickenpaint-layer[aria-describedby],.chickenpaint-slider[aria-describedby]", +g).each((G,L)=>{L=Y(ja)(L);(G=oc.Popover.getInstance(L[0]))&&G.dispose()});v&&(clearTimeout(v),v=!1)};this.showNotification=(G,L,W)=>{let U=p.indexOf(G);G=l.getActiveLayer()==G&&"opacity"==W?m.getElement():k.revealLayer(U);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))};h.className="form-control form-control-sm"; +h.tabIndex=-1;h.title=ka("Layer blending mode");h.addEventListener("change",function(G){a.actionPerformed({action:"CPSetLayerBlendMode",blendMode:parseInt(h.value,10)});h.blur()});g.appendChild(h);m.title=function(G){return ka("Opacity")+": "+G+"%"};m.on("valueChange",function(G){a.actionPerformed({action:"CPSetLayerAlpha",alpha:G})});g.appendChild(m.getElement());r.id="chickenpaint-chk-sample-all-layers";r.type="checkbox";r.addEventListener("click",function(G){l.setSampleAllLayers(r.checked);document.activeElement.blur()}); g.appendChild(Sg(r,ka("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()});g.appendChild(Sg(u,ka("Lock transparency")));g.appendChild(k.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 W of(L.className="chickenpaint-layer-buttons list-unstyled",G))G=document.createElement("li"),G.setAttribute("data-action",W.action),G.className="chickenpaint-small-toolbar-button "+(W.require?"chickenpaint-action-require-"+ -W.require:""),G.title=ka(W.title),G.appendChild(W.icon),G.addEventListener("click",function(){a.actionPerformed({action:W.action})}),L.appendChild(G);return L}();g.appendChild(x);m.on("changeActiveLayer",function(G,L,W){k.activeLayerChanged(L,W);c()});m.on("changeLayer",function(G){m=this;b.dismissNotification();k.layerChanged(G);c()});m.on("changeStructure",d);m.on("changeLayerMaskThumb",function(G){m=this;k.layerMaskThumbChanged(G)});m.on("changeLayerImageThumb",function(G){m=this;k.layerImageThumbChanged(G)}); -a.on("layerNotification",this.showNotification.bind(this));d.call(m)}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(U){for(let X=0;X=U&&(Z.data[ia]=255);return Z}function p(U,X){let Z=new eb(X,X,8);for(let ia=0;ia=U&&(Z.data[ia]=255);return Z}function g(){if(null!=r){u=r.clone();v&&u.mirrorHorizontally();let U=new Th;U.loadBrightnessContrast(C,K);x&&U.invert();u.applyLUT(U)}else u=null;a.getArtwork().setBrushTexture(u);null!=J&&J.updateTexture()}function e(U, -X,Z){let ia=document.createElement("canvas"),wa=ia.getContext("2d"),Ia=this;this.setTexture=function(S){this.texture=S;this.paint()};this.getElement=function(){return ia};this.paint=function(){null!=this.texture?wa.fillStyle=wa.createPattern(this.texture.getAsCanvas(),"repeat"):wa.fillStyle="white";wa.fillRect(0,0,ia.width,ia.height)};ia.addEventListener("click",function(){Ia.emit("click")});ia.width=X;ia.height=Z;this.setTexture(U)}var k;let l,h,n;lc.call(this,a,"textures","Textures");let r,u,v= -!1,x=!1,C=0,K=0,J,G=document.createElement("div"),L=this.getBodyElement();e.prototype=Object.create(Y(Zb).prototype);e.prototype.constructor=e;J=new function(){function U(){Ia.checked=x;S.checked=v;za.setValue(100*C+100);na.setValue(100*K+100)}let X,Z,ia,wa=document.createElement("div"),Ia=document.createElement("input"),S=document.createElement("input"),za=new Fc(0,200,!0),na=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 wa};wa.className="chickenpaint-texture-options";wa.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=ka("Customize");(X=document.createElement("div")).className="chickenpaint-texture-controls";Ia.id="chickenpaint-chk-texture-invert"; +W.require:""),G.title=ka(W.title),G.appendChild(W.icon),G.addEventListener("click",function(){a.actionPerformed({action:W.action})}),L.appendChild(G);return L}();g.appendChild(x);l.on("changeActiveLayer",function(G,L,W){k.activeLayerChanged(L,W);c()});l.on("changeLayer",function(G){l=this;b.dismissNotification();k.layerChanged(G);c()});l.on("changeStructure",d);l.on("changeLayerMaskThumb",function(G){l=this;k.layerMaskThumbChanged(G)});l.on("changeLayerImageThumb",function(G){l=this;k.layerImageThumbChanged(G)}); +a.on("layerNotification",this.showNotification.bind(this));d.call(l)}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(U){for(let X=0;X=U&&(Z.data[ia]=255);return Z}function p(U,X){let Z=new Ta(X,X,8);for(let ia=0;ia=U&&(Z.data[ia]=255);return Z}function g(){if(null!=r){u=r.clone();v&&u.mirrorHorizontally();let U=new Th;U.loadBrightnessContrast(C,K);x&&U.invert();u.applyLUT(U)}else u=null;a.getArtwork().setBrushTexture(u);null!=J&&J.updateTexture()}function e(U, +X,Z){let ia=document.createElement("canvas"),wa=ia.getContext("2d"),Ia=this;this.setTexture=function(S){this.texture=S;this.paint()};this.getElement=function(){return ia};this.paint=function(){null!=this.texture?wa.fillStyle=wa.createPattern(this.texture.getAsCanvas(),"repeat"):wa.fillStyle="white";wa.fillRect(0,0,ia.width,ia.height)};ia.addEventListener("click",function(){Ia.emit("click")});ia.width=X;ia.height=Z;this.setTexture(U)}var k;let m,h,n;lc.call(this,a,"textures","Textures");let r,u,v= +!1,x=!1,C=0,K=0,J,G=document.createElement("div"),L=this.getBodyElement();e.prototype=Object.create(Y(Zb).prototype);e.prototype.constructor=e;J=new function(){function U(){Ia.checked=x;S.checked=v;za.setValue(100*C+100);na.setValue(100*K+100)}let X,Z,ia,wa=document.createElement("div"),Ia=document.createElement("input"),S=document.createElement("input"),za=new Fc(0,200,!0),na=new Fc(0,200,!0),mb=new e(null,64,64),Ya=document.createElement("button"),Lb,Fb=new oc.Popover(Ya,{html:!0,content:()=>Lb, +trigger:"manual",placement:"right",container:L});this.updateTexture=function(){Ya.disabled=null==u;mb.setTexture(u)};this.getElement=function(){return wa};wa.className="chickenpaint-texture-options";wa.appendChild(mb.getElement());Ya.type="button";Ya.className="btn btn-light btn-sm";Ya.setAttribute("data-bs-toggle","popover");Ya.setAttribute("data-bs-placement","right");Ya.textContent=ka("Customize");(X=document.createElement("div")).className="chickenpaint-texture-controls";Ia.id="chickenpaint-chk-texture-invert"; Ia.type="checkbox";Ia.addEventListener("click",function(Ka){x=this.checked;g()});X.appendChild(Tg(Ia,ka("Inverse")));S.id="chickenpaint-chk-texture-mirror";S.type="checkbox";S.addEventListener("click",function(Ka){v=this.checked;g()});X.appendChild(Tg(S,ka("Mirror")));za.title=function(Ka){return ka("Brightness")+": "+(Ka-100)+"%"};za.on("valueChange",function(Ka){C=(Ka-100)/100;g()});X.appendChild(za.getElement());na.title=function(Ka){return ka("Contrast")+": "+(Ka-100)+"%"};na.on("valueChange", -function(Ka){K=(Ka-100)/100;g()});X.appendChild(na.getElement());Z=document.createElement("button");ia=document.createElement("button");Z.textContent="Ok";Z.className="btn btn-primary btn-sm";Z.type="button";Z.addEventListener("click",function(Ka){Fb.hide()});X.appendChild(Z);X.appendChild(document.createTextNode(" "));ia.textContent="Reset";ia.className="btn btn-secondary btn-sm";ia.type="button";ia.addEventListener("click",function(Ka){K=C=0;x=v=!1;U();g()});X.appendChild(ia);U();Lb=X;Xa.addEventListener("click", -function(){Fb.toggle()});wa.appendChild(Xa);this.updateTexture()};L.appendChild(J.getElement());G.className="chickenpaint-texture-swatches";L.appendChild(G);c((k=[null],(l=new eb(2,2,8)).data[0]=255,l.data[3]=255,k.push(l),k.push(d(2)),k.push(d(3)),k.push(d(4)),k.push(d(6)),k.push(d(8)),k.push(m(1,2)),k.push(m(2,4)),k.push(p(1,2)),k.push(p(2,4)),k.push(b(2)),k.push(b(4)),k.push(b(8)),k.push(b(16)),k.push(function(U){let X=new eb(256,256,8);for(let Z=0;ZU;U++){X.drawImage(h,0,32*U,32,32,0,0,32,32);try{let Z=X.getImageData(0,0,32,32),ia=new eb(32,32,8);for(let wa=0;1024>wa;wa++)ia.data[wa]=Z.data[4*wa];n.push(ia)}catch(Z){console.log(Z)}}W(n)}; +function(Ka){K=(Ka-100)/100;g()});X.appendChild(na.getElement());Z=document.createElement("button");ia=document.createElement("button");Z.textContent="Ok";Z.className="btn btn-primary btn-sm";Z.type="button";Z.addEventListener("click",function(Ka){Fb.hide()});X.appendChild(Z);X.appendChild(document.createTextNode(" "));ia.textContent="Reset";ia.className="btn btn-secondary btn-sm";ia.type="button";ia.addEventListener("click",function(Ka){K=C=0;x=v=!1;U();g()});X.appendChild(ia);U();Lb=X;Ya.addEventListener("click", +function(){Fb.toggle()});wa.appendChild(Ya);this.updateTexture()};L.appendChild(J.getElement());G.className="chickenpaint-texture-swatches";L.appendChild(G);c((k=[null],(m=new Ta(2,2,8)).data[0]=255,m.data[3]=255,k.push(m),k.push(d(2)),k.push(d(3)),k.push(d(4)),k.push(d(6)),k.push(d(8)),k.push(l(1,2)),k.push(l(2,4)),k.push(p(1,2)),k.push(p(2,4)),k.push(b(2)),k.push(b(4)),k.push(b(8)),k.push(b(16)),k.push(function(U){let X=new Ta(256,256,8);for(let Z=0;ZU;U++){X.drawImage(h,0,32*U,32,32,0,0,32,32);try{let Z=X.getImageData(0,0,32,32),ia=new Ta(32,32,8);for(let wa=0;1024>wa;wa++)ia.data[wa]=Z.data[4*wa];n.push(ia)}catch(Z){console.log(Z)}}W(n)}; h.src=k}function Se(a){function c(K){let J=document.createElement("div"),G=document.createElement("a"),L=document.createElement("ul"),W=document.createElement("a"),U=document.createElement("a"),X=this;this.getElement=function(){return J};this.setColor=function(ia){G.setAttribute("data-color",ia);var wa=G.style;for(ia=""+Number(ia).toString(16);6>ia.length;)ia="0"+ia;wa.backgroundColor="#"+ia};this.setColor(K);G.href="#";G.className="chickenpaint-color-swatch dropdown-toggle";W.className="dropdown-item"; W.href="#";W.textContent=ka("Remove");W.addEventListener("click",function(ia){ia.preventDefault();Y(ja)(J).remove();n=!0});U.className="dropdown-item";U.href="#";U.textContent=ka("Replace with current color");U.addEventListener("click",function(ia){ia.preventDefault();X.setColor(a.getCurColor().getRgb());n=!0});L.className="dropdown-menu";K=document.createElement("li");let Z=document.createElement("li");K.appendChild(W);Z.appendChild(U);L.appendChild(K);L.appendChild(Z);J.className="chickenpaint-color-swatch-wrapper"; -J.appendChild(G);J.appendChild(L)}function d(K){K=new c(K);r.appendChild(K.getElement())}function b(K){let J=document.createElement("span");return J.className="fa icon-"+K,J}let m,p,g;let e,k,l;lc.call(this,a,"swatches","Color swatches");let h=[16777215,0,16711680,65280,255,16776960],n=!1,r=document.createElement("ul"),u=document.createElement("div"),v,x=this;this.getSwatches=function(){let K=Y(ja)(".chickenpaint-color-swatch",r),J=Array(K.length);for(let G=0;GJ.length)){J=J[0];var G=new FileReader;G.onload=function(){let L=(new Rd).read(this.result);null!=L&&0 .chickenpaint-palette",g).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=0 .chickenpaint-palette",g).each(function(){e.showPaletteByName(this.getAttribute("data-paletteName"),!1);m.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
'), -m=navigator.userAgent.toLowerCase().includes("mac os");b[0].addEventListener("touchmove",g=>{g.preventDefault()},{passive:!1});this.getElement=function(){return b[0]};(function(g,e){g.append(e.map(k=>{let l=Y(ja)(''),h=Y(ja)(".dropdown-toggle",l),n=Y(ja)(".dropdown-menu",l);return h[0].addEventListener("show.bs.dropdown", -r=>{!function(u){Y(ja)("[data-action]",u).each(function(){let x=Y(ja)(this);var C=this.getAttribute("data-action");C=a.isActionAllowed(C);x.toggleClass("disabled",!C).toggleClass("hidden",!C&&!0===x.data("hideIfNotAvailable"))});Y(ja)(".dropdown-divider",u).removeClass("hidden");u=Y(ja)(".dropdown-item:not(.hidden),.dropdown-divider:not(.hidden)",u);let v=null;for(let x=0;x
'), +l=navigator.userAgent.toLowerCase().includes("mac os");b[0].addEventListener("touchmove",g=>{g.preventDefault()},{passive:!1});this.getElement=function(){return b[0]};(function(g,e){g.append(e.map(k=>{let m=Y(ja)(''),h=Y(ja)(".dropdown-toggle",m),n=Y(ja)(".dropdown-menu",m);return h[0].addEventListener("show.bs.dropdown", +r=>{!function(u){Y(ja)("[data-action]",u).each(function(){let x=Y(ja)(this);var C=this.getAttribute("data-action");C=a.isActionAllowed(C);x.toggleClass("disabled",!C).toggleClass("hidden",!C&&!0===x.data("hideIfNotAvailable"))});Y(ja)(".dropdown-divider",u).removeClass("hidden");u=Y(ja)(".dropdown-item:not(.hidden),.dropdown-divider:not(.hidden)",u);let v=null;for(let x=0;x{let u;if(!r.action||a.isActionSupported(r.action)){if("CPSend"!=r.action||a.isActionSupported("CPContinue")||(r.name=ka("Post Oekaki"),r.shortcut="ctrl+p"),"-"==r.name?u=Y(ja)(''):(u=Y(ja)(''+ka(r.name)+""),r.checkbox&&Y(ja)(u).data("checkbox",!0).toggleClass("selected",!!r.checked),r.hideIfNotAvailable&&u.data("hideIfNotAvailable",!0)),r.title&&u.attr("title", -ka(r.title)),r.shortcut){var v;let x=u,C=document.createElement("small");m&&(r.shortcut=r.shortcut.replace(/SHIFT/im,"\u21e7"),r.shortcut=r.shortcut.replace(/ALT/im,"\u2325"),r.shortcut=r.shortcut.replace(/CTRL/im,"\u2318"));C.className="chickenpaint-shortcut";C.textContent=(v=(v=(v=(v=r.shortcut).toUpperCase()).replace(/(,.+)$/,"")).replace("=","+"),v=m?v.replace(/([^+])\+/g,"$1"):v.replace(/([^+])\+/g,"$1 "));x.append(C);Y(Sb)(r.shortcut,function(K){return d(x),K.preventDefault(),K.stopPropagation(), -!1})}return Y(ja)("
  • ").append(u)}})),l}))})(Y(ja)(".navbar-nav",b),Ug);(function(g,e){g.append(e.filter(k=>!!k.mnemonic&&a.isActionSupported(k.action)).map(k=>{let l=Y(ja)(`");return l.on("click",h=>{d(l);h.preventDefault()}),l}))})(Y(ja)(".widget-nav",b),Ug[5].children);Y(ja)(b).on("click","a:not(.dropdown-toggle)",function(g){d(Y(ja)(this)); -g.preventDefault()});Y(ja)(".navbar-toggler",b).on("click",g=>{g.preventDefault()});c.getPaletteManager().on("paletteVisChange",function(g,e){Y(ja)('[data-action="CPPal'+g.substring(0,1).toUpperCase()+g.substring(1)+'"]',b).toggleClass("selected",e)});let p=Y(ja)(".dropdown-item[data-action=CPFullScreen]",b);a.on("fullScreen",g=>p.toggleClass("selected",g));p.toggleClass("selected",a.isFullScreen())}function Ue(a,c){let d=document.createElement("div"),b=new Le(a),m=new Te(a),p,g=!1,e=this;this.togglePalettes= -function(){m.togglePalettes()};this.arrangePalettes=function(){setTimeout(m.arrangePalettes.bind(m),0)};this.constrainPalettes=function(){m.constrainPalettes()};this.showPalette=function(l,h){m.showPaletteByName(l,h)};this.getSwatches=function(){return m.palettes.swatches.getSwatches()};this.setSwatches=function(l){m.palettes.swatches.setSwatches(l)};this.getPaletteManager=function(){return m};this.setRotation90=function(l){b.setRotation(l*Math.PI/2);m.palettes.layers.setRotation90(l)};this.setFullScreenMode= -function(l){g!==l&&(g=l,e.resize(),e.arrangePalettes())};this.resize=function(){let l=window.innerHeight,h=p.getElement().getBoundingClientRect().height;b.resize(g?l-h:Math.min(Math.max(l-h-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(m.getElement());c.appendChild(d);b.on("canvasRotated90",function(l){m.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 k=document.getElementById("chickenpaint-main-menu-content");if(document.addEventListener("show.bs.modal",()=>{k&&k.classList.contains("show")&&(new oc.Collapse(k,{toggle:!1})).hide()}),k){let l=document.querySelector(".chickenpaint .widget-nav"); -l&&(k.addEventListener("show.bs.collapse",h=>{l.classList.add("hidden")}),k.addEventListener("hidden.bs.collapse",h=>{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=>{Y(ja)(c).toggleClass("chickenpaint-toolbar-style-old","old"===l)});a.on("unsavedChanges", -l=>{Y(ja)(c).toggleClass("chickenpaint-unsaved",l)});setTimeout(this.resize.bind(this),0)}function Vh(a){var c=Y(ja)('
  • ").append(u)}})),m}))})(Y(ja)(".navbar-nav",b),Ug);(function(g,e){g.append(e.filter(k=>!!k.mnemonic&&a.isActionSupported(k.action)).map(k=>{let m=Y(ja)(`");return m.on("click",h=>{d(m);h.preventDefault()}),m}))})(Y(ja)(".widget-nav",b),Ug[5].children);Y(ja)(b).on("click","a:not(.dropdown-toggle)",function(g){d(Y(ja)(this)); +g.preventDefault()});Y(ja)(".navbar-toggler",b).on("click",g=>{g.preventDefault()});c.getPaletteManager().on("paletteVisChange",function(g,e){Y(ja)('[data-action="CPPal'+g.substring(0,1).toUpperCase()+g.substring(1)+'"]',b).toggleClass("selected",e)});let p=Y(ja)(".dropdown-item[data-action=CPFullScreen]",b);a.on("fullScreen",g=>p.toggleClass("selected",g));p.toggleClass("selected",a.isFullScreen())}function Ue(a,c){let d=document.createElement("div"),b=new Le(a),l=new Te(a),p,g=!1,e=this;this.togglePalettes= +function(){l.togglePalettes()};this.arrangePalettes=function(){setTimeout(l.arrangePalettes.bind(l),0)};this.constrainPalettes=function(){l.constrainPalettes()};this.showPalette=function(m,h){l.showPaletteByName(m,h)};this.getSwatches=function(){return l.palettes.swatches.getSwatches()};this.setSwatches=function(m){l.palettes.swatches.setSwatches(m)};this.getPaletteManager=function(){return l};this.setRotation90=function(m){b.setRotation(m*Math.PI/2);l.palettes.layers.setRotation90(m)};this.setFullScreenMode= +function(m){g!==m&&(g=m,e.resize(),e.arrangePalettes())};this.resize=function(){let m=window.innerHeight,h=p.getElement().getBoundingClientRect().height;b.resize(g?m-h:Math.min(Math.max(m-h-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(l.getElement());c.appendChild(d);b.on("canvasRotated90",function(m){l.palettes.layers.setRotation90(m)});screen.orientation&&screen.orientation.addEventListener("change", +m=>{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 k=document.getElementById("chickenpaint-main-menu-content");if(document.addEventListener("show.bs.modal",()=>{k&&k.classList.contains("show")&&(new oc.Collapse(k,{toggle:!1})).hide()}),k){let m=document.querySelector(".chickenpaint .widget-nav"); +m&&(k.addEventListener("show.bs.collapse",h=>{m.classList.add("hidden")}),k.addEventListener("hidden.bs.collapse",h=>{m.classList.remove("hidden")}));window.addEventListener("resize",()=>{m.classList.remove("hidden")})}document.addEventListener("hidden.bs.collapse",this.resize.bind(this));window.addEventListener("resize",this.resize.bind(this));a.on("fullScreen",m=>this.setFullScreenMode(m));a.on("toolbarStyleChange",m=>{Y(ja)(c).toggleClass("chickenpaint-toolbar-style-old","old"===m)});a.on("unsavedChanges", +m=>{Y(ja)(c).toggleClass("chickenpaint-unsaved",m)});setTimeout(this.resize.bind(this),0)}function Vh(a){var c=Y(ja)('