@linkurious/ogma-annotations-react 1.1.10 → 1.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs ADDED
@@ -0,0 +1,3223 @@
1
+ import Er, { createContext as _r, useContext as zr, useReducer as Nr, useState as zt, useEffect as Je } from "react";
2
+ import { useOgma as Hr } from "@linkurious/ogma-react";
3
+ var er = { exports: {} }, ae = {};
4
+ /**
5
+ * @license React
6
+ * react-jsx-runtime.production.min.js
7
+ *
8
+ * Copyright (c) Facebook, Inc. and its affiliates.
9
+ *
10
+ * This source code is licensed under the MIT license found in the
11
+ * LICENSE file in the root directory of this source tree.
12
+ */
13
+ var hr;
14
+ function Br() {
15
+ if (hr)
16
+ return ae;
17
+ hr = 1;
18
+ var p = Er, e = Symbol.for("react.element"), a = Symbol.for("react.fragment"), i = Object.prototype.hasOwnProperty, h = p.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, c = { key: !0, ref: !0, __self: !0, __source: !0 };
19
+ function g(m, f, s) {
20
+ var d, A = {}, _ = null, R = null;
21
+ s !== void 0 && (_ = "" + s), f.key !== void 0 && (_ = "" + f.key), f.ref !== void 0 && (R = f.ref);
22
+ for (d in f)
23
+ i.call(f, d) && !c.hasOwnProperty(d) && (A[d] = f[d]);
24
+ if (m && m.defaultProps)
25
+ for (d in f = m.defaultProps, f)
26
+ A[d] === void 0 && (A[d] = f[d]);
27
+ return { $$typeof: e, type: m, key: _, ref: R, props: A, _owner: h.current };
28
+ }
29
+ return ae.Fragment = a, ae.jsx = g, ae.jsxs = g, ae;
30
+ }
31
+ var le = {};
32
+ /**
33
+ * @license React
34
+ * react-jsx-runtime.development.js
35
+ *
36
+ * Copyright (c) Facebook, Inc. and its affiliates.
37
+ *
38
+ * This source code is licensed under the MIT license found in the
39
+ * LICENSE file in the root directory of this source tree.
40
+ */
41
+ var ur;
42
+ function Ur() {
43
+ return ur || (ur = 1, process.env.NODE_ENV !== "production" && function() {
44
+ var p = Er, e = Symbol.for("react.element"), a = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), h = Symbol.for("react.strict_mode"), c = Symbol.for("react.profiler"), g = Symbol.for("react.provider"), m = Symbol.for("react.context"), f = Symbol.for("react.forward_ref"), s = Symbol.for("react.suspense"), d = Symbol.for("react.suspense_list"), A = Symbol.for("react.memo"), _ = Symbol.for("react.lazy"), R = Symbol.for("react.offscreen"), P = Symbol.iterator, E = "@@iterator";
45
+ function M(t) {
46
+ if (t === null || typeof t != "object")
47
+ return null;
48
+ var o = P && t[P] || t[E];
49
+ return typeof o == "function" ? o : null;
50
+ }
51
+ var j = p.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
52
+ function k(t) {
53
+ {
54
+ for (var o = arguments.length, u = new Array(o > 1 ? o - 1 : 0), y = 1; y < o; y++)
55
+ u[y - 1] = arguments[y];
56
+ N("error", t, u);
57
+ }
58
+ }
59
+ function N(t, o, u) {
60
+ {
61
+ var y = j.ReactDebugCurrentFrame, v = y.getStackAddendum();
62
+ v !== "" && (o += "%s", u = u.concat([v]));
63
+ var w = u.map(function(b) {
64
+ return String(b);
65
+ });
66
+ w.unshift("Warning: " + o), Function.prototype.apply.call(console[t], console, w);
67
+ }
68
+ }
69
+ var H = !1, st = !1, xt = !1, Ut = !1, Wt = !1, fe;
70
+ fe = Symbol.for("react.module.reference");
71
+ function Rt(t) {
72
+ return !!(typeof t == "string" || typeof t == "function" || t === i || t === c || Wt || t === h || t === s || t === d || Ut || t === R || H || st || xt || typeof t == "object" && t !== null && (t.$$typeof === _ || t.$$typeof === A || t.$$typeof === g || t.$$typeof === m || t.$$typeof === f || // This needs to include all possible module reference object
73
+ // types supported by any Flight configuration anywhere since
74
+ // we don't know which Flight build this will end up being used
75
+ // with.
76
+ t.$$typeof === fe || t.getModuleId !== void 0));
77
+ }
78
+ function Ct(t, o, u) {
79
+ var y = t.displayName;
80
+ if (y)
81
+ return y;
82
+ var v = o.displayName || o.name || "";
83
+ return v !== "" ? u + "(" + v + ")" : u;
84
+ }
85
+ function Yt(t) {
86
+ return t.displayName || "Context";
87
+ }
88
+ function et(t) {
89
+ if (t == null)
90
+ return null;
91
+ if (typeof t.tag == "number" && k("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof t == "function")
92
+ return t.displayName || t.name || null;
93
+ if (typeof t == "string")
94
+ return t;
95
+ switch (t) {
96
+ case i:
97
+ return "Fragment";
98
+ case a:
99
+ return "Portal";
100
+ case c:
101
+ return "Profiler";
102
+ case h:
103
+ return "StrictMode";
104
+ case s:
105
+ return "Suspense";
106
+ case d:
107
+ return "SuspenseList";
108
+ }
109
+ if (typeof t == "object")
110
+ switch (t.$$typeof) {
111
+ case m:
112
+ var o = t;
113
+ return Yt(o) + ".Consumer";
114
+ case g:
115
+ var u = t;
116
+ return Yt(u._context) + ".Provider";
117
+ case f:
118
+ return Ct(t, t.render, "ForwardRef");
119
+ case A:
120
+ var y = t.displayName || null;
121
+ return y !== null ? y : et(t.type) || "Memo";
122
+ case _: {
123
+ var v = t, w = v._payload, b = v._init;
124
+ try {
125
+ return et(b(w));
126
+ } catch {
127
+ return null;
128
+ }
129
+ }
130
+ }
131
+ return null;
132
+ }
133
+ var F = Object.assign, at = 0, Z, ht, Pt, de, Vt, pe, ge;
134
+ function St() {
135
+ }
136
+ St.__reactDisabledLog = !0;
137
+ function ye() {
138
+ {
139
+ if (at === 0) {
140
+ Z = console.log, ht = console.info, Pt = console.warn, de = console.error, Vt = console.group, pe = console.groupCollapsed, ge = console.groupEnd;
141
+ var t = {
142
+ configurable: !0,
143
+ enumerable: !0,
144
+ value: St,
145
+ writable: !0
146
+ };
147
+ Object.defineProperties(console, {
148
+ info: t,
149
+ log: t,
150
+ warn: t,
151
+ error: t,
152
+ group: t,
153
+ groupCollapsed: t,
154
+ groupEnd: t
155
+ });
156
+ }
157
+ at++;
158
+ }
159
+ }
160
+ function De() {
161
+ {
162
+ if (at--, at === 0) {
163
+ var t = {
164
+ configurable: !0,
165
+ enumerable: !0,
166
+ writable: !0
167
+ };
168
+ Object.defineProperties(console, {
169
+ log: F({}, t, {
170
+ value: Z
171
+ }),
172
+ info: F({}, t, {
173
+ value: ht
174
+ }),
175
+ warn: F({}, t, {
176
+ value: Pt
177
+ }),
178
+ error: F({}, t, {
179
+ value: de
180
+ }),
181
+ group: F({}, t, {
182
+ value: Vt
183
+ }),
184
+ groupCollapsed: F({}, t, {
185
+ value: pe
186
+ }),
187
+ groupEnd: F({}, t, {
188
+ value: ge
189
+ })
190
+ });
191
+ }
192
+ at < 0 && k("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
193
+ }
194
+ }
195
+ var qt = j.ReactCurrentDispatcher, Xt;
196
+ function It(t, o, u) {
197
+ {
198
+ if (Xt === void 0)
199
+ try {
200
+ throw Error();
201
+ } catch (v) {
202
+ var y = v.stack.trim().match(/\n( *(at )?)/);
203
+ Xt = y && y[1] || "";
204
+ }
205
+ return `
206
+ ` + Xt + t;
207
+ }
208
+ }
209
+ var Zt = !1, At;
210
+ {
211
+ var Fe = typeof WeakMap == "function" ? WeakMap : Map;
212
+ At = new Fe();
213
+ }
214
+ function Gt(t, o) {
215
+ if (!t || Zt)
216
+ return "";
217
+ {
218
+ var u = At.get(t);
219
+ if (u !== void 0)
220
+ return u;
221
+ }
222
+ var y;
223
+ Zt = !0;
224
+ var v = Error.prepareStackTrace;
225
+ Error.prepareStackTrace = void 0;
226
+ var w;
227
+ w = qt.current, qt.current = null, ye();
228
+ try {
229
+ if (o) {
230
+ var b = function() {
231
+ throw Error();
232
+ };
233
+ if (Object.defineProperty(b.prototype, "props", {
234
+ set: function() {
235
+ throw Error();
236
+ }
237
+ }), typeof Reflect == "object" && Reflect.construct) {
238
+ try {
239
+ Reflect.construct(b, []);
240
+ } catch (O) {
241
+ y = O;
242
+ }
243
+ Reflect.construct(t, [], b);
244
+ } else {
245
+ try {
246
+ b.call();
247
+ } catch (O) {
248
+ y = O;
249
+ }
250
+ t.call(b.prototype);
251
+ }
252
+ } else {
253
+ try {
254
+ throw Error();
255
+ } catch (O) {
256
+ y = O;
257
+ }
258
+ t();
259
+ }
260
+ } catch (O) {
261
+ if (O && y && typeof O.stack == "string") {
262
+ for (var S = O.stack.split(`
263
+ `), I = y.stack.split(`
264
+ `), T = S.length - 1, C = I.length - 1; T >= 1 && C >= 0 && S[T] !== I[C]; )
265
+ C--;
266
+ for (; T >= 1 && C >= 0; T--, C--)
267
+ if (S[T] !== I[C]) {
268
+ if (T !== 1 || C !== 1)
269
+ do
270
+ if (T--, C--, C < 0 || S[T] !== I[C]) {
271
+ var D = `
272
+ ` + S[T].replace(" at new ", " at ");
273
+ return t.displayName && D.includes("<anonymous>") && (D = D.replace("<anonymous>", t.displayName)), typeof t == "function" && At.set(t, D), D;
274
+ }
275
+ while (T >= 1 && C >= 0);
276
+ break;
277
+ }
278
+ }
279
+ } finally {
280
+ Zt = !1, qt.current = w, De(), Error.prepareStackTrace = v;
281
+ }
282
+ var U = t ? t.displayName || t.name : "", L = U ? It(U) : "";
283
+ return typeof t == "function" && At.set(t, L), L;
284
+ }
285
+ function Le(t, o, u) {
286
+ return Gt(t, !1);
287
+ }
288
+ function ze(t) {
289
+ var o = t.prototype;
290
+ return !!(o && o.isReactComponent);
291
+ }
292
+ function Ot(t, o, u) {
293
+ if (t == null)
294
+ return "";
295
+ if (typeof t == "function")
296
+ return Gt(t, ze(t));
297
+ if (typeof t == "string")
298
+ return It(t);
299
+ switch (t) {
300
+ case s:
301
+ return It("Suspense");
302
+ case d:
303
+ return It("SuspenseList");
304
+ }
305
+ if (typeof t == "object")
306
+ switch (t.$$typeof) {
307
+ case f:
308
+ return Le(t.render);
309
+ case A:
310
+ return Ot(t.type, o, u);
311
+ case _: {
312
+ var y = t, v = y._payload, w = y._init;
313
+ try {
314
+ return Ot(w(v), o, u);
315
+ } catch {
316
+ }
317
+ }
318
+ }
319
+ return "";
320
+ }
321
+ var Et = Object.prototype.hasOwnProperty, me = {}, ve = j.ReactDebugCurrentFrame;
322
+ function jt(t) {
323
+ if (t) {
324
+ var o = t._owner, u = Ot(t.type, t._source, o ? o.type : null);
325
+ ve.setExtraStackFrame(u);
326
+ } else
327
+ ve.setExtraStackFrame(null);
328
+ }
329
+ function Ne(t, o, u, y, v) {
330
+ {
331
+ var w = Function.call.bind(Et);
332
+ for (var b in t)
333
+ if (w(t, b)) {
334
+ var S = void 0;
335
+ try {
336
+ if (typeof t[b] != "function") {
337
+ var I = Error((y || "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`.");
338
+ throw I.name = "Invariant Violation", I;
339
+ }
340
+ S = t[b](o, b, y, u, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
341
+ } catch (T) {
342
+ S = T;
343
+ }
344
+ S && !(S instanceof Error) && (jt(v), k("%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).", y || "React class", u, b, typeof S), jt(null)), S instanceof Error && !(S.message in me) && (me[S.message] = !0, jt(v), k("Failed %s type: %s", u, S.message), jt(null));
345
+ }
346
+ }
347
+ }
348
+ var He = Array.isArray;
349
+ function Jt(t) {
350
+ return He(t);
351
+ }
352
+ function B(t) {
353
+ {
354
+ var o = typeof Symbol == "function" && Symbol.toStringTag, u = o && t[Symbol.toStringTag] || t.constructor.name || "Object";
355
+ return u;
356
+ }
357
+ }
358
+ function Be(t) {
359
+ try {
360
+ return be(t), !1;
361
+ } catch {
362
+ return !0;
363
+ }
364
+ }
365
+ function be(t) {
366
+ return "" + t;
367
+ }
368
+ function Kt(t) {
369
+ if (Be(t))
370
+ return k("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", B(t)), be(t);
371
+ }
372
+ var ot = j.ReactCurrentOwner, we = {
373
+ key: !0,
374
+ ref: !0,
375
+ __self: !0,
376
+ __source: !0
377
+ }, $t, xe, Qt;
378
+ Qt = {};
379
+ function te(t) {
380
+ if (Et.call(t, "ref")) {
381
+ var o = Object.getOwnPropertyDescriptor(t, "ref").get;
382
+ if (o && o.isReactWarning)
383
+ return !1;
384
+ }
385
+ return t.ref !== void 0;
386
+ }
387
+ function Ue(t) {
388
+ if (Et.call(t, "key")) {
389
+ var o = Object.getOwnPropertyDescriptor(t, "key").get;
390
+ if (o && o.isReactWarning)
391
+ return !1;
392
+ }
393
+ return t.key !== void 0;
394
+ }
395
+ function We(t, o) {
396
+ if (typeof t.ref == "string" && ot.current && o && ot.current.stateNode !== o) {
397
+ var u = et(ot.current.type);
398
+ Qt[u] || (k('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', et(ot.current.type), t.ref), Qt[u] = !0);
399
+ }
400
+ }
401
+ function Ye(t, o) {
402
+ {
403
+ var u = function() {
404
+ $t || ($t = !0, k("%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));
405
+ };
406
+ u.isReactWarning = !0, Object.defineProperty(t, "key", {
407
+ get: u,
408
+ configurable: !0
409
+ });
410
+ }
411
+ }
412
+ function ee(t, o) {
413
+ {
414
+ var u = function() {
415
+ xe || (xe = !0, k("%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));
416
+ };
417
+ u.isReactWarning = !0, Object.defineProperty(t, "ref", {
418
+ get: u,
419
+ configurable: !0
420
+ });
421
+ }
422
+ }
423
+ var Se = function(t, o, u, y, v, w, b) {
424
+ var S = {
425
+ // This tag allows us to uniquely identify this as a React Element
426
+ $$typeof: e,
427
+ // Built-in properties that belong on the element
428
+ type: t,
429
+ key: o,
430
+ ref: u,
431
+ props: b,
432
+ // Record the component responsible for creating this element.
433
+ _owner: w
434
+ };
435
+ return S._store = {}, Object.defineProperty(S._store, "validated", {
436
+ configurable: !1,
437
+ enumerable: !1,
438
+ writable: !0,
439
+ value: !1
440
+ }), Object.defineProperty(S, "_self", {
441
+ configurable: !1,
442
+ enumerable: !1,
443
+ writable: !1,
444
+ value: y
445
+ }), Object.defineProperty(S, "_source", {
446
+ configurable: !1,
447
+ enumerable: !1,
448
+ writable: !1,
449
+ value: v
450
+ }), Object.freeze && (Object.freeze(S.props), Object.freeze(S)), S;
451
+ };
452
+ function _t(t, o, u, y, v) {
453
+ {
454
+ var w, b = {}, S = null, I = null;
455
+ u !== void 0 && (Kt(u), S = "" + u), Ue(o) && (Kt(o.key), S = "" + o.key), te(o) && (I = o.ref, We(o, v));
456
+ for (w in o)
457
+ Et.call(o, w) && !we.hasOwnProperty(w) && (b[w] = o[w]);
458
+ if (t && t.defaultProps) {
459
+ var T = t.defaultProps;
460
+ for (w in T)
461
+ b[w] === void 0 && (b[w] = T[w]);
462
+ }
463
+ if (S || I) {
464
+ var C = typeof t == "function" ? t.displayName || t.name || "Unknown" : t;
465
+ S && Ye(b, C), I && ee(b, C);
466
+ }
467
+ return Se(t, S, I, v, y, ot.current, b);
468
+ }
469
+ }
470
+ var re = j.ReactCurrentOwner, Ae = j.ReactDebugCurrentFrame;
471
+ function ut(t) {
472
+ if (t) {
473
+ var o = t._owner, u = Ot(t.type, t._source, o ? o.type : null);
474
+ Ae.setExtraStackFrame(u);
475
+ } else
476
+ Ae.setExtraStackFrame(null);
477
+ }
478
+ var G;
479
+ G = !1;
480
+ function ft(t) {
481
+ return typeof t == "object" && t !== null && t.$$typeof === e;
482
+ }
483
+ function Mt() {
484
+ {
485
+ if (re.current) {
486
+ var t = et(re.current.type);
487
+ if (t)
488
+ return `
489
+
490
+ Check the render method of \`` + t + "`.";
491
+ }
492
+ return "";
493
+ }
494
+ }
495
+ function Ve(t) {
496
+ {
497
+ if (t !== void 0) {
498
+ var o = t.fileName.replace(/^.*[\\\/]/, ""), u = t.lineNumber;
499
+ return `
500
+
501
+ Check your code at ` + o + ":" + u + ".";
502
+ }
503
+ return "";
504
+ }
505
+ }
506
+ var ne = {};
507
+ function Ee(t) {
508
+ {
509
+ var o = Mt();
510
+ if (!o) {
511
+ var u = typeof t == "string" ? t : t.displayName || t.name;
512
+ u && (o = `
513
+
514
+ Check the top-level render call using <` + u + ">.");
515
+ }
516
+ return o;
517
+ }
518
+ }
519
+ function _e(t, o) {
520
+ {
521
+ if (!t._store || t._store.validated || t.key != null)
522
+ return;
523
+ t._store.validated = !0;
524
+ var u = Ee(o);
525
+ if (ne[u])
526
+ return;
527
+ ne[u] = !0;
528
+ var y = "";
529
+ t && t._owner && t._owner !== re.current && (y = " It was passed a child from " + et(t._owner.type) + "."), ut(t), k('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', u, y), ut(null);
530
+ }
531
+ }
532
+ function Dt(t, o) {
533
+ {
534
+ if (typeof t != "object")
535
+ return;
536
+ if (Jt(t))
537
+ for (var u = 0; u < t.length; u++) {
538
+ var y = t[u];
539
+ ft(y) && _e(y, o);
540
+ }
541
+ else if (ft(t))
542
+ t._store && (t._store.validated = !0);
543
+ else if (t) {
544
+ var v = M(t);
545
+ if (typeof v == "function" && v !== t.entries)
546
+ for (var w = v.call(t), b; !(b = w.next()).done; )
547
+ ft(b.value) && _e(b.value, o);
548
+ }
549
+ }
550
+ }
551
+ function qe(t) {
552
+ {
553
+ var o = t.type;
554
+ if (o == null || typeof o == "string")
555
+ return;
556
+ var u;
557
+ if (typeof o == "function")
558
+ u = o.propTypes;
559
+ else if (typeof o == "object" && (o.$$typeof === f || // Note: Memo only checks outer props here.
560
+ // Inner props are checked in the reconciler.
561
+ o.$$typeof === A))
562
+ u = o.propTypes;
563
+ else
564
+ return;
565
+ if (u) {
566
+ var y = et(o);
567
+ Ne(u, t.props, "prop", y, t);
568
+ } else if (o.PropTypes !== void 0 && !G) {
569
+ G = !0;
570
+ var v = et(o);
571
+ k("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", v || "Unknown");
572
+ }
573
+ typeof o.getDefaultProps == "function" && !o.getDefaultProps.isReactClassApproved && k("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
574
+ }
575
+ }
576
+ function ke(t) {
577
+ {
578
+ for (var o = Object.keys(t.props), u = 0; u < o.length; u++) {
579
+ var y = o[u];
580
+ if (y !== "children" && y !== "key") {
581
+ ut(t), k("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", y), ut(null);
582
+ break;
583
+ }
584
+ }
585
+ t.ref !== null && (ut(t), k("Invalid attribute `ref` supplied to `React.Fragment`."), ut(null));
586
+ }
587
+ }
588
+ function ie(t, o, u, y, v, w) {
589
+ {
590
+ var b = Rt(t);
591
+ if (!b) {
592
+ var S = "";
593
+ (t === void 0 || typeof t == "object" && t !== null && Object.keys(t).length === 0) && (S += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
594
+ var I = Ve(v);
595
+ I ? S += I : S += Mt();
596
+ var T;
597
+ t === null ? T = "null" : Jt(t) ? T = "array" : t !== void 0 && t.$$typeof === e ? (T = "<" + (et(t.type) || "Unknown") + " />", S = " Did you accidentally export a JSX literal instead of a component?") : T = typeof t, k("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", T, S);
598
+ }
599
+ var C = _t(t, o, u, v, w);
600
+ if (C == null)
601
+ return C;
602
+ if (b) {
603
+ var D = o.children;
604
+ if (D !== void 0)
605
+ if (y)
606
+ if (Jt(D)) {
607
+ for (var U = 0; U < D.length; U++)
608
+ Dt(D[U], t);
609
+ Object.freeze && Object.freeze(D);
610
+ } else
611
+ k("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
612
+ else
613
+ Dt(D, t);
614
+ }
615
+ return t === i ? ke(C) : qe(C), C;
616
+ }
617
+ }
618
+ function Xe(t, o, u) {
619
+ return ie(t, o, u, !0);
620
+ }
621
+ function r(t, o, u) {
622
+ return ie(t, o, u, !1);
623
+ }
624
+ var n = r, l = Xe;
625
+ le.Fragment = i, le.jsx = n, le.jsxs = l;
626
+ }()), le;
627
+ }
628
+ process.env.NODE_ENV === "production" ? er.exports = Br() : er.exports = Ur();
629
+ var Wr = er.exports, Yr = Object.defineProperty, Vr = (p, e, a) => e in p ? Yr(p, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : p[e] = a, x = (p, e, a) => (Vr(p, typeof e != "symbol" ? e + "" : e, a), a), qr = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
630
+ function lr(p) {
631
+ return p && p.__esModule && Object.prototype.hasOwnProperty.call(p, "default") ? p.default : p;
632
+ }
633
+ var kr = { exports: {} };
634
+ (function(p) {
635
+ (function(e, a) {
636
+ p.exports = a();
637
+ })("Vector", function() {
638
+ var e = function() {
639
+ var a = Math.PI * 2, i = 180 / Math.PI, h = Math.PI / 180;
640
+ function c(s) {
641
+ return Math.round(s * 1e8) / 1e8;
642
+ }
643
+ function g(s, d) {
644
+ var A = d.x - s.x, _ = d.y - s.y;
645
+ return Math.sqrt(A * A + _ * _);
646
+ }
647
+ function m(s, d, A) {
648
+ var _ = d.y - s.y, R = d.x - s.x, P = Math.atan2(_, R);
649
+ if (A)
650
+ for (; P < 0; )
651
+ P += a;
652
+ return P;
653
+ }
654
+ function f(s, d) {
655
+ this.x = s !== void 0 ? s : 0, this.y = d !== void 0 ? d : 0;
656
+ }
657
+ return f.fromRadians = function(s) {
658
+ var d = Math.cos(s), A = Math.sin(s);
659
+ return new f(d, A);
660
+ }, f.fromDegrees = function(s) {
661
+ var d = s * (Math.PI / 180);
662
+ return f.fromRadians(d);
663
+ }, f.fromString = function(s) {
664
+ var d = s.split(",");
665
+ return new f(parseFloat(d[0]), parseFloat(d[1]));
666
+ }, f.fromArray = function(s) {
667
+ return new f(s[0], s[1]);
668
+ }, f.prototype = {
669
+ // version
670
+ version: "2.0.1",
671
+ // [API]
672
+ // [chainable, clone]
673
+ // clone the vector and return the cloned instance.
674
+ // @return cloned vector.
675
+ clone: function() {
676
+ return new f(this.x, this.y);
677
+ },
678
+ // [API]
679
+ // []
680
+ // Get if equal to another vector
681
+ // @param vector - other vector to compare with.
682
+ // @return if vectors are equal.
683
+ equals: function(s) {
684
+ return this.prototype === s.prototype && this.x === s.x && this.y === s.y;
685
+ },
686
+ // [API]
687
+ // [chainable, changeSelf]
688
+ // set values from another vector. this changes value of self.
689
+ // @param vector - other vector to get values from.
690
+ // @return self.
691
+ copy: function(s) {
692
+ return this.x = s.x, this.y = s.y, this;
693
+ },
694
+ // [API]
695
+ // [chainable, changeSelf]
696
+ // set only the x component from another vector.
697
+ // @return self.
698
+ copyX: function(s) {
699
+ return this.x = s.x, this;
700
+ },
701
+ // [API]
702
+ // [chainable, changeSelf]
703
+ // set only the y component from another vector.
704
+ // @return self.
705
+ copyY: function(s) {
706
+ return this.y = s.y, this;
707
+ },
708
+ // [API]
709
+ // []
710
+ // convert to a dictionary with {x, y}.
711
+ // @return a dictionary representation of the vector.
712
+ toDict: function() {
713
+ return { x: this.x, y: this.y };
714
+ },
715
+ // [API]
716
+ // []
717
+ // convert to array with [x, y].
718
+ // @return an array representation of the vector.
719
+ toArray: function() {
720
+ return [this.x, this.y];
721
+ },
722
+ // [API]
723
+ // [chainable, changeSelf]
724
+ // set values from x, y.
725
+ // @param x - optional x component to set.
726
+ // @param y - optional y component to set.
727
+ // @return self.
728
+ set: function(s, d) {
729
+ return s !== void 0 && (this.x = s), d !== void 0 && (this.y = d), this;
730
+ },
731
+ // [API]
732
+ // [chainable, clone]
733
+ // clone and flip between x and y values.
734
+ // @return cloned vector with flipped x and y components.
735
+ flipXY: function() {
736
+ return new f(this.y, this.x);
737
+ },
738
+ // [API]
739
+ // [chainable, changeSelf]
740
+ // flip between x and y values.
741
+ // @return self.
742
+ flipXYSelf: function() {
743
+ return this.y = [this.x, this.x = this.y][0], this;
744
+ },
745
+ // [API]
746
+ // [chainable, clone]
747
+ // clone and invert x and y values (like multiply with -1, eg x, y => -x, -y)
748
+ // @return cloned vector with inverted values.
749
+ invert: function() {
750
+ return this.mulScalar(-1);
751
+ },
752
+ // [API]
753
+ // [chainable, changeSelf]
754
+ // invert x and y values (like multiply with -1, eg x, y => -x, -y)
755
+ // @return self.
756
+ invertSelf: function() {
757
+ return this.mulScalarSelf(-1), this;
758
+ },
759
+ // [API]
760
+ // []
761
+ // get the distance from another vector.
762
+ // @param other - vector to get distance from.
763
+ // @return distance between vectors.
764
+ distanceFrom: function(s) {
765
+ return g(this, s);
766
+ },
767
+ // [API]
768
+ // []
769
+ // get angle from another vector in radians.
770
+ // @return angle in radians from this to other.
771
+ radiansTo: function(s) {
772
+ return m(this, s, !0);
773
+ },
774
+ // [API]
775
+ // []
776
+ // get degrees from another vector in degrees.
777
+ // @return angle in degrees from this to other.
778
+ degreesTo: function(s) {
779
+ return m(this, s, !0) * i;
780
+ },
781
+ // [API]
782
+ // []
783
+ // convert this vector to a radian angle.
784
+ // this is equivalent to doing Vector.zero.radiansTo(this).
785
+ // @return angle in radians.
786
+ toRadians: function(s) {
787
+ return m(f.zero, this, !0);
788
+ },
789
+ // [API]
790
+ // []
791
+ // convert this vector to degree.
792
+ // this is equivalent to doing Vector.zero.degreeTo(this).
793
+ // @return angle in degrees (0-360).
794
+ toDegrees: function(s) {
795
+ return this.toRadians() * i;
796
+ },
797
+ // [API]
798
+ // [chainable, changeSelf]
799
+ // rotate this vector by a given degree.
800
+ // @param degrees - degrees to rotate this vector by (can be positive or negative).
801
+ // @return self.
802
+ rotateDegreesSelf: function(s) {
803
+ return this.rotateRadiansSelf(s * h);
804
+ },
805
+ // [API]
806
+ // [chainable]
807
+ // clone and rotate the vector by a given degree.
808
+ // @param degrees - degree to rotate this vector by (can be positive or negative).
809
+ // @return cloned rotated vector.
810
+ rotateDegrees: function(s) {
811
+ return this.clone().rotateDegreesSelf(s);
812
+ },
813
+ // [API]
814
+ // [chainable, changeSelf]
815
+ // rotate this vector by a given radian.
816
+ // @param radians - radians to rotate this vector by (can be positive or negative).
817
+ // @return self.
818
+ rotateRadiansSelf: function(s) {
819
+ var d = Math.cos(s), A = Math.sin(s), _ = this.x * d - this.y * A, R = this.x * A + this.y * d;
820
+ return this.x = c(_), this.y = c(R), this;
821
+ },
822
+ // [API]
823
+ // [chainable]
824
+ // clone and rotate the vector by a given degree.
825
+ // @param radians - radians to rotate this vector by (can be positive or negative).
826
+ // @return cloned rotated vector.
827
+ rotateRadians: function(s) {
828
+ return this.clone().rotateRadiansSelf(s);
829
+ },
830
+ // [API]
831
+ // []
832
+ // calculate the length of this vector (aka magnitude).
833
+ // @return vector length.
834
+ length: function() {
835
+ return Math.sqrt(this.x * this.x + this.y * this.y);
836
+ },
837
+ // [API]
838
+ // [chainable, changeSelf]
839
+ // normalize this vector, eg make length equal 1.
840
+ // @return self.
841
+ normalizeSelf: function() {
842
+ var s = Math.sqrt(this.x * this.x + this.y * this.y);
843
+ return s === 0 ? this : (this.x /= s, this.y /= s, this);
844
+ },
845
+ // [API]
846
+ // [chainable, clone]
847
+ // clone and normalize the vector.
848
+ // @return normalized vector.
849
+ normalize: function() {
850
+ return this.clone().normalizeSelf();
851
+ },
852
+ // [API]
853
+ // [chainable, changeSelf]
854
+ // add other vector to self.
855
+ // for example, v(10, 11) + v(5, 6) = v(15, 17).
856
+ // @param other - vector to add components to self.
857
+ // @return self.
858
+ addSelf: function(s) {
859
+ return typeof s == "number" ? this.addScalarSelf(s) : (this.x += s.x, this.y += s.y, this);
860
+ },
861
+ // [API]
862
+ // [chainable, changeSelf]
863
+ // subtract other vector from self.
864
+ // for example, v(10, 10) - v(2, 3) = v(8, 7).
865
+ // @param other - vector to subtract components from self.
866
+ // @return self.
867
+ subSelf: function(s) {
868
+ return typeof s == "number" ? this.subScalarSelf(s) : (this.x -= s.x, this.y -= s.y, this);
869
+ },
870
+ // [API]
871
+ // [chainable, changeSelf]
872
+ // divide self by other vector.
873
+ // for example, v(10, 20) / v(2, 5) = v(5, 4).
874
+ // @param other - vector to divide components from self.
875
+ // @return self.
876
+ divSelf: function(s) {
877
+ return typeof s == "number" ? this.divScalarSelf(s) : (this.x /= s.x, this.y /= s.y, this);
878
+ },
879
+ // [API]
880
+ // [chainable, changeSelf]
881
+ // multiply self vector by other vector.
882
+ // for example, v(2, 3) * v(3, 4) = v(6, 12).
883
+ // @param other - vector to multiply components with self.
884
+ // @return self.
885
+ mulSelf: function(s) {
886
+ return typeof s == "number" ? this.mulScalarSelf(s) : (this.x *= s.x, this.y *= s.y, this);
887
+ },
888
+ // [API]
889
+ // [chainable, changeSelf]
890
+ // add scalar value to self.
891
+ // for example, v(2, 3) + 5 = v(7, 8).
892
+ // @param val - value to add to components.
893
+ // @return self.
894
+ addScalarSelf: function(s) {
895
+ return this.x += s, this.y += s, this;
896
+ },
897
+ // [API]
898
+ // [chainable, changeSelf]
899
+ // subtract scalar from self.
900
+ // for example, v(7, 9) - 5 = v(3, 4).
901
+ // @param val - value to subtract from components.
902
+ // @return self.
903
+ subScalarSelf: function(s) {
904
+ return this.x -= s, this.y -= s, this;
905
+ },
906
+ // [API]
907
+ // [chainable, changeSelf]
908
+ // divide self by scalar.
909
+ // for example, v(6, 8) / 5 = v(3, 4).
910
+ // @param val - value to divide components by.
911
+ // @return self.
912
+ divScalarSelf: function(s) {
913
+ return this.x /= s, this.y /= s, this;
914
+ },
915
+ // [API]
916
+ // [chainable, changeSelf]
917
+ // multiply self by scalar.
918
+ // for example, v(2, 3) * 2 = v(4, 6).
919
+ // @param val - value to multiply components with.
920
+ // @return self.
921
+ mulScalarSelf: function(s) {
922
+ return this.x *= s, this.y *= s, this;
923
+ },
924
+ // [API]
925
+ // [chainable, clone]
926
+ // clone self and add other vector to it.
927
+ // @param other - vector to add with.
928
+ // @return cloned vector.
929
+ add: function(s) {
930
+ return this.clone().addSelf(s);
931
+ },
932
+ // [API]
933
+ // [chainable, clone]
934
+ // clone self and subtract other vector from it.
935
+ // @param other - vector to subtract with.
936
+ // @return cloned vector.
937
+ sub: function(s) {
938
+ return this.clone().subSelf(s);
939
+ },
940
+ // [API]
941
+ // [chainable, clone]
942
+ // clone self and multiply by other vector.
943
+ // @param other - vector to multiply with.
944
+ // @return cloned vector.
945
+ mul: function(s) {
946
+ return this.clone().mulSelf(s);
947
+ },
948
+ // [API]
949
+ // [chainable, clone]
950
+ // clone self and divide by other vector.
951
+ // @param other - vector to divide with.
952
+ // @param scalar - value to divide by.
953
+ // @return cloned vector.
954
+ div: function(s) {
955
+ return this.clone().divSelf(s);
956
+ },
957
+ // [API]
958
+ // [chainable, clone]
959
+ // clone self and add scalar to it.
960
+ // @param scalar - value to add.
961
+ // @return cloned vector.
962
+ addScalar: function(s) {
963
+ return this.clone().addScalarSelf(s);
964
+ },
965
+ // [API]
966
+ // [chainable, clone]
967
+ // clone self and substract scalar from it.
968
+ // @param scalar - value to subtract.
969
+ // @return cloned vector.
970
+ subScalar: function(s) {
971
+ return this.clone().subScalarSelf(s);
972
+ },
973
+ // [API]
974
+ // [chainable, clone]
975
+ // clone self and multiply by scalar.
976
+ // @param scalar - value to multiply with.
977
+ // @return cloned vector.
978
+ mulScalar: function(s) {
979
+ return this.clone().mulScalarSelf(s);
980
+ },
981
+ // [API]
982
+ // [chainable, clone]
983
+ // clone self and divide by scalar.
984
+ // @param scalar - value to divide by.
985
+ // @return cloned vector.
986
+ divScalar: function(s) {
987
+ return this.clone().divScalarSelf(s);
988
+ },
989
+ // [API]
990
+ // [chainable, changeSelf]
991
+ // clamp vector values into range.
992
+ // note: this function does not validate that min < max.
993
+ // @param min - min value for x, y components.
994
+ // @param max - max value for x, y components.
995
+ // @return self.
996
+ clampSelf: function(s, d) {
997
+ return this.x < s.x && (this.x = s.x), this.y < s.y && (this.y = s.y), this.x > d.x && (this.x = d.x), this.y > d.y && (this.y = d.y), this;
998
+ },
999
+ // [API]
1000
+ // [chainable, clone]
1001
+ // clone vector and clamp its values.
1002
+ // note: this function does not validate that min < max.
1003
+ // @param min - min value for x, y components.
1004
+ // @param max - max value for x, y components.
1005
+ // @return cloned vector in range.
1006
+ clamp: function(s, d) {
1007
+ return this.clone().clampSelf(s, d);
1008
+ },
1009
+ // [API]
1010
+ // [chainable, changeSelf]
1011
+ // apply a function on x and y components of the vector.
1012
+ // for example, you can use Math.round to round the vector x, y values.
1013
+ // @param func - function to apply on components.
1014
+ // @return self.
1015
+ applySelf: function(s) {
1016
+ return this.x = s(this.x), this.y = s(this.y), this;
1017
+ },
1018
+ // [API]
1019
+ // [chainable, clone]
1020
+ // clone self and apply a function on x and y components of the clone vector.
1021
+ // for example, you can use Math.round to round the vector x, y values.
1022
+ // @param func - function to apply on components.
1023
+ // @return cloned vector.
1024
+ apply: function(s) {
1025
+ return this.clone().applySelf(s);
1026
+ },
1027
+ // [API]
1028
+ // [chainable, changeSelf]
1029
+ // turn self to absolute values (eg turn x, y positive).
1030
+ // @return self.
1031
+ absSelf: function() {
1032
+ return this.applySelf(Math.abs);
1033
+ },
1034
+ // [API]
1035
+ // [chainable, clone]
1036
+ // clone and turn to absolute values (eg turn x, y positive).
1037
+ // @return cloned vector.
1038
+ abs: function() {
1039
+ return this.clone().absSelf();
1040
+ },
1041
+ // [API]
1042
+ // [chainable, changeSelf]
1043
+ // turn self to round values (eg turn x, y positive).
1044
+ // @return self.
1045
+ roundSelf: function() {
1046
+ return this.applySelf(Math.round);
1047
+ },
1048
+ // [API]
1049
+ // [chainable, clone]
1050
+ // clone and turn to round values (eg turn x, y positive).
1051
+ // @return cloned vector.
1052
+ round: function() {
1053
+ return this.clone().roundSelf();
1054
+ },
1055
+ // [API]
1056
+ // []
1057
+ // calculate dot-product of this vector with another vector.
1058
+ // @param other - other vector to calculate dot-product with.
1059
+ // @return dot product.
1060
+ dot: function(s) {
1061
+ return this.x * s.x + this.y * s.y;
1062
+ },
1063
+ // [API]
1064
+ // []
1065
+ // calculate cross-product of this vector with another vector.
1066
+ // @param other - other vector to calculate cross-product with.
1067
+ // @return dot product.
1068
+ cross: function(s) {
1069
+ return this.x * s.y - this.y * s.x;
1070
+ },
1071
+ // [API]
1072
+ // [chainable, changeSelf]
1073
+ // if any of the components of this vector are NaN, null, undefined, etc. set them to defaults.
1074
+ // note: 0's are considered to be a valid number and will not be replaced with a default value.
1075
+ // @param x - default value for x if undefined (0 if not defined).
1076
+ // @param y - default value for y if undefined (0 if not defined).
1077
+ // @return self.
1078
+ repairSelf: function(s, d) {
1079
+ return (typeof this.x != "number" || isNaN(this.x + 1)) && (this.x = s || 0), (typeof this.y != "number" || isNaN(this.y + 1)) && (this.y = d || 0), this;
1080
+ },
1081
+ // [API]
1082
+ // [chainable, clone]
1083
+ // create a clone and if any of the components of the vector are NaN, null, undefined, etc. set them to default.
1084
+ // note: 0's are considered to be a valid number and will not be replaced with a default value.
1085
+ // @param x - default value for x if undefined (0 if not defined).
1086
+ // @param y - default value for y if undefined (0 if not defined).
1087
+ // @return repaired clone.
1088
+ repair: function(s, d) {
1089
+ return this.clone().repairSelf(s, d);
1090
+ },
1091
+ // [API]
1092
+ // []
1093
+ // convert to string in the form of "x,y".
1094
+ // @return string representation of the vector.
1095
+ toString: function() {
1096
+ return this.x + "," + this.y;
1097
+ },
1098
+ // [API]
1099
+ // []
1100
+ // convert to a string with a given format.
1101
+ // @param format - a string in which %x and %y will be replaced with the vector values.
1102
+ // @return formatted string representing the vector.
1103
+ format: function(s) {
1104
+ return s = s || "%x,%y", s = s.replace(new RegExp("%x", "g"), this.x), s = s.replace(new RegExp("%y", "g"), this.y), s;
1105
+ }
1106
+ }, f;
1107
+ }();
1108
+ return e.zero = new e(0, 0), e.one = new e(1, 1), e.up = new e(0, -1), e.down = new e(0, 1), e.left = new e(-1, 0), e.right = new e(1, 0), e.upLeft = new e(-1, -1), e.downLeft = new e(-1, 1), e.upRight = new e(1, -1), e.downRight = new e(1, 1), e.prototype.magnitude = e.prototype.length, Object.freeze && (Object.freeze(e.zero), Object.freeze(e.one), Object.freeze(e.up), Object.freeze(e.down), Object.freeze(e.left), Object.freeze(e.right), Object.freeze(e.upLeft), Object.freeze(e.downLeft), Object.freeze(e.upRight), Object.freeze(e.downRight)), e;
1109
+ });
1110
+ })(kr);
1111
+ var Xr = kr.exports;
1112
+ const X = /* @__PURE__ */ lr(Xr);
1113
+ let Me = (p = 21) => crypto.getRandomValues(new Uint8Array(p)).reduce((e, a) => (a &= 63, a < 36 ? e += a.toString(36) : a < 62 ? e += (a - 26).toString(36).toUpperCase() : a > 62 ? e += "-" : e += "_", e), "");
1114
+ const ce = {
1115
+ strokeType: "plain",
1116
+ strokeColor: "black",
1117
+ strokeWidth: 1,
1118
+ head: "none",
1119
+ tail: "none"
1120
+ }, cr = {
1121
+ id: 0,
1122
+ type: "Feature",
1123
+ properties: {
1124
+ type: "arrow",
1125
+ style: {
1126
+ ...ce
1127
+ }
1128
+ },
1129
+ geometry: {
1130
+ type: "LineString",
1131
+ coordinates: [
1132
+ [0, 0],
1133
+ [100, 100]
1134
+ ]
1135
+ }
1136
+ // type: 'arrow',
1137
+ // stroke: {
1138
+ // type: 'plain',
1139
+ // color: 'black',
1140
+ // width: 1
1141
+ // },
1142
+ // head: 'none',
1143
+ // tail: 'arrow-plain',
1144
+ // start: { x: 0, y: 0 },
1145
+ // end: { x: 100, y: 100 }
1146
+ }, Zr = (p = 0, e = 0, a = 0, i = 0, h = { ...ce }) => ({
1147
+ id: Me(),
1148
+ type: "Feature",
1149
+ properties: {
1150
+ type: "arrow",
1151
+ style: {
1152
+ ...ce,
1153
+ ...h
1154
+ }
1155
+ },
1156
+ geometry: {
1157
+ type: "LineString",
1158
+ coordinates: [
1159
+ [p, e],
1160
+ [a, i]
1161
+ ]
1162
+ }
1163
+ }), Gr = "http://www.w3.org/2000/svg";
1164
+ function he(p) {
1165
+ return document.createElementNS(Gr, p);
1166
+ }
1167
+ function Tr(p) {
1168
+ return p.geometry.bbox || Jr(p), p.geometry.bbox;
1169
+ }
1170
+ function mt(p) {
1171
+ const e = Tr(p);
1172
+ return {
1173
+ width: e[2] - e[0],
1174
+ height: e[3] - e[1]
1175
+ };
1176
+ }
1177
+ function yt(p) {
1178
+ const e = Tr(p);
1179
+ return { x: e[0], y: e[1] };
1180
+ }
1181
+ function Jr(p) {
1182
+ const [e, a] = p.geometry.coordinates[0][0], [i, h] = p.geometry.coordinates[0][2];
1183
+ p.geometry.bbox = [e, a, i, h];
1184
+ }
1185
+ function Kr(p, e, a, i, h) {
1186
+ p.geometry.bbox = [e, a, e + i, a + h], p.geometry.coordinates = [
1187
+ [
1188
+ [e, a],
1189
+ [e + i, a],
1190
+ [e + i, a + h],
1191
+ [e, a + h],
1192
+ [e, a]
1193
+ ]
1194
+ ];
1195
+ }
1196
+ function ue(p) {
1197
+ const [e, a] = p.geometry.coordinates[0];
1198
+ return { x: e, y: a };
1199
+ }
1200
+ function Ce(p, e) {
1201
+ const [a, i] = p.geometry.coordinates[e === "start" ? 0 : 1];
1202
+ return { x: a, y: i };
1203
+ }
1204
+ function Ie(p) {
1205
+ const [e, a] = p.geometry.coordinates[1];
1206
+ return { x: e, y: a };
1207
+ }
1208
+ function Rr(p, e, a) {
1209
+ p.geometry.coordinates[0] = [e, a];
1210
+ }
1211
+ function Cr(p, e, a) {
1212
+ p.geometry.coordinates[1] = [e, a];
1213
+ }
1214
+ function Oe(p) {
1215
+ return { start: ue(p), end: Ie(p) };
1216
+ }
1217
+ function Nt(p, e, a, i) {
1218
+ e === "start" ? Rr(p, a, i) : Cr(p, a, i);
1219
+ }
1220
+ const Pr = (p) => parseInt(p.getAttribute("data-handle-id") || "-1");
1221
+ function Pe(p, e, a) {
1222
+ const i = Math.atan2(p.y - e.y, p.x - e.x);
1223
+ return {
1224
+ x: e.x + a * Math.cos(i),
1225
+ y: e.y + a * Math.sin(i)
1226
+ };
1227
+ }
1228
+ function rr(p, e) {
1229
+ if (!e)
1230
+ return { x: p.clientX, y: p.clientY };
1231
+ const a = e.getBoundingClientRect();
1232
+ return {
1233
+ x: p.clientX - a.left - e.clientLeft,
1234
+ y: p.clientY - a.top - e.clientTop
1235
+ };
1236
+ }
1237
+ function Ir(p, e = 5, a = 30) {
1238
+ var i;
1239
+ const { start: h, end: c } = Oe(p), g = new X(h.x, h.y), m = new X(c.x, c.y).sub(g), f = p.properties.style && p.properties.style.strokeWidth ? (i = p.properties.style) == null ? void 0 : i.strokeWidth : 0;
1240
+ return Math.min(a, Math.max(3 * f, m.length() * 0.1, e));
1241
+ }
1242
+ function fr(p, e, a, i) {
1243
+ const h = e.clone().normalize().invert().mul(i);
1244
+ if (!a || a === "none")
1245
+ return "";
1246
+ const c = p.clone().add(h.rotateRadians(Math.PI / 8)), g = p.clone().add(h.rotateRadians(-Math.PI / 8)), m = `${p.x} ${p.y}`;
1247
+ return `M ${c.x} ${c.y} L ${m} ${g.x} ${g.y} ${a === "arrow" ? "" : `${c.x} ${c.y}`}`;
1248
+ }
1249
+ function Qr(p, e, a, i, h) {
1250
+ const { start: c, end: g } = Oe(p), { tail: m, head: f, strokeColor: s, strokeWidth: d } = p.properties.style || a, A = new X(c.x, c.y), _ = new X(g.x, g.y), R = _.clone().sub(A), P = Ir(p, i, h), E = he("path");
1251
+ E.setAttribute("data-annotation", `${p.id}`), E.setAttribute("data-annotation-type", "arrow");
1252
+ const M = f === "arrow-plain" || m === "arrow";
1253
+ E.setAttribute("stroke", s || "none"), E.setAttribute("stroke-width", `${d}`), E.setAttribute("fill", M ? s || "" : "none"), E.setAttribute("stroke-linecap", "round"), E.setAttribute("stroke-linejoin", "round");
1254
+ const j = fr(A, R.clone().invert(), m, P), k = fr(_, R, f, P), N = j + `M ${A.x} ${A.y} ${_.x} ${_.y}` + k;
1255
+ E.setAttribute("d", N), e.appendChild(E);
1256
+ }
1257
+ const q = -1, je = "dragging", $e = "dragstart", Bt = "dragend", nr = "select", ir = "unselect", tn = "hover", en = "unhover", sr = "remove", or = "add", rn = "cancelDrawing", ar = "update", nn = "link";
1258
+ var Or = { exports: {} };
1259
+ (function(p) {
1260
+ var e = Object.prototype.hasOwnProperty, a = "~";
1261
+ function i() {
1262
+ }
1263
+ Object.create && (i.prototype = /* @__PURE__ */ Object.create(null), new i().__proto__ || (a = !1));
1264
+ function h(f, s, d) {
1265
+ this.fn = f, this.context = s, this.once = d || !1;
1266
+ }
1267
+ function c(f, s, d, A, _) {
1268
+ if (typeof d != "function")
1269
+ throw new TypeError("The listener must be a function");
1270
+ var R = new h(d, A || f, _), P = a ? a + s : s;
1271
+ return f._events[P] ? f._events[P].fn ? f._events[P] = [f._events[P], R] : f._events[P].push(R) : (f._events[P] = R, f._eventsCount++), f;
1272
+ }
1273
+ function g(f, s) {
1274
+ --f._eventsCount === 0 ? f._events = new i() : delete f._events[s];
1275
+ }
1276
+ function m() {
1277
+ this._events = new i(), this._eventsCount = 0;
1278
+ }
1279
+ m.prototype.eventNames = function() {
1280
+ var f = [], s, d;
1281
+ if (this._eventsCount === 0)
1282
+ return f;
1283
+ for (d in s = this._events)
1284
+ e.call(s, d) && f.push(a ? d.slice(1) : d);
1285
+ return Object.getOwnPropertySymbols ? f.concat(Object.getOwnPropertySymbols(s)) : f;
1286
+ }, m.prototype.listeners = function(f) {
1287
+ var s = a ? a + f : f, d = this._events[s];
1288
+ if (!d)
1289
+ return [];
1290
+ if (d.fn)
1291
+ return [d.fn];
1292
+ for (var A = 0, _ = d.length, R = new Array(_); A < _; A++)
1293
+ R[A] = d[A].fn;
1294
+ return R;
1295
+ }, m.prototype.listenerCount = function(f) {
1296
+ var s = a ? a + f : f, d = this._events[s];
1297
+ return d ? d.fn ? 1 : d.length : 0;
1298
+ }, m.prototype.emit = function(f, s, d, A, _, R) {
1299
+ var P = a ? a + f : f;
1300
+ if (!this._events[P])
1301
+ return !1;
1302
+ var E = this._events[P], M = arguments.length, j, k;
1303
+ if (E.fn) {
1304
+ switch (E.once && this.removeListener(f, E.fn, void 0, !0), M) {
1305
+ case 1:
1306
+ return E.fn.call(E.context), !0;
1307
+ case 2:
1308
+ return E.fn.call(E.context, s), !0;
1309
+ case 3:
1310
+ return E.fn.call(E.context, s, d), !0;
1311
+ case 4:
1312
+ return E.fn.call(E.context, s, d, A), !0;
1313
+ case 5:
1314
+ return E.fn.call(E.context, s, d, A, _), !0;
1315
+ case 6:
1316
+ return E.fn.call(E.context, s, d, A, _, R), !0;
1317
+ }
1318
+ for (k = 1, j = new Array(M - 1); k < M; k++)
1319
+ j[k - 1] = arguments[k];
1320
+ E.fn.apply(E.context, j);
1321
+ } else {
1322
+ var N = E.length, H;
1323
+ for (k = 0; k < N; k++)
1324
+ switch (E[k].once && this.removeListener(f, E[k].fn, void 0, !0), M) {
1325
+ case 1:
1326
+ E[k].fn.call(E[k].context);
1327
+ break;
1328
+ case 2:
1329
+ E[k].fn.call(E[k].context, s);
1330
+ break;
1331
+ case 3:
1332
+ E[k].fn.call(E[k].context, s, d);
1333
+ break;
1334
+ case 4:
1335
+ E[k].fn.call(E[k].context, s, d, A);
1336
+ break;
1337
+ default:
1338
+ if (!j)
1339
+ for (H = 1, j = new Array(M - 1); H < M; H++)
1340
+ j[H - 1] = arguments[H];
1341
+ E[k].fn.apply(E[k].context, j);
1342
+ }
1343
+ }
1344
+ return !0;
1345
+ }, m.prototype.on = function(f, s, d) {
1346
+ return c(this, f, s, d, !1);
1347
+ }, m.prototype.once = function(f, s, d) {
1348
+ return c(this, f, s, d, !0);
1349
+ }, m.prototype.removeListener = function(f, s, d, A) {
1350
+ var _ = a ? a + f : f;
1351
+ if (!this._events[_])
1352
+ return this;
1353
+ if (!s)
1354
+ return g(this, _), this;
1355
+ var R = this._events[_];
1356
+ if (R.fn)
1357
+ R.fn === s && (!A || R.once) && (!d || R.context === d) && g(this, _);
1358
+ else {
1359
+ for (var P = 0, E = [], M = R.length; P < M; P++)
1360
+ (R[P].fn !== s || A && !R[P].once || d && R[P].context !== d) && E.push(R[P]);
1361
+ E.length ? this._events[_] = E.length === 1 ? E[0] : E : g(this, _);
1362
+ }
1363
+ return this;
1364
+ }, m.prototype.removeAllListeners = function(f) {
1365
+ var s;
1366
+ return f ? (s = a ? a + f : f, this._events[s] && g(this, s)) : (this._events = new i(), this._eventsCount = 0), this;
1367
+ }, m.prototype.off = m.prototype.removeListener, m.prototype.addListener = m.prototype.on, m.prefixed = a, m.EventEmitter = m, p.exports = m;
1368
+ })(Or);
1369
+ var sn = Or.exports;
1370
+ const jr = /* @__PURE__ */ lr(sn);
1371
+ class $r extends jr {
1372
+ constructor(e, a) {
1373
+ 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, "maxHandleScale", 1.5), x(this, "_onKeyUp", (i) => {
1374
+ i.code === 27 && this.selectedId !== q ? this.unselect() : (i.code === 46 || i.code === 8) && this.selectedId !== q && this._canRemove() && this.remove(this.selectedId);
1375
+ }), x(this, "_onClickMouseMove", (i) => {
1376
+ if (!i.domEvent || this.isDragging || !this.shouldDetect || i.domEvent.type !== "mousemove" && i.domEvent.target && i.domEvent.target.tagName === "a")
1377
+ return;
1378
+ const h = this.ogma.view.screenToGraphCoordinates(i), c = this.shouldDetect || !this.shouldDetect && +this.selectedId > -1 ? this.detect(h, 0) : void 0;
1379
+ i.domEvent.type === "mousemove" ? c ? this.hover(c.id) : this.hoveredId !== q && this.unhover() : c ? this.select(c.id) : this.selectedId !== q && this.unselect();
1380
+ }), 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", () => {
1381
+ this.refreshEditor(), this.refreshDrawing();
1382
+ }), this.layer = e.layers.addSVGLayer({
1383
+ draw: (i) => this.draw(i)
1384
+ }), this.layer.moveToTop(), this.editor = e.layers.addLayer(a), this.editor.hide();
1385
+ }
1386
+ _canRemove() {
1387
+ return !0;
1388
+ }
1389
+ /**
1390
+ * @method add
1391
+ * @param options Params for the annotation (merged with default)
1392
+ * @returns the added annotation
1393
+ */
1394
+ add(e) {
1395
+ const a = this.getDefaultOptions(), i = Object.assign(e, {
1396
+ id: e.id === void 0 ? Me() : e.id,
1397
+ type: e.type,
1398
+ properties: {
1399
+ ...a.properties,
1400
+ ...e.properties || {},
1401
+ // styles need to be merged
1402
+ style: { ...a.properties.style, ...e.properties.style || {} }
1403
+ },
1404
+ geometry: {
1405
+ ...a.geometry,
1406
+ ...e.geometry
1407
+ }
1408
+ });
1409
+ return this.elements.push(i), this.layer.refresh(), this.emit(or, i), i;
1410
+ }
1411
+ updateStyle(e, a) {
1412
+ this.updateAnnotation(e, {
1413
+ properties: {
1414
+ style: a
1415
+ }
1416
+ });
1417
+ }
1418
+ updateGeometry(e, a) {
1419
+ this.updateAnnotation(e, {
1420
+ geometry: a
1421
+ });
1422
+ }
1423
+ /**
1424
+ * @method update
1425
+ * Updates an annotation (position, color etc)
1426
+ * @param id Id of the annotation to update
1427
+ * @param new params of the annotation
1428
+ */
1429
+ update(e, a) {
1430
+ const i = this.getById(e);
1431
+ this.updateAnnotation(i, a);
1432
+ }
1433
+ updateAnnotation(e, a) {
1434
+ if (!e)
1435
+ return;
1436
+ const i = e.id;
1437
+ Object.keys(a).forEach((h) => {
1438
+ if (h !== "id")
1439
+ if (h === "properties") {
1440
+ const c = a.properties || { style: {} };
1441
+ e.properties = {
1442
+ ...e.properties || {},
1443
+ ...c || {},
1444
+ style: {
1445
+ ...e.properties.style || {},
1446
+ ...c.style || {}
1447
+ }
1448
+ };
1449
+ } else
1450
+ h === "geometry" ? e.geometry = {
1451
+ ...e.geometry,
1452
+ ...a.geometry
1453
+ } : e[h] = a[h];
1454
+ }), i === this.selectedId && this.refreshEditor(), this.layer.refresh();
1455
+ }
1456
+ getById(e) {
1457
+ const a = Number(e);
1458
+ for (let i = 0; i < this.elements.length; i++) {
1459
+ const h = this.elements[i];
1460
+ if (!(h.id !== e && h.id !== a))
1461
+ return h;
1462
+ }
1463
+ }
1464
+ /**
1465
+ * @method select
1466
+ * @param id id of the element to select
1467
+ * Select element, show editor, disable Ogma dragging and fire event
1468
+ */
1469
+ select(e) {
1470
+ const a = this.getById(e);
1471
+ a && (this.editor.show(), this.selectedId = e, this.refreshEditor(), this.layer.refresh(), this.emit(nr, a));
1472
+ }
1473
+ hover(e) {
1474
+ const a = this.getById(e);
1475
+ a && (this.showeditorOnHover && this.editor.show(), this.hoveredId = e, this.refreshEditor(), this.layer.refresh(), this.emit(tn, a));
1476
+ }
1477
+ getSelectedFeature() {
1478
+ return this.selectedId === q ? null : this.getById(this.selectedId);
1479
+ }
1480
+ unselect() {
1481
+ const e = this.getById(this.selectedId);
1482
+ return e && this.emit(ir, e), this.selectedId = q, this.hoveredId === q && this.editor.hide(), this.layer.refresh(), this;
1483
+ }
1484
+ unhover() {
1485
+ const e = this.getById(this.hoveredId);
1486
+ return this.emit(en, e), this.hoveredId = q, this.selectedId === q && this.editor.hide(), this.layer.refresh(), this;
1487
+ }
1488
+ /**
1489
+ * @method remove
1490
+ * @param id Id of the annotation to remove
1491
+ * Removes annotation with the given id
1492
+ */
1493
+ remove(e) {
1494
+ const a = this.getById(e);
1495
+ e === this.hoveredId && this.unhover(), e === this.selectedId && this.unselect(), this.elements = this.elements.filter((i) => i.id !== e), a && this.emit(sr, a), this.layer.refresh();
1496
+ }
1497
+ /**
1498
+ * @method disableDragging
1499
+ * Prevents Ogma from dragging elements or moving the view while dragging an annotation
1500
+ */
1501
+ disableDragging() {
1502
+ this.ogma.setOptions({
1503
+ interactions: {
1504
+ drag: { enabled: !1 },
1505
+ pan: { enabled: !1 }
1506
+ },
1507
+ detect: {
1508
+ nodes: !1,
1509
+ edges: !1,
1510
+ nodeTexts: !1,
1511
+ edgeTexts: !1
1512
+ }
1513
+ });
1514
+ }
1515
+ /**
1516
+ * @method restoreDragging
1517
+ * restore ogma options as they were before we start dragging an annotation
1518
+ */
1519
+ restoreDragging() {
1520
+ this.ogma.setOptions(this.ogmaOptions);
1521
+ }
1522
+ enableDetection() {
1523
+ this.shouldDetect = !0;
1524
+ }
1525
+ /**
1526
+ * @method disableDetection
1527
+ * Disables the hover behaviour, used by controller to avoid hovering
1528
+ * arrows while dragging texts and vice versa
1529
+ */
1530
+ disableDetection() {
1531
+ this.shouldDetect = !1;
1532
+ }
1533
+ refreshLayer() {
1534
+ this.layer.refresh();
1535
+ }
1536
+ refreshDrawing() {
1537
+ }
1538
+ getElements() {
1539
+ return [...this.elements];
1540
+ }
1541
+ destroy() {
1542
+ this.ogma.events.off(this._onClickMouseMove).off(this._onKeyUp), this.layer.destroy();
1543
+ }
1544
+ }
1545
+ const dr = "handle-line", pr = "handle-start", gr = "handle-end";
1546
+ class on extends $r {
1547
+ constructor(e, a = {}) {
1548
+ super(
1549
+ e,
1550
+ `
1551
+ <div class="arrow-handle">
1552
+ <div id="${dr}" data-handle-id="0" class="handle line"></div>
1553
+ <div id="${pr}" data-handle-id="1" class="handle"></div>
1554
+ <div id="${gr}" data-handle-id="2" class="handle"></div>
1555
+ </div>
1556
+ `
1557
+ ), x(this, "draggedHandle", q), x(this, "start", { x: 0, y: 0 }), x(this, "end", { x: 0, y: 0 }), x(this, "arrow", { ...cr }), x(this, "startX", 0), x(this, "startY", 0), x(this, "minArrowHeight", 0), x(this, "maxArrowHeight", 0), x(this, "handles", []), x(this, "onHandleMouseDown", (i) => {
1558
+ const h = this.getById(this.selectedId) || this.getById(this.hoveredId);
1559
+ if (!h)
1560
+ return;
1561
+ const { x: c, y: g } = rr(i, this.ogma.getContainer());
1562
+ this.startDragging(h, c, g), this.draggedHandle = Pr(i.target);
1563
+ }), x(this, "onMouseUp", () => {
1564
+ this.draggedHandle !== -1 && (this.restoreDragging(), this.isDragging = !1, this.draggedHandle = q, this.emit(Bt, this.arrow));
1565
+ }), x(this, "onMouseMove", (i) => {
1566
+ if (!this.isDragging || this.draggedHandle === q)
1567
+ return;
1568
+ const h = this.handles[this.draggedHandle], c = this.ogma.view.getAngle(), { x: g, y: m } = new X(
1569
+ i.clientX - this.startX,
1570
+ i.clientY - this.startY
1571
+ ).divScalar(this.ogma.view.getZoom()).rotateRadians(c), f = h.id === dr, s = h.id === pr, d = h.id === gr;
1572
+ (f || s) && Rr(this.arrow, this.start.x + g, this.start.y + m), (f || d) && Cr(this.arrow, this.end.x + g, this.end.y + m), this.emit(
1573
+ je,
1574
+ this.arrow,
1575
+ f ? "line" : s ? "start" : "end"
1576
+ ), this.refreshEditor(), this.layer.refresh();
1577
+ }), this.minArrowHeight = a.minArrowHeight || 0, this.maxArrowHeight = a.maxArrowHeight || 1e6, this.handles = Array.prototype.slice.call(
1578
+ this.editor.element.querySelectorAll(".arrow-handle>.handle")
1579
+ ), this.handles.forEach(
1580
+ (i) => i.addEventListener("mousedown", this.onHandleMouseDown)
1581
+ ), document.addEventListener("mousemove", this.onMouseMove, !0), document.addEventListener("mouseup", this.onMouseUp);
1582
+ }
1583
+ /**
1584
+ * Start drawing a new arrow, it will also be added as a new annotation
1585
+ * @param x
1586
+ * @param y
1587
+ * @param arrow
1588
+ */
1589
+ startDrawing(e, a, i = Zr(e, a, e, a, ce)) {
1590
+ var h;
1591
+ this.disableDragging(), this.add(i), this.hoveredId = i.id;
1592
+ const c = this.ogma.view.graphToScreenCoordinates({ x: e, y: a }), g = ((h = this.ogma.getContainer()) == null ? void 0 : h.getBoundingClientRect()) || {
1593
+ left: 0,
1594
+ top: 0
1595
+ };
1596
+ this.startDragging(
1597
+ this.getById(i.id),
1598
+ c.x + (g == null ? void 0 : g.left),
1599
+ c.y + g.top
1600
+ ), this.draggedHandle = 2;
1601
+ }
1602
+ cancelDrawing() {
1603
+ this.isDragging && (this.remove(this.arrow.id), this.emit(Bt, this.arrow), this.restoreDragging(), this.isDragging = !1, this.draggedHandle = q);
1604
+ }
1605
+ startDragging(e, a, i) {
1606
+ this.selectedId !== e.id && this.select(this.hoveredId), this.arrow = e, this.startX = a, this.startY = i, this.start = ue(this.arrow), this.end = Ie(this.arrow), this.disableDragging(), this.emit($e, this.arrow), this.isDragging = !0;
1607
+ }
1608
+ detect(e, a = 0) {
1609
+ return this.elements.find((i) => {
1610
+ const { start: h, end: c } = Oe(i), g = new X(e.x, e.y).sub(
1611
+ new X((h.x + c.x) / 2, (h.y + c.y) / 2)
1612
+ ), m = new X(c.x, c.y).sub(new X(h.x, h.y)), f = m.length(), s = m.normalize(), d = Ir(i);
1613
+ return Math.abs(s.dot(g)) < f / 2 + a && Math.abs(s.rotateRadians(Math.PI / 2).dot(g)) < d / 2 + a;
1614
+ });
1615
+ }
1616
+ refreshEditor() {
1617
+ if (+this.selectedId < 0 && +this.hoveredId < 0)
1618
+ return;
1619
+ const e = this.selectedId !== q ? this.getById(this.selectedId) : this.getById(this.hoveredId), a = Oe(e), i = this.ogma.view.graphToScreenCoordinates(a.start), h = this.ogma.view.graphToScreenCoordinates(a.end), c = Math.min(this.ogma.view.getZoom(), this.maxHandleScale), [g, m, f] = Array.prototype.slice.call(
1620
+ this.editor.element.querySelectorAll(".handle")
1621
+ );
1622
+ m.style.transform = `translate(${i.x}px, ${i.y}px) translate(-50%, -50%) scale(${c})`, f.style.transform = `translate(${h.x}px, ${h.y}px) translate(-50%, -50%) scale(${c}`;
1623
+ const s = {
1624
+ x: (h.x + i.x) / 2,
1625
+ y: (h.y + i.y) / 2
1626
+ }, d = new X(h.x - i.x, h.y - i.y), A = d.mul(1 / d.length()), _ = Math.atan2(A.y, A.x);
1627
+ g.style.width = `${d.length()}px`, g.style.left = `${s.x}px`, g.style.top = `${s.y}px`, g.style.transform = `translate(-50%, -50%) rotate(${_}rad)`;
1628
+ }
1629
+ getDefaultOptions() {
1630
+ return cr;
1631
+ }
1632
+ draw(e) {
1633
+ e.innerHTML = "";
1634
+ const a = he("g"), i = this.ogma.view.getAngle();
1635
+ a.setAttribute("transform", `rotate(${-i * (180 / Math.PI)})`), this.elements.forEach(
1636
+ (h) => Qr(h, a, ce, this.minArrowHeight, this.maxArrowHeight)
1637
+ ), e.appendChild(a);
1638
+ }
1639
+ refreshDrawing() {
1640
+ const e = this.ogma.view.getAngle();
1641
+ this.layer.element.children[0].setAttribute(
1642
+ "transform",
1643
+ `rotate(${-e * (180 / Math.PI)})`
1644
+ );
1645
+ }
1646
+ destroy() {
1647
+ super.destroy(), document.removeEventListener("mousemove", this.onMouseMove, !0), document.removeEventListener("mouseup", this.onMouseUp);
1648
+ }
1649
+ }
1650
+ const Ht = {
1651
+ font: "sans-serif",
1652
+ fontSize: 12,
1653
+ color: "black",
1654
+ background: "",
1655
+ strokeWidth: 1,
1656
+ strokeColor: "#000",
1657
+ strokeType: "plain"
1658
+ }, Ke = {
1659
+ id: 0,
1660
+ type: "Feature",
1661
+ properties: {
1662
+ type: "text",
1663
+ content: "",
1664
+ style: { ...Ht }
1665
+ },
1666
+ geometry: {
1667
+ type: "Polygon",
1668
+ coordinates: [
1669
+ [
1670
+ [0, 0],
1671
+ [100, 0],
1672
+ [100, 50],
1673
+ [0, 50],
1674
+ [0, 0]
1675
+ ]
1676
+ ]
1677
+ }
1678
+ // position: { x: 0, y: 0 },
1679
+ // size: { width: 100, height: 50 }
1680
+ }, yr = {
1681
+ handleSize: 3.5,
1682
+ placeholder: "Your text..."
1683
+ }, an = (p = 0, e = 0, a = 100, i = 50, h = "", c = { ...Ht }) => ({
1684
+ id: Me(),
1685
+ type: "Feature",
1686
+ properties: {
1687
+ type: "text",
1688
+ content: h,
1689
+ style: { ...Ht, ...c }
1690
+ },
1691
+ geometry: {
1692
+ type: "Polygon",
1693
+ coordinates: [
1694
+ [
1695
+ [p, e],
1696
+ [p + a, e],
1697
+ [p + a, e + i],
1698
+ [p, e + i],
1699
+ [p, e]
1700
+ ]
1701
+ ]
1702
+ }
1703
+ });
1704
+ var Mr = { exports: {} };
1705
+ (function(p, e) {
1706
+ (function(a, i) {
1707
+ p.exports = i();
1708
+ })(qr, () => (() => {
1709
+ var a = { d: (r, n) => {
1710
+ for (var l in n)
1711
+ a.o(n, l) && !a.o(r, l) && Object.defineProperty(r, l, { enumerable: !0, get: n[l] });
1712
+ }, o: (r, n) => Object.prototype.hasOwnProperty.call(r, n) }, i = {};
1713
+ function h(r) {
1714
+ return h = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
1715
+ return typeof n;
1716
+ } : function(n) {
1717
+ return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
1718
+ }, h(r);
1719
+ }
1720
+ a.d(i, { default: () => Xe });
1721
+ var c = /^((?:[a-z\d-]+\s+)*)([\d.]+(%|em|px)|(?:x+-)?large|(?:x+-)?small|medium)(?:\s*\/\s*(normal|[\d.]+(%|px|em)?))?(\s.+)?$/, g = /\bsmall-caps\b/, m = /\b(?:italic|oblique)\b/, f = /\bbold(?:er)?\b/, s = 13.3333333, d = { "xx-small": 9, "x-small": 10, smaller: 13.3333, small: 13, medium: 16, large: 18, larger: 19.2, "x-large": 24, "xx-large": 32 };
1722
+ function A(r) {
1723
+ var n = "", l = this;
1724
+ return l.style && l.style !== "normal" && (n += l.style), l.variant && l.variant !== "normal" && (n += (n ? " " : "") + l.variant), l.weight && l.weight !== "normal" && (n += (n ? " " : "") + l.weight), l.size && (n += (n ? " " : "") + l.size + "px", l.height !== l.size && (n += "/" + l.height + "px")), l.family && (n += (n ? " " : "") + l.family), r && (n += "::" + l.baseline), r && (n += "::" + l.color), n;
1725
+ }
1726
+ var _ = { id: "", family: "sans-serif", height: 14, size: 12, variant: "", style: "", weight: "", baseline: "", color: null, toString: A, valueOf: A };
1727
+ function R(r) {
1728
+ var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, l = c.exec(r);
1729
+ n.family = (l[6] || "").trim();
1730
+ var t = d[l[2]] || parseFloat(l[2]);
1731
+ l[3] === "%" ? t *= 0.16 : l[3] === "em" ? t *= 16 : l[3] === "pt" && (t *= s), n.size = t;
1732
+ var o = parseFloat(l[4]);
1733
+ if (o !== "normal" && o !== "inherit" && o ? l[5] && l[5] !== "em" ? l[5] === "pt" ? n.height = o * s : l[5] === "%" ? n.height = 0.01 * t : n.height = o : n.height = o * t : n.height = Math.round(t * (7 / 6)), g.test(l[1]) && (n.variant = "small-caps"), m.test(l[1]) && (n.style = "italic"), f.test(l[1]))
1734
+ n.weight = "bold";
1735
+ else {
1736
+ var u = parseInt(/\b(\d+)\b/.exec(l[1]), 10);
1737
+ u >= 100 && u !== 400 && (n.weight = u);
1738
+ }
1739
+ return n;
1740
+ }
1741
+ function P() {
1742
+ var r, n, l, 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, y = 12, v = null, w = null, b = "";
1743
+ if (t && t.nodeType) {
1744
+ var S = t && (t.ownerDocument && t.ownerDocument.defaultView || t.document && t || t.defaultView), I = S.getComputedStyle(t, null);
1745
+ r = I.getPropertyValue("font-family") || "", y = parseFloat(I.getPropertyValue("font-size")), u = I.getPropertyValue("line-height"), v = I.getPropertyValue("font-weight"), w = I.getPropertyValue("font-style"), b = I.getPropertyValue("font-variant") || "";
1746
+ } else if (typeof t == "string") {
1747
+ var T = R(t);
1748
+ r = T.family, y = T.size, u = T.height, b = T.variant, w = T.style, v = T.weight;
1749
+ } else
1750
+ h(t) === "object" && (r = t.family, y = t.size, u = t.height, b = t.variant, v = t.weight, w = t.style, n = t.baseline, l = t.color);
1751
+ o.size && o.size < 3 && (y *= o.size), u = u !== "normal" && u ? parseFloat(u) : y * (7 / 6), o.height && o.height < 3 && (u *= o.height);
1752
+ var C = Object.create(_);
1753
+ return C.family = o.family || r || "sans-serif", C.height = u ?? 14, C.size = y ?? 12, C.variant = o.variant || b || "", C.style = o.style || w || "", C.weight = o.weight || v || "", C.baseline = n || 0, o.baseline != null && (C.baseline = o.baseline), C.color = o.color || l || "", C.id = A.call(C, !0), C;
1754
+ }
1755
+ const E = { "\n": 0.28, "\r": 0.28, " ": 0.28, " ": 0.28, " ": 0.28, "᠎": 0, " ": 0.5, " ": 1, " ": 0.5, " ": 1, " ": 0.33, " ": 0.25, " ": 0.16, " ": 0.56, " ": 0.28, " ": 0.2, " ": 0.15, "​": 0, " ": 0.16, " ": 0.22, " ": 1, "\uFEFF": 0 };
1756
+ var M, j = function(r) {
1757
+ var n = typeof OffscreenCanvas < "u" && new OffscreenCanvas(100, 100) || r && r.createElement("canvas");
1758
+ if (n && n.getContext) {
1759
+ var l = n.getContext("2d");
1760
+ if (l && typeof l.measureText == "function")
1761
+ return function(t, o) {
1762
+ return l.font = String(o), l.measureText(t).width;
1763
+ };
1764
+ }
1765
+ }(typeof document < "u" ? document : null) || (M = {}, function(r, n) {
1766
+ if (!M[n]) {
1767
+ var l = P(n);
1768
+ M[n] = l, /\bmonospace\b/.test(l.family) ? l.size *= 0.6 : (l.size *= 0.45, l.weight && (l.size *= 1.18));
1769
+ }
1770
+ return r.length * M[n].size;
1771
+ }), k = {}, N = { trim: !0, collapse: !0 };
1772
+ function H(r, n, l) {
1773
+ var t = Object.assign({}, N, l), o = String(r);
1774
+ if (!o)
1775
+ return 0;
1776
+ if (o in E) {
1777
+ var u = n.id + "/" + o;
1778
+ return u in k || (k[u] = j("_".concat(o, "_"), n) - j("__", n)), k[u];
1779
+ }
1780
+ return t.trim && t.collapse ? t.trim ? o = o.trim() : t.collapse && (o = o.replace(/\s+/g, " ")) : o = o.replace(/\n/g, " "), j(o, n) + n.size * (r.tracking || 0);
1781
+ }
1782
+ function st(r) {
1783
+ return st = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
1784
+ return typeof n;
1785
+ } : function(n) {
1786
+ return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
1787
+ }, st(r);
1788
+ }
1789
+ function xt(r, n) {
1790
+ if (typeof n != "function" && n !== null)
1791
+ throw new TypeError("Super expression must either be null or a function");
1792
+ r.prototype = Object.create(n && n.prototype, { constructor: { value: r, writable: !0, configurable: !0 } }), Object.defineProperty(r, "prototype", { writable: !1 }), n && Ut(r, n);
1793
+ }
1794
+ function Ut(r, n) {
1795
+ return Ut = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(l, t) {
1796
+ return l.__proto__ = t, l;
1797
+ }, Ut(r, n);
1798
+ }
1799
+ function Wt(r) {
1800
+ var n = function() {
1801
+ if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham)
1802
+ return !1;
1803
+ if (typeof Proxy == "function")
1804
+ return !0;
1805
+ try {
1806
+ return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
1807
+ })), !0;
1808
+ } catch {
1809
+ return !1;
1810
+ }
1811
+ }();
1812
+ return function() {
1813
+ var l, t = Rt(r);
1814
+ if (n) {
1815
+ var o = Rt(this).constructor;
1816
+ l = Reflect.construct(t, arguments, o);
1817
+ } else
1818
+ l = t.apply(this, arguments);
1819
+ return fe(this, l);
1820
+ };
1821
+ }
1822
+ function fe(r, n) {
1823
+ if (n && (st(n) === "object" || typeof n == "function"))
1824
+ return n;
1825
+ if (n !== void 0)
1826
+ throw new TypeError("Derived constructors may only return object or undefined");
1827
+ return function(l) {
1828
+ if (l === void 0)
1829
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
1830
+ return l;
1831
+ }(r);
1832
+ }
1833
+ function Rt(r) {
1834
+ return Rt = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(n) {
1835
+ return n.__proto__ || Object.getPrototypeOf(n);
1836
+ }, Rt(r);
1837
+ }
1838
+ function Ct(r, n) {
1839
+ if (!(r instanceof n))
1840
+ throw new TypeError("Cannot call a class as a function");
1841
+ }
1842
+ function Yt(r, n) {
1843
+ for (var l = 0; l < n.length; l++) {
1844
+ var t = n[l];
1845
+ t.enumerable = t.enumerable || !1, t.configurable = !0, "value" in t && (t.writable = !0), Object.defineProperty(r, (o = function(u, y) {
1846
+ if (st(u) !== "object" || u === null)
1847
+ return u;
1848
+ var v = u[Symbol.toPrimitive];
1849
+ if (v !== void 0) {
1850
+ var w = v.call(u, y);
1851
+ if (st(w) !== "object")
1852
+ return w;
1853
+ throw new TypeError("@@toPrimitive must return a primitive value.");
1854
+ }
1855
+ return String(u);
1856
+ }(t.key, "string"), st(o) === "symbol" ? o : String(o)), t);
1857
+ }
1858
+ var o;
1859
+ }
1860
+ function et(r, n, l) {
1861
+ return n && Yt(r.prototype, n), l && Yt(r, l), Object.defineProperty(r, "prototype", { writable: !1 }), r;
1862
+ }
1863
+ var F = function() {
1864
+ function r() {
1865
+ var n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "";
1866
+ Ct(this, r), this.value = n, this.weight = null, this.style = null, this.font = null, this.href = null, this.sub = !1, this.sup = !1;
1867
+ }
1868
+ return et(r, [{ key: "clone", value: function() {
1869
+ var n = new r(this.value);
1870
+ 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;
1871
+ } }, { key: "valueOf", value: function() {
1872
+ return this.value;
1873
+ } }, { key: "toString", value: function() {
1874
+ return this.value;
1875
+ } }]), r;
1876
+ }(), at = function(r) {
1877
+ xt(l, r);
1878
+ var n = Wt(l);
1879
+ function l() {
1880
+ return Ct(this, l), n.apply(this, arguments);
1881
+ }
1882
+ return et(l);
1883
+ }(F), Z = function(r) {
1884
+ xt(l, r);
1885
+ var n = Wt(l);
1886
+ function l() {
1887
+ return Ct(this, l), n.apply(this, arguments);
1888
+ }
1889
+ return et(l);
1890
+ }(F), ht = function(r) {
1891
+ xt(l, r);
1892
+ var n = Wt(l);
1893
+ function l() {
1894
+ return Ct(this, l), n.apply(this, arguments);
1895
+ }
1896
+ return et(l);
1897
+ }(F), Pt = /^[\n\r\t\x20\xA0\u2000-\u200B\u205F\u3000]/, de = /^[^\n\r\t\u0020\u2000-\u200B\u205F\u3000]{2,}/, Vt = /^[\xA0\u2011\u202F\u2060\uFEFF]/, pe = /^(?:[;\xAD%?…]|,(?!\d))/, ge = /^[´±°¢£¤$¥\u2212]/;
1898
+ function St(r, n) {
1899
+ n !== !1 && (r = r.trim());
1900
+ for (var l, t, o = [], u = r.charAt(0), y = 0, v = 1, w = r.length; v < w; v++) {
1901
+ l = r.charAt(v), t = r.charAt(v + 1);
1902
+ var b = Pt.test(u), S = Pt.test(l), I = S || b, T = void 0;
1903
+ if ((ge.test(l) && !Vt.test(u) || pe.test(u + t) && !Vt.test(l)) && (I = !0), u !== "-" && u !== "‐" && u !== "–" && u !== "—" || ((T = Pt.test(r.charAt(v - 2))) && !S && (I = !1), !T && de.test(l + t) && (I = !0)), I) {
1904
+ var C = r.slice(y, v);
1905
+ /\u00AD$/.test(C) ? (o.push(new F(C.slice(0, -1))), o.push(new ht())) : (o.push(new F(C)), o.push(new at())), y = v;
1906
+ }
1907
+ u = l;
1908
+ }
1909
+ return o.push(new F(r.slice(y))), o;
1910
+ }
1911
+ const ye = { 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: "›" };
1912
+ var De = /^[\n\r\x20\u2000-\u200B\u205F\u3000]/, qt = /^<\/([a-zA-Z0-9]+)([^>]*)>/, Xt = /^<([a-zA-Z0-9]+)((?:\s[^=\s/]+(?:\s*=\s*(?:"[^"]+"|'[^']+'|[^>\\s]+))?)+)?\s*(\/?)>(\n*)/, It = /^<!--(.+?)-->/, Zt = /&(?:#(\d\d{2,})|#x([\da-fA-F]{2,})|([a-zA-Z][a-zA-Z1-4]{1,8}));/g, At = { b: function(r) {
1913
+ r.weight = "bold";
1914
+ }, strong: function(r) {
1915
+ r.weight = "bold";
1916
+ }, i: function(r) {
1917
+ r.style = "italic";
1918
+ }, em: function(r) {
1919
+ r.style = "italic";
1920
+ }, dfn: function(r) {
1921
+ r.style = "italic";
1922
+ }, cite: function(r) {
1923
+ r.style = "italic";
1924
+ }, code: function(r) {
1925
+ r.family = "monospace";
1926
+ }, kbd: function(r) {
1927
+ r.family = "monospace";
1928
+ }, samp: function(r) {
1929
+ r.family = "monospace";
1930
+ }, var: function(r) {
1931
+ r.family = "monospace";
1932
+ }, tt: function(r) {
1933
+ r.family = "monospace";
1934
+ }, sub: function(r) {
1935
+ r.sub = !0;
1936
+ }, sup: function(r) {
1937
+ r.sup = !0;
1938
+ } }, Fe = { 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 };
1939
+ function Gt(r) {
1940
+ return r.replace(Zt, function(n, l, t, o) {
1941
+ if (l || t) {
1942
+ var u = l ? 10 : 16;
1943
+ return String.fromCharCode(parseInt(l || t, u));
1944
+ }
1945
+ return o in ye ? ye[o] : n;
1946
+ });
1947
+ }
1948
+ function Le(r) {
1949
+ return r && r.length > 1 && (r[0] === '"' && r[r.length - 1] === '"' || r[0] === "'" && r[r.length - 1] === "'") ? r.slice(1, -1) : r;
1950
+ }
1951
+ var ze = /^\s*([^=\s&]+)(?:\s*=\s*("[^"]+"|'[^']+'|[^>\s]+))?/;
1952
+ function Ot(r) {
1953
+ var n, l = {};
1954
+ if (r) {
1955
+ do
1956
+ if (n = ze.exec(r)) {
1957
+ var t = Gt(Le(n[2] || "")).replace(/[ \r\n\t]+/g, " ").trim();
1958
+ if (l[n[1]] = t, (r = r.slice(n[0].length)).length && /^\S/.test(r[0]))
1959
+ throw new Error("Attribute error");
1960
+ }
1961
+ while (n && r.length);
1962
+ if (/\S/.test(r))
1963
+ throw new Error("Attribute error");
1964
+ }
1965
+ return l;
1966
+ }
1967
+ const Et = { 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: "Þ" };
1968
+ var me = /^(\^|_|\\[^#$%&~_^\\{}()\s]+)(\{)?/, ve = /^%[^\n]+(?:\n|$)/, jt = /^[^#$%&~_^\\{}]+/, Ne = /^\\([&{}$%#_])/, He = /(?:\\[\\@,!:;-]|-{2,3}|[!?]`|``?|,,|''?|~|<<|>>)/g, Jt = { "---": "—", "--": "–", "!`": "¡", "?`": "¿", "``": "“", ",,": "„", "''": "”", "`": "‘", "'": "’", "<<": "«", ">>": "»", "~": " ", "\\-": "­", "\\,": " ", "\\;": " ", "\\:": " ", "\\!": " ", "\\@": "\uFEFF", "\\\\": "\\newline{}" }, B = { bf: function(r) {
1969
+ r.weight = "bold";
1970
+ }, it: function(r) {
1971
+ r.style = "italic";
1972
+ }, sl: function(r) {
1973
+ r.style = "italic";
1974
+ }, color: function(r, n) {
1975
+ r.color = n;
1976
+ }, href: function(r, n) {
1977
+ r.href = n;
1978
+ }, "^": function(r) {
1979
+ r.sup = !0;
1980
+ }, _: function(r) {
1981
+ r.sub = !0;
1982
+ }, par: function(r) {
1983
+ this.tokens.push(new Z(), new Z());
1984
+ }, newline: function(r) {
1985
+ this.tokens.push(new Z());
1986
+ }, url: function(r, n) {
1987
+ this.open_context().href = n, this.add_token(new F(n)), this.close_context();
1988
+ } };
1989
+ B.textsuperscript = B["^"], B.textsubscript = B._, B.textsl = B.sl, B.mathbf = B.bf, B.mathit = B.it, B.textbf = B.bf, B.textit = B.it, B.textcolor = B.color;
1990
+ var Be = /[\r\n\xA0]+/g;
1991
+ function be(r, n) {
1992
+ r.sup && (r.baseline = 0.45, r.size = 0.7), r.sub && (r.baseline = -0.3, r.size = 0.7);
1993
+ var l = n;
1994
+ return (r.style || r.weight || r.baseline || r.color || r.size || r.family) && (l = P(n, r)), l;
1995
+ }
1996
+ function Kt(r, n, l) {
1997
+ for (var t, o, u = r.width; u + l.width > n && r.length; )
1998
+ o = (t = r[r.length - 1]).width, t.width > l.width ? (t.value = t.value.slice(0, -1), t.width = H(t, t.font), u += t.width) : r.pop(), u -= o;
1999
+ r[r.length - 1] instanceof ht && r.pop(), t = r[r.length - 1] || t || {}, l.font = P(l.font, t.bold, t.italic, ""), l.href = r.length ? t.href : null, l.rel = r.length ? t.rel : null, l.target = r.length ? t.target : null, r.push(l);
2000
+ }
2001
+ function ot(r) {
2002
+ return Math.round(1e6 * r) / 1e6;
2003
+ }
2004
+ function we(r) {
2005
+ return function(n) {
2006
+ if (Array.isArray(n))
2007
+ return $t(n);
2008
+ }(r) || function(n) {
2009
+ if (typeof Symbol < "u" && n[Symbol.iterator] != null || n["@@iterator"] != null)
2010
+ return Array.from(n);
2011
+ }(r) || function(n, l) {
2012
+ if (n) {
2013
+ if (typeof n == "string")
2014
+ return $t(n, l);
2015
+ var t = Object.prototype.toString.call(n).slice(8, -1);
2016
+ 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) ? $t(n, l) : void 0;
2017
+ }
2018
+ }(r) || function() {
2019
+ throw new TypeError(`Invalid attempt to spread non-iterable instance.
2020
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
2021
+ }();
2022
+ }
2023
+ function $t(r, n) {
2024
+ (n == null || n > r.length) && (n = r.length);
2025
+ for (var l = 0, t = new Array(n); l < n; l++)
2026
+ t[l] = r[l];
2027
+ return t;
2028
+ }
2029
+ var xe = { center: "middle", right: "end" }, Qt = { middle: 0.5, center: 0.5, bottom: 1, end: 1 }, te = function(r, n) {
2030
+ return !r && !n || r === n;
2031
+ };
2032
+ function Ue(r, n) {
2033
+ var l = [], t = n.font(), o = t.size, u = t.family, y = n.align(), v = n.createElement();
2034
+ if (r.length) {
2035
+ var w = t.height, b = n.valign(), S = n.height()(), I = n.width()(0), T = !isFinite(I) && r.length === 1, C = T ? null : n.x(), D = ot(w / o), U = T ? null : ot(w / (1.15 * o + (w - o) / 2));
2036
+ if (Qt[b] && isFinite(S)) {
2037
+ var L = b === "bottom" ? 1 : 0.5;
2038
+ U += (S * L - w * r.length * L) / o;
2039
+ }
2040
+ var O = y === "justify", W = 0;
2041
+ y === "right" ? W = I : y === "center" && (W = I / 2);
2042
+ for (var z = [], rt = "tspan", J = null, Y = "", $ = function() {
2043
+ if (Y) {
2044
+ var kt = v(rt, J, Y);
2045
+ z.push(kt);
2046
+ }
2047
+ rt = "tspan", J = null, Y = "";
2048
+ }, it = 0, nt = r.length; it < nt; it++) {
2049
+ var dt = "", vt = "", ct = 0, pt = r[it];
2050
+ if (pt.length) {
2051
+ z = [];
2052
+ for (var Ft = 0, se = 0, gt = void 0, K = 0, Te = pt.length; K < Te; K++) {
2053
+ var V = pt[K], Q = V.font;
2054
+ V.whitespace && Ft++, se += V.width, K && !V.tracking && !ct && te(Q.id, dt) && te(V.class, vt) && te(gt, V.href) ? Y += V.value : ($(), Y = V.value, J = { fontFamily: Q.family !== u ? Q.family : null, fontSize: Q.size !== o ? Q.size : null, fontWeight: Q.weight || null, fontStyle: Q.style || null, fontVariant: Q.variant !== "normal" && Q.variant || null, fill: Q.color || null, baselineShift: Q.baseline ? 100 * Q.baseline + "%" : null, className: V.class || null }, ct && (J.dx = ot(ct), ct = 0), V.tracking && (ct = Q.size * V.tracking), V.href && !gt ? (gt = V.href, rt = "a", J.href = gt, J.rel = V.rel, J.target = V.target) : gt = null, dt = Q.id, vt = V.class);
2055
+ }
2056
+ if ($(), T)
2057
+ l.push.apply(l, we(z));
2058
+ else {
2059
+ var Re = null, oe = it === nt - 1 || pt[pt.length - 1] instanceof Z;
2060
+ O && pt.length > 1 && !oe && (Re = ot((I - se) / Ft)), l.push(v.apply(void 0, ["tspan", { wordSpacing: Re, x: C(it) + W, dy: ot(it ? D : U) + "em" }].concat(we(z))));
2061
+ }
2062
+ } else
2063
+ l.push(v("tspan", { x: C(it), dy: ot(it ? D : U) + "em" }, " "));
2064
+ }
2065
+ }
2066
+ return v.apply(void 0, ["text", { fontFamily: u, fontSize: o, textAnchor: xe[y] || "start" }].concat(l));
2067
+ }
2068
+ var We = { middle: 0.5, center: 0.5, bottom: 1, end: 1 };
2069
+ function Ye(r, n, l) {
2070
+ if (r.length) {
2071
+ l.textBaseline = "middle";
2072
+ var t = n.font(), o = t.height, u = t.size, y = n.valign(), v = n.height()(), w = n.width()(0), b = n.align(), S = b === "justify", I = 0.5 * o, T = We[y];
2073
+ if (T && isFinite(v)) {
2074
+ var C = r.length * o;
2075
+ I += v * T - C * T;
2076
+ }
2077
+ r.forEach(function(D, U) {
2078
+ var L = n.x()(U), O = U * o + I, W = 0, z = 0;
2079
+ D.forEach(function(Y) {
2080
+ Y.whitespace && W++, z += Y.width;
2081
+ });
2082
+ var rt = 0, J = U === r.length - 1 || D[D.length - 1] instanceof Z;
2083
+ S && D.length > 1 && !J && (rt = (w - z) / W), D.forEach(function(Y) {
2084
+ l.font = Y.font;
2085
+ var $ = Y.font, it = $.baseline ? u * -$.baseline + 0.15 * u : 0;
2086
+ l.fillStyle = function(vt, ct) {
2087
+ return vt.color ? vt.color : ct.href ? "#00C" : "#000";
2088
+ }($, Y);
2089
+ var nt = 0;
2090
+ if (b === "right" ? nt += w - z : b === "center" ? nt += w / 2 - z / 2 : b === "justify" && (Y.whitespace || Y instanceof Z) && (L += rt), l.fillText(Y.value, L + nt, O + it), Y.href) {
2091
+ l.beginPath(), l.strokeStyle = l.fillStyle;
2092
+ var dt = Math.floor(O + 0.45 * u) + 0.5;
2093
+ l.moveTo(L + nt, dt), l.lineTo(L + nt + Y.width, dt), l.stroke();
2094
+ }
2095
+ L += Y.width;
2096
+ });
2097
+ });
2098
+ }
2099
+ }
2100
+ function ee(r) {
2101
+ return ee = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
2102
+ return typeof n;
2103
+ } : function(n) {
2104
+ return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
2105
+ }, ee(r);
2106
+ }
2107
+ function Se(r) {
2108
+ for (var n = {}, l = 0; l < r.length; l++) {
2109
+ var t = r[l];
2110
+ typeof t != "number" && t != null && (typeof t == "string" ? n.text = t : typeof t == "function" ? n.fn = t : ee(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));
2111
+ }
2112
+ return n;
2113
+ }
2114
+ function _t(r) {
2115
+ return _t = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
2116
+ return typeof n;
2117
+ } : function(n) {
2118
+ return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
2119
+ }, _t(r);
2120
+ }
2121
+ function re(r, n) {
2122
+ for (var l = 0; l < n.length; l++) {
2123
+ var t = n[l];
2124
+ t.enumerable = t.enumerable || !1, t.configurable = !0, "value" in t && (t.writable = !0), Object.defineProperty(r, (o = function(u, y) {
2125
+ if (_t(u) !== "object" || u === null)
2126
+ return u;
2127
+ var v = u[Symbol.toPrimitive];
2128
+ if (v !== void 0) {
2129
+ var w = v.call(u, y);
2130
+ if (_t(w) !== "object")
2131
+ return w;
2132
+ throw new TypeError("@@toPrimitive must return a primitive value.");
2133
+ }
2134
+ return String(u);
2135
+ }(t.key, "string"), _t(o) === "symbol" ? o : String(o)), t);
2136
+ }
2137
+ var o;
2138
+ }
2139
+ var Ae = P(), ut = function(r) {
2140
+ return typeof r == "function" ? r : function() {
2141
+ return r;
2142
+ };
2143
+ }, G = function() {
2144
+ function r(t) {
2145
+ if (function(u, y) {
2146
+ if (!(u instanceof y))
2147
+ throw new TypeError("Cannot call a class as a function");
2148
+ }(this, r), this.props = { overflow: "ellipsis", lineclamp: null, align: "left", wordBreak: null, valign: "top", width: function() {
2149
+ return 1 / 0;
2150
+ }, height: function() {
2151
+ return 1 / 0;
2152
+ }, x: function() {
2153
+ return 0;
2154
+ }, font: null, tAnchor: 0, parser: r.defaultparser }, t)
2155
+ for (var o in t)
2156
+ typeof this[o] == "function" && this[o](t[o]);
2157
+ }
2158
+ var n, l;
2159
+ return n = r, l = [{ key: "linebreak", value: function(t) {
2160
+ var o = this, u = this.props.parser(String(t)), y = this.font(), v = function(w, b, S) {
2161
+ if (!w.length)
2162
+ return [];
2163
+ var I = b.height(), T = b.width(), C = b.overflowLine(), D = b.overflowWrap(), U = P(S, !0, !1), L = isFinite(I()) ? Math.floor(I() / S.height) : 1 / 0;
2164
+ if (!I() && !T(0) || !L)
2165
+ return [];
2166
+ for (var O = 0, W = 0, z = 0, rt = [], J = [], Y = !1; O < w.length && W < L; ) {
2167
+ var $ = w[O], it = be($, S);
2168
+ if ($.width = H($, it), $.font = it, $.line = W, $.whitespace = $.value in E, $.value && ($.value = $.value.replace(Be, " ")), !(!z && $.whitespace || Y && $.whitespace))
2169
+ if ($ instanceof Z)
2170
+ z = 0, J = [], rt.push(O + 1), W++;
2171
+ else if ($ instanceof at || $ instanceof ht)
2172
+ J.push({ index: O, width: z });
2173
+ else if ($.whitespace || z + $.width < T(W))
2174
+ z += $.width;
2175
+ else if (J.length) {
2176
+ var nt = void 0, dt = void 0;
2177
+ do {
2178
+ dt = !0, nt = J.pop();
2179
+ var vt = w[nt.index], ct = void 0;
2180
+ vt instanceof ht && (ct = H("-", vt.font), nt.width + ct > T(W) && (dt = !J.length));
2181
+ } while (!dt);
2182
+ rt.push(nt.index + 1), z = 0, W++, O = nt.index, J = [];
2183
+ } else if (D === "break-word") {
2184
+ var pt = T(W);
2185
+ if (z + $.width > pt) {
2186
+ var Ft = $.clone();
2187
+ do
2188
+ $.value = $.value.slice(0, -1), $.width = H($, $.font), z += $.width;
2189
+ while ($.value && $.width > pt);
2190
+ Ft.value = Ft.value.slice($.value.length), w.splice(O + 1, 0, new at(), Ft);
2191
+ }
2192
+ rt.push(O + 1), z = 0, W++;
2193
+ } else
2194
+ z += $.width;
2195
+ O++, Y = $.whitespace;
2196
+ }
2197
+ O !== rt[rt.length - 1] && rt.push(O);
2198
+ var se = 0, gt = 0, K = rt.map(function(kt) {
2199
+ for (var tt, Tt = se; (tt = w[Tt]) && (tt.whitespace || !tt.value); )
2200
+ Tt++;
2201
+ for (var bt = kt, Ze = null; bt > Tt && (tt = w[bt - 1]) && (tt.whitespace || !(tt.value || tt instanceof ht)); )
2202
+ tt instanceof Z && (Ze = tt), bt--;
2203
+ tt instanceof ht && (tt.value = "-", tt.width = H("-", tt.font)), se = kt;
2204
+ var Lt = w.slice(Tt, bt).filter(function(Ge) {
2205
+ return Ge.value;
2206
+ });
2207
+ return Ze && Lt.push(Ze), Lt.width = Lt.reduce(function(Ge, Lr) {
2208
+ return Ge + Lr.width;
2209
+ }, 0), Lt.width > gt && (gt = Lt.width), Lt;
2210
+ });
2211
+ if (K.hasLineOverflow = !1, C) {
2212
+ var Te = C === "ellipsis" ? "…" : C;
2213
+ K.forEach(function(kt, tt) {
2214
+ var Tt = T(tt);
2215
+ if (kt.width > Tt) {
2216
+ var bt = new F(Te);
2217
+ bt.font = S, bt.width = H(Te, U), Kt(kt, Tt, bt), K.hasLineOverflow = !0;
2218
+ }
2219
+ });
2220
+ }
2221
+ var V = b.overflow() === "ellipsis" ? "…" : b.overflow();
2222
+ if (V && O !== w.length) {
2223
+ var Q = T(K.length - 1), Re = K[K.length - 1], oe = new F(V);
2224
+ oe.font = S, oe.width = H(V, U), Kt(Re, Q, oe), K.hasOverflow = !0;
2225
+ } else
2226
+ K.hasOverflow = !1;
2227
+ return K.font = S, K.width = gt, K;
2228
+ }(u, this, y);
2229
+ return v.height = v.length * y.height, v.render = function(w) {
2230
+ return o.render(v, w);
2231
+ }, v.svg = v.render, v.draw = v.render, v;
2232
+ } }, { key: "font", value: function(t) {
2233
+ return arguments.length ? (this.props.font = P(t), this) : this.props.font || P(Ae);
2234
+ } }, { key: "overflow", value: function(t) {
2235
+ return arguments.length ? (this.props.overflow = String(t), this) : this.props.overflow;
2236
+ } }, { key: "overflowLine", value: function(t) {
2237
+ return arguments.length ? (this.props.lineclamp = String(t), this) : this.props.lineclamp;
2238
+ } }, { key: "valign", value: function(t) {
2239
+ return arguments.length ? (this.props.valign = t, this) : this.props.valign;
2240
+ } }, { key: "align", value: function(t) {
2241
+ if (!arguments.length)
2242
+ return this.props.align;
2243
+ var o = String(t).toLowerCase();
2244
+ return o === "left" || o === "start" ? (this.props.align = "left", this.props.tAnchor = 0) : o === "center" || o === "middle" ? (this.props.align = "center", this.props.tAnchor = -0.5) : o === "end" || o === "right" ? (this.props.align = "right", this.props.tAnchor = -1) : o === "justify" && (this.props.align = t, this.props.tAnchor = 0), this;
2245
+ } }, { key: "overflowWrap", value: function(t) {
2246
+ if (!arguments.length)
2247
+ return this.props.overflowWrap || "normal";
2248
+ var o = String(t).toLowerCase();
2249
+ return o === "break-word" ? this.props.overflowWrap = "break-word" : o !== "normal" && t != null || (this.props.overflowWrap = null), this;
2250
+ } }, { key: "width", value: function(t) {
2251
+ return arguments.length ? (this.props.width = ut(t), this) : this.props.width;
2252
+ } }, { key: "height", value: function(t) {
2253
+ return arguments.length ? (this.props.height = ut(t), this) : this.props.height;
2254
+ } }, { key: "x", value: function(t) {
2255
+ return arguments.length ? (this.props.x = ut(t), this) : this.props.x;
2256
+ } }, { key: "parser", value: function(t) {
2257
+ if (!arguments.length)
2258
+ return this.props.parser;
2259
+ if (typeof t == "string") {
2260
+ var o = r[t] || r[t + "parser"];
2261
+ typeof o == "function" && (t = o);
2262
+ }
2263
+ if (typeof t != "function")
2264
+ throw new Error("Unknown parser: " + t);
2265
+ return this.props.parser = t, this;
2266
+ } }, { key: "createElement", value: function(t) {
2267
+ return arguments.length ? (this.props.createElement = t, this) : this.props.createElement || r.createElement;
2268
+ } }, { key: "render", value: function() {
2269
+ var t = Se(arguments);
2270
+ return typeof t.text == "string" && (t.text = this.linebreak(t.text)), t.ctx ? Ye(t.text, this, t.ctx) : Ue(t.text, this);
2271
+ } }], l && re(n.prototype, l), Object.defineProperty(n, "prototype", { writable: !1 }), r;
2272
+ }();
2273
+ function ft(r) {
2274
+ return ft = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
2275
+ return typeof n;
2276
+ } : function(n) {
2277
+ return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
2278
+ }, ft(r);
2279
+ }
2280
+ function Mt(r, n) {
2281
+ (n == null || n > r.length) && (n = r.length);
2282
+ for (var l = 0, t = new Array(n); l < n; l++)
2283
+ t[l] = r[l];
2284
+ return t;
2285
+ }
2286
+ function Ve(r, n) {
2287
+ for (var l = 0; l < n.length; l++) {
2288
+ var t = n[l];
2289
+ t.enumerable = t.enumerable || !1, t.configurable = !0, "value" in t && (t.writable = !0), Object.defineProperty(r, (o = function(u, y) {
2290
+ if (ft(u) !== "object" || u === null)
2291
+ return u;
2292
+ var v = u[Symbol.toPrimitive];
2293
+ if (v !== void 0) {
2294
+ var w = v.call(u, y);
2295
+ if (ft(w) !== "object")
2296
+ return w;
2297
+ throw new TypeError("@@toPrimitive must return a primitive value.");
2298
+ }
2299
+ return String(u);
2300
+ }(t.key, "string"), ft(o) === "symbol" ? o : String(o)), t);
2301
+ }
2302
+ var o;
2303
+ }
2304
+ var ne = function(r) {
2305
+ return typeof r == "function" ? r : function() {
2306
+ return r;
2307
+ };
2308
+ }, Ee = function() {
2309
+ function r(t) {
2310
+ if (function(u, y) {
2311
+ if (!(u instanceof y))
2312
+ throw new TypeError("Cannot call a class as a function");
2313
+ }(this, r), this.props = { width: function() {
2314
+ return 1 / 0;
2315
+ }, height: function() {
2316
+ return 1 / 0;
2317
+ }, rotation: 0, vAnchor: 0, hAnchor: 0 }, t)
2318
+ for (var o in t)
2319
+ typeof this[o] == "function" && this[o](t[o]);
2320
+ this.render = this.render.bind(this);
2321
+ }
2322
+ var n, l;
2323
+ return n = r, l = [{ key: "anchor", value: function(t) {
2324
+ var o = this.props, u = o.hAnchor, y = o.vAnchor, v = o.width, w = o.height;
2325
+ if (!arguments.length)
2326
+ return [u * v(0), y * w(0)];
2327
+ if (typeof t == "string") {
2328
+ var b = this.props;
2329
+ t.toLowerCase().trim().split(/\s+/).forEach(function(S) {
2330
+ S === "top" && (b.vAnchor = -0), S === "middle" && (b.vAnchor = -0.5), S === "bottom" && (b.vAnchor = -1), S === "left" && (b.hAnchor = -0), S === "center" && (b.hAnchor = -0.5), S === "right" && (b.hAnchor = -1);
2331
+ });
2332
+ }
2333
+ return this;
2334
+ } }, { key: "width", value: function(t) {
2335
+ return arguments.length ? (this.props.width = ne(t), this) : this.props.width;
2336
+ } }, { key: "height", value: function(t) {
2337
+ return arguments.length ? (this.props.height = ne(t), this) : this.props.height;
2338
+ } }, { key: "rotate", value: function(t) {
2339
+ return arguments.length ? (this.props.rotation = t, this) : this.props.rotation;
2340
+ } }, { key: "createElement", value: function(t) {
2341
+ return arguments.length ? (this.props.createElement = t, this) : this.props.createElement || r.createElement;
2342
+ } }, { key: "canvas", value: function(t, o) {
2343
+ var u, y = t.getContext ? t.getContext("2d") : t;
2344
+ return y.save(), y.rotate(this.rotate() * Math.PI / 180), y.translate.apply(y, function(v) {
2345
+ if (Array.isArray(v))
2346
+ return Mt(v);
2347
+ }(u = this.anchor()) || function(v) {
2348
+ if (typeof Symbol < "u" && v[Symbol.iterator] != null || v["@@iterator"] != null)
2349
+ return Array.from(v);
2350
+ }(u) || function(v, w) {
2351
+ if (v) {
2352
+ if (typeof v == "string")
2353
+ return Mt(v, w);
2354
+ var b = Object.prototype.toString.call(v).slice(8, -1);
2355
+ return b === "Object" && v.constructor && (b = v.constructor.name), b === "Map" || b === "Set" ? Array.from(v) : b === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b) ? Mt(v, w) : void 0;
2356
+ }
2357
+ }(u) || function() {
2358
+ throw new TypeError(`Invalid attempt to spread non-iterable instance.
2359
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
2360
+ }()), o(y), y.restore(), y;
2361
+ } }, { key: "render", value: function() {
2362
+ var t = Se(arguments);
2363
+ if (t.d3)
2364
+ return t.d3.attr("transform", "rotate(".concat(this.rotate(), ") translate(").concat(this.anchor(), ")"));
2365
+ if (t.ctx)
2366
+ return this.canvas(t.ctx, t.fn);
2367
+ if (t.text) {
2368
+ var o = typeof t.text.render == "function" ? t.text.render() : t.text;
2369
+ return this.createElement()("g", { transform: "rotate(".concat(this.rotate(), ") translate(").concat(this.anchor(), ")") }, o);
2370
+ }
2371
+ } }], l && Ve(n.prototype, l), Object.defineProperty(n, "prototype", { writable: !1 }), r;
2372
+ }(), _e = Object.prototype.hasOwnProperty, Dt = {};
2373
+ function qe(r) {
2374
+ return Dt[r] || (Dt[r] = r.replace(/([a-z])([A-Z])/g, function(n, l, t) {
2375
+ return l + "-" + t.toLowerCase();
2376
+ })), Dt[r];
2377
+ }
2378
+ function ke(r, n) {
2379
+ if (Array.isArray(n))
2380
+ return n.forEach(function(l) {
2381
+ return ke(r, l);
2382
+ });
2383
+ typeof n == "string" && (n = document.createTextNode(n)), r.appendChild(n);
2384
+ }
2385
+ function ie(r, n) {
2386
+ if (typeof document < "u") {
2387
+ var l = typeof r == "string" ? document.createElementNS("http://www.w3.org/2000/svg", r) : r;
2388
+ if (n && l.setAttribute)
2389
+ for (var t in n)
2390
+ _e.call(n, t) && n[t] != null && l.setAttribute(t === "className" ? "class" : qe(t), n[t]);
2391
+ for (var o = arguments.length, u = new Array(o > 2 ? o - 2 : 0), y = 2; y < o; y++)
2392
+ u[y - 2] = arguments[y];
2393
+ return u != null && u.length && u.forEach(function(v) {
2394
+ ke(l, v);
2395
+ }), l;
2396
+ }
2397
+ }
2398
+ G.createElement = ie, G.textparser = St, G.defaultparser = St, G.htmlparser = function(r) {
2399
+ r = String(r || "").trim();
2400
+ for (var n, l, t = { weight: null, style: null, sub: !1, sup: !1, href: null, color: null, rel: null, target: null }, o = [], u = [], y = function(I) {
2401
+ for (var T in t)
2402
+ t[T] && (I[T] = t[T]);
2403
+ o.push(I);
2404
+ }, v = function(I) {
2405
+ var T = o.length, C = Fe[I];
2406
+ if (T && C) {
2407
+ for (var D = T - 1; o[D] && (o[D] instanceof at || De.test(o[D].value)); )
2408
+ D--;
2409
+ for (; C && o[D] && o[D] instanceof Z; )
2410
+ D--, C--;
2411
+ for (; C-- > 0; )
2412
+ o.push(new Z());
2413
+ }
2414
+ }; r.length; ) {
2415
+ if (n = /^[^<]+/.exec(r))
2416
+ St(Gt(n[0]), !1).forEach(y);
2417
+ else if (!(n = It.exec(r)))
2418
+ if (n = qt.exec(r))
2419
+ u.length && (t = u.pop()), v(n[1]);
2420
+ else if (n = Xt.exec(r)) {
2421
+ var w = n[1];
2422
+ v(w), u.push(t), t = Object.create(t), At[w] && At[w](t, "");
2423
+ var b = Ot(n[2]);
2424
+ 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 && (l = /(?:^|\s|;)color\s*:\s*([^;\s"']+)/.exec(b.style)) && l[1] && (t.color = l[1]), w === "br" && o.push(new Z());
2425
+ } else
2426
+ n = [r.slice(0, 1)], y(new F(n[0]));
2427
+ r = r.slice(n[0].length);
2428
+ }
2429
+ for (var S = o[o.length - 1]; S instanceof Z; )
2430
+ o.pop(), S = o[o.length - 1];
2431
+ return o;
2432
+ }, G.latexparser = function(r) {
2433
+ r = String(r || "").trim();
2434
+ var n = [0];
2435
+ r = r.replace(/\\verb,(.*?),/, function(L, O) {
2436
+ return n.push(O), "\\verb," + (n.length - 1) + ",";
2437
+ }).replace(/\\\\\n/g, function() {
2438
+ return "\\\\";
2439
+ }).replace(He, function(L, O, W) {
2440
+ return W.charAt(O - 1) === "\\" ? L : Jt[L];
2441
+ }).replace(/\n\s+/g, function(L) {
2442
+ return /\n/.test(L.slice(1)) ? "\\par " : L;
2443
+ }).replace(/\\symbol\{(\d+)\}/, function(L, O, W, z) {
2444
+ return z.charAt(W - 1) === "\\" ? L : String.fromCharCode(1 * O);
2445
+ }).replace(/(^|[^\\])(\^|_)(\d|[^{]\S*)/g, function(L, O, W, z) {
2446
+ return O + W + "{" + z + "}";
2447
+ }).replace(/\\verb,(.*?),/, function(L, O) {
2448
+ return "\\verb,".concat(n[+O], ",");
2449
+ });
2450
+ for (var l, t = { weight: null, italic: null, variant: null, sub: !1, sup: !1, href: null }, o = [], u = [], y = function(L) {
2451
+ for (var O in t)
2452
+ t[O] && (L[O] = t[O]);
2453
+ return o.push(L), L;
2454
+ }, v = function() {
2455
+ u.push(t), t = Object.create(t);
2456
+ }, w = function() {
2457
+ if (!u.length)
2458
+ throw new Error("Unexpected }");
2459
+ t = u.pop();
2460
+ }, b = { tokens: o, open_context: v, close_context: w, add_token: y }; r.length; ) {
2461
+ if (l = jt.exec(r))
2462
+ St(l[0], !1).forEach(y);
2463
+ else if (l = Ne.exec(r))
2464
+ y(new F(l[1]));
2465
+ else if (!(l = ve.exec(r))) {
2466
+ if (l = /^\{/.exec(r))
2467
+ v();
2468
+ else if (l = /^\}/.exec(r))
2469
+ w();
2470
+ else if (!(l = /^\$/.exec(r)))
2471
+ if (l = /^\\verb,([^,]+),/.exec(r))
2472
+ y(new F(l[1]));
2473
+ else if (l = me.exec(r)) {
2474
+ var S = l[1].slice(1) || l[1], I = !!l[2];
2475
+ if (/^(La)?TeX$/i.test(S)) {
2476
+ v(), t.family = "serif";
2477
+ var T = void 0;
2478
+ S === "LaTeX" && ((T = y(new F("L"))).tracking = -0.25, (T = y(new F("A"))).size = 0.7, T.baseline = 0.3, T.tracking = -0.1), (T = y(new F("T"))).tracking = -0.17, (T = y(new F("E"))).baseline = -0.22, T.tracking = -0.13, T = y(new F("X")), w();
2479
+ } else if (S in Et)
2480
+ y(new F(Et[S])), I && v();
2481
+ else if (S in B) {
2482
+ var C = [], D = B[S].length - 1, U = void 0;
2483
+ if (D) {
2484
+ for (I = !1, r = r.slice(l[0].length - 1); D--; ) {
2485
+ if (!(U = /^\{([^}]+)\}/.exec(r)))
2486
+ throw new Error(S + " is missing an argument");
2487
+ C.push(U[1]), r = r.slice(U[0].length);
2488
+ }
2489
+ l[0] = /^\{/.exec(r) ? "{" : "", I = !!l[0];
2490
+ }
2491
+ I && v(), B[S].apply(b, [t].concat(C));
2492
+ } else
2493
+ console.warn("unknown latex command", S), y(new F(l[1])), I && v();
2494
+ } else
2495
+ l = [r.slice(0, 1)], y(new F(l[0]));
2496
+ }
2497
+ r = r.slice(l[0].length);
2498
+ }
2499
+ return o;
2500
+ }, G.measureText = function(r, n, l) {
2501
+ return H(r, P(n), l);
2502
+ }, G.Token = F, G.Break = at, G.LineBreak = Z, G.SoftHyphen = ht, G.Rotator = Ee, Ee.createElement = ie;
2503
+ const Xe = G;
2504
+ return i.default;
2505
+ })());
2506
+ })(Mr);
2507
+ var ln = Mr.exports;
2508
+ const mr = /* @__PURE__ */ lr(ln);
2509
+ function Qe(p) {
2510
+ return p.replace(/…$/, "");
2511
+ }
2512
+ function tr(p) {
2513
+ return p.children[0].innerHTML;
2514
+ }
2515
+ function hn(p, e) {
2516
+ const a = mt(p), { fontSize: i, font: h, padding: c = 0 } = p.properties.style || {};
2517
+ if (a.width === a.height && a.width === 0)
2518
+ return;
2519
+ const g = new mr({
2520
+ font: `${i}px/${i}px ${h}`.replace(/(px)+/g, "px"),
2521
+ width: a.width - c * 2,
2522
+ height: a.height - c * 2,
2523
+ align: "left",
2524
+ valign: "top",
2525
+ x: 0,
2526
+ overflow: "ellipsis",
2527
+ parser: "html",
2528
+ createElement: mr.createElement
2529
+ });
2530
+ g.overflowWrap("break-word");
2531
+ const m = g.linebreak(
2532
+ p.properties.content.replaceAll(`
2533
+ `, "<br>")
2534
+ ).render(), f = [...m.children];
2535
+ let s = 0;
2536
+ const d = [];
2537
+ p.properties.content.split(`
2538
+ `).forEach((R) => {
2539
+ let P = R;
2540
+ for (; P.length && s < f.length; ) {
2541
+ if (f[s].innerHTML === "&nbsp;") {
2542
+ P.startsWith(`
2543
+ `) || d.push(s), s++;
2544
+ break;
2545
+ }
2546
+ const E = Qe(tr(f[s]));
2547
+ P.startsWith(E) && (P = P.slice(E.length).trim()), s++;
2548
+ }
2549
+ }), d.forEach((R) => m.removeChild(f[R]));
2550
+ const A = p.properties.content.match(/(https?:\/\/.*)/gm), _ = A ? A.map((R) => R.split(" ")[0]) : [];
2551
+ m.setAttribute("transform", `translate(${c}, ${c})`), _.forEach((R) => {
2552
+ let P = R;
2553
+ const E = [];
2554
+ for (; P.length > 0; ) {
2555
+ const M = f.find((k) => !!k.children[0] && k.children[0].tagName === "tspan" && P.startsWith(Qe(tr(k))));
2556
+ if (!M)
2557
+ break;
2558
+ E.push(M);
2559
+ const j = Qe(M.children[0].innerHTML).length;
2560
+ if (!j)
2561
+ break;
2562
+ P = P.slice(j);
2563
+ }
2564
+ E.forEach((M) => {
2565
+ const j = document.createElementNS("http://www.w3.org/2000/svg", "a");
2566
+ j.setAttribute("href", R), j.setAttribute("target", "_blank"), j.innerHTML = tr(M), M.children[0].innerHTML = "", M.children[0].appendChild(j);
2567
+ });
2568
+ }), e.appendChild(m);
2569
+ }
2570
+ const vr = 20;
2571
+ class un extends $r {
2572
+ constructor(e, a = {}) {
2573
+ super(
2574
+ e,
2575
+ `
2576
+ <div class="annotation-text-handle">
2577
+ <span class="handle line-handle top" data-handle-id="0"></span>
2578
+ <span class="handle line-handle bottom" data-handle-id="1"></span>
2579
+ <span class="handle line-handle left" data-handle-id="2"></span>
2580
+ <span class="handle line-handle right" data-handle-id="3"></span>
2581
+ <span class="handle top right point-handle top-right" data-handle-id="4"></span>
2582
+ <span class="handle left top point-handle top-left" data-handle-id="5"></span>
2583
+ <span class="handle bottom right point-handle bottom-right" data-handle-id="6"></span>
2584
+ <span class="handle left bottom left-handle point-handle bottom-left" data-handle-id="7"></span>
2585
+ <textarea wrap="on"></textarea>
2586
+ </div>
2587
+ `
2588
+ ), x(this, "textArea"), x(this, "handleSize"), x(this, "rect", { x: 0, y: 0, width: 0, height: 0 }), x(this, "annotation", { ...Ke }), 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", () => {
2589
+ this.textArea.value === this.placeholder && (this.textArea.value = ""), this.isFocused = !0;
2590
+ }), x(this, "_onBlur", () => {
2591
+ this.isFocused = !1;
2592
+ }), x(this, "startDrawing", (h, c, g = an(h, c, 0, 0, "", Ht)) => {
2593
+ this.add(g);
2594
+ const m = this.ogma.view.graphToScreenCoordinates({ x: h, y: c });
2595
+ this.select(g.id), this.startDragging(this.getById(g.id), m.x, m.y), this.draggedHandle = 6;
2596
+ }), x(this, "cancelDrawing", () => {
2597
+ this.isDragging && (this.remove(this.annotation.id), this.annotation = { ...Ke }, this.draggedHandle = q, this.isDragging = !1, this.emit(Bt, this.annotation));
2598
+ }), x(this, "startDragging", (h, c, g) => {
2599
+ this.annotation = h;
2600
+ const m = yt(this.annotation), f = mt(this.annotation);
2601
+ this.rect.x = m.x, this.rect.y = m.y, this.rect.width = f.width, this.rect.height = f.height, this.startX = c, this.startY = g, this.disableDragging(), this.textArea.classList.add("noevents"), this.textArea.setAttribute("disabled", "disabled"), this.emit($e, this.annotation), this.isDragging = !0;
2602
+ }), x(this, "onHandleMouseDown", (h) => {
2603
+ const c = this.getById(this.selectedId) || this.getById(this.hoveredId);
2604
+ if (!c)
2605
+ return;
2606
+ this.selectedId !== c.id && this.select(this.hoveredId);
2607
+ const { x: g, y: m } = rr(h, this.ogma.getContainer());
2608
+ this.startDragging(c, g, m), this.draggedHandle = Pr(h.target);
2609
+ }), x(this, "onMouseMove", (h) => {
2610
+ requestAnimationFrame(() => this._onMouseMove(h));
2611
+ }), x(this, "_onMouseMove", (h) => {
2612
+ if (!this.isDragging)
2613
+ return;
2614
+ h.stopPropagation(), h.preventDefault();
2615
+ const c = this.handles[this.draggedHandle], g = c.classList.contains("top"), m = c.classList.contains("left"), f = c.classList.contains("right"), s = c.classList.contains("bottom"), d = c.classList.contains("line-handle"), { x: A, y: _ } = rr(
2616
+ h,
2617
+ this.ogma.getContainer()
2618
+ ), R = this.ogma.view.getZoom(), P = (A - this.startX) / R, E = (_ - this.startY) / R, M = this.ogma.view.getAngle(), j = new X(P, E).rotateRadians(M);
2619
+ (s && m || g && f) && (j.y = 0, j.x = 0);
2620
+ const k = m || d ? this.rect.x + j.x : this.rect.x, N = g || d ? this.rect.y + j.y : this.rect.y, H = Math.max(
2621
+ this.rect.width + P * (d || m ? 0 : 1),
2622
+ vr
2623
+ ), st = Math.max(
2624
+ this.rect.height + E * (d || g ? 0 : 1),
2625
+ vr
2626
+ );
2627
+ Kr(this.annotation, k, N, H, st), this.emit(je, this.annotation, "text"), this.refreshEditor(), this.layer.refresh();
2628
+ }), x(this, "onMouseUp", () => {
2629
+ !this.isDragging || this.draggedHandle === q || (this.restoreDragging(), this.textArea.classList.remove("noevents"), this.textArea.removeAttribute("disabled"), this.emit(Bt, this.annotation), this.isDragging = !1, this.draggedHandle = q);
2630
+ }), x(this, "_onMousedown", (h) => {
2631
+ h.stopPropagation();
2632
+ }), x(this, "onViewChanged", () => {
2633
+ const h = Math.max(2, this.handleSize / this.ogma.view.getZoom());
2634
+ document.documentElement.style.setProperty("--handle-scale", `${1 / h}`);
2635
+ }), x(this, "_onInput", () => {
2636
+ const h = this.getById(this.selectedId);
2637
+ h && (this.textArea.value = this.textArea.value.replace(/ +(?= )/g, ""), this.textArea.focus(), h.properties.content = this.textArea.value, this.emit(ar, h), this.layer.refresh());
2638
+ }), this.showeditorOnHover = !1, this.handleSize = yr.handleSize, this.placeholder = yr.placeholder;
2639
+ const i = this.textArea = this.editor.element.querySelector("textarea");
2640
+ 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(
2641
+ this.editor.element.querySelectorAll(".annotation-text-handle > .handle")
2642
+ ), this.handles.forEach(
2643
+ (h) => h.addEventListener("mousedown", this.onHandleMouseDown)
2644
+ ), document.addEventListener("mouseup", this.onMouseUp), document.addEventListener("mousemove", this.onMouseMove, !0), e.events.on(["viewChanged", "zoom"], this.onViewChanged);
2645
+ }
2646
+ _canRemove() {
2647
+ return !this.isFocused;
2648
+ }
2649
+ detect({ x: e, y: a }, i = 0) {
2650
+ const h = new X(e, a), c = this.ogma.view.getAngle();
2651
+ return this.elements.find((g) => {
2652
+ const { x: m, y: f } = yt(g), { width: s, height: d } = mt(g), A = new X(m, f), { x: _, y: R } = h.sub(A).rotateRadians(-c);
2653
+ return _ > -i && _ < s + i && R > -i && R < d + i;
2654
+ });
2655
+ }
2656
+ draw(e) {
2657
+ e.innerHTML = "";
2658
+ const a = "", i = this.ogma.view.getAngle();
2659
+ this.elements.forEach((c, g) => {
2660
+ const m = `class${g}`, f = mt(c), s = yt(c), d = c.id, {
2661
+ color: A,
2662
+ fontSize: _,
2663
+ font: R,
2664
+ strokeColor: P,
2665
+ strokeWidth: E,
2666
+ strokeType: M,
2667
+ background: j
2668
+ } = c.properties.style || Ht;
2669
+ if (d === this.selectedId)
2670
+ return;
2671
+ const k = he("g");
2672
+ k.classList.add("annotation-text"), k.setAttribute("fill", `${A}`), k.setAttribute("font-size", `${_}px`), k.setAttribute("font-family", `${R}`);
2673
+ const N = he("rect");
2674
+ let H = !1;
2675
+ M && M !== "none" && (H = !0, N.setAttribute("stroke", P || "black"), N.setAttribute("stroke-width", `${E}`), M === "dashed" && N.setAttribute("stroke-dasharray", "5,5")), (j && j.length || H) && (H = !0, N.setAttribute("fill", j || "transparent")), H && (N.setAttribute("width", `${f.width}`), N.setAttribute("height", `${f.height}`)), k.appendChild(N), hn(c, k);
2676
+ const { x: st, y: xt } = new X(s.x, s.y).rotateRadians(
2677
+ -i
2678
+ );
2679
+ k.setAttribute("transform", `translate(${st},${xt})`), k.classList.add(m), k.setAttribute("data-annotation", `${c.id}`), k.setAttribute("data-annotation-type", "text"), e.appendChild(k);
2680
+ });
2681
+ const h = he("style");
2682
+ h.innerHTML = a, e.firstChild && e.insertBefore(h, e.firstChild);
2683
+ }
2684
+ refreshDrawing() {
2685
+ const e = this.ogma.view.getAngle();
2686
+ [...this.layer.element.children].forEach((a) => {
2687
+ const i = a.getAttribute("data-annotation");
2688
+ if (!i)
2689
+ return;
2690
+ const h = yt(this.getById(i)), { x: c, y: g } = new X(h.x, h.y).rotateRadians(
2691
+ -e
2692
+ );
2693
+ a.setAttribute("transform", `translate(${c},${g})`);
2694
+ });
2695
+ }
2696
+ getDefaultOptions() {
2697
+ return Ke;
2698
+ }
2699
+ refreshEditor() {
2700
+ if (+this.selectedId < 0 && +this.hoveredId < 0)
2701
+ return;
2702
+ const e = this.getById(this.selectedId) || this.getById(this.hoveredId), a = mt(e), i = this.ogma.view.graphToScreenCoordinates(
2703
+ yt(e)
2704
+ ), h = this.ogma.view.getZoom(), {
2705
+ font: c,
2706
+ fontSize: g,
2707
+ color: m,
2708
+ background: f,
2709
+ padding: s = 0
2710
+ } = e.properties.style || Ht, d = (g || 1) * h;
2711
+ this.textArea.value = e.properties.content, this.editor.element.style.transform = `translate(${i.x}px, ${i.y}px)translate(-50%, -50%)translate(${a.width / 2 * h}px, ${a.height / 2 * h}px)`, this.editor.element.style.width = `${a.width * h}px`, this.editor.element.style.height = `${a.height * h}px`, this.textArea.style.font = `${d} ${c}`, this.textArea.style.fontFamily = c || "sans-serif", this.textArea.style.fontSize = `${d}px`, this.textArea.style.padding = `${h * s}px`, this.textArea.style.lineHeight = `${d}px`, this.textArea.style.boxSizing = "border-box", this.textArea.style.color = m || "black", this.textArea.style.background = f || "transparent", this.textArea.placeholder = this.placeholder, this.layer.refresh();
2712
+ }
2713
+ select(e) {
2714
+ super.select(e), this.textArea.focus();
2715
+ }
2716
+ destroy() {
2717
+ super.destroy(), document.removeEventListener("mouseup", this.onMouseUp), document.removeEventListener("mousemove", this.onMouseMove, !0), this.ogma.events.off(this.onViewChanged);
2718
+ }
2719
+ }
2720
+ class cn {
2721
+ constructor() {
2722
+ x(this, "links", {}), x(this, "linksByTargetId", {}), x(this, "linksByArrowId", {});
2723
+ }
2724
+ add(e, a, i, h, c) {
2725
+ const g = Me(), m = e.id, f = {
2726
+ id: g,
2727
+ arrow: m,
2728
+ target: i,
2729
+ targetType: h,
2730
+ connectionPoint: c,
2731
+ side: a
2732
+ };
2733
+ return this.links[g] = f, this.linksByTargetId[i] || (this.linksByTargetId[i] = []), this.linksByTargetId[i].push(g), this.linksByArrowId[m] || (this.linksByArrowId[m] = {}), this.linksByArrowId[m][a] = g, e.properties.link = e.properties.link || {}, e.properties.link[a] = {
2734
+ id: i,
2735
+ side: a,
2736
+ type: h,
2737
+ magnet: c
2738
+ }, this;
2739
+ }
2740
+ arrowIsLinked(e, a) {
2741
+ var i;
2742
+ return !!((i = this.linksByArrowId[e]) != null && i[a]);
2743
+ }
2744
+ // remove the link between the arrow and the target by arrow id and side
2745
+ remove(e, a) {
2746
+ var i, h;
2747
+ const c = e.id, g = (i = this.linksByArrowId[c]) == null ? void 0 : i[a];
2748
+ if ((h = e.properties.link) == null || delete h[a], !g)
2749
+ return this;
2750
+ const m = this.links[g];
2751
+ delete this.links[g];
2752
+ const f = this.linksByTargetId[m.target];
2753
+ for (let s = 0; s < f.length; s++)
2754
+ if (f[s] === g) {
2755
+ f.splice(s, 1);
2756
+ break;
2757
+ }
2758
+ return delete this.linksByArrowId[c][a], this;
2759
+ }
2760
+ getArrowLink(e, a) {
2761
+ var i;
2762
+ const h = (i = this.linksByArrowId[e]) == null ? void 0 : i[a];
2763
+ return h ? this.links[h] : null;
2764
+ }
2765
+ getTargetLinks(e, a) {
2766
+ var i;
2767
+ return ((i = this.linksByTargetId[e]) == null ? void 0 : i.map((h) => this.links[h]).filter((h) => h.targetType === a)) ?? [];
2768
+ }
2769
+ forEach(e) {
2770
+ Object.values(this.links).forEach(e);
2771
+ }
2772
+ }
2773
+ const lt = (p) => p.properties.type === "arrow", wt = (p) => p.properties.type === "text", br = (p) => p.type === "FeatureCollection", fn = {
2774
+ magnetColor: "#3e8",
2775
+ detectMargin: 20,
2776
+ magnetHandleRadius: 5,
2777
+ magnetRadius: 10,
2778
+ textPlaceholder: "Type here",
2779
+ arrowHandleSize: 3.5,
2780
+ textHandleSize: 3.5,
2781
+ minArrowHeight: 20,
2782
+ maxArrowHeight: 30
2783
+ }, wr = ["start", "end"], xr = [
2784
+ { x: 0, y: 0 },
2785
+ { x: 0.5, y: 0 },
2786
+ { x: 1, y: 0 },
2787
+ { x: 0, y: 0.5 },
2788
+ { x: 1, y: 0.5 },
2789
+ { x: 0, y: 1 },
2790
+ { x: 0.5, y: 1 },
2791
+ { x: 1, y: 1 }
2792
+ ];
2793
+ class dn extends jr {
2794
+ constructor(e, a = {}) {
2795
+ super(), x(this, "arrows"), x(this, "texts"), x(this, "links", new cn()), 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) => {
2796
+ if (!this.dragged || this.textToMagnet === void 0)
2797
+ return;
2798
+ i.beginPath(), i.fillStyle = "green";
2799
+ const h = this.ogma.view.getZoom();
2800
+ xr.forEach((c) => {
2801
+ if (!this.textToMagnet)
2802
+ return;
2803
+ const g = mt(this.textToMagnet), m = yt(this.textToMagnet), { x: f, y: s } = new X(c.x, c.y).mul({ x: g.width, y: g.height }).rotateRadians(this.ogma.view.getAngle()).add(m);
2804
+ i.moveTo(f, s), i.arc(f, s, this.options.magnetHandleRadius / h, 0, Math.PI * 2);
2805
+ }), i.fill(), i.closePath();
2806
+ }), x(this, "_onFeatureDrag", (i, h) => {
2807
+ const c = h;
2808
+ if (lt(i) && c === "line")
2809
+ ["start", "end"].find((g) => {
2810
+ const m = g === "start" ? ue(i) : Ie(i);
2811
+ return this._snapToText(i, c, m) || this._findAndSnapToNode(i, g, m);
2812
+ });
2813
+ else if (lt(i) && c !== "line") {
2814
+ const g = c === "start" ? ue(i) : Ie(i);
2815
+ this._snapToText(i, c, g) || this._findAndSnapToNode(i, c, g);
2816
+ } else
2817
+ wt(i) && (this.activeLinks.forEach(({ arrow: g, side: m, connectionPoint: f }) => {
2818
+ const s = this.getAnnotation(g), d = mt(i), A = yt(i), _ = new X(f.x, f.y).mul({ x: d.width, y: d.height }).rotateRadians(this.ogma.view.getAngle()).add(A);
2819
+ s.geometry.coordinates[m === "start" ? 0 : 1] = [_.x, _.y];
2820
+ }), this.activeLinks.length && this.arrows.refreshLayer());
2821
+ this.layer.refresh(), this.emit(je, i, h);
2822
+ }), x(this, "_onFeatureDragEnd", (i) => {
2823
+ this.dragged !== null && lt(i) && ue(this.dragged) && wr.forEach((h) => {
2824
+ this.links.getArrowLink(i.id, h) && this.emit(nn, {
2825
+ arrow: i,
2826
+ link: this.links.getArrowLink(i.id, h)
2827
+ });
2828
+ }), (wt(i) || lt(i)) && this.onUpdate(i), this.dragged = null, this.activeLinks = [], this.textToMagnet = void 0, this.annotations.forEach((h) => h.enableDetection()), this.layer.refresh(), this.emit(Bt, i);
2829
+ }), x(this, "_onFeatureDragStart", (i) => {
2830
+ this.textToMagnet = void 0, lt(i) ? this.dragged = i : wt(i) && this.activeLinks.push(...this.links.getTargetLinks(i.id, "text")), this.annotations.forEach((h) => {
2831
+ const c = h.getSelectedFeature();
2832
+ c && c !== i && h.unhover().unselect(), h.disableDetection();
2833
+ }), this.emit($e, i);
2834
+ }), x(this, "_onNodesDragStart", () => {
2835
+ this.arrows.unhover().unselect(), this.texts.unhover().unselect();
2836
+ }), x(this, "_onNodesDrag", (i) => {
2837
+ const { dx: h, dy: c } = i;
2838
+ this._moveNodes(i.nodes, h, c);
2839
+ }), x(this, "_onLayoutEnd", (i) => {
2840
+ i.ids.forEach((h, c) => {
2841
+ this.links.getTargetLinks(h, "node").forEach((g) => {
2842
+ const m = this.getAnnotation(g.arrow), f = g.side, s = Ce(
2843
+ m,
2844
+ f === "start" ? "end" : "start"
2845
+ ), d = i.positions.current[c], A = this.ogma.getNode(h).getAttribute("radius"), _ = Pe(s, d, +A);
2846
+ Nt(m, f, _.x, _.y);
2847
+ });
2848
+ }), this.arrows.refreshLayer(), this.texts.refreshLayer();
2849
+ }), x(this, "_onAdded", (i) => {
2850
+ this.emit(or, i);
2851
+ }), x(this, "_onRemoved", (i) => {
2852
+ this.emit(sr, i);
2853
+ }), x(this, "_onUnselect", (i) => {
2854
+ this.selected = null, this.emit(ir, i);
2855
+ }), x(this, "_onSelect", (i) => {
2856
+ this.selected !== i && (this.selected = i, this.emit(nr, this.selected));
2857
+ }), x(this, "onUpdate", (i) => {
2858
+ cancelAnimationFrame(this.updateTimeout), this.updateTimeout = requestAnimationFrame(
2859
+ () => this._onUpdate(i)
2860
+ );
2861
+ }), x(this, "_onUpdate", (i) => {
2862
+ this.emit(ar, i);
2863
+ }), this.options = this.setOptions({ ...fn, ...a }), this.ogma = e, this.arrows = new on(e, this.options), this.texts = new un(e, this.options), this.annotations = [this.arrows, this.texts], this.annotations.forEach((i) => {
2864
+ i.on($e, this._onFeatureDragStart).on(je, this._onFeatureDrag).on(Bt, this._onFeatureDragEnd).on(ar, this.onUpdate).on(ir, this._onUnselect).on(nr, this._onSelect).on(or, this._onAdded).on(sr, this._onRemoved);
2865
+ }), this.ogma.events.on("nodesDragStart", this._onNodesDragStart).on("nodesDragProgress", this._onNodesDrag).on("layoutEnd", this._onLayoutEnd).on(["viewChanged", "rotate"], () => {
2866
+ this.refreshTextLinks();
2867
+ }), this.layer = e.layers.addCanvasLayer(this._render), this.layer.moveToBottom();
2868
+ }
2869
+ _moveNodes(e, a, i) {
2870
+ e.forEach((h) => {
2871
+ const c = this.links.getTargetLinks(h.getId(), "node"), g = h.getPosition();
2872
+ c.forEach((m) => {
2873
+ const f = this.getAnnotation(m.arrow), s = m.side, d = Ce(
2874
+ f,
2875
+ s === "start" ? "end" : "start"
2876
+ );
2877
+ let A = g;
2878
+ const _ = +h.getAttribute("radius"), R = 1e-6;
2879
+ (m.connectionPoint.x - (g.x - a) > R || m.connectionPoint.y - (g.y - i) > R) && (A = Pe(d, g, _)), Nt(f, s, A.x, A.y);
2880
+ });
2881
+ }), this.arrows.refreshLayer();
2882
+ }
2883
+ _snapToText(e, a, i) {
2884
+ const h = this.texts.detect(i, this.options.detectMargin);
2885
+ if (this.links.remove(e, a), !h)
2886
+ return !1;
2887
+ this.textToMagnet = h;
2888
+ const c = this.findMagnetPoint(xr, h, i);
2889
+ return c ? (Nt(e, a, c.point.x, c.point.y), this.links.add(e, a, h.id, "text", c.magnet), !0) : !1;
2890
+ }
2891
+ _findAndSnapToNode(e, a, i) {
2892
+ const h = this.ogma.view.graphToScreenCoordinates(i), c = this.ogma.view.getElementAt(h);
2893
+ this.links.remove(e, a), c && c.isNode ? (this.hoveredNode = c, this.hoveredNode.setSelected(!0), this._snapToNode(e, a, c, h)) : (this.hoveredNode && this.hoveredNode.setSelected(!1), this.hoveredNode = null);
2894
+ }
2895
+ _snapToNode(e, a, i, h) {
2896
+ const c = i.getPositionOnScreen(), g = +i.getAttribute("radius"), m = g * this.ogma.view.getZoom(), f = h.x - c.x, s = h.y - c.y, d = Math.sqrt(f * f + s * s), A = i.getPosition();
2897
+ if (d < m + this.options.detectMargin) {
2898
+ let _ = A;
2899
+ if (d > m / 2) {
2900
+ const R = Ce(e, a === "end" ? "start" : "end");
2901
+ _ = Pe(R, _, g);
2902
+ }
2903
+ Nt(e, a, _.x, _.y), this.links.add(e, a, i.getId(), "node", _);
2904
+ }
2905
+ }
2906
+ refreshTextLinks() {
2907
+ let e = !1;
2908
+ this.links.forEach(
2909
+ ({ connectionPoint: a, targetType: i, target: h, arrow: c, side: g }) => {
2910
+ if (i !== "text")
2911
+ return;
2912
+ e = !0;
2913
+ const m = this.getAnnotation(h), f = this.getAnnotation(c), s = mt(m), d = yt(m), A = new X(a.x, a.y).mul({ x: s.width, y: s.height }).rotateRadians(this.ogma.view.getAngle()).add(d);
2914
+ Nt(f, g, A.x, A.y);
2915
+ }
2916
+ ), e && this.arrows.refreshLayer();
2917
+ }
2918
+ /**
2919
+ * @returns the currently selected annotation
2920
+ */
2921
+ getSelected() {
2922
+ return this.selected;
2923
+ }
2924
+ findMagnetPoint(e, a, i) {
2925
+ let h;
2926
+ for (const c of e) {
2927
+ const g = mt(a), m = yt(a), f = new X(c.x, c.y).mul({ x: g.width, y: g.height }).rotateRadians(this.ogma.view.getAngle()).add(m), s = f.sub(i).length(), d = Math.min(
2928
+ this.options.magnetRadius * this.ogma.view.getZoom(),
2929
+ // when really zoomed in: avoid to snap on too far away magnets
2930
+ g.width / 2,
2931
+ g.height / 2
2932
+ );
2933
+ if (s < Math.max(d, this.options.magnetHandleRadius)) {
2934
+ h = {
2935
+ point: f,
2936
+ magnet: c
2937
+ };
2938
+ break;
2939
+ }
2940
+ }
2941
+ return h;
2942
+ }
2943
+ /**
2944
+ * Set the options for the controller
2945
+ * @param options new Options
2946
+ * @returns the updated options
2947
+ */
2948
+ setOptions(e = {}) {
2949
+ return this.options = {
2950
+ ...this.options || {},
2951
+ ...e
2952
+ }, this.options;
2953
+ }
2954
+ /**
2955
+ * Selects the annotation with the given id
2956
+ * @param id the id of the annotation to select
2957
+ */
2958
+ select(e) {
2959
+ const a = this.getAnnotations().features.find((i) => i.id === e);
2960
+ return a ? (lt(a) ? this.arrows.select(a.id) : wt(a) && this.texts.select(a.id), this) : this;
2961
+ }
2962
+ /**
2963
+ * Unselects the currently selected annotation
2964
+ */
2965
+ unselect() {
2966
+ return this.selected ? (lt(this.selected) ? this.arrows.unselect() : wt(this.selected) && this.texts.unselect(), this) : this;
2967
+ }
2968
+ /**
2969
+ * Add an annotation to the controller
2970
+ * @param annotation The annotation to add
2971
+ */
2972
+ add(e) {
2973
+ if (br(e)) {
2974
+ const [a, i] = e.features.reduce(
2975
+ (h, c) => (lt(c) ? h[1].push(c) : wt(c) && h[0].push(c), h),
2976
+ [[], []]
2977
+ );
2978
+ return a.forEach((h) => this.add(h)), i.forEach((h) => this.add(h)), this.arrows.refreshLayer(), this;
2979
+ }
2980
+ switch (e.properties.type) {
2981
+ case "text":
2982
+ this.texts.add(e);
2983
+ break;
2984
+ default:
2985
+ this.arrows.add(e), this.loadLink(e);
2986
+ break;
2987
+ }
2988
+ return this;
2989
+ }
2990
+ /**
2991
+ * Remove an annotation or an array of annotations from the controller
2992
+ * @param annotation The annotation(s) to remove
2993
+ */
2994
+ remove(e) {
2995
+ return br(e) ? (e.features.forEach(
2996
+ (a) => this.remove(a)
2997
+ ), this) : (lt(e) ? (this.links.remove(e, "start"), this.links.remove(e, "end"), this.arrows.remove(e.id)) : this.texts.remove(e.id), this);
2998
+ }
2999
+ loadLink(e) {
3000
+ if (e.properties.link)
3001
+ for (const a of wr) {
3002
+ const i = e.properties.link[a];
3003
+ if (!i)
3004
+ continue;
3005
+ const h = this.getAnnotation(i.id);
3006
+ if (i.type === "text" && h)
3007
+ this.links.add(e, a, i.id, i.type, i.magnet);
3008
+ else if (i.type === "node") {
3009
+ const c = this.ogma.getNode(i.id);
3010
+ if (!c)
3011
+ continue;
3012
+ this.links.add(e, a, i.id, i.type, i.magnet);
3013
+ const g = c.getPosition(), m = c.getAttribute("radius") || 0, f = Ce(
3014
+ e,
3015
+ a === "start" ? "end" : "start"
3016
+ ), s = Pe(f, g, +m);
3017
+ Nt(e, a, s.x, s.y);
3018
+ }
3019
+ }
3020
+ }
3021
+ /**
3022
+ * Start adding an arrow (add it, and give control to the user)
3023
+ * @param x coord of the first point
3024
+ * @param y coord of the first point
3025
+ * @param arrow The arrow to add
3026
+ */
3027
+ startArrow(e, a, i) {
3028
+ this.cancelDrawing(), this.arrows.startDrawing(e, a, i);
3029
+ }
3030
+ /**
3031
+ * Start adding a text (add it, and give control to the user)
3032
+ * @param x coord of the top left point
3033
+ * @param y coord of the top left point
3034
+ * @param text The text to add
3035
+ */
3036
+ startText(e, a, i) {
3037
+ this.cancelDrawing(), this.texts.startDrawing(e, a, i);
3038
+ }
3039
+ /**
3040
+ * Cancel drawing on the current frame
3041
+ */
3042
+ cancelDrawing() {
3043
+ this.annotations.forEach((e) => e.cancelDrawing()), this.emit(rn);
3044
+ }
3045
+ /**
3046
+ * Update the style of the annotation with the given id
3047
+ * @param id The id of the annotation to update
3048
+ * @param style The new style
3049
+ */
3050
+ updateStyle(e, a) {
3051
+ const i = this.getAnnotations().features.find((h) => h.id === e);
3052
+ return i ? (lt(i) ? this.arrows.updateStyle(i, a) : wt(i) && this.texts.updateStyle(i, a), this.onUpdate(i), this) : this;
3053
+ }
3054
+ /**
3055
+ *
3056
+ * @returns the annotations in the controller
3057
+ */
3058
+ getAnnotations() {
3059
+ const e = {
3060
+ type: "FeatureCollection",
3061
+ features: []
3062
+ };
3063
+ return this.annotations.forEach((a) => {
3064
+ e.features = [...e.features, ...a.getElements()];
3065
+ }), e;
3066
+ }
3067
+ /**
3068
+ * Retrieve the annotation with the given id
3069
+ * @param id the id of the annotation to get
3070
+ * @returns The annotation with the given id
3071
+ */
3072
+ getAnnotation(e) {
3073
+ return this.getAnnotations().features.find((a) => a.id === e);
3074
+ }
3075
+ /**
3076
+ * Destroy the controller and its elements
3077
+ */
3078
+ destroy() {
3079
+ this.annotations.forEach((e) => e.destroy()), this.layer.destroy();
3080
+ }
3081
+ }
3082
+ const Sr = [8, 10, 12, 14, 16, 24, 32, 48, 64, 72], Ar = "none", Dr = "#333333", xn = [
3083
+ "#FFFFFF",
3084
+ "#F44E3B",
3085
+ "#FE9200",
3086
+ "#FCDC00",
3087
+ "#A4DD00",
3088
+ "#68CCCA",
3089
+ "#73D8FF",
3090
+ "#AEA1FF",
3091
+ "#1E88E5",
3092
+ "#333333",
3093
+ "#808080",
3094
+ "#cccccc"
3095
+ ], Sn = [
3096
+ "Roboto",
3097
+ "Helvetica Neue",
3098
+ "Helvetica",
3099
+ "Arial",
3100
+ "sans-serif",
3101
+ "Georgia, serif",
3102
+ "Menlo",
3103
+ "Monaco",
3104
+ "Consolas",
3105
+ "Courier New",
3106
+ "monospace"
3107
+ ].sort((p, e) => p.toLocaleLowerCase().localeCompare(e.toLocaleLowerCase())), pn = {
3108
+ head: "arrow",
3109
+ strokeColor: Dr,
3110
+ strokeWidth: 5
3111
+ }, gn = 0.25, yn = {
3112
+ font: "Roboto",
3113
+ fontSize: Sr[2],
3114
+ padding: Sr[2] * gn,
3115
+ color: Dr,
3116
+ strokeType: Ar,
3117
+ background: Ar
3118
+ };
3119
+ function mn(p) {
3120
+ return p.reduce((e, a) => e + a, 0) / p.length;
3121
+ }
3122
+ function An(p, e = 0, a = 1) {
3123
+ return e + (a - e) * p;
3124
+ }
3125
+ function En(p, e = 0, a = 1) {
3126
+ return (p - e) / (a - e);
3127
+ }
3128
+ function _n() {
3129
+ return _r(null);
3130
+ }
3131
+ const Fr = _r(
3132
+ void 0
3133
+ ), kn = () => zr(Fr), vn = (p, e) => {
3134
+ switch (e.type) {
3135
+ case "add":
3136
+ return {
3137
+ ...p,
3138
+ features: [...p.features, e.payload]
3139
+ };
3140
+ case "remove":
3141
+ return {
3142
+ ...p,
3143
+ features: p.features.filter((a) => a.id !== e.payload.id)
3144
+ };
3145
+ case "update":
3146
+ return {
3147
+ ...p,
3148
+ features: p.features.map(
3149
+ (a) => a.id === e.payload.id ? e.payload : a
3150
+ )
3151
+ };
3152
+ default:
3153
+ return p;
3154
+ }
3155
+ }, Tn = ({ children: p }) => {
3156
+ const e = Hr(), [a, i] = Nr(vn, {
3157
+ type: "FeatureCollection",
3158
+ features: []
3159
+ }), [h, c] = zt(null), [g, m] = zt(pn), [f, s] = zt(yn), [d, A] = zt(), [_, R] = zt(1), [P, E] = zt(1);
3160
+ return Je(() => {
3161
+ if (!e)
3162
+ return;
3163
+ const M = new dn(e, {
3164
+ minArrowHeight: 1
3165
+ }), j = mn(e.getNodes().getAttribute("radius")) / 5, k = _;
3166
+ return m({
3167
+ ...g,
3168
+ strokeWidth: (g.strokeWidth || 1) * k
3169
+ }), R(k), E(j), M.on("select", (N) => {
3170
+ lt(N) ? m({
3171
+ ...N.properties.style || {}
3172
+ }) : wt(N) && s({
3173
+ ...N.properties.style || {}
3174
+ }), c(N);
3175
+ }).on("unselect", () => {
3176
+ c(null);
3177
+ }), A(M), () => {
3178
+ d == null || d.destroy();
3179
+ };
3180
+ }, [e]), Je(() => {
3181
+ d && h && (h == null ? void 0 : h.properties.type) === "arrow" && d.updateStyle(h.id, g);
3182
+ }, [d, g, h]), Je(() => {
3183
+ d && h && (h == null ? void 0 : h.properties.type) === "text" && d.updateStyle(h.id, f);
3184
+ }, [d, f, h]), /* @__PURE__ */ Wr.jsx(
3185
+ Fr.Provider,
3186
+ {
3187
+ value: {
3188
+ annotations: a,
3189
+ updateAnnotations: i,
3190
+ currentAnnotation: h,
3191
+ setCurrentAnnotation: c,
3192
+ textStyle: f,
3193
+ setTextStyle: s,
3194
+ arrowStyle: g,
3195
+ setArrowStyle: m,
3196
+ arrowWidthFactor: _,
3197
+ setArrowWidthFactor: R,
3198
+ textSizeFactor: P,
3199
+ setTextSizeFactor: E,
3200
+ editor: d,
3201
+ setEditor: A
3202
+ },
3203
+ children: p
3204
+ }
3205
+ );
3206
+ };
3207
+ export {
3208
+ Fr as AnnotationsContext,
3209
+ Tn as AnnotationsContextProvider,
3210
+ Dr as BLACK,
3211
+ gn as RELATIVE_PADDING,
3212
+ Ar as TRANSPARENT,
3213
+ _n as createAnnotationsContext,
3214
+ pn as defaultArrowStyle,
3215
+ xn as defaultColors,
3216
+ yn as defaultTextStyle,
3217
+ Sr as fontSizes,
3218
+ Sn as fonts,
3219
+ An as interpolate,
3220
+ mn as mean,
3221
+ En as normalize,
3222
+ kn as useAnnotationsContext
3223
+ };