@soomo/react-text-annotator 3.0.0-staging.2 → 3.0.0-staging.21

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 (60) hide show
  1. package/dist/TextAnnotator.d.ts +3 -3
  2. package/dist/TextAnnotator.d.ts.map +1 -1
  3. package/dist/TextAnnotatorPlugin.d.ts +1 -2
  4. package/dist/TextAnnotatorPlugin.d.ts.map +1 -1
  5. package/dist/TextAnnotatorPopup.d.ts +6 -5
  6. package/dist/TextAnnotatorPopup.d.ts.map +1 -1
  7. package/dist/index.d.ts +5 -2
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/react-text-annotator.es.js +8 -2
  10. package/dist/react-text-annotator.es.js.map +1 -1
  11. package/dist/react-text-annotator.es10.js +230 -33
  12. package/dist/react-text-annotator.es10.js.map +1 -1
  13. package/dist/react-text-annotator.es11.js +236 -881
  14. package/dist/react-text-annotator.es11.js.map +1 -1
  15. package/dist/react-text-annotator.es12.js +579 -2
  16. package/dist/react-text-annotator.es12.js.map +1 -1
  17. package/dist/react-text-annotator.es13.js +488 -2
  18. package/dist/react-text-annotator.es13.js.map +1 -1
  19. package/dist/react-text-annotator.es14.js +2 -114
  20. package/dist/react-text-annotator.es14.js.map +1 -1
  21. package/dist/react-text-annotator.es15.js +34 -308
  22. package/dist/react-text-annotator.es15.js.map +1 -1
  23. package/dist/react-text-annotator.es16.js +895 -54
  24. package/dist/react-text-annotator.es16.js.map +1 -1
  25. package/dist/react-text-annotator.es17.js +131 -15
  26. package/dist/react-text-annotator.es17.js.map +1 -1
  27. package/dist/react-text-annotator.es18.js +5 -0
  28. package/dist/react-text-annotator.es18.js.map +1 -0
  29. package/dist/react-text-annotator.es19.js +5 -0
  30. package/dist/react-text-annotator.es19.js.map +1 -0
  31. package/dist/react-text-annotator.es2.js +2 -2
  32. package/dist/react-text-annotator.es20.js +117 -0
  33. package/dist/react-text-annotator.es20.js.map +1 -0
  34. package/dist/react-text-annotator.es21.js +312 -0
  35. package/dist/react-text-annotator.es21.js.map +1 -0
  36. package/dist/react-text-annotator.es22.js +61 -0
  37. package/dist/react-text-annotator.es22.js.map +1 -0
  38. package/dist/react-text-annotator.es23.js +23 -0
  39. package/dist/react-text-annotator.es23.js.map +1 -0
  40. package/dist/react-text-annotator.es24.js +124 -0
  41. package/dist/react-text-annotator.es24.js.map +1 -0
  42. package/dist/react-text-annotator.es25.js +555 -0
  43. package/dist/react-text-annotator.es25.js.map +1 -0
  44. package/dist/react-text-annotator.es3.js +2 -2
  45. package/dist/react-text-annotator.es4.js +6 -12
  46. package/dist/react-text-annotator.es4.js.map +1 -1
  47. package/dist/react-text-annotator.es5.js +62 -37
  48. package/dist/react-text-annotator.es5.js.map +1 -1
  49. package/dist/react-text-annotator.es6.js +178 -9
  50. package/dist/react-text-annotator.es6.js.map +1 -1
  51. package/dist/react-text-annotator.es7.js +12 -1
  52. package/dist/react-text-annotator.es7.js.map +1 -1
  53. package/dist/react-text-annotator.es9.js +24 -2
  54. package/dist/react-text-annotator.es9.js.map +1 -1
  55. package/dist/tei/TEIAnnotator.d.ts +2 -2
  56. package/dist/utils.d.ts +14 -0
  57. package/dist/utils.d.ts.map +1 -0
  58. package/package.json +20 -14
  59. package/dist/react-text-annotator.es8.js +0 -491
  60. package/dist/react-text-annotator.es8.js.map +0 -1
@@ -1,11 +1,12 @@
1
- import { j as jsxRuntimeExports } from "./react-text-annotator.es6.js";
1
+ import { j as jsxRuntimeExports } from "./react-text-annotator.es7.js";
2
2
  import { useRef, useContext, useEffect } from "react";
3
3
  import { AnnotoriousContext } from "@annotorious/react";
4
4
  import { createTextAnnotator } from "@soomo/text-annotator";
5
- import "./react-text-annotator.es7.js";
5
+ /* empty css */
6
6
  const TextAnnotator = (props) => {
7
7
  const el = useRef(null);
8
8
  const { className, children, ...opts } = props;
9
+ const { style, filter, user } = opts;
9
10
  const { anno, setAnno } = useContext(AnnotoriousContext);
10
11
  useEffect(() => {
11
12
  if (!setAnno)
@@ -15,16 +16,9 @@ const TextAnnotator = (props) => {
15
16
  setAnno(anno2);
16
17
  return () => anno2.destroy();
17
18
  }, [setAnno]);
18
- useEffect(() => {
19
- if (!anno)
20
- return;
21
- anno.setStyle(props.style);
22
- }, [anno, props.style]);
23
- useEffect(() => {
24
- if (!anno)
25
- return;
26
- anno.setFilter(props.filter);
27
- }, [anno, props.filter]);
19
+ useEffect(() => anno == null ? void 0 : anno.setStyle(style), [anno, style]);
20
+ useEffect(() => anno == null ? void 0 : anno.setFilter(filter), [anno, filter]);
21
+ useEffect(() => anno == null ? void 0 : anno.setUser(user), [anno, user]);
28
22
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref: el, className, children });
29
23
  };
30
24
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"react-text-annotator.es4.js","sources":["../src/TextAnnotator.tsx"],"sourcesContent":["import { ReactNode, useContext, useEffect, useRef } from 'react';\nimport { AnnotoriousContext, Filter } from '@annotorious/react';\nimport type { FormatAdapter } from '@annotorious/core';\nimport type { HighlightStyleExpression, TextAnnotation, TextAnnotatorOptions } from '@soomo/text-annotator';\nimport { createTextAnnotator } from '@soomo/text-annotator';\n\nimport '@soomo/text-annotator/dist/text-annotator.css';\n\n\nexport interface TextAnnotatorProps<E extends unknown> extends Omit<TextAnnotatorOptions<E>, 'adapter'> {\n\n children?: ReactNode | JSX.Element;\n\n adapter?: FormatAdapter<TextAnnotation, E> | ((container: HTMLElement) => FormatAdapter<TextAnnotation, E>) | null;\n\n filter?: Filter;\n\n style?: HighlightStyleExpression;\n\n className?: string;\n\n}\n\nexport const TextAnnotator = <E extends unknown>(props: TextAnnotatorProps<E>) => {\n\n const el = useRef<HTMLDivElement>(null);\n\n const { className, children, ...opts } = props;\n\n const { anno, setAnno } = useContext(AnnotoriousContext);\n\n useEffect(() => {\n if (!setAnno) return;\n\n const adapter = typeof opts.adapter === 'function' ? opts.adapter(el.current) : opts.adapter;\n\n const anno = createTextAnnotator(el.current, { ...opts, adapter });\n setAnno(anno);\n\n return () => anno.destroy();\n }, [setAnno]);\n\n useEffect(() => {\n if (!anno) return;\n\n anno.setStyle(props.style);\n }, [anno, props.style]);\n\n useEffect(() => {\n if (!anno) return;\n \n anno.setFilter(props.filter);\n }, [anno, props.filter]);\n\n return (\n <div ref={el} className={className}>\n {children}\n </div>\n )\n\n}\n"],"names":["anno","jsx"],"mappings":";;;;;AAuBa,MAAA,gBAAgB,CAAoB,UAAiC;AAE1E,QAAA,KAAK,OAAuB,IAAI;AAEtC,QAAM,EAAE,WAAW,UAAU,GAAG,SAAS;AAEzC,QAAM,EAAE,MAAM,QAAQ,IAAI,WAAW,kBAAkB;AAEvD,YAAU,MAAM;AACd,QAAI,CAAC;AAAS;AAER,UAAA,UAAU,OAAO,KAAK,YAAY,aAAa,KAAK,QAAQ,GAAG,OAAO,IAAI,KAAK;AAE/EA,UAAAA,QAAO,oBAAoB,GAAG,SAAS,EAAE,GAAG,MAAM,SAAS;AACjE,YAAQA,KAAI;AAEL,WAAA,MAAMA,MAAK;EAAQ,GACzB,CAAC,OAAO,CAAC;AAEZ,YAAU,MAAM;AACd,QAAI,CAAC;AAAM;AAEN,SAAA,SAAS,MAAM,KAAK;AAAA,EACxB,GAAA,CAAC,MAAM,MAAM,KAAK,CAAC;AAEtB,YAAU,MAAM;AACd,QAAI,CAAC;AAAM;AAEN,SAAA,UAAU,MAAM,MAAM;AAAA,EAC1B,GAAA,CAAC,MAAM,MAAM,MAAM,CAAC;AAEvB,SACGC,kCAAAA,IAAA,OAAA,EAAI,KAAK,IAAI,WACX,SACH,CAAA;AAGJ;"}
1
+ {"version":3,"file":"react-text-annotator.es4.js","sources":["../src/TextAnnotator.tsx"],"sourcesContent":["import { ReactNode, useContext, useEffect, useRef } from 'react';\nimport { AnnotoriousContext, Filter } from '@annotorious/react';\nimport type { FormatAdapter } from '@annotorious/core';\nimport type { HighlightStyleExpression, TextAnnotation, TextAnnotatorOptions } from '@soomo/text-annotator';\nimport { createTextAnnotator } from '@soomo/text-annotator';\n\nimport '@soomo/text-annotator/dist/text-annotator.css';\n\n\nexport interface TextAnnotatorProps<E extends unknown> extends Omit<TextAnnotatorOptions<E>, 'adapter'> {\n\n children?: ReactNode | JSX.Element;\n\n adapter?: FormatAdapter<TextAnnotation, E> | ((container: HTMLElement) => FormatAdapter<TextAnnotation, E>) | null;\n\n filter?: Filter;\n\n style?: HighlightStyleExpression;\n\n className?: string;\n\n}\n\nexport const TextAnnotator = <E extends unknown>(props: TextAnnotatorProps<E>) => {\n\n const el = useRef<HTMLDivElement>(null);\n\n const { className, children, ...opts } = props;\n const { style, filter, user } = opts;\n\n const { anno, setAnno } = useContext(AnnotoriousContext);\n\n useEffect(() => {\n if (!setAnno) return;\n\n const adapter = typeof opts.adapter === 'function' ? opts.adapter(el.current) : opts.adapter;\n\n const anno = createTextAnnotator(el.current, { ...opts, adapter });\n setAnno(anno);\n\n return () => anno.destroy();\n }, [setAnno]);\n\n useEffect(() => anno?.setStyle(style), [anno, style]);\n\n useEffect(() => anno?.setFilter(filter), [anno, filter]);\n\n useEffect(() => anno?.setUser(user), [anno, user]);\n\n return (\n <div ref={el} className={className}>\n {children}\n </div>\n );\n\n};\n"],"names":["anno","jsx"],"mappings":";;;;;AAuBa,MAAA,gBAAgB,CAAoB,UAAiC;AAE1E,QAAA,KAAK,OAAuB,IAAI;AAEtC,QAAM,EAAE,WAAW,UAAU,GAAG,SAAS;AACzC,QAAM,EAAE,OAAO,QAAQ,KAAA,IAAS;AAEhC,QAAM,EAAE,MAAM,QAAQ,IAAI,WAAW,kBAAkB;AAEvD,YAAU,MAAM;AACd,QAAI,CAAC;AAAS;AAER,UAAA,UAAU,OAAO,KAAK,YAAY,aAAa,KAAK,QAAQ,GAAG,OAAO,IAAI,KAAK;AAE/EA,UAAAA,QAAO,oBAAoB,GAAG,SAAS,EAAE,GAAG,MAAM,SAAS;AACjE,YAAQA,KAAI;AAEL,WAAA,MAAMA,MAAK;EAAQ,GACzB,CAAC,OAAO,CAAC;AAEF,YAAA,MAAM,6BAAM,SAAS,QAAQ,CAAC,MAAM,KAAK,CAAC;AAE1C,YAAA,MAAM,6BAAM,UAAU,SAAS,CAAC,MAAM,MAAM,CAAC;AAE7C,YAAA,MAAM,6BAAM,QAAQ,OAAO,CAAC,MAAM,IAAI,CAAC;AAEjD,SACGC,kCAAAA,IAAA,OAAA,EAAI,KAAK,IAAI,WACX,SACH,CAAA;AAGJ;"}
@@ -1,51 +1,76 @@
1
- import { j as jsxRuntimeExports } from "./react-text-annotator.es6.js";
2
- import { createPortal } from "react-dom";
3
- import { useRef, useState, useEffect } from "react";
4
- import { useAnnotator, useSelection } from "@annotorious/react";
1
+ import { j as jsxRuntimeExports } from "./react-text-annotator.es7.js";
2
+ import { useState, useEffect } from "react";
3
+ import { useSelection } from "@annotorious/react";
4
+ import { getClosestRect, toClientRects } from "./react-text-annotator.es9.js";
5
+ import { useFloating } from "./react-text-annotator.es10.js";
6
+ import { autoPlacement, inline, offset, shift } from "./react-text-annotator.es11.js";
7
+ import { autoUpdate } from "./react-text-annotator.es12.js";
5
8
  const TextAnnotatorPopup = (props) => {
6
- const el = useRef(null);
7
- const r = useAnnotator();
8
- const [open, setOpen] = useState(false);
9
9
  const { selected, pointerEvent } = useSelection();
10
+ const [mousePos, setMousePos] = useState();
11
+ const [isOpen, setIsOpen] = useState((selected == null ? void 0 : selected.length) > 0);
12
+ const { refs, floatingStyles, update } = useFloating({
13
+ open: isOpen,
14
+ onOpenChange: setIsOpen,
15
+ middleware: [
16
+ autoPlacement({ crossAxis: true, padding: 5 }),
17
+ inline(),
18
+ offset(5),
19
+ shift({ crossAxis: true, padding: 5 })
20
+ ],
21
+ whileElementsMounted: autoUpdate
22
+ });
10
23
  useEffect(() => {
11
24
  if (pointerEvent) {
12
25
  if (selected.length > 0 && pointerEvent.type === "pointerup") {
13
- setOpen(true);
26
+ setIsOpen(true);
14
27
  } else {
15
- setOpen(false);
28
+ setIsOpen(false);
16
29
  }
17
30
  }
18
31
  }, [pointerEvent, selected.map((a) => a.annotation.id).join("-")]);
19
32
  useEffect(() => {
20
- if (!(pointerEvent && open && (r == null ? void 0 : r.element)))
21
- return;
22
- const { left, top } = r.element.getBoundingClientRect();
23
- let x = pointerEvent.clientX - left;
24
- let y = pointerEvent.clientY - top;
25
- const { id } = selected[0].annotation;
26
- const { offsetX, offsetY } = pointerEvent;
27
- const bounds = r.state.store.getAnnotationBounds(id, offsetX, offsetY);
28
- if (bounds) {
29
- x = Math.max(x, bounds.x - left);
30
- x = Math.min(x, bounds.right - left);
31
- }
32
- el.current.style.left = `${x}px`;
33
- el.current.style.top = `${y}px`;
34
- }, [open, pointerEvent, r == null ? void 0 : r.element]);
35
- const onPointerUp = (evt) => evt.stopPropagation();
36
- return open && selected.length > 0 ? createPortal(
37
- /* @__PURE__ */ jsxRuntimeExports.jsx(
38
- "div",
39
- {
40
- ref: el,
41
- className: "a9s-popup r6o-popup not-annotatable",
42
- style: { position: "absolute" },
43
- onPointerUp,
44
- children: props.popup({ selected })
33
+ if ((selected == null ? void 0 : selected.length) > 0) {
34
+ const selector = selected[0].annotation.target.selector;
35
+ const range = Array.isArray(selector) ? selector[0].range : selector.range;
36
+ if (range && !range.collapsed) {
37
+ refs.setReference({
38
+ getBoundingClientRect: () => {
39
+ return range.getBoundingClientRect();
40
+ },
41
+ getClientRects: () => {
42
+ const rect = mousePos ? getClosestRect(range.getClientRects(), mousePos) : range.getClientRects()[0];
43
+ return toClientRects(rect);
44
+ }
45
+ });
45
46
  }
46
- ),
47
- r.element
48
- ) : null;
47
+ }
48
+ }, [open, selected, mousePos]);
49
+ useEffect(() => {
50
+ const onPointerUp = (event) => {
51
+ const { clientX, clientY } = event;
52
+ setMousePos({ x: clientX, y: clientY });
53
+ };
54
+ const config = { attributes: true, childList: true, subtree: true };
55
+ const mutationObserver = new MutationObserver(() => update());
56
+ mutationObserver.observe(document.body, config);
57
+ window.document.addEventListener("scroll", update, true);
58
+ window.document.addEventListener("pointerup", onPointerUp);
59
+ return () => {
60
+ mutationObserver.disconnect();
61
+ window.document.removeEventListener("scroll", update, true);
62
+ window.document.removeEventListener("pointerup", onPointerUp);
63
+ };
64
+ }, [update]);
65
+ return isOpen && selected.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx(
66
+ "div",
67
+ {
68
+ className: "annotation-popup text-annotation-popup not-annotatable",
69
+ ref: refs.setFloating,
70
+ style: floatingStyles,
71
+ children: props.popup({ selected })
72
+ }
73
+ );
49
74
  };
50
75
  export {
51
76
  TextAnnotatorPopup
@@ -1 +1 @@
1
- {"version":3,"file":"react-text-annotator.es5.js","sources":["../src/TextAnnotatorPopup.tsx"],"sourcesContent":["import { createPortal } from 'react-dom';\nimport { ReactNode, useEffect, useRef, useState } from 'react';\nimport { TextAnnotator, TextAnnotation, TextAnnotatorState } from '@soomo/text-annotator';\nimport { useAnnotator, useSelection } from '@annotorious/react';\n\nexport interface TextAnnotatorPopupProps {\n\n selected: { annotation: TextAnnotation, editable?: boolean }[];\n\n}\n\nexport interface TextAnnotatorPopupContainerProps {\n\n popup(props: TextAnnotatorPopupProps): ReactNode | JSX.Element;\n\n}\n\nexport const TextAnnotatorPopup = (props: TextAnnotatorPopupContainerProps) => {\n\n const el = useRef<HTMLDivElement>(null);\n\n const r = useAnnotator<TextAnnotator>();\n\n const [open, setOpen] = useState(false);\n\n const { selected, pointerEvent } = useSelection<TextAnnotation>();\n\n useEffect(() => {\n // Ignore all selection changes except those\n // accompanied by a pointer event.\n if (pointerEvent) {\n if (selected.length > 0 && pointerEvent.type === 'pointerup') {\n setOpen(true);\n } else {\n setOpen(false);\n }\n }\n }, [pointerEvent, selected.map(a => a.annotation.id).join('-')]);\n\n useEffect(() => {\n if (!(pointerEvent && open && r?.element))\n return;\n\n const { left, top } = r.element.getBoundingClientRect();\n let x = pointerEvent.clientX - left;\n let y = pointerEvent.clientY - top;\n\n const { id } = selected[0].annotation;\n const { offsetX, offsetY } = pointerEvent;\n const bounds = (r.state as TextAnnotatorState).store.getAnnotationBounds(id, offsetX, offsetY);\n \n if (bounds) {\n x = Math.max(x, bounds.x - left);\n x = Math.min(x, bounds.right - left);\n }\n\n el.current.style.left = `${x}px`;\n el.current.style.top = `${y}px`;\n }, [open, pointerEvent, r?.element]);\n\n const onPointerUp = (evt: React.PointerEvent<HTMLDivElement>) =>\n evt.stopPropagation();\n \n return (open && selected.length > 0) ? createPortal(\n <div \n ref={el}\n className=\"a9s-popup r6o-popup not-annotatable\"\n style={{ position: 'absolute' }}\n onPointerUp={onPointerUp}>\n\n {props.popup({ selected })}\n \n </div>, r.element\n ) : null;\n\n}\n"],"names":["jsx"],"mappings":";;;;AAiBa,MAAA,qBAAqB,CAAC,UAA4C;AAEvE,QAAA,KAAK,OAAuB,IAAI;AAEtC,QAAM,IAAI;AAEV,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS,KAAK;AAEtC,QAAM,EAAE,UAAU,aAAa,IAAI,aAA6B;AAEhE,YAAU,MAAM;AAGd,QAAI,cAAc;AAChB,UAAI,SAAS,SAAS,KAAK,aAAa,SAAS,aAAa;AAC5D,gBAAQ,IAAI;AAAA,MAAA,OACP;AACL,gBAAQ,KAAK;AAAA,MACf;AAAA,IACF;AAAA,EACC,GAAA,CAAC,cAAc,SAAS,IAAI,CAAA,MAAK,EAAE,WAAW,EAAE,EAAE,KAAK,GAAG,CAAC,CAAC;AAE/D,YAAU,MAAM;AACV,QAAA,EAAE,gBAAgB,SAAQ,uBAAG;AAC/B;AAEF,UAAM,EAAE,MAAM,IAAA,IAAQ,EAAE,QAAQ;AAC5B,QAAA,IAAI,aAAa,UAAU;AAC3B,QAAA,IAAI,aAAa,UAAU;AAE/B,UAAM,EAAE,GAAO,IAAA,SAAS,CAAC,EAAE;AACrB,UAAA,EAAE,SAAS,QAAY,IAAA;AAC7B,UAAM,SAAU,EAAE,MAA6B,MAAM,oBAAoB,IAAI,SAAS,OAAO;AAE7F,QAAI,QAAQ;AACV,UAAI,KAAK,IAAI,GAAG,OAAO,IAAI,IAAI;AAC/B,UAAI,KAAK,IAAI,GAAG,OAAO,QAAQ,IAAI;AAAA,IACrC;AAEA,OAAG,QAAQ,MAAM,OAAO,GAAG,CAAC;AAC5B,OAAG,QAAQ,MAAM,MAAM,GAAG,CAAC;AAAA,KAC1B,CAAC,MAAM,cAAc,uBAAG,OAAO,CAAC;AAEnC,QAAM,cAAc,CAAC,QACnB,IAAI,gBAAgB;AAEd,SAAA,QAAQ,SAAS,SAAS,IAAK;AAAA,IACrCA,kCAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAK;AAAA,QACL,WAAU;AAAA,QACV,OAAO,EAAE,UAAU,WAAW;AAAA,QAC9B;AAAA,QAEC,UAAM,MAAA,MAAM,EAAE,SAAA,CAAU;AAAA,MAAA;AAAA,IAE3B;AAAA,IAAQ,EAAE;AAAA,EACR,IAAA;AAEN;"}
1
+ {"version":3,"file":"react-text-annotator.es5.js","sources":["../src/TextAnnotatorPopup.tsx"],"sourcesContent":["import { ReactNode, useEffect, useState } from 'react';\nimport { useSelection } from '@annotorious/react';\nimport type { TextAnnotation, TextSelector } from '@soomo/text-annotator';\nimport { getClosestRect, toClientRects } from './utils';\nimport {\n autoPlacement,\n autoUpdate,\n inline,\n offset,\n shift,\n useFloating\n} from '@floating-ui/react';\n\ninterface TextAnnotationPopupProps {\n\n popup(props: TextAnnotatorPopupProps): ReactNode;\n\n}\n\nexport interface TextAnnotatorPopupProps {\n\n selected: { annotation: TextAnnotation, editable?: boolean }[];\n\n}\n\nexport const TextAnnotatorPopup = (props: TextAnnotationPopupProps) => {\n\n const { selected, pointerEvent } = useSelection<TextAnnotation>();\n\n const [mousePos, setMousePos] = useState<{ x: number, y: number } | undefined>();\n\n const [isOpen, setIsOpen] = useState(selected?.length > 0);\n\n const { refs, floatingStyles, update } = useFloating({\n open: isOpen,\n onOpenChange: setIsOpen,\n middleware: [\n autoPlacement({ crossAxis: true, padding: 5 }),\n inline(),\n offset(5),\n shift({ crossAxis: true, padding: 5 })\n ],\n whileElementsMounted: autoUpdate\n });\n\n useEffect(() => {\n // Ignore all selection changes except those\n // accompanied by a pointer event.\n if (pointerEvent) {\n if (selected.length > 0 && pointerEvent.type === 'pointerup') {\n setIsOpen(true);\n } else {\n setIsOpen(false);\n }\n }\n }, [pointerEvent, selected.map(a => a.annotation.id).join('-')]);\n\n useEffect(() => {\n if (selected?.length > 0) {\n const selector = selected[0].annotation.target.selector as (TextSelector | TextSelector[]);\n const range = Array.isArray(selector) ? selector[0].range : selector.range;\n\n if (range && !range.collapsed) {\n refs.setReference({\n getBoundingClientRect: () => {\n return range.getBoundingClientRect();\n },\n getClientRects: () => {\n const rect = mousePos\n ? getClosestRect(range.getClientRects(), mousePos)\n : range.getClientRects()[0];\n\n return toClientRects(rect);\n }\n });\n }\n }\n }, [open, selected, mousePos]);\n\n useEffect(() => {\n const onPointerUp = (event: PointerEvent) => {\n const { clientX, clientY } = event;\n setMousePos({ x: clientX, y: clientY });\n }\n\n const config: MutationObserverInit = { attributes: true, childList: true, subtree: true };\n\n const mutationObserver = new MutationObserver(() =>\n update());\n\n mutationObserver.observe(document.body, config);\n\n window.document.addEventListener('scroll', update, true);\n window.document.addEventListener('pointerup', onPointerUp);\n\n return () => {\n mutationObserver.disconnect();\n window.document.removeEventListener('scroll', update, true);\n window.document.removeEventListener('pointerup', onPointerUp);\n }\n }, [update]);\n\n return (isOpen && selected.length > 0) && (\n <div\n className=\"annotation-popup text-annotation-popup not-annotatable\"\n ref={refs.setFloating}\n style={floatingStyles}>\n {props.popup({ selected })}\n </div>\n )\n\n}\n"],"names":["jsx"],"mappings":";;;;;;;AAyBa,MAAA,qBAAqB,CAAC,UAAoC;AAErE,QAAM,EAAE,UAAU,aAAa,IAAI,aAA6B;AAEhE,QAAM,CAAC,UAAU,WAAW,IAAI,SAA+C;AAE/E,QAAM,CAAC,QAAQ,SAAS,IAAI,UAAS,qCAAU,UAAS,CAAC;AAEzD,QAAM,EAAE,MAAM,gBAAgB,OAAA,IAAW,YAAY;AAAA,IACnD,MAAM;AAAA,IACN,cAAc;AAAA,IACd,YAAY;AAAA,MACV,cAAc,EAAE,WAAW,MAAM,SAAS,GAAG;AAAA,MAC7C,OAAO;AAAA,MACP,OAAO,CAAC;AAAA,MACR,MAAM,EAAE,WAAW,MAAM,SAAS,GAAG;AAAA,IACvC;AAAA,IACA,sBAAsB;AAAA,EAAA,CACvB;AAED,YAAU,MAAM;AAGd,QAAI,cAAc;AAChB,UAAI,SAAS,SAAS,KAAK,aAAa,SAAS,aAAa;AAC5D,kBAAU,IAAI;AAAA,MAAA,OACT;AACL,kBAAU,KAAK;AAAA,MACjB;AAAA,IACF;AAAA,EACC,GAAA,CAAC,cAAc,SAAS,IAAI,CAAA,MAAK,EAAE,WAAW,EAAE,EAAE,KAAK,GAAG,CAAC,CAAC;AAE/D,YAAU,MAAM;AACV,SAAA,qCAAU,UAAS,GAAG;AACxB,YAAM,WAAW,SAAS,CAAC,EAAE,WAAW,OAAO;AACzC,YAAA,QAAQ,MAAM,QAAQ,QAAQ,IAAI,SAAS,CAAC,EAAE,QAAQ,SAAS;AAEjE,UAAA,SAAS,CAAC,MAAM,WAAW;AAC7B,aAAK,aAAa;AAAA,UAChB,uBAAuB,MAAM;AAC3B,mBAAO,MAAM;UACf;AAAA,UACA,gBAAgB,MAAM;AACd,kBAAA,OAAO,WACT,eAAe,MAAM,eAAA,GAAkB,QAAQ,IAC/C,MAAM,eAAe,EAAE,CAAC;AAE5B,mBAAO,cAAc,IAAI;AAAA,UAC3B;AAAA,QAAA,CACD;AAAA,MACH;AAAA,IACF;AAAA,EACC,GAAA,CAAC,MAAM,UAAU,QAAQ,CAAC;AAE7B,YAAU,MAAM;AACR,UAAA,cAAc,CAAC,UAAwB;AACrC,YAAA,EAAE,SAAS,QAAY,IAAA;AAC7B,kBAAY,EAAE,GAAG,SAAS,GAAG,QAAS,CAAA;AAAA,IAAA;AAGxC,UAAM,SAA+B,EAAE,YAAY,MAAM,WAAW,MAAM,SAAS;AAEnF,UAAM,mBAAmB,IAAI,iBAAiB,MAC5C,OAAQ,CAAA;AAEO,qBAAA,QAAQ,SAAS,MAAM,MAAM;AAE9C,WAAO,SAAS,iBAAiB,UAAU,QAAQ,IAAI;AAChD,WAAA,SAAS,iBAAiB,aAAa,WAAW;AAEzD,WAAO,MAAM;AACX,uBAAiB,WAAW;AAC5B,aAAO,SAAS,oBAAoB,UAAU,QAAQ,IAAI;AACnD,aAAA,SAAS,oBAAoB,aAAa,WAAW;AAAA,IAAA;AAAA,EAC9D,GACC,CAAC,MAAM,CAAC;AAEH,SAAA,UAAU,SAAS,SAAS,KAClCA,kCAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAU;AAAA,MACV,KAAK,KAAK;AAAA,MACV,OAAO;AAAA,MACN,UAAM,MAAA,MAAM,EAAE,SAAA,CAAU;AAAA,IAAA;AAAA,EAAA;AAI/B;"}
@@ -1,13 +1,182 @@
1
- import { __module as jsxRuntime } from "./react-text-annotator.es9.js";
2
- import { __require as requireReactJsxRuntime_production_min } from "./react-text-annotator.es10.js";
3
- import { __require as requireReactJsxRuntime_development } from "./react-text-annotator.es11.js";
4
- if (process.env.NODE_ENV === "production") {
5
- jsxRuntime.exports = requireReactJsxRuntime_production_min();
6
- } else {
7
- jsxRuntime.exports = requireReactJsxRuntime_development();
1
+ const _t = "not-annotatable", X = `.${_t}`, pt = (t) => {
2
+ const e = t.cloneContents();
3
+ return e.querySelectorAll(X).forEach((n) => n.remove()), e;
4
+ }, oe = (t, e, n = 10, o) => {
5
+ const i = e, r = document.createRange();
6
+ r.setStart(i, 0), r.setEnd(t.startContainer, t.startOffset);
7
+ const a = pt(r).textContent, s = document.createRange();
8
+ s.setStart(t.endContainer, t.endOffset), i === document.body ? s.setEnd(i, i.childNodes.length) : s.setEndAfter(i);
9
+ const u = pt(s).textContent;
10
+ return {
11
+ prefix: a.substring(a.length - n),
12
+ suffix: u.substring(0, n)
13
+ };
14
+ };
15
+ var V = [];
16
+ for (var lt = 0; lt < 256; ++lt)
17
+ V.push((lt + 256).toString(16).slice(1));
18
+ function Le(t, e = 0) {
19
+ return (V[t[e + 0]] + V[t[e + 1]] + V[t[e + 2]] + V[t[e + 3]] + "-" + V[t[e + 4]] + V[t[e + 5]] + "-" + V[t[e + 6]] + V[t[e + 7]] + "-" + V[t[e + 8]] + V[t[e + 9]] + "-" + V[t[e + 10]] + V[t[e + 11]] + V[t[e + 12]] + V[t[e + 13]] + V[t[e + 14]] + V[t[e + 15]]).toLowerCase();
20
+ }
21
+ var Z, Re = new Uint8Array(16);
22
+ function Be() {
23
+ if (!Z && (Z = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !Z))
24
+ throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
25
+ return Z(Re);
26
+ }
27
+ var Oe = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
28
+ const Ot = {
29
+ randomUUID: Oe
30
+ };
31
+ function $t(t, e, n) {
32
+ if (Ot.randomUUID && !e && !t)
33
+ return Ot.randomUUID();
34
+ t = t || {};
35
+ var o = t.random || (t.rng || Be)();
36
+ return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Le(o);
8
37
  }
9
- var jsxRuntimeExports = jsxRuntime.exports;
38
+ var D = [];
39
+ for (var ht = 0; ht < 256; ++ht)
40
+ D.push((ht + 256).toString(16).slice(1));
41
+ typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
42
+ const nn = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
43
+ let an = (t = 21) => {
44
+ let e = "", n = crypto.getRandomValues(new Uint8Array(t));
45
+ for (; t--; )
46
+ e += nn[n[t] & 63];
47
+ return e;
48
+ };
49
+ const ln = (t) => {
50
+ const e = JSON.stringify(t);
51
+ let n = 0;
52
+ for (let o = 0, i = e.length; o < i; o++) {
53
+ let r = e.charCodeAt(o);
54
+ n = (n << 5) - n + r, n |= 0;
55
+ }
56
+ return `${n}`;
57
+ }, zt = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, dn = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
58
+ const { id: o, type: i, purpose: r, value: a, created: s, modified: u, creator: f, ...m } = n;
59
+ return {
60
+ id: o || `temp-${ln(n)}`,
61
+ annotation: e,
62
+ type: i,
63
+ purpose: r,
64
+ value: a,
65
+ creator: zt(f),
66
+ created: s ? new Date(s) : void 0,
67
+ updated: u ? new Date(u) : void 0,
68
+ ...m
69
+ };
70
+ }), un = (t) => t.map((e) => {
71
+ var n;
72
+ const { annotation: o, created: i, updated: r, ...a } = e, s = {
73
+ ...a,
74
+ created: i == null ? void 0 : i.toISOString(),
75
+ modified: r == null ? void 0 : r.toISOString()
76
+ };
77
+ return (n = s.id) != null && n.startsWith("temp-") && delete s.id, s;
78
+ });
79
+ an();
80
+ const Vn = (t, e) => ({
81
+ parse: (n) => gn(n),
82
+ serialize: (n) => pn(n, t, e)
83
+ }), hn = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, fn = (t) => {
84
+ const {
85
+ id: e,
86
+ creator: n,
87
+ created: o,
88
+ modified: i,
89
+ target: r
90
+ } = t, a = Array.isArray(r) ? r : [r], s = {
91
+ creator: zt(n),
92
+ created: o ? new Date(o) : void 0,
93
+ updated: i ? new Date(i) : void 0,
94
+ annotation: e,
95
+ selector: []
96
+ };
97
+ for (const u of a) {
98
+ const m = (Array.isArray(u.selector) ? u.selector : [u.selector]).reduce((l, p) => {
99
+ switch (p.type) {
100
+ case "TextQuoteSelector":
101
+ l.quote = p.exact;
102
+ break;
103
+ case "TextPositionSelector":
104
+ l.start = p.start, l.end = p.end;
105
+ break;
106
+ }
107
+ return l;
108
+ }, {});
109
+ if (hn(m))
110
+ s.selector.push({ id: u.id, ...m });
111
+ else {
112
+ const l = [
113
+ m.start ? void 0 : "TextPositionSelector",
114
+ m.quote ? void 0 : "TextQuoteSelector"
115
+ ].filter(Boolean);
116
+ return { error: Error(`Missing selector types: ${l.join(" and ")} for annotation: ${t.id}`) };
117
+ }
118
+ }
119
+ return { parsed: s };
120
+ }, gn = (t) => {
121
+ const e = t.id || $t(), {
122
+ creator: n,
123
+ created: o,
124
+ modified: i,
125
+ body: r,
126
+ ...a
127
+ } = t, s = dn(r, e), u = fn(t);
128
+ return "error" in u ? { error: u.error } : {
129
+ parsed: {
130
+ ...a,
131
+ id: e,
132
+ bodies: s,
133
+ target: u.parsed
134
+ }
135
+ };
136
+ }, pn = (t, e, n) => {
137
+ const { bodies: o, target: i, ...r } = t, {
138
+ selector: a,
139
+ creator: s,
140
+ created: u,
141
+ updated: f,
142
+ ...m
143
+ } = i, l = a.map((p) => {
144
+ const { quote: g, start: x, end: v, range: h } = p, { prefix: d, suffix: c } = oe(h, n), y = [{
145
+ type: "TextQuoteSelector",
146
+ exact: g,
147
+ prefix: d,
148
+ suffix: c
149
+ }, {
150
+ type: "TextPositionSelector",
151
+ start: x,
152
+ end: v
153
+ }];
154
+ return {
155
+ ...m,
156
+ id: p.id,
157
+ source: e,
158
+ selector: y
159
+ };
160
+ });
161
+ return {
162
+ ...r,
163
+ "@context": "http://www.w3.org/ns/anno.jsonld",
164
+ id: t.id,
165
+ type: "Annotation",
166
+ body: un(t.bodies),
167
+ creator: s,
168
+ created: u == null ? void 0 : u.toISOString(),
169
+ modified: f == null ? void 0 : f.toISOString(),
170
+ target: l
171
+ };
172
+ };
10
173
  export {
11
- jsxRuntimeExports as j
174
+ _t as NOT_ANNOTATABLE_CLASS,
175
+ X as NOT_ANNOTATABLE_SELECTOR,
176
+ Vn as W3CTextFormat,
177
+ oe as getQuoteContext,
178
+ pt as getRangeAnnotatableContents,
179
+ gn as parseW3CTextAnnotation,
180
+ pn as serializeW3CTextAnnotation
12
181
  };
13
182
  //# sourceMappingURL=react-text-annotator.es6.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"react-text-annotator.es6.js","sources":["../../../node_modules/react/jsx-runtime.js"],"sourcesContent":["'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react-jsx-runtime.production.min.js');\n} else {\n module.exports = require('./cjs/react-jsx-runtime.development.js');\n}\n"],"names":["jsxRuntimeModule","require$$0","require$$1"],"mappings":";;;AAEA,IAAI,QAAQ,IAAI,aAAa,cAAc;AACzCA,aAAA,UAAiBC;AACnB,OAAO;AACLD,aAAA,UAAiBE;AACnB;;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"react-text-annotator.es6.js","sources":["../../../node_modules/@recogito/text-annotator/dist/text-annotator.es.js"],"sourcesContent":["const P = {\n fill: \"rgb(0, 128, 255)\",\n fillOpacity: 0.18\n}, ot = {\n fill: \"rgb(0, 128, 255)\",\n fillOpacity: 0.45\n}, Kt = (t, e, n, o, i) => {\n var a, s;\n const r = n ? typeof n == \"function\" ? n(t.annotation, t.state, i) || ((a = t.state) != null && a.selected ? ot : P) : n : (s = t.state) != null && s.selected ? ot : P;\n return o && o.paint(t, e) || r;\n}, _t = \"not-annotatable\", X = `.${_t}`, Qt = (t) => {\n var n;\n const e = t.commonAncestorContainer;\n return e instanceof HTMLElement ? !e.closest(X) : !((n = e.parentElement) != null && n.closest(X));\n}, Jt = function* (t) {\n const e = document.createNodeIterator(\n t.commonAncestorContainer,\n NodeFilter.SHOW_ELEMENT,\n (o) => o instanceof HTMLElement && o.classList.contains(_t) && !o.parentElement.closest(X) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP\n );\n let n;\n for (; n = e.nextNode(); )\n n instanceof HTMLElement && (yield n);\n}, Zt = (t) => {\n if (!Qt(t))\n return [];\n const e = [];\n let n = null;\n for (const o of Jt(t)) {\n let i;\n n ? (i = document.createRange(), i.setStartAfter(n), i.setEndBefore(o)) : (i = t.cloneRange(), i.setEndBefore(o)), i.collapsed || e.push(i), n = o;\n }\n if (n) {\n const o = t.cloneRange();\n o.setStartAfter(n), o.collapsed || e.push(o);\n }\n return e.length > 0 ? e : [t];\n}, pt = (t) => {\n const e = t.cloneContents();\n return e.querySelectorAll(X).forEach((n) => n.remove()), e;\n}, te = (t) => {\n t.addEventListener(\"click\", (e) => {\n // Allow clicks within not-annotatable elements\n !e.target.closest(X) && !e.target.closest(\"a\") && e.preventDefault();\n });\n}, bt = (t, e = 10) => {\n let n;\n return (...o) => {\n clearTimeout(n), n = setTimeout(() => t.apply(void 0, o), e);\n };\n}, On = (t) => {\n const e = t.cloneContents();\n return e.querySelectorAll(X).forEach((n) => n.remove()), e;\n}, wt = (t, e) => {\n const n = document.createNodeIterator(e);\n let o = 0, i = n.nextNode();\n for (; i !== null; ) {\n if (i === t)\n return o;\n o += 1, i = n.nextNode();\n }\n}, xt = (t, e) => {\n const n = document.createNodeIterator(e);\n let o = null;\n for (let i = 0; i < t + 1; i++)\n o = n.nextNode();\n return o;\n}, ee = (t) => {\n const {\n commonAncestorContainer: e,\n startContainer: n,\n startOffset: o,\n endContainer: i,\n endOffset: r\n } = t, a = Array.from(e.childNodes).map((l) => {\n const p = l.cloneNode(!0);\n return l.nodeName === \"CANVAS\" ? l : p;\n }), s = wt(n, e), u = wt(i, e), f = () => {\n const l = e;\n l.replaceChildren(...a);\n const p = xt(s, l), g = xt(u, l);\n return t.setStart(p, o), t.setEnd(g, r), t;\n }, m = (l) => {\n const p = document.createElement(\"SPAN\");\n return l.surroundContents(p), p;\n };\n if (n === i)\n throw \"Not implemented\";\n {\n const l = document.createRange();\n l.selectNodeContents(n), l.setStart(n, o);\n const p = m(l), g = document.createRange();\n g.selectNode(i), g.setEnd(i, r);\n const x = m(g), h = ne(t).reverse().map((d) => {\n var y;\n const c = document.createElement(\"SPAN\");\n return (y = d.parentNode) == null || y.insertBefore(c, d), c.appendChild(d), c;\n });\n return { unwrap: f, nodes: [p, ...h, x] };\n }\n}, ne = (t) => {\n const {\n commonAncestorContainer: e,\n startContainer: n,\n endContainer: o\n } = t, i = document.createNodeIterator(e, NodeFilter.SHOW_TEXT);\n let r = i.nextNode(), a = !1;\n const s = [];\n for (; r != null; )\n r === o && (a = !1), a && s.push(r), r === n && (a = !0), r = i.nextNode();\n return s;\n}, Mn = (t) => {\n const { startContainer: e, endContainer: n } = t;\n if (e === n)\n return Array.from(t.getClientRects());\n {\n const { unwrap: o, nodes: i } = ee(t), r = i.reduce((a, s) => [...a, ...s.getClientRects()], []);\n return o(), r;\n }\n}, oe = (t, e, n = 10, o) => {\n const i = o ? t.startContainer.parentElement.closest(o) : e, r = document.createRange();\n r.setStart(i, 0), r.setEnd(t.startContainer, t.startOffset);\n const a = pt(r).textContent, s = document.createRange();\n s.setStart(t.endContainer, t.endOffset), i === document.body ? s.setEnd(i, i.childNodes.length) : s.setEndAfter(i);\n const u = pt(s).textContent;\n return {\n prefix: a.substring(a.length - n),\n suffix: u.substring(0, n)\n };\n}, $ = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), ie = (t, e) => {\n const n = (r) => Math.round(r * 10) / 10, o = {\n top: n(t.top),\n bottom: n(t.bottom),\n left: n(t.left),\n right: n(t.right)\n }, i = {\n top: n(e.top),\n bottom: n(e.bottom),\n left: n(e.left),\n right: n(e.right)\n };\n if (Math.abs(o.top - i.top) < 0.5 && Math.abs(o.bottom - i.bottom) < 0.5) {\n if (Math.abs(o.left - i.right) < 0.5 || Math.abs(o.right - i.left) < 0.5)\n return \"inline-adjacent\";\n if (o.left >= i.left && o.right <= i.right)\n return \"inline-is-contained\";\n if (o.left <= i.left && o.right >= i.right)\n return \"inline-contains\";\n } else if (o.top <= i.top && o.bottom >= i.bottom) {\n if (o.left <= i.left && o.right >= i.right)\n return \"block-contains\";\n } else if (o.top >= i.top && o.bottom <= i.bottom && o.left >= i.left && o.right <= i.right)\n return \"block-is-contained\";\n}, re = (t, e) => {\n const n = Math.min(t.left, e.left), o = Math.max(t.right, e.right), i = Math.min(t.top, e.top), r = Math.max(t.bottom, e.bottom);\n return new DOMRect(n, i, o - n, r - i);\n}, se = (t) => t.reduce((e, n) => {\n if (n.width === 0 || n.height === 0)\n return e;\n let o = [...e], i = !1;\n for (const r of e) {\n const a = ie(n, r);\n if (a === \"inline-adjacent\") {\n o = o.map((s) => s === r ? re(n, r) : s), i = !0;\n break;\n } else if (a === \"inline-contains\") {\n o = o.map((s) => s === r ? n : s), i = !0;\n break;\n } else if (a === \"inline-is-contained\") {\n i = !0;\n break;\n } else if (a === \"block-contains\" || a === \"block-is-contained\") {\n n.width < r.width && (o = o.map((s) => s === r ? n : s)), i = !0;\n break;\n }\n }\n return i ? o : [...o, n];\n}, []), ae = (t, e, n) => {\n const o = document.createRange(), i = n ? t.startContainer.parentElement.closest(n) : e;\n o.setStart(i, 0), o.setEnd(t.startContainer, t.startOffset);\n const r = pt(o).textContent, a = t.toString(), s = r.length || 0, u = s + a.length;\n return n ? { quote: a, start: s, end: u, range: t, offsetReference: i } : { quote: a, start: s, end: u, range: t };\n}, Xt = (t, e) => {\n var m, l;\n const { start: n, end: o } = t, i = t.offsetReference || e, r = document.createNodeIterator(\n e,\n NodeFilter.SHOW_TEXT,\n (p) => {\n var g;\n return (g = p.parentElement) != null && g.closest(X) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;\n }\n );\n let a = 0;\n const s = document.createRange();\n let u = r.nextNode();\n u === null && console.error(\"Could not revive annotation target. Content missing.\");\n let f = !i;\n for (; u !== null; ) {\n if (f || (f = i == null ? void 0 : i.contains(u)), f) {\n const p = ((m = u.textContent) == null ? void 0 : m.length) || 0;\n if (a + p > n) {\n s.setStart(u, n - a);\n break;\n }\n a += p;\n }\n u = r.nextNode();\n }\n for (; u !== null; ) {\n const p = ((l = u.textContent) == null ? void 0 : l.length) || 0;\n if (a + p >= o) {\n s.setEnd(u, o - a);\n break;\n }\n a += p, u = r.nextNode();\n }\n return {\n ...t,\n range: s\n };\n}, it = (t, e) => $(t.selector) ? t : {\n ...t,\n selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : Xt(n, e))\n}, rt = (t, e) => $(t.target.selector) ? t : { ...t, target: it(t.target, e) }, ce = (t) => {\n var i;\n const { startContainer: e, endContainer: n } = t;\n if (e.nodeType === Node.TEXT_NODE && n.nodeType === Node.TEXT_NODE)\n return t;\n if (e.nodeType !== Node.TEXT_NODE) {\n const r = e.nextSibling || e.parentNode, a = (r == null ? void 0 : r.nodeType) === Node.TEXT_NODE ? r : Array.from(r.childNodes).filter((s) => s.nodeType === Node.TEXT_NODE).shift();\n t.setEnd(a, 0);\n }\n if (n.nodeType !== Node.TEXT_NODE) {\n const r = n.previousSibling || n.parentNode, a = (r == null ? void 0 : r.nodeType) === Node.TEXT_NODE ? r : Array.from(r.childNodes).filter((s) => s.nodeType === Node.TEXT_NODE).pop();\n t.setEnd(a, ((i = a == null ? void 0 : a.textContent) == null ? void 0 : i.length) || 0);\n }\n return t;\n}, le = (t) => {\n const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, r = -n, a = -e, s = o - n, u = i - e;\n return { top: e, left: n, minX: r, minY: a, maxX: s, maxY: u };\n}, de = (t) => {\n let e = /* @__PURE__ */ new Set();\n return (o) => {\n const i = o.map((r) => r.id);\n (e.size !== i.length || i.some((r) => !e.has(r))) && t.set(i), e = new Set(i);\n };\n}, vt = (t, e, n, o) => {\n const { store: i, selection: r, hover: a } = e;\n let s, u, f;\n const m = de(n), l = (L) => {\n const { x: O, y: b } = t.getBoundingClientRect(), w = i.getAt(L.clientX - O, L.clientY - b);\n w && (!u || u(w)) ? a.current !== w.id && (t.classList.add(\"hovered\"), a.set(w.id)) : a.current && (t.classList.remove(\"hovered\"), a.set(null));\n };\n t.addEventListener(\"pointermove\", l);\n const p = (L = !1) => {\n f && f.clear();\n const O = le(t), { minX: b, minY: w, maxX: A, maxY: S } = O, R = u ? i.getIntersecting(b, w, A, S).filter(({ annotation: k }) => u(k)) : i.getIntersecting(b, w, A, S), M = r.selected.map(({ id: k }) => k), H = R.map(({ annotation: k, rects: qt }) => {\n const jt = M.includes(k.id), Gt = k.id === a.current;\n return { annotation: k, rects: qt, state: { selected: jt, hover: Gt } };\n });\n o.redraw(H, O, s, f, L), setTimeout(() => m(R.map(({ annotation: k }) => k)), 1);\n }, g = (L) => {\n f = L, p();\n }, x = (L) => {\n s = L, p();\n }, v = (L) => {\n u = L, p(!1);\n }, h = () => p();\n i.observe(h);\n const d = r.subscribe(() => p()), c = () => p(!0);\n document.addEventListener(\"scroll\", c, { capture: !0, passive: !0 });\n const y = bt(() => {\n i.recalculatePositions(), f && f.reset(), p();\n });\n window.addEventListener(\"resize\", y);\n const T = new ResizeObserver(y);\n T.observe(t);\n const C = { attributes: !0, childList: !0, subtree: !0 }, E = new MutationObserver((L) => {\n L.every((b) => b.target === t || t.contains(b.target)) || p(!0);\n });\n return E.observe(document.body, C), {\n destroy: () => {\n t.removeEventListener(\"pointermove\", l), o.destroy(), i.unobserve(h), d(), document.removeEventListener(\"scroll\", c), window.removeEventListener(\"resize\", y), T.disconnect(), E.disconnect();\n },\n redraw: p,\n setStyle: x,\n setFilter: v,\n setPainter: g,\n setVisible: o.setVisible\n };\n}, ue = () => {\n const t = document.createElement(\"canvas\");\n return t.width = window.innerWidth, t.height = window.innerHeight, t.className = \"r6o-highlight-layer bg\", t;\n}, he = (t, e) => {\n t.width = window.innerWidth, t.height = window.innerHeight;\n}, fe = (t) => {\n t.classList.add(\"r6o-annotatable\");\n const e = ue(), n = e.getContext(\"2d\");\n t.insertBefore(e, t.firstChild);\n const o = (s, u, f, m) => requestAnimationFrame(() => {\n const { width: l, height: p } = e;\n n.clearRect(-0.5, -0.5, l + 1, p + 1), m && m.clear();\n const { top: g, left: x } = u;\n [...s].sort((h, d) => {\n const { annotation: { target: { created: c } } } = h, { annotation: { target: { created: y } } } = d;\n return c.getTime() - y.getTime();\n }).forEach((h) => {\n var C;\n const d = f ? typeof f == \"function\" ? f(h.annotation, h.state) : f : (C = h.state) != null && C.selected ? ot : P, c = m && m.paint(h, u) || d, y = h.rects.map(({ x: E, y: N, width: L, height: O }) => ({\n x: E + x,\n y: N + g,\n width: L,\n height: O\n }));\n n.fillStyle = c.fill, n.globalAlpha = c.fillOpacity || 1;\n const T = 5;\n if (y.forEach(\n ({ x: E, y: N, width: L, height: O }) => n.fillRect(\n E,\n N - T / 2,\n L,\n O + T\n )\n ), c.underlineColor) {\n n.globalAlpha = 1, n.strokeStyle = c.underlineColor, n.lineWidth = c.underlineThickness ?? 1;\n const E = T / 2 + (c.underlineOffset ?? 0);\n y.forEach(({ x: N, y: L, width: O, height: b }) => {\n n.beginPath(), n.moveTo(N, L + b + E), n.lineTo(N + O, L + b + E), n.stroke();\n });\n }\n });\n }), i = bt(() => {\n he(e);\n });\n return window.addEventListener(\"resize\", i), {\n destroy: () => {\n t.removeChild(e), window.removeEventListener(\"resize\", i);\n },\n setVisible: (s) => {\n console.log(\"setVisible not implemented on Canvas renderer\");\n },\n redraw: o\n };\n}, ge = (t, e, n) => vt(t, e, n, fe(t));\nvar pe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, Y = function(t) {\n return typeof t == \"string\" ? t.length > 0 : typeof t == \"number\";\n}, I = function(t, e, n) {\n return e === void 0 && (e = 0), n === void 0 && (n = Math.pow(10, e)), Math.round(n * t) / n + 0;\n}, U = function(t, e, n) {\n return e === void 0 && (e = 0), n === void 0 && (n = 1), t > n ? n : t > e ? t : e;\n}, kt = function(t) {\n return (t = isFinite(t) ? t % 360 : 0) > 0 ? t : t + 360;\n}, At = function(t) {\n return { r: U(t.r, 0, 255), g: U(t.g, 0, 255), b: U(t.b, 0, 255), a: U(t.a) };\n}, st = function(t) {\n return { r: I(t.r), g: I(t.g), b: I(t.b), a: I(t.a, 3) };\n}, me = /^#([0-9a-f]{3,8})$/i, J = function(t) {\n var e = t.toString(16);\n return e.length < 2 ? \"0\" + e : e;\n}, Yt = function(t) {\n var e = t.r, n = t.g, o = t.b, i = t.a, r = Math.max(e, n, o), a = r - Math.min(e, n, o), s = a ? r === e ? (n - o) / a : r === n ? 2 + (o - e) / a : 4 + (e - n) / a : 0;\n return { h: 60 * (s < 0 ? s + 6 : s), s: r ? a / r * 100 : 0, v: r / 255 * 100, a: i };\n}, Ht = function(t) {\n var e = t.h, n = t.s, o = t.v, i = t.a;\n e = e / 360 * 6, n /= 100, o /= 100;\n var r = Math.floor(e), a = o * (1 - n), s = o * (1 - (e - r) * n), u = o * (1 - (1 - e + r) * n), f = r % 6;\n return { r: 255 * [o, s, a, a, u, o][f], g: 255 * [u, o, o, s, a, a][f], b: 255 * [a, a, u, o, o, s][f], a: i };\n}, Et = function(t) {\n return { h: kt(t.h), s: U(t.s, 0, 100), l: U(t.l, 0, 100), a: U(t.a) };\n}, St = function(t) {\n return { h: I(t.h), s: I(t.s), l: I(t.l), a: I(t.a, 3) };\n}, Ct = function(t) {\n return Ht((n = (e = t).s, { h: e.h, s: (n *= ((o = e.l) < 50 ? o : 100 - o) / 100) > 0 ? 2 * n / (o + n) * 100 : 0, v: o + n, a: e.a }));\n var e, n, o;\n}, Q = function(t) {\n return { h: (e = Yt(t)).h, s: (i = (200 - (n = e.s)) * (o = e.v) / 100) > 0 && i < 200 ? n * o / 100 / (i <= 100 ? i : 200 - i) * 100 : 0, l: i / 2, a: e.a };\n var e, n, o, i;\n}, be = /^hsla?\\(\\s*([+-]?\\d*\\.?\\d+)(deg|rad|grad|turn)?\\s*,\\s*([+-]?\\d*\\.?\\d+)%\\s*,\\s*([+-]?\\d*\\.?\\d+)%\\s*(?:,\\s*([+-]?\\d*\\.?\\d+)(%)?\\s*)?\\)$/i, ve = /^hsla?\\(\\s*([+-]?\\d*\\.?\\d+)(deg|rad|grad|turn)?\\s+([+-]?\\d*\\.?\\d+)%\\s+([+-]?\\d*\\.?\\d+)%\\s*(?:\\/\\s*([+-]?\\d*\\.?\\d+)(%)?\\s*)?\\)$/i, ye = /^rgba?\\(\\s*([+-]?\\d*\\.?\\d+)(%)?\\s*,\\s*([+-]?\\d*\\.?\\d+)(%)?\\s*,\\s*([+-]?\\d*\\.?\\d+)(%)?\\s*(?:,\\s*([+-]?\\d*\\.?\\d+)(%)?\\s*)?\\)$/i, we = /^rgba?\\(\\s*([+-]?\\d*\\.?\\d+)(%)?\\s+([+-]?\\d*\\.?\\d+)(%)?\\s+([+-]?\\d*\\.?\\d+)(%)?\\s*(?:\\/\\s*([+-]?\\d*\\.?\\d+)(%)?\\s*)?\\)$/i, Tt = { string: [[function(t) {\n var e = me.exec(t);\n return e ? (t = e[1]).length <= 4 ? { r: parseInt(t[0] + t[0], 16), g: parseInt(t[1] + t[1], 16), b: parseInt(t[2] + t[2], 16), a: t.length === 4 ? I(parseInt(t[3] + t[3], 16) / 255, 2) : 1 } : t.length === 6 || t.length === 8 ? { r: parseInt(t.substr(0, 2), 16), g: parseInt(t.substr(2, 2), 16), b: parseInt(t.substr(4, 2), 16), a: t.length === 8 ? I(parseInt(t.substr(6, 2), 16) / 255, 2) : 1 } : null : null;\n}, \"hex\"], [function(t) {\n var e = ye.exec(t) || we.exec(t);\n return e ? e[2] !== e[4] || e[4] !== e[6] ? null : At({ r: Number(e[1]) / (e[2] ? 100 / 255 : 1), g: Number(e[3]) / (e[4] ? 100 / 255 : 1), b: Number(e[5]) / (e[6] ? 100 / 255 : 1), a: e[7] === void 0 ? 1 : Number(e[7]) / (e[8] ? 100 : 1) }) : null;\n}, \"rgb\"], [function(t) {\n var e = be.exec(t) || ve.exec(t);\n if (!e)\n return null;\n var n, o, i = Et({ h: (n = e[1], o = e[2], o === void 0 && (o = \"deg\"), Number(n) * (pe[o] || 1)), s: Number(e[3]), l: Number(e[4]), a: e[5] === void 0 ? 1 : Number(e[5]) / (e[6] ? 100 : 1) });\n return Ct(i);\n}, \"hsl\"]], object: [[function(t) {\n var e = t.r, n = t.g, o = t.b, i = t.a, r = i === void 0 ? 1 : i;\n return Y(e) && Y(n) && Y(o) ? At({ r: Number(e), g: Number(n), b: Number(o), a: Number(r) }) : null;\n}, \"rgb\"], [function(t) {\n var e = t.h, n = t.s, o = t.l, i = t.a, r = i === void 0 ? 1 : i;\n if (!Y(e) || !Y(n) || !Y(o))\n return null;\n var a = Et({ h: Number(e), s: Number(n), l: Number(o), a: Number(r) });\n return Ct(a);\n}, \"hsl\"], [function(t) {\n var e = t.h, n = t.s, o = t.v, i = t.a, r = i === void 0 ? 1 : i;\n if (!Y(e) || !Y(n) || !Y(o))\n return null;\n var a = function(s) {\n return { h: kt(s.h), s: U(s.s, 0, 100), v: U(s.v, 0, 100), a: U(s.a) };\n }({ h: Number(e), s: Number(n), v: Number(o), a: Number(r) });\n return Ht(a);\n}, \"hsv\"]] }, Nt = function(t, e) {\n for (var n = 0; n < e.length; n++) {\n var o = e[n][0](t);\n if (o)\n return [o, e[n][1]];\n }\n return [null, void 0];\n}, xe = function(t) {\n return typeof t == \"string\" ? Nt(t.trim(), Tt.string) : typeof t == \"object\" && t !== null ? Nt(t, Tt.object) : [null, void 0];\n}, at = function(t, e) {\n var n = Q(t);\n return { h: n.h, s: U(n.s + 100 * e, 0, 100), l: n.l, a: n.a };\n}, ct = function(t) {\n return (299 * t.r + 587 * t.g + 114 * t.b) / 1e3 / 255;\n}, Lt = function(t, e) {\n var n = Q(t);\n return { h: n.h, s: n.s, l: U(n.l + 100 * e, 0, 100), a: n.a };\n}, Rt = function() {\n function t(e) {\n this.parsed = xe(e)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };\n }\n return t.prototype.isValid = function() {\n return this.parsed !== null;\n }, t.prototype.brightness = function() {\n return I(ct(this.rgba), 2);\n }, t.prototype.isDark = function() {\n return ct(this.rgba) < 0.5;\n }, t.prototype.isLight = function() {\n return ct(this.rgba) >= 0.5;\n }, t.prototype.toHex = function() {\n return e = st(this.rgba), n = e.r, o = e.g, i = e.b, a = (r = e.a) < 1 ? J(I(255 * r)) : \"\", \"#\" + J(n) + J(o) + J(i) + a;\n var e, n, o, i, r, a;\n }, t.prototype.toRgb = function() {\n return st(this.rgba);\n }, t.prototype.toRgbString = function() {\n return e = st(this.rgba), n = e.r, o = e.g, i = e.b, (r = e.a) < 1 ? \"rgba(\" + n + \", \" + o + \", \" + i + \", \" + r + \")\" : \"rgb(\" + n + \", \" + o + \", \" + i + \")\";\n var e, n, o, i, r;\n }, t.prototype.toHsl = function() {\n return St(Q(this.rgba));\n }, t.prototype.toHslString = function() {\n return e = St(Q(this.rgba)), n = e.h, o = e.s, i = e.l, (r = e.a) < 1 ? \"hsla(\" + n + \", \" + o + \"%, \" + i + \"%, \" + r + \")\" : \"hsl(\" + n + \", \" + o + \"%, \" + i + \"%)\";\n var e, n, o, i, r;\n }, t.prototype.toHsv = function() {\n return e = Yt(this.rgba), { h: I(e.h), s: I(e.s), v: I(e.v), a: I(e.a, 3) };\n var e;\n }, t.prototype.invert = function() {\n return _({ r: 255 - (e = this.rgba).r, g: 255 - e.g, b: 255 - e.b, a: e.a });\n var e;\n }, t.prototype.saturate = function(e) {\n return e === void 0 && (e = 0.1), _(at(this.rgba, e));\n }, t.prototype.desaturate = function(e) {\n return e === void 0 && (e = 0.1), _(at(this.rgba, -e));\n }, t.prototype.grayscale = function() {\n return _(at(this.rgba, -1));\n }, t.prototype.lighten = function(e) {\n return e === void 0 && (e = 0.1), _(Lt(this.rgba, e));\n }, t.prototype.darken = function(e) {\n return e === void 0 && (e = 0.1), _(Lt(this.rgba, -e));\n }, t.prototype.rotate = function(e) {\n return e === void 0 && (e = 15), this.hue(this.hue() + e);\n }, t.prototype.alpha = function(e) {\n return typeof e == \"number\" ? _({ r: (n = this.rgba).r, g: n.g, b: n.b, a: e }) : I(this.rgba.a, 3);\n var n;\n }, t.prototype.hue = function(e) {\n var n = Q(this.rgba);\n return typeof e == \"number\" ? _({ h: e, s: n.s, l: n.l, a: n.a }) : I(n.h);\n }, t.prototype.isEqual = function(e) {\n return this.toHex() === _(e).toHex();\n }, t;\n}(), _ = function(t) {\n return t instanceof Rt ? t : new Rt(t);\n};\nconst Ae = (t) => [\n `background-color:${_((t == null ? void 0 : t.fill) || P.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? P.fillOpacity : t.fillOpacity).toHex()}`,\n t != null && t.underlineThickness ? \"text-decoration:underline\" : void 0,\n t != null && t.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,\n t != null && t.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,\n t != null && t.underlineThickness ? `text-decoration-thickness:${t.underlineThickness}px` : void 0\n].filter(Boolean).join(\";\"), Ee = () => {\n const t = document.createElement(\"style\");\n document.getElementsByTagName(\"head\")[0].appendChild(t);\n let e = /* @__PURE__ */ new Set();\n return {\n destroy: () => {\n CSS.highlights.clear(), t.remove();\n },\n setVisible: (r) => {\n console.log(\"setVisible not implemented on CSS Custom Highlights renderer\");\n },\n redraw: (r, a, s, u) => {\n u && u.clear();\n const f = new Set(r.map((l) => l.annotation.id));\n Array.from(e).filter((l) => !f.has(l));\n const m = r.map((l) => {\n var x;\n const p = s ? typeof s == \"function\" ? s(l.annotation, l.state) : s : (x = l.state) != null && x.selected ? ot : P, g = u && u.paint(l, a) || p;\n return `::highlight(_${l.annotation.id}) { ${Ae(g)} }`;\n });\n t.innerHTML = m.join(`\n`), CSS.highlights.clear(), r.forEach(({ annotation: l }) => {\n const p = l.target.selector.map((x) => x.range), g = new Highlight(...p);\n CSS.highlights.set(`_${l.id}`, g);\n }), e = f;\n }\n };\n}, Se = (t, e, n) => vt(t, e, n, Ee());\nvar Bt = Object.prototype.hasOwnProperty;\nfunction mt(t, e) {\n var n, o;\n if (t === e)\n return !0;\n if (t && e && (n = t.constructor) === e.constructor) {\n if (n === Date)\n return t.getTime() === e.getTime();\n if (n === RegExp)\n return t.toString() === e.toString();\n if (n === Array) {\n if ((o = t.length) === e.length)\n for (; o-- && mt(t[o], e[o]); )\n ;\n return o === -1;\n }\n if (!n || typeof t == \"object\") {\n o = 0;\n for (n in t)\n if (Bt.call(t, n) && ++o && !Bt.call(e, n) || !(n in e) || !mt(t[n], e[n]))\n return !1;\n return Object.keys(e).length === o;\n }\n }\n return t !== t && e !== e;\n}\nconst Ce = (t, e) => {\n const n = (o, i) => o.x <= i.x + i.width && o.x + o.width >= i.x && o.y <= i.y + i.height && o.y + o.height >= i.y;\n return e.filter((o) => t !== o && n(t, o) && o.width > t.width).length;\n}, Te = (t) => {\n t.classList.add(\"r6o-annotatable\");\n const e = document.createElement(\"div\");\n e.className = \"r6o-span-highlight-layer\", t.insertBefore(e, t.firstChild);\n let n = [];\n return {\n destroy: () => {\n e.remove();\n },\n redraw: (a, s, u, f, m) => {\n const p = !(mt(n, a) && m);\n if (!f && !p)\n return;\n p && (e.innerHTML = \"\");\n const g = a.reduce((x, { rects: v }) => [...x, ...v], []);\n a.forEach((x) => {\n x.rects.map((v) => {\n const h = Ce(v, g), d = Kt(x, s, u, f, h);\n if (p) {\n const c = document.createElement(\"span\");\n c.className = \"r6o-annotation\", c.dataset.annotation = x.annotation.id, c.style.left = `${v.x}px`, c.style.top = `${v.y}px`, c.style.width = `${v.width}px`, c.style.height = `${v.height}px`;\n const y = _((d == null ? void 0 : d.fill) || P.fill).alpha((d == null ? void 0 : d.fillOpacity) === void 0 ? P.fillOpacity : d.fillOpacity).toHex();\n c.style.backgroundColor = y, d.underlineStyle && (c.style.borderStyle = d.underlineStyle), d.underlineColor && (c.style.borderColor = d.underlineColor), d.underlineThickness && (c.style.borderBottomWidth = `${d.underlineThickness}px`), d.underlineOffset && (c.style.paddingBottom = `${d.underlineOffset}px`), e.appendChild(c);\n }\n });\n }), n = a;\n },\n setVisible: (a) => {\n a ? e.classList.remove(\"hidden\") : e.classList.add(\"hidden\");\n }\n };\n}, Ne = (t, e, n) => vt(t, e, n, Te(t));\nvar V = [];\nfor (var lt = 0; lt < 256; ++lt)\n V.push((lt + 256).toString(16).slice(1));\nfunction Le(t, e = 0) {\n return (V[t[e + 0]] + V[t[e + 1]] + V[t[e + 2]] + V[t[e + 3]] + \"-\" + V[t[e + 4]] + V[t[e + 5]] + \"-\" + V[t[e + 6]] + V[t[e + 7]] + \"-\" + V[t[e + 8]] + V[t[e + 9]] + \"-\" + V[t[e + 10]] + V[t[e + 11]] + V[t[e + 12]] + V[t[e + 13]] + V[t[e + 14]] + V[t[e + 15]]).toLowerCase();\n}\nvar Z, Re = new Uint8Array(16);\nfunction Be() {\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(Re);\n}\nvar Oe = typeof crypto < \"u\" && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nconst Ot = {\n randomUUID: Oe\n};\nfunction $t(t, e, n) {\n if (Ot.randomUUID && !e && !t)\n return Ot.randomUUID();\n t = t || {};\n var o = t.random || (t.rng || Be)();\n return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Le(o);\n}\nvar Mt = Object.prototype.hasOwnProperty;\nfunction q(t, e) {\n var n, o;\n if (t === e)\n return !0;\n if (t && e && (n = t.constructor) === e.constructor) {\n if (n === Date)\n return t.getTime() === e.getTime();\n if (n === RegExp)\n return t.toString() === e.toString();\n if (n === Array) {\n if ((o = t.length) === e.length)\n for (; o-- && q(t[o], e[o]); )\n ;\n return o === -1;\n }\n if (!n || typeof t == \"object\") {\n o = 0;\n for (n in t)\n if (Mt.call(t, n) && ++o && !Mt.call(e, n) || !(n in e) || !q(t[n], e[n]))\n return !1;\n return Object.keys(e).length === o;\n }\n }\n return t !== t && e !== e;\n}\nfunction dt() {\n}\nfunction Me(t, e) {\n return t != t ? e == e : t !== e || t && typeof t == \"object\" || typeof t == \"function\";\n}\nconst z = [];\nfunction yt(t, e = dt) {\n let n;\n const o = /* @__PURE__ */ new Set();\n function i(s) {\n if (Me(t, s) && (t = s, n)) {\n const u = !z.length;\n for (const f of o)\n f[1](), z.push(f, t);\n if (u) {\n for (let f = 0; f < z.length; f += 2)\n z[f][0](z[f + 1]);\n z.length = 0;\n }\n }\n }\n function r(s) {\n i(s(t));\n }\n function a(s, u = dt) {\n const f = [s, u];\n return o.add(f), o.size === 1 && (n = e(i, r) || dt), s(t), () => {\n o.delete(f), o.size === 0 && n && (n(), n = null);\n };\n }\n return { set: i, update: r, subscribe: a };\n}\nconst Ie = (t) => {\n const { subscribe: e, set: n } = yt();\n let o;\n return e((i) => o = i), t.observe(({ changes: i }) => {\n if (o) {\n (i.deleted || []).some((a) => a.id === o) && n(void 0);\n const r = (i.updated || []).find(({ oldValue: a }) => a.id === o);\n r && n(r.newValue.id);\n }\n }), {\n get current() {\n return o;\n },\n subscribe: e,\n set: n\n };\n};\nvar Ve = /* @__PURE__ */ ((t) => (t.EDIT = \"EDIT\", t.SELECT = \"SELECT\", t.NONE = \"NONE\", t))(Ve || {});\nconst ut = { selected: [] }, De = (t, e = \"EDIT\") => {\n const { subscribe: n, set: o } = yt(ut);\n let i = ut;\n n((l) => i = l);\n const r = () => o(ut), a = () => {\n var l;\n return ((l = i.selected) == null ? void 0 : l.length) === 0;\n }, s = (l) => {\n if (i.selected.length === 0)\n return !1;\n const p = typeof l == \"string\" ? l : l.id;\n return i.selected.some((g) => g.id === p);\n }, u = (l, p) => {\n const g = t.getAnnotation(l);\n if (g) {\n const x = It(g, e);\n o(x === \"EDIT\" ? { selected: [{ id: l, editable: !0 }], pointerEvent: p } : x === \"SELECT\" ? { selected: [{ id: l }], pointerEvent: p } : { selected: [], pointerEvent: p });\n } else\n console.warn(\"Invalid selection: \" + l);\n }, f = (l, p) => {\n const g = Array.isArray(l) ? l : [l], x = g.map((v) => t.getAnnotation(v)).filter(Boolean);\n o({\n selected: x.map((v) => {\n const h = p === void 0 ? It(v, e) === \"EDIT\" : p;\n return { id: v.id, editable: h };\n })\n }), x.length !== g.length && console.warn(\"Invalid selection\", l);\n }, m = (l) => {\n if (i.selected.length === 0)\n return !1;\n const { selected: p } = i;\n p.filter(({ id: g }) => l.includes(g)).length > 0 && o({ selected: p.filter(({ id: g }) => !l.includes(g)) });\n };\n return t.observe(({ changes: l }) => m((l.deleted || []).map((p) => p.id))), {\n clear: r,\n clickSelect: u,\n get selected() {\n return i ? [...i.selected] : null;\n },\n get pointerEvent() {\n return i ? i.pointerEvent : null;\n },\n isEmpty: a,\n isSelected: s,\n setSelected: f,\n subscribe: n\n };\n}, It = (t, e) => typeof e == \"function\" ? e(t) || \"EDIT\" : e || \"EDIT\";\nvar D = [];\nfor (var ht = 0; ht < 256; ++ht)\n D.push((ht + 256).toString(16).slice(1));\nfunction Ue(t, e = 0) {\n return (D[t[e + 0]] + D[t[e + 1]] + D[t[e + 2]] + D[t[e + 3]] + \"-\" + D[t[e + 4]] + D[t[e + 5]] + \"-\" + D[t[e + 6]] + D[t[e + 7]] + \"-\" + D[t[e + 8]] + D[t[e + 9]] + \"-\" + D[t[e + 10]] + D[t[e + 11]] + D[t[e + 12]] + D[t[e + 13]] + D[t[e + 14]] + D[t[e + 15]]).toLowerCase();\n}\nvar tt, _e = new Uint8Array(16);\nfunction Xe() {\n if (!tt && (tt = typeof crypto < \"u\" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !tt))\n throw new Error(\"crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported\");\n return tt(_e);\n}\nvar ke = typeof crypto < \"u\" && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nconst Vt = {\n randomUUID: ke\n};\nfunction Ye(t, e, n) {\n if (Vt.randomUUID && !e && !t)\n return Vt.randomUUID();\n t = t || {};\n var o = t.random || (t.rng || Xe)();\n return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Ue(o);\n}\nconst In = (t, e, n, o) => ({\n id: Ye(),\n annotation: t.id,\n created: n || /* @__PURE__ */ new Date(),\n creator: o,\n ...e\n}), He = (t, e) => {\n const n = new Set(t.bodies.map((o) => o.id));\n return e.bodies.filter((o) => !n.has(o.id));\n}, $e = (t, e) => {\n const n = new Set(e.bodies.map((o) => o.id));\n return t.bodies.filter((o) => !n.has(o.id));\n}, Pe = (t, e) => e.bodies.map((n) => {\n const o = t.bodies.find((i) => i.id === n.id);\n return { newBody: n, oldBody: o && !q(o, n) ? o : void 0 };\n}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), ze = (t, e) => !q(t.target, e.target), Pt = (t, e) => {\n const n = He(t, e), o = $e(t, e), i = Pe(t, e);\n return {\n oldValue: t,\n newValue: e,\n bodiesCreated: n.length > 0 ? n : void 0,\n bodiesDeleted: o.length > 0 ? o : void 0,\n bodiesUpdated: i.length > 0 ? i : void 0,\n targetUpdated: ze(t, e) ? { oldTarget: t.target, newTarget: e.target } : void 0\n };\n};\nvar B = /* @__PURE__ */ ((t) => (t.LOCAL = \"LOCAL\", t.REMOTE = \"REMOTE\", t))(B || {});\nconst Fe = (t, e) => {\n var n, o;\n const { changes: i, origin: r } = e;\n if (!(!t.options.origin || t.options.origin === r))\n return !1;\n if (t.options.ignore) {\n const { ignore: a } = t.options, s = (u) => u && u.length > 0;\n if (!(s(i.created) || s(i.deleted))) {\n const u = (n = i.updated) == null ? void 0 : n.some((m) => s(m.bodiesCreated) || s(m.bodiesDeleted) || s(m.bodiesUpdated)), f = (o = i.updated) == null ? void 0 : o.some((m) => m.targetUpdated);\n if (a === \"BODY_ONLY\" && u && !f || a === \"TARGET_ONLY\" && f && !u)\n return !1;\n }\n }\n if (t.options.annotations) {\n const a = /* @__PURE__ */ new Set([\n ...(i.created || []).map((s) => s.id),\n ...(i.deleted || []).map((s) => s.id),\n ...(i.updated || []).map(({ oldValue: s }) => s.id)\n ]);\n return !!(Array.isArray(t.options.annotations) ? t.options.annotations : [t.options.annotations]).find((s) => a.has(s));\n } else\n return !0;\n}, We = (t, e) => {\n const n = new Set((t.created || []).map((l) => l.id)), o = new Set((t.updated || []).map(({ newValue: l }) => l.id)), i = new Set((e.created || []).map((l) => l.id)), r = new Set((e.deleted || []).map((l) => l.id)), a = new Set((e.updated || []).map(({ oldValue: l }) => l.id)), s = new Set((e.updated || []).filter(({ oldValue: l }) => n.has(l.id) || o.has(l.id)).map(({ oldValue: l }) => l.id)), u = [\n ...(t.created || []).filter((l) => !r.has(l.id)).map((l) => a.has(l.id) ? e.updated.find(({ oldValue: p }) => p.id === l.id).newValue : l),\n ...e.created || []\n ], f = [\n ...(t.deleted || []).filter((l) => !i.has(l.id)),\n ...(e.deleted || []).filter((l) => !n.has(l.id))\n ], m = [\n ...(t.updated || []).filter(({ newValue: l }) => !r.has(l.id)).map((l) => {\n const { oldValue: p, newValue: g } = l;\n if (a.has(g.id)) {\n const x = e.updated.find((v) => v.oldValue.id === g.id).newValue;\n return Pt(p, x);\n } else\n return l;\n }),\n ...(e.updated || []).filter(({ oldValue: l }) => !s.has(l.id))\n ];\n return { created: u, deleted: f, updated: m };\n}, qe = (t) => t.id !== void 0, je = () => {\n const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (b, w = {}) => n.push({ onChange: b, options: w }), i = (b) => {\n const w = n.findIndex((A) => A.onChange == b);\n w > -1 && n.splice(w, 1);\n }, r = (b, w) => {\n const A = {\n origin: b,\n changes: {\n created: w.created || [],\n updated: w.updated || [],\n deleted: w.deleted || []\n },\n state: [...t.values()]\n };\n n.forEach((S) => {\n Fe(S, A) && S.onChange(A);\n });\n }, a = (b, w = B.LOCAL) => {\n if (t.get(b.id))\n throw Error(`Cannot add annotation ${b.id} - exists already`);\n t.set(b.id, b), b.bodies.forEach((A) => e.set(A.id, b.id)), r(w, { created: [b] });\n }, s = (b, w) => {\n const A = typeof b == \"string\" ? w : b, S = typeof b == \"string\" ? b : b.id, R = t.get(S);\n if (R) {\n const M = Pt(R, A);\n return S === A.id ? t.set(S, A) : (t.delete(S), t.set(A.id, A)), R.bodies.forEach((H) => e.delete(H.id)), A.bodies.forEach((H) => e.set(H.id, A.id)), M;\n } else\n console.warn(`Cannot update annotation ${S} - does not exist`);\n }, u = (b, w = B.LOCAL, A = B.LOCAL) => {\n const S = qe(w) ? A : w, R = s(b, w);\n R && r(S, { updated: [R] });\n }, f = (b, w = B.LOCAL) => {\n const A = b.reduce((S, R) => {\n const M = s(R);\n return M ? [...S, M] : S;\n }, []);\n A.length > 0 && r(w, { updated: A });\n }, m = (b, w = B.LOCAL) => {\n const A = t.get(b.annotation);\n if (A) {\n const S = {\n ...A,\n bodies: [...A.bodies, b]\n };\n t.set(A.id, S), e.set(b.id, S.id), r(w, { updated: [{\n oldValue: A,\n newValue: S,\n bodiesCreated: [b]\n }] });\n } else\n console.warn(`Attempt to add body to missing annotation: ${b.annotation}`);\n }, l = () => [...t.values()], p = (b = B.LOCAL) => {\n const w = [...t.values()];\n t.clear(), e.clear(), r(b, { deleted: w });\n }, g = (b, w = !0, A = B.LOCAL) => {\n if (w) {\n const S = [...t.values()];\n t.clear(), e.clear(), b.forEach((R) => {\n t.set(R.id, R), R.bodies.forEach((M) => e.set(M.id, R.id));\n }), r(A, { created: b, deleted: S });\n } else {\n const S = b.reduce((R, M) => {\n const H = t.get(M.id);\n return H ? [...R, H] : R;\n }, []);\n if (S.length > 0)\n throw Error(`Bulk insert would overwrite the following annotations: ${S.map((R) => R.id).join(\", \")}`);\n b.forEach((R) => {\n t.set(R.id, R), R.bodies.forEach((M) => e.set(M.id, R.id));\n }), r(A, { created: b });\n }\n }, x = (b) => {\n const w = typeof b == \"string\" ? b : b.id, A = t.get(w);\n if (A)\n return t.delete(w), A.bodies.forEach((S) => e.delete(S.id)), A;\n console.warn(`Attempt to delete missing annotation: ${w}`);\n }, v = (b, w = B.LOCAL) => {\n const A = x(b);\n A && r(w, { deleted: [A] });\n }, h = (b, w = B.LOCAL) => {\n const A = b.reduce((S, R) => {\n const M = x(R);\n return M ? [...S, M] : S;\n }, []);\n A.length > 0 && r(w, { deleted: A });\n }, d = (b) => {\n const w = t.get(b.annotation);\n if (w) {\n const A = w.bodies.find((S) => S.id === b.id);\n if (A) {\n e.delete(A.id);\n const S = {\n ...w,\n bodies: w.bodies.filter((R) => R.id !== b.id)\n };\n return t.set(w.id, S), {\n oldValue: w,\n newValue: S,\n bodiesDeleted: [A]\n };\n } else\n console.warn(`Attempt to delete missing body ${b.id} from annotation ${b.annotation}`);\n } else\n console.warn(`Attempt to delete body from missing annotation ${b.annotation}`);\n }, c = (b, w = B.LOCAL) => {\n const A = d(b);\n A && r(w, { updated: [A] });\n }, y = (b, w = B.LOCAL) => {\n const A = b.map((S) => d(S)).filter(Boolean);\n A.length > 0 && r(w, { updated: A });\n }, T = (b) => {\n const w = t.get(b);\n return w ? { ...w } : void 0;\n }, C = (b) => {\n const w = e.get(b);\n if (w) {\n const A = T(w).bodies.find((S) => S.id === b);\n if (A)\n return A;\n console.error(`Store integrity error: body ${b} in index, but not in annotation`);\n } else\n console.warn(`Attempt to retrieve missing body: ${b}`);\n }, E = (b, w) => {\n if (b.annotation !== w.annotation)\n throw \"Annotation integrity violation: annotation ID must be the same when updating bodies\";\n const A = t.get(b.annotation);\n if (A) {\n const S = A.bodies.find((M) => M.id === b.id), R = {\n ...A,\n bodies: A.bodies.map((M) => M.id === S.id ? w : M)\n };\n return t.set(A.id, R), S.id !== w.id && (e.delete(S.id), e.set(w.id, R.id)), {\n oldValue: A,\n newValue: R,\n bodiesUpdated: [{ oldBody: S, newBody: w }]\n };\n } else\n console.warn(`Attempt to add body to missing annotation ${b.annotation}`);\n }, N = (b, w, A = B.LOCAL) => {\n const S = E(b, w);\n S && r(A, { updated: [S] });\n }, L = (b, w = B.LOCAL) => {\n const A = b.map((S) => E({ id: S.id, annotation: S.annotation }, S)).filter(Boolean);\n r(w, { updated: A });\n }, O = (b) => {\n const w = t.get(b.annotation);\n if (w) {\n const A = {\n ...w,\n target: {\n ...w.target,\n ...b\n }\n };\n return t.set(w.id, A), {\n oldValue: w,\n newValue: A,\n targetUpdated: {\n oldTarget: w.target,\n newTarget: b\n }\n };\n } else\n console.warn(`Attempt to update target on missing annotation: ${b.annotation}`);\n };\n return {\n addAnnotation: a,\n addBody: m,\n all: l,\n bulkAddAnnotation: g,\n bulkDeleteAnnotation: h,\n bulkDeleteBodies: y,\n bulkUpdateAnnotation: f,\n bulkUpdateBodies: L,\n bulkUpdateTargets: (b, w = B.LOCAL) => {\n const A = b.map((S) => O(S)).filter(Boolean);\n A.length > 0 && r(w, { updated: A });\n },\n clear: p,\n deleteAnnotation: v,\n deleteBody: c,\n getAnnotation: T,\n getBody: C,\n observe: o,\n unobserve: i,\n updateAnnotation: u,\n updateBody: N,\n updateTarget: (b, w = B.LOCAL) => {\n const A = O(b);\n A && r(w, { updated: [A] });\n }\n };\n};\nlet Ge = () => ({\n emit(t, ...e) {\n for (let n = 0, o = this.events[t] || [], i = o.length; n < i; n++)\n o[n](...e);\n },\n events: {},\n on(t, e) {\n var n;\n return ((n = this.events)[t] || (n[t] = [])).push(e), () => {\n var o;\n this.events[t] = (o = this.events[t]) == null ? void 0 : o.filter((i) => e !== i);\n };\n }\n});\nconst Ke = 250, Qe = (t) => {\n const e = Ge(), n = [];\n let o = -1, i = !1, r = 0;\n const a = (g) => {\n if (!i) {\n const { changes: x } = g, v = performance.now();\n if (v - r > Ke)\n n.splice(o + 1), n.push(x), o = n.length - 1;\n else {\n const h = n.length - 1;\n n[h] = We(n[h], x);\n }\n r = v;\n }\n i = !1;\n };\n t.observe(a, { origin: B.LOCAL });\n const s = (g) => g && g.length > 0 && t.bulkDeleteAnnotation(g), u = (g) => g && g.length > 0 && t.bulkAddAnnotation(g, !1), f = (g) => g && g.length > 0 && t.bulkUpdateAnnotation(g.map(({ oldValue: x }) => x)), m = (g) => g && g.length > 0 && t.bulkUpdateAnnotation(g.map(({ newValue: x }) => x)), l = (g) => g && g.length > 0 && t.bulkAddAnnotation(g, !1), p = (g) => g && g.length > 0 && t.bulkDeleteAnnotation(g);\n return {\n canRedo: () => n.length - 1 > o,\n canUndo: () => o > -1,\n destroy: () => t.unobserve(a),\n on: (g, x) => e.on(g, x),\n redo: () => {\n if (n.length - 1 > o) {\n i = !0;\n const { created: g, updated: x, deleted: v } = n[o + 1];\n u(g), m(x), p(v), e.emit(\"redo\", n[o + 1]), o += 1;\n }\n },\n undo: () => {\n if (o > -1) {\n i = !0;\n const { created: g, updated: x, deleted: v } = n[o];\n s(g), f(x), l(v), e.emit(\"undo\", n[o]), o -= 1;\n }\n }\n };\n}, Je = () => {\n const { subscribe: t, set: e } = yt([]);\n return {\n subscribe: t,\n set: e\n };\n}, Ze = (t, e, n, o) => {\n const { store: i, selection: r, hover: a, viewport: s } = t, u = /* @__PURE__ */ new Map();\n let f = [], m;\n const l = (v, h) => {\n u.has(v) ? u.get(v).push(h) : u.set(v, [h]);\n }, p = (v, h) => {\n const d = u.get(v);\n d && d.indexOf(h) > 0 && d.splice(d.indexOf(h), 1);\n }, g = (v, h, d) => {\n u.has(v) && setTimeout(() => {\n u.get(v).forEach((c) => {\n if (n) {\n const y = Array.isArray(h) ? h.map((C) => n.serialize(C)) : n.serialize(h), T = d ? d instanceof PointerEvent ? d : n.serialize(d) : void 0;\n c(y, T);\n } else\n c(h, d);\n });\n }, 1);\n };\n r.subscribe(({ selected: v }) => {\n if (!(f.length === 0 && v.length === 0)) {\n if (f.length === 0 && v.length > 0)\n f = v.map(({ id: h }) => i.getAnnotation(h));\n else if (f.length > 0 && v.length === 0)\n f.forEach((h) => {\n const d = i.getAnnotation(h.id);\n d && !q(d, h) && g(\"updateAnnotation\", d, h);\n }), f = [];\n else {\n const h = new Set(f.map((c) => c.id)), d = new Set(v.map(({ id: c }) => c));\n f.filter((c) => !d.has(c.id)).forEach((c) => {\n const y = i.getAnnotation(c.id);\n y && !q(y, c) && g(\"updateAnnotation\", y, c);\n }), f = [\n // Remove annotations that were deselected\n ...f.filter((c) => d.has(c.id)),\n // Add editable annotations that were selected\n ...v.filter(({ id: c }) => !h.has(c)).map(({ id: c }) => i.getAnnotation(c))\n ];\n }\n g(\"selectionChanged\", f);\n }\n }), a.subscribe((v) => {\n !m && v ? g(\"mouseEnterAnnotation\", i.getAnnotation(v)) : m && !v ? g(\"mouseLeaveAnnotation\", i.getAnnotation(m)) : m && v && (g(\"mouseLeaveAnnotation\", i.getAnnotation(m)), g(\"mouseEnterAnnotation\", i.getAnnotation(v))), m = v;\n }), s == null || s.subscribe((v) => g(\"viewportIntersect\", v.map((h) => i.getAnnotation(h)))), i.observe((v) => {\n const { created: h, deleted: d } = v.changes;\n (h || []).forEach((c) => g(\"createAnnotation\", c)), (d || []).forEach((c) => g(\"deleteAnnotation\", c)), (v.changes.updated || []).filter((c) => [\n ...c.bodiesCreated || [],\n ...c.bodiesDeleted || [],\n ...c.bodiesUpdated || []\n ].length > 0).forEach(({ oldValue: c, newValue: y }) => {\n const T = f.find((C) => C.id === c.id) || c;\n f = f.map((C) => C.id === c.id ? y : C), g(\"updateAnnotation\", y, T);\n });\n }, { origin: B.LOCAL }), i.observe((v) => {\n if (f) {\n const h = new Set(f.map((c) => c.id)), d = (v.changes.updated || []).filter(({ newValue: c }) => h.has(c.id)).map(({ newValue: c }) => c);\n d.length > 0 && (f = f.map((c) => d.find((T) => T.id === c.id) || c));\n }\n }, { origin: B.REMOTE });\n const x = (v) => (h) => {\n const { updated: d } = h;\n v ? (d || []).forEach((c) => g(\"updateAnnotation\", c.oldValue, c.newValue)) : (d || []).forEach((c) => g(\"updateAnnotation\", c.newValue, c.oldValue));\n };\n return e.on(\"undo\", x(!0)), e.on(\"redo\", x(!1)), { on: l, off: p, emit: g };\n}, tn = (t) => (e) => e.reduce((n, o) => {\n const { parsed: i, error: r } = t.parse(o);\n return r ? {\n parsed: n.parsed,\n failed: [...n.failed, o]\n } : i ? {\n parsed: [...n.parsed, i],\n failed: n.failed\n } : {\n ...n\n };\n}, { parsed: [], failed: [] }), en = (t, e, n) => {\n const { store: o, selection: i } = t, r = (h) => {\n if (n) {\n const { parsed: d, error: c } = n.parse(h);\n d ? o.addAnnotation(d, B.REMOTE) : console.error(c);\n } else\n o.addAnnotation(h, B.REMOTE);\n }, a = () => i.clear(), s = () => o.clear(), u = (h) => {\n const d = o.getAnnotation(h);\n return n && d ? n.serialize(d) : d;\n }, f = () => n ? o.all().map(n.serialize) : o.all(), m = () => {\n var h;\n const d = (((h = i.selected) == null ? void 0 : h.map((c) => c.id)) || []).map((c) => o.getAnnotation(c)).filter(Boolean);\n return n ? d.map(n.serialize) : d;\n }, l = (h, d = !0) => fetch(h).then((c) => c.json()).then((c) => (g(c, d), c)), p = (h) => {\n if (typeof h == \"string\") {\n const d = o.getAnnotation(h);\n if (o.deleteAnnotation(h), d)\n return n ? n.serialize(d) : d;\n } else {\n const d = n ? n.parse(h).parsed : h;\n if (d)\n return o.deleteAnnotation(d), h;\n }\n }, g = (h, d = !0) => {\n if (n) {\n const { parsed: c, failed: y } = tn(n)(h);\n y.length > 0 && console.warn(`Discarded ${y.length} invalid annotations`, y), o.bulkAddAnnotation(c, d, B.REMOTE);\n } else\n o.bulkAddAnnotation(h, d, B.REMOTE);\n }, x = (h, d) => {\n h ? i.setSelected(h, d) : i.clear();\n }, v = (h) => {\n if (n) {\n const d = n.parse(h).parsed, c = n.serialize(o.getAnnotation(d.id));\n return o.updateAnnotation(d), c;\n } else {\n const d = o.getAnnotation(h.id);\n return o.updateAnnotation(h), d;\n }\n };\n return {\n addAnnotation: r,\n cancelSelected: a,\n canRedo: e.canRedo,\n canUndo: e.canUndo,\n clearAnnotations: s,\n getAnnotationById: u,\n getAnnotations: f,\n getSelected: m,\n loadAnnotations: l,\n redo: e.redo,\n removeAnnotation: p,\n setAnnotations: g,\n setSelected: x,\n undo: e.undo,\n updateAnnotation: v\n };\n}, nn = \"useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict\";\nlet on = (t) => crypto.getRandomValues(new Uint8Array(t)), rn = (t, e, n) => {\n let o = (2 << Math.log(t.length - 1) / Math.LN2) - 1, i = -~(1.6 * o * e / t.length);\n return (r = e) => {\n let a = \"\";\n for (; ; ) {\n let s = n(i), u = i;\n for (; u--; )\n if (a += t[s[u] & o] || \"\", a.length === r)\n return a;\n }\n };\n}, sn = (t, e = 21) => rn(t, e, on), an = (t = 21) => {\n let e = \"\", n = crypto.getRandomValues(new Uint8Array(t));\n for (; t--; )\n e += nn[n[t] & 63];\n return e;\n};\nconst cn = () => ({ isGuest: !0, id: sn(\"1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_\", 20)() }), ln = (t) => {\n const e = JSON.stringify(t);\n let n = 0;\n for (let o = 0, i = e.length; o < i; o++) {\n let r = e.charCodeAt(o);\n n = (n << 5) - n + r, n |= 0;\n }\n return `${n}`;\n}, zt = (t) => t ? typeof t == \"object\" ? { ...t } : t : void 0, dn = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {\n const { id: o, type: i, purpose: r, value: a, created: s, modified: u, creator: f, ...m } = n;\n return {\n id: o || `temp-${ln(n)}`,\n annotation: e,\n type: i,\n purpose: r,\n value: a,\n creator: zt(f),\n created: s ? new Date(s) : void 0,\n updated: u ? new Date(u) : void 0,\n ...m\n };\n}), un = (t) => t.map((e) => {\n var n;\n const { annotation: o, created: i, updated: r, ...a } = e, s = {\n ...a,\n created: i == null ? void 0 : i.toISOString(),\n modified: r == null ? void 0 : r.toISOString()\n };\n return (n = s.id) != null && n.startsWith(\"temp-\") && delete s.id, s;\n});\nan();\nconst Vn = (t, e) => ({\n parse: (n) => gn(n),\n serialize: (n) => pn(n, t, e)\n}), hn = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, fn = (t) => {\n const {\n id: e,\n creator: n,\n created: o,\n modified: i,\n target: r\n } = t, a = Array.isArray(r) ? r : [r], s = {\n creator: zt(n),\n created: o ? new Date(o) : void 0,\n updated: i ? new Date(i) : void 0,\n annotation: e,\n selector: []\n };\n for (const u of a) {\n const m = (Array.isArray(u.selector) ? u.selector : [u.selector]).reduce((l, p) => {\n switch (p.type) {\n case \"TextQuoteSelector\":\n l.quote = p.exact;\n break;\n case \"TextPositionSelector\":\n l.start = p.start, l.end = p.end;\n break;\n }\n return l;\n }, {});\n if (hn(m))\n s.selector.push({ id: u.id, ...m });\n else {\n const l = [\n m.start ? void 0 : \"TextPositionSelector\",\n m.quote ? void 0 : \"TextQuoteSelector\"\n ].filter(Boolean);\n return { error: Error(`Missing selector types: ${l.join(\" and \")} for annotation: ${t.id}`) };\n }\n }\n return { parsed: s };\n}, gn = (t) => {\n const e = t.id || $t(), {\n creator: n,\n created: o,\n modified: i,\n body: r,\n ...a\n } = t, s = dn(r, e), u = fn(t);\n return \"error\" in u ? { error: u.error } : {\n parsed: {\n ...a,\n id: e,\n bodies: s,\n target: u.parsed\n }\n };\n}, pn = (t, e, n) => {\n const { bodies: o, target: i, ...r } = t, {\n selector: a,\n creator: s,\n created: u,\n updated: f,\n ...m\n } = i, l = a.map((p) => {\n const { quote: g, start: x, end: v, range: h } = p, { prefix: d, suffix: c } = oe(h, n), y = [{\n type: \"TextQuoteSelector\",\n exact: g,\n prefix: d,\n suffix: c\n }, {\n type: \"TextPositionSelector\",\n start: x,\n end: v\n }];\n return {\n ...m,\n id: p.id,\n source: e,\n selector: y\n };\n });\n return {\n ...r,\n \"@context\": \"http://www.w3.org/ns/anno.jsonld\",\n id: t.id,\n type: \"Annotation\",\n body: un(t.bodies),\n creator: s,\n created: u == null ? void 0 : u.toISOString(),\n modified: f == null ? void 0 : f.toISOString(),\n target: l\n };\n};\nfunction mn(t, e, n, o, i) {\n Ft(t, e, n || 0, o || t.length - 1, i || bn);\n}\nfunction Ft(t, e, n, o, i) {\n for (; o > n; ) {\n if (o - n > 600) {\n var r = o - n + 1, a = e - n + 1, s = Math.log(r), u = 0.5 * Math.exp(2 * s / 3), f = 0.5 * Math.sqrt(s * u * (r - u) / r) * (a - r / 2 < 0 ? -1 : 1), m = Math.max(n, Math.floor(e - a * u / r + f)), l = Math.min(o, Math.floor(e + (r - a) * u / r + f));\n Ft(t, e, m, l, i);\n }\n var p = t[e], g = n, x = o;\n for (j(t, n, e), i(t[o], p) > 0 && j(t, n, o); g < x; ) {\n for (j(t, g, x), g++, x--; i(t[g], p) < 0; )\n g++;\n for (; i(t[x], p) > 0; )\n x--;\n }\n i(t[n], p) === 0 ? j(t, n, x) : (x++, j(t, x, o)), x <= e && (n = x + 1), e <= x && (o = x - 1);\n }\n}\nfunction j(t, e, n) {\n var o = t[e];\n t[e] = t[n], t[n] = o;\n}\nfunction bn(t, e) {\n return t < e ? -1 : t > e ? 1 : 0;\n}\nclass vn {\n constructor(e = 9) {\n this._maxEntries = Math.max(4, e), this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4)), this.clear();\n }\n all() {\n return this._all(this.data, []);\n }\n search(e) {\n let n = this.data;\n const o = [];\n if (!nt(e, n))\n return o;\n const i = this.toBBox, r = [];\n for (; n; ) {\n for (let a = 0; a < n.children.length; a++) {\n const s = n.children[a], u = n.leaf ? i(s) : s;\n nt(e, u) && (n.leaf ? o.push(s) : gt(e, u) ? this._all(s, o) : r.push(s));\n }\n n = r.pop();\n }\n return o;\n }\n collides(e) {\n let n = this.data;\n if (!nt(e, n))\n return !1;\n const o = [];\n for (; n; ) {\n for (let i = 0; i < n.children.length; i++) {\n const r = n.children[i], a = n.leaf ? this.toBBox(r) : r;\n if (nt(e, a)) {\n if (n.leaf || gt(e, a))\n return !0;\n o.push(r);\n }\n }\n n = o.pop();\n }\n return !1;\n }\n load(e) {\n if (!(e && e.length))\n return this;\n if (e.length < this._minEntries) {\n for (let o = 0; o < e.length; o++)\n this.insert(e[o]);\n return this;\n }\n let n = this._build(e.slice(), 0, e.length - 1, 0);\n if (!this.data.children.length)\n this.data = n;\n else if (this.data.height === n.height)\n this._splitRoot(this.data, n);\n else {\n if (this.data.height < n.height) {\n const o = this.data;\n this.data = n, n = o;\n }\n this._insert(n, this.data.height - n.height - 1, !0);\n }\n return this;\n }\n insert(e) {\n return e && this._insert(e, this.data.height - 1), this;\n }\n clear() {\n return this.data = W([]), this;\n }\n remove(e, n) {\n if (!e)\n return this;\n let o = this.data;\n const i = this.toBBox(e), r = [], a = [];\n let s, u, f;\n for (; o || r.length; ) {\n if (o || (o = r.pop(), u = r[r.length - 1], s = a.pop(), f = !0), o.leaf) {\n const m = yn(e, o.children, n);\n if (m !== -1)\n return o.children.splice(m, 1), r.push(o), this._condense(r), this;\n }\n !f && !o.leaf && gt(o, i) ? (r.push(o), a.push(s), s = 0, u = o, o = o.children[0]) : u ? (s++, o = u.children[s], f = !1) : o = null;\n }\n return this;\n }\n toBBox(e) {\n return e;\n }\n compareMinX(e, n) {\n return e.minX - n.minX;\n }\n compareMinY(e, n) {\n return e.minY - n.minY;\n }\n toJSON() {\n return this.data;\n }\n fromJSON(e) {\n return this.data = e, this;\n }\n _all(e, n) {\n const o = [];\n for (; e; )\n e.leaf ? n.push(...e.children) : o.push(...e.children), e = o.pop();\n return n;\n }\n _build(e, n, o, i) {\n const r = o - n + 1;\n let a = this._maxEntries, s;\n if (r <= a)\n return s = W(e.slice(n, o + 1)), F(s, this.toBBox), s;\n i || (i = Math.ceil(Math.log(r) / Math.log(a)), a = Math.ceil(r / Math.pow(a, i - 1))), s = W([]), s.leaf = !1, s.height = i;\n const u = Math.ceil(r / a), f = u * Math.ceil(Math.sqrt(a));\n Dt(e, n, o, f, this.compareMinX);\n for (let m = n; m <= o; m += f) {\n const l = Math.min(m + f - 1, o);\n Dt(e, m, l, u, this.compareMinY);\n for (let p = m; p <= l; p += u) {\n const g = Math.min(p + u - 1, l);\n s.children.push(this._build(e, p, g, i - 1));\n }\n }\n return F(s, this.toBBox), s;\n }\n _chooseSubtree(e, n, o, i) {\n for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {\n let r = 1 / 0, a = 1 / 0, s;\n for (let u = 0; u < n.children.length; u++) {\n const f = n.children[u], m = ft(f), l = An(e, f) - m;\n l < a ? (a = l, r = m < r ? m : r, s = f) : l === a && m < r && (r = m, s = f);\n }\n n = s || n.children[0];\n }\n return n;\n }\n _insert(e, n, o) {\n const i = o ? e : this.toBBox(e), r = [], a = this._chooseSubtree(i, this.data, n, r);\n for (a.children.push(e), K(a, i); n >= 0 && r[n].children.length > this._maxEntries; )\n this._split(r, n), n--;\n this._adjustParentBBoxes(i, r, n);\n }\n // split overflowed node into two\n _split(e, n) {\n const o = e[n], i = o.children.length, r = this._minEntries;\n this._chooseSplitAxis(o, r, i);\n const a = this._chooseSplitIndex(o, r, i), s = W(o.children.splice(a, o.children.length - a));\n s.height = o.height, s.leaf = o.leaf, F(o, this.toBBox), F(s, this.toBBox), n ? e[n - 1].children.push(s) : this._splitRoot(o, s);\n }\n _splitRoot(e, n) {\n this.data = W([e, n]), this.data.height = e.height + 1, this.data.leaf = !1, F(this.data, this.toBBox);\n }\n _chooseSplitIndex(e, n, o) {\n let i, r = 1 / 0, a = 1 / 0;\n for (let s = n; s <= o - n; s++) {\n const u = G(e, 0, s, this.toBBox), f = G(e, s, o, this.toBBox), m = En(u, f), l = ft(u) + ft(f);\n m < r ? (r = m, i = s, a = l < a ? l : a) : m === r && l < a && (a = l, i = s);\n }\n return i || o - n;\n }\n // sorts node children by the best axis for split\n _chooseSplitAxis(e, n, o) {\n const i = e.leaf ? this.compareMinX : wn, r = e.leaf ? this.compareMinY : xn, a = this._allDistMargin(e, n, o, i), s = this._allDistMargin(e, n, o, r);\n a < s && e.children.sort(i);\n }\n // total margin of all possible split distributions where each node is at least m full\n _allDistMargin(e, n, o, i) {\n e.children.sort(i);\n const r = this.toBBox, a = G(e, 0, n, r), s = G(e, o - n, o, r);\n let u = et(a) + et(s);\n for (let f = n; f < o - n; f++) {\n const m = e.children[f];\n K(a, e.leaf ? r(m) : m), u += et(a);\n }\n for (let f = o - n - 1; f >= n; f--) {\n const m = e.children[f];\n K(s, e.leaf ? r(m) : m), u += et(s);\n }\n return u;\n }\n _adjustParentBBoxes(e, n, o) {\n for (let i = o; i >= 0; i--)\n K(n[i], e);\n }\n _condense(e) {\n for (let n = e.length - 1, o; n >= 0; n--)\n e[n].children.length === 0 ? n > 0 ? (o = e[n - 1].children, o.splice(o.indexOf(e[n]), 1)) : this.clear() : F(e[n], this.toBBox);\n }\n}\nfunction yn(t, e, n) {\n if (!n)\n return e.indexOf(t);\n for (let o = 0; o < e.length; o++)\n if (n(t, e[o]))\n return o;\n return -1;\n}\nfunction F(t, e) {\n G(t, 0, t.children.length, e, t);\n}\nfunction G(t, e, n, o, i) {\n i || (i = W(null)), i.minX = 1 / 0, i.minY = 1 / 0, i.maxX = -1 / 0, i.maxY = -1 / 0;\n for (let r = e; r < n; r++) {\n const a = t.children[r];\n K(i, t.leaf ? o(a) : a);\n }\n return i;\n}\nfunction K(t, e) {\n return t.minX = Math.min(t.minX, e.minX), t.minY = Math.min(t.minY, e.minY), t.maxX = Math.max(t.maxX, e.maxX), t.maxY = Math.max(t.maxY, e.maxY), t;\n}\nfunction wn(t, e) {\n return t.minX - e.minX;\n}\nfunction xn(t, e) {\n return t.minY - e.minY;\n}\nfunction ft(t) {\n return (t.maxX - t.minX) * (t.maxY - t.minY);\n}\nfunction et(t) {\n return t.maxX - t.minX + (t.maxY - t.minY);\n}\nfunction An(t, e) {\n return (Math.max(e.maxX, t.maxX) - Math.min(e.minX, t.minX)) * (Math.max(e.maxY, t.maxY) - Math.min(e.minY, t.minY));\n}\nfunction En(t, e) {\n const n = Math.max(t.minX, e.minX), o = Math.max(t.minY, e.minY), i = Math.min(t.maxX, e.maxX), r = Math.min(t.maxY, e.maxY);\n return Math.max(0, i - n) * Math.max(0, r - o);\n}\nfunction gt(t, e) {\n return t.minX <= e.minX && t.minY <= e.minY && e.maxX <= t.maxX && e.maxY <= t.maxY;\n}\nfunction nt(t, e) {\n return e.minX <= t.maxX && e.minY <= t.maxY && e.maxX >= t.minX && e.maxY >= t.minY;\n}\nfunction W(t) {\n return {\n children: t,\n height: 1,\n leaf: !0,\n minX: 1 / 0,\n minY: 1 / 0,\n maxX: -1 / 0,\n maxY: -1 / 0\n };\n}\nfunction Dt(t, e, n, o, i) {\n const r = [e, n];\n for (; r.length; ) {\n if (n = r.pop(), e = r.pop(), n - e <= o)\n continue;\n const a = e + Math.ceil((n - e) / o / 2) * o;\n mn(t, a, e, n, i), r.push(e, a, a, n);\n }\n}\nconst Sn = (t, e) => {\n const n = new vn(), o = /* @__PURE__ */ new Map(), i = (d, c) => {\n const y = d.selector.flatMap((C) => {\n const N = C.range instanceof Range && !C.range.collapsed && C.range.startContainer.nodeType === Node.TEXT_NODE && C.range.endContainer.nodeType === Node.TEXT_NODE ? C.range : Xt(C, e).range;\n return Array.from(N.getClientRects());\n }), T = se(y).map(({ left: C, top: E, right: N, bottom: L }) => new DOMRect(C - c.left, E - c.top, N - C, L - E));\n return T.map((C) => {\n const { x: E, y: N, width: L, height: O } = C;\n return {\n minX: E,\n minY: N,\n maxX: E + L,\n maxY: N + O,\n annotation: {\n id: d.annotation,\n rects: T\n }\n };\n });\n }, r = () => [...o.values()], a = () => {\n n.clear(), o.clear();\n }, s = (d) => {\n const c = i(d, e.getBoundingClientRect());\n c.forEach((y) => n.insert(y)), o.set(d.annotation, c);\n }, u = (d) => {\n const c = o.get(d.annotation);\n c && (c.forEach((y) => n.remove(y)), o.delete(d.annotation));\n }, f = (d) => {\n u(d), s(d);\n }, m = (d, c = !0) => {\n c && a();\n const y = e.getBoundingClientRect(), T = d.map((E) => ({ target: E, rects: i(E, y) }));\n T.forEach(({ target: E, rects: N }) => o.set(E.annotation, N));\n const C = T.reduce((E, { rects: N }) => [...E, ...N], []);\n n.load(C);\n }, l = (d, c) => {\n const y = n.search({\n minX: d,\n minY: c,\n maxX: d,\n maxY: c\n }), T = (C) => C.annotation.rects.reduce((E, N) => E + N.width * N.height, 0);\n if (y.length > 0)\n return y.sort((C, E) => T(C) - T(E)), y[0].annotation.id;\n }, p = (d) => {\n const c = g(d);\n if (c.length === 0)\n return;\n let y = c[0].left, T = c[0].top, C = c[0].right, E = c[0].bottom;\n for (let N = 1; N < c.length; N++) {\n const L = c[N];\n y = Math.min(y, L.left), T = Math.min(T, L.top), C = Math.max(C, L.right), E = Math.max(E, L.bottom);\n }\n return new DOMRect(y, T, C - y, E - T);\n }, g = (d) => {\n const c = o.get(d);\n return c ? c[0].annotation.rects : [];\n };\n return {\n all: r,\n clear: a,\n getAt: l,\n getAnnotationBounds: p,\n getAnnotationRects: g,\n getIntersecting: (d, c, y, T) => {\n const C = n.search({ minX: d, minY: c, maxX: y, maxY: T }), E = new Set(C.reduce((N, L) => [...N, L.annotation.id], []));\n return Array.from(E).map((N) => ({\n annotation: t.getAnnotation(N),\n rects: g(N)\n })).filter((N) => !!N.annotation);\n },\n insert: s,\n recalculate: () => m(t.all().map((d) => d.target), !0),\n remove: u,\n set: m,\n size: () => n.all().length,\n update: f\n };\n}, Cn = (t, e) => {\n const n = je(), o = Sn(n, t), i = De(n, e), r = Ie(n), a = Je(), s = (v, h = B.LOCAL) => {\n const d = rt(v, t), c = $(d.target.selector);\n return c && n.addAnnotation(d, h), c;\n }, u = (v, h = !0, d = B.LOCAL) => {\n const c = v.map((T) => rt(T, t)), y = c.filter((T) => !$(T.target.selector));\n return y.length > 0 ? (console.warn(\"Could not revive all targets for these annotations:\", y), n.bulkAddAnnotation(c, h, d), y) : (n.bulkAddAnnotation(c, h, d), []);\n }, f = (v, h = B.LOCAL) => {\n const d = v.map((y) => rt(y, t)), c = d.filter((y) => !$(y.target.selector));\n return c.length > 0 && console.warn(\"Could not revive all targets for these annotations:\", c), d.forEach((y) => {\n n.getAnnotation(y.id) ? n.updateAnnotation(y, h) : n.addAnnotation(y, h);\n }), c;\n }, m = (v, h = B.LOCAL) => {\n const d = it(v, t);\n n.updateTarget(d, h);\n }, l = (v, h = B.LOCAL) => {\n const d = v.map((c) => it(c, t));\n n.bulkUpdateTargets(d, h);\n }, p = (v, h) => {\n const d = o.getAt(v, h);\n return d ? n.getAnnotation(d) : void 0;\n }, g = (v, h, d, c = 5) => {\n const y = o.getAnnotationRects(v);\n if (y.length !== 0) {\n if (h && d) {\n const T = y.find(({ top: C, right: E, bottom: N, left: L }) => h >= L - c && h <= E + c && d >= C - c && d <= N + c);\n if (T)\n return T;\n }\n return o.getAnnotationBounds(v);\n }\n }, x = () => o.recalculate();\n return n.observe(({ changes: v }) => {\n const h = (v.created || []).filter((y) => $(y.target.selector)), d = (v.deleted || []).filter((y) => $(y.target.selector)), c = (v.updated || []).filter((y) => $(y.newValue.target.selector));\n h.length > 0 && o.set(h.map((y) => y.target), !1), (d == null ? void 0 : d.length) > 0 && d.forEach((y) => o.remove(y.target)), (c == null ? void 0 : c.length) > 0 && c.forEach(({ newValue: y }) => o.update(y.target));\n }), {\n store: {\n ...n,\n addAnnotation: s,\n bulkAddAnnotation: u,\n bulkUpdateTargets: l,\n bulkUpsertAnnotations: f,\n getAnnotationBounds: g,\n getAt: p,\n getIntersecting: o.getIntersecting,\n recalculatePositions: x,\n updateTarget: m\n },\n selection: i,\n hover: r,\n viewport: a\n };\n}, Tn = () => {\n const t = document.createElement(\"canvas\");\n t.width = 2 * window.innerWidth, t.height = 2 * window.innerHeight, t.className = \"r6o-highlight-layer presence\";\n const e = t.getContext(\"2d\");\n return e.scale(2, 2), e.translate(0.5, 0.5), t;\n}, Nn = (t, e, n = {}) => {\n const o = Tn(), i = o.getContext(\"2d\");\n t.appendChild(o);\n const r = /* @__PURE__ */ new Map(), a = (l) => Array.from(r.entries()).filter(([p, g]) => g.presenceKey === l.presenceKey).map(([p, g]) => p);\n return e.on(\"selectionChange\", (l, p) => {\n a(l).forEach((x) => r.delete(x)), p && p.forEach((x) => r.set(x, l));\n }), {\n clear: () => {\n const { width: l, height: p } = o;\n i.clearRect(-0.5, -0.5, l + 1, p + 1);\n },\n destroy: () => {\n o.remove();\n },\n paint: (l, p, g) => {\n n.font && (i.font = n.font);\n const x = r.get(l.annotation.id);\n if (x) {\n const { height: v } = l.rects[0], h = l.rects[0].x + p.left, d = l.rects[0].y + p.top;\n i.fillStyle = x.appearance.color, i.fillRect(h - 2, d - 2.5, 2, v + 5);\n const c = i.measureText(x.appearance.label), y = c.width + 6, T = c.actualBoundingBoxAscent + c.actualBoundingBoxDescent + 8, C = c.fontBoundingBoxAscent ? 8 : 6.5;\n return i.fillRect(h - 2, d - 2.5 - T, y, T), i.fillStyle = \"#fff\", i.fillText(x.appearance.label, h + 1, d - C), {\n fill: x.appearance.color,\n fillOpacity: g ? 0.45 : 0.18\n };\n }\n },\n reset: () => {\n o.width = 2 * window.innerWidth, o.height = 2 * window.innerHeight;\n const l = o.getContext(\"2d\");\n l.scale(2, 2), l.translate(0.5, 0.5);\n }\n };\n}, Wt = (t) => {\n if (t === null)\n return document.scrollingElement;\n const { overflowY: e } = window.getComputedStyle(t);\n return e !== \"visible\" && e !== \"hidden\" && t.scrollHeight > t.clientHeight ? t : Wt(t.parentElement);\n}, Ln = (t, e) => (n) => {\n const o = typeof n == \"string\" ? n : n.id, i = (a) => {\n const s = r.getBoundingClientRect(), u = r.clientHeight, f = r.clientWidth, m = a.selector[0].range.getBoundingClientRect(), { width: l, height: p } = e.getAnnotationBounds(o), g = m.top - s.top, x = m.left - s.left, v = r.parentElement ? r.scrollTop : 0, h = r.parentElement ? r.scrollLeft : 0, d = g + v - (u - p) / 2, c = x + h - (f - l) / 2;\n r.scroll({ top: d, left: c, behavior: \"smooth\" });\n }, r = Wt(t);\n if (r) {\n const a = e.getAnnotation(o), { range: s } = a.target.selector[0];\n if (s && !s.collapsed)\n return i(a.target), !0;\n {\n const u = it(a.target, t), { range: f } = u.selector[0];\n if (f && !f.collapsed)\n return i(u), !0;\n }\n }\n return !1;\n}, Rn = (t, e) => ({\n ...t,\n annotationEnabled: t.annotationEnabled === void 0 ? e.annotationEnabled : t.annotationEnabled\n}), Bn = (t, e, n, o) => {\n const { store: i, selection: r } = e;\n let a, s;\n const u = (h) => a = h;\n let f = !1, m;\n const l = (h) => {\n var c;\n if (!f)\n return;\n !((c = h.target.parentElement) != null && c.closest(X)) ? s = {\n annotation: $t(),\n selector: [],\n creator: a,\n created: /* @__PURE__ */ new Date()\n } : s = void 0;\n };\n n && t.addEventListener(\"selectstart\", l);\n const p = bt((h) => {\n var N, L;\n const d = document.getSelection();\n if (!!((L = (N = d.anchorNode) == null ? void 0 : N.parentElement) != null && L.closest(X))) {\n s = void 0;\n return;\n }\n if (h.timeStamp - ((m == null ? void 0 : m.timeStamp) || h.timeStamp) < 1e3 && !s && l(m), d.isCollapsed || !f || !s)\n return;\n const y = d.getRangeAt(0), T = ce(y.cloneRange()), C = Zt(T);\n (C.length !== s.selector.length || C.some((O, b) => {\n var w;\n return O.toString() !== ((w = s.selector[b]) == null ? void 0 : w.quote);\n })) && (s = {\n ...s,\n selector: C.map((O) => ae(O, t, o)),\n updated: /* @__PURE__ */ new Date()\n }, i.getAnnotation(s.annotation) ? i.updateTarget(s, B.LOCAL) : (i.addAnnotation({\n id: s.annotation,\n bodies: [],\n target: s\n }), r.clickSelect(s.annotation, m)));\n });\n n && document.addEventListener(\"selectionchange\", p);\n const g = (h) => {\n const { target: d, timeStamp: c, offsetX: y, offsetY: T, type: C } = h;\n m = { ...h, target: d, timeStamp: c, offsetX: y, offsetY: T, type: C }, f = h.button === 0;\n };\n t.addEventListener(\"pointerdown\", g);\n const x = (h) => {\n var T;\n if (!!((T = h.target.parentElement) != null && T.closest(X)) || !f)\n return;\n const c = () => {\n const { x: C, y: E } = t.getBoundingClientRect(), N = i.getAt(h.clientX - C, h.clientY - E);\n if (N) {\n const { selected: L } = r;\n (L.length !== 1 || L[0].id !== N.id) && r.clickSelect(N.id, h);\n } else\n r.isEmpty() || r.clear();\n }, y = h.timeStamp - m.timeStamp;\n document.getSelection().isCollapsed && y < 300 ? (s = void 0, c()) : s && r.clickSelect(s.annotation, h);\n };\n return document.addEventListener(\"pointerup\", x), {\n destroy: () => {\n t.removeEventListener(\"selectstart\", l), document.removeEventListener(\"selectionchange\", p), t.removeEventListener(\"pointerdown\", g), document.removeEventListener(\"pointerup\", x);\n },\n setUser: u\n };\n}, Ut = \"SPANS\", Dn = (t, e = {}) => {\n te(t);\n const n = Rn(e, {\n annotationEnabled: !0\n }), o = Cn(t, n.pointerAction), { selection: i, viewport: r } = o, a = o.store, s = Qe(a), u = Ze(o, s, n.adapter);\n let f = cn();\n const m = n.renderer === \"CSS_HIGHLIGHTS\" ? CSS.highlights ? \"CSS_HIGHLIGHTS\" : Ut : n.renderer || Ut, l = m === \"SPANS\" ? Ne(t, o, r) : m === \"CSS_HIGHLIGHTS\" ? Se(t, o, r) : m === \"CANVAS\" ? ge(t, o, r) : void 0;\n if (!l)\n throw `Unknown renderer implementation: ${m}`;\n console.debug(`Using ${m} renderer`), n.style && l.setStyle(n.style);\n const p = Bn(t, o, n.annotationEnabled, n.offsetReferenceSelector);\n return p.setUser(f), {\n ...en(o, s, n.adapter),\n destroy: () => {\n l.destroy(), p.destroy(), s.destroy();\n },\n element: t,\n getUser: () => f,\n setFilter: (E) => l.setFilter(E),\n setStyle: (E) => l.setStyle(E),\n setUser: (E) => {\n f = E, p.setUser(E);\n },\n setSelected: (E) => {\n E ? i.setSelected(E) : i.clear();\n },\n setPresenceProvider: (E) => {\n E && (l.setPainter(Nn(t, E, n.presence)), E.on(\"selectionChange\", () => l.redraw()));\n },\n setVisible: (E) => l.setVisible(E),\n on: u.on,\n off: u.off,\n scrollIntoView: Ln(t, a),\n state: o\n };\n};\nexport {\n ot as DEFAULT_SELECTED_STYLE,\n P as DEFAULT_STYLE,\n _t as NOT_ANNOTATABLE_CLASS,\n X as NOT_ANNOTATABLE_SELECTOR,\n B as Origin,\n Ve as PointerSelectAction,\n Vn as W3CTextFormat,\n te as cancelSingleClickEvents,\n In as createBody,\n ge as createCanvasRenderer,\n Se as createHighlightsRenderer,\n Ee as createRenderer,\n Ne as createSpansRenderer,\n Dn as createTextAnnotator,\n Cn as createTextAnnotatorState,\n bt as debounce,\n Rn as fillDefaults,\n On as getAnnotatableFragment,\n Mn as getClientRectsPonyfill,\n oe as getQuoteContext,\n pt as getRangeAnnotatableContents,\n $ as isRevived,\n se as mergeClientRects,\n Kt as paint,\n gn as parseW3CTextAnnotation,\n ae as rangeToSelector,\n rt as reviveAnnotation,\n Xt as reviveSelector,\n it as reviveTarget,\n pn as serializeW3CTextAnnotation,\n Zt as splitAnnotatableRanges,\n ce as trimRange\n};\n//# sourceMappingURL=text-annotator.es.js.map\n"],"names":[],"mappings":"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","x_google_ignoreList":[0]}
@@ -1,2 +1,13 @@
1
-
1
+ import { __module as jsxRuntime } from "./react-text-annotator.es14.js";
2
+ import { __require as requireReactJsxRuntime_production_min } from "./react-text-annotator.es15.js";
3
+ import { __require as requireReactJsxRuntime_development } from "./react-text-annotator.es16.js";
4
+ if (process.env.NODE_ENV === "production") {
5
+ jsxRuntime.exports = requireReactJsxRuntime_production_min();
6
+ } else {
7
+ jsxRuntime.exports = requireReactJsxRuntime_development();
8
+ }
9
+ var jsxRuntimeExports = jsxRuntime.exports;
10
+ export {
11
+ jsxRuntimeExports as j
12
+ };
2
13
  //# sourceMappingURL=react-text-annotator.es7.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"react-text-annotator.es7.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
1
+ {"version":3,"file":"react-text-annotator.es7.js","sources":["../../../node_modules/react/jsx-runtime.js"],"sourcesContent":["'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react-jsx-runtime.production.min.js');\n} else {\n module.exports = require('./cjs/react-jsx-runtime.development.js');\n}\n"],"names":["jsxRuntimeModule","require$$0","require$$1"],"mappings":";;;AAEA,IAAI,QAAQ,IAAI,aAAa,cAAc;AACzCA,aAAA,UAAiBC;AACnB,OAAO;AACLD,aAAA,UAAiBE;AACnB;;","x_google_ignoreList":[0]}