@inweb/viewer-visualize 25.3.13 → 25.3.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).ODA=t.ODA||{},t.ODA.Visualize=t.ODA.Visualize||{}))}(this,(function(t){"use strict";class e{constructor(){this._commands=new Map}registerCommand(t,e,i,r){this._commands.set(t,{id:t,handler:e,thisArg:r,description:i})}registerCommandAlias(t,e){this.registerCommand(e,((e,...i)=>this.executeCommand(t,e,...i)))}getCommand(t){return this._commands.get(t)}getCommands(){const t=new Map;return this._commands.forEach(((e,i)=>t.set(i,e))),t}executeCommand(t,e,...i){const r=this._commands.get(t);if(!r){if(e){if(e.draggers.includes(t))return e.setActiveDragger(t)}return void console.warn(`Command '${t}' not found`)}const{handler:s,thisArg:a}=r,n=s.apply(a,[e,...i]);return null==e||e.emit({type:"command",data:t,args:i}),n}}const i=new Map;function r(t=""){let r=i.get(t);return r||(r=new e,i.set(t,r)),r}r("").registerCommand("noop",(()=>{})),r("VisualizeJS").registerCommand("noop",(()=>{})),r("ThreeJS").registerCommand("noop",(()=>{}));class s{constructor(t){this._emitter=t,this._data=s.defaults(),this.loadFromStorage()}static defaults(){return{showWCS:!0,cameraAnimation:!0,antialiasing:!0,groundShadow:!1,shadows:!1,cameraAxisXSpeed:4,cameraAxisYSpeed:1,ambientOcclusion:!1,enableStreamingMode:!0,enablePartialMode:!1,memoryLimit:3294967296,cuttingPlaneFillColor:{red:255,green:152,blue:0},edgesColor:{r:255,g:152,b:0},facesColor:{r:255,g:152,b:0},edgesVisibility:!0,edgesOverlap:!0,facesOverlap:!1,facesTransparancy:200,enableCustomHighlight:!0,sceneGraph:!1,edgeModel:!0,reverseZoomWheel:!1,enableZoomWheel:!0,enableGestures:!0,geometryType:"vsfx"}}notifierChangeEvent(){void 0!==this._emitter&&(this.saveToStorage(),this._emitter.emit({type:"optionschange",data:this}))}saveToStorage(){if("undefined"!=typeof window)try{localStorage.setItem("od-client-settings",JSON.stringify(this.data))}catch(t){console.error("Cannot save client settings.",t)}}loadFromStorage(){if("undefined"!=typeof window)try{const t=localStorage.getItem("od-client-settings");if(t){const e=JSON.parse(t);this.data={...e}}}catch(t){console.error("Cannot load client settings.",t)}}resetToDefaults(t){if(void 0!==t){const e=s.defaults(),i=t.reduce(((t,i)=>(t[i]=e[i],t)),{});this.data={...this.data,...i}}else this.data={...this.data,...s.defaults()}}get data(){return this._data}set data(t){const e=!t.enablePartialMode&&t.sceneGraph;this._data={...s.defaults(),...this._data,...t,sceneGraph:e},this.notifierChangeEvent()}get showWCS(){return this._data.showWCS}set showWCS(t){this._data.showWCS=t,this.notifierChangeEvent()}get cameraAnimation(){return this._data.cameraAnimation}set cameraAnimation(t){this._data.cameraAnimation=t,this.notifierChangeEvent()}get antialiasing(){return this._data.antialiasing}set antialiasing(t){this._data.antialiasing=t,this.notifierChangeEvent()}get groundShadow(){return this._data.groundShadow}set groundShadow(t){this._data.groundShadow=t,this.notifierChangeEvent()}get shadows(){return this._data.shadows}set shadows(t){this._data.shadows=t,this.notifierChangeEvent()}get cameraAxisXSpeed(){return this._data.cameraAxisXSpeed}set cameraAxisXSpeed(t){this._data.cameraAxisXSpeed=t,this.notifierChangeEvent()}get cameraAxisYSpeed(){return this._data.cameraAxisYSpeed}set cameraAxisYSpeed(t){this.cameraAxisYSpeed=t,this.notifierChangeEvent()}get ambientOcclusion(){return this._data.ambientOcclusion}set ambientOcclusion(t){this._data.ambientOcclusion=t,this.notifierChangeEvent()}get enableStreamingMode(){return this._data.enableStreamingMode}set enableStreamingMode(t){this._data.enableStreamingMode=t,this._data.enableStreamingMode&&(this._data.enablePartialMode=!1),this.notifierChangeEvent()}get enablePartialMode(){return this._data.enablePartialMode}set enablePartialMode(t){this._data.enablePartialMode=t,t&&(this._data.sceneGraph=!1),this.notifierChangeEvent()}get memoryLimit(){return this._data.memoryLimit}set memoryLimit(t){this._data.memoryLimit=t,this.notifierChangeEvent()}get cuttingPlaneFillColor(){return this._data.cuttingPlaneFillColor}set cuttingPlaneFillColor(t){this._data.cuttingPlaneFillColor=t,this.notifierChangeEvent()}get edgesColor(){return this._data.edgesColor}set edgesColor(t){this._data.edgesColor=t,this.notifierChangeEvent()}get facesColor(){return this._data.facesColor}set facesColor(t){this._data.facesColor=t,this.notifierChangeEvent()}get edgesVisibility(){return this._data.edgesVisibility}set edgesVisibility(t){this._data.edgesVisibility=t,this.notifierChangeEvent()}get edgesOverlap(){return this._data.edgesOverlap}set edgesOverlap(t){this._data.edgesOverlap=t,this.notifierChangeEvent()}get facesOverlap(){return this._data.facesOverlap}set facesOverlap(t){this._data.facesOverlap=t,this.notifierChangeEvent()}get facesTransparancy(){return this._data.facesTransparancy}set facesTransparancy(t){this._data.facesTransparancy=t,this.notifierChangeEvent()}get enableCustomHighlight(){return this._data.enableCustomHighlight}set enableCustomHighlight(t){this._data.enableCustomHighlight=t,this.notifierChangeEvent()}get sceneGraph(){return this._data.sceneGraph}set sceneGraph(t){this._data.sceneGraph=t,t&&(this._data.enablePartialMode=!1),this.notifierChangeEvent()}get edgeModel(){return Boolean(this._data.edgeModel)}set edgeModel(t){this._data.edgeModel=Boolean(t),this.notifierChangeEvent()}get reverseZoomWheel(){return this._data.reverseZoomWheel}set reverseZoomWheel(t){this._data.reverseZoomWheel=!!t,this.notifierChangeEvent()}get enableZoomWheel(){return this._data.enableZoomWheel}set enableZoomWheel(t){this._data.enableZoomWheel=!!t,this.notifierChangeEvent()}get enableGestures(){return this._data.enableGestures}set enableGestures(t){this._data.enableGestures=!!t,this.notifierChangeEvent()}get geometryType(){return this._data.geometryType}set geometryType(t){this._data.geometryType=t,this.notifierChangeEvent()}}const a=["click","dblclick","mousedown","mousemove","mouseup","mouseleave","pointerdown","pointermove","pointerup","pointerleave","pointercancel","wheel","touchstart","touchmove","touchend","touchcancel"];class n{constructor(){this._listeners=void 0}addEventListener(t,e){return void 0===this._listeners&&(this._listeners={}),void 0===this._listeners[t]&&(this._listeners[t]=[]),this._listeners[t].push(e),this}removeEventListener(t,e){if(void 0===this._listeners)return this;if(void 0===this._listeners[t])return this;const i=this._listeners[t].filter((t=>t!==e));return this._listeners[t]=0===i.length?void 0:i,this}removeAllListeners(t){return t?this._listeners[t]=void 0:this._listeners=void 0,this}emitEvent(t){if(void 0===this._listeners)return!1;if(void 0===this._listeners[t.type])return!1;return this._listeners[t.type].slice().forEach((e=>e.call(this,t))),!0}on(t,e){return this.addEventListener(t,e)}off(t,e){return this.removeEventListener(t,e)}emit(t,...e){return"string"==typeof t?this.emitEvent({type:t,args:e}):"object"==typeof t&&this.emitEvent(t)}}class o{constructor(t){this.setViewParams=t=>{var e;const i=this.m_module.getViewer().getActiveTvExtendedView();i.setView(t.position,t.target,t.upVector,t.viewFieldWidth,t.viewFieldHeight,t.perspective),null===(e=i.delete)||void 0===e||e.call(i)},this.getViewParams=()=>{var t;const e=this.m_module.getViewer().activeView,i={position:e.viewPosition,target:e.viewTarget,upVector:e.upVector,viewFieldWidth:e.viewFieldWidth,viewFieldHeight:e.viewFieldHeight,perspective:e.perspective};return null===(t=e.delete)||void 0===t||t.call(e),i},this.m_module=t}getViewer(){return this.m_module.getViewer()}getModel(){return this.getViewer().getMarkupModel()}copyPoint(t){const e=new this.m_module.Point3d;return e.set(t.x,t.y,t.z),e}createVector3d(){return new this.m_module.Vector3d}createPoint3d(){return new this.m_module.Point3d}createMatrix3d(){return new this.m_module.Matrix3d}createPlane(){return new this.m_module.OdTvPlane}toVector(t){return this.m_module.Vector3d.createFromArray(t)}toGeVector(t){return[t.x,t.y,t.z]}toGePoint(t){return[t.x,t.y,t.z]}toPoint(t){return this.m_module.Point3d.createFromArray(t)}screenToWorld(t,e){return this.toPoint(this.m_module.getViewer().screenToWorld(t,e))}toDoubleArray(t){const e=[];for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y),e.push(t[i].z);return e}correctCameraTarget(){const t=this.getViewParams(),e=this.m_module.getViewer().getActiveExtents(),{min:i,max:r}=e,s=this.toPoint(t.target);s.x>=i.x&&s.y>=i.y&&s.z>=i.z&&s.x<=r.x&&s.y<=r.y&&s.z<=r.z||(t.target=e.center(),this.setViewParams(t))}}class h extends o{constructor(t){super(t.visualizeJs),this.beginInteractivity=()=>{const t=this.getViewer().activeView;t.beginInteractivity&&(t.beginInteractivity(24),this.subject.update()),t.delete()},this.endInteractivity=()=>{const t=this.getViewer().activeView;if(t.endInteractivity){t.endInteractivity();const e=this.getViewer().getActiveDevice(),i=this.m_module.canvas;e.invalidate([0,0,i.width,i.height]),e.delete(),this.subject.update()}t.delete()},this.subject=t,this.needInputText=!1,this.mouseDownPosition={x:0,y:0},this.autoSelect=!1,this.onmessage=t=>this.subject.emitEvent(t),this.canvasEvents=a}initialize(){this.canvasEvents=this.canvasEvents.filter((t=>"function"==typeof this[t])),this.canvasEvents.forEach((t=>this[t]=this[t].bind(this))),this.canvasEvents.forEach((t=>this.subject.on(t,this[t]))),this.getViewer().setEnableAutoSelect(!!this.autoSelect)}dispose(){this.canvasEvents.forEach((t=>this.subject.off(t,this[t])))}relativeCoords(t){return{x:t.offsetX*window.devicePixelRatio,y:t.offsetY*window.devicePixelRatio}}pointerdown(t){if(!t.isPrimary||h.isGestureActive)return;t.target.setPointerCapture(t.pointerId);const e=this.relativeCoords(t);this.isDragging=!0,this.mouseDownPosition={x:e.x,y:e.y},this.start(e.x,e.y,t.clientX,t.clientY),this.subject.update()}pointerup(t){if(h.needSkipPointerUp)return;if(!t.isPrimary)return;t.target.releasePointerCapture(t.pointerId);const e=this.relativeCoords(t);this.end(e.x,e.y),this.isDragging=!1,this.subject.update()}pointercancel(t){t.isPrimary&&this.m_module.canvas.dispatchEvent(new PointerEvent("pointerup",t))}pointermove(t){if(!t.isPrimary||h.isGestureActive)return;const e=this.relativeCoords(t);this.drag(e.x,e.y,t.movementX,t.movementY),this.isDragging&&this.subject.update()}click(t){const e=this.getViewer(),i=this.relativeCoords(t),r=i.x,s=i.y,a=Math.abs(r-this.mouseDownPosition.x)<5&&Math.abs(s-this.mouseDownPosition.y)<5;if(e&&e.getEnableAutoSelect()&&a){e.unselect(),e.select(r,s,r,s),this.subject.update();const t=e.getSelected(),i=this.subject.getSelected();this.onmessage({type:"select",data:t,handles:i})}}dblclick(t){const e=this.getViewer(),i=this.relativeCoords(t),r=i.x,s=i.y,a=e.getActiveDevice(),n=a.viewAt([r,s]);if(n&&!n.active)e.activeView=n,n.delete(),this.subject.update();else if(e&&e.getEnableAutoSelect()){const t=e.getSelected();if(!t.isNull()&&0!==t.numItems()){const i=t.getIterator(),r=i.getEntity();e.zoomToEntity(r),this.onmessage({type:"zoomtoentity",data:r}),this.subject.update(),this.deleteAll([i,r])}}a.delete()}start(t,e,i=0,r=0){}drag(t,e,i=0,r=0){}end(t,e){}getActiveMarkupEntity(t){return this.subject.addMarkupEntity(t)}syncOverlayView(){return this.subject.syncOverlay()}deleteAll(t){var e;for(const i of t)null===(e=null==i?void 0:i.delete)||void 0===e||e.call(i)}updatePreview(){}static set isGestureActive(t){h._isGestureActive!==t&&(h._isGestureActive=t,h._isGestureActive&&(h.needSkipPointerUp=!0))}static get isGestureActive(){return h._isGestureActive}static get needSkipPointerUp(){return!!h._needSkipPointerUp&&(h.needSkipPointerUp=!1,!0)}static set needSkipPointerUp(t){h._needSkipPointerUp=t}}function l(t,e,i){return t||((t=document.createElement("div")).setAttribute("data-testid",i),e.appendChild(t)),t}function d(t,e){return t&&e.removeChild(t),null}function c(t,e,i){const r=e.Point3d.createFromArray(t),s=i.activeView,a=s.worldToDeviceMatrix,n=r.transformBy(a),o={x:n.x/window.devicePixelRatio,y:n.y/window.devicePixelRatio};return a.delete(),r.delete(),n.delete(),s.delete(),o}function u(t){return t<0?Math.ceil(t):Math.floor(t)}h._isGestureActive=!1,h._needSkipPointerUp=!1;const g=(t,e,i,r)=>{const s=e.x-t.x,a=e.y-t.y,n=r.x-i.x,o=r.y-i.y,h=(-a*(t.x-i.x)+s*(t.y-i.y))/(-n*a+s*o),l=(+n*(t.y-i.y)-o*(t.x-i.x))/(-n*a+s*o);return h>=0&&h<=1&&l>=0&&l<=1&&{x:u(t.x+l*s),y:u(t.y+l*a)}};function p(t,e,i,r,s){const a=g(t,e,i,r);a&&s.push(a)}function m(t,e,i){return t.x<=e&&t.x>=0&&t.y<=i&&t.y>=0}function f(t,e){t&&(t.onclick=e?()=>e():()=>{})}function v(t,e){t.style.pointerEvents=e?"auto":"none"}class _{constructor(t,e,i){this.htmlElemStartPoint=null,this.htmlElemEndPoint=null,this.htmlElemLine=null,this.htmlElemTitle=null,this.startPoint=null,this.endPoint=null,this.unit="",this.scale=1,this.size=10,this.lineThickness=2,this.style={border:"2px solid #FFFFFF",background:"#009bff",color:"white",boxShadow:"0 0 10px rgba(0,0,0,0.5)"},this.htmlElemStartPoint=l(this.htmlElemStartPoint,t,"ruler-start"),this.htmlElemEndPoint=l(this.htmlElemEndPoint,t,"ruler-end"),this.htmlElemLine=l(this.htmlElemLine,t,"ruler-line"),this.htmlElemTitle=l(this.htmlElemTitle,t,"ruler-value"),this.viewer=e,this.moduleInstance=i,this.targetElement=t,this.isFinishDraw=!1}drawMeasureLine(){const t=this.size,e=this.moduleInstance.canvas.getBoundingClientRect();if(this.startPoint){this.htmlElemStartPoint=l(this.htmlElemStartPoint,this.targetElement,"ruler-start");const i=c(this.startPoint,this.moduleInstance,this.viewer);m(i,e.width,e.height)?(this.htmlElemStartPoint.style.display="block",this.htmlElemStartPoint.style.cursor="pointer",this.htmlElemStartPoint.style.position="absolute",this.htmlElemStartPoint.style.top=i.y-t/2+"px",this.htmlElemStartPoint.style.left=i.x-t/2+"px",this.htmlElemStartPoint.style.borderRadius=`${t}px`,this.htmlElemStartPoint.style.border=this.style.border,this.htmlElemStartPoint.style.background=this.style.background,this.htmlElemStartPoint.style.zIndex="2",this.htmlElemStartPoint.style.width=`${t}px`,this.htmlElemStartPoint.style.height=`${t}px`,this.htmlElemStartPoint.style.boxShadow=this.style.boxShadow):this.htmlElemStartPoint.style.display="none"}if(this.endPoint&&this.isFinishDraw){this.htmlElemEndPoint=l(this.htmlElemEndPoint,this.targetElement,"ruler-end");const i=c(this.endPoint,this.moduleInstance,this.viewer);m(i,e.width,e.height)?(this.htmlElemEndPoint.style.display="block",this.htmlElemEndPoint.style.cursor="pointer",this.htmlElemEndPoint.style.position="absolute",this.htmlElemEndPoint.style.top=i.y-t/2+"px",this.htmlElemEndPoint.style.left=i.x-t/2+"px",this.htmlElemEndPoint.style.borderRadius=`${t}px`,this.htmlElemEndPoint.style.border=this.style.border,this.htmlElemEndPoint.style.background=this.style.background,this.htmlElemEndPoint.style.zIndex="2",this.htmlElemEndPoint.style.width=`${t}px`,this.htmlElemEndPoint.style.height=`${t}px`,this.htmlElemEndPoint.style.boxShadow=this.style.boxShadow):this.htmlElemEndPoint.style.display="none"}if(this.endPoint&&this.startPoint){const t=c(this.startPoint,this.moduleInstance,this.viewer),i=c(this.endPoint,this.moduleInstance,this.viewer),{p1:r,p2:s,angle:a,width:n}=function(t,e,i,r){const s={x:0,y:0},a={x:i,y:0},n={x:0,y:r},o={x:i,y:r},h=[];p(t,e,s,a,h),p(t,e,s,n,h),p(t,e,n,o,h),p(t,e,o,a,h);let l=null,d=null;0===h.length?(l=t,d=e):1===h.length?m(t,i,r)?(l=t,d=h[0]):(l=h[0],d=e):(l=h[0],d=h[1]);const c=d.x-l.x,u=d.y-l.y;let g=180*Math.atan(u/c)/Math.PI;return c<0&&(g-=180),{angle:g,width:Math.sqrt(Math.pow(c,2)+Math.pow(u,2)),p1:l,p2:d}}(t,i,e.width,e.height),o=s.x-r.x,h=s.y-r.y,d=this.lineThickness;if(m(r,e.width,e.height)&&m(s,e.width,e.height)){this.htmlElemLine=l(this.htmlElemLine,this.targetElement,"ruler-line"),this.htmlElemLine.style.display="block",this.htmlElemLine.style.cursor="pointer",this.htmlElemLine.style.position="absolute",this.htmlElemLine.style.top=`${r.y}px`,this.htmlElemLine.style.left=`${r.x}px`,this.htmlElemLine.style.width=`${n}px`,this.htmlElemLine.style.transform=`rotate(${a}deg)`,this.htmlElemLine.style.transformOrigin=`0px ${d/2}px`,this.htmlElemLine.style.boxShadow=this.style.boxShadow,this.htmlElemLine.style.border="none",this.htmlElemLine.style.background=this.style.background,this.htmlElemLine.style.zIndex="1",this.htmlElemLine.style.height=`${d}px`;const t=`${this.getDistance()} ${this.unit}`,e=r.x+o/2,i=r.y+h/2,s=10*t.length;this.htmlElemTitle=l(this.htmlElemTitle,this.targetElement,"ruler-value"),this.htmlElemTitle.style.display="block",this.htmlElemTitle.style.cursor="pointer",this.htmlElemTitle.style.font="10px",this.htmlElemTitle.style.color="white",this.htmlElemTitle.style.position="Absolute",this.htmlElemTitle.style.top=`${i}px`,this.htmlElemTitle.style.left=e-s/2+"px",this.htmlElemTitle.style.width=`${s}px`,this.htmlElemTitle.style.transformOrigin="0px 0px",this.htmlElemTitle.style.borderRadius="5px",this.htmlElemTitle.style.boxShadow=this.style.boxShadow,this.htmlElemTitle.style.border="none",this.htmlElemTitle.style.background=this.style.background,this.htmlElemTitle.style.zIndex="3",this.htmlElemTitle.style.padding="2px",this.htmlElemTitle.style.textAlign="center",this.htmlElemTitle.innerHTML=`${t}`}else this.htmlElemLine.style.display="none",this.htmlElemTitle.style.display="none"}}getDistance(){return function(t,e,i){const r=i.Point3d.createFromArray(t),s=i.Point3d.createFromArray(e),a=r.distanceTo(s).toFixed(2);return r.delete(),s.delete(),a}(this.startPoint,this.endPoint,this.moduleInstance)/this.scale}setStartPoint(t){this.startPoint=t,this.drawMeasureLine()}setEndPoint(t,e){this.isFinishDraw=void 0===e||e,this.endPoint=t,this.drawMeasureLine()}update(){this.drawMeasureLine()}setSize(t){this.size=t,this.drawMeasureLine()}clear(){this.endPoint=null,this.startPoint=null,this.htmlElemStartPoint=d(this.htmlElemStartPoint,this.targetElement),this.htmlElemEndPoint=d(this.htmlElemEndPoint,this.targetElement),this.htmlElemLine=d(this.htmlElemLine,this.targetElement),this.htmlElemTitle=d(this.htmlElemTitle,this.targetElement)}setUnit(t){this.unit=t,this.drawMeasureLine()}setConversionFactor(t){this.scale=t,this.drawMeasureLine()}setStyle(t){this.style=t,this.drawMeasureLine()}setSelectionReactor(t){f(this.htmlElemStartPoint,t?t.onStartPoint:null),f(this.htmlElemEndPoint,t?t.onEndPoint:null),f(this.htmlElemTitle,t?t.onTitle:null)}setSelectability(t){v(this.htmlElemStartPoint,t),v(this.htmlElemEndPoint,t),v(this.htmlElemLine,t),v(this.htmlElemTitle,t)}}class y extends h{constructor(t){super(t),this.lineThickness=2,this.press=!1,this.gripingRadius=5,this.firstPoint=null,this.secondPoint=null,this.renameUnitTable={Millimeters:"mm",Centimeters:"cm",Meters:"m",Feet:"ft",Inches:"in",Yards:"yd",Kilometers:"km",Miles:"mi",Micrometers:"µm",MicroInches:"µin",Undefined:" "},this.items=[],this.canvasEvents.push("resize")}initialize(){super.initialize(),this.m_overlayElement=document.createElement("div"),this.m_overlayElement.style.background="rgba(0,0,0,0)",this.m_overlayElement.style.position="fixed",this.m_overlayElement.style.zIndex="1",this.m_overlayElement.style.pointerEvents="none",document.body.appendChild(this.m_overlayElement),this.resize()}dispose(){super.dispose(),this.m_overlayElement.remove()}updatePreview(){this.items.forEach((t=>t.update()))}resize(){const t=this.m_module.canvas.getBoundingClientRect();this.m_overlayElement.style.top=`${t.top}px`,this.m_overlayElement.style.left=`${t.left}px`,this.m_overlayElement.style.width=`${t.width}px`,this.m_overlayElement.style.height=`${t.height}px`}getSnapPointRadius(){const t=this.getViewer().activeView.viewDcCorners(),e=t.lowerLeft,i=t.upperRight;return i[0]-=e[0],i[1]-=e[1],Math.min(i[0],i[1])/120}drag(t,e){this.createNewMeasureIfNeed();const i=this.getViewer().getSnapPoint(t,e,this.gripingRadius);this.isDragging?i?this.firstPoint?(this.secondPoint=i,this.previewMeasureLine.setStartPoint(this.firstPoint),this.previewMeasureLine.setEndPoint(this.secondPoint,!0)):(this.firstPoint=i,this.previewMeasureLine.setStartPoint(this.firstPoint)):(this.secondPoint=null,this.previewMeasureLine.clear(),this.previewMeasureLine.setStartPoint(this.firstPoint),this.previewMeasureLine.setEndPoint(this.getViewer().screenToWorld(t,e),!1)):i?this.previewMeasureLine.setStartPoint(i):this.previewMeasureLine.clear()}end(){if(this.firstPoint&&this.secondPoint){const t=this.createMeasureLine();t.setStartPoint(this.firstPoint),t.setEndPoint(this.secondPoint,!0)}this.firstPoint=null,this.secondPoint=null,this.previewMeasureLine.clear()}createNewMeasureIfNeed(){this.previewMeasureLine||(this.previewMeasureLine=this.createMeasureLine())}createMeasureLine(){const t=this.m_module.getViewer(),e=new _(this.m_overlayElement,t,this.m_module);var i,r;return e.lineThickness=this.lineThickness||e.lineThickness,e.setUnit((i=this.renameUnitTable,r=t.getUnit(),i[r]||r)),this.items.push(e),e}}class w extends h{constructor(t){super(t),this.viewer=void 0,this.multiplier=5,this.speed=1,this.keyPressMap=new Set,this.keydown=this.keydown.bind(this),this.keyup=this.keyup.bind(this),this.lastFrameTS=0,this.animationId=void 0,this.processMovement=this.processMovement.bind(this),this.deltaAngle=Math.PI/3600,this.autoSelect=!0}initialize(){super.initialize(),this.viewer=this.getViewer(),window.addEventListener("keydown",this.keydown,!1),window.addEventListener("keyup",this.keyup,!1),this.oldWCSEnableValue=this.viewer.getEnableWCS(),this.viewer.setEnableWCS(!1);const t=this.viewer.activeView,e=this.getMaxDimension(t);this.speed=e/3e4,this.subject.emitEvent({type:"walkstart"}),this.viewParams=this.getViewParams(),this.setViewParams(this.viewParams);const i=this.viewer.getActiveModel();this.cameraId=i.appendCamera("Camera0"),this.setupCamera(t),i.delete(),this.cameraWalker=new this.m_module.OdTvCameraWalker,this.cameraWalker.setCamera(this.cameraId),this.subject.update(),this.enableZoomWheelPreviousValue=this.subject.options.enableZoomWheel,this.subject.options.enableZoomWheel=!1}dispose(){var t;if(this.oldWCSEnableValue=void 0!==this.oldWCSEnableValue?this.oldWCSEnableValue:this.subject.options.showWCS,this.viewer.setEnableWCS(this.oldWCSEnableValue),super.dispose(),this.keyPressMap.clear(),window.removeEventListener("keydown",this.keydown),window.removeEventListener("keyup",this.keyup),this.animationId&&(window.cancelAnimationFrame(this.animationId),this.animationId=void 0),this.cameraId){const e=this.viewer.getActiveModel();e.removeEntity(this.cameraId),e.delete(),null===(t=this.cameraWalker)||void 0===t||t.delete()}if(this.viewParams){this.setViewParams(this.viewParams);this.viewer.activeView.delete()}this.subject.update(),this.subject.options.enableZoomWheel=this.enableZoomWheelPreviousValue}keydown(t){switch(t.code){case"NumpadSubtract":case"Minus":this.multiplier>1&&(this.multiplier=this.multiplier-1,this.subject.emitEvent({type:"walkspeedchange",data:this.multiplier}));break;case"NumpadAdd":case"Equal":this.multiplier<10&&(this.multiplier=this.multiplier+1,this.subject.emitEvent({type:"walkspeedchange",data:this.multiplier}));break;case"KeyW":case"KeyA":case"KeyS":case"KeyD":case"KeyQ":case"KeyE":this.keyPressMap.add(t.code),this.animationId||this.processMovement(0)}}keyup(t){this.keyPressMap.delete(t.code),this.keyPressMap.size<1&&this.animationId&&(window.cancelAnimationFrame(this.animationId),this.animationId=void 0,this.lastFrameTS=0)}processMovement(t){if(this.animationId=requestAnimationFrame(this.processMovement),0!==this.lastFrameTS){const e=t-this.lastFrameTS,i=this.multiplier*e*this.speed;for(const t of this.keyPressMap)switch(t){case"KeyW":this.cameraWalker.moveForward(i);break;case"KeyS":this.cameraWalker.moveBackward(i);break;case"KeyA":this.cameraWalker.moveLeft(i);break;case"KeyD":this.cameraWalker.moveRight(i);break;case"KeyQ":this.cameraWalker.moveUp(i);break;case"KeyE":this.cameraWalker.moveDown(i)}this.subject.update()}this.lastFrameTS=t}drag(t,e,i,r){this.cameraId&&this.isDragging&&(0!==i&&this.turnLeft(-i*this.deltaAngle),0!==r&&this.cameraWalker.turnDown(r*this.deltaAngle),this.subject.update())}turnLeft(t){const e=this.cameraWalker.camera().openObjectAsCamera(),i=this.toVector(e.direction()),r=this.toVector(e.upVector()),s=e.position(),a=this.createMatrix3d();a.setToRotation(t,[0,0,1],s),i.transformBy(a),r.transformBy(a),e.setupCameraByDirection(s,i.toArray(),r.toArray()),e.delete()}setupCamera(t){const e=this.cameraId.openObjectAsCamera(),i=t.viewTarget;e.setDisplayGlyph(!1),e.setDisplayTarget(!1),e.setAutoAdjust(!0),e.setupCamera(t.viewPosition,i,t.upVector),e.setNearClip(!1,1),e.setFarClip(!1,0),e.setViewParameters(t.viewFieldWidth,t.viewFieldHeight,!0);const r=(s=t.lensLength,a=t.viewFieldWidth,n=t.viewFieldHeight,s/42*Math.sqrt(a*a+n*n));var s,a,n;const o=this.toPoint(t.viewTarget),h=this.toPoint(t.viewPosition),l=h.sub(o),d=l.asVector(),c=d.normalize(),u=this.toGeVector(c),g=[u[0]*r,u[1]*r,u[2]*r],p=this.toPoint(t.viewTarget),m=this.toPoint(g),f=p.add(m);e.setupCamera(this.toGePoint(f),t.viewTarget,t.upVector),this.deleteAll([o,h,l,d,c,p,m,f]),e.assignView(t),e.delete()}getMaxDimension(t){const[e,i,r]=t.sceneExtents.max(),[s,a,n]=t.sceneExtents.min(),o=[e-s,i-a,r-n];return Math.max(...o)}}class b extends h{constructor(t){super(t),this.press=!1;const e=this.getViewer().getActiveExtents(),i=e.min(),r=e.max();this.m_size_x=Math.abs(r[0]-i[0])/2,this.m_size_y=Math.abs(r[1]-i[1])/2,this.m_size_z=Math.abs(r[2]-i[2])/2,this.m_center=this.toPoint(e.center()),this.m_normal=this.createNormal();const s=this.getViewer().activeView,a=this.createPlane();a.set(this.toGePoint(this.m_center),this.m_normal),s.addCuttingPlane(a),this.index=s.numCuttingPlanes()-1;const{red:n,green:o,blue:h}=this.subject.options.cuttingPlaneFillColor;s.setEnableCuttingPlaneFill(!0,n,o,h),s.setCuttingPlaneFillPatternEnabled(!0,this.m_module.CuttingPlaneFillStyle.kHorizontalBars,0,0,0),this.m_model=this.getModel(),this.createPreview(),this.deleteAll([e,s,a])}dispose(){super.dispose(),this.m_entity&&(this.m_model.removeEntity(this.m_entity),this.deleteAll([this.m_model,this.m_entity,this.planePreview,this.m_center]),this.m_entity=null,this.planePreview=null,this.subject.update())}createNormal(){return[0,0,0]}handleDelta(t){return t}getPlanePreviewCoordinate(){return[]}start(t,e){this.press=!0,this.m_last=this.screenToWorld(t,e),this.m_click={x:t,y:e}}drag(t,e){if(this.press){const i=this.screenToWorld(t,e),r=this.handleDelta(i.sub(this.m_last)),s=this.m_center;this.m_center=s.add(r);const a=this.m_last;this.m_last=i;const n=this.getViewer().activeView,o=this.createPlane(),h=o.set(this.toGePoint(this.m_center),this.m_normal),l=n.updateCuttingPlane(this.index,o);this.drawPreview(),this.deleteAll([n,o,s,r,a,h,l]);const d=this.getViewer().getActiveDevice();d.invalidate(d.getSize())}}end(t,e){if(this.press=!1,t===this.m_click.x&&e===this.m_click.y){this.m_normal=[-1*this.m_normal[0],-1*this.m_normal[1],-1*this.m_normal[2]];const t=this.getViewer().activeView,e=this.createPlane();e.set(this.toGePoint(this.m_center),this.m_normal),t.updateCuttingPlane(this.index,e),this.deleteAll([t,e,this.m_last]);const i=this.getViewer().getActiveDevice();i.invalidate(i.getSize())}}createPreview(){this.m_entity=this.m_model.appendEntity("&CuttingPlanePreview");const t=this.m_module.GeometryTypes,e=new this.m_module.OdTvTransparencyDef,i=new this.m_module.OdTvColorDef(112,112,112);e.setValue(.9);const r=this.m_entity.openObject();r.setColor(i,t.kFaces.value),i.setColor(112,112,112),r.setColor(i,t.kEdges.value),r.setLineWeight(5),r.setTransparency(e,t.kFaces),e.setValue(1),r.setTransparency(e,t.kEdges),this.planePreview=r.appendPolygon(this.getPlanePreviewCoordinate());const s=this.planePreview.openAsPolygon();s.setFilled(!0),this.deleteAll([e,i,r,s,t]),this.subject.syncOverlay()}drawPreview(){const t=this.planePreview.openAsPolygon();t.setPoints(this.getPlanePreviewCoordinate()),this.deleteAll([t]),this.subject.syncOverlay()}}class x extends b{createNormal(){return[1,0,0]}handleDelta(t){return t.y=0,t.z=0,t}getPlanePreviewCoordinate(){return[this.m_center.x,this.m_center.y-this.m_size_y,this.m_center.z-this.m_size_z,this.m_center.x,this.m_center.y+this.m_size_y,this.m_center.z-this.m_size_z,this.m_center.x,this.m_center.y+this.m_size_y,this.m_center.z+this.m_size_z,this.m_center.x,this.m_center.y-this.m_size_y,this.m_center.z+this.m_size_z]}}class S extends b{createNormal(){return[0,1,0]}handleDelta(t){return t.x=0,t.z=0,t}getPlanePreviewCoordinate(){return[this.m_center.x-this.m_size_x,this.m_center.y,this.m_center.z-this.m_size_z,this.m_center.x+this.m_size_x,this.m_center.y,this.m_center.z-this.m_size_z,this.m_center.x+this.m_size_x,this.m_center.y,this.m_center.z+this.m_size_z,this.m_center.x-this.m_size_x,this.m_center.y,this.m_center.z+this.m_size_z]}}class C extends b{createNormal(){return[0,0,1]}handleDelta(t){return t.x=0,t.y=0,t}getPlanePreviewCoordinate(){return[this.m_center.x-this.m_size_x,this.m_center.y-this.m_size_y,this.m_center.z,this.m_center.x+this.m_size_x,this.m_center.y-this.m_size_y,this.m_center.z,this.m_center.x+this.m_size_x,this.m_center.y+this.m_size_y,this.m_center.z,this.m_center.x-this.m_size_x,this.m_center.y+this.m_size_y,this.m_center.z]}}class P{constructor(t,e,i,r){this._m_module=t,this._subject=e,this._beginInteractivity=i,this._endInteractivity=r}beginAction(t,e){this.m_viewCenter=this.getCenter(),this.m_startPoint={x:t,y:e};this.getViewer().activeView.delete(),this._beginInteractivity()}action(t,e){var i;const r=this.getViewer().activeView,s=r.vportRect,a=Math.max(Math.abs(s[2]-s[0]),Math.abs(s[3]-s[1])),n=(this.m_startPoint.x-t)*Math.PI/a,o=(this.m_startPoint.y-e)*Math.PI/a;this.m_startPoint.x=t,this.m_startPoint.y=e;const h=o,l=n,d={position:r.viewPosition,target:r.viewTarget,upVector:r.upVector,viewFieldWidth:r.viewFieldWidth,viewFieldHeight:r.viewFieldHeight,perspective:r.perspective};r.delete();const c=this.getSideVector(d);0!==h&&this.calculateXOrbit(d,-h,c),0!==l&&this.calculateYOrbit(d,l,c),c.delete();const u=this.getViewer().getActiveTvExtendedView();u.setView(d.position,d.target,d.upVector,d.viewFieldWidth,d.viewFieldHeight,d.perspective),u.delete(),null===(i=this._subject.activeDragger())||void 0===i||i.updatePreview()}endAction(){this._endInteractivity()}getSideVector(t){const e=this.toVector(t.upVector),i=this.toPoint(t.target),r=this.toPoint(t.position),s=i.sub(r),a=s.asVector(),n=e.crossProduct(a),o=n.normalize();return this.deleteAll([s,e,i,r,a,n]),o}calculateXOrbit(t,e,i){{const r=this.toPoint(t.position),s=this.toPoint(this.m_viewCenter),a=r.rotateByBasePoint(e,i,s);t.position=a.toArray(),this.deleteAll([r,s,a])}{const r=this.toPoint(t.target),s=this.toPoint(this.m_viewCenter),a=r.rotateByBasePoint(e,i,s);t.target=a.toArray(),this.deleteAll([r,s,a])}{const e=this.toPoint(t.position),r=this.toPoint(t.target),s=this.toPoint(this.m_viewCenter),a=r.sub(e),n=a.asVector(),o=n.crossProduct(i),h=o.normalize();t.upVector=h.toArray(),this.deleteAll([e,r,s,a,n,o,h])}}calculateYOrbit(t,e,i){{const i=this.toPoint(t.position),r=this.toPoint(this.m_viewCenter),s=this.toVector(this._m_module.Vector3d.kZAxis),a=i.rotateByBasePoint(e,s,r);t.position=a.toArray(),this.deleteAll([s,i,r,a])}{const i=this.toPoint(t.target),r=this.toPoint(this.m_viewCenter),s=this.toVector(this._m_module.Vector3d.kZAxis),a=i.rotateByBasePoint(e,s,r);t.target=a.toArray(),this.deleteAll([s,i,r,a])}{const r=this.toVector(this._m_module.Vector3d.kZAxis),s=this.toPoint(t.target),a=this.toPoint(t.position),n=i.rotateBy(e,r),o=s.sub(a),h=o.asVector(),l=h.crossProduct(n),d=l.normalize();t.upVector=d.toArray(),this.deleteAll([r,s,a,n,o,h,l,d])}}getCenter(){const t=this.getViewer();let e;const i=t.getSelected();if(i.isNull()||0===i.numItems())e=t.getActiveExtents().center();else{const t=i.getIterator();let r,s,a;for(;!t.done();t.step())s=t.getEntity(),r=s.getWCSExtents(),a?a.addExt(r):a=r;e=a.center(),a.delete(),t.delete()}return e}getViewer(){return this._m_module.getViewer()}toVector(t){return this._m_module.Vector3d.createFromArray(t)}toPoint(t){return this._m_module.Point3d.createFromArray(t)}deleteAll(t){var e;for(const i of t)null===(e=null==i?void 0:i.delete)||void 0===e||e.call(i)}}class k extends h{constructor(t){super(t),this.autoSelect=!0,this.press=!1,this._orbitAction=new P(this.m_module,this.subject,this.beginInteractivity,this.endInteractivity)}start(t,e){this.press=!0,this._orbitAction.beginAction(t,e)}setDefaultViewParams(){const t=this.getViewer().getActiveTvExtendedView();t.setView(this.startCameraParams.position,this.startCameraParams.target,this.startCameraParams.upVector,this.startCameraParams.viewFieldWidth,this.startCameraParams.viewFieldHeight,this.startCameraParams.perspective),t.delete()}drag(t,e,i,r){this.press&&this._orbitAction.action(t,e)}end(){this.press=!1,this._orbitAction.endAction()}}class E{constructor(t,e,i,r,s,a){this._m_module=t,this._subject=e,this._beginInteractivity=i,this._endInteractivity=r,this._getViewParams=s,this._setViewParams=a}beginAction(t,e){this._m_start=this.screenToWorld(t,e),this._deltaScreenPosition={x:t,y:e},this._beginInteractivity()}action(t,e){var i;const{Vector3d:r}=this._m_module,s=this._getViewParams(),a=this.screenToWorld(t,e),n=this._m_start.sub(a).asVector(),o=r.createFromArray(s.target),h=o.add(n);s.target=h.toArray();const l=r.createFromArray(s.position),d=l.add(n);s.position=d.toArray(),this._setViewParams(s),o.delete(),h.delete(),l.delete(),d.delete(),null===(i=this._subject.activeDragger())||void 0===i||i.updatePreview(),this._subject.emitEvent({type:"pan",x:t,y:e,dX:t-this._deltaScreenPosition.x,dY:e-this._deltaScreenPosition.y}),this._deltaScreenPosition={x:t,y:e}}endAction(){this._endInteractivity()}screenToWorld(t,e){return this._m_module.Point3d.createFromArray(this._m_module.getViewer().screenToWorld(t,e))}}class A extends h{constructor(t){super(t),this.autoSelect=!0,this.press=!1,this._panAction=new E(this.m_module,this.subject,this.beginInteractivity,this.endInteractivity,this.getViewParams,this.setViewParams)}start(t,e){this.press=!0,this._panAction.beginAction(t,e)}drag(t,e,i,r){this.press&&this._panAction.action(t,e)}end(t,e){this.press=!1,this._panAction.endAction()}}class T{constructor(t,e){this._m_module=t,this._subject=e}action(t,e,i){var r;this._m_module.getViewer().zoomAt(i,t,e),null===(r=this._subject.activeDragger())||void 0===r||r.updatePreview(),this._subject.emitEvent({type:"zoomat",data:i})}}class M extends h{constructor(t){super(t),this.autoSelect=!0,this.press=!1,this._zoomAction=new T(this.m_module,this.subject)}start(t,e){this.press=!0,this.pressX=t,this.pressY=e,this.beginInteractivity()}drag(t,e,i,r){if(this.press){const t=.025,e=r>0?1+t:1-t;this._zoomAction.action(this.pressX,this.pressY,e)}}end(){this.press=!1,this.endInteractivity()}}class F extends h{constructor(t){super(t),this.canvasEvents=["wheel"],this._zoomAction=new T(this.m_module,this.subject),this._endInteractivityTimeOutId=void 0,this._isEnableInteractivityMode=!1}wheel(t){if(!this.subject.options.enableZoomWheel)return;(t=t||window.event).preventDefault();const e=.075*(this.subject.options.reverseZoomWheel?-1:1);if(this.getViewer()){const i=t.deltaY>0?1+e:1-e;this._zoomAction.action(t.offsetX*window.devicePixelRatio,t.offsetY*window.devicePixelRatio,i),this._isEnableInteractivityMode||(this._isEnableInteractivityMode=!0,this.beginInteractivity()),this._endInteractivityTimeOutId&&clearTimeout(this._endInteractivityTimeOutId),this._isEnableInteractivityMode||(this._isEnableInteractivityMode=!0,this.beginInteractivity()),this._endInteractivityTimeOutId&&clearTimeout(this._endInteractivityTimeOutId),this.subject.update(!0),this._endInteractivityTimeOutId=setTimeout((()=>{this._endInteractivityTimeOutId=void 0,this.endInteractivity(),this._isEnableInteractivityMode=!1}),100)}}dispose(){this._endInteractivityTimeOutId&&(clearTimeout(this._endInteractivityTimeOutId),this.endInteractivity(),this._isEnableInteractivityMode=!1)}}class O{constructor(){this.m_start=[0,0,0],this.m_end=[0,0,0],this.m_model=null}createPoint3d(){return new this.m_module.Point3d}init(t,e){this.m_module=t,this.m_model=e}getViewer(){return this.m_module.getViewer()}setValue(t){this.m_end=t,this.draw()}setStartPoint(t){this.m_start=t,this.m_end=t,this.draw()}toDoubleArray(t){const e=[];for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y),e.push(t[i].z);return e}draw(){const t=this.getViewer().activeView,e=t.viewingMatrix,i=[];i.push(this.m_start),i.push(this.createPoint3d()),i.push(this.m_end),i.push(this.createPoint3d());const r=this.createPoint3d();r.set(this.m_start[0],this.m_start[1],this.m_start[2]);const s=this.createPoint3d();s.set(this.m_end[0],this.m_end[1],this.m_end[2]),r.transformBy(e),s.transformBy(e),i[1].x=r.x,i[3].x=s.x,i[1].y=s.y,i[3].y=r.y,i[1].z=i[3].z=s.z;const a=t.eyeToWorldMatrix;if(i[1].transformBy(a),i[3].transformBy(a),this.m_entity)this.m_frame.openAsPolygon().setPoints(this.toDoubleArray(i));else{this.m_entity=this.m_model.appendEntity("");const t=this.m_entity.openObject();t.setColor(112,112,112),t.setLineWeight(2),this.m_frame=t.appendPolygon(this.toDoubleArray(i)),t.delete()}}clear(){this.m_entity&&(this.m_model.removeEntity(this.m_entity),this.m_entity=null)}}class R extends h{constructor(t){super(t),this.autoSelect=!0,this.press=!1,this.needInputText=!1,this.m_frame=new O,this.m_frame.init(this.m_module,this.getModel())}start(t,e){this.press=!0,this.m_minX=t,this.m_minY=e;const i=this.screenToWorld(t,e);this.m_frame.setStartPoint(i)}drag(t,e,i,r){if(this.press){this.m_maxX=t,this.m_maxY=e;const i=this.screenToWorld(t,e);this.m_frame.setValue(i)}}end(t,e){this.press=!1,this.m_maxX=t,this.m_maxY=e,this.m_minX!==this.m_maxX&&this.m_minY!==this.m_maxY&&(this.m_frame.clear(),this.getViewer().zoomWindow(this.m_minX,this.m_minY,this.m_maxX,this.m_maxY))}}class I extends h{constructor(t){super(t),this.autoSelect=!0,this.press=!1,this.maxPolarAngle=Math.PI/2,this.minPolarAngle=0}start(t,e){this.press=!0,this.m_viewCenter=this.getCenter(),this.m_startPoint={x:t,y:e};const i=this.getViewer().activeView;this.startCameraParams=this.getViewParams();const r=i.vportRect;this.m_delta=Math.max(r[1]-r[0],r[2]-r[3]),this.beginInteractivity()}setDefaultViewParams(){this.setViewParams(this.startCameraParams)}drag(t,e,i,r){if(this.press){let i=t-this.m_startPoint.x,r=e-this.m_startPoint.y;i*=Math.PI/this.m_delta,r*=Math.PI/this.m_delta,this.setDefaultViewParams();const{Vector3d:s,Matrix3d:a}=this.m_module,n=s.createFromArray(this.startCameraParams.target),o=s.createFromArray(this.startCameraParams.position).sub(n),h=o.normalize(),l=new a;l.setToIdentity();const d=new a;d.setToIdentity();const c=s.createFromArray([h.x,h.y,h.z]),u=s.createFromArray(this.startCameraParams.upVector),g=c.crossProduct(u);let p=s.createFromArray([c.x,c.y,0]);p.length()<=1e-5?p.set(-g.y,g.x,0):p=p.normalize();i-=Math.sign(p.dotProduct(s.createFromArray([-1,0,0])))*p.angleTo(s.createFromArray([0,1,0]));let m=s.createFromArray([h.x,h.y,0]),f=0;m.length()<=1e-5?f=-h.z*Math.PI/2:(m=m.normalize(),f=-m.angleTo(h)),r-=f,l.setToRotation(-i,[0,0,1],[0,0,0]);const v=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,r));d.setToRotation(v,[1,0,0],[0,0,0]);const _=l.postMultBy(d);let y=s.createFromArray([0,1,0]).transformBy(_);const w=s.createFromArray([0,0,1]).transformBy(_);y.setLength(o.length()),y=n.add(y);const b=this.getViewParams();b.position=y.toArray(),b.upVector=w.toArray(),this.setViewParams(b)}}end(){this.press=!1,this.endInteractivity()}getCenter(){const t=this.getViewer();let e=t.getActiveExtents();const i=t.getSelected();if(!i.isNull()&&0!==i.numItems()){const t=i.getIterator(),r=t.getEntity();if(1===r.getType()){const t=r.openObject();e.delete(),e=t.getExtents(),t.delete()}else if(2===r.getType()){const t=r.openObjectAsInsert(),i=t.getExtents();e.delete(),e=i.ext,i.delete(),t.delete()}t.delete()}const r=e.center();return e.delete(),r}}var D;!function(t){t[t.None=0]="None",t[t.Orbit=1]="Orbit",t[t.Pan=2]="Pan",t[t.Zoom=3]="Zoom"}(D||(D={}));class L extends h{get isSingleTouchEnabled(){return this._isSingleTouchEnabled}set isSingleTouchEnabled(t){this._isSingleTouchEnabled=t}constructor(t){super(t),this._previousEvents=new Map,this._currentEvents=new Map,this._lastGestureAction=D.None,this._maxInitialDistanceDifference=30*window.devicePixelRatio,this._isSingleTouchEnabled=!1,this._orbitAction=new P(this.m_module,this.subject,this.beginInteractivity,this.endInteractivity),this._panAction=new E(this.m_module,this.subject,this.beginInteractivity,this.endInteractivity,this.getViewParams,this.setViewParams),this._zoomAction=new T(this.m_module,this.subject)}getMiddlePoint(t){if(2!==t.size)return;const e=this.getKeys(t),i=this.relativeCoords(t.get(e[0])),r=this.relativeCoords(t.get(e[1]));return{x:Math.floor((i.x+r.x)/2),y:Math.floor((i.y+r.y)/2)}}getFirstPoint(t){if(t.size<1)return;const e=this.getKeys(t);return this.relativeCoords(t.get(e[0]))}getDistance(t){if(2!==t.size)return-1;const e=this.getKeys(t),i=this.relativeCoords(t.get(e[0])),r=this.relativeCoords(t.get(e[1]));return Math.hypot(i.x-r.x,i.y-r.y)}updateEvent(t){const e=!this._currentEvents.get(t.pointerId);if(e&&2===this._currentEvents.size)return;const i=this._currentEvents.get(t.pointerId);i&&this._previousEvents.set(i.pointerId,i),this._currentEvents.set(t.pointerId,t),e&&(this._initialDistance=this.getDistance(this._currentEvents))}removeEvent(t){this._currentEvents.delete(t.pointerId),this._previousEvents.delete(t.pointerId),this._currentEvents.size<2&&(this._initialDistance=-1)}getKeys(t){return Array.from(t.keys())}analyzeGesture(){if(2===this._currentEvents.size){const t=this.getDistance(this._currentEvents),e=this.getDistance(this._previousEvents);Math.abs(this._initialDistance-t)<=this._maxInitialDistanceDifference?this.executePanAction(this.getMiddlePoint(this._currentEvents)):-1!==e&&t!==e&&this.executeZoomAction(t,e)}else 1===this._currentEvents.size&&this.isSingleTouchEnabled&&this.executeOrbitAction(this.getFirstPoint(this._currentEvents))}executeZoomAction(t,e){this._lastGestureAction!==D.Zoom&&(this.executeEndAction(this._lastGestureAction),this._lastGestureAction=D.Zoom,h.isGestureActive=!0);const i=1+(t-e)/700,r=this.getMiddlePoint(this._currentEvents);this._zoomAction.action(r.x,r.y,i),this.subject.update()}executePanAction(t){this._lastGestureAction!==D.Pan&&(this.executeEndAction(this._lastGestureAction),this._lastGestureAction=D.Pan,h.isGestureActive=!0,this._panAction.beginAction(t.x,t.y)),this._panAction.action(t.x,t.y),this.subject.update()}executeOrbitAction(t){this._lastGestureAction!==D.Orbit&&(this.executeEndAction(this._lastGestureAction),this._lastGestureAction=D.Orbit,h.isGestureActive=!0,this._orbitAction.beginAction(t.x,t.y)),this._orbitAction.action(t.x,t.y),this.subject.update()}executeEndAction(t){t===D.Orbit&&this._orbitAction.endAction(),t===D.Pan&&this._panAction.endAction(),h.isGestureActive=!1}needIgnoreEvent(t){return!this.subject.options.enableZoomWheel||!this.subject.options.enableGestures||!this.eventIsTouchEvent(t)}eventIsTouchEvent(t){return"touch"===t.pointerType||""===t.pointerType}pointerdown(t){this.needIgnoreEvent(t)||this.updateEvent(t)}pointermove(t){this.needIgnoreEvent(t)||(this.updateEvent(t),this.analyzeGesture())}pointerup(t){this.needIgnoreEvent(t)||(this.removeEvent(t),this._currentEvents.size<2&&(this.executeEndAction(this._lastGestureAction),h.isGestureActive=!1),this._lastGestureAction=D.None)}pointercancel(t){this.needIgnoreEvent(t)||this.pointerup(t)}pointerleave(t){this.needIgnoreEvent(t)||this.pointerup(t)}}function V(t){if(window.getVisualizeLibInst){const e=window.getVisualizeLibInst.script;if(e){if(e.src===t)return Promise.resolve(e);e.remove()}delete window.getVisualizeLibInst}return function(t){return new Promise(((e,i)=>{const r=document.createElement("script");r.src=t,r.async=!0,r.onload=()=>e(r),r.onerror=()=>{r.remove(),i(new Error(`GET ${t} failed to load script`))},document.body.appendChild(r)}))}(t)}class G{constructor(t,e,i){this.viewer=t,this.model=e,this.options=i}async load(){}}class z extends G{async load(){if(!this.viewer.visualizeJs)return;const t=this.viewer.visLib().getViewer(),e=new AbortController,i=[this.model.database,...this.model.geometry],r=i.map((()=>0)),s=(t,e)=>{r[t]=e;const i=r.reduce(((t,e)=>t+e))/(r.length||1);this.viewer.emitEvent({type:"geometryprogress",data:i,model:this.model})};this.viewer._abortController=e;try{this.viewer.emitEvent({type:"geometrystart",model:this.model});for(let r=0;r<i.length;r++){const a=i[r],n=t=>s(r,t),o=await this.model.downloadResource(a,n,e.signal);e.signal.aborted&&await Promise.reject(new Error(`Open model aborted ${this.model.name}`)),t.parseStream(new Uint8Array(o)),this.viewer.update();const h=new Uint8Array(o);0===r?(this.viewer.update(!0),this.viewer.syncOpenCloudVisualStyle(!1),this.viewer.syncOptions(),this.viewer.resize(),this.viewer.emitEvent({type:"databasechunk",data:h,model:this.model})):this.viewer.emitEvent({type:"geometrychunk",data:h,model:this.model})}this.viewer.emitEvent({type:"geometryend",model:this.model})}catch(t){throw this.viewer.emitEvent({type:"geometryerror",data:t,model:this.model}),t}}}var N,U,W;!function(t){t[t.kDelay=0]="kDelay",t[t.kNormal=1]="kNormal",t[t.kForce=2]="kForce"}(N||(N={}));class j{constructor(){this.delayUpdateTime=1e3}initialize(t){this.viewer=t,this.lastUpdate=performance.now()}update(t){const e=t!==N.kDelay||performance.now()-this.lastUpdate>=this.delayUpdateTime,i=t===N.kForce;e&&(this.viewer.update(i),this.lastUpdate=performance.now(),this.delayUpdateTime*=2)}}class B extends G{async load(){if(!this.viewer.visualizeJs)return;const t=this.viewer.visLib(),e=t.getViewer(),i=new AbortController,r=new j;r.initialize(this.viewer),this.viewer._abortController=i;let s=!1;const a=(i,a)=>{if(!this.viewer.visualizeJs)return;const n=e.parseVsfx(a);r.update(N.kDelay),this.viewer.emitEvent({type:"geometryprogress",data:i,model:this.model});let o=!1;(n===t.DatabaseStreamStatus.ReadyServiceData||n===t.DatabaseStreamStatus.Complete&&!s)&&(s=!0,o=!0),o?(r.update(N.kForce),this.viewer.syncOpenCloudVisualStyle(!1),this.viewer.syncOptions(),this.viewer.resize(),this.viewer.emitEvent({type:"databasechunk",data:a,model:this.model})):this.viewer.emitEvent({type:"geometrychunk",data:a,model:this.model})};console.time("File load time");try{this.viewer.emitEvent({type:"geometrystart",model:this.model}),await this.model.partialDownloadResource(this.model.database,a,i.signal),console.timeEnd("File load time"),r.update(N.kNormal),this.viewer.emitEvent({type:"geometryend",model:this.model})}catch(t){throw this.viewer.emitEvent({type:"geometryerror",data:t,model:this.model}),t}}}class H extends G{async load(){if(!this.viewer.visualizeJs)return;const t=this.viewer.visLib().getViewer(),e=new AbortController,i=new Map;let r=!1;const s=new Map;let a=0;const n=()=>clearTimeout(a),o=new AbortController;i.set(0,o);const h=new j;h.initialize(this.viewer),this.viewer._abortController=e,this.viewer._abortControllerForRequestMap=i,t.memoryLimit=this.options.memoryLimit;const l=(e,i,r)=>{if(!this.viewer.visualizeJs)return;const s=t.parseVsfxInPartialMode(r,i);h.update(N.kDelay),this.viewer.emitEvent({type:"geometryprogress",data:e,model:this.model}),s?(h.update(N.kForce),this.viewer.syncOpenCloudVisualStyle(!1),this.viewer.syncOptions(),this.viewer.resize(),this.viewer.emitEvent({type:"databasechunk",data:i,model:this.model})):this.viewer.emitEvent({type:"geometrychunk",data:i,model:this.model})},d=async(e,r,s,a=!1)=>{const n=new AbortController;i.set(e,n);try{await this.model.downloadFileRange(e,r,s,l,n.signal)}catch(t){this.viewer.emitEvent({type:"geometryerror",data:t,model:this.model})}finally{(a?[...new Set(r.map((t=>t.reqId)))]:[e]).forEach((e=>t.onRequestResponseComplete(e))),i.delete(e),h.update(N.kNormal)}},c=(t,e)=>{const i=[];for(let r=0;r<e.size();r++){const s=e.get(r);i.push({reqId:t,begin:s.begin,end:s.end,size:parseInt(s.end,10)-parseInt(s.begin,10)}),s.delete()}return i},u={onServicePartReceived:t=>{t&&(r=!0,e.abort())},onRequest:(t,e)=>{d(t,e,this.model.database)},onFullLoaded:()=>{h.update(N.kNormal),console.timeEnd("File load time")},onRequestResponseParsed:t=>{i.delete(t),h.update(N.kNormal)},onRequestAborted:t=>{const e=i.get(t);e&&e.abort()},onRequestResourceFile:async(t,e,i)=>{const r=`${this.model.fileId}${this.model.file.type}`;let h=[],l=0;const u=s.get(r);if(u&&(h=u.array,l=u.number),l<6)return s.set(r,{array:h,number:l+1}),void await d(t,i,r);h.length>=50?(a&&(window.clearTimeout(a),a=0),d(t,h,r,!0),h=[...c(t,i)]):h=[...h,...c(t,i)],s.set(r,{array:h,number:l+1}),0===a&&(a=window.setTimeout((()=>{o.signal.removeEventListener("abort",n),a=0,s.forEach(((e,i)=>{const r=e.array;r.length>0&&(d(t,r,i,!0),s.set(i,{array:[],number:e.number+1}))}))}),250),o.signal.addEventListener("abort",n,{once:!0}))}};t.attachPartialResolver(u),console.time("File load time");try{this.viewer.emitEvent({type:"geometrystart",model:this.model}),await this.model.downloadFileRange(0,null,this.model.database,l,e.signal).catch((t=>{if(!r)throw t})),this.viewer.emitEvent({type:"geometryend",model:this.model})}catch(t){throw a&&(window.clearTimeout(a),a=0),this.viewer.emitEvent({type:"geometryerror",data:t,model:this.model}),t}}}class K extends G{async load(){if(!this.viewer.visualizeJs)return;const t=this.viewer.visLib().getViewer(),e=new AbortController;this.viewer._abortController=e,console.time("File load time");try{this.viewer.emitEvent({type:"geometrystart",model:this.model});const i=t=>this.viewer.emitEvent({type:"geometryprogress",data:t,model:this.model}),r=await this.model.downloadResource(this.model.database,i,e.signal);e.signal.aborted&&await Promise.reject(new Error(`Open model aborted ${this.model.name}`)),this.viewer.visualizeJs&&(t.parseVsfx(new Uint8Array(r)),this.viewer.update(!0),this.viewer.syncOpenCloudVisualStyle(!1),this.viewer.syncOptions(),this.viewer.resize()),console.timeEnd("File load time"),this.viewer.emitEvent({type:"geometryend",model:this.model})}catch(t){throw this.viewer.emitEvent({type:"geometryerror",data:t,model:this.model}),t}}}class Y{create(t,e,i){const r=e.database.split(".").pop();if(0===e.geometry.length&&"vsfx"===r)return i.enableStreamingMode?i.enablePartialMode?new H(t,e,i):new B(t,e,i):new K(t,e,i);if("data"===r)return new z(t,e,i);throw new Error(`Unknown geometry type: ${r}`)}}!function(t){t[t.Unknown=0]="Unknown",t.Konva="Konva",t.Visualize="Visualize"}(U||(U={})),function(t){t.Line="Line",t.Text="Text",t.Rectangle="Rectangle",t.Ellipse="Ellipse",t.Arrow="Arrow",t.Image="Image",t.Cloud="Cloud"}(W||(W={}));var X="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function q(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var J={exports:{}},Z={},$={},Q={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t._registerNode=t.Konva=t.glob=void 0;const e=Math.PI/180;t.glob=void 0!==X?X:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},t.Konva={_global:t.glob,version:"9.3.6",isBrowser:"undefined"!=typeof window&&("[object Window]"==={}.toString.call(window)||"[object global]"==={}.toString.call(window)),isUnminified:/param/.test(function(t){}.toString()),dblClickWindow:400,getAngle:i=>t.Konva.angleDeg?i*e:i,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,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:()=>t.Konva.DD.isDragging,isTransforming(){var e;return null===(e=t.Konva.Transformer)||void 0===e?void 0:e.isTransforming()},isDragReady:()=>!!t.Konva.DD.node,releaseCanvasOnDestroy:!0,document:t.glob.document,_injectGlobal(e){t.glob.Konva=e}};t._registerNode=e=>{t.Konva[e.prototype.getClassName()]=e},t.Konva._injectGlobal(t.Konva)}(Q);var tt={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Util=t.Transform=void 0;const e=Q;class i{constructor(t=[1,0,0,1,0,0]){this.dirty=!1,this.m=t&&t.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new i(this.m)}copyInto(t){t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5]}point(t){var e=this.m;return{x:e[0]*t.x+e[2]*t.y+e[4],y:e[1]*t.x+e[3]*t.y+e[5]}}translate(t,e){return this.m[4]+=this.m[0]*t+this.m[2]*e,this.m[5]+=this.m[1]*t+this.m[3]*e,this}scale(t,e){return this.m[0]*=t,this.m[1]*=t,this.m[2]*=e,this.m[3]*=e,this}rotate(t){var e=Math.cos(t),i=Math.sin(t),r=this.m[0]*e+this.m[2]*i,s=this.m[1]*e+this.m[3]*i,a=this.m[0]*-i+this.m[2]*e,n=this.m[1]*-i+this.m[3]*e;return this.m[0]=r,this.m[1]=s,this.m[2]=a,this.m[3]=n,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(t,e){var i=this.m[0]+this.m[2]*e,r=this.m[1]+this.m[3]*e,s=this.m[2]+this.m[0]*t,a=this.m[3]+this.m[1]*t;return this.m[0]=i,this.m[1]=r,this.m[2]=s,this.m[3]=a,this}multiply(t){var e=this.m[0]*t.m[0]+this.m[2]*t.m[1],i=this.m[1]*t.m[0]+this.m[3]*t.m[1],r=this.m[0]*t.m[2]+this.m[2]*t.m[3],s=this.m[1]*t.m[2]+this.m[3]*t.m[3],a=this.m[0]*t.m[4]+this.m[2]*t.m[5]+this.m[4],n=this.m[1]*t.m[4]+this.m[3]*t.m[5]+this.m[5];return this.m[0]=e,this.m[1]=i,this.m[2]=r,this.m[3]=s,this.m[4]=a,this.m[5]=n,this}invert(){var t=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),e=this.m[3]*t,i=-this.m[1]*t,r=-this.m[2]*t,s=this.m[0]*t,a=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),n=t*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=e,this.m[1]=i,this.m[2]=r,this.m[3]=s,this.m[4]=a,this.m[5]=n,this}getMatrix(){return this.m}decompose(){var e=this.m[0],i=this.m[1],r=this.m[2],s=this.m[3],a=e*s-i*r;let n={x:this.m[4],y:this.m[5],rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!=e||0!=i){var o=Math.sqrt(e*e+i*i);n.rotation=i>0?Math.acos(e/o):-Math.acos(e/o),n.scaleX=o,n.scaleY=a/o,n.skewX=(e*r+i*s)/a,n.skewY=0}else if(0!=r||0!=s){var h=Math.sqrt(r*r+s*s);n.rotation=Math.PI/2-(s>0?Math.acos(-r/h):-Math.acos(r/h)),n.scaleX=a/h,n.scaleY=h,n.skewX=0,n.skewY=(e*r+i*s)/a}return n.rotation=t.Util._getRotation(n.rotation),n}}t.Transform=i;var r=Math.PI/180,s=180/Math.PI,a="Konva error: ",n={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]},o=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,h=[];const l="undefined"!=typeof requestAnimationFrame&&requestAnimationFrame||function(t){setTimeout(t,60)};t.Util={_isElement:t=>!(!t||1!=t.nodeType),_isFunction:t=>!!(t&&t.constructor&&t.call&&t.apply),_isPlainObject:t=>!!t&&t.constructor===Object,_isArray:t=>"[object Array]"===Object.prototype.toString.call(t),_isNumber:t=>"[object Number]"===Object.prototype.toString.call(t)&&!isNaN(t)&&isFinite(t),_isString:t=>"[object String]"===Object.prototype.toString.call(t),_isBoolean:t=>"[object Boolean]"===Object.prototype.toString.call(t),isObject:t=>t instanceof Object,isValidSelector(t){if("string"!=typeof t)return!1;var e=t[0];return"#"===e||"."===e||e===e.toUpperCase()},_sign:t=>0===t||t>0?1:-1,requestAnimFrame(t){h.push(t),1===h.length&&l((function(){const t=h;h=[],t.forEach((function(t){t()}))}))},createCanvasElement(){var t=document.createElement("canvas");try{t.style=t.style||{}}catch(t){}return t},createImageElement:()=>document.createElement("img"),_isInDocument(t){for(;t=t.parentNode;)if(t==document)return!0;return!1},_urlToImage(e,i){var r=t.Util.createImageElement();r.onload=function(){i(r)},r.src=e},_rgbToHex:(t,e,i)=>((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1),_hexToRgb(t){t=t.replace("#","");var e=parseInt(t,16);return{r:e>>16&255,g:e>>8&255,b:255&e}},getRandomColor(){for(var t=(16777215*Math.random()|0).toString(16);t.length<6;)t="0"+t;return"#"+t},getRGB(t){var e;return t in n?{r:(e=n[t])[0],g:e[1],b:e[2]}:"#"===t[0]?this._hexToRgb(t.substring(1)):"rgb("===t.substr(0,4)?(e=o.exec(t.replace(/ /g,"")),{r:parseInt(e[1],10),g:parseInt(e[2],10),b:parseInt(e[3],10)}):{r:0,g:0,b:0}},colorToRGBA:e=>(e=e||"black",t.Util._namedColorToRBA(e)||t.Util._hex3ColorToRGBA(e)||t.Util._hex4ColorToRGBA(e)||t.Util._hex6ColorToRGBA(e)||t.Util._hex8ColorToRGBA(e)||t.Util._rgbColorToRGBA(e)||t.Util._rgbaColorToRGBA(e)||t.Util._hslColorToRGBA(e)),_namedColorToRBA(t){var e=n[t.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:1}:null},_rgbColorToRGBA(t){if(0===t.indexOf("rgb(")){var e=(t=t.match(/rgb\(([^)]+)\)/)[1]).split(/ *, */).map(Number);return{r:e[0],g:e[1],b:e[2],a:1}}},_rgbaColorToRGBA(t){if(0===t.indexOf("rgba(")){var e=(t=t.match(/rgba\(([^)]+)\)/)[1]).split(/ *, */).map(((t,e)=>"%"===t.slice(-1)?3===e?parseInt(t)/100:parseInt(t)/100*255:Number(t)));return{r:e[0],g:e[1],b:e[2],a:e[3]}}},_hex8ColorToRGBA(t){if("#"===t[0]&&9===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:parseInt(t.slice(7,9),16)/255}},_hex6ColorToRGBA(t){if("#"===t[0]&&7===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:1}},_hex4ColorToRGBA(t){if("#"===t[0]&&5===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:parseInt(t[4]+t[4],16)/255}},_hex3ColorToRGBA(t){if("#"===t[0]&&4===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:1}},_hslColorToRGBA(t){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(t)){const[e,...i]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t),r=Number(i[0])/360,s=Number(i[1])/100,a=Number(i[2])/100;let n,o,h;if(0===s)return h=255*a,{r:Math.round(h),g:Math.round(h),b:Math.round(h),a:1};n=a<.5?a*(1+s):a+s-a*s;const l=2*a-n,d=[0,0,0];for(let t=0;t<3;t++)o=r+1/3*-(t-1),o<0&&o++,o>1&&o--,h=6*o<1?l+6*(n-l)*o:2*o<1?n:3*o<2?l+(n-l)*(2/3-o)*6:l,d[t]=255*h;return{r:Math.round(d[0]),g:Math.round(d[1]),b:Math.round(d[2]),a:1}}},haveIntersection:(t,e)=>!(e.x>t.x+t.width||e.x+e.width<t.x||e.y>t.y+t.height||e.y+e.height<t.y),cloneObject(t){var e={};for(var i in t)this._isPlainObject(t[i])?e[i]=this.cloneObject(t[i]):this._isArray(t[i])?e[i]=this.cloneArray(t[i]):e[i]=t[i];return e},cloneArray:t=>t.slice(0),degToRad:t=>t*r,radToDeg:t=>t*s,_degToRad:e=>(t.Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),t.Util.degToRad(e)),_radToDeg:e=>(t.Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),t.Util.radToDeg(e)),_getRotation:i=>e.Konva.angleDeg?t.Util.radToDeg(i):i,_capitalize:t=>t.charAt(0).toUpperCase()+t.slice(1),throw(t){throw new Error(a+t)},error(t){console.error(a+t)},warn(t){e.Konva.showWarnings&&console.warn("Konva warning: "+t)},each(t,e){for(var i in t)e(i,t[i])},_inRange:(t,e,i)=>e<=t&&t<i,_getProjectionToSegment(t,e,i,r,s,a){var n,o,h,l=(t-i)*(t-i)+(e-r)*(e-r);if(0==l)n=t,o=e,h=(s-i)*(s-i)+(a-r)*(a-r);else{var d=((s-t)*(i-t)+(a-e)*(r-e))/l;d<0?(n=t,o=e,h=(t-s)*(t-s)+(e-a)*(e-a)):d>1?(n=i,o=r,h=(i-s)*(i-s)+(r-a)*(r-a)):h=((n=t+d*(i-t))-s)*(n-s)+((o=e+d*(r-e))-a)*(o-a)}return[n,o,h]},_getProjectionToLine(e,i,r){var s=t.Util.cloneObject(e),a=Number.MAX_VALUE;return i.forEach((function(n,o){if(r||o!==i.length-1){var h=i[(o+1)%i.length],l=t.Util._getProjectionToSegment(n.x,n.y,h.x,h.y,e.x,e.y),d=l[0],c=l[1],u=l[2];u<a&&(s.x=d,s.y=c,a=u)}})),s},_prepareArrayForTween(e,i,r){var s,a=[],n=[];if(e.length>i.length){var o=i;i=e,e=o}for(s=0;s<e.length;s+=2)a.push({x:e[s],y:e[s+1]});for(s=0;s<i.length;s+=2)n.push({x:i[s],y:i[s+1]});var h=[];return n.forEach((function(e){var i=t.Util._getProjectionToLine(e,a,r);h.push(i.x),h.push(i.y)})),h},_prepareToStringify(e){var i;for(var r in e.visitedByCircularReferenceRemoval=!0,e)if(e.hasOwnProperty(r)&&e[r]&&"object"==typeof e[r])if(i=Object.getOwnPropertyDescriptor(e,r),e[r].visitedByCircularReferenceRemoval||t.Util._isElement(e[r])){if(!i.configurable)return null;delete e[r]}else if(null===t.Util._prepareToStringify(e[r])){if(!i.configurable)return null;delete e[r]}return delete e.visitedByCircularReferenceRemoval,e},_assign(t,e){for(var i in e)t[i]=e[i];return t},_getFirstPointerId:t=>t.touches?t.changedTouches[0].identifier:t.pointerId||999,releaseCanvas(...t){e.Konva.releaseCanvasOnDestroy&&t.forEach((t=>{t.width=0,t.height=0}))},drawRoundedRectPath(t,e,i,r){let s=0,a=0,n=0,o=0;"number"==typeof r?s=a=n=o=Math.min(r,e/2,i/2):(s=Math.min(r[0]||0,e/2,i/2),a=Math.min(r[1]||0,e/2,i/2),o=Math.min(r[2]||0,e/2,i/2),n=Math.min(r[3]||0,e/2,i/2)),t.moveTo(s,0),t.lineTo(e-a,0),t.arc(e-a,a,a,3*Math.PI/2,0,!1),t.lineTo(e,i-o),t.arc(e-o,i-o,o,0,Math.PI/2,!1),t.lineTo(n,i),t.arc(n,i-n,n,Math.PI/2,Math.PI,!1),t.lineTo(0,s),t.arc(s,s,s,Math.PI,3*Math.PI/2,!1)}}}(tt);var et={},it={},rt={};Object.defineProperty(rt,"__esModule",{value:!0}),rt.getComponentValidator=rt.getBooleanValidator=rt.getNumberArrayValidator=rt.getFunctionValidator=rt.getStringOrGradientValidator=rt.getStringValidator=rt.getNumberOrAutoValidator=rt.getNumberOrArrayOfNumbersValidator=rt.getNumberValidator=rt.alphaComponent=rt.RGBComponent=void 0;const st=Q,at=tt;function nt(t){return at.Util._isString(t)?'"'+t+'"':"[object Number]"===Object.prototype.toString.call(t)||at.Util._isBoolean(t)?t:Object.prototype.toString.call(t)}rt.RGBComponent=function(t){return t>255?255:t<0?0:Math.round(t)},rt.alphaComponent=function(t){return t>1?1:t<1e-4?1e-4:t},rt.getNumberValidator=function(){if(st.Konva.isUnminified)return function(t,e){return at.Util._isNumber(t)||at.Util.warn(nt(t)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),t}},rt.getNumberOrArrayOfNumbersValidator=function(t){if(st.Konva.isUnminified)return function(e,i){let r=at.Util._isNumber(e),s=at.Util._isArray(e)&&e.length==t;return r||s||at.Util.warn(nt(e)+' is a not valid value for "'+i+'" attribute. The value should be a number or Array<number>('+t+")"),e}},rt.getNumberOrAutoValidator=function(){if(st.Konva.isUnminified)return function(t,e){return at.Util._isNumber(t)||"auto"===t||at.Util.warn(nt(t)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),t}},rt.getStringValidator=function(){if(st.Konva.isUnminified)return function(t,e){return at.Util._isString(t)||at.Util.warn(nt(t)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),t}},rt.getStringOrGradientValidator=function(){if(st.Konva.isUnminified)return function(t,e){const i=at.Util._isString(t),r="[object CanvasGradient]"===Object.prototype.toString.call(t)||t&&t.addColorStop;return i||r||at.Util.warn(nt(t)+' is a not valid value for "'+e+'" attribute. The value should be a string or a native gradient.'),t}},rt.getFunctionValidator=function(){if(st.Konva.isUnminified)return function(t,e){return at.Util._isFunction(t)||at.Util.warn(nt(t)+' is a not valid value for "'+e+'" attribute. The value should be a function.'),t}},rt.getNumberArrayValidator=function(){if(st.Konva.isUnminified)return function(t,e){const i=Int8Array?Object.getPrototypeOf(Int8Array):null;return i&&t instanceof i||(at.Util._isArray(t)?t.forEach((function(t){at.Util._isNumber(t)||at.Util.warn('"'+e+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")})):at.Util.warn(nt(t)+' is a not valid value for "'+e+'" attribute. The value should be a array of numbers.')),t}},rt.getBooleanValidator=function(){if(st.Konva.isUnminified)return function(t,e){return!0===t||!1===t||at.Util.warn(nt(t)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),t}},rt.getComponentValidator=function(t){if(st.Konva.isUnminified)return function(e,i){return null==e||at.Util.isObject(e)||at.Util.warn(nt(e)+' is a not valid value for "'+i+'" attribute. The value should be an object with properties '+t),e}},function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Factory=void 0;const e=tt,i=rt;var r="get",s="set";t.Factory={addGetterSetter(e,i,r,s,a){t.Factory.addGetter(e,i,r),t.Factory.addSetter(e,i,s,a),t.Factory.addOverloadedGetterSetter(e,i)},addGetter(t,i,s){var a=r+e.Util._capitalize(i);t.prototype[a]=t.prototype[a]||function(){var t=this.attrs[i];return void 0===t?s:t}},addSetter(i,r,a,n){var o=s+e.Util._capitalize(r);i.prototype[o]||t.Factory.overWriteSetter(i,r,a,n)},overWriteSetter(t,i,r,a){var n=s+e.Util._capitalize(i);t.prototype[n]=function(t){return r&&null!=t&&(t=r.call(this,t,i)),this._setAttr(i,t),a&&a.call(this),this}},addComponentsGetterSetter(a,n,o,h,l){var d,c,u=o.length,g=e.Util._capitalize,p=r+g(n),m=s+g(n);a.prototype[p]=function(){var t={};for(d=0;d<u;d++)t[c=o[d]]=this.getAttr(n+g(c));return t};var f=(0,i.getComponentValidator)(o);a.prototype[m]=function(t){var e,i=this.attrs[n];for(e in h&&(t=h.call(this,t)),f&&f.call(this,t,n),t)t.hasOwnProperty(e)&&this._setAttr(n+g(e),t[e]);return t||o.forEach((t=>{this._setAttr(n+g(t),void 0)})),this._fireChangeEvent(n,i,t),l&&l.call(this),this},t.Factory.addOverloadedGetterSetter(a,n)},addOverloadedGetterSetter(t,i){var a=e.Util._capitalize(i),n=s+a,o=r+a;t.prototype[i]=function(){return arguments.length?(this[n](arguments[0]),this):this[o]()}},addDeprecatedGetterSetter(i,s,a,n){e.Util.error("Adding deprecated "+s);var o=r+e.Util._capitalize(s),h=s+" property is deprecated and will be removed soon. Look at Konva change log for more information.";i.prototype[o]=function(){e.Util.error(h);var t=this.attrs[s];return void 0===t?a:t},t.Factory.addSetter(i,s,n,(function(){e.Util.error(h)})),t.Factory.addOverloadedGetterSetter(i,s)},backCompat(t,i){e.Util.each(i,(function(i,a){var n=t.prototype[a],o=r+e.Util._capitalize(i),h=s+e.Util._capitalize(i);function l(){n.apply(this,arguments),e.Util.error('"'+i+'" method is deprecated and will be removed soon. Use ""'+a+'" instead.')}t.prototype[i]=l,t.prototype[o]=l,t.prototype[h]=l}))},afterSetFilter(){this._filterUpToDate=!1}}}(it);var ot={},ht={};Object.defineProperty(ht,"__esModule",{value:!0}),ht.HitContext=ht.SceneContext=ht.Context=void 0;const lt=tt,dt=Q;var ct=["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"];class ut{constructor(t){this.canvas=t,dt.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,e){var i,r,s,a,n=this.traceArr,o=n.length,h="";for(i=0;i<o;i++)(s=(r=n[i]).method)?(a=r.args,h+=s,t?h+="()":lt.Util._isArray(a[0])?h+="(["+a.join(",")+"])":(e&&(a=a.map((t=>"number"==typeof t?Math.floor(t):t))),h+="("+a.join(",")+")")):(h+=r.property,t||(h+="="+r.val)),h+=";";return h}clearTrace(){this.traceArr=[]}_trace(t){var e=this.traceArr;e.push(t),e.length>=100&&e.shift()}reset(){var t=this.getCanvas().getPixelRatio();this.setTransform(1*t,0,0,1*t,0,0)}getCanvas(){return this.canvas}clear(t){var e=this.getCanvas();t?this.clearRect(t.x||0,t.y||0,t.width||0,t.height||0):this.clearRect(0,0,e.getWidth()/e.pixelRatio,e.getHeight()/e.pixelRatio)}_applyLineCap(t){const e=t.attrs.lineCap;e&&this.setAttr("lineCap",e)}_applyOpacity(t){var e=t.getAbsoluteOpacity();1!==e&&this.setAttr("globalAlpha",e)}_applyLineJoin(t){const e=t.attrs.lineJoin;e&&this.setAttr("lineJoin",e)}setAttr(t,e){this._context[t]=e}arc(t,e,i,r,s,a){this._context.arc(t,e,i,r,s,a)}arcTo(t,e,i,r,s){this._context.arcTo(t,e,i,r,s)}beginPath(){this._context.beginPath()}bezierCurveTo(t,e,i,r,s,a){this._context.bezierCurveTo(t,e,i,r,s,a)}clearRect(t,e,i,r){this._context.clearRect(t,e,i,r)}clip(...t){this._context.clip.apply(this._context,t)}closePath(){this._context.closePath()}createImageData(t,e){var i=arguments;return 2===i.length?this._context.createImageData(t,e):1===i.length?this._context.createImageData(t):void 0}createLinearGradient(t,e,i,r){return this._context.createLinearGradient(t,e,i,r)}createPattern(t,e){return this._context.createPattern(t,e)}createRadialGradient(t,e,i,r,s,a){return this._context.createRadialGradient(t,e,i,r,s,a)}drawImage(t,e,i,r,s,a,n,o,h){var l=arguments,d=this._context;3===l.length?d.drawImage(t,e,i):5===l.length?d.drawImage(t,e,i,r,s):9===l.length&&d.drawImage(t,e,i,r,s,a,n,o,h)}ellipse(t,e,i,r,s,a,n,o){this._context.ellipse(t,e,i,r,s,a,n,o)}isPointInPath(t,e,i,r){return i?this._context.isPointInPath(i,t,e,r):this._context.isPointInPath(t,e,r)}fill(...t){this._context.fill.apply(this._context,t)}fillRect(t,e,i,r){this._context.fillRect(t,e,i,r)}strokeRect(t,e,i,r){this._context.strokeRect(t,e,i,r)}fillText(t,e,i,r){r?this._context.fillText(t,e,i,r):this._context.fillText(t,e,i)}measureText(t){return this._context.measureText(t)}getImageData(t,e,i,r){return this._context.getImageData(t,e,i,r)}lineTo(t,e){this._context.lineTo(t,e)}moveTo(t,e){this._context.moveTo(t,e)}rect(t,e,i,r){this._context.rect(t,e,i,r)}roundRect(t,e,i,r,s){this._context.roundRect(t,e,i,r,s)}putImageData(t,e,i){this._context.putImageData(t,e,i)}quadraticCurveTo(t,e,i,r){this._context.quadraticCurveTo(t,e,i,r)}restore(){this._context.restore()}rotate(t){this._context.rotate(t)}save(){this._context.save()}scale(t,e){this._context.scale(t,e)}setLineDash(t){this._context.setLineDash?this._context.setLineDash(t):"mozDash"in this._context?this._context.mozDash=t:"webkitLineDash"in this._context&&(this._context.webkitLineDash=t)}getLineDash(){return this._context.getLineDash()}setTransform(t,e,i,r,s,a){this._context.setTransform(t,e,i,r,s,a)}stroke(t){t?this._context.stroke(t):this._context.stroke()}strokeText(t,e,i,r){this._context.strokeText(t,e,i,r)}transform(t,e,i,r,s,a){this._context.transform(t,e,i,r,s,a)}translate(t,e){this._context.translate(t,e)}_enableTrace(){var t,e,i=this,r=ct.length,s=this.setAttr,a=function(t){var r,s=i[t];i[t]=function(){return e=function(t){var e,i,r=[],s=t.length,a=lt.Util;for(e=0;e<s;e++)i=t[e],a._isNumber(i)?i=Math.round(1e3*i)/1e3:a._isString(i)||(i+=""),r.push(i);return r}(Array.prototype.slice.call(arguments,0)),r=s.apply(i,arguments),i._trace({method:t,args:e}),r}};for(t=0;t<r;t++)a(ct[t]);i.setAttr=function(){s.apply(i,arguments);var t=arguments[0],e=arguments[1];"shadowOffsetX"!==t&&"shadowOffsetY"!==t&&"shadowBlur"!==t||(e/=this.canvas.getPixelRatio()),i._trace({property:t,val:e})}}_applyGlobalCompositeOperation(t){const e=t.attrs.globalCompositeOperation;!e||"source-over"===e||this.setAttr("globalCompositeOperation",e)}}ht.Context=ut,["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"].forEach((function(t){Object.defineProperty(ut.prototype,t,{get(){return this._context[t]},set(e){this._context[t]=e}})}));ht.SceneContext=class extends ut{constructor(t,{willReadFrequently:e=!1}={}){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:e})}_fillColor(t){var e=t.fill();this.setAttr("fillStyle",e),t._fillFunc(this)}_fillPattern(t){this.setAttr("fillStyle",t._getFillPattern()),t._fillFunc(this)}_fillLinearGradient(t){var e=t._getLinearGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fillRadialGradient(t){const e=t._getRadialGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fill(t){const e=t.fill(),i=t.getFillPriority();if(e&&"color"===i)return void this._fillColor(t);const r=t.getFillPatternImage();if(r&&"pattern"===i)return void this._fillPattern(t);const s=t.getFillLinearGradientColorStops();if(s&&"linear-gradient"===i)return void this._fillLinearGradient(t);const a=t.getFillRadialGradientColorStops();a&&"radial-gradient"===i?this._fillRadialGradient(t):e?this._fillColor(t):r?this._fillPattern(t):s?this._fillLinearGradient(t):a&&this._fillRadialGradient(t)}_strokeLinearGradient(t){const e=t.getStrokeLinearGradientStartPoint(),i=t.getStrokeLinearGradientEndPoint(),r=t.getStrokeLinearGradientColorStops(),s=this.createLinearGradient(e.x,e.y,i.x,i.y);if(r){for(var a=0;a<r.length;a+=2)s.addColorStop(r[a],r[a+1]);this.setAttr("strokeStyle",s)}}_stroke(t){var e=t.dash(),i=t.getStrokeScaleEnabled();if(t.hasStroke()){if(!i){this.save();var r=this.getCanvas().getPixelRatio();this.setTransform(r,0,0,r,0,0)}this._applyLineCap(t),e&&t.dashEnabled()&&(this.setLineDash(e),this.setAttr("lineDashOffset",t.dashOffset())),this.setAttr("lineWidth",t.strokeWidth()),t.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)"),t.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(t):this.setAttr("strokeStyle",t.stroke()),t._strokeFunc(this),i||this.restore()}}_applyShadow(t){var e,i,r,s=null!==(e=t.getShadowRGBA())&&void 0!==e?e:"black",a=null!==(i=t.getShadowBlur())&&void 0!==i?i:5,n=null!==(r=t.getShadowOffset())&&void 0!==r?r:{x:0,y:0},o=t.getAbsoluteScale(),h=this.canvas.getPixelRatio(),l=o.x*h,d=o.y*h;this.setAttr("shadowColor",s),this.setAttr("shadowBlur",a*Math.min(Math.abs(l),Math.abs(d))),this.setAttr("shadowOffsetX",n.x*l),this.setAttr("shadowOffsetY",n.y*d)}};ht.HitContext=class extends ut{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 s=t.getStrokeScaleEnabled();if(!s){this.save();var e=this.getCanvas().getPixelRatio();this.setTransform(e,0,0,e,0,0)}this._applyLineCap(t);var i=t.hitStrokeWidth(),r="auto"===i?t.strokeWidth():i;this.setAttr("lineWidth",r),this.setAttr("strokeStyle",t.colorKey),t._strokeFuncHit(this),s||this.restore()}}},Object.defineProperty(ot,"__esModule",{value:!0}),ot.HitCanvas=ot.SceneCanvas=ot.Canvas=void 0;const gt=tt,pt=ht,mt=Q,ft=it,vt=rt;var _t;class yt{constructor(t){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;var e=(t||{}).pixelRatio||mt.Konva.pixelRatio||function(){if(_t)return _t;var t=gt.Util.createCanvasElement(),e=t.getContext("2d");return _t=(mt.Konva._global.devicePixelRatio||1)/(e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1),gt.Util.releaseCanvas(t),_t}();this.pixelRatio=e,this._canvas=gt.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){var e=this.pixelRatio;this.pixelRatio=t,this.setSize(this.getWidth()/e,this.getHeight()/e)}setWidth(t){this.width=this._canvas.width=t*this.pixelRatio,this._canvas.style.width=t+"px";var e=this.pixelRatio;this.getContext()._context.scale(e,e)}setHeight(t){this.height=this._canvas.height=t*this.pixelRatio,this._canvas.style.height=t+"px";var e=this.pixelRatio;this.getContext()._context.scale(e,e)}getWidth(){return this.width}getHeight(){return this.height}setSize(t,e){this.setWidth(t||0),this.setHeight(e||0)}toDataURL(t,e){try{return this._canvas.toDataURL(t,e)}catch(t){try{return this._canvas.toDataURL()}catch(t){return gt.Util.error("Unable to get data URL. "+t.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}}ot.Canvas=yt,ft.Factory.addGetterSetter(yt,"pixelRatio",void 0,(0,vt.getNumberValidator)());ot.SceneCanvas=class extends yt{constructor(t={width:0,height:0,willReadFrequently:!1}){super(t),this.context=new pt.SceneContext(this,{willReadFrequently:t.willReadFrequently}),this.setSize(t.width,t.height)}};ot.HitCanvas=class extends yt{constructor(t={width:0,height:0}){super(t),this.hitCanvas=!0,this.context=new pt.HitContext(this),this.setSize(t.width,t.height)}};var wt={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DD=void 0;const e=Q,i=tt;t.DD={get isDragging(){var e=!1;return t.DD._dragElements.forEach((t=>{"dragging"===t.dragStatus&&(e=!0)})),e},justDragged:!1,get node(){var e;return t.DD._dragElements.forEach((t=>{e=t.node})),e},_dragElements:new Map,_drag(e){const r=[];t.DD._dragElements.forEach(((t,s)=>{const{node:a}=t,n=a.getStage();n.setPointersPositions(e),void 0===t.pointerId&&(t.pointerId=i.Util._getFirstPointerId(e));const o=n._changedPointerPositions.find((e=>e.id===t.pointerId));if(o){if("dragging"!==t.dragStatus){var h=a.dragDistance();if(Math.max(Math.abs(o.x-t.startPointerPos.x),Math.abs(o.y-t.startPointerPos.y))<h)return;if(a.startDrag({evt:e}),!a.isDragging())return}a._setDragPosition(e,t),r.push(a)}})),r.forEach((t=>{t.fire("dragmove",{type:"dragmove",target:t,evt:e},!0)}))},_endDragBefore(i){const r=[];t.DD._dragElements.forEach((s=>{const{node:a}=s,n=a.getStage();i&&n.setPointersPositions(i);if(!n._changedPointerPositions.find((t=>t.id===s.pointerId)))return;"dragging"!==s.dragStatus&&"stopped"!==s.dragStatus||(t.DD.justDragged=!0,e.Konva._mouseListenClick=!1,e.Konva._touchListenClick=!1,e.Konva._pointerListenClick=!1,s.dragStatus="stopped");const o=s.node.getLayer()||s.node instanceof e.Konva.Stage&&s.node;o&&-1===r.indexOf(o)&&r.push(o)})),r.forEach((t=>{t.draw()}))},_endDragAfter(e){t.DD._dragElements.forEach(((i,r)=>{"stopped"===i.dragStatus&&i.node.fire("dragend",{type:"dragend",target:i.node,evt:e},!0),"dragging"!==i.dragStatus&&t.DD._dragElements.delete(r)}))}},e.Konva.isBrowser&&(window.addEventListener("mouseup",t.DD._endDragBefore,!0),window.addEventListener("touchend",t.DD._endDragBefore,!0),window.addEventListener("mousemove",t.DD._drag),window.addEventListener("touchmove",t.DD._drag),window.addEventListener("mouseup",t.DD._endDragAfter,!1),window.addEventListener("touchend",t.DD._endDragAfter,!1))}(wt),Object.defineProperty(et,"__esModule",{value:!0}),et.Node=void 0;const bt=tt,xt=it,St=ot,Ct=Q,Pt=wt,kt=rt;var Et="absoluteOpacity",At="allEventListeners",Tt="absoluteTransform",Mt="absoluteScale",Ft="canvas",Ot="listening",Rt="mouseenter",It="mouseleave",Dt="Shape",Lt=" ",Vt="stage",Gt="transform",zt="visible",Nt=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(Lt);let Ut=1;class Wt{constructor(t){this._id=Ut++,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!==Gt&&t!==Tt||!this._cache.get(t)?t?this._cache.delete(t):this._cache.clear():this._cache.get(t).dirty=!0}_getCache(t,e){var i=this._cache.get(t);return(void 0===i||(t===Gt||t===Tt)&&!0===i.dirty)&&(i=e.call(this),this._cache.set(t,i)),i}_calculate(t,e,i){if(!this._attachedDepsListeners.get(t)){const i=e.map((t=>t+"Change.konva")).join(Lt);this.on(i,(()=>{this._clearCache(t)})),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,i)}_getCanvasCache(){return this._cache.get(Ft)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===Tt&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(Ft)){const{scene:t,filter:e,hit:i}=this._cache.get(Ft);bt.Util.releaseCanvas(t,e,i),this._cache.delete(Ft)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(t){var e=t||{},i={};void 0!==e.x&&void 0!==e.y&&void 0!==e.width&&void 0!==e.height||(i=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));var r=Math.ceil(e.width||i.width),s=Math.ceil(e.height||i.height),a=e.pixelRatio,n=void 0===e.x?Math.floor(i.x):e.x,o=void 0===e.y?Math.floor(i.y):e.y,h=e.offset||0,l=e.drawBorder||!1,d=e.hitCanvasPixelRatio||1;if(!r||!s)return void bt.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");r+=2*h+(Math.abs(Math.round(i.x)-n)>.5?1:0),s+=2*h+(Math.abs(Math.round(i.y)-o)>.5?1:0),n-=h,o-=h;var c=new St.SceneCanvas({pixelRatio:a,width:r,height:s}),u=new St.SceneCanvas({pixelRatio:a,width:0,height:0,willReadFrequently:!0}),g=new St.HitCanvas({pixelRatio:d,width:r,height:s}),p=c.getContext(),m=g.getContext();return g.isCache=!0,c.isCache=!0,this._cache.delete(Ft),this._filterUpToDate=!1,!1===e.imageSmoothingEnabled&&(c.getContext()._context.imageSmoothingEnabled=!1,u.getContext()._context.imageSmoothingEnabled=!1),p.save(),m.save(),p.translate(-n,-o),m.translate(-n,-o),this._isUnderCache=!0,this._clearSelfAndDescendantCache(Et),this._clearSelfAndDescendantCache(Mt),this.drawScene(c,this),this.drawHit(g,this),this._isUnderCache=!1,p.restore(),m.restore(),l&&(p.save(),p.beginPath(),p.rect(0,0,r,s),p.closePath(),p.setAttr("strokeStyle","red"),p.setAttr("lineWidth",5),p.stroke(),p.restore()),this._cache.set(Ft,{scene:c,filter:u,hit:g,x:n,y:o}),this._requestDraw(),this}isCached(){return this._cache.has(Ft)}getClientRect(t){throw new Error('abstract "getClientRect" method call')}_transformedRect(t,e){var i=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}],r=1/0,s=1/0,a=-1/0,n=-1/0,o=this.getAbsoluteTransform(e);return i.forEach((function(t){var e=o.point(t);void 0===r&&(r=a=e.x,s=n=e.y),r=Math.min(r,e.x),s=Math.min(s,e.y),a=Math.max(a,e.x),n=Math.max(n,e.y)})),{x:r,y:s,width:a-r,height:n-s}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const e=this._getCanvasCache();t.translate(e.x,e.y);var i=this._getCachedSceneCanvas(),r=i.pixelRatio;t.drawImage(i._canvas,0,0,i.width/r,i.height/r),t.restore()}_drawCachedHitCanvas(t){var e=this._getCanvasCache(),i=e.hit;t.save(),t.translate(e.x,e.y),t.drawImage(i._canvas,0,0,i.width/i.pixelRatio,i.height/i.pixelRatio),t.restore()}_getCachedSceneCanvas(){var t,e,i,r,s=this.filters(),a=this._getCanvasCache(),n=a.scene,o=a.filter,h=o.getContext();if(s){if(!this._filterUpToDate){var l=n.pixelRatio;o.setSize(n.width/n.pixelRatio,n.height/n.pixelRatio);try{for(t=s.length,h.clear(),h.drawImage(n._canvas,0,0,n.getWidth()/l,n.getHeight()/l),e=h.getImageData(0,0,o.getWidth(),o.getHeight()),i=0;i<t;i++)"function"==typeof(r=s[i])?(r.call(this,e),h.putImageData(e,0,0)):bt.Util.error("Filter should be type of function, but got "+typeof r+" instead. Please check correct filters")}catch(t){bt.Util.error("Unable to apply filter. "+t.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return o}return n}on(t,e){if(this._cache&&this._cache.delete(At),3===arguments.length)return this._delegate.apply(this,arguments);var i,r,s,a,n=t.split(Lt),o=n.length;for(i=0;i<o;i++)s=(r=n[i].split("."))[0],a=r[1]||"",this.eventListeners[s]||(this.eventListeners[s]=[]),this.eventListeners[s].push({name:a,handler:e});return this}off(t,e){var i,r,s,a,n,o=(t||"").split(Lt),h=o.length;if(this._cache&&this._cache.delete(At),!t)for(r in this.eventListeners)this._off(r);for(i=0;i<h;i++)if(a=(s=o[i].split("."))[0],n=s[1],a)this.eventListeners[a]&&this._off(a,n,e);else for(r in this.eventListeners)this._off(r,n,e);return this}dispatchEvent(t){var e={target:this,type:t.type,evt:t};return this.fire(t.type,e),this}addEventListener(t,e){return this.on(t,(function(t){e.call(this,t.evt)})),this}removeEventListener(t){return this.off(t),this}_delegate(t,e,i){var r=this;this.on(t,(function(t){for(var s=t.target.findAncestors(e,!0,r),a=0;a<s.length;a++)(t=bt.Util.cloneObject(t)).currentTarget=s[a],i.call(s[a],t)}))}remove(){return this.isDragging()&&this.stopDrag(),Pt.DD._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(Tt),this._clearSelfAndDescendantCache(Et),this._clearSelfAndDescendantCache(Mt),this._clearSelfAndDescendantCache(Vt),this._clearSelfAndDescendantCache(zt),this._clearSelfAndDescendantCache(Ot)}_remove(){this._clearCaches();var 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){var e="get"+bt.Util._capitalize(t);return bt.Util._isFunction(this[e])?this[e]():this.attrs[t]}getAncestors(){for(var t=this.getParent(),e=[];t;)e.push(t),t=t.getParent();return e}getAttrs(){return this.attrs||{}}setAttrs(t){return this._batchTransformChanges((()=>{var e,i;if(!t)return this;for(e in t)"children"!==e&&(i="set"+bt.Util._capitalize(e),bt.Util._isFunction(this[i])?this[i](t[e]):this._setAttr(e,t[e]))})),this}isListening(){return this._getCache(Ot,this._isListening)}_isListening(t){if(!this.listening())return!1;const e=this.getParent();return!e||e===t||this===t||e._isListening(t)}isVisible(){return this._getCache(zt,this._isVisible)}_isVisible(t){if(!this.visible())return!1;const e=this.getParent();return!e||e===t||this===t||e._isVisible(t)}shouldDrawHit(t,e=!1){if(t)return this._isVisible(t)&&this._isListening(t);var i=this.getLayer(),r=!1;Pt.DD._dragElements.forEach((t=>{"dragging"===t.dragStatus&&("Stage"===t.node.nodeType||t.node.getLayer()===i)&&(r=!0)}));var s=!e&&!Ct.Konva.hitOnDragEnabled&&(r||Ct.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(){var t,e,i,r,s=this.getDepth(),a=this,n=0;const o=this.getStage();return"Stage"!==a.nodeType&&o&&function o(h){for(t=[],e=h.length,i=0;i<e;i++)r=h[i],n++,r.nodeType!==Dt&&(t=t.concat(r.getChildren().slice())),r._id===a._id&&(i=e);t.length>0&&t[0].getDepth()<=s&&o(t)}(o.getChildren()),n}getDepth(){for(var t=0,e=this.parent;e;)t++,e=e.parent;return t}_batchTransformChanges(t){this._batchingTransformChange=!0,t(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(Gt),this._clearSelfAndDescendantCache(Tt)),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;var e=t.getPointerPosition();if(!e)return null;var i=this.getAbsoluteTransform().copy();return i.invert(),i.point(e)}getAbsolutePosition(t){let e=!1,i=this.parent;for(;i;){if(i.isCached()){e=!0;break}i=i.parent}e&&!t&&(t=!0);var r=this.getAbsoluteTransform(t).getMatrix(),s=new bt.Transform,a=this.offset();return s.m=r.slice(),s.translate(a.x,a.y),s.getTranslation()}setAbsolutePosition(t){const{x:e,y:i,...r}=this._clearTransform();this.attrs.x=e,this.attrs.y=i,this._clearCache(Gt);var 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(Gt),this._clearSelfAndDescendantCache(Tt),this}_setTransform(t){var e;for(e in t)this.attrs[e]=t[e]}_clearTransform(){var 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){var e=t.x,i=t.y,r=this.x(),s=this.y();return void 0!==e&&(r+=e),void 0!==i&&(s+=i),this.setPosition({x:r,y:s}),this}_eachAncestorReverse(t,e){var i,r,s=[],a=this.getParent();if(!e||e._id!==this._id){for(s.unshift(this);a&&(!e||a._id!==e._id);)s.unshift(a),a=a.parent;for(i=s.length,r=0;r<i;r++)t(s[r])}}rotate(t){return this.rotation(this.rotation()+t),this}moveToTop(){if(!this.parent)return bt.Util.warn("Node has no parent. moveToTop function is ignored."),!1;var t=this.index;return t<this.parent.getChildren().length-1&&(this.parent.children.splice(t,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0)}moveUp(){if(!this.parent)return bt.Util.warn("Node has no parent. moveUp function is ignored."),!1;var t=this.index;return t<this.parent.getChildren().length-1&&(this.parent.children.splice(t,1),this.parent.children.splice(t+1,0,this),this.parent._setChildrenIndices(),!0)}moveDown(){if(!this.parent)return bt.Util.warn("Node has no parent. moveDown function is ignored."),!1;var t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.splice(t-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return bt.Util.warn("Node has no parent. moveToBottom function is ignored."),!1;var t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(t){if(!this.parent)return bt.Util.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&&bt.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)+".");var e=this.index;return this.parent.children.splice(e,1),this.parent.children.splice(t,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(Et,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){var t=this.opacity(),e=this.getParent();return e&&!e._isUnderCache&&(t*=e.getAbsoluteOpacity()),t}moveTo(t){return this.getParent()!==t&&(this._remove(),t.add(this)),this}toObject(){var t,e,i,r,s=this.getAttrs();const a={attrs:{},className:this.getClassName()};for(t in s)e=s[t],bt.Util.isObject(e)&&!bt.Util._isPlainObject(e)&&!bt.Util._isArray(e)||(i="function"==typeof this[t]&&this[t],delete s[t],r=i?i.call(this):null,s[t]=e,r!==e&&(a.attrs[t]=e));return bt.Util._prepareToStringify(a)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,e,i){var r=[];e&&this._isMatch(t)&&r.push(this);for(var s=this.parent;s;){if(s===i)return r;s._isMatch(t)&&r.push(s),s=s.parent}return r}isAncestorOf(t){return!1}findAncestor(t,e,i){return this.findAncestors(t,e,i)[0]}_isMatch(t){if(!t)return!1;if("function"==typeof t)return t(this);var e,i,r=t.replace(/ /g,"").split(","),s=r.length;for(e=0;e<s;e++)if(i=r[e],bt.Util.isValidSelector(i)||(bt.Util.warn('Selector "'+i+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),bt.Util.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),bt.Util.warn("Konva is awesome, right?")),"#"===i.charAt(0)){if(this.id()===i.slice(1))return!0}else if("."===i.charAt(0)){if(this.hasName(i.slice(1)))return!0}else if(this.className===i||this.nodeType===i)return!0;return!1}getLayer(){var t=this.getParent();return t?t.getLayer():null}getStage(){return this._getCache(Vt,this._getStage)}_getStage(){var t=this.getParent();return t?t.getStage():null}fire(t,e={},i){return e.target=e.target||this,i?this._fireAndBubble(t,e):this._fire(t,e),this}getAbsoluteTransform(t){return t?this._getAbsoluteTransform(t):this._getCache(Tt,this._getAbsoluteTransform)}_getAbsoluteTransform(t){var e;if(t)return e=new bt.Transform,this._eachAncestorReverse((function(t){var i=t.transformsEnabled();"all"===i?e.multiply(t.getTransform()):"position"===i&&e.translate(t.x()-t.offsetX(),t.y()-t.offsetY())}),t),e;e=this._cache.get(Tt)||new bt.Transform,this.parent?this.parent.getAbsoluteTransform().copyInto(e):e.reset();var i=this.transformsEnabled();if("all"===i)e.multiply(this.getTransform());else if("position"===i){const t=this.attrs.x||0,i=this.attrs.y||0,r=this.attrs.offsetX||0,s=this.attrs.offsetY||0;e.translate(t-r,i-s)}return e.dirty=!1,e}getAbsoluteScale(t){for(var e=this;e;)e._isUnderCache&&(t=e),e=e.getParent();const i=this.getAbsoluteTransform(t).decompose();return{x:i.scaleX,y:i.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(Gt,this._getTransform)}_getTransform(){var t,e,i=this._cache.get(Gt)||new bt.Transform;i.reset();var r=this.x(),s=this.y(),a=Ct.Konva.getAngle(this.rotation()),n=null!==(t=this.attrs.scaleX)&&void 0!==t?t:1,o=null!==(e=this.attrs.scaleY)&&void 0!==e?e:1,h=this.attrs.skewX||0,l=this.attrs.skewY||0,d=this.attrs.offsetX||0,c=this.attrs.offsetY||0;return 0===r&&0===s||i.translate(r,s),0!==a&&i.rotate(a),0===h&&0===l||i.skew(h,l),1===n&&1===o||i.scale(n,o),0===d&&0===c||i.translate(-1*d,-1*c),i.dirty=!1,i}clone(t){var e,i,r,s,a,n=bt.Util.cloneObject(this.attrs);for(e in t)n[e]=t[e];var o=new this.constructor(n);for(e in this.eventListeners)for(r=(i=this.eventListeners[e]).length,s=0;s<r;s++)(a=i[s]).name.indexOf("konva")<0&&(o.eventListeners[e]||(o.eventListeners[e]=[]),o.eventListeners[e].push(a));return o}_toKonvaCanvas(t){t=t||{};var e=this.getClientRect(),i=this.getStage(),r=void 0!==t.x?t.x:Math.floor(e.x),s=void 0!==t.y?t.y:Math.floor(e.y),a=t.pixelRatio||1,n=new St.SceneCanvas({width:t.width||Math.ceil(e.width)||(i?i.width():0),height:t.height||Math.ceil(e.height)||(i?i.height():0),pixelRatio:a}),o=n.getContext();const h=new St.SceneCanvas({width:n.width/n.pixelRatio+Math.abs(r),height:n.height/n.pixelRatio+Math.abs(s),pixelRatio:n.pixelRatio});return!1===t.imageSmoothingEnabled&&(o._context.imageSmoothingEnabled=!1),o.save(),(r||s)&&o.translate(-1*r,-1*s),this.drawScene(n,void 0,h),o.restore(),n}toCanvas(t){return this._toKonvaCanvas(t)._canvas}toDataURL(t){var e=(t=t||{}).mimeType||null,i=t.quality||null,r=this._toKonvaCanvas(t).toDataURL(e,i);return t.callback&&t.callback(r),r}toImage(t){return new Promise(((e,i)=>{try{const i=null==t?void 0:t.callback;i&&delete t.callback,bt.Util._urlToImage(this.toDataURL(t),(function(t){e(t),null==i||i(t)}))}catch(t){i(t)}}))}toBlob(t){return new Promise(((e,i)=>{try{const i=null==t?void 0:t.callback;i&&delete t.callback,this.toCanvas(t).toBlob((t=>{e(t),null==i||i(t)}),null==t?void 0:t.mimeType,null==t?void 0:t.quality)}catch(t){i(t)}}))}setSize(t){return this.width(t.width),this.height(t.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return void 0!==this.attrs.dragDistance?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():Ct.Konva.dragDistance}_off(t,e,i){var r,s,a,n=this.eventListeners[t];for(r=0;r<n.length;r++)if(s=n[r].name,a=n[r].handler,!("konva"===s&&"konva"!==e||e&&s!==e||i&&i!==a)){if(n.splice(r,1),0===n.length){delete this.eventListeners[t];break}r--}}_fireChangeEvent(t,e,i){this._fire(t+"Change",{oldVal:e,newVal:i})}addName(t){if(!this.hasName(t)){var e=this.name(),i=e?e+" "+t:t;this.name(i)}return this}hasName(t){if(!t)return!1;const e=this.name();return!!e&&-1!==(e||"").split(/\s/g).indexOf(t)}removeName(t){var e=(this.name()||"").split(/\s/g),i=e.indexOf(t);return-1!==i&&(e.splice(i,1),this.name(e.join(" "))),this}setAttr(t,e){var i=this["set"+bt.Util._capitalize(t)];return bt.Util._isFunction(i)?i.call(this,e):this._setAttr(t,e),this}_requestDraw(){if(Ct.Konva.autoDrawEnabled){const t=this.getLayer()||this.getStage();null==t||t.batchDraw()}}_setAttr(t,e){var i=this.attrs[t];(i!==e||bt.Util.isObject(e))&&(null==e?delete this.attrs[t]:this.attrs[t]=e,this._shouldFireChangeEvents&&this._fireChangeEvent(t,i,e),this._requestDraw())}_setComponentAttr(t,e,i){var r;void 0!==i&&((r=this.attrs[t])||(this.attrs[t]=this.getAttr(t)),this.attrs[t][e]=i,this._fireChangeEvent(t,r,i))}_fireAndBubble(t,e,i){if(e&&this.nodeType===Dt&&(e.target=this),!((t===Rt||t===It)&&(i&&(this===i||this.isAncestorOf&&this.isAncestorOf(i))||"Stage"===this.nodeType&&!i))){this._fire(t,e);var r=(t===Rt||t===It)&&i&&i.isAncestorOf&&i.isAncestorOf(this)&&!i.isAncestorOf(this.parent);(e&&!e.cancelBubble||!e)&&this.parent&&this.parent.isListening()&&!r&&(i&&i.parent?this._fireAndBubble.call(this.parent,t,e,i):this._fireAndBubble.call(this.parent,t,e))}}_getProtoListeners(t){var e,i,r;const s=null!==(e=this._cache.get(At))&&void 0!==e?e:{};let a=null==s?void 0:s[t];if(void 0===a){a=[];let e=Object.getPrototypeOf(this);for(;e;){const s=null!==(r=null===(i=e.eventListeners)||void 0===i?void 0:i[t])&&void 0!==r?r:[];a.push(...s),e=Object.getPrototypeOf(e)}s[t]=a,this._cache.set(At,s)}return a}_fire(t,e){(e=e||{}).currentTarget=this,e.type=t;const i=this._getProtoListeners(t);if(i)for(var r=0;r<i.length;r++)i[r].handler.call(this,e);const s=this.eventListeners[t];if(s)for(r=0;r<s.length;r++)s[r].handler.call(this,e)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(t){var e=t?t.pointerId:void 0,i=this.getStage(),r=this.getAbsolutePosition();if(i){var s=i._getPointerById(e)||i._changedPointerPositions[0]||r;Pt.DD._dragElements.set(this._id,{node:this,startPointerPos:s,offset:{x:s.x-r.x,y:s.y-r.y},dragStatus:"ready",pointerId:e})}}startDrag(t,e=!0){Pt.DD._dragElements.has(this._id)||this._createDragElement(t);Pt.DD._dragElements.get(this._id).dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:t&&t.evt},e)}_setDragPosition(t,e){const i=this.getStage()._getPointerById(e.pointerId);if(i){var r={x:i.x-e.offset.x,y:i.y-e.offset.y},s=this.dragBoundFunc();if(void 0!==s){const e=s.call(this,r,t);e?r=e:bt.Util.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}this._lastPos&&this._lastPos.x===r.x&&this._lastPos.y===r.y||(this.setAbsolutePosition(r),this._requestDraw()),this._lastPos=r}}stopDrag(t){const e=Pt.DD._dragElements.get(this._id);e&&(e.dragStatus="stopped"),Pt.DD._endDragBefore(t),Pt.DD._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=Pt.DD._dragElements.get(this._id);return!!t&&"dragging"===t.dragStatus}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",(function(t){if((!(void 0!==t.evt.button)||Ct.Konva.dragButtons.indexOf(t.evt.button)>=0)&&!this.isDragging()){var e=!1;Pt.DD._dragElements.forEach((t=>{this.isAncestorOf(t.node)&&(e=!0)})),e||this._createDragElement(t)}}))}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{if(this._dragCleanup(),!this.getStage())return;const t=Pt.DD._dragElements.get(this._id),e=t&&"dragging"===t.dragStatus,i=t&&"ready"===t.dragStatus;e?this.stopDrag():i&&Pt.DD._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(t={x:0,y:0}){const e=this.getStage();if(!e)return!1;const i={x:-t.x,y:-t.y,width:e.width()+2*t.x,height:e.height()+2*t.y};return bt.Util.haveIntersection(i,this.getClientRect())}static create(t,e){return bt.Util._isString(t)&&(t=JSON.parse(t)),this._createNode(t,e)}static _createNode(t,e){var i,r,s,a=Wt.prototype.getClassName.call(t),n=t.children;e&&(t.attrs.container=e),Ct.Konva[a]||(bt.Util.warn('Can not find a node with class name "'+a+'". Fallback to "Shape".'),a="Shape");if(i=new(0,Ct.Konva[a])(t.attrs),n)for(r=n.length,s=0;s<r;s++)i.add(Wt._createNode(n[s]));return i}}et.Node=Wt,Wt.prototype.nodeType="Node",Wt.prototype._attrsAffectingSize=[],Wt.prototype.eventListeners={},Wt.prototype.on.call(Wt.prototype,Nt,(function(){this._batchingTransformChange?this._needClearTransformCache=!0:(this._clearCache(Gt),this._clearSelfAndDescendantCache(Tt))})),Wt.prototype.on.call(Wt.prototype,"visibleChange.konva",(function(){this._clearSelfAndDescendantCache(zt)})),Wt.prototype.on.call(Wt.prototype,"listeningChange.konva",(function(){this._clearSelfAndDescendantCache(Ot)})),Wt.prototype.on.call(Wt.prototype,"opacityChange.konva",(function(){this._clearSelfAndDescendantCache(Et)}));const jt=xt.Factory.addGetterSetter;jt(Wt,"zIndex"),jt(Wt,"absolutePosition"),jt(Wt,"position"),jt(Wt,"x",0,(0,kt.getNumberValidator)()),jt(Wt,"y",0,(0,kt.getNumberValidator)()),jt(Wt,"globalCompositeOperation","source-over",(0,kt.getStringValidator)()),jt(Wt,"opacity",1,(0,kt.getNumberValidator)()),jt(Wt,"name","",(0,kt.getStringValidator)()),jt(Wt,"id","",(0,kt.getStringValidator)()),jt(Wt,"rotation",0,(0,kt.getNumberValidator)()),xt.Factory.addComponentsGetterSetter(Wt,"scale",["x","y"]),jt(Wt,"scaleX",1,(0,kt.getNumberValidator)()),jt(Wt,"scaleY",1,(0,kt.getNumberValidator)()),xt.Factory.addComponentsGetterSetter(Wt,"skew",["x","y"]),jt(Wt,"skewX",0,(0,kt.getNumberValidator)()),jt(Wt,"skewY",0,(0,kt.getNumberValidator)()),xt.Factory.addComponentsGetterSetter(Wt,"offset",["x","y"]),jt(Wt,"offsetX",0,(0,kt.getNumberValidator)()),jt(Wt,"offsetY",0,(0,kt.getNumberValidator)()),jt(Wt,"dragDistance",null,(0,kt.getNumberValidator)()),jt(Wt,"width",0,(0,kt.getNumberValidator)()),jt(Wt,"height",0,(0,kt.getNumberValidator)()),jt(Wt,"listening",!0,(0,kt.getBooleanValidator)()),jt(Wt,"preventDefault",!0,(0,kt.getBooleanValidator)()),jt(Wt,"filters",null,(function(t){return this._filterUpToDate=!1,t})),jt(Wt,"visible",!0,(0,kt.getBooleanValidator)()),jt(Wt,"transformsEnabled","all",(0,kt.getStringValidator)()),jt(Wt,"size"),jt(Wt,"dragBoundFunc"),jt(Wt,"draggable",!1,(0,kt.getBooleanValidator)()),xt.Factory.backCompat(Wt,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});var Bt={};Object.defineProperty(Bt,"__esModule",{value:!0}),Bt.Container=void 0;const Ht=it,Kt=et,Yt=rt;class Xt extends Kt.Node{constructor(){super(...arguments),this.children=[]}getChildren(t){if(!t)return this.children||[];const e=this.children||[];var i=[];return e.forEach((function(e){t(e)&&i.push(e)})),i}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach((t=>{t.parent=null,t.index=0,t.remove()})),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach((t=>{t.parent=null,t.index=0,t.destroy()})),this.children=[],this._requestDraw(),this}add(...t){if(0===t.length)return this;if(t.length>1){for(var e=0;e<t.length;e++)this.add(t[e]);return this}const i=t[0];return i.getParent()?(i.moveTo(this),this):(this._validateAdd(i),i.index=this.getChildren().length,i.parent=this,i._clearCaches(),this.getChildren().push(i),this._fire("add",{child:i}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(t){return this._generalFind(t,!1)}findOne(t){var e=this._generalFind(t,!0);return e.length>0?e[0]:void 0}_generalFind(t,e){var i=[];return this._descendants((r=>{const s=r._isMatch(t);return s&&i.push(r),!(!s||!e)})),i}_descendants(t){let e=!1;const i=this.getChildren();for(const r of i){if(e=t(r),e)return!0;if(r.hasChildren()&&(e=r._descendants(t),e))return!0}return!1}toObject(){var t=Kt.Node.prototype.toObject.call(this);return t.children=[],this.getChildren().forEach((e=>{t.children.push(e.toObject())})),t}isAncestorOf(t){for(var e=t.getParent();e;){if(e._id===this._id)return!0;e=e.getParent()}return!1}clone(t){var e=Kt.Node.prototype.clone.call(this,t);return this.getChildren().forEach((function(t){e.add(t.clone())})),e}getAllIntersections(t){var e=[];return this.find("Shape").forEach((i=>{i.isVisible()&&i.intersects(t)&&e.push(i)})),e}_clearSelfAndDescendantCache(t){var e;super._clearSelfAndDescendantCache(t),this.isCached()||null===(e=this.children)||void 0===e||e.forEach((function(e){e._clearSelfAndDescendantCache(t)}))}_setChildrenIndices(){var t;null===(t=this.children)||void 0===t||t.forEach((function(t,e){t.index=e})),this._requestDraw()}drawScene(t,e,i){var r=this.getLayer(),s=t||r&&r.getCanvas(),a=s&&s.getContext(),n=this._getCanvasCache(),o=n&&n.scene,h=s&&s.isCache;if(!this.isVisible()&&!h)return this;if(o){a.save();var l=this.getAbsoluteTransform(e).getMatrix();a.transform(l[0],l[1],l[2],l[3],l[4],l[5]),this._drawCachedSceneCanvas(a),a.restore()}else this._drawChildren("drawScene",s,e,i);return this}drawHit(t,e){if(!this.shouldDrawHit(e))return this;var i=this.getLayer(),r=t||i&&i.hitCanvas,s=r&&r.getContext(),a=this._getCanvasCache();if(a&&a.hit){s.save();var n=this.getAbsoluteTransform(e).getMatrix();s.transform(n[0],n[1],n[2],n[3],n[4],n[5]),this._drawCachedHitCanvas(s),s.restore()}else this._drawChildren("drawHit",r,e);return this}_drawChildren(t,e,i,r){var s,a=e&&e.getContext(),n=this.clipWidth(),o=this.clipHeight(),h=this.clipFunc(),l="number"==typeof n&&"number"==typeof o||h;const d=i===this;if(l){a.save();var c=this.getAbsoluteTransform(i),u=c.getMatrix();let t;if(a.transform(u[0],u[1],u[2],u[3],u[4],u[5]),a.beginPath(),h)t=h.call(this,a,this);else{var g=this.clipX(),p=this.clipY();a.rect(g||0,p||0,n,o)}a.clip.apply(a,t),u=c.copy().invert().getMatrix(),a.transform(u[0],u[1],u[2],u[3],u[4],u[5])}var m=!d&&"source-over"!==this.globalCompositeOperation()&&"drawScene"===t;m&&(a.save(),a._applyGlobalCompositeOperation(this)),null===(s=this.children)||void 0===s||s.forEach((function(s){s[t](e,i,r)})),m&&a.restore(),l&&a.restore()}getClientRect(t={}){var e,i,r,s,a,n=t.skipTransform,o=t.relativeTo,h={x:1/0,y:1/0,width:0,height:0},l=this;null===(e=this.children)||void 0===e||e.forEach((function(e){if(e.visible()){var n=e.getClientRect({relativeTo:l,skipShadow:t.skipShadow,skipStroke:t.skipStroke});0===n.width&&0===n.height||(void 0===i?(i=n.x,r=n.y,s=n.x+n.width,a=n.y+n.height):(i=Math.min(i,n.x),r=Math.min(r,n.y),s=Math.max(s,n.x+n.width),a=Math.max(a,n.y+n.height)))}}));for(var d=this.find("Shape"),c=!1,u=0;u<d.length;u++){if(d[u]._isVisible(this)){c=!0;break}}return h=c&&void 0!==i?{x:i,y:r,width:s-i,height:a-r}:{x:0,y:0,width:0,height:0},n?h:this._transformedRect(h,o)}}Bt.Container=Xt,Ht.Factory.addComponentsGetterSetter(Xt,"clip",["x","y","width","height"]),Ht.Factory.addGetterSetter(Xt,"clipX",void 0,(0,Yt.getNumberValidator)()),Ht.Factory.addGetterSetter(Xt,"clipY",void 0,(0,Yt.getNumberValidator)()),Ht.Factory.addGetterSetter(Xt,"clipWidth",void 0,(0,Yt.getNumberValidator)()),Ht.Factory.addGetterSetter(Xt,"clipHeight",void 0,(0,Yt.getNumberValidator)()),Ht.Factory.addGetterSetter(Xt,"clipFunc");var qt={},Jt={};Object.defineProperty(Jt,"__esModule",{value:!0}),Jt.releaseCapture=Jt.setPointerCapture=Jt.hasPointerCapture=Jt.createEvent=Jt.getCapturedShape=void 0;const Zt=Q,$t=new Map,Qt=void 0!==Zt.Konva._global.PointerEvent;function te(t){return{evt:t,pointerId:t.pointerId}}function ee(t,e){const i=$t.get(t);if(!i)return;const r=i.getStage();r&&r.content,$t.delete(t),Qt&&i._fire("lostpointercapture",te(new PointerEvent("lostpointercapture")))}Jt.getCapturedShape=function(t){return $t.get(t)},Jt.createEvent=te,Jt.hasPointerCapture=function(t,e){return $t.get(t)===e},Jt.setPointerCapture=function(t,e){ee(t),e.getStage()&&($t.set(t,e),Qt&&e._fire("gotpointercapture",te(new PointerEvent("gotpointercapture"))))},Jt.releaseCapture=ee,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Stage=t.stages=void 0;const e=tt,i=it,r=Bt,s=Q,a=ot,n=wt,o=Q,h=Jt;var l="mouseleave",d="mouseover",c="mouseenter",u="mousemove",g="mousedown",p="mouseup",m="pointermove",f="pointerdown",v="pointerup",_="pointercancel",y="pointerout",w="pointerleave",b="pointerover",x="pointerenter",S="contextmenu",C="touchstart",P="touchend",k="touchmove",E="touchcancel",A="wheel",T=[[c,"_pointerenter"],[g,"_pointerdown"],[u,"_pointermove"],[p,"_pointerup"],[l,"_pointerleave"],[C,"_pointerdown"],[k,"_pointermove"],[P,"_pointerup"],[E,"_pointercancel"],[d,"_pointerover"],[A,"_wheel"],[S,"_contextmenu"],[f,"_pointerdown"],[m,"_pointermove"],[v,"_pointerup"],[_,"_pointercancel"],["lostpointercapture","_lostpointercapture"]];const M={mouse:{[y]:"mouseout",[w]:l,[b]:d,[x]:c,[m]:u,[f]:g,[v]:p,[_]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[y]:"touchout",[w]:"touchleave",[b]:"touchover",[x]:"touchenter",[m]:k,[f]:C,[v]:P,[_]:E,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[y]:y,[w]:w,[b]:b,[x]:x,[m]:m,[f]:f,[v]:v,[_]:_,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},F=t=>t.indexOf("pointer")>=0?"pointer":t.indexOf("touch")>=0?"touch":"mouse",O=t=>{const e=F(t);return"pointer"===e?s.Konva.pointerEventsEnabled&&M.pointer:"touch"===e?M.touch:"mouse"===e?M.mouse:void 0};function R(t={}){return(t.clipFunc||t.clipWidth||t.clipHeight)&&e.Util.warn("Stage does not support clipping. Please use clip for Layers or Groups."),t}t.stages=[];class I extends r.Container{constructor(e){super(R(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),t.stages.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",(()=>{R(this.attrs)})),this._checkVisibility()}_validateAdd(t){const i="Layer"===t.getType(),r="FastLayer"===t.getType();i||r||e.Util.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const t=this.visible()?"":"none";this.content.style.display=t}setContainer(t){if("string"==typeof t){if("."===t.charAt(0)){var e=t.slice(1);t=document.getElementsByClassName(e)[0]}else{var i;i="#"!==t.charAt(0)?t:t.slice(1),t=document.getElementById(i)}if(!t)throw"Can not find container in document with id "+i}return this._setAttr("container",t),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),t.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){var t,e=this.children,i=e.length;for(t=0;t<i;t++)e[t].clear();return this}clone(t){return t||(t={}),t.container="undefined"!=typeof document&&document.createElement("div"),r.Container.prototype.clone.call(this,t)}destroy(){super.destroy();var i=this.content;i&&e.Util._isInDocument(i)&&this.container().removeChild(i);var r=t.stages.indexOf(this);return r>-1&&t.stages.splice(r,1),e.Util.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const t=this._pointerPositions[0]||this._changedPointerPositions[0];return t?{x:t.x,y:t.y}:(e.Util.warn("Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);"),null)}_getPointerById(t){return this._pointerPositions.find((e=>e.id===t))}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(t){(t=t||{}).x=t.x||0,t.y=t.y||0,t.width=t.width||this.width(),t.height=t.height||this.height();var e=new a.SceneCanvas({width:t.width,height:t.height,pixelRatio:t.pixelRatio||1}),i=e.getContext()._context,r=this.children;return(t.x||t.y)&&i.translate(-1*t.x,-1*t.y),r.forEach((function(e){if(e.isVisible()){var r=e._toKonvaCanvas(t);i.drawImage(r._canvas,t.x,t.y,r.getWidth()/r.getPixelRatio(),r.getHeight()/r.getPixelRatio())}})),e}getIntersection(t){if(!t)return null;var e,i=this.children;for(e=i.length-1;e>=0;e--){const r=i[e].getIntersection(t);if(r)return r}return null}_resizeDOM(){var t=this.width(),e=this.height();this.content&&(this.content.style.width=t+"px",this.content.style.height=e+"px"),this.bufferCanvas.setSize(t,e),this.bufferHitCanvas.setSize(t,e),this.children.forEach((i=>{i.setSize({width:t,height:e}),i.draw()}))}add(t,...i){if(arguments.length>1){for(var r=0;r<arguments.length;r++)this.add(arguments[r]);return this}super.add(t);var a=this.children.length;return a>5&&e.Util.warn("The stage has "+a+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),t.setSize({width:this.width(),height:this.height()}),t.draw(),s.Konva.isBrowser&&this.content.appendChild(t.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(t){return h.hasPointerCapture(t,this)}setPointerCapture(t){h.setPointerCapture(t,this)}releaseCapture(t){h.releaseCapture(t,this)}getLayers(){return this.children}_bindContentEvents(){s.Konva.isBrowser&&T.forEach((([t,e])=>{this.content.addEventListener(t,(t=>{this[e](t)}),{passive:!1})}))}_pointerenter(t){this.setPointersPositions(t);const e=O(t.type);e&&this._fire(e.pointerenter,{evt:t,target:this,currentTarget:this})}_pointerover(t){this.setPointersPositions(t);const e=O(t.type);e&&this._fire(e.pointerover,{evt:t,target:this,currentTarget:this})}_getTargetShape(t){let e=this[t+"targetShape"];return e&&!e.getStage()&&(e=null),e}_pointerleave(t){const e=O(t.type),i=F(t.type);if(e){this.setPointersPositions(t);var r=this._getTargetShape(i),a=!(s.Konva.isDragging()||s.Konva.isTransforming())||s.Konva.hitOnDragEnabled;r&&a?(r._fireAndBubble(e.pointerout,{evt:t}),r._fireAndBubble(e.pointerleave,{evt:t}),this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this[i+"targetShape"]=null):a&&(this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this._fire(e.pointerout,{evt:t,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}}_pointerdown(t){const e=O(t.type),i=F(t.type);if(e){this.setPointersPositions(t);var r=!1;this._changedPointerPositions.forEach((a=>{var o=this.getIntersection(a);if(n.DD.justDragged=!1,s.Konva["_"+i+"ListenClick"]=!0,!o||!o.isListening())return;s.Konva.capturePointerEventsEnabled&&o.setPointerCapture(a.id),this[i+"ClickStartShape"]=o,o._fireAndBubble(e.pointerdown,{evt:t,pointerId:a.id}),r=!0;const h=t.type.indexOf("touch")>=0;o.preventDefault()&&t.cancelable&&h&&t.preventDefault()})),r||this._fire(e.pointerdown,{evt:t,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}}_pointermove(t){const e=O(t.type),i=F(t.type);if(!e)return;if(s.Konva.isDragging()&&n.DD.node.preventDefault()&&t.cancelable&&t.preventDefault(),this.setPointersPositions(t),!(!(s.Konva.isDragging()||s.Konva.isTransforming())||s.Konva.hitOnDragEnabled))return;var r={};let a=!1;var o=this._getTargetShape(i);this._changedPointerPositions.forEach((s=>{const n=h.getCapturedShape(s.id)||this.getIntersection(s),l=s.id,d={evt:t,pointerId:l};var c=o!==n;if(c&&o&&(o._fireAndBubble(e.pointerout,{...d},n),o._fireAndBubble(e.pointerleave,{...d},n)),n){if(r[n._id])return;r[n._id]=!0}n&&n.isListening()?(a=!0,c&&(n._fireAndBubble(e.pointerover,{...d},o),n._fireAndBubble(e.pointerenter,{...d},o),this[i+"targetShape"]=n),n._fireAndBubble(e.pointermove,{...d})):o&&(this._fire(e.pointerover,{evt:t,target:this,currentTarget:this,pointerId:l}),this[i+"targetShape"]=null)})),a||this._fire(e.pointermove,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(t){const e=O(t.type),i=F(t.type);if(!e)return;this.setPointersPositions(t);const r=this[i+"ClickStartShape"],a=this[i+"ClickEndShape"];var o={};let l=!1;this._changedPointerPositions.forEach((d=>{const c=h.getCapturedShape(d.id)||this.getIntersection(d);if(c){if(c.releaseCapture(d.id),o[c._id])return;o[c._id]=!0}const u=d.id,g={evt:t,pointerId:u};let p=!1;s.Konva["_"+i+"InDblClickWindow"]?(p=!0,clearTimeout(this[i+"DblTimeout"])):n.DD.justDragged||(s.Konva["_"+i+"InDblClickWindow"]=!0,clearTimeout(this[i+"DblTimeout"])),this[i+"DblTimeout"]=setTimeout((function(){s.Konva["_"+i+"InDblClickWindow"]=!1}),s.Konva.dblClickWindow),c&&c.isListening()?(l=!0,this[i+"ClickEndShape"]=c,c._fireAndBubble(e.pointerup,{...g}),s.Konva["_"+i+"ListenClick"]&&r&&r===c&&(c._fireAndBubble(e.pointerclick,{...g}),p&&a&&a===c&&c._fireAndBubble(e.pointerdblclick,{...g}))):(this[i+"ClickEndShape"]=null,s.Konva["_"+i+"ListenClick"]&&this._fire(e.pointerclick,{evt:t,target:this,currentTarget:this,pointerId:u}),p&&this._fire(e.pointerdblclick,{evt:t,target:this,currentTarget:this,pointerId:u}))})),l||this._fire(e.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),s.Konva["_"+i+"ListenClick"]=!1,t.cancelable&&"touch"!==i&&t.preventDefault()}_contextmenu(t){this.setPointersPositions(t);var e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(S,{evt:t}):this._fire(S,{evt:t,target:this,currentTarget:this})}_wheel(t){this.setPointersPositions(t);var e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(A,{evt:t}):this._fire(A,{evt:t,target:this,currentTarget:this})}_pointercancel(t){this.setPointersPositions(t);const e=h.getCapturedShape(t.pointerId)||this.getIntersection(this.getPointerPosition());e&&e._fireAndBubble(v,h.createEvent(t)),h.releaseCapture(t.pointerId)}_lostpointercapture(t){h.releaseCapture(t.pointerId)}setPointersPositions(t){var i=this._getContentPosition(),r=null,s=null;void 0!==(t=t||window.event).touches?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(t.touches,(t=>{this._pointerPositions.push({id:t.identifier,x:(t.clientX-i.left)/i.scaleX,y:(t.clientY-i.top)/i.scaleY})})),Array.prototype.forEach.call(t.changedTouches||t.touches,(t=>{this._changedPointerPositions.push({id:t.identifier,x:(t.clientX-i.left)/i.scaleX,y:(t.clientY-i.top)/i.scaleY})}))):(r=(t.clientX-i.left)/i.scaleX,s=(t.clientY-i.top)/i.scaleY,this.pointerPos={x:r,y:s},this._pointerPositions=[{x:r,y:s,id:e.Util._getFirstPointerId(t)}],this._changedPointerPositions=[{x:r,y:s,id:e.Util._getFirstPointerId(t)}])}_setPointerPosition(t){e.Util.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(t)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};var t=this.content.getBoundingClientRect();return{top:t.top,left:t.left,scaleX:t.width/this.content.clientWidth||1,scaleY:t.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new a.SceneCanvas({width:this.width(),height:this.height()}),this.bufferHitCanvas=new a.HitCanvas({pixelRatio:1,width:this.width(),height:this.height()}),s.Konva.isBrowser){var t=this.container();if(!t)throw"Stage has no container. A container is required.";t.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),t.appendChild(this.content),this._resizeDOM()}}cache(){return e.Util.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach((function(t){t.batchDraw()})),this}}t.Stage=I,I.prototype.nodeType="Stage",(0,o._registerNode)(I),i.Factory.addGetterSetter(I,"container")}(qt);var ie={},re={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Shape=t.shapes=void 0;const e=Q,i=tt,r=it,s=et,a=rt,n=Q,o=Jt;var h="hasShadow",l="shadowRGBA",d="patternImage",c="linearGradient",u="radialGradient";let g;function p(){return g||(g=i.Util.createCanvasElement().getContext("2d"),g)}t.shapes={};class m extends s.Node{constructor(e){let r;for(super(e);r=i.Util.getRandomColor(),!r||r in t.shapes;);this.colorKey=r,t.shapes[r]=this}getContext(){return i.Util.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return i.Util.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(h,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&0!==this.shadowOpacity()&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(d,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const t=p().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){const r=new i.Transform;r.translate(this.fillPatternX(),this.fillPatternY()),r.rotate(e.Konva.getAngle(this.fillPatternRotation())),r.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),r.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const s=r.getMatrix(),a="undefined"==typeof DOMMatrix?{a:s[0],b:s[1],c:s[2],d:s[3],e:s[4],f:s[5]}:new DOMMatrix(s);t.setTransform(a)}return t}}_getLinearGradient(){return this._getCache(c,this.__getLinearGradient)}__getLinearGradient(){var t=this.fillLinearGradientColorStops();if(t){for(var e=p(),i=this.fillLinearGradientStartPoint(),r=this.fillLinearGradientEndPoint(),s=e.createLinearGradient(i.x,i.y,r.x,r.y),a=0;a<t.length;a+=2)s.addColorStop(t[a],t[a+1]);return s}}_getRadialGradient(){return this._getCache(u,this.__getRadialGradient)}__getRadialGradient(){var t=this.fillRadialGradientColorStops();if(t){for(var e=p(),i=this.fillRadialGradientStartPoint(),r=this.fillRadialGradientEndPoint(),s=e.createRadialGradient(i.x,i.y,this.fillRadialGradientStartRadius(),r.x,r.y,this.fillRadialGradientEndRadius()),a=0;a<t.length;a+=2)s.addColorStop(t[a],t[a+1]);return s}}getShadowRGBA(){return this._getCache(l,this._getShadowRGBA)}_getShadowRGBA(){if(this.hasShadow()){var t=i.Util.colorToRGBA(this.shadowColor());return t?"rgba("+t.r+","+t.g+","+t.b+","+t.a*(this.shadowOpacity()||1)+")":void 0}}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],(()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops())))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],(()=>this.strokeEnabled()&&this.strokeWidth()&&!(!this.stroke()&&!this.strokeLinearGradientColorStops())))}hasHitStroke(){const t=this.hitStrokeWidth();return"auto"===t?this.hasStroke():this.strokeEnabled()&&!!t}intersects(t){var e=this.getStage();if(!e)return!1;const i=e.bufferHitCanvas;i.getContext().clear(),this.drawHit(i,void 0,!0);return i.context.getImageData(Math.round(t.x),Math.round(t.y),1,1).data[3]>0}destroy(){return s.Node.prototype.destroy.call(this),delete t.shapes[this.colorKey],delete this.colorKey,this}_useBufferCanvas(t){var e;if(!(null===(e=this.attrs.perfectDrawEnabled)||void 0===e||e))return!1;const i=t||this.hasFill(),r=this.hasStroke(),s=1!==this.getAbsoluteOpacity();if(i&&r&&s)return!0;const a=this.hasShadow(),n=this.shadowForStrokeEnabled();return!!(i&&r&&a&&n)}setStrokeHitEnabled(t){i.Util.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),t?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return 0!==this.hitStrokeWidth()}getSelfRect(){var t=this.size();return{x:this._centroid?-t.width/2:0,y:this._centroid?-t.height/2:0,width:t.width,height:t.height}}getClientRect(t={}){const e=t.skipTransform,i=t.relativeTo,r=this.getSelfRect(),s=!t.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,a=r.width+s,n=r.height+s,o=!t.skipShadow&&this.hasShadow(),h=o?this.shadowOffsetX():0,l=o?this.shadowOffsetY():0,d=a+Math.abs(h),c=n+Math.abs(l),u=o&&this.shadowBlur()||0,g={width:d+2*u,height:c+2*u,x:-(s/2+u)+Math.min(h,0)+r.x,y:-(s/2+u)+Math.min(l,0)+r.y};return e?g:this._transformedRect(g,i)}drawScene(t,e,i){var r,s,a=this.getLayer(),n=t||a.getCanvas(),o=n.getContext(),h=this._getCanvasCache(),l=this.getSceneFunc(),d=this.hasShadow(),c=n.isCache,u=e===this;if(!this.isVisible()&&!u)return this;if(h){o.save();var g=this.getAbsoluteTransform(e).getMatrix();return o.transform(g[0],g[1],g[2],g[3],g[4],g[5]),this._drawCachedSceneCanvas(o),o.restore(),this}if(!l)return this;if(o.save(),this._useBufferCanvas()&&!c){r=this.getStage();const t=i||r.bufferCanvas;(s=t.getContext()).clear(),s.save(),s._applyLineJoin(this);var p=this.getAbsoluteTransform(e).getMatrix();s.transform(p[0],p[1],p[2],p[3],p[4],p[5]),l.call(this,s,this),s.restore();var m=t.pixelRatio;d&&o._applyShadow(this),o._applyOpacity(this),o._applyGlobalCompositeOperation(this),o.drawImage(t._canvas,0,0,t.width/m,t.height/m)}else{if(o._applyLineJoin(this),!u){p=this.getAbsoluteTransform(e).getMatrix();o.transform(p[0],p[1],p[2],p[3],p[4],p[5]),o._applyOpacity(this),o._applyGlobalCompositeOperation(this)}d&&o._applyShadow(this),l.call(this,o,this)}return o.restore(),this}drawHit(t,e,r=!1){if(!this.shouldDrawHit(e,r))return this;var s=this.getLayer(),a=t||s.hitCanvas,n=a&&a.getContext(),o=this.hitFunc()||this.sceneFunc(),h=this._getCanvasCache(),l=h&&h.hit;if(this.colorKey||i.Util.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),l){n.save();var d=this.getAbsoluteTransform(e).getMatrix();return n.transform(d[0],d[1],d[2],d[3],d[4],d[5]),this._drawCachedHitCanvas(n),n.restore(),this}if(!o)return this;n.save(),n._applyLineJoin(this);if(!(this===e)){var c=this.getAbsoluteTransform(e).getMatrix();n.transform(c[0],c[1],c[2],c[3],c[4],c[5])}return o.call(this,n,this),n.restore(),this}drawHitFromCache(t=0){var e,r,s,a,n,o=this._getCanvasCache(),h=this._getCachedSceneCanvas(),l=o.hit,d=l.getContext(),c=l.getWidth(),u=l.getHeight();d.clear(),d.drawImage(h._canvas,0,0,c,u);try{for(s=(r=(e=d.getImageData(0,0,c,u)).data).length,a=i.Util._hexToRgb(this.colorKey),n=0;n<s;n+=4)r[n+3]>t?(r[n]=a.r,r[n+1]=a.g,r[n+2]=a.b,r[n+3]=255):r[n+3]=0;d.putImageData(e,0,0)}catch(t){i.Util.error("Unable to draw hit graph from cached scene canvas. "+t.message)}return this}hasPointerCapture(t){return o.hasPointerCapture(t,this)}setPointerCapture(t){o.setPointerCapture(t,this)}releaseCapture(t){o.releaseCapture(t,this)}}t.Shape=m,m.prototype._fillFunc=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},m.prototype._strokeFunc=function(t){t.stroke()},m.prototype._fillFuncHit=function(t){t.fill()},m.prototype._strokeFuncHit=function(t){t.stroke()},m.prototype._centroid=!1,m.prototype.nodeType="Shape",(0,n._registerNode)(m),m.prototype.eventListeners={},m.prototype.on.call(m.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(h)})),m.prototype.on.call(m.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(l)})),m.prototype.on.call(m.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",(function(){this._clearCache(d)})),m.prototype.on.call(m.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",(function(){this._clearCache(c)})),m.prototype.on.call(m.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",(function(){this._clearCache(u)})),r.Factory.addGetterSetter(m,"stroke",void 0,(0,a.getStringOrGradientValidator)()),r.Factory.addGetterSetter(m,"strokeWidth",2,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(m,"fillAfterStrokeEnabled",!1),r.Factory.addGetterSetter(m,"hitStrokeWidth","auto",(0,a.getNumberOrAutoValidator)()),r.Factory.addGetterSetter(m,"strokeHitEnabled",!0,(0,a.getBooleanValidator)()),r.Factory.addGetterSetter(m,"perfectDrawEnabled",!0,(0,a.getBooleanValidator)()),r.Factory.addGetterSetter(m,"shadowForStrokeEnabled",!0,(0,a.getBooleanValidator)()),r.Factory.addGetterSetter(m,"lineJoin"),r.Factory.addGetterSetter(m,"lineCap"),r.Factory.addGetterSetter(m,"sceneFunc"),r.Factory.addGetterSetter(m,"hitFunc"),r.Factory.addGetterSetter(m,"dash"),r.Factory.addGetterSetter(m,"dashOffset",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(m,"shadowColor",void 0,(0,a.getStringValidator)()),r.Factory.addGetterSetter(m,"shadowBlur",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(m,"shadowOpacity",1,(0,a.getNumberValidator)()),r.Factory.addComponentsGetterSetter(m,"shadowOffset",["x","y"]),r.Factory.addGetterSetter(m,"shadowOffsetX",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(m,"shadowOffsetY",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(m,"fillPatternImage"),r.Factory.addGetterSetter(m,"fill",void 0,(0,a.getStringOrGradientValidator)()),r.Factory.addGetterSetter(m,"fillPatternX",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(m,"fillPatternY",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(m,"fillLinearGradientColorStops"),r.Factory.addGetterSetter(m,"strokeLinearGradientColorStops"),r.Factory.addGetterSetter(m,"fillRadialGradientStartRadius",0),r.Factory.addGetterSetter(m,"fillRadialGradientEndRadius",0),r.Factory.addGetterSetter(m,"fillRadialGradientColorStops"),r.Factory.addGetterSetter(m,"fillPatternRepeat","repeat"),r.Factory.addGetterSetter(m,"fillEnabled",!0),r.Factory.addGetterSetter(m,"strokeEnabled",!0),r.Factory.addGetterSetter(m,"shadowEnabled",!0),r.Factory.addGetterSetter(m,"dashEnabled",!0),r.Factory.addGetterSetter(m,"strokeScaleEnabled",!0),r.Factory.addGetterSetter(m,"fillPriority","color"),r.Factory.addComponentsGetterSetter(m,"fillPatternOffset",["x","y"]),r.Factory.addGetterSetter(m,"fillPatternOffsetX",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(m,"fillPatternOffsetY",0,(0,a.getNumberValidator)()),r.Factory.addComponentsGetterSetter(m,"fillPatternScale",["x","y"]),r.Factory.addGetterSetter(m,"fillPatternScaleX",1,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(m,"fillPatternScaleY",1,(0,a.getNumberValidator)()),r.Factory.addComponentsGetterSetter(m,"fillLinearGradientStartPoint",["x","y"]),r.Factory.addComponentsGetterSetter(m,"strokeLinearGradientStartPoint",["x","y"]),r.Factory.addGetterSetter(m,"fillLinearGradientStartPointX",0),r.Factory.addGetterSetter(m,"strokeLinearGradientStartPointX",0),r.Factory.addGetterSetter(m,"fillLinearGradientStartPointY",0),r.Factory.addGetterSetter(m,"strokeLinearGradientStartPointY",0),r.Factory.addComponentsGetterSetter(m,"fillLinearGradientEndPoint",["x","y"]),r.Factory.addComponentsGetterSetter(m,"strokeLinearGradientEndPoint",["x","y"]),r.Factory.addGetterSetter(m,"fillLinearGradientEndPointX",0),r.Factory.addGetterSetter(m,"strokeLinearGradientEndPointX",0),r.Factory.addGetterSetter(m,"fillLinearGradientEndPointY",0),r.Factory.addGetterSetter(m,"strokeLinearGradientEndPointY",0),r.Factory.addComponentsGetterSetter(m,"fillRadialGradientStartPoint",["x","y"]),r.Factory.addGetterSetter(m,"fillRadialGradientStartPointX",0),r.Factory.addGetterSetter(m,"fillRadialGradientStartPointY",0),r.Factory.addComponentsGetterSetter(m,"fillRadialGradientEndPoint",["x","y"]),r.Factory.addGetterSetter(m,"fillRadialGradientEndPointX",0),r.Factory.addGetterSetter(m,"fillRadialGradientEndPointY",0),r.Factory.addGetterSetter(m,"fillPatternRotation",0),r.Factory.addGetterSetter(m,"fillRule",void 0,(0,a.getStringValidator)()),r.Factory.backCompat(m,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"})}(re),Object.defineProperty(ie,"__esModule",{value:!0}),ie.Layer=void 0;const se=tt,ae=Bt,ne=et,oe=it,he=ot,le=rt,de=re,ce=Q;var ue=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],ge=ue.length;class pe extends ae.Container{constructor(t){super(t),this.canvas=new he.SceneCanvas,this.hitCanvas=new he.HitCanvas({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(t){return this.getContext().clear(t),this.getHitCanvas().getContext().clear(t),this}setZIndex(t){super.setZIndex(t);var e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),t<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[t+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){ne.Node.prototype.moveToTop.call(this);var t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!ne.Node.prototype.moveUp.call(this))return!1;var t=this.getStage();return!(!t||!t.content)&&(t.content.removeChild(this.getNativeCanvasElement()),this.index<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[this.index+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(ne.Node.prototype.moveDown.call(this)){var t=this.getStage();if(t){var e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(ne.Node.prototype.moveToBottom.call(this)){var t=this.getStage();if(t){var e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){var t=this.getNativeCanvasElement();return ne.Node.prototype.remove.call(this),t&&t.parentNode&&se.Util._isInDocument(t)&&t.parentNode.removeChild(t),this}getStage(){return this.parent}setSize({width:t,height:e}){return this.canvas.setSize(t,e),this.hitCanvas.setSize(t,e),this._setSmoothEnabled(),this}_validateAdd(t){var e=t.getType();"Group"!==e&&"Shape"!==e&&se.Util.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(t){return(t=t||{}).width=t.width||this.getWidth(),t.height=t.height||this.getHeight(),t.x=void 0!==t.x?t.x:this.x(),t.y=void 0!==t.y?t.y:this.y(),ne.Node.prototype._toKonvaCanvas.call(this,t)}_checkVisibility(){const t=this.visible();this.canvas._canvas.style.display=t?"block":"none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){se.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){se.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,se.Util.requestAnimFrame((()=>{this.draw(),this._waitingForDraw=!1}))),this}getIntersection(t){if(!this.isListening()||!this.isVisible())return null;for(var e=1,i=!1;;){for(let r=0;r<ge;r++){const s=ue[r],a=this._getIntersection({x:t.x+s.x*e,y:t.y+s.y*e}),n=a.shape;if(n)return n;if(i=!!a.antialiased,!a.antialiased)break}if(!i)return null;e+=1}}_getIntersection(t){const e=this.hitCanvas.pixelRatio,i=this.hitCanvas.context.getImageData(Math.round(t.x*e),Math.round(t.y*e),1,1).data,r=i[3];if(255===r){const t=se.Util._rgbToHex(i[0],i[1],i[2]),e=de.shapes["#"+t];return e?{shape:e}:{antialiased:!0}}return r>0?{antialiased:!0}:{}}drawScene(t,e){var i=this.getLayer(),r=t||i&&i.getCanvas();return this._fire("beforeDraw",{node:this}),this.clearBeforeDraw()&&r.getContext().clear(),ae.Container.prototype.drawScene.call(this,r,e),this._fire("draw",{node:this}),this}drawHit(t,e){var i=this.getLayer(),r=t||i&&i.hitCanvas;return i&&i.clearBeforeDraw()&&i.getHitCanvas().getContext().clear(),ae.Container.prototype.drawHit.call(this,r,e),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(t){se.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(t)}getHitGraphEnabled(t){return se.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(this.parent&&this.parent.content){var t=this.parent;!!this.hitCanvas._canvas.parentNode?t.content.removeChild(this.hitCanvas._canvas):t.content.appendChild(this.hitCanvas._canvas)}}destroy(){return se.Util.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}}ie.Layer=pe,pe.prototype.nodeType="Layer",(0,ce._registerNode)(pe),oe.Factory.addGetterSetter(pe,"imageSmoothingEnabled",!0),oe.Factory.addGetterSetter(pe,"clearBeforeDraw",!0),oe.Factory.addGetterSetter(pe,"hitGraphEnabled",!0,(0,le.getBooleanValidator)());var me={};Object.defineProperty(me,"__esModule",{value:!0}),me.FastLayer=void 0;const fe=tt,ve=ie,_e=Q;class ye extends ve.Layer{constructor(t){super(t),this.listening(!1),fe.Util.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}}me.FastLayer=ye,ye.prototype.nodeType="FastLayer",(0,_e._registerNode)(ye);var we={};Object.defineProperty(we,"__esModule",{value:!0}),we.Group=void 0;const be=tt,xe=Bt,Se=Q;class Ce extends xe.Container{_validateAdd(t){var e=t.getType();"Group"!==e&&"Shape"!==e&&be.Util.throw("You may only add groups and shapes to groups.")}}we.Group=Ce,Ce.prototype.nodeType="Group",(0,Se._registerNode)(Ce);var Pe={};Object.defineProperty(Pe,"__esModule",{value:!0}),Pe.Animation=void 0;const ke=Q,Ee=tt,Ae=ke.glob.performance&&ke.glob.performance.now?function(){return ke.glob.performance.now()}:function(){return(new Date).getTime()};class Te{constructor(t,e){this.id=Te.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:Ae(),frameRate:0},this.func=t,this.setLayers(e)}setLayers(t){let e=[];return t&&(e=Array.isArray(t)?t:[t]),this.layers=e,this}getLayers(){return this.layers}addLayer(t){const e=this.layers,i=e.length;for(let r=0;r<i;r++)if(e[r]._id===t._id)return!1;return this.layers.push(t),!0}isRunning(){const t=Te.animations,e=t.length;for(let i=0;i<e;i++)if(t[i].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=Ae(),Te._addAnimation(this),this}stop(){return Te._removeAnimation(this),this}_updateFrameObject(t){this.frame.timeDiff=t-this.frame.lastTime,this.frame.lastTime=t,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(t){this.animations.push(t),this._handleAnimation()}static _removeAnimation(t){const e=t.id,i=this.animations,r=i.length;for(let t=0;t<r;t++)if(i[t].id===e){this.animations.splice(t,1);break}}static _runFrames(){const t={},e=this.animations;for(let i=0;i<e.length;i++){const r=e[i],s=r.layers,a=r.func;r._updateFrameObject(Ae());const n=s.length;let o;if(o=!a||!1!==a.call(r,r.frame),o)for(let e=0;e<n;e++){const i=s[e];void 0!==i._id&&(t[i._id]=i)}}for(let e in t)t.hasOwnProperty(e)&&t[e].batchDraw()}static _animationLoop(){const t=Te;t.animations.length?(t._runFrames(),Ee.Util.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,Ee.Util.requestAnimFrame(this._animationLoop))}}Pe.Animation=Te,Te.animations=[],Te.animIdCounter=0,Te.animRunning=!1;var Me={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Easings=t.Tween=void 0;const e=tt,i=Pe,r=et,s=Q;var a={node:1,duration:1,easing:1,onFinish:1,yoyo:1},n=0,o=["fill","stroke","shadowColor"];class h{constructor(t,e,i,r,s,a,n){this.prop=t,this.propFunc=e,this.begin=r,this._pos=r,this.duration=a,this._change=0,this.prevPos=0,this.yoyo=n,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=i,this._change=s-this.begin,this.pause()}fire(t){var e=this[t];e&&e()}setTime(t){t>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():t<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=t,this.update())}getTime(){return this._time}setPosition(t){this.prevPos=this._pos,this.propFunc(t),this._pos=t}getPosition(t){return void 0===t&&(t=this._time),this.func(t,this.begin,this._change,this.duration)}play(){this.state=2,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=3,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(t){this.pause(),this._time=t,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){var t=this.getTimer()-this._startTime;2===this.state?this.setTime(t):3===this.state&&this.setTime(this.duration-t)}pause(){this.state=1,this.fire("onPause")}getTimer(){return(new Date).getTime()}}class l{constructor(r){var o,d,c=this,u=r.node,g=u._id,p=r.easing||t.Easings.Linear,m=!!r.yoyo;o=void 0===r.duration?.3:0===r.duration?.001:r.duration,this.node=u,this._id=n++;var f=u.getLayer()||(u instanceof s.Konva.Stage?u.getLayers():null);for(d in f||e.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new i.Animation((function(){c.tween.onEnterFrame()}),f),this.tween=new h(d,(function(t){c._tweenFunc(t)}),p,0,1,1e3*o,m),this._addListeners(),l.attrs[g]||(l.attrs[g]={}),l.attrs[g][this._id]||(l.attrs[g][this._id]={}),l.tweens[g]||(l.tweens[g]={}),r)void 0===a[d]&&this._addAttr(d,r[d]);this.reset(),this.onFinish=r.onFinish,this.onReset=r.onReset,this.onUpdate=r.onUpdate}_addAttr(t,i){var r,s,a,n,h,d,c,u,g=this.node,p=g._id;if((a=l.tweens[p][t])&&delete l.attrs[p][a][t],r=g.getAttr(t),e.Util._isArray(i))if(s=[],h=Math.max(i.length,r.length),"points"===t&&i.length!==r.length&&(i.length>r.length?(c=r,r=e.Util._prepareArrayForTween(r,i,g.closed())):(d=i,i=e.Util._prepareArrayForTween(i,r,g.closed()))),0===t.indexOf("fill"))for(n=0;n<h;n++)if(n%2==0)s.push(i[n]-r[n]);else{var m=e.Util.colorToRGBA(r[n]);u=e.Util.colorToRGBA(i[n]),r[n]=m,s.push({r:u.r-m.r,g:u.g-m.g,b:u.b-m.b,a:u.a-m.a})}else for(n=0;n<h;n++)s.push(i[n]-r[n]);else-1!==o.indexOf(t)?(r=e.Util.colorToRGBA(r),s={r:(u=e.Util.colorToRGBA(i)).r-r.r,g:u.g-r.g,b:u.b-r.b,a:u.a-r.a}):s=i-r;l.attrs[p][this._id][t]={start:r,diff:s,end:i,trueEnd:d,trueStart:c},l.tweens[p][t]=this._id}_tweenFunc(t){var i,r,s,a,n,h,d,c,u=this.node,g=l.attrs[u._id][this._id];for(i in g){if(s=(r=g[i]).start,a=r.diff,c=r.end,e.Util._isArray(s))if(n=[],d=Math.max(s.length,c.length),0===i.indexOf("fill"))for(h=0;h<d;h++)h%2==0?n.push((s[h]||0)+a[h]*t):n.push("rgba("+Math.round(s[h].r+a[h].r*t)+","+Math.round(s[h].g+a[h].g*t)+","+Math.round(s[h].b+a[h].b*t)+","+(s[h].a+a[h].a*t)+")");else for(h=0;h<d;h++)n.push((s[h]||0)+a[h]*t);else n=-1!==o.indexOf(i)?"rgba("+Math.round(s.r+a.r*t)+","+Math.round(s.g+a.g*t)+","+Math.round(s.b+a.b*t)+","+(s.a+a.a*t)+")":s+a*t;u.setAttr(i,n)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{var t=this.node,e=l.attrs[t._id][this._id];e.points&&e.points.trueEnd&&t.setAttr("points",e.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{var t=this.node,e=l.attrs[t._id][this._id];e.points&&e.points.trueStart&&t.points(e.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(t){return this.tween.seek(1e3*t),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){var t,e=this.node._id,i=this._id,r=l.tweens[e];for(t in this.pause(),r)delete l.tweens[e][t];delete l.attrs[e][i]}}t.Tween=l,l.attrs={},l.tweens={},r.Node.prototype.to=function(t){var e=t.onFinish;t.node=this,t.onFinish=function(){this.destroy(),e&&e()},new l(t).play()},t.Easings={BackEaseIn(t,e,i,r){var s=1.70158;return i*(t/=r)*t*((s+1)*t-s)+e},BackEaseOut(t,e,i,r){var s=1.70158;return i*((t=t/r-1)*t*((s+1)*t+s)+1)+e},BackEaseInOut(t,e,i,r){var s=1.70158;return(t/=r/2)<1?i/2*(t*t*((1+(s*=1.525))*t-s))+e:i/2*((t-=2)*t*((1+(s*=1.525))*t+s)+2)+e},ElasticEaseIn(t,e,i,r,s,a){var n=0;return 0===t?e:1==(t/=r)?e+i:(a||(a=.3*r),!s||s<Math.abs(i)?(s=i,n=a/4):n=a/(2*Math.PI)*Math.asin(i/s),-s*Math.pow(2,10*(t-=1))*Math.sin((t*r-n)*(2*Math.PI)/a)+e)},ElasticEaseOut(t,e,i,r,s,a){var n=0;return 0===t?e:1==(t/=r)?e+i:(a||(a=.3*r),!s||s<Math.abs(i)?(s=i,n=a/4):n=a/(2*Math.PI)*Math.asin(i/s),s*Math.pow(2,-10*t)*Math.sin((t*r-n)*(2*Math.PI)/a)+i+e)},ElasticEaseInOut(t,e,i,r,s,a){var n=0;return 0===t?e:2==(t/=r/2)?e+i:(a||(a=r*(.3*1.5)),!s||s<Math.abs(i)?(s=i,n=a/4):n=a/(2*Math.PI)*Math.asin(i/s),t<1?s*Math.pow(2,10*(t-=1))*Math.sin((t*r-n)*(2*Math.PI)/a)*-.5+e:s*Math.pow(2,-10*(t-=1))*Math.sin((t*r-n)*(2*Math.PI)/a)*.5+i+e)},BounceEaseOut:(t,e,i,r)=>(t/=r)<1/2.75?i*(7.5625*t*t)+e:t<2/2.75?i*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?i*(7.5625*(t-=2.25/2.75)*t+.9375)+e:i*(7.5625*(t-=2.625/2.75)*t+.984375)+e,BounceEaseIn:(e,i,r,s)=>r-t.Easings.BounceEaseOut(s-e,0,r,s)+i,BounceEaseInOut:(e,i,r,s)=>e<s/2?.5*t.Easings.BounceEaseIn(2*e,0,r,s)+i:.5*t.Easings.BounceEaseOut(2*e-s,0,r,s)+.5*r+i,EaseIn:(t,e,i,r)=>i*(t/=r)*t+e,EaseOut:(t,e,i,r)=>-i*(t/=r)*(t-2)+e,EaseInOut:(t,e,i,r)=>(t/=r/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e,StrongEaseIn:(t,e,i,r)=>i*(t/=r)*t*t*t*t+e,StrongEaseOut:(t,e,i,r)=>i*((t=t/r-1)*t*t*t*t+1)+e,StrongEaseInOut:(t,e,i,r)=>(t/=r/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e,Linear:(t,e,i,r)=>i*t/r+e}}(Me),function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Konva=void 0;const e=Q,i=tt,r=et,s=Bt,a=qt,n=ie,o=me,h=we,l=wt,d=re,c=Pe,u=Me,g=ht,p=ot;t.Konva=i.Util._assign(e.Konva,{Util:i.Util,Transform:i.Transform,Node:r.Node,Container:s.Container,Stage:a.Stage,stages:a.stages,Layer:n.Layer,FastLayer:o.FastLayer,Group:h.Group,DD:l.DD,Shape:d.Shape,shapes:d.shapes,Animation:c.Animation,Tween:u.Tween,Easings:u.Easings,Context:g.Context,Canvas:p.Canvas}),t.default=t.Konva}($);var Fe={};Object.defineProperty(Fe,"__esModule",{value:!0}),Fe.Arc=void 0;const Oe=it,Re=re,Ie=Q,De=rt,Le=Q;class Ve extends Re.Shape{_sceneFunc(t){var e=Ie.Konva.getAngle(this.angle()),i=this.clockwise();t.beginPath(),t.arc(0,0,this.outerRadius(),0,e,i),t.arc(0,0,this.innerRadius(),e,0,!i),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}getSelfRect(){const t=this.innerRadius(),e=this.outerRadius(),i=this.clockwise(),r=Ie.Konva.getAngle(i?360-this.angle():this.angle()),s=Math.cos(Math.min(r,Math.PI)),a=Math.sin(Math.min(Math.max(Math.PI,r),3*Math.PI/2)),n=Math.sin(Math.min(r,Math.PI/2)),o=s*(s>0?t:e),h=a*(a>0?t:e),l=n*(n>0?e:t);return{x:o,y:i?-1*l:h,width:1*e-o,height:l-h}}}Fe.Arc=Ve,Ve.prototype._centroid=!0,Ve.prototype.className="Arc",Ve.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,Le._registerNode)(Ve),Oe.Factory.addGetterSetter(Ve,"innerRadius",0,(0,De.getNumberValidator)()),Oe.Factory.addGetterSetter(Ve,"outerRadius",0,(0,De.getNumberValidator)()),Oe.Factory.addGetterSetter(Ve,"angle",0,(0,De.getNumberValidator)()),Oe.Factory.addGetterSetter(Ve,"clockwise",!1,(0,De.getBooleanValidator)());var Ge={},ze={};Object.defineProperty(ze,"__esModule",{value:!0}),ze.Line=void 0;const Ne=it,Ue=re,We=rt,je=Q;function Be(t,e,i,r,s,a,n){var o=Math.sqrt(Math.pow(i-t,2)+Math.pow(r-e,2)),h=Math.sqrt(Math.pow(s-i,2)+Math.pow(a-r,2)),l=n*o/(o+h),d=n*h/(o+h);return[i-l*(s-t),r-l*(a-e),i+d*(s-t),r+d*(a-e)]}function He(t,e){var i,r,s=t.length,a=[];for(i=2;i<s-2;i+=2)r=Be(t[i-2],t[i-1],t[i],t[i+1],t[i+2],t[i+3],e),isNaN(r[0])||(a.push(r[0]),a.push(r[1]),a.push(t[i]),a.push(t[i+1]),a.push(r[2]),a.push(r[3]));return a}class Ke extends Ue.Shape{constructor(t){super(t),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",(function(){this._clearCache("tensionPoints")}))}_sceneFunc(t){var e,i,r,s=this.points(),a=s.length,n=this.tension(),o=this.closed(),h=this.bezier();if(a){if(t.beginPath(),t.moveTo(s[0],s[1]),0!==n&&a>4){for(i=(e=this.getTensionPoints()).length,r=o?0:4,o||t.quadraticCurveTo(e[0],e[1],e[2],e[3]);r<i-2;)t.bezierCurveTo(e[r++],e[r++],e[r++],e[r++],e[r++],e[r++]);o||t.quadraticCurveTo(e[i-2],e[i-1],s[a-2],s[a-1])}else if(h)for(r=2;r<a;)t.bezierCurveTo(s[r++],s[r++],s[r++],s[r++],s[r++],s[r++]);else for(r=2;r<a;r+=2)t.lineTo(s[r],s[r+1]);o?(t.closePath(),t.fillStrokeShape(this)):t.strokeShape(this)}}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():He(this.points(),this.tension())}_getTensionPointsClosed(){var t=this.points(),e=t.length,i=this.tension(),r=Be(t[e-2],t[e-1],t[0],t[1],t[2],t[3],i),s=Be(t[e-4],t[e-3],t[e-2],t[e-1],t[0],t[1],i),a=He(t,i);return[r[2],r[3]].concat(a).concat([s[0],s[1],t[e-2],t[e-1],s[2],s[3],r[0],r[1],t[0],t[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){var t=this.points();if(t.length<4)return{x:t[0]||0,y:t[1]||0,width:0,height:0};for(var e,i,r=(t=0!==this.tension()?[t[0],t[1],...this._getTensionPoints(),t[t.length-2],t[t.length-1]]:this.points())[0],s=t[0],a=t[1],n=t[1],o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],r=Math.min(r,e),s=Math.max(s,e),a=Math.min(a,i),n=Math.max(n,i);return{x:r,y:a,width:s-r,height:n-a}}}ze.Line=Ke,Ke.prototype.className="Line",Ke.prototype._attrsAffectingSize=["points","bezier","tension"],(0,je._registerNode)(Ke),Ne.Factory.addGetterSetter(Ke,"closed",!1),Ne.Factory.addGetterSetter(Ke,"bezier",!1),Ne.Factory.addGetterSetter(Ke,"tension",0,(0,We.getNumberValidator)()),Ne.Factory.addGetterSetter(Ke,"points",[],(0,We.getNumberArrayValidator)());var Ye={},Xe={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.t2length=t.getQuadraticArcLength=t.getCubicArcLength=t.binomialCoefficients=t.cValues=t.tValues=void 0,t.tValues=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],t.cValues=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],t.binomialCoefficients=[[1],[1,1],[1,2,1],[1,3,3,1]];t.getCubicArcLength=(i,r,s)=>{let a,n,o;a=s/2,n=0;for(let s=0;s<20;s++)o=a*t.tValues[20][s]+a,n+=t.cValues[20][s]*e(i,r,o);return a*n};function e(t,e,r){const s=i(1,r,t),a=i(1,r,e),n=s*s+a*a;return Math.sqrt(n)}t.getQuadraticArcLength=(t,e,i)=>{void 0===i&&(i=1);const r=t[0]-2*t[1]+t[2],s=e[0]-2*e[1]+e[2],a=2*t[1]-2*t[0],n=2*e[1]-2*e[0],o=4*(r*r+s*s),h=4*(r*a+s*n),l=a*a+n*n;if(0===o)return i*Math.sqrt(Math.pow(t[2]-t[0],2)+Math.pow(e[2]-e[0],2));const d=h/(2*o),c=i+d,u=l/o-d*d,g=c*c+u>0?Math.sqrt(c*c+u):0,p=d*d+u>0?Math.sqrt(d*d+u):0,m=d+Math.sqrt(d*d+u)!==0?u*Math.log(Math.abs((c+g)/(d+p))):0;return Math.sqrt(o)/2*(c*g-d*p+m)};const i=(e,r,s)=>{const a=s.length-1;let n,o;if(0===a)return 0;if(0===e){o=0;for(let e=0;e<=a;e++)o+=t.binomialCoefficients[a][e]*Math.pow(1-r,a-e)*Math.pow(r,e)*s[e];return o}n=new Array(a);for(let t=0;t<a;t++)n[t]=a*(s[t+1]-s[t]);return i(e-1,r,n)};t.t2length=(t,e,i)=>{let r=1,s=t/e,a=(t-i(s))/e,n=0;for(;r>.001;){const o=i(s+a),h=Math.abs(t-o)/e;if(h<r)r=h,s+=a;else{const n=i(s-a),o=Math.abs(t-n)/e;o<r?(r=o,s-=a):a/=2}if(n++,n>500)break}return s}}(Xe),Object.defineProperty(Ye,"__esModule",{value:!0}),Ye.Path=void 0;const qe=it,Je=re,Ze=Q,$e=Xe;class Qe extends Je.Shape{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",(function(){this._readDataAttribute()}))}_readDataAttribute(){this.dataArray=Qe.parsePathData(this.data()),this.pathLength=Qe.getPathLength(this.dataArray)}_sceneFunc(t){var e=this.dataArray;t.beginPath();for(var i=!1,r=0;r<e.length;r++){var s=e[r].command,a=e[r].points;switch(s){case"L":t.lineTo(a[0],a[1]);break;case"M":t.moveTo(a[0],a[1]);break;case"C":t.bezierCurveTo(a[0],a[1],a[2],a[3],a[4],a[5]);break;case"Q":t.quadraticCurveTo(a[0],a[1],a[2],a[3]);break;case"A":var n=a[0],o=a[1],h=a[2],l=a[3],d=a[4],c=a[5],u=a[6],g=a[7],p=h>l?h:l,m=h>l?1:h/l,f=h>l?l/h:1;t.translate(n,o),t.rotate(u),t.scale(m,f),t.arc(0,0,p,d,d+c,1-g),t.scale(1/m,1/f),t.rotate(-u),t.translate(-n,-o);break;case"z":i=!0,t.closePath()}}i||this.hasFill()?t.fillStrokeShape(this):t.strokeShape(this)}getSelfRect(){var t=[];this.dataArray.forEach((function(e){if("A"===e.command){var i=e.points[4],r=e.points[5],s=e.points[4]+r,a=Math.PI/180;if(Math.abs(i-s)<a&&(a=Math.abs(i-s)),r<0)for(let r=i-a;r>s;r-=a){const i=Qe.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],r,0);t.push(i.x,i.y)}else for(let r=i+a;r<s;r+=a){const i=Qe.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],r,0);t.push(i.x,i.y)}}else if("C"===e.command)for(let i=0;i<=1;i+=.01){const r=Qe.getPointOnCubicBezier(i,e.start.x,e.start.y,e.points[0],e.points[1],e.points[2],e.points[3],e.points[4],e.points[5]);t.push(r.x,r.y)}else t=t.concat(e.points)}));for(var e,i,r=t[0],s=t[0],a=t[1],n=t[1],o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],isNaN(e)||(r=Math.min(r,e),s=Math.max(s,e)),isNaN(i)||(a=Math.min(a,i),n=Math.max(n,i));return{x:r,y:a,width:s-r,height:n-a}}getLength(){return this.pathLength}getPointAtLength(t){return Qe.getPointAtLengthOfDataArray(t,this.dataArray)}static getLineLength(t,e,i,r){return Math.sqrt((i-t)*(i-t)+(r-e)*(r-e))}static getPathLength(t){let e=0;for(var i=0;i<t.length;++i)e+=t[i].pathLength;return e}static getPointAtLengthOfDataArray(t,e){var i,r=0,s=e.length;if(!s)return null;for(;r<s&&t>e[r].pathLength;)t-=e[r].pathLength,++r;if(r===s)return{x:(i=e[r-1].points.slice(-2))[0],y:i[1]};if(t<.01)return{x:(i=e[r].points.slice(0,2))[0],y:i[1]};var a=e[r],n=a.points;switch(a.command){case"L":return Qe.getPointOnLine(t,a.start.x,a.start.y,n[0],n[1]);case"C":return Qe.getPointOnCubicBezier((0,$e.t2length)(t,Qe.getPathLength(e),(t=>(0,$e.getCubicArcLength)([a.start.x,n[0],n[2],n[4]],[a.start.y,n[1],n[3],n[5]],t))),a.start.x,a.start.y,n[0],n[1],n[2],n[3],n[4],n[5]);case"Q":return Qe.getPointOnQuadraticBezier((0,$e.t2length)(t,Qe.getPathLength(e),(t=>(0,$e.getQuadraticArcLength)([a.start.x,n[0],n[2]],[a.start.y,n[1],n[3]],t))),a.start.x,a.start.y,n[0],n[1],n[2],n[3]);case"A":var o=n[0],h=n[1],l=n[2],d=n[3],c=n[4],u=n[5],g=n[6];return c+=u*t/a.pathLength,Qe.getPointOnEllipticalArc(o,h,l,d,c,g)}return null}static getPointOnLine(t,e,i,r,s,a,n){void 0===a&&(a=e),void 0===n&&(n=i);var o=(s-i)/(r-e+1e-8),h=Math.sqrt(t*t/(1+o*o));r<e&&(h*=-1);var l,d=o*h;if(r===e)l={x:a,y:n+d};else if((n-i)/(a-e+1e-8)===o)l={x:a+h,y:n+d};else{var c,u,g=this.getLineLength(e,i,r,s),p=(a-e)*(r-e)+(n-i)*(s-i);c=e+(p/=g*g)*(r-e),u=i+p*(s-i);var m=this.getLineLength(a,n,c,u),f=Math.sqrt(t*t-m*m);h=Math.sqrt(f*f/(1+o*o)),r<e&&(h*=-1),l={x:c+h,y:u+(d=o*h)}}return l}static getPointOnCubicBezier(t,e,i,r,s,a,n,o,h){function l(t){return t*t*t}function d(t){return 3*t*t*(1-t)}function c(t){return 3*t*(1-t)*(1-t)}function u(t){return(1-t)*(1-t)*(1-t)}return{x:o*l(t)+a*d(t)+r*c(t)+e*u(t),y:h*l(t)+n*d(t)+s*c(t)+i*u(t)}}static getPointOnQuadraticBezier(t,e,i,r,s,a,n){function o(t){return t*t}function h(t){return 2*t*(1-t)}function l(t){return(1-t)*(1-t)}return{x:a*o(t)+r*h(t)+e*l(t),y:n*o(t)+s*h(t)+i*l(t)}}static getPointOnEllipticalArc(t,e,i,r,s,a){var n=Math.cos(a),o=Math.sin(a),h=i*Math.cos(s),l=r*Math.sin(s);return{x:t+(h*n-l*o),y:e+(h*o+l*n)}}static parsePathData(t){if(!t)return[];var e=t,i=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];e=e.replace(new RegExp(" ","g"),",");for(var r=0;r<i.length;r++)e=e.replace(new RegExp(i[r],"g"),"|"+i[r]);var s,a=e.split("|"),n=[],o=[],h=0,l=0,d=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;for(r=1;r<a.length;r++){var c=a[r],u=c.charAt(0);for(c=c.slice(1),o.length=0;s=d.exec(c);)o.push(s[0]);for(var g=[],p=0,m=o.length;p<m;p++)if("00"!==o[p]){var f=parseFloat(o[p]);isNaN(f)?g.push(0):g.push(f)}else g.push(0,0);for(;g.length>0&&!isNaN(g[0]);){var v,_,y,w,b,x,S,C,P,k,E="",A=[],T=h,M=l;switch(u){case"l":h+=g.shift(),l+=g.shift(),E="L",A.push(h,l);break;case"L":h=g.shift(),l=g.shift(),A.push(h,l);break;case"m":var F=g.shift(),O=g.shift();if(h+=F,l+=O,E="M",n.length>2&&"z"===n[n.length-1].command)for(var R=n.length-2;R>=0;R--)if("M"===n[R].command){h=n[R].points[0]+F,l=n[R].points[1]+O;break}A.push(h,l),u="l";break;case"M":h=g.shift(),l=g.shift(),E="M",A.push(h,l),u="L";break;case"h":h+=g.shift(),E="L",A.push(h,l);break;case"H":h=g.shift(),E="L",A.push(h,l);break;case"v":l+=g.shift(),E="L",A.push(h,l);break;case"V":l=g.shift(),E="L",A.push(h,l);break;case"C":A.push(g.shift(),g.shift(),g.shift(),g.shift()),h=g.shift(),l=g.shift(),A.push(h,l);break;case"c":A.push(h+g.shift(),l+g.shift(),h+g.shift(),l+g.shift()),h+=g.shift(),l+=g.shift(),E="C",A.push(h,l);break;case"S":_=h,y=l,"C"===(v=n[n.length-1]).command&&(_=h+(h-v.points[2]),y=l+(l-v.points[3])),A.push(_,y,g.shift(),g.shift()),h=g.shift(),l=g.shift(),E="C",A.push(h,l);break;case"s":_=h,y=l,"C"===(v=n[n.length-1]).command&&(_=h+(h-v.points[2]),y=l+(l-v.points[3])),A.push(_,y,h+g.shift(),l+g.shift()),h+=g.shift(),l+=g.shift(),E="C",A.push(h,l);break;case"Q":A.push(g.shift(),g.shift()),h=g.shift(),l=g.shift(),A.push(h,l);break;case"q":A.push(h+g.shift(),l+g.shift()),h+=g.shift(),l+=g.shift(),E="Q",A.push(h,l);break;case"T":_=h,y=l,"Q"===(v=n[n.length-1]).command&&(_=h+(h-v.points[0]),y=l+(l-v.points[1])),h=g.shift(),l=g.shift(),E="Q",A.push(_,y,h,l);break;case"t":_=h,y=l,"Q"===(v=n[n.length-1]).command&&(_=h+(h-v.points[0]),y=l+(l-v.points[1])),h+=g.shift(),l+=g.shift(),E="Q",A.push(_,y,h,l);break;case"A":w=g.shift(),b=g.shift(),x=g.shift(),S=g.shift(),C=g.shift(),P=h,k=l,h=g.shift(),l=g.shift(),E="A",A=this.convertEndpointToCenterParameterization(P,k,h,l,S,C,w,b,x);break;case"a":w=g.shift(),b=g.shift(),x=g.shift(),S=g.shift(),C=g.shift(),P=h,k=l,h+=g.shift(),l+=g.shift(),E="A",A=this.convertEndpointToCenterParameterization(P,k,h,l,S,C,w,b,x)}n.push({command:E||u,points:A,start:{x:T,y:M},pathLength:this.calcLength(T,M,E||u,A)})}"z"!==u&&"Z"!==u||n.push({command:"z",points:[],start:void 0,pathLength:0})}return n}static calcLength(t,e,i,r){var s,a,n,o,h=Qe;switch(i){case"L":return h.getLineLength(t,e,r[0],r[1]);case"C":return(0,$e.getCubicArcLength)([t,r[0],r[2],r[4]],[e,r[1],r[3],r[5]],1);case"Q":return(0,$e.getQuadraticArcLength)([t,r[0],r[2]],[e,r[1],r[3]],1);case"A":s=0;var l=r[4],d=r[5],c=r[4]+d,u=Math.PI/180;if(Math.abs(l-c)<u&&(u=Math.abs(l-c)),a=h.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],l,0),d<0)for(o=l-u;o>c;o-=u)n=h.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],o,0),s+=h.getLineLength(a.x,a.y,n.x,n.y),a=n;else for(o=l+u;o<c;o+=u)n=h.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],o,0),s+=h.getLineLength(a.x,a.y,n.x,n.y),a=n;return n=h.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],c,0),s+=h.getLineLength(a.x,a.y,n.x,n.y)}return 0}static convertEndpointToCenterParameterization(t,e,i,r,s,a,n,o,h){var l=h*(Math.PI/180),d=Math.cos(l)*(t-i)/2+Math.sin(l)*(e-r)/2,c=-1*Math.sin(l)*(t-i)/2+Math.cos(l)*(e-r)/2,u=d*d/(n*n)+c*c/(o*o);u>1&&(n*=Math.sqrt(u),o*=Math.sqrt(u));var g=Math.sqrt((n*n*(o*o)-n*n*(c*c)-o*o*(d*d))/(n*n*(c*c)+o*o*(d*d)));s===a&&(g*=-1),isNaN(g)&&(g=0);var p=g*n*c/o,m=g*-o*d/n,f=(t+i)/2+Math.cos(l)*p-Math.sin(l)*m,v=(e+r)/2+Math.sin(l)*p+Math.cos(l)*m,_=function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])},y=function(t,e){return(t[0]*e[0]+t[1]*e[1])/(_(t)*_(e))},w=function(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(y(t,e))},b=w([1,0],[(d-p)/n,(c-m)/o]),x=[(d-p)/n,(c-m)/o],S=[(-1*d-p)/n,(-1*c-m)/o],C=w(x,S);return y(x,S)<=-1&&(C=Math.PI),y(x,S)>=1&&(C=0),0===a&&C>0&&(C-=2*Math.PI),1===a&&C<0&&(C+=2*Math.PI),[f,v,n,o,b,C,l,a]}}Ye.Path=Qe,Qe.prototype.className="Path",Qe.prototype._attrsAffectingSize=["data"],(0,Ze._registerNode)(Qe),qe.Factory.addGetterSetter(Qe,"data"),Object.defineProperty(Ge,"__esModule",{value:!0}),Ge.Arrow=void 0;const ti=it,ei=ze,ii=rt,ri=Q,si=Ye;class ai extends ei.Line{_sceneFunc(t){super._sceneFunc(t);var e=2*Math.PI,i=this.points(),r=i,s=0!==this.tension()&&i.length>4;s&&(r=this.getTensionPoints());var a,n,o=this.pointerLength(),h=i.length;if(s){const t=[r[r.length-4],r[r.length-3],r[r.length-2],r[r.length-1],i[h-2],i[h-1]],e=si.Path.calcLength(r[r.length-4],r[r.length-3],"C",t),s=si.Path.getPointOnQuadraticBezier(Math.min(1,1-o/e),t[0],t[1],t[2],t[3],t[4],t[5]);a=i[h-2]-s.x,n=i[h-1]-s.y}else a=i[h-2]-i[h-4],n=i[h-1]-i[h-3];var l=(Math.atan2(n,a)+e)%e,d=this.pointerWidth();this.pointerAtEnding()&&(t.save(),t.beginPath(),t.translate(i[h-2],i[h-1]),t.rotate(l),t.moveTo(0,0),t.lineTo(-o,d/2),t.lineTo(-o,-d/2),t.closePath(),t.restore(),this.__fillStroke(t)),this.pointerAtBeginning()&&(t.save(),t.beginPath(),t.translate(i[0],i[1]),s?(a=(r[0]+r[2])/2-i[0],n=(r[1]+r[3])/2-i[1]):(a=i[2]-i[0],n=i[3]-i[1]),t.rotate((Math.atan2(-n,-a)+e)%e),t.moveTo(0,0),t.lineTo(-o,d/2),t.lineTo(-o,-d/2),t.closePath(),t.restore(),this.__fillStroke(t))}__fillStroke(t){var e=this.dashEnabled();e&&(this.attrs.dashEnabled=!1,t.setLineDash([])),t.fillStrokeShape(this),e&&(this.attrs.dashEnabled=!0)}getSelfRect(){const t=super.getSelfRect(),e=this.pointerWidth()/2;return{x:t.x-e,y:t.y-e,width:t.width+2*e,height:t.height+2*e}}}Ge.Arrow=ai,ai.prototype.className="Arrow",(0,ri._registerNode)(ai),ti.Factory.addGetterSetter(ai,"pointerLength",10,(0,ii.getNumberValidator)()),ti.Factory.addGetterSetter(ai,"pointerWidth",10,(0,ii.getNumberValidator)()),ti.Factory.addGetterSetter(ai,"pointerAtBeginning",!1),ti.Factory.addGetterSetter(ai,"pointerAtEnding",!0);var ni={};Object.defineProperty(ni,"__esModule",{value:!0}),ni.Circle=void 0;const oi=it,hi=re,li=rt,di=Q;class ci extends hi.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.attrs.radius||0,0,2*Math.PI,!1),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius()!==t/2&&this.radius(t/2)}setHeight(t){this.radius()!==t/2&&this.radius(t/2)}}ni.Circle=ci,ci.prototype._centroid=!0,ci.prototype.className="Circle",ci.prototype._attrsAffectingSize=["radius"],(0,di._registerNode)(ci),oi.Factory.addGetterSetter(ci,"radius",0,(0,li.getNumberValidator)());var ui={};Object.defineProperty(ui,"__esModule",{value:!0}),ui.Ellipse=void 0;const gi=it,pi=re,mi=rt,fi=Q;class vi extends pi.Shape{_sceneFunc(t){var e=this.radiusX(),i=this.radiusY();t.beginPath(),t.save(),e!==i&&t.scale(1,i/e),t.arc(0,0,e,0,2*Math.PI,!1),t.restore(),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radiusX()}getHeight(){return 2*this.radiusY()}setWidth(t){this.radiusX(t/2)}setHeight(t){this.radiusY(t/2)}}ui.Ellipse=vi,vi.prototype.className="Ellipse",vi.prototype._centroid=!0,vi.prototype._attrsAffectingSize=["radiusX","radiusY"],(0,fi._registerNode)(vi),gi.Factory.addComponentsGetterSetter(vi,"radius",["x","y"]),gi.Factory.addGetterSetter(vi,"radiusX",0,(0,mi.getNumberValidator)()),gi.Factory.addGetterSetter(vi,"radiusY",0,(0,mi.getNumberValidator)());var _i={};Object.defineProperty(_i,"__esModule",{value:!0}),_i.Image=void 0;const yi=tt,wi=it,bi=re,xi=Q,Si=rt;class Ci extends bi.Shape{constructor(t){super(t),this.on("imageChange.konva",(()=>{this._setImageLoad()})),this._setImageLoad()}_setImageLoad(){const t=this.image();t&&t.complete||t&&4===t.readyState||t&&t.addEventListener&&t.addEventListener("load",(()=>{this._requestDraw()}))}_useBufferCanvas(){return super._useBufferCanvas(!0)}_sceneFunc(t){const e=this.getWidth(),i=this.getHeight(),r=this.cornerRadius(),s=this.attrs.image;let a;if(s){const t=this.attrs.cropWidth,r=this.attrs.cropHeight;a=t&&r?[s,this.cropX(),this.cropY(),t,r,0,0,e,i]:[s,0,0,e,i]}(this.hasFill()||this.hasStroke()||r)&&(t.beginPath(),r?yi.Util.drawRoundedRectPath(t,e,i,r):t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)),s&&(r&&t.clip(),t.drawImage.apply(t,a))}_hitFunc(t){var e=this.width(),i=this.height(),r=this.cornerRadius();t.beginPath(),r?yi.Util.drawRoundedRectPath(t,e,i,r):t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}getWidth(){var t,e;return null!==(t=this.attrs.width)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.width}getHeight(){var t,e;return null!==(t=this.attrs.height)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.height}static fromURL(t,e,i=null){var r=yi.Util.createImageElement();r.onload=function(){var t=new Ci({image:r});e(t)},r.onerror=i,r.crossOrigin="Anonymous",r.src=t}}_i.Image=Ci,Ci.prototype.className="Image",(0,xi._registerNode)(Ci),wi.Factory.addGetterSetter(Ci,"cornerRadius",0,(0,Si.getNumberOrArrayOfNumbersValidator)(4)),wi.Factory.addGetterSetter(Ci,"image"),wi.Factory.addComponentsGetterSetter(Ci,"crop",["x","y","width","height"]),wi.Factory.addGetterSetter(Ci,"cropX",0,(0,Si.getNumberValidator)()),wi.Factory.addGetterSetter(Ci,"cropY",0,(0,Si.getNumberValidator)()),wi.Factory.addGetterSetter(Ci,"cropWidth",0,(0,Si.getNumberValidator)()),wi.Factory.addGetterSetter(Ci,"cropHeight",0,(0,Si.getNumberValidator)());var Pi={};Object.defineProperty(Pi,"__esModule",{value:!0}),Pi.Tag=Pi.Label=void 0;const ki=it,Ei=re,Ai=we,Ti=rt,Mi=Q;var Fi=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],Oi="up",Ri="right",Ii="down",Di="left",Li=Fi.length;class Vi extends Ai.Group{constructor(t){super(t),this.on("add.konva",(function(t){this._addListeners(t.child),this._sync()}))}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(t){var e,i=this,r=function(){i._sync()};for(e=0;e<Li;e++)t.on(Fi[e]+"Change.konva",r)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){var t,e,i,r,s,a,n,o=this.getText(),h=this.getTag();if(o&&h){switch(t=o.width(),e=o.height(),i=h.pointerDirection(),r=h.pointerWidth(),n=h.pointerHeight(),s=0,a=0,i){case Oi:s=t/2,a=-1*n;break;case Ri:s=t+r,a=e/2;break;case Ii:s=t/2,a=e+n;break;case Di:s=-1*r,a=e/2}h.setAttrs({x:-1*s,y:-1*a,width:t,height:e}),o.setAttrs({x:-1*s,y:-1*a})}}}Pi.Label=Vi,Vi.prototype.className="Label",(0,Mi._registerNode)(Vi);class Gi extends Ei.Shape{_sceneFunc(t){var e=this.width(),i=this.height(),r=this.pointerDirection(),s=this.pointerWidth(),a=this.pointerHeight(),n=this.cornerRadius();let o=0,h=0,l=0,d=0;"number"==typeof n?o=h=l=d=Math.min(n,e/2,i/2):(o=Math.min(n[0]||0,e/2,i/2),h=Math.min(n[1]||0,e/2,i/2),d=Math.min(n[2]||0,e/2,i/2),l=Math.min(n[3]||0,e/2,i/2)),t.beginPath(),t.moveTo(o,0),r===Oi&&(t.lineTo((e-s)/2,0),t.lineTo(e/2,-1*a),t.lineTo((e+s)/2,0)),t.lineTo(e-h,0),t.arc(e-h,h,h,3*Math.PI/2,0,!1),r===Ri&&(t.lineTo(e,(i-a)/2),t.lineTo(e+s,i/2),t.lineTo(e,(i+a)/2)),t.lineTo(e,i-d),t.arc(e-d,i-d,d,0,Math.PI/2,!1),r===Ii&&(t.lineTo((e+s)/2,i),t.lineTo(e/2,i+a),t.lineTo((e-s)/2,i)),t.lineTo(l,i),t.arc(l,i-l,l,Math.PI/2,Math.PI,!1),r===Di&&(t.lineTo(0,(i+a)/2),t.lineTo(-1*s,i/2),t.lineTo(0,(i-a)/2)),t.lineTo(0,o),t.arc(o,o,o,Math.PI,3*Math.PI/2,!1),t.closePath(),t.fillStrokeShape(this)}getSelfRect(){var t=0,e=0,i=this.pointerWidth(),r=this.pointerHeight(),s=this.pointerDirection(),a=this.width(),n=this.height();return s===Oi?(e-=r,n+=r):s===Ii?n+=r:s===Di?(t-=1.5*i,a+=i):s===Ri&&(a+=1.5*i),{x:t,y:e,width:a,height:n}}}Pi.Tag=Gi,Gi.prototype.className="Tag",(0,Mi._registerNode)(Gi),ki.Factory.addGetterSetter(Gi,"pointerDirection","none"),ki.Factory.addGetterSetter(Gi,"pointerWidth",0,(0,Ti.getNumberValidator)()),ki.Factory.addGetterSetter(Gi,"pointerHeight",0,(0,Ti.getNumberValidator)()),ki.Factory.addGetterSetter(Gi,"cornerRadius",0,(0,Ti.getNumberOrArrayOfNumbersValidator)(4));var zi={};Object.defineProperty(zi,"__esModule",{value:!0}),zi.Rect=void 0;const Ni=it,Ui=re,Wi=Q,ji=tt,Bi=rt;class Hi extends Ui.Shape{_sceneFunc(t){var e=this.cornerRadius(),i=this.width(),r=this.height();t.beginPath(),e?ji.Util.drawRoundedRectPath(t,i,r,e):t.rect(0,0,i,r),t.closePath(),t.fillStrokeShape(this)}}zi.Rect=Hi,Hi.prototype.className="Rect",(0,Wi._registerNode)(Hi),Ni.Factory.addGetterSetter(Hi,"cornerRadius",0,(0,Bi.getNumberOrArrayOfNumbersValidator)(4));var Ki={};Object.defineProperty(Ki,"__esModule",{value:!0}),Ki.RegularPolygon=void 0;const Yi=it,Xi=re,qi=rt,Ji=Q;class Zi extends Xi.Shape{_sceneFunc(t){const e=this._getPoints();t.beginPath(),t.moveTo(e[0].x,e[0].y);for(var i=1;i<e.length;i++)t.lineTo(e[i].x,e[i].y);t.closePath(),t.fillStrokeShape(this)}_getPoints(){const t=this.attrs.sides,e=this.attrs.radius||0,i=[];for(var r=0;r<t;r++)i.push({x:e*Math.sin(2*r*Math.PI/t),y:-1*e*Math.cos(2*r*Math.PI/t)});return i}getSelfRect(){const t=this._getPoints();var e=t[0].x,i=t[0].y,r=t[0].x,s=t[0].y;return t.forEach((t=>{e=Math.min(e,t.x),i=Math.max(i,t.x),r=Math.min(r,t.y),s=Math.max(s,t.y)})),{x:e,y:r,width:i-e,height:s-r}}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}}Ki.RegularPolygon=Zi,Zi.prototype.className="RegularPolygon",Zi.prototype._centroid=!0,Zi.prototype._attrsAffectingSize=["radius"],(0,Ji._registerNode)(Zi),Yi.Factory.addGetterSetter(Zi,"radius",0,(0,qi.getNumberValidator)()),Yi.Factory.addGetterSetter(Zi,"sides",0,(0,qi.getNumberValidator)());var $i={};Object.defineProperty($i,"__esModule",{value:!0}),$i.Ring=void 0;const Qi=it,tr=re,er=rt,ir=Q;var rr=2*Math.PI;class sr extends tr.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.innerRadius(),0,rr,!1),t.moveTo(this.outerRadius(),0),t.arc(0,0,this.outerRadius(),rr,0,!0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}}$i.Ring=sr,sr.prototype.className="Ring",sr.prototype._centroid=!0,sr.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,ir._registerNode)(sr),Qi.Factory.addGetterSetter(sr,"innerRadius",0,(0,er.getNumberValidator)()),Qi.Factory.addGetterSetter(sr,"outerRadius",0,(0,er.getNumberValidator)());var ar={};Object.defineProperty(ar,"__esModule",{value:!0}),ar.Sprite=void 0;const nr=it,or=re,hr=Pe,lr=rt,dr=Q;class cr extends or.Shape{constructor(t){super(t),this._updated=!0,this.anim=new hr.Animation((()=>{var t=this._updated;return this._updated=!1,t})),this.on("animationChange.konva",(function(){this.frameIndex(0)})),this.on("frameIndexChange.konva",(function(){this._updated=!0})),this.on("frameRateChange.konva",(function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())}))}_sceneFunc(t){var e=this.animation(),i=this.frameIndex(),r=4*i,s=this.animations()[e],a=this.frameOffsets(),n=s[r+0],o=s[r+1],h=s[r+2],l=s[r+3],d=this.image();if((this.hasFill()||this.hasStroke())&&(t.beginPath(),t.rect(0,0,h,l),t.closePath(),t.fillStrokeShape(this)),d)if(a){var c=a[e],u=2*i;t.drawImage(d,n,o,h,l,c[u+0],c[u+1],h,l)}else t.drawImage(d,n,o,h,l,0,0,h,l)}_hitFunc(t){var e=this.animation(),i=this.frameIndex(),r=4*i,s=this.animations()[e],a=this.frameOffsets(),n=s[r+2],o=s[r+3];if(t.beginPath(),a){var h=a[e],l=2*i;t.rect(h[l+0],h[l+1],n,o)}else t.rect(0,0,n,o);t.closePath(),t.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){var t=this;this.interval=setInterval((function(){t._updateIndex()}),1e3/this.frameRate())}start(){if(!this.isRunning()){var t=this.getLayer();this.anim.setLayers(t),this._setInterval(),this.anim.start()}}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){var t=this.frameIndex(),e=this.animation();t<this.animations()[e].length/4-1?this.frameIndex(t+1):this.frameIndex(0)}}ar.Sprite=cr,cr.prototype.className="Sprite",(0,dr._registerNode)(cr),nr.Factory.addGetterSetter(cr,"animation"),nr.Factory.addGetterSetter(cr,"animations"),nr.Factory.addGetterSetter(cr,"frameOffsets"),nr.Factory.addGetterSetter(cr,"image"),nr.Factory.addGetterSetter(cr,"frameIndex",0,(0,lr.getNumberValidator)()),nr.Factory.addGetterSetter(cr,"frameRate",17,(0,lr.getNumberValidator)()),nr.Factory.backCompat(cr,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});var ur={};Object.defineProperty(ur,"__esModule",{value:!0}),ur.Star=void 0;const gr=it,pr=re,mr=rt,fr=Q;class vr extends pr.Shape{_sceneFunc(t){var e=this.innerRadius(),i=this.outerRadius(),r=this.numPoints();t.beginPath(),t.moveTo(0,0-i);for(var s=1;s<2*r;s++){var a=s%2==0?i:e,n=a*Math.sin(s*Math.PI/r),o=-1*a*Math.cos(s*Math.PI/r);t.lineTo(n,o)}t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}}ur.Star=vr,vr.prototype.className="Star",vr.prototype._centroid=!0,vr.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,fr._registerNode)(vr),gr.Factory.addGetterSetter(vr,"numPoints",5,(0,mr.getNumberValidator)()),gr.Factory.addGetterSetter(vr,"innerRadius",0,(0,mr.getNumberValidator)()),gr.Factory.addGetterSetter(vr,"outerRadius",0,(0,mr.getNumberValidator)());var _r={};Object.defineProperty(_r,"__esModule",{value:!0}),_r.Text=_r.stringToArray=void 0;const yr=tt,wr=it,br=re,xr=rt,Sr=Q;function Cr(t){return Array.from(t)}_r.stringToArray=Cr;var Pr,kr="auto",Er="inherit",Ar="justify",Tr="left",Mr="middle",Fr="normal",Or=" ",Rr="none",Ir=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],Dr=Ir.length;function Lr(){return Pr||(Pr=yr.Util.createCanvasElement().getContext("2d"))}class Vr extends br.Shape{constructor(t){super(function(t){return(t=t||{}).fillLinearGradientColorStops||t.fillRadialGradientColorStops||t.fillPatternImage||(t.fill=t.fill||"black"),t}(t)),this._partialTextX=0,this._partialTextY=0;for(var e=0;e<Dr;e++)this.on(Ir[e]+"Change.konva",this._setTextData);this._setTextData()}_sceneFunc(t){var e=this.textArr,i=e.length;if(this.text()){var r,s=this.padding(),a=this.fontSize(),n=this.lineHeight()*a,o=this.verticalAlign(),h=this.direction(),l=0,d=this.align(),c=this.getWidth(),u=this.letterSpacing(),g=this.fill(),p=this.textDecoration(),m=-1!==p.indexOf("underline"),f=-1!==p.indexOf("line-through"),v=0,_=(v=n/2,0),y=0;for("rtl"===(h=h===Er?t.direction:h)&&t.setAttr("direction",h),t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",Mr),t.setAttr("textAlign",Tr),o===Mr?l=(this.getHeight()-i*n-2*s)/2:"bottom"===o&&(l=this.getHeight()-i*n-2*s),t.translate(s,l+s),r=0;r<i;r++){_=0,y=0;var w,b,x,S=e[r],C=S.text,P=S.width,k=S.lastInParagraph;if(t.save(),"right"===d?_+=c-P-2*s:"center"===d&&(_+=(c-P-2*s)/2),m){t.save(),t.beginPath(),t.moveTo(_,v+y+Math.round(a/2)),b=0===(w=C.split(" ").length-1),x=d!==Ar||k?P:c-2*s,t.lineTo(_+Math.round(x),v+y+Math.round(a/2)),t.lineWidth=a/15;const e=this._getLinearGradient();t.strokeStyle=e||g,t.stroke(),t.restore()}if(f){t.save(),t.beginPath(),t.moveTo(_,v+y),b=0===(w=C.split(" ").length-1),x=d===Ar&&k&&!b?c-2*s:P,t.lineTo(_+Math.round(x),v+y),t.lineWidth=a/15;const e=this._getLinearGradient();t.strokeStyle=e||g,t.stroke(),t.restore()}if("rtl"===h||0===u&&d!==Ar)0!==u&&t.setAttr("letterSpacing",`${u}px`),this._partialTextX=_,this._partialTextY=v+y,this._partialText=C,t.fillStrokeShape(this);else{w=C.split(" ").length-1;for(var E=Cr(C),A=0;A<E.length;A++){var T=E[A];" "!==T||k||d!==Ar||(_+=(c-2*s-P)/w),this._partialTextX=_,this._partialTextY=v+y,this._partialText=T,t.fillStrokeShape(this),_+=this.measureSize(T).width+u}}t.restore(),i>1&&(v+=n)}}}_hitFunc(t){var e=this.getWidth(),i=this.getHeight();t.beginPath(),t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}setText(t){var e=yr.Util._isString(t)?t:null==t?"":t+"";return this._setAttr("text",e),this}getWidth(){return this.attrs.width===kr||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}getHeight(){return this.attrs.height===kr||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return yr.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(t){var e,i=Lr(),r=this.fontSize();return i.save(),i.font=this._getContextFont(),e=i.measureText(t),i.restore(),{width:e.width,height:r}}_getContextFont(){return this.fontStyle()+Or+this.fontVariant()+Or+(this.fontSize()+"px ")+this.fontFamily().split(",").map((t=>{const e=(t=t.trim()).indexOf(" ")>=0,i=t.indexOf('"')>=0||t.indexOf("'")>=0;return e&&!i&&(t=`"${t}"`),t})).join(", ")}_addTextLine(t){this.align()===Ar&&(t=t.trim());var e=this._getTextWidth(t);return this.textArr.push({text:t,width:e,lastInParagraph:!1})}_getTextWidth(t){var e=this.letterSpacing(),i=t.length;return Lr().measureText(t).width+(i?e*(i-1):0)}_setTextData(){var t=this.text().split("\n"),e=+this.fontSize(),i=0,r=this.lineHeight()*e,s=this.attrs.width,a=this.attrs.height,n=s!==kr&&void 0!==s,o=a!==kr&&void 0!==a,h=this.padding(),l=s-2*h,d=a-2*h,c=0,u=this.wrap(),g="char"!==u&&u!==Rr,p=this.ellipsis();this.textArr=[],Lr().font=this._getContextFont();for(var m=p?this._getTextWidth("…"):0,f=0,v=t.length;f<v;++f){var _=t[f],y=this._getTextWidth(_);if(n&&y>l)for(;_.length>0;){for(var w=0,b=_.length,x="",S=0;w<b;){var C=w+b>>>1,P=_.slice(0,C+1),k=this._getTextWidth(P)+m;k<=l?(w=C+1,x=P,S=k):b=C}if(!x)break;if(g){var E,A=_[x.length];(E=(A===Or||"-"===A)&&S<=l?x.length:Math.max(x.lastIndexOf(Or),x.lastIndexOf("-"))+1)>0&&(w=E,x=x.slice(0,w),S=this._getTextWidth(x))}if(x=x.trimRight(),this._addTextLine(x),i=Math.max(i,S),c+=r,this._shouldHandleEllipsis(c)){this._tryToAddEllipsisToLastLine();break}if((_=(_=_.slice(w)).trimLeft()).length>0&&(y=this._getTextWidth(_))<=l){this._addTextLine(_),c+=r,i=Math.max(i,y);break}}else this._addTextLine(_),c+=r,i=Math.max(i,y),this._shouldHandleEllipsis(c)&&f<v-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),o&&c+r>d)break}this.textHeight=e,this.textWidth=i}_shouldHandleEllipsis(t){var e=+this.fontSize(),i=this.lineHeight()*e,r=this.attrs.height,s=r!==kr&&void 0!==r,a=r-2*this.padding();return!(this.wrap()!==Rr)||s&&t+i>a}_tryToAddEllipsisToLastLine(){var t=this.attrs.width,e=t!==kr&&void 0!==t,i=t-2*this.padding(),r=this.ellipsis(),s=this.textArr[this.textArr.length-1];if(s&&r){if(e)this._getTextWidth(s.text+"…")<i||(s.text=s.text.slice(0,s.text.length-3));this.textArr.splice(this.textArr.length-1,1),this._addTextLine(s.text+"…")}}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){const t=-1!==this.textDecoration().indexOf("underline")||-1!==this.textDecoration().indexOf("line-through"),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas()}}_r.Text=Vr,Vr.prototype._fillFunc=function(t){t.fillText(this._partialText,this._partialTextX,this._partialTextY)},Vr.prototype._strokeFunc=function(t){t.setAttr("miterLimit",2),t.strokeText(this._partialText,this._partialTextX,this._partialTextY)},Vr.prototype.className="Text",Vr.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],(0,Sr._registerNode)(Vr),wr.Factory.overWriteSetter(Vr,"width",(0,xr.getNumberOrAutoValidator)()),wr.Factory.overWriteSetter(Vr,"height",(0,xr.getNumberOrAutoValidator)()),wr.Factory.addGetterSetter(Vr,"direction",Er),wr.Factory.addGetterSetter(Vr,"fontFamily","Arial"),wr.Factory.addGetterSetter(Vr,"fontSize",12,(0,xr.getNumberValidator)()),wr.Factory.addGetterSetter(Vr,"fontStyle",Fr),wr.Factory.addGetterSetter(Vr,"fontVariant",Fr),wr.Factory.addGetterSetter(Vr,"padding",0,(0,xr.getNumberValidator)()),wr.Factory.addGetterSetter(Vr,"align",Tr),wr.Factory.addGetterSetter(Vr,"verticalAlign","top"),wr.Factory.addGetterSetter(Vr,"lineHeight",1,(0,xr.getNumberValidator)()),wr.Factory.addGetterSetter(Vr,"wrap","word"),wr.Factory.addGetterSetter(Vr,"ellipsis",!1,(0,xr.getBooleanValidator)()),wr.Factory.addGetterSetter(Vr,"letterSpacing",0,(0,xr.getNumberValidator)()),wr.Factory.addGetterSetter(Vr,"text","",(0,xr.getStringValidator)()),wr.Factory.addGetterSetter(Vr,"textDecoration","");var Gr={};Object.defineProperty(Gr,"__esModule",{value:!0}),Gr.TextPath=void 0;const zr=tt,Nr=it,Ur=re,Wr=Ye,jr=_r,Br=rt,Hr=Q;var Kr="normal";function Yr(t){t.fillText(this.partialText,0,0)}function Xr(t){t.strokeText(this.partialText,0,0)}class qr extends Ur.Shape{constructor(t){super(t),this.dummyCanvas=zr.Util.createCanvasElement(),this.dataArray=[],this._readDataAttribute(),this.on("dataChange.konva",(function(){this._readDataAttribute(),this._setTextData()})),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_getTextPathLength(){return Wr.Path.getPathLength(this.dataArray)}_getPointAtLength(t){if(!this.attrs.data)return null;return t-1>this.pathLength?null:Wr.Path.getPointAtLengthOfDataArray(t,this.dataArray)}_readDataAttribute(){this.dataArray=Wr.Path.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(t){t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",this.textBaseline()),t.setAttr("textAlign","left"),t.save();var e=this.textDecoration(),i=this.fill(),r=this.fontSize(),s=this.glyphInfo;"underline"===e&&t.beginPath();for(var a=0;a<s.length;a++){t.save();var n=s[a].p0;t.translate(n.x,n.y),t.rotate(s[a].rotation),this.partialText=s[a].text,t.fillStrokeShape(this),"underline"===e&&(0===a&&t.moveTo(0,r/2+1),t.lineTo(r,r/2+1)),t.restore()}"underline"===e&&(t.strokeStyle=i,t.lineWidth=r/20,t.stroke()),t.restore()}_hitFunc(t){t.beginPath();var e=this.glyphInfo;if(e.length>=1){var i=e[0].p0;t.moveTo(i.x,i.y)}for(var r=0;r<e.length;r++){var s=e[r].p1;t.lineTo(s.x,s.y)}t.setAttr("lineWidth",this.fontSize()),t.setAttr("strokeStyle",this.colorKey),t.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return zr.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(t){return jr.Text.prototype.setText.call(this,t)}_getContextFont(){return jr.Text.prototype._getContextFont.call(this)}_getTextSize(t){var e=this.dummyCanvas.getContext("2d");e.save(),e.font=this._getContextFont();var i=e.measureText(t);return e.restore(),{width:i.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const{width:t,height:e}=this._getTextSize(this.attrs.text);if(this.textWidth=t,this.textHeight=e,this.glyphInfo=[],!this.attrs.data)return null;const i=this.letterSpacing(),r=this.align(),s=this.kerningFunc(),a=Math.max(this.textWidth+((this.attrs.text||"").length-1)*i,0);let n=0;"center"===r&&(n=Math.max(0,this.pathLength/2-a/2)),"right"===r&&(n=Math.max(0,this.pathLength-a));const o=(0,jr.stringToArray)(this.text());let h=n;for(var l=0;l<o.length;l++){const t=this._getPointAtLength(h);if(!t)return;let e=this._getTextSize(o[l]).width+i;if(" "===o[l]&&"justify"===r){const t=this.text().split(" ").length-1;e+=(this.pathLength-a)/t}const n=this._getPointAtLength(h+e);if(!n)return;const d=Wr.Path.getLineLength(t.x,t.y,n.x,n.y);let c=0;if(s)try{c=s(o[l-1],o[l])*this.fontSize()}catch(t){c=0}t.x+=c,n.x+=c,this.textWidth+=c;const u=Wr.Path.getPointOnLine(c+d/2,t.x,t.y,n.x,n.y),g=Math.atan2(n.y-t.y,n.x-t.x);this.glyphInfo.push({transposeX:u.x,transposeY:u.y,text:o[l],rotation:g,p0:t,p1:n}),h+=e}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};var t=[];this.glyphInfo.forEach((function(e){t.push(e.p0.x),t.push(e.p0.y),t.push(e.p1.x),t.push(e.p1.y)}));for(var e,i,r=t[0]||0,s=t[0]||0,a=t[1]||0,n=t[1]||0,o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],r=Math.min(r,e),s=Math.max(s,e),a=Math.min(a,i),n=Math.max(n,i);var h=this.fontSize();return{x:r-h/2,y:a-h/2,width:s-r+h,height:n-a+h}}destroy(){return zr.Util.releaseCanvas(this.dummyCanvas),super.destroy()}}Gr.TextPath=qr,qr.prototype._fillFunc=Yr,qr.prototype._strokeFunc=Xr,qr.prototype._fillFuncHit=Yr,qr.prototype._strokeFuncHit=Xr,qr.prototype.className="TextPath",qr.prototype._attrsAffectingSize=["text","fontSize","data"],(0,Hr._registerNode)(qr),Nr.Factory.addGetterSetter(qr,"data"),Nr.Factory.addGetterSetter(qr,"fontFamily","Arial"),Nr.Factory.addGetterSetter(qr,"fontSize",12,(0,Br.getNumberValidator)()),Nr.Factory.addGetterSetter(qr,"fontStyle",Kr),Nr.Factory.addGetterSetter(qr,"align","left"),Nr.Factory.addGetterSetter(qr,"letterSpacing",0,(0,Br.getNumberValidator)()),Nr.Factory.addGetterSetter(qr,"textBaseline","middle"),Nr.Factory.addGetterSetter(qr,"fontVariant",Kr),Nr.Factory.addGetterSetter(qr,"text",""),Nr.Factory.addGetterSetter(qr,"textDecoration",null),Nr.Factory.addGetterSetter(qr,"kerningFunc",null);var Jr={};Object.defineProperty(Jr,"__esModule",{value:!0}),Jr.Transformer=void 0;const Zr=tt,$r=it,Qr=et,ts=re,es=zi,is=we,rs=Q,ss=rt,as=Q;var ns="tr-konva",os=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map((t=>t+`.${ns}`)).join(" "),hs="nodesRect",ls=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],ds={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135};const cs="ontouchstart"in rs.Konva._global;var us=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function gs(t,e,i){const r=i.x+(t.x-i.x)*Math.cos(e)-(t.y-i.y)*Math.sin(e),s=i.y+(t.x-i.x)*Math.sin(e)+(t.y-i.y)*Math.cos(e);return{...t,rotation:t.rotation+e,x:r,y:s}}function ps(t,e){const i=function(t){return{x:t.x+t.width/2*Math.cos(t.rotation)+t.height/2*Math.sin(-t.rotation),y:t.y+t.height/2*Math.cos(t.rotation)+t.width/2*Math.sin(t.rotation)}}(t);return gs(t,e,i)}let ms=0;class fs extends is.Group{constructor(t){super(t),this._movingAnchorName=null,this._transforming=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(os,this.update),this.getNode()&&this.update()}attachTo(t){return this.setNode(t),this}setNode(t){return Zr.Util.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([t])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return ns+this._id}setNodes(t=[]){this._nodes&&this._nodes.length&&this.detach();const e=t.filter((t=>!t.isAncestorOf(this)||(Zr.Util.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1)));return this._nodes=t=e,1===t.length&&this.useSingleNodeRotation()?this.rotation(t[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach((t=>{const e=()=>{1===this.nodes().length&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),this._transforming||this.isDragging()||this.update()},i=t._attrsAffectingSize.map((t=>t+"Change."+this._getEventNamespace())).join(" ");t.on(i,e),t.on(ls.map((t=>t+`.${this._getEventNamespace()}`)).join(" "),e),t.on(`absoluteTransformChange.${this._getEventNamespace()}`,e),this._proxyDrag(t)})),this._resetTransformCache(),!!this.findOne(".top-left")&&this.update(),this}_proxyDrag(t){let e;t.on(`dragstart.${this._getEventNamespace()}`,(i=>{e=t.getAbsolutePosition(),this.isDragging()||t===this.findOne(".back")||this.startDrag(i,!1)})),t.on(`dragmove.${this._getEventNamespace()}`,(i=>{if(!e)return;const r=t.getAbsolutePosition(),s=r.x-e.x,a=r.y-e.y;this.nodes().forEach((e=>{if(e===t)return;if(e.isDragging())return;const r=e.getAbsolutePosition();e.setAbsolutePosition({x:r.x+s,y:r.y+a}),e.startDrag(i)})),e=null}))}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach((t=>{t.off("."+this._getEventNamespace())})),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(hs),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(hs,this.__getNodeRect)}__getNodeShape(t,e=this.rotation(),i){var r=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),s=t.getAbsoluteScale(i),a=t.getAbsolutePosition(i),n=r.x*s.x-t.offsetX()*s.x,o=r.y*s.y-t.offsetY()*s.y;const h=(rs.Konva.getAngle(t.getAbsoluteRotation())+2*Math.PI)%(2*Math.PI);return gs({x:a.x+n*Math.cos(h)+o*Math.sin(-h),y:a.y+o*Math.cos(h)+n*Math.sin(h),width:r.width*s.x,height:r.height*s.y,rotation:h},-rs.Konva.getAngle(e),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};const t=[];this.nodes().map((e=>{const i=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()});var r=[{x:i.x,y:i.y},{x:i.x+i.width,y:i.y},{x:i.x+i.width,y:i.y+i.height},{x:i.x,y:i.y+i.height}],s=e.getAbsoluteTransform();r.forEach((function(e){var i=s.point(e);t.push(i)}))}));const e=new Zr.Transform;e.rotate(-rs.Konva.getAngle(this.rotation()));var i=1/0,r=1/0,s=-1/0,a=-1/0;t.forEach((function(t){var n=e.point(t);void 0===i&&(i=s=n.x,r=a=n.y),i=Math.min(i,n.x),r=Math.min(r,n.y),s=Math.max(s,n.x),a=Math.max(a,n.y)})),e.invert();const n=e.point({x:i,y:r});return{x:n.x,y:n.y,width:s-i,height:a-r,rotation:rs.Konva.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),us.forEach((t=>{this._createAnchor(t)})),this._createAnchor("rotater")}_createAnchor(t){var e=new es.Rect({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:t+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:cs?10:"auto"}),i=this;e.on("mousedown touchstart",(function(t){i._handleMouseDown(t)})),e.on("dragstart",(t=>{e.stopDrag(),t.cancelBubble=!0})),e.on("dragend",(t=>{t.cancelBubble=!0})),e.on("mouseenter",(()=>{var i=rs.Konva.getAngle(this.rotation()),r=this.rotateAnchorCursor(),s=function(t,e,i){if("rotater"===t)return i;e+=Zr.Util.degToRad(ds[t]||0);var r=(Zr.Util.radToDeg(e)%360+360)%360;return Zr.Util._inRange(r,337.5,360)||Zr.Util._inRange(r,0,22.5)?"ns-resize":Zr.Util._inRange(r,22.5,67.5)?"nesw-resize":Zr.Util._inRange(r,67.5,112.5)?"ew-resize":Zr.Util._inRange(r,112.5,157.5)?"nwse-resize":Zr.Util._inRange(r,157.5,202.5)?"ns-resize":Zr.Util._inRange(r,202.5,247.5)?"nesw-resize":Zr.Util._inRange(r,247.5,292.5)?"ew-resize":Zr.Util._inRange(r,292.5,337.5)?"nwse-resize":(Zr.Util.error("Transformer has unknown angle for cursor detection: "+r),"pointer")}(t,i,r);e.getStage().content&&(e.getStage().content.style.cursor=s),this._cursorChange=!0})),e.on("mouseout",(()=>{e.getStage().content&&(e.getStage().content.style.cursor=""),this._cursorChange=!1})),this.add(e)}_createBack(){var t=new ts.Shape({name:"back",width:0,height:0,draggable:!0,sceneFunc(t,e){var i=e.getParent(),r=i.padding();t.beginPath(),t.rect(-r,-r,e.width()+2*r,e.height()+2*r),t.moveTo(e.width()/2,-r),i.rotateEnabled()&&i.rotateLineVisible()&&t.lineTo(e.width()/2,-i.rotateAnchorOffset()*Zr.Util._sign(e.height())-r),t.fillStrokeShape(e)},hitFunc:(t,e)=>{if(this.shouldOverdrawWholeArea()){var i=this.padding();t.beginPath(),t.rect(-i,-i,e.width()+2*i,e.height()+2*i),t.fillStrokeShape(e)}}});this.add(t),this._proxyDrag(t),t.on("dragstart",(t=>{t.cancelBubble=!0})),t.on("dragmove",(t=>{t.cancelBubble=!0})),t.on("dragend",(t=>{t.cancelBubble=!0})),this.on("dragmove",(t=>{this.update()}))}_handleMouseDown(t){this._movingAnchorName=t.target.name().split(" ")[0];var e=this._getNodeRect(),i=e.width,r=e.height,s=Math.sqrt(Math.pow(i,2)+Math.pow(r,2));this.sin=Math.abs(r/s),this.cos=Math.abs(i/s),"undefined"!=typeof window&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;var a=t.target.getAbsolutePosition(),n=t.target.getStage().getPointerPosition();this._anchorDragOffset={x:n.x-a.x,y:n.y-a.y},ms++,this._fire("transformstart",{evt:t.evt,target:this.getNode()}),this._nodes.forEach((e=>{e._fire("transformstart",{evt:t.evt,target:e})}))}_handleMouseMove(t){var e,i,r,s=this.findOne("."+this._movingAnchorName),a=s.getStage();a.setPointersPositions(t);const n=a.getPointerPosition();let o={x:n.x-this._anchorDragOffset.x,y:n.y-this._anchorDragOffset.y};const h=s.getAbsolutePosition();this.anchorDragBoundFunc()&&(o=this.anchorDragBoundFunc()(h,o,t)),s.setAbsolutePosition(o);const l=s.getAbsolutePosition();if(h.x!==l.x||h.y!==l.y)if("rotater"!==this._movingAnchorName){var d,c=this.shiftBehavior();d="inverted"===c?this.keepRatio()&&!t.shiftKey:"none"===c?this.keepRatio():this.keepRatio()||t.shiftKey;var u=this.centeredScaling()||t.altKey;if("top-left"===this._movingAnchorName){if(d){var g=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};r=Math.sqrt(Math.pow(g.x-s.x(),2)+Math.pow(g.y-s.y(),2));var p=this.findOne(".top-left").x()>g.x?-1:1,m=this.findOne(".top-left").y()>g.y?-1:1;e=r*this.cos*p,i=r*this.sin*m,this.findOne(".top-left").x(g.x-e),this.findOne(".top-left").y(g.y-i)}}else if("top-center"===this._movingAnchorName)this.findOne(".top-left").y(s.y());else if("top-right"===this._movingAnchorName){if(d){g=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};r=Math.sqrt(Math.pow(s.x()-g.x,2)+Math.pow(g.y-s.y(),2));p=this.findOne(".top-right").x()<g.x?-1:1,m=this.findOne(".top-right").y()>g.y?-1:1;e=r*this.cos*p,i=r*this.sin*m,this.findOne(".top-right").x(g.x+e),this.findOne(".top-right").y(g.y-i)}var f=s.position();this.findOne(".top-left").y(f.y),this.findOne(".bottom-right").x(f.x)}else if("middle-left"===this._movingAnchorName)this.findOne(".top-left").x(s.x());else if("middle-right"===this._movingAnchorName)this.findOne(".bottom-right").x(s.x());else if("bottom-left"===this._movingAnchorName){if(d){g=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};r=Math.sqrt(Math.pow(g.x-s.x(),2)+Math.pow(s.y()-g.y,2));p=g.x<s.x()?-1:1,m=s.y()<g.y?-1:1;e=r*this.cos*p,i=r*this.sin*m,s.x(g.x-e),s.y(g.y+i)}f=s.position(),this.findOne(".top-left").x(f.x),this.findOne(".bottom-right").y(f.y)}else if("bottom-center"===this._movingAnchorName)this.findOne(".bottom-right").y(s.y());else if("bottom-right"===this._movingAnchorName){if(d){g=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};r=Math.sqrt(Math.pow(s.x()-g.x,2)+Math.pow(s.y()-g.y,2));p=this.findOne(".bottom-right").x()<g.x?-1:1,m=this.findOne(".bottom-right").y()<g.y?-1:1;e=r*this.cos*p,i=r*this.sin*m,this.findOne(".bottom-right").x(g.x+e),this.findOne(".bottom-right").y(g.y+i)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(u=this.centeredScaling()||t.altKey){var v=this.findOne(".top-left"),_=this.findOne(".bottom-right"),y=v.x(),w=v.y(),b=this.getWidth()-_.x(),x=this.getHeight()-_.y();_.move({x:-y,y:-w}),v.move({x:b,y:x})}var S=this.findOne(".top-left").getAbsolutePosition();e=S.x,i=S.y;var C=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),P=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:e,y:i,width:C,height:P,rotation:rs.Konva.getAngle(this.rotation())},t)}else{var k=this._getNodeRect();e=s.x()-k.width/2,i=-s.y()+k.height/2;let r=Math.atan2(-i,e)+Math.PI/2;k.height<0&&(r-=Math.PI);const a=rs.Konva.getAngle(this.rotation())+r,n=rs.Konva.getAngle(this.rotationSnapTolerance()),o=ps(k,function(t,e,i){let r=e;for(let s=0;s<t.length;s++){const a=rs.Konva.getAngle(t[s]),n=Math.abs(a-e)%(2*Math.PI);Math.min(n,2*Math.PI-n)<i&&(r=a)}return r}(this.rotationSnaps(),a,n)-k.rotation);this._fitNodesInto(o,t)}}_handleMouseUp(t){this._removeEvents(t)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(t){var e;if(this._transforming){this._transforming=!1,"undefined"!=typeof window&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));var i=this.getNode();ms--,this._fire("transformend",{evt:t,target:i}),null===(e=this.getLayer())||void 0===e||e.batchDraw(),i&&this._nodes.forEach((e=>{var i;e._fire("transformend",{evt:t,target:e}),null===(i=e.getLayer())||void 0===i||i.batchDraw()})),this._movingAnchorName=null}}_fitNodesInto(t,e){var i=this._getNodeRect();if(Zr.Util._inRange(t.width,2*-this.padding()-1,1))return void this.update();if(Zr.Util._inRange(t.height,2*-this.padding()-1,1))return void this.update();var r=new Zr.Transform;if(r.rotate(rs.Konva.getAngle(this.rotation())),this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("left")>=0){const e=r.point({x:2*-this.padding(),y:0});t.x+=e.x,t.y+=e.y,t.width+=2*this.padding(),this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y}else if(this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("right")>=0){const e=r.point({x:2*this.padding(),y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.width+=2*this.padding()}if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("top")>=0){const e=r.point({x:0,y:2*-this.padding()});t.x+=e.x,t.y+=e.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.height+=2*this.padding()}else if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const e=r.point({x:0,y:2*this.padding()});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.height+=2*this.padding()}if(this.boundBoxFunc()){const e=this.boundBoxFunc()(i,t);e?t=e:Zr.Util.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const s=1e7,a=new Zr.Transform;a.translate(i.x,i.y),a.rotate(i.rotation),a.scale(i.width/s,i.height/s);const n=new Zr.Transform,o=t.width/s,h=t.height/s;!1===this.flipEnabled()?(n.translate(t.x,t.y),n.rotate(t.rotation),n.translate(t.width<0?t.width:0,t.height<0?t.height:0),n.scale(Math.abs(o),Math.abs(h))):(n.translate(t.x,t.y),n.rotate(t.rotation),n.scale(o,h));const l=n.multiply(a.invert());this._nodes.forEach((t=>{var e;const i=t.getParent().getAbsoluteTransform(),r=t.getTransform().copy();r.translate(t.offsetX(),t.offsetY());const s=new Zr.Transform;s.multiply(i.copy().invert()).multiply(l).multiply(i).multiply(r);const a=s.decompose();t.setAttrs(a),null===(e=t.getLayer())||void 0===e||e.batchDraw()})),this.rotation(Zr.Util._getRotation(t.rotation)),this._nodes.forEach((t=>{this._fire("transform",{evt:e,target:t}),t._fire("transform",{evt:e,target:t})})),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(t,e){this.findOne(t).setAttrs(e)}update(){var t,e=this._getNodeRect();this.rotation(Zr.Util._getRotation(e.rotation));var i=e.width,r=e.height,s=this.enabledAnchors(),a=this.resizeEnabled(),n=this.padding(),o=this.anchorSize();const h=this.find("._anchor");h.forEach((t=>{t.setAttrs({width:o,height:o,offsetX:o/2,offsetY:o/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})})),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:o/2+n,offsetY:o/2+n,visible:a&&s.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:i/2,y:0,offsetY:o/2+n,visible:a&&s.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:i,y:0,offsetX:o/2-n,offsetY:o/2+n,visible:a&&s.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:r/2,offsetX:o/2+n,visible:a&&s.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:i,y:r/2,offsetX:o/2-n,visible:a&&s.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:r,offsetX:o/2+n,offsetY:o/2-n,visible:a&&s.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:i/2,y:r,offsetY:o/2-n,visible:a&&s.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:i,y:r,offsetX:o/2-n,offsetY:o/2-n,visible:a&&s.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:i/2,y:-this.rotateAnchorOffset()*Zr.Util._sign(r)-n,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:i,height:r,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0});const l=this.anchorStyleFunc();l&&h.forEach((t=>{l(t)})),null===(t=this.getLayer())||void 0===t||t.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();var t=this.findOne("."+this._movingAnchorName);t&&t.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),is.Group.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return Qr.Node.prototype.toObject.call(this)}clone(t){return Qr.Node.prototype.clone.call(this,t)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}}Jr.Transformer=fs,fs.isTransforming=()=>ms>0,fs.prototype.className="Transformer",(0,as._registerNode)(fs),$r.Factory.addGetterSetter(fs,"enabledAnchors",us,(function(t){return t instanceof Array||Zr.Util.warn("enabledAnchors value should be an array"),t instanceof Array&&t.forEach((function(t){-1===us.indexOf(t)&&Zr.Util.warn("Unknown anchor name: "+t+". Available names are: "+us.join(", "))})),t||[]})),$r.Factory.addGetterSetter(fs,"flipEnabled",!0,(0,ss.getBooleanValidator)()),$r.Factory.addGetterSetter(fs,"resizeEnabled",!0),$r.Factory.addGetterSetter(fs,"anchorSize",10,(0,ss.getNumberValidator)()),$r.Factory.addGetterSetter(fs,"rotateEnabled",!0),$r.Factory.addGetterSetter(fs,"rotateLineVisible",!0),$r.Factory.addGetterSetter(fs,"rotationSnaps",[]),$r.Factory.addGetterSetter(fs,"rotateAnchorOffset",50,(0,ss.getNumberValidator)()),$r.Factory.addGetterSetter(fs,"rotateAnchorCursor","crosshair"),$r.Factory.addGetterSetter(fs,"rotationSnapTolerance",5,(0,ss.getNumberValidator)()),$r.Factory.addGetterSetter(fs,"borderEnabled",!0),$r.Factory.addGetterSetter(fs,"anchorStroke","rgb(0, 161, 255)"),$r.Factory.addGetterSetter(fs,"anchorStrokeWidth",1,(0,ss.getNumberValidator)()),$r.Factory.addGetterSetter(fs,"anchorFill","white"),$r.Factory.addGetterSetter(fs,"anchorCornerRadius",0,(0,ss.getNumberValidator)()),$r.Factory.addGetterSetter(fs,"borderStroke","rgb(0, 161, 255)"),$r.Factory.addGetterSetter(fs,"borderStrokeWidth",1,(0,ss.getNumberValidator)()),$r.Factory.addGetterSetter(fs,"borderDash"),$r.Factory.addGetterSetter(fs,"keepRatio",!0),$r.Factory.addGetterSetter(fs,"shiftBehavior","default"),$r.Factory.addGetterSetter(fs,"centeredScaling",!1),$r.Factory.addGetterSetter(fs,"ignoreStroke",!1),$r.Factory.addGetterSetter(fs,"padding",0,(0,ss.getNumberValidator)()),$r.Factory.addGetterSetter(fs,"node"),$r.Factory.addGetterSetter(fs,"nodes"),$r.Factory.addGetterSetter(fs,"boundBoxFunc"),$r.Factory.addGetterSetter(fs,"anchorDragBoundFunc"),$r.Factory.addGetterSetter(fs,"anchorStyleFunc"),$r.Factory.addGetterSetter(fs,"shouldOverdrawWholeArea",!1),$r.Factory.addGetterSetter(fs,"useSingleNodeRotation",!0),$r.Factory.backCompat(fs,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});var vs={};Object.defineProperty(vs,"__esModule",{value:!0}),vs.Wedge=void 0;const _s=it,ys=re,ws=Q,bs=rt,xs=Q;class Ss extends ys.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.radius(),0,ws.Konva.getAngle(this.angle()),this.clockwise()),t.lineTo(0,0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}}vs.Wedge=Ss,Ss.prototype.className="Wedge",Ss.prototype._centroid=!0,Ss.prototype._attrsAffectingSize=["radius"],(0,xs._registerNode)(Ss),_s.Factory.addGetterSetter(Ss,"radius",0,(0,bs.getNumberValidator)()),_s.Factory.addGetterSetter(Ss,"angle",0,(0,bs.getNumberValidator)()),_s.Factory.addGetterSetter(Ss,"clockwise",!1),_s.Factory.backCompat(Ss,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});var Cs={};Object.defineProperty(Cs,"__esModule",{value:!0}),Cs.Blur=void 0;const Ps=it,ks=et,Es=rt;function As(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var Ts=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],Ms=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];Cs.Blur=function(t){var e=Math.round(this.blurRadius());e>0&&function(t,e){var i,r,s,a,n,o,h,l,d,c,u,g,p,m,f,v,_,y,w,b,x,S,C,P,k=t.data,E=t.width,A=t.height,T=e+e+1,M=E-1,F=A-1,O=e+1,R=O*(O+1)/2,I=new As,D=null,L=I,V=null,G=null,z=Ts[e],N=Ms[e];for(s=1;s<T;s++)L=L.next=new As,s===O&&(D=L);for(L.next=I,h=o=0,r=0;r<A;r++){for(v=_=y=w=l=d=c=u=0,g=O*(b=k[o]),p=O*(x=k[o+1]),m=O*(S=k[o+2]),f=O*(C=k[o+3]),l+=R*b,d+=R*x,c+=R*S,u+=R*C,L=I,s=0;s<O;s++)L.r=b,L.g=x,L.b=S,L.a=C,L=L.next;for(s=1;s<O;s++)a=o+((M<s?M:s)<<2),l+=(L.r=b=k[a])*(P=O-s),d+=(L.g=x=k[a+1])*P,c+=(L.b=S=k[a+2])*P,u+=(L.a=C=k[a+3])*P,v+=b,_+=x,y+=S,w+=C,L=L.next;for(V=I,G=D,i=0;i<E;i++)k[o+3]=C=u*z>>N,0!==C?(C=255/C,k[o]=(l*z>>N)*C,k[o+1]=(d*z>>N)*C,k[o+2]=(c*z>>N)*C):k[o]=k[o+1]=k[o+2]=0,l-=g,d-=p,c-=m,u-=f,g-=V.r,p-=V.g,m-=V.b,f-=V.a,a=h+((a=i+e+1)<M?a:M)<<2,l+=v+=V.r=k[a],d+=_+=V.g=k[a+1],c+=y+=V.b=k[a+2],u+=w+=V.a=k[a+3],V=V.next,g+=b=G.r,p+=x=G.g,m+=S=G.b,f+=C=G.a,v-=b,_-=x,y-=S,w-=C,G=G.next,o+=4;h+=E}for(i=0;i<E;i++){for(_=y=w=v=d=c=u=l=0,g=O*(b=k[o=i<<2]),p=O*(x=k[o+1]),m=O*(S=k[o+2]),f=O*(C=k[o+3]),l+=R*b,d+=R*x,c+=R*S,u+=R*C,L=I,s=0;s<O;s++)L.r=b,L.g=x,L.b=S,L.a=C,L=L.next;for(n=E,s=1;s<=e;s++)o=n+i<<2,l+=(L.r=b=k[o])*(P=O-s),d+=(L.g=x=k[o+1])*P,c+=(L.b=S=k[o+2])*P,u+=(L.a=C=k[o+3])*P,v+=b,_+=x,y+=S,w+=C,L=L.next,s<F&&(n+=E);for(o=i,V=I,G=D,r=0;r<A;r++)k[3+(a=o<<2)]=C=u*z>>N,C>0?(C=255/C,k[a]=(l*z>>N)*C,k[a+1]=(d*z>>N)*C,k[a+2]=(c*z>>N)*C):k[a]=k[a+1]=k[a+2]=0,l-=g,d-=p,c-=m,u-=f,g-=V.r,p-=V.g,m-=V.b,f-=V.a,a=i+((a=r+O)<F?a:F)*E<<2,l+=v+=V.r=k[a],d+=_+=V.g=k[a+1],c+=y+=V.b=k[a+2],u+=w+=V.a=k[a+3],V=V.next,g+=b=G.r,p+=x=G.g,m+=S=G.b,f+=C=G.a,v-=b,_-=x,y-=S,w-=C,G=G.next,o+=E}}(t,e)},Ps.Factory.addGetterSetter(ks.Node,"blurRadius",0,(0,Es.getNumberValidator)(),Ps.Factory.afterSetFilter);var Fs={};Object.defineProperty(Fs,"__esModule",{value:!0}),Fs.Brighten=void 0;const Os=it,Rs=et,Is=rt;Fs.Brighten=function(t){var e,i=255*this.brightness(),r=t.data,s=r.length;for(e=0;e<s;e+=4)r[e]+=i,r[e+1]+=i,r[e+2]+=i},Os.Factory.addGetterSetter(Rs.Node,"brightness",0,(0,Is.getNumberValidator)(),Os.Factory.afterSetFilter);var Ds={};Object.defineProperty(Ds,"__esModule",{value:!0}),Ds.Contrast=void 0;const Ls=it,Vs=et,Gs=rt;Ds.Contrast=function(t){var e,i=Math.pow((this.contrast()+100)/100,2),r=t.data,s=r.length,a=150,n=150,o=150;for(e=0;e<s;e+=4)a=r[e],n=r[e+1],o=r[e+2],a/=255,a-=.5,a*=i,a+=.5,n/=255,n-=.5,n*=i,n+=.5,o/=255,o-=.5,o*=i,o+=.5,a=(a*=255)<0?0:a>255?255:a,n=(n*=255)<0?0:n>255?255:n,o=(o*=255)<0?0:o>255?255:o,r[e]=a,r[e+1]=n,r[e+2]=o},Ls.Factory.addGetterSetter(Vs.Node,"contrast",0,(0,Gs.getNumberValidator)(),Ls.Factory.afterSetFilter);var zs={};Object.defineProperty(zs,"__esModule",{value:!0}),zs.Emboss=void 0;const Ns=it,Us=et,Ws=tt,js=rt;zs.Emboss=function(t){var e=10*this.embossStrength(),i=255*this.embossWhiteLevel(),r=this.embossDirection(),s=this.embossBlend(),a=0,n=0,o=t.data,h=t.width,l=t.height,d=4*h,c=l;switch(r){case"top-left":a=-1,n=-1;break;case"top":a=-1,n=0;break;case"top-right":a=-1,n=1;break;case"right":a=0,n=1;break;case"bottom-right":a=1,n=1;break;case"bottom":a=1,n=0;break;case"bottom-left":a=1,n=-1;break;case"left":a=0,n=-1;break;default:Ws.Util.error("Unknown emboss direction: "+r)}do{var u=(c-1)*d,g=a;c+g<1&&(g=0),c+g>l&&(g=0);var p=(c-1+g)*h*4,m=h;do{var f=u+4*(m-1),v=n;m+v<1&&(v=0),m+v>h&&(v=0);var _=p+4*(m-1+v),y=o[f]-o[_],w=o[f+1]-o[_+1],b=o[f+2]-o[_+2],x=y,S=x>0?x:-x;if((w>0?w:-w)>S&&(x=w),(b>0?b:-b)>S&&(x=b),x*=e,s){var C=o[f]+x,P=o[f+1]+x,k=o[f+2]+x;o[f]=C>255?255:C<0?0:C,o[f+1]=P>255?255:P<0?0:P,o[f+2]=k>255?255:k<0?0:k}else{var E=i-x;E<0?E=0:E>255&&(E=255),o[f]=o[f+1]=o[f+2]=E}}while(--m)}while(--c)},Ns.Factory.addGetterSetter(Us.Node,"embossStrength",.5,(0,js.getNumberValidator)(),Ns.Factory.afterSetFilter),Ns.Factory.addGetterSetter(Us.Node,"embossWhiteLevel",.5,(0,js.getNumberValidator)(),Ns.Factory.afterSetFilter),Ns.Factory.addGetterSetter(Us.Node,"embossDirection","top-left",null,Ns.Factory.afterSetFilter),Ns.Factory.addGetterSetter(Us.Node,"embossBlend",!1,null,Ns.Factory.afterSetFilter);var Bs={};Object.defineProperty(Bs,"__esModule",{value:!0}),Bs.Enhance=void 0;const Hs=it,Ks=et,Ys=rt;function Xs(t,e,i,r,s){var a=i-e,n=s-r;return 0===a?r+n/2:0===n?r:n*((t-e)/a)+r}Bs.Enhance=function(t){var e,i,r,s,a=t.data,n=a.length,o=a[0],h=o,l=a[1],d=l,c=a[2],u=c,g=this.enhance();if(0!==g){for(s=0;s<n;s+=4)(e=a[s+0])<o?o=e:e>h&&(h=e),(i=a[s+1])<l?l=i:i>d&&(d=i),(r=a[s+2])<c?c=r:r>u&&(u=r);var p,m,f,v,_,y,w,b,x;for(h===o&&(h=255,o=0),d===l&&(d=255,l=0),u===c&&(u=255,c=0),g>0?(m=h+g*(255-h),f=o-g*(o-0),_=d+g*(255-d),y=l-g*(l-0),b=u+g*(255-u),x=c-g*(c-0)):(m=h+g*(h-(p=.5*(h+o))),f=o+g*(o-p),_=d+g*(d-(v=.5*(d+l))),y=l+g*(l-v),b=u+g*(u-(w=.5*(u+c))),x=c+g*(c-w)),s=0;s<n;s+=4)a[s+0]=Xs(a[s+0],o,h,f,m),a[s+1]=Xs(a[s+1],l,d,y,_),a[s+2]=Xs(a[s+2],c,u,x,b)}},Hs.Factory.addGetterSetter(Ks.Node,"enhance",0,(0,Ys.getNumberValidator)(),Hs.Factory.afterSetFilter);var qs={};Object.defineProperty(qs,"__esModule",{value:!0}),qs.Grayscale=void 0;qs.Grayscale=function(t){var e,i,r=t.data,s=r.length;for(e=0;e<s;e+=4)i=.34*r[e]+.5*r[e+1]+.16*r[e+2],r[e]=i,r[e+1]=i,r[e+2]=i};var Js={};Object.defineProperty(Js,"__esModule",{value:!0}),Js.HSL=void 0;const Zs=it,$s=et,Qs=rt;Zs.Factory.addGetterSetter($s.Node,"hue",0,(0,Qs.getNumberValidator)(),Zs.Factory.afterSetFilter),Zs.Factory.addGetterSetter($s.Node,"saturation",0,(0,Qs.getNumberValidator)(),Zs.Factory.afterSetFilter),Zs.Factory.addGetterSetter($s.Node,"luminance",0,(0,Qs.getNumberValidator)(),Zs.Factory.afterSetFilter);Js.HSL=function(t){var e,i,r,s,a,n=t.data,o=n.length,h=Math.pow(2,this.saturation()),l=Math.abs(this.hue()+360)%360,d=127*this.luminance(),c=1*h*Math.cos(l*Math.PI/180),u=1*h*Math.sin(l*Math.PI/180),g=.299+.701*c+.167*u,p=.587-.587*c+.33*u,m=.114-.114*c-.497*u,f=.299-.299*c-.328*u,v=.587+.413*c+.035*u,_=.114-.114*c+.293*u,y=.299-.3*c+1.25*u,w=.587-.586*c-1.05*u,b=.114+.886*c-.2*u;for(e=0;e<o;e+=4)i=n[e+0],r=n[e+1],s=n[e+2],a=n[e+3],n[e+0]=g*i+p*r+m*s+d,n[e+1]=f*i+v*r+_*s+d,n[e+2]=y*i+w*r+b*s+d,n[e+3]=a};var ta={};Object.defineProperty(ta,"__esModule",{value:!0}),ta.HSV=void 0;const ea=it,ia=et,ra=rt;ta.HSV=function(t){var e,i,r,s,a,n=t.data,o=n.length,h=Math.pow(2,this.value()),l=Math.pow(2,this.saturation()),d=Math.abs(this.hue()+360)%360,c=h*l*Math.cos(d*Math.PI/180),u=h*l*Math.sin(d*Math.PI/180),g=.299*h+.701*c+.167*u,p=.587*h-.587*c+.33*u,m=.114*h-.114*c-.497*u,f=.299*h-.299*c-.328*u,v=.587*h+.413*c+.035*u,_=.114*h-.114*c+.293*u,y=.299*h-.3*c+1.25*u,w=.587*h-.586*c-1.05*u,b=.114*h+.886*c-.2*u;for(e=0;e<o;e+=4)i=n[e+0],r=n[e+1],s=n[e+2],a=n[e+3],n[e+0]=g*i+p*r+m*s,n[e+1]=f*i+v*r+_*s,n[e+2]=y*i+w*r+b*s,n[e+3]=a},ea.Factory.addGetterSetter(ia.Node,"hue",0,(0,ra.getNumberValidator)(),ea.Factory.afterSetFilter),ea.Factory.addGetterSetter(ia.Node,"saturation",0,(0,ra.getNumberValidator)(),ea.Factory.afterSetFilter),ea.Factory.addGetterSetter(ia.Node,"value",0,(0,ra.getNumberValidator)(),ea.Factory.afterSetFilter);var sa={};Object.defineProperty(sa,"__esModule",{value:!0}),sa.Invert=void 0;sa.Invert=function(t){var e,i=t.data,r=i.length;for(e=0;e<r;e+=4)i[e]=255-i[e],i[e+1]=255-i[e+1],i[e+2]=255-i[e+2]};var aa={};Object.defineProperty(aa,"__esModule",{value:!0}),aa.Kaleidoscope=void 0;const na=it,oa=et,ha=tt,la=rt;aa.Kaleidoscope=function(t){var e,i,r,s,a,n,o,h,l,d=t.width,c=t.height,u=Math.round(this.kaleidoscopePower()),g=Math.round(this.kaleidoscopeAngle()),p=Math.floor(d*(g%360)/360);if(!(u<1)){var m=ha.Util.createCanvasElement();m.width=d,m.height=c;var f=m.getContext("2d").getImageData(0,0,d,c);ha.Util.releaseCanvas(m),function(t,e,i){var r,s,a,n,o=t.data,h=e.data,l=t.width,d=t.height,c=i.polarCenterX||l/2,u=i.polarCenterY||d/2,g=0,p=0,m=0,f=0,v=Math.sqrt(c*c+u*u);s=l-c,a=d-u,v=(n=Math.sqrt(s*s+a*a))>v?n:v;var _,y,w,b,x=d,S=l,C=360/S*Math.PI/180;for(y=0;y<S;y+=1)for(w=Math.sin(y*C),b=Math.cos(y*C),_=0;_<x;_+=1)s=Math.floor(c+v*_/x*b),g=o[0+(r=4*((a=Math.floor(u+v*_/x*w))*l+s))],p=o[r+1],m=o[r+2],f=o[r+3],h[0+(r=4*(y+_*l))]=g,h[r+1]=p,h[r+2]=m,h[r+3]=f}(t,f,{polarCenterX:d/2,polarCenterY:c/2});for(var v=d/Math.pow(2,u);v<=8;)v*=2,u-=1;var _=v=Math.ceil(v),y=0,w=_,b=1;for(p+v>d&&(y=_,w=0,b=-1),i=0;i<c;i+=1)for(e=y;e!==w;e+=b)h=4*(d*i+Math.round(e+p)%d),s=f.data[h+0],a=f.data[h+1],n=f.data[h+2],o=f.data[h+3],l=4*(d*i+e),f.data[l+0]=s,f.data[l+1]=a,f.data[l+2]=n,f.data[l+3]=o;for(i=0;i<c;i+=1)for(_=Math.floor(v),r=0;r<u;r+=1){for(e=0;e<_+1;e+=1)h=4*(d*i+e),s=f.data[h+0],a=f.data[h+1],n=f.data[h+2],o=f.data[h+3],l=4*(d*i+2*_-e-1),f.data[l+0]=s,f.data[l+1]=a,f.data[l+2]=n,f.data[l+3]=o;_*=2}!function(t,e,i){var r,s,a,n,o,h,l=t.data,d=e.data,c=t.width,u=t.height,g=i.polarCenterX||c/2,p=i.polarCenterY||u/2,m=0,f=0,v=0,_=0,y=Math.sqrt(g*g+p*p);s=c-g,a=u-p,y=(h=Math.sqrt(s*s+a*a))>y?h:y;var w,b,x,S=u,C=c,P=i.polarRotation||0;for(s=0;s<c;s+=1)for(a=0;a<u;a+=1)n=s-g,o=a-p,w=Math.sqrt(n*n+o*o)*S/y,b=(b=(180*Math.atan2(o,n)/Math.PI+360+P)%360)*C/360,x=Math.floor(b),m=l[0+(r=4*(Math.floor(w)*c+x))],f=l[r+1],v=l[r+2],_=l[r+3],d[0+(r=4*(a*c+s))]=m,d[r+1]=f,d[r+2]=v,d[r+3]=_}(f,t,{polarRotation:0})}},na.Factory.addGetterSetter(oa.Node,"kaleidoscopePower",2,(0,la.getNumberValidator)(),na.Factory.afterSetFilter),na.Factory.addGetterSetter(oa.Node,"kaleidoscopeAngle",0,(0,la.getNumberValidator)(),na.Factory.afterSetFilter);var da={};Object.defineProperty(da,"__esModule",{value:!0}),da.Mask=void 0;const ca=it,ua=et,ga=rt;function pa(t,e,i){var r=4*(i*t.width+e),s=[];return s.push(t.data[r++],t.data[r++],t.data[r++],t.data[r++]),s}function ma(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2))}da.Mask=function(t){var e=function(t,e){var i=pa(t,0,0),r=pa(t,t.width-1,0),s=pa(t,0,t.height-1),a=pa(t,t.width-1,t.height-1),n=e||10;if(ma(i,r)<n&&ma(r,a)<n&&ma(a,s)<n&&ma(s,i)<n){for(var o=function(t){for(var e=[0,0,0],i=0;i<t.length;i++)e[0]+=t[i][0],e[1]+=t[i][1],e[2]+=t[i][2];return e[0]/=t.length,e[1]/=t.length,e[2]/=t.length,e}([r,i,a,s]),h=[],l=0;l<t.width*t.height;l++){var d=ma(o,[t.data[4*l],t.data[4*l+1],t.data[4*l+2]]);h[l]=d<n?0:255}return h}}(t,this.threshold());return e&&function(t,e){for(var i=0;i<t.width*t.height;i++)t.data[4*i+3]=e[i]}(t,e=function(t,e,i){for(var r=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],s=Math.round(Math.sqrt(r.length)),a=Math.floor(s/2),n=[],o=0;o<i;o++)for(var h=0;h<e;h++){for(var l=o*e+h,d=0,c=0;c<s;c++)for(var u=0;u<s;u++){var g=o+c-a,p=h+u-a;if(g>=0&&g<i&&p>=0&&p<e){var m=r[c*s+u];d+=t[g*e+p]*m}}n[l]=d}return n}(e=function(t,e,i){for(var r=[1,1,1,1,1,1,1,1,1],s=Math.round(Math.sqrt(r.length)),a=Math.floor(s/2),n=[],o=0;o<i;o++)for(var h=0;h<e;h++){for(var l=o*e+h,d=0,c=0;c<s;c++)for(var u=0;u<s;u++){var g=o+c-a,p=h+u-a;if(g>=0&&g<i&&p>=0&&p<e){var m=r[c*s+u];d+=t[g*e+p]*m}}n[l]=d>=1020?255:0}return n}(e=function(t,e,i){for(var r=[1,1,1,1,0,1,1,1,1],s=Math.round(Math.sqrt(r.length)),a=Math.floor(s/2),n=[],o=0;o<i;o++)for(var h=0;h<e;h++){for(var l=o*e+h,d=0,c=0;c<s;c++)for(var u=0;u<s;u++){var g=o+c-a,p=h+u-a;if(g>=0&&g<i&&p>=0&&p<e){var m=r[c*s+u];d+=t[g*e+p]*m}}n[l]=2040===d?255:0}return n}(e,t.width,t.height),t.width,t.height),t.width,t.height)),t},ca.Factory.addGetterSetter(ua.Node,"threshold",0,(0,ga.getNumberValidator)(),ca.Factory.afterSetFilter);var fa={};Object.defineProperty(fa,"__esModule",{value:!0}),fa.Noise=void 0;const va=it,_a=et,ya=rt;fa.Noise=function(t){var e,i=255*this.noise(),r=t.data,s=r.length,a=i/2;for(e=0;e<s;e+=4)r[e+0]+=a-2*a*Math.random(),r[e+1]+=a-2*a*Math.random(),r[e+2]+=a-2*a*Math.random()},va.Factory.addGetterSetter(_a.Node,"noise",.2,(0,ya.getNumberValidator)(),va.Factory.afterSetFilter);var wa={};Object.defineProperty(wa,"__esModule",{value:!0}),wa.Pixelate=void 0;const ba=it,xa=tt,Sa=et,Ca=rt;wa.Pixelate=function(t){var e,i,r,s,a,n,o,h,l,d,c,u,g,p,m=Math.ceil(this.pixelSize()),f=t.width,v=t.height,_=Math.ceil(f/m),y=Math.ceil(v/m),w=t.data;if(m<=0)xa.Util.error("pixelSize value can not be <= 0");else for(u=0;u<_;u+=1)for(g=0;g<y;g+=1){for(s=0,a=0,n=0,o=0,l=(h=u*m)+m,c=(d=g*m)+m,p=0,e=h;e<l;e+=1)if(!(e>=f))for(i=d;i<c;i+=1)i>=v||(s+=w[(r=4*(f*i+e))+0],a+=w[r+1],n+=w[r+2],o+=w[r+3],p+=1);for(s/=p,a/=p,n/=p,o/=p,e=h;e<l;e+=1)if(!(e>=f))for(i=d;i<c;i+=1)i>=v||(w[(r=4*(f*i+e))+0]=s,w[r+1]=a,w[r+2]=n,w[r+3]=o)}},ba.Factory.addGetterSetter(Sa.Node,"pixelSize",8,(0,Ca.getNumberValidator)(),ba.Factory.afterSetFilter);var Pa={};Object.defineProperty(Pa,"__esModule",{value:!0}),Pa.Posterize=void 0;const ka=it,Ea=et,Aa=rt;Pa.Posterize=function(t){var e,i=Math.round(254*this.levels())+1,r=t.data,s=r.length,a=255/i;for(e=0;e<s;e+=1)r[e]=Math.floor(r[e]/a)*a},ka.Factory.addGetterSetter(Ea.Node,"levels",.5,(0,Aa.getNumberValidator)(),ka.Factory.afterSetFilter);var Ta={};Object.defineProperty(Ta,"__esModule",{value:!0}),Ta.RGB=void 0;const Ma=it,Fa=et,Oa=rt;Ta.RGB=function(t){var e,i,r=t.data,s=r.length,a=this.red(),n=this.green(),o=this.blue();for(e=0;e<s;e+=4)i=(.34*r[e]+.5*r[e+1]+.16*r[e+2])/255,r[e]=i*a,r[e+1]=i*n,r[e+2]=i*o,r[e+3]=r[e+3]},Ma.Factory.addGetterSetter(Fa.Node,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),Ma.Factory.addGetterSetter(Fa.Node,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),Ma.Factory.addGetterSetter(Fa.Node,"blue",0,Oa.RGBComponent,Ma.Factory.afterSetFilter);var Ra={};Object.defineProperty(Ra,"__esModule",{value:!0}),Ra.RGBA=void 0;const Ia=it,Da=et,La=rt;Ra.RGBA=function(t){var e,i,r=t.data,s=r.length,a=this.red(),n=this.green(),o=this.blue(),h=this.alpha();for(e=0;e<s;e+=4)i=1-h,r[e]=a*h+r[e]*i,r[e+1]=n*h+r[e+1]*i,r[e+2]=o*h+r[e+2]*i},Ia.Factory.addGetterSetter(Da.Node,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),Ia.Factory.addGetterSetter(Da.Node,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),Ia.Factory.addGetterSetter(Da.Node,"blue",0,La.RGBComponent,Ia.Factory.afterSetFilter),Ia.Factory.addGetterSetter(Da.Node,"alpha",1,(function(t){return this._filterUpToDate=!1,t>1?1:t<0?0:t}));var Va={};Object.defineProperty(Va,"__esModule",{value:!0}),Va.Sepia=void 0;Va.Sepia=function(t){var e,i,r,s,a=t.data,n=a.length;for(e=0;e<n;e+=4)i=a[e+0],r=a[e+1],s=a[e+2],a[e+0]=Math.min(255,.393*i+.769*r+.189*s),a[e+1]=Math.min(255,.349*i+.686*r+.168*s),a[e+2]=Math.min(255,.272*i+.534*r+.131*s)};var Ga={};Object.defineProperty(Ga,"__esModule",{value:!0}),Ga.Solarize=void 0;Ga.Solarize=function(t){var e=t.data,i=t.width,r=4*i,s=t.height;do{var a=(s-1)*r,n=i;do{var o=a+4*(n-1),h=e[o],l=e[o+1],d=e[o+2];h>127&&(h=255-h),l>127&&(l=255-l),d>127&&(d=255-d),e[o]=h,e[o+1]=l,e[o+2]=d}while(--n)}while(--s)};var za={};Object.defineProperty(za,"__esModule",{value:!0}),za.Threshold=void 0;const Na=it,Ua=et,Wa=rt;za.Threshold=function(t){var e,i=255*this.threshold(),r=t.data,s=r.length;for(e=0;e<s;e+=1)r[e]=r[e]<i?0:255},Na.Factory.addGetterSetter(Ua.Node,"threshold",.5,(0,Wa.getNumberValidator)(),Na.Factory.afterSetFilter),Object.defineProperty(Z,"__esModule",{value:!0}),Z.Konva=void 0;const ja=$,Ba=Fe,Ha=Ge,Ka=ni,Ya=ui,Xa=_i,qa=Pi,Ja=ze,Za=Ye,$a=zi,Qa=Ki,tn=$i,en=ar,rn=ur,sn=_r,an=Gr,nn=Jr,on=vs,hn=Cs,ln=Fs,dn=Ds,cn=zs,un=Bs,gn=qs,pn=Js,mn=ta,fn=sa,vn=aa,_n=da,yn=fa,wn=wa,bn=Pa,xn=Ta,Sn=Ra,Cn=Va,Pn=Ga,kn=za;Z.Konva=ja.Konva.Util._assign(ja.Konva,{Arc:Ba.Arc,Arrow:Ha.Arrow,Circle:Ka.Circle,Ellipse:Ya.Ellipse,Image:Xa.Image,Label:qa.Label,Tag:qa.Tag,Line:Ja.Line,Path:Za.Path,Rect:$a.Rect,RegularPolygon:Qa.RegularPolygon,Ring:tn.Ring,Sprite:en.Sprite,Star:rn.Star,Text:sn.Text,TextPath:an.TextPath,Transformer:nn.Transformer,Wedge:on.Wedge,Filters:{Blur:hn.Blur,Brighten:ln.Brighten,Contrast:dn.Contrast,Emboss:cn.Emboss,Enhance:un.Enhance,Grayscale:gn.Grayscale,HSL:pn.HSL,HSV:mn.HSV,Invert:fn.Invert,Kaleidoscope:vn.Kaleidoscope,Mask:_n.Mask,Noise:yn.Noise,Pixelate:wn.Pixelate,Posterize:bn.Posterize,RGB:xn.RGB,RGBA:Sn.RGBA,Sepia:Cn.Sepia,Solarize:Pn.Solarize,Threshold:kn.Threshold}});var En=J.exports;Object.defineProperty(En,"__esModule",{value:!0});const An=Z;J.exports=An.Konva;var Tn=q(J.exports);class Mn{get HexColor(){return"#"+this._hex}get RGB(){return{r:this.R,g:this.G,b:this.B}}constructor(t,e,i){this.setColor(t,e,i)}setColor(t,e,i){this.R=t,this.G=e,this.B=i,this._hex=this.rgbToHex(t,e,i)}rgbToHex(t,e,i){const r=t=>{const e=t.toString(16);return"0"===e?"00":e};return r(t)+r(e)+r(i)}}const Fn=new Map([["solid",[]],["dot",[30,30,.001,30]],["dash",[30,30]]]);class On{constructor(t,e=null){var i,r;if(e)return void(this._ref=e);if(!t.points)return;const s=[];t.points.forEach((t=>s.push(t.x,t.y))),this._ref=new Tn.Line({stroke:null!==(i=t.color)&&void 0!==i?i:"#ff0000",strokeWidth:null!==(r=t.width)&&void 0!==r?r:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:s,draggable:!0,strokeScaleEnabled:!1,dash:Fn.get(t.type)||[]}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"line"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){return this._ref.points()}setLineWidth(t){this._ref.strokeWidth(t)}getLineWidth(){return this._ref.strokeWidth()}getLineType(){let t;switch(this._ref.dash()||[]){case Fn.get("dot"):t="dot";break;case Fn.get("dash"):t="dash";break;default:t="solid"}return t}setLineType(t){const e=Fn.get(t);e&&this._ref.dash(e)}addPoints(t){let e=this._ref.points();t.forEach((t=>{e=e.concat([t.x,t.y])})),this._ref.points(e)}}class Rn{constructor(t,e=null){var i,r,s;this.TEXT_FONT_FAMILY="Calibri",e?this._ref=e:t&&t.text&&(this._ref=new Tn.Text({x:t.position.x,y:t.position.y,text:t.text,fontSize:null!==(i=t.fontSize)&&void 0!==i?i:34,fontFamily:this.TEXT_FONT_FAMILY,fill:null!==(r=t.color)&&void 0!==r?r:"#ff0000",align:"left",draggable:!0,rotation:null!==(s=t.rotation)&&void 0!==s?s:0}),this._ref.id(this._ref._id.toString()))}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"text"}getColor(){return this._ref.fill()}setColor(t){this._ref.fill(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getText(){return this._ref.text()}setText(t){this._ref.text(t)}getPosition(){return this._ref.getPosition()}setPosition(t,e){this._ref.setPosition({x:t,y:e})}getFontSize(){return this._ref.fontSize()}setFontSize(t){this._ref.fontSize(t)}}class In{constructor(t,e=null){var i,r,s,a;e?this._ref=e:t.position&&(this._ref=new Tn.Rect({stroke:null!==(i=t.color)&&void 0!==i?i:"#ff0000",strokeWidth:null!==(r=t.lineWidth)&&void 0!==r?r:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",x:t.position.x,y:t.position.y,width:null!==(s=t.width)&&void 0!==s?s:200,height:null!==(a=t.height)&&void 0!==a?a:200,draggable:!0,strokeScaleEnabled:!1}),this._ref.id(this._ref._id.toString()))}getPosition(){return this._ref.position()}getWidth(){return this._ref.width()}getHeigth(){return this._ref.height()}setWidth(t){this._ref.width(t)}setHeight(t){this._ref.height(t)}setPosition(t,e){this._ref.setPosition({x:t,y:e})}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"rectangle"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}setLineWidth(t){this._ref.strokeWidth(t)}getLineWidth(){return this._ref.strokeWidth()}}class Dn{constructor(t,e=null){var i,r;e?this._ref=e:t.position&&(this._ref=new Tn.Ellipse({stroke:null!==(i=t.color)&&void 0!==i?i:"#ff0000",strokeWidth:null!==(r=t.lineWidth)&&void 0!==r?r:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",x:t.position.x,y:t.position.y,radiusX:t.radius.x,radiusY:t.radius.y,draggable:!0,strokeScaleEnabled:!1}),this._ref.id(this._ref._id.toString()))}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.setPosition({x:t,y:e})}getRadiusX(){return this._ref.radiusX()}setRadiusX(t){this._ref.radius({x:t,y:this._ref.radiusY()})}getRadiusY(){return this._ref.radiusY()}setRadiusY(t){this._ref.radius({x:this._ref.radiusX(),y:t})}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"ellipse"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}}class Ln{constructor(t,e=null){var i,r;e?this._ref=e:t.start&&t.end&&(this._ref=new Tn.Arrow({stroke:null!==(i=t.color)&&void 0!==i?i:"#ff0000",fill:null!==(r=t.color)&&void 0!==r?r:"#ff0000",strokeWidth:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:[t.start.x,t.start.y,t.end.x,t.end.y],draggable:!0,strokeScaleEnabled:!1}),this._ref.id(this._ref._id.toString()))}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"arrow"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){const t=this._ref.points();return[{x:t[0],y:t[1]},{x:t[2],y:t[3]}]}setPoints(t){2===t.length&&this._ref.points([t[0].x,t[0].y,t[1].x,t[1].y])}getStartPoint(){const t=this._ref.points();return{x:t[0],y:t[1]}}setStartPoint(t,e){const i=this._ref.points();this._ref.points([t,e,i[2],i[3]])}getEndPoint(){const t=this._ref.points();return{x:t[2],y:t[3]}}setEndPoint(t,e){const i=this._ref.points();this._ref.points([i[0],i[1],t,e])}}class Vn{constructor(t,e=null){if(this._ratio=1,e){if(0===e.height()||0===e.width())return;return this._ref=e,this._canvasImage=e.image(),void(this._ratio=this._ref.height()/this._ref.width())}t.position&&t.src&&(this._canvasImage=new Image,this._ref=new Tn.Image({x:t.position.x,y:t.position.y,image:this._canvasImage,width:t.width,height:t.height,draggable:!0}),this._canvasImage.onload=()=>{this._ref.image(this._canvasImage),this._ratio=0===this._ref.height()||0===this._ref.width()?1:this._ref.height()/this._ref.width()},this._canvasImage.src=t.src,this._ref.id(this._ref._id.toString()))}getSrc(){return this._canvasImage.src}setSrc(t){this._canvasImage.src=t}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t),this._ref.height(t*this._ratio)}getHeight(){return this._ref.height()}setHeight(t){this._ref.height(t),this._ref.width(t/this._ratio)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"image"}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPosition(){return this._ref.getPosition()}setPosition(t,e){this._ref.setPosition({x:t,y:e})}}class Gn{constructor(t,e=null){var i,r,s,a;if(e)return void(this._ref=e);if(!t.position||!t.width||!t.height)return;const n=16;this._ref=new Tn.Shape({x:t.position.x,y:t.position.y,width:null!==(i=t.width)&&void 0!==i?i:200,height:null!==(r=t.height)&&void 0!==r?r:200,stroke:null!==(s=t.color)&&void 0!==s?s:"#ff0000",strokeWidth:null!==(a=t.lineWidth)&&void 0!==a?a:5,draggable:!0,strokeScaleEnabled:!1,globalCompositeOperation:"source-over",sceneFunc:(t,e)=>{const i=[{x:0,y:0},{x:0+this._ref.width(),y:0},{x:0+this._ref.width(),y:0+this._ref.height()},{x:0,y:0+this._ref.height()},{x:0,y:0}],r=(s={x:0,y:0},a=this._ref.width(),o=this._ref.height(),{x:s.x+a/2,y:s.y+o/2});var s,a,o;t.beginPath();for(let e=0;e<i.length-1;e++){let s=30;const a=i[e+1].x-i[e].x,o=i[e+1].y-i[e].y,h=Math.sqrt(a*a+o*o),l=Math.floor(h/s);s=30+l/(h%s);let d=i[e].x+a/l/2,c=i[e].y+o/l/2;const u=i[e+1].x,g=i[e+1].y,p=Math.atan((g-c)/(u-d)),m=p+Math.PI,f=d>r.x&&c>r.y;for(let e=0;e<l;e++)f?t.arc(d,c,n,p,m):t.arc(d,c,n,m,p),d+=a/l,c+=o/l}t.closePath(),t.fillStrokeShape(e)}}),this._ref.className="Cloud",this._ref.on("transform",(t=>{const e=t.target.attrs,i=this._ref.width()*e.scaleX,r=this._ref.height()*e.scaleY;i<100||r<100||(Math.abs(e.scaleX-1)>1e-5&&this._ref.width(i),Math.abs(e.scaleY-1)>1e-5&&this._ref.height(r)),this._ref.scale({x:1,y:1})})),this._ref.getSelfRect=()=>({x:-16,y:-16,width:this._ref.width()+32,height:this._ref.height()+32}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"cloud"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.position({x:t,y:e})}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t)}getHeigth(){return this._ref.height()}setHeight(t){this._ref.height(t)}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}}const zn=new Map([[W.Line,{name:"Line",initializer:t=>new On(null,t)}],[W.Text,{name:"Text",initializer:t=>new Rn(null,t)}],[W.Rectangle,{name:"Rect",initializer:t=>new In(null,t)}],[W.Ellipse,{name:"Ellipse",initializer:t=>new Dn(null,t)}],[W.Arrow,{name:"Arrow",initializer:t=>new Ln(null,t)}],[W.Image,{name:"Image",initializer:t=>new Vn(null,t)}],[W.Cloud,{name:"Cloud",initializer:t=>new Gn(null,t)}]]);class Nn{constructor(){this._isInitialized=!1,this._zIndex=1,this._markupContainerName="markupContainer",this.lineWidth=4,this.changeActiveDragger=t=>{const e=t.data;this._markupContainer.className=this._canvasOriginal.className.split(" ").filter((t=>!t.startsWith("oda-cursor-"))).filter((t=>t)).concat(`oda-cursor-${e.toLowerCase()}`).join(" "),this.removeTextInput();const i=W[e];zn.get(i)?(this._markupMode=i,this._markupIsActive=!0):(this._markupIsActive=!1,this._konvaTransformer.nodes([]))},this.resize=()=>{var t,e;null===(t=this._konvaStage)||void 0===t||t.width(this._canvasOriginal.clientWidth),null===(e=this._konvaStage)||void 0===e||e.height(this._canvasOriginal.clientHeight)},this.pan=t=>{const e=t.dX/window.devicePixelRatio,i=t.dY/window.devicePixelRatio;Object.values(W).forEach((t=>this.konvaLayerFind(t).forEach((t=>t.move({x:e,y:i})))))},this.redirectToViewer=t=>{this._viewer.emit(t)}}initialize(t,e,i=[]){if(!Tn)throw new Error('Konva Markup: Error during Markup Initialization. Konva is not initialized. Update node_modules or add to your page <script src="https://unpkg.com/konva@9/konva.min.js"><\/script>');this._viewer=t,this._canvasOriginal=e,this._canvasEvents=i,this._markupContainer=document.createElement("div"),this._markupContainer.id=this._markupContainerName,this._markupContainer.style.position="absolute",this._markupContainer.style.top="0px",this._markupContainer.style.left="0px",this._markupContainer.style.outline="0px";this._canvasOriginal.parentElement.appendChild(this._markupContainer),this._markupColor=new Mn(255,0,0),this._markupIsActive=!1,this.initializeKonva(),this.resize(),this._canvasEvents.forEach((t=>this._markupContainer.addEventListener(t,this.redirectToViewer))),this._viewer.addEventListener("resize",this.resize),this._viewer.addEventListener("changeactivedragger",this.changeActiveDragger),this._viewer.addEventListener("pan",this.pan),this._isInitialized=!0}dispose(){this._isInitialized&&(this._canvasEvents.forEach((t=>this._markupContainer.removeEventListener(t,this.redirectToViewer))),this._viewer.removeEventListener("pan",this.pan),this._viewer.removeEventListener("changeactivedragger",this.changeActiveDragger),this._viewer.removeEventListener("resize",this.resize),this.destroyKonva(),this._markupContainer.remove(),this._markupContainer=void 0,this._canvasOriginal=void 0,this._viewer=void 0,this._isInitialized=!1)}getDraggers(){return null}clearOverlay(){this.removeTextInput(),this._konvaTransformer.nodes([]),Object.values(W).forEach((t=>this.konvaLayerFind(t).forEach((t=>t.destroy()))))}getMarkupColor(){return this._markupColor.RGB}setMarkupColor(t,e,i){this._markupColor.setColor(t,e,i)}colorizeAllMarkup(t=255,e=0,i=0){const r=new Mn(t,e,i).HexColor;Object.values(W).forEach((t=>{this.konvaLayerFind(t).forEach((e=>{const i=zn.get(t).initializer(e);i.setColor&&i.setColor(r)}))})),this._konvaLayer.draw()}setViewpoint(t){const e=t.custom_fields.markup_color||{r:255,g:0,b:0};this.setMarkupColor(e.r,e.g,e.b),this.loadMarkup(t)}getViewpoint(){if(!this._viewer.visualizeJs)return{};const t={lines:[],texts:[],arrows:[],clouds:[],ellipses:[],images:[],rectangles:[]};return t.snapshot={data:this.combineMarkupWithDrawing()},t.custom_fields={markup_color:this.getMarkupColor()},this.fillViewpointShapes(t),t.description=(new Date).toDateString(),t}createObject(t,e){let i,r=this._zIndex;switch(t){case"line":i=new On(e),r=1;break;case"text":i=new Rn(e);break;case"rectangle":i=new In(e),r=1;break;case"ellipse":i=new Dn(e),r=1;break;case"arrow":i=new Ln(e);break;case"image":i=new Vn(e),r=0;break;case"cloud":i=new Gn(e),r=1;break;default:throw new Error("Markup CreateObject - unsupported type has been detected.")}return this.addObject(i),i.setZIndex(r),this._zIndex++,i}getObjects(){const t=[];return this.konvaLayerFind(W.Line).forEach((e=>{t.push(new On(null,e))})),this.konvaLayerFind(W.Text).forEach((e=>{t.push(new Rn(null,e))})),this.konvaLayerFind(W.Rectangle).forEach((e=>{t.push(new In(null,e))})),this.konvaLayerFind(W.Ellipse).forEach((e=>{t.push(new Dn(null,e))})),this.konvaLayerFind(W.Arrow).forEach((e=>{t.push(new Ln(null,e))})),this.konvaLayerFind(W.Image).forEach((e=>{t.push(new Vn(null,e))})),this.konvaLayerFind(W.Cloud).forEach((e=>{t.push(new Gn(null,e))})),t}getSelectedObjects(){const t=[];return this._konvaTransformer.nodes().forEach((e=>{switch(e.className){case"Line":t.push(new On(null,e));break;case"Text":t.push(new Rn(null,e));break;case"Rect":t.push(new In(null,e));break;case"Ellipse":t.push(new Dn(null,e));break;case"Arrow":t.push(new Ln(null,e));break;case"Image":t.push(new Vn(null,e));break;case"Cloud":t.push(new Gn(null,e))}})),t}selectObjects(t){const e=this._konvaTransformer.nodes().concat(t.map((t=>t.ref())));this._konvaTransformer.nodes(e)}clearSelected(){this._konvaTransformer.nodes([])}getPoint3dFromArray(t){return{x:t[0],y:t[1],z:t[2]}}fillViewpointShapes(t){const e=this.getMarkupLines();e&&e.length>0&&(null==e||e.forEach((e=>{t.lines.push(e)})));const i=this.getMarkupTexts();i&&i.length>0&&(null==i||i.forEach((e=>{t.texts.push(e)})));const r=this.getMarkupRectangles();r&&r.length>0&&(null==r||r.forEach((e=>{t.rectangles.push(e)})));const s=this.getMarkupEllipses();s&&s.length>0&&(null==s||s.forEach((e=>{t.ellipses.push(e)})));const a=this.getMarkupArrows();a&&a.length>0&&(null==a||a.forEach((e=>{t.arrows.push(e)})));const n=this.getMarkupImages();n&&n.length>0&&(null==n||n.forEach((e=>{t.images.push(e)})));const o=this.getMarkupClouds();o&&o.length>0&&(null==o||o.forEach((e=>{t.clouds.push(e)})))}addObject(t){this._konvaLayer.add(t.ref())}konvaLayerFind(t){const e=zn.get(t);if(e){return this._konvaLayer.find(e.name).filter((t=>t.parent instanceof Tn.Layer))}}initializeKonva(){this._konvaStage=new Tn.Stage({container:this._markupContainerName,width:this._canvasOriginal.clientWidth,height:this._canvasOriginal.clientHeight});const t=this._konvaStage,e=new Tn.Layer({pixelRation:window.devicePixelRatio});t.add(e),this._konvaLayer=e;const i=new Tn.Transformer({shouldOverdrawWholeArea:!1});this._konvaTransformer=i,e.add(i);let r,s=!1;t.on("mousedown touchstart",(e=>{if(!this._markupIsActive||e.target!==t||this._markupMode===W.Text)return;if(e.target===t&&i.nodes().length>0)return void i.nodes([]);const a=t.getPointerPosition();this._markupMode===W.Line?(r=this.addLine([a.x,a.y,a.x,a.y]),s=!0):this._markupMode===W.Rectangle?this.addRectangle({x:a.x,y:a.y},50,50):this._markupMode===W.Ellipse?this.addEllipse({x:a.x,y:a.y},{x:50,y:50}):this._markupMode===W.Arrow?this.addArrow({x:a.x,y:a.y},{x:a.x+50,y:a.y+50}):this._markupMode===W.Cloud&&this.addCloud({x:a.x,y:a.y},200,400)})),t.on("mouseup touchend",(t=>{this._markupIsActive&&(s=!1)})),t.on("mousemove touchmove",(e=>{if(!this._markupIsActive)return;if(!s)return;const i=t.getPointerPosition(),a=r.points().concat([i.x,i.y]);r.points(a)})),t.on("click tap",(e=>{if(!this._markupIsActive)return;if(e.target===t){if(this._markupMode===W.Text)if(this._textInputRef)this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle);else if(0===i.nodes().length){const i=t.getPointerPosition();this.createTextInput(i,e.evt.pageX,e.evt.pageY,0,null)}return void i.nodes([])}if("Text"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._textInputRef?this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle):this.createTextInput({x:e.target.attrs.x,y:e.target.attrs.y},e.evt.pageX,e.evt.pageY,e.target.attrs.rotation,e.target.attrs.text));this.removeTextInput(),i.nodes().filter((t=>"Cloud"===t.className)).length>0||"Cloud"===e.target.className?i.rotateEnabled(!1):i.rotateEnabled(!0);const r=e.evt.shiftKey||e.evt.ctrlKey||e.evt.metaKey,s=i.nodes().indexOf(e.target)>=0;if(r||s){if(r&&s){const t=i.nodes().slice();t.splice(t.indexOf(e.target),1),i.nodes(t)}else if(r&&!s){const t=i.nodes().concat([e.target]);i.nodes(t)}}else i.nodes([e.target])}));const a=t.container();a.tabIndex=1,a.focus(),a.addEventListener("keydown",(t=>{if(this._markupIsActive){if("Delete"===t.code){return this._konvaTransformer.nodes().length>0&&(this._konvaTransformer.nodes().forEach((t=>t.destroy())),this._konvaTransformer.nodes([])),void e.draw()}t.preventDefault()}}))}destroyKonva(){this.clearOverlay(),this._konvaStage.destroy(),this._konvaLayer=void 0,this._konvaTransformer=void 0,this._konvaStage=void 0}getMarkupLines(){const t=[];return this.konvaLayerFind(W.Line).forEach((e=>{const i=e.points();if(!i)return;const r=[],s=e.getAbsoluteTransform();for(let t=0;t<i.length;t+=2){const e=s.point({x:i[t],y:i[t+1]}),a=this._viewer.visViewer().screenToWorld(e.x*window.devicePixelRatio,e.y*window.devicePixelRatio);r.push(a)}const a=new On(null,e);t.push({id:a.id(),points:r.map((t=>this.getPoint3dFromArray(t))),color:a.getColor()||"ff0000",type:a.getLineType()||"solid",width:a.getLineWidth()||3})})),t}getMarkupTexts(){const t=[];let e=1;const i=this._viewer.visViewer().activeView.projectionMatrix.get(1,1),r=1e-6;return(i>r||i<-r)&&(e=1/i),this.konvaLayerFind(W.Text).forEach((i=>{if(!i)return;const r=this._viewer.visViewer().screenToWorld(i.x()*window.devicePixelRatio,i.y()*window.devicePixelRatio),s=new Rn(null,i);t.push({id:s.id(),position:this.getPoint3dFromArray(r),text:s.getText(),text_size:.02*e,angle:s.getRotation(),color:s.getColor(),font_size:s.getFontSize()})})),t}getMarkupRectangles(){const t=[];return this.konvaLayerFind(W.Rectangle).forEach((e=>{const i=e.position(),r=this._viewer.visViewer().screenToWorld(i.x*window.devicePixelRatio,i.y*window.devicePixelRatio),s=new In(null,e);t.push({id:s.id(),position:this.getPoint3dFromArray(r),width:s.getWidth(),height:s.getHeigth(),line_width:s.getLineWidth(),color:s.getColor()})})),t}getMarkupEllipses(){const t=[];return this.konvaLayerFind(W.Ellipse).forEach((e=>{const i=e.position(),r=this._viewer.visViewer().screenToWorld(i.x*window.devicePixelRatio,i.y*window.devicePixelRatio),s=new Dn(null,e);t.push({id:s.id(),position:this.getPoint3dFromArray(r),radius:{x:e.getRadiusX(),y:e.getRadiusY()},line_width:s.getLineWidth(),color:s.getColor()})})),t}getMarkupArrows(){const t=[];return this.konvaLayerFind(W.Arrow).forEach((e=>{const i=e.getAbsoluteTransform(),r=i.point({x:e.points()[0],y:e.points()[1]}),s=this._viewer.visViewer().screenToWorld(r.x*window.devicePixelRatio,r.y*window.devicePixelRatio),a=i.point({x:e.points()[2],y:e.points()[3]}),n=this._viewer.visViewer().screenToWorld(a.x*window.devicePixelRatio,a.y*window.devicePixelRatio),o=new Ln(null,e);t.push({id:o.id(),start:this.getPoint3dFromArray(s),end:this.getPoint3dFromArray(n),color:o.getColor()})})),t}getMarkupImages(){const t=[];return this.konvaLayerFind(W.Image).forEach((e=>{const i=e.position(),r=this._viewer.visViewer().screenToWorld(i.x*window.devicePixelRatio,i.y*window.devicePixelRatio),s=new Vn(null,e);t.push({id:s.id(),position:this.getPoint3dFromArray(r),src:s.getSrc(),width:s.getWidth(),height:s.getHeight()})})),t}getMarkupClouds(){const t=[];return this.konvaLayerFind(W.Cloud).forEach((e=>{const i=e.position(),r=this._viewer.visViewer().screenToWorld(i.x*window.devicePixelRatio,i.y*window.devicePixelRatio),s=new Gn(null,e);t.push({id:s.id(),position:this.getPoint3dFromArray(r),width:s.getWidth(),height:s.getHeigth(),line_width:s.getLineWidth(),color:s.getColor()})})),t}loadMarkup(t){var e,i,r,s,a,n,o;null===(e=t.lines)||void 0===e||e.forEach((t=>{const e=[];t.points.forEach((t=>{const i=c([t.x,t.y,t.z],this._viewer.visualizeJs,this._viewer.visViewer());e.push(i.x),e.push(i.y)})),this.addLine(e,t.color,t.type,t.width,t.id)})),null===(i=t.texts)||void 0===i||i.forEach((t=>{const e=c([t.position.x,t.position.y,t.position.z],this._viewer.visualizeJs,this._viewer.visViewer());this.addText(t.text,e,t.angle,t.color,t.text_size,t.font_size,t.id)})),null===(r=t.rectangles)||void 0===r||r.forEach((t=>{const e=c([t.position.x,t.position.y,t.position.z],this._viewer.visualizeJs,this._viewer.visViewer());this.addRectangle({x:e.x,y:e.y},t.width,t.height,t.line_width,t.color,t.id)})),null===(s=t.ellipses)||void 0===s||s.forEach((t=>{const e=c([t.position.x,t.position.y,t.position.z],this._viewer.visualizeJs,this._viewer.visViewer());this.addEllipse({x:e.x,y:e.y},{x:t.radius.x,y:t.radius.y},t.line_width,t.color,t.id)})),null===(a=t.arrows)||void 0===a||a.forEach((t=>{const e=c([t.start.x,t.start.y,t.start.z],this._viewer.visualizeJs,this._viewer.visViewer()),i=c([t.end.x,t.end.y,t.end.z],this._viewer.visualizeJs,this._viewer.visViewer());this.addArrow({x:e.x,y:e.y},{x:i.x,y:i.y},t.color,t.id)})),null===(n=t.clouds)||void 0===n||n.forEach((t=>{const e=c([t.position.x,t.position.y,t.position.z],this._viewer.visualizeJs,this._viewer.visViewer());this.addCloud({x:e.x,y:e.y},t.width,t.height,t.line_width,t.color,t.id)})),null===(o=t.images)||void 0===o||o.forEach((t=>{const e=c([t.position.x,t.position.y,t.position.z],this._viewer.visualizeJs,this._viewer.visViewer());this.addImage({x:e.x,y:e.y},t.src,t.width,t.height,t.id)}))}combineMarkupWithDrawing(){this._konvaTransformer.nodes().length>0&&this._konvaTransformer.nodes([]);const t=document.createElement("canvas");t.height=this._canvasOriginal.height,t.width=this._canvasOriginal.width;const e=t.getContext("2d");return e.drawImage(this._canvasOriginal,0,0),e.drawImage(this._konvaStage.toCanvas({pixelRatio:window.devicePixelRatio}),0,0),t.toDataURL("image/jpeg",.25)}addLine(t,e,i,r,s){if(!t||0===t.length)return;const a=[];for(let e=0;e<t.length;e+=2)a.push({x:t[e],y:t[e+1]});const n=new On({points:a,type:i||"solid",width:r||this.lineWidth,color:e||this._markupColor.HexColor,id:s}).ref();return this._konvaLayer.add(n),n}createTextInput(t,e,i,r,s){this._textInputRef?this.removeTextInput():(this._textInputPos=t,this._textInputAngle=r,this._textInputRef=document.createElement("textarea"),this._textInputRef.style.zIndex="9999",this._textInputRef.style.position="absolute",this._textInputRef.style.display="block",this._textInputRef.style.top=i+"px",this._textInputRef.style.left=e+"px",this._textInputRef.onkeydown=t=>{"Enter"===t.key&&(t.preventDefault(),this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle)),"Escape"===t.key&&(t.preventDefault(),this.removeTextInput())},s&&(this._textInputRef.value=s),document.body.appendChild(this._textInputRef),setTimeout((()=>{this._textInputRef.focus()}),50))}removeTextInput(){var t;null===(t=this._textInputRef)||void 0===t||t.remove(),this._textInputRef=null,this._textInputPos=null,this._textInputAngle=0}addText(t,e,i,r,s,a,n){if(t){const o=1e-6;if(s&&s>o&&(!a||a<o)){const t=.02;let e=1;const i=this._viewer.visViewer().activeView.projectionMatrix.get(1,1);(i>o||i<-o)&&(e=1/i),a=s/(e/t)/34}const h=new Rn({position:{x:e.x,y:e.y},text:t,rotation:i,fontSize:a,color:r||this._markupColor.HexColor,id:n});this._konvaLayer.add(h.ref())}const o=this._konvaTransformer.nodes();o.length>0&&(o[0].destroy(),this._konvaTransformer.nodes([])),this.removeTextInput()}addRectangle(t,e,i,r,s,a){if(!t)return;const n=new In({position:t,width:e,height:i,lineWidth:r||this.lineWidth,color:s||this._markupColor.HexColor,id:a}).ref();return this._konvaLayer.add(n),n}addEllipse(t,e,i,r,s){if(!t)return;const a=new Dn({position:t,radius:e,lineWidth:i,color:r||this._markupColor.HexColor,id:s}).ref();return this._konvaLayer.add(a),a}addArrow(t,e,i,r){if(!t||!e)return;const s=new Ln({start:t,end:e,color:i||this._markupColor.HexColor,id:r}).ref();return this._konvaLayer.add(s),s}addCloud(t,e,i,r,s,a){if(!t||!e||!i)return;const n=new Gn({position:t,width:e,height:i,color:s||this._markupColor.HexColor,lineWidth:r||this.lineWidth,id:a}).ref();return this._konvaLayer.add(n),n}addImage(t,e,i,r,s){if(!t||!i||!r)return;const a=new Vn({position:t,src:e,width:i,height:r,id:s}).ref();return this._konvaLayer.add(a),a}}const Un="$MarkupTempEntity_Line";class Wn extends h{constructor(t){super(t),this.press=!1}dispose(){super.dispose(),this.end(),this.points=null,this.drawPoints=null}start(t,e){const i=this.getViewer().screenToWorld(t,e);this.drawPoints=[i[0],i[1],i[2]]}drag(t,e){if(this.isDragging){const i=this.getViewer().screenToWorld(t,e);this.drawPoints.push(i[0],i[1],i[2]),this._updateFrame()}}end(){this.entity&&(this.entity.delete(),this.drawPoints=null,this.entity=null)}_updateFrame(){if(this.entity){const t=this.getViewer().getMarkupModel();t.removeEntity(this.entity),t.delete(),this.entity.delete()}this.entity=this.getActiveMarkupEntity(Un);const t=this.entity.openObject();t.appendPolyline(this.drawPoints).delete(),t.delete()}}const jn="$MarkupTempEntity_Text";class Bn extends h{constructor(t){super(t),this.TEXT_HEIGHT_ALIGN=24,this.press=!1}dispose(){var t;super.dispose(),null===(t=this.textRef)||void 0===t||t.remove(),this.textRef=null}_finishInput(){var t;this.textRef&&this.textRef.value.trimLeft()&&this._updateFrame(),null===(t=this.textRef)||void 0===t||t.remove(),this.textRef=null}start(t,e,i,r){this.textRef?this._finishInput():(this.textRef=document.createElement("textarea"),this.textRef.style.zIndex="9999",this.textRef.style.position="absolute",this.textRef.style.display="block",this.textRef.style.top=r+"px",this.textRef.style.left=i+"px",this.textRef.onkeypress=t=>{"Enter"===t.key&&(t.preventDefault(),this._finishInput())},document.body.appendChild(this.textRef),this.press=!0,this.m_center=this.screenToWorld(t,e+this.TEXT_HEIGHT_ALIGN),this.needInputText=!0)}_updateFrame(){this.entity=this.getActiveMarkupEntity(jn);const t=this.entity.openObject(),e=this.getViewer().activeView,i=this.toPoint(e.viewPosition),r=this.toPoint(e.viewTarget),s=e.eyeToWorldMatrix,a=i.sub(r).asVector(),n=this.toVector([1,0,0]).transformBy(s),o=this.createMatrix3d();o.setToWorldToPlane(this.toGeVector(a)),n.transformBy(o);const h=-Math.atan2(-n.y,n.x);let l=1;const d=e.projectionMatrix.get(1,1),c=1e-6;d<c&&d>-c||(l=1/d);const u=t.appendText(this.toGePoint(this.m_center),this.textRef.value.trimLeft()),g=u.openAsText();g.setNormal(this.toGeVector(a)),g.setRotation(h),g.setTextSize(.02*l),g.delete(),u.delete(),t.delete()}}class Hn{constructor(){this._markupColor={r:255,g:0,b:0},this.lineWidth=0}initialize(t,e,i){this._viewer=t}dispose(){}getDraggers(){return new Map([[W.Line,Wn],[W.Text,Bn]])}clearOverlay(){if(!this._viewer.visualizeJs)return;const t=this._viewer.visViewer().getMarkupModel();t.clearEntities(),t.delete(),this._viewer.update()}getMarkupColor(){return this._markupColor}setMarkupColor(t,e,i){const r={r:t,g:e,b:i};this._markupColor=r}colorizeAllMarkup(t=255,e=0,i=0){if(!this._viewer.visualizeJs)return;const r=this._viewer.visViewer().getMarkupModel().getEntitiesIterator();for(;!r.done();r.step()){const s=r.getEntity().openObject(),a=s.getName();a!==Un&&a!==jn||s.setColor(t,e,i),s.delete()}r.delete(),this._viewer.update()}setViewpoint(t){function e(t){return[t.x,t.y,t.z]}function i(t,e){return t.Point3d.createFromArray(e)}if(!this._viewer.visualizeJs)return;const r=this._viewer.visLib(),s=r.getViewer().activeView;this._viewer.syncOverlay();const a=t.custom_fields.markup_color||{r:255,g:0,b:0};if(this.setMarkupColor(a.r,a.g,a.b),t.lines)for(const e of t.lines){const t=this._viewer.addMarkupEntity(Un).openObject(),i=[];for(const t of e.points)i.push(t.x,t.y,t.z);t.appendPolyline(i).delete(),t.delete()}if(t.texts){const a=i(r,s.viewPosition),n=i(r,s.viewTarget),o=a.sub(n).asVector();for(const i of t.texts){const t=this._viewer.addMarkupEntity(jn).openObject(),r=t.appendText(e(i.position),i.text),s=r.openAsText();s.setNormal(e(o)),s.setRotation(i.angle),s.setTextSize(i.text_size),s.delete(),r.delete(),t.delete()}}this._viewer.update()}getViewpoint(){function t(t){return{x:t[0],y:t[1],z:t[2]}}if(!this._viewer.visualizeJs)return{};const e=this._viewer.visLib(),i={lines:[],texts:[]},r=e.getViewer().getMarkupModel().getEntitiesIterator();for(;!r.done();r.step()){const e=r.getEntity().openObject(),s=e.getName(),a=e.getGeometryDataIterator();if(a.done()){e.delete();continue}const n=a.getGeometryData();if(s===Un){const e=n.openAsPolyline(),r=e.getPoints(),s={points:[]};for(const e of r)s.points.push(t(e));i.lines.push(s),e.delete()}else if(s===jn){const e=n.openAsText(),r={position:t(e.getPosition()),text:e.getString(),angle:e.getRotation(),text_size:e.getTextSize()};i.texts.push(r),e.delete()}e.delete()}return r.delete(),i.snapshot={data:e.canvas.toDataURL("image/jpeg",.25)},i.custom_fields={markup_color:this.getMarkupColor()},i.description=(new Date).toDateString(),i}getLayer(){throw new Error("Not implemented yet")}createObject(t,e){throw new Error("Not implemented yet")}getObjects(){throw new Error("Not implemented yet")}getSelectedObjects(){throw new Error("Not implemented yet")}selectObjects(t){throw new Error("Not implemented yet")}clearSelected(){throw new Error("Not implemented yet")}}class Kn{static createMarkup(t){let e;switch(t){case U.Konva:e=this.createKonva();break;case U.Visualize:e=this.createVisualize();break;default:throw new Error("Error during Markup Initialization. Markup Type is unknown.")}return e}static createKonva(){return new Nn}static createVisualize(){return new Hn}}const Yn="$OVERLAY_VIEW_NAME",Xn=t=>null!=t;t.OdBaseDragger=h,t.Viewer=class extends n{constructor(t,e={markupType:U.Konva}){var i,r;super(),this.configure(e),this._options=new s(this),this.client=t,this._activeDragger=null,this._renderTime=0,this.markup=Kn.createMarkup(null!==(i=e.markupType)&&void 0!==i?i:U.Konva),this.draggerFactory=new Map,this.registerDragger("Pan",A),this.registerDragger("Orbit",k),this.registerDragger("Zoom",M),this.registerDragger("ZoomWindow",R),this.registerDragger("OrbitAroundBuilding",I),this.registerDragger("MeasureLine",y),this.registerDragger("CuttingPlaneXAxis",x),this.registerDragger("CuttingPlaneYAxis",S),this.registerDragger("CuttingPlaneZAxis",C),this.registerDragger("Walk",w);const n=this.markup.getDraggers();null==n||n.forEach(((t,e)=>{this.registerDragger(e,t)})),this.canvasEvents=a,this.canvaseventlistener=t=>this.emit(t),this._enableAutoUpdate=null===(r=e.enableAutoUpdate)||void 0===r||r,this._isNeedRender=!1,this._isRunAsyncUpdate=!1,this.render=this.render.bind(this),this.resize=this.resize.bind(this)}get options(){return this._options}get visualizeJsUrl(){return this._visualizeJsUrl}configure(t){return this._visualizeJsUrl=t.visualizeJsUrl||"https://opencloud.azureedge.net/libs/visualizejs/master/Visualize.js",this}async initialize(t,e){this.addEventListener("optionschange",(t=>this.syncOptions(t.data))),""===t.style.width&&""===t.style.height&&(t.style.width="100%",t.style.height="100%"),t.parentElement.style.touchAction="none",t.style.touchAction="none",t.width=t.clientWidth*window.devicePixelRatio,t.height=t.clientHeight*window.devicePixelRatio;const i=await(r=this.visualizeJsUrl,s=t=>{const{loaded:i,timeStamp:r,total:s,lengthComputable:a}=t;null==e||e({loaded:i,timeStamp:r,total:s,lengthComputable:a,type:"visualizeprogress"})},V(r).then((t=>new Promise(((e,i)=>{const a=window.getVisualizeLibInst({urlMemFile:r+".wasm",TOTAL_MEMORY:134217728,onprogress:s});a.loadWasmError=i,a.postRun.push((()=>{window.getVisualizeLibInst.script=t,e(a)}))})))));var r,s;return this.visualizeJs=i,this.visualizeJs.canvas=t,this.visualizeJs.Viewer.create(),this.canvas=t,this.canvasEvents.forEach((e=>t.addEventListener(e,this.canvaseventlistener))),this.markup.initialize(this,t,this.canvasEvents),this._resizeObserver=new ResizeObserver(this.resize),this._resizeObserver.observe(t.parentElement),this.resize(),this._zoomWheelDragger=new F(this),this._zoomWheelDragger.name="ZoomWheel",this._zoomWheelDragger.initialize(),this._gestureManager=new L(this),this._gestureManager.initialize(),this.syncOpenCloudVisualStyle(!0),this.syncOptions(),this._renderTime=performance.now(),this.render(this._renderTime),this}dispose(){var t,e,i,r;return this.cancel(),this.emitEvent({type:"dispose"}),this.frameId&&cancelAnimationFrame(this.frameId),this.frameId=0,this.setActiveDragger(""),null===(t=this._zoomWheelDragger)||void 0===t||t.dispose(),null===(e=this._gestureManager)||void 0===e||e.dispose(),this.removeAllListeners(),null===(i=this._resizeObserver)||void 0===i||i.disconnect(),this._resizeObserver=void 0,this.markup.dispose(),this.canvasEvents.forEach((t=>{var e;return null===(e=this.canvas)||void 0===e?void 0:e.removeEventListener(t,this.canvaseventlistener)})),this.canvas=void 0,null===(r=this.visualizeJs)||void 0===r||r.getViewer().clear(),this.visualizeJs=void 0,this}isInitialized(){return!!this.visualizeJs}render(t){var e;if(this.frameId=requestAnimationFrame(this.render),!this.visualizeJs)return;if(this._isRunAsyncUpdate)return;const i=this.visualizeJs.getViewer();if(i.isRunningAnimation()||this._isNeedRender){i.update(),null===(e=this._activeDragger)||void 0===e||e.updatePreview(),this._isNeedRender=!i.getActiveDevice().isValid();const r=(t-this._renderTime)/1e3;this._renderTime=t,this.emitEvent({type:"render",time:t,deltaTime:r})}}resize(){if(!this.visualizeJs)return this;const{clientWidth:t,clientHeight:e}=this.canvas;this.canvas.width=t*window.devicePixelRatio,this.canvas.height=e*window.devicePixelRatio;return this.visualizeJs.getViewer().resize(0,this.canvas.width,this.canvas.height,0),this.update(!0),this.emitEvent({type:"resize",width:t,height:e}),this}update(t){var e,i;this._enableAutoUpdate&&(t?(null===(e=this.visViewer())||void 0===e||e.update(),null===(i=this.activeDragger())||void 0===i||i.updatePreview()):this._isNeedRender=!0),this.emitEvent({type:"update",data:t})}scheduleUpdateAsync(t=50){return new Promise(((e,i)=>{setTimeout((()=>{var r,s;try{null===(r=this.visViewer())||void 0===r||r.update(t),null===(s=this.activeDragger())||void 0===s||s.updatePreview(),e()}catch(t){console.error(t),i()}}),0)}))}async updateAsync(t=50,e=50){this._isRunAsyncUpdate=!0;const i=this.visViewer().getActiveDevice();try{for(let r=0;!i.isValid()&&r<e;r++)await this.scheduleUpdateAsync(t);await this.scheduleUpdateAsync(t)}catch(t){console.error(t)}finally{this._isRunAsyncUpdate=!1}}visLib(){return this.visualizeJs}visViewer(){var t;return null===(t=this.visualizeJs)||void 0===t?void 0:t.getViewer()}syncOpenCloudVisualStyle(t){if(!this.visualizeJs)return this;const e=this.visLib(),i=e.getViewer(),r=i.getActiveDevice();if(r.isNull())return this;const s=r.getActiveView();let a;s.enableDefaultLighting(!0,e.DefaultLightingType.kTwoLights),s.setDefaultLightingIntensity(1.25);try{a=i.findVisualStyle("OpenCloud")}catch(r){t||console.log("OpenCloud visual style not found, creating it on client side"),a=i.createVisualStyle("OpenCloud");const s=new e.OdTvColorDef(66,66,66),n=i.findVisualStyle("Realistic"),o=a.openObject();o.copyFrom(n),o.setOptionInt32(e.VisualStyleOptions.kFaceModifiers,0,e.VisualStyleOperations.kSet),o.setOptionInt32(e.VisualStyleOptions.kEdgeModel,2,e.VisualStyleOperations.kSet),o.setOptionDouble(e.VisualStyleOptions.kEdgeCreaseAngle,60,e.VisualStyleOperations.kSet),o.setOptionInt32(e.VisualStyleOptions.kEdgeStyles,0,e.VisualStyleOperations.kSet),o.setOptionInt32(e.VisualStyleOptions.kEdgeModifiers,8,e.VisualStyleOperations.kSet),o.setOptionColor(e.VisualStyleOptions.kEdgeColorValue,s,e.VisualStyleOperations.kSet),o.delete()}return s.visualStyle=a,s.delete(),r.delete(),this}syncOptions(t=this.options.data){if(!this.visualizeJs)return this;const e=this.visLib(),i=e.getViewer(),r=i.getActiveDevice();if(r.isNull())return this;if(t.showWCS!==i.getEnableWCS()&&i.setEnableWCS(t.showWCS),t.cameraAnimation!==i.getEnableAnimation()&&i.setEnableAnimation(t.cameraAnimation),t.antialiasing!==i.fxaaAntiAliasing3d&&(i.fxaaAntiAliasing3d=t.antialiasing,i.fxaaQuality=5),t.shadows!==i.shadows){i.shadows=t.shadows;const s=e.canvas;r.invalidate([0,s.clientWidth,s.clientHeight,0])}if(t.groundShadow!==i.groundShadow&&(i.groundShadow=t.groundShadow),t.ambientOcclusion!==r.getOptionBool(e.DeviceOptions.kSSAOEnable)){r.setOptionBool(e.DeviceOptions.kSSAOEnable,t.ambientOcclusion),r.setOptionBool(e.DeviceOptions.kSSAODynamicRadius,!0),r.setOptionDouble(e.DeviceOptions.kSSAORadius,1),r.setOptionInt32(e.DeviceOptions.kSSAOLoops,32),r.setOptionDouble(e.DeviceOptions.kSSAOPower,2),r.setOptionInt32(e.DeviceOptions.kSSAOBlurRadius,2);const s=i.activeView;s.setSSAOEnabled(t.ambientOcclusion),s.delete()}if(Xn(t.edgeModel)){const s=r.getActiveView(),a=i.findVisualStyle("OpenCloud"),n=a.openObject();n.setOptionInt32(e.VisualStyleOptions.kEdgeModel,t.edgeModel?2:0,e.VisualStyleOperations.kSet),s.visualStyle=a,n.delete(),a.delete(),s.delete()}return r.delete(),this.syncHighlightingOptions(t),this.update(),this}syncHighlightingOptions(t=this.options.data){if(!this.visualizeJs)return this;const e=t.enableCustomHighlight?t:s.defaults(),i=this.visLib(),r=i.getViewer(),{Entry:a,OdTvRGBColorDef:n}=i,o=r.findHighlightStyle("Web_Default").openObject();if(Xn(e.facesColor)){const t=new n(e.facesColor.r,e.facesColor.g,e.facesColor.b);o.setFacesColor(a.k3D.value|a.k3DTop.value,t),t.delete()}if(Xn(e.facesOverlap)&&o.setFacesVisibility(a.k3DTop.value,e.facesOverlap),Xn(e.facesTransparancy)&&o.setFacesTransparency(a.k3D.value|a.k3DTop.value,e.facesTransparancy),Xn(e.edgesColor)){const t=new n(e.edgesColor.r,e.edgesColor.g,e.edgesColor.b);o.setEdgesColor(a.k3DTop.value|a.k3D.value|a.k2D.value|a.k2DTop.value,t),t.delete()}if(Xn(e.edgesVisibility)&&o.setEdgesVisibility(a.k2D.value|a.k2DTop.value|a.k3DTop.value|a.k3D.value,e.edgesVisibility),Xn(e.edgesOverlap)){const t=!Xn(e.edgesVisibility)||e.edgesVisibility;o.setEdgesVisibility(a.k2DTop.value|a.k3DTop.value,e.edgesOverlap&&t)}const h=r.getActiveDevice();if(!h.isNull()){const t=i.canvas;h.invalidate([0,t.clientWidth,t.clientHeight,0]),h.delete()}return this}get draggers(){return[...this.draggerFactory.keys()]}registerDragger(t,e){this.draggerFactory.set(t,e)}activeDragger(){return this._activeDragger}setActiveDragger(t){var e;if((null===(e=this._activeDragger)||void 0===e?void 0:e.name)!==t){this._activeDragger&&(this._activeDragger.dispose(),this._activeDragger=null);const e=this.draggerFactory.get(t);e&&(this._activeDragger=new e(this),this._activeDragger.name=t,this._activeDragger.initialize());const i=this.canvas;i&&(i.className=i.className.split(" ").filter((t=>!t.startsWith("oda-cursor-"))).filter((t=>t)).concat(`oda-cursor-${t.toLowerCase()}`).join(" ")),this.emitEvent({type:"changeactivedragger",data:t})}return this._activeDragger}resetActiveDragger(){const t=this._activeDragger;t&&(this.setActiveDragger(""),this.setActiveDragger(t.name))}clearSlices(){if(!this.visualizeJs)return;const t=this.visViewer().activeView;t.removeCuttingPlanes(),t.delete(),this.update()}clearOverlay(){this.markup.clearOverlay()}syncOverlay(){if(!this.visualizeJs)return;const t=this.visViewer(),e=t.activeView;let i=t.getViewByName(Yn);if(!i){const r=t.getMarkupModel(),s=t.getActiveDevice();i=s.createView(Yn,!1),i.addModel(r),e.addSibling(i),s.addView(i)}i.viewPosition=e.viewPosition,i.viewTarget=e.viewTarget,i.upVector=e.upVector,i.viewFieldWidth=e.viewFieldWidth,i.viewFieldHeight=e.viewFieldHeight;const r=i.getViewport();return i.setViewport(r.lowerLeft,r.upperRight),i.vportRect=e.vportRect,this.update(),i}is3D(){if(!this.visualizeJs)return!1;const t=this.visViewer().getActiveExtents(),e=t.min();return 0!==t.max()[2]-e[2]}getSelected(){return this.executeCommand("getSelected")}setSelected(t){this.executeCommand("setSelected",t)}async loadReferences(t){var e;if(!this.visualizeJs)return this;const i=new AbortController;null===(e=this._abortControllerForReferences)||void 0===e||e.abort(),this._abortControllerForReferences=i;let r=[];await t.getReferences(i.signal).then((t=>r=t.references)).catch((t=>console.error("Cannot load model references.",t)));for(const t of r)await this.client.downloadFile(t.id,void 0,i.signal).then((e=>{var i;return null===(i=this.visualizeJs)||void 0===i?void 0:i.getViewer().addEmbeddedFile(t.name,new Uint8Array(e))})).catch((e=>console.error(`Cannot load reference file ${t.name}.`,e)));return this}applyModelTransformMatrix(t){this.executeCommand("applyModelTransform",t)}applySceneGraphSettings(t=this.options){if(!this.visualizeJs)return;const e=this.visLib(),i=e.getViewer().getActiveDevice();Xn(t.sceneGraph)&&i.setOptionBool(e.DeviceOptions.kDelaySceneGraphProc,!t.sceneGraph),i.delete(),this.update()}async open(t){if(!this.visualizeJs)return this;let e;if(this.cancel(),this.clear(),this.emitEvent({type:"open",file:t,model:t}),t){const i=await t.getModels()||[];e=i.find((t=>t.default))||i[0]}if(!e)throw new Error("No default model found");const i=new s;i.data=this.options.data,".rcs"===t.type&&(console.log("Partial load mode is forced for RCS file"),i.enablePartialMode=!0);const r=(new Y).create(this,e,i.data);return await this.loadReferences(e),await r.load(),this.visualizeJs&&(this.applyModelTransformMatrix(e),this.applySceneGraphSettings()),this}openVsfFile(t){if(!this.visualizeJs)return this;this.cancel(),this.clear(),this.emitEvent({type:"open",buffer:t});try{this.emitEvent({type:"geometrystart",buffer:t});const e=this.visLib().getViewer(),i=t instanceof Uint8Array?t:new Uint8Array(t);e.parseFile(i),this.syncOpenCloudVisualStyle(!1),this.syncOptions(),this.resize(),this.emitEvent({type:"geometryprogress",data:1,buffer:t}),this.emitEvent({type:"databasechunk",data:i,buffer:t}),this.emitEvent({type:"geometryend",buffer:t})}catch(e){throw this.emitEvent({type:"geometryerror",data:e,buffer:t}),e}return this}openVsfxFile(t){if(!this.visualizeJs)return this;this.cancel(),this.clear(),this.emitEvent({type:"open",buffer:t});try{this.emitEvent({type:"geometrystart",buffer:t});const e=this.visLib().getViewer(),i=t instanceof Uint8Array?t:new Uint8Array(t);e.parseVsfx(i),this.syncOpenCloudVisualStyle(!1),this.syncOptions(),this.resize(),this.emitEvent({type:"geometryprogress",data:1,buffer:t}),this.emitEvent({type:"databasechunk",data:i,buffer:t}),this.emitEvent({type:"geometryend",buffer:t})}catch(e){throw this.emitEvent({type:"geometryerror",data:e,buffer:t}),e}return this}cancel(){var t,e,i;return null===(t=this._abortControllerForReferences)||void 0===t||t.abort(),this._abortControllerForReferences=void 0,null===(e=this._abortController)||void 0===e||e.abort(),this._abortController=void 0,null===(i=this._abortControllerForRequestMap)||void 0===i||i.forEach((t=>t.abort())),this._abortControllerForRequestMap=void 0,this.emitEvent({type:"cancel"}),this}clear(){if(!this.visualizeJs)return this;const t=this.visLib().getViewer();return this.clearOverlay(),t.clear(),t.createLocalDatabase(),this.syncOpenCloudVisualStyle(!0),this.syncOptions(),this.resize(),this.emitEvent({type:"clear"}),this}getMarkupColor(){return this.markup.getMarkupColor()}setMarkupColor(t=255,e=0,i=0){this.markup.setMarkupColor(t,e,i);const r={r:t,g:e,b:i};this.emitEvent({type:"changemarkupcolor",data:r})}colorizeAllMarkup(t=255,e=0,i=0){this.markup.colorizeAllMarkup(t,e,i)}addMarkupEntity(t){if(!this.visualizeJs)return null;this.syncOverlay();const e=this.visViewer().getMarkupModel().appendEntity(t),i=e.openObject(),r=this.getMarkupColor();return i.setColor(r.r,r.g,r.b),i.setLineWeight(2),i.delete(),this.update(),e}drawViewpoint(t){this.setOrthogonalCameraSettings(t.orthogonal_camera),this.setClippingPlanes(t.clipping_planes),this.markup.setViewpoint(t)}createViewpoint(){const t=this.markup.getViewpoint();return t.orthogonal_camera=this.getOrthogonalCameraSettings(),t.clipping_planes=this.getClippingPlanes(),t}getPoint3dFromArray(t){return{x:t[0],y:t[1],z:t[2]}}getLogicalPoint3dAsArray(t){return[t.x,t.y,t.z]}getOrthogonalCameraSettings(){const t=this.visViewer().activeView;return{view_point:this.getPoint3dFromArray(t.viewPosition),direction:this.getPoint3dFromArray(t.viewTarget),up_vector:this.getPoint3dFromArray(t.upVector),field_width:t.viewFieldWidth,field_height:t.viewFieldHeight}}setOrthogonalCameraSettings(t){const e=this.visViewer().activeView;this.resetActiveDragger(),this.clearSlices(),this.clearOverlay(),t&&e.setView(this.getLogicalPoint3dAsArray(t.view_point),this.getLogicalPoint3dAsArray(t.direction),this.getLogicalPoint3dAsArray(t.up_vector),t.field_width,t.field_height,!0),this.syncOverlay()}getClippingPlanes(){const t=this.visViewer().activeView,e=[];for(let i=0;i<t.numCuttingPlanes();i++){const r=t.getCuttingPlane(i),s={location:this.getPoint3dFromArray(r.getOrigin()),direction:this.getPoint3dFromArray(r.normal())};e.push(s)}return e}setClippingPlanes(t){if(t){const e=this.visViewer().activeView;for(const i of t){const t=new(this.visLib().OdTvPlane);t.set(this.getLogicalPoint3dAsArray(i.location),this.getLogicalPoint3dAsArray(i.direction)),e.addCuttingPlane(t),e.setEnableCuttingPlaneFill(!0,102,102,102)}}}executeCommand(t,...e){return r("VisualizeJS").executeCommand(t,this,...e)}},t.commands=r,Object.defineProperty(t,"__esModule",{value:!0})}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).ODA=t.ODA||{},t.ODA.Visualize=t.ODA.Visualize||{}))}(this,(function(t){"use strict";class e{constructor(){this._commands=new Map}registerCommand(t,e,i,r){this._commands.set(t,{id:t,handler:e,thisArg:r,description:i})}registerCommandAlias(t,e){this.registerCommand(e,((e,...i)=>this.executeCommand(t,e,...i)))}getCommand(t){return this._commands.get(t)}getCommands(){const t=new Map;return this._commands.forEach(((e,i)=>t.set(i,e))),t}executeCommand(t,e,...i){const r=this._commands.get(t);if(!r){if(e){if(e.draggers.includes(t))return e.setActiveDragger(t)}return void console.warn(`Command '${t}' not found`)}const{handler:s,thisArg:a}=r,n=s.apply(a,[e,...i]);return null==e||e.emit({type:"command",data:t,args:i}),n}}const i=new Map;function r(t=""){let r=i.get(t);return r||(r=new e,i.set(t,r)),r}r("").registerCommand("noop",(()=>{})),r("VisualizeJS").registerCommand("noop",(()=>{})),r("ThreeJS").registerCommand("noop",(()=>{}));class s{constructor(t){this._emitter=t,this._data=s.defaults(),this.loadFromStorage()}static defaults(){return{showWCS:!0,cameraAnimation:!0,antialiasing:!0,groundShadow:!1,shadows:!1,cameraAxisXSpeed:4,cameraAxisYSpeed:1,ambientOcclusion:!1,enableStreamingMode:!0,enablePartialMode:!1,memoryLimit:3294967296,cuttingPlaneFillColor:{red:255,green:152,blue:0},edgesColor:{r:255,g:152,b:0},facesColor:{r:255,g:152,b:0},edgesVisibility:!0,edgesOverlap:!0,facesOverlap:!1,facesTransparancy:200,enableCustomHighlight:!0,sceneGraph:!1,edgeModel:!0,reverseZoomWheel:!1,enableZoomWheel:!0,enableGestures:!0,geometryType:"vsfx"}}notifierChangeEvent(){void 0!==this._emitter&&(this.saveToStorage(),this._emitter.emit({type:"optionschange",data:this}))}saveToStorage(){if("undefined"!=typeof window)try{localStorage.setItem("od-client-settings",JSON.stringify(this.data))}catch(t){console.error("Cannot save client settings.",t)}}loadFromStorage(){if("undefined"!=typeof window)try{const t=localStorage.getItem("od-client-settings");if(t){const e=JSON.parse(t);this.data={...e}}}catch(t){console.error("Cannot load client settings.",t)}}resetToDefaults(t){if(void 0!==t){const e=s.defaults(),i=t.reduce(((t,i)=>(t[i]=e[i],t)),{});this.data={...this.data,...i}}else this.data={...this.data,...s.defaults()}}get data(){return this._data}set data(t){const e=!t.enablePartialMode&&t.sceneGraph;this._data={...s.defaults(),...this._data,...t,sceneGraph:e},this.notifierChangeEvent()}get showWCS(){return this._data.showWCS}set showWCS(t){this._data.showWCS=t,this.notifierChangeEvent()}get cameraAnimation(){return this._data.cameraAnimation}set cameraAnimation(t){this._data.cameraAnimation=t,this.notifierChangeEvent()}get antialiasing(){return this._data.antialiasing}set antialiasing(t){this._data.antialiasing=t,this.notifierChangeEvent()}get groundShadow(){return this._data.groundShadow}set groundShadow(t){this._data.groundShadow=t,this.notifierChangeEvent()}get shadows(){return this._data.shadows}set shadows(t){this._data.shadows=t,this.notifierChangeEvent()}get cameraAxisXSpeed(){return this._data.cameraAxisXSpeed}set cameraAxisXSpeed(t){this._data.cameraAxisXSpeed=t,this.notifierChangeEvent()}get cameraAxisYSpeed(){return this._data.cameraAxisYSpeed}set cameraAxisYSpeed(t){this.cameraAxisYSpeed=t,this.notifierChangeEvent()}get ambientOcclusion(){return this._data.ambientOcclusion}set ambientOcclusion(t){this._data.ambientOcclusion=t,this.notifierChangeEvent()}get enableStreamingMode(){return this._data.enableStreamingMode}set enableStreamingMode(t){this._data.enableStreamingMode=t,this._data.enableStreamingMode&&(this._data.enablePartialMode=!1),this.notifierChangeEvent()}get enablePartialMode(){return this._data.enablePartialMode}set enablePartialMode(t){this._data.enablePartialMode=t,t&&(this._data.sceneGraph=!1),this.notifierChangeEvent()}get memoryLimit(){return this._data.memoryLimit}set memoryLimit(t){this._data.memoryLimit=t,this.notifierChangeEvent()}get cuttingPlaneFillColor(){return this._data.cuttingPlaneFillColor}set cuttingPlaneFillColor(t){this._data.cuttingPlaneFillColor=t,this.notifierChangeEvent()}get edgesColor(){return this._data.edgesColor}set edgesColor(t){this._data.edgesColor=t,this.notifierChangeEvent()}get facesColor(){return this._data.facesColor}set facesColor(t){this._data.facesColor=t,this.notifierChangeEvent()}get edgesVisibility(){return this._data.edgesVisibility}set edgesVisibility(t){this._data.edgesVisibility=t,this.notifierChangeEvent()}get edgesOverlap(){return this._data.edgesOverlap}set edgesOverlap(t){this._data.edgesOverlap=t,this.notifierChangeEvent()}get facesOverlap(){return this._data.facesOverlap}set facesOverlap(t){this._data.facesOverlap=t,this.notifierChangeEvent()}get facesTransparancy(){return this._data.facesTransparancy}set facesTransparancy(t){this._data.facesTransparancy=t,this.notifierChangeEvent()}get enableCustomHighlight(){return this._data.enableCustomHighlight}set enableCustomHighlight(t){this._data.enableCustomHighlight=t,this.notifierChangeEvent()}get sceneGraph(){return this._data.sceneGraph}set sceneGraph(t){this._data.sceneGraph=t,t&&(this._data.enablePartialMode=!1),this.notifierChangeEvent()}get edgeModel(){return Boolean(this._data.edgeModel)}set edgeModel(t){this._data.edgeModel=Boolean(t),this.notifierChangeEvent()}get reverseZoomWheel(){return this._data.reverseZoomWheel}set reverseZoomWheel(t){this._data.reverseZoomWheel=!!t,this.notifierChangeEvent()}get enableZoomWheel(){return this._data.enableZoomWheel}set enableZoomWheel(t){this._data.enableZoomWheel=!!t,this.notifierChangeEvent()}get enableGestures(){return this._data.enableGestures}set enableGestures(t){this._data.enableGestures=!!t,this.notifierChangeEvent()}get geometryType(){return this._data.geometryType}set geometryType(t){this._data.geometryType=t,this.notifierChangeEvent()}}const a=["click","dblclick","mousedown","mousemove","mouseup","mouseleave","pointerdown","pointermove","pointerup","pointerleave","pointercancel","wheel","touchstart","touchmove","touchend","touchcancel"],n=(t,e,i,r,s)=>{const a=s.setTranslation([t.x,t.y,t.z]),n=s.setToRotation(e.angle,[e.x,e.y,e.z],r),o=s.setToScaling(i,r);return a.postMultBy(n).postMultBy(o)};function o(t,e=0){if(!t.visualizeJs)return;t.visViewer().explode(e),t.update(),t.emit({type:"explode",data:e})}function h(t,e=""){if(!t.visualizeJs)return;const i=t.visLib(),r=t.visViewer(),s=i.DefaultViewPosition;r.setDefaultViewPositionWithAnimation(s[e]),t.update(),t.emit({type:"viewposition",data:e})}r("VisualizeJS").registerCommand("applyModelTransform",(function(t,e){var i;if(!t.visualizeJs)return;if(!e.getModelTransformMatrix)return;const r=t.visLib(),s=r.getViewer(),a=s.getModelIterator();for(;!a.done();a.step()){const t=a.getModel(),i=e.getModelTransformMatrix(t.getDatabaseHandle());if(i){const e=t.getExtents(),s=n(i.translate,i.rotation,i.scale,e.center(),new r.Matrix3d);t.setModelingMatrix(s,!0)}}a.delete(),null===(i=s.clearViewExtentsCache)||void 0===i||i.call(s),t.update()})),r("VisualizeJS").registerCommand("clearMarkup",(t=>t.clearOverlay())),r("VisualizeJS").registerCommandAlias("clearMarkup","clearOverlay"),r("VisualizeJS").registerCommand("clearSlices",(t=>t.clearSlices())),r("VisualizeJS").registerCommand("createPreview",(function(t,e="image/jpeg",i=.25){var r;return t.visualizeJs&&(null===(r=t.canvas)||void 0===r?void 0:r.toDataURL(e,i))||""})),r("VisualizeJS").registerCommand("explode",o),r("VisualizeJS").registerCommand("collect",(t=>o(t,0))),r("VisualizeJS").registerCommand("getDefaultViewPositions",(function(t){if(!t.visualizeJs)return[];const e=t.visLib().DefaultViewPosition;return Object.keys(e).filter((t=>"values"!==t))})),r("VisualizeJS").registerCommand("getModels",(function(t){if(!t.visualizeJs)return[];const e=[],i=t.visViewer().getModelIterator();for(;!i.done();i.step()){const t=i.getModel();"$"!==t.getName()[0]&&e.push(t.getDatabaseHandle())}return i.delete(),e})),r("VisualizeJS").registerCommand("getSelected",(function(t){if(!t.visualizeJs)return[];const e=[],i=t.visViewer().getSelected();if(!i.isNull()&&0!==i.numItems()){const t=i.getIterator();for(;!t.done();t.step()){const i=t.getEntity(),r=1===i.getType()?i.openObject():2===i.getType()?i.openObjectAsInsert():null;if(r){const t=r.getNativeDatabaseHandle();"-1"!==t&&e.push(t),r.delete()}}t.delete()}return e})),r("VisualizeJS").registerCommand("hideSelected",(function(t){if(!t.visualizeJs)return;t.visViewer().hideSelectedObjects(!1),t.update(),t.emit({type:"hide"})})),r("VisualizeJS").registerCommand("isolateSelected",(function(t){if(!t.visualizeJs)return;t.visViewer().isolateSelectedObjects(!1),t.update(),t.emit({type:"isolate"})})),r("VisualizeJS").registerCommand("regenerateAll",(function(t){if(!t.visualizeJs)return;t.visViewer().regenAll(),t.update(),t.emit({type:"regenerateall"})})),r("VisualizeJS").registerCommand("resetView",(function(t){t.visualizeJs&&(t.executeCommand("setActiveDragger",""),t.executeCommand("clearSlices"),t.executeCommand("clearOverlay"),t.executeCommand("setMarkupColor"),t.executeCommand("unselect"),t.executeCommand("showAll"),t.executeCommand("explode",0),t.executeCommand("zoomToExtents",!0),t.executeCommand("k3DViewSW"),t.emit({type:"resetview"}))})),r("VisualizeJS").registerCommand("selectModel",(function(t,e){if(!t.visualizeJs)return;const i=t.visViewer(),r=i.activeView,s=i.getModelIterator();for(;!s.done();s.step()){const a=s.getModel();if(a.getDatabaseHandle()===e){const e=r.selectCrossing([0,9999,9999,0],a);i.setSelected(e);const s=t.getSelected();t.update(),t.emitEvent({type:"select",data:e,handles:s}),e.delete();break}}s.delete()})),r("VisualizeJS").registerCommand("setActiveDragger",((t,e="")=>{t.setActiveDragger(e)})),r("VisualizeJS").registerCommand("setDefaultViewPosition",h),r("VisualizeJS").registerCommand("k3DViewTop",(t=>h(t,"k3DViewTop"))),r("VisualizeJS").registerCommand("k3DViewBottom",(t=>h(t,"k3DViewBottom"))),r("VisualizeJS").registerCommand("k3DViewLeft",(t=>h(t,"k3DViewLeft"))),r("VisualizeJS").registerCommand("k3DViewRight",(t=>h(t,"k3DViewRight"))),r("VisualizeJS").registerCommand("k3DViewFront",(t=>h(t,"k3DViewFront"))),r("VisualizeJS").registerCommand("k3DViewBack",(t=>h(t,"k3DViewBack"))),r("VisualizeJS").registerCommand("k3DViewSE",(t=>h(t,"k3DViewSE"))),r("VisualizeJS").registerCommand("k3DViewSW",(t=>h(t,"k3DViewSW"))),r("VisualizeJS").registerCommand("k3DViewNE",(t=>h(t,"k3DViewNE"))),r("VisualizeJS").registerCommand("k3DViewNW",(t=>h(t,"k3DViewNW"))),r("VisualizeJS").registerCommand("setMarkupColor",((t,e=255,i=0,r=0)=>{t.setMarkupColor(e,i,r)})),r("VisualizeJS").registerCommand("setSelected",(function(t,e=[]){if(!t.visualizeJs)return;const i=t.visLib(),r=i.getViewer(),s=new i.OdTvSelectionSet;null==e||e.forEach((t=>{const e=r.getEntityByOriginalHandle(t+"");e.isNull()||s.appendEntity(e)})),r.setSelected(s),t.update(),t.emitEvent({type:"select",data:s,handles:e}),s.delete()})),r("VisualizeJS").registerCommand("showAll",(function(t){if(!t.visualizeJs)return;t.visViewer().unisolateSelectedObjects(!1),t.update(),t.emit({type:"showall"})})),r("VisualizeJS").registerCommand("unselect",(function(t){if(!t.visualizeJs)return;const e=t.visViewer();e.unselect(),t.update(),t.emitEvent({type:"select",data:e.getSelected(),handles:[]})})),r("VisualizeJS").registerCommand("zoomToExtents",(function(t,e=!1,i=t.options.cameraAnimation){if(!t.visualizeJs)return;const r=t.visViewer(),s=r.getEnableAnimation();r.setEnableAnimation(i),r.zoomExtents(e),r.update(),r.setEnableAnimation(s),t.update(),t.emitEvent({type:"zoom"})})),r("VisualizeJS").registerCommandAlias("zoomToExtents","zoomExtents"),r("VisualizeJS").registerCommand("zoomToObjects",(function(t,e=[]){var i;if(!t.visualizeJs)return;const r=t.visLib(),s=t.visViewer(),a=new r.OdTvSelectionSet;e.forEach((t=>{const e=s.getEntityByOriginalHandle(t+"");e.isNull()||a.appendEntity(e)})),null===(i=s.zoomToObjects)||void 0===i||i.call(s,a),t.update(),t.emitEvent({type:"zoom"}),a.delete()})),r("VisualizeJS").registerCommand("zoomToSelected",(function(t){var e;if(!t.visualizeJs)return;const i=t.visViewer(),r=i.getSelected();null===(e=i.zoomToObjects)||void 0===e||e.call(i,r),t.update(),t.emitEvent({type:"zoom"})}));class l{constructor(){this._listeners=void 0}addEventListener(t,e){return void 0===this._listeners&&(this._listeners={}),void 0===this._listeners[t]&&(this._listeners[t]=[]),this._listeners[t].push(e),this}removeEventListener(t,e){if(void 0===this._listeners)return this;if(void 0===this._listeners[t])return this;const i=this._listeners[t].filter((t=>t!==e));return this._listeners[t]=0===i.length?void 0:i,this}removeAllListeners(t){return t?this._listeners[t]=void 0:this._listeners=void 0,this}emitEvent(t){if(void 0===this._listeners)return!1;if(void 0===this._listeners[t.type])return!1;return this._listeners[t.type].slice().forEach((e=>e.call(this,t))),!0}on(t,e){return this.addEventListener(t,e)}off(t,e){return this.removeEventListener(t,e)}emit(t,...e){return"string"==typeof t?this.emitEvent({type:t,args:e}):"object"==typeof t&&this.emitEvent(t)}}class d{constructor(t){this.setViewParams=t=>{var e;const i=this.m_module.getViewer().getActiveTvExtendedView();i.setView(t.position,t.target,t.upVector,t.viewFieldWidth,t.viewFieldHeight,t.perspective),null===(e=i.delete)||void 0===e||e.call(i)},this.getViewParams=()=>{var t;const e=this.m_module.getViewer().activeView,i={position:e.viewPosition,target:e.viewTarget,upVector:e.upVector,viewFieldWidth:e.viewFieldWidth,viewFieldHeight:e.viewFieldHeight,perspective:e.perspective};return null===(t=e.delete)||void 0===t||t.call(e),i},this.m_module=t}getViewer(){return this.m_module.getViewer()}getModel(){return this.getViewer().getMarkupModel()}copyPoint(t){const e=new this.m_module.Point3d;return e.set(t.x,t.y,t.z),e}createVector3d(){return new this.m_module.Vector3d}createPoint3d(){return new this.m_module.Point3d}createMatrix3d(){return new this.m_module.Matrix3d}createPlane(){return new this.m_module.OdTvPlane}toVector(t){return this.m_module.Vector3d.createFromArray(t)}toGeVector(t){return[t.x,t.y,t.z]}toGePoint(t){return[t.x,t.y,t.z]}toPoint(t){return this.m_module.Point3d.createFromArray(t)}screenToWorld(t,e){return this.toPoint(this.m_module.getViewer().screenToWorld(t,e))}toDoubleArray(t){const e=[];for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y),e.push(t[i].z);return e}correctCameraTarget(){const t=this.getViewParams(),e=this.m_module.getViewer().getActiveExtents(),{min:i,max:r}=e,s=this.toPoint(t.target);s.x>=i.x&&s.y>=i.y&&s.z>=i.z&&s.x<=r.x&&s.y<=r.y&&s.z<=r.z||(t.target=e.center(),this.setViewParams(t))}}class c extends d{constructor(t){super(t.visualizeJs),this.beginInteractivity=()=>{const t=this.getViewer().activeView;t.beginInteractivity&&(t.beginInteractivity(24),this.subject.update()),t.delete()},this.endInteractivity=()=>{const t=this.getViewer().activeView;if(t.endInteractivity){t.endInteractivity();const e=this.getViewer().getActiveDevice(),i=this.m_module.canvas;e.invalidate([0,0,i.width,i.height]),e.delete(),this.subject.update()}t.delete()},this.subject=t,this.needInputText=!1,this.mouseDownPosition={x:0,y:0},this.autoSelect=!1,this.onmessage=t=>this.subject.emitEvent(t),this.canvasEvents=a}initialize(){this.canvasEvents=this.canvasEvents.filter((t=>"function"==typeof this[t])),this.canvasEvents.forEach((t=>this[t]=this[t].bind(this))),this.canvasEvents.forEach((t=>this.subject.on(t,this[t]))),this.getViewer().setEnableAutoSelect(!!this.autoSelect)}dispose(){this.canvasEvents.forEach((t=>this.subject.off(t,this[t])))}relativeCoords(t){return{x:t.offsetX*window.devicePixelRatio,y:t.offsetY*window.devicePixelRatio}}pointerdown(t){if(!t.isPrimary||c.isGestureActive)return;t.target.setPointerCapture(t.pointerId);const e=this.relativeCoords(t);this.isDragging=!0,this.mouseDownPosition={x:e.x,y:e.y},this.start(e.x,e.y,t.clientX,t.clientY),this.subject.update()}pointerup(t){if(c.needSkipPointerUp)return;if(!t.isPrimary)return;t.target.releasePointerCapture(t.pointerId);const e=this.relativeCoords(t);this.end(e.x,e.y),this.isDragging=!1,this.subject.update()}pointercancel(t){t.isPrimary&&this.m_module.canvas.dispatchEvent(new PointerEvent("pointerup",t))}pointermove(t){if(!t.isPrimary||c.isGestureActive)return;const e=this.relativeCoords(t);this.drag(e.x,e.y,t.movementX,t.movementY),this.isDragging&&this.subject.update()}click(t){const e=this.getViewer(),i=this.relativeCoords(t),r=i.x,s=i.y,a=Math.abs(r-this.mouseDownPosition.x)<5&&Math.abs(s-this.mouseDownPosition.y)<5;if(e&&e.getEnableAutoSelect()&&a){e.unselect(),e.select(r,s,r,s),this.subject.update();const t=e.getSelected(),i=this.subject.getSelected();this.onmessage({type:"select",data:t,handles:i})}}dblclick(t){const e=this.getViewer(),i=this.relativeCoords(t),r=i.x,s=i.y,a=e.getActiveDevice(),n=a.viewAt([r,s]);if(n&&!n.active)e.activeView=n,n.delete(),this.subject.update();else if(e&&e.getEnableAutoSelect()){const t=e.getSelected();if(!t.isNull()&&0!==t.numItems()){const i=t.getIterator(),r=i.getEntity();e.zoomToEntity(r),this.onmessage({type:"zoomtoentity",data:r}),this.subject.update(),this.deleteAll([i,r])}}a.delete()}start(t,e,i=0,r=0){}drag(t,e,i=0,r=0){}end(t,e){}getActiveMarkupEntity(t){return this.subject.addMarkupEntity(t)}syncOverlayView(){return this.subject.syncOverlay()}deleteAll(t){var e;for(const i of t)null===(e=null==i?void 0:i.delete)||void 0===e||e.call(i)}updatePreview(){}static set isGestureActive(t){c._isGestureActive!==t&&(c._isGestureActive=t,c._isGestureActive&&(c.needSkipPointerUp=!0))}static get isGestureActive(){return c._isGestureActive}static get needSkipPointerUp(){return!!c._needSkipPointerUp&&(c.needSkipPointerUp=!1,!0)}static set needSkipPointerUp(t){c._needSkipPointerUp=t}}function u(t,e,i){return t||((t=document.createElement("div")).setAttribute("data-testid",i),e.appendChild(t)),t}function g(t,e){return t&&e.removeChild(t),null}function p(t,e,i){const r=e.Point3d.createFromArray(t),s=i.activeView,a=s.worldToDeviceMatrix,n=r.transformBy(a),o={x:n.x/window.devicePixelRatio,y:n.y/window.devicePixelRatio};return a.delete(),r.delete(),n.delete(),s.delete(),o}function m(t){return t<0?Math.ceil(t):Math.floor(t)}c._isGestureActive=!1,c._needSkipPointerUp=!1;const f=(t,e,i,r)=>{const s=e.x-t.x,a=e.y-t.y,n=r.x-i.x,o=r.y-i.y,h=(-a*(t.x-i.x)+s*(t.y-i.y))/(-n*a+s*o),l=(+n*(t.y-i.y)-o*(t.x-i.x))/(-n*a+s*o);return h>=0&&h<=1&&l>=0&&l<=1&&{x:m(t.x+l*s),y:m(t.y+l*a)}};function v(t,e,i,r,s){const a=f(t,e,i,r);a&&s.push(a)}function y(t,e,i){return t.x<=e&&t.x>=0&&t.y<=i&&t.y>=0}function _(t,e){t&&(t.onclick=e?()=>e():()=>{})}function w(t,e){t.style.pointerEvents=e?"auto":"none"}class b{constructor(t,e,i){this.htmlElemStartPoint=null,this.htmlElemEndPoint=null,this.htmlElemLine=null,this.htmlElemTitle=null,this.startPoint=null,this.endPoint=null,this.unit="",this.scale=1,this.size=10,this.lineThickness=2,this.style={border:"2px solid #FFFFFF",background:"#009bff",color:"white",boxShadow:"0 0 10px rgba(0,0,0,0.5)"},this.htmlElemStartPoint=u(this.htmlElemStartPoint,t,"ruler-start"),this.htmlElemEndPoint=u(this.htmlElemEndPoint,t,"ruler-end"),this.htmlElemLine=u(this.htmlElemLine,t,"ruler-line"),this.htmlElemTitle=u(this.htmlElemTitle,t,"ruler-value"),this.viewer=e,this.moduleInstance=i,this.targetElement=t,this.isFinishDraw=!1}drawMeasureLine(){const t=this.size,e=this.moduleInstance.canvas.getBoundingClientRect();if(this.startPoint){this.htmlElemStartPoint=u(this.htmlElemStartPoint,this.targetElement,"ruler-start");const i=p(this.startPoint,this.moduleInstance,this.viewer);y(i,e.width,e.height)?(this.htmlElemStartPoint.style.display="block",this.htmlElemStartPoint.style.cursor="pointer",this.htmlElemStartPoint.style.position="absolute",this.htmlElemStartPoint.style.top=i.y-t/2+"px",this.htmlElemStartPoint.style.left=i.x-t/2+"px",this.htmlElemStartPoint.style.borderRadius=`${t}px`,this.htmlElemStartPoint.style.border=this.style.border,this.htmlElemStartPoint.style.background=this.style.background,this.htmlElemStartPoint.style.zIndex="2",this.htmlElemStartPoint.style.width=`${t}px`,this.htmlElemStartPoint.style.height=`${t}px`,this.htmlElemStartPoint.style.boxShadow=this.style.boxShadow):this.htmlElemStartPoint.style.display="none"}if(this.endPoint&&this.isFinishDraw){this.htmlElemEndPoint=u(this.htmlElemEndPoint,this.targetElement,"ruler-end");const i=p(this.endPoint,this.moduleInstance,this.viewer);y(i,e.width,e.height)?(this.htmlElemEndPoint.style.display="block",this.htmlElemEndPoint.style.cursor="pointer",this.htmlElemEndPoint.style.position="absolute",this.htmlElemEndPoint.style.top=i.y-t/2+"px",this.htmlElemEndPoint.style.left=i.x-t/2+"px",this.htmlElemEndPoint.style.borderRadius=`${t}px`,this.htmlElemEndPoint.style.border=this.style.border,this.htmlElemEndPoint.style.background=this.style.background,this.htmlElemEndPoint.style.zIndex="2",this.htmlElemEndPoint.style.width=`${t}px`,this.htmlElemEndPoint.style.height=`${t}px`,this.htmlElemEndPoint.style.boxShadow=this.style.boxShadow):this.htmlElemEndPoint.style.display="none"}if(this.endPoint&&this.startPoint){const t=p(this.startPoint,this.moduleInstance,this.viewer),i=p(this.endPoint,this.moduleInstance,this.viewer),{p1:r,p2:s,angle:a,width:n}=function(t,e,i,r){const s={x:0,y:0},a={x:i,y:0},n={x:0,y:r},o={x:i,y:r},h=[];v(t,e,s,a,h),v(t,e,s,n,h),v(t,e,n,o,h),v(t,e,o,a,h);let l=null,d=null;0===h.length?(l=t,d=e):1===h.length?y(t,i,r)?(l=t,d=h[0]):(l=h[0],d=e):(l=h[0],d=h[1]);const c=d.x-l.x,u=d.y-l.y;let g=180*Math.atan(u/c)/Math.PI;return c<0&&(g-=180),{angle:g,width:Math.sqrt(Math.pow(c,2)+Math.pow(u,2)),p1:l,p2:d}}(t,i,e.width,e.height),o=s.x-r.x,h=s.y-r.y,l=this.lineThickness;if(y(r,e.width,e.height)&&y(s,e.width,e.height)){this.htmlElemLine=u(this.htmlElemLine,this.targetElement,"ruler-line"),this.htmlElemLine.style.display="block",this.htmlElemLine.style.cursor="pointer",this.htmlElemLine.style.position="absolute",this.htmlElemLine.style.top=`${r.y}px`,this.htmlElemLine.style.left=`${r.x}px`,this.htmlElemLine.style.width=`${n}px`,this.htmlElemLine.style.transform=`rotate(${a}deg)`,this.htmlElemLine.style.transformOrigin=`0px ${l/2}px`,this.htmlElemLine.style.boxShadow=this.style.boxShadow,this.htmlElemLine.style.border="none",this.htmlElemLine.style.background=this.style.background,this.htmlElemLine.style.zIndex="1",this.htmlElemLine.style.height=`${l}px`;const t=`${this.getDistance()} ${this.unit}`,e=r.x+o/2,i=r.y+h/2,s=10*t.length;this.htmlElemTitle=u(this.htmlElemTitle,this.targetElement,"ruler-value"),this.htmlElemTitle.style.display="block",this.htmlElemTitle.style.cursor="pointer",this.htmlElemTitle.style.font="10px",this.htmlElemTitle.style.color="white",this.htmlElemTitle.style.position="Absolute",this.htmlElemTitle.style.top=`${i}px`,this.htmlElemTitle.style.left=e-s/2+"px",this.htmlElemTitle.style.width=`${s}px`,this.htmlElemTitle.style.transformOrigin="0px 0px",this.htmlElemTitle.style.borderRadius="5px",this.htmlElemTitle.style.boxShadow=this.style.boxShadow,this.htmlElemTitle.style.border="none",this.htmlElemTitle.style.background=this.style.background,this.htmlElemTitle.style.zIndex="3",this.htmlElemTitle.style.padding="2px",this.htmlElemTitle.style.textAlign="center",this.htmlElemTitle.innerHTML=`${t}`}else this.htmlElemLine.style.display="none",this.htmlElemTitle.style.display="none"}}getDistance(){return function(t,e,i){const r=i.Point3d.createFromArray(t),s=i.Point3d.createFromArray(e),a=r.distanceTo(s).toFixed(2);return r.delete(),s.delete(),a}(this.startPoint,this.endPoint,this.moduleInstance)/this.scale}setStartPoint(t){this.startPoint=t,this.drawMeasureLine()}setEndPoint(t,e){this.isFinishDraw=void 0===e||e,this.endPoint=t,this.drawMeasureLine()}update(){this.drawMeasureLine()}setSize(t){this.size=t,this.drawMeasureLine()}clear(){this.endPoint=null,this.startPoint=null,this.htmlElemStartPoint=g(this.htmlElemStartPoint,this.targetElement),this.htmlElemEndPoint=g(this.htmlElemEndPoint,this.targetElement),this.htmlElemLine=g(this.htmlElemLine,this.targetElement),this.htmlElemTitle=g(this.htmlElemTitle,this.targetElement)}setUnit(t){this.unit=t,this.drawMeasureLine()}setConversionFactor(t){this.scale=t,this.drawMeasureLine()}setStyle(t){this.style=t,this.drawMeasureLine()}setSelectionReactor(t){_(this.htmlElemStartPoint,t?t.onStartPoint:null),_(this.htmlElemEndPoint,t?t.onEndPoint:null),_(this.htmlElemTitle,t?t.onTitle:null)}setSelectability(t){w(this.htmlElemStartPoint,t),w(this.htmlElemEndPoint,t),w(this.htmlElemLine,t),w(this.htmlElemTitle,t)}}class x extends c{constructor(t){super(t),this.lineThickness=2,this.press=!1,this.gripingRadius=5,this.firstPoint=null,this.secondPoint=null,this.renameUnitTable={Millimeters:"mm",Centimeters:"cm",Meters:"m",Feet:"ft",Inches:"in",Yards:"yd",Kilometers:"km",Miles:"mi",Micrometers:"µm",MicroInches:"µin",Undefined:" "},this.items=[],this.canvasEvents.push("resize")}initialize(){super.initialize(),this.m_overlayElement=document.createElement("div"),this.m_overlayElement.style.background="rgba(0,0,0,0)",this.m_overlayElement.style.position="fixed",this.m_overlayElement.style.zIndex="1",this.m_overlayElement.style.pointerEvents="none",document.body.appendChild(this.m_overlayElement),this.resize()}dispose(){super.dispose(),this.m_overlayElement.remove()}updatePreview(){this.items.forEach((t=>t.update()))}resize(){const t=this.m_module.canvas.getBoundingClientRect();this.m_overlayElement.style.top=`${t.top}px`,this.m_overlayElement.style.left=`${t.left}px`,this.m_overlayElement.style.width=`${t.width}px`,this.m_overlayElement.style.height=`${t.height}px`}getSnapPointRadius(){const t=this.getViewer().activeView.viewDcCorners(),e=t.lowerLeft,i=t.upperRight;return i[0]-=e[0],i[1]-=e[1],Math.min(i[0],i[1])/120}drag(t,e){this.createNewMeasureIfNeed();const i=this.getViewer().getSnapPoint(t,e,this.gripingRadius);this.isDragging?i?this.firstPoint?(this.secondPoint=i,this.previewMeasureLine.setStartPoint(this.firstPoint),this.previewMeasureLine.setEndPoint(this.secondPoint,!0)):(this.firstPoint=i,this.previewMeasureLine.setStartPoint(this.firstPoint)):(this.secondPoint=null,this.previewMeasureLine.clear(),this.previewMeasureLine.setStartPoint(this.firstPoint),this.previewMeasureLine.setEndPoint(this.getViewer().screenToWorld(t,e),!1)):i?this.previewMeasureLine.setStartPoint(i):this.previewMeasureLine.clear()}end(){if(this.firstPoint&&this.secondPoint){const t=this.createMeasureLine();t.setStartPoint(this.firstPoint),t.setEndPoint(this.secondPoint,!0)}this.firstPoint=null,this.secondPoint=null,this.previewMeasureLine.clear()}createNewMeasureIfNeed(){this.previewMeasureLine||(this.previewMeasureLine=this.createMeasureLine())}createMeasureLine(){const t=this.m_module.getViewer(),e=new b(this.m_overlayElement,t,this.m_module);var i,r;return e.lineThickness=this.lineThickness||e.lineThickness,e.setUnit((i=this.renameUnitTable,r=t.getUnit(),i[r]||r)),this.items.push(e),e}}class S extends c{constructor(t){super(t),this.viewer=void 0,this.multiplier=5,this.speed=1,this.keyPressMap=new Set,this.keydown=this.keydown.bind(this),this.keyup=this.keyup.bind(this),this.lastFrameTS=0,this.animationId=void 0,this.processMovement=this.processMovement.bind(this),this.deltaAngle=Math.PI/3600,this.autoSelect=!0}initialize(){super.initialize(),this.viewer=this.getViewer(),window.addEventListener("keydown",this.keydown,!1),window.addEventListener("keyup",this.keyup,!1),this.oldWCSEnableValue=this.viewer.getEnableWCS(),this.viewer.setEnableWCS(!1);const t=this.viewer.activeView,e=this.getMaxDimension(t);this.speed=e/3e4,this.subject.emitEvent({type:"walkstart"}),this.viewParams=this.getViewParams(),this.setViewParams(this.viewParams);const i=this.viewer.getActiveModel();this.cameraId=i.appendCamera("Camera0"),this.setupCamera(t),i.delete(),this.cameraWalker=new this.m_module.OdTvCameraWalker,this.cameraWalker.setCamera(this.cameraId),this.subject.update(),this.enableZoomWheelPreviousValue=this.subject.options.enableZoomWheel,this.subject.options.enableZoomWheel=!1}dispose(){var t;if(this.oldWCSEnableValue=void 0!==this.oldWCSEnableValue?this.oldWCSEnableValue:this.subject.options.showWCS,this.viewer.setEnableWCS(this.oldWCSEnableValue),super.dispose(),this.keyPressMap.clear(),window.removeEventListener("keydown",this.keydown),window.removeEventListener("keyup",this.keyup),this.animationId&&(window.cancelAnimationFrame(this.animationId),this.animationId=void 0),this.cameraId){const e=this.viewer.getActiveModel();e.removeEntity(this.cameraId),e.delete(),null===(t=this.cameraWalker)||void 0===t||t.delete()}if(this.viewParams){this.setViewParams(this.viewParams);this.viewer.activeView.delete()}this.subject.update(),this.subject.options.enableZoomWheel=this.enableZoomWheelPreviousValue}keydown(t){switch(t.code){case"NumpadSubtract":case"Minus":this.multiplier>1&&(this.multiplier=this.multiplier-1,this.subject.emitEvent({type:"walkspeedchange",data:this.multiplier}));break;case"NumpadAdd":case"Equal":this.multiplier<10&&(this.multiplier=this.multiplier+1,this.subject.emitEvent({type:"walkspeedchange",data:this.multiplier}));break;case"KeyW":case"KeyA":case"KeyS":case"KeyD":case"KeyQ":case"KeyE":this.keyPressMap.add(t.code),this.animationId||this.processMovement(0)}}keyup(t){this.keyPressMap.delete(t.code),this.keyPressMap.size<1&&this.animationId&&(window.cancelAnimationFrame(this.animationId),this.animationId=void 0,this.lastFrameTS=0)}processMovement(t){if(this.animationId=requestAnimationFrame(this.processMovement),0!==this.lastFrameTS){const e=t-this.lastFrameTS,i=this.multiplier*e*this.speed;for(const t of this.keyPressMap)switch(t){case"KeyW":this.cameraWalker.moveForward(i);break;case"KeyS":this.cameraWalker.moveBackward(i);break;case"KeyA":this.cameraWalker.moveLeft(i);break;case"KeyD":this.cameraWalker.moveRight(i);break;case"KeyQ":this.cameraWalker.moveUp(i);break;case"KeyE":this.cameraWalker.moveDown(i)}this.subject.update()}this.lastFrameTS=t}drag(t,e,i,r){this.cameraId&&this.isDragging&&(0!==i&&this.turnLeft(-i*this.deltaAngle),0!==r&&this.cameraWalker.turnDown(r*this.deltaAngle),this.subject.update())}turnLeft(t){const e=this.cameraWalker.camera().openObjectAsCamera(),i=this.toVector(e.direction()),r=this.toVector(e.upVector()),s=e.position(),a=this.createMatrix3d();a.setToRotation(t,[0,0,1],s),i.transformBy(a),r.transformBy(a),e.setupCameraByDirection(s,i.toArray(),r.toArray()),e.delete()}setupCamera(t){const e=this.cameraId.openObjectAsCamera(),i=t.viewTarget;e.setDisplayGlyph(!1),e.setDisplayTarget(!1),e.setAutoAdjust(!0),e.setupCamera(t.viewPosition,i,t.upVector),e.setNearClip(!1,1),e.setFarClip(!1,0),e.setViewParameters(t.viewFieldWidth,t.viewFieldHeight,!0);const r=(s=t.lensLength,a=t.viewFieldWidth,n=t.viewFieldHeight,s/42*Math.sqrt(a*a+n*n));var s,a,n;const o=this.toPoint(t.viewTarget),h=this.toPoint(t.viewPosition),l=h.sub(o),d=l.asVector(),c=d.normalize(),u=this.toGeVector(c),g=[u[0]*r,u[1]*r,u[2]*r],p=this.toPoint(t.viewTarget),m=this.toPoint(g),f=p.add(m);e.setupCamera(this.toGePoint(f),t.viewTarget,t.upVector),this.deleteAll([o,h,l,d,c,p,m,f]),e.assignView(t),e.delete()}getMaxDimension(t){const[e,i,r]=t.sceneExtents.max(),[s,a,n]=t.sceneExtents.min(),o=[e-s,i-a,r-n];return Math.max(...o)}}class C extends c{constructor(t){super(t),this.press=!1;const e=this.getViewer().getActiveExtents(),i=e.min(),r=e.max();this.m_size_x=Math.abs(r[0]-i[0])/2,this.m_size_y=Math.abs(r[1]-i[1])/2,this.m_size_z=Math.abs(r[2]-i[2])/2,this.m_center=this.toPoint(e.center()),this.m_normal=this.createNormal();const s=this.getViewer().activeView,a=this.createPlane();a.set(this.toGePoint(this.m_center),this.m_normal),s.addCuttingPlane(a),this.index=s.numCuttingPlanes()-1;const{red:n,green:o,blue:h}=this.subject.options.cuttingPlaneFillColor;s.setEnableCuttingPlaneFill(!0,n,o,h),s.setCuttingPlaneFillPatternEnabled(!0,this.m_module.CuttingPlaneFillStyle.kHorizontalBars,0,0,0),this.m_model=this.getModel(),this.createPreview(),this.deleteAll([e,s,a])}dispose(){super.dispose(),this.m_entity&&(this.m_model.removeEntity(this.m_entity),this.deleteAll([this.m_model,this.m_entity,this.planePreview,this.m_center]),this.m_entity=null,this.planePreview=null,this.subject.update())}createNormal(){return[0,0,0]}handleDelta(t){return t}getPlanePreviewCoordinate(){return[]}start(t,e){this.press=!0,this.m_last=this.screenToWorld(t,e),this.m_click={x:t,y:e}}drag(t,e){if(this.press){const i=this.screenToWorld(t,e),r=this.handleDelta(i.sub(this.m_last)),s=this.m_center;this.m_center=s.add(r);const a=this.m_last;this.m_last=i;const n=this.getViewer().activeView,o=this.createPlane(),h=o.set(this.toGePoint(this.m_center),this.m_normal),l=n.updateCuttingPlane(this.index,o);this.drawPreview(),this.deleteAll([n,o,s,r,a,h,l]);const d=this.getViewer().getActiveDevice();d.invalidate(d.getSize())}}end(t,e){if(this.press=!1,t===this.m_click.x&&e===this.m_click.y){this.m_normal=[-1*this.m_normal[0],-1*this.m_normal[1],-1*this.m_normal[2]];const t=this.getViewer().activeView,e=this.createPlane();e.set(this.toGePoint(this.m_center),this.m_normal),t.updateCuttingPlane(this.index,e),this.deleteAll([t,e,this.m_last]);const i=this.getViewer().getActiveDevice();i.invalidate(i.getSize())}}createPreview(){this.m_entity=this.m_model.appendEntity("&CuttingPlanePreview");const t=this.m_module.GeometryTypes,e=new this.m_module.OdTvTransparencyDef,i=new this.m_module.OdTvColorDef(112,112,112);e.setValue(.9);const r=this.m_entity.openObject();r.setColor(i,t.kFaces.value),i.setColor(112,112,112),r.setColor(i,t.kEdges.value),r.setLineWeight(5),r.setTransparency(e,t.kFaces),e.setValue(1),r.setTransparency(e,t.kEdges),this.planePreview=r.appendPolygon(this.getPlanePreviewCoordinate());const s=this.planePreview.openAsPolygon();s.setFilled(!0),this.deleteAll([e,i,r,s,t]),this.subject.syncOverlay()}drawPreview(){const t=this.planePreview.openAsPolygon();t.setPoints(this.getPlanePreviewCoordinate()),this.deleteAll([t]),this.subject.syncOverlay()}}class P extends C{createNormal(){return[1,0,0]}handleDelta(t){return t.y=0,t.z=0,t}getPlanePreviewCoordinate(){return[this.m_center.x,this.m_center.y-this.m_size_y,this.m_center.z-this.m_size_z,this.m_center.x,this.m_center.y+this.m_size_y,this.m_center.z-this.m_size_z,this.m_center.x,this.m_center.y+this.m_size_y,this.m_center.z+this.m_size_z,this.m_center.x,this.m_center.y-this.m_size_y,this.m_center.z+this.m_size_z]}}class k extends C{createNormal(){return[0,1,0]}handleDelta(t){return t.x=0,t.z=0,t}getPlanePreviewCoordinate(){return[this.m_center.x-this.m_size_x,this.m_center.y,this.m_center.z-this.m_size_z,this.m_center.x+this.m_size_x,this.m_center.y,this.m_center.z-this.m_size_z,this.m_center.x+this.m_size_x,this.m_center.y,this.m_center.z+this.m_size_z,this.m_center.x-this.m_size_x,this.m_center.y,this.m_center.z+this.m_size_z]}}class E extends C{createNormal(){return[0,0,1]}handleDelta(t){return t.x=0,t.y=0,t}getPlanePreviewCoordinate(){return[this.m_center.x-this.m_size_x,this.m_center.y-this.m_size_y,this.m_center.z,this.m_center.x+this.m_size_x,this.m_center.y-this.m_size_y,this.m_center.z,this.m_center.x+this.m_size_x,this.m_center.y+this.m_size_y,this.m_center.z,this.m_center.x-this.m_size_x,this.m_center.y+this.m_size_y,this.m_center.z]}}class A{constructor(t,e,i,r){this._m_module=t,this._subject=e,this._beginInteractivity=i,this._endInteractivity=r}beginAction(t,e){this.m_viewCenter=this.getCenter(),this.m_startPoint={x:t,y:e};this.getViewer().activeView.delete(),this._beginInteractivity()}action(t,e){var i;const r=this.getViewer().activeView,s=r.vportRect,a=Math.max(Math.abs(s[2]-s[0]),Math.abs(s[3]-s[1])),n=(this.m_startPoint.x-t)*Math.PI/a,o=(this.m_startPoint.y-e)*Math.PI/a;this.m_startPoint.x=t,this.m_startPoint.y=e;const h=o,l=n,d={position:r.viewPosition,target:r.viewTarget,upVector:r.upVector,viewFieldWidth:r.viewFieldWidth,viewFieldHeight:r.viewFieldHeight,perspective:r.perspective};r.delete();const c=this.getSideVector(d);0!==h&&this.calculateXOrbit(d,-h,c),0!==l&&this.calculateYOrbit(d,l,c),c.delete();const u=this.getViewer().getActiveTvExtendedView();u.setView(d.position,d.target,d.upVector,d.viewFieldWidth,d.viewFieldHeight,d.perspective),u.delete(),null===(i=this._subject.activeDragger())||void 0===i||i.updatePreview()}endAction(){this._endInteractivity()}getSideVector(t){const e=this.toVector(t.upVector),i=this.toPoint(t.target),r=this.toPoint(t.position),s=i.sub(r),a=s.asVector(),n=e.crossProduct(a),o=n.normalize();return this.deleteAll([s,e,i,r,a,n]),o}calculateXOrbit(t,e,i){{const r=this.toPoint(t.position),s=this.toPoint(this.m_viewCenter),a=r.rotateByBasePoint(e,i,s);t.position=a.toArray(),this.deleteAll([r,s,a])}{const r=this.toPoint(t.target),s=this.toPoint(this.m_viewCenter),a=r.rotateByBasePoint(e,i,s);t.target=a.toArray(),this.deleteAll([r,s,a])}{const e=this.toPoint(t.position),r=this.toPoint(t.target),s=this.toPoint(this.m_viewCenter),a=r.sub(e),n=a.asVector(),o=n.crossProduct(i),h=o.normalize();t.upVector=h.toArray(),this.deleteAll([e,r,s,a,n,o,h])}}calculateYOrbit(t,e,i){{const i=this.toPoint(t.position),r=this.toPoint(this.m_viewCenter),s=this.toVector(this._m_module.Vector3d.kZAxis),a=i.rotateByBasePoint(e,s,r);t.position=a.toArray(),this.deleteAll([s,i,r,a])}{const i=this.toPoint(t.target),r=this.toPoint(this.m_viewCenter),s=this.toVector(this._m_module.Vector3d.kZAxis),a=i.rotateByBasePoint(e,s,r);t.target=a.toArray(),this.deleteAll([s,i,r,a])}{const r=this.toVector(this._m_module.Vector3d.kZAxis),s=this.toPoint(t.target),a=this.toPoint(t.position),n=i.rotateBy(e,r),o=s.sub(a),h=o.asVector(),l=h.crossProduct(n),d=l.normalize();t.upVector=d.toArray(),this.deleteAll([r,s,a,n,o,h,l,d])}}getCenter(){const t=this.getViewer();let e;const i=t.getSelected();if(i.isNull()||0===i.numItems())e=t.getActiveExtents().center();else{const t=i.getIterator();let r,s,a;for(;!t.done();t.step())s=t.getEntity(),r=s.getWCSExtents(),a?a.addExt(r):a=r;e=a.center(),a.delete(),t.delete()}return e}getViewer(){return this._m_module.getViewer()}toVector(t){return this._m_module.Vector3d.createFromArray(t)}toPoint(t){return this._m_module.Point3d.createFromArray(t)}deleteAll(t){var e;for(const i of t)null===(e=null==i?void 0:i.delete)||void 0===e||e.call(i)}}class T extends c{constructor(t){super(t),this.autoSelect=!0,this.press=!1,this._orbitAction=new A(this.m_module,this.subject,this.beginInteractivity,this.endInteractivity)}start(t,e){this.press=!0,this._orbitAction.beginAction(t,e)}setDefaultViewParams(){const t=this.getViewer().getActiveTvExtendedView();t.setView(this.startCameraParams.position,this.startCameraParams.target,this.startCameraParams.upVector,this.startCameraParams.viewFieldWidth,this.startCameraParams.viewFieldHeight,this.startCameraParams.perspective),t.delete()}drag(t,e,i,r){this.press&&this._orbitAction.action(t,e)}end(){this.press=!1,this._orbitAction.endAction()}}class M{constructor(t,e,i,r,s,a){this._m_module=t,this._subject=e,this._beginInteractivity=i,this._endInteractivity=r,this._getViewParams=s,this._setViewParams=a}beginAction(t,e){this._m_start=this.screenToWorld(t,e),this._deltaScreenPosition={x:t,y:e},this._beginInteractivity()}action(t,e){var i;const{Vector3d:r}=this._m_module,s=this._getViewParams(),a=this.screenToWorld(t,e),n=this._m_start.sub(a).asVector(),o=r.createFromArray(s.target),h=o.add(n);s.target=h.toArray();const l=r.createFromArray(s.position),d=l.add(n);s.position=d.toArray(),this._setViewParams(s),o.delete(),h.delete(),l.delete(),d.delete(),null===(i=this._subject.activeDragger())||void 0===i||i.updatePreview(),this._subject.emitEvent({type:"pan",x:t,y:e,dX:t-this._deltaScreenPosition.x,dY:e-this._deltaScreenPosition.y}),this._deltaScreenPosition={x:t,y:e}}endAction(){this._endInteractivity()}screenToWorld(t,e){return this._m_module.Point3d.createFromArray(this._m_module.getViewer().screenToWorld(t,e))}}class F extends c{constructor(t){super(t),this.autoSelect=!0,this.press=!1,this._panAction=new M(this.m_module,this.subject,this.beginInteractivity,this.endInteractivity,this.getViewParams,this.setViewParams)}start(t,e){this.press=!0,this._panAction.beginAction(t,e)}drag(t,e,i,r){this.press&&this._panAction.action(t,e)}end(t,e){this.press=!1,this._panAction.endAction()}}class D{constructor(t,e){this._m_module=t,this._subject=e}action(t,e,i){var r;this._m_module.getViewer().zoomAt(i,t,e),null===(r=this._subject.activeDragger())||void 0===r||r.updatePreview(),this._subject.emitEvent({type:"zoomat",data:i})}}class O extends c{constructor(t){super(t),this.autoSelect=!0,this.press=!1,this._zoomAction=new D(this.m_module,this.subject)}start(t,e){this.press=!0,this.pressX=t,this.pressY=e,this.beginInteractivity()}drag(t,e,i,r){if(this.press){const t=.025,e=r>0?1+t:1-t;this._zoomAction.action(this.pressX,this.pressY,e)}}end(){this.press=!1,this.endInteractivity()}}class V extends c{constructor(t){super(t),this.canvasEvents=["wheel"],this._zoomAction=new D(this.m_module,this.subject),this._endInteractivityTimeOutId=void 0,this._isEnableInteractivityMode=!1}wheel(t){if(!this.subject.options.enableZoomWheel)return;(t=t||window.event).preventDefault();const e=.075*(this.subject.options.reverseZoomWheel?-1:1);if(this.getViewer()){const i=t.deltaY>0?1+e:1-e;this._zoomAction.action(t.offsetX*window.devicePixelRatio,t.offsetY*window.devicePixelRatio,i),this._isEnableInteractivityMode||(this._isEnableInteractivityMode=!0,this.beginInteractivity()),this._endInteractivityTimeOutId&&clearTimeout(this._endInteractivityTimeOutId),this._isEnableInteractivityMode||(this._isEnableInteractivityMode=!0,this.beginInteractivity()),this._endInteractivityTimeOutId&&clearTimeout(this._endInteractivityTimeOutId),this.subject.update(!0),this._endInteractivityTimeOutId=setTimeout((()=>{this._endInteractivityTimeOutId=void 0,this.endInteractivity(),this._isEnableInteractivityMode=!1}),100)}}dispose(){this._endInteractivityTimeOutId&&(clearTimeout(this._endInteractivityTimeOutId),this.endInteractivity(),this._isEnableInteractivityMode=!1)}}class R{constructor(){this.m_start=[0,0,0],this.m_end=[0,0,0],this.m_model=null}createPoint3d(){return new this.m_module.Point3d}init(t,e){this.m_module=t,this.m_model=e}getViewer(){return this.m_module.getViewer()}setValue(t){this.m_end=t,this.draw()}setStartPoint(t){this.m_start=t,this.m_end=t,this.draw()}toDoubleArray(t){const e=[];for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y),e.push(t[i].z);return e}draw(){const t=this.getViewer().activeView,e=t.viewingMatrix,i=[];i.push(this.m_start),i.push(this.createPoint3d()),i.push(this.m_end),i.push(this.createPoint3d());const r=this.createPoint3d();r.set(this.m_start[0],this.m_start[1],this.m_start[2]);const s=this.createPoint3d();s.set(this.m_end[0],this.m_end[1],this.m_end[2]),r.transformBy(e),s.transformBy(e),i[1].x=r.x,i[3].x=s.x,i[1].y=s.y,i[3].y=r.y,i[1].z=i[3].z=s.z;const a=t.eyeToWorldMatrix;if(i[1].transformBy(a),i[3].transformBy(a),this.m_entity)this.m_frame.openAsPolygon().setPoints(this.toDoubleArray(i));else{this.m_entity=this.m_model.appendEntity("");const t=this.m_entity.openObject();t.setColor(112,112,112),t.setLineWeight(2),this.m_frame=t.appendPolygon(this.toDoubleArray(i)),t.delete()}}clear(){this.m_entity&&(this.m_model.removeEntity(this.m_entity),this.m_entity=null)}}class I extends c{constructor(t){super(t),this.autoSelect=!0,this.press=!1,this.needInputText=!1,this.m_frame=new R,this.m_frame.init(this.m_module,this.getModel())}start(t,e){this.press=!0,this.m_minX=t,this.m_minY=e;const i=this.screenToWorld(t,e);this.m_frame.setStartPoint(i)}drag(t,e,i,r){if(this.press){this.m_maxX=t,this.m_maxY=e;const i=this.screenToWorld(t,e);this.m_frame.setValue(i)}}end(t,e){this.press=!1,this.m_maxX=t,this.m_maxY=e,this.m_minX!==this.m_maxX&&this.m_minY!==this.m_maxY&&(this.m_frame.clear(),this.getViewer().zoomWindow(this.m_minX,this.m_minY,this.m_maxX,this.m_maxY))}}class L extends c{constructor(t){super(t),this.autoSelect=!0,this.press=!1,this.maxPolarAngle=Math.PI/2,this.minPolarAngle=0}start(t,e){this.press=!0,this.m_viewCenter=this.getCenter(),this.m_startPoint={x:t,y:e};const i=this.getViewer().activeView;this.startCameraParams=this.getViewParams();const r=i.vportRect;this.m_delta=Math.max(r[1]-r[0],r[2]-r[3]),this.beginInteractivity()}setDefaultViewParams(){this.setViewParams(this.startCameraParams)}drag(t,e,i,r){if(this.press){let i=t-this.m_startPoint.x,r=e-this.m_startPoint.y;i*=Math.PI/this.m_delta,r*=Math.PI/this.m_delta,this.setDefaultViewParams();const{Vector3d:s,Matrix3d:a}=this.m_module,n=s.createFromArray(this.startCameraParams.target),o=s.createFromArray(this.startCameraParams.position).sub(n),h=o.normalize(),l=new a;l.setToIdentity();const d=new a;d.setToIdentity();const c=s.createFromArray([h.x,h.y,h.z]),u=s.createFromArray(this.startCameraParams.upVector),g=c.crossProduct(u);let p=s.createFromArray([c.x,c.y,0]);p.length()<=1e-5?p.set(-g.y,g.x,0):p=p.normalize();i-=Math.sign(p.dotProduct(s.createFromArray([-1,0,0])))*p.angleTo(s.createFromArray([0,1,0]));let m=s.createFromArray([h.x,h.y,0]),f=0;m.length()<=1e-5?f=-h.z*Math.PI/2:(m=m.normalize(),f=-m.angleTo(h)),r-=f,l.setToRotation(-i,[0,0,1],[0,0,0]);const v=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,r));d.setToRotation(v,[1,0,0],[0,0,0]);const y=l.postMultBy(d);let _=s.createFromArray([0,1,0]).transformBy(y);const w=s.createFromArray([0,0,1]).transformBy(y);_.setLength(o.length()),_=n.add(_);const b=this.getViewParams();b.position=_.toArray(),b.upVector=w.toArray(),this.setViewParams(b)}}end(){this.press=!1,this.endInteractivity()}getCenter(){const t=this.getViewer();let e=t.getActiveExtents();const i=t.getSelected();if(!i.isNull()&&0!==i.numItems()){const t=i.getIterator(),r=t.getEntity();if(1===r.getType()){const t=r.openObject();e.delete(),e=t.getExtents(),t.delete()}else if(2===r.getType()){const t=r.openObjectAsInsert(),i=t.getExtents();e.delete(),e=i.ext,i.delete(),t.delete()}t.delete()}const r=e.center();return e.delete(),r}}var z;!function(t){t[t.None=0]="None",t[t.Orbit=1]="Orbit",t[t.Pan=2]="Pan",t[t.Zoom=3]="Zoom"}(z||(z={}));class G extends c{get isSingleTouchEnabled(){return this._isSingleTouchEnabled}set isSingleTouchEnabled(t){this._isSingleTouchEnabled=t}constructor(t){super(t),this._previousEvents=new Map,this._currentEvents=new Map,this._lastGestureAction=z.None,this._maxInitialDistanceDifference=30*window.devicePixelRatio,this._isSingleTouchEnabled=!1,this._orbitAction=new A(this.m_module,this.subject,this.beginInteractivity,this.endInteractivity),this._panAction=new M(this.m_module,this.subject,this.beginInteractivity,this.endInteractivity,this.getViewParams,this.setViewParams),this._zoomAction=new D(this.m_module,this.subject)}getMiddlePoint(t){if(2!==t.size)return;const e=this.getKeys(t),i=this.relativeCoords(t.get(e[0])),r=this.relativeCoords(t.get(e[1]));return{x:Math.floor((i.x+r.x)/2),y:Math.floor((i.y+r.y)/2)}}getFirstPoint(t){if(t.size<1)return;const e=this.getKeys(t);return this.relativeCoords(t.get(e[0]))}getDistance(t){if(2!==t.size)return-1;const e=this.getKeys(t),i=this.relativeCoords(t.get(e[0])),r=this.relativeCoords(t.get(e[1]));return Math.hypot(i.x-r.x,i.y-r.y)}updateEvent(t){const e=!this._currentEvents.get(t.pointerId);if(e&&2===this._currentEvents.size)return;const i=this._currentEvents.get(t.pointerId);i&&this._previousEvents.set(i.pointerId,i),this._currentEvents.set(t.pointerId,t),e&&(this._initialDistance=this.getDistance(this._currentEvents))}removeEvent(t){this._currentEvents.delete(t.pointerId),this._previousEvents.delete(t.pointerId),this._currentEvents.size<2&&(this._initialDistance=-1)}getKeys(t){return Array.from(t.keys())}analyzeGesture(){if(2===this._currentEvents.size){const t=this.getDistance(this._currentEvents),e=this.getDistance(this._previousEvents);Math.abs(this._initialDistance-t)<=this._maxInitialDistanceDifference?this.executePanAction(this.getMiddlePoint(this._currentEvents)):-1!==e&&t!==e&&this.executeZoomAction(t,e)}else 1===this._currentEvents.size&&this.isSingleTouchEnabled&&this.executeOrbitAction(this.getFirstPoint(this._currentEvents))}executeZoomAction(t,e){this._lastGestureAction!==z.Zoom&&(this.executeEndAction(this._lastGestureAction),this._lastGestureAction=z.Zoom,c.isGestureActive=!0);const i=1+(t-e)/700,r=this.getMiddlePoint(this._currentEvents);this._zoomAction.action(r.x,r.y,i),this.subject.update()}executePanAction(t){this._lastGestureAction!==z.Pan&&(this.executeEndAction(this._lastGestureAction),this._lastGestureAction=z.Pan,c.isGestureActive=!0,this._panAction.beginAction(t.x,t.y)),this._panAction.action(t.x,t.y),this.subject.update()}executeOrbitAction(t){this._lastGestureAction!==z.Orbit&&(this.executeEndAction(this._lastGestureAction),this._lastGestureAction=z.Orbit,c.isGestureActive=!0,this._orbitAction.beginAction(t.x,t.y)),this._orbitAction.action(t.x,t.y),this.subject.update()}executeEndAction(t){t===z.Orbit&&this._orbitAction.endAction(),t===z.Pan&&this._panAction.endAction(),c.isGestureActive=!1}needIgnoreEvent(t){return!this.subject.options.enableZoomWheel||!this.subject.options.enableGestures||!this.eventIsTouchEvent(t)}eventIsTouchEvent(t){return"touch"===t.pointerType||""===t.pointerType}pointerdown(t){this.needIgnoreEvent(t)||this.updateEvent(t)}pointermove(t){this.needIgnoreEvent(t)||(this.updateEvent(t),this.analyzeGesture())}pointerup(t){this.needIgnoreEvent(t)||(this.removeEvent(t),this._currentEvents.size<2&&(this.executeEndAction(this._lastGestureAction),c.isGestureActive=!1),this._lastGestureAction=z.None)}pointercancel(t){this.needIgnoreEvent(t)||this.pointerup(t)}pointerleave(t){this.needIgnoreEvent(t)||this.pointerup(t)}}function N(t){if(window.getVisualizeLibInst){const e=window.getVisualizeLibInst.script;if(e){if(e.src===t)return Promise.resolve(e);e.remove()}delete window.getVisualizeLibInst}return function(t){return new Promise(((e,i)=>{const r=document.createElement("script");r.src=t,r.async=!0,r.onload=()=>e(r),r.onerror=()=>{r.remove(),i(new Error(`GET ${t} failed to load script`))},document.body.appendChild(r)}))}(t)}class U{constructor(t,e,i){this.viewer=t,this.model=e,this.options=i}async load(){}}class W extends U{async load(){if(!this.viewer.visualizeJs)return;const t=this.viewer.visLib().getViewer(),e=new AbortController,i=[this.model.database,...this.model.geometry],r=i.map((()=>0)),s=(t,e)=>{r[t]=e;const i=r.reduce(((t,e)=>t+e))/(r.length||1);this.viewer.emitEvent({type:"geometryprogress",data:i,model:this.model})};this.viewer._abortController=e;try{this.viewer.emitEvent({type:"geometrystart",model:this.model});for(let r=0;r<i.length;r++){const a=i[r],n=t=>s(r,t),o=await this.model.downloadResource(a,n,e.signal);e.signal.aborted&&await Promise.reject(new Error(`Open model aborted ${this.model.name}`)),t.parseStream(new Uint8Array(o)),this.viewer.update();const h=new Uint8Array(o);0===r?(this.viewer.update(!0),this.viewer.syncOpenCloudVisualStyle(!1),this.viewer.syncOptions(),this.viewer.resize(),this.viewer.emitEvent({type:"databasechunk",data:h,model:this.model})):this.viewer.emitEvent({type:"geometrychunk",data:h,model:this.model})}this.viewer.emitEvent({type:"geometryend",model:this.model})}catch(t){throw this.viewer.emitEvent({type:"geometryerror",data:t,model:this.model}),t}}}var j,B,H;!function(t){t[t.kDelay=0]="kDelay",t[t.kNormal=1]="kNormal",t[t.kForce=2]="kForce"}(j||(j={}));class K{constructor(){this.delayUpdateTime=1e3}initialize(t){this.viewer=t,this.lastUpdate=performance.now()}update(t){const e=t!==j.kDelay||performance.now()-this.lastUpdate>=this.delayUpdateTime,i=t===j.kForce;e&&(this.viewer.update(i),this.lastUpdate=performance.now(),this.delayUpdateTime*=2)}}class Y extends U{async load(){if(!this.viewer.visualizeJs)return;const t=this.viewer.visLib(),e=t.getViewer(),i=new AbortController,r=new K;r.initialize(this.viewer),this.viewer._abortController=i;let s=!1;const a=(i,a)=>{if(!this.viewer.visualizeJs)return;const n=e.parseVsfx(a);r.update(j.kDelay),this.viewer.emitEvent({type:"geometryprogress",data:i,model:this.model});let o=!1;(n===t.DatabaseStreamStatus.ReadyServiceData||n===t.DatabaseStreamStatus.Complete&&!s)&&(s=!0,o=!0),o?(r.update(j.kForce),this.viewer.syncOpenCloudVisualStyle(!1),this.viewer.syncOptions(),this.viewer.resize(),this.viewer.emitEvent({type:"databasechunk",data:a,model:this.model})):this.viewer.emitEvent({type:"geometrychunk",data:a,model:this.model})};console.time("File load time");try{this.viewer.emitEvent({type:"geometrystart",model:this.model}),await this.model.partialDownloadResource(this.model.database,a,i.signal),console.timeEnd("File load time"),r.update(j.kNormal),this.viewer.emitEvent({type:"geometryend",model:this.model})}catch(t){throw this.viewer.emitEvent({type:"geometryerror",data:t,model:this.model}),t}}}class X extends U{async load(){if(!this.viewer.visualizeJs)return;const t=this.viewer.visLib().getViewer(),e=new AbortController,i=new Map;let r=!1;const s=new Map;let a=0;const n=()=>clearTimeout(a),o=new AbortController;i.set(0,o);const h=new K;h.initialize(this.viewer),this.viewer._abortController=e,this.viewer._abortControllerForRequestMap=i,t.memoryLimit=this.options.memoryLimit;const l=(e,i,r)=>{if(!this.viewer.visualizeJs)return;const s=t.parseVsfxInPartialMode(r,i);h.update(j.kDelay),this.viewer.emitEvent({type:"geometryprogress",data:e,model:this.model}),s?(h.update(j.kForce),this.viewer.syncOpenCloudVisualStyle(!1),this.viewer.syncOptions(),this.viewer.resize(),this.viewer.emitEvent({type:"databasechunk",data:i,model:this.model})):this.viewer.emitEvent({type:"geometrychunk",data:i,model:this.model})},d=async(e,r,s,a=!1)=>{const n=new AbortController;i.set(e,n);try{await this.model.downloadFileRange(e,r,s,l,n.signal)}catch(t){this.viewer.emitEvent({type:"geometryerror",data:t,model:this.model})}finally{(a?[...new Set(r.map((t=>t.reqId)))]:[e]).forEach((e=>t.onRequestResponseComplete(e))),i.delete(e),h.update(j.kNormal)}},c=(t,e)=>{const i=[];for(let r=0;r<e.size();r++){const s=e.get(r);i.push({reqId:t,begin:s.begin,end:s.end,size:parseInt(s.end,10)-parseInt(s.begin,10)}),s.delete()}return i},u={onServicePartReceived:t=>{t&&(r=!0,e.abort())},onRequest:(t,e)=>{d(t,e,this.model.database)},onFullLoaded:()=>{h.update(j.kNormal),console.timeEnd("File load time")},onRequestResponseParsed:t=>{i.delete(t),h.update(j.kNormal)},onRequestAborted:t=>{const e=i.get(t);e&&e.abort()},onRequestResourceFile:async(t,e,i)=>{const r=`${this.model.fileId}${this.model.file.type}`;let h=[],l=0;const u=s.get(r);if(u&&(h=u.array,l=u.number),l<6)return s.set(r,{array:h,number:l+1}),void await d(t,i,r);h.length>=50?(a&&(window.clearTimeout(a),a=0),d(t,h,r,!0),h=[...c(t,i)]):h=[...h,...c(t,i)],s.set(r,{array:h,number:l+1}),0===a&&(a=window.setTimeout((()=>{o.signal.removeEventListener("abort",n),a=0,s.forEach(((e,i)=>{const r=e.array;r.length>0&&(d(t,r,i,!0),s.set(i,{array:[],number:e.number+1}))}))}),250),o.signal.addEventListener("abort",n,{once:!0}))}};t.attachPartialResolver(u),console.time("File load time");try{this.viewer.emitEvent({type:"geometrystart",model:this.model}),await this.model.downloadFileRange(0,null,this.model.database,l,e.signal).catch((t=>{if(!r)throw t})),this.viewer.emitEvent({type:"geometryend",model:this.model})}catch(t){throw a&&(window.clearTimeout(a),a=0),this.viewer.emitEvent({type:"geometryerror",data:t,model:this.model}),t}}}class J extends U{async load(){if(!this.viewer.visualizeJs)return;const t=this.viewer.visLib().getViewer(),e=new AbortController;this.viewer._abortController=e,console.time("File load time");try{this.viewer.emitEvent({type:"geometrystart",model:this.model});const i=t=>this.viewer.emitEvent({type:"geometryprogress",data:t,model:this.model}),r=await this.model.downloadResource(this.model.database,i,e.signal);e.signal.aborted&&await Promise.reject(new Error(`Open model aborted ${this.model.name}`)),this.viewer.visualizeJs&&(t.parseVsfx(new Uint8Array(r)),this.viewer.update(!0),this.viewer.syncOpenCloudVisualStyle(!1),this.viewer.syncOptions(),this.viewer.resize()),console.timeEnd("File load time"),this.viewer.emitEvent({type:"geometryend",model:this.model})}catch(t){throw this.viewer.emitEvent({type:"geometryerror",data:t,model:this.model}),t}}}class q{create(t,e,i){const r=e.database.split(".").pop();if(0===e.geometry.length&&"vsfx"===r)return i.enableStreamingMode?i.enablePartialMode?new X(t,e,i):new Y(t,e,i):new J(t,e,i);if("data"===r)return new W(t,e,i);throw new Error(`Unknown geometry type: ${r}`)}}!function(t){t[t.Unknown=0]="Unknown",t.Konva="Konva",t.Visualize="Visualize"}(B||(B={})),function(t){t.Line="Line",t.Text="Text",t.Rectangle="Rectangle",t.Ellipse="Ellipse",t.Arrow="Arrow",t.Image="Image",t.Cloud="Cloud"}(H||(H={}));var Z="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function $(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Q={exports:{}},tt={},et={},it={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t._registerNode=t.Konva=t.glob=void 0;const e=Math.PI/180;t.glob=void 0!==Z?Z:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},t.Konva={_global:t.glob,version:"9.3.6",isBrowser:"undefined"!=typeof window&&("[object Window]"==={}.toString.call(window)||"[object global]"==={}.toString.call(window)),isUnminified:/param/.test(function(t){}.toString()),dblClickWindow:400,getAngle:i=>t.Konva.angleDeg?i*e:i,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,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:()=>t.Konva.DD.isDragging,isTransforming(){var e;return null===(e=t.Konva.Transformer)||void 0===e?void 0:e.isTransforming()},isDragReady:()=>!!t.Konva.DD.node,releaseCanvasOnDestroy:!0,document:t.glob.document,_injectGlobal(e){t.glob.Konva=e}};t._registerNode=e=>{t.Konva[e.prototype.getClassName()]=e},t.Konva._injectGlobal(t.Konva)}(it);var rt={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Util=t.Transform=void 0;const e=it;class i{constructor(t=[1,0,0,1,0,0]){this.dirty=!1,this.m=t&&t.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new i(this.m)}copyInto(t){t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5]}point(t){var e=this.m;return{x:e[0]*t.x+e[2]*t.y+e[4],y:e[1]*t.x+e[3]*t.y+e[5]}}translate(t,e){return this.m[4]+=this.m[0]*t+this.m[2]*e,this.m[5]+=this.m[1]*t+this.m[3]*e,this}scale(t,e){return this.m[0]*=t,this.m[1]*=t,this.m[2]*=e,this.m[3]*=e,this}rotate(t){var e=Math.cos(t),i=Math.sin(t),r=this.m[0]*e+this.m[2]*i,s=this.m[1]*e+this.m[3]*i,a=this.m[0]*-i+this.m[2]*e,n=this.m[1]*-i+this.m[3]*e;return this.m[0]=r,this.m[1]=s,this.m[2]=a,this.m[3]=n,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(t,e){var i=this.m[0]+this.m[2]*e,r=this.m[1]+this.m[3]*e,s=this.m[2]+this.m[0]*t,a=this.m[3]+this.m[1]*t;return this.m[0]=i,this.m[1]=r,this.m[2]=s,this.m[3]=a,this}multiply(t){var e=this.m[0]*t.m[0]+this.m[2]*t.m[1],i=this.m[1]*t.m[0]+this.m[3]*t.m[1],r=this.m[0]*t.m[2]+this.m[2]*t.m[3],s=this.m[1]*t.m[2]+this.m[3]*t.m[3],a=this.m[0]*t.m[4]+this.m[2]*t.m[5]+this.m[4],n=this.m[1]*t.m[4]+this.m[3]*t.m[5]+this.m[5];return this.m[0]=e,this.m[1]=i,this.m[2]=r,this.m[3]=s,this.m[4]=a,this.m[5]=n,this}invert(){var t=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),e=this.m[3]*t,i=-this.m[1]*t,r=-this.m[2]*t,s=this.m[0]*t,a=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),n=t*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=e,this.m[1]=i,this.m[2]=r,this.m[3]=s,this.m[4]=a,this.m[5]=n,this}getMatrix(){return this.m}decompose(){var e=this.m[0],i=this.m[1],r=this.m[2],s=this.m[3],a=e*s-i*r;let n={x:this.m[4],y:this.m[5],rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!=e||0!=i){var o=Math.sqrt(e*e+i*i);n.rotation=i>0?Math.acos(e/o):-Math.acos(e/o),n.scaleX=o,n.scaleY=a/o,n.skewX=(e*r+i*s)/a,n.skewY=0}else if(0!=r||0!=s){var h=Math.sqrt(r*r+s*s);n.rotation=Math.PI/2-(s>0?Math.acos(-r/h):-Math.acos(r/h)),n.scaleX=a/h,n.scaleY=h,n.skewX=0,n.skewY=(e*r+i*s)/a}return n.rotation=t.Util._getRotation(n.rotation),n}}t.Transform=i;var r=Math.PI/180,s=180/Math.PI,a="Konva error: ",n={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]},o=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,h=[];const l="undefined"!=typeof requestAnimationFrame&&requestAnimationFrame||function(t){setTimeout(t,60)};t.Util={_isElement:t=>!(!t||1!=t.nodeType),_isFunction:t=>!!(t&&t.constructor&&t.call&&t.apply),_isPlainObject:t=>!!t&&t.constructor===Object,_isArray:t=>"[object Array]"===Object.prototype.toString.call(t),_isNumber:t=>"[object Number]"===Object.prototype.toString.call(t)&&!isNaN(t)&&isFinite(t),_isString:t=>"[object String]"===Object.prototype.toString.call(t),_isBoolean:t=>"[object Boolean]"===Object.prototype.toString.call(t),isObject:t=>t instanceof Object,isValidSelector(t){if("string"!=typeof t)return!1;var e=t[0];return"#"===e||"."===e||e===e.toUpperCase()},_sign:t=>0===t||t>0?1:-1,requestAnimFrame(t){h.push(t),1===h.length&&l((function(){const t=h;h=[],t.forEach((function(t){t()}))}))},createCanvasElement(){var t=document.createElement("canvas");try{t.style=t.style||{}}catch(t){}return t},createImageElement:()=>document.createElement("img"),_isInDocument(t){for(;t=t.parentNode;)if(t==document)return!0;return!1},_urlToImage(e,i){var r=t.Util.createImageElement();r.onload=function(){i(r)},r.src=e},_rgbToHex:(t,e,i)=>((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1),_hexToRgb(t){t=t.replace("#","");var e=parseInt(t,16);return{r:e>>16&255,g:e>>8&255,b:255&e}},getRandomColor(){for(var t=(16777215*Math.random()|0).toString(16);t.length<6;)t="0"+t;return"#"+t},getRGB(t){var e;return t in n?{r:(e=n[t])[0],g:e[1],b:e[2]}:"#"===t[0]?this._hexToRgb(t.substring(1)):"rgb("===t.substr(0,4)?(e=o.exec(t.replace(/ /g,"")),{r:parseInt(e[1],10),g:parseInt(e[2],10),b:parseInt(e[3],10)}):{r:0,g:0,b:0}},colorToRGBA:e=>(e=e||"black",t.Util._namedColorToRBA(e)||t.Util._hex3ColorToRGBA(e)||t.Util._hex4ColorToRGBA(e)||t.Util._hex6ColorToRGBA(e)||t.Util._hex8ColorToRGBA(e)||t.Util._rgbColorToRGBA(e)||t.Util._rgbaColorToRGBA(e)||t.Util._hslColorToRGBA(e)),_namedColorToRBA(t){var e=n[t.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:1}:null},_rgbColorToRGBA(t){if(0===t.indexOf("rgb(")){var e=(t=t.match(/rgb\(([^)]+)\)/)[1]).split(/ *, */).map(Number);return{r:e[0],g:e[1],b:e[2],a:1}}},_rgbaColorToRGBA(t){if(0===t.indexOf("rgba(")){var e=(t=t.match(/rgba\(([^)]+)\)/)[1]).split(/ *, */).map(((t,e)=>"%"===t.slice(-1)?3===e?parseInt(t)/100:parseInt(t)/100*255:Number(t)));return{r:e[0],g:e[1],b:e[2],a:e[3]}}},_hex8ColorToRGBA(t){if("#"===t[0]&&9===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:parseInt(t.slice(7,9),16)/255}},_hex6ColorToRGBA(t){if("#"===t[0]&&7===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:1}},_hex4ColorToRGBA(t){if("#"===t[0]&&5===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:parseInt(t[4]+t[4],16)/255}},_hex3ColorToRGBA(t){if("#"===t[0]&&4===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:1}},_hslColorToRGBA(t){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(t)){const[e,...i]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t),r=Number(i[0])/360,s=Number(i[1])/100,a=Number(i[2])/100;let n,o,h;if(0===s)return h=255*a,{r:Math.round(h),g:Math.round(h),b:Math.round(h),a:1};n=a<.5?a*(1+s):a+s-a*s;const l=2*a-n,d=[0,0,0];for(let t=0;t<3;t++)o=r+1/3*-(t-1),o<0&&o++,o>1&&o--,h=6*o<1?l+6*(n-l)*o:2*o<1?n:3*o<2?l+(n-l)*(2/3-o)*6:l,d[t]=255*h;return{r:Math.round(d[0]),g:Math.round(d[1]),b:Math.round(d[2]),a:1}}},haveIntersection:(t,e)=>!(e.x>t.x+t.width||e.x+e.width<t.x||e.y>t.y+t.height||e.y+e.height<t.y),cloneObject(t){var e={};for(var i in t)this._isPlainObject(t[i])?e[i]=this.cloneObject(t[i]):this._isArray(t[i])?e[i]=this.cloneArray(t[i]):e[i]=t[i];return e},cloneArray:t=>t.slice(0),degToRad:t=>t*r,radToDeg:t=>t*s,_degToRad:e=>(t.Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),t.Util.degToRad(e)),_radToDeg:e=>(t.Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),t.Util.radToDeg(e)),_getRotation:i=>e.Konva.angleDeg?t.Util.radToDeg(i):i,_capitalize:t=>t.charAt(0).toUpperCase()+t.slice(1),throw(t){throw new Error(a+t)},error(t){console.error(a+t)},warn(t){e.Konva.showWarnings&&console.warn("Konva warning: "+t)},each(t,e){for(var i in t)e(i,t[i])},_inRange:(t,e,i)=>e<=t&&t<i,_getProjectionToSegment(t,e,i,r,s,a){var n,o,h,l=(t-i)*(t-i)+(e-r)*(e-r);if(0==l)n=t,o=e,h=(s-i)*(s-i)+(a-r)*(a-r);else{var d=((s-t)*(i-t)+(a-e)*(r-e))/l;d<0?(n=t,o=e,h=(t-s)*(t-s)+(e-a)*(e-a)):d>1?(n=i,o=r,h=(i-s)*(i-s)+(r-a)*(r-a)):h=((n=t+d*(i-t))-s)*(n-s)+((o=e+d*(r-e))-a)*(o-a)}return[n,o,h]},_getProjectionToLine(e,i,r){var s=t.Util.cloneObject(e),a=Number.MAX_VALUE;return i.forEach((function(n,o){if(r||o!==i.length-1){var h=i[(o+1)%i.length],l=t.Util._getProjectionToSegment(n.x,n.y,h.x,h.y,e.x,e.y),d=l[0],c=l[1],u=l[2];u<a&&(s.x=d,s.y=c,a=u)}})),s},_prepareArrayForTween(e,i,r){var s,a=[],n=[];if(e.length>i.length){var o=i;i=e,e=o}for(s=0;s<e.length;s+=2)a.push({x:e[s],y:e[s+1]});for(s=0;s<i.length;s+=2)n.push({x:i[s],y:i[s+1]});var h=[];return n.forEach((function(e){var i=t.Util._getProjectionToLine(e,a,r);h.push(i.x),h.push(i.y)})),h},_prepareToStringify(e){var i;for(var r in e.visitedByCircularReferenceRemoval=!0,e)if(e.hasOwnProperty(r)&&e[r]&&"object"==typeof e[r])if(i=Object.getOwnPropertyDescriptor(e,r),e[r].visitedByCircularReferenceRemoval||t.Util._isElement(e[r])){if(!i.configurable)return null;delete e[r]}else if(null===t.Util._prepareToStringify(e[r])){if(!i.configurable)return null;delete e[r]}return delete e.visitedByCircularReferenceRemoval,e},_assign(t,e){for(var i in e)t[i]=e[i];return t},_getFirstPointerId:t=>t.touches?t.changedTouches[0].identifier:t.pointerId||999,releaseCanvas(...t){e.Konva.releaseCanvasOnDestroy&&t.forEach((t=>{t.width=0,t.height=0}))},drawRoundedRectPath(t,e,i,r){let s=0,a=0,n=0,o=0;"number"==typeof r?s=a=n=o=Math.min(r,e/2,i/2):(s=Math.min(r[0]||0,e/2,i/2),a=Math.min(r[1]||0,e/2,i/2),o=Math.min(r[2]||0,e/2,i/2),n=Math.min(r[3]||0,e/2,i/2)),t.moveTo(s,0),t.lineTo(e-a,0),t.arc(e-a,a,a,3*Math.PI/2,0,!1),t.lineTo(e,i-o),t.arc(e-o,i-o,o,0,Math.PI/2,!1),t.lineTo(n,i),t.arc(n,i-n,n,Math.PI/2,Math.PI,!1),t.lineTo(0,s),t.arc(s,s,s,Math.PI,3*Math.PI/2,!1)}}}(rt);var st={},at={},nt={};Object.defineProperty(nt,"__esModule",{value:!0}),nt.getComponentValidator=nt.getBooleanValidator=nt.getNumberArrayValidator=nt.getFunctionValidator=nt.getStringOrGradientValidator=nt.getStringValidator=nt.getNumberOrAutoValidator=nt.getNumberOrArrayOfNumbersValidator=nt.getNumberValidator=nt.alphaComponent=nt.RGBComponent=void 0;const ot=it,ht=rt;function lt(t){return ht.Util._isString(t)?'"'+t+'"':"[object Number]"===Object.prototype.toString.call(t)||ht.Util._isBoolean(t)?t:Object.prototype.toString.call(t)}nt.RGBComponent=function(t){return t>255?255:t<0?0:Math.round(t)},nt.alphaComponent=function(t){return t>1?1:t<1e-4?1e-4:t},nt.getNumberValidator=function(){if(ot.Konva.isUnminified)return function(t,e){return ht.Util._isNumber(t)||ht.Util.warn(lt(t)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),t}},nt.getNumberOrArrayOfNumbersValidator=function(t){if(ot.Konva.isUnminified)return function(e,i){let r=ht.Util._isNumber(e),s=ht.Util._isArray(e)&&e.length==t;return r||s||ht.Util.warn(lt(e)+' is a not valid value for "'+i+'" attribute. The value should be a number or Array<number>('+t+")"),e}},nt.getNumberOrAutoValidator=function(){if(ot.Konva.isUnminified)return function(t,e){return ht.Util._isNumber(t)||"auto"===t||ht.Util.warn(lt(t)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),t}},nt.getStringValidator=function(){if(ot.Konva.isUnminified)return function(t,e){return ht.Util._isString(t)||ht.Util.warn(lt(t)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),t}},nt.getStringOrGradientValidator=function(){if(ot.Konva.isUnminified)return function(t,e){const i=ht.Util._isString(t),r="[object CanvasGradient]"===Object.prototype.toString.call(t)||t&&t.addColorStop;return i||r||ht.Util.warn(lt(t)+' is a not valid value for "'+e+'" attribute. The value should be a string or a native gradient.'),t}},nt.getFunctionValidator=function(){if(ot.Konva.isUnminified)return function(t,e){return ht.Util._isFunction(t)||ht.Util.warn(lt(t)+' is a not valid value for "'+e+'" attribute. The value should be a function.'),t}},nt.getNumberArrayValidator=function(){if(ot.Konva.isUnminified)return function(t,e){const i=Int8Array?Object.getPrototypeOf(Int8Array):null;return i&&t instanceof i||(ht.Util._isArray(t)?t.forEach((function(t){ht.Util._isNumber(t)||ht.Util.warn('"'+e+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")})):ht.Util.warn(lt(t)+' is a not valid value for "'+e+'" attribute. The value should be a array of numbers.')),t}},nt.getBooleanValidator=function(){if(ot.Konva.isUnminified)return function(t,e){return!0===t||!1===t||ht.Util.warn(lt(t)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),t}},nt.getComponentValidator=function(t){if(ot.Konva.isUnminified)return function(e,i){return null==e||ht.Util.isObject(e)||ht.Util.warn(lt(e)+' is a not valid value for "'+i+'" attribute. The value should be an object with properties '+t),e}},function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Factory=void 0;const e=rt,i=nt;var r="get",s="set";t.Factory={addGetterSetter(e,i,r,s,a){t.Factory.addGetter(e,i,r),t.Factory.addSetter(e,i,s,a),t.Factory.addOverloadedGetterSetter(e,i)},addGetter(t,i,s){var a=r+e.Util._capitalize(i);t.prototype[a]=t.prototype[a]||function(){var t=this.attrs[i];return void 0===t?s:t}},addSetter(i,r,a,n){var o=s+e.Util._capitalize(r);i.prototype[o]||t.Factory.overWriteSetter(i,r,a,n)},overWriteSetter(t,i,r,a){var n=s+e.Util._capitalize(i);t.prototype[n]=function(t){return r&&null!=t&&(t=r.call(this,t,i)),this._setAttr(i,t),a&&a.call(this),this}},addComponentsGetterSetter(a,n,o,h,l){var d,c,u=o.length,g=e.Util._capitalize,p=r+g(n),m=s+g(n);a.prototype[p]=function(){var t={};for(d=0;d<u;d++)t[c=o[d]]=this.getAttr(n+g(c));return t};var f=(0,i.getComponentValidator)(o);a.prototype[m]=function(t){var e,i=this.attrs[n];for(e in h&&(t=h.call(this,t)),f&&f.call(this,t,n),t)t.hasOwnProperty(e)&&this._setAttr(n+g(e),t[e]);return t||o.forEach((t=>{this._setAttr(n+g(t),void 0)})),this._fireChangeEvent(n,i,t),l&&l.call(this),this},t.Factory.addOverloadedGetterSetter(a,n)},addOverloadedGetterSetter(t,i){var a=e.Util._capitalize(i),n=s+a,o=r+a;t.prototype[i]=function(){return arguments.length?(this[n](arguments[0]),this):this[o]()}},addDeprecatedGetterSetter(i,s,a,n){e.Util.error("Adding deprecated "+s);var o=r+e.Util._capitalize(s),h=s+" property is deprecated and will be removed soon. Look at Konva change log for more information.";i.prototype[o]=function(){e.Util.error(h);var t=this.attrs[s];return void 0===t?a:t},t.Factory.addSetter(i,s,n,(function(){e.Util.error(h)})),t.Factory.addOverloadedGetterSetter(i,s)},backCompat(t,i){e.Util.each(i,(function(i,a){var n=t.prototype[a],o=r+e.Util._capitalize(i),h=s+e.Util._capitalize(i);function l(){n.apply(this,arguments),e.Util.error('"'+i+'" method is deprecated and will be removed soon. Use ""'+a+'" instead.')}t.prototype[i]=l,t.prototype[o]=l,t.prototype[h]=l}))},afterSetFilter(){this._filterUpToDate=!1}}}(at);var dt={},ct={};Object.defineProperty(ct,"__esModule",{value:!0}),ct.HitContext=ct.SceneContext=ct.Context=void 0;const ut=rt,gt=it;var pt=["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"];class mt{constructor(t){this.canvas=t,gt.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,e){var i,r,s,a,n=this.traceArr,o=n.length,h="";for(i=0;i<o;i++)(s=(r=n[i]).method)?(a=r.args,h+=s,t?h+="()":ut.Util._isArray(a[0])?h+="(["+a.join(",")+"])":(e&&(a=a.map((t=>"number"==typeof t?Math.floor(t):t))),h+="("+a.join(",")+")")):(h+=r.property,t||(h+="="+r.val)),h+=";";return h}clearTrace(){this.traceArr=[]}_trace(t){var e=this.traceArr;e.push(t),e.length>=100&&e.shift()}reset(){var t=this.getCanvas().getPixelRatio();this.setTransform(1*t,0,0,1*t,0,0)}getCanvas(){return this.canvas}clear(t){var e=this.getCanvas();t?this.clearRect(t.x||0,t.y||0,t.width||0,t.height||0):this.clearRect(0,0,e.getWidth()/e.pixelRatio,e.getHeight()/e.pixelRatio)}_applyLineCap(t){const e=t.attrs.lineCap;e&&this.setAttr("lineCap",e)}_applyOpacity(t){var e=t.getAbsoluteOpacity();1!==e&&this.setAttr("globalAlpha",e)}_applyLineJoin(t){const e=t.attrs.lineJoin;e&&this.setAttr("lineJoin",e)}setAttr(t,e){this._context[t]=e}arc(t,e,i,r,s,a){this._context.arc(t,e,i,r,s,a)}arcTo(t,e,i,r,s){this._context.arcTo(t,e,i,r,s)}beginPath(){this._context.beginPath()}bezierCurveTo(t,e,i,r,s,a){this._context.bezierCurveTo(t,e,i,r,s,a)}clearRect(t,e,i,r){this._context.clearRect(t,e,i,r)}clip(...t){this._context.clip.apply(this._context,t)}closePath(){this._context.closePath()}createImageData(t,e){var i=arguments;return 2===i.length?this._context.createImageData(t,e):1===i.length?this._context.createImageData(t):void 0}createLinearGradient(t,e,i,r){return this._context.createLinearGradient(t,e,i,r)}createPattern(t,e){return this._context.createPattern(t,e)}createRadialGradient(t,e,i,r,s,a){return this._context.createRadialGradient(t,e,i,r,s,a)}drawImage(t,e,i,r,s,a,n,o,h){var l=arguments,d=this._context;3===l.length?d.drawImage(t,e,i):5===l.length?d.drawImage(t,e,i,r,s):9===l.length&&d.drawImage(t,e,i,r,s,a,n,o,h)}ellipse(t,e,i,r,s,a,n,o){this._context.ellipse(t,e,i,r,s,a,n,o)}isPointInPath(t,e,i,r){return i?this._context.isPointInPath(i,t,e,r):this._context.isPointInPath(t,e,r)}fill(...t){this._context.fill.apply(this._context,t)}fillRect(t,e,i,r){this._context.fillRect(t,e,i,r)}strokeRect(t,e,i,r){this._context.strokeRect(t,e,i,r)}fillText(t,e,i,r){r?this._context.fillText(t,e,i,r):this._context.fillText(t,e,i)}measureText(t){return this._context.measureText(t)}getImageData(t,e,i,r){return this._context.getImageData(t,e,i,r)}lineTo(t,e){this._context.lineTo(t,e)}moveTo(t,e){this._context.moveTo(t,e)}rect(t,e,i,r){this._context.rect(t,e,i,r)}roundRect(t,e,i,r,s){this._context.roundRect(t,e,i,r,s)}putImageData(t,e,i){this._context.putImageData(t,e,i)}quadraticCurveTo(t,e,i,r){this._context.quadraticCurveTo(t,e,i,r)}restore(){this._context.restore()}rotate(t){this._context.rotate(t)}save(){this._context.save()}scale(t,e){this._context.scale(t,e)}setLineDash(t){this._context.setLineDash?this._context.setLineDash(t):"mozDash"in this._context?this._context.mozDash=t:"webkitLineDash"in this._context&&(this._context.webkitLineDash=t)}getLineDash(){return this._context.getLineDash()}setTransform(t,e,i,r,s,a){this._context.setTransform(t,e,i,r,s,a)}stroke(t){t?this._context.stroke(t):this._context.stroke()}strokeText(t,e,i,r){this._context.strokeText(t,e,i,r)}transform(t,e,i,r,s,a){this._context.transform(t,e,i,r,s,a)}translate(t,e){this._context.translate(t,e)}_enableTrace(){var t,e,i=this,r=pt.length,s=this.setAttr,a=function(t){var r,s=i[t];i[t]=function(){return e=function(t){var e,i,r=[],s=t.length,a=ut.Util;for(e=0;e<s;e++)i=t[e],a._isNumber(i)?i=Math.round(1e3*i)/1e3:a._isString(i)||(i+=""),r.push(i);return r}(Array.prototype.slice.call(arguments,0)),r=s.apply(i,arguments),i._trace({method:t,args:e}),r}};for(t=0;t<r;t++)a(pt[t]);i.setAttr=function(){s.apply(i,arguments);var t=arguments[0],e=arguments[1];"shadowOffsetX"!==t&&"shadowOffsetY"!==t&&"shadowBlur"!==t||(e/=this.canvas.getPixelRatio()),i._trace({property:t,val:e})}}_applyGlobalCompositeOperation(t){const e=t.attrs.globalCompositeOperation;!e||"source-over"===e||this.setAttr("globalCompositeOperation",e)}}ct.Context=mt,["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"].forEach((function(t){Object.defineProperty(mt.prototype,t,{get(){return this._context[t]},set(e){this._context[t]=e}})}));ct.SceneContext=class extends mt{constructor(t,{willReadFrequently:e=!1}={}){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:e})}_fillColor(t){var e=t.fill();this.setAttr("fillStyle",e),t._fillFunc(this)}_fillPattern(t){this.setAttr("fillStyle",t._getFillPattern()),t._fillFunc(this)}_fillLinearGradient(t){var e=t._getLinearGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fillRadialGradient(t){const e=t._getRadialGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fill(t){const e=t.fill(),i=t.getFillPriority();if(e&&"color"===i)return void this._fillColor(t);const r=t.getFillPatternImage();if(r&&"pattern"===i)return void this._fillPattern(t);const s=t.getFillLinearGradientColorStops();if(s&&"linear-gradient"===i)return void this._fillLinearGradient(t);const a=t.getFillRadialGradientColorStops();a&&"radial-gradient"===i?this._fillRadialGradient(t):e?this._fillColor(t):r?this._fillPattern(t):s?this._fillLinearGradient(t):a&&this._fillRadialGradient(t)}_strokeLinearGradient(t){const e=t.getStrokeLinearGradientStartPoint(),i=t.getStrokeLinearGradientEndPoint(),r=t.getStrokeLinearGradientColorStops(),s=this.createLinearGradient(e.x,e.y,i.x,i.y);if(r){for(var a=0;a<r.length;a+=2)s.addColorStop(r[a],r[a+1]);this.setAttr("strokeStyle",s)}}_stroke(t){var e=t.dash(),i=t.getStrokeScaleEnabled();if(t.hasStroke()){if(!i){this.save();var r=this.getCanvas().getPixelRatio();this.setTransform(r,0,0,r,0,0)}this._applyLineCap(t),e&&t.dashEnabled()&&(this.setLineDash(e),this.setAttr("lineDashOffset",t.dashOffset())),this.setAttr("lineWidth",t.strokeWidth()),t.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)"),t.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(t):this.setAttr("strokeStyle",t.stroke()),t._strokeFunc(this),i||this.restore()}}_applyShadow(t){var e,i,r,s=null!==(e=t.getShadowRGBA())&&void 0!==e?e:"black",a=null!==(i=t.getShadowBlur())&&void 0!==i?i:5,n=null!==(r=t.getShadowOffset())&&void 0!==r?r:{x:0,y:0},o=t.getAbsoluteScale(),h=this.canvas.getPixelRatio(),l=o.x*h,d=o.y*h;this.setAttr("shadowColor",s),this.setAttr("shadowBlur",a*Math.min(Math.abs(l),Math.abs(d))),this.setAttr("shadowOffsetX",n.x*l),this.setAttr("shadowOffsetY",n.y*d)}};ct.HitContext=class extends mt{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 s=t.getStrokeScaleEnabled();if(!s){this.save();var e=this.getCanvas().getPixelRatio();this.setTransform(e,0,0,e,0,0)}this._applyLineCap(t);var i=t.hitStrokeWidth(),r="auto"===i?t.strokeWidth():i;this.setAttr("lineWidth",r),this.setAttr("strokeStyle",t.colorKey),t._strokeFuncHit(this),s||this.restore()}}},Object.defineProperty(dt,"__esModule",{value:!0}),dt.HitCanvas=dt.SceneCanvas=dt.Canvas=void 0;const ft=rt,vt=ct,yt=it,_t=at,wt=nt;var bt;class xt{constructor(t){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;var e=(t||{}).pixelRatio||yt.Konva.pixelRatio||function(){if(bt)return bt;var t=ft.Util.createCanvasElement(),e=t.getContext("2d");return bt=(yt.Konva._global.devicePixelRatio||1)/(e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1),ft.Util.releaseCanvas(t),bt}();this.pixelRatio=e,this._canvas=ft.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){var e=this.pixelRatio;this.pixelRatio=t,this.setSize(this.getWidth()/e,this.getHeight()/e)}setWidth(t){this.width=this._canvas.width=t*this.pixelRatio,this._canvas.style.width=t+"px";var e=this.pixelRatio;this.getContext()._context.scale(e,e)}setHeight(t){this.height=this._canvas.height=t*this.pixelRatio,this._canvas.style.height=t+"px";var e=this.pixelRatio;this.getContext()._context.scale(e,e)}getWidth(){return this.width}getHeight(){return this.height}setSize(t,e){this.setWidth(t||0),this.setHeight(e||0)}toDataURL(t,e){try{return this._canvas.toDataURL(t,e)}catch(t){try{return this._canvas.toDataURL()}catch(t){return ft.Util.error("Unable to get data URL. "+t.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}}dt.Canvas=xt,_t.Factory.addGetterSetter(xt,"pixelRatio",void 0,(0,wt.getNumberValidator)());dt.SceneCanvas=class extends xt{constructor(t={width:0,height:0,willReadFrequently:!1}){super(t),this.context=new vt.SceneContext(this,{willReadFrequently:t.willReadFrequently}),this.setSize(t.width,t.height)}};dt.HitCanvas=class extends xt{constructor(t={width:0,height:0}){super(t),this.hitCanvas=!0,this.context=new vt.HitContext(this),this.setSize(t.width,t.height)}};var St={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DD=void 0;const e=it,i=rt;t.DD={get isDragging(){var e=!1;return t.DD._dragElements.forEach((t=>{"dragging"===t.dragStatus&&(e=!0)})),e},justDragged:!1,get node(){var e;return t.DD._dragElements.forEach((t=>{e=t.node})),e},_dragElements:new Map,_drag(e){const r=[];t.DD._dragElements.forEach(((t,s)=>{const{node:a}=t,n=a.getStage();n.setPointersPositions(e),void 0===t.pointerId&&(t.pointerId=i.Util._getFirstPointerId(e));const o=n._changedPointerPositions.find((e=>e.id===t.pointerId));if(o){if("dragging"!==t.dragStatus){var h=a.dragDistance();if(Math.max(Math.abs(o.x-t.startPointerPos.x),Math.abs(o.y-t.startPointerPos.y))<h)return;if(a.startDrag({evt:e}),!a.isDragging())return}a._setDragPosition(e,t),r.push(a)}})),r.forEach((t=>{t.fire("dragmove",{type:"dragmove",target:t,evt:e},!0)}))},_endDragBefore(i){const r=[];t.DD._dragElements.forEach((s=>{const{node:a}=s,n=a.getStage();i&&n.setPointersPositions(i);if(!n._changedPointerPositions.find((t=>t.id===s.pointerId)))return;"dragging"!==s.dragStatus&&"stopped"!==s.dragStatus||(t.DD.justDragged=!0,e.Konva._mouseListenClick=!1,e.Konva._touchListenClick=!1,e.Konva._pointerListenClick=!1,s.dragStatus="stopped");const o=s.node.getLayer()||s.node instanceof e.Konva.Stage&&s.node;o&&-1===r.indexOf(o)&&r.push(o)})),r.forEach((t=>{t.draw()}))},_endDragAfter(e){t.DD._dragElements.forEach(((i,r)=>{"stopped"===i.dragStatus&&i.node.fire("dragend",{type:"dragend",target:i.node,evt:e},!0),"dragging"!==i.dragStatus&&t.DD._dragElements.delete(r)}))}},e.Konva.isBrowser&&(window.addEventListener("mouseup",t.DD._endDragBefore,!0),window.addEventListener("touchend",t.DD._endDragBefore,!0),window.addEventListener("mousemove",t.DD._drag),window.addEventListener("touchmove",t.DD._drag),window.addEventListener("mouseup",t.DD._endDragAfter,!1),window.addEventListener("touchend",t.DD._endDragAfter,!1))}(St),Object.defineProperty(st,"__esModule",{value:!0}),st.Node=void 0;const Ct=rt,Pt=at,kt=dt,Et=it,At=St,Tt=nt;var Mt="absoluteOpacity",Ft="allEventListeners",Dt="absoluteTransform",Ot="absoluteScale",Vt="canvas",Rt="listening",It="mouseenter",Lt="mouseleave",zt="Shape",Gt=" ",Nt="stage",Ut="transform",Wt="visible",jt=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(Gt);let Bt=1;class Ht{constructor(t){this._id=Bt++,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!==Ut&&t!==Dt||!this._cache.get(t)?t?this._cache.delete(t):this._cache.clear():this._cache.get(t).dirty=!0}_getCache(t,e){var i=this._cache.get(t);return(void 0===i||(t===Ut||t===Dt)&&!0===i.dirty)&&(i=e.call(this),this._cache.set(t,i)),i}_calculate(t,e,i){if(!this._attachedDepsListeners.get(t)){const i=e.map((t=>t+"Change.konva")).join(Gt);this.on(i,(()=>{this._clearCache(t)})),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,i)}_getCanvasCache(){return this._cache.get(Vt)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===Dt&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(Vt)){const{scene:t,filter:e,hit:i}=this._cache.get(Vt);Ct.Util.releaseCanvas(t,e,i),this._cache.delete(Vt)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(t){var e=t||{},i={};void 0!==e.x&&void 0!==e.y&&void 0!==e.width&&void 0!==e.height||(i=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));var r=Math.ceil(e.width||i.width),s=Math.ceil(e.height||i.height),a=e.pixelRatio,n=void 0===e.x?Math.floor(i.x):e.x,o=void 0===e.y?Math.floor(i.y):e.y,h=e.offset||0,l=e.drawBorder||!1,d=e.hitCanvasPixelRatio||1;if(!r||!s)return void Ct.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");r+=2*h+(Math.abs(Math.round(i.x)-n)>.5?1:0),s+=2*h+(Math.abs(Math.round(i.y)-o)>.5?1:0),n-=h,o-=h;var c=new kt.SceneCanvas({pixelRatio:a,width:r,height:s}),u=new kt.SceneCanvas({pixelRatio:a,width:0,height:0,willReadFrequently:!0}),g=new kt.HitCanvas({pixelRatio:d,width:r,height:s}),p=c.getContext(),m=g.getContext();return g.isCache=!0,c.isCache=!0,this._cache.delete(Vt),this._filterUpToDate=!1,!1===e.imageSmoothingEnabled&&(c.getContext()._context.imageSmoothingEnabled=!1,u.getContext()._context.imageSmoothingEnabled=!1),p.save(),m.save(),p.translate(-n,-o),m.translate(-n,-o),this._isUnderCache=!0,this._clearSelfAndDescendantCache(Mt),this._clearSelfAndDescendantCache(Ot),this.drawScene(c,this),this.drawHit(g,this),this._isUnderCache=!1,p.restore(),m.restore(),l&&(p.save(),p.beginPath(),p.rect(0,0,r,s),p.closePath(),p.setAttr("strokeStyle","red"),p.setAttr("lineWidth",5),p.stroke(),p.restore()),this._cache.set(Vt,{scene:c,filter:u,hit:g,x:n,y:o}),this._requestDraw(),this}isCached(){return this._cache.has(Vt)}getClientRect(t){throw new Error('abstract "getClientRect" method call')}_transformedRect(t,e){var i=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}],r=1/0,s=1/0,a=-1/0,n=-1/0,o=this.getAbsoluteTransform(e);return i.forEach((function(t){var e=o.point(t);void 0===r&&(r=a=e.x,s=n=e.y),r=Math.min(r,e.x),s=Math.min(s,e.y),a=Math.max(a,e.x),n=Math.max(n,e.y)})),{x:r,y:s,width:a-r,height:n-s}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const e=this._getCanvasCache();t.translate(e.x,e.y);var i=this._getCachedSceneCanvas(),r=i.pixelRatio;t.drawImage(i._canvas,0,0,i.width/r,i.height/r),t.restore()}_drawCachedHitCanvas(t){var e=this._getCanvasCache(),i=e.hit;t.save(),t.translate(e.x,e.y),t.drawImage(i._canvas,0,0,i.width/i.pixelRatio,i.height/i.pixelRatio),t.restore()}_getCachedSceneCanvas(){var t,e,i,r,s=this.filters(),a=this._getCanvasCache(),n=a.scene,o=a.filter,h=o.getContext();if(s){if(!this._filterUpToDate){var l=n.pixelRatio;o.setSize(n.width/n.pixelRatio,n.height/n.pixelRatio);try{for(t=s.length,h.clear(),h.drawImage(n._canvas,0,0,n.getWidth()/l,n.getHeight()/l),e=h.getImageData(0,0,o.getWidth(),o.getHeight()),i=0;i<t;i++)"function"==typeof(r=s[i])?(r.call(this,e),h.putImageData(e,0,0)):Ct.Util.error("Filter should be type of function, but got "+typeof r+" instead. Please check correct filters")}catch(t){Ct.Util.error("Unable to apply filter. "+t.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return o}return n}on(t,e){if(this._cache&&this._cache.delete(Ft),3===arguments.length)return this._delegate.apply(this,arguments);var i,r,s,a,n=t.split(Gt),o=n.length;for(i=0;i<o;i++)s=(r=n[i].split("."))[0],a=r[1]||"",this.eventListeners[s]||(this.eventListeners[s]=[]),this.eventListeners[s].push({name:a,handler:e});return this}off(t,e){var i,r,s,a,n,o=(t||"").split(Gt),h=o.length;if(this._cache&&this._cache.delete(Ft),!t)for(r in this.eventListeners)this._off(r);for(i=0;i<h;i++)if(a=(s=o[i].split("."))[0],n=s[1],a)this.eventListeners[a]&&this._off(a,n,e);else for(r in this.eventListeners)this._off(r,n,e);return this}dispatchEvent(t){var e={target:this,type:t.type,evt:t};return this.fire(t.type,e),this}addEventListener(t,e){return this.on(t,(function(t){e.call(this,t.evt)})),this}removeEventListener(t){return this.off(t),this}_delegate(t,e,i){var r=this;this.on(t,(function(t){for(var s=t.target.findAncestors(e,!0,r),a=0;a<s.length;a++)(t=Ct.Util.cloneObject(t)).currentTarget=s[a],i.call(s[a],t)}))}remove(){return this.isDragging()&&this.stopDrag(),At.DD._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(Dt),this._clearSelfAndDescendantCache(Mt),this._clearSelfAndDescendantCache(Ot),this._clearSelfAndDescendantCache(Nt),this._clearSelfAndDescendantCache(Wt),this._clearSelfAndDescendantCache(Rt)}_remove(){this._clearCaches();var 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){var e="get"+Ct.Util._capitalize(t);return Ct.Util._isFunction(this[e])?this[e]():this.attrs[t]}getAncestors(){for(var t=this.getParent(),e=[];t;)e.push(t),t=t.getParent();return e}getAttrs(){return this.attrs||{}}setAttrs(t){return this._batchTransformChanges((()=>{var e,i;if(!t)return this;for(e in t)"children"!==e&&(i="set"+Ct.Util._capitalize(e),Ct.Util._isFunction(this[i])?this[i](t[e]):this._setAttr(e,t[e]))})),this}isListening(){return this._getCache(Rt,this._isListening)}_isListening(t){if(!this.listening())return!1;const e=this.getParent();return!e||e===t||this===t||e._isListening(t)}isVisible(){return this._getCache(Wt,this._isVisible)}_isVisible(t){if(!this.visible())return!1;const e=this.getParent();return!e||e===t||this===t||e._isVisible(t)}shouldDrawHit(t,e=!1){if(t)return this._isVisible(t)&&this._isListening(t);var i=this.getLayer(),r=!1;At.DD._dragElements.forEach((t=>{"dragging"===t.dragStatus&&("Stage"===t.node.nodeType||t.node.getLayer()===i)&&(r=!0)}));var s=!e&&!Et.Konva.hitOnDragEnabled&&(r||Et.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(){var t,e,i,r,s=this.getDepth(),a=this,n=0;const o=this.getStage();return"Stage"!==a.nodeType&&o&&function o(h){for(t=[],e=h.length,i=0;i<e;i++)r=h[i],n++,r.nodeType!==zt&&(t=t.concat(r.getChildren().slice())),r._id===a._id&&(i=e);t.length>0&&t[0].getDepth()<=s&&o(t)}(o.getChildren()),n}getDepth(){for(var t=0,e=this.parent;e;)t++,e=e.parent;return t}_batchTransformChanges(t){this._batchingTransformChange=!0,t(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(Ut),this._clearSelfAndDescendantCache(Dt)),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;var e=t.getPointerPosition();if(!e)return null;var i=this.getAbsoluteTransform().copy();return i.invert(),i.point(e)}getAbsolutePosition(t){let e=!1,i=this.parent;for(;i;){if(i.isCached()){e=!0;break}i=i.parent}e&&!t&&(t=!0);var r=this.getAbsoluteTransform(t).getMatrix(),s=new Ct.Transform,a=this.offset();return s.m=r.slice(),s.translate(a.x,a.y),s.getTranslation()}setAbsolutePosition(t){const{x:e,y:i,...r}=this._clearTransform();this.attrs.x=e,this.attrs.y=i,this._clearCache(Ut);var 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(Ut),this._clearSelfAndDescendantCache(Dt),this}_setTransform(t){var e;for(e in t)this.attrs[e]=t[e]}_clearTransform(){var 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){var e=t.x,i=t.y,r=this.x(),s=this.y();return void 0!==e&&(r+=e),void 0!==i&&(s+=i),this.setPosition({x:r,y:s}),this}_eachAncestorReverse(t,e){var i,r,s=[],a=this.getParent();if(!e||e._id!==this._id){for(s.unshift(this);a&&(!e||a._id!==e._id);)s.unshift(a),a=a.parent;for(i=s.length,r=0;r<i;r++)t(s[r])}}rotate(t){return this.rotation(this.rotation()+t),this}moveToTop(){if(!this.parent)return Ct.Util.warn("Node has no parent. moveToTop function is ignored."),!1;var t=this.index;return t<this.parent.getChildren().length-1&&(this.parent.children.splice(t,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0)}moveUp(){if(!this.parent)return Ct.Util.warn("Node has no parent. moveUp function is ignored."),!1;var t=this.index;return t<this.parent.getChildren().length-1&&(this.parent.children.splice(t,1),this.parent.children.splice(t+1,0,this),this.parent._setChildrenIndices(),!0)}moveDown(){if(!this.parent)return Ct.Util.warn("Node has no parent. moveDown function is ignored."),!1;var t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.splice(t-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return Ct.Util.warn("Node has no parent. moveToBottom function is ignored."),!1;var t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(t){if(!this.parent)return Ct.Util.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&&Ct.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)+".");var e=this.index;return this.parent.children.splice(e,1),this.parent.children.splice(t,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(Mt,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){var t=this.opacity(),e=this.getParent();return e&&!e._isUnderCache&&(t*=e.getAbsoluteOpacity()),t}moveTo(t){return this.getParent()!==t&&(this._remove(),t.add(this)),this}toObject(){var t,e,i,r,s=this.getAttrs();const a={attrs:{},className:this.getClassName()};for(t in s)e=s[t],Ct.Util.isObject(e)&&!Ct.Util._isPlainObject(e)&&!Ct.Util._isArray(e)||(i="function"==typeof this[t]&&this[t],delete s[t],r=i?i.call(this):null,s[t]=e,r!==e&&(a.attrs[t]=e));return Ct.Util._prepareToStringify(a)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,e,i){var r=[];e&&this._isMatch(t)&&r.push(this);for(var s=this.parent;s;){if(s===i)return r;s._isMatch(t)&&r.push(s),s=s.parent}return r}isAncestorOf(t){return!1}findAncestor(t,e,i){return this.findAncestors(t,e,i)[0]}_isMatch(t){if(!t)return!1;if("function"==typeof t)return t(this);var e,i,r=t.replace(/ /g,"").split(","),s=r.length;for(e=0;e<s;e++)if(i=r[e],Ct.Util.isValidSelector(i)||(Ct.Util.warn('Selector "'+i+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),Ct.Util.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),Ct.Util.warn("Konva is awesome, right?")),"#"===i.charAt(0)){if(this.id()===i.slice(1))return!0}else if("."===i.charAt(0)){if(this.hasName(i.slice(1)))return!0}else if(this.className===i||this.nodeType===i)return!0;return!1}getLayer(){var t=this.getParent();return t?t.getLayer():null}getStage(){return this._getCache(Nt,this._getStage)}_getStage(){var t=this.getParent();return t?t.getStage():null}fire(t,e={},i){return e.target=e.target||this,i?this._fireAndBubble(t,e):this._fire(t,e),this}getAbsoluteTransform(t){return t?this._getAbsoluteTransform(t):this._getCache(Dt,this._getAbsoluteTransform)}_getAbsoluteTransform(t){var e;if(t)return e=new Ct.Transform,this._eachAncestorReverse((function(t){var i=t.transformsEnabled();"all"===i?e.multiply(t.getTransform()):"position"===i&&e.translate(t.x()-t.offsetX(),t.y()-t.offsetY())}),t),e;e=this._cache.get(Dt)||new Ct.Transform,this.parent?this.parent.getAbsoluteTransform().copyInto(e):e.reset();var i=this.transformsEnabled();if("all"===i)e.multiply(this.getTransform());else if("position"===i){const t=this.attrs.x||0,i=this.attrs.y||0,r=this.attrs.offsetX||0,s=this.attrs.offsetY||0;e.translate(t-r,i-s)}return e.dirty=!1,e}getAbsoluteScale(t){for(var e=this;e;)e._isUnderCache&&(t=e),e=e.getParent();const i=this.getAbsoluteTransform(t).decompose();return{x:i.scaleX,y:i.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(Ut,this._getTransform)}_getTransform(){var t,e,i=this._cache.get(Ut)||new Ct.Transform;i.reset();var r=this.x(),s=this.y(),a=Et.Konva.getAngle(this.rotation()),n=null!==(t=this.attrs.scaleX)&&void 0!==t?t:1,o=null!==(e=this.attrs.scaleY)&&void 0!==e?e:1,h=this.attrs.skewX||0,l=this.attrs.skewY||0,d=this.attrs.offsetX||0,c=this.attrs.offsetY||0;return 0===r&&0===s||i.translate(r,s),0!==a&&i.rotate(a),0===h&&0===l||i.skew(h,l),1===n&&1===o||i.scale(n,o),0===d&&0===c||i.translate(-1*d,-1*c),i.dirty=!1,i}clone(t){var e,i,r,s,a,n=Ct.Util.cloneObject(this.attrs);for(e in t)n[e]=t[e];var o=new this.constructor(n);for(e in this.eventListeners)for(r=(i=this.eventListeners[e]).length,s=0;s<r;s++)(a=i[s]).name.indexOf("konva")<0&&(o.eventListeners[e]||(o.eventListeners[e]=[]),o.eventListeners[e].push(a));return o}_toKonvaCanvas(t){t=t||{};var e=this.getClientRect(),i=this.getStage(),r=void 0!==t.x?t.x:Math.floor(e.x),s=void 0!==t.y?t.y:Math.floor(e.y),a=t.pixelRatio||1,n=new kt.SceneCanvas({width:t.width||Math.ceil(e.width)||(i?i.width():0),height:t.height||Math.ceil(e.height)||(i?i.height():0),pixelRatio:a}),o=n.getContext();const h=new kt.SceneCanvas({width:n.width/n.pixelRatio+Math.abs(r),height:n.height/n.pixelRatio+Math.abs(s),pixelRatio:n.pixelRatio});return!1===t.imageSmoothingEnabled&&(o._context.imageSmoothingEnabled=!1),o.save(),(r||s)&&o.translate(-1*r,-1*s),this.drawScene(n,void 0,h),o.restore(),n}toCanvas(t){return this._toKonvaCanvas(t)._canvas}toDataURL(t){var e=(t=t||{}).mimeType||null,i=t.quality||null,r=this._toKonvaCanvas(t).toDataURL(e,i);return t.callback&&t.callback(r),r}toImage(t){return new Promise(((e,i)=>{try{const i=null==t?void 0:t.callback;i&&delete t.callback,Ct.Util._urlToImage(this.toDataURL(t),(function(t){e(t),null==i||i(t)}))}catch(t){i(t)}}))}toBlob(t){return new Promise(((e,i)=>{try{const i=null==t?void 0:t.callback;i&&delete t.callback,this.toCanvas(t).toBlob((t=>{e(t),null==i||i(t)}),null==t?void 0:t.mimeType,null==t?void 0:t.quality)}catch(t){i(t)}}))}setSize(t){return this.width(t.width),this.height(t.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return void 0!==this.attrs.dragDistance?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():Et.Konva.dragDistance}_off(t,e,i){var r,s,a,n=this.eventListeners[t];for(r=0;r<n.length;r++)if(s=n[r].name,a=n[r].handler,!("konva"===s&&"konva"!==e||e&&s!==e||i&&i!==a)){if(n.splice(r,1),0===n.length){delete this.eventListeners[t];break}r--}}_fireChangeEvent(t,e,i){this._fire(t+"Change",{oldVal:e,newVal:i})}addName(t){if(!this.hasName(t)){var e=this.name(),i=e?e+" "+t:t;this.name(i)}return this}hasName(t){if(!t)return!1;const e=this.name();return!!e&&-1!==(e||"").split(/\s/g).indexOf(t)}removeName(t){var e=(this.name()||"").split(/\s/g),i=e.indexOf(t);return-1!==i&&(e.splice(i,1),this.name(e.join(" "))),this}setAttr(t,e){var i=this["set"+Ct.Util._capitalize(t)];return Ct.Util._isFunction(i)?i.call(this,e):this._setAttr(t,e),this}_requestDraw(){if(Et.Konva.autoDrawEnabled){const t=this.getLayer()||this.getStage();null==t||t.batchDraw()}}_setAttr(t,e){var i=this.attrs[t];(i!==e||Ct.Util.isObject(e))&&(null==e?delete this.attrs[t]:this.attrs[t]=e,this._shouldFireChangeEvents&&this._fireChangeEvent(t,i,e),this._requestDraw())}_setComponentAttr(t,e,i){var r;void 0!==i&&((r=this.attrs[t])||(this.attrs[t]=this.getAttr(t)),this.attrs[t][e]=i,this._fireChangeEvent(t,r,i))}_fireAndBubble(t,e,i){if(e&&this.nodeType===zt&&(e.target=this),!((t===It||t===Lt)&&(i&&(this===i||this.isAncestorOf&&this.isAncestorOf(i))||"Stage"===this.nodeType&&!i))){this._fire(t,e);var r=(t===It||t===Lt)&&i&&i.isAncestorOf&&i.isAncestorOf(this)&&!i.isAncestorOf(this.parent);(e&&!e.cancelBubble||!e)&&this.parent&&this.parent.isListening()&&!r&&(i&&i.parent?this._fireAndBubble.call(this.parent,t,e,i):this._fireAndBubble.call(this.parent,t,e))}}_getProtoListeners(t){var e,i,r;const s=null!==(e=this._cache.get(Ft))&&void 0!==e?e:{};let a=null==s?void 0:s[t];if(void 0===a){a=[];let e=Object.getPrototypeOf(this);for(;e;){const s=null!==(r=null===(i=e.eventListeners)||void 0===i?void 0:i[t])&&void 0!==r?r:[];a.push(...s),e=Object.getPrototypeOf(e)}s[t]=a,this._cache.set(Ft,s)}return a}_fire(t,e){(e=e||{}).currentTarget=this,e.type=t;const i=this._getProtoListeners(t);if(i)for(var r=0;r<i.length;r++)i[r].handler.call(this,e);const s=this.eventListeners[t];if(s)for(r=0;r<s.length;r++)s[r].handler.call(this,e)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(t){var e=t?t.pointerId:void 0,i=this.getStage(),r=this.getAbsolutePosition();if(i){var s=i._getPointerById(e)||i._changedPointerPositions[0]||r;At.DD._dragElements.set(this._id,{node:this,startPointerPos:s,offset:{x:s.x-r.x,y:s.y-r.y},dragStatus:"ready",pointerId:e})}}startDrag(t,e=!0){At.DD._dragElements.has(this._id)||this._createDragElement(t);At.DD._dragElements.get(this._id).dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:t&&t.evt},e)}_setDragPosition(t,e){const i=this.getStage()._getPointerById(e.pointerId);if(i){var r={x:i.x-e.offset.x,y:i.y-e.offset.y},s=this.dragBoundFunc();if(void 0!==s){const e=s.call(this,r,t);e?r=e:Ct.Util.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}this._lastPos&&this._lastPos.x===r.x&&this._lastPos.y===r.y||(this.setAbsolutePosition(r),this._requestDraw()),this._lastPos=r}}stopDrag(t){const e=At.DD._dragElements.get(this._id);e&&(e.dragStatus="stopped"),At.DD._endDragBefore(t),At.DD._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=At.DD._dragElements.get(this._id);return!!t&&"dragging"===t.dragStatus}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",(function(t){if((!(void 0!==t.evt.button)||Et.Konva.dragButtons.indexOf(t.evt.button)>=0)&&!this.isDragging()){var e=!1;At.DD._dragElements.forEach((t=>{this.isAncestorOf(t.node)&&(e=!0)})),e||this._createDragElement(t)}}))}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{if(this._dragCleanup(),!this.getStage())return;const t=At.DD._dragElements.get(this._id),e=t&&"dragging"===t.dragStatus,i=t&&"ready"===t.dragStatus;e?this.stopDrag():i&&At.DD._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(t={x:0,y:0}){const e=this.getStage();if(!e)return!1;const i={x:-t.x,y:-t.y,width:e.width()+2*t.x,height:e.height()+2*t.y};return Ct.Util.haveIntersection(i,this.getClientRect())}static create(t,e){return Ct.Util._isString(t)&&(t=JSON.parse(t)),this._createNode(t,e)}static _createNode(t,e){var i,r,s,a=Ht.prototype.getClassName.call(t),n=t.children;e&&(t.attrs.container=e),Et.Konva[a]||(Ct.Util.warn('Can not find a node with class name "'+a+'". Fallback to "Shape".'),a="Shape");if(i=new(0,Et.Konva[a])(t.attrs),n)for(r=n.length,s=0;s<r;s++)i.add(Ht._createNode(n[s]));return i}}st.Node=Ht,Ht.prototype.nodeType="Node",Ht.prototype._attrsAffectingSize=[],Ht.prototype.eventListeners={},Ht.prototype.on.call(Ht.prototype,jt,(function(){this._batchingTransformChange?this._needClearTransformCache=!0:(this._clearCache(Ut),this._clearSelfAndDescendantCache(Dt))})),Ht.prototype.on.call(Ht.prototype,"visibleChange.konva",(function(){this._clearSelfAndDescendantCache(Wt)})),Ht.prototype.on.call(Ht.prototype,"listeningChange.konva",(function(){this._clearSelfAndDescendantCache(Rt)})),Ht.prototype.on.call(Ht.prototype,"opacityChange.konva",(function(){this._clearSelfAndDescendantCache(Mt)}));const Kt=Pt.Factory.addGetterSetter;Kt(Ht,"zIndex"),Kt(Ht,"absolutePosition"),Kt(Ht,"position"),Kt(Ht,"x",0,(0,Tt.getNumberValidator)()),Kt(Ht,"y",0,(0,Tt.getNumberValidator)()),Kt(Ht,"globalCompositeOperation","source-over",(0,Tt.getStringValidator)()),Kt(Ht,"opacity",1,(0,Tt.getNumberValidator)()),Kt(Ht,"name","",(0,Tt.getStringValidator)()),Kt(Ht,"id","",(0,Tt.getStringValidator)()),Kt(Ht,"rotation",0,(0,Tt.getNumberValidator)()),Pt.Factory.addComponentsGetterSetter(Ht,"scale",["x","y"]),Kt(Ht,"scaleX",1,(0,Tt.getNumberValidator)()),Kt(Ht,"scaleY",1,(0,Tt.getNumberValidator)()),Pt.Factory.addComponentsGetterSetter(Ht,"skew",["x","y"]),Kt(Ht,"skewX",0,(0,Tt.getNumberValidator)()),Kt(Ht,"skewY",0,(0,Tt.getNumberValidator)()),Pt.Factory.addComponentsGetterSetter(Ht,"offset",["x","y"]),Kt(Ht,"offsetX",0,(0,Tt.getNumberValidator)()),Kt(Ht,"offsetY",0,(0,Tt.getNumberValidator)()),Kt(Ht,"dragDistance",null,(0,Tt.getNumberValidator)()),Kt(Ht,"width",0,(0,Tt.getNumberValidator)()),Kt(Ht,"height",0,(0,Tt.getNumberValidator)()),Kt(Ht,"listening",!0,(0,Tt.getBooleanValidator)()),Kt(Ht,"preventDefault",!0,(0,Tt.getBooleanValidator)()),Kt(Ht,"filters",null,(function(t){return this._filterUpToDate=!1,t})),Kt(Ht,"visible",!0,(0,Tt.getBooleanValidator)()),Kt(Ht,"transformsEnabled","all",(0,Tt.getStringValidator)()),Kt(Ht,"size"),Kt(Ht,"dragBoundFunc"),Kt(Ht,"draggable",!1,(0,Tt.getBooleanValidator)()),Pt.Factory.backCompat(Ht,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});var Yt={};Object.defineProperty(Yt,"__esModule",{value:!0}),Yt.Container=void 0;const Xt=at,Jt=st,qt=nt;class Zt extends Jt.Node{constructor(){super(...arguments),this.children=[]}getChildren(t){if(!t)return this.children||[];const e=this.children||[];var i=[];return e.forEach((function(e){t(e)&&i.push(e)})),i}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach((t=>{t.parent=null,t.index=0,t.remove()})),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach((t=>{t.parent=null,t.index=0,t.destroy()})),this.children=[],this._requestDraw(),this}add(...t){if(0===t.length)return this;if(t.length>1){for(var e=0;e<t.length;e++)this.add(t[e]);return this}const i=t[0];return i.getParent()?(i.moveTo(this),this):(this._validateAdd(i),i.index=this.getChildren().length,i.parent=this,i._clearCaches(),this.getChildren().push(i),this._fire("add",{child:i}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(t){return this._generalFind(t,!1)}findOne(t){var e=this._generalFind(t,!0);return e.length>0?e[0]:void 0}_generalFind(t,e){var i=[];return this._descendants((r=>{const s=r._isMatch(t);return s&&i.push(r),!(!s||!e)})),i}_descendants(t){let e=!1;const i=this.getChildren();for(const r of i){if(e=t(r),e)return!0;if(r.hasChildren()&&(e=r._descendants(t),e))return!0}return!1}toObject(){var t=Jt.Node.prototype.toObject.call(this);return t.children=[],this.getChildren().forEach((e=>{t.children.push(e.toObject())})),t}isAncestorOf(t){for(var e=t.getParent();e;){if(e._id===this._id)return!0;e=e.getParent()}return!1}clone(t){var e=Jt.Node.prototype.clone.call(this,t);return this.getChildren().forEach((function(t){e.add(t.clone())})),e}getAllIntersections(t){var e=[];return this.find("Shape").forEach((i=>{i.isVisible()&&i.intersects(t)&&e.push(i)})),e}_clearSelfAndDescendantCache(t){var e;super._clearSelfAndDescendantCache(t),this.isCached()||null===(e=this.children)||void 0===e||e.forEach((function(e){e._clearSelfAndDescendantCache(t)}))}_setChildrenIndices(){var t;null===(t=this.children)||void 0===t||t.forEach((function(t,e){t.index=e})),this._requestDraw()}drawScene(t,e,i){var r=this.getLayer(),s=t||r&&r.getCanvas(),a=s&&s.getContext(),n=this._getCanvasCache(),o=n&&n.scene,h=s&&s.isCache;if(!this.isVisible()&&!h)return this;if(o){a.save();var l=this.getAbsoluteTransform(e).getMatrix();a.transform(l[0],l[1],l[2],l[3],l[4],l[5]),this._drawCachedSceneCanvas(a),a.restore()}else this._drawChildren("drawScene",s,e,i);return this}drawHit(t,e){if(!this.shouldDrawHit(e))return this;var i=this.getLayer(),r=t||i&&i.hitCanvas,s=r&&r.getContext(),a=this._getCanvasCache();if(a&&a.hit){s.save();var n=this.getAbsoluteTransform(e).getMatrix();s.transform(n[0],n[1],n[2],n[3],n[4],n[5]),this._drawCachedHitCanvas(s),s.restore()}else this._drawChildren("drawHit",r,e);return this}_drawChildren(t,e,i,r){var s,a=e&&e.getContext(),n=this.clipWidth(),o=this.clipHeight(),h=this.clipFunc(),l="number"==typeof n&&"number"==typeof o||h;const d=i===this;if(l){a.save();var c=this.getAbsoluteTransform(i),u=c.getMatrix();let t;if(a.transform(u[0],u[1],u[2],u[3],u[4],u[5]),a.beginPath(),h)t=h.call(this,a,this);else{var g=this.clipX(),p=this.clipY();a.rect(g||0,p||0,n,o)}a.clip.apply(a,t),u=c.copy().invert().getMatrix(),a.transform(u[0],u[1],u[2],u[3],u[4],u[5])}var m=!d&&"source-over"!==this.globalCompositeOperation()&&"drawScene"===t;m&&(a.save(),a._applyGlobalCompositeOperation(this)),null===(s=this.children)||void 0===s||s.forEach((function(s){s[t](e,i,r)})),m&&a.restore(),l&&a.restore()}getClientRect(t={}){var e,i,r,s,a,n=t.skipTransform,o=t.relativeTo,h={x:1/0,y:1/0,width:0,height:0},l=this;null===(e=this.children)||void 0===e||e.forEach((function(e){if(e.visible()){var n=e.getClientRect({relativeTo:l,skipShadow:t.skipShadow,skipStroke:t.skipStroke});0===n.width&&0===n.height||(void 0===i?(i=n.x,r=n.y,s=n.x+n.width,a=n.y+n.height):(i=Math.min(i,n.x),r=Math.min(r,n.y),s=Math.max(s,n.x+n.width),a=Math.max(a,n.y+n.height)))}}));for(var d=this.find("Shape"),c=!1,u=0;u<d.length;u++){if(d[u]._isVisible(this)){c=!0;break}}return h=c&&void 0!==i?{x:i,y:r,width:s-i,height:a-r}:{x:0,y:0,width:0,height:0},n?h:this._transformedRect(h,o)}}Yt.Container=Zt,Xt.Factory.addComponentsGetterSetter(Zt,"clip",["x","y","width","height"]),Xt.Factory.addGetterSetter(Zt,"clipX",void 0,(0,qt.getNumberValidator)()),Xt.Factory.addGetterSetter(Zt,"clipY",void 0,(0,qt.getNumberValidator)()),Xt.Factory.addGetterSetter(Zt,"clipWidth",void 0,(0,qt.getNumberValidator)()),Xt.Factory.addGetterSetter(Zt,"clipHeight",void 0,(0,qt.getNumberValidator)()),Xt.Factory.addGetterSetter(Zt,"clipFunc");var $t={},Qt={};Object.defineProperty(Qt,"__esModule",{value:!0}),Qt.releaseCapture=Qt.setPointerCapture=Qt.hasPointerCapture=Qt.createEvent=Qt.getCapturedShape=void 0;const te=it,ee=new Map,ie=void 0!==te.Konva._global.PointerEvent;function re(t){return{evt:t,pointerId:t.pointerId}}function se(t,e){const i=ee.get(t);if(!i)return;const r=i.getStage();r&&r.content,ee.delete(t),ie&&i._fire("lostpointercapture",re(new PointerEvent("lostpointercapture")))}Qt.getCapturedShape=function(t){return ee.get(t)},Qt.createEvent=re,Qt.hasPointerCapture=function(t,e){return ee.get(t)===e},Qt.setPointerCapture=function(t,e){se(t),e.getStage()&&(ee.set(t,e),ie&&e._fire("gotpointercapture",re(new PointerEvent("gotpointercapture"))))},Qt.releaseCapture=se,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Stage=t.stages=void 0;const e=rt,i=at,r=Yt,s=it,a=dt,n=St,o=it,h=Qt;var l="mouseleave",d="mouseover",c="mouseenter",u="mousemove",g="mousedown",p="mouseup",m="pointermove",f="pointerdown",v="pointerup",y="pointercancel",_="pointerout",w="pointerleave",b="pointerover",x="pointerenter",S="contextmenu",C="touchstart",P="touchend",k="touchmove",E="touchcancel",A="wheel",T=[[c,"_pointerenter"],[g,"_pointerdown"],[u,"_pointermove"],[p,"_pointerup"],[l,"_pointerleave"],[C,"_pointerdown"],[k,"_pointermove"],[P,"_pointerup"],[E,"_pointercancel"],[d,"_pointerover"],[A,"_wheel"],[S,"_contextmenu"],[f,"_pointerdown"],[m,"_pointermove"],[v,"_pointerup"],[y,"_pointercancel"],["lostpointercapture","_lostpointercapture"]];const M={mouse:{[_]:"mouseout",[w]:l,[b]:d,[x]:c,[m]:u,[f]:g,[v]:p,[y]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[_]:"touchout",[w]:"touchleave",[b]:"touchover",[x]:"touchenter",[m]:k,[f]:C,[v]:P,[y]:E,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[_]:_,[w]:w,[b]:b,[x]:x,[m]:m,[f]:f,[v]:v,[y]:y,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},F=t=>t.indexOf("pointer")>=0?"pointer":t.indexOf("touch")>=0?"touch":"mouse",D=t=>{const e=F(t);return"pointer"===e?s.Konva.pointerEventsEnabled&&M.pointer:"touch"===e?M.touch:"mouse"===e?M.mouse:void 0};function O(t={}){return(t.clipFunc||t.clipWidth||t.clipHeight)&&e.Util.warn("Stage does not support clipping. Please use clip for Layers or Groups."),t}t.stages=[];class V extends r.Container{constructor(e){super(O(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),t.stages.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",(()=>{O(this.attrs)})),this._checkVisibility()}_validateAdd(t){const i="Layer"===t.getType(),r="FastLayer"===t.getType();i||r||e.Util.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const t=this.visible()?"":"none";this.content.style.display=t}setContainer(t){if("string"==typeof t){if("."===t.charAt(0)){var e=t.slice(1);t=document.getElementsByClassName(e)[0]}else{var i;i="#"!==t.charAt(0)?t:t.slice(1),t=document.getElementById(i)}if(!t)throw"Can not find container in document with id "+i}return this._setAttr("container",t),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),t.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){var t,e=this.children,i=e.length;for(t=0;t<i;t++)e[t].clear();return this}clone(t){return t||(t={}),t.container="undefined"!=typeof document&&document.createElement("div"),r.Container.prototype.clone.call(this,t)}destroy(){super.destroy();var i=this.content;i&&e.Util._isInDocument(i)&&this.container().removeChild(i);var r=t.stages.indexOf(this);return r>-1&&t.stages.splice(r,1),e.Util.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const t=this._pointerPositions[0]||this._changedPointerPositions[0];return t?{x:t.x,y:t.y}:(e.Util.warn("Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);"),null)}_getPointerById(t){return this._pointerPositions.find((e=>e.id===t))}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(t){(t=t||{}).x=t.x||0,t.y=t.y||0,t.width=t.width||this.width(),t.height=t.height||this.height();var e=new a.SceneCanvas({width:t.width,height:t.height,pixelRatio:t.pixelRatio||1}),i=e.getContext()._context,r=this.children;return(t.x||t.y)&&i.translate(-1*t.x,-1*t.y),r.forEach((function(e){if(e.isVisible()){var r=e._toKonvaCanvas(t);i.drawImage(r._canvas,t.x,t.y,r.getWidth()/r.getPixelRatio(),r.getHeight()/r.getPixelRatio())}})),e}getIntersection(t){if(!t)return null;var e,i=this.children;for(e=i.length-1;e>=0;e--){const r=i[e].getIntersection(t);if(r)return r}return null}_resizeDOM(){var t=this.width(),e=this.height();this.content&&(this.content.style.width=t+"px",this.content.style.height=e+"px"),this.bufferCanvas.setSize(t,e),this.bufferHitCanvas.setSize(t,e),this.children.forEach((i=>{i.setSize({width:t,height:e}),i.draw()}))}add(t,...i){if(arguments.length>1){for(var r=0;r<arguments.length;r++)this.add(arguments[r]);return this}super.add(t);var a=this.children.length;return a>5&&e.Util.warn("The stage has "+a+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),t.setSize({width:this.width(),height:this.height()}),t.draw(),s.Konva.isBrowser&&this.content.appendChild(t.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(t){return h.hasPointerCapture(t,this)}setPointerCapture(t){h.setPointerCapture(t,this)}releaseCapture(t){h.releaseCapture(t,this)}getLayers(){return this.children}_bindContentEvents(){s.Konva.isBrowser&&T.forEach((([t,e])=>{this.content.addEventListener(t,(t=>{this[e](t)}),{passive:!1})}))}_pointerenter(t){this.setPointersPositions(t);const e=D(t.type);e&&this._fire(e.pointerenter,{evt:t,target:this,currentTarget:this})}_pointerover(t){this.setPointersPositions(t);const e=D(t.type);e&&this._fire(e.pointerover,{evt:t,target:this,currentTarget:this})}_getTargetShape(t){let e=this[t+"targetShape"];return e&&!e.getStage()&&(e=null),e}_pointerleave(t){const e=D(t.type),i=F(t.type);if(e){this.setPointersPositions(t);var r=this._getTargetShape(i),a=!(s.Konva.isDragging()||s.Konva.isTransforming())||s.Konva.hitOnDragEnabled;r&&a?(r._fireAndBubble(e.pointerout,{evt:t}),r._fireAndBubble(e.pointerleave,{evt:t}),this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this[i+"targetShape"]=null):a&&(this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this._fire(e.pointerout,{evt:t,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}}_pointerdown(t){const e=D(t.type),i=F(t.type);if(e){this.setPointersPositions(t);var r=!1;this._changedPointerPositions.forEach((a=>{var o=this.getIntersection(a);if(n.DD.justDragged=!1,s.Konva["_"+i+"ListenClick"]=!0,!o||!o.isListening())return;s.Konva.capturePointerEventsEnabled&&o.setPointerCapture(a.id),this[i+"ClickStartShape"]=o,o._fireAndBubble(e.pointerdown,{evt:t,pointerId:a.id}),r=!0;const h=t.type.indexOf("touch")>=0;o.preventDefault()&&t.cancelable&&h&&t.preventDefault()})),r||this._fire(e.pointerdown,{evt:t,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}}_pointermove(t){const e=D(t.type),i=F(t.type);if(!e)return;if(s.Konva.isDragging()&&n.DD.node.preventDefault()&&t.cancelable&&t.preventDefault(),this.setPointersPositions(t),!(!(s.Konva.isDragging()||s.Konva.isTransforming())||s.Konva.hitOnDragEnabled))return;var r={};let a=!1;var o=this._getTargetShape(i);this._changedPointerPositions.forEach((s=>{const n=h.getCapturedShape(s.id)||this.getIntersection(s),l=s.id,d={evt:t,pointerId:l};var c=o!==n;if(c&&o&&(o._fireAndBubble(e.pointerout,{...d},n),o._fireAndBubble(e.pointerleave,{...d},n)),n){if(r[n._id])return;r[n._id]=!0}n&&n.isListening()?(a=!0,c&&(n._fireAndBubble(e.pointerover,{...d},o),n._fireAndBubble(e.pointerenter,{...d},o),this[i+"targetShape"]=n),n._fireAndBubble(e.pointermove,{...d})):o&&(this._fire(e.pointerover,{evt:t,target:this,currentTarget:this,pointerId:l}),this[i+"targetShape"]=null)})),a||this._fire(e.pointermove,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(t){const e=D(t.type),i=F(t.type);if(!e)return;this.setPointersPositions(t);const r=this[i+"ClickStartShape"],a=this[i+"ClickEndShape"];var o={};let l=!1;this._changedPointerPositions.forEach((d=>{const c=h.getCapturedShape(d.id)||this.getIntersection(d);if(c){if(c.releaseCapture(d.id),o[c._id])return;o[c._id]=!0}const u=d.id,g={evt:t,pointerId:u};let p=!1;s.Konva["_"+i+"InDblClickWindow"]?(p=!0,clearTimeout(this[i+"DblTimeout"])):n.DD.justDragged||(s.Konva["_"+i+"InDblClickWindow"]=!0,clearTimeout(this[i+"DblTimeout"])),this[i+"DblTimeout"]=setTimeout((function(){s.Konva["_"+i+"InDblClickWindow"]=!1}),s.Konva.dblClickWindow),c&&c.isListening()?(l=!0,this[i+"ClickEndShape"]=c,c._fireAndBubble(e.pointerup,{...g}),s.Konva["_"+i+"ListenClick"]&&r&&r===c&&(c._fireAndBubble(e.pointerclick,{...g}),p&&a&&a===c&&c._fireAndBubble(e.pointerdblclick,{...g}))):(this[i+"ClickEndShape"]=null,s.Konva["_"+i+"ListenClick"]&&this._fire(e.pointerclick,{evt:t,target:this,currentTarget:this,pointerId:u}),p&&this._fire(e.pointerdblclick,{evt:t,target:this,currentTarget:this,pointerId:u}))})),l||this._fire(e.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),s.Konva["_"+i+"ListenClick"]=!1,t.cancelable&&"touch"!==i&&t.preventDefault()}_contextmenu(t){this.setPointersPositions(t);var e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(S,{evt:t}):this._fire(S,{evt:t,target:this,currentTarget:this})}_wheel(t){this.setPointersPositions(t);var e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(A,{evt:t}):this._fire(A,{evt:t,target:this,currentTarget:this})}_pointercancel(t){this.setPointersPositions(t);const e=h.getCapturedShape(t.pointerId)||this.getIntersection(this.getPointerPosition());e&&e._fireAndBubble(v,h.createEvent(t)),h.releaseCapture(t.pointerId)}_lostpointercapture(t){h.releaseCapture(t.pointerId)}setPointersPositions(t){var i=this._getContentPosition(),r=null,s=null;void 0!==(t=t||window.event).touches?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(t.touches,(t=>{this._pointerPositions.push({id:t.identifier,x:(t.clientX-i.left)/i.scaleX,y:(t.clientY-i.top)/i.scaleY})})),Array.prototype.forEach.call(t.changedTouches||t.touches,(t=>{this._changedPointerPositions.push({id:t.identifier,x:(t.clientX-i.left)/i.scaleX,y:(t.clientY-i.top)/i.scaleY})}))):(r=(t.clientX-i.left)/i.scaleX,s=(t.clientY-i.top)/i.scaleY,this.pointerPos={x:r,y:s},this._pointerPositions=[{x:r,y:s,id:e.Util._getFirstPointerId(t)}],this._changedPointerPositions=[{x:r,y:s,id:e.Util._getFirstPointerId(t)}])}_setPointerPosition(t){e.Util.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(t)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};var t=this.content.getBoundingClientRect();return{top:t.top,left:t.left,scaleX:t.width/this.content.clientWidth||1,scaleY:t.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new a.SceneCanvas({width:this.width(),height:this.height()}),this.bufferHitCanvas=new a.HitCanvas({pixelRatio:1,width:this.width(),height:this.height()}),s.Konva.isBrowser){var t=this.container();if(!t)throw"Stage has no container. A container is required.";t.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),t.appendChild(this.content),this._resizeDOM()}}cache(){return e.Util.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach((function(t){t.batchDraw()})),this}}t.Stage=V,V.prototype.nodeType="Stage",(0,o._registerNode)(V),i.Factory.addGetterSetter(V,"container")}($t);var ae={},ne={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Shape=t.shapes=void 0;const e=it,i=rt,r=at,s=st,a=nt,n=it,o=Qt;var h="hasShadow",l="shadowRGBA",d="patternImage",c="linearGradient",u="radialGradient";let g;function p(){return g||(g=i.Util.createCanvasElement().getContext("2d"),g)}t.shapes={};class m extends s.Node{constructor(e){let r;for(super(e);r=i.Util.getRandomColor(),!r||r in t.shapes;);this.colorKey=r,t.shapes[r]=this}getContext(){return i.Util.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return i.Util.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(h,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&0!==this.shadowOpacity()&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(d,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const t=p().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){const r=new i.Transform;r.translate(this.fillPatternX(),this.fillPatternY()),r.rotate(e.Konva.getAngle(this.fillPatternRotation())),r.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),r.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const s=r.getMatrix(),a="undefined"==typeof DOMMatrix?{a:s[0],b:s[1],c:s[2],d:s[3],e:s[4],f:s[5]}:new DOMMatrix(s);t.setTransform(a)}return t}}_getLinearGradient(){return this._getCache(c,this.__getLinearGradient)}__getLinearGradient(){var t=this.fillLinearGradientColorStops();if(t){for(var e=p(),i=this.fillLinearGradientStartPoint(),r=this.fillLinearGradientEndPoint(),s=e.createLinearGradient(i.x,i.y,r.x,r.y),a=0;a<t.length;a+=2)s.addColorStop(t[a],t[a+1]);return s}}_getRadialGradient(){return this._getCache(u,this.__getRadialGradient)}__getRadialGradient(){var t=this.fillRadialGradientColorStops();if(t){for(var e=p(),i=this.fillRadialGradientStartPoint(),r=this.fillRadialGradientEndPoint(),s=e.createRadialGradient(i.x,i.y,this.fillRadialGradientStartRadius(),r.x,r.y,this.fillRadialGradientEndRadius()),a=0;a<t.length;a+=2)s.addColorStop(t[a],t[a+1]);return s}}getShadowRGBA(){return this._getCache(l,this._getShadowRGBA)}_getShadowRGBA(){if(this.hasShadow()){var t=i.Util.colorToRGBA(this.shadowColor());return t?"rgba("+t.r+","+t.g+","+t.b+","+t.a*(this.shadowOpacity()||1)+")":void 0}}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],(()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops())))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],(()=>this.strokeEnabled()&&this.strokeWidth()&&!(!this.stroke()&&!this.strokeLinearGradientColorStops())))}hasHitStroke(){const t=this.hitStrokeWidth();return"auto"===t?this.hasStroke():this.strokeEnabled()&&!!t}intersects(t){var e=this.getStage();if(!e)return!1;const i=e.bufferHitCanvas;i.getContext().clear(),this.drawHit(i,void 0,!0);return i.context.getImageData(Math.round(t.x),Math.round(t.y),1,1).data[3]>0}destroy(){return s.Node.prototype.destroy.call(this),delete t.shapes[this.colorKey],delete this.colorKey,this}_useBufferCanvas(t){var e;if(!(null===(e=this.attrs.perfectDrawEnabled)||void 0===e||e))return!1;const i=t||this.hasFill(),r=this.hasStroke(),s=1!==this.getAbsoluteOpacity();if(i&&r&&s)return!0;const a=this.hasShadow(),n=this.shadowForStrokeEnabled();return!!(i&&r&&a&&n)}setStrokeHitEnabled(t){i.Util.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),t?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return 0!==this.hitStrokeWidth()}getSelfRect(){var t=this.size();return{x:this._centroid?-t.width/2:0,y:this._centroid?-t.height/2:0,width:t.width,height:t.height}}getClientRect(t={}){const e=t.skipTransform,i=t.relativeTo,r=this.getSelfRect(),s=!t.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,a=r.width+s,n=r.height+s,o=!t.skipShadow&&this.hasShadow(),h=o?this.shadowOffsetX():0,l=o?this.shadowOffsetY():0,d=a+Math.abs(h),c=n+Math.abs(l),u=o&&this.shadowBlur()||0,g={width:d+2*u,height:c+2*u,x:-(s/2+u)+Math.min(h,0)+r.x,y:-(s/2+u)+Math.min(l,0)+r.y};return e?g:this._transformedRect(g,i)}drawScene(t,e,i){var r,s,a=this.getLayer(),n=t||a.getCanvas(),o=n.getContext(),h=this._getCanvasCache(),l=this.getSceneFunc(),d=this.hasShadow(),c=n.isCache,u=e===this;if(!this.isVisible()&&!u)return this;if(h){o.save();var g=this.getAbsoluteTransform(e).getMatrix();return o.transform(g[0],g[1],g[2],g[3],g[4],g[5]),this._drawCachedSceneCanvas(o),o.restore(),this}if(!l)return this;if(o.save(),this._useBufferCanvas()&&!c){r=this.getStage();const t=i||r.bufferCanvas;(s=t.getContext()).clear(),s.save(),s._applyLineJoin(this);var p=this.getAbsoluteTransform(e).getMatrix();s.transform(p[0],p[1],p[2],p[3],p[4],p[5]),l.call(this,s,this),s.restore();var m=t.pixelRatio;d&&o._applyShadow(this),o._applyOpacity(this),o._applyGlobalCompositeOperation(this),o.drawImage(t._canvas,0,0,t.width/m,t.height/m)}else{if(o._applyLineJoin(this),!u){p=this.getAbsoluteTransform(e).getMatrix();o.transform(p[0],p[1],p[2],p[3],p[4],p[5]),o._applyOpacity(this),o._applyGlobalCompositeOperation(this)}d&&o._applyShadow(this),l.call(this,o,this)}return o.restore(),this}drawHit(t,e,r=!1){if(!this.shouldDrawHit(e,r))return this;var s=this.getLayer(),a=t||s.hitCanvas,n=a&&a.getContext(),o=this.hitFunc()||this.sceneFunc(),h=this._getCanvasCache(),l=h&&h.hit;if(this.colorKey||i.Util.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),l){n.save();var d=this.getAbsoluteTransform(e).getMatrix();return n.transform(d[0],d[1],d[2],d[3],d[4],d[5]),this._drawCachedHitCanvas(n),n.restore(),this}if(!o)return this;n.save(),n._applyLineJoin(this);if(!(this===e)){var c=this.getAbsoluteTransform(e).getMatrix();n.transform(c[0],c[1],c[2],c[3],c[4],c[5])}return o.call(this,n,this),n.restore(),this}drawHitFromCache(t=0){var e,r,s,a,n,o=this._getCanvasCache(),h=this._getCachedSceneCanvas(),l=o.hit,d=l.getContext(),c=l.getWidth(),u=l.getHeight();d.clear(),d.drawImage(h._canvas,0,0,c,u);try{for(s=(r=(e=d.getImageData(0,0,c,u)).data).length,a=i.Util._hexToRgb(this.colorKey),n=0;n<s;n+=4)r[n+3]>t?(r[n]=a.r,r[n+1]=a.g,r[n+2]=a.b,r[n+3]=255):r[n+3]=0;d.putImageData(e,0,0)}catch(t){i.Util.error("Unable to draw hit graph from cached scene canvas. "+t.message)}return this}hasPointerCapture(t){return o.hasPointerCapture(t,this)}setPointerCapture(t){o.setPointerCapture(t,this)}releaseCapture(t){o.releaseCapture(t,this)}}t.Shape=m,m.prototype._fillFunc=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},m.prototype._strokeFunc=function(t){t.stroke()},m.prototype._fillFuncHit=function(t){t.fill()},m.prototype._strokeFuncHit=function(t){t.stroke()},m.prototype._centroid=!1,m.prototype.nodeType="Shape",(0,n._registerNode)(m),m.prototype.eventListeners={},m.prototype.on.call(m.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(h)})),m.prototype.on.call(m.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(l)})),m.prototype.on.call(m.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",(function(){this._clearCache(d)})),m.prototype.on.call(m.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",(function(){this._clearCache(c)})),m.prototype.on.call(m.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",(function(){this._clearCache(u)})),r.Factory.addGetterSetter(m,"stroke",void 0,(0,a.getStringOrGradientValidator)()),r.Factory.addGetterSetter(m,"strokeWidth",2,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(m,"fillAfterStrokeEnabled",!1),r.Factory.addGetterSetter(m,"hitStrokeWidth","auto",(0,a.getNumberOrAutoValidator)()),r.Factory.addGetterSetter(m,"strokeHitEnabled",!0,(0,a.getBooleanValidator)()),r.Factory.addGetterSetter(m,"perfectDrawEnabled",!0,(0,a.getBooleanValidator)()),r.Factory.addGetterSetter(m,"shadowForStrokeEnabled",!0,(0,a.getBooleanValidator)()),r.Factory.addGetterSetter(m,"lineJoin"),r.Factory.addGetterSetter(m,"lineCap"),r.Factory.addGetterSetter(m,"sceneFunc"),r.Factory.addGetterSetter(m,"hitFunc"),r.Factory.addGetterSetter(m,"dash"),r.Factory.addGetterSetter(m,"dashOffset",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(m,"shadowColor",void 0,(0,a.getStringValidator)()),r.Factory.addGetterSetter(m,"shadowBlur",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(m,"shadowOpacity",1,(0,a.getNumberValidator)()),r.Factory.addComponentsGetterSetter(m,"shadowOffset",["x","y"]),r.Factory.addGetterSetter(m,"shadowOffsetX",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(m,"shadowOffsetY",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(m,"fillPatternImage"),r.Factory.addGetterSetter(m,"fill",void 0,(0,a.getStringOrGradientValidator)()),r.Factory.addGetterSetter(m,"fillPatternX",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(m,"fillPatternY",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(m,"fillLinearGradientColorStops"),r.Factory.addGetterSetter(m,"strokeLinearGradientColorStops"),r.Factory.addGetterSetter(m,"fillRadialGradientStartRadius",0),r.Factory.addGetterSetter(m,"fillRadialGradientEndRadius",0),r.Factory.addGetterSetter(m,"fillRadialGradientColorStops"),r.Factory.addGetterSetter(m,"fillPatternRepeat","repeat"),r.Factory.addGetterSetter(m,"fillEnabled",!0),r.Factory.addGetterSetter(m,"strokeEnabled",!0),r.Factory.addGetterSetter(m,"shadowEnabled",!0),r.Factory.addGetterSetter(m,"dashEnabled",!0),r.Factory.addGetterSetter(m,"strokeScaleEnabled",!0),r.Factory.addGetterSetter(m,"fillPriority","color"),r.Factory.addComponentsGetterSetter(m,"fillPatternOffset",["x","y"]),r.Factory.addGetterSetter(m,"fillPatternOffsetX",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(m,"fillPatternOffsetY",0,(0,a.getNumberValidator)()),r.Factory.addComponentsGetterSetter(m,"fillPatternScale",["x","y"]),r.Factory.addGetterSetter(m,"fillPatternScaleX",1,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(m,"fillPatternScaleY",1,(0,a.getNumberValidator)()),r.Factory.addComponentsGetterSetter(m,"fillLinearGradientStartPoint",["x","y"]),r.Factory.addComponentsGetterSetter(m,"strokeLinearGradientStartPoint",["x","y"]),r.Factory.addGetterSetter(m,"fillLinearGradientStartPointX",0),r.Factory.addGetterSetter(m,"strokeLinearGradientStartPointX",0),r.Factory.addGetterSetter(m,"fillLinearGradientStartPointY",0),r.Factory.addGetterSetter(m,"strokeLinearGradientStartPointY",0),r.Factory.addComponentsGetterSetter(m,"fillLinearGradientEndPoint",["x","y"]),r.Factory.addComponentsGetterSetter(m,"strokeLinearGradientEndPoint",["x","y"]),r.Factory.addGetterSetter(m,"fillLinearGradientEndPointX",0),r.Factory.addGetterSetter(m,"strokeLinearGradientEndPointX",0),r.Factory.addGetterSetter(m,"fillLinearGradientEndPointY",0),r.Factory.addGetterSetter(m,"strokeLinearGradientEndPointY",0),r.Factory.addComponentsGetterSetter(m,"fillRadialGradientStartPoint",["x","y"]),r.Factory.addGetterSetter(m,"fillRadialGradientStartPointX",0),r.Factory.addGetterSetter(m,"fillRadialGradientStartPointY",0),r.Factory.addComponentsGetterSetter(m,"fillRadialGradientEndPoint",["x","y"]),r.Factory.addGetterSetter(m,"fillRadialGradientEndPointX",0),r.Factory.addGetterSetter(m,"fillRadialGradientEndPointY",0),r.Factory.addGetterSetter(m,"fillPatternRotation",0),r.Factory.addGetterSetter(m,"fillRule",void 0,(0,a.getStringValidator)()),r.Factory.backCompat(m,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"})}(ne),Object.defineProperty(ae,"__esModule",{value:!0}),ae.Layer=void 0;const oe=rt,he=Yt,le=st,de=at,ce=dt,ue=nt,ge=ne,pe=it;var me=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],fe=me.length;class ve extends he.Container{constructor(t){super(t),this.canvas=new ce.SceneCanvas,this.hitCanvas=new ce.HitCanvas({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(t){return this.getContext().clear(t),this.getHitCanvas().getContext().clear(t),this}setZIndex(t){super.setZIndex(t);var e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),t<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[t+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){le.Node.prototype.moveToTop.call(this);var t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!le.Node.prototype.moveUp.call(this))return!1;var t=this.getStage();return!(!t||!t.content)&&(t.content.removeChild(this.getNativeCanvasElement()),this.index<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[this.index+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(le.Node.prototype.moveDown.call(this)){var t=this.getStage();if(t){var e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(le.Node.prototype.moveToBottom.call(this)){var t=this.getStage();if(t){var e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){var t=this.getNativeCanvasElement();return le.Node.prototype.remove.call(this),t&&t.parentNode&&oe.Util._isInDocument(t)&&t.parentNode.removeChild(t),this}getStage(){return this.parent}setSize({width:t,height:e}){return this.canvas.setSize(t,e),this.hitCanvas.setSize(t,e),this._setSmoothEnabled(),this}_validateAdd(t){var e=t.getType();"Group"!==e&&"Shape"!==e&&oe.Util.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(t){return(t=t||{}).width=t.width||this.getWidth(),t.height=t.height||this.getHeight(),t.x=void 0!==t.x?t.x:this.x(),t.y=void 0!==t.y?t.y:this.y(),le.Node.prototype._toKonvaCanvas.call(this,t)}_checkVisibility(){const t=this.visible();this.canvas._canvas.style.display=t?"block":"none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){oe.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){oe.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,oe.Util.requestAnimFrame((()=>{this.draw(),this._waitingForDraw=!1}))),this}getIntersection(t){if(!this.isListening()||!this.isVisible())return null;for(var e=1,i=!1;;){for(let r=0;r<fe;r++){const s=me[r],a=this._getIntersection({x:t.x+s.x*e,y:t.y+s.y*e}),n=a.shape;if(n)return n;if(i=!!a.antialiased,!a.antialiased)break}if(!i)return null;e+=1}}_getIntersection(t){const e=this.hitCanvas.pixelRatio,i=this.hitCanvas.context.getImageData(Math.round(t.x*e),Math.round(t.y*e),1,1).data,r=i[3];if(255===r){const t=oe.Util._rgbToHex(i[0],i[1],i[2]),e=ge.shapes["#"+t];return e?{shape:e}:{antialiased:!0}}return r>0?{antialiased:!0}:{}}drawScene(t,e){var i=this.getLayer(),r=t||i&&i.getCanvas();return this._fire("beforeDraw",{node:this}),this.clearBeforeDraw()&&r.getContext().clear(),he.Container.prototype.drawScene.call(this,r,e),this._fire("draw",{node:this}),this}drawHit(t,e){var i=this.getLayer(),r=t||i&&i.hitCanvas;return i&&i.clearBeforeDraw()&&i.getHitCanvas().getContext().clear(),he.Container.prototype.drawHit.call(this,r,e),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(t){oe.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(t)}getHitGraphEnabled(t){return oe.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(this.parent&&this.parent.content){var t=this.parent;!!this.hitCanvas._canvas.parentNode?t.content.removeChild(this.hitCanvas._canvas):t.content.appendChild(this.hitCanvas._canvas)}}destroy(){return oe.Util.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}}ae.Layer=ve,ve.prototype.nodeType="Layer",(0,pe._registerNode)(ve),de.Factory.addGetterSetter(ve,"imageSmoothingEnabled",!0),de.Factory.addGetterSetter(ve,"clearBeforeDraw",!0),de.Factory.addGetterSetter(ve,"hitGraphEnabled",!0,(0,ue.getBooleanValidator)());var ye={};Object.defineProperty(ye,"__esModule",{value:!0}),ye.FastLayer=void 0;const _e=rt,we=ae,be=it;class xe extends we.Layer{constructor(t){super(t),this.listening(!1),_e.Util.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}}ye.FastLayer=xe,xe.prototype.nodeType="FastLayer",(0,be._registerNode)(xe);var Se={};Object.defineProperty(Se,"__esModule",{value:!0}),Se.Group=void 0;const Ce=rt,Pe=Yt,ke=it;class Ee extends Pe.Container{_validateAdd(t){var e=t.getType();"Group"!==e&&"Shape"!==e&&Ce.Util.throw("You may only add groups and shapes to groups.")}}Se.Group=Ee,Ee.prototype.nodeType="Group",(0,ke._registerNode)(Ee);var Ae={};Object.defineProperty(Ae,"__esModule",{value:!0}),Ae.Animation=void 0;const Te=it,Me=rt,Fe=Te.glob.performance&&Te.glob.performance.now?function(){return Te.glob.performance.now()}:function(){return(new Date).getTime()};class De{constructor(t,e){this.id=De.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:Fe(),frameRate:0},this.func=t,this.setLayers(e)}setLayers(t){let e=[];return t&&(e=Array.isArray(t)?t:[t]),this.layers=e,this}getLayers(){return this.layers}addLayer(t){const e=this.layers,i=e.length;for(let r=0;r<i;r++)if(e[r]._id===t._id)return!1;return this.layers.push(t),!0}isRunning(){const t=De.animations,e=t.length;for(let i=0;i<e;i++)if(t[i].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=Fe(),De._addAnimation(this),this}stop(){return De._removeAnimation(this),this}_updateFrameObject(t){this.frame.timeDiff=t-this.frame.lastTime,this.frame.lastTime=t,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(t){this.animations.push(t),this._handleAnimation()}static _removeAnimation(t){const e=t.id,i=this.animations,r=i.length;for(let t=0;t<r;t++)if(i[t].id===e){this.animations.splice(t,1);break}}static _runFrames(){const t={},e=this.animations;for(let i=0;i<e.length;i++){const r=e[i],s=r.layers,a=r.func;r._updateFrameObject(Fe());const n=s.length;let o;if(o=!a||!1!==a.call(r,r.frame),o)for(let e=0;e<n;e++){const i=s[e];void 0!==i._id&&(t[i._id]=i)}}for(let e in t)t.hasOwnProperty(e)&&t[e].batchDraw()}static _animationLoop(){const t=De;t.animations.length?(t._runFrames(),Me.Util.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,Me.Util.requestAnimFrame(this._animationLoop))}}Ae.Animation=De,De.animations=[],De.animIdCounter=0,De.animRunning=!1;var Oe={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Easings=t.Tween=void 0;const e=rt,i=Ae,r=st,s=it;var a={node:1,duration:1,easing:1,onFinish:1,yoyo:1},n=0,o=["fill","stroke","shadowColor"];class h{constructor(t,e,i,r,s,a,n){this.prop=t,this.propFunc=e,this.begin=r,this._pos=r,this.duration=a,this._change=0,this.prevPos=0,this.yoyo=n,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=i,this._change=s-this.begin,this.pause()}fire(t){var e=this[t];e&&e()}setTime(t){t>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():t<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=t,this.update())}getTime(){return this._time}setPosition(t){this.prevPos=this._pos,this.propFunc(t),this._pos=t}getPosition(t){return void 0===t&&(t=this._time),this.func(t,this.begin,this._change,this.duration)}play(){this.state=2,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=3,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(t){this.pause(),this._time=t,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){var t=this.getTimer()-this._startTime;2===this.state?this.setTime(t):3===this.state&&this.setTime(this.duration-t)}pause(){this.state=1,this.fire("onPause")}getTimer(){return(new Date).getTime()}}class l{constructor(r){var o,d,c=this,u=r.node,g=u._id,p=r.easing||t.Easings.Linear,m=!!r.yoyo;o=void 0===r.duration?.3:0===r.duration?.001:r.duration,this.node=u,this._id=n++;var f=u.getLayer()||(u instanceof s.Konva.Stage?u.getLayers():null);for(d in f||e.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new i.Animation((function(){c.tween.onEnterFrame()}),f),this.tween=new h(d,(function(t){c._tweenFunc(t)}),p,0,1,1e3*o,m),this._addListeners(),l.attrs[g]||(l.attrs[g]={}),l.attrs[g][this._id]||(l.attrs[g][this._id]={}),l.tweens[g]||(l.tweens[g]={}),r)void 0===a[d]&&this._addAttr(d,r[d]);this.reset(),this.onFinish=r.onFinish,this.onReset=r.onReset,this.onUpdate=r.onUpdate}_addAttr(t,i){var r,s,a,n,h,d,c,u,g=this.node,p=g._id;if((a=l.tweens[p][t])&&delete l.attrs[p][a][t],r=g.getAttr(t),e.Util._isArray(i))if(s=[],h=Math.max(i.length,r.length),"points"===t&&i.length!==r.length&&(i.length>r.length?(c=r,r=e.Util._prepareArrayForTween(r,i,g.closed())):(d=i,i=e.Util._prepareArrayForTween(i,r,g.closed()))),0===t.indexOf("fill"))for(n=0;n<h;n++)if(n%2==0)s.push(i[n]-r[n]);else{var m=e.Util.colorToRGBA(r[n]);u=e.Util.colorToRGBA(i[n]),r[n]=m,s.push({r:u.r-m.r,g:u.g-m.g,b:u.b-m.b,a:u.a-m.a})}else for(n=0;n<h;n++)s.push(i[n]-r[n]);else-1!==o.indexOf(t)?(r=e.Util.colorToRGBA(r),s={r:(u=e.Util.colorToRGBA(i)).r-r.r,g:u.g-r.g,b:u.b-r.b,a:u.a-r.a}):s=i-r;l.attrs[p][this._id][t]={start:r,diff:s,end:i,trueEnd:d,trueStart:c},l.tweens[p][t]=this._id}_tweenFunc(t){var i,r,s,a,n,h,d,c,u=this.node,g=l.attrs[u._id][this._id];for(i in g){if(s=(r=g[i]).start,a=r.diff,c=r.end,e.Util._isArray(s))if(n=[],d=Math.max(s.length,c.length),0===i.indexOf("fill"))for(h=0;h<d;h++)h%2==0?n.push((s[h]||0)+a[h]*t):n.push("rgba("+Math.round(s[h].r+a[h].r*t)+","+Math.round(s[h].g+a[h].g*t)+","+Math.round(s[h].b+a[h].b*t)+","+(s[h].a+a[h].a*t)+")");else for(h=0;h<d;h++)n.push((s[h]||0)+a[h]*t);else n=-1!==o.indexOf(i)?"rgba("+Math.round(s.r+a.r*t)+","+Math.round(s.g+a.g*t)+","+Math.round(s.b+a.b*t)+","+(s.a+a.a*t)+")":s+a*t;u.setAttr(i,n)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{var t=this.node,e=l.attrs[t._id][this._id];e.points&&e.points.trueEnd&&t.setAttr("points",e.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{var t=this.node,e=l.attrs[t._id][this._id];e.points&&e.points.trueStart&&t.points(e.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(t){return this.tween.seek(1e3*t),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){var t,e=this.node._id,i=this._id,r=l.tweens[e];for(t in this.pause(),r)delete l.tweens[e][t];delete l.attrs[e][i]}}t.Tween=l,l.attrs={},l.tweens={},r.Node.prototype.to=function(t){var e=t.onFinish;t.node=this,t.onFinish=function(){this.destroy(),e&&e()},new l(t).play()},t.Easings={BackEaseIn(t,e,i,r){var s=1.70158;return i*(t/=r)*t*((s+1)*t-s)+e},BackEaseOut(t,e,i,r){var s=1.70158;return i*((t=t/r-1)*t*((s+1)*t+s)+1)+e},BackEaseInOut(t,e,i,r){var s=1.70158;return(t/=r/2)<1?i/2*(t*t*((1+(s*=1.525))*t-s))+e:i/2*((t-=2)*t*((1+(s*=1.525))*t+s)+2)+e},ElasticEaseIn(t,e,i,r,s,a){var n=0;return 0===t?e:1==(t/=r)?e+i:(a||(a=.3*r),!s||s<Math.abs(i)?(s=i,n=a/4):n=a/(2*Math.PI)*Math.asin(i/s),-s*Math.pow(2,10*(t-=1))*Math.sin((t*r-n)*(2*Math.PI)/a)+e)},ElasticEaseOut(t,e,i,r,s,a){var n=0;return 0===t?e:1==(t/=r)?e+i:(a||(a=.3*r),!s||s<Math.abs(i)?(s=i,n=a/4):n=a/(2*Math.PI)*Math.asin(i/s),s*Math.pow(2,-10*t)*Math.sin((t*r-n)*(2*Math.PI)/a)+i+e)},ElasticEaseInOut(t,e,i,r,s,a){var n=0;return 0===t?e:2==(t/=r/2)?e+i:(a||(a=r*(.3*1.5)),!s||s<Math.abs(i)?(s=i,n=a/4):n=a/(2*Math.PI)*Math.asin(i/s),t<1?s*Math.pow(2,10*(t-=1))*Math.sin((t*r-n)*(2*Math.PI)/a)*-.5+e:s*Math.pow(2,-10*(t-=1))*Math.sin((t*r-n)*(2*Math.PI)/a)*.5+i+e)},BounceEaseOut:(t,e,i,r)=>(t/=r)<1/2.75?i*(7.5625*t*t)+e:t<2/2.75?i*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?i*(7.5625*(t-=2.25/2.75)*t+.9375)+e:i*(7.5625*(t-=2.625/2.75)*t+.984375)+e,BounceEaseIn:(e,i,r,s)=>r-t.Easings.BounceEaseOut(s-e,0,r,s)+i,BounceEaseInOut:(e,i,r,s)=>e<s/2?.5*t.Easings.BounceEaseIn(2*e,0,r,s)+i:.5*t.Easings.BounceEaseOut(2*e-s,0,r,s)+.5*r+i,EaseIn:(t,e,i,r)=>i*(t/=r)*t+e,EaseOut:(t,e,i,r)=>-i*(t/=r)*(t-2)+e,EaseInOut:(t,e,i,r)=>(t/=r/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e,StrongEaseIn:(t,e,i,r)=>i*(t/=r)*t*t*t*t+e,StrongEaseOut:(t,e,i,r)=>i*((t=t/r-1)*t*t*t*t+1)+e,StrongEaseInOut:(t,e,i,r)=>(t/=r/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e,Linear:(t,e,i,r)=>i*t/r+e}}(Oe),function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Konva=void 0;const e=it,i=rt,r=st,s=Yt,a=$t,n=ae,o=ye,h=Se,l=St,d=ne,c=Ae,u=Oe,g=ct,p=dt;t.Konva=i.Util._assign(e.Konva,{Util:i.Util,Transform:i.Transform,Node:r.Node,Container:s.Container,Stage:a.Stage,stages:a.stages,Layer:n.Layer,FastLayer:o.FastLayer,Group:h.Group,DD:l.DD,Shape:d.Shape,shapes:d.shapes,Animation:c.Animation,Tween:u.Tween,Easings:u.Easings,Context:g.Context,Canvas:p.Canvas}),t.default=t.Konva}(et);var Ve={};Object.defineProperty(Ve,"__esModule",{value:!0}),Ve.Arc=void 0;const Re=at,Ie=ne,Le=it,ze=nt,Ge=it;class Ne extends Ie.Shape{_sceneFunc(t){var e=Le.Konva.getAngle(this.angle()),i=this.clockwise();t.beginPath(),t.arc(0,0,this.outerRadius(),0,e,i),t.arc(0,0,this.innerRadius(),e,0,!i),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}getSelfRect(){const t=this.innerRadius(),e=this.outerRadius(),i=this.clockwise(),r=Le.Konva.getAngle(i?360-this.angle():this.angle()),s=Math.cos(Math.min(r,Math.PI)),a=Math.sin(Math.min(Math.max(Math.PI,r),3*Math.PI/2)),n=Math.sin(Math.min(r,Math.PI/2)),o=s*(s>0?t:e),h=a*(a>0?t:e),l=n*(n>0?e:t);return{x:o,y:i?-1*l:h,width:1*e-o,height:l-h}}}Ve.Arc=Ne,Ne.prototype._centroid=!0,Ne.prototype.className="Arc",Ne.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,Ge._registerNode)(Ne),Re.Factory.addGetterSetter(Ne,"innerRadius",0,(0,ze.getNumberValidator)()),Re.Factory.addGetterSetter(Ne,"outerRadius",0,(0,ze.getNumberValidator)()),Re.Factory.addGetterSetter(Ne,"angle",0,(0,ze.getNumberValidator)()),Re.Factory.addGetterSetter(Ne,"clockwise",!1,(0,ze.getBooleanValidator)());var Ue={},We={};Object.defineProperty(We,"__esModule",{value:!0}),We.Line=void 0;const je=at,Be=ne,He=nt,Ke=it;function Ye(t,e,i,r,s,a,n){var o=Math.sqrt(Math.pow(i-t,2)+Math.pow(r-e,2)),h=Math.sqrt(Math.pow(s-i,2)+Math.pow(a-r,2)),l=n*o/(o+h),d=n*h/(o+h);return[i-l*(s-t),r-l*(a-e),i+d*(s-t),r+d*(a-e)]}function Xe(t,e){var i,r,s=t.length,a=[];for(i=2;i<s-2;i+=2)r=Ye(t[i-2],t[i-1],t[i],t[i+1],t[i+2],t[i+3],e),isNaN(r[0])||(a.push(r[0]),a.push(r[1]),a.push(t[i]),a.push(t[i+1]),a.push(r[2]),a.push(r[3]));return a}class Je extends Be.Shape{constructor(t){super(t),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",(function(){this._clearCache("tensionPoints")}))}_sceneFunc(t){var e,i,r,s=this.points(),a=s.length,n=this.tension(),o=this.closed(),h=this.bezier();if(a){if(t.beginPath(),t.moveTo(s[0],s[1]),0!==n&&a>4){for(i=(e=this.getTensionPoints()).length,r=o?0:4,o||t.quadraticCurveTo(e[0],e[1],e[2],e[3]);r<i-2;)t.bezierCurveTo(e[r++],e[r++],e[r++],e[r++],e[r++],e[r++]);o||t.quadraticCurveTo(e[i-2],e[i-1],s[a-2],s[a-1])}else if(h)for(r=2;r<a;)t.bezierCurveTo(s[r++],s[r++],s[r++],s[r++],s[r++],s[r++]);else for(r=2;r<a;r+=2)t.lineTo(s[r],s[r+1]);o?(t.closePath(),t.fillStrokeShape(this)):t.strokeShape(this)}}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():Xe(this.points(),this.tension())}_getTensionPointsClosed(){var t=this.points(),e=t.length,i=this.tension(),r=Ye(t[e-2],t[e-1],t[0],t[1],t[2],t[3],i),s=Ye(t[e-4],t[e-3],t[e-2],t[e-1],t[0],t[1],i),a=Xe(t,i);return[r[2],r[3]].concat(a).concat([s[0],s[1],t[e-2],t[e-1],s[2],s[3],r[0],r[1],t[0],t[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){var t=this.points();if(t.length<4)return{x:t[0]||0,y:t[1]||0,width:0,height:0};for(var e,i,r=(t=0!==this.tension()?[t[0],t[1],...this._getTensionPoints(),t[t.length-2],t[t.length-1]]:this.points())[0],s=t[0],a=t[1],n=t[1],o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],r=Math.min(r,e),s=Math.max(s,e),a=Math.min(a,i),n=Math.max(n,i);return{x:r,y:a,width:s-r,height:n-a}}}We.Line=Je,Je.prototype.className="Line",Je.prototype._attrsAffectingSize=["points","bezier","tension"],(0,Ke._registerNode)(Je),je.Factory.addGetterSetter(Je,"closed",!1),je.Factory.addGetterSetter(Je,"bezier",!1),je.Factory.addGetterSetter(Je,"tension",0,(0,He.getNumberValidator)()),je.Factory.addGetterSetter(Je,"points",[],(0,He.getNumberArrayValidator)());var qe={},Ze={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.t2length=t.getQuadraticArcLength=t.getCubicArcLength=t.binomialCoefficients=t.cValues=t.tValues=void 0,t.tValues=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],t.cValues=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],t.binomialCoefficients=[[1],[1,1],[1,2,1],[1,3,3,1]];t.getCubicArcLength=(i,r,s)=>{let a,n,o;a=s/2,n=0;for(let s=0;s<20;s++)o=a*t.tValues[20][s]+a,n+=t.cValues[20][s]*e(i,r,o);return a*n};function e(t,e,r){const s=i(1,r,t),a=i(1,r,e),n=s*s+a*a;return Math.sqrt(n)}t.getQuadraticArcLength=(t,e,i)=>{void 0===i&&(i=1);const r=t[0]-2*t[1]+t[2],s=e[0]-2*e[1]+e[2],a=2*t[1]-2*t[0],n=2*e[1]-2*e[0],o=4*(r*r+s*s),h=4*(r*a+s*n),l=a*a+n*n;if(0===o)return i*Math.sqrt(Math.pow(t[2]-t[0],2)+Math.pow(e[2]-e[0],2));const d=h/(2*o),c=i+d,u=l/o-d*d,g=c*c+u>0?Math.sqrt(c*c+u):0,p=d*d+u>0?Math.sqrt(d*d+u):0,m=d+Math.sqrt(d*d+u)!==0?u*Math.log(Math.abs((c+g)/(d+p))):0;return Math.sqrt(o)/2*(c*g-d*p+m)};const i=(e,r,s)=>{const a=s.length-1;let n,o;if(0===a)return 0;if(0===e){o=0;for(let e=0;e<=a;e++)o+=t.binomialCoefficients[a][e]*Math.pow(1-r,a-e)*Math.pow(r,e)*s[e];return o}n=new Array(a);for(let t=0;t<a;t++)n[t]=a*(s[t+1]-s[t]);return i(e-1,r,n)};t.t2length=(t,e,i)=>{let r=1,s=t/e,a=(t-i(s))/e,n=0;for(;r>.001;){const o=i(s+a),h=Math.abs(t-o)/e;if(h<r)r=h,s+=a;else{const n=i(s-a),o=Math.abs(t-n)/e;o<r?(r=o,s-=a):a/=2}if(n++,n>500)break}return s}}(Ze),Object.defineProperty(qe,"__esModule",{value:!0}),qe.Path=void 0;const $e=at,Qe=ne,ti=it,ei=Ze;class ii extends Qe.Shape{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",(function(){this._readDataAttribute()}))}_readDataAttribute(){this.dataArray=ii.parsePathData(this.data()),this.pathLength=ii.getPathLength(this.dataArray)}_sceneFunc(t){var e=this.dataArray;t.beginPath();for(var i=!1,r=0;r<e.length;r++){var s=e[r].command,a=e[r].points;switch(s){case"L":t.lineTo(a[0],a[1]);break;case"M":t.moveTo(a[0],a[1]);break;case"C":t.bezierCurveTo(a[0],a[1],a[2],a[3],a[4],a[5]);break;case"Q":t.quadraticCurveTo(a[0],a[1],a[2],a[3]);break;case"A":var n=a[0],o=a[1],h=a[2],l=a[3],d=a[4],c=a[5],u=a[6],g=a[7],p=h>l?h:l,m=h>l?1:h/l,f=h>l?l/h:1;t.translate(n,o),t.rotate(u),t.scale(m,f),t.arc(0,0,p,d,d+c,1-g),t.scale(1/m,1/f),t.rotate(-u),t.translate(-n,-o);break;case"z":i=!0,t.closePath()}}i||this.hasFill()?t.fillStrokeShape(this):t.strokeShape(this)}getSelfRect(){var t=[];this.dataArray.forEach((function(e){if("A"===e.command){var i=e.points[4],r=e.points[5],s=e.points[4]+r,a=Math.PI/180;if(Math.abs(i-s)<a&&(a=Math.abs(i-s)),r<0)for(let r=i-a;r>s;r-=a){const i=ii.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],r,0);t.push(i.x,i.y)}else for(let r=i+a;r<s;r+=a){const i=ii.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],r,0);t.push(i.x,i.y)}}else if("C"===e.command)for(let i=0;i<=1;i+=.01){const r=ii.getPointOnCubicBezier(i,e.start.x,e.start.y,e.points[0],e.points[1],e.points[2],e.points[3],e.points[4],e.points[5]);t.push(r.x,r.y)}else t=t.concat(e.points)}));for(var e,i,r=t[0],s=t[0],a=t[1],n=t[1],o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],isNaN(e)||(r=Math.min(r,e),s=Math.max(s,e)),isNaN(i)||(a=Math.min(a,i),n=Math.max(n,i));return{x:r,y:a,width:s-r,height:n-a}}getLength(){return this.pathLength}getPointAtLength(t){return ii.getPointAtLengthOfDataArray(t,this.dataArray)}static getLineLength(t,e,i,r){return Math.sqrt((i-t)*(i-t)+(r-e)*(r-e))}static getPathLength(t){let e=0;for(var i=0;i<t.length;++i)e+=t[i].pathLength;return e}static getPointAtLengthOfDataArray(t,e){var i,r=0,s=e.length;if(!s)return null;for(;r<s&&t>e[r].pathLength;)t-=e[r].pathLength,++r;if(r===s)return{x:(i=e[r-1].points.slice(-2))[0],y:i[1]};if(t<.01)return{x:(i=e[r].points.slice(0,2))[0],y:i[1]};var a=e[r],n=a.points;switch(a.command){case"L":return ii.getPointOnLine(t,a.start.x,a.start.y,n[0],n[1]);case"C":return ii.getPointOnCubicBezier((0,ei.t2length)(t,ii.getPathLength(e),(t=>(0,ei.getCubicArcLength)([a.start.x,n[0],n[2],n[4]],[a.start.y,n[1],n[3],n[5]],t))),a.start.x,a.start.y,n[0],n[1],n[2],n[3],n[4],n[5]);case"Q":return ii.getPointOnQuadraticBezier((0,ei.t2length)(t,ii.getPathLength(e),(t=>(0,ei.getQuadraticArcLength)([a.start.x,n[0],n[2]],[a.start.y,n[1],n[3]],t))),a.start.x,a.start.y,n[0],n[1],n[2],n[3]);case"A":var o=n[0],h=n[1],l=n[2],d=n[3],c=n[4],u=n[5],g=n[6];return c+=u*t/a.pathLength,ii.getPointOnEllipticalArc(o,h,l,d,c,g)}return null}static getPointOnLine(t,e,i,r,s,a,n){void 0===a&&(a=e),void 0===n&&(n=i);var o=(s-i)/(r-e+1e-8),h=Math.sqrt(t*t/(1+o*o));r<e&&(h*=-1);var l,d=o*h;if(r===e)l={x:a,y:n+d};else if((n-i)/(a-e+1e-8)===o)l={x:a+h,y:n+d};else{var c,u,g=this.getLineLength(e,i,r,s),p=(a-e)*(r-e)+(n-i)*(s-i);c=e+(p/=g*g)*(r-e),u=i+p*(s-i);var m=this.getLineLength(a,n,c,u),f=Math.sqrt(t*t-m*m);h=Math.sqrt(f*f/(1+o*o)),r<e&&(h*=-1),l={x:c+h,y:u+(d=o*h)}}return l}static getPointOnCubicBezier(t,e,i,r,s,a,n,o,h){function l(t){return t*t*t}function d(t){return 3*t*t*(1-t)}function c(t){return 3*t*(1-t)*(1-t)}function u(t){return(1-t)*(1-t)*(1-t)}return{x:o*l(t)+a*d(t)+r*c(t)+e*u(t),y:h*l(t)+n*d(t)+s*c(t)+i*u(t)}}static getPointOnQuadraticBezier(t,e,i,r,s,a,n){function o(t){return t*t}function h(t){return 2*t*(1-t)}function l(t){return(1-t)*(1-t)}return{x:a*o(t)+r*h(t)+e*l(t),y:n*o(t)+s*h(t)+i*l(t)}}static getPointOnEllipticalArc(t,e,i,r,s,a){var n=Math.cos(a),o=Math.sin(a),h=i*Math.cos(s),l=r*Math.sin(s);return{x:t+(h*n-l*o),y:e+(h*o+l*n)}}static parsePathData(t){if(!t)return[];var e=t,i=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];e=e.replace(new RegExp(" ","g"),",");for(var r=0;r<i.length;r++)e=e.replace(new RegExp(i[r],"g"),"|"+i[r]);var s,a=e.split("|"),n=[],o=[],h=0,l=0,d=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;for(r=1;r<a.length;r++){var c=a[r],u=c.charAt(0);for(c=c.slice(1),o.length=0;s=d.exec(c);)o.push(s[0]);for(var g=[],p=0,m=o.length;p<m;p++)if("00"!==o[p]){var f=parseFloat(o[p]);isNaN(f)?g.push(0):g.push(f)}else g.push(0,0);for(;g.length>0&&!isNaN(g[0]);){var v,y,_,w,b,x,S,C,P,k,E="",A=[],T=h,M=l;switch(u){case"l":h+=g.shift(),l+=g.shift(),E="L",A.push(h,l);break;case"L":h=g.shift(),l=g.shift(),A.push(h,l);break;case"m":var F=g.shift(),D=g.shift();if(h+=F,l+=D,E="M",n.length>2&&"z"===n[n.length-1].command)for(var O=n.length-2;O>=0;O--)if("M"===n[O].command){h=n[O].points[0]+F,l=n[O].points[1]+D;break}A.push(h,l),u="l";break;case"M":h=g.shift(),l=g.shift(),E="M",A.push(h,l),u="L";break;case"h":h+=g.shift(),E="L",A.push(h,l);break;case"H":h=g.shift(),E="L",A.push(h,l);break;case"v":l+=g.shift(),E="L",A.push(h,l);break;case"V":l=g.shift(),E="L",A.push(h,l);break;case"C":A.push(g.shift(),g.shift(),g.shift(),g.shift()),h=g.shift(),l=g.shift(),A.push(h,l);break;case"c":A.push(h+g.shift(),l+g.shift(),h+g.shift(),l+g.shift()),h+=g.shift(),l+=g.shift(),E="C",A.push(h,l);break;case"S":y=h,_=l,"C"===(v=n[n.length-1]).command&&(y=h+(h-v.points[2]),_=l+(l-v.points[3])),A.push(y,_,g.shift(),g.shift()),h=g.shift(),l=g.shift(),E="C",A.push(h,l);break;case"s":y=h,_=l,"C"===(v=n[n.length-1]).command&&(y=h+(h-v.points[2]),_=l+(l-v.points[3])),A.push(y,_,h+g.shift(),l+g.shift()),h+=g.shift(),l+=g.shift(),E="C",A.push(h,l);break;case"Q":A.push(g.shift(),g.shift()),h=g.shift(),l=g.shift(),A.push(h,l);break;case"q":A.push(h+g.shift(),l+g.shift()),h+=g.shift(),l+=g.shift(),E="Q",A.push(h,l);break;case"T":y=h,_=l,"Q"===(v=n[n.length-1]).command&&(y=h+(h-v.points[0]),_=l+(l-v.points[1])),h=g.shift(),l=g.shift(),E="Q",A.push(y,_,h,l);break;case"t":y=h,_=l,"Q"===(v=n[n.length-1]).command&&(y=h+(h-v.points[0]),_=l+(l-v.points[1])),h+=g.shift(),l+=g.shift(),E="Q",A.push(y,_,h,l);break;case"A":w=g.shift(),b=g.shift(),x=g.shift(),S=g.shift(),C=g.shift(),P=h,k=l,h=g.shift(),l=g.shift(),E="A",A=this.convertEndpointToCenterParameterization(P,k,h,l,S,C,w,b,x);break;case"a":w=g.shift(),b=g.shift(),x=g.shift(),S=g.shift(),C=g.shift(),P=h,k=l,h+=g.shift(),l+=g.shift(),E="A",A=this.convertEndpointToCenterParameterization(P,k,h,l,S,C,w,b,x)}n.push({command:E||u,points:A,start:{x:T,y:M},pathLength:this.calcLength(T,M,E||u,A)})}"z"!==u&&"Z"!==u||n.push({command:"z",points:[],start:void 0,pathLength:0})}return n}static calcLength(t,e,i,r){var s,a,n,o,h=ii;switch(i){case"L":return h.getLineLength(t,e,r[0],r[1]);case"C":return(0,ei.getCubicArcLength)([t,r[0],r[2],r[4]],[e,r[1],r[3],r[5]],1);case"Q":return(0,ei.getQuadraticArcLength)([t,r[0],r[2]],[e,r[1],r[3]],1);case"A":s=0;var l=r[4],d=r[5],c=r[4]+d,u=Math.PI/180;if(Math.abs(l-c)<u&&(u=Math.abs(l-c)),a=h.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],l,0),d<0)for(o=l-u;o>c;o-=u)n=h.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],o,0),s+=h.getLineLength(a.x,a.y,n.x,n.y),a=n;else for(o=l+u;o<c;o+=u)n=h.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],o,0),s+=h.getLineLength(a.x,a.y,n.x,n.y),a=n;return n=h.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],c,0),s+=h.getLineLength(a.x,a.y,n.x,n.y)}return 0}static convertEndpointToCenterParameterization(t,e,i,r,s,a,n,o,h){var l=h*(Math.PI/180),d=Math.cos(l)*(t-i)/2+Math.sin(l)*(e-r)/2,c=-1*Math.sin(l)*(t-i)/2+Math.cos(l)*(e-r)/2,u=d*d/(n*n)+c*c/(o*o);u>1&&(n*=Math.sqrt(u),o*=Math.sqrt(u));var g=Math.sqrt((n*n*(o*o)-n*n*(c*c)-o*o*(d*d))/(n*n*(c*c)+o*o*(d*d)));s===a&&(g*=-1),isNaN(g)&&(g=0);var p=g*n*c/o,m=g*-o*d/n,f=(t+i)/2+Math.cos(l)*p-Math.sin(l)*m,v=(e+r)/2+Math.sin(l)*p+Math.cos(l)*m,y=function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])},_=function(t,e){return(t[0]*e[0]+t[1]*e[1])/(y(t)*y(e))},w=function(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(_(t,e))},b=w([1,0],[(d-p)/n,(c-m)/o]),x=[(d-p)/n,(c-m)/o],S=[(-1*d-p)/n,(-1*c-m)/o],C=w(x,S);return _(x,S)<=-1&&(C=Math.PI),_(x,S)>=1&&(C=0),0===a&&C>0&&(C-=2*Math.PI),1===a&&C<0&&(C+=2*Math.PI),[f,v,n,o,b,C,l,a]}}qe.Path=ii,ii.prototype.className="Path",ii.prototype._attrsAffectingSize=["data"],(0,ti._registerNode)(ii),$e.Factory.addGetterSetter(ii,"data"),Object.defineProperty(Ue,"__esModule",{value:!0}),Ue.Arrow=void 0;const ri=at,si=We,ai=nt,ni=it,oi=qe;class hi extends si.Line{_sceneFunc(t){super._sceneFunc(t);var e=2*Math.PI,i=this.points(),r=i,s=0!==this.tension()&&i.length>4;s&&(r=this.getTensionPoints());var a,n,o=this.pointerLength(),h=i.length;if(s){const t=[r[r.length-4],r[r.length-3],r[r.length-2],r[r.length-1],i[h-2],i[h-1]],e=oi.Path.calcLength(r[r.length-4],r[r.length-3],"C",t),s=oi.Path.getPointOnQuadraticBezier(Math.min(1,1-o/e),t[0],t[1],t[2],t[3],t[4],t[5]);a=i[h-2]-s.x,n=i[h-1]-s.y}else a=i[h-2]-i[h-4],n=i[h-1]-i[h-3];var l=(Math.atan2(n,a)+e)%e,d=this.pointerWidth();this.pointerAtEnding()&&(t.save(),t.beginPath(),t.translate(i[h-2],i[h-1]),t.rotate(l),t.moveTo(0,0),t.lineTo(-o,d/2),t.lineTo(-o,-d/2),t.closePath(),t.restore(),this.__fillStroke(t)),this.pointerAtBeginning()&&(t.save(),t.beginPath(),t.translate(i[0],i[1]),s?(a=(r[0]+r[2])/2-i[0],n=(r[1]+r[3])/2-i[1]):(a=i[2]-i[0],n=i[3]-i[1]),t.rotate((Math.atan2(-n,-a)+e)%e),t.moveTo(0,0),t.lineTo(-o,d/2),t.lineTo(-o,-d/2),t.closePath(),t.restore(),this.__fillStroke(t))}__fillStroke(t){var e=this.dashEnabled();e&&(this.attrs.dashEnabled=!1,t.setLineDash([])),t.fillStrokeShape(this),e&&(this.attrs.dashEnabled=!0)}getSelfRect(){const t=super.getSelfRect(),e=this.pointerWidth()/2;return{x:t.x-e,y:t.y-e,width:t.width+2*e,height:t.height+2*e}}}Ue.Arrow=hi,hi.prototype.className="Arrow",(0,ni._registerNode)(hi),ri.Factory.addGetterSetter(hi,"pointerLength",10,(0,ai.getNumberValidator)()),ri.Factory.addGetterSetter(hi,"pointerWidth",10,(0,ai.getNumberValidator)()),ri.Factory.addGetterSetter(hi,"pointerAtBeginning",!1),ri.Factory.addGetterSetter(hi,"pointerAtEnding",!0);var li={};Object.defineProperty(li,"__esModule",{value:!0}),li.Circle=void 0;const di=at,ci=ne,ui=nt,gi=it;class pi extends ci.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.attrs.radius||0,0,2*Math.PI,!1),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius()!==t/2&&this.radius(t/2)}setHeight(t){this.radius()!==t/2&&this.radius(t/2)}}li.Circle=pi,pi.prototype._centroid=!0,pi.prototype.className="Circle",pi.prototype._attrsAffectingSize=["radius"],(0,gi._registerNode)(pi),di.Factory.addGetterSetter(pi,"radius",0,(0,ui.getNumberValidator)());var mi={};Object.defineProperty(mi,"__esModule",{value:!0}),mi.Ellipse=void 0;const fi=at,vi=ne,yi=nt,_i=it;class wi extends vi.Shape{_sceneFunc(t){var e=this.radiusX(),i=this.radiusY();t.beginPath(),t.save(),e!==i&&t.scale(1,i/e),t.arc(0,0,e,0,2*Math.PI,!1),t.restore(),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radiusX()}getHeight(){return 2*this.radiusY()}setWidth(t){this.radiusX(t/2)}setHeight(t){this.radiusY(t/2)}}mi.Ellipse=wi,wi.prototype.className="Ellipse",wi.prototype._centroid=!0,wi.prototype._attrsAffectingSize=["radiusX","radiusY"],(0,_i._registerNode)(wi),fi.Factory.addComponentsGetterSetter(wi,"radius",["x","y"]),fi.Factory.addGetterSetter(wi,"radiusX",0,(0,yi.getNumberValidator)()),fi.Factory.addGetterSetter(wi,"radiusY",0,(0,yi.getNumberValidator)());var bi={};Object.defineProperty(bi,"__esModule",{value:!0}),bi.Image=void 0;const xi=rt,Si=at,Ci=ne,Pi=it,ki=nt;class Ei extends Ci.Shape{constructor(t){super(t),this.on("imageChange.konva",(()=>{this._setImageLoad()})),this._setImageLoad()}_setImageLoad(){const t=this.image();t&&t.complete||t&&4===t.readyState||t&&t.addEventListener&&t.addEventListener("load",(()=>{this._requestDraw()}))}_useBufferCanvas(){return super._useBufferCanvas(!0)}_sceneFunc(t){const e=this.getWidth(),i=this.getHeight(),r=this.cornerRadius(),s=this.attrs.image;let a;if(s){const t=this.attrs.cropWidth,r=this.attrs.cropHeight;a=t&&r?[s,this.cropX(),this.cropY(),t,r,0,0,e,i]:[s,0,0,e,i]}(this.hasFill()||this.hasStroke()||r)&&(t.beginPath(),r?xi.Util.drawRoundedRectPath(t,e,i,r):t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)),s&&(r&&t.clip(),t.drawImage.apply(t,a))}_hitFunc(t){var e=this.width(),i=this.height(),r=this.cornerRadius();t.beginPath(),r?xi.Util.drawRoundedRectPath(t,e,i,r):t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}getWidth(){var t,e;return null!==(t=this.attrs.width)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.width}getHeight(){var t,e;return null!==(t=this.attrs.height)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.height}static fromURL(t,e,i=null){var r=xi.Util.createImageElement();r.onload=function(){var t=new Ei({image:r});e(t)},r.onerror=i,r.crossOrigin="Anonymous",r.src=t}}bi.Image=Ei,Ei.prototype.className="Image",(0,Pi._registerNode)(Ei),Si.Factory.addGetterSetter(Ei,"cornerRadius",0,(0,ki.getNumberOrArrayOfNumbersValidator)(4)),Si.Factory.addGetterSetter(Ei,"image"),Si.Factory.addComponentsGetterSetter(Ei,"crop",["x","y","width","height"]),Si.Factory.addGetterSetter(Ei,"cropX",0,(0,ki.getNumberValidator)()),Si.Factory.addGetterSetter(Ei,"cropY",0,(0,ki.getNumberValidator)()),Si.Factory.addGetterSetter(Ei,"cropWidth",0,(0,ki.getNumberValidator)()),Si.Factory.addGetterSetter(Ei,"cropHeight",0,(0,ki.getNumberValidator)());var Ai={};Object.defineProperty(Ai,"__esModule",{value:!0}),Ai.Tag=Ai.Label=void 0;const Ti=at,Mi=ne,Fi=Se,Di=nt,Oi=it;var Vi=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],Ri="up",Ii="right",Li="down",zi="left",Gi=Vi.length;class Ni extends Fi.Group{constructor(t){super(t),this.on("add.konva",(function(t){this._addListeners(t.child),this._sync()}))}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(t){var e,i=this,r=function(){i._sync()};for(e=0;e<Gi;e++)t.on(Vi[e]+"Change.konva",r)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){var t,e,i,r,s,a,n,o=this.getText(),h=this.getTag();if(o&&h){switch(t=o.width(),e=o.height(),i=h.pointerDirection(),r=h.pointerWidth(),n=h.pointerHeight(),s=0,a=0,i){case Ri:s=t/2,a=-1*n;break;case Ii:s=t+r,a=e/2;break;case Li:s=t/2,a=e+n;break;case zi:s=-1*r,a=e/2}h.setAttrs({x:-1*s,y:-1*a,width:t,height:e}),o.setAttrs({x:-1*s,y:-1*a})}}}Ai.Label=Ni,Ni.prototype.className="Label",(0,Oi._registerNode)(Ni);class Ui extends Mi.Shape{_sceneFunc(t){var e=this.width(),i=this.height(),r=this.pointerDirection(),s=this.pointerWidth(),a=this.pointerHeight(),n=this.cornerRadius();let o=0,h=0,l=0,d=0;"number"==typeof n?o=h=l=d=Math.min(n,e/2,i/2):(o=Math.min(n[0]||0,e/2,i/2),h=Math.min(n[1]||0,e/2,i/2),d=Math.min(n[2]||0,e/2,i/2),l=Math.min(n[3]||0,e/2,i/2)),t.beginPath(),t.moveTo(o,0),r===Ri&&(t.lineTo((e-s)/2,0),t.lineTo(e/2,-1*a),t.lineTo((e+s)/2,0)),t.lineTo(e-h,0),t.arc(e-h,h,h,3*Math.PI/2,0,!1),r===Ii&&(t.lineTo(e,(i-a)/2),t.lineTo(e+s,i/2),t.lineTo(e,(i+a)/2)),t.lineTo(e,i-d),t.arc(e-d,i-d,d,0,Math.PI/2,!1),r===Li&&(t.lineTo((e+s)/2,i),t.lineTo(e/2,i+a),t.lineTo((e-s)/2,i)),t.lineTo(l,i),t.arc(l,i-l,l,Math.PI/2,Math.PI,!1),r===zi&&(t.lineTo(0,(i+a)/2),t.lineTo(-1*s,i/2),t.lineTo(0,(i-a)/2)),t.lineTo(0,o),t.arc(o,o,o,Math.PI,3*Math.PI/2,!1),t.closePath(),t.fillStrokeShape(this)}getSelfRect(){var t=0,e=0,i=this.pointerWidth(),r=this.pointerHeight(),s=this.pointerDirection(),a=this.width(),n=this.height();return s===Ri?(e-=r,n+=r):s===Li?n+=r:s===zi?(t-=1.5*i,a+=i):s===Ii&&(a+=1.5*i),{x:t,y:e,width:a,height:n}}}Ai.Tag=Ui,Ui.prototype.className="Tag",(0,Oi._registerNode)(Ui),Ti.Factory.addGetterSetter(Ui,"pointerDirection","none"),Ti.Factory.addGetterSetter(Ui,"pointerWidth",0,(0,Di.getNumberValidator)()),Ti.Factory.addGetterSetter(Ui,"pointerHeight",0,(0,Di.getNumberValidator)()),Ti.Factory.addGetterSetter(Ui,"cornerRadius",0,(0,Di.getNumberOrArrayOfNumbersValidator)(4));var Wi={};Object.defineProperty(Wi,"__esModule",{value:!0}),Wi.Rect=void 0;const ji=at,Bi=ne,Hi=it,Ki=rt,Yi=nt;class Xi extends Bi.Shape{_sceneFunc(t){var e=this.cornerRadius(),i=this.width(),r=this.height();t.beginPath(),e?Ki.Util.drawRoundedRectPath(t,i,r,e):t.rect(0,0,i,r),t.closePath(),t.fillStrokeShape(this)}}Wi.Rect=Xi,Xi.prototype.className="Rect",(0,Hi._registerNode)(Xi),ji.Factory.addGetterSetter(Xi,"cornerRadius",0,(0,Yi.getNumberOrArrayOfNumbersValidator)(4));var Ji={};Object.defineProperty(Ji,"__esModule",{value:!0}),Ji.RegularPolygon=void 0;const qi=at,Zi=ne,$i=nt,Qi=it;class tr extends Zi.Shape{_sceneFunc(t){const e=this._getPoints();t.beginPath(),t.moveTo(e[0].x,e[0].y);for(var i=1;i<e.length;i++)t.lineTo(e[i].x,e[i].y);t.closePath(),t.fillStrokeShape(this)}_getPoints(){const t=this.attrs.sides,e=this.attrs.radius||0,i=[];for(var r=0;r<t;r++)i.push({x:e*Math.sin(2*r*Math.PI/t),y:-1*e*Math.cos(2*r*Math.PI/t)});return i}getSelfRect(){const t=this._getPoints();var e=t[0].x,i=t[0].y,r=t[0].x,s=t[0].y;return t.forEach((t=>{e=Math.min(e,t.x),i=Math.max(i,t.x),r=Math.min(r,t.y),s=Math.max(s,t.y)})),{x:e,y:r,width:i-e,height:s-r}}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}}Ji.RegularPolygon=tr,tr.prototype.className="RegularPolygon",tr.prototype._centroid=!0,tr.prototype._attrsAffectingSize=["radius"],(0,Qi._registerNode)(tr),qi.Factory.addGetterSetter(tr,"radius",0,(0,$i.getNumberValidator)()),qi.Factory.addGetterSetter(tr,"sides",0,(0,$i.getNumberValidator)());var er={};Object.defineProperty(er,"__esModule",{value:!0}),er.Ring=void 0;const ir=at,rr=ne,sr=nt,ar=it;var nr=2*Math.PI;class or extends rr.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.innerRadius(),0,nr,!1),t.moveTo(this.outerRadius(),0),t.arc(0,0,this.outerRadius(),nr,0,!0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}}er.Ring=or,or.prototype.className="Ring",or.prototype._centroid=!0,or.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,ar._registerNode)(or),ir.Factory.addGetterSetter(or,"innerRadius",0,(0,sr.getNumberValidator)()),ir.Factory.addGetterSetter(or,"outerRadius",0,(0,sr.getNumberValidator)());var hr={};Object.defineProperty(hr,"__esModule",{value:!0}),hr.Sprite=void 0;const lr=at,dr=ne,cr=Ae,ur=nt,gr=it;class pr extends dr.Shape{constructor(t){super(t),this._updated=!0,this.anim=new cr.Animation((()=>{var t=this._updated;return this._updated=!1,t})),this.on("animationChange.konva",(function(){this.frameIndex(0)})),this.on("frameIndexChange.konva",(function(){this._updated=!0})),this.on("frameRateChange.konva",(function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())}))}_sceneFunc(t){var e=this.animation(),i=this.frameIndex(),r=4*i,s=this.animations()[e],a=this.frameOffsets(),n=s[r+0],o=s[r+1],h=s[r+2],l=s[r+3],d=this.image();if((this.hasFill()||this.hasStroke())&&(t.beginPath(),t.rect(0,0,h,l),t.closePath(),t.fillStrokeShape(this)),d)if(a){var c=a[e],u=2*i;t.drawImage(d,n,o,h,l,c[u+0],c[u+1],h,l)}else t.drawImage(d,n,o,h,l,0,0,h,l)}_hitFunc(t){var e=this.animation(),i=this.frameIndex(),r=4*i,s=this.animations()[e],a=this.frameOffsets(),n=s[r+2],o=s[r+3];if(t.beginPath(),a){var h=a[e],l=2*i;t.rect(h[l+0],h[l+1],n,o)}else t.rect(0,0,n,o);t.closePath(),t.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){var t=this;this.interval=setInterval((function(){t._updateIndex()}),1e3/this.frameRate())}start(){if(!this.isRunning()){var t=this.getLayer();this.anim.setLayers(t),this._setInterval(),this.anim.start()}}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){var t=this.frameIndex(),e=this.animation();t<this.animations()[e].length/4-1?this.frameIndex(t+1):this.frameIndex(0)}}hr.Sprite=pr,pr.prototype.className="Sprite",(0,gr._registerNode)(pr),lr.Factory.addGetterSetter(pr,"animation"),lr.Factory.addGetterSetter(pr,"animations"),lr.Factory.addGetterSetter(pr,"frameOffsets"),lr.Factory.addGetterSetter(pr,"image"),lr.Factory.addGetterSetter(pr,"frameIndex",0,(0,ur.getNumberValidator)()),lr.Factory.addGetterSetter(pr,"frameRate",17,(0,ur.getNumberValidator)()),lr.Factory.backCompat(pr,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});var mr={};Object.defineProperty(mr,"__esModule",{value:!0}),mr.Star=void 0;const fr=at,vr=ne,yr=nt,_r=it;class wr extends vr.Shape{_sceneFunc(t){var e=this.innerRadius(),i=this.outerRadius(),r=this.numPoints();t.beginPath(),t.moveTo(0,0-i);for(var s=1;s<2*r;s++){var a=s%2==0?i:e,n=a*Math.sin(s*Math.PI/r),o=-1*a*Math.cos(s*Math.PI/r);t.lineTo(n,o)}t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}}mr.Star=wr,wr.prototype.className="Star",wr.prototype._centroid=!0,wr.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,_r._registerNode)(wr),fr.Factory.addGetterSetter(wr,"numPoints",5,(0,yr.getNumberValidator)()),fr.Factory.addGetterSetter(wr,"innerRadius",0,(0,yr.getNumberValidator)()),fr.Factory.addGetterSetter(wr,"outerRadius",0,(0,yr.getNumberValidator)());var br={};Object.defineProperty(br,"__esModule",{value:!0}),br.Text=br.stringToArray=void 0;const xr=rt,Sr=at,Cr=ne,Pr=nt,kr=it;function Er(t){return Array.from(t)}br.stringToArray=Er;var Ar,Tr="auto",Mr="inherit",Fr="justify",Dr="left",Or="middle",Vr="normal",Rr=" ",Ir="none",Lr=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],zr=Lr.length;function Gr(){return Ar||(Ar=xr.Util.createCanvasElement().getContext("2d"))}class Nr extends Cr.Shape{constructor(t){super(function(t){return(t=t||{}).fillLinearGradientColorStops||t.fillRadialGradientColorStops||t.fillPatternImage||(t.fill=t.fill||"black"),t}(t)),this._partialTextX=0,this._partialTextY=0;for(var e=0;e<zr;e++)this.on(Lr[e]+"Change.konva",this._setTextData);this._setTextData()}_sceneFunc(t){var e=this.textArr,i=e.length;if(this.text()){var r,s=this.padding(),a=this.fontSize(),n=this.lineHeight()*a,o=this.verticalAlign(),h=this.direction(),l=0,d=this.align(),c=this.getWidth(),u=this.letterSpacing(),g=this.fill(),p=this.textDecoration(),m=-1!==p.indexOf("underline"),f=-1!==p.indexOf("line-through"),v=0,y=(v=n/2,0),_=0;for("rtl"===(h=h===Mr?t.direction:h)&&t.setAttr("direction",h),t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",Or),t.setAttr("textAlign",Dr),o===Or?l=(this.getHeight()-i*n-2*s)/2:"bottom"===o&&(l=this.getHeight()-i*n-2*s),t.translate(s,l+s),r=0;r<i;r++){y=0,_=0;var w,b,x,S=e[r],C=S.text,P=S.width,k=S.lastInParagraph;if(t.save(),"right"===d?y+=c-P-2*s:"center"===d&&(y+=(c-P-2*s)/2),m){t.save(),t.beginPath(),t.moveTo(y,v+_+Math.round(a/2)),b=0===(w=C.split(" ").length-1),x=d!==Fr||k?P:c-2*s,t.lineTo(y+Math.round(x),v+_+Math.round(a/2)),t.lineWidth=a/15;const e=this._getLinearGradient();t.strokeStyle=e||g,t.stroke(),t.restore()}if(f){t.save(),t.beginPath(),t.moveTo(y,v+_),b=0===(w=C.split(" ").length-1),x=d===Fr&&k&&!b?c-2*s:P,t.lineTo(y+Math.round(x),v+_),t.lineWidth=a/15;const e=this._getLinearGradient();t.strokeStyle=e||g,t.stroke(),t.restore()}if("rtl"===h||0===u&&d!==Fr)0!==u&&t.setAttr("letterSpacing",`${u}px`),this._partialTextX=y,this._partialTextY=v+_,this._partialText=C,t.fillStrokeShape(this);else{w=C.split(" ").length-1;for(var E=Er(C),A=0;A<E.length;A++){var T=E[A];" "!==T||k||d!==Fr||(y+=(c-2*s-P)/w),this._partialTextX=y,this._partialTextY=v+_,this._partialText=T,t.fillStrokeShape(this),y+=this.measureSize(T).width+u}}t.restore(),i>1&&(v+=n)}}}_hitFunc(t){var e=this.getWidth(),i=this.getHeight();t.beginPath(),t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}setText(t){var e=xr.Util._isString(t)?t:null==t?"":t+"";return this._setAttr("text",e),this}getWidth(){return this.attrs.width===Tr||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}getHeight(){return this.attrs.height===Tr||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return xr.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(t){var e,i=Gr(),r=this.fontSize();return i.save(),i.font=this._getContextFont(),e=i.measureText(t),i.restore(),{width:e.width,height:r}}_getContextFont(){return this.fontStyle()+Rr+this.fontVariant()+Rr+(this.fontSize()+"px ")+this.fontFamily().split(",").map((t=>{const e=(t=t.trim()).indexOf(" ")>=0,i=t.indexOf('"')>=0||t.indexOf("'")>=0;return e&&!i&&(t=`"${t}"`),t})).join(", ")}_addTextLine(t){this.align()===Fr&&(t=t.trim());var e=this._getTextWidth(t);return this.textArr.push({text:t,width:e,lastInParagraph:!1})}_getTextWidth(t){var e=this.letterSpacing(),i=t.length;return Gr().measureText(t).width+(i?e*(i-1):0)}_setTextData(){var t=this.text().split("\n"),e=+this.fontSize(),i=0,r=this.lineHeight()*e,s=this.attrs.width,a=this.attrs.height,n=s!==Tr&&void 0!==s,o=a!==Tr&&void 0!==a,h=this.padding(),l=s-2*h,d=a-2*h,c=0,u=this.wrap(),g="char"!==u&&u!==Ir,p=this.ellipsis();this.textArr=[],Gr().font=this._getContextFont();for(var m=p?this._getTextWidth("…"):0,f=0,v=t.length;f<v;++f){var y=t[f],_=this._getTextWidth(y);if(n&&_>l)for(;y.length>0;){for(var w=0,b=y.length,x="",S=0;w<b;){var C=w+b>>>1,P=y.slice(0,C+1),k=this._getTextWidth(P)+m;k<=l?(w=C+1,x=P,S=k):b=C}if(!x)break;if(g){var E,A=y[x.length];(E=(A===Rr||"-"===A)&&S<=l?x.length:Math.max(x.lastIndexOf(Rr),x.lastIndexOf("-"))+1)>0&&(w=E,x=x.slice(0,w),S=this._getTextWidth(x))}if(x=x.trimRight(),this._addTextLine(x),i=Math.max(i,S),c+=r,this._shouldHandleEllipsis(c)){this._tryToAddEllipsisToLastLine();break}if((y=(y=y.slice(w)).trimLeft()).length>0&&(_=this._getTextWidth(y))<=l){this._addTextLine(y),c+=r,i=Math.max(i,_);break}}else this._addTextLine(y),c+=r,i=Math.max(i,_),this._shouldHandleEllipsis(c)&&f<v-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),o&&c+r>d)break}this.textHeight=e,this.textWidth=i}_shouldHandleEllipsis(t){var e=+this.fontSize(),i=this.lineHeight()*e,r=this.attrs.height,s=r!==Tr&&void 0!==r,a=r-2*this.padding();return!(this.wrap()!==Ir)||s&&t+i>a}_tryToAddEllipsisToLastLine(){var t=this.attrs.width,e=t!==Tr&&void 0!==t,i=t-2*this.padding(),r=this.ellipsis(),s=this.textArr[this.textArr.length-1];if(s&&r){if(e)this._getTextWidth(s.text+"…")<i||(s.text=s.text.slice(0,s.text.length-3));this.textArr.splice(this.textArr.length-1,1),this._addTextLine(s.text+"…")}}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){const t=-1!==this.textDecoration().indexOf("underline")||-1!==this.textDecoration().indexOf("line-through"),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas()}}br.Text=Nr,Nr.prototype._fillFunc=function(t){t.fillText(this._partialText,this._partialTextX,this._partialTextY)},Nr.prototype._strokeFunc=function(t){t.setAttr("miterLimit",2),t.strokeText(this._partialText,this._partialTextX,this._partialTextY)},Nr.prototype.className="Text",Nr.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],(0,kr._registerNode)(Nr),Sr.Factory.overWriteSetter(Nr,"width",(0,Pr.getNumberOrAutoValidator)()),Sr.Factory.overWriteSetter(Nr,"height",(0,Pr.getNumberOrAutoValidator)()),Sr.Factory.addGetterSetter(Nr,"direction",Mr),Sr.Factory.addGetterSetter(Nr,"fontFamily","Arial"),Sr.Factory.addGetterSetter(Nr,"fontSize",12,(0,Pr.getNumberValidator)()),Sr.Factory.addGetterSetter(Nr,"fontStyle",Vr),Sr.Factory.addGetterSetter(Nr,"fontVariant",Vr),Sr.Factory.addGetterSetter(Nr,"padding",0,(0,Pr.getNumberValidator)()),Sr.Factory.addGetterSetter(Nr,"align",Dr),Sr.Factory.addGetterSetter(Nr,"verticalAlign","top"),Sr.Factory.addGetterSetter(Nr,"lineHeight",1,(0,Pr.getNumberValidator)()),Sr.Factory.addGetterSetter(Nr,"wrap","word"),Sr.Factory.addGetterSetter(Nr,"ellipsis",!1,(0,Pr.getBooleanValidator)()),Sr.Factory.addGetterSetter(Nr,"letterSpacing",0,(0,Pr.getNumberValidator)()),Sr.Factory.addGetterSetter(Nr,"text","",(0,Pr.getStringValidator)()),Sr.Factory.addGetterSetter(Nr,"textDecoration","");var Ur={};Object.defineProperty(Ur,"__esModule",{value:!0}),Ur.TextPath=void 0;const Wr=rt,jr=at,Br=ne,Hr=qe,Kr=br,Yr=nt,Xr=it;var Jr="normal";function qr(t){t.fillText(this.partialText,0,0)}function Zr(t){t.strokeText(this.partialText,0,0)}class $r extends Br.Shape{constructor(t){super(t),this.dummyCanvas=Wr.Util.createCanvasElement(),this.dataArray=[],this._readDataAttribute(),this.on("dataChange.konva",(function(){this._readDataAttribute(),this._setTextData()})),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_getTextPathLength(){return Hr.Path.getPathLength(this.dataArray)}_getPointAtLength(t){if(!this.attrs.data)return null;return t-1>this.pathLength?null:Hr.Path.getPointAtLengthOfDataArray(t,this.dataArray)}_readDataAttribute(){this.dataArray=Hr.Path.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(t){t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",this.textBaseline()),t.setAttr("textAlign","left"),t.save();var e=this.textDecoration(),i=this.fill(),r=this.fontSize(),s=this.glyphInfo;"underline"===e&&t.beginPath();for(var a=0;a<s.length;a++){t.save();var n=s[a].p0;t.translate(n.x,n.y),t.rotate(s[a].rotation),this.partialText=s[a].text,t.fillStrokeShape(this),"underline"===e&&(0===a&&t.moveTo(0,r/2+1),t.lineTo(r,r/2+1)),t.restore()}"underline"===e&&(t.strokeStyle=i,t.lineWidth=r/20,t.stroke()),t.restore()}_hitFunc(t){t.beginPath();var e=this.glyphInfo;if(e.length>=1){var i=e[0].p0;t.moveTo(i.x,i.y)}for(var r=0;r<e.length;r++){var s=e[r].p1;t.lineTo(s.x,s.y)}t.setAttr("lineWidth",this.fontSize()),t.setAttr("strokeStyle",this.colorKey),t.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return Wr.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(t){return Kr.Text.prototype.setText.call(this,t)}_getContextFont(){return Kr.Text.prototype._getContextFont.call(this)}_getTextSize(t){var e=this.dummyCanvas.getContext("2d");e.save(),e.font=this._getContextFont();var i=e.measureText(t);return e.restore(),{width:i.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const{width:t,height:e}=this._getTextSize(this.attrs.text);if(this.textWidth=t,this.textHeight=e,this.glyphInfo=[],!this.attrs.data)return null;const i=this.letterSpacing(),r=this.align(),s=this.kerningFunc(),a=Math.max(this.textWidth+((this.attrs.text||"").length-1)*i,0);let n=0;"center"===r&&(n=Math.max(0,this.pathLength/2-a/2)),"right"===r&&(n=Math.max(0,this.pathLength-a));const o=(0,Kr.stringToArray)(this.text());let h=n;for(var l=0;l<o.length;l++){const t=this._getPointAtLength(h);if(!t)return;let e=this._getTextSize(o[l]).width+i;if(" "===o[l]&&"justify"===r){const t=this.text().split(" ").length-1;e+=(this.pathLength-a)/t}const n=this._getPointAtLength(h+e);if(!n)return;const d=Hr.Path.getLineLength(t.x,t.y,n.x,n.y);let c=0;if(s)try{c=s(o[l-1],o[l])*this.fontSize()}catch(t){c=0}t.x+=c,n.x+=c,this.textWidth+=c;const u=Hr.Path.getPointOnLine(c+d/2,t.x,t.y,n.x,n.y),g=Math.atan2(n.y-t.y,n.x-t.x);this.glyphInfo.push({transposeX:u.x,transposeY:u.y,text:o[l],rotation:g,p0:t,p1:n}),h+=e}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};var t=[];this.glyphInfo.forEach((function(e){t.push(e.p0.x),t.push(e.p0.y),t.push(e.p1.x),t.push(e.p1.y)}));for(var e,i,r=t[0]||0,s=t[0]||0,a=t[1]||0,n=t[1]||0,o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],r=Math.min(r,e),s=Math.max(s,e),a=Math.min(a,i),n=Math.max(n,i);var h=this.fontSize();return{x:r-h/2,y:a-h/2,width:s-r+h,height:n-a+h}}destroy(){return Wr.Util.releaseCanvas(this.dummyCanvas),super.destroy()}}Ur.TextPath=$r,$r.prototype._fillFunc=qr,$r.prototype._strokeFunc=Zr,$r.prototype._fillFuncHit=qr,$r.prototype._strokeFuncHit=Zr,$r.prototype.className="TextPath",$r.prototype._attrsAffectingSize=["text","fontSize","data"],(0,Xr._registerNode)($r),jr.Factory.addGetterSetter($r,"data"),jr.Factory.addGetterSetter($r,"fontFamily","Arial"),jr.Factory.addGetterSetter($r,"fontSize",12,(0,Yr.getNumberValidator)()),jr.Factory.addGetterSetter($r,"fontStyle",Jr),jr.Factory.addGetterSetter($r,"align","left"),jr.Factory.addGetterSetter($r,"letterSpacing",0,(0,Yr.getNumberValidator)()),jr.Factory.addGetterSetter($r,"textBaseline","middle"),jr.Factory.addGetterSetter($r,"fontVariant",Jr),jr.Factory.addGetterSetter($r,"text",""),jr.Factory.addGetterSetter($r,"textDecoration",null),jr.Factory.addGetterSetter($r,"kerningFunc",null);var Qr={};Object.defineProperty(Qr,"__esModule",{value:!0}),Qr.Transformer=void 0;const ts=rt,es=at,is=st,rs=ne,ss=Wi,as=Se,ns=it,os=nt,hs=it;var ls="tr-konva",ds=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map((t=>t+`.${ls}`)).join(" "),cs="nodesRect",us=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],gs={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135};const ps="ontouchstart"in ns.Konva._global;var ms=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function fs(t,e,i){const r=i.x+(t.x-i.x)*Math.cos(e)-(t.y-i.y)*Math.sin(e),s=i.y+(t.x-i.x)*Math.sin(e)+(t.y-i.y)*Math.cos(e);return{...t,rotation:t.rotation+e,x:r,y:s}}function vs(t,e){const i=function(t){return{x:t.x+t.width/2*Math.cos(t.rotation)+t.height/2*Math.sin(-t.rotation),y:t.y+t.height/2*Math.cos(t.rotation)+t.width/2*Math.sin(t.rotation)}}(t);return fs(t,e,i)}let ys=0;class _s extends as.Group{constructor(t){super(t),this._movingAnchorName=null,this._transforming=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(ds,this.update),this.getNode()&&this.update()}attachTo(t){return this.setNode(t),this}setNode(t){return ts.Util.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([t])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return ls+this._id}setNodes(t=[]){this._nodes&&this._nodes.length&&this.detach();const e=t.filter((t=>!t.isAncestorOf(this)||(ts.Util.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1)));return this._nodes=t=e,1===t.length&&this.useSingleNodeRotation()?this.rotation(t[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach((t=>{const e=()=>{1===this.nodes().length&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),this._transforming||this.isDragging()||this.update()},i=t._attrsAffectingSize.map((t=>t+"Change."+this._getEventNamespace())).join(" ");t.on(i,e),t.on(us.map((t=>t+`.${this._getEventNamespace()}`)).join(" "),e),t.on(`absoluteTransformChange.${this._getEventNamespace()}`,e),this._proxyDrag(t)})),this._resetTransformCache(),!!this.findOne(".top-left")&&this.update(),this}_proxyDrag(t){let e;t.on(`dragstart.${this._getEventNamespace()}`,(i=>{e=t.getAbsolutePosition(),this.isDragging()||t===this.findOne(".back")||this.startDrag(i,!1)})),t.on(`dragmove.${this._getEventNamespace()}`,(i=>{if(!e)return;const r=t.getAbsolutePosition(),s=r.x-e.x,a=r.y-e.y;this.nodes().forEach((e=>{if(e===t)return;if(e.isDragging())return;const r=e.getAbsolutePosition();e.setAbsolutePosition({x:r.x+s,y:r.y+a}),e.startDrag(i)})),e=null}))}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach((t=>{t.off("."+this._getEventNamespace())})),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(cs),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(cs,this.__getNodeRect)}__getNodeShape(t,e=this.rotation(),i){var r=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),s=t.getAbsoluteScale(i),a=t.getAbsolutePosition(i),n=r.x*s.x-t.offsetX()*s.x,o=r.y*s.y-t.offsetY()*s.y;const h=(ns.Konva.getAngle(t.getAbsoluteRotation())+2*Math.PI)%(2*Math.PI);return fs({x:a.x+n*Math.cos(h)+o*Math.sin(-h),y:a.y+o*Math.cos(h)+n*Math.sin(h),width:r.width*s.x,height:r.height*s.y,rotation:h},-ns.Konva.getAngle(e),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};const t=[];this.nodes().map((e=>{const i=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()});var r=[{x:i.x,y:i.y},{x:i.x+i.width,y:i.y},{x:i.x+i.width,y:i.y+i.height},{x:i.x,y:i.y+i.height}],s=e.getAbsoluteTransform();r.forEach((function(e){var i=s.point(e);t.push(i)}))}));const e=new ts.Transform;e.rotate(-ns.Konva.getAngle(this.rotation()));var i=1/0,r=1/0,s=-1/0,a=-1/0;t.forEach((function(t){var n=e.point(t);void 0===i&&(i=s=n.x,r=a=n.y),i=Math.min(i,n.x),r=Math.min(r,n.y),s=Math.max(s,n.x),a=Math.max(a,n.y)})),e.invert();const n=e.point({x:i,y:r});return{x:n.x,y:n.y,width:s-i,height:a-r,rotation:ns.Konva.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),ms.forEach((t=>{this._createAnchor(t)})),this._createAnchor("rotater")}_createAnchor(t){var e=new ss.Rect({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:t+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:ps?10:"auto"}),i=this;e.on("mousedown touchstart",(function(t){i._handleMouseDown(t)})),e.on("dragstart",(t=>{e.stopDrag(),t.cancelBubble=!0})),e.on("dragend",(t=>{t.cancelBubble=!0})),e.on("mouseenter",(()=>{var i=ns.Konva.getAngle(this.rotation()),r=this.rotateAnchorCursor(),s=function(t,e,i){if("rotater"===t)return i;e+=ts.Util.degToRad(gs[t]||0);var r=(ts.Util.radToDeg(e)%360+360)%360;return ts.Util._inRange(r,337.5,360)||ts.Util._inRange(r,0,22.5)?"ns-resize":ts.Util._inRange(r,22.5,67.5)?"nesw-resize":ts.Util._inRange(r,67.5,112.5)?"ew-resize":ts.Util._inRange(r,112.5,157.5)?"nwse-resize":ts.Util._inRange(r,157.5,202.5)?"ns-resize":ts.Util._inRange(r,202.5,247.5)?"nesw-resize":ts.Util._inRange(r,247.5,292.5)?"ew-resize":ts.Util._inRange(r,292.5,337.5)?"nwse-resize":(ts.Util.error("Transformer has unknown angle for cursor detection: "+r),"pointer")}(t,i,r);e.getStage().content&&(e.getStage().content.style.cursor=s),this._cursorChange=!0})),e.on("mouseout",(()=>{e.getStage().content&&(e.getStage().content.style.cursor=""),this._cursorChange=!1})),this.add(e)}_createBack(){var t=new rs.Shape({name:"back",width:0,height:0,draggable:!0,sceneFunc(t,e){var i=e.getParent(),r=i.padding();t.beginPath(),t.rect(-r,-r,e.width()+2*r,e.height()+2*r),t.moveTo(e.width()/2,-r),i.rotateEnabled()&&i.rotateLineVisible()&&t.lineTo(e.width()/2,-i.rotateAnchorOffset()*ts.Util._sign(e.height())-r),t.fillStrokeShape(e)},hitFunc:(t,e)=>{if(this.shouldOverdrawWholeArea()){var i=this.padding();t.beginPath(),t.rect(-i,-i,e.width()+2*i,e.height()+2*i),t.fillStrokeShape(e)}}});this.add(t),this._proxyDrag(t),t.on("dragstart",(t=>{t.cancelBubble=!0})),t.on("dragmove",(t=>{t.cancelBubble=!0})),t.on("dragend",(t=>{t.cancelBubble=!0})),this.on("dragmove",(t=>{this.update()}))}_handleMouseDown(t){this._movingAnchorName=t.target.name().split(" ")[0];var e=this._getNodeRect(),i=e.width,r=e.height,s=Math.sqrt(Math.pow(i,2)+Math.pow(r,2));this.sin=Math.abs(r/s),this.cos=Math.abs(i/s),"undefined"!=typeof window&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;var a=t.target.getAbsolutePosition(),n=t.target.getStage().getPointerPosition();this._anchorDragOffset={x:n.x-a.x,y:n.y-a.y},ys++,this._fire("transformstart",{evt:t.evt,target:this.getNode()}),this._nodes.forEach((e=>{e._fire("transformstart",{evt:t.evt,target:e})}))}_handleMouseMove(t){var e,i,r,s=this.findOne("."+this._movingAnchorName),a=s.getStage();a.setPointersPositions(t);const n=a.getPointerPosition();let o={x:n.x-this._anchorDragOffset.x,y:n.y-this._anchorDragOffset.y};const h=s.getAbsolutePosition();this.anchorDragBoundFunc()&&(o=this.anchorDragBoundFunc()(h,o,t)),s.setAbsolutePosition(o);const l=s.getAbsolutePosition();if(h.x!==l.x||h.y!==l.y)if("rotater"!==this._movingAnchorName){var d,c=this.shiftBehavior();d="inverted"===c?this.keepRatio()&&!t.shiftKey:"none"===c?this.keepRatio():this.keepRatio()||t.shiftKey;var u=this.centeredScaling()||t.altKey;if("top-left"===this._movingAnchorName){if(d){var g=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};r=Math.sqrt(Math.pow(g.x-s.x(),2)+Math.pow(g.y-s.y(),2));var p=this.findOne(".top-left").x()>g.x?-1:1,m=this.findOne(".top-left").y()>g.y?-1:1;e=r*this.cos*p,i=r*this.sin*m,this.findOne(".top-left").x(g.x-e),this.findOne(".top-left").y(g.y-i)}}else if("top-center"===this._movingAnchorName)this.findOne(".top-left").y(s.y());else if("top-right"===this._movingAnchorName){if(d){g=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};r=Math.sqrt(Math.pow(s.x()-g.x,2)+Math.pow(g.y-s.y(),2));p=this.findOne(".top-right").x()<g.x?-1:1,m=this.findOne(".top-right").y()>g.y?-1:1;e=r*this.cos*p,i=r*this.sin*m,this.findOne(".top-right").x(g.x+e),this.findOne(".top-right").y(g.y-i)}var f=s.position();this.findOne(".top-left").y(f.y),this.findOne(".bottom-right").x(f.x)}else if("middle-left"===this._movingAnchorName)this.findOne(".top-left").x(s.x());else if("middle-right"===this._movingAnchorName)this.findOne(".bottom-right").x(s.x());else if("bottom-left"===this._movingAnchorName){if(d){g=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};r=Math.sqrt(Math.pow(g.x-s.x(),2)+Math.pow(s.y()-g.y,2));p=g.x<s.x()?-1:1,m=s.y()<g.y?-1:1;e=r*this.cos*p,i=r*this.sin*m,s.x(g.x-e),s.y(g.y+i)}f=s.position(),this.findOne(".top-left").x(f.x),this.findOne(".bottom-right").y(f.y)}else if("bottom-center"===this._movingAnchorName)this.findOne(".bottom-right").y(s.y());else if("bottom-right"===this._movingAnchorName){if(d){g=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};r=Math.sqrt(Math.pow(s.x()-g.x,2)+Math.pow(s.y()-g.y,2));p=this.findOne(".bottom-right").x()<g.x?-1:1,m=this.findOne(".bottom-right").y()<g.y?-1:1;e=r*this.cos*p,i=r*this.sin*m,this.findOne(".bottom-right").x(g.x+e),this.findOne(".bottom-right").y(g.y+i)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(u=this.centeredScaling()||t.altKey){var v=this.findOne(".top-left"),y=this.findOne(".bottom-right"),_=v.x(),w=v.y(),b=this.getWidth()-y.x(),x=this.getHeight()-y.y();y.move({x:-_,y:-w}),v.move({x:b,y:x})}var S=this.findOne(".top-left").getAbsolutePosition();e=S.x,i=S.y;var C=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),P=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:e,y:i,width:C,height:P,rotation:ns.Konva.getAngle(this.rotation())},t)}else{var k=this._getNodeRect();e=s.x()-k.width/2,i=-s.y()+k.height/2;let r=Math.atan2(-i,e)+Math.PI/2;k.height<0&&(r-=Math.PI);const a=ns.Konva.getAngle(this.rotation())+r,n=ns.Konva.getAngle(this.rotationSnapTolerance()),o=vs(k,function(t,e,i){let r=e;for(let s=0;s<t.length;s++){const a=ns.Konva.getAngle(t[s]),n=Math.abs(a-e)%(2*Math.PI);Math.min(n,2*Math.PI-n)<i&&(r=a)}return r}(this.rotationSnaps(),a,n)-k.rotation);this._fitNodesInto(o,t)}}_handleMouseUp(t){this._removeEvents(t)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(t){var e;if(this._transforming){this._transforming=!1,"undefined"!=typeof window&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));var i=this.getNode();ys--,this._fire("transformend",{evt:t,target:i}),null===(e=this.getLayer())||void 0===e||e.batchDraw(),i&&this._nodes.forEach((e=>{var i;e._fire("transformend",{evt:t,target:e}),null===(i=e.getLayer())||void 0===i||i.batchDraw()})),this._movingAnchorName=null}}_fitNodesInto(t,e){var i=this._getNodeRect();if(ts.Util._inRange(t.width,2*-this.padding()-1,1))return void this.update();if(ts.Util._inRange(t.height,2*-this.padding()-1,1))return void this.update();var r=new ts.Transform;if(r.rotate(ns.Konva.getAngle(this.rotation())),this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("left")>=0){const e=r.point({x:2*-this.padding(),y:0});t.x+=e.x,t.y+=e.y,t.width+=2*this.padding(),this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y}else if(this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("right")>=0){const e=r.point({x:2*this.padding(),y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.width+=2*this.padding()}if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("top")>=0){const e=r.point({x:0,y:2*-this.padding()});t.x+=e.x,t.y+=e.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.height+=2*this.padding()}else if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const e=r.point({x:0,y:2*this.padding()});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.height+=2*this.padding()}if(this.boundBoxFunc()){const e=this.boundBoxFunc()(i,t);e?t=e:ts.Util.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const s=1e7,a=new ts.Transform;a.translate(i.x,i.y),a.rotate(i.rotation),a.scale(i.width/s,i.height/s);const n=new ts.Transform,o=t.width/s,h=t.height/s;!1===this.flipEnabled()?(n.translate(t.x,t.y),n.rotate(t.rotation),n.translate(t.width<0?t.width:0,t.height<0?t.height:0),n.scale(Math.abs(o),Math.abs(h))):(n.translate(t.x,t.y),n.rotate(t.rotation),n.scale(o,h));const l=n.multiply(a.invert());this._nodes.forEach((t=>{var e;const i=t.getParent().getAbsoluteTransform(),r=t.getTransform().copy();r.translate(t.offsetX(),t.offsetY());const s=new ts.Transform;s.multiply(i.copy().invert()).multiply(l).multiply(i).multiply(r);const a=s.decompose();t.setAttrs(a),null===(e=t.getLayer())||void 0===e||e.batchDraw()})),this.rotation(ts.Util._getRotation(t.rotation)),this._nodes.forEach((t=>{this._fire("transform",{evt:e,target:t}),t._fire("transform",{evt:e,target:t})})),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(t,e){this.findOne(t).setAttrs(e)}update(){var t,e=this._getNodeRect();this.rotation(ts.Util._getRotation(e.rotation));var i=e.width,r=e.height,s=this.enabledAnchors(),a=this.resizeEnabled(),n=this.padding(),o=this.anchorSize();const h=this.find("._anchor");h.forEach((t=>{t.setAttrs({width:o,height:o,offsetX:o/2,offsetY:o/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})})),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:o/2+n,offsetY:o/2+n,visible:a&&s.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:i/2,y:0,offsetY:o/2+n,visible:a&&s.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:i,y:0,offsetX:o/2-n,offsetY:o/2+n,visible:a&&s.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:r/2,offsetX:o/2+n,visible:a&&s.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:i,y:r/2,offsetX:o/2-n,visible:a&&s.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:r,offsetX:o/2+n,offsetY:o/2-n,visible:a&&s.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:i/2,y:r,offsetY:o/2-n,visible:a&&s.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:i,y:r,offsetX:o/2-n,offsetY:o/2-n,visible:a&&s.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:i/2,y:-this.rotateAnchorOffset()*ts.Util._sign(r)-n,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:i,height:r,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0});const l=this.anchorStyleFunc();l&&h.forEach((t=>{l(t)})),null===(t=this.getLayer())||void 0===t||t.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();var t=this.findOne("."+this._movingAnchorName);t&&t.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),as.Group.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return is.Node.prototype.toObject.call(this)}clone(t){return is.Node.prototype.clone.call(this,t)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}}Qr.Transformer=_s,_s.isTransforming=()=>ys>0,_s.prototype.className="Transformer",(0,hs._registerNode)(_s),es.Factory.addGetterSetter(_s,"enabledAnchors",ms,(function(t){return t instanceof Array||ts.Util.warn("enabledAnchors value should be an array"),t instanceof Array&&t.forEach((function(t){-1===ms.indexOf(t)&&ts.Util.warn("Unknown anchor name: "+t+". Available names are: "+ms.join(", "))})),t||[]})),es.Factory.addGetterSetter(_s,"flipEnabled",!0,(0,os.getBooleanValidator)()),es.Factory.addGetterSetter(_s,"resizeEnabled",!0),es.Factory.addGetterSetter(_s,"anchorSize",10,(0,os.getNumberValidator)()),es.Factory.addGetterSetter(_s,"rotateEnabled",!0),es.Factory.addGetterSetter(_s,"rotateLineVisible",!0),es.Factory.addGetterSetter(_s,"rotationSnaps",[]),es.Factory.addGetterSetter(_s,"rotateAnchorOffset",50,(0,os.getNumberValidator)()),es.Factory.addGetterSetter(_s,"rotateAnchorCursor","crosshair"),es.Factory.addGetterSetter(_s,"rotationSnapTolerance",5,(0,os.getNumberValidator)()),es.Factory.addGetterSetter(_s,"borderEnabled",!0),es.Factory.addGetterSetter(_s,"anchorStroke","rgb(0, 161, 255)"),es.Factory.addGetterSetter(_s,"anchorStrokeWidth",1,(0,os.getNumberValidator)()),es.Factory.addGetterSetter(_s,"anchorFill","white"),es.Factory.addGetterSetter(_s,"anchorCornerRadius",0,(0,os.getNumberValidator)()),es.Factory.addGetterSetter(_s,"borderStroke","rgb(0, 161, 255)"),es.Factory.addGetterSetter(_s,"borderStrokeWidth",1,(0,os.getNumberValidator)()),es.Factory.addGetterSetter(_s,"borderDash"),es.Factory.addGetterSetter(_s,"keepRatio",!0),es.Factory.addGetterSetter(_s,"shiftBehavior","default"),es.Factory.addGetterSetter(_s,"centeredScaling",!1),es.Factory.addGetterSetter(_s,"ignoreStroke",!1),es.Factory.addGetterSetter(_s,"padding",0,(0,os.getNumberValidator)()),es.Factory.addGetterSetter(_s,"node"),es.Factory.addGetterSetter(_s,"nodes"),es.Factory.addGetterSetter(_s,"boundBoxFunc"),es.Factory.addGetterSetter(_s,"anchorDragBoundFunc"),es.Factory.addGetterSetter(_s,"anchorStyleFunc"),es.Factory.addGetterSetter(_s,"shouldOverdrawWholeArea",!1),es.Factory.addGetterSetter(_s,"useSingleNodeRotation",!0),es.Factory.backCompat(_s,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});var ws={};Object.defineProperty(ws,"__esModule",{value:!0}),ws.Wedge=void 0;const bs=at,xs=ne,Ss=it,Cs=nt,Ps=it;class ks extends xs.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.radius(),0,Ss.Konva.getAngle(this.angle()),this.clockwise()),t.lineTo(0,0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}}ws.Wedge=ks,ks.prototype.className="Wedge",ks.prototype._centroid=!0,ks.prototype._attrsAffectingSize=["radius"],(0,Ps._registerNode)(ks),bs.Factory.addGetterSetter(ks,"radius",0,(0,Cs.getNumberValidator)()),bs.Factory.addGetterSetter(ks,"angle",0,(0,Cs.getNumberValidator)()),bs.Factory.addGetterSetter(ks,"clockwise",!1),bs.Factory.backCompat(ks,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});var Es={};Object.defineProperty(Es,"__esModule",{value:!0}),Es.Blur=void 0;const As=at,Ts=st,Ms=nt;function Fs(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var Ds=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],Os=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];Es.Blur=function(t){var e=Math.round(this.blurRadius());e>0&&function(t,e){var i,r,s,a,n,o,h,l,d,c,u,g,p,m,f,v,y,_,w,b,x,S,C,P,k=t.data,E=t.width,A=t.height,T=e+e+1,M=E-1,F=A-1,D=e+1,O=D*(D+1)/2,V=new Fs,R=null,I=V,L=null,z=null,G=Ds[e],N=Os[e];for(s=1;s<T;s++)I=I.next=new Fs,s===D&&(R=I);for(I.next=V,h=o=0,r=0;r<A;r++){for(v=y=_=w=l=d=c=u=0,g=D*(b=k[o]),p=D*(x=k[o+1]),m=D*(S=k[o+2]),f=D*(C=k[o+3]),l+=O*b,d+=O*x,c+=O*S,u+=O*C,I=V,s=0;s<D;s++)I.r=b,I.g=x,I.b=S,I.a=C,I=I.next;for(s=1;s<D;s++)a=o+((M<s?M:s)<<2),l+=(I.r=b=k[a])*(P=D-s),d+=(I.g=x=k[a+1])*P,c+=(I.b=S=k[a+2])*P,u+=(I.a=C=k[a+3])*P,v+=b,y+=x,_+=S,w+=C,I=I.next;for(L=V,z=R,i=0;i<E;i++)k[o+3]=C=u*G>>N,0!==C?(C=255/C,k[o]=(l*G>>N)*C,k[o+1]=(d*G>>N)*C,k[o+2]=(c*G>>N)*C):k[o]=k[o+1]=k[o+2]=0,l-=g,d-=p,c-=m,u-=f,g-=L.r,p-=L.g,m-=L.b,f-=L.a,a=h+((a=i+e+1)<M?a:M)<<2,l+=v+=L.r=k[a],d+=y+=L.g=k[a+1],c+=_+=L.b=k[a+2],u+=w+=L.a=k[a+3],L=L.next,g+=b=z.r,p+=x=z.g,m+=S=z.b,f+=C=z.a,v-=b,y-=x,_-=S,w-=C,z=z.next,o+=4;h+=E}for(i=0;i<E;i++){for(y=_=w=v=d=c=u=l=0,g=D*(b=k[o=i<<2]),p=D*(x=k[o+1]),m=D*(S=k[o+2]),f=D*(C=k[o+3]),l+=O*b,d+=O*x,c+=O*S,u+=O*C,I=V,s=0;s<D;s++)I.r=b,I.g=x,I.b=S,I.a=C,I=I.next;for(n=E,s=1;s<=e;s++)o=n+i<<2,l+=(I.r=b=k[o])*(P=D-s),d+=(I.g=x=k[o+1])*P,c+=(I.b=S=k[o+2])*P,u+=(I.a=C=k[o+3])*P,v+=b,y+=x,_+=S,w+=C,I=I.next,s<F&&(n+=E);for(o=i,L=V,z=R,r=0;r<A;r++)k[3+(a=o<<2)]=C=u*G>>N,C>0?(C=255/C,k[a]=(l*G>>N)*C,k[a+1]=(d*G>>N)*C,k[a+2]=(c*G>>N)*C):k[a]=k[a+1]=k[a+2]=0,l-=g,d-=p,c-=m,u-=f,g-=L.r,p-=L.g,m-=L.b,f-=L.a,a=i+((a=r+D)<F?a:F)*E<<2,l+=v+=L.r=k[a],d+=y+=L.g=k[a+1],c+=_+=L.b=k[a+2],u+=w+=L.a=k[a+3],L=L.next,g+=b=z.r,p+=x=z.g,m+=S=z.b,f+=C=z.a,v-=b,y-=x,_-=S,w-=C,z=z.next,o+=E}}(t,e)},As.Factory.addGetterSetter(Ts.Node,"blurRadius",0,(0,Ms.getNumberValidator)(),As.Factory.afterSetFilter);var Vs={};Object.defineProperty(Vs,"__esModule",{value:!0}),Vs.Brighten=void 0;const Rs=at,Is=st,Ls=nt;Vs.Brighten=function(t){var e,i=255*this.brightness(),r=t.data,s=r.length;for(e=0;e<s;e+=4)r[e]+=i,r[e+1]+=i,r[e+2]+=i},Rs.Factory.addGetterSetter(Is.Node,"brightness",0,(0,Ls.getNumberValidator)(),Rs.Factory.afterSetFilter);var zs={};Object.defineProperty(zs,"__esModule",{value:!0}),zs.Contrast=void 0;const Gs=at,Ns=st,Us=nt;zs.Contrast=function(t){var e,i=Math.pow((this.contrast()+100)/100,2),r=t.data,s=r.length,a=150,n=150,o=150;for(e=0;e<s;e+=4)a=r[e],n=r[e+1],o=r[e+2],a/=255,a-=.5,a*=i,a+=.5,n/=255,n-=.5,n*=i,n+=.5,o/=255,o-=.5,o*=i,o+=.5,a=(a*=255)<0?0:a>255?255:a,n=(n*=255)<0?0:n>255?255:n,o=(o*=255)<0?0:o>255?255:o,r[e]=a,r[e+1]=n,r[e+2]=o},Gs.Factory.addGetterSetter(Ns.Node,"contrast",0,(0,Us.getNumberValidator)(),Gs.Factory.afterSetFilter);var Ws={};Object.defineProperty(Ws,"__esModule",{value:!0}),Ws.Emboss=void 0;const js=at,Bs=st,Hs=rt,Ks=nt;Ws.Emboss=function(t){var e=10*this.embossStrength(),i=255*this.embossWhiteLevel(),r=this.embossDirection(),s=this.embossBlend(),a=0,n=0,o=t.data,h=t.width,l=t.height,d=4*h,c=l;switch(r){case"top-left":a=-1,n=-1;break;case"top":a=-1,n=0;break;case"top-right":a=-1,n=1;break;case"right":a=0,n=1;break;case"bottom-right":a=1,n=1;break;case"bottom":a=1,n=0;break;case"bottom-left":a=1,n=-1;break;case"left":a=0,n=-1;break;default:Hs.Util.error("Unknown emboss direction: "+r)}do{var u=(c-1)*d,g=a;c+g<1&&(g=0),c+g>l&&(g=0);var p=(c-1+g)*h*4,m=h;do{var f=u+4*(m-1),v=n;m+v<1&&(v=0),m+v>h&&(v=0);var y=p+4*(m-1+v),_=o[f]-o[y],w=o[f+1]-o[y+1],b=o[f+2]-o[y+2],x=_,S=x>0?x:-x;if((w>0?w:-w)>S&&(x=w),(b>0?b:-b)>S&&(x=b),x*=e,s){var C=o[f]+x,P=o[f+1]+x,k=o[f+2]+x;o[f]=C>255?255:C<0?0:C,o[f+1]=P>255?255:P<0?0:P,o[f+2]=k>255?255:k<0?0:k}else{var E=i-x;E<0?E=0:E>255&&(E=255),o[f]=o[f+1]=o[f+2]=E}}while(--m)}while(--c)},js.Factory.addGetterSetter(Bs.Node,"embossStrength",.5,(0,Ks.getNumberValidator)(),js.Factory.afterSetFilter),js.Factory.addGetterSetter(Bs.Node,"embossWhiteLevel",.5,(0,Ks.getNumberValidator)(),js.Factory.afterSetFilter),js.Factory.addGetterSetter(Bs.Node,"embossDirection","top-left",null,js.Factory.afterSetFilter),js.Factory.addGetterSetter(Bs.Node,"embossBlend",!1,null,js.Factory.afterSetFilter);var Ys={};Object.defineProperty(Ys,"__esModule",{value:!0}),Ys.Enhance=void 0;const Xs=at,Js=st,qs=nt;function Zs(t,e,i,r,s){var a=i-e,n=s-r;return 0===a?r+n/2:0===n?r:n*((t-e)/a)+r}Ys.Enhance=function(t){var e,i,r,s,a=t.data,n=a.length,o=a[0],h=o,l=a[1],d=l,c=a[2],u=c,g=this.enhance();if(0!==g){for(s=0;s<n;s+=4)(e=a[s+0])<o?o=e:e>h&&(h=e),(i=a[s+1])<l?l=i:i>d&&(d=i),(r=a[s+2])<c?c=r:r>u&&(u=r);var p,m,f,v,y,_,w,b,x;for(h===o&&(h=255,o=0),d===l&&(d=255,l=0),u===c&&(u=255,c=0),g>0?(m=h+g*(255-h),f=o-g*(o-0),y=d+g*(255-d),_=l-g*(l-0),b=u+g*(255-u),x=c-g*(c-0)):(m=h+g*(h-(p=.5*(h+o))),f=o+g*(o-p),y=d+g*(d-(v=.5*(d+l))),_=l+g*(l-v),b=u+g*(u-(w=.5*(u+c))),x=c+g*(c-w)),s=0;s<n;s+=4)a[s+0]=Zs(a[s+0],o,h,f,m),a[s+1]=Zs(a[s+1],l,d,_,y),a[s+2]=Zs(a[s+2],c,u,x,b)}},Xs.Factory.addGetterSetter(Js.Node,"enhance",0,(0,qs.getNumberValidator)(),Xs.Factory.afterSetFilter);var $s={};Object.defineProperty($s,"__esModule",{value:!0}),$s.Grayscale=void 0;$s.Grayscale=function(t){var e,i,r=t.data,s=r.length;for(e=0;e<s;e+=4)i=.34*r[e]+.5*r[e+1]+.16*r[e+2],r[e]=i,r[e+1]=i,r[e+2]=i};var Qs={};Object.defineProperty(Qs,"__esModule",{value:!0}),Qs.HSL=void 0;const ta=at,ea=st,ia=nt;ta.Factory.addGetterSetter(ea.Node,"hue",0,(0,ia.getNumberValidator)(),ta.Factory.afterSetFilter),ta.Factory.addGetterSetter(ea.Node,"saturation",0,(0,ia.getNumberValidator)(),ta.Factory.afterSetFilter),ta.Factory.addGetterSetter(ea.Node,"luminance",0,(0,ia.getNumberValidator)(),ta.Factory.afterSetFilter);Qs.HSL=function(t){var e,i,r,s,a,n=t.data,o=n.length,h=Math.pow(2,this.saturation()),l=Math.abs(this.hue()+360)%360,d=127*this.luminance(),c=1*h*Math.cos(l*Math.PI/180),u=1*h*Math.sin(l*Math.PI/180),g=.299+.701*c+.167*u,p=.587-.587*c+.33*u,m=.114-.114*c-.497*u,f=.299-.299*c-.328*u,v=.587+.413*c+.035*u,y=.114-.114*c+.293*u,_=.299-.3*c+1.25*u,w=.587-.586*c-1.05*u,b=.114+.886*c-.2*u;for(e=0;e<o;e+=4)i=n[e+0],r=n[e+1],s=n[e+2],a=n[e+3],n[e+0]=g*i+p*r+m*s+d,n[e+1]=f*i+v*r+y*s+d,n[e+2]=_*i+w*r+b*s+d,n[e+3]=a};var ra={};Object.defineProperty(ra,"__esModule",{value:!0}),ra.HSV=void 0;const sa=at,aa=st,na=nt;ra.HSV=function(t){var e,i,r,s,a,n=t.data,o=n.length,h=Math.pow(2,this.value()),l=Math.pow(2,this.saturation()),d=Math.abs(this.hue()+360)%360,c=h*l*Math.cos(d*Math.PI/180),u=h*l*Math.sin(d*Math.PI/180),g=.299*h+.701*c+.167*u,p=.587*h-.587*c+.33*u,m=.114*h-.114*c-.497*u,f=.299*h-.299*c-.328*u,v=.587*h+.413*c+.035*u,y=.114*h-.114*c+.293*u,_=.299*h-.3*c+1.25*u,w=.587*h-.586*c-1.05*u,b=.114*h+.886*c-.2*u;for(e=0;e<o;e+=4)i=n[e+0],r=n[e+1],s=n[e+2],a=n[e+3],n[e+0]=g*i+p*r+m*s,n[e+1]=f*i+v*r+y*s,n[e+2]=_*i+w*r+b*s,n[e+3]=a},sa.Factory.addGetterSetter(aa.Node,"hue",0,(0,na.getNumberValidator)(),sa.Factory.afterSetFilter),sa.Factory.addGetterSetter(aa.Node,"saturation",0,(0,na.getNumberValidator)(),sa.Factory.afterSetFilter),sa.Factory.addGetterSetter(aa.Node,"value",0,(0,na.getNumberValidator)(),sa.Factory.afterSetFilter);var oa={};Object.defineProperty(oa,"__esModule",{value:!0}),oa.Invert=void 0;oa.Invert=function(t){var e,i=t.data,r=i.length;for(e=0;e<r;e+=4)i[e]=255-i[e],i[e+1]=255-i[e+1],i[e+2]=255-i[e+2]};var ha={};Object.defineProperty(ha,"__esModule",{value:!0}),ha.Kaleidoscope=void 0;const la=at,da=st,ca=rt,ua=nt;ha.Kaleidoscope=function(t){var e,i,r,s,a,n,o,h,l,d=t.width,c=t.height,u=Math.round(this.kaleidoscopePower()),g=Math.round(this.kaleidoscopeAngle()),p=Math.floor(d*(g%360)/360);if(!(u<1)){var m=ca.Util.createCanvasElement();m.width=d,m.height=c;var f=m.getContext("2d").getImageData(0,0,d,c);ca.Util.releaseCanvas(m),function(t,e,i){var r,s,a,n,o=t.data,h=e.data,l=t.width,d=t.height,c=i.polarCenterX||l/2,u=i.polarCenterY||d/2,g=0,p=0,m=0,f=0,v=Math.sqrt(c*c+u*u);s=l-c,a=d-u,v=(n=Math.sqrt(s*s+a*a))>v?n:v;var y,_,w,b,x=d,S=l,C=360/S*Math.PI/180;for(_=0;_<S;_+=1)for(w=Math.sin(_*C),b=Math.cos(_*C),y=0;y<x;y+=1)s=Math.floor(c+v*y/x*b),g=o[0+(r=4*((a=Math.floor(u+v*y/x*w))*l+s))],p=o[r+1],m=o[r+2],f=o[r+3],h[0+(r=4*(_+y*l))]=g,h[r+1]=p,h[r+2]=m,h[r+3]=f}(t,f,{polarCenterX:d/2,polarCenterY:c/2});for(var v=d/Math.pow(2,u);v<=8;)v*=2,u-=1;var y=v=Math.ceil(v),_=0,w=y,b=1;for(p+v>d&&(_=y,w=0,b=-1),i=0;i<c;i+=1)for(e=_;e!==w;e+=b)h=4*(d*i+Math.round(e+p)%d),s=f.data[h+0],a=f.data[h+1],n=f.data[h+2],o=f.data[h+3],l=4*(d*i+e),f.data[l+0]=s,f.data[l+1]=a,f.data[l+2]=n,f.data[l+3]=o;for(i=0;i<c;i+=1)for(y=Math.floor(v),r=0;r<u;r+=1){for(e=0;e<y+1;e+=1)h=4*(d*i+e),s=f.data[h+0],a=f.data[h+1],n=f.data[h+2],o=f.data[h+3],l=4*(d*i+2*y-e-1),f.data[l+0]=s,f.data[l+1]=a,f.data[l+2]=n,f.data[l+3]=o;y*=2}!function(t,e,i){var r,s,a,n,o,h,l=t.data,d=e.data,c=t.width,u=t.height,g=i.polarCenterX||c/2,p=i.polarCenterY||u/2,m=0,f=0,v=0,y=0,_=Math.sqrt(g*g+p*p);s=c-g,a=u-p,_=(h=Math.sqrt(s*s+a*a))>_?h:_;var w,b,x,S=u,C=c,P=i.polarRotation||0;for(s=0;s<c;s+=1)for(a=0;a<u;a+=1)n=s-g,o=a-p,w=Math.sqrt(n*n+o*o)*S/_,b=(b=(180*Math.atan2(o,n)/Math.PI+360+P)%360)*C/360,x=Math.floor(b),m=l[0+(r=4*(Math.floor(w)*c+x))],f=l[r+1],v=l[r+2],y=l[r+3],d[0+(r=4*(a*c+s))]=m,d[r+1]=f,d[r+2]=v,d[r+3]=y}(f,t,{polarRotation:0})}},la.Factory.addGetterSetter(da.Node,"kaleidoscopePower",2,(0,ua.getNumberValidator)(),la.Factory.afterSetFilter),la.Factory.addGetterSetter(da.Node,"kaleidoscopeAngle",0,(0,ua.getNumberValidator)(),la.Factory.afterSetFilter);var ga={};Object.defineProperty(ga,"__esModule",{value:!0}),ga.Mask=void 0;const pa=at,ma=st,fa=nt;function va(t,e,i){var r=4*(i*t.width+e),s=[];return s.push(t.data[r++],t.data[r++],t.data[r++],t.data[r++]),s}function ya(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2))}ga.Mask=function(t){var e=function(t,e){var i=va(t,0,0),r=va(t,t.width-1,0),s=va(t,0,t.height-1),a=va(t,t.width-1,t.height-1),n=e||10;if(ya(i,r)<n&&ya(r,a)<n&&ya(a,s)<n&&ya(s,i)<n){for(var o=function(t){for(var e=[0,0,0],i=0;i<t.length;i++)e[0]+=t[i][0],e[1]+=t[i][1],e[2]+=t[i][2];return e[0]/=t.length,e[1]/=t.length,e[2]/=t.length,e}([r,i,a,s]),h=[],l=0;l<t.width*t.height;l++){var d=ya(o,[t.data[4*l],t.data[4*l+1],t.data[4*l+2]]);h[l]=d<n?0:255}return h}}(t,this.threshold());return e&&function(t,e){for(var i=0;i<t.width*t.height;i++)t.data[4*i+3]=e[i]}(t,e=function(t,e,i){for(var r=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],s=Math.round(Math.sqrt(r.length)),a=Math.floor(s/2),n=[],o=0;o<i;o++)for(var h=0;h<e;h++){for(var l=o*e+h,d=0,c=0;c<s;c++)for(var u=0;u<s;u++){var g=o+c-a,p=h+u-a;if(g>=0&&g<i&&p>=0&&p<e){var m=r[c*s+u];d+=t[g*e+p]*m}}n[l]=d}return n}(e=function(t,e,i){for(var r=[1,1,1,1,1,1,1,1,1],s=Math.round(Math.sqrt(r.length)),a=Math.floor(s/2),n=[],o=0;o<i;o++)for(var h=0;h<e;h++){for(var l=o*e+h,d=0,c=0;c<s;c++)for(var u=0;u<s;u++){var g=o+c-a,p=h+u-a;if(g>=0&&g<i&&p>=0&&p<e){var m=r[c*s+u];d+=t[g*e+p]*m}}n[l]=d>=1020?255:0}return n}(e=function(t,e,i){for(var r=[1,1,1,1,0,1,1,1,1],s=Math.round(Math.sqrt(r.length)),a=Math.floor(s/2),n=[],o=0;o<i;o++)for(var h=0;h<e;h++){for(var l=o*e+h,d=0,c=0;c<s;c++)for(var u=0;u<s;u++){var g=o+c-a,p=h+u-a;if(g>=0&&g<i&&p>=0&&p<e){var m=r[c*s+u];d+=t[g*e+p]*m}}n[l]=2040===d?255:0}return n}(e,t.width,t.height),t.width,t.height),t.width,t.height)),t},pa.Factory.addGetterSetter(ma.Node,"threshold",0,(0,fa.getNumberValidator)(),pa.Factory.afterSetFilter);var _a={};Object.defineProperty(_a,"__esModule",{value:!0}),_a.Noise=void 0;const wa=at,ba=st,xa=nt;_a.Noise=function(t){var e,i=255*this.noise(),r=t.data,s=r.length,a=i/2;for(e=0;e<s;e+=4)r[e+0]+=a-2*a*Math.random(),r[e+1]+=a-2*a*Math.random(),r[e+2]+=a-2*a*Math.random()},wa.Factory.addGetterSetter(ba.Node,"noise",.2,(0,xa.getNumberValidator)(),wa.Factory.afterSetFilter);var Sa={};Object.defineProperty(Sa,"__esModule",{value:!0}),Sa.Pixelate=void 0;const Ca=at,Pa=rt,ka=st,Ea=nt;Sa.Pixelate=function(t){var e,i,r,s,a,n,o,h,l,d,c,u,g,p,m=Math.ceil(this.pixelSize()),f=t.width,v=t.height,y=Math.ceil(f/m),_=Math.ceil(v/m),w=t.data;if(m<=0)Pa.Util.error("pixelSize value can not be <= 0");else for(u=0;u<y;u+=1)for(g=0;g<_;g+=1){for(s=0,a=0,n=0,o=0,l=(h=u*m)+m,c=(d=g*m)+m,p=0,e=h;e<l;e+=1)if(!(e>=f))for(i=d;i<c;i+=1)i>=v||(s+=w[(r=4*(f*i+e))+0],a+=w[r+1],n+=w[r+2],o+=w[r+3],p+=1);for(s/=p,a/=p,n/=p,o/=p,e=h;e<l;e+=1)if(!(e>=f))for(i=d;i<c;i+=1)i>=v||(w[(r=4*(f*i+e))+0]=s,w[r+1]=a,w[r+2]=n,w[r+3]=o)}},Ca.Factory.addGetterSetter(ka.Node,"pixelSize",8,(0,Ea.getNumberValidator)(),Ca.Factory.afterSetFilter);var Aa={};Object.defineProperty(Aa,"__esModule",{value:!0}),Aa.Posterize=void 0;const Ta=at,Ma=st,Fa=nt;Aa.Posterize=function(t){var e,i=Math.round(254*this.levels())+1,r=t.data,s=r.length,a=255/i;for(e=0;e<s;e+=1)r[e]=Math.floor(r[e]/a)*a},Ta.Factory.addGetterSetter(Ma.Node,"levels",.5,(0,Fa.getNumberValidator)(),Ta.Factory.afterSetFilter);var Da={};Object.defineProperty(Da,"__esModule",{value:!0}),Da.RGB=void 0;const Oa=at,Va=st,Ra=nt;Da.RGB=function(t){var e,i,r=t.data,s=r.length,a=this.red(),n=this.green(),o=this.blue();for(e=0;e<s;e+=4)i=(.34*r[e]+.5*r[e+1]+.16*r[e+2])/255,r[e]=i*a,r[e+1]=i*n,r[e+2]=i*o,r[e+3]=r[e+3]},Oa.Factory.addGetterSetter(Va.Node,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),Oa.Factory.addGetterSetter(Va.Node,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),Oa.Factory.addGetterSetter(Va.Node,"blue",0,Ra.RGBComponent,Oa.Factory.afterSetFilter);var Ia={};Object.defineProperty(Ia,"__esModule",{value:!0}),Ia.RGBA=void 0;const La=at,za=st,Ga=nt;Ia.RGBA=function(t){var e,i,r=t.data,s=r.length,a=this.red(),n=this.green(),o=this.blue(),h=this.alpha();for(e=0;e<s;e+=4)i=1-h,r[e]=a*h+r[e]*i,r[e+1]=n*h+r[e+1]*i,r[e+2]=o*h+r[e+2]*i},La.Factory.addGetterSetter(za.Node,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),La.Factory.addGetterSetter(za.Node,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),La.Factory.addGetterSetter(za.Node,"blue",0,Ga.RGBComponent,La.Factory.afterSetFilter),La.Factory.addGetterSetter(za.Node,"alpha",1,(function(t){return this._filterUpToDate=!1,t>1?1:t<0?0:t}));var Na={};Object.defineProperty(Na,"__esModule",{value:!0}),Na.Sepia=void 0;Na.Sepia=function(t){var e,i,r,s,a=t.data,n=a.length;for(e=0;e<n;e+=4)i=a[e+0],r=a[e+1],s=a[e+2],a[e+0]=Math.min(255,.393*i+.769*r+.189*s),a[e+1]=Math.min(255,.349*i+.686*r+.168*s),a[e+2]=Math.min(255,.272*i+.534*r+.131*s)};var Ua={};Object.defineProperty(Ua,"__esModule",{value:!0}),Ua.Solarize=void 0;Ua.Solarize=function(t){var e=t.data,i=t.width,r=4*i,s=t.height;do{var a=(s-1)*r,n=i;do{var o=a+4*(n-1),h=e[o],l=e[o+1],d=e[o+2];h>127&&(h=255-h),l>127&&(l=255-l),d>127&&(d=255-d),e[o]=h,e[o+1]=l,e[o+2]=d}while(--n)}while(--s)};var Wa={};Object.defineProperty(Wa,"__esModule",{value:!0}),Wa.Threshold=void 0;const ja=at,Ba=st,Ha=nt;Wa.Threshold=function(t){var e,i=255*this.threshold(),r=t.data,s=r.length;for(e=0;e<s;e+=1)r[e]=r[e]<i?0:255},ja.Factory.addGetterSetter(Ba.Node,"threshold",.5,(0,Ha.getNumberValidator)(),ja.Factory.afterSetFilter),Object.defineProperty(tt,"__esModule",{value:!0}),tt.Konva=void 0;const Ka=et,Ya=Ve,Xa=Ue,Ja=li,qa=mi,Za=bi,$a=Ai,Qa=We,tn=qe,en=Wi,rn=Ji,sn=er,an=hr,nn=mr,on=br,hn=Ur,ln=Qr,dn=ws,cn=Es,un=Vs,gn=zs,pn=Ws,mn=Ys,fn=$s,vn=Qs,yn=ra,_n=oa,wn=ha,bn=ga,xn=_a,Sn=Sa,Cn=Aa,Pn=Da,kn=Ia,En=Na,An=Ua,Tn=Wa;tt.Konva=Ka.Konva.Util._assign(Ka.Konva,{Arc:Ya.Arc,Arrow:Xa.Arrow,Circle:Ja.Circle,Ellipse:qa.Ellipse,Image:Za.Image,Label:$a.Label,Tag:$a.Tag,Line:Qa.Line,Path:tn.Path,Rect:en.Rect,RegularPolygon:rn.RegularPolygon,Ring:sn.Ring,Sprite:an.Sprite,Star:nn.Star,Text:on.Text,TextPath:hn.TextPath,Transformer:ln.Transformer,Wedge:dn.Wedge,Filters:{Blur:cn.Blur,Brighten:un.Brighten,Contrast:gn.Contrast,Emboss:pn.Emboss,Enhance:mn.Enhance,Grayscale:fn.Grayscale,HSL:vn.HSL,HSV:yn.HSV,Invert:_n.Invert,Kaleidoscope:wn.Kaleidoscope,Mask:bn.Mask,Noise:xn.Noise,Pixelate:Sn.Pixelate,Posterize:Cn.Posterize,RGB:Pn.RGB,RGBA:kn.RGBA,Sepia:En.Sepia,Solarize:An.Solarize,Threshold:Tn.Threshold}});var Mn=Q.exports;Object.defineProperty(Mn,"__esModule",{value:!0});const Fn=tt;Q.exports=Fn.Konva;var Dn=$(Q.exports);class On{get HexColor(){return"#"+this._hex}get RGB(){return{r:this.R,g:this.G,b:this.B}}constructor(t,e,i){this.setColor(t,e,i)}setColor(t,e,i){this.R=t,this.G=e,this.B=i,this._hex=this.rgbToHex(t,e,i)}rgbToHex(t,e,i){const r=t=>{const e=t.toString(16);return"0"===e?"00":e};return r(t)+r(e)+r(i)}}const Vn=new Map([["solid",[]],["dot",[30,30,.001,30]],["dash",[30,30]]]);class Rn{constructor(t,e=null){var i,r;if(e)return void(this._ref=e);if(!t.points)return;const s=[];t.points.forEach((t=>s.push(t.x,t.y))),this._ref=new Dn.Line({stroke:null!==(i=t.color)&&void 0!==i?i:"#ff0000",strokeWidth:null!==(r=t.width)&&void 0!==r?r:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:s,draggable:!0,strokeScaleEnabled:!1,dash:Vn.get(t.type)||[]}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"line"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){return this._ref.points()}setLineWidth(t){this._ref.strokeWidth(t)}getLineWidth(){return this._ref.strokeWidth()}getLineType(){let t;switch(this._ref.dash()||[]){case Vn.get("dot"):t="dot";break;case Vn.get("dash"):t="dash";break;default:t="solid"}return t}setLineType(t){const e=Vn.get(t);e&&this._ref.dash(e)}addPoints(t){let e=this._ref.points();t.forEach((t=>{e=e.concat([t.x,t.y])})),this._ref.points(e)}}class In{constructor(t,e=null){var i,r,s;this.TEXT_FONT_FAMILY="Calibri",e?this._ref=e:t&&t.text&&(this._ref=new Dn.Text({x:t.position.x,y:t.position.y,text:t.text,fontSize:null!==(i=t.fontSize)&&void 0!==i?i:34,fontFamily:this.TEXT_FONT_FAMILY,fill:null!==(r=t.color)&&void 0!==r?r:"#ff0000",align:"left",draggable:!0,rotation:null!==(s=t.rotation)&&void 0!==s?s:0}),this._ref.id(this._ref._id.toString()))}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"text"}getColor(){return this._ref.fill()}setColor(t){this._ref.fill(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getText(){return this._ref.text()}setText(t){this._ref.text(t)}getPosition(){return this._ref.getPosition()}setPosition(t,e){this._ref.setPosition({x:t,y:e})}getFontSize(){return this._ref.fontSize()}setFontSize(t){this._ref.fontSize(t)}}class Ln{constructor(t,e=null){var i,r,s,a;e?this._ref=e:t.position&&(this._ref=new Dn.Rect({stroke:null!==(i=t.color)&&void 0!==i?i:"#ff0000",strokeWidth:null!==(r=t.lineWidth)&&void 0!==r?r:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",x:t.position.x,y:t.position.y,width:null!==(s=t.width)&&void 0!==s?s:200,height:null!==(a=t.height)&&void 0!==a?a:200,draggable:!0,strokeScaleEnabled:!1}),this._ref.id(this._ref._id.toString()))}getPosition(){return this._ref.position()}getWidth(){return this._ref.width()}getHeigth(){return this._ref.height()}setWidth(t){this._ref.width(t)}setHeight(t){this._ref.height(t)}setPosition(t,e){this._ref.setPosition({x:t,y:e})}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"rectangle"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}setLineWidth(t){this._ref.strokeWidth(t)}getLineWidth(){return this._ref.strokeWidth()}}class zn{constructor(t,e=null){var i,r;e?this._ref=e:t.position&&(this._ref=new Dn.Ellipse({stroke:null!==(i=t.color)&&void 0!==i?i:"#ff0000",strokeWidth:null!==(r=t.lineWidth)&&void 0!==r?r:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",x:t.position.x,y:t.position.y,radiusX:t.radius.x,radiusY:t.radius.y,draggable:!0,strokeScaleEnabled:!1}),this._ref.id(this._ref._id.toString()))}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.setPosition({x:t,y:e})}getRadiusX(){return this._ref.radiusX()}setRadiusX(t){this._ref.radius({x:t,y:this._ref.radiusY()})}getRadiusY(){return this._ref.radiusY()}setRadiusY(t){this._ref.radius({x:this._ref.radiusX(),y:t})}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"ellipse"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}}class Gn{constructor(t,e=null){var i,r;e?this._ref=e:t.start&&t.end&&(this._ref=new Dn.Arrow({stroke:null!==(i=t.color)&&void 0!==i?i:"#ff0000",fill:null!==(r=t.color)&&void 0!==r?r:"#ff0000",strokeWidth:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:[t.start.x,t.start.y,t.end.x,t.end.y],draggable:!0,strokeScaleEnabled:!1}),this._ref.id(this._ref._id.toString()))}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"arrow"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){const t=this._ref.points();return[{x:t[0],y:t[1]},{x:t[2],y:t[3]}]}setPoints(t){2===t.length&&this._ref.points([t[0].x,t[0].y,t[1].x,t[1].y])}getStartPoint(){const t=this._ref.points();return{x:t[0],y:t[1]}}setStartPoint(t,e){const i=this._ref.points();this._ref.points([t,e,i[2],i[3]])}getEndPoint(){const t=this._ref.points();return{x:t[2],y:t[3]}}setEndPoint(t,e){const i=this._ref.points();this._ref.points([i[0],i[1],t,e])}}class Nn{constructor(t,e=null){if(this._ratio=1,e){if(0===e.height()||0===e.width())return;return this._ref=e,this._canvasImage=e.image(),void(this._ratio=this._ref.height()/this._ref.width())}t.position&&t.src&&(this._canvasImage=new Image,this._ref=new Dn.Image({x:t.position.x,y:t.position.y,image:this._canvasImage,width:t.width,height:t.height,draggable:!0}),this._canvasImage.onload=()=>{this._ref.image(this._canvasImage),this._ratio=0===this._ref.height()||0===this._ref.width()?1:this._ref.height()/this._ref.width()},this._canvasImage.src=t.src,this._ref.id(this._ref._id.toString()))}getSrc(){return this._canvasImage.src}setSrc(t){this._canvasImage.src=t}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t),this._ref.height(t*this._ratio)}getHeight(){return this._ref.height()}setHeight(t){this._ref.height(t),this._ref.width(t/this._ratio)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"image"}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPosition(){return this._ref.getPosition()}setPosition(t,e){this._ref.setPosition({x:t,y:e})}}class Un{constructor(t,e=null){var i,r,s,a;if(e)return void(this._ref=e);if(!t.position||!t.width||!t.height)return;const n=16;this._ref=new Dn.Shape({x:t.position.x,y:t.position.y,width:null!==(i=t.width)&&void 0!==i?i:200,height:null!==(r=t.height)&&void 0!==r?r:200,stroke:null!==(s=t.color)&&void 0!==s?s:"#ff0000",strokeWidth:null!==(a=t.lineWidth)&&void 0!==a?a:5,draggable:!0,strokeScaleEnabled:!1,globalCompositeOperation:"source-over",sceneFunc:(t,e)=>{const i=[{x:0,y:0},{x:0+this._ref.width(),y:0},{x:0+this._ref.width(),y:0+this._ref.height()},{x:0,y:0+this._ref.height()},{x:0,y:0}],r=(s={x:0,y:0},a=this._ref.width(),o=this._ref.height(),{x:s.x+a/2,y:s.y+o/2});var s,a,o;t.beginPath();for(let e=0;e<i.length-1;e++){let s=30;const a=i[e+1].x-i[e].x,o=i[e+1].y-i[e].y,h=Math.sqrt(a*a+o*o),l=Math.floor(h/s);s=30+l/(h%s);let d=i[e].x+a/l/2,c=i[e].y+o/l/2;const u=i[e+1].x,g=i[e+1].y,p=Math.atan((g-c)/(u-d)),m=p+Math.PI,f=d>r.x&&c>r.y;for(let e=0;e<l;e++)f?t.arc(d,c,n,p,m):t.arc(d,c,n,m,p),d+=a/l,c+=o/l}t.closePath(),t.fillStrokeShape(e)}}),this._ref.className="Cloud",this._ref.on("transform",(t=>{const e=t.target.attrs,i=this._ref.width()*e.scaleX,r=this._ref.height()*e.scaleY;i<100||r<100||(Math.abs(e.scaleX-1)>1e-5&&this._ref.width(i),Math.abs(e.scaleY-1)>1e-5&&this._ref.height(r)),this._ref.scale({x:1,y:1})})),this._ref.getSelfRect=()=>({x:-16,y:-16,width:this._ref.width()+32,height:this._ref.height()+32}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"cloud"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.position({x:t,y:e})}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t)}getHeigth(){return this._ref.height()}setHeight(t){this._ref.height(t)}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}}const Wn=new Map([[H.Line,{name:"Line",initializer:t=>new Rn(null,t)}],[H.Text,{name:"Text",initializer:t=>new In(null,t)}],[H.Rectangle,{name:"Rect",initializer:t=>new Ln(null,t)}],[H.Ellipse,{name:"Ellipse",initializer:t=>new zn(null,t)}],[H.Arrow,{name:"Arrow",initializer:t=>new Gn(null,t)}],[H.Image,{name:"Image",initializer:t=>new Nn(null,t)}],[H.Cloud,{name:"Cloud",initializer:t=>new Un(null,t)}]]);class jn{constructor(){this._isInitialized=!1,this._zIndex=1,this._markupContainerName="markupContainer",this.lineWidth=4,this.changeActiveDragger=t=>{const e=t.data;this._markupContainer.className=this._canvasOriginal.className.split(" ").filter((t=>!t.startsWith("oda-cursor-"))).filter((t=>t)).concat(`oda-cursor-${e.toLowerCase()}`).join(" "),this.removeTextInput();const i=H[e];Wn.get(i)?(this._markupMode=i,this._markupIsActive=!0):(this._markupIsActive=!1,this._konvaTransformer.nodes([]))},this.resize=()=>{var t,e;null===(t=this._konvaStage)||void 0===t||t.width(this._canvasOriginal.clientWidth),null===(e=this._konvaStage)||void 0===e||e.height(this._canvasOriginal.clientHeight)},this.pan=t=>{const e=t.dX/window.devicePixelRatio,i=t.dY/window.devicePixelRatio;Object.values(H).forEach((t=>this.konvaLayerFind(t).forEach((t=>t.move({x:e,y:i})))))},this.redirectToViewer=t=>{this._viewer.emit(t)}}initialize(t,e,i=[]){if(!Dn)throw new Error('Konva Markup: Error during Markup Initialization. Konva is not initialized. Update node_modules or add to your page <script src="https://unpkg.com/konva@9/konva.min.js"><\/script>');this._viewer=t,this._canvasOriginal=e,this._canvasEvents=i,this._markupContainer=document.createElement("div"),this._markupContainer.id=this._markupContainerName,this._markupContainer.style.position="absolute",this._markupContainer.style.top="0px",this._markupContainer.style.left="0px",this._markupContainer.style.outline="0px";this._canvasOriginal.parentElement.appendChild(this._markupContainer),this._markupColor=new On(255,0,0),this._markupIsActive=!1,this.initializeKonva(),this.resize(),this._canvasEvents.forEach((t=>this._markupContainer.addEventListener(t,this.redirectToViewer))),this._viewer.addEventListener("resize",this.resize),this._viewer.addEventListener("changeactivedragger",this.changeActiveDragger),this._viewer.addEventListener("pan",this.pan),this._isInitialized=!0}dispose(){this._isInitialized&&(this._canvasEvents.forEach((t=>this._markupContainer.removeEventListener(t,this.redirectToViewer))),this._viewer.removeEventListener("pan",this.pan),this._viewer.removeEventListener("changeactivedragger",this.changeActiveDragger),this._viewer.removeEventListener("resize",this.resize),this.destroyKonva(),this._markupContainer.remove(),this._markupContainer=void 0,this._canvasOriginal=void 0,this._viewer=void 0,this._isInitialized=!1)}getDraggers(){return null}clearOverlay(){this.removeTextInput(),this._konvaTransformer.nodes([]),Object.values(H).forEach((t=>this.konvaLayerFind(t).forEach((t=>t.destroy()))))}getMarkupColor(){return this._markupColor.RGB}setMarkupColor(t,e,i){this._markupColor.setColor(t,e,i)}colorizeAllMarkup(t=255,e=0,i=0){const r=new On(t,e,i).HexColor;Object.values(H).forEach((t=>{this.konvaLayerFind(t).forEach((e=>{const i=Wn.get(t).initializer(e);i.setColor&&i.setColor(r)}))})),this._konvaLayer.draw()}setViewpoint(t){const e=t.custom_fields.markup_color||{r:255,g:0,b:0};this.setMarkupColor(e.r,e.g,e.b),this.loadMarkup(t)}getViewpoint(){if(!this._viewer.visualizeJs)return{};const t={lines:[],texts:[],arrows:[],clouds:[],ellipses:[],images:[],rectangles:[]};return t.snapshot={data:this.combineMarkupWithDrawing()},t.custom_fields={markup_color:this.getMarkupColor()},this.fillViewpointShapes(t),t.description=(new Date).toDateString(),t}createObject(t,e){let i,r=this._zIndex;switch(t){case"line":i=new Rn(e),r=1;break;case"text":i=new In(e);break;case"rectangle":i=new Ln(e),r=1;break;case"ellipse":i=new zn(e),r=1;break;case"arrow":i=new Gn(e);break;case"image":i=new Nn(e),r=0;break;case"cloud":i=new Un(e),r=1;break;default:throw new Error("Markup CreateObject - unsupported type has been detected.")}return this.addObject(i),i.setZIndex(r),this._zIndex++,i}getObjects(){const t=[];return this.konvaLayerFind(H.Line).forEach((e=>{t.push(new Rn(null,e))})),this.konvaLayerFind(H.Text).forEach((e=>{t.push(new In(null,e))})),this.konvaLayerFind(H.Rectangle).forEach((e=>{t.push(new Ln(null,e))})),this.konvaLayerFind(H.Ellipse).forEach((e=>{t.push(new zn(null,e))})),this.konvaLayerFind(H.Arrow).forEach((e=>{t.push(new Gn(null,e))})),this.konvaLayerFind(H.Image).forEach((e=>{t.push(new Nn(null,e))})),this.konvaLayerFind(H.Cloud).forEach((e=>{t.push(new Un(null,e))})),t}getSelectedObjects(){const t=[];return this._konvaTransformer.nodes().forEach((e=>{switch(e.className){case"Line":t.push(new Rn(null,e));break;case"Text":t.push(new In(null,e));break;case"Rect":t.push(new Ln(null,e));break;case"Ellipse":t.push(new zn(null,e));break;case"Arrow":t.push(new Gn(null,e));break;case"Image":t.push(new Nn(null,e));break;case"Cloud":t.push(new Un(null,e))}})),t}selectObjects(t){const e=this._konvaTransformer.nodes().concat(t.map((t=>t.ref())));this._konvaTransformer.nodes(e)}clearSelected(){this._konvaTransformer.nodes([])}getPoint3dFromArray(t){return{x:t[0],y:t[1],z:t[2]}}fillViewpointShapes(t){const e=this.getMarkupLines();e&&e.length>0&&(null==e||e.forEach((e=>{t.lines.push(e)})));const i=this.getMarkupTexts();i&&i.length>0&&(null==i||i.forEach((e=>{t.texts.push(e)})));const r=this.getMarkupRectangles();r&&r.length>0&&(null==r||r.forEach((e=>{t.rectangles.push(e)})));const s=this.getMarkupEllipses();s&&s.length>0&&(null==s||s.forEach((e=>{t.ellipses.push(e)})));const a=this.getMarkupArrows();a&&a.length>0&&(null==a||a.forEach((e=>{t.arrows.push(e)})));const n=this.getMarkupImages();n&&n.length>0&&(null==n||n.forEach((e=>{t.images.push(e)})));const o=this.getMarkupClouds();o&&o.length>0&&(null==o||o.forEach((e=>{t.clouds.push(e)})))}addObject(t){this._konvaLayer.add(t.ref())}konvaLayerFind(t){const e=Wn.get(t);if(e){return this._konvaLayer.find(e.name).filter((t=>t.parent instanceof Dn.Layer))}}initializeKonva(){this._konvaStage=new Dn.Stage({container:this._markupContainerName,width:this._canvasOriginal.clientWidth,height:this._canvasOriginal.clientHeight});const t=this._konvaStage,e=new Dn.Layer({pixelRation:window.devicePixelRatio});t.add(e),this._konvaLayer=e;const i=new Dn.Transformer({shouldOverdrawWholeArea:!1});this._konvaTransformer=i,e.add(i);let r,s=!1;t.on("mousedown touchstart",(e=>{if(!this._markupIsActive||e.target!==t||this._markupMode===H.Text)return;if(e.target===t&&i.nodes().length>0)return void i.nodes([]);const a=t.getPointerPosition();this._markupMode===H.Line?(r=this.addLine([a.x,a.y,a.x,a.y]),s=!0):this._markupMode===H.Rectangle?this.addRectangle({x:a.x,y:a.y},50,50):this._markupMode===H.Ellipse?this.addEllipse({x:a.x,y:a.y},{x:50,y:50}):this._markupMode===H.Arrow?this.addArrow({x:a.x,y:a.y},{x:a.x+50,y:a.y+50}):this._markupMode===H.Cloud&&this.addCloud({x:a.x,y:a.y},200,400)})),t.on("mouseup touchend",(t=>{this._markupIsActive&&(s=!1)})),t.on("mousemove touchmove",(e=>{if(!this._markupIsActive)return;if(!s)return;const i=t.getPointerPosition(),a=r.points().concat([i.x,i.y]);r.points(a)})),t.on("click tap",(e=>{if(!this._markupIsActive)return;if(e.target===t){if(this._markupMode===H.Text)if(this._textInputRef)this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle);else if(0===i.nodes().length){const i=t.getPointerPosition();this.createTextInput(i,e.evt.pageX,e.evt.pageY,0,null)}return void i.nodes([])}if("Text"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._textInputRef?this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle):this.createTextInput({x:e.target.attrs.x,y:e.target.attrs.y},e.evt.pageX,e.evt.pageY,e.target.attrs.rotation,e.target.attrs.text));this.removeTextInput(),i.nodes().filter((t=>"Cloud"===t.className)).length>0||"Cloud"===e.target.className?i.rotateEnabled(!1):i.rotateEnabled(!0);const r=e.evt.shiftKey||e.evt.ctrlKey||e.evt.metaKey,s=i.nodes().indexOf(e.target)>=0;if(r||s){if(r&&s){const t=i.nodes().slice();t.splice(t.indexOf(e.target),1),i.nodes(t)}else if(r&&!s){const t=i.nodes().concat([e.target]);i.nodes(t)}}else i.nodes([e.target])}));const a=t.container();a.tabIndex=1,a.focus(),a.addEventListener("keydown",(t=>{if(this._markupIsActive){if("Delete"===t.code){return this._konvaTransformer.nodes().length>0&&(this._konvaTransformer.nodes().forEach((t=>t.destroy())),this._konvaTransformer.nodes([])),void e.draw()}t.preventDefault()}}))}destroyKonva(){this.clearOverlay(),this._konvaStage.destroy(),this._konvaLayer=void 0,this._konvaTransformer=void 0,this._konvaStage=void 0}getMarkupLines(){const t=[];return this.konvaLayerFind(H.Line).forEach((e=>{const i=e.points();if(!i)return;const r=[],s=e.getAbsoluteTransform();for(let t=0;t<i.length;t+=2){const e=s.point({x:i[t],y:i[t+1]}),a=this._viewer.visViewer().screenToWorld(e.x*window.devicePixelRatio,e.y*window.devicePixelRatio);r.push(a)}const a=new Rn(null,e);t.push({id:a.id(),points:r.map((t=>this.getPoint3dFromArray(t))),color:a.getColor()||"ff0000",type:a.getLineType()||"solid",width:a.getLineWidth()||3})})),t}getMarkupTexts(){const t=[];let e=1;const i=this._viewer.visViewer().activeView.projectionMatrix.get(1,1),r=1e-6;return(i>r||i<-r)&&(e=1/i),this.konvaLayerFind(H.Text).forEach((i=>{if(!i)return;const r=this._viewer.visViewer().screenToWorld(i.x()*window.devicePixelRatio,i.y()*window.devicePixelRatio),s=new In(null,i);t.push({id:s.id(),position:this.getPoint3dFromArray(r),text:s.getText(),text_size:.02*e,angle:s.getRotation(),color:s.getColor(),font_size:s.getFontSize()})})),t}getMarkupRectangles(){const t=[];return this.konvaLayerFind(H.Rectangle).forEach((e=>{const i=e.position(),r=this._viewer.visViewer().screenToWorld(i.x*window.devicePixelRatio,i.y*window.devicePixelRatio),s=new Ln(null,e);t.push({id:s.id(),position:this.getPoint3dFromArray(r),width:s.getWidth(),height:s.getHeigth(),line_width:s.getLineWidth(),color:s.getColor()})})),t}getMarkupEllipses(){const t=[];return this.konvaLayerFind(H.Ellipse).forEach((e=>{const i=e.position(),r=this._viewer.visViewer().screenToWorld(i.x*window.devicePixelRatio,i.y*window.devicePixelRatio),s=new zn(null,e);t.push({id:s.id(),position:this.getPoint3dFromArray(r),radius:{x:e.getRadiusX(),y:e.getRadiusY()},line_width:s.getLineWidth(),color:s.getColor()})})),t}getMarkupArrows(){const t=[];return this.konvaLayerFind(H.Arrow).forEach((e=>{const i=e.getAbsoluteTransform(),r=i.point({x:e.points()[0],y:e.points()[1]}),s=this._viewer.visViewer().screenToWorld(r.x*window.devicePixelRatio,r.y*window.devicePixelRatio),a=i.point({x:e.points()[2],y:e.points()[3]}),n=this._viewer.visViewer().screenToWorld(a.x*window.devicePixelRatio,a.y*window.devicePixelRatio),o=new Gn(null,e);t.push({id:o.id(),start:this.getPoint3dFromArray(s),end:this.getPoint3dFromArray(n),color:o.getColor()})})),t}getMarkupImages(){const t=[];return this.konvaLayerFind(H.Image).forEach((e=>{const i=e.position(),r=this._viewer.visViewer().screenToWorld(i.x*window.devicePixelRatio,i.y*window.devicePixelRatio),s=new Nn(null,e);t.push({id:s.id(),position:this.getPoint3dFromArray(r),src:s.getSrc(),width:s.getWidth(),height:s.getHeight()})})),t}getMarkupClouds(){const t=[];return this.konvaLayerFind(H.Cloud).forEach((e=>{const i=e.position(),r=this._viewer.visViewer().screenToWorld(i.x*window.devicePixelRatio,i.y*window.devicePixelRatio),s=new Un(null,e);t.push({id:s.id(),position:this.getPoint3dFromArray(r),width:s.getWidth(),height:s.getHeigth(),line_width:s.getLineWidth(),color:s.getColor()})})),t}loadMarkup(t){var e,i,r,s,a,n,o;null===(e=t.lines)||void 0===e||e.forEach((t=>{const e=[];t.points.forEach((t=>{const i=p([t.x,t.y,t.z],this._viewer.visualizeJs,this._viewer.visViewer());e.push(i.x),e.push(i.y)})),this.addLine(e,t.color,t.type,t.width,t.id)})),null===(i=t.texts)||void 0===i||i.forEach((t=>{const e=p([t.position.x,t.position.y,t.position.z],this._viewer.visualizeJs,this._viewer.visViewer());this.addText(t.text,e,t.angle,t.color,t.text_size,t.font_size,t.id)})),null===(r=t.rectangles)||void 0===r||r.forEach((t=>{const e=p([t.position.x,t.position.y,t.position.z],this._viewer.visualizeJs,this._viewer.visViewer());this.addRectangle({x:e.x,y:e.y},t.width,t.height,t.line_width,t.color,t.id)})),null===(s=t.ellipses)||void 0===s||s.forEach((t=>{const e=p([t.position.x,t.position.y,t.position.z],this._viewer.visualizeJs,this._viewer.visViewer());this.addEllipse({x:e.x,y:e.y},{x:t.radius.x,y:t.radius.y},t.line_width,t.color,t.id)})),null===(a=t.arrows)||void 0===a||a.forEach((t=>{const e=p([t.start.x,t.start.y,t.start.z],this._viewer.visualizeJs,this._viewer.visViewer()),i=p([t.end.x,t.end.y,t.end.z],this._viewer.visualizeJs,this._viewer.visViewer());this.addArrow({x:e.x,y:e.y},{x:i.x,y:i.y},t.color,t.id)})),null===(n=t.clouds)||void 0===n||n.forEach((t=>{const e=p([t.position.x,t.position.y,t.position.z],this._viewer.visualizeJs,this._viewer.visViewer());this.addCloud({x:e.x,y:e.y},t.width,t.height,t.line_width,t.color,t.id)})),null===(o=t.images)||void 0===o||o.forEach((t=>{const e=p([t.position.x,t.position.y,t.position.z],this._viewer.visualizeJs,this._viewer.visViewer());this.addImage({x:e.x,y:e.y},t.src,t.width,t.height,t.id)}))}combineMarkupWithDrawing(){this._konvaTransformer.nodes().length>0&&this._konvaTransformer.nodes([]);const t=document.createElement("canvas");t.height=this._canvasOriginal.height,t.width=this._canvasOriginal.width;const e=t.getContext("2d");return e.drawImage(this._canvasOriginal,0,0),e.drawImage(this._konvaStage.toCanvas({pixelRatio:window.devicePixelRatio}),0,0),t.toDataURL("image/jpeg",.25)}addLine(t,e,i,r,s){if(!t||0===t.length)return;const a=[];for(let e=0;e<t.length;e+=2)a.push({x:t[e],y:t[e+1]});const n=new Rn({points:a,type:i||"solid",width:r||this.lineWidth,color:e||this._markupColor.HexColor,id:s}).ref();return this._konvaLayer.add(n),n}createTextInput(t,e,i,r,s){this._textInputRef?this.removeTextInput():(this._textInputPos=t,this._textInputAngle=r,this._textInputRef=document.createElement("textarea"),this._textInputRef.style.zIndex="9999",this._textInputRef.style.position="absolute",this._textInputRef.style.display="block",this._textInputRef.style.top=i+"px",this._textInputRef.style.left=e+"px",this._textInputRef.onkeydown=t=>{"Enter"===t.key&&(t.preventDefault(),this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle)),"Escape"===t.key&&(t.preventDefault(),this.removeTextInput())},s&&(this._textInputRef.value=s),document.body.appendChild(this._textInputRef),setTimeout((()=>{this._textInputRef.focus()}),50))}removeTextInput(){var t;null===(t=this._textInputRef)||void 0===t||t.remove(),this._textInputRef=null,this._textInputPos=null,this._textInputAngle=0}addText(t,e,i,r,s,a,n){if(t){const o=1e-6;if(s&&s>o&&(!a||a<o)){const t=.02;let e=1;const i=this._viewer.visViewer().activeView.projectionMatrix.get(1,1);(i>o||i<-o)&&(e=1/i),a=s/(e/t)/34}const h=new In({position:{x:e.x,y:e.y},text:t,rotation:i,fontSize:a,color:r||this._markupColor.HexColor,id:n});this._konvaLayer.add(h.ref())}const o=this._konvaTransformer.nodes();o.length>0&&(o[0].destroy(),this._konvaTransformer.nodes([])),this.removeTextInput()}addRectangle(t,e,i,r,s,a){if(!t)return;const n=new Ln({position:t,width:e,height:i,lineWidth:r||this.lineWidth,color:s||this._markupColor.HexColor,id:a}).ref();return this._konvaLayer.add(n),n}addEllipse(t,e,i,r,s){if(!t)return;const a=new zn({position:t,radius:e,lineWidth:i,color:r||this._markupColor.HexColor,id:s}).ref();return this._konvaLayer.add(a),a}addArrow(t,e,i,r){if(!t||!e)return;const s=new Gn({start:t,end:e,color:i||this._markupColor.HexColor,id:r}).ref();return this._konvaLayer.add(s),s}addCloud(t,e,i,r,s,a){if(!t||!e||!i)return;const n=new Un({position:t,width:e,height:i,color:s||this._markupColor.HexColor,lineWidth:r||this.lineWidth,id:a}).ref();return this._konvaLayer.add(n),n}addImage(t,e,i,r,s){if(!t||!i||!r)return;const a=new Nn({position:t,src:e,width:i,height:r,id:s}).ref();return this._konvaLayer.add(a),a}}const Bn="$MarkupTempEntity_Line";class Hn extends c{constructor(t){super(t),this.press=!1}dispose(){super.dispose(),this.end(),this.points=null,this.drawPoints=null}start(t,e){const i=this.getViewer().screenToWorld(t,e);this.drawPoints=[i[0],i[1],i[2]]}drag(t,e){if(this.isDragging){const i=this.getViewer().screenToWorld(t,e);this.drawPoints.push(i[0],i[1],i[2]),this._updateFrame()}}end(){this.entity&&(this.entity.delete(),this.drawPoints=null,this.entity=null)}_updateFrame(){if(this.entity){const t=this.getViewer().getMarkupModel();t.removeEntity(this.entity),t.delete(),this.entity.delete()}this.entity=this.getActiveMarkupEntity(Bn);const t=this.entity.openObject();t.appendPolyline(this.drawPoints).delete(),t.delete()}}const Kn="$MarkupTempEntity_Text";class Yn extends c{constructor(t){super(t),this.TEXT_HEIGHT_ALIGN=24,this.press=!1}dispose(){var t;super.dispose(),null===(t=this.textRef)||void 0===t||t.remove(),this.textRef=null}_finishInput(){var t;this.textRef&&this.textRef.value.trimLeft()&&this._updateFrame(),null===(t=this.textRef)||void 0===t||t.remove(),this.textRef=null}start(t,e,i,r){this.textRef?this._finishInput():(this.textRef=document.createElement("textarea"),this.textRef.style.zIndex="9999",this.textRef.style.position="absolute",this.textRef.style.display="block",this.textRef.style.top=r+"px",this.textRef.style.left=i+"px",this.textRef.onkeypress=t=>{"Enter"===t.key&&(t.preventDefault(),this._finishInput())},document.body.appendChild(this.textRef),this.press=!0,this.m_center=this.screenToWorld(t,e+this.TEXT_HEIGHT_ALIGN),this.needInputText=!0)}_updateFrame(){this.entity=this.getActiveMarkupEntity(Kn);const t=this.entity.openObject(),e=this.getViewer().activeView,i=this.toPoint(e.viewPosition),r=this.toPoint(e.viewTarget),s=e.eyeToWorldMatrix,a=i.sub(r).asVector(),n=this.toVector([1,0,0]).transformBy(s),o=this.createMatrix3d();o.setToWorldToPlane(this.toGeVector(a)),n.transformBy(o);const h=-Math.atan2(-n.y,n.x);let l=1;const d=e.projectionMatrix.get(1,1),c=1e-6;d<c&&d>-c||(l=1/d);const u=t.appendText(this.toGePoint(this.m_center),this.textRef.value.trimLeft()),g=u.openAsText();g.setNormal(this.toGeVector(a)),g.setRotation(h),g.setTextSize(.02*l),g.delete(),u.delete(),t.delete()}}class Xn{constructor(){this._markupColor={r:255,g:0,b:0},this.lineWidth=0}initialize(t,e,i){this._viewer=t}dispose(){}getDraggers(){return new Map([[H.Line,Hn],[H.Text,Yn]])}clearOverlay(){if(!this._viewer.visualizeJs)return;const t=this._viewer.visViewer().getMarkupModel();t.clearEntities(),t.delete(),this._viewer.update()}getMarkupColor(){return this._markupColor}setMarkupColor(t,e,i){const r={r:t,g:e,b:i};this._markupColor=r}colorizeAllMarkup(t=255,e=0,i=0){if(!this._viewer.visualizeJs)return;const r=this._viewer.visViewer().getMarkupModel().getEntitiesIterator();for(;!r.done();r.step()){const s=r.getEntity().openObject(),a=s.getName();a!==Bn&&a!==Kn||s.setColor(t,e,i),s.delete()}r.delete(),this._viewer.update()}setViewpoint(t){function e(t){return[t.x,t.y,t.z]}function i(t,e){return t.Point3d.createFromArray(e)}if(!this._viewer.visualizeJs)return;const r=this._viewer.visLib(),s=r.getViewer().activeView;this._viewer.syncOverlay();const a=t.custom_fields.markup_color||{r:255,g:0,b:0};if(this.setMarkupColor(a.r,a.g,a.b),t.lines)for(const e of t.lines){const t=this._viewer.addMarkupEntity(Bn).openObject(),i=[];for(const t of e.points)i.push(t.x,t.y,t.z);t.appendPolyline(i).delete(),t.delete()}if(t.texts){const a=i(r,s.viewPosition),n=i(r,s.viewTarget),o=a.sub(n).asVector();for(const i of t.texts){const t=this._viewer.addMarkupEntity(Kn).openObject(),r=t.appendText(e(i.position),i.text),s=r.openAsText();s.setNormal(e(o)),s.setRotation(i.angle),s.setTextSize(i.text_size),s.delete(),r.delete(),t.delete()}}this._viewer.update()}getViewpoint(){function t(t){return{x:t[0],y:t[1],z:t[2]}}if(!this._viewer.visualizeJs)return{};const e=this._viewer.visLib(),i={lines:[],texts:[]},r=e.getViewer().getMarkupModel().getEntitiesIterator();for(;!r.done();r.step()){const e=r.getEntity().openObject(),s=e.getName(),a=e.getGeometryDataIterator();if(a.done()){e.delete();continue}const n=a.getGeometryData();if(s===Bn){const e=n.openAsPolyline(),r=e.getPoints(),s={points:[]};for(const e of r)s.points.push(t(e));i.lines.push(s),e.delete()}else if(s===Kn){const e=n.openAsText(),r={position:t(e.getPosition()),text:e.getString(),angle:e.getRotation(),text_size:e.getTextSize()};i.texts.push(r),e.delete()}e.delete()}return r.delete(),i.snapshot={data:e.canvas.toDataURL("image/jpeg",.25)},i.custom_fields={markup_color:this.getMarkupColor()},i.description=(new Date).toDateString(),i}getLayer(){throw new Error("Not implemented yet")}createObject(t,e){throw new Error("Not implemented yet")}getObjects(){throw new Error("Not implemented yet")}getSelectedObjects(){throw new Error("Not implemented yet")}selectObjects(t){throw new Error("Not implemented yet")}clearSelected(){throw new Error("Not implemented yet")}}class Jn{static createMarkup(t){let e;switch(t){case B.Konva:e=this.createKonva();break;case B.Visualize:e=this.createVisualize();break;default:throw new Error("Error during Markup Initialization. Markup Type is unknown.")}return e}static createKonva(){return new jn}static createVisualize(){return new Xn}}const qn="$OVERLAY_VIEW_NAME",Zn=t=>null!=t;t.OdBaseDragger=c,t.Viewer=class extends l{constructor(t,e={markupType:B.Konva}){var i,r;super(),this.configure(e),this._options=new s(this),this.client=t,this._activeDragger=null,this._renderTime=0,this.markup=Jn.createMarkup(null!==(i=e.markupType)&&void 0!==i?i:B.Konva),this.draggerFactory=new Map,this.registerDragger("Pan",F),this.registerDragger("Orbit",T),this.registerDragger("Zoom",O),this.registerDragger("ZoomWindow",I),this.registerDragger("OrbitAroundBuilding",L),this.registerDragger("MeasureLine",x),this.registerDragger("CuttingPlaneXAxis",P),this.registerDragger("CuttingPlaneYAxis",k),this.registerDragger("CuttingPlaneZAxis",E),this.registerDragger("Walk",S);const n=this.markup.getDraggers();null==n||n.forEach(((t,e)=>{this.registerDragger(e,t)})),this.canvasEvents=a,this.canvaseventlistener=t=>this.emit(t),this._enableAutoUpdate=null===(r=e.enableAutoUpdate)||void 0===r||r,this._isNeedRender=!1,this._isRunAsyncUpdate=!1,this.render=this.render.bind(this),this.resize=this.resize.bind(this)}get options(){return this._options}get visualizeJsUrl(){return this._visualizeJsUrl}configure(t){return this._visualizeJsUrl=t.visualizeJsUrl||"https://opencloud.azureedge.net/libs/visualizejs/master/Visualize.js",this}async initialize(t,e){this.addEventListener("optionschange",(t=>this.syncOptions(t.data))),""===t.style.width&&""===t.style.height&&(t.style.width="100%",t.style.height="100%"),t.parentElement.style.touchAction="none",t.style.touchAction="none",t.width=t.clientWidth*window.devicePixelRatio,t.height=t.clientHeight*window.devicePixelRatio;const i=await(r=this.visualizeJsUrl,s=t=>{const{loaded:i,timeStamp:r,total:s,lengthComputable:a}=t;null==e||e({loaded:i,timeStamp:r,total:s,lengthComputable:a,type:"visualizeprogress"})},N(r).then((t=>new Promise(((e,i)=>{const a=window.getVisualizeLibInst({urlMemFile:r+".wasm",TOTAL_MEMORY:134217728,onprogress:s});a.loadWasmError=i,a.postRun.push((()=>{window.getVisualizeLibInst.script=t,e(a)}))})))));var r,s;return this.visualizeJs=i,this.visualizeJs.canvas=t,this.visualizeJs.Viewer.create(),this.canvas=t,this.canvasEvents.forEach((e=>t.addEventListener(e,this.canvaseventlistener))),this.markup.initialize(this,t,this.canvasEvents),this._resizeObserver=new ResizeObserver(this.resize),this._resizeObserver.observe(t.parentElement),this.resize(),this._zoomWheelDragger=new V(this),this._zoomWheelDragger.name="ZoomWheel",this._zoomWheelDragger.initialize(),this._gestureManager=new G(this),this._gestureManager.initialize(),this.syncOpenCloudVisualStyle(!0),this.syncOptions(),this._renderTime=performance.now(),this.render(this._renderTime),this}dispose(){var t,e,i,r;return this.cancel(),this.emitEvent({type:"dispose"}),this.frameId&&cancelAnimationFrame(this.frameId),this.frameId=0,this.setActiveDragger(""),null===(t=this._zoomWheelDragger)||void 0===t||t.dispose(),null===(e=this._gestureManager)||void 0===e||e.dispose(),this.removeAllListeners(),null===(i=this._resizeObserver)||void 0===i||i.disconnect(),this._resizeObserver=void 0,this.markup.dispose(),this.canvasEvents.forEach((t=>{var e;return null===(e=this.canvas)||void 0===e?void 0:e.removeEventListener(t,this.canvaseventlistener)})),this.canvas=void 0,null===(r=this.visualizeJs)||void 0===r||r.getViewer().clear(),this.visualizeJs=void 0,this}isInitialized(){return!!this.visualizeJs}render(t){var e;if(this.frameId=requestAnimationFrame(this.render),!this.visualizeJs)return;if(this._isRunAsyncUpdate)return;const i=this.visualizeJs.getViewer();if(i.isRunningAnimation()||this._isNeedRender){i.update(),null===(e=this._activeDragger)||void 0===e||e.updatePreview(),this._isNeedRender=!i.getActiveDevice().isValid();const r=(t-this._renderTime)/1e3;this._renderTime=t,this.emitEvent({type:"render",time:t,deltaTime:r})}}resize(){if(!this.visualizeJs)return this;const{clientWidth:t,clientHeight:e}=this.canvas;this.canvas.width=t*window.devicePixelRatio,this.canvas.height=e*window.devicePixelRatio;return this.visualizeJs.getViewer().resize(0,this.canvas.width,this.canvas.height,0),this.update(!0),this.emitEvent({type:"resize",width:t,height:e}),this}update(t){var e,i;this._enableAutoUpdate&&(t?(null===(e=this.visViewer())||void 0===e||e.update(),null===(i=this.activeDragger())||void 0===i||i.updatePreview()):this._isNeedRender=!0),this.emitEvent({type:"update",data:t})}scheduleUpdateAsync(t=50){return new Promise(((e,i)=>{setTimeout((()=>{var r,s;try{null===(r=this.visViewer())||void 0===r||r.update(t),null===(s=this.activeDragger())||void 0===s||s.updatePreview(),e()}catch(t){console.error(t),i()}}),0)}))}async updateAsync(t=50,e=50){this._isRunAsyncUpdate=!0;const i=this.visViewer().getActiveDevice();try{for(let r=0;!i.isValid()&&r<e;r++)await this.scheduleUpdateAsync(t);await this.scheduleUpdateAsync(t)}catch(t){console.error(t)}finally{this._isRunAsyncUpdate=!1}}visLib(){return this.visualizeJs}visViewer(){var t;return null===(t=this.visualizeJs)||void 0===t?void 0:t.getViewer()}syncOpenCloudVisualStyle(t){if(!this.visualizeJs)return this;const e=this.visLib(),i=e.getViewer(),r=i.getActiveDevice();if(r.isNull())return this;const s=r.getActiveView();let a;s.enableDefaultLighting(!0,e.DefaultLightingType.kTwoLights),s.setDefaultLightingIntensity(1.25);try{a=i.findVisualStyle("OpenCloud")}catch(r){t||console.log("OpenCloud visual style not found, creating it on client side"),a=i.createVisualStyle("OpenCloud");const s=new e.OdTvColorDef(66,66,66),n=i.findVisualStyle("Realistic"),o=a.openObject();o.copyFrom(n),o.setOptionInt32(e.VisualStyleOptions.kFaceModifiers,0,e.VisualStyleOperations.kSet),o.setOptionInt32(e.VisualStyleOptions.kEdgeModel,2,e.VisualStyleOperations.kSet),o.setOptionDouble(e.VisualStyleOptions.kEdgeCreaseAngle,60,e.VisualStyleOperations.kSet),o.setOptionInt32(e.VisualStyleOptions.kEdgeStyles,0,e.VisualStyleOperations.kSet),o.setOptionInt32(e.VisualStyleOptions.kEdgeModifiers,8,e.VisualStyleOperations.kSet),o.setOptionColor(e.VisualStyleOptions.kEdgeColorValue,s,e.VisualStyleOperations.kSet),o.delete()}return s.visualStyle=a,s.delete(),r.delete(),this}syncOptions(t=this.options.data){if(!this.visualizeJs)return this;const e=this.visLib(),i=e.getViewer(),r=i.getActiveDevice();if(r.isNull())return this;if(t.showWCS!==i.getEnableWCS()&&i.setEnableWCS(t.showWCS),t.cameraAnimation!==i.getEnableAnimation()&&i.setEnableAnimation(t.cameraAnimation),t.antialiasing!==i.fxaaAntiAliasing3d&&(i.fxaaAntiAliasing3d=t.antialiasing,i.fxaaQuality=5),t.shadows!==i.shadows){i.shadows=t.shadows;const s=e.canvas;r.invalidate([0,s.clientWidth,s.clientHeight,0])}if(t.groundShadow!==i.groundShadow&&(i.groundShadow=t.groundShadow),t.ambientOcclusion!==r.getOptionBool(e.DeviceOptions.kSSAOEnable)){r.setOptionBool(e.DeviceOptions.kSSAOEnable,t.ambientOcclusion),r.setOptionBool(e.DeviceOptions.kSSAODynamicRadius,!0),r.setOptionDouble(e.DeviceOptions.kSSAORadius,1),r.setOptionInt32(e.DeviceOptions.kSSAOLoops,32),r.setOptionDouble(e.DeviceOptions.kSSAOPower,2),r.setOptionInt32(e.DeviceOptions.kSSAOBlurRadius,2);const s=i.activeView;s.setSSAOEnabled(t.ambientOcclusion),s.delete()}if(Zn(t.edgeModel)){const s=r.getActiveView(),a=i.findVisualStyle("OpenCloud"),n=a.openObject();n.setOptionInt32(e.VisualStyleOptions.kEdgeModel,t.edgeModel?2:0,e.VisualStyleOperations.kSet),s.visualStyle=a,n.delete(),a.delete(),s.delete()}return r.delete(),this.syncHighlightingOptions(t),this.update(),this}syncHighlightingOptions(t=this.options.data){if(!this.visualizeJs)return this;const e=t.enableCustomHighlight?t:s.defaults(),i=this.visLib(),r=i.getViewer(),{Entry:a,OdTvRGBColorDef:n}=i,o=r.findHighlightStyle("Web_Default").openObject();if(Zn(e.facesColor)){const t=new n(e.facesColor.r,e.facesColor.g,e.facesColor.b);o.setFacesColor(a.k3D.value|a.k3DTop.value,t),t.delete()}if(Zn(e.facesOverlap)&&o.setFacesVisibility(a.k3DTop.value,e.facesOverlap),Zn(e.facesTransparancy)&&o.setFacesTransparency(a.k3D.value|a.k3DTop.value,e.facesTransparancy),Zn(e.edgesColor)){const t=new n(e.edgesColor.r,e.edgesColor.g,e.edgesColor.b);o.setEdgesColor(a.k3DTop.value|a.k3D.value|a.k2D.value|a.k2DTop.value,t),t.delete()}if(Zn(e.edgesVisibility)&&o.setEdgesVisibility(a.k2D.value|a.k2DTop.value|a.k3DTop.value|a.k3D.value,e.edgesVisibility),Zn(e.edgesOverlap)){const t=!Zn(e.edgesVisibility)||e.edgesVisibility;o.setEdgesVisibility(a.k2DTop.value|a.k3DTop.value,e.edgesOverlap&&t)}const h=r.getActiveDevice();if(!h.isNull()){const t=i.canvas;h.invalidate([0,t.clientWidth,t.clientHeight,0]),h.delete()}return this}get draggers(){return[...this.draggerFactory.keys()]}registerDragger(t,e){this.draggerFactory.set(t,e)}activeDragger(){return this._activeDragger}setActiveDragger(t){var e;if((null===(e=this._activeDragger)||void 0===e?void 0:e.name)!==t){this._activeDragger&&(this._activeDragger.dispose(),this._activeDragger=null);const e=this.draggerFactory.get(t);e&&(this._activeDragger=new e(this),this._activeDragger.name=t,this._activeDragger.initialize());const i=this.canvas;i&&(i.className=i.className.split(" ").filter((t=>!t.startsWith("oda-cursor-"))).filter((t=>t)).concat(`oda-cursor-${t.toLowerCase()}`).join(" ")),this.emitEvent({type:"changeactivedragger",data:t})}return this._activeDragger}resetActiveDragger(){const t=this._activeDragger;t&&(this.setActiveDragger(""),this.setActiveDragger(t.name))}clearSlices(){if(!this.visualizeJs)return;const t=this.visViewer().activeView;t.removeCuttingPlanes(),t.delete(),this.update()}clearOverlay(){this.markup.clearOverlay()}syncOverlay(){if(!this.visualizeJs)return;const t=this.visViewer(),e=t.activeView;let i=t.getViewByName(qn);if(!i){const r=t.getMarkupModel(),s=t.getActiveDevice();i=s.createView(qn,!1),i.addModel(r),e.addSibling(i),s.addView(i)}i.viewPosition=e.viewPosition,i.viewTarget=e.viewTarget,i.upVector=e.upVector,i.viewFieldWidth=e.viewFieldWidth,i.viewFieldHeight=e.viewFieldHeight;const r=i.getViewport();return i.setViewport(r.lowerLeft,r.upperRight),i.vportRect=e.vportRect,this.update(),i}is3D(){if(!this.visualizeJs)return!1;const t=this.visViewer().getActiveExtents(),e=t.min();return 0!==t.max()[2]-e[2]}getSelected(){return this.executeCommand("getSelected")}setSelected(t){this.executeCommand("setSelected",t)}async loadReferences(t){var e;if(!this.visualizeJs)return this;const i=new AbortController;null===(e=this._abortControllerForReferences)||void 0===e||e.abort(),this._abortControllerForReferences=i;let r=[];await t.getReferences(i.signal).then((t=>r=t.references)).catch((t=>console.error("Cannot load model references.",t)));for(const t of r)await this.client.downloadFile(t.id,void 0,i.signal).then((e=>{var i;return null===(i=this.visualizeJs)||void 0===i?void 0:i.getViewer().addEmbeddedFile(t.name,new Uint8Array(e))})).catch((e=>console.error(`Cannot load reference file ${t.name}.`,e)));return this}applyModelTransformMatrix(t){this.executeCommand("applyModelTransform",t)}applySceneGraphSettings(t=this.options){if(!this.visualizeJs)return;const e=this.visLib(),i=e.getViewer().getActiveDevice();Zn(t.sceneGraph)&&i.setOptionBool(e.DeviceOptions.kDelaySceneGraphProc,!t.sceneGraph),i.delete(),this.update()}async open(t){if(!this.visualizeJs)return this;let e;if(this.cancel(),this.clear(),this.emitEvent({type:"open",file:t,model:t}),t){const i=await t.getModels()||[];e=i.find((t=>t.default))||i[0]}if(!e)throw new Error("No default model found");const i=new s;i.data=this.options.data,".rcs"===t.type&&(console.log("Partial load mode is forced for RCS file"),i.enablePartialMode=!0);const r=(new q).create(this,e,i.data);return await this.loadReferences(e),await r.load(),this.visualizeJs&&(this.applyModelTransformMatrix(e),this.applySceneGraphSettings()),this}openVsfFile(t){if(!this.visualizeJs)return this;this.cancel(),this.clear(),this.emitEvent({type:"open",buffer:t});try{this.emitEvent({type:"geometrystart",buffer:t});const e=this.visLib().getViewer(),i=t instanceof Uint8Array?t:new Uint8Array(t);e.parseFile(i),this.syncOpenCloudVisualStyle(!1),this.syncOptions(),this.resize(),this.emitEvent({type:"geometryprogress",data:1,buffer:t}),this.emitEvent({type:"databasechunk",data:i,buffer:t}),this.emitEvent({type:"geometryend",buffer:t})}catch(e){throw this.emitEvent({type:"geometryerror",data:e,buffer:t}),e}return this}openVsfxFile(t){if(!this.visualizeJs)return this;this.cancel(),this.clear(),this.emitEvent({type:"open",buffer:t});try{this.emitEvent({type:"geometrystart",buffer:t});const e=this.visLib().getViewer(),i=t instanceof Uint8Array?t:new Uint8Array(t);e.parseVsfx(i),this.syncOpenCloudVisualStyle(!1),this.syncOptions(),this.resize(),this.emitEvent({type:"geometryprogress",data:1,buffer:t}),this.emitEvent({type:"databasechunk",data:i,buffer:t}),this.emitEvent({type:"geometryend",buffer:t})}catch(e){throw this.emitEvent({type:"geometryerror",data:e,buffer:t}),e}return this}cancel(){var t,e,i;return null===(t=this._abortControllerForReferences)||void 0===t||t.abort(),this._abortControllerForReferences=void 0,null===(e=this._abortController)||void 0===e||e.abort(),this._abortController=void 0,null===(i=this._abortControllerForRequestMap)||void 0===i||i.forEach((t=>t.abort())),this._abortControllerForRequestMap=void 0,this.emitEvent({type:"cancel"}),this}clear(){if(!this.visualizeJs)return this;const t=this.visLib().getViewer();return this.clearOverlay(),t.clear(),t.createLocalDatabase(),this.syncOpenCloudVisualStyle(!0),this.syncOptions(),this.resize(),this.emitEvent({type:"clear"}),this}getMarkupColor(){return this.markup.getMarkupColor()}setMarkupColor(t=255,e=0,i=0){this.markup.setMarkupColor(t,e,i);const r={r:t,g:e,b:i};this.emitEvent({type:"changemarkupcolor",data:r})}colorizeAllMarkup(t=255,e=0,i=0){this.markup.colorizeAllMarkup(t,e,i)}addMarkupEntity(t){if(!this.visualizeJs)return null;this.syncOverlay();const e=this.visViewer().getMarkupModel().appendEntity(t),i=e.openObject(),r=this.getMarkupColor();return i.setColor(r.r,r.g,r.b),i.setLineWeight(2),i.delete(),this.update(),e}drawViewpoint(t){this.setOrthogonalCameraSettings(t.orthogonal_camera),this.setClippingPlanes(t.clipping_planes),this.markup.setViewpoint(t)}createViewpoint(){const t=this.markup.getViewpoint();return t.orthogonal_camera=this.getOrthogonalCameraSettings(),t.clipping_planes=this.getClippingPlanes(),t}getPoint3dFromArray(t){return{x:t[0],y:t[1],z:t[2]}}getLogicalPoint3dAsArray(t){return[t.x,t.y,t.z]}getOrthogonalCameraSettings(){const t=this.visViewer().activeView;return{view_point:this.getPoint3dFromArray(t.viewPosition),direction:this.getPoint3dFromArray(t.viewTarget),up_vector:this.getPoint3dFromArray(t.upVector),field_width:t.viewFieldWidth,field_height:t.viewFieldHeight}}setOrthogonalCameraSettings(t){const e=this.visViewer().activeView;this.resetActiveDragger(),this.clearSlices(),this.clearOverlay(),t&&e.setView(this.getLogicalPoint3dAsArray(t.view_point),this.getLogicalPoint3dAsArray(t.direction),this.getLogicalPoint3dAsArray(t.up_vector),t.field_width,t.field_height,!0),this.syncOverlay()}getClippingPlanes(){const t=this.visViewer().activeView,e=[];for(let i=0;i<t.numCuttingPlanes();i++){const r=t.getCuttingPlane(i),s={location:this.getPoint3dFromArray(r.getOrigin()),direction:this.getPoint3dFromArray(r.normal())};e.push(s)}return e}setClippingPlanes(t){if(t){const e=this.visViewer().activeView;for(const i of t){const t=new(this.visLib().OdTvPlane);t.set(this.getLogicalPoint3dAsArray(i.location),this.getLogicalPoint3dAsArray(i.direction)),e.addCuttingPlane(t),e.setEnableCuttingPlaneFill(!0,102,102,102)}}}executeCommand(t,...e){return r("VisualizeJS").executeCommand(t,this,...e)}},t.commands=r,Object.defineProperty(t,"__esModule",{value:!0})}));