@annotorious/react 3.0.0-rc.6 → 3.0.0-rc.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/annotorious-react.es.js +23 -44
  2. package/dist/annotorious-react.es.js.map +1 -1
  3. package/dist/annotorious-react.es10.js +29 -3
  4. package/dist/annotorious-react.es10.js.map +1 -1
  5. package/dist/annotorious-react.es11.js +36 -27
  6. package/dist/annotorious-react.es11.js.map +1 -1
  7. package/dist/annotorious-react.es12.js +16 -20
  8. package/dist/annotorious-react.es12.js.map +1 -1
  9. package/dist/annotorious-react.es13.js +4 -54
  10. package/dist/annotorious-react.es13.js.map +1 -1
  11. package/dist/annotorious-react.es14.js +8 -17
  12. package/dist/annotorious-react.es14.js.map +1 -1
  13. package/dist/annotorious-react.es15.js +152 -21
  14. package/dist/annotorious-react.es15.js.map +1 -1
  15. package/dist/annotorious-react.es16.js +6 -2
  16. package/dist/annotorious-react.es16.js.map +1 -1
  17. package/dist/annotorious-react.es17.js +2 -2
  18. package/dist/annotorious-react.es17.js.map +1 -1
  19. package/dist/annotorious-react.es18.js +29 -3925
  20. package/dist/annotorious-react.es18.js.map +1 -1
  21. package/dist/annotorious-react.es19.js +597 -27
  22. package/dist/annotorious-react.es19.js.map +1 -1
  23. package/dist/annotorious-react.es2.js +2 -2
  24. package/dist/annotorious-react.es20.js +20707 -33
  25. package/dist/annotorious-react.es20.js.map +1 -1
  26. package/dist/annotorious-react.es21.js +32 -16
  27. package/dist/annotorious-react.es21.js.map +1 -1
  28. package/dist/annotorious-react.es22.js +2 -4
  29. package/dist/annotorious-react.es22.js.map +1 -1
  30. package/dist/annotorious-react.es23.js +2 -8
  31. package/dist/annotorious-react.es23.js.map +1 -1
  32. package/dist/annotorious-react.es4.js +2 -2
  33. package/dist/annotorious-react.es5.js +2 -2
  34. package/dist/annotorious-react.es8.js +21 -58
  35. package/dist/annotorious-react.es8.js.map +1 -1
  36. package/dist/annotorious-react.es9.js +3924 -10
  37. package/dist/annotorious-react.es9.js.map +1 -1
  38. package/dist/index.d.ts +3 -6
  39. package/dist/index.d.ts.map +1 -1
  40. package/package.json +1 -2
  41. package/dist/annotorious-react.es24.js +0 -156
  42. package/dist/annotorious-react.es24.js.map +0 -1
  43. package/dist/annotorious-react.es25.js +0 -9
  44. package/dist/annotorious-react.es25.js.map +0 -1
  45. package/dist/annotorious-react.es26.js +0 -5
  46. package/dist/annotorious-react.es26.js.map +0 -1
  47. package/dist/annotorious-react.es27.js +0 -33
  48. package/dist/annotorious-react.es27.js.map +0 -1
  49. package/dist/annotorious-react.es28.js +0 -602
  50. package/dist/annotorious-react.es28.js.map +0 -1
  51. package/dist/annotorious-react.es29.js +0 -20133
  52. package/dist/annotorious-react.es29.js.map +0 -1
  53. package/dist/annotorious-react.es30.js +0 -35
  54. package/dist/annotorious-react.es30.js.map +0 -1
  55. package/dist/annotorious-react.es31.js +0 -5
  56. package/dist/annotorious-react.es31.js.map +0 -1
  57. package/dist/annotorious-react.es32.js +0 -5
  58. package/dist/annotorious-react.es32.js.map +0 -1
  59. package/dist/annotorious-react.es33.js +0 -19
  60. package/dist/annotorious-react.es33.js.map +0 -1
  61. package/dist/annotorious-react.es34.js +0 -20
  62. package/dist/annotorious-react.es34.js.map +0 -1
  63. package/dist/annotorious-react.es35.js +0 -30
  64. package/dist/annotorious-react.es35.js.map +0 -1
  65. package/dist/annotorious-react.es36.js +0 -24
  66. package/dist/annotorious-react.es36.js.map +0 -1
  67. package/dist/annotorious-react.es37.js +0 -19
  68. package/dist/annotorious-react.es37.js.map +0 -1
  69. package/dist/annotorious-react.es38.js +0 -7
  70. package/dist/annotorious-react.es38.js.map +0 -1
  71. package/dist/annotorious-react.es39.js +0 -11
  72. package/dist/annotorious-react.es39.js.map +0 -1
  73. package/dist/annotorious-react.es40.js +0 -10
  74. package/dist/annotorious-react.es40.js.map +0 -1
@@ -1,19 +1,35 @@
1
- import { jsx as m } from "./annotorious-react.es22.js";
2
- import { forwardRef as a, useRef as c, useContext as p, useEffect as u, useImperativeHandle as d } from "react";
3
- import l from "openseadragon";
4
- import { OpenSeadragonAnnotatorContext as v } from "./annotorious-react.es19.js";
5
- const S = a((n, i) => {
6
- const { className: s, options: t } = n, r = c(null), { viewer: f, setViewer: e } = p(v);
7
- return u(() => {
8
- if (r.current) {
9
- const o = l({ ...t, element: r.current });
10
- return e && e(o), () => {
11
- o.destroy(), e && e(void 0);
12
- };
13
- }
14
- }, [JSON.stringify(t)]), d(i, () => f), /* @__PURE__ */ m("div", { className: s, ref: r });
15
- });
1
+ import w from "openseadragon";
2
+ const L = (i, h) => {
3
+ const e = i.element.getBoundingClientRect(), { minX: n, minY: l, maxX: t, maxY: c } = h.target.selector.geometry.bounds, s = i.viewport.imageToViewerElementCoordinates(new w.Point(n, l)), x = i.viewport.imageToViewerElementCoordinates(new w.Point(t, c));
4
+ return {
5
+ x: s.x + e.x,
6
+ right: x.x + e.x,
7
+ y: s.y + e.y,
8
+ bottom: x.y + e.y,
9
+ width: x.x - s.x,
10
+ height: x.y - s.y
11
+ };
12
+ }, T = (i, h, e, n = 5) => {
13
+ const l = i.element.getBoundingClientRect(), t = L(i, h), c = t.y - l.y, s = l.right - t.x, x = l.bottom - t.bottom, d = t.x - l.left, o = e.firstElementChild.getBoundingClientRect(), g = c / o.height, y = s / o.width, a = x / o.height, r = d / o.width, $ = () => {
14
+ e.style.left = `${t.x}px`, e.style.top = `${t.y - n - o.height}px`;
15
+ }, f = () => {
16
+ e.style.left = `${t.right - o.width}px`, e.style.top = `${t.y - n - o.height}px`;
17
+ }, B = () => {
18
+ e.style.left = `${t.x - o.width - n}px`, e.style.top = `${t.y}px`;
19
+ }, v = () => {
20
+ e.style.left = `${t.right + n}px`, e.style.top = `${t.y}px`;
21
+ }, R = () => {
22
+ e.style.left = `${t.x - o.width - n}px`, e.style.top = `${t.bottom - o.height}px`;
23
+ }, C = () => {
24
+ e.style.left = `${t.x + t.width + n}px`, e.style.top = `${t.bottom - o.height}px`;
25
+ }, E = () => {
26
+ e.style.left = `${t.x}px`, e.style.top = `${t.bottom + n}px`;
27
+ }, A = () => {
28
+ e.style.left = `${t.right - o.width}px`, e.style.top = `${t.bottom + n}px`;
29
+ }, b = [g, y, a, r], m = b.indexOf(Math.max(...b));
30
+ m === 0 ? y > r ? $() : f() : m === 1 ? g > a ? C() : v() : m === 2 ? y > r ? E() : A() : g > a ? R() : B();
31
+ };
16
32
  export {
17
- S as OpenSeadragonViewer
33
+ T as setPosition
18
34
  };
19
35
  //# sourceMappingURL=annotorious-react.es21.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es21.js","sources":["../src/openseadragon/OpenSeadragonViewer.tsx"],"sourcesContent":["import { forwardRef, useContext, useEffect, useImperativeHandle, useRef } from 'react';\nimport OpenSeadragon from 'openseadragon';\nimport { OpenSeadragonAnnotatorContext } from './OpenSeadragonAnnotator';\n\nexport interface OpenSeadragonViewerProps {\n\n className?: string;\n\n options: OpenSeadragon.Options;\n\n}\n\nexport const OpenSeadragonViewer = forwardRef<OpenSeadragon.Viewer, OpenSeadragonViewerProps>((props: OpenSeadragonViewerProps, ref) => {\n\n const { className, options } = props;\n\n const element = useRef<HTMLDivElement>(null);\n\n const { viewer, setViewer } = useContext(OpenSeadragonAnnotatorContext);\n\n useEffect(() => { \n if (element.current) {\n const v = OpenSeadragon({...options, element: element.current });\n\n // Checking for setViewer is just a convenience so we can\n // use this component also without an OpenSeadragonAnnotator\n if (setViewer)\n setViewer(v);\n\n return () => {\n v.destroy();\n\n if (setViewer) \n setViewer(undefined);\n }\n }\n }, [JSON.stringify(options)]);\n\n useImperativeHandle(ref, () => viewer);\n\n return (\n <div className={className} ref={element} />\n );\n\n});"],"names":["OpenSeadragonViewer","forwardRef","props","ref","className","options","element","useRef","viewer","setViewer","useContext","OpenSeadragonAnnotatorContext","useEffect","v","OpenSeadragon","useImperativeHandle","jsx"],"mappings":";;;;AAYO,MAAMA,IAAsBC,EAA2D,CAACC,GAAiCC,MAAQ;AAEhI,QAAA,EAAE,WAAAC,GAAW,SAAAC,EAAY,IAAAH,GAEzBI,IAAUC,EAAuB,IAAI,GAErC,EAAE,QAAAC,GAAQ,WAAAC,EAAU,IAAIC,EAAWC,CAA6B;AAEtE,SAAAC,EAAU,MAAM;AACd,QAAIN,EAAQ,SAAS;AACb,YAAAO,IAAIC,EAAc,EAAC,GAAGT,GAAS,SAASC,EAAQ,SAAS;AAI3D,aAAAG,KACFA,EAAUI,CAAC,GAEN,MAAM;AACX,QAAAA,EAAE,QAAQ,GAENJ,KACFA,EAAU,MAAS;AAAA,MAAA;AAAA,IAEzB;AAAA,KACC,CAAC,KAAK,UAAUJ,CAAO,CAAC,CAAC,GAERU,EAAAZ,GAAK,MAAMK,CAAM,GAGlC,gBAAAQ,EAAA,OAAA,EAAI,WAAAZ,GAAsB,KAAKE,EAAS,CAAA;AAG7C,CAAC;"}
1
+ {"version":3,"file":"annotorious-react.es21.js","sources":["../src/openseadragon/setPosition.ts"],"sourcesContent":["import { ImageAnnotation } from '@annotorious/annotorious';\nimport OpenSeadragon from 'openseadragon';\n\nconst getAnnotationDomRect = (viewer: OpenSeadragon.Viewer, annotation: ImageAnnotation) => {\n const viewerBounds = viewer.element.getBoundingClientRect();\n \n // Annotation bounds (image coordinates)\n const { minX, minY, maxX, maxY } = annotation.target.selector.geometry.bounds;\n\n // Annotation coordinates - viewer element coordinates\n const topLeft = viewer.viewport.imageToViewerElementCoordinates(new OpenSeadragon.Point(minX, minY));\n const bottomRight = viewer.viewport.imageToViewerElementCoordinates(new OpenSeadragon.Point(maxX, maxY));\n\n // Account for viewer element offset\n return {\n x: topLeft.x + viewerBounds.x,\n right: bottomRight.x + viewerBounds.x,\n y: topLeft.y + viewerBounds.y,\n bottom: bottomRight.y + viewerBounds.y,\n width: bottomRight.x - topLeft.x,\n height: bottomRight.y - topLeft.y,\n };\n}\n\nexport const setPosition = (\n viewer: OpenSeadragon.Viewer, \n annotation: ImageAnnotation, \n popup: HTMLElement,\n sideOffset: number = 5\n) => {\n const viewerBounds = viewer.element.getBoundingClientRect();\n const annoBounds = getAnnotationDomRect(viewer, annotation);\n\n // Available space above, right, below, left the annotation in the viewport\n const availableAbove = annoBounds.y - viewerBounds.y;\n const availableRight = viewerBounds.right - annoBounds.x;\n const availableBelow = viewerBounds.bottom - annoBounds.bottom;\n const availableLeft = annoBounds.x - viewerBounds.left;\n\n // Popup element bounds\n const popupBounds = popup.firstElementChild.getBoundingClientRect();\n\n // Eight possible base alignment anchor points\n //\n // topleft topright\n // * *\n // leftdown * |---------------------| * rightdown\n // | |\n // | |\n // | |\n // leftup * |---------------------| * rightup\n // * * \n // bottomleft bottomright\n //\n // We'll position the popup at the cardinal direction\n // with the highest ratio: available space vs. popup size.\n const ratioAbove = availableAbove / popupBounds.height;\n const ratioRight = availableRight / popupBounds.width;\n const ratioBelow = availableBelow / popupBounds.height;\n const ratioLeft = availableLeft / popupBounds.width;\n\n const topleft = () => {\n popup.style.left = `${annoBounds.x}px`;\n popup.style.top = `${annoBounds.y - sideOffset - popupBounds.height}px`;\n }\n\n const topright = () => {\n popup.style.left = `${annoBounds.right - popupBounds.width}px`;\n popup.style.top = `${annoBounds.y - sideOffset - popupBounds.height}px`;\n }\n\n const leftdown = () => {\n popup.style.left = `${annoBounds.x - popupBounds.width - sideOffset}px`;\n popup.style.top = `${annoBounds.y}px`;\n } \n\n const rightdown = () => {\n popup.style.left = `${annoBounds.right + sideOffset}px`;\n popup.style.top = `${annoBounds.y}px`;\n }\n\n const leftup = () => {\n popup.style.left = `${annoBounds.x - popupBounds.width - sideOffset}px`;\n popup.style.top = `${annoBounds.bottom - popupBounds.height}px`;\n }\n\n const rightup = () => {\n popup.style.left = `${annoBounds.x + annoBounds.width + sideOffset}px`;\n popup.style.top = `${annoBounds.bottom - popupBounds.height}px`;\n }\n\n const bottomleft = () => {\n popup.style.left = `${annoBounds.x}px`;\n popup.style.top = `${annoBounds.bottom + sideOffset}px`;\n }\n\n const bottomright = () => {\n popup.style.left = `${annoBounds.right - popupBounds.width}px`;\n popup.style.top = `${annoBounds.bottom + sideOffset}px`;\n }\n\n const ratios = [ratioAbove, ratioRight, ratioBelow, ratioLeft];\n const maxIdx = ratios.indexOf(Math.max(...ratios));\n\n if (maxIdx === 0) {\n // Main orientation: above\n if (ratioRight > ratioLeft)\n topleft();\n else \n topright();\n } else if (maxIdx === 1) {\n // Main orientation: right\n if (ratioAbove > ratioBelow)\n rightup();\n else\n rightdown();\n } else if (maxIdx === 2) {\n // Main orientation: below\n if (ratioRight > ratioLeft)\n bottomleft();\n else\n bottomright();\n } else {\n // Main orientation: left\n if (ratioAbove > ratioBelow)\n leftup();\n else \n leftdown();\n }\n}"],"names":["getAnnotationDomRect","viewer","annotation","viewerBounds","minX","minY","maxX","maxY","topLeft","OpenSeadragon","bottomRight","setPosition","popup","sideOffset","annoBounds","availableAbove","availableRight","availableBelow","availableLeft","popupBounds","ratioAbove","ratioRight","ratioBelow","ratioLeft","topleft","topright","leftdown","rightdown","leftup","rightup","bottomleft","bottomright","ratios","maxIdx"],"mappings":"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"}
@@ -1,7 +1,5 @@
1
- import { j as t } from "./annotorious-react.es25.js";
2
- const o = t.Fragment, r = t.jsx;
1
+ var r = {};
3
2
  export {
4
- o as Fragment,
5
- r as jsx
3
+ r as __exports
6
4
  };
7
5
  //# sourceMappingURL=annotorious-react.es22.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es22.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
1
+ {"version":3,"file":"annotorious-react.es22.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,11 +1,5 @@
1
- import { useState as c, useRef as n, useEffect as s } from "react";
2
- const m = (e, t) => {
3
- const [u, o] = c(e), r = n();
4
- return s(() => (r.current = setTimeout(() => o(e), t), () => {
5
- clearTimeout(r.current);
6
- }), [e, t]), u;
7
- };
1
+ var e = {};
8
2
  export {
9
- m as useDebounce
3
+ e as __exports
10
4
  };
11
5
  //# sourceMappingURL=annotorious-react.es23.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es23.js","sources":["../src/useDebounce.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nexport const useDebounce = (value: any, delay: number) => {\n const [debouncedValue, setDebouncedValue] = useState<any>(value);\n\n const timerRef = useRef<ReturnType<typeof setTimeout>>();\n\n useEffect(() => {\n timerRef.current = \n setTimeout(() => setDebouncedValue(value), delay);\n\n return () => {\n clearTimeout(timerRef.current);\n };\n }, [value, delay]);\n\n return debouncedValue;\n}"],"names":["useDebounce","value","delay","debouncedValue","setDebouncedValue","useState","timerRef","useRef","useEffect"],"mappings":";AAEa,MAAAA,IAAc,CAACC,GAAYC,MAAkB;AACxD,QAAM,CAACC,GAAgBC,CAAiB,IAAIC,EAAcJ,CAAK,GAEzDK,IAAWC;AAEjB,SAAAC,EAAU,OACRF,EAAS,UACP,WAAW,MAAMF,EAAkBH,CAAK,GAAGC,CAAK,GAE3C,MAAM;AACX,iBAAaI,EAAS,OAAO;AAAA,EAAA,IAE9B,CAACL,GAAOC,CAAK,CAAC,GAEVC;AACT;"}
1
+ {"version":3,"file":"annotorious-react.es23.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,6 +1,6 @@
1
- import { jsx as s } from "./annotorious-react.es22.js";
1
+ import { jsx as s } from "./annotorious-react.es13.js";
2
2
  import { forwardRef as g } from "react";
3
- import { useDraggable as i } from "./annotorious-react.es24.js";
3
+ import { useDraggable as i } from "./annotorious-react.es15.js";
4
4
  const d = g((r, o) => {
5
5
  const { children: a, className: t, onDragStart: n, onDragEnd: e } = r;
6
6
  return i(o, { onDragStart: n, onDragEnd: e, cancel: "button, .no-drag" }), /* @__PURE__ */ s(
@@ -1,6 +1,6 @@
1
- import { jsx as a, Fragment as g } from "./annotorious-react.es22.js";
1
+ import { jsx as a, Fragment as g } from "./annotorious-react.es13.js";
2
2
  import { Children as d, useContext as x, useEffect as e, cloneElement as h } from "react";
3
- import { createImageAnnotator as u } from "./annotorious-react.es18.js";
3
+ import { createImageAnnotator as u } from "./annotorious-react.es9.js";
4
4
  import { AnnotoriousContext as y } from "./annotorious-react.es2.js";
5
5
  const j = (t) => {
6
6
  const { children: n, tool: A, ...i } = t, l = d.only(n), { anno: o, setAnno: r } = x(y), c = (m) => {
@@ -1,63 +1,26 @@
1
- import { Origin as l } from "./annotorious-react.es17.js";
2
- import { parseAll as v } from "./annotorious-react.es9.js";
3
- const p = (d, i, t) => {
4
- const { store: o, selection: c } = d, a = (e) => {
5
- if (t) {
6
- const { parsed: n, error: s } = t.parse(e);
7
- n ? o.addAnnotation(n, l.REMOTE) : console.error(s);
8
- } else
9
- o.addAnnotation(e, l.REMOTE);
10
- }, u = () => c.clear(), f = () => o.clear(), m = (e) => {
11
- const n = o.getAnnotation(e);
12
- return t && n ? t.serialize(n) : n;
13
- }, E = () => t ? o.all().map(t.serialize) : o.all(), g = () => {
14
- var s;
15
- const n = (((s = c.selected) == null ? void 0 : s.map((r) => r.id)) || []).map((r) => o.getAnnotation(r));
16
- return t ? n.map(t.serialize) : n;
17
- }, R = (e) => fetch(e).then((n) => n.json()).then((n) => (A(n), n)), h = (e) => {
18
- if (typeof e == "string") {
19
- const n = o.getAnnotation(e);
20
- return o.deleteAnnotation(e), t ? t.serialize(n) : n;
21
- } else {
22
- const n = t ? t.parse(e).parsed : e;
23
- return o.deleteAnnotation(n), e;
1
+ var s = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(s || {});
2
+ const E = [];
3
+ for (let t = 0; t < 256; ++t)
4
+ E.push((t + 256).toString(16).slice(1));
5
+ typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
6
+ var p = /* @__PURE__ */ ((t) => (t.LOCAL = "LOCAL", t.REMOTE = "REMOTE", t))(p || {});
7
+ let u = (t) => crypto.getRandomValues(new Uint8Array(t)), g = (t, r, e) => {
8
+ let n = (2 << Math.log(t.length - 1) / Math.LN2) - 1, a = -~(1.6 * n * r / t.length);
9
+ return (c = r) => {
10
+ let o = "";
11
+ for (; ; ) {
12
+ let l = e(a), i = a;
13
+ for (; i--; )
14
+ if (o += t[l[i] & n] || "", o.length === c)
15
+ return o;
24
16
  }
25
- }, A = (e) => {
26
- if (t) {
27
- const { parsed: n, failed: s } = v(t)(e);
28
- s.length > 0 && console.warn(`Discarded ${s.length} invalid annotations`, s), o.bulkAddAnnotation(n, !0, l.REMOTE);
29
- } else
30
- o.bulkAddAnnotation(e, !0, l.REMOTE);
31
- }, z = (e) => {
32
- e ? c.setSelected(e) : c.clear();
33
- }, O = (e) => {
34
- if (t) {
35
- const n = t.parse(e).parsed, s = t.serialize(o.getAnnotation(n.id));
36
- return o.updateAnnotation(n), s;
37
- } else {
38
- const n = o.getAnnotation(e.id);
39
- return o.updateAnnotation(e), n;
40
- }
41
- };
42
- return {
43
- addAnnotation: a,
44
- cancelSelected: u,
45
- canRedo: i.canRedo,
46
- canUndo: i.canUndo,
47
- clearAnnotations: f,
48
- getAnnotationById: m,
49
- getAnnotations: E,
50
- getSelected: g,
51
- loadAnnotations: R,
52
- redo: i.redo,
53
- removeAnnotation: h,
54
- setAnnotations: A,
55
- setSelected: z,
56
- undo: i.undo,
57
- updateAnnotation: O
58
17
  };
59
- };
18
+ }, y = (t, r = 21) => g(t, r, u), O = (t = 21) => crypto.getRandomValues(new Uint8Array(t)).reduce((r, e) => (e &= 63, e < 36 ? r += e.toString(36) : e < 62 ? r += (e - 26).toString(36).toUpperCase() : e > 62 ? r += "-" : r += "_", r), "");
19
+ const U = () => ({ isGuest: !0, id: y("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() });
20
+ O();
60
21
  export {
61
- p as createBaseAnnotator
22
+ p as Origin,
23
+ s as PointerSelectAction,
24
+ U as createAnonymousGuest
62
25
  };
63
26
  //# sourceMappingURL=annotorious-react.es8.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-react.es8.js","sources":["../../annotorious-core/src/model/Annotator.ts"],"sourcesContent":["import type { Annotation } from './Annotation';\nimport type { User } from './User';\nimport type { PresenceProvider } from '../presence';\nimport { Origin, type HoverState, type SelectionState, type Store, type UndoStack, type ViewportState } from '../state';\nimport type { LifecycleEvents } from '../lifecycle';\nimport { parseAll, type FormatAdapter } from './FormatAdapter';\nimport type { DrawingStyle } from './DrawingStyle';\nimport type { Filter } from './Filter';\n\n/**\n * Base annotator interface.\n * I ... internal core data model \n * E ... external adapted representation\n */\nexport interface Annotator<I extends Annotation = Annotation, E extends unknown = Annotation> {\n\n addAnnotation(annotation: E): void;\n\n cancelSelected(): void;\n\n canRedo(): boolean;\n\n canUndo(): boolean;\n\n clearAnnotations(): void;\n\n destroy(): void;\n\n getAnnotationById(id: string): E | undefined;\n\n getAnnotations(): E[];\n\n getSelected(): E[];\n\n getUser(): User;\n\n loadAnnotations(url: string): Promise<E[]>;\n\n redo(): void;\n\n removeAnnotation(arg: E | string): E;\n\n setAnnotations(annotations: E[]): void;\n\n setFilter(filter: Filter): void;\n\n setPresenceProvider?(provider: PresenceProvider): void;\n\n setSelected(arg?: string | string[]): void;\n\n setStyle(arg: DrawingStyle | ((annotation: I) => DrawingStyle) | undefined): void;\n\n setUser(user: User): void;\n\n undo(): void;\n\n updateAnnotation(annotation: E): E;\n \n on<T extends keyof LifecycleEvents<E>>(event: T, callback: LifecycleEvents<E>[T]): void;\n\n off<T extends keyof LifecycleEvents<E>>(event: T, callback: LifecycleEvents<E>[T]): void;\n\n state: AnnotatorState<I>;\n\n}\n\nexport interface AnnotatorState<A extends Annotation> {\n\n store: Store<A>;\n\n selection: SelectionState<A>;\n\n hover: HoverState<A>;\n\n viewport: ViewportState;\n\n}\n\nexport const createBaseAnnotator = <I extends Annotation, E extends unknown>(\n state: AnnotatorState<I>, \n undoStack: UndoStack<I>,\n adapter?: FormatAdapter<I, E>\n) => {\n\n const { store, selection } = state;\n\n const addAnnotation = (annotation: E) => {\n if (adapter) {\n const { parsed, error } = adapter.parse(annotation);\n if (parsed) {\n store.addAnnotation(parsed, Origin.REMOTE);\n } else {\n console.error(error);\n }\n } else {\n store.addAnnotation(annotation as unknown as I, Origin.REMOTE);\n }\n }\n\n const cancelSelected = () => selection.clear();\n\n const clearAnnotations = () => store.clear();\n\n const getAnnotationById = (id: string): E | undefined => {\n const annotation = store.getAnnotation(id);\n return (adapter && annotation) ?\n adapter.serialize(annotation) as E : annotation as unknown as E;\n }\n\n const getAnnotations = () =>\n (adapter ? store.all().map(adapter.serialize) : store.all()) as E[];\n\n const getSelected = () => {\n const selectedIds = selection.selected?.map(s => s.id) || [];\n\n const selected = selectedIds.map(id => store.getAnnotation(id));\n\n return adapter \n ? selected.map(adapter.serialize) \n : selected as unknown as E[];\n }\n\n const loadAnnotations = (url: string) =>\n fetch(url)\n .then((response) => response.json())\n .then((annotations) => {\n setAnnotations(annotations);\n return annotations;\n });\n\n const removeAnnotation = (arg: E | string): E => {\n if (typeof arg === 'string') {\n const annotation = store.getAnnotation(arg);\n store.deleteAnnotation(arg);\n\n return adapter ? adapter.serialize(annotation) : annotation as unknown as E;\n } else {\n const annotation = adapter ? adapter.parse(arg).parsed : (arg as unknown as I);\n store.deleteAnnotation(annotation);\n return arg;\n }\n }\n\n const setAnnotations = (annotations: E[]) => {\n if (adapter) {\n const { parsed, failed } = parseAll(adapter)(annotations);\n\n if (failed.length > 0)\n console.warn(`Discarded ${failed.length} invalid annotations`, failed);\n\n store.bulkAddAnnotation(parsed, true, Origin.REMOTE);\n } else {\n store.bulkAddAnnotation(annotations as unknown as I[], true, Origin.REMOTE);\n }\n }\n\n const setSelected = (arg?: string | string[]) => {\n if (arg) {\n selection.setSelected(arg);\n } else {\n selection.clear();\n }\n }\n\n const updateAnnotation = (updated: E): E => {\n if (adapter) {\n const crosswalked = adapter.parse(updated).parsed;\n const previous = adapter.serialize(store.getAnnotation(crosswalked.id));\n store.updateAnnotation(crosswalked);\n return previous;\n } else {\n const previous = store.getAnnotation((updated as unknown as I).id);\n store.updateAnnotation(updated as unknown as I);\n return previous as unknown as E;\n }\n }\n\n // Note that we don't spread the undoStack - it has a .destroy()\n // method that would likely get overwritten by other Annotator implementations\n // if people are not careful.\n return { \n addAnnotation,\n cancelSelected,\n canRedo: undoStack.canRedo,\n canUndo: undoStack.canUndo,\n clearAnnotations,\n getAnnotationById,\n getAnnotations,\n getSelected,\n loadAnnotations,\n redo: undoStack.redo,\n removeAnnotation,\n setAnnotations,\n setSelected,\n undo: undoStack.undo,\n updateAnnotation\n }\n\n}"],"names":["createBaseAnnotator","state","undoStack","adapter","store","selection","addAnnotation","annotation","parsed","error","Origin","cancelSelected","clearAnnotations","getAnnotationById","id","getAnnotations","getSelected","selected","_a","s","loadAnnotations","url","response","annotations","setAnnotations","removeAnnotation","arg","failed","parseAll","setSelected","updateAnnotation","updated","crosswalked","previous"],"mappings":"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"}
1
+ {"version":3,"file":"annotorious-react.es8.js","sources":["../../annotorious-core/dist/annotorious-core.es.js"],"sourcesContent":["var Y = Object.prototype.hasOwnProperty;\nfunction B(e, n) {\n var t, o;\n if (e === n)\n return !0;\n if (e && n && (t = e.constructor) === n.constructor) {\n if (t === Date)\n return e.getTime() === n.getTime();\n if (t === RegExp)\n return e.toString() === n.toString();\n if (t === Array) {\n if ((o = e.length) === n.length)\n for (; o-- && B(e[o], n[o]); )\n ;\n return o === -1;\n }\n if (!t || typeof e == \"object\") {\n o = 0;\n for (t in e)\n if (Y.call(e, t) && ++o && !Y.call(n, t) || !(t in n) || !B(e[t], n[t]))\n return !1;\n return Object.keys(n).length === o;\n }\n }\n return e !== e && n !== n;\n}\nfunction $() {\n}\nfunction q(e, n) {\n return e != e ? n == n : e !== n || e && typeof e == \"object\" || typeof e == \"function\";\n}\nconst k = [];\nfunction _(e, n = $) {\n let t;\n const o = /* @__PURE__ */ new Set();\n function i(b) {\n if (q(e, b) && (e = b, t)) {\n const v = !k.length;\n for (const u of o)\n u[1](), k.push(u, e);\n if (v) {\n for (let u = 0; u < k.length; u += 2)\n k[u][0](k[u + 1]);\n k.length = 0;\n }\n }\n }\n function h(b) {\n i(b(e));\n }\n function U(b, v = $) {\n const u = [b, v];\n return o.add(u), o.size === 1 && (t = n(i) || $), b(e), () => {\n o.delete(u), o.size === 0 && t && (t(), t = null);\n };\n }\n return { set: i, update: h, subscribe: U };\n}\nconst Ee = (e) => {\n const { subscribe: n, set: t } = _(null);\n let o = null;\n return n((i) => o = i), e.observe(({ changes: i }) => {\n if (o) {\n i.deleted.some((b) => b.id === o) && t(null);\n const U = i.updated.find(({ oldValue: b }) => b.id === o);\n U && t(U.newValue.id);\n }\n }), {\n get current() {\n return o;\n },\n subscribe: n,\n set: t\n };\n};\nvar G = /* @__PURE__ */ ((e) => (e.EDIT = \"EDIT\", e.SELECT = \"SELECT\", e.NONE = \"NONE\", e))(G || {});\nconst V = { selected: [] }, be = (e, n = \"EDIT\") => {\n const { subscribe: t, set: o } = _(V);\n let i = V;\n t((s) => i = s);\n const h = () => o(V), U = () => {\n var s;\n return ((s = i.selected) == null ? void 0 : s.length) === 0;\n }, b = (s) => {\n if (i.selected.length === 0)\n return !1;\n const f = typeof s == \"string\" ? s : s.id;\n return i.selected.some((y) => y.id === f);\n }, v = (s, f) => {\n const y = e.getAnnotation(s);\n if (y) {\n const A = W(y, n);\n o(A === \"EDIT\" ? { selected: [{ id: s, editable: !0 }], pointerEvent: f } : A === \"SELECT\" ? { selected: [{ id: s }], pointerEvent: f } : { selected: [], pointerEvent: f });\n } else\n console.warn(\"Invalid selection: \" + s);\n }, u = (s, f = !0) => {\n const y = Array.isArray(s) ? s : [s], A = y.map((L) => e.getAnnotation(L)).filter((L) => L);\n o({ selected: A.map(({ id: L }) => ({ id: L, editable: f })) }), A.length !== y.length && console.warn(\"Invalid selection\", s);\n }, T = (s) => {\n if (i.selected.length === 0)\n return !1;\n const { selected: f } = i;\n f.filter(({ id: A }) => s.includes(A)).length > 0 && o({ selected: f.filter(({ id: A }) => !s.includes(A)) });\n };\n return e.observe(({ changes: s }) => T(s.deleted.map((f) => f.id))), {\n clear: h,\n clickSelect: v,\n get selected() {\n return i ? [...i.selected] : null;\n },\n get pointerEvent() {\n return i ? i.pointerEvent : null;\n },\n isEmpty: U,\n isSelected: b,\n setSelected: u,\n subscribe: t\n };\n}, W = (e, n) => typeof n == \"function\" ? n(e) || \"EDIT\" : n || \"EDIT\";\nlet z;\nconst H = new Uint8Array(16);\nfunction F() {\n if (!z && (z = typeof crypto < \"u\" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !z))\n throw new Error(\"crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported\");\n return z(H);\n}\nconst R = [];\nfor (let e = 0; e < 256; ++e)\n R.push((e + 256).toString(16).slice(1));\nfunction J(e, n = 0) {\n return R[e[n + 0]] + R[e[n + 1]] + R[e[n + 2]] + R[e[n + 3]] + \"-\" + R[e[n + 4]] + R[e[n + 5]] + \"-\" + R[e[n + 6]] + R[e[n + 7]] + \"-\" + R[e[n + 8]] + R[e[n + 9]] + \"-\" + R[e[n + 10]] + R[e[n + 11]] + R[e[n + 12]] + R[e[n + 13]] + R[e[n + 14]] + R[e[n + 15]];\n}\nconst Q = typeof crypto < \"u\" && crypto.randomUUID && crypto.randomUUID.bind(crypto), j = {\n randomUUID: Q\n};\nfunction X(e, n, t) {\n if (j.randomUUID && !n && !e)\n return j.randomUUID();\n e = e || {};\n const o = e.random || (e.rng || F)();\n if (o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, n) {\n t = t || 0;\n for (let i = 0; i < 16; ++i)\n n[t + i] = o[i];\n return n;\n }\n return J(o);\n}\nconst ve = (e) => {\n const { creator: n, updatedBy: t } = e.target, o = e.bodies.reduce((i, h) => [...i, h.creator, h.updatedBy], []);\n return [\n n,\n t,\n ...o\n ].filter((i) => i);\n}, Ce = (e, n, t, o) => ({\n id: X(),\n annotation: e.id,\n created: t || /* @__PURE__ */ new Date(),\n creator: o,\n ...n\n}), Z = (e, n) => {\n const t = new Set(e.bodies.map((o) => o.id));\n return n.bodies.filter((o) => !t.has(o.id));\n}, K = (e, n) => {\n const t = new Set(n.bodies.map((o) => o.id));\n return e.bodies.filter((o) => !t.has(o.id));\n}, ee = (e, n) => n.bodies.map((t) => {\n const o = e.bodies.find((i) => i.id === t.id);\n return { newBody: t, oldBody: o && !B(o, t) ? o : void 0 };\n}).filter(({ oldBody: t }) => t), te = (e, n) => !B(e.target, n.target), M = (e, n) => {\n const t = Z(e, n), o = K(e, n), i = ee(e, n);\n return {\n oldValue: e,\n newValue: n,\n bodiesCreated: t.length > 0 ? t : void 0,\n bodiesDeleted: o.length > 0 ? o : void 0,\n bodiesUpdated: i.length > 0 ? i : void 0,\n targetUpdated: te(e, n) ? { oldTarget: e.target, newTarget: n.target } : void 0\n };\n};\nvar ne = /* @__PURE__ */ ((e) => (e.BODY_ONLY = \"BODY_ONLY\", e.TARGET_ONLY = \"TARGET_ONLY\", e))(ne || {}), O = /* @__PURE__ */ ((e) => (e.LOCAL = \"LOCAL\", e.REMOTE = \"REMOTE\", e))(O || {});\nconst oe = (e, n) => {\n var h, U;\n const { changes: t, origin: o } = n;\n if (!(!e.options.origin || e.options.origin === o))\n return !1;\n if (e.options.ignore) {\n const { ignore: b } = e.options, v = (T) => (T == null ? void 0 : T.length) > 0;\n if (!(v(t.created) || v(t.deleted))) {\n const T = (h = t.updated) == null ? void 0 : h.some((f) => v(f.bodiesCreated) || v(f.bodiesDeleted) || v(f.bodiesUpdated)), s = (U = t.updated) == null ? void 0 : U.some((f) => f.targetUpdated);\n if (b === \"BODY_ONLY\" && T && !s || b === \"TARGET_ONLY\" && s && !T)\n return !1;\n }\n }\n if (e.options.annotations) {\n const b = /* @__PURE__ */ new Set([\n ...t.created.map((u) => u.id),\n ...t.deleted.map((u) => u.id),\n ...t.updated.map(({ oldValue: u }) => u.id)\n ]);\n return !!(Array.isArray(e.options.annotations) ? e.options.annotations : [e.options.annotations]).find((u) => b.has(u));\n } else\n return !0;\n}, se = (e, n) => {\n const t = new Set((e.created || []).map((s) => s.id)), o = new Set((e.updated || []).map(({ newValue: s }) => s.id)), i = new Set((n.created || []).map((s) => s.id)), h = new Set((n.deleted || []).map((s) => s.id)), U = new Set((n.updated || []).map(({ oldValue: s }) => s.id)), b = new Set((n.updated || []).filter(({ oldValue: s }) => t.has(s.id) || o.has(s.id)).map(({ oldValue: s }) => s.id)), v = [\n ...(e.created || []).filter((s) => !h.has(s.id)).map((s) => U.has(s.id) ? n.updated.find(({ oldValue: f }) => f.id === s.id).newValue : s),\n ...n.created || []\n ], u = [\n ...(e.deleted || []).filter((s) => !i.has(s.id)),\n ...(n.deleted || []).filter((s) => !t.has(s.id))\n ], T = [\n ...(e.updated || []).filter(({ newValue: s }) => !h.has(s.id)).map((s) => {\n const { oldValue: f, newValue: y } = s;\n if (U.has(y.id)) {\n const A = n.updated.find((L) => L.oldValue.id === y.id).newValue;\n return M(f, A);\n } else\n return s;\n }),\n ...(n.updated || []).filter(({ oldValue: s }) => !b.has(s.id))\n ];\n return { created: v, deleted: u, updated: T };\n}, ie = (e) => e.id !== void 0, we = () => {\n const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), t = [], o = (r, l = {}) => t.push({ onChange: r, options: l }), i = (r) => {\n const l = t.findIndex((a) => a.onChange == r);\n l > -1 && t.splice(l, 1);\n }, h = (r, l) => {\n const a = {\n origin: r,\n changes: {\n created: l.created || [],\n updated: l.updated || [],\n deleted: l.deleted || []\n },\n state: [...e.values()]\n };\n t.forEach((p) => {\n oe(p, a) && p.onChange(a);\n });\n }, U = (r, l = O.LOCAL) => {\n if (e.get(r.id))\n throw Error(`Cannot add annotation ${r.id} - exists already`);\n e.set(r.id, r), r.bodies.forEach((p) => n.set(p.id, r.id)), h(l, { created: [r] });\n }, b = (r, l) => {\n const a = typeof r == \"string\" ? l : r, p = typeof r == \"string\" ? r : r.id, C = e.get(p);\n if (C) {\n const D = M(C, a);\n return p === a.id ? e.set(p, a) : (e.delete(p), e.set(a.id, a)), C.bodies.forEach((x) => n.delete(x.id)), a.bodies.forEach((x) => n.set(x.id, a.id)), D;\n } else\n console.warn(`Cannot update annotation ${p} - does not exist`);\n }, v = (r, l = O.LOCAL, a = O.LOCAL) => {\n const p = ie(l) ? a : l, C = b(r, l);\n C && h(p, { updated: [C] });\n }, u = (r, l = O.LOCAL) => {\n const a = r.reduce((p, C) => {\n const D = b(C);\n return D ? [...p, D] : p;\n }, []);\n a.length > 0 && h(l, { updated: a });\n }, T = (r, l = O.LOCAL) => {\n const a = e.get(r.annotation);\n if (a) {\n const p = {\n ...a,\n bodies: [...a.bodies, r]\n };\n e.set(a.id, p), n.set(r.id, p.id), h(l, { updated: [{\n oldValue: a,\n newValue: p,\n bodiesCreated: [r]\n }] });\n } else\n console.warn(`Attempt to add body to missing annotation: ${r.annotation}`);\n }, s = () => [...e.values()], f = (r = O.LOCAL) => {\n const l = [...e.values()];\n e.clear(), n.clear(), h(r, { deleted: l });\n }, y = (r, l = !0, a = O.LOCAL) => {\n if (l) {\n const p = [...e.values()];\n e.clear(), n.clear(), r.forEach((C) => {\n e.set(C.id, C), C.bodies.forEach((D) => n.set(D.id, C.id));\n }), h(a, { created: r, deleted: p });\n } else {\n const p = r.reduce((C, D) => {\n const x = e.get(D.id);\n return x ? [...C, x] : C;\n }, []);\n if (p.length > 0)\n throw Error(`Bulk insert would overwrite the following annotations: ${p.map((C) => C.id).join(\", \")}`);\n r.forEach((C) => {\n e.set(C.id, C), C.bodies.forEach((D) => n.set(D.id, C.id));\n }), h(a, { created: r });\n }\n }, A = (r) => {\n const l = typeof r == \"string\" ? r : r.id, a = e.get(l);\n if (a)\n return e.delete(l), a.bodies.forEach((p) => n.delete(p.id)), a;\n console.warn(`Attempt to delete missing annotation: ${l}`);\n }, L = (r, l = O.LOCAL) => {\n const a = A(r);\n a && h(l, { deleted: [a] });\n }, w = (r, l = O.LOCAL) => {\n const a = r.reduce((p, C) => {\n const D = A(C);\n return D ? [...p, D] : p;\n }, []);\n a.length > 0 && h(l, { deleted: a });\n }, c = (r, l = O.LOCAL) => {\n const a = e.get(r.annotation);\n if (a) {\n const p = a.bodies.find((C) => C.id === r.id);\n if (p) {\n n.delete(p.id);\n const C = {\n ...a,\n bodies: a.bodies.filter((x) => x.id !== r.id)\n };\n e.set(a.id, C), h(l, { updated: [{\n oldValue: a,\n newValue: C,\n bodiesDeleted: [p]\n }] });\n } else\n console.warn(`Attempt to delete missing body ${r.id} from annotation ${r.annotation}`);\n } else\n console.warn(`Attempt to delete body from missing annotation ${r.annotation}`);\n }, m = (r) => {\n const l = e.get(r);\n return l ? { ...l } : void 0;\n }, d = (r) => {\n const l = n.get(r);\n if (l) {\n const p = m(l).bodies.find((C) => C.id === r);\n if (p)\n return p;\n console.error(`Store integrity error: body ${r} in index, but not in annotation`);\n } else\n console.warn(`Attempt to retrieve missing body: ${r}`);\n }, E = (r, l) => {\n if (r.annotation !== l.annotation)\n throw \"Annotation integrity violation: annotation ID must be the same when updating bodies\";\n const a = e.get(r.annotation);\n if (a) {\n const p = a.bodies.find((D) => D.id === r.id), C = {\n ...a,\n bodies: a.bodies.map((D) => D.id === p.id ? l : D)\n };\n return e.set(a.id, C), p.id !== l.id && (n.delete(p.id), n.set(l.id, C.id)), {\n oldValue: a,\n newValue: C,\n bodiesUpdated: [{ oldBody: p, newBody: l }]\n };\n } else\n console.warn(`Attempt to add body to missing annotation ${r.annotation}`);\n }, g = (r, l, a = O.LOCAL) => {\n const p = E(r, l);\n h(a, { updated: [p] });\n }, S = (r, l = O.LOCAL) => {\n const a = r.map((p) => E({ id: p.id, annotation: p.annotation }, p));\n h(l, { updated: a });\n }, I = (r) => {\n const l = e.get(r.annotation);\n if (l) {\n const a = {\n ...l,\n target: {\n ...l.target,\n ...r\n }\n };\n return e.set(l.id, a), {\n oldValue: l,\n newValue: a,\n targetUpdated: {\n oldTarget: l.target,\n newTarget: r\n }\n };\n } else\n console.warn(`Attempt to update target on missing annotation: ${r.annotation}`);\n };\n return {\n addAnnotation: U,\n addBody: T,\n all: s,\n bulkAddAnnotation: y,\n bulkDeleteAnnotation: w,\n bulkUpdateAnnotation: u,\n bulkUpdateBodies: S,\n bulkUpdateTargets: (r, l = O.LOCAL) => {\n const a = r.map(I).filter((p) => p);\n a.length > 0 && h(l, { updated: a });\n },\n clear: f,\n deleteAnnotation: L,\n deleteBody: c,\n getAnnotation: m,\n getBody: d,\n observe: o,\n unobserve: i,\n updateAnnotation: v,\n updateBody: g,\n updateTarget: (r, l = O.LOCAL) => {\n const a = I(r);\n a && h(l, { updated: [a] });\n }\n };\n}, ye = (e) => ({\n ...e,\n subscribe: (t) => {\n const o = (i) => t(i.state);\n return e.observe(o), t(e.all()), () => e.unobserve(o);\n }\n});\nlet P = () => ({\n emit(e, ...n) {\n let t = this.events[e] || [];\n for (let o = 0, i = t.length; o < i; o++)\n t[o](...n);\n },\n events: {},\n on(e, n) {\n var t;\n return (t = this.events[e]) != null && t.push(n) || (this.events[e] = [n]), () => {\n var o;\n this.events[e] = (o = this.events[e]) == null ? void 0 : o.filter((i) => n !== i);\n };\n }\n});\nconst de = 250, Ue = (e) => {\n const n = P(), t = [];\n let o = -1, i = !1, h = 0;\n const U = (d) => {\n if (!i) {\n const { changes: E } = d, g = performance.now();\n if (g - h > de)\n t.splice(o + 1), t.push(E), o = t.length - 1;\n else {\n const S = t.length - 1;\n t[S] = se(t[S], E);\n }\n h = g;\n }\n i = !1;\n };\n e.observe(U, { origin: O.LOCAL });\n const b = (d) => (d == null ? void 0 : d.length) > 0 && e.bulkDeleteAnnotation(d), v = (d) => (d == null ? void 0 : d.length) > 0 && e.bulkAddAnnotation(d, !1), u = (d) => (d == null ? void 0 : d.length) > 0 && e.bulkUpdateAnnotation(d.map(({ oldValue: E }) => E)), T = (d) => (d == null ? void 0 : d.length) > 0 && e.bulkUpdateAnnotation(d.map(({ newValue: E }) => E)), s = (d) => (d == null ? void 0 : d.length) > 0 && e.bulkAddAnnotation(d, !1), f = (d) => (d == null ? void 0 : d.length) > 0 && e.bulkDeleteAnnotation(d);\n return {\n canRedo: () => t.length - 1 > o,\n canUndo: () => o > -1,\n destroy: () => e.unobserve(U),\n on: (d, E) => n.on(d, E),\n redo: () => {\n if (t.length - 1 > o) {\n i = !0;\n const { created: d, updated: E, deleted: g } = t[o + 1];\n v(d), T(E), f(g), n.emit(\"redo\", t[o + 1]), o += 1;\n }\n },\n undo: () => {\n if (o > -1) {\n i = !0;\n const { created: d, updated: E, deleted: g } = t[o];\n b(d), u(E), s(g), n.emit(\"undo\", t[o]), o -= 1;\n }\n }\n };\n}, Le = () => {\n const { subscribe: e, set: n } = _([]);\n return {\n subscribe: e,\n set: n\n };\n}, Se = (e, n, t, o) => {\n const { store: i, selection: h, hover: U, viewport: b } = e, v = /* @__PURE__ */ new Map();\n let u = [], T, s;\n const f = (c, m) => {\n v.has(c) ? v.get(c).push(m) : v.set(c, [m]);\n }, y = (c, m) => {\n const d = v.get(c);\n d && d.indexOf(m) > 0 && d.splice(d.indexOf(m), 1);\n }, A = (c, m, d) => {\n v.has(c) && setTimeout(() => {\n v.get(c).forEach((E) => {\n if (t) {\n const g = Array.isArray(m) ? m.map((I) => t.serialize(I)) : t.serialize(m), S = d ? d instanceof PointerEvent ? d : t.serialize(d) : void 0;\n E(g, S);\n } else\n E(m, d);\n });\n }, 1);\n }, L = () => {\n const { selected: c } = h, m = c.map(({ id: d }) => i.getAnnotation(d));\n m.forEach((d) => {\n const E = u.find((g) => g.id === d.id);\n (!E || !B(E, d)) && A(\"updateAnnotation\", d, E);\n }), u = u.map((d) => {\n const E = m.find(({ id: g }) => g === d.id);\n return E || d;\n });\n };\n h.subscribe(({ selected: c }) => {\n if (!(u.length === 0 && c.length === 0)) {\n if (u.length === 0 && c.length > 0)\n u = c.map(({ id: m }) => i.getAnnotation(m));\n else if (u.length > 0 && c.length === 0)\n u.forEach((m) => {\n const d = i.getAnnotation(m.id);\n d && !B(d, m) && A(\"updateAnnotation\", d, m);\n }), u = [];\n else {\n const m = new Set(u.map((g) => g.id)), d = new Set(c.map(({ id: g }) => g));\n u.filter((g) => !d.has(g.id)).forEach((g) => {\n const S = i.getAnnotation(g.id);\n S && !B(S, g) && A(\"updateAnnotation\", S, g);\n }), u = [\n // Remove annotations that were deselected\n ...u.filter((g) => d.has(g.id)),\n // Add editable annotations that were selected\n ...c.filter(({ id: g }) => !m.has(g)).map(({ id: g }) => i.getAnnotation(g))\n ];\n }\n A(\"selectionChanged\", u);\n }\n }), U.subscribe((c) => {\n !T && c ? A(\"mouseEnterAnnotation\", i.getAnnotation(c)) : T && !c ? A(\"mouseLeaveAnnotation\", i.getAnnotation(T)) : T && c && (A(\"mouseLeaveAnnotation\", i.getAnnotation(T)), A(\"mouseEnterAnnotation\", i.getAnnotation(c))), T = c;\n }), b == null || b.subscribe((c) => A(\"viewportIntersect\", c.map(i.getAnnotation))), i.observe((c) => {\n o && (s && clearTimeout(s), s = setTimeout(L, 1e3));\n const { created: m, deleted: d } = c.changes;\n m.forEach((g) => A(\"createAnnotation\", g)), d.forEach((g) => A(\"deleteAnnotation\", g)), c.changes.updated.filter((g) => [\n ...g.bodiesCreated || [],\n ...g.bodiesDeleted || [],\n ...g.bodiesUpdated || []\n ].length > 0).forEach(({ oldValue: g, newValue: S }) => {\n const I = u.find((N) => N.id === g.id) || g;\n u = u.map((N) => N.id === g.id ? S : N), A(\"updateAnnotation\", S, I);\n });\n }, { origin: O.LOCAL }), i.observe((c) => {\n if (u) {\n const m = new Set(u.map((E) => E.id)), d = c.changes.updated.filter(({ newValue: E }) => m.has(E.id)).map(({ newValue: E }) => E);\n d.length > 0 && (u = u.map((E) => {\n const g = d.find((S) => S.id === E.id);\n return g || E;\n }));\n }\n }, { origin: O.REMOTE });\n const w = (c) => (m) => {\n const { created: d, deleted: E, updated: g } = m;\n d.forEach((S) => A(\"createAnnotation\", S)), E.forEach((S) => A(\"deleteAnnotation\", S)), c ? g.forEach((S) => A(\"updateAnnotation\", S.oldValue, S.newValue)) : g.forEach((S) => A(\"updateAnnotation\", S.newValue, S.oldValue));\n };\n return n.on(\"undo\", w(!0)), n.on(\"redo\", w(!1)), { on: f, off: y, emit: A };\n}, Te = (e) => (n) => n.map((t) => e.serialize(t)), re = (e) => (n) => n.reduce((t, o) => {\n const { parsed: i, error: h } = e.parse(o);\n return h ? {\n parsed: t.parsed,\n failed: [...t.failed, o]\n } : {\n parsed: [...t.parsed, i],\n failed: t.failed\n };\n}, { parsed: [], failed: [] }), Oe = (e, n, t) => {\n const { store: o, selection: i } = e, h = (w) => {\n if (t) {\n const { parsed: c, error: m } = t.parse(w);\n c ? o.addAnnotation(c, O.REMOTE) : console.error(m);\n } else\n o.addAnnotation(w, O.REMOTE);\n }, U = () => i.clear(), b = () => o.clear(), v = (w) => {\n const c = o.getAnnotation(w);\n return t && c ? t.serialize(c) : c;\n }, u = () => t ? o.all().map(t.serialize) : o.all(), T = () => {\n var m;\n const c = (((m = i.selected) == null ? void 0 : m.map((d) => d.id)) || []).map((d) => o.getAnnotation(d));\n return t ? c.map(t.serialize) : c;\n }, s = (w) => fetch(w).then((c) => c.json()).then((c) => (y(c), c)), f = (w) => {\n if (typeof w == \"string\") {\n const c = o.getAnnotation(w);\n return o.deleteAnnotation(w), t ? t.serialize(c) : c;\n } else {\n const c = t ? t.parse(w).parsed : w;\n return o.deleteAnnotation(c), w;\n }\n }, y = (w) => {\n if (t) {\n const { parsed: c, failed: m } = re(t)(w);\n m.length > 0 && console.warn(`Discarded ${m.length} invalid annotations`, m), o.bulkAddAnnotation(c, !0, O.REMOTE);\n } else\n o.bulkAddAnnotation(w, !0, O.REMOTE);\n }, A = (w) => {\n w ? i.setSelected(w) : i.clear();\n }, L = (w) => {\n if (t) {\n const c = t.parse(w).parsed, m = t.serialize(o.getAnnotation(c.id));\n return o.updateAnnotation(c), m;\n } else {\n const c = o.getAnnotation(w.id);\n return o.updateAnnotation(w), c;\n }\n };\n return {\n addAnnotation: h,\n cancelSelected: U,\n canRedo: n.canRedo,\n canUndo: n.canUndo,\n clearAnnotations: b,\n getAnnotationById: v,\n getAnnotations: u,\n getSelected: T,\n loadAnnotations: s,\n redo: n.redo,\n removeAnnotation: f,\n setAnnotations: y,\n setSelected: A,\n undo: n.undo,\n updateAnnotation: L\n };\n};\nlet ae = (e) => crypto.getRandomValues(new Uint8Array(e)), ce = (e, n, t) => {\n let o = (2 << Math.log(e.length - 1) / Math.LN2) - 1, i = -~(1.6 * o * n / e.length);\n return (h = n) => {\n let U = \"\";\n for (; ; ) {\n let b = t(i), v = i;\n for (; v--; )\n if (U += e[b[v] & o] || \"\", U.length === h)\n return U;\n }\n };\n}, le = (e, n = 21) => ce(e, n, ae), ue = (e = 21) => crypto.getRandomValues(new Uint8Array(e)).reduce((n, t) => (t &= 63, t < 36 ? n += t.toString(36) : t < 62 ? n += (t - 26).toString(36).toUpperCase() : t > 62 ? n += \"-\" : n += \"_\", n), \"\");\nconst De = () => ({ isGuest: !0, id: le(\"1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_\", 20)() }), fe = (e) => {\n const n = JSON.stringify(e);\n let t = 0;\n for (let o = 0, i = n.length; o < i; o++) {\n let h = n.charCodeAt(o);\n t = (t << 5) - t + h, t |= 0;\n }\n return `${t}`;\n}, Re = (e, n) => (Array.isArray(e) ? e : [e]).map((t) => {\n const { id: o, type: i, purpose: h, value: U, created: b, creator: v, ...u } = t;\n return {\n id: o || `temp-${fe(t)}`,\n annotation: n,\n type: i,\n purpose: h,\n value: U,\n created: b,\n creator: v ? typeof v == \"object\" ? { ...v } : v : void 0,\n ...u\n };\n}), xe = (e) => e.map((n) => {\n var o;\n const t = { ...n };\n return delete t.annotation, (o = t.id) != null && o.startsWith(\"temp-\") && delete t.id, t;\n}), pe = [\n \"#ff7c00\",\n // orange\n \"#1ac938\",\n // green\n \"#e8000b\",\n // red\n \"#8b2be2\",\n // purple\n \"#9f4800\",\n // brown\n \"#f14cc1\",\n // pink\n \"#ffc400\",\n // khaki\n \"#00d7ff\",\n // cyan\n \"#023eff\"\n // blue\n], he = () => {\n const e = [...pe];\n return { assignRandomColor: () => {\n const o = Math.floor(Math.random() * e.length), i = e[o];\n return e.splice(o, 1), i;\n }, releaseColor: (o) => e.push(o) };\n}, ge = () => {\n const e = he();\n return { addUser: (o, i) => {\n const h = e.assignRandomColor();\n return {\n label: i.name || i.id,\n avatar: i.avatar,\n color: h\n };\n }, removeUser: (o) => e.releaseColor(o.appearance.color) };\n}, me = (e, n) => e.every((t) => e.includes(t)) && n.every((t) => e.includes(t)), Be = ue(), Ie = (e = ge()) => {\n const n = P(), t = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), i = (s, f) => {\n if (t.has(s)) {\n console.warn(\"Attempt to add user that is already present\", s, f);\n return;\n }\n const y = e.addUser(s, f);\n t.set(s, {\n ...f,\n presenceKey: s,\n appearance: y\n });\n }, h = (s) => {\n const f = t.get(s);\n if (!f) {\n console.warn(\"Attempt to remove user that is not present\", s);\n return;\n }\n e.removeUser(f), t.delete(s);\n }, U = (s) => {\n const f = new Set(s.map((L) => L.presenceKey)), y = s.filter(({ presenceKey: L }) => !t.has(L)), A = Array.from(t.values()).filter((L) => !f.has(L.presenceKey));\n y.forEach(({ presenceKey: L, user: w }) => i(L, w)), A.forEach((L) => {\n const { presenceKey: w } = L;\n o.has(w) && n.emit(\"selectionChange\", L, null), h(w);\n }), (y.length > 0 || A.length > 0) && n.emit(\"presence\", u());\n }, b = (s, f) => {\n const y = t.get(s);\n if (!y) {\n console.warn(\"Activity notification from user that is not present\");\n return;\n }\n const A = o.get(s);\n (!A || !me(A, f)) && (o.set(s, f), n.emit(\"selectionChange\", y, f));\n }, v = (s, f) => {\n const y = t.get(s);\n if (!y) {\n console.warn(\"Selection change for user that is not present\", s);\n return;\n }\n f ? o.set(s, f) : o.delete(s), n.emit(\"selectionChange\", y, f);\n }, u = () => [...Array.from(t.values())];\n return {\n getPresentUsers: u,\n notifyActivity: b,\n on: (s, f) => n.on(s, f),\n syncUsers: U,\n updateSelection: v\n };\n};\nexport {\n ne as Ignore,\n O as Origin,\n Be as PRESENCE_KEY,\n G as PointerSelectAction,\n De as createAnonymousGuest,\n Oe as createBaseAnnotator,\n Ce as createBody,\n ge as createDefaultAppearenceProvider,\n Ee as createHoverState,\n Se as createLifecyleObserver,\n Ie as createPresenceState,\n be as createSelectionState,\n we as createStore,\n Ue as createUndoStack,\n Le as createViewportState,\n he as defaultColorProvider,\n M as diffAnnotations,\n ve as getContributors,\n se as mergeChanges,\n W as onPointerSelect,\n re as parseAll,\n Re as parseW3CBodies,\n Te as serializeAll,\n xe as serializeW3CBodies,\n oe as shouldNotify,\n ye as toSvelteStore\n};\n//# sourceMappingURL=annotorious-core.es.js.map\n"],"names":["G","e","R","O","ae","ce","n","t","o","i","h","U","b","v","le","ue","De"],"mappings":"AA2EG,IAACA,IAAqB,kBAACC,OAAOA,EAAE,OAAO,QAAQA,EAAE,SAAS,UAAUA,EAAE,OAAO,QAAQA,IAAID,KAAK,EAAE;AAmDnG,MAAME,IAAI,CAAA;AACV,SAASD,IAAI,GAAGA,IAAI,KAAK,EAAEA;AACzB,EAAAC,EAAE,MAAMD,IAAI,KAAK,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC;AAI9B,OAAO,SAAS,OAAO,OAAO,cAAc,OAAO,WAAW,KAAK,MAAM;AAiDhF,IAAwGE,IAAqB,kBAACF,OAAOA,EAAE,QAAQ,SAASA,EAAE,SAAS,UAAUA,IAAIE,KAAK,CAAA,CAAE;AAqb3L,IAAIC,IAAK,CAACH,MAAM,OAAO,gBAAgB,IAAI,WAAWA,CAAC,CAAC,GAAGI,IAAK,CAACJ,GAAGK,GAAGC,MAAM;AAC3E,MAAIC,KAAK,KAAK,KAAK,IAAIP,EAAE,SAAS,CAAC,IAAI,KAAK,OAAO,GAAGQ,IAAI,CAAC,EAAE,MAAMD,IAAIF,IAAIL,EAAE;AAC7E,SAAO,CAACS,IAAIJ,MAAM;AAChB,QAAIK,IAAI;AACR,eAAW;AACT,UAAIC,IAAIL,EAAEE,CAAC,GAAGI,IAAIJ;AAClB,aAAOI;AACL,YAAIF,KAAKV,EAAEW,EAAEC,CAAC,IAAIL,CAAC,KAAK,IAAIG,EAAE,WAAWD;AACvC,iBAAOC;AAAA,IACZ;AAAA,EACL;AACA,GAAGG,IAAK,CAACb,GAAGK,IAAI,OAAOD,EAAGJ,GAAGK,GAAGF,CAAE,GAAGW,IAAK,CAACd,IAAI,OAAO,OAAO,gBAAgB,IAAI,WAAWA,CAAC,CAAC,EAAE,OAAO,CAACK,GAAGC,OAAOA,KAAK,IAAIA,IAAI,KAAKD,KAAKC,EAAE,SAAS,EAAE,IAAIA,IAAI,KAAKD,MAAMC,IAAI,IAAI,SAAS,EAAE,EAAE,YAAW,IAAKA,IAAI,KAAKD,KAAK,MAAMA,KAAK,KAAKA,IAAI,EAAE;AAC7O,MAACU,IAAK,OAAO,EAAE,SAAS,IAAI,IAAIF,EAAG,mEAAmE,EAAE,EAAC;AA2DvBC,EAAI;"}