peaks-player
Version:
A Web Component for peaks.js
19 lines • 248 kB
JavaScript
(function(It){typeof define=="function"&&define.amd?define(It):It()})(function(){"use strict";var ua=Object.defineProperty;var fa=(It,Dt,ce)=>Dt in It?ua(It,Dt,{enumerable:!0,configurable:!0,writable:!0,value:ce}):It[Dt]=ce;var Oi=(It,Dt,ce)=>fa(It,typeof Dt!="symbol"?Dt+"":Dt,ce);const It=`<style>
#m-zoomview, #m-overview {
height: 100px;
background: var(--pp-color-bg, #111);
}
#m-audio, #m-zoomview, #m-overview {
width: 1000px;
}
#m-root {
display: flex;
flex-direction: column;
}
</style>
<div id="m-root">
<audio controls id="m-audio"></audio>
<div id="m-zoomview"></div>
<div id="m-overview"></div>
</div>
`;var Dt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ce(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var fi={exports:{}},ci={},q={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e._registerNode=e.Konva=e.glob=void 0;const t=Math.PI/180;function i(){return typeof window<"u"&&({}.toString.call(window)==="[object Window]"||{}.toString.call(window)==="[object global]")}e.glob=typeof Dt<"u"?Dt:typeof window<"u"?window:typeof WorkerGlobalScope<"u"?self:{},e.Konva={_global:e.glob,version:"9.3.18",isBrowser:i(),isUnminified:/param/.test((function(r){}).toString()),dblClickWindow:400,getAngle(r){return e.Konva.angleDeg?r*t:r},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:typeof window<"u"&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging(){return e.Konva.DD.isDragging},isTransforming(){var r;return(r=e.Konva.Transformer)===null||r===void 0?void 0:r.isTransforming()},isDragReady(){return!!e.Konva.DD.node},releaseCanvasOnDestroy:!0,document:e.glob.document,_injectGlobal(r){e.glob.Konva=r}};const n=r=>{e.Konva[r.prototype.getClassName()]=r};e._registerNode=n,e.Konva._injectGlobal(e.Konva)})(q);var dt={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Util=e.Transform=void 0;const t=q;class i{constructor(d=[1,0,0,1,0,0]){this.dirty=!1,this.m=d&&d.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(d){d.m[0]=this.m[0],d.m[1]=this.m[1],d.m[2]=this.m[2],d.m[3]=this.m[3],d.m[4]=this.m[4],d.m[5]=this.m[5]}point(d){const v=this.m;return{x:v[0]*d.x+v[2]*d.y+v[4],y:v[1]*d.x+v[3]*d.y+v[5]}}translate(d,v){return this.m[4]+=this.m[0]*d+this.m[2]*v,this.m[5]+=this.m[1]*d+this.m[3]*v,this}scale(d,v){return this.m[0]*=d,this.m[1]*=d,this.m[2]*=v,this.m[3]*=v,this}rotate(d){const v=Math.cos(d),C=Math.sin(d),E=this.m[0]*v+this.m[2]*C,p=this.m[1]*v+this.m[3]*C,x=this.m[0]*-C+this.m[2]*v,S=this.m[1]*-C+this.m[3]*v;return this.m[0]=E,this.m[1]=p,this.m[2]=x,this.m[3]=S,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(d,v){const C=this.m[0]+this.m[2]*v,E=this.m[1]+this.m[3]*v,p=this.m[2]+this.m[0]*d,x=this.m[3]+this.m[1]*d;return this.m[0]=C,this.m[1]=E,this.m[2]=p,this.m[3]=x,this}multiply(d){const v=this.m[0]*d.m[0]+this.m[2]*d.m[1],C=this.m[1]*d.m[0]+this.m[3]*d.m[1],E=this.m[0]*d.m[2]+this.m[2]*d.m[3],p=this.m[1]*d.m[2]+this.m[3]*d.m[3],x=this.m[0]*d.m[4]+this.m[2]*d.m[5]+this.m[4],S=this.m[1]*d.m[4]+this.m[3]*d.m[5]+this.m[5];return this.m[0]=v,this.m[1]=C,this.m[2]=E,this.m[3]=p,this.m[4]=x,this.m[5]=S,this}invert(){const d=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),v=this.m[3]*d,C=-this.m[1]*d,E=-this.m[2]*d,p=this.m[0]*d,x=d*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),S=d*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=v,this.m[1]=C,this.m[2]=E,this.m[3]=p,this.m[4]=x,this.m[5]=S,this}getMatrix(){return this.m}decompose(){const d=this.m[0],v=this.m[1],C=this.m[2],E=this.m[3],p=this.m[4],x=this.m[5],S=d*E-v*C,A={x:p,y:x,rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(d!=0||v!=0){const I=Math.sqrt(d*d+v*v);A.rotation=v>0?Math.acos(d/I):-Math.acos(d/I),A.scaleX=I,A.scaleY=S/I,A.skewX=(d*C+v*E)/S,A.skewY=0}else if(C!=0||E!=0){const I=Math.sqrt(C*C+E*E);A.rotation=Math.PI/2-(E>0?Math.acos(-C/I):-Math.acos(C/I)),A.scaleX=S/I,A.scaleY=I,A.skewX=0,A.skewY=(d*C+v*E)/S}return A.rotation=e.Util._getRotation(A.rotation),A}}e.Transform=i;const n="[object Array]",r="[object Number]",s="[object String]",a="[object Boolean]",o=Math.PI/180,l=180/Math.PI,f="#",c="",b="0",T="Konva warning: ",g="Konva error: ",u="rgb(",m={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]},y=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/;let w=[];const P=typeof requestAnimationFrame<"u"&&requestAnimationFrame||function(h){setTimeout(h,60)};e.Util={_isElement(h){return!!(h&&h.nodeType==1)},_isFunction(h){return!!(h&&h.constructor&&h.call&&h.apply)},_isPlainObject(h){return!!h&&h.constructor===Object},_isArray(h){return Object.prototype.toString.call(h)===n},_isNumber(h){return Object.prototype.toString.call(h)===r&&!isNaN(h)&&isFinite(h)},_isString(h){return Object.prototype.toString.call(h)===s},_isBoolean(h){return Object.prototype.toString.call(h)===a},isObject(h){return h instanceof Object},isValidSelector(h){if(typeof h!="string")return!1;const d=h[0];return d==="#"||d==="."||d===d.toUpperCase()},_sign(h){return h===0||h>0?1:-1},requestAnimFrame(h){w.push(h),w.length===1&&P(function(){const d=w;w=[],d.forEach(function(v){v()})})},createCanvasElement(){const h=document.createElement("canvas");try{h.style=h.style||{}}catch{}return h},createImageElement(){return document.createElement("img")},_isInDocument(h){for(;h=h.parentNode;)if(h==document)return!0;return!1},_urlToImage(h,d){const v=e.Util.createImageElement();v.onload=function(){d(v)},v.src=h},_rgbToHex(h,d,v){return((1<<24)+(h<<16)+(d<<8)+v).toString(16).slice(1)},_hexToRgb(h){h=h.replace(f,c);const d=parseInt(h,16);return{r:d>>16&255,g:d>>8&255,b:d&255}},getRandomColor(){let h=(Math.random()*16777215<<0).toString(16);for(;h.length<6;)h=b+h;return f+h},getRGB(h){let d;return h in m?(d=m[h],{r:d[0],g:d[1],b:d[2]}):h[0]===f?this._hexToRgb(h.substring(1)):h.substr(0,4)===u?(d=y.exec(h.replace(/ /g,"")),{r:parseInt(d[1],10),g:parseInt(d[2],10),b:parseInt(d[3],10)}):{r:0,g:0,b:0}},colorToRGBA(h){return h=h||"black",e.Util._namedColorToRBA(h)||e.Util._hex3ColorToRGBA(h)||e.Util._hex4ColorToRGBA(h)||e.Util._hex6ColorToRGBA(h)||e.Util._hex8ColorToRGBA(h)||e.Util._rgbColorToRGBA(h)||e.Util._rgbaColorToRGBA(h)||e.Util._hslColorToRGBA(h)},_namedColorToRBA(h){const d=m[h.toLowerCase()];return d?{r:d[0],g:d[1],b:d[2],a:1}:null},_rgbColorToRGBA(h){if(h.indexOf("rgb(")===0){h=h.match(/rgb\(([^)]+)\)/)[1];const d=h.split(/ *, */).map(Number);return{r:d[0],g:d[1],b:d[2],a:1}}},_rgbaColorToRGBA(h){if(h.indexOf("rgba(")===0){h=h.match(/rgba\(([^)]+)\)/)[1];const d=h.split(/ *, */).map((v,C)=>v.slice(-1)==="%"?C===3?parseInt(v)/100:parseInt(v)/100*255:Number(v));return{r:d[0],g:d[1],b:d[2],a:d[3]}}},_hex8ColorToRGBA(h){if(h[0]==="#"&&h.length===9)return{r:parseInt(h.slice(1,3),16),g:parseInt(h.slice(3,5),16),b:parseInt(h.slice(5,7),16),a:parseInt(h.slice(7,9),16)/255}},_hex6ColorToRGBA(h){if(h[0]==="#"&&h.length===7)return{r:parseInt(h.slice(1,3),16),g:parseInt(h.slice(3,5),16),b:parseInt(h.slice(5,7),16),a:1}},_hex4ColorToRGBA(h){if(h[0]==="#"&&h.length===5)return{r:parseInt(h[1]+h[1],16),g:parseInt(h[2]+h[2],16),b:parseInt(h[3]+h[3],16),a:parseInt(h[4]+h[4],16)/255}},_hex3ColorToRGBA(h){if(h[0]==="#"&&h.length===4)return{r:parseInt(h[1]+h[1],16),g:parseInt(h[2]+h[2],16),b:parseInt(h[3]+h[3],16),a:1}},_hslColorToRGBA(h){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(h)){const[d,...v]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(h),C=Number(v[0])/360,E=Number(v[1])/100,p=Number(v[2])/100;let x,S,A;if(E===0)return A=p*255,{r:Math.round(A),g:Math.round(A),b:Math.round(A),a:1};p<.5?x=p*(1+E):x=p+E-p*E;const I=2*p-x,O=[0,0,0];for(let R=0;R<3;R++)S=C+1/3*-(R-1),S<0&&S++,S>1&&S--,6*S<1?A=I+(x-I)*6*S:2*S<1?A=x:3*S<2?A=I+(x-I)*(2/3-S)*6:A=I,O[R]=A*255;return{r:Math.round(O[0]),g:Math.round(O[1]),b:Math.round(O[2]),a:1}}},haveIntersection(h,d){return!(d.x>h.x+h.width||d.x+d.width<h.x||d.y>h.y+h.height||d.y+d.height<h.y)},cloneObject(h){const d={};for(const v in h)this._isPlainObject(h[v])?d[v]=this.cloneObject(h[v]):this._isArray(h[v])?d[v]=this.cloneArray(h[v]):d[v]=h[v];return d},cloneArray(h){return h.slice(0)},degToRad(h){return h*o},radToDeg(h){return h*l},_degToRad(h){return e.Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),e.Util.degToRad(h)},_radToDeg(h){return e.Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),e.Util.radToDeg(h)},_getRotation(h){return t.Konva.angleDeg?e.Util.radToDeg(h):h},_capitalize(h){return h.charAt(0).toUpperCase()+h.slice(1)},throw(h){throw new Error(g+h)},error(h){console.error(g+h)},warn(h){t.Konva.showWarnings&&console.warn(T+h)},each(h,d){for(const v in h)d(v,h[v])},_inRange(h,d,v){return d<=h&&h<v},_getProjectionToSegment(h,d,v,C,E,p){let x,S,A;const I=(h-v)*(h-v)+(d-C)*(d-C);if(I==0)x=h,S=d,A=(E-v)*(E-v)+(p-C)*(p-C);else{const O=((E-h)*(v-h)+(p-d)*(C-d))/I;O<0?(x=h,S=d,A=(h-E)*(h-E)+(d-p)*(d-p)):O>1?(x=v,S=C,A=(v-E)*(v-E)+(C-p)*(C-p)):(x=h+O*(v-h),S=d+O*(C-d),A=(x-E)*(x-E)+(S-p)*(S-p))}return[x,S,A]},_getProjectionToLine(h,d,v){const C=e.Util.cloneObject(h);let E=Number.MAX_VALUE;return d.forEach(function(p,x){if(!v&&x===d.length-1)return;const S=d[(x+1)%d.length],A=e.Util._getProjectionToSegment(p.x,p.y,S.x,S.y,h.x,h.y),I=A[0],O=A[1],R=A[2];R<E&&(C.x=I,C.y=O,E=R)}),C},_prepareArrayForTween(h,d,v){const C=[],E=[];if(h.length>d.length){const x=d;d=h,h=x}for(let x=0;x<h.length;x+=2)C.push({x:h[x],y:h[x+1]});for(let x=0;x<d.length;x+=2)E.push({x:d[x],y:d[x+1]});const p=[];return E.forEach(function(x){const S=e.Util._getProjectionToLine(x,C,v);p.push(S.x),p.push(S.y)}),p},_prepareToStringify(h){let d;h.visitedByCircularReferenceRemoval=!0;for(const v in h)if(h.hasOwnProperty(v)&&h[v]&&typeof h[v]=="object"){if(d=Object.getOwnPropertyDescriptor(h,v),h[v].visitedByCircularReferenceRemoval||e.Util._isElement(h[v]))if(d.configurable)delete h[v];else return null;else if(e.Util._prepareToStringify(h[v])===null)if(d.configurable)delete h[v];else return null}return delete h.visitedByCircularReferenceRemoval,h},_assign(h,d){for(const v in d)h[v]=d[v];return h},_getFirstPointerId(h){return h.touches?h.changedTouches[0].identifier:h.pointerId||999},releaseCanvas(...h){t.Konva.releaseCanvasOnDestroy&&h.forEach(d=>{d.width=0,d.height=0})},drawRoundedRectPath(h,d,v,C){let E=0,p=0,x=0,S=0;typeof C=="number"?E=p=x=S=Math.min(C,d/2,v/2):(E=Math.min(C[0]||0,d/2,v/2),p=Math.min(C[1]||0,d/2,v/2),S=Math.min(C[2]||0,d/2,v/2),x=Math.min(C[3]||0,d/2,v/2)),h.moveTo(E,0),h.lineTo(d-p,0),h.arc(d-p,p,p,Math.PI*3/2,0,!1),h.lineTo(d,v-S),h.arc(d-S,v-S,S,0,Math.PI/2,!1),h.lineTo(x,v),h.arc(x,v-x,x,Math.PI/2,Math.PI,!1),h.lineTo(0,E),h.arc(E,E,E,Math.PI,Math.PI*3/2,!1)}}})(dt);var Xt={},Mt={},tt={};Object.defineProperty(tt,"__esModule",{value:!0}),tt.RGBComponent=Vn,tt.alphaComponent=Un,tt.getNumberValidator=Nn,tt.getNumberOrArrayOfNumbersValidator=Xn,tt.getNumberOrAutoValidator=zn,tt.getStringValidator=Yn,tt.getStringOrGradientValidator=Zn,tt.getFunctionValidator=Kn,tt.getNumberArrayValidator=jn,tt.getBooleanValidator=$n,tt.getComponentValidator=qn;const Ft=q,J=dt;function Rt(e){return J.Util._isString(e)?'"'+e+'"':Object.prototype.toString.call(e)==="[object Number]"||J.Util._isBoolean(e)?e:Object.prototype.toString.call(e)}function Vn(e){return e>255?255:e<0?0:Math.round(e)}function Un(e){return e>1?1:e<1e-4?1e-4:e}function Nn(){if(Ft.Konva.isUnminified)return function(e,t){return J.Util._isNumber(e)||J.Util.warn(Rt(e)+' is a not valid value for "'+t+'" attribute. The value should be a number.'),e}}function Xn(e){if(Ft.Konva.isUnminified)return function(t,i){let n=J.Util._isNumber(t),r=J.Util._isArray(t)&&t.length==e;return!n&&!r&&J.Util.warn(Rt(t)+' is a not valid value for "'+i+'" attribute. The value should be a number or Array<number>('+e+")"),t}}function zn(){if(Ft.Konva.isUnminified)return function(e,t){var i=J.Util._isNumber(e),n=e==="auto";return i||n||J.Util.warn(Rt(e)+' is a not valid value for "'+t+'" attribute. The value should be a number or "auto".'),e}}function Yn(){if(Ft.Konva.isUnminified)return function(e,t){return J.Util._isString(e)||J.Util.warn(Rt(e)+' is a not valid value for "'+t+'" attribute. The value should be a string.'),e}}function Zn(){if(Ft.Konva.isUnminified)return function(e,t){const i=J.Util._isString(e),n=Object.prototype.toString.call(e)==="[object CanvasGradient]"||e&&e.addColorStop;return i||n||J.Util.warn(Rt(e)+' is a not valid value for "'+t+'" attribute. The value should be a string or a native gradient.'),e}}function Kn(){if(Ft.Konva.isUnminified)return function(e,t){return J.Util._isFunction(e)||J.Util.warn(Rt(e)+' is a not valid value for "'+t+'" attribute. The value should be a function.'),e}}function jn(){if(Ft.Konva.isUnminified)return function(e,t){const i=Int8Array?Object.getPrototypeOf(Int8Array):null;return i&&e instanceof i||(J.Util._isArray(e)?e.forEach(function(n){J.Util._isNumber(n)||J.Util.warn('"'+t+'" attribute has non numeric element '+n+". Make sure that all elements are numbers.")}):J.Util.warn(Rt(e)+' is a not valid value for "'+t+'" attribute. The value should be a array of numbers.')),e}}function $n(){if(Ft.Konva.isUnminified)return function(e,t){var i=e===!0||e===!1;return i||J.Util.warn(Rt(e)+' is a not valid value for "'+t+'" attribute. The value should be a boolean.'),e}}function qn(e){if(Ft.Konva.isUnminified)return function(t,i){return t==null||J.Util.isObject(t)||J.Util.warn(Rt(t)+' is a not valid value for "'+i+'" attribute. The value should be an object with properties '+e),t}}(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Factory=void 0;const t=dt,i=tt,n="get",r="set";e.Factory={addGetterSetter(s,a,o,l,f){e.Factory.addGetter(s,a,o),e.Factory.addSetter(s,a,l,f),e.Factory.addOverloadedGetterSetter(s,a)},addGetter(s,a,o){var l=n+t.Util._capitalize(a);s.prototype[l]=s.prototype[l]||function(){const f=this.attrs[a];return f===void 0?o:f}},addSetter(s,a,o,l){var f=r+t.Util._capitalize(a);s.prototype[f]||e.Factory.overWriteSetter(s,a,o,l)},overWriteSetter(s,a,o,l){var f=r+t.Util._capitalize(a);s.prototype[f]=function(c){return o&&c!==void 0&&c!==null&&(c=o.call(this,c,a)),this._setAttr(a,c),l&&l.call(this),this}},addComponentsGetterSetter(s,a,o,l,f){const c=o.length,b=t.Util._capitalize,T=n+b(a),g=r+b(a);s.prototype[T]=function(){const m={};for(let y=0;y<c;y++){const w=o[y];m[w]=this.getAttr(a+b(w))}return m};const u=(0,i.getComponentValidator)(o);s.prototype[g]=function(m){const y=this.attrs[a];l&&(m=l.call(this,m,a)),u&&u.call(this,m,a);for(const w in m)m.hasOwnProperty(w)&&this._setAttr(a+b(w),m[w]);return m||o.forEach(w=>{this._setAttr(a+b(w),void 0)}),this._fireChangeEvent(a,y,m),f&&f.call(this),this},e.Factory.addOverloadedGetterSetter(s,a)},addOverloadedGetterSetter(s,a){var o=t.Util._capitalize(a),l=r+o,f=n+o;s.prototype[a]=function(){return arguments.length?(this[l](arguments[0]),this):this[f]()}},addDeprecatedGetterSetter(s,a,o,l){t.Util.error("Adding deprecated "+a);const f=n+t.Util._capitalize(a),c=a+" property is deprecated and will be removed soon. Look at Konva change log for more information.";s.prototype[f]=function(){t.Util.error(c);const b=this.attrs[a];return b===void 0?o:b},e.Factory.addSetter(s,a,l,function(){t.Util.error(c)}),e.Factory.addOverloadedGetterSetter(s,a)},backCompat(s,a){t.Util.each(a,function(o,l){const f=s.prototype[l],c=n+t.Util._capitalize(o),b=r+t.Util._capitalize(o);function T(){f.apply(this,arguments),t.Util.error('"'+o+'" method is deprecated and will be removed soon. Use ""'+l+'" instead.')}s.prototype[o]=T,s.prototype[c]=T,s.prototype[b]=T})},afterSetFilter(){this._filterUpToDate=!1}}})(Mt);var At={},Gt={};Object.defineProperty(Gt,"__esModule",{value:!0}),Gt.HitContext=Gt.SceneContext=Gt.Context=void 0;const Fi=dt,Jn=q;function Qn(e){const t=[],i=e.length,n=Fi.Util;for(let r=0;r<i;r++){let s=e[r];n._isNumber(s)?s=Math.round(s*1e3)/1e3:n._isString(s)||(s=s+""),t.push(s)}return t}const Ri=",",tr="(",er=")",ir="([",nr="])",rr=";",sr="()",ar="=",Gi=["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"],or=["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"],hr=100;class Be{constructor(t){this.canvas=t,Jn.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(t,i){let n=this.traceArr,r=n.length,s="",a,o,l,f;for(a=0;a<r;a++)o=n[a],l=o.method,l?(f=o.args,s+=l,t?s+=sr:Fi.Util._isArray(f[0])?s+=ir+f.join(Ri)+nr:(i&&(f=f.map(c=>typeof c=="number"?Math.floor(c):c)),s+=tr+f.join(Ri)+er)):(s+=o.property,t||(s+=ar+o.val)),s+=rr;return s}clearTrace(){this.traceArr=[]}_trace(t){let i=this.traceArr,n;i.push(t),n=i.length,n>=hr&&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 i=this.getCanvas();t?this.clearRect(t.x||0,t.y||0,t.width||0,t.height||0):this.clearRect(0,0,i.getWidth()/i.pixelRatio,i.getHeight()/i.pixelRatio)}_applyLineCap(t){const i=t.attrs.lineCap;i&&this.setAttr("lineCap",i)}_applyOpacity(t){const i=t.getAbsoluteOpacity();i!==1&&this.setAttr("globalAlpha",i)}_applyLineJoin(t){const i=t.attrs.lineJoin;i&&this.setAttr("lineJoin",i)}setAttr(t,i){this._context[t]=i}arc(t,i,n,r,s,a){this._context.arc(t,i,n,r,s,a)}arcTo(t,i,n,r,s){this._context.arcTo(t,i,n,r,s)}beginPath(){this._context.beginPath()}bezierCurveTo(t,i,n,r,s,a){this._context.bezierCurveTo(t,i,n,r,s,a)}clearRect(t,i,n,r){this._context.clearRect(t,i,n,r)}clip(...t){this._context.clip.apply(this._context,t)}closePath(){this._context.closePath()}createImageData(t,i){const n=arguments;if(n.length===2)return this._context.createImageData(t,i);if(n.length===1)return this._context.createImageData(t)}createLinearGradient(t,i,n,r){return this._context.createLinearGradient(t,i,n,r)}createPattern(t,i){return this._context.createPattern(t,i)}createRadialGradient(t,i,n,r,s,a){return this._context.createRadialGradient(t,i,n,r,s,a)}drawImage(t,i,n,r,s,a,o,l,f){const c=arguments,b=this._context;c.length===3?b.drawImage(t,i,n):c.length===5?b.drawImage(t,i,n,r,s):c.length===9&&b.drawImage(t,i,n,r,s,a,o,l,f)}ellipse(t,i,n,r,s,a,o,l){this._context.ellipse(t,i,n,r,s,a,o,l)}isPointInPath(t,i,n,r){return n?this._context.isPointInPath(n,t,i,r):this._context.isPointInPath(t,i,r)}fill(...t){this._context.fill.apply(this._context,t)}fillRect(t,i,n,r){this._context.fillRect(t,i,n,r)}strokeRect(t,i,n,r){this._context.strokeRect(t,i,n,r)}fillText(t,i,n,r){r?this._context.fillText(t,i,n,r):this._context.fillText(t,i,n)}measureText(t){return this._context.measureText(t)}getImageData(t,i,n,r){return this._context.getImageData(t,i,n,r)}lineTo(t,i){this._context.lineTo(t,i)}moveTo(t,i){this._context.moveTo(t,i)}rect(t,i,n,r){this._context.rect(t,i,n,r)}roundRect(t,i,n,r,s){this._context.roundRect(t,i,n,r,s)}putImageData(t,i,n){this._context.putImageData(t,i,n)}quadraticCurveTo(t,i,n,r){this._context.quadraticCurveTo(t,i,n,r)}restore(){this._context.restore()}rotate(t){this._context.rotate(t)}save(){this._context.save()}scale(t,i){this._context.scale(t,i)}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,i,n,r,s,a){this._context.setTransform(t,i,n,r,s,a)}stroke(t){t?this._context.stroke(t):this._context.stroke()}strokeText(t,i,n,r){this._context.strokeText(t,i,n,r)}transform(t,i,n,r,s,a){this._context.transform(t,i,n,r,s,a)}translate(t,i){this._context.translate(t,i)}_enableTrace(){let t=this,i=Gi.length,n=this.setAttr,r,s;const a=function(o){let l=t[o],f;t[o]=function(){return s=Qn(Array.prototype.slice.call(arguments,0)),f=l.apply(t,arguments),t._trace({method:o,args:s}),f}};for(r=0;r<i;r++)a(Gi[r]);t.setAttr=function(){n.apply(t,arguments);const o=arguments[0];let l=arguments[1];(o==="shadowOffsetX"||o==="shadowOffsetY"||o==="shadowBlur")&&(l=l/this.canvas.getPixelRatio()),t._trace({property:o,val:l})}}_applyGlobalCompositeOperation(t){const i=t.attrs.globalCompositeOperation;!i||i==="source-over"||this.setAttr("globalCompositeOperation",i)}}Gt.Context=Be,or.forEach(function(e){Object.defineProperty(Be.prototype,e,{get(){return this._context[e]},set(t){this._context[e]=t}})});class lr extends Be{constructor(t,{willReadFrequently:i=!1}={}){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:i})}_fillColor(t){const i=t.fill();this.setAttr("fillStyle",i),t._fillFunc(this)}_fillPattern(t){this.setAttr("fillStyle",t._getFillPattern()),t._fillFunc(this)}_fillLinearGradient(t){const i=t._getLinearGradient();i&&(this.setAttr("fillStyle",i),t._fillFunc(this))}_fillRadialGradient(t){const i=t._getRadialGradient();i&&(this.setAttr("fillStyle",i),t._fillFunc(this))}_fill(t){const i=t.fill(),n=t.getFillPriority();if(i&&n==="color"){this._fillColor(t);return}const r=t.getFillPatternImage();if(r&&n==="pattern"){this._fillPattern(t);return}const s=t.getFillLinearGradientColorStops();if(s&&n==="linear-gradient"){this._fillLinearGradient(t);return}const a=t.getFillRadialGradientColorStops();if(a&&n==="radial-gradient"){this._fillRadialGradient(t);return}i?this._fillColor(t):r?this._fillPattern(t):s?this._fillLinearGradient(t):a&&this._fillRadialGradient(t)}_strokeLinearGradient(t){const i=t.getStrokeLinearGradientStartPoint(),n=t.getStrokeLinearGradientEndPoint(),r=t.getStrokeLinearGradientColorStops(),s=this.createLinearGradient(i.x,i.y,n.x,n.y);if(r){for(let a=0;a<r.length;a+=2)s.addColorStop(r[a],r[a+1]);this.setAttr("strokeStyle",s)}}_stroke(t){const i=t.dash(),n=t.getStrokeScaleEnabled();if(t.hasStroke()){if(!n){this.save();const s=this.getCanvas().getPixelRatio();this.setTransform(s,0,0,s,0,0)}this._applyLineCap(t),i&&t.dashEnabled()&&(this.setLineDash(i),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),n||this.restore()}}_applyShadow(t){var i,n,r;const s=(i=t.getShadowRGBA())!==null&&i!==void 0?i:"black",a=(n=t.getShadowBlur())!==null&&n!==void 0?n:5,o=(r=t.getShadowOffset())!==null&&r!==void 0?r:{x:0,y:0},l=t.getAbsoluteScale(),f=this.canvas.getPixelRatio(),c=l.x*f,b=l.y*f;this.setAttr("shadowColor",s),this.setAttr("shadowBlur",a*Math.min(Math.abs(c),Math.abs(b))),this.setAttr("shadowOffsetX",o.x*c),this.setAttr("shadowOffsetY",o.y*b)}}Gt.SceneContext=lr;class dr extends Be{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 i=t.getStrokeScaleEnabled();if(!i){this.save();const s=this.getCanvas().getPixelRatio();this.setTransform(s,0,0,s,0,0)}this._applyLineCap(t);const n=t.hitStrokeWidth(),r=n==="auto"?t.strokeWidth():n;this.setAttr("lineWidth",r),this.setAttr("strokeStyle",t.colorKey),t._strokeFuncHit(this),i||this.restore()}}}Gt.HitContext=dr,Object.defineProperty(At,"__esModule",{value:!0}),At.HitCanvas=At.SceneCanvas=At.Canvas=void 0;const He=dt,Wi=Gt,Bi=q,ur=Mt,fr=tt;let Ve;function cr(){if(Ve)return Ve;const e=He.Util.createCanvasElement(),t=e.getContext("2d");return Ve=function(){const i=Bi.Konva._global.devicePixelRatio||1,n=t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1;return i/n}(),He.Util.releaseCanvas(e),Ve}class Ue{constructor(t){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;const n=(t||{}).pixelRatio||Bi.Konva.pixelRatio||cr();this.pixelRatio=n,this._canvas=He.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 i=this.pixelRatio;this.pixelRatio=t,this.setSize(this.getWidth()/i,this.getHeight()/i)}setWidth(t){this.width=this._canvas.width=t*this.pixelRatio,this._canvas.style.width=t+"px";const i=this.pixelRatio;this.getContext()._context.scale(i,i)}setHeight(t){this.height=this._canvas.height=t*this.pixelRatio,this._canvas.style.height=t+"px";const i=this.pixelRatio;this.getContext()._context.scale(i,i)}getWidth(){return this.width}getHeight(){return this.height}setSize(t,i){this.setWidth(t||0),this.setHeight(i||0)}toDataURL(t,i){try{return this._canvas.toDataURL(t,i)}catch{try{return this._canvas.toDataURL()}catch(r){return He.Util.error("Unable to get data URL. "+r.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}}At.Canvas=Ue,ur.Factory.addGetterSetter(Ue,"pixelRatio",void 0,(0,fr.getNumberValidator)());class gr extends Ue{constructor(t={width:0,height:0,willReadFrequently:!1}){super(t),this.context=new Wi.SceneContext(this,{willReadFrequently:t.willReadFrequently}),this.setSize(t.width,t.height)}}At.SceneCanvas=gr;class _r extends Ue{constructor(t={width:0,height:0}){super(t),this.hitCanvas=!0,this.context=new Wi.HitContext(this),this.setSize(t.width,t.height)}}At.HitCanvas=_r;var Ne={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.DD=void 0;const t=q,i=dt;e.DD={get isDragging(){let n=!1;return e.DD._dragElements.forEach(r=>{r.dragStatus==="dragging"&&(n=!0)}),n},justDragged:!1,get node(){let n;return e.DD._dragElements.forEach(r=>{n=r.node}),n},_dragElements:new Map,_drag(n){const r=[];e.DD._dragElements.forEach((s,a)=>{const{node:o}=s,l=o.getStage();l.setPointersPositions(n),s.pointerId===void 0&&(s.pointerId=i.Util._getFirstPointerId(n));const f=l._changedPointerPositions.find(c=>c.id===s.pointerId);if(f){if(s.dragStatus!=="dragging"){const c=o.dragDistance();if(Math.max(Math.abs(f.x-s.startPointerPos.x),Math.abs(f.y-s.startPointerPos.y))<c||(o.startDrag({evt:n}),!o.isDragging()))return}o._setDragPosition(n,s),r.push(o)}}),r.forEach(s=>{s.fire("dragmove",{type:"dragmove",target:s,evt:n},!0)})},_endDragBefore(n){const r=[];e.DD._dragElements.forEach(s=>{const{node:a}=s,o=a.getStage();if(n&&o.setPointersPositions(n),!o._changedPointerPositions.find(c=>c.id===s.pointerId))return;(s.dragStatus==="dragging"||s.dragStatus==="stopped")&&(e.DD.justDragged=!0,t.Konva._mouseListenClick=!1,t.Konva._touchListenClick=!1,t.Konva._pointerListenClick=!1,s.dragStatus="stopped");const f=s.node.getLayer()||s.node instanceof t.Konva.Stage&&s.node;f&&r.indexOf(f)===-1&&r.push(f)}),r.forEach(s=>{s.draw()})},_endDragAfter(n){e.DD._dragElements.forEach((r,s)=>{r.dragStatus==="stopped"&&r.node.fire("dragend",{type:"dragend",target:r.node,evt:n},!0),r.dragStatus!=="dragging"&&e.DD._dragElements.delete(s)})}},t.Konva.isBrowser&&(window.addEventListener("mouseup",e.DD._endDragBefore,!0),window.addEventListener("touchend",e.DD._endDragBefore,!0),window.addEventListener("touchcancel",e.DD._endDragBefore,!0),window.addEventListener("mousemove",e.DD._drag),window.addEventListener("touchmove",e.DD._drag),window.addEventListener("mouseup",e.DD._endDragAfter,!1),window.addEventListener("touchend",e.DD._endDragAfter,!1),window.addEventListener("touchcancel",e.DD._endDragAfter,!1))})(Ne),Object.defineProperty(Xt,"__esModule",{value:!0}),Xt.Node=void 0;const B=dt,Ce=Mt,Te=At,zt=q,St=Ne,et=tt,Xe="absoluteOpacity",ze="allEventListeners",Wt="absoluteTransform",Hi="absoluteScale",ee="canvas",pr="Change",mr="children",vr="konva",gi="listening",Vi="mouseenter",Ui="mouseleave",Ni="set",Xi="Shape",Ye=" ",zi="stage",Yt="transform",yr="Stage",_i="visible",wr=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(Ye);let br=1;class F{constructor(t){this._id=br++,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===Yt||t===Wt)&&this._cache.get(t)?this._cache.get(t).dirty=!0:t?this._cache.delete(t):this._cache.clear()}_getCache(t,i){let n=this._cache.get(t);return(n===void 0||(t===Yt||t===Wt)&&n.dirty===!0)&&(n=i.call(this),this._cache.set(t,n)),n}_calculate(t,i,n){if(!this._attachedDepsListeners.get(t)){const r=i.map(s=>s+"Change.konva").join(Ye);this.on(r,()=>{this._clearCache(t)}),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,n)}_getCanvasCache(){return this._cache.get(ee)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===Wt&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(ee)){const{scene:t,filter:i,hit:n}=this._cache.get(ee);B.Util.releaseCanvas(t,i,n),this._cache.delete(ee)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(t){const i=t||{};let n={};(i.x===void 0||i.y===void 0||i.width===void 0||i.height===void 0)&&(n=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let r=Math.ceil(i.width||n.width),s=Math.ceil(i.height||n.height),a=i.pixelRatio,o=i.x===void 0?Math.floor(n.x):i.x,l=i.y===void 0?Math.floor(n.y):i.y,f=i.offset||0,c=i.drawBorder||!1,b=i.hitCanvasPixelRatio||1;if(!r||!s){B.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");return}const T=Math.abs(Math.round(n.x)-o)>.5?1:0,g=Math.abs(Math.round(n.y)-l)>.5?1:0;r+=f*2+T,s+=f*2+g,o-=f,l-=f;const u=new Te.SceneCanvas({pixelRatio:a,width:r,height:s}),m=new Te.SceneCanvas({pixelRatio:a,width:0,height:0,willReadFrequently:!0}),y=new Te.HitCanvas({pixelRatio:b,width:r,height:s}),w=u.getContext(),P=y.getContext();return y.isCache=!0,u.isCache=!0,this._cache.delete(ee),this._filterUpToDate=!1,i.imageSmoothingEnabled===!1&&(u.getContext()._context.imageSmoothingEnabled=!1,m.getContext()._context.imageSmoothingEnabled=!1),w.save(),P.save(),w.translate(-o,-l),P.translate(-o,-l),this._isUnderCache=!0,this._clearSelfAndDescendantCache(Xe),this._clearSelfAndDescendantCache(Hi),this.drawScene(u,this),this.drawHit(y,this),this._isUnderCache=!1,w.restore(),P.restore(),c&&(w.save(),w.beginPath(),w.rect(0,0,r,s),w.closePath(),w.setAttr("strokeStyle","red"),w.setAttr("lineWidth",5),w.stroke(),w.restore()),this._cache.set(ee,{scene:u,filter:m,hit:y,x:o,y:l}),this._requestDraw(),this}isCached(){return this._cache.has(ee)}getClientRect(t){throw new Error('abstract "getClientRect" method call')}_transformedRect(t,i){const n=[{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,a=-1/0,o=-1/0;const l=this.getAbsoluteTransform(i);return n.forEach(function(f){const c=l.point(f);r===void 0&&(r=a=c.x,s=o=c.y),r=Math.min(r,c.x),s=Math.min(s,c.y),a=Math.max(a,c.x),o=Math.max(o,c.y)}),{x:r,y:s,width:a-r,height:o-s}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const i=this._getCanvasCache();t.translate(i.x,i.y);const n=this._getCachedSceneCanvas(),r=n.pixelRatio;t.drawImage(n._canvas,0,0,n.width/r,n.height/r),t.restore()}_drawCachedHitCanvas(t){const i=this._getCanvasCache(),n=i.hit;t.save(),t.translate(i.x,i.y),t.drawImage(n._canvas,0,0,n.width/n.pixelRatio,n.height/n.pixelRatio),t.restore()}_getCachedSceneCanvas(){let t=this.filters(),i=this._getCanvasCache(),n=i.scene,r=i.filter,s=r.getContext(),a,o,l,f;if(t){if(!this._filterUpToDate){const c=n.pixelRatio;r.setSize(n.width/n.pixelRatio,n.height/n.pixelRatio);try{for(a=t.length,s.clear(),s.drawImage(n._canvas,0,0,n.getWidth()/c,n.getHeight()/c),o=s.getImageData(0,0,r.getWidth(),r.getHeight()),l=0;l<a;l++){if(f=t[l],typeof f!="function"){B.Util.error("Filter should be type of function, but got "+typeof f+" instead. Please check correct filters");continue}f.call(this,o),s.putImageData(o,0,0)}}catch(b){B.Util.error("Unable to apply filter. "+b.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return r}return n}on(t,i){if(this._cache&&this._cache.delete(ze),arguments.length===3)return this._delegate.apply(this,arguments);let n=t.split(Ye),r=n.length,s,a,o,l,f;for(s=0;s<r;s++)a=n[s],o=a.split("."),l=o[0],f=o[1]||"",this.eventListeners[l]||(this.eventListeners[l]=[]),this.eventListeners[l].push({name:f,handler:i});return this}off(t,i){let n=(t||"").split(Ye),r=n.length,s,a,o,l,f,c;if(this._cache&&this._cache.delete(ze),!t)for(a in this.eventListeners)this._off(a);for(s=0;s<r;s++)if(o=n[s],l=o.split("."),f=l[0],c=l[1],f)this.eventListeners[f]&&this._off(f,c,i);else for(a in this.eventListeners)this._off(a,c,i);return this}dispatchEvent(t){const i={target:this,type:t.type,evt:t};return this.fire(t.type,i),this}addEventListener(t,i){return this.on(t,function(n){i.call(this,n.evt)}),this}removeEventListener(t){return this.off(t),this}_delegate(t,i,n){const r=this;this.on(t,function(s){const a=s.target.findAncestors(i,!0,r);for(let o=0;o<a.length;o++)s=B.Util.cloneObject(s),s.currentTarget=a[o],n.call(a[o],s)})}remove(){return this.isDragging()&&this.stopDrag(),St.DD._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(Wt),this._clearSelfAndDescendantCache(Xe),this._clearSelfAndDescendantCache(Hi),this._clearSelfAndDescendantCache(zi),this._clearSelfAndDescendantCache(_i),this._clearSelfAndDescendantCache(gi)}_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 i="get"+B.Util._capitalize(t);return B.Util._isFunction(this[i])?this[i]():this.attrs[t]}getAncestors(){let t=this.getParent(),i=[];for(;t;)i.push(t),t=t.getParent();return i}getAttrs(){return this.attrs||{}}setAttrs(t){return this._batchTransformChanges(()=>{let i,n;if(!t)return this;for(i in t)i!==mr&&(n=Ni+B.Util._capitalize(i),B.Util._isFunction(this[n])?this[n](t[i]):this._setAttr(i,t[i]))}),this}isListening(){return this._getCache(gi,this._isListening)}_isListening(t){if(!this.listening())return!1;const n=this.getParent();return n&&n!==t&&this!==t?n._isListening(t):!0}isVisible(){return this._getCache(_i,this._isVisible)}_isVisible(t){if(!this.visible())return!1;const n=this.getParent();return n&&n!==t&&this!==t?n._isVisible(t):!0}shouldDrawHit(t,i=!1){if(t)return this._isVisible(t)&&this._isListening(t);const n=this.getLayer();let r=!1;St.DD._dragElements.forEach(a=>{a.dragStatus==="dragging"&&(a.node.nodeType==="Stage"||a.node.getLayer()===n)&&(r=!0)});const s=!i&&!zt.Konva.hitOnDragEnabled&&(r||zt.Konva.isTransforming());return this.isListening()&&this.isVisible()&&!s}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let t=this.getDepth(),i=this,n=0,r,s,a,o;function l(c){for(r=[],s=c.length,a=0;a<s;a++)o=c[a],n++,o.nodeType!==Xi&&(r=r.concat(o.getChildren().slice())),o._id===i._id&&(a=s);r.length>0&&r[0].getDepth()<=t&&l(r)}const f=this.getStage();return i.nodeType!==yr&&f&&l(f.getChildren()),n}getDepth(){let t=0,i=this.parent;for(;i;)t++,i=i.parent;return t}_batchTransformChanges(t){this._batchingTransformChange=!0,t(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(Yt),this._clearSelfAndDescendantCache(Wt)),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 i=t.getPointerPosition();if(!i)return null;const n=this.getAbsoluteTransform().copy();return n.invert(),n.point(i)}getAbsolutePosition(t){let i=!1,n=this.parent;for(;n;){if(n.isCached()){i=!0;break}n=n.parent}i&&!t&&(t=!0);const r=this.getAbsoluteTransform(t).getMatrix(),s=new B.Transform,a=this.offset();return s.m=r.slice(),s.translate(a.x,a.y),s.getTranslation()}setAbsolutePosition(t){const{x:i,y:n,...r}=this._clearTransform();this.attrs.x=i,this.attrs.y=n,this._clearCache(Yt);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(Yt),this._clearSelfAndDescendantCache(Wt),this}_setTransform(t){let i;for(i in t)this.attrs[i]=t[i]}_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 i=t.x,n=t.y,r=this.x(),s=this.y();return i!==void 0&&(r+=i),n!==void 0&&(s+=n),this.setPosition({x:r,y:s}),this}_eachAncestorReverse(t,i){let n=[],r=this.getParent(),s,a;if(!(i&&i._id===this._id)){for(n.unshift(this);r&&(!i||r._id!==i._id);)n.unshift(r),r=r.parent;for(s=n.length,a=0;a<s;a++)t(n[a])}}rotate(t){return this.rotation(this.rotation()+t),this}moveToTop(){if(!this.parent)return B.Util.warn("Node has no parent. moveToTop function is ignored."),!1;const t=this.index,i=this.parent.getChildren().length;return t<i-1?(this.parent.children.splice(t,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0):!1}moveUp(){if(!this.parent)return B.Util.warn("Node has no parent. moveUp function is ignored."),!1;const t=this.index,i=this.parent.getChildren().length;return t<i-1?(this.parent.children.splice(t,1),this.parent.children.splice(t+1,0,this),this.parent._setChildrenIndices(),!0):!1}moveDown(){if(!this.parent)return B.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):!1}moveToBottom(){if(!this.parent)return B.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):!1}setZIndex(t){if(!this.parent)return B.Util.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&&B.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 i=this.index;return this.parent.children.splice(i,1),this.parent.children.splice(t,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(Xe,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let t=this.opacity();const i=this.getParent();return i&&!i._isUnderCache&&(t*=i.getAbsoluteOpacity()),t}moveTo(t){return this.getParent()!==t&&(this._remove(),t.add(this)),this}toObject(){let t=this.getAttrs(),i,n,r,s,a;const o={attrs:{},className:this.getClassName()};for(i in t)n=t[i],a=B.Util.isObject(n)&&!B.Util._isPlainObject(n)&&!B.Util._isArray(n),!a&&(r=typeof this[i]=="function"&&this[i],delete t[i],s=r?r.call(this):null,t[i]=n,s!==n&&(o.attrs[i]=n));return B.Util._prepareToStringify(o)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,i,n){const r=[];i&&this._isMatch(t)&&r.push(this);let s=this.parent;for(;s;){if(s===n)return r;s._isMatch(t)&&r.push(s),s=s.parent}return r}isAncestorOf(t){return!1}findAncestor(t,i,n){return this.findAncestors(t,i,n)[0]}_isMatch(t){if(!t)return!1;if(typeof t=="function")return t(this);let i=t.replace(/ /g,"").split(","),n=i.length,r,s;for(r=0;r<n;r++)if(s=i[r],B.Util.isValidSelector(s)||(B.Util.warn('Selector "'+s+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),B.Util.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),B.Util.warn("Konva is awesome, right?")),s.charAt(0)==="#"){if(this.id()===s.slice(1))return!0}else if(s.charAt(0)==="."){if(this.hasName(s.slice(1)))return!0}else if(this.className===s||this.nodeType===s)return!0;return!1}getLayer(){const t=this.getParent();return t?t.getLayer():null}getStage(){return this._getCache(zi,this._getStage)}_getStage(){const t=this.getParent();return t?t.getStage():null}fire(t,i={},n){return i.target=i.target||this,n?this._fireAndBubble(t,i):this._fire(t,i),this}getAbsoluteTransform(t){return t?this._getAbsoluteTransform(t):this._getCache(Wt,this._getAbsoluteTransform)}_getAbsoluteTransform(t){let i;if(t)return i=new B.Transform,this._eachAncestorReverse(function(n){const r=n.transformsEnabled();r==="all"?i.multiply(n.getTransform()):r==="position"&&i.translate(n.x()-n.offsetX(),n.y()-n.offsetY())},t),i;{i=this._cache.get(Wt)||new B.Transform,this.parent?this.parent.getAbsoluteTransform().copyInto(i):i.reset();const n=this.transformsEnabled();if(n==="all")i.multiply(this.getTransform());else if(n==="position"){const r=this.attrs.x||0,s=this.attrs.y||0,a=this.attrs.offsetX||0,o=this.attrs.offsetY||0;i.translate(r-a,s-o)}return i.dirty=!1,i}}getAbsoluteScale(t){let i=this;for(;i;)i._isUnderCache&&(t=i),i=i.getParent();const r=this.getAbsoluteTransform(t).decompose();return{x:r.scaleX,y:r.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(Yt,this._getTransform)}_getTransform(){var t,i;const n=this._cache.get(Yt)||new B.Transform;n.reset();const r=this.x(),s=this.y(),a=zt.Konva.getAngle(this.rotation()),o=(t=this.attrs.scaleX)!==null&&t!==void 0?t:1,l=(i=this.attrs.scaleY)!==null&&i!==void 0?i:1,f=this.attrs.skewX||0,c=this.attrs.skewY||0,b=this.attrs.offsetX||0,T=this.attrs.offsetY||0;return(r!==0||s!==0)&&n.translate(r,s),a!==0&&n.rotate(a),(f!==0||c!==0)&&n.skew(f,c),(o!==1||l!==1)&&n.scale(o,l),(b!==0||T!==0)&&n.translate(-1*b,-1*T),n.dirty=!1,n}clone(t){let i=B.Util.cloneObject(this.attrs),n,r,s,a,o;for(n in t)i[n]=t[n];const l=new this.constructor(i);for(n in this.eventListeners)for(r=this.eventListeners[n],s=r.length,a=0;a<s;a++)o=r[a],o.name.indexOf(vr)<0&&(l.eventListeners[n]||(l.eventListeners[n]=[]),l.eventListeners[n].push(o));return l}_toKonvaCanvas(t){t=t||{};const i=this.getClientRect(),n=this.getStage(),r=t.x!==void 0?t.x:Math.floor(i.x),s=t.y!==void 0?t.y:Math.floor(i.y),a=t.pixelRatio||1,o=new Te.SceneCanvas({width:t.width||Math.ceil(i.width)||(n?n.width():0),height:t.height||Math.ceil(i.height)||(n?n.height():0),pixelRatio:a}),l=o.getContext(),f=new Te.SceneCanvas({width:o.width/o.pixelRatio+Math.abs(r),height:o.height/o.pixelRatio+Math.abs(s),pixelRatio:o.pixelRatio});return t.imageSmoothingEnabled===!1&&(l._context.imageSmoothingEnabled=!1),l.save(),(r||s)&&l.translate(-1*r,-1*s),this.drawScene(o,void 0,f),l.restore(),o}toCanvas(t){return this._toKonvaCanvas(t)._canvas}toDataURL(t){t=t||{};const i=t.mimeType||null,n=t.quality||null,r=this._toKonvaCanvas(t).toDataURL(i,n);return t.callback&&t.callback(r),r}toImage(t){return new Promise((i,n)=>{try{const r=t==null?void 0:t.callback;r&&delete t.callback,B.Util._urlToImage(this.toDataURL(t),function(s){i(s),r==null||r(s)})}catch(r){n(r)}})}toBlob(t){return new Promise((i,n)=>{try{const r=t==null?void 0:t.callback;r&&delete t.callback,this.toCanvas(t).toBlob(s=>{i(s),r==null||r(s)},t==null?void 0:t.mimeType,t==null?void 0:t.quality)}catch(r){n(r)}})}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 this.attrs.dragDistance!==void 0?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():zt.Konva.dragDistance}_off(t,i,n){let r=this.eventListeners[t],s,a,o;for(s=0;s<r.length;s++)if(a=r[s].name,o=r[s].handler,(a!=="konva"||i==="konva")&&(!i||a===i)&&(!n||n===o)){if(r.splice(s,1),r.length===0){delete this.eventListeners[t];break}s--}}_fireChangeEvent(t,i,n){this._fire(t+pr,{oldVal:i,newVal:n})}addName(t){if(!this.hasName(t)){const i=this.name(),n=i?i+" "+t:t;this.name(n)}return this}hasName(t){if(!t)return!1;const i=this.name();return i?(i||"").split(/\s/g).indexOf(t)!==-1:!1}removeName(t){const i=(this.name()||"").split(/\s/g),n=i.indexOf(t);return n!==-1&&(i.splice(n,1),this.name(i.join(" "))),this}setAttr(t,i){const n=this[Ni+B.Util._capitalize(t)];return B.Util._isFunction(n)?n.call(this,i):this._setAttr(t,i),this}_requestDraw(){if(zt.Konva.autoDrawEnabled){const t=this.getLayer()||this.getStage();t==null||t.batchDraw()}}_setAttr(t,i){const n=this.attrs[t];n===i&&!B.Util.isObject(i)||(i==null?delete this.attrs[t]:this.attrs[t]=i,this._shouldFireChangeEvents&&this._fireChangeEvent(t,n,i),this._requestDraw())}_setComponentAttr(t,i,n){let r;n!==void 0&&(r=this.attrs[t],r||(this.attrs[t]=this.getAttr(t)),this.attrs[t][i]=n,this._fireChang