UNPKG

@determaer/cmkd

Version:

Cognitive Maps of Knowledge Diagnosis (CMKD) interactive builder

1 lines 104 kB
(function(dt,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(dt=typeof globalThis<"u"?globalThis:dt||self,t(dt["vue3-cmkd"]={},dt.Vue))})(this,(function(dt,t){"use strict";const Re=(i,r,k)=>{const o=[];return i.forEach(d=>{i.filter(b=>d.connections.some(C=>b.id==C)).forEach(b=>{const C=k||d.isBase,w=k||b.isBase,S=b.score<0||d.score<0;(r&&S&&b.isBase&&d.isBase||!r&&C&&w)&&o.push({objLabelOut:d,objLabelIn:b})})}),o},Ae=(i,r)=>{const o=i.length,d=o*5,p=[];return i.forEach((b,C)=>{const w=(C*5+2)*(360/d)+90;p.push({labelId:b.id,inAngle:(C*5+3)*(360/d)+90,outAngle:w,labelAngle:((C+1)*2-1)*(360/(o*2))+90,arrowAngle:w-2*r})}),p},Te=(i,r)=>{const k=[90];let o;return r.forEach((d,p)=>{if(p==0){o=d;return}if(o.prop!==d.prop){const b=i.find(w=>w.labelId==o.id)?.labelAngle??0,C=i.find(w=>w.labelId==d.id)?.labelAngle??0;k.push(b+(C-b)/2)}o=d}),k};function vt(i){return i instanceof Object&&"id"in i&&"prop"in i&&"typeText"in i&&"numText"in i&&"type"in i&&"num"in i&&"score"in i&&"isBase"in i&&"connections"in i&&"secStart"in i&&"secEnd"in i&&"fontStyle"in i&&"arrowOut"in i&&"arrowIn"in i&&"level"in i&&"grey"in i&&"sectorName"in i}const Pe={id:0,prop:0,typeText:"u",numText:"1",type:"circle",num:1,score:1,isBase:!0,connections:[],secStart:!0,secEnd:!0,fontStyle:"normal",arrowOut:!1,arrowIn:!1,level:0,isLabel:!0,secLength:1,grey:!1,yellow:!1,sectorName:""},De=(i,r,k)=>{const o=[];let d,p=9999;return k.forEach((b,C)=>{p>b.level&&(p=b.level,d=[0]);let w=null,S=null;const L=d[d.length-1]??0;if(b.level>0&&b.secLength!=null)w=L+360*(b.secLength/i)-1e-4,S={sLevel:b.level,shortname:b.typeText+b.numText,object:{id:b.id,isLabel:b.isLabel,fontStyle:b.fontStyle,numText:b.numText,typeText:b.typeText,score:b.score}};else if(b.level==0&&b.secEnd){if(w=359.9999,C!=k.length-1){const O=r.find(U=>U.labelId===k[C+1]?.id)?.labelAngle,M=r.find(U=>U.labelId===b.id)?.labelAngle;O!=null&&M!=null&&(w=M+(O-M)/2-90)}S={sLevel:b.level,shortname:b.sectorName,object:{id:b.id}}}else return;d.push(w),o.push({sStart:L,sEnd:w,sLevel:S.sLevel,object:S.object,shortname:S.shortname})}),o},Vt=t.ref(800),Ee=t.computed(()=>Vt.value/2),ee=t.computed(()=>Ft.value.reduce((i,r)=>i=r.level>i?r.level:i,0)),st=t.computed(()=>Tt.value.length),Oe=t.computed(()=>st.value<50?0:50),Be=t.computed(()=>ae.value?50*Wt.value:0),xt=i=>(i+Oe.value)*Wt.value,Ge=t.computed(()=>({outerRadius:xt(250),innerRadius:xt(200),labelRadius:xt(225),additionalLabelRadius:xt(285),lineStartRadius:xt(190),mergingPortsRadius:xt(212),sectorNameRadius:xt(275)+Be.value})),Ht=t.computed(()=>Ae(Tt.value,ne.value)),Fe=t.computed(()=>Te(Ht.value,Tt.value)),Wt=t.computed(()=>Vt.value/800),ne=t.computed(()=>st.value<=10?1:st.value>10&&st.value<20?.9:st.value>=20&&st.value<30?.8:st.value>=30&&st.value<40?.75:st.value>=40&&st.value<50?.7:st.value>=50?.65:1),ie=t.ref(0),ae=t.ref(!1),re=t.ref(!0),Ie=t.ref(!1),se=t.ref(!1),oe=t.computed(()=>ee.value==0),Ne=t.ref(!1),Me=t.ref(!1),je=t.ref(!1),Ue=t.computed(()=>!!oe.value),Ft=t.ref([]),Tt=t.computed(()=>Ft.value.filter(i=>i.level==0)),Ve=t.computed(()=>De(st.value,Ht.value,Ft.value)),He=t.computed(()=>Re(Tt.value,se.value,re.value)),ht=()=>{function i(){setTimeout(()=>{ie.value++},0)}return{width:Vt,centerPoint:Ee,circleNum:ee,discNum:st,angles:Ht,dividerAngles:Fe,radiuses:Ge,scaleMultiplier:Wt,sizeMultiplier:ne,showSupportRect:ae,showDefaultRect:Me,showUnreached:je,showAdditionalInCircle:re,showScore:Ie,showLight:se,showSectorName:Ue,oneLevel:oe,showImportant:Ne,labels:Ft,labelsZero:Tt,sectors:Ve,lines:He,reloadCount:ie,updateCMKD:i}},le=ht(),We=t.ref(-1e3),Xe=t.ref(-1e3),Pt=t.ref(!1),Dt=t.ref(!1),Et=t.ref(!1),ce=t.ref(),lt=t.ref(),Ye=t.computed(()=>lt.value!=null?[lt.value.objLabel,...lt.value.prevLabels,...lt.value.nextLabels]:[]),Ke=t.computed(()=>{const i=[];return lt.value?.nextLabels.map(r=>{lt.value?.objLabel&&i.push({objLabelIn:lt.value?.objLabel.label,objLabelOut:r.label})}),lt.value?.prevLabels.map(r=>{lt.value?.objLabel&&i.push({objLabelIn:r.label,objLabelOut:lt.value?.objLabel.label})}),i}),de=t.ref(),It=t.ref(),Ct=()=>{function i(){Pt.value=!1,Dt.value=!1,Et.value=!1}function r(d){let p=[],b=[];le.labelsZero.value.map(C=>{C.connections.map(w=>{d.id===w&&b.push({label:C,selected:!1})})}),d.connections.map(C=>{const w=le.labelsZero.value.find(S=>S.id===C);w&&p.push({label:w,selected:!1})}),Pt.value=!1,Et.value=!1,Dt.value=!0,lt.value={objLabel:{label:d,selected:!0},nextLabels:b,prevLabels:p},It.value={type:"label",object:d,nextLabels:b,prevLabels:p}}function k(d,p){Pt.value=!0,Et.value=!1,Dt.value=!1,ce.value={objLabelIn:d,objLabelOut:p},It.value={type:"line",object:{objLabelIn:d,objLabelOut:p}}}function o(d){Pt.value=!1,Et.value=!0,Dt.value=!1,de.value=d,It.value={type:"sector",object:d}}return{clickLayerX:We,clickLayerY:Xe,clickedLine:ce,clickedLabel:lt,labelsToDraw:Ye,linesToDraw:Ke,clickedSector:de,clickedInfo:It,isClickedLine:Pt,isClickedLabel:Dt,isClickedSector:Et,resetClicked:i,setClickedLabel:r,setClickedLine:k,setClickedSector:o}},z=(i,r,k)=>{const o=k/180*Math.PI,d=i+r*Math.cos(o),p=i-r*Math.sin(o);return{x:+d.toFixed(2),y:+p.toFixed(2)}};function ze(i){return i instanceof Object&&"objLabelIn"in i&&"objLabelOut"in i&&vt(i.objLabelIn)&&vt(i.objLabelOut)}function $e(i){return i instanceof Object&&"sStart"in i&&"sEnd"in i&&"sLevel"in i&&"object"in i&&vt(i.object)}function qe(i){return i instanceof Object&&"id"in i&&"isLabel"in i&&"numText"in i&&"typeText"in i&&"score"in i&&"fontStyle"in i}var he=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Rt={},Xt={},Yt={},ue;function ut(){return ue||(ue=1,(function(i){Object.defineProperty(i,"__esModule",{value:!0}),i._registerNode=i.Konva=i.glob=void 0;const r=Math.PI/180;function k(){return typeof window<"u"&&({}.toString.call(window)==="[object Window]"||{}.toString.call(window)==="[object global]")}i.glob=typeof he<"u"?he:typeof window<"u"?window:typeof WorkerGlobalScope<"u"?self:{},i.Konva={_global:i.glob,version:"9.3.22",isBrowser:k(),isUnminified:/param/.test((function(d){}).toString()),dblClickWindow:400,getAngle(d){return i.Konva.angleDeg?d*r:d},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 i.Konva.DD.isDragging},isTransforming(){var d;return(d=i.Konva.Transformer)===null||d===void 0?void 0:d.isTransforming()},isDragReady(){return!!i.Konva.DD.node},releaseCanvasOnDestroy:!0,document:i.glob.document,_injectGlobal(d){i.glob.Konva=d}};const o=d=>{i.Konva[d.prototype.getClassName()]=d};i._registerNode=o,i.Konva._injectGlobal(i.Konva)})(Yt)),Yt}var fe;function St(){return fe||(fe=1,(function(i){Object.defineProperty(i,"__esModule",{value:!0}),i.Util=i.Transform=void 0;const r=ut();class k{constructor(s=[1,0,0,1,0,0]){this.dirty=!1,this.m=s&&s.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 k(this.m)}copyInto(s){s.m[0]=this.m[0],s.m[1]=this.m[1],s.m[2]=this.m[2],s.m[3]=this.m[3],s.m[4]=this.m[4],s.m[5]=this.m[5]}point(s){const u=this.m;return{x:u[0]*s.x+u[2]*s.y+u[4],y:u[1]*s.x+u[3]*s.y+u[5]}}translate(s,u){return this.m[4]+=this.m[0]*s+this.m[2]*u,this.m[5]+=this.m[1]*s+this.m[3]*u,this}scale(s,u){return this.m[0]*=s,this.m[1]*=s,this.m[2]*=u,this.m[3]*=u,this}rotate(s){const u=Math.cos(s),_=Math.sin(s),T=this.m[0]*u+this.m[2]*_,m=this.m[1]*u+this.m[3]*_,A=this.m[0]*-_+this.m[2]*u,y=this.m[1]*-_+this.m[3]*u;return this.m[0]=T,this.m[1]=m,this.m[2]=A,this.m[3]=y,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(s,u){const _=this.m[0]+this.m[2]*u,T=this.m[1]+this.m[3]*u,m=this.m[2]+this.m[0]*s,A=this.m[3]+this.m[1]*s;return this.m[0]=_,this.m[1]=T,this.m[2]=m,this.m[3]=A,this}multiply(s){const u=this.m[0]*s.m[0]+this.m[2]*s.m[1],_=this.m[1]*s.m[0]+this.m[3]*s.m[1],T=this.m[0]*s.m[2]+this.m[2]*s.m[3],m=this.m[1]*s.m[2]+this.m[3]*s.m[3],A=this.m[0]*s.m[4]+this.m[2]*s.m[5]+this.m[4],y=this.m[1]*s.m[4]+this.m[3]*s.m[5]+this.m[5];return this.m[0]=u,this.m[1]=_,this.m[2]=T,this.m[3]=m,this.m[4]=A,this.m[5]=y,this}invert(){const s=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),u=this.m[3]*s,_=-this.m[1]*s,T=-this.m[2]*s,m=this.m[0]*s,A=s*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),y=s*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=u,this.m[1]=_,this.m[2]=T,this.m[3]=m,this.m[4]=A,this.m[5]=y,this}getMatrix(){return this.m}decompose(){const s=this.m[0],u=this.m[1],_=this.m[2],T=this.m[3],m=this.m[4],A=this.m[5],y=s*T-u*_,R={x:m,y:A,rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(s!=0||u!=0){const F=Math.sqrt(s*s+u*u);R.rotation=u>0?Math.acos(s/F):-Math.acos(s/F),R.scaleX=F,R.scaleY=y/F,R.skewX=(s*_+u*T)/y,R.skewY=0}else if(_!=0||T!=0){const F=Math.sqrt(_*_+T*T);R.rotation=Math.PI/2-(T>0?Math.acos(-_/F):-Math.acos(_/F)),R.scaleX=y/F,R.scaleY=F,R.skewX=0,R.skewY=(s*_+u*T)/y}return R.rotation=i.Util._getRotation(R.rotation),R}}i.Transform=k;const o="[object Array]",d="[object Number]",p="[object String]",b="[object Boolean]",C=Math.PI/180,w=180/Math.PI,S="#",L="",O="0",M="Konva warning: ",U="Konva error: ",v="rgb(",B={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]},V=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/;let N=[];const l=typeof requestAnimationFrame<"u"&&requestAnimationFrame||function(e){setTimeout(e,60)};i.Util={_isElement(e){return!!(e&&e.nodeType==1)},_isFunction(e){return!!(e&&e.constructor&&e.call&&e.apply)},_isPlainObject(e){return!!e&&e.constructor===Object},_isArray(e){return Object.prototype.toString.call(e)===o},_isNumber(e){return Object.prototype.toString.call(e)===d&&!isNaN(e)&&isFinite(e)},_isString(e){return Object.prototype.toString.call(e)===p},_isBoolean(e){return Object.prototype.toString.call(e)===b},isObject(e){return e instanceof Object},isValidSelector(e){if(typeof e!="string")return!1;const s=e[0];return s==="#"||s==="."||s===s.toUpperCase()},_sign(e){return e===0||e>0?1:-1},requestAnimFrame(e){N.push(e),N.length===1&&l(function(){const s=N;N=[],s.forEach(function(u){u()})})},createCanvasElement(){const e=document.createElement("canvas");try{e.style=e.style||{}}catch{}return e},createImageElement(){return document.createElement("img")},_isInDocument(e){for(;e=e.parentNode;)if(e==document)return!0;return!1},_urlToImage(e,s){const u=i.Util.createImageElement();u.onload=function(){s(u)},u.src=e},_rgbToHex(e,s,u){return((1<<24)+(e<<16)+(s<<8)+u).toString(16).slice(1)},_hexToRgb(e){e=e.replace(S,L);const s=parseInt(e,16);return{r:s>>16&255,g:s>>8&255,b:s&255}},getRandomColor(){let e=(Math.random()*16777215<<0).toString(16);for(;e.length<6;)e=O+e;return S+e},getRGB(e){let s;return e in B?(s=B[e],{r:s[0],g:s[1],b:s[2]}):e[0]===S?this._hexToRgb(e.substring(1)):e.substr(0,4)===v?(s=V.exec(e.replace(/ /g,"")),{r:parseInt(s[1],10),g:parseInt(s[2],10),b:parseInt(s[3],10)}):{r:0,g:0,b:0}},colorToRGBA(e){return e=e||"black",i.Util._namedColorToRBA(e)||i.Util._hex3ColorToRGBA(e)||i.Util._hex4ColorToRGBA(e)||i.Util._hex6ColorToRGBA(e)||i.Util._hex8ColorToRGBA(e)||i.Util._rgbColorToRGBA(e)||i.Util._rgbaColorToRGBA(e)||i.Util._hslColorToRGBA(e)},_namedColorToRBA(e){const s=B[e.toLowerCase()];return s?{r:s[0],g:s[1],b:s[2],a:1}:null},_rgbColorToRGBA(e){if(e.indexOf("rgb(")===0){e=e.match(/rgb\(([^)]+)\)/)[1];const s=e.split(/ *, */).map(Number);return{r:s[0],g:s[1],b:s[2],a:1}}},_rgbaColorToRGBA(e){if(e.indexOf("rgba(")===0){e=e.match(/rgba\(([^)]+)\)/)[1];const s=e.split(/ *, */).map((u,_)=>u.slice(-1)==="%"?_===3?parseInt(u)/100:parseInt(u)/100*255:Number(u));return{r:s[0],g:s[1],b:s[2],a:s[3]}}},_hex8ColorToRGBA(e){if(e[0]==="#"&&e.length===9)return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:parseInt(e.slice(7,9),16)/255}},_hex6ColorToRGBA(e){if(e[0]==="#"&&e.length===7)return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:1}},_hex4ColorToRGBA(e){if(e[0]==="#"&&e.length===5)return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:parseInt(e[4]+e[4],16)/255}},_hex3ColorToRGBA(e){if(e[0]==="#"&&e.length===4)return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:1}},_hslColorToRGBA(e){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(e)){const[s,...u]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(e),_=Number(u[0])/360,T=Number(u[1])/100,m=Number(u[2])/100;let A,y,R;if(T===0)return R=m*255,{r:Math.round(R),g:Math.round(R),b:Math.round(R),a:1};m<.5?A=m*(1+T):A=m+T-m*T;const F=2*m-A,j=[0,0,0];for(let D=0;D<3;D++)y=_+1/3*-(D-1),y<0&&y++,y>1&&y--,6*y<1?R=F+(A-F)*6*y:2*y<1?R=A:3*y<2?R=F+(A-F)*(2/3-y)*6:R=F,j[D]=R*255;return{r:Math.round(j[0]),g:Math.round(j[1]),b:Math.round(j[2]),a:1}}},haveIntersection(e,s){return!(s.x>e.x+e.width||s.x+s.width<e.x||s.y>e.y+e.height||s.y+s.height<e.y)},cloneObject(e){const s={};for(const u in e)this._isPlainObject(e[u])?s[u]=this.cloneObject(e[u]):this._isArray(e[u])?s[u]=this.cloneArray(e[u]):s[u]=e[u];return s},cloneArray(e){return e.slice(0)},degToRad(e){return e*C},radToDeg(e){return e*w},_degToRad(e){return i.Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),i.Util.degToRad(e)},_radToDeg(e){return i.Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),i.Util.radToDeg(e)},_getRotation(e){return r.Konva.angleDeg?i.Util.radToDeg(e):e},_capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)},throw(e){throw new Error(U+e)},error(e){console.error(U+e)},warn(e){r.Konva.showWarnings&&console.warn(M+e)},each(e,s){for(const u in e)s(u,e[u])},_inRange(e,s,u){return s<=e&&e<u},_getProjectionToSegment(e,s,u,_,T,m){let A,y,R;const F=(e-u)*(e-u)+(s-_)*(s-_);if(F==0)A=e,y=s,R=(T-u)*(T-u)+(m-_)*(m-_);else{const j=((T-e)*(u-e)+(m-s)*(_-s))/F;j<0?(A=e,y=s,R=(e-T)*(e-T)+(s-m)*(s-m)):j>1?(A=u,y=_,R=(u-T)*(u-T)+(_-m)*(_-m)):(A=e+j*(u-e),y=s+j*(_-s),R=(A-T)*(A-T)+(y-m)*(y-m))}return[A,y,R]},_getProjectionToLine(e,s,u){const _=i.Util.cloneObject(e);let T=Number.MAX_VALUE;return s.forEach(function(m,A){if(!u&&A===s.length-1)return;const y=s[(A+1)%s.length],R=i.Util._getProjectionToSegment(m.x,m.y,y.x,y.y,e.x,e.y),F=R[0],j=R[1],D=R[2];D<T&&(_.x=F,_.y=j,T=D)}),_},_prepareArrayForTween(e,s,u){const _=[],T=[];if(e.length>s.length){const A=s;s=e,e=A}for(let A=0;A<e.length;A+=2)_.push({x:e[A],y:e[A+1]});for(let A=0;A<s.length;A+=2)T.push({x:s[A],y:s[A+1]});const m=[];return T.forEach(function(A){const y=i.Util._getProjectionToLine(A,_,u);m.push(y.x),m.push(y.y)}),m},_prepareToStringify(e){let s;e.visitedByCircularReferenceRemoval=!0;for(const u in e)if(e.hasOwnProperty(u)&&e[u]&&typeof e[u]=="object"){if(s=Object.getOwnPropertyDescriptor(e,u),e[u].visitedByCircularReferenceRemoval||i.Util._isElement(e[u]))if(s.configurable)delete e[u];else return null;else if(i.Util._prepareToStringify(e[u])===null)if(s.configurable)delete e[u];else return null}return delete e.visitedByCircularReferenceRemoval,e},_assign(e,s){for(const u in s)e[u]=s[u];return e},_getFirstPointerId(e){return e.touches?e.changedTouches[0].identifier:e.pointerId||999},releaseCanvas(...e){r.Konva.releaseCanvasOnDestroy&&e.forEach(s=>{s.width=0,s.height=0})},drawRoundedRectPath(e,s,u,_){let T=0,m=0,A=0,y=0;typeof _=="number"?T=m=A=y=Math.min(_,s/2,u/2):(T=Math.min(_[0]||0,s/2,u/2),m=Math.min(_[1]||0,s/2,u/2),y=Math.min(_[2]||0,s/2,u/2),A=Math.min(_[3]||0,s/2,u/2)),e.moveTo(T,0),e.lineTo(s-m,0),e.arc(s-m,m,m,Math.PI*3/2,0,!1),e.lineTo(s,u-y),e.arc(s-y,u-y,y,0,Math.PI/2,!1),e.lineTo(A,u),e.arc(A,u-A,A,Math.PI/2,Math.PI,!1),e.lineTo(0,T),e.arc(T,T,T,Math.PI,Math.PI*3/2,!1)}}})(Xt)),Xt}var Kt={},tt={},ge;function Nt(){if(ge)return tt;ge=1,Object.defineProperty(tt,"__esModule",{value:!0}),tt.RGBComponent=o,tt.alphaComponent=d,tt.getNumberValidator=p,tt.getNumberOrArrayOfNumbersValidator=b,tt.getNumberOrAutoValidator=C,tt.getStringValidator=w,tt.getStringOrGradientValidator=S,tt.getFunctionValidator=L,tt.getNumberArrayValidator=O,tt.getBooleanValidator=M,tt.getComponentValidator=U;const i=ut(),r=St();function k(v){return r.Util._isString(v)?'"'+v+'"':Object.prototype.toString.call(v)==="[object Number]"||r.Util._isBoolean(v)?v:Object.prototype.toString.call(v)}function o(v){return v>255?255:v<0?0:Math.round(v)}function d(v){return v>1?1:v<1e-4?1e-4:v}function p(){if(i.Konva.isUnminified)return function(v,B){return r.Util._isNumber(v)||r.Util.warn(k(v)+' is a not valid value for "'+B+'" attribute. The value should be a number.'),v}}function b(v){if(i.Konva.isUnminified)return function(B,V){let N=r.Util._isNumber(B),l=r.Util._isArray(B)&&B.length==v;return!N&&!l&&r.Util.warn(k(B)+' is a not valid value for "'+V+'" attribute. The value should be a number or Array<number>('+v+")"),B}}function C(){if(i.Konva.isUnminified)return function(v,B){return r.Util._isNumber(v)||v==="auto"||r.Util.warn(k(v)+' is a not valid value for "'+B+'" attribute. The value should be a number or "auto".'),v}}function w(){if(i.Konva.isUnminified)return function(v,B){return r.Util._isString(v)||r.Util.warn(k(v)+' is a not valid value for "'+B+'" attribute. The value should be a string.'),v}}function S(){if(i.Konva.isUnminified)return function(v,B){const V=r.Util._isString(v),N=Object.prototype.toString.call(v)==="[object CanvasGradient]"||v&&v.addColorStop;return V||N||r.Util.warn(k(v)+' is a not valid value for "'+B+'" attribute. The value should be a string or a native gradient.'),v}}function L(){if(i.Konva.isUnminified)return function(v,B){return r.Util._isFunction(v)||r.Util.warn(k(v)+' is a not valid value for "'+B+'" attribute. The value should be a function.'),v}}function O(){if(i.Konva.isUnminified)return function(v,B){const V=Int8Array?Object.getPrototypeOf(Int8Array):null;return V&&v instanceof V||(r.Util._isArray(v)?v.forEach(function(N){r.Util._isNumber(N)||r.Util.warn('"'+B+'" attribute has non numeric element '+N+". Make sure that all elements are numbers.")}):r.Util.warn(k(v)+' is a not valid value for "'+B+'" attribute. The value should be a array of numbers.')),v}}function M(){if(i.Konva.isUnminified)return function(v,B){return v===!0||v===!1||r.Util.warn(k(v)+' is a not valid value for "'+B+'" attribute. The value should be a boolean.'),v}}function U(v){if(i.Konva.isUnminified)return function(B,V){return B==null||r.Util.isObject(B)||r.Util.warn(k(B)+' is a not valid value for "'+V+'" attribute. The value should be an object with properties '+v),B}}return tt}var pe;function zt(){return pe||(pe=1,(function(i){Object.defineProperty(i,"__esModule",{value:!0}),i.Factory=void 0;const r=St(),k=Nt(),o="get",d="set";i.Factory={addGetterSetter(p,b,C,w,S){i.Factory.addGetter(p,b,C),i.Factory.addSetter(p,b,w,S),i.Factory.addOverloadedGetterSetter(p,b)},addGetter(p,b,C){const w=o+r.Util._capitalize(b);p.prototype[w]=p.prototype[w]||function(){const S=this.attrs[b];return S===void 0?C:S}},addSetter(p,b,C,w){const S=d+r.Util._capitalize(b);p.prototype[S]||i.Factory.overWriteSetter(p,b,C,w)},overWriteSetter(p,b,C,w){const S=d+r.Util._capitalize(b);p.prototype[S]=function(L){return C&&L!==void 0&&L!==null&&(L=C.call(this,L,b)),this._setAttr(b,L),w&&w.call(this),this}},addComponentsGetterSetter(p,b,C,w,S){const L=C.length,O=r.Util._capitalize,M=o+O(b),U=d+O(b);p.prototype[M]=function(){const B={};for(let V=0;V<L;V++){const N=C[V];B[N]=this.getAttr(b+O(N))}return B};const v=(0,k.getComponentValidator)(C);p.prototype[U]=function(B){const V=this.attrs[b];w&&(B=w.call(this,B,b)),v&&v.call(this,B,b);for(const N in B)B.hasOwnProperty(N)&&this._setAttr(b+O(N),B[N]);return B||C.forEach(N=>{this._setAttr(b+O(N),void 0)}),this._fireChangeEvent(b,V,B),S&&S.call(this),this},i.Factory.addOverloadedGetterSetter(p,b)},addOverloadedGetterSetter(p,b){const C=r.Util._capitalize(b),w=d+C,S=o+C;p.prototype[b]=function(){return arguments.length?(this[w](arguments[0]),this):this[S]()}},addDeprecatedGetterSetter(p,b,C,w){r.Util.error("Adding deprecated "+b);const S=o+r.Util._capitalize(b),L=b+" property is deprecated and will be removed soon. Look at Konva change log for more information.";p.prototype[S]=function(){r.Util.error(L);const O=this.attrs[b];return O===void 0?C:O},i.Factory.addSetter(p,b,w,function(){r.Util.error(L)}),i.Factory.addOverloadedGetterSetter(p,b)},backCompat(p,b){r.Util.each(b,function(C,w){const S=p.prototype[w],L=o+r.Util._capitalize(C),O=d+r.Util._capitalize(C);function M(){S.apply(this,arguments),r.Util.error('"'+C+'" method is deprecated and will be removed soon. Use ""'+w+'" instead.')}p.prototype[C]=M,p.prototype[L]=M,p.prototype[O]=M})},afterSetFilter(){this._filterUpToDate=!1}}})(Kt)),Kt}var $t={},Ot={},_t={},yt={},me;function Je(){if(me)return yt;me=1,Object.defineProperty(yt,"__esModule",{value:!0}),yt.HitContext=yt.SceneContext=yt.Context=void 0;const i=St(),r=ut();function k(N){const l=[],e=N.length,s=i.Util;for(let u=0;u<e;u++){let _=N[u];s._isNumber(_)?_=Math.round(_*1e3)/1e3:s._isString(_)||(_=_+""),l.push(_)}return l}const o=",",d="(",p=")",b="([",C="])",w=";",S="()",L="=",O=["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"],M=["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"],U=100;let v=class{constructor(l){this.canvas=l,r.Konva.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(l){l.fillEnabled()&&this._fill(l)}_fill(l){}strokeShape(l){l.hasStroke()&&this._stroke(l)}_stroke(l){}fillStrokeShape(l){l.attrs.fillAfterStrokeEnabled?(this.strokeShape(l),this.fillShape(l)):(this.fillShape(l),this.strokeShape(l))}getTrace(l,e){let s=this.traceArr,u=s.length,_="",T,m,A,y;for(T=0;T<u;T++)m=s[T],A=m.method,A?(y=m.args,_+=A,l?_+=S:i.Util._isArray(y[0])?_+=b+y.join(o)+C:(e&&(y=y.map(R=>typeof R=="number"?Math.floor(R):R)),_+=d+y.join(o)+p)):(_+=m.property,l||(_+=L+m.val)),_+=w;return _}clearTrace(){this.traceArr=[]}_trace(l){let e=this.traceArr,s;e.push(l),s=e.length,s>=U&&e.shift()}reset(){const l=this.getCanvas().getPixelRatio();this.setTransform(1*l,0,0,1*l,0,0)}getCanvas(){return this.canvas}clear(l){const e=this.getCanvas();l?this.clearRect(l.x||0,l.y||0,l.width||0,l.height||0):this.clearRect(0,0,e.getWidth()/e.pixelRatio,e.getHeight()/e.pixelRatio)}_applyLineCap(l){const e=l.attrs.lineCap;e&&this.setAttr("lineCap",e)}_applyOpacity(l){const e=l.getAbsoluteOpacity();e!==1&&this.setAttr("globalAlpha",e)}_applyLineJoin(l){const e=l.attrs.lineJoin;e&&this.setAttr("lineJoin",e)}setAttr(l,e){this._context[l]=e}arc(l,e,s,u,_,T){this._context.arc(l,e,s,u,_,T)}arcTo(l,e,s,u,_){this._context.arcTo(l,e,s,u,_)}beginPath(){this._context.beginPath()}bezierCurveTo(l,e,s,u,_,T){this._context.bezierCurveTo(l,e,s,u,_,T)}clearRect(l,e,s,u){this._context.clearRect(l,e,s,u)}clip(...l){this._context.clip.apply(this._context,l)}closePath(){this._context.closePath()}createImageData(l,e){const s=arguments;if(s.length===2)return this._context.createImageData(l,e);if(s.length===1)return this._context.createImageData(l)}createLinearGradient(l,e,s,u){return this._context.createLinearGradient(l,e,s,u)}createPattern(l,e){return this._context.createPattern(l,e)}createRadialGradient(l,e,s,u,_,T){return this._context.createRadialGradient(l,e,s,u,_,T)}drawImage(l,e,s,u,_,T,m,A,y){const R=arguments,F=this._context;R.length===3?F.drawImage(l,e,s):R.length===5?F.drawImage(l,e,s,u,_):R.length===9&&F.drawImage(l,e,s,u,_,T,m,A,y)}ellipse(l,e,s,u,_,T,m,A){this._context.ellipse(l,e,s,u,_,T,m,A)}isPointInPath(l,e,s,u){return s?this._context.isPointInPath(s,l,e,u):this._context.isPointInPath(l,e,u)}fill(...l){this._context.fill.apply(this._context,l)}fillRect(l,e,s,u){this._context.fillRect(l,e,s,u)}strokeRect(l,e,s,u){this._context.strokeRect(l,e,s,u)}fillText(l,e,s,u){u?this._context.fillText(l,e,s,u):this._context.fillText(l,e,s)}measureText(l){return this._context.measureText(l)}getImageData(l,e,s,u){return this._context.getImageData(l,e,s,u)}lineTo(l,e){this._context.lineTo(l,e)}moveTo(l,e){this._context.moveTo(l,e)}rect(l,e,s,u){this._context.rect(l,e,s,u)}roundRect(l,e,s,u,_){this._context.roundRect(l,e,s,u,_)}putImageData(l,e,s){this._context.putImageData(l,e,s)}quadraticCurveTo(l,e,s,u){this._context.quadraticCurveTo(l,e,s,u)}restore(){this._context.restore()}rotate(l){this._context.rotate(l)}save(){this._context.save()}scale(l,e){this._context.scale(l,e)}setLineDash(l){this._context.setLineDash?this._context.setLineDash(l):"mozDash"in this._context?this._context.mozDash=l:"webkitLineDash"in this._context&&(this._context.webkitLineDash=l)}getLineDash(){return this._context.getLineDash()}setTransform(l,e,s,u,_,T){this._context.setTransform(l,e,s,u,_,T)}stroke(l){l?this._context.stroke(l):this._context.stroke()}strokeText(l,e,s,u){this._context.strokeText(l,e,s,u)}transform(l,e,s,u,_,T){this._context.transform(l,e,s,u,_,T)}translate(l,e){this._context.translate(l,e)}_enableTrace(){let l=this,e=O.length,s=this.setAttr,u,_;const T=function(m){let A=l[m],y;l[m]=function(){return _=k(Array.prototype.slice.call(arguments,0)),y=A.apply(l,arguments),l._trace({method:m,args:_}),y}};for(u=0;u<e;u++)T(O[u]);l.setAttr=function(){s.apply(l,arguments);const m=arguments[0];let A=arguments[1];(m==="shadowOffsetX"||m==="shadowOffsetY"||m==="shadowBlur")&&(A=A/this.canvas.getPixelRatio()),l._trace({property:m,val:A})}}_applyGlobalCompositeOperation(l){const e=l.attrs.globalCompositeOperation;!e||e==="source-over"||this.setAttr("globalCompositeOperation",e)}};yt.Context=v,M.forEach(function(N){Object.defineProperty(v.prototype,N,{get(){return this._context[N]},set(l){this._context[N]=l}})});class B extends v{constructor(l,{willReadFrequently:e=!1}={}){super(l),this._context=l._canvas.getContext("2d",{willReadFrequently:e})}_fillColor(l){const e=l.fill();this.setAttr("fillStyle",e),l._fillFunc(this)}_fillPattern(l){this.setAttr("fillStyle",l._getFillPattern()),l._fillFunc(this)}_fillLinearGradient(l){const e=l._getLinearGradient();e&&(this.setAttr("fillStyle",e),l._fillFunc(this))}_fillRadialGradient(l){const e=l._getRadialGradient();e&&(this.setAttr("fillStyle",e),l._fillFunc(this))}_fill(l){const e=l.fill(),s=l.getFillPriority();if(e&&s==="color"){this._fillColor(l);return}const u=l.getFillPatternImage();if(u&&s==="pattern"){this._fillPattern(l);return}const _=l.getFillLinearGradientColorStops();if(_&&s==="linear-gradient"){this._fillLinearGradient(l);return}const T=l.getFillRadialGradientColorStops();if(T&&s==="radial-gradient"){this._fillRadialGradient(l);return}e?this._fillColor(l):u?this._fillPattern(l):_?this._fillLinearGradient(l):T&&this._fillRadialGradient(l)}_strokeLinearGradient(l){const e=l.getStrokeLinearGradientStartPoint(),s=l.getStrokeLinearGradientEndPoint(),u=l.getStrokeLinearGradientColorStops(),_=this.createLinearGradient(e.x,e.y,s.x,s.y);if(u){for(let T=0;T<u.length;T+=2)_.addColorStop(u[T],u[T+1]);this.setAttr("strokeStyle",_)}}_stroke(l){const e=l.dash(),s=l.getStrokeScaleEnabled();if(l.hasStroke()){if(!s){this.save();const _=this.getCanvas().getPixelRatio();this.setTransform(_,0,0,_,0,0)}this._applyLineCap(l),e&&l.dashEnabled()&&(this.setLineDash(e),this.setAttr("lineDashOffset",l.dashOffset())),this.setAttr("lineWidth",l.strokeWidth()),l.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)"),l.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(l):this.setAttr("strokeStyle",l.stroke()),l._strokeFunc(this),s||this.restore()}}_applyShadow(l){var e,s,u;const _=(e=l.getShadowRGBA())!==null&&e!==void 0?e:"black",T=(s=l.getShadowBlur())!==null&&s!==void 0?s:5,m=(u=l.getShadowOffset())!==null&&u!==void 0?u:{x:0,y:0},A=l.getAbsoluteScale(),y=this.canvas.getPixelRatio(),R=A.x*y,F=A.y*y;this.setAttr("shadowColor",_),this.setAttr("shadowBlur",T*Math.min(Math.abs(R),Math.abs(F))),this.setAttr("shadowOffsetX",m.x*R),this.setAttr("shadowOffsetY",m.y*F)}}yt.SceneContext=B;class V extends v{constructor(l){super(l),this._context=l._canvas.getContext("2d",{willReadFrequently:!0})}_fill(l){this.save(),this.setAttr("fillStyle",l.colorKey),l._fillFuncHit(this),this.restore()}strokeShape(l){l.hasHitStroke()&&this._stroke(l)}_stroke(l){if(l.hasHitStroke()){const e=l.getStrokeScaleEnabled();if(!e){this.save();const _=this.getCanvas().getPixelRatio();this.setTransform(_,0,0,_,0,0)}this._applyLineCap(l);const s=l.hitStrokeWidth(),u=s==="auto"?l.strokeWidth():s;this.setAttr("lineWidth",u),this.setAttr("strokeStyle",l.colorKey),l._strokeFuncHit(this),e||this.restore()}}}return yt.HitContext=V,yt}var be;function Ze(){if(be)return _t;be=1,Object.defineProperty(_t,"__esModule",{value:!0}),_t.HitCanvas=_t.SceneCanvas=_t.Canvas=void 0;const i=St(),r=Je(),k=ut();let o;function d(){if(o)return o;const w=i.Util.createCanvasElement(),S=w.getContext("2d");return o=(function(){const L=k.Konva._global.devicePixelRatio||1,O=S.webkitBackingStorePixelRatio||S.mozBackingStorePixelRatio||S.msBackingStorePixelRatio||S.oBackingStorePixelRatio||S.backingStorePixelRatio||1;return L/O})(),i.Util.releaseCanvas(w),o}let p=class{constructor(S){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;const O=(S||{}).pixelRatio||k.Konva.pixelRatio||d();this.pixelRatio=O,this._canvas=i.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(S){const L=this.pixelRatio;this.pixelRatio=S,this.setSize(this.getWidth()/L,this.getHeight()/L)}setWidth(S){this.width=this._canvas.width=S*this.pixelRatio,this._canvas.style.width=S+"px";const L=this.pixelRatio;this.getContext()._context.scale(L,L)}setHeight(S){this.height=this._canvas.height=S*this.pixelRatio,this._canvas.style.height=S+"px";const L=this.pixelRatio;this.getContext()._context.scale(L,L)}getWidth(){return this.width}getHeight(){return this.height}setSize(S,L){this.setWidth(S||0),this.setHeight(L||0)}toDataURL(S,L){try{return this._canvas.toDataURL(S,L)}catch{try{return this._canvas.toDataURL()}catch(M){return i.Util.error("Unable to get data URL. "+M.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}};_t.Canvas=p;class b extends p{constructor(S={width:0,height:0,willReadFrequently:!1}){super(S),this.context=new r.SceneContext(this,{willReadFrequently:S.willReadFrequently}),this.setSize(S.width,S.height)}}_t.SceneCanvas=b;class C extends p{constructor(S={width:0,height:0}){super(S),this.hitCanvas=!0,this.context=new r.HitContext(this),this.setSize(S.width,S.height)}}return _t.HitCanvas=C,_t}var qt={},_e;function Qe(){return _e||(_e=1,(function(i){Object.defineProperty(i,"__esModule",{value:!0}),i.DD=void 0;const r=ut(),k=St();i.DD={get isDragging(){let o=!1;return i.DD._dragElements.forEach(d=>{d.dragStatus==="dragging"&&(o=!0)}),o},justDragged:!1,get node(){let o;return i.DD._dragElements.forEach(d=>{o=d.node}),o},_dragElements:new Map,_drag(o){const d=[];i.DD._dragElements.forEach((p,b)=>{const{node:C}=p,w=C.getStage();w.setPointersPositions(o),p.pointerId===void 0&&(p.pointerId=k.Util._getFirstPointerId(o));const S=w._changedPointerPositions.find(L=>L.id===p.pointerId);if(S){if(p.dragStatus!=="dragging"){const L=C.dragDistance();if(Math.max(Math.abs(S.x-p.startPointerPos.x),Math.abs(S.y-p.startPointerPos.y))<L||(C.startDrag({evt:o}),!C.isDragging()))return}C._setDragPosition(o,p),d.push(C)}}),d.forEach(p=>{p.fire("dragmove",{type:"dragmove",target:p,evt:o},!0)})},_endDragBefore(o){const d=[];i.DD._dragElements.forEach(p=>{const{node:b}=p,C=b.getStage();if(o&&C.setPointersPositions(o),!C._changedPointerPositions.find(L=>L.id===p.pointerId))return;(p.dragStatus==="dragging"||p.dragStatus==="stopped")&&(i.DD.justDragged=!0,r.Konva._mouseListenClick=!1,r.Konva._touchListenClick=!1,r.Konva._pointerListenClick=!1,p.dragStatus="stopped");const S=p.node.getLayer()||p.node instanceof r.Konva.Stage&&p.node;S&&d.indexOf(S)===-1&&d.push(S)}),d.forEach(p=>{p.draw()})},_endDragAfter(o){i.DD._dragElements.forEach((d,p)=>{d.dragStatus==="stopped"&&d.node.fire("dragend",{type:"dragend",target:d.node,evt:o},!0),d.dragStatus!=="dragging"&&i.DD._dragElements.delete(p)})}},r.Konva.isBrowser&&(window.addEventListener("mouseup",i.DD._endDragBefore,!0),window.addEventListener("touchend",i.DD._endDragBefore,!0),window.addEventListener("touchcancel",i.DD._endDragBefore,!0),window.addEventListener("mousemove",i.DD._drag),window.addEventListener("touchmove",i.DD._drag),window.addEventListener("mouseup",i.DD._endDragAfter,!1),window.addEventListener("touchend",i.DD._endDragAfter,!1),window.addEventListener("touchcancel",i.DD._endDragAfter,!1))})(qt)),qt}var ye;function tn(){if(ye)return Ot;ye=1,Object.defineProperty(Ot,"__esModule",{value:!0}),Ot.Node=void 0;const i=Ze(),r=Qe(),k=zt(),o=ut(),d=St(),p=Nt(),b="absoluteOpacity",C="allEventListeners",w="absoluteTransform",S="absoluteScale",L="canvas",O="Change",M="children",U="konva",v="listening",B="mouseenter",V="mouseleave",N="pointerenter",l="pointerleave",e="touchenter",s="touchleave",u="set",_="Shape",T=" ",m="stage",A="transform",y="Stage",R="visible",F=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(T);let j=1,D=class te{constructor(n){this._id=j++,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(n),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(n){(n===A||n===w)&&this._cache.get(n)?this._cache.get(n).dirty=!0:n?this._cache.delete(n):this._cache.clear()}_getCache(n,a){let c=this._cache.get(n);return(c===void 0||(n===A||n===w)&&c.dirty===!0)&&(c=a.call(this),this._cache.set(n,c)),c}_calculate(n,a,c){if(!this._attachedDepsListeners.get(n)){const f=a.map(h=>h+"Change.konva").join(T);this.on(f,()=>{this._clearCache(n)}),this._attachedDepsListeners.set(n,!0)}return this._getCache(n,c)}_getCanvasCache(){return this._cache.get(L)}_clearSelfAndDescendantCache(n){this._clearCache(n),n===w&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(L)){const{scene:n,filter:a,hit:c,buffer:f}=this._cache.get(L);d.Util.releaseCanvas(n,a,c,f),this._cache.delete(L)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(n){const a=n||{};let c={};(a.x===void 0||a.y===void 0||a.width===void 0||a.height===void 0)&&(c=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let f=Math.ceil(a.width||c.width),h=Math.ceil(a.height||c.height),x=a.pixelRatio,g=a.x===void 0?Math.floor(c.x):a.x,P=a.y===void 0?Math.floor(c.y):a.y,G=a.offset||0,I=a.drawBorder||!1,H=a.hitCanvasPixelRatio||1;if(!f||!h){d.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");return}const W=Math.abs(Math.round(c.x)-g)>.5?1:0,ot=Math.abs(Math.round(c.y)-P)>.5?1:0;f+=G*2+W,h+=G*2+ot,g-=G,P-=G;const X=new i.SceneCanvas({pixelRatio:x,width:f,height:h}),et=new i.SceneCanvas({pixelRatio:x,width:0,height:0,willReadFrequently:!0}),$=new i.HitCanvas({pixelRatio:H,width:f,height:h}),Y=X.getContext(),q=$.getContext(),Q=new i.SceneCanvas({width:X.width/X.pixelRatio+Math.abs(g),height:X.height/X.pixelRatio+Math.abs(P),pixelRatio:X.pixelRatio}),pt=Q.getContext();return $.isCache=!0,X.isCache=!0,this._cache.delete(L),this._filterUpToDate=!1,a.imageSmoothingEnabled===!1&&(X.getContext()._context.imageSmoothingEnabled=!1,et.getContext()._context.imageSmoothingEnabled=!1),Y.save(),q.save(),pt.save(),Y.translate(-g,-P),q.translate(-g,-P),pt.translate(-g,-P),Q.x=g,Q.y=P,this._isUnderCache=!0,this._clearSelfAndDescendantCache(b),this._clearSelfAndDescendantCache(S),this.drawScene(X,this,Q),this.drawHit($,this),this._isUnderCache=!1,Y.restore(),q.restore(),I&&(Y.save(),Y.beginPath(),Y.rect(0,0,f,h),Y.closePath(),Y.setAttr("strokeStyle","red"),Y.setAttr("lineWidth",5),Y.stroke(),Y.restore()),this._cache.set(L,{scene:X,filter:et,hit:$,buffer:Q,x:g,y:P}),this._requestDraw(),this}isCached(){return this._cache.has(L)}getClientRect(n){throw new Error('abstract "getClientRect" method call')}_transformedRect(n,a){const c=[{x:n.x,y:n.y},{x:n.x+n.width,y:n.y},{x:n.x+n.width,y:n.y+n.height},{x:n.x,y:n.y+n.height}];let f=1/0,h=1/0,x=-1/0,g=-1/0;const P=this.getAbsoluteTransform(a);return c.forEach(function(G){const I=P.point(G);f===void 0&&(f=x=I.x,h=g=I.y),f=Math.min(f,I.x),h=Math.min(h,I.y),x=Math.max(x,I.x),g=Math.max(g,I.y)}),{x:f,y:h,width:x-f,height:g-h}}_drawCachedSceneCanvas(n){n.save(),n._applyOpacity(this),n._applyGlobalCompositeOperation(this);const a=this._getCanvasCache();n.translate(a.x,a.y);const c=this._getCachedSceneCanvas(),f=c.pixelRatio;n.drawImage(c._canvas,0,0,c.width/f,c.height/f),n.restore()}_drawCachedHitCanvas(n){const a=this._getCanvasCache(),c=a.hit;n.save(),n.translate(a.x,a.y),n.drawImage(c._canvas,0,0,c.width/c.pixelRatio,c.height/c.pixelRatio),n.restore()}_getCachedSceneCanvas(){let n=this.filters(),a=this._getCanvasCache(),c=a.scene,f=a.filter,h=f.getContext(),x,g,P,G;if(n){if(!this._filterUpToDate){const I=c.pixelRatio;f.setSize(c.width/c.pixelRatio,c.height/c.pixelRatio);try{for(x=n.length,h.clear(),h.drawImage(c._canvas,0,0,c.getWidth()/I,c.getHeight()/I),g=h.getImageData(0,0,f.getWidth(),f.getHeight()),P=0;P<x;P++){if(G=n[P],typeof G!="function"){d.Util.error("Filter should be type of function, but got "+typeof G+" instead. Please check correct filters");continue}G.call(this,g),h.putImageData(g,0,0)}}catch(H){d.Util.error("Unable to apply filter. "+H.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return f}return c}on(n,a){if(this._cache&&this._cache.delete(C),arguments.length===3)return this._delegate.apply(this,arguments);const c=n.split(T);for(let f=0;f<c.length;f++){const x=c[f].split("."),g=x[0],P=x[1]||"";this.eventListeners[g]||(this.eventListeners[g]=[]),this.eventListeners[g].push({name:P,handler:a})}return this}off(n,a){let c=(n||"").split(T),f=c.length,h,x,g,P,G,I;if(this._cache&&this._cache.delete(C),!n)for(x in this.eventListeners)this._off(x);for(h=0;h<f;h++)if(g=c[h],P=g.split("."),G=P[0],I=P[1],G)this.eventListeners[G]&&this._off(G,I,a);else for(x in this.eventListeners)this._off(x,I,a);return this}dispatchEvent(n){const a={target:this,type:n.type,evt:n};return this.fire(n.type,a),this}addEventListener(n,a){return this.on(n,function(c){a.call(this,c.evt)}),this}removeEventListener(n){return this.off(n),this}_delegate(n,a,c){const f=this;this.on(n,function(h){const x=h.target.findAncestors(a,!0,f);for(let g=0;g<x.length;g++)h=d.Util.cloneObject(h),h.currentTarget=x[g],c.call(x[g],h)})}remove(){return this.isDragging()&&this.stopDrag(),r.DD._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(w),this._clearSelfAndDescendantCache(b),this._clearSelfAndDescendantCache(S),this._clearSelfAndDescendantCache(m),this._clearSelfAndDescendantCache(R),this._clearSelfAndDescendantCache(v)}_remove(){this._clearCaches();const n=this.getParent();n&&n.children&&(n.children.splice(this.index,1),n._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(n){const a="get"+d.Util._capitalize(n);return d.Util._isFunction(this[a])?this[a]():this.attrs[n]}getAncestors(){let n=this.getParent(),a=[];for(;n;)a.push(n),n=n.getParent();return a}getAttrs(){return this.attrs||{}}setAttrs(n){return this._batchTransformChanges(()=>{let a,c;if(!n)return this;for(a in n)a!==M&&(c=u+d.Util._capitalize(a),d.Util._isFunction(this[c])?this[c](n[a]):this._setAttr(a,n[a]))}),this}isListening(){return this._getCache(v,this._isListening)}_isListening(n){if(!this.listening())return!1;const c=this.getParent();return c&&c!==n&&this!==n?c._isListening(n):!0}isVisible(){return this._getCache(R,this._isVisible)}_isVisible(n){if(!this.visible())return!1;const c=this.getParent();return c&&c!==n&&this!==n?c._isVisible(n):!0}shouldDrawHit(n,a=!1){if(n)return this._isVisible(n)&&this._isListening(n);const c=this.getLayer();let f=!1;r.DD._dragElements.forEach(x=>{x.dragStatus==="dragging"&&(x.node.nodeType==="Stage"||x.node.getLayer()===c)&&(f=!0)});const h=!a&&!o.Konva.hitOnDragEnabled&&(f||o.Konva.isTransforming());return this.isListening()&&this.isVisible()&&!h}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let n=this.getDepth(),a=this,c=0,f,h,x,g;function P(I){for(f=[],h=I.length,x=0;x<h;x++)g=I[x],c++,g.nodeType!==_&&(f=f.concat(g.getChildren().slice())),g._id===a._id&&(x=h);f.length>0&&f[0].getDepth()<=n&&P(f)}const G=this.getStage();return a.nodeType!==y&&G&&P(G.getChildren()),c}getDepth(){let n=0,a=this.parent;for(;a;)n++,a=a.parent;return n}_batchTransformChanges(n){this._batchingTransformChange=!0,n(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(A),this._clearSelfAndDescendantCache(w)),this._needClearTransformCache=!1}setPosition(n){return this._batchTransformChanges(()=>{this.x(n.x),this.y(n.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){const n=this.getStage();if(!n)return null;const a=n.getPointerPosition();if(!a)return null;const c=this.getAbsoluteTransform().copy();return c.invert(),c.point(a)}getAbsolutePosition(n){let a=!1,c=this.parent;for(;c;){if(c.isCached()){a=!0;break}c=c.parent}a&&!n&&(n=!0);const f=this.getAbsoluteTransform(n).getMatrix(),h=new d.Transform,x=this.offset();return h.m=f.slice(),h.translate(x.x,x.y),h.getTranslation()}setAbsolutePosition(n){const{x:a,y:c,...f}=this._clearTransform();this.attrs.x=a,this.attrs.y=c,this._clearCache(A);const h=this._getAbsoluteTransform().copy();return h.invert(),h.translate(n.x,n.y),n={x:this.attrs.x+h.getTranslation().x,y:this.attrs.y+h.getTranslation().y},this._setTransform(f),this.setPosition({x:n.x,y:n.y}),this._clearCache(A),this._clearSelfAndDescendantCache(w),this}_setTransform(n){let a;for(a in n)this.attrs[a]=n[a]}_clearTransform(){const n={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,n}move(n){let a=n.x,c=n.y,f=this.x(),h=this.y();return a!==void 0&&(f+=a),c!==void 0&&(h+=c),this.setPosition({x:f,y:h}),this}_eachAncestorReverse(n,a){let c=[],f=this.getParent(),h,x;if(!(a&&a._id===this._id)){for(c.unshift(this);f&&(!a||f._id!==a._id);)c.unshift(f),f=f.parent;for(h=c.length,x=0;x<h;x++)n(c[x])}}rotate(n){return this.rotation(this.rotation()+n),this}moveToTop(){if(!this.parent)return d.Util.warn("Node has no parent. moveToTop function is ignored."),!1;const n=this.index,a=this.parent.getChildren().length;return n<a-1?(this.parent.children.splice(n,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0):!1}moveUp(){if(!this.parent)return d.Util.warn("Node has no parent. moveUp function is ignored."),!1;const n=this.index,a=this.parent.getChildren().length;return n<a-1?(this.parent.children.splice(n,1),this.parent.children.splice(n+1,0,this),this.parent._setChildrenIndices(),!0):!1}moveDown(){if(!this.parent)return d.Util.warn("Node has no parent. moveDown function is ignored."),!1;const n=this.index;return n>0?(this.parent.children.splice(n,1),this.parent.children.splice(n-1,0,this),this.parent._setChildrenIndices(),!0):!1}moveToBottom(){if(!this.parent)return d.Util.warn("Node has no parent. moveToBottom function is ignored."),!1;const n=this.index;return n>0?(this.parent.children.splice(n,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0):!1}setZIndex(n){if(!this.parent)return d.Util.warn("Node has no parent. zIndex parameter is ignored."),this;(n<0||n>=this.parent.children.length)&&d.Util.warn("Unexpected value "+n+" 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 a=this.index;return this.parent.children.splice(a,1),this.parent.children.splice(n,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(b,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let n=this.opacity();const a=this.getParent();return a&&!a._isUnderCache&&(n*=a.getAbsoluteOpacity()),n}moveTo(n){return this.getParent()!==n&&(this._remove(),n.add(this)),this}toObject(){let n=this.getAttrs(),a,c,f,h,x;const g={attrs:{},className:this.getClassName()};for(a in n)c=n[a],x=d.Util.isObject(c)&&!d.Util._isPlainObject(c)&&!d.Util._isArray(c),!x&&(f=typeof this[a]=="function"&&this[a],delete n[a],h=f?f.call(this):null,n[a]=c,h!==c&&(g.attrs[a]=c));return d.Util._prepareToStringify(g)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(n,a,c){const f=[];a&&this._isMatch(n)&&f.push(this);let h=this.parent;for(;h;){if(h===c)return f;h._isMatch(n)&&f.push(h),h=h.parent}return f}isAncestorOf(n){return!1}findAncestor(n,a,c){return this.findAncestors(n,a,c)[0]}_isMatch(n){if(!n)return!1;if(typeof n=="function")return n(this);let a=n.replace(/ /g,"").split(","),c=a.length,f,h;for(f=0;f<c;f++)if(h=a[f],d.Util.isValidSelector(h)||(d.Util.warn('Selector "'+h+'" is