From 0bbbcc6bbf727724ceadf71efd1f4cb7b6cb3630 Mon Sep 17 00:00:00 2001 From: satopian Date: Wed, 4 Dec 2024 21:50:24 +0900 Subject: [PATCH] chickenpaint.js --- potiboard5/chickenpaint/js/chickenpaint.js | 1288 ++++++++--------- .../chickenpaint/js/chickenpaint.min.js | 1288 ++++++++--------- potiboard5/potiboard.php | 4 +- 3 files changed, 1290 insertions(+), 1290 deletions(-) diff --git a/potiboard5/chickenpaint/js/chickenpaint.js b/potiboard5/chickenpaint/js/chickenpaint.js index 2803b3ad..3cd1f71f 100644 --- a/potiboard5/chickenpaint/js/chickenpaint.js +++ b/potiboard5/chickenpaint/js/chickenpaint.js @@ -51,7 +51,7 @@ !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 l,p=0,g=[0,0,0,0];var e=0;for(l=0;lYa.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);0Xa.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)));l(P)}function m(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);0N.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;EaN.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(),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(),kb.clipTo(this.getBounds()),kb.isEmpty()||(C(new K),v()),d(!1))};this.hasAlpha= @@ -117,8 +117,8 @@ G.prototype.constructor=G;L.prototype=Object.create(zc.prototype);L.prototype.co 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 +(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, @@ -169,11 +169,11 @@ Z.length)Z=wa;else{var Ia=new Uint8Array(wa.length+Z.length);Z=(Ia.set(wa,0),Ia. continue}else if("HEAD"==U.chunkType){C=1;continue}else C=5;break;case 1:if(X.lengthnew 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")}:${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 +(Ie=Je,Ff="en")}function ja(a){return a in Ie?Ie[a]:a}function le(a){function c(e){null===e?p.emitEvent("savingProgress",[1,ja("Saving drawing...")]):p.emitEvent("savingProgress",[e,ja("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(`${ja("The file size exceeds the server limit.")} +${ja("Limit size")}:${h} +${ja("Current size")}:${m}`);return}console.log(ja("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(`${ja("Network response was not ok")} ( ${ja("HTTP Status Code")} : ${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;za {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= +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(ka)(d).height():Y(ka)(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= @@ -210,229 +210,229 @@ La.y);Aa.preMultiply(nb);jb=Mb.subtractPoints(Fa,Ra);break;case -2:nb=Math.PI/4; 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(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 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:0Math.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(),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(),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)}; 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(){Wa.left=0;Wa.top=0;Wa.right=ya.width;Wa.bottom=ya.height;mb()};this.paint=function(){var F=!1;if(fb=!1,Wa.isEmpty()||(ha.save(),ha.clipTo&&(ha.beginPath(),Wa.left|=0,Wa.top|= -0,ha.rect(Wa.left,Wa.top,Math.ceil(Wa.getWidth()),Math.ceil(Wa.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=Ua,ha.fillRect(0,0,Ja.width,Ja.height),ha.drawImage(Oa,0,0,Oa.width,Oa.height),ha.restore(), +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()&& +F.preventDefault();ua.keyUp(F)});document.addEventListener("visibilitychange",function(){var F=ya.height+Y(ka)(Ca).outerHeight();ya.width=1;ya.height=1;Ka.resize(F,!0)},!1);window.addEventListener("scroll",function(){Fb=null});ya.addEventListener("mousedown",function(F){1==F.button&&F.preventDefault()});Ja.on("changeSelection",function(){Ka.repaintAll()});Ja.on("updateRegion",function(F){ec.union(F);Xa(wa(ec))});vc.on("valueChanged",function(F){var N=Ka.getOffset();Ka.setOffset(-F,N.y)});D.on("valueChanged", +function(F){var N=Ka.getOffset();Ka.setOffset(N.x,-F)});this.setInterpolation(!0);fa=document.createElement("div");fa.className="chickenpaint-canvas-container-wrapper";fa.appendChild(ya);ma.className="chickenpaint-canvas-container-top";ma.appendChild(fa);ma.appendChild(D.getElement());Ca.className="chickenpaint-canvas-container-bottom";Ca.appendChild(vc.getElement());Ma.appendChild(ma);Ma.appendChild(Ca);a.setCanvas(this)}function lc(a,c,d,b){a.getSmallScreenMode()&&ja(d+" (shorter)")!==d+" (shorter)"? +this.title=ja(d+" (shorter)"):this.title=ja(d);b=b||{};this.name=c;this.resizeVert=b.resizeVert||!1;this.resizeHorz=b.resizeHorz||!1;let l=document.createElement("div");d=document.createElement("div");let p=document.createElement("i"),g=document.createElement("button"),e=document.createElement("div"),k=null,m=null,h,n,r,u=this;this.getElement=function(){return l};this.getBodyElement=function(){return e};this.getWidth=function(){return Y(ka)(l).outerWidth()};this.getHeight=function(){return Y(ka)(l).outerHeight()}; +this.getX=function(){return parseInt(l.style.left,10)||0};this.getY=function(){return parseInt(l.style.top,10)||0};this.setLocation=function(x,C){l.style.left=x+"px";l.style.top=C+"px"};this.setWidth=function(x){l.style.width=x+"px"};this.setHeight=function(x){l.style.height=x+"px"};this.setSize=function(x,C){this.setWidth(x);this.setHeight(C)};this.setCollapseDownwards=function(x){b.collapseDownwards=x};this.toggleCollapse=function(x){let C=Y(ka)(l);if(void 0===x)x=!C.hasClass("collapsed");else if(C.hasClass("collapsed")== +x)return;let K=C.parents(".chickenpaint").find(".chickenpaint-canvas").height();var J=this.getHeight();J=this.getY()+J;(C.toggleClass("collapsed",x),Y(ka)(p).toggleClass("icon-angle-down",!x).toggleClass("icon-angle-up",x),x)?b.collapseDownwards&&this.setLocation(this.getX(),Math.min(J,K)-this.getHeight()):(x=this.getHeight(),b.collapseDownwards?this.setLocation(this.getX(),Math.max(J-x,0)):this.getY()+x>K&&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;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"== +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(ka)(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(ka)(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(ka)(l).position().left,y:x.pageY-Y(ka)(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}],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:"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(ka)("li",g).removeClass("selected");p==oa.M_DRAW?Y(ka)("li[data-tool="+a.getCurTool()+"]",g).addClass("selected"):Y(ka)("li[data-mode="+p+"]",g).addClass("selected")});a.on("toolChange",function(p){let g=d.getBodyElement();a.getCurMode()==oa.M_DRAW&&(Y(ka)("li", +g).removeClass("selected"),Y(ka)("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=ja(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(ka)(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(),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= +b.title=c||"";b.className="chickenpaint-checkbox";b.width=20;b.height=20;b.fillStyle="black";b.strokeStyle="black";d()}function Fc(a,c,d,b,l=150){function p(){let x=k.width||l,C=k.height,K="string"==typeof v.title?ja(v.title):v.title(v.value),J=3*window.devicePixelRatio,G=.75*k.height;if(d)m.save(),m.fillStyle="white",m.fillRect(0,0,x,C),m.fillStyle="black",m.fillText(K,J,G),m.beginPath(),v.value>=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!== +h+a)}function e(x){switch(n){case 1:return g(x);case 2:var C=v.title();if(!C.includes(ja("Brush size"))&&!C.includes(ja("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: ")+ +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 ja("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, +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(ja(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()});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= +"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,ja("Control brush opacity with pen pressure")),p=new Fc(1,255),g=new Sd(!0,ja("Control brush size with pen pressure")),e=new Fc(1,200,!1,!0),k=new Sd(!1,ja("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 ja("Opacity")+": "+x};p.on("valueChange",function(x){a.setAlpha(x)});e.title=function(x){return ja("Brush size")+": "+x};e.on("valueChange",function(x){a.setBrushSize(x)});h.title=function(x){return ja("Color")+": "+x+"%"};h.on("valueChange",function(x){a.getBrushInfo().resat=x/100;a.callToolListeners()});n.title=function(x){return ja("Blend")+": "+x+"%"};n.on("valueChange",function(x){a.getBrushInfo().bleed= +x/100;a.callToolListeners()});r.title=function(x){return ja("Spacing")+": "+x+"%"};r.on("valueChange",function(x){a.getBrushInfo().spacing=x/100;a.callToolListeners()});m.title=function(x){return ja("Scattering")+": "+x+"%"};m.on("valueChange",function(x){a.getBrushInfo().scattering=x/100;a.callToolListeners()});u.title=function(x){return ja("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(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"}); +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=ja("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:ja("Smooth"),sharp:ja("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=ja("Apply transform"),l.textContent=ja("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=ja("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=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]))); +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(ja(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+(0kb.bottom){Oa=l.getLayersRoot().layers[0];Oa={layer:Oa,displayIndex:p.indexOf(Oa),direction:"under"};break}if(qa>=kb.top){Ta=p[Ja];let bc=kb.bottom-kb.top;Oa={layer:Ta,displayIndex:Ja};Ta instanceof ob?qa>=kb.top+.75*bc?Ta.expanded&&0=kb.top+.25*bc?Ta.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":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)(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&&0Z(ha,ya)),Ca=document.createDocumentFragment();Y(ka)(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(ka)(G(Ca));0===ya.length||ma instanceof ob&&(ma.expanded!=Y(ka)(ya).hasClass("chickenpaint-layer-group-expanded")||ma.visible!=Y(ka)(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,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= +0==ma.button?("pen"===ma.pointerType||"touch"===ma.pointerType?(na.state=3,na.initialScrollTop=Xa.scrollTop,Ka&&clearTimeout(Ka),Ka=setTimeout(()=>{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)},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(ka)(W).parent();X&&(Y(ka)(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();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"), +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(ka)(".chickenpaint-layer[aria-describedby],.chickenpaint-slider[aria-describedby]", +g).each((G,L)=>{L=Y(ka)(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=ja("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 ja("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,ja("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,ja("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);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)}); +W.require:""),G.title=ja(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, +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 $a(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;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)}; +!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=ja("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,ja("Inverse")));S.id="chickenpaint-chk-texture-mirror";S.type="checkbox";S.addEventListener("click",function(Ka){v=this.checked;g()});X.appendChild(Tg(S,ja("Mirror")));za.title=function(Ka){return ja("Brightness")+": "+(Ka-100)+"%"};za.on("valueChange",function(Ka){C=(Ka-100)/100;g()});X.appendChild(za.getElement());na.title=function(Ka){return ja("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],(m=new $a(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 $a(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 $a(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 l,p,g;let e,k,m;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);m.push(this)});else{for(let n= +10))),K.stopPropagation(),K.preventDefault())});r.addEventListener("contextmenu",function(K){let J=K.target;if(/^J.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);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
'), -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");l&&(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=l?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)}})),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= +r=n.getElement();n.on("paletteVisChange",function(){d(this,!1)});h in p&&n.setCollapseDownwards(!0);r.setAttribute("data-paletteName",h);k.push(r)}for(let h in b)p=b[h].getElement(),g.appendChild(p)}function Uh(a,c){function d(g){let e=g.data("action"),k=g.data("checkbox"),m;a.isActionAllowed(e)&&(k?(g.toggleClass("selected"),m=g.hasClass("selected")):m=!1,a.actionPerformed({action:e,checkbox:k,selected:m}))}let b=Y(ka)(''), +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(ka)(''),h=Y(ka)(".dropdown-toggle",m),n=Y(ka)(".dropdown-menu",m);return h[0].addEventListener("show.bs.dropdown", +r=>{!function(u){Y(ka)("[data-action]",u).each(function(){let x=Y(ka)(this);var C=this.getAttribute("data-action");C=a.isActionAllowed(C);x.toggleClass("disabled",!C).toggleClass("hidden",!C&&!0===x.data("hideIfNotAvailable"))});Y(ka)(".dropdown-divider",u).removeClass("hidden");u=Y(ka)(".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=ja("Post Oekaki"),r.shortcut="ctrl+p"),"-"==r.name?u=Y(ka)(''):(u=Y(ka)(''+ja(r.name)+""),r.checkbox&&Y(ka)(u).data("checkbox",!0).toggleClass("selected",!!r.checked),r.hideIfNotAvailable&&u.data("hideIfNotAvailable",!0)),r.title&&u.attr("title", +ja(r.title)),r.shortcut){var v;let x=u,C=document.createElement("small");l&&(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=l?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(ka)("
  • ").append(u)}})),m}))})(Y(ka)(".navbar-nav",b),Ug);(function(g,e){g.append(e.filter(k=>!!k.mnemonic&&a.isActionSupported(k.action)).map(k=>{let m=Y(ka)(`");return m.on("click",h=>{d(m);h.preventDefault()}),m}))})(Y(ka)(".widget-nav",b),Ug[5].children);Y(ka)(b).on("click","a:not(.dropdown-toggle)",function(g){d(Y(ka)(this)); +g.preventDefault()});Y(ka)(".navbar-toggler",b).on("click",g=>{g.preventDefault()});c.getPaletteManager().on("paletteVisChange",function(g,e){Y(ka)('[data-action="CPPal'+g.substring(0,1).toUpperCase()+g.substring(1)+'"]',b).toggleClass("selected",e)});let p=Y(ka)(".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)('