@linkurious/ogma-annotations 2.1.3 → 2.1.4

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 CHANGED
@@ -1,15 +1,15 @@
1
- var Kn = Object.defineProperty;
2
- var Vn = (i, e, t) => e in i ? Kn(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
- var m = (i, e, t) => Vn(i, typeof e != "symbol" ? e + "" : e, t);
4
- import { i as H, C as Dt, a as de, E as Bt, b as Yt, c as z, d as qt, e as vt, g as Zn, f as he, h as gn, S as q, j as Q, T as P, k as at, l as kt, m as te, n as Be, o as Jn, p as Qn, q as ue, r as ts, s as _, t as G, u as Z, v as J, w as pn, x as xe, y as es, z as ye, A as mn, N as ns, B as Lt, D as Sn, F as K, G as ss, H as Pt, I as fe, J as O, K as j, L as Xt, M as Tt, O as rt, P as Ee, Q as Ot, R as is, U as rs, V as os, W as as, X as cs, Y as ls, Z as ds, _ as hs, $ as nt, a0 as dt, a1 as us, a2 as Fn, a3 as $, a4 as et, a5 as yt, a6 as xs, a7 as fs, a8 as yn, a9 as En, aa as gs, ab as An, ac as ke, ad as Et, ae as Nn, af as Cn, ag as ps, ah as ms, ai as Ss, aj as Fs, ak as ys, al as Es, am as As, an as Ns } from "./Polygon-C9ZkyU-t.js";
5
- import { ao as Sa, ap as Fa, aq as ya, ar as Ea, as as Aa, at as Na, au as Ca, av as va, aw as Ma, ax as ba, ay as wa, az as Da, aA as Ba, aB as ka, aC as La, aD as Ta, aE as Oa, aF as Pa, aG as Ra, aH as Ha, aI as Ia, aJ as za, aK as _a, aL as Ua, aM as Wa, aN as $a, aO as Ya, aP as Xa, aQ as Ga, aR as ja, aS as qa, aS as Ka, aT as Va } from "./Polygon-C9ZkyU-t.js";
6
- import { Node as Cs, geometry as Gt } from "@linkurious/ogma";
7
- function vs(i) {
1
+ var Vn = Object.defineProperty;
2
+ var Zn = (i, e, t) => e in i ? Vn(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
+ var m = (i, e, t) => Zn(i, typeof e != "symbol" ? e + "" : e, t);
4
+ import { i as H, C as Dt, a as de, E as Bt, b as Yt, c as z, d as qt, e as yt, g as Jn, f as he, h as pn, S as q, j as Q, T as P, k as at, l as kt, m as te, n as ke, o as Qn, p as ts, q as ue, r as es, s as _, t as G, u as Z, v as J, w as mn, x as ye, y as xe, z as ns, A as Ee, B as Sn, N as ss, D as Lt, F as Fn, G as K, H as is, I as Pt, J as fe, K as O, L as j, M as Xt, O as Tt, P as rt, Q as Ae, R as Ot, U as rs, V as os, W as as, X as cs, Y as ls, Z as ds, _ as hs, $ as us, a0 as nt, a1 as dt, a2 as xs, a3 as yn, a4 as $, a5 as et, a6 as Et, a7 as fs, a8 as gs, a9 as En, aa as An, ab as ps, ac as Nn, ad as Le, ae as At, af as Cn, ag as vn, ah as ms, ai as Ss, aj as Fs, ak as ys, al as Es, am as As, an as Ns, ao as Cs } from "./Polygon-BmJ_q7qz.js";
5
+ import { ap as Fa, aq as ya, ar as Ea, as as Aa, at as Na, au as Ca, av as va, aw as Ma, ax as ba, ay as wa, az as Da, aA as Ba, aB as ka, aC as La, aD as Ta, aE as Oa, aF as Pa, aG as Ra, aH as Ha, aI as Ia, aJ as za, aK as _a, aL as Ua, aM as Wa, aN as $a, aO as Ya, aP as Xa, aQ as Ga, aR as ja, aS as qa, aT as Ka, aT as Va, aU as Za } from "./Polygon-BmJ_q7qz.js";
6
+ import { Node as vs, geometry as Gt } from "@linkurious/ogma";
7
+ function Ms(i) {
8
8
  return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
9
9
  }
10
- var ee = { exports: {} }, Le;
11
- function Ms() {
12
- return Le || (Le = 1, (function(i) {
10
+ var ee = { exports: {} }, Te;
11
+ function bs() {
12
+ return Te || (Te = 1, (function(i) {
13
13
  var e = Object.prototype.hasOwnProperty, t = "~";
14
14
  function n() {
15
15
  }
@@ -114,13 +114,13 @@ function Ms() {
114
114
  }, a.prototype.off = a.prototype.removeListener, a.prototype.addListener = a.prototype.on, a.prefixed = t, a.EventEmitter = a, i.exports = a;
115
115
  })(ee)), ee.exports;
116
116
  }
117
- var bs = Ms();
118
- const ws = /* @__PURE__ */ vs(bs);
119
- function Ds(i, e) {
117
+ var ws = bs();
118
+ const Ds = /* @__PURE__ */ Ms(ws);
119
+ function Bs(i, e) {
120
120
  const t = i[0] - e[0], n = i[1] - e[1];
121
121
  return t * t + n * n;
122
122
  }
123
- function Bs(i, e, t) {
123
+ function ks(i, e, t) {
124
124
  let n = e[0], s = e[1], r = t[0] - n, o = t[1] - s;
125
125
  if (r !== 0 || o !== 0) {
126
126
  const a = ((i[0] - n) * r + (i[1] - s) * o) / (r * r + o * o);
@@ -128,32 +128,32 @@ function Bs(i, e, t) {
128
128
  }
129
129
  return r = i[0] - n, o = i[1] - s, r * r + o * o;
130
130
  }
131
- function ks(i, e) {
131
+ function Ls(i, e) {
132
132
  let t = i[0];
133
133
  const n = [t];
134
134
  let s;
135
135
  for (let r = 1, o = i.length; r < o; r++)
136
- s = i[r], Ds(s, t) > e && (n.push(s), t = s);
136
+ s = i[r], Bs(s, t) > e && (n.push(s), t = s);
137
137
  return t !== s && n.push(s), n;
138
138
  }
139
139
  function ge(i, e, t, n, s) {
140
140
  let r = n, o = 0;
141
141
  for (let a = e + 1; a < t; a++) {
142
- const l = Bs(i[a], i[e], i[t]);
142
+ const l = ks(i[a], i[e], i[t]);
143
143
  l > r && (o = a, r = l);
144
144
  }
145
145
  r > n && (o - e > 1 && ge(i, e, o, n, s), s.push(i[o]), t - o > 1 && ge(i, o, t, n, s));
146
146
  }
147
- function Ls(i, e) {
147
+ function Ts(i, e) {
148
148
  const t = i.length - 1, n = [i[0]];
149
149
  return ge(i, 0, t, e, n), n.push(i[t]), n;
150
150
  }
151
- function Te(i, e, t) {
151
+ function Oe(i, e, t) {
152
152
  if (i.length <= 2) return i;
153
153
  const n = e !== void 0 ? e * e : 1;
154
- return i = t ? i : ks(i, n), i = Ls(i, n), i;
154
+ return i = t ? i : Ls(i, n), i = Ts(i, n), i;
155
155
  }
156
- function vn(i) {
156
+ function Mn(i) {
157
157
  if (i.geometry.bbox) return i.geometry.bbox;
158
158
  const e = i.geometry.coordinates[0];
159
159
  let t = 1 / 0, n = 1 / 0, s = -1 / 0, r = -1 / 0;
@@ -161,7 +161,7 @@ function vn(i) {
161
161
  o < t && (t = o), o > s && (s = o), a < n && (n = a), a > r && (r = a);
162
162
  return [t, n, s, r];
163
163
  }
164
- function Mn(i) {
164
+ function bn(i) {
165
165
  const e = i.geometry.coordinates[0];
166
166
  let t = 0, n = 0;
167
167
  const s = e.length - 1;
@@ -172,7 +172,7 @@ function Mn(i) {
172
172
  y: n / s
173
173
  };
174
174
  }
175
- function ca(i, e, t) {
175
+ function la(i, e, t) {
176
176
  const n = i.geometry.coordinates.map(
177
177
  (o) => o.map(([a, l]) => [a + e, l + t])
178
178
  ), s = i.geometry.bbox, r = s ? [s[0] + e, s[1] + t, s[2] + e, s[3] + t] : void 0;
@@ -185,14 +185,14 @@ function ca(i, e, t) {
185
185
  }
186
186
  };
187
187
  }
188
- function bn(i) {
188
+ function wn(i) {
189
189
  const e = i.geometry.coordinates[0];
190
190
  let t = 1 / 0, n = 1 / 0, s = -1 / 0, r = -1 / 0;
191
191
  for (const [o, a] of e)
192
192
  o < t && (t = o), o > s && (s = o), a < n && (n = a), a > r && (r = a);
193
193
  i.geometry.bbox = [t, n, s, r];
194
194
  }
195
- function la(i, e, t, n) {
195
+ function da(i, e, t, n) {
196
196
  const s = i.geometry.coordinates.map(
197
197
  (o) => o.map(([a, l]) => {
198
198
  const c = a - t, d = l - n;
@@ -205,41 +205,41 @@ function la(i, e, t, n) {
205
205
  coordinates: s
206
206
  }
207
207
  };
208
- return bn(r), r;
208
+ return wn(r), r;
209
209
  }
210
- const Oe = (i) => i.type === "FeatureCollection";
211
- function wn(i) {
210
+ const Pe = (i) => i.type === "FeatureCollection";
211
+ function Dn(i) {
212
212
  return /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(i.trim());
213
213
  }
214
- function Dn(i) {
214
+ function Bn(i) {
215
215
  return /^rgb\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*\)$/.test(i.trim());
216
216
  }
217
- function Bn(i) {
217
+ function kn(i) {
218
218
  return /^rgba\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*[0-9.]+\s*\)$/.test(
219
219
  i.trim()
220
220
  );
221
221
  }
222
- function Ts(i) {
222
+ function Os(i) {
223
223
  const e = i.trim();
224
- return e === "transparent" || e === "none" || wn(e) || Dn(e) || Bn(e);
225
- }
226
- function da(i) {
227
- if (Ts(i)) return i;
228
- throw new Error(`Invalid color format: ${i}`);
224
+ return e === "transparent" || e === "none" || Dn(e) || Bn(e) || kn(e);
229
225
  }
230
226
  function ha(i) {
231
- if (wn(i)) return i;
232
- throw new Error(`Invalid hex color format: ${i}`);
227
+ if (Os(i)) return i;
228
+ throw new Error(`Invalid color format: ${i}`);
233
229
  }
234
230
  function ua(i) {
235
231
  if (Dn(i)) return i;
236
- throw new Error(`Invalid RGB color format: ${i}`);
232
+ throw new Error(`Invalid hex color format: ${i}`);
237
233
  }
238
234
  function xa(i) {
239
235
  if (Bn(i)) return i;
236
+ throw new Error(`Invalid RGB color format: ${i}`);
237
+ }
238
+ function fa(i) {
239
+ if (kn(i)) return i;
240
240
  throw new Error(`Invalid RGBA color format: ${i}`);
241
241
  }
242
- class Os {
242
+ class Ps {
243
243
  constructor(e) {
244
244
  m(this, "previousZoom", -1);
245
245
  this.store = e;
@@ -294,28 +294,28 @@ class Os {
294
294
  return Math.max(0.1, Math.min(1, s));
295
295
  }
296
296
  }
297
- const Ae = "ogma-annotation-link";
297
+ const Ne = "ogma-annotation-link";
298
298
  function wt(i) {
299
299
  let e = i;
300
300
  for (; e; ) {
301
- if (e.classList && e.classList.contains(Ae))
301
+ if (e.classList && e.classList.contains(Ne))
302
302
  return !0;
303
303
  e = e.parentElement;
304
304
  }
305
305
  return !1;
306
306
  }
307
- const Ps = "(https?://[^\\s)<]+)";
308
- function kn() {
309
- return new RegExp(Ps, "g");
310
- }
311
- const Rs = "\\[([^\\]\\n]+)\\]\\((https?://[^\\s)<]+)\\)";
312
- function Hs() {
307
+ const Rs = "(https?://[^\\s)<]+)";
308
+ function Ln() {
313
309
  return new RegExp(Rs, "g");
314
310
  }
315
- function Is(i) {
311
+ const Hs = "\\[([^\\]\\n]+)\\]\\((https?://[^\\s)<]+)\\)";
312
+ function Is() {
313
+ return new RegExp(Hs, "g");
314
+ }
315
+ function zs(i) {
316
316
  return i.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
317
317
  }
318
- function zs(i, e, t, n, s, r) {
318
+ function _s(i, e, t, n, s, r) {
319
319
  const o = Math.min(n / 2, s / 2), a = Math.min(r, o);
320
320
  i.beginPath(), i.moveTo(e + a, t), i.lineTo(e + n - a, t), i.quadraticCurveTo(e + n, t, e + n, t + a), i.lineTo(e + n, t + s - a), i.quadraticCurveTo(e + n, t + s, e + n - a, t + s), i.lineTo(e + a, t + s), i.quadraticCurveTo(e, t + s, e, t + s - a), i.lineTo(e, t + a), i.quadraticCurveTo(e, t, e + a, t), i.closePath();
321
321
  }
@@ -411,11 +411,11 @@ class Kt extends EventTarget {
411
411
  return this.isActive() ? (this.restorePanning(), this.dragging = !1, !0) : !1;
412
412
  }
413
413
  clientToCanvas(t) {
414
- const n = this.ogma, s = vt(t, n.getContainer());
414
+ const n = this.ogma, s = yt(t, n.getContainer());
415
415
  return n.view.screenToGraphCoordinates(s);
416
416
  }
417
417
  setAnnotation(t) {
418
- const n = this.ogma.getContainer(), s = n ? Zn() || n : null;
418
+ const n = this.ogma.getContainer(), s = n ? Jn() || n : null;
419
419
  n && s && (s.removeEventListener("mousemove", this.handleMouseMove), s.removeEventListener("mouseup", this.handleMouseUp), n.removeEventListener("mousedown", this.handleMouseDown, !0), s.removeEventListener("click", this.onClick, !0)), this.annotation = t ? t.id : null, this.annotation !== null ? n && s && (s.addEventListener("mousemove", this.handleMouseMove), s.addEventListener("mouseup", this.handleMouseUp, !1), n.addEventListener("mousedown", this.handleMouseDown, !0), s.addEventListener("click", this.onClick, !0)) : (this.clearDragState(), this.setCursor(z.default));
420
420
  }
421
421
  /** Is `id` the annotation this handler is currently tracking? */
@@ -446,8 +446,8 @@ class Kt extends EventTarget {
446
446
  return this.annotation !== null;
447
447
  }
448
448
  }
449
- const _s = 5;
450
- class Us extends Kt {
449
+ const Us = 5;
450
+ class Ws extends Kt {
451
451
  constructor(t, n, s, r, o, a, l) {
452
452
  super(t, n);
453
453
  m(this, "links");
@@ -468,7 +468,7 @@ class Us extends Kt {
468
468
  if (!s || !Q(s)) return;
469
469
  const r = s.geometry.coordinates[0], o = s.geometry.coordinates[1], a = o[0] - this.startX, l = o[1] - this.startY, c = Math.sqrt(a * a + l * l);
470
470
  let d, h;
471
- c < _s ? (d = this.startX + this.offsetX, h = this.startY + this.offsetY) : (d = o[0], h = o[1]);
471
+ c < Us ? (d = this.startX + this.offsetX, h = this.startY + this.offsetY) : (d = o[0], h = o[1]);
472
472
  const u = this.comment;
473
473
  u.geometry.coordinates = [d, h];
474
474
  const x = u.properties.height, f = t.zoom, p = x / f, g = d, E = h + p * 0.5;
@@ -535,7 +535,7 @@ class Us extends Kt {
535
535
  var o;
536
536
  this.startX = n, this.startY = s;
537
537
  const r = he(n, s, n, s, {
538
- ...gn,
538
+ ...pn,
539
539
  head: "arrow",
540
540
  ...(o = this.arrowStyle) == null ? void 0 : o.style
541
541
  });
@@ -555,7 +555,7 @@ class Us extends Kt {
555
555
  }, this.links.add(t, q, r.id, r.type, r.magnet));
556
556
  }
557
557
  }
558
- function Ws(i, e, t, n, s) {
558
+ function $s(i, e, t, n, s) {
559
559
  const { width: r, height: o } = n.view.getSize(), a = 8, l = 16, c = a * l, d = { width: 150, height: 50 }, h = d.width, u = d.height, x = Math.max(r, o), f = 200, p = {
560
560
  minX: 0,
561
561
  minY: 0,
@@ -578,7 +578,7 @@ function Ws(i, e, t, n, s) {
578
578
  }
579
579
  return n.view.screenToGraphCoordinates({ x: r / 2, y: o / 2 });
580
580
  }
581
- const Pe = 160, $s = {
581
+ const Re = 160, Ys = {
582
582
  font: "IBM Plex Sans",
583
583
  fontSize: 18,
584
584
  color: "#4A3B00",
@@ -596,7 +596,7 @@ const Pe = 160, $s = {
596
596
  // TextStyle.scaleFontOnResize/fontScale) instead of rewrapping the text.
597
597
  scaleFontOnResize: !0
598
598
  };
599
- class Ys {
599
+ class Xs {
600
600
  constructor(e, t, n, s, r, o, a) {
601
601
  m(this, "ogma");
602
602
  m(this, "store");
@@ -676,7 +676,7 @@ class Ys {
676
676
  */
677
677
  enableBoxDrawing(e) {
678
678
  return this.enableDrawingMode((t, n) => {
679
- const s = Be(t, n, 0, 0, e);
679
+ const s = ke(t, n, 0, 0, e);
680
680
  this.startBox(t, n, s);
681
681
  });
682
682
  }
@@ -687,7 +687,7 @@ class Ys {
687
687
  */
688
688
  enablePolygonDrawing(e) {
689
689
  return this.enableDrawingMode((t, n) => {
690
- const s = Jn([[[t, n]]], { style: e });
690
+ const s = Qn([[[t, n]]], { style: e });
691
691
  this.startPolygon(t, n, s);
692
692
  });
693
693
  }
@@ -704,10 +704,10 @@ class Ys {
704
704
  return this.enableDrawingMode((t, n) => {
705
705
  let s = e.offsetX, r = e.offsetY;
706
706
  if (s === void 0 && r === void 0) {
707
- const a = Ws(t, n, this.index, this.ogma);
707
+ const a = $s(t, n, this.index, this.ogma);
708
708
  s = a.x, r = a.y;
709
709
  }
710
- const o = Qn(t, n, "", e == null ? void 0 : e.commentStyle);
710
+ const o = ts(t, n, "", e == null ? void 0 : e.commentStyle);
711
711
  this.startComment(t, n, o, {
712
712
  ...e,
713
713
  offsetX: s,
@@ -738,13 +738,13 @@ class Ys {
738
738
  startStickyNote(e, t, n) {
739
739
  this.editor.getActiveHandler() && this.editor.getActiveHandler().stopEditing(), this.control.cancelDrawing();
740
740
  const s = te(e, t, 0, 0, "", {
741
- ...$s,
741
+ ...Ys,
742
742
  ...n
743
743
  });
744
744
  return this.store.getState().batchUpdate(() => {
745
745
  this.store.setState({ drawingFeature: s.id }), this.control.add(s), this.control.select(s.id);
746
746
  }), this.interactions.suppressClicksTemporarily(200), this.editor.getActiveHandler().startDrawing(s.id, e, t, {
747
- defaultSize: { width: Pe, height: Pe },
747
+ defaultSize: { width: Re, height: Re },
748
748
  // Unlike box/text, sticky notes are for writing - drop into editing
749
749
  // whether the user clicked (default size) or dragged one out.
750
750
  autoEditAfterDrag: !0
@@ -760,12 +760,12 @@ class Ys {
760
760
  const t = this.ogma.getContainer();
761
761
  if (!t) return this.control;
762
762
  const n = (a) => {
763
- const { x: l, y: c } = this.ogma.view.screenToGraphCoordinates(a), d = e.properties.width, h = e.properties.height;
763
+ const l = yt(a, t), { x: c, y: d } = this.ogma.view.screenToGraphCoordinates(l), h = e.properties.width, u = e.properties.height;
764
764
  this.store.getState().applyLiveUpdate(e.id, {
765
765
  geometry: {
766
766
  ...e.geometry,
767
- coordinates: [l, c],
768
- bbox: [l - d / 2, c - h / 2, l + d / 2, c + h / 2]
767
+ coordinates: [c, d],
768
+ bbox: [c - h / 2, d - u / 2, c + h / 2, d + u / 2]
769
769
  }
770
770
  });
771
771
  }, s = (a) => {
@@ -789,7 +789,7 @@ class Ys {
789
789
  this.editor.getActiveHandler() && this.editor.getActiveHandler().stopEditing(), this.control.cancelDrawing(), this.store.getState().batchUpdate(() => {
790
790
  this.store.setState({ drawingFeature: n.id });
791
791
  }), this.interactions.suppressClicksTemporarily(200);
792
- const r = new Us(
792
+ const r = new Ws(
793
793
  this.ogma,
794
794
  this.store,
795
795
  this.links,
@@ -804,7 +804,7 @@ class Ys {
804
804
  return this.control.on(ue, o), r.startDrawing(n.id, e, t), this.control;
805
805
  }
806
806
  startBox(e, t, n) {
807
- return n || (n = Be(e, t)), this.store.getState().batchUpdate(() => {
807
+ return n || (n = ke(e, t)), this.store.getState().batchUpdate(() => {
808
808
  this.store.setState({ drawingFeature: n.id }), this.control.add(n), this.control.select(n.id);
809
809
  }), this.interactions.suppressClicksTemporarily(200), this.editor.getActiveHandler().startDrawing(n.id, e, t), this.control;
810
810
  }
@@ -824,7 +824,7 @@ class Ys {
824
824
  }), this.interactions.suppressClicksTemporarily(200), this.editor.getActiveHandler().startDrawing(n.id, e, t), this.control;
825
825
  }
826
826
  }
827
- class Xs {
827
+ class Gs {
828
828
  constructor(e, t) {
829
829
  this.store = e, this.links = t;
830
830
  }
@@ -863,7 +863,7 @@ class Xs {
863
863
  this.store.temporal.getState().clear();
864
864
  }
865
865
  }
866
- class Gs {
866
+ class js {
867
867
  constructor(e) {
868
868
  this.store = e;
869
869
  }
@@ -912,7 +912,7 @@ class Gs {
912
912
  return t ? e.features[t] : null;
913
913
  }
914
914
  }
915
- class js {
915
+ class qs {
916
916
  constructor(e) {
917
917
  this.store = e;
918
918
  }
@@ -921,10 +921,10 @@ class js {
921
921
  * @param annotation The annotation to add
922
922
  */
923
923
  add(e) {
924
- if (Oe(e))
924
+ if (Pe(e))
925
925
  for (const t of e.features) this.add(t);
926
926
  else {
927
- const t = ts(e);
927
+ const t = es(e);
928
928
  this.store.getState().addFeature(t);
929
929
  }
930
930
  }
@@ -933,7 +933,7 @@ class js {
933
933
  * @param annotation The annotation(s) to remove
934
934
  */
935
935
  remove(e) {
936
- if (Oe(e))
936
+ if (Pe(e))
937
937
  for (const t of e.features) this.remove(t);
938
938
  else
939
939
  this.store.getState().removeFeature(e.id);
@@ -963,7 +963,7 @@ class js {
963
963
  * @param style The new style
964
964
  */
965
965
  updateStyle(e, t) {
966
- const n = this.store.getState().getFeature(e);
966
+ const n = this.store.getState().getMergedFeature(e);
967
967
  n && this.store.getState().updateFeature(e, {
968
968
  id: e,
969
969
  properties: {
@@ -1019,7 +1019,7 @@ class js {
1019
1019
  */
1020
1020
  update(e) {
1021
1021
  var s;
1022
- const t = this.store.getState(), n = t.getFeature(e.id);
1022
+ const t = this.store.getState(), n = t.getMergedFeature(e.id);
1023
1023
  n && t.updateFeature(e.id, {
1024
1024
  ...n,
1025
1025
  ...e,
@@ -1075,12 +1075,12 @@ class js {
1075
1075
  }
1076
1076
  }
1077
1077
  }
1078
- function qs(i) {
1078
+ function Ks(i) {
1079
1079
  var t, n;
1080
1080
  const e = i.properties.link;
1081
1081
  return e ? ((t = e.start) == null ? void 0 : t.type) === P.COMMENT || ((n = e.end) == null ? void 0 : n.type) === P.COMMENT : !1;
1082
1082
  }
1083
- function Ks(i) {
1083
+ function Vs(i) {
1084
1084
  var t, n;
1085
1085
  const e = i.properties.link;
1086
1086
  if (e) {
@@ -1088,21 +1088,21 @@ function Ks(i) {
1088
1088
  if (((n = e.end) == null ? void 0 : n.type) === P.COMMENT) return e.end.id;
1089
1089
  }
1090
1090
  }
1091
- function Vs(i) {
1091
+ function Zs(i) {
1092
1092
  var e, t;
1093
1093
  return ((t = (e = i.properties.link) == null ? void 0 : e.start) == null ? void 0 : t.type) !== P.COMMENT;
1094
1094
  }
1095
- function fa(i) {
1095
+ function ga(i) {
1096
1096
  return !0;
1097
1097
  }
1098
- function Zs(i, e) {
1098
+ function Js(i, e) {
1099
1099
  const t = /* @__PURE__ */ new Set([e]), n = i[e];
1100
1100
  return n && (H(n) || _(n)) && Object.values(i).forEach((s) => {
1101
1101
  var r, o, a, l;
1102
1102
  Q(s) && (((o = (r = s.properties.link) == null ? void 0 : r.end) == null ? void 0 : o.id) === e || ((l = (a = s.properties.link) == null ? void 0 : a.start) == null ? void 0 : l.id) === e) && t.add(s.id);
1103
1103
  }), t;
1104
1104
  }
1105
- function Js(i, e) {
1105
+ function Qs(i, e) {
1106
1106
  var r, o, a, l;
1107
1107
  const t = i[e];
1108
1108
  if (!t || !Q(t)) return null;
@@ -1114,14 +1114,14 @@ function Js(i, e) {
1114
1114
  }
1115
1115
  ) ? null : n : null;
1116
1116
  }
1117
- function Ne(i, e, t, n, s = !1) {
1117
+ function Ce(i, e, t, n, s = !1) {
1118
1118
  const r = i.getState(), o = {};
1119
1119
  pe(r, e, t, n, s, o);
1120
1120
  for (const a of r.selectedFeatures)
1121
1121
  a !== t && pe(r, e, a, n, !1, o);
1122
1122
  r.applyLiveUpdates(o);
1123
1123
  }
1124
- function Qs(i) {
1124
+ function ti(i) {
1125
1125
  return i !== P.NODE && i !== P.EDGE;
1126
1126
  }
1127
1127
  function pe(i, e, t, n, s, r) {
@@ -1131,7 +1131,7 @@ function pe(i, e, t, n, s, r) {
1131
1131
  if (s) {
1132
1132
  const c = o.properties.link || {};
1133
1133
  for (const d of [c.start, c.end])
1134
- d && Qs(d.type) && pe(i, e, d.id, n, !1, r);
1134
+ d && ti(d.type) && pe(i, e, d.id, n, !1, r);
1135
1135
  }
1136
1136
  const l = o.geometry.coordinates;
1137
1137
  r[t] = {
@@ -1145,10 +1145,10 @@ function pe(i, e, t, n, s, r) {
1145
1145
  };
1146
1146
  return;
1147
1147
  }
1148
- const a = ti(o, n);
1148
+ const a = ei(o, n);
1149
1149
  a && (r[t] = a, e.updateLinkedArrowsDuringDrag(t, n, r));
1150
1150
  }
1151
- function ti(i, e) {
1151
+ function ei(i, e) {
1152
1152
  if (_(i) || G(i) || H(i)) {
1153
1153
  const t = Z(i);
1154
1154
  return {
@@ -1171,7 +1171,7 @@ function ti(i, e) {
1171
1171
  }
1172
1172
  return null;
1173
1173
  }
1174
- class ei extends Kt {
1174
+ class ni extends Kt {
1175
1175
  constructor(t, n, s, r) {
1176
1176
  super(t, n);
1177
1177
  m(this, "snapping");
@@ -1180,12 +1180,12 @@ class ei extends Kt {
1180
1180
  this.snapping = s, this.links = r;
1181
1181
  }
1182
1182
  detectHandle(t) {
1183
- const n = this.getAnnotation(), s = this.clientToCanvas(t), r = ye, o = n.geometry.coordinates[0], a = n.geometry.coordinates[1], l = Math.sqrt(
1183
+ const n = this.getAnnotation(), s = this.clientToCanvas(t), r = Ee, o = n.geometry.coordinates[0], a = n.geometry.coordinates[1], l = Math.sqrt(
1184
1184
  Math.pow(s.x - o[0], 2) + Math.pow(s.y - o[1], 2)
1185
1185
  ), c = Math.sqrt(
1186
1186
  Math.pow(s.x - a[0], 2) + Math.pow(s.y - a[1], 2)
1187
1187
  );
1188
- l < r ? this.grabHandle("start", o[0], o[1]) : c < r ? this.grabHandle("end", a[0], a[1]) : pn(n, s, r) ? (this.setCursor(z.grab), this.hoveredHandle = {
1188
+ l < r ? this.grabHandle("start", o[0], o[1]) : c < r ? this.grabHandle("end", a[0], a[1]) : mn(n, s, r) ? (this.setCursor(z.grab), this.hoveredHandle = {
1189
1189
  type: "body",
1190
1190
  point: s
1191
1191
  }, this.store.setState({ hoveredHandle: 2, hoveredFeature: this.annotation })) : (this.store.setState({ hoveredHandle: -1, hoveredFeature: null }), this.hoveredHandle = void 0);
@@ -1209,7 +1209,7 @@ class ei extends Kt {
1209
1209
  }), c = [...s.geometry.coordinates];
1210
1210
  if (n.type === "body") {
1211
1211
  const h = a.x - n.point.x, u = a.y - n.point.y;
1212
- Ne(this.store, this.links, s.id, { x: h, y: u }, !0), this.dispatchEvent(l);
1212
+ Ce(this.store, this.links, s.id, { x: h, y: u }, !0), this.dispatchEvent(l);
1213
1213
  return;
1214
1214
  } else n.type === "start" ? (c[0] = [a.x, a.y], this.snap && (r.start = {
1215
1215
  side: n.type,
@@ -1234,7 +1234,7 @@ class ei extends Kt {
1234
1234
  onDragStart(t) {
1235
1235
  if (!super.onDragStart(t)) return !1;
1236
1236
  const n = this.getAnnotation(), s = this.hoveredHandle;
1237
- return s.type === "end" && !1 || s.type === "start" && !Vs(n) ? (this.clearDragState(), !1) : (this.store.getState().startLiveUpdate([this.annotation]), !0);
1237
+ return s.type === "end" && !1 || s.type === "start" && !Zs(n) ? (this.clearDragState(), !1) : (this.store.getState().startLiveUpdate([this.annotation]), !0);
1238
1238
  }
1239
1239
  onDragEnd(t) {
1240
1240
  var r, o, a, l;
@@ -1328,7 +1328,10 @@ class ei extends Kt {
1328
1328
  this.annotation = t;
1329
1329
  const r = this.getAnnotation();
1330
1330
  this.snapDrawingStart(r, n, s), this.grabHandle("end", n, s), this.dragging = !0, this.dragStartPoint = { x: n, y: s };
1331
- const o = this.ogma.view.graphToScreenCoordinates({ x: n, y: s });
1331
+ const o = ye(
1332
+ this.ogma.view.graphToScreenCoordinates({ x: n, y: s }),
1333
+ this.ogma.getContainer()
1334
+ );
1332
1335
  this.onDragStart({ clientX: o.x, clientY: o.y });
1333
1336
  }
1334
1337
  link(t, n, s) {
@@ -1339,7 +1342,7 @@ class ei extends Kt {
1339
1342
  let r = xe(t, s);
1340
1343
  const o = t.properties.link || {};
1341
1344
  let a = null;
1342
- if (n instanceof Cs)
1345
+ if (n instanceof vs)
1343
1346
  r = n.getPosition(), a = this.snapping.snapToNodes(r, n.toList());
1344
1347
  else {
1345
1348
  const l = this.store.getState().getFeature(n);
@@ -1348,7 +1351,7 @@ class ei extends Kt {
1348
1351
  if (_(l) || G(l))
1349
1352
  r = Z(l), a = this.snapping.snapToText(r, [l]);
1350
1353
  else if (J(l))
1351
- r = Mn(l), a = this.snapping.snapToPolygon(r, [l]);
1354
+ r = bn(l), a = this.snapping.snapToPolygon(r, [l]);
1352
1355
  else
1353
1356
  throw new Error(
1354
1357
  `Cannot link arrow to annotation of type ${l.properties.type}`
@@ -1359,7 +1362,7 @@ class ei extends Kt {
1359
1362
  id: a.id,
1360
1363
  type: a.type,
1361
1364
  magnet: a.magnet
1362
- }, this.links.add(t, s, a.id, a.type, a.magnet), es(t, s, r.x, r.y), this.store.getState().updateFeature(t.id, {
1365
+ }, this.links.add(t, s, a.id, a.type, a.magnet), ns(t, s, r.x, r.y), this.store.getState().updateFeature(t.id, {
1363
1366
  properties: { ...t.properties, link: o },
1364
1367
  geometry: {
1365
1368
  type: t.geometry.type,
@@ -1368,8 +1371,8 @@ class ei extends Kt {
1368
1371
  }));
1369
1372
  }
1370
1373
  }
1371
- const ni = -2;
1372
- class si extends Kt {
1374
+ const si = -2;
1375
+ class ii extends Kt {
1373
1376
  // Graph units
1374
1377
  constructor(t, n, s) {
1375
1378
  super(t, n);
@@ -1397,7 +1400,12 @@ class si extends Kt {
1397
1400
  const r = this.store.getState();
1398
1401
  r.startLiveUpdate([t]), r.setDrawingPoints([]);
1399
1402
  const o = this.ogma.view.graphToScreenCoordinates({ x: n, y: s });
1400
- return this.dragStartPoint = o, this.disablePanning(), this.onDragStart({ clientX: o.x, clientY: o.y }), this;
1403
+ this.dragStartPoint = o, this.disablePanning();
1404
+ const a = ye(o, this.ogma.getContainer());
1405
+ return this.onDragStart({
1406
+ clientX: a.x,
1407
+ clientY: a.y
1408
+ }), this;
1401
1409
  }
1402
1410
  /**
1403
1411
  * Cancel drawing mode
@@ -1412,7 +1420,7 @@ class si extends Kt {
1412
1420
  detectHandle(t, n = 1) {
1413
1421
  const s = this.getAnnotation();
1414
1422
  if (!s) return;
1415
- const r = this.clientToCanvas(t), o = ye / n, a = s.geometry.coordinates[0];
1423
+ const r = this.clientToCanvas(t), o = Ee / n, a = s.geometry.coordinates[0];
1416
1424
  for (let l = 0; l < a.length - 1; l++) {
1417
1425
  const [c, d] = a[l];
1418
1426
  if (Math.sqrt(
@@ -1422,13 +1430,13 @@ class si extends Kt {
1422
1430
  return;
1423
1431
  }
1424
1432
  }
1425
- mn(s, r, o) ? (this.setCursor(z.grab), this.hoveredHandle = {
1433
+ Sn(s, r, o) ? (this.setCursor(z.grab), this.hoveredHandle = {
1426
1434
  type: "body",
1427
1435
  point: r
1428
1436
  }, this.store.setState({
1429
- hoveredHandle: ni,
1437
+ hoveredHandle: si,
1430
1438
  hoveredFeature: this.annotation
1431
- })) : (this.store.setState({ hoveredHandle: ns, hoveredFeature: null }), this.hoveredHandle = void 0);
1439
+ })) : (this.store.setState({ hoveredHandle: ss, hoveredFeature: null }), this.hoveredHandle = void 0);
1432
1440
  }
1433
1441
  grabHandle(t, n, s, r) {
1434
1442
  this.setCursor(t === "vertex" ? z.pointer : z.grab), this.hoveredHandle = {
@@ -1470,7 +1478,7 @@ class si extends Kt {
1470
1478
  x[0]
1471
1479
  ];
1472
1480
  l.setDrawingPoints(f);
1473
- const p = Te(
1481
+ const p = Oe(
1474
1482
  f,
1475
1483
  // Exclude closing point
1476
1484
  this.simplificationTolerance,
@@ -1489,7 +1497,7 @@ class si extends Kt {
1489
1497
  const n = this.clientToCanvas(t), s = n.x - this.dragStartPoint.x, r = n.y - this.dragStartPoint.y, o = this.getAnnotation();
1490
1498
  if (o) {
1491
1499
  if (this.hoveredHandle.type === "body")
1492
- Ne(this.store, this.links, o.id, { x: s, y: r });
1500
+ Ce(this.store, this.links, o.id, { x: s, y: r });
1493
1501
  else if (this.hoveredHandle.type === "vertex" && this.hoveredHandle.vertexIndex !== void 0) {
1494
1502
  const a = o.geometry.coordinates[0].map((c, d) => d === this.hoveredHandle.vertexIndex ? [
1495
1503
  this.hoveredHandle.point.x + s,
@@ -1504,7 +1512,7 @@ class si extends Kt {
1504
1512
  coordinates: [a]
1505
1513
  }
1506
1514
  };
1507
- bn(l), this.store.getState().applyLiveUpdate(o.id, l), this.links.snapLinkedArrowsDuringDrag(o.id);
1515
+ wn(l), this.store.getState().applyLiveUpdate(o.id, l), this.links.snapLinkedArrowsDuringDrag(o.id);
1508
1516
  }
1509
1517
  this.dispatchEvent(new Event(qt));
1510
1518
  }
@@ -1516,7 +1524,7 @@ class si extends Kt {
1516
1524
  const r = n.drawingPoints;
1517
1525
  if (r.length < 3) this.cancelDrawing();
1518
1526
  else {
1519
- const o = Te(
1527
+ const o = Oe(
1520
1528
  r.slice(1, -1),
1521
1529
  // Exclude closing point
1522
1530
  this.simplificationTolerance,
@@ -1529,7 +1537,7 @@ class si extends Kt {
1529
1537
  }
1530
1538
  };
1531
1539
  Lt(a), this.store.getState().applyLiveUpdate(s.id, a), this.store.setState({ drawingFeature: null }), this.commitChange(), this.isDrawingMode = !1, this.dragging = !1, this.restorePanning(), this.dispatchEvent(
1532
- new CustomEvent(Sn, { detail: a })
1540
+ new CustomEvent(Fn, { detail: a })
1533
1541
  );
1534
1542
  }
1535
1543
  }
@@ -1542,7 +1550,7 @@ class si extends Kt {
1542
1550
  return this.store.getState().getFeature(this.annotation);
1543
1551
  }
1544
1552
  }
1545
- const ii = [
1553
+ const ri = [
1546
1554
  "BN",
1547
1555
  "BN",
1548
1556
  "BN",
@@ -1799,7 +1807,7 @@ const ii = [
1799
1807
  "L",
1800
1808
  "L",
1801
1809
  "L"
1802
- ], Re = [
1810
+ ], He = [
1803
1811
  [697, 698, "ON"],
1804
1812
  [706, 719, "ON"],
1805
1813
  [722, 735, "ON"],
@@ -2515,12 +2523,12 @@ const ii = [
2515
2523
  [1048574, 1048575, "BN"],
2516
2524
  [1114110, 1114111, "BN"]
2517
2525
  ];
2518
- function ri(i) {
2526
+ function oi(i) {
2519
2527
  if (i <= 255)
2520
- return ii[i];
2521
- let e = 0, t = Re.length - 1;
2528
+ return ri[i];
2529
+ let e = 0, t = He.length - 1;
2522
2530
  for (; e <= t; ) {
2523
- const n = e + t >> 1, s = Re[n];
2531
+ const n = e + t >> 1, s = He[n];
2524
2532
  if (i < s[0]) {
2525
2533
  t = n - 1;
2526
2534
  continue;
@@ -2533,7 +2541,7 @@ function ri(i) {
2533
2541
  }
2534
2542
  return "L";
2535
2543
  }
2536
- function oi(i) {
2544
+ function ai(i) {
2537
2545
  const e = i.length;
2538
2546
  if (e === 0)
2539
2547
  return null;
@@ -2546,7 +2554,7 @@ function oi(i) {
2546
2554
  const f = i.charCodeAt(c + 1);
2547
2555
  f >= 56320 && f <= 57343 && (h = (d - 55296 << 10) + (f - 56320) + 65536, u = 2);
2548
2556
  }
2549
- const x = ri(h);
2557
+ const x = oi(h);
2550
2558
  (x === "R" || x === "AL" || x === "AN") && (n = !0);
2551
2559
  for (let f = 0; f < u; f++)
2552
2560
  t[c + f] = x;
@@ -2620,8 +2628,8 @@ function oi(i) {
2620
2628
  }
2621
2629
  return r;
2622
2630
  }
2623
- function ai(i, e) {
2624
- const t = oi(i);
2631
+ function ci(i, e) {
2632
+ const t = ai(i);
2625
2633
  if (t === null)
2626
2634
  return null;
2627
2635
  const n = new Int8Array(e.length);
@@ -2629,31 +2637,31 @@ function ai(i, e) {
2629
2637
  n[s] = t[e[s]];
2630
2638
  return n;
2631
2639
  }
2632
- const ci = /[ \t\n\r\f]+/g, li = /[\t\n\r\f]| {2,}|^ | $/;
2633
- function di(i) {
2640
+ const li = /[ \t\n\r\f]+/g, di = /[\t\n\r\f]| {2,}|^ | $/;
2641
+ function hi(i) {
2634
2642
  const e = i ?? "normal";
2635
2643
  return e === "pre-wrap" ? { mode: e, preserveOrdinarySpaces: !0, preserveHardBreaks: !0 } : { mode: e, preserveOrdinarySpaces: !1, preserveHardBreaks: !1 };
2636
2644
  }
2637
- function hi(i) {
2638
- if (!li.test(i))
2645
+ function ui(i) {
2646
+ if (!di.test(i))
2639
2647
  return i;
2640
- let e = i.replace(ci, " ");
2648
+ let e = i.replace(li, " ");
2641
2649
  return e.charCodeAt(0) === 32 && (e = e.slice(1)), e.length > 0 && e.charCodeAt(e.length - 1) === 32 && (e = e.slice(0, -1)), e;
2642
2650
  }
2643
- function ui(i) {
2651
+ function xi(i) {
2644
2652
  return /[\r\f]/.test(i) ? i.replace(/\r\n/g, `
2645
2653
  `).replace(/[\r\f]/g, `
2646
2654
  `) : i;
2647
2655
  }
2648
- let ne = null, xi;
2649
- function fi() {
2650
- return ne === null && (ne = new Intl.Segmenter(xi, { granularity: "word" })), ne;
2651
- }
2652
- const gi = new RegExp("\\p{Script=Arabic}", "u"), ut = new RegExp("\\p{M}", "u"), Ce = new RegExp("\\p{Nd}", "u");
2653
- function He(i) {
2654
- return gi.test(i);
2656
+ let ne = null, fi;
2657
+ function gi() {
2658
+ return ne === null && (ne = new Intl.Segmenter(fi, { granularity: "word" })), ne;
2655
2659
  }
2660
+ const pi = new RegExp("\\p{Script=Arabic}", "u"), ut = new RegExp("\\p{M}", "u"), ve = new RegExp("\\p{Nd}", "u");
2656
2661
  function Ie(i) {
2662
+ return pi.test(i);
2663
+ }
2664
+ function ze(i) {
2657
2665
  return i >= 19968 && i <= 40959 || i >= 13312 && i <= 19903 || i >= 131072 && i <= 173791 || i >= 173824 && i <= 177983 || i >= 177984 && i <= 178207 || i >= 178208 && i <= 183983 || i >= 183984 && i <= 191471 || i >= 191472 && i <= 192093 || i >= 194560 && i <= 195103 || i >= 196608 && i <= 201551 || i >= 201552 && i <= 205743 || i >= 205744 && i <= 210041 || i >= 63744 && i <= 64255 || i >= 12288 && i <= 12351 || i >= 12352 && i <= 12447 || i >= 12448 && i <= 12543 || i >= 12592 && i <= 12687 || i >= 44032 && i <= 55215 || i >= 65280 && i <= 65519;
2658
2666
  }
2659
2667
  function st(i) {
@@ -2664,45 +2672,45 @@ function st(i) {
2664
2672
  const n = i.charCodeAt(e + 1);
2665
2673
  if (n >= 56320 && n <= 57343) {
2666
2674
  const s = (t - 55296 << 10) + (n - 56320) + 65536;
2667
- if (Ie(s))
2675
+ if (ze(s))
2668
2676
  return !0;
2669
2677
  e++;
2670
2678
  continue;
2671
2679
  }
2672
2680
  }
2673
- if (Ie(t))
2681
+ if (ze(t))
2674
2682
  return !0;
2675
2683
  }
2676
2684
  }
2677
2685
  return !1;
2678
2686
  }
2679
- function pi(i) {
2687
+ function mi(i) {
2680
2688
  const e = Rt(i);
2681
- return e !== null && (ve.has(e) || ht.has(e));
2689
+ return e !== null && (Me.has(e) || ht.has(e));
2682
2690
  }
2683
- const mi = /* @__PURE__ */ new Set([
2691
+ const Si = /* @__PURE__ */ new Set([
2684
2692
  " ",
2685
2693
  " ",
2686
2694
  "⁠",
2687
2695
  "\uFEFF"
2688
- ]), Si = /* @__PURE__ */ new Set([
2696
+ ]), Fi = /* @__PURE__ */ new Set([
2689
2697
  "-",
2690
2698
  "‐",
2691
2699
  "–",
2692
2700
  "—"
2693
2701
  ]);
2694
- function Fi(i) {
2695
- const e = Rt(i);
2696
- return e !== null && mi.has(e);
2697
- }
2698
2702
  function yi(i) {
2699
2703
  const e = Rt(i);
2700
2704
  return e !== null && Si.has(e);
2701
2705
  }
2702
- function Ln(i, e) {
2703
- return Fi(i) ? !1 : e ? !(pi(i) || yi(i)) : !0;
2706
+ function Ei(i) {
2707
+ const e = Rt(i);
2708
+ return e !== null && Fi.has(e);
2709
+ }
2710
+ function Tn(i, e) {
2711
+ return yi(i) ? !1 : e ? !(mi(i) || Ei(i)) : !0;
2704
2712
  }
2705
- const ve = /* @__PURE__ */ new Set([
2713
+ const Me = /* @__PURE__ */ new Set([
2706
2714
  ",",
2707
2715
  ".",
2708
2716
  "!",
@@ -2753,7 +2761,7 @@ const ve = /* @__PURE__ */ new Set([
2753
2761
  "〖",
2754
2762
  "〘",
2755
2763
  "〚"
2756
- ]), Me = /* @__PURE__ */ new Set([
2764
+ ]), be = /* @__PURE__ */ new Set([
2757
2765
  "'",
2758
2766
  "’"
2759
2767
  ]), ht = /* @__PURE__ */ new Set([
@@ -2783,14 +2791,14 @@ const ve = /* @__PURE__ */ new Set([
2783
2791
  "»",
2784
2792
  "›",
2785
2793
  "…"
2786
- ]), Ei = /* @__PURE__ */ new Set([
2794
+ ]), Ai = /* @__PURE__ */ new Set([
2787
2795
  ":",
2788
2796
  ".",
2789
2797
  "،",
2790
2798
  "؛"
2791
- ]), Ai = /* @__PURE__ */ new Set([
2792
- "၏"
2793
2799
  ]), Ni = /* @__PURE__ */ new Set([
2800
+ "၏"
2801
+ ]), Ci = /* @__PURE__ */ new Set([
2794
2802
  "”",
2795
2803
  "’",
2796
2804
  "»",
@@ -2803,8 +2811,8 @@ const ve = /* @__PURE__ */ new Set([
2803
2811
  "〕",
2804
2812
  ")"
2805
2813
  ]);
2806
- function Ci(i) {
2807
- if (be(i))
2814
+ function vi(i) {
2815
+ if (we(i))
2808
2816
  return !0;
2809
2817
  let e = !1;
2810
2818
  for (const t of i) {
@@ -2817,25 +2825,25 @@ function Ci(i) {
2817
2825
  }
2818
2826
  return e;
2819
2827
  }
2820
- function vi(i) {
2828
+ function Mi(i) {
2821
2829
  for (const e of i)
2822
- if (!ve.has(e) && !ht.has(e))
2830
+ if (!Me.has(e) && !ht.has(e))
2823
2831
  return !1;
2824
2832
  return i.length > 0;
2825
2833
  }
2826
- function Mi(i) {
2827
- if (be(i))
2834
+ function bi(i) {
2835
+ if (we(i))
2828
2836
  return !0;
2829
2837
  for (const e of i)
2830
- if (!Vt.has(e) && !Me.has(e) && !ut.test(e) && !Jt(e))
2838
+ if (!Vt.has(e) && !be.has(e) && !ut.test(e) && !Jt(e))
2831
2839
  return !1;
2832
2840
  return i.length > 0;
2833
2841
  }
2834
- function be(i) {
2842
+ function we(i) {
2835
2843
  let e = !1;
2836
2844
  for (const t of i)
2837
2845
  if (!(t === "\\" || ut.test(t))) {
2838
- if (Vt.has(t) || ht.has(t) || Me.has(t)) {
2846
+ if (Vt.has(t) || ht.has(t) || be.has(t)) {
2839
2847
  e = !0;
2840
2848
  continue;
2841
2849
  }
@@ -2862,13 +2870,13 @@ function Rt(i) {
2862
2870
  const e = Zt(i, i.length);
2863
2871
  return i.slice(e);
2864
2872
  }
2865
- function bi(i) {
2873
+ function wi(i) {
2866
2874
  for (const e of i)
2867
2875
  if (!ut.test(e))
2868
2876
  return e;
2869
2877
  return null;
2870
2878
  }
2871
- function wi(i) {
2879
+ function Di(i) {
2872
2880
  for (let e = i.length; e > 0; ) {
2873
2881
  const t = Zt(i, e), n = i.slice(t, e);
2874
2882
  if (!ut.test(n))
@@ -2877,7 +2885,7 @@ function wi(i) {
2877
2885
  }
2878
2886
  return null;
2879
2887
  }
2880
- const Di = [
2888
+ const Bi = [
2881
2889
  36,
2882
2890
  37,
2883
2891
  43,
@@ -2945,7 +2953,7 @@ const Di = [
2945
2953
  126128,
2946
2954
  126128
2947
2955
  ];
2948
- function Bi(i, e) {
2956
+ function ki(i, e) {
2949
2957
  for (let t = 0; t < e.length; t += 2)
2950
2958
  if (i >= e[t] && i <= e[t + 1])
2951
2959
  return !0;
@@ -2953,17 +2961,17 @@ function Bi(i, e) {
2953
2961
  }
2954
2962
  function Jt(i) {
2955
2963
  const e = i.codePointAt(0);
2956
- return e !== void 0 && Bi(e, Di);
2957
- }
2958
- function ki(i) {
2959
- const e = wi(i);
2960
- return e !== null && Jt(e);
2964
+ return e !== void 0 && ki(e, Bi);
2961
2965
  }
2962
2966
  function Li(i) {
2963
- const e = bi(i);
2964
- return e !== null && Ce.test(e);
2967
+ const e = Di(i);
2968
+ return e !== null && Jt(e);
2965
2969
  }
2966
2970
  function Ti(i) {
2971
+ const e = wi(i);
2972
+ return e !== null && ve.test(e);
2973
+ }
2974
+ function Oi(i) {
2967
2975
  const e = Array.from(i);
2968
2976
  let t = e.length;
2969
2977
  for (; t > 0; ) {
@@ -2972,7 +2980,7 @@ function Ti(i) {
2972
2980
  t--;
2973
2981
  continue;
2974
2982
  }
2975
- if (Vt.has(n) || Me.has(n)) {
2983
+ if (Vt.has(n) || be.has(n)) {
2976
2984
  t--;
2977
2985
  continue;
2978
2986
  }
@@ -2983,10 +2991,10 @@ function Ti(i) {
2983
2991
  tail: e.slice(t).join("")
2984
2992
  };
2985
2993
  }
2986
- function Oi(i, e, t) {
2994
+ function Pi(i, e, t) {
2987
2995
  return t === "text" && !e && i.length === 1 && i !== "-" && i !== "—" ? i : null;
2988
2996
  }
2989
- function ze(i, e, t, n) {
2997
+ function _e(i, e, t, n) {
2990
2998
  const s = e[n], r = i[n];
2991
2999
  if (s == null)
2992
3000
  return r;
@@ -2996,14 +3004,14 @@ function ze(i, e, t, n) {
2996
3004
  const a = s.repeat(o);
2997
3005
  return i[n] = a, a;
2998
3006
  }
2999
- function _e(i, e) {
3000
- return i && e !== null && Ei.has(e);
3007
+ function Ue(i, e) {
3008
+ return i && e !== null && Ai.has(e);
3001
3009
  }
3002
- function Pi(i) {
3010
+ function Ri(i) {
3003
3011
  const e = Rt(i);
3004
- return e !== null && Ai.has(e);
3012
+ return e !== null && Ni.has(e);
3005
3013
  }
3006
- function Ri(i) {
3014
+ function Hi(i) {
3007
3015
  if (i.length < 2 || i[0] !== " ")
3008
3016
  return null;
3009
3017
  const e = i.slice(1);
@@ -3013,7 +3021,7 @@ function me(i) {
3013
3021
  let e = i.length;
3014
3022
  for (; e > 0; ) {
3015
3023
  const t = Zt(i, e), n = i.slice(t, e);
3016
- if (Ni.has(n))
3024
+ if (Ci.has(n))
3017
3025
  return !0;
3018
3026
  if (!ht.has(n))
3019
3027
  return !1;
@@ -3021,7 +3029,7 @@ function me(i) {
3021
3029
  }
3022
3030
  return !1;
3023
3031
  }
3024
- function Hi(i, e) {
3032
+ function Ii(i, e) {
3025
3033
  if (e.preserveOrdinarySpaces || e.preserveHardBreaks) {
3026
3034
  if (i === " ")
3027
3035
  return "preserved-space";
@@ -3033,23 +3041,23 @@ function Hi(i, e) {
3033
3041
  }
3034
3042
  return i === " " ? "space" : i === " " || i === " " || i === "⁠" || i === "\uFEFF" ? "glue" : i === "​" ? "zero-width-break" : i === "­" ? "soft-hyphen" : "text";
3035
3043
  }
3036
- const Ii = /[\x20\t\n\xA0\xAD\u200B\u202F\u2060\uFEFF]/;
3044
+ const zi = /[\x20\t\n\xA0\xAD\u200B\u202F\u2060\uFEFF]/;
3037
3045
  function tt(i) {
3038
3046
  return i.length === 1 ? i[0] : i.join("");
3039
3047
  }
3040
- function zi(i, e) {
3048
+ function _i(i, e) {
3041
3049
  const t = [];
3042
3050
  for (let n = i.length - 1; n >= 0; n--)
3043
3051
  t.push(i[n]);
3044
3052
  return t.push(e), tt(t);
3045
3053
  }
3046
- function _i(i, e, t, n) {
3047
- if (!Ii.test(i))
3054
+ function Ui(i, e, t, n) {
3055
+ if (!zi.test(i))
3048
3056
  return [{ text: i, isWordLike: e, kind: "text", start: t }];
3049
3057
  const s = [];
3050
3058
  let r = null, o = [], a = t, l = !1, c = 0;
3051
3059
  for (const d of i) {
3052
- const h = Hi(d, n), u = h === "text" && e;
3060
+ const h = Ii(d, n), u = h === "text" && e;
3053
3061
  if (r !== null && h === r && u === l) {
3054
3062
  o.push(d), c += d.length;
3055
3063
  continue;
@@ -3071,18 +3079,18 @@ function _i(i, e, t, n) {
3071
3079
  function Se(i) {
3072
3080
  return i === "space" || i === "preserved-space" || i === "zero-width-break" || i === "hard-break";
3073
3081
  }
3074
- const Ui = /^[A-Za-z][A-Za-z0-9+.-]*:$/;
3075
- function Wi(i, e) {
3082
+ const Wi = /^[A-Za-z][A-Za-z0-9+.-]*:$/;
3083
+ function $i(i, e) {
3076
3084
  const t = i.texts[e];
3077
- return t.startsWith("www.") ? !0 : Ui.test(t) && e + 1 < i.len && i.kinds[e + 1] === "text" && i.texts[e + 1] === "//";
3085
+ return t.startsWith("www.") ? !0 : Wi.test(t) && e + 1 < i.len && i.kinds[e + 1] === "text" && i.texts[e + 1] === "//";
3078
3086
  }
3079
- function $i(i) {
3087
+ function Yi(i) {
3080
3088
  return i.includes("?") && (i.includes("://") || i.startsWith("www."));
3081
3089
  }
3082
- function Yi(i) {
3090
+ function Xi(i) {
3083
3091
  const e = i.texts.slice(), t = i.isWordLike.slice(), n = i.kinds.slice(), s = i.starts.slice();
3084
3092
  for (let o = 0; o < i.len; o++) {
3085
- if (n[o] !== "text" || !Wi(i, o))
3093
+ if (n[o] !== "text" || !$i(i, o))
3086
3094
  continue;
3087
3095
  const a = [e[o]];
3088
3096
  let l = o + 1;
@@ -3107,11 +3115,11 @@ function Yi(i) {
3107
3115
  starts: s
3108
3116
  };
3109
3117
  }
3110
- function Xi(i) {
3118
+ function Gi(i) {
3111
3119
  const e = [], t = [], n = [], s = [];
3112
3120
  for (let r = 0; r < i.len; r++) {
3113
3121
  const o = i.texts[r];
3114
- if (e.push(o), t.push(i.isWordLike[r]), n.push(i.kinds[r]), s.push(i.starts[r]), !$i(o))
3122
+ if (e.push(o), t.push(i.isWordLike[r]), n.push(i.kinds[r]), s.push(i.starts[r]), !Yi(o))
3115
3123
  continue;
3116
3124
  const a = r + 1;
3117
3125
  if (a >= i.len || Se(i.kinds[a]))
@@ -3130,7 +3138,7 @@ function Xi(i) {
3130
3138
  starts: s
3131
3139
  };
3132
3140
  }
3133
- const Gi = /* @__PURE__ */ new Set([
3141
+ const ji = /* @__PURE__ */ new Set([
3134
3142
  ":",
3135
3143
  "-",
3136
3144
  "/",
@@ -3140,24 +3148,24 @@ const Gi = /* @__PURE__ */ new Set([
3140
3148
  "+",
3141
3149
  "–",
3142
3150
  "—"
3143
- ]), ji = /* @__PURE__ */ new Set([".", ",", ":", ";"]);
3144
- function Ue(i) {
3151
+ ]), qi = /* @__PURE__ */ new Set([".", ",", ":", ";"]);
3152
+ function We(i) {
3145
3153
  for (let e = i.length; e > 0; ) {
3146
3154
  const t = Zt(i, e), n = i.slice(t, e);
3147
3155
  if (ut.test(n)) {
3148
3156
  e = t;
3149
3157
  continue;
3150
3158
  }
3151
- return ji.has(n) || Jt(n);
3159
+ return qi.has(n) || Jt(n);
3152
3160
  }
3153
3161
  return !1;
3154
3162
  }
3155
- function qi(i, e) {
3163
+ function Ki(i, e) {
3156
3164
  return e && !st(i);
3157
3165
  }
3158
- function Tn(i) {
3166
+ function On(i) {
3159
3167
  for (const e of i)
3160
- if (Ce.test(e))
3168
+ if (ve.test(e))
3161
3169
  return !0;
3162
3170
  return !1;
3163
3171
  }
@@ -3165,15 +3173,15 @@ function jt(i) {
3165
3173
  if (i.length === 0)
3166
3174
  return !1;
3167
3175
  for (const e of i)
3168
- if (!(Ce.test(e) || Gi.has(e)))
3176
+ if (!(ve.test(e) || ji.has(e)))
3169
3177
  return !1;
3170
3178
  return !0;
3171
3179
  }
3172
- function Ki(i) {
3180
+ function Vi(i) {
3173
3181
  const e = [], t = [], n = [], s = [];
3174
3182
  for (let r = 0; r < i.len; r++) {
3175
3183
  const o = i.texts[r], a = i.kinds[r];
3176
- if (a === "text" && jt(o) && Tn(o)) {
3184
+ if (a === "text" && jt(o) && On(o)) {
3177
3185
  const l = [o];
3178
3186
  let c = r + 1;
3179
3187
  for (; c < i.len && i.kinds[c] === "text" && jt(i.texts[c]); )
@@ -3191,16 +3199,16 @@ function Ki(i) {
3191
3199
  starts: s
3192
3200
  };
3193
3201
  }
3194
- function Vi(i) {
3202
+ function Zi(i) {
3195
3203
  const e = [], t = [], n = [], s = [];
3196
3204
  for (let r = 0; r < i.len; r++) {
3197
3205
  const o = i.texts[r], a = i.kinds[r], l = i.isWordLike[r];
3198
- if (a === "text" && Ue(o) && (l || ki(o)) && !st(o)) {
3206
+ if (a === "text" && We(o) && (l || Li(o)) && !st(o)) {
3199
3207
  const c = [o];
3200
3208
  let d = !0, h = r + 1;
3201
- for (; d && h < i.len && i.kinds[h] === "text" && qi(i.texts[h], i.isWordLike[h]); ) {
3209
+ for (; d && h < i.len && i.kinds[h] === "text" && Ki(i.texts[h], i.isWordLike[h]); ) {
3202
3210
  const u = i.texts[h];
3203
- c.push(u), d = Ue(u), h++;
3211
+ c.push(u), d = We(u), h++;
3204
3212
  }
3205
3213
  e.push(tt(c)), t.push(!0), n.push("text"), s.push(i.starts[r]), r = h - 1;
3206
3214
  continue;
@@ -3215,7 +3223,7 @@ function Vi(i) {
3215
3223
  starts: s
3216
3224
  };
3217
3225
  }
3218
- function Zi(i) {
3226
+ function Ji(i) {
3219
3227
  const e = [], t = [], n = [], s = [];
3220
3228
  for (let r = 0; r < i.len; r++) {
3221
3229
  const o = i.texts[r];
@@ -3226,7 +3234,7 @@ function Zi(i) {
3226
3234
  const d = a[c];
3227
3235
  if (!l)
3228
3236
  break;
3229
- (d.length === 0 || !Tn(d) || !jt(d)) && (l = !1);
3237
+ (d.length === 0 || !On(d) || !jt(d)) && (l = !1);
3230
3238
  }
3231
3239
  if (l) {
3232
3240
  let c = 0;
@@ -3247,7 +3255,7 @@ function Zi(i) {
3247
3255
  starts: s
3248
3256
  };
3249
3257
  }
3250
- function Ji(i) {
3258
+ function Qi(i) {
3251
3259
  const e = [], t = [], n = [], s = [];
3252
3260
  let r = 0;
3253
3261
  for (; r < i.len; ) {
@@ -3288,12 +3296,12 @@ function Ji(i) {
3288
3296
  starts: s
3289
3297
  };
3290
3298
  }
3291
- function Qi(i) {
3299
+ function tr(i) {
3292
3300
  const e = i.texts.slice(), t = i.isWordLike.slice(), n = i.kinds.slice(), s = i.starts.slice();
3293
3301
  for (let r = 0; r < e.length - 1; r++) {
3294
3302
  if (n[r] !== "text" || n[r + 1] !== "text" || !st(e[r]) || !st(e[r + 1]))
3295
3303
  continue;
3296
- const o = Ti(e[r]);
3304
+ const o = Oi(e[r]);
3297
3305
  o !== null && (e[r] = o.head, e[r + 1] = o.tail + e[r + 1], s[r + 1] = s[r] + o.head.length);
3298
3306
  }
3299
3307
  return {
@@ -3304,35 +3312,35 @@ function Qi(i) {
3304
3312
  starts: s
3305
3313
  };
3306
3314
  }
3307
- function tr(i, e, t) {
3308
- const n = fi();
3315
+ function er(i, e, t) {
3316
+ const n = gi();
3309
3317
  let s = 0;
3310
3318
  const r = [], o = [], a = [], l = [], c = [], d = [], h = [], u = [], x = [], f = [], p = [], g = [];
3311
3319
  for (const S of n.segment(i))
3312
- for (const N of _i(S.segment, S.isWordLike ?? !1, S.index, t)) {
3320
+ for (const N of Ui(S.segment, S.isWordLike ?? !1, S.index, t)) {
3313
3321
  let k = function() {
3314
3322
  d[M] !== null && (o[M] = [
3315
- ze(r, d, h, M)
3316
- ], d[M] = null), o[M].push(N.text), a[M] = a[M] || N.isWordLike, u[M] = u[M] || D, x[M] = x[M] || b, f[M] = T, p[M] = I, g[M] = _e(x[M], L);
3323
+ _e(r, d, h, M)
3324
+ ], d[M] = null), o[M].push(N.text), a[M] = a[M] || N.isWordLike, u[M] = u[M] || D, x[M] = x[M] || b, f[M] = T, p[M] = I, g[M] = Ue(x[M], L);
3317
3325
  };
3318
- const v = N.kind === "text", w = Oi(N.text, N.isWordLike, N.kind), D = st(N.text), b = He(N.text), L = Rt(N.text), T = me(N.text), I = Pi(N.text), M = s - 1;
3319
- e.carryCJKAfterClosingQuote && v && s > 0 && l[M] === "text" && D && u[M] && f[M] || v && s > 0 && l[M] === "text" && vi(N.text) && u[M] || v && s > 0 && l[M] === "text" && p[M] ? k() : v && s > 0 && l[M] === "text" && N.isWordLike && b && g[M] ? (k(), a[M] = !0) : w !== null && s > 0 && l[M] === "text" && d[M] === w ? h[M] = (h[M] ?? 1) + 1 : v && !N.isWordLike && s > 0 && l[M] === "text" && !u[M] && (Ci(N.text) || N.text === "-" && a[M]) ? k() : (r[s] = N.text, o[s] = [N.text], a[s] = N.isWordLike, l[s] = N.kind, c[s] = N.start, d[s] = w, h[s] = w === null ? 0 : 1, u[s] = D, x[s] = b, f[s] = T, p[s] = I, g[s] = _e(b, L), s++);
3326
+ const v = N.kind === "text", w = Pi(N.text, N.isWordLike, N.kind), D = st(N.text), b = Ie(N.text), L = Rt(N.text), T = me(N.text), I = Ri(N.text), M = s - 1;
3327
+ e.carryCJKAfterClosingQuote && v && s > 0 && l[M] === "text" && D && u[M] && f[M] || v && s > 0 && l[M] === "text" && Mi(N.text) && u[M] || v && s > 0 && l[M] === "text" && p[M] ? k() : v && s > 0 && l[M] === "text" && N.isWordLike && b && g[M] ? (k(), a[M] = !0) : w !== null && s > 0 && l[M] === "text" && d[M] === w ? h[M] = (h[M] ?? 1) + 1 : v && !N.isWordLike && s > 0 && l[M] === "text" && !u[M] && (vi(N.text) || N.text === "-" && a[M]) ? k() : (r[s] = N.text, o[s] = [N.text], a[s] = N.isWordLike, l[s] = N.kind, c[s] = N.start, d[s] = w, h[s] = w === null ? 0 : 1, u[s] = D, x[s] = b, f[s] = T, p[s] = I, g[s] = Ue(b, L), s++);
3320
3328
  }
3321
3329
  for (let S = 0; S < s; S++) {
3322
3330
  if (d[S] !== null) {
3323
- r[S] = ze(r, d, h, S);
3331
+ r[S] = _e(r, d, h, S);
3324
3332
  continue;
3325
3333
  }
3326
3334
  r[S] = tt(o[S]);
3327
3335
  }
3328
3336
  for (let S = 1; S < s; S++)
3329
- l[S] === "text" && !a[S] && be(r[S]) && l[S - 1] === "text" && !u[S - 1] && (r[S - 1] += r[S], a[S - 1] = a[S - 1] || a[S], r[S] = "");
3337
+ l[S] === "text" && !a[S] && we(r[S]) && l[S - 1] === "text" && !u[S - 1] && (r[S - 1] += r[S], a[S - 1] = a[S - 1] || a[S], r[S] = "");
3330
3338
  const E = Array.from({ length: s }, () => null);
3331
3339
  let y = -1;
3332
3340
  for (let S = s - 1; S >= 0; S--) {
3333
3341
  const N = r[S];
3334
3342
  if (N.length !== 0) {
3335
- if (l[S] === "text" && !a[S] && y >= 0 && l[y] === "text" && (Mi(N) || N === "-" && Li(r[y]))) {
3343
+ if (l[S] === "text" && !a[S] && y >= 0 && l[y] === "text" && (bi(N) || N === "-" && Ti(r[y]))) {
3336
3344
  const v = E[y] ?? [];
3337
3345
  v.push(N), E[y] = v, c[y] = c[S], r[S] = "";
3338
3346
  continue;
@@ -3342,7 +3350,7 @@ function tr(i, e, t) {
3342
3350
  }
3343
3351
  for (let S = 0; S < s; S++) {
3344
3352
  const N = E[S];
3345
- N != null && (r[S] = zi(N, r[S]));
3353
+ N != null && (r[S] = _i(N, r[S]));
3346
3354
  }
3347
3355
  let F = 0;
3348
3356
  for (let S = 0; S < s; S++) {
@@ -3350,20 +3358,20 @@ function tr(i, e, t) {
3350
3358
  N.length !== 0 && (F !== S && (r[F] = N, a[F] = a[S], l[F] = l[S], c[F] = c[S]), F++);
3351
3359
  }
3352
3360
  r.length = F, a.length = F, l.length = F, c.length = F;
3353
- const C = Ji({
3361
+ const C = Qi({
3354
3362
  len: F,
3355
3363
  texts: r,
3356
3364
  isWordLike: a,
3357
3365
  kinds: l,
3358
3366
  starts: c
3359
- }), A = Qi(Vi(Zi(Ki(Xi(Yi(C))))));
3367
+ }), A = tr(Zi(Ji(Vi(Gi(Xi(C))))));
3360
3368
  for (let S = 0; S < A.len - 1; S++) {
3361
- const N = Ri(A.texts[S]);
3362
- N !== null && (A.kinds[S] !== "space" && A.kinds[S] !== "preserved-space" || A.kinds[S + 1] !== "text" || !He(A.texts[S + 1]) || (A.texts[S] = N.space, A.isWordLike[S] = !1, A.kinds[S] = A.kinds[S] === "preserved-space" ? "preserved-space" : "space", A.texts[S + 1] = N.marks + A.texts[S + 1], A.starts[S + 1] = A.starts[S] + N.space.length));
3369
+ const N = Hi(A.texts[S]);
3370
+ N !== null && (A.kinds[S] !== "space" && A.kinds[S] !== "preserved-space" || A.kinds[S + 1] !== "text" || !Ie(A.texts[S + 1]) || (A.texts[S] = N.space, A.isWordLike[S] = !1, A.kinds[S] = A.kinds[S] === "preserved-space" ? "preserved-space" : "space", A.texts[S + 1] = N.marks + A.texts[S + 1], A.starts[S + 1] = A.starts[S] + N.space.length));
3363
3371
  }
3364
3372
  return A;
3365
3373
  }
3366
- function er(i, e) {
3374
+ function nr(i, e) {
3367
3375
  if (i.len === 0)
3368
3376
  return [];
3369
3377
  if (!e.preserveHardBreaks)
@@ -3386,7 +3394,7 @@ function er(i, e) {
3386
3394
  consumedEndSegmentIndex: i.len
3387
3395
  }), t;
3388
3396
  }
3389
- function nr(i, e, t) {
3397
+ function sr(i, e, t) {
3390
3398
  if (e.len <= 1)
3391
3399
  return e;
3392
3400
  const n = [], s = [], r = [], o = [];
@@ -3414,7 +3422,7 @@ function nr(i, e, t) {
3414
3422
  for (let u = 0; u < e.len; u++) {
3415
3423
  const x = e.texts[u], f = e.kinds[u];
3416
3424
  if (f === "text") {
3417
- a >= 0 && !Ln(e.texts[u - 1], t) && h(u), a < 0 && (a = u), l = l || st(x);
3425
+ a >= 0 && !Tn(e.texts[u - 1], t) && h(u), a < 0 && (a = u), l = l || st(x);
3418
3426
  continue;
3419
3427
  }
3420
3428
  h(u), n.push(x), s.push(e.isWordLike[u]), r.push(f), o.push(e.starts[u]);
@@ -3427,8 +3435,8 @@ function nr(i, e, t) {
3427
3435
  starts: o
3428
3436
  };
3429
3437
  }
3430
- function sr(i, e, t = "normal", n = "normal") {
3431
- const s = di(t), r = s.mode === "pre-wrap" ? ui(i) : hi(i);
3438
+ function ir(i, e, t = "normal", n = "normal") {
3439
+ const s = hi(t), r = s.mode === "pre-wrap" ? xi(i) : ui(i);
3432
3440
  if (r.length === 0)
3433
3441
  return {
3434
3442
  normalized: r,
@@ -3439,20 +3447,20 @@ function sr(i, e, t = "normal", n = "normal") {
3439
3447
  kinds: [],
3440
3448
  starts: []
3441
3449
  };
3442
- const o = tr(r, e, s), a = n === "keep-all" ? nr(r, o, e.breakKeepAllAfterPunctuation) : o;
3450
+ const o = er(r, e, s), a = n === "keep-all" ? sr(r, o, e.breakKeepAllAfterPunctuation) : o;
3443
3451
  return {
3444
3452
  normalized: r,
3445
- chunks: er(a, s),
3453
+ chunks: nr(a, s),
3446
3454
  ...a
3447
3455
  };
3448
3456
  }
3449
3457
  let pt = null;
3450
- const We = /* @__PURE__ */ new Map();
3458
+ const $e = /* @__PURE__ */ new Map();
3451
3459
  let mt = null;
3452
- const ir = 96, rr = new RegExp("\\p{Emoji_Presentation}", "u"), or = /[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u;
3460
+ const rr = 96, or = new RegExp("\\p{Emoji_Presentation}", "u"), ar = /[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u;
3453
3461
  let se = null;
3454
- const $e = /* @__PURE__ */ new Map();
3455
- function we() {
3462
+ const Ye = /* @__PURE__ */ new Map();
3463
+ function De() {
3456
3464
  if (pt !== null)
3457
3465
  return pt;
3458
3466
  if (typeof OffscreenCanvas < "u")
@@ -3461,14 +3469,14 @@ function we() {
3461
3469
  return pt = document.createElement("canvas").getContext("2d"), pt;
3462
3470
  throw new Error("Text measurement requires OffscreenCanvas or a DOM canvas context.");
3463
3471
  }
3464
- function ar(i) {
3465
- let e = We.get(i);
3466
- return e || (e = /* @__PURE__ */ new Map(), We.set(i, e)), e;
3472
+ function cr(i) {
3473
+ let e = $e.get(i);
3474
+ return e || (e = /* @__PURE__ */ new Map(), $e.set(i, e)), e;
3467
3475
  }
3468
3476
  function ot(i, e) {
3469
3477
  let t = e.get(i);
3470
3478
  return t === void 0 && (t = {
3471
- width: we().measureText(i).width,
3479
+ width: De().measureText(i).width,
3472
3480
  containsCJK: st(i)
3473
3481
  }, e.set(i, t)), t;
3474
3482
  }
@@ -3492,24 +3500,24 @@ function Qt() {
3492
3500
  preferEarlySoftHyphenBreak: t
3493
3501
  }, mt;
3494
3502
  }
3495
- function cr(i) {
3503
+ function lr(i) {
3496
3504
  const e = i.match(/(\d+(?:\.\d+)?)\s*px/);
3497
3505
  return e ? parseFloat(e[1]) : 16;
3498
3506
  }
3499
- function On() {
3507
+ function Pn() {
3500
3508
  return se === null && (se = new Intl.Segmenter(void 0, { granularity: "grapheme" })), se;
3501
3509
  }
3502
- function lr(i) {
3503
- return rr.test(i) || i.includes("️");
3504
- }
3505
3510
  function dr(i) {
3506
- return or.test(i);
3511
+ return or.test(i) || i.includes("️");
3507
3512
  }
3508
- function hr(i, e) {
3509
- let t = $e.get(i);
3513
+ function hr(i) {
3514
+ return ar.test(i);
3515
+ }
3516
+ function ur(i, e) {
3517
+ let t = Ye.get(i);
3510
3518
  if (t !== void 0)
3511
3519
  return t;
3512
- const n = we();
3520
+ const n = De();
3513
3521
  n.font = i;
3514
3522
  const s = n.measureText("😀").width;
3515
3523
  if (t = 0, s > e + 0.5 && typeof document < "u" && document.body !== null) {
@@ -3518,26 +3526,26 @@ function hr(i, e) {
3518
3526
  const o = r.getBoundingClientRect().width;
3519
3527
  document.body.removeChild(r), s - o > 0.5 && (t = s - o);
3520
3528
  }
3521
- return $e.set(i, t), t;
3529
+ return Ye.set(i, t), t;
3522
3530
  }
3523
- function ur(i) {
3531
+ function xr(i) {
3524
3532
  let e = 0;
3525
- const t = On();
3533
+ const t = Pn();
3526
3534
  for (const n of t.segment(i))
3527
- lr(n.segment) && e++;
3535
+ dr(n.segment) && e++;
3528
3536
  return e;
3529
3537
  }
3530
- function xr(i, e) {
3531
- return e.emojiCount === void 0 && (e.emojiCount = ur(i)), e.emojiCount;
3538
+ function fr(i, e) {
3539
+ return e.emojiCount === void 0 && (e.emojiCount = xr(i)), e.emojiCount;
3532
3540
  }
3533
3541
  function lt(i, e, t) {
3534
- return t === 0 ? e.width : e.width - xr(i, e) * t;
3542
+ return t === 0 ? e.width : e.width - fr(i, e) * t;
3535
3543
  }
3536
- function fr(i, e, t, n, s) {
3544
+ function gr(i, e, t, n, s) {
3537
3545
  if (e.breakableFitAdvances !== void 0 && e.breakableFitMode === s)
3538
3546
  return e.breakableFitAdvances;
3539
3547
  e.breakableFitMode = s;
3540
- const r = On(), o = [];
3548
+ const r = Pn(), o = [];
3541
3549
  for (const d of r.segment(i))
3542
3550
  o.push(d.segment);
3543
3551
  if (o.length <= 1)
@@ -3550,7 +3558,7 @@ function fr(i, e, t, n, s) {
3550
3558
  }
3551
3559
  return e.breakableFitAdvances = d, e.breakableFitAdvances;
3552
3560
  }
3553
- if (s === "pair-context" || o.length > ir) {
3561
+ if (s === "pair-context" || o.length > rr) {
3554
3562
  const d = [];
3555
3563
  let h = null, u = 0;
3556
3564
  for (const x of o) {
@@ -3574,61 +3582,61 @@ function fr(i, e, t, n, s) {
3574
3582
  }
3575
3583
  return e.breakableFitAdvances = a, e.breakableFitAdvances;
3576
3584
  }
3577
- function gr(i, e) {
3578
- const t = we();
3585
+ function pr(i, e) {
3586
+ const t = De();
3579
3587
  t.font = i;
3580
- const n = ar(i), s = cr(i), r = e ? hr(i, s) : 0;
3588
+ const n = cr(i), s = lr(i), r = e ? ur(i, s) : 0;
3581
3589
  return { cache: n, fontSize: s, emojiCorrection: r };
3582
3590
  }
3583
- function pr(i) {
3591
+ function mr(i) {
3584
3592
  return i === "space" || i === "zero-width-break" || i === "soft-hyphen";
3585
3593
  }
3586
- function Pn(i) {
3594
+ function Rn(i) {
3587
3595
  return i === "space" || i === "preserved-space" || i === "tab" || i === "zero-width-break" || i === "soft-hyphen";
3588
3596
  }
3589
- function Rn(i, e, t = i.widths.length) {
3597
+ function Hn(i, e, t = i.widths.length) {
3590
3598
  for (; e < t; ) {
3591
3599
  const n = i.kinds[e];
3592
- if (!pr(n))
3600
+ if (!mr(n))
3593
3601
  break;
3594
3602
  e++;
3595
3603
  }
3596
3604
  return e;
3597
3605
  }
3598
- function mr(i, e) {
3606
+ function Sr(i, e) {
3599
3607
  if (e <= 0)
3600
3608
  return 0;
3601
3609
  const t = i % e;
3602
3610
  return Math.abs(t) <= 1e-6 ? e : e - t;
3603
3611
  }
3604
- function Sr(i, e, t) {
3612
+ function Fr(i, e, t) {
3605
3613
  return i.letterSpacing !== 0 && e && i.spacingGraphemeCounts[t] > 0 ? i.letterSpacing : 0;
3606
3614
  }
3607
- function De(i, e) {
3615
+ function Be(i, e) {
3608
3616
  return e === 0 ? 0 : i + e;
3609
3617
  }
3610
- function Fr(i, e) {
3618
+ function yr(i, e) {
3611
3619
  return i.letterSpacing !== 0 && i.spacingGraphemeCounts[e] > 0 ? i.letterSpacing : 0;
3612
3620
  }
3613
- function yr(i, e, t, n, s) {
3614
- const r = e === "tab" ? s + Fr(i, t) : i.lineEndFitAdvances[t];
3615
- return De(n, r);
3621
+ function Er(i, e, t, n, s) {
3622
+ const r = e === "tab" ? s + yr(i, t) : i.lineEndFitAdvances[t];
3623
+ return Be(n, r);
3616
3624
  }
3617
- function Ye(i, e, t, n) {
3625
+ function Xe(i, e, t, n) {
3618
3626
  const s = e === "tab" ? 0 : i.lineEndFitAdvances[t];
3619
- return De(n, s);
3627
+ return Be(n, s);
3620
3628
  }
3621
- function Xe(i, e, t, n, s) {
3629
+ function Ge(i, e, t, n, s) {
3622
3630
  const r = e === "tab" ? s : i.lineEndPaintAdvances[t];
3623
- return De(n, r);
3631
+ return Be(n, r);
3624
3632
  }
3625
- function Er(i, e, t) {
3633
+ function Ar(i, e, t) {
3626
3634
  return i.letterSpacing !== 0 && e ? t + i.letterSpacing : t;
3627
3635
  }
3628
- function Ar(i, e) {
3636
+ function Nr(i, e) {
3629
3637
  return i.letterSpacing === 0 ? e : e + i.letterSpacing;
3630
3638
  }
3631
- function Nr(i, e, t, n, s) {
3639
+ function Cr(i, e, t, n, s) {
3632
3640
  if (i.letterSpacing === 0)
3633
3641
  return 0;
3634
3642
  if (s > 0)
@@ -3646,10 +3654,10 @@ function Nr(i, e, t, n, s) {
3646
3654
  }
3647
3655
  return 0;
3648
3656
  }
3649
- function Cr(i, e, t, n, s, r) {
3650
- return e + Nr(i, t, n, s, r);
3657
+ function vr(i, e, t, n, s, r) {
3658
+ return e + Cr(i, t, n, s, r);
3651
3659
  }
3652
- function vr(i, e, t) {
3660
+ function Mr(i, e, t) {
3653
3661
  const { widths: n, kinds: s, breakableFitAdvances: r } = i;
3654
3662
  if (n.length === 0)
3655
3663
  return 0;
@@ -3683,8 +3691,8 @@ function vr(i, e, t) {
3683
3691
  h && f === w && p === b.length && (f = w + 1, p = 0);
3684
3692
  }
3685
3693
  let v = 0;
3686
- for (; v < n.length && !(!h && (v = Rn(i, v), v >= n.length)); ) {
3687
- const w = n[v], D = s[v], b = Pn(D);
3694
+ for (; v < n.length && !(!h && (v = Hn(i, v), v >= n.length)); ) {
3695
+ const w = n[v], D = s[v], b = Rn(D);
3688
3696
  if (!h) {
3689
3697
  w > l && r[v] !== null ? N(v, 0) : C(v, w), b && (g = v + 1, E = d - w), v++;
3690
3698
  continue;
@@ -3713,9 +3721,9 @@ function vr(i, e, t) {
3713
3721
  }
3714
3722
  return h && F(), c;
3715
3723
  }
3716
- function Mr(i, e, t) {
3724
+ function br(i, e, t) {
3717
3725
  if (i.simpleLineWalkFastPath)
3718
- return vr(i, e, t);
3726
+ return Mr(i, e, t);
3719
3727
  const { widths: n, kinds: s, breakableFitAdvances: r, discretionaryHyphenWidth: o, chunks: a } = i;
3720
3728
  if (n.length === 0 || a.length === 0)
3721
3729
  return 0;
@@ -3728,7 +3736,7 @@ function Mr(i, e, t) {
3728
3736
  return A === "soft-hyphen" && y === g && E === 0 ? C : u;
3729
3737
  }
3730
3738
  function v(M = g, k = E, B) {
3731
- h++, t !== void 0 && t(Cr(i, B ?? N(), f, p, M, k), f, p, M, k), u = 0, x = !1, S();
3739
+ h++, t !== void 0 && t(vr(i, B ?? N(), f, p, M, k), f, p, M, k), u = 0, x = !1, S();
3732
3740
  }
3733
3741
  function w(M, k) {
3734
3742
  x = !0, f = M, p = 0, g = M + 1, E = 0, u = k;
@@ -3746,7 +3754,7 @@ function Mr(i, e, t) {
3746
3754
  function L(M, k, B, R, W, Y) {
3747
3755
  if (!k)
3748
3756
  return;
3749
- const U = Ye(i, M, B, W), V = Xe(i, M, B, W, R);
3757
+ const U = Xe(i, M, B, W), V = Ge(i, M, B, W, R);
3750
3758
  y = B + 1, F = u - Y + U, C = u - Y + V, A = M;
3751
3759
  }
3752
3760
  function T(M, k) {
@@ -3756,8 +3764,8 @@ function Mr(i, e, t) {
3756
3764
  if (!x)
3757
3765
  D(M, R, W);
3758
3766
  else {
3759
- const Y = Er(i, !0, W), U = u + Y;
3760
- Ar(i, U) > d ? (v(), D(M, R, W)) : (u = U, g = M, E = R + 1);
3767
+ const Y = Ar(i, !0, W), U = u + Y;
3768
+ Nr(i, U) > d ? (v(), D(M, R, W)) : (u = U, g = M, E = R + 1);
3761
3769
  }
3762
3770
  }
3763
3771
  x && g === M && E === B.length && (g = M + 1, E = 0);
@@ -3773,8 +3781,8 @@ function Mr(i, e, t) {
3773
3781
  }
3774
3782
  x = !1, u = 0, f = k.startSegmentIndex, p = 0, g = k.startSegmentIndex, E = 0, S();
3775
3783
  let B = k.startSegmentIndex;
3776
- for (; B < k.endSegmentIndex && !(!x && (B = Rn(i, B, k.endSegmentIndex), B >= k.endSegmentIndex)); ) {
3777
- const R = s[B], W = Pn(R), Y = Sr(i, x, B), U = R === "tab" ? mr(u + Y, i.tabStopAdvance) : n[B], V = Y + U, ct = yr(i, R, B, Y, U);
3784
+ for (; B < k.endSegmentIndex && !(!x && (B = Hn(i, B, k.endSegmentIndex), B >= k.endSegmentIndex)); ) {
3785
+ const R = s[B], W = Rn(R), Y = Fr(i, x, B), U = R === "tab" ? Sr(u + Y, i.tabStopAdvance) : n[B], V = Y + U, ct = Er(i, R, B, Y, U);
3778
3786
  if (R === "soft-hyphen") {
3779
3787
  x && (g = B + 1, E = 0, y = B + 1, F = u + o, C = u + o, A = R), B++;
3780
3788
  continue;
@@ -3784,7 +3792,7 @@ function Mr(i, e, t) {
3784
3792
  continue;
3785
3793
  }
3786
3794
  if (u + ct > d) {
3787
- const xt = u + Ye(i, R, B, Y), ft = u + Xe(i, R, B, Y, U);
3795
+ const xt = u + Xe(i, R, B, Y), ft = u + Ge(i, R, B, Y, U);
3788
3796
  if (A === "soft-hyphen" && l.preferEarlySoftHyphenBreak && F <= d) {
3789
3797
  v(y, 0, C);
3790
3798
  continue;
@@ -3818,54 +3826,54 @@ function Mr(i, e, t) {
3818
3826
  }
3819
3827
  return h;
3820
3828
  }
3821
- let ie = null, Ge = /* @__PURE__ */ new WeakMap();
3822
- function br() {
3829
+ let ie = null, je = /* @__PURE__ */ new WeakMap();
3830
+ function wr() {
3823
3831
  return ie === null && (ie = new Intl.Segmenter(void 0, { granularity: "grapheme" })), ie;
3824
3832
  }
3825
- function je(i, e, t) {
3833
+ function qe(i, e, t) {
3826
3834
  let n = t.get(i);
3827
3835
  if (n !== void 0)
3828
3836
  return n;
3829
3837
  n = [];
3830
- const s = br();
3838
+ const s = wr();
3831
3839
  for (const r of s.segment(e[i]))
3832
3840
  n.push(r.segment);
3833
3841
  return t.set(i, n), n;
3834
3842
  }
3835
- function wr(i, e, t) {
3843
+ function Dr(i, e, t) {
3836
3844
  return t > e && i[t - 1] === "soft-hyphen";
3837
3845
  }
3838
- function qe(i, e, t, n) {
3846
+ function Ke(i, e, t, n) {
3839
3847
  for (let s = t; s < n; s++)
3840
3848
  i += e[s];
3841
3849
  return i;
3842
3850
  }
3843
- function Dr(i) {
3844
- let e = Ge.get(i);
3845
- return e !== void 0 || (e = /* @__PURE__ */ new Map(), Ge.set(i, e)), e;
3851
+ function Br(i) {
3852
+ let e = je.get(i);
3853
+ return e !== void 0 || (e = /* @__PURE__ */ new Map(), je.set(i, e)), e;
3846
3854
  }
3847
- function Br(i, e, t, n, s, r) {
3855
+ function kr(i, e, t, n, s, r) {
3848
3856
  let o = "";
3849
- const a = wr(i.kinds, t, s);
3857
+ const a = Dr(i.kinds, t, s);
3850
3858
  for (let l = t; l < s; l++)
3851
3859
  if (!(i.kinds[l] === "soft-hyphen" || i.kinds[l] === "hard-break"))
3852
3860
  if (l === t && n > 0) {
3853
- const c = je(l, i.segments, e);
3854
- o = qe(o, c, n, c.length);
3861
+ const c = qe(l, i.segments, e);
3862
+ o = Ke(o, c, n, c.length);
3855
3863
  } else
3856
3864
  o += i.segments[l];
3857
3865
  if (r > 0) {
3858
3866
  a && (o += "-");
3859
- const l = je(s, i.segments, e);
3860
- o = qe(o, l, t === s ? n : 0, r);
3867
+ const l = qe(s, i.segments, e);
3868
+ o = Ke(o, l, t === s ? n : 0, r);
3861
3869
  } else a && (o += "-");
3862
3870
  return o;
3863
3871
  }
3864
3872
  let re = null;
3865
- function Hn() {
3873
+ function In() {
3866
3874
  return re === null && (re = new Intl.Segmenter(void 0, { granularity: "grapheme" })), re;
3867
3875
  }
3868
- function kr(i) {
3876
+ function Lr(i) {
3869
3877
  return {
3870
3878
  widths: [],
3871
3879
  lineEndFitAdvances: [],
@@ -3882,7 +3890,7 @@ function kr(i) {
3882
3890
  segments: []
3883
3891
  };
3884
3892
  }
3885
- function Lr(i, e) {
3893
+ function Tr(i, e) {
3886
3894
  const t = [];
3887
3895
  let n = [], s = 0, r = !1, o = !1, a = !1;
3888
3896
  function l() {
@@ -3899,13 +3907,13 @@ function Lr(i, e) {
3899
3907
  const x = me(h);
3900
3908
  h.length === 1 && ht.has(h) ? o = o || x : o = x, a = !1;
3901
3909
  }
3902
- for (const h of Hn().segment(i)) {
3910
+ for (const h of In().segment(i)) {
3903
3911
  const u = h.segment, x = st(u);
3904
3912
  if (n.length === 0) {
3905
3913
  c(u, h.index, x);
3906
3914
  continue;
3907
3915
  }
3908
- if (a || ve.has(u) || ht.has(u) || e.carryCJKAfterClosingQuote && x && o) {
3916
+ if (a || Me.has(u) || ht.has(u) || e.carryCJKAfterClosingQuote && x && o) {
3909
3917
  d(u, x);
3910
3918
  continue;
3911
3919
  }
@@ -3917,7 +3925,7 @@ function Lr(i, e) {
3917
3925
  }
3918
3926
  return l(), t;
3919
3927
  }
3920
- function Tr(i, e, t) {
3928
+ function Or(i, e, t) {
3921
3929
  if (e.length <= 1)
3922
3930
  return e;
3923
3931
  const n = [];
@@ -3941,28 +3949,28 @@ function Tr(i, e, t) {
3941
3949
  }
3942
3950
  for (let l = 0; l < e.length; l++) {
3943
3951
  const c = e[l];
3944
- s >= 0 && !Ln(e[l - 1].text, t) && a(l), s < 0 && (s = l), r = r || st(c.text);
3952
+ s >= 0 && !Tn(e[l - 1].text, t) && a(l), s < 0 && (s = l), r = r || st(c.text);
3945
3953
  }
3946
3954
  return a(e.length), n;
3947
3955
  }
3948
- function Ke(i, e) {
3956
+ function Ve(i, e) {
3949
3957
  if (e === "zero-width-break" || e === "soft-hyphen" || e === "hard-break")
3950
3958
  return 0;
3951
3959
  if (e === "tab")
3952
3960
  return 1;
3953
3961
  let t = 0;
3954
- const n = Hn();
3962
+ const n = In();
3955
3963
  for (const s of n.segment(i))
3956
3964
  t++;
3957
3965
  return t;
3958
3966
  }
3959
- function Or(i, e, t) {
3967
+ function Pr(i, e, t) {
3960
3968
  return e > 1 ? i + (e - 1) * t : i;
3961
3969
  }
3962
- function Pr(i, e, t, n, s) {
3963
- const r = Qt(), { cache: o, emojiCorrection: a } = gr(e, dr(i.normalized)), l = lt("-", ot("-", o), a) + (s === 0 ? 0 : s * 2), d = lt(" ", ot(" ", o), a) * 8, h = s !== 0;
3970
+ function Rr(i, e, t, n, s) {
3971
+ const r = Qt(), { cache: o, emojiCorrection: a } = pr(e, hr(i.normalized)), l = lt("-", ot("-", o), a) + (s === 0 ? 0 : s * 2), d = lt(" ", ot(" ", o), a) * 8, h = s !== 0;
3964
3972
  if (i.len === 0)
3965
- return kr();
3973
+ return Lr();
3966
3974
  const u = [], x = [], f = [], p = [];
3967
3975
  let g = i.chunks.length <= 1 && !h;
3968
3976
  const E = t ? [] : null, y = [], F = [], C = t ? [] : null, A = Array.from({ length: i.len });
@@ -3970,11 +3978,11 @@ function Pr(i, e, t, n, s) {
3970
3978
  I !== "text" && I !== "space" && I !== "zero-width-break" && (g = !1), u.push(b), x.push(L), f.push(T), p.push(I), E == null || E.push(M), y.push(k), h && F.push(B), C !== null && C.push(D);
3971
3979
  }
3972
3980
  function N(D, b, L, T, I) {
3973
- const M = ot(D, o), k = h ? Ke(D, b) : 0, B = Or(lt(D, M, a), k, s), R = b === "space" || b === "preserved-space" || b === "zero-width-break" ? 0 : B, W = R === 0 ? 0 : R + (k > 0 ? s : 0), Y = b === "space" || b === "zero-width-break" ? 0 : B;
3981
+ const M = ot(D, o), k = h ? Ve(D, b) : 0, B = Pr(lt(D, M, a), k, s), R = b === "space" || b === "preserved-space" || b === "zero-width-break" ? 0 : B, W = R === 0 ? 0 : R + (k > 0 ? s : 0), Y = b === "space" || b === "zero-width-break" ? 0 : B;
3974
3982
  if (I && T && D.length > 1) {
3975
3983
  let U = "sum-graphemes";
3976
3984
  s !== 0 ? U = "segment-prefixes" : jt(D) ? U = "pair-context" : r.preferPrefixWidthsForBreakableRuns && (U = "segment-prefixes");
3977
- const V = fr(D, M, o, a, U);
3985
+ const V = gr(D, M, o, a, U);
3978
3986
  S(D, B, W, Y, b, L, V, k);
3979
3987
  return;
3980
3988
  }
@@ -3992,12 +4000,12 @@ function Pr(i, e, t, n, s) {
3992
4000
  continue;
3993
4001
  }
3994
4002
  if (T === "tab") {
3995
- S(b, 0, 0, 0, T, I, null, h ? Ke(b, T) : 0);
4003
+ S(b, 0, 0, 0, T, I, null, h ? Ve(b, T) : 0);
3996
4004
  continue;
3997
4005
  }
3998
4006
  const M = ot(b, o);
3999
4007
  if (T === "text" && M.containsCJK) {
4000
- const k = Lr(b, r), B = n === "keep-all" ? Tr(b, k, r.breakKeepAllAfterPunctuation) : k;
4008
+ const k = Tr(b, r), B = n === "keep-all" ? Or(b, k, r.breakKeepAllAfterPunctuation) : k;
4001
4009
  for (let R = 0; R < B.length; R++) {
4002
4010
  const W = B[R];
4003
4011
  N(W.text, "text", I + W.start, L, n === "keep-all" || !st(W.text));
@@ -4006,7 +4014,7 @@ function Pr(i, e, t, n, s) {
4006
4014
  }
4007
4015
  N(b, T, I, L, !0);
4008
4016
  }
4009
- const v = Rr(i.chunks, A, u.length), w = E === null ? null : ai(i.normalized, E);
4017
+ const v = Hr(i.chunks, A, u.length), w = E === null ? null : ci(i.normalized, E);
4010
4018
  return C !== null ? {
4011
4019
  widths: u,
4012
4020
  lineEndFitAdvances: x,
@@ -4036,7 +4044,7 @@ function Pr(i, e, t, n, s) {
4036
4044
  chunks: v
4037
4045
  };
4038
4046
  }
4039
- function Rr(i, e, t) {
4047
+ function Hr(i, e, t) {
4040
4048
  const n = [];
4041
4049
  for (let s = 0; s < i.length; s++) {
4042
4050
  const r = i[s], o = r.startSegmentIndex < e.length ? e[r.startSegmentIndex] : t, a = r.endSegmentIndex < e.length ? e[r.endSegmentIndex] : t, l = r.consumedEndSegmentIndex < e.length ? e[r.consumedEndSegmentIndex] : t;
@@ -4048,16 +4056,16 @@ function Rr(i, e, t) {
4048
4056
  }
4049
4057
  return n;
4050
4058
  }
4051
- function Hr(i, e, t, n) {
4052
- const s = (n == null ? void 0 : n.wordBreak) ?? "normal", r = (n == null ? void 0 : n.letterSpacing) ?? 0, o = sr(i, Qt(), n == null ? void 0 : n.whiteSpace, s);
4053
- return Pr(o, e, t, s, r);
4059
+ function Ir(i, e, t, n) {
4060
+ const s = (n == null ? void 0 : n.wordBreak) ?? "normal", r = (n == null ? void 0 : n.letterSpacing) ?? 0, o = ir(i, Qt(), n == null ? void 0 : n.whiteSpace, s);
4061
+ return Rr(o, e, t, s, r);
4054
4062
  }
4055
- function In(i, e, t) {
4056
- return Hr(i, e, !0, t);
4063
+ function zn(i, e, t) {
4064
+ return Ir(i, e, !0, t);
4057
4065
  }
4058
- function Ir(i, e, t, n, s, r, o) {
4066
+ function zr(i, e, t, n, s, r, o) {
4059
4067
  return {
4060
- text: Br(i, e, n, s, r, o),
4068
+ text: kr(i, e, n, s, r, o),
4061
4069
  width: t,
4062
4070
  start: {
4063
4071
  segmentIndex: n,
@@ -4069,16 +4077,16 @@ function Ir(i, e, t, n, s, r, o) {
4069
4077
  }
4070
4078
  };
4071
4079
  }
4072
- function zn(i, e, t) {
4080
+ function _n(i, e, t) {
4073
4081
  const n = [];
4074
4082
  if (i.widths.length === 0)
4075
4083
  return { lineCount: 0, height: 0, lines: n };
4076
- const s = Dr(i), r = Mr(i, e, (o, a, l, c, d) => {
4077
- n.push(Ir(i, s, o, a, l, c, d));
4084
+ const s = Br(i), r = br(i, e, (o, a, l, c, d) => {
4085
+ n.push(zr(i, s, o, a, l, c, d));
4078
4086
  });
4079
4087
  return { lineCount: r, height: r * t, lines: n };
4080
4088
  }
4081
- function zr(i, e, t = "box") {
4089
+ function _r(i, e, t = "box") {
4082
4090
  if (!i) {
4083
4091
  i = O("g"), i.setAttribute("data-annotation", `${e}`), i.setAttribute("data-annotation-type", t), i.classList.add(`annotation-${t}`);
4084
4092
  const n = O("rect");
@@ -4086,16 +4094,16 @@ function zr(i, e, t = "box") {
4086
4094
  }
4087
4095
  return i;
4088
4096
  }
4089
- function _n(i, e, t, n) {
4090
- const s = e.id, r = `class${s}`, o = K(e), a = zr(t, s, e.properties.type), { strokeColor: l, strokeWidth: c, strokeType: d, background: h, borderRadius: u, boxShadow: x } = e.properties.style || ss;
4097
+ function Un(i, e, t, n) {
4098
+ const s = e.id, r = `class${s}`, o = K(e), a = _r(t, s, e.properties.type), { strokeColor: l, strokeWidth: c, strokeType: d, background: h, borderRadius: u, boxShadow: x } = e.properties.style || is;
4091
4099
  a.classList.add("annotation-box"), a.setAttribute("fill", `${h || "transparent"}`);
4092
4100
  const f = a.firstChild;
4093
4101
  u && (f.setAttribute("rx", `${u}`), f.setAttribute("ry", `${u}`)), d && d !== "none" && (f.setAttribute("stroke", l || "black"), f.setAttribute("stroke-width", `${c}`), d === "dashed" && f.setAttribute("stroke-dasharray", "5,5")), h && h.length && (n.hoveredFeature === e.id ? f.setAttribute("fill", Pt(h)) : f.setAttribute("fill", h));
4094
4102
  const p = fe(e);
4095
4103
  return f.setAttribute("width", `${o.width}`), f.setAttribute("height", `${o.height}`), f.setAttribute("x", `${p.x}`), f.setAttribute("y", `${p.y}`), a.appendChild(f), x ? a.style.filter = `drop-shadow(${x})` : a.style.filter = "", a.setAttribute("transform", n.getRotationTransform(0, 0)), a.classList.add(r), a.setAttribute("data-annotation", `${e.id}`), a.setAttribute("data-annotation-type", e.properties.type), i.appendChild(a), a;
4096
4104
  }
4097
- const _r = Hs(), Ve = kn();
4098
- function Ur(i, e, t, n, s = !1) {
4105
+ const Ur = Is(), Ze = Ln();
4106
+ function Wr(i, e, t, n, s = !1) {
4099
4107
  const { width: r, height: o } = K(e), {
4100
4108
  color: a = j.color,
4101
4109
  strokeColor: l = j.strokeColor,
@@ -4104,7 +4112,7 @@ function Ur(i, e, t, n, s = !1) {
4104
4112
  background: h = j.background,
4105
4113
  borderRadius: u = j.borderRadius,
4106
4114
  fixedSize: x = j.fixedSize
4107
- } = e.properties.style || j, f = _n(i, e, t, n);
4115
+ } = e.properties.style || j, f = Un(i, e, t, n);
4108
4116
  f.setAttribute("data-annotation-type", e.properties.type), f.classList.add("annotation-text"), f.setAttribute("fill", `${a}`);
4109
4117
  let p = f.firstChild;
4110
4118
  for (; p; ) {
@@ -4116,28 +4124,28 @@ function Ur(i, e, t, n, s = !1) {
4116
4124
  const E = -r / 2, y = -o / 2;
4117
4125
  u && (g.setAttribute("rx", `${u}`), g.setAttribute("ry", `${u}`)), d && d !== "none" && (g.setAttribute("stroke", l || "black"), g.setAttribute("stroke-width", `${c}`), d === "dashed" && g.setAttribute("stroke-dasharray", "5,5")), h && h.length && (n.hoveredFeature === e.id ? g.setAttribute("fill", Pt(h)) : g.setAttribute("fill", h)), g.setAttribute("width", `${r}`), g.setAttribute("height", `${o}`);
4118
4126
  const F = Z(e);
4119
- return g.setAttribute("x", `${E}`), g.setAttribute("y", `${y}`), Xr(e, f, E, y, n, s), f.setAttribute(
4127
+ return g.setAttribute("x", `${E}`), g.setAttribute("y", `${y}`), Gr(e, f, E, y, n, s), f.setAttribute(
4120
4128
  "transform",
4121
4129
  n.getScreenAlignedTransform(F.x, F.y, !x)
4122
4130
  ), i.appendChild(f), f;
4123
4131
  }
4124
- let At = null;
4125
- const Ze = /* @__PURE__ */ new Map();
4126
- function Je(i, e) {
4127
- const t = `${i}|${e}`, n = Ze.get(t);
4132
+ let Nt = null;
4133
+ const Je = /* @__PURE__ */ new Map();
4134
+ function Qe(i, e) {
4135
+ const t = `${i}|${e}`, n = Je.get(t);
4128
4136
  if (n != null) return n;
4129
4137
  try {
4130
4138
  const s = document.createElement("div"), r = document.createElement("span");
4131
4139
  s.style.cssText = `font:${i};line-height:${e}px;position:fixed;left:-9999px;top:0;margin:0;padding:0;visibility:hidden;`, r.style.cssText = "display:inline-block;width:1px;height:1px;vertical-align:baseline;", s.appendChild(r), document.body.appendChild(s);
4132
4140
  const o = r.getBoundingClientRect().bottom - s.getBoundingClientRect().top;
4133
4141
  if (document.body.removeChild(s), o > 0 && o <= e)
4134
- return Ze.set(t, o), o;
4142
+ return Je.set(t, o), o;
4135
4143
  } catch {
4136
4144
  }
4137
4145
  try {
4138
- if (At || (At = document.createElement("canvas").getContext("2d")), At) {
4139
- At.font = i;
4140
- const s = At.measureText("M"), r = s.fontBoundingBoxAscent, o = s.fontBoundingBoxDescent;
4146
+ if (Nt || (Nt = document.createElement("canvas").getContext("2d")), Nt) {
4147
+ Nt.font = i;
4148
+ const s = Nt.measureText("M"), r = s.fontBoundingBoxAscent, o = s.fontBoundingBoxDescent;
4141
4149
  if (r != null && o != null)
4142
4150
  return Math.max(0, (e - r - o) / 2) + r;
4143
4151
  }
@@ -4151,7 +4159,7 @@ const _t = {
4151
4159
  color: "#8a8a8a",
4152
4160
  fontWeight: "normal"
4153
4161
  };
4154
- function Un(i, e) {
4162
+ function Wn(i, e) {
4155
4163
  return {
4156
4164
  font: (i == null ? void 0 : i.font) ?? (e == null ? void 0 : e.font) ?? _t.font,
4157
4165
  fontSize: (i == null ? void 0 : i.fontSize) ?? (e == null ? void 0 : e.fontSize) ?? _t.fontSize,
@@ -4159,22 +4167,22 @@ function Un(i, e) {
4159
4167
  fontWeight: (i == null ? void 0 : i.fontWeight) ?? (e == null ? void 0 : e.fontWeight) ?? _t.fontWeight
4160
4168
  };
4161
4169
  }
4162
- const Wr = 4;
4163
- function $r(i, e, t = !1) {
4170
+ const $r = 4;
4171
+ function Yr(i, e, t = !1) {
4164
4172
  var u, x, f, p, g;
4165
4173
  const n = (u = i.properties.author) == null ? void 0 : u.trim();
4166
4174
  if (((x = i.properties.style) == null ? void 0 : x.showAuthor) !== !0 || !n) return 0;
4167
4175
  const {
4168
4176
  fixedSize: s = j.fixedSize,
4169
4177
  padding: r = 0
4170
- } = i.properties.style || {}, o = Un(
4178
+ } = i.properties.style || {}, o = Wn(
4171
4179
  (f = i.properties.style) == null ? void 0 : f.authorStyle,
4172
4180
  (p = e == null ? void 0 : e.options) == null ? void 0 : p.authorStyle
4173
4181
  ), a = Xt(o.fontSize, void 0), l = s ? 1 : (e == null ? void 0 : e.zoom) ?? 1, c = ((g = e == null ? void 0 : e.options) == null ? void 0 : g.minReadableFontSize) ?? 0;
4174
4182
  return !t && c > 0 && a * l < c ? 0 : r + a * Tt;
4175
4183
  }
4176
- function Qe(i) {
4177
- const e = [], t = _r;
4184
+ function tn(i) {
4185
+ const e = [], t = Ur;
4178
4186
  t.lastIndex = 0;
4179
4187
  let n = 0, s = "", r;
4180
4188
  for (; (r = t.exec(i)) !== null; ) {
@@ -4184,31 +4192,31 @@ function Qe(i) {
4184
4192
  }
4185
4193
  return s += i.slice(n), { measureText: s, links: e };
4186
4194
  }
4187
- function tn(i) {
4195
+ function en(i) {
4188
4196
  if (i.length === 0)
4189
- return { pattern: Ve, hrefByToken: null };
4190
- const e = new Map(i.map((n) => [n.token, n.href])), t = i.map((n) => Is(n.token));
4191
- return t.push(Ve.source), { pattern: new RegExp(t.join("|"), "g"), hrefByToken: e };
4197
+ return { pattern: Ze, hrefByToken: null };
4198
+ const e = new Map(i.map((n) => [n.token, n.href])), t = i.map((n) => zs(n.token));
4199
+ return t.push(Ze.source), { pattern: new RegExp(t.join("|"), "g"), hrefByToken: e };
4192
4200
  }
4193
- function en(i, e, t) {
4201
+ function nn(i, e, t) {
4194
4202
  const { pattern: n, hrefByToken: s } = t;
4195
4203
  n.lastIndex = 0;
4196
4204
  let r = 0, o;
4197
4205
  for (; (o = n.exec(e)) !== null; ) {
4198
4206
  o.index > r && i.appendChild(document.createTextNode(e.slice(r, o.index)));
4199
4207
  const a = s == null ? void 0 : s.get(o[0]), l = a ?? o[0], c = a !== void 0 ? o[0].replace(/ /g, " ") : o[0], d = document.createElementNS("http://www.w3.org/2000/svg", "a");
4200
- d.setAttribute("href", l), d.setAttribute("target", "_blank"), d.setAttribute("rel", "noopener noreferrer"), d.setAttribute("class", Ae), d.textContent = c, i.appendChild(d), r = o.index + o[0].length;
4208
+ d.setAttribute("href", l), d.setAttribute("target", "_blank"), d.setAttribute("rel", "noopener noreferrer"), d.setAttribute("class", Ne), d.textContent = c, i.appendChild(d), r = o.index + o[0].length;
4201
4209
  }
4202
4210
  r < e.length && i.appendChild(document.createTextNode(e.slice(r)));
4203
4211
  }
4204
- function Yr(i, e, t) {
4205
- const n = In(i, e, {
4212
+ function Xr(i, e, t) {
4213
+ const n = zn(i, e, {
4206
4214
  whiteSpace: "pre-wrap",
4207
4215
  wordBreak: "normal"
4208
- }), { lines: s } = zn(n, t, 1e6);
4216
+ }), { lines: s } = _n(n, t, 1e6);
4209
4217
  return s.length === 0 ? "" : s.length === 1 ? s[0].text : s[0].text.trimEnd() + "…";
4210
4218
  }
4211
- function Xr(i, e, t = 0, n = 0, s, r = !1) {
4219
+ function Gr(i, e, t = 0, n = 0, s, r = !1) {
4212
4220
  var k, B, R, W, Y;
4213
4221
  const { width: o, height: a } = K(i), {
4214
4222
  fontSize: l = j.fontSize,
@@ -4219,12 +4227,12 @@ function Xr(i, e, t = 0, n = 0, s, r = !1) {
4219
4227
  fixedSize: x = j.fixedSize
4220
4228
  } = i.properties.style || {};
4221
4229
  if (o === a && o === 0) return;
4222
- const f = Xt(l, h), p = f * Tt, g = `${u === "bold" ? "bold " : ""}${f}px ${c}`.replace(/(px)+/g, "px"), E = o - d * 2, y = x ? 1 : (s == null ? void 0 : s.zoom) ?? 1, F = ((k = s == null ? void 0 : s.options) == null ? void 0 : k.minReadableFontSize) ?? 0, C = !r && F > 0, A = C && f * y < F, S = (B = i.properties.author) == null ? void 0 : B.trim(), N = ((R = i.properties.style) == null ? void 0 : R.showAuthor) === !0 && !!S, v = N ? Un((W = i.properties.style) == null ? void 0 : W.authorStyle, (Y = s == null ? void 0 : s.options) == null ? void 0 : Y.authorStyle) : null, w = v ? Xt(v.fontSize, void 0) : 0, D = C && w * y < F, b = N && !D, L = b ? w * Tt : 0, T = b ? L + Wr : 0, I = a - d - T, M = i.properties.content || "";
4230
+ const f = Xt(l, h), p = f * Tt, g = `${u === "bold" ? "bold " : ""}${f}px ${c}`.replace(/(px)+/g, "px"), E = o - d * 2, y = x ? 1 : (s == null ? void 0 : s.zoom) ?? 1, F = ((k = s == null ? void 0 : s.options) == null ? void 0 : k.minReadableFontSize) ?? 0, C = !r && F > 0, A = C && f * y < F, S = (B = i.properties.author) == null ? void 0 : B.trim(), N = ((R = i.properties.style) == null ? void 0 : R.showAuthor) === !0 && !!S, v = N ? Wn((W = i.properties.style) == null ? void 0 : W.authorStyle, (Y = s == null ? void 0 : s.options) == null ? void 0 : Y.authorStyle) : null, w = v ? Xt(v.fontSize, void 0) : 0, D = C && w * y < F, b = N && !D, L = b ? w * Tt : 0, T = b ? L + $r : 0, I = a - d - T, M = i.properties.content || "";
4223
4231
  if (M.length > 0 && !A) {
4224
- const { measureText: U, links: V } = Qe(M), ct = tn(V), Ht = In(U, g, {
4232
+ const { measureText: U, links: V } = tn(M), ct = en(V), Ht = zn(U, g, {
4225
4233
  whiteSpace: "pre-wrap",
4226
4234
  wordBreak: "normal"
4227
- }), { lines: xt } = zn(Ht, E, p), ft = Math.max(1, Math.floor(I / p)), X = xt.slice(0, ft);
4235
+ }), { lines: xt } = _n(Ht, E, p), ft = Math.max(1, Math.floor(I / p)), X = xt.slice(0, ft);
4228
4236
  if (xt.length > ft && X.length > 0) {
4229
4237
  const It = X[X.length - 1];
4230
4238
  X[X.length - 1] = {
@@ -4237,17 +4245,17 @@ function Xr(i, e, t = 0, n = 0, s, r = !1) {
4237
4245
  "transform",
4238
4246
  `translate(${t + d}, ${n + d})`
4239
4247
  );
4240
- const gt = Je(g, p);
4241
- X.forEach((It, qn) => {
4248
+ const gt = Qe(g, p);
4249
+ X.forEach((It, Kn) => {
4242
4250
  const zt = O("tspan");
4243
- zt.setAttribute("x", "0"), zt.setAttribute("y", `${gt + qn * p}`), en(zt, It.text, ct), it.appendChild(zt);
4251
+ zt.setAttribute("x", "0"), zt.setAttribute("y", `${gt + Kn * p}`), nn(zt, It.text, ct), it.appendChild(zt);
4244
4252
  }), e.appendChild(it);
4245
4253
  }
4246
4254
  if (b && v) {
4247
4255
  const U = `${v.fontWeight === "bold" ? "bold " : ""}${w}px ${v.font}`.replace(
4248
4256
  /(px)+/g,
4249
4257
  "px"
4250
- ), V = o - d * 2, { measureText: ct, links: Ht } = Qe(S), xt = tn(Ht), ft = Yr(
4258
+ ), V = o - d * 2, { measureText: ct, links: Ht } = tn(S), xt = en(Ht), ft = Xr(
4251
4259
  ct,
4252
4260
  U,
4253
4261
  V
@@ -4256,11 +4264,11 @@ function Xr(i, e, t = 0, n = 0, s, r = !1) {
4256
4264
  const it = n + a - d - L;
4257
4265
  X.setAttribute("transform", `translate(${t + d}, ${it})`);
4258
4266
  const gt = O("tspan");
4259
- gt.setAttribute("x", "0"), gt.setAttribute("dy", `${Je(U, L)}`), en(gt, ft, xt), X.appendChild(gt), e.appendChild(X);
4267
+ gt.setAttribute("x", "0"), gt.setAttribute("dy", `${Qe(U, L)}`), nn(gt, ft, xt), X.appendChild(gt), e.appendChild(X);
4260
4268
  }
4261
4269
  }
4262
- const Gr = 24, jr = 4, qr = 16, Kr = 50;
4263
- class Vr {
4270
+ const jr = 24, qr = 4, Kr = 16, Vr = 50;
4271
+ class Zr {
4264
4272
  constructor(e, t, n, s = () => {
4265
4273
  }) {
4266
4274
  m(this, "layer");
@@ -4312,7 +4320,7 @@ class Vr {
4312
4320
  // Non-fixedSize annotations live in graph space and scale naturally.
4313
4321
  scaled: !this.fixedSize
4314
4322
  },
4315
- Ee.EDITOR
4323
+ Ae.EDITOR
4316
4324
  ), this.layer.moveToTop(), this.textarea = this.layer.element.querySelector("textarea"), this.textarea.setAttribute("wrap", "on"), this.textarea.setAttribute("spellcheck", "false"), this.textarea.value = r.properties.content || "", a && (this.sendButton = this.layer.element.querySelector(".ogma-send-button"), this.sendButton.addEventListener("click", this.onSendClick), this.updateSendButtonState()), this.isFocused = !1, this.textarea.addEventListener("focus", this.onFocus), this.textarea.addEventListener("blur", this.onBlur), this.textarea.addEventListener("input", this.onInput), this.textarea.addEventListener("keyup", this.onKeyup), this.textarea.addEventListener("keydown", this.onKeydown), this.textarea.addEventListener("wheel", this.onMouseEvent), this.textarea.addEventListener("mouseup", this.onMouseEvent), this.textarea.addEventListener("mousedown", this.onMouseEvent), this.textarea.addEventListener("click", this.onMouseEvent), this.textarea.addEventListener("drag", this.onMouseEvent), this.updateStyle(), this.updatePosition(), this.textarea.focus(), this.unsubscribe = this.store.subscribe(
4317
4325
  (C) => ({
4318
4326
  rotation: C.rotation,
@@ -4334,7 +4342,7 @@ class Vr {
4334
4342
  getPosition() {
4335
4343
  const e = this.getAnnotation();
4336
4344
  if (!e) return { x: 0, y: 0 };
4337
- const t = e.properties.style, n = t == null ? void 0 : t.maxHeight, s = this.store.getState().zoom, r = nn(e), [o, a] = e.geometry.coordinates, l = e.properties.width;
4345
+ const t = e.properties.style, n = t == null ? void 0 : t.maxHeight, s = this.store.getState().zoom, r = sn(e), [o, a] = e.geometry.coordinates, l = e.properties.width;
4338
4346
  let c = e.properties.height;
4339
4347
  n && (c = Math.min(c, n));
4340
4348
  const d = this.fixedSize ? 1 / s : 1;
@@ -4346,10 +4354,10 @@ class Vr {
4346
4354
  getSize() {
4347
4355
  const e = this.getAnnotation();
4348
4356
  if (!e) return { width: 0, height: 0 };
4349
- const t = K(e), n = nn(e), s = e.properties.style, r = s == null ? void 0 : s.maxHeight;
4357
+ const t = K(e), n = sn(e), s = e.properties.style, r = s == null ? void 0 : s.maxHeight;
4350
4358
  let o = t.height - n * 2;
4351
4359
  r && (o = Math.min(o, r - n * 2));
4352
- const a = $r(
4360
+ const a = Yr(
4353
4361
  e,
4354
4362
  this.store.getState()
4355
4363
  );
@@ -4379,13 +4387,13 @@ class Vr {
4379
4387
  }
4380
4388
  const F = u.style;
4381
4389
  if (F.fontFamily = n || "sans-serif", F.fontWeight = h || "normal", F.fontSize = `${g}px`, F.lineHeight = `${g * Tt}px`, F.padding = "0", F.border = "none", F.outline = "none", F.boxSizing = "border-box", F.color = o || "black", F.background = "transparent", F.flex = "1", F.minHeight = "0", F.resize = "none", this.sendButton) {
4382
- const A = Gr * f, S = jr * f;
4390
+ const A = jr * f, S = qr * f;
4383
4391
  this.sendButton.style.width = `${A}px`, this.sendButton.style.height = `${A}px`, this.sendButton.style.padding = `${S}px`, this.sendButton.style.transform = "";
4384
4392
  const N = this.sendButton.querySelector(
4385
4393
  ".ogma-send-button-icon"
4386
4394
  );
4387
4395
  if (N) {
4388
- const v = qr * f;
4396
+ const v = Kr * f;
4389
4397
  N.style.width = `${v}px`, N.style.height = `${v}px`;
4390
4398
  }
4391
4399
  }
@@ -4408,7 +4416,7 @@ class Vr {
4408
4416
  this.textarea.style.height = "0px";
4409
4417
  const h = this.textarea.scrollHeight;
4410
4418
  this.textarea.style.height = d;
4411
- const u = ((a = e.properties.style) == null ? void 0 : a.padding) || 0, x = this.sendButton ? parseFloat(this.sendButton.style.height || "0") : 0, f = h + u * 2 + x, p = ((l = e.properties.style) == null ? void 0 : l.minHeight) || Kr;
4419
+ const u = ((a = e.properties.style) == null ? void 0 : a.padding) || 0, x = this.sendButton ? parseFloat(this.sendButton.style.height || "0") : 0, f = h + u * 2 + x, p = ((l = e.properties.style) == null ? void 0 : l.minHeight) || Vr;
4412
4420
  t = Math.max(p, f);
4413
4421
  const g = (c = e.properties.style) == null ? void 0 : c.maxHeight, E = e.properties.height, y = t - E;
4414
4422
  if (!H(e) && Math.abs(y) > 1) {
@@ -4447,21 +4455,21 @@ class Vr {
4447
4455
  this.store.getState().commitLiveUpdates(/* @__PURE__ */ new Set([this.annotation])), this.unsubscribe(), this.sendButton && this.sendButton.removeEventListener("click", this.onSendClick), this.layer.destroy();
4448
4456
  }
4449
4457
  }
4450
- function nn(i) {
4458
+ function sn(i) {
4451
4459
  var e;
4452
4460
  return ((e = i.properties.style) == null ? void 0 : e.strokeWidth) || 0;
4453
4461
  }
4454
- const sn = { x: 1, y: 0 }, rn = { x: 0, y: 1 }, Zr = [
4455
- ["top", rn, -0.5, -0.5, 0.5, -0.5],
4456
- ["right", sn, 0.5, -0.5, 0.5, 0.5],
4457
- ["bottom", rn, -0.5, 0.5, 0.5, 0.5],
4458
- ["left", sn, -0.5, -0.5, -0.5, 0.5]
4459
- ], Jr = {
4462
+ const rn = { x: 1, y: 0 }, on = { x: 0, y: 1 }, Jr = [
4463
+ ["top", on, -0.5, -0.5, 0.5, -0.5],
4464
+ ["right", rn, 0.5, -0.5, 0.5, 0.5],
4465
+ ["bottom", on, -0.5, 0.5, 0.5, 0.5],
4466
+ ["left", rn, -0.5, -0.5, -0.5, 0.5]
4467
+ ], Qr = {
4460
4468
  top: [0, 1],
4461
4469
  right: [1, 2],
4462
4470
  bottom: [2, 3],
4463
4471
  left: [3, 0]
4464
- }, on = [
4472
+ }, an = [
4465
4473
  [-0.5, -0.5],
4466
4474
  // top-left (index 0)
4467
4475
  [0.5, -0.5],
@@ -4470,7 +4478,7 @@ const sn = { x: 1, y: 0 }, rn = { x: 0, y: 1 }, Zr = [
4470
4478
  // bottom-right (index 2)
4471
4479
  [-0.5, 0.5]
4472
4480
  // bottom-left (index 3)
4473
- ], Qr = [
4481
+ ], to = [
4474
4482
  z.nwResize,
4475
4483
  // top-left (0)
4476
4484
  z.neResize,
@@ -4479,7 +4487,7 @@ const sn = { x: 1, y: 0 }, rn = { x: 0, y: 1 }, Zr = [
4479
4487
  // bottom-right (2)
4480
4488
  z.swResize
4481
4489
  // bottom-left (3)
4482
- ], to = 100, eo = 50;
4490
+ ], eo = 100, no = 50;
4483
4491
  class oe extends Kt {
4484
4492
  constructor(t, n, s) {
4485
4493
  super(t, n);
@@ -4497,7 +4505,7 @@ class oe extends Kt {
4497
4505
  m(this, "onClick", (t) => {
4498
4506
  if (wt(t.target ?? null)) return;
4499
4507
  const n = this.getAnnotation();
4500
- if (n) {
4508
+ if (n && this.store.getState().options.isEditable(n)) {
4501
4509
  if (H(n) && n.properties.mode === Dt) {
4502
4510
  this.store.getState().updateFeature(n.id, {
4503
4511
  properties: {
@@ -4525,13 +4533,13 @@ class oe extends Kt {
4525
4533
  var C;
4526
4534
  const s = this.getAnnotation(), { x: r, y: o } = this.clientToCanvas(t);
4527
4535
  let { width: a, height: l } = K(s);
4528
- const c = ye / n, d = Z(s), h = this.store.getState();
4536
+ const c = Ee / n, d = Z(s), h = this.store.getState();
4529
4537
  let { revSin: u, revCos: x } = h;
4530
4538
  (G(s) || H(s)) && (u = 0, x = 1), this.hoveredHandle = void 0;
4531
- const f = os * (1 / n), p = r - d.x, g = o - d.y, E = p * x - g * u, y = p * u + g * x, F = ((C = s.properties.style) == null ? void 0 : C.fixedSize) === !0 || H(s);
4539
+ const f = as * (1 / n), p = r - d.x, g = o - d.y, E = p * x - g * u, y = p * u + g * x, F = ((C = s.properties.style) == null ? void 0 : C.fixedSize) === !0 || H(s);
4532
4540
  if (F && (a /= n, l /= n), !F) {
4533
- for (let A = 0; A < on.length; A++) {
4534
- const [S, N] = on[A], v = a * S, w = l * N;
4541
+ for (let A = 0; A < an.length; A++) {
4542
+ const [S, N] = an[A], v = a * S, w = l * N;
4535
4543
  if (E >= v - f - c && E <= v + f + c && y >= w - f - c && y <= w + f + c) {
4536
4544
  this.hoveredHandle = {
4537
4545
  type: "corner",
@@ -4540,10 +4548,10 @@ class oe extends Kt {
4540
4548
  return;
4541
4549
  }
4542
4550
  }
4543
- for (const [A, S, N, v, w, D] of Zr) {
4551
+ for (const [A, S, N, v, w, D] of Jr) {
4544
4552
  const b = a * N, L = l * v, T = a * w, I = l * D, M = Ot(S, { x: E - b, y: y - L });
4545
4553
  if (Math.abs(M) < c && E >= b - c && E <= T + c && y >= L - c && y <= I + c) {
4546
- this.hoveredHandle = { type: "edge", edge: A, corner: -1 }, this.store.setState({ hoveredHandle: Jr[A][0] + 4, hoveredFeature: this.annotation }), this.setCursor(this.getEdgeCursor(A));
4554
+ this.hoveredHandle = { type: "edge", edge: A, corner: -1 }, this.store.setState({ hoveredHandle: Qr[A][0] + 4, hoveredFeature: this.annotation }), this.setCursor(this.getEdgeCursor(A));
4547
4555
  return;
4548
4556
  }
4549
4557
  }
@@ -4562,7 +4570,7 @@ class oe extends Kt {
4562
4570
  y: s.y - this.dragStartPoint.y
4563
4571
  }, o = this.hoveredHandle, a = this.getAnnotation();
4564
4572
  let l = null;
4565
- o.type === "corner" ? l = this.dragCorner(a, r, o.corner) : o.type === "edge" && o.edge ? l = this.dragEdge(a, r, o) : o.type === "body" && (Ne(this.store, this.links, n.id, r), this.textEditor && this.textEditor.update()), l && (this.store.getState().applyLiveUpdate(n.id, l), this.links.updateLinkedArrowsDuringDrag(n.id, r), this.textEditor && this.textEditor.update()), this.dispatchEvent(
4573
+ o.type === "corner" ? l = this.dragCorner(a, r, o.corner) : o.type === "edge" && o.edge ? l = this.dragEdge(a, r, o) : o.type === "body" && (Ce(this.store, this.links, n.id, r), this.textEditor && this.textEditor.update()), l && (this.store.getState().applyLiveUpdate(n.id, l), this.links.updateLinkedArrowsDuringDrag(n.id, r), this.textEditor && this.textEditor.update()), this.dispatchEvent(
4566
4574
  new CustomEvent(qt, {
4567
4575
  detail: {
4568
4576
  point: s,
@@ -4583,8 +4591,8 @@ class oe extends Kt {
4583
4591
  if (!(a != null && a.scaleFontOnResize) || n <= 0 || s <= 0 || r <= 0 || o <= 0)
4584
4592
  return a;
4585
4593
  const l = Math.sqrt(r / n * (o / s)), c = Math.min(
4586
- is,
4587
- Math.max(rs, (a.fontScale ?? 1) * l)
4594
+ rs,
4595
+ Math.max(os, (a.fontScale ?? 1) * l)
4588
4596
  );
4589
4597
  return { ...a, fontScale: c };
4590
4598
  }
@@ -4679,7 +4687,7 @@ class oe extends Kt {
4679
4687
  const n = this.getAnnotation();
4680
4688
  if (!n || !(G(n) || _(n)) || (l = n.properties.style) != null && l.fixedSize || n.properties.width > 0 && n.properties.height > 0)
4681
4689
  return;
4682
- const s = (t == null ? void 0 : t.width) ?? to, r = (t == null ? void 0 : t.height) ?? eo, [o, a] = n.geometry.coordinates;
4690
+ const s = (t == null ? void 0 : t.width) ?? eo, r = (t == null ? void 0 : t.height) ?? no, [o, a] = n.geometry.coordinates;
4683
4691
  this.store.getState().updateFeature(n.id, {
4684
4692
  properties: { ...n.properties, width: s, height: r },
4685
4693
  geometry: {
@@ -4689,7 +4697,7 @@ class oe extends Kt {
4689
4697
  });
4690
4698
  }
4691
4699
  startEditingText() {
4692
- this.textEditor === null && (this.store.setState({ editingFeature: this.annotation }), this.textEditor = new Vr(
4700
+ this.textEditor === null && (this.store.setState({ editingFeature: this.annotation }), this.textEditor = new Zr(
4693
4701
  this.ogma,
4694
4702
  this.store,
4695
4703
  this.annotation,
@@ -4714,7 +4722,7 @@ class oe extends Kt {
4714
4722
  return this.hoveredHandle = void 0, this.dragStartPoint = void 0, this.dragging = !1, !0;
4715
4723
  }
4716
4724
  getCornerCursor(t) {
4717
- return Qr[t];
4725
+ return to[t];
4718
4726
  }
4719
4727
  getEdgeCursor(t) {
4720
4728
  switch (t) {
@@ -4749,7 +4757,12 @@ class oe extends Kt {
4749
4757
  corner: 2
4750
4758
  }, this.store.setState({ hoveredHandle: 2, hoveredFeature: this.annotation }), this.dragging = !0;
4751
4759
  const o = this.ogma.view.graphToScreenCoordinates({ x: n, y: s });
4752
- this.dragStartPoint = o, this.disablePanning(), this.onDragStart({ clientX: o.x, clientY: o.y });
4760
+ this.dragStartPoint = o, this.disablePanning();
4761
+ const a = ye(o, this.ogma.getContainer());
4762
+ this.onDragStart({
4763
+ clientX: a.x,
4764
+ clientY: a.y
4765
+ });
4753
4766
  }
4754
4767
  setAnnotation(t) {
4755
4768
  t && H(t) && (this.justActivated = !0), super.setAnnotation(t), t && H(t) && t.properties.mode === Dt && this.store.getState().updateFeature(t.id, {
@@ -4760,8 +4773,8 @@ class oe extends Kt {
4760
4773
  });
4761
4774
  }
4762
4775
  }
4763
- const Wn = "mousedown-annotation";
4764
- class no extends EventTarget {
4776
+ const $n = "mousedown-annotation";
4777
+ class so extends EventTarget {
4765
4778
  constructor(t, n, s) {
4766
4779
  super();
4767
4780
  m(this, "query", {
@@ -4785,7 +4798,7 @@ class no extends EventTarget {
4785
4798
  this.store.setState({ isDragging: !1 });
4786
4799
  });
4787
4800
  m(this, "onMouseMove", (t) => {
4788
- const n = vt(
4801
+ const n = yt(
4789
4802
  t,
4790
4803
  this.ogma.getContainer()
4791
4804
  ), s = this.store.getState();
@@ -4807,7 +4820,7 @@ class no extends EventTarget {
4807
4820
  // its own handle, even when that handle sits exactly on a node/edge.
4808
4821
  m(this, "onMouseDownArm", (t) => {
4809
4822
  if (Date.now() < this.suppressClickUntil || wt(t.target)) return;
4810
- const n = vt(
4823
+ const n = yt(
4811
4824
  t,
4812
4825
  this.ogma.getContainer()
4813
4826
  ), { x: s, y: r } = this.ogma.view.screenToGraphCoordinates(n);
@@ -4824,7 +4837,7 @@ class no extends EventTarget {
4824
4837
  this.mouseDownState = null;
4825
4838
  return;
4826
4839
  }
4827
- const n = vt(
4840
+ const n = yt(
4828
4841
  t,
4829
4842
  this.ogma.getContainer()
4830
4843
  ), { x: s, y: r } = this.ogma.view.screenToGraphCoordinates(n), o = this.detect(s, r), a = this.store.getState(), l = o ? a.selectedFeatures.has(o.id) : !1;
@@ -4840,7 +4853,7 @@ class no extends EventTarget {
4840
4853
  interactions: { pan: { enabled: !1 }, drag: { enabled: !1 } }
4841
4854
  });
4842
4855
  }
4843
- o && !l && (t.ctrlKey || t.metaKey ? a.toggleSelection(o.id) : a.setSelectedFeatures([o.id])), o && this.dispatchEvent(new CustomEvent(Wn, {
4856
+ o && !l && (t.ctrlKey || t.metaKey ? a.toggleSelection(o.id) : a.setSelectedFeatures([o.id])), o && this.dispatchEvent(new CustomEvent($n, {
4844
4857
  detail: { id: o.id }
4845
4858
  }));
4846
4859
  });
@@ -4872,7 +4885,7 @@ class no extends EventTarget {
4872
4885
  m(this, "onWheel", (t) => {
4873
4886
  var h;
4874
4887
  if (t.target instanceof HTMLTextAreaElement) return;
4875
- const n = vt(
4888
+ const n = yt(
4876
4889
  t,
4877
4890
  this.ogma.getContainer()
4878
4891
  ), { x: s, y: r } = this.ogma.view.screenToGraphCoordinates(n), o = this.detect(s, r);
@@ -4924,22 +4937,22 @@ class no extends EventTarget {
4924
4937
  for (const h of d) {
4925
4938
  const u = o.getFeature(h.id);
4926
4939
  if (Q(u)) {
4927
- if (pn(u, { x: t, y: n }, a)) {
4940
+ if (mn(u, { x: t, y: n }, a)) {
4928
4941
  r = u;
4929
4942
  break;
4930
4943
  }
4931
4944
  } else if (G(u)) {
4932
- if (as(u, { x: t, y: n }, 0, 1, a)) {
4945
+ if (cs(u, { x: t, y: n }, 0, 1, a)) {
4933
4946
  r = u;
4934
4947
  break;
4935
4948
  }
4936
4949
  } else if (J(u)) {
4937
- if (mn(u, { x: t, y: n }, a)) {
4950
+ if (Sn(u, { x: t, y: n }, a)) {
4938
4951
  r = u;
4939
4952
  break;
4940
4953
  }
4941
4954
  } else if (H(u)) {
4942
- if (cs(
4955
+ if (ls(
4943
4956
  u,
4944
4957
  { x: t, y: n },
4945
4958
  a,
@@ -4950,7 +4963,7 @@ class no extends EventTarget {
4950
4963
  r = u;
4951
4964
  break;
4952
4965
  }
4953
- } else if (_(u) && ls(
4966
+ } else if (_(u) && ds(
4954
4967
  u,
4955
4968
  { x: t, y: n },
4956
4969
  a,
@@ -4987,7 +5000,7 @@ class no extends EventTarget {
4987
5000
  t && (t.removeEventListener("mousemove", this.onMouseMove, !0), t.removeEventListener("click", this.onMouseClick, !0), t.removeEventListener("mousedown", this.onMouseDownArm, !0), t.removeEventListener("mousedown", this.onMouseDown, !1), t.removeEventListener("mouseup", this.onMouseUp, !0), t.removeEventListener("wheel", this.onWheel, !0)), this.ogma.events.off(this.onNativeDragStart), this.ogma.events.off(this.onNativeDragEnd);
4988
5001
  }
4989
5002
  }
4990
- class so extends EventTarget {
5003
+ class io extends EventTarget {
4991
5004
  constructor(t, n, s, r, o) {
4992
5005
  super();
4993
5006
  m(this, "handlers", /* @__PURE__ */ new Map());
@@ -4998,10 +5011,10 @@ class so extends EventTarget {
4998
5011
  m(this, "store");
4999
5012
  this.ogma = t, this.store = n, this.snapping = s, this.interaction = o, this.handlers.set("box", new oe(this.ogma, this.store, r)), this.handlers.set("text", new oe(this.ogma, this.store, r)), this.handlers.set("comment", new oe(this.ogma, this.store, r)), this.handlers.set(
5000
5013
  "arrow",
5001
- new ei(this.ogma, this.store, this.snapping, r)
5014
+ new ni(this.ogma, this.store, this.snapping, r)
5002
5015
  ), this.handlers.set(
5003
5016
  "polygon",
5004
- new si(this.ogma, this.store, r)
5017
+ new ii(this.ogma, this.store, r)
5005
5018
  ), this.handlers.forEach((a) => {
5006
5019
  a.addEventListener("dragstart", ((l) => {
5007
5020
  this.dispatchEvent(
@@ -5020,7 +5033,7 @@ class so extends EventTarget {
5020
5033
  })
5021
5034
  ), this.store.setState({ isDragging: !1 }), this.interaction.suppressClicksTemporarily();
5022
5035
  }));
5023
- }), this.interaction.addEventListener(Wn, ((a) => {
5036
+ }), this.interaction.addEventListener($n, ((a) => {
5024
5037
  const l = a.detail.id, c = this.store.getState().features[l], d = c && this.handlers.get(c.properties.type);
5025
5038
  d && !d.isAnnotation(l) && this.editFeature(l);
5026
5039
  })), this.store.subscribe(
@@ -5044,7 +5057,13 @@ class so extends EventTarget {
5044
5057
  editFeature(t) {
5045
5058
  var s;
5046
5059
  const n = this.store.getState().features[t];
5047
- n && (this.setActiveHandler(n.properties.type), this.store.getState().options.isEditable(n) && ((s = this.activeHandler) == null || s.setAnnotation(n)));
5060
+ if (n) {
5061
+ if (this.setActiveHandler(n.properties.type), !this.store.getState().options.isEditable(n)) {
5062
+ this.stopEditingFeature(t);
5063
+ return;
5064
+ }
5065
+ (s = this.activeHandler) == null || s.setAnnotation(n);
5066
+ }
5048
5067
  }
5049
5068
  getSnapping() {
5050
5069
  return this.snapping;
@@ -5064,7 +5083,7 @@ class so extends EventTarget {
5064
5083
  destroy() {
5065
5084
  }
5066
5085
  }
5067
- function $n(i, e, t, n, s) {
5086
+ function Yn(i, e, t, n, s) {
5068
5087
  const r = e.get(n);
5069
5088
  if (!r) return;
5070
5089
  const o = s.side === q ? r.end : r.start;
@@ -5076,7 +5095,7 @@ function $n(i, e, t, n, s) {
5076
5095
  function Fe(i, e) {
5077
5096
  if (!e || e.targetType !== P.COMMENT) return;
5078
5097
  const t = i.getState().getFeature(e.target);
5079
- if (!(!t || !H(t)) && ds(t))
5098
+ if (!(!t || !H(t)) && hs(t))
5080
5099
  return t;
5081
5100
  }
5082
5101
  function $t(i, e, t, n) {
@@ -5089,8 +5108,8 @@ function $t(i, e, t, n) {
5089
5108
  };
5090
5109
  t[i.id] = o, Lt(o), n.add(i.id);
5091
5110
  }
5092
- const io = 0.5;
5093
- class ro {
5111
+ const ro = 0.5;
5112
+ class oo {
5094
5113
  constructor(e, t) {
5095
5114
  m(this, "ogma");
5096
5115
  m(this, "store");
@@ -5135,11 +5154,11 @@ class ro {
5135
5154
  return this.getAnnotationSnapPoint(o, s, e, r.zoom);
5136
5155
  }
5137
5156
  getAnnotationCenter(e) {
5138
- return J(e) ? Mn(e) : Z(e);
5157
+ return J(e) ? bn(e) : Z(e);
5139
5158
  }
5140
5159
  getAnnotationSnapPoint(e, t, n, s) {
5141
5160
  if (J(e)) {
5142
- const r = vn(e), o = n.magnet, a = r[0] + o.rx * (r[2] - r[0]), l = r[1] + o.ry * (r[3] - r[1]);
5161
+ const r = Mn(e), o = n.magnet, a = r[0] + o.rx * (r[2] - r[0]), l = r[1] + o.ry * (r[3] - r[1]);
5143
5162
  return [a, l];
5144
5163
  }
5145
5164
  return this.getBoxSnapPoint(e, t, n, s);
@@ -5147,7 +5166,7 @@ class ro {
5147
5166
  getBoxSnapPoint(e, t, n, s) {
5148
5167
  var u;
5149
5168
  const r = Z(e);
5150
- let { width: o, height: a } = H(e) ? hs(e) : K(e);
5169
+ let { width: o, height: a } = H(e) ? us(e) : K(e);
5151
5170
  (_(e) && ((u = e.properties.style) == null ? void 0 : u.fixedSize) || H(e)) && (o /= s, a /= s);
5152
5171
  const c = n.magnet;
5153
5172
  let d = c.nx * o, h = c.ny * a;
@@ -5159,7 +5178,7 @@ class ro {
5159
5178
  }
5160
5179
  getNodeSnapPoint(e, t, n) {
5161
5180
  if (n) return [e.x, e.y];
5162
- const s = Math.sqrt(t.x * t.x + t.y * t.y), r = nt(t, 1 / s), o = s < Number(e.radius) * io ? { x: e.x, y: e.y } : dt({ x: e.x, y: e.y }, nt(r, -Number(e.radius)));
5181
+ const s = Math.sqrt(t.x * t.x + t.y * t.y), r = nt(t, 1 / s), o = s < Number(e.radius) * ro ? { x: e.x, y: e.y } : dt({ x: e.x, y: e.y }, nt(r, -Number(e.radius)));
5163
5182
  return [o.x, o.y];
5164
5183
  }
5165
5184
  getEdgeSnapPoint(e, t, n = !1) {
@@ -5191,10 +5210,10 @@ class ro {
5191
5210
  return n ? { x: h.x, y: h.y } : [h.x, h.y];
5192
5211
  }
5193
5212
  }
5194
- function oo(i, e) {
5213
+ function ao(i, e) {
5195
5214
  return e === P.NODE ? { type: "node", center: i.x === 0 && i.y === 0 } : e === P.EDGE ? { type: "edge", t: i.x } : e === P.POLYGON ? { type: "polygon", rx: i.x, ry: i.y } : { type: "box", nx: i.x, ny: i.y };
5196
5215
  }
5197
- class ao {
5216
+ class co {
5198
5217
  constructor(e, t, n) {
5199
5218
  m(this, "links", /* @__PURE__ */ new Map());
5200
5219
  m(this, "nodeToLink", /* @__PURE__ */ new Map());
@@ -5207,12 +5226,12 @@ class ao {
5207
5226
  this.ogma = e, this.store = t, this.onLinkCreated = n;
5208
5227
  }
5209
5228
  add(e, t, n, s, r, o = "absolute") {
5210
- const a = us(), l = e.id;
5229
+ const a = xs(), l = e.id;
5211
5230
  let c = r;
5212
5231
  if (s === P.POLYGON && o === "absolute") {
5213
5232
  const x = this.store.getState().getFeature(n);
5214
5233
  if (x && J(x)) {
5215
- const f = vn(x), p = f[2] - f[0], g = f[3] - f[1], E = r.x - f[0], y = r.y - f[1], F = p > 0 ? E / p : 0.5, C = g > 0 ? y / g : 0.5;
5234
+ const f = Mn(x), p = f[2] - f[0], g = f[3] - f[1], E = r.x - f[0], y = r.y - f[1], F = p > 0 ? E / p : 0.5, C = g > 0 ? y / g : 0.5;
5216
5235
  c = { x: F, y: C };
5217
5236
  }
5218
5237
  }
@@ -5221,7 +5240,7 @@ class ao {
5221
5240
  arrow: l,
5222
5241
  target: n,
5223
5242
  targetType: s,
5224
- magnet: oo(c, s),
5243
+ magnet: ao(c, s),
5225
5244
  side: t
5226
5245
  };
5227
5246
  if (s === P.NODE && !this.ogma.getNode(n) || s === P.EDGE && !this.ogma.getEdge(n))
@@ -5301,8 +5320,8 @@ class ao {
5301
5320
  return a;
5302
5321
  }
5303
5322
  }
5304
- const co = ["x", "y", "radius"], lo = 1, ho = 20;
5305
- class uo {
5323
+ const lo = ["x", "y", "radius"], ho = 1, uo = 20;
5324
+ class xo {
5306
5325
  constructor(e, t, n, s, r) {
5307
5326
  m(this, "ogma");
5308
5327
  m(this, "store");
@@ -5390,7 +5409,7 @@ class uo {
5390
5409
  });
5391
5410
  }), t.size > 0 && this.update(t);
5392
5411
  });
5393
- m(this, "throttledRefresh", Fn(() => this.refresh(), ho));
5412
+ m(this, "throttledRefresh", yn(() => this.refresh(), uo));
5394
5413
  m(this, "onAddRemoveEdges", (e) => {
5395
5414
  const t = e.edges;
5396
5415
  if (!t.size || !this.index.edgeToLink.size) return;
@@ -5488,7 +5507,7 @@ class uo {
5488
5507
  n.set(x, this.index.linksByArrowId.get(x)), s.set(x, this.index.linksByArrowId.get(x));
5489
5508
  });
5490
5509
  });
5491
- const o = e.getAttributes(co), a = this.store.getState(), l = {};
5510
+ const o = e.getAttributes(lo), a = this.store.getState(), l = {};
5492
5511
  for (let c = 0; c < t.length; c++) {
5493
5512
  const d = t[c], h = this.index.nodeToLink.get(d);
5494
5513
  if (h)
@@ -5499,7 +5518,7 @@ class uo {
5499
5518
  C,
5500
5519
  nt($(E, y), -1),
5501
5520
  this.geometry.isLinkedToCenter(x)
5502
- ), S = $n(
5521
+ ), S = Yn(
5503
5522
  this.index.links,
5504
5523
  this.index.linksByArrowId,
5505
5524
  this.store,
@@ -5613,7 +5632,7 @@ class uo {
5613
5632
  }), a;
5614
5633
  }
5615
5634
  requestCommit() {
5616
- this.commitBlocked() || (clearTimeout(this.commitTimeout), this.commitTimeout = setTimeout(this.commit, lo));
5635
+ this.commitBlocked() || (clearTimeout(this.commitTimeout), this.commitTimeout = setTimeout(this.commit, ho));
5617
5636
  }
5618
5637
  // See `geoOverlayActive`'s doc comment - neither the getter nor the
5619
5638
  // delayed geoEnabled/geoDisabled-driven flag is safe to gate on alone;
@@ -5636,7 +5655,7 @@ class uo {
5636
5655
  clearTimeout(this.commitTimeout), this.nodePositionFrameHandler && this.ogma.events.off(this.nodePositionFrameHandler), this.ogma.events.off(this.onSetMultipleAttributes).off(this.onAddRemoveEdges).off(this.onRemoveNodes).off(this.refresh).off(this.onGeoModeChanged);
5637
5656
  }
5638
5657
  }
5639
- class xo {
5658
+ class fo {
5640
5659
  constructor(e, t, n, s) {
5641
5660
  m(this, "registry");
5642
5661
  m(this, "geometry");
@@ -5650,7 +5669,7 @@ class xo {
5650
5669
  const n = this.registry.syncFromFeatureChange(e, t);
5651
5670
  n.size > 0 && this.sync.updateAndCommitSync(n);
5652
5671
  });
5653
- this.store = n, this.snapping = t, this.registry = new ao(e, n, s), this.geometry = new ro(e, n), this.sync = new uo(e, n, this.registry, this.geometry, this.updatedItems), this.store.subscribe((r) => r.features, this.onAddArrow);
5672
+ this.store = n, this.snapping = t, this.registry = new co(e, n, s), this.geometry = new oo(e, n), this.sync = new xo(e, n, this.registry, this.geometry, this.updatedItems), this.store.subscribe((r) => r.features, this.onAddArrow);
5654
5673
  }
5655
5674
  /**
5656
5675
  * Called by handlers during drag operations to update linked arrows.
@@ -5701,7 +5720,7 @@ class xo {
5701
5720
  n[h.arrow] = {
5702
5721
  geometry: y
5703
5722
  }, this.updatedItems.add(h.arrow);
5704
- const F = $n(
5723
+ const F = Yn(
5705
5724
  this.registry.links,
5706
5725
  this.registry.linksByArrowId,
5707
5726
  this.store,
@@ -5763,7 +5782,7 @@ class xo {
5763
5782
  this.sync.destroy();
5764
5783
  }
5765
5784
  }
5766
- function fo(i, e, t, n, s = 20) {
5785
+ function go(i, e, t, n, s = 20) {
5767
5786
  let r = 0, o = 1 / 0, a = null;
5768
5787
  for (let l = 0; l <= s; l++) {
5769
5788
  const c = l / s, d = Gt.getPointOnQuadraticCurve(
@@ -5779,7 +5798,7 @@ function fo(i, e, t, n, s = 20) {
5779
5798
  }
5780
5799
  return a ? { t: r, point: a, distance: o } : null;
5781
5800
  }
5782
- function go(i, e, t) {
5801
+ function po(i, e, t) {
5783
5802
  const n = t.x - e.x, s = t.y - e.y, r = n * n + s * s;
5784
5803
  if (r === 0)
5785
5804
  return {
@@ -5803,14 +5822,14 @@ function go(i, e, t) {
5803
5822
  distance: et($(a, i))
5804
5823
  };
5805
5824
  }
5806
- function po(i, e, t) {
5825
+ function mo(i, e, t) {
5807
5826
  let n = null, s = t;
5808
5827
  const r = e.getAttribute("curvature"), a = e.getExtremities().getPosition();
5809
5828
  for (let l = 0; l < e.size; l++) {
5810
5829
  const c = e.get(l), d = r[l], h = a[2 * l], u = a[2 * l + 1];
5811
5830
  let x;
5812
5831
  if (d === 0 || d === void 0)
5813
- x = go(i, h, u);
5832
+ x = po(i, h, u);
5814
5833
  else {
5815
5834
  const f = Gt.getQuadraticCurveControlPoint(
5816
5835
  h.x,
@@ -5819,7 +5838,7 @@ function po(i, e, t) {
5819
5838
  u.y,
5820
5839
  d
5821
5840
  );
5822
- x = fo(
5841
+ x = go(
5823
5842
  i,
5824
5843
  h,
5825
5844
  u,
@@ -5835,7 +5854,7 @@ function po(i, e, t) {
5835
5854
  }
5836
5855
  return n;
5837
5856
  }
5838
- function mo(i, e, t) {
5857
+ function So(i, e, t) {
5839
5858
  const n = e.getAttributes(["x", "y", "radius"]);
5840
5859
  for (let s = 0; s < n.length; s++) {
5841
5860
  const r = n[s], o = $({ x: r.x, y: r.y }, i), a = et(o);
@@ -5850,7 +5869,7 @@ function mo(i, e, t) {
5850
5869
  }
5851
5870
  return null;
5852
5871
  }
5853
- function So(i, e) {
5872
+ function Fo(i, e) {
5854
5873
  let t = !1;
5855
5874
  for (let n = 0, s = e.length - 1; n < e.length; s = n++) {
5856
5875
  const r = e[n][0], o = e[n][1], a = e[s][0], l = e[s][1];
@@ -5858,23 +5877,23 @@ function So(i, e) {
5858
5877
  }
5859
5878
  return t;
5860
5879
  }
5861
- function Fo(i, e, t, n, s) {
5880
+ function yo(i, e, t, n, s) {
5862
5881
  const r = i * i, o = r * i, a = 1 - i, l = a * a, c = l * a;
5863
5882
  return {
5864
5883
  x: c * e.x + 3 * l * i * t.x + 3 * a * r * n.x + o * s.x,
5865
5884
  y: c * e.y + 3 * l * i * t.y + 3 * a * r * n.y + o * s.y
5866
5885
  };
5867
5886
  }
5868
- function yo(i, e, t, n, s) {
5887
+ function Eo(i, e, t, n, s) {
5869
5888
  let r = 1 / 0, o = null;
5870
5889
  const a = 20;
5871
5890
  for (let l = 0; l <= a; l++) {
5872
- const c = l / a, d = Fo(c, e, t, n, s), h = et($(d, i));
5891
+ const c = l / a, d = yo(c, e, t, n, s), h = et($(d, i));
5873
5892
  h < r && (r = h, o = d);
5874
5893
  }
5875
5894
  return o ? { point: o, distance: r } : null;
5876
5895
  }
5877
- function Eo(i, e, t) {
5896
+ function Ao(i, e, t) {
5878
5897
  const n = e.geometry.coordinates[0];
5879
5898
  for (let s = 0; s < n.length - 1; s++) {
5880
5899
  const [r, o] = n[s];
@@ -5906,11 +5925,11 @@ function Eo(i, e, t) {
5906
5925
  }
5907
5926
  return null;
5908
5927
  }
5909
- function Ao(i, e, t) {
5928
+ function No(i, e, t) {
5910
5929
  for (const s of e) {
5911
5930
  const o = s.geometry.coordinates[0].slice(0, -1);
5912
5931
  if (o.length < 3)
5913
- return Eo(i, s, t);
5932
+ return Ao(i, s, t);
5914
5933
  for (let d = 0; d < o.length; d++) {
5915
5934
  const [h, u] = o[d];
5916
5935
  if (et($({ x: h, y: u }, i)) < t)
@@ -5921,10 +5940,10 @@ function Ao(i, e, t) {
5921
5940
  id: s.id
5922
5941
  };
5923
5942
  }
5924
- const a = So(i, o);
5943
+ const a = Fo(i, o);
5925
5944
  let l = null, c = a ? 1 / 0 : t;
5926
5945
  for (let d = 0; d < o.length; d++) {
5927
- const h = o[(d - 1 + o.length) % o.length], u = o[d], x = o[(d + 1) % o.length], f = o[(d + 2) % o.length], p = u[0] + (x[0] - h[0]) / 6 * 0.5, g = u[1] + (x[1] - h[1]) / 6 * 0.5, E = x[0] - (f[0] - u[0]) / 6 * 0.5, y = x[1] - (f[1] - u[1]) / 6 * 0.5, F = yo(
5946
+ const h = o[(d - 1 + o.length) % o.length], u = o[d], x = o[(d + 1) % o.length], f = o[(d + 2) % o.length], p = u[0] + (x[0] - h[0]) / 6 * 0.5, g = u[1] + (x[1] - h[1]) / 6 * 0.5, E = x[0] - (f[0] - u[0]) / 6 * 0.5, y = x[1] - (f[1] - u[1]) / 6 * 0.5, F = Eo(
5928
5947
  i,
5929
5948
  { x: u[0], y: u[1] },
5930
5949
  { x: p, y: g },
@@ -5954,7 +5973,7 @@ function Ao(i, e, t) {
5954
5973
  }
5955
5974
  return null;
5956
5975
  }
5957
- const Yn = [
5976
+ const Xn = [
5958
5977
  { x: -0.5, y: -0.5 },
5959
5978
  { x: 0, y: -0.5 },
5960
5979
  { x: 0.5, y: -0.5 },
@@ -5965,7 +5984,7 @@ const Yn = [
5965
5984
  { x: 0.5, y: 0.5 },
5966
5985
  { x: 0, y: 0 }
5967
5986
  // center
5968
- ], No = [
5987
+ ], Co = [
5969
5988
  [-0.5, -0.5, 0.5, -0.5],
5970
5989
  // top
5971
5990
  [0.5, -0.5, 0.5, 0.5],
@@ -5975,20 +5994,20 @@ const Yn = [
5975
5994
  [-0.5, 0.5, -0.5, -0.5]
5976
5995
  // left
5977
5996
  ];
5978
- function an(i, e, t, n, s, r, o, a, l) {
5997
+ function cn(i, e, t, n, s, r, o, a, l) {
5979
5998
  const c = i * s, d = e * r;
5980
5999
  return l ? {
5981
6000
  x: t + (c * o - d * a),
5982
6001
  y: n + (c * a + d * o)
5983
6002
  } : { x: t + c, y: n + d };
5984
6003
  }
5985
- function Co(i, e, t, n, s) {
6004
+ function vo(i, e, t, n, s) {
5986
6005
  var d;
5987
6006
  const r = Z(e);
5988
6007
  let { width: o, height: a } = K(e);
5989
6008
  const { sin: l, cos: c } = s.getState();
5990
6009
  (d = e.properties.style) != null && d.fixedSize && (o /= t, a /= t);
5991
- for (const h of Yn) {
6010
+ for (const h of Xn) {
5992
6011
  let u = h.x * o, x = h.y * a;
5993
6012
  if (!G(e)) {
5994
6013
  const g = u * c - x * l, E = u * l + x * c;
@@ -6005,7 +6024,7 @@ function Co(i, e, t, n, s) {
6005
6024
  }
6006
6025
  return null;
6007
6026
  }
6008
- function vo(i, e, t, n, s) {
6027
+ function Mo(i, e, t, n, s) {
6009
6028
  var f;
6010
6029
  const { x: r, y: o } = Z(e);
6011
6030
  let { width: a, height: l } = K(e);
@@ -6013,7 +6032,7 @@ function vo(i, e, t, n, s) {
6013
6032
  const { sin: c, cos: d } = s.getState(), h = !G(e);
6014
6033
  let u = null, x = 1 / 0;
6015
6034
  for (let p = 0; p < 4; p++) {
6016
- const [g, E, y, F] = No[p], C = an(g, E, r, o, a, l, d, c, h), A = an(y, F, r, o, a, l, d, c, h), S = $(A, C), N = et(S), v = { x: S.x / N, y: S.y / N }, w = { x: -v.y, y: v.x }, D = $(i, C), b = Ot(w, D), L = Ot(v, D);
6035
+ const [g, E, y, F] = Co[p], C = cn(g, E, r, o, a, l, d, c, h), A = cn(y, F, r, o, a, l, d, c, h), S = $(A, C), N = et(S), v = { x: S.x / N, y: S.y / N }, w = { x: -v.y, y: v.x }, D = $(i, C), b = Ot(w, D), L = Ot(v, D);
6017
6036
  if (L >= 0 && L <= N) {
6018
6037
  const T = Math.abs(b);
6019
6038
  if (T < n || T < x) {
@@ -6036,14 +6055,14 @@ function vo(i, e, t, n, s) {
6036
6055
  }
6037
6056
  return u && x < Math.max(a, l) ? u : null;
6038
6057
  }
6039
- function Mo(i, e, t, n, s) {
6058
+ function bo(i, e, t, n, s) {
6040
6059
  for (const r of e) {
6041
- const o = Co(i, r, t, n, s) || vo(i, r, t, n, s);
6060
+ const o = vo(i, r, t, n, s) || Mo(i, r, t, n, s);
6042
6061
  if (o) return o;
6043
6062
  }
6044
6063
  return null;
6045
6064
  }
6046
- class bo extends EventTarget {
6065
+ class wo extends EventTarget {
6047
6066
  constructor(t, n, s, r) {
6048
6067
  super();
6049
6068
  m(this, "ogma");
@@ -6079,16 +6098,16 @@ class bo extends EventTarget {
6079
6098
  }
6080
6099
  snapToText(t, n) {
6081
6100
  const { zoom: s } = this.store.getState();
6082
- return Mo(t, n, s, this.options.magnetRadius, this.store);
6101
+ return bo(t, n, s, this.options.magnetRadius, this.store);
6083
6102
  }
6084
6103
  snapToPolygon(t, n) {
6085
- return Ao(t, n, this.options.magnetRadius);
6104
+ return No(t, n, this.options.magnetRadius);
6086
6105
  }
6087
6106
  snapToNodes(t, n) {
6088
- return mo(t, n, this.options.detectMargin);
6107
+ return So(t, n, this.options.detectMargin);
6089
6108
  }
6090
6109
  snapToEdges(t, n) {
6091
- return po(t, n, this.options.magnetRadius);
6110
+ return mo(t, n, this.options.magnetRadius);
6092
6111
  }
6093
6112
  getHoveredNode() {
6094
6113
  return this.hoveredNode;
@@ -6098,32 +6117,32 @@ class bo extends EventTarget {
6098
6117
  (t = this.hoveredNode) == null || t.setSelected(!1), this.hoveredNode = null;
6099
6118
  }
6100
6119
  getMagnets() {
6101
- return Yn;
6120
+ return Xn;
6102
6121
  }
6103
6122
  }
6104
- function Xn(i, e, t = 0, n = i.length - 1, s = wo) {
6123
+ function Gn(i, e, t = 0, n = i.length - 1, s = Do) {
6105
6124
  for (; n > t; ) {
6106
6125
  if (n - t > 600) {
6107
6126
  const l = n - t + 1, c = e - t + 1, d = Math.log(l), h = 0.5 * Math.exp(2 * d / 3), u = 0.5 * Math.sqrt(d * h * (l - h) / l) * (c - l / 2 < 0 ? -1 : 1), x = Math.max(t, Math.floor(e - c * h / l + u)), f = Math.min(n, Math.floor(e + (l - c) * h / l + u));
6108
- Xn(i, e, x, f, s);
6127
+ Gn(i, e, x, f, s);
6109
6128
  }
6110
6129
  const r = i[e];
6111
6130
  let o = t, a = n;
6112
- for (Nt(i, t, e), s(i[n], r) > 0 && Nt(i, t, n); o < a; ) {
6113
- for (Nt(i, o, a), o++, a--; s(i[o], r) < 0; ) o++;
6131
+ for (Ct(i, t, e), s(i[n], r) > 0 && Ct(i, t, n); o < a; ) {
6132
+ for (Ct(i, o, a), o++, a--; s(i[o], r) < 0; ) o++;
6114
6133
  for (; s(i[a], r) > 0; ) a--;
6115
6134
  }
6116
- s(i[t], r) === 0 ? Nt(i, t, a) : (a++, Nt(i, a, n)), a <= e && (t = a + 1), e <= a && (n = a - 1);
6135
+ s(i[t], r) === 0 ? Ct(i, t, a) : (a++, Ct(i, a, n)), a <= e && (t = a + 1), e <= a && (n = a - 1);
6117
6136
  }
6118
6137
  }
6119
- function Nt(i, e, t) {
6138
+ function Ct(i, e, t) {
6120
6139
  const n = i[e];
6121
6140
  i[e] = i[t], i[t] = n;
6122
6141
  }
6123
- function wo(i, e) {
6142
+ function Do(i, e) {
6124
6143
  return i < e ? -1 : i > e ? 1 : 0;
6125
6144
  }
6126
- class Do {
6145
+ class Bo {
6127
6146
  constructor(e = 9) {
6128
6147
  this._maxEntries = Math.max(4, e), this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4)), this.clear();
6129
6148
  }
@@ -6194,7 +6213,7 @@ class Do {
6194
6213
  let a, l, c;
6195
6214
  for (; n || r.length; ) {
6196
6215
  if (n || (n = r.pop(), l = r[r.length - 1], a = o.pop(), c = !0), n.leaf) {
6197
- const d = Bo(e, n.children, t);
6216
+ const d = ko(e, n.children, t);
6198
6217
  if (d !== -1)
6199
6218
  return n.children.splice(d, 1), r.push(n), this._condense(r), this;
6200
6219
  }
@@ -6230,10 +6249,10 @@ class Do {
6230
6249
  return a = Ft(e.slice(t, n + 1)), St(a, this.toBBox), a;
6231
6250
  s || (s = Math.ceil(Math.log(r) / Math.log(o)), o = Math.ceil(r / Math.pow(o, s - 1))), a = Ft([]), a.leaf = !1, a.height = s;
6232
6251
  const l = Math.ceil(r / o), c = l * Math.ceil(Math.sqrt(o));
6233
- cn(e, t, n, c, this.compareMinX);
6252
+ ln(e, t, n, c, this.compareMinX);
6234
6253
  for (let d = t; d <= n; d += c) {
6235
6254
  const h = Math.min(d + c - 1, n);
6236
- cn(e, d, h, l, this.compareMinY);
6255
+ ln(e, d, h, l, this.compareMinY);
6237
6256
  for (let u = d; u <= h; u += l) {
6238
6257
  const x = Math.min(u + l - 1, h);
6239
6258
  a.children.push(this._build(e, u, x, s - 1));
@@ -6245,7 +6264,7 @@ class Do {
6245
6264
  for (; s.push(t), !(t.leaf || s.length - 1 === n); ) {
6246
6265
  let r = 1 / 0, o = 1 / 0, a;
6247
6266
  for (let l = 0; l < t.children.length; l++) {
6248
- const c = t.children[l], d = ae(c), h = To(e, c) - d;
6267
+ const c = t.children[l], d = ae(c), h = Oo(e, c) - d;
6249
6268
  h < o ? (o = h, r = d < r ? d : r, a = c) : h === o && d < r && (r = d, a = c);
6250
6269
  }
6251
6270
  t = a || t.children[0];
@@ -6271,14 +6290,14 @@ class Do {
6271
6290
  _chooseSplitIndex(e, t, n) {
6272
6291
  let s, r = 1 / 0, o = 1 / 0;
6273
6292
  for (let a = t; a <= n - t; a++) {
6274
- const l = Mt(e, 0, a, this.toBBox), c = Mt(e, a, n, this.toBBox), d = Oo(l, c), h = ae(l) + ae(c);
6293
+ const l = Mt(e, 0, a, this.toBBox), c = Mt(e, a, n, this.toBBox), d = Po(l, c), h = ae(l) + ae(c);
6275
6294
  d < r ? (r = d, s = a, o = h < o ? h : o) : d === r && h < o && (o = h, s = a);
6276
6295
  }
6277
6296
  return s || n - t;
6278
6297
  }
6279
6298
  // sorts node children by the best axis for split
6280
6299
  _chooseSplitAxis(e, t, n) {
6281
- const s = e.leaf ? this.compareMinX : ko, r = e.leaf ? this.compareMinY : Lo, o = this._allDistMargin(e, t, n, s), a = this._allDistMargin(e, t, n, r);
6300
+ const s = e.leaf ? this.compareMinX : Lo, r = e.leaf ? this.compareMinY : To, o = this._allDistMargin(e, t, n, s), a = this._allDistMargin(e, t, n, r);
6282
6301
  o < a && e.children.sort(s);
6283
6302
  }
6284
6303
  // total margin of all possible split distributions where each node is at least m full
@@ -6305,7 +6324,7 @@ class Do {
6305
6324
  e[t].children.length === 0 ? t > 0 ? (n = e[t - 1].children, n.splice(n.indexOf(e[t]), 1)) : this.clear() : St(e[t], this.toBBox);
6306
6325
  }
6307
6326
  }
6308
- function Bo(i, e, t) {
6327
+ function ko(i, e, t) {
6309
6328
  if (!t) return e.indexOf(i);
6310
6329
  for (let n = 0; n < e.length; n++)
6311
6330
  if (t(i, e[n])) return n;
@@ -6325,10 +6344,10 @@ function Mt(i, e, t, n, s) {
6325
6344
  function bt(i, e) {
6326
6345
  return i.minX = Math.min(i.minX, e.minX), i.minY = Math.min(i.minY, e.minY), i.maxX = Math.max(i.maxX, e.maxX), i.maxY = Math.max(i.maxY, e.maxY), i;
6327
6346
  }
6328
- function ko(i, e) {
6347
+ function Lo(i, e) {
6329
6348
  return i.minX - e.minX;
6330
6349
  }
6331
- function Lo(i, e) {
6350
+ function To(i, e) {
6332
6351
  return i.minY - e.minY;
6333
6352
  }
6334
6353
  function ae(i) {
@@ -6337,10 +6356,10 @@ function ae(i) {
6337
6356
  function Ut(i) {
6338
6357
  return i.maxX - i.minX + (i.maxY - i.minY);
6339
6358
  }
6340
- function To(i, e) {
6359
+ function Oo(i, e) {
6341
6360
  return (Math.max(e.maxX, i.maxX) - Math.min(e.minX, i.minX)) * (Math.max(e.maxY, i.maxY) - Math.min(e.minY, i.minY));
6342
6361
  }
6343
- function Oo(i, e) {
6362
+ function Po(i, e) {
6344
6363
  const t = Math.max(i.minX, e.minX), n = Math.max(i.minY, e.minY), s = Math.min(i.maxX, e.maxX), r = Math.min(i.maxY, e.maxY);
6345
6364
  return Math.max(0, s - t) * Math.max(0, r - n);
6346
6365
  }
@@ -6361,16 +6380,16 @@ function Ft(i) {
6361
6380
  maxY: -1 / 0
6362
6381
  };
6363
6382
  }
6364
- function cn(i, e, t, n, s) {
6383
+ function ln(i, e, t, n, s) {
6365
6384
  const r = [e, t];
6366
6385
  for (; r.length; ) {
6367
6386
  if (t = r.pop(), e = r.pop(), t - e <= n) continue;
6368
6387
  const o = e + Math.ceil((t - e) / n / 2) * n;
6369
- Xn(i, o, e, t, s), r.push(e, o, o, t);
6388
+ Gn(i, o, e, t, s), r.push(e, o, o, t);
6370
6389
  }
6371
6390
  }
6372
- const Ct = { minX: 0, minY: 0, maxX: 0, maxY: 0 }, le = (i, e) => i.id === e.id;
6373
- class Po extends Do {
6391
+ const vt = { minX: 0, minY: 0, maxX: 0, maxY: 0 }, le = (i, e) => i.id === e.id;
6392
+ class Ro extends Bo {
6374
6393
  constructor(t) {
6375
6394
  super();
6376
6395
  m(this, "store");
@@ -6443,24 +6462,24 @@ class Po extends Do {
6443
6462
  });
6444
6463
  }
6445
6464
  compareMinX(t, n) {
6446
- return yt(t)[0] - yt(n)[0];
6465
+ return Et(t)[0] - Et(n)[0];
6447
6466
  }
6448
6467
  compareMinY(t, n) {
6449
- return yt(t)[1] - yt(n)[1];
6468
+ return Et(t)[1] - Et(n)[1];
6450
6469
  }
6451
6470
  // insert(item: Annotation) {
6452
6471
  // console.log(item.properties.type, "---", item.id, item.geometry.bbox);
6453
6472
  // return super.insert(item);
6454
6473
  // }
6455
6474
  toBBox(t) {
6456
- const n = yt(t);
6457
- return Ct.minX = n[0], Ct.minY = n[1], Ct.maxX = n[2], Ct.maxY = n[3], Ct;
6475
+ const n = Et(t);
6476
+ return vt.minX = n[0], vt.minY = n[1], vt.maxX = n[2], vt.maxY = n[3], vt;
6458
6477
  }
6459
6478
  query(t) {
6460
6479
  return super.search(t);
6461
6480
  }
6462
6481
  }
6463
- class Gn {
6482
+ class jn {
6464
6483
  constructor(e, t) {
6465
6484
  m(this, "layer");
6466
6485
  this.ogma = e, this.store = t;
@@ -6468,7 +6487,7 @@ class Gn {
6468
6487
  destroy() {
6469
6488
  }
6470
6489
  }
6471
- const ln = [
6490
+ const dn = [
6472
6491
  [-0.5, -0.5],
6473
6492
  // top-left
6474
6493
  [0.5, -0.5],
@@ -6478,7 +6497,7 @@ const ln = [
6478
6497
  [-0.5, 0.5]
6479
6498
  // bottom-right
6480
6499
  ];
6481
- class Ro extends Gn {
6500
+ class Ho extends jn {
6482
6501
  constructor(t, n) {
6483
6502
  super(t, n);
6484
6503
  // TODO: move it to settings and state
@@ -6520,7 +6539,7 @@ class Ro extends Gn {
6520
6539
  this.layer = t.layers.addCanvasLayer(
6521
6540
  this.render,
6522
6541
  void 0,
6523
- Ee.HANDLES
6542
+ Ae.HANDLES
6524
6543
  ), this.store.subscribe(
6525
6544
  (s) => ({
6526
6545
  selectedFeatures: s.selectedFeatures,
@@ -6537,7 +6556,7 @@ class Ro extends Gn {
6537
6556
  const d = fe(t, a, o), h = l / 2, u = c / 2, x = d.x + h, f = d.y + u;
6538
6557
  n.save(), n.translate(x, f), n.rotate(s);
6539
6558
  const p = (E = t.properties.style) == null ? void 0 : E.borderRadius;
6540
- if (p && p > 0 ? (zs(n, -h, -u, l, c, p), n.stroke()) : n.strokeRect(-h, -u, l, c), r >= 4 && r < 8) {
6559
+ if (p && p > 0 ? (_s(n, -h, -u, l, c, p), n.stroke()) : n.strokeRect(-h, -u, l, c), r >= 4 && r < 8) {
6541
6560
  let y, F, C, A;
6542
6561
  const S = p && p > 0 ? p : this.handleRadius / o;
6543
6562
  switch (r) {
@@ -6560,7 +6579,7 @@ class Ro extends Gn {
6560
6579
  }
6561
6580
  renderArrowHandles(t, n, s, r, o) {
6562
6581
  var x, f, p, g;
6563
- const a = xs(t), l = fs(t), c = +(r === 0), d = +(r === 1), h = s * (1 + (this.handleMagnifier - 1) * c), u = s * (1 + (this.handleMagnifier - 1) * d);
6582
+ const a = fs(t), l = gs(t), c = +(r === 0), d = +(r === 1), h = s * (1 + (this.handleMagnifier - 1) * c), u = s * (1 + (this.handleMagnifier - 1) * d);
6564
6583
  n.beginPath(), n.moveTo(a.x, a.y), n.lineTo(l.x, l.y), n.closePath(), n.stroke(), o && (n.beginPath(), ((f = (x = t.properties.link) == null ? void 0 : x.start) == null ? void 0 : f.type) !== "comment" && (n.moveTo(a.x - h, a.y - h), n.rect(a.x - h, a.y - h, h * 2, h * 2)), ((g = (p = t.properties.link) == null ? void 0 : p.end) == null ? void 0 : g.type) !== "comment" && (n.moveTo(l.x - u, l.y - u), n.rect(l.x - u, l.y - u, u * 2, u * 2)), n.closePath(), n.fill(), n.stroke());
6565
6584
  }
6566
6585
  renderBoxHandles(t, n, s, r, o) {
@@ -6568,8 +6587,8 @@ class Ro extends Gn {
6568
6587
  if (_(t) && ((f = t.properties.style) != null && f.fixedSize)) return;
6569
6588
  const { width: a, height: l } = K(t), c = fe(t), d = a / 2, h = l / 2, u = c.x + d, x = c.y + h;
6570
6589
  n.save(), n.translate(u, x), n.rotate(o), n.beginPath();
6571
- for (let p = 0; p < ln.length; p++) {
6572
- const [g, E] = ln[p], y = a * g, F = l * E, C = r === p ? s * this.handleMagnifier : s;
6590
+ for (let p = 0; p < dn.length; p++) {
6591
+ const [g, E] = dn[p], y = a * g, F = l * E, C = r === p ? s * this.handleMagnifier : s;
6573
6592
  n.rect(y - C, F - C, C * 2, C * 2);
6574
6593
  }
6575
6594
  n.closePath(), n.fill(), n.stroke(), n.restore();
@@ -6600,15 +6619,15 @@ class Ro extends Gn {
6600
6619
  this.layer.destroy(), super.destroy();
6601
6620
  }
6602
6621
  }
6603
- const Ho = 0.5;
6604
- function Io(i, e, t, n) {
6605
- const { start: s, end: r } = yn(i), o = $(r, s);
6622
+ const Io = 0.5;
6623
+ function zo(i, e, t, n) {
6624
+ const { start: s, end: r } = En(i), o = $(r, s);
6606
6625
  return Math.min(n, Math.max(2 * e, et(o) * 0.01, t));
6607
6626
  }
6608
- function dn(i, e) {
6627
+ function hn(i, e) {
6609
6628
  return !i || i === "none" ? 0 : i === "dot" ? e * 2 : i === "halo-dot" ? e * 4 : i === "arrow" || i === "arrow-plain" ? e : 0;
6610
6629
  }
6611
- function zo(i, e) {
6630
+ function _o(i, e) {
6612
6631
  if (!i) {
6613
6632
  i = O("g");
6614
6633
  const t = O("path");
@@ -6618,13 +6637,13 @@ function zo(i, e) {
6618
6637
  }
6619
6638
  return i;
6620
6639
  }
6621
- function _o(i, e, t, n, s, r, o = !1) {
6622
- const { start: a, end: l } = yn(e), c = e.properties.style || gn, { tail: d, strokeWidth: h = 0, head: u, strokeColor: x, strokeType: f } = c, p = $(l, a), g = qs(e) || o ? 1 / r.zoom : 1, E = Io(e, h, t, n) * g, y = zo(s, e.id), F = y.firstChild, C = x || "none";
6640
+ function Uo(i, e, t, n, s, r, o = !1) {
6641
+ const { start: a, end: l } = En(e), c = e.properties.style || pn, { tail: d, strokeWidth: h = 0, head: u, strokeColor: x, strokeType: f } = c, p = $(l, a), g = Ks(e) || o ? 1 / r.zoom : 1, E = zo(e, h, t, n) * g, y = _o(s, e.id), F = y.firstChild, C = x || "none";
6623
6642
  F.setAttribute("stroke", C), F.setAttribute("stroke-width", `${g * h}`), F.setAttribute("fill", "none"), F.setAttribute("stroke-linecap", "round"), F.setAttribute("stroke-linejoin", "round");
6624
- const A = dn(d, h * g), S = dn(u, h * g), N = En(p), v = dt(a, nt(N, A)), w = dt(l, nt(N, -S)), D = `M ${v.x} ${v.y} L ${w.x} ${w.y}`;
6643
+ const A = hn(d, h * g), S = hn(u, h * g), N = An(p), v = dt(a, nt(N, A)), w = dt(l, nt(N, -S)), D = `M ${v.x} ${v.y} L ${w.x} ${w.y}`;
6625
6644
  F.setAttribute("d", D);
6626
6645
  const b = y.children[1];
6627
- b.innerHTML = "", f === "dashed" ? F.setAttribute("stroke-dasharray", "5,10") : F.removeAttribute("stroke-dasharray"), hn(
6646
+ b.innerHTML = "", f === "dashed" ? F.setAttribute("stroke-dasharray", "5,10") : F.removeAttribute("stroke-dasharray"), un(
6628
6647
  b,
6629
6648
  a,
6630
6649
  p,
@@ -6633,10 +6652,10 @@ function _o(i, e, t, n, s, r, o = !1) {
6633
6652
  h,
6634
6653
  g,
6635
6654
  E
6636
- ), hn(
6655
+ ), un(
6637
6656
  b,
6638
6657
  l,
6639
- gs(p),
6658
+ ps(p),
6640
6659
  C,
6641
6660
  u,
6642
6661
  h,
@@ -6646,17 +6665,17 @@ function _o(i, e, t, n, s, r, o = !1) {
6646
6665
  "transform",
6647
6666
  `rotate(${-r.rotation * (180 / Math.PI)})`
6648
6667
  );
6649
- const L = Ks(e);
6650
- return (!y.parentNode || y.parentNode !== i || r.selectedFeatures.has(e.id) || L !== void 0 && r.selectedFeatures.has(L)) && An(i, y), y;
6668
+ const L = Vs(e);
6669
+ return (!y.parentNode || y.parentNode !== i || r.selectedFeatures.has(e.id) || L !== void 0 && r.selectedFeatures.has(L)) && Nn(i, y), y;
6651
6670
  }
6652
- function hn(i, e, t, n, s, r, o, a) {
6653
- s === "halo-dot" && un(
6671
+ function un(i, e, t, n, s, r, o, a) {
6672
+ s === "halo-dot" && xn(
6654
6673
  i,
6655
6674
  e,
6656
- Uo(n),
6657
- Ho,
6675
+ Wo(n),
6676
+ Io,
6658
6677
  r * o * 4
6659
- ), (s === "dot" || s === "halo-dot") && un(i, e, n, 1, r * o * 2), (s === "arrow" || s === "arrow-plain") && Wo(
6678
+ ), (s === "dot" || s === "halo-dot") && xn(i, e, n, 1, r * o * 2), (s === "arrow" || s === "arrow-plain") && $o(
6660
6679
  i,
6661
6680
  e,
6662
6681
  t,
@@ -6666,18 +6685,18 @@ function hn(i, e, t, n, s, r, o, a) {
6666
6685
  a
6667
6686
  );
6668
6687
  }
6669
- function Uo(i) {
6688
+ function Wo(i) {
6670
6689
  return i === "none" ? "none" : i;
6671
6690
  }
6672
- function un(i, e, t, n, s) {
6691
+ function xn(i, e, t, n, s) {
6673
6692
  const r = O("circle");
6674
6693
  r.setAttribute("cx", `${e.x}`), r.setAttribute("cy", `${e.y}`), r.setAttribute("r", `${s}`), r.setAttribute("fill-opacity", `${n}`), r.setAttribute("fill", t), i.appendChild(r);
6675
6694
  }
6676
- function Wo(i, e, t, n, s, r, o) {
6677
- const a = nt(En(t), o), l = dt(e, ke(a, Math.PI / 6)), c = dt(e, ke(a, -Math.PI / 6)), d = O("path"), h = `${e.x} ${e.y}`, u = `M ${l.x} ${l.y} L ${h} L ${c.x} ${c.y}${s ? " Z" : ""}`;
6695
+ function $o(i, e, t, n, s, r, o) {
6696
+ const a = nt(An(t), o), l = dt(e, Le(a, Math.PI / 6)), c = dt(e, Le(a, -Math.PI / 6)), d = O("path"), h = `${e.x} ${e.y}`, u = `M ${l.x} ${l.y} L ${h} L ${c.x} ${c.y}${s ? " Z" : ""}`;
6678
6697
  d.setAttribute("d", u), d.setAttribute("stroke", n), d.setAttribute("stroke-width", `${r}`), d.setAttribute("fill", s ? n : "none"), d.setAttribute("stroke-linecap", "round"), d.setAttribute("stroke-linejoin", "round"), i.appendChild(d);
6679
6698
  }
6680
- function $o() {
6699
+ function Yo() {
6681
6700
  const i = O("style");
6682
6701
  return i.textContent = `
6683
6702
  /* Comment Animation Styles */
@@ -6758,7 +6777,7 @@ function $o() {
6758
6777
  }
6759
6778
  `, i;
6760
6779
  }
6761
- function Yo(i, e, t) {
6780
+ function Xo(i, e, t) {
6762
6781
  const n = { ...rt, ...e.properties.style }, s = n.iconSize, {
6763
6782
  iconColor: r = rt.iconColor,
6764
6783
  iconSymbol: o = rt.iconSymbol,
@@ -6770,7 +6789,7 @@ function Yo(i, e, t) {
6770
6789
  let d = i.querySelector("text");
6771
6790
  d || (d = O("text"), d.setAttribute("x", "0"), d.setAttribute("y", "0"), d.setAttribute("text-anchor", "middle"), d.setAttribute("dominant-baseline", "central"), d.setAttribute("pointer-events", "none"), i.appendChild(d)), d.setAttribute("font-size", `${s * 0.5}`), d.textContent = o;
6772
6791
  }
6773
- function Xo(i, e, t, n = !1) {
6792
+ function Go(i, e, t, n = !1) {
6774
6793
  const s = { ...rt, ...e.properties.style }, {
6775
6794
  font: r = "Arial, sans-serif",
6776
6795
  fontSize: o = 12,
@@ -6791,7 +6810,7 @@ function Xo(i, e, t, n = !1) {
6791
6810
  const S = O("foreignObject");
6792
6811
  S.setAttribute("x", `${F}`), S.setAttribute("y", `${C}`), S.setAttribute("width", `${f}`), S.setAttribute("height", `${g}`), S.style.pointerEvents = "none";
6793
6812
  const N = document.createElement("div");
6794
- if (N.style.width = "100%", N.style.height = "100%", N.style.padding = `${a}px`, N.style.boxSizing = "border-box", N.style.fontFamily = r, N.style.fontSize = `${typeof o == "number" ? o : parseFloat(o)}px`, N.style.lineHeight = `${(typeof o == "number" ? o : parseFloat(o)) * Tt}px`, N.style.color = c, N.style.overflowY = E ? "auto" : "hidden", N.style.overflowX = "hidden", N.style.overflowWrap = "break-word", N.style.whiteSpace = "pre-wrap", N.style.pointerEvents = "none", N.innerHTML = Go(y), S.appendChild(N), i.appendChild(S), n) {
6813
+ if (N.style.width = "100%", N.style.height = "100%", N.style.padding = `${a}px`, N.style.boxSizing = "border-box", N.style.fontFamily = r, N.style.fontSize = `${typeof o == "number" ? o : parseFloat(o)}px`, N.style.lineHeight = `${(typeof o == "number" ? o : parseFloat(o)) * Tt}px`, N.style.color = c, N.style.overflowY = E ? "auto" : "hidden", N.style.overflowX = "hidden", N.style.overflowWrap = "break-word", N.style.whiteSpace = "pre-wrap", N.style.pointerEvents = "none", N.innerHTML = jo(y), S.appendChild(N), i.appendChild(S), n) {
6795
6814
  const D = O("foreignObject");
6796
6815
  D.setAttribute("x", `${F + f - 24 - 4}`), D.setAttribute("y", `${C + g - 24 - 4}`), D.setAttribute("width", "24"), D.setAttribute("height", "24");
6797
6816
  const b = document.createElement("div");
@@ -6801,15 +6820,15 @@ function Xo(i, e, t, n = !1) {
6801
6820
  }
6802
6821
  s.shadow !== !1 ? i.setAttribute("filter", "url(#softShadow)") : i.removeAttribute("filter");
6803
6822
  }
6804
- function Go(i) {
6823
+ function jo(i) {
6805
6824
  if (!i) return "";
6806
6825
  let e = i.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
6807
6826
  return e = e.replace(
6808
- kn(),
6809
- `<a href="$1" class="${Ae}" target="_blank" rel="noopener noreferrer">$1</a>`
6827
+ Ln(),
6828
+ `<a href="$1" class="${Ne}" target="_blank" rel="noopener noreferrer">$1</a>`
6810
6829
  ), e;
6811
6830
  }
6812
- function jo(i, e, t, n, s) {
6831
+ function qo(i, e, t, n, s) {
6813
6832
  const r = e.properties.mode;
6814
6833
  let o = t;
6815
6834
  o || (o = O("g"), o.setAttribute("data-annotation", `${e.id}`), o.setAttribute("data-annotation-type", "comment"));
@@ -6818,14 +6837,14 @@ function jo(i, e, t, n, s) {
6818
6837
  let l = o.querySelector(".comment-box");
6819
6838
  l || (l = O("g"), l.classList.add("comment-box"), o.appendChild(l));
6820
6839
  const c = r !== Dt && n.selectedFeatures.has(e.id) && n.editingFeature !== e.id && n.options.showEditButton && n.options.isEditable(e);
6821
- Yo(a, e, n), Xo(l, e, n, c), s ? o.classList.remove("comment-no-transition") : o.classList.add("comment-no-transition"), r === Dt ? (o.classList.add("comment-collapsed"), o.classList.remove("comment-expanded")) : (o.classList.add("comment-expanded"), o.classList.remove("comment-collapsed"));
6840
+ Xo(a, e, n), Go(l, e, n, c), s ? o.classList.remove("comment-no-transition") : o.classList.add("comment-no-transition"), r === Dt ? (o.classList.add("comment-collapsed"), o.classList.remove("comment-expanded")) : (o.classList.add("comment-expanded"), o.classList.remove("comment-collapsed"));
6822
6841
  const d = Z(e);
6823
6842
  return o.setAttribute(
6824
6843
  "transform",
6825
6844
  n.getScreenAlignedTransform(d.x, d.y, !1)
6826
- ), o.style.visibility = n.editingFeature === e.id ? "hidden" : "", (!o.parentNode || o.parentNode !== i || n.selectedFeatures.has(e.id)) && An(i, o), o;
6845
+ ), o.style.visibility = n.editingFeature === e.id ? "hidden" : "", (!o.parentNode || o.parentNode !== i || n.selectedFeatures.has(e.id)) && Nn(i, o), o;
6827
6846
  }
6828
- function qo(i, e = 0.5, t = !1) {
6847
+ function Ko(i, e = 0.5, t = !1) {
6829
6848
  if (i.length < 2) return "";
6830
6849
  if (i.length < 3)
6831
6850
  return i.map((o, a) => `${a === 0 ? "M" : "L"}${o[0]},${o[1]}`).join(" ") + " Z";
@@ -6836,9 +6855,9 @@ function qo(i, e = 0.5, t = !1) {
6836
6855
  }
6837
6856
  return r.push("Z"), r.join(" ");
6838
6857
  }
6839
- const Ko = (i, e, t = "box") => (i || (i = O("g"), i.setAttribute("data-annotation", `${e}`), i.classList.add(`annotation-${t}`)), i);
6840
- function Vo(i, e, t, n) {
6841
- const s = Ko(
6858
+ const Vo = (i, e, t = "box") => (i || (i = O("g"), i.setAttribute("data-annotation", `${e}`), i.classList.add(`annotation-${t}`)), i);
6859
+ function Zo(i, e, t, n) {
6860
+ const s = Vo(
6842
6861
  t,
6843
6862
  e.id.toString(),
6844
6863
  e.properties.type
@@ -6847,20 +6866,20 @@ function Vo(i, e, t, n) {
6847
6866
  let r = s.querySelector("path");
6848
6867
  r || (r = O("path"), s.appendChild(r));
6849
6868
  const {
6850
- strokeColor: o = Et.strokeColor,
6851
- strokeWidth: a = Et.strokeWidth,
6852
- background: l = Et.background,
6853
- strokeType: c = Et.strokeType
6854
- } = e.properties.style || Et;
6869
+ strokeColor: o = At.strokeColor,
6870
+ strokeWidth: a = At.strokeWidth,
6871
+ background: l = At.background,
6872
+ strokeType: c = At.strokeType
6873
+ } = e.properties.style || At;
6855
6874
  o && r.setAttribute("stroke", o), a !== void 0 && r.setAttribute("stroke-width", String(a)), l && (n.hoveredFeature === e.id ? r.setAttribute("fill", Pt(l)) : r.setAttribute("fill", l)), c === "dashed" ? r.setAttribute("stroke-dasharray", "5,5") : r.removeAttribute("stroke-dasharray");
6856
- const d = e.geometry.coordinates[0], h = qo(
6875
+ const d = e.geometry.coordinates[0], h = Ko(
6857
6876
  d,
6858
6877
  0.5,
6859
6878
  n.drawingFeature === e.id
6860
6879
  );
6861
6880
  return r.setAttribute("d", h), s.setAttribute("transform", n.getRotationTransform(0, 0)), i.appendChild(s), s;
6862
6881
  }
6863
- class Zo extends Gn {
6882
+ class Jo extends jn {
6864
6883
  constructor(t, n) {
6865
6884
  super(t, n);
6866
6885
  m(this, "features", /* @__PURE__ */ new Map());
@@ -6884,19 +6903,19 @@ class Zo extends Gn {
6884
6903
  for (let p of Object.values(n)) {
6885
6904
  if (o[p.id] && (p = { ...p, ...o[p.id] }), this.hideIfNotVisible(p) || !this.isExporting && !this.isFeatureVisible(p, x) || (f.add(p.id), G(p) || J(p))) continue;
6886
6905
  let g = this.features.get(p.id);
6887
- _(p) ? g = Ur(
6906
+ _(p) ? g = Wr(
6888
6907
  d,
6889
6908
  p,
6890
6909
  g,
6891
6910
  h,
6892
6911
  this.isExporting
6893
- ) : H(p) ? g = jo(
6912
+ ) : H(p) ? g = qo(
6894
6913
  c,
6895
6914
  p,
6896
6915
  g,
6897
6916
  h,
6898
6917
  this.visibleFeatures.has(p.id)
6899
- ) : Q(p) && (g = _o(
6918
+ ) : Q(p) && (g = Uo(
6900
6919
  a,
6901
6920
  p,
6902
6921
  h.options.minArrowHeight,
@@ -6918,12 +6937,12 @@ class Zo extends Gn {
6918
6937
  if (!(G(d) || J(d)) || (s[d.id] && (d = { ...d, ...s[d.id] }), this.hideIfNotVisible(d)) || !this.isExporting && !this.isFeatureVisible(d, c))
6919
6938
  continue;
6920
6939
  let h = this.features.get(d.id);
6921
- G(d) ? h = _n(
6940
+ G(d) ? h = Un(
6922
6941
  a,
6923
6942
  d,
6924
6943
  h,
6925
6944
  l
6926
- ) : J(d) && (h = Vo(
6945
+ ) : J(d) && (h = Zo(
6927
6946
  a,
6928
6947
  d,
6929
6948
  h,
@@ -6932,7 +6951,7 @@ class Zo extends Gn {
6932
6951
  }
6933
6952
  this.applyStateClasses(a, r, o), t.appendChild(a);
6934
6953
  });
6935
- m(this, "throttleRender", Fn(
6954
+ m(this, "throttleRender", yn(
6936
6955
  () => {
6937
6956
  this.render(this.layer.element), this.renderUnderGraph(this.underLayer.element);
6938
6957
  },
@@ -6952,7 +6971,7 @@ class Zo extends Gn {
6952
6971
  {
6953
6972
  draw: this.render
6954
6973
  },
6955
- Ee.SHAPES
6974
+ Ae.SHAPES
6956
6975
  ), this.underLayer = this.ogma.layers.addSVGLayer({
6957
6976
  draw: this.renderUnderGraph
6958
6977
  }), this.underLayer.moveToBottom(), this.store.subscribe(
@@ -7024,7 +7043,7 @@ class Zo extends Gn {
7024
7043
  }
7025
7044
  getDefs() {
7026
7045
  const t = O("defs");
7027
- t.appendChild($o());
7046
+ t.appendChild(Yo());
7028
7047
  const n = O("filter");
7029
7048
  n.setAttribute("id", "softShadow"), n.setAttribute("x", "-50%"), n.setAttribute("y", "-50%"), n.setAttribute("width", "200%"), n.setAttribute("height", "200%");
7030
7049
  const s = O("feGaussianBlur");
@@ -7076,7 +7095,7 @@ class Zo extends Gn {
7076
7095
  this.features.clear(), this.layer.destroy(), this.underLayer.destroy(), this.ogma.events.off(this.onExportStart), this.ogma.events.off(this.onExportEnd), super.destroy();
7077
7096
  }
7078
7097
  }
7079
- const xn = (i) => {
7098
+ const fn = (i) => {
7080
7099
  let e;
7081
7100
  const t = /* @__PURE__ */ new Set(), n = (c, d) => {
7082
7101
  const h = typeof c == "function" ? c(e) : c;
@@ -7086,8 +7105,8 @@ const xn = (i) => {
7086
7105
  }
7087
7106
  }, s = () => e, a = { setState: n, getState: s, getInitialState: () => l, subscribe: (c) => (t.add(c), () => t.delete(c)) }, l = e = i(n, s, a);
7088
7107
  return a;
7089
- }, jn = (i) => i ? xn(i) : xn;
7090
- var fn = (i, e, t) => (s, r) => ({
7108
+ }, qn = (i) => i ? fn(i) : fn;
7109
+ var gn = (i, e, t) => (s, r) => ({
7091
7110
  pastStates: (t == null ? void 0 : t.pastStates) || [],
7092
7111
  futureStates: (t == null ? void 0 : t.futureStates) || [],
7093
7112
  undo: (o = 1) => {
@@ -7130,10 +7149,10 @@ var fn = (i, e, t) => (s, r) => ({
7130
7149
  futureStates: []
7131
7150
  });
7132
7151
  }
7133
- }), Jo = (i, e) => (n, s, r) => {
7152
+ }), Qo = (i, e) => (n, s, r) => {
7134
7153
  var c, d;
7135
- r.temporal = jn(
7136
- ((c = e == null ? void 0 : e.wrapTemporal) == null ? void 0 : c.call(e, fn(n, s, e))) || fn(n, s, e)
7154
+ r.temporal = qn(
7155
+ ((c = e == null ? void 0 : e.wrapTemporal) == null ? void 0 : c.call(e, gn(n, s, e))) || gn(n, s, e)
7137
7156
  );
7138
7157
  const o = ((d = e == null ? void 0 : e.handleSet) == null ? void 0 : d.call(
7139
7158
  e,
@@ -7166,7 +7185,7 @@ var fn = (i, e, t) => (s, r) => ({
7166
7185
  r
7167
7186
  );
7168
7187
  };
7169
- const Qo = (i) => (e, t, n) => {
7188
+ const ta = (i) => (e, t, n) => {
7170
7189
  const s = n.subscribe;
7171
7190
  return n.subscribe = (o, a, l) => {
7172
7191
  let c = o;
@@ -7183,8 +7202,8 @@ const Qo = (i) => (e, t, n) => {
7183
7202
  }
7184
7203
  return s(c);
7185
7204
  }, i(e, t, n);
7186
- }, ta = Qo, ea = [0, 0, 0, 0];
7187
- function na(i, e) {
7205
+ }, ea = ta, na = [0, 0, 0, 0];
7206
+ function sa(i, e) {
7188
7207
  const t = Object.keys(i.features), n = Object.keys(e.features);
7189
7208
  if (t.length !== n.length) return !1;
7190
7209
  for (const s of t)
@@ -7195,10 +7214,10 @@ function na(i, e) {
7195
7214
  }
7196
7215
  return i.drawingFeature === e.drawingFeature;
7197
7216
  }
7198
- const sa = (i) => {
7199
- const e = jn()(
7200
- ta(
7201
- Jo(
7217
+ const ia = (i) => {
7218
+ const e = qn()(
7219
+ ea(
7220
+ Qo(
7202
7221
  (t, n) => ({
7203
7222
  features: {},
7204
7223
  liveUpdates: {},
@@ -7223,9 +7242,9 @@ const sa = (i) => {
7223
7242
  invZoom: 1,
7224
7243
  options: {
7225
7244
  showSendButton: (i == null ? void 0 : i.showSendButton) ?? !0,
7226
- sendButtonIcon: (i == null ? void 0 : i.sendButtonIcon) ?? Cn,
7245
+ sendButtonIcon: (i == null ? void 0 : i.sendButtonIcon) ?? vn,
7227
7246
  showEditButton: (i == null ? void 0 : i.showEditButton) ?? !0,
7228
- editButtonIcon: (i == null ? void 0 : i.editButtonIcon) ?? Nn,
7247
+ editButtonIcon: (i == null ? void 0 : i.editButtonIcon) ?? Cn,
7229
7248
  minArrowHeight: (i == null ? void 0 : i.minArrowHeight) ?? 20,
7230
7249
  maxArrowHeight: (i == null ? void 0 : i.maxArrowHeight) ?? 30,
7231
7250
  detectMargin: (i == null ? void 0 : i.detectMargin) ?? 2,
@@ -7246,11 +7265,11 @@ const sa = (i) => {
7246
7265
  if (s !== r.drawingFeature && !r.options.isEditable(o))
7247
7266
  return console.error(`Cannot delete annotation ${s}: not editable`), r;
7248
7267
  const { features: a, liveUpdates: l } = r;
7249
- if (Q(o) && Js(a, s))
7268
+ if (Q(o) && Qs(a, s))
7250
7269
  return console.error(
7251
7270
  "Cannot delete last arrow attached to comment. Delete the comment instead."
7252
7271
  ), r;
7253
- const c = Zs(a, s);
7272
+ const c = Js(a, s);
7254
7273
  for (const f of c) {
7255
7274
  const p = a[f];
7256
7275
  if (p && f !== r.drawingFeature && !r.options.isEditable(p))
@@ -7442,7 +7461,7 @@ const sa = (i) => {
7442
7461
  return `matrix(${a}, ${o}, ${-o}, ${a}, ${-l}, ${-c})`;
7443
7462
  },
7444
7463
  getRotatedBBox(s, r, o, a) {
7445
- return ps(
7464
+ return ms(
7446
7465
  s,
7447
7466
  r,
7448
7467
  o - s,
@@ -7451,7 +7470,7 @@ const sa = (i) => {
7451
7470
  this.cos,
7452
7471
  s + (o - s) / 2,
7453
7472
  r + (a - r) / 2,
7454
- ea
7473
+ na
7455
7474
  );
7456
7475
  },
7457
7476
  setDrawingPoints: (s) => t({ drawingPoints: s })
@@ -7465,7 +7484,7 @@ const sa = (i) => {
7465
7484
  // Only track features, not liveUpdates!
7466
7485
  lastChangedFeatures: t.lastChangedFeatures
7467
7486
  }),
7468
- equality: na,
7487
+ equality: sa,
7469
7488
  handleSet: (t) => (n) => {
7470
7489
  n.drawingFeature === null && t(n);
7471
7490
  }
@@ -7474,22 +7493,22 @@ const sa = (i) => {
7474
7493
  )
7475
7494
  );
7476
7495
  return e;
7477
- }, ia = {
7496
+ }, ra = {
7478
7497
  detectMargin: 2,
7479
7498
  magnetHandleRadius: 5,
7480
7499
  magnetRadius: 10,
7481
7500
  textPlaceholder: "Type here",
7482
7501
  minReadableFontSize: 2,
7483
7502
  showSendButton: !0,
7484
- sendButtonIcon: Cn,
7503
+ sendButtonIcon: vn,
7485
7504
  showEditButton: !0,
7486
- editButtonIcon: Nn,
7505
+ editButtonIcon: Cn,
7487
7506
  minArrowHeight: 20,
7488
7507
  maxArrowHeight: 30,
7489
7508
  isEditable: () => !0,
7490
7509
  isVisible: () => !0
7491
7510
  };
7492
- class ga extends ws {
7511
+ class pa extends Ds {
7493
7512
  constructor(t, n = {}) {
7494
7513
  super();
7495
7514
  m(this, "ogma");
@@ -7516,23 +7535,23 @@ class ga extends ws {
7516
7535
  this.links.update();
7517
7536
  });
7518
7537
  this.ogma = t;
7519
- const s = { ...ia, ...n };
7520
- this.store = sa(s), this.index = new Po(this.store), this.snapping = new bo(this.ogma, {
7538
+ const s = { ...ra, ...n };
7539
+ this.store = ia(s), this.index = new Ro(this.store), this.snapping = new wo(this.ogma, {
7521
7540
  detectMargin: n.detectMargin === void 0 ? 10 : n.detectMargin,
7522
7541
  magnetRadius: n.magnetRadius === void 0 ? 10 : n.magnetRadius
7523
- }, this.index, this.store), this.links = new xo(this.ogma, this.snapping, this.store, (r, o) => {
7524
- this.emit(ms, { arrow: r, link: o });
7525
- }), this.interactions = new no(
7542
+ }, this.index, this.store), this.links = new fo(this.ogma, this.snapping, this.store, (r, o) => {
7543
+ this.emit(Ss, { arrow: r, link: o });
7544
+ }), this.interactions = new so(
7526
7545
  this.ogma,
7527
7546
  this.store,
7528
7547
  this.index
7529
- ), this.editor = new so(
7548
+ ), this.editor = new io(
7530
7549
  this.ogma,
7531
7550
  this.store,
7532
7551
  this.snapping,
7533
7552
  this.links,
7534
7553
  this.interactions
7535
- ), this.drawing = new Ys(
7554
+ ), this.drawing = new Xs(
7536
7555
  this.ogma,
7537
7556
  this.store,
7538
7557
  this.editor,
@@ -7540,10 +7559,10 @@ class ga extends ws {
7540
7559
  this.links,
7541
7560
  this,
7542
7561
  this.index
7543
- ), this.selectionManager = new Gs(this.store), this.historyManager = new Xs(this.store, this.links), this.updateManager = new js(this.store), this.commentManager = new Os(this.store), this.initializeRenderers(), this.setupEvents();
7562
+ ), this.selectionManager = new js(this.store), this.historyManager = new Gs(this.store, this.links), this.updateManager = new qs(this.store), this.commentManager = new Ps(this.store), this.initializeRenderers(), this.setupEvents();
7544
7563
  }
7545
7564
  initializeRenderers() {
7546
- this.renderers.shapes = new Zo(this.ogma, this.store), this.renderers.handles = new Ro(this.ogma, this.store);
7565
+ this.renderers.shapes = new Jo(this.ogma, this.store), this.renderers.handles = new Ho(this.ogma, this.store);
7547
7566
  }
7548
7567
  setupEvents() {
7549
7568
  this.ogma.events.on("rotate", this.onRotate).on("zoom", this.onZoom).on("layoutEnd", this.onLayout), this.editor.addEventListener(
@@ -7559,7 +7578,7 @@ class ga extends ws {
7559
7578
  id: t.detail.id,
7560
7579
  position: t.detail.position
7561
7580
  }))), this.store.temporal.subscribe((t) => {
7562
- this.emit(Ss, {
7581
+ this.emit(Fs, {
7563
7582
  canUndo: t.pastStates.length > 0,
7564
7583
  canRedo: t.futureStates.length > 0
7565
7584
  });
@@ -7569,23 +7588,23 @@ class ga extends ws {
7569
7588
  const s = Array.from(t).filter(
7570
7589
  (r) => !(n != null && n.has(r))
7571
7590
  );
7572
- if (s.length > 0 && this.emit(Fs, { ids: s }), n) {
7591
+ if (s.length > 0 && this.emit(ys, { ids: s }), n) {
7573
7592
  const r = Array.from(n).filter((o) => !t.has(o));
7574
- r.length > 0 && this.emit(ys, { ids: r });
7593
+ r.length > 0 && this.emit(Es, { ids: r });
7575
7594
  }
7576
7595
  }
7577
7596
  ), this.store.subscribe(
7578
7597
  (t) => t.drawingFeature,
7579
7598
  (t, n) => {
7580
- t === null && n !== null && this.emit(Sn, { id: n });
7599
+ t === null && n !== null && this.emit(Fn, { id: n });
7581
7600
  }
7582
7601
  ), this.store.subscribe(
7583
7602
  (t) => t.features,
7584
7603
  (t, n) => {
7585
7604
  for (const s of Object.keys(t))
7586
- n[s] ? n[s] !== t[s] && this.emit(Es, t[s]) : this.emit(ue, { id: s });
7605
+ n[s] ? n[s] !== t[s] && this.emit(As, t[s]) : this.emit(ue, { id: s });
7587
7606
  for (const s of Object.keys(n))
7588
- t[s] || this.emit(As, { id: s });
7607
+ t[s] || this.emit(Ns, { id: s });
7589
7608
  }
7590
7609
  );
7591
7610
  }
@@ -7633,6 +7652,20 @@ class ga extends ws {
7633
7652
  const n = this.store.getState().getFeature(t);
7634
7653
  return !!n && this.store.getState().options.isVisible(n);
7635
7654
  }
7655
+ /**
7656
+ * (Re-)apply `id`'s handler attachment (drag/resize/text-edit) to match
7657
+ * `isEditable` right now, instead of waiting for a deselect/reselect -
7658
+ * this is the same call a selection change makes internally. Call it
7659
+ * directly after changing whatever external state your `isEditable`
7660
+ * predicate depends on (e.g. a `locked` flag kept outside the
7661
+ * annotation - see the lock-toolbar-item.ts example): closes any open
7662
+ * text editor and detaches the handler if `id` just became
7663
+ * non-editable, or attaches it if `id` is selected and just became
7664
+ * editable again.
7665
+ */
7666
+ editFeature(t) {
7667
+ return this.editor.editFeature(t), this;
7668
+ }
7636
7669
  /**
7637
7670
  * Add an annotation to the controller
7638
7671
  * @param annotation The annotation to add
@@ -7710,7 +7743,7 @@ class ga extends ws {
7710
7743
  */
7711
7744
  cancelDrawing() {
7712
7745
  var t;
7713
- return this.drawing.cancelPendingDrawing(), (t = this.editor.getActiveHandler()) == null || t.cancelDrawing(), this.emit(Ns), this;
7746
+ return this.drawing.cancelPendingDrawing(), (t = this.editor.getActiveHandler()) == null || t.cancelDrawing(), this.emit(Cs), this;
7714
7747
  }
7715
7748
  /**
7716
7749
  * Enable arrow drawing mode - the recommended way to add arrows.
@@ -8215,129 +8248,130 @@ class ga extends ws {
8215
8248
  export {
8216
8249
  Dt as COMMENT_MODE_COLLAPSED,
8217
8250
  de as COMMENT_MODE_EXPANDED,
8218
- ga as Control,
8219
- Sa as DATA_ATTR,
8220
- Nn as DEFAULT_EDIT_ICON,
8221
- Cn as DEFAULT_SEND_ICON,
8251
+ pa as Control,
8252
+ Fa as DATA_ATTR,
8253
+ Cn as DEFAULT_EDIT_ICON,
8254
+ vn as DEFAULT_SEND_ICON,
8222
8255
  ue as EVT_ADD,
8223
- Ns as EVT_CANCEL_DRAWING,
8256
+ Cs as EVT_CANCEL_DRAWING,
8224
8257
  kt as EVT_CLICK,
8225
- Sn as EVT_COMPLETE_DRAWING,
8258
+ Fn as EVT_COMPLETE_DRAWING,
8226
8259
  qt as EVT_DRAG,
8227
8260
  Yt as EVT_DRAG_END,
8228
8261
  Bt as EVT_DRAG_START,
8229
- Ss as EVT_HISTORY,
8230
- Fa as EVT_HOVER,
8231
- ms as EVT_LINK,
8232
- As as EVT_REMOVE,
8233
- Fs as EVT_SELECT,
8234
- ya as EVT_UNHOVER,
8235
- ys as EVT_UNSELECT,
8236
- Es as EVT_UPDATE,
8237
- Ea as HL_BRIGHTEN,
8238
- Ee as LAYERS,
8239
- is as MAX_FONT_SCALE,
8240
- rs as MIN_FONT_SCALE,
8241
- ns as NONE,
8262
+ Fs as EVT_HISTORY,
8263
+ ya as EVT_HOVER,
8264
+ Ss as EVT_LINK,
8265
+ Ns as EVT_REMOVE,
8266
+ ys as EVT_SELECT,
8267
+ Ea as EVT_UNHOVER,
8268
+ Es as EVT_UNSELECT,
8269
+ As as EVT_UPDATE,
8270
+ Aa as HL_BRIGHTEN,
8271
+ Ae as LAYERS,
8272
+ rs as MAX_FONT_SCALE,
8273
+ os as MIN_FONT_SCALE,
8274
+ ss as NONE,
8242
8275
  at as SIDE_END,
8243
8276
  q as SIDE_START,
8244
8277
  P as TARGET_TYPES,
8245
8278
  Tt as TEXT_LINE_HEIGHT,
8246
- Aa as adjustColorBrightness,
8247
- da as asColor,
8248
- ha as asHexColor,
8249
- ua as asRgbColor,
8250
- xa as asRgbaColor,
8279
+ Na as adjustColorBrightness,
8280
+ ha as asColor,
8281
+ ua as asHexColor,
8282
+ xa as asRgbColor,
8283
+ fa as asRgbaColor,
8251
8284
  Pt as brighten,
8252
- An as bringToTop,
8253
- Na as calculateCommentZoomThreshold,
8254
- fa as canDetachArrowEnd,
8255
- Vs as canDetachArrowStart,
8256
- vt as clientToContainerPosition,
8257
- Ca as colorToRgba,
8285
+ Nn as bringToTop,
8286
+ Ca as calculateCommentZoomThreshold,
8287
+ ga as canDetachArrowEnd,
8288
+ Zs as canDetachArrowStart,
8289
+ yt as clientToContainerPosition,
8290
+ va as colorToRgba,
8291
+ ye as containerToClientPosition,
8258
8292
  he as createArrow,
8259
- Be as createBox,
8260
- Qn as createComment,
8261
- va as createCommentWithArrow,
8262
- Jn as createPolygon,
8293
+ ke as createBox,
8294
+ ts as createComment,
8295
+ Ma as createCommentWithArrow,
8296
+ Qn as createPolygon,
8263
8297
  O as createSVGElement,
8264
8298
  te as createText,
8265
8299
  z as cursors,
8266
- Ma as darken,
8267
- ba as debounce,
8268
- wa as debounceTail,
8269
- Da as defaultArrowOptions,
8270
- gn as defaultArrowStyle,
8271
- Ba as defaultBoxOptions,
8272
- ss as defaultBoxStyle,
8273
- ka as defaultCommentOptions,
8300
+ ba as darken,
8301
+ wa as debounce,
8302
+ Da as debounceTail,
8303
+ Ba as defaultArrowOptions,
8304
+ pn as defaultArrowStyle,
8305
+ ka as defaultBoxOptions,
8306
+ is as defaultBoxStyle,
8307
+ La as defaultCommentOptions,
8274
8308
  rt as defaultCommentStyle,
8275
- La as defaultPolygonProperties,
8276
- Et as defaultPolygonStyle,
8277
- Ta as defaultTextOptions,
8309
+ Ta as defaultPolygonProperties,
8310
+ At as defaultPolygonStyle,
8311
+ Oa as defaultTextOptions,
8278
8312
  j as defaultTextStyle,
8279
- pn as detectArrow,
8280
- as as detectBox,
8281
- cs as detectComment,
8282
- mn as detectPolygon,
8283
- ls as detectText,
8284
- Oa as getAnnotationsBounds,
8285
- fs as getArrowEnd,
8286
- yn as getArrowEndPoints,
8313
+ mn as detectArrow,
8314
+ cs as detectBox,
8315
+ ls as detectComment,
8316
+ Sn as detectPolygon,
8317
+ ds as detectText,
8318
+ Pa as getAnnotationsBounds,
8319
+ gs as getArrowEnd,
8320
+ En as getArrowEndPoints,
8287
8321
  xe as getArrowSide,
8288
- xs as getArrowStart,
8289
- Pa as getAttachmentPointOnNode,
8290
- yt as getBbox,
8322
+ fs as getArrowStart,
8323
+ Ra as getAttachmentPointOnNode,
8324
+ Et as getBbox,
8291
8325
  Z as getBoxCenter,
8292
8326
  fe as getBoxPosition,
8293
8327
  K as getBoxSize,
8294
- Zn as getBrowserWindow,
8295
- Zs as getCascadeDeleteIds,
8296
- Js as getCommentLeftOrphanedBy,
8297
- Ks as getCommentLinkId,
8298
- Ra as getCommentPosition,
8299
- hs as getCommentSize,
8300
- Ha as getCommentZoomThreshold,
8301
- Ia as getCoordinates,
8328
+ Jn as getBrowserWindow,
8329
+ Js as getCascadeDeleteIds,
8330
+ Qs as getCommentLeftOrphanedBy,
8331
+ Vs as getCommentLinkId,
8332
+ Ha as getCommentPosition,
8333
+ us as getCommentSize,
8334
+ Ia as getCommentZoomThreshold,
8335
+ za as getCoordinates,
8302
8336
  Xt as getEffectiveFontSize,
8303
- za as getHandleId,
8304
- vn as getPolygonBounds,
8305
- Mn as getPolygonCenter,
8306
- yt as getTextBbox,
8337
+ _a as getHandleId,
8338
+ Mn as getPolygonBounds,
8339
+ bn as getPolygonCenter,
8340
+ Et as getTextBbox,
8307
8341
  fe as getTextPosition,
8308
8342
  K as getTextSize,
8309
- ye as handleDetectionThreshold,
8310
- os as handleRadius,
8311
- _a as hexShortToLong,
8312
- Ua as hexToRgba,
8313
- Oe as isAnnotationCollection,
8343
+ Ee as handleDetectionThreshold,
8344
+ as as handleRadius,
8345
+ Ua as hexShortToLong,
8346
+ Wa as hexToRgba,
8347
+ Pe as isAnnotationCollection,
8314
8348
  Q as isArrow,
8315
8349
  G as isBox,
8316
- Ts as isColor,
8350
+ Os as isColor,
8317
8351
  H as isComment,
8318
- qs as isCommentArrow,
8319
- wn as isHexColor,
8352
+ Ks as isCommentArrow,
8353
+ Dn as isHexColor,
8320
8354
  J as isPolygon,
8321
- Dn as isRgbColor,
8322
- Bn as isRgbaColor,
8323
- ds as isRigidConnector,
8324
- Wa as isStickyNote,
8355
+ Bn as isRgbColor,
8356
+ kn as isRgbaColor,
8357
+ hs as isRigidConnector,
8358
+ $a as isStickyNote,
8325
8359
  _ as isText,
8326
- ts as migrateBoxOrTextIfNeeded,
8327
- $a as parseColor,
8328
- Ya as rgbToRgba,
8329
- Xa as scaleGeometry,
8330
- la as scalePolygon,
8331
- Ga as setArrowEnd,
8332
- es as setArrowEndPoint,
8333
- ja as setArrowStart,
8334
- qa as setBbox,
8335
- Ka as setTextBbox,
8336
- Te as simplifyPolygon,
8337
- Fn as throttle,
8338
- Va as toggleCommentMode,
8339
- ca as translatePolygon,
8360
+ es as migrateBoxOrTextIfNeeded,
8361
+ Ya as parseColor,
8362
+ Xa as rgbToRgba,
8363
+ Ga as scaleGeometry,
8364
+ da as scalePolygon,
8365
+ ja as setArrowEnd,
8366
+ ns as setArrowEndPoint,
8367
+ qa as setArrowStart,
8368
+ Ka as setBbox,
8369
+ Va as setTextBbox,
8370
+ Oe as simplifyPolygon,
8371
+ yn as throttle,
8372
+ Za as toggleCommentMode,
8373
+ la as translatePolygon,
8340
8374
  Lt as updateBbox,
8341
- bn as updatePolygonBbox,
8375
+ wn as updatePolygonBbox,
8342
8376
  Lt as updateTextBbox
8343
8377
  };