@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.
@@ -2,7 +2,7 @@ const it = -1, at = "dragging", ct = "dragstart", dt = "dragend", ut = "click",
2
2
  SHAPES: 1,
3
3
  EDITOR: 2,
4
4
  HANDLES: 3
5
- }, b = "start", At = "end", Ct = {
5
+ }, b = "start", Ct = "end", At = {
6
6
  default: "default",
7
7
  move: "move",
8
8
  pointer: "pointer",
@@ -208,14 +208,22 @@ function vt(t, e) {
208
208
  y: t.clientY - n.top - e.clientTop
209
209
  };
210
210
  }
211
- const Z = { r: 0, g: 0, b: 0, a: 0 };
212
211
  function $t(t, e) {
212
+ if (!e) return t;
213
+ const n = e.getBoundingClientRect();
214
+ return {
215
+ x: t.x + n.left + e.clientLeft,
216
+ y: t.y + n.top + e.clientTop
217
+ };
218
+ }
219
+ const Z = { r: 0, g: 0, b: 0, a: 0 };
220
+ function Ut(t, e) {
213
221
  return t === "transparent" || t === "none" ? "rgba(0, 0, 0, 0)" : t.startsWith("#") ? K(t, e) : t.startsWith("rgb") ? Q(t, e) : t;
214
222
  }
215
- function Ut(t) {
223
+ function qt(t) {
216
224
  if (t === "transparent" || t === "none") return Z;
217
225
  if (t.startsWith("#")) {
218
- const e = C(t), n = parseInt(e.slice(1, 3), 16), r = parseInt(e.slice(3, 5), 16), s = parseInt(e.slice(5, 7), 16);
226
+ const e = A(t), n = parseInt(e.slice(1, 3), 16), r = parseInt(e.slice(3, 5), 16), s = parseInt(e.slice(5, 7), 16);
219
227
  return { r: n, g: r, b: s, a: 1 };
220
228
  } else {
221
229
  const e = t.match(
@@ -230,21 +238,21 @@ function Ut(t) {
230
238
  };
231
239
  }
232
240
  }
233
- function C(t) {
241
+ function A(t) {
234
242
  return t.length === 4 ? t.split("").map((e) => e + e).join("") : t;
235
243
  }
236
244
  function K(t, e) {
237
- const [n, r, s] = C(t).match(/\w\w/g).map((o) => parseInt(o, 16));
245
+ const [n, r, s] = A(t).match(/\w\w/g).map((o) => parseInt(o, 16));
238
246
  return `rgba(${n}, ${r}, ${s}, ${e})`;
239
247
  }
240
248
  function Q(t, e) {
241
249
  const [n, r, s] = t.match(/\d+/g).map((o) => parseInt(o, 10));
242
250
  return `rgba(${n}, ${r}, ${s}, ${e})`;
243
251
  }
244
- function qt() {
252
+ function Zt() {
245
253
  return typeof window < "u" ? window : void 0;
246
254
  }
247
- const Zt = (t, e = 16, n = !1) => {
255
+ const Kt = (t, e = 16, n = !1) => {
248
256
  let r = !1, s = null;
249
257
  const o = Math.max(1, Math.round(e * 60 / 1e3)), i = (a) => {
250
258
  requestAnimationFrame(() => {
@@ -263,13 +271,13 @@ const Zt = (t, e = 16, n = !1) => {
263
271
  }
264
272
  t(...a), r = !0, i(o);
265
273
  };
266
- }, Kt = (t, e) => {
274
+ }, Qt = (t, e) => {
267
275
  let n;
268
276
  return (...s) => {
269
277
  clearTimeout(n), n = setTimeout(() => t(...s), e);
270
278
  };
271
279
  };
272
- function Qt(t, e) {
280
+ function Jt(t, e) {
273
281
  let n;
274
282
  return function(...r) {
275
283
  clearTimeout(n), n = setTimeout(() => {
@@ -277,7 +285,7 @@ function Qt(t, e) {
277
285
  }, e);
278
286
  };
279
287
  }
280
- function Jt(t) {
288
+ function jt(t) {
281
289
  if ((L(t) || k(t)) && t.geometry.type === "Polygon") {
282
290
  const e = t.geometry.coordinates[0], n = e[0][0], r = e[0][1], s = e[2][0], o = e[2][1], i = s - n, a = o - r, c = n + i / 2, d = r + a / 2;
283
291
  return {
@@ -300,7 +308,7 @@ function O(t, e) {
300
308
  let n, r, s, o = 1;
301
309
  const i = t.trim();
302
310
  if (i.startsWith("#")) {
303
- const y = (i.length === 4 ? C(i) : i).match(/#?(\w{2})(\w{2})(\w{2})/);
311
+ const y = (i.length === 4 ? A(i) : i).match(/#?(\w{2})(\w{2})(\w{2})/);
304
312
  if (!y) return t;
305
313
  n = parseInt(y[1], 16), r = parseInt(y[2], 16), s = parseInt(y[3], 16);
306
314
  } else {
@@ -313,10 +321,10 @@ function O(t, e) {
313
321
  const a = e * 100, d = 0.299 * n + 0.587 * r + 0.114 * s > 186 ? -a / 2 : a;
314
322
  return n = Math.max(0, Math.min(255, n + Math.round(2.55 * d))), r = Math.max(0, Math.min(255, r + Math.round(2.55 * d))), s = Math.max(0, Math.min(255, s + Math.round(2.55 * d))), `rgba(${n},${r},${s},${o})`;
315
323
  }
316
- const jt = (t) => O(t, F), te = (t) => O(t, -F), R = (t, e) => ({
324
+ const te = (t) => O(t, F), ee = (t) => O(t, -F), R = (t, e) => ({
317
325
  x: t.x - e.x,
318
326
  y: t.y - e.y
319
- }), D = (t) => Math.sqrt(t.x * t.x + t.y * t.y), ee = (t) => ({
327
+ }), D = (t) => Math.sqrt(t.x * t.x + t.y * t.y), ne = (t) => ({
320
328
  x: -t.x,
321
329
  y: -t.y
322
330
  }), P = (t) => {
@@ -325,20 +333,20 @@ const jt = (t) => O(t, F), te = (t) => O(t, -F), R = (t, e) => ({
325
333
  x: t.x / e,
326
334
  y: t.y / e
327
335
  };
328
- }, ne = (t, e) => ({
336
+ }, re = (t, e) => ({
329
337
  x: t.x + e.x,
330
338
  y: t.y + e.y
331
- }), re = (t, e) => ({
339
+ }), se = (t, e) => ({
332
340
  x: t.x * e,
333
341
  y: t.y * e
334
- }), se = (t, e) => {
342
+ }), oe = (t, e) => {
335
343
  const n = Math.sin(e), r = Math.cos(e);
336
344
  return {
337
345
  x: t.x * r - t.y * n,
338
346
  y: t.x * n + t.y * r
339
347
  };
340
348
  }, J = (t, e) => t.x * e.x + t.y * e.y, j = (t, e) => t.x * e.y - t.y * e.x, tt = (t) => t.properties.type === "arrow";
341
- function oe(t, e, n) {
349
+ function ie(t, e, n) {
342
350
  const { start: r, end: s } = U(t), o = R(e, r), i = t.properties.style.strokeWidth, a = R(s, r), c = D(a), d = J(o, P(a));
343
351
  return d > 0 && d < c && Math.abs(j(o, P(a))) < i / 2 + n;
344
352
  }
@@ -348,7 +356,7 @@ const E = {
348
356
  strokeWidth: 1,
349
357
  head: "none",
350
358
  tail: "none"
351
- }, ie = {
359
+ }, ae = {
352
360
  id: void 0,
353
361
  // will be set by the editor
354
362
  type: "Feature",
@@ -393,7 +401,7 @@ const E = {
393
401
  ]
394
402
  }
395
403
  }), L = (t) => t.properties.type === "box";
396
- function ae(t, e, n = 0, r = 1, s = 0) {
404
+ function ce(t, e, n = 0, r = 1, s = 0) {
397
405
  const o = Y(t), { width: i, height: a } = z(t), c = e.x - o.x, d = e.y - o.y, u = c * r - d * n, y = c * n + d * r;
398
406
  return u > -s && u < i + s && y > -s && y < a + s;
399
407
  }
@@ -404,7 +412,7 @@ const I = {
404
412
  boxShadow: "",
405
413
  padding: 16,
406
414
  strokeType: "plain"
407
- }, ce = {
415
+ }, de = {
408
416
  id: void 0,
409
417
  // will be set by the editor
410
418
  type: "Feature",
@@ -420,7 +428,7 @@ const I = {
420
428
  // center of 100x50 box
421
429
  bbox: [0, 0, 100, 50]
422
430
  }
423
- }, de = (t = 0, e = 0, n = 100, r = 50, s = { ...I }) => ({
431
+ }, ue = (t = 0, e = 0, n = 100, r = 50, s = { ...I }) => ({
424
432
  id: g(),
425
433
  type: "Feature",
426
434
  properties: {
@@ -434,10 +442,10 @@ const I = {
434
442
  coordinates: [t + n / 2, e + r / 2]
435
443
  // center
436
444
  }
437
- }), k = (t) => t.properties.type === "text", ue = (t) => {
445
+ }), k = (t) => t.properties.type === "text", ye = (t) => {
438
446
  const e = t.properties.style;
439
447
  return (e == null ? void 0 : e.scaleFontOnResize) === !0 && (e == null ? void 0 : e.placeholder) === "Quick note…";
440
- }, A = {
448
+ }, C = {
441
449
  font: "sans-serif",
442
450
  fontSize: 18,
443
451
  color: "#505050",
@@ -447,7 +455,7 @@ const I = {
447
455
  padding: 16,
448
456
  strokeType: "plain",
449
457
  fixedSize: !1
450
- }, ye = {
458
+ }, le = {
451
459
  id: g(),
452
460
  type: "Feature",
453
461
  properties: {
@@ -455,7 +463,7 @@ const I = {
455
463
  content: "",
456
464
  width: 100,
457
465
  height: 50,
458
- style: { ...A }
466
+ style: { ...C }
459
467
  },
460
468
  geometry: {
461
469
  type: "Point",
@@ -463,7 +471,7 @@ const I = {
463
471
  // center of 100x50 box
464
472
  bbox: [0, 0, 100, 50]
465
473
  }
466
- }, le = (t = 0, e = 0, n = 100, r = 50, s = "", o = { ...A }) => ({
474
+ }, fe = (t = 0, e = 0, n = 100, r = 50, s = "", o = { ...C }) => ({
467
475
  id: g(),
468
476
  type: "Feature",
469
477
  properties: {
@@ -471,7 +479,7 @@ const I = {
471
479
  content: s,
472
480
  width: n,
473
481
  height: r,
474
- style: { ...A, ...o }
482
+ style: { ...C, ...o }
475
483
  },
476
484
  geometry: {
477
485
  type: "Point",
@@ -488,7 +496,7 @@ function nt(t, e, n = 0, r = 0, s = 1, o = 1) {
488
496
  const u = c / 2, y = d / 2, l = e.x - i, f = e.y - a, h = l * s - f * r, x = l * r + f * s;
489
497
  return h > -u - n && h < u + n && x > -y - n && x < y + n;
490
498
  }
491
- const fe = (t) => t.properties.type === "comment", p = {
499
+ const ge = (t) => t.properties.type === "comment", p = {
492
500
  // Box styling
493
501
  background: "#FFFACD",
494
502
  // Light yellow (sticky note color)
@@ -553,7 +561,7 @@ function rt(t, e, n, r) {
553
561
  }
554
562
  };
555
563
  }
556
- function ge(t) {
564
+ function pe(t) {
557
565
  return {
558
566
  ...t,
559
567
  properties: {
@@ -562,7 +570,7 @@ function ge(t) {
562
570
  }
563
571
  };
564
572
  }
565
- function pe(t, e, n = 0, r, s, o = 1) {
573
+ function he(t, e, n = 0, r, s, o = 1) {
566
574
  if (t.properties.mode !== w)
567
575
  return nt(
568
576
  t,
@@ -578,11 +586,11 @@ function pe(t, e, n = 0, r, s, o = 1) {
578
586
  const u = c / 2, y = d / 2, l = e.x - t.geometry.coordinates[0], f = e.y - t.geometry.coordinates[1];
579
587
  return l >= -u - n && l <= u + n && f >= -y - n && f <= y + n;
580
588
  }
581
- function he(t) {
589
+ function xe(t) {
582
590
  const [e, n] = t.geometry.coordinates;
583
591
  return { x: e, y: n };
584
592
  }
585
- function xe(t) {
593
+ function me(t) {
586
594
  const e = t.properties, n = { ...p, ...e.style };
587
595
  return e.mode === w ? { width: n.iconSize, height: n.iconSize } : { width: e.width, height: e.height };
588
596
  }
@@ -590,14 +598,14 @@ function st(t, e = 80) {
590
598
  const n = e / t.properties.width;
591
599
  return Math.max(0.1, Math.min(1, n));
592
600
  }
593
- function me(t) {
601
+ function Te(t) {
594
602
  return ({ ...p, ...t.properties.style }.connectorMode ?? "rigid") !== "elastic";
595
603
  }
596
- function Te(t) {
604
+ function be(t) {
597
605
  const e = { ...p, ...t.properties.style };
598
606
  return e.collapseZoomThreshold !== void 0 ? e.collapseZoomThreshold : st(t);
599
607
  }
600
- function be(t, e, n, r, s = "", o) {
608
+ function we(t, e, n, r, s = "", o) {
601
609
  const i = rt(
602
610
  n,
603
611
  r,
@@ -618,7 +626,7 @@ function be(t, e, n, r, s = "", o) {
618
626
  }
619
627
  }, { comment: i, arrow: c };
620
628
  }
621
- function we(t, e, n, r, s, o, i, a, c) {
629
+ function Ee(t, e, n, r, s, o, i, a, c) {
622
630
  const d = t - i, u = e - a, y = i + d * o - u * s, l = a + d * s + u * o, f = i + (d + n) * o - u * s, h = a + (d + n) * s + u * o, x = i + (d + n) * o - (u + r) * s, m = a + (d + n) * s + (u + r) * o, M = i + d * o - (u + r) * s, _ = a + d * s + (u + r) * o;
623
631
  return c[0] = Math.min(y, f, x, M), c[1] = Math.min(l, h, m, _), c[2] = Math.max(y, f, x, M), c[3] = Math.max(l, h, m, _), c;
624
632
  }
@@ -633,8 +641,8 @@ function ot(t, e, n) {
633
641
  const a = e.x + i * r, c = e.y + i * s, d = t.x - a, u = t.y - c;
634
642
  return Math.sqrt(d * d + u * u);
635
643
  }
636
- const Ee = (t) => t.properties.type === "polygon";
637
- function Ie(t, e, n = 0) {
644
+ const Ie = (t) => t.properties.type === "polygon";
645
+ function Se(t, e, n = 0) {
638
646
  const r = t.geometry.coordinates[0], s = t.geometry.bbox;
639
647
  if (s) {
640
648
  const [i, a, c, d] = s;
@@ -654,7 +662,7 @@ function Ie(t, e, n = 0) {
654
662
  }
655
663
  return !1;
656
664
  }
657
- function Se(t, e) {
665
+ function Ne(t, e) {
658
666
  const n = t[0];
659
667
  n.length > 0 && (n[0][0] !== n[n.length - 1][0] || n[0][1] !== n[n.length - 1][1]) && n.push([n[0][0], n[0][1]]);
660
668
  let r = 1 / 0, s = 1 / 0, o = -1 / 0, i = -1 / 0;
@@ -684,121 +692,122 @@ const V = {
684
692
  strokeColor: "#000000",
685
693
  strokeWidth: 2,
686
694
  background: "transparent"
687
- }, Ne = {
695
+ }, Ce = {
688
696
  type: "polygon",
689
697
  style: {
690
698
  ...V
691
699
  }
692
700
  };
693
701
  export {
694
- re as $,
695
- Ie as A,
696
- H as B,
702
+ me as $,
703
+ It as A,
704
+ Se as B,
697
705
  w as C,
698
- mt as D,
706
+ H as D,
699
707
  ct as E,
700
- z as F,
701
- I as G,
702
- jt as H,
703
- Y as I,
704
- Ft as J,
705
- A as K,
706
- Lt as L,
707
- Mt as M,
708
+ mt as F,
709
+ z as G,
710
+ I as H,
711
+ te as I,
712
+ Y as J,
713
+ Ft as K,
714
+ C as L,
715
+ Lt as M,
708
716
  it as N,
709
- p as O,
710
- Nt as P,
711
- J as Q,
712
- Dt as R,
717
+ Mt as O,
718
+ p as P,
719
+ Nt as Q,
720
+ J as R,
713
721
  b as S,
714
722
  _t as T,
715
- Ot as U,
716
- St as V,
717
- ae as W,
718
- pe as X,
719
- nt as Y,
720
- me as Z,
721
- xe as _,
723
+ Dt as U,
724
+ Ot as V,
725
+ St as W,
726
+ ce as X,
727
+ he as Y,
728
+ nt as Z,
729
+ Te as _,
722
730
  B as a,
723
- ne as a0,
724
- g as a1,
725
- Zt as a2,
726
- R as a3,
727
- D as a4,
728
- S as a5,
729
- W as a6,
730
- X as a7,
731
- U as a8,
732
- P as a9,
733
- ce as aA,
734
- N as aB,
735
- Ne as aC,
736
- ye as aD,
737
- Ht as aE,
738
- Xt as aF,
739
- he as aG,
740
- Te as aH,
741
- T as aI,
742
- Yt as aJ,
743
- C as aK,
744
- K as aL,
745
- ue as aM,
746
- Ut as aN,
747
- Q as aO,
748
- Wt as aP,
749
- $ as aQ,
750
- v as aR,
751
- Vt as aS,
752
- ge as aT,
753
- ee as aa,
754
- zt as ab,
755
- se as ac,
756
- V as ad,
757
- Pt as ae,
758
- Rt as af,
759
- we as ag,
760
- bt as ah,
761
- wt as ai,
762
- yt as aj,
763
- lt as ak,
764
- Tt as al,
765
- pt as am,
766
- xt as an,
767
- Et as ao,
768
- ft as ap,
769
- gt as aq,
770
- F as ar,
771
- O as as,
772
- st as at,
773
- $t as au,
774
- be as av,
775
- te as aw,
776
- Kt as ax,
731
+ se as a0,
732
+ re as a1,
733
+ g as a2,
734
+ Kt as a3,
735
+ R as a4,
736
+ D as a5,
737
+ S as a6,
738
+ W as a7,
739
+ X as a8,
740
+ U as a9,
741
+ ae as aA,
742
+ de as aB,
743
+ N as aC,
744
+ Ce as aD,
745
+ le as aE,
746
+ Ht as aF,
747
+ Xt as aG,
748
+ xe as aH,
749
+ be as aI,
750
+ T as aJ,
751
+ Yt as aK,
752
+ A as aL,
753
+ K as aM,
754
+ ye as aN,
755
+ qt as aO,
756
+ Q as aP,
757
+ Wt as aQ,
758
+ $ as aR,
759
+ v as aS,
760
+ Vt as aT,
761
+ pe as aU,
762
+ P as aa,
763
+ ne as ab,
764
+ zt as ac,
765
+ oe as ad,
766
+ V as ae,
767
+ Pt as af,
768
+ Rt as ag,
769
+ Ee as ah,
770
+ bt as ai,
771
+ wt as aj,
772
+ yt as ak,
773
+ lt as al,
774
+ Tt as am,
775
+ pt as an,
776
+ xt as ao,
777
+ Et as ap,
778
+ ft as aq,
779
+ gt as ar,
780
+ F as as,
781
+ O as at,
782
+ st as au,
783
+ Ut as av,
784
+ we as aw,
785
+ ee as ax,
777
786
  Qt as ay,
778
- ie as az,
787
+ Jt as az,
779
788
  dt as b,
780
- Ct as c,
789
+ At as c,
781
790
  at as d,
782
791
  vt as e,
783
792
  et as f,
784
- qt as g,
793
+ Zt as g,
785
794
  E as h,
786
- fe as i,
795
+ ge as i,
787
796
  tt as j,
788
- At as k,
797
+ Ct as k,
789
798
  ut as l,
790
- le as m,
791
- de as n,
792
- Se as o,
799
+ fe as m,
800
+ ue as n,
801
+ Ne as o,
793
802
  rt as p,
794
803
  ht as q,
795
- Jt as r,
804
+ jt as r,
796
805
  k as s,
797
806
  L as t,
798
807
  kt as u,
799
- Ee as v,
800
- oe as w,
801
- Bt as x,
802
- Gt as y,
803
- It as z
808
+ Ie as v,
809
+ ie as w,
810
+ $t as x,
811
+ Bt as y,
812
+ Gt as z
804
813
  };