@inweb/markup
Version:
JavaScript 2D markups
1 lines • 237 kB
JavaScript
!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.18",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],g=l[2];g<n&&(s.x=d,s.y=c,n=g)})),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 g,u,f={},p={},_={};function m(){if(g)return _;g=1,Object.defineProperty(_,"__esModule",{value:!0}),_.RGBComponent=function(t){if(t>255)return 255;if(t<0)return 0;return Math.round(t)},_.alphaComponent=function(t){if(t>1)return 1;if(t<1e-4)return 1e-4;return t},_.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}},_.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}},_.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}},_.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}},_.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}},_.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}},_.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}},_.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}},_.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 _}function y(){return u||(u=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Factory=void 0;const e=c(),i=m(),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){var 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){var a=s+e.Util._capitalize(r);i.prototype[a]||t.Factory.overWriteSetter(i,r,n,o)},overWriteSetter(t,i,r,n){var 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,g=r+c(o),u=s+c(o);n.prototype[g]=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[u]=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){var 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}}}(p)),p}var v,x,w={},b={};function S(){if(v)return b;v=1,Object.defineProperty(b,"__esModule",{value:!0}),b.HitContext=b.SceneContext=b.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)}};b.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}})}));b.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 b.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()}}},b}function C(){if(x)return w;x=1,Object.defineProperty(w,"__esModule",{value:!0}),w.HitCanvas=w.SceneCanvas=w.Canvas=void 0;const t=c(),e=S(),i=h(),r=y(),s=m();let n;let o=class{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;const r=(e||{}).pixelRatio||i.Konva.pixelRatio||function(){if(n)return n;const e=t.Util.createCanvasElement(),r=e.getContext("2d");return n=(i.Konva._global.devicePixelRatio||1)/(r.webkitBackingStorePixelRatio||r.mozBackingStorePixelRatio||r.msBackingStorePixelRatio||r.oBackingStorePixelRatio||r.backingStorePixelRatio||1),t.Util.releaseCanvas(e),n}();this.pixelRatio=r,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."),""}}}};w.Canvas=o,r.Factory.addGetterSetter(o,"pixelRatio",void 0,(0,s.getNumberValidator)());w.SceneCanvas=class extends o{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 w.HitCanvas=class extends o{constructor(t={width:0,height:0}){super(t),this.hitCanvas=!0,this.context=new e.HitContext(this),this.setSize(t.width,t.height)}},w}var T,A,P={};function k(){return T||(T=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))}(P)),P}function M(){if(A)return f;A=1,Object.defineProperty(f,"__esModule",{value:!0}),f.Node=void 0;const t=c(),e=y(),i=C(),r=h(),s=k(),n=m(),o="absoluteOpacity",a="allEventListeners",l="absoluteTransform",d="absoluteScale",g="canvas",u="listening",p="mouseenter",_="mouseleave",v="Shape",x=" ",w="stage",b="transform",S="visible",T=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(x);let P=1,M=class e{constructor(t){this._id=P++,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!==b&&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===b||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(x);this.on(i,(()=>{this._clearCache(t)})),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,i)}_getCanvasCache(){return this._cache.get(g)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===l&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(g)){const{scene:e,filter:i,hit:r}=this._cache.get(g);t.Util.releaseCanvas(e,i,r),this._cache.delete(g)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){const r=e||{};let s={};void 0!==r.x&&void 0!==r.y&&void 0!==r.width&&void 0!==r.height||(s=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let n=Math.ceil(r.width||s.width),a=Math.ceil(r.height||s.height),h=r.pixelRatio,l=void 0===r.x?Math.floor(s.x):r.x,c=void 0===r.y?Math.floor(s.y):r.y,u=r.offset||0,f=r.drawBorder||!1,p=r.hitCanvasPixelRatio||1;if(!n||!a)return void t.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");n+=2*u+(Math.abs(Math.round(s.x)-l)>.5?1:0),a+=2*u+(Math.abs(Math.round(s.y)-c)>.5?1:0),l-=u,c-=u;const _=new i.SceneCanvas({pixelRatio:h,width:n,height:a}),m=new i.SceneCanvas({pixelRatio:h,width:0,height:0,willReadFrequently:!0}),y=new i.HitCanvas({pixelRatio:p,width:n,height:a}),v=_.getContext(),x=y.getContext();return y.isCache=!0,_.isCache=!0,this._cache.delete(g),this._filterUpToDate=!1,!1===r.imageSmoothingEnabled&&(_.getContext()._context.imageSmoothingEnabled=!1,m.getContext()._context.imageSmoothingEnabled=!1),v.save(),x.save(),v.translate(-l,-c),x.translate(-l,-c),this._isUnderCache=!0,this._clearSelfAndDescendantCache(o),this._clearSelfAndDescendantCache(d),this.drawScene(_,this),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(g,{scene:_,filter:m,hit:y,x:l,y:c}),this._requestDraw(),this}isCached(){return this._cache.has(g)}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 e,i,r,s,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(e=n.length,l.clear(),l.drawImage(a._canvas,0,0,a.getWidth()/o,a.getHeight()/o),i=l.getImageData(0,0,h.getWidth(),h.getHeight()),r=0;r<e;r++)s=n[r],"function"==typeof s?(s.call(this,i),l.putImageData(i,0,0)):t.Util.error("Filter should be type of function, but got "+typeof s+" instead. Please check correct filters")}catch(e){t.Util.error("Unable to apply filter. "+e.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);let i,r,s,n,o,h=t.split(x),l=h.length;for(i=0;i<l;i++)r=h[i],s=r.split("."),n=s[0],o=s[1]||"",this.eventListeners[n]||(this.eventListeners[n]=[]),this.eventListeners[n].push({name:o,handler:e});return this}off(t,e){let i,r,s,n,o,h,l=(t||"").split(x),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(e,i,r){const s=this;this.on(e,(function(e){const n=e.target.findAncestors(i,!0,s);for(let i=0;i<n.length;i++)(e=t.Util.cloneObject(e)).currentTarget=n[i],r.call(n[i],e)}))}remove(){return this.isDragging()&&this.stopDrag(),s.DD._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(l),this._clearSelfAndDescendantCache(o),this._clearSelfAndDescendantCache(d),this._clearSelfAndDescendantCache(w),this._clearSelfAndDescendantCache(S),this._clearSelfAndDescendantCache(u)}_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(e){const i="get"+t.Util._capitalize(e);return t.Util._isFunction(this[i])?this[i]():this.attrs[e]}getAncestors(){let t=this.getParent(),e=[];for(;t;)e.push(t),t=t.getParent();return e}getAttrs(){return this.attrs||{}}setAttrs(e){return this._batchTransformChanges((()=>{let i,r;if(!e)return this;for(i in e)"children"!==i&&(r="set"+t.Util._capitalize(i),t.Util._isFunction(this[r])?this[r](e[i]):this._setAttr(i,e[i]))})),this}isListening(){return this._getCache(u,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(S,this._isVisible)}_isVisible(t){if(!this.visible())return!1;const e=this.getParent();return!e||e===t||this===t||e._isVisible(t)}shouldDrawHit(t,e=!1){if(t)return this._isVisible(t)&&this._isListening(t);const i=this.getLayer();let n=!1;s.DD._dragElements.forEach((t=>{"dragging"===t.dragStatus&&("Stage"===t.node.nodeType||t.node.getLayer()===i)&&(n=!0)}));const o=!e&&!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!==v&&(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(b),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(e){let i=!1,r=this.parent;for(;r;){if(r.isCached()){i=!0;break}r=r.parent}i&&!e&&(e=!0);const s=this.getAbsoluteTransform(e).getMatrix(),n=new t.Transform,o=this.offset();return n.m=s.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(b);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(b),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 t.Util.warn("Node has no parent. moveToTop function is ignored."),!1;const e=this.index;return e<this.parent.getChildren().length-1&&(this.parent.children.splice(e,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0)}moveUp(){if(!this.parent)return t.Util.warn("Node has no parent. moveUp function is ignored."),!1;const e=this.index;return e<this.parent.getChildren().length-1&&(this.parent.children.splice(e,1),this.parent.children.splice(e+1,0,this),this.parent._setChildrenIndices(),!0)}moveDown(){if(!this.parent)return t.Util.warn("Node has no parent. moveDown function is ignored."),!1;const e=this.index;return e>0&&(this.parent.children.splice(e,1),this.parent.children.splice(e-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return t.Util.warn("Node has no parent. moveToBottom function is ignored."),!1;const e=this.index;return e>0&&(this.parent.children.splice(e,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(e){if(!this.parent)return t.Util.warn("Node has no parent. zIndex parameter is ignored."),this;(e<0||e>=this.parent.children.length)&&t.Util.warn("Unexpected value "+e+" 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 i=this.index;return this.parent.children.splice(i,1),this.parent.children.splice(e,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 e,i,r,s,n,o=this.getAttrs();const a={attrs:{},className:this.getClassName()};for(e in o)i=o[e],n=t.Util.isObject(i)&&!t.Util._isPlainObject(i)&&!t.Util._isArray(i),n||(r="function"==typeof this[e]&&this[e],delete o[e],s=r?r.call(this):null,o[e]=i,s!==i&&(a.attrs[e]=i));return t.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(e){if(!e)return!1;if("function"==typeof e)return e(this);let i,r,s=e.replace(/ /g,"").split(","),n=s.length;for(i=0;i<n;i++)if(r=s[i],t.Util.isValidSelector(r)||(t.Util.warn('Selector "'+r+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),t.Util.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),t.Util.warn("Konva is awesome, right?")),"#"===r.charAt(0)){if(this.id()===r.slice(1))return!0}else if("."===r.charAt(0)){if(this.hasName(r.slice(1)))return!0}else if(this.className===r||this.nodeType===r)return!0;return!1}getLayer(){const t=this.getParent();return t?t.getLayer():null}getStage(){return this._getCache(w,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(e){let i;if(e)return i=new t.Transform,this._eachAncestorReverse((function(t){const e=t.transformsEnabled();"all"===e?i.multiply(t.getTransform()):"position"===e&&i.translate(t.x()-t.offsetX(),t.y()-t.offsetY())}),e),i;{i=this._cache.get(l)||new t.Transform,this.parent?this.parent.getAbsoluteTransform().copyInto(i):i.reset();const e=this.transformsEnabled();if("all"===e)i.multiply(this.getTransform());else if("position"===e){const t=this.attrs.x||0,e=this.attrs.y||0,r=this.attrs.offsetX||0,s=this.attrs.offsetY||0;i.translate(t-r,e-s)}return i.dirty=!1,i}}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(b,this._getTransform)}_getTransform(){var e,i;const s=this._cache.get(b)||new t.Transform;s.reset();const n=this.x(),o=this.y(),a=r.Konva.getAngle(this.rotation()),h=null!==(e=this.attrs.scaleX)&&void 0!==e?e:1,l=null!==(i=this.attrs.scaleY)&&void 0!==i?i:1,d=this.attrs.skewX||0,c=this.attrs.skewY||0,g=this.attrs.offsetX||0,u=this.attrs.offsetY||0;return 0===n&&0===o||s.translate(n,o),0!==a&&s.rotate(a),0===d&&0===c||s.skew(d,c),1===h&&1===l||s.scale(h,l),0===g&&0===u||s.translate(-1*g,-1*u),s.dirty=!1,s}clone(e){let i,r,s,n,o,a=t.Util.cloneObject(this.attrs);for(i in e)a[i]=e[i];const h=new this.constructor(a);for(i in this.eventListeners)for(r=this.eventListeners[i],s=r.length,n=0;n<s;n++)o=r[n],o.name.indexOf("konva")<0&&(h.eventListeners[i]||(h.eventListeners[i]=[]),h.eventListeners[i].push(o));return h}_toKonvaCanvas(t){t=t||{};const e=this.getClientRect(),r=this.getStage(),s=void 0!==t.x?t.x:Math.floor(e.x),n=void 0!==t.y?t.y:Math.floor(e.y),o=t.pixelRatio||1,a=new i.SceneCanvas({width:t.width||Math.ceil(e.width)||(r?r.width():0),height:t.height||Math.ceil(e.height)||(r?r.height():0),pixelRatio:o}),h=a.getContext(),l=new i.SceneCanvas({width:a.width/a.pixelRatio+Math.abs(s),height:a.height/a.pixelRatio+Math.abs(n),pixelRatio:a.pixelRatio});return!1===t.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(e){return new Promise(((i,r)=>{try{const r=null==e?void 0:e.callback;r&&delete e.callback,t.Util._urlToImage(this.toDataURL(e),(function(t){i(t),null==r||r(t)}))}catch(t){r(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(e,i){const r=this["set"+t.Util._capitalize(e)];return t.Util._isFunction(r)?r.call(this,i):this._setAttr(e,i),this}_requestDraw(){if(r.Konva.autoDrawEnabled){const t=this.getLayer()||this.getStage();null==t||t.batchDraw()}}_setAttr(e,i){const r=this.attrs[e];(r!==i||t.Util.isObject(i))&&(null==i?delete this.attrs[e]:this.attrs[e]=i,this._shouldFireChangeEvents&&this._fireChangeEvent(e,r,i),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===v&&(e.target=this);if(!((t===p||t===_)&&(i&&(this===i||this.isAncestorOf&&this.isAncestorOf(i))||"Stage"===this.nodeType&&!i))){this._fire(t,e);const r=(t===p||t===_)&&i&&i.isAncestorOf&&i.isAncestorOf(this)&&!i.isAncestorOf(this.parent);(e&&!e.cancelBubble||!e)&&this.parent&&this.parent.isListening()&&!r&&(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=[];