@linkurious/ogma-annotations 1.1.10 → 1.1.12

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,6 +1,6 @@
1
- import Ogma from '@linkurious/ogma';
2
- import EventEmitter from 'eventemitter3';
3
- import { Annotation, AnnotationCollection, Arrow, ControllerOptions, FeatureEvents, Id, Text } from './types';
1
+ import Ogma from "@linkurious/ogma";
2
+ import EventEmitter from "eventemitter3";
3
+ import { Annotation, AnnotationCollection, Arrow, ControllerOptions, FeatureEvents, Id, Text } from "./types";
4
4
  export declare class Control extends EventEmitter<FeatureEvents> {
5
5
  private arrows;
6
6
  private texts;
@@ -58,9 +58,9 @@ export declare class Control extends EventEmitter<FeatureEvents> {
58
58
  */
59
59
  add(annotation: Arrow | Text | AnnotationCollection): this;
60
60
  /**
61
- * Remove an annotation or an array of annotations from the controller
62
- * @param annotation The annotation(s) to remove
63
- */
61
+ * Remove an annotation or an array of annotations from the controller
62
+ * @param annotation The annotation(s) to remove
63
+ */
64
64
  remove(annotation: Arrow | Text | AnnotationCollection): this;
65
65
  private loadLink;
66
66
  /**
@@ -92,7 +92,7 @@ export declare class Control extends EventEmitter<FeatureEvents> {
92
92
  * @param id The id of the annotation to update
93
93
  * @param style The new style
94
94
  */
95
- updateStyle<A extends Annotation>(id: Id, style: A['properties']['style']): this;
95
+ updateStyle<A extends Annotation>(id: Id, style: A["properties"]["style"]): this;
96
96
  /**
97
97
  *
98
98
  * @returns the annotations in the controller
@@ -1,7 +1,7 @@
1
- import Ogma, { Point } from '@linkurious/ogma';
2
- import { createArrow, defaultOptions, defaultStyle } from './defaults';
3
- import { Arrow, ControllerOptions } from '../../types';
4
- import Editor from '../base';
1
+ import Ogma, { Point } from "@linkurious/ogma";
2
+ import { createArrow, defaultOptions, defaultStyle } from "./defaults";
3
+ import { Arrow, ControllerOptions } from "../../types";
4
+ import Editor from "../base";
5
5
  /**
6
6
  * @class Arrows
7
7
  * Draw and edit arrows
@@ -16,7 +16,7 @@ export declare class Arrows extends Editor<Arrow> {
16
16
  private minArrowHeight;
17
17
  private maxArrowHeight;
18
18
  private handles;
19
- constructor(ogma: Ogma, options?: Pick<Partial<ControllerOptions>, 'arrowHandleSize' | 'maxArrowHeight' | 'minArrowHeight'>);
19
+ constructor(ogma: Ogma, options?: Pick<Partial<ControllerOptions>, "arrowHandleSize" | "maxArrowHeight" | "minArrowHeight">);
20
20
  private onHandleMouseDown;
21
21
  /**
22
22
  * Start drawing a new arrow, it will also be added as a new annotation
@@ -36,4 +36,4 @@ export declare class Arrows extends Editor<Arrow> {
36
36
  refreshDrawing(): void;
37
37
  destroy(): void;
38
38
  }
39
- export { defaultOptions as defaultArrowOptions, defaultStyle as defaultArrowStyle, createArrow };
39
+ export { defaultOptions as defaultArrowOptions, defaultStyle as defaultArrowStyle, createArrow, };
@@ -1,7 +1,7 @@
1
- import Ogma, { Point } from '@linkurious/ogma';
2
- import { createText, defaultControllerOptions, defaultOptions, defaultStyle } from './defaults';
3
- import { ControllerOptions, Id, Text } from '../../types';
4
- import Editor from '../base';
1
+ import Ogma, { Point } from "@linkurious/ogma";
2
+ import { createText, defaultControllerOptions, defaultOptions, defaultStyle } from "./defaults";
3
+ import { ControllerOptions, Id, Text } from "../../types";
4
+ import Editor from "../base";
5
5
  /**
6
6
  * @class Texts
7
7
  * Draw, update, edit texts
@@ -17,7 +17,7 @@ export declare class Texts extends Editor<Text> {
17
17
  private draggedHandle;
18
18
  private isFocused;
19
19
  private placeholder;
20
- constructor(ogma: Ogma, options?: Pick<Partial<ControllerOptions>, 'textHandleSize' | 'textPlaceholder'>);
20
+ constructor(ogma: Ogma, options?: Pick<Partial<ControllerOptions>, "textHandleSize" | "textPlaceholder">);
21
21
  private _onFocus;
22
22
  private _onBlur;
23
23
  protected _canRemove(): boolean;
@@ -39,4 +39,4 @@ export declare class Texts extends Editor<Text> {
39
39
  select(id: Id): void;
40
40
  destroy(): void;
41
41
  }
42
- export { defaultOptions as defaultTextOptions, defaultStyle as defaultTextStyle, defaultControllerOptions, createText };
42
+ export { defaultOptions as defaultTextOptions, defaultStyle as defaultTextStyle, defaultControllerOptions, createText, };
@@ -1,6 +1,6 @@
1
- import Ogma, { Options, Overlay, Point, SVGLayer } from '@linkurious/ogma';
2
- import eventEmmitter from 'eventemitter3';
3
- import { Annotation, Events, Id } from '../types';
1
+ import Ogma, { Options, Overlay, Point, SVGLayer } from "@linkurious/ogma";
2
+ import eventEmmitter from "eventemitter3";
3
+ import { Annotation, Events, Id } from "../types";
4
4
  /**
5
5
  * @class Annotations
6
6
  * Abstract class to display Texts and Arrows, provide add/remove/update and mouse events
@@ -28,8 +28,8 @@ export default abstract class Editor<T extends Annotation> extends eventEmmitter
28
28
  * @returns the added annotation
29
29
  */
30
30
  add(options: T): T;
31
- updateStyle(annotation: T, style: Partial<T['properties']['style']>): void;
32
- updateGeometry(annotation: T, geometry: Partial<T['geometry']>): void;
31
+ updateStyle(annotation: T, style: Partial<T["properties"]["style"]>): void;
32
+ updateGeometry(annotation: T, geometry: Partial<T["geometry"]>): void;
33
33
  /**
34
34
  * @method update
35
35
  * Updates an annotation (position, color etc)
@@ -1,6 +1,7 @@
1
- import './style.css';
2
- export * from './Editor/Arrows';
3
- export * from './Editor/Texts';
4
- export * from './Control';
5
- export * from './utils';
6
- export * from './types';
1
+ import "./style.css";
2
+ export * from "./Editor/Arrows";
3
+ export * from "./Editor/Texts";
4
+ export * from "./Control";
5
+ export * from "./utils";
6
+ export * from "./types";
7
+ export * from "./constants";
@@ -1,6 +1,6 @@
1
- import { Point } from '@linkurious/ogma';
2
- import type { BBox } from 'geojson';
3
- import { AnnotationCollection, Arrow, Text } from './types';
1
+ import { Point } from "@linkurious/ogma";
2
+ import type { BBox } from "geojson";
3
+ import { AnnotationCollection, Arrow, Text } from "./types";
4
4
  export declare function createSVGElement<T extends SVGElement>(tag: string): T;
5
5
  export declare function getTextBbox(t: Text): BBox;
6
6
  export declare function getTextSize(t: Text): {
@@ -17,7 +17,7 @@ export declare function getArrowStart(a: Arrow): {
17
17
  x: number;
18
18
  y: number;
19
19
  };
20
- export declare function getArrowSide(a: Arrow, side: 'start' | 'end'): {
20
+ export declare function getArrowSide(a: Arrow, side: "start" | "end"): {
21
21
  x: number;
22
22
  y: number;
23
23
  };
@@ -37,7 +37,7 @@ export declare function getArrowEndPoints(a: Arrow): {
37
37
  y: number;
38
38
  };
39
39
  };
40
- export declare function setArrowEndPoint(a: Arrow, side: 'start' | 'end', x: number, y: number): void;
40
+ export declare function setArrowEndPoint(a: Arrow, side: "start" | "end", x: number, y: number): void;
41
41
  export declare const getHandleId: (handle: HTMLDivElement) => number;
42
42
  type Bounds = [number, number, number, number];
43
43
  export declare function getAnnotationsBounds(annotations: AnnotationCollection): Bounds;
@@ -45,4 +45,11 @@ export declare function getAttachmentPointOnNode(start: Point, nodeCenter: Point
45
45
  x: number;
46
46
  y: number;
47
47
  };
48
+ export declare function clientToContainerPosition(evt: {
49
+ clientX: number;
50
+ clientY: number;
51
+ }, container?: HTMLElement | null): {
52
+ x: number;
53
+ y: number;
54
+ };
48
55
  export {};
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@linkurious/ogma-annotations",
3
- "version": "1.1.10",
3
+ "version": "1.1.12",
4
4
  "description": "Headless annotation plugin for Ogma",
5
5
  "main": "dist/index.mjs",
6
6
  "module": "dist/index.mjs",
7
- "browser": "dist/index.umd.js",
7
+ "browser": "dist/index.js",
8
8
  "types": "dist/types/index.d.ts",
9
9
  "files": [
10
10
  "dist/*.mjs",
@@ -15,7 +15,7 @@
15
15
  "exports": {
16
16
  ".": {
17
17
  "import": "./dist/index.mjs",
18
- "require": "./dist/index.umd.js",
18
+ "require": "./dist/index.js",
19
19
  "default": "./dist/index.mjs",
20
20
  "types": "./dist/types/index.d.ts"
21
21
  },
@@ -23,7 +23,7 @@
23
23
  "import": "./dist/style.css",
24
24
  "require": "./dist/style.css"
25
25
  },
26
- "./umd": "./dist/index.umd.js",
26
+ "./umd": "./dist/index.js",
27
27
  "./esm": "./dist/index.mjs"
28
28
  },
29
29
  "scripts": {
package/dist/index.umd.js DELETED
@@ -1,24 +0,0 @@
1
- (function(_,it){typeof exports=="object"&&typeof module<"u"?it(exports):typeof define=="function"&&define.amd?define(["exports"],it):(_=typeof globalThis<"u"?globalThis:_||self,it(_["@linkurious/ogma-annotations"]={}))})(this,function(_){"use strict";var Wn=Object.defineProperty;var Zn=(_,it,ut)=>it in _?Wn(_,it,{enumerable:!0,configurable:!0,writable:!0,value:ut}):_[it]=ut;var v=(_,it,ut)=>(Zn(_,typeof it!="symbol"?it+"":it,ut),ut);var it=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ut(u){return u&&u.__esModule&&Object.prototype.hasOwnProperty.call(u,"default")?u.default:u}var Ae={exports:{}};(function(u){(function(l,t){u.exports=t()})("Vector",function(){var l=function(){var t=Math.PI*2,r=180/Math.PI,a=Math.PI/180;function h(s){return Math.round(s*1e8)/1e8}function f(s,d){var m=d.x-s.x,S=d.y-s.y;return Math.sqrt(m*m+S*S)}function g(s,d,m){var S=d.y-s.y,T=d.x-s.x,b=Math.atan2(S,T);if(m)for(;b<0;)b+=t;return b}function p(s,d){this.x=s!==void 0?s:0,this.y=d!==void 0?d:0}return p.fromRadians=function(s){var d=Math.cos(s),m=Math.sin(s);return new p(d,m)},p.fromDegrees=function(s){var d=s*(Math.PI/180);return p.fromRadians(d)},p.fromString=function(s){var d=s.split(",");return new p(parseFloat(d[0]),parseFloat(d[1]))},p.fromArray=function(s){return new p(s[0],s[1])},p.prototype={version:"2.0.1",clone:function(){return new p(this.x,this.y)},equals:function(s){return this.prototype===s.prototype&&this.x===s.x&&this.y===s.y},copy:function(s){return this.x=s.x,this.y=s.y,this},copyX:function(s){return this.x=s.x,this},copyY:function(s){return this.y=s.y,this},toDict:function(){return{x:this.x,y:this.y}},toArray:function(){return[this.x,this.y]},set:function(s,d){return s!==void 0&&(this.x=s),d!==void 0&&(this.y=d),this},flipXY:function(){return new p(this.y,this.x)},flipXYSelf:function(){return this.y=[this.x,this.x=this.y][0],this},invert:function(){return this.mulScalar(-1)},invertSelf:function(){return this.mulScalarSelf(-1),this},distanceFrom:function(s){return f(this,s)},radiansTo:function(s){return g(this,s,!0)},degreesTo:function(s){return g(this,s,!0)*r},toRadians:function(s){return g(p.zero,this,!0)},toDegrees:function(s){return this.toRadians()*r},rotateDegreesSelf:function(s){return this.rotateRadiansSelf(s*a)},rotateDegrees:function(s){return this.clone().rotateDegreesSelf(s)},rotateRadiansSelf:function(s){var d=Math.cos(s),m=Math.sin(s),S=this.x*d-this.y*m,T=this.x*m+this.y*d;return this.x=h(S),this.y=h(T),this},rotateRadians:function(s){return this.clone().rotateRadiansSelf(s)},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},normalizeSelf:function(){var s=Math.sqrt(this.x*this.x+this.y*this.y);return s===0?this:(this.x/=s,this.y/=s,this)},normalize:function(){return this.clone().normalizeSelf()},addSelf:function(s){return typeof s=="number"?this.addScalarSelf(s):(this.x+=s.x,this.y+=s.y,this)},subSelf:function(s){return typeof s=="number"?this.subScalarSelf(s):(this.x-=s.x,this.y-=s.y,this)},divSelf:function(s){return typeof s=="number"?this.divScalarSelf(s):(this.x/=s.x,this.y/=s.y,this)},mulSelf:function(s){return typeof s=="number"?this.mulScalarSelf(s):(this.x*=s.x,this.y*=s.y,this)},addScalarSelf:function(s){return this.x+=s,this.y+=s,this},subScalarSelf:function(s){return this.x-=s,this.y-=s,this},divScalarSelf:function(s){return this.x/=s,this.y/=s,this},mulScalarSelf:function(s){return this.x*=s,this.y*=s,this},add:function(s){return this.clone().addSelf(s)},sub:function(s){return this.clone().subSelf(s)},mul:function(s){return this.clone().mulSelf(s)},div:function(s){return this.clone().divSelf(s)},addScalar:function(s){return this.clone().addScalarSelf(s)},subScalar:function(s){return this.clone().subScalarSelf(s)},mulScalar:function(s){return this.clone().mulScalarSelf(s)},divScalar:function(s){return this.clone().divScalarSelf(s)},clampSelf:function(s,d){return this.x<s.x&&(this.x=s.x),this.y<s.y&&(this.y=s.y),this.x>d.x&&(this.x=d.x),this.y>d.y&&(this.y=d.y),this},clamp:function(s,d){return this.clone().clampSelf(s,d)},applySelf:function(s){return this.x=s(this.x),this.y=s(this.y),this},apply:function(s){return this.clone().applySelf(s)},absSelf:function(){return this.applySelf(Math.abs)},abs:function(){return this.clone().absSelf()},roundSelf:function(){return this.applySelf(Math.round)},round:function(){return this.clone().roundSelf()},dot:function(s){return this.x*s.x+this.y*s.y},cross:function(s){return this.x*s.y-this.y*s.x},repairSelf:function(s,d){return(typeof this.x!="number"||isNaN(this.x+1))&&(this.x=s||0),(typeof this.y!="number"||isNaN(this.y+1))&&(this.y=d||0),this},repair:function(s,d){return this.clone().repairSelf(s,d)},toString:function(){return this.x+","+this.y},format:function(s){return s=s||"%x,%y",s=s.replace(new RegExp("%x","g"),this.x),s=s.replace(new RegExp("%y","g"),this.y),s}},p}();return l.zero=new l(0,0),l.one=new l(1,1),l.up=new l(0,-1),l.down=new l(0,1),l.left=new l(-1,0),l.right=new l(1,0),l.upLeft=new l(-1,-1),l.downLeft=new l(-1,1),l.upRight=new l(1,-1),l.downRight=new l(1,1),l.prototype.magnitude=l.prototype.length,Object.freeze&&(Object.freeze(l.zero),Object.freeze(l.one),Object.freeze(l.up),Object.freeze(l.down),Object.freeze(l.left),Object.freeze(l.right),Object.freeze(l.upLeft),Object.freeze(l.downLeft),Object.freeze(l.upRight),Object.freeze(l.downRight)),l})})(Ae);var en=Ae.exports;const Y=ut(en);let Ft=(u=21)=>crypto.getRandomValues(new Uint8Array(u)).reduce((l,t)=>(t&=63,t<36?l+=t.toString(36):t<62?l+=(t-26).toString(36).toUpperCase():t>62?l+="-":l+="_",l),"");const St={strokeType:"plain",strokeColor:"black",strokeWidth:1,head:"none",tail:"none"},Jt={id:0,type:"Feature",properties:{type:"arrow",style:{...St}},geometry:{type:"LineString",coordinates:[[0,0],[100,100]]}},Se=(u=0,l=0,t=0,r=0,a={...St})=>({id:Ft(),type:"Feature",properties:{type:"arrow",style:{...St,...a}},geometry:{type:"LineString",coordinates:[[u,l],[t,r]]}}),nn="http://www.w3.org/2000/svg";function Et(u){return document.createElementNS(nn,u)}function Qt(u){return u.geometry.bbox||Ee(u),u.geometry.bbox}function lt(u){const l=Qt(u);return{width:l[2]-l[0],height:l[3]-l[1]}}function ht(u){const l=Qt(u);return{x:l[0],y:l[1]}}function Ee(u){const[l,t]=u.geometry.coordinates[0][0],[r,a]=u.geometry.coordinates[0][2];u.geometry.bbox=[l,t,r,a]}function ke(u,l,t,r,a){u.geometry.bbox=[l,t,l+r,t+a],u.geometry.coordinates=[[[l,t],[l+r,t],[l+r,t+a],[l,t+a],[l,t]]]}function kt(u){const[l,t]=u.geometry.coordinates[0];return{x:l,y:t}}function Ot(u,l){const[t,r]=u.geometry.coordinates[l==="start"?0:1];return{x:t,y:r}}function Dt(u){const[l,t]=u.geometry.coordinates[1];return{x:l,y:t}}function te(u,l,t){u.geometry.coordinates[0]=[l,t]}function ee(u,l,t){u.geometry.coordinates[1]=[l,t]}function Lt(u){return{start:kt(u),end:Dt(u)}}function vt(u,l,t,r){l==="start"?te(u,t,r):ee(u,t,r)}const ne=u=>parseInt(u.getAttribute("data-handle-id")||"-1");function rn(u){return Bt(u).reduce((l,t)=>(l[0]=Math.min(t[0],l[0]),l[1]=Math.min(t[1],l[1]),l[2]=Math.max(t[0],l[2]),l[3]=Math.max(t[1],l[3]),l),[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY])}function Bt(u){let l=[];return u.type=="Point"?l=[u.coordinates]:u.type=="LineString"||u.type=="MultiPoint"?l=u.coordinates:u.type=="Polygon"||u.type=="MultiLineString"?l=u.coordinates.reduce(function(t,r){return t.concat(r)},[]):u.type=="MultiPolygon"?l=u.coordinates.reduce((t,r)=>t.concat(r.reduce((a,h)=>a.concat(h),[])),[]):u.type=="Feature"?l=Bt(u.geometry):u.type=="GeometryCollection"?l=u.geometries.reduce((t,r)=>t.concat(Bt(r)),[]):u.type=="FeatureCollection"&&(l=u.features.reduce((t,r)=>t.concat(Bt(r)),[])),l}function zt(u,l,t){const r=Math.atan2(u.y-l.y,u.x-l.x);return{x:l.x+t*Math.cos(r),y:l.y+t*Math.sin(r)}}function Te(u,l=5,t=30){var s;const{start:r,end:a}=Lt(u),h=new Y(r.x,r.y),g=new Y(a.x,a.y).sub(h),p=u.properties.style&&u.properties.style.strokeWidth?(s=u.properties.style)==null?void 0:s.strokeWidth:0;return Math.min(t,Math.max(3*p,g.length()*.1,l))}function _e(u,l,t,r){const a=l.clone().normalize().invert().mul(r);if(!t||t==="none")return"";const h=u.clone().add(a.rotateRadians(Math.PI/8)),f=u.clone().add(a.rotateRadians(-Math.PI/8)),g=`${u.x} ${u.y}`;return`M ${h.x} ${h.y} L ${g} ${f.x} ${f.y} ${t==="arrow"?"":`${h.x} ${h.y}`}`}function sn(u,l,t,r,a){const{start:h,end:f}=Lt(u),{tail:g,head:p,strokeColor:s,strokeWidth:d}=u.properties.style||t,m=new Y(h.x,h.y),S=new Y(f.x,f.y),T=S.clone().sub(m),b=Te(u,r,a),D=Et("path");D.setAttribute("data-annotation",`${u.id}`),D.setAttribute("data-annotation-type","arrow");const A=p==="arrow-plain"||g==="arrow";D.setAttribute("stroke",s||"none"),D.setAttribute("stroke-width",`${d}`),D.setAttribute("fill",A?s||"":"none"),D.setAttribute("stroke-linecap","round"),D.setAttribute("stroke-linejoin","round");const $=_e(m,T.clone().invert(),g,b),H=_e(S,T,p,b),I=$+`M ${m.x} ${m.y} ${S.x} ${S.y}`+H;D.setAttribute("d",I),l.appendChild(D)}const V=-1,qt="dragging",Vt="dragstart",Tt="dragend",ie="select",re="unselect",on="hover",an="unhover",se="remove",oe="add",ln="cancelDrawing",ae="update",hn="link";var Ie={exports:{}};(function(u){var l=Object.prototype.hasOwnProperty,t="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(t=!1));function a(p,s,d){this.fn=p,this.context=s,this.once=d||!1}function h(p,s,d,m,S){if(typeof d!="function")throw new TypeError("The listener must be a function");var T=new a(d,m||p,S),b=t?t+s:s;return p._events[b]?p._events[b].fn?p._events[b]=[p._events[b],T]:p._events[b].push(T):(p._events[b]=T,p._eventsCount++),p}function f(p,s){--p._eventsCount===0?p._events=new r:delete p._events[s]}function g(){this._events=new r,this._eventsCount=0}g.prototype.eventNames=function(){var s=[],d,m;if(this._eventsCount===0)return s;for(m in d=this._events)l.call(d,m)&&s.push(t?m.slice(1):m);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(d)):s},g.prototype.listeners=function(s){var d=t?t+s:s,m=this._events[d];if(!m)return[];if(m.fn)return[m.fn];for(var S=0,T=m.length,b=new Array(T);S<T;S++)b[S]=m[S].fn;return b},g.prototype.listenerCount=function(s){var d=t?t+s:s,m=this._events[d];return m?m.fn?1:m.length:0},g.prototype.emit=function(s,d,m,S,T,b){var D=t?t+s:s;if(!this._events[D])return!1;var A=this._events[D],$=arguments.length,H,I;if(A.fn){switch(A.once&&this.removeListener(s,A.fn,void 0,!0),$){case 1:return A.fn.call(A.context),!0;case 2:return A.fn.call(A.context,d),!0;case 3:return A.fn.call(A.context,d,m),!0;case 4:return A.fn.call(A.context,d,m,S),!0;case 5:return A.fn.call(A.context,d,m,S,T),!0;case 6:return A.fn.call(A.context,d,m,S,T,b),!0}for(I=1,H=new Array($-1);I<$;I++)H[I-1]=arguments[I];A.fn.apply(A.context,H)}else{var G=A.length,W;for(I=0;I<G;I++)switch(A[I].once&&this.removeListener(s,A[I].fn,void 0,!0),$){case 1:A[I].fn.call(A[I].context);break;case 2:A[I].fn.call(A[I].context,d);break;case 3:A[I].fn.call(A[I].context,d,m);break;case 4:A[I].fn.call(A[I].context,d,m,S);break;default:if(!H)for(W=1,H=new Array($-1);W<$;W++)H[W-1]=arguments[W];A[I].fn.apply(A[I].context,H)}}return!0},g.prototype.on=function(s,d,m){return h(this,s,d,m,!1)},g.prototype.once=function(s,d,m){return h(this,s,d,m,!0)},g.prototype.removeListener=function(s,d,m,S){var T=t?t+s:s;if(!this._events[T])return this;if(!d)return f(this,T),this;var b=this._events[T];if(b.fn)b.fn===d&&(!S||b.once)&&(!m||b.context===m)&&f(this,T);else{for(var D=0,A=[],$=b.length;D<$;D++)(b[D].fn!==d||S&&!b[D].once||m&&b[D].context!==m)&&A.push(b[D]);A.length?this._events[T]=A.length===1?A[0]:A:f(this,T)}return this},g.prototype.removeAllListeners=function(s){var d;return s?(d=t?t+s:s,this._events[d]&&f(this,d)):(this._events=new r,this._eventsCount=0),this},g.prototype.off=g.prototype.removeListener,g.prototype.addListener=g.prototype.on,g.prefixed=t,g.EventEmitter=g,u.exports=g})(Ie);var cn=Ie.exports;const Me=ut(cn);class Oe extends Me{constructor(t,r){super();v(this,"ogma");v(this,"elements");v(this,"layer");v(this,"editor");v(this,"selectedId",V);v(this,"hoveredId",V);v(this,"ogmaOptions");v(this,"shouldDetect");v(this,"isDragging");v(this,"showeditorOnHover");v(this,"maxHandleScale",1.5);v(this,"_onKeyUp",t=>{t.code===27&&this.selectedId!==V?this.unselect():(t.code===46||t.code===8)&&this.selectedId!==V&&this._canRemove()&&this.remove(this.selectedId)});v(this,"_onClickMouseMove",t=>{if(!t.domEvent||this.isDragging||!this.shouldDetect||t.domEvent.type!=="mousemove"&&t.domEvent.target.tagName==="a")return;const r=this.ogma.view.screenToGraphCoordinates(t),a=this.shouldDetect||!this.shouldDetect&&+this.selectedId>-1?this.detect(r,0):void 0;t.domEvent.type==="mousemove"?a?this.hover(a.id):this.hoveredId!==V&&this.unhover():a?this.select(a.id):this.selectedId!==V&&this.unselect()});this.ogma=t,this.elements=[],this.shouldDetect=!0,this.isDragging=!1,this.showeditorOnHover=!0,this.ogmaOptions=t.getOptions(),t.events.on(["click","mousemove"],this._onClickMouseMove).on("keyup",this._onKeyUp).on("frame",()=>{this.refreshEditor(),this.refreshDrawing()}),this.layer=t.layers.addSVGLayer({draw:a=>this.draw(a)}),this.layer.moveToTop(),this.editor=t.layers.addLayer(r),this.editor.hide()}_canRemove(){return!0}add(t){const r=this.getDefaultOptions(),a=Object.assign(t,{id:t.id===void 0?Ft():t.id,type:t.type,properties:{...r.properties,...t.properties||{},style:{...r.properties.style,...t.properties.style||{}}},geometry:{...r.geometry,...t.geometry}});return this.elements.push(a),this.layer.refresh(),this.emit(oe,a),a}updateStyle(t,r){this.updateAnnotation(t,{properties:{style:r}})}updateGeometry(t,r){this.updateAnnotation(t,{geometry:r})}update(t,r){const a=this.getById(t);this.updateAnnotation(a,r)}updateAnnotation(t,r){if(!t)return;const a=t.id;Object.keys(r).forEach(h=>{if(h!=="id")if(h==="properties"){const f=r.properties||{style:{}};t.properties={...t.properties||{},...f||{},style:{...t.properties.style||{},...f.style||{}}}}else h==="geometry"?t.geometry={...t.geometry,...r.geometry}:t[h]=r[h]}),a===this.selectedId&&this.refreshEditor(),this.layer.refresh()}getById(t){const r=Number(t);for(let a=0;a<this.elements.length;a++){const h=this.elements[a];if(!(h.id!==t&&h.id!==r))return h}}select(t){const r=this.getById(t);r&&(this.editor.show(),this.selectedId=t,this.refreshEditor(),this.layer.refresh(),this.emit(ie,r))}hover(t){const r=this.getById(t);r&&(this.showeditorOnHover&&this.editor.show(),this.hoveredId=t,this.refreshEditor(),this.layer.refresh(),this.emit(on,r))}getSelectedFeature(){return this.selectedId===V?null:this.getById(this.selectedId)}unselect(){const t=this.getById(this.selectedId);return t&&this.emit(re,t),this.selectedId=V,this.hoveredId===V&&this.editor.hide(),this.layer.refresh(),this}unhover(){const t=this.getById(this.hoveredId);return this.emit(an,t),this.hoveredId=V,this.selectedId===V&&this.editor.hide(),this.layer.refresh(),this}remove(t){const r=this.getById(t);t===this.hoveredId&&this.unhover(),t===this.selectedId&&this.unselect(),this.elements=this.elements.filter(a=>a.id!==t),r&&this.emit(se,r),this.layer.refresh()}disableDragging(){this.ogma.setOptions({interactions:{drag:{enabled:!1},pan:{enabled:!1}},detect:{nodes:!1,edges:!1,nodeTexts:!1,edgeTexts:!1}})}restoreDragging(){this.ogma.setOptions(this.ogmaOptions)}enableDetection(){this.shouldDetect=!0}disableDetection(){this.shouldDetect=!1}refreshLayer(){this.layer.refresh()}refreshDrawing(){}getElements(){return[...this.elements]}destroy(){this.ogma.events.off(this._onClickMouseMove).off(this._onKeyUp),this.layer.destroy()}}const De="handle-line",Le="handle-start",ze="handle-end";class Ce extends Oe{constructor(t,r={}){super(t,`
2
- <div class="arrow-handle">
3
- <div id="${De}" data-handle-id="0" class="handle line"></div>
4
- <div id="${Le}" data-handle-id="1" class="handle"></div>
5
- <div id="${ze}" data-handle-id="2" class="handle"></div>
6
- </div>
7
- `);v(this,"draggedHandle",V);v(this,"start",{x:0,y:0});v(this,"end",{x:0,y:0});v(this,"arrow",{...Jt});v(this,"startX",0);v(this,"startY",0);v(this,"minArrowHeight",0);v(this,"maxArrowHeight",0);v(this,"handles",[]);v(this,"onHandleMouseDown",t=>{const r=this.getById(this.selectedId)||this.getById(this.hoveredId);r&&(this.startDragging(r,t.clientX,t.clientY),this.draggedHandle=ne(t.target))});v(this,"onMouseUp",()=>{this.draggedHandle!==-1&&(this.restoreDragging(),this.isDragging=!1,this.draggedHandle=V,this.emit(Tt,this.arrow))});v(this,"onMouseMove",t=>{if(!this.isDragging||this.draggedHandle===V)return;const r=this.handles[this.draggedHandle],a=this.ogma.view.getAngle(),{x:h,y:f}=new Y(t.clientX-this.startX,t.clientY-this.startY).divScalar(this.ogma.view.getZoom()).rotateRadians(a),g=r.id===De,p=r.id===Le,s=r.id===ze;(g||p)&&te(this.arrow,this.start.x+h,this.start.y+f),(g||s)&&ee(this.arrow,this.end.x+h,this.end.y+f),this.emit(qt,this.arrow,g?"line":p?"start":"end"),this.refreshEditor(),this.layer.refresh()});this.minArrowHeight=r.minArrowHeight||0,this.maxArrowHeight=r.maxArrowHeight||1e6,this.handles=Array.prototype.slice.call(this.editor.element.querySelectorAll(".arrow-handle>.handle")),this.handles.forEach(a=>a.addEventListener("mousedown",this.onHandleMouseDown)),document.addEventListener("mousemove",this.onMouseMove,!0),document.addEventListener("mouseup",this.onMouseUp)}startDrawing(t,r,a=Se(t,r,t,r,St)){var g;this.add(a),this.hoveredId=a.id;const h=this.ogma.view.graphToScreenCoordinates({x:t,y:r}),f=((g=this.ogma.getContainer())==null?void 0:g.getBoundingClientRect())||{left:0,top:0};this.startDragging(this.getById(a.id),h.x+(f==null?void 0:f.left),h.y+f.top),this.draggedHandle=2}cancelDrawing(){this.isDragging&&(this.remove(this.arrow.id),this.emit(Tt,this.arrow),this.restoreDragging(),this.isDragging=!1,this.draggedHandle=V)}startDragging(t,r,a){this.selectedId!==t.id&&this.select(this.hoveredId),this.arrow=t,this.startX=r,this.startY=a,this.start=kt(this.arrow),this.end=Dt(this.arrow),this.disableDragging(),this.emit(Vt,this.arrow),this.isDragging=!0}detect(t,r=0){return this.elements.find(a=>{const{start:h,end:f}=Lt(a),g=new Y(t.x,t.y).sub(new Y((h.x+f.x)/2,(h.y+f.y)/2)),p=new Y(f.x,f.y).sub(new Y(h.x,h.y)),s=p.length(),d=p.normalize(),m=Te(a);return Math.abs(d.dot(g))<s/2+r&&Math.abs(d.rotateRadians(Math.PI/2).dot(g))<m/2+r})}refreshEditor(){if(+this.selectedId<0&&+this.hoveredId<0)return;const t=this.selectedId!==V?this.getById(this.selectedId):this.getById(this.hoveredId),r=Lt(t),a=this.ogma.view.graphToScreenCoordinates(r.start),h=this.ogma.view.graphToScreenCoordinates(r.end),f=Math.min(this.ogma.view.getZoom(),this.maxHandleScale),[g,p,s]=Array.prototype.slice.call(this.editor.element.querySelectorAll(".handle"));p.style.transform=`translate(${a.x}px, ${a.y}px) translate(-50%, -50%) scale(${f})`,s.style.transform=`translate(${h.x}px, ${h.y}px) translate(-50%, -50%) scale(${f}`;const d={x:(h.x+a.x)/2,y:(h.y+a.y)/2},m=new Y(h.x-a.x,h.y-a.y),S=m.mul(1/m.length()),T=Math.atan2(S.y,S.x);g.style.width=`${m.length()}px`,g.style.left=`${d.x}px`,g.style.top=`${d.y}px`,g.style.transform=`translate(-50%, -50%) rotate(${T}rad)`}getDefaultOptions(){return Jt}draw(t){t.innerHTML="";const r=Et("g"),a=this.ogma.view.getAngle();r.setAttribute("transform",`rotate(${-a*(180/Math.PI)})`),this.elements.forEach(h=>sn(h,r,St,this.minArrowHeight,this.maxArrowHeight)),t.appendChild(r)}refreshDrawing(){const t=this.ogma.view.getAngle();this.layer.element.children[0].setAttribute("transform",`rotate(${-t*(180/Math.PI)})`)}destroy(){super.destroy(),document.removeEventListener("mousemove",this.onMouseMove,!0),document.removeEventListener("mouseup",this.onMouseUp)}}const wt={font:"sans-serif",fontSize:12,color:"black",background:"",strokeWidth:1,strokeColor:"#000",strokeType:"plain"},Ut={id:0,type:"Feature",properties:{type:"text",content:"",style:{...wt}},geometry:{type:"Polygon",coordinates:[[[0,0],[100,0],[100,50],[0,50],[0,0]]]}},le={handleSize:3.5,placeholder:"Your text..."},Pe=(u=0,l=0,t=100,r=50,a="",h={...wt})=>({id:Ft(),type:"Feature",properties:{type:"text",content:a,style:{...wt,...h}},geometry:{type:"Polygon",coordinates:[[[u,l],[u+t,l],[u+t,l+r],[u,l+r],[u,l]]]}});var $e={exports:{}};(function(u,l){(function(t,r){u.exports=r()})(it,()=>(()=>{var t={d:(e,n)=>{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n)},r={};function a(e){return a=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},a(e)}t.d(r,{default:()=>Xn});var h=/^((?:[a-z\d-]+\s+)*)([\d.]+(%|em|px)|(?:x+-)?large|(?:x+-)?small|medium)(?:\s*\/\s*(normal|[\d.]+(%|px|em)?))?(\s.+)?$/,f=/\bsmall-caps\b/,g=/\b(?:italic|oblique)\b/,p=/\bbold(?:er)?\b/,s=13.3333333,d={"xx-small":9,"x-small":10,smaller:13.3333,small:13,medium:16,large:18,larger:19.2,"x-large":24,"xx-large":32};function m(e){var n="",o=this;return o.style&&o.style!=="normal"&&(n+=o.style),o.variant&&o.variant!=="normal"&&(n+=(n?" ":"")+o.variant),o.weight&&o.weight!=="normal"&&(n+=(n?" ":"")+o.weight),o.size&&(n+=(n?" ":"")+o.size+"px",o.height!==o.size&&(n+="/"+o.height+"px")),o.family&&(n+=(n?" ":"")+o.family),e&&(n+="::"+o.baseline),e&&(n+="::"+o.color),n}var S={id:"",family:"sans-serif",height:14,size:12,variant:"",style:"",weight:"",baseline:"",color:null,toString:m,valueOf:m};function T(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=h.exec(e);n.family=(o[6]||"").trim();var i=d[o[2]]||parseFloat(o[2]);o[3]==="%"?i*=.16:o[3]==="em"?i*=16:o[3]==="pt"&&(i*=s),n.size=i;var c=parseFloat(o[4]);if(c!=="normal"&&c!=="inherit"&&c?o[5]&&o[5]!=="em"?o[5]==="pt"?n.height=c*s:o[5]==="%"?n.height=.01*i:n.height=c:n.height=c*i:n.height=Math.round(i*(7/6)),f.test(o[1])&&(n.variant="small-caps"),g.test(o[1])&&(n.style="italic"),p.test(o[1]))n.weight="bold";else{var y=parseInt(/\b(\d+)\b/.exec(o[1]),10);y>=100&&y!==400&&(n.weight=y)}return n}function b(){var e,n,o,i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"12px/14px sans-serif",c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},y=14,x=12,w=null,E=null,k="";if(i&&i.nodeType){var L=i&&(i.ownerDocument&&i.ownerDocument.defaultView||i.document&&i||i.defaultView),z=L.getComputedStyle(i,null);e=z.getPropertyValue("font-family")||"",x=parseFloat(z.getPropertyValue("font-size")),y=z.getPropertyValue("line-height"),w=z.getPropertyValue("font-weight"),E=z.getPropertyValue("font-style"),k=z.getPropertyValue("font-variant")||""}else if(typeof i=="string"){var M=T(i);e=M.family,x=M.size,y=M.height,k=M.variant,E=M.style,w=M.weight}else a(i)==="object"&&(e=i.family,x=i.size,y=i.height,k=i.variant,w=i.weight,E=i.style,n=i.baseline,o=i.color);c.size&&c.size<3&&(x*=c.size),y=y!=="normal"&&y?parseFloat(y):x*(7/6),c.height&&c.height<3&&(y*=c.height);var C=Object.create(S);return C.family=c.family||e||"sans-serif",C.height=y??14,C.size=x??12,C.variant=c.variant||k||"",C.style=c.style||E||"",C.weight=c.weight||w||"",C.baseline=n||0,c.baseline!=null&&(C.baseline=c.baseline),C.color=c.color||o||"",C.id=m.call(C,!0),C}const D={"\n":.28,"\r":.28," ":.28," ":.28," ":.28,"᠎":0," ":.5," ":1," ":.5," ":1," ":.33," ":.25," ":.16," ":.56," ":.28," ":.2," ":.15,"​":0," ":.16," ":.22," ":1,"\uFEFF":0};var A,$=function(e){var n=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(100,100)||e&&e.createElement("canvas");if(n&&n.getContext){var o=n.getContext("2d");if(o&&typeof o.measureText=="function")return function(i,c){return o.font=String(c),o.measureText(i).width}}}(typeof document<"u"?document:null)||(A={},function(e,n){if(!A[n]){var o=b(n);A[n]=o,/\bmonospace\b/.test(o.family)?o.size*=.6:(o.size*=.45,o.weight&&(o.size*=1.18))}return e.length*A[n].size}),H={},I={trim:!0,collapse:!0};function G(e,n,o){var i=Object.assign({},I,o),c=String(e);if(!c)return 0;if(c in D){var y=n.id+"/"+c;return y in H||(H[y]=$("_".concat(c,"_"),n)-$("__",n)),H[y]}return i.trim&&i.collapse?i.trim?c=c.trim():i.collapse&&(c=c.replace(/\s+/g," ")):c=c.replace(/\n/g," "),$(c,n)+n.size*(e.tracking||0)}function W(e){return W=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},W(e)}function Ct(e,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),n&&Pt(e,n)}function Pt(e,n){return Pt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(o,i){return o.__proto__=i,o},Pt(e,n)}function de(e){var n=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}();return function(){var o,i=Yt(e);if(n){var c=Yt(this).constructor;o=Reflect.construct(i,arguments,c)}else o=i.apply(this,arguments);return yn(this,o)}}function yn(e,n){if(n&&(W(n)==="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(o){if(o===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return o}(e)}function Yt(e){return Yt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Yt(e)}function Xt(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function Be(e,n){for(var o=0;o<n.length;o++){var i=n[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(c=function(y,x){if(W(y)!=="object"||y===null)return y;var w=y[Symbol.toPrimitive];if(w!==void 0){var E=w.call(y,x);if(W(E)!=="object")return E;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(y)}(i.key,"string"),W(c)==="symbol"?c:String(c)),i)}var c}function Gt(e,n,o){return n&&Be(e.prototype,n),o&&Be(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e}var j=function(){function e(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";Xt(this,e),this.value=n,this.weight=null,this.style=null,this.font=null,this.href=null,this.sub=!1,this.sup=!1}return Gt(e,[{key:"clone",value:function(){var n=new e(this.value);return n.value=this.value,n.weight=this.weight,n.style=this.style,n.font=this.font,n.href=this.href,n.sub=this.sub,n.sup=this.sup,n}},{key:"valueOf",value:function(){return this.value}},{key:"toString",value:function(){return this.value}}]),e}(),$t=function(e){Ct(o,e);var n=de(o);function o(){return Xt(this,o),n.apply(this,arguments)}return Gt(o)}(j),rt=function(e){Ct(o,e);var n=de(o);function o(){return Xt(this,o),n.apply(this,arguments)}return Gt(o)}(j),xt=function(e){Ct(o,e);var n=de(o);function o(){return Xt(this,o),n.apply(this,arguments)}return Gt(o)}(j),fe=/^[\n\r\t\x20\xA0\u2000-\u200B\u205F\u3000]/,mn=/^[^\n\r\t\u0020\u2000-\u200B\u205F\u3000]{2,}/,qe=/^[\xA0\u2011\u202F\u2060\uFEFF]/,vn=/^(?:[;\xAD%?…]|,(?!\d))/,wn=/^[´±°¢£¤$¥\u2212]/;function Wt(e,n){n!==!1&&(e=e.trim());for(var o,i,c=[],y=e.charAt(0),x=0,w=1,E=e.length;w<E;w++){o=e.charAt(w),i=e.charAt(w+1);var k=fe.test(y),L=fe.test(o),z=L||k,M=void 0;if((wn.test(o)&&!qe.test(y)||vn.test(y+i)&&!qe.test(o))&&(z=!0),y!=="-"&&y!=="‐"&&y!=="–"&&y!=="—"||((M=fe.test(e.charAt(w-2)))&&!L&&(z=!1),!M&&mn.test(o+i)&&(z=!0)),z){var C=e.slice(x,w);/\u00AD$/.test(C)?(c.push(new j(C.slice(0,-1))),c.push(new xt)):(c.push(new j(C)),c.push(new $t)),x=w}y=o}return c.push(new j(e.slice(x))),c}const Ve={nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",fnof:"ƒ",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",bull:"•",hellip:"…",prime:"′",Prime:"″",oline:"‾",frasl:"⁄",weierp:"℘",image:"ℑ",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"⊥",or:"⊦",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",quot:'"',amp:"&",lt:"<",gt:">",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",permil:"‰",lsaquo:"‹",rsaquo:"›"};var xn=/^[\n\r\x20\u2000-\u200B\u205F\u3000]/,bn=/^<\/([a-zA-Z0-9]+)([^>]*)>/,An=/^<([a-zA-Z0-9]+)((?:\s[^=\s/]+(?:\s*=\s*(?:"[^"]+"|'[^']+'|[^>\\s]+))?)+)?\s*(\/?)>(\n*)/,Sn=/^<!--(.+?)-->/,En=/&(?:#(\d\d{2,})|#x([\da-fA-F]{2,})|([a-zA-Z][a-zA-Z1-4]{1,8}));/g,Ue={b:function(e){e.weight="bold"},strong:function(e){e.weight="bold"},i:function(e){e.style="italic"},em:function(e){e.style="italic"},dfn:function(e){e.style="italic"},cite:function(e){e.style="italic"},code:function(e){e.family="monospace"},kbd:function(e){e.family="monospace"},samp:function(e){e.family="monospace"},var:function(e){e.family="monospace"},tt:function(e){e.family="monospace"},sub:function(e){e.sub=!0},sup:function(e){e.sup=!0}},kn={div:1,li:1,blockquote:2,h1:2,h2:2,h3:2,h4:2,h5:2,h6:2,ul:2,ol:2,hr:2,p:2};function Ye(e){return e.replace(En,function(n,o,i,c){if(o||i){var y=o?10:16;return String.fromCharCode(parseInt(o||i,y))}return c in Ve?Ve[c]:n})}function Tn(e){return e&&e.length>1&&(e[0]==='"'&&e[e.length-1]==='"'||e[0]==="'"&&e[e.length-1]==="'")?e.slice(1,-1):e}var _n=/^\s*([^=\s&]+)(?:\s*=\s*("[^"]+"|'[^']+'|[^>\s]+))?/;function In(e){var n,o={};if(e){do if(n=_n.exec(e)){var i=Ye(Tn(n[2]||"")).replace(/[ \r\n\t]+/g," ").trim();if(o[n[1]]=i,(e=e.slice(n[0].length)).length&&/^\S/.test(e[0]))throw new Error("Attribute error")}while(n&&e.length);if(/\S/.test(e))throw new Error("Attribute error")}return o}const Xe={copyright:"©",textcopyright:"©",dag:"†",textdagger:"†",ddag:"‡",textdaggerdbl:"‡",guillemotleft:"«",guillemotright:"»",guilsinglleft:"‹",guilsinglright:"›",ldots:"…",dots:"…",textellipsis:"…",lq:"‘",P:"¶",textparagraph:"¶",pounds:"£",textsterling:"£",quotedblbase:"„",quotesinglbase:"‚",rq:"’",S:"§",sim:"~",textasciicircum:"^",textasciitilde:"˜",texttildelow:"~",textasteriskcentered:"*",textbackslash:"'",textbar:"|",textbardbl:"╎",textbigcircle:"◯",textbraceleft:"{",textbraceright:"}",textbullet:"•",textdollar:"$",textemdash:"—",textendash:"—",texteuro:"€",eurosym:"€",euro:"€",textexclamdown:"¡",textgreater:">",textless:"<",textordfeminine:"ª",textordmasculine:"º",textperiodcentered:"·",cdot:"·",textquestiondown:"¿",textquotedblleft:"“",textquotedblright:"”",textquoteleft:"‘",textquoteright:"’",textquotestraightbase:"‚",textquotestraightdblbase:"„",textregistered:"®",textthreequartersemdash:"-",texttrademark:"™",texttwelveudash:"-",textunderscore:"_",textvisiblespace:"␣",gets:"←",textleftarrow:"←",to:"→",textrightarrow:"→",textdegree:"°",infty:"∞",triangle:"△",triangledown:"▽",blacktriangle:"▲",blacktriangledown:"▼",angle:"∠",sphericalangle:"∢",aleph:"ℵ",hbar:"ħ",imath:"𝚤",jmath:"𝚥",ell:"ℓ",wp:"℘",Re:"ℜ",Im:"ℑ",mho:"℧",prime:"′",emptyset:"∅",nabla:"∇",surd:"√",partial:"∂",top:"⟙",bot:"⟂",vdash:"⟝",dashv:"⟞",forall:"∀",exists:"∃",nexists:"∄",neg:"¬",lnot:"¬",flat:"♭",natural:"♮",sharp:"♯",backslash:"\\",Box:"□",Diamond:"♢",clubsuit:"♣",diamondsuit:"♦",heartsuit:"♥",spadesuit:"♠",Join:"⨝",blacksquare:"■",bigstar:"★",diagdown:"╲",diagup:"╱",blacklozenge:"⧫",rfloor:"⌋",lfloor:"⌊",rceil:"⌉",lceil:"⌈",rangle:"⟩",langle:"⟨",sum:"∑",int:"∫",oint:"∮",prod:"∏",coprod:"∏",bigcap:"∩",bigcup:"∪",bigsqcup:"⊔",bigvee:"∨",bigwedge:"∧",bigodot:"⊙",bigotimes:"⊗",bigoplus:"⊕",biguplus:"⊎",alpha:"α",beta:"β",chi:"χ",delta:"δ",epsilon:"ε",eta:"η",gamma:"γ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",omega:"ω",phi:"φ",pi:"π",psi:"ψ",rho:"ρ",sigma:"σ",tau:"τ",theta:"θ",upsilon:"υ",xi:"ξ",zeta:"ζ",Alpha:"Α",Beta:"Β",Chi:"Χ",Delta:"Δ",Epsilon:"Ε",Eta:"Η",Gamma:"Γ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Omega:"Ω",Phi:"Φ",Pi:"Π",Psi:"Ψ",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Theta:"Θ",Upsilon:"Υ",Xi:"Ξ",Zeta:"Ζ",aa:"å",AA:"Å",ae:"æ",AE:"Æ",dh:"ð",DH:"Ð",dj:"đ",DJ:"Đ",ij:"ij",IJ:"IJ",l:"ł",L:"Ł",ng:"ŋ",NG:"Ŋ",o:"ø",O:"Ø",oe:"œ",OE:"Œ",ss:"ß",SS:"SS",th:"þ",TH:"Þ"};var Mn=/^(\^|_|\\[^#$%&~_^\\{}()\s]+)(\{)?/,On=/^%[^\n]+(?:\n|$)/,Dn=/^[^#$%&~_^\\{}]+/,Ln=/^\\([&{}$%#_])/,zn=/(?:\\[\\@,!:;-]|-{2,3}|[!?]`|``?|,,|''?|~|<<|>>)/g,Cn={"---":"—","--":"–","!`":"¡","?`":"¿","``":"“",",,":"„","''":"”","`":"‘","'":"’","<<":"«",">>":"»","~":" ","\\-":"­","\\,":" ","\\;":" ","\\:":" ","\\!":" ","\\@":"\uFEFF","\\\\":"\\newline{}"},X={bf:function(e){e.weight="bold"},it:function(e){e.style="italic"},sl:function(e){e.style="italic"},color:function(e,n){e.color=n},href:function(e,n){e.href=n},"^":function(e){e.sup=!0},_:function(e){e.sub=!0},par:function(e){this.tokens.push(new rt,new rt)},newline:function(e){this.tokens.push(new rt)},url:function(e,n){this.open_context().href=n,this.add_token(new j(n)),this.close_context()}};X.textsuperscript=X["^"],X.textsubscript=X._,X.textsl=X.sl,X.mathbf=X.bf,X.mathit=X.it,X.textbf=X.bf,X.textit=X.it,X.textcolor=X.color;var Pn=/[\r\n\xA0]+/g;function $n(e,n){e.sup&&(e.baseline=.45,e.size=.7),e.sub&&(e.baseline=-.3,e.size=.7);var o=n;return(e.style||e.weight||e.baseline||e.color||e.size||e.family)&&(o=b(n,e)),o}function Ge(e,n,o){for(var i,c,y=e.width;y+o.width>n&&e.length;)c=(i=e[e.length-1]).width,i.width>o.width?(i.value=i.value.slice(0,-1),i.width=G(i,i.font),y+=i.width):e.pop(),y-=c;e[e.length-1]instanceof xt&&e.pop(),i=e[e.length-1]||i||{},o.font=b(o.font,i.bold,i.italic,""),o.href=e.length?i.href:null,o.rel=e.length?i.rel:null,o.target=e.length?i.target:null,e.push(o)}function _t(e){return Math.round(1e6*e)/1e6}function We(e){return function(n){if(Array.isArray(n))return pe(n)}(e)||function(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}(e)||function(n,o){if(n){if(typeof n=="string")return pe(n,o);var i=Object.prototype.toString.call(n).slice(8,-1);return i==="Object"&&n.constructor&&(i=n.constructor.name),i==="Map"||i==="Set"?Array.from(n):i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?pe(n,o):void 0}}(e)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
8
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function pe(e,n){(n==null||n>e.length)&&(n=e.length);for(var o=0,i=new Array(n);o<n;o++)i[o]=e[o];return i}var Nn={center:"middle",right:"end"},Hn={middle:.5,center:.5,bottom:1,end:1},ge=function(e,n){return!e&&!n||e===n};function Rn(e,n){var o=[],i=n.font(),c=i.size,y=i.family,x=n.align(),w=n.createElement();if(e.length){var E=i.height,k=n.valign(),L=n.height()(),z=n.width()(0),M=!isFinite(z)&&e.length===1,C=M?null:n.x(),F=_t(E/c),tt=M?null:_t(E/(1.15*c+(E-c)/2));if(Hn[k]&&isFinite(L)){var N=k==="bottom"?1:.5;tt+=(L*N-E*e.length*N)/c}var P=x==="justify",B=0;x==="right"?B=z:x==="center"&&(B=z/2);for(var R=[],et="tspan",Z=null,q="",O=function(){if(q){var bt=w(et,Z,q);R.push(bt)}et="tspan",Z=null,q=""},st=0,nt=e.length;st<nt;st++){var dt="",yt="",ct=0,ft=e[st];if(ft.length){R=[];for(var It=0,Rt=0,pt=void 0,K=0,Zt=ft.length;K<Zt;K++){var U=ft[K],J=U.font;U.whitespace&&It++,Rt+=U.width,K&&!U.tracking&&!ct&&ge(J.id,dt)&&ge(U.class,yt)&&ge(pt,U.href)?q+=U.value:(O(),q=U.value,Z={fontFamily:J.family!==y?J.family:null,fontSize:J.size!==c?J.size:null,fontWeight:J.weight||null,fontStyle:J.style||null,fontVariant:J.variant!=="normal"&&J.variant||null,fill:J.color||null,baselineShift:J.baseline?100*J.baseline+"%":null,className:U.class||null},ct&&(Z.dx=_t(ct),ct=0),U.tracking&&(ct=J.size*U.tracking),U.href&&!pt?(pt=U.href,et="a",Z.href=pt,Z.rel=U.rel,Z.target=U.target):pt=null,dt=J.id,yt=U.class)}if(O(),M)o.push.apply(o,We(R));else{var Kt=null,jt=st===nt-1||ft[ft.length-1]instanceof rt;P&&ft.length>1&&!jt&&(Kt=_t((z-Rt)/It)),o.push(w.apply(void 0,["tspan",{wordSpacing:Kt,x:C(st)+B,dy:_t(st?F:tt)+"em"}].concat(We(R))))}}else o.push(w("tspan",{x:C(st),dy:_t(st?F:tt)+"em"}," "))}}return w.apply(void 0,["text",{fontFamily:y,fontSize:c,textAnchor:Nn[x]||"start"}].concat(o))}var jn={middle:.5,center:.5,bottom:1,end:1};function Fn(e,n,o){if(e.length){o.textBaseline="middle";var i=n.font(),c=i.height,y=i.size,x=n.valign(),w=n.height()(),E=n.width()(0),k=n.align(),L=k==="justify",z=.5*c,M=jn[x];if(M&&isFinite(w)){var C=e.length*c;z+=w*M-C*M}e.forEach(function(F,tt){var N=n.x()(tt),P=tt*c+z,B=0,R=0;F.forEach(function(q){q.whitespace&&B++,R+=q.width});var et=0,Z=tt===e.length-1||F[F.length-1]instanceof rt;L&&F.length>1&&!Z&&(et=(E-R)/B),F.forEach(function(q){o.font=q.font;var O=q.font,st=O.baseline?y*-O.baseline+.15*y:0;o.fillStyle=function(yt,ct){return yt.color?yt.color:ct.href?"#00C":"#000"}(O,q);var nt=0;if(k==="right"?nt+=E-R:k==="center"?nt+=E/2-R/2:k==="justify"&&(q.whitespace||q instanceof rt)&&(N+=et),o.fillText(q.value,N+nt,P+st),q.href){o.beginPath(),o.strokeStyle=o.fillStyle;var dt=Math.floor(P+.45*y)+.5;o.moveTo(N+nt,dt),o.lineTo(N+nt+q.width,dt),o.stroke()}N+=q.width})})}}function ye(e){return ye=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},ye(e)}function Ze(e){for(var n={},o=0;o<e.length;o++){var i=e[o];typeof i!="number"&&i!=null&&(typeof i=="string"?n.text=i:typeof i=="function"?n.fn=i:ye(i)==="object"&&i._groups?n.d3=i:i&&i.nodeType&&i.getContext?n.ctx=i.getContext("2d"):i&&i.fillText&&i.beginPath?n.ctx=i:i&&(n.text=i))}return n}function Nt(e){return Nt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Nt(e)}function Bn(e,n){for(var o=0;o<n.length;o++){var i=n[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(c=function(y,x){if(Nt(y)!=="object"||y===null)return y;var w=y[Symbol.toPrimitive];if(w!==void 0){var E=w.call(y,x);if(Nt(E)!=="object")return E;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(y)}(i.key,"string"),Nt(c)==="symbol"?c:String(c)),i)}var c}var qn=b(),me=function(e){return typeof e=="function"?e:function(){return e}},ot=function(){function e(i){if(function(y,x){if(!(y instanceof x))throw new TypeError("Cannot call a class as a function")}(this,e),this.props={overflow:"ellipsis",lineclamp:null,align:"left",wordBreak:null,valign:"top",width:function(){return 1/0},height:function(){return 1/0},x:function(){return 0},font:null,tAnchor:0,parser:e.defaultparser},i)for(var c in i)typeof this[c]=="function"&&this[c](i[c])}var n,o;return n=e,o=[{key:"linebreak",value:function(i){var c=this,y=this.props.parser(String(i)),x=this.font(),w=function(E,k,L){if(!E.length)return[];var z=k.height(),M=k.width(),C=k.overflowLine(),F=k.overflowWrap(),tt=b(L,!0,!1),N=isFinite(z())?Math.floor(z()/L.height):1/0;if(!z()&&!M(0)||!N)return[];for(var P=0,B=0,R=0,et=[],Z=[],q=!1;P<E.length&&B<N;){var O=E[P],st=$n(O,L);if(O.width=G(O,st),O.font=st,O.line=B,O.whitespace=O.value in D,O.value&&(O.value=O.value.replace(Pn," ")),!(!R&&O.whitespace||q&&O.whitespace))if(O instanceof rt)R=0,Z=[],et.push(P+1),B++;else if(O instanceof $t||O instanceof xt)Z.push({index:P,width:R});else if(O.whitespace||R+O.width<M(B))R+=O.width;else if(Z.length){var nt=void 0,dt=void 0;do{dt=!0,nt=Z.pop();var yt=E[nt.index],ct=void 0;yt instanceof xt&&(ct=G("-",yt.font),nt.width+ct>M(B)&&(dt=!Z.length))}while(!dt);et.push(nt.index+1),R=0,B++,P=nt.index,Z=[]}else if(F==="break-word"){var ft=M(B);if(R+O.width>ft){var It=O.clone();do O.value=O.value.slice(0,-1),O.width=G(O,O.font),R+=O.width;while(O.value&&O.width>ft);It.value=It.value.slice(O.value.length),E.splice(P+1,0,new $t,It)}et.push(P+1),R=0,B++}else R+=O.width;P++,q=O.whitespace}P!==et[et.length-1]&&et.push(P);var Rt=0,pt=0,K=et.map(function(bt){for(var Q,At=Rt;(Q=E[At])&&(Q.whitespace||!Q.value);)At++;for(var mt=bt,xe=null;mt>At&&(Q=E[mt-1])&&(Q.whitespace||!(Q.value||Q instanceof xt));)Q instanceof rt&&(xe=Q),mt--;Q instanceof xt&&(Q.value="-",Q.width=G("-",Q.font)),Rt=bt;var Mt=E.slice(At,mt).filter(function(be){return be.value});return xe&&Mt.push(xe),Mt.width=Mt.reduce(function(be,Gn){return be+Gn.width},0),Mt.width>pt&&(pt=Mt.width),Mt});if(K.hasLineOverflow=!1,C){var Zt=C==="ellipsis"?"…":C;K.forEach(function(bt,Q){var At=M(Q);if(bt.width>At){var mt=new j(Zt);mt.font=L,mt.width=G(Zt,tt),Ge(bt,At,mt),K.hasLineOverflow=!0}})}var U=k.overflow()==="ellipsis"?"…":k.overflow();if(U&&P!==E.length){var J=M(K.length-1),Kt=K[K.length-1],jt=new j(U);jt.font=L,jt.width=G(U,tt),Ge(Kt,J,jt),K.hasOverflow=!0}else K.hasOverflow=!1;return K.font=L,K.width=pt,K}(y,this,x);return w.height=w.length*x.height,w.render=function(E){return c.render(w,E)},w.svg=w.render,w.draw=w.render,w}},{key:"font",value:function(i){return arguments.length?(this.props.font=b(i),this):this.props.font||b(qn)}},{key:"overflow",value:function(i){return arguments.length?(this.props.overflow=String(i),this):this.props.overflow}},{key:"overflowLine",value:function(i){return arguments.length?(this.props.lineclamp=String(i),this):this.props.lineclamp}},{key:"valign",value:function(i){return arguments.length?(this.props.valign=i,this):this.props.valign}},{key:"align",value:function(i){if(!arguments.length)return this.props.align;var c=String(i).toLowerCase();return c==="left"||c==="start"?(this.props.align="left",this.props.tAnchor=0):c==="center"||c==="middle"?(this.props.align="center",this.props.tAnchor=-.5):c==="end"||c==="right"?(this.props.align="right",this.props.tAnchor=-1):c==="justify"&&(this.props.align=i,this.props.tAnchor=0),this}},{key:"overflowWrap",value:function(i){if(!arguments.length)return this.props.overflowWrap||"normal";var c=String(i).toLowerCase();return c==="break-word"?this.props.overflowWrap="break-word":c!=="normal"&&i!=null||(this.props.overflowWrap=null),this}},{key:"width",value:function(i){return arguments.length?(this.props.width=me(i),this):this.props.width}},{key:"height",value:function(i){return arguments.length?(this.props.height=me(i),this):this.props.height}},{key:"x",value:function(i){return arguments.length?(this.props.x=me(i),this):this.props.x}},{key:"parser",value:function(i){if(!arguments.length)return this.props.parser;if(typeof i=="string"){var c=e[i]||e[i+"parser"];typeof c=="function"&&(i=c)}if(typeof i!="function")throw new Error("Unknown parser: "+i);return this.props.parser=i,this}},{key:"createElement",value:function(i){return arguments.length?(this.props.createElement=i,this):this.props.createElement||e.createElement}},{key:"render",value:function(){var i=Ze(arguments);return typeof i.text=="string"&&(i.text=this.linebreak(i.text)),i.ctx?Fn(i.text,this,i.ctx):Rn(i.text,this)}}],o&&Bn(n.prototype,o),Object.defineProperty(n,"prototype",{writable:!1}),e}();function Ht(e){return Ht=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Ht(e)}function ve(e,n){(n==null||n>e.length)&&(n=e.length);for(var o=0,i=new Array(n);o<n;o++)i[o]=e[o];return i}function Vn(e,n){for(var o=0;o<n.length;o++){var i=n[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(c=function(y,x){if(Ht(y)!=="object"||y===null)return y;var w=y[Symbol.toPrimitive];if(w!==void 0){var E=w.call(y,x);if(Ht(E)!=="object")return E;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(y)}(i.key,"string"),Ht(c)==="symbol"?c:String(c)),i)}var c}var Ke=function(e){return typeof e=="function"?e:function(){return e}},Je=function(){function e(i){if(function(y,x){if(!(y instanceof x))throw new TypeError("Cannot call a class as a function")}(this,e),this.props={width:function(){return 1/0},height:function(){return 1/0},rotation:0,vAnchor:0,hAnchor:0},i)for(var c in i)typeof this[c]=="function"&&this[c](i[c]);this.render=this.render.bind(this)}var n,o;return n=e,o=[{key:"anchor",value:function(i){var c=this.props,y=c.hAnchor,x=c.vAnchor,w=c.width,E=c.height;if(!arguments.length)return[y*w(0),x*E(0)];if(typeof i=="string"){var k=this.props;i.toLowerCase().trim().split(/\s+/).forEach(function(L){L==="top"&&(k.vAnchor=-0),L==="middle"&&(k.vAnchor=-.5),L==="bottom"&&(k.vAnchor=-1),L==="left"&&(k.hAnchor=-0),L==="center"&&(k.hAnchor=-.5),L==="right"&&(k.hAnchor=-1)})}return this}},{key:"width",value:function(i){return arguments.length?(this.props.width=Ke(i),this):this.props.width}},{key:"height",value:function(i){return arguments.length?(this.props.height=Ke(i),this):this.props.height}},{key:"rotate",value:function(i){return arguments.length?(this.props.rotation=i,this):this.props.rotation}},{key:"createElement",value:function(i){return arguments.length?(this.props.createElement=i,this):this.props.createElement||e.createElement}},{key:"canvas",value:function(i,c){var y,x=i.getContext?i.getContext("2d"):i;return x.save(),x.rotate(this.rotate()*Math.PI/180),x.translate.apply(x,function(w){if(Array.isArray(w))return ve(w)}(y=this.anchor())||function(w){if(typeof Symbol<"u"&&w[Symbol.iterator]!=null||w["@@iterator"]!=null)return Array.from(w)}(y)||function(w,E){if(w){if(typeof w=="string")return ve(w,E);var k=Object.prototype.toString.call(w).slice(8,-1);return k==="Object"&&w.constructor&&(k=w.constructor.name),k==="Map"||k==="Set"?Array.from(w):k==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(k)?ve(w,E):void 0}}(y)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
9
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()),c(x),x.restore(),x}},{key:"render",value:function(){var i=Ze(arguments);if(i.d3)return i.d3.attr("transform","rotate(".concat(this.rotate(),") translate(").concat(this.anchor(),")"));if(i.ctx)return this.canvas(i.ctx,i.fn);if(i.text){var c=typeof i.text.render=="function"?i.text.render():i.text;return this.createElement()("g",{transform:"rotate(".concat(this.rotate(),") translate(").concat(this.anchor(),")")},c)}}}],o&&Vn(n.prototype,o),Object.defineProperty(n,"prototype",{writable:!1}),e}(),Un=Object.prototype.hasOwnProperty,we={};function Yn(e){return we[e]||(we[e]=e.replace(/([a-z])([A-Z])/g,function(n,o,i){return o+"-"+i.toLowerCase()})),we[e]}function Qe(e,n){if(Array.isArray(n))return n.forEach(function(o){return Qe(e,o)});typeof n=="string"&&(n=document.createTextNode(n)),e.appendChild(n)}function tn(e,n){if(typeof document<"u"){var o=typeof e=="string"?document.createElementNS("http://www.w3.org/2000/svg",e):e;if(n&&o.setAttribute)for(var i in n)Un.call(n,i)&&n[i]!=null&&o.setAttribute(i==="className"?"class":Yn(i),n[i]);for(var c=arguments.length,y=new Array(c>2?c-2:0),x=2;x<c;x++)y[x-2]=arguments[x];return y!=null&&y.length&&y.forEach(function(w){Qe(o,w)}),o}}ot.createElement=tn,ot.textparser=Wt,ot.defaultparser=Wt,ot.htmlparser=function(e){e=String(e||"").trim();for(var n,o,i={weight:null,style:null,sub:!1,sup:!1,href:null,color:null,rel:null,target:null},c=[],y=[],x=function(z){for(var M in i)i[M]&&(z[M]=i[M]);c.push(z)},w=function(z){var M=c.length,C=kn[z];if(M&&C){for(var F=M-1;c[F]&&(c[F]instanceof $t||xn.test(c[F].value));)F--;for(;C&&c[F]&&c[F]instanceof rt;)F--,C--;for(;C-- >0;)c.push(new rt)}};e.length;){if(n=/^[^<]+/.exec(e))Wt(Ye(n[0]),!1).forEach(x);else if(!(n=Sn.exec(e)))if(n=bn.exec(e))y.length&&(i=y.pop()),w(n[1]);else if(n=An.exec(e)){var E=n[1];w(E),y.push(i),i=Object.create(i),Ue[E]&&Ue[E](i,"");var k=In(n[2]);E==="a"&&(k.href&&(i.href=k.href),k.rel&&(i.rel=k.rel),k.target&&(i.target=k.target)),k.class&&(i.class=i.class?i.class+" "+k.class:k.class),k.style&&(o=/(?:^|\s|;)color\s*:\s*([^;\s"']+)/.exec(k.style))&&o[1]&&(i.color=o[1]),E==="br"&&c.push(new rt)}else n=[e.slice(0,1)],x(new j(n[0]));e=e.slice(n[0].length)}for(var L=c[c.length-1];L instanceof rt;)c.pop(),L=c[c.length-1];return c},ot.latexparser=function(e){e=String(e||"").trim();var n=[0];e=e.replace(/\\verb,(.*?),/,function(N,P){return n.push(P),"\\verb,"+(n.length-1)+","}).replace(/\\\\\n/g,function(){return"\\\\"}).replace(zn,function(N,P,B){return B.charAt(P-1)==="\\"?N:Cn[N]}).replace(/\n\s+/g,function(N){return/\n/.test(N.slice(1))?"\\par ":N}).replace(/\\symbol\{(\d+)\}/,function(N,P,B,R){return R.charAt(B-1)==="\\"?N:String.fromCharCode(1*P)}).replace(/(^|[^\\])(\^|_)(\d|[^{]\S*)/g,function(N,P,B,R){return P+B+"{"+R+"}"}).replace(/\\verb,(.*?),/,function(N,P){return"\\verb,".concat(n[+P],",")});for(var o,i={weight:null,italic:null,variant:null,sub:!1,sup:!1,href:null},c=[],y=[],x=function(N){for(var P in i)i[P]&&(N[P]=i[P]);return c.push(N),N},w=function(){y.push(i),i=Object.create(i)},E=function(){if(!y.length)throw new Error("Unexpected }");i=y.pop()},k={tokens:c,open_context:w,close_context:E,add_token:x};e.length;){if(o=Dn.exec(e))Wt(o[0],!1).forEach(x);else if(o=Ln.exec(e))x(new j(o[1]));else if(!(o=On.exec(e))){if(o=/^\{/.exec(e))w();else if(o=/^\}/.exec(e))E();else if(!(o=/^\$/.exec(e)))if(o=/^\\verb,([^,]+),/.exec(e))x(new j(o[1]));else if(o=Mn.exec(e)){var L=o[1].slice(1)||o[1],z=!!o[2];if(/^(La)?TeX$/i.test(L)){w(),i.family="serif";var M=void 0;L==="LaTeX"&&((M=x(new j("L"))).tracking=-.25,(M=x(new j("A"))).size=.7,M.baseline=.3,M.tracking=-.1),(M=x(new j("T"))).tracking=-.17,(M=x(new j("E"))).baseline=-.22,M.tracking=-.13,M=x(new j("X")),E()}else if(L in Xe)x(new j(Xe[L])),z&&w();else if(L in X){var C=[],F=X[L].length-1,tt=void 0;if(F){for(z=!1,e=e.slice(o[0].length-1);F--;){if(!(tt=/^\{([^}]+)\}/.exec(e)))throw new Error(L+" is missing an argument");C.push(tt[1]),e=e.slice(tt[0].length)}o[0]=/^\{/.exec(e)?"{":"",z=!!o[0]}z&&w(),X[L].apply(k,[i].concat(C))}else console.warn("unknown latex command",L),x(new j(o[1])),z&&w()}else o=[e.slice(0,1)],x(new j(o[0]))}e=e.slice(o[0].length)}return c},ot.measureText=function(e,n,o){return G(e,b(n),o)},ot.Token=j,ot.Break=$t,ot.LineBreak=rt,ot.SoftHyphen=xt,ot.Rotator=Je,Je.createElement=tn;const Xn=ot;return r.default})())})($e);var un=$e.exports;const Ne=ut(un);function he(u){return u.replace(/…$/,"")}function ce(u){return u.children[0].innerHTML}function dn(u,l){const t=lt(u),{fontSize:r,font:a,padding:h=0}=u.properties.style||{};if(t.width===t.height&&t.width===0)return;const f=new Ne({font:`${r}px/${r}px ${a}`.replace(/(px)+/g,"px"),width:t.width-h*2,height:t.height-h*2,align:"left",valign:"top",x:0,overflow:"ellipsis",parser:"html",createElement:Ne.createElement});f.overflowWrap("break-word");const p=f.linebreak(u.properties.content.replaceAll(`
10
- `,"<br>")).render(),s=[...p.children];let d=0;const m=[];u.properties.content.split(`
11
- `).forEach(b=>{let D=b;for(;D.length&&d<s.length;){if(s[d].innerHTML==="&nbsp;"){D.startsWith(`
12
- `)||m.push(d),d++;break}const A=he(ce(s[d]));D.startsWith(A)&&(D=D.slice(A.length).trim()),d++}}),m.forEach(b=>p.removeChild(s[b]));const S=u.properties.content.match(/(https?:\/\/.*)/gm),T=S?S.map(b=>b.split(" ")[0]):[];p.setAttribute("transform",`translate(${h}, ${h})`),T.forEach(b=>{let D=b;const A=[];for(;D.length>0;){const $=s.find(I=>!!I.children[0]&&I.children[0].tagName==="tspan"&&D.startsWith(he(ce(I))));if(!$)break;A.push($);const H=he($.children[0].innerHTML).length;if(!H)break;D=D.slice(H)}A.forEach($=>{const H=document.createElementNS("http://www.w3.org/2000/svg","a");H.setAttribute("href",b),H.setAttribute("target","_blank"),H.innerHTML=ce($),$.children[0].innerHTML="",$.children[0].appendChild(H)})}),l.appendChild(p)}const He=20;class Re extends Oe{constructor(t,r={}){super(t,`
13
- <div class="annotation-text-handle">
14
- <span class="handle line-handle top" data-handle-id="0"></span>
15
- <span class="handle line-handle bottom" data-handle-id="1"></span>
16
- <span class="handle line-handle left" data-handle-id="2"></span>
17
- <span class="handle line-handle right" data-handle-id="3"></span>
18
- <span class="handle top right point-handle top-right" data-handle-id="4"></span>
19
- <span class="handle left top point-handle top-left" data-handle-id="5"></span>
20
- <span class="handle bottom right point-handle bottom-right" data-handle-id="6"></span>
21
- <span class="handle left bottom left-handle point-handle bottom-left" data-handle-id="7"></span>
22
- <textarea wrap="on"></textarea>
23
- </div>
24
- `);v(this,"textArea");v(this,"handleSize");v(this,"rect",{x:0,y:0,width:0,height:0});v(this,"annotation",{...Ut});v(this,"startX",0);v(this,"startY",0);v(this,"handles",[]);v(this,"draggedHandle",V);v(this,"isFocused",!1);v(this,"placeholder","Type your text here...");v(this,"_onFocus",()=>{this.textArea.value===this.placeholder&&(this.textArea.value=""),this.isFocused=!0});v(this,"_onBlur",()=>{this.isFocused=!1});v(this,"startDrawing",(t,r,a=Pe(t,r,0,0,"",wt))=>{this.add(a);const h=this.ogma.view.graphToScreenCoordinates({x:t,y:r});this.select(a.id),this.startDragging(this.getById(a.id),h.x,h.y),this.draggedHandle=6});v(this,"cancelDrawing",()=>{this.isDragging&&(this.remove(this.annotation.id),this.annotation={...Ut},this.draggedHandle=V,this.isDragging=!1,this.emit(Tt,this.annotation))});v(this,"startDragging",(t,r,a)=>{this.annotation=t;const h=ht(this.annotation),f=lt(this.annotation);this.rect.x=h.x,this.rect.y=h.y,this.rect.width=f.width,this.rect.height=f.height,this.startX=r,this.startY=a,this.disableDragging(),this.textArea.classList.add("noevents"),this.textArea.setAttribute("disabled","disabled"),this.emit(Vt,this.annotation),this.isDragging=!0});v(this,"onHandleMouseDown",t=>{const r=this.getById(this.selectedId)||this.getById(this.hoveredId);r&&(this.selectedId!==r.id&&this.select(this.hoveredId),this.startDragging(r,t.clientX,t.clientY),this.draggedHandle=ne(t.target))});v(this,"onMouseMove",t=>{requestAnimationFrame(()=>this._onMouseMove(t))});v(this,"_onMouseMove",t=>{if(!this.isDragging)return;t.stopPropagation(),t.preventDefault();const r=this.handles[this.draggedHandle],a=r.classList.contains("top"),h=r.classList.contains("left"),f=r.classList.contains("right"),g=r.classList.contains("bottom"),p=r.classList.contains("line-handle"),s=this.ogma.view.getZoom(),d=(t.clientX-this.startX)/s,m=(t.clientY-this.startY)/s,S=this.ogma.view.getAngle(),T=new Y(d,m).rotateRadians(S);(g&&h||a&&f)&&(T.y=0,T.x=0);const b=h||p?this.rect.x+T.x:this.rect.x,D=a||p?this.rect.y+T.y:this.rect.y,A=Math.max(this.rect.width+d*(p||h?0:1),He),$=Math.max(this.rect.height+m*(p||a?0:1),He);ke(this.annotation,b,D,A,$),this.emit(qt,this.annotation,"text"),this.refreshEditor(),this.layer.refresh()});v(this,"onMouseUp",()=>{!this.isDragging||this.draggedHandle===V||(this.restoreDragging(),this.textArea.classList.remove("noevents"),this.textArea.removeAttribute("disabled"),this.emit(Tt,this.annotation),this.isDragging=!1,this.draggedHandle=V)});v(this,"_onMousedown",t=>{t.stopPropagation()});v(this,"onViewChanged",()=>{const t=Math.max(2,this.handleSize/this.ogma.view.getZoom());document.documentElement.style.setProperty("--handle-scale",`${1/t}`)});v(this,"_onInput",()=>{const t=this.getById(this.selectedId);t&&(this.textArea.value=this.textArea.value.replace(/ +(?= )/g,""),this.textArea.focus(),t.properties.content=this.textArea.value,this.emit(ae,t),this.layer.refresh())});this.showeditorOnHover=!1,this.handleSize=le.handleSize||r.textHandleSize,this.placeholder=le.placeholder||r.textPlaceholder||"";const a=this.textArea=this.editor.element.querySelector("textarea");a.addEventListener("input",this._onInput),a.addEventListener("focus",this._onFocus),a.addEventListener("blur",this._onBlur),a.addEventListener("mousedown",this._onMousedown),a.spellcheck=!1,this.handles=Array.prototype.slice.call(this.editor.element.querySelectorAll(".annotation-text-handle > .handle")),this.handles.forEach(h=>h.addEventListener("mousedown",this.onHandleMouseDown)),document.addEventListener("mouseup",this.onMouseUp),document.addEventListener("mousemove",this.onMouseMove,!0),t.events.on(["viewChanged","zoom"],this.onViewChanged)}_canRemove(){return!this.isFocused}detect({x:t,y:r},a=0){const h=new Y(t,r),f=this.ogma.view.getAngle();return this.elements.find(g=>{const{x:p,y:s}=ht(g),{width:d,height:m}=lt(g),S=new Y(p,s),{x:T,y:b}=h.sub(S).rotateRadians(-f);return T>-a&&T<d+a&&b>-a&&b<m+a})}draw(t){t.innerHTML="";const r="",a=this.ogma.view.getAngle();this.elements.forEach((f,g)=>{const p=`class${g}`,s=lt(f),d=ht(f),m=f.id,{color:S,fontSize:T,font:b,strokeColor:D,strokeWidth:A,strokeType:$,background:H}=f.properties.style||wt;if(m===this.selectedId)return;const I=Et("g");I.classList.add("annotation-text"),I.setAttribute("fill",`${S}`),I.setAttribute("font-size",`${T}px`),I.setAttribute("font-family",`${b}`);const G=Et("rect");let W=!1;$&&$!=="none"&&(W=!0,G.setAttribute("stroke",D||"black"),G.setAttribute("stroke-width",`${A}`),$==="dashed"&&G.setAttribute("stroke-dasharray","5,5")),(H&&H.length||W)&&(W=!0,G.setAttribute("fill",H||"transparent")),W&&(G.setAttribute("width",`${s.width}`),G.setAttribute("height",`${s.height}`)),I.appendChild(G),dn(f,I);const{x:Ct,y:Pt}=new Y(d.x,d.y).rotateRadians(-a);I.setAttribute("transform",`translate(${Ct},${Pt})`),I.classList.add(p),I.setAttribute("data-annotation",`${f.id}`),I.setAttribute("data-annotation-type","text"),t.appendChild(I)});const h=Et("style");h.innerHTML=r,t.firstChild&&t.insertBefore(h,t.firstChild)}refreshDrawing(){const t=this.ogma.view.getAngle();[...this.layer.element.children].forEach(r=>{const a=r.getAttribute("data-annotation");if(!a)return;const h=ht(this.getById(a)),{x:f,y:g}=new Y(h.x,h.y).rotateRadians(-t);r.setAttribute("transform",`translate(${f},${g})`)})}getDefaultOptions(){return Ut}refreshEditor(){if(+this.selectedId<0&&+this.hoveredId<0)return;const t=this.getById(this.selectedId)||this.getById(this.hoveredId),r=lt(t),a=this.ogma.view.graphToScreenCoordinates(ht(t)),h=this.ogma.view.getZoom(),{font:f,fontSize:g,color:p,background:s,padding:d=0}=t.properties.style||wt,m=(g||1)*h;this.textArea.value=t.properties.content,this.editor.element.style.transform=`translate(${a.x}px, ${a.y}px)translate(-50%, -50%)translate(${r.width/2*h}px, ${r.height/2*h}px)`,this.editor.element.style.width=`${r.width*h}px`,this.editor.element.style.height=`${r.height*h}px`,this.textArea.style.font=`${m} ${f}`,this.textArea.style.fontFamily=f||"sans-serif",this.textArea.style.fontSize=`${m}px`,this.textArea.style.padding=`${h*d}px`,this.textArea.style.lineHeight=`${m}px`,this.textArea.style.boxSizing="border-box",this.textArea.style.color=p||"black",this.textArea.style.background=s||"transparent",this.textArea.placeholder=this.placeholder,this.layer.refresh()}select(t){super.select(t),this.textArea.focus()}destroy(){super.destroy(),document.removeEventListener("mouseup",this.onMouseUp),document.removeEventListener("mousemove",this.onMouseMove,!0),this.ogma.events.off(this.onViewChanged)}}class fn{constructor(){v(this,"links",{});v(this,"linksByTargetId",{});v(this,"linksByArrowId",{})}add(l,t,r,a,h){const f=Ft(),g=l.id,p={id:f,arrow:g,target:r,targetType:a,connectionPoint:h,side:t};return this.links[f]=p,this.linksByTargetId[r]||(this.linksByTargetId[r]=[]),this.linksByTargetId[r].push(f),this.linksByArrowId[g]||(this.linksByArrowId[g]={}),this.linksByArrowId[g][t]=f,l.properties.link=l.properties.link||{},l.properties.link[t]={id:r,side:t,type:a,magnet:h},this}arrowIsLinked(l,t){var r;return!!((r=this.linksByArrowId[l])!=null&&r[t])}remove(l,t){var g,p;const r=l.id,a=(g=this.linksByArrowId[r])==null?void 0:g[t];if((p=l.properties.link)==null||delete p[t],!a)return this;const h=this.links[a];delete this.links[a];const f=this.linksByTargetId[h.target];for(let s=0;s<f.length;s++)if(f[s]===a){f.splice(s,1);break}return delete this.linksByArrowId[r][t],this}getArrowLink(l,t){var a;const r=(a=this.linksByArrowId[l])==null?void 0:a[t];return r?this.links[r]:null}getTargetLinks(l,t){var r;return((r=this.linksByTargetId[l])==null?void 0:r.map(a=>this.links[a]).filter(a=>a.targetType===t))??[]}forEach(l){Object.values(this.links).forEach(l)}}const at=u=>u.properties.type==="arrow",gt=u=>u.properties.type==="text",ue=u=>u.type==="FeatureCollection",pn={magnetColor:"#3e8",detectMargin:20,magnetHandleRadius:5,magnetRadius:10,textPlaceholder:"Type here",arrowHandleSize:3.5,textHandleSize:3.5,minArrowHeight:20,maxArrowHeight:30},je=["start","end"],Fe=[{x:0,y:0},{x:.5,y:0},{x:1,y:0},{x:0,y:.5},{x:1,y:.5},{x:0,y:1},{x:.5,y:1},{x:1,y:1}];class gn extends Me{constructor(t,r={}){super();v(this,"arrows");v(this,"texts");v(this,"links",new fn);v(this,"layer");v(this,"annotations");v(this,"ogma");v(this,"options");v(this,"selected",null);v(this,"updateTimeout",0);v(this,"hoveredNode",null);v(this,"dragged",null);v(this,"textToMagnet");v(this,"activeLinks",[]);v(this,"_render",t=>{if(!this.dragged||this.textToMagnet===void 0)return;t.beginPath(),t.fillStyle="green";const r=this.ogma.view.getZoom();Fe.forEach(a=>{if(!this.textToMagnet)return;const h=lt(this.textToMagnet),f=ht(this.textToMagnet),{x:g,y:p}=new Y(a.x,a.y).mul({x:h.width,y:h.height}).rotateRadians(this.ogma.view.getAngle()).add(f);t.moveTo(g,p),t.arc(g,p,this.options.magnetHandleRadius/r,0,Math.PI*2)}),t.fill(),t.closePath()});v(this,"_onFeatureDrag",(t,r)=>{const a=r;if(at(t)&&a==="line")["start","end"].find(h=>{const f=h==="start"?kt(t):Dt(t);return this._snapToText(t,a,f)||this._findAndSnapToNode(t,h,f)});else if(at(t)&&a!=="line"){const h=a==="start"?kt(t):Dt(t);this._snapToText(t,a,h)||this._findAndSnapToNode(t,a,h)}else gt(t)&&(this.activeLinks.forEach(({arrow:h,side:f,connectionPoint:g})=>{const p=this.getAnnotation(h),s=lt(t),d=ht(t),m=new Y(g.x,g.y).mul({x:s.width,y:s.height}).rotateRadians(this.ogma.view.getAngle()).add(d);p.geometry.coordinates[f==="start"?0:1]=[m.x,m.y]}),this.activeLinks.length&&this.arrows.refreshLayer());this.layer.refresh(),this.emit(qt,t,r)});v(this,"_onFeatureDragEnd",t=>{this.dragged!==null&&at(t)&&kt(this.dragged)&&je.forEach(r=>{this.links.getArrowLink(t.id,r)&&this.emit(hn,{arrow:t,link:this.links.getArrowLink(t.id,r)})}),(gt(t)||at(t))&&this.onUpdate(t),this.dragged=null,this.activeLinks=[],this.textToMagnet=void 0,this.annotations.forEach(r=>r.enableDetection()),this.layer.refresh(),this.emit(Tt,t)});v(this,"_onFeatureDragStart",t=>{this.textToMagnet=void 0,at(t)?this.dragged=t:gt(t)&&this.activeLinks.push(...this.links.getTargetLinks(t.id,"text")),this.annotations.forEach(r=>{const a=r.getSelectedFeature();a&&a!==t&&r.unhover().unselect(),r.disableDetection()}),this.emit(Vt,t)});v(this,"_onNodesDragStart",()=>{this.arrows.unhover().unselect(),this.texts.unhover().unselect()});v(this,"_onNodesDrag",t=>{const{dx:r,dy:a}=t;this._moveNodes(t.nodes,r,a)});v(this,"_onLayoutEnd",t=>{t.ids.forEach((r,a)=>{this.links.getTargetLinks(r,"node").forEach(f=>{const g=this.getAnnotation(f.arrow),p=f.side,s=Ot(g,p==="start"?"end":"start"),d=t.positions.current[a],m=this.ogma.getNode(r).getAttribute("radius"),S=zt(s,d,+m);vt(g,p,S.x,S.y)})}),this.arrows.refreshLayer(),this.texts.refreshLayer()});v(this,"_onAdded",t=>{this.emit(oe,t)});v(this,"_onRemoved",t=>{this.emit(se,t)});v(this,"_onUnselect",t=>{this.selected=null,this.emit(re,t)});v(this,"_onSelect",t=>{this.selected!==t&&(this.selected=t,this.emit(ie,this.selected))});v(this,"onUpdate",t=>{cancelAnimationFrame(this.updateTimeout),this.updateTimeout=requestAnimationFrame(()=>this._onUpdate(t))});v(this,"_onUpdate",t=>{this.emit(ae,t)});this.options=this.setOptions({...pn,...r}),this.ogma=t,this.arrows=new Ce(t,this.options),this.texts=new Re(t,this.options),this.annotations=[this.arrows,this.texts],this.annotations.forEach(a=>{a.on(Vt,this._onFeatureDragStart).on(qt,this._onFeatureDrag).on(Tt,this._onFeatureDragEnd).on(ae,this.onUpdate).on(re,this._onUnselect).on(ie,this._onSelect).on(oe,this._onAdded).on(se,this._onRemoved)}),this.ogma.events.on("nodesDragStart",this._onNodesDragStart).on("nodesDragProgress",this._onNodesDrag).on("layoutEnd",this._onLayoutEnd).on(["viewChanged","rotate"],()=>{this.refreshTextLinks()}),this.layer=t.layers.addCanvasLayer(this._render),this.layer.moveToBottom()}_moveNodes(t,r,a){t.forEach(h=>{const f=this.links.getTargetLinks(h.getId(),"node"),g=h.getPosition();f.forEach(p=>{const s=this.getAnnotation(p.arrow),d=p.side,m=Ot(s,d==="start"?"end":"start");let S=g;const T=+h.getAttribute("radius"),b=1e-6;(p.connectionPoint.x-(g.x-r)>b||p.connectionPoint.y-(g.y-a)>b)&&(S=zt(m,g,T)),vt(s,d,S.x,S.y)})}),this.arrows.refreshLayer()}_snapToText(t,r,a){const h=this.texts.detect(a,this.options.detectMargin);if(this.links.remove(t,r),!h)return!1;this.textToMagnet=h;const f=this.findMagnetPoint(Fe,h,a);return f?(vt(t,r,f.point.x,f.point.y),this.links.add(t,r,h.id,"text",f.magnet),!0):!1}_findAndSnapToNode(t,r,a){const h=this.ogma.view.graphToScreenCoordinates(a),f=this.ogma.view.getElementAt(h);this.links.remove(t,r),f&&f.isNode?(this.hoveredNode=f,this.hoveredNode.setSelected(!0),this._snapToNode(t,r,f,h)):(this.hoveredNode&&this.hoveredNode.setSelected(!1),this.hoveredNode=null)}_snapToNode(t,r,a,h){const f=a.getPositionOnScreen(),g=+a.getAttribute("radius"),p=g*this.ogma.view.getZoom(),s=h.x-f.x,d=h.y-f.y,m=Math.sqrt(s*s+d*d),S=a.getPosition();if(m<p+this.options.detectMargin){let T=S;if(m>p/2){const b=Ot(t,r==="end"?"start":"end");T=zt(b,T,g)}vt(t,r,T.x,T.y),this.links.add(t,r,a.getId(),"node",T)}}refreshTextLinks(){let t=!1;this.links.forEach(({connectionPoint:r,targetType:a,target:h,arrow:f,side:g})=>{if(a!=="text")return;t=!0;const p=this.getAnnotation(h),s=this.getAnnotation(f),d=lt(p),m=ht(p),S=new Y(r.x,r.y).mul({x:d.width,y:d.height}).rotateRadians(this.ogma.view.getAngle()).add(m);vt(s,g,S.x,S.y)}),t&&this.arrows.refreshLayer()}getSelected(){return this.selected}findMagnetPoint(t,r,a){let h;for(const f of t){const g=lt(r),p=ht(r),s=new Y(f.x,f.y).mul({x:g.width,y:g.height}).rotateRadians(this.ogma.view.getAngle()).add(p),d=s.sub(a).length(),m=Math.min(this.options.magnetRadius*this.ogma.view.getZoom(),g.width/2,g.height/2);if(d<Math.max(m,this.options.magnetHandleRadius)){h={point:s,magnet:f};break}}return h}setOptions(t={}){return this.options={...this.options||{},...t},this.options}select(t){const r=this.getAnnotations().features.find(a=>a.id===t);return r?(at(r)?this.arrows.select(r.id):gt(r)&&this.texts.select(r.id),this):this}unselect(){return this.selected?(at(this.selected)?this.arrows.unselect():gt(this.selected)&&this.texts.unselect(),this):this}add(t){if(ue(t)){const[r,a]=t.features.reduce((h,f)=>(at(f)?h[1].push(f):gt(f)&&h[0].push(f),h),[[],[]]);return r.forEach(h=>this.add(h)),a.forEach(h=>this.add(h)),this.arrows.refreshLayer(),this}switch(t.properties.type){case"text":this.texts.add(t);break;default:this.arrows.add(t),this.loadLink(t);break}return this}remove(t){return ue(t)?(t.features.forEach(r=>this.remove(r)),this):(at(t)?(this.links.remove(t,"start"),this.links.remove(t,"end"),this.arrows.remove(t.id)):this.texts.remove(t.id),this)}loadLink(t){if(t.properties.link)for(const r of je){const a=t.properties.link[r];if(!a)continue;const h=this.getAnnotation(a.id);if(a.type==="text"&&h)this.links.add(t,r,a.id,a.type,a.magnet);else if(a.type==="node"){const f=this.ogma.getNode(a.id);if(!f)continue;this.links.add(t,r,a.id,a.type,a.magnet);const g=f.getPosition(),p=f.getAttribute("radius")||0,s=Ot(t,r==="start"?"end":"start"),d=zt(s,g,+p);vt(t,r,d.x,d.y)}}}startArrow(t,r,a){this.cancelDrawing(),this.arrows.startDrawing(t,r,a)}startText(t,r,a){this.cancelDrawing(),this.texts.startDrawing(t,r,a)}cancelDrawing(){this.annotations.forEach(t=>t.cancelDrawing()),this.emit(ln)}updateStyle(t,r){const a=this.getAnnotations().features.find(h=>h.id===t);return a?(at(a)?this.arrows.updateStyle(a,r):gt(a)&&this.texts.updateStyle(a,r),this.onUpdate(a),this):this}getAnnotations(){const t={type:"FeatureCollection",features:[]};return this.annotations.forEach(r=>{t.features=[...t.features,...r.getElements()]}),t}getAnnotation(t){return this.getAnnotations().features.find(r=>r.id===t)}destroy(){this.annotations.forEach(t=>t.destroy()),this.layer.destroy()}}_.Arrows=Ce,_.Control=gn,_.Texts=Re,_.createArrow=Se,_.createSVGElement=Et,_.createText=Pe,_.defaultArrowOptions=Jt,_.defaultArrowStyle=St,_.defaultControllerOptions=le,_.defaultTextOptions=Ut,_.defaultTextStyle=wt,_.getAnnotationsBounds=rn,_.getArrowEnd=Dt,_.getArrowEndPoints=Lt,_.getArrowSide=Ot,_.getArrowStart=kt,_.getAttachmentPointOnNode=zt,_.getHandleId=ne,_.getTextBbox=Qt,_.getTextPosition=ht,_.getTextSize=lt,_.isAnnotationCollection=ue,_.isArrow=at,_.isText=gt,_.setArrowEnd=ee,_.setArrowEndPoint=vt,_.setArrowStart=te,_.setTextBbox=ke,_.updateTextBbox=Ee,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});