@annotorious/svelte 3.0.0-rc.15 → 3.0.0-rc.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/annotorious-svelte.es.js.map +1 -1
  2. package/dist/annotorious-svelte.es10.js +114 -0
  3. package/dist/annotorious-svelte.es10.js.map +1 -0
  4. package/dist/annotorious-svelte.es11.js +3 -0
  5. package/dist/annotorious-svelte.es11.js.map +1 -0
  6. package/dist/annotorious-svelte.es12.js +5 -0
  7. package/dist/annotorious-svelte.es12.js.map +1 -0
  8. package/dist/annotorious-svelte.es13.js +123 -0
  9. package/dist/annotorious-svelte.es13.js.map +1 -0
  10. package/dist/annotorious-svelte.es14.js +2 -0
  11. package/dist/annotorious-svelte.es14.js.map +1 -0
  12. package/dist/annotorious-svelte.es15.js +59 -0
  13. package/dist/annotorious-svelte.es15.js.map +1 -0
  14. package/dist/annotorious-svelte.es2.js +30 -25
  15. package/dist/annotorious-svelte.es2.js.map +1 -1
  16. package/dist/annotorious-svelte.es3.js +13 -13
  17. package/dist/annotorious-svelte.es3.js.map +1 -1
  18. package/dist/annotorious-svelte.es4.js +58 -53
  19. package/dist/annotorious-svelte.es4.js.map +1 -1
  20. package/dist/annotorious-svelte.es5.js +43 -39
  21. package/dist/annotorious-svelte.es5.js.map +1 -1
  22. package/dist/annotorious-svelte.es6.js +56 -272
  23. package/dist/annotorious-svelte.es6.js.map +1 -1
  24. package/dist/annotorious-svelte.es7.js +40 -119
  25. package/dist/annotorious-svelte.es7.js.map +1 -1
  26. package/dist/annotorious-svelte.es8.js +31 -2
  27. package/dist/annotorious-svelte.es8.js.map +1 -1
  28. package/dist/annotorious-svelte.es9.js +27 -0
  29. package/dist/annotorious-svelte.es9.js.map +1 -0
  30. package/dist/index.d.ts +2 -2
  31. package/dist/index.d.ts.map +1 -1
  32. package/package.json +9 -9
  33. package/src/index.ts +2 -3
  34. package/vite.config.js +1 -0
  35. /package/dist/{style.css → annotorious-svelte.css} +0 -0
@@ -1,7 +1,7 @@
1
1
  var f = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(f || {});
2
2
  let s;
3
3
  const p = new Uint8Array(16);
4
- function y() {
4
+ function g() {
5
5
  if (!s && (s = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !s))
6
6
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
7
7
  return s(p);
@@ -9,7 +9,7 @@ function y() {
9
9
  const e = [];
10
10
  for (let t = 0; t < 256; ++t)
11
11
  e.push((t + 256).toString(16).slice(1));
12
- function g(t, o = 0) {
12
+ function y(t, o = 0) {
13
13
  return e[t[o + 0]] + e[t[o + 1]] + e[t[o + 2]] + e[t[o + 3]] + "-" + e[t[o + 4]] + e[t[o + 5]] + "-" + e[t[o + 6]] + e[t[o + 7]] + "-" + e[t[o + 8]] + e[t[o + 9]] + "-" + e[t[o + 10]] + e[t[o + 11]] + e[t[o + 12]] + e[t[o + 13]] + e[t[o + 14]] + e[t[o + 15]];
14
14
  }
15
15
  const m = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), i = {
@@ -19,16 +19,16 @@ function U(t, o, r) {
19
19
  if (i.randomUUID && !o && !t)
20
20
  return i.randomUUID();
21
21
  t = t || {};
22
- const a = t.random || (t.rng || y)();
22
+ const a = t.random || (t.rng || g)();
23
23
  if (a[6] = a[6] & 15 | 64, a[8] = a[8] & 63 | 128, o) {
24
24
  r = r || 0;
25
25
  for (let n = 0; n < 16; ++n)
26
26
  o[r + n] = a[n];
27
27
  return o;
28
28
  }
29
- return g(a);
29
+ return y(a);
30
30
  }
31
- const S = (t, o, r, a) => ({
31
+ const C = (t, o, r, a) => ({
32
32
  id: U(),
33
33
  annotation: t.id,
34
34
  created: r || /* @__PURE__ */ new Date(),
@@ -36,7 +36,7 @@ const S = (t, o, r, a) => ({
36
36
  ...o
37
37
  });
38
38
  var h = /* @__PURE__ */ ((t) => (t.LOCAL = "LOCAL", t.REMOTE = "REMOTE", t))(h || {});
39
- const v = (t) => ({
39
+ const D = (t) => ({
40
40
  ...t,
41
41
  subscribe: (o) => {
42
42
  const r = (a) => o(a.state);
@@ -54,8 +54,8 @@ let E = (t) => crypto.getRandomValues(new Uint8Array(t)), b = (t, o, r) => {
54
54
  return c;
55
55
  }
56
56
  };
57
- }, C = (t, o = 21) => b(t, o, E), D = (t = 21) => crypto.getRandomValues(new Uint8Array(t)).reduce((o, r) => (r &= 63, r < 36 ? o += r.toString(36) : r < 62 ? o += (r - 26).toString(36).toUpperCase() : r > 62 ? o += "-" : o += "_", o), "");
58
- const O = () => ({ isGuest: !0, id: C("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), R = [
57
+ }, R = (t, o = 21) => b(t, o, E), S = (t = 21) => crypto.getRandomValues(new Uint8Array(t)).reduce((o, r) => (r &= 63, r < 36 ? o += r.toString(36) : r < 62 ? o += (r - 26).toString(36).toUpperCase() : r > 62 ? o += "-" : o += "_", o), "");
58
+ const v = () => ({ isGuest: !0, id: R("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), w = [
59
59
  "#ff7c00",
60
60
  // orange
61
61
  "#1ac938",
@@ -75,19 +75,19 @@ const O = () => ({ isGuest: !0, id: C("1234567890abcdefghijklmnopqrstuvwxyzABCDE
75
75
  "#023eff"
76
76
  // blue
77
77
  ], A = () => {
78
- const t = [...R];
78
+ const t = [...w];
79
79
  return { assignRandomColor: () => {
80
80
  const o = Math.floor(Math.random() * t.length), r = t[o];
81
81
  return t.splice(o, 1), r;
82
82
  }, releaseColor: (o) => t.push(o) };
83
83
  };
84
- D();
84
+ S();
85
85
  export {
86
86
  h as Origin,
87
87
  f as PointerSelectAction,
88
- O as createAnonymousGuest,
89
- S as createBody,
88
+ v as createAnonymousGuest,
89
+ C as createBody,
90
90
  A as defaultColorProvider,
91
- v as toSvelteStore
91
+ D as toSvelteStore
92
92
  };
93
93
  //# sourceMappingURL=annotorious-svelte.es3.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-svelte.es3.js","sources":["../../annotorious-core/dist/annotorious-core.es.js"],"sourcesContent":["var Y = Object.prototype.hasOwnProperty;\nfunction B(e, n) {\n var t, o;\n if (e === n)\n return !0;\n if (e && n && (t = e.constructor) === n.constructor) {\n if (t === Date)\n return e.getTime() === n.getTime();\n if (t === RegExp)\n return e.toString() === n.toString();\n if (t === Array) {\n if ((o = e.length) === n.length)\n for (; o-- && B(e[o], n[o]); )\n ;\n return o === -1;\n }\n if (!t || typeof e == \"object\") {\n o = 0;\n for (t in e)\n if (Y.call(e, t) && ++o && !Y.call(n, t) || !(t in n) || !B(e[t], n[t]))\n return !1;\n return Object.keys(n).length === o;\n }\n }\n return e !== e && n !== n;\n}\nfunction $() {\n}\nfunction q(e, n) {\n return e != e ? n == n : e !== n || e && typeof e == \"object\" || typeof e == \"function\";\n}\nconst k = [];\nfunction _(e, n = $) {\n let t;\n const o = /* @__PURE__ */ new Set();\n function i(b) {\n if (q(e, b) && (e = b, t)) {\n const v = !k.length;\n for (const u of o)\n u[1](), k.push(u, e);\n if (v) {\n for (let u = 0; u < k.length; u += 2)\n k[u][0](k[u + 1]);\n k.length = 0;\n }\n }\n }\n function h(b) {\n i(b(e));\n }\n function U(b, v = $) {\n const u = [b, v];\n return o.add(u), o.size === 1 && (t = n(i) || $), b(e), () => {\n o.delete(u), o.size === 0 && t && (t(), t = null);\n };\n }\n return { set: i, update: h, subscribe: U };\n}\nconst Ee = (e) => {\n const { subscribe: n, set: t } = _(null);\n let o = null;\n return n((i) => o = i), e.observe(({ changes: i }) => {\n if (o) {\n i.deleted.some((b) => b.id === o) && t(null);\n const U = i.updated.find(({ oldValue: b }) => b.id === o);\n U && t(U.newValue.id);\n }\n }), {\n get current() {\n return o;\n },\n subscribe: n,\n set: t\n };\n};\nvar G = /* @__PURE__ */ ((e) => (e.EDIT = \"EDIT\", e.SELECT = \"SELECT\", e.NONE = \"NONE\", e))(G || {});\nconst V = { selected: [] }, be = (e, n = \"EDIT\") => {\n const { subscribe: t, set: o } = _(V);\n let i = V;\n t((s) => i = s);\n const h = () => o(V), U = () => {\n var s;\n return ((s = i.selected) == null ? void 0 : s.length) === 0;\n }, b = (s) => {\n if (i.selected.length === 0)\n return !1;\n const f = typeof s == \"string\" ? s : s.id;\n return i.selected.some((y) => y.id === f);\n }, v = (s, f) => {\n const y = e.getAnnotation(s);\n if (y) {\n const A = W(y, n);\n o(A === \"EDIT\" ? { selected: [{ id: s, editable: !0 }], pointerEvent: f } : A === \"SELECT\" ? { selected: [{ id: s }], pointerEvent: f } : { selected: [], pointerEvent: f });\n } else\n console.warn(\"Invalid selection: \" + s);\n }, u = (s, f = !0) => {\n const y = Array.isArray(s) ? s : [s], A = y.map((L) => e.getAnnotation(L)).filter((L) => L);\n o({ selected: A.map(({ id: L }) => ({ id: L, editable: f })) }), A.length !== y.length && console.warn(\"Invalid selection\", s);\n }, T = (s) => {\n if (i.selected.length === 0)\n return !1;\n const { selected: f } = i;\n f.filter(({ id: A }) => s.includes(A)).length > 0 && o({ selected: f.filter(({ id: A }) => !s.includes(A)) });\n };\n return e.observe(({ changes: s }) => T(s.deleted.map((f) => f.id))), {\n clear: h,\n clickSelect: v,\n get selected() {\n return i ? [...i.selected] : null;\n },\n get pointerEvent() {\n return i ? i.pointerEvent : null;\n },\n isEmpty: U,\n isSelected: b,\n setSelected: u,\n subscribe: t\n };\n}, W = (e, n) => typeof n == \"function\" ? n(e) || \"EDIT\" : n || \"EDIT\";\nlet z;\nconst H = new Uint8Array(16);\nfunction F() {\n if (!z && (z = typeof crypto < \"u\" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !z))\n throw new Error(\"crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported\");\n return z(H);\n}\nconst R = [];\nfor (let e = 0; e < 256; ++e)\n R.push((e + 256).toString(16).slice(1));\nfunction J(e, n = 0) {\n return R[e[n + 0]] + R[e[n + 1]] + R[e[n + 2]] + R[e[n + 3]] + \"-\" + R[e[n + 4]] + R[e[n + 5]] + \"-\" + R[e[n + 6]] + R[e[n + 7]] + \"-\" + R[e[n + 8]] + R[e[n + 9]] + \"-\" + R[e[n + 10]] + R[e[n + 11]] + R[e[n + 12]] + R[e[n + 13]] + R[e[n + 14]] + R[e[n + 15]];\n}\nconst Q = typeof crypto < \"u\" && crypto.randomUUID && crypto.randomUUID.bind(crypto), j = {\n randomUUID: Q\n};\nfunction X(e, n, t) {\n if (j.randomUUID && !n && !e)\n return j.randomUUID();\n e = e || {};\n const o = e.random || (e.rng || F)();\n if (o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, n) {\n t = t || 0;\n for (let i = 0; i < 16; ++i)\n n[t + i] = o[i];\n return n;\n }\n return J(o);\n}\nconst ve = (e) => {\n const { creator: n, updatedBy: t } = e.target, o = e.bodies.reduce((i, h) => [...i, h.creator, h.updatedBy], []);\n return [\n n,\n t,\n ...o\n ].filter((i) => i);\n}, Ce = (e, n, t, o) => ({\n id: X(),\n annotation: e.id,\n created: t || /* @__PURE__ */ new Date(),\n creator: o,\n ...n\n}), Z = (e, n) => {\n const t = new Set(e.bodies.map((o) => o.id));\n return n.bodies.filter((o) => !t.has(o.id));\n}, K = (e, n) => {\n const t = new Set(n.bodies.map((o) => o.id));\n return e.bodies.filter((o) => !t.has(o.id));\n}, ee = (e, n) => n.bodies.map((t) => {\n const o = e.bodies.find((i) => i.id === t.id);\n return { newBody: t, oldBody: o && !B(o, t) ? o : void 0 };\n}).filter(({ oldBody: t }) => t), te = (e, n) => !B(e.target, n.target), M = (e, n) => {\n const t = Z(e, n), o = K(e, n), i = ee(e, n);\n return {\n oldValue: e,\n newValue: n,\n bodiesCreated: t.length > 0 ? t : void 0,\n bodiesDeleted: o.length > 0 ? o : void 0,\n bodiesUpdated: i.length > 0 ? i : void 0,\n targetUpdated: te(e, n) ? { oldTarget: e.target, newTarget: n.target } : void 0\n };\n};\nvar ne = /* @__PURE__ */ ((e) => (e.BODY_ONLY = \"BODY_ONLY\", e.TARGET_ONLY = \"TARGET_ONLY\", e))(ne || {}), O = /* @__PURE__ */ ((e) => (e.LOCAL = \"LOCAL\", e.REMOTE = \"REMOTE\", e))(O || {});\nconst oe = (e, n) => {\n var h, U;\n const { changes: t, origin: o } = n;\n if (!(!e.options.origin || e.options.origin === o))\n return !1;\n if (e.options.ignore) {\n const { ignore: b } = e.options, v = (T) => (T == null ? void 0 : T.length) > 0;\n if (!(v(t.created) || v(t.deleted))) {\n const T = (h = t.updated) == null ? void 0 : h.some((f) => v(f.bodiesCreated) || v(f.bodiesDeleted) || v(f.bodiesUpdated)), s = (U = t.updated) == null ? void 0 : U.some((f) => f.targetUpdated);\n if (b === \"BODY_ONLY\" && T && !s || b === \"TARGET_ONLY\" && s && !T)\n return !1;\n }\n }\n if (e.options.annotations) {\n const b = /* @__PURE__ */ new Set([\n ...t.created.map((u) => u.id),\n ...t.deleted.map((u) => u.id),\n ...t.updated.map(({ oldValue: u }) => u.id)\n ]);\n return !!(Array.isArray(e.options.annotations) ? e.options.annotations : [e.options.annotations]).find((u) => b.has(u));\n } else\n return !0;\n}, se = (e, n) => {\n const t = new Set((e.created || []).map((s) => s.id)), o = new Set((e.updated || []).map(({ newValue: s }) => s.id)), i = new Set((n.created || []).map((s) => s.id)), h = new Set((n.deleted || []).map((s) => s.id)), U = new Set((n.updated || []).map(({ oldValue: s }) => s.id)), b = new Set((n.updated || []).filter(({ oldValue: s }) => t.has(s.id) || o.has(s.id)).map(({ oldValue: s }) => s.id)), v = [\n ...(e.created || []).filter((s) => !h.has(s.id)).map((s) => U.has(s.id) ? n.updated.find(({ oldValue: f }) => f.id === s.id).newValue : s),\n ...n.created || []\n ], u = [\n ...(e.deleted || []).filter((s) => !i.has(s.id)),\n ...(n.deleted || []).filter((s) => !t.has(s.id))\n ], T = [\n ...(e.updated || []).filter(({ newValue: s }) => !h.has(s.id)).map((s) => {\n const { oldValue: f, newValue: y } = s;\n if (U.has(y.id)) {\n const A = n.updated.find((L) => L.oldValue.id === y.id).newValue;\n return M(f, A);\n } else\n return s;\n }),\n ...(n.updated || []).filter(({ oldValue: s }) => !b.has(s.id))\n ];\n return { created: v, deleted: u, updated: T };\n}, ie = (e) => e.id !== void 0, we = () => {\n const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), t = [], o = (r, l = {}) => t.push({ onChange: r, options: l }), i = (r) => {\n const l = t.findIndex((a) => a.onChange == r);\n l > -1 && t.splice(l, 1);\n }, h = (r, l) => {\n const a = {\n origin: r,\n changes: {\n created: l.created || [],\n updated: l.updated || [],\n deleted: l.deleted || []\n },\n state: [...e.values()]\n };\n t.forEach((p) => {\n oe(p, a) && p.onChange(a);\n });\n }, U = (r, l = O.LOCAL) => {\n if (e.get(r.id))\n throw Error(`Cannot add annotation ${r.id} - exists already`);\n e.set(r.id, r), r.bodies.forEach((p) => n.set(p.id, r.id)), h(l, { created: [r] });\n }, b = (r, l) => {\n const a = typeof r == \"string\" ? l : r, p = typeof r == \"string\" ? r : r.id, C = e.get(p);\n if (C) {\n const D = M(C, a);\n return p === a.id ? e.set(p, a) : (e.delete(p), e.set(a.id, a)), C.bodies.forEach((x) => n.delete(x.id)), a.bodies.forEach((x) => n.set(x.id, a.id)), D;\n } else\n console.warn(`Cannot update annotation ${p} - does not exist`);\n }, v = (r, l = O.LOCAL, a = O.LOCAL) => {\n const p = ie(l) ? a : l, C = b(r, l);\n C && h(p, { updated: [C] });\n }, u = (r, l = O.LOCAL) => {\n const a = r.reduce((p, C) => {\n const D = b(C);\n return D ? [...p, D] : p;\n }, []);\n a.length > 0 && h(l, { updated: a });\n }, T = (r, l = O.LOCAL) => {\n const a = e.get(r.annotation);\n if (a) {\n const p = {\n ...a,\n bodies: [...a.bodies, r]\n };\n e.set(a.id, p), n.set(r.id, p.id), h(l, { updated: [{\n oldValue: a,\n newValue: p,\n bodiesCreated: [r]\n }] });\n } else\n console.warn(`Attempt to add body to missing annotation: ${r.annotation}`);\n }, s = () => [...e.values()], f = (r = O.LOCAL) => {\n const l = [...e.values()];\n e.clear(), n.clear(), h(r, { deleted: l });\n }, y = (r, l = !0, a = O.LOCAL) => {\n if (l) {\n const p = [...e.values()];\n e.clear(), n.clear(), r.forEach((C) => {\n e.set(C.id, C), C.bodies.forEach((D) => n.set(D.id, C.id));\n }), h(a, { created: r, deleted: p });\n } else {\n const p = r.reduce((C, D) => {\n const x = e.get(D.id);\n return x ? [...C, x] : C;\n }, []);\n if (p.length > 0)\n throw Error(`Bulk insert would overwrite the following annotations: ${p.map((C) => C.id).join(\", \")}`);\n r.forEach((C) => {\n e.set(C.id, C), C.bodies.forEach((D) => n.set(D.id, C.id));\n }), h(a, { created: r });\n }\n }, A = (r) => {\n const l = typeof r == \"string\" ? r : r.id, a = e.get(l);\n if (a)\n return e.delete(l), a.bodies.forEach((p) => n.delete(p.id)), a;\n console.warn(`Attempt to delete missing annotation: ${l}`);\n }, L = (r, l = O.LOCAL) => {\n const a = A(r);\n a && h(l, { deleted: [a] });\n }, w = (r, l = O.LOCAL) => {\n const a = r.reduce((p, C) => {\n const D = A(C);\n return D ? [...p, D] : p;\n }, []);\n a.length > 0 && h(l, { deleted: a });\n }, c = (r, l = O.LOCAL) => {\n const a = e.get(r.annotation);\n if (a) {\n const p = a.bodies.find((C) => C.id === r.id);\n if (p) {\n n.delete(p.id);\n const C = {\n ...a,\n bodies: a.bodies.filter((x) => x.id !== r.id)\n };\n e.set(a.id, C), h(l, { updated: [{\n oldValue: a,\n newValue: C,\n bodiesDeleted: [p]\n }] });\n } else\n console.warn(`Attempt to delete missing body ${r.id} from annotation ${r.annotation}`);\n } else\n console.warn(`Attempt to delete body from missing annotation ${r.annotation}`);\n }, m = (r) => {\n const l = e.get(r);\n return l ? { ...l } : void 0;\n }, d = (r) => {\n const l = n.get(r);\n if (l) {\n const p = m(l).bodies.find((C) => C.id === r);\n if (p)\n return p;\n console.error(`Store integrity error: body ${r} in index, but not in annotation`);\n } else\n console.warn(`Attempt to retrieve missing body: ${r}`);\n }, E = (r, l) => {\n if (r.annotation !== l.annotation)\n throw \"Annotation integrity violation: annotation ID must be the same when updating bodies\";\n const a = e.get(r.annotation);\n if (a) {\n const p = a.bodies.find((D) => D.id === r.id), C = {\n ...a,\n bodies: a.bodies.map((D) => D.id === p.id ? l : D)\n };\n return e.set(a.id, C), p.id !== l.id && (n.delete(p.id), n.set(l.id, C.id)), {\n oldValue: a,\n newValue: C,\n bodiesUpdated: [{ oldBody: p, newBody: l }]\n };\n } else\n console.warn(`Attempt to add body to missing annotation ${r.annotation}`);\n }, g = (r, l, a = O.LOCAL) => {\n const p = E(r, l);\n h(a, { updated: [p] });\n }, S = (r, l = O.LOCAL) => {\n const a = r.map((p) => E({ id: p.id, annotation: p.annotation }, p));\n h(l, { updated: a });\n }, I = (r) => {\n const l = e.get(r.annotation);\n if (l) {\n const a = {\n ...l,\n target: {\n ...l.target,\n ...r\n }\n };\n return e.set(l.id, a), {\n oldValue: l,\n newValue: a,\n targetUpdated: {\n oldTarget: l.target,\n newTarget: r\n }\n };\n } else\n console.warn(`Attempt to update target on missing annotation: ${r.annotation}`);\n };\n return {\n addAnnotation: U,\n addBody: T,\n all: s,\n bulkAddAnnotation: y,\n bulkDeleteAnnotation: w,\n bulkUpdateAnnotation: u,\n bulkUpdateBodies: S,\n bulkUpdateTargets: (r, l = O.LOCAL) => {\n const a = r.map(I).filter((p) => p);\n a.length > 0 && h(l, { updated: a });\n },\n clear: f,\n deleteAnnotation: L,\n deleteBody: c,\n getAnnotation: m,\n getBody: d,\n observe: o,\n unobserve: i,\n updateAnnotation: v,\n updateBody: g,\n updateTarget: (r, l = O.LOCAL) => {\n const a = I(r);\n a && h(l, { updated: [a] });\n }\n };\n}, ye = (e) => ({\n ...e,\n subscribe: (t) => {\n const o = (i) => t(i.state);\n return e.observe(o), t(e.all()), () => e.unobserve(o);\n }\n});\nlet P = () => ({\n emit(e, ...n) {\n let t = this.events[e] || [];\n for (let o = 0, i = t.length; o < i; o++)\n t[o](...n);\n },\n events: {},\n on(e, n) {\n var t;\n return (t = this.events[e]) != null && t.push(n) || (this.events[e] = [n]), () => {\n var o;\n this.events[e] = (o = this.events[e]) == null ? void 0 : o.filter((i) => n !== i);\n };\n }\n});\nconst de = 250, Ue = (e) => {\n const n = P(), t = [];\n let o = -1, i = !1, h = 0;\n const U = (d) => {\n if (!i) {\n const { changes: E } = d, g = performance.now();\n if (g - h > de)\n t.splice(o + 1), t.push(E), o = t.length - 1;\n else {\n const S = t.length - 1;\n t[S] = se(t[S], E);\n }\n h = g;\n }\n i = !1;\n };\n e.observe(U, { origin: O.LOCAL });\n const b = (d) => (d == null ? void 0 : d.length) > 0 && e.bulkDeleteAnnotation(d), v = (d) => (d == null ? void 0 : d.length) > 0 && e.bulkAddAnnotation(d, !1), u = (d) => (d == null ? void 0 : d.length) > 0 && e.bulkUpdateAnnotation(d.map(({ oldValue: E }) => E)), T = (d) => (d == null ? void 0 : d.length) > 0 && e.bulkUpdateAnnotation(d.map(({ newValue: E }) => E)), s = (d) => (d == null ? void 0 : d.length) > 0 && e.bulkAddAnnotation(d, !1), f = (d) => (d == null ? void 0 : d.length) > 0 && e.bulkDeleteAnnotation(d);\n return {\n canRedo: () => t.length - 1 > o,\n canUndo: () => o > -1,\n destroy: () => e.unobserve(U),\n on: (d, E) => n.on(d, E),\n redo: () => {\n if (t.length - 1 > o) {\n i = !0;\n const { created: d, updated: E, deleted: g } = t[o + 1];\n v(d), T(E), f(g), n.emit(\"redo\", t[o + 1]), o += 1;\n }\n },\n undo: () => {\n if (o > -1) {\n i = !0;\n const { created: d, updated: E, deleted: g } = t[o];\n b(d), u(E), s(g), n.emit(\"undo\", t[o]), o -= 1;\n }\n }\n };\n}, Le = () => {\n const { subscribe: e, set: n } = _([]);\n return {\n subscribe: e,\n set: n\n };\n}, Se = (e, n, t, o) => {\n const { store: i, selection: h, hover: U, viewport: b } = e, v = /* @__PURE__ */ new Map();\n let u = [], T, s;\n const f = (c, m) => {\n v.has(c) ? v.get(c).push(m) : v.set(c, [m]);\n }, y = (c, m) => {\n const d = v.get(c);\n d && d.indexOf(m) > 0 && d.splice(d.indexOf(m), 1);\n }, A = (c, m, d) => {\n v.has(c) && setTimeout(() => {\n v.get(c).forEach((E) => {\n if (t) {\n const g = Array.isArray(m) ? m.map((I) => t.serialize(I)) : t.serialize(m), S = d ? d instanceof PointerEvent ? d : t.serialize(d) : void 0;\n E(g, S);\n } else\n E(m, d);\n });\n }, 1);\n }, L = () => {\n const { selected: c } = h, m = c.map(({ id: d }) => i.getAnnotation(d));\n m.forEach((d) => {\n const E = u.find((g) => g.id === d.id);\n (!E || !B(E, d)) && A(\"updateAnnotation\", d, E);\n }), u = u.map((d) => {\n const E = m.find(({ id: g }) => g === d.id);\n return E || d;\n });\n };\n h.subscribe(({ selected: c }) => {\n if (!(u.length === 0 && c.length === 0)) {\n if (u.length === 0 && c.length > 0)\n u = c.map(({ id: m }) => i.getAnnotation(m));\n else if (u.length > 0 && c.length === 0)\n u.forEach((m) => {\n const d = i.getAnnotation(m.id);\n d && !B(d, m) && A(\"updateAnnotation\", d, m);\n }), u = [];\n else {\n const m = new Set(u.map((g) => g.id)), d = new Set(c.map(({ id: g }) => g));\n u.filter((g) => !d.has(g.id)).forEach((g) => {\n const S = i.getAnnotation(g.id);\n S && !B(S, g) && A(\"updateAnnotation\", S, g);\n }), u = [\n // Remove annotations that were deselected\n ...u.filter((g) => d.has(g.id)),\n // Add editable annotations that were selected\n ...c.filter(({ id: g }) => !m.has(g)).map(({ id: g }) => i.getAnnotation(g))\n ];\n }\n A(\"selectionChanged\", u);\n }\n }), U.subscribe((c) => {\n !T && c ? A(\"mouseEnterAnnotation\", i.getAnnotation(c)) : T && !c ? A(\"mouseLeaveAnnotation\", i.getAnnotation(T)) : T && c && (A(\"mouseLeaveAnnotation\", i.getAnnotation(T)), A(\"mouseEnterAnnotation\", i.getAnnotation(c))), T = c;\n }), b == null || b.subscribe((c) => A(\"viewportIntersect\", c.map(i.getAnnotation))), i.observe((c) => {\n o && (s && clearTimeout(s), s = setTimeout(L, 1e3));\n const { created: m, deleted: d } = c.changes;\n m.forEach((g) => A(\"createAnnotation\", g)), d.forEach((g) => A(\"deleteAnnotation\", g)), c.changes.updated.filter((g) => [\n ...g.bodiesCreated || [],\n ...g.bodiesDeleted || [],\n ...g.bodiesUpdated || []\n ].length > 0).forEach(({ oldValue: g, newValue: S }) => {\n const I = u.find((N) => N.id === g.id) || g;\n u = u.map((N) => N.id === g.id ? S : N), A(\"updateAnnotation\", S, I);\n });\n }, { origin: O.LOCAL }), i.observe((c) => {\n if (u) {\n const m = new Set(u.map((E) => E.id)), d = c.changes.updated.filter(({ newValue: E }) => m.has(E.id)).map(({ newValue: E }) => E);\n d.length > 0 && (u = u.map((E) => {\n const g = d.find((S) => S.id === E.id);\n return g || E;\n }));\n }\n }, { origin: O.REMOTE });\n const w = (c) => (m) => {\n const { created: d, deleted: E, updated: g } = m;\n d.forEach((S) => A(\"createAnnotation\", S)), E.forEach((S) => A(\"deleteAnnotation\", S)), c ? g.forEach((S) => A(\"updateAnnotation\", S.oldValue, S.newValue)) : g.forEach((S) => A(\"updateAnnotation\", S.newValue, S.oldValue));\n };\n return n.on(\"undo\", w(!0)), n.on(\"redo\", w(!1)), { on: f, off: y, emit: A };\n}, Te = (e) => (n) => n.map((t) => e.serialize(t)), re = (e) => (n) => n.reduce((t, o) => {\n const { parsed: i, error: h } = e.parse(o);\n return h ? {\n parsed: t.parsed,\n failed: [...t.failed, o]\n } : {\n parsed: [...t.parsed, i],\n failed: t.failed\n };\n}, { parsed: [], failed: [] }), Oe = (e, n, t) => {\n const { store: o, selection: i } = e, h = (w) => {\n if (t) {\n const { parsed: c, error: m } = t.parse(w);\n c ? o.addAnnotation(c, O.REMOTE) : console.error(m);\n } else\n o.addAnnotation(w, O.REMOTE);\n }, U = () => i.clear(), b = () => o.clear(), v = (w) => {\n const c = o.getAnnotation(w);\n return t && c ? t.serialize(c) : c;\n }, u = () => t ? o.all().map(t.serialize) : o.all(), T = () => {\n var m;\n const c = (((m = i.selected) == null ? void 0 : m.map((d) => d.id)) || []).map((d) => o.getAnnotation(d));\n return t ? c.map(t.serialize) : c;\n }, s = (w) => fetch(w).then((c) => c.json()).then((c) => (y(c), c)), f = (w) => {\n if (typeof w == \"string\") {\n const c = o.getAnnotation(w);\n return o.deleteAnnotation(w), t ? t.serialize(c) : c;\n } else {\n const c = t ? t.parse(w).parsed : w;\n return o.deleteAnnotation(c), w;\n }\n }, y = (w) => {\n if (t) {\n const { parsed: c, failed: m } = re(t)(w);\n m.length > 0 && console.warn(`Discarded ${m.length} invalid annotations`, m), o.bulkAddAnnotation(c, !0, O.REMOTE);\n } else\n o.bulkAddAnnotation(w, !0, O.REMOTE);\n }, A = (w) => {\n w ? i.setSelected(w) : i.clear();\n }, L = (w) => {\n if (t) {\n const c = t.parse(w).parsed, m = t.serialize(o.getAnnotation(c.id));\n return o.updateAnnotation(c), m;\n } else {\n const c = o.getAnnotation(w.id);\n return o.updateAnnotation(w), c;\n }\n };\n return {\n addAnnotation: h,\n cancelSelected: U,\n canRedo: n.canRedo,\n canUndo: n.canUndo,\n clearAnnotations: b,\n getAnnotationById: v,\n getAnnotations: u,\n getSelected: T,\n loadAnnotations: s,\n redo: n.redo,\n removeAnnotation: f,\n setAnnotations: y,\n setSelected: A,\n undo: n.undo,\n updateAnnotation: L\n };\n};\nlet ae = (e) => crypto.getRandomValues(new Uint8Array(e)), ce = (e, n, t) => {\n let o = (2 << Math.log(e.length - 1) / Math.LN2) - 1, i = -~(1.6 * o * n / e.length);\n return (h = n) => {\n let U = \"\";\n for (; ; ) {\n let b = t(i), v = i;\n for (; v--; )\n if (U += e[b[v] & o] || \"\", U.length === h)\n return U;\n }\n };\n}, le = (e, n = 21) => ce(e, n, ae), ue = (e = 21) => crypto.getRandomValues(new Uint8Array(e)).reduce((n, t) => (t &= 63, t < 36 ? n += t.toString(36) : t < 62 ? n += (t - 26).toString(36).toUpperCase() : t > 62 ? n += \"-\" : n += \"_\", n), \"\");\nconst De = () => ({ isGuest: !0, id: le(\"1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_\", 20)() }), fe = (e) => {\n const n = JSON.stringify(e);\n let t = 0;\n for (let o = 0, i = n.length; o < i; o++) {\n let h = n.charCodeAt(o);\n t = (t << 5) - t + h, t |= 0;\n }\n return `${t}`;\n}, Re = (e, n) => (Array.isArray(e) ? e : [e]).map((t) => {\n const { id: o, type: i, purpose: h, value: U, created: b, creator: v, ...u } = t;\n return {\n id: o || `temp-${fe(t)}`,\n annotation: n,\n type: i,\n purpose: h,\n value: U,\n created: b,\n creator: v ? typeof v == \"object\" ? { ...v } : v : void 0,\n ...u\n };\n}), xe = (e) => e.map((n) => {\n var o;\n const t = { ...n };\n return delete t.annotation, (o = t.id) != null && o.startsWith(\"temp-\") && delete t.id, t;\n}), pe = [\n \"#ff7c00\",\n // orange\n \"#1ac938\",\n // green\n \"#e8000b\",\n // red\n \"#8b2be2\",\n // purple\n \"#9f4800\",\n // brown\n \"#f14cc1\",\n // pink\n \"#ffc400\",\n // khaki\n \"#00d7ff\",\n // cyan\n \"#023eff\"\n // blue\n], he = () => {\n const e = [...pe];\n return { assignRandomColor: () => {\n const o = Math.floor(Math.random() * e.length), i = e[o];\n return e.splice(o, 1), i;\n }, releaseColor: (o) => e.push(o) };\n}, ge = () => {\n const e = he();\n return { addUser: (o, i) => {\n const h = e.assignRandomColor();\n return {\n label: i.name || i.id,\n avatar: i.avatar,\n color: h\n };\n }, removeUser: (o) => e.releaseColor(o.appearance.color) };\n}, me = (e, n) => e.every((t) => e.includes(t)) && n.every((t) => e.includes(t)), Be = ue(), Ie = (e = ge()) => {\n const n = P(), t = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), i = (s, f) => {\n if (t.has(s)) {\n console.warn(\"Attempt to add user that is already present\", s, f);\n return;\n }\n const y = e.addUser(s, f);\n t.set(s, {\n ...f,\n presenceKey: s,\n appearance: y\n });\n }, h = (s) => {\n const f = t.get(s);\n if (!f) {\n console.warn(\"Attempt to remove user that is not present\", s);\n return;\n }\n e.removeUser(f), t.delete(s);\n }, U = (s) => {\n const f = new Set(s.map((L) => L.presenceKey)), y = s.filter(({ presenceKey: L }) => !t.has(L)), A = Array.from(t.values()).filter((L) => !f.has(L.presenceKey));\n y.forEach(({ presenceKey: L, user: w }) => i(L, w)), A.forEach((L) => {\n const { presenceKey: w } = L;\n o.has(w) && n.emit(\"selectionChange\", L, null), h(w);\n }), (y.length > 0 || A.length > 0) && n.emit(\"presence\", u());\n }, b = (s, f) => {\n const y = t.get(s);\n if (!y) {\n console.warn(\"Activity notification from user that is not present\");\n return;\n }\n const A = o.get(s);\n (!A || !me(A, f)) && (o.set(s, f), n.emit(\"selectionChange\", y, f));\n }, v = (s, f) => {\n const y = t.get(s);\n if (!y) {\n console.warn(\"Selection change for user that is not present\", s);\n return;\n }\n f ? o.set(s, f) : o.delete(s), n.emit(\"selectionChange\", y, f);\n }, u = () => [...Array.from(t.values())];\n return {\n getPresentUsers: u,\n notifyActivity: b,\n on: (s, f) => n.on(s, f),\n syncUsers: U,\n updateSelection: v\n };\n};\nexport {\n ne as Ignore,\n O as Origin,\n Be as PRESENCE_KEY,\n G as PointerSelectAction,\n De as createAnonymousGuest,\n Oe as createBaseAnnotator,\n Ce as createBody,\n ge as createDefaultAppearenceProvider,\n Ee as createHoverState,\n Se as createLifecyleObserver,\n Ie as createPresenceState,\n be as createSelectionState,\n we as createStore,\n Ue as createUndoStack,\n Le as createViewportState,\n he as defaultColorProvider,\n M as diffAnnotations,\n ve as getContributors,\n se as mergeChanges,\n W as onPointerSelect,\n re as parseAll,\n Re as parseW3CBodies,\n Te as serializeAll,\n xe as serializeW3CBodies,\n oe as shouldNotify,\n ye as toSvelteStore\n};\n//# sourceMappingURL=annotorious-core.es.js.map\n"],"names":["G","e","z","H","F","R","J","n","Q","j","X","t","o","i","Ce","O","ye","ae","ce","h","U","b","v","le","ue","De","pe","he"],"mappings":"AA2EG,IAACA,IAAqB,kBAACC,OAAOA,EAAE,OAAO,QAAQA,EAAE,SAAS,UAAUA,EAAE,OAAO,QAAQA,IAAID,KAAK,EAAE;AA4CnG,IAAIE;AACJ,MAAMC,IAAI,IAAI,WAAW,EAAE;AAC3B,SAASC,IAAI;AACX,MAAI,CAACF,MAAMA,IAAI,OAAO,SAAS,OAAO,OAAO,mBAAmB,OAAO,gBAAgB,KAAK,MAAM,GAAG,CAACA;AACpG,UAAM,IAAI,MAAM,0GAA0G;AAC5H,SAAOA,EAAEC,CAAC;AACZ;AACA,MAAME,IAAI,CAAA;AACV,SAASJ,IAAI,GAAGA,IAAI,KAAK,EAAEA;AACzB,EAAAI,EAAE,MAAMJ,IAAI,KAAK,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC;AACxC,SAASK,EAAEL,GAAGM,IAAI,GAAG;AACnB,SAAOF,EAAEJ,EAAEM,IAAI,CAAC,CAAC,IAAIF,EAAEJ,EAAEM,IAAI,CAAC,CAAC,IAAIF,EAAEJ,EAAEM,IAAI,CAAC,CAAC,IAAIF,EAAEJ,EAAEM,IAAI,CAAC,CAAC,IAAI,MAAMF,EAAEJ,EAAEM,IAAI,CAAC,CAAC,IAAIF,EAAEJ,EAAEM,IAAI,CAAC,CAAC,IAAI,MAAMF,EAAEJ,EAAEM,IAAI,CAAC,CAAC,IAAIF,EAAEJ,EAAEM,IAAI,CAAC,CAAC,IAAI,MAAMF,EAAEJ,EAAEM,IAAI,CAAC,CAAC,IAAIF,EAAEJ,EAAEM,IAAI,CAAC,CAAC,IAAI,MAAMF,EAAEJ,EAAEM,IAAI,EAAE,CAAC,IAAIF,EAAEJ,EAAEM,IAAI,EAAE,CAAC,IAAIF,EAAEJ,EAAEM,IAAI,EAA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I,KAAK,MAAM,KAAK,OAAM,IAAKzB,EAAE,MAAM,GAAGY,IAAIZ,EAAE,CAAC;AACvD,WAAOA,EAAE,OAAO,GAAG,CAAC,GAAGY;AAAA,EAC3B,GAAK,cAAc,CAAC,MAAMZ,EAAE,KAAK,CAAC;AAClC;AAUuFuB,EAAI;"}
1
+ {"version":3,"file":"annotorious-svelte.es3.js","sources":["../../annotorious-core/dist/annotorious-core.es.js"],"sourcesContent":["var Y = Object.prototype.hasOwnProperty;\nfunction x(e, n) {\n var t, o;\n if (e === n)\n return !0;\n if (e && n && (t = e.constructor) === n.constructor) {\n if (t === Date)\n return e.getTime() === n.getTime();\n if (t === RegExp)\n return e.toString() === n.toString();\n if (t === Array) {\n if ((o = e.length) === n.length)\n for (; o-- && x(e[o], n[o]); )\n ;\n return o === -1;\n }\n if (!t || typeof e == \"object\") {\n o = 0;\n for (t in e)\n if (Y.call(e, t) && ++o && !Y.call(n, t) || !(t in n) || !x(e[t], n[t]))\n return !1;\n return Object.keys(n).length === o;\n }\n }\n return e !== e && n !== n;\n}\nfunction $() {\n}\nfunction W(e, n) {\n return e != e ? n == n : e !== n || e && typeof e == \"object\" || typeof e == \"function\";\n}\nconst k = [];\nfunction _(e, n = $) {\n let t;\n const o = /* @__PURE__ */ new Set();\n function i(b) {\n if (W(e, b) && (e = b, t)) {\n const w = !k.length;\n for (const u of o)\n u[1](), k.push(u, e);\n if (w) {\n for (let u = 0; u < k.length; u += 2)\n k[u][0](k[u + 1]);\n k.length = 0;\n }\n }\n }\n function p(b) {\n i(b(e));\n }\n function U(b, w = $) {\n const u = [b, w];\n return o.add(u), o.size === 1 && (t = n(i, p) || $), b(e), () => {\n o.delete(u), o.size === 0 && t && (t(), t = null);\n };\n }\n return { set: i, update: p, subscribe: U };\n}\nconst be = (e) => {\n const { subscribe: n, set: t } = _();\n let o;\n return n((i) => o = i), e.observe(({ changes: i }) => {\n if (o) {\n (i.deleted || []).some((b) => b.id === o) && t(void 0);\n const U = (i.updated || []).find(({ oldValue: b }) => b.id === o);\n U && t(U.newValue.id);\n }\n }), {\n get current() {\n return o;\n },\n subscribe: n,\n set: t\n };\n};\nvar q = /* @__PURE__ */ ((e) => (e.EDIT = \"EDIT\", e.SELECT = \"SELECT\", e.NONE = \"NONE\", e))(q || {});\nconst V = { selected: [] }, ve = (e, n = \"EDIT\") => {\n const { subscribe: t, set: o } = _(V);\n let i = V;\n t((s) => i = s);\n const p = () => o(V), U = () => {\n var s;\n return ((s = i.selected) == null ? void 0 : s.length) === 0;\n }, b = (s) => {\n if (i.selected.length === 0)\n return !1;\n const g = typeof s == \"string\" ? s : s.id;\n return i.selected.some((y) => y.id === g);\n }, w = (s, g) => {\n const y = e.getAnnotation(s);\n if (y) {\n const A = G(y, n);\n o(A === \"EDIT\" ? { selected: [{ id: s, editable: !0 }], pointerEvent: g } : A === \"SELECT\" ? { selected: [{ id: s }], pointerEvent: g } : { selected: [], pointerEvent: g });\n } else\n console.warn(\"Invalid selection: \" + s);\n }, u = (s, g = !0) => {\n const y = Array.isArray(s) ? s : [s], A = y.map((O) => e.getAnnotation(O)).filter(Boolean);\n o({ selected: A.map(({ id: O }) => ({ id: O, editable: g })) }), A.length !== y.length && console.warn(\"Invalid selection\", s);\n }, S = (s) => {\n if (i.selected.length === 0)\n return !1;\n const { selected: g } = i;\n g.filter(({ id: A }) => s.includes(A)).length > 0 && o({ selected: g.filter(({ id: A }) => !s.includes(A)) });\n };\n return e.observe(({ changes: s }) => S((s.deleted || []).map((g) => g.id))), {\n clear: p,\n clickSelect: w,\n get selected() {\n return i ? [...i.selected] : null;\n },\n get pointerEvent() {\n return i ? i.pointerEvent : null;\n },\n isEmpty: U,\n isSelected: b,\n setSelected: u,\n subscribe: t\n };\n}, G = (e, n) => typeof n == \"function\" ? n(e) || \"EDIT\" : n || \"EDIT\";\nlet z;\nconst H = new Uint8Array(16);\nfunction F() {\n if (!z && (z = typeof crypto < \"u\" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !z))\n throw new Error(\"crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported\");\n return z(H);\n}\nconst R = [];\nfor (let e = 0; e < 256; ++e)\n R.push((e + 256).toString(16).slice(1));\nfunction J(e, n = 0) {\n return R[e[n + 0]] + R[e[n + 1]] + R[e[n + 2]] + R[e[n + 3]] + \"-\" + R[e[n + 4]] + R[e[n + 5]] + \"-\" + R[e[n + 6]] + R[e[n + 7]] + \"-\" + R[e[n + 8]] + R[e[n + 9]] + \"-\" + R[e[n + 10]] + R[e[n + 11]] + R[e[n + 12]] + R[e[n + 13]] + R[e[n + 14]] + R[e[n + 15]];\n}\nconst Q = typeof crypto < \"u\" && crypto.randomUUID && crypto.randomUUID.bind(crypto), j = {\n randomUUID: Q\n};\nfunction X(e, n, t) {\n if (j.randomUUID && !n && !e)\n return j.randomUUID();\n e = e || {};\n const o = e.random || (e.rng || F)();\n if (o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, n) {\n t = t || 0;\n for (let i = 0; i < 16; ++i)\n n[t + i] = o[i];\n return n;\n }\n return J(o);\n}\nconst Ce = (e) => {\n const { creator: n, updatedBy: t } = e.target, o = e.bodies.reduce((i, p) => [...i, p.creator, p.updatedBy].filter(Boolean), []);\n return [\n n,\n t,\n ...o\n ].filter((i) => i);\n}, we = (e, n, t, o) => ({\n id: X(),\n annotation: e.id,\n created: t || /* @__PURE__ */ new Date(),\n creator: o,\n ...n\n}), Z = (e, n) => {\n const t = new Set(e.bodies.map((o) => o.id));\n return n.bodies.filter((o) => !t.has(o.id));\n}, K = (e, n) => {\n const t = new Set(n.bodies.map((o) => o.id));\n return e.bodies.filter((o) => !t.has(o.id));\n}, ee = (e, n) => n.bodies.map((t) => {\n const o = e.bodies.find((i) => i.id === t.id);\n return { newBody: t, oldBody: o && !x(o, t) ? o : void 0 };\n}).filter(({ oldBody: t }) => t).map(({ oldBody: t, newBody: o }) => ({ oldBody: t, newBody: o })), te = (e, n) => !x(e.target, n.target), M = (e, n) => {\n const t = Z(e, n), o = K(e, n), i = ee(e, n);\n return {\n oldValue: e,\n newValue: n,\n bodiesCreated: t.length > 0 ? t : void 0,\n bodiesDeleted: o.length > 0 ? o : void 0,\n bodiesUpdated: i.length > 0 ? i : void 0,\n targetUpdated: te(e, n) ? { oldTarget: e.target, newTarget: n.target } : void 0\n };\n};\nvar ne = /* @__PURE__ */ ((e) => (e.BODY_ONLY = \"BODY_ONLY\", e.TARGET_ONLY = \"TARGET_ONLY\", e))(ne || {}), T = /* @__PURE__ */ ((e) => (e.LOCAL = \"LOCAL\", e.REMOTE = \"REMOTE\", e))(T || {});\nconst oe = (e, n) => {\n var p, U;\n const { changes: t, origin: o } = n;\n if (!(!e.options.origin || e.options.origin === o))\n return !1;\n if (e.options.ignore) {\n const { ignore: b } = e.options, w = (S) => S && S.length > 0;\n if (!(w(t.created) || w(t.deleted))) {\n const S = (p = t.updated) == null ? void 0 : p.some((g) => w(g.bodiesCreated) || w(g.bodiesDeleted) || w(g.bodiesUpdated)), s = (U = t.updated) == null ? void 0 : U.some((g) => g.targetUpdated);\n if (b === \"BODY_ONLY\" && S && !s || b === \"TARGET_ONLY\" && s && !S)\n return !1;\n }\n }\n if (e.options.annotations) {\n const b = /* @__PURE__ */ new Set([\n ...(t.created || []).map((u) => u.id),\n ...(t.deleted || []).map((u) => u.id),\n ...(t.updated || []).map(({ oldValue: u }) => u.id)\n ]);\n return !!(Array.isArray(e.options.annotations) ? e.options.annotations : [e.options.annotations]).find((u) => b.has(u));\n } else\n return !0;\n}, se = (e, n) => {\n const t = new Set((e.created || []).map((s) => s.id)), o = new Set((e.updated || []).map(({ newValue: s }) => s.id)), i = new Set((n.created || []).map((s) => s.id)), p = new Set((n.deleted || []).map((s) => s.id)), U = new Set((n.updated || []).map(({ oldValue: s }) => s.id)), b = new Set((n.updated || []).filter(({ oldValue: s }) => t.has(s.id) || o.has(s.id)).map(({ oldValue: s }) => s.id)), w = [\n ...(e.created || []).filter((s) => !p.has(s.id)).map((s) => U.has(s.id) ? n.updated.find(({ oldValue: g }) => g.id === s.id).newValue : s),\n ...n.created || []\n ], u = [\n ...(e.deleted || []).filter((s) => !i.has(s.id)),\n ...(n.deleted || []).filter((s) => !t.has(s.id))\n ], S = [\n ...(e.updated || []).filter(({ newValue: s }) => !p.has(s.id)).map((s) => {\n const { oldValue: g, newValue: y } = s;\n if (U.has(y.id)) {\n const A = n.updated.find((O) => O.oldValue.id === y.id).newValue;\n return M(g, A);\n } else\n return s;\n }),\n ...(n.updated || []).filter(({ oldValue: s }) => !b.has(s.id))\n ];\n return { created: w, deleted: u, updated: S };\n}, ie = (e) => e.id !== void 0, ye = () => {\n const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), t = [], o = (d, l = {}) => t.push({ onChange: d, options: l }), i = (d) => {\n const l = t.findIndex((c) => c.onChange == d);\n l > -1 && t.splice(l, 1);\n }, p = (d, l) => {\n const c = {\n origin: d,\n changes: {\n created: l.created || [],\n updated: l.updated || [],\n deleted: l.deleted || []\n },\n state: [...e.values()]\n };\n t.forEach((f) => {\n oe(f, c) && f.onChange(c);\n });\n }, U = (d, l = T.LOCAL) => {\n if (e.get(d.id))\n throw Error(`Cannot add annotation ${d.id} - exists already`);\n e.set(d.id, d), d.bodies.forEach((f) => n.set(f.id, d.id)), p(l, { created: [d] });\n }, b = (d, l) => {\n const c = typeof d == \"string\" ? l : d, f = typeof d == \"string\" ? d : d.id, v = e.get(f);\n if (v) {\n const D = M(v, c);\n return f === c.id ? e.set(f, c) : (e.delete(f), e.set(c.id, c)), v.bodies.forEach((B) => n.delete(B.id)), c.bodies.forEach((B) => n.set(B.id, c.id)), D;\n } else\n console.warn(`Cannot update annotation ${f} - does not exist`);\n }, w = (d, l = T.LOCAL, c = T.LOCAL) => {\n const f = ie(l) ? c : l, v = b(d, l);\n v && p(f, { updated: [v] });\n }, u = (d, l = T.LOCAL) => {\n const c = d.reduce((f, v) => {\n const D = b(v);\n return D ? [...f, D] : f;\n }, []);\n c.length > 0 && p(l, { updated: c });\n }, S = (d, l = T.LOCAL) => {\n const c = e.get(d.annotation);\n if (c) {\n const f = {\n ...c,\n bodies: [...c.bodies, d]\n };\n e.set(c.id, f), n.set(d.id, f.id), p(l, { updated: [{\n oldValue: c,\n newValue: f,\n bodiesCreated: [d]\n }] });\n } else\n console.warn(`Attempt to add body to missing annotation: ${d.annotation}`);\n }, s = () => [...e.values()], g = (d = T.LOCAL) => {\n const l = [...e.values()];\n e.clear(), n.clear(), p(d, { deleted: l });\n }, y = (d, l = !0, c = T.LOCAL) => {\n if (l) {\n const f = [...e.values()];\n e.clear(), n.clear(), d.forEach((v) => {\n e.set(v.id, v), v.bodies.forEach((D) => n.set(D.id, v.id));\n }), p(c, { created: d, deleted: f });\n } else {\n const f = d.reduce((v, D) => {\n const B = e.get(D.id);\n return B ? [...v, B] : v;\n }, []);\n if (f.length > 0)\n throw Error(`Bulk insert would overwrite the following annotations: ${f.map((v) => v.id).join(\", \")}`);\n d.forEach((v) => {\n e.set(v.id, v), v.bodies.forEach((D) => n.set(D.id, v.id));\n }), p(c, { created: d });\n }\n }, A = (d) => {\n const l = typeof d == \"string\" ? d : d.id, c = e.get(l);\n if (c)\n return e.delete(l), c.bodies.forEach((f) => n.delete(f.id)), c;\n console.warn(`Attempt to delete missing annotation: ${l}`);\n }, O = (d, l = T.LOCAL) => {\n const c = A(d);\n c && p(l, { deleted: [c] });\n }, C = (d, l = T.LOCAL) => {\n const c = d.reduce((f, v) => {\n const D = A(v);\n return D ? [...f, D] : f;\n }, []);\n c.length > 0 && p(l, { deleted: c });\n }, a = (d, l = T.LOCAL) => {\n const c = e.get(d.annotation);\n if (c) {\n const f = c.bodies.find((v) => v.id === d.id);\n if (f) {\n n.delete(f.id);\n const v = {\n ...c,\n bodies: c.bodies.filter((B) => B.id !== d.id)\n };\n e.set(c.id, v), p(l, { updated: [{\n oldValue: c,\n newValue: v,\n bodiesDeleted: [f]\n }] });\n } else\n console.warn(`Attempt to delete missing body ${d.id} from annotation ${d.annotation}`);\n } else\n console.warn(`Attempt to delete body from missing annotation ${d.annotation}`);\n }, m = (d) => {\n const l = e.get(d);\n return l ? { ...l } : void 0;\n }, r = (d) => {\n const l = n.get(d);\n if (l) {\n const f = m(l).bodies.find((v) => v.id === d);\n if (f)\n return f;\n console.error(`Store integrity error: body ${d} in index, but not in annotation`);\n } else\n console.warn(`Attempt to retrieve missing body: ${d}`);\n }, E = (d, l) => {\n if (d.annotation !== l.annotation)\n throw \"Annotation integrity violation: annotation ID must be the same when updating bodies\";\n const c = e.get(d.annotation);\n if (c) {\n const f = c.bodies.find((D) => D.id === d.id), v = {\n ...c,\n bodies: c.bodies.map((D) => D.id === f.id ? l : D)\n };\n return e.set(c.id, v), f.id !== l.id && (n.delete(f.id), n.set(l.id, v.id)), {\n oldValue: c,\n newValue: v,\n bodiesUpdated: [{ oldBody: f, newBody: l }]\n };\n } else\n console.warn(`Attempt to add body to missing annotation ${d.annotation}`);\n }, h = (d, l, c = T.LOCAL) => {\n const f = E(d, l);\n f && p(c, { updated: [f] });\n }, L = (d, l = T.LOCAL) => {\n const c = d.map((f) => E({ id: f.id, annotation: f.annotation }, f)).filter(Boolean);\n p(l, { updated: c });\n }, I = (d) => {\n const l = e.get(d.annotation);\n if (l) {\n const c = {\n ...l,\n target: {\n ...l.target,\n ...d\n }\n };\n return e.set(l.id, c), {\n oldValue: l,\n newValue: c,\n targetUpdated: {\n oldTarget: l.target,\n newTarget: d\n }\n };\n } else\n console.warn(`Attempt to update target on missing annotation: ${d.annotation}`);\n };\n return {\n addAnnotation: U,\n addBody: S,\n all: s,\n bulkAddAnnotation: y,\n bulkDeleteAnnotation: C,\n bulkUpdateAnnotation: u,\n bulkUpdateBodies: L,\n bulkUpdateTargets: (d, l = T.LOCAL) => {\n const c = d.map((f) => I(f)).filter(Boolean);\n c.length > 0 && p(l, { updated: c });\n },\n clear: g,\n deleteAnnotation: O,\n deleteBody: a,\n getAnnotation: m,\n getBody: r,\n observe: o,\n unobserve: i,\n updateAnnotation: w,\n updateBody: h,\n updateTarget: (d, l = T.LOCAL) => {\n const c = I(d);\n c && p(l, { updated: [c] });\n }\n };\n}, Ue = (e) => ({\n ...e,\n subscribe: (t) => {\n const o = (i) => t(i.state);\n return e.observe(o), t(e.all()), () => e.unobserve(o);\n }\n});\nlet P = () => ({\n emit(e, ...n) {\n for (let t = 0, o = this.events[e] || [], i = o.length; t < i; t++)\n o[t](...n);\n },\n events: {},\n on(e, n) {\n var t;\n return ((t = this.events)[e] || (t[e] = [])).push(n), () => {\n var o;\n this.events[e] = (o = this.events[e]) == null ? void 0 : o.filter((i) => n !== i);\n };\n }\n});\nconst de = 250, Le = (e) => {\n const n = P(), t = [];\n let o = -1, i = !1, p = 0;\n const U = (r) => {\n if (!i) {\n const { changes: E } = r, h = performance.now();\n if (h - p > de)\n t.splice(o + 1), t.push(E), o = t.length - 1;\n else {\n const L = t.length - 1;\n t[L] = se(t[L], E);\n }\n p = h;\n }\n i = !1;\n };\n e.observe(U, { origin: T.LOCAL });\n const b = (r) => r && r.length > 0 && e.bulkDeleteAnnotation(r), w = (r) => r && r.length > 0 && e.bulkAddAnnotation(r, !1), u = (r) => r && r.length > 0 && e.bulkUpdateAnnotation(r.map(({ oldValue: E }) => E)), S = (r) => r && r.length > 0 && e.bulkUpdateAnnotation(r.map(({ newValue: E }) => E)), s = (r) => r && r.length > 0 && e.bulkAddAnnotation(r, !1), g = (r) => r && r.length > 0 && e.bulkDeleteAnnotation(r);\n return {\n canRedo: () => t.length - 1 > o,\n canUndo: () => o > -1,\n destroy: () => e.unobserve(U),\n on: (r, E) => n.on(r, E),\n redo: () => {\n if (t.length - 1 > o) {\n i = !0;\n const { created: r, updated: E, deleted: h } = t[o + 1];\n w(r), S(E), g(h), n.emit(\"redo\", t[o + 1]), o += 1;\n }\n },\n undo: () => {\n if (o > -1) {\n i = !0;\n const { created: r, updated: E, deleted: h } = t[o];\n b(r), u(E), s(h), n.emit(\"undo\", t[o]), o -= 1;\n }\n }\n };\n}, Se = () => {\n const { subscribe: e, set: n } = _([]);\n return {\n subscribe: e,\n set: n\n };\n}, Oe = (e, n, t, o) => {\n const { store: i, selection: p, hover: U, viewport: b } = e, w = /* @__PURE__ */ new Map();\n let u = [], S, s;\n const g = (a, m) => {\n w.has(a) ? w.get(a).push(m) : w.set(a, [m]);\n }, y = (a, m) => {\n const r = w.get(a);\n r && r.indexOf(m) > 0 && r.splice(r.indexOf(m), 1);\n }, A = (a, m, r) => {\n w.has(a) && setTimeout(() => {\n w.get(a).forEach((E) => {\n if (t) {\n const h = Array.isArray(m) ? m.map((I) => t.serialize(I)) : t.serialize(m), L = r ? r instanceof PointerEvent ? r : t.serialize(r) : void 0;\n E(h, L);\n } else\n E(m, r);\n });\n }, 1);\n }, O = () => {\n const { selected: a } = p, m = (a || []).map(({ id: r }) => i.getAnnotation(r));\n m.forEach((r) => {\n const E = u.find((h) => h.id === r.id);\n (!E || !x(E, r)) && A(\"updateAnnotation\", r, E);\n }), u = u.map((r) => {\n const E = m.find(({ id: h }) => h === r.id);\n return E || r;\n });\n };\n p.subscribe(({ selected: a }) => {\n if (!(u.length === 0 && a.length === 0)) {\n if (u.length === 0 && a.length > 0)\n u = a.map(({ id: m }) => i.getAnnotation(m));\n else if (u.length > 0 && a.length === 0)\n u.forEach((m) => {\n const r = i.getAnnotation(m.id);\n r && !x(r, m) && A(\"updateAnnotation\", r, m);\n }), u = [];\n else {\n const m = new Set(u.map((h) => h.id)), r = new Set(a.map(({ id: h }) => h));\n u.filter((h) => !r.has(h.id)).forEach((h) => {\n const L = i.getAnnotation(h.id);\n L && !x(L, h) && A(\"updateAnnotation\", L, h);\n }), u = [\n // Remove annotations that were deselected\n ...u.filter((h) => r.has(h.id)),\n // Add editable annotations that were selected\n ...a.filter(({ id: h }) => !m.has(h)).map(({ id: h }) => i.getAnnotation(h))\n ];\n }\n A(\"selectionChanged\", u);\n }\n }), U.subscribe((a) => {\n !S && a ? A(\"mouseEnterAnnotation\", i.getAnnotation(a)) : S && !a ? A(\"mouseLeaveAnnotation\", i.getAnnotation(S)) : S && a && (A(\"mouseLeaveAnnotation\", i.getAnnotation(S)), A(\"mouseEnterAnnotation\", i.getAnnotation(a))), S = a;\n }), b == null || b.subscribe((a) => A(\"viewportIntersect\", a.map((m) => i.getAnnotation(m)))), i.observe((a) => {\n o && (s && clearTimeout(s), s = setTimeout(O, 1e3));\n const { created: m, deleted: r } = a.changes;\n (m || []).forEach((h) => A(\"createAnnotation\", h)), (r || []).forEach((h) => A(\"deleteAnnotation\", h)), (a.changes.updated || []).filter((h) => [\n ...h.bodiesCreated || [],\n ...h.bodiesDeleted || [],\n ...h.bodiesUpdated || []\n ].length > 0).forEach(({ oldValue: h, newValue: L }) => {\n const I = u.find((N) => N.id === h.id) || h;\n u = u.map((N) => N.id === h.id ? L : N), A(\"updateAnnotation\", L, I);\n });\n }, { origin: T.LOCAL }), i.observe((a) => {\n if (u) {\n const m = new Set(u.map((E) => E.id)), r = (a.changes.updated || []).filter(({ newValue: E }) => m.has(E.id)).map(({ newValue: E }) => E);\n r.length > 0 && (u = u.map((E) => {\n const h = r.find((L) => L.id === E.id);\n return h || E;\n }));\n }\n }, { origin: T.REMOTE });\n const C = (a) => (m) => {\n const { created: r, deleted: E, updated: h } = m;\n (r || []).forEach((L) => A(\"createAnnotation\", L)), (E || []).forEach((L) => A(\"deleteAnnotation\", L)), a ? (h || []).forEach((L) => A(\"updateAnnotation\", L.oldValue, L.newValue)) : (h || []).forEach((L) => A(\"updateAnnotation\", L.newValue, L.oldValue));\n };\n return n.on(\"undo\", C(!0)), n.on(\"redo\", C(!1)), { on: g, off: y, emit: A };\n}, Te = (e) => (n) => n.map((t) => e.serialize(t)), re = (e) => (n) => n.reduce((t, o) => {\n const { parsed: i, error: p } = e.parse(o);\n return p ? {\n parsed: t.parsed,\n failed: [...t.failed, o]\n } : i ? {\n parsed: [...t.parsed, i],\n failed: t.failed\n } : {\n ...t\n };\n}, { parsed: [], failed: [] }), De = (e, n, t) => {\n const { store: o, selection: i } = e, p = (C) => {\n if (t) {\n const { parsed: a, error: m } = t.parse(C);\n a ? o.addAnnotation(a, T.REMOTE) : console.error(m);\n } else\n o.addAnnotation(C, T.REMOTE);\n }, U = () => i.clear(), b = () => o.clear(), w = (C) => {\n const a = o.getAnnotation(C);\n return t && a ? t.serialize(a) : a;\n }, u = () => t ? o.all().map(t.serialize) : o.all(), S = () => {\n var m;\n const a = (((m = i.selected) == null ? void 0 : m.map((r) => r.id)) || []).map((r) => o.getAnnotation(r)).filter(Boolean);\n return t ? a.map(t.serialize) : a;\n }, s = (C) => fetch(C).then((a) => a.json()).then((a) => (y(a), a)), g = (C) => {\n if (typeof C == \"string\") {\n const a = o.getAnnotation(C);\n if (o.deleteAnnotation(C), a)\n return t ? t.serialize(a) : a;\n } else {\n const a = t ? t.parse(C).parsed : C;\n if (a)\n return o.deleteAnnotation(a), C;\n }\n }, y = (C) => {\n if (t) {\n const { parsed: a, failed: m } = re(t)(C);\n m.length > 0 && console.warn(`Discarded ${m.length} invalid annotations`, m), o.bulkAddAnnotation(a, !0, T.REMOTE);\n } else\n o.bulkAddAnnotation(C, !0, T.REMOTE);\n }, A = (C) => {\n C ? i.setSelected(C) : i.clear();\n }, O = (C) => {\n if (t) {\n const a = t.parse(C).parsed, m = t.serialize(o.getAnnotation(a.id));\n return o.updateAnnotation(a), m;\n } else {\n const a = o.getAnnotation(C.id);\n return o.updateAnnotation(C), a;\n }\n };\n return {\n addAnnotation: p,\n cancelSelected: U,\n canRedo: n.canRedo,\n canUndo: n.canUndo,\n clearAnnotations: b,\n getAnnotationById: w,\n getAnnotations: u,\n getSelected: S,\n loadAnnotations: s,\n redo: n.redo,\n removeAnnotation: g,\n setAnnotations: y,\n setSelected: A,\n undo: n.undo,\n updateAnnotation: O\n };\n};\nlet ae = (e) => crypto.getRandomValues(new Uint8Array(e)), ce = (e, n, t) => {\n let o = (2 << Math.log(e.length - 1) / Math.LN2) - 1, i = -~(1.6 * o * n / e.length);\n return (p = n) => {\n let U = \"\";\n for (; ; ) {\n let b = t(i), w = i;\n for (; w--; )\n if (U += e[b[w] & o] || \"\", U.length === p)\n return U;\n }\n };\n}, le = (e, n = 21) => ce(e, n, ae), ue = (e = 21) => crypto.getRandomValues(new Uint8Array(e)).reduce((n, t) => (t &= 63, t < 36 ? n += t.toString(36) : t < 62 ? n += (t - 26).toString(36).toUpperCase() : t > 62 ? n += \"-\" : n += \"_\", n), \"\");\nconst Re = () => ({ isGuest: !0, id: le(\"1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_\", 20)() }), fe = (e) => {\n const n = JSON.stringify(e);\n let t = 0;\n for (let o = 0, i = n.length; o < i; o++) {\n let p = n.charCodeAt(o);\n t = (t << 5) - t + p, t |= 0;\n }\n return `${t}`;\n}, pe = (e) => e ? typeof e == \"object\" ? { ...e } : e : void 0, Be = (e, n) => (Array.isArray(e) ? e : [e]).map((t) => {\n const { id: o, type: i, purpose: p, value: U, created: b, creator: w, ...u } = t;\n return {\n id: o || `temp-${fe(t)}`,\n annotation: n,\n type: i,\n purpose: p,\n value: U,\n created: b ? new Date(b) : void 0,\n creator: pe(w),\n ...u\n };\n}), xe = (e) => e.map((n) => {\n var o, i;\n const t = { ...n };\n return delete t.annotation, (o = t.id) != null && o.startsWith(\"temp-\") && delete t.id, { ...t, created: (i = t.created) == null ? void 0 : i.toISOString() };\n}), ge = [\n \"#ff7c00\",\n // orange\n \"#1ac938\",\n // green\n \"#e8000b\",\n // red\n \"#8b2be2\",\n // purple\n \"#9f4800\",\n // brown\n \"#f14cc1\",\n // pink\n \"#ffc400\",\n // khaki\n \"#00d7ff\",\n // cyan\n \"#023eff\"\n // blue\n], he = () => {\n const e = [...ge];\n return { assignRandomColor: () => {\n const o = Math.floor(Math.random() * e.length), i = e[o];\n return e.splice(o, 1), i;\n }, releaseColor: (o) => e.push(o) };\n}, me = () => {\n const e = he();\n return { addUser: (o, i) => {\n const p = e.assignRandomColor();\n return {\n label: i.name || i.id,\n avatar: i.avatar,\n color: p\n };\n }, removeUser: (o) => e.releaseColor(o.appearance.color) };\n}, Ae = (e, n) => e.every((t) => e.includes(t)) && n.every((t) => e.includes(t)), Ie = ue(), ke = (e = me()) => {\n const n = P(), t = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), i = (s, g) => {\n if (t.has(s)) {\n console.warn(\"Attempt to add user that is already present\", s, g);\n return;\n }\n const y = e.addUser(s, g);\n t.set(s, {\n ...g,\n presenceKey: s,\n appearance: y\n });\n }, p = (s) => {\n const g = t.get(s);\n if (!g) {\n console.warn(\"Attempt to remove user that is not present\", s);\n return;\n }\n e.removeUser(g), t.delete(s);\n }, U = (s) => {\n const g = new Set(s.map((O) => O.presenceKey)), y = s.filter(({ presenceKey: O }) => !t.has(O)), A = Array.from(t.values()).filter((O) => !g.has(O.presenceKey));\n y.forEach(({ presenceKey: O, user: C }) => i(O, C)), A.forEach((O) => {\n const { presenceKey: C } = O;\n o.has(C) && n.emit(\"selectionChange\", O, null), p(C);\n }), (y.length > 0 || A.length > 0) && n.emit(\"presence\", u());\n }, b = (s, g) => {\n const y = t.get(s);\n if (!y) {\n console.warn(\"Activity notification from user that is not present\");\n return;\n }\n const A = o.get(s);\n (!A || !Ae(A, g)) && (o.set(s, g), n.emit(\"selectionChange\", y, g));\n }, w = (s, g) => {\n const y = t.get(s);\n if (!y) {\n console.warn(\"Selection change for user that is not present\", s);\n return;\n }\n g ? o.set(s, g) : o.delete(s), n.emit(\"selectionChange\", y, g);\n }, u = () => [...Array.from(t.values())];\n return {\n getPresentUsers: u,\n notifyActivity: b,\n on: (s, g) => n.on(s, g),\n syncUsers: U,\n updateSelection: w\n };\n};\nexport {\n ne as Ignore,\n T as Origin,\n Ie as PRESENCE_KEY,\n q as PointerSelectAction,\n Re as createAnonymousGuest,\n De as createBaseAnnotator,\n we as createBody,\n me as createDefaultAppearenceProvider,\n be as createHoverState,\n Oe as createLifecyleObserver,\n ke as createPresenceState,\n ve as createSelectionState,\n ye as createStore,\n Le as createUndoStack,\n Se as createViewportState,\n he as defaultColorProvider,\n M as diffAnnotations,\n Ce as getContributors,\n se as mergeChanges,\n G as onPointerSelect,\n re as parseAll,\n Be as parseW3CBodies,\n pe as parseW3CUser,\n Te as serializeAll,\n xe as serializeW3CBodies,\n oe as shouldNotify,\n Ue as toSvelteStore\n};\n//# sourceMappingURL=annotorious-core.es.js.map\n"],"names":["q","e","z","H","F","R","J","n","Q","j","X","t","o","i","we","T","Ue","ae","ce","p","U","b","w","le","ue","Re","ge","he"],"mappings":"AA2EG,IAACA,IAAqB,kBAACC,OAAOA,EAAE,OAAO,QAAQA,EAAE,SAAS,UAAUA,EAAE,OAAO,QAAQA,IAAID,KAAK,EAAE;AA4CnG,IAAIE;AACJ,MAAMC,IAAI,IAAI,WAAW,EAAE;AAC3B,SAASC,IAAI;AACX,MAAI,CAACF,MAAMA,IAAI,OAAO,SAAS,OAAO,OAAO,mBAAmB,OAAO,gBAAgB,KAAK,MAAM,GAAG,CAACA;AACpG,UAAM,IAAI,MAAM,0GAA0G;AAC5H,SAAOA,EAAEC,CAAC;AACZ;AACA,MAAME,IAAI,CAAA;AACV,SAASJ,IAAI,GAAGA,IAAI,KAAK,EAAEA;AACzB,EAAAI,EAAE,MAAMJ,IAAI,KAAK,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC;AACxC,SAASK,EAAEL,GAAGM,IAAI,GAAG;AACnB,SAAOF,EAAEJ,EAAEM,IAAI,CAAC,CAAC,IAAIF,EAAEJ,EAAEM,IAAI,CAAC,CAAC,IAAIF,EAAEJ,EAAEM,IAAI,CAAC,CAAC,IAAIF,EAAEJ,EAAEM,IAAI,CAAC,CAAC,IAAI,MAAMF,EAAEJ,EAAEM,IAAI,CAAC,CAAC,IAAIF,EAAEJ,EAAEM,IAAI,CAAC,CAAC,IAAI,MAAMF,EAAEJ,EAAEM,IAAI,CAAC,CAAC,IAAIF,EAAEJ,EAAEM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AAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAEF,GAAGC,IAAK,MAAM;AACZ,QAAM1B,IAAI,CAAC,GAAGyB,CAAE;AAChB,SAAO,EAAE,mBAAmB,MAAM;AAChC,UAAM,IAAI,KAAK,MAAM,KAAK,OAAM,IAAKzB,EAAE,MAAM,GAAGY,IAAIZ,EAAE,CAAC;AACvD,WAAOA,EAAE,OAAO,GAAG,CAAC,GAAGY;AAAA,EAC3B,GAAK,cAAc,CAAC,MAAMZ,EAAE,KAAK,CAAC;AAClC;AAUuFuB,EAAI;"}
@@ -1,40 +1,45 @@
1
- import { SvelteComponent as g, init as b, safe_not_equal as h, empty as k, insert as w, transition_in as l, transition_out as c, check_outros as A, detach as O, create_slot as v, update_slot_base as y, get_all_dirty_from_scope as C, get_slot_changes as q, group_outros as D, setContext as m } from "./annotorious-svelte.es6.js";
1
+ import { safe_not_equal as g, create_slot as b, update_slot_base as h, get_all_dirty_from_scope as k, get_slot_changes as w } from "./annotorious-svelte.es6.js";
2
+ import { empty as A, insert as O, detach as v } from "./annotorious-svelte.es7.js";
3
+ import { transition_in as s, transition_out as c, check_outros as C, group_outros as q } from "./annotorious-svelte.es8.js";
4
+ import { setContext as _ } from "./annotorious-svelte.es9.js";
5
+ import { SvelteComponent as y, init as D } from "./annotorious-svelte.es10.js";
6
+ import "./annotorious-svelte.es11.js";
2
7
  import { toSvelteStore as N } from "./annotorious-svelte.es3.js";
3
- import { createOSDAnnotator as j } from "@annotorious/openseadragon";
4
- function d(s) {
5
- let n;
6
- const o = (
8
+ import { createOSDAnnotator as U } from "@annotorious/openseadragon";
9
+ function d(f) {
10
+ let o;
11
+ const n = (
7
12
  /*#slots*/
8
- s[4].default
9
- ), t = v(
10
- o,
11
- s,
13
+ f[4].default
14
+ ), t = b(
15
+ n,
16
+ f,
12
17
  /*$$scope*/
13
- s[3],
18
+ f[3],
14
19
  null
15
20
  );
16
21
  return {
17
22
  c() {
18
23
  t && t.c();
19
24
  },
20
- m(e, i) {
21
- t && t.m(e, i), n = !0;
25
+ m(e, r) {
26
+ t && t.m(e, r), o = !0;
22
27
  },
23
- p(e, i) {
24
- t && t.p && (!n || i & /*$$scope*/
25
- 8) && y(
28
+ p(e, r) {
29
+ t && t.p && (!o || r & /*$$scope*/
30
+ 8) && h(
26
31
  t,
27
- o,
32
+ n,
28
33
  e,
29
34
  /*$$scope*/
30
35
  e[3],
31
- n ? q(
32
- o,
36
+ o ? w(
37
+ n,
33
38
  /*$$scope*/
34
39
  e[3],
35
- i,
40
+ r,
36
41
  null
37
- ) : C(
42
+ ) : k(
38
43
  /*$$scope*/
39
44
  e[3]
40
45
  ),
@@ -42,71 +47,71 @@ function d(s) {
42
47
  );
43
48
  },
44
49
  i(e) {
45
- n || (l(t, e), n = !0);
50
+ o || (s(t, e), o = !0);
46
51
  },
47
52
  o(e) {
48
- c(t, e), n = !1;
53
+ c(t, e), o = !1;
49
54
  },
50
55
  d(e) {
51
56
  t && t.d(e);
52
57
  }
53
58
  };
54
59
  }
55
- function z(s) {
56
- let n, o, t = (
60
+ function j(f) {
61
+ let o, n, t = (
57
62
  /*viewer*/
58
- s[0] && d(s)
63
+ f[0] && d(f)
59
64
  );
60
65
  return {
61
66
  c() {
62
- t && t.c(), n = k();
67
+ t && t.c(), o = A();
63
68
  },
64
- m(e, i) {
65
- t && t.m(e, i), w(e, n, i), o = !0;
69
+ m(e, r) {
70
+ t && t.m(e, r), O(e, o, r), n = !0;
66
71
  },
67
- p(e, [i]) {
72
+ p(e, [r]) {
68
73
  /*viewer*/
69
- e[0] ? t ? (t.p(e, i), i & /*viewer*/
70
- 1 && l(t, 1)) : (t = d(e), t.c(), l(t, 1), t.m(n.parentNode, n)) : t && (D(), c(t, 1, 1, () => {
74
+ e[0] ? t ? (t.p(e, r), r & /*viewer*/
75
+ 1 && s(t, 1)) : (t = d(e), t.c(), s(t, 1), t.m(o.parentNode, o)) : t && (q(), c(t, 1, 1, () => {
71
76
  t = null;
72
- }), A());
77
+ }), C());
73
78
  },
74
79
  i(e) {
75
- o || (l(t), o = !0);
80
+ n || (s(t), n = !0);
76
81
  },
77
82
  o(e) {
78
- c(t), o = !1;
83
+ c(t), n = !1;
79
84
  },
80
85
  d(e) {
81
- t && t.d(e), e && O(n);
86
+ e && v(o), t && t.d(e);
82
87
  }
83
88
  };
84
89
  }
85
- function B(s, n, o) {
86
- let { $$slots: t = {}, $$scope: e } = n, { viewer: i } = n, { opts: f = {} } = n, { anno: a = void 0 } = n;
87
- const S = (r) => {
88
- if (r) {
89
- const u = j(r, f), p = N(u.state.store), _ = {
90
+ function z(f, o, n) {
91
+ let { $$slots: t = {}, $$scope: e } = o, { viewer: r } = o, { opts: l = {} } = o, { anno: a = void 0 } = o;
92
+ const p = (i) => {
93
+ if (i) {
94
+ const u = U(i, l), S = N(u.state.store), m = {
90
95
  ...u,
91
- state: { ...u.state, store: p }
96
+ state: { ...u.state, store: S }
92
97
  };
93
- m("anno", _), m("viewer", r), o(1, a = _);
98
+ _("anno", m), _("viewer", i), n(1, a = m);
94
99
  }
95
100
  };
96
- return s.$$set = (r) => {
97
- "viewer" in r && o(0, i = r.viewer), "opts" in r && o(2, f = r.opts), "anno" in r && o(1, a = r.anno), "$$scope" in r && o(3, e = r.$$scope);
98
- }, s.$$.update = () => {
99
- s.$$.dirty & /*viewer*/
100
- 1 && S(i);
101
- }, [i, a, f, e, t];
101
+ return f.$$set = (i) => {
102
+ "viewer" in i && n(0, r = i.viewer), "opts" in i && n(2, l = i.opts), "anno" in i && n(1, a = i.anno), "$$scope" in i && n(3, e = i.$$scope);
103
+ }, f.$$.update = () => {
104
+ f.$$.dirty & /*viewer*/
105
+ 1 && p(r);
106
+ }, [r, a, l, e, t];
102
107
  }
103
- class E extends g {
104
- constructor(n) {
105
- super(), b(this, n, B, z, h, { viewer: 0, opts: 2, anno: 1 });
108
+ class B extends y {
109
+ constructor(o) {
110
+ super(), D(this, o, z, j, g, { viewer: 0, opts: 2, anno: 1 });
106
111
  }
107
112
  }
108
- const I = E;
113
+ const M = B;
109
114
  export {
110
- I as default
115
+ M as default
111
116
  };
112
117
  //# sourceMappingURL=annotorious-svelte.es4.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-svelte.es4.js","sources":["../src/osd/OpenSeadragonAnnotator.svelte"],"sourcesContent":["<script lang=\"ts\">\n import { setContext } from 'svelte';\n import { SvelteAnnotator, SvelteAnnotatorState, toSvelteStore } from '@annotorious/core';\n import { createOSDAnnotator, ImageAnnotation } from '@annotorious/openseadragon';\n import type OpenSeadragon from 'openseadragon';\n\n /** props **/\n export let viewer: OpenSeadragon.Viewer;\n export let opts = {};\n export let anno: SvelteAnnotator<ImageAnnotation> = undefined;\n\n $: init(viewer);\n\n const init = (viewer: OpenSeadragon.Viewer) => {\n if (viewer) {\n const annotator = createOSDAnnotator(viewer, opts);\n\n // Wrap the store for Svelte reactivity\n const svelteStore = toSvelteStore(annotator.state.store);\n\n const shim = {\n ...annotator,\n state: {\n ...annotator.state,\n store: svelteStore\n } as SvelteAnnotatorState<ImageAnnotation>\n } as SvelteAnnotator<ImageAnnotation>\n\n setContext('anno', shim);\n setContext('viewer', viewer);\n\n anno = shim;\n }\n }\n</script>\n\n{#if viewer}\n <slot />\n{/if}\n"],"names":["ctx","create_if_block","viewer","$$props","opts","anno","init","annotator","createOSDAnnotator","svelteStore","toSvelteStore","shim","setContext","$$invalidate"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAoCKA,EAAM,CAAA,KAAAC,EAAAD,CAAA;AAAA;;;;;;;;;;MAANA,EAAM,CAAA;;;;;;;;;;;;;;;;;6CA7BE,QAAAE,EAA4B,IAAAC,KAC5B,MAAAC,IAAI,GAAA,IAAAD,GACJ,EAAA,MAAAE,IAAyC,OAAS,IAAAF;AAIvD,QAAAG,IAAQ,CAAAJ,MAA4B;QACpCA,GAAM;AACF,YAAAK,IAAYC,EAAmBN,GAAQE,CAAI,GAG3CK,IAAcC,EAAcH,EAAU,MAAM,KAAK,GAEjDI,IAAI;AAAA,WACLJ;AAAA,QACH,YACKA,EAAU,OACb,OAAOE,EAAA;AAAA;AAIX,MAAAG,EAAW,QAAQD,CAAI,GACvBC,EAAW,UAAUV,CAAM,GAE3BW,EAAA,GAAAR,IAAOM,CAAI;AAAA;;;;;;SApBZL,EAAKJ,CAAM;AAAA;;;;;;;;"}
1
+ {"version":3,"file":"annotorious-svelte.es4.js","sources":["../src/osd/OpenSeadragonAnnotator.svelte"],"sourcesContent":["<script lang=\"ts\">\n import { setContext } from 'svelte';\n import { SvelteAnnotator, SvelteAnnotatorState, toSvelteStore } from '@annotorious/core';\n import { createOSDAnnotator, ImageAnnotation } from '@annotorious/openseadragon';\n import type OpenSeadragon from 'openseadragon';\n\n /** props **/\n export let viewer: OpenSeadragon.Viewer;\n export let opts = {};\n export let anno: SvelteAnnotator<ImageAnnotation> = undefined;\n\n $: init(viewer);\n\n const init = (viewer: OpenSeadragon.Viewer) => {\n if (viewer) {\n const annotator = createOSDAnnotator(viewer, opts);\n\n // Wrap the store for Svelte reactivity\n const svelteStore = toSvelteStore(annotator.state.store);\n\n const shim = {\n ...annotator,\n state: {\n ...annotator.state,\n store: svelteStore\n } as SvelteAnnotatorState<ImageAnnotation>\n } as SvelteAnnotator<ImageAnnotation>\n\n setContext('anno', shim);\n setContext('viewer', viewer);\n\n anno = shim;\n }\n }\n</script>\n\n{#if viewer}\n <slot />\n{/if}\n"],"names":["ctx","create_if_block","viewer","$$props","opts","anno","init","annotator","createOSDAnnotator","svelteStore","toSvelteStore","shim","setContext","$$invalidate"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAoCKA,EAAM,CAAA,KAAAC,EAAAD,CAAA;AAAA;;;;;;;;;;MAANA,EAAM,CAAA;;;;;;;;;;;;;;;;;6CA7BE,QAAAE,EAA4B,IAAAC,KAC5B,MAAAC,IAAI,GAAA,IAAAD,GACJ,EAAA,MAAAE,IAAyC,OAAS,IAAAF;AAIvD,QAAAG,IAAQ,CAAAJ,MAA4B;QACpCA,GAAM;AACF,YAAAK,IAAYC,EAAmBN,GAAQE,CAAI,GAG3CK,IAAcC,EAAcH,EAAU,MAAM,KAAK,GAEjDI,IAAI;AAAA,WACLJ;AAAA,QACH,YACKA,EAAU,OACb,OAAOE,EAAA;AAAA;AAIX,MAAAG,EAAW,QAAQD,CAAI,GACvBC,EAAW,UAAUV,CAAM,GAE3BW,EAAA,GAAAR,IAAOM,CAAI;AAAA;;;;;;SApBZL,EAAKJ,CAAM;AAAA;;;;;;;;"}
@@ -1,19 +1,23 @@
1
- import { SvelteComponent as H, init as I, safe_not_equal as T, empty as X, insert as y, noop as v, detach as P, component_subscribe as Y, onMount as q, element as x, text as G, attr as L, append as R, action_destroyer as U, listen as _, set_data as z, is_function as B, run_all as F } from "./annotorious-svelte.es6.js";
2
- import { draggable as J } from "./annotorious-svelte.es7.js";
1
+ import { safe_not_equal as H, noop as v, component_subscribe as I, action_destroyer as T, is_function as X, run_all as Y } from "./annotorious-svelte.es6.js";
2
+ import { empty as q, insert as y, detach as P, element as x, text as G, attr as L, append as R, listen as _, set_data as U } from "./annotorious-svelte.es7.js";
3
+ import { onMount as z } from "./annotorious-svelte.es9.js";
4
+ import { SvelteComponent as B, init as F } from "./annotorious-svelte.es10.js";
5
+ import "./annotorious-svelte.es11.js";
6
+ import { draggable as J } from "./annotorious-svelte.es13.js";
3
7
  import b from "openseadragon";
4
- import "./annotorious-svelte.es8.js";
8
+ import "./annotorious-svelte.es14.js";
5
9
  function w(n) {
6
10
  let o, e = (
7
11
  /*$selection*/
8
12
  n[0].selected.map(S).join(", ") + ""
9
- ), t, s, a, d;
13
+ ), t, s, r, d;
10
14
  return {
11
15
  c() {
12
16
  o = x("div"), t = G(e), L(o, "class", "a9s-popup a9s-osd-popup svelte-1xuxeat");
13
17
  },
14
- m(r, l) {
15
- y(r, o, l), R(o, t), a || (d = [
16
- U(s = J.call(null, o, {
18
+ m(a, l) {
19
+ y(a, o, l), R(o, t), r || (d = [
20
+ T(s = J.call(null, o, {
17
21
  position: { x: (
18
22
  /*left*/
19
23
  n[1]
@@ -34,24 +38,24 @@ function w(n) {
34
38
  /*onDragEnd*/
35
39
  n[5]
36
40
  )
37
- ], a = !0);
41
+ ], r = !0);
38
42
  },
39
- p(r, l) {
43
+ p(a, l) {
40
44
  l & /*$selection*/
41
45
  1 && e !== (e = /*$selection*/
42
- r[0].selected.map(S).join(", ") + "") && z(t, e), s && B(s.update) && l & /*left, top*/
46
+ a[0].selected.map(S).join(", ") + "") && U(t, e), s && X(s.update) && l & /*left, top*/
43
47
  6 && s.update.call(null, {
44
48
  position: { x: (
45
49
  /*left*/
46
- r[1]
50
+ a[1]
47
51
  ), y: (
48
52
  /*top*/
49
- r[2]
53
+ a[2]
50
54
  ) }
51
55
  });
52
56
  },
53
- d(r) {
54
- r && P(o), a = !1, F(d);
57
+ d(a) {
58
+ a && P(o), r = !1, Y(d);
55
59
  }
56
60
  };
57
61
  }
@@ -62,7 +66,7 @@ function K(n) {
62
66
  );
63
67
  return {
64
68
  c() {
65
- e && e.c(), o = X();
69
+ e && e.c(), o = q();
66
70
  },
67
71
  m(t, s) {
68
72
  e && e.m(t, s), y(t, o, s);
@@ -74,53 +78,53 @@ function K(n) {
74
78
  i: v,
75
79
  o: v,
76
80
  d(t) {
77
- e && e.d(t), t && P(o);
81
+ t && P(o), e && e.d(t);
78
82
  }
79
83
  };
80
84
  }
81
85
  const S = (n) => n.id;
82
86
  function Q(n, o, e) {
83
- let t, { state: s } = o, { viewer: a } = o, d, r, l = !1, c;
84
- const { selection: m, store: u } = s;
85
- Y(n, m, (i) => e(0, t = i));
87
+ let t, { state: s } = o, { viewer: r } = o, d, a, l = !1, p;
88
+ const { selection: u, store: f } = s;
89
+ I(n, u, (i) => e(0, t = i));
86
90
  const g = (i) => {
87
- var p;
88
- return ((p = i.selected) == null ? void 0 : p.length) > 0;
91
+ var c;
92
+ return ((c = i.selected) == null ? void 0 : c.length) > 0;
89
93
  }, E = () => {
90
- l = !0, a.setMouseNavEnabled(!1);
94
+ l = !0, r.setMouseNavEnabled(!1);
91
95
  }, D = () => {
92
- a.setMouseNavEnabled(!0);
96
+ r.setMouseNavEnabled(!0);
93
97
  }, N = () => {
94
- c && u.unobserve(c), g(t) && (l = !1, f(t), c = (i) => {
95
- l || f(t);
96
- }, u.observe(c, {
98
+ p && f.unobserve(p), g(t) && (l = !1, m(t), p = (i) => {
99
+ l || m(t);
100
+ }, f.observe(p, {
97
101
  annotations: t.selected.map((i) => i.id)
98
102
  }));
99
- }, f = (i) => {
100
- const p = i.selected[0].id, O = u.getAnnotation(p), { minX: h, minY: k, maxX: C, maxY: M } = O.target.selector.geometry.bounds, V = 14, j = a.viewport.imageToViewerElementCoordinates(new b.Point(h, k)), A = a.viewport.imageToViewerElementCoordinates(new b.Point(C, M));
101
- e(1, d = A.x + V), e(2, r = j.y);
103
+ }, m = (i) => {
104
+ const c = i.selected[0].id, O = f.getAnnotation(c), { minX: h, minY: k, maxX: C, maxY: M } = O.target.selector.geometry.bounds, V = 14, j = r.viewport.imageToViewerElementCoordinates(new b.Point(h, k)), A = r.viewport.imageToViewerElementCoordinates(new b.Point(C, M));
105
+ e(1, d = A.x + V), e(2, a = j.y);
102
106
  };
103
- return q(() => {
107
+ return z(() => {
104
108
  const i = () => {
105
- g(t) && !l && f(t);
109
+ g(t) && !l && m(t);
106
110
  };
107
- return a.addHandler("update-viewport", i), () => {
108
- a.removeHandler("update-viewport", i);
111
+ return r.addHandler("update-viewport", i), () => {
112
+ r.removeHandler("update-viewport", i);
109
113
  };
110
114
  }), n.$$set = (i) => {
111
- "state" in i && e(6, s = i.state), "viewer" in i && e(7, a = i.viewer);
115
+ "state" in i && e(6, s = i.state), "viewer" in i && e(7, r = i.viewer);
112
116
  }, n.$$.update = () => {
113
117
  n.$$.dirty & /*$selection*/
114
118
  1 && N();
115
- }, [t, d, r, m, E, D, s, a];
119
+ }, [t, d, a, u, E, D, s, r];
116
120
  }
117
- class W extends H {
121
+ class W extends B {
118
122
  constructor(o) {
119
- super(), I(this, o, Q, K, T, { state: 6, viewer: 7 });
123
+ super(), F(this, o, Q, K, H, { state: 6, viewer: 7 });
120
124
  }
121
125
  }
122
- const oe = W;
126
+ const re = W;
123
127
  export {
124
- oe as default
128
+ re as default
125
129
  };
126
130
  //# sourceMappingURL=annotorious-svelte.es5.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotorious-svelte.es5.js","sources":["../src/osd/OpenSeadragonPopup.svelte"],"sourcesContent":["<script lang=\"ts\">\n import { onMount } from 'svelte';\n import { draggable } from '@neodrag/svelte';\n import OpenSeadragon from 'openseadragon';\n import type { Selection, StoreChangeEvent, SvelteAnnotatorState } from '@annotorious/core';\n import type { ImageAnnotation } from '@annotorious/annotorious';\n\n export let state: SvelteAnnotatorState<ImageAnnotation>;\n\n export let viewer: OpenSeadragon.Viewer;\n\n let left: number;\n\n let top: number;\n\n let dragged = false;\n\n let storeObserver: (event: StoreChangeEvent<ImageAnnotation>) => void;\n\n const { selection, store } = state; \n\n const isSelected = (selection: Selection) => selection.selected?.length > 0;\n\n const onDragStart = () => {\n dragged = true;\n viewer.setMouseNavEnabled(false);\n }\n\n const onDragEnd = () => {\n viewer.setMouseNavEnabled(true);\n }\n\n $: $selection, onSelect();\n\n const onSelect = () => {\n if (storeObserver)\n store.unobserve(storeObserver);\n\n if (isSelected($selection)) {\n dragged = false;\n\n setPosition($selection);\n\n storeObserver = (event: StoreChangeEvent<ImageAnnotation>) => {\n if (!dragged)\n setPosition($selection);\n }\n\n store.observe(storeObserver, { annotations: $selection.selected.map(s => s.id) });\n }\n }\n\n const setPosition = (selection: Selection) => {\n // Note: this demo popup only supports a single selection\n const selectedId = selection.selected[0].id;\n const annotation = store.getAnnotation(selectedId);\n\n const { minX, minY, maxX, maxY } = annotation.target.selector.geometry.bounds;\n\n const PADDING = 14;\n\n const topLeft = viewer.viewport.imageToViewerElementCoordinates(new OpenSeadragon.Point(minX, minY));\n const bottomRight = viewer.viewport.imageToViewerElementCoordinates(new OpenSeadragon.Point(maxX, maxY));\n\n // [left, top] = defaultStrategy(annotation, lastPointerDown);\n left = bottomRight.x + PADDING;\n top = topLeft.y;\n }\n\n onMount(() => {\n const onUpdateViewport = () => {\n if (isSelected($selection) && !dragged)\n setPosition($selection);\n }\n\n viewer.addHandler('update-viewport', onUpdateViewport);\n\n return () => {\n viewer.removeHandler('update-viewport', onUpdateViewport);\n }\n });\n</script>\n\n{#if $selection}\n <div \n class=\"a9s-popup a9s-osd-popup\"\n use:draggable={{ position: { x: left, y: top }}}\n on:neodrag:start={onDragStart}\n on:neodrag:end={onDragEnd}>\n {$selection.selected.map(s => s.id).join(', ')}\n </div>\n{/if}\n\n<style>\n .a9s-osd-popup {\n background-color: #fff;\n border: 1px solid #a2a2a2;\n height: 250px;\n position: absolute;\n width: 400px;\n z-index: 1;\n }\n</style>"],"names":["t_value","ctx","func","insert","target","div","anchor","dirty","set_data","create_if_block","s","state","$$props","viewer","left","top","dragged","storeObserver","selection","store","isSelected","_a","onDragStart","onDragEnd","onSelect","$selection","setPosition","event","selectedId","annotation","minX","minY","maxX","maxY","PADDING","topLeft","OpenSeadragon","bottomRight","$$invalidate","onMount","onUpdateViewport"],"mappings":";;;;;SAyFKA;AAAA;AAAA,IAAAC,KAAW,SAAS,IAAeC,CAAA,EAAA,KAAK,IAAI,IAAA;AAAA;;;;;;AAL/C,MAAAC,EAMKC,GAAAC,GAAAC,CAAA;;UAJc,YAAY;AAAA;AAAA,YAAGL,EAAM,CAAA;AAAA,aAAA;AAAA;AAAA,YAAGA,EAAG,CAAA;AAAA,YAAA;AAAA;;;;;UAC1BA,EAAW,CAAA;AAAA,QAAA;AAAA;;;;UACbA,EAAS,CAAA;AAAA,QAAA;AAAA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tB,EAAO,SAAS,gCAAoC,IAAAuB,EAAc,MAAMN,GAAMC,CAAI,CAAA,GAC5FM,IAAcxB,EAAO,SAAS,gCAAoC,IAAAuB,EAAc,MAAMJ,GAAMC,CAAI,CAAA;AAGtG,IAAAK,EAAA,GAAAxB,IAAOuB,EAAY,IAAIH,CAAO,QAC9BnB,IAAMoB,EAAQ,CAAC;AAAA;AAGjB,SAAAI,EAAO,MAAA;UACCC,IAAgB,MAAA;AAChB,MAAApB,EAAWK,CAAU,KAAA,CAAMT,KAC7BU,EAAYD,CAAU;AAAA;AAG1B,WAAAZ,EAAO,WAAW,mBAAmB2B,CAAgB;AAGnD,MAAA3B,EAAO,cAAc,mBAAmB2B,CAAgB;AAAA;;;;;SA9C7ChB,EAAQ;AAAA;;;;;;;;"}
1
+ {"version":3,"file":"annotorious-svelte.es5.js","sources":["../src/osd/OpenSeadragonPopup.svelte"],"sourcesContent":["<script lang=\"ts\">\n import { onMount } from 'svelte';\n import { draggable } from '@neodrag/svelte';\n import OpenSeadragon from 'openseadragon';\n import type { Selection, StoreChangeEvent, SvelteAnnotatorState } from '@annotorious/core';\n import type { ImageAnnotation } from '@annotorious/annotorious';\n\n export let state: SvelteAnnotatorState<ImageAnnotation>;\n\n export let viewer: OpenSeadragon.Viewer;\n\n let left: number;\n\n let top: number;\n\n let dragged = false;\n\n let storeObserver: (event: StoreChangeEvent<ImageAnnotation>) => void;\n\n const { selection, store } = state; \n\n const isSelected = (selection: Selection) => selection.selected?.length > 0;\n\n const onDragStart = () => {\n dragged = true;\n viewer.setMouseNavEnabled(false);\n }\n\n const onDragEnd = () => {\n viewer.setMouseNavEnabled(true);\n }\n\n $: $selection, onSelect();\n\n const onSelect = () => {\n if (storeObserver)\n store.unobserve(storeObserver);\n\n if (isSelected($selection)) {\n dragged = false;\n\n setPosition($selection);\n\n storeObserver = (event: StoreChangeEvent<ImageAnnotation>) => {\n if (!dragged)\n setPosition($selection);\n }\n\n store.observe(storeObserver, { annotations: $selection.selected.map(s => s.id) });\n }\n }\n\n const setPosition = (selection: Selection) => {\n // Note: this demo popup only supports a single selection\n const selectedId = selection.selected[0].id;\n const annotation = store.getAnnotation(selectedId);\n\n const { minX, minY, maxX, maxY } = annotation.target.selector.geometry.bounds;\n\n const PADDING = 14;\n\n const topLeft = viewer.viewport.imageToViewerElementCoordinates(new OpenSeadragon.Point(minX, minY));\n const bottomRight = viewer.viewport.imageToViewerElementCoordinates(new OpenSeadragon.Point(maxX, maxY));\n\n // [left, top] = defaultStrategy(annotation, lastPointerDown);\n left = bottomRight.x + PADDING;\n top = topLeft.y;\n }\n\n onMount(() => {\n const onUpdateViewport = () => {\n if (isSelected($selection) && !dragged)\n setPosition($selection);\n }\n\n viewer.addHandler('update-viewport', onUpdateViewport);\n\n return () => {\n viewer.removeHandler('update-viewport', onUpdateViewport);\n }\n });\n</script>\n\n{#if $selection}\n <div \n class=\"a9s-popup a9s-osd-popup\"\n use:draggable={{ position: { x: left, y: top }}}\n on:neodrag:start={onDragStart}\n on:neodrag:end={onDragEnd}>\n {$selection.selected.map(s => s.id).join(', ')}\n </div>\n{/if}\n\n<style>\n .a9s-osd-popup {\n background-color: #fff;\n border: 1px solid #a2a2a2;\n height: 250px;\n position: absolute;\n width: 400px;\n z-index: 1;\n }\n</style>"],"names":["t_value","ctx","func","insert","target","div","anchor","dirty","set_data","create_if_block","s","state","$$props","viewer","left","top","dragged","storeObserver","selection","store","isSelected","_a","onDragStart","onDragEnd","onSelect","$selection","setPosition","event","selectedId","annotation","minX","minY","maxX","maxY","PADDING","topLeft","OpenSeadragon","bottomRight","$$invalidate","onMount","onUpdateViewport"],"mappings":";;;;;;;;;SAyFKA;AAAA;AAAA,IAAAC,KAAW,SAAS,IAAeC,CAAA,EAAA,KAAK,IAAI,IAAA;AAAA;;;;;;AAL/C,MAAAC,EAMKC,GAAAC,GAAAC,CAAA;;UAJc,YAAY;AAAA;AAAA,YAAGL,EAAM,CAAA;AAAA,aAAA;AAAA;AAAA,YAAGA,E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