konva 10.3.3 → 10.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/konva.js +1576 -1636
- package/konva.min.js +4 -4
- package/lib/Animation.d.ts +63 -3
- package/lib/Animation.js +86 -65
- package/lib/BezierFunctions.d.ts +10 -0
- package/lib/BezierFunctions.js +32 -0
- package/lib/Canvas.d.ts +53 -0
- package/lib/Canvas.js +93 -34
- package/lib/Container.d.ts +156 -9
- package/lib/Container.js +260 -25
- package/lib/Context.d.ts +247 -0
- package/lib/Context.js +312 -74
- package/lib/Core.js +1 -0
- package/lib/DragAndDrop.d.ts +2 -0
- package/lib/DragAndDrop.js +92 -21
- package/lib/Factory.d.ts +24 -1
- package/lib/Factory.js +14 -20
- package/lib/FastLayer.d.ts +14 -1
- package/lib/FastLayer.js +14 -1
- package/lib/Global.d.ts +114 -3
- package/lib/Global.js +134 -5
- package/lib/Group.d.ts +11 -0
- package/lib/Group.js +11 -0
- package/lib/Layer.d.ts +128 -3
- package/lib/Layer.js +260 -49
- package/lib/Node.d.ts +703 -32
- package/lib/Node.js +1545 -202
- package/lib/PointerEvents.d.ts +2 -1
- package/lib/PointerEvents.js +19 -1
- package/lib/Shape.d.ts +99 -14
- package/lib/Shape.js +1101 -67
- package/lib/Stage.d.ts +85 -2
- package/lib/Stage.js +205 -14
- package/lib/Tween.d.ts +159 -4
- package/lib/Tween.js +243 -24
- package/lib/Util.d.ts +148 -4
- package/lib/Util.js +354 -82
- package/lib/Validators.d.ts +0 -2
- package/lib/Validators.js +3 -25
- package/lib/_CoreInternals.d.ts +12 -6
- package/lib/_CoreInternals.js +1 -0
- package/lib/_FullInternals.d.ts +17 -6
- package/lib/_FullInternals.js +7 -0
- package/lib/canvas-backend.js +6 -0
- package/lib/filters/Blur.d.ts +18 -0
- package/lib/filters/Blur.js +97 -24
- package/lib/filters/Brighten.d.ts +21 -0
- package/lib/filters/Brighten.js +24 -0
- package/lib/filters/Brightness.d.ts +11 -0
- package/lib/filters/Brightness.js +16 -0
- package/lib/filters/Contrast.d.ts +10 -0
- package/lib/filters/Contrast.js +21 -0
- package/lib/filters/Emboss.d.ts +20 -0
- package/lib/filters/Emboss.js +68 -8
- package/lib/filters/Enhance.d.ts +14 -0
- package/lib/filters/Enhance.js +34 -0
- package/lib/filters/Grayscale.d.ts +9 -0
- package/lib/filters/Grayscale.js +12 -0
- package/lib/filters/HSL.d.ts +17 -0
- package/lib/filters/HSL.js +48 -5
- package/lib/filters/HSV.d.ts +18 -0
- package/lib/filters/HSV.js +49 -5
- package/lib/filters/Invert.d.ts +9 -0
- package/lib/filters/Invert.js +12 -0
- package/lib/filters/Kaleidoscope.d.ts +12 -0
- package/lib/filters/Kaleidoscope.js +83 -0
- package/lib/filters/Mask.d.ts +11 -0
- package/lib/filters/Mask.js +18 -0
- package/lib/filters/Noise.d.ts +19 -0
- package/lib/filters/Noise.js +19 -0
- package/lib/filters/Pixelate.d.ts +20 -0
- package/lib/filters/Pixelate.js +28 -1
- package/lib/filters/Posterize.d.ts +21 -0
- package/lib/filters/Posterize.js +22 -0
- package/lib/filters/RGB.d.ts +21 -0
- package/lib/filters/RGB.js +43 -28
- package/lib/filters/RGBA.d.ts +23 -0
- package/lib/filters/RGBA.js +28 -41
- package/lib/filters/Sepia.d.ts +9 -0
- package/lib/filters/Sepia.js +10 -0
- package/lib/filters/Solarize.d.ts +10 -0
- package/lib/filters/Solarize.js +11 -0
- package/lib/filters/Threshold.d.ts +22 -0
- package/lib/filters/Threshold.js +22 -0
- package/lib/shapes/Arc.d.ts +40 -0
- package/lib/shapes/Arc.js +89 -6
- package/lib/shapes/Arrow.d.ts +24 -1
- package/lib/shapes/Arrow.js +83 -0
- package/lib/shapes/Circle.d.ts +18 -0
- package/lib/shapes/Circle.js +36 -9
- package/lib/shapes/Ellipse.d.ts +34 -2
- package/lib/shapes/Ellipse.js +67 -9
- package/lib/shapes/Image.d.ts +49 -0
- package/lib/shapes/Image.js +151 -22
- package/lib/shapes/Label.d.ts +65 -1
- package/lib/shapes/Label.js +113 -20
- package/lib/shapes/Line.d.ts +50 -8
- package/lib/shapes/Line.js +116 -20
- package/lib/shapes/Path.d.ts +56 -6
- package/lib/shapes/Path.js +203 -128
- package/lib/shapes/Rect.d.ts +18 -0
- package/lib/shapes/Rect.js +36 -0
- package/lib/shapes/RegularPolygon.d.ts +22 -0
- package/lib/shapes/RegularPolygon.js +70 -0
- package/lib/shapes/Ring.d.ts +19 -0
- package/lib/shapes/Ring.js +51 -5
- package/lib/shapes/Sprite.d.ts +78 -0
- package/lib/shapes/Sprite.js +238 -25
- package/lib/shapes/Star.d.ts +23 -0
- package/lib/shapes/Star.js +62 -0
- package/lib/shapes/Text.d.ts +59 -1
- package/lib/shapes/Text.js +481 -97
- package/lib/shapes/TextPath.d.ts +49 -3
- package/lib/shapes/TextPath.js +278 -34
- package/lib/shapes/Transformer.d.ts +124 -12
- package/lib/shapes/Transformer.js +864 -140
- package/lib/shapes/Wedge.d.ts +22 -0
- package/lib/shapes/Wedge.js +67 -3
- package/lib/skia-backend.js +9 -0
- package/lib/types.d.ts +2 -23
- package/lib/types.js +1 -21
- package/package.json +12 -16
package/konva.min.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Konva=e()}(this,function(){"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Konva JavaScript Framework v10.
|
|
3
|
+
* Konva JavaScript Framework v10.5.0
|
|
4
4
|
* http://konvajs.org/
|
|
5
5
|
* Licensed under the MIT
|
|
6
|
-
* Date:
|
|
6
|
+
* Date: Tue Sep 08 2026
|
|
7
7
|
*
|
|
8
8
|
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
|
|
9
9
|
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
|
|
10
10
|
*
|
|
11
11
|
* @license
|
|
12
|
-
*/const t=Math.PI/180;const e="undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},i={_global:e,version:"10.3.3",isBrowser:"undefined"!=typeof window&&("[object Window]"==={}.toString.call(window)||"[object global]"==={}.toString.call(window)),isUnminified:/param/.test(function(t){}.toString()),dblClickWindow:400,getAngle:e=>i.angleDeg?e*t:e,enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,_renderBackend:"web",legacyTextRendering:!1,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:()=>i.DD.isDragging,isTransforming(){var t,e;return null!==(e=null===(t=i.Transformer)||void 0===t?void 0:t.isTransforming())&&void 0!==e&&e},isDragReady:()=>!!i.DD.node,releaseCanvasOnDestroy:!0,document:e.document,_injectGlobal(t){void 0!==e.Konva&&console.error("Several Konva instances detected. It is not recommended to use multiple Konva instances in the same environment."),e.Konva=t}},n=t=>{i[t.prototype.getClassName()]=t};i._injectGlobal(i);const s=()=>{if("undefined"==typeof document)throw new Error('Konva.js unsupported environment.\n\nLooks like you are trying to use Konva.js in Node.js environment. because "document" object is undefined.\n\nTo use Konva.js in Node.js environment, you need to use the "canvas-backend" or "skia-backend" module.\n\nbash: npm install canvas\njs: import "konva/canvas-backend";\n\nor\n\nbash: npm install skia-canvas\njs: import "konva/skia-backend";\n')};class r{constructor(t=[1,0,0,1,0,0]){this.dirty=!1,this.m=t&&t.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new r(this.m)}copyInto(t){t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5]}point(t){const e=this.m;return{x:e[0]*t.x+e[2]*t.y+e[4],y:e[1]*t.x+e[3]*t.y+e[5]}}translate(t,e){return this.m[4]+=this.m[0]*t+this.m[2]*e,this.m[5]+=this.m[1]*t+this.m[3]*e,this}scale(t,e){return this.m[0]*=t,this.m[1]*=t,this.m[2]*=e,this.m[3]*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),n=this.m[0]*e+this.m[2]*i,s=this.m[1]*e+this.m[3]*i,r=this.m[0]*-i+this.m[2]*e,a=this.m[1]*-i+this.m[3]*e;return this.m[0]=n,this.m[1]=s,this.m[2]=r,this.m[3]=a,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(t,e){const i=this.m[0]+this.m[2]*e,n=this.m[1]+this.m[3]*e,s=this.m[2]+this.m[0]*t,r=this.m[3]+this.m[1]*t;return this.m[0]=i,this.m[1]=n,this.m[2]=s,this.m[3]=r,this}multiply(t){const e=this.m[0]*t.m[0]+this.m[2]*t.m[1],i=this.m[1]*t.m[0]+this.m[3]*t.m[1],n=this.m[0]*t.m[2]+this.m[2]*t.m[3],s=this.m[1]*t.m[2]+this.m[3]*t.m[3],r=this.m[0]*t.m[4]+this.m[2]*t.m[5]+this.m[4],a=this.m[1]*t.m[4]+this.m[3]*t.m[5]+this.m[5];return this.m[0]=e,this.m[1]=i,this.m[2]=n,this.m[3]=s,this.m[4]=r,this.m[5]=a,this}invert(){const t=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),e=this.m[3]*t,i=-this.m[1]*t,n=-this.m[2]*t,s=this.m[0]*t,r=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),a=t*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=e,this.m[1]=i,this.m[2]=n,this.m[3]=s,this.m[4]=r,this.m[5]=a,this}getMatrix(){return this.m}decompose(){const t=this.m[0],e=this.m[1],i=this.m[2],n=this.m[3],s=t*n-e*i,r={x:this.m[4],y:this.m[5],rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!=t||0!=e){const a=Math.sqrt(t*t+e*e);r.rotation=e>0?Math.acos(t/a):-Math.acos(t/a),r.scaleX=a,r.scaleY=s/a,r.skewX=(t*i+e*n)/s,r.skewY=0}else if(0!=i||0!=n){const a=Math.sqrt(i*i+n*n);r.rotation=Math.PI/2-(n>0?Math.acos(-i/a):-Math.acos(i/a)),r.scaleX=s/a,r.scaleY=a,r.skewX=0,r.skewY=(t*i+e*n)/s}return r.rotation=w._getRotation(r.rotation),r}}const a=Math.PI/180,o=180/Math.PI,h="#",l="Konva error: ",d={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};let c=null;const g="undefined"!=typeof window?window:{},u=new WeakMap,f=new Map,p=t=>{const e=t.trim();return-1===e.indexOf(",")?e.split(/\s*\/\s*|\s+/):e.split(/\s*,\s*/)},m="[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:e[+-]?\\d+)?",_=new RegExp(`^(${m})(%?)$`,"i"),y=(t,e)=>{const i=_.exec(t);return i?i[2]?Number(i[1])/100*e:Number(i[1]):NaN},v=/^#[0-9a-f]+$/i,x=t=>Math.min(Math.max(t,0),1),b=new RegExp(`^(${m})(deg|grad|rad|turn)?$`,"i"),S={deg:1,grad:.9,rad:o,turn:360},w={_isElement:t=>!(!t||1!=t.nodeType),_isFunction:t=>!!(t&&t.constructor&&t.call&&t.apply),_isPlainObject:t=>!!t&&t.constructor===Object,_isArray:t=>"[object Array]"===Object.prototype.toString.call(t),_isNumber:t=>"[object Number]"===Object.prototype.toString.call(t)&&!isNaN(t)&&isFinite(t),_isString:t=>"[object String]"===Object.prototype.toString.call(t),_isBoolean:t=>"[object Boolean]"===Object.prototype.toString.call(t),isObject:t=>t instanceof Object,isValidSelector(t){if("string"!=typeof t)return!1;const e=t[0];return"#"===e||"."===e||e===e.toUpperCase()},_sign:t=>0===t||t>0?1:-1,requestAnimFrame(t,e){const i=e&&!e.closed&&e||g;let n=u.get(i);n||(n=[],u.set(i,n),((t,e)=>{"function"==typeof t.requestAnimationFrame?t.requestAnimationFrame(e):"undefined"!=typeof requestAnimationFrame?requestAnimationFrame(e):setTimeout(e,16)})(i,function(){u.delete(i),n.forEach(function(t){t()})})),n.push(t)},createCanvasElement(){s();const t=document.createElement("canvas");try{t.style=t.style||{}}catch(t){}return t},createImageElement:()=>(s(),document.createElement("img")),_isInDocument:t=>!!t.isConnected,_urlToImage(t,e){const i=w.createImageElement();i.onload=function(){e(i)},i.src=t},_rgbToHex:(t,e,i)=>((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1),_hexToRgb(t){t=t.replace(h,"");const e=parseInt(t,16);return{r:e>>16&255,g:e>>8&255,b:255&e}},getRandomColor(){let t=(16777215*Math.random()|0).toString(16);for(;t.length<6;)t="0"+t;return h+t},isCanvasFarblingActive(){if(null!==c)return c;if("undefined"==typeof document)return c=!1,!1;const t=this.createCanvasElement();t.width=10,t.height=10;const e=t.getContext("2d",{willReadFrequently:!0});e.clearRect(0,0,10,10),e.fillStyle="#282828",e.fillRect(0,0,10,10);const i=e.getImageData(0,0,10,10).data;let n=!1;for(let t=0;t<100;t++)if(40!==i[4*t]||40!==i[4*t+1]||40!==i[4*t+2]||255!==i[4*t+3]){n=!0;break}return c=n,this.releaseCanvas(t),c},getHitColor(){const t=this.getRandomColor();return this.isCanvasFarblingActive()?this.getSnappedHexColor(t):t},getHitColorKey(t,e,i){return this.isCanvasFarblingActive()&&(t=5*Math.round(t/5),e=5*Math.round(e/5),i=5*Math.round(i/5)),h+this._rgbToHex(t,e,i)},getSnappedHexColor(t){const e=this._hexToRgb(t);return h+this._rgbToHex(5*Math.round(e.r/5),5*Math.round(e.g/5),5*Math.round(e.b/5))},getRGB(t){var e;const{r:i=0,g:n=0,b:s=0}=null!==(e=w.colorToRGBA(t))&&void 0!==e?e:{};return{r:i,g:n,b:s}},colorToRGBA(t){t=(t||"").trim()||"black";const e=w._namedColorToRBA(t)||w._hex3ColorToRGBA(t)||w._hex4ColorToRGBA(t)||w._hex6ColorToRGBA(t)||w._hex8ColorToRGBA(t)||w._rgbColorToRGBA(t)||w._hslColorToRGBA(t);if(e&&[e.r,e.g,e.b,e.a].every(w._isNumber))return e},_namedColorToRBA(t){const e=d[t.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:e.length>3?e[3]:1}:null},_rgbColorToRGBA(t){const e=/^rgba?\(([^)]*)\)$/i.exec(t);if(!e)return;const i=p(e[1]);return i.length<3||i.length>4?void 0:{r:y(i[0],255),g:y(i[1],255),b:y(i[2],255),a:i.length>3?y(i[3],1):1}},_hex8ColorToRGBA(t){if(9===t.length&&v.test(t))return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:parseInt(t.slice(7,9),16)/255}},_hex6ColorToRGBA(t){if(7===t.length&&v.test(t))return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:1}},_hex4ColorToRGBA(t){if(5===t.length&&v.test(t))return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:parseInt(t[4]+t[4],16)/255}},_hex3ColorToRGBA(t){if(4===t.length&&v.test(t))return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:1}},_hslColorToRGBA(t){const e=/^hsla?\(([^)]*)\)$/i.exec(t);if(!e)return;const i=p(e[1]);if(i.length<3||i.length>4)return;const n=b.exec(i[0]);if(!n)return;const s=n[2],r=Number(n[1])*(s?S[s.toLowerCase()]:1);if(!isFinite(r))return;const a=(r%360+360)%360/360,o=x(y(i[1],100)/100),h=x(y(i[2],100)/100),l=i.length>3?y(i[3],1):1,d=h<.5?h*(1+o):h+o-h*o,c=2*h-d,g=[0,0,0];for(let t=0;t<3;t++){let e,i=a+1/3*-(t-1);i<0&&i++,i>1&&i--,e=6*i<1?c+6*(d-c)*i:2*i<1?d:3*i<2?c+(d-c)*(2/3-i)*6:c,g[t]=255*e}return{r:Math.round(g[0]),g:Math.round(g[1]),b:Math.round(g[2]),a:l}},haveIntersection:(t,e)=>!(e.x>t.x+t.width||e.x+e.width<t.x||e.y>t.y+t.height||e.y+e.height<t.y),cloneObject(t){const e={};for(const i in t)this._isPlainObject(t[i])?e[i]=this.cloneObject(t[i]):this._isArray(t[i])?e[i]=this.cloneArray(t[i]):e[i]=t[i];return e},cloneArray:t=>t.slice(0),degToRad:t=>t*a,radToDeg:t=>t*o,_degToRad:t=>(w.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),w.degToRad(t)),_radToDeg:t=>(w.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),w.radToDeg(t)),_getRotation:t=>i.angleDeg?w.radToDeg(t):t,_capitalize(t){const e=f.get(t);if(void 0!==e)return e;const i=t.charAt(0).toUpperCase()+t.slice(1);return f.set(t,i),i},throw(t){throw new Error(l+t)},error(t){console.error(l+t)},warn(t){i.showWarnings&&console.warn("Konva warning: "+t)},each(t,e){for(const i in t)e(i,t[i])},_inRange:(t,e,i)=>e<=t&&t<i,_getProjectionToSegment(t,e,i,n,s,r){let a,o,h;const l=(t-i)*(t-i)+(e-n)*(e-n);if(0==l)a=t,o=e,h=(s-i)*(s-i)+(r-n)*(r-n);else{const d=((s-t)*(i-t)+(r-e)*(n-e))/l;d<0?(a=t,o=e,h=(t-s)*(t-s)+(e-r)*(e-r)):d>1?(a=i,o=n,h=(i-s)*(i-s)+(n-r)*(n-r)):(a=t+d*(i-t),o=e+d*(n-e),h=(a-s)*(a-s)+(o-r)*(o-r))}return[a,o,h]},_getProjectionToLine(t,e,i){const n=w.cloneObject(t);let s=Number.MAX_VALUE;return e.forEach(function(r,a){if(!i&&a===e.length-1)return;const o=e[(a+1)%e.length],h=w._getProjectionToSegment(r.x,r.y,o.x,o.y,t.x,t.y),l=h[0],d=h[1],c=h[2];c<s&&(n.x=l,n.y=d,s=c)}),n},_prepareArrayForTween(t,e,i){const n=[],s=[];if(t.length>e.length){const i=e;e=t,t=i}for(let e=0;e<t.length;e+=2)n.push({x:t[e],y:t[e+1]});for(let t=0;t<e.length;t+=2)s.push({x:e[t],y:e[t+1]});const r=[];return s.forEach(function(t){const e=w._getProjectionToLine(t,n,i);r.push(e.x),r.push(e.y)}),r},_prepareToStringify(t){let e;t.visitedByCircularReferenceRemoval=!0;for(const i in t)if(t.hasOwnProperty(i)&&t[i]&&"object"==typeof t[i])if(e=Object.getOwnPropertyDescriptor(t,i),t[i].visitedByCircularReferenceRemoval||w._isElement(t[i])){if(!e.configurable)return null;delete t[i]}else if(null===w._prepareToStringify(t[i])){if(!e.configurable)return null;delete t[i]}return delete t.visitedByCircularReferenceRemoval,t},_assign(t,e){for(const i in e)t[i]=e[i];return t},_getFirstPointerId:t=>t.touches?t.changedTouches[0].identifier:t.pointerId||999,releaseCanvas(...t){i.releaseCanvasOnDestroy&&t.forEach(t=>{t.width=0,t.height=0})},drawRoundedRectPath(t,e,i,n){let s=e<0?e:0,r=i<0?i:0;e=Math.abs(e),i=Math.abs(i);let a=0,o=0,h=0,l=0;"number"==typeof n?a=o=h=l=Math.min(n,e/2,i/2):(a=Math.min(n[0]||0,e/2,i/2),o=Math.min(n[1]||0,e/2,i/2),l=Math.min(n[2]||0,e/2,i/2),h=Math.min(n[3]||0,e/2,i/2)),t.moveTo(s+a,r),t.lineTo(s+e-o,r),t.arc(s+e-o,r+o,o,3*Math.PI/2,0,!1),t.lineTo(s+e,r+i-l),t.arc(s+e-l,r+i-l,l,0,Math.PI/2,!1),t.lineTo(s+h,r+i),t.arc(s+h,r+i-h,h,Math.PI/2,Math.PI,!1),t.lineTo(s,r+a),t.arc(s+a,r+a,a,Math.PI,3*Math.PI/2,!1)},drawRoundedPolygonPath(t,e,i,n,s){n=Math.abs(n);for(let r=0;r<i;r++){const a=e[(r-1+i)%i],o=e[r],h=e[(r+1)%i],l={x:o.x-a.x,y:o.y-a.y},d={x:h.x-o.x,y:h.y-o.y},c=Math.hypot(l.x,l.y),g=Math.hypot(d.x,d.y);let u;u="number"==typeof s?s:r<s.length?s[r]:0;u=n*Math.cos(Math.PI/i)*Math.min(1,u/n*2);const f={x:l.x/c,y:l.y/c},p={x:d.x/g,y:d.y/g},m={x:o.x-f.x*u,y:o.y-f.y*u},_={x:o.x+p.x*u,y:o.y+p.y*u};0===r?t.moveTo(m.x,m.y):t.lineTo(m.x,m.y),t.arcTo(o.x,o.y,_.x,_.y,u)}}};const C=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","roundRect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"];let k,P=null;function A(){if(null!==P)return P;try{const t=w.createCanvasElement().getContext("2d");return t?!!t&&"filter"in t:(P=!1,!1)}catch(t){return P=!1,!1}}class T{constructor(t){this.canvas=t,i.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(t){t.fillEnabled()&&this._fill(t)}_fill(t){}strokeShape(t){t.hasStroke()&&this._stroke(t)}_stroke(t){}fillStrokeShape(t){t.attrs.fillAfterStrokeEnabled?(this.strokeShape(t),this.fillShape(t)):(this.fillShape(t),this.strokeShape(t))}getTrace(t,e){let i,n,s,r,a=this.traceArr,o=a.length,h="";for(i=0;i<o;i++)n=a[i],s=n.method,s?(r=n.args,h+=s,t?h+="()":w._isArray(r[0])?h+="(["+r.join(",")+"])":(e&&(r=r.map(t=>"number"==typeof t?Math.floor(t):t)),h+="("+r.join(",")+")")):(h+=n.property,t||(h+="="+n.val)),h+=";";return h}clearTrace(){this.traceArr=[]}_trace(t){let e,i=this.traceArr;i.push(t),e=i.length,e>=100&&i.shift()}reset(){const t=this.getCanvas().getPixelRatio();this.setTransform(1*t,0,0,1*t,0,0)}getCanvas(){return this.canvas}clear(t){const e=this.getCanvas();t?this.clearRect(t.x||0,t.y||0,t.width||0,t.height||0):this.clearRect(0,0,e.getWidth()/e.pixelRatio,e.getHeight()/e.pixelRatio)}_applyLineCap(t){const e=t.attrs.lineCap;e&&this.setAttr("lineCap",e)}_applyOpacity(t){const e=t.getAbsoluteOpacity();1!==e&&this.setAttr("globalAlpha",e)}_applyLineJoin(t){const e=t.attrs.lineJoin;e&&this.setAttr("lineJoin",e)}_applyMiterLimit(t){const e=t.attrs.miterLimit;null!=e&&this.setAttr("miterLimit",e)}setAttr(t,e){this._context[t]=e}arc(t,e,i,n,s,r){this._context.arc(t,e,i,n,s,r)}arcTo(t,e,i,n,s){this._context.arcTo(t,e,i,n,s)}beginPath(){this._context.beginPath()}bezierCurveTo(t,e,i,n,s,r){this._context.bezierCurveTo(t,e,i,n,s,r)}clearRect(t,e,i,n){this._context.clearRect(t,e,i,n)}clip(...t){this._context.clip.apply(this._context,t)}closePath(){this._context.closePath()}createImageData(t,e){const i=arguments;return 2===i.length?this._context.createImageData(t,e):1===i.length?this._context.createImageData(t):void 0}createLinearGradient(t,e,i,n){return this._context.createLinearGradient(t,e,i,n)}createPattern(t,e){return this._context.createPattern(t,e)}createRadialGradient(t,e,i,n,s,r){return this._context.createRadialGradient(t,e,i,n,s,r)}drawImage(t,e,i,n,s,r,a,o,h){const l=arguments,d=this._context;3===l.length?d.drawImage(t,e,i):5===l.length?d.drawImage(t,e,i,n,s):9===l.length&&d.drawImage(t,e,i,n,s,r,a,o,h)}ellipse(t,e,i,n,s,r,a,o){this._context.ellipse(t,e,i,n,s,r,a,o)}isPointInPath(t,e,i,n){return i?this._context.isPointInPath(i,t,e,n):this._context.isPointInPath(t,e,n)}fill(...t){this._context.fill.apply(this._context,t)}fillRect(t,e,i,n){this._context.fillRect(t,e,i,n)}strokeRect(t,e,i,n){this._context.strokeRect(t,e,i,n)}fillText(t,e,i,n){n?this._context.fillText(t,e,i,n):this._context.fillText(t,e,i)}measureText(t){return this._context.measureText(t)}getImageData(t,e,i,n){return this._context.getImageData(t,e,i,n)}lineTo(t,e){this._context.lineTo(t,e)}moveTo(t,e){this._context.moveTo(t,e)}rect(t,e,i,n){this._context.rect(t,e,i,n)}roundRect(t,e,i,n,s){this._context.roundRect(t,e,i,n,s)}putImageData(t,e,i){this._context.putImageData(t,e,i)}quadraticCurveTo(t,e,i,n){this._context.quadraticCurveTo(t,e,i,n)}restore(){this._context.restore()}rotate(t){this._context.rotate(t)}save(){this._context.save()}scale(t,e){this._context.scale(t,e)}setLineDash(t){this._context.setLineDash?this._context.setLineDash(t):"mozDash"in this._context?this._context.mozDash=t:"webkitLineDash"in this._context&&(this._context.webkitLineDash=t)}getLineDash(){return this._context.getLineDash()}setTransform(t,e,i,n,s,r){this._context.setTransform(t,e,i,n,s,r)}stroke(t){t?this._context.stroke(t):this._context.stroke()}strokeText(t,e,i,n){this._context.strokeText(t,e,i,n)}transform(t,e,i,n,s,r){this._context.transform(t,e,i,n,s,r)}translate(t,e){this._context.translate(t,e)}_enableTrace(){let t,e,i=this,n=C.length,s=this.setAttr;const r=function(t){let n,s=i[t];i[t]=function(){return e=function(t){const e=[],i=t.length,n=w;for(let s=0;s<i;s++){let i=t[s];n._isNumber(i)?i=Math.round(1e3*i)/1e3:n._isString(i)||(i+=""),e.push(i)}return e}(Array.prototype.slice.call(arguments,0)),n=s.apply(i,arguments),i._trace({method:t,args:e}),n}};for(t=0;t<n;t++)r(C[t]);i.setAttr=function(){s.apply(i,arguments);const t=arguments[0];let e=arguments[1];"shadowOffsetX"!==t&&"shadowOffsetY"!==t&&"shadowBlur"!==t||(e/=this.canvas.getPixelRatio()),i._trace({property:t,val:e})}}_applyGlobalCompositeOperation(t){const e=t.attrs.globalCompositeOperation;!e||"source-over"===e||this.setAttr("globalCompositeOperation",e)}}["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled","filter"].forEach(function(t){Object.defineProperty(T.prototype,t,{get(){return this._context[t]},set(e){this._context[t]=e}})});class M extends T{constructor(t,{willReadFrequently:e=!1}={}){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:e})}_fillColor(t){const e=t.fill();this.setAttr("fillStyle",e),t._fillFunc(this)}_fillPattern(t){const e=this._context;"patternQuality"in e&&(e.patternQuality=e.imageSmoothingEnabled?"good":"nearest"),this.setAttr("fillStyle",t._getFillPattern()),t._fillFunc(this)}_fillLinearGradient(t){const e=t._getLinearGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fillRadialGradient(t){const e=t._getRadialGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fill(t){const e=t.fill(),i=t.getFillPriority();if(e&&"color"===i)return void this._fillColor(t);const n=t.getFillPatternImage();if(n&&"pattern"===i)return void this._fillPattern(t);const s=t.getFillLinearGradientColorStops();if(s&&"linear-gradient"===i)return void this._fillLinearGradient(t);const r=t.getFillRadialGradientColorStops();r&&"radial-gradient"===i?this._fillRadialGradient(t):e?this._fillColor(t):n?this._fillPattern(t):s?this._fillLinearGradient(t):r&&this._fillRadialGradient(t)}_strokeLinearGradient(t){const e=t.getStrokeLinearGradientStartPoint(),i=t.getStrokeLinearGradientEndPoint(),n=t.getStrokeLinearGradientColorStops(),s=this.createLinearGradient(e.x,e.y,i.x,i.y);if(n){for(let t=0;t<n.length;t+=2)s.addColorStop(n[t],n[t+1]);this.setAttr("strokeStyle",s)}}_stroke(t){const e=t.dash(),i=t.getStrokeScaleEnabled();if(t.hasStroke()){if(!i){this.save();const t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(t),e&&t.dashEnabled()&&(this.setLineDash(e),this.setAttr("lineDashOffset",t.dashOffset())),this.setAttr("lineWidth",t.strokeWidth()),t.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)");t.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(t):this.setAttr("strokeStyle",t.stroke()),t._strokeFunc(this),i||this.restore()}}_applyShadow(t){var e,i,n;const s=null!==(e=t.getShadowRGBA())&&void 0!==e?e:"black",r=null!==(i=t.getShadowBlur())&&void 0!==i?i:5,a=null!==(n=t.getShadowOffset())&&void 0!==n?n:{x:0,y:0},o=t.getAbsoluteScale(),h=this.canvas.getPixelRatio(),l=o.x*h,d=o.y*h;this.setAttr("shadowColor",s),this.setAttr("shadowBlur",r*Math.min(Math.abs(l),Math.abs(d))),this.setAttr("shadowOffsetX",a.x*l),this.setAttr("shadowOffsetY",a.y*d)}}class R extends T{constructor(t){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:!0})}_fill(t){this.save(),this.setAttr("fillStyle",t.colorKey),t._fillFuncHit(this),this.restore()}strokeShape(t){t.hasHitStroke()&&this._stroke(t)}_stroke(t){if(t.hasHitStroke()){const e=t.getStrokeScaleEnabled();if(!e){this.save();const t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(t);const i=t.hitStrokeWidth(),n="auto"===i?t.strokeWidth():i;this.setAttr("lineWidth",n),this.setAttr("strokeStyle",t.colorKey),t._strokeFuncHit(this),e||this.restore()}}}class G{constructor(t){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;const e=(t||{}).pixelRatio||i.pixelRatio||function(){if(k)return k;const t=w.createCanvasElement(),e=t.getContext("2d");return k=(i._global.devicePixelRatio||1)/(e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1),w.releaseCanvas(t),k}();this.pixelRatio=e,this._canvas=w.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(t){const e=this.pixelRatio;this.pixelRatio=t,this.setSize(this.getWidth()/e,this.getHeight()/e)}setWidth(t){this.width=this._canvas.width=t*this.pixelRatio,this._canvas.style.width=t+"px";const e=this.pixelRatio;this.getContext()._context.scale(e,e)}setHeight(t){this.height=this._canvas.height=t*this.pixelRatio,this._canvas.style.height=t+"px";const e=this.pixelRatio;this.getContext()._context.scale(e,e)}getWidth(){return this.width}getHeight(){return this.height}setSize(t,e){this.setWidth(t||0),this.setHeight(e||0)}setSizeIfChanged(t,e){this.width===t*this.pixelRatio&&this.height===e*this.pixelRatio||this.setSize(t,e)}toDataURL(t,e){try{return this._canvas.toDataURL(t,e)}catch(t){try{return this._canvas.toDataURL()}catch(t){return w.error("Unable to get data URL. "+t.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}}class E extends G{constructor(t={width:0,height:0,willReadFrequently:!1}){super(t),this.context=new M(this,{willReadFrequently:t.willReadFrequently}),this.setSize(t.width,t.height)}}class L extends G{constructor(t={width:0,height:0}){super(t),this.hitCanvas=!0,this.context=new R(this),this.setSize(t.width,t.height)}}const D={get isDragging(){let t=!1;return D._dragElements.forEach(e=>{"dragging"===e.dragStatus&&(t=!0)}),t},justDragged:!1,get node(){let t;return D._dragElements.forEach(e=>{t=e.node}),t},_dragElements:new Map,_listenToWindow(t){const e=e=>D._endDragBefore(e,t),i=e=>D._drag(e,t);t.addEventListener("mouseup",e,!0),t.addEventListener("touchend",e,!0),t.addEventListener("touchcancel",e,!0),t.addEventListener("mousemove",i),t.addEventListener("touchmove",i),t.addEventListener("mouseup",D._endDragAfter,!1),t.addEventListener("touchend",D._endDragAfter,!1),t.addEventListener("touchcancel",D._endDragAfter,!1)},_drag(t,e){const i=[];D._dragElements.forEach((n,s)=>{const{node:r}=n,a=r.getStage();if(e&&a._getOwnerWindow()!==e)return;a.setPointersPositions(t),void 0===n.pointerId&&(n.pointerId=w._getFirstPointerId(t));const o=a._changedPointerPositions.find(t=>t.id===n.pointerId);if(o){if("dragging"!==n.dragStatus){const e=r.dragDistance();if(Math.max(Math.abs(o.x-n.startPointerPos.x),Math.abs(o.y-n.startPointerPos.y))<e)return;if(r.startDrag({evt:t}),!r.isDragging())return}r._setDragPosition(t,n),i.push(r)}}),i.forEach(e=>{e.getStage()&&e.fire("dragmove",{type:"dragmove",target:e,evt:t},!0)})},_endDragBefore(t,e){const n=[];D._dragElements.forEach(s=>{const{node:r}=s,a=r.getStage();!t||e&&a._getOwnerWindow()!==e||a.setPointersPositions(t);if(!a._changedPointerPositions.find(t=>t.id===s.pointerId))return;"dragging"!==s.dragStatus&&"stopped"!==s.dragStatus||(D.justDragged=!0,i._mouseListenClick=!1,i._touchListenClick=!1,i._pointerListenClick=!1,s.dragStatus="stopped");const o=s.node.getLayer()||s.node instanceof i.Stage&&s.node;o&&-1===n.indexOf(o)&&n.push(o)}),n.forEach(t=>{t.draw()})},_endDragAfter(t){D._dragElements.forEach((e,i)=>{"stopped"===e.dragStatus&&e.node.fire("dragend",{type:"dragend",target:e.node,evt:t},!0),"dragging"!==e.dragStatus&&D._dragElements.delete(i)})}};function I(t){return w._isString(t)?'"'+t+'"':"[object Number]"===Object.prototype.toString.call(t)||w._isBoolean(t)?t:Object.prototype.toString.call(t)}function O(t){return t>255?255:t<0?0:Math.round(t)}function F(){if(i.isUnminified)return function(t,e){return w._isNumber(t)||w.warn(I(t)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),t}}function B(t){if(i.isUnminified)return function(e,i){let n=w._isNumber(e),s=w._isArray(e)&&e.length==t;return n||s||w.warn(I(e)+' is a not valid value for "'+i+'" attribute. The value should be a number or Array<number>('+t+")"),e}}function N(){if(i.isUnminified)return function(t,e){return w._isNumber(t)||"auto"===t||w.warn(I(t)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),t}}function H(){if(i.isUnminified)return function(t,e){return w._isString(t)||w.warn(I(t)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),t}}function W(){if(i.isUnminified)return function(t,e){const i=w._isString(t),n="[object CanvasGradient]"===Object.prototype.toString.call(t)||t&&t.addColorStop;return i||n||w.warn(I(t)+' is a not valid value for "'+e+'" attribute. The value should be a string or a native gradient.'),t}}function z(){if(i.isUnminified)return function(t,e){return!0===t||!1===t||w.warn(I(t)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),t}}const Y="get",X="set",j={addGetterSetter(t,e,i,n,s){j.addGetter(t,e,i),j.addSetter(t,e,n,s),j.addOverloadedGetterSetter(t,e)},addGetter(t,e,i){const n=Y+w._capitalize(e);t.prototype[n]=t.prototype[n]||function(){const t=this.attrs[e];return void 0===t?i:t}},addSetter(t,e,i,n){const s=X+w._capitalize(e);t.prototype[s]||j.overWriteSetter(t,e,i,n)},overWriteSetter(t,e,i,n){const s=X+w._capitalize(e);t.prototype[s]=function(t){return i&&null!=t&&(t=i.call(this,t,e)),this._setAttr(e,t),n&&n.call(this),this}},addComponentsGetterSetter(t,e,n,s,r){const a=n.length,o=w._capitalize,h=Y+o(e),l=X+o(e);t.prototype[h]=function(){const t={};for(let i=0;i<a;i++){const s=n[i];t[s]=this.getAttr(e+o(s))}return t};const d=function(t){if(i.isUnminified)return function(e,i){return null==e||w.isObject(e)||w.warn(I(e)+' is a not valid value for "'+i+'" attribute. The value should be an object with properties '+t),e}}(n);t.prototype[l]=function(t){const i=this.attrs[e];s&&(t=s.call(this,t,e)),d&&d.call(this,t,e);for(const i in t)t.hasOwnProperty(i)&&this._setAttr(e+o(i),t[i]);return t||n.forEach(t=>{this._setAttr(e+o(t),void 0)}),this._fireChangeEvent(e,i,t),r&&r.call(this),this},j.addOverloadedGetterSetter(t,e)},addOverloadedGetterSetter(t,e){const i=w._capitalize(e),n=X+i,s=Y+i;t.prototype[e]=function(){return arguments.length?(this[n](arguments[0]),this):this[s]()}},addDeprecatedGetterSetter(t,e,i,n){w.error("Adding deprecated "+e);const s=Y+w._capitalize(e),r=e+" property is deprecated and will be removed soon. Look at Konva change log for more information.";t.prototype[s]=function(){w.error(r);const t=this.attrs[e];return void 0===t?i:t},j.addSetter(t,e,n,function(){w.error(r)}),j.addOverloadedGetterSetter(t,e)},backCompat(t,e){w.each(e,function(e,i){const n=t.prototype[i],s=Y+w._capitalize(e),r=X+w._capitalize(e);function a(){n.apply(this,arguments),w.error('"'+e+'" method is deprecated and will be removed soon. Use ""'+i+'" instead.')}t.prototype[e]=a,t.prototype[s]=a,t.prototype[r]=a})},afterSetFilter(){this._filterUpToDate=!1}};function q(t){const e=/(\w+)\(([^)]+)\)/g;let n;for(;null!==(n=e.exec(t));){const[,t,e]=n;switch(t){case"blur":{const t=parseFloat(e.replace("px",""));return function(e){this.blurRadius(.5*t);const n=i.Filters;n&&n.Blur&&n.Blur.call(this,e)}}case"brightness":{const t=e.includes("%")?parseFloat(e)/100:parseFloat(e);return function(e){this.brightness(t);const n=i.Filters;n&&n.Brightness&&n.Brightness.call(this,e)}}case"contrast":{const t=parseFloat(e);return function(e){const n=100*(Math.sqrt(t)-1);this.contrast(n);const s=i.Filters;s&&s.Contrast&&s.Contrast.call(this,e)}}case"grayscale":return function(t){const e=i.Filters;e&&e.Grayscale&&e.Grayscale.call(this,t)};case"sepia":return function(t){const e=i.Filters;e&&e.Sepia&&e.Sepia.call(this,t)};case"invert":return function(t){const e=i.Filters;e&&e.Invert&&e.Invert.call(this,t)};default:w.warn(`CSS filter "${t}" is not supported in fallback mode. Consider using function filters for better compatibility.`)}}return()=>{}}const U="absoluteOpacity",K="allEventListeners",V="absoluteTransform",$="absoluteScale",Q="canvas",J="listening",Z="Shape",tt=" ",et="stage",it="transform",nt="visible",st=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(tt);let rt=1;class at{constructor(t){this._id=rt++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(t),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(t){t!==it&&t!==V||!this._cache.get(t)?t?this._cache.delete(t):this._cache.clear():this._cache.get(t).dirty=!0}_getCache(t,e){let i=this._cache.get(t);return(void 0===i||(t===it||t===V)&&!0===i.dirty)&&(i=e.call(this),this._cache.set(t,i)),i}_calculate(t,e,i){if(!this._attachedDepsListeners.get(t)){const i=e.map(t=>t+"Change.konva").join(tt);this.on(i,()=>{this._clearCache(t)}),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,i)}_getCanvasCache(){return this._cache.get(Q)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===V&&this.fire("absoluteTransformChange")}static _runAfterAbsTransformCascade(t){at._absTransformCascadeDepth>0?at._pendingAfterCascade.push(t):t()}clearCache(){if(this._cache.has(Q)){const{scene:t,filter:e,hit:i}=this._cache.get(Q);w.releaseCanvas(t._canvas,e._canvas,...i?[i._canvas]:[]),this._cache.delete(Q)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(t){const e=t||{};let i={};void 0!==e.x&&void 0!==e.y&&void 0!==e.width&&void 0!==e.height||(i=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let n=Math.ceil(e.width||i.width),s=Math.ceil(e.height||i.height),r=e.pixelRatio,a=void 0===e.x?Math.floor(i.x):e.x,o=void 0===e.y?Math.floor(i.y):e.y,h=e.offset||0,l=e.drawBorder||!1,d=e.hitCanvasPixelRatio||1;if(!n||!s)return void w.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");n+=2*h+(Math.abs(Math.round(i.x)-a)>.5?1:0),s+=2*h+(Math.abs(Math.round(i.y)-o)>.5?1:0),a-=h,o-=h;const c=new E({pixelRatio:r,width:n,height:s}),g=new E({pixelRatio:r,width:0,height:0,willReadFrequently:!0}),u=c.getContext(),f=new E({width:c.width/c.pixelRatio+Math.abs(a),height:c.height/c.pixelRatio+Math.abs(o),pixelRatio:c.pixelRatio}),p=f.getContext();return c.isCache=!0,this._cache.delete(Q),this._filterUpToDate=!1,!1===e.imageSmoothingEnabled&&(c.getContext()._context.imageSmoothingEnabled=!1,g.getContext()._context.imageSmoothingEnabled=!1),u.save(),p.save(),u.translate(-a,-o),p.translate(-a,-o),f.x=a,f.y=o,this._isUnderCache=!0,this._clearSelfAndDescendantCache(U),this._clearSelfAndDescendantCache($),this.drawScene(c,this,f),this._isUnderCache=!1,u.restore(),l&&(u.save(),u.beginPath(),u.rect(0,0,n,s),u.closePath(),u.setAttr("strokeStyle","red"),u.setAttr("lineWidth",5),u.stroke(),u.restore()),w.releaseCanvas(f._canvas),this._cache.set(Q,{scene:c,filter:g,hit:null,hitConfig:{pixelRatio:d,width:n,height:s},x:a,y:o}),this._requestDraw(),this}_getCachedHitCanvas(t){if(t===this)return null;const e=this._getCanvasCache();if(!e)return null;if(e.hit)return e.hit;const i=new L(e.hitConfig);i.isCache=!0;const n=i.getContext();return n.save(),n.translate(-e.x,-e.y),this.drawHit(i,this),n.restore(),e.hit=i,i}isCached(){return this._cache.has(Q)}getClientRect(t){throw new Error('abstract "getClientRect" method call')}_transformedRect(t,e){const i=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}];let n=1/0,s=1/0,r=-1/0,a=-1/0;const o=this.getAbsoluteTransform(e);return i.forEach(function(t){const e=o.point(t);void 0===n&&(n=r=e.x,s=a=e.y),n=Math.min(n,e.x),s=Math.min(s,e.y),r=Math.max(r,e.x),a=Math.max(a,e.y)}),{x:n,y:s,width:r-n,height:a-s}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const e=this._getCanvasCache();t.translate(e.x,e.y);const i=this._getCachedSceneCanvas(),n=i.pixelRatio;t.drawImage(i._canvas,0,0,i.width/n,i.height/n),t.restore()}_drawCachedHitCanvas(t,e){const i=this._getCanvasCache();t.save(),t.translate(i.x,i.y),t.drawImage(e._canvas,0,0,e.width/e.pixelRatio,e.height/e.pixelRatio),t.restore()}_getCachedSceneCanvas(){let t,e,i,n,s=this.filters(),r=this._getCanvasCache(),a=r.scene,o=r.filter,h=o.getContext();if(!s||0===s.length)return a;if(this._filterUpToDate)return o;let l=!0;for(let t=0;t<s.length;t++)if("string"==typeof s[t]&&A(),"string"!=typeof s[t]||!A()){l=!1;break}const d=a.pixelRatio;if(o.setSize(a.width/a.pixelRatio,a.height/a.pixelRatio),l){const t=s.join(" ");return h.save(),h.setAttr("filter",t),h.drawImage(a._canvas,0,0,a.getWidth()/d,a.getHeight()/d),h.restore(),this._filterUpToDate=!0,o}try{for(t=s.length,h.clear(),h.drawImage(a._canvas,0,0,a.getWidth()/d,a.getHeight()/d),e=h.getImageData(0,0,o.getWidth(),o.getHeight()),i=0;i<t;i++)n=s[i],"string"==typeof n&&(n=q(n)),n.call(this,e),h.putImageData(e,0,0)}catch(t){w.error("Unable to apply filter. "+t.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}return this._filterUpToDate=!0,o}on(...t){const e=t[0],i=t[1];if(t[2],this._cache&&this._cache.delete(K),3===t.length)return this._delegate.apply(this,t);const n=e.split(tt);for(let t=0;t<n.length;t++){const e=n[t].split("."),s=e[0],r=e[1]||"";this.eventListeners[s]||(this.eventListeners[s]=[]),this.eventListeners[s].push({name:r,handler:i})}return this}off(t,e){let i,n,s,r,a,o,h=(t||"").split(tt),l=h.length;if(this._cache&&this._cache.delete(K),!t)for(n in this.eventListeners)this._off(n);for(i=0;i<l;i++)if(s=h[i],r=s.split("."),a=r[0],o=r[1],a)this.eventListeners[a]&&this._off(a,o,e);else for(n in this.eventListeners)this._off(n,o,e);return this}dispatchEvent(t){const e={target:this,type:t.type,evt:t};return this.fire(t.type,e),this}addEventListener(t,e){return this.on(t,function(t){e.call(this,t.evt)}),this}removeEventListener(t){return this.off(t),this}_delegate(t,e,i){const n=this;return this.on(t,function(t){const s=t.target.findAncestors(e,!0,n);for(let e=0;e<s.length;e++)(t=w.cloneObject(t)).currentTarget=s[e],i.call(s[e],t)}),this}remove(){return this.isDragging()&&this.stopDrag(),D._dragElements.delete(this._id),D._dragElements.forEach((t,e)=>{this.isAncestorOf(t.node)&&D._dragElements.delete(e)}),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(V),this._clearSelfAndDescendantCache(U),this._clearSelfAndDescendantCache($),this._clearSelfAndDescendantCache(et),this._clearSelfAndDescendantCache(nt),this._clearSelfAndDescendantCache(J)}_remove(){this._clearCaches();const t=this.getParent();t&&t.children&&(t.children.splice(this.index,1),t._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(t){const e="get"+w._capitalize(t);return w._isFunction(this[e])?this[e]():this.attrs[t]}getAncestors(){let t=this.getParent(),e=[];for(;t;)e.push(t),t=t.getParent();return e}getAttrs(){return this.attrs||{}}setAttrs(t){return this._batchTransformChanges(()=>{let e,i;if(!t)return this;for(e in t)"children"!==e&&(i="set"+w._capitalize(e),w._isFunction(this[i])?this[i](t[e]):this._setAttr(e,t[e]))}),this}isListening(){return this._getCache(J,this._isListening)}_isListening(t){if(!this.listening())return!1;const e=this.getParent();return!e||e===t||this===t||e._isListening(t)}isVisible(){return this._getCache(nt,this._isVisible)}_isVisible(t){if(!this.visible())return!1;const e=this.getParent();return!e||e===t||this===t||e._isVisible(t)}shouldDrawHit(t,e=!1){if(t)return this._isVisible(t)&&this._isListening(t);const n=this.getLayer();let s=!1;D._dragElements.forEach(t=>{"dragging"===t.dragStatus&&("Stage"===t.node.nodeType||t.node.getLayer()===n)&&(s=!0)});const r=!e&&!i.hitOnDragEnabled&&(s||i.isTransforming());return this.isListening()&&this.isVisible()&&!r}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let t,e,i,n,s=this.getDepth(),r=this,a=0;const o=this.getStage();return"Stage"!==r.nodeType&&o&&function o(h){for(t=[],e=h.length,i=0;i<e;i++)n=h[i],a++,n.nodeType!==Z&&(t=t.concat(n.getChildren().slice())),n._id===r._id&&(i=e);t.length>0&&t[0].getDepth()<=s&&o(t)}(o.getChildren()),a}getDepth(){let t=0,e=this.parent;for(;e;)t++,e=e.parent;return t}_batchTransformChanges(t){this._batchingTransformChange=!0,t(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(it),this._clearSelfAndDescendantCache(V)),this._needClearTransformCache=!1}setPosition(t){return this._batchTransformChanges(()=>{this.x(t.x),this.y(t.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){const t=this.getStage();if(!t)return null;const e=t.getPointerPosition();if(!e)return null;const i=this.getAbsoluteTransform().copy();return i.invert(),i.point(e)}getAbsolutePosition(t){let e=!1,i=this.parent;for(;i;){if(i.isCached()){e=!0;break}i=i.parent}e&&!t&&(t=!0);const n=this.getAbsoluteTransform(t).getMatrix(),s=new r,a=this.offset();return s.m=n.slice(),s.translate(a.x,a.y),s.getTranslation()}setAbsolutePosition(t){const{x:e,y:i,...n}=this._clearTransform();this.attrs.x=e,this.attrs.y=i,this._clearCache(it);const s=this._getAbsoluteTransform().copy();return s.invert(),s.translate(t.x,t.y),t={x:this.attrs.x+s.getTranslation().x,y:this.attrs.y+s.getTranslation().y},this._setTransform(n),this.setPosition({x:t.x,y:t.y}),this._clearCache(it),this._clearSelfAndDescendantCache(V),this}_setTransform(t){let e;for(e in t)this.attrs[e]=t[e]}_clearTransform(){const t={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,t}move(t){let e=t.x,i=t.y,n=this.x(),s=this.y();return void 0!==e&&(n+=e),void 0!==i&&(s+=i),this.setPosition({x:n,y:s}),this}_eachAncestorReverse(t,e){let i,n,s=[],r=this.getParent();if(!e||e._id!==this._id){for(s.unshift(this);r&&(!e||r._id!==e._id);)s.unshift(r),r=r.parent;for(i=s.length,n=0;n<i;n++)t(s[n])}}rotate(t){return this.rotation(this.rotation()+t),this}moveToTop(){if(!this.parent)return w.warn("Node has no parent. moveToTop function is ignored."),!1;const t=this.index;return t<this.parent.getChildren().length-1&&(this.parent.children.splice(t,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0)}moveUp(){if(!this.parent)return w.warn("Node has no parent. moveUp function is ignored."),!1;const t=this.index;return t<this.parent.getChildren().length-1&&(this.parent.children.splice(t,1),this.parent.children.splice(t+1,0,this),this.parent._setChildrenIndices(),!0)}moveDown(){if(!this.parent)return w.warn("Node has no parent. moveDown function is ignored."),!1;const t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.splice(t-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return w.warn("Node has no parent. moveToBottom function is ignored."),!1;const t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(t){if(!this.parent)return w.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&&w.warn("Unexpected value "+t+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");const e=this.index;return this.parent.children.splice(e,1),this.parent.children.splice(t,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(U,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let t=this.opacity();const e=this.getParent();return e&&!e._isUnderCache&&(t*=e.getAbsoluteOpacity()),t}moveTo(t){return this.getParent()!==t&&(this._remove(),t.add(this)),this}toObject(){let t,e,i,n,s,r=this.getAttrs();const a={attrs:{},className:this.getClassName()};for(t in r)e=r[t],s=w.isObject(e)&&!w._isPlainObject(e)&&!w._isArray(e),s||(i="function"==typeof this[t]&&this[t],delete r[t],n=i?i.call(this):null,r[t]=e,n!==e&&(a.attrs[t]=e));return w._prepareToStringify(a)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,e,i){const n=[];e&&this._isMatch(t)&&n.push(this);let s=this.parent;for(;s;){if(s===i)return n;s._isMatch(t)&&n.push(s),s=s.parent}return n}isAncestorOf(t){return!1}findAncestor(t,e,i){return this.findAncestors(t,e,i)[0]}_isMatch(t){if(!t)return!1;if("function"==typeof t)return t(this);let e,i,n=t.replace(/ /g,"").split(","),s=n.length;for(e=0;e<s;e++)if(i=n[e],w.isValidSelector(i)||(w.warn('Selector "'+i+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),w.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),w.warn("Konva is awesome, right?")),"#"===i.charAt(0)){if(this.id()===i.slice(1))return!0}else if("."===i.charAt(0)){if(this.hasName(i.slice(1)))return!0}else if(this.className===i||this.nodeType===i)return!0;return!1}getLayer(){const t=this.getParent();return t?t.getLayer():null}getStage(){return this._getCache(et,this._getStage)}_getStage(){const t=this.getParent();return t?t.getStage():null}fire(t,e={},i){return e.target=e.target||this,i?this._fireAndBubble(t,e):this._fire(t,e),this}getAbsoluteTransform(t){return t?this._getAbsoluteTransform(t):this._getCache(V,this._getAbsoluteTransform)}_getAbsoluteTransform(t){let e;if(t)return e=new r,this._eachAncestorReverse(function(t){const i=t.transformsEnabled();"all"===i?e.multiply(t.getTransform()):"position"===i&&e.translate(t.x()-t.offsetX(),t.y()-t.offsetY())},t),e;{e=this._cache.get(V)||new r,this.parent?this.parent.getAbsoluteTransform().copyInto(e):e.reset();const t=this.transformsEnabled();if("all"===t)e.multiply(this.getTransform());else if("position"===t){const t=this.attrs.x||0,i=this.attrs.y||0,n=this.attrs.offsetX||0,s=this.attrs.offsetY||0;e.translate(t-n,i-s)}return e.dirty=!1,e}}getAbsoluteScale(t){let e=this;for(;e;)e._isUnderCache&&(t=e),e=e.getParent();const i=this.getAbsoluteTransform(t).decompose();return{x:i.scaleX,y:i.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(it,this._getTransform)}_getTransform(){var t,e;const n=this._cache.get(it)||new r;n.reset();const s=this.x(),a=this.y(),o=i.getAngle(this.rotation()),h=null!==(t=this.attrs.scaleX)&&void 0!==t?t:1,l=null!==(e=this.attrs.scaleY)&&void 0!==e?e:1,d=this.attrs.skewX||0,c=this.attrs.skewY||0,g=this.attrs.offsetX||0,u=this.attrs.offsetY||0;return 0===s&&0===a||n.translate(s,a),0!==o&&n.rotate(o),0===d&&0===c||n.skew(d,c),1===h&&1===l||n.scale(h,l),0===g&&0===u||n.translate(-1*g,-1*u),n.dirty=!1,n}clone(t){let e,i,n,s,r,a=w.cloneObject(this.attrs);for(e in t)a[e]=t[e];const o=new this.constructor(a);for(e in this.eventListeners)for(i=this.eventListeners[e],n=i.length,s=0;s<n;s++)r=i[s],r.name.indexOf("konva")<0&&(o.eventListeners[e]||(o.eventListeners[e]=[]),o.eventListeners[e].push(r));return o}_toKonvaCanvas(t){t=t||{};const e=this.getClientRect(),i=this.getStage(),n=void 0!==t.x?t.x:Math.floor(e.x),s=void 0!==t.y?t.y:Math.floor(e.y),r=t.pixelRatio||1,a=new E({width:t.width||Math.ceil(e.width)||(i?i.width():0),height:t.height||Math.ceil(e.height)||(i?i.height():0),pixelRatio:r}),o=a.getContext(),h=new E({width:a.width/a.pixelRatio+Math.abs(n),height:a.height/a.pixelRatio+Math.abs(s),pixelRatio:a.pixelRatio});return!1===t.imageSmoothingEnabled&&(o._context.imageSmoothingEnabled=!1),o.save(),(n||s)&&o.translate(-1*n,-1*s),this.drawScene(a,void 0,h),o.restore(),a}toCanvas(t){return this._toKonvaCanvas(t)._canvas}toDataURL(t){const e=(t=t||{}).mimeType||null,i=t.quality||null,n=this._toKonvaCanvas(t).toDataURL(e,i);return t.callback&&t.callback(n),n}toImage(t){return new Promise((e,i)=>{try{const i=null==t?void 0:t.callback;i&&delete t.callback,w._urlToImage(this.toDataURL(t),function(t){e(t),null==i||i(t)})}catch(t){i(t)}})}toBlob(t){return new Promise((e,i)=>{try{const i=null==t?void 0:t.callback;i&&delete t.callback,this.toCanvas(t).toBlob(t=>{e(t),null==i||i(t)},null==t?void 0:t.mimeType,null==t?void 0:t.quality)}catch(t){i(t)}})}setSize(t){return this.width(t.width),this.height(t.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return void 0!==this.attrs.dragDistance?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():i.dragDistance}_off(t,e,i){let n,s,r,a=this.eventListeners[t];for(n=0;n<a.length;n++)if(s=a[n].name,r=a[n].handler,!("konva"===s&&"konva"!==e||e&&s!==e||i&&i!==r)){if(a.splice(n,1),0===a.length){delete this.eventListeners[t];break}n--}}_fireChangeEvent(t,e,i){this._fire(t+"Change",{oldVal:e,newVal:i})}addName(t){if(!this.hasName(t)){const e=this.name(),i=e?e+" "+t:t;this.name(i)}return this}hasName(t){if(!t)return!1;const e=this.name();if(!e)return!1;return-1!==(e||"").split(/\s/g).indexOf(t)}removeName(t){const e=(this.name()||"").split(/\s/g),i=e.indexOf(t);return-1!==i&&(e.splice(i,1),this.name(e.join(" "))),this}setAttr(t,e){const i=this["set"+w._capitalize(t)];return w._isFunction(i)?i.call(this,e):this._setAttr(t,e),this}_requestDraw(){if(i.autoDrawEnabled){const t=this.getLayer()||this.getStage();null==t||t.batchDraw()}}_setAttr(t,e){const i=this.attrs[t];(i!==e||w.isObject(e))&&(null==e?delete this.attrs[t]:this.attrs[t]=e,this._shouldFireChangeEvents&&this._fireChangeEvent(t,i,e),this._requestDraw())}_setComponentAttr(t,e,i){let n;void 0!==i&&(n=this.attrs[t],n||(this.attrs[t]=this.getAttr(t)),this.attrs[t][e]=i,this._fireChangeEvent(t,n,i))}_fireAndBubble(t,e,i){e&&this.nodeType===Z&&(e.target=this);const n=["mouseenter","mouseleave","pointerenter","pointerleave","touchenter","touchleave"];if(!(-1!==n.indexOf(t)&&(i&&(this===i||this.isAncestorOf&&this.isAncestorOf(i))||"Stage"===this.nodeType&&!i))){this._fire(t,e);const s=-1!==n.indexOf(t)&&i&&i.isAncestorOf&&i.isAncestorOf(this)&&!i.isAncestorOf(this.parent);(e&&!e.cancelBubble||!e)&&this.parent&&this.parent.isListening()&&!s&&(i&&i.parent?this._fireAndBubble.call(this.parent,t,e,i):this._fireAndBubble.call(this.parent,t,e))}}_getProtoListeners(t){var e,i;const{nodeType:n}=this,s=at.protoListenerMap.get(n)||{};let r=null==s?void 0:s[t];if(void 0===r){r=[];const a=new Set;let o=Object.getPrototypeOf(this);for(;o;){const n=null!==(i=null===(e=o.eventListeners)||void 0===e?void 0:e[t])&&void 0!==i?i:[];for(let t=0;t<n.length;t++){const e=n[t];a.has(e)||(a.add(e),r.push(e))}o=Object.getPrototypeOf(o)}s[t]=r,at.protoListenerMap.set(n,s)}return r}_fire(t,e){(e=e||{}).currentTarget=this,e.type=t;const i=this._getProtoListeners(t);if(i)for(let t=0;t<i.length;t++)i[t].handler.call(this,e);const n=this.eventListeners[t];if(n){const i=n.slice(),s=i.length;for(let t=0;t<i.length;t++)i[t].handler.call(this,e);const r=this.eventListeners[t];if(r)for(let t=s;t<r.length;t++)r[t].handler.call(this,e)}}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(t){const e=t?t.pointerId:void 0,i=this.getStage(),n=this.getAbsolutePosition();if(!i)return;const s=i._getPointerById(e)||i._changedPointerPositions[0]||n;D._dragElements.set(this._id,{node:this,startPointerPos:s,offset:{x:s.x-n.x,y:s.y-n.y},dragStatus:"ready",pointerId:e,startEvent:t})}startDrag(t,e=!0){D._dragElements.has(this._id)||this._createDragElement(t);const i=D._dragElements.get(this._id);i.dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:i.startEvent&&i.startEvent.evt||t&&t.evt},e)}_setDragPosition(t,e){const i=this.getStage()._getPointerById(e.pointerId);if(!i)return;let n={x:i.x-e.offset.x,y:i.y-e.offset.y};const s=this.dragBoundFunc();if(void 0!==s){const e=s.call(this,n,t);e?n=e:w.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}this._lastPos&&this._lastPos.x===n.x&&this._lastPos.y===n.y||(this.setAbsolutePosition(n),this._requestDraw()),this._lastPos=n}stopDrag(t){const e=D._dragElements.get(this._id);e&&(e.dragStatus="stopped"),D._endDragBefore(t),D._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=D._dragElements.get(this._id);return!!t&&"dragging"===t.dragStatus}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",function(t){if(!(!(void 0!==t.evt.button)||i.dragButtons.indexOf(t.evt.button)>=0))return;if(this.isDragging())return;let e=!1;D._dragElements.forEach(t=>{this.isAncestorOf(t.node)&&(e=!0)}),e||this._createDragElement(t)})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{this._dragCleanup();if(!this.getStage())return;const t=D._dragElements.get(this._id),e=t&&"dragging"===t.dragStatus,i=t&&"ready"===t.dragStatus;e?this.stopDrag():i&&D._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(t={x:0,y:0}){const e=this.getStage();if(!e)return!1;const i={x:-t.x,y:-t.y,width:e.width()+2*t.x,height:e.height()+2*t.y};return w.haveIntersection(i,this.getClientRect())}static create(t,e){return w._isString(t)&&(t=JSON.parse(t)),this._createNode(t,e)}static _createNode(t,e){let n,s,r,a=at.prototype.getClassName.call(t),o=t.children;e&&(t.attrs.container=e),i[a]||(w.warn('Can not find a node with class name "'+a+'". Fallback to "Shape".'),a="Shape");if(n=new(0,i[a])(t.attrs),o)for(s=o.length,r=0;r<s;r++)n.add(at._createNode(o[r]));return n}}at._absTransformCascadeDepth=0,at._pendingAfterCascade=[],at.protoListenerMap=new Map,at.prototype.nodeType="Node",at.prototype._attrsAffectingSize=[],at.prototype.eventListeners={},at.prototype.on(st,function(){this._batchingTransformChange?this._needClearTransformCache=!0:(this._clearCache(it),this._clearSelfAndDescendantCache(V))}),at.prototype.on("visibleChange.konva",function(){this._clearSelfAndDescendantCache(nt)}),at.prototype.on("listeningChange.konva",function(){this._clearSelfAndDescendantCache(J)}),at.prototype.on("opacityChange.konva",function(){this._clearSelfAndDescendantCache(U)});const ot=j.addGetterSetter;ot(at,"zIndex"),ot(at,"absolutePosition"),ot(at,"position"),ot(at,"x",0,F()),ot(at,"y",0,F()),ot(at,"globalCompositeOperation","source-over",H()),ot(at,"opacity",1,F()),ot(at,"name","",H()),ot(at,"id","",H()),ot(at,"rotation",0,F()),j.addComponentsGetterSetter(at,"scale",["x","y"]),ot(at,"scaleX",1,F()),ot(at,"scaleY",1,F()),j.addComponentsGetterSetter(at,"skew",["x","y"]),ot(at,"skewX",0,F()),ot(at,"skewY",0,F()),j.addComponentsGetterSetter(at,"offset",["x","y"]),ot(at,"offsetX",0,F()),ot(at,"offsetY",0,F()),ot(at,"dragDistance",void 0,F()),ot(at,"width",0,F()),ot(at,"height",0,F()),ot(at,"listening",!0,z()),ot(at,"preventDefault",!0,z()),ot(at,"filters",void 0,function(t){return this._filterUpToDate=!1,t}),ot(at,"visible",!0,z()),ot(at,"transformsEnabled","all",H()),ot(at,"size"),ot(at,"dragBoundFunc"),ot(at,"draggable",!1,z()),j.backCompat(at,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});class ht extends at{constructor(){super(...arguments),this.children=[]}getChildren(t){const e=this.children||[];return t?e.filter(t):e}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach(t=>{t.parent=null,t.index=0,t.remove()}),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach(t=>{t.parent=null,t.index=0,t.destroy()}),this.children=[],this._requestDraw(),this}add(...t){if(0===t.length)return this;if(t.length>1){for(let e=0;e<t.length;e++)this.add(t[e]);return this}const e=t[0];return e.getParent()?(e.moveTo(this),this):(this._validateAdd(e),e.index=this.getChildren().length,e.parent=this,e._clearCaches(),this.getChildren().push(e),this._fire("add",{child:e}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(t){return this._generalFind(t,!1)}findOne(t){const e=this._generalFind(t,!0);return e.length>0?e[0]:void 0}_generalFind(t,e){const i=[];return this._descendants(n=>{const s=n._isMatch(t);return s&&i.push(n),!(!s||!e)}),i}_descendants(t){let e=!1;const i=this.getChildren();for(const n of i){if(e=t(n),e)return!0;if(n.hasChildren()&&(e=n._descendants(t),e))return!0}return!1}toObject(){const t=at.prototype.toObject.call(this);return t.children=[],this.getChildren().forEach(e=>{t.children.push(e.toObject())}),t}isAncestorOf(t){let e=t.getParent();for(;e;){if(e._id===this._id)return!0;e=e.getParent()}return!1}clone(t){const e=at.prototype.clone.call(this,t);return this.getChildren().forEach(function(t){e.add(t.clone())}),e}getAllIntersections(t){const e=[];return this.find("Shape").forEach(i=>{i.isVisible()&&i.intersects(t)&&e.push(i)}),e}_clearSelfAndDescendantCache(t){var e;const i="absoluteTransform"===t;i&&at._absTransformCascadeDepth++;try{if(super._clearSelfAndDescendantCache(t),this.isCached())return;null===(e=this.children)||void 0===e||e.forEach(function(e){e._clearSelfAndDescendantCache(t)})}finally{if(i&&0===--at._absTransformCascadeDepth){const t=at._pendingAfterCascade;if(t.length){at._pendingAfterCascade=[];for(let e=0;e<t.length;e++)t[e]()}}}}_setChildrenIndices(){var t;null===(t=this.children)||void 0===t||t.forEach(function(t,e){t.index=e}),this._requestDraw()}drawScene(t,e,i){const n=this.getLayer(),s=t||n&&n.getCanvas(),r=s&&s.getContext(),a=this._getCanvasCache(),o=a&&a.scene,h=s&&s.isCache;if(!this.isVisible()&&!h)return this;if(o){r.save();const t=this.getAbsoluteTransform(e).getMatrix();r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(r),r.restore()}else this._drawChildren("drawScene",s,e,i);return this}drawHit(t,e){if(!this.shouldDrawHit(e))return this;const i=this.getLayer(),n=t||i&&i.hitCanvas,s=n&&n.getContext(),r=this._getCachedHitCanvas(e);if(r){s.save();const t=this.getAbsoluteTransform(e).getMatrix();s.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(s,r),s.restore()}else this._drawChildren("drawHit",n,e);return this}_drawChildren(t,e,i,n){var s;const r=e&&e.getContext(),a=this.clipWidth(),o=this.clipHeight(),h=this.clipFunc(),l="number"==typeof a&&"number"==typeof o||h,d=i===this;if(l){r.save();const t=this.getAbsoluteTransform(i);let e,n=t.getMatrix();if(r.transform(n[0],n[1],n[2],n[3],n[4],n[5]),r.beginPath(),h)e=h.call(this,r,this);else{const t=this.clipX(),e=this.clipY();r.rect(t||0,e||0,a,o)}r.clip.apply(r,e),n=t.copy().invert().getMatrix(),r.transform(n[0],n[1],n[2],n[3],n[4],n[5])}const c=!d&&"source-over"!==this.globalCompositeOperation()&&"drawScene"===t;c&&(r.save(),r._applyGlobalCompositeOperation(this)),null===(s=this.children)||void 0===s||s.forEach(function(s){s[t](e,i,n)}),c&&r.restore(),l&&r.restore()}getClientRect(t={}){var e;const i=t.skipTransform,n=t.relativeTo;let s,r,a,o,h={x:1/0,y:1/0,width:0,height:0};const l=this;null===(e=this.children)||void 0===e||e.forEach(function(e){if(!e.visible())return;const i=e.getClientRect({relativeTo:l,skipShadow:t.skipShadow,skipStroke:t.skipStroke});0===i.width&&0===i.height||(void 0===s?(s=i.x,r=i.y,a=i.x+i.width,o=i.y+i.height):(s=Math.min(s,i.x),r=Math.min(r,i.y),a=Math.max(a,i.x+i.width),o=Math.max(o,i.y+i.height)))});const d=this.find("Shape");let c=!1;for(let t=0;t<d.length;t++){if(d[t]._isVisible(this)){c=!0;break}}return h=c&&void 0!==s?{x:s,y:r,width:a-s,height:o-r}:{x:0,y:0,width:0,height:0},i?h:this._transformedRect(h,n)}}j.addComponentsGetterSetter(ht,"clip",["x","y","width","height"]),j.addGetterSetter(ht,"clipX",void 0,F()),j.addGetterSetter(ht,"clipY",void 0,F()),j.addGetterSetter(ht,"clipWidth",void 0,F()),j.addGetterSetter(ht,"clipHeight",void 0,F()),j.addGetterSetter(ht,"clipFunc");const lt=new Map,dt=void 0!==i._global.PointerEvent;function ct(t){return lt.get(t)}function gt(t){return{evt:t,pointerId:t.pointerId}}function ut(t,e){return lt.get(t)===e}function ft(t,e){var i;pt(t);const n=e.getStage();if(n&&(lt.set(t,e),dt)){try{null===(i=n.content)||void 0===i||i.setPointerCapture(t)}catch(t){}e._fire("gotpointercapture",gt(new PointerEvent("gotpointercapture")))}}function pt(t,e){var i;const n=lt.get(t);if(!n)return;const s=n.getStage();if(lt.delete(t),dt){try{null===(i=null==s?void 0:s.content)||void 0===i||i.releasePointerCapture(t)}catch(t){}n._fire("lostpointercapture",gt(new PointerEvent("lostpointercapture")))}}const mt="mouseleave",_t="mouseover",yt="mouseenter",vt="mousemove",xt="mousedown",bt="mouseup",St="pointermove",wt="pointerdown",Ct="pointerup",kt="pointercancel",Pt="pointerout",At="pointerleave",Tt="pointerover",Mt="pointerenter",Rt="contextmenu",Gt="touchstart",Et="touchend",Lt="touchmove",Dt="touchcancel",It="wheel",Ot=[[yt,"_pointerenter"],[xt,"_pointerdown"],[vt,"_pointermove"],[bt,"_pointerup"],[mt,"_pointerleave"],[Gt,"_pointerdown"],[Lt,"_pointermove"],[Et,"_pointerup"],[Dt,"_pointercancel"],[_t,"_pointerover"],[It,"_wheel"],[Rt,"_contextmenu"],[wt,"_pointerdown"],[St,"_pointermove"],[Ct,"_pointerup"],[kt,"_pointercancel"],[At,"_pointerleave"],["lostpointercapture","_lostpointercapture"]],Ft={mouse:{[Pt]:"mouseout",[At]:mt,[Tt]:_t,[Mt]:yt,[St]:vt,[wt]:xt,[Ct]:bt,[kt]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[Pt]:"touchout",[At]:"touchleave",[Tt]:"touchover",[Mt]:"touchenter",[St]:Lt,[wt]:Gt,[Ct]:Et,[kt]:Dt,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[Pt]:Pt,[At]:At,[Tt]:Tt,[Mt]:Mt,[St]:St,[wt]:wt,[Ct]:Ct,[kt]:kt,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},Bt=t=>t.indexOf("pointer")>=0?"pointer":t.indexOf("touch")>=0?"touch":"mouse",Nt=t=>{const e=Bt(t);return"pointer"===e?i.pointerEventsEnabled&&Ft.pointer:"touch"===e?Ft.touch:"mouse"===e?Ft.mouse:void 0};function Ht(t={}){return(t.clipFunc||t.clipWidth||t.clipHeight)&&w.warn("Stage does not support clipping. Please use clip for Layers or Groups."),t}const Wt=[],zt=new WeakSet,Yt=t=>{t&&!zt.has(t)&&(zt.add(t),D._listenToWindow(t),t.document.addEventListener("visibilitychange",()=>{Wt.forEach(t=>{t.batchDraw()})}))};class Xt extends ht{constructor(t){super(Ht(t)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),Wt.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{Ht(this.attrs)}),this._checkVisibility()}_validateAdd(t){const e="Layer"===t.getType(),i="FastLayer"===t.getType();e||i||w.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const t=this.visible()?"":"none";this.content.style.display=t}_getOwnerWindow(){var t;const e=this.content||this.container();return(null===(t=null==e?void 0:e.ownerDocument)||void 0===t?void 0:t.defaultView)||(i.isBrowser?window:null)}setContainer(t){if("string"==typeof t){let e;if("."===t.charAt(0)){const e=t.slice(1);t=document.getElementsByClassName(e)[0]}else e="#"!==t.charAt(0)?t:t.slice(1),t=document.getElementById(e);if(!t)throw"Can not find container in document with id "+e}return this._setAttr("container",t),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),t.appendChild(this.content),Yt(this._getOwnerWindow())),this}shouldDrawHit(){return!0}clear(){const t=this.children,e=t.length;for(let i=0;i<e;i++)t[i].clear();return this}clone(t){return t||(t={}),t.container="undefined"!=typeof document&&document.createElement("div"),ht.prototype.clone.call(this,t)}destroy(){super.destroy();const t=this.content;t&&w._isInDocument(t)&&this.container().removeChild(t);const e=Wt.indexOf(this);return e>-1&&Wt.splice(e,1),w.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const t=this._pointerPositions[0]||this._changedPointerPositions[0];return t?{x:t.x,y:t.y}:(w.warn("Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);"),null)}_getPointerById(t){return this._pointerPositions.find(e=>e.id===t)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(t){(t={...t}).x=t.x||0,t.y=t.y||0,t.width=t.width||this.width(),t.height=t.height||this.height();const e=new E({width:t.width,height:t.height,pixelRatio:t.pixelRatio||1}),i=e.getContext()._context,n=this.children;return(t.x||t.y)&&i.translate(-1*t.x,-1*t.y),n.forEach(function(e){if(!e.isVisible())return;const n=e._toKonvaCanvas(t);i.drawImage(n._canvas,t.x,t.y,n.getWidth()/n.getPixelRatio(),n.getHeight()/n.getPixelRatio())}),e}getIntersection(t){if(!t)return null;const e=this.children;for(let i=e.length-1;i>=0;i--){const n=e[i].getIntersection(t);if(n)return n}return null}_resizeDOM(){const t=this.width(),e=this.height();this.content&&(this.content.style.width=t+"px",this.content.style.height=e+"px"),this.children.forEach(i=>{i.setSize({width:t,height:e}),i.draw()})}_syncBufferSize(t){return t.setSizeIfChanged(this.width(),this.height()),t}add(t,...e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}super.add(t);const n=this.children.length;return n>5&&w.warn("The stage has "+n+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),t.setSize({width:this.width(),height:this.height()}),t.draw(),i.isBrowser&&this.content.appendChild(t.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(t){return ut(t,this)}setPointerCapture(t){ft(t,this)}releaseCapture(t){pt(t)}getLayers(){return this.children}_bindContentEvents(){i.isBrowser&&Ot.forEach(([t,e])=>{this.content.addEventListener(t,t=>{this[e](t)},{passive:!1})})}_pointerenter(t){this.setPointersPositions(t);const e=Nt(t.type);e&&this._fire(e.pointerenter,{evt:t,target:this,currentTarget:this})}_pointerover(t){this.setPointersPositions(t);const e=Nt(t.type);e&&this._fire(e.pointerover,{evt:t,target:this,currentTarget:this})}_getTargetShape(t){let e=this[t+"targetShape"];return e&&!e.getStage()&&(e=null),e}_pointerleave(t){const e=Nt(t.type),n=Bt(t.type);if(!e)return;this.setPointersPositions(t);const s=this._getTargetShape(n),r=!(i.isDragging()||i.isTransforming())||i.hitOnDragEnabled;s&&r?(s._fireAndBubble(e.pointerout,{evt:t}),s._fireAndBubble(e.pointerleave,{evt:t}),this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this[n+"targetShape"]=null):r&&(this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this._fire(e.pointerout,{evt:t,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}_pointerdown(t){const e=Nt(t.type),n=Bt(t.type);if(!e)return;this.setPointersPositions(t);let s=!1;this._changedPointerPositions.forEach(r=>{const a=this.getIntersection(r);if(D.justDragged=!1,i["_"+n+"ListenClick"]=!0,!a||!a.isListening())return void(this[n+"ClickStartShape"]=void 0);i.capturePointerEventsEnabled&&a.setPointerCapture(r.id),this[n+"ClickStartShape"]=a,a._fireAndBubble(e.pointerdown,{evt:t,pointerId:r.id}),s=!0;const o=t.type.indexOf("touch")>=0;a.preventDefault()&&t.cancelable&&o&&t.preventDefault()}),s||this._fire(e.pointerdown,{evt:t,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(t){const e=Nt(t.type),n=Bt(t.type);if(!e)return;const s=t.type.indexOf("touch")>=0||"touch"===t.pointerType;i.isDragging()&&D.node.preventDefault()&&t.cancelable&&s&&t.preventDefault(),this.setPointersPositions(t);if(!(!(i.isDragging()||i.isTransforming())||i.hitOnDragEnabled))return;const r={};let a=!1;const o=this._getTargetShape(n);this._changedPointerPositions.forEach(i=>{const s=ct(i.id)||this.getIntersection(i),h=i.id,l={evt:t,pointerId:h},d=o!==s;if(d&&o&&(o._fireAndBubble(e.pointerout,{...l},s),o._fireAndBubble(e.pointerleave,{...l},s)),s){if(r[s._id])return;r[s._id]=!0}s&&s.isListening()?(a=!0,d&&(s._fireAndBubble(e.pointerover,{...l},o),s._fireAndBubble(e.pointerenter,{...l},o),this[n+"targetShape"]=s),s._fireAndBubble(e.pointermove,{...l})):o&&(this._fire(e.pointerover,{evt:t,target:this,currentTarget:this,pointerId:h}),this[n+"targetShape"]=null)}),a||this._fire(e.pointermove,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(t){const e=Nt(t.type),n=Bt(t.type);if(!e)return;this.setPointersPositions(t);const s=D.justDragged||"pointer"===n&&i.isDragging(),r=i["_"+n+"ListenClick"]&&!s,a=this[n+"ClickStartShape"],o=this[n+"ClickEndShape"],h={};let l=!1;this._changedPointerPositions.forEach(d=>{const c=ct(d.id)||this.getIntersection(d);if(c){if(c.releaseCapture(d.id),h[c._id])return;h[c._id]=!0}const g=d.id,u={evt:t,pointerId:g};let f=!1;i["_"+n+"InDblClickWindow"]?(f=!0,clearTimeout(this[n+"DblTimeout"])):s||(i["_"+n+"InDblClickWindow"]=!0,clearTimeout(this[n+"DblTimeout"])),this[n+"DblTimeout"]=setTimeout(function(){i["_"+n+"InDblClickWindow"]=!1},i.dblClickWindow),c&&c.isListening()?(l=!0,this[n+"ClickEndShape"]=c,c._fireAndBubble(e.pointerup,{...u}),r&&a===c&&(c._fireAndBubble(e.pointerclick,{...u}),f&&o&&o===c&&c._fireAndBubble(e.pointerdblclick,{...u}))):(this[n+"ClickEndShape"]=null,l||(this._fire(e.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),l=!0),r&&this._fire(e.pointerclick,{evt:t,target:this,currentTarget:this,pointerId:g}),f&&this._fire(e.pointerdblclick,{evt:t,target:this,currentTarget:this,pointerId:g}))}),l||this._fire(e.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),i["_"+n+"ListenClick"]=!1,t.cancelable&&"touch"!==n&&"pointer"!==n&&t.preventDefault()}_contextmenu(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(Rt,{evt:t}):this._fire(Rt,{evt:t,target:this,currentTarget:this})}_wheel(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(It,{evt:t}):this._fire(It,{evt:t,target:this,currentTarget:this})}_pointercancel(t){this.setPointersPositions(t);const e=ct(t.pointerId)||this.getIntersection(this.getPointerPosition());e&&e._fireAndBubble(Ct,gt(t)),pt(t.pointerId)}_lostpointercapture(t){pt(t.pointerId)}setPointersPositions(t){const e=this._getContentPosition();let i=null,n=null;void 0!==(t=t||window.event).touches?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(t.touches,t=>{this._pointerPositions.push({id:t.identifier,x:(t.clientX-e.left)/e.scaleX,y:(t.clientY-e.top)/e.scaleY})}),Array.prototype.forEach.call(t.changedTouches||t.touches,t=>{this._changedPointerPositions.push({id:t.identifier,x:(t.clientX-e.left)/e.scaleX,y:(t.clientY-e.top)/e.scaleY})})):(i=(t.clientX-e.left)/e.scaleX,n=(t.clientY-e.top)/e.scaleY,this.pointerPos={x:i,y:n},this._pointerPositions=[{x:i,y:n,id:w._getFirstPointerId(t)}],this._changedPointerPositions=[{x:i,y:n,id:w._getFirstPointerId(t)}])}_setPointerPosition(t){w.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(t)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};const t=this.content.getBoundingClientRect();return{top:t.top,left:t.left,scaleX:t.width/this.content.clientWidth||1,scaleY:t.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new E({width:0,height:0}),this.bufferHitCanvas=new L({pixelRatio:1,width:0,height:0}),!i.isBrowser)return;const t=this.container();if(!t)throw"Stage has no container. A container is required.";t.innerHTML="",this.content=t.ownerDocument.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),t.appendChild(this.content),Yt(this._getOwnerWindow()),this._resizeDOM()}cache(){return w.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach(function(t){t.batchDraw()}),this}}Xt.prototype.nodeType="Stage",n(Xt),j.addGetterSetter(Xt,"container");const jt="hasShadow",qt="shadowRGBA",Ut="patternImage",Kt="linearGradient",Vt="radialGradient";let $t;function Qt(){return $t||($t=w.createCanvasElement().getContext("2d"),$t)}const Jt={};class Zt extends at{constructor(t){let e;super(t);let i=0;for(;e=w.getHitColor(),!e||e in Jt;)if(i++,i>=1e4){w.warn("Failed to find a unique color key for a shape. Konva may work incorrectly. Most likely your browser is using canvas farbling. Consider disabling it."),e=w.getRandomColor();break}this.colorKey=e,Jt[e]=this}getContext(){return w.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return w.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(jt,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&0!==this.shadowOpacity()&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(Ut,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const t=Qt().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){const e=new r;e.translate(this.fillPatternX(),this.fillPatternY()),e.rotate(i.getAngle(this.fillPatternRotation())),e.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),e.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const n=e.getMatrix(),s="undefined"==typeof DOMMatrix?{a:n[0],b:n[1],c:n[2],d:n[3],e:n[4],f:n[5]}:new DOMMatrix(n);t.setTransform(s)}return t}}_getLinearGradient(){return this._getCache(Kt,this.__getLinearGradient)}__getLinearGradient(){const t=this.fillLinearGradientColorStops();if(t){const e=Qt(),i=this.fillLinearGradientStartPoint(),n=this.fillLinearGradientEndPoint(),s=e.createLinearGradient(i.x,i.y,n.x,n.y);for(let e=0;e<t.length;e+=2)s.addColorStop(t[e],t[e+1]);return s}}_getRadialGradient(){return this._getCache(Vt,this.__getRadialGradient)}__getRadialGradient(){const t=this.fillRadialGradientColorStops();if(t){const e=Qt(),i=this.fillRadialGradientStartPoint(),n=this.fillRadialGradientEndPoint(),s=e.createRadialGradient(i.x,i.y,this.fillRadialGradientStartRadius(),n.x,n.y,this.fillRadialGradientEndRadius());for(let e=0;e<t.length;e+=2)s.addColorStop(t[e],t[e+1]);return s}}getShadowRGBA(){return this._getCache(qt,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;const t=w.colorToRGBA(this.shadowColor());return t?"rgba("+t.r+","+t.g+","+t.b+","+t.a*(this.shadowOpacity()||1)+")":void 0}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops()))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],()=>this.strokeEnabled()&&this.strokeWidth()&&!(!this.stroke()&&!this.strokeLinearGradientColorStops()))}hasHitStroke(){const t=this.hitStrokeWidth();return"auto"===t?this.hasStroke():this.strokeEnabled()&&!!t}intersects(t){const e=this.getStage();if(!e)return!1;const i=e._syncBufferSize(e.bufferHitCanvas);i.getContext().clear(),this.drawHit(i,void 0,!0);return i.context.getImageData(Math.round(t.x),Math.round(t.y),1,1).data[3]>0}destroy(){return at.prototype.destroy.call(this),delete Jt[this.colorKey],delete this.colorKey,this}_useBufferCanvas(t){var e;if(!(null===(e=this.attrs.perfectDrawEnabled)||void 0===e||e))return!1;const i=t||this.hasFill(),n=this.hasStroke(),s=1!==this.getAbsoluteOpacity();if(i&&n&&s)return!0;const r=this.hasShadow(),a=this.shadowForStrokeEnabled();return!!(i&&n&&r&&a)}setStrokeHitEnabled(t){w.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),t?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return 0!==this.hitStrokeWidth()}getSelfRect(){const t=this.size();return{x:this._centroid?-t.width/2:0,y:this._centroid?-t.height/2:0,width:t.width,height:t.height}}getClientRect(t={}){let e=!1,i=this.getParent();for(;i;){if(i.isCached()){e=!0;break}i=i.getParent()}const n=t.skipTransform,s=t.relativeTo||e&&this.getStage()||void 0,r=this.getSelfRect(),a=!t.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,o=r.width+a,h=r.height+a,l=!t.skipShadow&&this.hasShadow(),d=l?this.shadowOffsetX():0,c=l?this.shadowOffsetY():0,g=o+Math.abs(d),u=h+Math.abs(c),f=l&&this.shadowBlur()||0,p={width:g+2*f,height:u+2*f,x:-(a/2+f)+Math.min(d,0)+r.x,y:-(a/2+f)+Math.min(c,0)+r.y};return n?p:this._transformedRect(p,s)}drawScene(t,e,i){const n=this.getLayer(),s=(t||n.getCanvas()).getContext(),r=this._getCanvasCache(),a=this.getSceneFunc(),o=this.hasShadow();let h;const l=e===this;if(!this.isVisible()&&!l)return this;if(r){s.save();const t=this.getAbsoluteTransform(e).getMatrix();return s.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(s),s.restore(),this}if(!a)return this;if(s.save(),this._useBufferCanvas()){h=this.getStage();const t=i||h._syncBufferSize(h.bufferCanvas),n=t.getContext();i?(n.save(),n.setTransform(1,0,0,1,0,0),n.clearRect(0,0,t.width,t.height),n.restore()):n.clear(),n.save(),n.imageSmoothingEnabled=s.imageSmoothingEnabled,n._applyLineJoin(this),n._applyMiterLimit(this);const r=this.getAbsoluteTransform(e).getMatrix();n.transform(r[0],r[1],r[2],r[3],r[4],r[5]),a.call(this,n,this),n.restore();const d=t.pixelRatio;o&&s._applyShadow(this),l||(s._applyOpacity(this),s._applyGlobalCompositeOperation(this)),s.drawImage(t._canvas,t.x||0,t.y||0,t.width/d,t.height/d)}else{if(s._applyLineJoin(this),s._applyMiterLimit(this),!l){const t=this.getAbsoluteTransform(e).getMatrix();s.transform(t[0],t[1],t[2],t[3],t[4],t[5]),s._applyOpacity(this),s._applyGlobalCompositeOperation(this)}o&&s._applyShadow(this),a.call(this,s,this)}return s.restore(),this}drawHit(t,e,i=!1){if(!this.shouldDrawHit(e,i))return this;const n=this.getLayer(),s=t||n.hitCanvas,r=s&&s.getContext(),a=this.hitFunc()||this.sceneFunc(),o=this._getCachedHitCanvas(e);if(this.colorKey||w.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),o){r.save();const t=this.getAbsoluteTransform(e).getMatrix();return r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(r,o),r.restore(),this}if(!a)return this;r.save(),r._applyLineJoin(this),r._applyMiterLimit(this);if(!(this===e)){const t=this.getAbsoluteTransform(e).getMatrix();r.transform(t[0],t[1],t[2],t[3],t[4],t[5])}return a.call(this,r,this),r.restore(),this}drawHitFromCache(t=0){const e=this._getCachedSceneCanvas(),i=this._getCachedHitCanvas(),n=i.getContext(),s=i.getWidth(),r=i.getHeight();n.clear(),n.drawImage(e._canvas,0,0,s,r);try{const e=n.getImageData(0,0,s,r),i=e.data,a=i.length,o=w._hexToRgb(this.colorKey);for(let e=0;e<a;e+=4){i[e+3]>t?(i[e]=o.r,i[e+1]=o.g,i[e+2]=o.b,i[e+3]=255):i[e+3]=0}n.putImageData(e,0,0)}catch(t){w.error("Unable to draw hit graph from cached scene canvas. "+t.message)}return this}hasPointerCapture(t){return ut(t,this)}setPointerCapture(t){ft(t,this)}releaseCapture(t){pt(t)}}Zt.prototype._fillFunc=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},Zt.prototype._strokeFunc=function(t){t.stroke()},Zt.prototype._fillFuncHit=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},Zt.prototype._strokeFuncHit=function(t){t.stroke()},Zt.prototype._centroid=!1,Zt.prototype.nodeType="Shape",n(Zt),Zt.prototype.eventListeners={},Zt.prototype.on("shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",function(){this._clearCache(jt)}),Zt.prototype.on("shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",function(){this._clearCache(qt)}),Zt.prototype.on("fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",function(){this._clearCache(Ut)}),Zt.prototype.on("fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",function(){this._clearCache(Kt)}),Zt.prototype.on("fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",function(){this._clearCache(Vt)}),j.addGetterSetter(Zt,"stroke",void 0,W()),j.addGetterSetter(Zt,"strokeWidth",2,F()),j.addGetterSetter(Zt,"fillAfterStrokeEnabled",!1),j.addGetterSetter(Zt,"hitStrokeWidth","auto",N()),j.addGetterSetter(Zt,"strokeHitEnabled",!0,z()),j.addGetterSetter(Zt,"perfectDrawEnabled",!0,z()),j.addGetterSetter(Zt,"shadowForStrokeEnabled",!0,z()),j.addGetterSetter(Zt,"lineJoin"),j.addGetterSetter(Zt,"lineCap"),j.addGetterSetter(Zt,"miterLimit"),j.addGetterSetter(Zt,"sceneFunc"),j.addGetterSetter(Zt,"hitFunc"),j.addGetterSetter(Zt,"dash"),j.addGetterSetter(Zt,"dashOffset",0,F()),j.addGetterSetter(Zt,"shadowColor",void 0,H()),j.addGetterSetter(Zt,"shadowBlur",0,F()),j.addGetterSetter(Zt,"shadowOpacity",1,F()),j.addComponentsGetterSetter(Zt,"shadowOffset",["x","y"]),j.addGetterSetter(Zt,"shadowOffsetX",0,F()),j.addGetterSetter(Zt,"shadowOffsetY",0,F()),j.addGetterSetter(Zt,"fillPatternImage"),j.addGetterSetter(Zt,"fill",void 0,W()),j.addGetterSetter(Zt,"fillPatternX",0,F()),j.addGetterSetter(Zt,"fillPatternY",0,F()),j.addGetterSetter(Zt,"fillLinearGradientColorStops"),j.addGetterSetter(Zt,"strokeLinearGradientColorStops"),j.addGetterSetter(Zt,"fillRadialGradientStartRadius",0),j.addGetterSetter(Zt,"fillRadialGradientEndRadius",0),j.addGetterSetter(Zt,"fillRadialGradientColorStops"),j.addGetterSetter(Zt,"fillPatternRepeat","repeat"),j.addGetterSetter(Zt,"fillEnabled",!0),j.addGetterSetter(Zt,"strokeEnabled",!0),j.addGetterSetter(Zt,"shadowEnabled",!0),j.addGetterSetter(Zt,"dashEnabled",!0),j.addGetterSetter(Zt,"strokeScaleEnabled",!0),j.addGetterSetter(Zt,"fillPriority","color"),j.addComponentsGetterSetter(Zt,"fillPatternOffset",["x","y"]),j.addGetterSetter(Zt,"fillPatternOffsetX",0,F()),j.addGetterSetter(Zt,"fillPatternOffsetY",0,F()),j.addComponentsGetterSetter(Zt,"fillPatternScale",["x","y"]),j.addGetterSetter(Zt,"fillPatternScaleX",1,F()),j.addGetterSetter(Zt,"fillPatternScaleY",1,F()),j.addComponentsGetterSetter(Zt,"fillLinearGradientStartPoint",["x","y"]),j.addComponentsGetterSetter(Zt,"strokeLinearGradientStartPoint",["x","y"]),j.addGetterSetter(Zt,"fillLinearGradientStartPointX",0),j.addGetterSetter(Zt,"strokeLinearGradientStartPointX",0),j.addGetterSetter(Zt,"fillLinearGradientStartPointY",0),j.addGetterSetter(Zt,"strokeLinearGradientStartPointY",0),j.addComponentsGetterSetter(Zt,"fillLinearGradientEndPoint",["x","y"]),j.addComponentsGetterSetter(Zt,"strokeLinearGradientEndPoint",["x","y"]),j.addGetterSetter(Zt,"fillLinearGradientEndPointX",0),j.addGetterSetter(Zt,"strokeLinearGradientEndPointX",0),j.addGetterSetter(Zt,"fillLinearGradientEndPointY",0),j.addGetterSetter(Zt,"strokeLinearGradientEndPointY",0),j.addComponentsGetterSetter(Zt,"fillRadialGradientStartPoint",["x","y"]),j.addGetterSetter(Zt,"fillRadialGradientStartPointX",0),j.addGetterSetter(Zt,"fillRadialGradientStartPointY",0),j.addComponentsGetterSetter(Zt,"fillRadialGradientEndPoint",["x","y"]),j.addGetterSetter(Zt,"fillRadialGradientEndPointX",0),j.addGetterSetter(Zt,"fillRadialGradientEndPointY",0),j.addGetterSetter(Zt,"fillPatternRotation",0),j.addGetterSetter(Zt,"fillRule",void 0,H()),j.backCompat(Zt,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"});const te=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],ee=te.length;class ie extends ht{constructor(t){super(t),this.canvas=new E,this.hitCanvas=new L({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(t){return this.getContext().clear(t),this.getHitCanvas().getContext().clear(t),this}setZIndex(t){super.setZIndex(t);const e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),t<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[t+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){at.prototype.moveToTop.call(this);const t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!at.prototype.moveUp.call(this))return!1;const t=this.getStage();return!(!t||!t.content)&&(t.content.removeChild(this.getNativeCanvasElement()),this.index<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[this.index+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(at.prototype.moveDown.call(this)){const t=this.getStage();if(t){const e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(at.prototype.moveToBottom.call(this)){const t=this.getStage();if(t){const e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){const t=this.getNativeCanvasElement();return at.prototype.remove.call(this),t&&t.parentNode&&w._isInDocument(t)&&t.parentNode.removeChild(t),this}getStage(){return this.parent}setSize({width:t,height:e}){return this.canvas.setSize(t,e),this._syncHitCanvasSize(),this._setSmoothEnabled(),this}_syncHitCanvasSize(){const t=this.isListening();this.hitCanvas.setSizeIfChanged((t?this.getWidth():0)||0,(t?this.getHeight():0)||0)}_validateAdd(t){const e=t.getType();"Group"!==e&&"Shape"!==e&&w.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(t){return(t={...t}).width=t.width||this.getWidth(),t.height=t.height||this.getHeight(),t.x=void 0!==t.x?t.x:this.x(),t.y=void 0!==t.y?t.y:this.y(),at.prototype._toKonvaCanvas.call(this,t)}_checkVisibility(){const t=this.visible();this.canvas._canvas.style.display=t?"block":"none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){w.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){w.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){var t;return this._waitingForDraw||(this._waitingForDraw=!0,w.requestAnimFrame(()=>{this.draw(),this._waitingForDraw=!1},null===(t=this.getStage())||void 0===t?void 0:t._getOwnerWindow())),this}getIntersection(t){if(!this.isListening()||!this.isVisible())return null;let e=1,i=!1;for(;;){for(let n=0;n<ee;n++){const s=te[n],r=this._getIntersection({x:t.x+s.x*e,y:t.y+s.y*e}),a=r.shape;if(a)return a;if(i=!!r.antialiased,!r.antialiased)break}if(!i)return null;e+=1}}_getIntersection(t){if(!this.hitCanvas.width||!this.hitCanvas.height)return{};const e=this.hitCanvas.pixelRatio,i=this.hitCanvas.context.getImageData(Math.round(t.x*e),Math.round(t.y*e),1,1).data,n=i[3];if(255===n){const t=w.getHitColorKey(i[0],i[1],i[2]),e=Jt[t];return e?{shape:e}:{antialiased:!0}}return n>0?{antialiased:!0}:{}}drawScene(t,e,i){const n=this.getLayer(),s=t||n&&n.getCanvas();return this._fire("beforeDraw",{node:this}),this.clearBeforeDraw()&&s.getContext().clear(),ht.prototype.drawScene.call(this,s,e,i),this._fire("draw",{node:this}),this}drawHit(t,e){const i=this.getLayer(),n=t||i&&i.hitCanvas;return!t&&i&&(i._syncHitCanvasSize(),i.clearBeforeDraw()&&i.getHitCanvas().getContext().clear()),ht.prototype.drawHit.call(this,n,e),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(t){w.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(t)}getHitGraphEnabled(t){return w.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(!this.parent||!this.parent.content)return;const t=this.parent;!!this.hitCanvas._canvas.parentNode?t.content.removeChild(this.hitCanvas._canvas):t.content.appendChild(this.hitCanvas._canvas)}destroy(){return w.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}}ie.prototype.nodeType="Layer",n(ie),j.addGetterSetter(ie,"imageSmoothingEnabled",!0),j.addGetterSetter(ie,"clearBeforeDraw",!0),j.addGetterSetter(ie,"hitGraphEnabled",!0,z());class ne extends ie{constructor(t){super(t),this.listening(!1),w.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}}ne.prototype.nodeType="FastLayer",n(ne);class se extends ht{_validateAdd(t){const e=t.getType();"Group"!==e&&"Shape"!==e&&w.throw("You may only add groups and shapes to groups.")}}se.prototype.nodeType="Group",n(se);const re=e.performance&&e.performance.now?function(){return e.performance.now()}:function(){return(new Date).getTime()};class ae{constructor(t,e){this.id=ae.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:re(),frameRate:0},this.func=t,this.setLayers(e)}setLayers(t){let e=[];return t&&(e=Array.isArray(t)?t:[t]),this.layers=e,this}getLayers(){return this.layers}addLayer(t){const e=this.layers,i=e.length;for(let n=0;n<i;n++)if(e[n]._id===t._id)return!1;return this.layers.push(t),!0}isRunning(){const t=ae.animations,e=t.length;for(let i=0;i<e;i++)if(t[i].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=re(),ae._addAnimation(this),this}stop(){return ae._removeAnimation(this),this}_updateFrameObject(t){this.frame.timeDiff=t-this.frame.lastTime,this.frame.lastTime=t,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(t){this.animations.push(t),this._handleAnimation()}static _removeAnimation(t){const e=t.id,i=this.animations,n=i.length;for(let t=0;t<n;t++)if(i[t].id===e){this.animations.splice(t,1);break}}static _runFrames(){const t={},e=this.animations;for(let i=0;i<e.length;i++){const n=e[i],s=n.layers,r=n.func;n._updateFrameObject(re());const a=s.length;let o;if(o=!r||!1!==r.call(n,n.frame),o)for(let e=0;e<a;e++){const i=s[e];void 0!==i._id&&(t[i._id]=i)}}for(const e in t)t.hasOwnProperty(e)&&t[e].batchDraw()}static _animationLoop(){const t=ae;t.animations.length?(t._runFrames(),w.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,w.requestAnimFrame(this._animationLoop))}}ae.animations=[],ae.animIdCounter=0,ae.animRunning=!1;const oe={node:1,duration:1,easing:1,onFinish:1,yoyo:1},he=["fill","stroke","shadowColor"];let le=0;function de(t){return w.colorToRGBA(t)||w.throw('can not tween the color "'+t+'", because it is not a valid color.')}class ce{constructor(t,e,i,n,s,r,a){this.prop=t,this.propFunc=e,this.begin=n,this._pos=n,this.duration=r,this._change=0,this.prevPos=0,this.yoyo=a,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=i,this._change=s-this.begin,this.pause()}fire(t){const e=this[t];e&&e()}setTime(t){t>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():t<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=t,this.update())}getTime(){return this._time}setPosition(t){this.prevPos=this._pos,this.propFunc(t),this._pos=t}getPosition(t){return void 0===t&&(t=this._time),this.func(t,this.begin,this._change,this.duration)}play(){this.state=2,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=3,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(t){this.pause(),this._time=t,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){const t=this.getTimer()-this._startTime;2===this.state?this.setTime(t):3===this.state&&this.setTime(this.duration-t)}pause(){this.state=1,this.fire("onPause")}getTimer(){return(new Date).getTime()}}class ge{constructor(t){const e=this,n=t.node,s=n._id,r=t.easing||ue.Linear,a=!!t.yoyo;let o,h;o=void 0===t.duration?.3:0===t.duration?.001:t.duration,this.node=n,this._id=le++;const l=n.getLayer()||(n instanceof i.Stage?n.getLayers():null);for(h in l||w.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new ae(function(){e.tween.onEnterFrame()},l),this.tween=new ce(h,function(t){e._tweenFunc(t)},r,0,1,1e3*o,a),this._addListeners(),ge.attrs[s]||(ge.attrs[s]={}),ge.attrs[s][this._id]||(ge.attrs[s][this._id]={}),ge.tweens[s]||(ge.tweens[s]={}),t)void 0===oe[h]&&this._addAttr(h,t[h]);this.reset(),this.onFinish=t.onFinish,this.onReset=t.onReset,this.onUpdate=t.onUpdate}_addAttr(t,e){const i=this.node,n=i._id;let s,r,a,o,h;const l=ge.tweens[n][t];l&&delete ge.attrs[n][l][t];let d=i.getAttr(t);if(w._isArray(e))if(s=[],r=Math.max(e.length,d.length),"points"===t&&e.length!==d.length&&(e.length>d.length?(o=d,d=w._prepareArrayForTween(d,e,i.closed())):(a=e,e=w._prepareArrayForTween(e,d,i.closed()))),0===t.indexOf("fill"))for(let t=0;t<r;t++)if(t%2==0)s.push(e[t]-d[t]);else{const i=de(d[t]);h=de(e[t]),d[t]=i,s.push({r:h.r-i.r,g:h.g-i.g,b:h.b-i.b,a:h.a-i.a})}else for(let t=0;t<r;t++)s.push(e[t]-d[t]);else-1!==he.indexOf(t)?(d=de(d),h=de(e),s={r:h.r-d.r,g:h.g-d.g,b:h.b-d.b,a:h.a-d.a}):s=e-d;ge.attrs[n][this._id][t]={start:d,diff:s,end:e,trueEnd:a,trueStart:o},ge.tweens[n][t]=this._id}_tweenFunc(t){const e=this.node,i=ge.attrs[e._id][this._id];let n,s,r,a,o,h,l,d;for(n in i){if(s=i[n],r=s.start,a=s.diff,d=s.end,w._isArray(r))if(o=[],l=Math.max(r.length,d.length),0===n.indexOf("fill"))for(h=0;h<l;h++)h%2==0?o.push((r[h]||0)+a[h]*t):o.push("rgba("+Math.round(r[h].r+a[h].r*t)+","+Math.round(r[h].g+a[h].g*t)+","+Math.round(r[h].b+a[h].b*t)+","+(r[h].a+a[h].a*t)+")");else for(h=0;h<l;h++)o.push((r[h]||0)+a[h]*t);else o=-1!==he.indexOf(n)?"rgba("+Math.round(r.r+a.r*t)+","+Math.round(r.g+a.g*t)+","+Math.round(r.b+a.b*t)+","+(r.a+a.a*t)+")":r+a*t;e.setAttr(n,o)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{const t=this.node,e=ge.attrs[t._id][this._id];e.points&&e.points.trueEnd&&t.setAttr("points",e.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{const t=this.node,e=ge.attrs[t._id][this._id];e.points&&e.points.trueStart&&t.points(e.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(t){return this.tween.seek(1e3*t),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){const t=this.node._id,e=this._id,i=ge.tweens[t];this.pause(),this.anim&&this.anim.stop();for(const e in i)delete ge.tweens[t][e];delete ge.attrs[t][e],ge.tweens[t]&&(0===Object.keys(ge.tweens[t]).length&&delete ge.tweens[t],0===Object.keys(ge.attrs[t]).length&&delete ge.attrs[t])}}ge.attrs={},ge.tweens={},at.prototype.to=function(t){const e=t.onFinish;t.node=this,t.onFinish=function(){this.destroy(),e&&e()};new ge(t).play()};const ue={BackEaseIn(t,e,i,n){const s=1.70158;return i*(t/=n)*t*((s+1)*t-s)+e},BackEaseOut(t,e,i,n){const s=1.70158;return i*((t=t/n-1)*t*((s+1)*t+s)+1)+e},BackEaseInOut(t,e,i,n){let s=1.70158;return(t/=n/2)<1?i/2*(t*t*((1+(s*=1.525))*t-s))+e:i/2*((t-=2)*t*((1+(s*=1.525))*t+s)+2)+e},ElasticEaseIn(t,e,i,n,s,r){let a=0;return 0===t?e:1===(t/=n)?e+i:(r||(r=.3*n),!s||s<Math.abs(i)?(s=i,a=r/4):a=r/(2*Math.PI)*Math.asin(i/s),-s*Math.pow(2,10*(t-=1))*Math.sin((t*n-a)*(2*Math.PI)/r)+e)},ElasticEaseOut(t,e,i,n,s,r){let a=0;return 0===t?e:1===(t/=n)?e+i:(r||(r=.3*n),!s||s<Math.abs(i)?(s=i,a=r/4):a=r/(2*Math.PI)*Math.asin(i/s),s*Math.pow(2,-10*t)*Math.sin((t*n-a)*(2*Math.PI)/r)+i+e)},ElasticEaseInOut(t,e,i,n,s,r){let a=0;return 0===t?e:2==(t/=n/2)?e+i:(r||(r=n*(.3*1.5)),!s||s<Math.abs(i)?(s=i,a=r/4):a=r/(2*Math.PI)*Math.asin(i/s),t<1?s*Math.pow(2,10*(t-=1))*Math.sin((t*n-a)*(2*Math.PI)/r)*-.5+e:s*Math.pow(2,-10*(t-=1))*Math.sin((t*n-a)*(2*Math.PI)/r)*.5+i+e)},BounceEaseOut:(t,e,i,n)=>(t/=n)<1/2.75?i*(7.5625*t*t)+e:t<2/2.75?i*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?i*(7.5625*(t-=2.25/2.75)*t+.9375)+e:i*(7.5625*(t-=2.625/2.75)*t+.984375)+e,BounceEaseIn:(t,e,i,n)=>i-ue.BounceEaseOut(n-t,0,i,n)+e,BounceEaseInOut:(t,e,i,n)=>t<n/2?.5*ue.BounceEaseIn(2*t,0,i,n)+e:.5*ue.BounceEaseOut(2*t-n,0,i,n)+.5*i+e,EaseIn:(t,e,i,n)=>i*(t/=n)*t+e,EaseOut:(t,e,i,n)=>-i*(t/=n)*(t-2)+e,EaseInOut:(t,e,i,n)=>(t/=n/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e,StrongEaseIn:(t,e,i,n)=>i*(t/=n)*t*t*t*t+e,StrongEaseOut:(t,e,i,n)=>i*((t=t/n-1)*t*t*t*t+1)+e,StrongEaseInOut:(t,e,i,n)=>(t/=n/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e,Linear:(t,e,i,n)=>i*t/n+e},fe=w._assign(i,{Util:w,Transform:r,Node:at,Container:ht,Stage:Xt,stages:Wt,Layer:ie,FastLayer:ne,Group:se,DD:D,Shape:Zt,shapes:Jt,Animation:ae,Tween:ge,Easings:ue,Context:T,Canvas:G});class pe extends Zt{_sceneFunc(t){const e=i.getAngle(this.angle()),n=this.clockwise();t.beginPath(),t.arc(0,0,this.outerRadius(),0,e,n),t.arc(0,0,this.innerRadius(),e,0,!n),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}getSelfRect(){const t=this.innerRadius(),e=this.outerRadius(),n=this.clockwise(),s=i.getAngle(this.angle());if(s%(2*Math.PI)==0)return 0!==s?{x:-e,y:-e,width:2*e,height:2*e}:{x:t,y:0,width:e-t,height:0};const r=i.getAngle(n?360-this.angle():this.angle()),a=Math.cos(Math.min(r,Math.PI)),o=Math.sin(Math.min(Math.max(Math.PI,r),3*Math.PI/2)),h=Math.sin(Math.min(r,Math.PI/2)),l=a*(a>0?t:e),d=o*(o>0?t:e),c=h*(h>0?e:t);return{x:l,y:n?-1*c:d,width:1*e-l,height:c-d}}}pe.prototype._centroid=!0,pe.prototype.className="Arc",pe.prototype._attrsAffectingSize=["innerRadius","outerRadius","angle","clockwise"],n(pe),j.addGetterSetter(pe,"innerRadius",0,F()),j.addGetterSetter(pe,"outerRadius",0,F()),j.addGetterSetter(pe,"angle",0,F()),j.addGetterSetter(pe,"clockwise",!1,z());const me=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],_e=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],ye=[[1],[1,1],[1,2,1],[1,3,3,1]],ve=(t,e,i)=>{let n,s;const r=i/2;n=0;for(let i=0;i<20;i++)s=r*me[20][i]+r,n+=_e[20][i]*be(t,e,s);return r*n},xe=(t,e,i)=>{void 0===i&&(i=1);const n=t[0]-2*t[1]+t[2],s=e[0]-2*e[1]+e[2],r=2*t[1]-2*t[0],a=2*e[1]-2*e[0],o=4*(n*n+s*s),h=4*(n*r+s*a),l=r*r+a*a;if(0===o)return i*Math.sqrt(Math.pow(t[2]-t[0],2)+Math.pow(e[2]-e[0],2));const d=h/(2*o),c=i+d,g=l/o-d*d,u=c*c+g>0?Math.sqrt(c*c+g):0,f=d*d+g>0?Math.sqrt(d*d+g):0,p=d+Math.sqrt(d*d+g)!==0?g*Math.log(Math.abs((c+u)/(d+f))):0;return Math.sqrt(o)/2*(c*u-d*f+p)};function be(t,e,i){const n=Se(1,i,t),s=Se(1,i,e),r=n*n+s*s;return Math.sqrt(r)}const Se=(t,e,i)=>{const n=i.length-1;let s,r;if(0===n)return 0;if(0===t){r=0;for(let t=0;t<=n;t++)r+=ye[n][t]*Math.pow(1-e,n-t)*Math.pow(e,t)*i[t];return r}s=new Array(n);for(let t=0;t<n;t++)s[t]=n*(i[t+1]-i[t]);return Se(t-1,e,s)},we=(t,e,i)=>{let n=1,s=t/e,r=(t-i(s))/e,a=0;for(;n>.001;){const o=i(s+r),h=Math.abs(t-o)/e;if(h<n)n=h,s+=r;else{const a=i(s-r),o=Math.abs(t-a)/e;o<n?(n=o,s-=r):r/=2}if(a++,a>500)break}return s},Ce=(t,e,i,n)=>{const s=1-n;return s*s*t+2*s*n*e+n*n*i},ke=(t,e,i,n,s,r)=>{const a=[];for(const o of[[t,i,s],[e,n,r]]){const h=(o[0]-o[1])/(o[0]-2*o[1]+o[2]);h>0&&h<1&&a.push(Ce(t,i,s,h),Ce(e,n,r,h))}return a},Pe=(t,e,i,n,s)=>{const r=1-s;return r*r*r*t+3*r*r*s*e+3*r*s*s*i+s*s*s*n},Ae=(t,e,i,n,s,r,a,o)=>{const h=[];for(const l of[[t,i,s,a],[e,n,r,o]]){const d=-3*l[0]+9*l[1]-9*l[2]+3*l[3],c=6*l[0]-12*l[1]+6*l[2],g=-3*l[0]+3*l[1],u=c*c-4*d*g;if(u<0)continue;const f=-(c+(c<0?-1:1)*Math.sqrt(u))/2;for(const l of[f/d,g/f])l>0&&l<1&&h.push(Pe(t,i,s,a,l),Pe(e,n,r,o,l))}return h};function Te(t,e,i,n,s,r,a){const o=Math.sqrt(Math.pow(i-t,2)+Math.pow(n-e,2)),h=Math.sqrt(Math.pow(s-i,2)+Math.pow(r-n,2)),l=o+h;if(0===l)return[i,n,i,n];const d=a*o/l,c=a*h/l;return[i-d*(s-t),n-d*(r-e),i+c*(s-t),n+c*(r-e)]}function Me(t,e){const i=t.length,n=[];for(let s=2;s<i-2;s+=2){const i=Te(t[s-2],t[s-1],t[s],t[s+1],t[s+2],t[s+3],e);isNaN(i[0])||(n.push(i[0]),n.push(i[1]),n.push(t[s]),n.push(t[s+1]),n.push(i[2]),n.push(i[3]))}return n}function Re(t){const e=[];for(let i=0;i+7<t.length;i+=6)e.push(t[i+6],t[i+7],...Ae(t[i],t[i+1],t[i+2],t[i+3],t[i+4],t[i+5],t[i+6],t[i+7]));return e}class Ge extends Zt{constructor(t){super(t),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",function(){this._clearCache("tensionPoints")})}_hasTension(){return 0!==this.tension()&&this.points().length>4}_eachTensionSegment(t,e){const i=this.points(),n=i.length,s=this.closed(),r=this.getTensionPoints(),a=r.length;let o=i[0],h=i[1],l=s?0:4;for(s||(t(o,h,r[0],r[1],r[2],r[3]),o=r[2],h=r[3]);l<a-2;){const t=r[l++],i=r[l++],n=r[l++],s=r[l++],a=r[l++],d=r[l++];e(o,h,t,i,n,s,a,d),o=a,h=d}s||t(o,h,r[a-2],r[a-1],i[n-2],i[n-1])}_sceneFunc(t){const e=this.points(),i=e.length,n=this.closed(),s=this.bezier();if(!i)return;let r=0;if(t.beginPath(),t.moveTo(e[0],e[1]),this._hasTension())this._eachTensionSegment((e,i,n,s,r,a)=>t.quadraticCurveTo(n,s,r,a),(e,i,n,s,r,a,o,h)=>t.bezierCurveTo(n,s,r,a,o,h));else if(s)for(r=2;r<i;)t.bezierCurveTo(e[r++],e[r++],e[r++],e[r++],e[r++],e[r++]);else for(r=2;r<i;r+=2)t.lineTo(e[r],e[r+1]);n?(t.closePath(),t.fillStrokeShape(this)):t.strokeShape(this)}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():Me(this.points(),this.tension())}_getTensionPointsClosed(){const t=this.points(),e=t.length,i=this.tension(),n=Te(t[e-2],t[e-1],t[0],t[1],t[2],t[3],i),s=Te(t[e-4],t[e-3],t[e-2],t[e-1],t[0],t[1],i),r=Me(t,i);return[n[2],n[3]].concat(r).concat([s[0],s[1],t[e-2],t[e-1],s[2],s[3],n[0],n[1],t[0],t[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){let t=this.points();if(t.length<4)return{x:t[0]||0,y:t[1]||0,width:0,height:0};if(this._hasTension()){const e=[t[0],t[1]];this._eachTensionSegment((t,i,n,s,r,a)=>e.push(r,a,...ke(t,i,n,s,r,a)),(t,i,n,s,r,a,o,h)=>e.push(o,h,...Ae(t,i,n,s,r,a,o,h))),t=e}else this.bezier()&&(t=[t[0],t[1],...Re(t)]);let e,i,n=t[0],s=t[0],r=t[1],a=t[1];for(let o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],n=Math.min(n,e),s=Math.max(s,e),r=Math.min(r,i),a=Math.max(a,i);return{x:n,y:r,width:s-n,height:a-r}}}Ge.prototype.className="Line",Ge.prototype._attrsAffectingSize=["points","bezier","tension"],n(Ge),j.addGetterSetter(Ge,"closed",!1),j.addGetterSetter(Ge,"bezier",!1),j.addGetterSetter(Ge,"tension",0,F()),j.addGetterSetter(Ge,"points",[],function(){if(i.isUnminified)return function(t,e){const i=Int8Array?Object.getPrototypeOf(Int8Array):null;return i&&t instanceof i||(w._isArray(t)?t.forEach(function(t){w._isNumber(t)||w.warn('"'+e+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")}):w.warn(I(t)+' is a not valid value for "'+e+'" attribute. The value should be a array of numbers.')),t}}());class Ee extends Zt{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=Ee.parsePathData(this.data()),this.pathLength=Ee.getPathLength(this.dataArray)}_sceneFunc(t){const e=this.dataArray;t.beginPath();let i=!1;for(let n=0;n<e.length;n++){const s=e[n].command,r=e[n].points;switch(s){case"L":t.lineTo(r[0],r[1]);break;case"M":t.moveTo(r[0],r[1]);break;case"C":t.bezierCurveTo(r[0],r[1],r[2],r[3],r[4],r[5]);break;case"Q":t.quadraticCurveTo(r[0],r[1],r[2],r[3]);break;case"A":const e=r[0],n=r[1],s=r[2],a=r[3],o=r[4],h=r[5],l=r[6],d=r[7],c=s>a?s:a,g=s>a?1:s/a,u=s>a?a/s:1;t.translate(e,n),t.rotate(l),t.scale(g,u),t.arc(0,0,c,o,o+h,1-d),t.scale(1/g,1/u),t.rotate(-l),t.translate(-e,-n);break;case"z":i=!0,t.closePath()}}i||this.hasFill()?t.fillStrokeShape(this):t.strokeShape(this)}getSelfRect(){let t=[];this.dataArray.forEach(function(e){if("A"===e.command){const i=e.points[4],n=e.points[5],s=e.points[4]+n;let r=Math.PI/180;if(Math.abs(i-s)<r&&(r=Math.abs(i-s)),n<0)for(let n=i-r;n>s;n-=r){const i=Ee.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],n,0);t.push(i.x,i.y)}else for(let n=i+r;n<s;n+=r){const i=Ee.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],n,0);t.push(i.x,i.y)}}else"C"===e.command?t.push(e.start.x,e.start.y,e.points[4],e.points[5],...Ae(e.start.x,e.start.y,e.points[0],e.points[1],e.points[2],e.points[3],e.points[4],e.points[5])):"Q"===e.command?t.push(e.start.x,e.start.y,e.points[2],e.points[3],...ke(e.start.x,e.start.y,e.points[0],e.points[1],e.points[2],e.points[3])):t=t.concat(e.points)});let e,i,n=t[0],s=t[0],r=t[1],a=t[1];for(let o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],isNaN(e)||(n=Math.min(n,e),s=Math.max(s,e)),isNaN(i)||(r=Math.min(r,i),a=Math.max(a,i));return{x:n,y:r,width:s-n,height:a-r}}getLength(){return this.pathLength}getPointAtLength(t){return Ee.getPointAtLengthOfDataArray(t,this.dataArray)}static getLineLength(t,e,i,n){return Math.sqrt((i-t)*(i-t)+(n-e)*(n-e))}static getPathLength(t){let e=0;for(let i=0;i<t.length;++i)e+=t[i].pathLength;return e}static getPointAtLengthOfDataArray(t,e){let i,n=0,s=e.length;if(!s)return null;for(;n<s&&t>e[n].pathLength;)t-=e[n].pathLength,++n;if(n===s){let t=n-1;for(;t>0&&e[t].points.length<2;)t--;return i=e[t].points.slice(-2),{x:i[0],y:i[1]}}if(t<.01){return"M"===e[n].command?(i=e[n].points.slice(0,2),{x:i[0],y:i[1]}):{x:e[n].start.x,y:e[n].start.y}}const r=e[n],a=r.points;switch(r.command){case"L":return Ee.getPointOnLine(t,r.start.x,r.start.y,a[0],a[1]);case"C":return Ee.getPointOnCubicBezier(we(t,Ee.getPathLength(e),t=>ve([r.start.x,a[0],a[2],a[4]],[r.start.y,a[1],a[3],a[5]],t)),r.start.x,r.start.y,a[0],a[1],a[2],a[3],a[4],a[5]);case"Q":return Ee.getPointOnQuadraticBezier(we(t,Ee.getPathLength(e),t=>xe([r.start.x,a[0],a[2]],[r.start.y,a[1],a[3]],t)),r.start.x,r.start.y,a[0],a[1],a[2],a[3]);case"A":const i=a[0],n=a[1],s=a[2],o=a[3],h=a[5],l=a[6];let d=a[4];return d+=h*t/r.pathLength,Ee.getPointOnEllipticalArc(i,n,s,o,d,l)}return null}static getPointOnLine(t,e,i,n,s,r,a){r=null!=r?r:e,a=null!=a?a:i;const o=this.getLineLength(e,i,n,s);if(o<1e-10)return{x:e,y:i};if(n===e)return{x:r,y:a+(s>i?t:-t)};const h=(s-i)/(n-e),l=Math.sqrt(t*t/(1+h*h))*(n<e?-1:1),d=h*l;if(Math.abs(a-i-h*(r-e))<1e-10)return{x:r+l,y:a+d};const c=((r-e)*(n-e)+(a-i)*(s-i))/(o*o),g=e+c*(n-e),u=i+c*(s-i),f=this.getLineLength(r,a,g,u),p=Math.sqrt(t*t-f*f),m=Math.sqrt(p*p/(1+h*h))*(n<e?-1:1);return{x:g+m,y:u+h*m}}static getPointOnCubicBezier(t,e,i,n,s,r,a,o,h){function l(t){return t*t*t}function d(t){return 3*t*t*(1-t)}function c(t){return 3*t*(1-t)*(1-t)}function g(t){return(1-t)*(1-t)*(1-t)}return{x:o*l(t)+r*d(t)+n*c(t)+e*g(t),y:h*l(t)+a*d(t)+s*c(t)+i*g(t)}}static getPointOnQuadraticBezier(t,e,i,n,s,r,a){function o(t){return t*t}function h(t){return 2*t*(1-t)}function l(t){return(1-t)*(1-t)}return{x:r*o(t)+n*h(t)+e*l(t),y:a*o(t)+s*h(t)+i*l(t)}}static getPointOnEllipticalArc(t,e,i,n,s,r){const a=Math.cos(r),o=Math.sin(r),h=i*Math.cos(s),l=n*Math.sin(s);return{x:t+(h*a-l*o),y:e+(h*o+l*a)}}static parsePathData(t){if(!t)return[];let e=t;const i=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];e=e.replace(new RegExp(" ","g"),",");for(let t=0;t<i.length;t++)e=e.replace(new RegExp(i[t],"g"),"|"+i[t]);const n=e.split("|"),s=[],r=[];let a=0,o=0;const h=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;let l;for(let t=1;t<n.length;t++){let e=n[t],i=e.charAt(0);for(e=e.slice(1),r.length=0;l=h.exec(e);)r.push(l[0]);let d=[],c="A"===i||"a"===i?0:-1;for(let t=0,e=r.length;t<e;t++){const e=r[t];if("00"!==e)if(c>=0){if(3===c){if(/^[01]{2}\d+(?:\.\d+)?$/.test(e)){d.push(parseInt(e[0],10)),d.push(parseInt(e[1],10)),d.push(parseFloat(e.slice(2))),c+=3,c>=7&&(c-=7);continue}if("11"===e||"10"===e||"01"===e){d.push(parseInt(e[0],10)),d.push(parseInt(e[1],10)),c+=2,c>=7&&(c-=7);continue}if("0"===e||"1"===e){d.push(parseInt(e,10)),c+=1,c>=7&&(c-=7);continue}}else if(4===c){if(/^[01]\d+(?:\.\d+)?$/.test(e)){d.push(parseInt(e[0],10)),d.push(parseFloat(e.slice(1))),c+=2,c>=7&&(c-=7);continue}if("0"===e||"1"===e){d.push(parseInt(e,10)),c+=1,c>=7&&(c-=7);continue}}const t=parseFloat(e);isNaN(t)?d.push(0):d.push(t),c+=1,c>=7&&(c-=7)}else{const t=parseFloat(e);isNaN(t)?d.push(0):d.push(t)}else d.push(0,0),c>=0&&(c+=2,c>=7&&(c-=7))}for(;d.length>0&&!isNaN(d[0]);){let t="",e=[];const n=a,r=o;let h,l,c,g,u,f,p,m,_,y;switch(i){case"l":a+=d.shift(),o+=d.shift(),t="L",e.push(a,o);break;case"L":a=d.shift(),o=d.shift(),e.push(a,o);break;case"m":const n=d.shift(),r=d.shift();if(a+=n,o+=r,t="M",s.length>2&&"z"===s[s.length-1].command)for(let t=s.length-2;t>=0;t--)if("M"===s[t].command){a=s[t].points[0]+n,o=s[t].points[1]+r;break}e.push(a,o),i="l";break;case"M":a=d.shift(),o=d.shift(),t="M",e.push(a,o),i="L";break;case"h":a+=d.shift(),t="L",e.push(a,o);break;case"H":a=d.shift(),t="L",e.push(a,o);break;case"v":o+=d.shift(),t="L",e.push(a,o);break;case"V":o=d.shift(),t="L",e.push(a,o);break;case"C":e.push(d.shift(),d.shift(),d.shift(),d.shift()),a=d.shift(),o=d.shift(),e.push(a,o);break;case"c":e.push(a+d.shift(),o+d.shift(),a+d.shift(),o+d.shift()),a+=d.shift(),o+=d.shift(),t="C",e.push(a,o);break;case"S":l=a,c=o,h=s[s.length-1],"C"===h.command&&(l=a+(a-h.points[2]),c=o+(o-h.points[3])),e.push(l,c,d.shift(),d.shift()),a=d.shift(),o=d.shift(),t="C",e.push(a,o);break;case"s":l=a,c=o,h=s[s.length-1],"C"===h.command&&(l=a+(a-h.points[2]),c=o+(o-h.points[3])),e.push(l,c,a+d.shift(),o+d.shift()),a+=d.shift(),o+=d.shift(),t="C",e.push(a,o);break;case"Q":e.push(d.shift(),d.shift()),a=d.shift(),o=d.shift(),e.push(a,o);break;case"q":e.push(a+d.shift(),o+d.shift()),a+=d.shift(),o+=d.shift(),t="Q",e.push(a,o);break;case"T":l=a,c=o,h=s[s.length-1],"Q"===h.command&&(l=a+(a-h.points[0]),c=o+(o-h.points[1])),a=d.shift(),o=d.shift(),t="Q",e.push(l,c,a,o);break;case"t":l=a,c=o,h=s[s.length-1],"Q"===h.command&&(l=a+(a-h.points[0]),c=o+(o-h.points[1])),a+=d.shift(),o+=d.shift(),t="Q",e.push(l,c,a,o);break;case"A":g=d.shift(),u=d.shift(),f=d.shift(),p=d.shift(),m=d.shift(),_=a,y=o,a=d.shift(),o=d.shift(),t="A",e=this.convertEndpointToCenterParameterization(_,y,a,o,p,m,g,u,f);break;case"a":g=d.shift(),u=d.shift(),f=d.shift(),p=d.shift(),m=d.shift(),_=a,y=o,a+=d.shift(),o+=d.shift(),t="A",e=this.convertEndpointToCenterParameterization(_,y,a,o,p,m,g,u,f)}s.push({command:t||i,points:e,start:{x:n,y:r},pathLength:this.calcLength(n,r,t||i,e)})}"z"!==i&&"Z"!==i||s.push({command:"z",points:[],start:void 0,pathLength:0})}return s}static calcLength(t,e,i,n){let s,r,a,o;const h=Ee;switch(i){case"L":return h.getLineLength(t,e,n[0],n[1]);case"C":return ve([t,n[0],n[2],n[4]],[e,n[1],n[3],n[5]],1);case"Q":return xe([t,n[0],n[2]],[e,n[1],n[3]],1);case"A":s=0;const i=n[4],l=n[5],d=n[4]+l;let c=Math.PI/180;if(Math.abs(i-d)<c&&(c=Math.abs(i-d)),r=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],i,0),l<0)for(o=i-c;o>d;o-=c)a=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],o,0),s+=h.getLineLength(r.x,r.y,a.x,a.y),r=a;else for(o=i+c;o<d;o+=c)a=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],o,0),s+=h.getLineLength(r.x,r.y,a.x,a.y),r=a;return a=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],d,0),s+=h.getLineLength(r.x,r.y,a.x,a.y),s}return 0}static convertEndpointToCenterParameterization(t,e,i,n,s,r,a,o,h){const l=h*(Math.PI/180),d=Math.cos(l)*(t-i)/2+Math.sin(l)*(e-n)/2,c=-1*Math.sin(l)*(t-i)/2+Math.cos(l)*(e-n)/2,g=d*d/(a*a)+c*c/(o*o);g>1&&(a*=Math.sqrt(g),o*=Math.sqrt(g));let u=Math.sqrt((a*a*(o*o)-a*a*(c*c)-o*o*(d*d))/(a*a*(c*c)+o*o*(d*d)));s===r&&(u*=-1),isNaN(u)&&(u=0);const f=u*a*c/o,p=u*-o*d/a,m=(t+i)/2+Math.cos(l)*f-Math.sin(l)*p,_=(e+n)/2+Math.sin(l)*f+Math.cos(l)*p,y=function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])},v=function(t,e){return(t[0]*e[0]+t[1]*e[1])/(y(t)*y(e))},x=function(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(v(t,e))},b=x([1,0],[(d-f)/a,(c-p)/o]),S=[(d-f)/a,(c-p)/o],w=[(-1*d-f)/a,(-1*c-p)/o];let C=x(S,w);return v(S,w)<=-1&&(C=Math.PI),v(S,w)>=1&&(C=0),0===r&&C>0&&(C-=2*Math.PI),1===r&&C<0&&(C+=2*Math.PI),[m,_,a,o,b,C,l,r]}}Ee.prototype.className="Path",Ee.prototype._attrsAffectingSize=["data"],n(Ee),j.addGetterSetter(Ee,"data");class Le extends Ge{_sceneFunc(t){super._sceneFunc(t);const e=2*Math.PI,i=this.points();let n=i;const s=0!==this.tension()&&i.length>4;s&&(n=this.getTensionPoints());const r=this.pointerLength(),a=i.length;let o,h;if(s){const t=[n[n.length-4],n[n.length-3],n[n.length-2],n[n.length-1],i[a-2],i[a-1]],e=Ee.calcLength(n[n.length-4],n[n.length-3],"C",t),s=Ee.getPointOnQuadraticBezier(Math.min(1,1-r/e),t[0],t[1],t[2],t[3],t[4],t[5]);o=i[a-2]-s.x,h=i[a-1]-s.y}else o=i[a-2]-i[a-4],h=i[a-1]-i[a-3];const l=(Math.atan2(h,o)+e)%e,d=this.pointerWidth();this.pointerAtEnding()&&(t.save(),t.beginPath(),t.translate(i[a-2],i[a-1]),t.rotate(l),t.moveTo(0,0),t.lineTo(-r,d/2),t.lineTo(-r,-d/2),t.closePath(),t.restore(),this.__fillStroke(t)),this.pointerAtBeginning()&&(t.save(),t.beginPath(),t.translate(i[0],i[1]),s?(o=(n[0]+n[2])/2-i[0],h=(n[1]+n[3])/2-i[1]):(o=i[2]-i[0],h=i[3]-i[1]),t.rotate((Math.atan2(-h,-o)+e)%e),t.moveTo(0,0),t.lineTo(-r,d/2),t.lineTo(-r,-d/2),t.closePath(),t.restore(),this.__fillStroke(t))}__fillStroke(t){const e=this.dashEnabled();e&&(this.attrs.dashEnabled=!1,t.setLineDash([])),t.fillStrokeShape(this),e&&(this.attrs.dashEnabled=!0)}getSelfRect(){const t=super.getSelfRect(),e=this.pointerWidth()/2;return{x:t.x,y:t.y-e,width:t.width,height:t.height+2*e}}}Le.prototype.className="Arrow",n(Le),j.addGetterSetter(Le,"pointerLength",10,F()),j.addGetterSetter(Le,"pointerWidth",10,F()),j.addGetterSetter(Le,"pointerAtBeginning",!1),j.addGetterSetter(Le,"pointerAtEnding",!0);class De extends Zt{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.attrs.radius||0,0,2*Math.PI,!1),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius()!==t/2&&this.radius(t/2)}setHeight(t){this.radius()!==t/2&&this.radius(t/2)}}De.prototype._centroid=!0,De.prototype.className="Circle",De.prototype._attrsAffectingSize=["radius"],n(De),j.addGetterSetter(De,"radius",0,F());class Ie extends Zt{_sceneFunc(t){const e=this.radiusX(),i=this.radiusY();t.beginPath(),t.save(),e!==i&&t.scale(1,i/e),t.arc(0,0,e,0,2*Math.PI,!1),t.restore(),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radiusX()}getHeight(){return 2*this.radiusY()}setWidth(t){this.radiusX(t/2)}setHeight(t){this.radiusY(t/2)}}Ie.prototype.className="Ellipse",Ie.prototype._centroid=!0,Ie.prototype._attrsAffectingSize=["radiusX","radiusY"],n(Ie),j.addComponentsGetterSetter(Ie,"radius",["x","y"]),j.addGetterSetter(Ie,"radiusX",0,F()),j.addGetterSetter(Ie,"radiusY",0,F());class Oe extends Zt{constructor(t){super(t),this._loadListener=()=>{this._requestDraw()},this.on("imageChange.konva",t=>{this._removeImageLoad(t.oldVal),this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){const t=this.image();t&&t.complete||t&&4===t.readyState||t&&t.addEventListener&&t.addEventListener("load",this._loadListener)}_removeImageLoad(t){t&&t.removeEventListener&&t.removeEventListener("load",this._loadListener)}destroy(){return this._removeImageLoad(this.image()),super.destroy(),this}_useBufferCanvas(){const t=!!this.cornerRadius(),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas(!0)}_sceneFunc(t){const e=this.getWidth(),i=this.getHeight(),n=this.cornerRadius(),s=this.attrs.image;let r;if(s){const t=this.attrs.cropWidth,n=this.attrs.cropHeight;r=t&&n?[s,this.cropX(),this.cropY(),t,n,0,0,e,i]:[s,0,0,e,i]}(this.hasFill()||this.hasStroke()||n)&&(t.beginPath(),n?w.drawRoundedRectPath(t,e,i,n):t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)),s&&(n&&t.clip(),t.drawImage.apply(t,r))}_hitFunc(t){const e=this.width(),i=this.height(),n=this.cornerRadius();t.beginPath(),n?w.drawRoundedRectPath(t,e,i,n):t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}getWidth(){var t,e,i;return null!==(i=null!==(t=this.attrs.width)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.width)&&void 0!==i?i:0}getHeight(){var t,e,i;return null!==(i=null!==(t=this.attrs.height)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.height)&&void 0!==i?i:0}static fromURL(t,e,i=null){const n=w.createImageElement();n.onload=function(){const t=new Oe({image:n});e(t)},n.onerror=i,n.crossOrigin="Anonymous",n.src=t}}Oe.prototype.className="Image",Oe.prototype._attrsAffectingSize=["image"],n(Oe),j.addGetterSetter(Oe,"cornerRadius",0,B(4)),j.addGetterSetter(Oe,"image"),j.addComponentsGetterSetter(Oe,"crop",["x","y","width","height"]),j.addGetterSetter(Oe,"cropX",0,F()),j.addGetterSetter(Oe,"cropY",0,F()),j.addGetterSetter(Oe,"cropWidth",0,F()),j.addGetterSetter(Oe,"cropHeight",0,F());const Fe=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],Be="up",Ne="right",He="down",We="left",ze=Fe.length;class Ye extends se{constructor(t){super(t),this.on("add.konva",function(t){this._addListeners(t.child),this._sync()})}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(t){let e,i=this;const n=function(){i._sync()};for(e=0;e<ze;e++)t.on(Fe[e]+"Change.konva",n)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let t,e,i,n,s,r,a,o=this.getText(),h=this.getTag();if(o&&h){switch(t=o.width(),e=o.height(),i=h.pointerDirection(),n=h.pointerWidth(),a=h.pointerHeight(),s=0,r=0,i){case Be:s=t/2,r=-1*a;break;case Ne:s=t+n,r=e/2;break;case He:s=t/2,r=e+a;break;case We:s=-1*n,r=e/2}h.setAttrs({x:-1*s,y:-1*r,width:t,height:e}),o.setAttrs({x:-1*s,y:-1*r})}}}Ye.prototype.className="Label",n(Ye);class Xe extends Zt{_sceneFunc(t){const e=this.width(),i=this.height(),n=this.pointerDirection(),s=this.pointerWidth(),r=this.pointerHeight(),a=this.cornerRadius();let o=0,h=0,l=0,d=0;"number"==typeof a?o=h=l=d=Math.min(a,e/2,i/2):(o=Math.min(a[0]||0,e/2,i/2),h=Math.min(a[1]||0,e/2,i/2),d=Math.min(a[2]||0,e/2,i/2),l=Math.min(a[3]||0,e/2,i/2)),t.beginPath(),t.moveTo(o,0),n===Be&&(t.lineTo((e-s)/2,0),t.lineTo(e/2,-1*r),t.lineTo((e+s)/2,0)),t.lineTo(e-h,0),t.arc(e-h,h,h,3*Math.PI/2,0,!1),n===Ne&&(t.lineTo(e,(i-r)/2),t.lineTo(e+s,i/2),t.lineTo(e,(i+r)/2)),t.lineTo(e,i-d),t.arc(e-d,i-d,d,0,Math.PI/2,!1),n===He&&(t.lineTo((e+s)/2,i),t.lineTo(e/2,i+r),t.lineTo((e-s)/2,i)),t.lineTo(l,i),t.arc(l,i-l,l,Math.PI/2,Math.PI,!1),n===We&&(t.lineTo(0,(i+r)/2),t.lineTo(-1*s,i/2),t.lineTo(0,(i-r)/2)),t.lineTo(0,o),t.arc(o,o,o,Math.PI,3*Math.PI/2,!1),t.closePath(),t.fillStrokeShape(this)}getSelfRect(){let t=0,e=0,i=this.pointerWidth(),n=this.pointerHeight(),s=this.pointerDirection(),r=this.width(),a=this.height();return s===Be?(e-=n,a+=n):s===He?a+=n:s===We?(t-=1.5*i,r+=i):s===Ne&&(r+=1.5*i),{x:t,y:e,width:r,height:a}}}Xe.prototype.className="Tag",n(Xe),j.addGetterSetter(Xe,"pointerDirection","none"),j.addGetterSetter(Xe,"pointerWidth",0,F()),j.addGetterSetter(Xe,"pointerHeight",0,F()),j.addGetterSetter(Xe,"cornerRadius",0,B(4));class je extends Zt{_sceneFunc(t){const e=this.cornerRadius(),i=this.width(),n=this.height();t.beginPath(),e?w.drawRoundedRectPath(t,i,n,e):t.rect(0,0,i,n),t.closePath(),t.fillStrokeShape(this)}}je.prototype.className="Rect",n(je),j.addGetterSetter(je,"cornerRadius",0,B(4));class qe extends Zt{_sceneFunc(t){const e=this._getPoints(),i=this.radius(),n=this.sides(),s=this.cornerRadius();if(t.beginPath(),s)w.drawRoundedPolygonPath(t,e,n,i,s);else{t.moveTo(e[0].x,e[0].y);for(let i=1;i<e.length;i++)t.lineTo(e[i].x,e[i].y)}t.closePath(),t.fillStrokeShape(this)}_getPoints(){const t=this.attrs.sides,e=this.attrs.radius||0,i=[];for(let n=0;n<t;n++)i.push({x:e*Math.sin(2*n*Math.PI/t),y:-1*e*Math.cos(2*n*Math.PI/t)});return i}getSelfRect(){const t=this._getPoints();let e=t[0].x,i=t[0].x,n=t[0].y,s=t[0].y;return t.forEach(t=>{e=Math.min(e,t.x),i=Math.max(i,t.x),n=Math.min(n,t.y),s=Math.max(s,t.y)}),{x:e,y:n,width:i-e,height:s-n}}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}}qe.prototype.className="RegularPolygon",qe.prototype._centroid=!0,qe.prototype._attrsAffectingSize=["radius"],n(qe),j.addGetterSetter(qe,"radius",0,F()),j.addGetterSetter(qe,"sides",0,F()),j.addGetterSetter(qe,"cornerRadius",0,B(4));const Ue=2*Math.PI;class Ke extends Zt{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.innerRadius(),0,Ue,!1),t.moveTo(this.outerRadius(),0),t.arc(0,0,this.outerRadius(),Ue,0,!0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}}Ke.prototype.className="Ring",Ke.prototype._centroid=!0,Ke.prototype._attrsAffectingSize=["innerRadius","outerRadius"],n(Ke),j.addGetterSetter(Ke,"innerRadius",0,F()),j.addGetterSetter(Ke,"outerRadius",0,F());class Ve extends Zt{constructor(t){super(t),this._updated=!0,this.anim=new ae(()=>{const t=this._updated;return this._updated=!1,t}),this.on("animationChange.konva",function(){this.frameIndex(0)}),this.on("frameIndexChange.konva",function(){this._updated=!0}),this.on("frameRateChange.konva",function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})}_sceneFunc(t){const e=this.animation(),i=this.frameIndex(),n=4*i,s=this.animations()[e],r=this.frameOffsets(),a=s[n+0],o=s[n+1],h=s[n+2],l=s[n+3],d=this.image();if((this.hasFill()||this.hasStroke())&&(t.beginPath(),t.rect(0,0,h,l),t.closePath(),t.fillStrokeShape(this)),d)if(r){const n=r[e],s=2*i;t.drawImage(d,a,o,h,l,n[s+0],n[s+1],h,l)}else t.drawImage(d,a,o,h,l,0,0,h,l)}_hitFunc(t){const e=this.animation(),i=this.frameIndex(),n=4*i,s=this.animations()[e],r=this.frameOffsets(),a=s[n+2],o=s[n+3];if(t.beginPath(),r){const n=r[e],s=2*i;t.rect(n[s+0],n[s+1],a,o)}else t.rect(0,0,a,o);t.closePath(),t.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){const t=this;this.interval=setInterval(function(){t._updateIndex()},1e3/this.frameRate())}start(){if(this.isRunning())return;const t=this.getLayer();this.anim.setLayers(t),this._setInterval(),this.anim.start()}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){const t=this.frameIndex(),e=this.animation();t<this.animations()[e].length/4-1?this.frameIndex(t+1):this.frameIndex(0)}}Ve.prototype.className="Sprite",n(Ve),j.addGetterSetter(Ve,"animation"),j.addGetterSetter(Ve,"animations"),j.addGetterSetter(Ve,"frameOffsets"),j.addGetterSetter(Ve,"image"),j.addGetterSetter(Ve,"frameIndex",0,F()),j.addGetterSetter(Ve,"frameRate",17,F()),j.backCompat(Ve,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});class $e extends Zt{_sceneFunc(t){const e=this.innerRadius(),i=this.outerRadius(),n=this.numPoints();t.beginPath(),t.moveTo(0,0-i);for(let s=1;s<2*n;s++){const r=s%2==0?i:e,a=r*Math.sin(s*Math.PI/n),o=-1*r*Math.cos(s*Math.PI/n);t.lineTo(a,o)}t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}}function Qe(t){return[...t].reduce((t,e,i,n)=>{if(/\p{Emoji}/u.test(e)){const s=n[i+1];s&&/\p{Emoji_Modifier}|\u200D/u.test(s)?(t.push(e+s),n[i+1]=""):t.push(e)}else/\p{Regional_Indicator}{2}/u.test(e+(n[i+1]||""))?t.push(e+n[i+1]):i>0&&/\p{Mn}|\p{Me}|\p{Mc}/u.test(e)?t[t.length-1]+=e:e&&t.push(e);return t},[])}$e.prototype.className="Star",$e.prototype._centroid=!0,$e.prototype._attrsAffectingSize=["innerRadius","outerRadius"],n($e),j.addGetterSetter($e,"numPoints",5,F()),j.addGetterSetter($e,"innerRadius",0,F()),j.addGetterSetter($e,"outerRadius",0,F());const Je="auto",Ze="inherit",ti="justify",ei="left",ii="middle",ni="normal",si=" ",ri="none",ai=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],oi=ai.length;let hi,li=null;function di(){return hi||(hi=w.createCanvasElement().getContext("2d"),hi)}class ci extends Zt{constructor(t){super(function(t){return(t=t||{}).fillLinearGradientColorStops||t.fillRadialGradientColorStops||t.fillPatternImage||(t.fill=t.fill||"black"),t}(t)),this._partialTextX=0,this._partialTextY=0;for(let t=0;t<oi;t++)this.on(ai[t]+"Change.konva",this._setTextData);this._setTextData()}_sceneFunc(t){var e,n;const s=this.textArr,r=s.length;if(!this.text())return;let a,o=this.padding(),h=this.fontSize(),l=this.lineHeight()*h,d=this.verticalAlign(),c=this.direction(),g=0,u=this.align(),f=this.getWidth(),p=this.letterSpacing(),m=this.charRenderFunc(),_=this.fill(),y=this.textDecoration(),v=this.underlineOffset(),x=-1!==y.indexOf("underline"),b=-1!==y.indexOf("line-through");c=c===Ze?t.direction:c;let S=l/2,w=ii;if(!i.legacyTextRendering){const t=this.measureSize("M");w="alphabetic";S=((null!==(e=t.fontBoundingBoxAscent)&&void 0!==e?e:t.actualBoundingBoxAscent)-(null!==(n=t.fontBoundingBoxDescent)&&void 0!==n?n:t.actualBoundingBoxDescent))/2+l/2}"rtl"===c&&t.setAttr("direction",c),t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",w),t.setAttr("textAlign",ei),d===ii?g=(this.getHeight()-r*l-2*o)/2:"bottom"===d&&(g=this.getHeight()-r*l-2*o),t.translate(o,g+o);const C=m?t.fillStyle:void 0,k=m?t.strokeStyle:void 0;for(a=0;a<r;a++){let e=0,n=0;const d=s[a],g=d.text,y=d.width,w=d.lastInParagraph;if(t.save(),"right"===u?e+=f-y-2*o:"center"===u&&(e+=(f-y-2*o)/2),x){t.save(),t.beginPath();const s=e,r=S+n+(null!=v?v:i.legacyTextRendering?Math.round(h/2):Math.round(h/4));t.moveTo(s,r);const a=u!==ti||w?y:f-2*o;t.lineTo(s+Math.round(a),r),t.lineWidth=h/15;const l=this._getLinearGradient();t.strokeStyle=l||_,t.stroke(),t.restore()}const P=e;if("rtl"===c||0===p&&u!==ti&&!m)0!==p&&t.setAttr("letterSpacing",`${p}px`),this._partialTextX=e,this._partialTextY=S+n,this._partialText=g,t.fillStrokeShape(this);else{const i=g.split(" ").length-1,r=Qe(g);for(let h=0;h<r.length;h++){const l=r[h];if(" "!==l||w||u!==ti||(e+=(f-2*o-y)/i),this._partialTextX=e,this._partialTextY=S+n,this._partialText=l,m){t.save();m({char:l,index:h+s.slice(0,a).reduce((t,e)=>t+Qe(e.text).length,0),x:e,y:S+n,lineIndex:a,column:h,isLastInLine:w,width:this.measureSize(l).width,context:t});const i=t.fillStyle;i!==C&&(this._partialFillStyle=i);const r=t.strokeStyle;r!==k&&(this._partialStrokeStyle=r)}t.fillStrokeShape(this),m&&(this._partialFillStyle=void 0,this._partialStrokeStyle=void 0,t.restore()),e+=this.measureSize(l).width+p}}if(b){t.save(),t.beginPath();const e=i.legacyTextRendering?0:-Math.round(h/4),s=P;t.moveTo(s,S+n+e);const r=u!==ti||w?y:f-2*o;t.lineTo(s+Math.round(r),S+n+e),t.lineWidth=h/15;const a=this._getLinearGradient();t.strokeStyle=a||_,t.stroke(),t.restore()}t.restore(),r>1&&(S+=l)}}_hitFunc(t){const e=this.getWidth(),i=this.getHeight();t.beginPath(),t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}setText(t){const e=w._isString(t)?t:null==t?"":t+"";return this._setAttr("text",e),this}getWidth(){return this.attrs.width===Je||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}getHeight(){return this.attrs.height===Je||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return w.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(t){var e,i,n,s,r,a,o,h,l,d,c;let g,u=di(),f=this.fontSize();u.save(),u.font=this._getContextFont(),g=u.measureText(t),u.restore();const p=f/100;return{actualBoundingBoxAscent:null!==(e=g.actualBoundingBoxAscent)&&void 0!==e?e:71.58203125*p,actualBoundingBoxDescent:null!==(i=g.actualBoundingBoxDescent)&&void 0!==i?i:0,actualBoundingBoxLeft:null!==(n=g.actualBoundingBoxLeft)&&void 0!==n?n:-7.421875*p,actualBoundingBoxRight:null!==(s=g.actualBoundingBoxRight)&&void 0!==s?s:75.732421875*p,alphabeticBaseline:null!==(r=g.alphabeticBaseline)&&void 0!==r?r:0,emHeightAscent:null!==(a=g.emHeightAscent)&&void 0!==a?a:100*p,emHeightDescent:null!==(o=g.emHeightDescent)&&void 0!==o?o:-20*p,fontBoundingBoxAscent:null!==(h=g.fontBoundingBoxAscent)&&void 0!==h?h:91*p,fontBoundingBoxDescent:null!==(l=g.fontBoundingBoxDescent)&&void 0!==l?l:21*p,hangingBaseline:null!==(d=g.hangingBaseline)&&void 0!==d?d:72.80000305175781*p,ideographicBaseline:null!==(c=g.ideographicBaseline)&&void 0!==c?c:-21*p,width:g.width,height:f}}_getContextFont(){return this.fontStyle()+si+this.fontVariant()+si+(this.fontSize()+"px ")+this.fontFamily().split(",").map(t=>{const e=(t=t.trim()).indexOf(" ")>=0,i=t.indexOf('"')>=0||t.indexOf("'")>=0;return e&&!i&&(t=`"${t}"`),t}).join(", ")}_addTextLine(t){this.align()===ti&&(t=t.trim());const e=this._getTextWidth(t);return this.textArr.push({text:t,width:e,lastInParagraph:!1})}_getTextWidth(t){const e=this.letterSpacing(),i=t.length;return di().measureText(t).width+e*i}_setTextData(){let t=this.text().split("\n"),e=+this.fontSize(),i=0,n=this.lineHeight()*e,s=this.attrs.width,r=this.attrs.height,a=s!==Je&&void 0!==s,o=r!==Je&&void 0!==r,h=this.padding(),l=s-2*h,d=r-2*h,c=0,g=this.wrap(),u="char"!==g&&g!==ri,f=this.ellipsis();this.textArr=[],di().font=this._getContextFont();const p=f?this._getTextWidth("…"):0;for(let e=0,s=t.length;e<s;++e){let r=t[e],h=this._getTextWidth(r);if(a&&h>l)for(;r.length>0;){const t=Qe(r);let e=0,s=t.length,a="",g=0;for(;e<s;){const i=e+s>>>1,r=t.slice(0,i+1).join(""),h=this._getTextWidth(r);(f&&o&&c+n>d?h+p:h)<=l?(e=i+1,a=r,g=h):s=i}if(!a)break;if(u){const i=Qe(a),n=t[i.length];let s;if((n===si||"-"===n)&&g<=l)s=i.length;else{const t=i.lastIndexOf(si),e=i.lastIndexOf("-");s=Math.max(t,e)+1}s>0&&(e=s,a=t.slice(0,e).join(""),g=this._getTextWidth(a))}a=a.trimRight(),this._addTextLine(a),i=Math.max(i,g),c+=n;if(this._shouldHandleEllipsis(c)){this._tryToAddEllipsisToLastLine();break}if(r=t.slice(e).join("").trimLeft(),r.length>0&&(h=this._getTextWidth(r),h<=l)){this._addTextLine(r),c+=n,i=Math.max(i,h);break}}else this._addTextLine(r),c+=n,i=Math.max(i,h),this._shouldHandleEllipsis(c)&&e<s-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),o&&c+n>d)break}this.textHeight=e,this.textWidth=i}_shouldHandleEllipsis(t){const e=+this.fontSize(),i=this.lineHeight()*e,n=this.attrs.height,s=n!==Je&&void 0!==n,r=n-2*this.padding();return!(this.wrap()!==ri)||s&&t+i>r}_tryToAddEllipsisToLastLine(){const t=this.attrs.width,e=t!==Je&&void 0!==t,i=t-2*this.padding(),n=this.ellipsis(),s=this.textArr[this.textArr.length-1];if(s&&n){if(e){this._getTextWidth(s.text+"…")<i||(s.text=s.text.slice(0,s.text.length-3))}this.textArr.splice(this.textArr.length-1,1),this._addTextLine(s.text+"…")}}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){const t=-1!==this.textDecoration().indexOf("underline")||-1!==this.textDecoration().indexOf("line-through"),e=this.hasShadow();return!(!t||!e)||(!(!e||1===this.getAbsoluteOpacity()||!function(){if(null!==li)return li;li=!1;try{const t=document.createElement("canvas");t.width=10,t.height=10;const e=t.getContext("2d");if(e){e.globalAlpha=0,e.shadowColor="black",e.shadowBlur=5,e.shadowOffsetX=5,e.shadowOffsetY=5,e.fillStyle="black",e.font="10px Arial",e.fillText("X",0,10);const t=e.getImageData(0,0,10,10).data;for(let e=3;e<t.length;e+=4)if(t[e]>0){li=!0;break}}}catch(t){}return li}())||super._useBufferCanvas())}}ci.prototype._fillFunc=function(t){this._partialFillStyle&&t.setAttr("fillStyle",this._partialFillStyle),t.fillText(this._partialText,this._partialTextX,this._partialTextY)},ci.prototype._strokeFunc=function(t){t.setAttr("miterLimit",2),this._partialStrokeStyle&&t.setAttr("strokeStyle",this._partialStrokeStyle),t.strokeText(this._partialText,this._partialTextX,this._partialTextY)},ci.prototype.className="Text",ci.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],n(ci),j.overWriteSetter(ci,"width",N()),j.overWriteSetter(ci,"height",N()),j.addGetterSetter(ci,"direction",Ze),j.addGetterSetter(ci,"fontFamily","Arial"),j.addGetterSetter(ci,"fontSize",12,F()),j.addGetterSetter(ci,"fontStyle",ni),j.addGetterSetter(ci,"fontVariant",ni),j.addGetterSetter(ci,"padding",0,F()),j.addGetterSetter(ci,"align",ei),j.addGetterSetter(ci,"verticalAlign","top"),j.addGetterSetter(ci,"lineHeight",1,F()),j.addGetterSetter(ci,"wrap","word"),j.addGetterSetter(ci,"ellipsis",!1,z()),j.addGetterSetter(ci,"letterSpacing",0,F()),j.addGetterSetter(ci,"text","",H()),j.addGetterSetter(ci,"textDecoration",""),j.addGetterSetter(ci,"underlineOffset",void 0,F()),j.addGetterSetter(ci,"charRenderFunc",void 0);const gi="normal";function ui(t){t.fillText(this.partialText,0,0)}function fi(t){t.strokeText(this.partialText,0,0)}class pi extends Zt{constructor(t){super(t),this.dummyCanvas=w.createCanvasElement(),this.dataArray=[],this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute(),this._setTextData()}),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva directionChange.konva",this._setTextData),this._setTextData()}_getTextPathLength(){return Ee.getPathLength(this.dataArray)}_getPointAtLength(t){if(!this.attrs.data)return null;return t>this.pathLength?null:Ee.getPointAtLengthOfDataArray(t,this.dataArray)}_readDataAttribute(){this.dataArray=Ee.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(t){t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",this.textBaseline()),t.setAttr("textAlign","left"),t.save();const e=this.textDecoration(),i=this.fill(),n=this.fontSize(),s=this.glyphInfo,r=-1!==e.indexOf("underline"),a=-1!==e.indexOf("line-through");r&&t.beginPath();for(let e=0;e<s.length;e++){t.save();const i=s[e].p0;t.translate(i.x,i.y),t.rotate(s[e].rotation),this.partialText=s[e].text,t.fillStrokeShape(this),r&&(0===e&&t.moveTo(0,n/2+1),t.lineTo(s[e].width,n/2+1)),t.restore()}if(r&&(t.strokeStyle=i,t.lineWidth=n/20,t.stroke()),a){t.beginPath();for(let e=0;e<s.length;e++){t.save();const i=s[e].p0;t.translate(i.x,i.y),t.rotate(s[e].rotation),0===e&&t.moveTo(0,0),t.lineTo(s[e].width,0),t.restore()}t.strokeStyle=i,t.lineWidth=n/20,t.stroke()}t.restore()}_hitFunc(t){t.beginPath();const e=this.glyphInfo;if(e.length>=1){const i=e[0].p0;t.moveTo(i.x,i.y)}for(let i=0;i<e.length;i++){const n=e[i].p1;t.lineTo(n.x,n.y)}t.setAttr("lineWidth",this.fontSize()),t.setAttr("strokeStyle",this.colorKey),t.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return w.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(t){return ci.prototype.setText.call(this,t)}_getContextFont(){return ci.prototype._getContextFont.call(this)}_getTextSize(t){const e=this.dummyCanvas.getContext("2d");e.save(),e.font=this._getContextFont();const i=e.measureText(t);return e.restore(),{width:i.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const t=Qe(this.text());"rtl"===this.direction()&&t.reverse();const e=[];let i=0;for(let n=0;n<t.length;n++)e.push({char:t[n],width:this._getTextSize(t[n]).width}),i+=e[n].width;const{width:n,height:s}=this._getTextSize(this.attrs.text);if(this.textWidth=i,this.textHeight=s,this.glyphInfo=[],!this.attrs.data)return null;const r=this.letterSpacing(),a=this.align(),o=this.kerningFunc(),h=Math.max(0,i-n),l=Math.max(this.textWidth+((this.attrs.text||"").length-1)*r,0);let d=0;"center"===a&&(d=Math.max(0,this.pathLength/2-l/2)),"right"===a&&(d=Math.max(0,this.pathLength-l));let c=d;for(let i=0;i<e.length;i++){const n=this._getPointAtLength(c);if(!n)return;const s=e[i].char;let d=e[i].width+r;if(" "===s&&"justify"===a){const t=this.text().split(" ").length-1;d+=(this.pathLength-l)/t}const g=c+d,u=this._getPointAtLength(g>this.pathLength&&g-this.pathLength<=h?this.pathLength:g);if(!u)return;const f=Ee.getLineLength(n.x,n.y,u.x,u.y);let p=0;if(o)try{p=o(e[i-1].char,s)*this.fontSize()}catch(t){p=0}n.x+=p,u.x+=p,this.textWidth+=p;const m=Ee.getPointOnLine(p+f/2,n.x,n.y,u.x,u.y),_=Math.atan2(u.y-n.y,u.x-n.x);this.glyphInfo.push({transposeX:m.x,transposeY:m.y,text:t[i],rotation:_,p0:n,p1:u,width:f}),c+=d}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};const t=[];this.glyphInfo.forEach(function(e){t.push(e.p0.x),t.push(e.p0.y),t.push(e.p1.x),t.push(e.p1.y)});let e,i,n=t[0]||0,s=t[0]||0,r=t[1]||0,a=t[1]||0;for(let o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],n=Math.min(n,e),s=Math.max(s,e),r=Math.min(r,i),a=Math.max(a,i);const o=this.fontSize();return{x:n-o/2,y:r-o/2,width:s-n+o,height:a-r+o}}destroy(){return w.releaseCanvas(this.dummyCanvas),super.destroy()}}pi.prototype._fillFunc=ui,pi.prototype._strokeFunc=fi,pi.prototype._fillFuncHit=ui,pi.prototype._strokeFuncHit=fi,pi.prototype.className="TextPath",pi.prototype._attrsAffectingSize=["text","fontSize","data"],n(pi),j.addGetterSetter(pi,"data"),j.addGetterSetter(pi,"fontFamily","Arial"),j.addGetterSetter(pi,"fontSize",12,F()),j.addGetterSetter(pi,"fontStyle",gi),j.addGetterSetter(pi,"align","left"),j.addGetterSetter(pi,"letterSpacing",0,F()),j.addGetterSetter(pi,"textBaseline","middle"),j.addGetterSetter(pi,"fontVariant",gi),j.addGetterSetter(pi,"text",""),j.addGetterSetter(pi,"textDecoration",""),j.addGetterSetter(pi,"kerningFunc",void 0),j.addGetterSetter(pi,"direction","inherit");const mi="tr-konva",_i=["resizeEnabledChange","rotateAnchorOffsetChange","rotateAnchorAngleChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map(t=>t+`.${mi}`).join(" "),yi="nodesRect",vi=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange","draggableChange"],xi={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},bi="ontouchstart"in i._global;const Si=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function wi(t,e,i){const n=i.x+(t.x-i.x)*Math.cos(e)-(t.y-i.y)*Math.sin(e),s=i.y+(t.x-i.x)*Math.sin(e)+(t.y-i.y)*Math.cos(e);return{...t,rotation:t.rotation+e,x:n,y:s}}function Ci(t,e){const i=function(t){return{x:t.x+t.width/2*Math.cos(t.rotation)+t.height/2*Math.sin(-t.rotation),y:t.y+t.height/2*Math.cos(t.rotation)+t.width/2*Math.sin(t.rotation)}}(t);return wi(t,e,i)}let ki=0;class Pi extends se{constructor(t){super(t),this._movingAnchorName=null,this._transforming=!1,this._transformWindow=null,this._elementsCreated=!1,this._updateScheduled=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(_i,this.update),this.getNode()&&this.update()}attachTo(t){return this.setNode(t),this}setNode(t){return w.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([t])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return mi+this._id}setNodes(t=[]){this._nodes&&this._nodes.length&&this.detach();const e=t.filter(t=>!t.isAncestorOf(this)||(w.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1));this._nodes=t=e,1===t.length&&this.useSingleNodeRotation()?this.rotation(t[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(t=>{const e=()=>{this._transforming||(1===this.nodes().length&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),this.isDragging()||this._scheduleUpdate())};if(t._attrsAffectingSize.length){const i=t._attrsAffectingSize.map(t=>t+"Change."+this._getEventNamespace()).join(" ");t.on(i,e)}t.on(vi.map(t=>t+`.${this._getEventNamespace()}`).join(" "),e),t.on(`absoluteTransformChange.${this._getEventNamespace()}`,e),this._proxyDrag(t)}),this._resetTransformCache();return!!this.findOne(".top-left")&&this.update(),this}_proxyDrag(t){let e;t.on(`dragstart.${this._getEventNamespace()}`,i=>{e=t.getAbsolutePosition(),this.isDragging()||t===this.findOne(".back")||this.startDrag(i,!1)}),t.on(`dragmove.${this._getEventNamespace()}`,i=>{if(!e)return;const n=t.getAbsolutePosition(),s=n.x-e.x,r=n.y-e.y;this.nodes().forEach(e=>{if(e===t)return;if(e.isDragging())return;const n=e.getAbsolutePosition();e.setAbsolutePosition({x:n.x+s,y:n.y+r}),e.startDrag(i)}),e=null})}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach(t=>{t.off("."+this._getEventNamespace())}),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(yi),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(yi,this.__getNodeRect)}__getNodeShape(t,e=this.rotation(),n){const s=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),r=t.getAbsoluteScale(n),a=t.getAbsolutePosition(n),o=s.x*r.x-t.offsetX()*r.x,h=s.y*r.y-t.offsetY()*r.y,l=(i.getAngle(t.getAbsoluteRotation())+2*Math.PI)%(2*Math.PI);return wi({x:a.x+o*Math.cos(l)+h*Math.sin(-l),y:a.y+h*Math.cos(l)+o*Math.sin(l),width:s.width*r.x,height:s.height*r.y,rotation:l},-i.getAngle(e),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};const t=[];this.nodes().map(e=>{const i=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),n=[{x:i.x,y:i.y},{x:i.x+i.width,y:i.y},{x:i.x+i.width,y:i.y+i.height},{x:i.x,y:i.y+i.height}],s=e.getAbsoluteTransform();n.forEach(function(e){const i=s.point(e);t.push(i)})});const e=new r;e.rotate(-i.getAngle(this.rotation()));let n=1/0,s=1/0,a=-1/0,o=-1/0;t.forEach(function(t){const i=e.point(t);void 0===n&&(n=a=i.x,s=o=i.y),n=Math.min(n,i.x),s=Math.min(s,i.y),a=Math.max(a,i.x),o=Math.max(o,i.y)}),e.invert();const h=e.point({x:n,y:s});return{x:h.x,y:h.y,width:a-n,height:o-s,rotation:i.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),Si.forEach(t=>{this._createAnchor(t)}),this._createAnchor("rotater"),this._elementsCreated=!0}_createAnchor(t){const e=new je({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:t+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:bi?10:"auto"}),n=this;e.on("mousedown touchstart",function(t){n._handleMouseDown(t)}),e.on("dragstart",t=>{e.stopDrag(),t.cancelBubble=!0}),e.on("dragend",t=>{t.cancelBubble=!0}),e.on("mouseenter",()=>{const n=i.getAngle(this.rotation()),s=this.rotateAnchorCursor(),r=function(t,e,i){if("rotater"===t)return i;e+=w.degToRad(xi[t]||0);const n=(w.radToDeg(e)%360+360)%360;return w._inRange(n,337.5,360)||w._inRange(n,0,22.5)?"ns-resize":w._inRange(n,22.5,67.5)?"nesw-resize":w._inRange(n,67.5,112.5)?"ew-resize":w._inRange(n,112.5,157.5)?"nwse-resize":w._inRange(n,157.5,202.5)?"ns-resize":w._inRange(n,202.5,247.5)?"nesw-resize":w._inRange(n,247.5,292.5)?"ew-resize":w._inRange(n,292.5,337.5)?"nwse-resize":(w.error("Transformer has unknown angle for cursor detection: "+n),"pointer")}(t,n,s);e.getStage().content&&(e.getStage().content.style.cursor=r),this._cursorChange=!0}),e.on("mouseout",()=>{e.getStage().content&&(e.getStage().content.style.cursor=""),this._cursorChange=!1}),this.add(e)}_createBack(){const t=new Zt({name:"back",width:0,height:0,sceneFunc(t,e){const i=e.getParent(),n=i.padding(),s=e.width(),r=e.height();if(t.beginPath(),t.rect(-n,-n,s+2*n,r+2*n),i.rotateEnabled()&&i.rotateLineVisible()){const e=i.rotateAnchorAngle(),n=i.rotateAnchorOffset(),a=w.degToRad(e),o=Math.sin(a),h=-Math.cos(a),l=s/2,d=r/2;let c=1/0;h<0?c=Math.min(c,-d/h):h>0&&(c=Math.min(c,(r-d)/h)),o<0?c=Math.min(c,-l/o):o>0&&(c=Math.min(c,(s-l)/o));const g=l+o*c,u=d+h*c,f=w._sign(r),p=g+o*n*f,m=u+h*n*f;t.moveTo(g,u),t.lineTo(p,m)}t.fillStrokeShape(e)},hitFunc:(t,e)=>{if(!this.shouldOverdrawWholeArea())return;const i=this.padding();t.beginPath(),t.rect(-i,-i,e.width()+2*i,e.height()+2*i),t.fillStrokeShape(e)}});this.add(t),this._proxyDrag(t),t.on("dragstart",t=>{t.cancelBubble=!0}),t.on("dragmove",t=>{t.cancelBubble=!0}),t.on("dragend",t=>{t.cancelBubble=!0}),this.on("dragmove",t=>{this.update()})}_handleMouseDown(t){var e;if(this._transforming)return;this._movingAnchorName=t.target.name().split(" ")[0];const i=this._getNodeRect(),n=i.width,s=i.height,r=Math.sqrt(Math.pow(n,2)+Math.pow(s,2));this.sin=Math.abs(s/r),this.cos=Math.abs(n/r);const a=null===(e=this.getStage())||void 0===e?void 0:e._getOwnerWindow();this._transformWindow=a||null,a&&(a.addEventListener("mousemove",this._handleMouseMove),a.addEventListener("touchmove",this._handleMouseMove),a.addEventListener("mouseup",this._handleMouseUp,!0),a.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;const o=t.target.getAbsolutePosition(),h=t.target.getStage().getPointerPosition();this._anchorDragOffset={x:h.x-o.x,y:h.y-o.y},ki++,this._fire("transformstart",{evt:t.evt,target:this.getNode()}),this._nodes.forEach(e=>{e._fire("transformstart",{evt:t.evt,target:e})})}_handleMouseMove(t){let e,n,s;const r=this.findOne("."+this._movingAnchorName),a=r.getStage();a.setPointersPositions(t);const o=a.getPointerPosition();let h={x:o.x-this._anchorDragOffset.x,y:o.y-this._anchorDragOffset.y};const l=r.getAbsolutePosition();this.anchorDragBoundFunc()&&(h=this.anchorDragBoundFunc()(l,h,t)),r.setAbsolutePosition(h);const d=r.getAbsolutePosition();if(l.x===d.x&&l.y===d.y)return;if("rotater"===this._movingAnchorName){const s=this._getNodeRect();e=r.x()-s.width/2,n=-r.y()+s.height/2;const a=i.getAngle(this.rotateAnchorAngle());let o=Math.atan2(-n,e)+Math.PI/2-a;s.height<0&&(o-=Math.PI);const h=i.getAngle(this.rotation())+o,l=i.getAngle(this.rotationSnapTolerance()),d=function(t,e,n){let s=e;for(let r=0;r<t.length;r++){const a=i.getAngle(t[r]),o=Math.abs(a-e)%(2*Math.PI);Math.min(o,2*Math.PI-o)<n&&(s=a)}return s}(this.rotationSnaps(),h,l),c=Ci(s,d-s.rotation);return void this._fitNodesInto(c,t)}const c=this.shiftBehavior();let g;g="inverted"===c?this.keepRatio()&&!t.shiftKey:"none"===c?this.keepRatio():this.keepRatio()||t.shiftKey;let u=this.centeredScaling()||t.altKey,f=!1;if("top-left"===this._movingAnchorName){if(g){f=!0;const t=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};s=Math.sqrt(Math.pow(t.x-r.x(),2)+Math.pow(t.y-r.y(),2));const i=this.findOne(".top-left").x()>t.x?-1:1,a=this.findOne(".top-left").y()>t.y?-1:1;e=s*this.cos*i,n=s*this.sin*a,this.findOne(".top-left").x(t.x-e),this.findOne(".top-left").y(t.y-n)}}else if("top-center"===this._movingAnchorName)this.findOne(".top-left").y(r.y());else if("top-right"===this._movingAnchorName){if(g){f=!0;const t=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};s=Math.sqrt(Math.pow(r.x()-t.x,2)+Math.pow(t.y-r.y(),2));const i=this.findOne(".top-right").x()<t.x?-1:1,a=this.findOne(".top-right").y()>t.y?-1:1;e=s*this.cos*i,n=s*this.sin*a,this.findOne(".top-right").x(t.x+e),this.findOne(".top-right").y(t.y-n)}var p=r.position();this.findOne(".top-left").y(p.y),this.findOne(".bottom-right").x(p.x)}else if("middle-left"===this._movingAnchorName)this.findOne(".top-left").x(r.x());else if("middle-right"===this._movingAnchorName)this.findOne(".bottom-right").x(r.x());else if("bottom-left"===this._movingAnchorName){if(g){f=!0;const t=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};s=Math.sqrt(Math.pow(t.x-r.x(),2)+Math.pow(r.y()-t.y,2));const i=t.x<r.x()?-1:1,a=r.y()<t.y?-1:1;e=s*this.cos*i,n=s*this.sin*a,r.x(t.x-e),r.y(t.y+n)}p=r.position(),this.findOne(".top-left").x(p.x),this.findOne(".bottom-right").y(p.y)}else if("bottom-center"===this._movingAnchorName)this.findOne(".bottom-right").y(r.y());else if("bottom-right"===this._movingAnchorName){if(g){f=!0;const t=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};s=Math.sqrt(Math.pow(r.x()-t.x,2)+Math.pow(r.y()-t.y,2));const i=this.findOne(".bottom-right").x()<t.x?-1:1,a=this.findOne(".bottom-right").y()<t.y?-1:1;e=s*this.cos*i,n=s*this.sin*a,this.findOne(".bottom-right").x(t.x+e),this.findOne(".bottom-right").y(t.y+n)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(u=this.centeredScaling()||t.altKey,u){const t=this.findOne(".top-left"),e=this.findOne(".bottom-right"),i=t.x(),n=t.y(),s=this.getWidth()-e.x(),r=this.getHeight()-e.y();e.move({x:-i,y:-n}),t.move({x:s,y:r})}const m=this.findOne(".top-left").getAbsolutePosition();e=m.x,n=m.y;const _=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),y=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:e,y:n,width:_,height:y,rotation:i.getAngle(this.rotation())},t,f)}_handleMouseUp(t){this._removeEvents(t)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(t){var e;if(this._transforming){this._transforming=!1;const i=this._transformWindow;this._transformWindow=null,i&&(i.removeEventListener("mousemove",this._handleMouseMove),i.removeEventListener("touchmove",this._handleMouseMove),i.removeEventListener("mouseup",this._handleMouseUp,!0),i.removeEventListener("touchend",this._handleMouseUp,!0));const n=this.getNode();ki--,this._fire("transformend",{evt:t,target:n}),null===(e=this.getLayer())||void 0===e||e.batchDraw(),n&&this._nodes.forEach(e=>{var i;e._fire("transformend",{evt:t,target:e}),null===(i=e.getLayer())||void 0===i||i.batchDraw()}),this._movingAnchorName=null}}_fitNodesInto(t,e,n=!1){const s=i.autoDrawEnabled;i.autoDrawEnabled=!1;try{return this._doFitNodesInto(t,e,n)}finally{i.autoDrawEnabled=s}}_doFitNodesInto(t,e,n=!1){const s=this._getNodeRect();if(w._inRange(t.width,2*-this.padding()-1,1))return void this.update();if(w._inRange(t.height,2*-this.padding()-1,1))return void this.update();const a=new r;a.rotate(i.getAngle(this.rotation()));const o=n?0:2*this.padding();let h=null,l=null;if(this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("left")>=0){const e=a.point({x:-o,y:0});t.x+=e.x,t.y+=e.y,t.width+=o,h={axis:"width",from:"left",to:"right",offset:e}}else if(this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("right")>=0){const e=a.point({x:o,y:0});t.width+=o,h={axis:"width",from:"right",to:"left",offset:e}}if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("top")>=0){const e=a.point({x:0,y:-o});t.x+=e.x,t.y+=e.y,t.height+=o,l={axis:"height",from:"top",to:"bottom",offset:e}}else if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const e=a.point({x:0,y:o});t.height+=o,l={axis:"height",from:"bottom",to:"top",offset:e}}if(this.boundBoxFunc()){const e=this.boundBoxFunc()(s,t);e?t=e:w.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}for(const e of[h,l])e&&t[e.axis]<0&&this._movingAnchorName&&(this._movingAnchorName=this._movingAnchorName.replace(e.from,e.to),this._anchorDragOffset.x-=e.offset.x,this._anchorDragOffset.y-=e.offset.y);const d=1e7,c=new r;c.translate(s.x,s.y),c.rotate(s.rotation),c.scale(s.width/d,s.height/d);const g=new r,u=t.width/d,f=t.height/d;!1===this.flipEnabled()?(g.translate(t.x,t.y),g.rotate(t.rotation),g.translate(t.width<0?t.width:0,t.height<0?t.height:0),g.scale(Math.abs(u),Math.abs(f))):(g.translate(t.x,t.y),g.rotate(t.rotation),g.scale(u,f));const p=g.multiply(c.invert()),m=new Set;this._nodes.forEach(t=>{if(!t.getStage())return;const e=t.getParent().getAbsoluteTransform(),i=t.getTransform().copy();i.translate(t.offsetX(),t.offsetY());const n=new r;n.multiply(e.copy().invert()).multiply(p).multiply(e).multiply(i);const s=n.decompose();t.setAttrs(s);const a=t.getLayer();a&&m.add(a)}),this.rotation(w._getRotation(t.rotation)),this._nodes.forEach(t=>{this._fire("transform",{evt:e,target:t}),t._fire("transform",{evt:e,target:t})}),this._resetTransformCache(),this.update(),m.add(this.getLayer()),m.forEach(t=>t&&t.batchDraw())}_scheduleUpdate(){this._updateScheduled||(this._updateScheduled=!0,at._runAfterAbsTransformCascade(()=>{var t;this._updateScheduled=!1,!(null===(t=this._nodes)||void 0===t?void 0:t.length)||this._transforming||this.isDragging()||this.update()}))}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(t,e){this.findOne(t).setAttrs(e)}update(){var t;const e=this._getNodeRect();this.rotation(w._getRotation(e.rotation));const i=e.width,n=e.height,s=this.enabledAnchors(),r=this.resizeEnabled(),a=this.padding(),o=this.anchorSize(),h=this.find("._anchor");h.forEach(t=>{t.setAttrs({width:o,height:o,offsetX:o/2,offsetY:o/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:o/2+a,offsetY:o/2+a,visible:r&&s.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:i/2,y:0,offsetY:o/2+a,visible:r&&s.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:i,y:0,offsetX:o/2-a,offsetY:o/2+a,visible:r&&s.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:n/2,offsetX:o/2+a,visible:r&&s.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:i,y:n/2,offsetX:o/2-a,visible:r&&s.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:n,offsetX:o/2+a,offsetY:o/2-a,visible:r&&s.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:i/2,y:n,offsetY:o/2-a,visible:r&&s.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:i,y:n,offsetX:o/2-a,offsetY:o/2-a,visible:r&&s.indexOf("bottom-right")>=0});const l=this.rotateAnchorAngle(),d=this.rotateAnchorOffset(),c=w.degToRad(l),g=Math.sin(c),u=-Math.cos(c),f=i/2,p=n/2;let m=1/0;u<0?m=Math.min(m,-p/u):u>0&&(m=Math.min(m,(n-p)/u)),g<0?m=Math.min(m,-f/g):g>0&&(m=Math.min(m,(i-f)/g));const _=f+g*m,y=p+u*m,v=w._sign(n);this._batchChangeChild(".rotater",{x:_+g*d*v,y:y+u*d*v-a*u,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:i,height:n,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),draggable:this.nodes().some(t=>t.draggable()),x:0,y:0});const x=this.anchorStyleFunc();x&&h.forEach(t=>{x(t)}),null===(t=this.getLayer())||void 0===t||t.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();const t=this.findOne("."+this._movingAnchorName);t&&t.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),se.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}add(...t){return this._elementsCreated?(w.error("You cannot add external nodes to the Transformer. Use tr.nodes([node]) instead."),this):super.add(...t)}toObject(){return at.prototype.toObject.call(this)}clone(t){return at.prototype.clone.call(this,t)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}}Pi.isTransforming=()=>ki>0,Pi.prototype.className="Transformer",n(Pi),j.addGetterSetter(Pi,"enabledAnchors",Si,function(t){return t instanceof Array||w.warn("enabledAnchors value should be an array"),t instanceof Array&&t.forEach(function(t){-1===Si.indexOf(t)&&w.warn("Unknown anchor name: "+t+". Available names are: "+Si.join(", "))}),t||[]}),j.addGetterSetter(Pi,"flipEnabled",!0,z()),j.addGetterSetter(Pi,"resizeEnabled",!0),j.addGetterSetter(Pi,"anchorSize",10,F()),j.addGetterSetter(Pi,"rotateEnabled",!0),j.addGetterSetter(Pi,"rotateLineVisible",!0),j.addGetterSetter(Pi,"rotationSnaps",[]),j.addGetterSetter(Pi,"rotateAnchorOffset",50,F()),j.addGetterSetter(Pi,"rotateAnchorAngle",0,F()),j.addGetterSetter(Pi,"rotateAnchorCursor","crosshair"),j.addGetterSetter(Pi,"rotationSnapTolerance",5,F()),j.addGetterSetter(Pi,"borderEnabled",!0),j.addGetterSetter(Pi,"anchorStroke","rgb(0, 161, 255)"),j.addGetterSetter(Pi,"anchorStrokeWidth",1,F()),j.addGetterSetter(Pi,"anchorFill","white"),j.addGetterSetter(Pi,"anchorCornerRadius",0,F()),j.addGetterSetter(Pi,"borderStroke","rgb(0, 161, 255)"),j.addGetterSetter(Pi,"borderStrokeWidth",1,F()),j.addGetterSetter(Pi,"borderDash"),j.addGetterSetter(Pi,"keepRatio",!0),j.addGetterSetter(Pi,"shiftBehavior","default"),j.addGetterSetter(Pi,"centeredScaling",!1),j.addGetterSetter(Pi,"ignoreStroke",!1),j.addGetterSetter(Pi,"padding",0,F()),j.addGetterSetter(Pi,"nodes"),j.addGetterSetter(Pi,"node"),j.addGetterSetter(Pi,"boundBoxFunc"),j.addGetterSetter(Pi,"anchorDragBoundFunc"),j.addGetterSetter(Pi,"anchorStyleFunc"),j.addGetterSetter(Pi,"shouldOverdrawWholeArea",!1),j.addGetterSetter(Pi,"useSingleNodeRotation",!0),j.backCompat(Pi,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});class Ai extends Zt{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.radius(),0,i.getAngle(this.angle()),this.clockwise()),t.lineTo(0,0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}}
|
|
12
|
+
*/const t=Math.PI/180;const e="undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},i={_global:e,version:"10.5.0",isBrowser:"undefined"!=typeof window&&("[object Window]"==={}.toString.call(window)||"[object global]"==={}.toString.call(window)),isUnminified:/param/.test(function(t){}.toString()),dblClickWindow:400,getAngle:e=>i.angleDeg?e*t:e,enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_renderBackend:"web",legacyTextRendering:!1,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:()=>i.DD.isDragging,isTransforming(){var t,e;return null!==(e=null===(t=i.Transformer)||void 0===t?void 0:t.isTransforming())&&void 0!==e&&e},isDragReady:()=>!!i.DD.node,releaseCanvasOnDestroy:!0,document:e.document,_injectGlobal(t){void 0!==e.Konva&&console.error("Several Konva instances detected. It is not recommended to use multiple Konva instances in the same environment."),e.Konva=t}},n=t=>{i[t.prototype.getClassName()]=t};i._injectGlobal(i);const s=()=>{if("undefined"==typeof document)throw new Error('Konva.js unsupported environment.\n\nLooks like you are trying to use Konva.js in Node.js environment (or in a Web Worker), because "document" object is undefined.\n\nTo use Konva.js in Node.js environment, you need to use the "canvas-backend" or "skia-backend" module.\n\nbash: npm install canvas\njs: import "konva/canvas-backend";\n\nor\n\nbash: npm install skia-canvas\njs: import "konva/skia-backend";\n')};class r{constructor(t){this.dirty=!1,this.m=t?t.slice():[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new r(this.m)}copyInto(t){t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5]}point(t){const e=this.m;return{x:e[0]*t.x+e[2]*t.y+e[4],y:e[1]*t.x+e[3]*t.y+e[5]}}translate(t,e){return this.m[4]+=this.m[0]*t+this.m[2]*e,this.m[5]+=this.m[1]*t+this.m[3]*e,this}scale(t,e){return this.m[0]*=t,this.m[1]*=t,this.m[2]*=e,this.m[3]*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),n=this.m[0]*e+this.m[2]*i,s=this.m[1]*e+this.m[3]*i,r=this.m[0]*-i+this.m[2]*e,a=this.m[1]*-i+this.m[3]*e;return this.m[0]=n,this.m[1]=s,this.m[2]=r,this.m[3]=a,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(t,e){const i=this.m[0]+this.m[2]*e,n=this.m[1]+this.m[3]*e,s=this.m[2]+this.m[0]*t,r=this.m[3]+this.m[1]*t;return this.m[0]=i,this.m[1]=n,this.m[2]=s,this.m[3]=r,this}multiply(t){const e=this.m[0]*t.m[0]+this.m[2]*t.m[1],i=this.m[1]*t.m[0]+this.m[3]*t.m[1],n=this.m[0]*t.m[2]+this.m[2]*t.m[3],s=this.m[1]*t.m[2]+this.m[3]*t.m[3],r=this.m[0]*t.m[4]+this.m[2]*t.m[5]+this.m[4],a=this.m[1]*t.m[4]+this.m[3]*t.m[5]+this.m[5];return this.m[0]=e,this.m[1]=i,this.m[2]=n,this.m[3]=s,this.m[4]=r,this.m[5]=a,this}isInvertible(){return this.m[0]*this.m[3]-this.m[1]*this.m[2]!==0}invert(){const t=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),e=this.m[3]*t,i=-this.m[1]*t,n=-this.m[2]*t,s=this.m[0]*t,r=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),a=t*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=e,this.m[1]=i,this.m[2]=n,this.m[3]=s,this.m[4]=r,this.m[5]=a,this}getMatrix(){return this.m}decompose(){const t=this.m[0],e=this.m[1],i=this.m[2],n=this.m[3],s=t*n-e*i,r={x:this.m[4],y:this.m[5],rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!=t||0!=e){const a=Math.sqrt(t*t+e*e);r.rotation=e>0?Math.acos(t/a):-Math.acos(t/a),r.scaleX=a,r.scaleY=s/a,r.skewX=s&&(t*i+e*n)/s,r.skewY=0}else if(0!=i||0!=n){const a=Math.sqrt(i*i+n*n);r.rotation=Math.PI/2-(n>0?Math.acos(-i/a):-Math.acos(i/a)),r.scaleX=s/a,r.scaleY=a,r.skewX=0,r.skewY=s&&(t*i+e*n)/s}return r.rotation=C._getRotation(r.rotation),r}}const a=Math.PI/180,o=180/Math.PI,h="Konva error: ",l={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[0,0,0,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};let c=null;const d="undefined"!=typeof window?window:{},g=new WeakMap,u=new Map,f=Object.getPrototypeOf(Int8Array),p=t=>{const e=t.trim();return-1===e.indexOf(",")?e.split(/\s*\/\s*|\s+/):e.split(/\s*,\s*/)},m="[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:e[+-]?\\d+)?",_=new RegExp(`^(${m})(%?)$`,"i"),v=(t,e)=>{const i=_.exec(t);return i?i[2]?Number(i[1])/100*e:Number(i[1]):NaN},y=/^#[0-9a-f]+$/i,x=t=>Math.min(Math.max(t,0),1),b=new RegExp(`^(${m})(deg|grad|rad|turn)?$`,"i"),S={deg:1,grad:.9,rad:o,turn:360};function w(t,e){return Math.min(Math.max(t||0,0),e)}const C={_isElement:t=>!(!t||1!=t.nodeType),_isFunction:t=>!!(t&&t.constructor&&t.call&&t.apply),_isPlainObject:t=>!!t&&t.constructor===Object,_isArray:t=>"[object Array]"===Object.prototype.toString.call(t),_isNumber:t=>"[object Number]"===Object.prototype.toString.call(t)&&!isNaN(t)&&isFinite(t),_isString:t=>"[object String]"===Object.prototype.toString.call(t),_isBoolean:t=>"[object Boolean]"===Object.prototype.toString.call(t),isObject:t=>t instanceof Object,isValidSelector(t){if("string"!=typeof t)return!1;const e=t[0];return"#"===e||"."===e||e===e.toUpperCase()},_sign:t=>0===t||t>0?1:-1,requestAnimFrame(t,e){const i=e&&!e.closed&&e||d;let n=g.get(i);n||(n=[],g.set(i,n),((t,e)=>{"function"==typeof t.requestAnimationFrame?t.requestAnimationFrame(e):"undefined"!=typeof requestAnimationFrame?requestAnimationFrame(e):setTimeout(e,16)})(i,function(){g.delete(i),n.forEach(function(t){t()})})),n.push(t)},createCanvasElement(){s();const t=document.createElement("canvas");try{t.style=t.style||{}}catch(t){}return t},createImageElement:()=>(s(),document.createElement("img")),_isInDocument:t=>!!t.isConnected,_urlToImage(t,e){const i=C.createImageElement();i.onload=function(){e(i)},i.src=t},_rgbToHex:(t,e,i)=>((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1),_hexToRgb(t){t=t.replace("#","");const e=parseInt(t,16);return{r:e>>16&255,g:e>>8&255,b:255&e}},getRandomColor(){let t=(16777215*Math.random()|0).toString(16);for(;t.length<6;)t="0"+t;return"#"+t},isCanvasFarblingActive(){if(null!==c)return c;if("undefined"==typeof document)return c=!1,!1;const t=this.createCanvasElement();t.width=10,t.height=10;const e=t.getContext("2d",{willReadFrequently:!0});e.clearRect(0,0,10,10),e.fillStyle="#282828",e.fillRect(0,0,10,10);const i=e.getImageData(0,0,10,10).data;let n=!1;for(let t=0;t<100;t++)if(40!==i[4*t]||40!==i[4*t+1]||40!==i[4*t+2]||255!==i[4*t+3]){n=!0;break}return c=n,this.releaseCanvas(t),c},getHitColor(){const t=()=>256*Math.random()|0;return this.getHitColorKey(t(),t(),t())},getHitColorKey(t,e,i){const n=this.isCanvasFarblingActive()?5:3,s=t=>Math.round(t/n)*n;return"#"+this._rgbToHex(s(t),s(e),s(i))},getSnappedHexColor(t){const{r:e,g:i,b:n}=this._hexToRgb(t);return this.getHitColorKey(e,i,n)},getRGB(t){var e;const{r:i=0,g:n=0,b:s=0}=null!==(e=C.colorToRGBA(t))&&void 0!==e?e:{};return{r:i,g:n,b:s}},colorToRGBA(t){t=(t||"").trim()||"black";const e=C._namedColorToRBA(t)||C._hex3ColorToRGBA(t)||C._hex4ColorToRGBA(t)||C._hex6ColorToRGBA(t)||C._hex8ColorToRGBA(t)||C._rgbColorToRGBA(t)||C._hslColorToRGBA(t);if(e&&[e.r,e.g,e.b,e.a].every(C._isNumber))return e},_namedColorToRBA(t){const e=l[t.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:e.length>3?e[3]:1}:null},_rgbColorToRGBA(t){const e=/^rgba?\(([^)]*)\)$/i.exec(t);if(!e)return;const i=p(e[1]);return i.length<3||i.length>4?void 0:{r:v(i[0],255),g:v(i[1],255),b:v(i[2],255),a:i.length>3?v(i[3],1):1}},_hex8ColorToRGBA(t){if(9===t.length&&y.test(t))return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:parseInt(t.slice(7,9),16)/255}},_hex6ColorToRGBA(t){if(7===t.length&&y.test(t))return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:1}},_hex4ColorToRGBA(t){if(5===t.length&&y.test(t))return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:parseInt(t[4]+t[4],16)/255}},_hex3ColorToRGBA(t){if(4===t.length&&y.test(t))return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:1}},_hslColorToRGBA(t){const e=/^hsla?\(([^)]*)\)$/i.exec(t);if(!e)return;const i=p(e[1]);if(i.length<3||i.length>4)return;const n=b.exec(i[0]);if(!n)return;const s=n[2],r=Number(n[1])*(s?S[s.toLowerCase()]:1);if(!isFinite(r))return;const a=(r%360+360)%360/360,o=x(v(i[1],100)/100),h=x(v(i[2],100)/100),l=i.length>3?v(i[3],1):1,c=h<.5?h*(1+o):h+o-h*o,d=2*h-c,g=[0,0,0];for(let t=0;t<3;t++){let e,i=a+1/3*-(t-1);i<0&&i++,i>1&&i--,e=6*i<1?d+6*(c-d)*i:2*i<1?c:3*i<2?d+(c-d)*(2/3-i)*6:d,g[t]=255*e}return{r:Math.round(g[0]),g:Math.round(g[1]),b:Math.round(g[2]),a:l}},_getPointsRect(t){let e=1/0,i=1/0,n=-1/0,s=-1/0;for(let r=0;r<t.length;r+=2){const a=t[r],o=t[r+1];isNaN(a)||(e=Math.min(e,a),n=Math.max(n,a)),isNaN(o)||(i=Math.min(i,o),s=Math.max(s,o))}return isFinite(e+i)?{x:e,y:i,width:n-e,height:s-i}:{x:0,y:0,width:0,height:0}},haveIntersection:(t,e)=>!(e.x>t.x+t.width||e.x+e.width<t.x||e.y>t.y+t.height||e.y+e.height<t.y),cloneObject(t){const e={};for(const i in t)e[i]=C._cloneValue(t[i]);return e},_cloneValue:t=>C._isArray(t)?t.some(t=>"object"==typeof t)?t.map(C._cloneValue):t.slice():C._isPlainObject(t)?C.cloneObject(t):t instanceof f?t.slice():t,cloneArray:t=>t.slice(0),degToRad:t=>t*a,radToDeg:t=>t*o,_getRotation:t=>i.angleDeg?C.radToDeg(t):t,_capitalize(t){const e=u.get(t);if(void 0!==e)return e;const i=t.charAt(0).toUpperCase()+t.slice(1);return u.set(t,i),i},throw(t){throw new Error(h+t)},error(t){console.error(h+t)},warn(t){i.showWarnings&&console.warn("Konva warning: "+t)},_batchEvents(t,e){if(!t)return e();let i=!1,n=!0;try{t(()=>{!i&&n?(i=!0,e()):C.warn("eventBatchFunc must call its argument exactly once, synchronously.")})}finally{n=!1,i||C.warn("eventBatchFunc must call its argument synchronously.")}},each(t,e){for(const i in t)e(i,t[i])},_inRange:(t,e,i)=>e<=t&&t<i,_getProjectionToSegment(t,e,i,n,s,r){let a,o,h;const l=(t-i)*(t-i)+(e-n)*(e-n);if(0==l)a=t,o=e,h=(s-i)*(s-i)+(r-n)*(r-n);else{const c=((s-t)*(i-t)+(r-e)*(n-e))/l;c<0?(a=t,o=e,h=(t-s)*(t-s)+(e-r)*(e-r)):c>1?(a=i,o=n,h=(i-s)*(i-s)+(n-r)*(n-r)):(a=t+c*(i-t),o=e+c*(n-e),h=(a-s)*(a-s)+(o-r)*(o-r))}return[a,o,h]},_getProjectionToLine(t,e,i){const n=C.cloneObject(t);let s=Number.MAX_VALUE;return e.forEach(function(r,a){if(!i&&a===e.length-1)return;const o=e[(a+1)%e.length],h=C._getProjectionToSegment(r.x,r.y,o.x,o.y,t.x,t.y),l=h[0],c=h[1],d=h[2];d<s&&(n.x=l,n.y=c,s=d)}),n},_prepareArrayForTween(t,e,i){const n=[],s=[];if(t.length>e.length){const i=e;e=t,t=i}for(let e=0;e<t.length;e+=2)n.push({x:t[e],y:t[e+1]});for(let t=0;t<e.length;t+=2)s.push({x:e[t],y:e[t+1]});const r=[];return s.forEach(function(t){const e=C._getProjectionToLine(t,n,i);r.push(e.x),r.push(e.y)}),r},_prepareToStringify(t,e=new Set){const i=C._isArray(t)?[]:{};e.add(t);for(const n of Object.keys(t)){const s=t[n];C._isElement(s)||e.has(s)||(i[n]=C._isPlainObject(s)||C._isArray(s)?C._prepareToStringify(s,e):s)}return e.delete(t),i},_assign(t,e){for(const i in e)t[i]=e[i];return t},_getFirstPointerId:t=>t.touches?t.changedTouches[0].identifier:t.pointerId||999,releaseCanvas(...t){i.releaseCanvasOnDestroy&&t.forEach(t=>{t.width=0,t.height=0})},_cornerRadii(t,e,i){const n=Math.min(e,i)/2;if("number"==typeof t){const e=w(t,n);return[e,e,e,e]}return[w(t[0],n),w(t[1],n),w(t[2],n),w(t[3],n)]},drawRoundedRectPath(t,e,i,n){let s=e<0?e:0,r=i<0?i:0;e=Math.abs(e),i=Math.abs(i);const[a,o,h,l]=C._cornerRadii(n,e,i);t.moveTo(s+a,r),t.lineTo(s+e-o,r),t.arc(s+e-o,r+o,o,3*Math.PI/2,0,!1),t.lineTo(s+e,r+i-h),t.arc(s+e-h,r+i-h,h,0,Math.PI/2,!1),t.lineTo(s+l,r+i),t.arc(s+l,r+i-l,l,Math.PI/2,Math.PI,!1),t.lineTo(s,r+a),t.arc(s+a,r+a,a,Math.PI,3*Math.PI/2,!1)},drawRoundedPolygonPath(t,e,i,n,s){n=Math.abs(n);for(let r=0;r<i;r++){const a=e[(r-1+i)%i],o=e[r],h=e[(r+1)%i],l={x:o.x-a.x,y:o.y-a.y},c={x:h.x-o.x,y:h.y-o.y},d=Math.hypot(l.x,l.y),g=Math.hypot(c.x,c.y);let u;u="number"==typeof s?s:r<s.length?s[r]:0;u=n*Math.cos(Math.PI/i)*Math.min(1,u/n*2);const f={x:l.x/d,y:l.y/d},p={x:c.x/g,y:c.y/g},m={x:o.x-f.x*u,y:o.y-f.y*u},_={x:o.x+p.x*u,y:o.y+p.y*u};0===r?t.moveTo(m.x,m.y):t.lineTo(m.x,m.y),t.arcTo(o.x,o.y,_.x,_.y,u)}}};const k=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","roundRect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"];let P=null;function A(){if(null!==P)return P;try{const t=C.createCanvasElement(),e=t.getContext("2d");P=!!e&&"filter"in e,C.releaseCanvas(t)}catch(t){P=!1}return P}class T{constructor(t){this.canvas=t,i.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(t){t.fillEnabled()&&this._fill(t)}_fill(t){}strokeShape(t){t.hasStroke()&&this._stroke(t)}_stroke(t){}fillStrokeShape(t){t.attrs.fillAfterStrokeEnabled?(this.strokeShape(t),this.fillShape(t)):(this.fillShape(t),this.strokeShape(t))}getTrace(t,e){let i,n,s,r,a=this.traceArr,o=a.length,h="";for(i=0;i<o;i++)n=a[i],s=n.method,s?(r=n.args,h+=s,t?h+="()":(e&&(r=r.map(t=>"number"==typeof t?Math.floor(t):t)),h+="("+r.join(",")+")")):(h+=n.property,t||(h+="="+n.val)),h+=";";return h}clearTrace(){this.traceArr=[]}_trace(t){let e,i=this.traceArr;i.push(t),e=i.length,e>=100&&i.shift()}reset(){const t=this.getCanvas().getPixelRatio();this.setTransform(1*t,0,0,1*t,0,0)}getCanvas(){return this.canvas}clear(t){const e=this.getCanvas();t?this.clearRect(t.x||0,t.y||0,t.width||0,t.height||0):this.clearRect(0,0,e.getWidth()/e.pixelRatio,e.getHeight()/e.pixelRatio)}_applyLineCap(t){const e=t.attrs.lineCap;e&&this.setAttr("lineCap",e)}_applyOpacity(t){const e=t.getAbsoluteOpacity();1!==e&&this.setAttr("globalAlpha",e)}_applyLineJoin(t){const e=t.attrs.lineJoin;e&&this.setAttr("lineJoin",e)}_applyMiterLimit(t){const e=t.attrs.miterLimit;null!=e&&this.setAttr("miterLimit",e)}setAttr(t,e){this._context[t]=e}arc(t,e,i,n,s,r){this._context.arc(t,e,i,n,s,r)}arcTo(t,e,i,n,s){this._context.arcTo(t,e,i,n,s)}beginPath(){this._context.beginPath()}bezierCurveTo(t,e,i,n,s,r){this._context.bezierCurveTo(t,e,i,n,s,r)}clearRect(t,e,i,n){this._context.clearRect(t,e,i,n)}clip(...t){this._context.clip.apply(this._context,t)}closePath(){this._context.closePath()}createImageData(t,e){const i=arguments;return 2===i.length?this._context.createImageData(t,e):1===i.length?this._context.createImageData(t):void 0}createLinearGradient(t,e,i,n){return this._context.createLinearGradient(t,e,i,n)}createPattern(t,e){return this._context.createPattern(t,e)}createRadialGradient(t,e,i,n,s,r){return this._context.createRadialGradient(t,e,i,n,s,r)}drawImage(t,e,i,n,s,r,a,o,h){const l=arguments,c=this._context;3===l.length?c.drawImage(t,e,i):5===l.length?c.drawImage(t,e,i,n,s):9===l.length&&c.drawImage(t,e,i,n,s,r,a,o,h)}ellipse(t,e,i,n,s,r,a,o){this._context.ellipse(t,e,i,n,s,r,a,o)}isPointInPath(t,e,i,n){return i?this._context.isPointInPath(i,t,e,n):this._context.isPointInPath(t,e,n)}fill(...t){this._context.fill.apply(this._context,t)}fillRect(t,e,i,n){this._context.fillRect(t,e,i,n)}strokeRect(t,e,i,n){this._context.strokeRect(t,e,i,n)}fillText(t,e,i,n){n?this._context.fillText(t,e,i,n):this._context.fillText(t,e,i)}measureText(t){return this._context.measureText(t)}getImageData(t,e,i,n){return this._context.getImageData(t,e,i,n)}lineTo(t,e){this._context.lineTo(t,e)}moveTo(t,e){this._context.moveTo(t,e)}rect(t,e,i,n){this._context.rect(t,e,i,n)}roundRect(t,e,i,n,s){this._context.roundRect(t,e,i,n,s)}putImageData(t,e,i){this._context.putImageData(t,e,i)}quadraticCurveTo(t,e,i,n){this._context.quadraticCurveTo(t,e,i,n)}restore(){this._context.restore()}rotate(t){this._context.rotate(t)}save(){this._context.save()}scale(t,e){this._context.scale(t,e)}setLineDash(t){this._context.setLineDash(t)}getLineDash(){return this._context.getLineDash()}setTransform(t,e,i,n,s,r){this._context.setTransform(t,e,i,n,s,r)}stroke(t){t?this._context.stroke(t):this._context.stroke()}strokeText(t,e,i,n){this._context.strokeText(t,e,i,n)}transform(t,e,i,n,s,r){this._context.transform(t,e,i,n,s,r)}translate(t,e){this._context.translate(t,e)}_enableTrace(){let t,e,i=this,n=k.length,s=this.setAttr;const r=function(t){let n,s=i[t];i[t]=function(){return e=function(t){const e=[],i=t.length,n=C;for(let s=0;s<i;s++){let i=t[s];n._isNumber(i)?i=Math.round(1e3*i)/1e3:n._isString(i)||(i+=""),e.push(i)}return e}(Array.prototype.slice.call(arguments,0)),n=s.apply(i,arguments),i._trace({method:t,args:e}),n}};for(t=0;t<n;t++)r(k[t]);i.setAttr=function(){s.apply(i,arguments);const t=arguments[0];let e=arguments[1];"shadowOffsetX"!==t&&"shadowOffsetY"!==t&&"shadowBlur"!==t||(e/=this.canvas.getPixelRatio()),i._trace({property:t,val:e})}}_applyGlobalCompositeOperation(t){const e=t.attrs.globalCompositeOperation;!e||"source-over"===e||this.setAttr("globalCompositeOperation",e)}}["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled","filter"].forEach(function(t){Object.defineProperty(T.prototype,t,{get(){return this._context[t]},set(e){this._context[t]=e}})});class M extends T{constructor(t,{willReadFrequently:e=!1}={}){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:e})}_fillColor(t){const e=t.fill();this.setAttr("fillStyle",e),t._fillFunc(this)}_fillPattern(t){const e=this._context;"patternQuality"in e&&(e.patternQuality=e.imageSmoothingEnabled?"good":"nearest"),this.setAttr("fillStyle",t._getFillPattern()),t._fillFunc(this)}_fillLinearGradient(t){const e=t._getLinearGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fillRadialGradient(t){const e=t._getRadialGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fill(t){const e=t.fill(),i=t.getFillPriority();if(e&&"color"===i)return void this._fillColor(t);const n=t.getFillPatternImage();if(n&&"pattern"===i)return void this._fillPattern(t);const s=t.getFillLinearGradientColorStops();if(s&&"linear-gradient"===i)return void this._fillLinearGradient(t);const r=t.getFillRadialGradientColorStops();r&&"radial-gradient"===i?this._fillRadialGradient(t):e?this._fillColor(t):n?this._fillPattern(t):s?this._fillLinearGradient(t):r&&this._fillRadialGradient(t)}_strokeLinearGradient(t){const e=t.getStrokeLinearGradientStartPoint(),i=t.getStrokeLinearGradientEndPoint(),n=t.getStrokeLinearGradientColorStops(),s=this.createLinearGradient(e.x,e.y,i.x,i.y);if(n){for(let t=0;t<n.length;t+=2)s.addColorStop(n[t],n[t+1]);this.setAttr("strokeStyle",s)}}_stroke(t){const e=t.dash(),i=t.getStrokeScaleEnabled();if(!i){this.save();const t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(t),e&&t.dashEnabled()&&(this.setLineDash(e),this.setAttr("lineDashOffset",t.dashOffset())),this.setAttr("lineWidth",t.strokeWidth()),t.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)");t.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(t):this.setAttr("strokeStyle",t.stroke()),t._strokeFunc(this),i||this.restore()}_applyShadow(t){var e;const i=null!==(e=t.getShadowRGBA())&&void 0!==e?e:"black",n=t.getShadowBlur(),s=t.getShadowOffset(),r=t.getAbsoluteScale(),a=this.canvas.getPixelRatio(),o=r.x*a,h=r.y*a;this.setAttr("shadowColor",i),this.setAttr("shadowBlur",n*Math.min(Math.abs(o),Math.abs(h))),this.setAttr("shadowOffsetX",s.x*o),this.setAttr("shadowOffsetY",s.y*h)}}class E extends T{constructor(t){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:!0})}_fill(t){this.save(),this.setAttr("fillStyle",t.colorKey),t._fillFuncHit(this),this.restore()}strokeShape(t){t.hasHitStroke()&&this._stroke(t)}_stroke(t){const e=t.getStrokeScaleEnabled();if(!e){this.save();const t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(t);const i=t.hitStrokeWidth(),n="auto"===i?t.strokeWidth():i;this.setAttr("lineWidth",n),this.setAttr("strokeStyle",t.colorKey),t._strokeFuncHit(this),e||this.restore()}}class R{constructor(t){this.pixelRatio=1,this.width=0,this.height=0,this._logicalWidth=0,this._logicalHeight=0,this.isCache=!1,this.x=0,this.y=0;const e=(t||{}).pixelRatio||i.pixelRatio||i._global.devicePixelRatio||1;this.pixelRatio=e,this._canvas=C.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(t){this.pixelRatio=t,this.setSize(this._logicalWidth,this._logicalHeight)}setWidth(t){this.setSize(t,this._logicalHeight)}setHeight(t){this.setSize(this._logicalWidth,t)}getWidth(){return this.width}getHeight(){return this.height}_bitmapSize(t){return Math.floor((t||0)*this.pixelRatio)}setSize(t,e){isFinite(null!=t?t:0)&&isFinite(null!=e?e:0)||(C.error(`Canvas size must be finite numbers, got ${t}x${e}. The canvas is left empty.`),t=e=0),t=t||0,e=e||0;const i=this.pixelRatio;this._logicalWidth=t,this._logicalHeight=e,this.width=this._canvas.width=this._bitmapSize(t),this.height=this._canvas.height=this._bitmapSize(e),this._canvas.style.width=t+"px",this._canvas.style.height=e+"px",this.getContext()._context.scale(i,i)}setSizeIfChanged(t,e){this.width===this._bitmapSize(t)&&this.height===this._bitmapSize(e)||this.setSize(t,e)}toDataURL(t,e){try{return this._canvas.toDataURL(t,e)}catch(t){try{return this._canvas.toDataURL()}catch(t){return C.error("Unable to get data URL. "+t.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}}class G extends R{constructor(t={width:0,height:0,willReadFrequently:!1}){super(t),this.context=new M(this,{willReadFrequently:t.willReadFrequently}),this.setSize(t.width,t.height)}}class L extends R{constructor(t={width:0,height:0}){super(t),this.hitCanvas=!0,this.context=new E(this),this.setSize(t.width,t.height)}}const D={get isDragging(){let t=!1;return D._dragElements.forEach(e=>{"dragging"===e.dragStatus&&(t=!0)}),t},justDragged:!1,get node(){let t;return D._dragElements.forEach(e=>{t=e.node}),t},_dragElements:new Map,_listenToWindow(t){const e=e=>D._endDragBefore(e,t),i=e=>D._batchEvents(()=>D._drag(e,t),t),n=t=>D._batchEvents(()=>D._endDragAfter(t));t.addEventListener("mouseup",e,!0),t.addEventListener("touchend",e,!0),t.addEventListener("touchcancel",e,!0),t.addEventListener("mousemove",i),t.addEventListener("touchmove",i),t.addEventListener("mouseup",n,!1),t.addEventListener("touchend",n,!1),t.addEventListener("touchcancel",n,!1)},_batchEvents(t,e){if(!D._dragElements.size)return;const i=new Set;for(const{node:t}of D._dragElements.values()){const n=t.getStage();if(!n||e&&n._getOwnerWindow()!==e)continue;const s=n.eventBatchFunc();s&&i.add(s)}let n=t;for(const t of i){const e=n;n=()=>C._batchEvents(t,e)}n()},_drag(t,e){const i=[],n=new Set;D._dragElements.forEach((s,r)=>{const{node:a}=s,o=a.getStage();if(e&&o._getOwnerWindow()!==e)return;n.has(o)||(o.setPointersPositions(t),n.add(o)),void 0===s.pointerId&&(s.pointerId=C._getFirstPointerId(t));const h=o._changedPointerPositions.find(t=>t.id===s.pointerId);if(h){if("dragging"!==s.dragStatus){const e=a.dragDistance();if(Math.max(Math.abs(h.x-s.startPointerPos.x),Math.abs(h.y-s.startPointerPos.y))<e)return;if(a.startDrag({evt:t}),!a.isDragging())return}a._setDragPosition(t,s),i.push(a)}}),i.forEach(e=>{e.getStage()&&e.fire("dragmove",{type:"dragmove",target:e,evt:t},!0)})},_endDragBefore(t,e){const n=[],s=new Set;D._dragElements.forEach((r,a)=>{const{node:o}=r,h=o.getStage();!t||s.has(h)||e&&h._getOwnerWindow()!==e||(h.setPointersPositions(t),s.add(h));if(void 0===r.pointerId||h._changedPointerPositions.some(t=>t.id===r.pointerId))if("ready"===r.dragStatus)D._dragElements.delete(a);else{D.justDragged=!0,i._mouseListenClick=!1,i._touchListenClick=!1,i._pointerListenClick=!1,r.dragStatus="stopped";const t=r.node.getLayer()||r.node instanceof i.Stage&&r.node;t&&-1===n.indexOf(t)&&n.push(t)}}),n.forEach(t=>{t.draw()})},_endDragAfter(t){D._dragElements.forEach((e,i)=>{"stopped"===e.dragStatus&&(e.node.fire("dragend",{type:"dragend",target:e.node,evt:t},!0),"dragging"!==e.dragStatus&&D._dragElements.delete(i))})}},I=new Map,F=void 0!==i._global.PointerEvent;function O(t){return I.get(t)}function B(t){return{evt:t,pointerId:t.pointerId}}function N(t,e){return I.get(t)===e}function W(t,e){var i;H(t);const n=e.getStage();if(n&&(I.set(t,e),F)){try{null===(i=n.content)||void 0===i||i.setPointerCapture(t)}catch(t){}e._fire("gotpointercapture",B(new PointerEvent("gotpointercapture")))}}function H(t,e){var i;const n=I.get(t);if(!n||e&&n!==e)return;const s=n.getStage();if(I.delete(t),F){try{null===(i=null==s?void 0:s.content)||void 0===i||i.releasePointerCapture(t)}catch(t){}n._fire("lostpointercapture",B(new PointerEvent("lostpointercapture")))}}function z(t){return C._isString(t)?'"'+t+'"':"[object Number]"===Object.prototype.toString.call(t)||C._isBoolean(t)?t:Object.prototype.toString.call(t)}function Y(t){return t>255?255:t<0?0:Math.round(t)}function X(){if(i.isUnminified)return function(t,e){return C._isNumber(t)||C.warn(z(t)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),t}}function j(t){if(i.isUnminified)return function(e,i){let n=C._isNumber(e),s=C._isArray(e)&&e.length==t;return n||s||C.warn(z(e)+' is a not valid value for "'+i+'" attribute. The value should be a number or Array<number>('+t+")"),e}}function q(){if(i.isUnminified)return function(t,e){return C._isNumber(t)||"auto"===t||C.warn(z(t)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),t}}function U(){if(i.isUnminified)return function(t,e){return C._isString(t)||C.warn(z(t)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),t}}function V(){if(i.isUnminified)return function(t,e){const i=C._isString(t),n="[object CanvasGradient]"===Object.prototype.toString.call(t)||t&&t.addColorStop;return i||n||C.warn(z(t)+' is a not valid value for "'+e+'" attribute. The value should be a string or a native gradient.'),t}}function K(){if(i.isUnminified)return function(t,e){return!0===t||!1===t||C.warn(z(t)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),t}}const $="get",Q="set",J={addGetterSetter(t,e,i,n,s){J.addGetter(t,e,i),J.addSetter(t,e,n,s),J.addOverloadedGetterSetter(t,e)},addGetter(t,e,i){const n=$+C._capitalize(e);t.prototype[n]=t.prototype[n]||function(){const t=this.attrs[e];return void 0===t?i:t}},addSetter(t,e,i,n){const s=Q+C._capitalize(e);t.prototype[s]||J.overWriteSetter(t,e,i,n)},overWriteSetter(t,e,i,n){const s=Q+C._capitalize(e);t.prototype[s]=function(t){return i&&null!=t&&(t=i.call(this,t,e)),this._setAttr(e,t),n&&n.call(this),this}},addComponentsGetterSetter(t,e,n,s,r){const a=n.length,o=C._capitalize,h=$+o(e),l=Q+o(e),c=n.map(t=>e+o(t)),d=c.map(t=>$+o(t));t.prototype[h]=function(){const t={};for(let e=0;e<a;e++){const i=this[d[e]];t[n[e]]=i?i.call(this):this.attrs[c[e]]}return t};const g=function(t){if(i.isUnminified)return function(e,i){return null==e||C.isObject(e)||C.warn(z(e)+' is a not valid value for "'+i+'" attribute. The value should be an object with properties '+t),e}}(n);t.prototype[l]=function(t){const i=this.attrs[e];s&&(t=s.call(this,t,e)),g&&g.call(this,t,e);for(const i in t)t.hasOwnProperty(i)&&this._setAttr(e+o(i),t[i]);return t||n.forEach(t=>{this._setAttr(e+o(t),void 0)}),this._fireChangeEvent(e,i,t),r&&r.call(this),this},J.addOverloadedGetterSetter(t,e)},addOverloadedGetterSetter(t,e){const i=C._capitalize(e),n=Q+i,s=$+i,r=function(){return arguments.length?(this[n](arguments[0]),this):this[s]()};r._isAttrAccessor=!0,t.prototype[e]=r},backCompat(t,e){C.each(e,function(e,i){const n=t.prototype[i],s=$+C._capitalize(e),r=Q+C._capitalize(e);function a(){return C.error('"'+e+'" method is deprecated and will be removed soon. Use ""'+i+'" instead.'),n.apply(this,arguments)}t.prototype[e]=a,t.prototype[s]=a,t.prototype[r]=a})},afterSetFilter(){this._filterUpToDate=!1}};function Z(t){const e=/(\w+)\(([^)]+)\)/g;let n;for(;null!==(n=e.exec(t));){const[,t,e]=n;switch(t){case"blur":{const t=parseFloat(e.replace("px",""));return function(e){this.blurRadius(.5*t);const n=i.Filters;n&&n.Blur&&n.Blur.call(this,e)}}case"brightness":{const t=e.includes("%")?parseFloat(e)/100:parseFloat(e);return function(e){this.brightness(t);const n=i.Filters;n&&n.Brightness&&n.Brightness.call(this,e)}}case"contrast":{const t=parseFloat(e);return function(e){const n=100*(Math.sqrt(t)-1);this.contrast(n);const s=i.Filters;s&&s.Contrast&&s.Contrast.call(this,e)}}case"grayscale":return function(t){const e=i.Filters;e&&e.Grayscale&&e.Grayscale.call(this,t)};case"sepia":return function(t){const e=i.Filters;e&&e.Sepia&&e.Sepia.call(this,t)};case"invert":return function(t){const e=i.Filters;e&&e.Invert&&e.Invert.call(this,t)};default:C.warn(`CSS filter "${t}" is not supported in fallback mode. Consider using function filters for better compatibility.`)}}return()=>{}}const tt="absoluteOpacity",et="absoluteTransform",it="listening",nt=["mouseenter","mouseleave","pointerenter","pointerleave","touchenter","touchleave"],st="Shape",rt="stage",at="transform",ot="visible",ht=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(" ");let lt=1;function ct(t,e,i){const n=new G({width:0,height:0,pixelRatio:t.pixelRatio});return n.x=e,n.y=i,n}class dt{constructor(t){this._id=lt++,this.eventListeners={},this.attrs={},this.index=0,this.parent=null,this._cache={},this._canvasCache=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(t),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(t){t!==at&&t!==et||!this._cache[t]?t?this._cache[t]=void 0:(this._cache={},void 0!==this._attrsVersion&&this._attrsVersion++):this._cache[t].dirty=!0}_releaseCanvasCache(){const t=this._canvasCache;t&&(C.releaseCanvas(t.scene._canvas,t.filter._canvas,...t.hit?[t.hit._canvas]:[]),this._canvasCache=null)}_getCache(t,e){let i=this._cache[t];return(void 0===i||(t===at||t===et)&&!0===i.dirty)&&(i=e.call(this),this._cache[t]=i),i}_getCanvasCache(){return this._canvasCache}_clearSelfAndDescendantCache(t){this._clearCache(t),t===et&&this.fire("absoluteTransformChange")}static _runAfterAbsTransformCascade(t){dt._absTransformCascadeDepth>0?dt._pendingAfterCascade.push(t):t()}clearCache(){return this._releaseCanvasCache(),this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(t){const e=t||{};let i={};void 0!==e.x&&void 0!==e.y&&void 0!==e.width&&void 0!==e.height||(i=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let n=Math.ceil(e.width||i.width),s=Math.ceil(e.height||i.height),r=e.pixelRatio,a=void 0===e.x?Math.floor(i.x):e.x,o=void 0===e.y?Math.floor(i.y):e.y,h=e.offset||0,l=e.drawBorder||!1,c=e.hitCanvasPixelRatio||1;if(!n||!s||!isFinite(a+o+n+s))return C.error(`Can not cache the node. Its size is 0 or its bounds are not finite numbers (${a}, ${o}, ${n}x${s}). Caching is skipped.`),this;n+=2*h+(Math.abs(Math.round(i.x)-a)>.5?1:0),s+=2*h+(Math.abs(Math.round(i.y)-o)>.5?1:0),a-=h,o-=h;const d=new G({pixelRatio:r,width:n,height:s}),g=new G({pixelRatio:r,width:0,height:0,willReadFrequently:!0}),u=d.getContext(),f=ct(d,a,o);d.isCache=!0,this._releaseCanvasCache(),this._filterUpToDate=!1,!1===e.imageSmoothingEnabled&&(d.getContext()._context.imageSmoothingEnabled=!1,g.getContext()._context.imageSmoothingEnabled=!1),u.save(),u.translate(-a,-o),this._isUnderCache=!0,this._clearSelfAndDescendantCache(tt);try{this.drawScene(d,this,f)}catch(t){throw C.releaseCanvas(d._canvas),t}finally{this._isUnderCache=!1,this._clearSelfAndDescendantCache(tt),u.restore(),C.releaseCanvas(f._canvas)}return l&&(u.save(),u.beginPath(),u.rect(0,0,n,s),u.closePath(),u.setAttr("strokeStyle","red"),u.setAttr("lineWidth",5),u.stroke(),u.restore()),this._canvasCache={scene:d,filter:g,hit:null,hitConfig:{pixelRatio:c,width:n,height:s},x:a,y:o},this._requestDraw(),this}_getCachedHitCanvas(t){if(t===this)return null;const e=this._getCanvasCache();if(!e)return null;if(e.hit)return e.hit;const i=new L(e.hitConfig);i.isCache=!0;const n=i.getContext();return n.save(),n.translate(-e.x,-e.y),this.drawHit(i,this),n.restore(),e.hit=i,i}isCached(){return!!this._canvasCache}getClientRect(t){throw new Error('abstract "getClientRect" method call')}_transformedRect(t,e){const i=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}];let n=1/0,s=1/0,r=-1/0,a=-1/0;const o=this.getAbsoluteTransform(e);return i.forEach(function(t){const e=o.point(t);n=Math.min(n,e.x),s=Math.min(s,e.y),r=Math.max(r,e.x),a=Math.max(a,e.y)}),{x:n,y:s,width:r-n,height:a-s}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const e=this._getCanvasCache();t.translate(e.x,e.y);const i=this._getCachedSceneCanvas(),n=i.pixelRatio;t.drawImage(i._canvas,0,0,i.width/n,i.height/n),t.restore()}_drawCachedHitCanvas(t,e){const i=this._getCanvasCache();t.save(),t.translate(i.x,i.y),t.drawImage(e._canvas,0,0,e.width/e.pixelRatio,e.height/e.pixelRatio),t.restore()}_getCachedSceneCanvas(){let t,e,i,n,s=this.filters(),r=this._getCanvasCache(),a=r.scene,o=r.filter,h=o.getContext();if(!s||0===s.length)return a;if(this._filterUpToDate)return o;let l=!0;for(let t=0;t<s.length;t++)if("string"!=typeof s[t]||!A()){l=!1;break}const c=a.pixelRatio;if(o.setSizeIfChanged(a._logicalWidth,a._logicalHeight),l){const t=s.join(" ");return h.clear(),h.save(),h.setAttr("filter",t),h.drawImage(a._canvas,0,0,a.getWidth()/c,a.getHeight()/c),h.restore(),this._filterUpToDate=!0,o}try{for(t=s.length,h.clear(),h.drawImage(a._canvas,0,0,a.getWidth()/c,a.getHeight()/c),e=h.getImageData(0,0,o.getWidth(),o.getHeight()),i=0;i<t;i++)n=s[i],"string"==typeof n&&(n=Z(n)),n.call(this,e);h.putImageData(e,0,0)}catch(t){C.error("Unable to apply filter. "+t.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}return this._filterUpToDate=!0,o}on(...t){this._prepareListeners();const e=t[0],i=t[1];if(t[2],3===t.length)return this._delegate.apply(this,t);const n=e.split(" ");for(let t=0;t<n.length;t++){const e=n[t].split("."),s=e[0],r=e[1]||"";this.eventListeners[s]||(this.eventListeners[s]=[]),this.eventListeners[s].push({name:r,handler:i})}return this}_prepareListeners(){this===this.constructor.prototype&&(this.hasOwnProperty("eventListeners")||(this.eventListeners={}),dt.protoListenerMap=new WeakMap)}off(t,e){this._prepareListeners();let i,n,s,r,a,o,h=(t||"").split(" "),l=h.length;if(!t)for(n in this.eventListeners)this._off(n);for(i=0;i<l;i++)if(s=h[i],r=s.split("."),a=r[0],o=r[1],a)this.eventListeners[a]&&this._off(a,o,e);else for(n in this.eventListeners)this._off(n,o,e);return this}dispatchEvent(t){const e={target:this,type:t.type,evt:t};return this.fire(t.type,e),this}addEventListener(t,e){return this.on(t,function(t){e.call(this,t.evt)}),this}removeEventListener(t){return this.off(t),this}_delegate(t,e,i){const n=this;return this.on(t,function(t){const s=t.target.findAncestors(e,!0,n);for(let e=0;e<s.length;e++)(t=C.cloneObject(t)).currentTarget=s[e],i.call(s[e],t)}),this}remove(){return this.isDragging()&&this.stopDrag(),D._dragElements.delete(this._id),D._dragElements.forEach((t,e)=>{this.isAncestorOf(t.node)&&D._dragElements.delete(e)}),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(et),this._clearSelfAndDescendantCache(tt),this._clearSelfAndDescendantCache(rt),this._clearSelfAndDescendantCache(ot),this._clearSelfAndDescendantCache(it)}_remove(){this._clearCaches();const t=this.getParent();t&&t.children&&(t.children.splice(this.index,1),t._setChildrenIndices(),this.parent=null)}destroy(){var t;return this._fire("destroy",{target:this}),t=this,I.forEach((e,i)=>{e===t&&H(i)}),this.remove(),this.clearCache(),this}getAttr(t){const e="get"+C._capitalize(t);return C._isFunction(this[e])?this[e]():this.attrs[t]}getAncestors(){let t=this.getParent(),e=[];for(;t;)e.push(t),t=t.getParent();return e}getAttrs(){return this.attrs||{}}setAttrs(t){return this._batchTransformChanges(()=>{let e,i;if(!t)return this;for(e in t)"children"!==e&&(i="set"+C._capitalize(e),C._isFunction(this[i])?this[i](t[e]):this._setAttr(e,t[e]))}),this}isListening(){return this._getCache(it,this._isListening)}_isListening(t){if(!this.listening())return!1;const e=this.getParent();return!e||e===t||this===t||e._isListening(t)}isVisible(){return this._getCache(ot,this._isVisible)}_isVisible(t){if(!this.visible())return!1;const e=this.getParent();return!e||e===t||this===t||e._isVisible(t)}shouldDrawHit(t){return t?this._isVisible(t)&&this._isListening(t):this.isListening()&&this.isVisible()}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let t,e,i,n,s=this.getDepth(),r=this,a=0;const o=this.getStage();return"Stage"!==r.nodeType&&o&&function o(h){for(t=[],e=h.length,i=0;i<e;i++)n=h[i],a++,n.nodeType!==st&&(t=t.concat(n.children)),n._id===r._id&&(i=e);t.length>0&&t[0].getDepth()<=s&&o(t)}(o.children),a}getDepth(){let t=0,e=this.parent;for(;e;)t++,e=e.parent;return t}_batchTransformChanges(t){this._batchingTransformChange=!0;try{t()}finally{this._batchingTransformChange=!1,this._needClearTransformCache&&(this._needClearTransformCache=!1,this._clearCache(at),this._clearSelfAndDescendantCache(et))}}setPosition(t){return this._batchTransformChanges(()=>{this.x(t.x),this.y(t.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){const t=this.getStage();if(!t)return null;const e=t.getPointerPosition();if(!e)return null;const i=this.getAbsoluteTransform().copy();return i.invert(),i.point(e)}getAbsolutePosition(t){const e=this.getAbsoluteTransform(t).getMatrix(),i=new r,n=this.offset();return i.m=e.slice(),i.translate(n.x,n.y),i.getTranslation()}setAbsolutePosition(t){const{x:e,y:i,...n}=this._clearTransform();this.attrs.x=e,this.attrs.y=i,this._clearCache(at);const s=this._getAbsoluteTransform().copy(),r=s.isInvertible();s.invert(),s.translate(t.x,t.y);const{x:a,y:o}=s.getTranslation();return this._setTransform(n),r?this.setPosition({x:this.attrs.x+a,y:this.attrs.y+o}):C.warn("Cannot set the absolute position: the absolute transform is not invertible (an ancestor has a zero scale)."),this._clearCache(at),this._clearSelfAndDescendantCache(et),this}_setTransform(t){let e;for(e in t)this.attrs[e]=t[e]}_clearTransform(){const t={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,t}move(t){let e=t.x,i=t.y,n=this.x(),s=this.y();return void 0!==e&&(n+=e),void 0!==i&&(s+=i),this.setPosition({x:n,y:s}),this}rotate(t){return this.rotation(this.rotation()+t),this}moveToTop(){if(!this.parent)return C.warn("Node has no parent. moveToTop function is ignored."),!1;const t=this.index;return t<this.parent.children.length-1&&(this.parent.children.splice(t,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0)}moveUp(){if(!this.parent)return C.warn("Node has no parent. moveUp function is ignored."),!1;const t=this.index;return t<this.parent.children.length-1&&(this.parent.children.splice(t,1),this.parent.children.splice(t+1,0,this),this.parent._setChildrenIndices(),!0)}moveDown(){if(!this.parent)return C.warn("Node has no parent. moveDown function is ignored."),!1;const t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.splice(t-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return C.warn("Node has no parent. moveToBottom function is ignored."),!1;const t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(t){if(!this.parent)return C.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&&C.warn("Unexpected value "+t+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");const e=this.index;return this.parent.children.splice(e,1),this.parent.children.splice(t,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(tt,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let t=this.opacity();const e=this.getParent();return e&&!e._isUnderCache&&(t*=e.getAbsoluteOpacity()),t}moveTo(t){return this.getParent()!==t&&(this._remove(),t.add(this)),this}toObject(){var t;let e,i,n,s,r,a=this.getAttrs();const o={attrs:{},className:this.getClassName()};for(e in a)i=a[e],r=C.isObject(i)&&!C._isPlainObject(i)&&!C._isArray(i),r||(n=(null===(t=this[e])||void 0===t?void 0:t._isAttrAccessor)&&this[e],delete a[e],s=n?n.call(this):null,a[e]=i,s!==i&&(o.attrs[e]=C.isObject(i)?C._prepareToStringify(i):i));return o}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,e,i){const n=[];e&&this._isMatch(t)&&n.push(this);let s=this.parent;for(;s;){if(s===i)return n;s._isMatch(t)&&n.push(s),s=s.parent}return n}isAncestorOf(t){return!1}findAncestor(t,e,i){return this.findAncestors(t,e,i)[0]}_isMatch(t){if(!t)return!1;if("function"==typeof t)return t(this);let e,i,n=t.replace(/ /g,"").split(","),s=n.length;for(e=0;e<s;e++)if(i=n[e],C.isValidSelector(i)||(C.warn('Selector "'+i+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),C.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),C.warn("Konva is awesome, right?")),"#"===i.charAt(0)){if(this.id()===i.slice(1))return!0}else if("."===i.charAt(0)){if(this.hasName(i.slice(1)))return!0}else if(this.className===i||this.nodeType===i)return!0;return!1}getLayer(){const t=this.getParent();return t?t.getLayer():null}getStage(){return this._getCache(rt,this._getStage)}_getStage(){const t=this.getParent();return t?t.getStage():null}fire(t,e,i){return(e=e||{}).target=e.target||this,i?this._fireAndBubble(t,e):this._fire(t,e),this}getAbsoluteTransform(t){return t||this._hasCachedAncestor()?this._getAbsoluteTransform(t):this._getCache(et,this._getCachedAbsoluteTransform)}_hasCachedAncestor(){let t=this.parent;for(;t;){if(t.isCached())return!0;t=t.parent}return!1}_getAbsoluteTransform(t){const e=new r;return this===t?e:(this.parent&&this.parent!==t&&this.parent.getAbsoluteTransform(t).copyInto(e),this._multiplyOwnTransform(e))}_getCachedAbsoluteTransform(){const t=this._cache[et]||new r;return this.parent?this.parent.getAbsoluteTransform().copyInto(t):t.reset(),this._multiplyOwnTransform(t),t.dirty=!1,t}_multiplyOwnTransform(t){const e=this.transformsEnabled();if("all"===e)t.multiply(this.getTransform());else if("position"===e){const e=this.attrs.x||0,i=this.attrs.y||0,n=this.attrs.offsetX||0,s=this.attrs.offsetY||0;t.translate(e-n,i-s)}return t}getAbsoluteScale(t){let e=this;for(;e;)e._isUnderCache&&(t=e),e=e.getParent();const i=this.getAbsoluteTransform(t).decompose();return{x:i.scaleX,y:i.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(at,this._getTransform)}_getTransform(){var t,e;const n=this._cache[at]||new r;n.reset();const s=this.x(),a=this.y(),o=i.getAngle(this.rotation()),h=null!==(t=this.attrs.scaleX)&&void 0!==t?t:1,l=null!==(e=this.attrs.scaleY)&&void 0!==e?e:1,c=this.attrs.skewX||0,d=this.attrs.skewY||0,g=this.attrs.offsetX||0,u=this.attrs.offsetY||0;return 0===s&&0===a||n.translate(s,a),0!==o&&n.rotate(o),0===c&&0===d||n.skew(c,d),1===h&&1===l||n.scale(h,l),0===g&&0===u||n.translate(-1*g,-1*u),n.dirty=!1,n}clone(t){let e,i,n,s,r,a=C.cloneObject(this.attrs);for(e in t)a[e]=t[e];const o=new this.constructor(a);for(e in this.eventListeners)for(i=this.eventListeners[e],n=i.length,s=0;s<n;s++)r=i[s],r.name.indexOf("konva")<0&&(o.eventListeners[e]||(o.eventListeners[e]=[]),o.eventListeners[e].push(r));return o}_toKonvaCanvas(t){const e=void 0===(t=t||{}).x||void 0===t.y||!t.width||!t.height?this.getClientRect():{x:0,y:0,width:0,height:0};isFinite(e.x+e.y+e.width+e.height)||C.error(`Cannot find the bounds of the node to export, its client rect is ${e.x}, ${e.y}, ${e.width}x${e.height}. Check its position, size and points.`);const i=this.getStage(),n=void 0!==t.x?t.x:Math.floor(e.x),s=void 0!==t.y?t.y:Math.floor(e.y),r=t.pixelRatio||1,a=new G({width:t.width||Math.ceil(e.width)||(i?i.width():0),height:t.height||Math.ceil(e.height)||(i?i.height():0),pixelRatio:r}),o=a.getContext(),h=ct(a,n,s);return!1===t.imageSmoothingEnabled&&(o._context.imageSmoothingEnabled=!1),o.save(),(n||s)&&o.translate(-1*n,-1*s),this.drawScene(a,void 0,h),o.restore(),C.releaseCanvas(h._canvas),a}toCanvas(t){return this._toKonvaCanvas(t)._canvas}toDataURL(t){const e=(t=t||{}).mimeType||null,i=t.quality||null,n=this._toKonvaCanvas(t).toDataURL(e,i);return t.callback&&t.callback(n),n}toImage(t){return new Promise((e,i)=>{try{const i=null==t?void 0:t.callback;i&&delete t.callback,C._urlToImage(this.toDataURL(t),function(t){e(t),null==i||i(t)})}catch(t){i(t)}})}toBlob(t){return new Promise((e,i)=>{try{const n=null==t?void 0:t.callback;n&&delete t.callback,this.toCanvas(t).toBlob(t=>{t?(e(t),null==n||n(t)):i(new Error("Konva: toBlob() failed, the canvas was not encoded"))},null==t?void 0:t.mimeType,null==t?void 0:t.quality)}catch(t){i(t)}})}setSize(t){return this.width(t.width),this.height(t.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return void 0!==this.attrs.dragDistance?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():i.dragDistance}_off(t,e,i){let n,s,r,a=this.eventListeners[t];for(n=0;n<a.length;n++)if(s=a[n].name,r=a[n].handler,!("konva"===s&&"konva"!==e||e&&s!==e||i&&i!==r)){if(a.splice(n,1),0===a.length){delete this.eventListeners[t];break}n--}}_fireChangeEvent(t,e,i){this._fire(t+"Change",{oldVal:e,newVal:i})}addName(t){if(!this.hasName(t)){const e=this.name(),i=e?e+" "+t:t;this.name(i)}return this}hasName(t){if(!t)return!1;const e=this.name();if(!e)return!1;return-1!==(e||"").split(/\s/g).indexOf(t)}removeName(t){const e=(this.name()||"").split(/\s/g),i=e.indexOf(t);return-1!==i&&(e.splice(i,1),this.name(e.join(" "))),this}setAttr(t,e){const i=this["set"+C._capitalize(t)];return C._isFunction(i)?i.call(this,e):this._setAttr(t,e),this}_requestDraw(){if(i.autoDrawEnabled){const t=this.getLayer()||this.getStage();null==t||t.batchDraw()}}_setAttr(t,e){const i=this.attrs[t];(i!==e||C.isObject(e))&&(null==e?delete this.attrs[t]:this.attrs[t]=e,void 0!==this._attrsVersion&&this._attrsVersion++,this._shouldFireChangeEvents&&this._fireChangeEvent(t,i,e),this._requestDraw())}_fireAndBubble(t,e,i){e&&this.nodeType===st&&(e.target=this);const n=-1!==nt.indexOf(t);if(!(n&&(i&&(this===i||this.isAncestorOf&&this.isAncestorOf(i))||"Stage"===this.nodeType&&!i))){this._fire(t,e);const s=n&&i&&i.isAncestorOf&&i.isAncestorOf(this)&&!i.isAncestorOf(this.parent);(e&&!e.cancelBubble||!e)&&this.parent&&this.parent.isListening()&&!s&&(i&&i.parent?this._fireAndBubble.call(this.parent,t,e,i):this._fireAndBubble.call(this.parent,t,e))}}_getProtoListeners(t){var e,i;const n=Object.getPrototypeOf(this);let s=dt.protoListenerMap.get(n);s||(s={},dt.protoListenerMap.set(n,s));let r=s[t];if(void 0===r){r=[];const n=new Set;let a=Object.getPrototypeOf(this);for(;a;){const s=null!==(i=null===(e=a.eventListeners)||void 0===e?void 0:e[t])&&void 0!==i?i:[];for(let t=0;t<s.length;t++){const e=s[t];n.has(e)||(n.add(e),r.push(e))}a=Object.getPrototypeOf(a)}s[t]=r}return r}_fire(t,e){(e=e||{}).currentTarget=this,e.type=t;const i=this._getProtoListeners(t);if(i)for(let t=0;t<i.length;t++)i[t].handler.call(this,e);const n=this.eventListeners[t];if(n){const i=n.slice(),s=i.length;for(let t=0;t<i.length;t++)i[t].handler.call(this,e);const r=this.eventListeners[t];if(r)for(let t=s;t<r.length;t++)r[t].handler.call(this,e)}}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(t){const e=t?t.pointerId:void 0,i=this.getStage(),n=this.getAbsolutePosition();if(!i)return;const s=i._getPointerById(e)||i._changedPointerPositions[0]||n;D._dragElements.set(this._id,{node:this,startPointerPos:s,offset:{x:s.x-n.x,y:s.y-n.y},dragStatus:"ready",pointerId:e,startEvent:t})}startDrag(t,e=!0){D._dragElements.has(this._id)||this._createDragElement(t);const i=D._dragElements.get(this._id);i&&(i.dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:i.startEvent&&i.startEvent.evt||t&&t.evt},e))}_setDragPosition(t,e){const i=this.getStage()._getPointerById(e.pointerId);if(!i)return;let n={x:i.x-e.offset.x,y:i.y-e.offset.y};const s=this.dragBoundFunc();if(void 0!==s){const e=s.call(this,n,t);if(e){if(!C._isNumber(e.x)||!C._isNumber(e.y))return void C.warn(`dragBoundFunc returned a position with a non-finite x or y (${e.x}, ${e.y}). The node was not moved.`);n=e}else C.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}const r=e.lastPos;r&&r.x===n.x&&r.y===n.y||(this.setAbsolutePosition(n),this._requestDraw()),e.lastPos=n}stopDrag(t){const e=D._dragElements.get(this._id);e&&(e.dragStatus="stopped"),D._endDragBefore(t),D._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=D._dragElements.get(this._id);return!!t&&"dragging"===t.dragStatus}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",function(t){if(!(!(void 0!==t.evt.button)||i.dragButtons.indexOf(t.evt.button)>=0))return;if(this.isDragging())return;let e=!1;D._dragElements.forEach(t=>{this.isAncestorOf(t.node)&&(e=!0)}),e||this._createDragElement(t)})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{this._dragCleanup();if(!this.getStage())return;const t=D._dragElements.get(this._id),e=t&&"dragging"===t.dragStatus,i=t&&"ready"===t.dragStatus;e?this.stopDrag():i&&D._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(t={x:0,y:0}){const e=this.getStage();if(!e)return!1;const i={x:-t.x,y:-t.y,width:e.width()+2*t.x,height:e.height()+2*t.y};return C.haveIntersection(i,this.getClientRect())}static create(t,e){return C._isString(t)&&(t=JSON.parse(t)),this._createNode(t,e)}static _createNode(t,e){let n,s,r,a=dt.prototype.getClassName.call(t),o=t.children;e&&(t.attrs.container=e),i[a]||(C.warn('Can not find a node with class name "'+a+'". Fallback to "Shape".'),a="Shape");if(n=new(0,i[a])(t.attrs),o)for(s=o.length,r=0;r<s;r++)n.add(dt._createNode(o[r]));return n}}dt._absTransformCascadeDepth=0,dt._pendingAfterCascade=[],dt.protoListenerMap=new WeakMap,dt.prototype.nodeType="Node",dt.prototype._attrsAffectingSize=[],dt.prototype.on(ht,function(){this._batchingTransformChange?this._needClearTransformCache=!0:(this._clearCache(at),this._clearSelfAndDescendantCache(et))}),dt.prototype.on("visibleChange.konva",function(){this._clearSelfAndDescendantCache(ot)}),dt.prototype.on("listeningChange.konva",function(){this._clearSelfAndDescendantCache(it)}),dt.prototype.on("opacityChange.konva",function(){this._clearSelfAndDescendantCache(tt)});const gt=J.addGetterSetter;gt(dt,"zIndex"),gt(dt,"absolutePosition"),gt(dt,"position"),gt(dt,"x",0,X()),gt(dt,"y",0,X()),gt(dt,"globalCompositeOperation","source-over",U()),gt(dt,"opacity",1,X()),gt(dt,"name","",U()),gt(dt,"id","",U()),gt(dt,"rotation",0,X()),J.addComponentsGetterSetter(dt,"scale",["x","y"]),gt(dt,"scaleX",1,X()),gt(dt,"scaleY",1,X()),J.addComponentsGetterSetter(dt,"skew",["x","y"]),gt(dt,"skewX",0,X()),gt(dt,"skewY",0,X()),J.addComponentsGetterSetter(dt,"offset",["x","y"]),gt(dt,"offsetX",0,X()),gt(dt,"offsetY",0,X()),gt(dt,"dragDistance",void 0,X()),gt(dt,"width",0,X()),gt(dt,"height",0,X()),gt(dt,"listening",!0,K()),gt(dt,"preventDefault",!0,K()),gt(dt,"filters",void 0,function(t){return this._filterUpToDate=!1,t}),gt(dt,"visible",!0,K()),gt(dt,"transformsEnabled","all",U()),gt(dt,"size"),gt(dt,"dragBoundFunc"),gt(dt,"draggable",!1,K()),J.backCompat(dt,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});class ut extends dt{constructor(){super(...arguments),this.children=[]}getChildren(t){const e=this.children||[];return t?e.filter(t):e.slice()}hasChildren(){return this.children.length>0}removeChildren(){return this.children.forEach(t=>{t.parent=null,t.index=0,t.remove()}),this.children=[],this._requestDraw(),this}destroyChildren(){return this.children.forEach(t=>{t.parent=null,t.index=0,t.destroy()}),this.children=[],this._requestDraw(),this}add(...t){if(0===t.length)return this;if(t.length>1){for(let e=0;e<t.length;e++)this.add(t[e]);return this}const e=t[0];return e.getParent()?(e.moveTo(this),this):(this._validateAdd(e),e.index=this.children.length,e.parent=this,e._clearCaches(),this.children.push(e),this._fire("add",{child:e}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(t){return this._generalFind(t,!1)}findOne(t){const e=this._generalFind(t,!0);return e.length>0?e[0]:void 0}_generalFind(t,e){const i=[];return this._descendants(n=>{const s=n._isMatch(t);return s&&i.push(n),!(!s||!e)}),i}_descendants(t){let e=!1;for(const i of this.children){if(e=t(i),e)return!0;if(i.hasChildren()&&(e=i._descendants(t),e))return!0}return!1}toObject(){const t=dt.prototype.toObject.call(this);return t.children=[],this.children.forEach(e=>{t.children.push(e.toObject())}),t}isAncestorOf(t){let e=t.getParent();for(;e;){if(e._id===this._id)return!0;e=e.getParent()}return!1}clone(t){const e=dt.prototype.clone.call(this,t);return this.children.forEach(function(t){e.add(t.clone())}),e}getAllIntersections(t){const e=[];return this.find("Shape").forEach(i=>{i.isVisible()&&i.intersects(t)&&e.push(i)}),e}_clearSelfAndDescendantCache(t){var e;const i="absoluteTransform"===t;i&&dt._absTransformCascadeDepth++;try{if(super._clearSelfAndDescendantCache(t),i&&this.isCached())return;null===(e=this.children)||void 0===e||e.forEach(function(e){e._clearSelfAndDescendantCache(t)})}finally{if(i&&0===--dt._absTransformCascadeDepth){const t=dt._pendingAfterCascade;if(t.length){dt._pendingAfterCascade=[];for(let e=0;e<t.length;e++)t[e]()}}}}_setChildrenIndices(){var t;null===(t=this.children)||void 0===t||t.forEach(function(t,e){t.index=e}),this._requestDraw()}drawScene(t,e,i){const n=this.getLayer(),s=t||n&&n.getCanvas(),r=s&&s.getContext(),a=this._getCanvasCache(),o=a&&a.scene,h=s&&s.isCache;if(!this.isVisible()&&!h)return this;if(o){r.save();const t=this.getAbsoluteTransform(e).getMatrix();r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(r),r.restore()}else this._drawChildren("drawScene",s,e,i);return this}drawHit(t,e){if(!this.shouldDrawHit(e))return this;const i=this.getLayer(),n=t||i&&i.hitCanvas,s=n&&n.getContext(),r=this._getCachedHitCanvas(e);if(r){s.save();const t=this.getAbsoluteTransform(e).getMatrix();s.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(s,r),s.restore()}else this._drawChildren("drawHit",n,e);return this}_drawChildren(t,e,i,n){var s;const r=e&&e.getContext(),a=this.clipWidth(),o=this.clipHeight(),h=this.clipFunc(),l="number"==typeof a&&"number"==typeof o||h,c=i===this;if(l){r.save();const t=this.getAbsoluteTransform(i);let e,n=t.getMatrix();if(r.transform(n[0],n[1],n[2],n[3],n[4],n[5]),r.beginPath(),h)e=h.call(this,r,this);else{const t=this.clipX(),e=this.clipY();r.rect(t||0,e||0,a,o)}r.clip.apply(r,e),n=t.copy().invert().getMatrix(),r.transform(n[0],n[1],n[2],n[3],n[4],n[5])}const d=!c&&"source-over"!==this.globalCompositeOperation()&&"drawScene"===t;d&&(r.save(),r._applyGlobalCompositeOperation(this)),null===(s=this.children)||void 0===s||s.forEach(function(s){s[t](e,i,n)}),d&&r.restore(),l&&r.restore()}getClientRect(t={}){var e;const i=t.skipTransform,n=t.relativeTo;let s,r,a,o,h={x:1/0,y:1/0,width:0,height:0};const l=this;return null===(e=this.children)||void 0===e||e.forEach(function(e){if(!e.visible())return;const i=e.getClientRect({relativeTo:l,skipShadow:t.skipShadow,skipStroke:t.skipStroke});0===i.width&&0===i.height||!isFinite(i.x+i.y+i.width+i.height)||(void 0===s?(s=i.x,r=i.y,a=i.x+i.width,o=i.y+i.height):(s=Math.min(s,i.x),r=Math.min(r,i.y),a=Math.max(a,i.x+i.width),o=Math.max(o,i.y+i.height)))}),h=void 0!==s?{x:s,y:r,width:a-s,height:o-r}:{x:0,y:0,width:0,height:0},i?h:this._transformedRect(h,n)}}J.addComponentsGetterSetter(ut,"clip",["x","y","width","height"]),J.addGetterSetter(ut,"clipX",void 0,X()),J.addGetterSetter(ut,"clipY",void 0,X()),J.addGetterSetter(ut,"clipWidth",void 0,X()),J.addGetterSetter(ut,"clipHeight",void 0,X()),J.addGetterSetter(ut,"clipFunc");const ft="mouseleave",pt="mouseover",mt="mouseenter",_t="mousemove",vt="mousedown",yt="mouseup",xt="pointermove",bt="pointerdown",St="pointerup",wt="pointercancel",Ct="pointerout",kt="pointerleave",Pt="pointerover",At="pointerenter",Tt="contextmenu",Mt="touchstart",Et="touchend",Rt="touchmove",Gt="touchcancel",Lt="wheel",Dt=[[mt,"_pointerenter"],[vt,"_pointerdown"],[_t,"_pointermove"],[yt,"_pointerup"],[ft,"_pointerleave"],[Mt,"_pointerdown"],[Rt,"_pointermove"],[Et,"_pointerup"],[Gt,"_pointercancel"],[pt,"_pointerover"],[Lt,"_wheel"],[Tt,"_contextmenu"],[bt,"_pointerdown"],[xt,"_pointermove"],[St,"_pointerup"],[wt,"_pointercancel"],[kt,"_pointerleave"],["lostpointercapture","_lostpointercapture"]],It={mouse:{[Ct]:"mouseout",[kt]:ft,[Pt]:pt,[At]:mt,[xt]:_t,[bt]:vt,[St]:yt,[wt]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[Ct]:"touchout",[kt]:"touchleave",[Pt]:"touchover",[At]:"touchenter",[xt]:Rt,[bt]:Mt,[St]:Et,[wt]:Gt,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[Ct]:Ct,[kt]:kt,[Pt]:Pt,[At]:At,[xt]:xt,[bt]:bt,[St]:St,[wt]:wt,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},Ft=t=>t.indexOf("pointer")>=0?"pointer":t.indexOf("touch")>=0?"touch":"mouse",Ot=t=>{const e=Ft(t);return"pointer"===e?i.pointerEventsEnabled&&It.pointer:"touch"===e?It.touch:"mouse"===e?It.mouse:void 0};function Bt(t={}){return(t.clipFunc||t.clipWidth||t.clipHeight)&&C.warn("Stage does not support clipping. Please use clip for Layers or Groups."),t}const Nt=[],Wt=new WeakSet,Ht=t=>{t&&!Wt.has(t)&&(Wt.add(t),D._listenToWindow(t),t.document.addEventListener("visibilitychange",()=>{Nt.forEach(t=>{t.batchDraw()})}))};class zt extends ut{constructor(t){super(Bt(t)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),Nt.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{Bt(this.attrs)}),this._checkVisibility()}_validateAdd(t){const e="Layer"===t.getType(),i="FastLayer"===t.getType();e||i||C.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const t=this.visible()?"":"none";this.content.style.display=t}_getOwnerWindow(){var t;const e=this.content||this.container();return(null===(t=null==e?void 0:e.ownerDocument)||void 0===t?void 0:t.defaultView)||(i.isBrowser?window:null)}setContainer(t){if("string"==typeof t){let e;if("."===t.charAt(0)){const e=t.slice(1);t=document.getElementsByClassName(e)[0]}else e="#"!==t.charAt(0)?t:t.slice(1),t=document.getElementById(e);if(!t)throw"Can not find container in document with id "+e}return this._setAttr("container",t),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),t.appendChild(this.content),Ht(this._getOwnerWindow())),this}shouldDrawHit(){return!0}clear(){const t=this.children,e=t.length;for(let i=0;i<e;i++)t[i].clear();return this}clone(t){return t||(t={}),t.container="undefined"!=typeof document&&document.createElement("div"),ut.prototype.clone.call(this,t)}destroy(){super.destroy(),["mouse","touch","pointer"].forEach(t=>{clearTimeout(this["_"+t+"DblTimeout"]),i["_"+t+"InDblClickWindow"]=!1});const t=this.content;t&&C._isInDocument(t)&&this.container().removeChild(t);const e=Nt.indexOf(this);return e>-1&&Nt.splice(e,1),C.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const t=this._pointerPositions[0]||this._changedPointerPositions[0];return t?{x:t.x,y:t.y}:(C.warn("Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);"),null)}_getPointerById(t){return this._pointerPositions.find(e=>e.id===t)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(t){(t={...t}).x=t.x||0,t.y=t.y||0,t.width=t.width||this.width(),t.height=t.height||this.height();const e=new G({width:t.width,height:t.height,pixelRatio:t.pixelRatio||1}),i=e.getContext()._context,n=this.children;return(t.x||t.y)&&i.translate(-1*t.x,-1*t.y),n.forEach(function(e){if(!e.isVisible())return;const n=e._toKonvaCanvas(t);i.drawImage(n._canvas,t.x,t.y,n.getWidth()/n.getPixelRatio(),n.getHeight()/n.getPixelRatio()),C.releaseCanvas(n._canvas)}),e}getIntersection(t){if(!t)return null;const e=this.children;for(let i=e.length-1;i>=0;i--){const n=e[i].getIntersection(t);if(n)return n}return null}_resizeDOM(){const t=this.width(),e=this.height();this.content&&(this.content.style.width=t+"px",this.content.style.height=e+"px"),this.children.forEach(i=>{i._setSize({width:t,height:e}),i.draw()})}_syncBufferSize(t){return t.setSizeIfChanged(this.width(),this.height()),t}add(t,...e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}super.add(t);const n=this.children.length;return n>5&&C.warn("The stage has "+n+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),t._setSize({width:this.width(),height:this.height()}),t.draw(),i.isBrowser&&this.content.appendChild(t.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(t){return N(t,this)}setPointerCapture(t){W(t,this)}releaseCapture(t){H(t,this)}getLayers(){return this.getChildren()}_bindContentEvents(){i.isBrowser&&Dt.forEach(([t,e])=>{this.content.addEventListener(t,t=>{this._batchEvents(()=>this[e](t))},{passive:!1})})}_batchEvents(t){C._batchEvents(this.eventBatchFunc(),t)}_pointerenter(t){this.setPointersPositions(t);const e=Ot(t.type);e&&this._fire(e.pointerenter,{evt:t,target:this,currentTarget:this})}_pointerover(t){this.setPointersPositions(t);const e=Ot(t.type);e&&this._fire(e.pointerover,{evt:t,target:this,currentTarget:this})}_getTargetShape(t){let e=this[t+"targetShape"];return e&&!e.getStage()&&(e=null),e}_pointerleave(t){const e=Ot(t.type),n=Ft(t.type);if(!e)return;this.setPointersPositions(t);const s=this._getTargetShape(n),r=!(i.isDragging()||i.isTransforming())||i.hitOnDragEnabled;s&&r?(s._fireAndBubble(e.pointerout,{evt:t}),s._fireAndBubble(e.pointerleave,{evt:t}),this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this[n+"targetShape"]=null):r&&(this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this._fire(e.pointerout,{evt:t,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}_pointerdown(t){const e=Ot(t.type),n=Ft(t.type);if(!e)return;this.setPointersPositions(t);let s=!1;this._changedPointerPositions.forEach(r=>{const a=this.getIntersection(r);if(D.justDragged=!1,i["_"+n+"ListenClick"]=!0,!a||!a.isListening())return void(this[n+"ClickStartShape"]=void 0);i.capturePointerEventsEnabled&&a.setPointerCapture(r.id),this[n+"ClickStartShape"]=a,a._fireAndBubble(e.pointerdown,{evt:t,pointerId:r.id}),s=!0;const o=t.type.indexOf("touch")>=0;a.preventDefault()&&t.cancelable&&o&&t.preventDefault()}),s||this._fire(e.pointerdown,{evt:t,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(t){const e=Ot(t.type),n=Ft(t.type);if(!e)return;const s=t.type.indexOf("touch")>=0||"touch"===t.pointerType;i.isDragging()&&D.node.preventDefault()&&t.cancelable&&s&&t.preventDefault(),this.setPointersPositions(t);if(!(!(i.isDragging()||i.isTransforming())||i.hitOnDragEnabled))return;const r={};let a=!1;const o=this._getTargetShape(n);this._changedPointerPositions.forEach(i=>{const s=O(i.id)||this.getIntersection(i),h=i.id,l={evt:t,pointerId:h},c=o!==s;if(c&&o&&(o._fireAndBubble(e.pointerout,{...l},s),o._fireAndBubble(e.pointerleave,{...l},s)),s){if(r[s._id])return;r[s._id]=!0}s&&s.isListening()?(a=!0,c&&(s._fireAndBubble(e.pointerover,{...l},o),s._fireAndBubble(e.pointerenter,{...l},o),this[n+"targetShape"]=s),s._fireAndBubble(e.pointermove,{...l})):o&&(this._fire(e.pointerover,{evt:t,target:this,currentTarget:this,pointerId:h}),this[n+"targetShape"]=null)}),a||this._fire(e.pointermove,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(t){const e=Ot(t.type),n=Ft(t.type);if(!e)return;this.setPointersPositions(t);const s=D.justDragged||"pointer"===n&&i.isDragging(),r=i["_"+n+"ListenClick"]&&!s,a=this[n+"ClickStartShape"],o=this[n+"ClickEndShape"],h={};let l=!1;this._changedPointerPositions.forEach(c=>{const d=O(c.id)||this.getIntersection(c);if(d){if(d.releaseCapture(c.id),h[d._id])return;h[d._id]=!0}const g=c.id,u={evt:t,pointerId:g};let f=!1;i["_"+n+"InDblClickWindow"]?(f=!0,clearTimeout(this["_"+n+"DblTimeout"])):s||(i["_"+n+"InDblClickWindow"]=!0,clearTimeout(this["_"+n+"DblTimeout"])),this["_"+n+"DblTimeout"]=setTimeout(function(){i["_"+n+"InDblClickWindow"]=!1},i.dblClickWindow),d&&d.isListening()?(l=!0,this[n+"ClickEndShape"]=d,d._fireAndBubble(e.pointerup,{...u}),r&&a===d&&(d._fireAndBubble(e.pointerclick,{...u}),f&&o&&o===d&&d._fireAndBubble(e.pointerdblclick,{...u}))):(this[n+"ClickEndShape"]=null,l||(this._fire(e.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),l=!0),r&&this._fire(e.pointerclick,{evt:t,target:this,currentTarget:this,pointerId:g}),f&&this._fire(e.pointerdblclick,{evt:t,target:this,currentTarget:this,pointerId:g}))}),l||this._fire(e.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),i["_"+n+"ListenClick"]=!1,t.cancelable&&"touch"!==n&&"pointer"!==n&&t.preventDefault()}_contextmenu(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(Tt,{evt:t}):this._fire(Tt,{evt:t,target:this,currentTarget:this})}_wheel(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(Lt,{evt:t}):this._fire(Lt,{evt:t,target:this,currentTarget:this})}_pointercancel(t){this.setPointersPositions(t);const e=Ot(t.type);this._changedPointerPositions.forEach(i=>{const n=O(i.id)||this.getIntersection(i),s={evt:t,pointerId:i.id};n?(e&&n._fireAndBubble(e.pointercancel,{...s}),n._fireAndBubble(St,{...s})):e&&this._fire(e.pointercancel,{...s,target:this,currentTarget:this}),H(i.id)})}_lostpointercapture(t){H(t.pointerId)}setPointersPositions(t){const e=this._getContentPosition();let i=null,n=null;void 0!==(t=t||window.event).touches?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(t.touches,t=>{this._pointerPositions.push({id:t.identifier,x:(t.clientX-e.left)/e.scaleX,y:(t.clientY-e.top)/e.scaleY})}),Array.prototype.forEach.call(t.changedTouches||t.touches,t=>{this._changedPointerPositions.push({id:t.identifier,x:(t.clientX-e.left)/e.scaleX,y:(t.clientY-e.top)/e.scaleY})})):(i=(t.clientX-e.left)/e.scaleX,n=(t.clientY-e.top)/e.scaleY,this.pointerPos={x:i,y:n},this._pointerPositions=[{x:i,y:n,id:C._getFirstPointerId(t)}],this._changedPointerPositions=[{x:i,y:n,id:C._getFirstPointerId(t)}])}_setPointerPosition(t){C.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(t)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};const t=this.content.getBoundingClientRect();return{top:t.top,left:t.left,scaleX:t.width/this.content.clientWidth||1,scaleY:t.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new G({width:0,height:0}),this.bufferHitCanvas=new L({pixelRatio:1,width:0,height:0}),!i.isBrowser)return;const t=this.container();if(!t)throw"Stage has no container. A container is required.";t.innerHTML="",this.content=t.ownerDocument.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),t.appendChild(this.content),Ht(this._getOwnerWindow()),this._resizeDOM()}cache(){return C.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){var t;return null===(t=this.children)||void 0===t||t.forEach(function(t){t.batchDraw()}),this}}zt.prototype.nodeType="Stage",n(zt),J.addGetterSetter(zt,"container"),J.addGetterSetter(zt,"eventBatchFunc");const Yt="hasShadow",Xt="hasFill",jt="hasStroke",qt="shadowRGBA",Ut="patternImage",Vt="linearGradient",Kt="radialGradient";let $t;function Qt(){return $t||($t=C.createCanvasElement().getContext("2d"),$t)}const Jt={};function Zt(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()}function te(t){t.stroke()}class ee extends dt{constructor(t){let e;super(t);let i=0;for(;e=C.getHitColor(),!e||e in Jt;)if(i++,i>=1e4){C.warn("Failed to find a unique color key for a shape. Konva may work incorrectly. Most likely your browser is using canvas farbling. Consider disabling it."),e=C.getRandomColor();break}this.colorKey=e,Jt[e]=this}getContext(){return C.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return C.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(Yt,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&0!==this.shadowOpacity()&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(Ut,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const t=Qt().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){const e=new r;e.translate(this.fillPatternX(),this.fillPatternY()),e.rotate(i.getAngle(this.fillPatternRotation())),e.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),e.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const n=e.getMatrix(),s="undefined"==typeof DOMMatrix?{a:n[0],b:n[1],c:n[2],d:n[3],e:n[4],f:n[5]}:new DOMMatrix(n);t.setTransform(s)}return t}}_getLinearGradient(){return this._getCache(Vt,this.__getLinearGradient)}__getLinearGradient(){const t=this.fillLinearGradientColorStops();if(t){const e=Qt(),i=this.fillLinearGradientStartPoint(),n=this.fillLinearGradientEndPoint(),s=e.createLinearGradient(i.x,i.y,n.x,n.y);for(let e=0;e<t.length;e+=2)s.addColorStop(t[e],t[e+1]);return s}}_getRadialGradient(){return this._getCache(Kt,this.__getRadialGradient)}__getRadialGradient(){const t=this.fillRadialGradientColorStops();if(t){const e=Qt(),i=this.fillRadialGradientStartPoint(),n=this.fillRadialGradientEndPoint(),s=e.createRadialGradient(i.x,i.y,this.fillRadialGradientStartRadius(),n.x,n.y,this.fillRadialGradientEndRadius());for(let e=0;e<t.length;e+=2)s.addColorStop(t[e],t[e+1]);return s}}getShadowRGBA(){return this._getCache(qt,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;const t=C.colorToRGBA(this.shadowColor());return t?"rgba("+t.r+","+t.g+","+t.b+","+t.a*(this.shadowOpacity()||1)+")":void 0}hasFill(){return this._getCache(Xt,this._hasFill)}_hasFill(){return this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops())}hasStroke(){return this._getCache(jt,this._hasStroke)}_hasStroke(){return this.strokeEnabled()&&!(!this.strokeWidth()||!this.stroke()&&!this.strokeLinearGradientColorStops())}hasHitStroke(){const t=this.hitStrokeWidth();return"auto"===t?this.hasStroke():this.strokeEnabled()&&!!t}intersects(t){const e=this.getStage();if(!e)return!1;const i=e._syncBufferSize(e.bufferHitCanvas);i.getContext().clear(),this.drawHit(i);return i.context.getImageData(Math.floor(t.x),Math.floor(t.y),1,1).data[3]>0}destroy(){return dt.prototype.destroy.call(this),delete Jt[this.colorKey],delete this.colorKey,this}_useBufferCanvas(t){var e;if(!(null===(e=this.attrs.perfectDrawEnabled)||void 0===e||e))return!1;const i=t||this.hasFill(),n=this.hasStroke(),s=1!==this.getAbsoluteOpacity();if(i&&n&&s)return!0;const r=this.hasShadow(),a=this.shadowForStrokeEnabled();return!!(i&&n&&r&&a)}setStrokeHitEnabled(t){C.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),t?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return 0!==this.hitStrokeWidth()}getSelfRect(){const t=this.size();return{x:this._centroid?-t.width/2:0,y:this._centroid?-t.height/2:0,width:t.width,height:t.height}}getClientRect(t={}){const e=t.skipTransform,i=t.relativeTo,n=this.getSelfRect(),s=!t.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,r=n.width+s,a=n.height+s,o=!t.skipShadow&&this.hasShadow(),h=o?this.shadowOffsetX():0,l=o?this.shadowOffsetY():0,c=r+Math.abs(h),d=a+Math.abs(l),g=o&&this.shadowBlur()||0,u={width:c+2*g,height:d+2*g,x:-(s/2+g)+Math.min(h,0)+n.x,y:-(s/2+g)+Math.min(l,0)+n.y};return e?u:this._transformedRect(u,i)}drawScene(t,e,i){const n=this.getLayer(),s=t||n.getCanvas(),r=s.getContext(),a=this._getCanvasCache(),o=this.getSceneFunc(),h=this.hasShadow();let l;const c=e===this;if(!this.isVisible()&&!c)return this;if(a){r.save();const t=this.getAbsoluteTransform(e).getMatrix();return r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(r),r.restore(),this}if(!o)return this;if(r.save(),this._useBufferCanvas()){l=this.getStage();const t=i||l._syncBufferSize(l.bufferCanvas),n=t.getContext();i?t.width?(n.save(),n.setTransform(1,0,0,1,0,0),n.clearRect(0,0,t.width,t.height),n.restore()):(t.setSize(s._logicalWidth,s._logicalHeight),n.translate(-t.x,-t.y)):n.clear(),n.save(),n.imageSmoothingEnabled=r.imageSmoothingEnabled,n._applyLineJoin(this),n._applyMiterLimit(this);const a=this.getAbsoluteTransform(e).getMatrix();n.transform(a[0],a[1],a[2],a[3],a[4],a[5]),o.call(this,n,this),n.restore();const d=t.pixelRatio;h&&r._applyShadow(this),c||(r._applyOpacity(this),r._applyGlobalCompositeOperation(this)),r.drawImage(t._canvas,t.x,t.y,t.width/d,t.height/d)}else{if(r._applyLineJoin(this),r._applyMiterLimit(this),!c){const t=this.getAbsoluteTransform(e).getMatrix();r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),r._applyOpacity(this),r._applyGlobalCompositeOperation(this)}h&&r._applyShadow(this),o.call(this,r,this)}return r.restore(),this}drawHit(t,e){if(!this.shouldDrawHit(e))return this;const i=this.getLayer(),n=t||i.hitCanvas,s=n&&n.getContext(),r=this.hitFunc()||this.sceneFunc(),a=this._getCachedHitCanvas(e);if(this.colorKey||C.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),a){s.save();const t=this.getAbsoluteTransform(e).getMatrix();return s.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(s,a),s.restore(),this}if(!r)return this;s.save(),s._applyLineJoin(this),s._applyMiterLimit(this);if(!(this===e)){const t=this.getAbsoluteTransform(e).getMatrix();s.transform(t[0],t[1],t[2],t[3],t[4],t[5])}return r.call(this,s,this),s.restore(),this}drawHitFromCache(t=0){const e=this._getCachedSceneCanvas(),i=this._getCachedHitCanvas(),n=i.getContext(),s=i.getWidth(),r=i.getHeight();n.clear(),n.drawImage(e._canvas,0,0,s/i.pixelRatio,r/i.pixelRatio);try{const e=n.getImageData(0,0,s,r),i=e.data,a=i.length,o=C._hexToRgb(this.colorKey);for(let e=0;e<a;e+=4){i[e+3]>t?(i[e]=o.r,i[e+1]=o.g,i[e+2]=o.b,i[e+3]=255):i[e+3]=0}n.putImageData(e,0,0)}catch(t){C.error("Unable to draw hit graph from cached scene canvas. "+t.message)}return this}hasPointerCapture(t){return N(t,this)}setPointerCapture(t){W(t,this)}releaseCapture(t){H(t,this)}}ee.prototype._fillFunc=Zt,ee.prototype._strokeFunc=te,ee.prototype._fillFuncHit=Zt,ee.prototype._strokeFuncHit=te,ee.prototype._centroid=!1,ee.prototype.nodeType="Shape",n(ee),ee.prototype.on("shadowColorChange.konva shadowBlurChange.konva shadowOffsetXChange.konva shadowOffsetYChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",function(){this._clearCache(Yt)}),ee.prototype.on("shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",function(){this._clearCache(qt)}),ee.prototype.on("fillEnabledChange.konva fillChange.konva fillPatternImageChange.konva fillLinearGradientColorStopsChange.konva fillRadialGradientColorStopsChange.konva",function(){this._clearCache(Xt)}),ee.prototype.on("strokeEnabledChange.konva strokeWidthChange.konva strokeChange.konva strokeLinearGradientColorStopsChange.konva",function(){this._clearCache(jt)}),ee.prototype.on("fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",function(){this._clearCache(Ut)}),ee.prototype.on("fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",function(){this._clearCache(Vt)}),ee.prototype.on("fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",function(){this._clearCache(Kt)}),J.addGetterSetter(ee,"stroke",void 0,V()),J.addGetterSetter(ee,"strokeWidth",2,X()),J.addGetterSetter(ee,"fillAfterStrokeEnabled",!1),J.addGetterSetter(ee,"hitStrokeWidth","auto",q()),J.addGetterSetter(ee,"strokeHitEnabled",!0,K()),J.addGetterSetter(ee,"perfectDrawEnabled",!0,K()),J.addGetterSetter(ee,"shadowForStrokeEnabled",!0,K()),J.addGetterSetter(ee,"lineJoin"),J.addGetterSetter(ee,"lineCap"),J.addGetterSetter(ee,"miterLimit"),J.addGetterSetter(ee,"sceneFunc"),J.addGetterSetter(ee,"hitFunc"),J.addGetterSetter(ee,"dash"),J.addGetterSetter(ee,"dashOffset",0,X()),J.addGetterSetter(ee,"shadowColor",void 0,U()),J.addGetterSetter(ee,"shadowBlur",0,X()),J.addGetterSetter(ee,"shadowOpacity",1,X()),J.addComponentsGetterSetter(ee,"shadowOffset",["x","y"]),J.addGetterSetter(ee,"shadowOffsetX",0,X()),J.addGetterSetter(ee,"shadowOffsetY",0,X()),J.addGetterSetter(ee,"fillPatternImage"),J.addGetterSetter(ee,"fill",void 0,V()),J.addGetterSetter(ee,"fillPatternX",0,X()),J.addGetterSetter(ee,"fillPatternY",0,X()),J.addGetterSetter(ee,"fillLinearGradientColorStops"),J.addGetterSetter(ee,"strokeLinearGradientColorStops"),J.addGetterSetter(ee,"fillRadialGradientStartRadius",0),J.addGetterSetter(ee,"fillRadialGradientEndRadius",0),J.addGetterSetter(ee,"fillRadialGradientColorStops"),J.addGetterSetter(ee,"fillPatternRepeat","repeat"),J.addGetterSetter(ee,"fillEnabled",!0),J.addGetterSetter(ee,"strokeEnabled",!0),J.addGetterSetter(ee,"shadowEnabled",!0),J.addGetterSetter(ee,"dashEnabled",!0),J.addGetterSetter(ee,"strokeScaleEnabled",!0),J.addGetterSetter(ee,"fillPriority","color"),J.addComponentsGetterSetter(ee,"fillPatternOffset",["x","y"]),J.addGetterSetter(ee,"fillPatternOffsetX",0,X()),J.addGetterSetter(ee,"fillPatternOffsetY",0,X()),J.addComponentsGetterSetter(ee,"fillPatternScale",["x","y"]),J.addGetterSetter(ee,"fillPatternScaleX",1,X()),J.addGetterSetter(ee,"fillPatternScaleY",1,X()),J.addComponentsGetterSetter(ee,"fillLinearGradientStartPoint",["x","y"]),J.addComponentsGetterSetter(ee,"strokeLinearGradientStartPoint",["x","y"]),J.addGetterSetter(ee,"fillLinearGradientStartPointX",0),J.addGetterSetter(ee,"strokeLinearGradientStartPointX",0),J.addGetterSetter(ee,"fillLinearGradientStartPointY",0),J.addGetterSetter(ee,"strokeLinearGradientStartPointY",0),J.addComponentsGetterSetter(ee,"fillLinearGradientEndPoint",["x","y"]),J.addComponentsGetterSetter(ee,"strokeLinearGradientEndPoint",["x","y"]),J.addGetterSetter(ee,"fillLinearGradientEndPointX",0),J.addGetterSetter(ee,"strokeLinearGradientEndPointX",0),J.addGetterSetter(ee,"fillLinearGradientEndPointY",0),J.addGetterSetter(ee,"strokeLinearGradientEndPointY",0),J.addComponentsGetterSetter(ee,"fillRadialGradientStartPoint",["x","y"]),J.addGetterSetter(ee,"fillRadialGradientStartPointX",0),J.addGetterSetter(ee,"fillRadialGradientStartPointY",0),J.addComponentsGetterSetter(ee,"fillRadialGradientEndPoint",["x","y"]),J.addGetterSetter(ee,"fillRadialGradientEndPointX",0),J.addGetterSetter(ee,"fillRadialGradientEndPointY",0),J.addGetterSetter(ee,"fillPatternRotation",0),J.addGetterSetter(ee,"fillRule",void 0,U()),J.backCompat(ee,{dashArray:"dash",getDashArray:"getDash",setDashArray:"setDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"});function ie(t,e){return t[e+3]>=128?Jt[C.getHitColorKey(t[e],t[e+1],t[e+2])]:void 0}class ne extends ut{constructor(t){super(t),this.canvas=new G,this.hitCanvas=new L({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(t){return this.getContext().clear(t),this.getHitCanvas().getContext().clear(t),this}setZIndex(t){super.setZIndex(t);const e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),t<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[t+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){dt.prototype.moveToTop.call(this);const t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!dt.prototype.moveUp.call(this))return!1;const t=this.getStage();return!(!t||!t.content)&&(t.content.removeChild(this.getNativeCanvasElement()),this.index<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[this.index+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(dt.prototype.moveDown.call(this)){const t=this.getStage();if(t){const e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(dt.prototype.moveToBottom.call(this)){const t=this.getStage();if(t){const e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){const t=this.getNativeCanvasElement();return dt.prototype.remove.call(this),t&&t.parentNode&&C._isInDocument(t)&&t.parentNode.removeChild(t),this}getStage(){return this.parent}_setSize({width:t,height:e}){return this.canvas.setSize(t,e),this._syncHitCanvasSize(),this._setSmoothEnabled(),this}_syncHitCanvasSize(){const t=this.isListening();this.hitCanvas.setSizeIfChanged((t?this.getWidth():0)||0,(t?this.getHeight():0)||0)}_validateAdd(t){const e=t.getType();"Group"!==e&&"Shape"!==e&&C.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(t){return(t={...t}).width=t.width||this.getWidth(),t.height=t.height||this.getHeight(),t.x=void 0!==t.x?t.x:this.x(),t.y=void 0!==t.y?t.y:this.y(),dt.prototype._toKonvaCanvas.call(this,t)}_checkVisibility(){const t=this.visible();this.canvas._canvas.style.display=t?"block":"none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){C.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){C.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){var t;return this._waitingForDraw||(this._waitingForDraw=!0,C.requestAnimFrame(()=>{this._waitingForDraw=!1,this.draw()},null===(t=this.getStage())||void 0===t?void 0:t._getOwnerWindow())),this}getIntersection(t){if(!this.isListening()||!this.isVisible())return null;const e=this._getIntersection(t);if(e.shape)return e.shape;if(!e.antialiased)return null;const i=this.hitCanvas.pixelRatio,n=Math.floor(t.x*i),s=Math.floor(t.y*i),r=t=>this.hitCanvas.context.getImageData(n-t,s-t,2*t+1,2*t+1).data;let a=10,o=2*a+1,h=r(a),l=h[4*(a*o+a)+3];for(let t=1;t<=256;t++){t>a&&(a=Math.min(256,2*a),o=2*a+1,h=r(a));let e=0;for(let i=-t;i<=t;i++){const n=Math.abs(i)===t?1:2*t;for(let s=-t;s<=t;s+=n){const t=4*((i+a)*o+s+a),n=ie(h,t);if(n)return n;e=Math.max(e,h[t+3])}}if(e<=l&&255!==e)return null;l=e}return null}_getIntersection(t){if(!this.hitCanvas.width||!this.hitCanvas.height)return{};const e=this.hitCanvas.pixelRatio,i=this.hitCanvas.context.getImageData(Math.floor(t.x*e),Math.floor(t.y*e),1,1).data,n=ie(i,0);return n?{shape:n}:i[3]>0?{antialiased:!0}:{}}drawScene(t,e,i){const n=this.getLayer(),s=t||n&&n.getCanvas();return this._fire("beforeDraw",{node:this}),this.clearBeforeDraw()&&s.getContext().clear(),ut.prototype.drawScene.call(this,s,e,i),this._fire("draw",{node:this}),this}shouldDrawHit(t){var e;if(!super.shouldDrawHit(t))return!1;if(t||i.hitOnDragEnabled)return!0;let n=!1;return D._dragElements.forEach(t=>{"dragging"!==t.dragStatus||"Stage"!==t.node.nodeType&&t.node.getLayer()!==this||(n=!0)}),!n&&!(null===(e=i.Transformer)||void 0===e?void 0:e._isLayerTransforming(this))}drawHit(t,e){const i=this.getLayer(),n=t||i&&i.hitCanvas;return!t&&i&&(i._syncHitCanvasSize(),i.clearBeforeDraw()&&i.getHitCanvas().getContext().clear()),ut.prototype.drawHit.call(this,n,e),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(t){C.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(t)}getHitGraphEnabled(t){return C.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(!this.parent||!this.parent.content)return;const t=this.parent;!!this.hitCanvas._canvas.parentNode?t.content.removeChild(this.hitCanvas._canvas):t.content.appendChild(this.hitCanvas._canvas)}destroy(){return C.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}}ne.prototype.nodeType="Layer",n(ne),J.addGetterSetter(ne,"imageSmoothingEnabled",!0),J.addGetterSetter(ne,"clearBeforeDraw",!0),J.addOverloadedGetterSetter(ne,"hitGraphEnabled");class se extends ne{constructor(t){super(t),this.listening(!1),C.warn('Konva.FastLayer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}}se.prototype.nodeType="FastLayer",n(se);class re extends ut{_validateAdd(t){const e=t.getType();"Group"!==e&&"Shape"!==e&&C.throw("You may only add groups and shapes to groups.")}}var ae;re.prototype.nodeType="Group",n(re);const oe=(null===(ae=e.performance)||void 0===ae?void 0:ae.now)?()=>e.performance.now():Date.now;class he{constructor(t,e){this.id=he.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:oe(),frameRate:0},this.func=t,this.setLayers(e)}setLayers(t){return this.layers=t?[].concat(t):[],this}getLayers(){return this.layers}addLayer(t){const e=this.layers,i=e.length;for(let n=0;n<i;n++)if(e[n]._id===t._id)return!1;return this.layers.push(t),!0}isRunning(){return he.animations.has(this)}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=oe(),he._addAnimation(this),this}stop(){return he._removeAnimation(this),this}_updateFrameObject(t){this.frame.timeDiff=t-this.frame.lastTime,this.frame.lastTime=t,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(t){this.animations.add(t),this._handleAnimation()}static _removeAnimation(t){this.animations.delete(t)}static _runFrames(){const t=new Set;Array.from(this.animations).forEach(e=>{this.animations.has(e)&&(e._updateFrameObject(oe()),e.func&&!1===e.func.call(e,e.frame)||e.layers.forEach(e=>e&&t.add(e)))}),t.forEach(t=>t.batchDraw())}static _animationLoop(){const t=he;t.animations.size?(t._runFrames(),C.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,C.requestAnimFrame(this._animationLoop))}}he.animations=new Set,he.animIdCounter=0,he.animRunning=!1;const le={node:1,duration:1,easing:1,onFinish:1,onUpdate:1,onReset:1,yoyo:1},ce=["fill","stroke","shadowColor"];let de=0;function ge(t){return C.colorToRGBA(t)||C.throw('can not tween the color "'+t+'", because it is not a valid color.')}class ue{constructor(t,e,i,n,s,r,a){this.prop=t,this.propFunc=e,this.begin=n,this._pos=n,this.duration=r,this._change=0,this.prevPos=0,this.yoyo=a,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=i,this._change=s-this.begin,this.pause()}fire(t){const e=this[t];e&&e()}setTime(t){t>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():t<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=t,this.update())}getTime(){return this._time}setPosition(t){this.prevPos=this._pos,this.propFunc(t),this._pos=t}getPosition(t){return void 0===t&&(t=this._time),this.func(t,this.begin,this._change,this.duration)}play(){this.state=2,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=3,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(t){this.pause(),this._time=t,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){const t=this.getTimer()-this._startTime;2===this.state?this.setTime(t):3===this.state&&this.setTime(this.duration-t)}pause(){this.state=1,this.fire("onPause")}getTimer(){return Date.now()}}class fe{constructor(t){const e=this,n=t.node,s=n._id,r=t.easing||pe.Linear,a=!!t.yoyo;let o,h;o=void 0===t.duration?.3:0===t.duration?.001:t.duration,this.node=n,this._id=de++;const l=n.getLayer()||(n instanceof i.Stage?n.getLayers():null);for(h in l||C.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new he(function(){e.tween.onEnterFrame()},l),this.tween=new ue(h,function(t){e._tweenFunc(t)},r,0,1,1e3*o,a),this._addListeners(),fe.attrs[s]||(fe.attrs[s]={}),fe.attrs[s][this._id]||(fe.attrs[s][this._id]={}),fe.tweens[s]||(fe.tweens[s]={}),t)void 0===le[h]&&this._addAttr(h,t[h]);this.reset(),this.onFinish=t.onFinish,this.onReset=t.onReset,this.onUpdate=t.onUpdate}_addAttr(t,e){if(C._isPlainObject(e)){for(const i in e)this._addAttr(t+C._capitalize(i),e[i]);return}const i=this.node,n=i._id;let s,r,a,o,h;const l=fe.tweens[n][t];void 0!==l&&delete fe.attrs[n][l][t];let c=i.getAttr(t);if(C._isArray(e))if(s=[],c=(c||[]).slice(),r=Math.max(e.length,c.length),"points"===t&&e.length!==c.length&&(e.length>c.length?(o=c,c=C._prepareArrayForTween(c,e,i.closed())):(a=e,e=C._prepareArrayForTween(e,c,i.closed()))),0===t.indexOf("fill"))for(let t=0;t<r;t++)if(t%2==0)s.push(e[t]-(c[t]||0));else{const i=ge(c[t]);h=ge(e[t]),c[t]=i,s.push({r:h.r-i.r,g:h.g-i.g,b:h.b-i.b,a:h.a-i.a})}else for(let t=0;t<r;t++)s.push(e[t]-(c[t]||0));else-1!==ce.indexOf(t)?(c=ge(c),h=ge(e),s={r:h.r-c.r,g:h.g-c.g,b:h.b-c.b,a:h.a-c.a}):s=e-c;fe.attrs[n][this._id][t]={start:c,diff:s,end:e,trueEnd:a,trueStart:o},fe.tweens[n][t]=this._id}_tweenFunc(t){const e=this.node,i=fe.attrs[e._id][this._id];let n,s,r,a,o,h,l,c;for(n in i){if(s=i[n],r=s.start,a=s.diff,c=s.end,C._isArray(r))if(o=[],l=Math.max(r.length,c.length),0===n.indexOf("fill"))for(h=0;h<l;h++)h%2==0?o.push((r[h]||0)+a[h]*t):o.push("rgba("+Math.round(r[h].r+a[h].r*t)+","+Math.round(r[h].g+a[h].g*t)+","+Math.round(r[h].b+a[h].b*t)+","+(r[h].a+a[h].a*t)+")");else for(h=0;h<l;h++)o.push((r[h]||0)+a[h]*t);else o=-1!==ce.indexOf(n)?"rgba("+Math.round(r.r+a.r*t)+","+Math.round(r.g+a.g*t)+","+Math.round(r.b+a.b*t)+","+(r.a+a.a*t)+")":r+a*t;e.setAttr(n,o)}}_addListeners(){const t=`destroy.konva-tween${this._id}`,e=()=>this.destroy(),i=()=>{this.node.off(t).on(t,e),this.anim.start()};this.tween.onPlay=i,this.tween.onReverse=i,this.tween.onPause=()=>{this.node.off(t),this.anim.stop()},this.tween.onFinish=()=>{const t=this.node,e=fe.attrs[t._id][this._id];e.points&&e.points.trueEnd&&t.setAttr("points",e.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{const t=this.node,e=fe.attrs[t._id][this._id];e.points&&e.points.trueStart&&t.points(e.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(t){return this.tween.seek(1e3*t),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){var t;const e=this.node._id,i=this._id,n=null===(t=fe.attrs[e])||void 0===t?void 0:t[i],s=fe.tweens[e];if(this.pause(),this.anim&&this.anim.stop(),n){if(s){for(const t in n)delete s[t];0===Object.keys(s).length&&delete fe.tweens[e]}delete fe.attrs[e][i],0===Object.keys(fe.attrs[e]).length&&delete fe.attrs[e]}}}fe.attrs={},fe.tweens={},dt.prototype.to=function(t){const e=t.onFinish,i=new fe({...t,node:this,onFinish(){i.destroy(),e&&e()}});return i.play(),i};const pe={BackEaseIn(t,e,i,n){const s=1.70158;return i*(t/=n)*t*((s+1)*t-s)+e},BackEaseOut(t,e,i,n){const s=1.70158;return i*((t=t/n-1)*t*((s+1)*t+s)+1)+e},BackEaseInOut(t,e,i,n){let s=1.70158;return(t/=n/2)<1?i/2*(t*t*((1+(s*=1.525))*t-s))+e:i/2*((t-=2)*t*((1+(s*=1.525))*t+s)+2)+e},ElasticEaseIn(t,e,i,n,s,r){let a=0;return 0===t?e:1===(t/=n)?e+i:(r||(r=.3*n),!s||s<Math.abs(i)?(s=i,a=r/4):a=r/(2*Math.PI)*Math.asin(i/s),-s*Math.pow(2,10*(t-=1))*Math.sin((t*n-a)*(2*Math.PI)/r)+e)},ElasticEaseOut(t,e,i,n,s,r){let a=0;return 0===t?e:1===(t/=n)?e+i:(r||(r=.3*n),!s||s<Math.abs(i)?(s=i,a=r/4):a=r/(2*Math.PI)*Math.asin(i/s),s*Math.pow(2,-10*t)*Math.sin((t*n-a)*(2*Math.PI)/r)+i+e)},ElasticEaseInOut(t,e,i,n,s,r){let a=0;return 0===t?e:2==(t/=n/2)?e+i:(r||(r=n*(.3*1.5)),!s||s<Math.abs(i)?(s=i,a=r/4):a=r/(2*Math.PI)*Math.asin(i/s),t<1?s*Math.pow(2,10*(t-=1))*Math.sin((t*n-a)*(2*Math.PI)/r)*-.5+e:s*Math.pow(2,-10*(t-=1))*Math.sin((t*n-a)*(2*Math.PI)/r)*.5+i+e)},BounceEaseOut:(t,e,i,n)=>(t/=n)<1/2.75?i*(7.5625*t*t)+e:t<2/2.75?i*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?i*(7.5625*(t-=2.25/2.75)*t+.9375)+e:i*(7.5625*(t-=2.625/2.75)*t+.984375)+e,BounceEaseIn:(t,e,i,n)=>i-pe.BounceEaseOut(n-t,0,i,n)+e,BounceEaseInOut:(t,e,i,n)=>t<n/2?.5*pe.BounceEaseIn(2*t,0,i,n)+e:.5*pe.BounceEaseOut(2*t-n,0,i,n)+.5*i+e,EaseIn:(t,e,i,n)=>i*(t/=n)*t+e,EaseOut:(t,e,i,n)=>-i*(t/=n)*(t-2)+e,EaseInOut:(t,e,i,n)=>(t/=n/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e,StrongEaseIn:(t,e,i,n)=>i*(t/=n)*t*t*t*t+e,StrongEaseOut:(t,e,i,n)=>i*((t=t/n-1)*t*t*t*t+1)+e,StrongEaseInOut:(t,e,i,n)=>(t/=n/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e,Linear:(t,e,i,n)=>i*t/n+e},me=C._assign(i,{Util:C,Transform:r,Node:dt,Container:ut,Stage:zt,stages:Nt,Layer:ne,FastLayer:se,Group:re,DD:D,Shape:ee,shapes:Jt,Animation:he,Tween:fe,Easings:pe,Context:T,Canvas:R});class _e extends ee{_sceneFunc(t){const e=i.getAngle(this.angle()),n=this.clockwise();t.beginPath(),t.arc(0,0,Math.abs(this.outerRadius()),0,e,n),t.arc(0,0,Math.abs(this.innerRadius()),e,0,!n),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*Math.abs(this.outerRadius())}getHeight(){return 2*Math.abs(this.outerRadius())}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}getSelfRect(){const t=Math.abs(this.innerRadius()),e=Math.abs(this.outerRadius()),n=this.clockwise(),s=i.getAngle(this.angle());if(s%(2*Math.PI)==0)return 0!==s?{x:-e,y:-e,width:2*e,height:2*e}:{x:t,y:0,width:e-t,height:0};const r=i.getAngle(n?360-this.angle():this.angle()),a=Math.cos(Math.min(r,Math.PI)),o=Math.sin(Math.min(Math.max(Math.PI,r),3*Math.PI/2)),h=Math.sin(Math.min(r,Math.PI/2)),l=a*(a>0?t:e),c=o*(o>0?t:e),d=h*(h>0?e:t);return{x:l,y:n?-1*d:c,width:1*e-l,height:d-c}}}_e.prototype._centroid=!0,_e.prototype.className="Arc",_e.prototype._attrsAffectingSize=["innerRadius","outerRadius","angle","clockwise"],n(_e),J.addGetterSetter(_e,"innerRadius",0,X()),J.addGetterSetter(_e,"outerRadius",0,X()),J.addGetterSetter(_e,"angle",0,X()),J.addGetterSetter(_e,"clockwise",!1,K());const ve=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],ye=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],xe=[[1],[1,1],[1,2,1],[1,3,3,1]],be=(t,e,i)=>{let n,s;const r=i/2;n=0;for(let i=0;i<20;i++)s=r*ve[20][i]+r,n+=ye[20][i]*we(t,e,s);return r*n},Se=(t,e,i)=>{void 0===i&&(i=1);const n=t[0]-2*t[1]+t[2],s=e[0]-2*e[1]+e[2],r=2*t[1]-2*t[0],a=2*e[1]-2*e[0],o=4*(n*n+s*s),h=4*(n*r+s*a),l=r*r+a*a;if(0===o)return i*Math.sqrt(Math.pow(t[2]-t[0],2)+Math.pow(e[2]-e[0],2));const c=h/(2*o),d=i+c,g=l/o-c*c,u=d*d+g>0?Math.sqrt(d*d+g):0,f=c*c+g>0?Math.sqrt(c*c+g):0,p=c+Math.sqrt(c*c+g)!==0?g*Math.log(Math.abs((d+u)/(c+f))):0;return Math.sqrt(o)/2*(d*u-c*f+p)};function we(t,e,i){const n=Ce(1,i,t),s=Ce(1,i,e),r=n*n+s*s;return Math.sqrt(r)}const Ce=(t,e,i)=>{const n=i.length-1;let s,r;if(0===n)return 0;if(0===t){r=0;for(let t=0;t<=n;t++)r+=xe[n][t]*Math.pow(1-e,n-t)*Math.pow(e,t)*i[t];return r}s=new Array(n);for(let t=0;t<n;t++)s[t]=n*(i[t+1]-i[t]);return Ce(t-1,e,s)},ke=(t,e,i)=>{let n=1,s=t/e,r=(t-i(s))/e,a=0;for(;n>.001;){const o=i(s+r),h=Math.abs(t-o)/e;if(h<n)n=h,s+=r;else{const a=i(s-r),o=Math.abs(t-a)/e;o<n?(n=o,s-=r):r/=2}if(a++,a>500)break}return s},Pe=(t,e,i,n)=>{const s=1-n;return s*s*t+2*s*n*e+n*n*i},Ae=(t,e,i,n,s,r)=>{const a=[];for(const o of[[t,i,s],[e,n,r]]){const h=(o[0]-o[1])/(o[0]-2*o[1]+o[2]);h>0&&h<1&&a.push(Pe(t,i,s,h),Pe(e,n,r,h))}return a},Te=(t,e,i,n,s)=>{const r=1-s;return r*r*r*t+3*r*r*s*e+3*r*s*s*i+s*s*s*n},Me=(t,e,i,n,s,r,a,o)=>{const h=[];for(const l of[[t,i,s,a],[e,n,r,o]]){const c=-3*l[0]+9*l[1]-9*l[2]+3*l[3],d=6*l[0]-12*l[1]+6*l[2],g=-3*l[0]+3*l[1],u=d*d-4*c*g;if(u<0)continue;const f=-(d+(d<0?-1:1)*Math.sqrt(u))/2;for(const l of[f/c,g/f])l>0&&l<1&&h.push(Te(t,i,s,a,l),Te(e,n,r,o,l))}return h};function Ee(t,e,i,n,s,r,a){const o=Math.sqrt(Math.pow(i-t,2)+Math.pow(n-e,2)),h=Math.sqrt(Math.pow(s-i,2)+Math.pow(r-n,2)),l=o+h;if(0===l)return[i,n,i,n];const c=a*o/l,d=a*h/l;return[i-c*(s-t),n-c*(r-e),i+d*(s-t),n+d*(r-e)]}function Re(t,e){const i=t.length,n=[];for(let s=2;s<i-2;s+=2){const i=Ee(t[s-2],t[s-1],t[s],t[s+1],t[s+2],t[s+3],e);isNaN(i[0])||(n.push(i[0]),n.push(i[1]),n.push(t[s]),n.push(t[s+1]),n.push(i[2]),n.push(i[3]))}return n}function Ge(t){const e=[];for(let i=0;i+7<t.length;i+=6)e.push(t[i+6],t[i+7],...Me(t[i],t[i+1],t[i+2],t[i+3],t[i+4],t[i+5],t[i+6],t[i+7]));return e}class Le extends ee{constructor(t){super(t),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",function(){this._clearCache("tensionPoints")})}_hasTension(){return 0!==this.tension()&&this.points().length>4}_eachTensionSegment(t,e){const i=this.points(),n=i.length,s=this.closed(),r=this.getTensionPoints(),a=r.length;let o=i[0],h=i[1],l=s?0:4;for(s||(t(o,h,r[0],r[1],r[2],r[3]),o=r[2],h=r[3]);l<a-2;){const t=r[l++],i=r[l++],n=r[l++],s=r[l++],a=r[l++],c=r[l++];e(o,h,t,i,n,s,a,c),o=a,h=c}s||t(o,h,r[a-2],r[a-1],i[n-2],i[n-1])}_sceneFunc(t){const e=this.points(),i=e.length,n=this.closed(),s=this.bezier();if(!i)return;let r=0;if(t.beginPath(),t.moveTo(e[0],e[1]),this._hasTension())this._eachTensionSegment((e,i,n,s,r,a)=>t.quadraticCurveTo(n,s,r,a),(e,i,n,s,r,a,o,h)=>t.bezierCurveTo(n,s,r,a,o,h));else if(s)for(r=2;r<i;)t.bezierCurveTo(e[r++],e[r++],e[r++],e[r++],e[r++],e[r++]);else for(r=2;r<i;r+=2)t.lineTo(e[r],e[r+1]);n?(t.closePath(),t.fillStrokeShape(this)):t.strokeShape(this)}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():Re(this.points(),this.tension())}_getTensionPointsClosed(){const t=this.points(),e=t.length,i=this.tension(),n=Ee(t[e-2],t[e-1],t[0],t[1],t[2],t[3],i),s=Ee(t[e-4],t[e-3],t[e-2],t[e-1],t[0],t[1],i),r=Re(t,i);return[n[2],n[3]].concat(r).concat([s[0],s[1],t[e-2],t[e-1],s[2],s[3],n[0],n[1],t[0],t[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){let t=this.points();if(t.length<4)return{x:t[0]||0,y:t[1]||0,width:0,height:0};if(this._hasTension()){const e=[t[0],t[1]];this._eachTensionSegment((t,i,n,s,r,a)=>e.push(r,a,...Ae(t,i,n,s,r,a)),(t,i,n,s,r,a,o,h)=>e.push(o,h,...Me(t,i,n,s,r,a,o,h))),t=e}else this.bezier()&&(t=[t[0],t[1],...Ge(t)]);return C._getPointsRect(t)}}Le.prototype.className="Line",Le.prototype._attrsAffectingSize=["points","bezier","tension"],n(Le),J.addGetterSetter(Le,"closed",!1),J.addGetterSetter(Le,"bezier",!1),J.addGetterSetter(Le,"tension",0,X()),J.addGetterSetter(Le,"points",[],function(){if(i.isUnminified)return function(t,e){return t instanceof f||(C._isArray(t)?t.forEach(function(t){C._isNumber(t)||C.warn('"'+e+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")}):C.warn(z(t)+' is a not valid value for "'+e+'" attribute. The value should be a array of numbers.')),t}}());const De={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7,z:0};class Ie extends ee{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=Ie.parsePathData(this.data()),this.pathLength=Ie.getPathLength(this.dataArray)}_sceneFunc(t){const e=this.dataArray;t.beginPath();let i=!1;for(let n=0;n<e.length;n++){const s=e[n].command,r=e[n].points;switch(s){case"L":t.lineTo(r[0],r[1]);break;case"M":t.moveTo(r[0],r[1]);break;case"C":t.bezierCurveTo(r[0],r[1],r[2],r[3],r[4],r[5]);break;case"Q":t.quadraticCurveTo(r[0],r[1],r[2],r[3]);break;case"A":const e=r[0],n=r[1],s=r[2],a=r[3],o=r[4],h=r[5],l=r[6],c=r[7],d=s>a?s:a,g=s>a?1:s/a,u=s>a?a/s:1;t.translate(e,n),t.rotate(l),t.scale(g,u),t.arc(0,0,d,o,o+h,1-c),t.scale(1/g,1/u),t.rotate(-l),t.translate(-e,-n);break;case"z":i=!0,t.closePath()}}i||this.hasFill()?t.fillStrokeShape(this):t.strokeShape(this)}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){let t=[];return this.dataArray.forEach(function(e){if("A"===e.command){const i=e.points[4],n=e.points[5],s=e.points[4]+n;let r=Math.PI/180;if(Math.abs(i-s)<r&&(r=Math.abs(i-s)),n<0)for(let n=i-r;n>s;n-=r){const i=Ie.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],n,e.points[6]);t.push(i.x,i.y)}else for(let n=i+r;n<s;n+=r){const i=Ie.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],n,e.points[6]);t.push(i.x,i.y)}}else"C"===e.command?t.push(e.start.x,e.start.y,e.points[4],e.points[5],...Me(e.start.x,e.start.y,e.points[0],e.points[1],e.points[2],e.points[3],e.points[4],e.points[5])):"Q"===e.command?t.push(e.start.x,e.start.y,e.points[2],e.points[3],...Ae(e.start.x,e.start.y,e.points[0],e.points[1],e.points[2],e.points[3])):t=t.concat(e.points)}),C._getPointsRect(t)}getLength(){return this.pathLength}getPointAtLength(t){return Ie.getPointAtLengthOfDataArray(t,this.dataArray)}static getLineLength(t,e,i,n){return Math.sqrt((i-t)*(i-t)+(n-e)*(n-e))}static getPathLength(t){let e=0;for(let i=0;i<t.length;++i)e+=t[i].pathLength;return e}static getPointAtLengthOfDataArray(t,e){let i,n=0,s=e.length;if(!s)return null;for(;n<s&&t>e[n].pathLength;)t-=e[n].pathLength,++n;if(n===s){for(n--;n>0&&e[n].points.length<2;)n--;t=e[n].pathLength}if(t<.01){return"M"===e[n].command?(i=e[n].points.slice(0,2),{x:i[0],y:i[1]}):{x:e[n].start.x,y:e[n].start.y}}const r=e[n],a=r.points;switch(r.command){case"L":return Ie.getPointOnLine(t,r.start.x,r.start.y,a[0],a[1]);case"C":return Ie.getPointOnCubicBezier(ke(t,r.pathLength,t=>be([r.start.x,a[0],a[2],a[4]],[r.start.y,a[1],a[3],a[5]],t)),r.start.x,r.start.y,a[0],a[1],a[2],a[3],a[4],a[5]);case"Q":return Ie.getPointOnQuadraticBezier(ke(t,r.pathLength,t=>Se([r.start.x,a[0],a[2]],[r.start.y,a[1],a[3]],t)),r.start.x,r.start.y,a[0],a[1],a[2],a[3]);case"A":const e=a[0],i=a[1],n=a[2],s=a[3],o=a[5],h=a[6];let l=a[4];return l+=o*t/r.pathLength,Ie.getPointOnEllipticalArc(e,i,n,s,l,h)}return null}static getPointOnLine(t,e,i,n,s,r,a){r=null!=r?r:e,a=null!=a?a:i;const o=this.getLineLength(e,i,n,s);if(o<1e-10)return{x:e,y:i};if(n===e)return{x:r,y:a+(s>i?t:-t)};const h=(s-i)/(n-e),l=Math.sqrt(t*t/(1+h*h))*(n<e?-1:1),c=h*l;if(Math.abs(a-i-h*(r-e))<1e-10)return{x:r+l,y:a+c};const d=((r-e)*(n-e)+(a-i)*(s-i))/(o*o),g=e+d*(n-e),u=i+d*(s-i),f=this.getLineLength(r,a,g,u),p=Math.sqrt(t*t-f*f),m=Math.sqrt(p*p/(1+h*h))*(n<e?-1:1);return{x:g+m,y:u+h*m}}static getPointOnCubicBezier(t,e,i,n,s,r,a,o,h){function l(t){return t*t*t}function c(t){return 3*t*t*(1-t)}function d(t){return 3*t*(1-t)*(1-t)}function g(t){return(1-t)*(1-t)*(1-t)}return{x:o*l(t)+r*c(t)+n*d(t)+e*g(t),y:h*l(t)+a*c(t)+s*d(t)+i*g(t)}}static getPointOnQuadraticBezier(t,e,i,n,s,r,a){function o(t){return t*t}function h(t){return 2*t*(1-t)}function l(t){return(1-t)*(1-t)}return{x:r*o(t)+n*h(t)+e*l(t),y:a*o(t)+s*h(t)+i*l(t)}}static getPointOnEllipticalArc(t,e,i,n,s,r){const a=Math.cos(r),o=Math.sin(r),h=i*Math.cos(s),l=n*Math.sin(s);return{x:t+(h*a-l*o),y:e+(h*o+l*a)}}static parsePathData(t){if(!t)return[];let e=t;const i=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];e=e.replace(new RegExp(" ","g"),",");for(let t=0;t<i.length;t++)e=e.replace(new RegExp(i[t],"g"),"|"+i[t]);const n=e.split("|"),s=[],r=[];let a=0,o=0;const h=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;let l;for(let t=1;t<n.length;t++){let e=n[t],i=e.charAt(0);for(e=e.slice(1),r.length=0;l=h.exec(e);)r.push(l[0]);let c=[],d="A"===i||"a"===i?0:-1;for(let t=0,e=r.length;t<e;t++){let e=r[t];for(;(3===d||4===d)&&e.length>1&&("0"===e[0]||"1"===e[0]);)c.push(+e[0]),d++,e=e.slice(1);const i=parseFloat(e);c.push(isNaN(i)?0:i),d>=0&&(d=(d+1)%7)}for(;c.length>0&&!(c.length<De[i.toLowerCase()]||"z"===i||"Z"===i);){let t="",e=[];const n=a,r=o;let h,l,d,g,u,f,p,m,_,v;switch(i){case"l":a+=c.shift(),o+=c.shift(),t="L",e.push(a,o);break;case"L":a=c.shift(),o=c.shift(),e.push(a,o);break;case"m":const n=c.shift(),r=c.shift();if(a+=n,o+=r,t="M",s.length>2&&"z"===s[s.length-1].command)for(let t=s.length-2;t>=0;t--)if("M"===s[t].command){a=s[t].points[0]+n,o=s[t].points[1]+r;break}e.push(a,o),i="l";break;case"M":a=c.shift(),o=c.shift(),t="M",e.push(a,o),i="L";break;case"h":a+=c.shift(),t="L",e.push(a,o);break;case"H":a=c.shift(),t="L",e.push(a,o);break;case"v":o+=c.shift(),t="L",e.push(a,o);break;case"V":o=c.shift(),t="L",e.push(a,o);break;case"C":e.push(c.shift(),c.shift(),c.shift(),c.shift()),a=c.shift(),o=c.shift(),e.push(a,o);break;case"c":e.push(a+c.shift(),o+c.shift(),a+c.shift(),o+c.shift()),a+=c.shift(),o+=c.shift(),t="C",e.push(a,o);break;case"S":l=a,d=o,h=s[s.length-1],"C"===(null==h?void 0:h.command)&&(l=a+(a-h.points[2]),d=o+(o-h.points[3])),e.push(l,d,c.shift(),c.shift()),a=c.shift(),o=c.shift(),t="C",e.push(a,o);break;case"s":l=a,d=o,h=s[s.length-1],"C"===(null==h?void 0:h.command)&&(l=a+(a-h.points[2]),d=o+(o-h.points[3])),e.push(l,d,a+c.shift(),o+c.shift()),a+=c.shift(),o+=c.shift(),t="C",e.push(a,o);break;case"Q":e.push(c.shift(),c.shift()),a=c.shift(),o=c.shift(),e.push(a,o);break;case"q":e.push(a+c.shift(),o+c.shift()),a+=c.shift(),o+=c.shift(),t="Q",e.push(a,o);break;case"T":l=a,d=o,h=s[s.length-1],"Q"===(null==h?void 0:h.command)&&(l=a+(a-h.points[0]),d=o+(o-h.points[1])),a=c.shift(),o=c.shift(),t="Q",e.push(l,d,a,o);break;case"t":l=a,d=o,h=s[s.length-1],"Q"===(null==h?void 0:h.command)&&(l=a+(a-h.points[0]),d=o+(o-h.points[1])),a+=c.shift(),o+=c.shift(),t="Q",e.push(l,d,a,o);break;case"A":case"a":if(g=c.shift(),u=c.shift(),f=c.shift(),p=c.shift(),m=c.shift(),_=a,v=o,"a"===i?(a+=c.shift(),o+=c.shift()):(a=c.shift(),o=c.shift()),t="A",a===_&&o===v)continue;g&&u?e=this.convertEndpointToCenterParameterization(_,v,a,o,p,m,g,u,f):(t="L",e.push(a,o))}s.push({command:t||i,points:e,start:{x:n,y:r},pathLength:this.calcLength(n,r,t||i,e)})}"z"!==i&&"Z"!==i||s.push({command:"z",points:[],start:void 0,pathLength:0})}return s}static calcLength(t,e,i,n){let s,r,a,o;const h=Ie;switch(i){case"L":return h.getLineLength(t,e,n[0],n[1]);case"C":return be([t,n[0],n[2],n[4]],[e,n[1],n[3],n[5]],1);case"Q":return Se([t,n[0],n[2]],[e,n[1],n[3]],1);case"A":s=0;const i=n[4],l=n[5],c=n[4]+l;let d=Math.PI/180;if(Math.abs(i-c)<d&&(d=Math.abs(i-c)),r=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],i,0),l<0)for(o=i-d;o>c;o-=d)a=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],o,0),s+=h.getLineLength(r.x,r.y,a.x,a.y),r=a;else for(o=i+d;o<c;o+=d)a=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],o,0),s+=h.getLineLength(r.x,r.y,a.x,a.y),r=a;return a=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],c,0),s+=h.getLineLength(r.x,r.y,a.x,a.y),s}return 0}static convertEndpointToCenterParameterization(t,e,i,n,s,r,a,o,h){const l=h*(Math.PI/180),c=Math.cos(l)*(t-i)/2+Math.sin(l)*(e-n)/2,d=-1*Math.sin(l)*(t-i)/2+Math.cos(l)*(e-n)/2,g=c*c/(a*a)+d*d/(o*o);g>1&&(a*=Math.sqrt(g),o*=Math.sqrt(g));let u=Math.sqrt((a*a*(o*o)-a*a*(d*d)-o*o*(c*c))/(a*a*(d*d)+o*o*(c*c)));s===r&&(u*=-1),isNaN(u)&&(u=0);const f=u*a*d/o,p=u*-o*c/a,m=(t+i)/2+Math.cos(l)*f-Math.sin(l)*p,_=(e+n)/2+Math.sin(l)*f+Math.cos(l)*p,v=function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])},y=function(t,e){return(t[0]*e[0]+t[1]*e[1])/(v(t)*v(e))},x=function(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(y(t,e))},b=x([1,0],[(c-f)/a,(d-p)/o]),S=[(c-f)/a,(d-p)/o],w=[(-1*c-f)/a,(-1*d-p)/o];let C=x(S,w);return y(S,w)<=-1&&(C=Math.PI),y(S,w)>=1&&(C=0),0===r&&C>0&&(C-=2*Math.PI),1===r&&C<0&&(C+=2*Math.PI),[m,_,a,o,b,C,l,r]}}Ie.prototype.className="Path",Ie.prototype._attrsAffectingSize=["data"],n(Ie),J.addGetterSetter(Ie,"data");class Fe extends Le{_sceneFunc(t){super._sceneFunc(t);const e=2*Math.PI,i=this.points();let n=i;const s=0!==this.tension()&&i.length>4;s&&(n=this.getTensionPoints());const r=this.pointerLength(),a=i.length;let o,h;if(s){const t=[n[n.length-4],n[n.length-3],n[n.length-2],n[n.length-1],i[a-2],i[a-1]],e=Ie.calcLength(n[n.length-4],n[n.length-3],"C",t),s=Ie.getPointOnQuadraticBezier(Math.min(1,1-r/e),t[0],t[1],t[2],t[3],t[4],t[5]);o=i[a-2]-s.x,h=i[a-1]-s.y}else o=i[a-2]-i[a-4],h=i[a-1]-i[a-3];const l=(Math.atan2(h,o)+e)%e,c=this.pointerWidth();this.pointerAtEnding()&&(t.save(),t.beginPath(),t.translate(i[a-2],i[a-1]),t.rotate(l),t.moveTo(0,0),t.lineTo(-r,c/2),t.lineTo(-r,-c/2),t.closePath(),t.restore(),this.__fillStroke(t)),this.pointerAtBeginning()&&(t.save(),t.beginPath(),t.translate(i[0],i[1]),s?(o=(n[0]+n[2])/2-i[0],h=(n[1]+n[3])/2-i[1]):(o=i[2]-i[0],h=i[3]-i[1]),t.rotate((Math.atan2(-h,-o)+e)%e),t.moveTo(0,0),t.lineTo(-r,c/2),t.lineTo(-r,-c/2),t.closePath(),t.restore(),this.__fillStroke(t))}__fillStroke(t){const e=this.dashEnabled();e&&(this.attrs.dashEnabled=!1,t.setLineDash([])),t.fillStrokeShape(this),e&&(this.attrs.dashEnabled=!0)}getSelfRect(){const t=super.getSelfRect(),e=this.pointerWidth()/2;return{x:t.x,y:t.y-e,width:t.width,height:t.height+2*e}}}Fe.prototype.className="Arrow",n(Fe),J.addGetterSetter(Fe,"pointerLength",10,X()),J.addGetterSetter(Fe,"pointerWidth",10,X()),J.addGetterSetter(Fe,"pointerAtBeginning",!1),J.addGetterSetter(Fe,"pointerAtEnding",!0);class Oe extends ee{_sceneFunc(t){t.beginPath(),t.arc(0,0,Math.abs(this.attrs.radius||0),0,2*Math.PI,!1),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*Math.abs(this.radius())}getHeight(){return 2*Math.abs(this.radius())}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}}Oe.prototype._centroid=!0,Oe.prototype.className="Circle",Oe.prototype._attrsAffectingSize=["radius"],n(Oe),J.addGetterSetter(Oe,"radius",0,X());class Be extends ee{_sceneFunc(t){const e=Math.abs(this.radiusX()),i=Math.abs(this.radiusY());t.beginPath(),t.ellipse(0,0,e,i,0,0,2*Math.PI,!1),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*Math.abs(this.radiusX())}getHeight(){return 2*Math.abs(this.radiusY())}setWidth(t){this.radiusX(t/2)}setHeight(t){this.radiusY(t/2)}}Be.prototype.className="Ellipse",Be.prototype._centroid=!0,Be.prototype._attrsAffectingSize=["radiusX","radiusY"],n(Be),J.addComponentsGetterSetter(Be,"radius",["x","y"]),J.addGetterSetter(Be,"radiusX",0,X()),J.addGetterSetter(Be,"radiusY",0,X());class Ne extends ee{constructor(t){super(t),this._loadListener=()=>{this._requestDraw()},this.on("imageChange.konva",t=>{this._removeImageLoad(t.oldVal),this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){const t=this.image();t&&t.complete||t&&4===t.readyState||t&&t.addEventListener&&t.addEventListener("load",this._loadListener)}_removeImageLoad(t){t&&t.removeEventListener&&t.removeEventListener("load",this._loadListener)}destroy(){return this._removeImageLoad(this.image()),super.destroy(),this}_useBufferCanvas(){const t=!!this.cornerRadius(),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas(!0)}_sceneFunc(t){const e=this.getWidth(),i=this.getHeight(),n=this.cornerRadius(),s=this.attrs.image;if((this.hasFill()||this.hasStroke()||n)&&(t.beginPath(),n?C.drawRoundedRectPath(t,e,i,n):t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)),s){n&&t.clip();const r=this.attrs.cropWidth,a=this.attrs.cropHeight;r&&a?t.drawImage(s,this.cropX(),this.cropY(),r,a,0,0,e,i):t.drawImage(s,0,0,e,i)}}_hitFunc(t){const e=this.width(),i=this.height(),n=this.cornerRadius();t.beginPath(),n?C.drawRoundedRectPath(t,e,i,n):t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}getWidth(){var t,e,i;return null!==(i=null!==(t=this.attrs.width)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.width)&&void 0!==i?i:0}getHeight(){var t,e,i;return null!==(i=null!==(t=this.attrs.height)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.height)&&void 0!==i?i:0}static fromURL(t,e,i=null){const n=C.createImageElement();n.onload=function(){const t=new Ne({image:n});e(t)},n.onerror=i,n.crossOrigin="Anonymous",n.src=t}}Ne.prototype.className="Image",Ne.prototype._attrsAffectingSize=["image"],n(Ne),J.addGetterSetter(Ne,"cornerRadius",0,j(4)),J.addGetterSetter(Ne,"image"),J.addComponentsGetterSetter(Ne,"crop",["x","y","width","height"]),J.addGetterSetter(Ne,"cropX",0,X()),J.addGetterSetter(Ne,"cropY",0,X()),J.addGetterSetter(Ne,"cropWidth",0,X()),J.addGetterSetter(Ne,"cropHeight",0,X());const We=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],He="up",ze="right",Ye="down",Xe="left",je=We.length;class qe extends re{constructor(t){super(t),this.on("add.konva",function(t){this._addListeners(t.child),this._sync()})}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(t){let e,i=this;const n=function(){i._sync()};for(e=0;e<je;e++)t.on(We[e]+"Change.konva",n)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let t,e,i,n,s,r,a,o=this.getText(),h=this.getTag();if(o&&h){switch(t=o.width(),e=o.height(),i=h.pointerDirection(),n=h.pointerWidth(),a=h.pointerHeight(),s=0,r=0,i){case He:s=t/2,r=-1*a;break;case ze:s=t+n,r=e/2;break;case Ye:s=t/2,r=e+a;break;case Xe:s=-1*n,r=e/2}h.setAttrs({x:-1*s,y:-1*r,width:t,height:e}),o.setAttrs({x:-1*s,y:-1*r})}}}qe.prototype.className="Label",n(qe);class Ue extends ee{_sceneFunc(t){const e=this.width(),i=this.height(),n=this.pointerDirection(),s=this.pointerWidth(),r=this.pointerHeight(),a=this.cornerRadius(),[o,h,l,c]=C._cornerRadii(a,e,i);t.beginPath(),t.moveTo(o,0),n===He&&(t.lineTo((e-s)/2,0),t.lineTo(e/2,-1*r),t.lineTo((e+s)/2,0)),t.lineTo(e-h,0),t.arc(e-h,h,h,3*Math.PI/2,0,!1),n===ze&&(t.lineTo(e,(i-r)/2),t.lineTo(e+s,i/2),t.lineTo(e,(i+r)/2)),t.lineTo(e,i-l),t.arc(e-l,i-l,l,0,Math.PI/2,!1),n===Ye&&(t.lineTo((e+s)/2,i),t.lineTo(e/2,i+r),t.lineTo((e-s)/2,i)),t.lineTo(c,i),t.arc(c,i-c,c,Math.PI/2,Math.PI,!1),n===Xe&&(t.lineTo(0,(i+r)/2),t.lineTo(-1*s,i/2),t.lineTo(0,(i-r)/2)),t.lineTo(0,o),t.arc(o,o,o,Math.PI,3*Math.PI/2,!1),t.closePath(),t.fillStrokeShape(this)}getSelfRect(){let t=0,e=0,i=this.pointerWidth(),n=this.pointerHeight(),s=this.pointerDirection(),r=this.width(),a=this.height();return s===He?(e-=n,a+=n):s===Ye?a+=n:s===Xe?(t-=i,r+=i):s===ze&&(r+=i),{x:t,y:e,width:r,height:a}}}Ue.prototype.className="Tag",n(Ue),J.addGetterSetter(Ue,"pointerDirection","none"),J.addGetterSetter(Ue,"pointerWidth",0,X()),J.addGetterSetter(Ue,"pointerHeight",0,X()),J.addGetterSetter(Ue,"cornerRadius",0,j(4));class Ve extends ee{_sceneFunc(t){const e=this.cornerRadius(),i=this.width(),n=this.height();t.beginPath(),e?C.drawRoundedRectPath(t,i,n,e):t.rect(0,0,i,n),t.closePath(),t.fillStrokeShape(this)}}Ve.prototype.className="Rect",n(Ve),J.addGetterSetter(Ve,"cornerRadius",0,j(4));class Ke extends ee{_sceneFunc(t){const e=this._getPoints(),i=this.radius(),n=this.sides(),s=this.cornerRadius();if(e.length){if(t.beginPath(),s)C.drawRoundedPolygonPath(t,e,n,i,s);else{t.moveTo(e[0].x,e[0].y);for(let i=1;i<e.length;i++)t.lineTo(e[i].x,e[i].y)}t.closePath(),t.fillStrokeShape(this)}}_getPoints(){const t=this.attrs.sides,e=this.attrs.radius||0,i=[];for(let n=0;n<t;n++)i.push({x:e*Math.sin(2*n*Math.PI/t),y:-1*e*Math.cos(2*n*Math.PI/t)});return i}getSelfRect(){const t=this._getPoints();if(!t.length)return{x:0,y:0,width:0,height:0};let e=t[0].x,i=t[0].x,n=t[0].y,s=t[0].y;return t.forEach(t=>{e=Math.min(e,t.x),i=Math.max(i,t.x),n=Math.min(n,t.y),s=Math.max(s,t.y)}),{x:e,y:n,width:i-e,height:s-n}}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}}Ke.prototype.className="RegularPolygon",Ke.prototype._centroid=!0,Ke.prototype._attrsAffectingSize=["radius"],n(Ke),J.addGetterSetter(Ke,"radius",0,X()),J.addGetterSetter(Ke,"sides",0,X()),J.addGetterSetter(Ke,"cornerRadius",0,j(4));const $e=2*Math.PI;class Qe extends ee{_sceneFunc(t){const e=Math.abs(this.innerRadius()),i=Math.abs(this.outerRadius());t.beginPath(),t.arc(0,0,e,0,$e,!1),t.moveTo(i,0),t.arc(0,0,i,$e,0,!0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*Math.abs(this.outerRadius())}getHeight(){return 2*Math.abs(this.outerRadius())}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}}Qe.prototype.className="Ring",Qe.prototype._centroid=!0,Qe.prototype._attrsAffectingSize=["innerRadius","outerRadius"],n(Qe),J.addGetterSetter(Qe,"innerRadius",0,X()),J.addGetterSetter(Qe,"outerRadius",0,X());class Je extends ee{constructor(t){super(t),this._updated=!0,this.anim=new he(()=>{const t=this._updated;return this._updated=!1,t}),this.on("animationChange.konva",function(){this.frameIndex(0)}),this.on("frameIndexChange.konva",function(){this._updated=!0}),this.on("frameRateChange.konva",function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})}_getFrame(){var t,e;const i=this.animation(),n=null===(t=this.animations())||void 0===t?void 0:t[i],s=this.frameIndex(),r=4*s;if(!n||!Number.isInteger(s)||r<0||r+4>n.length)return;const a=(null===(e=this.frameOffsets())||void 0===e?void 0:e[i])||[];return{x:n[r],y:n[r+1],width:n[r+2],height:n[r+3],offsetX:a[2*s]||0,offsetY:a[2*s+1]||0}}_sceneFunc(t){const e=this._getFrame();if(!e)return;const{x:i,y:n,width:s,height:r,offsetX:a,offsetY:o}=e,h=this.image();(this.hasFill()||this.hasStroke())&&(t.beginPath(),t.rect(a,o,s,r),t.closePath(),t.fillStrokeShape(this)),h&&t.drawImage(h,i,n,s,r,a,o,s,r)}_hitFunc(t){const{x:e,y:i,width:n,height:s}=this.getSelfRect();t.beginPath(),t.rect(e,i,n,s),t.closePath(),t.fillShape(this)}getSelfRect(){const t=this._getFrame();return t?{x:t.offsetX,y:t.offsetY,width:t.width,height:t.height}:{x:0,y:0,width:0,height:0}}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){const t=this;this.interval=setInterval(function(){t._updateIndex()},1e3/this.frameRate())}start(){if(this.isRunning())return;const t=this.getLayer();this.anim.setLayers(t),this._setInterval(),this.anim.start()}stop(){this.anim.stop(),clearInterval(this.interval)}destroy(){return this.stop(),super.destroy()}isRunning(){return this.anim.isRunning()}_updateIndex(){var t;const e=this.frameIndex(),i=null===(t=this.animations())||void 0===t?void 0:t[this.animation()],n=i?i.length/4:0;this.frameIndex(e<n-1?e+1:0)}}Je.prototype.className="Sprite",n(Je),J.addGetterSetter(Je,"animation"),J.addGetterSetter(Je,"animations"),J.addGetterSetter(Je,"frameOffsets"),J.addGetterSetter(Je,"image"),J.addGetterSetter(Je,"frameIndex",0,X()),J.addGetterSetter(Je,"frameRate",17,X()),J.backCompat(Je,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});class Ze extends ee{_sceneFunc(t){const e=this.innerRadius(),i=this.outerRadius(),n=this.numPoints();t.beginPath(),t.moveTo(0,0-i);for(let s=1;s<2*n;s++){const r=s%2==0?i:e,a=r*Math.sin(s*Math.PI/n),o=-1*r*Math.cos(s*Math.PI/n);t.lineTo(a,o)}t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}}Ze.prototype.className="Star",Ze.prototype._centroid=!0,Ze.prototype._attrsAffectingSize=["innerRadius","outerRadius"],n(Ze),J.addGetterSetter(Ze,"numPoints",5,X()),J.addGetterSetter(Ze,"innerRadius",0,X()),J.addGetterSetter(Ze,"outerRadius",0,X());const ti="undefined"!=typeof Intl&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"grapheme"}):null;function ei(t){return t/15}function ii(t){return ti?Array.from(ti.segment(t),t=>t.segment):t.match(/\p{RI}\p{RI}|\P{M}(?:\p{M}|\p{Emoji_Modifier}|\uFE0F|\u200D\P{M})*|\p{M}+/gu)||[]}const ni="auto",si="inherit",ri="justify",ai="left",oi="middle",hi="normal",li="none";let ci,di=null;function gi(){return ci||(ci=C.createCanvasElement().getContext("2d"),ci)}class ui extends ee{constructor(t){super(function(t){return(t=t||{}).fillLinearGradientColorStops||t.fillRadialGradientColorStops||t.fillPatternImage||(t.fill=t.fill||"black"),t}(t)),this._partialTextX=0,this._partialTextY=0,this._setTextData()}_sceneFunc(t){var e,n;const s=this.textArr,r=s.length;if(!this.text())return;let a,o=this.padding(),h=this.fontSize(),l=this.lineHeight()*h,c=this.verticalAlign(),d=this.direction(),g=0,u=this.align(),f=this.getWidth(),p=this.letterSpacing(),m=this.charRenderFunc(),_=this.fill(),v=this.textDecoration(),y=this.underlineOffset(),x=-1!==v.indexOf("underline"),b=-1!==v.indexOf("line-through");d=d===si?t.direction:d;let S=l/2,w=oi;if(!i.legacyTextRendering){const t=this.measureSize("M");w="alphabetic";S=((null!==(e=t.fontBoundingBoxAscent)&&void 0!==e?e:t.actualBoundingBoxAscent)-(null!==(n=t.fontBoundingBoxDescent)&&void 0!==n?n:t.actualBoundingBoxDescent))/2+l/2}"rtl"===d&&t.setAttr("direction",d),t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",w),t.setAttr("textAlign",ai),c===oi?g=(this.getHeight()-r*l-2*o)/2:"bottom"===c&&(g=this.getHeight()-r*l-2*o),t.translate(o,g+o);const C=m?t.fillStyle:void 0,k=m?t.strokeStyle:void 0;let P=0;for(a=0;a<r;a++){let e=0,n=0;const c=s[a],g=c.text,v=c.width,w=c.lastInParagraph;if(t.save(),"right"===u?e+=f-v-2*o:"center"===u&&(e+=(f-v-2*o)/2),x){t.save(),t.beginPath();const s=e,r=S+n+(null!=y?y:i.legacyTextRendering?Math.round(h/2):Math.round(h/4));t.moveTo(s,r);const a=u!==ri||w?v:f-2*o;t.lineTo(s+Math.round(a),r),t.lineWidth=ei(h);const l=this._getLinearGradient();t.strokeStyle=l||_,t.stroke(),t.restore()}const A=e;if("rtl"===d||0===p&&u!==ri&&!m)0!==p&&t.setAttr("letterSpacing",`${p}px`),this._partialTextX=e,this._partialTextY=S+n,this._partialText=g,t.fillStrokeShape(this);else{const i=g.split(" ").length-1,s=ii(g);for(let r=0;r<s.length;r++){const h=s[r];" "!==h||w||u!==ri||(e+=(f-2*o-v)/i),this._partialTextX=e,this._partialTextY=S+n,this._partialText=h;const l=t.measureText(h).width;if(m){t.save(),m({char:h,index:P,x:e,y:S+n,lineIndex:a,column:r,isLastInLine:r===s.length-1,width:l,context:t});const i=t.fillStyle;i!==C&&(this._partialFillStyle=i);const o=t.strokeStyle;o!==k&&(this._partialStrokeStyle=o)}t.fillStrokeShape(this),m&&(this._partialFillStyle=void 0,this._partialStrokeStyle=void 0,t.restore()),e+=l+p,P++}}if(b){t.save(),t.beginPath();const e=i.legacyTextRendering?0:-Math.round(h/4),s=A;t.moveTo(s,S+n+e);const r=u!==ri||w?v:f-2*o;t.lineTo(s+Math.round(r),S+n+e),t.lineWidth=ei(h);const a=this._getLinearGradient();t.strokeStyle=a||_,t.stroke(),t.restore()}t.restore(),r>1&&(S+=l)}}_hitFunc(t){const e=this.getWidth(),i=this.getHeight();t.beginPath(),t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}setText(t){const e=C._isString(t)?t:null==t?"":t+"";return this._setAttr("text",e),this}getWidth(){return this.attrs.width===ni||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}getHeight(){return this.attrs.height===ni||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return C.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(t){var e,i,n,s,r,a,o,h,l,c,d;let g,u=gi(),f=this.fontSize();u.save(),u.font=this._getContextFont(),g=u.measureText(t),u.restore();const p=f/100;return{actualBoundingBoxAscent:null!==(e=g.actualBoundingBoxAscent)&&void 0!==e?e:71.58203125*p,actualBoundingBoxDescent:null!==(i=g.actualBoundingBoxDescent)&&void 0!==i?i:0,actualBoundingBoxLeft:null!==(n=g.actualBoundingBoxLeft)&&void 0!==n?n:-7.421875*p,actualBoundingBoxRight:null!==(s=g.actualBoundingBoxRight)&&void 0!==s?s:75.732421875*p,alphabeticBaseline:null!==(r=g.alphabeticBaseline)&&void 0!==r?r:0,emHeightAscent:null!==(a=g.emHeightAscent)&&void 0!==a?a:100*p,emHeightDescent:null!==(o=g.emHeightDescent)&&void 0!==o?o:-20*p,fontBoundingBoxAscent:null!==(h=g.fontBoundingBoxAscent)&&void 0!==h?h:91*p,fontBoundingBoxDescent:null!==(l=g.fontBoundingBoxDescent)&&void 0!==l?l:21*p,hangingBaseline:null!==(c=g.hangingBaseline)&&void 0!==c?c:72.80000305175781*p,ideographicBaseline:null!==(d=g.ideographicBaseline)&&void 0!==d?d:-21*p,width:g.width,height:f}}_getContextFont(){return this.fontStyle()+" "+this.fontVariant()+" "+this.fontSize()+"px "+this.fontFamily().split(",").map(t=>{const e=(t=t.trim()).indexOf(" ")>=0,i=t.indexOf('"')>=0||t.indexOf("'")>=0;return e&&!i&&(t=`"${t}"`),t}).join(", ")}_addTextLine(t){this.align()===ri&&(t=t.trim());const e=this._getTextWidth(t);return this.textArr.push({text:t,width:e,lastInParagraph:!1})}_getTextWidth(t,e){const i=this.letterSpacing(),n=i?i*(null!=e?e:ii(t).length):0;return gi().measureText(t).width+n}_setTextData(){let t=this.text().split("\n"),e=+this.fontSize(),i=0,n=this.lineHeight()*e,s=this.attrs.width,r=this.attrs.height,a=s!==ni&&void 0!==s,o=r!==ni&&void 0!==r,h=this.padding(),l=s-2*h,c=r-2*h,d=0,g=this.wrap(),u="char"!==g&&g!==li,f=this.ellipsis();this.textArr=[],gi().font=this._getContextFont();const p=f?this._getTextWidth("…"):0;for(let e=0,s=t.length;e<s;++e){let r=t[e],h=this._getTextWidth(r);if(a&&h>l){const t=ii(r),e=t.length;let s=0;const a=e=>t.slice(s,e).join(""),g=t=>" "===t||"-"===t,m=Math.max(1,Math.ceil(e*l/h));for(;s<e;){const r=f&&o&&d+n>c?p:0;let h=0;const _=t=>{const e=this._getTextWidth(a(t),t-s);return!(e+r>l)&&(h=e,!0)};let v=s,y=Math.min(e,s+m);for(;_(y)&&(v=y,y!==e);)y=Math.min(e,y+(y-s));for(;y-v>1;){const t=v+y>>>1;_(t)?v=t:y=t}if(v===s)break;if(v===e){this._addTextLine(a(e)),d+=n,i=Math.max(i,h);break}if(u&&!g(t[v])){let e=v-1;for(;e>=s&&!g(t[e]);)e--;e>=s&&(v=e+1,h=this._getTextWidth(a(v),v-s))}if(this._addTextLine(a(v).trimRight()),i=Math.max(i,h),d+=n,this._shouldHandleEllipsis(d)){this._tryToAddEllipsisToLastLine();break}for(s=v;s<e&&!t[s].trim();)s++}}else this._addTextLine(r),d+=n,i=Math.max(i,h),this._shouldHandleEllipsis(d)&&e<s-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),o&&d+n>c)break}this.textHeight=e,this.textWidth=i}_shouldHandleEllipsis(t){const e=+this.fontSize(),i=this.lineHeight()*e,n=this.attrs.height,s=n!==ni&&void 0!==n,r=n-2*this.padding();return!(this.wrap()!==li)||s&&t+i>r}_tryToAddEllipsisToLastLine(){const t=this.attrs.width,e=t!==ni&&void 0!==t,i=t-2*this.padding(),n=this.ellipsis(),s=this.textArr[this.textArr.length-1];if(s&&n){if(e){this._getTextWidth(s.text+"…")<i||(s.text=s.text.slice(0,s.text.length-3))}this.textArr.splice(this.textArr.length-1,1),this._addTextLine(s.text+"…")}}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){const t=-1!==this.textDecoration().indexOf("underline")||-1!==this.textDecoration().indexOf("line-through"),e=this.hasShadow();return!(!t||!e)||(!(!e||1===this.getAbsoluteOpacity()||!function(){if(null!==di)return di;let t;di=!1;try{t=C.createCanvasElement(),t.width=10,t.height=10;const e=t.getContext("2d");if(e){e.globalAlpha=0,e.shadowColor="black",e.shadowBlur=5,e.shadowOffsetX=5,e.shadowOffsetY=5,e.fillStyle="black",e.font="10px Arial",e.fillText("X",0,10);const t=e.getImageData(0,0,10,10).data;for(let e=3;e<t.length;e+=4)if(t[e]>0){di=!0;break}}}catch(t){}finally{t&&C.releaseCanvas(t)}return di}())||super._useBufferCanvas())}}ui.prototype._fillFunc=function(t){this._partialFillStyle&&t.setAttr("fillStyle",this._partialFillStyle),t.fillText(this._partialText,this._partialTextX,this._partialTextY)},ui.prototype._strokeFunc=function(t){t.setAttr("miterLimit",2),this._partialStrokeStyle&&t.setAttr("strokeStyle",this._partialStrokeStyle),t.strokeText(this._partialText,this._partialTextX,this._partialTextY)},ui.prototype.className="Text",ui.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],n(ui),ui.prototype.on(["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"].map(t=>t+"Change.konva").join(" "),function(){this._setTextData()}),J.overWriteSetter(ui,"width",q()),J.overWriteSetter(ui,"height",q()),J.addGetterSetter(ui,"direction",si),J.addGetterSetter(ui,"fontFamily","Arial"),J.addGetterSetter(ui,"fontSize",12,X()),J.addGetterSetter(ui,"fontStyle",hi),J.addGetterSetter(ui,"fontVariant",hi),J.addGetterSetter(ui,"padding",0,X()),J.addGetterSetter(ui,"align",ai),J.addGetterSetter(ui,"verticalAlign","top"),J.addGetterSetter(ui,"lineHeight",1,X()),J.addGetterSetter(ui,"wrap","word"),J.addGetterSetter(ui,"ellipsis",!1,K()),J.addGetterSetter(ui,"letterSpacing",0,X()),J.addGetterSetter(ui,"text","",U()),J.addGetterSetter(ui,"textDecoration",""),J.addGetterSetter(ui,"underlineOffset",void 0,X()),J.addGetterSetter(ui,"charRenderFunc",void 0);const fi="normal";function pi(t){t.fillText(this.partialText,0,0)}function mi(t){t.strokeText(this.partialText,0,0)}class _i extends ee{constructor(t){super(t),this.dataArray=[],this._readDataAttribute(),this._setTextData()}_getTextPathLength(){return Ie.getPathLength(this.dataArray)}_getPointAtLength(t){if(!this.attrs.data)return null;return t>this.pathLength?null:Ie.getPointAtLengthOfDataArray(t,this.dataArray)}_readDataAttribute(){this.dataArray=Ie.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(t){t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",this.textBaseline()),t.setAttr("textAlign","left"),t.save();const e=this.textDecoration(),i=this.fill(),n=this.fontSize(),s=this.glyphInfo,r=-1!==e.indexOf("underline"),a=-1!==e.indexOf("line-through");r&&t.beginPath();for(let e=0;e<s.length;e++){t.save();const i=s[e].p0;t.translate(i.x,i.y),t.rotate(s[e].rotation),this.partialText=s[e].text,t.fillStrokeShape(this),r&&(0===e&&t.moveTo(0,n/2+1),t.lineTo(s[e].width,n/2+1)),t.restore()}if(r&&(t.strokeStyle=i,t.lineWidth=ei(n),t.stroke()),a){t.beginPath();for(let e=0;e<s.length;e++){t.save();const i=s[e].p0;t.translate(i.x,i.y),t.rotate(s[e].rotation),0===e&&t.moveTo(0,0),t.lineTo(s[e].width,0),t.restore()}t.strokeStyle=i,t.lineWidth=ei(n),t.stroke()}t.restore()}_hitFunc(t){t.beginPath();const e=this.glyphInfo;if(e.length>=1){const i=e[0].p0;t.moveTo(i.x,i.y)}for(let i=0;i<e.length;i++){const n=e[i].p1;t.lineTo(n.x,n.y)}t.setAttr("lineWidth",this.fontSize()),t.setAttr("strokeStyle",this.colorKey),t.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return C.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(t){return ui.prototype.setText.call(this,t)}_getContextFont(){return ui.prototype._getContextFont.call(this)}_getTextSize(t){const e=gi();e.save(),e.font=this._getContextFont();const i=e.measureText(t);return e.restore(),{width:i.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const t=ii(this.text());"rtl"===this.direction()&&t.reverse();const e=[];let i=0;for(let n=0;n<t.length;n++)e.push({char:t[n],width:this._getTextSize(t[n]).width}),i+=e[n].width;const{width:n,height:s}=this._getTextSize(this.attrs.text);if(this.textWidth=i,this.textHeight=s,this.glyphInfo=[],!this.attrs.data)return null;const r=this.letterSpacing(),a=this.align(),o=this.kerningFunc(),h=Math.max(0,i-n),l=Math.max(this.textWidth+(t.length-1)*r,0);let c=0;"center"===a&&(c=Math.max(0,this.pathLength/2-l/2)),"right"===a&&(c=Math.max(0,this.pathLength-l));let d=c;for(let i=0;i<e.length;i++){const n=this._getPointAtLength(d);if(!n)return;const s=e[i].char;let c=e[i].width+r;if(" "===s&&"justify"===a){const t=this.text().split(" ").length-1;c+=(this.pathLength-l)/t}const g=d+c,u=this._getPointAtLength(g>this.pathLength&&g-this.pathLength<=h?this.pathLength:g);if(!u)return;const f=Ie.getLineLength(n.x,n.y,u.x,u.y);let p=0;if(o&&i>0)try{p=o(e[i-1].char,s)*this.fontSize()}catch(t){p=0}n.x+=p,u.x+=p,this.textWidth+=p;const m=Ie.getPointOnLine(p+f/2,n.x,n.y,u.x,u.y),_=Math.atan2(u.y-n.y,u.x-n.x);this.glyphInfo.push({transposeX:m.x,transposeY:m.y,text:t[i],rotation:_,p0:n,p1:u,width:f}),d+=c}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};const t=[];this.glyphInfo.forEach(function(e){t.push(e.p0.x),t.push(e.p0.y),t.push(e.p1.x),t.push(e.p1.y)});const e=C._getPointsRect(t),i=this.fontSize();return{x:e.x-i/2,y:e.y-i/2,width:e.width+i,height:e.height+i}}}_i.prototype._fillFunc=pi,_i.prototype._strokeFunc=mi,_i.prototype._fillFuncHit=pi,_i.prototype._strokeFuncHit=mi,_i.prototype.className="TextPath",_i.prototype._attrsAffectingSize=["text","fontSize","data"],n(_i),_i.prototype.on("dataChange.konva",function(){this._readDataAttribute(),this._setTextData()}),_i.prototype.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva fontStyleChange.konva fontVariantChange.konva directionChange.konva",function(){this._setTextData()}),J.addGetterSetter(_i,"data"),J.addGetterSetter(_i,"fontFamily","Arial"),J.addGetterSetter(_i,"fontSize",12,X()),J.addGetterSetter(_i,"fontStyle",fi),J.addGetterSetter(_i,"align","left"),J.addGetterSetter(_i,"letterSpacing",0,X()),J.addGetterSetter(_i,"textBaseline","middle"),J.addGetterSetter(_i,"fontVariant",fi),J.addGetterSetter(_i,"text",""),J.addGetterSetter(_i,"textDecoration",""),J.addGetterSetter(_i,"kerningFunc",void 0),J.addGetterSetter(_i,"direction","inherit");const vi="tr-konva",yi=["resizeEnabledChange","rotateAnchorOffsetChange","rotateAnchorAngleChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange","paddingChange"].map(t=>t+`.${vi}`).join(" "),xi="nodesRect",bi=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange","draggableChange"],Si={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},wi="ontouchstart"in i._global;const Ci=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function ki(t,e){const i=function(t){return{x:t.x+t.width/2*Math.cos(t.rotation)+t.height/2*Math.sin(-t.rotation),y:t.y+t.height/2*Math.cos(t.rotation)+t.width/2*Math.sin(t.rotation)}}(t);return function(t,e,i){const n=i.x+(t.x-i.x)*Math.cos(e)-(t.y-i.y)*Math.sin(e),s=i.y+(t.x-i.x)*Math.sin(e)+(t.y-i.y)*Math.cos(e);return{...t,rotation:t.rotation+e,x:n,y:s}}(t,e,i)}const Pi=new Set;class Ai extends re{static _isLayerTransforming(t){for(const e of Pi)if(e.getLayer()===t||e._nodes.some(e=>e.getLayer()===t))return!0;return!1}constructor(t){super(t),this._movingAnchorName=null,this._anchors={},this._transforming=!1,this._fitting=!1,this._transformWindow=null,this._elementsCreated=!1,this._updateScheduled=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(yi,this.update),this.getNode()&&this.update()}attachTo(t){return this.setNode(t),this}setNode(t){return C.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([t])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return vi+this._id}setNodes(t=[]){this._nodes&&this._nodes.length&&this.detach();const e=t.filter(t=>!t.isAncestorOf(this)||(C.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1));return this._nodes=t=e,1===t.length&&this.useSingleNodeRotation()?this.rotation(t[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(t=>{const e=()=>{var e;this._fitting?null===(e=this._nodeRectCache)||void 0===e||e.delete(t):(1===this.nodes().length&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(t),this.isDragging()||this._scheduleUpdate())};if(t._attrsAffectingSize.length){const i=t._attrsAffectingSize.map(t=>t+"Change."+this._getEventNamespace()).join(" ");t.on(i,e)}t.on(bi.map(t=>t+`.${this._getEventNamespace()}`).join(" "),e),t.on(`absoluteTransformChange.${this._getEventNamespace()}`,e),t.on(`destroy.${this._getEventNamespace()}`,()=>{this.setNodes(this._nodes.filter(e=>e!==t))}),this._proxyDrag(t)}),this._resetTransformCache(),this._elementsCreated&&this.update(),this}_proxyDrag(t){let e;t.on(`dragstart.${this._getEventNamespace()}`,i=>{e=t.getAbsolutePosition(),this.isDragging()||t===this._back||this.startDrag(i,!1)}),t.on(`dragmove.${this._getEventNamespace()}`,i=>{if(!e)return;const n=t.getAbsolutePosition(),s=n.x-e.x,r=n.y-e.y;this.nodes().forEach(e=>{if(e===t)return;if(e.isDragging())return;const n=e.getAbsolutePosition();e.setAbsolutePosition({x:n.x+s,y:n.y+r}),e.startDrag(i)}),e=null})}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach(t=>{t.off("."+this._getEventNamespace())}),this._nodes=[],this._resetTransformCache()}_resetTransformCache(t){var e,i;t?null===(e=this._nodeRectCache)||void 0===e||e.delete(t):null===(i=this._nodeRectCache)||void 0===i||i.clear(),this._clearCache(xi),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(xi,this.__getNodeRect)}__getNodeRect(){var t;if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};const e=i.getAngle(this.rotation()),n=this.ignoreStroke(),s=new r;s.rotate(-e);const a=this._nodeRectCache||(this._nodeRectCache=new Map);let o=1/0,h=1/0,l=-1/0,c=-1/0;for(const i of this.nodes()){const r=i instanceof ee&&i.getSelfRect===ee.prototype.getSelfRect&&!i._hasCachedAncestor(),d=r?i.width():0,g=r?i.height():0;r&&(null!==(t=i._attrsVersion)&&void 0!==t||(i._attrsVersion=0));let u=r?a.get(i):void 0;if(!u||u.rotation!==e||u.ignoreStroke!==n||u.version!==i._attrsVersion||u.width!==d||u.height!==g){const t=i.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:n}),o=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}],h=i.getAbsoluteTransform();u={rotation:e,ignoreStroke:n,width:d,height:g,version:i._attrsVersion||0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};for(const t of o){const e=s.point(h.point(t));u.minX=Math.min(u.minX,e.x),u.minY=Math.min(u.minY,e.y),u.maxX=Math.max(u.maxX,e.x),u.maxY=Math.max(u.maxY,e.y)}r&&a.set(i,u)}o=Math.min(o,u.minX),h=Math.min(h,u.minY),l=Math.max(l,u.maxX),c=Math.max(c,u.maxY)}s.invert();const d=s.point({x:o,y:h});return{x:d.x,y:d.y,width:l-o,height:c-h,rotation:i.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),Ci.forEach(t=>{this._createAnchor(t)}),this._createAnchor("rotater"),this._elementsCreated=!0}_createAnchor(t){const e=new Ve({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:t+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:wi?10:"auto"});this._anchors[t]=e;const n=this;e.on("mousedown touchstart",function(t){n._handleMouseDown(t)}),e.on("dragstart",t=>{e.stopDrag(),t.cancelBubble=!0}),e.on("dragend",t=>{t.cancelBubble=!0}),e.on("mouseenter",()=>{const n=i.getAngle(this.rotation()),s=this.rotateAnchorCursor(),r=function(t,e,i){if("rotater"===t)return i;e+=C.degToRad(Si[t]||0);const n=(C.radToDeg(e)%360+360)%360;return C._inRange(n,337.5,360)||C._inRange(n,0,22.5)?"ns-resize":C._inRange(n,22.5,67.5)?"nesw-resize":C._inRange(n,67.5,112.5)?"ew-resize":C._inRange(n,112.5,157.5)?"nwse-resize":C._inRange(n,157.5,202.5)?"ns-resize":C._inRange(n,202.5,247.5)?"nesw-resize":C._inRange(n,247.5,292.5)?"ew-resize":C._inRange(n,292.5,337.5)?"nwse-resize":(C.error("Transformer has unknown angle for cursor detection: "+n),"pointer")}(t,n,s);e.getStage().content&&(e.getStage().content.style.cursor=r),this._cursorChange=!0}),e.on("mouseout",()=>{e.getStage().content&&(e.getStage().content.style.cursor=""),this._cursorChange=!1}),this.add(e)}_createBack(){const t=new ee({name:"back",width:0,height:0,sceneFunc(t,e){const i=e.getParent(),n=i.padding(),s=e.width(),r=e.height();if(t.beginPath(),t.rect(-n,-n,s+2*n,r+2*n),i.rotateEnabled()&&i.rotateLineVisible()){const e=i.rotateAnchorAngle(),n=i.rotateAnchorOffset(),a=C.degToRad(e),o=Math.sin(a),h=-Math.cos(a),l=s/2,c=r/2;let d=1/0;h<0?d=Math.min(d,-c/h):h>0&&(d=Math.min(d,(r-c)/h)),o<0?d=Math.min(d,-l/o):o>0&&(d=Math.min(d,(s-l)/o));const g=l+o*d,u=c+h*d,f=C._sign(r),p=g+o*n*f,m=u+h*n*f;t.moveTo(g,u),t.lineTo(p,m)}t.fillStrokeShape(e)},hitFunc:(t,e)=>{if(!this.shouldOverdrawWholeArea())return;const i=this.padding();t.beginPath(),t.rect(-i,-i,e.width()+2*i,e.height()+2*i),t.fillStrokeShape(e)}});this._back=t,this.add(t),this._proxyDrag(t),t.on("dragstart",t=>{t.cancelBubble=!0}),t.on("dragmove",t=>{t.cancelBubble=!0}),t.on("dragend",t=>{t.cancelBubble=!0}),this.on("dragmove",t=>{this.update()})}_handleMouseDown(t){var e,i;if(this._transforming)return;this._movingAnchorName=t.target.name().split(" ")[0];const n=this._getNodeRect(),s=n.width,r=n.height,a=Math.sqrt(Math.pow(s,2)+Math.pow(r,2));this.sin=Math.abs(r/a),this.cos=Math.abs(s/a);const o=null===(e=this.getStage())||void 0===e?void 0:e._getOwnerWindow();this._transformWindow=o||null,o&&(o.addEventListener("mousemove",this._handleMouseMove),o.addEventListener("touchmove",this._handleMouseMove),o.addEventListener("mouseup",this._handleMouseUp,!0),o.addEventListener("touchend",this._handleMouseUp,!0),o.addEventListener("touchcancel",this._handleMouseUp,!0)),this._transforming=!0,this._pointerId=null!==(i=t.pointerId)&&void 0!==i?i:C._getFirstPointerId(t.evt);const h=t.target.getAbsolutePosition(),l=t.target.getStage()._getPointerById(this._pointerId);this._anchorDragOffset={x:l.x-h.x,y:l.y-h.y},Pi.add(this),this._fire("transformstart",{evt:t.evt,target:this.getNode()}),this._nodes.forEach(e=>{e._fire("transformstart",{evt:t.evt,target:e})})}_handleMouseMove(t){var e;null===(e=this.getStage())||void 0===e||e._batchEvents(()=>this._moveTransform(t))}_moveTransform(t){let e,n,s;const r=this._anchors[this._movingAnchorName],a=r.getStage();a.setPointersPositions(t);const o=a._getPointerById(this._pointerId);if(!o)return;let h={x:o.x-this._anchorDragOffset.x,y:o.y-this._anchorDragOffset.y};const l=r.getAbsolutePosition();this.anchorDragBoundFunc()&&(h=this.anchorDragBoundFunc()(l,h,t)),r.setAbsolutePosition(h);const c=r.getAbsolutePosition();if(l.x===c.x&&l.y===c.y)return;if("rotater"===this._movingAnchorName){const s=this._getNodeRect();e=r.x()-s.width/2,n=-r.y()+s.height/2;const a=i.getAngle(this.rotateAnchorAngle());let o=Math.atan2(-n,e)+Math.PI/2-a;s.height<0&&(o-=Math.PI);const h=i.getAngle(this.rotation())+o,l=i.getAngle(this.rotationSnapTolerance()),c=function(t,e,n){let s=e;for(let r=0;r<t.length;r++){const a=i.getAngle(t[r]),o=Math.abs(a-e)%(2*Math.PI);Math.min(o,2*Math.PI-o)<n&&(s=a)}return s}(this.rotationSnaps(),h,l),d=ki(s,c-s.rotation);return void this._fitNodesInto(d,t)}const d=this.shiftBehavior();let g;g="inverted"===d?this.keepRatio()&&!t.shiftKey:"none"===d?this.keepRatio():this.keepRatio()||t.shiftKey;let u=this.centeredScaling()||t.altKey,f=!1;if("top-left"===this._movingAnchorName){if(g){f=!0;const t=u?{x:this.width()/2,y:this.height()/2}:{x:this._anchors["bottom-right"].x(),y:this._anchors["bottom-right"].y()};s=Math.sqrt(Math.pow(t.x-r.x(),2)+Math.pow(t.y-r.y(),2));const i=this._anchors["top-left"].x()>t.x?-1:1,a=this._anchors["top-left"].y()>t.y?-1:1;e=s*this.cos*i,n=s*this.sin*a,this._anchors["top-left"].x(t.x-e),this._anchors["top-left"].y(t.y-n)}}else if("top-center"===this._movingAnchorName)this._anchors["top-left"].y(r.y());else if("top-right"===this._movingAnchorName){if(g){f=!0;const t=u?{x:this.width()/2,y:this.height()/2}:{x:this._anchors["bottom-left"].x(),y:this._anchors["bottom-left"].y()};s=Math.sqrt(Math.pow(r.x()-t.x,2)+Math.pow(t.y-r.y(),2));const i=this._anchors["top-right"].x()<t.x?-1:1,a=this._anchors["top-right"].y()>t.y?-1:1;e=s*this.cos*i,n=s*this.sin*a,this._anchors["top-right"].x(t.x+e),this._anchors["top-right"].y(t.y-n)}var p=r.position();this._anchors["top-left"].y(p.y),this._anchors["bottom-right"].x(p.x)}else if("middle-left"===this._movingAnchorName)this._anchors["top-left"].x(r.x());else if("middle-right"===this._movingAnchorName)this._anchors["bottom-right"].x(r.x());else if("bottom-left"===this._movingAnchorName){if(g){f=!0;const t=u?{x:this.width()/2,y:this.height()/2}:{x:this._anchors["top-right"].x(),y:this._anchors["top-right"].y()};s=Math.sqrt(Math.pow(t.x-r.x(),2)+Math.pow(r.y()-t.y,2));const i=t.x<r.x()?-1:1,a=r.y()<t.y?-1:1;e=s*this.cos*i,n=s*this.sin*a,r.x(t.x-e),r.y(t.y+n)}p=r.position(),this._anchors["top-left"].x(p.x),this._anchors["bottom-right"].y(p.y)}else if("bottom-center"===this._movingAnchorName)this._anchors["bottom-right"].y(r.y());else if("bottom-right"===this._movingAnchorName){if(g){f=!0;const t=u?{x:this.width()/2,y:this.height()/2}:{x:this._anchors["top-left"].x(),y:this._anchors["top-left"].y()};s=Math.sqrt(Math.pow(r.x()-t.x,2)+Math.pow(r.y()-t.y,2));const i=this._anchors["bottom-right"].x()<t.x?-1:1,a=this._anchors["bottom-right"].y()<t.y?-1:1;e=s*this.cos*i,n=s*this.sin*a,this._anchors["bottom-right"].x(t.x+e),this._anchors["bottom-right"].y(t.y+n)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(u=this.centeredScaling()||t.altKey,u){const t=this._anchors["top-left"],e=this._anchors["bottom-right"],i=t.x(),n=t.y(),s=this.getWidth()-e.x(),r=this.getHeight()-e.y();e.move({x:-i,y:-n}),t.move({x:s,y:r})}const m=this._anchors["top-left"].getAbsolutePosition();e=m.x,n=m.y;const _=this._anchors["bottom-right"].x()-this._anchors["top-left"].x(),v=this._anchors["bottom-right"].y()-this._anchors["top-left"].y();this._fitNodesInto({x:e,y:n,width:_,height:v,rotation:i.getAngle(this.rotation())},t,f)}_handleMouseUp(t){const e=this.getStage();e&&(e.setPointersPositions(t),!e._changedPointerPositions.some(t=>t.id===this._pointerId))||(e?e._batchEvents(()=>this._removeEvents(t)):this._removeEvents(t))}getAbsoluteTransform(t){const e=this.getTransform();return t?t.getAbsoluteTransform().copy().invert().multiply(e):e}_removeEvents(t){var e;if(this._transforming){this._transforming=!1;const i=this._transformWindow;this._transformWindow=null,i&&(i.removeEventListener("mousemove",this._handleMouseMove),i.removeEventListener("touchmove",this._handleMouseMove),i.removeEventListener("mouseup",this._handleMouseUp,!0),i.removeEventListener("touchend",this._handleMouseUp,!0),i.removeEventListener("touchcancel",this._handleMouseUp,!0));const n=this.getNode();Pi.delete(this),this._fire("transformend",{evt:t,target:n}),null===(e=this.getLayer())||void 0===e||e.batchDraw(),n&&this._nodes.forEach(e=>{var i;e._fire("transformend",{evt:t,target:e}),null===(i=e.getLayer())||void 0===i||i.batchDraw()}),this._movingAnchorName=null}}_fitNodesInto(t,e,n=!1){const s=i.autoDrawEnabled;i.autoDrawEnabled=!1,this._fitting=!0;try{return this._doFitNodesInto(t,e,n)}finally{i.autoDrawEnabled=s,this._fitting=!1}}_doFitNodesInto(t,e,n=!1){const s=this._getNodeRect();if(!s.width||!s.height||C._inRange(t.width,2*-this.padding()-1,1)||C._inRange(t.height,2*-this.padding()-1,1))return void this.update();const a=new r;a.rotate(i.getAngle(this.rotation()));const o=n?0:2*this.padding();let h=null,l=null;if(this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("left")>=0){const e=a.point({x:-o,y:0});t.x+=e.x,t.y+=e.y,t.width+=o,h={axis:"width",from:"left",to:"right",offset:e}}else if(this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("right")>=0){const e=a.point({x:o,y:0});t.width+=o,h={axis:"width",from:"right",to:"left",offset:e}}if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("top")>=0){const e=a.point({x:0,y:-o});t.x+=e.x,t.y+=e.y,t.height+=o,l={axis:"height",from:"top",to:"bottom",offset:e}}else if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const e=a.point({x:0,y:o});t.height+=o,l={axis:"height",from:"bottom",to:"top",offset:e}}if(this.boundBoxFunc()){const e=this.boundBoxFunc()(s,t);e?t=e:C.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}for(const e of[h,l])e&&t[e.axis]<0&&this._movingAnchorName&&(this._movingAnchorName=this._movingAnchorName.replace(e.from,e.to),this._anchorDragOffset.x-=e.offset.x,this._anchorDragOffset.y-=e.offset.y);const c=1e7,d=new r;d.translate(s.x,s.y),d.rotate(s.rotation),d.scale(s.width/c,s.height/c);const g=new r,u=t.width/c,f=t.height/c;!1===this.flipEnabled()?(g.translate(t.x,t.y),g.rotate(t.rotation),g.translate(t.width<0?t.width:0,t.height<0?t.height:0),g.scale(Math.abs(u),Math.abs(f))):(g.translate(t.x,t.y),g.rotate(t.rotation),g.scale(u,f));const p=g.multiply(d.invert()),m=new Set;this._nodes.forEach(t=>{if(!t.getStage())return;const e=t.getParent().getAbsoluteTransform(),i=t.getTransform().copy();i.translate(t.offsetX(),t.offsetY());const n=new r;n.multiply(e.copy().invert()).multiply(p).multiply(e).multiply(i);const s=n.decompose();t.setAttrs(s);const a=t.getLayer();a&&m.add(a)}),this.rotation(C._getRotation(t.rotation)),this._nodes.forEach(t=>{this._fire("transform",{evt:e,target:t}),t._fire("transform",{evt:e,target:t})}),this._resetTransformCache(),this.update(),m.add(this.getLayer()),m.forEach(t=>t&&t.batchDraw())}_scheduleUpdate(){this._updateScheduled||(this._updateScheduled=!0,dt._runAfterAbsTransformCascade(()=>{var t;this._updateScheduled=!1,!(null===(t=this._nodes)||void 0===t?void 0:t.length)||this._fitting||this.isDragging()||this._update()}))}forceUpdate(){this._resetTransformCache(),this.update()}update(){this._lastNodeRect=void 0,this._update()}_update(){var t;const e=this._getNodeRect();this._updateElements(e);const i=this.nodes().some(t=>t.draggable());this._back.draggable()!==i&&this._back.draggable(i);const n=this.anchorStyleFunc();n&&Object.values(this._anchors).forEach(t=>n(t)),null===(t=this.getLayer())||void 0===t||t.batchDraw()}_updateElements(t){const e=this._lastNodeRect;if(e&&!this.anchorStyleFunc()&&t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height&&t.rotation===e.rotation)return;this._lastNodeRect={...t},this.rotation(C._getRotation(t.rotation));const i=t.width,n=t.height,s=this.enabledAnchors(),r=this.resizeEnabled(),a=this.padding(),o=this.anchorSize();Object.values(this._anchors).forEach(t=>{t.setAttrs({width:o,height:o,offsetX:o/2,offsetY:o/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._anchors["top-left"].setAttrs({x:0,y:0,offsetX:o/2+a,offsetY:o/2+a,visible:r&&s.indexOf("top-left")>=0}),this._anchors["top-center"].setAttrs({x:i/2,y:0,offsetY:o/2+a,visible:r&&s.indexOf("top-center")>=0}),this._anchors["top-right"].setAttrs({x:i,y:0,offsetX:o/2-a,offsetY:o/2+a,visible:r&&s.indexOf("top-right")>=0}),this._anchors["middle-left"].setAttrs({x:0,y:n/2,offsetX:o/2+a,visible:r&&s.indexOf("middle-left")>=0}),this._anchors["middle-right"].setAttrs({x:i,y:n/2,offsetX:o/2-a,visible:r&&s.indexOf("middle-right")>=0}),this._anchors["bottom-left"].setAttrs({x:0,y:n,offsetX:o/2+a,offsetY:o/2-a,visible:r&&s.indexOf("bottom-left")>=0}),this._anchors["bottom-center"].setAttrs({x:i/2,y:n,offsetY:o/2-a,visible:r&&s.indexOf("bottom-center")>=0}),this._anchors["bottom-right"].setAttrs({x:i,y:n,offsetX:o/2-a,offsetY:o/2-a,visible:r&&s.indexOf("bottom-right")>=0});const h=this.rotateAnchorAngle(),l=this.rotateAnchorOffset(),c=C.degToRad(h),d=Math.sin(c),g=-Math.cos(c),u=i/2,f=n/2;let p=1/0;g<0?p=Math.min(p,-f/g):g>0&&(p=Math.min(p,(n-f)/g)),d<0?p=Math.min(p,-u/d):d>0&&(p=Math.min(p,(i-u)/d));const m=u+d*p,_=f+g*p,v=C._sign(n);this._anchors.rotater.setAttrs({x:m+d*l*v,y:_+g*l*v-a*g,visible:this.rotateEnabled()}),this._back.setAttrs({width:i,height:n,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0})}isTransforming(){return this._transforming}stopTransform(){this._transforming&&this._removeEvents()}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),re.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}add(...t){return this._elementsCreated?(C.error("You cannot add external nodes to the Transformer. Use tr.nodes([node]) instead."),this):super.add(...t)}toObject(){return dt.prototype.toObject.call(this)}clone(t){return dt.prototype.clone.call(this,t)}getClientRect(t){return this.nodes().length>0?super.getClientRect(t):{x:0,y:0,width:0,height:0}}}Ai.isTransforming=()=>Pi.size>0,Ai.prototype.className="Transformer",n(Ai),J.addGetterSetter(Ai,"enabledAnchors",Ci,function(t){return t instanceof Array||C.warn("enabledAnchors value should be an array"),t instanceof Array&&t.forEach(function(t){-1===Ci.indexOf(t)&&C.warn("Unknown anchor name: "+t+". Available names are: "+Ci.join(", "))}),t||[]}),J.addGetterSetter(Ai,"flipEnabled",!0,K()),J.addGetterSetter(Ai,"resizeEnabled",!0),J.addGetterSetter(Ai,"anchorSize",10,X()),J.addGetterSetter(Ai,"rotateEnabled",!0),J.addGetterSetter(Ai,"rotateLineVisible",!0),J.addGetterSetter(Ai,"rotationSnaps",[]),J.addGetterSetter(Ai,"rotateAnchorOffset",50,X()),J.addGetterSetter(Ai,"rotateAnchorAngle",0,X()),J.addGetterSetter(Ai,"rotateAnchorCursor","crosshair"),J.addGetterSetter(Ai,"rotationSnapTolerance",5,X()),J.addGetterSetter(Ai,"borderEnabled",!0),J.addGetterSetter(Ai,"anchorStroke","rgb(0, 161, 255)"),J.addGetterSetter(Ai,"anchorStrokeWidth",1,X()),J.addGetterSetter(Ai,"anchorFill","white"),J.addGetterSetter(Ai,"anchorCornerRadius",0,X()),J.addGetterSetter(Ai,"borderStroke","rgb(0, 161, 255)"),J.addGetterSetter(Ai,"borderStrokeWidth",1,X()),J.addGetterSetter(Ai,"borderDash"),J.addGetterSetter(Ai,"keepRatio",!0),J.addGetterSetter(Ai,"shiftBehavior","default"),J.addGetterSetter(Ai,"centeredScaling",!1),J.addGetterSetter(Ai,"ignoreStroke",!1),J.addGetterSetter(Ai,"padding",0,X()),J.addGetterSetter(Ai,"nodes"),J.addGetterSetter(Ai,"node"),J.addGetterSetter(Ai,"boundBoxFunc"),J.addGetterSetter(Ai,"anchorDragBoundFunc"),J.addGetterSetter(Ai,"anchorStyleFunc"),J.addGetterSetter(Ai,"shouldOverdrawWholeArea",!1),J.addGetterSetter(Ai,"useSingleNodeRotation",!0),J.backCompat(Ai,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});class Ti extends ee{_sceneFunc(t){t.beginPath(),t.arc(0,0,Math.abs(this.radius()),0,i.getAngle(this.angle()),this.clockwise()),t.lineTo(0,0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*Math.abs(this.radius())}getHeight(){return 2*Math.abs(this.radius())}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}}
|
|
13
13
|
/*
|
|
14
14
|
|
|
15
15
|
StackBlur - a fast almost Gaussian Blur For Canvas
|
|
@@ -51,4 +51,4 @@
|
|
|
51
51
|
OTHER DEALINGS IN THE SOFTWARE.
|
|
52
52
|
* @license MIT
|
|
53
53
|
*/
|
|
54
|
-
function Ti(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}Ai.prototype.className="Wedge",Ai.prototype._centroid=!0,Ai.prototype._attrsAffectingSize=["radius"],n(Ai),j.addGetterSetter(Ai,"radius",0,F()),j.addGetterSetter(Ai,"angle",0,F()),j.addGetterSetter(Ai,"clockwise",!1),j.backCompat(Ai,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});const Mi=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],Ri=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];j.addGetterSetter(at,"blurRadius",0,F(),j.afterSetFilter);j.addGetterSetter(at,"brightness",0,F(),j.afterSetFilter);j.addGetterSetter(at,"contrast",0,F(),j.afterSetFilter);function Gi(t,e,i,n,s){const r=i-e,a=s-n;if(0===r)return n+a/2;if(0===a)return n;let o=(t-e)/r;return o=a*o+n,o}j.addGetterSetter(at,"embossStrength",.5,F(),j.afterSetFilter),j.addGetterSetter(at,"embossWhiteLevel",.5,F(),j.afterSetFilter),j.addGetterSetter(at,"embossDirection","top-left",void 0,j.afterSetFilter),j.addGetterSetter(at,"embossBlend",!1,void 0,j.afterSetFilter);j.addGetterSetter(at,"enhance",0,F(),j.afterSetFilter);j.addGetterSetter(at,"hue",0,F(),j.afterSetFilter),j.addGetterSetter(at,"saturation",0,F(),j.afterSetFilter),j.addGetterSetter(at,"luminance",0,F(),j.afterSetFilter);j.addGetterSetter(at,"hue",0,F(),j.afterSetFilter),j.addGetterSetter(at,"saturation",0,F(),j.afterSetFilter),j.addGetterSetter(at,"value",0,F(),j.afterSetFilter);function Ei(t,e,i){let n=4*(i*t.width+e);const s=[];return s.push(t.data[n++],t.data[n++],t.data[n++],t.data[n++]),s}function Li(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2))}j.addGetterSetter(at,"kaleidoscopePower",2,F(),j.afterSetFilter),j.addGetterSetter(at,"kaleidoscopeAngle",0,F(),j.afterSetFilter);j.addGetterSetter(at,"threshold",0,F(),j.afterSetFilter);j.addGetterSetter(at,"noise",.2,F(),j.afterSetFilter);j.addGetterSetter(at,"pixelSize",8,F(),j.afterSetFilter);j.addGetterSetter(at,"levels",.5,F(),j.afterSetFilter);j.addGetterSetter(at,"red",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),j.addGetterSetter(at,"green",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),j.addGetterSetter(at,"blue",0,O,j.afterSetFilter);j.addGetterSetter(at,"red",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),j.addGetterSetter(at,"green",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),j.addGetterSetter(at,"blue",0,O,j.afterSetFilter),j.addGetterSetter(at,"alpha",1,function(t){return this._filterUpToDate=!1,t>1?1:t<0?0:t});j.addGetterSetter(at,"threshold",.5,F(),j.afterSetFilter);return fe.Util._assign(fe,{Arc:pe,Arrow:Le,Circle:De,Ellipse:Ie,Image:Oe,Label:Ye,Tag:Xe,Line:Ge,Path:Ee,Rect:je,RegularPolygon:qe,Ring:Ke,Sprite:Ve,Star:$e,Text:ci,TextPath:pi,Transformer:Pi,Wedge:Ai,Filters:{Blur:function(t){const e=Math.round(this.blurRadius());e>0&&function(t,e){const i=t.data,n=t.width,s=t.height;let r,a,o,h,l,d,c,g,u,f,p,m,_,y,v,x,b,S,w,C;const k=e+e+1,P=n-1,A=s-1,T=e+1,M=T*(T+1)/2,R=new Ti,G=Mi[e],E=Ri[e];let L=null,D=R,I=null,O=null;for(let t=1;t<k;t++)D=D.next=new Ti,t===T&&(L=D);D.next=R,o=a=0;for(let t=0;t<s;t++){m=_=y=v=h=l=d=c=0,g=T*(x=i[a]),u=T*(b=i[a+1]),f=T*(S=i[a+2]),p=T*(w=i[a+3]),h+=M*x,l+=M*b,d+=M*S,c+=M*w,D=R;for(let t=0;t<T;t++)D.r=x,D.g=b,D.b=S,D.a=w,D=D.next;for(let t=1;t<T;t++)r=a+((P<t?P:t)<<2),h+=(D.r=x=i[r])*(C=T-t),l+=(D.g=b=i[r+1])*C,d+=(D.b=S=i[r+2])*C,c+=(D.a=w=i[r+3])*C,m+=x,_+=b,y+=S,v+=w,D=D.next;I=R,O=L;for(let t=0;t<n;t++)i[a+3]=w=c*G>>E,0!==w?(w=255/w,i[a]=(h*G>>E)*w,i[a+1]=(l*G>>E)*w,i[a+2]=(d*G>>E)*w):i[a]=i[a+1]=i[a+2]=0,h-=g,l-=u,d-=f,c-=p,g-=I.r,u-=I.g,f-=I.b,p-=I.a,r=o+((r=t+e+1)<P?r:P)<<2,m+=I.r=i[r],_+=I.g=i[r+1],y+=I.b=i[r+2],v+=I.a=i[r+3],h+=m,l+=_,d+=y,c+=v,I=I.next,g+=x=O.r,u+=b=O.g,f+=S=O.b,p+=w=O.a,m-=x,_-=b,y-=S,v-=w,O=O.next,a+=4;o+=n}for(let t=0;t<n;t++){_=y=v=m=l=d=c=h=0,a=t<<2,g=T*(x=i[a]),u=T*(b=i[a+1]),f=T*(S=i[a+2]),p=T*(w=i[a+3]),h+=M*x,l+=M*b,d+=M*S,c+=M*w,D=R;for(let t=0;t<T;t++)D.r=x,D.g=b,D.b=S,D.a=w,D=D.next;let o=n;for(let s=1;s<=e;s++)a=o+t<<2,h+=(D.r=x=i[a])*(C=T-s),l+=(D.g=b=i[a+1])*C,d+=(D.b=S=i[a+2])*C,c+=(D.a=w=i[a+3])*C,m+=x,_+=b,y+=S,v+=w,D=D.next,s<A&&(o+=n);a=t,I=R,O=L;for(let e=0;e<s;e++)r=a<<2,i[r+3]=w=c*G>>E,w>0?(w=255/w,i[r]=(h*G>>E)*w,i[r+1]=(l*G>>E)*w,i[r+2]=(d*G>>E)*w):i[r]=i[r+1]=i[r+2]=0,h-=g,l-=u,d-=f,c-=p,g-=I.r,u-=I.g,f-=I.b,p-=I.a,r=t+((r=e+T)<A?r:A)*n<<2,h+=m+=I.r=i[r],l+=_+=I.g=i[r+1],d+=y+=I.b=i[r+2],c+=v+=I.a=i[r+3],I=I.next,g+=x=O.r,u+=b=O.g,f+=S=O.b,p+=w=O.a,m-=x,_-=b,y-=S,v-=w,O=O.next,a+=n}}(t,e)},Brightness:function(t){const e=this.brightness(),i=t.data,n=i.length;for(let t=0;t<n;t+=4)i[t]=Math.min(255,i[t]*e),i[t+1]=Math.min(255,i[t+1]*e),i[t+2]=Math.min(255,i[t+2]*e)},Brighten:function(t){const e=255*this.brightness(),i=t.data,n=i.length;for(let t=0;t<n;t+=4)i[t]+=e,i[t+1]+=e,i[t+2]+=e},Contrast:function(t){const e=Math.pow((this.contrast()+100)/100,2),i=t.data,n=i.length;let s=150,r=150,a=150;for(let t=0;t<n;t+=4)s=i[t],r=i[t+1],a=i[t+2],s/=255,s-=.5,s*=e,s+=.5,s*=255,r/=255,r-=.5,r*=e,r+=.5,r*=255,a/=255,a-=.5,a*=e,a+=.5,a*=255,s=s<0?0:s>255?255:s,r=r<0?0:r>255?255:r,a=a<0?0:a>255?255:a,i[t]=s,i[t+1]=r,i[t+2]=a},Emboss:function(t){var e,i,n,s,r,a,o,h,l;const d=t.data,c=t.width,g=t.height,u=Math.min(1,Math.max(0,null!==(i=null===(e=this.embossStrength)||void 0===e?void 0:e.call(this))&&void 0!==i?i:.5)),f=Math.min(1,Math.max(0,null!==(s=null===(n=this.embossWhiteLevel)||void 0===n?void 0:n.call(this))&&void 0!==s?s:.5)),p=null!==(o={"top-left":315,top:270,"top-right":225,right:180,"bottom-right":135,bottom:90,"bottom-left":45,left:0}[null!==(a=null===(r=this.embossDirection)||void 0===r?void 0:r.call(this))&&void 0!==a?a:"top-left"])&&void 0!==o?o:315,m=!(null===(l=null===(h=this.embossBlend)||void 0===h?void 0:h.call(this))||void 0===l||!l),_=10*u,y=255*f,v=p*Math.PI/180,x=Math.cos(v),b=Math.sin(v),S=128/1020*_,w=new Uint8ClampedArray(d),C=new Float32Array(c*g);for(let t=0,e=0;e<d.length;e+=4,t++)C[t]=.2126*w[e]+.7152*w[e+1]+.0722*w[e+2];const k=[-1,0,1,-2,0,2,-1,0,1],P=[-1,-2,-1,0,0,0,1,2,1],A=[-c-1,-c,1-c,-1,0,1,c-1,c,c+1],T=t=>t<0?0:t>255?255:t;for(let t=1;t<g-1;t++)for(let e=1;e<c-1;e++){const i=t*c+e;let n=0,s=0;n+=C[i+A[0]]*k[0],s+=C[i+A[0]]*P[0],n+=C[i+A[1]]*k[1],s+=C[i+A[1]]*P[1],n+=C[i+A[2]]*k[2],s+=C[i+A[2]]*P[2],n+=C[i+A[3]]*k[3],s+=C[i+A[3]]*P[3],n+=C[i+A[5]]*k[5],s+=C[i+A[5]]*P[5],n+=C[i+A[6]]*k[6],s+=C[i+A[6]]*P[6],n+=C[i+A[7]]*k[7],s+=C[i+A[7]]*P[7],n+=C[i+A[8]]*k[8],s+=C[i+A[8]]*P[8];const r=T(y+(x*n+b*s)*S),a=4*i;if(m){const t=r-y;d[a]=T(w[a]+t),d[a+1]=T(w[a+1]+t),d[a+2]=T(w[a+2]+t),d[a+3]=w[a+3]}else d[a]=d[a+1]=d[a+2]=r,d[a+3]=w[a+3]}for(let t=0;t<c;t++){let e=4*t,i=4*((g-1)*c+t);d[e]=w[e],d[e+1]=w[e+1],d[e+2]=w[e+2],d[e+3]=w[e+3],d[i]=w[i],d[i+1]=w[i+1],d[i+2]=w[i+2],d[i+3]=w[i+3]}for(let t=1;t<g-1;t++){let e=t*c*4,i=4*(t*c+(c-1));d[e]=w[e],d[e+1]=w[e+1],d[e+2]=w[e+2],d[e+3]=w[e+3],d[i]=w[i],d[i+1]=w[i+1],d[i+2]=w[i+2],d[i+3]=w[i+3]}return t},Enhance:function(t){const e=t.data,i=e.length;let n,s,r,a=e[0],o=a,h=e[1],l=h,d=e[2],c=d;const g=this.enhance();if(0===g)return;for(let t=0;t<i;t+=4)n=e[t+0],n<a?a=n:n>o&&(o=n),s=e[t+1],s<h?h=s:s>l&&(l=s),r=e[t+2],r<d?d=r:r>c&&(c=r);let u,f,p,m,_,y;if(o===a&&(o=255,a=0),l===h&&(l=255,h=0),c===d&&(c=255,d=0),g>0)u=o+g*(255-o),f=a-g*(a-0),p=l+g*(255-l),m=h-g*(h-0),_=c+g*(255-c),y=d-g*(d-0);else{const t=.5*(o+a);u=o+g*(o-t),f=a+g*(a-t);const e=.5*(l+h);p=l+g*(l-e),m=h+g*(h-e);const i=.5*(c+d);_=c+g*(c-i),y=d+g*(d-i)}for(let t=0;t<i;t+=4)e[t+0]=Gi(e[t+0],a,o,f,u),e[t+1]=Gi(e[t+1],h,l,m,p),e[t+2]=Gi(e[t+2],d,c,y,_)},Grayscale:function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4){const i=.34*e[t]+.5*e[t+1]+.16*e[t+2];e[t]=i,e[t+1]=i,e[t+2]=i}},HSL:function(t){const e=t.data,i=e.length,n=Math.pow(2,this.saturation()),s=Math.abs(this.hue()+360)%360,r=127*this.luminance(),a=1*n*Math.cos(s*Math.PI/180),o=1*n*Math.sin(s*Math.PI/180),h=.299+.701*a+.167*o,l=.587-.587*a+.33*o,d=.114-.114*a-.497*o,c=.299-.299*a-.328*o,g=.587+.413*a+.035*o,u=.114-.114*a+.293*o,f=.299-.3*a+1.25*o,p=.587-.586*a-1.05*o,m=.114+.886*a-.2*o;let _,y,v,x;for(let t=0;t<i;t+=4)_=e[t+0],y=e[t+1],v=e[t+2],x=e[t+3],e[t+0]=h*_+l*y+d*v+r,e[t+1]=c*_+g*y+u*v+r,e[t+2]=f*_+p*y+m*v+r,e[t+3]=x},HSV:function(t){const e=t.data,i=e.length,n=Math.pow(2,this.value()),s=Math.pow(2,this.saturation()),r=Math.abs(this.hue()+360)%360,a=n*s*Math.cos(r*Math.PI/180),o=n*s*Math.sin(r*Math.PI/180),h=.299*n+.701*a+.167*o,l=.587*n-.587*a+.33*o,d=.114*n-.114*a-.497*o,c=.299*n-.299*a-.328*o,g=.587*n+.413*a+.035*o,u=.114*n-.114*a+.293*o,f=.299*n-.3*a+1.25*o,p=.587*n-.586*a-1.05*o,m=.114*n+.886*a-.2*o;for(let t=0;t<i;t+=4){const i=e[t+0],n=e[t+1],s=e[t+2],r=e[t+3];e[t+0]=h*i+l*n+d*s,e[t+1]=c*i+g*n+u*s,e[t+2]=f*i+p*n+m*s,e[t+3]=r}},Invert:function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4)e[t]=255-e[t],e[t+1]=255-e[t+1],e[t+2]=255-e[t+2]},Kaleidoscope:function(t){const e=t.width,i=t.height;let n,s,r,a,o,h,l,d,c,g,u=Math.round(this.kaleidoscopePower());const f=Math.round(this.kaleidoscopeAngle()),p=Math.floor(e*(f%360)/360);if(u<1)return;const m=w.createCanvasElement();m.width=e,m.height=i;const _=m.getContext("2d").getImageData(0,0,e,i);w.releaseCanvas(m),function(t,e,i){const n=t.data,s=e.data,r=t.width,a=t.height,o=i.polarCenterX||r/2,h=i.polarCenterY||a/2;let l=Math.sqrt(o*o+h*h),d=r-o,c=a-h;const g=Math.sqrt(d*d+c*c);l=g>l?g:l;const u=a,f=r,p=360/f*Math.PI/180;for(let t=0;t<f;t+=1){const e=Math.sin(t*p),i=Math.cos(t*p);for(let a=0;a<u;a+=1){d=Math.floor(o+l*a/u*i),c=Math.floor(h+l*a/u*e);let g=4*(c*r+d);const f=n[g+0],p=n[g+1],m=n[g+2],_=n[g+3];g=4*(t+a*r),s[g+0]=f,s[g+1]=p,s[g+2]=m,s[g+3]=_}}}(t,_,{polarCenterX:e/2,polarCenterY:i/2});let y=e/Math.pow(2,u);for(;y<=8;)y*=2,u-=1;y=Math.ceil(y);let v=y,x=0,b=v,S=1;for(p+y>e&&(x=v,b=0,S=-1),s=0;s<i;s+=1)for(n=x;n!==b;n+=S)r=Math.round(n+p)%e,c=4*(e*s+r),o=_.data[c+0],h=_.data[c+1],l=_.data[c+2],d=_.data[c+3],g=4*(e*s+n),_.data[g+0]=o,_.data[g+1]=h,_.data[g+2]=l,_.data[g+3]=d;for(s=0;s<i;s+=1)for(v=Math.floor(y),a=0;a<u;a+=1){for(n=0;n<v+1;n+=1)c=4*(e*s+n),o=_.data[c+0],h=_.data[c+1],l=_.data[c+2],d=_.data[c+3],g=4*(e*s+2*v-n-1),_.data[g+0]=o,_.data[g+1]=h,_.data[g+2]=l,_.data[g+3]=d;v*=2}!function(t,e,i){const n=t.data,s=e.data,r=t.width,a=t.height,o=i.polarCenterX||r/2,h=i.polarCenterY||a/2;let l=Math.sqrt(o*o+h*h),d=r-o,c=a-h;const g=Math.sqrt(d*d+c*c);l=g>l?g:l;const u=a,f=r;let p,m;for(d=0;d<r;d+=1)for(c=0;c<a;c+=1){const t=d-o,e=c-h,i=Math.sqrt(t*t+e*e)*u/l;let a=(180*Math.atan2(e,t)/Math.PI+360+0)%360;a=a*f/360,p=Math.floor(a),m=Math.floor(i);let g=4*(m*r+p);const _=n[g+0],y=n[g+1],v=n[g+2],x=n[g+3];g=4*(c*r+d),s[g+0]=_,s[g+1]=y,s[g+2]=v,s[g+3]=x}}(_,t,{})},Mask:function(t){let e=function(t,e){const i=Ei(t,0,0),n=Ei(t,t.width-1,0),s=Ei(t,0,t.height-1),r=Ei(t,t.width-1,t.height-1),a=e||10;if(Li(i,n)<a&&Li(n,r)<a&&Li(r,s)<a&&Li(s,i)<a){const e=function(t){const e=[0,0,0];for(let i=0;i<t.length;i++)e[0]+=t[i][0],e[1]+=t[i][1],e[2]+=t[i][2];return e[0]/=t.length,e[1]/=t.length,e[2]/=t.length,e}([n,i,r,s]),o=[];for(let i=0;i<t.width*t.height;i++){const n=Li(e,[t.data[4*i],t.data[4*i+1],t.data[4*i+2]]);o[i]=n<a?0:255}return o}}(t,this.threshold());return e&&(e=function(t,e,i){const n=[1,1,1,1,0,1,1,1,1],s=Math.round(Math.sqrt(n.length)),r=Math.floor(s/2),a=[];for(let o=0;o<i;o++)for(let h=0;h<e;h++){const l=o*e+h;let d=0;for(let a=0;a<s;a++)for(let l=0;l<s;l++){const c=o+a-r,g=h+l-r;if(c>=0&&c<i&&g>=0&&g<e){const i=n[a*s+l];d+=t[c*e+g]*i}}a[l]=2040===d?255:0}return a}(e,t.width,t.height),e=function(t,e,i){const n=[1,1,1,1,1,1,1,1,1],s=Math.round(Math.sqrt(n.length)),r=Math.floor(s/2),a=[];for(let o=0;o<i;o++)for(let h=0;h<e;h++){const l=o*e+h;let d=0;for(let a=0;a<s;a++)for(let l=0;l<s;l++){const c=o+a-r,g=h+l-r;if(c>=0&&c<i&&g>=0&&g<e){const i=n[a*s+l];d+=t[c*e+g]*i}}a[l]=d>=1020?255:0}return a}(e,t.width,t.height),e=function(t,e,i){const n=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],s=Math.round(Math.sqrt(n.length)),r=Math.floor(s/2),a=[];for(let o=0;o<i;o++)for(let h=0;h<e;h++){const l=o*e+h;let d=0;for(let a=0;a<s;a++)for(let l=0;l<s;l++){const c=o+a-r,g=h+l-r;if(c>=0&&c<i&&g>=0&&g<e){const i=n[a*s+l];d+=t[c*e+g]*i}}a[l]=d}return a}(e,t.width,t.height),function(t,e){for(let i=0;i<t.width*t.height;i++)t.data[4*i+3]=e[i]}(t,e)),t},Noise:function(t){const e=255*this.noise(),i=t.data,n=i.length,s=e/2;for(let t=0;t<n;t+=4)i[t+0]+=s-2*s*Math.random(),i[t+1]+=s-2*s*Math.random(),i[t+2]+=s-2*s*Math.random()},Pixelate:function(t){let e=Math.ceil(this.pixelSize()),i=t.width,n=t.height,s=Math.ceil(i/e),r=Math.ceil(n/e),a=t.data;if(e<=0)w.error("pixelSize value can not be <= 0");else for(let t=0;t<s;t+=1)for(let s=0;s<r;s+=1){let r=0,o=0,h=0,l=0;const d=t*e,c=d+e,g=s*e,u=g+e;let f=0;for(let t=d;t<c;t+=1)if(!(t>=i))for(let e=g;e<u;e+=1){if(e>=n)continue;const s=4*(i*e+t);r+=a[s+0],o+=a[s+1],h+=a[s+2],l+=a[s+3],f+=1}r/=f,o/=f,h/=f,l/=f;for(let t=d;t<c;t+=1)if(!(t>=i))for(let e=g;e<u;e+=1){if(e>=n)continue;const s=4*(i*e+t);a[s+0]=r,a[s+1]=o,a[s+2]=h,a[s+3]=l}}},Posterize:function(t){const e=Math.round(254*this.levels())+1,i=t.data,n=i.length,s=255/e;for(let t=0;t<n;t+=1)i[t]=Math.floor(i[t]/s)*s},RGB:function(t){const e=t.data,i=e.length,n=this.red(),s=this.green(),r=this.blue();for(let t=0;t<i;t+=4){const i=(.34*e[t]+.5*e[t+1]+.16*e[t+2])/255;e[t]=i*n,e[t+1]=i*s,e[t+2]=i*r,e[t+3]=e[t+3]}},RGBA:function(t){const e=t.data,i=e.length,n=this.red(),s=this.green(),r=this.blue(),a=this.alpha();for(let t=0;t<i;t+=4){const i=1-a;e[t]=n*a+e[t]*i,e[t+1]=s*a+e[t+1]*i,e[t+2]=r*a+e[t+2]*i}},Sepia:function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4){const i=e[t+0],n=e[t+1],s=e[t+2];e[t+0]=Math.min(255,.393*i+.769*n+.189*s),e[t+1]=Math.min(255,.349*i+.686*n+.168*s),e[t+2]=Math.min(255,.272*i+.534*n+.131*s)}},Solarize:function(t){const e=t.data;for(let t=0;t<e.length;t+=4){const i=e[t],n=e[t+1],s=e[t+2];.2126*i+.7152*n+.0722*s>=128&&(e[t]=255-i,e[t+1]=255-n,e[t+2]=255-s)}return t},Threshold:function(t){const e=255*this.threshold(),i=t.data,n=i.length;for(let t=0;t<n;t+=1)i[t]=i[t]<e?0:255}}})});
|
|
54
|
+
function Mi(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}Ti.prototype.className="Wedge",Ti.prototype._centroid=!0,Ti.prototype._attrsAffectingSize=["radius"],n(Ti),J.addGetterSetter(Ti,"radius",0,X()),J.addGetterSetter(Ti,"angle",0,X()),J.addGetterSetter(Ti,"clockwise",!1),J.backCompat(Ti,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});const Ei=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],Ri=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function Gi(t,e){return 255===e?t:t*e/255}J.addGetterSetter(dt,"blurRadius",0,X(),J.afterSetFilter);J.addGetterSetter(dt,"brightness",0,X(),J.afterSetFilter);J.addGetterSetter(dt,"contrast",0,X(),J.afterSetFilter);function Li(t,e,i,n,s){const r=i-e,a=s-n;if(0===r)return n+a/2;if(0===a)return n;let o=(t-e)/r;return o=a*o+n,o}J.addGetterSetter(dt,"embossStrength",.5,X(),J.afterSetFilter),J.addGetterSetter(dt,"embossWhiteLevel",.5,X(),J.afterSetFilter),J.addGetterSetter(dt,"embossDirection","top-left",void 0,J.afterSetFilter),J.addGetterSetter(dt,"embossBlend",!1,void 0,J.afterSetFilter);J.addGetterSetter(dt,"enhance",0,X(),J.afterSetFilter);J.addGetterSetter(dt,"hue",0,X(),J.afterSetFilter),J.addGetterSetter(dt,"saturation",0,X(),J.afterSetFilter),J.addGetterSetter(dt,"luminance",0,X(),J.afterSetFilter);J.addGetterSetter(dt,"hue",0,X(),J.afterSetFilter),J.addGetterSetter(dt,"saturation",0,X(),J.afterSetFilter),J.addGetterSetter(dt,"value",0,X(),J.afterSetFilter);function Di(t,e,i){let n=4*(i*t.width+e);const s=[];return s.push(t.data[n++],t.data[n++],t.data[n++],t.data[n++]),s}function Ii(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2))}J.addGetterSetter(dt,"kaleidoscopePower",2,X(),J.afterSetFilter),J.addGetterSetter(dt,"kaleidoscopeAngle",0,X(),J.afterSetFilter);J.addGetterSetter(dt,"threshold",0,X(),J.afterSetFilter);J.addGetterSetter(dt,"noise",.2,X(),J.afterSetFilter);J.addGetterSetter(dt,"pixelSize",8,X(),J.afterSetFilter);J.addGetterSetter(dt,"levels",.5,X(),J.afterSetFilter);J.addGetterSetter(dt,"red",0,Y,J.afterSetFilter),J.addGetterSetter(dt,"green",0,Y,J.afterSetFilter),J.addGetterSetter(dt,"blue",0,Y,J.afterSetFilter);J.addGetterSetter(dt,"alpha",1,t=>Math.min(1,Math.max(0,t)),J.afterSetFilter);J.addGetterSetter(dt,"threshold",.5,X(),J.afterSetFilter);const Fi=me.Util._assign(me,{Arc:_e,Arrow:Fe,Circle:Oe,Ellipse:Be,Image:Ne,Label:qe,Tag:Ue,Line:Le,Path:Ie,Rect:Ve,RegularPolygon:Ke,Ring:Qe,Sprite:Je,Star:Ze,Text:ui,TextPath:_i,Transformer:Ai,Wedge:Ti,Filters:{Blur:function(t){const e=Math.min(Math.round(this.blurRadius()),180);e>0&&function(t,e){const i=t.data,n=t.width,s=t.height;let r,a,o,h,l,c,d,g,u,f,p,m,_,v,y,x,b,S,w,C;const k=e+e+1,P=n-1,A=s-1,T=e+1,M=T*(T+1)/2,E=new Mi,R=Ei[e],G=Ri[e];let L=null,D=E,I=null,F=null;for(let t=1;t<k;t++)D=D.next=new Mi,t===T&&(L=D);D.next=E,o=a=0;for(let t=0;t<s;t++){m=_=v=y=h=l=c=d=0,w=i[a+3],x=Gi(i[a],w),b=Gi(i[a+1],w),S=Gi(i[a+2],w),g=T*x,u=T*b,f=T*S,p=T*w,h+=M*x,l+=M*b,c+=M*S,d+=M*w,D=E;for(let t=0;t<T;t++)D.r=x,D.g=b,D.b=S,D.a=w,D=D.next;for(let t=1;t<T;t++)r=a+((P<t?P:t)<<2),w=i[r+3],h+=(D.r=x=Gi(i[r],w))*(C=T-t),l+=(D.g=b=Gi(i[r+1],w))*C,c+=(D.b=S=Gi(i[r+2],w))*C,d+=(D.a=w)*C,m+=x,_+=b,v+=S,y+=w,D=D.next;I=E,F=L;for(let t=0;t<n;t++)i[a]=h*R>>G,i[a+1]=l*R>>G,i[a+2]=c*R>>G,i[a+3]=d*R>>G,h-=g,l-=u,c-=f,d-=p,g-=I.r,u-=I.g,f-=I.b,p-=I.a,r=o+((r=t+e+1)<P?r:P)<<2,w=i[r+3],m+=I.r=Gi(i[r],w),_+=I.g=Gi(i[r+1],w),v+=I.b=Gi(i[r+2],w),y+=I.a=w,h+=m,l+=_,c+=v,d+=y,I=I.next,g+=x=F.r,u+=b=F.g,f+=S=F.b,p+=w=F.a,m-=x,_-=b,v-=S,y-=w,F=F.next,a+=4;o+=n}for(let t=0;t<n;t++){_=v=y=m=l=c=d=h=0,a=t<<2,g=T*(x=i[a]),u=T*(b=i[a+1]),f=T*(S=i[a+2]),p=T*(w=i[a+3]),h+=M*x,l+=M*b,c+=M*S,d+=M*w,D=E;for(let t=0;t<T;t++)D.r=x,D.g=b,D.b=S,D.a=w,D=D.next;let o=Math.min(1,A)*n;for(let s=1;s<=e;s++)a=o+t<<2,h+=(D.r=x=i[a])*(C=T-s),l+=(D.g=b=i[a+1])*C,c+=(D.b=S=i[a+2])*C,d+=(D.a=w=i[a+3])*C,m+=x,_+=b,v+=S,y+=w,D=D.next,s<A&&(o+=n);a=t,I=E,F=L;for(let e=0;e<s;e++)r=a<<2,i[r+3]=w=d*R>>G,w>0?(w=255/w,i[r]=(h*R>>G)*w,i[r+1]=(l*R>>G)*w,i[r+2]=(c*R>>G)*w):i[r]=i[r+1]=i[r+2]=0,h-=g,l-=u,c-=f,d-=p,g-=I.r,u-=I.g,f-=I.b,p-=I.a,r=t+((r=e+T)<A?r:A)*n<<2,h+=m+=I.r=i[r],l+=_+=I.g=i[r+1],c+=v+=I.b=i[r+2],d+=y+=I.a=i[r+3],I=I.next,g+=x=F.r,u+=b=F.g,f+=S=F.b,p+=w=F.a,m-=x,_-=b,v-=S,y-=w,F=F.next,a+=n}}(t,e)},Brightness:function(t){const e=this.brightness(),i=t.data,n=i.length;for(let t=0;t<n;t+=4)i[t]=Math.min(255,i[t]*e),i[t+1]=Math.min(255,i[t+1]*e),i[t+2]=Math.min(255,i[t+2]*e)},Brighten:function(t){const e=255*this.brightness(),i=t.data,n=i.length;for(let t=0;t<n;t+=4)i[t]+=e,i[t+1]+=e,i[t+2]+=e},Contrast:function(t){const e=Math.pow((this.contrast()+100)/100,2),i=t.data,n=i.length;let s=150,r=150,a=150;for(let t=0;t<n;t+=4)s=i[t],r=i[t+1],a=i[t+2],s/=255,s-=.5,s*=e,s+=.5,s*=255,r/=255,r-=.5,r*=e,r+=.5,r*=255,a/=255,a-=.5,a*=e,a+=.5,a*=255,s=s<0?0:s>255?255:s,r=r<0?0:r>255?255:r,a=a<0?0:a>255?255:a,i[t]=s,i[t+1]=r,i[t+2]=a},Emboss:function(t){var e,i,n,s,r,a,o,h,l;const c=t.data,d=t.width,g=t.height,u=Math.min(1,Math.max(0,null!==(i=null===(e=this.embossStrength)||void 0===e?void 0:e.call(this))&&void 0!==i?i:.5)),f=Math.min(1,Math.max(0,null!==(s=null===(n=this.embossWhiteLevel)||void 0===n?void 0:n.call(this))&&void 0!==s?s:.5)),p=null!==(o={"top-left":315,top:270,"top-right":225,right:180,"bottom-right":135,bottom:90,"bottom-left":45,left:0}[null!==(a=null===(r=this.embossDirection)||void 0===r?void 0:r.call(this))&&void 0!==a?a:"top-left"])&&void 0!==o?o:315,m=!(null===(l=null===(h=this.embossBlend)||void 0===h?void 0:h.call(this))||void 0===l||!l),_=10*u,v=255*f,y=p*Math.PI/180,x=Math.cos(y),b=Math.sin(y),S=128/1020*_,w=new Uint8ClampedArray(c),C=new Float32Array(d*g);for(let t=0,e=0;e<c.length;e+=4,t++)C[t]=.2126*w[e]+.7152*w[e+1]+.0722*w[e+2];const k=[-1,0,1,-2,0,2,-1,0,1],P=[-1,-2,-1,0,0,0,1,2,1],A=[-d-1,-d,1-d,-1,0,1,d-1,d,d+1],T=t=>t<0?0:t>255?255:t;for(let t=1;t<g-1;t++)for(let e=1;e<d-1;e++){const i=t*d+e;let n=0,s=0;n+=C[i+A[0]]*k[0],s+=C[i+A[0]]*P[0],n+=C[i+A[1]]*k[1],s+=C[i+A[1]]*P[1],n+=C[i+A[2]]*k[2],s+=C[i+A[2]]*P[2],n+=C[i+A[3]]*k[3],s+=C[i+A[3]]*P[3],n+=C[i+A[5]]*k[5],s+=C[i+A[5]]*P[5],n+=C[i+A[6]]*k[6],s+=C[i+A[6]]*P[6],n+=C[i+A[7]]*k[7],s+=C[i+A[7]]*P[7],n+=C[i+A[8]]*k[8],s+=C[i+A[8]]*P[8];const r=T(v+(x*n+b*s)*S),a=4*i;if(m){const t=r-v;c[a]=T(w[a]+t),c[a+1]=T(w[a+1]+t),c[a+2]=T(w[a+2]+t),c[a+3]=w[a+3]}else c[a]=c[a+1]=c[a+2]=r,c[a+3]=w[a+3]}for(let t=0;t<d;t++){let e=4*t,i=4*((g-1)*d+t);c[e]=w[e],c[e+1]=w[e+1],c[e+2]=w[e+2],c[e+3]=w[e+3],c[i]=w[i],c[i+1]=w[i+1],c[i+2]=w[i+2],c[i+3]=w[i+3]}for(let t=1;t<g-1;t++){let e=t*d*4,i=4*(t*d+(d-1));c[e]=w[e],c[e+1]=w[e+1],c[e+2]=w[e+2],c[e+3]=w[e+3],c[i]=w[i],c[i+1]=w[i+1],c[i+2]=w[i+2],c[i+3]=w[i+3]}return t},Enhance:function(t){const e=t.data,i=e.length;let n,s,r,a=e[0],o=a,h=e[1],l=h,c=e[2],d=c;const g=this.enhance();if(0===g)return;for(let t=0;t<i;t+=4)n=e[t+0],n<a?a=n:n>o&&(o=n),s=e[t+1],s<h?h=s:s>l&&(l=s),r=e[t+2],r<c?c=r:r>d&&(d=r);let u,f,p,m,_,v;if(o===a&&(o=255,a=0),l===h&&(l=255,h=0),d===c&&(d=255,c=0),g>0)u=o+g*(255-o),f=a-g*(a-0),p=l+g*(255-l),m=h-g*(h-0),_=d+g*(255-d),v=c-g*(c-0);else{const t=.5*(o+a);u=o+g*(o-t),f=a+g*(a-t);const e=.5*(l+h);p=l+g*(l-e),m=h+g*(h-e);const i=.5*(d+c);_=d+g*(d-i),v=c+g*(c-i)}for(let t=0;t<i;t+=4)e[t+0]=Li(e[t+0],a,o,f,u),e[t+1]=Li(e[t+1],h,l,m,p),e[t+2]=Li(e[t+2],c,d,v,_)},Grayscale:function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4){const i=.34*e[t]+.5*e[t+1]+.16*e[t+2];e[t]=i,e[t+1]=i,e[t+2]=i}},HSL:function(t){const e=t.data,i=e.length,n=Math.pow(2,this.saturation()),s=(this.hue()%360+360)%360,r=127*this.luminance(),a=1*n*Math.cos(s*Math.PI/180),o=1*n*Math.sin(s*Math.PI/180),h=.299+.701*a+.168*o,l=.587-.587*a+.33*o,c=.114-.114*a-.497*o,d=.299-.299*a-.328*o,g=.587+.413*a+.035*o,u=.114-.114*a+.292*o,f=.299-.3*a+1.25*o,p=.587-.588*a-1.05*o,m=.114+.886*a-.203*o;let _,v,y,x;for(let t=0;t<i;t+=4)_=e[t+0],v=e[t+1],y=e[t+2],x=e[t+3],e[t+0]=h*_+l*v+c*y+r,e[t+1]=d*_+g*v+u*y+r,e[t+2]=f*_+p*v+m*y+r,e[t+3]=x},HSV:function(t){const e=t.data,i=e.length,n=Math.pow(2,this.value()),s=Math.pow(2,this.saturation()),r=(this.hue()%360+360)%360,a=n*s*Math.cos(r*Math.PI/180),o=n*s*Math.sin(r*Math.PI/180),h=.299*n+.701*a+.168*o,l=.587*n-.587*a+.33*o,c=.114*n-.114*a-.497*o,d=.299*n-.299*a-.328*o,g=.587*n+.413*a+.035*o,u=.114*n-.114*a+.292*o,f=.299*n-.3*a+1.25*o,p=.587*n-.588*a-1.05*o,m=.114*n+.886*a-.203*o;for(let t=0;t<i;t+=4){const i=e[t+0],n=e[t+1],s=e[t+2],r=e[t+3];e[t+0]=h*i+l*n+c*s,e[t+1]=d*i+g*n+u*s,e[t+2]=f*i+p*n+m*s,e[t+3]=r}},Invert:function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4)e[t]=255-e[t],e[t+1]=255-e[t+1],e[t+2]=255-e[t+2]},Kaleidoscope:function(t){const e=t.width,i=t.height;let n,s,r,a,o,h,l,c,d,g,u=Math.round(this.kaleidoscopePower());const f=Math.round(this.kaleidoscopeAngle()),p=Math.floor(e*(f%360)/360);if(u<1)return;const m=C.createCanvasElement();m.width=e,m.height=i;const _=m.getContext("2d").getImageData(0,0,e,i);C.releaseCanvas(m),function(t,e,i){const n=t.data,s=e.data,r=t.width,a=t.height,o=i.polarCenterX||r/2,h=i.polarCenterY||a/2;let l=Math.sqrt(o*o+h*h),c=r-o,d=a-h;const g=Math.sqrt(c*c+d*d);l=g>l?g:l;const u=a,f=r,p=360/f*Math.PI/180;for(let t=0;t<f;t+=1){const e=Math.sin(t*p),i=Math.cos(t*p);for(let a=0;a<u;a+=1){c=Math.floor(o+l*a/u*i),d=Math.floor(h+l*a/u*e);let g=4*(d*r+c);const f=n[g+0],p=n[g+1],m=n[g+2],_=n[g+3];g=4*(t+a*r),s[g+0]=f,s[g+1]=p,s[g+2]=m,s[g+3]=_}}}(t,_,{polarCenterX:e/2,polarCenterY:i/2});let v=e/Math.pow(2,u);for(;v<=8;)v*=2,u-=1;v=Math.ceil(v);let y=v,x=0,b=y,S=1;for(p+v>e&&(x=y,b=0,S=-1),s=0;s<i;s+=1)for(n=x;n!==b;n+=S)r=Math.round(n+p)%e,d=4*(e*s+r),o=_.data[d+0],h=_.data[d+1],l=_.data[d+2],c=_.data[d+3],g=4*(e*s+n),_.data[g+0]=o,_.data[g+1]=h,_.data[g+2]=l,_.data[g+3]=c;for(s=0;s<i;s+=1)for(y=Math.floor(v),a=0;a<u;a+=1){for(n=0;n<y+1;n+=1)d=4*(e*s+n),o=_.data[d+0],h=_.data[d+1],l=_.data[d+2],c=_.data[d+3],g=4*(e*s+2*y-n-1),_.data[g+0]=o,_.data[g+1]=h,_.data[g+2]=l,_.data[g+3]=c;y*=2}!function(t,e,i){const n=t.data,s=e.data,r=t.width,a=t.height,o=i.polarCenterX||r/2,h=i.polarCenterY||a/2;let l=Math.sqrt(o*o+h*h),c=r-o,d=a-h;const g=Math.sqrt(c*c+d*d);l=g>l?g:l;const u=a,f=r;let p,m;for(c=0;c<r;c+=1)for(d=0;d<a;d+=1){const t=c-o,e=d-h,i=Math.sqrt(t*t+e*e)*u/l;let a=(180*Math.atan2(e,t)/Math.PI+360+0)%360;a=a*f/360,p=Math.floor(a),m=Math.floor(i);let g=4*(m*r+p);const _=n[g+0],v=n[g+1],y=n[g+2],x=n[g+3];g=4*(d*r+c),s[g+0]=_,s[g+1]=v,s[g+2]=y,s[g+3]=x}}(_,t,{})},Mask:function(t){let e=function(t,e){const i=Di(t,0,0),n=Di(t,t.width-1,0),s=Di(t,0,t.height-1),r=Di(t,t.width-1,t.height-1),a=e||10;if(Ii(i,n)<a&&Ii(n,r)<a&&Ii(r,s)<a&&Ii(s,i)<a){const e=function(t){const e=[0,0,0];for(let i=0;i<t.length;i++)e[0]+=t[i][0],e[1]+=t[i][1],e[2]+=t[i][2];return e[0]/=t.length,e[1]/=t.length,e[2]/=t.length,e}([n,i,r,s]),o=[];for(let i=0;i<t.width*t.height;i++){const n=Ii(e,[t.data[4*i],t.data[4*i+1],t.data[4*i+2]]);o[i]=n<a?0:255}return o}}(t,this.threshold());return e&&(e=function(t,e,i){const n=[1,1,1,1,0,1,1,1,1],s=Math.round(Math.sqrt(n.length)),r=Math.floor(s/2),a=[];for(let o=0;o<i;o++)for(let h=0;h<e;h++){const l=o*e+h;let c=0;for(let a=0;a<s;a++)for(let l=0;l<s;l++){const d=o+a-r,g=h+l-r;if(d>=0&&d<i&&g>=0&&g<e){const i=n[a*s+l];c+=t[d*e+g]*i}}a[l]=2040===c?255:0}return a}(e,t.width,t.height),e=function(t,e,i){const n=[1,1,1,1,1,1,1,1,1],s=Math.round(Math.sqrt(n.length)),r=Math.floor(s/2),a=[];for(let o=0;o<i;o++)for(let h=0;h<e;h++){const l=o*e+h;let c=0;for(let a=0;a<s;a++)for(let l=0;l<s;l++){const d=o+a-r,g=h+l-r;if(d>=0&&d<i&&g>=0&&g<e){const i=n[a*s+l];c+=t[d*e+g]*i}}a[l]=c>=1020?255:0}return a}(e,t.width,t.height),e=function(t,e,i){const n=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],s=Math.round(Math.sqrt(n.length)),r=Math.floor(s/2),a=[];for(let o=0;o<i;o++)for(let h=0;h<e;h++){const l=o*e+h;let c=0;for(let a=0;a<s;a++)for(let l=0;l<s;l++){const d=o+a-r,g=h+l-r;if(d>=0&&d<i&&g>=0&&g<e){const i=n[a*s+l];c+=t[d*e+g]*i}}a[l]=c}return a}(e,t.width,t.height),function(t,e){for(let i=0;i<t.width*t.height;i++)t.data[4*i+3]=e[i]}(t,e)),t},Noise:function(t){const e=255*this.noise(),i=t.data,n=i.length,s=e/2;for(let t=0;t<n;t+=4)i[t+0]+=s-2*s*Math.random(),i[t+1]+=s-2*s*Math.random(),i[t+2]+=s-2*s*Math.random()},Pixelate:function(t){let e=Math.ceil(this.pixelSize()),i=t.width,n=t.height,s=Math.ceil(i/e),r=Math.ceil(n/e),a=t.data;if(e<=0)C.error("pixelSize value can not be <= 0");else for(let t=0;t<s;t+=1)for(let s=0;s<r;s+=1){let r=0,o=0,h=0,l=0;const c=t*e,d=c+e,g=s*e,u=g+e;let f=0;for(let t=c;t<d;t+=1)if(!(t>=i))for(let e=g;e<u;e+=1){if(e>=n)continue;const s=4*(i*e+t);r+=a[s+0],o+=a[s+1],h+=a[s+2],l+=a[s+3],f+=1}r/=f,o/=f,h/=f,l/=f;for(let t=c;t<d;t+=1)if(!(t>=i))for(let e=g;e<u;e+=1){if(e>=n)continue;const s=4*(i*e+t);a[s+0]=r,a[s+1]=o,a[s+2]=h,a[s+3]=l}}},Posterize:function(t){const e=Math.round(254*this.levels())+1,i=t.data,n=i.length,s=255/e;for(let t=0;t<n;t+=1)i[t]=Math.floor(i[t]/s)*s},RGB:function(t){const e=t.data,i=e.length,n=this.red(),s=this.green(),r=this.blue();for(let t=0;t<i;t+=4){const i=(.34*e[t]+.5*e[t+1]+.16*e[t+2])/255;e[t]=i*n,e[t+1]=i*s,e[t+2]=i*r,e[t+3]=e[t+3]}},RGBA:function(t){const e=t.data,i=e.length,n=this.red(),s=this.green(),r=this.blue(),a=this.alpha();for(let t=0;t<i;t+=4){const i=1-a;e[t]=n*a+e[t]*i,e[t+1]=s*a+e[t+1]*i,e[t+2]=r*a+e[t+2]*i}},Sepia:function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4){const i=e[t+0],n=e[t+1],s=e[t+2];e[t+0]=Math.min(255,.393*i+.769*n+.189*s),e[t+1]=Math.min(255,.349*i+.686*n+.168*s),e[t+2]=Math.min(255,.272*i+.534*n+.131*s)}},Solarize:function(t){const e=t.data;for(let t=0;t<e.length;t+=4){const i=e[t],n=e[t+1],s=e[t+2];.2126*i+.7152*n+.0722*s>=128&&(e[t]=255-i,e[t+1]=255-n,e[t+2]=255-s)}return t},Threshold:function(t){const e=255*this.threshold(),i=t.data,n=i.length;for(let t=0;t<n;t+=1)i[t]=i[t]<e?0:255}}});return Fi});
|