@annotorious/core 3.0.0-rc.26 → 3.0.0-rc.28

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.
@@ -1,4 +1,4 @@
1
- var j = Object.prototype.hasOwnProperty;
1
+ var M = Object.prototype.hasOwnProperty;
2
2
  function B(e, n) {
3
3
  var t, o;
4
4
  if (e === n)
@@ -17,7 +17,7 @@ function B(e, n) {
17
17
  if (!t || typeof e == "object") {
18
18
  o = 0;
19
19
  for (t in e)
20
- if (j.call(e, t) && ++o && !j.call(n, t) || !(t in n) || !B(e[t], n[t]))
20
+ if (M.call(e, t) && ++o && !M.call(n, t) || !(t in n) || !B(e[t], n[t]))
21
21
  return !1;
22
22
  return Object.keys(n).length === o;
23
23
  }
@@ -26,19 +26,19 @@ function B(e, n) {
26
26
  }
27
27
  function z() {
28
28
  }
29
- function q(e, n) {
29
+ function H(e, n) {
30
30
  return e != e ? n == n : e !== n || e && typeof e == "object" || typeof e == "function";
31
31
  }
32
32
  const k = [];
33
- function _(e, n = z) {
33
+ function Y(e, n = z) {
34
34
  let t;
35
35
  const o = /* @__PURE__ */ new Set();
36
36
  function i(b) {
37
- if (q(e, b) && (e = b, t)) {
38
- const v = !k.length;
37
+ if (H(e, b) && (e = b, t)) {
38
+ const y = !k.length;
39
39
  for (const u of o)
40
40
  u[1](), k.push(u, e);
41
- if (v) {
41
+ if (y) {
42
42
  for (let u = 0; u < k.length; u += 2)
43
43
  k[u][0](k[u + 1]);
44
44
  k.length = 0;
@@ -48,16 +48,16 @@ function _(e, n = z) {
48
48
  function p(b) {
49
49
  i(b(e));
50
50
  }
51
- function w(b, v = z) {
52
- const u = [b, v];
51
+ function w(b, y = z) {
52
+ const u = [b, y];
53
53
  return o.add(u), o.size === 1 && (t = n(i, p) || z), b(e), () => {
54
54
  o.delete(u), o.size === 0 && t && (t(), t = null);
55
55
  };
56
56
  }
57
57
  return { set: i, update: p, subscribe: w };
58
58
  }
59
- const we = (e) => {
60
- const { subscribe: n, set: t } = _();
59
+ const Ce = (e) => {
60
+ const { subscribe: n, set: t } = Y();
61
61
  let o;
62
62
  return n((i) => o = i), e.observe(({ changes: i }) => {
63
63
  if (o) {
@@ -73,9 +73,9 @@ const we = (e) => {
73
73
  set: t
74
74
  };
75
75
  };
76
- var G = /* @__PURE__ */ ((e) => (e.EDIT = "EDIT", e.SELECT = "SELECT", e.NONE = "NONE", e))(G || {});
77
- const V = { selected: [] }, Ce = (e, n = "EDIT") => {
78
- const { subscribe: t, set: o } = _(V);
76
+ var F = /* @__PURE__ */ ((e) => (e.EDIT = "EDIT", e.SELECT = "SELECT", e.NONE = "NONE", e))(F || {});
77
+ const V = { selected: [] }, Le = (e, n = "EDIT") => {
78
+ const { subscribe: t, set: o } = Y(V);
79
79
  let i = V;
80
80
  t((s) => i = s);
81
81
  const p = () => o(V), w = () => {
@@ -86,25 +86,30 @@ const V = { selected: [] }, Ce = (e, n = "EDIT") => {
86
86
  return !1;
87
87
  const h = typeof s == "string" ? s : s.id;
88
88
  return i.selected.some((L) => L.id === h);
89
- }, v = (s, h) => {
89
+ }, y = (s, h) => {
90
90
  const L = e.getAnnotation(s);
91
91
  if (L) {
92
- const E = H(L, n);
93
- o(E === "EDIT" ? { selected: [{ id: s, editable: !0 }], pointerEvent: h } : E === "SELECT" ? { selected: [{ id: s }], pointerEvent: h } : { selected: [], pointerEvent: h });
92
+ const v = P(L, n);
93
+ o(v === "EDIT" ? { selected: [{ id: s, editable: !0 }], pointerEvent: h } : v === "SELECT" ? { selected: [{ id: s }], pointerEvent: h } : { selected: [], pointerEvent: h });
94
94
  } else
95
95
  console.warn("Invalid selection: " + s);
96
- }, u = (s, h = !0) => {
97
- const L = Array.isArray(s) ? s : [s], E = L.map((S) => e.getAnnotation(S)).filter(Boolean);
98
- o({ selected: E.map(({ id: S }) => ({ id: S, editable: h })) }), E.length !== L.length && console.warn("Invalid selection", s);
96
+ }, u = (s, h) => {
97
+ const L = Array.isArray(s) ? s : [s], v = L.map((S) => e.getAnnotation(S)).filter(Boolean);
98
+ o({
99
+ selected: v.map((S) => {
100
+ const E = h === void 0 ? P(S, n) === "EDIT" : h;
101
+ return { id: S.id, editable: E };
102
+ })
103
+ }), v.length !== L.length && console.warn("Invalid selection", s);
99
104
  }, U = (s) => {
100
105
  if (i.selected.length === 0)
101
106
  return !1;
102
107
  const { selected: h } = i;
103
- h.filter(({ id: E }) => s.includes(E)).length > 0 && o({ selected: h.filter(({ id: E }) => !s.includes(E)) });
108
+ h.filter(({ id: v }) => s.includes(v)).length > 0 && o({ selected: h.filter(({ id: v }) => !s.includes(v)) });
104
109
  };
105
110
  return e.observe(({ changes: s }) => U((s.deleted || []).map((h) => h.id))), {
106
111
  clear: p,
107
- clickSelect: v,
112
+ clickSelect: y,
108
113
  get selected() {
109
114
  return i ? [...i.selected] : null;
110
115
  },
@@ -116,73 +121,73 @@ const V = { selected: [] }, Ce = (e, n = "EDIT") => {
116
121
  setSelected: u,
117
122
  subscribe: t
118
123
  };
119
- }, H = (e, n) => typeof n == "function" ? n(e) || "EDIT" : n || "EDIT";
120
- let $;
121
- const F = new Uint8Array(16);
122
- function J() {
124
+ }, P = (e, n) => typeof n == "function" ? n(e) || "EDIT" : n || "EDIT";
125
+ var D = [];
126
+ for (var _ = 0; _ < 256; ++_)
127
+ D.push((_ + 256).toString(16).slice(1));
128
+ function J(e, n = 0) {
129
+ return (D[e[n + 0]] + D[e[n + 1]] + D[e[n + 2]] + D[e[n + 3]] + "-" + D[e[n + 4]] + D[e[n + 5]] + "-" + D[e[n + 6]] + D[e[n + 7]] + "-" + D[e[n + 8]] + D[e[n + 9]] + "-" + D[e[n + 10]] + D[e[n + 11]] + D[e[n + 12]] + D[e[n + 13]] + D[e[n + 14]] + D[e[n + 15]]).toLowerCase();
130
+ }
131
+ var $, Q = new Uint8Array(16);
132
+ function X() {
123
133
  if (!$ && ($ = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !$))
124
134
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
125
- return $(F);
126
- }
127
- const D = [];
128
- for (let e = 0; e < 256; ++e)
129
- D.push((e + 256).toString(16).slice(1));
130
- function Q(e, n = 0) {
131
- return D[e[n + 0]] + D[e[n + 1]] + D[e[n + 2]] + D[e[n + 3]] + "-" + D[e[n + 4]] + D[e[n + 5]] + "-" + D[e[n + 6]] + D[e[n + 7]] + "-" + D[e[n + 8]] + D[e[n + 9]] + "-" + D[e[n + 10]] + D[e[n + 11]] + D[e[n + 12]] + D[e[n + 13]] + D[e[n + 14]] + D[e[n + 15]];
135
+ return $(Q);
132
136
  }
133
- const X = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), M = {
134
- randomUUID: X
137
+ var Z = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
138
+ const W = {
139
+ randomUUID: Z
135
140
  };
136
- function Z(e, n, t) {
137
- if (M.randomUUID && !n && !e)
138
- return M.randomUUID();
141
+ function K(e, n, t) {
142
+ if (W.randomUUID && !n && !e)
143
+ return W.randomUUID();
139
144
  e = e || {};
140
- const o = e.random || (e.rng || J)();
141
- return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Q(o);
145
+ var o = e.random || (e.rng || X)();
146
+ return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, J(o);
142
147
  }
143
- const Le = (e) => {
148
+ const Ue = (e) => {
144
149
  const { creator: n, updatedBy: t } = e.target, o = e.bodies.reduce((i, p) => [...i, p.creator, p.updatedBy].filter(Boolean), []);
145
150
  return [
146
151
  n,
147
152
  t,
148
153
  ...o
149
154
  ].filter((i) => i);
150
- }, Ue = (e, n, t, o) => ({
151
- id: Z(),
155
+ }, Se = (e, n, t, o) => ({
156
+ id: K(),
152
157
  annotation: e.id,
153
158
  created: t || /* @__PURE__ */ new Date(),
154
159
  creator: o,
155
160
  ...n
156
- }), K = (e, n) => {
161
+ }), ee = (e, n) => {
157
162
  const t = new Set(e.bodies.map((o) => o.id));
158
163
  return n.bodies.filter((o) => !t.has(o.id));
159
- }, ee = (e, n) => {
164
+ }, te = (e, n) => {
160
165
  const t = new Set(n.bodies.map((o) => o.id));
161
166
  return e.bodies.filter((o) => !t.has(o.id));
162
- }, te = (e, n) => n.bodies.map((t) => {
167
+ }, ne = (e, n) => n.bodies.map((t) => {
163
168
  const o = e.bodies.find((i) => i.id === t.id);
164
169
  return { newBody: t, oldBody: o && !B(o, t) ? o : void 0 };
165
- }).filter(({ oldBody: t }) => t).map(({ oldBody: t, newBody: o }) => ({ oldBody: t, newBody: o })), ne = (e, n) => !B(e.target, n.target), P = (e, n) => {
166
- const t = K(e, n), o = ee(e, n), i = te(e, n);
170
+ }).filter(({ oldBody: t }) => t).map(({ oldBody: t, newBody: o }) => ({ oldBody: t, newBody: o })), oe = (e, n) => !B(e.target, n.target), q = (e, n) => {
171
+ const t = ee(e, n), o = te(e, n), i = ne(e, n);
167
172
  return {
168
173
  oldValue: e,
169
174
  newValue: n,
170
175
  bodiesCreated: t.length > 0 ? t : void 0,
171
176
  bodiesDeleted: o.length > 0 ? o : void 0,
172
177
  bodiesUpdated: i.length > 0 ? i : void 0,
173
- targetUpdated: ne(e, n) ? { oldTarget: e.target, newTarget: n.target } : void 0
178
+ targetUpdated: oe(e, n) ? { oldTarget: e.target, newTarget: n.target } : void 0
174
179
  };
175
180
  };
176
- var oe = /* @__PURE__ */ ((e) => (e.BODY_ONLY = "BODY_ONLY", e.TARGET_ONLY = "TARGET_ONLY", e))(oe || {}), O = /* @__PURE__ */ ((e) => (e.LOCAL = "LOCAL", e.REMOTE = "REMOTE", e))(O || {});
177
- const se = (e, n) => {
181
+ var se = /* @__PURE__ */ ((e) => (e.BODY_ONLY = "BODY_ONLY", e.TARGET_ONLY = "TARGET_ONLY", e))(se || {}), O = /* @__PURE__ */ ((e) => (e.LOCAL = "LOCAL", e.REMOTE = "REMOTE", e))(O || {});
182
+ const ie = (e, n) => {
178
183
  var p, w;
179
184
  const { changes: t, origin: o } = n;
180
185
  if (!(!e.options.origin || e.options.origin === o))
181
186
  return !1;
182
187
  if (e.options.ignore) {
183
- const { ignore: b } = e.options, v = (U) => U && U.length > 0;
184
- if (!(v(t.created) || v(t.deleted))) {
185
- const U = (p = t.updated) == null ? void 0 : p.some((h) => v(h.bodiesCreated) || v(h.bodiesDeleted) || v(h.bodiesUpdated)), s = (w = t.updated) == null ? void 0 : w.some((h) => h.targetUpdated);
188
+ const { ignore: b } = e.options, y = (U) => U && U.length > 0;
189
+ if (!(y(t.created) || y(t.deleted))) {
190
+ const U = (p = t.updated) == null ? void 0 : p.some((h) => y(h.bodiesCreated) || y(h.bodiesDeleted) || y(h.bodiesUpdated)), s = (w = t.updated) == null ? void 0 : w.some((h) => h.targetUpdated);
186
191
  if (b === "BODY_ONLY" && U && !s || b === "TARGET_ONLY" && s && !U)
187
192
  return !1;
188
193
  }
@@ -196,8 +201,8 @@ const se = (e, n) => {
196
201
  return !!(Array.isArray(e.options.annotations) ? e.options.annotations : [e.options.annotations]).find((u) => b.has(u));
197
202
  } else
198
203
  return !0;
199
- }, ie = (e, n) => {
200
- 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)), w = 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 = [
204
+ }, de = (e, n) => {
205
+ 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)), w = 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)), y = [
201
206
  ...(e.created || []).filter((s) => !p.has(s.id)).map((s) => w.has(s.id) ? n.updated.find(({ oldValue: h }) => h.id === s.id).newValue : s),
202
207
  ...n.created || []
203
208
  ], u = [
@@ -207,59 +212,59 @@ const se = (e, n) => {
207
212
  ...(e.updated || []).filter(({ newValue: s }) => !p.has(s.id)).map((s) => {
208
213
  const { oldValue: h, newValue: L } = s;
209
214
  if (w.has(L.id)) {
210
- const E = n.updated.find((S) => S.oldValue.id === L.id).newValue;
211
- return P(h, E);
215
+ const v = n.updated.find((S) => S.oldValue.id === L.id).newValue;
216
+ return q(h, v);
212
217
  } else
213
218
  return s;
214
219
  }),
215
220
  ...(n.updated || []).filter(({ oldValue: s }) => !b.has(s.id))
216
221
  ];
217
- return { created: v, deleted: u, updated: U };
218
- }, de = (e) => e.id !== void 0, Se = () => {
219
- const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), t = [], o = (d, r = {}) => t.push({ onChange: d, options: r }), i = (d) => {
220
- const r = t.findIndex((c) => c.onChange == d);
221
- r > -1 && t.splice(r, 1);
222
- }, p = (d, r) => {
222
+ return { created: y, deleted: u, updated: U };
223
+ }, re = (e) => e.id !== void 0, Oe = () => {
224
+ const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), t = [], o = (d, a = {}) => t.push({ onChange: d, options: a }), i = (d) => {
225
+ const a = t.findIndex((c) => c.onChange == d);
226
+ a > -1 && t.splice(a, 1);
227
+ }, p = (d, a) => {
223
228
  const c = {
224
229
  origin: d,
225
230
  changes: {
226
- created: r.created || [],
227
- updated: r.updated || [],
228
- deleted: r.deleted || []
231
+ created: a.created || [],
232
+ updated: a.updated || [],
233
+ deleted: a.deleted || []
229
234
  },
230
235
  state: [...e.values()]
231
236
  };
232
237
  t.forEach((f) => {
233
- se(f, c) && f.onChange(c);
238
+ ie(f, c) && f.onChange(c);
234
239
  });
235
- }, w = (d, r = O.LOCAL) => {
240
+ }, w = (d, a = O.LOCAL) => {
236
241
  if (e.get(d.id))
237
242
  throw Error(`Cannot add annotation ${d.id} - exists already`);
238
- e.set(d.id, d), d.bodies.forEach((f) => n.set(f.id, d.id)), p(r, { created: [d] });
239
- }, b = (d, r) => {
240
- const c = typeof d == "string" ? r : d, f = typeof d == "string" ? d : d.id, C = e.get(f);
243
+ e.set(d.id, d), d.bodies.forEach((f) => n.set(f.id, d.id)), p(a, { created: [d] });
244
+ }, b = (d, a) => {
245
+ const c = typeof d == "string" ? a : d, f = typeof d == "string" ? d : d.id, C = e.get(f);
241
246
  if (C) {
242
- const T = P(C, c);
247
+ const T = q(C, c);
243
248
  return f === c.id ? e.set(f, c) : (e.delete(f), e.set(c.id, c)), C.bodies.forEach((I) => n.delete(I.id)), c.bodies.forEach((I) => n.set(I.id, c.id)), T;
244
249
  } else
245
250
  console.warn(`Cannot update annotation ${f} - does not exist`);
246
- }, v = (d, r = O.LOCAL, c = O.LOCAL) => {
247
- const f = de(r) ? c : r, C = b(d, r);
251
+ }, y = (d, a = O.LOCAL, c = O.LOCAL) => {
252
+ const f = re(a) ? c : a, C = b(d, a);
248
253
  C && p(f, { updated: [C] });
249
- }, u = (d, r = O.LOCAL) => {
254
+ }, u = (d, a = O.LOCAL) => {
250
255
  const c = d.reduce((f, C) => {
251
256
  const T = b(C);
252
257
  return T ? [...f, T] : f;
253
258
  }, []);
254
- c.length > 0 && p(r, { updated: c });
255
- }, U = (d, r = O.LOCAL) => {
259
+ c.length > 0 && p(a, { updated: c });
260
+ }, U = (d, a = O.LOCAL) => {
256
261
  const c = e.get(d.annotation);
257
262
  if (c) {
258
263
  const f = {
259
264
  ...c,
260
265
  bodies: [...c.bodies, d]
261
266
  };
262
- e.set(c.id, f), n.set(d.id, f.id), p(r, { updated: [{
267
+ e.set(c.id, f), n.set(d.id, f.id), p(a, { updated: [{
263
268
  oldValue: c,
264
269
  newValue: f,
265
270
  bodiesCreated: [d]
@@ -267,10 +272,10 @@ const se = (e, n) => {
267
272
  } else
268
273
  console.warn(`Attempt to add body to missing annotation: ${d.annotation}`);
269
274
  }, s = () => [...e.values()], h = (d = O.LOCAL) => {
270
- const r = [...e.values()];
271
- e.clear(), n.clear(), p(d, { deleted: r });
272
- }, L = (d, r = !0, c = O.LOCAL) => {
273
- if (r) {
275
+ const a = [...e.values()];
276
+ e.clear(), n.clear(), p(d, { deleted: a });
277
+ }, L = (d, a = !0, c = O.LOCAL) => {
278
+ if (a) {
274
279
  const f = [...e.values()];
275
280
  e.clear(), n.clear(), d.forEach((C) => {
276
281
  e.set(C.id, C), C.bodies.forEach((T) => n.set(T.id, C.id));
@@ -286,32 +291,32 @@ const se = (e, n) => {
286
291
  e.set(C.id, C), C.bodies.forEach((T) => n.set(T.id, C.id));
287
292
  }), p(c, { created: d });
288
293
  }
289
- }, E = (d) => {
290
- const r = typeof d == "string" ? d : d.id, c = e.get(r);
294
+ }, v = (d) => {
295
+ const a = typeof d == "string" ? d : d.id, c = e.get(a);
291
296
  if (c)
292
- return e.delete(r), c.bodies.forEach((f) => n.delete(f.id)), c;
293
- console.warn(`Attempt to delete missing annotation: ${r}`);
294
- }, S = (d, r = O.LOCAL) => {
295
- const c = E(d);
296
- c && p(r, { deleted: [c] });
297
- }, y = (d, r = O.LOCAL) => {
297
+ return e.delete(a), c.bodies.forEach((f) => n.delete(f.id)), c;
298
+ console.warn(`Attempt to delete missing annotation: ${a}`);
299
+ }, S = (d, a = O.LOCAL) => {
300
+ const c = v(d);
301
+ c && p(a, { deleted: [c] });
302
+ }, E = (d, a = O.LOCAL) => {
298
303
  const c = d.reduce((f, C) => {
299
- const T = E(C);
304
+ const T = v(C);
300
305
  return T ? [...f, T] : f;
301
306
  }, []);
302
- c.length > 0 && p(r, { deleted: c });
307
+ c.length > 0 && p(a, { deleted: c });
303
308
  }, l = (d) => {
304
- const r = e.get(d.annotation);
305
- if (r) {
306
- const c = r.bodies.find((f) => f.id === d.id);
309
+ const a = e.get(d.annotation);
310
+ if (a) {
311
+ const c = a.bodies.find((f) => f.id === d.id);
307
312
  if (c) {
308
313
  n.delete(c.id);
309
314
  const f = {
310
- ...r,
311
- bodies: r.bodies.filter((T) => T.id !== d.id)
315
+ ...a,
316
+ bodies: a.bodies.filter((T) => T.id !== d.id)
312
317
  };
313
- return e.set(r.id, f), {
314
- oldValue: r,
318
+ return e.set(a.id, f), {
319
+ oldValue: a,
315
320
  newValue: f,
316
321
  bodiesDeleted: [c]
317
322
  };
@@ -319,61 +324,61 @@ const se = (e, n) => {
319
324
  console.warn(`Attempt to delete missing body ${d.id} from annotation ${d.annotation}`);
320
325
  } else
321
326
  console.warn(`Attempt to delete body from missing annotation ${d.annotation}`);
322
- }, g = (d, r = O.LOCAL) => {
327
+ }, g = (d, a = O.LOCAL) => {
323
328
  const c = l(d);
324
- c && p(r, { updated: [c] });
325
- }, a = (d, r = O.LOCAL) => {
329
+ c && p(a, { updated: [c] });
330
+ }, r = (d, a = O.LOCAL) => {
326
331
  const c = d.map((f) => l(f)).filter(Boolean);
327
- c.length > 0 && p(r, { updated: c });
332
+ c.length > 0 && p(a, { updated: c });
328
333
  }, A = (d) => {
329
- const r = e.get(d);
330
- return r ? { ...r } : void 0;
334
+ const a = e.get(d);
335
+ return a ? { ...a } : void 0;
331
336
  }, m = (d) => {
332
- const r = n.get(d);
333
- if (r) {
334
- const f = A(r).bodies.find((C) => C.id === d);
337
+ const a = n.get(d);
338
+ if (a) {
339
+ const f = A(a).bodies.find((C) => C.id === d);
335
340
  if (f)
336
341
  return f;
337
342
  console.error(`Store integrity error: body ${d} in index, but not in annotation`);
338
343
  } else
339
344
  console.warn(`Attempt to retrieve missing body: ${d}`);
340
- }, R = (d, r) => {
341
- if (d.annotation !== r.annotation)
345
+ }, R = (d, a) => {
346
+ if (d.annotation !== a.annotation)
342
347
  throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
343
348
  const c = e.get(d.annotation);
344
349
  if (c) {
345
350
  const f = c.bodies.find((T) => T.id === d.id), C = {
346
351
  ...c,
347
- bodies: c.bodies.map((T) => T.id === f.id ? r : T)
352
+ bodies: c.bodies.map((T) => T.id === f.id ? a : T)
348
353
  };
349
- return e.set(c.id, C), f.id !== r.id && (n.delete(f.id), n.set(r.id, C.id)), {
354
+ return e.set(c.id, C), f.id !== a.id && (n.delete(f.id), n.set(a.id, C.id)), {
350
355
  oldValue: c,
351
356
  newValue: C,
352
- bodiesUpdated: [{ oldBody: f, newBody: r }]
357
+ bodiesUpdated: [{ oldBody: f, newBody: a }]
353
358
  };
354
359
  } else
355
360
  console.warn(`Attempt to add body to missing annotation ${d.annotation}`);
356
- }, N = (d, r, c = O.LOCAL) => {
357
- const f = R(d, r);
361
+ }, N = (d, a, c = O.LOCAL) => {
362
+ const f = R(d, a);
358
363
  f && p(c, { updated: [f] });
359
- }, x = (d, r = O.LOCAL) => {
364
+ }, x = (d, a = O.LOCAL) => {
360
365
  const c = d.map((f) => R({ id: f.id, annotation: f.annotation }, f)).filter(Boolean);
361
- p(r, { updated: c });
362
- }, Y = (d) => {
363
- const r = e.get(d.annotation);
364
- if (r) {
366
+ p(a, { updated: c });
367
+ }, j = (d) => {
368
+ const a = e.get(d.annotation);
369
+ if (a) {
365
370
  const c = {
366
- ...r,
371
+ ...a,
367
372
  target: {
368
- ...r.target,
373
+ ...a.target,
369
374
  ...d
370
375
  }
371
376
  };
372
- return e.set(r.id, c), {
373
- oldValue: r,
377
+ return e.set(a.id, c), {
378
+ oldValue: a,
374
379
  newValue: c,
375
380
  targetUpdated: {
376
- oldTarget: r.target,
381
+ oldTarget: a.target,
377
382
  newTarget: d
378
383
  }
379
384
  };
@@ -385,13 +390,13 @@ const se = (e, n) => {
385
390
  addBody: U,
386
391
  all: s,
387
392
  bulkAddAnnotation: L,
388
- bulkDeleteAnnotation: y,
389
- bulkDeleteBodies: a,
393
+ bulkDeleteAnnotation: E,
394
+ bulkDeleteBodies: r,
390
395
  bulkUpdateAnnotation: u,
391
396
  bulkUpdateBodies: x,
392
- bulkUpdateTargets: (d, r = O.LOCAL) => {
393
- const c = d.map((f) => Y(f)).filter(Boolean);
394
- c.length > 0 && p(r, { updated: c });
397
+ bulkUpdateTargets: (d, a = O.LOCAL) => {
398
+ const c = d.map((f) => j(f)).filter(Boolean);
399
+ c.length > 0 && p(a, { updated: c });
395
400
  },
396
401
  clear: h,
397
402
  deleteAnnotation: S,
@@ -400,21 +405,21 @@ const se = (e, n) => {
400
405
  getBody: m,
401
406
  observe: o,
402
407
  unobserve: i,
403
- updateAnnotation: v,
408
+ updateAnnotation: y,
404
409
  updateBody: N,
405
- updateTarget: (d, r = O.LOCAL) => {
406
- const c = Y(d);
407
- c && p(r, { updated: [c] });
410
+ updateTarget: (d, a = O.LOCAL) => {
411
+ const c = j(d);
412
+ c && p(a, { updated: [c] });
408
413
  }
409
414
  };
410
- }, Oe = (e) => ({
415
+ }, Te = (e) => ({
411
416
  ...e,
412
417
  subscribe: (t) => {
413
418
  const o = (i) => t(i.state);
414
419
  return e.observe(o), t(e.all()), () => e.unobserve(o);
415
420
  }
416
421
  });
417
- let W = () => ({
422
+ let G = () => ({
418
423
  emit(e, ...n) {
419
424
  for (let t = 0, o = this.events[e] || [], i = o.length; t < i; t++)
420
425
  o[t](...n);
@@ -428,76 +433,76 @@ let W = () => ({
428
433
  };
429
434
  }
430
435
  });
431
- const ae = 250, Te = (e) => {
432
- const n = W(), t = [];
436
+ const ae = 250, De = (e) => {
437
+ const n = G(), t = [];
433
438
  let o = -1, i = !1, p = 0;
434
- const w = (a) => {
439
+ const w = (r) => {
435
440
  if (!i) {
436
- const { changes: A } = a, m = performance.now();
441
+ const { changes: A } = r, m = performance.now();
437
442
  if (m - p > ae)
438
443
  t.splice(o + 1), t.push(A), o = t.length - 1;
439
444
  else {
440
445
  const R = t.length - 1;
441
- t[R] = ie(t[R], A);
446
+ t[R] = de(t[R], A);
442
447
  }
443
448
  p = m;
444
449
  }
445
450
  i = !1;
446
451
  };
447
452
  e.observe(w, { origin: O.LOCAL });
448
- const b = (a) => a && a.length > 0 && e.bulkDeleteAnnotation(a), v = (a) => a && a.length > 0 && e.bulkAddAnnotation(a, !1), u = (a) => a && a.length > 0 && e.bulkUpdateAnnotation(a.map(({ oldValue: A }) => A)), U = (a) => a && a.length > 0 && e.bulkUpdateAnnotation(a.map(({ newValue: A }) => A)), s = (a) => a && a.length > 0 && e.bulkAddAnnotation(a, !1), h = (a) => a && a.length > 0 && e.bulkDeleteAnnotation(a);
453
+ const b = (r) => r && r.length > 0 && e.bulkDeleteAnnotation(r), y = (r) => r && r.length > 0 && e.bulkAddAnnotation(r, !1), u = (r) => r && r.length > 0 && e.bulkUpdateAnnotation(r.map(({ oldValue: A }) => A)), U = (r) => r && r.length > 0 && e.bulkUpdateAnnotation(r.map(({ newValue: A }) => A)), s = (r) => r && r.length > 0 && e.bulkAddAnnotation(r, !1), h = (r) => r && r.length > 0 && e.bulkDeleteAnnotation(r);
449
454
  return {
450
455
  canRedo: () => t.length - 1 > o,
451
456
  canUndo: () => o > -1,
452
457
  destroy: () => e.unobserve(w),
453
- on: (a, A) => n.on(a, A),
458
+ on: (r, A) => n.on(r, A),
454
459
  redo: () => {
455
460
  if (t.length - 1 > o) {
456
461
  i = !0;
457
- const { created: a, updated: A, deleted: m } = t[o + 1];
458
- v(a), U(A), h(m), n.emit("redo", t[o + 1]), o += 1;
462
+ const { created: r, updated: A, deleted: m } = t[o + 1];
463
+ y(r), U(A), h(m), n.emit("redo", t[o + 1]), o += 1;
459
464
  }
460
465
  },
461
466
  undo: () => {
462
467
  if (o > -1) {
463
468
  i = !0;
464
- const { created: a, updated: A, deleted: m } = t[o];
465
- b(a), u(A), s(m), n.emit("undo", t[o]), o -= 1;
469
+ const { created: r, updated: A, deleted: m } = t[o];
470
+ b(r), u(A), s(m), n.emit("undo", t[o]), o -= 1;
466
471
  }
467
472
  }
468
473
  };
469
- }, De = () => {
470
- const { subscribe: e, set: n } = _([]);
474
+ }, Re = () => {
475
+ const { subscribe: e, set: n } = Y([]);
471
476
  return {
472
477
  subscribe: e,
473
478
  set: n
474
479
  };
475
- }, Re = (e, n, t, o) => {
476
- const { store: i, selection: p, hover: w, viewport: b } = e, v = /* @__PURE__ */ new Map();
480
+ }, Be = (e, n, t, o) => {
481
+ const { store: i, selection: p, hover: w, viewport: b } = e, y = /* @__PURE__ */ new Map();
477
482
  let u = [], U, s;
478
483
  const h = (l, g) => {
479
- v.has(l) ? v.get(l).push(g) : v.set(l, [g]);
484
+ y.has(l) ? y.get(l).push(g) : y.set(l, [g]);
480
485
  }, L = (l, g) => {
481
- const a = v.get(l);
482
- a && a.indexOf(g) > 0 && a.splice(a.indexOf(g), 1);
483
- }, E = (l, g, a) => {
484
- v.has(l) && setTimeout(() => {
485
- v.get(l).forEach((A) => {
486
+ const r = y.get(l);
487
+ r && r.indexOf(g) > 0 && r.splice(r.indexOf(g), 1);
488
+ }, v = (l, g, r) => {
489
+ y.has(l) && setTimeout(() => {
490
+ y.get(l).forEach((A) => {
486
491
  if (t) {
487
- const m = Array.isArray(g) ? g.map((N) => t.serialize(N)) : t.serialize(g), R = a ? a instanceof PointerEvent ? a : t.serialize(a) : void 0;
492
+ const m = Array.isArray(g) ? g.map((N) => t.serialize(N)) : t.serialize(g), R = r ? r instanceof PointerEvent ? r : t.serialize(r) : void 0;
488
493
  A(m, R);
489
494
  } else
490
- A(g, a);
495
+ A(g, r);
491
496
  });
492
497
  }, 1);
493
498
  }, S = () => {
494
- const { selected: l } = p, g = (l || []).map(({ id: a }) => i.getAnnotation(a));
495
- g.forEach((a) => {
496
- const A = u.find((m) => m.id === a.id);
497
- (!A || !B(A, a)) && E("updateAnnotation", a, A);
498
- }), u = u.map((a) => {
499
- const A = g.find(({ id: m }) => m === a.id);
500
- return A || a;
499
+ const { selected: l } = p, g = (l || []).map(({ id: r }) => i.getAnnotation(r));
500
+ g.forEach((r) => {
501
+ const A = u.find((m) => m.id === r.id);
502
+ (!A || !B(A, r)) && v("updateAnnotation", r, A);
503
+ }), u = u.map((r) => {
504
+ const A = g.find(({ id: m }) => m === r.id);
505
+ return A || r;
501
506
  });
502
507
  };
503
508
  p.subscribe(({ selected: l }) => {
@@ -506,51 +511,51 @@ const ae = 250, Te = (e) => {
506
511
  u = l.map(({ id: g }) => i.getAnnotation(g));
507
512
  else if (u.length > 0 && l.length === 0)
508
513
  u.forEach((g) => {
509
- const a = i.getAnnotation(g.id);
510
- a && !B(a, g) && E("updateAnnotation", a, g);
514
+ const r = i.getAnnotation(g.id);
515
+ r && !B(r, g) && v("updateAnnotation", r, g);
511
516
  }), u = [];
512
517
  else {
513
- const g = new Set(u.map((m) => m.id)), a = new Set(l.map(({ id: m }) => m));
514
- u.filter((m) => !a.has(m.id)).forEach((m) => {
518
+ const g = new Set(u.map((m) => m.id)), r = new Set(l.map(({ id: m }) => m));
519
+ u.filter((m) => !r.has(m.id)).forEach((m) => {
515
520
  const R = i.getAnnotation(m.id);
516
- R && !B(R, m) && E("updateAnnotation", R, m);
521
+ R && !B(R, m) && v("updateAnnotation", R, m);
517
522
  }), u = [
518
523
  // Remove annotations that were deselected
519
- ...u.filter((m) => a.has(m.id)),
524
+ ...u.filter((m) => r.has(m.id)),
520
525
  // Add editable annotations that were selected
521
526
  ...l.filter(({ id: m }) => !g.has(m)).map(({ id: m }) => i.getAnnotation(m))
522
527
  ];
523
528
  }
524
- E("selectionChanged", u);
529
+ v("selectionChanged", u);
525
530
  }
526
531
  }), w.subscribe((l) => {
527
- !U && l ? E("mouseEnterAnnotation", i.getAnnotation(l)) : U && !l ? E("mouseLeaveAnnotation", i.getAnnotation(U)) : U && l && (E("mouseLeaveAnnotation", i.getAnnotation(U)), E("mouseEnterAnnotation", i.getAnnotation(l))), U = l;
528
- }), b == null || b.subscribe((l) => E("viewportIntersect", l.map((g) => i.getAnnotation(g)))), i.observe((l) => {
532
+ !U && l ? v("mouseEnterAnnotation", i.getAnnotation(l)) : U && !l ? v("mouseLeaveAnnotation", i.getAnnotation(U)) : U && l && (v("mouseLeaveAnnotation", i.getAnnotation(U)), v("mouseEnterAnnotation", i.getAnnotation(l))), U = l;
533
+ }), b == null || b.subscribe((l) => v("viewportIntersect", l.map((g) => i.getAnnotation(g)))), i.observe((l) => {
529
534
  o && (s && clearTimeout(s), s = setTimeout(S, 1e3));
530
- const { created: g, deleted: a } = l.changes;
531
- (g || []).forEach((m) => E("createAnnotation", m)), (a || []).forEach((m) => E("deleteAnnotation", m)), (l.changes.updated || []).filter((m) => [
535
+ const { created: g, deleted: r } = l.changes;
536
+ (g || []).forEach((m) => v("createAnnotation", m)), (r || []).forEach((m) => v("deleteAnnotation", m)), (l.changes.updated || []).filter((m) => [
532
537
  ...m.bodiesCreated || [],
533
538
  ...m.bodiesDeleted || [],
534
539
  ...m.bodiesUpdated || []
535
540
  ].length > 0).forEach(({ oldValue: m, newValue: R }) => {
536
541
  const N = u.find((x) => x.id === m.id) || m;
537
- u = u.map((x) => x.id === m.id ? R : x), E("updateAnnotation", R, N);
542
+ u = u.map((x) => x.id === m.id ? R : x), v("updateAnnotation", R, N);
538
543
  });
539
544
  }, { origin: O.LOCAL }), i.observe((l) => {
540
545
  if (u) {
541
- const g = new Set(u.map((A) => A.id)), a = (l.changes.updated || []).filter(({ newValue: A }) => g.has(A.id)).map(({ newValue: A }) => A);
542
- a.length > 0 && (u = u.map((A) => {
543
- const m = a.find((R) => R.id === A.id);
546
+ const g = new Set(u.map((A) => A.id)), r = (l.changes.updated || []).filter(({ newValue: A }) => g.has(A.id)).map(({ newValue: A }) => A);
547
+ r.length > 0 && (u = u.map((A) => {
548
+ const m = r.find((R) => R.id === A.id);
544
549
  return m || A;
545
550
  }));
546
551
  }
547
552
  }, { origin: O.REMOTE });
548
- const y = (l) => (g) => {
549
- const { updated: a } = g;
550
- l ? (a || []).forEach((A) => E("updateAnnotation", A.oldValue, A.newValue)) : (a || []).forEach((A) => E("updateAnnotation", A.newValue, A.oldValue));
553
+ const E = (l) => (g) => {
554
+ const { updated: r } = g;
555
+ l ? (r || []).forEach((A) => v("updateAnnotation", A.oldValue, A.newValue)) : (r || []).forEach((A) => v("updateAnnotation", A.newValue, A.oldValue));
551
556
  };
552
- return n.on("undo", y(!0)), n.on("redo", y(!1)), { on: h, off: L, emit: E };
553
- }, Be = (e) => (n) => n.map((t) => e.serialize(t)), re = (e) => (n) => n.reduce((t, o) => {
557
+ return n.on("undo", E(!0)), n.on("redo", E(!1)), { on: h, off: L, emit: v };
558
+ }, xe = (e) => (n) => n.map((t) => e.serialize(t)), ce = (e) => (n) => n.reduce((t, o) => {
554
559
  const { parsed: i, error: p } = e.parse(o);
555
560
  return p ? {
556
561
  parsed: t.parsed,
@@ -561,45 +566,45 @@ const ae = 250, Te = (e) => {
561
566
  } : {
562
567
  ...t
563
568
  };
564
- }, { parsed: [], failed: [] }), xe = (e, n, t) => {
565
- const { store: o, selection: i } = e, p = (y) => {
569
+ }, { parsed: [], failed: [] }), Ie = (e, n, t) => {
570
+ const { store: o, selection: i } = e, p = (E) => {
566
571
  if (t) {
567
- const { parsed: l, error: g } = t.parse(y);
572
+ const { parsed: l, error: g } = t.parse(E);
568
573
  l ? o.addAnnotation(l, O.REMOTE) : console.error(g);
569
574
  } else
570
- o.addAnnotation(y, O.REMOTE);
571
- }, w = () => i.clear(), b = () => o.clear(), v = (y) => {
572
- const l = o.getAnnotation(y);
575
+ o.addAnnotation(E, O.REMOTE);
576
+ }, w = () => i.clear(), b = () => o.clear(), y = (E) => {
577
+ const l = o.getAnnotation(E);
573
578
  return t && l ? t.serialize(l) : l;
574
579
  }, u = () => t ? o.all().map(t.serialize) : o.all(), U = () => {
575
580
  var g;
576
- const l = (((g = i.selected) == null ? void 0 : g.map((a) => a.id)) || []).map((a) => o.getAnnotation(a)).filter(Boolean);
581
+ const l = (((g = i.selected) == null ? void 0 : g.map((r) => r.id)) || []).map((r) => o.getAnnotation(r)).filter(Boolean);
577
582
  return t ? l.map(t.serialize) : l;
578
- }, s = (y, l = !0) => fetch(y).then((g) => g.json()).then((g) => (L(g, l), g)), h = (y) => {
579
- if (typeof y == "string") {
580
- const l = o.getAnnotation(y);
581
- if (o.deleteAnnotation(y), l)
583
+ }, s = (E, l = !0) => fetch(E).then((g) => g.json()).then((g) => (L(g, l), g)), h = (E) => {
584
+ if (typeof E == "string") {
585
+ const l = o.getAnnotation(E);
586
+ if (o.deleteAnnotation(E), l)
582
587
  return t ? t.serialize(l) : l;
583
588
  } else {
584
- const l = t ? t.parse(y).parsed : y;
589
+ const l = t ? t.parse(E).parsed : E;
585
590
  if (l)
586
- return o.deleteAnnotation(l), y;
591
+ return o.deleteAnnotation(l), E;
587
592
  }
588
- }, L = (y, l = !0) => {
593
+ }, L = (E, l = !0) => {
589
594
  if (t) {
590
- const { parsed: g, failed: a } = re(t)(y);
591
- a.length > 0 && console.warn(`Discarded ${a.length} invalid annotations`, a), o.bulkAddAnnotation(g, l, O.REMOTE);
595
+ const { parsed: g, failed: r } = ce(t)(E);
596
+ r.length > 0 && console.warn(`Discarded ${r.length} invalid annotations`, r), o.bulkAddAnnotation(g, l, O.REMOTE);
592
597
  } else
593
- o.bulkAddAnnotation(y, l, O.REMOTE);
594
- }, E = (y) => {
595
- y ? i.setSelected(y) : i.clear();
596
- }, S = (y) => {
598
+ o.bulkAddAnnotation(E, l, O.REMOTE);
599
+ }, v = (E, l) => {
600
+ E ? i.setSelected(E, l) : i.clear();
601
+ }, S = (E) => {
597
602
  if (t) {
598
- const l = t.parse(y).parsed, g = t.serialize(o.getAnnotation(l.id));
603
+ const l = t.parse(E).parsed, g = t.serialize(o.getAnnotation(l.id));
599
604
  return o.updateAnnotation(l), g;
600
605
  } else {
601
- const l = o.getAnnotation(y.id);
602
- return o.updateAnnotation(y), l;
606
+ const l = o.getAnnotation(E.id);
607
+ return o.updateAnnotation(E), l;
603
608
  }
604
609
  };
605
610
  return {
@@ -608,36 +613,36 @@ const ae = 250, Te = (e) => {
608
613
  canRedo: n.canRedo,
609
614
  canUndo: n.canUndo,
610
615
  clearAnnotations: b,
611
- getAnnotationById: v,
616
+ getAnnotationById: y,
612
617
  getAnnotations: u,
613
618
  getSelected: U,
614
619
  loadAnnotations: s,
615
620
  redo: n.redo,
616
621
  removeAnnotation: h,
617
622
  setAnnotations: L,
618
- setSelected: E,
623
+ setSelected: v,
619
624
  undo: n.undo,
620
625
  updateAnnotation: S
621
626
  };
622
- }, ce = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
623
- let le = (e) => crypto.getRandomValues(new Uint8Array(e)), ue = (e, n, t) => {
627
+ }, le = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
628
+ let ue = (e) => crypto.getRandomValues(new Uint8Array(e)), fe = (e, n, t) => {
624
629
  let o = (2 << Math.log(e.length - 1) / Math.LN2) - 1, i = -~(1.6 * o * n / e.length);
625
630
  return (p = n) => {
626
631
  let w = "";
627
632
  for (; ; ) {
628
- let b = t(i), v = i;
629
- for (; v--; )
630
- if (w += e[b[v] & o] || "", w.length === p)
633
+ let b = t(i), y = i;
634
+ for (; y--; )
635
+ if (w += e[b[y] & o] || "", w.length === p)
631
636
  return w;
632
637
  }
633
638
  };
634
- }, fe = (e, n = 21) => ue(e, n, le), pe = (e = 21) => {
639
+ }, pe = (e, n = 21) => fe(e, n, ue), he = (e = 21) => {
635
640
  let n = "", t = crypto.getRandomValues(new Uint8Array(e));
636
641
  for (; e--; )
637
- n += ce[t[e] & 63];
642
+ n += le[t[e] & 63];
638
643
  return n;
639
644
  };
640
- const Ie = () => ({ isGuest: !0, id: fe("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), he = (e) => {
645
+ const ke = () => ({ isGuest: !0, id: pe("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), ge = (e) => {
641
646
  const n = JSON.stringify(e);
642
647
  let t = 0;
643
648
  for (let o = 0, i = n.length; o < i; o++) {
@@ -645,20 +650,20 @@ const Ie = () => ({ isGuest: !0, id: fe("1234567890abcdefghijklmnopqrstuvwxyzABC
645
650
  t = (t << 5) - t + p, t |= 0;
646
651
  }
647
652
  return `${t}`;
648
- }, ge = (e) => e ? typeof e == "object" ? { ...e } : e : void 0, ke = (e, n) => (Array.isArray(e) ? e : [e]).map((t) => {
649
- const { id: o, type: i, purpose: p, value: w, created: b, modified: v, creator: u, ...U } = t;
653
+ }, me = (e) => e ? typeof e == "object" ? { ...e } : e : void 0, Ne = (e, n) => (Array.isArray(e) ? e : [e]).map((t) => {
654
+ const { id: o, type: i, purpose: p, value: w, created: b, modified: y, creator: u, ...U } = t;
650
655
  return {
651
- id: o || `temp-${he(t)}`,
656
+ id: o || `temp-${ge(t)}`,
652
657
  annotation: n,
653
658
  type: i,
654
659
  purpose: p,
655
660
  value: w,
656
- creator: ge(u),
661
+ creator: me(u),
657
662
  created: b ? new Date(b) : void 0,
658
- updated: v ? new Date(v) : void 0,
663
+ updated: y ? new Date(y) : void 0,
659
664
  ...U
660
665
  };
661
- }), Ne = (e) => e.map((n) => {
666
+ }), $e = (e) => e.map((n) => {
662
667
  var b;
663
668
  const { annotation: t, created: o, updated: i, ...p } = n, w = {
664
669
  ...p,
@@ -666,7 +671,7 @@ const Ie = () => ({ isGuest: !0, id: fe("1234567890abcdefghijklmnopqrstuvwxyzABC
666
671
  modified: i == null ? void 0 : i.toISOString()
667
672
  };
668
673
  return (b = w.id) != null && b.startsWith("temp-") && delete w.id, w;
669
- }), me = [
674
+ }), Ae = [
670
675
  "#ff7c00",
671
676
  // orange
672
677
  "#1ac938",
@@ -685,14 +690,14 @@ const Ie = () => ({ isGuest: !0, id: fe("1234567890abcdefghijklmnopqrstuvwxyzABC
685
690
  // cyan
686
691
  "#023eff"
687
692
  // blue
688
- ], Ae = () => {
689
- const e = [...me];
693
+ ], be = () => {
694
+ const e = [...Ae];
690
695
  return { assignRandomColor: () => {
691
696
  const o = Math.floor(Math.random() * e.length), i = e[o];
692
697
  return e.splice(o, 1), i;
693
698
  }, releaseColor: (o) => e.push(o) };
694
- }, be = () => {
695
- const e = Ae();
699
+ }, ve = () => {
700
+ const e = be();
696
701
  return { addUser: (o, i) => {
697
702
  const p = e.assignRandomColor();
698
703
  return {
@@ -701,8 +706,8 @@ const Ie = () => ({ isGuest: !0, id: fe("1234567890abcdefghijklmnopqrstuvwxyzABC
701
706
  color: p
702
707
  };
703
708
  }, removeUser: (o) => e.releaseColor(o.appearance.color) };
704
- }, Ee = (e, n) => e.every((t) => e.includes(t)) && n.every((t) => e.includes(t)), $e = pe(), ze = (e = be()) => {
705
- const n = W(), t = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), i = (s, h) => {
709
+ }, Ee = (e, n) => e.every((t) => e.includes(t)) && n.every((t) => e.includes(t)), ze = he(), Ve = (e = ve()) => {
710
+ const n = G(), t = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), i = (s, h) => {
706
711
  if (t.has(s)) {
707
712
  console.warn("Attempt to add user that is already present", s, h);
708
713
  return;
@@ -721,20 +726,20 @@ const Ie = () => ({ isGuest: !0, id: fe("1234567890abcdefghijklmnopqrstuvwxyzABC
721
726
  }
722
727
  e.removeUser(h), t.delete(s);
723
728
  }, w = (s) => {
724
- const h = new Set(s.map((S) => S.presenceKey)), L = s.filter(({ presenceKey: S }) => !t.has(S)), E = Array.from(t.values()).filter((S) => !h.has(S.presenceKey));
725
- L.forEach(({ presenceKey: S, user: y }) => i(S, y)), E.forEach((S) => {
726
- const { presenceKey: y } = S;
727
- o.has(y) && n.emit("selectionChange", S, null), p(y);
728
- }), (L.length > 0 || E.length > 0) && n.emit("presence", u());
729
+ const h = new Set(s.map((S) => S.presenceKey)), L = s.filter(({ presenceKey: S }) => !t.has(S)), v = Array.from(t.values()).filter((S) => !h.has(S.presenceKey));
730
+ L.forEach(({ presenceKey: S, user: E }) => i(S, E)), v.forEach((S) => {
731
+ const { presenceKey: E } = S;
732
+ o.has(E) && n.emit("selectionChange", S, null), p(E);
733
+ }), (L.length > 0 || v.length > 0) && n.emit("presence", u());
729
734
  }, b = (s, h) => {
730
735
  const L = t.get(s);
731
736
  if (!L) {
732
737
  console.warn("Activity notification from user that is not present");
733
738
  return;
734
739
  }
735
- const E = o.get(s);
736
- (!E || !Ee(E, h)) && (o.set(s, h), n.emit("selectionChange", L, h));
737
- }, v = (s, h) => {
740
+ const v = o.get(s);
741
+ (!v || !Ee(v, h)) && (o.set(s, h), n.emit("selectionChange", L, h));
742
+ }, y = (s, h) => {
738
743
  const L = t.get(s);
739
744
  if (!L) {
740
745
  console.warn("Selection change for user that is not present", s);
@@ -747,36 +752,36 @@ const Ie = () => ({ isGuest: !0, id: fe("1234567890abcdefghijklmnopqrstuvwxyzABC
747
752
  notifyActivity: b,
748
753
  on: (s, h) => n.on(s, h),
749
754
  syncUsers: w,
750
- updateSelection: v
755
+ updateSelection: y
751
756
  };
752
757
  };
753
758
  export {
754
- oe as Ignore,
759
+ se as Ignore,
755
760
  O as Origin,
756
- $e as PRESENCE_KEY,
757
- G as PointerSelectAction,
758
- Ie as createAnonymousGuest,
759
- xe as createBaseAnnotator,
760
- Ue as createBody,
761
- be as createDefaultAppearenceProvider,
762
- we as createHoverState,
763
- Re as createLifecyleObserver,
764
- ze as createPresenceState,
765
- Ce as createSelectionState,
766
- Se as createStore,
767
- Te as createUndoStack,
768
- De as createViewportState,
769
- Ae as defaultColorProvider,
770
- P as diffAnnotations,
771
- Le as getContributors,
772
- ie as mergeChanges,
773
- H as onPointerSelect,
774
- re as parseAll,
775
- ke as parseW3CBodies,
776
- ge as parseW3CUser,
777
- Be as serializeAll,
778
- Ne as serializeW3CBodies,
779
- se as shouldNotify,
780
- Oe as toSvelteStore
761
+ ze as PRESENCE_KEY,
762
+ F as PointerSelectAction,
763
+ ke as createAnonymousGuest,
764
+ Ie as createBaseAnnotator,
765
+ Se as createBody,
766
+ ve as createDefaultAppearenceProvider,
767
+ Ce as createHoverState,
768
+ Be as createLifecyleObserver,
769
+ Ve as createPresenceState,
770
+ Le as createSelectionState,
771
+ Oe as createStore,
772
+ De as createUndoStack,
773
+ Re as createViewportState,
774
+ be as defaultColorProvider,
775
+ q as diffAnnotations,
776
+ Ue as getContributors,
777
+ de as mergeChanges,
778
+ P as onPointerSelect,
779
+ ce as parseAll,
780
+ Ne as parseW3CBodies,
781
+ me as parseW3CUser,
782
+ xe as serializeAll,
783
+ $e as serializeW3CBodies,
784
+ ie as shouldNotify,
785
+ Te as toSvelteStore
781
786
  };
782
787
  //# sourceMappingURL=annotorious-core.es.js.map