@annotorious/react 3.0.0-rc.15 → 3.0.0-rc.17
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/Annotorious.d.ts +2 -35
- package/dist/Annotorious.d.ts.map +1 -1
- package/dist/annotorious-react.es.js +27 -28
- package/dist/annotorious-react.es.js.map +1 -1
- package/dist/annotorious-react.es10.js +17 -17
- package/dist/annotorious-react.es10.js.map +1 -1
- package/dist/annotorious-react.es11.js +8 -8
- package/dist/annotorious-react.es11.js.map +1 -1
- package/dist/annotorious-react.es12.js +6 -4
- package/dist/annotorious-react.es12.js.map +1 -1
- package/dist/annotorious-react.es15.js +18868 -6
- package/dist/annotorious-react.es15.js.map +1 -1
- package/dist/annotorious-react.es16.js +32 -2
- package/dist/annotorious-react.es16.js.map +1 -1
- package/dist/annotorious-react.es17.js +2 -30
- package/dist/annotorious-react.es17.js.map +1 -1
- package/dist/annotorious-react.es18.js +1 -1
- package/dist/annotorious-react.es19.js +25 -21004
- package/dist/annotorious-react.es19.js.map +1 -1
- package/dist/annotorious-react.es2.js +53 -54
- package/dist/annotorious-react.es2.js.map +1 -1
- package/dist/annotorious-react.es20.js +2 -32
- package/dist/annotorious-react.es20.js.map +1 -1
- package/dist/annotorious-react.es4.js +7 -7
- package/dist/annotorious-react.es4.js.map +1 -1
- package/dist/annotorious-react.es5.js +9 -9
- package/dist/annotorious-react.es5.js.map +1 -1
- package/dist/annotorious-react.es6.js +1 -4
- package/dist/annotorious-react.es6.js.map +1 -1
- package/dist/annotorious-react.es7.js +1 -4
- package/dist/annotorious-react.es7.js.map +1 -1
- package/dist/annotorious-react.es8.js +5 -5
- package/dist/annotorious-react.es8.js.map +1 -1
- package/dist/annotorious-react.es9.js +25 -29
- package/dist/annotorious-react.es9.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/package.json +9 -9
- package/dist/annotorious-react.es22.js +0 -5
- package/dist/annotorious-react.es22.js.map +0 -1
- package/dist/openseadragon/annotorious-react-osd.es.js +0 -10
- package/dist/openseadragon/annotorious-react-osd.es.js.map +0 -1
- package/dist/openseadragon/annotorious-react-osd.es10.js +0 -9
- package/dist/openseadragon/annotorious-react-osd.es10.js.map +0 -1
- package/dist/openseadragon/annotorious-react-osd.es11.js +0 -156
- package/dist/openseadragon/annotorious-react-osd.es11.js.map +0 -1
- package/dist/openseadragon/annotorious-react-osd.es12.js +0 -5
- package/dist/openseadragon/annotorious-react-osd.es12.js.map +0 -1
- package/dist/openseadragon/annotorious-react-osd.es13.js +0 -33
- package/dist/openseadragon/annotorious-react-osd.es13.js.map +0 -1
- package/dist/openseadragon/annotorious-react-osd.es14.js +0 -602
- package/dist/openseadragon/annotorious-react-osd.es14.js.map +0 -1
- package/dist/openseadragon/annotorious-react-osd.es15.js +0 -5
- package/dist/openseadragon/annotorious-react-osd.es15.js.map +0 -1
- package/dist/openseadragon/annotorious-react-osd.es16.js +0 -5
- package/dist/openseadragon/annotorious-react-osd.es16.js.map +0 -1
- package/dist/openseadragon/annotorious-react-osd.es2.js +0 -32
- package/dist/openseadragon/annotorious-react-osd.es2.js.map +0 -1
- package/dist/openseadragon/annotorious-react-osd.es3.js +0 -39
- package/dist/openseadragon/annotorious-react-osd.es3.js.map +0 -1
- package/dist/openseadragon/annotorious-react-osd.es4.js +0 -19
- package/dist/openseadragon/annotorious-react-osd.es4.js.map +0 -1
- package/dist/openseadragon/annotorious-react-osd.es5.js +0 -6
- package/dist/openseadragon/annotorious-react-osd.es5.js.map +0 -1
- package/dist/openseadragon/annotorious-react-osd.es6.js +0 -21012
- package/dist/openseadragon/annotorious-react-osd.es6.js.map +0 -1
- package/dist/openseadragon/annotorious-react-osd.es7.js +0 -51
- package/dist/openseadragon/annotorious-react-osd.es7.js.map +0 -1
- package/dist/openseadragon/annotorious-react-osd.es8.js +0 -19
- package/dist/openseadragon/annotorious-react-osd.es8.js.map +0 -1
- package/dist/openseadragon/annotorious-react-osd.es9.js +0 -35
- package/dist/openseadragon/annotorious-react-osd.es9.js.map +0 -1
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createContext as
|
|
1
|
+
import { j as I } from "./annotorious-react.es12.js";
|
|
2
|
+
import { createContext as O, forwardRef as R, useState as f, useImperativeHandle as U, useEffect as h, useContext as c } from "react";
|
|
3
3
|
import { useDebounce as C } from "./annotorious-react.es13.js";
|
|
4
|
-
const
|
|
4
|
+
const o = O({
|
|
5
5
|
anno: void 0,
|
|
6
6
|
setAnno: void 0,
|
|
7
7
|
annotations: [],
|
|
8
8
|
selection: { selected: [] }
|
|
9
|
-
}), B =
|
|
10
|
-
const [
|
|
11
|
-
return
|
|
12
|
-
if (
|
|
13
|
-
const { selection:
|
|
14
|
-
e.all().length > 0 &&
|
|
15
|
-
const v = (a) =>
|
|
9
|
+
}), B = R((t, s) => {
|
|
10
|
+
const [n, u] = f(null), [p, r] = f([]), [m, l] = f({ selected: [] });
|
|
11
|
+
return U(s, () => n), h(() => {
|
|
12
|
+
if (n) {
|
|
13
|
+
const { selection: A, store: e } = n.state;
|
|
14
|
+
e.all().length > 0 && r(e.all());
|
|
15
|
+
const v = (a) => r(() => e.all());
|
|
16
16
|
e.observe(v);
|
|
17
17
|
let i;
|
|
18
|
-
const b =
|
|
18
|
+
const b = A.subscribe(({ selected: a, pointerEvent: w }) => {
|
|
19
19
|
i && e.unobserve(i);
|
|
20
|
-
const
|
|
21
|
-
l({ selected:
|
|
20
|
+
const j = (a || []).map(({ id: d, editable: S }) => ({ annotation: e.getAnnotation(d), editable: S }));
|
|
21
|
+
l({ selected: j, pointerEvent: w }), i = (d) => {
|
|
22
22
|
const { updated: S } = d.changes;
|
|
23
|
-
l(({ selected:
|
|
24
|
-
selected:
|
|
25
|
-
const
|
|
26
|
-
return
|
|
23
|
+
l(({ selected: D }) => ({
|
|
24
|
+
selected: D.map(({ annotation: V, editable: x }) => {
|
|
25
|
+
const g = S.find((E) => E.oldValue.id === V.id);
|
|
26
|
+
return g ? { annotation: g.newValue, editable: x } : { annotation: V, editable: x };
|
|
27
27
|
})
|
|
28
28
|
}));
|
|
29
29
|
}, e.observe(i, { annotations: a.map(({ id: d }) => d) });
|
|
@@ -32,67 +32,66 @@ const n = j({
|
|
|
32
32
|
e.unobserve(v), b();
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
-
}, [
|
|
36
|
-
anno:
|
|
35
|
+
}, [n]), /* @__PURE__ */ I.jsx(o.Provider, { value: {
|
|
36
|
+
anno: n,
|
|
37
37
|
setAnno: u,
|
|
38
38
|
annotations: p,
|
|
39
|
-
selection:
|
|
39
|
+
selection: m
|
|
40
40
|
}, children: t.children });
|
|
41
|
-
}), F = () =>
|
|
42
|
-
const { anno: t } =
|
|
41
|
+
}), F = () => {
|
|
42
|
+
const { anno: t } = c(o);
|
|
43
43
|
return t;
|
|
44
|
-
},
|
|
45
|
-
const { anno: t } =
|
|
44
|
+
}, G = () => {
|
|
45
|
+
const { anno: t } = c(o);
|
|
46
46
|
return t == null ? void 0 : t.state.store;
|
|
47
|
-
},
|
|
48
|
-
const { annotations: t } =
|
|
47
|
+
}, H = () => {
|
|
48
|
+
const { annotations: t } = c(o);
|
|
49
49
|
return t;
|
|
50
|
-
},
|
|
51
|
-
const { annotations:
|
|
52
|
-
return C(
|
|
53
|
-
},
|
|
54
|
-
const { selection: t } =
|
|
50
|
+
}, P = (t) => {
|
|
51
|
+
const { annotations: s } = c(o);
|
|
52
|
+
return C(s, t);
|
|
53
|
+
}, J = (t) => t ? P(t) : H(), K = () => {
|
|
54
|
+
const { selection: t } = c(o);
|
|
55
55
|
return t;
|
|
56
|
-
},
|
|
57
|
-
const { anno: t } =
|
|
56
|
+
}, L = () => {
|
|
57
|
+
const { anno: t } = c(o);
|
|
58
58
|
return t == null ? void 0 : t.getUser();
|
|
59
59
|
}, _ = () => {
|
|
60
|
-
const { anno: t } =
|
|
60
|
+
const { anno: t } = c(o), [s, n] = f([]);
|
|
61
61
|
return h(() => {
|
|
62
62
|
if (t) {
|
|
63
63
|
const { store: u, viewport: p } = t.state;
|
|
64
64
|
if (!p)
|
|
65
65
|
return;
|
|
66
|
-
let
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
66
|
+
let r;
|
|
67
|
+
const m = p.subscribe((l) => {
|
|
68
|
+
r && u.unobserve(r);
|
|
69
|
+
const A = l.map((e) => u.getAnnotation(e));
|
|
70
|
+
n(A), r = (e) => {
|
|
71
71
|
const { updated: v } = e.changes;
|
|
72
|
-
|
|
72
|
+
n((i) => i.map((b) => {
|
|
73
73
|
const a = v.find((w) => w.oldValue.id === b.id);
|
|
74
74
|
return a ? a.newValue : b;
|
|
75
75
|
}));
|
|
76
|
-
}, u.observe(
|
|
76
|
+
}, u.observe(r, { annotations: l });
|
|
77
77
|
});
|
|
78
78
|
return () => {
|
|
79
|
-
|
|
79
|
+
m();
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
|
-
}, [t]),
|
|
82
|
+
}, [t]), s;
|
|
83
83
|
}, k = (t) => {
|
|
84
|
-
const
|
|
85
|
-
return C(
|
|
86
|
-
},
|
|
84
|
+
const s = _();
|
|
85
|
+
return C(s, t);
|
|
86
|
+
}, M = (t) => t ? k(t) : _();
|
|
87
87
|
export {
|
|
88
88
|
B as Annotorious,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
N as useViewportState
|
|
89
|
+
o as AnnotoriousContext,
|
|
90
|
+
G as useAnnotationStore,
|
|
91
|
+
J as useAnnotations,
|
|
92
|
+
F as useAnnotator,
|
|
93
|
+
L as useAnnotatorUser,
|
|
94
|
+
K as useSelection,
|
|
95
|
+
M as useViewportState
|
|
97
96
|
};
|
|
98
97
|
//# sourceMappingURL=annotorious-react.es2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotorious-react.es2.js","sources":["../src/Annotorious.tsx"],"sourcesContent":["import { createContext, forwardRef, ReactNode} from 'react';\nimport { useContext, useEffect, useImperativeHandle, useState } from 'react';\nimport { Annotation, Annotator, Store, StoreChangeEvent } from '@annotorious/annotorious';\nimport { useDebounce } from './useDebounce';\n\ninterface Selection<T extends Annotation = Annotation> {\n\n selected: { annotation: T, editable?: boolean }[];\n\n pointerEvent?: PointerEvent;\n\n}\n\nexport interface AnnotoriousContextState {\n\n anno: Annotator;\n\n setAnno(anno: Annotator<Annotation, unknown>): void;\n\n annotations: Annotation[];\n\n selection: Selection;\n\n}\n\nexport const AnnotoriousContext = createContext({ \n\n anno: undefined, \n\n setAnno: undefined, \n\n annotations: [], \n\n selection: { selected: [] }\n\n});\n\nexport const Annotorious = forwardRef<Annotator, { children: ReactNode }>((props: { children: ReactNode }, ref) => {\n\n const [anno, setAnno] = useState<Annotator>(null);\n\n const [annotations, setAnnotations] = useState<Annotation[]>([]);\n\n const [selection, setSelection] = useState<Selection>({ selected: [] });\n\n useImperativeHandle(ref, () => anno);\n\n useEffect(() => {\n if (anno) {\n const { selection, store } = anno.state;\n\n // Components below <Annotorious /> may have\n // loaded annotations into the store already! \n if (store.all().length > 0)\n setAnnotations(store.all());\n\n // Keeps annotations in sync with a React state,\n // so clients can render components the usual React way.\n const onStoreChange = (event: StoreChangeEvent<Annotation>) =>\n setAnnotations(() => store.all());\n\n store.observe(onStoreChange);\n\n // Keep selection in sync with a react state, and resolve them\n // from IDs to annotations automatically, for convenience\n let selectionStoreObserver: (event: StoreChangeEvent<Annotation>) => void;\n\n const unsubscribeSelection = selection.subscribe(({ selected, pointerEvent }) => {\n if (selectionStoreObserver) \n store.unobserve(selectionStoreObserver);\n\n const resolved = (selected || [])\n .map(({ id, editable }) => ({ annotation: store.getAnnotation(id), editable }));\n\n setSelection({ selected: resolved, pointerEvent });\n\n selectionStoreObserver = event => {\n const { updated } = event.changes;\n\n setSelection(({ selected }) => ({\n selected: selected.map(({ annotation, editable }) => {\n const next = updated.find(u => u.oldValue.id === annotation.id);\n return next ? { annotation: next.newValue, editable } : { annotation, editable };\n })\n }));\n }\n\n store.observe(selectionStoreObserver, { annotations: selected.map(({ id }) => id) });\n });\n\n return () => {\n store.unobserve(onStoreChange);\n unsubscribeSelection();\n }\n }\n }, [anno]);\n\n return (\n <AnnotoriousContext.Provider value={{ \n anno, \n setAnno,\n annotations, \n selection \n }}>\n {props.children}\n </AnnotoriousContext.Provider>\n )\n\n});\n\nexport const
|
|
1
|
+
{"version":3,"file":"annotorious-react.es2.js","sources":["../src/Annotorious.tsx"],"sourcesContent":["import { createContext, forwardRef, ReactNode} from 'react';\nimport { useContext, useEffect, useImperativeHandle, useState } from 'react';\nimport { Annotation, Annotator, Store, StoreChangeEvent } from '@annotorious/annotorious';\nimport { useDebounce } from './useDebounce';\n\ninterface Selection<T extends Annotation = Annotation> {\n\n selected: { annotation: T, editable?: boolean }[];\n\n pointerEvent?: PointerEvent;\n\n}\n\nexport interface AnnotoriousContextState {\n\n anno: Annotator;\n\n setAnno(anno: Annotator<Annotation, unknown>): void;\n\n annotations: Annotation[];\n\n selection: Selection;\n\n}\n\nexport const AnnotoriousContext = createContext({ \n\n anno: undefined, \n\n setAnno: undefined, \n\n annotations: [], \n\n selection: { selected: [] }\n\n});\n\nexport const Annotorious = forwardRef<Annotator, { children: ReactNode }>((props: { children: ReactNode }, ref) => {\n\n const [anno, setAnno] = useState<Annotator>(null);\n\n const [annotations, setAnnotations] = useState<Annotation[]>([]);\n\n const [selection, setSelection] = useState<Selection>({ selected: [] });\n\n useImperativeHandle(ref, () => anno);\n\n useEffect(() => {\n if (anno) {\n const { selection, store } = anno.state;\n\n // Components below <Annotorious /> may have\n // loaded annotations into the store already! \n if (store.all().length > 0)\n setAnnotations(store.all());\n\n // Keeps annotations in sync with a React state,\n // so clients can render components the usual React way.\n const onStoreChange = (event: StoreChangeEvent<Annotation>) =>\n setAnnotations(() => store.all());\n\n store.observe(onStoreChange);\n\n // Keep selection in sync with a react state, and resolve them\n // from IDs to annotations automatically, for convenience\n let selectionStoreObserver: (event: StoreChangeEvent<Annotation>) => void;\n\n const unsubscribeSelection = selection.subscribe(({ selected, pointerEvent }) => {\n if (selectionStoreObserver) \n store.unobserve(selectionStoreObserver);\n\n const resolved = (selected || [])\n .map(({ id, editable }) => ({ annotation: store.getAnnotation(id), editable }));\n\n setSelection({ selected: resolved, pointerEvent });\n\n selectionStoreObserver = event => {\n const { updated } = event.changes;\n\n setSelection(({ selected }) => ({\n selected: selected.map(({ annotation, editable }) => {\n const next = updated.find(u => u.oldValue.id === annotation.id);\n return next ? { annotation: next.newValue, editable } : { annotation, editable };\n })\n }));\n }\n\n store.observe(selectionStoreObserver, { annotations: selected.map(({ id }) => id) });\n });\n\n return () => {\n store.unobserve(onStoreChange);\n unsubscribeSelection();\n }\n }\n }, [anno]);\n\n return (\n <AnnotoriousContext.Provider value={{ \n anno, \n setAnno,\n annotations, \n selection \n }}>\n {props.children}\n </AnnotoriousContext.Provider>\n )\n\n});\n\nexport const useAnnotator = <T extends Annotator<any, unknown>>() => {\n const { anno } = useContext(AnnotoriousContext);\n return anno as T;\n}\n\nexport const useAnnotationStore = <T extends Store<Annotation>>() => {\n const { anno } = useContext(AnnotoriousContext);\n return anno?.state.store as T | undefined;\n}\n\nconst _useAnnotations = <T extends Annotation>() => {\n const { annotations } = useContext(AnnotoriousContext);\n return annotations as T[];\n}\n\nconst _useAnnotationsDebouced = <T extends Annotation>(debounce: number) => {\n const { annotations } = useContext(AnnotoriousContext);\n return useDebounce(annotations, debounce) as T[];\n}\n\nexport const useAnnotations = <T extends Annotation>(debounce?: number) =>\n debounce ? _useAnnotationsDebouced<T>(debounce) : _useAnnotations<T>();\n\nexport const useSelection = <T extends Annotation>() => {\n const { selection } = useContext(AnnotoriousContext);\n return selection as Selection<T>;\n}\n\nexport const useAnnotatorUser = () => {\n const { anno } = useContext(AnnotoriousContext);\n return anno?.getUser();\n}\n\nconst _useViewportState = <T extends Annotation>() => {\n const { anno } = useContext(AnnotoriousContext);\n\n const [inViewport, setInViewport] = useState<T[]>([]);\n\n useEffect(() => {\n if (anno) {\n const { store, viewport } = anno.state;\n\n if (!viewport)\n return;\n\n // Keep viewport annotations in sync with a react state, and resolve them\n // from IDs to annotations automatically, for convenience\n let viewportStoreObserver: (event: StoreChangeEvent<T>) => void;\n\n const unsubscribeViewport = viewport.subscribe(ids => {\n if (viewportStoreObserver) \n store.unobserve(viewportStoreObserver);\n\n const resolved = ids.map(id => store.getAnnotation(id)) as T[];\n setInViewport(resolved);\n\n viewportStoreObserver = event => {\n const { updated } = event.changes;\n\n setInViewport(annotations => annotations.map(annotation => {\n const next = updated.find(u => u.oldValue.id === annotation.id);\n return next ? next.newValue : annotation;\n }));\n }\n\n store.observe(viewportStoreObserver, { annotations: ids });\n });\n\n return () => {\n unsubscribeViewport();\n }\n }\n }, [anno]);\n\n return inViewport;\n}\n\nconst _useViewportStateDebounced = <T extends Annotation>(debounce: number) => {\n const inViewport = _useViewportState();\n return useDebounce(inViewport, debounce) as T[];\n}\n\nexport const useViewportState = <T extends Annotation>(debounce?: number) =>\n debounce ? _useViewportStateDebounced<T>(debounce) : _useViewportState<T>();\n"],"names":["AnnotoriousContext","createContext","Annotorious","forwardRef","props","ref","anno","setAnno","useState","annotations","setAnnotations","selection","setSelection","useImperativeHandle","useEffect","store","onStoreChange","event","selectionStoreObserver","unsubscribeSelection","selected","pointerEvent","resolved","id","editable","updated","annotation","next","u","jsx","useAnnotator","useContext","useAnnotationStore","_useAnnotations","_useAnnotationsDebouced","debounce","useDebounce","useAnnotations","useSelection","useAnnotatorUser","_useViewportState","inViewport","setInViewport","viewport","viewportStoreObserver","unsubscribeViewport","ids","_useViewportStateDebounced","useViewportState"],"mappings":";;;AAyBO,MAAMA,IAAqBC,EAAc;AAAA,EAE9C,MAAM;AAAA,EAEN,SAAS;AAAA,EAET,aAAa,CAAC;AAAA,EAEd,WAAW,EAAE,UAAU,GAAG;AAE5B,CAAC,GAEYC,IAA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,CAACyC,GAAYC,CAAa,IAAIlC,EAAc,CAAE,CAAA;AAEpD,SAAAM,EAAU,MAAM;AACd,QAAIR,GAAM;AACR,YAAM,EAAE,OAAAS,GAAO,UAAA4B,MAAarC,EAAK;AAEjC,UAAI,CAACqC;AACH;AAIE,UAAAC;AAEE,YAAAC,IAAsBF,EAAS,UAAU,CAAOG,MAAA;AAChD,QAAAF,KACF7B,EAAM,UAAU6B,CAAqB;AAEvC,cAAMtB,IAAWwB,EAAI,IAAI,OAAM/B,EAAM,cAAcQ,CAAE,CAAC;AACtD,QAAAmB,EAAcpB,CAAQ,GAEtBsB,IAAwB,CAAS3B,MAAA;AACzB,gBAAA,EAAE,SAAAQ,EAAQ,IAAIR,EAAM;AAEZ,UAAAyB,EAAA,CAAAjC,MAAeA,EAAY,IAAI,CAAciB,MAAA;AACnD,kBAAAC,IAAOF,EAAQ,KAAK,CAAAG,MAAKA,EAAE,SAAS,OAAOF,EAAW,EAAE;AACvD,mBAAAC,IAAOA,EAAK,WAAWD;AAAA,UAC/B,CAAA,CAAC;AAAA,QAAA,GAGJX,EAAM,QAAQ6B,GAAuB,EAAE,aAAaE,EAAK,CAAA;AAAA,MAAA,CAC1D;AAED,aAAO,MAAM;AACS,QAAAD;MAAA;AAAA,IAExB;AAAA,EAAA,GACC,CAACvC,CAAI,CAAC,GAEFmC;AACT,GAEMM,IAA8B,CAAuBZ,MAAqB;AAC9E,QAAMM,IAAaD;AACZ,SAAAJ,EAAYK,GAAYN,CAAQ;AACzC,GAEaa,IAAoB,CAAuBb,MACtDA,IAAWY,EAA8BZ,CAAQ,IAAIK,EAAqB;"}
|
|
@@ -1,35 +1,5 @@
|
|
|
1
|
-
|
|
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
|
-
}, A = () => {
|
|
26
|
-
e.style.left = `${t.x}px`, e.style.top = `${t.bottom + n}px`;
|
|
27
|
-
}, E = () => {
|
|
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 ? A() : E() : g > a ? R() : B();
|
|
31
|
-
};
|
|
1
|
+
var e = {};
|
|
32
2
|
export {
|
|
33
|
-
|
|
3
|
+
e as __exports
|
|
34
4
|
};
|
|
35
5
|
//# sourceMappingURL=annotorious-react.es20.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotorious-react.es20.js","sources":[
|
|
1
|
+
{"version":3,"file":"annotorious-react.es20.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { j as e } from "./annotorious-react.es12.js";
|
|
2
2
|
import { forwardRef as g } from "react";
|
|
3
3
|
import { useDraggable as i } from "./annotorious-react.es14.js";
|
|
4
|
-
const
|
|
5
|
-
const { children:
|
|
6
|
-
return i(o, { onDragStart:
|
|
4
|
+
const p = g((r, o) => {
|
|
5
|
+
const { children: t, className: a, onDragStart: s, onDragEnd: n } = r;
|
|
6
|
+
return i(o, { onDragStart: s, onDragEnd: n, cancel: "button, .no-drag" }), /* @__PURE__ */ e.jsx(
|
|
7
7
|
"div",
|
|
8
8
|
{
|
|
9
9
|
ref: o,
|
|
10
|
-
className:
|
|
10
|
+
className: a,
|
|
11
11
|
style: { position: "absolute" },
|
|
12
|
-
children:
|
|
12
|
+
children: t
|
|
13
13
|
}
|
|
14
14
|
);
|
|
15
15
|
});
|
|
16
16
|
export {
|
|
17
|
-
|
|
17
|
+
p as Draggable
|
|
18
18
|
};
|
|
19
19
|
//# sourceMappingURL=annotorious-react.es4.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotorious-react.es4.js","sources":["../src/AnnotoriousPopup.tsx"],"sourcesContent":["import { forwardRef, ReactNode } from 'react';\nimport { ImageAnnotation } from '@annotorious/annotorious';\nimport { useDraggable } from '@neodrag/react';\n\nexport interface AnnotoriousPopupProps {\n\n selected: { annotation: ImageAnnotation, editable?: boolean }[];\n\n}\n\nexport interface DraggableProps {\n\n children: ReactNode;\n\n className?: string;\n\n onDragStart?(): void;\n\n onDragEnd?(): void;\n\n}\n\nexport const Draggable = forwardRef((props: DraggableProps, ref: React.MutableRefObject<HTMLDivElement>) => {\n\n const { children, className, onDragStart, onDragEnd } = props;\n\n useDraggable(ref, { onDragStart, onDragEnd, cancel: 'button, .no-drag' });\n\n return (\n <div \n ref={ref} \n className={className} \n style={{ position: 'absolute' }}>\n {children}\n </div>\n )\n\n});"],"names":["Draggable","forwardRef","props","ref","children","className","onDragStart","onDragEnd","useDraggable","jsx"],"mappings":";;;AAsBO,MAAMA,IAAYC,EAAW,CAACC,GAAuBC,MAAiD;AAE3G,QAAM,EAAE,UAAAC,GAAU,WAAAC,GAAW,aAAAC,GAAa,WAAAC,MAAcL;AAExDM,SAAAA,EAAaL,GAAK,EAAE,aAAAG,GAAa,WAAAC,GAAW,QAAQ,oBAAoB,
|
|
1
|
+
{"version":3,"file":"annotorious-react.es4.js","sources":["../src/AnnotoriousPopup.tsx"],"sourcesContent":["import { forwardRef, ReactNode } from 'react';\nimport { ImageAnnotation } from '@annotorious/annotorious';\nimport { useDraggable } from '@neodrag/react';\n\nexport interface AnnotoriousPopupProps {\n\n selected: { annotation: ImageAnnotation, editable?: boolean }[];\n\n}\n\nexport interface DraggableProps {\n\n children: ReactNode;\n\n className?: string;\n\n onDragStart?(): void;\n\n onDragEnd?(): void;\n\n}\n\nexport const Draggable = forwardRef((props: DraggableProps, ref: React.MutableRefObject<HTMLDivElement>) => {\n\n const { children, className, onDragStart, onDragEnd } = props;\n\n useDraggable(ref, { onDragStart, onDragEnd, cancel: 'button, .no-drag' });\n\n return (\n <div \n ref={ref} \n className={className} \n style={{ position: 'absolute' }}>\n {children}\n </div>\n )\n\n});"],"names":["Draggable","forwardRef","props","ref","children","className","onDragStart","onDragEnd","useDraggable","jsx"],"mappings":";;;AAsBO,MAAMA,IAAYC,EAAW,CAACC,GAAuBC,MAAiD;AAE3G,QAAM,EAAE,UAAAC,GAAU,WAAAC,GAAW,aAAAC,GAAa,WAAAC,MAAcL;AAExDM,SAAAA,EAAaL,GAAK,EAAE,aAAAG,GAAa,WAAAC,GAAW,QAAQ,oBAAoB,GAGtEE,gBAAAA,EAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAAN;AAAA,MACA,WAAAE;AAAA,MACA,OAAO,EAAE,UAAU,WAAW;AAAA,MAC7B,UAAAD;AAAA,IAAA;AAAA,EAAA;AAIP,CAAC;"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Children as
|
|
1
|
+
import { j as n } from "./annotorious-react.es12.js";
|
|
2
|
+
import { Children as x, useContext as g, useEffect as e, cloneElement as d } from "react";
|
|
3
3
|
import { createImageAnnotator as u } from "@annotorious/annotorious";
|
|
4
|
-
import { AnnotoriousContext as
|
|
5
|
-
const
|
|
6
|
-
const { children:
|
|
4
|
+
import { AnnotoriousContext as h } from "./annotorious-react.es2.js";
|
|
5
|
+
const F = (t) => {
|
|
6
|
+
const { children: i, tool: y, ...l } = t, r = x.only(i), { anno: o, setAnno: m } = g(h), s = (c) => {
|
|
7
7
|
if (!o) {
|
|
8
|
-
const f =
|
|
9
|
-
|
|
8
|
+
const f = c.target, a = u(f, l);
|
|
9
|
+
m(a);
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
12
|
return e(() => {
|
|
@@ -15,9 +15,9 @@ const j = (t) => {
|
|
|
15
15
|
o && o.setFilter(t.filter);
|
|
16
16
|
}, [t.filter]), e(() => {
|
|
17
17
|
o && o.setStyle(t.style);
|
|
18
|
-
}, [t.style]), /* @__PURE__ */
|
|
18
|
+
}, [t.style]), /* @__PURE__ */ n.jsx(n.Fragment, { children: d(r, { onLoad: s }) });
|
|
19
19
|
};
|
|
20
20
|
export {
|
|
21
|
-
|
|
21
|
+
F as ImageAnnotator
|
|
22
22
|
};
|
|
23
23
|
//# sourceMappingURL=annotorious-react.es5.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotorious-react.es5.js","sources":["../src/ImageAnnotator.tsx"],"sourcesContent":["import { Children, ReactElement, cloneElement, useContext, useEffect } from 'react';\nimport { AnnotoriousOpts, createImageAnnotator } from '@annotorious/annotorious';\nimport type { DrawingStyle, DrawingTool, Filter, ImageAnnotation } from '@annotorious/annotorious';\nimport { AnnotoriousContext } from './Annotorious';\n\nexport interface ImageAnnotatorProps<E extends unknown> extends AnnotoriousOpts<ImageAnnotation, E> {\n\n children: ReactElement<HTMLImageElement>;\n\n filter?: Filter<ImageAnnotation>;\n\n style?: DrawingStyle | ((annotation: ImageAnnotation) => DrawingStyle);\n\n tool?: DrawingTool\n\n}\n\nexport const ImageAnnotator = <E extends unknown>(props: ImageAnnotatorProps<E>) => {\n\n const { children, tool, ...opts } = props;\n\n const child = Children.only(children);\n\n const { anno, setAnno } = useContext(AnnotoriousContext);\n\n const onLoad = (evt: Event) => {\n if (!anno) {\n const img = evt.target as HTMLImageElement;\n\n const next = createImageAnnotator(img, opts);\n setAnno(next); \n }\n };\n\n useEffect(() => {\n if (props.tool && anno) anno.setDrawingTool(props.tool);\n }, [props.tool, anno]);\n\n useEffect(() => {\n if (anno) anno.setFilter(props.filter);\n }, [props.filter]);\n\n useEffect(() => {\n if (anno) anno.setStyle(props.style);\n }, [props.style]);\n \n return <>{cloneElement(child, { onLoad } as Partial<HTMLImageElement>)}</>\n\n}"],"names":["ImageAnnotator","props","children","tool","opts","child","Children","anno","setAnno","useContext","AnnotoriousContext","onLoad","evt","img","next","createImageAnnotator","useEffect","cloneElement"],"mappings":";;;;AAiBa,MAAAA,IAAiB,CAAoBC,MAAkC;AAElF,QAAM,EAAE,UAAAC,GAAU,MAAAC,GAAM,GAAGC,MAASH,GAE9BI,IAAQC,EAAS,KAAKJ,CAAQ,GAE9B,EAAE,MAAAK,GAAM,SAAAC,EAAQ,IAAIC,EAAWC,CAAkB,GAEjDC,IAAS,CAACC,MAAe;AAC7B,QAAI,CAACL,GAAM;AACT,YAAMM,IAAMD,EAAI,QAEVE,IAAOC,EAAqBF,GAAKT,CAAI;AAC3C,MAAAI,EAAQM,CAAI;AAAA,IACd;AAAA,EAAA;AAGF,SAAAE,EAAU,MAAM;AACd,IAAIf,EAAM,QAAQM,KAAWA,EAAA,eAAeN,EAAM,IAAI;AAAA,EACrD,GAAA,CAACA,EAAM,MAAMM,CAAI,CAAC,GAErBS,EAAU,MAAM;AACV,IAAAT,KAAWA,EAAA,UAAUN,EAAM,MAAM;AAAA,EAAA,GACpC,CAACA,EAAM,MAAM,CAAC,GAEjBe,EAAU,MAAM;AACV,IAAAT,KAAWA,EAAA,SAASN,EAAM,KAAK;AAAA,EAAA,GAClC,CAACA,EAAM,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"annotorious-react.es5.js","sources":["../src/ImageAnnotator.tsx"],"sourcesContent":["import { Children, ReactElement, cloneElement, useContext, useEffect } from 'react';\nimport { AnnotoriousOpts, createImageAnnotator } from '@annotorious/annotorious';\nimport type { DrawingStyle, DrawingTool, Filter, ImageAnnotation } from '@annotorious/annotorious';\nimport { AnnotoriousContext } from './Annotorious';\n\nexport interface ImageAnnotatorProps<E extends unknown> extends AnnotoriousOpts<ImageAnnotation, E> {\n\n children: ReactElement<HTMLImageElement>;\n\n filter?: Filter<ImageAnnotation>;\n\n style?: DrawingStyle | ((annotation: ImageAnnotation) => DrawingStyle);\n\n tool?: DrawingTool\n\n}\n\nexport const ImageAnnotator = <E extends unknown>(props: ImageAnnotatorProps<E>) => {\n\n const { children, tool, ...opts } = props;\n\n const child = Children.only(children);\n\n const { anno, setAnno } = useContext(AnnotoriousContext);\n\n const onLoad = (evt: Event) => {\n if (!anno) {\n const img = evt.target as HTMLImageElement;\n\n const next = createImageAnnotator(img, opts);\n setAnno(next); \n }\n };\n\n useEffect(() => {\n if (props.tool && anno) anno.setDrawingTool(props.tool);\n }, [props.tool, anno]);\n\n useEffect(() => {\n if (anno) anno.setFilter(props.filter);\n }, [props.filter]);\n\n useEffect(() => {\n if (anno) anno.setStyle(props.style);\n }, [props.style]);\n \n return <>{cloneElement(child, { onLoad } as Partial<HTMLImageElement>)}</>\n\n}"],"names":["ImageAnnotator","props","children","tool","opts","child","Children","anno","setAnno","useContext","AnnotoriousContext","onLoad","evt","img","next","createImageAnnotator","useEffect","cloneElement"],"mappings":";;;;AAiBa,MAAAA,IAAiB,CAAoBC,MAAkC;AAElF,QAAM,EAAE,UAAAC,GAAU,MAAAC,GAAM,GAAGC,MAASH,GAE9BI,IAAQC,EAAS,KAAKJ,CAAQ,GAE9B,EAAE,MAAAK,GAAM,SAAAC,EAAQ,IAAIC,EAAWC,CAAkB,GAEjDC,IAAS,CAACC,MAAe;AAC7B,QAAI,CAACL,GAAM;AACT,YAAMM,IAAMD,EAAI,QAEVE,IAAOC,EAAqBF,GAAKT,CAAI;AAC3C,MAAAI,EAAQM,CAAI;AAAA,IACd;AAAA,EAAA;AAGF,SAAAE,EAAU,MAAM;AACd,IAAIf,EAAM,QAAQM,KAAWA,EAAA,eAAeN,EAAM,IAAI;AAAA,EACrD,GAAA,CAACA,EAAM,MAAMM,CAAI,CAAC,GAErBS,EAAU,MAAM;AACV,IAAAT,KAAWA,EAAA,UAAUN,EAAM,MAAM;AAAA,EAAA,GACpC,CAACA,EAAM,MAAM,CAAC,GAEjBe,EAAU,MAAM;AACV,IAAAT,KAAWA,EAAA,SAASN,EAAM,KAAK;AAAA,EAAA,GAClC,CAACA,EAAM,KAAK,CAAC,uCAEN,UAAagB,EAAAZ,GAAO,EAAE,QAAAM,GAAsC,EAAE,CAAA;AAE1E;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotorious-react.es6.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"annotorious-react.es6.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotorious-react.es7.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"annotorious-react.es7.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -36,7 +36,7 @@ const b = (t, r, e, a) => ({
|
|
|
36
36
|
...r
|
|
37
37
|
});
|
|
38
38
|
var h = /* @__PURE__ */ ((t) => (t.LOCAL = "LOCAL", t.REMOTE = "REMOTE", t))(h || {});
|
|
39
|
-
let E = (t) => crypto.getRandomValues(new Uint8Array(t)),
|
|
39
|
+
let E = (t) => crypto.getRandomValues(new Uint8Array(t)), R = (t, r, e) => {
|
|
40
40
|
let a = (2 << Math.log(t.length - 1) / Math.LN2) - 1, n = -~(1.6 * a * r / t.length);
|
|
41
41
|
return (d = r) => {
|
|
42
42
|
let s = "";
|
|
@@ -47,8 +47,8 @@ let E = (t) => crypto.getRandomValues(new Uint8Array(t)), C = (t, r, e) => {
|
|
|
47
47
|
return s;
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
|
-
},
|
|
51
|
-
const A = () => ({ isGuest: !0, id:
|
|
50
|
+
}, w = (t, r = 21) => R(t, r, E), C = (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), "");
|
|
51
|
+
const A = () => ({ isGuest: !0, id: w("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), D = [
|
|
52
52
|
"#ff7c00",
|
|
53
53
|
// orange
|
|
54
54
|
"#1ac938",
|
|
@@ -68,13 +68,13 @@ const A = () => ({ isGuest: !0, id: D("1234567890abcdefghijklmnopqrstuvwxyzABCDE
|
|
|
68
68
|
"#023eff"
|
|
69
69
|
// blue
|
|
70
70
|
], I = () => {
|
|
71
|
-
const t = [...
|
|
71
|
+
const t = [...D];
|
|
72
72
|
return { assignRandomColor: () => {
|
|
73
73
|
const r = Math.floor(Math.random() * t.length), e = t[r];
|
|
74
74
|
return t.splice(r, 1), e;
|
|
75
75
|
}, releaseColor: (r) => t.push(r) };
|
|
76
76
|
};
|
|
77
|
-
|
|
77
|
+
C();
|
|
78
78
|
export {
|
|
79
79
|
h as Origin,
|
|
80
80
|
f as PointerSelectAction,
|
|
@@ -1 +1 @@
|
|
|
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"],"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AI;AACR,eAAW;AACT,UAAIC,IAAIT,EAAEE,CAAC,GAAGQ,IAAIR;AAClB,aAAOQ;AACL,YAAIF,KAAKlB,EAAEmB,EAAEC,CAAC,IAAIT,CAAC,KAAK,IAAIO,EAAE,WAAWD;AACvC,iBAAOC;AAAA,IACZ;AAAA,EACL;AACA,GAAGG,IAAK,CAACrB,GAAGM,IAAI,OAAOU,EAAGhB,GAAGM,GAAGS,CAAE,GAAGO,IAAK,CAACtB,IAAI,OAAO,OAAO,gBAAgB,IAAI,WAAWA,CAAC,CAAC,EAAE,OAAO,CAACM,GAAGI,OAAOA,KAAK,IAAIA,IAAI,KAAKJ,KAAKI,EAAE,SAAS,EAAE,IAAIA,IAAI,KAAKJ,MAAMI,IAAI,IAAI,SAAS,EAAE,EAAE,YAAW,IAAKA,IAAI,KAAKJ,KAAK,MAAMA,KAAK,KAAKA,IAAI,EAAE;AAC7O,MAACiB,IAAK,OAAO,EAAE,SAAS,IAAI,IAAIF,EAAG,mEAAmE,EAAE,EAAC,MAwB1GG,IAAK;AAAA,EACP;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAEF,GAAGC,IAAK,MAAM;AACZ,QAAMzB,IAAI,CAAC,GAAGwB,CAAE;AAChB,SAAO,EAAE,mBAAmB,MAAM;AAChC,UAAMb,IAAI,KAAK,MAAM,KAAK,OAAM,IAAKX,EAAE,MAAM,GAAGY,IAAIZ,EAAEW,CAAC;AACvD,WAAOX,EAAE,OAAOW,GAAG,CAAC,GAAGC;AAAA,EAC3B,GAAK,cAAc,CAACD,MAAMX,EAAE,KAAKW,CAAC;AAClC;AAUuFW,EAAI;"}
|
|
1
|
+
{"version":3,"file":"annotorious-react.es8.js","sources":["../../annotorious-core/dist/annotorious-core.es.js"],"sourcesContent":["var Y = Object.prototype.hasOwnProperty;\nfunction x(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-- && x(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) || !x(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 W(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 (W(e, b) && (e = b, t)) {\n const w = !k.length;\n for (const u of o)\n u[1](), k.push(u, e);\n if (w) {\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 p(b) {\n i(b(e));\n }\n function U(b, w = $) {\n const u = [b, w];\n return o.add(u), o.size === 1 && (t = n(i, p) || $), b(e), () => {\n o.delete(u), o.size === 0 && t && (t(), t = null);\n };\n }\n return { set: i, update: p, subscribe: U };\n}\nconst be = (e) => {\n const { subscribe: n, set: t } = _();\n let o;\n return n((i) => o = i), e.observe(({ changes: i }) => {\n if (o) {\n (i.deleted || []).some((b) => b.id === o) && t(void 0);\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 q = /* @__PURE__ */ ((e) => (e.EDIT = \"EDIT\", e.SELECT = \"SELECT\", e.NONE = \"NONE\", e))(q || {});\nconst V = { selected: [] }, ve = (e, n = \"EDIT\") => {\n const { subscribe: t, set: o } = _(V);\n let i = V;\n t((s) => i = s);\n const p = () => 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 g = typeof s == \"string\" ? s : s.id;\n return i.selected.some((y) => y.id === g);\n }, w = (s, g) => {\n const y = e.getAnnotation(s);\n if (y) {\n const A = G(y, n);\n o(A === \"EDIT\" ? { selected: [{ id: s, editable: !0 }], pointerEvent: g } : A === \"SELECT\" ? { selected: [{ id: s }], pointerEvent: g } : { selected: [], pointerEvent: g });\n } else\n console.warn(\"Invalid selection: \" + s);\n }, u = (s, g = !0) => {\n const y = Array.isArray(s) ? s : [s], A = y.map((O) => e.getAnnotation(O)).filter(Boolean);\n o({ selected: A.map(({ id: O }) => ({ id: O, editable: g })) }), A.length !== y.length && console.warn(\"Invalid selection\", s);\n }, S = (s) => {\n if (i.selected.length === 0)\n return !1;\n const { selected: g } = i;\n g.filter(({ id: A }) => s.includes(A)).length > 0 && o({ selected: g.filter(({ id: A }) => !s.includes(A)) });\n };\n return e.observe(({ changes: s }) => S((s.deleted || []).map((g) => g.id))), {\n clear: p,\n clickSelect: w,\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}, G = (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 Ce = (e) => {\n const { creator: n, updatedBy: t } = e.target, o = e.bodies.reduce((i, p) => [...i, p.creator, p.updatedBy].filter(Boolean), []);\n return [\n n,\n t,\n ...o\n ].filter((i) => i);\n}, we = (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 && !x(o, t) ? o : void 0 };\n}).filter(({ oldBody: t }) => t).map(({ oldBody: t, newBody: o }) => ({ oldBody: t, newBody: o })), te = (e, n) => !x(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 || {}), T = /* @__PURE__ */ ((e) => (e.LOCAL = \"LOCAL\", e.REMOTE = \"REMOTE\", e))(T || {});\nconst oe = (e, n) => {\n var p, 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, w = (S) => S && S.length > 0;\n if (!(w(t.created) || w(t.deleted))) {\n const S = (p = t.updated) == null ? void 0 : p.some((g) => w(g.bodiesCreated) || w(g.bodiesDeleted) || w(g.bodiesUpdated)), s = (U = t.updated) == null ? void 0 : U.some((g) => g.targetUpdated);\n if (b === \"BODY_ONLY\" && S && !s || b === \"TARGET_ONLY\" && s && !S)\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)), p = 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)), w = [\n ...(e.created || []).filter((s) => !p.has(s.id)).map((s) => U.has(s.id) ? n.updated.find(({ oldValue: g }) => g.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 ], S = [\n ...(e.updated || []).filter(({ newValue: s }) => !p.has(s.id)).map((s) => {\n const { oldValue: g, newValue: y } = s;\n if (U.has(y.id)) {\n const A = n.updated.find((O) => O.oldValue.id === y.id).newValue;\n return M(g, A);\n } else\n return s;\n }),\n ...(n.updated || []).filter(({ oldValue: s }) => !b.has(s.id))\n ];\n return { created: w, deleted: u, updated: S };\n}, ie = (e) => e.id !== void 0, ye = () => {\n const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), t = [], o = (d, l = {}) => t.push({ onChange: d, options: l }), i = (d) => {\n const l = t.findIndex((c) => c.onChange == d);\n l > -1 && t.splice(l, 1);\n }, p = (d, l) => {\n const c = {\n origin: d,\n changes: {\n created: l.created || [],\n updated: l.updated || [],\n deleted: l.deleted || []\n },\n state: [...e.values()]\n };\n t.forEach((f) => {\n oe(f, c) && f.onChange(c);\n });\n }, U = (d, l = T.LOCAL) => {\n if (e.get(d.id))\n throw Error(`Cannot add annotation ${d.id} - exists already`);\n e.set(d.id, d), d.bodies.forEach((f) => n.set(f.id, d.id)), p(l, { created: [d] });\n }, b = (d, l) => {\n const c = typeof d == \"string\" ? l : d, f = typeof d == \"string\" ? d : d.id, v = e.get(f);\n if (v) {\n const D = M(v, c);\n return f === c.id ? e.set(f, c) : (e.delete(f), e.set(c.id, c)), v.bodies.forEach((B) => n.delete(B.id)), c.bodies.forEach((B) => n.set(B.id, c.id)), D;\n } else\n console.warn(`Cannot update annotation ${f} - does not exist`);\n }, w = (d, l = T.LOCAL, c = T.LOCAL) => {\n const f = ie(l) ? c : l, v = b(d, l);\n v && p(f, { updated: [v] });\n }, u = (d, l = T.LOCAL) => {\n const c = d.reduce((f, v) => {\n const D = b(v);\n return D ? [...f, D] : f;\n }, []);\n c.length > 0 && p(l, { updated: c });\n }, S = (d, l = T.LOCAL) => {\n const c = e.get(d.annotation);\n if (c) {\n const f = {\n ...c,\n bodies: [...c.bodies, d]\n };\n e.set(c.id, f), n.set(d.id, f.id), p(l, { updated: [{\n oldValue: c,\n newValue: f,\n bodiesCreated: [d]\n }] });\n } else\n console.warn(`Attempt to add body to missing annotation: ${d.annotation}`);\n }, s = () => [...e.values()], g = (d = T.LOCAL) => {\n const l = [...e.values()];\n e.clear(), n.clear(), p(d, { deleted: l });\n }, y = (d, l = !0, c = T.LOCAL) => {\n if (l) {\n const f = [...e.values()];\n e.clear(), n.clear(), d.forEach((v) => {\n e.set(v.id, v), v.bodies.forEach((D) => n.set(D.id, v.id));\n }), p(c, { created: d, deleted: f });\n } else {\n const f = d.reduce((v, D) => {\n const B = e.get(D.id);\n return B ? [...v, B] : v;\n }, []);\n if (f.length > 0)\n throw Error(`Bulk insert would overwrite the following annotations: ${f.map((v) => v.id).join(\", \")}`);\n d.forEach((v) => {\n e.set(v.id, v), v.bodies.forEach((D) => n.set(D.id, v.id));\n }), p(c, { created: d });\n }\n }, A = (d) => {\n const l = typeof d == \"string\" ? d : d.id, c = e.get(l);\n if (c)\n return e.delete(l), c.bodies.forEach((f) => n.delete(f.id)), c;\n console.warn(`Attempt to delete missing annotation: ${l}`);\n }, O = (d, l = T.LOCAL) => {\n const c = A(d);\n c && p(l, { deleted: [c] });\n }, C = (d, l = T.LOCAL) => {\n const c = d.reduce((f, v) => {\n const D = A(v);\n return D ? [...f, D] : f;\n }, []);\n c.length > 0 && p(l, { deleted: c });\n }, a = (d, l = T.LOCAL) => {\n const c = e.get(d.annotation);\n if (c) {\n const f = c.bodies.find((v) => v.id === d.id);\n if (f) {\n n.delete(f.id);\n const v = {\n ...c,\n bodies: c.bodies.filter((B) => B.id !== d.id)\n };\n e.set(c.id, v), p(l, { updated: [{\n oldValue: c,\n newValue: v,\n bodiesDeleted: [f]\n }] });\n } else\n console.warn(`Attempt to delete missing body ${d.id} from annotation ${d.annotation}`);\n } else\n console.warn(`Attempt to delete body from missing annotation ${d.annotation}`);\n }, m = (d) => {\n const l = e.get(d);\n return l ? { ...l } : void 0;\n }, r = (d) => {\n const l = n.get(d);\n if (l) {\n const f = m(l).bodies.find((v) => v.id === d);\n if (f)\n return f;\n console.error(`Store integrity error: body ${d} in index, but not in annotation`);\n } else\n console.warn(`Attempt to retrieve missing body: ${d}`);\n }, E = (d, l) => {\n if (d.annotation !== l.annotation)\n throw \"Annotation integrity violation: annotation ID must be the same when updating bodies\";\n const c = e.get(d.annotation);\n if (c) {\n const f = c.bodies.find((D) => D.id === d.id), v = {\n ...c,\n bodies: c.bodies.map((D) => D.id === f.id ? l : D)\n };\n return e.set(c.id, v), f.id !== l.id && (n.delete(f.id), n.set(l.id, v.id)), {\n oldValue: c,\n newValue: v,\n bodiesUpdated: [{ oldBody: f, newBody: l }]\n };\n } else\n console.warn(`Attempt to add body to missing annotation ${d.annotation}`);\n }, h = (d, l, c = T.LOCAL) => {\n const f = E(d, l);\n f && p(c, { updated: [f] });\n }, L = (d, l = T.LOCAL) => {\n const c = d.map((f) => E({ id: f.id, annotation: f.annotation }, f)).filter(Boolean);\n p(l, { updated: c });\n }, I = (d) => {\n const l = e.get(d.annotation);\n if (l) {\n const c = {\n ...l,\n target: {\n ...l.target,\n ...d\n }\n };\n return e.set(l.id, c), {\n oldValue: l,\n newValue: c,\n targetUpdated: {\n oldTarget: l.target,\n newTarget: d\n }\n };\n } else\n console.warn(`Attempt to update target on missing annotation: ${d.annotation}`);\n };\n return {\n addAnnotation: U,\n addBody: S,\n all: s,\n bulkAddAnnotation: y,\n bulkDeleteAnnotation: C,\n bulkUpdateAnnotation: u,\n bulkUpdateBodies: L,\n bulkUpdateTargets: (d, l = T.LOCAL) => {\n const c = d.map((f) => I(f)).filter(Boolean);\n c.length > 0 && p(l, { updated: c });\n },\n clear: g,\n deleteAnnotation: O,\n deleteBody: a,\n getAnnotation: m,\n getBody: r,\n observe: o,\n unobserve: i,\n updateAnnotation: w,\n updateBody: h,\n updateTarget: (d, l = T.LOCAL) => {\n const c = I(d);\n c && p(l, { updated: [c] });\n }\n };\n}, Ue = (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 for (let t = 0, o = this.events[e] || [], i = o.length; t < i; t++)\n o[t](...n);\n },\n events: {},\n on(e, n) {\n var t;\n return ((t = this.events)[e] || (t[e] = [])).push(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, Le = (e) => {\n const n = P(), t = [];\n let o = -1, i = !1, p = 0;\n const U = (r) => {\n if (!i) {\n const { changes: E } = r, h = performance.now();\n if (h - p > de)\n t.splice(o + 1), t.push(E), o = t.length - 1;\n else {\n const L = t.length - 1;\n t[L] = se(t[L], E);\n }\n p = h;\n }\n i = !1;\n };\n e.observe(U, { origin: T.LOCAL });\n const b = (r) => r && r.length > 0 && e.bulkDeleteAnnotation(r), w = (r) => r && r.length > 0 && e.bulkAddAnnotation(r, !1), u = (r) => r && r.length > 0 && e.bulkUpdateAnnotation(r.map(({ oldValue: E }) => E)), S = (r) => r && r.length > 0 && e.bulkUpdateAnnotation(r.map(({ newValue: E }) => E)), s = (r) => r && r.length > 0 && e.bulkAddAnnotation(r, !1), g = (r) => r && r.length > 0 && e.bulkDeleteAnnotation(r);\n return {\n canRedo: () => t.length - 1 > o,\n canUndo: () => o > -1,\n destroy: () => e.unobserve(U),\n on: (r, E) => n.on(r, E),\n redo: () => {\n if (t.length - 1 > o) {\n i = !0;\n const { created: r, updated: E, deleted: h } = t[o + 1];\n w(r), S(E), g(h), n.emit(\"redo\", t[o + 1]), o += 1;\n }\n },\n undo: () => {\n if (o > -1) {\n i = !0;\n const { created: r, updated: E, deleted: h } = t[o];\n b(r), u(E), s(h), n.emit(\"undo\", t[o]), o -= 1;\n }\n }\n };\n}, Se = () => {\n const { subscribe: e, set: n } = _([]);\n return {\n subscribe: e,\n set: n\n };\n}, Oe = (e, n, t, o) => {\n const { store: i, selection: p, hover: U, viewport: b } = e, w = /* @__PURE__ */ new Map();\n let u = [], S, s;\n const g = (a, m) => {\n w.has(a) ? w.get(a).push(m) : w.set(a, [m]);\n }, y = (a, m) => {\n const r = w.get(a);\n r && r.indexOf(m) > 0 && r.splice(r.indexOf(m), 1);\n }, A = (a, m, r) => {\n w.has(a) && setTimeout(() => {\n w.get(a).forEach((E) => {\n if (t) {\n const h = Array.isArray(m) ? m.map((I) => t.serialize(I)) : t.serialize(m), L = r ? r instanceof PointerEvent ? r : t.serialize(r) : void 0;\n E(h, L);\n } else\n E(m, r);\n });\n }, 1);\n }, O = () => {\n const { selected: a } = p, m = (a || []).map(({ id: r }) => i.getAnnotation(r));\n m.forEach((r) => {\n const E = u.find((h) => h.id === r.id);\n (!E || !x(E, r)) && A(\"updateAnnotation\", r, E);\n }), u = u.map((r) => {\n const E = m.find(({ id: h }) => h === r.id);\n return E || r;\n });\n };\n p.subscribe(({ selected: a }) => {\n if (!(u.length === 0 && a.length === 0)) {\n if (u.length === 0 && a.length > 0)\n u = a.map(({ id: m }) => i.getAnnotation(m));\n else if (u.length > 0 && a.length === 0)\n u.forEach((m) => {\n const r = i.getAnnotation(m.id);\n r && !x(r, m) && A(\"updateAnnotation\", r, m);\n }), u = [];\n else {\n const m = new Set(u.map((h) => h.id)), r = new Set(a.map(({ id: h }) => h));\n u.filter((h) => !r.has(h.id)).forEach((h) => {\n const L = i.getAnnotation(h.id);\n L && !x(L, h) && A(\"updateAnnotation\", L, h);\n }), u = [\n // Remove annotations that were deselected\n ...u.filter((h) => r.has(h.id)),\n // Add editable annotations that were selected\n ...a.filter(({ id: h }) => !m.has(h)).map(({ id: h }) => i.getAnnotation(h))\n ];\n }\n A(\"selectionChanged\", u);\n }\n }), U.subscribe((a) => {\n !S && a ? A(\"mouseEnterAnnotation\", i.getAnnotation(a)) : S && !a ? A(\"mouseLeaveAnnotation\", i.getAnnotation(S)) : S && a && (A(\"mouseLeaveAnnotation\", i.getAnnotation(S)), A(\"mouseEnterAnnotation\", i.getAnnotation(a))), S = a;\n }), b == null || b.subscribe((a) => A(\"viewportIntersect\", a.map((m) => i.getAnnotation(m)))), i.observe((a) => {\n o && (s && clearTimeout(s), s = setTimeout(O, 1e3));\n const { created: m, deleted: r } = a.changes;\n (m || []).forEach((h) => A(\"createAnnotation\", h)), (r || []).forEach((h) => A(\"deleteAnnotation\", h)), (a.changes.updated || []).filter((h) => [\n ...h.bodiesCreated || [],\n ...h.bodiesDeleted || [],\n ...h.bodiesUpdated || []\n ].length > 0).forEach(({ oldValue: h, newValue: L }) => {\n const I = u.find((N) => N.id === h.id) || h;\n u = u.map((N) => N.id === h.id ? L : N), A(\"updateAnnotation\", L, I);\n });\n }, { origin: T.LOCAL }), i.observe((a) => {\n if (u) {\n const m = new Set(u.map((E) => E.id)), r = (a.changes.updated || []).filter(({ newValue: E }) => m.has(E.id)).map(({ newValue: E }) => E);\n r.length > 0 && (u = u.map((E) => {\n const h = r.find((L) => L.id === E.id);\n return h || E;\n }));\n }\n }, { origin: T.REMOTE });\n const C = (a) => (m) => {\n const { created: r, deleted: E, updated: h } = m;\n (r || []).forEach((L) => A(\"createAnnotation\", L)), (E || []).forEach((L) => A(\"deleteAnnotation\", L)), a ? (h || []).forEach((L) => A(\"updateAnnotation\", L.oldValue, L.newValue)) : (h || []).forEach((L) => A(\"updateAnnotation\", L.newValue, L.oldValue));\n };\n return n.on(\"undo\", C(!0)), n.on(\"redo\", C(!1)), { on: g, 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: p } = e.parse(o);\n return p ? {\n parsed: t.parsed,\n failed: [...t.failed, o]\n } : i ? {\n parsed: [...t.parsed, i],\n failed: t.failed\n } : {\n ...t\n };\n}, { parsed: [], failed: [] }), De = (e, n, t) => {\n const { store: o, selection: i } = e, p = (C) => {\n if (t) {\n const { parsed: a, error: m } = t.parse(C);\n a ? o.addAnnotation(a, T.REMOTE) : console.error(m);\n } else\n o.addAnnotation(C, T.REMOTE);\n }, U = () => i.clear(), b = () => o.clear(), w = (C) => {\n const a = o.getAnnotation(C);\n return t && a ? t.serialize(a) : a;\n }, u = () => t ? o.all().map(t.serialize) : o.all(), S = () => {\n var m;\n const a = (((m = i.selected) == null ? void 0 : m.map((r) => r.id)) || []).map((r) => o.getAnnotation(r)).filter(Boolean);\n return t ? a.map(t.serialize) : a;\n }, s = (C) => fetch(C).then((a) => a.json()).then((a) => (y(a), a)), g = (C) => {\n if (typeof C == \"string\") {\n const a = o.getAnnotation(C);\n if (o.deleteAnnotation(C), a)\n return t ? t.serialize(a) : a;\n } else {\n const a = t ? t.parse(C).parsed : C;\n if (a)\n return o.deleteAnnotation(a), C;\n }\n }, y = (C) => {\n if (t) {\n const { parsed: a, failed: m } = re(t)(C);\n m.length > 0 && console.warn(`Discarded ${m.length} invalid annotations`, m), o.bulkAddAnnotation(a, !0, T.REMOTE);\n } else\n o.bulkAddAnnotation(C, !0, T.REMOTE);\n }, A = (C) => {\n C ? i.setSelected(C) : i.clear();\n }, O = (C) => {\n if (t) {\n const a = t.parse(C).parsed, m = t.serialize(o.getAnnotation(a.id));\n return o.updateAnnotation(a), m;\n } else {\n const a = o.getAnnotation(C.id);\n return o.updateAnnotation(C), a;\n }\n };\n return {\n addAnnotation: p,\n cancelSelected: U,\n canRedo: n.canRedo,\n canUndo: n.canUndo,\n clearAnnotations: b,\n getAnnotationById: w,\n getAnnotations: u,\n getSelected: S,\n loadAnnotations: s,\n redo: n.redo,\n removeAnnotation: g,\n setAnnotations: y,\n setSelected: A,\n undo: n.undo,\n updateAnnotation: O\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 (p = n) => {\n let U = \"\";\n for (; ; ) {\n let b = t(i), w = i;\n for (; w--; )\n if (U += e[b[w] & o] || \"\", U.length === p)\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 Re = () => ({ 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 p = n.charCodeAt(o);\n t = (t << 5) - t + p, t |= 0;\n }\n return `${t}`;\n}, pe = (e) => e ? typeof e == \"object\" ? { ...e } : e : void 0, Be = (e, n) => (Array.isArray(e) ? e : [e]).map((t) => {\n const { id: o, type: i, purpose: p, value: U, created: b, creator: w, ...u } = t;\n return {\n id: o || `temp-${fe(t)}`,\n annotation: n,\n type: i,\n purpose: p,\n value: U,\n created: b ? new Date(b) : void 0,\n creator: pe(w),\n ...u\n };\n}), xe = (e) => e.map((n) => {\n var o, i;\n const t = { ...n };\n return delete t.annotation, (o = t.id) != null && o.startsWith(\"temp-\") && delete t.id, { ...t, created: (i = t.created) == null ? void 0 : i.toISOString() };\n}), ge = [\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 = [...ge];\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}, me = () => {\n const e = he();\n return { addUser: (o, i) => {\n const p = e.assignRandomColor();\n return {\n label: i.name || i.id,\n avatar: i.avatar,\n color: p\n };\n }, removeUser: (o) => e.releaseColor(o.appearance.color) };\n}, Ae = (e, n) => e.every((t) => e.includes(t)) && n.every((t) => e.includes(t)), Ie = ue(), ke = (e = me()) => {\n const n = P(), t = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), i = (s, g) => {\n if (t.has(s)) {\n console.warn(\"Attempt to add user that is already present\", s, g);\n return;\n }\n const y = e.addUser(s, g);\n t.set(s, {\n ...g,\n presenceKey: s,\n appearance: y\n });\n }, p = (s) => {\n const g = t.get(s);\n if (!g) {\n console.warn(\"Attempt to remove user that is not present\", s);\n return;\n }\n e.removeUser(g), t.delete(s);\n }, U = (s) => {\n const g = new Set(s.map((O) => O.presenceKey)), y = s.filter(({ presenceKey: O }) => !t.has(O)), A = Array.from(t.values()).filter((O) => !g.has(O.presenceKey));\n y.forEach(({ presenceKey: O, user: C }) => i(O, C)), A.forEach((O) => {\n const { presenceKey: C } = O;\n o.has(C) && n.emit(\"selectionChange\", O, null), p(C);\n }), (y.length > 0 || A.length > 0) && n.emit(\"presence\", u());\n }, b = (s, g) => {\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 || !Ae(A, g)) && (o.set(s, g), n.emit(\"selectionChange\", y, g));\n }, w = (s, g) => {\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 g ? o.set(s, g) : o.delete(s), n.emit(\"selectionChange\", y, g);\n }, u = () => [...Array.from(t.values())];\n return {\n getPresentUsers: u,\n notifyActivity: b,\n on: (s, g) => n.on(s, g),\n syncUsers: U,\n updateSelection: w\n };\n};\nexport {\n ne as Ignore,\n T as Origin,\n Ie as PRESENCE_KEY,\n q as PointerSelectAction,\n Re as createAnonymousGuest,\n De as createBaseAnnotator,\n we as createBody,\n me as createDefaultAppearenceProvider,\n be as createHoverState,\n Oe as createLifecyleObserver,\n ke as createPresenceState,\n ve as createSelectionState,\n ye as createStore,\n Le as createUndoStack,\n Se as createViewportState,\n he as defaultColorProvider,\n M as diffAnnotations,\n Ce as getContributors,\n se as mergeChanges,\n G as onPointerSelect,\n re as parseAll,\n Be as parseW3CBodies,\n pe as parseW3CUser,\n Te as serializeAll,\n xe as serializeW3CBodies,\n oe as shouldNotify,\n Ue as toSvelteStore\n};\n//# sourceMappingURL=annotorious-core.es.js.map\n"],"names":["q","e","z","H","F","R","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