@inweb/viewer-visualize 25.8.21 → 25.8.22
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}function s(){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"}}r("").registerCommand("noop",(()=>{})),r("VisualizeJS").registerCommand("noop",(()=>{})),r("ThreeJS").registerCommand("noop",(()=>{}));class a{constructor(t){this._emitter=t,this._data={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"},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(){console.warn("Options.notifierChangeEvent() has been deprecated since 25.3 and will be removed in a future release, use Options.change() instead."),this.change()}change(){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=a.defaults(),i=t.reduce(((t,i)=>(t[i]=e[i],t)),{});this.data={...this.data,...i}}else this.data={...this.data,...a.defaults()}}get data(){return this._data}set data(t){const e=!!t.enableStreamingMode&&t.enablePartialMode,i=!e&&t.sceneGraph;this._data={...a.defaults(),...this._data,...t,enablePartialMode:e,sceneGraph:i},this.change()}get showWCS(){return this._data.showWCS}set showWCS(t){this._data.showWCS=t,this.change()}get cameraAnimation(){return this._data.cameraAnimation}set cameraAnimation(t){this._data.cameraAnimation=t,this.change()}get antialiasing(){return this._data.antialiasing}set antialiasing(t){this._data.antialiasing=t,this.change()}get groundShadow(){return this._data.groundShadow}set groundShadow(t){this._data.groundShadow=t,this.change()}get shadows(){return this._data.shadows}set shadows(t){this._data.shadows=t,this.change()}get cameraAxisXSpeed(){return this._data.cameraAxisXSpeed}set cameraAxisXSpeed(t){this._data.cameraAxisXSpeed=t,this.change()}get cameraAxisYSpeed(){return this._data.cameraAxisYSpeed}set cameraAxisYSpeed(t){this.cameraAxisYSpeed=t,this.change()}get ambientOcclusion(){return this._data.ambientOcclusion}set ambientOcclusion(t){this._data.ambientOcclusion=t,this.change()}get enableStreamingMode(){return this._data.enableStreamingMode}set enableStreamingMode(t){this._data.enableStreamingMode=t,t||(this._data.enablePartialMode=!1),this.change()}get enablePartialMode(){return this._data.enablePartialMode}set enablePartialMode(t){this._data.enablePartialMode=t,t&&(this._data.enableStreamingMode=!0,this._data.sceneGraph=!1),this.change()}get memoryLimit(){return this._data.memoryLimit}set memoryLimit(t){this._data.memoryLimit=t,this.change()}get cuttingPlaneFillColor(){return this._data.cuttingPlaneFillColor}set cuttingPlaneFillColor(t){this._data.cuttingPlaneFillColor=t,this.change()}get edgesColor(){return this._data.edgesColor}set edgesColor(t){this._data.edgesColor=t,this.change()}get facesColor(){return this._data.facesColor}set facesColor(t){this._data.facesColor=t,this.change()}get edgesVisibility(){return this._data.edgesVisibility}set edgesVisibility(t){this._data.edgesVisibility=t,this.change()}get edgesOverlap(){return this._data.edgesOverlap}set edgesOverlap(t){this._data.edgesOverlap=t,this.change()}get facesOverlap(){return this._data.facesOverlap}set facesOverlap(t){this._data.facesOverlap=t,this.change()}get facesTransparancy(){return this._data.facesTransparancy}set facesTransparancy(t){this._data.facesTransparancy=t,this.change()}get enableCustomHighlight(){return this._data.enableCustomHighlight}set enableCustomHighlight(t){this._data.enableCustomHighlight=t,this.change()}get sceneGraph(){return this._data.sceneGraph}set sceneGraph(t){this._data.sceneGraph=t,t&&(this._data.enablePartialMode=!1),this.change()}get edgeModel(){return Boolean(this._data.edgeModel)}set edgeModel(t){this._data.edgeModel=Boolean(t),this.change()}get reverseZoomWheel(){return this._data.reverseZoomWheel}set reverseZoomWheel(t){this._data.reverseZoomWheel=!!t,this.change()}get enableZoomWheel(){return this._data.enableZoomWheel}set enableZoomWheel(t){this._data.enableZoomWheel=!!t,this.change()}get enableGestures(){return this._data.enableGestures}set enableGestures(t){this._data.enableGestures=!!t,this.change()}get geometryType(){return this._data.geometryType}set geometryType(t){this._data.geometryType=t,this.change()}}const n=["click","contextmenu","dblclick","mousedown","mouseleave","mousemove","mouseup","pointercancel","pointerdown","pointerleave","pointermove","pointerup","touchcancel","touchend","touchmove","touchstart","wheel"],o=n;const h=(t,e,i)=>{const{translate:r,scale:s,rotation:a}=t,n=new i.Matrix3d;n.setTranslation([r.x,r.y,r.z]);const o=new i.Matrix3d;o.setToRotation(a.angle,[a.x,a.y,a.z],e);const h=new i.Matrix3d;return h.setToScaling(s,e),o.postMultBy(n).postMultBy(h)};function l(t,e=0){if(!t.visualizeJs)return;t.visViewer().explode(e),t.update(),t.emit({type:"explode",data:e})}function d(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})}function c(t){return"$"===t.getName()[0]}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();e.transformBy(t.getUnitsMatrix());const s=h(i,e.center(),r);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",l),r("VisualizeJS").registerCommand("collect",(t=>l(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",d),r("VisualizeJS").registerCommand("k3DViewTop",(t=>d(t,"k3DViewTop"))),r("VisualizeJS").registerCommand("k3DViewBottom",(t=>d(t,"k3DViewBottom"))),r("VisualizeJS").registerCommand("k3DViewLeft",(t=>d(t,"k3DViewLeft"))),r("VisualizeJS").registerCommand("k3DViewRight",(t=>d(t,"k3DViewRight"))),r("VisualizeJS").registerCommand("k3DViewFront",(t=>d(t,"k3DViewFront"))),r("VisualizeJS").registerCommand("k3DViewBack",(t=>d(t,"k3DViewBack"))),r("VisualizeJS").registerCommand("k3DViewSE",(t=>d(t,"k3DViewSE"))),r("VisualizeJS").registerCommand("k3DViewSW",(t=>d(t,"k3DViewSW"))),r("VisualizeJS").registerCommand("k3DViewNE",(t=>d(t,"k3DViewNE"))),r("VisualizeJS").registerCommand("k3DViewNW",(t=>d(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.deviceAutoRegeneration(),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.deviceAutoRegeneration(),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.deviceAutoRegeneration(),t.update(),t.emitEvent({type:"zoom"})})),r("VisualizeJS").registerCommand("autoTransformAllModelsToCentralPoint",(async function(t,e){var i;if(!t.visualizeJs)return;if(!e.getModelTransformMatrix)return;const r=t.visLib(),s=r.getViewer(),a=s.getActiveExtents().center(),n=s.getModelIterator();for(;!n.done();n.step()){const t=n.getModel();if(!c(t)){let i=t.getExtents();const s=t.getUnitsMatrix();i.transformBy(t.getUnitsMatrix());const n=t.getUnitsMatrix().invert(),o=i.center(),l=1,d=new r.Matrix3d,c=new r.Matrix3d;c.setTranslation([a[0]-o[0],a[1]-o[1],a[2]-o[2]]),d.setToScaling(l,a);const u=n.postMultBy(d).postMultBy(c).postMultBy(s),g=u.scale(),p={translate:{x:u.get(0,3)-(1-g)*o[0],y:u.get(1,3)-(1-g)*o[1],z:u.get(2,3)-(1-g)*o[2]},rotation:{x:0,y:0,z:1,angle:0},scale:g},m=h(p,o,r);t.setModelingMatrix(m,!0),a[0]+=Math.abs(i.max()[0]-i.min()[0])*g,await e.setModelTransformMatrix(t.getDatabaseHandle(),p)}t.delete()}n.delete(),null===(i=s.clearViewExtentsCache)||void 0===i||i.call(s),t.update()}));var u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function g(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var p={exports:{}},m={},f={},v={};!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!==u?u:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},t.Konva={_global:t.glob,version:"9.3.13",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,_fixTextRendering:!1,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:()=>t.Konva.DD.isDragging,isTransforming(){var e;return null===(e=t.Konva.Transformer)||void 0===e?void 0:e.isTransforming()},isDragReady:()=>!!t.Konva.DD.node,releaseCanvasOnDestroy:!0,document:t.glob.document,_injectGlobal(e){t.glob.Konva=e}};t._registerNode=e=>{t.Konva[e.prototype.getClassName()]=e},t.Konva._injectGlobal(t.Konva)}(v);var _={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Util=t.Transform=void 0;const e=v;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)}}}(_);var y={},w={},b={};Object.defineProperty(b,"__esModule",{value:!0}),b.getComponentValidator=b.getBooleanValidator=b.getNumberArrayValidator=b.getFunctionValidator=b.getStringOrGradientValidator=b.getStringValidator=b.getNumberOrAutoValidator=b.getNumberOrArrayOfNumbersValidator=b.getNumberValidator=b.alphaComponent=b.RGBComponent=void 0;const x=v,S=_;function C(t){return S.Util._isString(t)?'"'+t+'"':"[object Number]"===Object.prototype.toString.call(t)||S.Util._isBoolean(t)?t:Object.prototype.toString.call(t)}b.RGBComponent=function(t){return t>255?255:t<0?0:Math.round(t)},b.alphaComponent=function(t){return t>1?1:t<1e-4?1e-4:t},b.getNumberValidator=function(){if(x.Konva.isUnminified)return function(t,e){return S.Util._isNumber(t)||S.Util.warn(C(t)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),t}},b.getNumberOrArrayOfNumbersValidator=function(t){if(x.Konva.isUnminified)return function(e,i){let r=S.Util._isNumber(e),s=S.Util._isArray(e)&&e.length==t;return r||s||S.Util.warn(C(e)+' is a not valid value for "'+i+'" attribute. The value should be a number or Array<number>('+t+")"),e}},b.getNumberOrAutoValidator=function(){if(x.Konva.isUnminified)return function(t,e){return S.Util._isNumber(t)||"auto"===t||S.Util.warn(C(t)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),t}},b.getStringValidator=function(){if(x.Konva.isUnminified)return function(t,e){return S.Util._isString(t)||S.Util.warn(C(t)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),t}},b.getStringOrGradientValidator=function(){if(x.Konva.isUnminified)return function(t,e){const i=S.Util._isString(t),r="[object CanvasGradient]"===Object.prototype.toString.call(t)||t&&t.addColorStop;return i||r||S.Util.warn(C(t)+' is a not valid value for "'+e+'" attribute. The value should be a string or a native gradient.'),t}},b.getFunctionValidator=function(){if(x.Konva.isUnminified)return function(t,e){return S.Util._isFunction(t)||S.Util.warn(C(t)+' is a not valid value for "'+e+'" attribute. The value should be a function.'),t}},b.getNumberArrayValidator=function(){if(x.Konva.isUnminified)return function(t,e){const i=Int8Array?Object.getPrototypeOf(Int8Array):null;return i&&t instanceof i||(S.Util._isArray(t)?t.forEach((function(t){S.Util._isNumber(t)||S.Util.warn('"'+e+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")})):S.Util.warn(C(t)+' is a not valid value for "'+e+'" attribute. The value should be a array of numbers.')),t}},b.getBooleanValidator=function(){if(x.Konva.isUnminified)return function(t,e){return!0===t||!1===t||S.Util.warn(C(t)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),t}},b.getComponentValidator=function(t){if(x.Konva.isUnminified)return function(e,i){return null==e||S.Util.isObject(e)||S.Util.warn(C(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=_,i=b;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}}}(w);var P={},A={};Object.defineProperty(A,"__esModule",{value:!0}),A.HitContext=A.SceneContext=A.Context=void 0;const k=_,E=v;var T=["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 M{constructor(t){this.canvas=t,E.Konva.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(t){t.fillEnabled()&&this._fill(t)}_fill(t){}strokeShape(t){t.hasStroke()&&this._stroke(t)}_stroke(t){}fillStrokeShape(t){t.attrs.fillAfterStrokeEnabled?(this.strokeShape(t),this.fillShape(t)):(this.fillShape(t),this.strokeShape(t))}getTrace(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+="()":k.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=T.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=k.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(T[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)}}A.Context=M,["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"].forEach((function(t){Object.defineProperty(M.prototype,t,{get(){return this._context[t]},set(e){this._context[t]=e}})}));A.SceneContext=class extends M{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)}};A.HitContext=class extends M{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(P,"__esModule",{value:!0}),P.HitCanvas=P.SceneCanvas=P.Canvas=void 0;const I=_,F=A,O=v,D=w,R=b;var V;class L{constructor(t){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;var e=(t||{}).pixelRatio||O.Konva.pixelRatio||function(){if(V)return V;var t=I.Util.createCanvasElement(),e=t.getContext("2d");return V=(O.Konva._global.devicePixelRatio||1)/(e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1),I.Util.releaseCanvas(t),V}();this.pixelRatio=e,this._canvas=I.Util.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(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 I.Util.error("Unable to get data URL. "+t.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}}P.Canvas=L,D.Factory.addGetterSetter(L,"pixelRatio",void 0,(0,R.getNumberValidator)());P.SceneCanvas=class extends L{constructor(t={width:0,height:0,willReadFrequently:!1}){super(t),this.context=new F.SceneContext(this,{willReadFrequently:t.willReadFrequently}),this.setSize(t.width,t.height)}};P.HitCanvas=class extends L{constructor(t={width:0,height:0}){super(t),this.hitCanvas=!0,this.context=new F.HitContext(this),this.setSize(t.width,t.height)}};var z={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DD=void 0;const e=v,i=_;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))}(z),Object.defineProperty(y,"__esModule",{value:!0}),y.Node=void 0;const G=_,N=w,W=P,U=v,B=z,j=b;var H="absoluteOpacity",K="allEventListeners",Y="absoluteTransform",X="absoluteScale",J="canvas",q="listening",Z="mouseenter",$="mouseleave",Q="Shape",tt=" ",et="stage",it="transform",rt="visible",st=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(tt);let at=1;class nt{constructor(t){this._id=at++,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!==it&&t!==Y||!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===it||t===Y)&&!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(tt);this.on(i,(()=>{this._clearCache(t)})),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,i)}_getCanvasCache(){return this._cache.get(J)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===Y&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(J)){const{scene:t,filter:e,hit:i}=this._cache.get(J);G.Util.releaseCanvas(t,e,i),this._cache.delete(J)}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 G.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 W.SceneCanvas({pixelRatio:a,width:r,height:s}),u=new W.SceneCanvas({pixelRatio:a,width:0,height:0,willReadFrequently:!0}),g=new W.HitCanvas({pixelRatio:d,width:r,height:s}),p=c.getContext(),m=g.getContext();return g.isCache=!0,c.isCache=!0,this._cache.delete(J),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(H),this._clearSelfAndDescendantCache(X),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(J,{scene:c,filter:u,hit:g,x:n,y:o}),this._requestDraw(),this}isCached(){return this._cache.has(J)}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)):G.Util.error("Filter should be type of function, but got "+typeof r+" instead. Please check correct filters")}catch(t){G.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(K),3===arguments.length)return this._delegate.apply(this,arguments);var i,r,s,a,n=t.split(tt),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(tt),h=o.length;if(this._cache&&this._cache.delete(K),!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=G.Util.cloneObject(t)).currentTarget=s[a],i.call(s[a],t)}))}remove(){return this.isDragging()&&this.stopDrag(),B.DD._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(Y),this._clearSelfAndDescendantCache(H),this._clearSelfAndDescendantCache(X),this._clearSelfAndDescendantCache(et),this._clearSelfAndDescendantCache(rt),this._clearSelfAndDescendantCache(q)}_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"+G.Util._capitalize(t);return G.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"+G.Util._capitalize(e),G.Util._isFunction(this[i])?this[i](t[e]):this._setAttr(e,t[e]))})),this}isListening(){return this._getCache(q,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(rt,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;B.DD._dragElements.forEach((t=>{"dragging"===t.dragStatus&&("Stage"===t.node.nodeType||t.node.getLayer()===i)&&(r=!0)}));var s=!e&&!U.Konva.hitOnDragEnabled&&(r||U.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!==Q&&(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(it),this._clearSelfAndDescendantCache(Y)),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 G.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(it);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(it),this._clearSelfAndDescendantCache(Y),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 G.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 G.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 G.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 G.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 G.Util.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&&G.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(H,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],G.Util.isObject(e)&&!G.Util._isPlainObject(e)&&!G.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 G.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],G.Util.isValidSelector(i)||(G.Util.warn('Selector "'+i+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),G.Util.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),G.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(et,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(Y,this._getAbsoluteTransform)}_getAbsoluteTransform(t){var e;if(t)return e=new G.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(Y)||new G.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(it,this._getTransform)}_getTransform(){var t,e,i=this._cache.get(it)||new G.Transform;i.reset();var r=this.x(),s=this.y(),a=U.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=G.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 W.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 W.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,G.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():U.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"+G.Util._capitalize(t)];return G.Util._isFunction(i)?i.call(this,e):this._setAttr(t,e),this}_requestDraw(){if(U.Konva.autoDrawEnabled){const t=this.getLayer()||this.getStage();null==t||t.batchDraw()}}_setAttr(t,e){var i=this.attrs[t];(i!==e||G.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===Q&&(e.target=this),!((t===Z||t===$)&&(i&&(this===i||this.isAncestorOf&&this.isAncestorOf(i))||"Stage"===this.nodeType&&!i))){this._fire(t,e);var r=(t===Z||t===$)&&i&&i.isAncestorOf&&i.isAncestorOf(this)&&!i.isAncestorOf(this.parent);(e&&!e.cancelBubble||!e)&&this.parent&&this.parent.isListening()&&!r&&(i&&i.parent?this._fireAndBubble.call(this.parent,t,e,i):this._fireAndBubble.call(this.parent,t,e))}}_getProtoListeners(t){var e,i,r;const s=null!==(e=this._cache.get(K))&&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(K,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;B.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){B.DD._dragElements.has(this._id)||this._createDragElement(t);B.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:G.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=B.DD._dragElements.get(this._id);e&&(e.dragStatus="stopped"),B.DD._endDragBefore(t),B.DD._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=B.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)||U.Konva.dragButtons.indexOf(t.evt.button)>=0)&&!this.isDragging()){var e=!1;B.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=B.DD._dragElements.get(this._id),e=t&&"dragging"===t.dragStatus,i=t&&"ready"===t.dragStatus;e?this.stopDrag():i&&B.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 G.Util.haveIntersection(i,this.getClientRect())}static create(t,e){return G.Util._isString(t)&&(t=JSON.parse(t)),this._createNode(t,e)}static _createNode(t,e){var i,r,s,a=nt.prototype.getClassName.call(t),n=t.children;e&&(t.attrs.container=e),U.Konva[a]||(G.Util.warn('Can not find a node with class name "'+a+'". Fallback to "Shape".'),a="Shape");if(i=new(0,U.Konva[a])(t.attrs),n)for(r=n.length,s=0;s<r;s++)i.add(nt._createNode(n[s]));return i}}y.Node=nt,nt.prototype.nodeType="Node",nt.prototype._attrsAffectingSize=[],nt.prototype.eventListeners={},nt.prototype.on.call(nt.prototype,st,(function(){this._batchingTransformChange?this._needClearTransformCache=!0:(this._clearCache(it),this._clearSelfAndDescendantCache(Y))})),nt.prototype.on.call(nt.prototype,"visibleChange.konva",(function(){this._clearSelfAndDescendantCache(rt)})),nt.prototype.on.call(nt.prototype,"listeningChange.konva",(function(){this._clearSelfAndDescendantCache(q)})),nt.prototype.on.call(nt.prototype,"opacityChange.konva",(function(){this._clearSelfAndDescendantCache(H)}));const ot=N.Factory.addGetterSetter;ot(nt,"zIndex"),ot(nt,"absolutePosition"),ot(nt,"position"),ot(nt,"x",0,(0,j.getNumberValidator)()),ot(nt,"y",0,(0,j.getNumberValidator)()),ot(nt,"globalCompositeOperation","source-over",(0,j.getStringValidator)()),ot(nt,"opacity",1,(0,j.getNumberValidator)()),ot(nt,"name","",(0,j.getStringValidator)()),ot(nt,"id","",(0,j.getStringValidator)()),ot(nt,"rotation",0,(0,j.getNumberValidator)()),N.Factory.addComponentsGetterSetter(nt,"scale",["x","y"]),ot(nt,"scaleX",1,(0,j.getNumberValidator)()),ot(nt,"scaleY",1,(0,j.getNumberValidator)()),N.Factory.addComponentsGetterSetter(nt,"skew",["x","y"]),ot(nt,"skewX",0,(0,j.getNumberValidator)()),ot(nt,"skewY",0,(0,j.getNumberValidator)()),N.Factory.addComponentsGetterSetter(nt,"offset",["x","y"]),ot(nt,"offsetX",0,(0,j.getNumberValidator)()),ot(nt,"offsetY",0,(0,j.getNumberValidator)()),ot(nt,"dragDistance",null,(0,j.getNumberValidator)()),ot(nt,"width",0,(0,j.getNumberValidator)()),ot(nt,"height",0,(0,j.getNumberValidator)()),ot(nt,"listening",!0,(0,j.getBooleanValidator)()),ot(nt,"preventDefault",!0,(0,j.getBooleanValidator)()),ot(nt,"filters",null,(function(t){return this._filterUpToDate=!1,t})),ot(nt,"visible",!0,(0,j.getBooleanValidator)()),ot(nt,"transformsEnabled","all",(0,j.getStringValidator)()),ot(nt,"size"),ot(nt,"dragBoundFunc"),ot(nt,"draggable",!1,(0,j.getBooleanValidator)()),N.Factory.backCompat(nt,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});var ht={};Object.defineProperty(ht,"__esModule",{value:!0}),ht.Container=void 0;const lt=w,dt=y,ct=b;class ut extends dt.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=dt.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=dt.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)}}ht.Container=ut,lt.Factory.addComponentsGetterSetter(ut,"clip",["x","y","width","height"]),lt.Factory.addGetterSetter(ut,"clipX",void 0,(0,ct.getNumberValidator)()),lt.Factory.addGetterSetter(ut,"clipY",void 0,(0,ct.getNumberValidator)()),lt.Factory.addGetterSetter(ut,"clipWidth",void 0,(0,ct.getNumberValidator)()),lt.Factory.addGetterSetter(ut,"clipHeight",void 0,(0,ct.getNumberValidator)()),lt.Factory.addGetterSetter(ut,"clipFunc");var gt={},pt={};Object.defineProperty(pt,"__esModule",{value:!0}),pt.releaseCapture=pt.setPointerCapture=pt.hasPointerCapture=pt.createEvent=pt.getCapturedShape=void 0;const mt=v,ft=new Map,vt=void 0!==mt.Konva._global.PointerEvent;function _t(t){return{evt:t,pointerId:t.pointerId}}function yt(t,e){const i=ft.get(t);if(!i)return;const r=i.getStage();r&&r.content,ft.delete(t),vt&&i._fire("lostpointercapture",_t(new PointerEvent("lostpointercapture")))}pt.getCapturedShape=function(t){return ft.get(t)},pt.createEvent=_t,pt.hasPointerCapture=function(t,e){return ft.get(t)===e},pt.setPointerCapture=function(t,e){yt(t),e.getStage()&&(ft.set(t,e),vt&&e._fire("gotpointercapture",_t(new PointerEvent("gotpointercapture"))))},pt.releaseCapture=yt,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Stage=t.stages=void 0;const e=_,i=w,r=ht,s=v,a=P,n=z,o=v,h=pt;var l="mouseleave",d="mouseover",c="mouseenter",u="mousemove",g="mousedown",p="mouseup",m="pointermove",f="pointerdown",y="pointerup",b="pointercancel",x="pointerout",S="pointerleave",C="pointerover",A="pointerenter",k="contextmenu",E="touchstart",T="touchend",M="touchmove",I="touchcancel",F="wheel",O=[[c,"_pointerenter"],[g,"_pointerdown"],[u,"_pointermove"],[p,"_pointerup"],[l,"_pointerleave"],[E,"_pointerdown"],[M,"_pointermove"],[T,"_pointerup"],[I,"_pointercancel"],[d,"_pointerover"],[F,"_wheel"],[k,"_contextmenu"],[f,"_pointerdown"],[m,"_pointermove"],[y,"_pointerup"],[b,"_pointercancel"],["lostpointercapture","_lostpointercapture"]];const D={mouse:{[x]:"mouseout",[S]:l,[C]:d,[A]:c,[m]:u,[f]:g,[y]:p,[b]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[x]:"touchout",[S]:"touchleave",[C]:"touchover",[A]:"touchenter",[m]:M,[f]:E,[y]:T,[b]:I,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[x]:x,[S]:S,[C]:C,[A]:A,[m]:m,[f]:f,[y]:y,[b]:b,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},R=t=>t.indexOf("pointer")>=0?"pointer":t.indexOf("touch")>=0?"touch":"mouse",V=t=>{const e=R(t);return"pointer"===e?s.Konva.pointerEventsEnabled&&D.pointer:"touch"===e?D.touch:"mouse"===e?D.mouse:void 0};function L(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 G extends r.Container{constructor(e){super(L(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",(()=>{L(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&&O.forEach((([t,e])=>{this.content.addEventListener(t,(t=>{this[e](t)}),{passive:!1})}))}_pointerenter(t){this.setPointersPositions(t);const e=V(t.type);e&&this._fire(e.pointerenter,{evt:t,target:this,currentTarget:this})}_pointerover(t){this.setPointersPositions(t);const e=V(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=V(t.type),i=R(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=V(t.type),i=R(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 void(this[i+"ClickStartShape"]=void 0);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=V(t.type),i=R(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=V(t.type),i=R(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(k,{evt:t}):this._fire(k,{evt:t,target:this,currentTarget:this})}_wheel(t){this.setPointersPositions(t);var e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(F,{evt:t}):this._fire(F,{evt:t,target:this,currentTarget:this})}_pointercancel(t){this.setPointersPositions(t);const e=h.getCapturedShape(t.pointerId)||this.getIntersection(this.getPointerPosition());e&&e._fireAndBubble(y,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=G,G.prototype.nodeType="Stage",(0,o._registerNode)(G),i.Factory.addGetterSetter(G,"container"),s.Konva.isBrowser&&document.addEventListener("visibilitychange",(()=>{t.stages.forEach((t=>{t.batchDraw()}))}))}(gt);var wt={},bt={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Shape=t.shapes=void 0;const e=v,i=_,r=w,s=y,a=b,n=v,o=pt;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={}){let e=!1,i=this.getParent();for(;i;){if(i.isCached()){e=!0;break}i=i.getParent()}const r=t.skipTransform,s=t.relativeTo||e&&this.getStage()||void 0,a=this.getSelfRect(),n=!t.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,o=a.width+n,h=a.height+n,l=!t.skipShadow&&this.hasShadow(),d=l?this.shadowOffsetX():0,c=l?this.shadowOffsetY():0,u=o+Math.abs(d),g=h+Math.abs(c),p=l&&this.shadowBlur()||0,m={width:u+2*p,height:g+2*p,x:-(n/2+p)+Math.min(d,0)+a.x,y:-(n/2+p)+Math.min(c,0)+a.y};return r?m:this._transformedRect(m,s)}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"})}(bt),Object.defineProperty(wt,"__esModule",{value:!0}),wt.Layer=void 0;const xt=_,St=ht,Ct=y,Pt=w,At=P,kt=b,Et=bt,Tt=v;var Mt=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],It=Mt.length;class Ft extends St.Container{constructor(t){super(t),this.canvas=new At.SceneCanvas,this.hitCanvas=new At.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(){Ct.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(!Ct.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(Ct.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(Ct.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 Ct.Node.prototype.remove.call(this),t&&t.parentNode&&xt.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&&xt.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(),Ct.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(){xt.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){xt.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,xt.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<It;r++){const s=Mt[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=xt.Util._rgbToHex(i[0],i[1],i[2]),e=Et.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(),St.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(),St.Container.prototype.drawHit.call(this,r,e),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(t){xt.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(t)}getHitGraphEnabled(t){return xt.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 xt.Util.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}}wt.Layer=Ft,Ft.prototype.nodeType="Layer",(0,Tt._registerNode)(Ft),Pt.Factory.addGetterSetter(Ft,"imageSmoothingEnabled",!0),Pt.Factory.addGetterSetter(Ft,"clearBeforeDraw",!0),Pt.Factory.addGetterSetter(Ft,"hitGraphEnabled",!0,(0,kt.getBooleanValidator)());var Ot={};Object.defineProperty(Ot,"__esModule",{value:!0}),Ot.FastLayer=void 0;const Dt=_,Rt=wt,Vt=v;class Lt extends Rt.Layer{constructor(t){super(t),this.listening(!1),Dt.Util.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}}Ot.FastLayer=Lt,Lt.prototype.nodeType="FastLayer",(0,Vt._registerNode)(Lt);var zt={};Object.defineProperty(zt,"__esModule",{value:!0}),zt.Group=void 0;const Gt=_,Nt=ht,Wt=v;class Ut extends Nt.Container{_validateAdd(t){var e=t.getType();"Group"!==e&&"Shape"!==e&&Gt.Util.throw("You may only add groups and shapes to groups.")}}zt.Group=Ut,Ut.prototype.nodeType="Group",(0,Wt._registerNode)(Ut);var Bt={};Object.defineProperty(Bt,"__esModule",{value:!0}),Bt.Animation=void 0;const jt=v,Ht=_,Kt=jt.glob.performance&&jt.glob.performance.now?function(){return jt.glob.performance.now()}:function(){return(new Date).getTime()};class Yt{constructor(t,e){this.id=Yt.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:Kt(),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=Yt.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=Kt(),Yt._addAnimation(this),this}stop(){return Yt._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(Kt());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=Yt;t.animations.length?(t._runFrames(),Ht.Util.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,Ht.Util.requestAnimFrame(this._animationLoop))}}Bt.Animation=Yt,Yt.animations=[],Yt.animIdCounter=0,Yt.animRunning=!1;var Xt={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Easings=t.Tween=void 0;const e=_,i=Bt,r=y,s=v;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}}(Xt),function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Konva=void 0;const e=v,i=_,r=y,s=ht,a=gt,n=wt,o=Ot,h=zt,l=z,d=bt,c=Bt,u=Xt,g=A,p=P;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}(f);var Jt={};Object.defineProperty(Jt,"__esModule",{value:!0}),Jt.Arc=void 0;const qt=w,Zt=bt,$t=v,Qt=b,te=v;class ee extends Zt.Shape{_sceneFunc(t){var e=$t.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=$t.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}}}Jt.Arc=ee,ee.prototype._centroid=!0,ee.prototype.className="Arc",ee.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,te._registerNode)(ee),qt.Factory.addGetterSetter(ee,"innerRadius",0,(0,Qt.getNumberValidator)()),qt.Factory.addGetterSetter(ee,"outerRadius",0,(0,Qt.getNumberValidator)()),qt.Factory.addGetterSetter(ee,"angle",0,(0,Qt.getNumberValidator)()),qt.Factory.addGetterSetter(ee,"clockwise",!1,(0,Qt.getBooleanValidator)());var ie={},re={};Object.defineProperty(re,"__esModule",{value:!0}),re.Line=void 0;const se=w,ae=bt,ne=b,oe=v;function he(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 le(t,e){var i,r,s=t.length,a=[];for(i=2;i<s-2;i+=2)r=he(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 de extends ae.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():le(this.points(),this.tension())}_getTensionPointsClosed(){var t=this.points(),e=t.length,i=this.tension(),r=he(t[e-2],t[e-1],t[0],t[1],t[2],t[3],i),s=he(t[e-4],t[e-3],t[e-2],t[e-1],t[0],t[1],i),a=le(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}}}re.Line=de,de.prototype.className="Line",de.prototype._attrsAffectingSize=["points","bezier","tension"],(0,oe._registerNode)(de),se.Factory.addGetterSetter(de,"closed",!1),se.Factory.addGetterSetter(de,"bezier",!1),se.Factory.addGetterSetter(de,"tension",0,(0,ne.getNumberValidator)()),se.Factory.addGetterSetter(de,"points",[],(0,ne.getNumberArrayValidator)());var ce={},ue={};!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}}(ue),Object.defineProperty(ce,"__esModule",{value:!0}),ce.Path=void 0;const ge=w,pe=bt,me=v,fe=ue;class ve extends pe.Shape{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",(function(){this._readDataAttribute()}))}_readDataAttribute(){this.dataArray=ve.parsePathData(this.data()),this.pathLength=ve.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=ve.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=ve.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=ve.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 ve.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 ve.getPointOnLine(t,a.start.x,a.start.y,n[0],n[1]);case"C":return ve.getPointOnCubicBezier((0,fe.t2length)(t,ve.getPathLength(e),(t=>(0,fe.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 ve.getPointOnQuadraticBezier((0,fe.t2length)(t,ve.getPathLength(e),(t=>(0,fe.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,ve.getPointOnEllipticalArc(o,h,l,d,c,g)}return null}static getPointOnLine(t,e,i,r,s,a,n){a=null!=a?a:e,n=null!=n?n:i;const o=this.getLineLength(e,i,r,s);if(o<1e-10)return{x:e,y:i};if(r===e)return{x:a,y:n+(s>i?t:-t)};const h=(s-i)/(r-e),l=Math.sqrt(t*t/(1+h*h))*(r<e?-1:1),d=h*l;if(Math.abs(n-i-h*(a-e))<1e-10)return{x:a+l,y:n+d};const c=((a-e)*(r-e)+(n-i)*(s-i))/(o*o),u=e+c*(r-e),g=i+c*(s-i),p=this.getLineLength(a,n,u,g),m=Math.sqrt(t*t-p*p),f=Math.sqrt(m*m/(1+h*h))*(r<e?-1:1);return{x:u+f,y:g+h*f}}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,A,k="",E=[],T=h,M=l;switch(u){case"l":h+=g.shift(),l+=g.shift(),k="L",E.push(h,l);break;case"L":h=g.shift(),l=g.shift(),E.push(h,l);break;case"m":var I=g.shift(),F=g.shift();if(h+=I,l+=F,k="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]+I,l=n[O].points[1]+F;break}E.push(h,l),u="l";break;case"M":h=g.shift(),l=g.shift(),k="M",E.push(h,l),u="L";break;case"h":h+=g.shift(),k="L",E.push(h,l);break;case"H":h=g.shift(),k="L",E.push(h,l);break;case"v":l+=g.shift(),k="L",E.push(h,l);break;case"V":l=g.shift(),k="L",E.push(h,l);break;case"C":E.push(g.shift(),g.shift(),g.shift(),g.shift()),h=g.shift(),l=g.shift(),E.push(h,l);break;case"c":E.push(h+g.shift(),l+g.shift(),h+g.shift(),l+g.shift()),h+=g.shift(),l+=g.shift(),k="C",E.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])),E.push(_,y,g.shift(),g.shift()),h=g.shift(),l=g.shift(),k="C",E.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])),E.push(_,y,h+g.shift(),l+g.shift()),h+=g.shift(),l+=g.shift(),k="C",E.push(h,l);break;case"Q":E.push(g.shift(),g.shift()),h=g.shift(),l=g.shift(),E.push(h,l);break;case"q":E.push(h+g.shift(),l+g.shift()),h+=g.shift(),l+=g.shift(),k="Q",E.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(),k="Q",E.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(),k="Q",E.push(_,y,h,l);break;case"A":w=g.shift(),b=g.shift(),x=g.shift(),S=g.shift(),C=g.shift(),P=h,A=l,h=g.shift(),l=g.shift(),k="A",E=this.convertEndpointToCenterParameterization(P,A,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,A=l,h+=g.shift(),l+=g.shift(),k="A",E=this.convertEndpointToCenterParameterization(P,A,h,l,S,C,w,b,x)}n.push({command:k||u,points:E,start:{x:T,y:M},pathLength:this.calcLength(T,M,k||u,E)})}"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=ve;switch(i){case"L":return h.getLineLength(t,e,r[0],r[1]);case"C":return(0,fe.getCubicArcLength)([t,r[0],r[2],r[4]],[e,r[1],r[3],r[5]],1);case"Q":return(0,fe.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]}}ce.Path=ve,ve.prototype.className="Path",ve.prototype._attrsAffectingSize=["data"],(0,me._registerNode)(ve),ge.Factory.addGetterSetter(ve,"data"),Object.defineProperty(ie,"__esModule",{value:!0}),ie.Arrow=void 0;const _e=w,ye=re,we=b,be=v,xe=ce;class Se extends ye.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=xe.Path.calcLength(r[r.length-4],r[r.length-3],"C",t),s=xe.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}}}ie.Arrow=Se,Se.prototype.className="Arrow",(0,be._registerNode)(Se),_e.Factory.addGetterSetter(Se,"pointerLength",10,(0,we.getNumberValidator)()),_e.Factory.addGetterSetter(Se,"pointerWidth",10,(0,we.getNumberValidator)()),_e.Factory.addGetterSetter(Se,"pointerAtBeginning",!1),_e.Factory.addGetterSetter(Se,"pointerAtEnding",!0);var Ce={};Object.defineProperty(Ce,"__esModule",{value:!0}),Ce.Circle=void 0;const Pe=w,Ae=bt,ke=b,Ee=v;class Te extends Ae.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)}}Ce.Circle=Te,Te.prototype._centroid=!0,Te.prototype.className="Circle",Te.prototype._attrsAffectingSize=["radius"],(0,Ee._registerNode)(Te),Pe.Factory.addGetterSetter(Te,"radius",0,(0,ke.getNumberValidator)());var Me={};Object.defineProperty(Me,"__esModule",{value:!0}),Me.Ellipse=void 0;const Ie=w,Fe=bt,Oe=b,De=v;class Re extends Fe.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)}}Me.Ellipse=Re,Re.prototype.className="Ellipse",Re.prototype._centroid=!0,Re.prototype._attrsAffectingSize=["radiusX","radiusY"],(0,De._registerNode)(Re),Ie.Factory.addComponentsGetterSetter(Re,"radius",["x","y"]),Ie.Factory.addGetterSetter(Re,"radiusX",0,(0,Oe.getNumberValidator)()),Ie.Factory.addGetterSetter(Re,"radiusY",0,(0,Oe.getNumberValidator)());var Ve={};Object.defineProperty(Ve,"__esModule",{value:!0}),Ve.Image=void 0;const Le=_,ze=w,Ge=bt,Ne=v,We=b;class Ue extends Ge.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?Le.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?Le.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=Le.Util.createImageElement();r.onload=function(){var t=new Ue({image:r});e(t)},r.onerror=i,r.crossOrigin="Anonymous",r.src=t}}Ve.Image=Ue,Ue.prototype.className="Image",(0,Ne._registerNode)(Ue),ze.Factory.addGetterSetter(Ue,"cornerRadius",0,(0,We.getNumberOrArrayOfNumbersValidator)(4)),ze.Factory.addGetterSetter(Ue,"image"),ze.Factory.addComponentsGetterSetter(Ue,"crop",["x","y","width","height"]),ze.Factory.addGetterSetter(Ue,"cropX",0,(0,We.getNumberValidator)()),ze.Factory.addGetterSetter(Ue,"cropY",0,(0,We.getNumberValidator)()),ze.Factory.addGetterSetter(Ue,"cropWidth",0,(0,We.getNumberValidator)()),ze.Factory.addGetterSetter(Ue,"cropHeight",0,(0,We.getNumberValidator)());var Be={};Object.defineProperty(Be,"__esModule",{value:!0}),Be.Tag=Be.Label=void 0;const je=w,He=bt,Ke=zt,Ye=b,Xe=v;var Je=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],qe="up",Ze="right",$e="down",Qe="left",ti=Je.length;class ei extends Ke.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<ti;e++)t.on(Je[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 qe:s=t/2,a=-1*n;break;case Ze:s=t+r,a=e/2;break;case $e:s=t/2,a=e+n;break;case Qe: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})}}}Be.Label=ei,ei.prototype.className="Label",(0,Xe._registerNode)(ei);class ii extends He.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===qe&&(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===Ze&&(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===$e&&(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===Qe&&(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===qe?(e-=r,n+=r):s===$e?n+=r:s===Qe?(t-=1.5*i,a+=i):s===Ze&&(a+=1.5*i),{x:t,y:e,width:a,height:n}}}Be.Tag=ii,ii.prototype.className="Tag",(0,Xe._registerNode)(ii),je.Factory.addGetterSetter(ii,"pointerDirection","none"),je.Factory.addGetterSetter(ii,"pointerWidth",0,(0,Ye.getNumberValidator)()),je.Factory.addGetterSetter(ii,"pointerHeight",0,(0,Ye.getNumberValidator)()),je.Factory.addGetterSetter(ii,"cornerRadius",0,(0,Ye.getNumberOrArrayOfNumbersValidator)(4));var ri={};Object.defineProperty(ri,"__esModule",{value:!0}),ri.Rect=void 0;const si=w,ai=bt,ni=v,oi=_,hi=b;class li extends ai.Shape{_sceneFunc(t){var e=this.cornerRadius(),i=this.width(),r=this.height();t.beginPath(),e?oi.Util.drawRoundedRectPath(t,i,r,e):t.rect(0,0,i,r),t.closePath(),t.fillStrokeShape(this)}}ri.Rect=li,li.prototype.className="Rect",(0,ni._registerNode)(li),si.Factory.addGetterSetter(li,"cornerRadius",0,(0,hi.getNumberOrArrayOfNumbersValidator)(4));var di={};Object.defineProperty(di,"__esModule",{value:!0}),di.RegularPolygon=void 0;const ci=w,ui=bt,gi=b,pi=v;class mi extends ui.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)}}di.RegularPolygon=mi,mi.prototype.className="RegularPolygon",mi.prototype._centroid=!0,mi.prototype._attrsAffectingSize=["radius"],(0,pi._registerNode)(mi),ci.Factory.addGetterSetter(mi,"radius",0,(0,gi.getNumberValidator)()),ci.Factory.addGetterSetter(mi,"sides",0,(0,gi.getNumberValidator)());var fi={};Object.defineProperty(fi,"__esModule",{value:!0}),fi.Ring=void 0;const vi=w,_i=bt,yi=b,wi=v;var bi=2*Math.PI;class xi extends _i.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.innerRadius(),0,bi,!1),t.moveTo(this.outerRadius(),0),t.arc(0,0,this.outerRadius(),bi,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)}}fi.Ring=xi,xi.prototype.className="Ring",xi.prototype._centroid=!0,xi.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,wi._registerNode)(xi),vi.Factory.addGetterSetter(xi,"innerRadius",0,(0,yi.getNumberValidator)()),vi.Factory.addGetterSetter(xi,"outerRadius",0,(0,yi.getNumberValidator)());var Si={};Object.defineProperty(Si,"__esModule",{value:!0}),Si.Sprite=void 0;const Ci=w,Pi=bt,Ai=Bt,ki=b,Ei=v;class Ti extends Pi.Shape{constructor(t){super(t),this._updated=!0,this.anim=new Ai.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)}}Si.Sprite=Ti,Ti.prototype.className="Sprite",(0,Ei._registerNode)(Ti),Ci.Factory.addGetterSetter(Ti,"animation"),Ci.Factory.addGetterSetter(Ti,"animations"),Ci.Factory.addGetterSetter(Ti,"frameOffsets"),Ci.Factory.addGetterSetter(Ti,"image"),Ci.Factory.addGetterSetter(Ti,"frameIndex",0,(0,ki.getNumberValidator)()),Ci.Factory.addGetterSetter(Ti,"frameRate",17,(0,ki.getNumberValidator)()),Ci.Factory.backCompat(Ti,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});var Mi={};Object.defineProperty(Mi,"__esModule",{value:!0}),Mi.Star=void 0;const Ii=w,Fi=bt,Oi=b,Di=v;class Ri extends Fi.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)}}Mi.Star=Ri,Ri.prototype.className="Star",Ri.prototype._centroid=!0,Ri.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,Di._registerNode)(Ri),Ii.Factory.addGetterSetter(Ri,"numPoints",5,(0,Oi.getNumberValidator)()),Ii.Factory.addGetterSetter(Ri,"innerRadius",0,(0,Oi.getNumberValidator)()),Ii.Factory.addGetterSetter(Ri,"outerRadius",0,(0,Oi.getNumberValidator)());var Vi={};Object.defineProperty(Vi,"__esModule",{value:!0}),Vi.Text=Vi.stringToArray=void 0;const Li=_,zi=w,Gi=bt,Ni=v,Wi=b,Ui=v;function Bi(t){return Array.from(t)}Vi.stringToArray=Bi;var ji,Hi="auto",Ki="inherit",Yi="justify",Xi="left",Ji="middle",qi="normal",Zi=" ",$i="none",Qi=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],tr=Qi.length;function er(){return ji||(ji=Li.Util.createCanvasElement().getContext("2d"))}class ir extends Gi.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<tr;e++)this.on(Qi[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");h=h===Ki?t.direction:h;var v=n/2,_=Ji;if(Ni.Konva._fixTextRendering){var y=this.measureSize("M");_="alphabetic",v=(y.fontBoundingBoxAscent-y.fontBoundingBoxDescent)/2+n/2}var w=0,b=0;for("rtl"===h&&t.setAttr("direction",h),t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",_),t.setAttr("textAlign",Xi),o===Ji?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++){w=0,b=0;var x,S,C,P=e[r],A=P.text,k=P.width,E=P.lastInParagraph;if(t.save(),"right"===d?w+=c-k-2*s:"center"===d&&(w+=(c-k-2*s)/2),m){t.save(),t.beginPath();const e=w,i=v+b+(Ni.Konva._fixTextRendering?Math.round(a/4):Math.round(a/2));t.moveTo(e,i),S=0===(x=A.split(" ").length-1),C=d!==Yi||E?k:c-2*s,t.lineTo(e+Math.round(C),i),t.lineWidth=a/15;const r=this._getLinearGradient();t.strokeStyle=r||g,t.stroke(),t.restore()}if(f){t.save(),t.beginPath();let e=Ni.Konva._fixTextRendering?-Math.round(a/4):0;t.moveTo(w,v+b+e),S=0===(x=A.split(" ").length-1),C=d===Yi&&E&&!S?c-2*s:k,t.lineTo(w+Math.round(C),v+b+e),t.lineWidth=a/15;const i=this._getLinearGradient();t.strokeStyle=i||g,t.stroke(),t.restore()}if("rtl"===h||0===u&&d!==Yi)0!==u&&t.setAttr("letterSpacing",`${u}px`),this._partialTextX=w,this._partialTextY=v+b,this._partialText=A,t.fillStrokeShape(this);else{x=A.split(" ").length-1;for(var T=Bi(A),M=0;M<T.length;M++){var I=T[M];" "!==I||E||d!==Yi||(w+=(c-2*s-k)/x),this._partialTextX=w,this._partialTextY=v+b,this._partialText=I,t.fillStrokeShape(this),w+=this.measureSize(I).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=Li.Util._isString(t)?t:null==t?"":t+"";return this._setAttr("text",e),this}getWidth(){return this.attrs.width===Hi||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}getHeight(){return this.attrs.height===Hi||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return Li.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(t){var e,i,r,s,a,n,o,h,l,d,c,u,g=er(),p=this.fontSize();g.save(),g.font=this._getContextFont(),u=g.measureText(t),g.restore();const m=p/100;return{actualBoundingBoxAscent:null!==(e=u.actualBoundingBoxAscent)&&void 0!==e?e:71.58203125*m,actualBoundingBoxDescent:null!==(i=u.actualBoundingBoxDescent)&&void 0!==i?i:0,actualBoundingBoxLeft:null!==(r=u.actualBoundingBoxLeft)&&void 0!==r?r:-7.421875*m,actualBoundingBoxRight:null!==(s=u.actualBoundingBoxRight)&&void 0!==s?s:75.732421875*m,alphabeticBaseline:null!==(a=u.alphabeticBaseline)&&void 0!==a?a:0,emHeightAscent:null!==(n=u.emHeightAscent)&&void 0!==n?n:100*m,emHeightDescent:null!==(o=u.emHeightDescent)&&void 0!==o?o:-20*m,fontBoundingBoxAscent:null!==(h=u.fontBoundingBoxAscent)&&void 0!==h?h:91*m,fontBoundingBoxDescent:null!==(l=u.fontBoundingBoxDescent)&&void 0!==l?l:21*m,hangingBaseline:null!==(d=u.hangingBaseline)&&void 0!==d?d:72.80000305175781*m,ideographicBaseline:null!==(c=u.ideographicBaseline)&&void 0!==c?c:-21*m,width:u.width,height:p}}_getContextFont(){return this.fontStyle()+Zi+this.fontVariant()+Zi+(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()===Yi&&(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 er().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!==Hi&&void 0!==s,o=a!==Hi&&void 0!==a,h=this.padding(),l=s-2*h,d=a-2*h,c=0,u=this.wrap(),g="char"!==u&&u!==$i,p=this.ellipsis();this.textArr=[],er().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),A=this._getTextWidth(P)+m;A<=l?(w=C+1,x=P,S=A):b=C}if(!x)break;if(g){var k,E=_[x.length];(k=(E===Zi||"-"===E)&&S<=l?x.length:Math.max(x.lastIndexOf(Zi),x.lastIndexOf("-"))+1)>0&&(w=k,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!==Hi&&void 0!==r,a=r-2*this.padding();return!(this.wrap()!==$i)||s&&t+i>a}_tryToAddEllipsisToLastLine(){var t=this.attrs.width,e=t!==Hi&&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()}}Vi.Text=ir,ir.prototype._fillFunc=function(t){t.fillText(this._partialText,this._partialTextX,this._partialTextY)},ir.prototype._strokeFunc=function(t){t.setAttr("miterLimit",2),t.strokeText(this._partialText,this._partialTextX,this._partialTextY)},ir.prototype.className="Text",ir.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],(0,Ui._registerNode)(ir),zi.Factory.overWriteSetter(ir,"width",(0,Wi.getNumberOrAutoValidator)()),zi.Factory.overWriteSetter(ir,"height",(0,Wi.getNumberOrAutoValidator)()),zi.Factory.addGetterSetter(ir,"direction",Ki),zi.Factory.addGetterSetter(ir,"fontFamily","Arial"),zi.Factory.addGetterSetter(ir,"fontSize",12,(0,Wi.getNumberValidator)()),zi.Factory.addGetterSetter(ir,"fontStyle",qi),zi.Factory.addGetterSetter(ir,"fontVariant",qi),zi.Factory.addGetterSetter(ir,"padding",0,(0,Wi.getNumberValidator)()),zi.Factory.addGetterSetter(ir,"align",Xi),zi.Factory.addGetterSetter(ir,"verticalAlign","top"),zi.Factory.addGetterSetter(ir,"lineHeight",1,(0,Wi.getNumberValidator)()),zi.Factory.addGetterSetter(ir,"wrap","word"),zi.Factory.addGetterSetter(ir,"ellipsis",!1,(0,Wi.getBooleanValidator)()),zi.Factory.addGetterSetter(ir,"letterSpacing",0,(0,Wi.getNumberValidator)()),zi.Factory.addGetterSetter(ir,"text","",(0,Wi.getStringValidator)()),zi.Factory.addGetterSetter(ir,"textDecoration","");var rr={};Object.defineProperty(rr,"__esModule",{value:!0}),rr.TextPath=void 0;const sr=_,ar=w,nr=bt,or=ce,hr=Vi,lr=b,dr=v;var cr="normal";function ur(t){t.fillText(this.partialText,0,0)}function gr(t){t.strokeText(this.partialText,0,0)}class pr extends nr.Shape{constructor(t){super(t),this.dummyCanvas=sr.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 or.Path.getPathLength(this.dataArray)}_getPointAtLength(t){if(!this.attrs.data)return null;return t-1>this.pathLength?null:or.Path.getPointAtLengthOfDataArray(t,this.dataArray)}_readDataAttribute(){this.dataArray=or.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 sr.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 hr.Text.prototype.setText.call(this,t)}_getContextFont(){return hr.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,hr.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=or.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=or.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 sr.Util.releaseCanvas(this.dummyCanvas),super.destroy()}}rr.TextPath=pr,pr.prototype._fillFunc=ur,pr.prototype._strokeFunc=gr,pr.prototype._fillFuncHit=ur,pr.prototype._strokeFuncHit=gr,pr.prototype.className="TextPath",pr.prototype._attrsAffectingSize=["text","fontSize","data"],(0,dr._registerNode)(pr),ar.Factory.addGetterSetter(pr,"data"),ar.Factory.addGetterSetter(pr,"fontFamily","Arial"),ar.Factory.addGetterSetter(pr,"fontSize",12,(0,lr.getNumberValidator)()),ar.Factory.addGetterSetter(pr,"fontStyle",cr),ar.Factory.addGetterSetter(pr,"align","left"),ar.Factory.addGetterSetter(pr,"letterSpacing",0,(0,lr.getNumberValidator)()),ar.Factory.addGetterSetter(pr,"textBaseline","middle"),ar.Factory.addGetterSetter(pr,"fontVariant",cr),ar.Factory.addGetterSetter(pr,"text",""),ar.Factory.addGetterSetter(pr,"textDecoration",null),ar.Factory.addGetterSetter(pr,"kerningFunc",null);var mr={};Object.defineProperty(mr,"__esModule",{value:!0}),mr.Transformer=void 0;const fr=_,vr=w,_r=y,yr=bt,wr=ri,br=zt,xr=v,Sr=b,Cr=v;var Pr="tr-konva",Ar=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map((t=>t+`.${Pr}`)).join(" "),kr="nodesRect",Er=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],Tr={"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 Mr="ontouchstart"in xr.Konva._global;var Ir=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function Fr(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 Or(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 Fr(t,e,i)}let Dr=0;class Rr extends br.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(Ar,this.update),this.getNode()&&this.update()}attachTo(t){return this.setNode(t),this}setNode(t){return fr.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 Pr+this._id}setNodes(t=[]){this._nodes&&this._nodes.length&&this.detach();const e=t.filter((t=>!t.isAncestorOf(this)||(fr.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(Er.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(kr),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(kr,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=(xr.Konva.getAngle(t.getAbsoluteRotation())+2*Math.PI)%(2*Math.PI);return Fr({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},-xr.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 fr.Transform;e.rotate(-xr.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:xr.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(),Ir.forEach((t=>{this._createAnchor(t)})),this._createAnchor("rotater")}_createAnchor(t){var e=new wr.Rect({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:t+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:Mr?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=xr.Konva.getAngle(this.rotation()),r=this.rotateAnchorCursor(),s=function(t,e,i){if("rotater"===t)return i;e+=fr.Util.degToRad(Tr[t]||0);var r=(fr.Util.radToDeg(e)%360+360)%360;return fr.Util._inRange(r,337.5,360)||fr.Util._inRange(r,0,22.5)?"ns-resize":fr.Util._inRange(r,22.5,67.5)?"nesw-resize":fr.Util._inRange(r,67.5,112.5)?"ew-resize":fr.Util._inRange(r,112.5,157.5)?"nwse-resize":fr.Util._inRange(r,157.5,202.5)?"ns-resize":fr.Util._inRange(r,202.5,247.5)?"nesw-resize":fr.Util._inRange(r,247.5,292.5)?"ew-resize":fr.Util._inRange(r,292.5,337.5)?"nwse-resize":(fr.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 yr.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()*fr.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){if(!this._transforming){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},Dr++,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:xr.Konva.getAngle(this.rotation())},t)}else{var A=this._getNodeRect();e=s.x()-A.width/2,i=-s.y()+A.height/2;let r=Math.atan2(-i,e)+Math.PI/2;A.height<0&&(r-=Math.PI);const a=xr.Konva.getAngle(this.rotation())+r,n=xr.Konva.getAngle(this.rotationSnapTolerance()),o=Or(A,function(t,e,i){let r=e;for(let s=0;s<t.length;s++){const a=xr.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)-A.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();Dr--,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(fr.Util._inRange(t.width,2*-this.padding()-1,1))return void this.update();if(fr.Util._inRange(t.height,2*-this.padding()-1,1))return void this.update();var r=new fr.Transform;if(r.rotate(xr.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:fr.Util.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const s=1e7,a=new fr.Transform;a.translate(i.x,i.y),a.rotate(i.rotation),a.scale(i.width/s,i.height/s);const n=new fr.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 fr.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(fr.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(fr.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()*fr.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=""),br.Group.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return _r.Node.prototype.toObject.call(this)}clone(t){return _r.Node.prototype.clone.call(this,t)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}}mr.Transformer=Rr,Rr.isTransforming=()=>Dr>0,Rr.prototype.className="Transformer",(0,Cr._registerNode)(Rr),vr.Factory.addGetterSetter(Rr,"enabledAnchors",Ir,(function(t){return t instanceof Array||fr.Util.warn("enabledAnchors value should be an array"),t instanceof Array&&t.forEach((function(t){-1===Ir.indexOf(t)&&fr.Util.warn("Unknown anchor name: "+t+". Available names are: "+Ir.join(", "))})),t||[]})),vr.Factory.addGetterSetter(Rr,"flipEnabled",!0,(0,Sr.getBooleanValidator)()),vr.Factory.addGetterSetter(Rr,"resizeEnabled",!0),vr.Factory.addGetterSetter(Rr,"anchorSize",10,(0,Sr.getNumberValidator)()),vr.Factory.addGetterSetter(Rr,"rotateEnabled",!0),vr.Factory.addGetterSetter(Rr,"rotateLineVisible",!0),vr.Factory.addGetterSetter(Rr,"rotationSnaps",[]),vr.Factory.addGetterSetter(Rr,"rotateAnchorOffset",50,(0,Sr.getNumberValidator)()),vr.Factory.addGetterSetter(Rr,"rotateAnchorCursor","crosshair"),vr.Factory.addGetterSetter(Rr,"rotationSnapTolerance",5,(0,Sr.getNumberValidator)()),vr.Factory.addGetterSetter(Rr,"borderEnabled",!0),vr.Factory.addGetterSetter(Rr,"anchorStroke","rgb(0, 161, 255)"),vr.Factory.addGetterSetter(Rr,"anchorStrokeWidth",1,(0,Sr.getNumberValidator)()),vr.Factory.addGetterSetter(Rr,"anchorFill","white"),vr.Factory.addGetterSetter(Rr,"anchorCornerRadius",0,(0,Sr.getNumberValidator)()),vr.Factory.addGetterSetter(Rr,"borderStroke","rgb(0, 161, 255)"),vr.Factory.addGetterSetter(Rr,"borderStrokeWidth",1,(0,Sr.getNumberValidator)()),vr.Factory.addGetterSetter(Rr,"borderDash"),vr.Factory.addGetterSetter(Rr,"keepRatio",!0),vr.Factory.addGetterSetter(Rr,"shiftBehavior","default"),vr.Factory.addGetterSetter(Rr,"centeredScaling",!1),vr.Factory.addGetterSetter(Rr,"ignoreStroke",!1),vr.Factory.addGetterSetter(Rr,"padding",0,(0,Sr.getNumberValidator)()),vr.Factory.addGetterSetter(Rr,"node"),vr.Factory.addGetterSetter(Rr,"nodes"),vr.Factory.addGetterSetter(Rr,"boundBoxFunc"),vr.Factory.addGetterSetter(Rr,"anchorDragBoundFunc"),vr.Factory.addGetterSetter(Rr,"anchorStyleFunc"),vr.Factory.addGetterSetter(Rr,"shouldOverdrawWholeArea",!1),vr.Factory.addGetterSetter(Rr,"useSingleNodeRotation",!0),vr.Factory.backCompat(Rr,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});var Vr={};Object.defineProperty(Vr,"__esModule",{value:!0}),Vr.Wedge=void 0;const Lr=w,zr=bt,Gr=v,Nr=b,Wr=v;class Ur extends zr.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.radius(),0,Gr.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)}}Vr.Wedge=Ur,Ur.prototype.className="Wedge",Ur.prototype._centroid=!0,Ur.prototype._attrsAffectingSize=["radius"],(0,Wr._registerNode)(Ur),Lr.Factory.addGetterSetter(Ur,"radius",0,(0,Nr.getNumberValidator)()),Lr.Factory.addGetterSetter(Ur,"angle",0,(0,Nr.getNumberValidator)()),Lr.Factory.addGetterSetter(Ur,"clockwise",!1),Lr.Factory.backCompat(Ur,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});var Br={};Object.defineProperty(Br,"__esModule",{value:!0}),Br.Blur=void 0;const jr=w,Hr=y,Kr=b;function Yr(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var Xr=[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],Jr=[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];Br.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,A=t.data,k=t.width,E=t.height,T=e+e+1,M=k-1,I=E-1,F=e+1,O=F*(F+1)/2,D=new Yr,R=null,V=D,L=null,z=null,G=Xr[e],N=Jr[e];for(s=1;s<T;s++)V=V.next=new Yr,s===F&&(R=V);for(V.next=D,h=o=0,r=0;r<E;r++){for(v=_=y=w=l=d=c=u=0,g=F*(b=A[o]),p=F*(x=A[o+1]),m=F*(S=A[o+2]),f=F*(C=A[o+3]),l+=O*b,d+=O*x,c+=O*S,u+=O*C,V=D,s=0;s<F;s++)V.r=b,V.g=x,V.b=S,V.a=C,V=V.next;for(s=1;s<F;s++)a=o+((M<s?M:s)<<2),l+=(V.r=b=A[a])*(P=F-s),d+=(V.g=x=A[a+1])*P,c+=(V.b=S=A[a+2])*P,u+=(V.a=C=A[a+3])*P,v+=b,_+=x,y+=S,w+=C,V=V.next;for(L=D,z=R,i=0;i<k;i++)A[o+3]=C=u*G>>N,0!==C?(C=255/C,A[o]=(l*G>>N)*C,A[o+1]=(d*G>>N)*C,A[o+2]=(c*G>>N)*C):A[o]=A[o+1]=A[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=A[a],d+=_+=L.g=A[a+1],c+=y+=L.b=A[a+2],u+=w+=L.a=A[a+3],L=L.next,g+=b=z.r,p+=x=z.g,m+=S=z.b,f+=C=z.a,v-=b,_-=x,y-=S,w-=C,z=z.next,o+=4;h+=k}for(i=0;i<k;i++){for(_=y=w=v=d=c=u=l=0,g=F*(b=A[o=i<<2]),p=F*(x=A[o+1]),m=F*(S=A[o+2]),f=F*(C=A[o+3]),l+=O*b,d+=O*x,c+=O*S,u+=O*C,V=D,s=0;s<F;s++)V.r=b,V.g=x,V.b=S,V.a=C,V=V.next;for(n=k,s=1;s<=e;s++)o=n+i<<2,l+=(V.r=b=A[o])*(P=F-s),d+=(V.g=x=A[o+1])*P,c+=(V.b=S=A[o+2])*P,u+=(V.a=C=A[o+3])*P,v+=b,_+=x,y+=S,w+=C,V=V.next,s<I&&(n+=k);for(o=i,L=D,z=R,r=0;r<E;r++)A[3+(a=o<<2)]=C=u*G>>N,C>0?(C=255/C,A[a]=(l*G>>N)*C,A[a+1]=(d*G>>N)*C,A[a+2]=(c*G>>N)*C):A[a]=A[a+1]=A[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+F)<I?a:I)*k<<2,l+=v+=L.r=A[a],d+=_+=L.g=A[a+1],c+=y+=L.b=A[a+2],u+=w+=L.a=A[a+3],L=L.next,g+=b=z.r,p+=x=z.g,m+=S=z.b,f+=C=z.a,v-=b,_-=x,y-=S,w-=C,z=z.next,o+=k}}(t,e)},jr.Factory.addGetterSetter(Hr.Node,"blurRadius",0,(0,Kr.getNumberValidator)(),jr.Factory.afterSetFilter);var qr={};Object.defineProperty(qr,"__esModule",{value:!0}),qr.Brighten=void 0;const Zr=w,$r=y,Qr=b;qr.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},Zr.Factory.addGetterSetter($r.Node,"brightness",0,(0,Qr.getNumberValidator)(),Zr.Factory.afterSetFilter);var ts={};Object.defineProperty(ts,"__esModule",{value:!0}),ts.Contrast=void 0;const es=w,is=y,rs=b;ts.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},es.Factory.addGetterSetter(is.Node,"contrast",0,(0,rs.getNumberValidator)(),es.Factory.afterSetFilter);var ss={};Object.defineProperty(ss,"__esModule",{value:!0}),ss.Emboss=void 0;const as=w,ns=y,os=_,hs=b;ss.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:os.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,A=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]=A>255?255:A<0?0:A}else{var k=i-x;k<0?k=0:k>255&&(k=255),o[f]=o[f+1]=o[f+2]=k}}while(--m)}while(--c)},as.Factory.addGetterSetter(ns.Node,"embossStrength",.5,(0,hs.getNumberValidator)(),as.Factory.afterSetFilter),as.Factory.addGetterSetter(ns.Node,"embossWhiteLevel",.5,(0,hs.getNumberValidator)(),as.Factory.afterSetFilter),as.Factory.addGetterSetter(ns.Node,"embossDirection","top-left",null,as.Factory.afterSetFilter),as.Factory.addGetterSetter(ns.Node,"embossBlend",!1,null,as.Factory.afterSetFilter);var ls={};Object.defineProperty(ls,"__esModule",{value:!0}),ls.Enhance=void 0;const ds=w,cs=y,us=b;function gs(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}ls.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]=gs(a[s+0],o,h,f,m),a[s+1]=gs(a[s+1],l,d,y,_),a[s+2]=gs(a[s+2],c,u,x,b)}},ds.Factory.addGetterSetter(cs.Node,"enhance",0,(0,us.getNumberValidator)(),ds.Factory.afterSetFilter);var ps={};Object.defineProperty(ps,"__esModule",{value:!0}),ps.Grayscale=void 0;ps.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 ms={};Object.defineProperty(ms,"__esModule",{value:!0}),ms.HSL=void 0;const fs=w,vs=y,_s=b;fs.Factory.addGetterSetter(vs.Node,"hue",0,(0,_s.getNumberValidator)(),fs.Factory.afterSetFilter),fs.Factory.addGetterSetter(vs.Node,"saturation",0,(0,_s.getNumberValidator)(),fs.Factory.afterSetFilter),fs.Factory.addGetterSetter(vs.Node,"luminance",0,(0,_s.getNumberValidator)(),fs.Factory.afterSetFilter);ms.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 ys={};Object.defineProperty(ys,"__esModule",{value:!0}),ys.HSV=void 0;const ws=w,bs=y,xs=b;ys.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},ws.Factory.addGetterSetter(bs.Node,"hue",0,(0,xs.getNumberValidator)(),ws.Factory.afterSetFilter),ws.Factory.addGetterSetter(bs.Node,"saturation",0,(0,xs.getNumberValidator)(),ws.Factory.afterSetFilter),ws.Factory.addGetterSetter(bs.Node,"value",0,(0,xs.getNumberValidator)(),ws.Factory.afterSetFilter);var Ss={};Object.defineProperty(Ss,"__esModule",{value:!0}),Ss.Invert=void 0;Ss.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 Cs={};Object.defineProperty(Cs,"__esModule",{value:!0}),Cs.Kaleidoscope=void 0;const Ps=w,As=y,ks=_,Es=b;Cs.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=ks.Util.createCanvasElement();m.width=d,m.height=c;var f=m.getContext("2d").getImageData(0,0,d,c);ks.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})}},Ps.Factory.addGetterSetter(As.Node,"kaleidoscopePower",2,(0,Es.getNumberValidator)(),Ps.Factory.afterSetFilter),Ps.Factory.addGetterSetter(As.Node,"kaleidoscopeAngle",0,(0,Es.getNumberValidator)(),Ps.Factory.afterSetFilter);var Ts={};Object.defineProperty(Ts,"__esModule",{value:!0}),Ts.Mask=void 0;const Ms=w,Is=y,Fs=b;function Os(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 Ds(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))}Ts.Mask=function(t){var e=function(t,e){var i=Os(t,0,0),r=Os(t,t.width-1,0),s=Os(t,0,t.height-1),a=Os(t,t.width-1,t.height-1),n=e||10;if(Ds(i,r)<n&&Ds(r,a)<n&&Ds(a,s)<n&&Ds(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=Ds(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},Ms.Factory.addGetterSetter(Is.Node,"threshold",0,(0,Fs.getNumberValidator)(),Ms.Factory.afterSetFilter);var Rs={};Object.defineProperty(Rs,"__esModule",{value:!0}),Rs.Noise=void 0;const Vs=w,Ls=y,zs=b;Rs.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()},Vs.Factory.addGetterSetter(Ls.Node,"noise",.2,(0,zs.getNumberValidator)(),Vs.Factory.afterSetFilter);var Gs={};Object.defineProperty(Gs,"__esModule",{value:!0}),Gs.Pixelate=void 0;const Ns=w,Ws=_,Us=y,Bs=b;Gs.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)Ws.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)}},Ns.Factory.addGetterSetter(Us.Node,"pixelSize",8,(0,Bs.getNumberValidator)(),Ns.Factory.afterSetFilter);var js={};Object.defineProperty(js,"__esModule",{value:!0}),js.Posterize=void 0;const Hs=w,Ks=y,Ys=b;js.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},Hs.Factory.addGetterSetter(Ks.Node,"levels",.5,(0,Ys.getNumberValidator)(),Hs.Factory.afterSetFilter);var Xs={};Object.defineProperty(Xs,"__esModule",{value:!0}),Xs.RGB=void 0;const Js=w,qs=y,Zs=b;Xs.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]},Js.Factory.addGetterSetter(qs.Node,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),Js.Factory.addGetterSetter(qs.Node,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),Js.Factory.addGetterSetter(qs.Node,"blue",0,Zs.RGBComponent,Js.Factory.afterSetFilter);var $s={};Object.defineProperty($s,"__esModule",{value:!0}),$s.RGBA=void 0;const Qs=w,ta=y,ea=b;$s.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},Qs.Factory.addGetterSetter(ta.Node,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),Qs.Factory.addGetterSetter(ta.Node,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),Qs.Factory.addGetterSetter(ta.Node,"blue",0,ea.RGBComponent,Qs.Factory.afterSetFilter),Qs.Factory.addGetterSetter(ta.Node,"alpha",1,(function(t){return this._filterUpToDate=!1,t>1?1:t<0?0:t}));var ia={};Object.defineProperty(ia,"__esModule",{value:!0}),ia.Sepia=void 0;ia.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 ra={};Object.defineProperty(ra,"__esModule",{value:!0}),ra.Solarize=void 0;ra.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 sa={};Object.defineProperty(sa,"__esModule",{value:!0}),sa.Threshold=void 0;const aa=w,na=y,oa=b;sa.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},aa.Factory.addGetterSetter(na.Node,"threshold",.5,(0,oa.getNumberValidator)(),aa.Factory.afterSetFilter),Object.defineProperty(m,"__esModule",{value:!0}),m.Konva=void 0;const ha=f,la=Jt,da=ie,ca=Ce,ua=Me,ga=Ve,pa=Be,ma=re,fa=ce,va=ri,_a=di,ya=fi,wa=Si,ba=Mi,xa=Vi,Sa=rr,Ca=mr,Pa=Vr,Aa=Br,ka=qr,Ea=ts,Ta=ss,Ma=ls,Ia=ps,Fa=ms,Oa=ys,Da=Ss,Ra=Cs,Va=Ts,La=Rs,za=Gs,Ga=js,Na=Xs,Wa=$s,Ua=ia,Ba=ra,ja=sa;m.Konva=ha.Konva.Util._assign(ha.Konva,{Arc:la.Arc,Arrow:da.Arrow,Circle:ca.Circle,Ellipse:ua.Ellipse,Image:ga.Image,Label:pa.Label,Tag:pa.Tag,Line:ma.Line,Path:fa.Path,Rect:va.Rect,RegularPolygon:_a.RegularPolygon,Ring:ya.Ring,Sprite:wa.Sprite,Star:ba.Star,Text:xa.Text,TextPath:Sa.TextPath,Transformer:Ca.Transformer,Wedge:Pa.Wedge,Filters:{Blur:Aa.Blur,Brighten:ka.Brighten,Contrast:Ea.Contrast,Emboss:Ta.Emboss,Enhance:Ma.Enhance,Grayscale:Ia.Grayscale,HSL:Fa.HSL,HSV:Oa.HSV,Invert:Da.Invert,Kaleidoscope:Ra.Kaleidoscope,Mask:Va.Mask,Noise:La.Noise,Pixelate:za.Pixelate,Posterize:Ga.Posterize,RGB:Na.RGB,RGBA:Wa.RGBA,Sepia:Ua.Sepia,Solarize:Ba.Solarize,Threshold:ja.Threshold}});var Ha=p.exports;Object.defineProperty(Ha,"__esModule",{value:!0});const Ka=m;p.exports=Ka.Konva;var Ya=g(p.exports);class Xa{constructor(t,e,i){this.setColor(t,e,i)}asHex(){return"#"+this.HEX}asRGB(){return{r:this.R,g:this.G,b:this.B}}setColor(t,e,i){this.R=t,this.G=e,this.B=i,this.HEX=this.rgbToHex(t,e,i)}rgbToHex(t,e,i){const r=t=>{const e=t.toString(16);return"0"===e?"00":e};return r(t)+r(e)+r(i)}}class Ja{screenToWorld(t){return{x:t.x,y:t.y,z:0}}worldToScreen(t){return{x:t.x,y:t.y}}getScale(){return{x:1,y:1,z:1}}}const qa=new Map([["solid",[]],["dot",[30,30,.001,30]],["dash",[30,30]]]);class Za{constructor(t,e=null){var i,r;if(e)return void(this._ref=e);t||(t={}),t.points||(t.points=[{x:50,y:50},{x:100,y:100}]);const s=[];t.points.forEach((t=>s.push(t.x,t.y))),this._ref=new Ya.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:qa.get(t.type)||[]}),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation)})),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 qa.get("dot"):t="dot";break;case qa.get("dash"):t="dash";break;default:t="solid"}return t}setLineType(t){const e=qa.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 $a{constructor(t,e=null){var i,r,s;this.TEXT_FONT_FAMILY="Calibri",e?this._ref=e:(t||(t={}),t.position||(t.position={x:100,y:100}),t.text||(t.text="default"),this._ref=new Ya.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.width(this._ref.getTextWidth()),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,r=Math.abs(e.scaleY-1)>1e-5;let s=this._ref.width();i&&(s*=e.scaleX);let a=this._ref.height();r&&(a*=e.scaleY);s<50&&(s=50),a<Math.round(this.getFontSize())&&(a=Math.round(this.getFontSize())),i&&this._ref.width(s),r&&this._ref.height(a),this._ref.scale({x:1,y: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"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 Qa{constructor(t,e=null){var i,r,s,a;e?this._ref=e:(t||(t={}),t.position||(t.position={x:100,y:100}),this._ref=new Ya.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.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,r=Math.abs(e.scaleY-1)>1e-5;let s=this._ref.width();i&&(s*=e.scaleX);let a=this._ref.height();r&&(a*=e.scaleY);s<50&&(s=50),a<50&&(a=50),i&&this._ref.width(s),r&&this._ref.height(a),this._ref.scale({x:1,y: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 tn{constructor(t,e=null){var i,r;e?this._ref=e:(t||(t={}),t.position||(t.position={x:100,y:100}),t.radius||(t.radius={x:25,y:25}),this._ref=new Ya.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.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,r=Math.abs(e.scaleY-1)>1e-5;let s=this._ref.radiusX();i&&(s*=e.scaleX);let a=this._ref.radiusY();r&&(a*=e.scaleY);s<25&&(s=25),a<25&&(a=25),t.evt.ctrlKey||t.evt.shiftKey?i?this._ref.radius({x:s,y:s}):this._ref.radius({x:a,y:a}):this._ref.radius({x:s,y:a}),this._ref.scale({x:1,y: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.radiusX(t)}getRadiusY(){return this._ref.radiusY()}setRadiusY(t){this._ref.radiusY(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 en{constructor(t,e=null){var i,r;e?this._ref=e:(t||(t={}),t.start||(t.start={x:50,y:50}),t.end||(t.end={x:100,y:100}),this._ref=new Ya.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.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation)})),this._ref.id(this._ref._id.toString()))}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Arrow"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t),this._ref.fill(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){const t=this._ref.points();return[{x:t[0],y:t[1]},{x:t[2],y:t[3]}]}setPoints(t){2===t.length&&this._ref.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 rn{constructor(t,e=null){var i,r;if(this._ratio=1,this.EPSILON=1e-5,this.BASE64_NOT_FOUND="data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAADsAAAA7AF5KHG9AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAmhJREFUWIXtlr9rVEEQxz+H8RQUJIdeIopYm0vkCg0GBBtbG1NF7Kxt7dR/IGIw/uhTaBNLERURg2kCEUyCYCPi70b0InjGS57FzOZN3r19d+9HJIVfWO52dma/s7Mz8xa2KAaBCWAR+AkECWOmSOIdwC1gtQOpHc+NfQ8wClQ8+1d0vcdH/lQ3bSIRGAZ2pTjAqNovANXIWlXlAXA2zvi2Ln4AjqYgtagYEutENSLvjRoOImFv5iB32Ae8UrLXwFBk3h9ndF0VJnKSO9gTu3yKu5Z1LKnS8YIcABgw5Ks692JZFXcXRJ46Aq6kikCnHNi/mQ50WwVtfaIoBzL3gRk2drSscJ2wrc4VvUoe2wn/41/iBfoVLRnBGnDSY3AAKacy8AmYR+o7K1zCl6wgrgpOAc/MuhvfgMuk+1JGHQgSBcAloKXy78AjYBppJk5/noTulseBMZ23iD/piHFkEdgTQzKk+5wHjmHC3cmBg0BD5xcSTrFXyQPgIWFtDwMvab+2N8DpbhyY1v/3E8gdDgNfVX9SCVZ0/gW4B0wB71S2BpxLcuCM/jaQSHSDEeAX4VMuAG4gTzyHbcAVXXO6GxxwIX+vvxe7JHcYQ07nHqklj96UIW/YhSWzMKcep8VVtf8B1Dw6h4DfhB+sdbgn2R+gnoEc5NR3dZ+3QJ9H74HqXLPCGlJyTfI9y3YCs0owq3OLOpKkLeBI1HhSDT/mdKIPiUCARMTlQx34TMLjtww8IczmO8AJ/N/2JNSQXAiQ671JePePge0+wzJSQq4FFzlaenIvucUAkiQLhC/mLGNZ9xgn5s63BP4CCk0QDtm4BhoAAAAASUVORK5CYII=",this.BASE64_HEADER_START="data:image/",e)return e.src&&e.src.startsWith(this.BASE64_HEADER_START)||(e.src=this.BASE64_NOT_FOUND),e.height()<=this.EPSILON&&e.height(32),e.width()<=this.EPSILON&&e.width(32),this._ref=e,this._canvasImage=e.image(),void(this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width());t||(t={}),t.position||(t.position={x:50,y:50}),t.src&&t.src.startsWith(this.BASE64_HEADER_START)||(t.src=this.BASE64_NOT_FOUND),this._canvasImage=new Image,this._canvasImage.onload=()=>{if(this._ref.image(this._canvasImage),this._ref.height()<=this.EPSILON&&this._ref.height(this._canvasImage.height),this._ref.width()<=this.EPSILON&&this._ref.width(this._canvasImage.width),this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width(),(t.width<=this.EPSILON||t.height<=this.EPSILON)&&(t.maxWidth>=this.EPSILON||t.maxWidth>=this.EPSILON)){const e=t.maxHeight-this._canvasImage.height,i=t.maxWidth-this._canvasImage.width;(e<=this.EPSILON||i<=this.EPSILON)&&(i<=this.EPSILON&&i<e/this._ratio?(this._ref.height(t.maxWidth*this._ratio),this._ref.width(t.maxWidth)):(this._ref.width(t.maxHeight/this._ratio),this._ref.height(t.maxHeight)))}},this._canvasImage.onerror=()=>{this._canvasImage.onerror=function(){},this._canvasImage.src=this.BASE64_NOT_FOUND},this._canvasImage.src=t.src,this._ref=new Ya.Image({x:t.position.x,y:t.position.y,image:this._canvasImage,width:null!==(i=t.width)&&void 0!==i?i:0,height:null!==(r=t.height)&&void 0!==r?r:0,draggable:!0}),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,r=Math.abs(e.scaleY-1)>1e-5;let s=this._ref.width();i&&(s*=e.scaleX);let a=this._ref.height();r&&(a*=e.scaleY),t.evt.ctrlKey||t.evt.shiftKey?i?(this._ref.width(s),this._ref.height(s*this._ratio)):(this._ref.width(a/this._ratio),this._ref.height(a)):(i&&this._ref.width(s),r&&this._ref.height(a)),this._ref.scale({x:1,y:1})})),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 sn{constructor(t,e=null){var i,r,s,a;if(e)return void(this._ref=e);t||(t={}),t.position||(t.position={x:100,y:100});const n=16;this._ref=new Ya.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:4,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;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,r=Math.abs(e.scaleY-1)>1e-5;let s=this._ref.width();i&&(s*=e.scaleX);let a=this._ref.height();r&&(a*=e.scaleY);s<100&&(s=100),a<100&&(a=100),i&&this._ref.width(s),r&&this._ref.height(a),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 an={SelectMarkup:{name:"SelectMarkup",initializer:null},Line:{name:"Line",initializer:(t,e=null)=>new Za(e,t)},Text:{name:"Text",initializer:(t,e=null)=>new $a(e,t)},Rectangle:{name:"Rect",initializer:(t,e=null)=>new Qa(e,t)},Ellipse:{name:"Ellipse",initializer:(t,e=null)=>new tn(e,t)},Arrow:{name:"Arrow",initializer:(t,e=null)=>new en(e,t)},Image:{name:"Image",initializer:(t,e=null)=>new rn(e,t)},Cloud:{name:"Cloud",initializer:(t,e=null)=>new sn(e,t)}};class nn{constructor(){this._containerEvents=[],this._markupIsActive=!1,this._markupColor=new Xa(255,0,0),this.lineWidth=4,this.lineType="solid",this.fontSize=34,this.changeActiveDragger=t=>{const e=t.data;this._markupContainer.className=this._container.className.split(" ").filter((t=>!t.startsWith("oda-cursor-"))).filter((t=>t)).concat(`oda-cursor-${e.toLowerCase()}`).join(" "),this.removeTextInput(),this.removeImageInput(),this.enableEditMode(e)},this.resizeContainer=t=>{const{width:e,height:i}=t[0].contentRect;e&&i&&this._konvaStage&&(this._konvaStage.width(e),this._konvaStage.height(i))},this.pan=t=>{const e=t.dX/window.devicePixelRatio,i=t.dY/window.devicePixelRatio;this.getObjects().forEach((t=>t.ref().move({x:e,y:i})))},this.redirectToViewer=t=>{this._viewer&&this._viewer.emit(t)}}initialize(t,e,i,r){if(!Ya)throw new Error('Markup error: Konva is not initialized. Forgot to add <script src="https://unpkg.com/konva@9/konva.min.js"><\/script> to your page?');this._viewer=i,this._worldTransformer=null!=r?r:new Ja,this._container=t,this._containerEvents=null!=e?e:[],this._markupContainer=document.createElement("div"),this._markupContainer.id="markup-container",this._markupContainer.style.position="absolute",this._markupContainer.style.top="0px",this._markupContainer.style.left="0px",this._markupContainer.style.outline="0px";const s=this._container.parentElement;s.appendChild(this._markupContainer),this._resizeObserver=new ResizeObserver(this.resizeContainer),this._resizeObserver.observe(s),this._markupColor.setColor(255,0,0),this.initializeKonva(),this._viewer&&(this._containerEvents.forEach((t=>this._markupContainer.addEventListener(t,this.redirectToViewer))),this._viewer.addEventListener("changeactivedragger",this.changeActiveDragger),this._viewer.addEventListener("pan",this.pan))}dispose(){var t,e;this._viewer&&(this._viewer.removeEventListener("pan",this.pan),this._viewer.removeEventListener("changeactivedragger",this.changeActiveDragger),this._containerEvents.forEach((t=>this._markupContainer.removeEventListener(t,this.redirectToViewer)))),this.destroyKonva(),null===(t=this._resizeObserver)||void 0===t||t.disconnect(),this._resizeObserver=void 0,null===(e=this._markupContainer)||void 0===e||e.remove(),this._markupContainer=void 0,this._container=void 0,this._viewer=void 0,this._worldTransformer=void 0,this._markupIsActive=!1}syncOverlay(){}clearOverlay(){this.removeTextInput(),this.removeImageInput(),this.clearSelected(),this.getObjects().forEach((t=>t.delete()))}getMarkupColor(){return this._markupColor.asRGB()}setMarkupColor(t,e,i){this._markupColor.setColor(t,e,i)}colorizeAllMarkup(t,e,i){const r=new Xa(t,e,i).asHex();this.getObjects().filter((t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,r)}))}colorizeSelectedMarkups(t,e,i){const r=new Xa(t,e,i).asHex();this.getSelectedObjects().filter((t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,r)}))}setViewpoint(t){var e,i,r,s,a,n,o,h;this.clearSelected(),this.removeTextInput(),this.removeImageInput();const l=(null===(e=t.custom_fields)||void 0===e?void 0:e.markup_color)||{r:255,g:0,b:0};this.setMarkupColor(l.r,l.g,l.b),null===(i=t.lines)||void 0===i||i.forEach((t=>{const e=[];t.points.forEach((t=>{const i=this._worldTransformer.worldToScreen(t);e.push(i.x),e.push(i.y)})),this.addLine(e,t.color,t.type,t.width,t.id)})),null===(r=t.texts)||void 0===r||r.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addText(t.text,e,t.angle,t.color,t.text_size,t.font_size,t.id)})),null===(s=t.rectangles)||void 0===s||s.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addRectangle(e,t.width,t.height,t.line_width,t.color,t.id)})),null===(a=t.ellipses)||void 0===a||a.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addEllipse(e,t.radius,t.line_width,t.color,t.id)})),null===(n=t.arrows)||void 0===n||n.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.start),i=this._worldTransformer.worldToScreen(t.end);this.addArrow(e,i,t.color,t.id)})),null===(o=t.clouds)||void 0===o||o.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addCloud(e,t.width,t.height,t.line_width,t.color,t.id)})),null===(h=t.images)||void 0===h||h.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addImage(e,t.src,t.width,t.height,t.id)}))}getViewpoint(){const t={};return t.lines=this.getMarkupLines(),t.texts=this.getMarkupTexts(),t.arrows=this.getMarkupArrows(),t.clouds=this.getMarkupClouds(),t.ellipses=this.getMarkupEllipses(),t.images=this.getMarkupImages(),t.rectangles=this.getMarkupRectangles(),t.custom_fields={markup_color:this.getMarkupColor()},t.snapshot={data:this.combineMarkupWithDrawing()},t.description=(new Date).toDateString(),t}enableEditMode(t){return t&&an[t]?(this._markupMode=t,this._markupIsActive=!0):(this.clearSelected(),this.removeTextInput(),this.removeImageInput(),this._markupIsActive=!1),this}createObject(t,e){const i=an[t];if(!i||!i.initializer)throw new Error(`Markup CreateObject - unsupported markup type ${t}`);const r=i.initializer(null,e);return this.addObject(r),r}getObjects(){const t=[];return Object.keys(an).forEach((e=>{const i=an[e];this.konvaLayerFind(e).forEach((e=>t.push(i.initializer(e))))})),t}getSelectedObjects(){return this._konvaTransformer?this._konvaTransformer.nodes().map((t=>{const e=t.className,i=Object.values(an).find((t=>t.name===e));return i?i.initializer(t):null})).filter((t=>t)):[]}selectObjects(t){if(!this._konvaTransformer)return;const e=this._konvaTransformer.nodes().concat(t.map((t=>t.ref())));this._konvaTransformer.nodes(e)}clearSelected(){this._konvaTransformer&&this._konvaTransformer.nodes([])}addObject(t){"Image"===t.type()?this._groupImages.add(t.ref()):"Text"===t.type()?this._groupTexts.add(t.ref()):this._groupGeometry.add(t.ref())}konvaLayerFind(t){if(!this._konvaLayer)return[];const e=an[t];return e&&e.initializer?this._konvaLayer.find(e.name).filter((t=>t.parent===this._konvaLayer||t.parent===this._groupImages||t.parent===this._groupGeometry||t.parent===this._groupTexts)):[]}initializeKonva(){const t=new Ya.Stage({container:this._markupContainer,width:this._container.clientWidth,height:this._container.clientHeight});this._konvaStage=t;const e=new Ya.Layer({pixelRation:window.devicePixelRatio});t.add(e),this._groupImages=new Ya.Group,e.add(this._groupImages),this._groupGeometry=new Ya.Group,e.add(this._groupGeometry),this._groupTexts=new Ya.Group,e.add(this._groupTexts),this._konvaLayer=e;const i=new Ya.Transformer({shouldOverdrawWholeArea:!1,keepRatio:!1,flipEnabled:!1});e.add(i),this._konvaTransformer=i;let r,s,a,n=!1;t.on("mousedown touchstart",(e=>{if(!this._markupIsActive||e.target!==t||"Text"===this._markupMode||"Image"===this._markupMode)return;if(e.target===t&&i.nodes().length>0)return void i.nodes([]);const a=t.getPointerPosition();s=a,n=["Arrow","Cloud","Ellipse","Line","Rectangle"].some((t=>t===this._markupMode)),"Line"===this._markupMode&&(r=this.addLine([a.x,a.y,a.x,a.y]))})),t.on("mouseup touchend",(e=>{if(this._markupIsActive){if(n){const e=t.getPointerPosition(),i=s&&e.x===s.x&&e.y===s.y,r=i?s.x:Math.min(s.x,e.x),a=i?s.y:Math.min(s.y,e.y),n=i?200:Math.abs(s.x-e.x),o=i?200:Math.abs(s.y-e.y);i&&("Rectangle"===this._markupMode?this.addRectangle({x:r,y:a},n,o):"Ellipse"===this._markupMode?this.addEllipse({x:r,y:a},{x:n/2,y:o/2}):"Arrow"===this._markupMode?this.addArrow({x:s.x,y:s.y},{x:i?s.x+200:e.x,y:i?a:e.y}):"Cloud"===this._markupMode&&this.addCloud({x:r,y:a},Math.max(100,n),Math.max(100,o)))}a=void 0,n=!1}})),t.on("mousemove touchmove",(e=>{if(!this._markupIsActive)return;if(!n)return;const i=t.getPointerPosition(),o=s&&i.x===s.x&&i.y===s.y,h=o?s.x:Math.min(s.x,i.x),l=o?s.y:Math.min(s.y,i.y),d=o?200:Math.abs(s.x-i.x),c=o?200:Math.abs(s.y-i.y);"Line"===this._markupMode?r.addPoints([{x:i.x,y:i.y}]):"Arrow"===this._markupMode?a?a.setEndPoint(i.x,i.y):a=this.addArrow({x:s.x,y:s.y},{x:i.x,y:i.y}):"Rectangle"===this._markupMode?a?(a.setPosition(h,l),a.setWidth(d),a.setHeight(c)):a=this.addRectangle({x:h,y:l},d,c):"Ellipse"===this._markupMode?a?(a.setPosition(h,l),a.setRadiusX(d),a.setRadiusY(c)):a=this.addEllipse({x:h,y:l},{x:d,y:c}):"Cloud"===this._markupMode&&(a?(a.setPosition(h,l),a.setWidth(Math.max(100,d)),a.setHeight(Math.max(100,c))):a=this.addCloud({x:h,y:l},d,c))})),t.on("click tap",(e=>{if(!this._markupIsActive)return;if(e.target===t){if("Text"===this._markupMode){if(this._textInputRef&&this._textInputRef.value)this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle);else if(0===i.nodes().length){const i=t.getPointerPosition();this.createTextInput(i,e.evt.pageX,e.evt.pageY,0,null)}}else if("Image"===this._markupMode)if(this._imageInputRef&&this._imageInputRef.value)this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},this._imageInputRef.value,0,0,this._imageInputRef.value);else if(0===i.nodes().length){const e=t.getPointerPosition();this.createImageInput(e)}return void i.nodes([])}if("Text"===this._markupMode||"SelectMarkup"===this._markupMode){if("Text"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._textInputRef&&this._textInputRef.value?this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle):this.createTextInput({x:e.target.attrs.x,y:e.target.attrs.y},e.evt.pageX,e.evt.pageY,e.target.attrs.rotation,e.target.attrs.text));this.removeTextInput()}if("Image"===this._markupMode||"SelectMarkup"===this._markupMode){if("Image"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._imageInputRef&&this._imageInputRef.value?this.addImage(this._imageInputPos,this._imageInputRef.value,0,0):this.createImageInput({x:e.target.attrs.x,y:e.target.attrs.y}));this.removeImageInput()}i.nodes().filter((t=>"Cloud"===t.className||"Image"===t.className)).length>0||"Cloud"===e.target.className||"Image"===e.target.className?i.rotateEnabled(!1):i.rotateEnabled(!0);const r=e.evt.shiftKey||e.evt.ctrlKey||e.evt.metaKey,s=i.nodes().indexOf(e.target)>=0;if(r||s){if(r&&s){const t=i.nodes().slice();t.splice(t.indexOf(e.target),1),i.nodes(t)}else if(r&&!s){const t=i.nodes().concat([e.target]);i.nodes(t)}}else i.nodes([e.target])}));const o=t.container();o.tabIndex=1,o.focus(),o.addEventListener("keydown",(t=>{if(this._markupIsActive)return"Delete"===t.code?(this.getSelectedObjects().forEach((t=>t.delete())),void this.clearSelected()):void t.preventDefault()}))}destroyKonva(){var t;this.removeTextInput(),this.removeImageInput(),this.clearOverlay(),null===(t=this._konvaStage)||void 0===t||t.destroy(),this._groupImages=void 0,this._groupGeometry=void 0,this._groupTexts=void 0,this._konvaLayer=void 0,this._konvaTransformer=void 0,this._konvaStage=void 0}getMarkupLines(){const t=[];return this.konvaLayerFind("Line").forEach((e=>{const i=e.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._worldTransformer.screenToWorld(e);r.push(a)}const a=new Za(null,e),n={id:a.id(),points:r,color:a.getColor()||"#ff0000",type:a.getLineType()||this.lineType,width:a.getLineWidth()||this.lineWidth};t.push(n)})),t}getMarkupTexts(){const t=[];return this.konvaLayerFind("Text").forEach((e=>{const i=this._worldTransformer.getScale(),r={x:e.x(),y:e.y()},s=this._worldTransformer.screenToWorld(r),a=new $a(null,e),n={id:a.id(),position:s,text:a.getText(),text_size:.02*i.y,angle:a.getRotation(),color:a.getColor(),font_size:a.getFontSize()};t.push(n)})),t}getMarkupRectangles(){const t=[];return this.konvaLayerFind("Rectangle").forEach((e=>{const i=e.position(),r=this._worldTransformer.screenToWorld(i),s=new Qa(null,e),a={id:s.id(),position:r,width:s.getWidth(),height:s.getHeigth(),line_width:s.getLineWidth(),color:s.getColor()};t.push(a)})),t}getMarkupEllipses(){const t=[];return this.konvaLayerFind("Ellipse").forEach((e=>{const i=e.position(),r=this._worldTransformer.screenToWorld(i),s=new tn(null,e),a={id:s.id(),position:r,radius:{x:e.getRadiusX(),y:e.getRadiusY()},line_width:s.getLineWidth(),color:s.getColor()};t.push(a)})),t}getMarkupArrows(){const t=[];return this.konvaLayerFind("Arrow").forEach((e=>{const i=e.getAbsoluteTransform(),r=i.point({x:e.points()[0],y:e.points()[1]}),s=this._worldTransformer.screenToWorld(r),a=i.point({x:e.points()[2],y:e.points()[3]}),n=this._worldTransformer.screenToWorld(a),o=new en(null,e),h={id:o.id(),start:s,end:n,color:o.getColor()};t.push(h)})),t}getMarkupImages(){const t=[];return this.konvaLayerFind("Image").forEach((e=>{const i=e.position(),r=this._worldTransformer.screenToWorld(i),s=new rn(null,e),a={id:s.id(),position:r,src:s.getSrc(),width:s.getWidth(),height:s.getHeight()};t.push(a)})),t}getMarkupClouds(){const t=[];return this.konvaLayerFind("Cloud").forEach((e=>{const i=e.position(),r=this._worldTransformer.screenToWorld(i),s=new sn(null,e),a={id:s.id(),position:r,width:s.getWidth(),height:s.getHeigth(),line_width:s.getLineWidth(),color:s.getColor()};t.push(a)})),t}combineMarkupWithDrawing(){this.clearSelected();const t=document.createElement("canvas");if(this._konvaStage){t.width=this._konvaStage.width(),t.height=this._konvaStage.height();const e=t.getContext("2d");this._container instanceof HTMLCanvasElement&&e.drawImage(this._container,0,0),e.drawImage(this._konvaStage.toCanvas({pixelRatio:window.devicePixelRatio}),0,0)}return t.toDataURL("image/jpeg",.25)}addLine(t,e,i,r,s){if(!t||0===t.length)return;const a=[];for(let e=0;e<t.length;e+=2)a.push({x:t[e],y:t[e+1]});const n=new Za({points:a,type:i||this.lineType,width:r||this.lineWidth,color:e||this._markupColor.asHex(),id:s});return this.addObject(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.style.fontSize=`${this.fontSize}px`,this._textInputRef.style.color=`${this._markupColor.asHex()}`,this._textInputRef.style.fontFamily="Calibri",this._textInputRef.onkeydown=t=>{"Enter"!==t.key||t.shiftKey||(t.preventDefault(),this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle)),"Escape"===t.key&&(t.preventDefault(),this.removeTextInput())},s&&(this._textInputRef.value=s),document.body.appendChild(this._textInputRef),setTimeout((()=>{this._textInputRef.focus()}),50))}removeTextInput(){var t;null===(t=this._textInputRef)||void 0===t||t.remove(),this._textInputRef=null,this._textInputPos=null,this._textInputAngle=0}createImageInput(t){if(this._imageInputRef)this.removeImageInput();else{const e=t=>new Promise(((e,i)=>{const r=new FileReader;r.readAsDataURL(t),r.onload=()=>{e(r.result)},r.onerror=t=>{i(t)}}));this._imageInputPos=t,this._imageInputRef=document.createElement("input"),this._imageInputRef.style.display="none",this._imageInputRef.type="file",this._imageInputRef.accept="image/png, image/jpeg",this._imageInputRef.onchange=async t=>{const i=t.target.files[0],r=await e(i);this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},r.toString(),0,0)},this._imageInputRef.oncancel=t=>{this.removeImageInput()},document.body.appendChild(this._imageInputRef),setTimeout((()=>{this._imageInputRef.click()}),50)}}removeImageInput(){var t;null===(t=this._imageInputRef)||void 0===t||t.remove(),this._imageInputRef=null,this._imageInputPos=null}addText(t,e,i,r,s,a,n){var o;if(!t)return;null===(o=this.getSelectedObjects().at(0))||void 0===o||o.delete(),this.clearSelected(),this.removeTextInput();const h=1e-6;if(s&&s>h&&(!a||a<h)){const t=.02;a=s/(this._worldTransformer.getScale().y/t)/34}const l=new $a({position:{x:e.x,y:e.y},text:t,rotation:i,fontSize:a||this.fontSize,color:r||this._markupColor.asHex(),id:n});return this.addObject(l),l}addRectangle(t,e,i,r,s,a){if(!t)return;const n=new Qa({position:t,width:e,height:i,lineWidth:r||this.lineWidth,color:s||this._markupColor.asHex(),id:a});return this.addObject(n),n}addEllipse(t,e,i,r,s){if(!t)return;const a=new tn({position:t,radius:e,lineWidth:i,color:r||this._markupColor.asHex(),id:s});return this.addObject(a),a}addArrow(t,e,i,r){if(!t||!e)return;const s=new en({start:t,end:e,color:i||this._markupColor.asHex(),id:r});return this.addObject(s),s}addCloud(t,e,i,r,s,a){if(!t||!e||!i)return;const n=new sn({position:t,width:e,height:i,color:s||this._markupColor.asHex(),lineWidth:r||this.lineWidth,id:a});return this.addObject(n),n}addImage(t,e,i,r,s){var a;if(!t||!e)return;null===(a=this.getSelectedObjects().at(0))||void 0===a||a.delete(),this.clearSelected(),this.removeImageInput();const n=new rn({position:t,src:e,width:i,height:r,maxWidth:this._konvaStage.width()-t.x,maxHeight:this._konvaStage.height()-t.y,id:s});return this.addObject(n),n}}class on{constructor(){this._listeners={}}addEventListener(t,e){return void 0===this._listeners[t]&&(this._listeners[t]=[]),this._listeners[t].push(e),this}removeEventListener(t,e){if(void 0===this._listeners[t])return this;const i=this._listeners[t].filter((t=>t!==e));return 0!==i.length?this._listeners[t]=i:delete this._listeners[t],this}removeAllListeners(t){return t?delete this._listeners[t]:this._listeners={},this}emitEvent(t){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 hn{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 ln extends hn{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=o}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||ln.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(ln.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||ln.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){ln._isGestureActive!==t&&(ln._isGestureActive=t,ln._isGestureActive&&(ln.needSkipPointerUp=!0))}static get isGestureActive(){return ln._isGestureActive}static get needSkipPointerUp(){return!!ln._needSkipPointerUp&&(ln.needSkipPointerUp=!1,!0)}static set needSkipPointerUp(t){ln._needSkipPointerUp=t}}function dn(t,e,i){return t||((t=document.createElement("div")).setAttribute("data-testid",i),e.appendChild(t)),t}function cn(t,e){return t&&e.removeChild(t),null}function un(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 gn(t){return t<0?Math.ceil(t):Math.floor(t)}ln._isGestureActive=!1,ln._needSkipPointerUp=!1;const pn=(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:gn(t.x+l*s),y:gn(t.y+l*a)}};function mn(t,e,i,r,s){const a=pn(t,e,i,r);a&&s.push(a)}function fn(t,e,i){return t.x<=e&&t.x>=0&&t.y<=i&&t.y>=0}function vn(t,e){t&&(t.onclick=e?()=>e():()=>{})}function _n(t,e){t.style.pointerEvents=e?"auto":"none"}class yn{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=dn(this.htmlElemStartPoint,t,"ruler-start"),this.htmlElemEndPoint=dn(this.htmlElemEndPoint,t,"ruler-end"),this.htmlElemLine=dn(this.htmlElemLine,t,"ruler-line"),this.htmlElemTitle=dn(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=dn(this.htmlElemStartPoint,this.targetElement,"ruler-start");const i=un(this.startPoint,this.moduleInstance,this.viewer);fn(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=dn(this.htmlElemEndPoint,this.targetElement,"ruler-end");const i=un(this.endPoint,this.moduleInstance,this.viewer);fn(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=un(this.startPoint,this.moduleInstance,this.viewer),i=un(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=[];mn(t,e,s,a,h),mn(t,e,s,n,h),mn(t,e,n,o,h),mn(t,e,o,a,h);let l=null,d=null;0===h.length?(l=t,d=e):1===h.length?fn(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(fn(r,e.width,e.height)&&fn(s,e.width,e.height)){this.htmlElemLine=dn(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=dn(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=cn(this.htmlElemStartPoint,this.targetElement),this.htmlElemEndPoint=cn(this.htmlElemEndPoint,this.targetElement),this.htmlElemLine=cn(this.htmlElemLine,this.targetElement),this.htmlElemTitle=cn(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){vn(this.htmlElemStartPoint,t?t.onStartPoint:null),vn(this.htmlElemEndPoint,t?t.onEndPoint:null),vn(this.htmlElemTitle,t?t.onTitle:null)}setSelectability(t){_n(this.htmlElemStartPoint,t),_n(this.htmlElemEndPoint,t),_n(this.htmlElemLine,t),_n(this.htmlElemTitle,t)}}class wn extends ln{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}start(t,e){this.createNewMeasureIfNeed();const i=this.getViewer().getSnapPoint(t,e,this.gripingRadius);i&&(this.firstPoint=i,this.previewMeasureLine.setStartPoint(this.firstPoint))}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 yn(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 bn extends ln{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 xn extends ln{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 Sn extends xn{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 Cn extends xn{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 Pn extends xn{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 An{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 kn extends ln{constructor(t){super(t),this.autoSelect=!0,this.press=!1,this._orbitAction=new An(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 En{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 Tn extends ln{constructor(t){super(t),this.autoSelect=!0,this.press=!1,this._panAction=new En(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 Mn{constructor(t,e){this._m_module=t,this._subject=e}action(t,e,i){var r;this._m_module.getViewer().zoomAt(i,t,e),this._subject.deviceAutoRegeneration(),null===(r=this._subject.activeDragger())||void 0===r||r.updatePreview(),this._subject.emitEvent({type:"zoomat",data:i})}}class In extends ln{constructor(t){super(t),this.autoSelect=!0,this.press=!1,this._zoomAction=new Mn(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&&Math.abs(r)<=1e-5){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 Fn extends ln{constructor(t){super(t),this.canvasEvents=["wheel"],this._zoomAction=new Mn(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 On{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 Dn extends ln{constructor(t){super(t),this.autoSelect=!0,this.press=!1,this.needInputText=!1,this.m_frame=new On,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 Rn extends ln{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 Vn;!function(t){t[t.None=0]="None",t[t.Orbit=1]="Orbit",t[t.Pan=2]="Pan",t[t.Zoom=3]="Zoom"}(Vn||(Vn={}));class Ln extends ln{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=Vn.None,this._maxInitialDistanceDifference=30*window.devicePixelRatio,this._isSingleTouchEnabled=!1,this._orbitAction=new An(this.m_module,this.subject,this.beginInteractivity,this.endInteractivity),this._panAction=new En(this.m_module,this.subject,this.beginInteractivity,this.endInteractivity,this.getViewParams,this.setViewParams),this._zoomAction=new Mn(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!==Vn.Zoom&&(this.executeEndAction(this._lastGestureAction),this._lastGestureAction=Vn.Zoom,ln.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!==Vn.Pan&&(this.executeEndAction(this._lastGestureAction),this._lastGestureAction=Vn.Pan,ln.isGestureActive=!0,this._panAction.beginAction(t.x,t.y)),this._panAction.action(t.x,t.y),this.subject.update()}executeOrbitAction(t){this._lastGestureAction!==Vn.Orbit&&(this.executeEndAction(this._lastGestureAction),this._lastGestureAction=Vn.Orbit,ln.isGestureActive=!0,this._orbitAction.beginAction(t.x,t.y)),this._orbitAction.action(t.x,t.y),this.subject.update()}executeEndAction(t){t===Vn.Orbit&&this._orbitAction.endAction(),t===Vn.Pan&&this._panAction.endAction(),ln.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),ln.isGestureActive=!1),this._lastGestureAction=Vn.None)}pointercancel(t){this.needIgnoreEvent(t)||this.pointerup(t)}pointerleave(t){this.needIgnoreEvent(t)||this.pointerup(t)}}function zn(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 Gn{constructor(t,e,i){this.viewer=t,this.model=e,this.options=i}async load(){}}class Nn extends Gn{async load(){if(!this.viewer.visualizeJs)return;const t=this.viewer.visLib().getViewer(),e=new AbortController,i=[this.model.database,...this.model.geometry];this.viewer._abortController=e,console.time("File load time");try{this.viewer.emitEvent({type:"geometrystart",model:this.model});for(let r=0;r<i.length;r++){const s=i[r],a=t=>{const e=(r+t)/i.length;this.viewer.emitEvent({type:"geometryprogress",data:e,model:this.model})},n=await this.model.downloadResource(s,a,e.signal);e.signal.aborted&&await Promise.reject(new Error(`Open model aborted ${this.model.name}`)),t.parseStream(new Uint8Array(n)),this.viewer.update();const o=new Uint8Array(n);0===r?(this.viewer.update(!0),this.viewer.syncOpenCloudVisualStyle(!1),this.viewer.syncOptions(),this.viewer.resize(),this.viewer.emitEvent({type:"databasechunk",data:o,model:this.model})):this.viewer.emitEvent({type:"geometrychunk",data:o,model:this.model})}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 Wn extends Gn{async load(){if(!this.viewer.visualizeJs)return;const t=this.viewer.visLib().getViewer(),e=new AbortController;this.viewer._abortController=e;const i=t=>{this.viewer.emitEvent({type:"geometryprogress",data:t,model:this.model})};console.time("File load time");try{this.viewer.emitEvent({type:"geometrystart",model:this.model});const 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}`));const s=new Uint8Array(r);this.viewer.visualizeJs&&(t.parseVsfx(s),this.viewer.syncOpenCloudVisualStyle(!1),this.viewer.syncOptions(),this.viewer.resize()),console.timeEnd("File load time"),this.viewer.emitEvent({type:"databasechunk",data:s,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 Un;!function(t){t[t.kDelay=0]="kDelay",t[t.kNormal=1]="kNormal",t[t.kForce=2]="kForce"}(Un||(Un={}));class Bn{constructor(){this.lastUpdate=0,this.delayUpdateTime=1e3}initialize(t){this.viewer=t,this.lastUpdate=performance.now()}update(t){const e=t!==Un.kDelay||performance.now()-this.lastUpdate>=this.delayUpdateTime,i=t===Un.kForce;e&&(this.viewer.update(i),this.lastUpdate=performance.now(),this.delayUpdateTime*=2)}}class jn extends Gn{async load(){if(!this.viewer.visualizeJs)return;const t=this.viewer.visLib(),e=t.getViewer(),i=new AbortController,r=new Bn;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(Un.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(Un.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.downloadResource(this.model.database,a,i.signal),console.timeEnd("File load time"),r.update(Un.kNormal),this.viewer.emitEvent({type:"geometryend",model:this.model})}catch(t){throw this.viewer.emitEvent({type:"geometryerror",data:t,model:this.model}),t}}}class Hn extends Gn{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 Bn;h.initialize(this.viewer),this.viewer._abortController=e,this.viewer._abortControllerForRequestMap=i,t.memoryLimit=this.options.memoryLimit;const l=(e,i,r=0)=>{if(!this.viewer.visualizeJs)return;const s=t.parseVsfxInPartialMode(r,i);h.update(Un.kDelay),this.viewer.emitEvent({type:"geometryprogress",data:e,model:this.model}),s?(h.update(Un.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)=>{const a=new AbortController;i.set(r,a);try{await this.model.downloadResourceRange(e,r,s,l,a.signal)}catch(t){this.viewer.emitEvent({type:"geometryerror",data:t,model:this.model})}finally{s.forEach((e=>t.onRequestResponseComplete(e.requestId))),i.delete(r),h.update(Un.kNormal)}},c=(t,e)=>{const i=[];for(let r=0;r<e.size();r++){const s=e.get(r);i.push({requestId:t,begin:Number(s.begin),end:Number(s.end)}),s.delete()}return i},u={onServicePartReceived:t=>{t&&(r=!0,e.abort())},onRequest:(t,e)=>{const i=c(t,e);d(this.model.database,t,i)},onFullLoaded:()=>{h.update(Un.kNormal)},onRequestResponseParsed:t=>{i.delete(t),h.update(Un.kNormal)},onRequestAborted:t=>{const e=i.get(t);e&&e.abort()},onRequestResourceFile:(t,e,i)=>{const r=`${this.model.fileId}${this.model.file.type}`,h=c(t,i);let l=[],u=0;const g=s.get(r);return g&&(l=g.ranges,u=g.number),u<=5?(s.set(r,{ranges:[],number:u+1}),void d(r,t,h)):(l=l.concat(h),l.length>=50?(a&&(window.clearTimeout(a),a=0),s.set(r,{ranges:[],number:u+1}),void d(r,t,l)):(s.set(r,{ranges:l,number:u+1}),void(0===a&&(a=window.setTimeout((()=>{o.signal.removeEventListener("abort",n),a=0,s.forEach(((e,i)=>{e.ranges.length>0&&(s.set(i,{ranges:[],number:e.number+1}),d(i,t,e.ranges))}))}),250),o.signal.addEventListener("abort",n,{once:!0})))))}};t.attachPartialResolver(u);try{this.viewer.emitEvent({type:"geometrystart",model:this.model}),await this.model.downloadResource(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 Kn{create(t,e,i){const r=e.database.split(".").pop();if(0===e.geometry.length&&"vsfx"===r)return i.enableStreamingMode?i.enablePartialMode?new Hn(t,e,i):new jn(t,e,i):new Wn(t,e,i);if("data"===r)return new Nn(t,e,i);throw new Error(`Unknown geometry type: ${r}`)}}const Yn="$MarkupTempEntity_Line";class Xn extends ln{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(Yn);const t=this.entity.openObject();t.appendPolyline(this.drawPoints).delete(),t.delete()}}const Jn="$MarkupTempEntity_Text";class qn extends ln{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 Zn{constructor(){this._markupColor={r:255,g:0,b:0},this.lineWidth=4,this.fontSize=34}initialize(t,e,i,r){this._viewer=i,this._viewer.registerDragger("Line",Xn),this._viewer.registerDragger("Text",qn)}dispose(){}syncOverlay(){}clearOverlay(){if(!this._viewer.visualizeJs)return;const t=this._viewer.visViewer().getMarkupModel();t.clearEntities(),t.delete()}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!==Yn&&a!==Jn||s.setColor(t,e,i),s.delete()}r.delete(),this._viewer.update()}colorizeSelectedMarkups(t=255,e=0,i=0){throw new Error("Not implemented yet")}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(Yn).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===Yn){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}enableEditMode(t){return this}createObject(t,e){}getObjects(){return[]}getSelectedObjects(){return[]}selectObjects(t){}clearSelected(){}}class $n{static createMarkup(t="Konva"){let e;switch(t){case"Konva":e=new nn;break;case"Visualize":e=new Zn;break;default:throw new Error("Error during Markup initialization. Unknown Markup type.")}return e}}const Qn="$OVERLAY_VIEW_NAME",to=t=>null!=t;t.CANVAS_EVENTS=o,t.CanvasEvents=n,t.Dragger=class{constructor(t){this.name=""}initialize(){}dispose(){}updatePreview(){}},t.Markup=nn,t.OdBaseDragger=ln,t.Options=a,t.Viewer=class extends on{constructor(t,e={}){var i;super(),this._visualizeJsUrl="",this.frameId=0,this.configure(e),this._options=new a(this),this.client=t,this._activeDragger=null,this._zoomWheelDragger=null,this._gestureManager=null,this._renderTime=0,this.draggerFactory=new Map,this.registerDragger("Pan",Tn),this.registerDragger("Orbit",kn),this.registerDragger("Zoom",In),this.registerDragger("ZoomWindow",Dn),this.registerDragger("OrbitAroundBuilding",Rn),this.registerDragger("MeasureLine",wn),this.registerDragger("CuttingPlaneXAxis",Sn),this.registerDragger("CuttingPlaneYAxis",Cn),this.registerDragger("CuttingPlaneZAxis",Pn),this.registerDragger("Walk",bn),this.canvasEvents=o.slice(),this.canvaseventlistener=t=>this.emit(t),this._enableAutoUpdate=null===(i=e.enableAutoUpdate)||void 0===i||i,this._isNeedRender=!1,this._isRunAsyncUpdate=!1,this.render=this.render.bind(this),this.resize=this.resize.bind(this),this._markup=$n.createMarkup(e.markupType)}get options(){return this._options}get visualizeJsUrl(){return this._visualizeJsUrl}get markup(){return this._markup}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,this._visualizeTimestamp=Date.now();const i=this._visualizeTimestamp,r=await(s=this.visualizeJsUrl,a=t=>{const{loaded:i,total:r}=t;e&&e(new ProgressEvent("progress",{lengthComputable:!0,loaded:i,total:r})),this.emitEvent({type:"initializeprogress",data:i/r,loaded:i,total:r})},zn(s).then((t=>new Promise(((e,i)=>{const r=window.getVisualizeLibInst({urlMemFile:s+".wasm",TOTAL_MEMORY:134217728,onprogress:a});r.loadWasmError=i,r.postRun.push((()=>{window.getVisualizeLibInst.script=t,e(r)}))})))));var s,a;if(i!==this._visualizeTimestamp)throw new Error("Viewer error: dispose() was called before initialize() completed. Are you using React strict mode?");return this._visualizeJs=r,this.visualizeJs.canvas=t,this.visualizeJs.Viewer.create(),this.canvas=t,this.canvasEvents.forEach((e=>t.addEventListener(e,this.canvaseventlistener))),this._markup.initialize(this.canvas,this.canvasEvents,this,this),this._resizeObserver=new ResizeObserver(this.resize),this._resizeObserver.observe(t.parentElement),this.resize(),this._zoomWheelDragger=new Fn(this),this._zoomWheelDragger.name="ZoomWheel",this._zoomWheelDragger.initialize(),this._gestureManager=new Ln(this),this._gestureManager.initialize(),this.syncOpenCloudVisualStyle(!0),this.syncOptions(),this._renderTime=performance.now(),this.render(this._renderTime),this.emitEvent({type:"initialize"}),this}dispose(){return this.cancel(),this.emitEvent({type:"dispose"}),this.frameId&&cancelAnimationFrame(this.frameId),this.frameId=0,this.setActiveDragger(""),this.removeAllListeners(),this._gestureManager&&this._gestureManager.dispose(),this._gestureManager=void 0,this._zoomWheelDragger&&this._zoomWheelDragger.dispose(),this._zoomWheelDragger=void 0,this._resizeObserver&&this._resizeObserver.disconnect(),this._resizeObserver=void 0,this._markup.dispose(),this.canvas&&(this.canvasEvents.forEach((t=>this.canvas.removeEventListener(t,this.canvaseventlistener))),this.canvas=void 0),this._visualizeJs&&this._visualizeJs.getViewer().clear(),this._visualizeJs=void 0,this._visualizeTimestamp=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=!1){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{this._enableAutoUpdate&&(null===(r=this.visViewer())||void 0===r||r.update(t),null===(s=this.activeDragger())||void 0===s||s.updatePreview()),this.emitEvent({type:"update",data:!1}),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}}get visualizeJs(){return this._visualizeJs}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(t){a=i.createVisualStyle("OpenCloud");const r=new e.OdTvColorDef(66,66,66),s=i.findVisualStyle("Realistic"),n=a.openObject();n.copyFrom(s),n.setOptionInt32(e.VisualStyleOptions.kFaceModifiers,0,e.VisualStyleOperations.kSet),n.setOptionInt32(e.VisualStyleOptions.kEdgeModel,2,e.VisualStyleOperations.kSet),n.setOptionDouble(e.VisualStyleOptions.kEdgeCreaseAngle,60,e.VisualStyleOperations.kSet),n.setOptionInt32(e.VisualStyleOptions.kEdgeStyles,0,e.VisualStyleOperations.kSet),n.setOptionInt32(e.VisualStyleOptions.kEdgeModifiers,8,e.VisualStyleOperations.kSet),n.setOptionColor(e.VisualStyleOptions.kEdgeColorValue,r,e.VisualStyleOperations.kSet),n.delete()}return s.visualStyle=a,s.delete(),r.delete(),this}syncOptions(t=this.options){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(to(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){if(!this.visualizeJs)return this;const e=t.enableCustomHighlight?t:a.defaults(),i=this.visLib(),r=i.getViewer(),{Entry:s,OdTvRGBColorDef:n}=i,o=r.findHighlightStyle("Web_Default").openObject();if(to(e.facesColor)){const t=new n(e.facesColor.r,e.facesColor.g,e.facesColor.b);o.setFacesColor(s.k3D.value|s.k3DTop.value,t),t.delete()}if(to(e.facesOverlap)&&o.setFacesVisibility(s.k3DTop.value,e.facesOverlap),to(e.facesTransparancy)&&o.setFacesTransparency(s.k3D.value|s.k3DTop.value,e.facesTransparancy),to(e.edgesColor)){const t=new n(e.edgesColor.r,e.edgesColor.g,e.edgesColor.b);o.setEdgesColor(s.k3DTop.value|s.k3D.value|s.k2D.value|s.k2DTop.value,t),t.delete()}if(to(e.edgesVisibility)&&o.setEdgesVisibility(s.k2D.value|s.k2DTop.value|s.k3DTop.value|s.k3D.value,e.edgesVisibility),to(e.edgesOverlap)){const t=!to(e.edgesVisibility)||e.edgesVisibility;o.setEdgesVisibility(s.k2DTop.value|s.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){if(this._activeDragger&&(this._activeDragger.dispose(),this._activeDragger=null),this.visualizeJs){const e=this.draggerFactory.get(t);e&&(this._activeDragger=new e(this),this._activeDragger.name=t,this._activeDragger.initialize())}const e=this.canvas;e&&(e.className=e.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.visualizeJs&&(this._markup.clearOverlay(),this.update())}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();i.setViewport(r.lowerLeft,r.upperRight),i.vportRect=e.vportRect,this._markup.syncOverlay(),this.update()}is3D(){if(!this.visualizeJs)return!1;const t=this.visViewer().getActiveExtents(),e=t.min();return 0!==t.max()[2]-e[2]}screenToWorld(t){if(!this.visualizeJs)return{x:t.x,y:t.y,z:0};const e=this.visViewer().activeView,i=e.transformScreenToWorld(t.x*window.devicePixelRatio,t.y*window.devicePixelRatio),r={x:i[0],y:i[1],z:i[2]};return e.delete(),r}worldToScreen(t){if(!this.visualizeJs)return{x:t.x,y:t.y};const e=this.visViewer().activeView,i=e.transformWorldToScreen(t.x,t.y,t.z),r={x:i[0]/window.devicePixelRatio,y:i[1]/window.devicePixelRatio};return e.delete(),r}getScale(){const t={x:1,y:1,z:1},e=this.visViewer().activeView.projectionMatrix,i=1e-6,r=e.get(0,0);(r>i||r<-1e-6)&&(t.x=1/r);const s=e.get(1,1);(s>i||s<-1e-6)&&(t.y=1/s);const a=e.get(2,2);return(a>i||a<-1e-6)&&(t.z=1/a),t}getSelected(){return this.executeCommand("getSelected")}setSelected(t){this.executeCommand("setSelected",t)}async loadReferences(t){var e;if(!this.visualizeJs)return this;if(!this.client)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();to(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 a;i.data=this._options.data,".rcs"!==t.type||i.enablePartialMode||(console.log("Partial load mode is forced for RCS file"),i.enablePartialMode=!0);const r=(new Kn).create(this,e,i);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)}colorizeSelectedMarkups(t=255,e=0,i=0){this._markup.colorizeSelectedMarkups(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)}deviceAutoRegeneration(){const t=this.visViewer();t.getActiveDevice().getOptionDouble(this.visLib().DeviceOptions.kRegenCoef)>1&&(t.regenAll(),this.update())}},t.commands=r,t.defaultOptions=s,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}function s(){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"}}r("").registerCommand("noop",(()=>{})),r("VisualizeJS").registerCommand("noop",(()=>{})),r("ThreeJS").registerCommand("noop",(()=>{}));class a{constructor(t){this._emitter=t,this._data={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"},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(){console.warn("Options.notifierChangeEvent() has been deprecated since 25.3 and will be removed in a future release, use Options.change() instead."),this.change()}change(){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=a.defaults(),i=t.reduce(((t,i)=>(t[i]=e[i],t)),{});this.data={...this.data,...i}}else this.data={...this.data,...a.defaults()}}get data(){return this._data}set data(t){const e=!!t.enableStreamingMode&&t.enablePartialMode,i=!e&&t.sceneGraph;this._data={...a.defaults(),...this._data,...t,enablePartialMode:e,sceneGraph:i},this.change()}get showWCS(){return this._data.showWCS}set showWCS(t){this._data.showWCS=t,this.change()}get cameraAnimation(){return this._data.cameraAnimation}set cameraAnimation(t){this._data.cameraAnimation=t,this.change()}get antialiasing(){return this._data.antialiasing}set antialiasing(t){this._data.antialiasing=t,this.change()}get groundShadow(){return this._data.groundShadow}set groundShadow(t){this._data.groundShadow=t,this.change()}get shadows(){return this._data.shadows}set shadows(t){this._data.shadows=t,this.change()}get cameraAxisXSpeed(){return this._data.cameraAxisXSpeed}set cameraAxisXSpeed(t){this._data.cameraAxisXSpeed=t,this.change()}get cameraAxisYSpeed(){return this._data.cameraAxisYSpeed}set cameraAxisYSpeed(t){this.cameraAxisYSpeed=t,this.change()}get ambientOcclusion(){return this._data.ambientOcclusion}set ambientOcclusion(t){this._data.ambientOcclusion=t,this.change()}get enableStreamingMode(){return this._data.enableStreamingMode}set enableStreamingMode(t){this._data.enableStreamingMode=t,t||(this._data.enablePartialMode=!1),this.change()}get enablePartialMode(){return this._data.enablePartialMode}set enablePartialMode(t){this._data.enablePartialMode=t,t&&(this._data.enableStreamingMode=!0,this._data.sceneGraph=!1),this.change()}get memoryLimit(){return this._data.memoryLimit}set memoryLimit(t){this._data.memoryLimit=t,this.change()}get cuttingPlaneFillColor(){return this._data.cuttingPlaneFillColor}set cuttingPlaneFillColor(t){this._data.cuttingPlaneFillColor=t,this.change()}get edgesColor(){return this._data.edgesColor}set edgesColor(t){this._data.edgesColor=t,this.change()}get facesColor(){return this._data.facesColor}set facesColor(t){this._data.facesColor=t,this.change()}get edgesVisibility(){return this._data.edgesVisibility}set edgesVisibility(t){this._data.edgesVisibility=t,this.change()}get edgesOverlap(){return this._data.edgesOverlap}set edgesOverlap(t){this._data.edgesOverlap=t,this.change()}get facesOverlap(){return this._data.facesOverlap}set facesOverlap(t){this._data.facesOverlap=t,this.change()}get facesTransparancy(){return this._data.facesTransparancy}set facesTransparancy(t){this._data.facesTransparancy=t,this.change()}get enableCustomHighlight(){return this._data.enableCustomHighlight}set enableCustomHighlight(t){this._data.enableCustomHighlight=t,this.change()}get sceneGraph(){return this._data.sceneGraph}set sceneGraph(t){this._data.sceneGraph=t,t&&(this._data.enablePartialMode=!1),this.change()}get edgeModel(){return Boolean(this._data.edgeModel)}set edgeModel(t){this._data.edgeModel=Boolean(t),this.change()}get reverseZoomWheel(){return this._data.reverseZoomWheel}set reverseZoomWheel(t){this._data.reverseZoomWheel=!!t,this.change()}get enableZoomWheel(){return this._data.enableZoomWheel}set enableZoomWheel(t){this._data.enableZoomWheel=!!t,this.change()}get enableGestures(){return this._data.enableGestures}set enableGestures(t){this._data.enableGestures=!!t,this.change()}get geometryType(){return this._data.geometryType}set geometryType(t){this._data.geometryType=t,this.change()}}const n=["click","contextmenu","dblclick","mousedown","mouseleave","mousemove","mouseup","pointercancel","pointerdown","pointerleave","pointermove","pointerup","touchcancel","touchend","touchmove","touchstart","wheel"],o=n;const h=(t,e,i)=>{const{translate:r,scale:s,rotation:a}=t,n=new i.Matrix3d;n.setTranslation([r.x,r.y,r.z]);const o=new i.Matrix3d;o.setToRotation(a.angle,[a.x,a.y,a.z],e);const h=new i.Matrix3d;return h.setToScaling(s,e),o.postMultBy(n).postMultBy(h)};function l(t,e=0){if(!t.visualizeJs)return;t.visViewer().explode(e),t.update(),t.emit({type:"explode",data:e})}function d(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})}function c(t){return"$"===t.getName()[0]}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();e.transformBy(t.getUnitsMatrix());const s=h(i,e.center(),r);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",l),r("VisualizeJS").registerCommand("collect",(t=>l(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",d),r("VisualizeJS").registerCommand("k3DViewTop",(t=>d(t,"k3DViewTop"))),r("VisualizeJS").registerCommand("k3DViewBottom",(t=>d(t,"k3DViewBottom"))),r("VisualizeJS").registerCommand("k3DViewLeft",(t=>d(t,"k3DViewLeft"))),r("VisualizeJS").registerCommand("k3DViewRight",(t=>d(t,"k3DViewRight"))),r("VisualizeJS").registerCommand("k3DViewFront",(t=>d(t,"k3DViewFront"))),r("VisualizeJS").registerCommand("k3DViewBack",(t=>d(t,"k3DViewBack"))),r("VisualizeJS").registerCommand("k3DViewSE",(t=>d(t,"k3DViewSE"))),r("VisualizeJS").registerCommand("k3DViewSW",(t=>d(t,"k3DViewSW"))),r("VisualizeJS").registerCommand("k3DViewNE",(t=>d(t,"k3DViewNE"))),r("VisualizeJS").registerCommand("k3DViewNW",(t=>d(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.deviceAutoRegeneration(),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.deviceAutoRegeneration(),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.deviceAutoRegeneration(),t.update(),t.emitEvent({type:"zoom"})})),r("VisualizeJS").registerCommand("autoTransformAllModelsToCentralPoint",(async function(t,e){var i;if(!t.visualizeJs)return;if(!e.getModelTransformMatrix)return;const r=t.visLib(),s=r.getViewer(),a=s.getActiveExtents().center(),n=s.getModelIterator();for(;!n.done();n.step()){const t=n.getModel();if(!c(t)){let i=t.getExtents();const s=t.getUnitsMatrix();i.transformBy(t.getUnitsMatrix());const n=t.getUnitsMatrix().invert(),o=i.center(),l=1,d=new r.Matrix3d,c=new r.Matrix3d;c.setTranslation([a[0]-o[0],a[1]-o[1],a[2]-o[2]]),d.setToScaling(l,a);const u=n.postMultBy(d).postMultBy(c).postMultBy(s),g=u.scale(),p={translate:{x:u.get(0,3)-(1-g)*o[0],y:u.get(1,3)-(1-g)*o[1],z:u.get(2,3)-(1-g)*o[2]},rotation:{x:0,y:0,z:1,angle:0},scale:g},m=h(p,o,r);t.setModelingMatrix(m,!0),a[0]+=Math.abs(i.max()[0]-i.min()[0])*g,await e.setModelTransformMatrix(t.getDatabaseHandle(),p)}t.delete()}n.delete(),null===(i=s.clearViewExtentsCache)||void 0===i||i.call(s),t.update()}));var u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function g(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var p={exports:{}},m={},f={},v={};!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!==u?u:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},t.Konva={_global:t.glob,version:"9.3.13",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,_fixTextRendering:!1,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:()=>t.Konva.DD.isDragging,isTransforming(){var e;return null===(e=t.Konva.Transformer)||void 0===e?void 0:e.isTransforming()},isDragReady:()=>!!t.Konva.DD.node,releaseCanvasOnDestroy:!0,document:t.glob.document,_injectGlobal(e){t.glob.Konva=e}};t._registerNode=e=>{t.Konva[e.prototype.getClassName()]=e},t.Konva._injectGlobal(t.Konva)}(v);var _={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Util=t.Transform=void 0;const e=v;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)}}}(_);var y={},w={},b={};Object.defineProperty(b,"__esModule",{value:!0}),b.getComponentValidator=b.getBooleanValidator=b.getNumberArrayValidator=b.getFunctionValidator=b.getStringOrGradientValidator=b.getStringValidator=b.getNumberOrAutoValidator=b.getNumberOrArrayOfNumbersValidator=b.getNumberValidator=b.alphaComponent=b.RGBComponent=void 0;const x=v,S=_;function C(t){return S.Util._isString(t)?'"'+t+'"':"[object Number]"===Object.prototype.toString.call(t)||S.Util._isBoolean(t)?t:Object.prototype.toString.call(t)}b.RGBComponent=function(t){return t>255?255:t<0?0:Math.round(t)},b.alphaComponent=function(t){return t>1?1:t<1e-4?1e-4:t},b.getNumberValidator=function(){if(x.Konva.isUnminified)return function(t,e){return S.Util._isNumber(t)||S.Util.warn(C(t)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),t}},b.getNumberOrArrayOfNumbersValidator=function(t){if(x.Konva.isUnminified)return function(e,i){let r=S.Util._isNumber(e),s=S.Util._isArray(e)&&e.length==t;return r||s||S.Util.warn(C(e)+' is a not valid value for "'+i+'" attribute. The value should be a number or Array<number>('+t+")"),e}},b.getNumberOrAutoValidator=function(){if(x.Konva.isUnminified)return function(t,e){return S.Util._isNumber(t)||"auto"===t||S.Util.warn(C(t)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),t}},b.getStringValidator=function(){if(x.Konva.isUnminified)return function(t,e){return S.Util._isString(t)||S.Util.warn(C(t)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),t}},b.getStringOrGradientValidator=function(){if(x.Konva.isUnminified)return function(t,e){const i=S.Util._isString(t),r="[object CanvasGradient]"===Object.prototype.toString.call(t)||t&&t.addColorStop;return i||r||S.Util.warn(C(t)+' is a not valid value for "'+e+'" attribute. The value should be a string or a native gradient.'),t}},b.getFunctionValidator=function(){if(x.Konva.isUnminified)return function(t,e){return S.Util._isFunction(t)||S.Util.warn(C(t)+' is a not valid value for "'+e+'" attribute. The value should be a function.'),t}},b.getNumberArrayValidator=function(){if(x.Konva.isUnminified)return function(t,e){const i=Int8Array?Object.getPrototypeOf(Int8Array):null;return i&&t instanceof i||(S.Util._isArray(t)?t.forEach((function(t){S.Util._isNumber(t)||S.Util.warn('"'+e+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")})):S.Util.warn(C(t)+' is a not valid value for "'+e+'" attribute. The value should be a array of numbers.')),t}},b.getBooleanValidator=function(){if(x.Konva.isUnminified)return function(t,e){return!0===t||!1===t||S.Util.warn(C(t)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),t}},b.getComponentValidator=function(t){if(x.Konva.isUnminified)return function(e,i){return null==e||S.Util.isObject(e)||S.Util.warn(C(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=_,i=b;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}}}(w);var P={},A={};Object.defineProperty(A,"__esModule",{value:!0}),A.HitContext=A.SceneContext=A.Context=void 0;const k=_,E=v;var T=["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 M{constructor(t){this.canvas=t,E.Konva.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(t){t.fillEnabled()&&this._fill(t)}_fill(t){}strokeShape(t){t.hasStroke()&&this._stroke(t)}_stroke(t){}fillStrokeShape(t){t.attrs.fillAfterStrokeEnabled?(this.strokeShape(t),this.fillShape(t)):(this.fillShape(t),this.strokeShape(t))}getTrace(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+="()":k.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=T.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=k.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(T[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)}}A.Context=M,["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"].forEach((function(t){Object.defineProperty(M.prototype,t,{get(){return this._context[t]},set(e){this._context[t]=e}})}));A.SceneContext=class extends M{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)}};A.HitContext=class extends M{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(P,"__esModule",{value:!0}),P.HitCanvas=P.SceneCanvas=P.Canvas=void 0;const I=_,F=A,O=v,D=w,R=b;var V;class L{constructor(t){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;var e=(t||{}).pixelRatio||O.Konva.pixelRatio||function(){if(V)return V;var t=I.Util.createCanvasElement(),e=t.getContext("2d");return V=(O.Konva._global.devicePixelRatio||1)/(e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1),I.Util.releaseCanvas(t),V}();this.pixelRatio=e,this._canvas=I.Util.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(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 I.Util.error("Unable to get data URL. "+t.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}}P.Canvas=L,D.Factory.addGetterSetter(L,"pixelRatio",void 0,(0,R.getNumberValidator)());P.SceneCanvas=class extends L{constructor(t={width:0,height:0,willReadFrequently:!1}){super(t),this.context=new F.SceneContext(this,{willReadFrequently:t.willReadFrequently}),this.setSize(t.width,t.height)}};P.HitCanvas=class extends L{constructor(t={width:0,height:0}){super(t),this.hitCanvas=!0,this.context=new F.HitContext(this),this.setSize(t.width,t.height)}};var z={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DD=void 0;const e=v,i=_;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))}(z),Object.defineProperty(y,"__esModule",{value:!0}),y.Node=void 0;const G=_,N=w,W=P,U=v,B=z,j=b;var H="absoluteOpacity",K="allEventListeners",Y="absoluteTransform",X="absoluteScale",J="canvas",q="listening",Z="mouseenter",$="mouseleave",Q="Shape",tt=" ",et="stage",it="transform",rt="visible",st=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(tt);let at=1;class nt{constructor(t){this._id=at++,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!==it&&t!==Y||!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===it||t===Y)&&!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(tt);this.on(i,(()=>{this._clearCache(t)})),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,i)}_getCanvasCache(){return this._cache.get(J)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===Y&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(J)){const{scene:t,filter:e,hit:i}=this._cache.get(J);G.Util.releaseCanvas(t,e,i),this._cache.delete(J)}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 G.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 W.SceneCanvas({pixelRatio:a,width:r,height:s}),u=new W.SceneCanvas({pixelRatio:a,width:0,height:0,willReadFrequently:!0}),g=new W.HitCanvas({pixelRatio:d,width:r,height:s}),p=c.getContext(),m=g.getContext();return g.isCache=!0,c.isCache=!0,this._cache.delete(J),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(H),this._clearSelfAndDescendantCache(X),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(J,{scene:c,filter:u,hit:g,x:n,y:o}),this._requestDraw(),this}isCached(){return this._cache.has(J)}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)):G.Util.error("Filter should be type of function, but got "+typeof r+" instead. Please check correct filters")}catch(t){G.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(K),3===arguments.length)return this._delegate.apply(this,arguments);var i,r,s,a,n=t.split(tt),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(tt),h=o.length;if(this._cache&&this._cache.delete(K),!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=G.Util.cloneObject(t)).currentTarget=s[a],i.call(s[a],t)}))}remove(){return this.isDragging()&&this.stopDrag(),B.DD._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(Y),this._clearSelfAndDescendantCache(H),this._clearSelfAndDescendantCache(X),this._clearSelfAndDescendantCache(et),this._clearSelfAndDescendantCache(rt),this._clearSelfAndDescendantCache(q)}_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"+G.Util._capitalize(t);return G.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"+G.Util._capitalize(e),G.Util._isFunction(this[i])?this[i](t[e]):this._setAttr(e,t[e]))})),this}isListening(){return this._getCache(q,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(rt,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;B.DD._dragElements.forEach((t=>{"dragging"===t.dragStatus&&("Stage"===t.node.nodeType||t.node.getLayer()===i)&&(r=!0)}));var s=!e&&!U.Konva.hitOnDragEnabled&&(r||U.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!==Q&&(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(it),this._clearSelfAndDescendantCache(Y)),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 G.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(it);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(it),this._clearSelfAndDescendantCache(Y),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 G.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 G.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 G.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 G.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 G.Util.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&&G.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(H,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],G.Util.isObject(e)&&!G.Util._isPlainObject(e)&&!G.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 G.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],G.Util.isValidSelector(i)||(G.Util.warn('Selector "'+i+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),G.Util.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),G.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(et,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(Y,this._getAbsoluteTransform)}_getAbsoluteTransform(t){var e;if(t)return e=new G.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(Y)||new G.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(it,this._getTransform)}_getTransform(){var t,e,i=this._cache.get(it)||new G.Transform;i.reset();var r=this.x(),s=this.y(),a=U.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=G.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 W.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 W.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,G.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():U.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"+G.Util._capitalize(t)];return G.Util._isFunction(i)?i.call(this,e):this._setAttr(t,e),this}_requestDraw(){if(U.Konva.autoDrawEnabled){const t=this.getLayer()||this.getStage();null==t||t.batchDraw()}}_setAttr(t,e){var i=this.attrs[t];(i!==e||G.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===Q&&(e.target=this),!((t===Z||t===$)&&(i&&(this===i||this.isAncestorOf&&this.isAncestorOf(i))||"Stage"===this.nodeType&&!i))){this._fire(t,e);var r=(t===Z||t===$)&&i&&i.isAncestorOf&&i.isAncestorOf(this)&&!i.isAncestorOf(this.parent);(e&&!e.cancelBubble||!e)&&this.parent&&this.parent.isListening()&&!r&&(i&&i.parent?this._fireAndBubble.call(this.parent,t,e,i):this._fireAndBubble.call(this.parent,t,e))}}_getProtoListeners(t){var e,i,r;const s=null!==(e=this._cache.get(K))&&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(K,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;B.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){B.DD._dragElements.has(this._id)||this._createDragElement(t);B.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:G.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=B.DD._dragElements.get(this._id);e&&(e.dragStatus="stopped"),B.DD._endDragBefore(t),B.DD._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=B.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)||U.Konva.dragButtons.indexOf(t.evt.button)>=0)&&!this.isDragging()){var e=!1;B.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=B.DD._dragElements.get(this._id),e=t&&"dragging"===t.dragStatus,i=t&&"ready"===t.dragStatus;e?this.stopDrag():i&&B.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 G.Util.haveIntersection(i,this.getClientRect())}static create(t,e){return G.Util._isString(t)&&(t=JSON.parse(t)),this._createNode(t,e)}static _createNode(t,e){var i,r,s,a=nt.prototype.getClassName.call(t),n=t.children;e&&(t.attrs.container=e),U.Konva[a]||(G.Util.warn('Can not find a node with class name "'+a+'". Fallback to "Shape".'),a="Shape");if(i=new(0,U.Konva[a])(t.attrs),n)for(r=n.length,s=0;s<r;s++)i.add(nt._createNode(n[s]));return i}}y.Node=nt,nt.prototype.nodeType="Node",nt.prototype._attrsAffectingSize=[],nt.prototype.eventListeners={},nt.prototype.on.call(nt.prototype,st,(function(){this._batchingTransformChange?this._needClearTransformCache=!0:(this._clearCache(it),this._clearSelfAndDescendantCache(Y))})),nt.prototype.on.call(nt.prototype,"visibleChange.konva",(function(){this._clearSelfAndDescendantCache(rt)})),nt.prototype.on.call(nt.prototype,"listeningChange.konva",(function(){this._clearSelfAndDescendantCache(q)})),nt.prototype.on.call(nt.prototype,"opacityChange.konva",(function(){this._clearSelfAndDescendantCache(H)}));const ot=N.Factory.addGetterSetter;ot(nt,"zIndex"),ot(nt,"absolutePosition"),ot(nt,"position"),ot(nt,"x",0,(0,j.getNumberValidator)()),ot(nt,"y",0,(0,j.getNumberValidator)()),ot(nt,"globalCompositeOperation","source-over",(0,j.getStringValidator)()),ot(nt,"opacity",1,(0,j.getNumberValidator)()),ot(nt,"name","",(0,j.getStringValidator)()),ot(nt,"id","",(0,j.getStringValidator)()),ot(nt,"rotation",0,(0,j.getNumberValidator)()),N.Factory.addComponentsGetterSetter(nt,"scale",["x","y"]),ot(nt,"scaleX",1,(0,j.getNumberValidator)()),ot(nt,"scaleY",1,(0,j.getNumberValidator)()),N.Factory.addComponentsGetterSetter(nt,"skew",["x","y"]),ot(nt,"skewX",0,(0,j.getNumberValidator)()),ot(nt,"skewY",0,(0,j.getNumberValidator)()),N.Factory.addComponentsGetterSetter(nt,"offset",["x","y"]),ot(nt,"offsetX",0,(0,j.getNumberValidator)()),ot(nt,"offsetY",0,(0,j.getNumberValidator)()),ot(nt,"dragDistance",null,(0,j.getNumberValidator)()),ot(nt,"width",0,(0,j.getNumberValidator)()),ot(nt,"height",0,(0,j.getNumberValidator)()),ot(nt,"listening",!0,(0,j.getBooleanValidator)()),ot(nt,"preventDefault",!0,(0,j.getBooleanValidator)()),ot(nt,"filters",null,(function(t){return this._filterUpToDate=!1,t})),ot(nt,"visible",!0,(0,j.getBooleanValidator)()),ot(nt,"transformsEnabled","all",(0,j.getStringValidator)()),ot(nt,"size"),ot(nt,"dragBoundFunc"),ot(nt,"draggable",!1,(0,j.getBooleanValidator)()),N.Factory.backCompat(nt,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});var ht={};Object.defineProperty(ht,"__esModule",{value:!0}),ht.Container=void 0;const lt=w,dt=y,ct=b;class ut extends dt.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=dt.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=dt.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)}}ht.Container=ut,lt.Factory.addComponentsGetterSetter(ut,"clip",["x","y","width","height"]),lt.Factory.addGetterSetter(ut,"clipX",void 0,(0,ct.getNumberValidator)()),lt.Factory.addGetterSetter(ut,"clipY",void 0,(0,ct.getNumberValidator)()),lt.Factory.addGetterSetter(ut,"clipWidth",void 0,(0,ct.getNumberValidator)()),lt.Factory.addGetterSetter(ut,"clipHeight",void 0,(0,ct.getNumberValidator)()),lt.Factory.addGetterSetter(ut,"clipFunc");var gt={},pt={};Object.defineProperty(pt,"__esModule",{value:!0}),pt.releaseCapture=pt.setPointerCapture=pt.hasPointerCapture=pt.createEvent=pt.getCapturedShape=void 0;const mt=v,ft=new Map,vt=void 0!==mt.Konva._global.PointerEvent;function _t(t){return{evt:t,pointerId:t.pointerId}}function yt(t,e){const i=ft.get(t);if(!i)return;const r=i.getStage();r&&r.content,ft.delete(t),vt&&i._fire("lostpointercapture",_t(new PointerEvent("lostpointercapture")))}pt.getCapturedShape=function(t){return ft.get(t)},pt.createEvent=_t,pt.hasPointerCapture=function(t,e){return ft.get(t)===e},pt.setPointerCapture=function(t,e){yt(t),e.getStage()&&(ft.set(t,e),vt&&e._fire("gotpointercapture",_t(new PointerEvent("gotpointercapture"))))},pt.releaseCapture=yt,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Stage=t.stages=void 0;const e=_,i=w,r=ht,s=v,a=P,n=z,o=v,h=pt;var l="mouseleave",d="mouseover",c="mouseenter",u="mousemove",g="mousedown",p="mouseup",m="pointermove",f="pointerdown",y="pointerup",b="pointercancel",x="pointerout",S="pointerleave",C="pointerover",A="pointerenter",k="contextmenu",E="touchstart",T="touchend",M="touchmove",I="touchcancel",F="wheel",O=[[c,"_pointerenter"],[g,"_pointerdown"],[u,"_pointermove"],[p,"_pointerup"],[l,"_pointerleave"],[E,"_pointerdown"],[M,"_pointermove"],[T,"_pointerup"],[I,"_pointercancel"],[d,"_pointerover"],[F,"_wheel"],[k,"_contextmenu"],[f,"_pointerdown"],[m,"_pointermove"],[y,"_pointerup"],[b,"_pointercancel"],["lostpointercapture","_lostpointercapture"]];const D={mouse:{[x]:"mouseout",[S]:l,[C]:d,[A]:c,[m]:u,[f]:g,[y]:p,[b]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[x]:"touchout",[S]:"touchleave",[C]:"touchover",[A]:"touchenter",[m]:M,[f]:E,[y]:T,[b]:I,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[x]:x,[S]:S,[C]:C,[A]:A,[m]:m,[f]:f,[y]:y,[b]:b,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},R=t=>t.indexOf("pointer")>=0?"pointer":t.indexOf("touch")>=0?"touch":"mouse",V=t=>{const e=R(t);return"pointer"===e?s.Konva.pointerEventsEnabled&&D.pointer:"touch"===e?D.touch:"mouse"===e?D.mouse:void 0};function L(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 G extends r.Container{constructor(e){super(L(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",(()=>{L(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&&O.forEach((([t,e])=>{this.content.addEventListener(t,(t=>{this[e](t)}),{passive:!1})}))}_pointerenter(t){this.setPointersPositions(t);const e=V(t.type);e&&this._fire(e.pointerenter,{evt:t,target:this,currentTarget:this})}_pointerover(t){this.setPointersPositions(t);const e=V(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=V(t.type),i=R(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=V(t.type),i=R(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 void(this[i+"ClickStartShape"]=void 0);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=V(t.type),i=R(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=V(t.type),i=R(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(k,{evt:t}):this._fire(k,{evt:t,target:this,currentTarget:this})}_wheel(t){this.setPointersPositions(t);var e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(F,{evt:t}):this._fire(F,{evt:t,target:this,currentTarget:this})}_pointercancel(t){this.setPointersPositions(t);const e=h.getCapturedShape(t.pointerId)||this.getIntersection(this.getPointerPosition());e&&e._fireAndBubble(y,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=G,G.prototype.nodeType="Stage",(0,o._registerNode)(G),i.Factory.addGetterSetter(G,"container"),s.Konva.isBrowser&&document.addEventListener("visibilitychange",(()=>{t.stages.forEach((t=>{t.batchDraw()}))}))}(gt);var wt={},bt={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Shape=t.shapes=void 0;const e=v,i=_,r=w,s=y,a=b,n=v,o=pt;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={}){let e=!1,i=this.getParent();for(;i;){if(i.isCached()){e=!0;break}i=i.getParent()}const r=t.skipTransform,s=t.relativeTo||e&&this.getStage()||void 0,a=this.getSelfRect(),n=!t.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,o=a.width+n,h=a.height+n,l=!t.skipShadow&&this.hasShadow(),d=l?this.shadowOffsetX():0,c=l?this.shadowOffsetY():0,u=o+Math.abs(d),g=h+Math.abs(c),p=l&&this.shadowBlur()||0,m={width:u+2*p,height:g+2*p,x:-(n/2+p)+Math.min(d,0)+a.x,y:-(n/2+p)+Math.min(c,0)+a.y};return r?m:this._transformedRect(m,s)}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"})}(bt),Object.defineProperty(wt,"__esModule",{value:!0}),wt.Layer=void 0;const xt=_,St=ht,Ct=y,Pt=w,At=P,kt=b,Et=bt,Tt=v;var Mt=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],It=Mt.length;class Ft extends St.Container{constructor(t){super(t),this.canvas=new At.SceneCanvas,this.hitCanvas=new At.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(){Ct.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(!Ct.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(Ct.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(Ct.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 Ct.Node.prototype.remove.call(this),t&&t.parentNode&&xt.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&&xt.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(),Ct.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(){xt.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){xt.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,xt.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<It;r++){const s=Mt[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=xt.Util._rgbToHex(i[0],i[1],i[2]),e=Et.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(),St.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(),St.Container.prototype.drawHit.call(this,r,e),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(t){xt.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(t)}getHitGraphEnabled(t){return xt.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 xt.Util.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}}wt.Layer=Ft,Ft.prototype.nodeType="Layer",(0,Tt._registerNode)(Ft),Pt.Factory.addGetterSetter(Ft,"imageSmoothingEnabled",!0),Pt.Factory.addGetterSetter(Ft,"clearBeforeDraw",!0),Pt.Factory.addGetterSetter(Ft,"hitGraphEnabled",!0,(0,kt.getBooleanValidator)());var Ot={};Object.defineProperty(Ot,"__esModule",{value:!0}),Ot.FastLayer=void 0;const Dt=_,Rt=wt,Vt=v;class Lt extends Rt.Layer{constructor(t){super(t),this.listening(!1),Dt.Util.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}}Ot.FastLayer=Lt,Lt.prototype.nodeType="FastLayer",(0,Vt._registerNode)(Lt);var zt={};Object.defineProperty(zt,"__esModule",{value:!0}),zt.Group=void 0;const Gt=_,Nt=ht,Wt=v;class Ut extends Nt.Container{_validateAdd(t){var e=t.getType();"Group"!==e&&"Shape"!==e&&Gt.Util.throw("You may only add groups and shapes to groups.")}}zt.Group=Ut,Ut.prototype.nodeType="Group",(0,Wt._registerNode)(Ut);var Bt={};Object.defineProperty(Bt,"__esModule",{value:!0}),Bt.Animation=void 0;const jt=v,Ht=_,Kt=jt.glob.performance&&jt.glob.performance.now?function(){return jt.glob.performance.now()}:function(){return(new Date).getTime()};class Yt{constructor(t,e){this.id=Yt.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:Kt(),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=Yt.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=Kt(),Yt._addAnimation(this),this}stop(){return Yt._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(Kt());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=Yt;t.animations.length?(t._runFrames(),Ht.Util.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,Ht.Util.requestAnimFrame(this._animationLoop))}}Bt.Animation=Yt,Yt.animations=[],Yt.animIdCounter=0,Yt.animRunning=!1;var Xt={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Easings=t.Tween=void 0;const e=_,i=Bt,r=y,s=v;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}}(Xt),function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Konva=void 0;const e=v,i=_,r=y,s=ht,a=gt,n=wt,o=Ot,h=zt,l=z,d=bt,c=Bt,u=Xt,g=A,p=P;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}(f);var Jt={};Object.defineProperty(Jt,"__esModule",{value:!0}),Jt.Arc=void 0;const qt=w,Zt=bt,$t=v,Qt=b,te=v;class ee extends Zt.Shape{_sceneFunc(t){var e=$t.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=$t.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}}}Jt.Arc=ee,ee.prototype._centroid=!0,ee.prototype.className="Arc",ee.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,te._registerNode)(ee),qt.Factory.addGetterSetter(ee,"innerRadius",0,(0,Qt.getNumberValidator)()),qt.Factory.addGetterSetter(ee,"outerRadius",0,(0,Qt.getNumberValidator)()),qt.Factory.addGetterSetter(ee,"angle",0,(0,Qt.getNumberValidator)()),qt.Factory.addGetterSetter(ee,"clockwise",!1,(0,Qt.getBooleanValidator)());var ie={},re={};Object.defineProperty(re,"__esModule",{value:!0}),re.Line=void 0;const se=w,ae=bt,ne=b,oe=v;function he(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 le(t,e){var i,r,s=t.length,a=[];for(i=2;i<s-2;i+=2)r=he(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 de extends ae.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():le(this.points(),this.tension())}_getTensionPointsClosed(){var t=this.points(),e=t.length,i=this.tension(),r=he(t[e-2],t[e-1],t[0],t[1],t[2],t[3],i),s=he(t[e-4],t[e-3],t[e-2],t[e-1],t[0],t[1],i),a=le(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}}}re.Line=de,de.prototype.className="Line",de.prototype._attrsAffectingSize=["points","bezier","tension"],(0,oe._registerNode)(de),se.Factory.addGetterSetter(de,"closed",!1),se.Factory.addGetterSetter(de,"bezier",!1),se.Factory.addGetterSetter(de,"tension",0,(0,ne.getNumberValidator)()),se.Factory.addGetterSetter(de,"points",[],(0,ne.getNumberArrayValidator)());var ce={},ue={};!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}}(ue),Object.defineProperty(ce,"__esModule",{value:!0}),ce.Path=void 0;const ge=w,pe=bt,me=v,fe=ue;class ve extends pe.Shape{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",(function(){this._readDataAttribute()}))}_readDataAttribute(){this.dataArray=ve.parsePathData(this.data()),this.pathLength=ve.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=ve.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=ve.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=ve.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 ve.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 ve.getPointOnLine(t,a.start.x,a.start.y,n[0],n[1]);case"C":return ve.getPointOnCubicBezier((0,fe.t2length)(t,ve.getPathLength(e),(t=>(0,fe.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 ve.getPointOnQuadraticBezier((0,fe.t2length)(t,ve.getPathLength(e),(t=>(0,fe.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,ve.getPointOnEllipticalArc(o,h,l,d,c,g)}return null}static getPointOnLine(t,e,i,r,s,a,n){a=null!=a?a:e,n=null!=n?n:i;const o=this.getLineLength(e,i,r,s);if(o<1e-10)return{x:e,y:i};if(r===e)return{x:a,y:n+(s>i?t:-t)};const h=(s-i)/(r-e),l=Math.sqrt(t*t/(1+h*h))*(r<e?-1:1),d=h*l;if(Math.abs(n-i-h*(a-e))<1e-10)return{x:a+l,y:n+d};const c=((a-e)*(r-e)+(n-i)*(s-i))/(o*o),u=e+c*(r-e),g=i+c*(s-i),p=this.getLineLength(a,n,u,g),m=Math.sqrt(t*t-p*p),f=Math.sqrt(m*m/(1+h*h))*(r<e?-1:1);return{x:u+f,y:g+h*f}}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,A,k="",E=[],T=h,M=l;switch(u){case"l":h+=g.shift(),l+=g.shift(),k="L",E.push(h,l);break;case"L":h=g.shift(),l=g.shift(),E.push(h,l);break;case"m":var I=g.shift(),F=g.shift();if(h+=I,l+=F,k="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]+I,l=n[O].points[1]+F;break}E.push(h,l),u="l";break;case"M":h=g.shift(),l=g.shift(),k="M",E.push(h,l),u="L";break;case"h":h+=g.shift(),k="L",E.push(h,l);break;case"H":h=g.shift(),k="L",E.push(h,l);break;case"v":l+=g.shift(),k="L",E.push(h,l);break;case"V":l=g.shift(),k="L",E.push(h,l);break;case"C":E.push(g.shift(),g.shift(),g.shift(),g.shift()),h=g.shift(),l=g.shift(),E.push(h,l);break;case"c":E.push(h+g.shift(),l+g.shift(),h+g.shift(),l+g.shift()),h+=g.shift(),l+=g.shift(),k="C",E.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])),E.push(_,y,g.shift(),g.shift()),h=g.shift(),l=g.shift(),k="C",E.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])),E.push(_,y,h+g.shift(),l+g.shift()),h+=g.shift(),l+=g.shift(),k="C",E.push(h,l);break;case"Q":E.push(g.shift(),g.shift()),h=g.shift(),l=g.shift(),E.push(h,l);break;case"q":E.push(h+g.shift(),l+g.shift()),h+=g.shift(),l+=g.shift(),k="Q",E.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(),k="Q",E.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(),k="Q",E.push(_,y,h,l);break;case"A":w=g.shift(),b=g.shift(),x=g.shift(),S=g.shift(),C=g.shift(),P=h,A=l,h=g.shift(),l=g.shift(),k="A",E=this.convertEndpointToCenterParameterization(P,A,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,A=l,h+=g.shift(),l+=g.shift(),k="A",E=this.convertEndpointToCenterParameterization(P,A,h,l,S,C,w,b,x)}n.push({command:k||u,points:E,start:{x:T,y:M},pathLength:this.calcLength(T,M,k||u,E)})}"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=ve;switch(i){case"L":return h.getLineLength(t,e,r[0],r[1]);case"C":return(0,fe.getCubicArcLength)([t,r[0],r[2],r[4]],[e,r[1],r[3],r[5]],1);case"Q":return(0,fe.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]}}ce.Path=ve,ve.prototype.className="Path",ve.prototype._attrsAffectingSize=["data"],(0,me._registerNode)(ve),ge.Factory.addGetterSetter(ve,"data"),Object.defineProperty(ie,"__esModule",{value:!0}),ie.Arrow=void 0;const _e=w,ye=re,we=b,be=v,xe=ce;class Se extends ye.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=xe.Path.calcLength(r[r.length-4],r[r.length-3],"C",t),s=xe.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}}}ie.Arrow=Se,Se.prototype.className="Arrow",(0,be._registerNode)(Se),_e.Factory.addGetterSetter(Se,"pointerLength",10,(0,we.getNumberValidator)()),_e.Factory.addGetterSetter(Se,"pointerWidth",10,(0,we.getNumberValidator)()),_e.Factory.addGetterSetter(Se,"pointerAtBeginning",!1),_e.Factory.addGetterSetter(Se,"pointerAtEnding",!0);var Ce={};Object.defineProperty(Ce,"__esModule",{value:!0}),Ce.Circle=void 0;const Pe=w,Ae=bt,ke=b,Ee=v;class Te extends Ae.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)}}Ce.Circle=Te,Te.prototype._centroid=!0,Te.prototype.className="Circle",Te.prototype._attrsAffectingSize=["radius"],(0,Ee._registerNode)(Te),Pe.Factory.addGetterSetter(Te,"radius",0,(0,ke.getNumberValidator)());var Me={};Object.defineProperty(Me,"__esModule",{value:!0}),Me.Ellipse=void 0;const Ie=w,Fe=bt,Oe=b,De=v;class Re extends Fe.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)}}Me.Ellipse=Re,Re.prototype.className="Ellipse",Re.prototype._centroid=!0,Re.prototype._attrsAffectingSize=["radiusX","radiusY"],(0,De._registerNode)(Re),Ie.Factory.addComponentsGetterSetter(Re,"radius",["x","y"]),Ie.Factory.addGetterSetter(Re,"radiusX",0,(0,Oe.getNumberValidator)()),Ie.Factory.addGetterSetter(Re,"radiusY",0,(0,Oe.getNumberValidator)());var Ve={};Object.defineProperty(Ve,"__esModule",{value:!0}),Ve.Image=void 0;const Le=_,ze=w,Ge=bt,Ne=v,We=b;class Ue extends Ge.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?Le.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?Le.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=Le.Util.createImageElement();r.onload=function(){var t=new Ue({image:r});e(t)},r.onerror=i,r.crossOrigin="Anonymous",r.src=t}}Ve.Image=Ue,Ue.prototype.className="Image",(0,Ne._registerNode)(Ue),ze.Factory.addGetterSetter(Ue,"cornerRadius",0,(0,We.getNumberOrArrayOfNumbersValidator)(4)),ze.Factory.addGetterSetter(Ue,"image"),ze.Factory.addComponentsGetterSetter(Ue,"crop",["x","y","width","height"]),ze.Factory.addGetterSetter(Ue,"cropX",0,(0,We.getNumberValidator)()),ze.Factory.addGetterSetter(Ue,"cropY",0,(0,We.getNumberValidator)()),ze.Factory.addGetterSetter(Ue,"cropWidth",0,(0,We.getNumberValidator)()),ze.Factory.addGetterSetter(Ue,"cropHeight",0,(0,We.getNumberValidator)());var Be={};Object.defineProperty(Be,"__esModule",{value:!0}),Be.Tag=Be.Label=void 0;const je=w,He=bt,Ke=zt,Ye=b,Xe=v;var Je=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],qe="up",Ze="right",$e="down",Qe="left",ti=Je.length;class ei extends Ke.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<ti;e++)t.on(Je[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 qe:s=t/2,a=-1*n;break;case Ze:s=t+r,a=e/2;break;case $e:s=t/2,a=e+n;break;case Qe: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})}}}Be.Label=ei,ei.prototype.className="Label",(0,Xe._registerNode)(ei);class ii extends He.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===qe&&(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===Ze&&(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===$e&&(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===Qe&&(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===qe?(e-=r,n+=r):s===$e?n+=r:s===Qe?(t-=1.5*i,a+=i):s===Ze&&(a+=1.5*i),{x:t,y:e,width:a,height:n}}}Be.Tag=ii,ii.prototype.className="Tag",(0,Xe._registerNode)(ii),je.Factory.addGetterSetter(ii,"pointerDirection","none"),je.Factory.addGetterSetter(ii,"pointerWidth",0,(0,Ye.getNumberValidator)()),je.Factory.addGetterSetter(ii,"pointerHeight",0,(0,Ye.getNumberValidator)()),je.Factory.addGetterSetter(ii,"cornerRadius",0,(0,Ye.getNumberOrArrayOfNumbersValidator)(4));var ri={};Object.defineProperty(ri,"__esModule",{value:!0}),ri.Rect=void 0;const si=w,ai=bt,ni=v,oi=_,hi=b;class li extends ai.Shape{_sceneFunc(t){var e=this.cornerRadius(),i=this.width(),r=this.height();t.beginPath(),e?oi.Util.drawRoundedRectPath(t,i,r,e):t.rect(0,0,i,r),t.closePath(),t.fillStrokeShape(this)}}ri.Rect=li,li.prototype.className="Rect",(0,ni._registerNode)(li),si.Factory.addGetterSetter(li,"cornerRadius",0,(0,hi.getNumberOrArrayOfNumbersValidator)(4));var di={};Object.defineProperty(di,"__esModule",{value:!0}),di.RegularPolygon=void 0;const ci=w,ui=bt,gi=b,pi=v;class mi extends ui.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)}}di.RegularPolygon=mi,mi.prototype.className="RegularPolygon",mi.prototype._centroid=!0,mi.prototype._attrsAffectingSize=["radius"],(0,pi._registerNode)(mi),ci.Factory.addGetterSetter(mi,"radius",0,(0,gi.getNumberValidator)()),ci.Factory.addGetterSetter(mi,"sides",0,(0,gi.getNumberValidator)());var fi={};Object.defineProperty(fi,"__esModule",{value:!0}),fi.Ring=void 0;const vi=w,_i=bt,yi=b,wi=v;var bi=2*Math.PI;class xi extends _i.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.innerRadius(),0,bi,!1),t.moveTo(this.outerRadius(),0),t.arc(0,0,this.outerRadius(),bi,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)}}fi.Ring=xi,xi.prototype.className="Ring",xi.prototype._centroid=!0,xi.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,wi._registerNode)(xi),vi.Factory.addGetterSetter(xi,"innerRadius",0,(0,yi.getNumberValidator)()),vi.Factory.addGetterSetter(xi,"outerRadius",0,(0,yi.getNumberValidator)());var Si={};Object.defineProperty(Si,"__esModule",{value:!0}),Si.Sprite=void 0;const Ci=w,Pi=bt,Ai=Bt,ki=b,Ei=v;class Ti extends Pi.Shape{constructor(t){super(t),this._updated=!0,this.anim=new Ai.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)}}Si.Sprite=Ti,Ti.prototype.className="Sprite",(0,Ei._registerNode)(Ti),Ci.Factory.addGetterSetter(Ti,"animation"),Ci.Factory.addGetterSetter(Ti,"animations"),Ci.Factory.addGetterSetter(Ti,"frameOffsets"),Ci.Factory.addGetterSetter(Ti,"image"),Ci.Factory.addGetterSetter(Ti,"frameIndex",0,(0,ki.getNumberValidator)()),Ci.Factory.addGetterSetter(Ti,"frameRate",17,(0,ki.getNumberValidator)()),Ci.Factory.backCompat(Ti,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});var Mi={};Object.defineProperty(Mi,"__esModule",{value:!0}),Mi.Star=void 0;const Ii=w,Fi=bt,Oi=b,Di=v;class Ri extends Fi.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)}}Mi.Star=Ri,Ri.prototype.className="Star",Ri.prototype._centroid=!0,Ri.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,Di._registerNode)(Ri),Ii.Factory.addGetterSetter(Ri,"numPoints",5,(0,Oi.getNumberValidator)()),Ii.Factory.addGetterSetter(Ri,"innerRadius",0,(0,Oi.getNumberValidator)()),Ii.Factory.addGetterSetter(Ri,"outerRadius",0,(0,Oi.getNumberValidator)());var Vi={};Object.defineProperty(Vi,"__esModule",{value:!0}),Vi.Text=Vi.stringToArray=void 0;const Li=_,zi=w,Gi=bt,Ni=v,Wi=b,Ui=v;function Bi(t){return Array.from(t)}Vi.stringToArray=Bi;var ji,Hi="auto",Ki="inherit",Yi="justify",Xi="left",Ji="middle",qi="normal",Zi=" ",$i="none",Qi=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],tr=Qi.length;function er(){return ji||(ji=Li.Util.createCanvasElement().getContext("2d"))}class ir extends Gi.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<tr;e++)this.on(Qi[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");h=h===Ki?t.direction:h;var v=n/2,_=Ji;if(Ni.Konva._fixTextRendering){var y=this.measureSize("M");_="alphabetic",v=(y.fontBoundingBoxAscent-y.fontBoundingBoxDescent)/2+n/2}var w=0,b=0;for("rtl"===h&&t.setAttr("direction",h),t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",_),t.setAttr("textAlign",Xi),o===Ji?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++){w=0,b=0;var x,S,C,P=e[r],A=P.text,k=P.width,E=P.lastInParagraph;if(t.save(),"right"===d?w+=c-k-2*s:"center"===d&&(w+=(c-k-2*s)/2),m){t.save(),t.beginPath();const e=w,i=v+b+(Ni.Konva._fixTextRendering?Math.round(a/4):Math.round(a/2));t.moveTo(e,i),S=0===(x=A.split(" ").length-1),C=d!==Yi||E?k:c-2*s,t.lineTo(e+Math.round(C),i),t.lineWidth=a/15;const r=this._getLinearGradient();t.strokeStyle=r||g,t.stroke(),t.restore()}if(f){t.save(),t.beginPath();let e=Ni.Konva._fixTextRendering?-Math.round(a/4):0;t.moveTo(w,v+b+e),S=0===(x=A.split(" ").length-1),C=d===Yi&&E&&!S?c-2*s:k,t.lineTo(w+Math.round(C),v+b+e),t.lineWidth=a/15;const i=this._getLinearGradient();t.strokeStyle=i||g,t.stroke(),t.restore()}if("rtl"===h||0===u&&d!==Yi)0!==u&&t.setAttr("letterSpacing",`${u}px`),this._partialTextX=w,this._partialTextY=v+b,this._partialText=A,t.fillStrokeShape(this);else{x=A.split(" ").length-1;for(var T=Bi(A),M=0;M<T.length;M++){var I=T[M];" "!==I||E||d!==Yi||(w+=(c-2*s-k)/x),this._partialTextX=w,this._partialTextY=v+b,this._partialText=I,t.fillStrokeShape(this),w+=this.measureSize(I).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=Li.Util._isString(t)?t:null==t?"":t+"";return this._setAttr("text",e),this}getWidth(){return this.attrs.width===Hi||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}getHeight(){return this.attrs.height===Hi||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return Li.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(t){var e,i,r,s,a,n,o,h,l,d,c,u,g=er(),p=this.fontSize();g.save(),g.font=this._getContextFont(),u=g.measureText(t),g.restore();const m=p/100;return{actualBoundingBoxAscent:null!==(e=u.actualBoundingBoxAscent)&&void 0!==e?e:71.58203125*m,actualBoundingBoxDescent:null!==(i=u.actualBoundingBoxDescent)&&void 0!==i?i:0,actualBoundingBoxLeft:null!==(r=u.actualBoundingBoxLeft)&&void 0!==r?r:-7.421875*m,actualBoundingBoxRight:null!==(s=u.actualBoundingBoxRight)&&void 0!==s?s:75.732421875*m,alphabeticBaseline:null!==(a=u.alphabeticBaseline)&&void 0!==a?a:0,emHeightAscent:null!==(n=u.emHeightAscent)&&void 0!==n?n:100*m,emHeightDescent:null!==(o=u.emHeightDescent)&&void 0!==o?o:-20*m,fontBoundingBoxAscent:null!==(h=u.fontBoundingBoxAscent)&&void 0!==h?h:91*m,fontBoundingBoxDescent:null!==(l=u.fontBoundingBoxDescent)&&void 0!==l?l:21*m,hangingBaseline:null!==(d=u.hangingBaseline)&&void 0!==d?d:72.80000305175781*m,ideographicBaseline:null!==(c=u.ideographicBaseline)&&void 0!==c?c:-21*m,width:u.width,height:p}}_getContextFont(){return this.fontStyle()+Zi+this.fontVariant()+Zi+(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()===Yi&&(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 er().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!==Hi&&void 0!==s,o=a!==Hi&&void 0!==a,h=this.padding(),l=s-2*h,d=a-2*h,c=0,u=this.wrap(),g="char"!==u&&u!==$i,p=this.ellipsis();this.textArr=[],er().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),A=this._getTextWidth(P)+m;A<=l?(w=C+1,x=P,S=A):b=C}if(!x)break;if(g){var k,E=_[x.length];(k=(E===Zi||"-"===E)&&S<=l?x.length:Math.max(x.lastIndexOf(Zi),x.lastIndexOf("-"))+1)>0&&(w=k,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!==Hi&&void 0!==r,a=r-2*this.padding();return!(this.wrap()!==$i)||s&&t+i>a}_tryToAddEllipsisToLastLine(){var t=this.attrs.width,e=t!==Hi&&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()}}Vi.Text=ir,ir.prototype._fillFunc=function(t){t.fillText(this._partialText,this._partialTextX,this._partialTextY)},ir.prototype._strokeFunc=function(t){t.setAttr("miterLimit",2),t.strokeText(this._partialText,this._partialTextX,this._partialTextY)},ir.prototype.className="Text",ir.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],(0,Ui._registerNode)(ir),zi.Factory.overWriteSetter(ir,"width",(0,Wi.getNumberOrAutoValidator)()),zi.Factory.overWriteSetter(ir,"height",(0,Wi.getNumberOrAutoValidator)()),zi.Factory.addGetterSetter(ir,"direction",Ki),zi.Factory.addGetterSetter(ir,"fontFamily","Arial"),zi.Factory.addGetterSetter(ir,"fontSize",12,(0,Wi.getNumberValidator)()),zi.Factory.addGetterSetter(ir,"fontStyle",qi),zi.Factory.addGetterSetter(ir,"fontVariant",qi),zi.Factory.addGetterSetter(ir,"padding",0,(0,Wi.getNumberValidator)()),zi.Factory.addGetterSetter(ir,"align",Xi),zi.Factory.addGetterSetter(ir,"verticalAlign","top"),zi.Factory.addGetterSetter(ir,"lineHeight",1,(0,Wi.getNumberValidator)()),zi.Factory.addGetterSetter(ir,"wrap","word"),zi.Factory.addGetterSetter(ir,"ellipsis",!1,(0,Wi.getBooleanValidator)()),zi.Factory.addGetterSetter(ir,"letterSpacing",0,(0,Wi.getNumberValidator)()),zi.Factory.addGetterSetter(ir,"text","",(0,Wi.getStringValidator)()),zi.Factory.addGetterSetter(ir,"textDecoration","");var rr={};Object.defineProperty(rr,"__esModule",{value:!0}),rr.TextPath=void 0;const sr=_,ar=w,nr=bt,or=ce,hr=Vi,lr=b,dr=v;var cr="normal";function ur(t){t.fillText(this.partialText,0,0)}function gr(t){t.strokeText(this.partialText,0,0)}class pr extends nr.Shape{constructor(t){super(t),this.dummyCanvas=sr.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 or.Path.getPathLength(this.dataArray)}_getPointAtLength(t){if(!this.attrs.data)return null;return t-1>this.pathLength?null:or.Path.getPointAtLengthOfDataArray(t,this.dataArray)}_readDataAttribute(){this.dataArray=or.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 sr.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 hr.Text.prototype.setText.call(this,t)}_getContextFont(){return hr.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,hr.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=or.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=or.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 sr.Util.releaseCanvas(this.dummyCanvas),super.destroy()}}rr.TextPath=pr,pr.prototype._fillFunc=ur,pr.prototype._strokeFunc=gr,pr.prototype._fillFuncHit=ur,pr.prototype._strokeFuncHit=gr,pr.prototype.className="TextPath",pr.prototype._attrsAffectingSize=["text","fontSize","data"],(0,dr._registerNode)(pr),ar.Factory.addGetterSetter(pr,"data"),ar.Factory.addGetterSetter(pr,"fontFamily","Arial"),ar.Factory.addGetterSetter(pr,"fontSize",12,(0,lr.getNumberValidator)()),ar.Factory.addGetterSetter(pr,"fontStyle",cr),ar.Factory.addGetterSetter(pr,"align","left"),ar.Factory.addGetterSetter(pr,"letterSpacing",0,(0,lr.getNumberValidator)()),ar.Factory.addGetterSetter(pr,"textBaseline","middle"),ar.Factory.addGetterSetter(pr,"fontVariant",cr),ar.Factory.addGetterSetter(pr,"text",""),ar.Factory.addGetterSetter(pr,"textDecoration",null),ar.Factory.addGetterSetter(pr,"kerningFunc",null);var mr={};Object.defineProperty(mr,"__esModule",{value:!0}),mr.Transformer=void 0;const fr=_,vr=w,_r=y,yr=bt,wr=ri,br=zt,xr=v,Sr=b,Cr=v;var Pr="tr-konva",Ar=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map((t=>t+`.${Pr}`)).join(" "),kr="nodesRect",Er=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],Tr={"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 Mr="ontouchstart"in xr.Konva._global;var Ir=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function Fr(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 Or(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 Fr(t,e,i)}let Dr=0;class Rr extends br.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(Ar,this.update),this.getNode()&&this.update()}attachTo(t){return this.setNode(t),this}setNode(t){return fr.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 Pr+this._id}setNodes(t=[]){this._nodes&&this._nodes.length&&this.detach();const e=t.filter((t=>!t.isAncestorOf(this)||(fr.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(Er.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(kr),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(kr,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=(xr.Konva.getAngle(t.getAbsoluteRotation())+2*Math.PI)%(2*Math.PI);return Fr({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},-xr.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 fr.Transform;e.rotate(-xr.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:xr.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(),Ir.forEach((t=>{this._createAnchor(t)})),this._createAnchor("rotater")}_createAnchor(t){var e=new wr.Rect({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:t+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:Mr?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=xr.Konva.getAngle(this.rotation()),r=this.rotateAnchorCursor(),s=function(t,e,i){if("rotater"===t)return i;e+=fr.Util.degToRad(Tr[t]||0);var r=(fr.Util.radToDeg(e)%360+360)%360;return fr.Util._inRange(r,337.5,360)||fr.Util._inRange(r,0,22.5)?"ns-resize":fr.Util._inRange(r,22.5,67.5)?"nesw-resize":fr.Util._inRange(r,67.5,112.5)?"ew-resize":fr.Util._inRange(r,112.5,157.5)?"nwse-resize":fr.Util._inRange(r,157.5,202.5)?"ns-resize":fr.Util._inRange(r,202.5,247.5)?"nesw-resize":fr.Util._inRange(r,247.5,292.5)?"ew-resize":fr.Util._inRange(r,292.5,337.5)?"nwse-resize":(fr.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 yr.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()*fr.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){if(!this._transforming){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},Dr++,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:xr.Konva.getAngle(this.rotation())},t)}else{var A=this._getNodeRect();e=s.x()-A.width/2,i=-s.y()+A.height/2;let r=Math.atan2(-i,e)+Math.PI/2;A.height<0&&(r-=Math.PI);const a=xr.Konva.getAngle(this.rotation())+r,n=xr.Konva.getAngle(this.rotationSnapTolerance()),o=Or(A,function(t,e,i){let r=e;for(let s=0;s<t.length;s++){const a=xr.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)-A.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();Dr--,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(fr.Util._inRange(t.width,2*-this.padding()-1,1))return void this.update();if(fr.Util._inRange(t.height,2*-this.padding()-1,1))return void this.update();var r=new fr.Transform;if(r.rotate(xr.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:fr.Util.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const s=1e7,a=new fr.Transform;a.translate(i.x,i.y),a.rotate(i.rotation),a.scale(i.width/s,i.height/s);const n=new fr.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 fr.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(fr.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(fr.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()*fr.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=""),br.Group.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return _r.Node.prototype.toObject.call(this)}clone(t){return _r.Node.prototype.clone.call(this,t)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}}mr.Transformer=Rr,Rr.isTransforming=()=>Dr>0,Rr.prototype.className="Transformer",(0,Cr._registerNode)(Rr),vr.Factory.addGetterSetter(Rr,"enabledAnchors",Ir,(function(t){return t instanceof Array||fr.Util.warn("enabledAnchors value should be an array"),t instanceof Array&&t.forEach((function(t){-1===Ir.indexOf(t)&&fr.Util.warn("Unknown anchor name: "+t+". Available names are: "+Ir.join(", "))})),t||[]})),vr.Factory.addGetterSetter(Rr,"flipEnabled",!0,(0,Sr.getBooleanValidator)()),vr.Factory.addGetterSetter(Rr,"resizeEnabled",!0),vr.Factory.addGetterSetter(Rr,"anchorSize",10,(0,Sr.getNumberValidator)()),vr.Factory.addGetterSetter(Rr,"rotateEnabled",!0),vr.Factory.addGetterSetter(Rr,"rotateLineVisible",!0),vr.Factory.addGetterSetter(Rr,"rotationSnaps",[]),vr.Factory.addGetterSetter(Rr,"rotateAnchorOffset",50,(0,Sr.getNumberValidator)()),vr.Factory.addGetterSetter(Rr,"rotateAnchorCursor","crosshair"),vr.Factory.addGetterSetter(Rr,"rotationSnapTolerance",5,(0,Sr.getNumberValidator)()),vr.Factory.addGetterSetter(Rr,"borderEnabled",!0),vr.Factory.addGetterSetter(Rr,"anchorStroke","rgb(0, 161, 255)"),vr.Factory.addGetterSetter(Rr,"anchorStrokeWidth",1,(0,Sr.getNumberValidator)()),vr.Factory.addGetterSetter(Rr,"anchorFill","white"),vr.Factory.addGetterSetter(Rr,"anchorCornerRadius",0,(0,Sr.getNumberValidator)()),vr.Factory.addGetterSetter(Rr,"borderStroke","rgb(0, 161, 255)"),vr.Factory.addGetterSetter(Rr,"borderStrokeWidth",1,(0,Sr.getNumberValidator)()),vr.Factory.addGetterSetter(Rr,"borderDash"),vr.Factory.addGetterSetter(Rr,"keepRatio",!0),vr.Factory.addGetterSetter(Rr,"shiftBehavior","default"),vr.Factory.addGetterSetter(Rr,"centeredScaling",!1),vr.Factory.addGetterSetter(Rr,"ignoreStroke",!1),vr.Factory.addGetterSetter(Rr,"padding",0,(0,Sr.getNumberValidator)()),vr.Factory.addGetterSetter(Rr,"node"),vr.Factory.addGetterSetter(Rr,"nodes"),vr.Factory.addGetterSetter(Rr,"boundBoxFunc"),vr.Factory.addGetterSetter(Rr,"anchorDragBoundFunc"),vr.Factory.addGetterSetter(Rr,"anchorStyleFunc"),vr.Factory.addGetterSetter(Rr,"shouldOverdrawWholeArea",!1),vr.Factory.addGetterSetter(Rr,"useSingleNodeRotation",!0),vr.Factory.backCompat(Rr,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});var Vr={};Object.defineProperty(Vr,"__esModule",{value:!0}),Vr.Wedge=void 0;const Lr=w,zr=bt,Gr=v,Nr=b,Wr=v;class Ur extends zr.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.radius(),0,Gr.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)}}Vr.Wedge=Ur,Ur.prototype.className="Wedge",Ur.prototype._centroid=!0,Ur.prototype._attrsAffectingSize=["radius"],(0,Wr._registerNode)(Ur),Lr.Factory.addGetterSetter(Ur,"radius",0,(0,Nr.getNumberValidator)()),Lr.Factory.addGetterSetter(Ur,"angle",0,(0,Nr.getNumberValidator)()),Lr.Factory.addGetterSetter(Ur,"clockwise",!1),Lr.Factory.backCompat(Ur,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});var Br={};Object.defineProperty(Br,"__esModule",{value:!0}),Br.Blur=void 0;const jr=w,Hr=y,Kr=b;function Yr(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var Xr=[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],Jr=[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];Br.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,A=t.data,k=t.width,E=t.height,T=e+e+1,M=k-1,I=E-1,F=e+1,O=F*(F+1)/2,D=new Yr,R=null,V=D,L=null,z=null,G=Xr[e],N=Jr[e];for(s=1;s<T;s++)V=V.next=new Yr,s===F&&(R=V);for(V.next=D,h=o=0,r=0;r<E;r++){for(v=_=y=w=l=d=c=u=0,g=F*(b=A[o]),p=F*(x=A[o+1]),m=F*(S=A[o+2]),f=F*(C=A[o+3]),l+=O*b,d+=O*x,c+=O*S,u+=O*C,V=D,s=0;s<F;s++)V.r=b,V.g=x,V.b=S,V.a=C,V=V.next;for(s=1;s<F;s++)a=o+((M<s?M:s)<<2),l+=(V.r=b=A[a])*(P=F-s),d+=(V.g=x=A[a+1])*P,c+=(V.b=S=A[a+2])*P,u+=(V.a=C=A[a+3])*P,v+=b,_+=x,y+=S,w+=C,V=V.next;for(L=D,z=R,i=0;i<k;i++)A[o+3]=C=u*G>>N,0!==C?(C=255/C,A[o]=(l*G>>N)*C,A[o+1]=(d*G>>N)*C,A[o+2]=(c*G>>N)*C):A[o]=A[o+1]=A[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=A[a],d+=_+=L.g=A[a+1],c+=y+=L.b=A[a+2],u+=w+=L.a=A[a+3],L=L.next,g+=b=z.r,p+=x=z.g,m+=S=z.b,f+=C=z.a,v-=b,_-=x,y-=S,w-=C,z=z.next,o+=4;h+=k}for(i=0;i<k;i++){for(_=y=w=v=d=c=u=l=0,g=F*(b=A[o=i<<2]),p=F*(x=A[o+1]),m=F*(S=A[o+2]),f=F*(C=A[o+3]),l+=O*b,d+=O*x,c+=O*S,u+=O*C,V=D,s=0;s<F;s++)V.r=b,V.g=x,V.b=S,V.a=C,V=V.next;for(n=k,s=1;s<=e;s++)o=n+i<<2,l+=(V.r=b=A[o])*(P=F-s),d+=(V.g=x=A[o+1])*P,c+=(V.b=S=A[o+2])*P,u+=(V.a=C=A[o+3])*P,v+=b,_+=x,y+=S,w+=C,V=V.next,s<I&&(n+=k);for(o=i,L=D,z=R,r=0;r<E;r++)A[3+(a=o<<2)]=C=u*G>>N,C>0?(C=255/C,A[a]=(l*G>>N)*C,A[a+1]=(d*G>>N)*C,A[a+2]=(c*G>>N)*C):A[a]=A[a+1]=A[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+F)<I?a:I)*k<<2,l+=v+=L.r=A[a],d+=_+=L.g=A[a+1],c+=y+=L.b=A[a+2],u+=w+=L.a=A[a+3],L=L.next,g+=b=z.r,p+=x=z.g,m+=S=z.b,f+=C=z.a,v-=b,_-=x,y-=S,w-=C,z=z.next,o+=k}}(t,e)},jr.Factory.addGetterSetter(Hr.Node,"blurRadius",0,(0,Kr.getNumberValidator)(),jr.Factory.afterSetFilter);var qr={};Object.defineProperty(qr,"__esModule",{value:!0}),qr.Brighten=void 0;const Zr=w,$r=y,Qr=b;qr.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},Zr.Factory.addGetterSetter($r.Node,"brightness",0,(0,Qr.getNumberValidator)(),Zr.Factory.afterSetFilter);var ts={};Object.defineProperty(ts,"__esModule",{value:!0}),ts.Contrast=void 0;const es=w,is=y,rs=b;ts.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},es.Factory.addGetterSetter(is.Node,"contrast",0,(0,rs.getNumberValidator)(),es.Factory.afterSetFilter);var ss={};Object.defineProperty(ss,"__esModule",{value:!0}),ss.Emboss=void 0;const as=w,ns=y,os=_,hs=b;ss.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:os.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,A=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]=A>255?255:A<0?0:A}else{var k=i-x;k<0?k=0:k>255&&(k=255),o[f]=o[f+1]=o[f+2]=k}}while(--m)}while(--c)},as.Factory.addGetterSetter(ns.Node,"embossStrength",.5,(0,hs.getNumberValidator)(),as.Factory.afterSetFilter),as.Factory.addGetterSetter(ns.Node,"embossWhiteLevel",.5,(0,hs.getNumberValidator)(),as.Factory.afterSetFilter),as.Factory.addGetterSetter(ns.Node,"embossDirection","top-left",null,as.Factory.afterSetFilter),as.Factory.addGetterSetter(ns.Node,"embossBlend",!1,null,as.Factory.afterSetFilter);var ls={};Object.defineProperty(ls,"__esModule",{value:!0}),ls.Enhance=void 0;const ds=w,cs=y,us=b;function gs(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}ls.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]=gs(a[s+0],o,h,f,m),a[s+1]=gs(a[s+1],l,d,y,_),a[s+2]=gs(a[s+2],c,u,x,b)}},ds.Factory.addGetterSetter(cs.Node,"enhance",0,(0,us.getNumberValidator)(),ds.Factory.afterSetFilter);var ps={};Object.defineProperty(ps,"__esModule",{value:!0}),ps.Grayscale=void 0;ps.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 ms={};Object.defineProperty(ms,"__esModule",{value:!0}),ms.HSL=void 0;const fs=w,vs=y,_s=b;fs.Factory.addGetterSetter(vs.Node,"hue",0,(0,_s.getNumberValidator)(),fs.Factory.afterSetFilter),fs.Factory.addGetterSetter(vs.Node,"saturation",0,(0,_s.getNumberValidator)(),fs.Factory.afterSetFilter),fs.Factory.addGetterSetter(vs.Node,"luminance",0,(0,_s.getNumberValidator)(),fs.Factory.afterSetFilter);ms.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 ys={};Object.defineProperty(ys,"__esModule",{value:!0}),ys.HSV=void 0;const ws=w,bs=y,xs=b;ys.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},ws.Factory.addGetterSetter(bs.Node,"hue",0,(0,xs.getNumberValidator)(),ws.Factory.afterSetFilter),ws.Factory.addGetterSetter(bs.Node,"saturation",0,(0,xs.getNumberValidator)(),ws.Factory.afterSetFilter),ws.Factory.addGetterSetter(bs.Node,"value",0,(0,xs.getNumberValidator)(),ws.Factory.afterSetFilter);var Ss={};Object.defineProperty(Ss,"__esModule",{value:!0}),Ss.Invert=void 0;Ss.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 Cs={};Object.defineProperty(Cs,"__esModule",{value:!0}),Cs.Kaleidoscope=void 0;const Ps=w,As=y,ks=_,Es=b;Cs.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=ks.Util.createCanvasElement();m.width=d,m.height=c;var f=m.getContext("2d").getImageData(0,0,d,c);ks.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})}},Ps.Factory.addGetterSetter(As.Node,"kaleidoscopePower",2,(0,Es.getNumberValidator)(),Ps.Factory.afterSetFilter),Ps.Factory.addGetterSetter(As.Node,"kaleidoscopeAngle",0,(0,Es.getNumberValidator)(),Ps.Factory.afterSetFilter);var Ts={};Object.defineProperty(Ts,"__esModule",{value:!0}),Ts.Mask=void 0;const Ms=w,Is=y,Fs=b;function Os(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 Ds(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))}Ts.Mask=function(t){var e=function(t,e){var i=Os(t,0,0),r=Os(t,t.width-1,0),s=Os(t,0,t.height-1),a=Os(t,t.width-1,t.height-1),n=e||10;if(Ds(i,r)<n&&Ds(r,a)<n&&Ds(a,s)<n&&Ds(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=Ds(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},Ms.Factory.addGetterSetter(Is.Node,"threshold",0,(0,Fs.getNumberValidator)(),Ms.Factory.afterSetFilter);var Rs={};Object.defineProperty(Rs,"__esModule",{value:!0}),Rs.Noise=void 0;const Vs=w,Ls=y,zs=b;Rs.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()},Vs.Factory.addGetterSetter(Ls.Node,"noise",.2,(0,zs.getNumberValidator)(),Vs.Factory.afterSetFilter);var Gs={};Object.defineProperty(Gs,"__esModule",{value:!0}),Gs.Pixelate=void 0;const Ns=w,Ws=_,Us=y,Bs=b;Gs.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)Ws.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)}},Ns.Factory.addGetterSetter(Us.Node,"pixelSize",8,(0,Bs.getNumberValidator)(),Ns.Factory.afterSetFilter);var js={};Object.defineProperty(js,"__esModule",{value:!0}),js.Posterize=void 0;const Hs=w,Ks=y,Ys=b;js.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},Hs.Factory.addGetterSetter(Ks.Node,"levels",.5,(0,Ys.getNumberValidator)(),Hs.Factory.afterSetFilter);var Xs={};Object.defineProperty(Xs,"__esModule",{value:!0}),Xs.RGB=void 0;const Js=w,qs=y,Zs=b;Xs.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]},Js.Factory.addGetterSetter(qs.Node,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),Js.Factory.addGetterSetter(qs.Node,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),Js.Factory.addGetterSetter(qs.Node,"blue",0,Zs.RGBComponent,Js.Factory.afterSetFilter);var $s={};Object.defineProperty($s,"__esModule",{value:!0}),$s.RGBA=void 0;const Qs=w,ta=y,ea=b;$s.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},Qs.Factory.addGetterSetter(ta.Node,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),Qs.Factory.addGetterSetter(ta.Node,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),Qs.Factory.addGetterSetter(ta.Node,"blue",0,ea.RGBComponent,Qs.Factory.afterSetFilter),Qs.Factory.addGetterSetter(ta.Node,"alpha",1,(function(t){return this._filterUpToDate=!1,t>1?1:t<0?0:t}));var ia={};Object.defineProperty(ia,"__esModule",{value:!0}),ia.Sepia=void 0;ia.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 ra={};Object.defineProperty(ra,"__esModule",{value:!0}),ra.Solarize=void 0;ra.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 sa={};Object.defineProperty(sa,"__esModule",{value:!0}),sa.Threshold=void 0;const aa=w,na=y,oa=b;sa.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},aa.Factory.addGetterSetter(na.Node,"threshold",.5,(0,oa.getNumberValidator)(),aa.Factory.afterSetFilter),Object.defineProperty(m,"__esModule",{value:!0}),m.Konva=void 0;const ha=f,la=Jt,da=ie,ca=Ce,ua=Me,ga=Ve,pa=Be,ma=re,fa=ce,va=ri,_a=di,ya=fi,wa=Si,ba=Mi,xa=Vi,Sa=rr,Ca=mr,Pa=Vr,Aa=Br,ka=qr,Ea=ts,Ta=ss,Ma=ls,Ia=ps,Fa=ms,Oa=ys,Da=Ss,Ra=Cs,Va=Ts,La=Rs,za=Gs,Ga=js,Na=Xs,Wa=$s,Ua=ia,Ba=ra,ja=sa;m.Konva=ha.Konva.Util._assign(ha.Konva,{Arc:la.Arc,Arrow:da.Arrow,Circle:ca.Circle,Ellipse:ua.Ellipse,Image:ga.Image,Label:pa.Label,Tag:pa.Tag,Line:ma.Line,Path:fa.Path,Rect:va.Rect,RegularPolygon:_a.RegularPolygon,Ring:ya.Ring,Sprite:wa.Sprite,Star:ba.Star,Text:xa.Text,TextPath:Sa.TextPath,Transformer:Ca.Transformer,Wedge:Pa.Wedge,Filters:{Blur:Aa.Blur,Brighten:ka.Brighten,Contrast:Ea.Contrast,Emboss:Ta.Emboss,Enhance:Ma.Enhance,Grayscale:Ia.Grayscale,HSL:Fa.HSL,HSV:Oa.HSV,Invert:Da.Invert,Kaleidoscope:Ra.Kaleidoscope,Mask:Va.Mask,Noise:La.Noise,Pixelate:za.Pixelate,Posterize:Ga.Posterize,RGB:Na.RGB,RGBA:Wa.RGBA,Sepia:Ua.Sepia,Solarize:Ba.Solarize,Threshold:ja.Threshold}});var Ha=p.exports;Object.defineProperty(Ha,"__esModule",{value:!0});const Ka=m;p.exports=Ka.Konva;var Ya=g(p.exports);class Xa{constructor(t,e,i){this.setColor(t,e,i)}asHex(){return"#"+this.HEX}asRGB(){return{r:this.R,g:this.G,b:this.B}}setColor(t,e,i){this.R=t,this.G=e,this.B=i,this.HEX=this.rgbToHex(t,e,i)}rgbToHex(t,e,i){const r=t=>{const e=t.toString(16);return"0"===e?"00":e};return r(t)+r(e)+r(i)}}class Ja{screenToWorld(t){return{x:t.x,y:t.y,z:0}}worldToScreen(t){return{x:t.x,y:t.y}}getScale(){return{x:1,y:1,z:1}}}const qa=new Map([["solid",[]],["dot",[30,30,.001,30]],["dash",[30,30]]]);class Za{constructor(t,e=null){var i,r;if(e)return void(this._ref=e);t||(t={}),t.points||(t.points=[{x:50,y:50},{x:100,y:100}]);const s=[];t.points.forEach((t=>s.push(t.x,t.y))),this._ref=new Ya.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:qa.get(t.type)||[]}),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation)})),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 qa.get("dot"):t="dot";break;case qa.get("dash"):t="dash";break;default:t="solid"}return t}setLineType(t){const e=qa.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 $a{constructor(t,e=null){var i,r,s;this.TEXT_FONT_FAMILY="Calibri",e?this._ref=e:(t||(t={}),t.position||(t.position={x:100,y:100}),t.text||(t.text="default"),this._ref=new Ya.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.width(this._ref.getTextWidth()),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,r=Math.abs(e.scaleY-1)>1e-5;let s=this._ref.width();i&&(s*=e.scaleX);let a=this._ref.height();r&&(a*=e.scaleY);s<50&&(s=50),a<Math.round(this.getFontSize())&&(a=Math.round(this.getFontSize())),i&&this._ref.width(s),r&&this._ref.height(a),this._ref.scale({x:1,y: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"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 Qa{constructor(t,e=null){var i,r,s,a;e?this._ref=e:(t||(t={}),t.position||(t.position={x:100,y:100}),this._ref=new Ya.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.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,r=Math.abs(e.scaleY-1)>1e-5;let s=this._ref.width();i&&(s*=e.scaleX);let a=this._ref.height();r&&(a*=e.scaleY);s<50&&(s=50),a<50&&(a=50),i&&this._ref.width(s),r&&this._ref.height(a),this._ref.scale({x:1,y: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 tn{constructor(t,e=null){var i,r;e?this._ref=e:(t||(t={}),t.position||(t.position={x:100,y:100}),t.radius||(t.radius={x:25,y:25}),this._ref=new Ya.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.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,r=Math.abs(e.scaleY-1)>1e-5;let s=this._ref.radiusX();i&&(s*=e.scaleX);let a=this._ref.radiusY();r&&(a*=e.scaleY);s<25&&(s=25),a<25&&(a=25),t.evt.ctrlKey||t.evt.shiftKey?i?this._ref.radius({x:s,y:s}):this._ref.radius({x:a,y:a}):this._ref.radius({x:s,y:a}),this._ref.scale({x:1,y: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.radiusX(t)}getRadiusY(){return this._ref.radiusY()}setRadiusY(t){this._ref.radiusY(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 en{constructor(t,e=null){var i,r;e?this._ref=e:(t||(t={}),t.start||(t.start={x:50,y:50}),t.end||(t.end={x:100,y:100}),this._ref=new Ya.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.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation)})),this._ref.id(this._ref._id.toString()))}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Arrow"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t),this._ref.fill(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){const t=this._ref.points();return[{x:t[0],y:t[1]},{x:t[2],y:t[3]}]}setPoints(t){2===t.length&&this._ref.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 rn{constructor(t,e=null){var i,r;if(this._ratio=1,this.EPSILON=1e-5,this.BASE64_NOT_FOUND="data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAADsAAAA7AF5KHG9AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAmhJREFUWIXtlr9rVEEQxz+H8RQUJIdeIopYm0vkCg0GBBtbG1NF7Kxt7dR/IGIw/uhTaBNLERURg2kCEUyCYCPi70b0InjGS57FzOZN3r19d+9HJIVfWO52dma/s7Mz8xa2KAaBCWAR+AkECWOmSOIdwC1gtQOpHc+NfQ8wClQ8+1d0vcdH/lQ3bSIRGAZ2pTjAqNovANXIWlXlAXA2zvi2Ln4AjqYgtagYEutENSLvjRoOImFv5iB32Ae8UrLXwFBk3h9ndF0VJnKSO9gTu3yKu5Z1LKnS8YIcABgw5Ks692JZFXcXRJ46Aq6kikCnHNi/mQ50WwVtfaIoBzL3gRk2drSscJ2wrc4VvUoe2wn/41/iBfoVLRnBGnDSY3AAKacy8AmYR+o7K1zCl6wgrgpOAc/MuhvfgMuk+1JGHQgSBcAloKXy78AjYBppJk5/noTulseBMZ23iD/piHFkEdgTQzKk+5wHjmHC3cmBg0BD5xcSTrFXyQPgIWFtDwMvab+2N8DpbhyY1v/3E8gdDgNfVX9SCVZ0/gW4B0wB71S2BpxLcuCM/jaQSHSDEeAX4VMuAG4gTzyHbcAVXXO6GxxwIX+vvxe7JHcYQ07nHqklj96UIW/YhSWzMKcep8VVtf8B1Dw6h4DfhB+sdbgn2R+gnoEc5NR3dZ+3QJ9H74HqXLPCGlJyTfI9y3YCs0owq3OLOpKkLeBI1HhSDT/mdKIPiUCARMTlQx34TMLjtww8IczmO8AJ/N/2JNSQXAiQ671JePePge0+wzJSQq4FFzlaenIvucUAkiQLhC/mLGNZ9xgn5s63BP4CCk0QDtm4BhoAAAAASUVORK5CYII=",this.BASE64_HEADER_START="data:image/",e)return e.src&&e.src.startsWith(this.BASE64_HEADER_START)||(e.src=this.BASE64_NOT_FOUND),e.height()<=this.EPSILON&&e.height(32),e.width()<=this.EPSILON&&e.width(32),this._ref=e,this._canvasImage=e.image(),void(this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width());t||(t={}),t.position||(t.position={x:50,y:50}),t.src&&t.src.startsWith(this.BASE64_HEADER_START)||(t.src=this.BASE64_NOT_FOUND),this._canvasImage=new Image,this._canvasImage.onload=()=>{if(this._ref.image(this._canvasImage),this._ref.height()<=this.EPSILON&&this._ref.height(this._canvasImage.height),this._ref.width()<=this.EPSILON&&this._ref.width(this._canvasImage.width),this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width(),(t.width<=this.EPSILON||t.height<=this.EPSILON)&&(t.maxWidth>=this.EPSILON||t.maxWidth>=this.EPSILON)){const e=t.maxHeight-this._canvasImage.height,i=t.maxWidth-this._canvasImage.width;(e<=this.EPSILON||i<=this.EPSILON)&&(i<=this.EPSILON&&i<e/this._ratio?(this._ref.height(t.maxWidth*this._ratio),this._ref.width(t.maxWidth)):(this._ref.width(t.maxHeight/this._ratio),this._ref.height(t.maxHeight)))}},this._canvasImage.onerror=()=>{this._canvasImage.onerror=function(){},this._canvasImage.src=this.BASE64_NOT_FOUND},this._canvasImage.src=t.src,this._ref=new Ya.Image({x:t.position.x,y:t.position.y,image:this._canvasImage,width:null!==(i=t.width)&&void 0!==i?i:0,height:null!==(r=t.height)&&void 0!==r?r:0,draggable:!0}),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,r=Math.abs(e.scaleY-1)>1e-5;let s=this._ref.width();i&&(s*=e.scaleX);let a=this._ref.height();r&&(a*=e.scaleY),t.evt.ctrlKey||t.evt.shiftKey?i?(this._ref.width(s),this._ref.height(s*this._ratio)):(this._ref.width(a/this._ratio),this._ref.height(a)):(i&&this._ref.width(s),r&&this._ref.height(a)),this._ref.scale({x:1,y:1})})),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 sn{constructor(t,e=null){var i,r,s,a;if(e)return void(this._ref=e);t||(t={}),t.position||(t.position={x:100,y:100});const n=16;this._ref=new Ya.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:4,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;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,r=Math.abs(e.scaleY-1)>1e-5;let s=this._ref.width();i&&(s*=e.scaleX);let a=this._ref.height();r&&(a*=e.scaleY);s<100&&(s=100),a<100&&(a=100),i&&this._ref.width(s),r&&this._ref.height(a),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 an={SelectMarkup:{name:"SelectMarkup",initializer:null},Line:{name:"Line",initializer:(t,e=null)=>new Za(e,t)},Text:{name:"Text",initializer:(t,e=null)=>new $a(e,t)},Rectangle:{name:"Rect",initializer:(t,e=null)=>new Qa(e,t)},Ellipse:{name:"Ellipse",initializer:(t,e=null)=>new tn(e,t)},Arrow:{name:"Arrow",initializer:(t,e=null)=>new en(e,t)},Image:{name:"Image",initializer:(t,e=null)=>new rn(e,t)},Cloud:{name:"Cloud",initializer:(t,e=null)=>new sn(e,t)}};class nn{constructor(){this._containerEvents=[],this._markupIsActive=!1,this._markupColor=new Xa(255,0,0),this.lineWidth=4,this.lineType="solid",this.fontSize=34,this.changeActiveDragger=t=>{const e=t.data;this._markupContainer.className=this._container.className.split(" ").filter((t=>!t.startsWith("oda-cursor-"))).filter((t=>t)).concat(`oda-cursor-${e.toLowerCase()}`).join(" "),this.removeTextInput(),this.removeImageInput(),this.enableEditMode(e)},this.resizeContainer=t=>{const{width:e,height:i}=t[0].contentRect;e&&i&&this._konvaStage&&(this._konvaStage.width(e),this._konvaStage.height(i))},this.pan=t=>{const e=t.dX/window.devicePixelRatio,i=t.dY/window.devicePixelRatio;this.getObjects().forEach((t=>t.ref().move({x:e,y:i})))},this.redirectToViewer=t=>{this._viewer&&this._viewer.emit(t)}}initialize(t,e,i,r){if(!Ya)throw new Error('Markup error: Konva is not initialized. Forgot to add <script src="https://unpkg.com/konva@9/konva.min.js"><\/script> to your page?');this._viewer=i,this._worldTransformer=null!=r?r:new Ja,this._container=t,this._containerEvents=null!=e?e:[],this._markupContainer=document.createElement("div"),this._markupContainer.id="markup-container",this._markupContainer.style.position="absolute",this._markupContainer.style.top="0px",this._markupContainer.style.left="0px",this._markupContainer.style.outline="0px";const s=this._container.parentElement;s.appendChild(this._markupContainer),this._resizeObserver=new ResizeObserver(this.resizeContainer),this._resizeObserver.observe(s),this._markupColor.setColor(255,0,0),this.initializeKonva(),this._viewer&&(this._containerEvents.forEach((t=>this._markupContainer.addEventListener(t,this.redirectToViewer))),this._viewer.addEventListener("changeactivedragger",this.changeActiveDragger),this._viewer.addEventListener("pan",this.pan))}dispose(){var t,e;this._viewer&&(this._viewer.removeEventListener("pan",this.pan),this._viewer.removeEventListener("changeactivedragger",this.changeActiveDragger),this._containerEvents.forEach((t=>this._markupContainer.removeEventListener(t,this.redirectToViewer)))),this.destroyKonva(),null===(t=this._resizeObserver)||void 0===t||t.disconnect(),this._resizeObserver=void 0,null===(e=this._markupContainer)||void 0===e||e.remove(),this._markupContainer=void 0,this._container=void 0,this._viewer=void 0,this._worldTransformer=void 0,this._markupIsActive=!1}syncOverlay(){}clearOverlay(){this.removeTextInput(),this.removeImageInput(),this.clearSelected(),this.getObjects().forEach((t=>t.delete()))}getMarkupColor(){return this._markupColor.asRGB()}setMarkupColor(t,e,i){this._markupColor.setColor(t,e,i)}colorizeAllMarkup(t,e,i){const r=new Xa(t,e,i).asHex();this.getObjects().filter((t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,r)}))}colorizeSelectedMarkups(t,e,i){const r=new Xa(t,e,i).asHex();this.getSelectedObjects().filter((t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,r)}))}setViewpoint(t){var e,i,r,s,a,n,o,h;this.clearSelected(),this.removeTextInput(),this.removeImageInput();const l=(null===(e=t.custom_fields)||void 0===e?void 0:e.markup_color)||{r:255,g:0,b:0};this.setMarkupColor(l.r,l.g,l.b),null===(i=t.lines)||void 0===i||i.forEach((t=>{const e=[];t.points.forEach((t=>{const i=this._worldTransformer.worldToScreen(t);e.push(i.x),e.push(i.y)})),this.addLine(e,t.color,t.type,t.width,t.id)})),null===(r=t.texts)||void 0===r||r.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addText(t.text,e,t.angle,t.color,t.text_size,t.font_size,t.id)})),null===(s=t.rectangles)||void 0===s||s.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addRectangle(e,t.width,t.height,t.line_width,t.color,t.id)})),null===(a=t.ellipses)||void 0===a||a.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addEllipse(e,t.radius,t.line_width,t.color,t.id)})),null===(n=t.arrows)||void 0===n||n.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.start),i=this._worldTransformer.worldToScreen(t.end);this.addArrow(e,i,t.color,t.id)})),null===(o=t.clouds)||void 0===o||o.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addCloud(e,t.width,t.height,t.line_width,t.color,t.id)})),null===(h=t.images)||void 0===h||h.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addImage(e,t.src,t.width,t.height,t.id)}))}getViewpoint(){const t={};return t.lines=this.getMarkupLines(),t.texts=this.getMarkupTexts(),t.arrows=this.getMarkupArrows(),t.clouds=this.getMarkupClouds(),t.ellipses=this.getMarkupEllipses(),t.images=this.getMarkupImages(),t.rectangles=this.getMarkupRectangles(),t.custom_fields={markup_color:this.getMarkupColor()},t.snapshot={data:this.combineMarkupWithDrawing()},t.description=(new Date).toDateString(),t}enableEditMode(t){return t&&an[t]?(this._markupMode=t,this._markupIsActive=!0):(this.clearSelected(),this.removeTextInput(),this.removeImageInput(),this._markupIsActive=!1),this}createObject(t,e){const i=an[t];if(!i||!i.initializer)throw new Error(`Markup CreateObject - unsupported markup type ${t}`);const r=i.initializer(null,e);return this.addObject(r),r}getObjects(){const t=[];return Object.keys(an).forEach((e=>{const i=an[e];this.konvaLayerFind(e).forEach((e=>t.push(i.initializer(e))))})),t}getSelectedObjects(){return this._konvaTransformer?this._konvaTransformer.nodes().map((t=>{const e=t.className,i=Object.values(an).find((t=>t.name===e));return i?i.initializer(t):null})).filter((t=>t)):[]}selectObjects(t){if(!this._konvaTransformer)return;const e=this._konvaTransformer.nodes().concat(t.map((t=>t.ref())));this._konvaTransformer.nodes(e)}clearSelected(){this._konvaTransformer&&this._konvaTransformer.nodes([])}addObject(t){"Image"===t.type()?this._groupImages.add(t.ref()):"Text"===t.type()?this._groupTexts.add(t.ref()):this._groupGeometry.add(t.ref())}konvaLayerFind(t){if(!this._konvaLayer)return[];const e=an[t];return e&&e.initializer?this._konvaLayer.find(e.name).filter((t=>t.parent===this._konvaLayer||t.parent===this._groupImages||t.parent===this._groupGeometry||t.parent===this._groupTexts)):[]}initializeKonva(){const t=new Ya.Stage({container:this._markupContainer,width:this._container.clientWidth,height:this._container.clientHeight});this._konvaStage=t;const e=new Ya.Layer({pixelRation:window.devicePixelRatio});t.add(e),this._groupImages=new Ya.Group,e.add(this._groupImages),this._groupGeometry=new Ya.Group,e.add(this._groupGeometry),this._groupTexts=new Ya.Group,e.add(this._groupTexts),this._konvaLayer=e;const i=new Ya.Transformer({shouldOverdrawWholeArea:!1,keepRatio:!1,flipEnabled:!1});e.add(i),this._konvaTransformer=i;let r,s,a,n=!1;t.on("mousedown touchstart",(e=>{if(!this._markupIsActive||e.target!==t||"Text"===this._markupMode||"Image"===this._markupMode)return;if(e.target===t&&i.nodes().length>0)return void i.nodes([]);const a=t.getPointerPosition();s=a,n=["Arrow","Cloud","Ellipse","Line","Rectangle"].some((t=>t===this._markupMode)),"Line"===this._markupMode&&(r=this.addLine([a.x,a.y,a.x,a.y]))})),t.on("mouseup touchend",(e=>{if(this._markupIsActive){if(n){const e=t.getPointerPosition(),i=s&&e.x===s.x&&e.y===s.y,r=i?s.x:Math.min(s.x,e.x),a=i?s.y:Math.min(s.y,e.y),n=i?200:Math.abs(s.x-e.x),o=i?200:Math.abs(s.y-e.y);i&&("Rectangle"===this._markupMode?this.addRectangle({x:r,y:a},n,o):"Ellipse"===this._markupMode?this.addEllipse({x:r,y:a},{x:n/2,y:o/2}):"Arrow"===this._markupMode?this.addArrow({x:s.x,y:s.y},{x:i?s.x+200:e.x,y:i?a:e.y}):"Cloud"===this._markupMode&&this.addCloud({x:r,y:a},Math.max(100,n),Math.max(100,o)))}a=void 0,n=!1}})),t.on("mousemove touchmove",(e=>{if(!this._markupIsActive)return;if(!n)return;const i=t.getPointerPosition(),o=s&&i.x===s.x&&i.y===s.y,h=o?s.x:Math.min(s.x,i.x),l=o?s.y:Math.min(s.y,i.y),d=o?200:Math.abs(s.x-i.x),c=o?200:Math.abs(s.y-i.y);"Line"===this._markupMode?r.addPoints([{x:i.x,y:i.y}]):"Arrow"===this._markupMode?a?a.setEndPoint(i.x,i.y):a=this.addArrow({x:s.x,y:s.y},{x:i.x,y:i.y}):"Rectangle"===this._markupMode?a?(a.setPosition(h,l),a.setWidth(d),a.setHeight(c)):a=this.addRectangle({x:h,y:l},d,c):"Ellipse"===this._markupMode?a?(a.setPosition(h,l),a.setRadiusX(d),a.setRadiusY(c)):a=this.addEllipse({x:h,y:l},{x:d,y:c}):"Cloud"===this._markupMode&&(a?(a.setPosition(h,l),a.setWidth(Math.max(100,d)),a.setHeight(Math.max(100,c))):a=this.addCloud({x:h,y:l},d,c))})),t.on("click tap",(e=>{if(!this._markupIsActive)return;if(e.target===t){if("Text"===this._markupMode){if(this._textInputRef&&this._textInputRef.value)this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle);else if(0===i.nodes().length){const i=t.getPointerPosition();this.createTextInput(i,e.evt.pageX,e.evt.pageY,0,null)}}else if("Image"===this._markupMode)if(this._imageInputRef&&this._imageInputRef.value)this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},this._imageInputRef.value,0,0,this._imageInputRef.value);else if(0===i.nodes().length){const e=t.getPointerPosition();this.createImageInput(e)}return void i.nodes([])}if("Text"===this._markupMode||"SelectMarkup"===this._markupMode){if("Text"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._textInputRef&&this._textInputRef.value?this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle):this.createTextInput({x:e.target.attrs.x,y:e.target.attrs.y},e.evt.pageX,e.evt.pageY,e.target.attrs.rotation,e.target.attrs.text));this.removeTextInput()}if("Image"===this._markupMode||"SelectMarkup"===this._markupMode){if("Image"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._imageInputRef&&this._imageInputRef.value?this.addImage(this._imageInputPos,this._imageInputRef.value,0,0):this.createImageInput({x:e.target.attrs.x,y:e.target.attrs.y}));this.removeImageInput()}i.nodes().filter((t=>"Cloud"===t.className||"Image"===t.className)).length>0||"Cloud"===e.target.className||"Image"===e.target.className?i.rotateEnabled(!1):i.rotateEnabled(!0);const r=e.evt.shiftKey||e.evt.ctrlKey||e.evt.metaKey,s=i.nodes().indexOf(e.target)>=0;if(r||s){if(r&&s){const t=i.nodes().slice();t.splice(t.indexOf(e.target),1),i.nodes(t)}else if(r&&!s){const t=i.nodes().concat([e.target]);i.nodes(t)}}else i.nodes([e.target])}));const o=t.container();o.tabIndex=1,o.focus(),o.addEventListener("keydown",(t=>{if(this._markupIsActive)return"Delete"===t.code?(this.getSelectedObjects().forEach((t=>t.delete())),void this.clearSelected()):void t.preventDefault()}))}destroyKonva(){var t;this.removeTextInput(),this.removeImageInput(),this.clearOverlay(),null===(t=this._konvaStage)||void 0===t||t.destroy(),this._groupImages=void 0,this._groupGeometry=void 0,this._groupTexts=void 0,this._konvaLayer=void 0,this._konvaTransformer=void 0,this._konvaStage=void 0}getMarkupLines(){const t=[];return this.konvaLayerFind("Line").forEach((e=>{const i=e.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._worldTransformer.screenToWorld(e);r.push(a)}const a=new Za(null,e),n={id:a.id(),points:r,color:a.getColor()||"#ff0000",type:a.getLineType()||this.lineType,width:a.getLineWidth()||this.lineWidth};t.push(n)})),t}getMarkupTexts(){const t=[];return this.konvaLayerFind("Text").forEach((e=>{const i=this._worldTransformer.getScale(),r={x:e.x(),y:e.y()},s=this._worldTransformer.screenToWorld(r),a=new $a(null,e),n={id:a.id(),position:s,text:a.getText(),text_size:.02*i.y,angle:a.getRotation(),color:a.getColor(),font_size:a.getFontSize()};t.push(n)})),t}getMarkupRectangles(){const t=[];return this.konvaLayerFind("Rectangle").forEach((e=>{const i=e.position(),r=this._worldTransformer.screenToWorld(i),s=new Qa(null,e),a={id:s.id(),position:r,width:s.getWidth(),height:s.getHeigth(),line_width:s.getLineWidth(),color:s.getColor()};t.push(a)})),t}getMarkupEllipses(){const t=[];return this.konvaLayerFind("Ellipse").forEach((e=>{const i=e.position(),r=this._worldTransformer.screenToWorld(i),s=new tn(null,e),a={id:s.id(),position:r,radius:{x:e.getRadiusX(),y:e.getRadiusY()},line_width:s.getLineWidth(),color:s.getColor()};t.push(a)})),t}getMarkupArrows(){const t=[];return this.konvaLayerFind("Arrow").forEach((e=>{const i=e.getAbsoluteTransform(),r=i.point({x:e.points()[0],y:e.points()[1]}),s=this._worldTransformer.screenToWorld(r),a=i.point({x:e.points()[2],y:e.points()[3]}),n=this._worldTransformer.screenToWorld(a),o=new en(null,e),h={id:o.id(),start:s,end:n,color:o.getColor()};t.push(h)})),t}getMarkupImages(){const t=[];return this.konvaLayerFind("Image").forEach((e=>{const i=e.position(),r=this._worldTransformer.screenToWorld(i),s=new rn(null,e),a={id:s.id(),position:r,src:s.getSrc(),width:s.getWidth(),height:s.getHeight()};t.push(a)})),t}getMarkupClouds(){const t=[];return this.konvaLayerFind("Cloud").forEach((e=>{const i=e.position(),r=this._worldTransformer.screenToWorld(i),s=new sn(null,e),a={id:s.id(),position:r,width:s.getWidth(),height:s.getHeigth(),line_width:s.getLineWidth(),color:s.getColor()};t.push(a)})),t}combineMarkupWithDrawing(){this.clearSelected();const t=document.createElement("canvas");if(this._konvaStage){t.width=this._konvaStage.width(),t.height=this._konvaStage.height();const e=t.getContext("2d");this._container instanceof HTMLCanvasElement&&e.drawImage(this._container,0,0),e.drawImage(this._konvaStage.toCanvas({pixelRatio:window.devicePixelRatio}),0,0)}return t.toDataURL("image/jpeg",.25)}addLine(t,e,i,r,s){if(!t||0===t.length)return;const a=[];for(let e=0;e<t.length;e+=2)a.push({x:t[e],y:t[e+1]});const n=new Za({points:a,type:i||this.lineType,width:r||this.lineWidth,color:e||this._markupColor.asHex(),id:s});return this.addObject(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.style.fontSize=`${this.fontSize}px`,this._textInputRef.style.color=`${this._markupColor.asHex()}`,this._textInputRef.style.fontFamily="Calibri",this._textInputRef.onkeydown=t=>{"Enter"!==t.key||t.shiftKey||(t.preventDefault(),this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle)),"Escape"===t.key&&(t.preventDefault(),this.removeTextInput())},s&&(this._textInputRef.value=s),document.body.appendChild(this._textInputRef),setTimeout((()=>{this._textInputRef.focus()}),50))}removeTextInput(){var t;null===(t=this._textInputRef)||void 0===t||t.remove(),this._textInputRef=null,this._textInputPos=null,this._textInputAngle=0}createImageInput(t){if(this._imageInputRef)this.removeImageInput();else{const e=t=>new Promise(((e,i)=>{const r=new FileReader;r.readAsDataURL(t),r.onload=()=>{e(r.result)},r.onerror=t=>{i(t)}}));this._imageInputPos=t,this._imageInputRef=document.createElement("input"),this._imageInputRef.style.display="none",this._imageInputRef.type="file",this._imageInputRef.accept="image/png, image/jpeg",this._imageInputRef.onchange=async t=>{const i=t.target.files[0],r=await e(i);this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},r.toString(),0,0)},this._imageInputRef.oncancel=t=>{this.removeImageInput()},document.body.appendChild(this._imageInputRef),setTimeout((()=>{this._imageInputRef.click()}),50)}}removeImageInput(){var t;null===(t=this._imageInputRef)||void 0===t||t.remove(),this._imageInputRef=null,this._imageInputPos=null}addText(t,e,i,r,s,a,n){var o;if(!t)return;null===(o=this.getSelectedObjects().at(0))||void 0===o||o.delete(),this.clearSelected(),this.removeTextInput();const h=1e-6;if(s&&s>h&&(!a||a<h)){const t=.02;a=s/(this._worldTransformer.getScale().y/t)/34}const l=new $a({position:{x:e.x,y:e.y},text:t,rotation:i,fontSize:a||this.fontSize,color:r||this._markupColor.asHex(),id:n});return this.addObject(l),l}addRectangle(t,e,i,r,s,a){if(!t)return;const n=new Qa({position:t,width:e,height:i,lineWidth:r||this.lineWidth,color:s||this._markupColor.asHex(),id:a});return this.addObject(n),n}addEllipse(t,e,i,r,s){if(!t)return;const a=new tn({position:t,radius:e,lineWidth:i,color:r||this._markupColor.asHex(),id:s});return this.addObject(a),a}addArrow(t,e,i,r){if(!t||!e)return;const s=new en({start:t,end:e,color:i||this._markupColor.asHex(),id:r});return this.addObject(s),s}addCloud(t,e,i,r,s,a){if(!t||!e||!i)return;const n=new sn({position:t,width:e,height:i,color:s||this._markupColor.asHex(),lineWidth:r||this.lineWidth,id:a});return this.addObject(n),n}addImage(t,e,i,r,s){var a;if(!t||!e)return;null===(a=this.getSelectedObjects().at(0))||void 0===a||a.delete(),this.clearSelected(),this.removeImageInput();const n=new rn({position:t,src:e,width:i,height:r,maxWidth:this._konvaStage.width()-t.x,maxHeight:this._konvaStage.height()-t.y,id:s});return this.addObject(n),n}}class on{constructor(){this._listeners={}}addEventListener(t,e){return void 0===this._listeners[t]&&(this._listeners[t]=[]),this._listeners[t].push(e),this}removeEventListener(t,e){if(void 0===this._listeners[t])return this;const i=this._listeners[t].filter((t=>t!==e));return 0!==i.length?this._listeners[t]=i:delete this._listeners[t],this}removeAllListeners(t){return t?delete this._listeners[t]:this._listeners={},this}emitEvent(t){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 hn{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 ln extends hn{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=o}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||ln.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(ln.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||ln.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){ln._isGestureActive!==t&&(ln._isGestureActive=t,ln._isGestureActive&&(ln.needSkipPointerUp=!0))}static get isGestureActive(){return ln._isGestureActive}static get needSkipPointerUp(){return!!ln._needSkipPointerUp&&(ln.needSkipPointerUp=!1,!0)}static set needSkipPointerUp(t){ln._needSkipPointerUp=t}}function dn(t,e,i){return t||((t=document.createElement("div")).setAttribute("data-testid",i),e.appendChild(t)),t}function cn(t,e){return t&&e.removeChild(t),null}function un(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 gn(t){return t<0?Math.ceil(t):Math.floor(t)}ln._isGestureActive=!1,ln._needSkipPointerUp=!1;const pn=(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:gn(t.x+l*s),y:gn(t.y+l*a)}};function mn(t,e,i,r,s){const a=pn(t,e,i,r);a&&s.push(a)}function fn(t,e,i){return t.x<=e&&t.x>=0&&t.y<=i&&t.y>=0}function vn(t,e){t&&(t.onclick=e?()=>e():()=>{})}function _n(t,e){t.style.pointerEvents=e?"auto":"none"}class yn{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=dn(this.htmlElemStartPoint,t,"ruler-start"),this.htmlElemEndPoint=dn(this.htmlElemEndPoint,t,"ruler-end"),this.htmlElemLine=dn(this.htmlElemLine,t,"ruler-line"),this.htmlElemTitle=dn(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=dn(this.htmlElemStartPoint,this.targetElement,"ruler-start");const i=un(this.startPoint,this.moduleInstance,this.viewer);fn(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=dn(this.htmlElemEndPoint,this.targetElement,"ruler-end");const i=un(this.endPoint,this.moduleInstance,this.viewer);fn(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=un(this.startPoint,this.moduleInstance,this.viewer),i=un(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=[];mn(t,e,s,a,h),mn(t,e,s,n,h),mn(t,e,n,o,h),mn(t,e,o,a,h);let l=null,d=null;0===h.length?(l=t,d=e):1===h.length?fn(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(fn(r,e.width,e.height)&&fn(s,e.width,e.height)){this.htmlElemLine=dn(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=dn(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=cn(this.htmlElemStartPoint,this.targetElement),this.htmlElemEndPoint=cn(this.htmlElemEndPoint,this.targetElement),this.htmlElemLine=cn(this.htmlElemLine,this.targetElement),this.htmlElemTitle=cn(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){vn(this.htmlElemStartPoint,t?t.onStartPoint:null),vn(this.htmlElemEndPoint,t?t.onEndPoint:null),vn(this.htmlElemTitle,t?t.onTitle:null)}setSelectability(t){_n(this.htmlElemStartPoint,t),_n(this.htmlElemEndPoint,t),_n(this.htmlElemLine,t),_n(this.htmlElemTitle,t)}}class wn extends ln{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}start(t,e){this.createNewMeasureIfNeed();const i=this.getViewer().getSnapPoint(t,e,this.gripingRadius);i&&(this.firstPoint=i,this.previewMeasureLine.setStartPoint(this.firstPoint))}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 yn(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 bn extends ln{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 xn extends ln{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 Sn extends xn{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 Cn extends xn{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 Pn extends xn{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 An{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 kn extends ln{constructor(t){super(t),this.autoSelect=!0,this.press=!1,this._orbitAction=new An(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 En{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 Tn extends ln{constructor(t){super(t),this.autoSelect=!0,this.press=!1,this._panAction=new En(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 Mn{constructor(t,e){this._m_module=t,this._subject=e}action(t,e,i){var r;this._m_module.getViewer().zoomAt(i,t,e),this._subject.deviceAutoRegeneration(),null===(r=this._subject.activeDragger())||void 0===r||r.updatePreview(),this._subject.emitEvent({type:"zoomat",data:i})}}class In extends ln{constructor(t){super(t),this.autoSelect=!0,this.press=!1,this._zoomAction=new Mn(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&&Math.abs(r)<=1e-5){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 Fn extends ln{constructor(t){super(t),this.canvasEvents=["wheel"],this._zoomAction=new Mn(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 On{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 Dn extends ln{constructor(t){super(t),this.autoSelect=!0,this.press=!1,this.needInputText=!1,this.m_frame=new On,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 Rn extends ln{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 Vn;!function(t){t[t.None=0]="None",t[t.Orbit=1]="Orbit",t[t.Pan=2]="Pan",t[t.Zoom=3]="Zoom"}(Vn||(Vn={}));class Ln extends ln{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=Vn.None,this._maxInitialDistanceDifference=30*window.devicePixelRatio,this._isSingleTouchEnabled=!1,this._orbitAction=new An(this.m_module,this.subject,this.beginInteractivity,this.endInteractivity),this._panAction=new En(this.m_module,this.subject,this.beginInteractivity,this.endInteractivity,this.getViewParams,this.setViewParams),this._zoomAction=new Mn(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!==Vn.Zoom&&(this.executeEndAction(this._lastGestureAction),this._lastGestureAction=Vn.Zoom,ln.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!==Vn.Pan&&(this.executeEndAction(this._lastGestureAction),this._lastGestureAction=Vn.Pan,ln.isGestureActive=!0,this._panAction.beginAction(t.x,t.y)),this._panAction.action(t.x,t.y),this.subject.update()}executeOrbitAction(t){this._lastGestureAction!==Vn.Orbit&&(this.executeEndAction(this._lastGestureAction),this._lastGestureAction=Vn.Orbit,ln.isGestureActive=!0,this._orbitAction.beginAction(t.x,t.y)),this._orbitAction.action(t.x,t.y),this.subject.update()}executeEndAction(t){t===Vn.Orbit&&this._orbitAction.endAction(),t===Vn.Pan&&this._panAction.endAction(),ln.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),ln.isGestureActive=!1),this._lastGestureAction=Vn.None)}pointercancel(t){this.needIgnoreEvent(t)||this.pointerup(t)}pointerleave(t){this.needIgnoreEvent(t)||this.pointerup(t)}}function zn(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 Gn{constructor(t,e,i){this.viewer=t,this.model=e,this.options=i}async load(){}}class Nn extends Gn{async load(){if(!this.viewer.visualizeJs)return;const t=this.viewer.visLib().getViewer(),e=new AbortController,i=[this.model.database,...this.model.geometry];this.viewer._abortController=e,console.time("File load time");try{this.viewer.emitEvent({type:"geometrystart",model:this.model});for(let r=0;r<i.length;r++){const s=i[r],a=t=>{const e=(r+t)/i.length;this.viewer.emitEvent({type:"geometryprogress",data:e,model:this.model})},n=await this.model.downloadResource(s,a,e.signal);e.signal.aborted&&await Promise.reject(new Error(`Open model aborted ${this.model.name}`)),t.parseStream(new Uint8Array(n)),this.viewer.update();const o=new Uint8Array(n);0===r?(this.viewer.update(!0),this.viewer.syncOpenCloudVisualStyle(!1),this.viewer.syncOptions(),this.viewer.resize(),this.viewer.emitEvent({type:"databasechunk",data:o,model:this.model})):this.viewer.emitEvent({type:"geometrychunk",data:o,model:this.model})}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 Wn extends Gn{async load(){if(!this.viewer.visualizeJs)return;const t=this.viewer.visLib().getViewer(),e=new AbortController;this.viewer._abortController=e;const i=t=>{this.viewer.emitEvent({type:"geometryprogress",data:t,model:this.model})};console.time("File load time");try{this.viewer.emitEvent({type:"geometrystart",model:this.model});const 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}`));const s=new Uint8Array(r);this.viewer.visualizeJs&&(t.parseVsfx(s),this.viewer.syncOpenCloudVisualStyle(!1),this.viewer.syncOptions(),this.viewer.resize()),console.timeEnd("File load time"),this.viewer.emitEvent({type:"databasechunk",data:s,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 Un;!function(t){t[t.kDelay=0]="kDelay",t[t.kNormal=1]="kNormal",t[t.kForce=2]="kForce"}(Un||(Un={}));class Bn{constructor(){this.lastUpdate=0,this.delayUpdateTime=1e3}initialize(t){this.viewer=t,this.lastUpdate=performance.now()}update(t){const e=t!==Un.kDelay||performance.now()-this.lastUpdate>=this.delayUpdateTime,i=t===Un.kForce;e&&(this.viewer.update(i),this.lastUpdate=performance.now(),this.delayUpdateTime*=2)}}class jn extends Gn{async load(){if(!this.viewer.visualizeJs)return;const t=this.viewer.visLib(),e=t.getViewer(),i=new AbortController,r=new Bn;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(Un.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(Un.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.downloadResource(this.model.database,a,i.signal),console.timeEnd("File load time"),r.update(Un.kNormal),this.viewer.emitEvent({type:"geometryend",model:this.model})}catch(t){throw this.viewer.emitEvent({type:"geometryerror",data:t,model:this.model}),t}}}class Hn extends Gn{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 Bn;h.initialize(this.viewer),this.viewer._abortController=e,this.viewer._abortControllerForRequestMap=i,t.memoryLimit=this.options.memoryLimit;const l=(e,i,r=0)=>{if(!this.viewer.visualizeJs)return;const s=t.parseVsfxInPartialMode(r,i);h.update(Un.kDelay),this.viewer.emitEvent({type:"geometryprogress",data:e,model:this.model}),s?(h.update(Un.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)=>{const a=new AbortController;i.set(r,a);try{await this.model.downloadResourceRange(e,r,s,l,a.signal)}catch(t){this.viewer.emitEvent({type:"geometryerror",data:t,model:this.model})}finally{s.forEach((e=>t.onRequestResponseComplete(e.requestId))),i.delete(r),h.update(Un.kNormal)}},c=(t,e)=>{const i=[];for(let r=0;r<e.size();r++){const s=e.get(r);i.push({requestId:t,begin:Number(s.begin),end:Number(s.end)}),s.delete()}return i},u={onServicePartReceived:t=>{t&&(r=!0,e.abort())},onRequest:(t,e)=>{const i=c(t,e);d(this.model.database,t,i)},onFullLoaded:()=>{h.update(Un.kNormal)},onRequestResponseParsed:t=>{i.delete(t),h.update(Un.kNormal)},onRequestAborted:t=>{const e=i.get(t);e&&e.abort()},onRequestResourceFile:(t,e,i)=>{const r=`${this.model.fileId}${this.model.file.type}`,h=c(t,i);let l=[],u=0;const g=s.get(r);return g&&(l=g.ranges,u=g.number),u<=5?(s.set(r,{ranges:[],number:u+1}),void d(r,t,h)):(l=l.concat(h),l.length>=50?(a&&(window.clearTimeout(a),a=0),s.set(r,{ranges:[],number:u+1}),void d(r,t,l)):(s.set(r,{ranges:l,number:u+1}),void(0===a&&(a=window.setTimeout((()=>{o.signal.removeEventListener("abort",n),a=0,s.forEach(((e,i)=>{e.ranges.length>0&&(s.set(i,{ranges:[],number:e.number+1}),d(i,t,e.ranges))}))}),250),o.signal.addEventListener("abort",n,{once:!0})))))}};t.attachPartialResolver(u);try{this.viewer.emitEvent({type:"geometrystart",model:this.model}),await this.model.downloadResource(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 Kn{create(t,e,i){const r=e.database.split(".").pop();if(0===e.geometry.length&&"vsfx"===r)return i.enableStreamingMode?i.enablePartialMode?new Hn(t,e,i):new jn(t,e,i):new Wn(t,e,i);if("data"===r)return new Nn(t,e,i);throw new Error(`Unknown geometry type: ${r}`)}}const Yn="$MarkupTempEntity_Line";class Xn extends ln{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(Yn);const t=this.entity.openObject();t.appendPolyline(this.drawPoints).delete(),t.delete()}}const Jn="$MarkupTempEntity_Text";class qn extends ln{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 Zn{constructor(){this._markupColor={r:255,g:0,b:0},this.lineWidth=4,this.fontSize=34}initialize(t,e,i,r){this._viewer=i,this._viewer.registerDragger("Line",Xn),this._viewer.registerDragger("Text",qn)}dispose(){}syncOverlay(){}clearOverlay(){if(!this._viewer.visualizeJs)return;const t=this._viewer.visViewer().getMarkupModel();t.clearEntities(),t.delete()}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!==Yn&&a!==Jn||s.setColor(t,e,i),s.delete()}r.delete(),this._viewer.update()}colorizeSelectedMarkups(t=255,e=0,i=0){throw new Error("Not implemented yet")}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(Yn).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===Yn){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}enableEditMode(t){return this}createObject(t,e){}getObjects(){return[]}getSelectedObjects(){return[]}selectObjects(t){}clearSelected(){}}class $n{static createMarkup(t="Konva"){let e;switch(t){case"Konva":e=new nn;break;case"Visualize":e=new Zn;break;default:throw new Error("Error during Markup initialization. Unknown Markup type.")}return e}}const Qn="$OVERLAY_VIEW_NAME",to=t=>null!=t;t.CANVAS_EVENTS=o,t.CanvasEvents=n,t.Dragger=class{constructor(t){this.name=""}initialize(){}dispose(){}updatePreview(){}},t.Markup=nn,t.OdBaseDragger=ln,t.Options=a,t.Viewer=class extends on{constructor(t,e={}){var i;super(),this._visualizeJsUrl="",this.frameId=0,this.configure(e),this._options=new a(this),this.client=t,this._activeDragger=null,this._zoomWheelDragger=null,this._gestureManager=null,this._renderTime=0,this.draggerFactory=new Map,this.registerDragger("Pan",Tn),this.registerDragger("Orbit",kn),this.registerDragger("Zoom",In),this.registerDragger("ZoomWindow",Dn),this.registerDragger("OrbitAroundBuilding",Rn),this.registerDragger("MeasureLine",wn),this.registerDragger("CuttingPlaneXAxis",Sn),this.registerDragger("CuttingPlaneYAxis",Cn),this.registerDragger("CuttingPlaneZAxis",Pn),this.registerDragger("Walk",bn),this.canvasEvents=o.slice(),this.canvaseventlistener=t=>this.emit(t),this._enableAutoUpdate=null===(i=e.enableAutoUpdate)||void 0===i||i,this._isNeedRender=!1,this._isRunAsyncUpdate=!1,this.render=this.render.bind(this),this.resize=this.resize.bind(this),this._markup=$n.createMarkup(e.markupType)}get options(){return this._options}get visualizeJsUrl(){return this._visualizeJsUrl}get markup(){return this._markup}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,this._visualizeTimestamp=Date.now();const i=this._visualizeTimestamp,r=await(s=this.visualizeJsUrl,a=t=>{const{loaded:i,total:r}=t;e&&e(new ProgressEvent("progress",{lengthComputable:!0,loaded:i,total:r})),this.emitEvent({type:"initializeprogress",data:i/r,loaded:i,total:r})},zn(s).then((t=>new Promise(((e,i)=>{const r=window.getVisualizeLibInst({urlMemFile:s+".wasm",TOTAL_MEMORY:134217728,onprogress:a});r.loadWasmError=i,r.postRun.push((()=>{window.getVisualizeLibInst.script=t,e(r)}))})))));var s,a;if(i!==this._visualizeTimestamp)throw new Error("Viewer error: dispose() was called before initialize() completed. Are you using React strict mode?");return this._visualizeJs=r,this.visualizeJs.canvas=t,this.visualizeJs.Viewer.create(),this.canvas=t,this.canvasEvents.forEach((e=>t.addEventListener(e,this.canvaseventlistener))),this._markup.initialize(this.canvas,this.canvasEvents,this,this),this._resizeObserver=new ResizeObserver(this.resize),this._resizeObserver.observe(t.parentElement),this.resize(),this._zoomWheelDragger=new Fn(this),this._zoomWheelDragger.name="ZoomWheel",this._zoomWheelDragger.initialize(),this._gestureManager=new Ln(this),this._gestureManager.initialize(),this.syncOpenCloudVisualStyle(!0),this.syncOptions(),this._renderTime=performance.now(),this.render(this._renderTime),this.emitEvent({type:"initialize"}),this}dispose(){return this.cancel(),this.emitEvent({type:"dispose"}),this.frameId&&cancelAnimationFrame(this.frameId),this.frameId=0,this.setActiveDragger(""),this.removeAllListeners(),this._gestureManager&&this._gestureManager.dispose(),this._gestureManager=void 0,this._zoomWheelDragger&&this._zoomWheelDragger.dispose(),this._zoomWheelDragger=void 0,this._resizeObserver&&this._resizeObserver.disconnect(),this._resizeObserver=void 0,this._markup.dispose(),this.canvas&&(this.canvasEvents.forEach((t=>this.canvas.removeEventListener(t,this.canvaseventlistener))),this.canvas=void 0),this._visualizeJs&&this._visualizeJs.getViewer().clear(),this._visualizeJs=void 0,this._visualizeTimestamp=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;if(!t||!e)return this;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=!1){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{this._enableAutoUpdate&&(null===(r=this.visViewer())||void 0===r||r.update(t),null===(s=this.activeDragger())||void 0===s||s.updatePreview()),this.emitEvent({type:"update",data:!1}),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}}get visualizeJs(){return this._visualizeJs}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(t){a=i.createVisualStyle("OpenCloud");const r=new e.OdTvColorDef(66,66,66),s=i.findVisualStyle("Realistic"),n=a.openObject();n.copyFrom(s),n.setOptionInt32(e.VisualStyleOptions.kFaceModifiers,0,e.VisualStyleOperations.kSet),n.setOptionInt32(e.VisualStyleOptions.kEdgeModel,2,e.VisualStyleOperations.kSet),n.setOptionDouble(e.VisualStyleOptions.kEdgeCreaseAngle,60,e.VisualStyleOperations.kSet),n.setOptionInt32(e.VisualStyleOptions.kEdgeStyles,0,e.VisualStyleOperations.kSet),n.setOptionInt32(e.VisualStyleOptions.kEdgeModifiers,8,e.VisualStyleOperations.kSet),n.setOptionColor(e.VisualStyleOptions.kEdgeColorValue,r,e.VisualStyleOperations.kSet),n.delete()}return s.visualStyle=a,s.delete(),r.delete(),this}syncOptions(t=this.options){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(to(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){if(!this.visualizeJs)return this;const e=t.enableCustomHighlight?t:a.defaults(),i=this.visLib(),r=i.getViewer(),{Entry:s,OdTvRGBColorDef:n}=i,o=r.findHighlightStyle("Web_Default").openObject();if(to(e.facesColor)){const t=new n(e.facesColor.r,e.facesColor.g,e.facesColor.b);o.setFacesColor(s.k3D.value|s.k3DTop.value,t),t.delete()}if(to(e.facesOverlap)&&o.setFacesVisibility(s.k3DTop.value,e.facesOverlap),to(e.facesTransparancy)&&o.setFacesTransparency(s.k3D.value|s.k3DTop.value,e.facesTransparancy),to(e.edgesColor)){const t=new n(e.edgesColor.r,e.edgesColor.g,e.edgesColor.b);o.setEdgesColor(s.k3DTop.value|s.k3D.value|s.k2D.value|s.k2DTop.value,t),t.delete()}if(to(e.edgesVisibility)&&o.setEdgesVisibility(s.k2D.value|s.k2DTop.value|s.k3DTop.value|s.k3D.value,e.edgesVisibility),to(e.edgesOverlap)){const t=!to(e.edgesVisibility)||e.edgesVisibility;o.setEdgesVisibility(s.k2DTop.value|s.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){if(this._activeDragger&&(this._activeDragger.dispose(),this._activeDragger=null),this.visualizeJs){const e=this.draggerFactory.get(t);e&&(this._activeDragger=new e(this),this._activeDragger.name=t,this._activeDragger.initialize())}const e=this.canvas;e&&(e.className=e.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.visualizeJs&&(this._markup.clearOverlay(),this.update())}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();i.setViewport(r.lowerLeft,r.upperRight),i.vportRect=e.vportRect,this._markup.syncOverlay(),this.update()}is3D(){if(!this.visualizeJs)return!1;const t=this.visViewer().getActiveExtents(),e=t.min();return 0!==t.max()[2]-e[2]}screenToWorld(t){if(!this.visualizeJs)return{x:t.x,y:t.y,z:0};const e=this.visViewer().activeView,i=e.transformScreenToWorld(t.x*window.devicePixelRatio,t.y*window.devicePixelRatio),r={x:i[0],y:i[1],z:i[2]};return e.delete(),r}worldToScreen(t){if(!this.visualizeJs)return{x:t.x,y:t.y};const e=this.visViewer().activeView,i=e.transformWorldToScreen(t.x,t.y,t.z),r={x:i[0]/window.devicePixelRatio,y:i[1]/window.devicePixelRatio};return e.delete(),r}getScale(){const t={x:1,y:1,z:1},e=this.visViewer().activeView.projectionMatrix,i=1e-6,r=e.get(0,0);(r>i||r<-1e-6)&&(t.x=1/r);const s=e.get(1,1);(s>i||s<-1e-6)&&(t.y=1/s);const a=e.get(2,2);return(a>i||a<-1e-6)&&(t.z=1/a),t}getSelected(){return this.executeCommand("getSelected")}setSelected(t){this.executeCommand("setSelected",t)}async loadReferences(t){var e;if(!this.visualizeJs)return this;if(!this.client)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();to(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 a;i.data=this._options.data,".rcs"!==t.type||i.enablePartialMode||(console.log("Partial load mode is forced for RCS file"),i.enablePartialMode=!0);const r=(new Kn).create(this,e,i);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)}colorizeSelectedMarkups(t=255,e=0,i=0){this._markup.colorizeSelectedMarkups(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)}deviceAutoRegeneration(){const t=this.visViewer();t.getActiveDevice().getOptionDouble(this.visLib().DeviceOptions.kRegenCoef)>1&&(t.regenAll(),this.update())}},t.commands=r,t.defaultOptions=s,Object.defineProperty(t,"__esModule",{value:!0})}));
|