@inweb/markup 26.9.8 → 26.9.9
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/dist/markup.min.js
CHANGED
|
@@ -21,4 +21,4 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).ODA=t.ODA||{},t.ODA.Markup=t.ODA.Markup||{}))}(this,function(t){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function i(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var r,s={exports:{}},n={},o={},a={};function h(){return r||(r=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t._registerNode=t.Konva=t.glob=void 0;const i=Math.PI/180;t.glob=void 0!==e?e:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},t.Konva={_global:t.glob,version:"9.3.22",isBrowser:"undefined"!=typeof window&&("[object Window]"==={}.toString.call(window)||"[object global]"==={}.toString.call(window)),isUnminified:/param/.test(function(t){}.toString()),dblClickWindow:400,getAngle:e=>t.Konva.angleDeg?e*i: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,_fixTextRendering:!1,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:()=>t.Konva.DD.isDragging,isTransforming(){var e;return null===(e=t.Konva.Transformer)||void 0===e?void 0:e.isTransforming()},isDragReady:()=>!!t.Konva.DD.node,releaseCanvasOnDestroy:!0,document:t.glob.document,_injectGlobal(e){t.glob.Konva=e}};t._registerNode=e=>{t.Konva[e.prototype.getClassName()]=e},t.Konva._injectGlobal(t.Konva)}(a)),a}var l,d={};function c(){return l||(l=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Util=t.Transform=void 0;const e=h();class i{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 i(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),r=this.m[0]*e+this.m[2]*i,s=this.m[1]*e+this.m[3]*i,n=this.m[0]*-i+this.m[2]*e,o=this.m[1]*-i+this.m[3]*e;return this.m[0]=r,this.m[1]=s,this.m[2]=n,this.m[3]=o,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(t,e){const i=this.m[0]+this.m[2]*e,r=this.m[1]+this.m[3]*e,s=this.m[2]+this.m[0]*t,n=this.m[3]+this.m[1]*t;return this.m[0]=i,this.m[1]=r,this.m[2]=s,this.m[3]=n,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],r=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],n=this.m[0]*t.m[4]+this.m[2]*t.m[5]+this.m[4],o=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]=r,this.m[3]=s,this.m[4]=n,this.m[5]=o,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,r=-this.m[2]*t,s=this.m[0]*t,n=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),o=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]=r,this.m[3]=s,this.m[4]=n,this.m[5]=o,this}getMatrix(){return this.m}decompose(){const e=this.m[0],i=this.m[1],r=this.m[2],s=this.m[3],n=e*s-i*r,o={x:this.m[4],y:this.m[5],rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!=e||0!=i){const t=Math.sqrt(e*e+i*i);o.rotation=i>0?Math.acos(e/t):-Math.acos(e/t),o.scaleX=t,o.scaleY=n/t,o.skewX=(e*r+i*s)/n,o.skewY=0}else if(0!=r||0!=s){const t=Math.sqrt(r*r+s*s);o.rotation=Math.PI/2-(s>0?Math.acos(-r/t):-Math.acos(r/t)),o.scaleX=n/t,o.scaleY=t,o.skewX=0,o.skewY=(e*r+i*s)/n}return o.rotation=t.Util._getRotation(o.rotation),o}}t.Transform=i;const r=Math.PI/180,s=180/Math.PI,n="Konva error: ",o={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,132,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,255,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,203],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:[119,128,144],slategrey:[119,128,144],snow:[255,255,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,5]},a=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/;let l=[];const d="undefined"!=typeof requestAnimationFrame&&requestAnimationFrame||function(t){setTimeout(t,60)};t.Util={_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){l.push(t),1===l.length&&d(function(){const t=l;l=[],t.forEach(function(t){t()})})},createCanvasElement(){const t=document.createElement("canvas");try{t.style=t.style||{}}catch(t){}return t},createImageElement:()=>document.createElement("img"),_isInDocument(t){for(;t=t.parentNode;)if(t==document)return!0;return!1},_urlToImage(e,i){const r=t.Util.createImageElement();r.onload=function(){i(r)},r.src=e},_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},getRGB(t){let e;return t in o?(e=o[t],{r:e[0],g:e[1],b:e[2]}):"#"===t[0]?this._hexToRgb(t.substring(1)):"rgb("===t.substr(0,4)?(e=a.exec(t.replace(/ /g,"")),{r:parseInt(e[1],10),g:parseInt(e[2],10),b:parseInt(e[3],10)}):{r:0,g:0,b:0}},colorToRGBA:e=>(e=e||"black",t.Util._namedColorToRBA(e)||t.Util._hex3ColorToRGBA(e)||t.Util._hex4ColorToRGBA(e)||t.Util._hex6ColorToRGBA(e)||t.Util._hex8ColorToRGBA(e)||t.Util._rgbColorToRGBA(e)||t.Util._rgbaColorToRGBA(e)||t.Util._hslColorToRGBA(e)),_namedColorToRBA(t){const e=o[t.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:1}:null},_rgbColorToRGBA(t){if(0===t.indexOf("rgb(")){const e=(t=t.match(/rgb\(([^)]+)\)/)[1]).split(/ *, */).map(Number);return{r:e[0],g:e[1],b:e[2],a:1}}},_rgbaColorToRGBA(t){if(0===t.indexOf("rgba(")){const e=(t=t.match(/rgba\(([^)]+)\)/)[1]).split(/ *, */).map((t,e)=>"%"===t.slice(-1)?3===e?parseInt(t)/100:parseInt(t)/100*255:Number(t));return{r:e[0],g:e[1],b:e[2],a:e[3]}}},_hex8ColorToRGBA(t){if("#"===t[0]&&9===t.length)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("#"===t[0]&&7===t.length)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("#"===t[0]&&5===t.length)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("#"===t[0]&&4===t.length)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){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(t)){const[e,...i]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t),r=Number(i[0])/360,s=Number(i[1])/100,n=Number(i[2])/100;let o,a,h;if(0===s)return h=255*n,{r:Math.round(h),g:Math.round(h),b:Math.round(h),a:1};o=n<.5?n*(1+s):n+s-n*s;const l=2*n-o,d=[0,0,0];for(let t=0;t<3;t++)a=r+1/3*-(t-1),a<0&&a++,a>1&&a--,h=6*a<1?l+6*(o-l)*a:2*a<1?o:3*a<2?l+(o-l)*(2/3-a)*6:l,d[t]=255*h;return{r:Math.round(d[0]),g:Math.round(d[1]),b:Math.round(d[2]),a:1}}},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*r,radToDeg:t=>t*s,_degToRad:e=>(t.Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),t.Util.degToRad(e)),_radToDeg:e=>(t.Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),t.Util.radToDeg(e)),_getRotation:i=>e.Konva.angleDeg?t.Util.radToDeg(i):i,_capitalize:t=>t.charAt(0).toUpperCase()+t.slice(1),throw(t){throw new Error(n+t)},error(t){console.error(n+t)},warn(t){e.Konva.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,r,s,n){let o,a,h;const l=(t-i)*(t-i)+(e-r)*(e-r);if(0==l)o=t,a=e,h=(s-i)*(s-i)+(n-r)*(n-r);else{const d=((s-t)*(i-t)+(n-e)*(r-e))/l;d<0?(o=t,a=e,h=(t-s)*(t-s)+(e-n)*(e-n)):d>1?(o=i,a=r,h=(i-s)*(i-s)+(r-n)*(r-n)):(o=t+d*(i-t),a=e+d*(r-e),h=(o-s)*(o-s)+(a-n)*(a-n))}return[o,a,h]},_getProjectionToLine(e,i,r){const s=t.Util.cloneObject(e);let n=Number.MAX_VALUE;return i.forEach(function(o,a){if(!r&&a===i.length-1)return;const h=i[(a+1)%i.length],l=t.Util._getProjectionToSegment(o.x,o.y,h.x,h.y,e.x,e.y),d=l[0],c=l[1],u=l[2];u<n&&(s.x=d,s.y=c,n=u)}),s},_prepareArrayForTween(e,i,r){const s=[],n=[];if(e.length>i.length){const t=i;i=e,e=t}for(let t=0;t<e.length;t+=2)s.push({x:e[t],y:e[t+1]});for(let t=0;t<i.length;t+=2)n.push({x:i[t],y:i[t+1]});const o=[];return n.forEach(function(e){const i=t.Util._getProjectionToLine(e,s,r);o.push(i.x),o.push(i.y)}),o},_prepareToStringify(e){let i;e.visitedByCircularReferenceRemoval=!0;for(const r in e)if(e.hasOwnProperty(r)&&e[r]&&"object"==typeof e[r])if(i=Object.getOwnPropertyDescriptor(e,r),e[r].visitedByCircularReferenceRemoval||t.Util._isElement(e[r])){if(!i.configurable)return null;delete e[r]}else if(null===t.Util._prepareToStringify(e[r])){if(!i.configurable)return null;delete e[r]}return delete e.visitedByCircularReferenceRemoval,e},_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){e.Konva.releaseCanvasOnDestroy&&t.forEach(t=>{t.width=0,t.height=0})},drawRoundedRectPath(t,e,i,r){let s=0,n=0,o=0,a=0;"number"==typeof r?s=n=o=a=Math.min(r,e/2,i/2):(s=Math.min(r[0]||0,e/2,i/2),n=Math.min(r[1]||0,e/2,i/2),a=Math.min(r[2]||0,e/2,i/2),o=Math.min(r[3]||0,e/2,i/2)),t.moveTo(s,0),t.lineTo(e-n,0),t.arc(e-n,n,n,3*Math.PI/2,0,!1),t.lineTo(e,i-a),t.arc(e-a,i-a,a,0,Math.PI/2,!1),t.lineTo(o,i),t.arc(o,i-o,o,Math.PI/2,Math.PI,!1),t.lineTo(0,s),t.arc(s,s,s,Math.PI,3*Math.PI/2,!1)}}}(d)),d}var u,g,f={},p={},_={};function m(){if(u)return _;u=1,Object.defineProperty(_,"__esModule",{value:!0}),_.HitContext=_.SceneContext=_.Context=void 0;const t=c(),e=h();const i=["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 r=class{constructor(t){this.canvas=t,e.Konva.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(e,i){let r,s,n,o,a=this.traceArr,h=a.length,l="";for(r=0;r<h;r++)s=a[r],n=s.method,n?(o=s.args,l+=n,e?l+="()":t.Util._isArray(o[0])?l+="(["+o.join(",")+"])":(i&&(o=o.map(t=>"number"==typeof t?Math.floor(t):t)),l+="("+o.join(",")+")")):(l+=s.property,e||(l+="="+s.val)),l+=";";return l}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)}setAttr(t,e){this._context[t]=e}arc(t,e,i,r,s,n){this._context.arc(t,e,i,r,s,n)}arcTo(t,e,i,r,s){this._context.arcTo(t,e,i,r,s)}beginPath(){this._context.beginPath()}bezierCurveTo(t,e,i,r,s,n){this._context.bezierCurveTo(t,e,i,r,s,n)}clearRect(t,e,i,r){this._context.clearRect(t,e,i,r)}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,r){return this._context.createLinearGradient(t,e,i,r)}createPattern(t,e){return this._context.createPattern(t,e)}createRadialGradient(t,e,i,r,s,n){return this._context.createRadialGradient(t,e,i,r,s,n)}drawImage(t,e,i,r,s,n,o,a,h){const l=arguments,d=this._context;3===l.length?d.drawImage(t,e,i):5===l.length?d.drawImage(t,e,i,r,s):9===l.length&&d.drawImage(t,e,i,r,s,n,o,a,h)}ellipse(t,e,i,r,s,n,o,a){this._context.ellipse(t,e,i,r,s,n,o,a)}isPointInPath(t,e,i,r){return i?this._context.isPointInPath(i,t,e,r):this._context.isPointInPath(t,e,r)}fill(...t){this._context.fill.apply(this._context,t)}fillRect(t,e,i,r){this._context.fillRect(t,e,i,r)}strokeRect(t,e,i,r){this._context.strokeRect(t,e,i,r)}fillText(t,e,i,r){r?this._context.fillText(t,e,i,r):this._context.fillText(t,e,i)}measureText(t){return this._context.measureText(t)}getImageData(t,e,i,r){return this._context.getImageData(t,e,i,r)}lineTo(t,e){this._context.lineTo(t,e)}moveTo(t,e){this._context.moveTo(t,e)}rect(t,e,i,r){this._context.rect(t,e,i,r)}roundRect(t,e,i,r,s){this._context.roundRect(t,e,i,r,s)}putImageData(t,e,i){this._context.putImageData(t,e,i)}quadraticCurveTo(t,e,i,r){this._context.quadraticCurveTo(t,e,i,r)}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,r,s,n){this._context.setTransform(t,e,i,r,s,n)}stroke(t){t?this._context.stroke(t):this._context.stroke()}strokeText(t,e,i,r){this._context.strokeText(t,e,i,r)}transform(t,e,i,r,s,n){this._context.transform(t,e,i,r,s,n)}translate(t,e){this._context.translate(t,e)}_enableTrace(){let e,r,s=this,n=i.length,o=this.setAttr;const a=function(e){let i,n=s[e];s[e]=function(){return r=function(e){const i=[],r=e.length,s=t.Util;for(let t=0;t<r;t++){let r=e[t];s._isNumber(r)?r=Math.round(1e3*r)/1e3:s._isString(r)||(r+=""),i.push(r)}return i}(Array.prototype.slice.call(arguments,0)),i=n.apply(s,arguments),s._trace({method:e,args:r}),i}};for(e=0;e<n;e++)a(i[e]);s.setAttr=function(){o.apply(s,arguments);const t=arguments[0];let e=arguments[1];"shadowOffsetX"!==t&&"shadowOffsetY"!==t&&"shadowBlur"!==t||(e/=this.canvas.getPixelRatio()),s._trace({property:t,val:e})}}_applyGlobalCompositeOperation(t){const e=t.attrs.globalCompositeOperation;!e||"source-over"===e||this.setAttr("globalCompositeOperation",e)}};_.Context=r,["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"].forEach(function(t){Object.defineProperty(r.prototype,t,{get(){return this._context[t]},set(e){this._context[t]=e}})});_.SceneContext=class extends r{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){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 r=t.getFillPatternImage();if(r&&"pattern"===i)return void this._fillPattern(t);const s=t.getFillLinearGradientColorStops();if(s&&"linear-gradient"===i)return void this._fillLinearGradient(t);const n=t.getFillRadialGradientColorStops();n&&"radial-gradient"===i?this._fillRadialGradient(t):e?this._fillColor(t):r?this._fillPattern(t):s?this._fillLinearGradient(t):n&&this._fillRadialGradient(t)}_strokeLinearGradient(t){const e=t.getStrokeLinearGradientStartPoint(),i=t.getStrokeLinearGradientEndPoint(),r=t.getStrokeLinearGradientColorStops(),s=this.createLinearGradient(e.x,e.y,i.x,i.y);if(r){for(let t=0;t<r.length;t+=2)s.addColorStop(r[t],r[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,r;const s=null!==(e=t.getShadowRGBA())&&void 0!==e?e:"black",n=null!==(i=t.getShadowBlur())&&void 0!==i?i:5,o=null!==(r=t.getShadowOffset())&&void 0!==r?r:{x:0,y:0},a=t.getAbsoluteScale(),h=this.canvas.getPixelRatio(),l=a.x*h,d=a.y*h;this.setAttr("shadowColor",s),this.setAttr("shadowBlur",n*Math.min(Math.abs(l),Math.abs(d))),this.setAttr("shadowOffsetX",o.x*l),this.setAttr("shadowOffsetY",o.y*d)}};return _.HitContext=class extends r{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(),r="auto"===i?t.strokeWidth():i;this.setAttr("lineWidth",r),this.setAttr("strokeStyle",t.colorKey),t._strokeFuncHit(this),e||this.restore()}}},_}function y(){if(g)return p;g=1,Object.defineProperty(p,"__esModule",{value:!0}),p.HitCanvas=p.SceneCanvas=p.Canvas=void 0;const t=c(),e=m(),i=h();let r;let s=class{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;const s=(e||{}).pixelRatio||i.Konva.pixelRatio||function(){if(r)return r;const e=t.Util.createCanvasElement(),s=e.getContext("2d");return r=(i.Konva._global.devicePixelRatio||1)/(s.webkitBackingStorePixelRatio||s.mozBackingStorePixelRatio||s.msBackingStorePixelRatio||s.oBackingStorePixelRatio||s.backingStorePixelRatio||1),t.Util.releaseCanvas(e),r}();this.pixelRatio=s,this._canvas=t.Util.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)}toDataURL(e,i){try{return this._canvas.toDataURL(e,i)}catch(e){try{return this._canvas.toDataURL()}catch(e){return t.Util.error("Unable to get data URL. "+e.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}};p.Canvas=s;p.SceneCanvas=class extends s{constructor(t={width:0,height:0,willReadFrequently:!1}){super(t),this.context=new e.SceneContext(this,{willReadFrequently:t.willReadFrequently}),this.setSize(t.width,t.height)}};return p.HitCanvas=class extends s{constructor(t={width:0,height:0}){super(t),this.hitCanvas=!0,this.context=new e.HitContext(this),this.setSize(t.width,t.height)}},p}var v,x={};function w(){return v||(v=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DD=void 0;const e=h(),i=c();t.DD={get isDragging(){let e=!1;return t.DD._dragElements.forEach(t=>{"dragging"===t.dragStatus&&(e=!0)}),e},justDragged:!1,get node(){let e;return t.DD._dragElements.forEach(t=>{e=t.node}),e},_dragElements:new Map,_drag(e){const r=[];t.DD._dragElements.forEach((t,s)=>{const{node:n}=t,o=n.getStage();o.setPointersPositions(e),void 0===t.pointerId&&(t.pointerId=i.Util._getFirstPointerId(e));const a=o._changedPointerPositions.find(e=>e.id===t.pointerId);if(a){if("dragging"!==t.dragStatus){const i=n.dragDistance();if(Math.max(Math.abs(a.x-t.startPointerPos.x),Math.abs(a.y-t.startPointerPos.y))<i)return;if(n.startDrag({evt:e}),!n.isDragging())return}n._setDragPosition(e,t),r.push(n)}}),r.forEach(t=>{t.fire("dragmove",{type:"dragmove",target:t,evt:e},!0)})},_endDragBefore(i){const r=[];t.DD._dragElements.forEach(s=>{const{node:n}=s,o=n.getStage();i&&o.setPointersPositions(i);if(!o._changedPointerPositions.find(t=>t.id===s.pointerId))return;"dragging"!==s.dragStatus&&"stopped"!==s.dragStatus||(t.DD.justDragged=!0,e.Konva._mouseListenClick=!1,e.Konva._touchListenClick=!1,e.Konva._pointerListenClick=!1,s.dragStatus="stopped");const a=s.node.getLayer()||s.node instanceof e.Konva.Stage&&s.node;a&&-1===r.indexOf(a)&&r.push(a)}),r.forEach(t=>{t.draw()})},_endDragAfter(e){t.DD._dragElements.forEach((i,r)=>{"stopped"===i.dragStatus&&i.node.fire("dragend",{type:"dragend",target:i.node,evt:e},!0),"dragging"!==i.dragStatus&&t.DD._dragElements.delete(r)})}},e.Konva.isBrowser&&(window.addEventListener("mouseup",t.DD._endDragBefore,!0),window.addEventListener("touchend",t.DD._endDragBefore,!0),window.addEventListener("touchcancel",t.DD._endDragBefore,!0),window.addEventListener("mousemove",t.DD._drag),window.addEventListener("touchmove",t.DD._drag),window.addEventListener("mouseup",t.DD._endDragAfter,!1),window.addEventListener("touchend",t.DD._endDragAfter,!1),window.addEventListener("touchcancel",t.DD._endDragAfter,!1))}(x)),x}var b,S,C,T={},A={};function k(){if(b)return A;b=1,Object.defineProperty(A,"__esModule",{value:!0}),A.RGBComponent=function(t){if(t>255)return 255;if(t<0)return 0;return Math.round(t)},A.alphaComponent=function(t){if(t>1)return 1;if(t<1e-4)return 1e-4;return t},A.getNumberValidator=function(){if(t.Konva.isUnminified)return function(t,r){return e.Util._isNumber(t)||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a number.'),t}},A.getNumberOrArrayOfNumbersValidator=function(r){if(t.Konva.isUnminified)return function(t,s){let n=e.Util._isNumber(t),o=e.Util._isArray(t)&&t.length==r;return n||o||e.Util.warn(i(t)+' is a not valid value for "'+s+'" attribute. The value should be a number or Array<number>('+r+")"),t}},A.getNumberOrAutoValidator=function(){if(t.Konva.isUnminified)return function(t,r){return e.Util._isNumber(t)||"auto"===t||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a number or "auto".'),t}},A.getStringValidator=function(){if(t.Konva.isUnminified)return function(t,r){return e.Util._isString(t)||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a string.'),t}},A.getStringOrGradientValidator=function(){if(t.Konva.isUnminified)return function(t,r){const s=e.Util._isString(t),n="[object CanvasGradient]"===Object.prototype.toString.call(t)||t&&t.addColorStop;return s||n||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a string or a native gradient.'),t}},A.getFunctionValidator=function(){if(t.Konva.isUnminified)return function(t,r){return e.Util._isFunction(t)||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a function.'),t}},A.getNumberArrayValidator=function(){if(t.Konva.isUnminified)return function(t,r){const s=Int8Array?Object.getPrototypeOf(Int8Array):null;return s&&t instanceof s||(e.Util._isArray(t)?t.forEach(function(t){e.Util._isNumber(t)||e.Util.warn('"'+r+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")}):e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a array of numbers.')),t}},A.getBooleanValidator=function(){if(t.Konva.isUnminified)return function(t,r){return!0===t||!1===t||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a boolean.'),t}},A.getComponentValidator=function(r){if(t.Konva.isUnminified)return function(t,s){return null==t||e.Util.isObject(t)||e.Util.warn(i(t)+' is a not valid value for "'+s+'" attribute. The value should be an object with properties '+r),t}};const t=h(),e=c();function i(t){return e.Util._isString(t)?'"'+t+'"':"[object Number]"===Object.prototype.toString.call(t)||e.Util._isBoolean(t)?t:Object.prototype.toString.call(t)}return A}function P(){return S||(S=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Factory=void 0;const e=c(),i=k(),r="get",s="set";t.Factory={addGetterSetter(e,i,r,s,n){t.Factory.addGetter(e,i,r),t.Factory.addSetter(e,i,s,n),t.Factory.addOverloadedGetterSetter(e,i)},addGetter(t,i,s){const n=r+e.Util._capitalize(i);t.prototype[n]=t.prototype[n]||function(){const t=this.attrs[i];return void 0===t?s:t}},addSetter(i,r,n,o){const a=s+e.Util._capitalize(r);i.prototype[a]||t.Factory.overWriteSetter(i,r,n,o)},overWriteSetter(t,i,r,n){const o=s+e.Util._capitalize(i);t.prototype[o]=function(t){return r&&null!=t&&(t=r.call(this,t,i)),this._setAttr(i,t),n&&n.call(this),this}},addComponentsGetterSetter(n,o,a,h,l){const d=a.length,c=e.Util._capitalize,u=r+c(o),g=s+c(o);n.prototype[u]=function(){const t={};for(let e=0;e<d;e++){const i=a[e];t[i]=this.getAttr(o+c(i))}return t};const f=(0,i.getComponentValidator)(a);n.prototype[g]=function(t){const e=this.attrs[o];h&&(t=h.call(this,t,o)),f&&f.call(this,t,o);for(const e in t)t.hasOwnProperty(e)&&this._setAttr(o+c(e),t[e]);return t||a.forEach(t=>{this._setAttr(o+c(t),void 0)}),this._fireChangeEvent(o,e,t),l&&l.call(this),this},t.Factory.addOverloadedGetterSetter(n,o)},addOverloadedGetterSetter(t,i){const n=e.Util._capitalize(i),o=s+n,a=r+n;t.prototype[i]=function(){return arguments.length?(this[o](arguments[0]),this):this[a]()}},addDeprecatedGetterSetter(i,s,n,o){e.Util.error("Adding deprecated "+s);const a=r+e.Util._capitalize(s),h=s+" property is deprecated and will be removed soon. Look at Konva change log for more information.";i.prototype[a]=function(){e.Util.error(h);const t=this.attrs[s];return void 0===t?n:t},t.Factory.addSetter(i,s,o,function(){e.Util.error(h)}),t.Factory.addOverloadedGetterSetter(i,s)},backCompat(t,i){e.Util.each(i,function(i,n){const o=t.prototype[n],a=r+e.Util._capitalize(i),h=s+e.Util._capitalize(i);function l(){o.apply(this,arguments),e.Util.error('"'+i+'" method is deprecated and will be removed soon. Use ""'+n+'" instead.')}t.prototype[i]=l,t.prototype[a]=l,t.prototype[h]=l})},afterSetFilter(){this._filterUpToDate=!1}}}(T)),T}function M(){if(C)return f;C=1,Object.defineProperty(f,"__esModule",{value:!0}),f.Node=void 0;const t=y(),e=w(),i=P(),r=h(),s=c(),n=k(),o="absoluteOpacity",a="allEventListeners",l="absoluteTransform",d="absoluteScale",u="canvas",g="listening",p="Shape",_=" ",m="stage",v="transform",x="visible",b=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(_);let S=1,T=class i{constructor(t){this._id=S++,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!==v&&t!==l||!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===v||t===l)&&!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(_);this.on(i,()=>{this._clearCache(t)}),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,i)}_getCanvasCache(){return this._cache.get(u)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===l&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(u)){const{scene:t,filter:e,hit:i,buffer:r}=this._cache.get(u);s.Util.releaseCanvas(t,e,i,r),this._cache.delete(u)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){const i=e||{};let r={};void 0!==i.x&&void 0!==i.y&&void 0!==i.width&&void 0!==i.height||(r=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let n=Math.ceil(i.width||r.width),a=Math.ceil(i.height||r.height),h=i.pixelRatio,l=void 0===i.x?Math.floor(r.x):i.x,c=void 0===i.y?Math.floor(r.y):i.y,g=i.offset||0,f=i.drawBorder||!1,p=i.hitCanvasPixelRatio||1;if(!n||!a)return void s.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");n+=2*g+(Math.abs(Math.round(r.x)-l)>.5?1:0),a+=2*g+(Math.abs(Math.round(r.y)-c)>.5?1:0),l-=g,c-=g;const _=new t.SceneCanvas({pixelRatio:h,width:n,height:a}),m=new t.SceneCanvas({pixelRatio:h,width:0,height:0,willReadFrequently:!0}),y=new t.HitCanvas({pixelRatio:p,width:n,height:a}),v=_.getContext(),x=y.getContext(),w=new t.SceneCanvas({width:_.width/_.pixelRatio+Math.abs(l),height:_.height/_.pixelRatio+Math.abs(c),pixelRatio:_.pixelRatio}),b=w.getContext();return y.isCache=!0,_.isCache=!0,this._cache.delete(u),this._filterUpToDate=!1,!1===i.imageSmoothingEnabled&&(_.getContext()._context.imageSmoothingEnabled=!1,m.getContext()._context.imageSmoothingEnabled=!1),v.save(),x.save(),b.save(),v.translate(-l,-c),x.translate(-l,-c),b.translate(-l,-c),w.x=l,w.y=c,this._isUnderCache=!0,this._clearSelfAndDescendantCache(o),this._clearSelfAndDescendantCache(d),this.drawScene(_,this,w),this.drawHit(y,this),this._isUnderCache=!1,v.restore(),x.restore(),f&&(v.save(),v.beginPath(),v.rect(0,0,n,a),v.closePath(),v.setAttr("strokeStyle","red"),v.setAttr("lineWidth",5),v.stroke(),v.restore()),this._cache.set(u,{scene:_,filter:m,hit:y,buffer:w,x:l,y:c}),this._requestDraw(),this}isCached(){return this._cache.has(u)}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 r=1/0,s=1/0,n=-1/0,o=-1/0;const a=this.getAbsoluteTransform(e);return i.forEach(function(t){const e=a.point(t);void 0===r&&(r=n=e.x,s=o=e.y),r=Math.min(r,e.x),s=Math.min(s,e.y),n=Math.max(n,e.x),o=Math.max(o,e.y)}),{x:r,y:s,width:n-r,height:o-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(),r=i.pixelRatio;t.drawImage(i._canvas,0,0,i.width/r,i.height/r),t.restore()}_drawCachedHitCanvas(t){const e=this._getCanvasCache(),i=e.hit;t.save(),t.translate(e.x,e.y),t.drawImage(i._canvas,0,0,i.width/i.pixelRatio,i.height/i.pixelRatio),t.restore()}_getCachedSceneCanvas(){let t,e,i,r,n=this.filters(),o=this._getCanvasCache(),a=o.scene,h=o.filter,l=h.getContext();if(n){if(!this._filterUpToDate){const o=a.pixelRatio;h.setSize(a.width/a.pixelRatio,a.height/a.pixelRatio);try{for(t=n.length,l.clear(),l.drawImage(a._canvas,0,0,a.getWidth()/o,a.getHeight()/o),e=l.getImageData(0,0,h.getWidth(),h.getHeight()),i=0;i<t;i++)r=n[i],"function"==typeof r?(r.call(this,e),l.putImageData(e,0,0)):s.Util.error("Filter should be type of function, but got "+typeof r+" instead. Please check correct filters")}catch(t){s.Util.error("Unable to apply filter. "+t.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return h}return a}on(t,e){if(this._cache&&this._cache.delete(a),3===arguments.length)return this._delegate.apply(this,arguments);const i=t.split(_);for(let t=0;t<i.length;t++){const r=i[t].split("."),s=r[0],n=r[1]||"";this.eventListeners[s]||(this.eventListeners[s]=[]),this.eventListeners[s].push({name:n,handler:e})}return this}off(t,e){let i,r,s,n,o,h,l=(t||"").split(_),d=l.length;if(this._cache&&this._cache.delete(a),!t)for(r in this.eventListeners)this._off(r);for(i=0;i<d;i++)if(s=l[i],n=s.split("."),o=n[0],h=n[1],o)this.eventListeners[o]&&this._off(o,h,e);else for(r in this.eventListeners)this._off(r,h,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 r=this;this.on(t,function(t){const n=t.target.findAncestors(e,!0,r);for(let e=0;e<n.length;e++)(t=s.Util.cloneObject(t)).currentTarget=n[e],i.call(n[e],t)})}remove(){return this.isDragging()&&this.stopDrag(),e.DD._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(l),this._clearSelfAndDescendantCache(o),this._clearSelfAndDescendantCache(d),this._clearSelfAndDescendantCache(m),this._clearSelfAndDescendantCache(x),this._clearSelfAndDescendantCache(g)}_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"+s.Util._capitalize(t);return s.Util._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"+s.Util._capitalize(e),s.Util._isFunction(this[i])?this[i](t[e]):this._setAttr(e,t[e]))}),this}isListening(){return this._getCache(g,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(x,this._isVisible)}_isVisible(t){if(!this.visible())return!1;const e=this.getParent();return!e||e===t||this===t||e._isVisible(t)}shouldDrawHit(t,i=!1){if(t)return this._isVisible(t)&&this._isListening(t);const s=this.getLayer();let n=!1;e.DD._dragElements.forEach(t=>{"dragging"===t.dragStatus&&("Stage"===t.node.nodeType||t.node.getLayer()===s)&&(n=!0)});const o=!i&&!r.Konva.hitOnDragEnabled&&(n||r.Konva.isTransforming());return this.isListening()&&this.isVisible()&&!o}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let t,e,i,r,s=this.getDepth(),n=this,o=0;const a=this.getStage();return"Stage"!==n.nodeType&&a&&function a(h){for(t=[],e=h.length,i=0;i<e;i++)r=h[i],o++,r.nodeType!==p&&(t=t.concat(r.getChildren().slice())),r._id===n._id&&(i=e);t.length>0&&t[0].getDepth()<=s&&a(t)}(a.getChildren()),o}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(v),this._clearSelfAndDescendantCache(l)),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 r=this.getAbsoluteTransform(t).getMatrix(),n=new s.Transform,o=this.offset();return n.m=r.slice(),n.translate(o.x,o.y),n.getTranslation()}setAbsolutePosition(t){const{x:e,y:i,...r}=this._clearTransform();this.attrs.x=e,this.attrs.y=i,this._clearCache(v);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(r),this.setPosition({x:t.x,y:t.y}),this._clearCache(v),this._clearSelfAndDescendantCache(l),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,r=this.x(),s=this.y();return void 0!==e&&(r+=e),void 0!==i&&(s+=i),this.setPosition({x:r,y:s}),this}_eachAncestorReverse(t,e){let i,r,s=[],n=this.getParent();if(!e||e._id!==this._id){for(s.unshift(this);n&&(!e||n._id!==e._id);)s.unshift(n),n=n.parent;for(i=s.length,r=0;r<i;r++)t(s[r])}}rotate(t){return this.rotation(this.rotation()+t),this}moveToTop(){if(!this.parent)return s.Util.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 s.Util.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 s.Util.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 s.Util.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 s.Util.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&&s.Util.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(o,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,r,n,o=this.getAttrs();const a={attrs:{},className:this.getClassName()};for(t in o)e=o[t],n=s.Util.isObject(e)&&!s.Util._isPlainObject(e)&&!s.Util._isArray(e),n||(i="function"==typeof this[t]&&this[t],delete o[t],r=i?i.call(this):null,o[t]=e,r!==e&&(a.attrs[t]=e));return s.Util._prepareToStringify(a)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,e,i){const r=[];e&&this._isMatch(t)&&r.push(this);let s=this.parent;for(;s;){if(s===i)return r;s._isMatch(t)&&r.push(s),s=s.parent}return r}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,r=t.replace(/ /g,"").split(","),n=r.length;for(e=0;e<n;e++)if(i=r[e],s.Util.isValidSelector(i)||(s.Util.warn('Selector "'+i+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),s.Util.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),s.Util.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(m,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(l,this._getAbsoluteTransform)}_getAbsoluteTransform(t){let e;if(t)return e=new s.Transform,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(l)||new s.Transform,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,r=this.attrs.offsetX||0,s=this.attrs.offsetY||0;e.translate(t-r,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(v,this._getTransform)}_getTransform(){var t,e;const i=this._cache.get(v)||new s.Transform;i.reset();const n=this.x(),o=this.y(),a=r.Konva.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,u=this.attrs.offsetX||0,g=this.attrs.offsetY||0;return 0===n&&0===o||i.translate(n,o),0!==a&&i.rotate(a),0===d&&0===c||i.skew(d,c),1===h&&1===l||i.scale(h,l),0===u&&0===g||i.translate(-1*u,-1*g),i.dirty=!1,i}clone(t){let e,i,r,n,o,a=s.Util.cloneObject(this.attrs);for(e in t)a[e]=t[e];const h=new this.constructor(a);for(e in this.eventListeners)for(i=this.eventListeners[e],r=i.length,n=0;n<r;n++)o=i[n],o.name.indexOf("konva")<0&&(h.eventListeners[e]||(h.eventListeners[e]=[]),h.eventListeners[e].push(o));return h}_toKonvaCanvas(e){e=e||{};const i=this.getClientRect(),r=this.getStage(),s=void 0!==e.x?e.x:Math.floor(i.x),n=void 0!==e.y?e.y:Math.floor(i.y),o=e.pixelRatio||1,a=new t.SceneCanvas({width:e.width||Math.ceil(i.width)||(r?r.width():0),height:e.height||Math.ceil(i.height)||(r?r.height():0),pixelRatio:o}),h=a.getContext(),l=new t.SceneCanvas({width:a.width/a.pixelRatio+Math.abs(s),height:a.height/a.pixelRatio+Math.abs(n),pixelRatio:a.pixelRatio});return!1===e.imageSmoothingEnabled&&(h._context.imageSmoothingEnabled=!1),h.save(),(s||n)&&h.translate(-1*s,-1*n),this.drawScene(a,void 0,l),h.restore(),a}toCanvas(t){return this._toKonvaCanvas(t)._canvas}toDataURL(t){const e=(t=t||{}).mimeType||null,i=t.quality||null,r=this._toKonvaCanvas(t).toDataURL(e,i);return t.callback&&t.callback(r),r}toImage(t){return new Promise((e,i)=>{try{const i=null==t?void 0:t.callback;i&&delete t.callback,s.Util._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():r.Konva.dragDistance}_off(t,e,i){let r,s,n,o=this.eventListeners[t];for(r=0;r<o.length;r++)if(s=o[r].name,n=o[r].handler,!("konva"===s&&"konva"!==e||e&&s!==e||i&&i!==n)){if(o.splice(r,1),0===o.length){delete this.eventListeners[t];break}r--}}_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"+s.Util._capitalize(t)];return s.Util._isFunction(i)?i.call(this,e):this._setAttr(t,e),this}_requestDraw(){if(r.Konva.autoDrawEnabled){const t=this.getLayer()||this.getStage();null==t||t.batchDraw()}}_setAttr(t,e){const i=this.attrs[t];(i!==e||s.Util.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 r;void 0!==i&&(r=this.attrs[t],r||(this.attrs[t]=this.getAttr(t)),this.attrs[t][e]=i,this._fireChangeEvent(t,r,i))}_fireAndBubble(t,e,i){e&&this.nodeType===p&&(e.target=this);const r=["mouseenter","mouseleave","pointerenter","pointerleave","touchenter","touchleave"];if(!(-1!==r.indexOf(t)&&(i&&(this===i||this.isAncestorOf&&this.isAncestorOf(i))||"Stage"===this.nodeType&&!i))){this._fire(t,e);const s=-1!==r.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,r;const s=null!==(e=this._cache.get(a))&&void 0!==e?e:{};let n=null==s?void 0:s[t];if(void 0===n){n=[];let e=Object.getPrototypeOf(this);for(;e;){const s=null!==(r=null===(i=e.eventListeners)||void 0===i?void 0:i[t])&&void 0!==r?r:[];n.push(...s),e=Object.getPrototypeOf(e)}s[t]=n,this._cache.set(a,s)}return n}_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 r=this.eventListeners[t];if(r)for(let t=0;t<r.length;t++)r[t].handler.call(this,e)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(t){const i=t?t.pointerId:void 0,r=this.getStage(),s=this.getAbsolutePosition();if(!r)return;const n=r._getPointerById(i)||r._changedPointerPositions[0]||s;e.DD._dragElements.set(this._id,{node:this,startPointerPos:n,offset:{x:n.x-s.x,y:n.y-s.y},dragStatus:"ready",pointerId:i})}startDrag(t,i=!0){e.DD._dragElements.has(this._id)||this._createDragElement(t);e.DD._dragElements.get(this._id).dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:t&&t.evt},i)}_setDragPosition(t,e){const i=this.getStage()._getPointerById(e.pointerId);if(!i)return;let r={x:i.x-e.offset.x,y:i.y-e.offset.y};const n=this.dragBoundFunc();if(void 0!==n){const e=n.call(this,r,t);e?r=e:s.Util.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}this._lastPos&&this._lastPos.x===r.x&&this._lastPos.y===r.y||(this.setAbsolutePosition(r),this._requestDraw()),this._lastPos=r}stopDrag(t){const i=e.DD._dragElements.get(this._id);i&&(i.dragStatus="stopped"),e.DD._endDragBefore(t),e.DD._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=e.DD._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)||r.Konva.dragButtons.indexOf(t.evt.button)>=0))return;if(this.isDragging())return;let i=!1;e.DD._dragElements.forEach(t=>{this.isAncestorOf(t.node)&&(i=!0)}),i||this._createDragElement(t)})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{this._dragCleanup();if(!this.getStage())return;const t=e.DD._dragElements.get(this._id),i=t&&"dragging"===t.dragStatus,r=t&&"ready"===t.dragStatus;i?this.stopDrag():r&&e.DD._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 s.Util.haveIntersection(i,this.getClientRect())}static create(t,e){return s.Util._isString(t)&&(t=JSON.parse(t)),this._createNode(t,e)}static _createNode(t,e){let n,o,a,h=i.prototype.getClassName.call(t),l=t.children;e&&(t.attrs.container=e),r.Konva[h]||(s.Util.warn('Can not find a node with class name "'+h+'". Fallback to "Shape".'),h="Shape");if(n=new(0,r.Konva[h])(t.attrs),l)for(o=l.length,a=0;a<o;a++)n.add(i._createNode(l[a]));return n}};f.Node=T,T.prototype.nodeType="Node",T.prototype._attrsAffectingSize=[],T.prototype.eventListeners={},T.prototype.on.call(T.prototype,b,function(){this._batchingTransformChange?this._needClearTransformCache=!0:(this._clearCache(v),this._clearSelfAndDescendantCache(l))}),T.prototype.on.call(T.prototype,"visibleChange.konva",function(){this._clearSelfAndDescendantCache(x)}),T.prototype.on.call(T.prototype,"listeningChange.konva",function(){this._clearSelfAndDescendantCache(g)}),T.prototype.on.call(T.prototype,"opacityChange.konva",function(){this._clearSelfAndDescendantCache(o)});const A=i.Factory.addGetterSetter;return A(T,"zIndex"),A(T,"absolutePosition"),A(T,"position"),A(T,"x",0,(0,n.getNumberValidator)()),A(T,"y",0,(0,n.getNumberValidator)()),A(T,"globalCompositeOperation","source-over",(0,n.getStringValidator)()),A(T,"opacity",1,(0,n.getNumberValidator)()),A(T,"name","",(0,n.getStringValidator)()),A(T,"id","",(0,n.getStringValidator)()),A(T,"rotation",0,(0,n.getNumberValidator)()),i.Factory.addComponentsGetterSetter(T,"scale",["x","y"]),A(T,"scaleX",1,(0,n.getNumberValidator)()),A(T,"scaleY",1,(0,n.getNumberValidator)()),i.Factory.addComponentsGetterSetter(T,"skew",["x","y"]),A(T,"skewX",0,(0,n.getNumberValidator)()),A(T,"skewY",0,(0,n.getNumberValidator)()),i.Factory.addComponentsGetterSetter(T,"offset",["x","y"]),A(T,"offsetX",0,(0,n.getNumberValidator)()),A(T,"offsetY",0,(0,n.getNumberValidator)()),A(T,"dragDistance",void 0,(0,n.getNumberValidator)()),A(T,"width",0,(0,n.getNumberValidator)()),A(T,"height",0,(0,n.getNumberValidator)()),A(T,"listening",!0,(0,n.getBooleanValidator)()),A(T,"preventDefault",!0,(0,n.getBooleanValidator)()),A(T,"filters",void 0,function(t){return this._filterUpToDate=!1,t}),A(T,"visible",!0,(0,n.getBooleanValidator)()),A(T,"transformsEnabled","all",(0,n.getStringValidator)()),A(T,"size"),A(T,"dragBoundFunc"),A(T,"draggable",!1,(0,n.getBooleanValidator)()),i.Factory.backCompat(T,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"}),f}var R,E={};function F(){if(R)return E;R=1,Object.defineProperty(E,"__esModule",{value:!0}),E.Container=void 0;const t=P(),e=M(),i=k();let r=class extends e.Node{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(r=>{const s=r._isMatch(t);return s&&i.push(r),!(!s||!e)}),i}_descendants(t){let e=!1;const i=this.getChildren();for(const r of i){if(e=t(r),e)return!0;if(r.hasChildren()&&(e=r._descendants(t),e))return!0}return!1}toObject(){const t=e.Node.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 i=e.Node.prototype.clone.call(this,t);return this.getChildren().forEach(function(t){i.add(t.clone())}),i}getAllIntersections(t){const e=[];return this.find("Shape").forEach(i=>{i.isVisible()&&i.intersects(t)&&e.push(i)}),e}_clearSelfAndDescendantCache(t){var e;super._clearSelfAndDescendantCache(t),this.isCached()||null===(e=this.children)||void 0===e||e.forEach(function(e){e._clearSelfAndDescendantCache(t)})}_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 r=this.getLayer(),s=t||r&&r.getCanvas(),n=s&&s.getContext(),o=this._getCanvasCache(),a=o&&o.scene,h=s&&s.isCache;if(!this.isVisible()&&!h)return this;if(a){n.save();const t=this.getAbsoluteTransform(e).getMatrix();n.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(n),n.restore()}else this._drawChildren("drawScene",s,e,i);return this}drawHit(t,e){if(!this.shouldDrawHit(e))return this;const i=this.getLayer(),r=t||i&&i.hitCanvas,s=r&&r.getContext(),n=this._getCanvasCache();if(n&&n.hit){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),s.restore()}else this._drawChildren("drawHit",r,e);return this}_drawChildren(t,e,i,r){var s;const n=e&&e.getContext(),o=this.clipWidth(),a=this.clipHeight(),h=this.clipFunc(),l="number"==typeof o&&"number"==typeof a||h,d=i===this;if(l){n.save();const t=this.getAbsoluteTransform(i);let e,r=t.getMatrix();if(n.transform(r[0],r[1],r[2],r[3],r[4],r[5]),n.beginPath(),h)e=h.call(this,n,this);else{const t=this.clipX(),e=this.clipY();n.rect(t||0,e||0,o,a)}n.clip.apply(n,e),r=t.copy().invert().getMatrix(),n.transform(r[0],r[1],r[2],r[3],r[4],r[5])}const c=!d&&"source-over"!==this.globalCompositeOperation()&&"drawScene"===t;c&&(n.save(),n._applyGlobalCompositeOperation(this)),null===(s=this.children)||void 0===s||s.forEach(function(s){s[t](e,i,r)}),c&&n.restore(),l&&n.restore()}getClientRect(t={}){var e;const i=t.skipTransform,r=t.relativeTo;let s,n,o,a,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,n=i.y,o=i.x+i.width,a=i.y+i.height):(s=Math.min(s,i.x),n=Math.min(n,i.y),o=Math.max(o,i.x+i.width),a=Math.max(a,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:n,width:o-s,height:a-n}:{x:0,y:0,width:0,height:0},i?h:this._transformedRect(h,r)}};return E.Container=r,t.Factory.addComponentsGetterSetter(r,"clip",["x","y","width","height"]),t.Factory.addGetterSetter(r,"clipX",void 0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(r,"clipY",void 0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(r,"clipWidth",void 0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(r,"clipHeight",void 0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(r,"clipFunc"),E}var I,O,L={},D={};function G(){if(I)return D;I=1,Object.defineProperty(D,"__esModule",{value:!0}),D.getCapturedShape=function(t){return e.get(t)},D.createEvent=r,D.hasPointerCapture=function(t,i){return e.get(t)===i},D.setPointerCapture=function(t,n){s(t);if(!n.getStage())return;e.set(t,n),i&&n._fire("gotpointercapture",r(new PointerEvent("gotpointercapture")))},D.releaseCapture=s;const t=h(),e=new Map,i=void 0!==t.Konva._global.PointerEvent;function r(t){return{evt:t,pointerId:t.pointerId}}function s(t,s){const n=e.get(t);if(!n)return;const o=n.getStage();o&&o.content,e.delete(t),i&&n._fire("lostpointercapture",r(new PointerEvent("lostpointercapture")))}return D}var N,W,U={},B={};function z(){return N||(N=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Shape=t.shapes=void 0;const e=h(),i=c(),r=P(),s=M(),n=k(),o=h(),a=G(),l="hasShadow",d="shadowRGBA",u="patternImage",g="linearGradient",f="radialGradient";let p;function _(){return p||(p=i.Util.createCanvasElement().getContext("2d"),p)}t.shapes={};class m extends s.Node{constructor(e){let r;for(super(e);r=i.Util.getRandomColor(),!r||r in t.shapes;);this.colorKey=r,t.shapes[r]=this}getContext(){return i.Util.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return i.Util.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(l,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&0!==this.shadowOpacity()&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(u,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const t=_().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){const r=new i.Transform;r.translate(this.fillPatternX(),this.fillPatternY()),r.rotate(e.Konva.getAngle(this.fillPatternRotation())),r.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),r.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const s=r.getMatrix(),n="undefined"==typeof DOMMatrix?{a:s[0],b:s[1],c:s[2],d:s[3],e:s[4],f:s[5]}:new DOMMatrix(s);t.setTransform(n)}return t}}_getLinearGradient(){return this._getCache(g,this.__getLinearGradient)}__getLinearGradient(){const t=this.fillLinearGradientColorStops();if(t){const e=_(),i=this.fillLinearGradientStartPoint(),r=this.fillLinearGradientEndPoint(),s=e.createLinearGradient(i.x,i.y,r.x,r.y);for(let e=0;e<t.length;e+=2)s.addColorStop(t[e],t[e+1]);return s}}_getRadialGradient(){return this._getCache(f,this.__getRadialGradient)}__getRadialGradient(){const t=this.fillRadialGradientColorStops();if(t){const e=_(),i=this.fillRadialGradientStartPoint(),r=this.fillRadialGradientEndPoint(),s=e.createRadialGradient(i.x,i.y,this.fillRadialGradientStartRadius(),r.x,r.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(d,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;const t=i.Util.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.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 s.Node.prototype.destroy.call(this),delete t.shapes[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(),r=this.hasStroke(),s=1!==this.getAbsoluteOpacity();if(i&&r&&s)return!0;const n=this.hasShadow(),o=this.shadowForStrokeEnabled();return!!(i&&r&&n&&o)}setStrokeHitEnabled(t){i.Util.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 r=t.skipTransform,s=t.relativeTo||e&&this.getStage()||void 0,n=this.getSelfRect(),o=!t.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,a=n.width+o,h=n.height+o,l=!t.skipShadow&&this.hasShadow(),d=l?this.shadowOffsetX():0,c=l?this.shadowOffsetY():0,u=a+Math.abs(d),g=h+Math.abs(c),f=l&&this.shadowBlur()||0,p={width:u+2*f,height:g+2*f,x:-(o/2+f)+Math.min(d,0)+n.x,y:-(o/2+f)+Math.min(c,0)+n.y};return r?p:this._transformedRect(p,s)}drawScene(t,e,i){const r=this.getLayer(),s=(t||r.getCanvas()).getContext(),n=this._getCanvasCache(),o=this.getSceneFunc(),a=this.hasShadow();let h;const l=e===this;if(!this.isVisible()&&!l)return this;if(n){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(!o)return this;if(s.save(),this._useBufferCanvas()){h=this.getStage();const t=i||h.bufferCanvas,r=t.getContext();r.clear(),r.save(),r._applyLineJoin(this);const n=this.getAbsoluteTransform(e).getMatrix();r.transform(n[0],n[1],n[2],n[3],n[4],n[5]),o.call(this,r,this),r.restore();const l=t.pixelRatio;a&&s._applyShadow(this),s._applyOpacity(this),s._applyGlobalCompositeOperation(this),s.drawImage(t._canvas,t.x||0,t.y||0,t.width/l,t.height/l)}else{if(s._applyLineJoin(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)}a&&s._applyShadow(this),o.call(this,s,this)}return s.restore(),this}drawHit(t,e,r=!1){if(!this.shouldDrawHit(e,r))return this;const s=this.getLayer(),n=t||s.hitCanvas,o=n&&n.getContext(),a=this.hitFunc()||this.sceneFunc(),h=this._getCanvasCache(),l=h&&h.hit;if(this.colorKey||i.Util.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()"),l){o.save();const t=this.getAbsoluteTransform(e).getMatrix();return o.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(o),o.restore(),this}if(!a)return this;o.save(),o._applyLineJoin(this);if(!(this===e)){const t=this.getAbsoluteTransform(e).getMatrix();o.transform(t[0],t[1],t[2],t[3],t[4],t[5])}return a.call(this,o,this),o.restore(),this}drawHitFromCache(t=0){const e=this._getCanvasCache(),r=this._getCachedSceneCanvas(),s=e.hit,n=s.getContext(),o=s.getWidth(),a=s.getHeight();n.clear(),n.drawImage(r._canvas,0,0,o,a);try{const e=n.getImageData(0,0,o,a),r=e.data,s=r.length,h=i.Util._hexToRgb(this.colorKey);for(let e=0;e<s;e+=4){r[e+3]>t?(r[e]=h.r,r[e+1]=h.g,r[e+2]=h.b,r[e+3]=255):r[e+3]=0}n.putImageData(e,0,0)}catch(t){i.Util.error("Unable to draw hit graph from cached scene canvas. "+t.message)}return this}hasPointerCapture(t){return a.hasPointerCapture(t,this)}setPointerCapture(t){a.setPointerCapture(t,this)}releaseCapture(t){a.releaseCapture(t,this)}}t.Shape=m,m.prototype._fillFunc=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},m.prototype._strokeFunc=function(t){t.stroke()},m.prototype._fillFuncHit=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},m.prototype._strokeFuncHit=function(t){t.stroke()},m.prototype._centroid=!1,m.prototype.nodeType="Shape",(0,o._registerNode)(m),m.prototype.eventListeners={},m.prototype.on.call(m.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",function(){this._clearCache(l)}),m.prototype.on.call(m.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",function(){this._clearCache(d)}),m.prototype.on.call(m.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",function(){this._clearCache(u)}),m.prototype.on.call(m.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",function(){this._clearCache(g)}),m.prototype.on.call(m.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",function(){this._clearCache(f)}),r.Factory.addGetterSetter(m,"stroke",void 0,(0,n.getStringOrGradientValidator)()),r.Factory.addGetterSetter(m,"strokeWidth",2,(0,n.getNumberValidator)()),r.Factory.addGetterSetter(m,"fillAfterStrokeEnabled",!1),r.Factory.addGetterSetter(m,"hitStrokeWidth","auto",(0,n.getNumberOrAutoValidator)()),r.Factory.addGetterSetter(m,"strokeHitEnabled",!0,(0,n.getBooleanValidator)()),r.Factory.addGetterSetter(m,"perfectDrawEnabled",!0,(0,n.getBooleanValidator)()),r.Factory.addGetterSetter(m,"shadowForStrokeEnabled",!0,(0,n.getBooleanValidator)()),r.Factory.addGetterSetter(m,"lineJoin"),r.Factory.addGetterSetter(m,"lineCap"),r.Factory.addGetterSetter(m,"sceneFunc"),r.Factory.addGetterSetter(m,"hitFunc"),r.Factory.addGetterSetter(m,"dash"),r.Factory.addGetterSetter(m,"dashOffset",0,(0,n.getNumberValidator)()),r.Factory.addGetterSetter(m,"shadowColor",void 0,(0,n.getStringValidator)()),r.Factory.addGetterSetter(m,"shadowBlur",0,(0,n.getNumberValidator)()),r.Factory.addGetterSetter(m,"shadowOpacity",1,(0,n.getNumberValidator)()),r.Factory.addComponentsGetterSetter(m,"shadowOffset",["x","y"]),r.Factory.addGetterSetter(m,"shadowOffsetX",0,(0,n.getNumberValidator)()),r.Factory.addGetterSetter(m,"shadowOffsetY",0,(0,n.getNumberValidator)()),r.Factory.addGetterSetter(m,"fillPatternImage"),r.Factory.addGetterSetter(m,"fill",void 0,(0,n.getStringOrGradientValidator)()),r.Factory.addGetterSetter(m,"fillPatternX",0,(0,n.getNumberValidator)()),r.Factory.addGetterSetter(m,"fillPatternY",0,(0,n.getNumberValidator)()),r.Factory.addGetterSetter(m,"fillLinearGradientColorStops"),r.Factory.addGetterSetter(m,"strokeLinearGradientColorStops"),r.Factory.addGetterSetter(m,"fillRadialGradientStartRadius",0),r.Factory.addGetterSetter(m,"fillRadialGradientEndRadius",0),r.Factory.addGetterSetter(m,"fillRadialGradientColorStops"),r.Factory.addGetterSetter(m,"fillPatternRepeat","repeat"),r.Factory.addGetterSetter(m,"fillEnabled",!0),r.Factory.addGetterSetter(m,"strokeEnabled",!0),r.Factory.addGetterSetter(m,"shadowEnabled",!0),r.Factory.addGetterSetter(m,"dashEnabled",!0),r.Factory.addGetterSetter(m,"strokeScaleEnabled",!0),r.Factory.addGetterSetter(m,"fillPriority","color"),r.Factory.addComponentsGetterSetter(m,"fillPatternOffset",["x","y"]),r.Factory.addGetterSetter(m,"fillPatternOffsetX",0,(0,n.getNumberValidator)()),r.Factory.addGetterSetter(m,"fillPatternOffsetY",0,(0,n.getNumberValidator)()),r.Factory.addComponentsGetterSetter(m,"fillPatternScale",["x","y"]),r.Factory.addGetterSetter(m,"fillPatternScaleX",1,(0,n.getNumberValidator)()),r.Factory.addGetterSetter(m,"fillPatternScaleY",1,(0,n.getNumberValidator)()),r.Factory.addComponentsGetterSetter(m,"fillLinearGradientStartPoint",["x","y"]),r.Factory.addComponentsGetterSetter(m,"strokeLinearGradientStartPoint",["x","y"]),r.Factory.addGetterSetter(m,"fillLinearGradientStartPointX",0),r.Factory.addGetterSetter(m,"strokeLinearGradientStartPointX",0),r.Factory.addGetterSetter(m,"fillLinearGradientStartPointY",0),r.Factory.addGetterSetter(m,"strokeLinearGradientStartPointY",0),r.Factory.addComponentsGetterSetter(m,"fillLinearGradientEndPoint",["x","y"]),r.Factory.addComponentsGetterSetter(m,"strokeLinearGradientEndPoint",["x","y"]),r.Factory.addGetterSetter(m,"fillLinearGradientEndPointX",0),r.Factory.addGetterSetter(m,"strokeLinearGradientEndPointX",0),r.Factory.addGetterSetter(m,"fillLinearGradientEndPointY",0),r.Factory.addGetterSetter(m,"strokeLinearGradientEndPointY",0),r.Factory.addComponentsGetterSetter(m,"fillRadialGradientStartPoint",["x","y"]),r.Factory.addGetterSetter(m,"fillRadialGradientStartPointX",0),r.Factory.addGetterSetter(m,"fillRadialGradientStartPointY",0),r.Factory.addComponentsGetterSetter(m,"fillRadialGradientEndPoint",["x","y"]),r.Factory.addGetterSetter(m,"fillRadialGradientEndPointX",0),r.Factory.addGetterSetter(m,"fillRadialGradientEndPointY",0),r.Factory.addGetterSetter(m,"fillPatternRotation",0),r.Factory.addGetterSetter(m,"fillRule",void 0,(0,n.getStringValidator)()),r.Factory.backCompat(m,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"})}(B)),B}function H(){if(W)return U;W=1,Object.defineProperty(U,"__esModule",{value:!0}),U.Layer=void 0;const t=c(),e=F(),i=M(),r=P(),s=y(),n=k(),o=z(),a=h(),l=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],d=l.length;let u=class extends e.Container{constructor(t){super(t),this.canvas=new s.SceneCanvas,this.hitCanvas=new s.HitCanvas({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(){i.Node.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(!i.Node.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(i.Node.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(i.Node.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 e=this.getNativeCanvasElement();return i.Node.prototype.remove.call(this),e&&e.parentNode&&t.Util._isInDocument(e)&&e.parentNode.removeChild(e),this}getStage(){return this.parent}setSize({width:t,height:e}){return this.canvas.setSize(t,e),this.hitCanvas.setSize(t,e),this._setSmoothEnabled(),this}_validateAdd(e){const i=e.getType();"Group"!==i&&"Shape"!==i&&t.Util.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(),i.Node.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(){t.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){t.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,t.Util.requestAnimFrame(()=>{this.draw(),this._waitingForDraw=!1})),this}getIntersection(t){if(!this.isListening()||!this.isVisible())return null;let e=1,i=!1;for(;;){for(let r=0;r<d;r++){const s=l[r],n=this._getIntersection({x:t.x+s.x*e,y:t.y+s.y*e}),o=n.shape;if(o)return o;if(i=!!n.antialiased,!n.antialiased)break}if(!i)return null;e+=1}}_getIntersection(e){const i=this.hitCanvas.pixelRatio,r=this.hitCanvas.context.getImageData(Math.round(e.x*i),Math.round(e.y*i),1,1).data,s=r[3];if(255===s){const e=t.Util._rgbToHex(r[0],r[1],r[2]),i=o.shapes["#"+e];return i?{shape:i}:{antialiased:!0}}return s>0?{antialiased:!0}:{}}drawScene(t,i,r){const s=this.getLayer(),n=t||s&&s.getCanvas();return this._fire("beforeDraw",{node:this}),this.clearBeforeDraw()&&n.getContext().clear(),e.Container.prototype.drawScene.call(this,n,i,r),this._fire("draw",{node:this}),this}drawHit(t,i){const r=this.getLayer(),s=t||r&&r.hitCanvas;return r&&r.clearBeforeDraw()&&r.getHitCanvas().getContext().clear(),e.Container.prototype.drawHit.call(this,s,i),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){t.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(e)}getHitGraphEnabled(e){return t.Util.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 t.Util.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};return U.Layer=u,u.prototype.nodeType="Layer",(0,a._registerNode)(u),r.Factory.addGetterSetter(u,"imageSmoothingEnabled",!0),r.Factory.addGetterSetter(u,"clearBeforeDraw",!0),r.Factory.addGetterSetter(u,"hitGraphEnabled",!0,(0,n.getBooleanValidator)()),U}var V,j={};var K,X={};function Y(){if(K)return X;K=1,Object.defineProperty(X,"__esModule",{value:!0}),X.Group=void 0;const t=c(),e=F(),i=h();let r=class extends e.Container{_validateAdd(e){const i=e.getType();"Group"!==i&&"Shape"!==i&&t.Util.throw("You may only add groups and shapes to groups.")}};return X.Group=r,r.prototype.nodeType="Group",(0,i._registerNode)(r),X}var q,Q={};function J(){if(q)return Q;q=1,Object.defineProperty(Q,"__esModule",{value:!0}),Q.Animation=void 0;const t=h(),e=c(),i=t.glob.performance&&t.glob.performance.now?function(){return t.glob.performance.now()}:function(){return(new Date).getTime()};let r=class t{constructor(e,r){this.id=t.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:i(),frameRate:0},this.func=e,this.setLayers(r)}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 r=0;r<i;r++)if(e[r]._id===t._id)return!1;return this.layers.push(t),!0}isRunning(){const e=t.animations,i=e.length;for(let t=0;t<i;t++)if(e[t].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=i(),t._addAnimation(this),this}stop(){return t._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,r=i.length;for(let t=0;t<r;t++)if(i[t].id===e){this.animations.splice(t,1);break}}static _runFrames(){const t={},e=this.animations;for(let r=0;r<e.length;r++){const s=e[r],n=s.layers,o=s.func;s._updateFrameObject(i());const a=n.length;let h;if(h=!o||!1!==o.call(s,s.frame),h)for(let e=0;e<a;e++){const i=n[e];void 0!==i._id&&(t[i._id]=i)}}for(const e in t)t.hasOwnProperty(e)&&t[e].batchDraw()}static _animationLoop(){const i=t;i.animations.length?(i._runFrames(),e.Util.requestAnimFrame(i._animationLoop)):i.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,e.Util.requestAnimFrame(this._animationLoop))}};return Q.Animation=r,r.animations=[],r.animIdCounter=0,r.animRunning=!1,Q}var Z,$,tt={};function et(){return $||($=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Konva=void 0;const e=h(),i=c(),r=M(),s=F(),n=(O||(O=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Stage=t.stages=void 0;const e=c(),i=P(),r=F(),s=h(),n=y(),o=w(),a=h(),l=G(),d="mouseleave",u="mouseover",g="mouseenter",f="mousemove",p="mousedown",_="mouseup",m="pointermove",v="pointerdown",x="pointerup",b="pointercancel",S="pointerout",C="pointerleave",T="pointerover",A="pointerenter",k="contextmenu",M="touchstart",R="touchend",E="touchmove",I="touchcancel",O="wheel",L=[[g,"_pointerenter"],[p,"_pointerdown"],[f,"_pointermove"],[_,"_pointerup"],[d,"_pointerleave"],[M,"_pointerdown"],[E,"_pointermove"],[R,"_pointerup"],[I,"_pointercancel"],[u,"_pointerover"],[O,"_wheel"],[k,"_contextmenu"],[v,"_pointerdown"],[m,"_pointermove"],[x,"_pointerup"],[b,"_pointercancel"],[C,"_pointerleave"],["lostpointercapture","_lostpointercapture"]],D={mouse:{[S]:"mouseout",[C]:d,[T]:u,[A]:g,[m]:f,[v]:p,[x]:_,[b]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[S]:"touchout",[C]:"touchleave",[T]:"touchover",[A]:"touchenter",[m]:E,[v]:M,[x]:R,[b]:I,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[S]:S,[C]:C,[T]:T,[A]:A,[m]:m,[v]:v,[x]:x,[b]:b,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},N=t=>t.indexOf("pointer")>=0?"pointer":t.indexOf("touch")>=0?"touch":"mouse",W=t=>{const e=N(t);return"pointer"===e?s.Konva.pointerEventsEnabled&&D.pointer:"touch"===e?D.touch:"mouse"===e?D.mouse:void 0};function U(t={}){return(t.clipFunc||t.clipWidth||t.clipHeight)&&e.Util.warn("Stage does not support clipping. Please use clip for Layers or Groups."),t}t.stages=[];class B extends r.Container{constructor(e){super(U(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),t.stages.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{U(this.attrs)}),this._checkVisibility()}_validateAdd(t){const i="Layer"===t.getType(),r="FastLayer"===t.getType();i||r||e.Util.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const t=this.visible()?"":"none";this.content.style.display=t}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)),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"),r.Container.prototype.clone.call(this,t)}destroy(){super.destroy();const i=this.content;i&&e.Util._isInDocument(i)&&this.container().removeChild(i);const r=t.stages.indexOf(this);return r>-1&&t.stages.splice(r,1),e.Util.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}:(e.Util.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 n.SceneCanvas({width:t.width,height:t.height,pixelRatio:t.pixelRatio||1}),i=e.getContext()._context,r=this.children;return(t.x||t.y)&&i.translate(-1*t.x,-1*t.y),r.forEach(function(e){if(!e.isVisible())return;const r=e._toKonvaCanvas(t);i.drawImage(r._canvas,t.x,t.y,r.getWidth()/r.getPixelRatio(),r.getHeight()/r.getPixelRatio())}),e}getIntersection(t){if(!t)return null;const e=this.children;for(let i=e.length-1;i>=0;i--){const r=e[i].getIntersection(t);if(r)return r}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.bufferCanvas.setSize(t,e),this.bufferHitCanvas.setSize(t,e),this.children.forEach(i=>{i.setSize({width:t,height:e}),i.draw()})}add(t,...i){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}super.add(t);const r=this.children.length;return r>5&&e.Util.warn("The stage has "+r+" 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(),s.Konva.isBrowser&&this.content.appendChild(t.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(t){return l.hasPointerCapture(t,this)}setPointerCapture(t){l.setPointerCapture(t,this)}releaseCapture(t){l.releaseCapture(t,this)}getLayers(){return this.children}_bindContentEvents(){s.Konva.isBrowser&&L.forEach(([t,e])=>{this.content.addEventListener(t,t=>{this[e](t)},{passive:!1})})}_pointerenter(t){this.setPointersPositions(t);const e=W(t.type);e&&this._fire(e.pointerenter,{evt:t,target:this,currentTarget:this})}_pointerover(t){this.setPointersPositions(t);const e=W(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=W(t.type),i=N(t.type);if(!e)return;this.setPointersPositions(t);const r=this._getTargetShape(i),n=!(s.Konva.isDragging()||s.Konva.isTransforming())||s.Konva.hitOnDragEnabled;r&&n?(r._fireAndBubble(e.pointerout,{evt:t}),r._fireAndBubble(e.pointerleave,{evt:t}),this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this[i+"targetShape"]=null):n&&(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=W(t.type),i=N(t.type);if(!e)return;this.setPointersPositions(t);let r=!1;this._changedPointerPositions.forEach(n=>{const a=this.getIntersection(n);if(o.DD.justDragged=!1,s.Konva["_"+i+"ListenClick"]=!0,!a||!a.isListening())return void(this[i+"ClickStartShape"]=void 0);s.Konva.capturePointerEventsEnabled&&a.setPointerCapture(n.id),this[i+"ClickStartShape"]=a,a._fireAndBubble(e.pointerdown,{evt:t,pointerId:n.id}),r=!0;const h=t.type.indexOf("touch")>=0;a.preventDefault()&&t.cancelable&&h&&t.preventDefault()}),r||this._fire(e.pointerdown,{evt:t,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(t){const e=W(t.type),i=N(t.type);if(!e)return;if(s.Konva.isDragging()&&o.DD.node.preventDefault()&&t.cancelable&&t.preventDefault(),this.setPointersPositions(t),(s.Konva.isDragging()||s.Konva.isTransforming())&&!s.Konva.hitOnDragEnabled)return;const r={};let n=!1;const a=this._getTargetShape(i);this._changedPointerPositions.forEach(s=>{const o=l.getCapturedShape(s.id)||this.getIntersection(s),h=s.id,d={evt:t,pointerId:h},c=a!==o;if(c&&a&&(a._fireAndBubble(e.pointerout,{...d},o),a._fireAndBubble(e.pointerleave,{...d},o)),o){if(r[o._id])return;r[o._id]=!0}o&&o.isListening()?(n=!0,c&&(o._fireAndBubble(e.pointerover,{...d},a),o._fireAndBubble(e.pointerenter,{...d},a),this[i+"targetShape"]=o),o._fireAndBubble(e.pointermove,{...d})):a&&(this._fire(e.pointerover,{evt:t,target:this,currentTarget:this,pointerId:h}),this[i+"targetShape"]=null)}),n||this._fire(e.pointermove,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(t){const e=W(t.type),i=N(t.type);if(!e)return;this.setPointersPositions(t);const r=this[i+"ClickStartShape"],n=this[i+"ClickEndShape"],a={};let h=!1;this._changedPointerPositions.forEach(d=>{const c=l.getCapturedShape(d.id)||this.getIntersection(d);if(c){if(c.releaseCapture(d.id),a[c._id])return;a[c._id]=!0}const u=d.id,g={evt:t,pointerId:u};let f=!1;s.Konva["_"+i+"InDblClickWindow"]?(f=!0,clearTimeout(this[i+"DblTimeout"])):o.DD.justDragged||(s.Konva["_"+i+"InDblClickWindow"]=!0,clearTimeout(this[i+"DblTimeout"])),this[i+"DblTimeout"]=setTimeout(function(){s.Konva["_"+i+"InDblClickWindow"]=!1},s.Konva.dblClickWindow),c&&c.isListening()?(h=!0,this[i+"ClickEndShape"]=c,c._fireAndBubble(e.pointerup,{...g}),s.Konva["_"+i+"ListenClick"]&&r&&r===c&&(c._fireAndBubble(e.pointerclick,{...g}),f&&n&&n===c&&c._fireAndBubble(e.pointerdblclick,{...g}))):(this[i+"ClickEndShape"]=null,s.Konva["_"+i+"ListenClick"]&&this._fire(e.pointerclick,{evt:t,target:this,currentTarget:this,pointerId:u}),f&&this._fire(e.pointerdblclick,{evt:t,target:this,currentTarget:this,pointerId:u}))}),h||this._fire(e.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),s.Konva["_"+i+"ListenClick"]=!1,t.cancelable&&"touch"!==i&&"pointer"!==i&&t.preventDefault()}_contextmenu(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(k,{evt:t}):this._fire(k,{evt:t,target:this,currentTarget:this})}_wheel(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(O,{evt:t}):this._fire(O,{evt:t,target:this,currentTarget:this})}_pointercancel(t){this.setPointersPositions(t);const e=l.getCapturedShape(t.pointerId)||this.getIntersection(this.getPointerPosition());e&&e._fireAndBubble(x,l.createEvent(t)),l.releaseCapture(t.pointerId)}_lostpointercapture(t){l.releaseCapture(t.pointerId)}setPointersPositions(t){const i=this._getContentPosition();let r=null,s=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-i.left)/i.scaleX,y:(t.clientY-i.top)/i.scaleY})}),Array.prototype.forEach.call(t.changedTouches||t.touches,t=>{this._changedPointerPositions.push({id:t.identifier,x:(t.clientX-i.left)/i.scaleX,y:(t.clientY-i.top)/i.scaleY})})):(r=(t.clientX-i.left)/i.scaleX,s=(t.clientY-i.top)/i.scaleY,this.pointerPos={x:r,y:s},this._pointerPositions=[{x:r,y:s,id:e.Util._getFirstPointerId(t)}],this._changedPointerPositions=[{x:r,y:s,id:e.Util._getFirstPointerId(t)}])}_setPointerPosition(t){e.Util.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 n.SceneCanvas({width:this.width(),height:this.height()}),this.bufferHitCanvas=new n.HitCanvas({pixelRatio:1,width:this.width(),height:this.height()}),!s.Konva.isBrowser)return;const t=this.container();if(!t)throw"Stage has no container. A container is required.";t.innerHTML="",this.content=document.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),this._resizeDOM()}cache(){return e.Util.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}}t.Stage=B,B.prototype.nodeType="Stage",(0,a._registerNode)(B),i.Factory.addGetterSetter(B,"container"),s.Konva.isBrowser&&document.addEventListener("visibilitychange",()=>{t.stages.forEach(t=>{t.batchDraw()})})}(L)),L),o=H(),a=function(){if(V)return j;V=1,Object.defineProperty(j,"__esModule",{value:!0}),j.FastLayer=void 0;const t=c(),e=H(),i=h();let r=class extends e.Layer{constructor(e){super(e),this.listening(!1),t.Util.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}};return j.FastLayer=r,r.prototype.nodeType="FastLayer",(0,i._registerNode)(r),j}(),l=Y(),d=w(),u=z(),g=J(),f=(Z||(Z=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Easings=t.Tween=void 0;const e=c(),i=J(),r=M(),s=h(),n={node:1,duration:1,easing:1,onFinish:1,yoyo:1},o=["fill","stroke","shadowColor"];let a=0;class l{constructor(t,e,i,r,s,n,o){this.prop=t,this.propFunc=e,this.begin=r,this._pos=r,this.duration=n,this._change=0,this.prevPos=0,this.yoyo=o,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 d{constructor(r){const o=this,h=r.node,c=h._id,u=r.easing||t.Easings.Linear,g=!!r.yoyo;let f,p;f=void 0===r.duration?.3:0===r.duration?.001:r.duration,this.node=h,this._id=a++;const _=h.getLayer()||(h instanceof s.Konva.Stage?h.getLayers():null);for(p in _||e.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new i.Animation(function(){o.tween.onEnterFrame()},_),this.tween=new l(p,function(t){o._tweenFunc(t)},u,0,1,1e3*f,g),this._addListeners(),d.attrs[c]||(d.attrs[c]={}),d.attrs[c][this._id]||(d.attrs[c][this._id]={}),d.tweens[c]||(d.tweens[c]={}),r)void 0===n[p]&&this._addAttr(p,r[p]);this.reset(),this.onFinish=r.onFinish,this.onReset=r.onReset,this.onUpdate=r.onUpdate}_addAttr(t,i){const r=this.node,s=r._id;let n,a,h,l,c;const u=d.tweens[s][t];u&&delete d.attrs[s][u][t];let g=r.getAttr(t);if(e.Util._isArray(i))if(n=[],a=Math.max(i.length,g.length),"points"===t&&i.length!==g.length&&(i.length>g.length?(l=g,g=e.Util._prepareArrayForTween(g,i,r.closed())):(h=i,i=e.Util._prepareArrayForTween(i,g,r.closed()))),0===t.indexOf("fill"))for(let t=0;t<a;t++)if(t%2==0)n.push(i[t]-g[t]);else{const r=e.Util.colorToRGBA(g[t]);c=e.Util.colorToRGBA(i[t]),g[t]=r,n.push({r:c.r-r.r,g:c.g-r.g,b:c.b-r.b,a:c.a-r.a})}else for(let t=0;t<a;t++)n.push(i[t]-g[t]);else-1!==o.indexOf(t)?(g=e.Util.colorToRGBA(g),c=e.Util.colorToRGBA(i),n={r:c.r-g.r,g:c.g-g.g,b:c.b-g.b,a:c.a-g.a}):n=i-g;d.attrs[s][this._id][t]={start:g,diff:n,end:i,trueEnd:h,trueStart:l},d.tweens[s][t]=this._id}_tweenFunc(t){const i=this.node,r=d.attrs[i._id][this._id];let s,n,a,h,l,c,u,g;for(s in r){if(n=r[s],a=n.start,h=n.diff,g=n.end,e.Util._isArray(a))if(l=[],u=Math.max(a.length,g.length),0===s.indexOf("fill"))for(c=0;c<u;c++)c%2==0?l.push((a[c]||0)+h[c]*t):l.push("rgba("+Math.round(a[c].r+h[c].r*t)+","+Math.round(a[c].g+h[c].g*t)+","+Math.round(a[c].b+h[c].b*t)+","+(a[c].a+h[c].a*t)+")");else for(c=0;c<u;c++)l.push((a[c]||0)+h[c]*t);else l=-1!==o.indexOf(s)?"rgba("+Math.round(a.r+h.r*t)+","+Math.round(a.g+h.g*t)+","+Math.round(a.b+h.b*t)+","+(a.a+h.a*t)+")":a+h*t;i.setAttr(s,l)}}_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=d.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=d.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=d.tweens[t];this.pause(),this.anim&&this.anim.stop();for(const e in i)delete d.tweens[t][e];delete d.attrs[t][e],d.tweens[t]&&(0===Object.keys(d.tweens[t]).length&&delete d.tweens[t],0===Object.keys(d.attrs[t]).length&&delete d.attrs[t])}}t.Tween=d,d.attrs={},d.tweens={},r.Node.prototype.to=function(t){const e=t.onFinish;t.node=this,t.onFinish=function(){this.destroy(),e&&e()},new d(t).play()},t.Easings={BackEaseIn(t,e,i,r){const s=1.70158;return i*(t/=r)*t*((s+1)*t-s)+e},BackEaseOut(t,e,i,r){const s=1.70158;return i*((t=t/r-1)*t*((s+1)*t+s)+1)+e},BackEaseInOut(t,e,i,r){let s=1.70158;return(t/=r/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,r,s,n){let o=0;return 0===t?e:1===(t/=r)?e+i:(n||(n=.3*r),!s||s<Math.abs(i)?(s=i,o=n/4):o=n/(2*Math.PI)*Math.asin(i/s),-s*Math.pow(2,10*(t-=1))*Math.sin((t*r-o)*(2*Math.PI)/n)+e)},ElasticEaseOut(t,e,i,r,s,n){let o=0;return 0===t?e:1===(t/=r)?e+i:(n||(n=.3*r),!s||s<Math.abs(i)?(s=i,o=n/4):o=n/(2*Math.PI)*Math.asin(i/s),s*Math.pow(2,-10*t)*Math.sin((t*r-o)*(2*Math.PI)/n)+i+e)},ElasticEaseInOut(t,e,i,r,s,n){let o=0;return 0===t?e:2==(t/=r/2)?e+i:(n||(n=r*(.3*1.5)),!s||s<Math.abs(i)?(s=i,o=n/4):o=n/(2*Math.PI)*Math.asin(i/s),t<1?s*Math.pow(2,10*(t-=1))*Math.sin((t*r-o)*(2*Math.PI)/n)*-.5+e:s*Math.pow(2,-10*(t-=1))*Math.sin((t*r-o)*(2*Math.PI)/n)*.5+i+e)},BounceEaseOut:(t,e,i,r)=>(t/=r)<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:(e,i,r,s)=>r-t.Easings.BounceEaseOut(s-e,0,r,s)+i,BounceEaseInOut:(e,i,r,s)=>e<s/2?.5*t.Easings.BounceEaseIn(2*e,0,r,s)+i:.5*t.Easings.BounceEaseOut(2*e-s,0,r,s)+.5*r+i,EaseIn:(t,e,i,r)=>i*(t/=r)*t+e,EaseOut:(t,e,i,r)=>-i*(t/=r)*(t-2)+e,EaseInOut:(t,e,i,r)=>(t/=r/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e,StrongEaseIn:(t,e,i,r)=>i*(t/=r)*t*t*t*t+e,StrongEaseOut:(t,e,i,r)=>i*((t=t/r-1)*t*t*t*t+1)+e,StrongEaseInOut:(t,e,i,r)=>(t/=r/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e,Linear:(t,e,i,r)=>i*t/r+e}}(tt)),tt),p=m(),_=y();t.Konva=i.Util._assign(e.Konva,{Util:i.Util,Transform:i.Transform,Node:r.Node,Container:s.Container,Stage:n.Stage,stages:n.stages,Layer:o.Layer,FastLayer:a.FastLayer,Group:l.Group,DD:d.DD,Shape:u.Shape,shapes:u.shapes,Animation:g.Animation,Tween:f.Tween,Easings:f.Easings,Context:p.Context,Canvas:_.Canvas}),t.default=t.Konva}(o)),o}var it,rt={};var st,nt={},ot={};function at(){if(st)return ot;st=1,Object.defineProperty(ot,"__esModule",{value:!0}),ot.Line=void 0;const t=P(),e=h(),i=z(),r=k();function s(t,e,i,r,s,n,o){const a=Math.sqrt(Math.pow(i-t,2)+Math.pow(r-e,2)),h=Math.sqrt(Math.pow(s-i,2)+Math.pow(n-r,2)),l=o*a/(a+h),d=o*h/(a+h);return[i-l*(s-t),r-l*(n-e),i+d*(s-t),r+d*(n-e)]}function n(t,e){const i=t.length,r=[];for(let n=2;n<i-2;n+=2){const i=s(t[n-2],t[n-1],t[n],t[n+1],t[n+2],t[n+3],e);isNaN(i[0])||(r.push(i[0]),r.push(i[1]),r.push(t[n]),r.push(t[n+1]),r.push(i[2]),r.push(i[3]))}return r}let o=class extends i.Shape{constructor(t){super(t),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",function(){this._clearCache("tensionPoints")})}_sceneFunc(t){const e=this.points(),i=e.length,r=this.tension(),s=this.closed(),n=this.bezier();if(!i)return;let o=0;if(t.beginPath(),t.moveTo(e[0],e[1]),0!==r&&i>4){const r=this.getTensionPoints(),n=r.length;for(o=s?0:4,s||t.quadraticCurveTo(r[0],r[1],r[2],r[3]);o<n-2;)t.bezierCurveTo(r[o++],r[o++],r[o++],r[o++],r[o++],r[o++]);s||t.quadraticCurveTo(r[n-2],r[n-1],e[i-2],e[i-1])}else if(n)for(o=2;o<i;)t.bezierCurveTo(e[o++],e[o++],e[o++],e[o++],e[o++],e[o++]);else for(o=2;o<i;o+=2)t.lineTo(e[o],e[o+1]);s?(t.closePath(),t.fillStrokeShape(this)):t.strokeShape(this)}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():n(this.points(),this.tension())}_getTensionPointsClosed(){const t=this.points(),e=t.length,i=this.tension(),r=s(t[e-2],t[e-1],t[0],t[1],t[2],t[3],i),o=s(t[e-4],t[e-3],t[e-2],t[e-1],t[0],t[1],i),a=n(t,i);return[r[2],r[3]].concat(a).concat([o[0],o[1],t[e-2],t[e-1],o[2],o[3],r[0],r[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};t=0!==this.tension()?[t[0],t[1],...this._getTensionPoints(),t[t.length-2],t[t.length-1]]:this.points();let e,i,r=t[0],s=t[0],n=t[1],o=t[1];for(let a=0;a<t.length/2;a++)e=t[2*a],i=t[2*a+1],r=Math.min(r,e),s=Math.max(s,e),n=Math.min(n,i),o=Math.max(o,i);return{x:r,y:n,width:s-r,height:o-n}}};return ot.Line=o,o.prototype.className="Line",o.prototype._attrsAffectingSize=["points","bezier","tension"],(0,e._registerNode)(o),t.Factory.addGetterSetter(o,"closed",!1),t.Factory.addGetterSetter(o,"bezier",!1),t.Factory.addGetterSetter(o,"tension",0,(0,r.getNumberValidator)()),t.Factory.addGetterSetter(o,"points",[],(0,r.getNumberArrayValidator)()),ot}var ht,lt,dt,ct={},ut={};function gt(){if(lt)return ct;lt=1,Object.defineProperty(ct,"__esModule",{value:!0}),ct.Path=void 0;const t=P(),e=h(),i=z(),r=(ht||(ht=1,function(t){function e(t,e,r){const s=i(1,r,t),n=i(1,r,e),o=s*s+n*n;return Math.sqrt(o)}Object.defineProperty(t,"__esModule",{value:!0}),t.t2length=t.getQuadraticArcLength=t.getCubicArcLength=t.binomialCoefficients=t.cValues=t.tValues=void 0,t.tValues=[[],[],[-.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]],t.cValues=[[],[],[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]],t.binomialCoefficients=[[1],[1,1],[1,2,1],[1,3,3,1]],t.getCubicArcLength=(i,r,s)=>{let n,o;const a=s/2;n=0;for(let s=0;s<20;s++)o=a*t.tValues[20][s]+a,n+=t.cValues[20][s]*e(i,r,o);return a*n},t.getQuadraticArcLength=(t,e,i)=>{void 0===i&&(i=1);const r=t[0]-2*t[1]+t[2],s=e[0]-2*e[1]+e[2],n=2*t[1]-2*t[0],o=2*e[1]-2*e[0],a=4*(r*r+s*s),h=4*(r*n+s*o),l=n*n+o*o;if(0===a)return i*Math.sqrt(Math.pow(t[2]-t[0],2)+Math.pow(e[2]-e[0],2));const d=h/(2*a),c=i+d,u=l/a-d*d,g=c*c+u>0?Math.sqrt(c*c+u):0,f=d*d+u>0?Math.sqrt(d*d+u):0,p=d+Math.sqrt(d*d+u)!==0?u*Math.log(Math.abs((c+g)/(d+f))):0;return Math.sqrt(a)/2*(c*g-d*f+p)};const i=(e,r,s)=>{const n=s.length-1;let o,a;if(0===n)return 0;if(0===e){a=0;for(let e=0;e<=n;e++)a+=t.binomialCoefficients[n][e]*Math.pow(1-r,n-e)*Math.pow(r,e)*s[e];return a}o=new Array(n);for(let t=0;t<n;t++)o[t]=n*(s[t+1]-s[t]);return i(e-1,r,o)};t.t2length=(t,e,i)=>{let r=1,s=t/e,n=(t-i(s))/e,o=0;for(;r>.001;){const a=i(s+n),h=Math.abs(t-a)/e;if(h<r)r=h,s+=n;else{const o=i(s-n),a=Math.abs(t-o)/e;a<r?(r=a,s-=n):n/=2}if(o++,o>500)break}return s}}(ut)),ut);let s=class t extends i.Shape{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=t.parsePathData(this.data()),this.pathLength=t.getPathLength(this.dataArray)}_sceneFunc(t){const e=this.dataArray;t.beginPath();let i=!1;for(let r=0;r<e.length;r++){const s=e[r].command,n=e[r].points;switch(s){case"L":t.lineTo(n[0],n[1]);break;case"M":t.moveTo(n[0],n[1]);break;case"C":t.bezierCurveTo(n[0],n[1],n[2],n[3],n[4],n[5]);break;case"Q":t.quadraticCurveTo(n[0],n[1],n[2],n[3]);break;case"A":const e=n[0],r=n[1],s=n[2],o=n[3],a=n[4],h=n[5],l=n[6],d=n[7],c=s>o?s:o,u=s>o?1:s/o,g=s>o?o/s:1;t.translate(e,r),t.rotate(l),t.scale(u,g),t.arc(0,0,c,a,a+h,1-d),t.scale(1/u,1/g),t.rotate(-l),t.translate(-e,-r);break;case"z":i=!0,t.closePath()}}i||this.hasFill()?t.fillStrokeShape(this):t.strokeShape(this)}getSelfRect(){let e=[];this.dataArray.forEach(function(i){if("A"===i.command){const r=i.points[4],s=i.points[5],n=i.points[4]+s;let o=Math.PI/180;if(Math.abs(r-n)<o&&(o=Math.abs(r-n)),s<0)for(let s=r-o;s>n;s-=o){const r=t.getPointOnEllipticalArc(i.points[0],i.points[1],i.points[2],i.points[3],s,0);e.push(r.x,r.y)}else for(let s=r+o;s<n;s+=o){const r=t.getPointOnEllipticalArc(i.points[0],i.points[1],i.points[2],i.points[3],s,0);e.push(r.x,r.y)}}else if("C"===i.command)for(let r=0;r<=1;r+=.01){const s=t.getPointOnCubicBezier(r,i.start.x,i.start.y,i.points[0],i.points[1],i.points[2],i.points[3],i.points[4],i.points[5]);e.push(s.x,s.y)}else e=e.concat(i.points)});let i,r,s=e[0],n=e[0],o=e[1],a=e[1];for(let t=0;t<e.length/2;t++)i=e[2*t],r=e[2*t+1],isNaN(i)||(s=Math.min(s,i),n=Math.max(n,i)),isNaN(r)||(o=Math.min(o,r),a=Math.max(a,r));return{x:s,y:o,width:n-s,height:a-o}}getLength(){return this.pathLength}getPointAtLength(e){return t.getPointAtLengthOfDataArray(e,this.dataArray)}static getLineLength(t,e,i,r){return Math.sqrt((i-t)*(i-t)+(r-e)*(r-e))}static getPathLength(t){let e=0;for(let i=0;i<t.length;++i)e+=t[i].pathLength;return e}static getPointAtLengthOfDataArray(e,i){let s,n=0,o=i.length;if(!o)return null;for(;n<o&&e>i[n].pathLength;)e-=i[n].pathLength,++n;if(n===o)return s=i[n-1].points.slice(-2),{x:s[0],y:s[1]};if(e<.01){return"M"===i[n].command?(s=i[n].points.slice(0,2),{x:s[0],y:s[1]}):{x:i[n].start.x,y:i[n].start.y}}const a=i[n],h=a.points;switch(a.command){case"L":return t.getPointOnLine(e,a.start.x,a.start.y,h[0],h[1]);case"C":return t.getPointOnCubicBezier((0,r.t2length)(e,t.getPathLength(i),t=>(0,r.getCubicArcLength)([a.start.x,h[0],h[2],h[4]],[a.start.y,h[1],h[3],h[5]],t)),a.start.x,a.start.y,h[0],h[1],h[2],h[3],h[4],h[5]);case"Q":return t.getPointOnQuadraticBezier((0,r.t2length)(e,t.getPathLength(i),t=>(0,r.getQuadraticArcLength)([a.start.x,h[0],h[2]],[a.start.y,h[1],h[3]],t)),a.start.x,a.start.y,h[0],h[1],h[2],h[3]);case"A":const s=h[0],n=h[1],o=h[2],l=h[3],d=h[5],c=h[6];let u=h[4];return u+=d*e/a.pathLength,t.getPointOnEllipticalArc(s,n,o,l,u,c)}return null}static getPointOnLine(t,e,i,r,s,n,o){n=null!=n?n:e,o=null!=o?o:i;const a=this.getLineLength(e,i,r,s);if(a<1e-10)return{x:e,y:i};if(r===e)return{x:n,y:o+(s>i?t:-t)};const h=(s-i)/(r-e),l=Math.sqrt(t*t/(1+h*h))*(r<e?-1:1),d=h*l;if(Math.abs(o-i-h*(n-e))<1e-10)return{x:n+l,y:o+d};const c=((n-e)*(r-e)+(o-i)*(s-i))/(a*a),u=e+c*(r-e),g=i+c*(s-i),f=this.getLineLength(n,o,u,g),p=Math.sqrt(t*t-f*f),_=Math.sqrt(p*p/(1+h*h))*(r<e?-1:1);return{x:u+_,y:g+h*_}}static getPointOnCubicBezier(t,e,i,r,s,n,o,a,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 u(t){return(1-t)*(1-t)*(1-t)}return{x:a*l(t)+n*d(t)+r*c(t)+e*u(t),y:h*l(t)+o*d(t)+s*c(t)+i*u(t)}}static getPointOnQuadraticBezier(t,e,i,r,s,n,o){function a(t){return t*t}function h(t){return 2*t*(1-t)}function l(t){return(1-t)*(1-t)}return{x:n*a(t)+r*h(t)+e*l(t),y:o*a(t)+s*h(t)+i*l(t)}}static getPointOnEllipticalArc(t,e,i,r,s,n){const o=Math.cos(n),a=Math.sin(n),h=i*Math.cos(s),l=r*Math.sin(s);return{x:t+(h*o-l*a),y:e+(h*a+l*o)}}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 r=e.split("|"),s=[],n=[];let o=0,a=0;const h=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;let l;for(let t=1;t<r.length;t++){let e=r[t],i=e.charAt(0);for(e=e.slice(1),n.length=0;l=h.exec(e);)n.push(l[0]);const d=[];for(let t=0,e=n.length;t<e;t++){if("00"===n[t]){d.push(0,0);continue}const e=parseFloat(n[t]);isNaN(e)?d.push(0):d.push(e)}for(;d.length>0&&!isNaN(d[0]);){let t="",e=[];const r=o,n=a;let h,l,c,u,g,f,p,_,m,y;switch(i){case"l":o+=d.shift(),a+=d.shift(),t="L",e.push(o,a);break;case"L":o=d.shift(),a=d.shift(),e.push(o,a);break;case"m":const r=d.shift(),n=d.shift();if(o+=r,a+=n,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){o=s[t].points[0]+r,a=s[t].points[1]+n;break}e.push(o,a),i="l";break;case"M":o=d.shift(),a=d.shift(),t="M",e.push(o,a),i="L";break;case"h":o+=d.shift(),t="L",e.push(o,a);break;case"H":o=d.shift(),t="L",e.push(o,a);break;case"v":a+=d.shift(),t="L",e.push(o,a);break;case"V":a=d.shift(),t="L",e.push(o,a);break;case"C":e.push(d.shift(),d.shift(),d.shift(),d.shift()),o=d.shift(),a=d.shift(),e.push(o,a);break;case"c":e.push(o+d.shift(),a+d.shift(),o+d.shift(),a+d.shift()),o+=d.shift(),a+=d.shift(),t="C",e.push(o,a);break;case"S":l=o,c=a,h=s[s.length-1],"C"===h.command&&(l=o+(o-h.points[2]),c=a+(a-h.points[3])),e.push(l,c,d.shift(),d.shift()),o=d.shift(),a=d.shift(),t="C",e.push(o,a);break;case"s":l=o,c=a,h=s[s.length-1],"C"===h.command&&(l=o+(o-h.points[2]),c=a+(a-h.points[3])),e.push(l,c,o+d.shift(),a+d.shift()),o+=d.shift(),a+=d.shift(),t="C",e.push(o,a);break;case"Q":e.push(d.shift(),d.shift()),o=d.shift(),a=d.shift(),e.push(o,a);break;case"q":e.push(o+d.shift(),a+d.shift()),o+=d.shift(),a+=d.shift(),t="Q",e.push(o,a);break;case"T":l=o,c=a,h=s[s.length-1],"Q"===h.command&&(l=o+(o-h.points[0]),c=a+(a-h.points[1])),o=d.shift(),a=d.shift(),t="Q",e.push(l,c,o,a);break;case"t":l=o,c=a,h=s[s.length-1],"Q"===h.command&&(l=o+(o-h.points[0]),c=a+(a-h.points[1])),o+=d.shift(),a+=d.shift(),t="Q",e.push(l,c,o,a);break;case"A":u=d.shift(),g=d.shift(),f=d.shift(),p=d.shift(),_=d.shift(),m=o,y=a,o=d.shift(),a=d.shift(),t="A",e=this.convertEndpointToCenterParameterization(m,y,o,a,p,_,u,g,f);break;case"a":u=d.shift(),g=d.shift(),f=d.shift(),p=d.shift(),_=d.shift(),m=o,y=a,o+=d.shift(),a+=d.shift(),t="A",e=this.convertEndpointToCenterParameterization(m,y,o,a,p,_,u,g,f)}s.push({command:t||i,points:e,start:{x:r,y:n},pathLength:this.calcLength(r,n,t||i,e)})}"z"!==i&&"Z"!==i||s.push({command:"z",points:[],start:void 0,pathLength:0})}return s}static calcLength(e,i,s,n){let o,a,h,l;const d=t;switch(s){case"L":return d.getLineLength(e,i,n[0],n[1]);case"C":return(0,r.getCubicArcLength)([e,n[0],n[2],n[4]],[i,n[1],n[3],n[5]],1);case"Q":return(0,r.getQuadraticArcLength)([e,n[0],n[2]],[i,n[1],n[3]],1);case"A":o=0;const t=n[4],s=n[5],c=n[4]+s;let u=Math.PI/180;if(Math.abs(t-c)<u&&(u=Math.abs(t-c)),a=d.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],t,0),s<0)for(l=t-u;l>c;l-=u)h=d.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],l,0),o+=d.getLineLength(a.x,a.y,h.x,h.y),a=h;else for(l=t+u;l<c;l+=u)h=d.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],l,0),o+=d.getLineLength(a.x,a.y,h.x,h.y),a=h;return h=d.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],c,0),o+=d.getLineLength(a.x,a.y,h.x,h.y),o}return 0}static convertEndpointToCenterParameterization(t,e,i,r,s,n,o,a,h){const l=h*(Math.PI/180),d=Math.cos(l)*(t-i)/2+Math.sin(l)*(e-r)/2,c=-1*Math.sin(l)*(t-i)/2+Math.cos(l)*(e-r)/2,u=d*d/(o*o)+c*c/(a*a);u>1&&(o*=Math.sqrt(u),a*=Math.sqrt(u));let g=Math.sqrt((o*o*(a*a)-o*o*(c*c)-a*a*(d*d))/(o*o*(c*c)+a*a*(d*d)));s===n&&(g*=-1),isNaN(g)&&(g=0);const f=g*o*c/a,p=g*-a*d/o,_=(t+i)/2+Math.cos(l)*f-Math.sin(l)*p,m=(e+r)/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))},w=x([1,0],[(d-f)/o,(c-p)/a]),b=[(d-f)/o,(c-p)/a],S=[(-1*d-f)/o,(-1*c-p)/a];let C=x(b,S);return v(b,S)<=-1&&(C=Math.PI),v(b,S)>=1&&(C=0),0===n&&C>0&&(C-=2*Math.PI),1===n&&C<0&&(C+=2*Math.PI),[_,m,o,a,w,C,l,n]}};return ct.Path=s,s.prototype.className="Path",s.prototype._attrsAffectingSize=["data"],(0,e._registerNode)(s),t.Factory.addGetterSetter(s,"data"),ct}var ft,pt={};var _t,mt={};var yt,vt={};var xt,wt={};var bt,St={};function Ct(){if(bt)return St;bt=1,Object.defineProperty(St,"__esModule",{value:!0}),St.Rect=void 0;const t=P(),e=z(),i=h(),r=c(),s=k();let n=class extends e.Shape{_sceneFunc(t){const e=this.cornerRadius(),i=this.width(),s=this.height();t.beginPath(),e?r.Util.drawRoundedRectPath(t,i,s,e):t.rect(0,0,i,s),t.closePath(),t.fillStrokeShape(this)}};return St.Rect=n,n.prototype.className="Rect",(0,i._registerNode)(n),t.Factory.addGetterSetter(n,"cornerRadius",0,(0,s.getNumberOrArrayOfNumbersValidator)(4)),St}var Tt,At={};var kt,Pt={};var Mt,Rt={};var Et,Ft={};var It,Ot={};function Lt(){if(It)return Ot;It=1,Object.defineProperty(Ot,"__esModule",{value:!0}),Ot.Text=void 0,Ot.stringToArray=o;const t=c(),e=P(),i=z(),r=h(),s=k(),n=h();function o(t){return[...t].reduce((t,e,i,r)=>{if(/\p{Emoji}/u.test(e)){const s=r[i+1];s&&/\p{Emoji_Modifier}|\u200D/u.test(s)?(t.push(e+s),r[i+1]=""):t.push(e)}else/\p{Regional_Indicator}{2}/u.test(e+(r[i+1]||""))?t.push(e+r[i+1]):i>0&&/\p{Mn}|\p{Me}|\p{Mc}/u.test(e)?t[t.length-1]+=e:e&&t.push(e);return t},[])}const a="auto",l="inherit",d="justify",u="left",g="middle",f="normal",p=" ",_="none",m=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],y=m.length;let v;function x(){return v||(v=t.Util.createCanvasElement().getContext("2d"),v)}let w=class extends i.Shape{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<y;t++)this.on(m[t]+"Change.konva",this._setTextData);this._setTextData()}_sceneFunc(t){const e=this.textArr,i=e.length;if(!this.text())return;let s,n=this.padding(),a=this.fontSize(),h=this.lineHeight()*a,c=this.verticalAlign(),f=this.direction(),p=0,_=this.align(),m=this.getWidth(),y=this.letterSpacing(),v=this.fill(),x=this.textDecoration(),w=-1!==x.indexOf("underline"),b=-1!==x.indexOf("line-through");f=f===l?t.direction:f;let S=h/2,C=g;if(r.Konva._fixTextRendering){const t=this.measureSize("M");C="alphabetic",S=(t.fontBoundingBoxAscent-t.fontBoundingBoxDescent)/2+h/2}for("rtl"===f&&t.setAttr("direction",f),t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",C),t.setAttr("textAlign",u),c===g?p=(this.getHeight()-i*h-2*n)/2:"bottom"===c&&(p=this.getHeight()-i*h-2*n),t.translate(n,p+n),s=0;s<i;s++){let l=0,c=0;const u=e[s],g=u.text,p=u.width,x=u.lastInParagraph;if(t.save(),"right"===_?l+=m-p-2*n:"center"===_&&(l+=(m-p-2*n)/2),w){t.save(),t.beginPath();const e=l,i=S+c+(r.Konva._fixTextRendering?Math.round(a/4):Math.round(a/2));t.moveTo(e,i);const s=_!==d||x?p:m-2*n;t.lineTo(e+Math.round(s),i),t.lineWidth=a/15;const o=this._getLinearGradient();t.strokeStyle=o||v,t.stroke(),t.restore()}if(b){t.save(),t.beginPath();const e=r.Konva._fixTextRendering?-Math.round(a/4):0;t.moveTo(l,S+c+e);const i=_!==d||x?p:m-2*n;t.lineTo(l+Math.round(i),S+c+e),t.lineWidth=a/15;const s=this._getLinearGradient();t.strokeStyle=s||v,t.stroke(),t.restore()}if("rtl"===f||0===y&&_!==d)0!==y&&t.setAttr("letterSpacing",`${y}px`),this._partialTextX=l,this._partialTextY=S+c,this._partialText=g,t.fillStrokeShape(this);else{const e=g.split(" ").length-1,i=o(g);for(let r=0;r<i.length;r++){const s=i[r];" "!==s||x||_!==d||(l+=(m-2*n-p)/e),this._partialTextX=l,this._partialTextY=S+c,this._partialText=s,t.fillStrokeShape(this),l+=this.measureSize(s).width+y}}t.restore(),i>1&&(S+=h)}}_hitFunc(t){const e=this.getWidth(),i=this.getHeight();t.beginPath(),t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}setText(e){const i=t.Util._isString(e)?e:null==e?"":e+"";return this._setAttr("text",i),this}getWidth(){return this.attrs.width===a||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}getHeight(){return this.attrs.height===a||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return t.Util.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,r,s,n,o,a,h,l,d,c;let u,g=x(),f=this.fontSize();g.save(),g.font=this._getContextFont(),u=g.measureText(t),g.restore();const p=f/100;return{actualBoundingBoxAscent:null!==(e=u.actualBoundingBoxAscent)&&void 0!==e?e:71.58203125*p,actualBoundingBoxDescent:null!==(i=u.actualBoundingBoxDescent)&&void 0!==i?i:0,actualBoundingBoxLeft:null!==(r=u.actualBoundingBoxLeft)&&void 0!==r?r:-7.421875*p,actualBoundingBoxRight:null!==(s=u.actualBoundingBoxRight)&&void 0!==s?s:75.732421875*p,alphabeticBaseline:null!==(n=u.alphabeticBaseline)&&void 0!==n?n:0,emHeightAscent:null!==(o=u.emHeightAscent)&&void 0!==o?o:100*p,emHeightDescent:null!==(a=u.emHeightDescent)&&void 0!==a?a:-20*p,fontBoundingBoxAscent:null!==(h=u.fontBoundingBoxAscent)&&void 0!==h?h:91*p,fontBoundingBoxDescent:null!==(l=u.fontBoundingBoxDescent)&&void 0!==l?l:21*p,hangingBaseline:null!==(d=u.hangingBaseline)&&void 0!==d?d:72.80000305175781*p,ideographicBaseline:null!==(c=u.ideographicBaseline)&&void 0!==c?c:-21*p,width:u.width,height:f}}_getContextFont(){return this.fontStyle()+p+this.fontVariant()+p+(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()===d&&(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 x().measureText(t).width+e*i}_setTextData(){let t=this.text().split("\n"),e=+this.fontSize(),i=0,r=this.lineHeight()*e,s=this.attrs.width,n=this.attrs.height,h=s!==a&&void 0!==s,l=n!==a&&void 0!==n,d=this.padding(),c=s-2*d,u=n-2*d,g=0,f=this.wrap(),m="char"!==f&&f!==_,y=this.ellipsis();this.textArr=[],x().font=this._getContextFont();const v=y?this._getTextWidth("…"):0;for(let e=0,s=t.length;e<s;++e){let n=t[e],a=this._getTextWidth(n);if(h&&a>c)for(;n.length>0;){let t=0,e=o(n).length,s="",h=0;for(;t<e;){const i=t+e>>>1,a=o(n).slice(0,i+1).join(""),d=this._getTextWidth(a);(y&&l&&g+r>u?d+v:d)<=c?(t=i+1,s=a,h=d):e=i}if(!s)break;if(m){const e=o(n),i=o(s),r=e[i.length];let a;if((r===p||"-"===r)&&h<=c)a=i.length;else{const t=i.lastIndexOf(p),e=i.lastIndexOf("-");a=Math.max(t,e)+1}a>0&&(t=a,s=e.slice(0,t).join(""),h=this._getTextWidth(s))}s=s.trimRight(),this._addTextLine(s),i=Math.max(i,h),g+=r;if(this._shouldHandleEllipsis(g)){this._tryToAddEllipsisToLastLine();break}if(n=o(n).slice(t).join("").trimLeft(),n.length>0&&(a=this._getTextWidth(n),a<=c)){this._addTextLine(n),g+=r,i=Math.max(i,a);break}}else this._addTextLine(n),g+=r,i=Math.max(i,a),this._shouldHandleEllipsis(g)&&e<s-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),l&&g+r>u)break}this.textHeight=e,this.textWidth=i}_shouldHandleEllipsis(t){const e=+this.fontSize(),i=this.lineHeight()*e,r=this.attrs.height,s=r!==a&&void 0!==r,n=r-2*this.padding();return!(this.wrap()!==_)||s&&t+i>n}_tryToAddEllipsisToLastLine(){const t=this.attrs.width,e=t!==a&&void 0!==t,i=t-2*this.padding(),r=this.ellipsis(),s=this.textArr[this.textArr.length-1];if(s&&r){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)||super._useBufferCanvas()}};return Ot.Text=w,w.prototype._fillFunc=function(t){t.fillText(this._partialText,this._partialTextX,this._partialTextY)},w.prototype._strokeFunc=function(t){t.setAttr("miterLimit",2),t.strokeText(this._partialText,this._partialTextX,this._partialTextY)},w.prototype.className="Text",w.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],(0,n._registerNode)(w),e.Factory.overWriteSetter(w,"width",(0,s.getNumberOrAutoValidator)()),e.Factory.overWriteSetter(w,"height",(0,s.getNumberOrAutoValidator)()),e.Factory.addGetterSetter(w,"direction",l),e.Factory.addGetterSetter(w,"fontFamily","Arial"),e.Factory.addGetterSetter(w,"fontSize",12,(0,s.getNumberValidator)()),e.Factory.addGetterSetter(w,"fontStyle",f),e.Factory.addGetterSetter(w,"fontVariant",f),e.Factory.addGetterSetter(w,"padding",0,(0,s.getNumberValidator)()),e.Factory.addGetterSetter(w,"align",u),e.Factory.addGetterSetter(w,"verticalAlign","top"),e.Factory.addGetterSetter(w,"lineHeight",1,(0,s.getNumberValidator)()),e.Factory.addGetterSetter(w,"wrap","word"),e.Factory.addGetterSetter(w,"ellipsis",!1,(0,s.getBooleanValidator)()),e.Factory.addGetterSetter(w,"letterSpacing",0,(0,s.getNumberValidator)()),e.Factory.addGetterSetter(w,"text","",(0,s.getStringValidator)()),e.Factory.addGetterSetter(w,"textDecoration",""),Ot}var Dt,Gt={};var Nt,Wt={};function Ut(){if(Nt)return Wt;Nt=1,Object.defineProperty(Wt,"__esModule",{value:!0}),Wt.Transformer=void 0;const t=c(),e=P(),i=M(),r=z(),s=Ct(),n=Y(),o=h(),a=k(),l=h(),d="tr-konva",u=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map(t=>t+`.${d}`).join(" "),g="nodesRect",f=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],p={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},_="ontouchstart"in o.Konva._global;const m=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function y(t,e,i){const r=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:r,y:s}}function v(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 y(t,e,i)}let x=0,w=class extends n.Group{constructor(t){super(t),this._movingAnchorName=null,this._transforming=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(u,this.update),this.getNode()&&this.update()}attachTo(t){return this.setNode(t),this}setNode(e){return t.Util.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return d+this._id}setNodes(e=[]){this._nodes&&this._nodes.length&&this.detach();const i=e.filter(e=>!e.isAncestorOf(this)||(t.Util.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1));this._nodes=e=i,1===e.length&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(t=>{const e=()=>{1===this.nodes().length&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),this._transforming||this.isDragging()||this.update()};if(t._attrsAffectingSize.length){const i=t._attrsAffectingSize.map(t=>t+"Change."+this._getEventNamespace()).join(" ");t.on(i,e)}t.on(f.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 r=t.getAbsolutePosition(),s=r.x-e.x,n=r.y-e.y;this.nodes().forEach(e=>{if(e===t)return;if(e.isDragging())return;const r=e.getAbsolutePosition();e.setAbsolutePosition({x:r.x+s,y:r.y+n}),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(g),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(g,this.__getNodeRect)}__getNodeShape(t,e=this.rotation(),i){const r=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),s=t.getAbsoluteScale(i),n=t.getAbsolutePosition(i),a=r.x*s.x-t.offsetX()*s.x,h=r.y*s.y-t.offsetY()*s.y,l=(o.Konva.getAngle(t.getAbsoluteRotation())+2*Math.PI)%(2*Math.PI);return y({x:n.x+a*Math.cos(l)+h*Math.sin(-l),y:n.y+h*Math.cos(l)+a*Math.sin(l),width:r.width*s.x,height:r.height*s.y,rotation:l},-o.Konva.getAngle(e),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};const e=[];this.nodes().map(t=>{const i=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),r=[{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=t.getAbsoluteTransform();r.forEach(function(t){const i=s.point(t);e.push(i)})});const i=new t.Transform;i.rotate(-o.Konva.getAngle(this.rotation()));let r=1/0,s=1/0,n=-1/0,a=-1/0;e.forEach(function(t){const e=i.point(t);void 0===r&&(r=n=e.x,s=a=e.y),r=Math.min(r,e.x),s=Math.min(s,e.y),n=Math.max(n,e.x),a=Math.max(a,e.y)}),i.invert();const h=i.point({x:r,y:s});return{x:h.x,y:h.y,width:n-r,height:a-s,rotation:o.Konva.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(),m.forEach(t=>{this._createAnchor(t)}),this._createAnchor("rotater")}_createAnchor(e){const i=new s.Rect({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:_?10:"auto"}),r=this;i.on("mousedown touchstart",function(t){r._handleMouseDown(t)}),i.on("dragstart",t=>{i.stopDrag(),t.cancelBubble=!0}),i.on("dragend",t=>{t.cancelBubble=!0}),i.on("mouseenter",()=>{const r=o.Konva.getAngle(this.rotation()),s=this.rotateAnchorCursor(),n=function(e,i,r){if("rotater"===e)return r;i+=t.Util.degToRad(p[e]||0);const s=(t.Util.radToDeg(i)%360+360)%360;return t.Util._inRange(s,337.5,360)||t.Util._inRange(s,0,22.5)?"ns-resize":t.Util._inRange(s,22.5,67.5)?"nesw-resize":t.Util._inRange(s,67.5,112.5)?"ew-resize":t.Util._inRange(s,112.5,157.5)?"nwse-resize":t.Util._inRange(s,157.5,202.5)?"ns-resize":t.Util._inRange(s,202.5,247.5)?"nesw-resize":t.Util._inRange(s,247.5,292.5)?"ew-resize":t.Util._inRange(s,292.5,337.5)?"nwse-resize":(t.Util.error("Transformer has unknown angle for cursor detection: "+s),"pointer")}(e,r,s);i.getStage().content&&(i.getStage().content.style.cursor=n),this._cursorChange=!0}),i.on("mouseout",()=>{i.getStage().content&&(i.getStage().content.style.cursor=""),this._cursorChange=!1}),this.add(i)}_createBack(){const e=new r.Shape({name:"back",width:0,height:0,draggable:!0,sceneFunc(e,i){const r=i.getParent(),s=r.padding();e.beginPath(),e.rect(-s,-s,i.width()+2*s,i.height()+2*s),e.moveTo(i.width()/2,-s),r.rotateEnabled()&&r.rotateLineVisible()&&e.lineTo(i.width()/2,-r.rotateAnchorOffset()*t.Util._sign(i.height())-s),e.fillStrokeShape(i)},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(e),this._proxyDrag(e),e.on("dragstart",t=>{t.cancelBubble=!0}),e.on("dragmove",t=>{t.cancelBubble=!0}),e.on("dragend",t=>{t.cancelBubble=!0}),this.on("dragmove",t=>{this.update()})}_handleMouseDown(t){if(this._transforming)return;this._movingAnchorName=t.target.name().split(" ")[0];const e=this._getNodeRect(),i=e.width,r=e.height,s=Math.sqrt(Math.pow(i,2)+Math.pow(r,2));this.sin=Math.abs(r/s),this.cos=Math.abs(i/s),"undefined"!=typeof window&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;const n=t.target.getAbsolutePosition(),o=t.target.getStage().getPointerPosition();this._anchorDragOffset={x:o.x-n.x,y:o.y-n.y},x++,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,i,r;const s=this.findOne("."+this._movingAnchorName),n=s.getStage();n.setPointersPositions(t);const a=n.getPointerPosition();let h={x:a.x-this._anchorDragOffset.x,y:a.y-this._anchorDragOffset.y};const l=s.getAbsolutePosition();this.anchorDragBoundFunc()&&(h=this.anchorDragBoundFunc()(l,h,t)),s.setAbsolutePosition(h);const d=s.getAbsolutePosition();if(l.x===d.x&&l.y===d.y)return;if("rotater"===this._movingAnchorName){const r=this._getNodeRect();e=s.x()-r.width/2,i=-s.y()+r.height/2;let n=Math.atan2(-i,e)+Math.PI/2;r.height<0&&(n-=Math.PI);const a=o.Konva.getAngle(this.rotation())+n,h=o.Konva.getAngle(this.rotationSnapTolerance()),l=function(t,e,i){let r=e;for(let s=0;s<t.length;s++){const n=o.Konva.getAngle(t[s]),a=Math.abs(n-e)%(2*Math.PI);Math.min(a,2*Math.PI-a)<i&&(r=n)}return r}(this.rotationSnaps(),a,h),d=v(r,l-r.rotation);return void this._fitNodesInto(d,t)}const c=this.shiftBehavior();let u;u="inverted"===c?this.keepRatio()&&!t.shiftKey:"none"===c?this.keepRatio():this.keepRatio()||t.shiftKey;let g=this.centeredScaling()||t.altKey;if("top-left"===this._movingAnchorName){if(u){const t=g?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};r=Math.sqrt(Math.pow(t.x-s.x(),2)+Math.pow(t.y-s.y(),2));const n=this.findOne(".top-left").x()>t.x?-1:1,o=this.findOne(".top-left").y()>t.y?-1:1;e=r*this.cos*n,i=r*this.sin*o,this.findOne(".top-left").x(t.x-e),this.findOne(".top-left").y(t.y-i)}}else if("top-center"===this._movingAnchorName)this.findOne(".top-left").y(s.y());else if("top-right"===this._movingAnchorName){if(u){const t=g?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};r=Math.sqrt(Math.pow(s.x()-t.x,2)+Math.pow(t.y-s.y(),2));const n=this.findOne(".top-right").x()<t.x?-1:1,o=this.findOne(".top-right").y()>t.y?-1:1;e=r*this.cos*n,i=r*this.sin*o,this.findOne(".top-right").x(t.x+e),this.findOne(".top-right").y(t.y-i)}var f=s.position();this.findOne(".top-left").y(f.y),this.findOne(".bottom-right").x(f.x)}else if("middle-left"===this._movingAnchorName)this.findOne(".top-left").x(s.x());else if("middle-right"===this._movingAnchorName)this.findOne(".bottom-right").x(s.x());else if("bottom-left"===this._movingAnchorName){if(u){const t=g?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};r=Math.sqrt(Math.pow(t.x-s.x(),2)+Math.pow(s.y()-t.y,2));const n=t.x<s.x()?-1:1,o=s.y()<t.y?-1:1;e=r*this.cos*n,i=r*this.sin*o,s.x(t.x-e),s.y(t.y+i)}f=s.position(),this.findOne(".top-left").x(f.x),this.findOne(".bottom-right").y(f.y)}else if("bottom-center"===this._movingAnchorName)this.findOne(".bottom-right").y(s.y());else if("bottom-right"===this._movingAnchorName){if(u){const t=g?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};r=Math.sqrt(Math.pow(s.x()-t.x,2)+Math.pow(s.y()-t.y,2));const n=this.findOne(".bottom-right").x()<t.x?-1:1,o=this.findOne(".bottom-right").y()<t.y?-1:1;e=r*this.cos*n,i=r*this.sin*o,this.findOne(".bottom-right").x(t.x+e),this.findOne(".bottom-right").y(t.y+i)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(g=this.centeredScaling()||t.altKey,g){const t=this.findOne(".top-left"),e=this.findOne(".bottom-right"),i=t.x(),r=t.y(),s=this.getWidth()-e.x(),n=this.getHeight()-e.y();e.move({x:-i,y:-r}),t.move({x:s,y:n})}const p=this.findOne(".top-left").getAbsolutePosition();e=p.x,i=p.y;const _=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),m=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:e,y:i,width:_,height:m,rotation:o.Konva.getAngle(this.rotation())},t)}_handleMouseUp(t){this._removeEvents(t)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(t){var e;if(this._transforming){this._transforming=!1,"undefined"!=typeof window&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));const i=this.getNode();x--,this._fire("transformend",{evt:t,target:i}),null===(e=this.getLayer())||void 0===e||e.batchDraw(),i&&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(e,i){const r=this._getNodeRect();if(t.Util._inRange(e.width,2*-this.padding()-1,1))return void this.update();if(t.Util._inRange(e.height,2*-this.padding()-1,1))return void this.update();const s=new t.Transform;if(s.rotate(o.Konva.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const t=s.point({x:2*-this.padding(),y:0});e.x+=t.x,e.y+=t.y,e.width+=2*this.padding(),this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const t=s.point({x:2*this.padding(),y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.width+=2*this.padding()}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const t=s.point({x:0,y:2*-this.padding()});e.x+=t.x,e.y+=t.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=2*this.padding()}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const t=s.point({x:0,y:2*this.padding()});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=2*this.padding()}if(this.boundBoxFunc()){const i=this.boundBoxFunc()(r,e);i?e=i:t.Util.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const n=1e7,a=new t.Transform;a.translate(r.x,r.y),a.rotate(r.rotation),a.scale(r.width/n,r.height/n);const h=new t.Transform,l=e.width/n,d=e.height/n;!1===this.flipEnabled()?(h.translate(e.x,e.y),h.rotate(e.rotation),h.translate(e.width<0?e.width:0,e.height<0?e.height:0),h.scale(Math.abs(l),Math.abs(d))):(h.translate(e.x,e.y),h.rotate(e.rotation),h.scale(l,d));const c=h.multiply(a.invert());this._nodes.forEach(e=>{var i;const r=e.getParent().getAbsoluteTransform(),s=e.getTransform().copy();s.translate(e.offsetX(),e.offsetY());const n=new t.Transform;n.multiply(r.copy().invert()).multiply(c).multiply(r).multiply(s);const o=n.decompose();e.setAttrs(o),null===(i=e.getLayer())||void 0===i||i.batchDraw()}),this.rotation(t.Util._getRotation(e.rotation)),this._nodes.forEach(t=>{this._fire("transform",{evt:i,target:t}),t._fire("transform",{evt:i,target:t})}),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(t,e){this.findOne(t).setAttrs(e)}update(){var e;const i=this._getNodeRect();this.rotation(t.Util._getRotation(i.rotation));const r=i.width,s=i.height,n=this.enabledAnchors(),o=this.resizeEnabled(),a=this.padding(),h=this.anchorSize(),l=this.find("._anchor");l.forEach(t=>{t.setAttrs({width:h,height:h,offsetX:h/2,offsetY:h/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:h/2+a,offsetY:h/2+a,visible:o&&n.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:r/2,y:0,offsetY:h/2+a,visible:o&&n.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:r,y:0,offsetX:h/2-a,offsetY:h/2+a,visible:o&&n.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:s/2,offsetX:h/2+a,visible:o&&n.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:r,y:s/2,offsetX:h/2-a,visible:o&&n.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:s,offsetX:h/2+a,offsetY:h/2-a,visible:o&&n.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:r/2,y:s,offsetY:h/2-a,visible:o&&n.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:r,y:s,offsetX:h/2-a,offsetY:h/2-a,visible:o&&n.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:r/2,y:-this.rotateAnchorOffset()*t.Util._sign(s)-a,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:r,height:s,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0});const d=this.anchorStyleFunc();d&&l.forEach(t=>{d(t)}),null===(e=this.getLayer())||void 0===e||e.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=""),n.Group.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return i.Node.prototype.toObject.call(this)}clone(t){return i.Node.prototype.clone.call(this,t)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}};return Wt.Transformer=w,w.isTransforming=()=>x>0,w.prototype.className="Transformer",(0,l._registerNode)(w),e.Factory.addGetterSetter(w,"enabledAnchors",m,function(e){return e instanceof Array||t.Util.warn("enabledAnchors value should be an array"),e instanceof Array&&e.forEach(function(e){-1===m.indexOf(e)&&t.Util.warn("Unknown anchor name: "+e+". Available names are: "+m.join(", "))}),e||[]}),e.Factory.addGetterSetter(w,"flipEnabled",!0,(0,a.getBooleanValidator)()),e.Factory.addGetterSetter(w,"resizeEnabled",!0),e.Factory.addGetterSetter(w,"anchorSize",10,(0,a.getNumberValidator)()),e.Factory.addGetterSetter(w,"rotateEnabled",!0),e.Factory.addGetterSetter(w,"rotateLineVisible",!0),e.Factory.addGetterSetter(w,"rotationSnaps",[]),e.Factory.addGetterSetter(w,"rotateAnchorOffset",50,(0,a.getNumberValidator)()),e.Factory.addGetterSetter(w,"rotateAnchorCursor","crosshair"),e.Factory.addGetterSetter(w,"rotationSnapTolerance",5,(0,a.getNumberValidator)()),e.Factory.addGetterSetter(w,"borderEnabled",!0),e.Factory.addGetterSetter(w,"anchorStroke","rgb(0, 161, 255)"),e.Factory.addGetterSetter(w,"anchorStrokeWidth",1,(0,a.getNumberValidator)()),e.Factory.addGetterSetter(w,"anchorFill","white"),e.Factory.addGetterSetter(w,"anchorCornerRadius",0,(0,a.getNumberValidator)()),e.Factory.addGetterSetter(w,"borderStroke","rgb(0, 161, 255)"),e.Factory.addGetterSetter(w,"borderStrokeWidth",1,(0,a.getNumberValidator)()),e.Factory.addGetterSetter(w,"borderDash"),e.Factory.addGetterSetter(w,"keepRatio",!0),e.Factory.addGetterSetter(w,"shiftBehavior","default"),e.Factory.addGetterSetter(w,"centeredScaling",!1),e.Factory.addGetterSetter(w,"ignoreStroke",!1),e.Factory.addGetterSetter(w,"padding",0,(0,a.getNumberValidator)()),e.Factory.addGetterSetter(w,"nodes"),e.Factory.addGetterSetter(w,"node"),e.Factory.addGetterSetter(w,"boundBoxFunc"),e.Factory.addGetterSetter(w,"anchorDragBoundFunc"),e.Factory.addGetterSetter(w,"anchorStyleFunc"),e.Factory.addGetterSetter(w,"shouldOverdrawWholeArea",!1),e.Factory.addGetterSetter(w,"useSingleNodeRotation",!0),e.Factory.backCompat(w,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"}),Wt}var Bt,zt={};var Ht,Vt={};function jt(){if(Ht)return Vt;Ht=1,Object.defineProperty(Vt,"__esModule",{value:!0}),Vt.Blur=void 0;const t=P(),e=M(),i=k();function r(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}const s=[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],n=[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];return Vt.Blur=function(t){const e=Math.round(this.blurRadius());e>0&&function(t,e){const i=t.data,o=t.width,a=t.height;let h,l,d,c,u,g,f,p,_,m,y,v,x,w,b,S,C,T,A,k;const P=e+e+1,M=o-1,R=a-1,E=e+1,F=E*(E+1)/2,I=new r,O=s[e],L=n[e];let D=null,G=I,N=null,W=null;for(let t=1;t<P;t++)G=G.next=new r,t===E&&(D=G);G.next=I,d=l=0;for(let t=0;t<a;t++){v=x=w=b=c=u=g=f=0,p=E*(S=i[l]),_=E*(C=i[l+1]),m=E*(T=i[l+2]),y=E*(A=i[l+3]),c+=F*S,u+=F*C,g+=F*T,f+=F*A,G=I;for(let t=0;t<E;t++)G.r=S,G.g=C,G.b=T,G.a=A,G=G.next;for(let t=1;t<E;t++)h=l+((M<t?M:t)<<2),c+=(G.r=S=i[h])*(k=E-t),u+=(G.g=C=i[h+1])*k,g+=(G.b=T=i[h+2])*k,f+=(G.a=A=i[h+3])*k,v+=S,x+=C,w+=T,b+=A,G=G.next;N=I,W=D;for(let t=0;t<o;t++)i[l+3]=A=f*O>>L,0!==A?(A=255/A,i[l]=(c*O>>L)*A,i[l+1]=(u*O>>L)*A,i[l+2]=(g*O>>L)*A):i[l]=i[l+1]=i[l+2]=0,c-=p,u-=_,g-=m,f-=y,p-=N.r,_-=N.g,m-=N.b,y-=N.a,h=d+((h=t+e+1)<M?h:M)<<2,v+=N.r=i[h],x+=N.g=i[h+1],w+=N.b=i[h+2],b+=N.a=i[h+3],c+=v,u+=x,g+=w,f+=b,N=N.next,p+=S=W.r,_+=C=W.g,m+=T=W.b,y+=A=W.a,v-=S,x-=C,w-=T,b-=A,W=W.next,l+=4;d+=o}for(let t=0;t<o;t++){x=w=b=v=u=g=f=c=0,l=t<<2,p=E*(S=i[l]),_=E*(C=i[l+1]),m=E*(T=i[l+2]),y=E*(A=i[l+3]),c+=F*S,u+=F*C,g+=F*T,f+=F*A,G=I;for(let t=0;t<E;t++)G.r=S,G.g=C,G.b=T,G.a=A,G=G.next;let r=o;for(let s=1;s<=e;s++)l=r+t<<2,c+=(G.r=S=i[l])*(k=E-s),u+=(G.g=C=i[l+1])*k,g+=(G.b=T=i[l+2])*k,f+=(G.a=A=i[l+3])*k,v+=S,x+=C,w+=T,b+=A,G=G.next,s<R&&(r+=o);l=t,N=I,W=D;for(let e=0;e<a;e++)h=l<<2,i[h+3]=A=f*O>>L,A>0?(A=255/A,i[h]=(c*O>>L)*A,i[h+1]=(u*O>>L)*A,i[h+2]=(g*O>>L)*A):i[h]=i[h+1]=i[h+2]=0,c-=p,u-=_,g-=m,f-=y,p-=N.r,_-=N.g,m-=N.b,y-=N.a,h=t+((h=e+E)<R?h:R)*o<<2,c+=v+=N.r=i[h],u+=x+=N.g=i[h+1],g+=w+=N.b=i[h+2],f+=b+=N.a=i[h+3],N=N.next,p+=S=W.r,_+=C=W.g,m+=T=W.b,y+=A=W.a,v-=S,x-=C,w-=T,b-=A,W=W.next,l+=o}}(t,e)},t.Factory.addGetterSetter(e.Node,"blurRadius",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),Vt}var Kt,Xt={};var Yt,qt={};var Qt,Jt={};var Zt,$t={};var te,ee={};var ie,re={};var se,ne={};var oe,ae={};var he,le={};function de(){if(he)return le;he=1,Object.defineProperty(le,"__esModule",{value:!0}),le.Kaleidoscope=void 0;const t=P(),e=M(),i=c(),r=k();return le.Kaleidoscope=function(t){const e=t.width,r=t.height;let s,n,o,a,h,l,d,c,u,g,f=Math.round(this.kaleidoscopePower());const p=Math.round(this.kaleidoscopeAngle()),_=Math.floor(e*(p%360)/360);if(f<1)return;const m=i.Util.createCanvasElement();m.width=e,m.height=r;const y=m.getContext("2d").getImageData(0,0,e,r);i.Util.releaseCanvas(m),function(t,e,i){const r=t.data,s=e.data,n=t.width,o=t.height,a=i.polarCenterX||n/2,h=i.polarCenterY||o/2;let l=Math.sqrt(a*a+h*h),d=n-a,c=o-h;const u=Math.sqrt(d*d+c*c);l=u>l?u:l;const g=o,f=n,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 o=0;o<g;o+=1){d=Math.floor(a+l*o/g*i),c=Math.floor(h+l*o/g*e);let u=4*(c*n+d);const f=r[u+0],p=r[u+1],_=r[u+2],m=r[u+3];u=4*(t+o*n),s[u+0]=f,s[u+1]=p,s[u+2]=_,s[u+3]=m}}}(t,y,{polarCenterX:e/2,polarCenterY:r/2});let v=e/Math.pow(2,f);for(;v<=8;)v*=2,f-=1;v=Math.ceil(v);let x=v,w=0,b=x,S=1;for(_+v>e&&(w=x,b=0,S=-1),n=0;n<r;n+=1)for(s=w;s!==b;s+=S)o=Math.round(s+_)%e,u=4*(e*n+o),h=y.data[u+0],l=y.data[u+1],d=y.data[u+2],c=y.data[u+3],g=4*(e*n+s),y.data[g+0]=h,y.data[g+1]=l,y.data[g+2]=d,y.data[g+3]=c;for(n=0;n<r;n+=1)for(x=Math.floor(v),a=0;a<f;a+=1){for(s=0;s<x+1;s+=1)u=4*(e*n+s),h=y.data[u+0],l=y.data[u+1],d=y.data[u+2],c=y.data[u+3],g=4*(e*n+2*x-s-1),y.data[g+0]=h,y.data[g+1]=l,y.data[g+2]=d,y.data[g+3]=c;x*=2}!function(t,e,i){const r=t.data,s=e.data,n=t.width,o=t.height,a=i.polarCenterX||n/2,h=i.polarCenterY||o/2;let l=Math.sqrt(a*a+h*h),d=n-a,c=o-h;const u=Math.sqrt(d*d+c*c);l=u>l?u:l;const g=o,f=n;let p,_;for(d=0;d<n;d+=1)for(c=0;c<o;c+=1){const t=d-a,e=c-h,i=Math.sqrt(t*t+e*e)*g/l;let o=(180*Math.atan2(e,t)/Math.PI+360+0)%360;o=o*f/360,p=Math.floor(o),_=Math.floor(i);let u=4*(_*n+p);const m=r[u+0],y=r[u+1],v=r[u+2],x=r[u+3];u=4*(c*n+d),s[u+0]=m,s[u+1]=y,s[u+2]=v,s[u+3]=x}}(y,t,{})},t.Factory.addGetterSetter(e.Node,"kaleidoscopePower",2,(0,r.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"kaleidoscopeAngle",0,(0,r.getNumberValidator)(),t.Factory.afterSetFilter),le}var ce,ue={};function ge(){if(ce)return ue;ce=1,Object.defineProperty(ue,"__esModule",{value:!0}),ue.Mask=void 0;const t=P(),e=M(),i=k();function r(t,e,i){let r=4*(i*t.width+e);const s=[];return s.push(t.data[r++],t.data[r++],t.data[r++],t.data[r++]),s}function s(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))}return ue.Mask=function(t){let e=function(t,e){const i=r(t,0,0),n=r(t,t.width-1,0),o=r(t,0,t.height-1),a=r(t,t.width-1,t.height-1),h=e||10;if(s(i,n)<h&&s(n,a)<h&&s(a,o)<h&&s(o,i)<h){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,a,o]),r=[];for(let i=0;i<t.width*t.height;i++){const n=s(e,[t.data[4*i],t.data[4*i+1],t.data[4*i+2]]);r[i]=n<h?0:255}return r}}(t,this.threshold());return e&&(e=function(t,e,i){const r=[1,1,1,1,0,1,1,1,1],s=Math.round(Math.sqrt(r.length)),n=Math.floor(s/2),o=[];for(let a=0;a<i;a++)for(let h=0;h<e;h++){const l=a*e+h;let d=0;for(let o=0;o<s;o++)for(let l=0;l<s;l++){const c=a+o-n,u=h+l-n;if(c>=0&&c<i&&u>=0&&u<e){const i=r[o*s+l];d+=t[c*e+u]*i}}o[l]=2040===d?255:0}return o}(e,t.width,t.height),e=function(t,e,i){const r=[1,1,1,1,1,1,1,1,1],s=Math.round(Math.sqrt(r.length)),n=Math.floor(s/2),o=[];for(let a=0;a<i;a++)for(let h=0;h<e;h++){const l=a*e+h;let d=0;for(let o=0;o<s;o++)for(let l=0;l<s;l++){const c=a+o-n,u=h+l-n;if(c>=0&&c<i&&u>=0&&u<e){const i=r[o*s+l];d+=t[c*e+u]*i}}o[l]=d>=1020?255:0}return o}(e,t.width,t.height),e=function(t,e,i){const r=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],s=Math.round(Math.sqrt(r.length)),n=Math.floor(s/2),o=[];for(let a=0;a<i;a++)for(let h=0;h<e;h++){const l=a*e+h;let d=0;for(let o=0;o<s;o++)for(let l=0;l<s;l++){const c=a+o-n,u=h+l-n;if(c>=0&&c<i&&u>=0&&u<e){const i=r[o*s+l];d+=t[c*e+u]*i}}o[l]=d}return o}(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},t.Factory.addGetterSetter(e.Node,"threshold",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),ue}var fe,pe={};var _e,me={};var ye,ve={};var xe,we={};var be,Se={};var Ce,Te={};var Ae,ke={};var Pe,Me,Re={};function Ee(){if(Me)return n;Me=1,Object.defineProperty(n,"__esModule",{value:!0}),n.Konva=void 0;const t=et(),e=function(){if(it)return rt;it=1,Object.defineProperty(rt,"__esModule",{value:!0}),rt.Arc=void 0;const t=P(),e=z(),i=h(),r=k(),s=h();let n=class extends e.Shape{_sceneFunc(t){const e=i.Konva.getAngle(this.angle()),r=this.clockwise();t.beginPath(),t.arc(0,0,this.outerRadius(),0,e,r),t.arc(0,0,this.innerRadius(),e,0,!r),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(),r=this.clockwise(),s=i.Konva.getAngle(r?360-this.angle():this.angle()),n=Math.cos(Math.min(s,Math.PI)),o=Math.sin(Math.min(Math.max(Math.PI,s),3*Math.PI/2)),a=Math.sin(Math.min(s,Math.PI/2)),h=n*(n>0?t:e),l=o*(o>0?t:e),d=a*(a>0?e:t);return{x:h,y:r?-1*d:l,width:1*e-h,height:d-l}}};return rt.Arc=n,n.prototype._centroid=!0,n.prototype.className="Arc",n.prototype._attrsAffectingSize=["innerRadius","outerRadius","angle","clockwise"],(0,s._registerNode)(n),t.Factory.addGetterSetter(n,"innerRadius",0,(0,r.getNumberValidator)()),t.Factory.addGetterSetter(n,"outerRadius",0,(0,r.getNumberValidator)()),t.Factory.addGetterSetter(n,"angle",0,(0,r.getNumberValidator)()),t.Factory.addGetterSetter(n,"clockwise",!1,(0,r.getBooleanValidator)()),rt}(),i=function(){if(dt)return nt;dt=1,Object.defineProperty(nt,"__esModule",{value:!0}),nt.Arrow=void 0;const t=P(),e=at(),i=k(),r=h(),s=gt();let n=class extends e.Line{_sceneFunc(t){super._sceneFunc(t);const e=2*Math.PI,i=this.points();let r=i;const n=0!==this.tension()&&i.length>4;n&&(r=this.getTensionPoints());const o=this.pointerLength(),a=i.length;let h,l;if(n){const t=[r[r.length-4],r[r.length-3],r[r.length-2],r[r.length-1],i[a-2],i[a-1]],e=s.Path.calcLength(r[r.length-4],r[r.length-3],"C",t),n=s.Path.getPointOnQuadraticBezier(Math.min(1,1-o/e),t[0],t[1],t[2],t[3],t[4],t[5]);h=i[a-2]-n.x,l=i[a-1]-n.y}else h=i[a-2]-i[a-4],l=i[a-1]-i[a-3];const d=(Math.atan2(l,h)+e)%e,c=this.pointerWidth();this.pointerAtEnding()&&(t.save(),t.beginPath(),t.translate(i[a-2],i[a-1]),t.rotate(d),t.moveTo(0,0),t.lineTo(-o,c/2),t.lineTo(-o,-c/2),t.closePath(),t.restore(),this.__fillStroke(t)),this.pointerAtBeginning()&&(t.save(),t.beginPath(),t.translate(i[0],i[1]),n?(h=(r[0]+r[2])/2-i[0],l=(r[1]+r[3])/2-i[1]):(h=i[2]-i[0],l=i[3]-i[1]),t.rotate((Math.atan2(-l,-h)+e)%e),t.moveTo(0,0),t.lineTo(-o,c/2),t.lineTo(-o,-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}}};return nt.Arrow=n,n.prototype.className="Arrow",(0,r._registerNode)(n),t.Factory.addGetterSetter(n,"pointerLength",10,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(n,"pointerWidth",10,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(n,"pointerAtBeginning",!1),t.Factory.addGetterSetter(n,"pointerAtEnding",!0),nt}(),r=function(){if(ft)return pt;ft=1,Object.defineProperty(pt,"__esModule",{value:!0}),pt.Circle=void 0;const t=P(),e=z(),i=k(),r=h();let s=class extends e.Shape{_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)}};return pt.Circle=s,s.prototype._centroid=!0,s.prototype.className="Circle",s.prototype._attrsAffectingSize=["radius"],(0,r._registerNode)(s),t.Factory.addGetterSetter(s,"radius",0,(0,i.getNumberValidator)()),pt}(),s=function(){if(_t)return mt;_t=1,Object.defineProperty(mt,"__esModule",{value:!0}),mt.Ellipse=void 0;const t=P(),e=z(),i=k(),r=h();let s=class extends e.Shape{_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)}};return mt.Ellipse=s,s.prototype.className="Ellipse",s.prototype._centroid=!0,s.prototype._attrsAffectingSize=["radiusX","radiusY"],(0,r._registerNode)(s),t.Factory.addComponentsGetterSetter(s,"radius",["x","y"]),t.Factory.addGetterSetter(s,"radiusX",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"radiusY",0,(0,i.getNumberValidator)()),mt}(),o=function(){if(yt)return vt;yt=1,Object.defineProperty(vt,"__esModule",{value:!0}),vt.Image=void 0;const t=c(),e=P(),i=z(),r=h(),s=k();class n extends i.Shape{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(e){const i=this.getWidth(),r=this.getHeight(),s=this.cornerRadius(),n=this.attrs.image;let o;if(n){const t=this.attrs.cropWidth,e=this.attrs.cropHeight;o=t&&e?[n,this.cropX(),this.cropY(),t,e,0,0,i,r]:[n,0,0,i,r]}(this.hasFill()||this.hasStroke()||s)&&(e.beginPath(),s?t.Util.drawRoundedRectPath(e,i,r,s):e.rect(0,0,i,r),e.closePath(),e.fillStrokeShape(this)),n&&(s&&e.clip(),e.drawImage.apply(e,o))}_hitFunc(e){const i=this.width(),r=this.height(),s=this.cornerRadius();e.beginPath(),s?t.Util.drawRoundedRectPath(e,i,r,s):e.rect(0,0,i,r),e.closePath(),e.fillStrokeShape(this)}getWidth(){var t,e;return null!==(t=this.attrs.width)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.width}getHeight(){var t,e;return null!==(t=this.attrs.height)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.height}static fromURL(e,i,r=null){const s=t.Util.createImageElement();s.onload=function(){const t=new n({image:s});i(t)},s.onerror=r,s.crossOrigin="Anonymous",s.src=e}}return vt.Image=n,n.prototype.className="Image",(0,r._registerNode)(n),e.Factory.addGetterSetter(n,"cornerRadius",0,(0,s.getNumberOrArrayOfNumbersValidator)(4)),e.Factory.addGetterSetter(n,"image"),e.Factory.addComponentsGetterSetter(n,"crop",["x","y","width","height"]),e.Factory.addGetterSetter(n,"cropX",0,(0,s.getNumberValidator)()),e.Factory.addGetterSetter(n,"cropY",0,(0,s.getNumberValidator)()),e.Factory.addGetterSetter(n,"cropWidth",0,(0,s.getNumberValidator)()),e.Factory.addGetterSetter(n,"cropHeight",0,(0,s.getNumberValidator)()),vt}(),a=function(){if(xt)return wt;xt=1,Object.defineProperty(wt,"__esModule",{value:!0}),wt.Tag=wt.Label=void 0;const t=P(),e=z(),i=Y(),r=k(),s=h(),n=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],o="up",a="right",l="down",d="left",c=n.length;let u=class extends i.Group{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 r=function(){i._sync()};for(e=0;e<c;e++)t.on(n[e]+"Change.konva",r)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let t,e,i,r,s,n,h,c=this.getText(),u=this.getTag();if(c&&u){switch(t=c.width(),e=c.height(),i=u.pointerDirection(),r=u.pointerWidth(),h=u.pointerHeight(),s=0,n=0,i){case o:s=t/2,n=-1*h;break;case a:s=t+r,n=e/2;break;case l:s=t/2,n=e+h;break;case d:s=-1*r,n=e/2}u.setAttrs({x:-1*s,y:-1*n,width:t,height:e}),c.setAttrs({x:-1*s,y:-1*n})}}};wt.Label=u,u.prototype.className="Label",(0,s._registerNode)(u);class g extends e.Shape{_sceneFunc(t){const e=this.width(),i=this.height(),r=this.pointerDirection(),s=this.pointerWidth(),n=this.pointerHeight(),h=this.cornerRadius();let c=0,u=0,g=0,f=0;"number"==typeof h?c=u=g=f=Math.min(h,e/2,i/2):(c=Math.min(h[0]||0,e/2,i/2),u=Math.min(h[1]||0,e/2,i/2),f=Math.min(h[2]||0,e/2,i/2),g=Math.min(h[3]||0,e/2,i/2)),t.beginPath(),t.moveTo(c,0),r===o&&(t.lineTo((e-s)/2,0),t.lineTo(e/2,-1*n),t.lineTo((e+s)/2,0)),t.lineTo(e-u,0),t.arc(e-u,u,u,3*Math.PI/2,0,!1),r===a&&(t.lineTo(e,(i-n)/2),t.lineTo(e+s,i/2),t.lineTo(e,(i+n)/2)),t.lineTo(e,i-f),t.arc(e-f,i-f,f,0,Math.PI/2,!1),r===l&&(t.lineTo((e+s)/2,i),t.lineTo(e/2,i+n),t.lineTo((e-s)/2,i)),t.lineTo(g,i),t.arc(g,i-g,g,Math.PI/2,Math.PI,!1),r===d&&(t.lineTo(0,(i+n)/2),t.lineTo(-1*s,i/2),t.lineTo(0,(i-n)/2)),t.lineTo(0,c),t.arc(c,c,c,Math.PI,3*Math.PI/2,!1),t.closePath(),t.fillStrokeShape(this)}getSelfRect(){let t=0,e=0,i=this.pointerWidth(),r=this.pointerHeight(),s=this.pointerDirection(),n=this.width(),h=this.height();return s===o?(e-=r,h+=r):s===l?h+=r:s===d?(t-=1.5*i,n+=i):s===a&&(n+=1.5*i),{x:t,y:e,width:n,height:h}}}return wt.Tag=g,g.prototype.className="Tag",(0,s._registerNode)(g),t.Factory.addGetterSetter(g,"pointerDirection","none"),t.Factory.addGetterSetter(g,"pointerWidth",0,(0,r.getNumberValidator)()),t.Factory.addGetterSetter(g,"pointerHeight",0,(0,r.getNumberValidator)()),t.Factory.addGetterSetter(g,"cornerRadius",0,(0,r.getNumberOrArrayOfNumbersValidator)(4)),wt}(),l=at(),d=gt(),u=Ct(),g=function(){if(Tt)return At;Tt=1,Object.defineProperty(At,"__esModule",{value:!0}),At.RegularPolygon=void 0;const t=P(),e=z(),i=k(),r=h();let s=class extends e.Shape{_sceneFunc(t){const e=this._getPoints();t.beginPath(),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 r=0;r<t;r++)i.push({x:e*Math.sin(2*r*Math.PI/t),y:-1*e*Math.cos(2*r*Math.PI/t)});return i}getSelfRect(){const t=this._getPoints();let e=t[0].x,i=t[0].y,r=t[0].x,s=t[0].y;return t.forEach(t=>{e=Math.min(e,t.x),i=Math.max(i,t.x),r=Math.min(r,t.y),s=Math.max(s,t.y)}),{x:e,y:r,width:i-e,height:s-r}}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}};return At.RegularPolygon=s,s.prototype.className="RegularPolygon",s.prototype._centroid=!0,s.prototype._attrsAffectingSize=["radius"],(0,r._registerNode)(s),t.Factory.addGetterSetter(s,"radius",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"sides",0,(0,i.getNumberValidator)()),At}(),f=function(){if(kt)return Pt;kt=1,Object.defineProperty(Pt,"__esModule",{value:!0}),Pt.Ring=void 0;const t=P(),e=z(),i=k(),r=h(),s=2*Math.PI;let n=class extends e.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.innerRadius(),0,s,!1),t.moveTo(this.outerRadius(),0),t.arc(0,0,this.outerRadius(),s,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)}};return Pt.Ring=n,n.prototype.className="Ring",n.prototype._centroid=!0,n.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,r._registerNode)(n),t.Factory.addGetterSetter(n,"innerRadius",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(n,"outerRadius",0,(0,i.getNumberValidator)()),Pt}(),p=function(){if(Mt)return Rt;Mt=1,Object.defineProperty(Rt,"__esModule",{value:!0}),Rt.Sprite=void 0;const t=P(),e=z(),i=J(),r=k(),s=h();let n=class extends e.Shape{constructor(t){super(t),this._updated=!0,this.anim=new i.Animation(()=>{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(),r=4*i,s=this.animations()[e],n=this.frameOffsets(),o=s[r+0],a=s[r+1],h=s[r+2],l=s[r+3],d=this.image();if((this.hasFill()||this.hasStroke())&&(t.beginPath(),t.rect(0,0,h,l),t.closePath(),t.fillStrokeShape(this)),d)if(n){const r=n[e],s=2*i;t.drawImage(d,o,a,h,l,r[s+0],r[s+1],h,l)}else t.drawImage(d,o,a,h,l,0,0,h,l)}_hitFunc(t){const e=this.animation(),i=this.frameIndex(),r=4*i,s=this.animations()[e],n=this.frameOffsets(),o=s[r+2],a=s[r+3];if(t.beginPath(),n){const r=n[e],s=2*i;t.rect(r[s+0],r[s+1],o,a)}else t.rect(0,0,o,a);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)}};return Rt.Sprite=n,n.prototype.className="Sprite",(0,s._registerNode)(n),t.Factory.addGetterSetter(n,"animation"),t.Factory.addGetterSetter(n,"animations"),t.Factory.addGetterSetter(n,"frameOffsets"),t.Factory.addGetterSetter(n,"image"),t.Factory.addGetterSetter(n,"frameIndex",0,(0,r.getNumberValidator)()),t.Factory.addGetterSetter(n,"frameRate",17,(0,r.getNumberValidator)()),t.Factory.backCompat(n,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"}),Rt}(),_=function(){if(Et)return Ft;Et=1,Object.defineProperty(Ft,"__esModule",{value:!0}),Ft.Star=void 0;const t=P(),e=z(),i=k(),r=h();let s=class extends e.Shape{_sceneFunc(t){const e=this.innerRadius(),i=this.outerRadius(),r=this.numPoints();t.beginPath(),t.moveTo(0,0-i);for(let s=1;s<2*r;s++){const n=s%2==0?i:e,o=n*Math.sin(s*Math.PI/r),a=-1*n*Math.cos(s*Math.PI/r);t.lineTo(o,a)}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)}};return Ft.Star=s,s.prototype.className="Star",s.prototype._centroid=!0,s.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,r._registerNode)(s),t.Factory.addGetterSetter(s,"numPoints",5,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"innerRadius",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"outerRadius",0,(0,i.getNumberValidator)()),Ft}(),m=Lt(),y=function(){if(Dt)return Gt;Dt=1,Object.defineProperty(Gt,"__esModule",{value:!0}),Gt.TextPath=void 0;const t=c(),e=P(),i=z(),r=gt(),s=Lt(),n=k(),o=h(),a="normal";function l(t){t.fillText(this.partialText,0,0)}function d(t){t.strokeText(this.partialText,0,0)}let u=class extends i.Shape{constructor(e){super(e),this.dummyCanvas=t.Util.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",this._setTextData),this._setTextData()}_getTextPathLength(){return r.Path.getPathLength(this.dataArray)}_getPointAtLength(t){return this.attrs.data?t-1>this.pathLength?null:r.Path.getPointAtLengthOfDataArray(t,this.dataArray):null}_readDataAttribute(){this.dataArray=r.Path.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(),r=this.fontSize(),s=this.glyphInfo;"underline"===e&&t.beginPath();for(let i=0;i<s.length;i++){t.save();const n=s[i].p0;t.translate(n.x,n.y),t.rotate(s[i].rotation),this.partialText=s[i].text,t.fillStrokeShape(this),"underline"===e&&(0===i&&t.moveTo(0,r/2+1),t.lineTo(r,r/2+1)),t.restore()}"underline"===e&&(t.strokeStyle=i,t.lineWidth=r/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 r=e[i].p1;t.lineTo(r.x,r.y)}t.setAttr("lineWidth",this.fontSize()),t.setAttr("strokeStyle",this.colorKey),t.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return t.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(t){return s.Text.prototype.setText.call(this,t)}_getContextFont(){return s.Text.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{width:t,height:e}=this._getTextSize(this.attrs.text);if(this.textWidth=t,this.textHeight=e,this.glyphInfo=[],!this.attrs.data)return null;const i=this.letterSpacing(),n=this.align(),o=this.kerningFunc(),a=Math.max(this.textWidth+((this.attrs.text||"").length-1)*i,0);let h=0;"center"===n&&(h=Math.max(0,this.pathLength/2-a/2)),"right"===n&&(h=Math.max(0,this.pathLength-a));const l=(0,s.stringToArray)(this.text());let d=h;for(let t=0;t<l.length;t++){const e=this._getPointAtLength(d);if(!e)return;let s=this._getTextSize(l[t]).width+i;if(" "===l[t]&&"justify"===n){const t=this.text().split(" ").length-1;s+=(this.pathLength-a)/t}const h=this._getPointAtLength(d+s);if(!h)return;const c=r.Path.getLineLength(e.x,e.y,h.x,h.y);let u=0;if(o)try{u=o(l[t-1],l[t])*this.fontSize()}catch(t){u=0}e.x+=u,h.x+=u,this.textWidth+=u;const g=r.Path.getPointOnLine(u+c/2,e.x,e.y,h.x,h.y),f=Math.atan2(h.y-e.y,h.x-e.x);this.glyphInfo.push({transposeX:g.x,transposeY:g.y,text:l[t],rotation:f,p0:e,p1:h}),d+=s}}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,r=t[0]||0,s=t[0]||0,n=t[1]||0,o=t[1]||0;for(let a=0;a<t.length/2;a++)e=t[2*a],i=t[2*a+1],r=Math.min(r,e),s=Math.max(s,e),n=Math.min(n,i),o=Math.max(o,i);const a=this.fontSize();return{x:r-a/2,y:n-a/2,width:s-r+a,height:o-n+a}}destroy(){return t.Util.releaseCanvas(this.dummyCanvas),super.destroy()}};return Gt.TextPath=u,u.prototype._fillFunc=l,u.prototype._strokeFunc=d,u.prototype._fillFuncHit=l,u.prototype._strokeFuncHit=d,u.prototype.className="TextPath",u.prototype._attrsAffectingSize=["text","fontSize","data"],(0,o._registerNode)(u),e.Factory.addGetterSetter(u,"data"),e.Factory.addGetterSetter(u,"fontFamily","Arial"),e.Factory.addGetterSetter(u,"fontSize",12,(0,n.getNumberValidator)()),e.Factory.addGetterSetter(u,"fontStyle",a),e.Factory.addGetterSetter(u,"align","left"),e.Factory.addGetterSetter(u,"letterSpacing",0,(0,n.getNumberValidator)()),e.Factory.addGetterSetter(u,"textBaseline","middle"),e.Factory.addGetterSetter(u,"fontVariant",a),e.Factory.addGetterSetter(u,"text",""),e.Factory.addGetterSetter(u,"textDecoration",""),e.Factory.addGetterSetter(u,"kerningFunc",void 0),Gt}(),v=Ut(),x=function(){if(Bt)return zt;Bt=1,Object.defineProperty(zt,"__esModule",{value:!0}),zt.Wedge=void 0;const t=P(),e=z(),i=h(),r=k(),s=h();let n=class extends e.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.radius(),0,i.Konva.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)}};return zt.Wedge=n,n.prototype.className="Wedge",n.prototype._centroid=!0,n.prototype._attrsAffectingSize=["radius"],(0,s._registerNode)(n),t.Factory.addGetterSetter(n,"radius",0,(0,r.getNumberValidator)()),t.Factory.addGetterSetter(n,"angle",0,(0,r.getNumberValidator)()),t.Factory.addGetterSetter(n,"clockwise",!1),t.Factory.backCompat(n,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"}),zt}(),w=jt(),b=function(){if(Kt)return Xt;Kt=1,Object.defineProperty(Xt,"__esModule",{value:!0}),Xt.Brighten=void 0;const t=P(),e=M(),i=k();return Xt.Brighten=function(t){const e=255*this.brightness(),i=t.data,r=i.length;for(let t=0;t<r;t+=4)i[t]+=e,i[t+1]+=e,i[t+2]+=e},t.Factory.addGetterSetter(e.Node,"brightness",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),Xt}(),S=function(){if(Yt)return qt;Yt=1,Object.defineProperty(qt,"__esModule",{value:!0}),qt.Contrast=void 0;const t=P(),e=M(),i=k();return qt.Contrast=function(t){const e=Math.pow((this.contrast()+100)/100,2),i=t.data,r=i.length;let s=150,n=150,o=150;for(let t=0;t<r;t+=4)s=i[t],n=i[t+1],o=i[t+2],s/=255,s-=.5,s*=e,s+=.5,s*=255,n/=255,n-=.5,n*=e,n+=.5,n*=255,o/=255,o-=.5,o*=e,o+=.5,o*=255,s=s<0?0:s>255?255:s,n=n<0?0:n>255?255:n,o=o<0?0:o>255?255:o,i[t]=s,i[t+1]=n,i[t+2]=o},t.Factory.addGetterSetter(e.Node,"contrast",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),qt}(),C=function(){if(Qt)return Jt;Qt=1,Object.defineProperty(Jt,"__esModule",{value:!0}),Jt.Emboss=void 0;const t=P(),e=M(),i=c(),r=k();return Jt.Emboss=function(t){const e=10*this.embossStrength(),r=255*this.embossWhiteLevel(),s=this.embossDirection(),n=this.embossBlend(),o=t.data,a=t.width,h=t.height,l=4*a;let d=0,c=0,u=h;switch(s){case"top-left":d=-1,c=-1;break;case"top":d=-1,c=0;break;case"top-right":d=-1,c=1;break;case"right":d=0,c=1;break;case"bottom-right":d=1,c=1;break;case"bottom":d=1,c=0;break;case"bottom-left":d=1,c=-1;break;case"left":d=0,c=-1;break;default:i.Util.error("Unknown emboss direction: "+s)}do{const t=(u-1)*l;let i=d;u+i<1&&(i=0),u+i>h&&(i=0);const s=(u-1+i)*a*4;let g=a;do{const i=t+4*(g-1);let h=c;g+h<1&&(h=0),g+h>a&&(h=0);const l=s+4*(g-1+h),d=o[i]-o[l],u=o[i+1]-o[l+1],f=o[i+2]-o[l+2];let p=d;const _=p>0?p:-p;if((u>0?u:-u)>_&&(p=u),(f>0?f:-f)>_&&(p=f),p*=e,n){const t=o[i]+p,e=o[i+1]+p,r=o[i+2]+p;o[i]=t>255?255:t<0?0:t,o[i+1]=e>255?255:e<0?0:e,o[i+2]=r>255?255:r<0?0:r}else{let t=r-p;t<0?t=0:t>255&&(t=255),o[i]=o[i+1]=o[i+2]=t}}while(--g)}while(--u)},t.Factory.addGetterSetter(e.Node,"embossStrength",.5,(0,r.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"embossWhiteLevel",.5,(0,r.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"embossDirection","top-left",void 0,t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"embossBlend",!1,void 0,t.Factory.afterSetFilter),Jt}(),T=function(){if(Zt)return $t;Zt=1,Object.defineProperty($t,"__esModule",{value:!0}),$t.Enhance=void 0;const t=P(),e=M(),i=k();function r(t,e,i,r,s){const n=i-e,o=s-r;if(0===n)return r+o/2;if(0===o)return r;let a=(t-e)/n;return a=o*a+r,a}return $t.Enhance=function(t){const e=t.data,i=e.length;let s,n,o,a=e[0],h=a,l=e[1],d=l,c=e[2],u=c;const g=this.enhance();if(0===g)return;for(let t=0;t<i;t+=4)s=e[t+0],s<a?a=s:s>h&&(h=s),n=e[t+1],n<l?l=n:n>d&&(d=n),o=e[t+2],o<c?c=o:o>u&&(u=o);let f,p,_,m,y,v;if(h===a&&(h=255,a=0),d===l&&(d=255,l=0),u===c&&(u=255,c=0),g>0)f=h+g*(255-h),p=a-g*(a-0),_=d+g*(255-d),m=l-g*(l-0),y=u+g*(255-u),v=c-g*(c-0);else{const t=.5*(h+a);f=h+g*(h-t),p=a+g*(a-t);const e=.5*(d+l);_=d+g*(d-e),m=l+g*(l-e);const i=.5*(u+c);y=u+g*(u-i),v=c+g*(c-i)}for(let t=0;t<i;t+=4)e[t+0]=r(e[t+0],a,h,p,f),e[t+1]=r(e[t+1],l,d,m,_),e[t+2]=r(e[t+2],c,u,v,y)},t.Factory.addGetterSetter(e.Node,"enhance",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),$t}(),A=(te||(te=1,Object.defineProperty(ee,"__esModule",{value:!0}),ee.Grayscale=void 0,ee.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}}),ee),R=function(){if(ie)return re;ie=1,Object.defineProperty(re,"__esModule",{value:!0}),re.HSL=void 0;const t=P(),e=M(),i=k();return t.Factory.addGetterSetter(e.Node,"hue",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"saturation",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"luminance",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),re.HSL=function(t){const e=t.data,i=e.length,r=Math.pow(2,this.saturation()),s=Math.abs(this.hue()+360)%360,n=127*this.luminance(),o=1*r*Math.cos(s*Math.PI/180),a=1*r*Math.sin(s*Math.PI/180),h=.299+.701*o+.167*a,l=.587-.587*o+.33*a,d=.114-.114*o-.497*a,c=.299-.299*o-.328*a,u=.587+.413*o+.035*a,g=.114-.114*o+.293*a,f=.299-.3*o+1.25*a,p=.587-.586*o-1.05*a,_=.114+.886*o-.2*a;let m,y,v,x;for(let t=0;t<i;t+=4)m=e[t+0],y=e[t+1],v=e[t+2],x=e[t+3],e[t+0]=h*m+l*y+d*v+n,e[t+1]=c*m+u*y+g*v+n,e[t+2]=f*m+p*y+_*v+n,e[t+3]=x},re}(),E=function(){if(se)return ne;se=1,Object.defineProperty(ne,"__esModule",{value:!0}),ne.HSV=void 0;const t=P(),e=M(),i=k();return ne.HSV=function(t){const e=t.data,i=e.length,r=Math.pow(2,this.value()),s=Math.pow(2,this.saturation()),n=Math.abs(this.hue()+360)%360,o=r*s*Math.cos(n*Math.PI/180),a=r*s*Math.sin(n*Math.PI/180),h=.299*r+.701*o+.167*a,l=.587*r-.587*o+.33*a,d=.114*r-.114*o-.497*a,c=.299*r-.299*o-.328*a,u=.587*r+.413*o+.035*a,g=.114*r-.114*o+.293*a,f=.299*r-.3*o+1.25*a,p=.587*r-.586*o-1.05*a,_=.114*r+.886*o-.2*a;for(let t=0;t<i;t+=4){const i=e[t+0],r=e[t+1],s=e[t+2],n=e[t+3];e[t+0]=h*i+l*r+d*s,e[t+1]=c*i+u*r+g*s,e[t+2]=f*i+p*r+_*s,e[t+3]=n}},t.Factory.addGetterSetter(e.Node,"hue",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"saturation",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"value",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),ne}(),F=(oe||(oe=1,Object.defineProperty(ae,"__esModule",{value:!0}),ae.Invert=void 0,ae.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]}),ae),I=de(),O=ge(),L=function(){if(fe)return pe;fe=1,Object.defineProperty(pe,"__esModule",{value:!0}),pe.Noise=void 0;const t=P(),e=M(),i=k();return pe.Noise=function(t){const e=255*this.noise(),i=t.data,r=i.length,s=e/2;for(let t=0;t<r;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()},t.Factory.addGetterSetter(e.Node,"noise",.2,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),pe}(),D=function(){if(_e)return me;_e=1,Object.defineProperty(me,"__esModule",{value:!0}),me.Pixelate=void 0;const t=P(),e=c(),i=M(),r=k();return me.Pixelate=function(t){let i=Math.ceil(this.pixelSize()),r=t.width,s=t.height,n=Math.ceil(r/i),o=Math.ceil(s/i),a=t.data;if(i<=0)e.Util.error("pixelSize value can not be <= 0");else for(let t=0;t<n;t+=1)for(let e=0;e<o;e+=1){let n=0,o=0,h=0,l=0;const d=t*i,c=d+i,u=e*i,g=u+i;let f=0;for(let t=d;t<c;t+=1)if(!(t>=r))for(let e=u;e<g;e+=1){if(e>=s)continue;const i=4*(r*e+t);n+=a[i+0],o+=a[i+1],h+=a[i+2],l+=a[i+3],f+=1}n/=f,o/=f,h/=f,l/=f;for(let t=d;t<c;t+=1)if(!(t>=r))for(let e=u;e<g;e+=1){if(e>=s)continue;const i=4*(r*e+t);a[i+0]=n,a[i+1]=o,a[i+2]=h,a[i+3]=l}}},t.Factory.addGetterSetter(i.Node,"pixelSize",8,(0,r.getNumberValidator)(),t.Factory.afterSetFilter),me}(),G=function(){if(ye)return ve;ye=1,Object.defineProperty(ve,"__esModule",{value:!0}),ve.Posterize=void 0;const t=P(),e=M(),i=k();return ve.Posterize=function(t){const e=Math.round(254*this.levels())+1,i=t.data,r=i.length,s=255/e;for(let t=0;t<r;t+=1)i[t]=Math.floor(i[t]/s)*s},t.Factory.addGetterSetter(e.Node,"levels",.5,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),ve}(),N=function(){if(xe)return we;xe=1,Object.defineProperty(we,"__esModule",{value:!0}),we.RGB=void 0;const t=P(),e=M(),i=k();return we.RGB=function(t){const e=t.data,i=e.length,r=this.red(),s=this.green(),n=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*r,e[t+1]=i*s,e[t+2]=i*n,e[t+3]=e[t+3]}},t.Factory.addGetterSetter(e.Node,"red",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),t.Factory.addGetterSetter(e.Node,"green",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),t.Factory.addGetterSetter(e.Node,"blue",0,i.RGBComponent,t.Factory.afterSetFilter),we}(),W=function(){if(be)return Se;be=1,Object.defineProperty(Se,"__esModule",{value:!0}),Se.RGBA=void 0;const t=P(),e=M(),i=k();return Se.RGBA=function(t){const e=t.data,i=e.length,r=this.red(),s=this.green(),n=this.blue(),o=this.alpha();for(let t=0;t<i;t+=4){const i=1-o;e[t]=r*o+e[t]*i,e[t+1]=s*o+e[t+1]*i,e[t+2]=n*o+e[t+2]*i}},t.Factory.addGetterSetter(e.Node,"red",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),t.Factory.addGetterSetter(e.Node,"green",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),t.Factory.addGetterSetter(e.Node,"blue",0,i.RGBComponent,t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"alpha",1,function(t){return this._filterUpToDate=!1,t>1?1:t<0?0:t}),Se}(),U=(Ce||(Ce=1,Object.defineProperty(Te,"__esModule",{value:!0}),Te.Sepia=void 0,Te.Sepia=function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4){const i=e[t+0],r=e[t+1],s=e[t+2];e[t+0]=Math.min(255,.393*i+.769*r+.189*s),e[t+1]=Math.min(255,.349*i+.686*r+.168*s),e[t+2]=Math.min(255,.272*i+.534*r+.131*s)}}),Te),B=(Ae||(Ae=1,Object.defineProperty(ke,"__esModule",{value:!0}),ke.Solarize=void 0,ke.Solarize=function(t){const e=t.data,i=t.width,r=4*i;let s=t.height;do{const t=(s-1)*r;let n=i;do{const i=t+4*(n-1);let r=e[i],s=e[i+1],o=e[i+2];r>127&&(r=255-r),s>127&&(s=255-s),o>127&&(o=255-o),e[i]=r,e[i+1]=s,e[i+2]=o}while(--n)}while(--s)}),ke),H=function(){if(Pe)return Re;Pe=1,Object.defineProperty(Re,"__esModule",{value:!0}),Re.Threshold=void 0;const t=P(),e=M(),i=k();return Re.Threshold=function(t){const e=255*this.threshold(),i=t.data,r=i.length;for(let t=0;t<r;t+=1)i[t]=i[t]<e?0:255},t.Factory.addGetterSetter(e.Node,"threshold",.5,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),Re}();return n.Konva=t.Konva.Util._assign(t.Konva,{Arc:e.Arc,Arrow:i.Arrow,Circle:r.Circle,Ellipse:s.Ellipse,Image:o.Image,Label:a.Label,Tag:a.Tag,Line:l.Line,Path:d.Path,Rect:u.Rect,RegularPolygon:g.RegularPolygon,Ring:f.Ring,Sprite:p.Sprite,Star:_.Star,Text:m.Text,TextPath:y.TextPath,Transformer:v.Transformer,Wedge:x.Wedge,Filters:{Blur:w.Blur,Brighten:b.Brighten,Contrast:S.Contrast,Emboss:C.Emboss,Enhance:T.Enhance,Grayscale:A.Grayscale,HSL:R.HSL,HSV:E.HSV,Invert:F.Invert,Kaleidoscope:I.Kaleidoscope,Mask:O.Mask,Noise:L.Noise,Pixelate:D.Pixelate,Posterize:G.Posterize,RGB:N.RGB,RGBA:W.RGBA,Sepia:U.Sepia,Solarize:B.Solarize,Threshold:H.Threshold}}),n}var Fe,Ie=s.exports;var Oe=i(function(){if(Fe)return s.exports;Fe=1,Object.defineProperty(Ie,"__esModule",{value:!0});const t=Ee();return s.exports=t.Konva,s.exports}());class Le{screenToWorld(t){return{x:t.x,y:t.y,z:0}}worldToScreen(t){return{x:t.x,y:t.y}}getScale(){return{x:1,y:1,z:1}}}class De{constructor(t,e,i){this.setColor(t,e,i)}asHex(){return"#"+this.HEX}asRGB(){return{r:this.R,g:this.G,b:this.B}}setColor(t,e,i){this.R=t,this.G=e,this.B=i,this.HEX=this.rgbToHex(t,e,i)}rgbToHex(t,e,i){const r=t=>{const e=t.toString(16);return"0"===e?"00":e};return r(t)+r(e)+r(i)}}const Ge=new Map([["solid",[]],["dot",[30,30,.001,30]],["dash",[30,30]]]);class Ne{constructor(t,e=null,i=new Le){var r,s;if(this._worldTransformer=i,e){this._ref=e;let t=this._ref.getAttr("wcsPoints");if(!t){t=[];const e=this._ref.points();let i;for(let r=0;r<e.length;r+=2)i=this._worldTransformer.screenToWorld({x:e[r],y:e[r+1]}),t.push({x:i.x,y:i.y,z:i.z});this._ref.setAttr("wcsPoints",t)}return}t||(t={}),t.points||(t.points=[{x:0,y:0},{x:100,y:100}]);const n=[],o=[];t.points.forEach(t=>{n.push(t.x,t.y);const e=this._worldTransformer.screenToWorld({x:t.x,y:t.y});o.push({x:e.x,y:e.y,z:e.z})}),this._ref=new Oe.Line({stroke:null!==(r=t.color)&&void 0!==r?r:"#ff0000",strokeWidth:null!==(s=t.width)&&void 0!==s?s:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:n,draggable:!0,strokeScaleEnabled:!1,dash:Ge.get(t.type)||[]}),this._ref.setAttr("wcsPoints",o),this._ref.on("transform",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation)}),this._ref.on("transformend",()=>{const t=this._ref.getAbsoluteTransform(),e=[],i=this._ref.points();let r;for(let s=0;s<i.length;s+=2){const n=t.point({x:i[s],y:i[s+1]});r=this._worldTransformer.screenToWorld({x:n.x,y:n.y}),e.push({x:r.x,y:r.y,z:r.z})}this._ref.setAttr("wcsPoints",e)}),this._ref.on("dragend",()=>{const t=this._ref.getAbsoluteTransform(),e=[],i=this._ref.points();let r;for(let s=0;s<i.length;s+=2){const n=t.point({x:i[s],y:i[s+1]});r=this._worldTransformer.screenToWorld({x:n.x,y:n.y}),e.push({x:r.x,y:r.y,z:r.z})}this._ref.setAttr("wcsPoints",e)}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Line"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){return this._ref.points()}setLineWidth(t){this._ref.strokeWidth(t)}getLineWidth(){return this._ref.strokeWidth()}getLineType(){let t;switch(this._ref.dash()||[]){case Ge.get("dot"):t="dot";break;case Ge.get("dash"):t="dash";break;default:t="solid"}return t}setLineType(t){const e=Ge.get(t);e&&this._ref.dash(e)}addPoints(t){let e=this._ref.points();const i=this._ref.getAttr("wcsPoints");t.forEach(t=>{e=e.concat([t.x,t.y]);const r=this._worldTransformer.screenToWorld(t);i.push(r)}),this._ref.points(e)}updateScreenCoordinates(){const t=this._ref.getAttr("wcsPoints"),e=[];let i=this._ref.getAbsoluteTransform().copy();i=i.invert(),t.forEach(t=>{let r=this._worldTransformer.worldToScreen(t);r=i.point({x:r.x,y:r.y}),e.push(r.x),e.push(r.y)}),this._ref.points([]),this._ref.points(e),this._ref.clearCache()}}class We{constructor(t,e=null,i=new Le){var r,s,n;if(this.TEXT_FONT_FAMILY="Calibri",this._worldTransformer=i,e){this._ref=e;return void(this._ref.getAttr("wcsStart")||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})))}t||(t={}),t.position||(t.position={x:0,y:0}),t.text||(t.text="default"),this._ref=new Oe.Text({x:t.position.x,y:t.position.y,text:t.text,fontSize:null!==(r=t.fontSize)&&void 0!==r?r:34,fontFamily:this.TEXT_FONT_FAMILY,fill:null!==(s=t.color)&&void 0!==s?s:"#ff0000",align:"left",draggable:!0,rotation:null!==(n=t.rotation)&&void 0!==n?n:0}),this._ref.width(this._ref.getTextWidth()),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.on("transform",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,r=Math.abs(e.scaleY-1)>1e-5;let s=this._ref.width();i&&(s*=e.scaleX);let n=this._ref.height();r&&(n*=e.scaleY);s<50&&(s=50),n<Math.round(this.getFontSize())&&(n=Math.round(this.getFontSize())),i&&this._ref.width(s),r&&this._ref.height(n),this._ref.scale({x:1,y:1})}),this._ref.on("transformend",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(i))}),this._ref.on("dragend",()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t))}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Text"}getColor(){return this._ref.fill()}setColor(t){this._ref.fill(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getText(){return this._ref.text()}setText(t){this._ref.text(t)}getPosition(){return this._ref.getPosition()}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}))}getFontSize(){return this._ref.fontSize()}setFontSize(t){this._ref.fontSize(t)}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart"));let e=this._ref.getStage().getAbsoluteTransform().copy();e=e.invert();const i=e.point(t);this._ref.position({x:i.x,y:i.y})}}class Ue{constructor(t,e=null,i=new Le){var r,s,n,o;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");if(t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),!i){const t={x:e.x()+e.width(),y:e.y()+e.height()};this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x,y:t.y}))}return}t||(t={}),t.position||(t.position={x:0,y:0}),t.position2?(t.width=t.position2.x-t.position.x,t.height=t.position2.y-t.position.y):t.width&&t.height?t.position2={x:t.position.x+t.width,y:t.position.y+t.height}:(t.position2={x:200,y:200},t.width=200,t.height=200),this._ref=new Oe.Rect({stroke:null!==(r=t.color)&&void 0!==r?r:"#ff0000",strokeWidth:null!==(s=t.lineWidth)&&void 0!==s?s:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",x:t.position.x,y:t.position.y,width:null!==(n=t.width)&&void 0!==n?n:200,height:null!==(o=t.height)&&void 0!==o?o:200,draggable:!0,strokeScaleEnabled:!1}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.position2.x,y:t.position2.y})),this._ref.on("transform",t=>{const e=t.target.attrs,i=Math.abs(e.scaleX-1)>1e-5,r=Math.abs(e.scaleY-1)>1e-5;let s=this._ref.width();i&&(s*=e.scaleX);let n=this._ref.height();r&&(n*=e.scaleY);s<50&&(s=50),n<50&&(n=50),i&&this._ref.width(s),r&&this._ref.height(n),this._ref.scale({x:1,y:1})}),this._ref.on("transformend",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(i)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:i.x+this._ref.width(),y:i.y+this._ref.height()}))}),this._ref.on("dragend",()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))}),this._ref.id(this._ref._id.toString())}getPosition(){return this._ref.position()}getWidth(){return this._ref.width()}getHeight(){return this._ref.height()}setWidth(t){this._ref.width(t);const e={x:this._ref.x()+t,y:this._ref.y()+this._ref.height()},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}setHeight(t){this._ref.height(t);const e={x:this._ref.x()+this._ref.width(),y:this._ref.y()+t},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}));const i={x:t+this._ref.width(),y:e+this._ref.y()},r=this._worldTransformer.screenToWorld(i);this._ref.setAttr("wcsEnd",r)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Rectangle"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}setLineWidth(t){this._ref.strokeWidth(t)}getLineWidth(){return this._ref.strokeWidth()}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getStage().getAbsoluteTransform().copy();i=i.invert();const r=i.point(t),s=i.point(e);this._ref.position({x:r.x,y:r.y}),this._ref.width(Math.abs(s.x-r.x)),this._ref.height(Math.abs(s.y-r.y))}}function Be(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}class ze{constructor(t,e=null,i=new Le){var r,s,n;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsPosition"),i=this._ref.getAttr("wcsRadiusX"),r=this._ref.getAttr("wcsRadiusY");return t||this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),i||this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld({x:e.x()+e.radiusX(),y:e.y()})),void(r||this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()+e.radiusY()})))}t||(t={}),t.position||(t.position={x:0,y:0}),t.position2?(null!==(r=t.radius)&&void 0!==r||(t.radius={x:0,y:0}),t.radius.x=Be(t.position,t.position2),t.position3?t.radius.y=Be(t.position,t.position3):t.radius.x=t.radius.y):t.radius||(t.radius={x:25,y:25}),this._ref=new Oe.Ellipse({stroke:null!==(s=t.color)&&void 0!==s?s:"#ff0000",strokeWidth:null!==(n=t.lineWidth)&&void 0!==n?n:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",x:t.position.x,y:t.position.y,radiusX:t.radius.x,radiusY:t.radius.y,draggable:!0,strokeScaleEnabled:!1}),this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld({x:this._ref.x()+t.radius.x,y:this._ref.y()})),this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld({x:this._ref.x(),y:this._ref.y()+t.radius.y})),this._ref.on("transform",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,r=Math.abs(e.scaleY-1)>1e-5;let s=this._ref.radiusX();i&&(s*=e.scaleX);let n=this._ref.radiusY();r&&(n*=e.scaleY);s<25&&(s=25),n<25&&(n=25),t.evt.ctrlKey||t.evt.shiftKey?i?this._ref.radius({x:s,y:s}):this._ref.radius({x:n,y:n}):this._ref.radius({x:s,y:n}),this._ref.scale({x:1,y:1})}),this._ref.on("transformend",()=>{const t=this._ref.getStage().getAbsoluteTransform(),e=t.point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld(e));const i=t.point({x:this._ref.x()+this._ref.radiusX(),y:this._ref.y()});this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld(i));const r=t.point({x:this._ref.x(),y:this._ref.y()+this._ref.radiusY()});this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld(r))}),this._ref.on("dragend",()=>{const t=this._ref.getStage().getAbsoluteTransform(),e=t.point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld(e));const i=t.point({x:this._ref.x()+this._ref.radiusX(),y:this._ref.y()});this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld(i));const r=t.point({x:this._ref.x(),y:this._ref.y()+this._ref.radiusY()});this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld(r))}),this._ref.id(this._ref._id.toString())}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld({x:t,y:e}))}getRadiusX(){return this._ref.radiusX()}setRadiusX(t){this._ref.radiusX(t),this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld({x:this._ref.x()+t,y:this._ref.y()}))}getRadiusY(){return this._ref.radiusY()}setRadiusY(t){this._ref.radiusY(t),this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld({x:this._ref.x(),y:this._ref.y()+t}))}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Ellipse"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsPosition")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsRadiusX")),i=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsRadiusY"));let r=this._ref.getStage().getAbsoluteTransform().copy();r=r.invert();const s=r.point({x:t.x,y:t.y});this._ref.position({x:s.x,y:s.y}),this._ref.radius({x:Math.abs(r.point(e).x-s.x),y:Math.abs(r.point(i).y-s.y)})}}class He{constructor(t,e=null,i=new Le){var r,s;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");return t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.points()[0],y:e.points()[1]})),void(i||this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:e.points()[2],y:e.points()[3]})))}t||(t={}),t.start||(t.start={x:0,y:0}),t.end||(t.end={x:100,y:100}),this._ref=new Oe.Arrow({stroke:null!==(r=t.color)&&void 0!==r?r:"#ff0000",fill:null!==(s=t.color)&&void 0!==s?s:"#ff0000",strokeWidth:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:[t.start.x,t.start.y,t.end.x,t.end.y],draggable:!0,strokeScaleEnabled:!1}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.start.x,y:t.start.y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.end.x,y:t.end.y})),this._ref.on("transformend",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.points(),r=this._ref.getAbsoluteTransform(),s=r.point({x:i[0],y:i[1]}),n=r.point({x:i[2],y:i[3]});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(s)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld(n))}),this._ref.on("dragend",t=>{const e=this._ref.points(),i=t.target.getAbsoluteTransform(),r=i.point({x:e[0],y:e[1]}),s=i.point({x:e[2],y:e[3]});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(r)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld(s))}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Arrow"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t),this._ref.fill(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){const t=this._ref.points();return[{x:t[0],y:t[1]},{x:t[2],y:t[3]}]}setPoints(t){2===t.length&&(this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t[0].x,y:t[0].y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t[1].x,y:t[1].y})),this._ref.points([t[0].x,t[0].y,t[1].x,t[1].y]))}getStartPoint(){const t=this._ref.points();return{x:t[0],y:t[1]}}setStartPoint(t,e){const i=this._ref.points();this._ref.points([t,e,i[2],i[3]]),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}))}getEndPoint(){const t=this._ref.points();return{x:t[2],y:t[3]}}setEndPoint(t,e){const i=this._ref.points();this._ref.points([i[0],i[1],t,e]),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t,y:e}))}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getAbsoluteTransform().copy();i=i.invert();const r=i.point({x:t.x,y:t.y}),s=i.point({x:e.x,y:e.y});this._ref.points([r.x,r.y,s.x,s.y])}}class Ve{constructor(t,e=null,i=new Le){var r,s;if(this._ratio=1,this.EPSILON=1e-5,this.BASE64_HEADER_START="data:image/",this.BASE64_NOT_FOUND="data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAADsAAAA7AF5KHG9AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAmhJREFUWIXtlr9rVEEQxz+H8RQUJIdeIopYm0vkCg0GBBtbG1NF7Kxt7dR/IGIw/uhTaBNLERURg2kCEUyCYCPi70b0InjGS57FzOZN3r19d+9HJIVfWO52dma/s7Mz8xa2KAaBCWAR+AkECWOmSOIdwC1gtQOpHc+NfQ8wClQ8+1d0vcdH/lQ3bSIRGAZ2pTjAqNovANXIWlXlAXA2zvi2Ln4AjqYgtagYEutENSLvjRoOImFv5iB32Ae8UrLXwFBk3h9ndF0VJnKSO9gTu3yKu5Z1LKnS8YIcABgw5Ks692JZFXcXRJ46Aq6kikCnHNi/mQ50WwVtfaIoBzL3gRk2drSscJ2wrc4VvUoe2wn/41/iBfoVLRnBGnDSY3AAKacy8AmYR+o7K1zCl6wgrgpOAc/MuhvfgMuk+1JGHQgSBcAloKXy78AjYBppJk5/noTulseBMZ23iD/piHFkEdgTQzKk+5wHjmHC3cmBg0BD5xcSTrFXyQPgIWFtDwMvab+2N8DpbhyY1v/3E8gdDgNfVX9SCVZ0/gW4B0wB71S2BpxLcuCM/jaQSHSDEeAX4VMuAG4gTzyHbcAVXXO6GxxwIX+vvxe7JHcYQ07nHqklj96UIW/YhSWzMKcep8VVtf8B1Dw6h4DfhB+sdbgn2R+gnoEc5NR3dZ+3QJ9H74HqXLPCGlJyTfI9y3YCs0owq3OLOpKkLeBI1HhSDT/mdKIPiUCARMTlQx34TMLjtww8IczmO8AJ/N/2JNSQXAiQ671JePePge0+wzJSQq4FFzlaenIvucUAkiQLhC/mLGNZ9xgn5s63BP4CCk0QDtm4BhoAAAAASUVORK5CYII=",this._worldTransformer=i,e){e.src&&e.src.startsWith(this.BASE64_HEADER_START)||(e.src=this.BASE64_NOT_FOUND),e.height()<=this.EPSILON&&e.height(32),e.width()<=this.EPSILON&&e.width(32),this._ref=e,this._canvasImage=e.image(),this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width();const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");if(t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),!i){const t={x:e.x()+e.width(),y:e.y()+e.height()};this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x,y:t.y}))}return}t||(t={}),t.position||(t.position={x:0,y:0}),t.src&&t.src.startsWith(this.BASE64_HEADER_START)||(t.src=this.BASE64_NOT_FOUND),t.position2&&(t.width=t.position2.x-t.position.x,t.height=t.position2.y-t.position.y),this._canvasImage=new Image,this._canvasImage.onload=()=>{if(this._ref.image(this._canvasImage),this._ref.height()<=this.EPSILON&&this._ref.height(this._canvasImage.height),this._ref.width()<=this.EPSILON&&this._ref.width(this._canvasImage.width),this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width(),(t.width<=this.EPSILON||t.height<=this.EPSILON)&&(t.maxWidth>=this.EPSILON||t.maxWidth>=this.EPSILON)){const e=t.maxHeight-this._canvasImage.height,i=t.maxWidth-this._canvasImage.width;(e<=this.EPSILON||i<=this.EPSILON)&&(i<=this.EPSILON&&i<e/this._ratio?(this._ref.height(t.maxWidth*this._ratio),this._ref.width(t.maxWidth)):(this._ref.width(t.maxHeight/this._ratio),this._ref.height(t.maxHeight)))}const e=this._worldTransformer.screenToWorld({x:t.position.x+this._ref.width(),y:t.position.y+this._ref.height()});this._ref.setAttr("wcsEnd",e)},this._canvasImage.onerror=()=>{this._canvasImage.onerror=function(){},this._canvasImage.src=this.BASE64_NOT_FOUND},this._canvasImage.src=t.src,this._ref=new Oe.Image({x:t.position.x,y:t.position.y,image:this._canvasImage,width:null!==(r=t.width)&&void 0!==r?r:0,height:null!==(s=t.height)&&void 0!==s?s:0,draggable:!0}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.on("transform",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,r=Math.abs(e.scaleY-1)>1e-5;let s=this._ref.width();i&&(s*=e.scaleX);let n=this._ref.height();r&&(n*=e.scaleY),t.evt.ctrlKey||t.evt.shiftKey?i?(this._ref.width(s),this._ref.height(s*this._ratio)):(this._ref.width(n/this._ratio),this._ref.height(n)):(i&&this._ref.width(s),r&&this._ref.height(n)),this._ref.scale({x:1,y:1})}),this._ref.on("transformend",()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))}),this._ref.on("dragend",()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))}),this._ref.id(this._ref._id.toString())}getSrc(){return this._canvasImage.src}setSrc(t){this._canvasImage.src=t}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t),this._ref.height(t*this._ratio);const e={x:this._ref.x()+t,y:this._ref.y()+this._ref.height()},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}getHeight(){return this._ref.height()}setHeight(t){this._ref.height(t),this._ref.width(t/this._ratio);const e={x:this._ref.x()+this._ref.width(),y:this._ref.y()+t},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Image"}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPosition(){return this._ref.getPosition()}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}));const i={x:t+this._ref.width(),y:e+this._ref.y()},r=this._worldTransformer.screenToWorld(i);this._ref.setAttr("wcsEnd",r)}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getStage().getAbsoluteTransform().copy();i=i.invert();const r=i.point(t),s=i.point(e);this._ref.position({x:r.x,y:r.y}),this._ref.width(Math.abs(s.x-r.x)),this._ref.height(Math.abs(s.y-r.y))}}class je{constructor(t,e=null,i=new Le){var r,s,n,o;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");if(t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),!i){const t={x:e.x()+e.width(),y:e.y()+e.height()};this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x,y:t.y}))}return}t||(t={}),t.position||(t.position={x:0,y:0}),t.position2?(t.width=t.position2.x-t.position.x,t.height=t.position2.y-t.position.y):t.width&&t.height?t.position2={x:t.position.x+t.width,y:t.position.y+t.height}:(t.position2={x:200,y:200},t.width=200,t.height=200);this._ref=new Oe.Shape({x:t.position.x,y:t.position.y,width:null!==(r=t.width)&&void 0!==r?r:200,height:null!==(s=t.height)&&void 0!==s?s:200,stroke:null!==(n=t.color)&&void 0!==n?n:"#ff0000",strokeWidth:null!==(o=t.lineWidth)&&void 0!==o?o:4,draggable:!0,strokeScaleEnabled:!1,globalCompositeOperation:"source-over",sceneFunc:(t,e)=>{const i=this._ref.width(),r=this._ref.height(),s=[{x:0,y:0},{x:0+i,y:0},{x:0+i,y:0+r},{x:0,y:0+r},{x:0,y:0}];function n(n,o){const a={x:(h={x:0,y:0}).x+i/2,y:h.y+r/2};var h;t.beginPath();for(let e=0;e<s.length-1;e++){let i=o;const r=s[e+1].x-s[e].x,h=s[e+1].y-s[e].y,l=Math.sqrt(r*r+h*h),d=Math.floor(l/i);i=o+d/(l%i);let c=s[e].x+r/d/2,u=s[e].y+h/d/2;const g=s[e+1].x,f=s[e+1].y,p=Math.atan((f-u)/(g-c)),_=p+Math.PI,m=c>a.x&&u>a.y;for(let e=0;e<d;e++)m?t.arc(c,u,n,p,_):t.arc(c,u,n,_,p),c+=r/d,u+=h/d}t.closePath(),t.fillStrokeShape(e)}i>=49||r>=49?n(8,15):i>=25||r>=25?n(4,7.5):(t.beginPath(),t.lineTo(s[1].x,s[1].y),t.lineTo(s[2].x,s[2].y),t.lineTo(s[3].x,s[3].y),t.lineTo(s[4].x,s[4].y),t.closePath(),t.fillStrokeShape(e))}}),this._ref.className="Cloud",this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.position2.x,y:t.position2.y})),this._ref.on("transform",t=>{const e=t.target.attrs,i=Math.abs(e.scaleX-1)>1e-5,r=Math.abs(e.scaleY-1)>1e-5;let s=this._ref.width();i&&(s*=e.scaleX);let n=this._ref.height();r&&(n*=e.scaleY),s<50&&(s=50),n<50&&(n=50),i&&this._ref.width(s),r&&this._ref.height(n),this._ref.scale({x:1,y:1})}),this._ref.on("transformend",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(i)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:i.x+this._ref.width(),y:i.y+this._ref.height()}))}),this._ref.on("dragend",()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))}),this._ref.getSelfRect=()=>({x:-8,y:-8,width:this._ref.width()+16,height:this._ref.height()+16}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Cloud"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.position({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}));const i={x:t+this._ref.width(),y:e+this._ref.y()},r=this._worldTransformer.screenToWorld(i);this._ref.setAttr("wcsEnd",r)}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t);const e={x:this._ref.x()+t,y:this._ref.y()+this._ref.height()},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}getHeight(){return this._ref.height()}setHeight(t){this._ref.height(t);const e={x:this._ref.x()+this._ref.width(),y:this._ref.y()+t},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getStage().getAbsoluteTransform().copy();i=i.invert();const r=i.point(t),s=i.point(e);this._ref.position({x:r.x,y:r.y}),this._ref.width(Math.abs(s.x-r.x)),this._ref.height(Math.abs(s.y-r.y))}}const Ke={SelectMarkup:{name:"SelectMarkup",initializer:null},Line:{name:"Line",initializer:(t,e=null,...i)=>new Ne(e,t,...i)},Text:{name:"Text",initializer:(t,e=null,...i)=>new We(e,t,...i)},Rectangle:{name:"Rect",initializer:(t,e=null,...i)=>new Ue(e,t,...i)},Ellipse:{name:"Ellipse",initializer:(t,e=null,...i)=>new ze(e,t,...i)},Arrow:{name:"Arrow",initializer:(t,e=null,...i)=>new He(e,t,...i)},Image:{name:"Image",initializer:(t,e=null,...i)=>new Ve(e,t,...i)},Cloud:{name:"Cloud",initializer:(t,e=null,...i)=>new je(e,t,...i)}};t.Markup=class{constructor(){this._markupIsActive=!1,this._markupColor=new De(255,0,0),this.lineWidth=4,this.lineType="solid",this.fontSize=34,this.changeActiveDragger=t=>{const e=t.data;this._markupContainer.className=this._container.className.split(" ").filter(t=>!t.startsWith("oda-cursor-")).filter(t=>t).concat(`oda-cursor-${e.toLowerCase()}`).join(" "),this.removeTextInput(),this.removeImageInput(),this.enableEditMode(e)},this.resizeContainer=t=>{if(!t||!t[0]||!t[0].contentRect)return;const{width:e,height:i}=t[0].contentRect;e&&i&&this._konvaStage&&(this._konvaStage.width(e),this._konvaStage.height(i),this.getObjects().forEach(t=>{t.updateScreenCoordinates()}))},this.resizeViewer=t=>{const{width:e,height:i}=t;e&&i&&this._konvaStage&&(this._konvaStage.width(e),this._konvaStage.height(i),this.getObjects().forEach(t=>{t.updateScreenCoordinates()}))},this.pan=()=>{this.getObjects().forEach(t=>{t.updateScreenCoordinates()})},this.zoomAt=()=>{this.getObjects().forEach(t=>{t.updateScreenCoordinates()})},this.redirectToViewer=t=>{this._viewer&&this._viewer.emit(t)},this.getRelativePointPosition=(t,e)=>{const i=e.getAbsoluteTransform().copy();return i.invert(),i.point(t)},this.getRelativePointerPosition=t=>this.getRelativePointPosition(t.getStage().getPointerPosition(),t)}initialize(t,e,i,r){if(!Oe)throw new Error('Markup error: Konva is not initialized. Forgot to add <script src="https://unpkg.com/konva@9/konva.min.js"><\/script> to your page?');this._viewer=i,this._worldTransformer=null!=r?r:new Le,this._container=t,this._markupContainer=document.createElement("div"),this._markupContainer.id="markup-container",this._markupContainer.style.position="absolute",this._markupContainer.style.top="0px",this._markupContainer.style.left="0px",this._markupContainer.style.outline="0px",this._markupContainer.style.pointerEvents="none";this._container.parentElement.appendChild(this._markupContainer),i?this._viewer.addEventListener("resize",this.resizeViewer):this._resizeObserver=new ResizeObserver(function(t,e){let i=null;return(...r)=>{i&&clearTimeout(i),i=setTimeout(()=>{i=null,t(...r)},e)}}(this.resizeContainer,100)),this._markupColor.setColor(255,0,0),this.initializeKonva(),this._viewer&&(this._viewer.addEventListener("changeactivedragger",this.changeActiveDragger),this._viewer.addEventListener("pan",this.pan),this._viewer.addEventListener("zoomat",this.zoomAt))}dispose(){var t,e;this._viewer&&(this._viewer.removeEventListener("zoomat",this.zoomAt),this._viewer.removeEventListener("pan",this.pan),this._viewer.removeEventListener("changeactivedragger",this.changeActiveDragger)),this.destroyKonva(),null===(t=this._resizeObserver)||void 0===t||t.disconnect(),this._resizeObserver=void 0,null===(e=this._markupContainer)||void 0===e||e.remove(),this._markupContainer=void 0,this._container=void 0,this._viewer=void 0,this._worldTransformer=void 0,this._markupIsActive=!1}syncOverlay(){}clearOverlay(){this.removeTextInput(),this.removeImageInput(),this.clearSelected(),this.getObjects().forEach(t=>t.delete())}getMarkupColor(){return this._markupColor.asRGB()}setMarkupColor(t,e,i){this._markupColor.setColor(t,e,i),this.redirectToViewer({type:"changemarkupcolor",data:{r:t,g:e,b:i}})}colorizeAllMarkup(t,e,i){this.setMarkupColor(t,e,i);const r=new De(t,e,i).asHex();this.getObjects().filter(t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,r)})}colorizeSelectedMarkups(t,e,i){const r=new De(t,e,i).asHex();this.getSelectedObjects().filter(t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,r)})}setViewpoint(t){var e,i,r,s,n,o,a,h;this.clearSelected(),this.removeTextInput(),this.removeImageInput(),this._konvaStage.scale({x:1,y:1}),this._konvaStage.position({x:0,y:0});const l=(null===(e=t.custom_fields)||void 0===e?void 0:e.markup_color)||{r:255,g:0,b:0};this.setMarkupColor(l.r,l.g,l.b),null===(i=t.lines)||void 0===i||i.forEach(t=>{const e=[];t.points.forEach(t=>{const i=this._worldTransformer.worldToScreen(t);e.push(i.x),e.push(i.y)}),this.addLine(e,t.color,t.type,t.width,t.id)}),null===(r=t.texts)||void 0===r||r.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addText(t.text,e,t.angle,t.color,t.text_size,t.font_size,t.id)}),null===(s=t.rectangles)||void 0===s||s.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null;this.addRectangle(e,i,t.width,t.height,t.line_width,t.color,t.id)}),null===(n=t.ellipses)||void 0===n||n.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null,r=t.position3?this._worldTransformer.worldToScreen(t.position3):null;this.addEllipse(e,i,r,t.radius,t.line_width,t.color,t.id)}),null===(o=t.arrows)||void 0===o||o.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.start),i=this._worldTransformer.worldToScreen(t.end);this.addArrow(e,i,t.color,t.id)}),null===(a=t.clouds)||void 0===a||a.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null;this.addCloud(e,i,t.width,t.height,t.line_width,t.color,t.id)}),null===(h=t.images)||void 0===h||h.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null;this.addImage(e,i,t.src,t.width,t.height,t.id)})}getViewpoint(t){return t||(t={}),t.lines=this.getMarkupLines(),t.texts=this.getMarkupTexts(),t.arrows=this.getMarkupArrows(),t.clouds=this.getMarkupClouds(),t.ellipses=this.getMarkupEllipses(),t.images=this.getMarkupImages(),t.rectangles=this.getMarkupRectangles(),t.custom_fields={markup_color:this.getMarkupColor()},t.snapshot={data:this.combineMarkupWithDrawing()},t}enableEditMode(t){return t&&Ke[t]?(this._markupMode=t,this._markupContainer.style.pointerEvents="all",this._markupIsActive=!0):(this.clearSelected(),this.removeTextInput(),this.removeImageInput(),this._markupContainer.style.pointerEvents="none",this._markupIsActive=!1),this}createObject(t,e){const i=Ke[t];if(!i||!i.initializer)throw new Error(`Markup CreateObject - unsupported markup type ${t}`);const r=i.initializer(null,e,this._worldTransformer);return this.addObject(r),r}getObjects(){const t=[];return Object.keys(Ke).forEach(e=>{const i=Ke[e];this.konvaLayerFind(e).forEach(e=>t.push(i.initializer(e,null,this._worldTransformer)))}),t}getSelectedObjects(){return this._konvaTransformer?this._konvaTransformer.nodes().map(t=>{const e=t.className,i=Object.values(Ke).find(t=>t.name===e);return i?i.initializer(t,null,this._worldTransformer):null}).filter(t=>t):[]}selectObjects(t){if(!this._konvaTransformer)return;const e=this._konvaTransformer.nodes().concat(t.map(t=>t.ref()));this._konvaTransformer.nodes(e)}clearSelected(){this._konvaTransformer&&this._konvaTransformer.nodes([])}addObject(t){"Image"===t.type()?this._groupImages.add(t.ref()):"Text"===t.type()?this._groupTexts.add(t.ref()):this._groupGeometry.add(t.ref())}konvaLayerFind(t){if(!this._konvaLayer)return[];const e=Ke[t];return e&&e.initializer?this._konvaLayer.find(e.name).filter(t=>t.parent===this._konvaLayer||t.parent===this._groupImages||t.parent===this._groupGeometry||t.parent===this._groupTexts):[]}initializeKonva(){const t=new Oe.Stage({container:this._markupContainer,width:this._container.clientWidth,height:this._container.clientHeight});this._konvaStage=t;const e=new Oe.Layer({pixelRation:window.devicePixelRatio});t.add(e),this._groupImages=new Oe.Group,e.add(this._groupImages),this._groupGeometry=new Oe.Group,e.add(this._groupGeometry),this._groupTexts=new Oe.Group,e.add(this._groupTexts),this._konvaLayer=e;const i=new Oe.Transformer({shouldOverdrawWholeArea:!1,keepRatio:!1,flipEnabled:!1});e.add(i),this._konvaTransformer=i;let r,s,n,o=!1;t.on("mousedown touchstart",e=>{if(!this._markupIsActive||e.target!==t||"Text"===this._markupMode||"Image"===this._markupMode)return;if(e.target===t&&i.nodes().length>0)return void i.nodes([]);const n=this.getRelativePointerPosition(t);s=n,o=["Arrow","Cloud","Ellipse","Line","Rectangle"].some(t=>t===this._markupMode),"Line"===this._markupMode&&(r=this.addLine([n.x,n.y,n.x,n.y]))}),t.on("mouseup touchend",()=>{if(this._markupIsActive){if(o){const e=this.getRelativePointerPosition(t),i=s&&e.x===s.x&&e.y===s.y,r=i?s.x:Math.min(s.x,e.x),n=i?s.y:Math.min(s.y,e.y),o=i?200:Math.abs(s.x-e.x),a=i?200:Math.abs(s.y-e.y);i&&("Rectangle"===this._markupMode?this.addRectangle({x:r,y:n},null,o,a):"Ellipse"===this._markupMode?this.addEllipse({x:r,y:n},null,null,{x:o/2,y:a/2}):"Arrow"===this._markupMode?this.addArrow({x:s.x,y:s.y},{x:i?s.x+200:e.x,y:i?n:e.y}):"Cloud"===this._markupMode&&this.addCloud({x:r,y:n},null,Math.max(100,o),Math.max(100,a)))}n=void 0,o=!1}}),t.on("mousemove touchmove",()=>{if(!this._markupIsActive)return;if(!o)return;const e=this.getRelativePointerPosition(t),i=s&&e.x===s.x&&e.y===s.y,a=i?s.x:Math.min(s.x,e.x),h=i?s.y:Math.min(s.y,e.y),l=i?200:Math.abs(s.x-e.x),d=i?200:Math.abs(s.y-e.y);"Line"===this._markupMode?r.addPoints([{x:e.x,y:e.y}]):"Arrow"===this._markupMode?n?n.setEndPoint(e.x,e.y):n=this.addArrow({x:s.x,y:s.y},{x:e.x,y:e.y}):"Rectangle"===this._markupMode?n?(n.setPosition(a,h),n.setWidth(l),n.setHeight(d)):n=this.addRectangle({x:a,y:h},null,l,d):"Ellipse"===this._markupMode?n?(n.setPosition(a,h),n.setRadiusX(l),n.setRadiusY(d)):n=this.addEllipse({x:a,y:h},null,null,{x:l,y:d}):"Cloud"===this._markupMode&&(n?(n.setPosition(a,h),n.setWidth(Math.max(100,l)),n.setHeight(Math.max(100,d))):n=this.addCloud({x:a,y:h},null,l,d))}),t.on("click tap",e=>{if(!this._markupIsActive)return;if(e.target===t){if("Text"===this._markupMode){if(this._textInputRef&&this._textInputRef.value)this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle);else if(0===i.nodes().length){const i=this.getRelativePointerPosition(t);this.createTextInput(i,e.evt.pageX,e.evt.pageY,0,null)}}else if("Image"===this._markupMode)if(this._imageInputRef&&this._imageInputRef.value)this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},null,this._imageInputRef.value,0,0,this._imageInputRef.value);else if(0===i.nodes().length){const e=this.getRelativePointerPosition(t);this.createImageInput(e)}return void i.nodes([])}if("Text"===this._markupMode||"SelectMarkup"===this._markupMode){if("Text"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._textInputRef&&this._textInputRef.value?this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle):this.createTextInput({x:e.target.attrs.x,y:e.target.attrs.y},e.evt.pageX,e.evt.pageY,e.target.attrs.rotation,e.target.attrs.text));this.removeTextInput()}if("Image"===this._markupMode||"SelectMarkup"===this._markupMode){if("Image"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._imageInputRef&&this._imageInputRef.value?this.addImage(this._imageInputPos,null,this._imageInputRef.value,0,0):this.createImageInput({x:e.target.attrs.x,y:e.target.attrs.y}));this.removeImageInput()}i.nodes().filter(t=>"Cloud"===t.className||"Image"===t.className).length>0||"Cloud"===e.target.className||"Image"===e.target.className?i.rotateEnabled(!1):i.rotateEnabled(!0);const r=e.evt.shiftKey||e.evt.ctrlKey||e.evt.metaKey,s=i.nodes().indexOf(e.target)>=0;if(r||s){if(r&&s){const t=i.nodes().slice();t.splice(t.indexOf(e.target),1),i.nodes(t)}else if(r&&!s){const t=i.nodes().concat([e.target]);i.nodes(t)}}else i.nodes([e.target])});const a=t.container();a.tabIndex=1,a.focus(),a.addEventListener("keydown",t=>{if(this._markupIsActive)return"Delete"===t.code?(this.getSelectedObjects().forEach(t=>t.delete()),void this.clearSelected()):void t.preventDefault()})}destroyKonva(){var t;this.removeTextInput(),this.removeImageInput(),this.clearOverlay(),null===(t=this._konvaStage)||void 0===t||t.destroy(),this._groupImages=void 0,this._groupGeometry=void 0,this._groupTexts=void 0,this._konvaLayer=void 0,this._konvaTransformer=void 0,this._konvaStage=void 0}getMarkupLines(){const t=[];return this.konvaLayerFind("Line").forEach(e=>{const i=e.getAttr("wcsPoints");if(!i)return;const r=new Ne(null,e,this._worldTransformer),s={id:r.id(),points:i,color:r.getColor()||"#ff0000",type:r.getLineType()||this.lineType,width:r.getLineWidth()||this.lineWidth};t.push(s)}),t}getMarkupTexts(){const t=[];return this.konvaLayerFind("Text").forEach(e=>{const i=this._worldTransformer.getScale(),r=e.getAttr("wcsStart"),s=this._konvaStage.getAbsoluteTransform(),n=new We(null,e,this._worldTransformer),o={id:n.id(),position:r,text:n.getText(),text_size:.02*i.y,angle:n.getRotation(),color:n.getColor(),font_size:n.getFontSize()*s.getMatrix()[0]};t.push(o)}),t}getMarkupRectangles(){const t=[];return this.konvaLayerFind("Rectangle").forEach(e=>{const i=e.getAttr("wcsStart"),r=e.getAttr("wcsEnd"),s=this._worldTransformer.worldToScreen(i),n=this._worldTransformer.worldToScreen(r),o=new Ue(null,e,this._worldTransformer),a={id:o.id(),position:i,position2:r,width:Math.abs(s.x-n.x),height:Math.abs(s.y-n.y),line_width:o.getLineWidth(),color:o.getColor()};t.push(a)}),t}getMarkupEllipses(){const t=[];return this.konvaLayerFind("Ellipse").forEach(e=>{const i=e.getAttr("wcsPosition"),r=e.getAttr("wcsRadiusX"),s=e.getAttr("wcsRadiusY"),n=this._konvaStage.getAbsoluteTransform().getMatrix()[0],o=new ze(null,e,this._worldTransformer),a={id:o.id(),position:i,position2:r,position3:s,radius:{x:e.getRadiusX()*n,y:e.getRadiusY()*n},line_width:o.getLineWidth(),color:o.getColor()};t.push(a)}),t}getMarkupArrows(){const t=[];return this.konvaLayerFind("Arrow").forEach(e=>{const i=e.getAttr("wcsStart"),r=e.getAttr("wcsEnd"),s=new He(null,e,this._worldTransformer),n={id:s.id(),start:i,end:r,color:s.getColor()};t.push(n)}),t}getMarkupImages(){const t=[];return this.konvaLayerFind("Image").forEach(e=>{const i=e.getAttr("wcsStart"),r=e.getAttr("wcsEnd"),s=this._konvaStage.getAbsoluteTransform().getMatrix()[0],n=new Ve(null,e,this._worldTransformer),o={id:n.id(),position:i,position2:r,src:n.getSrc(),width:n.getWidth()*s,height:n.getHeight()*s};t.push(o)}),t}getMarkupClouds(){const t=[];return this.konvaLayerFind("Cloud").forEach(e=>{const i=e.getAttr("wcsStart"),r=e.getAttr("wcsEnd"),s=this._worldTransformer.worldToScreen(i),n=this._worldTransformer.worldToScreen(r),o=new je(null,e,this._worldTransformer),a={id:o.id(),position:i,position2:r,width:Math.abs(s.x-n.x),height:Math.abs(s.y-n.y),line_width:o.getLineWidth(),color:o.getColor()};t.push(a)}),t}combineMarkupWithDrawing(){this.clearSelected();const t=document.createElement("canvas");if(this._konvaStage){t.width=this._konvaStage.width(),t.height=this._konvaStage.height();const e=t.getContext("2d");this._container instanceof HTMLCanvasElement&&e.drawImage(this._container,0,0),e.drawImage(this._konvaStage.toCanvas({pixelRatio:window.devicePixelRatio}),0,0)}return t.toDataURL("image/jpeg",.25)}addLine(t,e,i,r,s){if(!t||0===t.length)return;const n=[];for(let e=0;e<t.length;e+=2)n.push({x:t[e],y:t[e+1]});const o=new Ne({points:n,type:i||this.lineType,width:r||this.lineWidth,color:e||this._markupColor.asHex(),id:s},null,this._worldTransformer);return this.addObject(o),o}createTextInput(t,e,i,r,s){this._textInputRef?this.removeTextInput():(this._textInputPos=t,this._textInputAngle=r,this._textInputRef=document.createElement("textarea"),this._textInputRef.style.zIndex="9999",this._textInputRef.style.position="absolute",this._textInputRef.style.display="block",this._textInputRef.style.top=i+"px",this._textInputRef.style.left=e+"px",this._textInputRef.style.fontSize=`${this.fontSize}px`,this._textInputRef.style.color=`${this._markupColor.asHex()}`,this._textInputRef.style.fontFamily="Calibri",this._textInputRef.onkeydown=t=>{"Enter"!==t.key||t.shiftKey||(t.preventDefault(),this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle)),"Escape"===t.key&&(t.preventDefault(),this.removeTextInput())},s&&(this._textInputRef.value=s),document.body.appendChild(this._textInputRef),setTimeout(()=>{this._textInputRef.focus()},50))}removeTextInput(){var t;null===(t=this._textInputRef)||void 0===t||t.remove(),this._textInputRef=null,this._textInputPos=null,this._textInputAngle=0}createImageInput(t){if(this._imageInputRef)this.removeImageInput();else{const e=t=>new Promise((e,i)=>{const r=new FileReader;r.readAsDataURL(t),r.onload=()=>{e(r.result)},r.onerror=t=>{i(t)}});this._imageInputPos=t,this._imageInputRef=document.createElement("input"),this._imageInputRef.style.display="none",this._imageInputRef.type="file",this._imageInputRef.accept="image/png, image/jpeg",this._imageInputRef.onchange=async t=>{const i=t.target.files[0],r=await e(i);this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},null,r.toString(),0,0)},this._imageInputRef.oncancel=()=>{this.removeImageInput()},document.body.appendChild(this._imageInputRef),setTimeout(()=>{this._imageInputRef.click()},50)}}removeImageInput(){var t;null===(t=this._imageInputRef)||void 0===t||t.remove(),this._imageInputRef=null,this._imageInputPos=null}addText(t,e,i,r,s,n,o){var a;if(!t)return;null===(a=this.getSelectedObjects().shift())||void 0===a||a.delete(),this.clearSelected(),this.removeTextInput();const h=1e-6;if(s&&s>h&&(!n||n<h)){const t=.02;n=s/(this._worldTransformer.getScale().y/t)/34}const l=new We({position:{x:e.x,y:e.y},text:t,rotation:i,fontSize:n||this.fontSize,color:r||this._markupColor.asHex(),id:o},null,this._worldTransformer);return this.addObject(l),l}addRectangle(t,e,i,r,s,n,o){if(!t)return;const a=new Ue({position:t,position2:e,width:i,height:r,lineWidth:s||this.lineWidth,color:n||this._markupColor.asHex(),id:o},null,this._worldTransformer);return this.addObject(a),a}addEllipse(t,e,i,r,s,n,o){if(!t)return;const a=new ze({position:t,position2:e,position3:i,radius:r,lineWidth:s,color:n||this._markupColor.asHex(),id:o},null,this._worldTransformer);return this.addObject(a),a}addArrow(t,e,i,r){if(!t||!e)return;const s=new He({start:t,end:e,color:i||this._markupColor.asHex(),id:r},null,this._worldTransformer);return this.addObject(s),s}addCloud(t,e,i,r,s,n,o){if(!t||!i||!r)return;const a=new je({position:t,position2:e,width:i,height:r,color:n||this._markupColor.asHex(),lineWidth:s||this.lineWidth,id:o},null,this._worldTransformer);return this.addObject(a),a}addImage(t,e,i,r,s,n){var o;if(!t||!i)return;null===(o=this.getSelectedObjects().shift())||void 0===o||o.delete(),this.clearSelected(),this.removeImageInput();const a=new Ve({position:t,position2:e,src:i,width:r,height:s,maxWidth:this._konvaStage.width()-t.x,maxHeight:this._konvaStage.height()-t.y,id:n},null,this._worldTransformer);return this.addObject(a),a}}});
|
|
24
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).ODA=t.ODA||{},t.ODA.Markup=t.ODA.Markup||{}))}(this,function(t){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function i(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var r,s={exports:{}},n={},o={},a={};function h(){return r||(r=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t._registerNode=t.Konva=t.glob=void 0;const i=Math.PI/180;t.glob=void 0!==e?e:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},t.Konva={_global:t.glob,version:"9.3.22",isBrowser:"undefined"!=typeof window&&("[object Window]"==={}.toString.call(window)||"[object global]"==={}.toString.call(window)),isUnminified:/param/.test(function(t){}.toString()),dblClickWindow:400,getAngle:e=>t.Konva.angleDeg?e*i: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,_fixTextRendering:!1,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:()=>t.Konva.DD.isDragging,isTransforming(){var e;return null===(e=t.Konva.Transformer)||void 0===e?void 0:e.isTransforming()},isDragReady:()=>!!t.Konva.DD.node,releaseCanvasOnDestroy:!0,document:t.glob.document,_injectGlobal(e){t.glob.Konva=e}};t._registerNode=e=>{t.Konva[e.prototype.getClassName()]=e},t.Konva._injectGlobal(t.Konva)}(a)),a}var l,d={};function c(){return l||(l=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Util=t.Transform=void 0;const e=h();class i{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 i(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),r=this.m[0]*e+this.m[2]*i,s=this.m[1]*e+this.m[3]*i,n=this.m[0]*-i+this.m[2]*e,o=this.m[1]*-i+this.m[3]*e;return this.m[0]=r,this.m[1]=s,this.m[2]=n,this.m[3]=o,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(t,e){const i=this.m[0]+this.m[2]*e,r=this.m[1]+this.m[3]*e,s=this.m[2]+this.m[0]*t,n=this.m[3]+this.m[1]*t;return this.m[0]=i,this.m[1]=r,this.m[2]=s,this.m[3]=n,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],r=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],n=this.m[0]*t.m[4]+this.m[2]*t.m[5]+this.m[4],o=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]=r,this.m[3]=s,this.m[4]=n,this.m[5]=o,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,r=-this.m[2]*t,s=this.m[0]*t,n=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),o=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]=r,this.m[3]=s,this.m[4]=n,this.m[5]=o,this}getMatrix(){return this.m}decompose(){const e=this.m[0],i=this.m[1],r=this.m[2],s=this.m[3],n=e*s-i*r,o={x:this.m[4],y:this.m[5],rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!=e||0!=i){const t=Math.sqrt(e*e+i*i);o.rotation=i>0?Math.acos(e/t):-Math.acos(e/t),o.scaleX=t,o.scaleY=n/t,o.skewX=(e*r+i*s)/n,o.skewY=0}else if(0!=r||0!=s){const t=Math.sqrt(r*r+s*s);o.rotation=Math.PI/2-(s>0?Math.acos(-r/t):-Math.acos(r/t)),o.scaleX=n/t,o.scaleY=t,o.skewX=0,o.skewY=(e*r+i*s)/n}return o.rotation=t.Util._getRotation(o.rotation),o}}t.Transform=i;const r=Math.PI/180,s=180/Math.PI,n="Konva error: ",o={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,132,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,255,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,203],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:[119,128,144],slategrey:[119,128,144],snow:[255,255,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,5]},a=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/;let l=[];const d="undefined"!=typeof requestAnimationFrame&&requestAnimationFrame||function(t){setTimeout(t,60)};t.Util={_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){l.push(t),1===l.length&&d(function(){const t=l;l=[],t.forEach(function(t){t()})})},createCanvasElement(){const t=document.createElement("canvas");try{t.style=t.style||{}}catch(t){}return t},createImageElement:()=>document.createElement("img"),_isInDocument(t){for(;t=t.parentNode;)if(t==document)return!0;return!1},_urlToImage(e,i){const r=t.Util.createImageElement();r.onload=function(){i(r)},r.src=e},_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},getRGB(t){let e;return t in o?(e=o[t],{r:e[0],g:e[1],b:e[2]}):"#"===t[0]?this._hexToRgb(t.substring(1)):"rgb("===t.substr(0,4)?(e=a.exec(t.replace(/ /g,"")),{r:parseInt(e[1],10),g:parseInt(e[2],10),b:parseInt(e[3],10)}):{r:0,g:0,b:0}},colorToRGBA:e=>(e=e||"black",t.Util._namedColorToRBA(e)||t.Util._hex3ColorToRGBA(e)||t.Util._hex4ColorToRGBA(e)||t.Util._hex6ColorToRGBA(e)||t.Util._hex8ColorToRGBA(e)||t.Util._rgbColorToRGBA(e)||t.Util._rgbaColorToRGBA(e)||t.Util._hslColorToRGBA(e)),_namedColorToRBA(t){const e=o[t.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:1}:null},_rgbColorToRGBA(t){if(0===t.indexOf("rgb(")){const e=(t=t.match(/rgb\(([^)]+)\)/)[1]).split(/ *, */).map(Number);return{r:e[0],g:e[1],b:e[2],a:1}}},_rgbaColorToRGBA(t){if(0===t.indexOf("rgba(")){const e=(t=t.match(/rgba\(([^)]+)\)/)[1]).split(/ *, */).map((t,e)=>"%"===t.slice(-1)?3===e?parseInt(t)/100:parseInt(t)/100*255:Number(t));return{r:e[0],g:e[1],b:e[2],a:e[3]}}},_hex8ColorToRGBA(t){if("#"===t[0]&&9===t.length)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("#"===t[0]&&7===t.length)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("#"===t[0]&&5===t.length)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("#"===t[0]&&4===t.length)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){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(t)){const[e,...i]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t),r=Number(i[0])/360,s=Number(i[1])/100,n=Number(i[2])/100;let o,a,h;if(0===s)return h=255*n,{r:Math.round(h),g:Math.round(h),b:Math.round(h),a:1};o=n<.5?n*(1+s):n+s-n*s;const l=2*n-o,d=[0,0,0];for(let t=0;t<3;t++)a=r+1/3*-(t-1),a<0&&a++,a>1&&a--,h=6*a<1?l+6*(o-l)*a:2*a<1?o:3*a<2?l+(o-l)*(2/3-a)*6:l,d[t]=255*h;return{r:Math.round(d[0]),g:Math.round(d[1]),b:Math.round(d[2]),a:1}}},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*r,radToDeg:t=>t*s,_degToRad:e=>(t.Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),t.Util.degToRad(e)),_radToDeg:e=>(t.Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),t.Util.radToDeg(e)),_getRotation:i=>e.Konva.angleDeg?t.Util.radToDeg(i):i,_capitalize:t=>t.charAt(0).toUpperCase()+t.slice(1),throw(t){throw new Error(n+t)},error(t){console.error(n+t)},warn(t){e.Konva.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,r,s,n){let o,a,h;const l=(t-i)*(t-i)+(e-r)*(e-r);if(0==l)o=t,a=e,h=(s-i)*(s-i)+(n-r)*(n-r);else{const d=((s-t)*(i-t)+(n-e)*(r-e))/l;d<0?(o=t,a=e,h=(t-s)*(t-s)+(e-n)*(e-n)):d>1?(o=i,a=r,h=(i-s)*(i-s)+(r-n)*(r-n)):(o=t+d*(i-t),a=e+d*(r-e),h=(o-s)*(o-s)+(a-n)*(a-n))}return[o,a,h]},_getProjectionToLine(e,i,r){const s=t.Util.cloneObject(e);let n=Number.MAX_VALUE;return i.forEach(function(o,a){if(!r&&a===i.length-1)return;const h=i[(a+1)%i.length],l=t.Util._getProjectionToSegment(o.x,o.y,h.x,h.y,e.x,e.y),d=l[0],c=l[1],u=l[2];u<n&&(s.x=d,s.y=c,n=u)}),s},_prepareArrayForTween(e,i,r){const s=[],n=[];if(e.length>i.length){const t=i;i=e,e=t}for(let t=0;t<e.length;t+=2)s.push({x:e[t],y:e[t+1]});for(let t=0;t<i.length;t+=2)n.push({x:i[t],y:i[t+1]});const o=[];return n.forEach(function(e){const i=t.Util._getProjectionToLine(e,s,r);o.push(i.x),o.push(i.y)}),o},_prepareToStringify(e){let i;e.visitedByCircularReferenceRemoval=!0;for(const r in e)if(e.hasOwnProperty(r)&&e[r]&&"object"==typeof e[r])if(i=Object.getOwnPropertyDescriptor(e,r),e[r].visitedByCircularReferenceRemoval||t.Util._isElement(e[r])){if(!i.configurable)return null;delete e[r]}else if(null===t.Util._prepareToStringify(e[r])){if(!i.configurable)return null;delete e[r]}return delete e.visitedByCircularReferenceRemoval,e},_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){e.Konva.releaseCanvasOnDestroy&&t.forEach(t=>{t.width=0,t.height=0})},drawRoundedRectPath(t,e,i,r){let s=0,n=0,o=0,a=0;"number"==typeof r?s=n=o=a=Math.min(r,e/2,i/2):(s=Math.min(r[0]||0,e/2,i/2),n=Math.min(r[1]||0,e/2,i/2),a=Math.min(r[2]||0,e/2,i/2),o=Math.min(r[3]||0,e/2,i/2)),t.moveTo(s,0),t.lineTo(e-n,0),t.arc(e-n,n,n,3*Math.PI/2,0,!1),t.lineTo(e,i-a),t.arc(e-a,i-a,a,0,Math.PI/2,!1),t.lineTo(o,i),t.arc(o,i-o,o,Math.PI/2,Math.PI,!1),t.lineTo(0,s),t.arc(s,s,s,Math.PI,3*Math.PI/2,!1)}}}(d)),d}var u,g,f={},p={},_={};function m(){if(u)return _;u=1,Object.defineProperty(_,"__esModule",{value:!0}),_.HitContext=_.SceneContext=_.Context=void 0;const t=c(),e=h();const i=["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 r=class{constructor(t){this.canvas=t,e.Konva.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(e,i){let r,s,n,o,a=this.traceArr,h=a.length,l="";for(r=0;r<h;r++)s=a[r],n=s.method,n?(o=s.args,l+=n,e?l+="()":t.Util._isArray(o[0])?l+="(["+o.join(",")+"])":(i&&(o=o.map(t=>"number"==typeof t?Math.floor(t):t)),l+="("+o.join(",")+")")):(l+=s.property,e||(l+="="+s.val)),l+=";";return l}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)}setAttr(t,e){this._context[t]=e}arc(t,e,i,r,s,n){this._context.arc(t,e,i,r,s,n)}arcTo(t,e,i,r,s){this._context.arcTo(t,e,i,r,s)}beginPath(){this._context.beginPath()}bezierCurveTo(t,e,i,r,s,n){this._context.bezierCurveTo(t,e,i,r,s,n)}clearRect(t,e,i,r){this._context.clearRect(t,e,i,r)}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,r){return this._context.createLinearGradient(t,e,i,r)}createPattern(t,e){return this._context.createPattern(t,e)}createRadialGradient(t,e,i,r,s,n){return this._context.createRadialGradient(t,e,i,r,s,n)}drawImage(t,e,i,r,s,n,o,a,h){const l=arguments,d=this._context;3===l.length?d.drawImage(t,e,i):5===l.length?d.drawImage(t,e,i,r,s):9===l.length&&d.drawImage(t,e,i,r,s,n,o,a,h)}ellipse(t,e,i,r,s,n,o,a){this._context.ellipse(t,e,i,r,s,n,o,a)}isPointInPath(t,e,i,r){return i?this._context.isPointInPath(i,t,e,r):this._context.isPointInPath(t,e,r)}fill(...t){this._context.fill.apply(this._context,t)}fillRect(t,e,i,r){this._context.fillRect(t,e,i,r)}strokeRect(t,e,i,r){this._context.strokeRect(t,e,i,r)}fillText(t,e,i,r){r?this._context.fillText(t,e,i,r):this._context.fillText(t,e,i)}measureText(t){return this._context.measureText(t)}getImageData(t,e,i,r){return this._context.getImageData(t,e,i,r)}lineTo(t,e){this._context.lineTo(t,e)}moveTo(t,e){this._context.moveTo(t,e)}rect(t,e,i,r){this._context.rect(t,e,i,r)}roundRect(t,e,i,r,s){this._context.roundRect(t,e,i,r,s)}putImageData(t,e,i){this._context.putImageData(t,e,i)}quadraticCurveTo(t,e,i,r){this._context.quadraticCurveTo(t,e,i,r)}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,r,s,n){this._context.setTransform(t,e,i,r,s,n)}stroke(t){t?this._context.stroke(t):this._context.stroke()}strokeText(t,e,i,r){this._context.strokeText(t,e,i,r)}transform(t,e,i,r,s,n){this._context.transform(t,e,i,r,s,n)}translate(t,e){this._context.translate(t,e)}_enableTrace(){let e,r,s=this,n=i.length,o=this.setAttr;const a=function(e){let i,n=s[e];s[e]=function(){return r=function(e){const i=[],r=e.length,s=t.Util;for(let t=0;t<r;t++){let r=e[t];s._isNumber(r)?r=Math.round(1e3*r)/1e3:s._isString(r)||(r+=""),i.push(r)}return i}(Array.prototype.slice.call(arguments,0)),i=n.apply(s,arguments),s._trace({method:e,args:r}),i}};for(e=0;e<n;e++)a(i[e]);s.setAttr=function(){o.apply(s,arguments);const t=arguments[0];let e=arguments[1];"shadowOffsetX"!==t&&"shadowOffsetY"!==t&&"shadowBlur"!==t||(e/=this.canvas.getPixelRatio()),s._trace({property:t,val:e})}}_applyGlobalCompositeOperation(t){const e=t.attrs.globalCompositeOperation;!e||"source-over"===e||this.setAttr("globalCompositeOperation",e)}};_.Context=r,["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"].forEach(function(t){Object.defineProperty(r.prototype,t,{get(){return this._context[t]},set(e){this._context[t]=e}})});_.SceneContext=class extends r{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){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 r=t.getFillPatternImage();if(r&&"pattern"===i)return void this._fillPattern(t);const s=t.getFillLinearGradientColorStops();if(s&&"linear-gradient"===i)return void this._fillLinearGradient(t);const n=t.getFillRadialGradientColorStops();n&&"radial-gradient"===i?this._fillRadialGradient(t):e?this._fillColor(t):r?this._fillPattern(t):s?this._fillLinearGradient(t):n&&this._fillRadialGradient(t)}_strokeLinearGradient(t){const e=t.getStrokeLinearGradientStartPoint(),i=t.getStrokeLinearGradientEndPoint(),r=t.getStrokeLinearGradientColorStops(),s=this.createLinearGradient(e.x,e.y,i.x,i.y);if(r){for(let t=0;t<r.length;t+=2)s.addColorStop(r[t],r[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,r;const s=null!==(e=t.getShadowRGBA())&&void 0!==e?e:"black",n=null!==(i=t.getShadowBlur())&&void 0!==i?i:5,o=null!==(r=t.getShadowOffset())&&void 0!==r?r:{x:0,y:0},a=t.getAbsoluteScale(),h=this.canvas.getPixelRatio(),l=a.x*h,d=a.y*h;this.setAttr("shadowColor",s),this.setAttr("shadowBlur",n*Math.min(Math.abs(l),Math.abs(d))),this.setAttr("shadowOffsetX",o.x*l),this.setAttr("shadowOffsetY",o.y*d)}};return _.HitContext=class extends r{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(),r="auto"===i?t.strokeWidth():i;this.setAttr("lineWidth",r),this.setAttr("strokeStyle",t.colorKey),t._strokeFuncHit(this),e||this.restore()}}},_}function y(){if(g)return p;g=1,Object.defineProperty(p,"__esModule",{value:!0}),p.HitCanvas=p.SceneCanvas=p.Canvas=void 0;const t=c(),e=m(),i=h();let r;let s=class{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;const s=(e||{}).pixelRatio||i.Konva.pixelRatio||function(){if(r)return r;const e=t.Util.createCanvasElement(),s=e.getContext("2d");return r=(i.Konva._global.devicePixelRatio||1)/(s.webkitBackingStorePixelRatio||s.mozBackingStorePixelRatio||s.msBackingStorePixelRatio||s.oBackingStorePixelRatio||s.backingStorePixelRatio||1),t.Util.releaseCanvas(e),r}();this.pixelRatio=s,this._canvas=t.Util.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)}toDataURL(e,i){try{return this._canvas.toDataURL(e,i)}catch(e){try{return this._canvas.toDataURL()}catch(e){return t.Util.error("Unable to get data URL. "+e.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}};p.Canvas=s;p.SceneCanvas=class extends s{constructor(t={width:0,height:0,willReadFrequently:!1}){super(t),this.context=new e.SceneContext(this,{willReadFrequently:t.willReadFrequently}),this.setSize(t.width,t.height)}};return p.HitCanvas=class extends s{constructor(t={width:0,height:0}){super(t),this.hitCanvas=!0,this.context=new e.HitContext(this),this.setSize(t.width,t.height)}},p}var v,x={};function w(){return v||(v=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DD=void 0;const e=h(),i=c();t.DD={get isDragging(){let e=!1;return t.DD._dragElements.forEach(t=>{"dragging"===t.dragStatus&&(e=!0)}),e},justDragged:!1,get node(){let e;return t.DD._dragElements.forEach(t=>{e=t.node}),e},_dragElements:new Map,_drag(e){const r=[];t.DD._dragElements.forEach((t,s)=>{const{node:n}=t,o=n.getStage();o.setPointersPositions(e),void 0===t.pointerId&&(t.pointerId=i.Util._getFirstPointerId(e));const a=o._changedPointerPositions.find(e=>e.id===t.pointerId);if(a){if("dragging"!==t.dragStatus){const i=n.dragDistance();if(Math.max(Math.abs(a.x-t.startPointerPos.x),Math.abs(a.y-t.startPointerPos.y))<i)return;if(n.startDrag({evt:e}),!n.isDragging())return}n._setDragPosition(e,t),r.push(n)}}),r.forEach(t=>{t.fire("dragmove",{type:"dragmove",target:t,evt:e},!0)})},_endDragBefore(i){const r=[];t.DD._dragElements.forEach(s=>{const{node:n}=s,o=n.getStage();i&&o.setPointersPositions(i);if(!o._changedPointerPositions.find(t=>t.id===s.pointerId))return;"dragging"!==s.dragStatus&&"stopped"!==s.dragStatus||(t.DD.justDragged=!0,e.Konva._mouseListenClick=!1,e.Konva._touchListenClick=!1,e.Konva._pointerListenClick=!1,s.dragStatus="stopped");const a=s.node.getLayer()||s.node instanceof e.Konva.Stage&&s.node;a&&-1===r.indexOf(a)&&r.push(a)}),r.forEach(t=>{t.draw()})},_endDragAfter(e){t.DD._dragElements.forEach((i,r)=>{"stopped"===i.dragStatus&&i.node.fire("dragend",{type:"dragend",target:i.node,evt:e},!0),"dragging"!==i.dragStatus&&t.DD._dragElements.delete(r)})}},e.Konva.isBrowser&&(window.addEventListener("mouseup",t.DD._endDragBefore,!0),window.addEventListener("touchend",t.DD._endDragBefore,!0),window.addEventListener("touchcancel",t.DD._endDragBefore,!0),window.addEventListener("mousemove",t.DD._drag),window.addEventListener("touchmove",t.DD._drag),window.addEventListener("mouseup",t.DD._endDragAfter,!1),window.addEventListener("touchend",t.DD._endDragAfter,!1),window.addEventListener("touchcancel",t.DD._endDragAfter,!1))}(x)),x}var b,S,C,T={},A={};function k(){if(b)return A;b=1,Object.defineProperty(A,"__esModule",{value:!0}),A.RGBComponent=function(t){if(t>255)return 255;if(t<0)return 0;return Math.round(t)},A.alphaComponent=function(t){if(t>1)return 1;if(t<1e-4)return 1e-4;return t},A.getNumberValidator=function(){if(t.Konva.isUnminified)return function(t,r){return e.Util._isNumber(t)||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a number.'),t}},A.getNumberOrArrayOfNumbersValidator=function(r){if(t.Konva.isUnminified)return function(t,s){let n=e.Util._isNumber(t),o=e.Util._isArray(t)&&t.length==r;return n||o||e.Util.warn(i(t)+' is a not valid value for "'+s+'" attribute. The value should be a number or Array<number>('+r+")"),t}},A.getNumberOrAutoValidator=function(){if(t.Konva.isUnminified)return function(t,r){return e.Util._isNumber(t)||"auto"===t||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a number or "auto".'),t}},A.getStringValidator=function(){if(t.Konva.isUnminified)return function(t,r){return e.Util._isString(t)||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a string.'),t}},A.getStringOrGradientValidator=function(){if(t.Konva.isUnminified)return function(t,r){const s=e.Util._isString(t),n="[object CanvasGradient]"===Object.prototype.toString.call(t)||t&&t.addColorStop;return s||n||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a string or a native gradient.'),t}},A.getFunctionValidator=function(){if(t.Konva.isUnminified)return function(t,r){return e.Util._isFunction(t)||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a function.'),t}},A.getNumberArrayValidator=function(){if(t.Konva.isUnminified)return function(t,r){const s=Int8Array?Object.getPrototypeOf(Int8Array):null;return s&&t instanceof s||(e.Util._isArray(t)?t.forEach(function(t){e.Util._isNumber(t)||e.Util.warn('"'+r+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")}):e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a array of numbers.')),t}},A.getBooleanValidator=function(){if(t.Konva.isUnminified)return function(t,r){return!0===t||!1===t||e.Util.warn(i(t)+' is a not valid value for "'+r+'" attribute. The value should be a boolean.'),t}},A.getComponentValidator=function(r){if(t.Konva.isUnminified)return function(t,s){return null==t||e.Util.isObject(t)||e.Util.warn(i(t)+' is a not valid value for "'+s+'" attribute. The value should be an object with properties '+r),t}};const t=h(),e=c();function i(t){return e.Util._isString(t)?'"'+t+'"':"[object Number]"===Object.prototype.toString.call(t)||e.Util._isBoolean(t)?t:Object.prototype.toString.call(t)}return A}function P(){return S||(S=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Factory=void 0;const e=c(),i=k(),r="get",s="set";t.Factory={addGetterSetter(e,i,r,s,n){t.Factory.addGetter(e,i,r),t.Factory.addSetter(e,i,s,n),t.Factory.addOverloadedGetterSetter(e,i)},addGetter(t,i,s){const n=r+e.Util._capitalize(i);t.prototype[n]=t.prototype[n]||function(){const t=this.attrs[i];return void 0===t?s:t}},addSetter(i,r,n,o){const a=s+e.Util._capitalize(r);i.prototype[a]||t.Factory.overWriteSetter(i,r,n,o)},overWriteSetter(t,i,r,n){const o=s+e.Util._capitalize(i);t.prototype[o]=function(t){return r&&null!=t&&(t=r.call(this,t,i)),this._setAttr(i,t),n&&n.call(this),this}},addComponentsGetterSetter(n,o,a,h,l){const d=a.length,c=e.Util._capitalize,u=r+c(o),g=s+c(o);n.prototype[u]=function(){const t={};for(let e=0;e<d;e++){const i=a[e];t[i]=this.getAttr(o+c(i))}return t};const f=(0,i.getComponentValidator)(a);n.prototype[g]=function(t){const e=this.attrs[o];h&&(t=h.call(this,t,o)),f&&f.call(this,t,o);for(const e in t)t.hasOwnProperty(e)&&this._setAttr(o+c(e),t[e]);return t||a.forEach(t=>{this._setAttr(o+c(t),void 0)}),this._fireChangeEvent(o,e,t),l&&l.call(this),this},t.Factory.addOverloadedGetterSetter(n,o)},addOverloadedGetterSetter(t,i){const n=e.Util._capitalize(i),o=s+n,a=r+n;t.prototype[i]=function(){return arguments.length?(this[o](arguments[0]),this):this[a]()}},addDeprecatedGetterSetter(i,s,n,o){e.Util.error("Adding deprecated "+s);const a=r+e.Util._capitalize(s),h=s+" property is deprecated and will be removed soon. Look at Konva change log for more information.";i.prototype[a]=function(){e.Util.error(h);const t=this.attrs[s];return void 0===t?n:t},t.Factory.addSetter(i,s,o,function(){e.Util.error(h)}),t.Factory.addOverloadedGetterSetter(i,s)},backCompat(t,i){e.Util.each(i,function(i,n){const o=t.prototype[n],a=r+e.Util._capitalize(i),h=s+e.Util._capitalize(i);function l(){o.apply(this,arguments),e.Util.error('"'+i+'" method is deprecated and will be removed soon. Use ""'+n+'" instead.')}t.prototype[i]=l,t.prototype[a]=l,t.prototype[h]=l})},afterSetFilter(){this._filterUpToDate=!1}}}(T)),T}function M(){if(C)return f;C=1,Object.defineProperty(f,"__esModule",{value:!0}),f.Node=void 0;const t=y(),e=w(),i=P(),r=h(),s=c(),n=k(),o="absoluteOpacity",a="allEventListeners",l="absoluteTransform",d="absoluteScale",u="canvas",g="listening",p="Shape",_=" ",m="stage",v="transform",x="visible",b=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(_);let S=1,T=class i{constructor(t){this._id=S++,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!==v&&t!==l||!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===v||t===l)&&!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(_);this.on(i,()=>{this._clearCache(t)}),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,i)}_getCanvasCache(){return this._cache.get(u)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===l&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(u)){const{scene:t,filter:e,hit:i,buffer:r}=this._cache.get(u);s.Util.releaseCanvas(t,e,i,r),this._cache.delete(u)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){const i=e||{};let r={};void 0!==i.x&&void 0!==i.y&&void 0!==i.width&&void 0!==i.height||(r=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let n=Math.ceil(i.width||r.width),a=Math.ceil(i.height||r.height),h=i.pixelRatio,l=void 0===i.x?Math.floor(r.x):i.x,c=void 0===i.y?Math.floor(r.y):i.y,g=i.offset||0,f=i.drawBorder||!1,p=i.hitCanvasPixelRatio||1;if(!n||!a)return void s.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");n+=2*g+(Math.abs(Math.round(r.x)-l)>.5?1:0),a+=2*g+(Math.abs(Math.round(r.y)-c)>.5?1:0),l-=g,c-=g;const _=new t.SceneCanvas({pixelRatio:h,width:n,height:a}),m=new t.SceneCanvas({pixelRatio:h,width:0,height:0,willReadFrequently:!0}),y=new t.HitCanvas({pixelRatio:p,width:n,height:a}),v=_.getContext(),x=y.getContext(),w=new t.SceneCanvas({width:_.width/_.pixelRatio+Math.abs(l),height:_.height/_.pixelRatio+Math.abs(c),pixelRatio:_.pixelRatio}),b=w.getContext();return y.isCache=!0,_.isCache=!0,this._cache.delete(u),this._filterUpToDate=!1,!1===i.imageSmoothingEnabled&&(_.getContext()._context.imageSmoothingEnabled=!1,m.getContext()._context.imageSmoothingEnabled=!1),v.save(),x.save(),b.save(),v.translate(-l,-c),x.translate(-l,-c),b.translate(-l,-c),w.x=l,w.y=c,this._isUnderCache=!0,this._clearSelfAndDescendantCache(o),this._clearSelfAndDescendantCache(d),this.drawScene(_,this,w),this.drawHit(y,this),this._isUnderCache=!1,v.restore(),x.restore(),f&&(v.save(),v.beginPath(),v.rect(0,0,n,a),v.closePath(),v.setAttr("strokeStyle","red"),v.setAttr("lineWidth",5),v.stroke(),v.restore()),this._cache.set(u,{scene:_,filter:m,hit:y,buffer:w,x:l,y:c}),this._requestDraw(),this}isCached(){return this._cache.has(u)}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 r=1/0,s=1/0,n=-1/0,o=-1/0;const a=this.getAbsoluteTransform(e);return i.forEach(function(t){const e=a.point(t);void 0===r&&(r=n=e.x,s=o=e.y),r=Math.min(r,e.x),s=Math.min(s,e.y),n=Math.max(n,e.x),o=Math.max(o,e.y)}),{x:r,y:s,width:n-r,height:o-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(),r=i.pixelRatio;t.drawImage(i._canvas,0,0,i.width/r,i.height/r),t.restore()}_drawCachedHitCanvas(t){const e=this._getCanvasCache(),i=e.hit;t.save(),t.translate(e.x,e.y),t.drawImage(i._canvas,0,0,i.width/i.pixelRatio,i.height/i.pixelRatio),t.restore()}_getCachedSceneCanvas(){let t,e,i,r,n=this.filters(),o=this._getCanvasCache(),a=o.scene,h=o.filter,l=h.getContext();if(n){if(!this._filterUpToDate){const o=a.pixelRatio;h.setSize(a.width/a.pixelRatio,a.height/a.pixelRatio);try{for(t=n.length,l.clear(),l.drawImage(a._canvas,0,0,a.getWidth()/o,a.getHeight()/o),e=l.getImageData(0,0,h.getWidth(),h.getHeight()),i=0;i<t;i++)r=n[i],"function"==typeof r?(r.call(this,e),l.putImageData(e,0,0)):s.Util.error("Filter should be type of function, but got "+typeof r+" instead. Please check correct filters")}catch(t){s.Util.error("Unable to apply filter. "+t.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return h}return a}on(t,e){if(this._cache&&this._cache.delete(a),3===arguments.length)return this._delegate.apply(this,arguments);const i=t.split(_);for(let t=0;t<i.length;t++){const r=i[t].split("."),s=r[0],n=r[1]||"";this.eventListeners[s]||(this.eventListeners[s]=[]),this.eventListeners[s].push({name:n,handler:e})}return this}off(t,e){let i,r,s,n,o,h,l=(t||"").split(_),d=l.length;if(this._cache&&this._cache.delete(a),!t)for(r in this.eventListeners)this._off(r);for(i=0;i<d;i++)if(s=l[i],n=s.split("."),o=n[0],h=n[1],o)this.eventListeners[o]&&this._off(o,h,e);else for(r in this.eventListeners)this._off(r,h,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 r=this;this.on(t,function(t){const n=t.target.findAncestors(e,!0,r);for(let e=0;e<n.length;e++)(t=s.Util.cloneObject(t)).currentTarget=n[e],i.call(n[e],t)})}remove(){return this.isDragging()&&this.stopDrag(),e.DD._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(l),this._clearSelfAndDescendantCache(o),this._clearSelfAndDescendantCache(d),this._clearSelfAndDescendantCache(m),this._clearSelfAndDescendantCache(x),this._clearSelfAndDescendantCache(g)}_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"+s.Util._capitalize(t);return s.Util._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"+s.Util._capitalize(e),s.Util._isFunction(this[i])?this[i](t[e]):this._setAttr(e,t[e]))}),this}isListening(){return this._getCache(g,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(x,this._isVisible)}_isVisible(t){if(!this.visible())return!1;const e=this.getParent();return!e||e===t||this===t||e._isVisible(t)}shouldDrawHit(t,i=!1){if(t)return this._isVisible(t)&&this._isListening(t);const s=this.getLayer();let n=!1;e.DD._dragElements.forEach(t=>{"dragging"===t.dragStatus&&("Stage"===t.node.nodeType||t.node.getLayer()===s)&&(n=!0)});const o=!i&&!r.Konva.hitOnDragEnabled&&(n||r.Konva.isTransforming());return this.isListening()&&this.isVisible()&&!o}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let t,e,i,r,s=this.getDepth(),n=this,o=0;const a=this.getStage();return"Stage"!==n.nodeType&&a&&function a(h){for(t=[],e=h.length,i=0;i<e;i++)r=h[i],o++,r.nodeType!==p&&(t=t.concat(r.getChildren().slice())),r._id===n._id&&(i=e);t.length>0&&t[0].getDepth()<=s&&a(t)}(a.getChildren()),o}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(v),this._clearSelfAndDescendantCache(l)),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 r=this.getAbsoluteTransform(t).getMatrix(),n=new s.Transform,o=this.offset();return n.m=r.slice(),n.translate(o.x,o.y),n.getTranslation()}setAbsolutePosition(t){const{x:e,y:i,...r}=this._clearTransform();this.attrs.x=e,this.attrs.y=i,this._clearCache(v);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(r),this.setPosition({x:t.x,y:t.y}),this._clearCache(v),this._clearSelfAndDescendantCache(l),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,r=this.x(),s=this.y();return void 0!==e&&(r+=e),void 0!==i&&(s+=i),this.setPosition({x:r,y:s}),this}_eachAncestorReverse(t,e){let i,r,s=[],n=this.getParent();if(!e||e._id!==this._id){for(s.unshift(this);n&&(!e||n._id!==e._id);)s.unshift(n),n=n.parent;for(i=s.length,r=0;r<i;r++)t(s[r])}}rotate(t){return this.rotation(this.rotation()+t),this}moveToTop(){if(!this.parent)return s.Util.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 s.Util.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 s.Util.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 s.Util.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 s.Util.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&&s.Util.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(o,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,r,n,o=this.getAttrs();const a={attrs:{},className:this.getClassName()};for(t in o)e=o[t],n=s.Util.isObject(e)&&!s.Util._isPlainObject(e)&&!s.Util._isArray(e),n||(i="function"==typeof this[t]&&this[t],delete o[t],r=i?i.call(this):null,o[t]=e,r!==e&&(a.attrs[t]=e));return s.Util._prepareToStringify(a)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,e,i){const r=[];e&&this._isMatch(t)&&r.push(this);let s=this.parent;for(;s;){if(s===i)return r;s._isMatch(t)&&r.push(s),s=s.parent}return r}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,r=t.replace(/ /g,"").split(","),n=r.length;for(e=0;e<n;e++)if(i=r[e],s.Util.isValidSelector(i)||(s.Util.warn('Selector "'+i+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),s.Util.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),s.Util.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(m,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(l,this._getAbsoluteTransform)}_getAbsoluteTransform(t){let e;if(t)return e=new s.Transform,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(l)||new s.Transform,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,r=this.attrs.offsetX||0,s=this.attrs.offsetY||0;e.translate(t-r,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(v,this._getTransform)}_getTransform(){var t,e;const i=this._cache.get(v)||new s.Transform;i.reset();const n=this.x(),o=this.y(),a=r.Konva.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,u=this.attrs.offsetX||0,g=this.attrs.offsetY||0;return 0===n&&0===o||i.translate(n,o),0!==a&&i.rotate(a),0===d&&0===c||i.skew(d,c),1===h&&1===l||i.scale(h,l),0===u&&0===g||i.translate(-1*u,-1*g),i.dirty=!1,i}clone(t){let e,i,r,n,o,a=s.Util.cloneObject(this.attrs);for(e in t)a[e]=t[e];const h=new this.constructor(a);for(e in this.eventListeners)for(i=this.eventListeners[e],r=i.length,n=0;n<r;n++)o=i[n],o.name.indexOf("konva")<0&&(h.eventListeners[e]||(h.eventListeners[e]=[]),h.eventListeners[e].push(o));return h}_toKonvaCanvas(e){e=e||{};const i=this.getClientRect(),r=this.getStage(),s=void 0!==e.x?e.x:Math.floor(i.x),n=void 0!==e.y?e.y:Math.floor(i.y),o=e.pixelRatio||1,a=new t.SceneCanvas({width:e.width||Math.ceil(i.width)||(r?r.width():0),height:e.height||Math.ceil(i.height)||(r?r.height():0),pixelRatio:o}),h=a.getContext(),l=new t.SceneCanvas({width:a.width/a.pixelRatio+Math.abs(s),height:a.height/a.pixelRatio+Math.abs(n),pixelRatio:a.pixelRatio});return!1===e.imageSmoothingEnabled&&(h._context.imageSmoothingEnabled=!1),h.save(),(s||n)&&h.translate(-1*s,-1*n),this.drawScene(a,void 0,l),h.restore(),a}toCanvas(t){return this._toKonvaCanvas(t)._canvas}toDataURL(t){const e=(t=t||{}).mimeType||null,i=t.quality||null,r=this._toKonvaCanvas(t).toDataURL(e,i);return t.callback&&t.callback(r),r}toImage(t){return new Promise((e,i)=>{try{const i=null==t?void 0:t.callback;i&&delete t.callback,s.Util._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():r.Konva.dragDistance}_off(t,e,i){let r,s,n,o=this.eventListeners[t];for(r=0;r<o.length;r++)if(s=o[r].name,n=o[r].handler,!("konva"===s&&"konva"!==e||e&&s!==e||i&&i!==n)){if(o.splice(r,1),0===o.length){delete this.eventListeners[t];break}r--}}_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"+s.Util._capitalize(t)];return s.Util._isFunction(i)?i.call(this,e):this._setAttr(t,e),this}_requestDraw(){if(r.Konva.autoDrawEnabled){const t=this.getLayer()||this.getStage();null==t||t.batchDraw()}}_setAttr(t,e){const i=this.attrs[t];(i!==e||s.Util.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 r;void 0!==i&&(r=this.attrs[t],r||(this.attrs[t]=this.getAttr(t)),this.attrs[t][e]=i,this._fireChangeEvent(t,r,i))}_fireAndBubble(t,e,i){e&&this.nodeType===p&&(e.target=this);const r=["mouseenter","mouseleave","pointerenter","pointerleave","touchenter","touchleave"];if(!(-1!==r.indexOf(t)&&(i&&(this===i||this.isAncestorOf&&this.isAncestorOf(i))||"Stage"===this.nodeType&&!i))){this._fire(t,e);const s=-1!==r.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,r;const s=null!==(e=this._cache.get(a))&&void 0!==e?e:{};let n=null==s?void 0:s[t];if(void 0===n){n=[];let e=Object.getPrototypeOf(this);for(;e;){const s=null!==(r=null===(i=e.eventListeners)||void 0===i?void 0:i[t])&&void 0!==r?r:[];n.push(...s),e=Object.getPrototypeOf(e)}s[t]=n,this._cache.set(a,s)}return n}_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 r=this.eventListeners[t];if(r)for(let t=0;t<r.length;t++)r[t].handler.call(this,e)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(t){const i=t?t.pointerId:void 0,r=this.getStage(),s=this.getAbsolutePosition();if(!r)return;const n=r._getPointerById(i)||r._changedPointerPositions[0]||s;e.DD._dragElements.set(this._id,{node:this,startPointerPos:n,offset:{x:n.x-s.x,y:n.y-s.y},dragStatus:"ready",pointerId:i})}startDrag(t,i=!0){e.DD._dragElements.has(this._id)||this._createDragElement(t);e.DD._dragElements.get(this._id).dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:t&&t.evt},i)}_setDragPosition(t,e){const i=this.getStage()._getPointerById(e.pointerId);if(!i)return;let r={x:i.x-e.offset.x,y:i.y-e.offset.y};const n=this.dragBoundFunc();if(void 0!==n){const e=n.call(this,r,t);e?r=e:s.Util.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}this._lastPos&&this._lastPos.x===r.x&&this._lastPos.y===r.y||(this.setAbsolutePosition(r),this._requestDraw()),this._lastPos=r}stopDrag(t){const i=e.DD._dragElements.get(this._id);i&&(i.dragStatus="stopped"),e.DD._endDragBefore(t),e.DD._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=e.DD._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)||r.Konva.dragButtons.indexOf(t.evt.button)>=0))return;if(this.isDragging())return;let i=!1;e.DD._dragElements.forEach(t=>{this.isAncestorOf(t.node)&&(i=!0)}),i||this._createDragElement(t)})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{this._dragCleanup();if(!this.getStage())return;const t=e.DD._dragElements.get(this._id),i=t&&"dragging"===t.dragStatus,r=t&&"ready"===t.dragStatus;i?this.stopDrag():r&&e.DD._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 s.Util.haveIntersection(i,this.getClientRect())}static create(t,e){return s.Util._isString(t)&&(t=JSON.parse(t)),this._createNode(t,e)}static _createNode(t,e){let n,o,a,h=i.prototype.getClassName.call(t),l=t.children;e&&(t.attrs.container=e),r.Konva[h]||(s.Util.warn('Can not find a node with class name "'+h+'". Fallback to "Shape".'),h="Shape");if(n=new(0,r.Konva[h])(t.attrs),l)for(o=l.length,a=0;a<o;a++)n.add(i._createNode(l[a]));return n}};f.Node=T,T.prototype.nodeType="Node",T.prototype._attrsAffectingSize=[],T.prototype.eventListeners={},T.prototype.on.call(T.prototype,b,function(){this._batchingTransformChange?this._needClearTransformCache=!0:(this._clearCache(v),this._clearSelfAndDescendantCache(l))}),T.prototype.on.call(T.prototype,"visibleChange.konva",function(){this._clearSelfAndDescendantCache(x)}),T.prototype.on.call(T.prototype,"listeningChange.konva",function(){this._clearSelfAndDescendantCache(g)}),T.prototype.on.call(T.prototype,"opacityChange.konva",function(){this._clearSelfAndDescendantCache(o)});const A=i.Factory.addGetterSetter;return A(T,"zIndex"),A(T,"absolutePosition"),A(T,"position"),A(T,"x",0,(0,n.getNumberValidator)()),A(T,"y",0,(0,n.getNumberValidator)()),A(T,"globalCompositeOperation","source-over",(0,n.getStringValidator)()),A(T,"opacity",1,(0,n.getNumberValidator)()),A(T,"name","",(0,n.getStringValidator)()),A(T,"id","",(0,n.getStringValidator)()),A(T,"rotation",0,(0,n.getNumberValidator)()),i.Factory.addComponentsGetterSetter(T,"scale",["x","y"]),A(T,"scaleX",1,(0,n.getNumberValidator)()),A(T,"scaleY",1,(0,n.getNumberValidator)()),i.Factory.addComponentsGetterSetter(T,"skew",["x","y"]),A(T,"skewX",0,(0,n.getNumberValidator)()),A(T,"skewY",0,(0,n.getNumberValidator)()),i.Factory.addComponentsGetterSetter(T,"offset",["x","y"]),A(T,"offsetX",0,(0,n.getNumberValidator)()),A(T,"offsetY",0,(0,n.getNumberValidator)()),A(T,"dragDistance",void 0,(0,n.getNumberValidator)()),A(T,"width",0,(0,n.getNumberValidator)()),A(T,"height",0,(0,n.getNumberValidator)()),A(T,"listening",!0,(0,n.getBooleanValidator)()),A(T,"preventDefault",!0,(0,n.getBooleanValidator)()),A(T,"filters",void 0,function(t){return this._filterUpToDate=!1,t}),A(T,"visible",!0,(0,n.getBooleanValidator)()),A(T,"transformsEnabled","all",(0,n.getStringValidator)()),A(T,"size"),A(T,"dragBoundFunc"),A(T,"draggable",!1,(0,n.getBooleanValidator)()),i.Factory.backCompat(T,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"}),f}var R,E={};function F(){if(R)return E;R=1,Object.defineProperty(E,"__esModule",{value:!0}),E.Container=void 0;const t=P(),e=M(),i=k();let r=class extends e.Node{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(r=>{const s=r._isMatch(t);return s&&i.push(r),!(!s||!e)}),i}_descendants(t){let e=!1;const i=this.getChildren();for(const r of i){if(e=t(r),e)return!0;if(r.hasChildren()&&(e=r._descendants(t),e))return!0}return!1}toObject(){const t=e.Node.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 i=e.Node.prototype.clone.call(this,t);return this.getChildren().forEach(function(t){i.add(t.clone())}),i}getAllIntersections(t){const e=[];return this.find("Shape").forEach(i=>{i.isVisible()&&i.intersects(t)&&e.push(i)}),e}_clearSelfAndDescendantCache(t){var e;super._clearSelfAndDescendantCache(t),this.isCached()||null===(e=this.children)||void 0===e||e.forEach(function(e){e._clearSelfAndDescendantCache(t)})}_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 r=this.getLayer(),s=t||r&&r.getCanvas(),n=s&&s.getContext(),o=this._getCanvasCache(),a=o&&o.scene,h=s&&s.isCache;if(!this.isVisible()&&!h)return this;if(a){n.save();const t=this.getAbsoluteTransform(e).getMatrix();n.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(n),n.restore()}else this._drawChildren("drawScene",s,e,i);return this}drawHit(t,e){if(!this.shouldDrawHit(e))return this;const i=this.getLayer(),r=t||i&&i.hitCanvas,s=r&&r.getContext(),n=this._getCanvasCache();if(n&&n.hit){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),s.restore()}else this._drawChildren("drawHit",r,e);return this}_drawChildren(t,e,i,r){var s;const n=e&&e.getContext(),o=this.clipWidth(),a=this.clipHeight(),h=this.clipFunc(),l="number"==typeof o&&"number"==typeof a||h,d=i===this;if(l){n.save();const t=this.getAbsoluteTransform(i);let e,r=t.getMatrix();if(n.transform(r[0],r[1],r[2],r[3],r[4],r[5]),n.beginPath(),h)e=h.call(this,n,this);else{const t=this.clipX(),e=this.clipY();n.rect(t||0,e||0,o,a)}n.clip.apply(n,e),r=t.copy().invert().getMatrix(),n.transform(r[0],r[1],r[2],r[3],r[4],r[5])}const c=!d&&"source-over"!==this.globalCompositeOperation()&&"drawScene"===t;c&&(n.save(),n._applyGlobalCompositeOperation(this)),null===(s=this.children)||void 0===s||s.forEach(function(s){s[t](e,i,r)}),c&&n.restore(),l&&n.restore()}getClientRect(t={}){var e;const i=t.skipTransform,r=t.relativeTo;let s,n,o,a,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,n=i.y,o=i.x+i.width,a=i.y+i.height):(s=Math.min(s,i.x),n=Math.min(n,i.y),o=Math.max(o,i.x+i.width),a=Math.max(a,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:n,width:o-s,height:a-n}:{x:0,y:0,width:0,height:0},i?h:this._transformedRect(h,r)}};return E.Container=r,t.Factory.addComponentsGetterSetter(r,"clip",["x","y","width","height"]),t.Factory.addGetterSetter(r,"clipX",void 0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(r,"clipY",void 0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(r,"clipWidth",void 0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(r,"clipHeight",void 0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(r,"clipFunc"),E}var I,O,L={},D={};function G(){if(I)return D;I=1,Object.defineProperty(D,"__esModule",{value:!0}),D.getCapturedShape=function(t){return e.get(t)},D.createEvent=r,D.hasPointerCapture=function(t,i){return e.get(t)===i},D.setPointerCapture=function(t,n){s(t);if(!n.getStage())return;e.set(t,n),i&&n._fire("gotpointercapture",r(new PointerEvent("gotpointercapture")))},D.releaseCapture=s;const t=h(),e=new Map,i=void 0!==t.Konva._global.PointerEvent;function r(t){return{evt:t,pointerId:t.pointerId}}function s(t,s){const n=e.get(t);if(!n)return;const o=n.getStage();o&&o.content,e.delete(t),i&&n._fire("lostpointercapture",r(new PointerEvent("lostpointercapture")))}return D}var N,W,U={},B={};function z(){return N||(N=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Shape=t.shapes=void 0;const e=h(),i=c(),r=P(),s=M(),n=k(),o=h(),a=G(),l="hasShadow",d="shadowRGBA",u="patternImage",g="linearGradient",f="radialGradient";let p;function _(){return p||(p=i.Util.createCanvasElement().getContext("2d"),p)}t.shapes={};class m extends s.Node{constructor(e){let r;for(super(e);r=i.Util.getRandomColor(),!r||r in t.shapes;);this.colorKey=r,t.shapes[r]=this}getContext(){return i.Util.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return i.Util.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(l,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&0!==this.shadowOpacity()&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(u,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const t=_().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){const r=new i.Transform;r.translate(this.fillPatternX(),this.fillPatternY()),r.rotate(e.Konva.getAngle(this.fillPatternRotation())),r.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),r.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const s=r.getMatrix(),n="undefined"==typeof DOMMatrix?{a:s[0],b:s[1],c:s[2],d:s[3],e:s[4],f:s[5]}:new DOMMatrix(s);t.setTransform(n)}return t}}_getLinearGradient(){return this._getCache(g,this.__getLinearGradient)}__getLinearGradient(){const t=this.fillLinearGradientColorStops();if(t){const e=_(),i=this.fillLinearGradientStartPoint(),r=this.fillLinearGradientEndPoint(),s=e.createLinearGradient(i.x,i.y,r.x,r.y);for(let e=0;e<t.length;e+=2)s.addColorStop(t[e],t[e+1]);return s}}_getRadialGradient(){return this._getCache(f,this.__getRadialGradient)}__getRadialGradient(){const t=this.fillRadialGradientColorStops();if(t){const e=_(),i=this.fillRadialGradientStartPoint(),r=this.fillRadialGradientEndPoint(),s=e.createRadialGradient(i.x,i.y,this.fillRadialGradientStartRadius(),r.x,r.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(d,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;const t=i.Util.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.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 s.Node.prototype.destroy.call(this),delete t.shapes[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(),r=this.hasStroke(),s=1!==this.getAbsoluteOpacity();if(i&&r&&s)return!0;const n=this.hasShadow(),o=this.shadowForStrokeEnabled();return!!(i&&r&&n&&o)}setStrokeHitEnabled(t){i.Util.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 r=t.skipTransform,s=t.relativeTo||e&&this.getStage()||void 0,n=this.getSelfRect(),o=!t.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,a=n.width+o,h=n.height+o,l=!t.skipShadow&&this.hasShadow(),d=l?this.shadowOffsetX():0,c=l?this.shadowOffsetY():0,u=a+Math.abs(d),g=h+Math.abs(c),f=l&&this.shadowBlur()||0,p={width:u+2*f,height:g+2*f,x:-(o/2+f)+Math.min(d,0)+n.x,y:-(o/2+f)+Math.min(c,0)+n.y};return r?p:this._transformedRect(p,s)}drawScene(t,e,i){const r=this.getLayer(),s=(t||r.getCanvas()).getContext(),n=this._getCanvasCache(),o=this.getSceneFunc(),a=this.hasShadow();let h;const l=e===this;if(!this.isVisible()&&!l)return this;if(n){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(!o)return this;if(s.save(),this._useBufferCanvas()){h=this.getStage();const t=i||h.bufferCanvas,r=t.getContext();r.clear(),r.save(),r._applyLineJoin(this);const n=this.getAbsoluteTransform(e).getMatrix();r.transform(n[0],n[1],n[2],n[3],n[4],n[5]),o.call(this,r,this),r.restore();const l=t.pixelRatio;a&&s._applyShadow(this),s._applyOpacity(this),s._applyGlobalCompositeOperation(this),s.drawImage(t._canvas,t.x||0,t.y||0,t.width/l,t.height/l)}else{if(s._applyLineJoin(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)}a&&s._applyShadow(this),o.call(this,s,this)}return s.restore(),this}drawHit(t,e,r=!1){if(!this.shouldDrawHit(e,r))return this;const s=this.getLayer(),n=t||s.hitCanvas,o=n&&n.getContext(),a=this.hitFunc()||this.sceneFunc(),h=this._getCanvasCache(),l=h&&h.hit;if(this.colorKey||i.Util.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()"),l){o.save();const t=this.getAbsoluteTransform(e).getMatrix();return o.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(o),o.restore(),this}if(!a)return this;o.save(),o._applyLineJoin(this);if(!(this===e)){const t=this.getAbsoluteTransform(e).getMatrix();o.transform(t[0],t[1],t[2],t[3],t[4],t[5])}return a.call(this,o,this),o.restore(),this}drawHitFromCache(t=0){const e=this._getCanvasCache(),r=this._getCachedSceneCanvas(),s=e.hit,n=s.getContext(),o=s.getWidth(),a=s.getHeight();n.clear(),n.drawImage(r._canvas,0,0,o,a);try{const e=n.getImageData(0,0,o,a),r=e.data,s=r.length,h=i.Util._hexToRgb(this.colorKey);for(let e=0;e<s;e+=4){r[e+3]>t?(r[e]=h.r,r[e+1]=h.g,r[e+2]=h.b,r[e+3]=255):r[e+3]=0}n.putImageData(e,0,0)}catch(t){i.Util.error("Unable to draw hit graph from cached scene canvas. "+t.message)}return this}hasPointerCapture(t){return a.hasPointerCapture(t,this)}setPointerCapture(t){a.setPointerCapture(t,this)}releaseCapture(t){a.releaseCapture(t,this)}}t.Shape=m,m.prototype._fillFunc=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},m.prototype._strokeFunc=function(t){t.stroke()},m.prototype._fillFuncHit=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},m.prototype._strokeFuncHit=function(t){t.stroke()},m.prototype._centroid=!1,m.prototype.nodeType="Shape",(0,o._registerNode)(m),m.prototype.eventListeners={},m.prototype.on.call(m.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",function(){this._clearCache(l)}),m.prototype.on.call(m.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",function(){this._clearCache(d)}),m.prototype.on.call(m.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",function(){this._clearCache(u)}),m.prototype.on.call(m.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",function(){this._clearCache(g)}),m.prototype.on.call(m.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",function(){this._clearCache(f)}),r.Factory.addGetterSetter(m,"stroke",void 0,(0,n.getStringOrGradientValidator)()),r.Factory.addGetterSetter(m,"strokeWidth",2,(0,n.getNumberValidator)()),r.Factory.addGetterSetter(m,"fillAfterStrokeEnabled",!1),r.Factory.addGetterSetter(m,"hitStrokeWidth","auto",(0,n.getNumberOrAutoValidator)()),r.Factory.addGetterSetter(m,"strokeHitEnabled",!0,(0,n.getBooleanValidator)()),r.Factory.addGetterSetter(m,"perfectDrawEnabled",!0,(0,n.getBooleanValidator)()),r.Factory.addGetterSetter(m,"shadowForStrokeEnabled",!0,(0,n.getBooleanValidator)()),r.Factory.addGetterSetter(m,"lineJoin"),r.Factory.addGetterSetter(m,"lineCap"),r.Factory.addGetterSetter(m,"sceneFunc"),r.Factory.addGetterSetter(m,"hitFunc"),r.Factory.addGetterSetter(m,"dash"),r.Factory.addGetterSetter(m,"dashOffset",0,(0,n.getNumberValidator)()),r.Factory.addGetterSetter(m,"shadowColor",void 0,(0,n.getStringValidator)()),r.Factory.addGetterSetter(m,"shadowBlur",0,(0,n.getNumberValidator)()),r.Factory.addGetterSetter(m,"shadowOpacity",1,(0,n.getNumberValidator)()),r.Factory.addComponentsGetterSetter(m,"shadowOffset",["x","y"]),r.Factory.addGetterSetter(m,"shadowOffsetX",0,(0,n.getNumberValidator)()),r.Factory.addGetterSetter(m,"shadowOffsetY",0,(0,n.getNumberValidator)()),r.Factory.addGetterSetter(m,"fillPatternImage"),r.Factory.addGetterSetter(m,"fill",void 0,(0,n.getStringOrGradientValidator)()),r.Factory.addGetterSetter(m,"fillPatternX",0,(0,n.getNumberValidator)()),r.Factory.addGetterSetter(m,"fillPatternY",0,(0,n.getNumberValidator)()),r.Factory.addGetterSetter(m,"fillLinearGradientColorStops"),r.Factory.addGetterSetter(m,"strokeLinearGradientColorStops"),r.Factory.addGetterSetter(m,"fillRadialGradientStartRadius",0),r.Factory.addGetterSetter(m,"fillRadialGradientEndRadius",0),r.Factory.addGetterSetter(m,"fillRadialGradientColorStops"),r.Factory.addGetterSetter(m,"fillPatternRepeat","repeat"),r.Factory.addGetterSetter(m,"fillEnabled",!0),r.Factory.addGetterSetter(m,"strokeEnabled",!0),r.Factory.addGetterSetter(m,"shadowEnabled",!0),r.Factory.addGetterSetter(m,"dashEnabled",!0),r.Factory.addGetterSetter(m,"strokeScaleEnabled",!0),r.Factory.addGetterSetter(m,"fillPriority","color"),r.Factory.addComponentsGetterSetter(m,"fillPatternOffset",["x","y"]),r.Factory.addGetterSetter(m,"fillPatternOffsetX",0,(0,n.getNumberValidator)()),r.Factory.addGetterSetter(m,"fillPatternOffsetY",0,(0,n.getNumberValidator)()),r.Factory.addComponentsGetterSetter(m,"fillPatternScale",["x","y"]),r.Factory.addGetterSetter(m,"fillPatternScaleX",1,(0,n.getNumberValidator)()),r.Factory.addGetterSetter(m,"fillPatternScaleY",1,(0,n.getNumberValidator)()),r.Factory.addComponentsGetterSetter(m,"fillLinearGradientStartPoint",["x","y"]),r.Factory.addComponentsGetterSetter(m,"strokeLinearGradientStartPoint",["x","y"]),r.Factory.addGetterSetter(m,"fillLinearGradientStartPointX",0),r.Factory.addGetterSetter(m,"strokeLinearGradientStartPointX",0),r.Factory.addGetterSetter(m,"fillLinearGradientStartPointY",0),r.Factory.addGetterSetter(m,"strokeLinearGradientStartPointY",0),r.Factory.addComponentsGetterSetter(m,"fillLinearGradientEndPoint",["x","y"]),r.Factory.addComponentsGetterSetter(m,"strokeLinearGradientEndPoint",["x","y"]),r.Factory.addGetterSetter(m,"fillLinearGradientEndPointX",0),r.Factory.addGetterSetter(m,"strokeLinearGradientEndPointX",0),r.Factory.addGetterSetter(m,"fillLinearGradientEndPointY",0),r.Factory.addGetterSetter(m,"strokeLinearGradientEndPointY",0),r.Factory.addComponentsGetterSetter(m,"fillRadialGradientStartPoint",["x","y"]),r.Factory.addGetterSetter(m,"fillRadialGradientStartPointX",0),r.Factory.addGetterSetter(m,"fillRadialGradientStartPointY",0),r.Factory.addComponentsGetterSetter(m,"fillRadialGradientEndPoint",["x","y"]),r.Factory.addGetterSetter(m,"fillRadialGradientEndPointX",0),r.Factory.addGetterSetter(m,"fillRadialGradientEndPointY",0),r.Factory.addGetterSetter(m,"fillPatternRotation",0),r.Factory.addGetterSetter(m,"fillRule",void 0,(0,n.getStringValidator)()),r.Factory.backCompat(m,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"})}(B)),B}function H(){if(W)return U;W=1,Object.defineProperty(U,"__esModule",{value:!0}),U.Layer=void 0;const t=c(),e=F(),i=M(),r=P(),s=y(),n=k(),o=z(),a=h(),l=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],d=l.length;let u=class extends e.Container{constructor(t){super(t),this.canvas=new s.SceneCanvas,this.hitCanvas=new s.HitCanvas({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(){i.Node.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(!i.Node.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(i.Node.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(i.Node.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 e=this.getNativeCanvasElement();return i.Node.prototype.remove.call(this),e&&e.parentNode&&t.Util._isInDocument(e)&&e.parentNode.removeChild(e),this}getStage(){return this.parent}setSize({width:t,height:e}){return this.canvas.setSize(t,e),this.hitCanvas.setSize(t,e),this._setSmoothEnabled(),this}_validateAdd(e){const i=e.getType();"Group"!==i&&"Shape"!==i&&t.Util.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(),i.Node.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(){t.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){t.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,t.Util.requestAnimFrame(()=>{this.draw(),this._waitingForDraw=!1})),this}getIntersection(t){if(!this.isListening()||!this.isVisible())return null;let e=1,i=!1;for(;;){for(let r=0;r<d;r++){const s=l[r],n=this._getIntersection({x:t.x+s.x*e,y:t.y+s.y*e}),o=n.shape;if(o)return o;if(i=!!n.antialiased,!n.antialiased)break}if(!i)return null;e+=1}}_getIntersection(e){const i=this.hitCanvas.pixelRatio,r=this.hitCanvas.context.getImageData(Math.round(e.x*i),Math.round(e.y*i),1,1).data,s=r[3];if(255===s){const e=t.Util._rgbToHex(r[0],r[1],r[2]),i=o.shapes["#"+e];return i?{shape:i}:{antialiased:!0}}return s>0?{antialiased:!0}:{}}drawScene(t,i,r){const s=this.getLayer(),n=t||s&&s.getCanvas();return this._fire("beforeDraw",{node:this}),this.clearBeforeDraw()&&n.getContext().clear(),e.Container.prototype.drawScene.call(this,n,i,r),this._fire("draw",{node:this}),this}drawHit(t,i){const r=this.getLayer(),s=t||r&&r.hitCanvas;return r&&r.clearBeforeDraw()&&r.getHitCanvas().getContext().clear(),e.Container.prototype.drawHit.call(this,s,i),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){t.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(e)}getHitGraphEnabled(e){return t.Util.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 t.Util.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};return U.Layer=u,u.prototype.nodeType="Layer",(0,a._registerNode)(u),r.Factory.addGetterSetter(u,"imageSmoothingEnabled",!0),r.Factory.addGetterSetter(u,"clearBeforeDraw",!0),r.Factory.addGetterSetter(u,"hitGraphEnabled",!0,(0,n.getBooleanValidator)()),U}var V,j={};var K,X={};function Y(){if(K)return X;K=1,Object.defineProperty(X,"__esModule",{value:!0}),X.Group=void 0;const t=c(),e=F(),i=h();let r=class extends e.Container{_validateAdd(e){const i=e.getType();"Group"!==i&&"Shape"!==i&&t.Util.throw("You may only add groups and shapes to groups.")}};return X.Group=r,r.prototype.nodeType="Group",(0,i._registerNode)(r),X}var q,Q={};function J(){if(q)return Q;q=1,Object.defineProperty(Q,"__esModule",{value:!0}),Q.Animation=void 0;const t=h(),e=c(),i=t.glob.performance&&t.glob.performance.now?function(){return t.glob.performance.now()}:function(){return(new Date).getTime()};let r=class t{constructor(e,r){this.id=t.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:i(),frameRate:0},this.func=e,this.setLayers(r)}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 r=0;r<i;r++)if(e[r]._id===t._id)return!1;return this.layers.push(t),!0}isRunning(){const e=t.animations,i=e.length;for(let t=0;t<i;t++)if(e[t].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=i(),t._addAnimation(this),this}stop(){return t._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,r=i.length;for(let t=0;t<r;t++)if(i[t].id===e){this.animations.splice(t,1);break}}static _runFrames(){const t={},e=this.animations;for(let r=0;r<e.length;r++){const s=e[r],n=s.layers,o=s.func;s._updateFrameObject(i());const a=n.length;let h;if(h=!o||!1!==o.call(s,s.frame),h)for(let e=0;e<a;e++){const i=n[e];void 0!==i._id&&(t[i._id]=i)}}for(const e in t)t.hasOwnProperty(e)&&t[e].batchDraw()}static _animationLoop(){const i=t;i.animations.length?(i._runFrames(),e.Util.requestAnimFrame(i._animationLoop)):i.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,e.Util.requestAnimFrame(this._animationLoop))}};return Q.Animation=r,r.animations=[],r.animIdCounter=0,r.animRunning=!1,Q}var Z,$,tt={};function et(){return $||($=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Konva=void 0;const e=h(),i=c(),r=M(),s=F(),n=(O||(O=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Stage=t.stages=void 0;const e=c(),i=P(),r=F(),s=h(),n=y(),o=w(),a=h(),l=G(),d="mouseleave",u="mouseover",g="mouseenter",f="mousemove",p="mousedown",_="mouseup",m="pointermove",v="pointerdown",x="pointerup",b="pointercancel",S="pointerout",C="pointerleave",T="pointerover",A="pointerenter",k="contextmenu",M="touchstart",R="touchend",E="touchmove",I="touchcancel",O="wheel",L=[[g,"_pointerenter"],[p,"_pointerdown"],[f,"_pointermove"],[_,"_pointerup"],[d,"_pointerleave"],[M,"_pointerdown"],[E,"_pointermove"],[R,"_pointerup"],[I,"_pointercancel"],[u,"_pointerover"],[O,"_wheel"],[k,"_contextmenu"],[v,"_pointerdown"],[m,"_pointermove"],[x,"_pointerup"],[b,"_pointercancel"],[C,"_pointerleave"],["lostpointercapture","_lostpointercapture"]],D={mouse:{[S]:"mouseout",[C]:d,[T]:u,[A]:g,[m]:f,[v]:p,[x]:_,[b]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[S]:"touchout",[C]:"touchleave",[T]:"touchover",[A]:"touchenter",[m]:E,[v]:M,[x]:R,[b]:I,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[S]:S,[C]:C,[T]:T,[A]:A,[m]:m,[v]:v,[x]:x,[b]:b,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},N=t=>t.indexOf("pointer")>=0?"pointer":t.indexOf("touch")>=0?"touch":"mouse",W=t=>{const e=N(t);return"pointer"===e?s.Konva.pointerEventsEnabled&&D.pointer:"touch"===e?D.touch:"mouse"===e?D.mouse:void 0};function U(t={}){return(t.clipFunc||t.clipWidth||t.clipHeight)&&e.Util.warn("Stage does not support clipping. Please use clip for Layers or Groups."),t}t.stages=[];class B extends r.Container{constructor(e){super(U(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),t.stages.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{U(this.attrs)}),this._checkVisibility()}_validateAdd(t){const i="Layer"===t.getType(),r="FastLayer"===t.getType();i||r||e.Util.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const t=this.visible()?"":"none";this.content.style.display=t}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)),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"),r.Container.prototype.clone.call(this,t)}destroy(){super.destroy();const i=this.content;i&&e.Util._isInDocument(i)&&this.container().removeChild(i);const r=t.stages.indexOf(this);return r>-1&&t.stages.splice(r,1),e.Util.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}:(e.Util.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 n.SceneCanvas({width:t.width,height:t.height,pixelRatio:t.pixelRatio||1}),i=e.getContext()._context,r=this.children;return(t.x||t.y)&&i.translate(-1*t.x,-1*t.y),r.forEach(function(e){if(!e.isVisible())return;const r=e._toKonvaCanvas(t);i.drawImage(r._canvas,t.x,t.y,r.getWidth()/r.getPixelRatio(),r.getHeight()/r.getPixelRatio())}),e}getIntersection(t){if(!t)return null;const e=this.children;for(let i=e.length-1;i>=0;i--){const r=e[i].getIntersection(t);if(r)return r}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.bufferCanvas.setSize(t,e),this.bufferHitCanvas.setSize(t,e),this.children.forEach(i=>{i.setSize({width:t,height:e}),i.draw()})}add(t,...i){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}super.add(t);const r=this.children.length;return r>5&&e.Util.warn("The stage has "+r+" 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(),s.Konva.isBrowser&&this.content.appendChild(t.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(t){return l.hasPointerCapture(t,this)}setPointerCapture(t){l.setPointerCapture(t,this)}releaseCapture(t){l.releaseCapture(t,this)}getLayers(){return this.children}_bindContentEvents(){s.Konva.isBrowser&&L.forEach(([t,e])=>{this.content.addEventListener(t,t=>{this[e](t)},{passive:!1})})}_pointerenter(t){this.setPointersPositions(t);const e=W(t.type);e&&this._fire(e.pointerenter,{evt:t,target:this,currentTarget:this})}_pointerover(t){this.setPointersPositions(t);const e=W(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=W(t.type),i=N(t.type);if(!e)return;this.setPointersPositions(t);const r=this._getTargetShape(i),n=!(s.Konva.isDragging()||s.Konva.isTransforming())||s.Konva.hitOnDragEnabled;r&&n?(r._fireAndBubble(e.pointerout,{evt:t}),r._fireAndBubble(e.pointerleave,{evt:t}),this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this[i+"targetShape"]=null):n&&(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=W(t.type),i=N(t.type);if(!e)return;this.setPointersPositions(t);let r=!1;this._changedPointerPositions.forEach(n=>{const a=this.getIntersection(n);if(o.DD.justDragged=!1,s.Konva["_"+i+"ListenClick"]=!0,!a||!a.isListening())return void(this[i+"ClickStartShape"]=void 0);s.Konva.capturePointerEventsEnabled&&a.setPointerCapture(n.id),this[i+"ClickStartShape"]=a,a._fireAndBubble(e.pointerdown,{evt:t,pointerId:n.id}),r=!0;const h=t.type.indexOf("touch")>=0;a.preventDefault()&&t.cancelable&&h&&t.preventDefault()}),r||this._fire(e.pointerdown,{evt:t,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(t){const e=W(t.type),i=N(t.type);if(!e)return;if(s.Konva.isDragging()&&o.DD.node.preventDefault()&&t.cancelable&&t.preventDefault(),this.setPointersPositions(t),(s.Konva.isDragging()||s.Konva.isTransforming())&&!s.Konva.hitOnDragEnabled)return;const r={};let n=!1;const a=this._getTargetShape(i);this._changedPointerPositions.forEach(s=>{const o=l.getCapturedShape(s.id)||this.getIntersection(s),h=s.id,d={evt:t,pointerId:h},c=a!==o;if(c&&a&&(a._fireAndBubble(e.pointerout,{...d},o),a._fireAndBubble(e.pointerleave,{...d},o)),o){if(r[o._id])return;r[o._id]=!0}o&&o.isListening()?(n=!0,c&&(o._fireAndBubble(e.pointerover,{...d},a),o._fireAndBubble(e.pointerenter,{...d},a),this[i+"targetShape"]=o),o._fireAndBubble(e.pointermove,{...d})):a&&(this._fire(e.pointerover,{evt:t,target:this,currentTarget:this,pointerId:h}),this[i+"targetShape"]=null)}),n||this._fire(e.pointermove,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(t){const e=W(t.type),i=N(t.type);if(!e)return;this.setPointersPositions(t);const r=this[i+"ClickStartShape"],n=this[i+"ClickEndShape"],a={};let h=!1;this._changedPointerPositions.forEach(d=>{const c=l.getCapturedShape(d.id)||this.getIntersection(d);if(c){if(c.releaseCapture(d.id),a[c._id])return;a[c._id]=!0}const u=d.id,g={evt:t,pointerId:u};let f=!1;s.Konva["_"+i+"InDblClickWindow"]?(f=!0,clearTimeout(this[i+"DblTimeout"])):o.DD.justDragged||(s.Konva["_"+i+"InDblClickWindow"]=!0,clearTimeout(this[i+"DblTimeout"])),this[i+"DblTimeout"]=setTimeout(function(){s.Konva["_"+i+"InDblClickWindow"]=!1},s.Konva.dblClickWindow),c&&c.isListening()?(h=!0,this[i+"ClickEndShape"]=c,c._fireAndBubble(e.pointerup,{...g}),s.Konva["_"+i+"ListenClick"]&&r&&r===c&&(c._fireAndBubble(e.pointerclick,{...g}),f&&n&&n===c&&c._fireAndBubble(e.pointerdblclick,{...g}))):(this[i+"ClickEndShape"]=null,s.Konva["_"+i+"ListenClick"]&&this._fire(e.pointerclick,{evt:t,target:this,currentTarget:this,pointerId:u}),f&&this._fire(e.pointerdblclick,{evt:t,target:this,currentTarget:this,pointerId:u}))}),h||this._fire(e.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),s.Konva["_"+i+"ListenClick"]=!1,t.cancelable&&"touch"!==i&&"pointer"!==i&&t.preventDefault()}_contextmenu(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(k,{evt:t}):this._fire(k,{evt:t,target:this,currentTarget:this})}_wheel(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(O,{evt:t}):this._fire(O,{evt:t,target:this,currentTarget:this})}_pointercancel(t){this.setPointersPositions(t);const e=l.getCapturedShape(t.pointerId)||this.getIntersection(this.getPointerPosition());e&&e._fireAndBubble(x,l.createEvent(t)),l.releaseCapture(t.pointerId)}_lostpointercapture(t){l.releaseCapture(t.pointerId)}setPointersPositions(t){const i=this._getContentPosition();let r=null,s=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-i.left)/i.scaleX,y:(t.clientY-i.top)/i.scaleY})}),Array.prototype.forEach.call(t.changedTouches||t.touches,t=>{this._changedPointerPositions.push({id:t.identifier,x:(t.clientX-i.left)/i.scaleX,y:(t.clientY-i.top)/i.scaleY})})):(r=(t.clientX-i.left)/i.scaleX,s=(t.clientY-i.top)/i.scaleY,this.pointerPos={x:r,y:s},this._pointerPositions=[{x:r,y:s,id:e.Util._getFirstPointerId(t)}],this._changedPointerPositions=[{x:r,y:s,id:e.Util._getFirstPointerId(t)}])}_setPointerPosition(t){e.Util.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 n.SceneCanvas({width:this.width(),height:this.height()}),this.bufferHitCanvas=new n.HitCanvas({pixelRatio:1,width:this.width(),height:this.height()}),!s.Konva.isBrowser)return;const t=this.container();if(!t)throw"Stage has no container. A container is required.";t.innerHTML="",this.content=document.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),this._resizeDOM()}cache(){return e.Util.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}}t.Stage=B,B.prototype.nodeType="Stage",(0,a._registerNode)(B),i.Factory.addGetterSetter(B,"container"),s.Konva.isBrowser&&document.addEventListener("visibilitychange",()=>{t.stages.forEach(t=>{t.batchDraw()})})}(L)),L),o=H(),a=function(){if(V)return j;V=1,Object.defineProperty(j,"__esModule",{value:!0}),j.FastLayer=void 0;const t=c(),e=H(),i=h();let r=class extends e.Layer{constructor(e){super(e),this.listening(!1),t.Util.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}};return j.FastLayer=r,r.prototype.nodeType="FastLayer",(0,i._registerNode)(r),j}(),l=Y(),d=w(),u=z(),g=J(),f=(Z||(Z=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Easings=t.Tween=void 0;const e=c(),i=J(),r=M(),s=h(),n={node:1,duration:1,easing:1,onFinish:1,yoyo:1},o=["fill","stroke","shadowColor"];let a=0;class l{constructor(t,e,i,r,s,n,o){this.prop=t,this.propFunc=e,this.begin=r,this._pos=r,this.duration=n,this._change=0,this.prevPos=0,this.yoyo=o,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 d{constructor(r){const o=this,h=r.node,c=h._id,u=r.easing||t.Easings.Linear,g=!!r.yoyo;let f,p;f=void 0===r.duration?.3:0===r.duration?.001:r.duration,this.node=h,this._id=a++;const _=h.getLayer()||(h instanceof s.Konva.Stage?h.getLayers():null);for(p in _||e.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new i.Animation(function(){o.tween.onEnterFrame()},_),this.tween=new l(p,function(t){o._tweenFunc(t)},u,0,1,1e3*f,g),this._addListeners(),d.attrs[c]||(d.attrs[c]={}),d.attrs[c][this._id]||(d.attrs[c][this._id]={}),d.tweens[c]||(d.tweens[c]={}),r)void 0===n[p]&&this._addAttr(p,r[p]);this.reset(),this.onFinish=r.onFinish,this.onReset=r.onReset,this.onUpdate=r.onUpdate}_addAttr(t,i){const r=this.node,s=r._id;let n,a,h,l,c;const u=d.tweens[s][t];u&&delete d.attrs[s][u][t];let g=r.getAttr(t);if(e.Util._isArray(i))if(n=[],a=Math.max(i.length,g.length),"points"===t&&i.length!==g.length&&(i.length>g.length?(l=g,g=e.Util._prepareArrayForTween(g,i,r.closed())):(h=i,i=e.Util._prepareArrayForTween(i,g,r.closed()))),0===t.indexOf("fill"))for(let t=0;t<a;t++)if(t%2==0)n.push(i[t]-g[t]);else{const r=e.Util.colorToRGBA(g[t]);c=e.Util.colorToRGBA(i[t]),g[t]=r,n.push({r:c.r-r.r,g:c.g-r.g,b:c.b-r.b,a:c.a-r.a})}else for(let t=0;t<a;t++)n.push(i[t]-g[t]);else-1!==o.indexOf(t)?(g=e.Util.colorToRGBA(g),c=e.Util.colorToRGBA(i),n={r:c.r-g.r,g:c.g-g.g,b:c.b-g.b,a:c.a-g.a}):n=i-g;d.attrs[s][this._id][t]={start:g,diff:n,end:i,trueEnd:h,trueStart:l},d.tweens[s][t]=this._id}_tweenFunc(t){const i=this.node,r=d.attrs[i._id][this._id];let s,n,a,h,l,c,u,g;for(s in r){if(n=r[s],a=n.start,h=n.diff,g=n.end,e.Util._isArray(a))if(l=[],u=Math.max(a.length,g.length),0===s.indexOf("fill"))for(c=0;c<u;c++)c%2==0?l.push((a[c]||0)+h[c]*t):l.push("rgba("+Math.round(a[c].r+h[c].r*t)+","+Math.round(a[c].g+h[c].g*t)+","+Math.round(a[c].b+h[c].b*t)+","+(a[c].a+h[c].a*t)+")");else for(c=0;c<u;c++)l.push((a[c]||0)+h[c]*t);else l=-1!==o.indexOf(s)?"rgba("+Math.round(a.r+h.r*t)+","+Math.round(a.g+h.g*t)+","+Math.round(a.b+h.b*t)+","+(a.a+h.a*t)+")":a+h*t;i.setAttr(s,l)}}_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=d.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=d.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=d.tweens[t];this.pause(),this.anim&&this.anim.stop();for(const e in i)delete d.tweens[t][e];delete d.attrs[t][e],d.tweens[t]&&(0===Object.keys(d.tweens[t]).length&&delete d.tweens[t],0===Object.keys(d.attrs[t]).length&&delete d.attrs[t])}}t.Tween=d,d.attrs={},d.tweens={},r.Node.prototype.to=function(t){const e=t.onFinish;t.node=this,t.onFinish=function(){this.destroy(),e&&e()},new d(t).play()},t.Easings={BackEaseIn(t,e,i,r){const s=1.70158;return i*(t/=r)*t*((s+1)*t-s)+e},BackEaseOut(t,e,i,r){const s=1.70158;return i*((t=t/r-1)*t*((s+1)*t+s)+1)+e},BackEaseInOut(t,e,i,r){let s=1.70158;return(t/=r/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,r,s,n){let o=0;return 0===t?e:1===(t/=r)?e+i:(n||(n=.3*r),!s||s<Math.abs(i)?(s=i,o=n/4):o=n/(2*Math.PI)*Math.asin(i/s),-s*Math.pow(2,10*(t-=1))*Math.sin((t*r-o)*(2*Math.PI)/n)+e)},ElasticEaseOut(t,e,i,r,s,n){let o=0;return 0===t?e:1===(t/=r)?e+i:(n||(n=.3*r),!s||s<Math.abs(i)?(s=i,o=n/4):o=n/(2*Math.PI)*Math.asin(i/s),s*Math.pow(2,-10*t)*Math.sin((t*r-o)*(2*Math.PI)/n)+i+e)},ElasticEaseInOut(t,e,i,r,s,n){let o=0;return 0===t?e:2==(t/=r/2)?e+i:(n||(n=r*(.3*1.5)),!s||s<Math.abs(i)?(s=i,o=n/4):o=n/(2*Math.PI)*Math.asin(i/s),t<1?s*Math.pow(2,10*(t-=1))*Math.sin((t*r-o)*(2*Math.PI)/n)*-.5+e:s*Math.pow(2,-10*(t-=1))*Math.sin((t*r-o)*(2*Math.PI)/n)*.5+i+e)},BounceEaseOut:(t,e,i,r)=>(t/=r)<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:(e,i,r,s)=>r-t.Easings.BounceEaseOut(s-e,0,r,s)+i,BounceEaseInOut:(e,i,r,s)=>e<s/2?.5*t.Easings.BounceEaseIn(2*e,0,r,s)+i:.5*t.Easings.BounceEaseOut(2*e-s,0,r,s)+.5*r+i,EaseIn:(t,e,i,r)=>i*(t/=r)*t+e,EaseOut:(t,e,i,r)=>-i*(t/=r)*(t-2)+e,EaseInOut:(t,e,i,r)=>(t/=r/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e,StrongEaseIn:(t,e,i,r)=>i*(t/=r)*t*t*t*t+e,StrongEaseOut:(t,e,i,r)=>i*((t=t/r-1)*t*t*t*t+1)+e,StrongEaseInOut:(t,e,i,r)=>(t/=r/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e,Linear:(t,e,i,r)=>i*t/r+e}}(tt)),tt),p=m(),_=y();t.Konva=i.Util._assign(e.Konva,{Util:i.Util,Transform:i.Transform,Node:r.Node,Container:s.Container,Stage:n.Stage,stages:n.stages,Layer:o.Layer,FastLayer:a.FastLayer,Group:l.Group,DD:d.DD,Shape:u.Shape,shapes:u.shapes,Animation:g.Animation,Tween:f.Tween,Easings:f.Easings,Context:p.Context,Canvas:_.Canvas}),t.default=t.Konva}(o)),o}var it,rt={};var st,nt={},ot={};function at(){if(st)return ot;st=1,Object.defineProperty(ot,"__esModule",{value:!0}),ot.Line=void 0;const t=P(),e=h(),i=z(),r=k();function s(t,e,i,r,s,n,o){const a=Math.sqrt(Math.pow(i-t,2)+Math.pow(r-e,2)),h=Math.sqrt(Math.pow(s-i,2)+Math.pow(n-r,2)),l=o*a/(a+h),d=o*h/(a+h);return[i-l*(s-t),r-l*(n-e),i+d*(s-t),r+d*(n-e)]}function n(t,e){const i=t.length,r=[];for(let n=2;n<i-2;n+=2){const i=s(t[n-2],t[n-1],t[n],t[n+1],t[n+2],t[n+3],e);isNaN(i[0])||(r.push(i[0]),r.push(i[1]),r.push(t[n]),r.push(t[n+1]),r.push(i[2]),r.push(i[3]))}return r}let o=class extends i.Shape{constructor(t){super(t),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",function(){this._clearCache("tensionPoints")})}_sceneFunc(t){const e=this.points(),i=e.length,r=this.tension(),s=this.closed(),n=this.bezier();if(!i)return;let o=0;if(t.beginPath(),t.moveTo(e[0],e[1]),0!==r&&i>4){const r=this.getTensionPoints(),n=r.length;for(o=s?0:4,s||t.quadraticCurveTo(r[0],r[1],r[2],r[3]);o<n-2;)t.bezierCurveTo(r[o++],r[o++],r[o++],r[o++],r[o++],r[o++]);s||t.quadraticCurveTo(r[n-2],r[n-1],e[i-2],e[i-1])}else if(n)for(o=2;o<i;)t.bezierCurveTo(e[o++],e[o++],e[o++],e[o++],e[o++],e[o++]);else for(o=2;o<i;o+=2)t.lineTo(e[o],e[o+1]);s?(t.closePath(),t.fillStrokeShape(this)):t.strokeShape(this)}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():n(this.points(),this.tension())}_getTensionPointsClosed(){const t=this.points(),e=t.length,i=this.tension(),r=s(t[e-2],t[e-1],t[0],t[1],t[2],t[3],i),o=s(t[e-4],t[e-3],t[e-2],t[e-1],t[0],t[1],i),a=n(t,i);return[r[2],r[3]].concat(a).concat([o[0],o[1],t[e-2],t[e-1],o[2],o[3],r[0],r[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};t=0!==this.tension()?[t[0],t[1],...this._getTensionPoints(),t[t.length-2],t[t.length-1]]:this.points();let e,i,r=t[0],s=t[0],n=t[1],o=t[1];for(let a=0;a<t.length/2;a++)e=t[2*a],i=t[2*a+1],r=Math.min(r,e),s=Math.max(s,e),n=Math.min(n,i),o=Math.max(o,i);return{x:r,y:n,width:s-r,height:o-n}}};return ot.Line=o,o.prototype.className="Line",o.prototype._attrsAffectingSize=["points","bezier","tension"],(0,e._registerNode)(o),t.Factory.addGetterSetter(o,"closed",!1),t.Factory.addGetterSetter(o,"bezier",!1),t.Factory.addGetterSetter(o,"tension",0,(0,r.getNumberValidator)()),t.Factory.addGetterSetter(o,"points",[],(0,r.getNumberArrayValidator)()),ot}var ht,lt,dt,ct={},ut={};function gt(){if(lt)return ct;lt=1,Object.defineProperty(ct,"__esModule",{value:!0}),ct.Path=void 0;const t=P(),e=h(),i=z(),r=(ht||(ht=1,function(t){function e(t,e,r){const s=i(1,r,t),n=i(1,r,e),o=s*s+n*n;return Math.sqrt(o)}Object.defineProperty(t,"__esModule",{value:!0}),t.t2length=t.getQuadraticArcLength=t.getCubicArcLength=t.binomialCoefficients=t.cValues=t.tValues=void 0,t.tValues=[[],[],[-.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]],t.cValues=[[],[],[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]],t.binomialCoefficients=[[1],[1,1],[1,2,1],[1,3,3,1]],t.getCubicArcLength=(i,r,s)=>{let n,o;const a=s/2;n=0;for(let s=0;s<20;s++)o=a*t.tValues[20][s]+a,n+=t.cValues[20][s]*e(i,r,o);return a*n},t.getQuadraticArcLength=(t,e,i)=>{void 0===i&&(i=1);const r=t[0]-2*t[1]+t[2],s=e[0]-2*e[1]+e[2],n=2*t[1]-2*t[0],o=2*e[1]-2*e[0],a=4*(r*r+s*s),h=4*(r*n+s*o),l=n*n+o*o;if(0===a)return i*Math.sqrt(Math.pow(t[2]-t[0],2)+Math.pow(e[2]-e[0],2));const d=h/(2*a),c=i+d,u=l/a-d*d,g=c*c+u>0?Math.sqrt(c*c+u):0,f=d*d+u>0?Math.sqrt(d*d+u):0,p=d+Math.sqrt(d*d+u)!==0?u*Math.log(Math.abs((c+g)/(d+f))):0;return Math.sqrt(a)/2*(c*g-d*f+p)};const i=(e,r,s)=>{const n=s.length-1;let o,a;if(0===n)return 0;if(0===e){a=0;for(let e=0;e<=n;e++)a+=t.binomialCoefficients[n][e]*Math.pow(1-r,n-e)*Math.pow(r,e)*s[e];return a}o=new Array(n);for(let t=0;t<n;t++)o[t]=n*(s[t+1]-s[t]);return i(e-1,r,o)};t.t2length=(t,e,i)=>{let r=1,s=t/e,n=(t-i(s))/e,o=0;for(;r>.001;){const a=i(s+n),h=Math.abs(t-a)/e;if(h<r)r=h,s+=n;else{const o=i(s-n),a=Math.abs(t-o)/e;a<r?(r=a,s-=n):n/=2}if(o++,o>500)break}return s}}(ut)),ut);let s=class t extends i.Shape{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=t.parsePathData(this.data()),this.pathLength=t.getPathLength(this.dataArray)}_sceneFunc(t){const e=this.dataArray;t.beginPath();let i=!1;for(let r=0;r<e.length;r++){const s=e[r].command,n=e[r].points;switch(s){case"L":t.lineTo(n[0],n[1]);break;case"M":t.moveTo(n[0],n[1]);break;case"C":t.bezierCurveTo(n[0],n[1],n[2],n[3],n[4],n[5]);break;case"Q":t.quadraticCurveTo(n[0],n[1],n[2],n[3]);break;case"A":const e=n[0],r=n[1],s=n[2],o=n[3],a=n[4],h=n[5],l=n[6],d=n[7],c=s>o?s:o,u=s>o?1:s/o,g=s>o?o/s:1;t.translate(e,r),t.rotate(l),t.scale(u,g),t.arc(0,0,c,a,a+h,1-d),t.scale(1/u,1/g),t.rotate(-l),t.translate(-e,-r);break;case"z":i=!0,t.closePath()}}i||this.hasFill()?t.fillStrokeShape(this):t.strokeShape(this)}getSelfRect(){let e=[];this.dataArray.forEach(function(i){if("A"===i.command){const r=i.points[4],s=i.points[5],n=i.points[4]+s;let o=Math.PI/180;if(Math.abs(r-n)<o&&(o=Math.abs(r-n)),s<0)for(let s=r-o;s>n;s-=o){const r=t.getPointOnEllipticalArc(i.points[0],i.points[1],i.points[2],i.points[3],s,0);e.push(r.x,r.y)}else for(let s=r+o;s<n;s+=o){const r=t.getPointOnEllipticalArc(i.points[0],i.points[1],i.points[2],i.points[3],s,0);e.push(r.x,r.y)}}else if("C"===i.command)for(let r=0;r<=1;r+=.01){const s=t.getPointOnCubicBezier(r,i.start.x,i.start.y,i.points[0],i.points[1],i.points[2],i.points[3],i.points[4],i.points[5]);e.push(s.x,s.y)}else e=e.concat(i.points)});let i,r,s=e[0],n=e[0],o=e[1],a=e[1];for(let t=0;t<e.length/2;t++)i=e[2*t],r=e[2*t+1],isNaN(i)||(s=Math.min(s,i),n=Math.max(n,i)),isNaN(r)||(o=Math.min(o,r),a=Math.max(a,r));return{x:s,y:o,width:n-s,height:a-o}}getLength(){return this.pathLength}getPointAtLength(e){return t.getPointAtLengthOfDataArray(e,this.dataArray)}static getLineLength(t,e,i,r){return Math.sqrt((i-t)*(i-t)+(r-e)*(r-e))}static getPathLength(t){let e=0;for(let i=0;i<t.length;++i)e+=t[i].pathLength;return e}static getPointAtLengthOfDataArray(e,i){let s,n=0,o=i.length;if(!o)return null;for(;n<o&&e>i[n].pathLength;)e-=i[n].pathLength,++n;if(n===o)return s=i[n-1].points.slice(-2),{x:s[0],y:s[1]};if(e<.01){return"M"===i[n].command?(s=i[n].points.slice(0,2),{x:s[0],y:s[1]}):{x:i[n].start.x,y:i[n].start.y}}const a=i[n],h=a.points;switch(a.command){case"L":return t.getPointOnLine(e,a.start.x,a.start.y,h[0],h[1]);case"C":return t.getPointOnCubicBezier((0,r.t2length)(e,t.getPathLength(i),t=>(0,r.getCubicArcLength)([a.start.x,h[0],h[2],h[4]],[a.start.y,h[1],h[3],h[5]],t)),a.start.x,a.start.y,h[0],h[1],h[2],h[3],h[4],h[5]);case"Q":return t.getPointOnQuadraticBezier((0,r.t2length)(e,t.getPathLength(i),t=>(0,r.getQuadraticArcLength)([a.start.x,h[0],h[2]],[a.start.y,h[1],h[3]],t)),a.start.x,a.start.y,h[0],h[1],h[2],h[3]);case"A":const s=h[0],n=h[1],o=h[2],l=h[3],d=h[5],c=h[6];let u=h[4];return u+=d*e/a.pathLength,t.getPointOnEllipticalArc(s,n,o,l,u,c)}return null}static getPointOnLine(t,e,i,r,s,n,o){n=null!=n?n:e,o=null!=o?o:i;const a=this.getLineLength(e,i,r,s);if(a<1e-10)return{x:e,y:i};if(r===e)return{x:n,y:o+(s>i?t:-t)};const h=(s-i)/(r-e),l=Math.sqrt(t*t/(1+h*h))*(r<e?-1:1),d=h*l;if(Math.abs(o-i-h*(n-e))<1e-10)return{x:n+l,y:o+d};const c=((n-e)*(r-e)+(o-i)*(s-i))/(a*a),u=e+c*(r-e),g=i+c*(s-i),f=this.getLineLength(n,o,u,g),p=Math.sqrt(t*t-f*f),_=Math.sqrt(p*p/(1+h*h))*(r<e?-1:1);return{x:u+_,y:g+h*_}}static getPointOnCubicBezier(t,e,i,r,s,n,o,a,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 u(t){return(1-t)*(1-t)*(1-t)}return{x:a*l(t)+n*d(t)+r*c(t)+e*u(t),y:h*l(t)+o*d(t)+s*c(t)+i*u(t)}}static getPointOnQuadraticBezier(t,e,i,r,s,n,o){function a(t){return t*t}function h(t){return 2*t*(1-t)}function l(t){return(1-t)*(1-t)}return{x:n*a(t)+r*h(t)+e*l(t),y:o*a(t)+s*h(t)+i*l(t)}}static getPointOnEllipticalArc(t,e,i,r,s,n){const o=Math.cos(n),a=Math.sin(n),h=i*Math.cos(s),l=r*Math.sin(s);return{x:t+(h*o-l*a),y:e+(h*a+l*o)}}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 r=e.split("|"),s=[],n=[];let o=0,a=0;const h=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;let l;for(let t=1;t<r.length;t++){let e=r[t],i=e.charAt(0);for(e=e.slice(1),n.length=0;l=h.exec(e);)n.push(l[0]);const d=[];for(let t=0,e=n.length;t<e;t++){if("00"===n[t]){d.push(0,0);continue}const e=parseFloat(n[t]);isNaN(e)?d.push(0):d.push(e)}for(;d.length>0&&!isNaN(d[0]);){let t="",e=[];const r=o,n=a;let h,l,c,u,g,f,p,_,m,y;switch(i){case"l":o+=d.shift(),a+=d.shift(),t="L",e.push(o,a);break;case"L":o=d.shift(),a=d.shift(),e.push(o,a);break;case"m":const r=d.shift(),n=d.shift();if(o+=r,a+=n,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){o=s[t].points[0]+r,a=s[t].points[1]+n;break}e.push(o,a),i="l";break;case"M":o=d.shift(),a=d.shift(),t="M",e.push(o,a),i="L";break;case"h":o+=d.shift(),t="L",e.push(o,a);break;case"H":o=d.shift(),t="L",e.push(o,a);break;case"v":a+=d.shift(),t="L",e.push(o,a);break;case"V":a=d.shift(),t="L",e.push(o,a);break;case"C":e.push(d.shift(),d.shift(),d.shift(),d.shift()),o=d.shift(),a=d.shift(),e.push(o,a);break;case"c":e.push(o+d.shift(),a+d.shift(),o+d.shift(),a+d.shift()),o+=d.shift(),a+=d.shift(),t="C",e.push(o,a);break;case"S":l=o,c=a,h=s[s.length-1],"C"===h.command&&(l=o+(o-h.points[2]),c=a+(a-h.points[3])),e.push(l,c,d.shift(),d.shift()),o=d.shift(),a=d.shift(),t="C",e.push(o,a);break;case"s":l=o,c=a,h=s[s.length-1],"C"===h.command&&(l=o+(o-h.points[2]),c=a+(a-h.points[3])),e.push(l,c,o+d.shift(),a+d.shift()),o+=d.shift(),a+=d.shift(),t="C",e.push(o,a);break;case"Q":e.push(d.shift(),d.shift()),o=d.shift(),a=d.shift(),e.push(o,a);break;case"q":e.push(o+d.shift(),a+d.shift()),o+=d.shift(),a+=d.shift(),t="Q",e.push(o,a);break;case"T":l=o,c=a,h=s[s.length-1],"Q"===h.command&&(l=o+(o-h.points[0]),c=a+(a-h.points[1])),o=d.shift(),a=d.shift(),t="Q",e.push(l,c,o,a);break;case"t":l=o,c=a,h=s[s.length-1],"Q"===h.command&&(l=o+(o-h.points[0]),c=a+(a-h.points[1])),o+=d.shift(),a+=d.shift(),t="Q",e.push(l,c,o,a);break;case"A":u=d.shift(),g=d.shift(),f=d.shift(),p=d.shift(),_=d.shift(),m=o,y=a,o=d.shift(),a=d.shift(),t="A",e=this.convertEndpointToCenterParameterization(m,y,o,a,p,_,u,g,f);break;case"a":u=d.shift(),g=d.shift(),f=d.shift(),p=d.shift(),_=d.shift(),m=o,y=a,o+=d.shift(),a+=d.shift(),t="A",e=this.convertEndpointToCenterParameterization(m,y,o,a,p,_,u,g,f)}s.push({command:t||i,points:e,start:{x:r,y:n},pathLength:this.calcLength(r,n,t||i,e)})}"z"!==i&&"Z"!==i||s.push({command:"z",points:[],start:void 0,pathLength:0})}return s}static calcLength(e,i,s,n){let o,a,h,l;const d=t;switch(s){case"L":return d.getLineLength(e,i,n[0],n[1]);case"C":return(0,r.getCubicArcLength)([e,n[0],n[2],n[4]],[i,n[1],n[3],n[5]],1);case"Q":return(0,r.getQuadraticArcLength)([e,n[0],n[2]],[i,n[1],n[3]],1);case"A":o=0;const t=n[4],s=n[5],c=n[4]+s;let u=Math.PI/180;if(Math.abs(t-c)<u&&(u=Math.abs(t-c)),a=d.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],t,0),s<0)for(l=t-u;l>c;l-=u)h=d.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],l,0),o+=d.getLineLength(a.x,a.y,h.x,h.y),a=h;else for(l=t+u;l<c;l+=u)h=d.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],l,0),o+=d.getLineLength(a.x,a.y,h.x,h.y),a=h;return h=d.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],c,0),o+=d.getLineLength(a.x,a.y,h.x,h.y),o}return 0}static convertEndpointToCenterParameterization(t,e,i,r,s,n,o,a,h){const l=h*(Math.PI/180),d=Math.cos(l)*(t-i)/2+Math.sin(l)*(e-r)/2,c=-1*Math.sin(l)*(t-i)/2+Math.cos(l)*(e-r)/2,u=d*d/(o*o)+c*c/(a*a);u>1&&(o*=Math.sqrt(u),a*=Math.sqrt(u));let g=Math.sqrt((o*o*(a*a)-o*o*(c*c)-a*a*(d*d))/(o*o*(c*c)+a*a*(d*d)));s===n&&(g*=-1),isNaN(g)&&(g=0);const f=g*o*c/a,p=g*-a*d/o,_=(t+i)/2+Math.cos(l)*f-Math.sin(l)*p,m=(e+r)/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))},w=x([1,0],[(d-f)/o,(c-p)/a]),b=[(d-f)/o,(c-p)/a],S=[(-1*d-f)/o,(-1*c-p)/a];let C=x(b,S);return v(b,S)<=-1&&(C=Math.PI),v(b,S)>=1&&(C=0),0===n&&C>0&&(C-=2*Math.PI),1===n&&C<0&&(C+=2*Math.PI),[_,m,o,a,w,C,l,n]}};return ct.Path=s,s.prototype.className="Path",s.prototype._attrsAffectingSize=["data"],(0,e._registerNode)(s),t.Factory.addGetterSetter(s,"data"),ct}var ft,pt={};var _t,mt={};var yt,vt={};var xt,wt={};var bt,St={};function Ct(){if(bt)return St;bt=1,Object.defineProperty(St,"__esModule",{value:!0}),St.Rect=void 0;const t=P(),e=z(),i=h(),r=c(),s=k();let n=class extends e.Shape{_sceneFunc(t){const e=this.cornerRadius(),i=this.width(),s=this.height();t.beginPath(),e?r.Util.drawRoundedRectPath(t,i,s,e):t.rect(0,0,i,s),t.closePath(),t.fillStrokeShape(this)}};return St.Rect=n,n.prototype.className="Rect",(0,i._registerNode)(n),t.Factory.addGetterSetter(n,"cornerRadius",0,(0,s.getNumberOrArrayOfNumbersValidator)(4)),St}var Tt,At={};var kt,Pt={};var Mt,Rt={};var Et,Ft={};var It,Ot={};function Lt(){if(It)return Ot;It=1,Object.defineProperty(Ot,"__esModule",{value:!0}),Ot.Text=void 0,Ot.stringToArray=o;const t=c(),e=P(),i=z(),r=h(),s=k(),n=h();function o(t){return[...t].reduce((t,e,i,r)=>{if(/\p{Emoji}/u.test(e)){const s=r[i+1];s&&/\p{Emoji_Modifier}|\u200D/u.test(s)?(t.push(e+s),r[i+1]=""):t.push(e)}else/\p{Regional_Indicator}{2}/u.test(e+(r[i+1]||""))?t.push(e+r[i+1]):i>0&&/\p{Mn}|\p{Me}|\p{Mc}/u.test(e)?t[t.length-1]+=e:e&&t.push(e);return t},[])}const a="auto",l="inherit",d="justify",u="left",g="middle",f="normal",p=" ",_="none",m=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],y=m.length;let v;function x(){return v||(v=t.Util.createCanvasElement().getContext("2d"),v)}let w=class extends i.Shape{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<y;t++)this.on(m[t]+"Change.konva",this._setTextData);this._setTextData()}_sceneFunc(t){const e=this.textArr,i=e.length;if(!this.text())return;let s,n=this.padding(),a=this.fontSize(),h=this.lineHeight()*a,c=this.verticalAlign(),f=this.direction(),p=0,_=this.align(),m=this.getWidth(),y=this.letterSpacing(),v=this.fill(),x=this.textDecoration(),w=-1!==x.indexOf("underline"),b=-1!==x.indexOf("line-through");f=f===l?t.direction:f;let S=h/2,C=g;if(r.Konva._fixTextRendering){const t=this.measureSize("M");C="alphabetic",S=(t.fontBoundingBoxAscent-t.fontBoundingBoxDescent)/2+h/2}for("rtl"===f&&t.setAttr("direction",f),t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",C),t.setAttr("textAlign",u),c===g?p=(this.getHeight()-i*h-2*n)/2:"bottom"===c&&(p=this.getHeight()-i*h-2*n),t.translate(n,p+n),s=0;s<i;s++){let l=0,c=0;const u=e[s],g=u.text,p=u.width,x=u.lastInParagraph;if(t.save(),"right"===_?l+=m-p-2*n:"center"===_&&(l+=(m-p-2*n)/2),w){t.save(),t.beginPath();const e=l,i=S+c+(r.Konva._fixTextRendering?Math.round(a/4):Math.round(a/2));t.moveTo(e,i);const s=_!==d||x?p:m-2*n;t.lineTo(e+Math.round(s),i),t.lineWidth=a/15;const o=this._getLinearGradient();t.strokeStyle=o||v,t.stroke(),t.restore()}if(b){t.save(),t.beginPath();const e=r.Konva._fixTextRendering?-Math.round(a/4):0;t.moveTo(l,S+c+e);const i=_!==d||x?p:m-2*n;t.lineTo(l+Math.round(i),S+c+e),t.lineWidth=a/15;const s=this._getLinearGradient();t.strokeStyle=s||v,t.stroke(),t.restore()}if("rtl"===f||0===y&&_!==d)0!==y&&t.setAttr("letterSpacing",`${y}px`),this._partialTextX=l,this._partialTextY=S+c,this._partialText=g,t.fillStrokeShape(this);else{const e=g.split(" ").length-1,i=o(g);for(let r=0;r<i.length;r++){const s=i[r];" "!==s||x||_!==d||(l+=(m-2*n-p)/e),this._partialTextX=l,this._partialTextY=S+c,this._partialText=s,t.fillStrokeShape(this),l+=this.measureSize(s).width+y}}t.restore(),i>1&&(S+=h)}}_hitFunc(t){const e=this.getWidth(),i=this.getHeight();t.beginPath(),t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}setText(e){const i=t.Util._isString(e)?e:null==e?"":e+"";return this._setAttr("text",i),this}getWidth(){return this.attrs.width===a||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}getHeight(){return this.attrs.height===a||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return t.Util.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,r,s,n,o,a,h,l,d,c;let u,g=x(),f=this.fontSize();g.save(),g.font=this._getContextFont(),u=g.measureText(t),g.restore();const p=f/100;return{actualBoundingBoxAscent:null!==(e=u.actualBoundingBoxAscent)&&void 0!==e?e:71.58203125*p,actualBoundingBoxDescent:null!==(i=u.actualBoundingBoxDescent)&&void 0!==i?i:0,actualBoundingBoxLeft:null!==(r=u.actualBoundingBoxLeft)&&void 0!==r?r:-7.421875*p,actualBoundingBoxRight:null!==(s=u.actualBoundingBoxRight)&&void 0!==s?s:75.732421875*p,alphabeticBaseline:null!==(n=u.alphabeticBaseline)&&void 0!==n?n:0,emHeightAscent:null!==(o=u.emHeightAscent)&&void 0!==o?o:100*p,emHeightDescent:null!==(a=u.emHeightDescent)&&void 0!==a?a:-20*p,fontBoundingBoxAscent:null!==(h=u.fontBoundingBoxAscent)&&void 0!==h?h:91*p,fontBoundingBoxDescent:null!==(l=u.fontBoundingBoxDescent)&&void 0!==l?l:21*p,hangingBaseline:null!==(d=u.hangingBaseline)&&void 0!==d?d:72.80000305175781*p,ideographicBaseline:null!==(c=u.ideographicBaseline)&&void 0!==c?c:-21*p,width:u.width,height:f}}_getContextFont(){return this.fontStyle()+p+this.fontVariant()+p+(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()===d&&(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 x().measureText(t).width+e*i}_setTextData(){let t=this.text().split("\n"),e=+this.fontSize(),i=0,r=this.lineHeight()*e,s=this.attrs.width,n=this.attrs.height,h=s!==a&&void 0!==s,l=n!==a&&void 0!==n,d=this.padding(),c=s-2*d,u=n-2*d,g=0,f=this.wrap(),m="char"!==f&&f!==_,y=this.ellipsis();this.textArr=[],x().font=this._getContextFont();const v=y?this._getTextWidth("…"):0;for(let e=0,s=t.length;e<s;++e){let n=t[e],a=this._getTextWidth(n);if(h&&a>c)for(;n.length>0;){let t=0,e=o(n).length,s="",h=0;for(;t<e;){const i=t+e>>>1,a=o(n).slice(0,i+1).join(""),d=this._getTextWidth(a);(y&&l&&g+r>u?d+v:d)<=c?(t=i+1,s=a,h=d):e=i}if(!s)break;if(m){const e=o(n),i=o(s),r=e[i.length];let a;if((r===p||"-"===r)&&h<=c)a=i.length;else{const t=i.lastIndexOf(p),e=i.lastIndexOf("-");a=Math.max(t,e)+1}a>0&&(t=a,s=e.slice(0,t).join(""),h=this._getTextWidth(s))}s=s.trimRight(),this._addTextLine(s),i=Math.max(i,h),g+=r;if(this._shouldHandleEllipsis(g)){this._tryToAddEllipsisToLastLine();break}if(n=o(n).slice(t).join("").trimLeft(),n.length>0&&(a=this._getTextWidth(n),a<=c)){this._addTextLine(n),g+=r,i=Math.max(i,a);break}}else this._addTextLine(n),g+=r,i=Math.max(i,a),this._shouldHandleEllipsis(g)&&e<s-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),l&&g+r>u)break}this.textHeight=e,this.textWidth=i}_shouldHandleEllipsis(t){const e=+this.fontSize(),i=this.lineHeight()*e,r=this.attrs.height,s=r!==a&&void 0!==r,n=r-2*this.padding();return!(this.wrap()!==_)||s&&t+i>n}_tryToAddEllipsisToLastLine(){const t=this.attrs.width,e=t!==a&&void 0!==t,i=t-2*this.padding(),r=this.ellipsis(),s=this.textArr[this.textArr.length-1];if(s&&r){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)||super._useBufferCanvas()}};return Ot.Text=w,w.prototype._fillFunc=function(t){t.fillText(this._partialText,this._partialTextX,this._partialTextY)},w.prototype._strokeFunc=function(t){t.setAttr("miterLimit",2),t.strokeText(this._partialText,this._partialTextX,this._partialTextY)},w.prototype.className="Text",w.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],(0,n._registerNode)(w),e.Factory.overWriteSetter(w,"width",(0,s.getNumberOrAutoValidator)()),e.Factory.overWriteSetter(w,"height",(0,s.getNumberOrAutoValidator)()),e.Factory.addGetterSetter(w,"direction",l),e.Factory.addGetterSetter(w,"fontFamily","Arial"),e.Factory.addGetterSetter(w,"fontSize",12,(0,s.getNumberValidator)()),e.Factory.addGetterSetter(w,"fontStyle",f),e.Factory.addGetterSetter(w,"fontVariant",f),e.Factory.addGetterSetter(w,"padding",0,(0,s.getNumberValidator)()),e.Factory.addGetterSetter(w,"align",u),e.Factory.addGetterSetter(w,"verticalAlign","top"),e.Factory.addGetterSetter(w,"lineHeight",1,(0,s.getNumberValidator)()),e.Factory.addGetterSetter(w,"wrap","word"),e.Factory.addGetterSetter(w,"ellipsis",!1,(0,s.getBooleanValidator)()),e.Factory.addGetterSetter(w,"letterSpacing",0,(0,s.getNumberValidator)()),e.Factory.addGetterSetter(w,"text","",(0,s.getStringValidator)()),e.Factory.addGetterSetter(w,"textDecoration",""),Ot}var Dt,Gt={};var Nt,Wt={};function Ut(){if(Nt)return Wt;Nt=1,Object.defineProperty(Wt,"__esModule",{value:!0}),Wt.Transformer=void 0;const t=c(),e=P(),i=M(),r=z(),s=Ct(),n=Y(),o=h(),a=k(),l=h(),d="tr-konva",u=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map(t=>t+`.${d}`).join(" "),g="nodesRect",f=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],p={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},_="ontouchstart"in o.Konva._global;const m=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function y(t,e,i){const r=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:r,y:s}}function v(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 y(t,e,i)}let x=0,w=class extends n.Group{constructor(t){super(t),this._movingAnchorName=null,this._transforming=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(u,this.update),this.getNode()&&this.update()}attachTo(t){return this.setNode(t),this}setNode(e){return t.Util.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return d+this._id}setNodes(e=[]){this._nodes&&this._nodes.length&&this.detach();const i=e.filter(e=>!e.isAncestorOf(this)||(t.Util.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1));this._nodes=e=i,1===e.length&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(t=>{const e=()=>{1===this.nodes().length&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),this._transforming||this.isDragging()||this.update()};if(t._attrsAffectingSize.length){const i=t._attrsAffectingSize.map(t=>t+"Change."+this._getEventNamespace()).join(" ");t.on(i,e)}t.on(f.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 r=t.getAbsolutePosition(),s=r.x-e.x,n=r.y-e.y;this.nodes().forEach(e=>{if(e===t)return;if(e.isDragging())return;const r=e.getAbsolutePosition();e.setAbsolutePosition({x:r.x+s,y:r.y+n}),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(g),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(g,this.__getNodeRect)}__getNodeShape(t,e=this.rotation(),i){const r=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),s=t.getAbsoluteScale(i),n=t.getAbsolutePosition(i),a=r.x*s.x-t.offsetX()*s.x,h=r.y*s.y-t.offsetY()*s.y,l=(o.Konva.getAngle(t.getAbsoluteRotation())+2*Math.PI)%(2*Math.PI);return y({x:n.x+a*Math.cos(l)+h*Math.sin(-l),y:n.y+h*Math.cos(l)+a*Math.sin(l),width:r.width*s.x,height:r.height*s.y,rotation:l},-o.Konva.getAngle(e),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};const e=[];this.nodes().map(t=>{const i=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),r=[{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=t.getAbsoluteTransform();r.forEach(function(t){const i=s.point(t);e.push(i)})});const i=new t.Transform;i.rotate(-o.Konva.getAngle(this.rotation()));let r=1/0,s=1/0,n=-1/0,a=-1/0;e.forEach(function(t){const e=i.point(t);void 0===r&&(r=n=e.x,s=a=e.y),r=Math.min(r,e.x),s=Math.min(s,e.y),n=Math.max(n,e.x),a=Math.max(a,e.y)}),i.invert();const h=i.point({x:r,y:s});return{x:h.x,y:h.y,width:n-r,height:a-s,rotation:o.Konva.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(),m.forEach(t=>{this._createAnchor(t)}),this._createAnchor("rotater")}_createAnchor(e){const i=new s.Rect({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:_?10:"auto"}),r=this;i.on("mousedown touchstart",function(t){r._handleMouseDown(t)}),i.on("dragstart",t=>{i.stopDrag(),t.cancelBubble=!0}),i.on("dragend",t=>{t.cancelBubble=!0}),i.on("mouseenter",()=>{const r=o.Konva.getAngle(this.rotation()),s=this.rotateAnchorCursor(),n=function(e,i,r){if("rotater"===e)return r;i+=t.Util.degToRad(p[e]||0);const s=(t.Util.radToDeg(i)%360+360)%360;return t.Util._inRange(s,337.5,360)||t.Util._inRange(s,0,22.5)?"ns-resize":t.Util._inRange(s,22.5,67.5)?"nesw-resize":t.Util._inRange(s,67.5,112.5)?"ew-resize":t.Util._inRange(s,112.5,157.5)?"nwse-resize":t.Util._inRange(s,157.5,202.5)?"ns-resize":t.Util._inRange(s,202.5,247.5)?"nesw-resize":t.Util._inRange(s,247.5,292.5)?"ew-resize":t.Util._inRange(s,292.5,337.5)?"nwse-resize":(t.Util.error("Transformer has unknown angle for cursor detection: "+s),"pointer")}(e,r,s);i.getStage().content&&(i.getStage().content.style.cursor=n),this._cursorChange=!0}),i.on("mouseout",()=>{i.getStage().content&&(i.getStage().content.style.cursor=""),this._cursorChange=!1}),this.add(i)}_createBack(){const e=new r.Shape({name:"back",width:0,height:0,draggable:!0,sceneFunc(e,i){const r=i.getParent(),s=r.padding();e.beginPath(),e.rect(-s,-s,i.width()+2*s,i.height()+2*s),e.moveTo(i.width()/2,-s),r.rotateEnabled()&&r.rotateLineVisible()&&e.lineTo(i.width()/2,-r.rotateAnchorOffset()*t.Util._sign(i.height())-s),e.fillStrokeShape(i)},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(e),this._proxyDrag(e),e.on("dragstart",t=>{t.cancelBubble=!0}),e.on("dragmove",t=>{t.cancelBubble=!0}),e.on("dragend",t=>{t.cancelBubble=!0}),this.on("dragmove",t=>{this.update()})}_handleMouseDown(t){if(this._transforming)return;this._movingAnchorName=t.target.name().split(" ")[0];const e=this._getNodeRect(),i=e.width,r=e.height,s=Math.sqrt(Math.pow(i,2)+Math.pow(r,2));this.sin=Math.abs(r/s),this.cos=Math.abs(i/s),"undefined"!=typeof window&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;const n=t.target.getAbsolutePosition(),o=t.target.getStage().getPointerPosition();this._anchorDragOffset={x:o.x-n.x,y:o.y-n.y},x++,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,i,r;const s=this.findOne("."+this._movingAnchorName),n=s.getStage();n.setPointersPositions(t);const a=n.getPointerPosition();let h={x:a.x-this._anchorDragOffset.x,y:a.y-this._anchorDragOffset.y};const l=s.getAbsolutePosition();this.anchorDragBoundFunc()&&(h=this.anchorDragBoundFunc()(l,h,t)),s.setAbsolutePosition(h);const d=s.getAbsolutePosition();if(l.x===d.x&&l.y===d.y)return;if("rotater"===this._movingAnchorName){const r=this._getNodeRect();e=s.x()-r.width/2,i=-s.y()+r.height/2;let n=Math.atan2(-i,e)+Math.PI/2;r.height<0&&(n-=Math.PI);const a=o.Konva.getAngle(this.rotation())+n,h=o.Konva.getAngle(this.rotationSnapTolerance()),l=function(t,e,i){let r=e;for(let s=0;s<t.length;s++){const n=o.Konva.getAngle(t[s]),a=Math.abs(n-e)%(2*Math.PI);Math.min(a,2*Math.PI-a)<i&&(r=n)}return r}(this.rotationSnaps(),a,h),d=v(r,l-r.rotation);return void this._fitNodesInto(d,t)}const c=this.shiftBehavior();let u;u="inverted"===c?this.keepRatio()&&!t.shiftKey:"none"===c?this.keepRatio():this.keepRatio()||t.shiftKey;let g=this.centeredScaling()||t.altKey;if("top-left"===this._movingAnchorName){if(u){const t=g?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};r=Math.sqrt(Math.pow(t.x-s.x(),2)+Math.pow(t.y-s.y(),2));const n=this.findOne(".top-left").x()>t.x?-1:1,o=this.findOne(".top-left").y()>t.y?-1:1;e=r*this.cos*n,i=r*this.sin*o,this.findOne(".top-left").x(t.x-e),this.findOne(".top-left").y(t.y-i)}}else if("top-center"===this._movingAnchorName)this.findOne(".top-left").y(s.y());else if("top-right"===this._movingAnchorName){if(u){const t=g?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};r=Math.sqrt(Math.pow(s.x()-t.x,2)+Math.pow(t.y-s.y(),2));const n=this.findOne(".top-right").x()<t.x?-1:1,o=this.findOne(".top-right").y()>t.y?-1:1;e=r*this.cos*n,i=r*this.sin*o,this.findOne(".top-right").x(t.x+e),this.findOne(".top-right").y(t.y-i)}var f=s.position();this.findOne(".top-left").y(f.y),this.findOne(".bottom-right").x(f.x)}else if("middle-left"===this._movingAnchorName)this.findOne(".top-left").x(s.x());else if("middle-right"===this._movingAnchorName)this.findOne(".bottom-right").x(s.x());else if("bottom-left"===this._movingAnchorName){if(u){const t=g?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};r=Math.sqrt(Math.pow(t.x-s.x(),2)+Math.pow(s.y()-t.y,2));const n=t.x<s.x()?-1:1,o=s.y()<t.y?-1:1;e=r*this.cos*n,i=r*this.sin*o,s.x(t.x-e),s.y(t.y+i)}f=s.position(),this.findOne(".top-left").x(f.x),this.findOne(".bottom-right").y(f.y)}else if("bottom-center"===this._movingAnchorName)this.findOne(".bottom-right").y(s.y());else if("bottom-right"===this._movingAnchorName){if(u){const t=g?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};r=Math.sqrt(Math.pow(s.x()-t.x,2)+Math.pow(s.y()-t.y,2));const n=this.findOne(".bottom-right").x()<t.x?-1:1,o=this.findOne(".bottom-right").y()<t.y?-1:1;e=r*this.cos*n,i=r*this.sin*o,this.findOne(".bottom-right").x(t.x+e),this.findOne(".bottom-right").y(t.y+i)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(g=this.centeredScaling()||t.altKey,g){const t=this.findOne(".top-left"),e=this.findOne(".bottom-right"),i=t.x(),r=t.y(),s=this.getWidth()-e.x(),n=this.getHeight()-e.y();e.move({x:-i,y:-r}),t.move({x:s,y:n})}const p=this.findOne(".top-left").getAbsolutePosition();e=p.x,i=p.y;const _=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),m=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:e,y:i,width:_,height:m,rotation:o.Konva.getAngle(this.rotation())},t)}_handleMouseUp(t){this._removeEvents(t)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(t){var e;if(this._transforming){this._transforming=!1,"undefined"!=typeof window&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));const i=this.getNode();x--,this._fire("transformend",{evt:t,target:i}),null===(e=this.getLayer())||void 0===e||e.batchDraw(),i&&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(e,i){const r=this._getNodeRect();if(t.Util._inRange(e.width,2*-this.padding()-1,1))return void this.update();if(t.Util._inRange(e.height,2*-this.padding()-1,1))return void this.update();const s=new t.Transform;if(s.rotate(o.Konva.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const t=s.point({x:2*-this.padding(),y:0});e.x+=t.x,e.y+=t.y,e.width+=2*this.padding(),this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const t=s.point({x:2*this.padding(),y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.width+=2*this.padding()}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const t=s.point({x:0,y:2*-this.padding()});e.x+=t.x,e.y+=t.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=2*this.padding()}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const t=s.point({x:0,y:2*this.padding()});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=2*this.padding()}if(this.boundBoxFunc()){const i=this.boundBoxFunc()(r,e);i?e=i:t.Util.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const n=1e7,a=new t.Transform;a.translate(r.x,r.y),a.rotate(r.rotation),a.scale(r.width/n,r.height/n);const h=new t.Transform,l=e.width/n,d=e.height/n;!1===this.flipEnabled()?(h.translate(e.x,e.y),h.rotate(e.rotation),h.translate(e.width<0?e.width:0,e.height<0?e.height:0),h.scale(Math.abs(l),Math.abs(d))):(h.translate(e.x,e.y),h.rotate(e.rotation),h.scale(l,d));const c=h.multiply(a.invert());this._nodes.forEach(e=>{var i;const r=e.getParent().getAbsoluteTransform(),s=e.getTransform().copy();s.translate(e.offsetX(),e.offsetY());const n=new t.Transform;n.multiply(r.copy().invert()).multiply(c).multiply(r).multiply(s);const o=n.decompose();e.setAttrs(o),null===(i=e.getLayer())||void 0===i||i.batchDraw()}),this.rotation(t.Util._getRotation(e.rotation)),this._nodes.forEach(t=>{this._fire("transform",{evt:i,target:t}),t._fire("transform",{evt:i,target:t})}),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(t,e){this.findOne(t).setAttrs(e)}update(){var e;const i=this._getNodeRect();this.rotation(t.Util._getRotation(i.rotation));const r=i.width,s=i.height,n=this.enabledAnchors(),o=this.resizeEnabled(),a=this.padding(),h=this.anchorSize(),l=this.find("._anchor");l.forEach(t=>{t.setAttrs({width:h,height:h,offsetX:h/2,offsetY:h/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:h/2+a,offsetY:h/2+a,visible:o&&n.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:r/2,y:0,offsetY:h/2+a,visible:o&&n.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:r,y:0,offsetX:h/2-a,offsetY:h/2+a,visible:o&&n.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:s/2,offsetX:h/2+a,visible:o&&n.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:r,y:s/2,offsetX:h/2-a,visible:o&&n.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:s,offsetX:h/2+a,offsetY:h/2-a,visible:o&&n.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:r/2,y:s,offsetY:h/2-a,visible:o&&n.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:r,y:s,offsetX:h/2-a,offsetY:h/2-a,visible:o&&n.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:r/2,y:-this.rotateAnchorOffset()*t.Util._sign(s)-a,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:r,height:s,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0});const d=this.anchorStyleFunc();d&&l.forEach(t=>{d(t)}),null===(e=this.getLayer())||void 0===e||e.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=""),n.Group.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return i.Node.prototype.toObject.call(this)}clone(t){return i.Node.prototype.clone.call(this,t)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}};return Wt.Transformer=w,w.isTransforming=()=>x>0,w.prototype.className="Transformer",(0,l._registerNode)(w),e.Factory.addGetterSetter(w,"enabledAnchors",m,function(e){return e instanceof Array||t.Util.warn("enabledAnchors value should be an array"),e instanceof Array&&e.forEach(function(e){-1===m.indexOf(e)&&t.Util.warn("Unknown anchor name: "+e+". Available names are: "+m.join(", "))}),e||[]}),e.Factory.addGetterSetter(w,"flipEnabled",!0,(0,a.getBooleanValidator)()),e.Factory.addGetterSetter(w,"resizeEnabled",!0),e.Factory.addGetterSetter(w,"anchorSize",10,(0,a.getNumberValidator)()),e.Factory.addGetterSetter(w,"rotateEnabled",!0),e.Factory.addGetterSetter(w,"rotateLineVisible",!0),e.Factory.addGetterSetter(w,"rotationSnaps",[]),e.Factory.addGetterSetter(w,"rotateAnchorOffset",50,(0,a.getNumberValidator)()),e.Factory.addGetterSetter(w,"rotateAnchorCursor","crosshair"),e.Factory.addGetterSetter(w,"rotationSnapTolerance",5,(0,a.getNumberValidator)()),e.Factory.addGetterSetter(w,"borderEnabled",!0),e.Factory.addGetterSetter(w,"anchorStroke","rgb(0, 161, 255)"),e.Factory.addGetterSetter(w,"anchorStrokeWidth",1,(0,a.getNumberValidator)()),e.Factory.addGetterSetter(w,"anchorFill","white"),e.Factory.addGetterSetter(w,"anchorCornerRadius",0,(0,a.getNumberValidator)()),e.Factory.addGetterSetter(w,"borderStroke","rgb(0, 161, 255)"),e.Factory.addGetterSetter(w,"borderStrokeWidth",1,(0,a.getNumberValidator)()),e.Factory.addGetterSetter(w,"borderDash"),e.Factory.addGetterSetter(w,"keepRatio",!0),e.Factory.addGetterSetter(w,"shiftBehavior","default"),e.Factory.addGetterSetter(w,"centeredScaling",!1),e.Factory.addGetterSetter(w,"ignoreStroke",!1),e.Factory.addGetterSetter(w,"padding",0,(0,a.getNumberValidator)()),e.Factory.addGetterSetter(w,"nodes"),e.Factory.addGetterSetter(w,"node"),e.Factory.addGetterSetter(w,"boundBoxFunc"),e.Factory.addGetterSetter(w,"anchorDragBoundFunc"),e.Factory.addGetterSetter(w,"anchorStyleFunc"),e.Factory.addGetterSetter(w,"shouldOverdrawWholeArea",!1),e.Factory.addGetterSetter(w,"useSingleNodeRotation",!0),e.Factory.backCompat(w,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"}),Wt}var Bt,zt={};var Ht,Vt={};function jt(){if(Ht)return Vt;Ht=1,Object.defineProperty(Vt,"__esModule",{value:!0}),Vt.Blur=void 0;const t=P(),e=M(),i=k();function r(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}const s=[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],n=[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];return Vt.Blur=function(t){const e=Math.round(this.blurRadius());e>0&&function(t,e){const i=t.data,o=t.width,a=t.height;let h,l,d,c,u,g,f,p,_,m,y,v,x,w,b,S,C,T,A,k;const P=e+e+1,M=o-1,R=a-1,E=e+1,F=E*(E+1)/2,I=new r,O=s[e],L=n[e];let D=null,G=I,N=null,W=null;for(let t=1;t<P;t++)G=G.next=new r,t===E&&(D=G);G.next=I,d=l=0;for(let t=0;t<a;t++){v=x=w=b=c=u=g=f=0,p=E*(S=i[l]),_=E*(C=i[l+1]),m=E*(T=i[l+2]),y=E*(A=i[l+3]),c+=F*S,u+=F*C,g+=F*T,f+=F*A,G=I;for(let t=0;t<E;t++)G.r=S,G.g=C,G.b=T,G.a=A,G=G.next;for(let t=1;t<E;t++)h=l+((M<t?M:t)<<2),c+=(G.r=S=i[h])*(k=E-t),u+=(G.g=C=i[h+1])*k,g+=(G.b=T=i[h+2])*k,f+=(G.a=A=i[h+3])*k,v+=S,x+=C,w+=T,b+=A,G=G.next;N=I,W=D;for(let t=0;t<o;t++)i[l+3]=A=f*O>>L,0!==A?(A=255/A,i[l]=(c*O>>L)*A,i[l+1]=(u*O>>L)*A,i[l+2]=(g*O>>L)*A):i[l]=i[l+1]=i[l+2]=0,c-=p,u-=_,g-=m,f-=y,p-=N.r,_-=N.g,m-=N.b,y-=N.a,h=d+((h=t+e+1)<M?h:M)<<2,v+=N.r=i[h],x+=N.g=i[h+1],w+=N.b=i[h+2],b+=N.a=i[h+3],c+=v,u+=x,g+=w,f+=b,N=N.next,p+=S=W.r,_+=C=W.g,m+=T=W.b,y+=A=W.a,v-=S,x-=C,w-=T,b-=A,W=W.next,l+=4;d+=o}for(let t=0;t<o;t++){x=w=b=v=u=g=f=c=0,l=t<<2,p=E*(S=i[l]),_=E*(C=i[l+1]),m=E*(T=i[l+2]),y=E*(A=i[l+3]),c+=F*S,u+=F*C,g+=F*T,f+=F*A,G=I;for(let t=0;t<E;t++)G.r=S,G.g=C,G.b=T,G.a=A,G=G.next;let r=o;for(let s=1;s<=e;s++)l=r+t<<2,c+=(G.r=S=i[l])*(k=E-s),u+=(G.g=C=i[l+1])*k,g+=(G.b=T=i[l+2])*k,f+=(G.a=A=i[l+3])*k,v+=S,x+=C,w+=T,b+=A,G=G.next,s<R&&(r+=o);l=t,N=I,W=D;for(let e=0;e<a;e++)h=l<<2,i[h+3]=A=f*O>>L,A>0?(A=255/A,i[h]=(c*O>>L)*A,i[h+1]=(u*O>>L)*A,i[h+2]=(g*O>>L)*A):i[h]=i[h+1]=i[h+2]=0,c-=p,u-=_,g-=m,f-=y,p-=N.r,_-=N.g,m-=N.b,y-=N.a,h=t+((h=e+E)<R?h:R)*o<<2,c+=v+=N.r=i[h],u+=x+=N.g=i[h+1],g+=w+=N.b=i[h+2],f+=b+=N.a=i[h+3],N=N.next,p+=S=W.r,_+=C=W.g,m+=T=W.b,y+=A=W.a,v-=S,x-=C,w-=T,b-=A,W=W.next,l+=o}}(t,e)},t.Factory.addGetterSetter(e.Node,"blurRadius",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),Vt}var Kt,Xt={};var Yt,qt={};var Qt,Jt={};var Zt,$t={};var te,ee={};var ie,re={};var se,ne={};var oe,ae={};var he,le={};function de(){if(he)return le;he=1,Object.defineProperty(le,"__esModule",{value:!0}),le.Kaleidoscope=void 0;const t=P(),e=M(),i=c(),r=k();return le.Kaleidoscope=function(t){const e=t.width,r=t.height;let s,n,o,a,h,l,d,c,u,g,f=Math.round(this.kaleidoscopePower());const p=Math.round(this.kaleidoscopeAngle()),_=Math.floor(e*(p%360)/360);if(f<1)return;const m=i.Util.createCanvasElement();m.width=e,m.height=r;const y=m.getContext("2d").getImageData(0,0,e,r);i.Util.releaseCanvas(m),function(t,e,i){const r=t.data,s=e.data,n=t.width,o=t.height,a=i.polarCenterX||n/2,h=i.polarCenterY||o/2;let l=Math.sqrt(a*a+h*h),d=n-a,c=o-h;const u=Math.sqrt(d*d+c*c);l=u>l?u:l;const g=o,f=n,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 o=0;o<g;o+=1){d=Math.floor(a+l*o/g*i),c=Math.floor(h+l*o/g*e);let u=4*(c*n+d);const f=r[u+0],p=r[u+1],_=r[u+2],m=r[u+3];u=4*(t+o*n),s[u+0]=f,s[u+1]=p,s[u+2]=_,s[u+3]=m}}}(t,y,{polarCenterX:e/2,polarCenterY:r/2});let v=e/Math.pow(2,f);for(;v<=8;)v*=2,f-=1;v=Math.ceil(v);let x=v,w=0,b=x,S=1;for(_+v>e&&(w=x,b=0,S=-1),n=0;n<r;n+=1)for(s=w;s!==b;s+=S)o=Math.round(s+_)%e,u=4*(e*n+o),h=y.data[u+0],l=y.data[u+1],d=y.data[u+2],c=y.data[u+3],g=4*(e*n+s),y.data[g+0]=h,y.data[g+1]=l,y.data[g+2]=d,y.data[g+3]=c;for(n=0;n<r;n+=1)for(x=Math.floor(v),a=0;a<f;a+=1){for(s=0;s<x+1;s+=1)u=4*(e*n+s),h=y.data[u+0],l=y.data[u+1],d=y.data[u+2],c=y.data[u+3],g=4*(e*n+2*x-s-1),y.data[g+0]=h,y.data[g+1]=l,y.data[g+2]=d,y.data[g+3]=c;x*=2}!function(t,e,i){const r=t.data,s=e.data,n=t.width,o=t.height,a=i.polarCenterX||n/2,h=i.polarCenterY||o/2;let l=Math.sqrt(a*a+h*h),d=n-a,c=o-h;const u=Math.sqrt(d*d+c*c);l=u>l?u:l;const g=o,f=n;let p,_;for(d=0;d<n;d+=1)for(c=0;c<o;c+=1){const t=d-a,e=c-h,i=Math.sqrt(t*t+e*e)*g/l;let o=(180*Math.atan2(e,t)/Math.PI+360+0)%360;o=o*f/360,p=Math.floor(o),_=Math.floor(i);let u=4*(_*n+p);const m=r[u+0],y=r[u+1],v=r[u+2],x=r[u+3];u=4*(c*n+d),s[u+0]=m,s[u+1]=y,s[u+2]=v,s[u+3]=x}}(y,t,{})},t.Factory.addGetterSetter(e.Node,"kaleidoscopePower",2,(0,r.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"kaleidoscopeAngle",0,(0,r.getNumberValidator)(),t.Factory.afterSetFilter),le}var ce,ue={};function ge(){if(ce)return ue;ce=1,Object.defineProperty(ue,"__esModule",{value:!0}),ue.Mask=void 0;const t=P(),e=M(),i=k();function r(t,e,i){let r=4*(i*t.width+e);const s=[];return s.push(t.data[r++],t.data[r++],t.data[r++],t.data[r++]),s}function s(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))}return ue.Mask=function(t){let e=function(t,e){const i=r(t,0,0),n=r(t,t.width-1,0),o=r(t,0,t.height-1),a=r(t,t.width-1,t.height-1),h=e||10;if(s(i,n)<h&&s(n,a)<h&&s(a,o)<h&&s(o,i)<h){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,a,o]),r=[];for(let i=0;i<t.width*t.height;i++){const n=s(e,[t.data[4*i],t.data[4*i+1],t.data[4*i+2]]);r[i]=n<h?0:255}return r}}(t,this.threshold());return e&&(e=function(t,e,i){const r=[1,1,1,1,0,1,1,1,1],s=Math.round(Math.sqrt(r.length)),n=Math.floor(s/2),o=[];for(let a=0;a<i;a++)for(let h=0;h<e;h++){const l=a*e+h;let d=0;for(let o=0;o<s;o++)for(let l=0;l<s;l++){const c=a+o-n,u=h+l-n;if(c>=0&&c<i&&u>=0&&u<e){const i=r[o*s+l];d+=t[c*e+u]*i}}o[l]=2040===d?255:0}return o}(e,t.width,t.height),e=function(t,e,i){const r=[1,1,1,1,1,1,1,1,1],s=Math.round(Math.sqrt(r.length)),n=Math.floor(s/2),o=[];for(let a=0;a<i;a++)for(let h=0;h<e;h++){const l=a*e+h;let d=0;for(let o=0;o<s;o++)for(let l=0;l<s;l++){const c=a+o-n,u=h+l-n;if(c>=0&&c<i&&u>=0&&u<e){const i=r[o*s+l];d+=t[c*e+u]*i}}o[l]=d>=1020?255:0}return o}(e,t.width,t.height),e=function(t,e,i){const r=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],s=Math.round(Math.sqrt(r.length)),n=Math.floor(s/2),o=[];for(let a=0;a<i;a++)for(let h=0;h<e;h++){const l=a*e+h;let d=0;for(let o=0;o<s;o++)for(let l=0;l<s;l++){const c=a+o-n,u=h+l-n;if(c>=0&&c<i&&u>=0&&u<e){const i=r[o*s+l];d+=t[c*e+u]*i}}o[l]=d}return o}(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},t.Factory.addGetterSetter(e.Node,"threshold",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),ue}var fe,pe={};var _e,me={};var ye,ve={};var xe,we={};var be,Se={};var Ce,Te={};var Ae,ke={};var Pe,Me,Re={};function Ee(){if(Me)return n;Me=1,Object.defineProperty(n,"__esModule",{value:!0}),n.Konva=void 0;const t=et(),e=function(){if(it)return rt;it=1,Object.defineProperty(rt,"__esModule",{value:!0}),rt.Arc=void 0;const t=P(),e=z(),i=h(),r=k(),s=h();let n=class extends e.Shape{_sceneFunc(t){const e=i.Konva.getAngle(this.angle()),r=this.clockwise();t.beginPath(),t.arc(0,0,this.outerRadius(),0,e,r),t.arc(0,0,this.innerRadius(),e,0,!r),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(),r=this.clockwise(),s=i.Konva.getAngle(r?360-this.angle():this.angle()),n=Math.cos(Math.min(s,Math.PI)),o=Math.sin(Math.min(Math.max(Math.PI,s),3*Math.PI/2)),a=Math.sin(Math.min(s,Math.PI/2)),h=n*(n>0?t:e),l=o*(o>0?t:e),d=a*(a>0?e:t);return{x:h,y:r?-1*d:l,width:1*e-h,height:d-l}}};return rt.Arc=n,n.prototype._centroid=!0,n.prototype.className="Arc",n.prototype._attrsAffectingSize=["innerRadius","outerRadius","angle","clockwise"],(0,s._registerNode)(n),t.Factory.addGetterSetter(n,"innerRadius",0,(0,r.getNumberValidator)()),t.Factory.addGetterSetter(n,"outerRadius",0,(0,r.getNumberValidator)()),t.Factory.addGetterSetter(n,"angle",0,(0,r.getNumberValidator)()),t.Factory.addGetterSetter(n,"clockwise",!1,(0,r.getBooleanValidator)()),rt}(),i=function(){if(dt)return nt;dt=1,Object.defineProperty(nt,"__esModule",{value:!0}),nt.Arrow=void 0;const t=P(),e=at(),i=k(),r=h(),s=gt();let n=class extends e.Line{_sceneFunc(t){super._sceneFunc(t);const e=2*Math.PI,i=this.points();let r=i;const n=0!==this.tension()&&i.length>4;n&&(r=this.getTensionPoints());const o=this.pointerLength(),a=i.length;let h,l;if(n){const t=[r[r.length-4],r[r.length-3],r[r.length-2],r[r.length-1],i[a-2],i[a-1]],e=s.Path.calcLength(r[r.length-4],r[r.length-3],"C",t),n=s.Path.getPointOnQuadraticBezier(Math.min(1,1-o/e),t[0],t[1],t[2],t[3],t[4],t[5]);h=i[a-2]-n.x,l=i[a-1]-n.y}else h=i[a-2]-i[a-4],l=i[a-1]-i[a-3];const d=(Math.atan2(l,h)+e)%e,c=this.pointerWidth();this.pointerAtEnding()&&(t.save(),t.beginPath(),t.translate(i[a-2],i[a-1]),t.rotate(d),t.moveTo(0,0),t.lineTo(-o,c/2),t.lineTo(-o,-c/2),t.closePath(),t.restore(),this.__fillStroke(t)),this.pointerAtBeginning()&&(t.save(),t.beginPath(),t.translate(i[0],i[1]),n?(h=(r[0]+r[2])/2-i[0],l=(r[1]+r[3])/2-i[1]):(h=i[2]-i[0],l=i[3]-i[1]),t.rotate((Math.atan2(-l,-h)+e)%e),t.moveTo(0,0),t.lineTo(-o,c/2),t.lineTo(-o,-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}}};return nt.Arrow=n,n.prototype.className="Arrow",(0,r._registerNode)(n),t.Factory.addGetterSetter(n,"pointerLength",10,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(n,"pointerWidth",10,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(n,"pointerAtBeginning",!1),t.Factory.addGetterSetter(n,"pointerAtEnding",!0),nt}(),r=function(){if(ft)return pt;ft=1,Object.defineProperty(pt,"__esModule",{value:!0}),pt.Circle=void 0;const t=P(),e=z(),i=k(),r=h();let s=class extends e.Shape{_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)}};return pt.Circle=s,s.prototype._centroid=!0,s.prototype.className="Circle",s.prototype._attrsAffectingSize=["radius"],(0,r._registerNode)(s),t.Factory.addGetterSetter(s,"radius",0,(0,i.getNumberValidator)()),pt}(),s=function(){if(_t)return mt;_t=1,Object.defineProperty(mt,"__esModule",{value:!0}),mt.Ellipse=void 0;const t=P(),e=z(),i=k(),r=h();let s=class extends e.Shape{_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)}};return mt.Ellipse=s,s.prototype.className="Ellipse",s.prototype._centroid=!0,s.prototype._attrsAffectingSize=["radiusX","radiusY"],(0,r._registerNode)(s),t.Factory.addComponentsGetterSetter(s,"radius",["x","y"]),t.Factory.addGetterSetter(s,"radiusX",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"radiusY",0,(0,i.getNumberValidator)()),mt}(),o=function(){if(yt)return vt;yt=1,Object.defineProperty(vt,"__esModule",{value:!0}),vt.Image=void 0;const t=c(),e=P(),i=z(),r=h(),s=k();class n extends i.Shape{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(e){const i=this.getWidth(),r=this.getHeight(),s=this.cornerRadius(),n=this.attrs.image;let o;if(n){const t=this.attrs.cropWidth,e=this.attrs.cropHeight;o=t&&e?[n,this.cropX(),this.cropY(),t,e,0,0,i,r]:[n,0,0,i,r]}(this.hasFill()||this.hasStroke()||s)&&(e.beginPath(),s?t.Util.drawRoundedRectPath(e,i,r,s):e.rect(0,0,i,r),e.closePath(),e.fillStrokeShape(this)),n&&(s&&e.clip(),e.drawImage.apply(e,o))}_hitFunc(e){const i=this.width(),r=this.height(),s=this.cornerRadius();e.beginPath(),s?t.Util.drawRoundedRectPath(e,i,r,s):e.rect(0,0,i,r),e.closePath(),e.fillStrokeShape(this)}getWidth(){var t,e;return null!==(t=this.attrs.width)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.width}getHeight(){var t,e;return null!==(t=this.attrs.height)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.height}static fromURL(e,i,r=null){const s=t.Util.createImageElement();s.onload=function(){const t=new n({image:s});i(t)},s.onerror=r,s.crossOrigin="Anonymous",s.src=e}}return vt.Image=n,n.prototype.className="Image",(0,r._registerNode)(n),e.Factory.addGetterSetter(n,"cornerRadius",0,(0,s.getNumberOrArrayOfNumbersValidator)(4)),e.Factory.addGetterSetter(n,"image"),e.Factory.addComponentsGetterSetter(n,"crop",["x","y","width","height"]),e.Factory.addGetterSetter(n,"cropX",0,(0,s.getNumberValidator)()),e.Factory.addGetterSetter(n,"cropY",0,(0,s.getNumberValidator)()),e.Factory.addGetterSetter(n,"cropWidth",0,(0,s.getNumberValidator)()),e.Factory.addGetterSetter(n,"cropHeight",0,(0,s.getNumberValidator)()),vt}(),a=function(){if(xt)return wt;xt=1,Object.defineProperty(wt,"__esModule",{value:!0}),wt.Tag=wt.Label=void 0;const t=P(),e=z(),i=Y(),r=k(),s=h(),n=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],o="up",a="right",l="down",d="left",c=n.length;let u=class extends i.Group{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 r=function(){i._sync()};for(e=0;e<c;e++)t.on(n[e]+"Change.konva",r)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let t,e,i,r,s,n,h,c=this.getText(),u=this.getTag();if(c&&u){switch(t=c.width(),e=c.height(),i=u.pointerDirection(),r=u.pointerWidth(),h=u.pointerHeight(),s=0,n=0,i){case o:s=t/2,n=-1*h;break;case a:s=t+r,n=e/2;break;case l:s=t/2,n=e+h;break;case d:s=-1*r,n=e/2}u.setAttrs({x:-1*s,y:-1*n,width:t,height:e}),c.setAttrs({x:-1*s,y:-1*n})}}};wt.Label=u,u.prototype.className="Label",(0,s._registerNode)(u);class g extends e.Shape{_sceneFunc(t){const e=this.width(),i=this.height(),r=this.pointerDirection(),s=this.pointerWidth(),n=this.pointerHeight(),h=this.cornerRadius();let c=0,u=0,g=0,f=0;"number"==typeof h?c=u=g=f=Math.min(h,e/2,i/2):(c=Math.min(h[0]||0,e/2,i/2),u=Math.min(h[1]||0,e/2,i/2),f=Math.min(h[2]||0,e/2,i/2),g=Math.min(h[3]||0,e/2,i/2)),t.beginPath(),t.moveTo(c,0),r===o&&(t.lineTo((e-s)/2,0),t.lineTo(e/2,-1*n),t.lineTo((e+s)/2,0)),t.lineTo(e-u,0),t.arc(e-u,u,u,3*Math.PI/2,0,!1),r===a&&(t.lineTo(e,(i-n)/2),t.lineTo(e+s,i/2),t.lineTo(e,(i+n)/2)),t.lineTo(e,i-f),t.arc(e-f,i-f,f,0,Math.PI/2,!1),r===l&&(t.lineTo((e+s)/2,i),t.lineTo(e/2,i+n),t.lineTo((e-s)/2,i)),t.lineTo(g,i),t.arc(g,i-g,g,Math.PI/2,Math.PI,!1),r===d&&(t.lineTo(0,(i+n)/2),t.lineTo(-1*s,i/2),t.lineTo(0,(i-n)/2)),t.lineTo(0,c),t.arc(c,c,c,Math.PI,3*Math.PI/2,!1),t.closePath(),t.fillStrokeShape(this)}getSelfRect(){let t=0,e=0,i=this.pointerWidth(),r=this.pointerHeight(),s=this.pointerDirection(),n=this.width(),h=this.height();return s===o?(e-=r,h+=r):s===l?h+=r:s===d?(t-=1.5*i,n+=i):s===a&&(n+=1.5*i),{x:t,y:e,width:n,height:h}}}return wt.Tag=g,g.prototype.className="Tag",(0,s._registerNode)(g),t.Factory.addGetterSetter(g,"pointerDirection","none"),t.Factory.addGetterSetter(g,"pointerWidth",0,(0,r.getNumberValidator)()),t.Factory.addGetterSetter(g,"pointerHeight",0,(0,r.getNumberValidator)()),t.Factory.addGetterSetter(g,"cornerRadius",0,(0,r.getNumberOrArrayOfNumbersValidator)(4)),wt}(),l=at(),d=gt(),u=Ct(),g=function(){if(Tt)return At;Tt=1,Object.defineProperty(At,"__esModule",{value:!0}),At.RegularPolygon=void 0;const t=P(),e=z(),i=k(),r=h();let s=class extends e.Shape{_sceneFunc(t){const e=this._getPoints();t.beginPath(),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 r=0;r<t;r++)i.push({x:e*Math.sin(2*r*Math.PI/t),y:-1*e*Math.cos(2*r*Math.PI/t)});return i}getSelfRect(){const t=this._getPoints();let e=t[0].x,i=t[0].y,r=t[0].x,s=t[0].y;return t.forEach(t=>{e=Math.min(e,t.x),i=Math.max(i,t.x),r=Math.min(r,t.y),s=Math.max(s,t.y)}),{x:e,y:r,width:i-e,height:s-r}}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}};return At.RegularPolygon=s,s.prototype.className="RegularPolygon",s.prototype._centroid=!0,s.prototype._attrsAffectingSize=["radius"],(0,r._registerNode)(s),t.Factory.addGetterSetter(s,"radius",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"sides",0,(0,i.getNumberValidator)()),At}(),f=function(){if(kt)return Pt;kt=1,Object.defineProperty(Pt,"__esModule",{value:!0}),Pt.Ring=void 0;const t=P(),e=z(),i=k(),r=h(),s=2*Math.PI;let n=class extends e.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.innerRadius(),0,s,!1),t.moveTo(this.outerRadius(),0),t.arc(0,0,this.outerRadius(),s,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)}};return Pt.Ring=n,n.prototype.className="Ring",n.prototype._centroid=!0,n.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,r._registerNode)(n),t.Factory.addGetterSetter(n,"innerRadius",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(n,"outerRadius",0,(0,i.getNumberValidator)()),Pt}(),p=function(){if(Mt)return Rt;Mt=1,Object.defineProperty(Rt,"__esModule",{value:!0}),Rt.Sprite=void 0;const t=P(),e=z(),i=J(),r=k(),s=h();let n=class extends e.Shape{constructor(t){super(t),this._updated=!0,this.anim=new i.Animation(()=>{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(),r=4*i,s=this.animations()[e],n=this.frameOffsets(),o=s[r+0],a=s[r+1],h=s[r+2],l=s[r+3],d=this.image();if((this.hasFill()||this.hasStroke())&&(t.beginPath(),t.rect(0,0,h,l),t.closePath(),t.fillStrokeShape(this)),d)if(n){const r=n[e],s=2*i;t.drawImage(d,o,a,h,l,r[s+0],r[s+1],h,l)}else t.drawImage(d,o,a,h,l,0,0,h,l)}_hitFunc(t){const e=this.animation(),i=this.frameIndex(),r=4*i,s=this.animations()[e],n=this.frameOffsets(),o=s[r+2],a=s[r+3];if(t.beginPath(),n){const r=n[e],s=2*i;t.rect(r[s+0],r[s+1],o,a)}else t.rect(0,0,o,a);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)}};return Rt.Sprite=n,n.prototype.className="Sprite",(0,s._registerNode)(n),t.Factory.addGetterSetter(n,"animation"),t.Factory.addGetterSetter(n,"animations"),t.Factory.addGetterSetter(n,"frameOffsets"),t.Factory.addGetterSetter(n,"image"),t.Factory.addGetterSetter(n,"frameIndex",0,(0,r.getNumberValidator)()),t.Factory.addGetterSetter(n,"frameRate",17,(0,r.getNumberValidator)()),t.Factory.backCompat(n,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"}),Rt}(),_=function(){if(Et)return Ft;Et=1,Object.defineProperty(Ft,"__esModule",{value:!0}),Ft.Star=void 0;const t=P(),e=z(),i=k(),r=h();let s=class extends e.Shape{_sceneFunc(t){const e=this.innerRadius(),i=this.outerRadius(),r=this.numPoints();t.beginPath(),t.moveTo(0,0-i);for(let s=1;s<2*r;s++){const n=s%2==0?i:e,o=n*Math.sin(s*Math.PI/r),a=-1*n*Math.cos(s*Math.PI/r);t.lineTo(o,a)}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)}};return Ft.Star=s,s.prototype.className="Star",s.prototype._centroid=!0,s.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,r._registerNode)(s),t.Factory.addGetterSetter(s,"numPoints",5,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"innerRadius",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"outerRadius",0,(0,i.getNumberValidator)()),Ft}(),m=Lt(),y=function(){if(Dt)return Gt;Dt=1,Object.defineProperty(Gt,"__esModule",{value:!0}),Gt.TextPath=void 0;const t=c(),e=P(),i=z(),r=gt(),s=Lt(),n=k(),o=h(),a="normal";function l(t){t.fillText(this.partialText,0,0)}function d(t){t.strokeText(this.partialText,0,0)}let u=class extends i.Shape{constructor(e){super(e),this.dummyCanvas=t.Util.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",this._setTextData),this._setTextData()}_getTextPathLength(){return r.Path.getPathLength(this.dataArray)}_getPointAtLength(t){return this.attrs.data?t-1>this.pathLength?null:r.Path.getPointAtLengthOfDataArray(t,this.dataArray):null}_readDataAttribute(){this.dataArray=r.Path.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(),r=this.fontSize(),s=this.glyphInfo;"underline"===e&&t.beginPath();for(let i=0;i<s.length;i++){t.save();const n=s[i].p0;t.translate(n.x,n.y),t.rotate(s[i].rotation),this.partialText=s[i].text,t.fillStrokeShape(this),"underline"===e&&(0===i&&t.moveTo(0,r/2+1),t.lineTo(r,r/2+1)),t.restore()}"underline"===e&&(t.strokeStyle=i,t.lineWidth=r/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 r=e[i].p1;t.lineTo(r.x,r.y)}t.setAttr("lineWidth",this.fontSize()),t.setAttr("strokeStyle",this.colorKey),t.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return t.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(t){return s.Text.prototype.setText.call(this,t)}_getContextFont(){return s.Text.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{width:t,height:e}=this._getTextSize(this.attrs.text);if(this.textWidth=t,this.textHeight=e,this.glyphInfo=[],!this.attrs.data)return null;const i=this.letterSpacing(),n=this.align(),o=this.kerningFunc(),a=Math.max(this.textWidth+((this.attrs.text||"").length-1)*i,0);let h=0;"center"===n&&(h=Math.max(0,this.pathLength/2-a/2)),"right"===n&&(h=Math.max(0,this.pathLength-a));const l=(0,s.stringToArray)(this.text());let d=h;for(let t=0;t<l.length;t++){const e=this._getPointAtLength(d);if(!e)return;let s=this._getTextSize(l[t]).width+i;if(" "===l[t]&&"justify"===n){const t=this.text().split(" ").length-1;s+=(this.pathLength-a)/t}const h=this._getPointAtLength(d+s);if(!h)return;const c=r.Path.getLineLength(e.x,e.y,h.x,h.y);let u=0;if(o)try{u=o(l[t-1],l[t])*this.fontSize()}catch(t){u=0}e.x+=u,h.x+=u,this.textWidth+=u;const g=r.Path.getPointOnLine(u+c/2,e.x,e.y,h.x,h.y),f=Math.atan2(h.y-e.y,h.x-e.x);this.glyphInfo.push({transposeX:g.x,transposeY:g.y,text:l[t],rotation:f,p0:e,p1:h}),d+=s}}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,r=t[0]||0,s=t[0]||0,n=t[1]||0,o=t[1]||0;for(let a=0;a<t.length/2;a++)e=t[2*a],i=t[2*a+1],r=Math.min(r,e),s=Math.max(s,e),n=Math.min(n,i),o=Math.max(o,i);const a=this.fontSize();return{x:r-a/2,y:n-a/2,width:s-r+a,height:o-n+a}}destroy(){return t.Util.releaseCanvas(this.dummyCanvas),super.destroy()}};return Gt.TextPath=u,u.prototype._fillFunc=l,u.prototype._strokeFunc=d,u.prototype._fillFuncHit=l,u.prototype._strokeFuncHit=d,u.prototype.className="TextPath",u.prototype._attrsAffectingSize=["text","fontSize","data"],(0,o._registerNode)(u),e.Factory.addGetterSetter(u,"data"),e.Factory.addGetterSetter(u,"fontFamily","Arial"),e.Factory.addGetterSetter(u,"fontSize",12,(0,n.getNumberValidator)()),e.Factory.addGetterSetter(u,"fontStyle",a),e.Factory.addGetterSetter(u,"align","left"),e.Factory.addGetterSetter(u,"letterSpacing",0,(0,n.getNumberValidator)()),e.Factory.addGetterSetter(u,"textBaseline","middle"),e.Factory.addGetterSetter(u,"fontVariant",a),e.Factory.addGetterSetter(u,"text",""),e.Factory.addGetterSetter(u,"textDecoration",""),e.Factory.addGetterSetter(u,"kerningFunc",void 0),Gt}(),v=Ut(),x=function(){if(Bt)return zt;Bt=1,Object.defineProperty(zt,"__esModule",{value:!0}),zt.Wedge=void 0;const t=P(),e=z(),i=h(),r=k(),s=h();let n=class extends e.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.radius(),0,i.Konva.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)}};return zt.Wedge=n,n.prototype.className="Wedge",n.prototype._centroid=!0,n.prototype._attrsAffectingSize=["radius"],(0,s._registerNode)(n),t.Factory.addGetterSetter(n,"radius",0,(0,r.getNumberValidator)()),t.Factory.addGetterSetter(n,"angle",0,(0,r.getNumberValidator)()),t.Factory.addGetterSetter(n,"clockwise",!1),t.Factory.backCompat(n,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"}),zt}(),w=jt(),b=function(){if(Kt)return Xt;Kt=1,Object.defineProperty(Xt,"__esModule",{value:!0}),Xt.Brighten=void 0;const t=P(),e=M(),i=k();return Xt.Brighten=function(t){const e=255*this.brightness(),i=t.data,r=i.length;for(let t=0;t<r;t+=4)i[t]+=e,i[t+1]+=e,i[t+2]+=e},t.Factory.addGetterSetter(e.Node,"brightness",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),Xt}(),S=function(){if(Yt)return qt;Yt=1,Object.defineProperty(qt,"__esModule",{value:!0}),qt.Contrast=void 0;const t=P(),e=M(),i=k();return qt.Contrast=function(t){const e=Math.pow((this.contrast()+100)/100,2),i=t.data,r=i.length;let s=150,n=150,o=150;for(let t=0;t<r;t+=4)s=i[t],n=i[t+1],o=i[t+2],s/=255,s-=.5,s*=e,s+=.5,s*=255,n/=255,n-=.5,n*=e,n+=.5,n*=255,o/=255,o-=.5,o*=e,o+=.5,o*=255,s=s<0?0:s>255?255:s,n=n<0?0:n>255?255:n,o=o<0?0:o>255?255:o,i[t]=s,i[t+1]=n,i[t+2]=o},t.Factory.addGetterSetter(e.Node,"contrast",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),qt}(),C=function(){if(Qt)return Jt;Qt=1,Object.defineProperty(Jt,"__esModule",{value:!0}),Jt.Emboss=void 0;const t=P(),e=M(),i=c(),r=k();return Jt.Emboss=function(t){const e=10*this.embossStrength(),r=255*this.embossWhiteLevel(),s=this.embossDirection(),n=this.embossBlend(),o=t.data,a=t.width,h=t.height,l=4*a;let d=0,c=0,u=h;switch(s){case"top-left":d=-1,c=-1;break;case"top":d=-1,c=0;break;case"top-right":d=-1,c=1;break;case"right":d=0,c=1;break;case"bottom-right":d=1,c=1;break;case"bottom":d=1,c=0;break;case"bottom-left":d=1,c=-1;break;case"left":d=0,c=-1;break;default:i.Util.error("Unknown emboss direction: "+s)}do{const t=(u-1)*l;let i=d;u+i<1&&(i=0),u+i>h&&(i=0);const s=(u-1+i)*a*4;let g=a;do{const i=t+4*(g-1);let h=c;g+h<1&&(h=0),g+h>a&&(h=0);const l=s+4*(g-1+h),d=o[i]-o[l],u=o[i+1]-o[l+1],f=o[i+2]-o[l+2];let p=d;const _=p>0?p:-p;if((u>0?u:-u)>_&&(p=u),(f>0?f:-f)>_&&(p=f),p*=e,n){const t=o[i]+p,e=o[i+1]+p,r=o[i+2]+p;o[i]=t>255?255:t<0?0:t,o[i+1]=e>255?255:e<0?0:e,o[i+2]=r>255?255:r<0?0:r}else{let t=r-p;t<0?t=0:t>255&&(t=255),o[i]=o[i+1]=o[i+2]=t}}while(--g)}while(--u)},t.Factory.addGetterSetter(e.Node,"embossStrength",.5,(0,r.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"embossWhiteLevel",.5,(0,r.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"embossDirection","top-left",void 0,t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"embossBlend",!1,void 0,t.Factory.afterSetFilter),Jt}(),T=function(){if(Zt)return $t;Zt=1,Object.defineProperty($t,"__esModule",{value:!0}),$t.Enhance=void 0;const t=P(),e=M(),i=k();function r(t,e,i,r,s){const n=i-e,o=s-r;if(0===n)return r+o/2;if(0===o)return r;let a=(t-e)/n;return a=o*a+r,a}return $t.Enhance=function(t){const e=t.data,i=e.length;let s,n,o,a=e[0],h=a,l=e[1],d=l,c=e[2],u=c;const g=this.enhance();if(0===g)return;for(let t=0;t<i;t+=4)s=e[t+0],s<a?a=s:s>h&&(h=s),n=e[t+1],n<l?l=n:n>d&&(d=n),o=e[t+2],o<c?c=o:o>u&&(u=o);let f,p,_,m,y,v;if(h===a&&(h=255,a=0),d===l&&(d=255,l=0),u===c&&(u=255,c=0),g>0)f=h+g*(255-h),p=a-g*(a-0),_=d+g*(255-d),m=l-g*(l-0),y=u+g*(255-u),v=c-g*(c-0);else{const t=.5*(h+a);f=h+g*(h-t),p=a+g*(a-t);const e=.5*(d+l);_=d+g*(d-e),m=l+g*(l-e);const i=.5*(u+c);y=u+g*(u-i),v=c+g*(c-i)}for(let t=0;t<i;t+=4)e[t+0]=r(e[t+0],a,h,p,f),e[t+1]=r(e[t+1],l,d,m,_),e[t+2]=r(e[t+2],c,u,v,y)},t.Factory.addGetterSetter(e.Node,"enhance",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),$t}(),A=(te||(te=1,Object.defineProperty(ee,"__esModule",{value:!0}),ee.Grayscale=void 0,ee.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}}),ee),R=function(){if(ie)return re;ie=1,Object.defineProperty(re,"__esModule",{value:!0}),re.HSL=void 0;const t=P(),e=M(),i=k();return t.Factory.addGetterSetter(e.Node,"hue",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"saturation",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"luminance",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),re.HSL=function(t){const e=t.data,i=e.length,r=Math.pow(2,this.saturation()),s=Math.abs(this.hue()+360)%360,n=127*this.luminance(),o=1*r*Math.cos(s*Math.PI/180),a=1*r*Math.sin(s*Math.PI/180),h=.299+.701*o+.167*a,l=.587-.587*o+.33*a,d=.114-.114*o-.497*a,c=.299-.299*o-.328*a,u=.587+.413*o+.035*a,g=.114-.114*o+.293*a,f=.299-.3*o+1.25*a,p=.587-.586*o-1.05*a,_=.114+.886*o-.2*a;let m,y,v,x;for(let t=0;t<i;t+=4)m=e[t+0],y=e[t+1],v=e[t+2],x=e[t+3],e[t+0]=h*m+l*y+d*v+n,e[t+1]=c*m+u*y+g*v+n,e[t+2]=f*m+p*y+_*v+n,e[t+3]=x},re}(),E=function(){if(se)return ne;se=1,Object.defineProperty(ne,"__esModule",{value:!0}),ne.HSV=void 0;const t=P(),e=M(),i=k();return ne.HSV=function(t){const e=t.data,i=e.length,r=Math.pow(2,this.value()),s=Math.pow(2,this.saturation()),n=Math.abs(this.hue()+360)%360,o=r*s*Math.cos(n*Math.PI/180),a=r*s*Math.sin(n*Math.PI/180),h=.299*r+.701*o+.167*a,l=.587*r-.587*o+.33*a,d=.114*r-.114*o-.497*a,c=.299*r-.299*o-.328*a,u=.587*r+.413*o+.035*a,g=.114*r-.114*o+.293*a,f=.299*r-.3*o+1.25*a,p=.587*r-.586*o-1.05*a,_=.114*r+.886*o-.2*a;for(let t=0;t<i;t+=4){const i=e[t+0],r=e[t+1],s=e[t+2],n=e[t+3];e[t+0]=h*i+l*r+d*s,e[t+1]=c*i+u*r+g*s,e[t+2]=f*i+p*r+_*s,e[t+3]=n}},t.Factory.addGetterSetter(e.Node,"hue",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"saturation",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"value",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),ne}(),F=(oe||(oe=1,Object.defineProperty(ae,"__esModule",{value:!0}),ae.Invert=void 0,ae.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]}),ae),I=de(),O=ge(),L=function(){if(fe)return pe;fe=1,Object.defineProperty(pe,"__esModule",{value:!0}),pe.Noise=void 0;const t=P(),e=M(),i=k();return pe.Noise=function(t){const e=255*this.noise(),i=t.data,r=i.length,s=e/2;for(let t=0;t<r;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()},t.Factory.addGetterSetter(e.Node,"noise",.2,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),pe}(),D=function(){if(_e)return me;_e=1,Object.defineProperty(me,"__esModule",{value:!0}),me.Pixelate=void 0;const t=P(),e=c(),i=M(),r=k();return me.Pixelate=function(t){let i=Math.ceil(this.pixelSize()),r=t.width,s=t.height,n=Math.ceil(r/i),o=Math.ceil(s/i),a=t.data;if(i<=0)e.Util.error("pixelSize value can not be <= 0");else for(let t=0;t<n;t+=1)for(let e=0;e<o;e+=1){let n=0,o=0,h=0,l=0;const d=t*i,c=d+i,u=e*i,g=u+i;let f=0;for(let t=d;t<c;t+=1)if(!(t>=r))for(let e=u;e<g;e+=1){if(e>=s)continue;const i=4*(r*e+t);n+=a[i+0],o+=a[i+1],h+=a[i+2],l+=a[i+3],f+=1}n/=f,o/=f,h/=f,l/=f;for(let t=d;t<c;t+=1)if(!(t>=r))for(let e=u;e<g;e+=1){if(e>=s)continue;const i=4*(r*e+t);a[i+0]=n,a[i+1]=o,a[i+2]=h,a[i+3]=l}}},t.Factory.addGetterSetter(i.Node,"pixelSize",8,(0,r.getNumberValidator)(),t.Factory.afterSetFilter),me}(),G=function(){if(ye)return ve;ye=1,Object.defineProperty(ve,"__esModule",{value:!0}),ve.Posterize=void 0;const t=P(),e=M(),i=k();return ve.Posterize=function(t){const e=Math.round(254*this.levels())+1,i=t.data,r=i.length,s=255/e;for(let t=0;t<r;t+=1)i[t]=Math.floor(i[t]/s)*s},t.Factory.addGetterSetter(e.Node,"levels",.5,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),ve}(),N=function(){if(xe)return we;xe=1,Object.defineProperty(we,"__esModule",{value:!0}),we.RGB=void 0;const t=P(),e=M(),i=k();return we.RGB=function(t){const e=t.data,i=e.length,r=this.red(),s=this.green(),n=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*r,e[t+1]=i*s,e[t+2]=i*n,e[t+3]=e[t+3]}},t.Factory.addGetterSetter(e.Node,"red",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),t.Factory.addGetterSetter(e.Node,"green",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),t.Factory.addGetterSetter(e.Node,"blue",0,i.RGBComponent,t.Factory.afterSetFilter),we}(),W=function(){if(be)return Se;be=1,Object.defineProperty(Se,"__esModule",{value:!0}),Se.RGBA=void 0;const t=P(),e=M(),i=k();return Se.RGBA=function(t){const e=t.data,i=e.length,r=this.red(),s=this.green(),n=this.blue(),o=this.alpha();for(let t=0;t<i;t+=4){const i=1-o;e[t]=r*o+e[t]*i,e[t+1]=s*o+e[t+1]*i,e[t+2]=n*o+e[t+2]*i}},t.Factory.addGetterSetter(e.Node,"red",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),t.Factory.addGetterSetter(e.Node,"green",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),t.Factory.addGetterSetter(e.Node,"blue",0,i.RGBComponent,t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"alpha",1,function(t){return this._filterUpToDate=!1,t>1?1:t<0?0:t}),Se}(),U=(Ce||(Ce=1,Object.defineProperty(Te,"__esModule",{value:!0}),Te.Sepia=void 0,Te.Sepia=function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4){const i=e[t+0],r=e[t+1],s=e[t+2];e[t+0]=Math.min(255,.393*i+.769*r+.189*s),e[t+1]=Math.min(255,.349*i+.686*r+.168*s),e[t+2]=Math.min(255,.272*i+.534*r+.131*s)}}),Te),B=(Ae||(Ae=1,Object.defineProperty(ke,"__esModule",{value:!0}),ke.Solarize=void 0,ke.Solarize=function(t){const e=t.data,i=t.width,r=4*i;let s=t.height;do{const t=(s-1)*r;let n=i;do{const i=t+4*(n-1);let r=e[i],s=e[i+1],o=e[i+2];r>127&&(r=255-r),s>127&&(s=255-s),o>127&&(o=255-o),e[i]=r,e[i+1]=s,e[i+2]=o}while(--n)}while(--s)}),ke),H=function(){if(Pe)return Re;Pe=1,Object.defineProperty(Re,"__esModule",{value:!0}),Re.Threshold=void 0;const t=P(),e=M(),i=k();return Re.Threshold=function(t){const e=255*this.threshold(),i=t.data,r=i.length;for(let t=0;t<r;t+=1)i[t]=i[t]<e?0:255},t.Factory.addGetterSetter(e.Node,"threshold",.5,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),Re}();return n.Konva=t.Konva.Util._assign(t.Konva,{Arc:e.Arc,Arrow:i.Arrow,Circle:r.Circle,Ellipse:s.Ellipse,Image:o.Image,Label:a.Label,Tag:a.Tag,Line:l.Line,Path:d.Path,Rect:u.Rect,RegularPolygon:g.RegularPolygon,Ring:f.Ring,Sprite:p.Sprite,Star:_.Star,Text:m.Text,TextPath:y.TextPath,Transformer:v.Transformer,Wedge:x.Wedge,Filters:{Blur:w.Blur,Brighten:b.Brighten,Contrast:S.Contrast,Emboss:C.Emboss,Enhance:T.Enhance,Grayscale:A.Grayscale,HSL:R.HSL,HSV:E.HSV,Invert:F.Invert,Kaleidoscope:I.Kaleidoscope,Mask:O.Mask,Noise:L.Noise,Pixelate:D.Pixelate,Posterize:G.Posterize,RGB:N.RGB,RGBA:W.RGBA,Sepia:U.Sepia,Solarize:B.Solarize,Threshold:H.Threshold}}),n}var Fe,Ie=s.exports;var Oe=i(function(){if(Fe)return s.exports;Fe=1,Object.defineProperty(Ie,"__esModule",{value:!0});const t=Ee();return s.exports=t.Konva,s.exports}());class Le{screenToWorld(t){return{x:t.x,y:t.y,z:0}}worldToScreen(t){return{x:t.x,y:t.y}}getScale(){return{x:1,y:1,z:1}}}class De{constructor(t,e,i){this.setColor(t,e,i)}asHex(){return"#"+this.HEX}asRGB(){return{r:this.R,g:this.G,b:this.B}}setColor(t,e,i){this.R=t,this.G=e,this.B=i,this.HEX=this.rgbToHex(t,e,i)}rgbToHex(t,e,i){const r=t=>{const e=t.toString(16);return"0"===e?"00":e};return r(t)+r(e)+r(i)}}const Ge=new Map([["solid",[]],["dot",[30,30,.001,30]],["dash",[30,30]]]);class Ne{constructor(t,e=null,i=new Le){var r,s;if(this._worldTransformer=i,e){this._ref=e;let t=this._ref.getAttr("wcsPoints");if(!t){t=[];const e=this._ref.points();let i;for(let r=0;r<e.length;r+=2)i=this._worldTransformer.screenToWorld({x:e[r],y:e[r+1]}),t.push({x:i.x,y:i.y,z:i.z});this._ref.setAttr("wcsPoints",t)}return}t||(t={}),t.points||(t.points=[{x:0,y:0},{x:100,y:100}]);const n=[],o=[];t.points.forEach(t=>{n.push(t.x,t.y);const e=this._worldTransformer.screenToWorld({x:t.x,y:t.y});o.push({x:e.x,y:e.y,z:e.z})}),this._ref=new Oe.Line({stroke:null!==(r=t.color)&&void 0!==r?r:"#ff0000",strokeWidth:null!==(s=t.width)&&void 0!==s?s:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:n,draggable:!0,strokeScaleEnabled:!1,dash:Ge.get(t.type)||[]}),this._ref.setAttr("wcsPoints",o),this._ref.on("transform",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation)}),this._ref.on("transformend",()=>{const t=this._ref.getAbsoluteTransform(),e=[],i=this._ref.points();let r;for(let s=0;s<i.length;s+=2){const n=t.point({x:i[s],y:i[s+1]});r=this._worldTransformer.screenToWorld({x:n.x,y:n.y}),e.push({x:r.x,y:r.y,z:r.z})}this._ref.setAttr("wcsPoints",e)}),this._ref.on("dragend",()=>{const t=this._ref.getAbsoluteTransform(),e=[],i=this._ref.points();let r;for(let s=0;s<i.length;s+=2){const n=t.point({x:i[s],y:i[s+1]});r=this._worldTransformer.screenToWorld({x:n.x,y:n.y}),e.push({x:r.x,y:r.y,z:r.z})}this._ref.setAttr("wcsPoints",e)}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Line"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){return this._ref.points()}setLineWidth(t){this._ref.strokeWidth(t)}getLineWidth(){return this._ref.strokeWidth()}getLineType(){let t;switch(this._ref.dash()||[]){case Ge.get("dot"):t="dot";break;case Ge.get("dash"):t="dash";break;default:t="solid"}return t}setLineType(t){const e=Ge.get(t);e&&this._ref.dash(e)}addPoints(t){let e=this._ref.points();const i=this._ref.getAttr("wcsPoints");t.forEach(t=>{e=e.concat([t.x,t.y]);const r=this._worldTransformer.screenToWorld(t);i.push(r)}),this._ref.points(e)}updateScreenCoordinates(){const t=this._ref.getAttr("wcsPoints"),e=[];let i=this._ref.getAbsoluteTransform().copy();i=i.invert(),t.forEach(t=>{let r=this._worldTransformer.worldToScreen(t);r=i.point({x:r.x,y:r.y}),e.push(r.x),e.push(r.y)}),this._ref.points([]),this._ref.points(e),this._ref.clearCache()}}class We{constructor(t,e=null,i=new Le){var r,s,n;if(this.TEXT_FONT_FAMILY="Calibri",this._worldTransformer=i,e){this._ref=e;return void(this._ref.getAttr("wcsStart")||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})))}t||(t={}),t.position||(t.position={x:0,y:0}),t.text||(t.text="default"),this._ref=new Oe.Text({x:t.position.x,y:t.position.y,text:t.text,fontSize:null!==(r=t.fontSize)&&void 0!==r?r:34,fontFamily:this.TEXT_FONT_FAMILY,fill:null!==(s=t.color)&&void 0!==s?s:"#ff0000",align:"left",draggable:!0,rotation:null!==(n=t.rotation)&&void 0!==n?n:0}),this._ref.width(this._ref.getTextWidth()),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.on("transform",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,r=Math.abs(e.scaleY-1)>1e-5;let s=this._ref.width();i&&(s*=e.scaleX);let n=this._ref.height();r&&(n*=e.scaleY);s<50&&(s=50),n<Math.round(this.getFontSize())&&(n=Math.round(this.getFontSize())),i&&this._ref.width(s),r&&this._ref.height(n),this._ref.scale({x:1,y:1})}),this._ref.on("transformend",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(i))}),this._ref.on("dragend",()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t))}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Text"}getColor(){return this._ref.fill()}setColor(t){this._ref.fill(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getText(){return this._ref.text()}setText(t){this._ref.text(t)}getPosition(){return this._ref.getPosition()}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}))}getFontSize(){return this._ref.fontSize()}setFontSize(t){this._ref.fontSize(t)}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart"));let e=this._ref.getStage().getAbsoluteTransform().copy();e=e.invert();const i=e.point(t);this._ref.position({x:i.x,y:i.y})}}class Ue{constructor(t,e=null,i=new Le){var r,s,n,o;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");if(t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),!i){const t={x:e.x()+e.width(),y:e.y()+e.height()};this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x,y:t.y}))}return}t||(t={}),t.position||(t.position={x:0,y:0}),t.position2?(t.width=t.position2.x-t.position.x,t.height=t.position2.y-t.position.y):t.width&&t.height?t.position2={x:t.position.x+t.width,y:t.position.y+t.height}:(t.position2={x:200,y:200},t.width=200,t.height=200),this._ref=new Oe.Rect({stroke:null!==(r=t.color)&&void 0!==r?r:"#ff0000",strokeWidth:null!==(s=t.lineWidth)&&void 0!==s?s:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",x:t.position.x,y:t.position.y,width:null!==(n=t.width)&&void 0!==n?n:200,height:null!==(o=t.height)&&void 0!==o?o:200,draggable:!0,strokeScaleEnabled:!1}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.position2.x,y:t.position2.y})),this._ref.on("transform",t=>{const e=t.target.attrs,i=Math.abs(e.scaleX-1)>1e-5,r=Math.abs(e.scaleY-1)>1e-5;let s=this._ref.width();i&&(s*=e.scaleX);let n=this._ref.height();r&&(n*=e.scaleY);s<50&&(s=50),n<50&&(n=50),i&&this._ref.width(s),r&&this._ref.height(n),this._ref.scale({x:1,y:1})}),this._ref.on("transformend",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(i)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:i.x+this._ref.width(),y:i.y+this._ref.height()}))}),this._ref.on("dragend",()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))}),this._ref.id(this._ref._id.toString())}getPosition(){return this._ref.position()}getWidth(){return this._ref.width()}getHeight(){return this._ref.height()}setWidth(t){this._ref.width(t);const e={x:this._ref.x()+t,y:this._ref.y()+this._ref.height()},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}setHeight(t){this._ref.height(t);const e={x:this._ref.x()+this._ref.width(),y:this._ref.y()+t},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}));const i={x:t+this._ref.width(),y:e+this._ref.y()},r=this._worldTransformer.screenToWorld(i);this._ref.setAttr("wcsEnd",r)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Rectangle"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}setLineWidth(t){this._ref.strokeWidth(t)}getLineWidth(){return this._ref.strokeWidth()}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getStage().getAbsoluteTransform().copy();i=i.invert();const r=i.point(t),s=i.point(e);this._ref.position({x:r.x,y:r.y}),this._ref.width(Math.abs(s.x-r.x)),this._ref.height(Math.abs(s.y-r.y))}}function Be(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}class ze{constructor(t,e=null,i=new Le){var r,s,n;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsPosition"),i=this._ref.getAttr("wcsRadiusX"),r=this._ref.getAttr("wcsRadiusY");return t||this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),i||this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld({x:e.x()+e.radiusX(),y:e.y()})),void(r||this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()+e.radiusY()})))}t||(t={}),t.position||(t.position={x:0,y:0}),t.position2?(null!==(r=t.radius)&&void 0!==r||(t.radius={x:0,y:0}),t.radius.x=Be(t.position,t.position2),t.position3?t.radius.y=Be(t.position,t.position3):t.radius.x=t.radius.y):t.radius||(t.radius={x:25,y:25}),this._ref=new Oe.Ellipse({stroke:null!==(s=t.color)&&void 0!==s?s:"#ff0000",strokeWidth:null!==(n=t.lineWidth)&&void 0!==n?n:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",x:t.position.x,y:t.position.y,radiusX:t.radius.x,radiusY:t.radius.y,draggable:!0,strokeScaleEnabled:!1}),this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld({x:this._ref.x()+t.radius.x,y:this._ref.y()})),this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld({x:this._ref.x(),y:this._ref.y()+t.radius.y})),this._ref.on("transform",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,r=Math.abs(e.scaleY-1)>1e-5;let s=this._ref.radiusX();i&&(s*=e.scaleX);let n=this._ref.radiusY();r&&(n*=e.scaleY);s<25&&(s=25),n<25&&(n=25),t.evt.ctrlKey||t.evt.shiftKey?i?this._ref.radius({x:s,y:s}):this._ref.radius({x:n,y:n}):this._ref.radius({x:s,y:n}),this._ref.scale({x:1,y:1})}),this._ref.on("transformend",()=>{const t=this._ref.getStage().getAbsoluteTransform(),e=t.point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld(e));const i=t.point({x:this._ref.x()+this._ref.radiusX(),y:this._ref.y()});this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld(i));const r=t.point({x:this._ref.x(),y:this._ref.y()+this._ref.radiusY()});this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld(r))}),this._ref.on("dragend",()=>{const t=this._ref.getStage().getAbsoluteTransform(),e=t.point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld(e));const i=t.point({x:this._ref.x()+this._ref.radiusX(),y:this._ref.y()});this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld(i));const r=t.point({x:this._ref.x(),y:this._ref.y()+this._ref.radiusY()});this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld(r))}),this._ref.id(this._ref._id.toString())}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld({x:t,y:e}))}getRadiusX(){return this._ref.radiusX()}setRadiusX(t){this._ref.radiusX(t),this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld({x:this._ref.x()+t,y:this._ref.y()}))}getRadiusY(){return this._ref.radiusY()}setRadiusY(t){this._ref.radiusY(t),this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld({x:this._ref.x(),y:this._ref.y()+t}))}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Ellipse"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsPosition")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsRadiusX")),i=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsRadiusY"));let r=this._ref.getStage().getAbsoluteTransform().copy();r=r.invert();const s=r.point({x:t.x,y:t.y});this._ref.position({x:s.x,y:s.y}),this._ref.radius({x:Math.abs(r.point(e).x-s.x),y:Math.abs(r.point(i).y-s.y)})}}class He{constructor(t,e=null,i=new Le){var r,s;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");return t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.points()[0],y:e.points()[1]})),void(i||this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:e.points()[2],y:e.points()[3]})))}t||(t={}),t.start||(t.start={x:0,y:0}),t.end||(t.end={x:100,y:100}),this._ref=new Oe.Arrow({stroke:null!==(r=t.color)&&void 0!==r?r:"#ff0000",fill:null!==(s=t.color)&&void 0!==s?s:"#ff0000",strokeWidth:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:[t.start.x,t.start.y,t.end.x,t.end.y],draggable:!0,strokeScaleEnabled:!1}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.start.x,y:t.start.y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.end.x,y:t.end.y})),this._ref.on("transformend",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.points(),r=this._ref.getAbsoluteTransform(),s=r.point({x:i[0],y:i[1]}),n=r.point({x:i[2],y:i[3]});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(s)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld(n))}),this._ref.on("dragend",t=>{const e=this._ref.points(),i=t.target.getAbsoluteTransform(),r=i.point({x:e[0],y:e[1]}),s=i.point({x:e[2],y:e[3]});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(r)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld(s))}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Arrow"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t),this._ref.fill(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){const t=this._ref.points();return[{x:t[0],y:t[1]},{x:t[2],y:t[3]}]}setPoints(t){2===t.length&&(this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t[0].x,y:t[0].y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t[1].x,y:t[1].y})),this._ref.points([t[0].x,t[0].y,t[1].x,t[1].y]))}getStartPoint(){const t=this._ref.points();return{x:t[0],y:t[1]}}setStartPoint(t,e){const i=this._ref.points();this._ref.points([t,e,i[2],i[3]]),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}))}getEndPoint(){const t=this._ref.points();return{x:t[2],y:t[3]}}setEndPoint(t,e){const i=this._ref.points();this._ref.points([i[0],i[1],t,e]),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t,y:e}))}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getAbsoluteTransform().copy();i=i.invert();const r=i.point({x:t.x,y:t.y}),s=i.point({x:e.x,y:e.y});this._ref.points([r.x,r.y,s.x,s.y])}}class Ve{constructor(t,e=null,i=new Le){var r,s;if(this._ratio=1,this.EPSILON=1e-5,this.BASE64_HEADER_START="data:image/",this.BASE64_NOT_FOUND="data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAADsAAAA7AF5KHG9AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAmhJREFUWIXtlr9rVEEQxz+H8RQUJIdeIopYm0vkCg0GBBtbG1NF7Kxt7dR/IGIw/uhTaBNLERURg2kCEUyCYCPi70b0InjGS57FzOZN3r19d+9HJIVfWO52dma/s7Mz8xa2KAaBCWAR+AkECWOmSOIdwC1gtQOpHc+NfQ8wClQ8+1d0vcdH/lQ3bSIRGAZ2pTjAqNovANXIWlXlAXA2zvi2Ln4AjqYgtagYEutENSLvjRoOImFv5iB32Ae8UrLXwFBk3h9ndF0VJnKSO9gTu3yKu5Z1LKnS8YIcABgw5Ks692JZFXcXRJ46Aq6kikCnHNi/mQ50WwVtfaIoBzL3gRk2drSscJ2wrc4VvUoe2wn/41/iBfoVLRnBGnDSY3AAKacy8AmYR+o7K1zCl6wgrgpOAc/MuhvfgMuk+1JGHQgSBcAloKXy78AjYBppJk5/noTulseBMZ23iD/piHFkEdgTQzKk+5wHjmHC3cmBg0BD5xcSTrFXyQPgIWFtDwMvab+2N8DpbhyY1v/3E8gdDgNfVX9SCVZ0/gW4B0wB71S2BpxLcuCM/jaQSHSDEeAX4VMuAG4gTzyHbcAVXXO6GxxwIX+vvxe7JHcYQ07nHqklj96UIW/YhSWzMKcep8VVtf8B1Dw6h4DfhB+sdbgn2R+gnoEc5NR3dZ+3QJ9H74HqXLPCGlJyTfI9y3YCs0owq3OLOpKkLeBI1HhSDT/mdKIPiUCARMTlQx34TMLjtww8IczmO8AJ/N/2JNSQXAiQ671JePePge0+wzJSQq4FFzlaenIvucUAkiQLhC/mLGNZ9xgn5s63BP4CCk0QDtm4BhoAAAAASUVORK5CYII=",this._worldTransformer=i,e){e.src&&e.src.startsWith(this.BASE64_HEADER_START)||(e.src=this.BASE64_NOT_FOUND),e.height()<=this.EPSILON&&e.height(32),e.width()<=this.EPSILON&&e.width(32),this._ref=e,this._canvasImage=e.image(),this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width();const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");if(t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),!i){const t={x:e.x()+e.width(),y:e.y()+e.height()};this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x,y:t.y}))}return}t||(t={}),t.position||(t.position={x:0,y:0}),t.src&&t.src.startsWith(this.BASE64_HEADER_START)||(t.src=this.BASE64_NOT_FOUND),t.position2&&(t.width=t.position2.x-t.position.x,t.height=t.position2.y-t.position.y),this._canvasImage=new Image,this._canvasImage.onload=()=>{if(this._ref.image(this._canvasImage),this._ref.height()<=this.EPSILON&&this._ref.height(this._canvasImage.height),this._ref.width()<=this.EPSILON&&this._ref.width(this._canvasImage.width),this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width(),(t.width<=this.EPSILON||t.height<=this.EPSILON)&&(t.maxWidth>=this.EPSILON||t.maxWidth>=this.EPSILON)){const e=t.maxHeight-this._canvasImage.height,i=t.maxWidth-this._canvasImage.width;(e<=this.EPSILON||i<=this.EPSILON)&&(i<=this.EPSILON&&i<e/this._ratio?(this._ref.height(t.maxWidth*this._ratio),this._ref.width(t.maxWidth)):(this._ref.width(t.maxHeight/this._ratio),this._ref.height(t.maxHeight)))}const e=this._worldTransformer.screenToWorld({x:t.position.x+this._ref.width(),y:t.position.y+this._ref.height()});this._ref.setAttr("wcsEnd",e)},this._canvasImage.onerror=()=>{this._canvasImage.onerror=function(){},this._canvasImage.src=this.BASE64_NOT_FOUND},this._canvasImage.src=t.src,this._ref=new Oe.Image({x:t.position.x,y:t.position.y,image:this._canvasImage,width:null!==(r=t.width)&&void 0!==r?r:0,height:null!==(s=t.height)&&void 0!==s?s:0,draggable:!0}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),t.position2&&this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.position2.x,y:t.position2.y})),this._ref.on("transform",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,r=Math.abs(e.scaleY-1)>1e-5;let s=this._ref.width();i&&(s*=e.scaleX);let n=this._ref.height();r&&(n*=e.scaleY),t.evt.ctrlKey||t.evt.shiftKey?i?(this._ref.width(s),this._ref.height(s*this._ratio)):(this._ref.width(n/this._ratio),this._ref.height(n)):(i&&this._ref.width(s),r&&this._ref.height(n)),this._ref.scale({x:1,y:1})}),this._ref.on("transformend",()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))}),this._ref.on("dragend",()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))}),this._ref.id(this._ref._id.toString())}getSrc(){return this._canvasImage.src}setSrc(t){this._canvasImage.src=t}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t),this._ref.height(t*this._ratio);const e={x:this._ref.x()+t,y:this._ref.y()+this._ref.height()},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}getHeight(){return this._ref.height()}setHeight(t){this._ref.height(t),this._ref.width(t/this._ratio);const e={x:this._ref.x()+this._ref.width(),y:this._ref.y()+t},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Image"}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPosition(){return this._ref.getPosition()}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}));const i={x:t+this._ref.width(),y:e+this._ref.y()},r=this._worldTransformer.screenToWorld(i);this._ref.setAttr("wcsEnd",r)}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getStage().getAbsoluteTransform().copy();i=i.invert();const r=i.point(t),s=i.point(e);this._ref.position({x:r.x,y:r.y}),this._ref.width(Math.abs(s.x-r.x)),this._ref.height(Math.abs(s.y-r.y))}}class je{constructor(t,e=null,i=new Le){var r,s,n,o;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");if(t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),!i){const t={x:e.x()+e.width(),y:e.y()+e.height()};this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x,y:t.y}))}return}t||(t={}),t.position||(t.position={x:0,y:0}),t.position2?(t.width=t.position2.x-t.position.x,t.height=t.position2.y-t.position.y):t.width&&t.height?t.position2={x:t.position.x+t.width,y:t.position.y+t.height}:(t.position2={x:200,y:200},t.width=200,t.height=200);this._ref=new Oe.Shape({x:t.position.x,y:t.position.y,width:null!==(r=t.width)&&void 0!==r?r:200,height:null!==(s=t.height)&&void 0!==s?s:200,stroke:null!==(n=t.color)&&void 0!==n?n:"#ff0000",strokeWidth:null!==(o=t.lineWidth)&&void 0!==o?o:4,draggable:!0,strokeScaleEnabled:!1,globalCompositeOperation:"source-over",sceneFunc:(t,e)=>{const i=this._ref.width(),r=this._ref.height(),s=[{x:0,y:0},{x:0+i,y:0},{x:0+i,y:0+r},{x:0,y:0+r},{x:0,y:0}];function n(n,o){const a={x:(h={x:0,y:0}).x+i/2,y:h.y+r/2};var h;t.beginPath();for(let e=0;e<s.length-1;e++){let i=o;const r=s[e+1].x-s[e].x,h=s[e+1].y-s[e].y,l=Math.sqrt(r*r+h*h),d=Math.floor(l/i);i=o+d/(l%i);let c=s[e].x+r/d/2,u=s[e].y+h/d/2;const g=s[e+1].x,f=s[e+1].y,p=Math.atan((f-u)/(g-c)),_=p+Math.PI,m=c>a.x&&u>a.y;for(let e=0;e<d;e++)m?t.arc(c,u,n,p,_):t.arc(c,u,n,_,p),c+=r/d,u+=h/d}t.closePath(),t.fillStrokeShape(e)}i>=49||r>=49?n(8,15):i>=25||r>=25?n(4,7.5):(t.beginPath(),t.lineTo(s[1].x,s[1].y),t.lineTo(s[2].x,s[2].y),t.lineTo(s[3].x,s[3].y),t.lineTo(s[4].x,s[4].y),t.closePath(),t.fillStrokeShape(e))}}),this._ref.className="Cloud",this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.position2.x,y:t.position2.y})),this._ref.on("transform",t=>{const e=t.target.attrs,i=Math.abs(e.scaleX-1)>1e-5,r=Math.abs(e.scaleY-1)>1e-5;let s=this._ref.width();i&&(s*=e.scaleX);let n=this._ref.height();r&&(n*=e.scaleY),s<50&&(s=50),n<50&&(n=50),i&&this._ref.width(s),r&&this._ref.height(n),this._ref.scale({x:1,y:1})}),this._ref.on("transformend",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(i)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:i.x+this._ref.width(),y:i.y+this._ref.height()}))}),this._ref.on("dragend",()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))}),this._ref.getSelfRect=()=>({x:-8,y:-8,width:this._ref.width()+16,height:this._ref.height()+16}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Cloud"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.position({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}));const i={x:t+this._ref.width(),y:e+this._ref.y()},r=this._worldTransformer.screenToWorld(i);this._ref.setAttr("wcsEnd",r)}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t);const e={x:this._ref.x()+t,y:this._ref.y()+this._ref.height()},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}getHeight(){return this._ref.height()}setHeight(t){this._ref.height(t);const e={x:this._ref.x()+this._ref.width(),y:this._ref.y()+t},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getStage().getAbsoluteTransform().copy();i=i.invert();const r=i.point(t),s=i.point(e);this._ref.position({x:r.x,y:r.y}),this._ref.width(Math.abs(s.x-r.x)),this._ref.height(Math.abs(s.y-r.y))}}const Ke={SelectMarkup:{name:"SelectMarkup",initializer:null},Line:{name:"Line",initializer:(t,e=null,...i)=>new Ne(e,t,...i)},Text:{name:"Text",initializer:(t,e=null,...i)=>new We(e,t,...i)},Rectangle:{name:"Rect",initializer:(t,e=null,...i)=>new Ue(e,t,...i)},Ellipse:{name:"Ellipse",initializer:(t,e=null,...i)=>new ze(e,t,...i)},Arrow:{name:"Arrow",initializer:(t,e=null,...i)=>new He(e,t,...i)},Image:{name:"Image",initializer:(t,e=null,...i)=>new Ve(e,t,...i)},Cloud:{name:"Cloud",initializer:(t,e=null,...i)=>new je(e,t,...i)}};t.Markup=class{constructor(){this._markupIsActive=!1,this._markupColor=new De(255,0,0),this.lineWidth=4,this.lineType="solid",this.fontSize=34,this.changeActiveDragger=t=>{const e=t.data;this._markupContainer.className=this._container.className.split(" ").filter(t=>!t.startsWith("oda-cursor-")).filter(t=>t).concat(`oda-cursor-${e.toLowerCase()}`).join(" "),this.removeTextInput(),this.removeImageInput(),this.enableEditMode(e)},this.resizeContainer=t=>{if(!t||!t[0]||!t[0].contentRect)return;const{width:e,height:i}=t[0].contentRect;e&&i&&this._konvaStage&&(this._konvaStage.width(e),this._konvaStage.height(i),this.getObjects().forEach(t=>{t.updateScreenCoordinates()}))},this.resizeViewer=t=>{const{width:e,height:i}=t;e&&i&&this._konvaStage&&(this._konvaStage.width(e),this._konvaStage.height(i),this.getObjects().forEach(t=>{t.updateScreenCoordinates()}))},this.pan=()=>{this.getObjects().forEach(t=>{t.updateScreenCoordinates()})},this.zoomAt=()=>{this.getObjects().forEach(t=>{t.updateScreenCoordinates()})},this.redirectToViewer=t=>{this._viewer&&this._viewer.emit(t)},this.getRelativePointPosition=(t,e)=>{const i=e.getAbsoluteTransform().copy();return i.invert(),i.point(t)},this.getRelativePointerPosition=t=>this.getRelativePointPosition(t.getStage().getPointerPosition(),t)}initialize(t,e,i,r){if(!Oe)throw new Error('Markup error: Konva is not initialized. Forgot to add <script src="https://unpkg.com/konva@9/konva.min.js"><\/script> to your page?');this._viewer=i,this._worldTransformer=null!=r?r:new Le,this._container=t,this._markupContainer=document.createElement("div"),this._markupContainer.id="markup-container",this._markupContainer.style.position="absolute",this._markupContainer.style.top="0px",this._markupContainer.style.left="0px",this._markupContainer.style.outline="0px",this._markupContainer.style.pointerEvents="none";this._container.parentElement.appendChild(this._markupContainer),i?this._viewer.addEventListener("resize",this.resizeViewer):this._resizeObserver=new ResizeObserver(function(t,e){let i=null;return(...r)=>{i&&clearTimeout(i),i=setTimeout(()=>{i=null,t(...r)},e)}}(this.resizeContainer,100)),this._markupColor.setColor(255,0,0),this.initializeKonva(),this._viewer&&(this._viewer.addEventListener("changeactivedragger",this.changeActiveDragger),this._viewer.addEventListener("pan",this.pan),this._viewer.addEventListener("zoomat",this.zoomAt))}dispose(){var t,e;this._viewer&&(this._viewer.removeEventListener("zoomat",this.zoomAt),this._viewer.removeEventListener("pan",this.pan),this._viewer.removeEventListener("changeactivedragger",this.changeActiveDragger)),this.destroyKonva(),null===(t=this._resizeObserver)||void 0===t||t.disconnect(),this._resizeObserver=void 0,null===(e=this._markupContainer)||void 0===e||e.remove(),this._markupContainer=void 0,this._container=void 0,this._viewer=void 0,this._worldTransformer=void 0,this._markupIsActive=!1}syncOverlay(){}clearOverlay(){this.removeTextInput(),this.removeImageInput(),this.clearSelected(),this.getObjects().forEach(t=>t.delete())}getMarkupColor(){return this._markupColor.asRGB()}setMarkupColor(t,e,i){this._markupColor.setColor(t,e,i),this.redirectToViewer({type:"changemarkupcolor",data:{r:t,g:e,b:i}})}colorizeAllMarkup(t,e,i){this.setMarkupColor(t,e,i);const r=new De(t,e,i).asHex();this.getObjects().filter(t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,r)})}colorizeSelectedMarkups(t,e,i){const r=new De(t,e,i).asHex();this.getSelectedObjects().filter(t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,r)})}setViewpoint(t){var e,i,r,s,n,o,a,h;this.clearSelected(),this.removeTextInput(),this.removeImageInput(),this._konvaStage.scale({x:1,y:1}),this._konvaStage.position({x:0,y:0});const l=(null===(e=t.custom_fields)||void 0===e?void 0:e.markup_color)||{r:255,g:0,b:0};this.setMarkupColor(l.r,l.g,l.b),null===(i=t.lines)||void 0===i||i.forEach(t=>{const e=[];t.points.forEach(t=>{const i=this._worldTransformer.worldToScreen(t);e.push(i.x),e.push(i.y)}),this.addLine(e,t.color,t.type,t.width,t.id)}),null===(r=t.texts)||void 0===r||r.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addText(t.text,e,t.angle,t.color,t.text_size,t.font_size,t.id)}),null===(s=t.rectangles)||void 0===s||s.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null;this.addRectangle(e,i,t.width,t.height,t.line_width,t.color,t.id)}),null===(n=t.ellipses)||void 0===n||n.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null,r=t.position3?this._worldTransformer.worldToScreen(t.position3):null;this.addEllipse(e,i,r,t.radius,t.line_width,t.color,t.id)}),null===(o=t.arrows)||void 0===o||o.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.start),i=this._worldTransformer.worldToScreen(t.end);this.addArrow(e,i,t.color,t.id)}),null===(a=t.clouds)||void 0===a||a.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null;this.addCloud(e,i,t.width,t.height,t.line_width,t.color,t.id)}),null===(h=t.images)||void 0===h||h.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null;this.addImage(e,i,t.src,t.width,t.height,t.id)})}getViewpoint(t){return t||(t={}),t.lines=this.getMarkupLines(),t.texts=this.getMarkupTexts(),t.arrows=this.getMarkupArrows(),t.clouds=this.getMarkupClouds(),t.ellipses=this.getMarkupEllipses(),t.images=this.getMarkupImages(),t.rectangles=this.getMarkupRectangles(),t.custom_fields={markup_color:this.getMarkupColor()},t.snapshot={data:this.combineMarkupWithDrawing()},t}enableEditMode(t){return t&&Ke[t]?(this._markupMode=t,this._markupContainer.style.pointerEvents="all",this._markupIsActive=!0):(this.clearSelected(),this.removeTextInput(),this.removeImageInput(),this._markupContainer.style.pointerEvents="none",this._markupIsActive=!1),this}createObject(t,e){const i=Ke[t];if(!i||!i.initializer)throw new Error(`Markup CreateObject - unsupported markup type ${t}`);const r=i.initializer(null,e,this._worldTransformer);return this.addObject(r),r}getObjects(){const t=[];return Object.keys(Ke).forEach(e=>{const i=Ke[e];this.konvaLayerFind(e).forEach(e=>t.push(i.initializer(e,null,this._worldTransformer)))}),t}getSelectedObjects(){return this._konvaTransformer?this._konvaTransformer.nodes().map(t=>{const e=t.className,i=Object.values(Ke).find(t=>t.name===e);return i?i.initializer(t,null,this._worldTransformer):null}).filter(t=>t):[]}selectObjects(t){if(!this._konvaTransformer)return;const e=this._konvaTransformer.nodes().concat(t.map(t=>t.ref()));this._konvaTransformer.nodes(e)}clearSelected(){this._konvaTransformer&&this._konvaTransformer.nodes([])}addObject(t){"Image"===t.type()?this._groupImages.add(t.ref()):"Text"===t.type()?this._groupTexts.add(t.ref()):this._groupGeometry.add(t.ref())}konvaLayerFind(t){if(!this._konvaLayer)return[];const e=Ke[t];return e&&e.initializer?this._konvaLayer.find(e.name).filter(t=>t.parent===this._konvaLayer||t.parent===this._groupImages||t.parent===this._groupGeometry||t.parent===this._groupTexts):[]}initializeKonva(){const t=new Oe.Stage({container:this._markupContainer,width:this._container.clientWidth,height:this._container.clientHeight});this._konvaStage=t;const e=new Oe.Layer({pixelRation:window.devicePixelRatio});t.add(e),this._groupImages=new Oe.Group,e.add(this._groupImages),this._groupGeometry=new Oe.Group,e.add(this._groupGeometry),this._groupTexts=new Oe.Group,e.add(this._groupTexts),this._konvaLayer=e;const i=new Oe.Transformer({shouldOverdrawWholeArea:!1,keepRatio:!1,flipEnabled:!1});e.add(i),this._konvaTransformer=i;let r,s,n,o=!1;t.on("mousedown touchstart",e=>{if(!this._markupIsActive||e.target!==t||"Text"===this._markupMode||"Image"===this._markupMode)return;if(e.target===t&&i.nodes().length>0)return void i.nodes([]);const n=this.getRelativePointerPosition(t);s=n,o=["Arrow","Cloud","Ellipse","Line","Rectangle"].some(t=>t===this._markupMode),"Line"===this._markupMode&&(r=this.addLine([n.x,n.y,n.x,n.y]))}),t.on("mouseup touchend",()=>{if(this._markupIsActive){if(o){const e=this.getRelativePointerPosition(t),i=s&&e.x===s.x&&e.y===s.y,r=i?s.x:Math.min(s.x,e.x),n=i?s.y:Math.min(s.y,e.y),o=i?200:Math.abs(s.x-e.x),a=i?200:Math.abs(s.y-e.y);i&&("Rectangle"===this._markupMode?this.addRectangle({x:r,y:n},null,o,a):"Ellipse"===this._markupMode?this.addEllipse({x:r,y:n},null,null,{x:o/2,y:a/2}):"Arrow"===this._markupMode?this.addArrow({x:s.x,y:s.y},{x:i?s.x+200:e.x,y:i?n:e.y}):"Cloud"===this._markupMode&&this.addCloud({x:r,y:n},null,Math.max(100,o),Math.max(100,a)))}n=void 0,o=!1}}),t.on("mousemove touchmove",()=>{if(!this._markupIsActive)return;if(!o)return;const e=this.getRelativePointerPosition(t),i=s&&e.x===s.x&&e.y===s.y,a=i?s.x:Math.min(s.x,e.x),h=i?s.y:Math.min(s.y,e.y),l=i?200:Math.abs(s.x-e.x),d=i?200:Math.abs(s.y-e.y);"Line"===this._markupMode?r.addPoints([{x:e.x,y:e.y}]):"Arrow"===this._markupMode?n?n.setEndPoint(e.x,e.y):n=this.addArrow({x:s.x,y:s.y},{x:e.x,y:e.y}):"Rectangle"===this._markupMode?n?(n.setPosition(a,h),n.setWidth(l),n.setHeight(d)):n=this.addRectangle({x:a,y:h},null,l,d):"Ellipse"===this._markupMode?n?(n.setPosition(a,h),n.setRadiusX(l),n.setRadiusY(d)):n=this.addEllipse({x:a,y:h},null,null,{x:l,y:d}):"Cloud"===this._markupMode&&(n?(n.setPosition(a,h),n.setWidth(Math.max(100,l)),n.setHeight(Math.max(100,d))):n=this.addCloud({x:a,y:h},null,l,d))}),t.on("click tap",e=>{if(!this._markupIsActive)return;if(e.target===t){if("Text"===this._markupMode){if(this._textInputRef&&this._textInputRef.value)this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle);else if(0===i.nodes().length){const i=this.getRelativePointerPosition(t);this.createTextInput(i,e.evt.pageX,e.evt.pageY,0,null)}}else if("Image"===this._markupMode)if(this._imageInputRef&&this._imageInputRef.value)this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},null,this._imageInputRef.value,0,0,this._imageInputRef.value);else if(0===i.nodes().length){const e=this.getRelativePointerPosition(t);this.createImageInput(e)}return void i.nodes([])}if("Text"===this._markupMode||"SelectMarkup"===this._markupMode){if("Text"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._textInputRef&&this._textInputRef.value?this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle):this.createTextInput({x:e.target.attrs.x,y:e.target.attrs.y},e.evt.pageX,e.evt.pageY,e.target.attrs.rotation,e.target.attrs.text));this.removeTextInput()}if("Image"===this._markupMode||"SelectMarkup"===this._markupMode){if("Image"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._imageInputRef&&this._imageInputRef.value?this.addImage(this._imageInputPos,null,this._imageInputRef.value,0,0):this.createImageInput({x:e.target.attrs.x,y:e.target.attrs.y}));this.removeImageInput()}i.nodes().filter(t=>"Cloud"===t.className||"Image"===t.className).length>0||"Cloud"===e.target.className||"Image"===e.target.className?i.rotateEnabled(!1):i.rotateEnabled(!0);const r=e.evt.shiftKey||e.evt.ctrlKey||e.evt.metaKey,s=i.nodes().indexOf(e.target)>=0;if(r||s){if(r&&s){const t=i.nodes().slice();t.splice(t.indexOf(e.target),1),i.nodes(t)}else if(r&&!s){const t=i.nodes().concat([e.target]);i.nodes(t)}}else i.nodes([e.target])});const a=t.container();a.tabIndex=1,a.focus(),a.addEventListener("keydown",t=>{if(this._markupIsActive)return"Delete"===t.code?(this.getSelectedObjects().forEach(t=>t.delete()),void this.clearSelected()):void t.preventDefault()})}destroyKonva(){var t;this.removeTextInput(),this.removeImageInput(),this.clearOverlay(),null===(t=this._konvaStage)||void 0===t||t.destroy(),this._groupImages=void 0,this._groupGeometry=void 0,this._groupTexts=void 0,this._konvaLayer=void 0,this._konvaTransformer=void 0,this._konvaStage=void 0}getMarkupLines(){const t=[];return this.konvaLayerFind("Line").forEach(e=>{const i=e.getAttr("wcsPoints");if(!i)return;const r=new Ne(null,e,this._worldTransformer),s={id:r.id(),points:i,color:r.getColor()||"#ff0000",type:r.getLineType()||this.lineType,width:r.getLineWidth()||this.lineWidth};t.push(s)}),t}getMarkupTexts(){const t=[];return this.konvaLayerFind("Text").forEach(e=>{const i=this._worldTransformer.getScale(),r=e.getAttr("wcsStart"),s=this._konvaStage.getAbsoluteTransform(),n=new We(null,e,this._worldTransformer),o={id:n.id(),position:r,text:n.getText(),text_size:.02*i.y,angle:n.getRotation(),color:n.getColor(),font_size:n.getFontSize()*s.getMatrix()[0]};t.push(o)}),t}getMarkupRectangles(){const t=[];return this.konvaLayerFind("Rectangle").forEach(e=>{const i=e.getAttr("wcsStart"),r=e.getAttr("wcsEnd"),s=this._worldTransformer.worldToScreen(i),n=this._worldTransformer.worldToScreen(r),o=new Ue(null,e,this._worldTransformer),a={id:o.id(),position:i,position2:r,width:Math.abs(s.x-n.x),height:Math.abs(s.y-n.y),line_width:o.getLineWidth(),color:o.getColor()};t.push(a)}),t}getMarkupEllipses(){const t=[];return this.konvaLayerFind("Ellipse").forEach(e=>{const i=e.getAttr("wcsPosition"),r=e.getAttr("wcsRadiusX"),s=e.getAttr("wcsRadiusY"),n=this._konvaStage.getAbsoluteTransform().getMatrix()[0],o=new ze(null,e,this._worldTransformer),a={id:o.id(),position:i,position2:r,position3:s,radius:{x:e.getRadiusX()*n,y:e.getRadiusY()*n},line_width:o.getLineWidth(),color:o.getColor()};t.push(a)}),t}getMarkupArrows(){const t=[];return this.konvaLayerFind("Arrow").forEach(e=>{const i=e.getAttr("wcsStart"),r=e.getAttr("wcsEnd"),s=new He(null,e,this._worldTransformer),n={id:s.id(),start:i,end:r,color:s.getColor()};t.push(n)}),t}getMarkupImages(){const t=[];return this.konvaLayerFind("Image").forEach(e=>{const i=e.getAttr("wcsStart"),r=e.getAttr("wcsEnd"),s=this._konvaStage.getAbsoluteTransform().getMatrix()[0],n=new Ve(null,e,this._worldTransformer),o={id:n.id(),position:i,position2:r,src:n.getSrc(),width:n.getWidth()*s,height:n.getHeight()*s};t.push(o)}),t}getMarkupClouds(){const t=[];return this.konvaLayerFind("Cloud").forEach(e=>{const i=e.getAttr("wcsStart"),r=e.getAttr("wcsEnd"),s=this._worldTransformer.worldToScreen(i),n=this._worldTransformer.worldToScreen(r),o=new je(null,e,this._worldTransformer),a={id:o.id(),position:i,position2:r,width:Math.abs(s.x-n.x),height:Math.abs(s.y-n.y),line_width:o.getLineWidth(),color:o.getColor()};t.push(a)}),t}combineMarkupWithDrawing(){this.clearSelected();const t=document.createElement("canvas");if(this._konvaStage){t.width=this._konvaStage.width(),t.height=this._konvaStage.height();const e=t.getContext("2d");this._container instanceof HTMLCanvasElement&&e.drawImage(this._container,0,0),e.drawImage(this._konvaStage.toCanvas({pixelRatio:window.devicePixelRatio}),0,0)}return t.toDataURL("image/jpeg",.25)}addLine(t,e,i,r,s){if(!t||0===t.length)return;const n=[];for(let e=0;e<t.length;e+=2)n.push({x:t[e],y:t[e+1]});const o=new Ne({points:n,type:i||this.lineType,width:r||this.lineWidth,color:e||this._markupColor.asHex(),id:s},null,this._worldTransformer);return this.addObject(o),o}createTextInput(t,e,i,r,s){this._textInputRef?this.removeTextInput():(this._textInputPos=t,this._textInputAngle=r,this._textInputRef=document.createElement("textarea"),this._textInputRef.style.zIndex="9999",this._textInputRef.style.position="absolute",this._textInputRef.style.display="block",this._textInputRef.style.top=i+"px",this._textInputRef.style.left=e+"px",this._textInputRef.style.fontSize=`${this.fontSize}px`,this._textInputRef.style.color=`${this._markupColor.asHex()}`,this._textInputRef.style.fontFamily="Calibri",this._textInputRef.onkeydown=t=>{"Enter"!==t.key||t.shiftKey||(t.preventDefault(),this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle)),"Escape"===t.key&&(t.preventDefault(),this.removeTextInput())},s&&(this._textInputRef.value=s),document.body.appendChild(this._textInputRef),setTimeout(()=>{this._textInputRef.focus()},50))}removeTextInput(){var t;null===(t=this._textInputRef)||void 0===t||t.remove(),this._textInputRef=null,this._textInputPos=null,this._textInputAngle=0}createImageInput(t){if(this._imageInputRef)this.removeImageInput();else{const e=t=>new Promise((e,i)=>{const r=new FileReader;r.readAsDataURL(t),r.onload=()=>{e(r.result)},r.onerror=t=>{i(t)}});this._imageInputPos=t,this._imageInputRef=document.createElement("input"),this._imageInputRef.style.display="none",this._imageInputRef.type="file",this._imageInputRef.accept="image/png, image/jpeg",this._imageInputRef.onchange=async t=>{const i=t.target.files[0],r=await e(i);this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},null,r.toString(),0,0)},this._imageInputRef.oncancel=()=>{this.removeImageInput()},document.body.appendChild(this._imageInputRef),setTimeout(()=>{this._imageInputRef.click()},50)}}removeImageInput(){var t;null===(t=this._imageInputRef)||void 0===t||t.remove(),this._imageInputRef=null,this._imageInputPos=null}addText(t,e,i,r,s,n,o){var a;if(!t)return;null===(a=this.getSelectedObjects().shift())||void 0===a||a.delete(),this.clearSelected(),this.removeTextInput();const h=1e-6;if(s&&s>h&&(!n||n<h)){const t=.02;n=s/(this._worldTransformer.getScale().y/t)/34}const l=new We({position:{x:e.x,y:e.y},text:t,rotation:i,fontSize:n||this.fontSize,color:r||this._markupColor.asHex(),id:o},null,this._worldTransformer);return this.addObject(l),l}addRectangle(t,e,i,r,s,n,o){if(!t)return;const a=new Ue({position:t,position2:e,width:i,height:r,lineWidth:s||this.lineWidth,color:n||this._markupColor.asHex(),id:o},null,this._worldTransformer);return this.addObject(a),a}addEllipse(t,e,i,r,s,n,o){if(!t)return;const a=new ze({position:t,position2:e,position3:i,radius:r,lineWidth:s,color:n||this._markupColor.asHex(),id:o},null,this._worldTransformer);return this.addObject(a),a}addArrow(t,e,i,r){if(!t||!e)return;const s=new He({start:t,end:e,color:i||this._markupColor.asHex(),id:r},null,this._worldTransformer);return this.addObject(s),s}addCloud(t,e,i,r,s,n,o){if(!t||!i||!r)return;const a=new je({position:t,position2:e,width:i,height:r,color:n||this._markupColor.asHex(),lineWidth:s||this.lineWidth,id:o},null,this._worldTransformer);return this.addObject(a),a}addImage(t,e,i,r,s,n){var o;if(!t||!i)return;null===(o=this.getSelectedObjects().shift())||void 0===o||o.delete(),this.clearSelected(),this.removeImageInput();const a=new Ve({position:t,position2:e,src:i,width:r,height:s,maxWidth:this._konvaStage.width()-t.x,maxHeight:this._konvaStage.height()-t.y,id:n},null,this._worldTransformer);return this.addObject(a),a}}});
|