@linkurious/ogma-annotations-react 1.1.14 → 1.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.js +15 -15
  2. package/dist/index.mjs +754 -728
  3. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(B,G){typeof exports=="object"&&typeof module<"u"?G(exports,require("react"),require("@linkurious/ogma-react")):typeof define=="function"&&define.amd?define(["exports","react","@linkurious/ogma-react"],G):(B=typeof globalThis<"u"?globalThis:B||self,G(B.index={},B.React,B.OgmaReact))})(this,function(B,G,qr){"use strict";var Be={exports:{}},qt={};/**
1
+ (function(B,X){typeof exports=="object"&&typeof module<"u"?X(exports,require("react"),require("@linkurious/ogma-react")):typeof define=="function"&&define.amd?define(["exports","react","@linkurious/ogma-react"],X):(B=typeof globalThis<"u"?globalThis:B||self,X(B.index={},B.React,B.OgmaReact))})(this,function(B,X,Gr){"use strict";var Be={exports:{}},Gt={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var yr;function Xr(){if(yr)return qt;yr=1;var h=G,e=Symbol.for("react.element"),s=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,l=h.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function f(p,d,v){var y,_={},C=null,E=null;v!==void 0&&(C=""+v),d.key!==void 0&&(C=""+d.key),d.ref!==void 0&&(E=d.ref);for(y in d)i.call(d,y)&&!c.hasOwnProperty(y)&&(_[y]=d[y]);if(p&&p.defaultProps)for(y in d=p.defaultProps,d)_[y]===void 0&&(_[y]=d[y]);return{$$typeof:e,type:p,key:C,ref:E,props:_,_owner:l.current}}return qt.Fragment=s,qt.jsx=f,qt.jsxs=f,qt}var Xt={};/**
9
+ */var yr;function qr(){if(yr)return Gt;yr=1;var u=X,e=Symbol.for("react.element"),o=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,l=u.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function f(g,d,v){var y,_={},C=null,E=null;v!==void 0&&(C=""+v),d.key!==void 0&&(C=""+d.key),d.ref!==void 0&&(E=d.ref);for(y in d)i.call(d,y)&&!c.hasOwnProperty(y)&&(_[y]=d[y]);if(g&&g.defaultProps)for(y in d=g.defaultProps,d)_[y]===void 0&&(_[y]=d[y]);return{$$typeof:e,type:g,key:C,ref:E,props:_,_owner:l.current}}return Gt.Fragment=o,Gt.jsx=f,Gt.jsxs=f,Gt}var qt={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,28 +14,28 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var vr;function Gr(){return vr||(vr=1,process.env.NODE_ENV!=="production"&&function(){var h=G,e=Symbol.for("react.element"),s=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),f=Symbol.for("react.provider"),p=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),v=Symbol.for("react.suspense"),y=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),C=Symbol.for("react.lazy"),E=Symbol.for("react.offscreen"),P=Symbol.iterator,S="@@iterator";function j(t){if(t===null||typeof t!="object")return null;var o=P&&t[P]||t[S];return typeof o=="function"?o:null}var L=h.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function T(t){{for(var o=arguments.length,u=new Array(o>1?o-1:0),g=1;g<o;g++)u[g-1]=arguments[g];H("error",t,u)}}function H(t,o,u){{var g=L.ReactDebugCurrentFrame,m=g.getStackAddendum();m!==""&&(o+="%s",u=u.concat([m]));var w=u.map(function(b){return String(b)});w.unshift("Warning: "+o),Function.prototype.apply.call(console[t],console,w)}}var N=!1,at=!1,_t=!1,Kt=!1,Qt=!1,_e;_e=Symbol.for("react.module.reference");function Dt(t){return!!(typeof t=="string"||typeof t=="function"||t===i||t===c||Qt||t===l||t===v||t===y||Kt||t===E||N||at||_t||typeof t=="object"&&t!==null&&(t.$$typeof===C||t.$$typeof===_||t.$$typeof===f||t.$$typeof===p||t.$$typeof===d||t.$$typeof===_e||t.getModuleId!==void 0))}function Mt(t,o,u){var g=t.displayName;if(g)return g;var m=o.displayName||o.name||"";return m!==""?u+"("+m+")":u}function te(t){return t.displayName||"Context"}function rt(t){if(t==null)return null;if(typeof t.tag=="number"&&T("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case i:return"Fragment";case s:return"Portal";case c:return"Profiler";case l:return"StrictMode";case v:return"Suspense";case y:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case p:var o=t;return te(o)+".Consumer";case f:var u=t;return te(u._context)+".Provider";case d:return Mt(t,t.render,"ForwardRef");case _:var g=t.displayName||null;return g!==null?g:rt(t.type)||"Memo";case C:{var m=t,w=m._payload,b=m._init;try{return rt(b(w))}catch{return null}}}return null}var M=Object.assign,ut=0,J,ct,$t,ke,ee,Te,Se;function kt(){}kt.__reactDisabledLog=!0;function Ce(){{if(ut===0){J=console.log,ct=console.info,$t=console.warn,ke=console.error,ee=console.group,Te=console.groupCollapsed,Se=console.groupEnd;var t={configurable:!0,enumerable:!0,value:kt,writable:!0};Object.defineProperties(console,{info:t,log:t,warn:t,error:t,group:t,groupCollapsed:t,groupEnd:t})}ut++}}function er(){{if(ut--,ut===0){var t={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:M({},t,{value:J}),info:M({},t,{value:ct}),warn:M({},t,{value:$t}),error:M({},t,{value:ke}),group:M({},t,{value:ee}),groupCollapsed:M({},t,{value:Te}),groupEnd:M({},t,{value:Se})})}ut<0&&T("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var re=L.ReactCurrentDispatcher,ne;function zt(t,o,u){{if(ne===void 0)try{throw Error()}catch(m){var g=m.stack.trim().match(/\n( *(at )?)/);ne=g&&g[1]||""}return`
18
- `+ne+t}}var ie=!1,Tt;{var rr=typeof WeakMap=="function"?WeakMap:Map;Tt=new rr}function oe(t,o){if(!t||ie)return"";{var u=Tt.get(t);if(u!==void 0)return u}var g;ie=!0;var m=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var w;w=re.current,re.current=null,Ce();try{if(o){var b=function(){throw Error()};if(Object.defineProperty(b.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(b,[])}catch(I){g=I}Reflect.construct(t,[],b)}else{try{b.call()}catch(I){g=I}t.call(b.prototype)}}else{try{throw Error()}catch(I){g=I}t()}}catch(I){if(I&&g&&typeof I.stack=="string"){for(var A=I.stack.split(`
19
- `),R=g.stack.split(`
17
+ */var vr;function Xr(){return vr||(vr=1,process.env.NODE_ENV!=="production"&&function(){var u=X,e=Symbol.for("react.element"),o=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),f=Symbol.for("react.provider"),g=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),v=Symbol.for("react.suspense"),y=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),C=Symbol.for("react.lazy"),E=Symbol.for("react.offscreen"),P=Symbol.iterator,T="@@iterator";function j(t){if(t===null||typeof t!="object")return null;var s=P&&t[P]||t[T];return typeof s=="function"?s:null}var L=u.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function S(t){{for(var s=arguments.length,h=new Array(s>1?s-1:0),p=1;p<s;p++)h[p-1]=arguments[p];H("error",t,h)}}function H(t,s,h){{var p=L.ReactDebugCurrentFrame,m=p.getStackAddendum();m!==""&&(s+="%s",h=h.concat([m]));var w=h.map(function(b){return String(b)});w.unshift("Warning: "+s),Function.prototype.apply.call(console[t],console,w)}}var N=!1,lt=!1,_t=!1,Kt=!1,Qt=!1,_e;_e=Symbol.for("react.module.reference");function Dt(t){return!!(typeof t=="string"||typeof t=="function"||t===i||t===c||Qt||t===l||t===v||t===y||Kt||t===E||N||lt||_t||typeof t=="object"&&t!==null&&(t.$$typeof===C||t.$$typeof===_||t.$$typeof===f||t.$$typeof===g||t.$$typeof===d||t.$$typeof===_e||t.getModuleId!==void 0))}function Mt(t,s,h){var p=t.displayName;if(p)return p;var m=s.displayName||s.name||"";return m!==""?h+"("+m+")":h}function te(t){return t.displayName||"Context"}function rt(t){if(t==null)return null;if(typeof t.tag=="number"&&S("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case i:return"Fragment";case o:return"Portal";case c:return"Profiler";case l:return"StrictMode";case v:return"Suspense";case y:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case g:var s=t;return te(s)+".Consumer";case f:var h=t;return te(h._context)+".Provider";case d:return Mt(t,t.render,"ForwardRef");case _:var p=t.displayName||null;return p!==null?p:rt(t.type)||"Memo";case C:{var m=t,w=m._payload,b=m._init;try{return rt(b(w))}catch{return null}}}return null}var M=Object.assign,ht=0,J,ct,$t,ke,ee,Se,Te;function kt(){}kt.__reactDisabledLog=!0;function Ce(){{if(ht===0){J=console.log,ct=console.info,$t=console.warn,ke=console.error,ee=console.group,Se=console.groupCollapsed,Te=console.groupEnd;var t={configurable:!0,enumerable:!0,value:kt,writable:!0};Object.defineProperties(console,{info:t,log:t,warn:t,error:t,group:t,groupCollapsed:t,groupEnd:t})}ht++}}function er(){{if(ht--,ht===0){var t={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:M({},t,{value:J}),info:M({},t,{value:ct}),warn:M({},t,{value:$t}),error:M({},t,{value:ke}),group:M({},t,{value:ee}),groupCollapsed:M({},t,{value:Se}),groupEnd:M({},t,{value:Te})})}ht<0&&S("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var re=L.ReactCurrentDispatcher,ne;function zt(t,s,h){{if(ne===void 0)try{throw Error()}catch(m){var p=m.stack.trim().match(/\n( *(at )?)/);ne=p&&p[1]||""}return`
18
+ `+ne+t}}var ie=!1,St;{var rr=typeof WeakMap=="function"?WeakMap:Map;St=new rr}function oe(t,s){if(!t||ie)return"";{var h=St.get(t);if(h!==void 0)return h}var p;ie=!0;var m=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var w;w=re.current,re.current=null,Ce();try{if(s){var b=function(){throw Error()};if(Object.defineProperty(b.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(b,[])}catch(I){p=I}Reflect.construct(t,[],b)}else{try{b.call()}catch(I){p=I}t.call(b.prototype)}}else{try{throw Error()}catch(I){p=I}t()}}catch(I){if(I&&p&&typeof I.stack=="string"){for(var A=I.stack.split(`
19
+ `),R=p.stack.split(`
20
20
  `),k=A.length-1,O=R.length-1;k>=1&&O>=0&&A[k]!==R[O];)O--;for(;k>=1&&O>=0;k--,O--)if(A[k]!==R[O]){if(k!==1||O!==1)do if(k--,O--,O<0||A[k]!==R[O]){var D=`
21
- `+A[k].replace(" at new "," at ");return t.displayName&&D.includes("<anonymous>")&&(D=D.replace("<anonymous>",t.displayName)),typeof t=="function"&&Tt.set(t,D),D}while(k>=1&&O>=0);break}}}finally{ie=!1,re.current=w,er(),Error.prepareStackTrace=m}var U=t?t.displayName||t.name:"",$=U?zt(U):"";return typeof t=="function"&&Tt.set(t,$),$}function nr(t,o,u){return oe(t,!1)}function ir(t){var o=t.prototype;return!!(o&&o.isReactComponent)}function Nt(t,o,u){if(t==null)return"";if(typeof t=="function")return oe(t,ir(t));if(typeof t=="string")return zt(t);switch(t){case v:return zt("Suspense");case y:return zt("SuspenseList")}if(typeof t=="object")switch(t.$$typeof){case d:return nr(t.render);case _:return Nt(t.type,o,u);case C:{var g=t,m=g._payload,w=g._init;try{return Nt(w(m),o,u)}catch{}}}return""}var St=Object.prototype.hasOwnProperty,Oe={},Pe=L.ReactDebugCurrentFrame;function Bt(t){if(t){var o=t._owner,u=Nt(t.type,t._source,o?o.type:null);Pe.setExtraStackFrame(u)}else Pe.setExtraStackFrame(null)}function or(t,o,u,g,m){{var w=Function.call.bind(St);for(var b in t)if(w(t,b)){var A=void 0;try{if(typeof t[b]!="function"){var R=Error((g||"React class")+": "+u+" type `"+b+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof t[b]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw R.name="Invariant Violation",R}A=t[b](o,b,g,u,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(k){A=k}A&&!(A instanceof Error)&&(Bt(m),T("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",g||"React class",u,b,typeof A),Bt(null)),A instanceof Error&&!(A.message in Oe)&&(Oe[A.message]=!0,Bt(m),T("Failed %s type: %s",u,A.message),Bt(null))}}}var sr=Array.isArray;function se(t){return sr(t)}function W(t){{var o=typeof Symbol=="function"&&Symbol.toStringTag,u=o&&t[Symbol.toStringTag]||t.constructor.name||"Object";return u}}function ar(t){try{return Re(t),!1}catch{return!0}}function Re(t){return""+t}function ae(t){if(ar(t))return T("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",W(t)),Re(t)}var lt=L.ReactCurrentOwner,Ie={key:!0,ref:!0,__self:!0,__source:!0},Ht,Le,le;le={};function he(t){if(St.call(t,"ref")){var o=Object.getOwnPropertyDescriptor(t,"ref").get;if(o&&o.isReactWarning)return!1}return t.ref!==void 0}function lr(t){if(St.call(t,"key")){var o=Object.getOwnPropertyDescriptor(t,"key").get;if(o&&o.isReactWarning)return!1}return t.key!==void 0}function hr(t,o){if(typeof t.ref=="string"&&lt.current&&o&&lt.current.stateNode!==o){var u=rt(lt.current.type);le[u]||(T('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',rt(lt.current.type),t.ref),le[u]=!0)}}function ur(t,o){{var u=function(){Ht||(Ht=!0,T("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",o))};u.isReactWarning=!0,Object.defineProperty(t,"key",{get:u,configurable:!0})}}function ue(t,o){{var u=function(){Le||(Le=!0,T("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",o))};u.isReactWarning=!0,Object.defineProperty(t,"ref",{get:u,configurable:!0})}}var Fe=function(t,o,u,g,m,w,b){var A={$$typeof:e,type:t,key:o,ref:u,props:b,_owner:w};return A._store={},Object.defineProperty(A._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(A,"_self",{configurable:!1,enumerable:!1,writable:!1,value:g}),Object.defineProperty(A,"_source",{configurable:!1,enumerable:!1,writable:!1,value:m}),Object.freeze&&(Object.freeze(A.props),Object.freeze(A)),A};function Ct(t,o,u,g,m){{var w,b={},A=null,R=null;u!==void 0&&(ae(u),A=""+u),lr(o)&&(ae(o.key),A=""+o.key),he(o)&&(R=o.ref,hr(o,m));for(w in o)St.call(o,w)&&!Ie.hasOwnProperty(w)&&(b[w]=o[w]);if(t&&t.defaultProps){var k=t.defaultProps;for(w in k)b[w]===void 0&&(b[w]=k[w])}if(A||R){var O=typeof t=="function"?t.displayName||t.name||"Unknown":t;A&&ur(b,O),R&&ue(b,O)}return Fe(t,A,R,m,g,lt.current,b)}}var ce=L.ReactCurrentOwner,je=L.ReactDebugCurrentFrame;function dt(t){if(t){var o=t._owner,u=Nt(t.type,t._source,o?o.type:null);je.setExtraStackFrame(u)}else je.setExtraStackFrame(null)}var Z;Z=!1;function yt(t){return typeof t=="object"&&t!==null&&t.$$typeof===e}function Wt(){{if(ce.current){var t=rt(ce.current.type);if(t)return`
21
+ `+A[k].replace(" at new "," at ");return t.displayName&&D.includes("<anonymous>")&&(D=D.replace("<anonymous>",t.displayName)),typeof t=="function"&&St.set(t,D),D}while(k>=1&&O>=0);break}}}finally{ie=!1,re.current=w,er(),Error.prepareStackTrace=m}var W=t?t.displayName||t.name:"",$=W?zt(W):"";return typeof t=="function"&&St.set(t,$),$}function nr(t,s,h){return oe(t,!1)}function ir(t){var s=t.prototype;return!!(s&&s.isReactComponent)}function Nt(t,s,h){if(t==null)return"";if(typeof t=="function")return oe(t,ir(t));if(typeof t=="string")return zt(t);switch(t){case v:return zt("Suspense");case y:return zt("SuspenseList")}if(typeof t=="object")switch(t.$$typeof){case d:return nr(t.render);case _:return Nt(t.type,s,h);case C:{var p=t,m=p._payload,w=p._init;try{return Nt(w(m),s,h)}catch{}}}return""}var Tt=Object.prototype.hasOwnProperty,Oe={},Pe=L.ReactDebugCurrentFrame;function Bt(t){if(t){var s=t._owner,h=Nt(t.type,t._source,s?s.type:null);Pe.setExtraStackFrame(h)}else Pe.setExtraStackFrame(null)}function or(t,s,h,p,m){{var w=Function.call.bind(Tt);for(var b in t)if(w(t,b)){var A=void 0;try{if(typeof t[b]!="function"){var R=Error((p||"React class")+": "+h+" type `"+b+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof t[b]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw R.name="Invariant Violation",R}A=t[b](s,b,p,h,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(k){A=k}A&&!(A instanceof Error)&&(Bt(m),S("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",p||"React class",h,b,typeof A),Bt(null)),A instanceof Error&&!(A.message in Oe)&&(Oe[A.message]=!0,Bt(m),S("Failed %s type: %s",h,A.message),Bt(null))}}}var sr=Array.isArray;function se(t){return sr(t)}function U(t){{var s=typeof Symbol=="function"&&Symbol.toStringTag,h=s&&t[Symbol.toStringTag]||t.constructor.name||"Object";return h}}function ar(t){try{return Re(t),!1}catch{return!0}}function Re(t){return""+t}function ae(t){if(ar(t))return S("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",U(t)),Re(t)}var ut=L.ReactCurrentOwner,Ie={key:!0,ref:!0,__self:!0,__source:!0},Ht,Le,le;le={};function ue(t){if(Tt.call(t,"ref")){var s=Object.getOwnPropertyDescriptor(t,"ref").get;if(s&&s.isReactWarning)return!1}return t.ref!==void 0}function lr(t){if(Tt.call(t,"key")){var s=Object.getOwnPropertyDescriptor(t,"key").get;if(s&&s.isReactWarning)return!1}return t.key!==void 0}function ur(t,s){if(typeof t.ref=="string"&&ut.current&&s&&ut.current.stateNode!==s){var h=rt(ut.current.type);le[h]||(S('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',rt(ut.current.type),t.ref),le[h]=!0)}}function hr(t,s){{var h=function(){Ht||(Ht=!0,S("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",s))};h.isReactWarning=!0,Object.defineProperty(t,"key",{get:h,configurable:!0})}}function he(t,s){{var h=function(){Le||(Le=!0,S("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",s))};h.isReactWarning=!0,Object.defineProperty(t,"ref",{get:h,configurable:!0})}}var Fe=function(t,s,h,p,m,w,b){var A={$$typeof:e,type:t,key:s,ref:h,props:b,_owner:w};return A._store={},Object.defineProperty(A._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(A,"_self",{configurable:!1,enumerable:!1,writable:!1,value:p}),Object.defineProperty(A,"_source",{configurable:!1,enumerable:!1,writable:!1,value:m}),Object.freeze&&(Object.freeze(A.props),Object.freeze(A)),A};function Ct(t,s,h,p,m){{var w,b={},A=null,R=null;h!==void 0&&(ae(h),A=""+h),lr(s)&&(ae(s.key),A=""+s.key),ue(s)&&(R=s.ref,ur(s,m));for(w in s)Tt.call(s,w)&&!Ie.hasOwnProperty(w)&&(b[w]=s[w]);if(t&&t.defaultProps){var k=t.defaultProps;for(w in k)b[w]===void 0&&(b[w]=k[w])}if(A||R){var O=typeof t=="function"?t.displayName||t.name||"Unknown":t;A&&hr(b,O),R&&he(b,O)}return Fe(t,A,R,m,p,ut.current,b)}}var ce=L.ReactCurrentOwner,je=L.ReactDebugCurrentFrame;function dt(t){if(t){var s=t._owner,h=Nt(t.type,t._source,s?s.type:null);je.setExtraStackFrame(h)}else je.setExtraStackFrame(null)}var Z;Z=!1;function vt(t){return typeof t=="object"&&t!==null&&t.$$typeof===e}function Ut(){{if(ce.current){var t=rt(ce.current.type);if(t)return`
22
22
 
23
- Check the render method of \``+t+"`."}return""}}function cr(t){{if(t!==void 0){var o=t.fileName.replace(/^.*[\\\/]/,""),u=t.lineNumber;return`
23
+ Check the render method of \``+t+"`."}return""}}function cr(t){{if(t!==void 0){var s=t.fileName.replace(/^.*[\\\/]/,""),h=t.lineNumber;return`
24
24
 
25
- Check your code at `+o+":"+u+"."}return""}}var de={};function De(t){{var o=Wt();if(!o){var u=typeof t=="string"?t:t.displayName||t.name;u&&(o=`
25
+ Check your code at `+s+":"+h+"."}return""}}var de={};function De(t){{var s=Ut();if(!s){var h=typeof t=="string"?t:t.displayName||t.name;h&&(s=`
26
26
 
27
- Check the top-level render call using <`+u+">.")}return o}}function Me(t,o){{if(!t._store||t._store.validated||t.key!=null)return;t._store.validated=!0;var u=De(o);if(de[u])return;de[u]=!0;var g="";t&&t._owner&&t._owner!==ce.current&&(g=" It was passed a child from "+rt(t._owner.type)+"."),dt(t),T('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',u,g),dt(null)}}function Ut(t,o){{if(typeof t!="object")return;if(se(t))for(var u=0;u<t.length;u++){var g=t[u];yt(g)&&Me(g,o)}else if(yt(t))t._store&&(t._store.validated=!0);else if(t){var m=j(t);if(typeof m=="function"&&m!==t.entries)for(var w=m.call(t),b;!(b=w.next()).done;)yt(b.value)&&Me(b.value,o)}}}function dr(t){{var o=t.type;if(o==null||typeof o=="string")return;var u;if(typeof o=="function")u=o.propTypes;else if(typeof o=="object"&&(o.$$typeof===d||o.$$typeof===_))u=o.propTypes;else return;if(u){var g=rt(o);or(u,t.props,"prop",g,t)}else if(o.PropTypes!==void 0&&!Z){Z=!0;var m=rt(o);T("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",m||"Unknown")}typeof o.getDefaultProps=="function"&&!o.getDefaultProps.isReactClassApproved&&T("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function $e(t){{for(var o=Object.keys(t.props),u=0;u<o.length;u++){var g=o[u];if(g!=="children"&&g!=="key"){dt(t),T("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",g),dt(null);break}}t.ref!==null&&(dt(t),T("Invalid attribute `ref` supplied to `React.Fragment`."),dt(null))}}function fe(t,o,u,g,m,w){{var b=Dt(t);if(!b){var A="";(t===void 0||typeof t=="object"&&t!==null&&Object.keys(t).length===0)&&(A+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var R=cr(m);R?A+=R:A+=Wt();var k;t===null?k="null":se(t)?k="array":t!==void 0&&t.$$typeof===e?(k="<"+(rt(t.type)||"Unknown")+" />",A=" Did you accidentally export a JSX literal instead of a component?"):k=typeof t,T("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",k,A)}var O=Ct(t,o,u,m,w);if(O==null)return O;if(b){var D=o.children;if(D!==void 0)if(g)if(se(D)){for(var U=0;U<D.length;U++)Ut(D[U],t);Object.freeze&&Object.freeze(D)}else T("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ut(D,t)}return t===i?$e(O):dr(O),O}}function fr(t,o,u){return fe(t,o,u,!0)}function r(t,o,u){return fe(t,o,u,!1)}var n=r,a=fr;Xt.Fragment=i,Xt.jsx=n,Xt.jsxs=a}()),Xt}process.env.NODE_ENV==="production"?Be.exports=Xr():Be.exports=Gr();var Jr=Be.exports,Zr=Object.defineProperty,Kr=(h,e,s)=>e in h?Zr(h,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):h[e]=s,x=(h,e,s)=>(Kr(h,typeof e!="symbol"?e+"":e,s),s);let ye=(h=21)=>crypto.getRandomValues(new Uint8Array(h)).reduce((e,s)=>(s&=63,s<36?e+=s.toString(36):s<62?e+=(s-26).toString(36).toUpperCase():s>62?e+="-":e+="_",e),"");const Gt={strokeType:"plain",strokeColor:"black",strokeWidth:1,head:"none",tail:"none"},mr={id:0,type:"Feature",properties:{type:"arrow",style:{...Gt}},geometry:{type:"LineString",coordinates:[[0,0],[100,100]]}},Qr=(h=0,e=0,s=0,i=0,l={...Gt})=>({id:ye(),type:"Feature",properties:{type:"arrow",style:{...Gt,...l}},geometry:{type:"LineString",coordinates:[[h,e],[s,i]]}}),tn="http://www.w3.org/2000/svg";function Jt(h){return document.createElementNS(tn,h)}function br(h){return h.geometry.bbox||en(h),h.geometry.bbox}function gt(h){const e=br(h);return{width:e[2]-e[0],height:e[3]-e[1]}}function pt(h){const e=br(h);return{x:e[0],y:e[1]}}function en(h){const[e,s]=h.geometry.coordinates[0][0],[i,l]=h.geometry.coordinates[0][2];h.geometry.bbox=[e,s,i,l]}function rn(h,e,s,i,l){h.geometry.bbox=[e,s,e+i,s+l],h.geometry.coordinates=[[[e,s],[e+i,s],[e+i,s+l],[e,s+l],[e,s]]]}function Zt(h){const[e,s]=h.geometry.coordinates[0];return{x:e,y:s}}function ve(h,e){const[s,i]=h.geometry.coordinates[e==="start"?0:1];return{x:s,y:i}}function me(h){const[e,s]=h.geometry.coordinates[1];return{x:e,y:s}}function wr(h,e,s){h.geometry.coordinates[0]=[e,s]}function xr(h,e,s){h.geometry.coordinates[1]=[e,s]}function be(h){return{start:Zt(h),end:me(h)}}function Rt(h,e,s,i){e==="start"?wr(h,s,i):xr(h,s,i)}const Ar=h=>parseInt(h.getAttribute("data-handle-id")||"-1");function we(h,e,s){const i=Math.atan2(h.y-e.y,h.x-e.x);return{x:e.x+s*Math.cos(i),y:e.y+s*Math.sin(i)}}function He(h,e){if(!e)return{x:h.clientX,y:h.clientY};const s=e.getBoundingClientRect();return{x:h.clientX-s.left-e.clientLeft,y:h.clientY-s.top-e.clientTop}}const Et=(h,e)=>({x:h.x-e.x,y:h.y-e.y}),It=h=>Math.sqrt(h.x*h.x+h.y*h.y),Er=h=>({x:-h.x,y:-h.y}),_r=h=>{const e=It(h);return e===0?{x:0,y:0}:{x:h.x/e,y:h.y/e}},Lt=(h,e)=>({x:h.x+e.x,y:h.y+e.y}),kr=(h,e)=>({x:h.x*e,y:h.y*e}),xe=(h,e)=>({x:h.x*e.x,y:h.y*e.y}),st=(h,e)=>{const s=Math.sin(e),i=Math.cos(e);return{x:h.x*i-h.y*s,y:h.x*s+h.y*i}},nn=(h,e)=>({x:h.x/e,y:h.y/e}),Tr=(h,e)=>h.x*e.x+h.y*e.y;function Sr(h,e=5,s=30){var i;const{start:l,end:c}=be(h),f=Et(c,l),p=h.properties.style&&h.properties.style.strokeWidth?(i=h.properties.style)==null?void 0:i.strokeWidth:0;return Math.min(s,Math.max(3*p,It(f)*.1,e))}function Cr(h,e,s,i){const l=kr(Er(_r(e)),i);if(!s||s==="none")return"";const c=Lt(h,st(l,Math.PI/8)),f=Lt(h,st(l,-Math.PI/8)),p=`${h.x} ${h.y}`;return`M ${c.x} ${c.y} L ${p} ${f.x} ${f.y} ${s==="arrow"?"":`${c.x} ${c.y}`}`}function on(h,e,s,i,l){const{start:c,end:f}=be(h),{tail:p,head:d,strokeColor:v,strokeWidth:y}=h.properties.style||s,_=Et(f,c),C=Sr(h,i,l),E=Jt("path");E.setAttribute("data-annotation",`${h.id}`),E.setAttribute("data-annotation-type","arrow");const P=d==="arrow-plain"||p==="arrow";E.setAttribute("stroke",v||"none"),E.setAttribute("stroke-width",`${y}`),E.setAttribute("fill",P?v||"":"none"),E.setAttribute("stroke-linecap","round"),E.setAttribute("stroke-linejoin","round");const S=Cr(c,Er(_),p,C),j=Cr(f,_,d,C),L=S+`M ${c.x} ${c.y} ${f.x} ${f.y}`+j;E.setAttribute("d",L),e.appendChild(E)}const q=-1,Ae="dragging",Ee="dragstart",Ft="dragend",We="select",Ue="unselect",sn="hover",an="unhover",Ve="remove",Ye="add",ln="cancelDrawing",qe="update",hn="link";var un=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Or(h){return h&&h.__esModule&&Object.prototype.hasOwnProperty.call(h,"default")?h.default:h}var Pr={exports:{}};(function(h){var e=Object.prototype.hasOwnProperty,s="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(s=!1));function l(d,v,y){this.fn=d,this.context=v,this.once=y||!1}function c(d,v,y,_,C){if(typeof y!="function")throw new TypeError("The listener must be a function");var E=new l(y,_||d,C),P=s?s+v:v;return d._events[P]?d._events[P].fn?d._events[P]=[d._events[P],E]:d._events[P].push(E):(d._events[P]=E,d._eventsCount++),d}function f(d,v){--d._eventsCount===0?d._events=new i:delete d._events[v]}function p(){this._events=new i,this._eventsCount=0}p.prototype.eventNames=function(){var d=[],v,y;if(this._eventsCount===0)return d;for(y in v=this._events)e.call(v,y)&&d.push(s?y.slice(1):y);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(v)):d},p.prototype.listeners=function(d){var v=s?s+d:d,y=this._events[v];if(!y)return[];if(y.fn)return[y.fn];for(var _=0,C=y.length,E=new Array(C);_<C;_++)E[_]=y[_].fn;return E},p.prototype.listenerCount=function(d){var v=s?s+d:d,y=this._events[v];return y?y.fn?1:y.length:0},p.prototype.emit=function(d,v,y,_,C,E){var P=s?s+d:d;if(!this._events[P])return!1;var S=this._events[P],j=arguments.length,L,T;if(S.fn){switch(S.once&&this.removeListener(d,S.fn,void 0,!0),j){case 1:return S.fn.call(S.context),!0;case 2:return S.fn.call(S.context,v),!0;case 3:return S.fn.call(S.context,v,y),!0;case 4:return S.fn.call(S.context,v,y,_),!0;case 5:return S.fn.call(S.context,v,y,_,C),!0;case 6:return S.fn.call(S.context,v,y,_,C,E),!0}for(T=1,L=new Array(j-1);T<j;T++)L[T-1]=arguments[T];S.fn.apply(S.context,L)}else{var H=S.length,N;for(T=0;T<H;T++)switch(S[T].once&&this.removeListener(d,S[T].fn,void 0,!0),j){case 1:S[T].fn.call(S[T].context);break;case 2:S[T].fn.call(S[T].context,v);break;case 3:S[T].fn.call(S[T].context,v,y);break;case 4:S[T].fn.call(S[T].context,v,y,_);break;default:if(!L)for(N=1,L=new Array(j-1);N<j;N++)L[N-1]=arguments[N];S[T].fn.apply(S[T].context,L)}}return!0},p.prototype.on=function(d,v,y){return c(this,d,v,y,!1)},p.prototype.once=function(d,v,y){return c(this,d,v,y,!0)},p.prototype.removeListener=function(d,v,y,_){var C=s?s+d:d;if(!this._events[C])return this;if(!v)return f(this,C),this;var E=this._events[C];if(E.fn)E.fn===v&&(!_||E.once)&&(!y||E.context===y)&&f(this,C);else{for(var P=0,S=[],j=E.length;P<j;P++)(E[P].fn!==v||_&&!E[P].once||y&&E[P].context!==y)&&S.push(E[P]);S.length?this._events[C]=S.length===1?S[0]:S:f(this,C)}return this},p.prototype.removeAllListeners=function(d){var v;return d?(v=s?s+d:d,this._events[v]&&f(this,v)):(this._events=new i,this._eventsCount=0),this},p.prototype.off=p.prototype.removeListener,p.prototype.addListener=p.prototype.on,p.prefixed=s,p.EventEmitter=p,h.exports=p})(Pr);var cn=Pr.exports;const Rr=Or(cn);class Ir extends Rr{constructor(e,s){super(),x(this,"ogma"),x(this,"elements"),x(this,"layer"),x(this,"editor"),x(this,"selectedId",q),x(this,"hoveredId",q),x(this,"ogmaOptions"),x(this,"shouldDetect"),x(this,"isDragging"),x(this,"showeditorOnHover"),x(this,"_onKeyUp",i=>{i.code===27&&this.selectedId!==q?this.unselect():(i.code===46||i.code===8)&&this.selectedId!==q&&this._canRemove()&&this.remove(this.selectedId)}),x(this,"_onClickMouseMove",i=>{if(!i.domEvent||this.isDragging||!this.shouldDetect||i.domEvent.type!=="mousemove"&&i.domEvent.target&&i.domEvent.target.tagName==="a")return;const l=this.ogma.view.screenToGraphCoordinates(i),c=this.shouldDetect||!this.shouldDetect&&+this.selectedId>-1?this.detect(l,0):void 0;i.domEvent.type==="mousemove"?c?this.hover(c.id):this.hoveredId!==q&&this.unhover():c?this.select(c.id):this.selectedId!==q&&this.unselect()}),this.ogma=e,this.elements=[],this.shouldDetect=!0,this.isDragging=!1,this.showeditorOnHover=!0,this.ogmaOptions=e.getOptions(),e.events.on(["click","mousemove"],this._onClickMouseMove).on("keyup",this._onKeyUp).on("frame",()=>{this.refreshEditor(),this.refreshDrawing()}),this.layer=e.layers.addSVGLayer({draw:i=>this.draw(i)}),this.layer.moveToTop(),this.editor=e.layers.addLayer(s),this.editor.hide()}_canRemove(){return!0}add(e){const s=this.getDefaultOptions(),i=Object.assign(e,{id:e.id===void 0?ye():e.id,type:e.type,properties:{...s.properties,...e.properties||{},style:{...s.properties.style,...e.properties.style||{}}},geometry:{...s.geometry,...e.geometry}});return this.elements.push(i),this.layer.refresh(),this.emit(Ye,i),i}updateStyle(e,s){this.updateAnnotation(e,{properties:{style:s}})}updateGeometry(e,s){this.updateAnnotation(e,{geometry:s})}update(e,s){const i=this.getById(e);this.updateAnnotation(i,s)}updateAnnotation(e,s){if(!e)return;const i=e.id;Object.keys(s).forEach(l=>{if(l!=="id")if(l==="properties"){const c=s.properties||{style:{}};e.properties={...e.properties||{},...c||{},style:{...e.properties.style||{},...c.style||{}}}}else l==="geometry"?e.geometry={...e.geometry,...s.geometry}:e[l]=s[l]}),i===this.selectedId&&this.refreshEditor(),this.layer.refresh()}getById(e){const s=Number(e);for(let i=0;i<this.elements.length;i++){const l=this.elements[i];if(!(l.id!==e&&l.id!==s))return l}}select(e){const s=this.getById(e);s&&(this.editor.show(),this.selectedId=e,this.refreshEditor(),this.layer.refresh(),this.emit(We,s))}hover(e){const s=this.getById(e);s&&(this.showeditorOnHover&&this.editor.show(),this.hoveredId=e,this.refreshEditor(),this.layer.refresh(),this.emit(sn,s))}getSelectedFeature(){return this.selectedId===q?null:this.getById(this.selectedId)}unselect(){const e=this.getById(this.selectedId);return e&&this.emit(Ue,e),this.selectedId=q,this.hoveredId===q&&this.editor.hide(),this.layer.refresh(),this}unhover(){const e=this.getById(this.hoveredId);return this.emit(an,e),this.hoveredId=q,this.selectedId===q&&this.editor.hide(),this.layer.refresh(),this}remove(e){const s=this.getById(e);e===this.hoveredId&&this.unhover(),e===this.selectedId&&this.unselect(),this.elements=this.elements.filter(i=>i.id!==e),s&&this.emit(Ve,s),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 Lr="handle-line",Fr="handle-start",jr="handle-end";class dn extends Ir{constructor(e,s={}){super(e,`
27
+ Check the top-level render call using <`+h+">.")}return s}}function Me(t,s){{if(!t._store||t._store.validated||t.key!=null)return;t._store.validated=!0;var h=De(s);if(de[h])return;de[h]=!0;var p="";t&&t._owner&&t._owner!==ce.current&&(p=" It was passed a child from "+rt(t._owner.type)+"."),dt(t),S('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',h,p),dt(null)}}function Wt(t,s){{if(typeof t!="object")return;if(se(t))for(var h=0;h<t.length;h++){var p=t[h];vt(p)&&Me(p,s)}else if(vt(t))t._store&&(t._store.validated=!0);else if(t){var m=j(t);if(typeof m=="function"&&m!==t.entries)for(var w=m.call(t),b;!(b=w.next()).done;)vt(b.value)&&Me(b.value,s)}}}function dr(t){{var s=t.type;if(s==null||typeof s=="string")return;var h;if(typeof s=="function")h=s.propTypes;else if(typeof s=="object"&&(s.$$typeof===d||s.$$typeof===_))h=s.propTypes;else return;if(h){var p=rt(s);or(h,t.props,"prop",p,t)}else if(s.PropTypes!==void 0&&!Z){Z=!0;var m=rt(s);S("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",m||"Unknown")}typeof s.getDefaultProps=="function"&&!s.getDefaultProps.isReactClassApproved&&S("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function $e(t){{for(var s=Object.keys(t.props),h=0;h<s.length;h++){var p=s[h];if(p!=="children"&&p!=="key"){dt(t),S("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",p),dt(null);break}}t.ref!==null&&(dt(t),S("Invalid attribute `ref` supplied to `React.Fragment`."),dt(null))}}function fe(t,s,h,p,m,w){{var b=Dt(t);if(!b){var A="";(t===void 0||typeof t=="object"&&t!==null&&Object.keys(t).length===0)&&(A+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var R=cr(m);R?A+=R:A+=Ut();var k;t===null?k="null":se(t)?k="array":t!==void 0&&t.$$typeof===e?(k="<"+(rt(t.type)||"Unknown")+" />",A=" Did you accidentally export a JSX literal instead of a component?"):k=typeof t,S("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",k,A)}var O=Ct(t,s,h,m,w);if(O==null)return O;if(b){var D=s.children;if(D!==void 0)if(p)if(se(D)){for(var W=0;W<D.length;W++)Wt(D[W],t);Object.freeze&&Object.freeze(D)}else S("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Wt(D,t)}return t===i?$e(O):dr(O),O}}function fr(t,s,h){return fe(t,s,h,!0)}function r(t,s,h){return fe(t,s,h,!1)}var n=r,a=fr;qt.Fragment=i,qt.jsx=n,qt.jsxs=a}()),qt}process.env.NODE_ENV==="production"?Be.exports=qr():Be.exports=Xr();var Jr=Be.exports,Zr=Object.defineProperty,Kr=(u,e,o)=>e in u?Zr(u,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):u[e]=o,x=(u,e,o)=>(Kr(u,typeof e!="symbol"?e+"":e,o),o);let ye=(u=21)=>crypto.getRandomValues(new Uint8Array(u)).reduce((e,o)=>(o&=63,o<36?e+=o.toString(36):o<62?e+=(o-26).toString(36).toUpperCase():o>62?e+="-":e+="_",e),"");const Xt={strokeType:"plain",strokeColor:"black",strokeWidth:1,head:"none",tail:"none"},mr={id:0,type:"Feature",properties:{type:"arrow",style:{...Xt}},geometry:{type:"LineString",coordinates:[[0,0],[100,100]]}},Qr=(u=0,e=0,o=0,i=0,l={...Xt})=>({id:ye(),type:"Feature",properties:{type:"arrow",style:{...Xt,...l}},geometry:{type:"LineString",coordinates:[[u,e],[o,i]]}}),tn="http://www.w3.org/2000/svg";function Jt(u){return document.createElementNS(tn,u)}function br(u){return u.geometry.bbox||en(u),u.geometry.bbox}function gt(u){const e=br(u);return{width:e[2]-e[0],height:e[3]-e[1]}}function pt(u){const e=br(u);return{x:e[0],y:e[1]}}function en(u){const[e,o]=u.geometry.coordinates[0][0],[i,l]=u.geometry.coordinates[0][2];u.geometry.bbox=[e,o,i,l]}function rn(u,e,o,i,l){u.geometry.bbox=[e,o,e+i,o+l],u.geometry.coordinates=[[[e,o],[e+i,o],[e+i,o+l],[e,o+l],[e,o]]]}function Zt(u){const[e,o]=u.geometry.coordinates[0];return{x:e,y:o}}function ve(u,e){const[o,i]=u.geometry.coordinates[e==="start"?0:1];return{x:o,y:i}}function me(u){const[e,o]=u.geometry.coordinates[1];return{x:e,y:o}}function wr(u,e,o){u.geometry.coordinates[0]=[e,o]}function xr(u,e,o){u.geometry.coordinates[1]=[e,o]}function be(u){return{start:Zt(u),end:me(u)}}function Rt(u,e,o,i){e==="start"?wr(u,o,i):xr(u,o,i)}const Ar=u=>parseInt(u.getAttribute("data-handle-id")||"-1");function nn(u){return Array.isArray(u)&&u.length===2&&u.every(isFinite)}function on(u,e,o,i){for(let l=0;l<u.coordinates.length;l++){const c=u.coordinates[l];if(nn(c))c[0]=o+(c[0]-o)*e,c[1]=i+(c[1]-i)*e;else for(let f=0;f<c.length;f++){const g=c[f];g[0]=o+(g[0]-o)*e,g[1]=i+(g[1]-i)*e}}return u}function we(u,e,o){const i=Math.atan2(u.y-e.y,u.x-e.x);return{x:e.x+o*Math.cos(i),y:e.y+o*Math.sin(i)}}function He(u,e){if(!e)return{x:u.clientX,y:u.clientY};const o=e.getBoundingClientRect();return{x:u.clientX-o.left-e.clientLeft,y:u.clientY-o.top-e.clientTop}}const Et=(u,e)=>({x:u.x-e.x,y:u.y-e.y}),It=u=>Math.sqrt(u.x*u.x+u.y*u.y),Er=u=>({x:-u.x,y:-u.y}),_r=u=>{const e=It(u);return e===0?{x:0,y:0}:{x:u.x/e,y:u.y/e}},Lt=(u,e)=>({x:u.x+e.x,y:u.y+e.y}),kr=(u,e)=>({x:u.x*e,y:u.y*e}),xe=(u,e)=>({x:u.x*e.x,y:u.y*e.y}),st=(u,e)=>{const o=Math.sin(e),i=Math.cos(e);return{x:u.x*i-u.y*o,y:u.x*o+u.y*i}},sn=(u,e)=>({x:u.x/e,y:u.y/e}),Sr=(u,e)=>u.x*e.x+u.y*e.y;function Tr(u,e=5,o=30){var i;const{start:l,end:c}=be(u),f=Et(c,l),g=u.properties.style&&u.properties.style.strokeWidth?(i=u.properties.style)==null?void 0:i.strokeWidth:0;return Math.min(o,Math.max(3*g,It(f)*.1,e))}function Cr(u,e,o,i){const l=kr(Er(_r(e)),i);if(!o||o==="none")return"";const c=Lt(u,st(l,Math.PI/8)),f=Lt(u,st(l,-Math.PI/8)),g=`${u.x} ${u.y}`;return`M ${c.x} ${c.y} L ${g} ${f.x} ${f.y} ${o==="arrow"?"":`${c.x} ${c.y}`}`}function an(u,e,o,i,l){const{start:c,end:f}=be(u),{tail:g,head:d,strokeColor:v,strokeWidth:y}=u.properties.style||o,_=Et(f,c),C=Tr(u,i,l),E=Jt("path");E.setAttribute("data-annotation",`${u.id}`),E.setAttribute("data-annotation-type","arrow");const P=d==="arrow-plain"||g==="arrow";E.setAttribute("stroke",v||"none"),E.setAttribute("stroke-width",`${y}`),E.setAttribute("fill",P?v||"":"none"),E.setAttribute("stroke-linecap","round"),E.setAttribute("stroke-linejoin","round");const T=Cr(c,Er(_),g,C),j=Cr(f,_,d,C),L=T+`M ${c.x} ${c.y} ${f.x} ${f.y}`+j;E.setAttribute("d",L),e.appendChild(E)}const G=-1,Ae="dragging",Ee="dragstart",Ft="dragend",Ue="select",We="unselect",ln="hover",un="unhover",Ve="remove",Ye="add",hn="cancelDrawing",Ge="update",cn="link";var dn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Or(u){return u&&u.__esModule&&Object.prototype.hasOwnProperty.call(u,"default")?u.default:u}var Pr={exports:{}};(function(u){var e=Object.prototype.hasOwnProperty,o="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(o=!1));function l(d,v,y){this.fn=d,this.context=v,this.once=y||!1}function c(d,v,y,_,C){if(typeof y!="function")throw new TypeError("The listener must be a function");var E=new l(y,_||d,C),P=o?o+v:v;return d._events[P]?d._events[P].fn?d._events[P]=[d._events[P],E]:d._events[P].push(E):(d._events[P]=E,d._eventsCount++),d}function f(d,v){--d._eventsCount===0?d._events=new i:delete d._events[v]}function g(){this._events=new i,this._eventsCount=0}g.prototype.eventNames=function(){var d=[],v,y;if(this._eventsCount===0)return d;for(y in v=this._events)e.call(v,y)&&d.push(o?y.slice(1):y);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(v)):d},g.prototype.listeners=function(d){var v=o?o+d:d,y=this._events[v];if(!y)return[];if(y.fn)return[y.fn];for(var _=0,C=y.length,E=new Array(C);_<C;_++)E[_]=y[_].fn;return E},g.prototype.listenerCount=function(d){var v=o?o+d:d,y=this._events[v];return y?y.fn?1:y.length:0},g.prototype.emit=function(d,v,y,_,C,E){var P=o?o+d:d;if(!this._events[P])return!1;var T=this._events[P],j=arguments.length,L,S;if(T.fn){switch(T.once&&this.removeListener(d,T.fn,void 0,!0),j){case 1:return T.fn.call(T.context),!0;case 2:return T.fn.call(T.context,v),!0;case 3:return T.fn.call(T.context,v,y),!0;case 4:return T.fn.call(T.context,v,y,_),!0;case 5:return T.fn.call(T.context,v,y,_,C),!0;case 6:return T.fn.call(T.context,v,y,_,C,E),!0}for(S=1,L=new Array(j-1);S<j;S++)L[S-1]=arguments[S];T.fn.apply(T.context,L)}else{var H=T.length,N;for(S=0;S<H;S++)switch(T[S].once&&this.removeListener(d,T[S].fn,void 0,!0),j){case 1:T[S].fn.call(T[S].context);break;case 2:T[S].fn.call(T[S].context,v);break;case 3:T[S].fn.call(T[S].context,v,y);break;case 4:T[S].fn.call(T[S].context,v,y,_);break;default:if(!L)for(N=1,L=new Array(j-1);N<j;N++)L[N-1]=arguments[N];T[S].fn.apply(T[S].context,L)}}return!0},g.prototype.on=function(d,v,y){return c(this,d,v,y,!1)},g.prototype.once=function(d,v,y){return c(this,d,v,y,!0)},g.prototype.removeListener=function(d,v,y,_){var C=o?o+d:d;if(!this._events[C])return this;if(!v)return f(this,C),this;var E=this._events[C];if(E.fn)E.fn===v&&(!_||E.once)&&(!y||E.context===y)&&f(this,C);else{for(var P=0,T=[],j=E.length;P<j;P++)(E[P].fn!==v||_&&!E[P].once||y&&E[P].context!==y)&&T.push(E[P]);T.length?this._events[C]=T.length===1?T[0]:T:f(this,C)}return this},g.prototype.removeAllListeners=function(d){var v;return d?(v=o?o+d:d,this._events[v]&&f(this,v)):(this._events=new i,this._eventsCount=0),this},g.prototype.off=g.prototype.removeListener,g.prototype.addListener=g.prototype.on,g.prefixed=o,g.EventEmitter=g,u.exports=g})(Pr);var fn=Pr.exports;const Rr=Or(fn);class Ir extends Rr{constructor(e,o){super(),x(this,"ogma"),x(this,"elements"),x(this,"layer"),x(this,"editor"),x(this,"selectedId",G),x(this,"hoveredId",G),x(this,"ogmaOptions"),x(this,"shouldDetect"),x(this,"isDragging"),x(this,"showeditorOnHover"),x(this,"_onKeyUp",i=>{i.code===27&&this.selectedId!==G?this.unselect():(i.code===46||i.code===8)&&this.selectedId!==G&&this._canRemove()&&this.remove(this.selectedId)}),x(this,"_onClickMouseMove",i=>{if(!i.domEvent||this.isDragging||!this.shouldDetect||i.domEvent.type!=="mousemove"&&i.domEvent.target&&i.domEvent.target.tagName==="a")return;const l=this.ogma.view.screenToGraphCoordinates(i),c=this.shouldDetect||!this.shouldDetect&&+this.selectedId>-1?this.detect(l,0):void 0;i.domEvent.type==="mousemove"?c?this.hover(c.id):this.hoveredId!==G&&this.unhover():c?this.select(c.id):this.selectedId!==G&&this.unselect()}),this.ogma=e,this.elements=[],this.shouldDetect=!0,this.isDragging=!1,this.showeditorOnHover=!0,this.ogmaOptions=e.getOptions(),e.events.on(["click","mousemove"],this._onClickMouseMove).on("keyup",this._onKeyUp).on("frame",()=>{this.refreshEditor(),this.refreshDrawing()}),this.layer=e.layers.addSVGLayer({draw:i=>this.draw(i)}),this.layer.moveToTop(),this.editor=e.layers.addLayer(o),this.editor.hide()}_canRemove(){return!0}add(e){const o=this.getDefaultOptions(),i=Object.assign(e,{id:e.id===void 0?ye():e.id,type:e.type,properties:{...o.properties,...e.properties||{},style:{...o.properties.style,...e.properties.style||{}}},geometry:{...o.geometry,...e.geometry}});return this.elements.push(i),this.layer.refresh(),this.emit(Ye,i),i}updateStyle(e,o){this.updateAnnotation(e,{properties:{style:o}})}updateGeometry(e,o){this.updateAnnotation(e,{geometry:o})}scale(e,o,i,l){this.updateGeometry(e,on(e.geometry,o,i,l))}update(e,o){const i=this.getById(e);this.updateAnnotation(i,o)}updateAnnotation(e,o){if(!e)return;const i=e.id;Object.keys(o).forEach(l=>{if(l!=="id")if(l==="properties"){const c=o.properties||{style:{}};e.properties={...e.properties||{},...c||{},style:{...e.properties.style||{},...c.style||{}}}}else l==="geometry"?e.geometry={...e.geometry,...o.geometry}:e[l]=o[l]}),i===this.selectedId&&this.refreshEditor(),this.layer.refresh()}getById(e){const o=Number(e);for(let i=0;i<this.elements.length;i++){const l=this.elements[i];if(!(l.id!==e&&l.id!==o))return l}}select(e){const o=this.getById(e);o&&(this.editor.show(),this.selectedId=e,this.refreshEditor(),this.layer.refresh(),this.emit(Ue,o))}hover(e){const o=this.getById(e);o&&(this.showeditorOnHover&&this.editor.show(),this.hoveredId=e,this.refreshEditor(),this.layer.refresh(),this.emit(ln,o))}getSelectedFeature(){return this.selectedId===G?null:this.getById(this.selectedId)}unselect(){const e=this.getById(this.selectedId);return e&&this.emit(We,e),this.selectedId=G,this.hoveredId===G&&this.editor.hide(),this.layer.refresh(),this}unhover(){const e=this.getById(this.hoveredId);return this.emit(un,e),this.hoveredId=G,this.selectedId===G&&this.editor.hide(),this.layer.refresh(),this}remove(e){const o=this.getById(e);e===this.hoveredId&&this.unhover(),e===this.selectedId&&this.unselect(),this.elements=this.elements.filter(i=>i.id!==e),o&&this.emit(Ve,o),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 Lr="handle-line",Fr="handle-start",jr="handle-end";class gn extends Ir{constructor(e,o={}){super(e,`
28
28
  <div class="arrow-handle">
29
29
  <div id="${Lr}" data-handle-id="0" class="handle line"></div>
30
30
  <div id="${Fr}" data-handle-id="1" class="handle point"></div>
31
31
  <div id="${jr}" data-handle-id="2" class="handle point"></div>
32
32
  </div>
33
- `),x(this,"draggedHandle",q),x(this,"start",{x:0,y:0}),x(this,"end",{x:0,y:0}),x(this,"arrow",{...mr}),x(this,"startX",0),x(this,"startY",0),x(this,"minArrowHeight",0),x(this,"maxArrowHeight",0),x(this,"handles",[]),x(this,"onHandleMouseDown",i=>{const l=this.getById(this.selectedId)||this.getById(this.hoveredId);if(!l)return;const{x:c,y:f}=He(i,this.ogma.getContainer());this.startDragging(l,c,f),this.draggedHandle=Ar(i.target)}),x(this,"onMouseUp",()=>{this.draggedHandle!==-1&&(this.restoreDragging(),this.isDragging=!1,this.draggedHandle=q,this.emit(Ft,this.arrow))}),x(this,"onMouseMove",i=>{if(!this.isDragging||this.draggedHandle===q)return;const l=this.handles[this.draggedHandle],c=this.ogma.view.getAngle(),{x:f,y:p}=st(nn({x:i.clientX-this.startX,y:i.clientY-this.startY},this.ogma.view.getZoom()),c),d=l.id===Lr,v=l.id===Fr,y=l.id===jr;(d||v)&&wr(this.arrow,this.start.x+f,this.start.y+p),(d||y)&&xr(this.arrow,this.end.x+f,this.end.y+p),this.emit(Ae,this.arrow,d?"line":v?"start":"end"),this.refreshEditor(),this.layer.refresh()}),this.minArrowHeight=s.minArrowHeight||0,this.maxArrowHeight=s.maxArrowHeight||1e6,this.handles=Array.prototype.slice.call(this.editor.element.querySelectorAll(".arrow-handle>.handle")),this.handles.forEach(i=>i.addEventListener("mousedown",this.onHandleMouseDown)),document.addEventListener("mousemove",this.onMouseMove,!0),document.addEventListener("mouseup",this.onMouseUp)}startDrawing(e,s,i=Qr(e,s,e,s,Gt)){var l;this.disableDragging(),this.add(i),this.hoveredId=i.id;const c=this.ogma.view.graphToScreenCoordinates({x:e,y:s}),f=((l=this.ogma.getContainer())==null?void 0:l.getBoundingClientRect())||{left:0,top:0};this.startDragging(this.getById(i.id),c.x+(f==null?void 0:f.left),c.y+f.top),this.draggedHandle=2}cancelDrawing(){this.isDragging&&(this.remove(this.arrow.id),this.emit(Ft,this.arrow),this.restoreDragging(),this.isDragging=!1,this.draggedHandle=q)}startDragging(e,s,i){this.selectedId!==e.id&&this.select(this.hoveredId),this.arrow=e,this.startX=s,this.startY=i,this.start=Zt(this.arrow),this.end=me(this.arrow),this.disableDragging(),this.emit(Ee,this.arrow),this.isDragging=!0}detect(e,s=0){return this.elements.find(i=>{const{start:l,end:c}=be(i),f=Et(e,{x:(l.x+c.x)/2,y:(l.y+c.y)/2}),p=Et(c,l),d=It(p),v=_r(p),y=Sr(i);return Math.abs(Tr(v,f))<d/2+s&&Math.abs(Tr(st(v,Math.PI/2),f))<y/2+s})}refreshEditor(){if(+this.selectedId<0&&+this.hoveredId<0)return;const e=this.selectedId!==q?this.getById(this.selectedId):this.getById(this.hoveredId),s=be(e),i=this.ogma.view.graphToScreenCoordinates(s.start),l=this.ogma.view.graphToScreenCoordinates(s.end),[c,f,p]=Array.prototype.slice.call(this.editor.element.querySelectorAll(".handle"));f.style.transform=`translate(${i.x}px, ${i.y}px) translate(-50%, -50%)`,p.style.transform=`translate(${l.x}px, ${l.y}px) translate(-50%, -50%)`;const d={x:(l.x+i.x)/2,y:(l.y+i.y)/2},v=Et(l,i),y=kr(v,1/It(v)),_=Math.atan2(y.y,y.x);c.style.width=`${It(v)}px`,c.style.left=`${d.x}px`,c.style.top=`${d.y}px`,c.style.transform=`translate(-50%, -50%) rotate(${_}rad)`}getDefaultOptions(){return mr}draw(e){e.innerHTML="";const s=Jt("g"),i=this.ogma.view.getAngle();s.setAttribute("transform",`rotate(${-i*(180/Math.PI)})`),this.elements.forEach(l=>on(l,s,Gt,this.minArrowHeight,this.maxArrowHeight)),e.appendChild(s)}refreshDrawing(){const e=this.ogma.view.getAngle();this.layer.element.children[0].setAttribute("transform",`rotate(${-e*(180/Math.PI)})`)}destroy(){super.destroy(),document.removeEventListener("mousemove",this.onMouseMove,!0),document.removeEventListener("mouseup",this.onMouseUp)}}const jt={font:"sans-serif",fontSize:12,color:"black",background:"",strokeWidth:1,strokeColor:"#000",strokeType:"plain"},Xe={id:0,type:"Feature",properties:{type:"text",content:"",style:{...jt}},geometry:{type:"Polygon",coordinates:[[[0,0],[100,0],[100,50],[0,50],[0,0]]]}},Dr={handleSize:3.5,placeholder:"Your text..."},fn=(h=0,e=0,s=100,i=50,l="",c={...jt})=>({id:ye(),type:"Feature",properties:{type:"text",content:l,style:{...jt,...c}},geometry:{type:"Polygon",coordinates:[[[h,e],[h+s,e],[h+s,e+i],[h,e+i],[h,e]]]}});var Mr={exports:{}};(function(h,e){(function(s,i){h.exports=i()})(un,()=>(()=>{var s={d:(r,n)=>{for(var a in n)s.o(n,a)&&!s.o(r,a)&&Object.defineProperty(r,a,{enumerable:!0,get:n[a]})},o:(r,n)=>Object.prototype.hasOwnProperty.call(r,n)},i={};function l(r){return l=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},l(r)}s.d(i,{default:()=>fr});var c=/^((?:[a-z\d-]+\s+)*)([\d.]+(%|em|px)|(?:x+-)?large|(?:x+-)?small|medium)(?:\s*\/\s*(normal|[\d.]+(%|px|em)?))?(\s.+)?$/,f=/\bsmall-caps\b/,p=/\b(?:italic|oblique)\b/,d=/\bbold(?:er)?\b/,v=13.3333333,y={"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 _(r){var n="",a=this;return a.style&&a.style!=="normal"&&(n+=a.style),a.variant&&a.variant!=="normal"&&(n+=(n?" ":"")+a.variant),a.weight&&a.weight!=="normal"&&(n+=(n?" ":"")+a.weight),a.size&&(n+=(n?" ":"")+a.size+"px",a.height!==a.size&&(n+="/"+a.height+"px")),a.family&&(n+=(n?" ":"")+a.family),r&&(n+="::"+a.baseline),r&&(n+="::"+a.color),n}var C={id:"",family:"sans-serif",height:14,size:12,variant:"",style:"",weight:"",baseline:"",color:null,toString:_,valueOf:_};function E(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=c.exec(r);n.family=(a[6]||"").trim();var t=y[a[2]]||parseFloat(a[2]);a[3]==="%"?t*=.16:a[3]==="em"?t*=16:a[3]==="pt"&&(t*=v),n.size=t;var o=parseFloat(a[4]);if(o!=="normal"&&o!=="inherit"&&o?a[5]&&a[5]!=="em"?a[5]==="pt"?n.height=o*v:a[5]==="%"?n.height=.01*t:n.height=o:n.height=o*t:n.height=Math.round(t*(7/6)),f.test(a[1])&&(n.variant="small-caps"),p.test(a[1])&&(n.style="italic"),d.test(a[1]))n.weight="bold";else{var u=parseInt(/\b(\d+)\b/.exec(a[1]),10);u>=100&&u!==400&&(n.weight=u)}return n}function P(){var r,n,a,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"12px/14px sans-serif",o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u=14,g=12,m=null,w=null,b="";if(t&&t.nodeType){var A=t&&(t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView),R=A.getComputedStyle(t,null);r=R.getPropertyValue("font-family")||"",g=parseFloat(R.getPropertyValue("font-size")),u=R.getPropertyValue("line-height"),m=R.getPropertyValue("font-weight"),w=R.getPropertyValue("font-style"),b=R.getPropertyValue("font-variant")||""}else if(typeof t=="string"){var k=E(t);r=k.family,g=k.size,u=k.height,b=k.variant,w=k.style,m=k.weight}else l(t)==="object"&&(r=t.family,g=t.size,u=t.height,b=t.variant,m=t.weight,w=t.style,n=t.baseline,a=t.color);o.size&&o.size<3&&(g*=o.size),u=u!=="normal"&&u?parseFloat(u):g*(7/6),o.height&&o.height<3&&(u*=o.height);var O=Object.create(C);return O.family=o.family||r||"sans-serif",O.height=u??14,O.size=g??12,O.variant=o.variant||b||"",O.style=o.style||w||"",O.weight=o.weight||m||"",O.baseline=n||0,o.baseline!=null&&(O.baseline=o.baseline),O.color=o.color||a||"",O.id=_.call(O,!0),O}const S={"\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 j,L=function(r){var n=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(100,100)||r&&r.createElement("canvas");if(n&&n.getContext){var a=n.getContext("2d");if(a&&typeof a.measureText=="function")return function(t,o){return a.font=String(o),a.measureText(t).width}}}(typeof document<"u"?document:null)||(j={},function(r,n){if(!j[n]){var a=P(n);j[n]=a,/\bmonospace\b/.test(a.family)?a.size*=.6:(a.size*=.45,a.weight&&(a.size*=1.18))}return r.length*j[n].size}),T={},H={trim:!0,collapse:!0};function N(r,n,a){var t=Object.assign({},H,a),o=String(r);if(!o)return 0;if(o in S){var u=n.id+"/"+o;return u in T||(T[u]=L("_".concat(o,"_"),n)-L("__",n)),T[u]}return t.trim&&t.collapse?t.trim?o=o.trim():t.collapse&&(o=o.replace(/\s+/g," ")):o=o.replace(/\n/g," "),L(o,n)+n.size*(r.tracking||0)}function at(r){return at=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},at(r)}function _t(r,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(n&&n.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),n&&Kt(r,n)}function Kt(r,n){return Kt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,t){return a.__proto__=t,a},Kt(r,n)}function Qt(r){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 a,t=Dt(r);if(n){var o=Dt(this).constructor;a=Reflect.construct(t,arguments,o)}else a=t.apply(this,arguments);return _e(this,a)}}function _e(r,n){if(n&&(at(n)==="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(a){if(a===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}(r)}function Dt(r){return Dt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Dt(r)}function Mt(r,n){if(!(r instanceof n))throw new TypeError("Cannot call a class as a function")}function te(r,n){for(var a=0;a<n.length;a++){var t=n[a];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,(o=function(u,g){if(at(u)!=="object"||u===null)return u;var m=u[Symbol.toPrimitive];if(m!==void 0){var w=m.call(u,g);if(at(w)!=="object")return w;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(u)}(t.key,"string"),at(o)==="symbol"?o:String(o)),t)}var o}function rt(r,n,a){return n&&te(r.prototype,n),a&&te(r,a),Object.defineProperty(r,"prototype",{writable:!1}),r}var M=function(){function r(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";Mt(this,r),this.value=n,this.weight=null,this.style=null,this.font=null,this.href=null,this.sub=!1,this.sup=!1}return rt(r,[{key:"clone",value:function(){var n=new r(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}}]),r}(),ut=function(r){_t(a,r);var n=Qt(a);function a(){return Mt(this,a),n.apply(this,arguments)}return rt(a)}(M),J=function(r){_t(a,r);var n=Qt(a);function a(){return Mt(this,a),n.apply(this,arguments)}return rt(a)}(M),ct=function(r){_t(a,r);var n=Qt(a);function a(){return Mt(this,a),n.apply(this,arguments)}return rt(a)}(M),$t=/^[\n\r\t\x20\xA0\u2000-\u200B\u205F\u3000]/,ke=/^[^\n\r\t\u0020\u2000-\u200B\u205F\u3000]{2,}/,ee=/^[\xA0\u2011\u202F\u2060\uFEFF]/,Te=/^(?:[;\xAD%?…]|,(?!\d))/,Se=/^[´±°¢£¤$¥\u2212]/;function kt(r,n){n!==!1&&(r=r.trim());for(var a,t,o=[],u=r.charAt(0),g=0,m=1,w=r.length;m<w;m++){a=r.charAt(m),t=r.charAt(m+1);var b=$t.test(u),A=$t.test(a),R=A||b,k=void 0;if((Se.test(a)&&!ee.test(u)||Te.test(u+t)&&!ee.test(a))&&(R=!0),u!=="-"&&u!=="‐"&&u!=="–"&&u!=="—"||((k=$t.test(r.charAt(m-2)))&&!A&&(R=!1),!k&&ke.test(a+t)&&(R=!0)),R){var O=r.slice(g,m);/\u00AD$/.test(O)?(o.push(new M(O.slice(0,-1))),o.push(new ct)):(o.push(new M(O)),o.push(new ut)),g=m}u=a}return o.push(new M(r.slice(g))),o}const Ce={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 er=/^[\n\r\x20\u2000-\u200B\u205F\u3000]/,re=/^<\/([a-zA-Z0-9]+)([^>]*)>/,ne=/^<([a-zA-Z0-9]+)((?:\s[^=\s/]+(?:\s*=\s*(?:"[^"]+"|'[^']+'|[^>\\s]+))?)+)?\s*(\/?)>(\n*)/,zt=/^<!--(.+?)-->/,ie=/&(?:#(\d\d{2,})|#x([\da-fA-F]{2,})|([a-zA-Z][a-zA-Z1-4]{1,8}));/g,Tt={b:function(r){r.weight="bold"},strong:function(r){r.weight="bold"},i:function(r){r.style="italic"},em:function(r){r.style="italic"},dfn:function(r){r.style="italic"},cite:function(r){r.style="italic"},code:function(r){r.family="monospace"},kbd:function(r){r.family="monospace"},samp:function(r){r.family="monospace"},var:function(r){r.family="monospace"},tt:function(r){r.family="monospace"},sub:function(r){r.sub=!0},sup:function(r){r.sup=!0}},rr={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 oe(r){return r.replace(ie,function(n,a,t,o){if(a||t){var u=a?10:16;return String.fromCharCode(parseInt(a||t,u))}return o in Ce?Ce[o]:n})}function nr(r){return r&&r.length>1&&(r[0]==='"'&&r[r.length-1]==='"'||r[0]==="'"&&r[r.length-1]==="'")?r.slice(1,-1):r}var ir=/^\s*([^=\s&]+)(?:\s*=\s*("[^"]+"|'[^']+'|[^>\s]+))?/;function Nt(r){var n,a={};if(r){do if(n=ir.exec(r)){var t=oe(nr(n[2]||"")).replace(/[ \r\n\t]+/g," ").trim();if(a[n[1]]=t,(r=r.slice(n[0].length)).length&&/^\S/.test(r[0]))throw new Error("Attribute error")}while(n&&r.length);if(/\S/.test(r))throw new Error("Attribute error")}return a}const St={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 Oe=/^(\^|_|\\[^#$%&~_^\\{}()\s]+)(\{)?/,Pe=/^%[^\n]+(?:\n|$)/,Bt=/^[^#$%&~_^\\{}]+/,or=/^\\([&{}$%#_])/,sr=/(?:\\[\\@,!:;-]|-{2,3}|[!?]`|``?|,,|''?|~|<<|>>)/g,se={"---":"—","--":"–","!`":"¡","?`":"¿","``":"“",",,":"„","''":"”","`":"‘","'":"’","<<":"«",">>":"»","~":" ","\\-":"­","\\,":" ","\\;":" ","\\:":" ","\\!":" ","\\@":"\uFEFF","\\\\":"\\newline{}"},W={bf:function(r){r.weight="bold"},it:function(r){r.style="italic"},sl:function(r){r.style="italic"},color:function(r,n){r.color=n},href:function(r,n){r.href=n},"^":function(r){r.sup=!0},_:function(r){r.sub=!0},par:function(r){this.tokens.push(new J,new J)},newline:function(r){this.tokens.push(new J)},url:function(r,n){this.open_context().href=n,this.add_token(new M(n)),this.close_context()}};W.textsuperscript=W["^"],W.textsubscript=W._,W.textsl=W.sl,W.mathbf=W.bf,W.mathit=W.it,W.textbf=W.bf,W.textit=W.it,W.textcolor=W.color;var ar=/[\r\n\xA0]+/g;function Re(r,n){r.sup&&(r.baseline=.45,r.size=.7),r.sub&&(r.baseline=-.3,r.size=.7);var a=n;return(r.style||r.weight||r.baseline||r.color||r.size||r.family)&&(a=P(n,r)),a}function ae(r,n,a){for(var t,o,u=r.width;u+a.width>n&&r.length;)o=(t=r[r.length-1]).width,t.width>a.width?(t.value=t.value.slice(0,-1),t.width=N(t,t.font),u+=t.width):r.pop(),u-=o;r[r.length-1]instanceof ct&&r.pop(),t=r[r.length-1]||t||{},a.font=P(a.font,t.bold,t.italic,""),a.href=r.length?t.href:null,a.rel=r.length?t.rel:null,a.target=r.length?t.target:null,r.push(a)}function lt(r){return Math.round(1e6*r)/1e6}function Ie(r){return function(n){if(Array.isArray(n))return Ht(n)}(r)||function(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}(r)||function(n,a){if(n){if(typeof n=="string")return Ht(n,a);var t=Object.prototype.toString.call(n).slice(8,-1);return t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set"?Array.from(n):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Ht(n,a):void 0}}(r)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
34
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Ht(r,n){(n==null||n>r.length)&&(n=r.length);for(var a=0,t=new Array(n);a<n;a++)t[a]=r[a];return t}var Le={center:"middle",right:"end"},le={middle:.5,center:.5,bottom:1,end:1},he=function(r,n){return!r&&!n||r===n};function lr(r,n){var a=[],t=n.font(),o=t.size,u=t.family,g=n.align(),m=n.createElement();if(r.length){var w=t.height,b=n.valign(),A=n.height()(),R=n.width()(0),k=!isFinite(R)&&r.length===1,O=k?null:n.x(),D=lt(w/o),U=k?null:lt(w/(1.15*o+(w-o)/2));if(le[b]&&isFinite(A)){var $=b==="bottom"?1:.5;U+=(A*$-w*r.length*$)/o}var I=g==="justify",V=0;g==="right"?V=R:g==="center"&&(V=R/2);for(var z=[],nt="tspan",K=null,Y="",F=function(){if(Y){var Ot=m(nt,K,Y);z.push(Ot)}nt="tspan",K=null,Y=""},ot=0,it=r.length;ot<it;ot++){var vt="",xt="",ft=0,mt=r[ot];if(mt.length){z=[];for(var Vt=0,ge=0,bt=void 0,Q=0,ze=mt.length;Q<ze;Q++){var X=mt[Q],tt=X.font;X.whitespace&&Vt++,ge+=X.width,Q&&!X.tracking&&!ft&&he(tt.id,vt)&&he(X.class,xt)&&he(bt,X.href)?Y+=X.value:(F(),Y=X.value,K={fontFamily:tt.family!==u?tt.family:null,fontSize:tt.size!==o?tt.size:null,fontWeight:tt.weight||null,fontStyle:tt.style||null,fontVariant:tt.variant!=="normal"&&tt.variant||null,fill:tt.color||null,baselineShift:tt.baseline?100*tt.baseline+"%":null,className:X.class||null},ft&&(K.dx=lt(ft),ft=0),X.tracking&&(ft=tt.size*X.tracking),X.href&&!bt?(bt=X.href,nt="a",K.href=bt,K.rel=X.rel,K.target=X.target):bt=null,vt=tt.id,xt=X.class)}if(F(),k)a.push.apply(a,Ie(z));else{var Ne=null,pe=ot===it-1||mt[mt.length-1]instanceof J;I&&mt.length>1&&!pe&&(Ne=lt((R-ge)/Vt)),a.push(m.apply(void 0,["tspan",{wordSpacing:Ne,x:O(ot)+V,dy:lt(ot?D:U)+"em"}].concat(Ie(z))))}}else a.push(m("tspan",{x:O(ot),dy:lt(ot?D:U)+"em"}," "))}}return m.apply(void 0,["text",{fontFamily:u,fontSize:o,textAnchor:Le[g]||"start"}].concat(a))}var hr={middle:.5,center:.5,bottom:1,end:1};function ur(r,n,a){if(r.length){a.textBaseline="middle";var t=n.font(),o=t.height,u=t.size,g=n.valign(),m=n.height()(),w=n.width()(0),b=n.align(),A=b==="justify",R=.5*o,k=hr[g];if(k&&isFinite(m)){var O=r.length*o;R+=m*k-O*k}r.forEach(function(D,U){var $=n.x()(U),I=U*o+R,V=0,z=0;D.forEach(function(Y){Y.whitespace&&V++,z+=Y.width});var nt=0,K=U===r.length-1||D[D.length-1]instanceof J;A&&D.length>1&&!K&&(nt=(w-z)/V),D.forEach(function(Y){a.font=Y.font;var F=Y.font,ot=F.baseline?u*-F.baseline+.15*u:0;a.fillStyle=function(xt,ft){return xt.color?xt.color:ft.href?"#00C":"#000"}(F,Y);var it=0;if(b==="right"?it+=w-z:b==="center"?it+=w/2-z/2:b==="justify"&&(Y.whitespace||Y instanceof J)&&($+=nt),a.fillText(Y.value,$+it,I+ot),Y.href){a.beginPath(),a.strokeStyle=a.fillStyle;var vt=Math.floor(I+.45*u)+.5;a.moveTo($+it,vt),a.lineTo($+it+Y.width,vt),a.stroke()}$+=Y.width})})}}function ue(r){return ue=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},ue(r)}function Fe(r){for(var n={},a=0;a<r.length;a++){var t=r[a];typeof t!="number"&&t!=null&&(typeof t=="string"?n.text=t:typeof t=="function"?n.fn=t:ue(t)==="object"&&t._groups?n.d3=t:t&&t.nodeType&&t.getContext?n.ctx=t.getContext("2d"):t&&t.fillText&&t.beginPath?n.ctx=t:t&&(n.text=t))}return n}function Ct(r){return Ct=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},Ct(r)}function ce(r,n){for(var a=0;a<n.length;a++){var t=n[a];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,(o=function(u,g){if(Ct(u)!=="object"||u===null)return u;var m=u[Symbol.toPrimitive];if(m!==void 0){var w=m.call(u,g);if(Ct(w)!=="object")return w;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(u)}(t.key,"string"),Ct(o)==="symbol"?o:String(o)),t)}var o}var je=P(),dt=function(r){return typeof r=="function"?r:function(){return r}},Z=function(){function r(t){if(function(u,g){if(!(u instanceof g))throw new TypeError("Cannot call a class as a function")}(this,r),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:r.defaultparser},t)for(var o in t)typeof this[o]=="function"&&this[o](t[o])}var n,a;return n=r,a=[{key:"linebreak",value:function(t){var o=this,u=this.props.parser(String(t)),g=this.font(),m=function(w,b,A){if(!w.length)return[];var R=b.height(),k=b.width(),O=b.overflowLine(),D=b.overflowWrap(),U=P(A,!0,!1),$=isFinite(R())?Math.floor(R()/A.height):1/0;if(!R()&&!k(0)||!$)return[];for(var I=0,V=0,z=0,nt=[],K=[],Y=!1;I<w.length&&V<$;){var F=w[I],ot=Re(F,A);if(F.width=N(F,ot),F.font=ot,F.line=V,F.whitespace=F.value in S,F.value&&(F.value=F.value.replace(ar," ")),!(!z&&F.whitespace||Y&&F.whitespace))if(F instanceof J)z=0,K=[],nt.push(I+1),V++;else if(F instanceof ut||F instanceof ct)K.push({index:I,width:z});else if(F.whitespace||z+F.width<k(V))z+=F.width;else if(K.length){var it=void 0,vt=void 0;do{vt=!0,it=K.pop();var xt=w[it.index],ft=void 0;xt instanceof ct&&(ft=N("-",xt.font),it.width+ft>k(V)&&(vt=!K.length))}while(!vt);nt.push(it.index+1),z=0,V++,I=it.index,K=[]}else if(D==="break-word"){var mt=k(V);if(z+F.width>mt){var Vt=F.clone();do F.value=F.value.slice(0,-1),F.width=N(F,F.font),z+=F.width;while(F.value&&F.width>mt);Vt.value=Vt.value.slice(F.value.length),w.splice(I+1,0,new ut,Vt)}nt.push(I+1),z=0,V++}else z+=F.width;I++,Y=F.whitespace}I!==nt[nt.length-1]&&nt.push(I);var ge=0,bt=0,Q=nt.map(function(Ot){for(var et,Pt=ge;(et=w[Pt])&&(et.whitespace||!et.value);)Pt++;for(var At=Ot,gr=null;At>Pt&&(et=w[At-1])&&(et.whitespace||!(et.value||et instanceof ct));)et instanceof J&&(gr=et),At--;et instanceof ct&&(et.value="-",et.width=N("-",et.font)),ge=Ot;var Yt=w.slice(Pt,At).filter(function(pr){return pr.value});return gr&&Yt.push(gr),Yt.width=Yt.reduce(function(pr,Cn){return pr+Cn.width},0),Yt.width>bt&&(bt=Yt.width),Yt});if(Q.hasLineOverflow=!1,O){var ze=O==="ellipsis"?"…":O;Q.forEach(function(Ot,et){var Pt=k(et);if(Ot.width>Pt){var At=new M(ze);At.font=A,At.width=N(ze,U),ae(Ot,Pt,At),Q.hasLineOverflow=!0}})}var X=b.overflow()==="ellipsis"?"…":b.overflow();if(X&&I!==w.length){var tt=k(Q.length-1),Ne=Q[Q.length-1],pe=new M(X);pe.font=A,pe.width=N(X,U),ae(Ne,tt,pe),Q.hasOverflow=!0}else Q.hasOverflow=!1;return Q.font=A,Q.width=bt,Q}(u,this,g);return m.height=m.length*g.height,m.render=function(w){return o.render(m,w)},m.svg=m.render,m.draw=m.render,m}},{key:"font",value:function(t){return arguments.length?(this.props.font=P(t),this):this.props.font||P(je)}},{key:"overflow",value:function(t){return arguments.length?(this.props.overflow=String(t),this):this.props.overflow}},{key:"overflowLine",value:function(t){return arguments.length?(this.props.lineclamp=String(t),this):this.props.lineclamp}},{key:"valign",value:function(t){return arguments.length?(this.props.valign=t,this):this.props.valign}},{key:"align",value:function(t){if(!arguments.length)return this.props.align;var o=String(t).toLowerCase();return o==="left"||o==="start"?(this.props.align="left",this.props.tAnchor=0):o==="center"||o==="middle"?(this.props.align="center",this.props.tAnchor=-.5):o==="end"||o==="right"?(this.props.align="right",this.props.tAnchor=-1):o==="justify"&&(this.props.align=t,this.props.tAnchor=0),this}},{key:"overflowWrap",value:function(t){if(!arguments.length)return this.props.overflowWrap||"normal";var o=String(t).toLowerCase();return o==="break-word"?this.props.overflowWrap="break-word":o!=="normal"&&t!=null||(this.props.overflowWrap=null),this}},{key:"width",value:function(t){return arguments.length?(this.props.width=dt(t),this):this.props.width}},{key:"height",value:function(t){return arguments.length?(this.props.height=dt(t),this):this.props.height}},{key:"x",value:function(t){return arguments.length?(this.props.x=dt(t),this):this.props.x}},{key:"parser",value:function(t){if(!arguments.length)return this.props.parser;if(typeof t=="string"){var o=r[t]||r[t+"parser"];typeof o=="function"&&(t=o)}if(typeof t!="function")throw new Error("Unknown parser: "+t);return this.props.parser=t,this}},{key:"createElement",value:function(t){return arguments.length?(this.props.createElement=t,this):this.props.createElement||r.createElement}},{key:"render",value:function(){var t=Fe(arguments);return typeof t.text=="string"&&(t.text=this.linebreak(t.text)),t.ctx?ur(t.text,this,t.ctx):lr(t.text,this)}}],a&&ce(n.prototype,a),Object.defineProperty(n,"prototype",{writable:!1}),r}();function yt(r){return yt=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},yt(r)}function Wt(r,n){(n==null||n>r.length)&&(n=r.length);for(var a=0,t=new Array(n);a<n;a++)t[a]=r[a];return t}function cr(r,n){for(var a=0;a<n.length;a++){var t=n[a];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,(o=function(u,g){if(yt(u)!=="object"||u===null)return u;var m=u[Symbol.toPrimitive];if(m!==void 0){var w=m.call(u,g);if(yt(w)!=="object")return w;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(u)}(t.key,"string"),yt(o)==="symbol"?o:String(o)),t)}var o}var de=function(r){return typeof r=="function"?r:function(){return r}},De=function(){function r(t){if(function(u,g){if(!(u instanceof g))throw new TypeError("Cannot call a class as a function")}(this,r),this.props={width:function(){return 1/0},height:function(){return 1/0},rotation:0,vAnchor:0,hAnchor:0},t)for(var o in t)typeof this[o]=="function"&&this[o](t[o]);this.render=this.render.bind(this)}var n,a;return n=r,a=[{key:"anchor",value:function(t){var o=this.props,u=o.hAnchor,g=o.vAnchor,m=o.width,w=o.height;if(!arguments.length)return[u*m(0),g*w(0)];if(typeof t=="string"){var b=this.props;t.toLowerCase().trim().split(/\s+/).forEach(function(A){A==="top"&&(b.vAnchor=-0),A==="middle"&&(b.vAnchor=-.5),A==="bottom"&&(b.vAnchor=-1),A==="left"&&(b.hAnchor=-0),A==="center"&&(b.hAnchor=-.5),A==="right"&&(b.hAnchor=-1)})}return this}},{key:"width",value:function(t){return arguments.length?(this.props.width=de(t),this):this.props.width}},{key:"height",value:function(t){return arguments.length?(this.props.height=de(t),this):this.props.height}},{key:"rotate",value:function(t){return arguments.length?(this.props.rotation=t,this):this.props.rotation}},{key:"createElement",value:function(t){return arguments.length?(this.props.createElement=t,this):this.props.createElement||r.createElement}},{key:"canvas",value:function(t,o){var u,g=t.getContext?t.getContext("2d"):t;return g.save(),g.rotate(this.rotate()*Math.PI/180),g.translate.apply(g,function(m){if(Array.isArray(m))return Wt(m)}(u=this.anchor())||function(m){if(typeof Symbol<"u"&&m[Symbol.iterator]!=null||m["@@iterator"]!=null)return Array.from(m)}(u)||function(m,w){if(m){if(typeof m=="string")return Wt(m,w);var b=Object.prototype.toString.call(m).slice(8,-1);return b==="Object"&&m.constructor&&(b=m.constructor.name),b==="Map"||b==="Set"?Array.from(m):b==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b)?Wt(m,w):void 0}}(u)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
35
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()),o(g),g.restore(),g}},{key:"render",value:function(){var t=Fe(arguments);if(t.d3)return t.d3.attr("transform","rotate(".concat(this.rotate(),") translate(").concat(this.anchor(),")"));if(t.ctx)return this.canvas(t.ctx,t.fn);if(t.text){var o=typeof t.text.render=="function"?t.text.render():t.text;return this.createElement()("g",{transform:"rotate(".concat(this.rotate(),") translate(").concat(this.anchor(),")")},o)}}}],a&&cr(n.prototype,a),Object.defineProperty(n,"prototype",{writable:!1}),r}(),Me=Object.prototype.hasOwnProperty,Ut={};function dr(r){return Ut[r]||(Ut[r]=r.replace(/([a-z])([A-Z])/g,function(n,a,t){return a+"-"+t.toLowerCase()})),Ut[r]}function $e(r,n){if(Array.isArray(n))return n.forEach(function(a){return $e(r,a)});typeof n=="string"&&(n=document.createTextNode(n)),r.appendChild(n)}function fe(r,n){if(typeof document<"u"){var a=typeof r=="string"?document.createElementNS("http://www.w3.org/2000/svg",r):r;if(n&&a.setAttribute)for(var t in n)Me.call(n,t)&&n[t]!=null&&a.setAttribute(t==="className"?"class":dr(t),n[t]);for(var o=arguments.length,u=new Array(o>2?o-2:0),g=2;g<o;g++)u[g-2]=arguments[g];return u!=null&&u.length&&u.forEach(function(m){$e(a,m)}),a}}Z.createElement=fe,Z.textparser=kt,Z.defaultparser=kt,Z.htmlparser=function(r){r=String(r||"").trim();for(var n,a,t={weight:null,style:null,sub:!1,sup:!1,href:null,color:null,rel:null,target:null},o=[],u=[],g=function(R){for(var k in t)t[k]&&(R[k]=t[k]);o.push(R)},m=function(R){var k=o.length,O=rr[R];if(k&&O){for(var D=k-1;o[D]&&(o[D]instanceof ut||er.test(o[D].value));)D--;for(;O&&o[D]&&o[D]instanceof J;)D--,O--;for(;O-- >0;)o.push(new J)}};r.length;){if(n=/^[^<]+/.exec(r))kt(oe(n[0]),!1).forEach(g);else if(!(n=zt.exec(r)))if(n=re.exec(r))u.length&&(t=u.pop()),m(n[1]);else if(n=ne.exec(r)){var w=n[1];m(w),u.push(t),t=Object.create(t),Tt[w]&&Tt[w](t,"");var b=Nt(n[2]);w==="a"&&(b.href&&(t.href=b.href),b.rel&&(t.rel=b.rel),b.target&&(t.target=b.target)),b.class&&(t.class=t.class?t.class+" "+b.class:b.class),b.style&&(a=/(?:^|\s|;)color\s*:\s*([^;\s"']+)/.exec(b.style))&&a[1]&&(t.color=a[1]),w==="br"&&o.push(new J)}else n=[r.slice(0,1)],g(new M(n[0]));r=r.slice(n[0].length)}for(var A=o[o.length-1];A instanceof J;)o.pop(),A=o[o.length-1];return o},Z.latexparser=function(r){r=String(r||"").trim();var n=[0];r=r.replace(/\\verb,(.*?),/,function($,I){return n.push(I),"\\verb,"+(n.length-1)+","}).replace(/\\\\\n/g,function(){return"\\\\"}).replace(sr,function($,I,V){return V.charAt(I-1)==="\\"?$:se[$]}).replace(/\n\s+/g,function($){return/\n/.test($.slice(1))?"\\par ":$}).replace(/\\symbol\{(\d+)\}/,function($,I,V,z){return z.charAt(V-1)==="\\"?$:String.fromCharCode(1*I)}).replace(/(^|[^\\])(\^|_)(\d|[^{]\S*)/g,function($,I,V,z){return I+V+"{"+z+"}"}).replace(/\\verb,(.*?),/,function($,I){return"\\verb,".concat(n[+I],",")});for(var a,t={weight:null,italic:null,variant:null,sub:!1,sup:!1,href:null},o=[],u=[],g=function($){for(var I in t)t[I]&&($[I]=t[I]);return o.push($),$},m=function(){u.push(t),t=Object.create(t)},w=function(){if(!u.length)throw new Error("Unexpected }");t=u.pop()},b={tokens:o,open_context:m,close_context:w,add_token:g};r.length;){if(a=Bt.exec(r))kt(a[0],!1).forEach(g);else if(a=or.exec(r))g(new M(a[1]));else if(!(a=Pe.exec(r))){if(a=/^\{/.exec(r))m();else if(a=/^\}/.exec(r))w();else if(!(a=/^\$/.exec(r)))if(a=/^\\verb,([^,]+),/.exec(r))g(new M(a[1]));else if(a=Oe.exec(r)){var A=a[1].slice(1)||a[1],R=!!a[2];if(/^(La)?TeX$/i.test(A)){m(),t.family="serif";var k=void 0;A==="LaTeX"&&((k=g(new M("L"))).tracking=-.25,(k=g(new M("A"))).size=.7,k.baseline=.3,k.tracking=-.1),(k=g(new M("T"))).tracking=-.17,(k=g(new M("E"))).baseline=-.22,k.tracking=-.13,k=g(new M("X")),w()}else if(A in St)g(new M(St[A])),R&&m();else if(A in W){var O=[],D=W[A].length-1,U=void 0;if(D){for(R=!1,r=r.slice(a[0].length-1);D--;){if(!(U=/^\{([^}]+)\}/.exec(r)))throw new Error(A+" is missing an argument");O.push(U[1]),r=r.slice(U[0].length)}a[0]=/^\{/.exec(r)?"{":"",R=!!a[0]}R&&m(),W[A].apply(b,[t].concat(O))}else console.warn("unknown latex command",A),g(new M(a[1])),R&&m()}else a=[r.slice(0,1)],g(new M(a[0]))}r=r.slice(a[0].length)}return o},Z.measureText=function(r,n,a){return N(r,P(n),a)},Z.Token=M,Z.Break=ut,Z.LineBreak=J,Z.SoftHyphen=ct,Z.Rotator=De,De.createElement=fe;const fr=Z;return i.default})())})(Mr);var gn=Mr.exports;const $r=Or(gn);function Ge(h){return h.replace(/…$/,"")}function Je(h){return h.children[0].innerHTML}function pn(h,e){const s=gt(h),{fontSize:i,font:l,padding:c=0}=h.properties.style||{};if(s.width===s.height&&s.width===0)return;const f=new $r({font:`${i}px/${i}px ${l}`.replace(/(px)+/g,"px"),width:s.width-c*2,height:s.height-c*2,align:"left",valign:"top",x:0,overflow:"ellipsis",parser:"html",createElement:$r.createElement});f.overflowWrap("break-word");const p=f.linebreak(h.properties.content.replaceAll(`
36
- `,"<br>")).render(),d=[...p.children];let v=0;const y=[];h.properties.content.split(`
33
+ `),x(this,"draggedHandle",G),x(this,"start",{x:0,y:0}),x(this,"end",{x:0,y:0}),x(this,"arrow",{...mr}),x(this,"startX",0),x(this,"startY",0),x(this,"minArrowHeight",0),x(this,"maxArrowHeight",0),x(this,"handles",[]),x(this,"onHandleMouseDown",i=>{const l=this.getById(this.selectedId)||this.getById(this.hoveredId);if(!l)return;const{x:c,y:f}=He(i,this.ogma.getContainer());this.startDragging(l,c,f),this.draggedHandle=Ar(i.target)}),x(this,"onMouseUp",()=>{this.draggedHandle!==-1&&(this.restoreDragging(),this.isDragging=!1,this.draggedHandle=G,this.emit(Ft,this.arrow))}),x(this,"onMouseMove",i=>{if(!this.isDragging||this.draggedHandle===G)return;const l=this.handles[this.draggedHandle],c=this.ogma.view.getAngle(),{x:f,y:g}=st(sn({x:i.clientX-this.startX,y:i.clientY-this.startY},this.ogma.view.getZoom()),c),d=l.id===Lr,v=l.id===Fr,y=l.id===jr;(d||v)&&wr(this.arrow,this.start.x+f,this.start.y+g),(d||y)&&xr(this.arrow,this.end.x+f,this.end.y+g),this.emit(Ae,this.arrow,d?"line":v?"start":"end"),this.refreshEditor(),this.layer.refresh()}),this.minArrowHeight=o.minArrowHeight||0,this.maxArrowHeight=o.maxArrowHeight||1e6,this.handles=Array.prototype.slice.call(this.editor.element.querySelectorAll(".arrow-handle>.handle")),this.handles.forEach(i=>i.addEventListener("mousedown",this.onHandleMouseDown)),document.addEventListener("mousemove",this.onMouseMove,!0),document.addEventListener("mouseup",this.onMouseUp)}startDrawing(e,o,i=Qr(e,o,e,o,Xt)){var l;this.disableDragging(),this.add(i),this.hoveredId=i.id;const c=this.ogma.view.graphToScreenCoordinates({x:e,y:o}),f=((l=this.ogma.getContainer())==null?void 0:l.getBoundingClientRect())||{left:0,top:0};this.startDragging(this.getById(i.id),c.x+(f==null?void 0:f.left),c.y+f.top),this.draggedHandle=2}cancelDrawing(){this.isDragging&&(this.remove(this.arrow.id),this.emit(Ft,this.arrow),this.restoreDragging(),this.isDragging=!1,this.draggedHandle=G)}startDragging(e,o,i){this.selectedId!==e.id&&this.select(this.hoveredId),this.arrow=e,this.startX=o,this.startY=i,this.start=Zt(this.arrow),this.end=me(this.arrow),this.disableDragging(),this.emit(Ee,this.arrow),this.isDragging=!0}detect(e,o=0){return this.elements.find(i=>{const{start:l,end:c}=be(i),f=Et(e,{x:(l.x+c.x)/2,y:(l.y+c.y)/2}),g=Et(c,l),d=It(g),v=_r(g),y=Tr(i);return Math.abs(Sr(v,f))<d/2+o&&Math.abs(Sr(st(v,Math.PI/2),f))<y/2+o})}refreshEditor(){if(+this.selectedId<0&&+this.hoveredId<0)return;const e=this.selectedId!==G?this.getById(this.selectedId):this.getById(this.hoveredId),o=be(e),i=this.ogma.view.graphToScreenCoordinates(o.start),l=this.ogma.view.graphToScreenCoordinates(o.end),[c,f,g]=Array.prototype.slice.call(this.editor.element.querySelectorAll(".handle"));f.style.transform=`translate(${i.x}px, ${i.y}px) translate(-50%, -50%)`,g.style.transform=`translate(${l.x}px, ${l.y}px) translate(-50%, -50%)`;const d={x:(l.x+i.x)/2,y:(l.y+i.y)/2},v=Et(l,i),y=kr(v,1/It(v)),_=Math.atan2(y.y,y.x);c.style.width=`${It(v)}px`,c.style.left=`${d.x}px`,c.style.top=`${d.y}px`,c.style.transform=`translate(-50%, -50%) rotate(${_}rad)`}getDefaultOptions(){return mr}draw(e){e.innerHTML="";const o=Jt("g"),i=this.ogma.view.getAngle();o.setAttribute("transform",`rotate(${-i*(180/Math.PI)})`),this.elements.forEach(l=>an(l,o,Xt,this.minArrowHeight,this.maxArrowHeight)),e.appendChild(o)}refreshDrawing(){const e=this.ogma.view.getAngle();this.layer.element!==null&&this.layer.element.children[0].setAttribute("transform",`rotate(${-e*(180/Math.PI)})`)}destroy(){super.destroy(),document.removeEventListener("mousemove",this.onMouseMove,!0),document.removeEventListener("mouseup",this.onMouseUp)}}const jt={font:"sans-serif",fontSize:12,color:"black",background:"",strokeWidth:1,strokeColor:"#000",strokeType:"plain"},qe={id:0,type:"Feature",properties:{type:"text",content:"",style:{...jt}},geometry:{type:"Polygon",coordinates:[[[0,0],[100,0],[100,50],[0,50],[0,0]]]}},Dr={handleSize:3.5,placeholder:"Your text..."},pn=(u=0,e=0,o=100,i=50,l="",c={...jt})=>({id:ye(),type:"Feature",properties:{type:"text",content:l,style:{...jt,...c}},geometry:{type:"Polygon",coordinates:[[[u,e],[u+o,e],[u+o,e+i],[u,e+i],[u,e]]]}});var Mr={exports:{}};(function(u,e){(function(o,i){u.exports=i()})(dn,()=>(()=>{var o={d:(r,n)=>{for(var a in n)o.o(n,a)&&!o.o(r,a)&&Object.defineProperty(r,a,{enumerable:!0,get:n[a]})},o:(r,n)=>Object.prototype.hasOwnProperty.call(r,n)},i={};function l(r){return l=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},l(r)}o.d(i,{default:()=>fr});var c=/^((?:[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/,d=/\bbold(?:er)?\b/,v=13.3333333,y={"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 _(r){var n="",a=this;return a.style&&a.style!=="normal"&&(n+=a.style),a.variant&&a.variant!=="normal"&&(n+=(n?" ":"")+a.variant),a.weight&&a.weight!=="normal"&&(n+=(n?" ":"")+a.weight),a.size&&(n+=(n?" ":"")+a.size+"px",a.height!==a.size&&(n+="/"+a.height+"px")),a.family&&(n+=(n?" ":"")+a.family),r&&(n+="::"+a.baseline),r&&(n+="::"+a.color),n}var C={id:"",family:"sans-serif",height:14,size:12,variant:"",style:"",weight:"",baseline:"",color:null,toString:_,valueOf:_};function E(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=c.exec(r);n.family=(a[6]||"").trim();var t=y[a[2]]||parseFloat(a[2]);a[3]==="%"?t*=.16:a[3]==="em"?t*=16:a[3]==="pt"&&(t*=v),n.size=t;var s=parseFloat(a[4]);if(s!=="normal"&&s!=="inherit"&&s?a[5]&&a[5]!=="em"?a[5]==="pt"?n.height=s*v:a[5]==="%"?n.height=.01*t:n.height=s:n.height=s*t:n.height=Math.round(t*(7/6)),f.test(a[1])&&(n.variant="small-caps"),g.test(a[1])&&(n.style="italic"),d.test(a[1]))n.weight="bold";else{var h=parseInt(/\b(\d+)\b/.exec(a[1]),10);h>=100&&h!==400&&(n.weight=h)}return n}function P(){var r,n,a,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"12px/14px sans-serif",s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},h=14,p=12,m=null,w=null,b="";if(t&&t.nodeType){var A=t&&(t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView),R=A.getComputedStyle(t,null);r=R.getPropertyValue("font-family")||"",p=parseFloat(R.getPropertyValue("font-size")),h=R.getPropertyValue("line-height"),m=R.getPropertyValue("font-weight"),w=R.getPropertyValue("font-style"),b=R.getPropertyValue("font-variant")||""}else if(typeof t=="string"){var k=E(t);r=k.family,p=k.size,h=k.height,b=k.variant,w=k.style,m=k.weight}else l(t)==="object"&&(r=t.family,p=t.size,h=t.height,b=t.variant,m=t.weight,w=t.style,n=t.baseline,a=t.color);s.size&&s.size<3&&(p*=s.size),h=h!=="normal"&&h?parseFloat(h):p*(7/6),s.height&&s.height<3&&(h*=s.height);var O=Object.create(C);return O.family=s.family||r||"sans-serif",O.height=h??14,O.size=p??12,O.variant=s.variant||b||"",O.style=s.style||w||"",O.weight=s.weight||m||"",O.baseline=n||0,s.baseline!=null&&(O.baseline=s.baseline),O.color=s.color||a||"",O.id=_.call(O,!0),O}const T={"\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 j,L=function(r){var n=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(100,100)||r&&r.createElement("canvas");if(n&&n.getContext){var a=n.getContext("2d");if(a&&typeof a.measureText=="function")return function(t,s){return a.font=String(s),a.measureText(t).width}}}(typeof document<"u"?document:null)||(j={},function(r,n){if(!j[n]){var a=P(n);j[n]=a,/\bmonospace\b/.test(a.family)?a.size*=.6:(a.size*=.45,a.weight&&(a.size*=1.18))}return r.length*j[n].size}),S={},H={trim:!0,collapse:!0};function N(r,n,a){var t=Object.assign({},H,a),s=String(r);if(!s)return 0;if(s in T){var h=n.id+"/"+s;return h in S||(S[h]=L("_".concat(s,"_"),n)-L("__",n)),S[h]}return t.trim&&t.collapse?t.trim?s=s.trim():t.collapse&&(s=s.replace(/\s+/g," ")):s=s.replace(/\n/g," "),L(s,n)+n.size*(r.tracking||0)}function lt(r){return lt=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},lt(r)}function _t(r,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(n&&n.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),n&&Kt(r,n)}function Kt(r,n){return Kt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,t){return a.__proto__=t,a},Kt(r,n)}function Qt(r){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 a,t=Dt(r);if(n){var s=Dt(this).constructor;a=Reflect.construct(t,arguments,s)}else a=t.apply(this,arguments);return _e(this,a)}}function _e(r,n){if(n&&(lt(n)==="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(a){if(a===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}(r)}function Dt(r){return Dt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Dt(r)}function Mt(r,n){if(!(r instanceof n))throw new TypeError("Cannot call a class as a function")}function te(r,n){for(var a=0;a<n.length;a++){var t=n[a];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,(s=function(h,p){if(lt(h)!=="object"||h===null)return h;var m=h[Symbol.toPrimitive];if(m!==void 0){var w=m.call(h,p);if(lt(w)!=="object")return w;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(h)}(t.key,"string"),lt(s)==="symbol"?s:String(s)),t)}var s}function rt(r,n,a){return n&&te(r.prototype,n),a&&te(r,a),Object.defineProperty(r,"prototype",{writable:!1}),r}var M=function(){function r(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";Mt(this,r),this.value=n,this.weight=null,this.style=null,this.font=null,this.href=null,this.sub=!1,this.sup=!1}return rt(r,[{key:"clone",value:function(){var n=new r(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}}]),r}(),ht=function(r){_t(a,r);var n=Qt(a);function a(){return Mt(this,a),n.apply(this,arguments)}return rt(a)}(M),J=function(r){_t(a,r);var n=Qt(a);function a(){return Mt(this,a),n.apply(this,arguments)}return rt(a)}(M),ct=function(r){_t(a,r);var n=Qt(a);function a(){return Mt(this,a),n.apply(this,arguments)}return rt(a)}(M),$t=/^[\n\r\t\x20\xA0\u2000-\u200B\u205F\u3000]/,ke=/^[^\n\r\t\u0020\u2000-\u200B\u205F\u3000]{2,}/,ee=/^[\xA0\u2011\u202F\u2060\uFEFF]/,Se=/^(?:[;\xAD%?…]|,(?!\d))/,Te=/^[´±°¢£¤$¥\u2212]/;function kt(r,n){n!==!1&&(r=r.trim());for(var a,t,s=[],h=r.charAt(0),p=0,m=1,w=r.length;m<w;m++){a=r.charAt(m),t=r.charAt(m+1);var b=$t.test(h),A=$t.test(a),R=A||b,k=void 0;if((Te.test(a)&&!ee.test(h)||Se.test(h+t)&&!ee.test(a))&&(R=!0),h!=="-"&&h!=="‐"&&h!=="–"&&h!=="—"||((k=$t.test(r.charAt(m-2)))&&!A&&(R=!1),!k&&ke.test(a+t)&&(R=!0)),R){var O=r.slice(p,m);/\u00AD$/.test(O)?(s.push(new M(O.slice(0,-1))),s.push(new ct)):(s.push(new M(O)),s.push(new ht)),p=m}h=a}return s.push(new M(r.slice(p))),s}const Ce={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 er=/^[\n\r\x20\u2000-\u200B\u205F\u3000]/,re=/^<\/([a-zA-Z0-9]+)([^>]*)>/,ne=/^<([a-zA-Z0-9]+)((?:\s[^=\s/]+(?:\s*=\s*(?:"[^"]+"|'[^']+'|[^>\\s]+))?)+)?\s*(\/?)>(\n*)/,zt=/^<!--(.+?)-->/,ie=/&(?:#(\d\d{2,})|#x([\da-fA-F]{2,})|([a-zA-Z][a-zA-Z1-4]{1,8}));/g,St={b:function(r){r.weight="bold"},strong:function(r){r.weight="bold"},i:function(r){r.style="italic"},em:function(r){r.style="italic"},dfn:function(r){r.style="italic"},cite:function(r){r.style="italic"},code:function(r){r.family="monospace"},kbd:function(r){r.family="monospace"},samp:function(r){r.family="monospace"},var:function(r){r.family="monospace"},tt:function(r){r.family="monospace"},sub:function(r){r.sub=!0},sup:function(r){r.sup=!0}},rr={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 oe(r){return r.replace(ie,function(n,a,t,s){if(a||t){var h=a?10:16;return String.fromCharCode(parseInt(a||t,h))}return s in Ce?Ce[s]:n})}function nr(r){return r&&r.length>1&&(r[0]==='"'&&r[r.length-1]==='"'||r[0]==="'"&&r[r.length-1]==="'")?r.slice(1,-1):r}var ir=/^\s*([^=\s&]+)(?:\s*=\s*("[^"]+"|'[^']+'|[^>\s]+))?/;function Nt(r){var n,a={};if(r){do if(n=ir.exec(r)){var t=oe(nr(n[2]||"")).replace(/[ \r\n\t]+/g," ").trim();if(a[n[1]]=t,(r=r.slice(n[0].length)).length&&/^\S/.test(r[0]))throw new Error("Attribute error")}while(n&&r.length);if(/\S/.test(r))throw new Error("Attribute error")}return a}const Tt={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 Oe=/^(\^|_|\\[^#$%&~_^\\{}()\s]+)(\{)?/,Pe=/^%[^\n]+(?:\n|$)/,Bt=/^[^#$%&~_^\\{}]+/,or=/^\\([&{}$%#_])/,sr=/(?:\\[\\@,!:;-]|-{2,3}|[!?]`|``?|,,|''?|~|<<|>>)/g,se={"---":"—","--":"–","!`":"¡","?`":"¿","``":"“",",,":"„","''":"”","`":"‘","'":"’","<<":"«",">>":"»","~":" ","\\-":"­","\\,":" ","\\;":" ","\\:":" ","\\!":" ","\\@":"\uFEFF","\\\\":"\\newline{}"},U={bf:function(r){r.weight="bold"},it:function(r){r.style="italic"},sl:function(r){r.style="italic"},color:function(r,n){r.color=n},href:function(r,n){r.href=n},"^":function(r){r.sup=!0},_:function(r){r.sub=!0},par:function(r){this.tokens.push(new J,new J)},newline:function(r){this.tokens.push(new J)},url:function(r,n){this.open_context().href=n,this.add_token(new M(n)),this.close_context()}};U.textsuperscript=U["^"],U.textsubscript=U._,U.textsl=U.sl,U.mathbf=U.bf,U.mathit=U.it,U.textbf=U.bf,U.textit=U.it,U.textcolor=U.color;var ar=/[\r\n\xA0]+/g;function Re(r,n){r.sup&&(r.baseline=.45,r.size=.7),r.sub&&(r.baseline=-.3,r.size=.7);var a=n;return(r.style||r.weight||r.baseline||r.color||r.size||r.family)&&(a=P(n,r)),a}function ae(r,n,a){for(var t,s,h=r.width;h+a.width>n&&r.length;)s=(t=r[r.length-1]).width,t.width>a.width?(t.value=t.value.slice(0,-1),t.width=N(t,t.font),h+=t.width):r.pop(),h-=s;r[r.length-1]instanceof ct&&r.pop(),t=r[r.length-1]||t||{},a.font=P(a.font,t.bold,t.italic,""),a.href=r.length?t.href:null,a.rel=r.length?t.rel:null,a.target=r.length?t.target:null,r.push(a)}function ut(r){return Math.round(1e6*r)/1e6}function Ie(r){return function(n){if(Array.isArray(n))return Ht(n)}(r)||function(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}(r)||function(n,a){if(n){if(typeof n=="string")return Ht(n,a);var t=Object.prototype.toString.call(n).slice(8,-1);return t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set"?Array.from(n):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Ht(n,a):void 0}}(r)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
34
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Ht(r,n){(n==null||n>r.length)&&(n=r.length);for(var a=0,t=new Array(n);a<n;a++)t[a]=r[a];return t}var Le={center:"middle",right:"end"},le={middle:.5,center:.5,bottom:1,end:1},ue=function(r,n){return!r&&!n||r===n};function lr(r,n){var a=[],t=n.font(),s=t.size,h=t.family,p=n.align(),m=n.createElement();if(r.length){var w=t.height,b=n.valign(),A=n.height()(),R=n.width()(0),k=!isFinite(R)&&r.length===1,O=k?null:n.x(),D=ut(w/s),W=k?null:ut(w/(1.15*s+(w-s)/2));if(le[b]&&isFinite(A)){var $=b==="bottom"?1:.5;W+=(A*$-w*r.length*$)/s}var I=p==="justify",V=0;p==="right"?V=R:p==="center"&&(V=R/2);for(var z=[],nt="tspan",K=null,Y="",F=function(){if(Y){var Ot=m(nt,K,Y);z.push(Ot)}nt="tspan",K=null,Y=""},ot=0,it=r.length;ot<it;ot++){var mt="",xt="",ft=0,bt=r[ot];if(bt.length){z=[];for(var Vt=0,ge=0,wt=void 0,Q=0,ze=bt.length;Q<ze;Q++){var q=bt[Q],tt=q.font;q.whitespace&&Vt++,ge+=q.width,Q&&!q.tracking&&!ft&&ue(tt.id,mt)&&ue(q.class,xt)&&ue(wt,q.href)?Y+=q.value:(F(),Y=q.value,K={fontFamily:tt.family!==h?tt.family:null,fontSize:tt.size!==s?tt.size:null,fontWeight:tt.weight||null,fontStyle:tt.style||null,fontVariant:tt.variant!=="normal"&&tt.variant||null,fill:tt.color||null,baselineShift:tt.baseline?100*tt.baseline+"%":null,className:q.class||null},ft&&(K.dx=ut(ft),ft=0),q.tracking&&(ft=tt.size*q.tracking),q.href&&!wt?(wt=q.href,nt="a",K.href=wt,K.rel=q.rel,K.target=q.target):wt=null,mt=tt.id,xt=q.class)}if(F(),k)a.push.apply(a,Ie(z));else{var Ne=null,pe=ot===it-1||bt[bt.length-1]instanceof J;I&&bt.length>1&&!pe&&(Ne=ut((R-ge)/Vt)),a.push(m.apply(void 0,["tspan",{wordSpacing:Ne,x:O(ot)+V,dy:ut(ot?D:W)+"em"}].concat(Ie(z))))}}else a.push(m("tspan",{x:O(ot),dy:ut(ot?D:W)+"em"}," "))}}return m.apply(void 0,["text",{fontFamily:h,fontSize:s,textAnchor:Le[p]||"start"}].concat(a))}var ur={middle:.5,center:.5,bottom:1,end:1};function hr(r,n,a){if(r.length){a.textBaseline="middle";var t=n.font(),s=t.height,h=t.size,p=n.valign(),m=n.height()(),w=n.width()(0),b=n.align(),A=b==="justify",R=.5*s,k=ur[p];if(k&&isFinite(m)){var O=r.length*s;R+=m*k-O*k}r.forEach(function(D,W){var $=n.x()(W),I=W*s+R,V=0,z=0;D.forEach(function(Y){Y.whitespace&&V++,z+=Y.width});var nt=0,K=W===r.length-1||D[D.length-1]instanceof J;A&&D.length>1&&!K&&(nt=(w-z)/V),D.forEach(function(Y){a.font=Y.font;var F=Y.font,ot=F.baseline?h*-F.baseline+.15*h:0;a.fillStyle=function(xt,ft){return xt.color?xt.color:ft.href?"#00C":"#000"}(F,Y);var it=0;if(b==="right"?it+=w-z:b==="center"?it+=w/2-z/2:b==="justify"&&(Y.whitespace||Y instanceof J)&&($+=nt),a.fillText(Y.value,$+it,I+ot),Y.href){a.beginPath(),a.strokeStyle=a.fillStyle;var mt=Math.floor(I+.45*h)+.5;a.moveTo($+it,mt),a.lineTo($+it+Y.width,mt),a.stroke()}$+=Y.width})})}}function he(r){return he=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},he(r)}function Fe(r){for(var n={},a=0;a<r.length;a++){var t=r[a];typeof t!="number"&&t!=null&&(typeof t=="string"?n.text=t:typeof t=="function"?n.fn=t:he(t)==="object"&&t._groups?n.d3=t:t&&t.nodeType&&t.getContext?n.ctx=t.getContext("2d"):t&&t.fillText&&t.beginPath?n.ctx=t:t&&(n.text=t))}return n}function Ct(r){return Ct=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},Ct(r)}function ce(r,n){for(var a=0;a<n.length;a++){var t=n[a];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,(s=function(h,p){if(Ct(h)!=="object"||h===null)return h;var m=h[Symbol.toPrimitive];if(m!==void 0){var w=m.call(h,p);if(Ct(w)!=="object")return w;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(h)}(t.key,"string"),Ct(s)==="symbol"?s:String(s)),t)}var s}var je=P(),dt=function(r){return typeof r=="function"?r:function(){return r}},Z=function(){function r(t){if(function(h,p){if(!(h instanceof p))throw new TypeError("Cannot call a class as a function")}(this,r),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:r.defaultparser},t)for(var s in t)typeof this[s]=="function"&&this[s](t[s])}var n,a;return n=r,a=[{key:"linebreak",value:function(t){var s=this,h=this.props.parser(String(t)),p=this.font(),m=function(w,b,A){if(!w.length)return[];var R=b.height(),k=b.width(),O=b.overflowLine(),D=b.overflowWrap(),W=P(A,!0,!1),$=isFinite(R())?Math.floor(R()/A.height):1/0;if(!R()&&!k(0)||!$)return[];for(var I=0,V=0,z=0,nt=[],K=[],Y=!1;I<w.length&&V<$;){var F=w[I],ot=Re(F,A);if(F.width=N(F,ot),F.font=ot,F.line=V,F.whitespace=F.value in T,F.value&&(F.value=F.value.replace(ar," ")),!(!z&&F.whitespace||Y&&F.whitespace))if(F instanceof J)z=0,K=[],nt.push(I+1),V++;else if(F instanceof ht||F instanceof ct)K.push({index:I,width:z});else if(F.whitespace||z+F.width<k(V))z+=F.width;else if(K.length){var it=void 0,mt=void 0;do{mt=!0,it=K.pop();var xt=w[it.index],ft=void 0;xt instanceof ct&&(ft=N("-",xt.font),it.width+ft>k(V)&&(mt=!K.length))}while(!mt);nt.push(it.index+1),z=0,V++,I=it.index,K=[]}else if(D==="break-word"){var bt=k(V);if(z+F.width>bt){var Vt=F.clone();do F.value=F.value.slice(0,-1),F.width=N(F,F.font),z+=F.width;while(F.value&&F.width>bt);Vt.value=Vt.value.slice(F.value.length),w.splice(I+1,0,new ht,Vt)}nt.push(I+1),z=0,V++}else z+=F.width;I++,Y=F.whitespace}I!==nt[nt.length-1]&&nt.push(I);var ge=0,wt=0,Q=nt.map(function(Ot){for(var et,Pt=ge;(et=w[Pt])&&(et.whitespace||!et.value);)Pt++;for(var At=Ot,gr=null;At>Pt&&(et=w[At-1])&&(et.whitespace||!(et.value||et instanceof ct));)et instanceof J&&(gr=et),At--;et instanceof ct&&(et.value="-",et.width=N("-",et.font)),ge=Ot;var Yt=w.slice(Pt,At).filter(function(pr){return pr.value});return gr&&Yt.push(gr),Yt.width=Yt.reduce(function(pr,Pn){return pr+Pn.width},0),Yt.width>wt&&(wt=Yt.width),Yt});if(Q.hasLineOverflow=!1,O){var ze=O==="ellipsis"?"…":O;Q.forEach(function(Ot,et){var Pt=k(et);if(Ot.width>Pt){var At=new M(ze);At.font=A,At.width=N(ze,W),ae(Ot,Pt,At),Q.hasLineOverflow=!0}})}var q=b.overflow()==="ellipsis"?"…":b.overflow();if(q&&I!==w.length){var tt=k(Q.length-1),Ne=Q[Q.length-1],pe=new M(q);pe.font=A,pe.width=N(q,W),ae(Ne,tt,pe),Q.hasOverflow=!0}else Q.hasOverflow=!1;return Q.font=A,Q.width=wt,Q}(h,this,p);return m.height=m.length*p.height,m.render=function(w){return s.render(m,w)},m.svg=m.render,m.draw=m.render,m}},{key:"font",value:function(t){return arguments.length?(this.props.font=P(t),this):this.props.font||P(je)}},{key:"overflow",value:function(t){return arguments.length?(this.props.overflow=String(t),this):this.props.overflow}},{key:"overflowLine",value:function(t){return arguments.length?(this.props.lineclamp=String(t),this):this.props.lineclamp}},{key:"valign",value:function(t){return arguments.length?(this.props.valign=t,this):this.props.valign}},{key:"align",value:function(t){if(!arguments.length)return this.props.align;var s=String(t).toLowerCase();return s==="left"||s==="start"?(this.props.align="left",this.props.tAnchor=0):s==="center"||s==="middle"?(this.props.align="center",this.props.tAnchor=-.5):s==="end"||s==="right"?(this.props.align="right",this.props.tAnchor=-1):s==="justify"&&(this.props.align=t,this.props.tAnchor=0),this}},{key:"overflowWrap",value:function(t){if(!arguments.length)return this.props.overflowWrap||"normal";var s=String(t).toLowerCase();return s==="break-word"?this.props.overflowWrap="break-word":s!=="normal"&&t!=null||(this.props.overflowWrap=null),this}},{key:"width",value:function(t){return arguments.length?(this.props.width=dt(t),this):this.props.width}},{key:"height",value:function(t){return arguments.length?(this.props.height=dt(t),this):this.props.height}},{key:"x",value:function(t){return arguments.length?(this.props.x=dt(t),this):this.props.x}},{key:"parser",value:function(t){if(!arguments.length)return this.props.parser;if(typeof t=="string"){var s=r[t]||r[t+"parser"];typeof s=="function"&&(t=s)}if(typeof t!="function")throw new Error("Unknown parser: "+t);return this.props.parser=t,this}},{key:"createElement",value:function(t){return arguments.length?(this.props.createElement=t,this):this.props.createElement||r.createElement}},{key:"render",value:function(){var t=Fe(arguments);return typeof t.text=="string"&&(t.text=this.linebreak(t.text)),t.ctx?hr(t.text,this,t.ctx):lr(t.text,this)}}],a&&ce(n.prototype,a),Object.defineProperty(n,"prototype",{writable:!1}),r}();function vt(r){return vt=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},vt(r)}function Ut(r,n){(n==null||n>r.length)&&(n=r.length);for(var a=0,t=new Array(n);a<n;a++)t[a]=r[a];return t}function cr(r,n){for(var a=0;a<n.length;a++){var t=n[a];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,(s=function(h,p){if(vt(h)!=="object"||h===null)return h;var m=h[Symbol.toPrimitive];if(m!==void 0){var w=m.call(h,p);if(vt(w)!=="object")return w;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(h)}(t.key,"string"),vt(s)==="symbol"?s:String(s)),t)}var s}var de=function(r){return typeof r=="function"?r:function(){return r}},De=function(){function r(t){if(function(h,p){if(!(h instanceof p))throw new TypeError("Cannot call a class as a function")}(this,r),this.props={width:function(){return 1/0},height:function(){return 1/0},rotation:0,vAnchor:0,hAnchor:0},t)for(var s in t)typeof this[s]=="function"&&this[s](t[s]);this.render=this.render.bind(this)}var n,a;return n=r,a=[{key:"anchor",value:function(t){var s=this.props,h=s.hAnchor,p=s.vAnchor,m=s.width,w=s.height;if(!arguments.length)return[h*m(0),p*w(0)];if(typeof t=="string"){var b=this.props;t.toLowerCase().trim().split(/\s+/).forEach(function(A){A==="top"&&(b.vAnchor=-0),A==="middle"&&(b.vAnchor=-.5),A==="bottom"&&(b.vAnchor=-1),A==="left"&&(b.hAnchor=-0),A==="center"&&(b.hAnchor=-.5),A==="right"&&(b.hAnchor=-1)})}return this}},{key:"width",value:function(t){return arguments.length?(this.props.width=de(t),this):this.props.width}},{key:"height",value:function(t){return arguments.length?(this.props.height=de(t),this):this.props.height}},{key:"rotate",value:function(t){return arguments.length?(this.props.rotation=t,this):this.props.rotation}},{key:"createElement",value:function(t){return arguments.length?(this.props.createElement=t,this):this.props.createElement||r.createElement}},{key:"canvas",value:function(t,s){var h,p=t.getContext?t.getContext("2d"):t;return p.save(),p.rotate(this.rotate()*Math.PI/180),p.translate.apply(p,function(m){if(Array.isArray(m))return Ut(m)}(h=this.anchor())||function(m){if(typeof Symbol<"u"&&m[Symbol.iterator]!=null||m["@@iterator"]!=null)return Array.from(m)}(h)||function(m,w){if(m){if(typeof m=="string")return Ut(m,w);var b=Object.prototype.toString.call(m).slice(8,-1);return b==="Object"&&m.constructor&&(b=m.constructor.name),b==="Map"||b==="Set"?Array.from(m):b==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b)?Ut(m,w):void 0}}(h)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
35
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()),s(p),p.restore(),p}},{key:"render",value:function(){var t=Fe(arguments);if(t.d3)return t.d3.attr("transform","rotate(".concat(this.rotate(),") translate(").concat(this.anchor(),")"));if(t.ctx)return this.canvas(t.ctx,t.fn);if(t.text){var s=typeof t.text.render=="function"?t.text.render():t.text;return this.createElement()("g",{transform:"rotate(".concat(this.rotate(),") translate(").concat(this.anchor(),")")},s)}}}],a&&cr(n.prototype,a),Object.defineProperty(n,"prototype",{writable:!1}),r}(),Me=Object.prototype.hasOwnProperty,Wt={};function dr(r){return Wt[r]||(Wt[r]=r.replace(/([a-z])([A-Z])/g,function(n,a,t){return a+"-"+t.toLowerCase()})),Wt[r]}function $e(r,n){if(Array.isArray(n))return n.forEach(function(a){return $e(r,a)});typeof n=="string"&&(n=document.createTextNode(n)),r.appendChild(n)}function fe(r,n){if(typeof document<"u"){var a=typeof r=="string"?document.createElementNS("http://www.w3.org/2000/svg",r):r;if(n&&a.setAttribute)for(var t in n)Me.call(n,t)&&n[t]!=null&&a.setAttribute(t==="className"?"class":dr(t),n[t]);for(var s=arguments.length,h=new Array(s>2?s-2:0),p=2;p<s;p++)h[p-2]=arguments[p];return h!=null&&h.length&&h.forEach(function(m){$e(a,m)}),a}}Z.createElement=fe,Z.textparser=kt,Z.defaultparser=kt,Z.htmlparser=function(r){r=String(r||"").trim();for(var n,a,t={weight:null,style:null,sub:!1,sup:!1,href:null,color:null,rel:null,target:null},s=[],h=[],p=function(R){for(var k in t)t[k]&&(R[k]=t[k]);s.push(R)},m=function(R){var k=s.length,O=rr[R];if(k&&O){for(var D=k-1;s[D]&&(s[D]instanceof ht||er.test(s[D].value));)D--;for(;O&&s[D]&&s[D]instanceof J;)D--,O--;for(;O-- >0;)s.push(new J)}};r.length;){if(n=/^[^<]+/.exec(r))kt(oe(n[0]),!1).forEach(p);else if(!(n=zt.exec(r)))if(n=re.exec(r))h.length&&(t=h.pop()),m(n[1]);else if(n=ne.exec(r)){var w=n[1];m(w),h.push(t),t=Object.create(t),St[w]&&St[w](t,"");var b=Nt(n[2]);w==="a"&&(b.href&&(t.href=b.href),b.rel&&(t.rel=b.rel),b.target&&(t.target=b.target)),b.class&&(t.class=t.class?t.class+" "+b.class:b.class),b.style&&(a=/(?:^|\s|;)color\s*:\s*([^;\s"']+)/.exec(b.style))&&a[1]&&(t.color=a[1]),w==="br"&&s.push(new J)}else n=[r.slice(0,1)],p(new M(n[0]));r=r.slice(n[0].length)}for(var A=s[s.length-1];A instanceof J;)s.pop(),A=s[s.length-1];return s},Z.latexparser=function(r){r=String(r||"").trim();var n=[0];r=r.replace(/\\verb,(.*?),/,function($,I){return n.push(I),"\\verb,"+(n.length-1)+","}).replace(/\\\\\n/g,function(){return"\\\\"}).replace(sr,function($,I,V){return V.charAt(I-1)==="\\"?$:se[$]}).replace(/\n\s+/g,function($){return/\n/.test($.slice(1))?"\\par ":$}).replace(/\\symbol\{(\d+)\}/,function($,I,V,z){return z.charAt(V-1)==="\\"?$:String.fromCharCode(1*I)}).replace(/(^|[^\\])(\^|_)(\d|[^{]\S*)/g,function($,I,V,z){return I+V+"{"+z+"}"}).replace(/\\verb,(.*?),/,function($,I){return"\\verb,".concat(n[+I],",")});for(var a,t={weight:null,italic:null,variant:null,sub:!1,sup:!1,href:null},s=[],h=[],p=function($){for(var I in t)t[I]&&($[I]=t[I]);return s.push($),$},m=function(){h.push(t),t=Object.create(t)},w=function(){if(!h.length)throw new Error("Unexpected }");t=h.pop()},b={tokens:s,open_context:m,close_context:w,add_token:p};r.length;){if(a=Bt.exec(r))kt(a[0],!1).forEach(p);else if(a=or.exec(r))p(new M(a[1]));else if(!(a=Pe.exec(r))){if(a=/^\{/.exec(r))m();else if(a=/^\}/.exec(r))w();else if(!(a=/^\$/.exec(r)))if(a=/^\\verb,([^,]+),/.exec(r))p(new M(a[1]));else if(a=Oe.exec(r)){var A=a[1].slice(1)||a[1],R=!!a[2];if(/^(La)?TeX$/i.test(A)){m(),t.family="serif";var k=void 0;A==="LaTeX"&&((k=p(new M("L"))).tracking=-.25,(k=p(new M("A"))).size=.7,k.baseline=.3,k.tracking=-.1),(k=p(new M("T"))).tracking=-.17,(k=p(new M("E"))).baseline=-.22,k.tracking=-.13,k=p(new M("X")),w()}else if(A in Tt)p(new M(Tt[A])),R&&m();else if(A in U){var O=[],D=U[A].length-1,W=void 0;if(D){for(R=!1,r=r.slice(a[0].length-1);D--;){if(!(W=/^\{([^}]+)\}/.exec(r)))throw new Error(A+" is missing an argument");O.push(W[1]),r=r.slice(W[0].length)}a[0]=/^\{/.exec(r)?"{":"",R=!!a[0]}R&&m(),U[A].apply(b,[t].concat(O))}else console.warn("unknown latex command",A),p(new M(a[1])),R&&m()}else a=[r.slice(0,1)],p(new M(a[0]))}r=r.slice(a[0].length)}return s},Z.measureText=function(r,n,a){return N(r,P(n),a)},Z.Token=M,Z.Break=ht,Z.LineBreak=J,Z.SoftHyphen=ct,Z.Rotator=De,De.createElement=fe;const fr=Z;return i.default})())})(Mr);var yn=Mr.exports;const $r=Or(yn);function Xe(u){return u.replace(/…$/,"")}function Je(u){return u.children[0].innerHTML}function vn(u,e){const o=gt(u),{fontSize:i,font:l,padding:c=0}=u.properties.style||{};if(o.width===o.height&&o.width===0)return;const f=new $r({font:`${i}px/${i}px ${l}`.replace(/(px)+/g,"px"),width:o.width-c*2,height:o.height-c*2,align:"left",valign:"top",x:0,overflow:"ellipsis",parser:"html",createElement:$r.createElement});f.overflowWrap("break-word");const g=f.linebreak(u.properties.content.replaceAll(`
36
+ `,"<br>")).render(),d=[...g.children];let v=0;const y=[];u.properties.content.split(`
37
37
  `).forEach(E=>{let P=E;for(;P.length&&v<d.length;){if(d[v].innerHTML==="&nbsp;"){P.startsWith(`
38
- `)||y.push(v),v++;break}const S=Ge(Je(d[v]));P.startsWith(S)&&(P=P.slice(S.length).trim()),v++}}),y.forEach(E=>p.removeChild(d[E]));const _=h.properties.content.match(/(https?:\/\/.*)/gm),C=_?_.map(E=>E.split(" ")[0]):[];p.setAttribute("transform",`translate(${c}, ${c})`),C.forEach(E=>{let P=E;const S=[];for(;P.length>0;){const j=d.find(T=>!!T.children[0]&&T.children[0].tagName==="tspan"&&P.startsWith(Ge(Je(T))));if(!j)break;S.push(j);const L=Ge(j.children[0].innerHTML).length;if(!L)break;P=P.slice(L)}S.forEach(j=>{const L=document.createElementNS("http://www.w3.org/2000/svg","a");L.setAttribute("href",E),L.setAttribute("target","_blank"),L.innerHTML=Je(j),j.children[0].innerHTML="",j.children[0].appendChild(L)})}),e.appendChild(p)}const zr=20;class yn extends Ir{constructor(e,s={}){super(e,`
38
+ `)||y.push(v),v++;break}const T=Xe(Je(d[v]));P.startsWith(T)&&(P=P.slice(T.length).trim()),v++}}),y.forEach(E=>g.removeChild(d[E]));const _=u.properties.content.match(/(https?:\/\/.*)/gm),C=_?_.map(E=>E.split(" ")[0]):[];g.setAttribute("transform",`translate(${c}, ${c})`),C.forEach(E=>{let P=E;const T=[];for(;P.length>0;){const j=d.find(S=>!!S.children[0]&&S.children[0].tagName==="tspan"&&P.startsWith(Xe(Je(S))));if(!j)break;T.push(j);const L=Xe(j.children[0].innerHTML).length;if(!L)break;P=P.slice(L)}T.forEach(j=>{const L=document.createElementNS("http://www.w3.org/2000/svg","a");L.setAttribute("href",E),L.setAttribute("target","_blank"),L.innerHTML=Je(j),j.children[0].innerHTML="",j.children[0].appendChild(L)})}),e.appendChild(g)}const zr=20;class mn extends Ir{constructor(e,o={}){super(e,`
39
39
  <div class="annotation-text-handle">
40
40
  <span class="handle line-handle top" data-handle-id="0"></span>
41
41
  <span class="handle line-handle bottom" data-handle-id="1"></span>
@@ -47,4 +47,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
47
47
  <span class="handle left bottom left-handle point-handle bottom-left" data-handle-id="7"></span>
48
48
  <textarea wrap="on"></textarea>
49
49
  </div>
50
- `),x(this,"textArea"),x(this,"handleSize"),x(this,"rect",{x:0,y:0,width:0,height:0}),x(this,"annotation",{...Xe}),x(this,"startX",0),x(this,"startY",0),x(this,"handles",[]),x(this,"draggedHandle",q),x(this,"isFocused",!1),x(this,"placeholder","Type your text here..."),x(this,"_onFocus",()=>{this.textArea.value===this.placeholder&&(this.textArea.value=""),this.isFocused=!0}),x(this,"_onBlur",()=>{this.isFocused=!1}),x(this,"startDrawing",(l,c,f=fn(l,c,0,0,"",jt))=>{this.add(f);const p=this.ogma.view.graphToScreenCoordinates({x:l,y:c});this.select(f.id),this.startDragging(this.getById(f.id),p.x,p.y),this.draggedHandle=6}),x(this,"cancelDrawing",()=>{this.isDragging&&(this.remove(this.annotation.id),this.annotation={...Xe},this.draggedHandle=q,this.isDragging=!1,this.emit(Ft,this.annotation))}),x(this,"startDragging",(l,c,f)=>{this.annotation=l;const p=pt(this.annotation),d=gt(this.annotation);this.rect.x=p.x,this.rect.y=p.y,this.rect.width=d.width,this.rect.height=d.height,this.startX=c,this.startY=f,this.disableDragging(),this.textArea.classList.add("noevents"),this.textArea.setAttribute("disabled","disabled"),this.emit(Ee,this.annotation),this.isDragging=!0}),x(this,"onHandleMouseDown",l=>{const c=this.getById(this.selectedId)||this.getById(this.hoveredId);if(!c)return;this.selectedId!==c.id&&this.select(this.hoveredId);const{x:f,y:p}=He(l,this.ogma.getContainer());this.startDragging(c,f,p),this.draggedHandle=Ar(l.target)}),x(this,"onMouseMove",l=>{requestAnimationFrame(()=>this._onMouseMove(l))}),x(this,"_onMouseMove",l=>{if(!this.isDragging)return;l.stopPropagation(),l.preventDefault();const c=this.handles[this.draggedHandle],f=c.classList.contains("top"),p=c.classList.contains("left"),d=c.classList.contains("right"),v=c.classList.contains("bottom"),y=c.classList.contains("line-handle"),{x:_,y:C}=He(l,this.ogma.getContainer()),E=this.ogma.view.getZoom(),P=(_-this.startX)/E,S=(C-this.startY)/E,j=this.ogma.view.getAngle(),L=st({x:P,y:S},j);(v&&p||f&&d)&&(L.y=0,L.x=0);const T=p||y?this.rect.x+L.x:this.rect.x,H=f||y?this.rect.y+L.y:this.rect.y,N=Math.max(this.rect.width+P*(y||p?0:1),zr),at=Math.max(this.rect.height+S*(y||f?0:1),zr);rn(this.annotation,T,H,N,at),this.emit(Ae,this.annotation,"text"),this.refreshEditor(),this.layer.refresh()}),x(this,"onMouseUp",()=>{!this.isDragging||this.draggedHandle===q||(this.restoreDragging(),this.textArea.classList.remove("noevents"),this.textArea.removeAttribute("disabled"),this.emit(Ft,this.annotation),this.isDragging=!1,this.draggedHandle=q)}),x(this,"_onMousedown",l=>{l.stopPropagation()}),x(this,"onViewChanged",()=>{const l=Math.max(2,this.handleSize/this.ogma.view.getZoom());document.documentElement.style.setProperty("--handle-scale",`${1/l}`)}),x(this,"_onInput",()=>{const l=this.getById(this.selectedId);l&&(this.textArea.value=this.textArea.value.replace(/ +(?= )/g,""),this.textArea.focus(),l.properties.content=this.textArea.value,this.emit(qe,l),this.layer.refresh())}),this.showeditorOnHover=!1,this.handleSize=Dr.handleSize,this.placeholder=Dr.placeholder;const i=this.textArea=this.editor.element.querySelector("textarea");i.addEventListener("input",this._onInput),i.addEventListener("focus",this._onFocus),i.addEventListener("blur",this._onBlur),i.addEventListener("mousedown",this._onMousedown),i.spellcheck=!1,this.handles=Array.prototype.slice.call(this.editor.element.querySelectorAll(".annotation-text-handle > .handle")),this.handles.forEach(l=>l.addEventListener("mousedown",this.onHandleMouseDown)),document.addEventListener("mouseup",this.onMouseUp),document.addEventListener("mousemove",this.onMouseMove,!0),e.events.on(["viewChanged","zoom"],this.onViewChanged)}_canRemove(){return!this.isFocused}detect({x:e,y:s},i=0){const l={x:e,y:s},c=this.ogma.view.getAngle();return this.elements.find(f=>{const{x:p,y:d}=pt(f),{width:v,height:y}=gt(f),_={x:p,y:d},{x:C,y:E}=st(Et(l,_),-c);return C>-i&&C<v+i&&E>-i&&E<y+i})}draw(e){e.innerHTML="";const s="",i=this.ogma.view.getAngle();this.elements.forEach((c,f)=>{const p=`class${f}`,d=gt(c),v=pt(c),y=c.id,{color:_,fontSize:C,font:E,strokeColor:P,strokeWidth:S,strokeType:j,background:L}=c.properties.style||jt;if(y===this.selectedId)return;const T=Jt("g");T.classList.add("annotation-text"),T.setAttribute("fill",`${_}`),T.setAttribute("font-size",`${C}px`),T.setAttribute("font-family",`${E}`);const H=Jt("rect");let N=!1;j&&j!=="none"&&(N=!0,H.setAttribute("stroke",P||"black"),H.setAttribute("stroke-width",`${S}`),j==="dashed"&&H.setAttribute("stroke-dasharray","5,5")),(L&&L.length||N)&&(N=!0,H.setAttribute("fill",L||"transparent")),N&&(H.setAttribute("width",`${d.width}`),H.setAttribute("height",`${d.height}`)),T.appendChild(H),pn(c,T);const{x:at,y:_t}=st(v,-i);T.setAttribute("transform",`translate(${at},${_t})`),T.classList.add(p),T.setAttribute("data-annotation",`${c.id}`),T.setAttribute("data-annotation-type","text"),e.appendChild(T)});const l=Jt("style");l.innerHTML=s,e.firstChild&&e.insertBefore(l,e.firstChild)}refreshDrawing(){const e=this.ogma.view.getAngle();[...this.layer.element.children].forEach(s=>{const i=s.getAttribute("data-annotation");if(!i)return;const l=pt(this.getById(i)),{x:c,y:f}=st(l,-e);s.setAttribute("transform",`translate(${c},${f})`)})}getDefaultOptions(){return Xe}refreshEditor(){if(+this.selectedId<0&&+this.hoveredId<0)return;const e=this.getById(this.selectedId)||this.getById(this.hoveredId),s=gt(e),i=this.ogma.view.graphToScreenCoordinates(pt(e)),l=this.ogma.view.getZoom(),{font:c,fontSize:f,color:p,background:d,padding:v=0}=e.properties.style||jt,y=(f||1)*l;this.textArea.value=e.properties.content,this.editor.element.style.transform=`translate(${i.x}px, ${i.y}px)translate(-50%, -50%)translate(${s.width/2*l}px, ${s.height/2*l}px)`,this.editor.element.style.width=`${s.width*l}px`,this.editor.element.style.height=`${s.height*l}px`,this.textArea.style.font=`${y} ${c}`,this.textArea.style.fontFamily=c||"sans-serif",this.textArea.style.fontSize=`${y}px`,this.textArea.style.padding=`${l*v}px`,this.textArea.style.lineHeight=`${y}px`,this.textArea.style.boxSizing="border-box",this.textArea.style.color=p||"black",this.textArea.style.background=d||"transparent",this.textArea.placeholder=this.placeholder,this.layer.refresh()}select(e){super.select(e),this.textArea.focus()}destroy(){super.destroy(),document.removeEventListener("mouseup",this.onMouseUp),document.removeEventListener("mousemove",this.onMouseMove,!0),this.ogma.events.off(this.onViewChanged)}}class vn{constructor(){x(this,"links",{}),x(this,"linksByTargetId",{}),x(this,"linksByArrowId",{})}add(e,s,i,l,c){const f=ye(),p=e.id,d={id:f,arrow:p,target:i,targetType:l,connectionPoint:c,side:s};return this.links[f]=d,this.linksByTargetId[i]||(this.linksByTargetId[i]=[]),this.linksByTargetId[i].push(f),this.linksByArrowId[p]||(this.linksByArrowId[p]={}),this.linksByArrowId[p][s]=f,e.properties.link=e.properties.link||{},e.properties.link[s]={id:i,side:s,type:l,magnet:c},this}arrowIsLinked(e,s){var i;return!!((i=this.linksByArrowId[e])!=null&&i[s])}remove(e,s){var i,l;const c=e.id,f=(i=this.linksByArrowId[c])==null?void 0:i[s];if((l=e.properties.link)==null||delete l[s],!f)return this;const p=this.links[f];delete this.links[f];const d=this.linksByTargetId[p.target];for(let v=0;v<d.length;v++)if(d[v]===f){d.splice(v,1);break}return delete this.linksByArrowId[c][s],this}getArrowLink(e,s){var i;const l=(i=this.linksByArrowId[e])==null?void 0:i[s];return l?this.links[l]:null}getTargetLinks(e,s){var i;return((i=this.linksByTargetId[e])==null?void 0:i.map(l=>this.links[l]).filter(l=>l.targetType===s))??[]}forEach(e){Object.values(this.links).forEach(e)}}const ht=h=>h.properties.type==="arrow",wt=h=>h.properties.type==="text",Nr=h=>h.type==="FeatureCollection",mn={magnetColor:"#3e8",detectMargin:20,magnetHandleRadius:5,magnetRadius:10,textPlaceholder:"Type here",arrowHandleSize:3.5,textHandleSize:3.5,minArrowHeight:20,maxArrowHeight:30},Br=["start","end"],Hr=[{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 bn extends Rr{constructor(e,s={}){super(),x(this,"arrows"),x(this,"texts"),x(this,"links",new vn),x(this,"layer"),x(this,"annotations"),x(this,"ogma"),x(this,"options"),x(this,"selected",null),x(this,"updateTimeout",0),x(this,"hoveredNode",null),x(this,"dragged",null),x(this,"textToMagnet"),x(this,"activeLinks",[]),x(this,"_render",i=>{if(!this.dragged||this.textToMagnet===void 0)return;i.beginPath(),i.fillStyle="green";const l=this.ogma.view.getZoom();Hr.forEach(c=>{if(!this.textToMagnet)return;const f=gt(this.textToMagnet),p=pt(this.textToMagnet),d=xe(c,{x:f.width,y:f.height}),v=st(d,this.ogma.view.getAngle()),{x:y,y:_}=Lt(v,p);i.moveTo(y,_),i.arc(y,_,this.options.magnetHandleRadius/l,0,Math.PI*2)}),i.fill(),i.closePath()}),x(this,"_onFeatureDrag",(i,l)=>{const c=l;if(ht(i)&&c==="line")["start","end"].find(f=>{const p=f==="start"?Zt(i):me(i);return this._snapToText(i,c,p)||this._findAndSnapToNode(i,f,p)});else if(ht(i)&&c!=="line"){const f=c==="start"?Zt(i):me(i);this._snapToText(i,c,f)||this._findAndSnapToNode(i,c,f)}else wt(i)&&(this.activeLinks.forEach(({arrow:f,side:p,connectionPoint:d})=>{const v=this.getAnnotation(f),y=gt(i),_=pt(i),C=xe(d,{x:y.width,y:y.height}),E=st(C,this.ogma.view.getAngle()),P=Lt(E,_);v.geometry.coordinates[p==="start"?0:1]=[P.x,P.y]}),this.activeLinks.length&&this.arrows.refreshLayer());this.layer.refresh(),this.emit(Ae,i,l)}),x(this,"_onFeatureDragEnd",i=>{this.dragged!==null&&ht(i)&&Zt(this.dragged)&&Br.forEach(l=>{this.links.getArrowLink(i.id,l)&&this.emit(hn,{arrow:i,link:this.links.getArrowLink(i.id,l)})}),(wt(i)||ht(i))&&this.onUpdate(i),this.dragged=null,this.activeLinks=[],this.textToMagnet=void 0,this.annotations.forEach(l=>l.enableDetection()),this.layer.refresh(),this.emit(Ft,i)}),x(this,"_onFeatureDragStart",i=>{this.textToMagnet=void 0,ht(i)?this.dragged=i:wt(i)&&this.activeLinks.push(...this.links.getTargetLinks(i.id,"text")),this.annotations.forEach(l=>{const c=l.getSelectedFeature();c&&c!==i&&l.unhover().unselect(),l.disableDetection()}),this.emit(Ee,i)}),x(this,"_onNodesDragStart",()=>{this.arrows.unhover().unselect(),this.texts.unhover().unselect()}),x(this,"_onNodesDrag",i=>{const{dx:l,dy:c}=i;this._moveNodes(i.nodes,l,c)}),x(this,"_onLayoutEnd",i=>{i.ids.forEach((l,c)=>{this.links.getTargetLinks(l,"node").forEach(f=>{const p=this.getAnnotation(f.arrow),d=f.side,v=ve(p,d==="start"?"end":"start"),y=i.positions.current[c],_=this.ogma.getNode(l).getAttribute("radius"),C=we(v,y,+_);Rt(p,d,C.x,C.y)})}),this.arrows.refreshLayer(),this.texts.refreshLayer()}),x(this,"_onAdded",i=>{this.emit(Ye,i)}),x(this,"_onRemoved",i=>{this.emit(Ve,i)}),x(this,"_onUnselect",i=>{this.selected=null,this.emit(Ue,i)}),x(this,"_onSelect",i=>{this.selected!==i&&(this.selected=i,this.emit(We,this.selected))}),x(this,"onUpdate",i=>{cancelAnimationFrame(this.updateTimeout),this.updateTimeout=requestAnimationFrame(()=>this._onUpdate(i))}),x(this,"_onUpdate",i=>{this.emit(qe,i)}),this.options=this.setOptions({...mn,...s}),this.ogma=e,this.arrows=new dn(e,this.options),this.texts=new yn(e,this.options),this.annotations=[this.arrows,this.texts],this.annotations.forEach(i=>{i.on(Ee,this._onFeatureDragStart).on(Ae,this._onFeatureDrag).on(Ft,this._onFeatureDragEnd).on(qe,this.onUpdate).on(Ue,this._onUnselect).on(We,this._onSelect).on(Ye,this._onAdded).on(Ve,this._onRemoved)}),this.ogma.events.on("nodesDragStart",this._onNodesDragStart).on("nodesDragProgress",this._onNodesDrag).on("layoutEnd",this._onLayoutEnd).on(["viewChanged","rotate"],()=>{this.refreshTextLinks()}),this.layer=e.layers.addCanvasLayer(this._render),this.layer.moveToBottom()}_moveNodes(e,s,i){e.forEach(l=>{const c=this.links.getTargetLinks(l.getId(),"node"),f=l.getPosition();c.forEach(p=>{const d=this.getAnnotation(p.arrow),v=p.side,y=ve(d,v==="start"?"end":"start");let _=f;const C=+l.getAttribute("radius"),E=1e-6;(p.connectionPoint.x-(f.x-s)>E||p.connectionPoint.y-(f.y-i)>E)&&(_=we(y,f,C)),Rt(d,v,_.x,_.y)})}),this.arrows.refreshLayer()}_snapToText(e,s,i){const l=this.texts.detect(i,this.options.detectMargin);if(this.links.remove(e,s),!l)return!1;this.textToMagnet=l;const c=this.findMagnetPoint(Hr,l,i);return c?(Rt(e,s,c.point.x,c.point.y),this.links.add(e,s,l.id,"text",c.magnet),!0):!1}_findAndSnapToNode(e,s,i){var l,c;const f=this.ogma.view.graphToScreenCoordinates(i),p=this.ogma.view.getElementAt(f);this.links.remove(e,s),p&&p.isNode?((l=this.hoveredNode)==null||l.setSelected(!1),this.hoveredNode=p,p.setSelected(!0),this._snapToNode(e,s,p,f)):((c=this.hoveredNode)==null||c.setSelected(!1),this.hoveredNode=null)}_snapToNode(e,s,i,l){const c=i.getPositionOnScreen(),f=+i.getAttribute("radius"),p=f*this.ogma.view.getZoom(),d=l.x-c.x,v=l.y-c.y,y=Math.sqrt(d*d+v*v),_=i.getPosition();if(y<p+this.options.detectMargin){let C=_;if(y>p/2){const E=ve(e,s==="end"?"start":"end");C=we(E,C,f)}Rt(e,s,C.x,C.y),this.links.add(e,s,i.getId(),"node",C)}}refreshTextLinks(){let e=!1;this.links.forEach(({connectionPoint:s,targetType:i,target:l,arrow:c,side:f})=>{if(i!=="text")return;e=!0;const p=this.getAnnotation(l),d=this.getAnnotation(c),v=gt(p),y=pt(p),_=xe(s,{x:v.width,y:v.height}),C=st(_,this.ogma.view.getAngle()),E=Lt(C,y);Rt(d,f,E.x,E.y)}),e&&this.arrows.refreshLayer()}getSelected(){return this.selected}findMagnetPoint(e,s,i){let l;for(const c of e){const f=gt(s),p=pt(s),d=xe(c,{x:f.width,y:f.height}),v=st(d,this.ogma.view.getAngle()),y=Lt(v,p),_=It(Et(y,i)),C=Math.min(this.options.magnetRadius*this.ogma.view.getZoom(),f.width/2,f.height/2);if(_<Math.max(C,this.options.magnetHandleRadius)){l={point:y,magnet:c};break}}return l}setOptions(e={}){return this.options={...this.options||{},...e},this.options}select(e){const s=this.getAnnotations().features.find(i=>i.id===e);return s?(ht(s)?this.arrows.select(s.id):wt(s)&&this.texts.select(s.id),this):this}unselect(){return this.selected?(ht(this.selected)?this.arrows.unselect():wt(this.selected)&&this.texts.unselect(),this):this}add(e){if(Nr(e)){const[s,i]=e.features.reduce((l,c)=>(ht(c)?l[1].push(c):wt(c)&&l[0].push(c),l),[[],[]]);return s.forEach(l=>this.add(l)),i.forEach(l=>this.add(l)),this.arrows.refreshLayer(),this}switch(e.properties.type){case"text":this.texts.add(e);break;default:this.arrows.add(e),this.loadLink(e);break}return this}remove(e){return Nr(e)?(e.features.forEach(s=>this.remove(s)),this):(ht(e)?(this.links.remove(e,"start"),this.links.remove(e,"end"),this.arrows.remove(e.id)):this.texts.remove(e.id),this)}loadLink(e){if(e.properties.link)for(const s of Br){const i=e.properties.link[s];if(!i)continue;const l=this.getAnnotation(i.id);if(i.type==="text"&&l)this.links.add(e,s,i.id,i.type,i.magnet);else if(i.type==="node"){const c=this.ogma.getNode(i.id);if(!c)continue;this.links.add(e,s,i.id,i.type,i.magnet);const f=c.getPosition(),p=c.getAttribute("radius")||0,d=ve(e,s==="start"?"end":"start"),v=we(d,f,+p);Rt(e,s,v.x,v.y)}}}startArrow(e,s,i){this.cancelDrawing(),this.arrows.startDrawing(e,s,i)}startText(e,s,i){this.cancelDrawing(),this.texts.startDrawing(e,s,i)}cancelDrawing(){this.annotations.forEach(e=>e.cancelDrawing()),this.emit(ln)}updateStyle(e,s){const i=this.getAnnotations().features.find(l=>l.id===e);return i?(ht(i)?this.arrows.updateStyle(i,s):wt(i)&&this.texts.updateStyle(i,s),this.onUpdate(i),this):this}getAnnotations(){const e={type:"FeatureCollection",features:[]};return this.annotations.forEach(s=>{e.features=[...e.features,...s.getElements()]}),e}getAnnotation(e){return this.getAnnotations().features.find(s=>s.id===e)}destroy(){this.annotations.forEach(e=>e.destroy()),this.layer.destroy()}}const Ze=[8,10,12,14,16,24,32,48,64,72],Ke="none",Qe="#333333",wn=["#FFFFFF","#F44E3B","#FE9200","#FCDC00","#A4DD00","#68CCCA","#73D8FF","#AEA1FF","#1E88E5","#333333","#808080","#cccccc"],xn=["Roboto","Helvetica Neue","Helvetica","Arial","sans-serif","Georgia, serif","Menlo","Monaco","Consolas","Courier New","monospace"].sort((h,e)=>h.toLocaleLowerCase().localeCompare(e.toLocaleLowerCase())),Wr={head:"arrow",strokeColor:Qe,strokeWidth:5},Ur=.25,Vr={font:"Roboto",fontSize:Ze[2],padding:Ze[2]*Ur,color:Qe,strokeType:Ke,background:Ke};function Yr(h){return h.reduce((e,s)=>e+s,0)/h.length}function An(h,e=0,s=1){return e+(s-e)*h}function En(h,e=0,s=1){return(h-e)/(s-e)}function _n(){return G.createContext(null)}const tr=G.createContext(void 0),kn=()=>G.useContext(tr),Tn=(h,e)=>{switch(e.type){case"add":return{...h,features:[...h.features,e.payload]};case"remove":return{...h,features:h.features.filter(s=>s.id!==e.payload.id)};case"update":return{...h,features:h.features.map(s=>s.id===e.payload.id?e.payload:s)};default:return h}},Sn=({children:h})=>{const e=qr.useOgma(),[s,i]=G.useReducer(Tn,{type:"FeatureCollection",features:[]}),[l,c]=G.useState(null),[f,p]=G.useState(Wr),[d,v]=G.useState(Vr),[y,_]=G.useState(),[C,E]=G.useState(1),[P,S]=G.useState(1);return G.useEffect(()=>{if(!e)return;const j=new bn(e,{minArrowHeight:1}),L=Yr(e.getNodes().getAttribute("radius"))/5,T=C;return p({...f,strokeWidth:(f.strokeWidth||1)*T}),E(T),S(L),j.on("select",H=>{ht(H)?p({...H.properties.style||{}}):wt(H)&&v({...H.properties.style||{}}),c(H)}).on("unselect",()=>{c(null)}),_(j),()=>{y==null||y.destroy()}},[e]),G.useEffect(()=>{y&&l&&(l==null?void 0:l.properties.type)==="arrow"&&y.updateStyle(l.id,f)},[y,f,l]),G.useEffect(()=>{y&&l&&(l==null?void 0:l.properties.type)==="text"&&y.updateStyle(l.id,d)},[y,d,l]),Jr.jsx(tr.Provider,{value:{annotations:s,updateAnnotations:i,currentAnnotation:l,setCurrentAnnotation:c,textStyle:d,setTextStyle:v,arrowStyle:f,setArrowStyle:p,arrowWidthFactor:C,setArrowWidthFactor:E,textSizeFactor:P,setTextSizeFactor:S,editor:y,setEditor:_},children:h})};B.AnnotationsContext=tr,B.AnnotationsContextProvider=Sn,B.BLACK=Qe,B.RELATIVE_PADDING=Ur,B.TRANSPARENT=Ke,B.createAnnotationsContext=_n,B.defaultArrowStyle=Wr,B.defaultColors=wn,B.defaultTextStyle=Vr,B.fontSizes=Ze,B.fonts=xn,B.interpolate=An,B.mean=Yr,B.normalize=En,B.useAnnotationsContext=kn,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"})});
50
+ `),x(this,"textArea"),x(this,"handleSize"),x(this,"rect",{x:0,y:0,width:0,height:0}),x(this,"annotation",{...qe}),x(this,"startX",0),x(this,"startY",0),x(this,"handles",[]),x(this,"draggedHandle",G),x(this,"isFocused",!1),x(this,"placeholder","Type your text here..."),x(this,"_onFocus",()=>{this.textArea.value===this.placeholder&&(this.textArea.value=""),this.isFocused=!0}),x(this,"_onBlur",()=>{this.isFocused=!1}),x(this,"startDrawing",(l,c,f=pn(l,c,0,0,"",jt))=>{this.add(f);const g=this.ogma.view.graphToScreenCoordinates({x:l,y:c});this.select(f.id),this.startDragging(this.getById(f.id),g.x,g.y),this.draggedHandle=6}),x(this,"cancelDrawing",()=>{this.isDragging&&(this.remove(this.annotation.id),this.annotation={...qe},this.draggedHandle=G,this.isDragging=!1,this.emit(Ft,this.annotation))}),x(this,"startDragging",(l,c,f)=>{this.annotation=l;const g=pt(this.annotation),d=gt(this.annotation);this.rect.x=g.x,this.rect.y=g.y,this.rect.width=d.width,this.rect.height=d.height,this.startX=c,this.startY=f,this.disableDragging(),this.textArea.classList.add("noevents"),this.textArea.setAttribute("disabled","disabled"),this.emit(Ee,this.annotation),this.isDragging=!0}),x(this,"onHandleMouseDown",l=>{const c=this.getById(this.selectedId)||this.getById(this.hoveredId);if(!c)return;this.selectedId!==c.id&&this.select(this.hoveredId);const{x:f,y:g}=He(l,this.ogma.getContainer());this.startDragging(c,f,g),this.draggedHandle=Ar(l.target)}),x(this,"onMouseMove",l=>{requestAnimationFrame(()=>this._onMouseMove(l))}),x(this,"_onMouseMove",l=>{if(!this.isDragging)return;l.stopPropagation(),l.preventDefault();const c=this.handles[this.draggedHandle],f=c.classList.contains("top"),g=c.classList.contains("left"),d=c.classList.contains("right"),v=c.classList.contains("bottom"),y=c.classList.contains("line-handle"),{x:_,y:C}=He(l,this.ogma.getContainer()),E=this.ogma.view.getZoom(),P=(_-this.startX)/E,T=(C-this.startY)/E,j=this.ogma.view.getAngle(),L=st({x:P,y:T},j);(v&&g||f&&d)&&(L.y=0,L.x=0);const S=g||y?this.rect.x+L.x:this.rect.x,H=f||y?this.rect.y+L.y:this.rect.y,N=Math.max(this.rect.width+P*(y||g?0:1),zr),lt=Math.max(this.rect.height+T*(y||f?0:1),zr);rn(this.annotation,S,H,N,lt),this.emit(Ae,this.annotation,"text"),this.refreshEditor(),this.layer.refresh()}),x(this,"onMouseUp",()=>{!this.isDragging||this.draggedHandle===G||(this.restoreDragging(),this.textArea.classList.remove("noevents"),this.textArea.removeAttribute("disabled"),this.emit(Ft,this.annotation),this.isDragging=!1,this.draggedHandle=G)}),x(this,"_onMousedown",l=>{l.stopPropagation()}),x(this,"onViewChanged",()=>{const l=Math.max(2,this.handleSize/this.ogma.view.getZoom());document.documentElement.style.setProperty("--handle-scale",`${1/l}`)}),x(this,"_onInput",()=>{const l=this.getById(this.selectedId);l&&(this.textArea.value=this.textArea.value.replace(/ +(?= )/g,""),this.textArea.focus(),l.properties.content=this.textArea.value,this.emit(Ge,l),this.layer.refresh())}),this.showeditorOnHover=!1,this.handleSize=Dr.handleSize,this.placeholder=Dr.placeholder;const i=this.textArea=this.editor.element.querySelector("textarea");i.addEventListener("input",this._onInput),i.addEventListener("focus",this._onFocus),i.addEventListener("blur",this._onBlur),i.addEventListener("mousedown",this._onMousedown),i.spellcheck=!1,this.handles=Array.prototype.slice.call(this.editor.element.querySelectorAll(".annotation-text-handle > .handle")),this.handles.forEach(l=>l.addEventListener("mousedown",this.onHandleMouseDown)),document.addEventListener("mouseup",this.onMouseUp),document.addEventListener("mousemove",this.onMouseMove,!0),e.events.on(["viewChanged","zoom"],this.onViewChanged)}_canRemove(){return!this.isFocused}detect({x:e,y:o},i=0){const l={x:e,y:o},c=this.ogma.view.getAngle();return this.elements.find(f=>{const{x:g,y:d}=pt(f),{width:v,height:y}=gt(f),_={x:g,y:d},{x:C,y:E}=st(Et(l,_),-c);return C>-i&&C<v+i&&E>-i&&E<y+i})}draw(e){e.innerHTML="";const o="",i=this.ogma.view.getAngle();this.elements.forEach((c,f)=>{const g=`class${f}`,d=gt(c),v=pt(c),y=c.id,{color:_,fontSize:C,font:E,strokeColor:P,strokeWidth:T,strokeType:j,background:L}=c.properties.style||jt;if(y===this.selectedId)return;const S=Jt("g");S.classList.add("annotation-text"),S.setAttribute("fill",`${_}`),S.setAttribute("font-size",`${C}px`),S.setAttribute("font-family",`${E}`);const H=Jt("rect");let N=!1;j&&j!=="none"&&(N=!0,H.setAttribute("stroke",P||"black"),H.setAttribute("stroke-width",`${T}`),j==="dashed"&&H.setAttribute("stroke-dasharray","5,5")),(L&&L.length||N)&&(N=!0,H.setAttribute("fill",L||"transparent")),N&&(H.setAttribute("width",`${d.width}`),H.setAttribute("height",`${d.height}`)),S.appendChild(H),vn(c,S);const{x:lt,y:_t}=st(v,-i);S.setAttribute("transform",`translate(${lt},${_t})`),S.classList.add(g),S.setAttribute("data-annotation",`${c.id}`),S.setAttribute("data-annotation-type","text"),e.appendChild(S)});const l=Jt("style");l.innerHTML=o,e.firstChild&&e.insertBefore(l,e.firstChild)}refreshDrawing(){const e=this.ogma.view.getAngle();[...this.layer.element.children].forEach(o=>{const i=o.getAttribute("data-annotation");if(!i)return;const l=pt(this.getById(i)),{x:c,y:f}=st(l,-e);o.setAttribute("transform",`translate(${c},${f})`)})}getDefaultOptions(){return qe}refreshEditor(){if(+this.selectedId<0&&+this.hoveredId<0)return;const e=this.getById(this.selectedId)||this.getById(this.hoveredId),o=gt(e),i=this.ogma.view.graphToScreenCoordinates(pt(e)),l=this.ogma.view.getZoom(),{font:c,fontSize:f,color:g,background:d,padding:v=0}=e.properties.style||jt,y=(f||1)*l;this.textArea.value=e.properties.content,this.editor.element.style.transform=`translate(${i.x}px, ${i.y}px)translate(-50%, -50%)translate(${o.width/2*l}px, ${o.height/2*l}px)`,this.editor.element.style.width=`${o.width*l}px`,this.editor.element.style.height=`${o.height*l}px`,this.textArea.style.font=`${y} ${c}`,this.textArea.style.fontFamily=c||"sans-serif",this.textArea.style.fontSize=`${y}px`,this.textArea.style.padding=`${l*v}px`,this.textArea.style.lineHeight=`${y}px`,this.textArea.style.boxSizing="border-box",this.textArea.style.color=g||"black",this.textArea.style.background=d||"transparent",this.textArea.placeholder=this.placeholder,this.layer.refresh()}select(e){super.select(e),this.textArea.focus()}destroy(){super.destroy(),document.removeEventListener("mouseup",this.onMouseUp),document.removeEventListener("mousemove",this.onMouseMove,!0),this.ogma.events.off(this.onViewChanged)}}class bn{constructor(){x(this,"links",{}),x(this,"linksByTargetId",{}),x(this,"linksByArrowId",{})}add(e,o,i,l,c){const f=ye(),g=e.id,d={id:f,arrow:g,target:i,targetType:l,connectionPoint:c,side:o};return this.links[f]=d,this.linksByTargetId[i]||(this.linksByTargetId[i]=[]),this.linksByTargetId[i].push(f),this.linksByArrowId[g]||(this.linksByArrowId[g]={}),this.linksByArrowId[g][o]=f,e.properties.link=e.properties.link||{},e.properties.link[o]={id:i,side:o,type:l,magnet:c},this}arrowIsLinked(e,o){var i;return!!((i=this.linksByArrowId[e])!=null&&i[o])}remove(e,o){var i,l;const c=e.id,f=(i=this.linksByArrowId[c])==null?void 0:i[o];if((l=e.properties.link)==null||delete l[o],!f)return this;const g=this.links[f];delete this.links[f];const d=this.linksByTargetId[g.target];for(let v=0;v<d.length;v++)if(d[v]===f){d.splice(v,1);break}return delete this.linksByArrowId[c][o],this}getArrowLink(e,o){var i;const l=(i=this.linksByArrowId[e])==null?void 0:i[o];return l?this.links[l]:null}getTargetLinks(e,o){var i;return((i=this.linksByTargetId[e])==null?void 0:i.map(l=>this.links[l]).filter(l=>l.targetType===o))??[]}forEach(e){Object.values(this.links).forEach(e)}}const at=u=>u.properties.type==="arrow",yt=u=>u.properties.type==="text",Nr=u=>u.type==="FeatureCollection",wn={magnetColor:"#3e8",detectMargin:20,magnetHandleRadius:5,magnetRadius:10,textPlaceholder:"Type here",arrowHandleSize:3.5,textHandleSize:3.5,minArrowHeight:20,maxArrowHeight:30},Br=["start","end"],Hr=[{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 xn extends Rr{constructor(e,o={}){super(),x(this,"arrows"),x(this,"texts"),x(this,"links",new bn),x(this,"layer"),x(this,"annotations"),x(this,"ogma"),x(this,"options"),x(this,"selected",null),x(this,"updateTimeout",0),x(this,"hoveredNode",null),x(this,"dragged",null),x(this,"textToMagnet"),x(this,"activeLinks",[]),x(this,"_render",i=>{if(!this.dragged||this.textToMagnet===void 0)return;i.beginPath(),i.fillStyle="green";const l=this.ogma.view.getZoom();Hr.forEach(c=>{if(!this.textToMagnet)return;const f=gt(this.textToMagnet),g=pt(this.textToMagnet),d=xe(c,{x:f.width,y:f.height}),v=st(d,this.ogma.view.getAngle()),{x:y,y:_}=Lt(v,g);i.moveTo(y,_),i.arc(y,_,this.options.magnetHandleRadius/l,0,Math.PI*2)}),i.fill(),i.closePath()}),x(this,"_onFeatureDrag",(i,l)=>{const c=l;if(at(i)&&c==="line")["start","end"].find(f=>{const g=f==="start"?Zt(i):me(i);return this._snapToText(i,c,g)||this._findAndSnapToNode(i,f,g)});else if(at(i)&&c!=="line"){const f=c==="start"?Zt(i):me(i);this._snapToText(i,c,f)||this._findAndSnapToNode(i,c,f)}else yt(i)&&(this.activeLinks.forEach(({arrow:f,side:g,connectionPoint:d})=>{const v=this.getAnnotation(f),y=gt(i),_=pt(i),C=xe(d,{x:y.width,y:y.height}),E=st(C,this.ogma.view.getAngle()),P=Lt(E,_);v.geometry.coordinates[g==="start"?0:1]=[P.x,P.y]}),this.activeLinks.length&&this.arrows.refreshLayer());this.layer.refresh(),this.emit(Ae,i,l)}),x(this,"_onFeatureDragEnd",i=>{this.dragged!==null&&at(i)&&Zt(this.dragged)&&Br.forEach(l=>{this.links.getArrowLink(i.id,l)&&this.emit(cn,{arrow:i,link:this.links.getArrowLink(i.id,l)})}),(yt(i)||at(i))&&this.onUpdate(i),this.dragged=null,this.activeLinks=[],this.textToMagnet=void 0,this.annotations.forEach(l=>l.enableDetection()),this.layer.refresh(),this.emit(Ft,i)}),x(this,"_onFeatureDragStart",i=>{this.textToMagnet=void 0,at(i)?this.dragged=i:yt(i)&&this.activeLinks.push(...this.links.getTargetLinks(i.id,"text")),this.annotations.forEach(l=>{const c=l.getSelectedFeature();c&&c!==i&&l.unhover().unselect(),l.disableDetection()}),this.emit(Ee,i)}),x(this,"_onNodesDragStart",()=>{this.arrows.unhover().unselect(),this.texts.unhover().unselect()}),x(this,"_onNodesDrag",i=>{const{dx:l,dy:c}=i;this._moveNodes(i.nodes,l,c)}),x(this,"_onLayoutEnd",i=>{i.ids.forEach((l,c)=>{this.links.getTargetLinks(l,"node").forEach(f=>{const g=this.getAnnotation(f.arrow),d=f.side,v=ve(g,d==="start"?"end":"start"),y=i.positions.current[c],_=this.ogma.getNode(l).getAttribute("radius"),C=we(v,y,+_);Rt(g,d,C.x,C.y)})}),this.arrows.refreshLayer(),this.texts.refreshLayer()}),x(this,"_onAdded",i=>{this.emit(Ye,i)}),x(this,"_onRemoved",i=>{this.emit(Ve,i)}),x(this,"_onUnselect",i=>{this.selected=null,this.emit(We,i)}),x(this,"_onSelect",i=>{this.selected!==i&&(this.selected=i,this.emit(Ue,this.selected))}),x(this,"onUpdate",i=>{cancelAnimationFrame(this.updateTimeout),this.updateTimeout=requestAnimationFrame(()=>this._onUpdate(i))}),x(this,"_onUpdate",i=>{this.emit(Ge,i)}),this.options=this.setOptions({...wn,...o}),this.ogma=e,this.arrows=new gn(e,this.options),this.texts=new mn(e,this.options),this.annotations=[this.arrows,this.texts],this.annotations.forEach(i=>{i.on(Ee,this._onFeatureDragStart).on(Ae,this._onFeatureDrag).on(Ft,this._onFeatureDragEnd).on(Ge,this.onUpdate).on(We,this._onUnselect).on(Ue,this._onSelect).on(Ye,this._onAdded).on(Ve,this._onRemoved)}),this.ogma.events.on("nodesDragStart",this._onNodesDragStart).on("nodesDragProgress",this._onNodesDrag).on("layoutEnd",this._onLayoutEnd).on(["viewChanged","rotate"],()=>{this.refreshTextLinks()}),this.layer=e.layers.addCanvasLayer(this._render),this.layer.moveToBottom()}_moveNodes(e,o,i){e.forEach(l=>{const c=this.links.getTargetLinks(l.getId(),"node"),f=l.getPosition();c.forEach(g=>{const d=this.getAnnotation(g.arrow),v=g.side,y=ve(d,v==="start"?"end":"start");let _=f;const C=+l.getAttribute("radius"),E=1e-6;(g.connectionPoint.x-(f.x-o)>E||g.connectionPoint.y-(f.y-i)>E)&&(_=we(y,f,C)),Rt(d,v,_.x,_.y)})}),this.arrows.refreshLayer()}_snapToText(e,o,i){const l=this.texts.detect(i,this.options.detectMargin);if(this.links.remove(e,o),!l)return!1;this.textToMagnet=l;const c=this.findMagnetPoint(Hr,l,i);return c?(Rt(e,o,c.point.x,c.point.y),this.links.add(e,o,l.id,"text",c.magnet),!0):!1}_findAndSnapToNode(e,o,i){var l,c;const f=this.ogma.view.graphToScreenCoordinates(i),g=this.ogma.view.getElementAt(f);this.links.remove(e,o),g&&g.isNode?((l=this.hoveredNode)==null||l.setSelected(!1),this.hoveredNode=g,g.setSelected(!0),this._snapToNode(e,o,g,f)):((c=this.hoveredNode)==null||c.setSelected(!1),this.hoveredNode=null)}_snapToNode(e,o,i,l){const c=i.getPositionOnScreen(),f=+i.getAttribute("radius"),g=f*this.ogma.view.getZoom(),d=l.x-c.x,v=l.y-c.y,y=Math.sqrt(d*d+v*v),_=i.getPosition();if(y<g+this.options.detectMargin){let C=_;if(y>g/2){const E=ve(e,o==="end"?"start":"end");C=we(E,C,f)}Rt(e,o,C.x,C.y),this.links.add(e,o,i.getId(),"node",C)}}refreshTextLinks(){let e=!1;this.links.forEach(({connectionPoint:o,targetType:i,target:l,arrow:c,side:f})=>{if(i!=="text")return;e=!0;const g=this.getAnnotation(l),d=this.getAnnotation(c),v=gt(g),y=pt(g),_=xe(o,{x:v.width,y:v.height}),C=st(_,this.ogma.view.getAngle()),E=Lt(C,y);Rt(d,f,E.x,E.y)}),e&&this.arrows.refreshLayer()}getSelected(){return this.selected}findMagnetPoint(e,o,i){let l;for(const c of e){const f=gt(o),g=pt(o),d=xe(c,{x:f.width,y:f.height}),v=st(d,this.ogma.view.getAngle()),y=Lt(v,g),_=It(Et(y,i)),C=Math.min(this.options.magnetRadius*this.ogma.view.getZoom(),f.width/2,f.height/2);if(_<Math.max(C,this.options.magnetHandleRadius)){l={point:y,magnet:c};break}}return l}setOptions(e={}){return this.options={...this.options||{},...e},this.options}select(e){const o=this.getAnnotations().features.find(i=>i.id===e);return o?(at(o)?this.arrows.select(o.id):yt(o)&&this.texts.select(o.id),this):this}unselect(){return this.selected?(at(this.selected)?this.arrows.unselect():yt(this.selected)&&this.texts.unselect(),this):this}add(e){if(Nr(e)){const[o,i]=e.features.reduce((l,c)=>(at(c)?l[1].push(c):yt(c)&&l[0].push(c),l),[[],[]]);return o.forEach(l=>this.add(l)),i.forEach(l=>this.add(l)),this.arrows.refreshLayer(),this}switch(e.properties.type){case"text":this.texts.add(e);break;default:this.arrows.add(e),this.loadLink(e);break}return this}remove(e){return Nr(e)?(e.features.forEach(o=>this.remove(o)),this):(at(e)?(this.links.remove(e,"start"),this.links.remove(e,"end"),this.arrows.remove(e.id)):this.texts.remove(e.id),this)}loadLink(e){if(e.properties.link)for(const o of Br){const i=e.properties.link[o];if(!i)continue;const l=this.getAnnotation(i.id);if(i.type==="text"&&l)this.links.add(e,o,i.id,i.type,i.magnet);else if(i.type==="node"){const c=this.ogma.getNode(i.id);if(!c)continue;this.links.add(e,o,i.id,i.type,i.magnet);const f=c.getPosition(),g=c.getAttribute("radius")||0,d=ve(e,o==="start"?"end":"start"),v=we(d,f,+g);Rt(e,o,v.x,v.y)}}}startArrow(e,o,i){this.cancelDrawing(),this.arrows.startDrawing(e,o,i)}startText(e,o,i){this.cancelDrawing(),this.texts.startDrawing(e,o,i)}cancelDrawing(){this.annotations.forEach(e=>e.cancelDrawing()),this.emit(hn)}updateStyle(e,o){const i=this.getAnnotations().features.find(l=>l.id===e);return i?(at(i)?this.arrows.updateStyle(i,o):yt(i)&&this.texts.updateStyle(i,o),this.onUpdate(i),this):this}setScale(e,o,i,l){const c=this.getAnnotations().features.find(f=>f.id===e);return c?(at(c)?this.arrows.scale(c,o,i,l):yt(c)&&this.texts.scale(c,o,i,l),this.onUpdate(c),this):this}getAnnotations(){const e={type:"FeatureCollection",features:[]};return this.annotations.forEach(o=>{e.features=[...e.features,...o.getElements()]}),e}getAnnotation(e){return this.getAnnotations().features.find(o=>o.id===e)}destroy(){this.annotations.forEach(e=>e.destroy()),this.layer.destroy()}}const Ze=[8,10,12,14,16,24,32,48,64,72],Ke="none",Qe="#333333",An=["#FFFFFF","#F44E3B","#FE9200","#FCDC00","#A4DD00","#68CCCA","#73D8FF","#AEA1FF","#1E88E5","#333333","#808080","#cccccc"],En=["Roboto","Helvetica Neue","Helvetica","Arial","sans-serif","Georgia, serif","Menlo","Monaco","Consolas","Courier New","monospace"].sort((u,e)=>u.toLocaleLowerCase().localeCompare(e.toLocaleLowerCase())),Ur={head:"arrow",strokeColor:Qe,strokeWidth:5},Wr=.25,Vr={font:"Roboto",fontSize:Ze[2],padding:Ze[2]*Wr,color:Qe,strokeType:Ke,background:Ke};function Yr(u){return u.reduce((e,o)=>e+o,0)/u.length}function _n(u,e=0,o=1){return e+(o-e)*u}function kn(u,e=0,o=1){return(u-e)/(o-e)}function Sn(){return X.createContext(null)}const tr=X.createContext(void 0),Tn=()=>X.useContext(tr),Cn=(u,e)=>{switch(e.type){case"add":return{...u,features:[...u.features,e.payload]};case"remove":return{...u,features:u.features.filter(o=>o.id!==e.payload.id)};case"update":return{...u,features:u.features.map(o=>o.id===e.payload.id?e.payload:o)};default:return u}},On=({children:u})=>{const e=Gr.useOgma(),[o,i]=X.useReducer(Cn,{type:"FeatureCollection",features:[]}),[l,c]=X.useState(null),[f,g]=X.useState(Ur),[d,v]=X.useState(Vr),[y,_]=X.useState(),[C,E]=X.useState(1),[P,T]=X.useState(1);return X.useEffect(()=>{if(!e)return;const j=new xn(e,{minArrowHeight:1}),L=Yr(e.getNodes().getAttribute("radius"))/5,S=C;return g({...f,strokeWidth:(f.strokeWidth||1)*S}),E(S),T(L),j.on("select",H=>{at(H)?g({...H.properties.style||{}}):yt(H)&&v({...H.properties.style||{}}),c(H)}).on("unselect",()=>{c(null)}),_(j),()=>{y==null||y.destroy()}},[e]),X.useEffect(()=>{y&&l&&(l==null?void 0:l.properties.type)==="arrow"&&y.updateStyle(l.id,f)},[y,f,l]),X.useEffect(()=>{y&&l&&(l==null?void 0:l.properties.type)==="text"&&y.updateStyle(l.id,d)},[y,d,l]),Jr.jsx(tr.Provider,{value:{annotations:o,updateAnnotations:i,currentAnnotation:l,setCurrentAnnotation:c,textStyle:d,setTextStyle:v,arrowStyle:f,setArrowStyle:g,arrowWidthFactor:C,setArrowWidthFactor:E,textSizeFactor:P,setTextSizeFactor:T,editor:y,setEditor:_},children:u})};B.AnnotationsContext=tr,B.AnnotationsContextProvider=On,B.BLACK=Qe,B.RELATIVE_PADDING=Wr,B.TRANSPARENT=Ke,B.createAnnotationsContext=Sn,B.defaultArrowStyle=Ur,B.defaultColors=An,B.defaultTextStyle=Vr,B.fontSizes=Ze,B.fonts=En,B.interpolate=_n,B.mean=Yr,B.normalize=kn,B.useAnnotationsContext=Tn,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"})});