@annotorious/core 3.0.20 → 3.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/annotorious-core.es.js +84 -84
- package/dist/annotorious-core.es.js.map +1 -1
- package/package.json +13 -13
|
@@ -30,10 +30,10 @@ function j(e, t = V) {
|
|
|
30
30
|
const o = /* @__PURE__ */ new Set();
|
|
31
31
|
function s(b) {
|
|
32
32
|
if (X(e, b) && (e = b, n)) {
|
|
33
|
-
const
|
|
33
|
+
const v = !N.length;
|
|
34
34
|
for (const m of o)
|
|
35
35
|
m[1](), N.push(m, e);
|
|
36
|
-
if (
|
|
36
|
+
if (v) {
|
|
37
37
|
for (let m = 0; m < N.length; m += 2)
|
|
38
38
|
N[m][0](N[m + 1]);
|
|
39
39
|
N.length = 0;
|
|
@@ -43,8 +43,8 @@ function j(e, t = V) {
|
|
|
43
43
|
function f(b) {
|
|
44
44
|
s(b(e));
|
|
45
45
|
}
|
|
46
|
-
function A(b,
|
|
47
|
-
const m = [b,
|
|
46
|
+
function A(b, v = V) {
|
|
47
|
+
const m = [b, v];
|
|
48
48
|
return o.add(m), o.size === 1 && (n = t(s, f) || V), b(e), () => {
|
|
49
49
|
o.delete(m), o.size === 0 && n && (n(), n = null);
|
|
50
50
|
};
|
|
@@ -75,11 +75,11 @@ const z = { selected: [] }, Se = (e, t, n) => {
|
|
|
75
75
|
o((h) => A = h);
|
|
76
76
|
const b = () => {
|
|
77
77
|
k(A, z) || s(z);
|
|
78
|
-
},
|
|
78
|
+
}, v = () => {
|
|
79
79
|
var h;
|
|
80
80
|
return ((h = A.selected) == null ? void 0 : h.length) === 0;
|
|
81
81
|
}, m = (h) => {
|
|
82
|
-
if (
|
|
82
|
+
if (v())
|
|
83
83
|
return !1;
|
|
84
84
|
const C = typeof h == "string" ? h : h.id;
|
|
85
85
|
return A.selected.some((D) => D.id === C);
|
|
@@ -99,8 +99,8 @@ const z = { selected: [] }, Se = (e, t, n) => {
|
|
|
99
99
|
D = [i];
|
|
100
100
|
}
|
|
101
101
|
const a = D.reduce((i, p) => {
|
|
102
|
-
const
|
|
103
|
-
return
|
|
102
|
+
const E = W(p, f, n);
|
|
103
|
+
return E === "EDIT" ? [...i, { id: p.id, editable: !0 }] : E === "SELECT" ? [...i, { id: p.id }] : i;
|
|
104
104
|
}, []);
|
|
105
105
|
s({ selected: a, event: C });
|
|
106
106
|
}, c = (h, C) => {
|
|
@@ -111,8 +111,8 @@ const z = { selected: [] }, Se = (e, t, n) => {
|
|
|
111
111
|
return { id: i.id, editable: p };
|
|
112
112
|
})
|
|
113
113
|
}), a.length !== D.length && console.warn("Invalid selection", h);
|
|
114
|
-
},
|
|
115
|
-
if (
|
|
114
|
+
}, w = (h) => {
|
|
115
|
+
if (v())
|
|
116
116
|
return !1;
|
|
117
117
|
const { selected: C } = A;
|
|
118
118
|
C.some(({ id: a }) => h.includes(a)) && s({ selected: C.filter(({ id: a }) => !h.includes(a)) });
|
|
@@ -120,7 +120,7 @@ const z = { selected: [] }, Se = (e, t, n) => {
|
|
|
120
120
|
f = h, c(A.selected.map(({ id: C }) => C));
|
|
121
121
|
};
|
|
122
122
|
return e.observe(
|
|
123
|
-
({ changes: h }) =>
|
|
123
|
+
({ changes: h }) => w((h.deleted || []).map((C) => C.id))
|
|
124
124
|
), {
|
|
125
125
|
get event() {
|
|
126
126
|
return A ? A.event : null;
|
|
@@ -132,7 +132,7 @@ const z = { selected: [] }, Se = (e, t, n) => {
|
|
|
132
132
|
return f;
|
|
133
133
|
},
|
|
134
134
|
clear: b,
|
|
135
|
-
isEmpty:
|
|
135
|
+
isEmpty: v,
|
|
136
136
|
isSelected: m,
|
|
137
137
|
setSelected: c,
|
|
138
138
|
setUserSelectAction: T,
|
|
@@ -160,7 +160,7 @@ function ee() {
|
|
|
160
160
|
}
|
|
161
161
|
const te = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), q = { randomUUID: te };
|
|
162
162
|
function G(e, t, n) {
|
|
163
|
-
if (q.randomUUID && !
|
|
163
|
+
if (q.randomUUID && !e)
|
|
164
164
|
return q.randomUUID();
|
|
165
165
|
e = e || {};
|
|
166
166
|
const o = e.random || (e.rng || ee)();
|
|
@@ -216,9 +216,9 @@ const re = (e, t) => {
|
|
|
216
216
|
if (!(e.options.origin ? e.options.origin === o : o !== "SILENT"))
|
|
217
217
|
return !1;
|
|
218
218
|
if (e.options.ignore) {
|
|
219
|
-
const { ignore: b } = e.options,
|
|
220
|
-
if (!(
|
|
221
|
-
const U = (f = n.updated) == null ? void 0 : f.some((
|
|
219
|
+
const { ignore: b } = e.options, v = (U) => U && U.length > 0;
|
|
220
|
+
if (!(v(n.created) || v(n.deleted))) {
|
|
221
|
+
const U = (f = n.updated) == null ? void 0 : f.some((w) => v(w.bodiesCreated) || v(w.bodiesDeleted) || v(w.bodiesUpdated)), c = (A = n.updated) == null ? void 0 : A.some((w) => w.targetUpdated);
|
|
222
222
|
if (b === "BODY_ONLY" && U && !c || b === "TARGET_ONLY" && c && !U)
|
|
223
223
|
return !1;
|
|
224
224
|
}
|
|
@@ -233,24 +233,24 @@ const re = (e, t) => {
|
|
|
233
233
|
} else
|
|
234
234
|
return !0;
|
|
235
235
|
}, ae = (e, t) => {
|
|
236
|
-
const n = new Set((e.created || []).map((c) => c.id)), o = new Set((e.updated || []).map(({ newValue: c }) => c.id)), s = new Set((t.created || []).map((c) => c.id)), f = new Set((t.deleted || []).map((c) => c.id)), A = new Set((t.updated || []).map(({ oldValue: c }) => c.id)), b = new Set((t.updated || []).filter(({ oldValue: c }) => n.has(c.id) || o.has(c.id)).map(({ oldValue: c }) => c.id)),
|
|
237
|
-
...(e.created || []).filter((c) => !f.has(c.id)).map((c) => A.has(c.id) ? t.updated.find(({ oldValue:
|
|
236
|
+
const n = new Set((e.created || []).map((c) => c.id)), o = new Set((e.updated || []).map(({ newValue: c }) => c.id)), s = new Set((t.created || []).map((c) => c.id)), f = new Set((t.deleted || []).map((c) => c.id)), A = new Set((t.updated || []).map(({ oldValue: c }) => c.id)), b = new Set((t.updated || []).filter(({ oldValue: c }) => n.has(c.id) || o.has(c.id)).map(({ oldValue: c }) => c.id)), v = [
|
|
237
|
+
...(e.created || []).filter((c) => !f.has(c.id)).map((c) => A.has(c.id) ? t.updated.find(({ oldValue: w }) => w.id === c.id).newValue : c),
|
|
238
238
|
...t.created || []
|
|
239
239
|
], m = [
|
|
240
240
|
...(e.deleted || []).filter((c) => !s.has(c.id)),
|
|
241
241
|
...(t.deleted || []).filter((c) => !n.has(c.id))
|
|
242
242
|
], U = [
|
|
243
243
|
...(e.updated || []).filter(({ newValue: c }) => !f.has(c.id)).map((c) => {
|
|
244
|
-
const { oldValue:
|
|
244
|
+
const { oldValue: w, newValue: T } = c;
|
|
245
245
|
if (A.has(T.id)) {
|
|
246
246
|
const h = t.updated.find((C) => C.oldValue.id === T.id).newValue;
|
|
247
|
-
return J(
|
|
247
|
+
return J(w, h);
|
|
248
248
|
} else
|
|
249
249
|
return c;
|
|
250
250
|
}),
|
|
251
251
|
...(t.updated || []).filter(({ oldValue: c }) => !b.has(c.id))
|
|
252
252
|
];
|
|
253
|
-
return { created:
|
|
253
|
+
return { created: v, deleted: m, updated: U };
|
|
254
254
|
}, $ = (e) => {
|
|
255
255
|
const t = e.id === void 0 ? G() : e.id;
|
|
256
256
|
return {
|
|
@@ -298,7 +298,7 @@ const re = (e, t) => {
|
|
|
298
298
|
return g === u.id ? e.set(g, u) : (e.delete(g), e.set(u.id, u)), S.bodies.forEach((x) => t.delete(x.id)), u.bodies.forEach((x) => t.set(x.id, u.id)), y;
|
|
299
299
|
} else
|
|
300
300
|
console.warn(`Cannot update annotation ${g} - does not exist`);
|
|
301
|
-
},
|
|
301
|
+
}, v = (d, l = O.LOCAL, u = O.LOCAL) => {
|
|
302
302
|
const g = ce(l) ? u : l, S = b(d, l);
|
|
303
303
|
S && f(g, { updated: [S] });
|
|
304
304
|
}, m = (d, l = O.LOCAL) => {
|
|
@@ -321,7 +321,7 @@ const re = (e, t) => {
|
|
|
321
321
|
}] });
|
|
322
322
|
} else
|
|
323
323
|
console.warn(`Attempt to add body to missing annotation: ${d.annotation}`);
|
|
324
|
-
}, c = () => [...e.values()],
|
|
324
|
+
}, c = () => [...e.values()], w = (d = O.LOCAL) => {
|
|
325
325
|
const l = [...e.values()];
|
|
326
326
|
e.clear(), t.clear(), f(d, { deleted: l });
|
|
327
327
|
}, T = (d, l = !0, u = O.LOCAL) => {
|
|
@@ -381,13 +381,13 @@ const re = (e, t) => {
|
|
|
381
381
|
}, p = (d, l = O.LOCAL) => {
|
|
382
382
|
const u = d.map((g) => a(g)).filter(Boolean);
|
|
383
383
|
u.length > 0 && f(l, { updated: u });
|
|
384
|
-
},
|
|
384
|
+
}, E = (d) => {
|
|
385
385
|
const l = e.get(d);
|
|
386
386
|
return l ? { ...l } : void 0;
|
|
387
387
|
}, r = (d) => {
|
|
388
388
|
const l = t.get(d);
|
|
389
389
|
if (l) {
|
|
390
|
-
const g =
|
|
390
|
+
const g = E(l).bodies.find((S) => S.id === d);
|
|
391
391
|
if (g)
|
|
392
392
|
return g;
|
|
393
393
|
console.error(`Store integrity error: body ${d} in index, but not in annotation`);
|
|
@@ -449,14 +449,14 @@ const re = (e, t) => {
|
|
|
449
449
|
const u = d.map((g) => P(g)).filter(Boolean);
|
|
450
450
|
u.length > 0 && f(l, { updated: u });
|
|
451
451
|
},
|
|
452
|
-
clear:
|
|
452
|
+
clear: w,
|
|
453
453
|
deleteAnnotation: C,
|
|
454
454
|
deleteBody: i,
|
|
455
|
-
getAnnotation:
|
|
455
|
+
getAnnotation: E,
|
|
456
456
|
getBody: r,
|
|
457
457
|
observe: o,
|
|
458
458
|
unobserve: s,
|
|
459
|
-
updateAnnotation:
|
|
459
|
+
updateAnnotation: v,
|
|
460
460
|
updateBody: B,
|
|
461
461
|
updateTarget: (d, l = O.LOCAL) => {
|
|
462
462
|
const u = P(d);
|
|
@@ -501,7 +501,7 @@ const le = 250, Be = (e, t) => {
|
|
|
501
501
|
f = !1;
|
|
502
502
|
};
|
|
503
503
|
e.observe(b, { origin: O.LOCAL });
|
|
504
|
-
const
|
|
504
|
+
const v = (r) => r && r.length > 0 && e.bulkDeleteAnnotation(r), m = (r) => r && r.length > 0 && e.bulkAddAnnotation(r, !1), U = (r) => r && r.length > 0 && e.bulkUpdateAnnotation(r.map(({ oldValue: L }) => L)), c = (r) => r && r.length > 0 && e.bulkUpdateAnnotation(r.map(({ newValue: L }) => L)), w = (r) => r && r.length > 0 && e.bulkAddAnnotation(r, !1), T = (r) => r && r.length > 0 && e.bulkDeleteAnnotation(r);
|
|
505
505
|
return {
|
|
506
506
|
canRedo: () => o.length - 1 > s,
|
|
507
507
|
canUndo: () => s > -1,
|
|
@@ -519,7 +519,7 @@ const le = 250, Be = (e, t) => {
|
|
|
519
519
|
if (s > -1) {
|
|
520
520
|
f = !0;
|
|
521
521
|
const { created: r, updated: L, deleted: B } = o[s];
|
|
522
|
-
|
|
522
|
+
v(r), U(L), w(B), n.emit("undo", o[s]), s -= 1;
|
|
523
523
|
}
|
|
524
524
|
}
|
|
525
525
|
};
|
|
@@ -530,34 +530,34 @@ const le = 250, Be = (e, t) => {
|
|
|
530
530
|
set: t
|
|
531
531
|
};
|
|
532
532
|
}, Ie = (e, t, n, o) => {
|
|
533
|
-
const { hover: s, selection: f, store: A, viewport: b } = e,
|
|
533
|
+
const { hover: s, selection: f, store: A, viewport: b } = e, v = /* @__PURE__ */ new Map();
|
|
534
534
|
let m = [], U, c;
|
|
535
|
-
const
|
|
536
|
-
|
|
535
|
+
const w = (a, i) => {
|
|
536
|
+
v.has(a) ? v.get(a).push(i) : v.set(a, [i]);
|
|
537
537
|
}, T = (a, i) => {
|
|
538
|
-
const p =
|
|
538
|
+
const p = v.get(a);
|
|
539
539
|
if (p) {
|
|
540
|
-
const
|
|
541
|
-
|
|
540
|
+
const E = p.indexOf(i);
|
|
541
|
+
E !== -1 && p.splice(E, 1);
|
|
542
542
|
}
|
|
543
543
|
}, h = (a, i, p) => {
|
|
544
|
-
|
|
545
|
-
|
|
544
|
+
v.has(a) && setTimeout(() => {
|
|
545
|
+
v.get(a).forEach((E) => {
|
|
546
546
|
if (n) {
|
|
547
547
|
const r = Array.isArray(i) ? i.map((B) => n.serialize(B)) : n.serialize(i), L = p ? p instanceof PointerEvent ? p : n.serialize(p) : void 0;
|
|
548
|
-
|
|
548
|
+
E(r, L);
|
|
549
549
|
} else
|
|
550
|
-
|
|
550
|
+
E(i, p);
|
|
551
551
|
});
|
|
552
552
|
}, 1);
|
|
553
553
|
}, C = () => {
|
|
554
554
|
const { selected: a } = f, i = (a || []).map(({ id: p }) => A.getAnnotation(p));
|
|
555
555
|
i.forEach((p) => {
|
|
556
|
-
const
|
|
557
|
-
(!
|
|
556
|
+
const E = m.find((r) => r.id === p.id);
|
|
557
|
+
(!E || !k(E, p)) && h("updateAnnotation", p, E);
|
|
558
558
|
}), m = m.map((p) => {
|
|
559
|
-
const
|
|
560
|
-
return
|
|
559
|
+
const E = i.find(({ id: r }) => r === p.id);
|
|
560
|
+
return E || p;
|
|
561
561
|
});
|
|
562
562
|
};
|
|
563
563
|
f.subscribe(({ selected: a }) => {
|
|
@@ -598,18 +598,18 @@ const le = 250, Be = (e, t) => {
|
|
|
598
598
|
});
|
|
599
599
|
}, { origin: O.LOCAL }), A.observe((a) => {
|
|
600
600
|
if (m) {
|
|
601
|
-
const i = new Set(m.map((
|
|
602
|
-
p.length > 0 && (m = m.map((
|
|
603
|
-
const r = p.find((L) => L.id ===
|
|
604
|
-
return r ||
|
|
601
|
+
const i = new Set(m.map((E) => E.id)), p = (a.changes.updated || []).filter(({ newValue: E }) => i.has(E.id)).map(({ newValue: E }) => E);
|
|
602
|
+
p.length > 0 && (m = m.map((E) => {
|
|
603
|
+
const r = p.find((L) => L.id === E.id);
|
|
604
|
+
return r || E;
|
|
605
605
|
}));
|
|
606
606
|
}
|
|
607
607
|
}, { origin: O.REMOTE });
|
|
608
608
|
const D = (a) => (i) => {
|
|
609
609
|
const { updated: p } = i;
|
|
610
|
-
a ? (p || []).forEach((
|
|
610
|
+
a ? (p || []).forEach((E) => h("updateAnnotation", E.oldValue, E.newValue)) : (p || []).forEach((E) => h("updateAnnotation", E.newValue, E.oldValue));
|
|
611
611
|
};
|
|
612
|
-
return t.on("undo", D(!0)), t.on("redo", D(!1)), { on:
|
|
612
|
+
return t.on("undo", D(!0)), t.on("redo", D(!1)), { on: w, off: T, emit: h };
|
|
613
613
|
}, ke = (e) => (t) => t.map((n) => e.serialize(n)), ue = (e) => (t) => t.reduce((n, o) => {
|
|
614
614
|
const { parsed: s, error: f } = e.parse(o);
|
|
615
615
|
return f ? {
|
|
@@ -628,14 +628,14 @@ const le = 250, Be = (e, t) => {
|
|
|
628
628
|
i ? o.addAnnotation(i, O.REMOTE) : console.error(p);
|
|
629
629
|
} else
|
|
630
630
|
o.addAnnotation(Y(a), O.REMOTE);
|
|
631
|
-
}, A = () => s.clear(), b = () => o.clear(),
|
|
631
|
+
}, A = () => s.clear(), b = () => o.clear(), v = (a) => {
|
|
632
632
|
const i = o.getAnnotation(a);
|
|
633
633
|
return n && i ? n.serialize(i) : i;
|
|
634
634
|
}, m = () => n ? o.all().map(n.serialize) : o.all(), U = () => {
|
|
635
635
|
var p;
|
|
636
|
-
const i = (((p = s.selected) == null ? void 0 : p.map((
|
|
636
|
+
const i = (((p = s.selected) == null ? void 0 : p.map((E) => E.id)) || []).map((E) => o.getAnnotation(E)).filter(Boolean);
|
|
637
637
|
return n ? i.map(n.serialize) : i;
|
|
638
|
-
}, c = (a, i = !0) => fetch(a).then((p) => p.json()).then((p) => (T(p, i), p)),
|
|
638
|
+
}, c = (a, i = !0) => fetch(a).then((p) => p.json()).then((p) => (T(p, i), p)), w = (a) => {
|
|
639
639
|
if (typeof a == "string") {
|
|
640
640
|
const i = o.getAnnotation(a);
|
|
641
641
|
if (o.deleteAnnotation(a), i)
|
|
@@ -647,8 +647,8 @@ const le = 250, Be = (e, t) => {
|
|
|
647
647
|
}
|
|
648
648
|
}, T = (a, i = !0) => {
|
|
649
649
|
if (n) {
|
|
650
|
-
const p = n.parseAll || ue(n), { parsed:
|
|
651
|
-
r.length > 0 && console.warn(`Discarded ${r.length} invalid annotations`, r), o.bulkAddAnnotation(
|
|
650
|
+
const p = n.parseAll || ue(n), { parsed: E, failed: r } = p(a);
|
|
651
|
+
r.length > 0 && console.warn(`Discarded ${r.length} invalid annotations`, r), o.bulkAddAnnotation(E, i, O.REMOTE);
|
|
652
652
|
} else
|
|
653
653
|
o.bulkAddAnnotation(a.map(Y), i, O.REMOTE);
|
|
654
654
|
}, h = (a, i) => {
|
|
@@ -670,13 +670,13 @@ const le = 250, Be = (e, t) => {
|
|
|
670
670
|
canRedo: t.canRedo,
|
|
671
671
|
canUndo: t.canUndo,
|
|
672
672
|
clearAnnotations: b,
|
|
673
|
-
getAnnotationById:
|
|
673
|
+
getAnnotationById: v,
|
|
674
674
|
getAnnotations: m,
|
|
675
675
|
getHistory: t.getHistory,
|
|
676
676
|
getSelected: U,
|
|
677
677
|
loadAnnotations: c,
|
|
678
678
|
redo: t.redo,
|
|
679
|
-
removeAnnotation:
|
|
679
|
+
removeAnnotation: w,
|
|
680
680
|
setAnnotations: T,
|
|
681
681
|
setSelected: h,
|
|
682
682
|
setUserSelectAction: C,
|
|
@@ -698,9 +698,9 @@ let pe = (e) => crypto.getRandomValues(new Uint8Array(e)), ge = (e, t, n) => {
|
|
|
698
698
|
return (f = t) => {
|
|
699
699
|
let A = "";
|
|
700
700
|
for (; ; ) {
|
|
701
|
-
let b = n(s),
|
|
702
|
-
for (;
|
|
703
|
-
if (A += e[b[
|
|
701
|
+
let b = n(s), v = s | 0;
|
|
702
|
+
for (; v--; )
|
|
703
|
+
if (A += e[b[v] & o] || "", A.length >= f) return A;
|
|
704
704
|
}
|
|
705
705
|
};
|
|
706
706
|
}, he = (e, t = 21) => ge(e, t | 0, pe), me = (e = 21) => {
|
|
@@ -718,7 +718,7 @@ const Ve = () => ({ isGuest: !0, id: he("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
718
718
|
}
|
|
719
719
|
return `${n}`;
|
|
720
720
|
}, be = (e) => e ? typeof e == "object" ? { ...e } : e : void 0, _e = (e, t) => (Array.isArray(e) ? e : [e]).map((n) => {
|
|
721
|
-
const { id: o, type: s, purpose: f, value: A, created: b, modified:
|
|
721
|
+
const { id: o, type: s, purpose: f, value: A, created: b, modified: v, creator: m, ...U } = n;
|
|
722
722
|
return {
|
|
723
723
|
id: o || `temp-${Ae(n)}`,
|
|
724
724
|
annotation: t,
|
|
@@ -727,7 +727,7 @@ const Ve = () => ({ isGuest: !0, id: he("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
727
727
|
value: A,
|
|
728
728
|
creator: be(m),
|
|
729
729
|
created: b ? new Date(b) : void 0,
|
|
730
|
-
updated:
|
|
730
|
+
updated: v ? new Date(v) : void 0,
|
|
731
731
|
...U
|
|
732
732
|
};
|
|
733
733
|
}), Ye = (e) => e.map((t) => {
|
|
@@ -738,7 +738,7 @@ const Ve = () => ({ isGuest: !0, id: he("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
738
738
|
modified: s == null ? void 0 : s.toISOString()
|
|
739
739
|
};
|
|
740
740
|
return (b = A.id) != null && b.startsWith("temp-") && delete A.id, A;
|
|
741
|
-
}),
|
|
741
|
+
}), Ee = [
|
|
742
742
|
"#ff7c00",
|
|
743
743
|
// orange
|
|
744
744
|
"#1ac938",
|
|
@@ -757,14 +757,14 @@ const Ve = () => ({ isGuest: !0, id: he("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
757
757
|
// cyan
|
|
758
758
|
"#023eff"
|
|
759
759
|
// blue
|
|
760
|
-
],
|
|
761
|
-
const e = [...
|
|
760
|
+
], we = () => {
|
|
761
|
+
const e = [...Ee];
|
|
762
762
|
return { assignRandomColor: () => {
|
|
763
763
|
const o = Math.floor(Math.random() * e.length), s = e[o];
|
|
764
764
|
return e.splice(o, 1), s;
|
|
765
765
|
}, releaseColor: (o) => e.push(o) };
|
|
766
|
-
},
|
|
767
|
-
const e =
|
|
766
|
+
}, ve = () => {
|
|
767
|
+
const e = we();
|
|
768
768
|
return { addUser: (o, s) => {
|
|
769
769
|
const f = e.assignRandomColor();
|
|
770
770
|
return {
|
|
@@ -773,53 +773,53 @@ const Ve = () => ({ isGuest: !0, id: he("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
773
773
|
color: f
|
|
774
774
|
};
|
|
775
775
|
}, removeUser: (o) => e.releaseColor(o.appearance.color) };
|
|
776
|
-
}, Ce = (e, t) => e.every((n) => e.includes(n)) && t.every((n) => e.includes(n)), je = me(), Pe = (e =
|
|
777
|
-
const t = Q(), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = (c,
|
|
776
|
+
}, Ce = (e, t) => e.every((n) => e.includes(n)) && t.every((n) => e.includes(n)), je = me(), Pe = (e = ve()) => {
|
|
777
|
+
const t = Q(), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = (c, w) => {
|
|
778
778
|
if (n.has(c)) {
|
|
779
|
-
console.warn("Attempt to add user that is already present", c,
|
|
779
|
+
console.warn("Attempt to add user that is already present", c, w);
|
|
780
780
|
return;
|
|
781
781
|
}
|
|
782
|
-
const T = e.addUser(c,
|
|
782
|
+
const T = e.addUser(c, w);
|
|
783
783
|
n.set(c, {
|
|
784
|
-
...
|
|
784
|
+
...w,
|
|
785
785
|
presenceKey: c,
|
|
786
786
|
appearance: T
|
|
787
787
|
});
|
|
788
788
|
}, f = (c) => {
|
|
789
|
-
const
|
|
790
|
-
if (!
|
|
789
|
+
const w = n.get(c);
|
|
790
|
+
if (!w) {
|
|
791
791
|
console.warn("Attempt to remove user that is not present", c);
|
|
792
792
|
return;
|
|
793
793
|
}
|
|
794
|
-
e.removeUser(
|
|
794
|
+
e.removeUser(w), n.delete(c);
|
|
795
795
|
}, A = (c) => {
|
|
796
|
-
const
|
|
796
|
+
const w = new Set(c.map((C) => C.presenceKey)), T = c.filter(({ presenceKey: C }) => !n.has(C)), h = Array.from(n.values()).filter((C) => !w.has(C.presenceKey));
|
|
797
797
|
T.forEach(({ presenceKey: C, user: D }) => s(C, D)), h.forEach((C) => {
|
|
798
798
|
const { presenceKey: D } = C;
|
|
799
799
|
o.has(D) && t.emit("selectionChange", C, null), f(D);
|
|
800
800
|
}), (T.length > 0 || h.length > 0) && t.emit("presence", m());
|
|
801
|
-
}, b = (c,
|
|
801
|
+
}, b = (c, w) => {
|
|
802
802
|
const T = n.get(c);
|
|
803
803
|
if (!T) {
|
|
804
804
|
console.warn("Activity notification from user that is not present");
|
|
805
805
|
return;
|
|
806
806
|
}
|
|
807
807
|
const h = o.get(c);
|
|
808
|
-
(!h || !Ce(h,
|
|
809
|
-
},
|
|
808
|
+
(!h || !Ce(h, w)) && (o.set(c, w), t.emit("selectionChange", T, w));
|
|
809
|
+
}, v = (c, w) => {
|
|
810
810
|
const T = n.get(c);
|
|
811
811
|
if (!T) {
|
|
812
812
|
console.warn("Selection change for user that is not present", c);
|
|
813
813
|
return;
|
|
814
814
|
}
|
|
815
|
-
|
|
815
|
+
w ? o.set(c, w) : o.delete(c), t.emit("selectionChange", T, w);
|
|
816
816
|
}, m = () => [...Array.from(n.values())];
|
|
817
817
|
return {
|
|
818
818
|
getPresentUsers: m,
|
|
819
819
|
notifyActivity: b,
|
|
820
|
-
on: (c,
|
|
820
|
+
on: (c, w) => t.on(c, w),
|
|
821
821
|
syncUsers: A,
|
|
822
|
-
updateSelection:
|
|
822
|
+
updateSelection: v
|
|
823
823
|
};
|
|
824
824
|
};
|
|
825
825
|
export {
|
|
@@ -832,7 +832,7 @@ export {
|
|
|
832
832
|
Ve as createAnonymousGuest,
|
|
833
833
|
Ne as createBaseAnnotator,
|
|
834
834
|
De as createBody,
|
|
835
|
-
|
|
835
|
+
ve as createDefaultAppearanceProvider,
|
|
836
836
|
Ue as createHoverState,
|
|
837
837
|
Ie as createLifecycleObserver,
|
|
838
838
|
Pe as createPresenceState,
|
|
@@ -840,7 +840,7 @@ export {
|
|
|
840
840
|
Oe as createStore,
|
|
841
841
|
Be as createUndoStack,
|
|
842
842
|
xe as createViewportState,
|
|
843
|
-
|
|
843
|
+
we as defaultColorProvider,
|
|
844
844
|
J as diffAnnotations,
|
|
845
845
|
Te as getContributors,
|
|
846
846
|
ae as mergeChanges,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotorious-core.es.js","sources":["../../../node_modules/dequal/lite/index.mjs","../../../node_modules/svelte/src/runtime/internal/utils.js","../../../node_modules/svelte/src/runtime/store/index.js","../src/state/Hover.ts","../src/state/Selection.ts","../../../node_modules/uuid/dist/esm-browser/stringify.js","../../../node_modules/uuid/dist/esm-browser/rng.js","../../../node_modules/uuid/dist/esm-browser/native.js","../../../node_modules/uuid/dist/esm-browser/v4.js","../src/utils/annotationUtils.ts","../src/utils/diffAnnotations.ts","../src/state/StoreObserver.ts","../src/state/Store.ts","../src/state/SvelteStore.ts","../../../node_modules/nanoevents/index.js","../src/state/UndoStack.ts","../src/state/Viewport.ts","../src/lifecycle/Lifecycle.ts","../src/model/FormatAdapter.ts","../src/model/Annotator.ts","../src/model/DrawingStyle.ts","../../../node_modules/nanoid/url-alphabet/index.js","../../../node_modules/nanoid/index.browser.js","../src/model/User.ts","../src/model/W3CAnnotation.ts","../src/presence/ColorPalette.ts","../src/presence/AppearanceProvider.ts","../src/presence/PresenceState.ts"],"sourcesContent":["var has = Object.prototype.hasOwnProperty;\n\nexport function dequal(foo, bar) {\n\tvar ctor, len;\n\tif (foo === bar) return true;\n\n\tif (foo && bar && (ctor=foo.constructor) === bar.constructor) {\n\t\tif (ctor === Date) return foo.getTime() === bar.getTime();\n\t\tif (ctor === RegExp) return foo.toString() === bar.toString();\n\n\t\tif (ctor === Array) {\n\t\t\tif ((len=foo.length) === bar.length) {\n\t\t\t\twhile (len-- && dequal(foo[len], bar[len]));\n\t\t\t}\n\t\t\treturn len === -1;\n\t\t}\n\n\t\tif (!ctor || typeof foo === 'object') {\n\t\t\tlen = 0;\n\t\t\tfor (ctor in foo) {\n\t\t\t\tif (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;\n\t\t\t\tif (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;\n\t\t\t}\n\t\t\treturn Object.keys(bar).length === len;\n\t\t}\n\t}\n\n\treturn foo !== foo && bar !== bar;\n}\n","/** @returns {void} */\nexport function noop() {}\n\nexport const identity = (x) => x;\n\n/**\n * @template T\n * @template S\n * @param {T} tar\n * @param {S} src\n * @returns {T & S}\n */\nexport function assign(tar, src) {\n\t// @ts-ignore\n\tfor (const k in src) tar[k] = src[k];\n\treturn /** @type {T & S} */ (tar);\n}\n\n// Adapted from https://github.com/then/is-promise/blob/master/index.js\n// Distributed under MIT License https://github.com/then/is-promise/blob/master/LICENSE\n/**\n * @param {any} value\n * @returns {value is PromiseLike<any>}\n */\nexport function is_promise(value) {\n\treturn (\n\t\t!!value &&\n\t\t(typeof value === 'object' || typeof value === 'function') &&\n\t\ttypeof (/** @type {any} */ (value).then) === 'function'\n\t);\n}\n\n/** @returns {void} */\nexport function add_location(element, file, line, column, char) {\n\telement.__svelte_meta = {\n\t\tloc: { file, line, column, char }\n\t};\n}\n\nexport function run(fn) {\n\treturn fn();\n}\n\nexport function blank_object() {\n\treturn Object.create(null);\n}\n\n/**\n * @param {Function[]} fns\n * @returns {void}\n */\nexport function run_all(fns) {\n\tfns.forEach(run);\n}\n\n/**\n * @param {any} thing\n * @returns {thing is Function}\n */\nexport function is_function(thing) {\n\treturn typeof thing === 'function';\n}\n\n/** @returns {boolean} */\nexport function safe_not_equal(a, b) {\n\treturn a != a ? b == b : a !== b || (a && typeof a === 'object') || typeof a === 'function';\n}\n\nlet src_url_equal_anchor;\n\n/**\n * @param {string} element_src\n * @param {string} url\n * @returns {boolean}\n */\nexport function src_url_equal(element_src, url) {\n\tif (element_src === url) return true;\n\tif (!src_url_equal_anchor) {\n\t\tsrc_url_equal_anchor = document.createElement('a');\n\t}\n\t// This is actually faster than doing URL(..).href\n\tsrc_url_equal_anchor.href = url;\n\treturn element_src === src_url_equal_anchor.href;\n}\n\n/** @param {string} srcset */\nfunction split_srcset(srcset) {\n\treturn srcset.split(',').map((src) => src.trim().split(' ').filter(Boolean));\n}\n\n/**\n * @param {HTMLSourceElement | HTMLImageElement} element_srcset\n * @param {string | undefined | null} srcset\n * @returns {boolean}\n */\nexport function srcset_url_equal(element_srcset, srcset) {\n\tconst element_urls = split_srcset(element_srcset.srcset);\n\tconst urls = split_srcset(srcset || '');\n\n\treturn (\n\t\turls.length === element_urls.length &&\n\t\turls.every(\n\t\t\t([url, width], i) =>\n\t\t\t\twidth === element_urls[i][1] &&\n\t\t\t\t// We need to test both ways because Vite will create an a full URL with\n\t\t\t\t// `new URL(asset, import.meta.url).href` for the client when `base: './'`, and the\n\t\t\t\t// relative URLs inside srcset are not automatically resolved to absolute URLs by\n\t\t\t\t// browsers (in contrast to img.src). This means both SSR and DOM code could\n\t\t\t\t// contain relative or absolute URLs.\n\t\t\t\t(src_url_equal(element_urls[i][0], url) || src_url_equal(url, element_urls[i][0]))\n\t\t)\n\t);\n}\n\n/** @returns {boolean} */\nexport function not_equal(a, b) {\n\treturn a != a ? b == b : a !== b;\n}\n\n/** @returns {boolean} */\nexport function is_empty(obj) {\n\treturn Object.keys(obj).length === 0;\n}\n\n/** @returns {void} */\nexport function validate_store(store, name) {\n\tif (store != null && typeof store.subscribe !== 'function') {\n\t\tthrow new Error(`'${name}' is not a store with a 'subscribe' method`);\n\t}\n}\n\nexport function subscribe(store, ...callbacks) {\n\tif (store == null) {\n\t\tfor (const callback of callbacks) {\n\t\t\tcallback(undefined);\n\t\t}\n\t\treturn noop;\n\t}\n\tconst unsub = store.subscribe(...callbacks);\n\treturn unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;\n}\n\n/**\n * Get the current value from a store by subscribing and immediately unsubscribing.\n *\n * https://svelte.dev/docs/svelte-store#get\n * @template T\n * @param {import('../store/public.js').Readable<T>} store\n * @returns {T}\n */\nexport function get_store_value(store) {\n\tlet value;\n\tsubscribe(store, (_) => (value = _))();\n\treturn value;\n}\n\n/** @returns {void} */\nexport function component_subscribe(component, store, callback) {\n\tcomponent.$$.on_destroy.push(subscribe(store, callback));\n}\n\nexport function create_slot(definition, ctx, $$scope, fn) {\n\tif (definition) {\n\t\tconst slot_ctx = get_slot_context(definition, ctx, $$scope, fn);\n\t\treturn definition[0](slot_ctx);\n\t}\n}\n\nfunction get_slot_context(definition, ctx, $$scope, fn) {\n\treturn definition[1] && fn ? assign($$scope.ctx.slice(), definition[1](fn(ctx))) : $$scope.ctx;\n}\n\nexport function get_slot_changes(definition, $$scope, dirty, fn) {\n\tif (definition[2] && fn) {\n\t\tconst lets = definition[2](fn(dirty));\n\t\tif ($$scope.dirty === undefined) {\n\t\t\treturn lets;\n\t\t}\n\t\tif (typeof lets === 'object') {\n\t\t\tconst merged = [];\n\t\t\tconst len = Math.max($$scope.dirty.length, lets.length);\n\t\t\tfor (let i = 0; i < len; i += 1) {\n\t\t\t\tmerged[i] = $$scope.dirty[i] | lets[i];\n\t\t\t}\n\t\t\treturn merged;\n\t\t}\n\t\treturn $$scope.dirty | lets;\n\t}\n\treturn $$scope.dirty;\n}\n\n/** @returns {void} */\nexport function update_slot_base(\n\tslot,\n\tslot_definition,\n\tctx,\n\t$$scope,\n\tslot_changes,\n\tget_slot_context_fn\n) {\n\tif (slot_changes) {\n\t\tconst slot_context = get_slot_context(slot_definition, ctx, $$scope, get_slot_context_fn);\n\t\tslot.p(slot_context, slot_changes);\n\t}\n}\n\n/** @returns {void} */\nexport function update_slot(\n\tslot,\n\tslot_definition,\n\tctx,\n\t$$scope,\n\tdirty,\n\tget_slot_changes_fn,\n\tget_slot_context_fn\n) {\n\tconst slot_changes = get_slot_changes(slot_definition, $$scope, dirty, get_slot_changes_fn);\n\tupdate_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn);\n}\n\n/** @returns {any[] | -1} */\nexport function get_all_dirty_from_scope($$scope) {\n\tif ($$scope.ctx.length > 32) {\n\t\tconst dirty = [];\n\t\tconst length = $$scope.ctx.length / 32;\n\t\tfor (let i = 0; i < length; i++) {\n\t\t\tdirty[i] = -1;\n\t\t}\n\t\treturn dirty;\n\t}\n\treturn -1;\n}\n\n/** @returns {{}} */\nexport function exclude_internal_props(props) {\n\tconst result = {};\n\tfor (const k in props) if (k[0] !== '$') result[k] = props[k];\n\treturn result;\n}\n\n/** @returns {{}} */\nexport function compute_rest_props(props, keys) {\n\tconst rest = {};\n\tkeys = new Set(keys);\n\tfor (const k in props) if (!keys.has(k) && k[0] !== '$') rest[k] = props[k];\n\treturn rest;\n}\n\n/** @returns {{}} */\nexport function compute_slots(slots) {\n\tconst result = {};\n\tfor (const key in slots) {\n\t\tresult[key] = true;\n\t}\n\treturn result;\n}\n\n/** @returns {(this: any, ...args: any[]) => void} */\nexport function once(fn) {\n\tlet ran = false;\n\treturn function (...args) {\n\t\tif (ran) return;\n\t\tran = true;\n\t\tfn.call(this, ...args);\n\t};\n}\n\nexport function null_to_empty(value) {\n\treturn value == null ? '' : value;\n}\n\nexport function set_store_value(store, ret, value) {\n\tstore.set(value);\n\treturn ret;\n}\n\nexport const has_prop = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);\n\nexport function action_destroyer(action_result) {\n\treturn action_result && is_function(action_result.destroy) ? action_result.destroy : noop;\n}\n\n/** @param {number | string} value\n * @returns {[number, string]}\n */\nexport function split_css_unit(value) {\n\tconst split = typeof value === 'string' && value.match(/^\\s*(-?[\\d.]+)([^\\s]*)\\s*$/);\n\treturn split ? [parseFloat(split[1]), split[2] || 'px'] : [/** @type {number} */ (value), 'px'];\n}\n\nexport const contenteditable_truthy_values = ['', true, 1, 'true', 'contenteditable'];\n","import {\n\trun_all,\n\tsubscribe,\n\tnoop,\n\tsafe_not_equal,\n\tis_function,\n\tget_store_value\n} from '../internal/index.js';\n\nconst subscriber_queue = [];\n\n/**\n * Creates a `Readable` store that allows reading by subscription.\n *\n * https://svelte.dev/docs/svelte-store#readable\n * @template T\n * @param {T} [value] initial value\n * @param {import('./public.js').StartStopNotifier<T>} [start]\n * @returns {import('./public.js').Readable<T>}\n */\nexport function readable(value, start) {\n\treturn {\n\t\tsubscribe: writable(value, start).subscribe\n\t};\n}\n\n/**\n * Create a `Writable` store that allows both updating and reading by subscription.\n *\n * https://svelte.dev/docs/svelte-store#writable\n * @template T\n * @param {T} [value] initial value\n * @param {import('./public.js').StartStopNotifier<T>} [start]\n * @returns {import('./public.js').Writable<T>}\n */\nexport function writable(value, start = noop) {\n\t/** @type {import('./public.js').Unsubscriber} */\n\tlet stop;\n\t/** @type {Set<import('./private.js').SubscribeInvalidateTuple<T>>} */\n\tconst subscribers = new Set();\n\t/** @param {T} new_value\n\t * @returns {void}\n\t */\n\tfunction set(new_value) {\n\t\tif (safe_not_equal(value, new_value)) {\n\t\t\tvalue = new_value;\n\t\t\tif (stop) {\n\t\t\t\t// store is ready\n\t\t\t\tconst run_queue = !subscriber_queue.length;\n\t\t\t\tfor (const subscriber of subscribers) {\n\t\t\t\t\tsubscriber[1]();\n\t\t\t\t\tsubscriber_queue.push(subscriber, value);\n\t\t\t\t}\n\t\t\t\tif (run_queue) {\n\t\t\t\t\tfor (let i = 0; i < subscriber_queue.length; i += 2) {\n\t\t\t\t\t\tsubscriber_queue[i][0](subscriber_queue[i + 1]);\n\t\t\t\t\t}\n\t\t\t\t\tsubscriber_queue.length = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * @param {import('./public.js').Updater<T>} fn\n\t * @returns {void}\n\t */\n\tfunction update(fn) {\n\t\tset(fn(value));\n\t}\n\n\t/**\n\t * @param {import('./public.js').Subscriber<T>} run\n\t * @param {import('./private.js').Invalidator<T>} [invalidate]\n\t * @returns {import('./public.js').Unsubscriber}\n\t */\n\tfunction subscribe(run, invalidate = noop) {\n\t\t/** @type {import('./private.js').SubscribeInvalidateTuple<T>} */\n\t\tconst subscriber = [run, invalidate];\n\t\tsubscribers.add(subscriber);\n\t\tif (subscribers.size === 1) {\n\t\t\tstop = start(set, update) || noop;\n\t\t}\n\t\trun(value);\n\t\treturn () => {\n\t\t\tsubscribers.delete(subscriber);\n\t\t\tif (subscribers.size === 0 && stop) {\n\t\t\t\tstop();\n\t\t\t\tstop = null;\n\t\t\t}\n\t\t};\n\t}\n\treturn { set, update, subscribe };\n}\n\n/**\n * Derived value store by synchronizing one or more readable stores and\n * applying an aggregation function over its input values.\n *\n * https://svelte.dev/docs/svelte-store#derived\n * @template {import('./private.js').Stores} S\n * @template T\n * @overload\n * @param {S} stores - input stores\n * @param {(values: import('./private.js').StoresValues<S>, set: (value: T) => void, update: (fn: import('./public.js').Updater<T>) => void) => import('./public.js').Unsubscriber | void} fn - function callback that aggregates the values\n * @param {T} [initial_value] - initial value\n * @returns {import('./public.js').Readable<T>}\n */\n\n/**\n * Derived value store by synchronizing one or more readable stores and\n * applying an aggregation function over its input values.\n *\n * https://svelte.dev/docs/svelte-store#derived\n * @template {import('./private.js').Stores} S\n * @template T\n * @overload\n * @param {S} stores - input stores\n * @param {(values: import('./private.js').StoresValues<S>) => T} fn - function callback that aggregates the values\n * @param {T} [initial_value] - initial value\n * @returns {import('./public.js').Readable<T>}\n */\n\n/**\n * @template {import('./private.js').Stores} S\n * @template T\n * @param {S} stores\n * @param {Function} fn\n * @param {T} [initial_value]\n * @returns {import('./public.js').Readable<T>}\n */\nexport function derived(stores, fn, initial_value) {\n\tconst single = !Array.isArray(stores);\n\t/** @type {Array<import('./public.js').Readable<any>>} */\n\tconst stores_array = single ? [stores] : stores;\n\tif (!stores_array.every(Boolean)) {\n\t\tthrow new Error('derived() expects stores as input, got a falsy value');\n\t}\n\tconst auto = fn.length < 2;\n\treturn readable(initial_value, (set, update) => {\n\t\tlet started = false;\n\t\tconst values = [];\n\t\tlet pending = 0;\n\t\tlet cleanup = noop;\n\t\tconst sync = () => {\n\t\t\tif (pending) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcleanup();\n\t\t\tconst result = fn(single ? values[0] : values, set, update);\n\t\t\tif (auto) {\n\t\t\t\tset(result);\n\t\t\t} else {\n\t\t\t\tcleanup = is_function(result) ? result : noop;\n\t\t\t}\n\t\t};\n\t\tconst unsubscribers = stores_array.map((store, i) =>\n\t\t\tsubscribe(\n\t\t\t\tstore,\n\t\t\t\t(value) => {\n\t\t\t\t\tvalues[i] = value;\n\t\t\t\t\tpending &= ~(1 << i);\n\t\t\t\t\tif (started) {\n\t\t\t\t\t\tsync();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tpending |= 1 << i;\n\t\t\t\t}\n\t\t\t)\n\t\t);\n\t\tstarted = true;\n\t\tsync();\n\t\treturn function stop() {\n\t\t\trun_all(unsubscribers);\n\t\t\tcleanup();\n\t\t\t// We need to set this to false because callbacks can still happen despite having unsubscribed:\n\t\t\t// Callbacks might already be placed in the queue which doesn't know it should no longer\n\t\t\t// invoke this derived store.\n\t\t\tstarted = false;\n\t\t};\n\t});\n}\n\n/**\n * Takes a store and returns a new one derived from the old one that is readable.\n *\n * https://svelte.dev/docs/svelte-store#readonly\n * @template T\n * @param {import('./public.js').Readable<T>} store - store to make readonly\n * @returns {import('./public.js').Readable<T>}\n */\nexport function readonly(store) {\n\treturn {\n\t\tsubscribe: store.subscribe.bind(store)\n\t};\n}\n\nexport { get_store_value as get };\n","import { writable } from 'svelte/store';\nimport type { Annotation } from '../model';\nimport type { Store } from './Store';\n\nexport type HoverState<T extends Annotation> = ReturnType<typeof createHoverState<T>>;\n\nexport const createHoverState = <T extends Annotation>(store: Store<T>) => {\n\n const { subscribe, set } = writable<string | undefined>();\n\n let currentHover: string | undefined;\n\n subscribe(updated => currentHover = updated);\n\n // Track store delete and update events\n store.observe(( { changes }) => { \n if (currentHover) {\n const isDeleted = (changes.deleted || []).some(a => a.id === currentHover);\n if (isDeleted)\n set(undefined);\n \n const updated = (changes.updated || []).find(({ oldValue }) => oldValue.id === currentHover);\n if (updated)\n set(updated.newValue.id);\n }\n });\n\n return { \n get current() { return currentHover },\n subscribe, \n set \n };\n\n}\n","import { writable } from 'svelte/store';\nimport { dequal } from 'dequal/lite';\nimport type { Annotation, FormatAdapter } from '../model';\nimport type { Store } from './Store';\n\nexport interface Selection {\n\n selected: { id: string, editable?: boolean }[],\n\n event?: PointerEvent | KeyboardEvent;\n\n}\n\nexport type SelectionState<I extends Annotation, E extends unknown> = ReturnType<typeof createSelectionState<I, E>>;\n\nexport enum UserSelectAction {\n\n EDIT = 'EDIT', // Make annotation target(s) editable on pointer select\n\n SELECT = 'SELECT', // Just select, but don't make editable\n\n NONE = 'NONE' // Click won't select - the annotation is completely inert\n\n}\n\nexport type UserSelectActionExpression<T extends unknown> = UserSelectAction | ((a: T) => UserSelectAction);\n\nconst EMPTY: Selection = { selected: [] };\n\nexport const createSelectionState = <I extends Annotation, E extends unknown>(\n store: Store<I>,\n defaultSelectionAction?: UserSelectActionExpression<E>,\n adapter?: FormatAdapter<I, E>\n) => {\n const { subscribe, set } = writable<Selection>(EMPTY);\n\n let currentUserSelectAction = defaultSelectionAction;\n\n let currentSelection: Selection = EMPTY;\n\n subscribe(updated => currentSelection = updated);\n\n const clear = () => {\n if (!dequal(currentSelection, EMPTY)) {\n set(EMPTY);\n }\n };\n\n const isEmpty = () => currentSelection.selected?.length === 0;\n\n const isSelected = (annotationOrId: I | string) => {\n if (isEmpty())\n return false;\n\n const id = typeof annotationOrId === 'string' ? annotationOrId : annotationOrId.id;\n return currentSelection.selected.some(i => i.id === id);\n }\n\n const userSelect = (idOrIds: string | string[], event?: Selection['event']) => {\n let annotations: I[];\n\n if (Array.isArray(idOrIds)) {\n annotations = idOrIds.map(id => store.getAnnotation(id)!).filter(Boolean);\n\n if (annotations.length < idOrIds.length) {\n console.warn('Invalid selection: ' + idOrIds.filter(id => !annotations.some(a => a.id === id)));\n return;\n }\n } else {\n const annotation = store.getAnnotation(idOrIds);\n if (!annotation) {\n console.warn('Invalid selection: ' + idOrIds);\n return;\n }\n\n annotations = [annotation];\n }\n\n const selected = annotations.reduce<{ id: string, editable?: boolean }[]>((sel, a) => {\n const action = onUserSelect(a, currentUserSelectAction, adapter);\n if (action === UserSelectAction.EDIT)\n return [...sel, { id: a.id, editable: true }];\n else if (action === UserSelectAction.SELECT) \n return [...sel, { id: a.id }];\n else\n return sel;\n }, []);\n\n set({ selected, event });\n }\n\n const setSelected = (idOrIds: string | string[], editable?: boolean) => {\n const ids = Array.isArray(idOrIds) ? idOrIds : [idOrIds];\n\n // Remove invalid\n const annotations = ids\n .map(id => store.getAnnotation(id))\n .filter((a): a is I => Boolean(a));\n\n set({\n selected: annotations.map(annotation => {\n\n // If editable isn't set, use the default behavior\n const isEditable = editable === undefined\n ? onUserSelect(annotation, currentUserSelectAction, adapter) === UserSelectAction.EDIT\n : editable;\n\n return { id: annotation.id, editable: isEditable }\n })\n });\n\n if (annotations.length !== ids.length)\n console.warn('Invalid selection', idOrIds);\n }\n\n const removeFromSelection = (ids: string[]) => {\n if (isEmpty())\n return false;\n\n const { selected } = currentSelection;\n\n // Checks which of the given annotations are actually in the selection\n const shouldRemove = selected.some(({ id }) => ids.includes(id));\n if (shouldRemove)\n set({ selected: selected.filter(({ id }) => !ids.includes(id)) });\n }\n\n const setUserSelectAction = (action: UserSelectActionExpression<E> | undefined) => {\n currentUserSelectAction = action;\n setSelected(currentSelection.selected.map(({ id }) => id));\n };\n\n // Track store delete and update events\n store.observe(\n ({ changes }) => removeFromSelection((changes.deleted || []).map(a => a.id))\n );\n\n return {\n get event() {\n return currentSelection ? currentSelection.event : null;\n },\n get selected() {\n return currentSelection ? [...currentSelection.selected] : null;\n },\n get userSelectAction() {\n return currentUserSelectAction;\n },\n clear,\n isEmpty,\n isSelected,\n setSelected,\n setUserSelectAction,\n subscribe,\n userSelect\n };\n\n}\n\nexport const onUserSelect = <I extends Annotation, E extends unknown>(\n annotation: I,\n action?: UserSelectActionExpression<E>,\n adapter?: FormatAdapter<I, E>\n): UserSelectAction => {\n const crosswalked = adapter ? adapter.serialize(annotation) : annotation as unknown as E;\n return (typeof action === 'function') ? action(crosswalked) : (action || UserSelectAction.EDIT)\n}\n","import validate from './validate.js';\nconst byteToHex = [];\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\nexport function unsafeStringify(arr, offset = 0) {\n return (byteToHex[arr[offset + 0]] +\n byteToHex[arr[offset + 1]] +\n byteToHex[arr[offset + 2]] +\n byteToHex[arr[offset + 3]] +\n '-' +\n byteToHex[arr[offset + 4]] +\n byteToHex[arr[offset + 5]] +\n '-' +\n byteToHex[arr[offset + 6]] +\n byteToHex[arr[offset + 7]] +\n '-' +\n byteToHex[arr[offset + 8]] +\n byteToHex[arr[offset + 9]] +\n '-' +\n byteToHex[arr[offset + 10]] +\n byteToHex[arr[offset + 11]] +\n byteToHex[arr[offset + 12]] +\n byteToHex[arr[offset + 13]] +\n byteToHex[arr[offset + 14]] +\n byteToHex[arr[offset + 15]]).toLowerCase();\n}\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset);\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n return uuid;\n}\nexport default stringify;\n","let getRandomValues;\nconst rnds8 = new Uint8Array(16);\nexport default function rng() {\n if (!getRandomValues) {\n if (typeof crypto === 'undefined' || !crypto.getRandomValues) {\n throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n getRandomValues = crypto.getRandomValues.bind(crypto);\n }\n return getRandomValues(rnds8);\n}\n","const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nexport default { randomUUID };\n","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n options = options || {};\n const rnds = options.random || (options.rng || rng)();\n rnds[6] = (rnds[6] & 0x0f) | 0x40;\n rnds[8] = (rnds[8] & 0x3f) | 0x80;\n if (buf) {\n offset = offset || 0;\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n return buf;\n }\n return unsafeStringify(rnds);\n}\nexport default v4;\n","import { v4 as uuidv4 } from 'uuid';\nimport type { Annotation, AnnotationBody } from '../model/Annotation';\nimport type { User } from '../model/User';\n\n/**\n * Returns all users listed as creators or updaters in any parts of this\n * annotation.\n */\nexport const getContributors = (annotation: Annotation): User[] => {\n const { creator, updatedBy } = annotation.target;\n\n const bodyCollaborators = annotation.bodies.reduce((users, body) => (\n [...users, body.creator, body.updatedBy].filter(Boolean) as User[]\n ), [] as User[]);\n\n return [\n creator,\n updatedBy,\n ...bodyCollaborators\n ].filter(u => u) as User[] // Remove undefined\n}\n\ntype HasTime = { created?: string | Date; updated?: string | Date; };\n\n/** \n * Converts any string dates in the given annotation(-like) \n * object to proper Date objects.\n */\nexport const reviveDates = <A extends Annotation = Annotation>(annotation: any): A => {\n const revive = <T extends HasTime>(body: T): T => {\n const revived = {...body};\n\n if (body.created && typeof body.created === 'string')\n revived.created = new Date(body.created);\n\n if (body.updated && typeof body.updated === 'string')\n revived.updated = new Date(body.updated);\n\n return revived;\n }\n\n return {\n ...annotation,\n bodies: (annotation.bodies || []).map(revive),\n target: revive(annotation.target)\n } as A;\n}\n\n/**\n * Shorthand/helper.\n */\nexport const createBody = (\n annotationOrId: string | Annotation, \n payload: { [key: string]: any },\n created?: Date,\n creator?: User\n): AnnotationBody => ({\n id: uuidv4(),\n annotation: typeof annotationOrId === 'string' ? annotationOrId : annotationOrId.id,\n created: created || new Date(),\n creator,\n ...payload\n});","import { dequal } from 'dequal/lite';\nimport type { Update } from '../state/StoreObserver';\nimport type { Annotation } from '../model/Annotation';\n\nconst getAddedBodies = (oldValue: Annotation, newValue: Annotation) => {\n const oldBodyIds = new Set(oldValue.bodies.map(b => b.id));\n return newValue.bodies.filter(b => !oldBodyIds.has(b.id));\n}\n\nconst getRemovedBodies = (oldValue: Annotation, newValue: Annotation) => {\n const newBodyIds = new Set(newValue.bodies.map(b => b.id));\n return oldValue.bodies.filter(b => !newBodyIds.has(b.id));\n}\n\nconst getChangedBodies = (oldValue: Annotation, newValue: Annotation) => \n newValue.bodies\n .map(newBody => {\n const oldBody = oldValue.bodies.find(b => b.id === newBody.id);\n return { newBody, oldBody: oldBody && !dequal(oldBody, newBody) ? oldBody : undefined }\n })\n .filter(({ oldBody }) => oldBody)\n .map(({ oldBody, newBody }) => ({ oldBody: oldBody!, newBody }));\n\nconst hasTargetChanged = (oldValue: Annotation, newValue: Annotation) => \n !dequal(oldValue.target, newValue.target);\n\nexport const diffAnnotations = <T extends Annotation = Annotation>(oldValue: T, newValue: T): Update<T> => {\n const bodiesCreated = getAddedBodies(oldValue, newValue);\n const bodiesDeleted = getRemovedBodies(oldValue, newValue);\n const bodiesUpdated = getChangedBodies(oldValue, newValue);\n\n return {\n oldValue, \n newValue,\n bodiesCreated: bodiesCreated.length > 0 ? bodiesCreated : undefined,\n bodiesDeleted: bodiesDeleted.length > 0 ? bodiesDeleted : undefined,\n bodiesUpdated: bodiesUpdated.length > 0 ? bodiesUpdated : undefined,\n targetUpdated: hasTargetChanged(oldValue, newValue) ? { oldTarget: oldValue.target, newTarget: newValue.target } : undefined\n }\n}","import type { Annotation, AnnotationBody, AnnotationTarget } from '../model/Annotation';\nimport { diffAnnotations } from '../utils';\n\n/** Interface for listening to changes in the annotation store **/\nexport interface StoreObserver<T extends Annotation> { \n\n onChange: { (event: StoreChangeEvent<T>): void };\n\n options: StoreObserveOptions;\n\n}\n\n/** A change event fired when the store state changes **/\nexport interface StoreChangeEvent<T extends Annotation> {\n\n origin: Origin;\n\n changes: ChangeSet<T>;\n\n state: T[];\n\n}\n\nexport interface ChangeSet<T extends Annotation> {\n\n created?: T[];\n\n deleted?: T[];\n\n updated?: Update<T>[];\n\n}\n\nexport interface Update<T extends Annotation> {\n\n oldValue: T;\n\n newValue: T;\n\n bodiesCreated?: T['bodies'];\n\n bodiesDeleted?: T['bodies'];\n\n bodiesUpdated?: Array<{ oldBody: T['bodies'][number], newBody: T['bodies'][number] }>;\n\n targetUpdated?: { oldTarget: T['target'], newTarget: T['target'] };\n\n}\n\n/** Options to control which events the observer wants to get notified about **/\nexport interface StoreObserveOptions {\n\n // Observe changes on targets, bodies or both?\n ignore?: Ignore;\n\n // Observe changes on one more specific annotations\n annotations?: string | string[];\n\n // Observer changes only for a specific origin\n origin?: Origin\n\n}\n\n/** Allows the observer to ignore certain event types **/\nexport enum Ignore { \n\n // Don't notify this observer for changes that involve bodies only\n BODY_ONLY = 'BODY_ONLY',\n\n // Don't notify for changes on targets only\n TARGET_ONLY = 'TARGET_ONLY'\n\n}\n\n/** \n * Allows the observer to listen only for events that originated locally or from a remote source.\n * \n * SILENT should be used for updates that are not supposed to trigger an event. Remember that \n * with great power comes great responsibility: SILENT is really for Annotorious plugins and\n * extensions ONLY.\n */\nexport enum Origin { \n \n LOCAL = 'LOCAL', \n \n REMOTE = 'REMOTE',\n \n SILENT = 'SILENT'\n\n}\n\n/** Tests if this observer should be notified about this event **/\nexport const shouldNotify = <T extends Annotation>(observer: StoreObserver<T>, event: StoreChangeEvent<T>) => {\n const { changes, origin } = event;\n\n const isRelevantOrigin = observer.options.origin \n ? observer.options.origin === origin \n : origin !== Origin.SILENT;\n\n if (!isRelevantOrigin)\n return false;\n\n if (observer.options.ignore) {\n const { ignore } = observer.options;\n\n // Shorthand\n const has = (arg: any[] | undefined) => arg && arg.length > 0;\n\n const hasAnnotationChanges =\n has(changes.created) || has(changes.deleted);\n\n if (!hasAnnotationChanges) {\n const hasBodyChanges =\n changes.updated?.some(u => has(u.bodiesCreated) || has(u.bodiesDeleted) || has(u.bodiesUpdated));\n \n const hasTargetChanges = \n changes.updated?.some(u => u.targetUpdated);\n\n if (ignore === Ignore.BODY_ONLY && hasBodyChanges && !hasTargetChanges)\n return false;\n\n if (ignore === Ignore.TARGET_ONLY && hasTargetChanges && !hasBodyChanges)\n return false;\n }\n }\n\n if (observer.options.annotations) {\n // This observer has a filter set on specific annotations - check affected\n const affectedAnnotations = new Set([\n ...(changes.created || []).map(a => a.id),\n ...(changes.deleted || []).map(a => a.id),\n ...(changes.updated || []).map(({ oldValue }) => oldValue.id)\n ]);\n\n const observed = Array.isArray(observer.options.annotations) ?\n observer.options.annotations : [ observer.options.annotations ];\n\n return Boolean(observed.find(id => affectedAnnotations.has(id)));\n } else {\n return true;\n }\n\n}\n\nexport const mergeChanges = <T extends Annotation>(changes: ChangeSet<T>, toMerge: ChangeSet<T>) => {\n const previouslyCreatedIds = new Set((changes.created || []).map(a => a.id));\n const previouslyUpdatedIds = new Set((changes.updated || []).map(({ newValue })=> newValue.id));\n\n const createdIds = new Set((toMerge.created || []).map(a => a.id));\n const deletedIds = new Set((toMerge.deleted || []).map(a => a.id));\n const updatedIds = new Set((toMerge.updated || []).map(({ oldValue }) => oldValue.id));\n\n // Updates that will be merged into create or previous update events\n const mergeableUpdates = new Set((toMerge.updated || [])\n .filter(({ oldValue }) => previouslyCreatedIds.has(oldValue.id) || previouslyUpdatedIds.has(oldValue.id))\n .map(({ oldValue }) => oldValue.id ));\n\n // * created *\n // - drop created that were then deleted\n // - merge any updates on created\n // - append newly created\n const created = [\n ...(changes.created || [])\n .filter(a => !deletedIds.has(a.id))\n .map(a => updatedIds.has(a.id) \n ? toMerge.updated!.find(({ oldValue }) => oldValue.id === a.id)!.newValue\n : a),\n ...(toMerge.created || [])\n ];\n\n // * deleted *\n // - drop deleted that were later re-created (redo action!)\n // - append newly deleted, but remove any that delete annotations \n // that were created in the same round\n const deleted = [\n ...(changes.deleted || [])\n .filter(a => !createdIds.has(a.id)),\n ...(toMerge.deleted || []) \n .filter(a => !previouslyCreatedIds.has(a.id))\n ] \n\n // * updated *\n // - drop updates on deleted annotations\n // - merge any updates that override previous ones\n // - append new updates, but remove any that were merged\n const updated = [\n ...(changes.updated || [])\n .filter(({ newValue }) => !deletedIds.has(newValue.id))\n .map(update => {\n const { oldValue, newValue } = update;\n if (updatedIds.has(newValue.id)) {\n const updated = toMerge.updated!.find(u => u.oldValue.id === newValue.id)!.newValue;\n return diffAnnotations(oldValue, updated);\n } else {\n return update;\n }\n }),\n ...(toMerge.updated || []).filter(({ oldValue }) => !mergeableUpdates.has(oldValue.id))\n ]\n\n return { created, deleted, updated };\n}\n","import { v4 as uuidv4 } from 'uuid';\nimport type { Annotation } from '../model';\nimport { diffAnnotations } from '../utils';\nimport { Origin, shouldNotify, type Update, type ChangeSet } from './StoreObserver';\nimport type { StoreObserver, StoreChangeEvent, StoreObserveOptions } from './StoreObserver';\n\n// Shorthand\ntype AnnotationBodyIdentifier = { id: string, annotation: string }; \n\nconst sanitize = <T extends Annotation>(a: Partial<T>): T => {\n const id = a.id === undefined ? uuidv4() : a.id;\n\n return {\n ...a,\n id,\n bodies: a.bodies === undefined ? [] : a.bodies.map(b => ({\n ...b,\n annotation: id \n })),\n target: {\n ...a.target,\n annotation: id\n }\n } as T;\n}\n\nexport type Store<T extends Annotation> = ReturnType<typeof createStore<T>>;\n\nconst isAnnotation = <T extends Annotation>(arg: any): arg is T => arg.id !== undefined;\n\nexport const createStore = <T extends Annotation>() => {\n\n const annotationIndex = new Map<string, T>();\n\n const bodyIndex = new Map<string, string>();\n\n const observers: StoreObserver<T>[] = [];\n\n const observe = (onChange: { (event: StoreChangeEvent<T>): void }, options: StoreObserveOptions = {}) => {\n observers.push({ onChange, options });\n }\n\n const unobserve = (onChange: { (event: StoreChangeEvent<T>): void }) => {\n const idx = observers.findIndex(observer => observer.onChange == onChange);\n if (idx > -1)\n observers.splice(idx, 1);\n }\n\n const emit = (origin: Origin, changes: ChangeSet<T>) => {\n const event: StoreChangeEvent<T> = {\n origin,\n changes: {\n created: changes.created || [],\n updated: changes.updated || [],\n deleted: changes.deleted || []\n },\n state: [...annotationIndex.values()]\n };\n\n observers.forEach(observer => {\n if (shouldNotify(observer, event))\n observer.onChange(event);\n });\n }\n\n const addAnnotation = (annotation: Partial<T>, origin = Origin.LOCAL) => {\n const existing = annotation.id && annotationIndex.get(annotation.id);\n\n if (existing) {\n throw Error(`Cannot add annotation ${annotation.id} - exists already`);\n } else {\n const sanitized = sanitize(annotation);\n\n annotationIndex.set(sanitized.id, sanitized);\n sanitized.bodies.forEach(b => bodyIndex.set(b.id, sanitized.id));\n emit(origin, { created: [sanitized] });\n }\n }\n\n const updateOneAnnotation = (arg1: string | Partial<T>, arg2?: Partial<T> | Origin) => {\n const updated: T = typeof arg1 === 'string' ? sanitize(arg2 as Partial<T>) : sanitize(arg1);\n\n const oldId: string | undefined = typeof arg1 === 'string' ? arg1 : arg1.id;\n const oldValue = oldId && annotationIndex.get(oldId);\n\n if (oldValue) {\n const update: Update<T> = diffAnnotations(oldValue, updated);\n\n if (oldId === updated.id) {\n annotationIndex.set(oldId, updated);\n } else {\n annotationIndex.delete(oldId);\n annotationIndex.set(updated.id, updated);\n }\n\n oldValue.bodies.forEach(b => bodyIndex.delete(b.id));\n updated.bodies.forEach(b => bodyIndex.set(b.id, updated.id));\n\n return update;\n } else {\n console.warn(`Cannot update annotation ${oldId} - does not exist`);\n }\n }\n \n const updateAnnotation = (arg1: string | T, arg2: T | Origin = Origin.LOCAL, arg3 = Origin.LOCAL) => {\n const origin: Origin = isAnnotation(arg2) ? arg3 : arg2;\n\n const update = updateOneAnnotation(arg1, arg2);\n if (update)\n emit(origin, { updated: [update] })\n }\n\n const bulkUpdateAnnotation = (annotations: T[], origin = Origin.LOCAL) => {\n const updated = annotations.reduce((updated, annotation) => {\n const u = updateOneAnnotation(annotation);\n return u ? [...updated, u] : updated;\n }, [] as Update<T>[]);\n\n if (updated.length > 0)\n emit(origin, { updated });\n }\n\n const addBody = (body: T['bodies'][number], origin = Origin.LOCAL) => {\n const oldValue = annotationIndex.get(body.annotation);\n if (oldValue) {\n const newValue = { \n ...oldValue,\n bodies: [ ...oldValue.bodies, body ]\n };\n\n annotationIndex.set(oldValue.id, newValue);\n\n bodyIndex.set(body.id, newValue.id);\n\n const update: Update<T> = {\n oldValue, newValue, bodiesCreated: [ body ]\n };\n\n emit(origin, { updated: [update] });\n } else {\n console.warn(`Attempt to add body to missing annotation: ${body.annotation}`);\n }\n }\n\n const all = () => [...annotationIndex.values()];\n\n const clear = (origin = Origin.LOCAL) => { \n const all = [...annotationIndex.values()];\n\n annotationIndex.clear();\n bodyIndex.clear();\n\n emit(origin, { deleted: all });\n }\n\n const bulkAddAnnotation = (annotations: Partial<T>[], replace = true, origin = Origin.LOCAL) => {\n const sanitized = annotations.map(sanitize);\n\n if (replace) {\n // Delete existing first\n const deleted = [...annotationIndex.values()];\n annotationIndex.clear();\n bodyIndex.clear();\n\n sanitized.forEach(annotation => {\n annotationIndex.set(annotation.id, annotation);\n annotation.bodies.forEach(b => bodyIndex.set(b.id, annotation.id));\n });\n\n emit(origin, { created: sanitized, deleted });\n } else {\n // Don't allow overwriting of existing annotations\n const existing = annotations.reduce((all, next) => {\n const existing = next.id && annotationIndex.get(next.id);\n return existing ? [...all, existing ] : all;\n }, [] as T[]);\n\n if (existing.length > 0)\n throw Error(`Bulk insert would overwrite the following annotations: ${existing.map(a => a.id).join(', ')}`);\n\n sanitized.forEach(annotation => {\n annotationIndex.set(annotation.id, annotation);\n annotation.bodies.forEach(b => bodyIndex.set(b.id, annotation.id));\n });\n\n emit(origin, { created: sanitized });\n }\n }\n\n const deleteOneAnnotation = (annotationOrId: T | string) => {\n const id = typeof annotationOrId === 'string' ? annotationOrId : annotationOrId.id;\n\n const existing = annotationIndex.get(id);\n if (existing) {\n annotationIndex.delete(id);\n existing.bodies.forEach(b => bodyIndex.delete(b.id));\n return existing;\n } else {\n console.warn(`Attempt to delete missing annotation: ${id}`);\n }\n }\n\n const deleteAnnotation = (annotationOrId: T | string, origin = Origin.LOCAL) => {\n const deleted = deleteOneAnnotation(annotationOrId);\n if (deleted)\n emit(origin, { deleted: [ deleted ]});\n }\n\n const bulkDeleteAnnotation = (annotationsOrIds: (T | string)[], origin = Origin.LOCAL) => {\n const deleted = annotationsOrIds.reduce((deleted, arg) => {\n const existing = deleteOneAnnotation(arg);\n return existing ? [...deleted, existing] : deleted;\n }, [] as T[]);\n\n if (deleted.length > 0)\n emit(origin, { deleted });\n }\n\n const deleteOneBody = (body: AnnotationBodyIdentifier) => {\n const oldAnnotation = annotationIndex.get(body.annotation);\n\n if (oldAnnotation) {\n const oldBody = oldAnnotation.bodies.find(b => b.id === body.id);\n\n if (oldBody) {\n bodyIndex.delete(oldBody.id);\n\n const newAnnotation = {\n ...oldAnnotation,\n bodies: oldAnnotation.bodies.filter(b => b.id !== body.id)\n };\n\n annotationIndex.set(oldAnnotation.id, newAnnotation);\n\n const update: Update<T> = {\n oldValue: oldAnnotation, newValue: newAnnotation, bodiesDeleted: [oldBody]\n };\n\n return update;\n } else {\n console.warn(`Attempt to delete missing body ${body.id} from annotation ${body.annotation}`);\n }\n } else {\n console.warn(`Attempt to delete body from missing annotation ${body.annotation}`);\n }\n }\n \n const deleteBody = (body: AnnotationBodyIdentifier, origin = Origin.LOCAL) => {\n const updated = deleteOneBody(body);\n if (updated)\n emit(origin, { updated: [ updated ]});\n }\n\n const bulkDeleteBodies = (bodies: AnnotationBodyIdentifier[], origin = Origin.LOCAL) => {\n const updated = bodies\n .map(b => deleteOneBody(b)!)\n .filter(Boolean);\n\n if (updated.length > 0)\n emit(origin, { updated });\n }\n\n const getAnnotation = (id: string): T | undefined => {\n const a = annotationIndex.get(id);\n return a ? {...a} : undefined;\n }\n\n const getBody = (id: string): T['bodies'][number] | undefined => {\n const annotationId = bodyIndex.get(id);\n if (annotationId) {\n const annotation = getAnnotation(annotationId);\n const body = annotation!.bodies.find(b => b.id === id);\n if (body) {\n return body;\n } else {\n console.error(`Store integrity error: body ${id} in index, but not in annotation`);\n }\n } else {\n console.warn(`Attempt to retrieve missing body: ${id}`);\n }\n }\n\n const updateOneBody = (oldBodyId: AnnotationBodyIdentifier, newBody: T['bodies'][number]) => {\n if (oldBodyId.annotation !== newBody.annotation)\n throw 'Annotation integrity violation: annotation ID must be the same when updating bodies';\n\n const oldAnnotation = annotationIndex.get(oldBodyId.annotation);\n if (oldAnnotation) {\n const oldBody = oldAnnotation.bodies.find(b => b.id === oldBodyId.id)!;\n\n const newAnnotation = { \n ...oldAnnotation,\n bodies: oldAnnotation.bodies.map(b => b.id === oldBody.id ? newBody : b)\n };\n\n annotationIndex.set(oldAnnotation.id, newAnnotation);\n\n if (oldBody.id !== newBody.id) {\n bodyIndex.delete(oldBody.id);\n bodyIndex.set(newBody.id, newAnnotation.id);\n }\n\n return {\n oldValue: oldAnnotation, \n newValue: newAnnotation,\n bodiesUpdated: [{ oldBody, newBody }]\n }\n } else {\n console.warn(`Attempt to add body to missing annotation ${oldBodyId.annotation}`);\n }\n }\n\n const updateBody = (oldBodyId: AnnotationBodyIdentifier, newBody: T['bodies'][number], origin = Origin.LOCAL) => {\n const update = updateOneBody(oldBodyId, newBody);\n if (update)\n emit(origin, { updated: [ update ]} );\n }\n\n const bulkUpdateBodies = (bodies: Array<T['bodies'][number]>, origin = Origin.LOCAL) => {\n const updated = bodies\n .map(b => updateOneBody({ id: b.id, annotation: b.annotation }, b)!)\n .filter(Boolean);\n\n emit(origin, { updated });\n }\n\n const updateOneTarget = (target: T['target']): Update<T> | undefined => {\n const oldValue = annotationIndex.get(target.annotation);\n \n if (oldValue) {\n const newValue = { \n ...oldValue, \n target: {\n ...oldValue.target,\n ...target \n }\n };\n\n annotationIndex.set(oldValue.id, newValue);\n\n return {\n oldValue, newValue, targetUpdated: { \n oldTarget: oldValue.target,\n newTarget: target\n }\n };\n } else {\n console.warn(`Attempt to update target on missing annotation: ${target.annotation}`);\n }\n }\n\n const updateTarget = (target: T['target'], origin = Origin.LOCAL) => {\n const update = updateOneTarget(target);\n if (update)\n emit(origin, { updated: [ update ]} );\n }\n\n const bulkUpdateTargets = (targets: Array<T['target']>, origin = Origin.LOCAL) => {\n const updated = \n targets.map(t => updateOneTarget(t)!).filter(Boolean);\n if (updated.length > 0)\n emit(origin, { updated });\n }\n\n\treturn {\n addAnnotation,\n addBody,\n all,\n bulkAddAnnotation,\n bulkDeleteAnnotation,\n bulkDeleteBodies,\n bulkUpdateAnnotation,\n bulkUpdateBodies,\n bulkUpdateTargets,\n clear,\n deleteAnnotation,\n deleteBody,\n getAnnotation,\n getBody,\n observe,\n unobserve,\n updateAnnotation,\n updateBody,\n updateTarget\n\t};\n\n}\n","import type { Annotation, Annotator, AnnotatorState } from '../model';\nimport type { Store } from './Store';\nimport type { StoreChangeEvent } from './StoreObserver';\n\ntype Subscriber<T extends Annotation> = (annotation: T[]) => void; \n\nexport interface SvelteStore<T extends Annotation> extends Store<T> {\n\n subscribe(onChange: Subscriber<T>): void;\n\n}\n\nexport interface SvelteAnnotatorState<I extends Annotation, E extends unknown> extends AnnotatorState<I, E> {\n\n store: SvelteStore<I>\n\n}\n\nexport interface SvelteAnnotator<I extends Annotation, E extends unknown> extends Annotator<I, E> {\n\n state: SvelteAnnotatorState<I, E>\n\n}\n\n/** \n * A simple wrapper around the event-based store implementation\n * that adds a Svelte shim, for use with the reactive '$' notation.\n * Other frameworks might not actually need this. But it's pretty\n * convenient for everyone using Svelte, as well as for the\n * basic (Svelte-based) Annotorious standard implementation.\n */\nexport const toSvelteStore = <T extends Annotation = Annotation>(store: Store<T>): SvelteStore<T> => {\n\n const subscribe = (onChange: Subscriber<T>) => {\n\n // Register a store observer on behalf of the subscriber\n const shim = (event: StoreChangeEvent<T>) => onChange(event.state);\n store.observe(shim);\n\n // Immediately call the subscriber function with the\n // current store value, according to the Svelte contract.\n // https://stackoverflow.com/questions/68220955/how-does-svelte-unsubscribe-actually-work\n onChange(store.all());\n\n // Return the unsubscribe function\n return () => store.unobserve(shim);\n }\n\n return {\n ...store,\n subscribe\n }\n\n}","export let createNanoEvents = () => ({\n emit(event, ...args) {\n for (\n let callbacks = this.events[event] || [],\n i = 0,\n length = callbacks.length;\n i < length;\n i++\n ) {\n callbacks[i](...args)\n }\n },\n events: {},\n on(event, cb) {\n ;(this.events[event] ||= []).push(cb)\n return () => {\n this.events[event] = this.events[event]?.filter(i => cb !== i)\n }\n }\n})\n","import { createNanoEvents, type Unsubscribe } from 'nanoevents';\nimport type { Annotation } from '../model';\nimport type { Store } from './Store';\nimport { Origin } from './StoreObserver';\nimport { mergeChanges, type ChangeSet, type StoreChangeEvent, type Update } from './StoreObserver';\n\n// Duration with fast successive changes get merged \n// with the last event in the stack, rather than getting stacked\n// as a new undo/redo step.\nconst DEBOUNCE = 250;\n\nexport interface UndoStack <T extends Annotation> {\n\n canRedo(): boolean;\n\n canUndo(): boolean;\n\n destroy(): void;\n\n getHistory(): History<T>;\n\n on<E extends keyof UndoStackEvents<T>>(event: E, callback: UndoStackEvents<T>[E]): Unsubscribe;\n\n undo(): void;\n\n redo(): void;\n\n}\n\nexport interface UndoStackEvents <T extends Annotation> {\n\n redo(change: ChangeSet<T>): void;\n\n undo(change: ChangeSet<T>): void;\n\n}\n\nexport interface History <T extends Annotation> {\n\n changes: ChangeSet<T>[];\n \n pointer: number;\n\n}\n\nexport const createUndoStack = <T extends Annotation>(store: Store<T>, history?: History<T>): UndoStack<T> => {\n\n const emitter = createNanoEvents<UndoStackEvents<T>>();\n\n const changeStack: ChangeSet<T>[] = history?.changes || [];\n\n let pointer = history ? history.pointer : - 1;\n\n let muteEvents = false;\n\n let lastEvent = 0;\n\n const onChange = (event: StoreChangeEvent<T>) => {\n if (!muteEvents) {\n const { changes } = event;\n\n const now = performance.now();\n\n if (now - lastEvent > DEBOUNCE) {\n // Put this change on the stack...\n changeStack.splice(pointer + 1);\n changeStack.push(changes);\n\n // ...and update the pointer\n pointer = changeStack.length - 1;\n } else {\n // Merge this change with the last in the stack\n const last = changeStack.length - 1;\n changeStack[last] = mergeChanges(changeStack[last], changes);\n }\n\n lastEvent = now;\n }\n\n muteEvents = false;\n }\n\n store.observe(onChange, { origin: Origin.LOCAL });\n\n const undoCreated = (created?: T[]) =>\n created && created.length > 0 && store.bulkDeleteAnnotation(created);\n\n const redoCreated = (created?: T[]) =>\n created && created.length > 0 && store.bulkAddAnnotation(created, false);\n\n const undoUpdated = (updated?: Update<T>[]) =>\n updated && updated.length > 0 && store.bulkUpdateAnnotation(updated.map(({ oldValue }) => oldValue));\n \n const redoUpdated = (updated?: Update<T>[]) =>\n updated && updated.length > 0 && store.bulkUpdateAnnotation(updated.map(({ newValue }) => newValue));\n\n const undoDeleted = (deleted?: T[]) => \n deleted && deleted.length > 0 && store.bulkAddAnnotation(deleted, false);\n\n const redoDeleted = (deleted?: T[]) =>\n deleted && deleted.length > 0 && store.bulkDeleteAnnotation(deleted);\n\n const undo = () => {\n if (pointer > -1) {\n muteEvents = true;\n\n const { created, updated, deleted } = changeStack[pointer];\n\n undoCreated(created);\n undoUpdated(updated);\n undoDeleted(deleted);\n\n emitter.emit('undo', changeStack[pointer]);\n\n pointer -= 1;\n }\n }\n\n const canUndo = () => pointer > -1;\n\n const redo = () => {\n if (changeStack.length - 1 > pointer) {\n muteEvents = true;\n\n const { created, updated, deleted } = changeStack[pointer + 1];\n\n redoCreated(created);\n redoUpdated(updated);\n redoDeleted(deleted);\n\n emitter.emit('redo', changeStack[pointer + 1]);\n\n pointer += 1;\n }\n }\n\n const canRedo = () => changeStack.length - 1 > pointer;\n\n const destroy = () => store.unobserve(onChange);\n\n const getHistory = () => ({ changes: [...changeStack], pointer });\n\n const on = <E extends keyof UndoStackEvents<T>>(event: E, callback: UndoStackEvents<T>[E]) => \n emitter.on(event, callback);\n\n return {\n canRedo,\n canUndo,\n destroy,\n getHistory,\n on,\n redo,\n undo\n }\n\n}","import { writable } from 'svelte/store';\n\nexport type ViewportState = ReturnType<typeof createViewportState>;\n\nexport const createViewportState = () => {\n\n const { subscribe, set } = writable<string[]>([]);\n\n return { \n subscribe, \n set\n };\n\n}\n","import { dequal } from 'dequal/lite';\nimport type { Annotation, AnnotatorState, FormatAdapter } from '../model';\nimport { Origin } from '../state';\nimport type { ChangeSet, SelectionState, UndoStack } from '../state';\nimport type { LifecycleEvents } from './LifecycleEvents';\n\nexport type Lifecycle<I extends Annotation, E extends unknown> = \n ReturnType<typeof createLifecycleObserver<I, E>>;\n\nexport const createLifecycleObserver = <I extends Annotation, E extends unknown>(\n state: AnnotatorState<I, E>,\n undoStack: UndoStack<I>,\n adapter?: FormatAdapter<I, E>,\n autoSave?: boolean\n) => {\n const { hover, selection, store, viewport } = state;\n\n const observers: Map<keyof LifecycleEvents, Function[]> = new Map();\n\n // The currently selected annotations, in the state when they were selected \n let initialSelection: I[] = [];\n\n let currentHover: string | undefined;\n\n let idleTimeout: ReturnType<typeof setTimeout>;\n\n const on = <T extends keyof LifecycleEvents>(event: T, callback: LifecycleEvents<E>[T]) => {\n if (observers.has(event)) {\n observers.get(event)!.push(callback);\n } else {\n observers.set(event, [callback]);\n }\n }\n\n const off = <T extends keyof LifecycleEvents<E>>(event: T, callback: LifecycleEvents<E>[T]) => {\n const callbacks = observers.get(event);\n if (callbacks) {\n const idx = callbacks.indexOf(callback);\n if (idx !== -1)\n callbacks.splice(idx, 1);\n }\n }\n\n const emit = (event: keyof LifecycleEvents<E>, arg0: I | I[], arg1?: I | PointerEvent) => {\n if (observers.has(event)) {\n setTimeout(() => {\n observers.get(event)!.forEach(callback => { \n if (adapter) {\n const serialized0 = Array.isArray(arg0) ? \n arg0.map(a => adapter.serialize(a)) : adapter.serialize(arg0);\n \n const serialized1: E | PointerEvent | undefined =\n arg1 ? arg1 instanceof PointerEvent ? arg1 : adapter.serialize(arg1) : undefined;\n\n callback(serialized0 as E & E[], serialized1); \n } else {\n callback(arg0 as E & E[], arg1 as unknown as E); \n }\n });\n }, 1);\n }\n }\n\n const onIdleUpdate = () => {\n const { selected } = selection;\n\n // User idle after activity - fire update events for selected\n // annotations that changed\n const updatedSelected = (selected || []).map(({ id }) => store.getAnnotation(id)!);\n\n updatedSelected.forEach(updated => {\n const initial = initialSelection.find(a => a.id === updated.id);\n if (!initial || !dequal(initial, updated)) {\n emit('updateAnnotation', updated, initial);\n }\n });\n\n initialSelection = initialSelection.map(initial => {\n const updated = updatedSelected.find(({ id }) => id === initial.id);\n return updated ? updated : initial\n });\n }\n\n selection.subscribe(({ selected })=> {\n if (initialSelection.length === 0 && selected.length === 0)\n return;\n\n if (initialSelection.length === 0 && selected.length > 0) {\n // A new selection was made - store the editable annotation as initial state\n initialSelection = selected.map(({ id }) => store.getAnnotation(id)!);\n } else if (initialSelection.length > 0 && selected.length === 0) {\n // Deselect!\n initialSelection.forEach(initial => {\n const updatedState = store.getAnnotation(initial.id); \n \n if (updatedState && !dequal(updatedState, initial)) {\n emit('updateAnnotation', updatedState, initial);\n }\n });\n\n initialSelection = [];\n } else {\n // Changed selection\n const initialIds = new Set(initialSelection.map(a => a.id));\n const selectedIds = new Set(selected.map(({ id }) => id));\n\n // Fire update events for deselected annotations that have changed\n const deselected = initialSelection.filter(a => !selectedIds.has(a.id));\n deselected.forEach(initial => {\n const updatedState = store.getAnnotation(initial.id);\n\n if (updatedState && !dequal(updatedState, initial))\n emit('updateAnnotation', updatedState, initial);\n });\n\n initialSelection = [\n // Remove annotations that were deselected\n ...initialSelection.filter(a => selectedIds.has(a.id)),\n // Add editable annotations that were selected\n ...selected\n .filter(({ id }) => !initialIds.has(id))\n .map(({ id }) => store.getAnnotation(id)!)\n ];\n }\n\n emit('selectionChanged', initialSelection);\n });\n\n hover.subscribe(id => {\n if (!currentHover && id) {\n emit('mouseEnterAnnotation', store.getAnnotation(id)!);\n } else if (currentHover && !id) {\n emit('mouseLeaveAnnotation', store.getAnnotation(currentHover)!);\n } else if (currentHover && id) {\n emit('mouseLeaveAnnotation', store.getAnnotation(currentHover)!);\n emit('mouseEnterAnnotation', store.getAnnotation(id)!);\n }\n\n currentHover = id;\n });\n\n viewport?.subscribe(ids => \n emit('viewportIntersect', ids.map(id => store.getAnnotation(id)!)));\n\n store.observe(event => {\n // autoSave option triggers update events on idleness\n if (autoSave) {\n if (idleTimeout)\n clearTimeout(idleTimeout);\n\n idleTimeout = setTimeout(onIdleUpdate, 1000);\n }\n\n // Local CREATE and DELETE events are applied immediately\n const { created, deleted } = event.changes;\n (created || []).forEach(a => emit('createAnnotation', a));\n (deleted || []).forEach(a => emit('deleteAnnotation', a));\n\n // Updates are only applied immediately if they involve body changes\n const updatesWithBody = (event.changes.updated || []).filter(u => [\n ...(u.bodiesCreated || []),\n ...(u.bodiesDeleted || []),\n ...(u.bodiesUpdated || [])\n ].length > 0);\n\n // Emit an update with the new annototation and the stored initial state\n updatesWithBody.forEach(({ oldValue, newValue }) => {\n const initial = initialSelection.find(a => a.id === oldValue.id) || oldValue;\n\n // Record the update as the new last known state\n initialSelection = initialSelection\n .map(a => a.id === oldValue.id ? newValue : a);\n\n emit('updateAnnotation', newValue, initial);\n });\n }, { origin: Origin.LOCAL });\n\n // Track remote changes - these should update the initial state\n store.observe(event => {\n if (initialSelection) {\n const selectedIds = new Set(initialSelection.map(a => a.id));\n\n const relevantUpdates = (event.changes.updated || [])\n .filter(({ newValue }) => selectedIds.has(newValue.id))\n .map(({ newValue }) => newValue);\n\n if (relevantUpdates.length > 0) {\n initialSelection = initialSelection.map(selected => {\n const updated = relevantUpdates.find(updated => updated.id === selected.id);\n return updated ? updated : selected;\n })\n }\n }\n }, { origin: Origin.REMOTE });\n\n const onUndoOrRedo = (undo: boolean) => (changes: ChangeSet<I>) => {\n // Undo/redo of created/delete will cause lifecycle events automatically,\n // but we need to handle updates specifically!\n const { updated } = changes;\n\n if (undo)\n (updated || []).forEach(t => emit('updateAnnotation', t.oldValue, t.newValue));\n else\n (updated || []).forEach(t => emit('updateAnnotation', t.newValue, t.oldValue));\n }\n\n undoStack.on('undo', onUndoOrRedo(true));\n undoStack.on('redo', onUndoOrRedo(false));\n\n return { on, off, emit }\n\n}\n","import type { Annotation } from './Annotation';\n\nexport interface FormatAdapter<A extends Annotation, T extends unknown> {\n\n parse(serialized: T): ParseResult<A>;\n\n parseAll?(serialized: unknown[]): { parsed: A[], failed: T[] };\n\n serialize(core: A): T;\n\n}\n\nexport interface ParseResult<A extends Annotation> {\n\n parsed?: A;\n \n error?: Error;\n\n}\n\nexport const serializeAll = \n <A extends Annotation, T extends unknown>(adapter: FormatAdapter<A, T>) =>\n (annotations: A[]) => annotations.map(a => adapter.serialize(a));\n\nexport const parseAll = \n <A extends Annotation, T extends unknown>(adapter: FormatAdapter<A, T>) =>\n (serialized: T[]) => serialized.reduce((result, next) => {\n const { parsed, error } = adapter.parse(next);\n \n return error ? {\n parsed: result.parsed,\n failed: [...result.failed, next ]\n } : parsed ? {\n parsed: [...result.parsed, parsed ],\n failed: result.failed\n } : {\n ...result\n }\n }, { parsed: [] as A[], failed: [] as T[]});\n ","import type { Annotation } from './Annotation';\nimport type { User } from './User';\nimport type { PresenceProvider } from '../presence';\nimport type {\n History,\n HoverState,\n SelectionState,\n Store,\n UndoStack,\n UserSelectActionExpression,\n ViewportState\n} from '../state';\nimport { Origin } from '../state';\nimport type { LifecycleEvents } from '../lifecycle';\nimport { reviveDates } from '../utils';\nimport { type FormatAdapter, parseAll } from './FormatAdapter';\nimport type { DrawingStyleExpression } from './DrawingStyle';\nimport type { Filter } from './Filter';\n\n/**\n * Base annotator interface\n * @template I - internal core data model\n * @template E - external adapted representation\n */\nexport interface Annotator<I extends Annotation = Annotation, E extends unknown = Annotation> {\n\n addAnnotation(annotation: Partial<E>): void;\n\n cancelSelected(): void;\n\n canRedo(): boolean;\n\n canUndo(): boolean;\n\n clearAnnotations(): void;\n\n destroy(): void;\n\n getAnnotationById(id: string): E | undefined;\n\n getAnnotations(): E[];\n\n getHistory(): History<I>;\n\n getSelected(): E[];\n\n getUser(): User;\n\n loadAnnotations(url: string, replace?: boolean): Promise<E[]>;\n\n redo(): void;\n\n removeAnnotation(arg: Partial<E> | string): E | undefined;\n\n setAnnotations(annotations: Partial<E>[], replace?: boolean): void;\n\n setFilter(filter: Filter<I> | undefined): void;\n\n setPresenceProvider?(provider: PresenceProvider): void;\n\n setSelected(arg?: string | string[], editable?: boolean): void;\n\n setStyle(style: DrawingStyleExpression<I> | undefined): void;\n\n setUser(user: User): void;\n\n setUserSelectAction(action: UserSelectActionExpression<E>): void;\n\n setVisible(visible: boolean): void;\n\n undo(): void;\n\n updateAnnotation(annotation: Partial<E>): E;\n \n on<T extends keyof LifecycleEvents<E>>(event: T, callback: LifecycleEvents<E>[T]): void;\n\n off<T extends keyof LifecycleEvents<E>>(event: T, callback: LifecycleEvents<E>[T]): void;\n\n state: AnnotatorState<I, E>;\n\n}\n\nexport interface AnnotatorState<I extends Annotation, E extends unknown> {\n\n store: Store<I>;\n\n selection: SelectionState<I, E>;\n\n hover: HoverState<I>;\n\n viewport: ViewportState;\n\n}\n\nexport const createBaseAnnotator = <I extends Annotation, E extends unknown>(\n state: AnnotatorState<I, E>, \n undoStack: UndoStack<I>,\n adapter?: FormatAdapter<I, E>\n) => {\n\n const { store, selection } = state;\n\n const addAnnotation = (annotation: E) => {\n if (adapter) {\n const { parsed, error } = adapter.parse(annotation);\n if (parsed) {\n store.addAnnotation(parsed, Origin.REMOTE);\n } else {\n console.error(error);\n }\n } else {\n store.addAnnotation(reviveDates<I>(annotation), Origin.REMOTE);\n }\n }\n\n const cancelSelected = () => selection.clear();\n\n const clearAnnotations = () => store.clear();\n\n const getAnnotationById = (id: string): E | undefined => {\n const annotation = store.getAnnotation(id);\n return (adapter && annotation) ?\n adapter.serialize(annotation) as E : annotation as unknown as E;\n }\n\n const getAnnotations = () =>\n (adapter ? store.all().map(adapter.serialize) : store.all()) as E[];\n\n const getSelected = () => {\n const selectedIds = selection.selected?.map(s => s.id) || [];\n\n const selected = selectedIds.map(id => store.getAnnotation(id)!).filter(Boolean);\n\n return adapter \n ? selected.map(adapter.serialize) \n : selected as unknown as E[];\n }\n\n const loadAnnotations = (url: string, replace = true) =>\n fetch(url)\n .then((response) => response.json())\n .then((annotations) => {\n setAnnotations(annotations, replace);\n return annotations;\n });\n\n const removeAnnotation = (arg: E | string): E | undefined => {\n if (typeof arg === 'string') {\n const annotation = store.getAnnotation(arg);\n store.deleteAnnotation(arg);\n\n if (annotation)\n return adapter ? adapter.serialize(annotation) : annotation as unknown as E;\n } else {\n const annotation = adapter ? adapter.parse(arg).parsed : (arg as unknown as I);\n\n if (annotation) {\n store.deleteAnnotation(annotation);\n return arg;\n }\n }\n }\n\n const setAnnotations = (annotations: E[], replace = true) => {\n if (adapter) {\n const parseFn = adapter.parseAll || parseAll(adapter);\n const { parsed, failed } = parseFn(annotations);\n\n if (failed.length > 0)\n console.warn(`Discarded ${failed.length} invalid annotations`, failed);\n\n store.bulkAddAnnotation(parsed, replace, Origin.REMOTE);\n } else {\n store.bulkAddAnnotation(annotations.map(reviveDates<I>), replace, Origin.REMOTE);\n }\n }\n\n const setSelected = (arg?: string | string[], editable?: boolean) => {\n if (arg) {\n selection.setSelected(arg, editable);\n } else {\n selection.clear();\n }\n }\n\n const setUserSelectAction = (action: UserSelectActionExpression<E>) => {\n selection.clear();\n selection.setUserSelectAction(action);\n }\n\n const updateAnnotation = (updated: E): E => {\n if (adapter) {\n const crosswalked = adapter.parse(updated).parsed!;\n const previous = adapter.serialize(store.getAnnotation(crosswalked.id)!);\n store.updateAnnotation(crosswalked);\n return previous;\n } else {\n const previous = store.getAnnotation((updated as unknown as I).id);\n store.updateAnnotation(reviveDates<I>(updated));\n return previous as unknown as E;\n }\n }\n\n // Note that we don't spread the undoStack - it has a .destroy()\n // method that would likely get overwritten by other Annotator implementations\n // if people are not careful.\n return { \n addAnnotation,\n cancelSelected,\n canRedo: undoStack.canRedo,\n canUndo: undoStack.canUndo,\n clearAnnotations,\n getAnnotationById,\n getAnnotations,\n getHistory: undoStack.getHistory,\n getSelected,\n loadAnnotations,\n redo: undoStack.redo,\n removeAnnotation,\n setAnnotations,\n setSelected,\n setUserSelectAction,\n undo: undoStack.undo,\n updateAnnotation\n }\n\n}\n","import type { Annotation } from \"./Annotation\";\nimport type { AnnotationState } from \"./AnnotationState\";\n\ntype RGB = `rgb(${number}, ${number}, ${number})`;\n\ntype RGBA = `rgba(${number}, ${number}, ${number}, ${number})`;\n\ntype HEX = `#${string}`;\n\nexport type Color = RGB | RGBA | HEX;\n\nexport interface DrawingStyle {\n\n fill?: Color;\n\n fillOpacity?: number;\n\n stroke?: Color;\n\n strokeOpacity?: number;\n\n strokeWidth?: number;\n\n}\n\nexport type DrawingStyleExpression<T extends Annotation = Annotation> =\n DrawingStyle | ((annotation: T, state?: AnnotationState) => DrawingStyle | undefined);\n\n/** Utility functions **/\n\nexport const computeStyle = <T extends Annotation = Annotation>(\n annotation: T,\n style: DrawingStyleExpression<T>,\n state?: AnnotationState\n) => {\n return typeof style === 'function' ? style(annotation, state) : style;\n};\n\nexport const chainStyles = <T extends Annotation = Annotation>(\n applyFirst: DrawingStyleExpression<T>,\n applySecond: DrawingStyleExpression<T>\n) => {\n if (typeof applyFirst !== 'function' && typeof applySecond !== 'function') {\n // Simple case: just two objects\n return {\n ...(applyFirst || {}),\n ...(applySecond || {})\n };\n } else {\n // Return a function\n return (a: T, state: AnnotationState) => {\n const first = typeof applyFirst === 'function' ? applyFirst(a, state) : applyFirst;\n const second = typeof applySecond === 'function' ? applySecond(a, state) : applySecond;\n\n return {\n ...(first || {}),\n ...(second || {})\n }\n }\n }\n}\n \n","export const urlAlphabet =\n 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'\n","import { urlAlphabet as scopedUrlAlphabet } from './url-alphabet/index.js'\nexport { urlAlphabet } from './url-alphabet/index.js'\nexport let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\nexport let customRandom = (alphabet, defaultSize, getRandom) => {\n let mask = (2 << Math.log2(alphabet.length - 1)) - 1\n let step = -~((1.6 * mask * defaultSize) / alphabet.length)\n return (size = defaultSize) => {\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let j = step | 0\n while (j--) {\n id += alphabet[bytes[j] & mask] || ''\n if (id.length >= size) return id\n }\n }\n }\n}\nexport let customAlphabet = (alphabet, size = 21) =>\n customRandom(alphabet, size | 0, random)\nexport let nanoid = (size = 21) => {\n let id = ''\n let bytes = crypto.getRandomValues(new Uint8Array((size |= 0)))\n while (size--) {\n id += scopedUrlAlphabet[bytes[size] & 63]\n }\n return id\n}\n","import { customAlphabet } from 'nanoid';\n\nexport interface User {\n\n id: string;\n\n isGuest?: boolean;\n\n name?: string;\n\n avatar?: string;\n\n}\n\nexport const createAnonymousGuest = () => {\n const nanoid = customAlphabet('1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_', 20);\n \n return { isGuest: true, id: nanoid() }\n}","import type { AnnotationBody } from './Annotation';\n\nexport interface W3CAnnotation {\n\n '@context': 'http://www.w3.org/ns/anno.jsonld';\n\n type: 'Annotation';\n\n id: string;\n\n creator?: W3CUser;\n\n created?: string;\n\n modified?: string;\n\n body: W3CAnnotationBody | W3CAnnotationBody[];\n\n target: W3CAnnotationTarget | W3CAnnotationTarget[];\n\n [key: string]: any;\n\n}\n\nexport interface W3CUser {\n\n type?: string;\n\n id: string;\n\n name?: string;\n\n}\n\nexport interface W3CAnnotationBody {\n\n type?: string;\n\n id?: string;\n\n purpose?: string;\n\n value?: string;\n\n source?: string;\n\n creator?: W3CUser;\n\n created?: string;\n\n modified?: string;\n\n}\n\nexport interface W3CAnnotationTarget {\n\n id?: string;\n\n source: string;\n\n selector?: AbstractW3CSelector;\n\n}\n\nexport interface AbstractW3CSelector { }\n\n// https://stackoverflow.com/questions/6122571/simple-non-secure-hash-function-for-javascript\nconst hashCode = (obj: Object): string => {\n const str = JSON.stringify(obj);\n\n let hash = 0;\n\n for (let i = 0, len = str.length; i < len; i++) {\n let chr = str.charCodeAt(i);\n hash = (hash << 5) - hash + chr;\n hash |= 0; // Convert to 32bit integer\n }\n\n return `${hash}`;\n}\n\nexport const parseW3CUser = (user?: any) => user\n ? typeof user === 'object' ? { ...user } : user : undefined;\n\n/**\n * Helper to crosswalk the W3C annotation body to a list of core AnnotationBody objects.\n */\nexport const parseW3CBodies = (\n body: W3CAnnotationBody | W3CAnnotationBody[],\n annotationId: string\n) : AnnotationBody[] => (Array.isArray(body) ? body : [body]).map(body => {\n\n // Extract properties that conform to the internal model, but keep custom props\n const { id, type, purpose, value, created, modified, creator, ...rest } = body;\n\n // The internal model strictly requires IDs. (Because multi-user scenarios\n // will have problems without them.) In the W3C model, bodys *may* have IDs.\n // We'll create ad-hoc IDs for bodies without IDs, but want to make sure that\n // generating the ID is idempotent: the same body should always get the same ID.\n // This will avoid unexpected results when checking for equality. \n return {\n id: id || `temp-${hashCode(body)}`,\n annotation: annotationId,\n type,\n purpose,\n value,\n creator: parseW3CUser(creator),\n created: created ? new Date(created) : undefined,\n updated: modified ? new Date(modified) : undefined,\n ...rest\n }\n\n});\n\n/** Serialization helper to remove core-specific fields from the annotation body **/\nexport const serializeW3CBodies = (bodies: AnnotationBody[]): W3CAnnotationBody[] =>\n bodies.map(b => {\n const { annotation: _a, created, updated, ...bodyRest } = b;\n\n const w3cBody: W3CAnnotationBody = {\n ...bodyRest,\n created: created?.toISOString(),\n modified: updated?.toISOString()\n }\n if (w3cBody.id?.startsWith('temp-')) {\n delete w3cBody.id;\n }\n\n return w3cBody;\n });\n","// SEABORN_BRIGHT\nexport const DEFAULT_PALETTE: Palette = [\n '#ff7c00', // orange\n '#1ac938', // green\n '#e8000b', // red\n '#8b2be2', // purple\n '#9f4800', // brown\n '#f14cc1', // pink\n '#ffc400', // khaki\n '#00d7ff', // cyan\n '#023eff' // blue\n];\n\nexport type Palette = string[];","import type { User } from '../model/User';\nimport type { Appearance } from './Appearance';\nimport type { PresentUser } from './PresentUser';\nimport { DEFAULT_PALETTE } from './ColorPalette';\n\nexport interface AppearanceProvider {\n\n addUser(presenceKey: string, user: User): Appearance;\n\n removeUser(user: PresentUser): void;\n\n}\n\nexport const defaultColorProvider = () => {\n\n const unassignedColors = [...DEFAULT_PALETTE];\n\n const assignRandomColor = () => {\n const rnd = Math.floor(Math.random() * unassignedColors.length);\n const color = unassignedColors[rnd];\n\n unassignedColors.splice(rnd, 1);\n\n return color;\n }\n\n const releaseColor = (color: string) =>\n unassignedColors.push(color);\n\n return { assignRandomColor, releaseColor };\n\n}\n\nexport const createDefaultAppearanceProvider = () => {\n\n const colorProvider = defaultColorProvider();\n\n const addUser = (presenceKey: string, user: User): Appearance => {\n const color = colorProvider.assignRandomColor();\n\n return {\n label: user.name || user.id,\n avatar: user.avatar,\n color\n };\n }\n\n const removeUser = (user: PresentUser) =>\n colorProvider.releaseColor(user.appearance.color);\n\n return { addUser, removeUser }\n \n}","import { nanoid } from 'nanoid';\nimport { createNanoEvents, type Unsubscribe } from 'nanoevents';\nimport type { User } from '../model/User';\nimport type { PresentUser } from './PresentUser';\nimport type { PresenceEvents } from './PresenceEvents';\nimport { createDefaultAppearanceProvider } from './AppearanceProvider';\nimport type { AppearanceProvider } from './AppearanceProvider';\n\nexport interface PresenceState {\n\n // Get users currently present to this room\n getPresentUsers(): PresentUser[];\n\n // Notify of a given present user's activity on the given annotations\n notifyActivity(presenceKey: string, annotationIds: string[]): void;\n\n // Add a listener for the given presence event\n on<E extends keyof PresenceEvents>(event: E, callback: PresenceEvents[E]): Unsubscribe;\n\n // Initial sync - which users are present under which keys\n syncUsers(state: { presenceKey: string, user: User }[]): void;\n\n // Update the selection state for the given prresent user\n updateSelection(presenceKey: string, selection: string[] | null): void;\n\n}\n\nconst isListEqual = (listA: any[], listB: any[]) => \n listA.every(a => listA.includes(a)) && listB.every(b => listA.includes(b));\n\n// This client's presence key\nexport const PRESENCE_KEY = nanoid();\n\nexport const createPresenceState = (\n appearanceProvider: AppearanceProvider = createDefaultAppearanceProvider()\n): PresenceState => {\n\n const emitter = createNanoEvents<PresenceEvents>();\n\n const presentUsers = new Map<string, PresentUser>();\n\n const selectionStates = new Map<string, string[]>();\n\n const addUser = (presenceKey: string, user: User) => {\n if (presentUsers.has(presenceKey)) {\n console.warn('Attempt to add user that is already present', presenceKey, user);\n return; \n }\n\n const appearance = appearanceProvider.addUser(presenceKey, user);\n\n presentUsers.set(presenceKey, { \n ...user,\n presenceKey,\n appearance\n });\n }\n\n const removeUser = (presenceKey: string) => {\n const user = presentUsers.get(presenceKey);\n if (!user) {\n console.warn('Attempt to remove user that is not present', presenceKey);\n return;\n }\n\n appearanceProvider.removeUser(user);\n\n presentUsers.delete(presenceKey);\n }\n\n const syncUsers = (state: { presenceKey: string, user: User }[]) => {\n // const keys = new Set(others.map(s => s.presenceKey));\n const keys = new Set(state.map(s => s.presenceKey));\n\n // These users need to be added to the presentUsers list\n // const toAdd = others.filter(({ presenceKey }) => !presentUsers.has(presenceKey));\n const toAdd = state.filter(({ presenceKey }) => !presentUsers.has(presenceKey));\n\n // These users need to be dropped from the list\n const toRemove = Array.from(presentUsers.values()).filter(presentUser =>\n !keys.has(presentUser.presenceKey));\n\n toAdd.forEach(({ presenceKey, user }) => addUser(presenceKey, user));\n\n toRemove.forEach(user => {\n const { presenceKey } = user;\n\n // If this user has a selection, fire deselect event\n if (selectionStates.has(presenceKey))\n emitter.emit('selectionChange', user, null);\n\n removeUser(presenceKey)\n });\n\n if (toAdd.length > 0 || toRemove.length > 0)\n emitter.emit('presence', getPresentUsers());\n }\n\n const notifyActivity = (presenceKey: string, annotationIds: string[]) => { \n const user = presentUsers.get(presenceKey);\n \n if (!user) {\n console.warn('Activity notification from user that is not present');\n return;\n }\n\n const currentSelection = selectionStates.get(presenceKey);\n\n // Was there a selection change we might have missed?\n if (!currentSelection || !isListEqual(currentSelection, annotationIds)) {\n selectionStates.set(presenceKey, annotationIds);\n emitter.emit('selectionChange', user, annotationIds);\n }\n }\n\n const updateSelection = (presenceKey: string, selection: string[] | null) => {\n const from = presentUsers.get(presenceKey);\n if (!from) {\n console.warn('Selection change for user that is not present', presenceKey);\n return;\n }\n\n if (selection)\n selectionStates.set(presenceKey, selection);\n else \n selectionStates.delete(presenceKey);\n\n emitter.emit('selectionChange', from, selection);\n }\n\n const getPresentUsers = () =>\n [...Array.from(presentUsers.values())];\n \n const on = <E extends keyof PresenceEvents>(event: E, callback: PresenceEvents[E]) =>\n emitter.on(event, callback);\n\n return {\n getPresentUsers,\n notifyActivity,\n on,\n syncUsers,\n updateSelection\n }\n\n}"],"names":["has","dequal","foo","bar","ctor","len","noop","safe_not_equal","a","b","subscriber_queue","writable","value","start","stop","subscribers","set","new_value","run_queue","subscriber","i","update","fn","subscribe","run","invalidate","createHoverState","store","currentHover","updated","changes","oldValue","UserSelectAction","EMPTY","createSelectionState","defaultSelectionAction","adapter","currentUserSelectAction","currentSelection","clear","isEmpty","_a","isSelected","annotationOrId","id","userSelect","idOrIds","event","annotations","annotation","selected","sel","action","onUserSelect","setSelected","editable","ids","isEditable","removeFromSelection","setUserSelectAction","crosswalked","byteToHex","unsafeStringify","arr","offset","getRandomValues","rnds8","rng","randomUUID","native","v4","options","buf","rnds","getContributors","creator","updatedBy","bodyCollaborators","users","body","u","reviveDates","revive","revived","createBody","payload","created","uuidv4","getAddedBodies","newValue","oldBodyIds","getRemovedBodies","newBodyIds","getChangedBodies","newBody","oldBody","hasTargetChanged","diffAnnotations","bodiesCreated","bodiesDeleted","bodiesUpdated","Ignore","Origin","shouldNotify","observer","_b","origin","ignore","arg","hasBodyChanges","hasTargetChanges","affectedAnnotations","mergeChanges","toMerge","previouslyCreatedIds","previouslyUpdatedIds","createdIds","deletedIds","updatedIds","mergeableUpdates","deleted","sanitize","isAnnotation","createStore","annotationIndex","bodyIndex","observers","observe","onChange","unobserve","idx","emit","addAnnotation","sanitized","updateOneAnnotation","arg1","arg2","oldId","updateAnnotation","arg3","bulkUpdateAnnotation","addBody","all","bulkAddAnnotation","replace","existing","next","deleteOneAnnotation","deleteAnnotation","bulkDeleteAnnotation","annotationsOrIds","deleteOneBody","oldAnnotation","newAnnotation","deleteBody","bulkDeleteBodies","bodies","getAnnotation","getBody","annotationId","updateOneBody","oldBodyId","updateBody","bulkUpdateBodies","updateOneTarget","target","targets","t","toSvelteStore","shim","createNanoEvents","args","callbacks","length","cb","DEBOUNCE","createUndoStack","history","emitter","changeStack","pointer","muteEvents","lastEvent","now","last","undoCreated","redoCreated","undoUpdated","redoUpdated","undoDeleted","redoDeleted","callback","createViewportState","createLifecycleObserver","state","undoStack","autoSave","hover","selection","viewport","initialSelection","idleTimeout","on","off","arg0","serialized0","serialized1","onIdleUpdate","updatedSelected","initial","updatedState","initialIds","selectedIds","relevantUpdates","onUndoOrRedo","undo","serializeAll","parseAll","serialized","result","parsed","error","createBaseAnnotator","cancelSelected","clearAnnotations","getAnnotationById","getAnnotations","getSelected","s","loadAnnotations","url","response","setAnnotations","removeAnnotation","parseFn","failed","previous","computeStyle","style","chainStyles","applyFirst","applySecond","first","second","urlAlphabet","random","bytes","customRandom","alphabet","defaultSize","getRandom","mask","step","size","j","customAlphabet","nanoid","scopedUrlAlphabet","createAnonymousGuest","hashCode","obj","str","hash","chr","parseW3CUser","user","parseW3CBodies","type","purpose","modified","rest","serializeW3CBodies","bodyRest","w3cBody","DEFAULT_PALETTE","defaultColorProvider","unassignedColors","rnd","color","createDefaultAppearanceProvider","colorProvider","presenceKey","isListEqual","listA","listB","PRESENCE_KEY","createPresenceState","appearanceProvider","presentUsers","selectionStates","addUser","appearance","removeUser","syncUsers","keys","toAdd","toRemove","presentUser","getPresentUsers","notifyActivity","annotationIds","updateSelection","from"],"mappings":"AAAA,IAAIA,IAAM,OAAO,UAAU;AAEpB,SAASC,EAAOC,GAAKC,GAAK;AAChC,MAAIC,GAAMC;AACV,MAAIH,MAAQC,EAAK,QAAO;AAExB,MAAID,KAAOC,MAAQC,IAAKF,EAAI,iBAAiBC,EAAI,aAAa;AAC7D,QAAIC,MAAS,KAAM,QAAOF,EAAI,QAAS,MAAKC,EAAI,QAAS;AACzD,QAAIC,MAAS,OAAQ,QAAOF,EAAI,SAAU,MAAKC,EAAI,SAAU;AAE7D,QAAI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,EAAS,SAAS,MAChCtH,EAAA,KAAK,YAAYwH,GAAiB;AAAA,EAC9C,GAEMC,IAAiB,CAAClB,GAAqBmB,MAA4B;AACjE,UAAAnC,IAAOuB,EAAa,IAAIP,CAAW;AAEzC,QAAI,CAAChB,GAAM;AACT,cAAQ,KAAK,qDAAqD;AAClE;AAAA,IAAA;AAGI,UAAAnO,IAAmB2P,EAAgB,IAAIR,CAAW;AAGxD,KAAI,CAACnP,KAAoB,CAACoP,GAAYpP,GAAkBsQ,CAAa,OACnDX,EAAA,IAAIR,GAAamB,CAAa,GACtC1H,EAAA,KAAK,mBAAmBuF,GAAMmC,CAAa;AAAA,EAEvD,GAEMC,IAAkB,CAACpB,GAAqBnF,MAA+B;AACrE,UAAAwG,IAAOd,EAAa,IAAIP,CAAW;AACzC,QAAI,CAACqB,GAAM;AACD,cAAA,KAAK,iDAAiDrB,CAAW;AACzE;AAAA,IAAA;AAGE,IAAAnF,IACc2F,EAAA,IAAIR,GAAanF,CAAS,IAE1C2F,EAAgB,OAAOR,CAAW,GAE5BvG,EAAA,KAAK,mBAAmB4H,GAAMxG,CAAS;AAAA,EACjD,GAEMoG,IAAkB,MACtB,CAAC,GAAG,MAAM,KAAKV,EAAa,OAAO,CAAC,CAAC;AAKhC,SAAA;AAAA,IACL,iBAAAU;AAAA,IACA,gBAAAC;AAAA,IACA,IANS,CAAiC5P,GAAUgJ,MACpDb,EAAQ,GAAGnI,GAAOgJ,CAAQ;AAAA,IAM1B,WAAAsG;AAAA,IACA,iBAAAQ;AAAA,EACF;AAEF;","x_google_ignoreList":[0,1,2,5,6,7,8,14,21,22]}
|
|
1
|
+
{"version":3,"file":"annotorious-core.es.js","sources":["../../../node_modules/dequal/lite/index.mjs","../../../node_modules/svelte/src/runtime/internal/utils.js","../../../node_modules/svelte/src/runtime/store/index.js","../src/state/Hover.ts","../src/state/Selection.ts","../../../node_modules/uuid/dist/esm-browser/stringify.js","../../../node_modules/uuid/dist/esm-browser/rng.js","../../../node_modules/uuid/dist/esm-browser/native.js","../../../node_modules/uuid/dist/esm-browser/v4.js","../src/utils/annotationUtils.ts","../src/utils/diffAnnotations.ts","../src/state/StoreObserver.ts","../src/state/Store.ts","../src/state/SvelteStore.ts","../../../node_modules/nanoevents/index.js","../src/state/UndoStack.ts","../src/state/Viewport.ts","../src/lifecycle/Lifecycle.ts","../src/model/FormatAdapter.ts","../src/model/Annotator.ts","../src/model/DrawingStyle.ts","../../../node_modules/nanoid/url-alphabet/index.js","../../../node_modules/nanoid/index.browser.js","../src/model/User.ts","../src/model/W3CAnnotation.ts","../src/presence/ColorPalette.ts","../src/presence/AppearanceProvider.ts","../src/presence/PresenceState.ts"],"sourcesContent":["var has = Object.prototype.hasOwnProperty;\n\nexport function dequal(foo, bar) {\n\tvar ctor, len;\n\tif (foo === bar) return true;\n\n\tif (foo && bar && (ctor=foo.constructor) === bar.constructor) {\n\t\tif (ctor === Date) return foo.getTime() === bar.getTime();\n\t\tif (ctor === RegExp) return foo.toString() === bar.toString();\n\n\t\tif (ctor === Array) {\n\t\t\tif ((len=foo.length) === bar.length) {\n\t\t\t\twhile (len-- && dequal(foo[len], bar[len]));\n\t\t\t}\n\t\t\treturn len === -1;\n\t\t}\n\n\t\tif (!ctor || typeof foo === 'object') {\n\t\t\tlen = 0;\n\t\t\tfor (ctor in foo) {\n\t\t\t\tif (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;\n\t\t\t\tif (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;\n\t\t\t}\n\t\t\treturn Object.keys(bar).length === len;\n\t\t}\n\t}\n\n\treturn foo !== foo && bar !== bar;\n}\n","/** @returns {void} */\nexport function noop() {}\n\nexport const identity = (x) => x;\n\n/**\n * @template T\n * @template S\n * @param {T} tar\n * @param {S} src\n * @returns {T & S}\n */\nexport function assign(tar, src) {\n\t// @ts-ignore\n\tfor (const k in src) tar[k] = src[k];\n\treturn /** @type {T & S} */ (tar);\n}\n\n// Adapted from https://github.com/then/is-promise/blob/master/index.js\n// Distributed under MIT License https://github.com/then/is-promise/blob/master/LICENSE\n/**\n * @param {any} value\n * @returns {value is PromiseLike<any>}\n */\nexport function is_promise(value) {\n\treturn (\n\t\t!!value &&\n\t\t(typeof value === 'object' || typeof value === 'function') &&\n\t\ttypeof (/** @type {any} */ (value).then) === 'function'\n\t);\n}\n\n/** @returns {void} */\nexport function add_location(element, file, line, column, char) {\n\telement.__svelte_meta = {\n\t\tloc: { file, line, column, char }\n\t};\n}\n\nexport function run(fn) {\n\treturn fn();\n}\n\nexport function blank_object() {\n\treturn Object.create(null);\n}\n\n/**\n * @param {Function[]} fns\n * @returns {void}\n */\nexport function run_all(fns) {\n\tfns.forEach(run);\n}\n\n/**\n * @param {any} thing\n * @returns {thing is Function}\n */\nexport function is_function(thing) {\n\treturn typeof thing === 'function';\n}\n\n/** @returns {boolean} */\nexport function safe_not_equal(a, b) {\n\treturn a != a ? b == b : a !== b || (a && typeof a === 'object') || typeof a === 'function';\n}\n\nlet src_url_equal_anchor;\n\n/**\n * @param {string} element_src\n * @param {string} url\n * @returns {boolean}\n */\nexport function src_url_equal(element_src, url) {\n\tif (element_src === url) return true;\n\tif (!src_url_equal_anchor) {\n\t\tsrc_url_equal_anchor = document.createElement('a');\n\t}\n\t// This is actually faster than doing URL(..).href\n\tsrc_url_equal_anchor.href = url;\n\treturn element_src === src_url_equal_anchor.href;\n}\n\n/** @param {string} srcset */\nfunction split_srcset(srcset) {\n\treturn srcset.split(',').map((src) => src.trim().split(' ').filter(Boolean));\n}\n\n/**\n * @param {HTMLSourceElement | HTMLImageElement} element_srcset\n * @param {string | undefined | null} srcset\n * @returns {boolean}\n */\nexport function srcset_url_equal(element_srcset, srcset) {\n\tconst element_urls = split_srcset(element_srcset.srcset);\n\tconst urls = split_srcset(srcset || '');\n\n\treturn (\n\t\turls.length === element_urls.length &&\n\t\turls.every(\n\t\t\t([url, width], i) =>\n\t\t\t\twidth === element_urls[i][1] &&\n\t\t\t\t// We need to test both ways because Vite will create an a full URL with\n\t\t\t\t// `new URL(asset, import.meta.url).href` for the client when `base: './'`, and the\n\t\t\t\t// relative URLs inside srcset are not automatically resolved to absolute URLs by\n\t\t\t\t// browsers (in contrast to img.src). This means both SSR and DOM code could\n\t\t\t\t// contain relative or absolute URLs.\n\t\t\t\t(src_url_equal(element_urls[i][0], url) || src_url_equal(url, element_urls[i][0]))\n\t\t)\n\t);\n}\n\n/** @returns {boolean} */\nexport function not_equal(a, b) {\n\treturn a != a ? b == b : a !== b;\n}\n\n/** @returns {boolean} */\nexport function is_empty(obj) {\n\treturn Object.keys(obj).length === 0;\n}\n\n/** @returns {void} */\nexport function validate_store(store, name) {\n\tif (store != null && typeof store.subscribe !== 'function') {\n\t\tthrow new Error(`'${name}' is not a store with a 'subscribe' method`);\n\t}\n}\n\nexport function subscribe(store, ...callbacks) {\n\tif (store == null) {\n\t\tfor (const callback of callbacks) {\n\t\t\tcallback(undefined);\n\t\t}\n\t\treturn noop;\n\t}\n\tconst unsub = store.subscribe(...callbacks);\n\treturn unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;\n}\n\n/**\n * Get the current value from a store by subscribing and immediately unsubscribing.\n *\n * https://svelte.dev/docs/svelte-store#get\n * @template T\n * @param {import('../store/public.js').Readable<T>} store\n * @returns {T}\n */\nexport function get_store_value(store) {\n\tlet value;\n\tsubscribe(store, (_) => (value = _))();\n\treturn value;\n}\n\n/** @returns {void} */\nexport function component_subscribe(component, store, callback) {\n\tcomponent.$$.on_destroy.push(subscribe(store, callback));\n}\n\nexport function create_slot(definition, ctx, $$scope, fn) {\n\tif (definition) {\n\t\tconst slot_ctx = get_slot_context(definition, ctx, $$scope, fn);\n\t\treturn definition[0](slot_ctx);\n\t}\n}\n\nfunction get_slot_context(definition, ctx, $$scope, fn) {\n\treturn definition[1] && fn ? assign($$scope.ctx.slice(), definition[1](fn(ctx))) : $$scope.ctx;\n}\n\nexport function get_slot_changes(definition, $$scope, dirty, fn) {\n\tif (definition[2] && fn) {\n\t\tconst lets = definition[2](fn(dirty));\n\t\tif ($$scope.dirty === undefined) {\n\t\t\treturn lets;\n\t\t}\n\t\tif (typeof lets === 'object') {\n\t\t\tconst merged = [];\n\t\t\tconst len = Math.max($$scope.dirty.length, lets.length);\n\t\t\tfor (let i = 0; i < len; i += 1) {\n\t\t\t\tmerged[i] = $$scope.dirty[i] | lets[i];\n\t\t\t}\n\t\t\treturn merged;\n\t\t}\n\t\treturn $$scope.dirty | lets;\n\t}\n\treturn $$scope.dirty;\n}\n\n/** @returns {void} */\nexport function update_slot_base(\n\tslot,\n\tslot_definition,\n\tctx,\n\t$$scope,\n\tslot_changes,\n\tget_slot_context_fn\n) {\n\tif (slot_changes) {\n\t\tconst slot_context = get_slot_context(slot_definition, ctx, $$scope, get_slot_context_fn);\n\t\tslot.p(slot_context, slot_changes);\n\t}\n}\n\n/** @returns {void} */\nexport function update_slot(\n\tslot,\n\tslot_definition,\n\tctx,\n\t$$scope,\n\tdirty,\n\tget_slot_changes_fn,\n\tget_slot_context_fn\n) {\n\tconst slot_changes = get_slot_changes(slot_definition, $$scope, dirty, get_slot_changes_fn);\n\tupdate_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn);\n}\n\n/** @returns {any[] | -1} */\nexport function get_all_dirty_from_scope($$scope) {\n\tif ($$scope.ctx.length > 32) {\n\t\tconst dirty = [];\n\t\tconst length = $$scope.ctx.length / 32;\n\t\tfor (let i = 0; i < length; i++) {\n\t\t\tdirty[i] = -1;\n\t\t}\n\t\treturn dirty;\n\t}\n\treturn -1;\n}\n\n/** @returns {{}} */\nexport function exclude_internal_props(props) {\n\tconst result = {};\n\tfor (const k in props) if (k[0] !== '$') result[k] = props[k];\n\treturn result;\n}\n\n/** @returns {{}} */\nexport function compute_rest_props(props, keys) {\n\tconst rest = {};\n\tkeys = new Set(keys);\n\tfor (const k in props) if (!keys.has(k) && k[0] !== '$') rest[k] = props[k];\n\treturn rest;\n}\n\n/** @returns {{}} */\nexport function compute_slots(slots) {\n\tconst result = {};\n\tfor (const key in slots) {\n\t\tresult[key] = true;\n\t}\n\treturn result;\n}\n\n/** @returns {(this: any, ...args: any[]) => void} */\nexport function once(fn) {\n\tlet ran = false;\n\treturn function (...args) {\n\t\tif (ran) return;\n\t\tran = true;\n\t\tfn.call(this, ...args);\n\t};\n}\n\nexport function null_to_empty(value) {\n\treturn value == null ? '' : value;\n}\n\nexport function set_store_value(store, ret, value) {\n\tstore.set(value);\n\treturn ret;\n}\n\nexport const has_prop = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);\n\nexport function action_destroyer(action_result) {\n\treturn action_result && is_function(action_result.destroy) ? action_result.destroy : noop;\n}\n\n/** @param {number | string} value\n * @returns {[number, string]}\n */\nexport function split_css_unit(value) {\n\tconst split = typeof value === 'string' && value.match(/^\\s*(-?[\\d.]+)([^\\s]*)\\s*$/);\n\treturn split ? [parseFloat(split[1]), split[2] || 'px'] : [/** @type {number} */ (value), 'px'];\n}\n\nexport const contenteditable_truthy_values = ['', true, 1, 'true', 'contenteditable'];\n","import {\n\trun_all,\n\tsubscribe,\n\tnoop,\n\tsafe_not_equal,\n\tis_function,\n\tget_store_value\n} from '../internal/index.js';\n\nconst subscriber_queue = [];\n\n/**\n * Creates a `Readable` store that allows reading by subscription.\n *\n * https://svelte.dev/docs/svelte-store#readable\n * @template T\n * @param {T} [value] initial value\n * @param {import('./public.js').StartStopNotifier<T>} [start]\n * @returns {import('./public.js').Readable<T>}\n */\nexport function readable(value, start) {\n\treturn {\n\t\tsubscribe: writable(value, start).subscribe\n\t};\n}\n\n/**\n * Create a `Writable` store that allows both updating and reading by subscription.\n *\n * https://svelte.dev/docs/svelte-store#writable\n * @template T\n * @param {T} [value] initial value\n * @param {import('./public.js').StartStopNotifier<T>} [start]\n * @returns {import('./public.js').Writable<T>}\n */\nexport function writable(value, start = noop) {\n\t/** @type {import('./public.js').Unsubscriber} */\n\tlet stop;\n\t/** @type {Set<import('./private.js').SubscribeInvalidateTuple<T>>} */\n\tconst subscribers = new Set();\n\t/** @param {T} new_value\n\t * @returns {void}\n\t */\n\tfunction set(new_value) {\n\t\tif (safe_not_equal(value, new_value)) {\n\t\t\tvalue = new_value;\n\t\t\tif (stop) {\n\t\t\t\t// store is ready\n\t\t\t\tconst run_queue = !subscriber_queue.length;\n\t\t\t\tfor (const subscriber of subscribers) {\n\t\t\t\t\tsubscriber[1]();\n\t\t\t\t\tsubscriber_queue.push(subscriber, value);\n\t\t\t\t}\n\t\t\t\tif (run_queue) {\n\t\t\t\t\tfor (let i = 0; i < subscriber_queue.length; i += 2) {\n\t\t\t\t\t\tsubscriber_queue[i][0](subscriber_queue[i + 1]);\n\t\t\t\t\t}\n\t\t\t\t\tsubscriber_queue.length = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * @param {import('./public.js').Updater<T>} fn\n\t * @returns {void}\n\t */\n\tfunction update(fn) {\n\t\tset(fn(value));\n\t}\n\n\t/**\n\t * @param {import('./public.js').Subscriber<T>} run\n\t * @param {import('./private.js').Invalidator<T>} [invalidate]\n\t * @returns {import('./public.js').Unsubscriber}\n\t */\n\tfunction subscribe(run, invalidate = noop) {\n\t\t/** @type {import('./private.js').SubscribeInvalidateTuple<T>} */\n\t\tconst subscriber = [run, invalidate];\n\t\tsubscribers.add(subscriber);\n\t\tif (subscribers.size === 1) {\n\t\t\tstop = start(set, update) || noop;\n\t\t}\n\t\trun(value);\n\t\treturn () => {\n\t\t\tsubscribers.delete(subscriber);\n\t\t\tif (subscribers.size === 0 && stop) {\n\t\t\t\tstop();\n\t\t\t\tstop = null;\n\t\t\t}\n\t\t};\n\t}\n\treturn { set, update, subscribe };\n}\n\n/**\n * Derived value store by synchronizing one or more readable stores and\n * applying an aggregation function over its input values.\n *\n * https://svelte.dev/docs/svelte-store#derived\n * @template {import('./private.js').Stores} S\n * @template T\n * @overload\n * @param {S} stores - input stores\n * @param {(values: import('./private.js').StoresValues<S>, set: (value: T) => void, update: (fn: import('./public.js').Updater<T>) => void) => import('./public.js').Unsubscriber | void} fn - function callback that aggregates the values\n * @param {T} [initial_value] - initial value\n * @returns {import('./public.js').Readable<T>}\n */\n\n/**\n * Derived value store by synchronizing one or more readable stores and\n * applying an aggregation function over its input values.\n *\n * https://svelte.dev/docs/svelte-store#derived\n * @template {import('./private.js').Stores} S\n * @template T\n * @overload\n * @param {S} stores - input stores\n * @param {(values: import('./private.js').StoresValues<S>) => T} fn - function callback that aggregates the values\n * @param {T} [initial_value] - initial value\n * @returns {import('./public.js').Readable<T>}\n */\n\n/**\n * @template {import('./private.js').Stores} S\n * @template T\n * @param {S} stores\n * @param {Function} fn\n * @param {T} [initial_value]\n * @returns {import('./public.js').Readable<T>}\n */\nexport function derived(stores, fn, initial_value) {\n\tconst single = !Array.isArray(stores);\n\t/** @type {Array<import('./public.js').Readable<any>>} */\n\tconst stores_array = single ? [stores] : stores;\n\tif (!stores_array.every(Boolean)) {\n\t\tthrow new Error('derived() expects stores as input, got a falsy value');\n\t}\n\tconst auto = fn.length < 2;\n\treturn readable(initial_value, (set, update) => {\n\t\tlet started = false;\n\t\tconst values = [];\n\t\tlet pending = 0;\n\t\tlet cleanup = noop;\n\t\tconst sync = () => {\n\t\t\tif (pending) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcleanup();\n\t\t\tconst result = fn(single ? values[0] : values, set, update);\n\t\t\tif (auto) {\n\t\t\t\tset(result);\n\t\t\t} else {\n\t\t\t\tcleanup = is_function(result) ? result : noop;\n\t\t\t}\n\t\t};\n\t\tconst unsubscribers = stores_array.map((store, i) =>\n\t\t\tsubscribe(\n\t\t\t\tstore,\n\t\t\t\t(value) => {\n\t\t\t\t\tvalues[i] = value;\n\t\t\t\t\tpending &= ~(1 << i);\n\t\t\t\t\tif (started) {\n\t\t\t\t\t\tsync();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tpending |= 1 << i;\n\t\t\t\t}\n\t\t\t)\n\t\t);\n\t\tstarted = true;\n\t\tsync();\n\t\treturn function stop() {\n\t\t\trun_all(unsubscribers);\n\t\t\tcleanup();\n\t\t\t// We need to set this to false because callbacks can still happen despite having unsubscribed:\n\t\t\t// Callbacks might already be placed in the queue which doesn't know it should no longer\n\t\t\t// invoke this derived store.\n\t\t\tstarted = false;\n\t\t};\n\t});\n}\n\n/**\n * Takes a store and returns a new one derived from the old one that is readable.\n *\n * https://svelte.dev/docs/svelte-store#readonly\n * @template T\n * @param {import('./public.js').Readable<T>} store - store to make readonly\n * @returns {import('./public.js').Readable<T>}\n */\nexport function readonly(store) {\n\treturn {\n\t\tsubscribe: store.subscribe.bind(store)\n\t};\n}\n\nexport { get_store_value as get };\n","import { writable } from 'svelte/store';\nimport type { Annotation } from '../model';\nimport type { Store } from './Store';\n\nexport type HoverState<T extends Annotation> = ReturnType<typeof createHoverState<T>>;\n\nexport const createHoverState = <T extends Annotation>(store: Store<T>) => {\n\n const { subscribe, set } = writable<string | undefined>();\n\n let currentHover: string | undefined;\n\n subscribe(updated => currentHover = updated);\n\n // Track store delete and update events\n store.observe(( { changes }) => { \n if (currentHover) {\n const isDeleted = (changes.deleted || []).some(a => a.id === currentHover);\n if (isDeleted)\n set(undefined);\n \n const updated = (changes.updated || []).find(({ oldValue }) => oldValue.id === currentHover);\n if (updated)\n set(updated.newValue.id);\n }\n });\n\n return { \n get current() { return currentHover },\n subscribe, \n set \n };\n\n}\n","import { writable } from 'svelte/store';\nimport { dequal } from 'dequal/lite';\nimport type { Annotation, FormatAdapter } from '../model';\nimport type { Store } from './Store';\n\nexport interface Selection {\n\n selected: { id: string, editable?: boolean }[],\n\n event?: PointerEvent | KeyboardEvent;\n\n}\n\nexport type SelectionState<I extends Annotation, E extends unknown> = ReturnType<typeof createSelectionState<I, E>>;\n\nexport enum UserSelectAction {\n\n EDIT = 'EDIT', // Make annotation target(s) editable on pointer select\n\n SELECT = 'SELECT', // Just select, but don't make editable\n\n NONE = 'NONE' // Click won't select - the annotation is completely inert\n\n}\n\nexport type UserSelectActionExpression<T extends unknown> = UserSelectAction | ((a: T) => UserSelectAction);\n\nconst EMPTY: Selection = { selected: [] };\n\nexport const createSelectionState = <I extends Annotation, E extends unknown>(\n store: Store<I>,\n defaultSelectionAction?: UserSelectActionExpression<E>,\n adapter?: FormatAdapter<I, E>\n) => {\n const { subscribe, set } = writable<Selection>(EMPTY);\n\n let currentUserSelectAction = defaultSelectionAction;\n\n let currentSelection: Selection = EMPTY;\n\n subscribe(updated => currentSelection = updated);\n\n const clear = () => {\n if (!dequal(currentSelection, EMPTY)) {\n set(EMPTY);\n }\n };\n\n const isEmpty = () => currentSelection.selected?.length === 0;\n\n const isSelected = (annotationOrId: I | string) => {\n if (isEmpty())\n return false;\n\n const id = typeof annotationOrId === 'string' ? annotationOrId : annotationOrId.id;\n return currentSelection.selected.some(i => i.id === id);\n }\n\n const userSelect = (idOrIds: string | string[], event?: Selection['event']) => {\n let annotations: I[];\n\n if (Array.isArray(idOrIds)) {\n annotations = idOrIds.map(id => store.getAnnotation(id)!).filter(Boolean);\n\n if (annotations.length < idOrIds.length) {\n console.warn('Invalid selection: ' + idOrIds.filter(id => !annotations.some(a => a.id === id)));\n return;\n }\n } else {\n const annotation = store.getAnnotation(idOrIds);\n if (!annotation) {\n console.warn('Invalid selection: ' + idOrIds);\n return;\n }\n\n annotations = [annotation];\n }\n\n const selected = annotations.reduce<{ id: string, editable?: boolean }[]>((sel, a) => {\n const action = onUserSelect(a, currentUserSelectAction, adapter);\n if (action === UserSelectAction.EDIT)\n return [...sel, { id: a.id, editable: true }];\n else if (action === UserSelectAction.SELECT) \n return [...sel, { id: a.id }];\n else\n return sel;\n }, []);\n\n set({ selected, event });\n }\n\n const setSelected = (idOrIds: string | string[], editable?: boolean) => {\n const ids = Array.isArray(idOrIds) ? idOrIds : [idOrIds];\n\n // Remove invalid\n const annotations = ids\n .map(id => store.getAnnotation(id))\n .filter((a): a is I => Boolean(a));\n\n set({\n selected: annotations.map(annotation => {\n\n // If editable isn't set, use the default behavior\n const isEditable = editable === undefined\n ? onUserSelect(annotation, currentUserSelectAction, adapter) === UserSelectAction.EDIT\n : editable;\n\n return { id: annotation.id, editable: isEditable }\n })\n });\n\n if (annotations.length !== ids.length)\n console.warn('Invalid selection', idOrIds);\n }\n\n const removeFromSelection = (ids: string[]) => {\n if (isEmpty())\n return false;\n\n const { selected } = currentSelection;\n\n // Checks which of the given annotations are actually in the selection\n const shouldRemove = selected.some(({ id }) => ids.includes(id));\n if (shouldRemove)\n set({ selected: selected.filter(({ id }) => !ids.includes(id)) });\n }\n\n const setUserSelectAction = (action: UserSelectActionExpression<E> | undefined) => {\n currentUserSelectAction = action;\n setSelected(currentSelection.selected.map(({ id }) => id));\n };\n\n // Track store delete and update events\n store.observe(\n ({ changes }) => removeFromSelection((changes.deleted || []).map(a => a.id))\n );\n\n return {\n get event() {\n return currentSelection ? currentSelection.event : null;\n },\n get selected() {\n return currentSelection ? [...currentSelection.selected] : null;\n },\n get userSelectAction() {\n return currentUserSelectAction;\n },\n clear,\n isEmpty,\n isSelected,\n setSelected,\n setUserSelectAction,\n subscribe,\n userSelect\n };\n\n}\n\nexport const onUserSelect = <I extends Annotation, E extends unknown>(\n annotation: I,\n action?: UserSelectActionExpression<E>,\n adapter?: FormatAdapter<I, E>\n): UserSelectAction => {\n const crosswalked = adapter ? adapter.serialize(annotation) : annotation as unknown as E;\n return (typeof action === 'function') ? action(crosswalked) : (action || UserSelectAction.EDIT)\n}\n","import validate from './validate.js';\nconst byteToHex = [];\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\nexport function unsafeStringify(arr, offset = 0) {\n return (byteToHex[arr[offset + 0]] +\n byteToHex[arr[offset + 1]] +\n byteToHex[arr[offset + 2]] +\n byteToHex[arr[offset + 3]] +\n '-' +\n byteToHex[arr[offset + 4]] +\n byteToHex[arr[offset + 5]] +\n '-' +\n byteToHex[arr[offset + 6]] +\n byteToHex[arr[offset + 7]] +\n '-' +\n byteToHex[arr[offset + 8]] +\n byteToHex[arr[offset + 9]] +\n '-' +\n byteToHex[arr[offset + 10]] +\n byteToHex[arr[offset + 11]] +\n byteToHex[arr[offset + 12]] +\n byteToHex[arr[offset + 13]] +\n byteToHex[arr[offset + 14]] +\n byteToHex[arr[offset + 15]]).toLowerCase();\n}\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset);\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n return uuid;\n}\nexport default stringify;\n","let getRandomValues;\nconst rnds8 = new Uint8Array(16);\nexport default function rng() {\n if (!getRandomValues) {\n if (typeof crypto === 'undefined' || !crypto.getRandomValues) {\n throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n getRandomValues = crypto.getRandomValues.bind(crypto);\n }\n return getRandomValues(rnds8);\n}\n","const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nexport default { randomUUID };\n","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n options = options || {};\n const rnds = options.random || (options.rng || rng)();\n rnds[6] = (rnds[6] & 0x0f) | 0x40;\n rnds[8] = (rnds[8] & 0x3f) | 0x80;\n if (buf) {\n offset = offset || 0;\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n return buf;\n }\n return unsafeStringify(rnds);\n}\nexport default v4;\n","import { v4 as uuidv4 } from 'uuid';\nimport type { Annotation, AnnotationBody } from '../model/Annotation';\nimport type { User } from '../model/User';\n\n/**\n * Returns all users listed as creators or updaters in any parts of this\n * annotation.\n */\nexport const getContributors = (annotation: Annotation): User[] => {\n const { creator, updatedBy } = annotation.target;\n\n const bodyCollaborators = annotation.bodies.reduce((users, body) => (\n [...users, body.creator, body.updatedBy].filter(Boolean) as User[]\n ), [] as User[]);\n\n return [\n creator,\n updatedBy,\n ...bodyCollaborators\n ].filter(u => u) as User[] // Remove undefined\n}\n\ntype HasTime = { created?: string | Date; updated?: string | Date; };\n\n/** \n * Converts any string dates in the given annotation(-like) \n * object to proper Date objects.\n */\nexport const reviveDates = <A extends Annotation = Annotation>(annotation: any): A => {\n const revive = <T extends HasTime>(body: T): T => {\n const revived = {...body};\n\n if (body.created && typeof body.created === 'string')\n revived.created = new Date(body.created);\n\n if (body.updated && typeof body.updated === 'string')\n revived.updated = new Date(body.updated);\n\n return revived;\n }\n\n return {\n ...annotation,\n bodies: (annotation.bodies || []).map(revive),\n target: revive(annotation.target)\n } as A;\n}\n\n/**\n * Shorthand/helper.\n */\nexport const createBody = (\n annotationOrId: string | Annotation, \n payload: { [key: string]: any },\n created?: Date,\n creator?: User\n): AnnotationBody => ({\n id: uuidv4(),\n annotation: typeof annotationOrId === 'string' ? annotationOrId : annotationOrId.id,\n created: created || new Date(),\n creator,\n ...payload\n});","import { dequal } from 'dequal/lite';\nimport type { Update } from '../state/StoreObserver';\nimport type { Annotation } from '../model/Annotation';\n\nconst getAddedBodies = (oldValue: Annotation, newValue: Annotation) => {\n const oldBodyIds = new Set(oldValue.bodies.map(b => b.id));\n return newValue.bodies.filter(b => !oldBodyIds.has(b.id));\n}\n\nconst getRemovedBodies = (oldValue: Annotation, newValue: Annotation) => {\n const newBodyIds = new Set(newValue.bodies.map(b => b.id));\n return oldValue.bodies.filter(b => !newBodyIds.has(b.id));\n}\n\nconst getChangedBodies = (oldValue: Annotation, newValue: Annotation) => \n newValue.bodies\n .map(newBody => {\n const oldBody = oldValue.bodies.find(b => b.id === newBody.id);\n return { newBody, oldBody: oldBody && !dequal(oldBody, newBody) ? oldBody : undefined }\n })\n .filter(({ oldBody }) => oldBody)\n .map(({ oldBody, newBody }) => ({ oldBody: oldBody!, newBody }));\n\nconst hasTargetChanged = (oldValue: Annotation, newValue: Annotation) => \n !dequal(oldValue.target, newValue.target);\n\nexport const diffAnnotations = <T extends Annotation = Annotation>(oldValue: T, newValue: T): Update<T> => {\n const bodiesCreated = getAddedBodies(oldValue, newValue);\n const bodiesDeleted = getRemovedBodies(oldValue, newValue);\n const bodiesUpdated = getChangedBodies(oldValue, newValue);\n\n return {\n oldValue, \n newValue,\n bodiesCreated: bodiesCreated.length > 0 ? bodiesCreated : undefined,\n bodiesDeleted: bodiesDeleted.length > 0 ? bodiesDeleted : undefined,\n bodiesUpdated: bodiesUpdated.length > 0 ? bodiesUpdated : undefined,\n targetUpdated: hasTargetChanged(oldValue, newValue) ? { oldTarget: oldValue.target, newTarget: newValue.target } : undefined\n }\n}","import type { Annotation, AnnotationBody, AnnotationTarget } from '../model/Annotation';\nimport { diffAnnotations } from '../utils';\n\n/** Interface for listening to changes in the annotation store **/\nexport interface StoreObserver<T extends Annotation> { \n\n onChange: { (event: StoreChangeEvent<T>): void };\n\n options: StoreObserveOptions;\n\n}\n\n/** A change event fired when the store state changes **/\nexport interface StoreChangeEvent<T extends Annotation> {\n\n origin: Origin;\n\n changes: ChangeSet<T>;\n\n state: T[];\n\n}\n\nexport interface ChangeSet<T extends Annotation> {\n\n created?: T[];\n\n deleted?: T[];\n\n updated?: Update<T>[];\n\n}\n\nexport interface Update<T extends Annotation> {\n\n oldValue: T;\n\n newValue: T;\n\n bodiesCreated?: T['bodies'];\n\n bodiesDeleted?: T['bodies'];\n\n bodiesUpdated?: Array<{ oldBody: T['bodies'][number], newBody: T['bodies'][number] }>;\n\n targetUpdated?: { oldTarget: T['target'], newTarget: T['target'] };\n\n}\n\n/** Options to control which events the observer wants to get notified about **/\nexport interface StoreObserveOptions {\n\n // Observe changes on targets, bodies or both?\n ignore?: Ignore;\n\n // Observe changes on one more specific annotations\n annotations?: string | string[];\n\n // Observer changes only for a specific origin\n origin?: Origin\n\n}\n\n/** Allows the observer to ignore certain event types **/\nexport enum Ignore { \n\n // Don't notify this observer for changes that involve bodies only\n BODY_ONLY = 'BODY_ONLY',\n\n // Don't notify for changes on targets only\n TARGET_ONLY = 'TARGET_ONLY'\n\n}\n\n/** \n * Allows the observer to listen only for events that originated locally or from a remote source.\n * \n * SILENT should be used for updates that are not supposed to trigger an event. Remember that \n * with great power comes great responsibility: SILENT is really for Annotorious plugins and\n * extensions ONLY.\n */\nexport enum Origin { \n \n LOCAL = 'LOCAL', \n \n REMOTE = 'REMOTE',\n \n SILENT = 'SILENT'\n\n}\n\n/** Tests if this observer should be notified about this event **/\nexport const shouldNotify = <T extends Annotation>(observer: StoreObserver<T>, event: StoreChangeEvent<T>) => {\n const { changes, origin } = event;\n\n const isRelevantOrigin = observer.options.origin \n ? observer.options.origin === origin \n : origin !== Origin.SILENT;\n\n if (!isRelevantOrigin)\n return false;\n\n if (observer.options.ignore) {\n const { ignore } = observer.options;\n\n // Shorthand\n const has = (arg: any[] | undefined) => arg && arg.length > 0;\n\n const hasAnnotationChanges =\n has(changes.created) || has(changes.deleted);\n\n if (!hasAnnotationChanges) {\n const hasBodyChanges =\n changes.updated?.some(u => has(u.bodiesCreated) || has(u.bodiesDeleted) || has(u.bodiesUpdated));\n \n const hasTargetChanges = \n changes.updated?.some(u => u.targetUpdated);\n\n if (ignore === Ignore.BODY_ONLY && hasBodyChanges && !hasTargetChanges)\n return false;\n\n if (ignore === Ignore.TARGET_ONLY && hasTargetChanges && !hasBodyChanges)\n return false;\n }\n }\n\n if (observer.options.annotations) {\n // This observer has a filter set on specific annotations - check affected\n const affectedAnnotations = new Set([\n ...(changes.created || []).map(a => a.id),\n ...(changes.deleted || []).map(a => a.id),\n ...(changes.updated || []).map(({ oldValue }) => oldValue.id)\n ]);\n\n const observed = Array.isArray(observer.options.annotations) ?\n observer.options.annotations : [ observer.options.annotations ];\n\n return Boolean(observed.find(id => affectedAnnotations.has(id)));\n } else {\n return true;\n }\n\n}\n\nexport const mergeChanges = <T extends Annotation>(changes: ChangeSet<T>, toMerge: ChangeSet<T>) => {\n const previouslyCreatedIds = new Set((changes.created || []).map(a => a.id));\n const previouslyUpdatedIds = new Set((changes.updated || []).map(({ newValue })=> newValue.id));\n\n const createdIds = new Set((toMerge.created || []).map(a => a.id));\n const deletedIds = new Set((toMerge.deleted || []).map(a => a.id));\n const updatedIds = new Set((toMerge.updated || []).map(({ oldValue }) => oldValue.id));\n\n // Updates that will be merged into create or previous update events\n const mergeableUpdates = new Set((toMerge.updated || [])\n .filter(({ oldValue }) => previouslyCreatedIds.has(oldValue.id) || previouslyUpdatedIds.has(oldValue.id))\n .map(({ oldValue }) => oldValue.id ));\n\n // * created *\n // - drop created that were then deleted\n // - merge any updates on created\n // - append newly created\n const created = [\n ...(changes.created || [])\n .filter(a => !deletedIds.has(a.id))\n .map(a => updatedIds.has(a.id) \n ? toMerge.updated!.find(({ oldValue }) => oldValue.id === a.id)!.newValue\n : a),\n ...(toMerge.created || [])\n ];\n\n // * deleted *\n // - drop deleted that were later re-created (redo action!)\n // - append newly deleted, but remove any that delete annotations \n // that were created in the same round\n const deleted = [\n ...(changes.deleted || [])\n .filter(a => !createdIds.has(a.id)),\n ...(toMerge.deleted || []) \n .filter(a => !previouslyCreatedIds.has(a.id))\n ] \n\n // * updated *\n // - drop updates on deleted annotations\n // - merge any updates that override previous ones\n // - append new updates, but remove any that were merged\n const updated = [\n ...(changes.updated || [])\n .filter(({ newValue }) => !deletedIds.has(newValue.id))\n .map(update => {\n const { oldValue, newValue } = update;\n if (updatedIds.has(newValue.id)) {\n const updated = toMerge.updated!.find(u => u.oldValue.id === newValue.id)!.newValue;\n return diffAnnotations(oldValue, updated);\n } else {\n return update;\n }\n }),\n ...(toMerge.updated || []).filter(({ oldValue }) => !mergeableUpdates.has(oldValue.id))\n ]\n\n return { created, deleted, updated };\n}\n","import { v4 as uuidv4 } from 'uuid';\nimport type { Annotation } from '../model';\nimport { diffAnnotations } from '../utils';\nimport { Origin, shouldNotify, type Update, type ChangeSet } from './StoreObserver';\nimport type { StoreObserver, StoreChangeEvent, StoreObserveOptions } from './StoreObserver';\n\n// Shorthand\ntype AnnotationBodyIdentifier = { id: string, annotation: string }; \n\nconst sanitize = <T extends Annotation>(a: Partial<T>): T => {\n const id = a.id === undefined ? uuidv4() : a.id;\n\n return {\n ...a,\n id,\n bodies: a.bodies === undefined ? [] : a.bodies.map(b => ({\n ...b,\n annotation: id \n })),\n target: {\n ...a.target,\n annotation: id\n }\n } as T;\n}\n\nexport type Store<T extends Annotation> = ReturnType<typeof createStore<T>>;\n\nconst isAnnotation = <T extends Annotation>(arg: any): arg is T => arg.id !== undefined;\n\nexport const createStore = <T extends Annotation>() => {\n\n const annotationIndex = new Map<string, T>();\n\n const bodyIndex = new Map<string, string>();\n\n const observers: StoreObserver<T>[] = [];\n\n const observe = (onChange: { (event: StoreChangeEvent<T>): void }, options: StoreObserveOptions = {}) => {\n observers.push({ onChange, options });\n }\n\n const unobserve = (onChange: { (event: StoreChangeEvent<T>): void }) => {\n const idx = observers.findIndex(observer => observer.onChange == onChange);\n if (idx > -1)\n observers.splice(idx, 1);\n }\n\n const emit = (origin: Origin, changes: ChangeSet<T>) => {\n const event: StoreChangeEvent<T> = {\n origin,\n changes: {\n created: changes.created || [],\n updated: changes.updated || [],\n deleted: changes.deleted || []\n },\n state: [...annotationIndex.values()]\n };\n\n observers.forEach(observer => {\n if (shouldNotify(observer, event))\n observer.onChange(event);\n });\n }\n\n const addAnnotation = (annotation: Partial<T>, origin = Origin.LOCAL) => {\n const existing = annotation.id && annotationIndex.get(annotation.id);\n\n if (existing) {\n throw Error(`Cannot add annotation ${annotation.id} - exists already`);\n } else {\n const sanitized = sanitize(annotation);\n\n annotationIndex.set(sanitized.id, sanitized);\n sanitized.bodies.forEach(b => bodyIndex.set(b.id, sanitized.id));\n emit(origin, { created: [sanitized] });\n }\n }\n\n const updateOneAnnotation = (arg1: string | Partial<T>, arg2?: Partial<T> | Origin) => {\n const updated: T = typeof arg1 === 'string' ? sanitize(arg2 as Partial<T>) : sanitize(arg1);\n\n const oldId: string | undefined = typeof arg1 === 'string' ? arg1 : arg1.id;\n const oldValue = oldId && annotationIndex.get(oldId);\n\n if (oldValue) {\n const update: Update<T> = diffAnnotations(oldValue, updated);\n\n if (oldId === updated.id) {\n annotationIndex.set(oldId, updated);\n } else {\n annotationIndex.delete(oldId);\n annotationIndex.set(updated.id, updated);\n }\n\n oldValue.bodies.forEach(b => bodyIndex.delete(b.id));\n updated.bodies.forEach(b => bodyIndex.set(b.id, updated.id));\n\n return update;\n } else {\n console.warn(`Cannot update annotation ${oldId} - does not exist`);\n }\n }\n \n const updateAnnotation = (arg1: string | T, arg2: T | Origin = Origin.LOCAL, arg3 = Origin.LOCAL) => {\n const origin: Origin = isAnnotation(arg2) ? arg3 : arg2;\n\n const update = updateOneAnnotation(arg1, arg2);\n if (update)\n emit(origin, { updated: [update] })\n }\n\n const bulkUpdateAnnotation = (annotations: T[], origin = Origin.LOCAL) => {\n const updated = annotations.reduce((updated, annotation) => {\n const u = updateOneAnnotation(annotation);\n return u ? [...updated, u] : updated;\n }, [] as Update<T>[]);\n\n if (updated.length > 0)\n emit(origin, { updated });\n }\n\n const addBody = (body: T['bodies'][number], origin = Origin.LOCAL) => {\n const oldValue = annotationIndex.get(body.annotation);\n if (oldValue) {\n const newValue = { \n ...oldValue,\n bodies: [ ...oldValue.bodies, body ]\n };\n\n annotationIndex.set(oldValue.id, newValue);\n\n bodyIndex.set(body.id, newValue.id);\n\n const update: Update<T> = {\n oldValue, newValue, bodiesCreated: [ body ]\n };\n\n emit(origin, { updated: [update] });\n } else {\n console.warn(`Attempt to add body to missing annotation: ${body.annotation}`);\n }\n }\n\n const all = () => [...annotationIndex.values()];\n\n const clear = (origin = Origin.LOCAL) => { \n const all = [...annotationIndex.values()];\n\n annotationIndex.clear();\n bodyIndex.clear();\n\n emit(origin, { deleted: all });\n }\n\n const bulkAddAnnotation = (annotations: Partial<T>[], replace = true, origin = Origin.LOCAL) => {\n const sanitized = annotations.map(sanitize);\n\n if (replace) {\n // Delete existing first\n const deleted = [...annotationIndex.values()];\n annotationIndex.clear();\n bodyIndex.clear();\n\n sanitized.forEach(annotation => {\n annotationIndex.set(annotation.id, annotation);\n annotation.bodies.forEach(b => bodyIndex.set(b.id, annotation.id));\n });\n\n emit(origin, { created: sanitized, deleted });\n } else {\n // Don't allow overwriting of existing annotations\n const existing = annotations.reduce((all, next) => {\n const existing = next.id && annotationIndex.get(next.id);\n return existing ? [...all, existing ] : all;\n }, [] as T[]);\n\n if (existing.length > 0)\n throw Error(`Bulk insert would overwrite the following annotations: ${existing.map(a => a.id).join(', ')}`);\n\n sanitized.forEach(annotation => {\n annotationIndex.set(annotation.id, annotation);\n annotation.bodies.forEach(b => bodyIndex.set(b.id, annotation.id));\n });\n\n emit(origin, { created: sanitized });\n }\n }\n\n const deleteOneAnnotation = (annotationOrId: T | string) => {\n const id = typeof annotationOrId === 'string' ? annotationOrId : annotationOrId.id;\n\n const existing = annotationIndex.get(id);\n if (existing) {\n annotationIndex.delete(id);\n existing.bodies.forEach(b => bodyIndex.delete(b.id));\n return existing;\n } else {\n console.warn(`Attempt to delete missing annotation: ${id}`);\n }\n }\n\n const deleteAnnotation = (annotationOrId: T | string, origin = Origin.LOCAL) => {\n const deleted = deleteOneAnnotation(annotationOrId);\n if (deleted)\n emit(origin, { deleted: [ deleted ]});\n }\n\n const bulkDeleteAnnotation = (annotationsOrIds: (T | string)[], origin = Origin.LOCAL) => {\n const deleted = annotationsOrIds.reduce((deleted, arg) => {\n const existing = deleteOneAnnotation(arg);\n return existing ? [...deleted, existing] : deleted;\n }, [] as T[]);\n\n if (deleted.length > 0)\n emit(origin, { deleted });\n }\n\n const deleteOneBody = (body: AnnotationBodyIdentifier) => {\n const oldAnnotation = annotationIndex.get(body.annotation);\n\n if (oldAnnotation) {\n const oldBody = oldAnnotation.bodies.find(b => b.id === body.id);\n\n if (oldBody) {\n bodyIndex.delete(oldBody.id);\n\n const newAnnotation = {\n ...oldAnnotation,\n bodies: oldAnnotation.bodies.filter(b => b.id !== body.id)\n };\n\n annotationIndex.set(oldAnnotation.id, newAnnotation);\n\n const update: Update<T> = {\n oldValue: oldAnnotation, newValue: newAnnotation, bodiesDeleted: [oldBody]\n };\n\n return update;\n } else {\n console.warn(`Attempt to delete missing body ${body.id} from annotation ${body.annotation}`);\n }\n } else {\n console.warn(`Attempt to delete body from missing annotation ${body.annotation}`);\n }\n }\n \n const deleteBody = (body: AnnotationBodyIdentifier, origin = Origin.LOCAL) => {\n const updated = deleteOneBody(body);\n if (updated)\n emit(origin, { updated: [ updated ]});\n }\n\n const bulkDeleteBodies = (bodies: AnnotationBodyIdentifier[], origin = Origin.LOCAL) => {\n const updated = bodies\n .map(b => deleteOneBody(b)!)\n .filter(Boolean);\n\n if (updated.length > 0)\n emit(origin, { updated });\n }\n\n const getAnnotation = (id: string): T | undefined => {\n const a = annotationIndex.get(id);\n return a ? {...a} : undefined;\n }\n\n const getBody = (id: string): T['bodies'][number] | undefined => {\n const annotationId = bodyIndex.get(id);\n if (annotationId) {\n const annotation = getAnnotation(annotationId);\n const body = annotation!.bodies.find(b => b.id === id);\n if (body) {\n return body;\n } else {\n console.error(`Store integrity error: body ${id} in index, but not in annotation`);\n }\n } else {\n console.warn(`Attempt to retrieve missing body: ${id}`);\n }\n }\n\n const updateOneBody = (oldBodyId: AnnotationBodyIdentifier, newBody: T['bodies'][number]) => {\n if (oldBodyId.annotation !== newBody.annotation)\n throw 'Annotation integrity violation: annotation ID must be the same when updating bodies';\n\n const oldAnnotation = annotationIndex.get(oldBodyId.annotation);\n if (oldAnnotation) {\n const oldBody = oldAnnotation.bodies.find(b => b.id === oldBodyId.id)!;\n\n const newAnnotation = { \n ...oldAnnotation,\n bodies: oldAnnotation.bodies.map(b => b.id === oldBody.id ? newBody : b)\n };\n\n annotationIndex.set(oldAnnotation.id, newAnnotation);\n\n if (oldBody.id !== newBody.id) {\n bodyIndex.delete(oldBody.id);\n bodyIndex.set(newBody.id, newAnnotation.id);\n }\n\n return {\n oldValue: oldAnnotation, \n newValue: newAnnotation,\n bodiesUpdated: [{ oldBody, newBody }]\n }\n } else {\n console.warn(`Attempt to add body to missing annotation ${oldBodyId.annotation}`);\n }\n }\n\n const updateBody = (oldBodyId: AnnotationBodyIdentifier, newBody: T['bodies'][number], origin = Origin.LOCAL) => {\n const update = updateOneBody(oldBodyId, newBody);\n if (update)\n emit(origin, { updated: [ update ]} );\n }\n\n const bulkUpdateBodies = (bodies: Array<T['bodies'][number]>, origin = Origin.LOCAL) => {\n const updated = bodies\n .map(b => updateOneBody({ id: b.id, annotation: b.annotation }, b)!)\n .filter(Boolean);\n\n emit(origin, { updated });\n }\n\n const updateOneTarget = (target: T['target']): Update<T> | undefined => {\n const oldValue = annotationIndex.get(target.annotation);\n \n if (oldValue) {\n const newValue = { \n ...oldValue, \n target: {\n ...oldValue.target,\n ...target \n }\n };\n\n annotationIndex.set(oldValue.id, newValue);\n\n return {\n oldValue, newValue, targetUpdated: { \n oldTarget: oldValue.target,\n newTarget: target\n }\n };\n } else {\n console.warn(`Attempt to update target on missing annotation: ${target.annotation}`);\n }\n }\n\n const updateTarget = (target: T['target'], origin = Origin.LOCAL) => {\n const update = updateOneTarget(target);\n if (update)\n emit(origin, { updated: [ update ]} );\n }\n\n const bulkUpdateTargets = (targets: Array<T['target']>, origin = Origin.LOCAL) => {\n const updated = \n targets.map(t => updateOneTarget(t)!).filter(Boolean);\n if (updated.length > 0)\n emit(origin, { updated });\n }\n\n\treturn {\n addAnnotation,\n addBody,\n all,\n bulkAddAnnotation,\n bulkDeleteAnnotation,\n bulkDeleteBodies,\n bulkUpdateAnnotation,\n bulkUpdateBodies,\n bulkUpdateTargets,\n clear,\n deleteAnnotation,\n deleteBody,\n getAnnotation,\n getBody,\n observe,\n unobserve,\n updateAnnotation,\n updateBody,\n updateTarget\n\t};\n\n}\n","import type { Annotation, Annotator, AnnotatorState } from '../model';\nimport type { Store } from './Store';\nimport type { StoreChangeEvent } from './StoreObserver';\n\ntype Subscriber<T extends Annotation> = (annotation: T[]) => void; \n\nexport interface SvelteStore<T extends Annotation> extends Store<T> {\n\n subscribe(onChange: Subscriber<T>): void;\n\n}\n\nexport interface SvelteAnnotatorState<I extends Annotation, E extends unknown> extends AnnotatorState<I, E> {\n\n store: SvelteStore<I>\n\n}\n\nexport interface SvelteAnnotator<I extends Annotation, E extends unknown> extends Annotator<I, E> {\n\n state: SvelteAnnotatorState<I, E>\n\n}\n\n/** \n * A simple wrapper around the event-based store implementation\n * that adds a Svelte shim, for use with the reactive '$' notation.\n * Other frameworks might not actually need this. But it's pretty\n * convenient for everyone using Svelte, as well as for the\n * basic (Svelte-based) Annotorious standard implementation.\n */\nexport const toSvelteStore = <T extends Annotation = Annotation>(store: Store<T>): SvelteStore<T> => {\n\n const subscribe = (onChange: Subscriber<T>) => {\n\n // Register a store observer on behalf of the subscriber\n const shim = (event: StoreChangeEvent<T>) => onChange(event.state);\n store.observe(shim);\n\n // Immediately call the subscriber function with the\n // current store value, according to the Svelte contract.\n // https://stackoverflow.com/questions/68220955/how-does-svelte-unsubscribe-actually-work\n onChange(store.all());\n\n // Return the unsubscribe function\n return () => store.unobserve(shim);\n }\n\n return {\n ...store,\n subscribe\n }\n\n}","export let createNanoEvents = () => ({\n emit(event, ...args) {\n for (\n let callbacks = this.events[event] || [],\n i = 0,\n length = callbacks.length;\n i < length;\n i++\n ) {\n callbacks[i](...args)\n }\n },\n events: {},\n on(event, cb) {\n ;(this.events[event] ||= []).push(cb)\n return () => {\n this.events[event] = this.events[event]?.filter(i => cb !== i)\n }\n }\n})\n","import { createNanoEvents, type Unsubscribe } from 'nanoevents';\nimport type { Annotation } from '../model';\nimport type { Store } from './Store';\nimport { Origin } from './StoreObserver';\nimport { mergeChanges, type ChangeSet, type StoreChangeEvent, type Update } from './StoreObserver';\n\n// Duration with fast successive changes get merged \n// with the last event in the stack, rather than getting stacked\n// as a new undo/redo step.\nconst DEBOUNCE = 250;\n\nexport interface UndoStack <T extends Annotation> {\n\n canRedo(): boolean;\n\n canUndo(): boolean;\n\n destroy(): void;\n\n getHistory(): History<T>;\n\n on<E extends keyof UndoStackEvents<T>>(event: E, callback: UndoStackEvents<T>[E]): Unsubscribe;\n\n undo(): void;\n\n redo(): void;\n\n}\n\nexport interface UndoStackEvents <T extends Annotation> {\n\n redo(change: ChangeSet<T>): void;\n\n undo(change: ChangeSet<T>): void;\n\n}\n\nexport interface History <T extends Annotation> {\n\n changes: ChangeSet<T>[];\n \n pointer: number;\n\n}\n\nexport const createUndoStack = <T extends Annotation>(store: Store<T>, history?: History<T>): UndoStack<T> => {\n\n const emitter = createNanoEvents<UndoStackEvents<T>>();\n\n const changeStack: ChangeSet<T>[] = history?.changes || [];\n\n let pointer = history ? history.pointer : - 1;\n\n let muteEvents = false;\n\n let lastEvent = 0;\n\n const onChange = (event: StoreChangeEvent<T>) => {\n if (!muteEvents) {\n const { changes } = event;\n\n const now = performance.now();\n\n if (now - lastEvent > DEBOUNCE) {\n // Put this change on the stack...\n changeStack.splice(pointer + 1);\n changeStack.push(changes);\n\n // ...and update the pointer\n pointer = changeStack.length - 1;\n } else {\n // Merge this change with the last in the stack\n const last = changeStack.length - 1;\n changeStack[last] = mergeChanges(changeStack[last], changes);\n }\n\n lastEvent = now;\n }\n\n muteEvents = false;\n }\n\n store.observe(onChange, { origin: Origin.LOCAL });\n\n const undoCreated = (created?: T[]) =>\n created && created.length > 0 && store.bulkDeleteAnnotation(created);\n\n const redoCreated = (created?: T[]) =>\n created && created.length > 0 && store.bulkAddAnnotation(created, false);\n\n const undoUpdated = (updated?: Update<T>[]) =>\n updated && updated.length > 0 && store.bulkUpdateAnnotation(updated.map(({ oldValue }) => oldValue));\n \n const redoUpdated = (updated?: Update<T>[]) =>\n updated && updated.length > 0 && store.bulkUpdateAnnotation(updated.map(({ newValue }) => newValue));\n\n const undoDeleted = (deleted?: T[]) => \n deleted && deleted.length > 0 && store.bulkAddAnnotation(deleted, false);\n\n const redoDeleted = (deleted?: T[]) =>\n deleted && deleted.length > 0 && store.bulkDeleteAnnotation(deleted);\n\n const undo = () => {\n if (pointer > -1) {\n muteEvents = true;\n\n const { created, updated, deleted } = changeStack[pointer];\n\n undoCreated(created);\n undoUpdated(updated);\n undoDeleted(deleted);\n\n emitter.emit('undo', changeStack[pointer]);\n\n pointer -= 1;\n }\n }\n\n const canUndo = () => pointer > -1;\n\n const redo = () => {\n if (changeStack.length - 1 > pointer) {\n muteEvents = true;\n\n const { created, updated, deleted } = changeStack[pointer + 1];\n\n redoCreated(created);\n redoUpdated(updated);\n redoDeleted(deleted);\n\n emitter.emit('redo', changeStack[pointer + 1]);\n\n pointer += 1;\n }\n }\n\n const canRedo = () => changeStack.length - 1 > pointer;\n\n const destroy = () => store.unobserve(onChange);\n\n const getHistory = () => ({ changes: [...changeStack], pointer });\n\n const on = <E extends keyof UndoStackEvents<T>>(event: E, callback: UndoStackEvents<T>[E]) => \n emitter.on(event, callback);\n\n return {\n canRedo,\n canUndo,\n destroy,\n getHistory,\n on,\n redo,\n undo\n }\n\n}","import { writable } from 'svelte/store';\n\nexport type ViewportState = ReturnType<typeof createViewportState>;\n\nexport const createViewportState = () => {\n\n const { subscribe, set } = writable<string[]>([]);\n\n return { \n subscribe, \n set\n };\n\n}\n","import { dequal } from 'dequal/lite';\nimport type { Annotation, AnnotatorState, FormatAdapter } from '../model';\nimport { Origin } from '../state';\nimport type { ChangeSet, SelectionState, UndoStack } from '../state';\nimport type { LifecycleEvents } from './LifecycleEvents';\n\nexport type Lifecycle<I extends Annotation, E extends unknown> = \n ReturnType<typeof createLifecycleObserver<I, E>>;\n\nexport const createLifecycleObserver = <I extends Annotation, E extends unknown>(\n state: AnnotatorState<I, E>,\n undoStack: UndoStack<I>,\n adapter?: FormatAdapter<I, E>,\n autoSave?: boolean\n) => {\n const { hover, selection, store, viewport } = state;\n\n const observers: Map<keyof LifecycleEvents, Function[]> = new Map();\n\n // The currently selected annotations, in the state when they were selected \n let initialSelection: I[] = [];\n\n let currentHover: string | undefined;\n\n let idleTimeout: ReturnType<typeof setTimeout>;\n\n const on = <T extends keyof LifecycleEvents>(event: T, callback: LifecycleEvents<E>[T]) => {\n if (observers.has(event)) {\n observers.get(event)!.push(callback);\n } else {\n observers.set(event, [callback]);\n }\n }\n\n const off = <T extends keyof LifecycleEvents<E>>(event: T, callback: LifecycleEvents<E>[T]) => {\n const callbacks = observers.get(event);\n if (callbacks) {\n const idx = callbacks.indexOf(callback);\n if (idx !== -1)\n callbacks.splice(idx, 1);\n }\n }\n\n const emit = (event: keyof LifecycleEvents<E>, arg0: I | I[], arg1?: I | PointerEvent) => {\n if (observers.has(event)) {\n setTimeout(() => {\n observers.get(event)!.forEach(callback => { \n if (adapter) {\n const serialized0 = Array.isArray(arg0) ? \n arg0.map(a => adapter.serialize(a)) : adapter.serialize(arg0);\n \n const serialized1: E | PointerEvent | undefined =\n arg1 ? arg1 instanceof PointerEvent ? arg1 : adapter.serialize(arg1) : undefined;\n\n callback(serialized0 as E & E[], serialized1); \n } else {\n callback(arg0 as E & E[], arg1 as unknown as E); \n }\n });\n }, 1);\n }\n }\n\n const onIdleUpdate = () => {\n const { selected } = selection;\n\n // User idle after activity - fire update events for selected\n // annotations that changed\n const updatedSelected = (selected || []).map(({ id }) => store.getAnnotation(id)!);\n\n updatedSelected.forEach(updated => {\n const initial = initialSelection.find(a => a.id === updated.id);\n if (!initial || !dequal(initial, updated)) {\n emit('updateAnnotation', updated, initial);\n }\n });\n\n initialSelection = initialSelection.map(initial => {\n const updated = updatedSelected.find(({ id }) => id === initial.id);\n return updated ? updated : initial\n });\n }\n\n selection.subscribe(({ selected })=> {\n if (initialSelection.length === 0 && selected.length === 0)\n return;\n\n if (initialSelection.length === 0 && selected.length > 0) {\n // A new selection was made - store the editable annotation as initial state\n initialSelection = selected.map(({ id }) => store.getAnnotation(id)!);\n } else if (initialSelection.length > 0 && selected.length === 0) {\n // Deselect!\n initialSelection.forEach(initial => {\n const updatedState = store.getAnnotation(initial.id); \n \n if (updatedState && !dequal(updatedState, initial)) {\n emit('updateAnnotation', updatedState, initial);\n }\n });\n\n initialSelection = [];\n } else {\n // Changed selection\n const initialIds = new Set(initialSelection.map(a => a.id));\n const selectedIds = new Set(selected.map(({ id }) => id));\n\n // Fire update events for deselected annotations that have changed\n const deselected = initialSelection.filter(a => !selectedIds.has(a.id));\n deselected.forEach(initial => {\n const updatedState = store.getAnnotation(initial.id);\n\n if (updatedState && !dequal(updatedState, initial))\n emit('updateAnnotation', updatedState, initial);\n });\n\n initialSelection = [\n // Remove annotations that were deselected\n ...initialSelection.filter(a => selectedIds.has(a.id)),\n // Add editable annotations that were selected\n ...selected\n .filter(({ id }) => !initialIds.has(id))\n .map(({ id }) => store.getAnnotation(id)!)\n ];\n }\n\n emit('selectionChanged', initialSelection);\n });\n\n hover.subscribe(id => {\n if (!currentHover && id) {\n emit('mouseEnterAnnotation', store.getAnnotation(id)!);\n } else if (currentHover && !id) {\n emit('mouseLeaveAnnotation', store.getAnnotation(currentHover)!);\n } else if (currentHover && id) {\n emit('mouseLeaveAnnotation', store.getAnnotation(currentHover)!);\n emit('mouseEnterAnnotation', store.getAnnotation(id)!);\n }\n\n currentHover = id;\n });\n\n viewport?.subscribe(ids => \n emit('viewportIntersect', ids.map(id => store.getAnnotation(id)!)));\n\n store.observe(event => {\n // autoSave option triggers update events on idleness\n if (autoSave) {\n if (idleTimeout)\n clearTimeout(idleTimeout);\n\n idleTimeout = setTimeout(onIdleUpdate, 1000);\n }\n\n // Local CREATE and DELETE events are applied immediately\n const { created, deleted } = event.changes;\n (created || []).forEach(a => emit('createAnnotation', a));\n (deleted || []).forEach(a => emit('deleteAnnotation', a));\n\n // Updates are only applied immediately if they involve body changes\n const updatesWithBody = (event.changes.updated || []).filter(u => [\n ...(u.bodiesCreated || []),\n ...(u.bodiesDeleted || []),\n ...(u.bodiesUpdated || [])\n ].length > 0);\n\n // Emit an update with the new annototation and the stored initial state\n updatesWithBody.forEach(({ oldValue, newValue }) => {\n const initial = initialSelection.find(a => a.id === oldValue.id) || oldValue;\n\n // Record the update as the new last known state\n initialSelection = initialSelection\n .map(a => a.id === oldValue.id ? newValue : a);\n\n emit('updateAnnotation', newValue, initial);\n });\n }, { origin: Origin.LOCAL });\n\n // Track remote changes - these should update the initial state\n store.observe(event => {\n if (initialSelection) {\n const selectedIds = new Set(initialSelection.map(a => a.id));\n\n const relevantUpdates = (event.changes.updated || [])\n .filter(({ newValue }) => selectedIds.has(newValue.id))\n .map(({ newValue }) => newValue);\n\n if (relevantUpdates.length > 0) {\n initialSelection = initialSelection.map(selected => {\n const updated = relevantUpdates.find(updated => updated.id === selected.id);\n return updated ? updated : selected;\n })\n }\n }\n }, { origin: Origin.REMOTE });\n\n const onUndoOrRedo = (undo: boolean) => (changes: ChangeSet<I>) => {\n // Undo/redo of created/delete will cause lifecycle events automatically,\n // but we need to handle updates specifically!\n const { updated } = changes;\n\n if (undo)\n (updated || []).forEach(t => emit('updateAnnotation', t.oldValue, t.newValue));\n else\n (updated || []).forEach(t => emit('updateAnnotation', t.newValue, t.oldValue));\n }\n\n undoStack.on('undo', onUndoOrRedo(true));\n undoStack.on('redo', onUndoOrRedo(false));\n\n return { on, off, emit }\n\n}\n","import type { Annotation } from './Annotation';\n\nexport interface FormatAdapter<A extends Annotation, T extends unknown> {\n\n parse(serialized: T): ParseResult<A>;\n\n parseAll?(serialized: unknown[]): { parsed: A[], failed: T[] };\n\n serialize(core: A): T;\n\n}\n\nexport interface ParseResult<A extends Annotation> {\n\n parsed?: A;\n \n error?: Error;\n\n}\n\nexport const serializeAll = \n <A extends Annotation, T extends unknown>(adapter: FormatAdapter<A, T>) =>\n (annotations: A[]) => annotations.map(a => adapter.serialize(a));\n\nexport const parseAll = \n <A extends Annotation, T extends unknown>(adapter: FormatAdapter<A, T>) =>\n (serialized: T[]) => serialized.reduce((result, next) => {\n const { parsed, error } = adapter.parse(next);\n \n return error ? {\n parsed: result.parsed,\n failed: [...result.failed, next ]\n } : parsed ? {\n parsed: [...result.parsed, parsed ],\n failed: result.failed\n } : {\n ...result\n }\n }, { parsed: [] as A[], failed: [] as T[]});\n ","import type { Annotation } from './Annotation';\nimport type { User } from './User';\nimport type { PresenceProvider } from '../presence';\nimport type {\n History,\n HoverState,\n SelectionState,\n Store,\n UndoStack,\n UserSelectActionExpression,\n ViewportState\n} from '../state';\nimport { Origin } from '../state';\nimport type { LifecycleEvents } from '../lifecycle';\nimport { reviveDates } from '../utils';\nimport { type FormatAdapter, parseAll } from './FormatAdapter';\nimport type { DrawingStyleExpression } from './DrawingStyle';\nimport type { Filter } from './Filter';\n\n/**\n * Base annotator interface\n * @template I - internal core data model\n * @template E - external adapted representation\n */\nexport interface Annotator<I extends Annotation = Annotation, E extends unknown = Annotation> {\n\n addAnnotation(annotation: Partial<E>): void;\n\n cancelSelected(): void;\n\n canRedo(): boolean;\n\n canUndo(): boolean;\n\n clearAnnotations(): void;\n\n destroy(): void;\n\n getAnnotationById(id: string): E | undefined;\n\n getAnnotations(): E[];\n\n getHistory(): History<I>;\n\n getSelected(): E[];\n\n getUser(): User;\n\n loadAnnotations(url: string, replace?: boolean): Promise<E[]>;\n\n redo(): void;\n\n removeAnnotation(arg: Partial<E> | string): E | undefined;\n\n setAnnotations(annotations: Partial<E>[], replace?: boolean): void;\n\n setFilter(filter: Filter<I> | undefined): void;\n\n setPresenceProvider?(provider: PresenceProvider): void;\n\n setSelected(arg?: string | string[], editable?: boolean): void;\n\n setStyle(style: DrawingStyleExpression<I> | undefined): void;\n\n setUser(user: User): void;\n\n setUserSelectAction(action: UserSelectActionExpression<E>): void;\n\n setVisible(visible: boolean): void;\n\n undo(): void;\n\n updateAnnotation(annotation: Partial<E>): E;\n \n on<T extends keyof LifecycleEvents<E>>(event: T, callback: LifecycleEvents<E>[T]): void;\n\n off<T extends keyof LifecycleEvents<E>>(event: T, callback: LifecycleEvents<E>[T]): void;\n\n state: AnnotatorState<I, E>;\n\n}\n\nexport interface AnnotatorState<I extends Annotation, E extends unknown> {\n\n store: Store<I>;\n\n selection: SelectionState<I, E>;\n\n hover: HoverState<I>;\n\n viewport: ViewportState;\n\n}\n\nexport const createBaseAnnotator = <I extends Annotation, E extends unknown>(\n state: AnnotatorState<I, E>, \n undoStack: UndoStack<I>,\n adapter?: FormatAdapter<I, E>\n) => {\n\n const { store, selection } = state;\n\n const addAnnotation = (annotation: E) => {\n if (adapter) {\n const { parsed, error } = adapter.parse(annotation);\n if (parsed) {\n store.addAnnotation(parsed, Origin.REMOTE);\n } else {\n console.error(error);\n }\n } else {\n store.addAnnotation(reviveDates<I>(annotation), Origin.REMOTE);\n }\n }\n\n const cancelSelected = () => selection.clear();\n\n const clearAnnotations = () => store.clear();\n\n const getAnnotationById = (id: string): E | undefined => {\n const annotation = store.getAnnotation(id);\n return (adapter && annotation) ?\n adapter.serialize(annotation) as E : annotation as unknown as E;\n }\n\n const getAnnotations = () =>\n (adapter ? store.all().map(adapter.serialize) : store.all()) as E[];\n\n const getSelected = () => {\n const selectedIds = selection.selected?.map(s => s.id) || [];\n\n const selected = selectedIds.map(id => store.getAnnotation(id)!).filter(Boolean);\n\n return adapter \n ? selected.map(adapter.serialize) \n : selected as unknown as E[];\n }\n\n const loadAnnotations = (url: string, replace = true) =>\n fetch(url)\n .then((response) => response.json())\n .then((annotations) => {\n setAnnotations(annotations, replace);\n return annotations;\n });\n\n const removeAnnotation = (arg: E | string): E | undefined => {\n if (typeof arg === 'string') {\n const annotation = store.getAnnotation(arg);\n store.deleteAnnotation(arg);\n\n if (annotation)\n return adapter ? adapter.serialize(annotation) : annotation as unknown as E;\n } else {\n const annotation = adapter ? adapter.parse(arg).parsed : (arg as unknown as I);\n\n if (annotation) {\n store.deleteAnnotation(annotation);\n return arg;\n }\n }\n }\n\n const setAnnotations = (annotations: E[], replace = true) => {\n if (adapter) {\n const parseFn = adapter.parseAll || parseAll(adapter);\n const { parsed, failed } = parseFn(annotations);\n\n if (failed.length > 0)\n console.warn(`Discarded ${failed.length} invalid annotations`, failed);\n\n store.bulkAddAnnotation(parsed, replace, Origin.REMOTE);\n } else {\n store.bulkAddAnnotation(annotations.map(reviveDates<I>), replace, Origin.REMOTE);\n }\n }\n\n const setSelected = (arg?: string | string[], editable?: boolean) => {\n if (arg) {\n selection.setSelected(arg, editable);\n } else {\n selection.clear();\n }\n }\n\n const setUserSelectAction = (action: UserSelectActionExpression<E>) => {\n selection.clear();\n selection.setUserSelectAction(action);\n }\n\n const updateAnnotation = (updated: E): E => {\n if (adapter) {\n const crosswalked = adapter.parse(updated).parsed!;\n const previous = adapter.serialize(store.getAnnotation(crosswalked.id)!);\n store.updateAnnotation(crosswalked);\n return previous;\n } else {\n const previous = store.getAnnotation((updated as unknown as I).id);\n store.updateAnnotation(reviveDates<I>(updated));\n return previous as unknown as E;\n }\n }\n\n // Note that we don't spread the undoStack - it has a .destroy()\n // method that would likely get overwritten by other Annotator implementations\n // if people are not careful.\n return { \n addAnnotation,\n cancelSelected,\n canRedo: undoStack.canRedo,\n canUndo: undoStack.canUndo,\n clearAnnotations,\n getAnnotationById,\n getAnnotations,\n getHistory: undoStack.getHistory,\n getSelected,\n loadAnnotations,\n redo: undoStack.redo,\n removeAnnotation,\n setAnnotations,\n setSelected,\n setUserSelectAction,\n undo: undoStack.undo,\n updateAnnotation\n }\n\n}\n","import type { Annotation } from \"./Annotation\";\nimport type { AnnotationState } from \"./AnnotationState\";\n\ntype RGB = `rgb(${number}, ${number}, ${number})`;\n\ntype RGBA = `rgba(${number}, ${number}, ${number}, ${number})`;\n\ntype HEX = `#${string}`;\n\nexport type Color = RGB | RGBA | HEX;\n\nexport interface DrawingStyle {\n\n fill?: Color;\n\n fillOpacity?: number;\n\n stroke?: Color;\n\n strokeOpacity?: number;\n\n strokeWidth?: number;\n\n}\n\nexport type DrawingStyleExpression<T extends Annotation = Annotation> =\n DrawingStyle | ((annotation: T, state?: AnnotationState) => DrawingStyle | undefined);\n\n/** Utility functions **/\n\nexport const computeStyle = <T extends Annotation = Annotation>(\n annotation: T,\n style: DrawingStyleExpression<T>,\n state?: AnnotationState\n) => {\n return typeof style === 'function' ? style(annotation, state) : style;\n};\n\nexport const chainStyles = <T extends Annotation = Annotation>(\n applyFirst: DrawingStyleExpression<T>,\n applySecond: DrawingStyleExpression<T>\n) => {\n if (typeof applyFirst !== 'function' && typeof applySecond !== 'function') {\n // Simple case: just two objects\n return {\n ...(applyFirst || {}),\n ...(applySecond || {})\n };\n } else {\n // Return a function\n return (a: T, state: AnnotationState) => {\n const first = typeof applyFirst === 'function' ? applyFirst(a, state) : applyFirst;\n const second = typeof applySecond === 'function' ? applySecond(a, state) : applySecond;\n\n return {\n ...(first || {}),\n ...(second || {})\n }\n }\n }\n}\n \n","export const urlAlphabet =\n 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'\n","import { urlAlphabet as scopedUrlAlphabet } from './url-alphabet/index.js'\nexport { urlAlphabet } from './url-alphabet/index.js'\nexport let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\nexport let customRandom = (alphabet, defaultSize, getRandom) => {\n let mask = (2 << Math.log2(alphabet.length - 1)) - 1\n let step = -~((1.6 * mask * defaultSize) / alphabet.length)\n return (size = defaultSize) => {\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let j = step | 0\n while (j--) {\n id += alphabet[bytes[j] & mask] || ''\n if (id.length >= size) return id\n }\n }\n }\n}\nexport let customAlphabet = (alphabet, size = 21) =>\n customRandom(alphabet, size | 0, random)\nexport let nanoid = (size = 21) => {\n let id = ''\n let bytes = crypto.getRandomValues(new Uint8Array((size |= 0)))\n while (size--) {\n id += scopedUrlAlphabet[bytes[size] & 63]\n }\n return id\n}\n","import { customAlphabet } from 'nanoid';\n\nexport interface User {\n\n id: string;\n\n isGuest?: boolean;\n\n name?: string;\n\n avatar?: string;\n\n}\n\nexport const createAnonymousGuest = () => {\n const nanoid = customAlphabet('1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_', 20);\n \n return { isGuest: true, id: nanoid() }\n}","import type { AnnotationBody } from './Annotation';\n\nexport interface W3CAnnotation {\n\n '@context': 'http://www.w3.org/ns/anno.jsonld';\n\n type: 'Annotation';\n\n id: string;\n\n creator?: W3CUser;\n\n created?: string;\n\n modified?: string;\n\n body: W3CAnnotationBody | W3CAnnotationBody[];\n\n target: W3CAnnotationTarget | W3CAnnotationTarget[];\n\n [key: string]: any;\n\n}\n\nexport interface W3CUser {\n\n type?: string;\n\n id: string;\n\n name?: string;\n\n}\n\nexport interface W3CAnnotationBody {\n\n type?: string;\n\n id?: string;\n\n purpose?: string;\n\n value?: string;\n\n source?: string;\n\n creator?: W3CUser;\n\n created?: string;\n\n modified?: string;\n\n}\n\nexport interface W3CAnnotationTarget {\n\n id?: string;\n\n source: string;\n\n selector?: AbstractW3CSelector;\n\n}\n\nexport interface AbstractW3CSelector { }\n\n// https://stackoverflow.com/questions/6122571/simple-non-secure-hash-function-for-javascript\nconst hashCode = (obj: Object): string => {\n const str = JSON.stringify(obj);\n\n let hash = 0;\n\n for (let i = 0, len = str.length; i < len; i++) {\n let chr = str.charCodeAt(i);\n hash = (hash << 5) - hash + chr;\n hash |= 0; // Convert to 32bit integer\n }\n\n return `${hash}`;\n}\n\nexport const parseW3CUser = (user?: any) => user\n ? typeof user === 'object' ? { ...user } : user : undefined;\n\n/**\n * Helper to crosswalk the W3C annotation body to a list of core AnnotationBody objects.\n */\nexport const parseW3CBodies = (\n body: W3CAnnotationBody | W3CAnnotationBody[],\n annotationId: string\n) : AnnotationBody[] => (Array.isArray(body) ? body : [body]).map(body => {\n\n // Extract properties that conform to the internal model, but keep custom props\n const { id, type, purpose, value, created, modified, creator, ...rest } = body;\n\n // The internal model strictly requires IDs. (Because multi-user scenarios\n // will have problems without them.) In the W3C model, bodys *may* have IDs.\n // We'll create ad-hoc IDs for bodies without IDs, but want to make sure that\n // generating the ID is idempotent: the same body should always get the same ID.\n // This will avoid unexpected results when checking for equality. \n return {\n id: id || `temp-${hashCode(body)}`,\n annotation: annotationId,\n type,\n purpose,\n value,\n creator: parseW3CUser(creator),\n created: created ? new Date(created) : undefined,\n updated: modified ? new Date(modified) : undefined,\n ...rest\n }\n\n});\n\n/** Serialization helper to remove core-specific fields from the annotation body **/\nexport const serializeW3CBodies = (bodies: AnnotationBody[]): W3CAnnotationBody[] =>\n bodies.map(b => {\n const { annotation: _a, created, updated, ...bodyRest } = b;\n\n const w3cBody: W3CAnnotationBody = {\n ...bodyRest,\n created: created?.toISOString(),\n modified: updated?.toISOString()\n }\n if (w3cBody.id?.startsWith('temp-')) {\n delete w3cBody.id;\n }\n\n return w3cBody;\n });\n","// SEABORN_BRIGHT\nexport const DEFAULT_PALETTE: Palette = [\n '#ff7c00', // orange\n '#1ac938', // green\n '#e8000b', // red\n '#8b2be2', // purple\n '#9f4800', // brown\n '#f14cc1', // pink\n '#ffc400', // khaki\n '#00d7ff', // cyan\n '#023eff' // blue\n];\n\nexport type Palette = string[];","import type { User } from '../model/User';\nimport type { Appearance } from './Appearance';\nimport type { PresentUser } from './PresentUser';\nimport { DEFAULT_PALETTE } from './ColorPalette';\n\nexport interface AppearanceProvider {\n\n addUser(presenceKey: string, user: User): Appearance;\n\n removeUser(user: PresentUser): void;\n\n}\n\nexport const defaultColorProvider = () => {\n\n const unassignedColors = [...DEFAULT_PALETTE];\n\n const assignRandomColor = () => {\n const rnd = Math.floor(Math.random() * unassignedColors.length);\n const color = unassignedColors[rnd];\n\n unassignedColors.splice(rnd, 1);\n\n return color;\n }\n\n const releaseColor = (color: string) =>\n unassignedColors.push(color);\n\n return { assignRandomColor, releaseColor };\n\n}\n\nexport const createDefaultAppearanceProvider = () => {\n\n const colorProvider = defaultColorProvider();\n\n const addUser = (presenceKey: string, user: User): Appearance => {\n const color = colorProvider.assignRandomColor();\n\n return {\n label: user.name || user.id,\n avatar: user.avatar,\n color\n };\n }\n\n const removeUser = (user: PresentUser) =>\n colorProvider.releaseColor(user.appearance.color);\n\n return { addUser, removeUser }\n \n}","import { nanoid } from 'nanoid';\nimport { createNanoEvents, type Unsubscribe } from 'nanoevents';\nimport type { User } from '../model/User';\nimport type { PresentUser } from './PresentUser';\nimport type { PresenceEvents } from './PresenceEvents';\nimport { createDefaultAppearanceProvider } from './AppearanceProvider';\nimport type { AppearanceProvider } from './AppearanceProvider';\n\nexport interface PresenceState {\n\n // Get users currently present to this room\n getPresentUsers(): PresentUser[];\n\n // Notify of a given present user's activity on the given annotations\n notifyActivity(presenceKey: string, annotationIds: string[]): void;\n\n // Add a listener for the given presence event\n on<E extends keyof PresenceEvents>(event: E, callback: PresenceEvents[E]): Unsubscribe;\n\n // Initial sync - which users are present under which keys\n syncUsers(state: { presenceKey: string, user: User }[]): void;\n\n // Update the selection state for the given prresent user\n updateSelection(presenceKey: string, selection: string[] | null): void;\n\n}\n\nconst isListEqual = (listA: any[], listB: any[]) => \n listA.every(a => listA.includes(a)) && listB.every(b => listA.includes(b));\n\n// This client's presence key\nexport const PRESENCE_KEY = nanoid();\n\nexport const createPresenceState = (\n appearanceProvider: AppearanceProvider = createDefaultAppearanceProvider()\n): PresenceState => {\n\n const emitter = createNanoEvents<PresenceEvents>();\n\n const presentUsers = new Map<string, PresentUser>();\n\n const selectionStates = new Map<string, string[]>();\n\n const addUser = (presenceKey: string, user: User) => {\n if (presentUsers.has(presenceKey)) {\n console.warn('Attempt to add user that is already present', presenceKey, user);\n return; \n }\n\n const appearance = appearanceProvider.addUser(presenceKey, user);\n\n presentUsers.set(presenceKey, { \n ...user,\n presenceKey,\n appearance\n });\n }\n\n const removeUser = (presenceKey: string) => {\n const user = presentUsers.get(presenceKey);\n if (!user) {\n console.warn('Attempt to remove user that is not present', presenceKey);\n return;\n }\n\n appearanceProvider.removeUser(user);\n\n presentUsers.delete(presenceKey);\n }\n\n const syncUsers = (state: { presenceKey: string, user: User }[]) => {\n // const keys = new Set(others.map(s => s.presenceKey));\n const keys = new Set(state.map(s => s.presenceKey));\n\n // These users need to be added to the presentUsers list\n // const toAdd = others.filter(({ presenceKey }) => !presentUsers.has(presenceKey));\n const toAdd = state.filter(({ presenceKey }) => !presentUsers.has(presenceKey));\n\n // These users need to be dropped from the list\n const toRemove = Array.from(presentUsers.values()).filter(presentUser =>\n !keys.has(presentUser.presenceKey));\n\n toAdd.forEach(({ presenceKey, user }) => addUser(presenceKey, user));\n\n toRemove.forEach(user => {\n const { presenceKey } = user;\n\n // If this user has a selection, fire deselect event\n if (selectionStates.has(presenceKey))\n emitter.emit('selectionChange', user, null);\n\n removeUser(presenceKey)\n });\n\n if (toAdd.length > 0 || toRemove.length > 0)\n emitter.emit('presence', getPresentUsers());\n }\n\n const notifyActivity = (presenceKey: string, annotationIds: string[]) => { \n const user = presentUsers.get(presenceKey);\n \n if (!user) {\n console.warn('Activity notification from user that is not present');\n return;\n }\n\n const currentSelection = selectionStates.get(presenceKey);\n\n // Was there a selection change we might have missed?\n if (!currentSelection || !isListEqual(currentSelection, annotationIds)) {\n selectionStates.set(presenceKey, annotationIds);\n emitter.emit('selectionChange', user, annotationIds);\n }\n }\n\n const updateSelection = (presenceKey: string, selection: string[] | null) => {\n const from = presentUsers.get(presenceKey);\n if (!from) {\n console.warn('Selection change for user that is not present', presenceKey);\n return;\n }\n\n if (selection)\n selectionStates.set(presenceKey, selection);\n else \n selectionStates.delete(presenceKey);\n\n emitter.emit('selectionChange', from, selection);\n }\n\n const getPresentUsers = () =>\n [...Array.from(presentUsers.values())];\n \n const on = <E extends keyof PresenceEvents>(event: E, callback: PresenceEvents[E]) =>\n emitter.on(event, callback);\n\n return {\n getPresentUsers,\n notifyActivity,\n on,\n syncUsers,\n updateSelection\n }\n\n}"],"names":["has","dequal","foo","bar","ctor","len","noop","safe_not_equal","a","b","subscriber_queue","writable","value","start","stop","subscribers","set","new_value","run_queue","subscriber","i","update","fn","subscribe","run","invalidate","createHoverState","store","currentHover","updated","changes","oldValue","UserSelectAction","EMPTY","createSelectionState","defaultSelectionAction","adapter","currentUserSelectAction","currentSelection","clear","isEmpty","_a","isSelected","annotationOrId","id","userSelect","idOrIds","event","annotations","annotation","selected","sel","action","onUserSelect","setSelected","editable","ids","isEditable","removeFromSelection","setUserSelectAction","crosswalked","byteToHex","unsafeStringify","arr","offset","getRandomValues","rnds8","rng","randomUUID","native","v4","options","buf","rnds","getContributors","creator","updatedBy","bodyCollaborators","users","body","u","reviveDates","revive","revived","createBody","payload","created","uuidv4","getAddedBodies","newValue","oldBodyIds","getRemovedBodies","newBodyIds","getChangedBodies","newBody","oldBody","hasTargetChanged","diffAnnotations","bodiesCreated","bodiesDeleted","bodiesUpdated","Ignore","Origin","shouldNotify","observer","_b","origin","ignore","arg","hasBodyChanges","hasTargetChanges","affectedAnnotations","mergeChanges","toMerge","previouslyCreatedIds","previouslyUpdatedIds","createdIds","deletedIds","updatedIds","mergeableUpdates","deleted","sanitize","isAnnotation","createStore","annotationIndex","bodyIndex","observers","observe","onChange","unobserve","idx","emit","addAnnotation","sanitized","updateOneAnnotation","arg1","arg2","oldId","updateAnnotation","arg3","bulkUpdateAnnotation","addBody","all","bulkAddAnnotation","replace","existing","next","deleteOneAnnotation","deleteAnnotation","bulkDeleteAnnotation","annotationsOrIds","deleteOneBody","oldAnnotation","newAnnotation","deleteBody","bulkDeleteBodies","bodies","getAnnotation","getBody","annotationId","updateOneBody","oldBodyId","updateBody","bulkUpdateBodies","updateOneTarget","target","targets","t","toSvelteStore","shim","createNanoEvents","args","callbacks","length","cb","DEBOUNCE","createUndoStack","history","emitter","changeStack","pointer","muteEvents","lastEvent","now","last","undoCreated","redoCreated","undoUpdated","redoUpdated","undoDeleted","redoDeleted","callback","createViewportState","createLifecycleObserver","state","undoStack","autoSave","hover","selection","viewport","initialSelection","idleTimeout","on","off","arg0","serialized0","serialized1","onIdleUpdate","updatedSelected","initial","updatedState","initialIds","selectedIds","relevantUpdates","onUndoOrRedo","undo","serializeAll","parseAll","serialized","result","parsed","error","createBaseAnnotator","cancelSelected","clearAnnotations","getAnnotationById","getAnnotations","getSelected","s","loadAnnotations","url","response","setAnnotations","removeAnnotation","parseFn","failed","previous","computeStyle","style","chainStyles","applyFirst","applySecond","first","second","urlAlphabet","random","bytes","customRandom","alphabet","defaultSize","getRandom","mask","step","size","j","customAlphabet","nanoid","scopedUrlAlphabet","createAnonymousGuest","hashCode","obj","str","hash","chr","parseW3CUser","user","parseW3CBodies","type","purpose","modified","rest","serializeW3CBodies","bodyRest","w3cBody","DEFAULT_PALETTE","defaultColorProvider","unassignedColors","rnd","color","createDefaultAppearanceProvider","colorProvider","presenceKey","isListEqual","listA","listB","PRESENCE_KEY","createPresenceState","appearanceProvider","presentUsers","selectionStates","addUser","appearance","removeUser","syncUsers","keys","toAdd","toRemove","presentUser","getPresentUsers","notifyActivity","annotationIds","updateSelection","from"],"mappings":"AAAA,IAAIA,IAAM,OAAO,UAAU;AAEpB,SAASC,EAAOC,GAAKC,GAAK;AAChC,MAAIC,GAAMC;AACV,MAAIH,MAAQC,EAAK,QAAO;AAExB,MAAID,KAAOC,MAAQC,IAAKF,EAAI,iBAAiBC,EAAI,aAAa;AAC7D,QAAIC,MAAS,KAAM,QAAOF,EAAI,QAAS,MAAKC,EAAI,QAAS;AACzD,QAAIC,MAAS,OAAQ,QAAOF,EAAI,SAAU,MAAKC,EAAI,SAAU;AAE7D,QAAIC,MAAS,OAAO;AACnB,WAAKC,IAAIH,EAAI,YAAYC,EAAI;AAC5B,eAAOE,OAASJ,EAAOC,EAAIG,CAAG,GAAGF,EAAIE,CAAG,CAAC,IAAE;AAE5C,aAAOA,MAAQ;AAAA,IAClB;AAEE,QAAI,CAACD,KAAQ,OAAOF,KAAQ,UAAU;AACrC,MAAAG,IAAM;AACN,WAAKD,KAAQF;AAEZ,YADIF,EAAI,KAAKE,GAAKE,CAAI,KAAK,EAAEC,KAAO,CAACL,EAAI,KAAKG,GAAKC,CAAI,KACnD,EAAEA,KAAQD,MAAQ,CAACF,EAAOC,EAAIE,CAAI,GAAGD,EAAIC,CAAI,CAAC,EAAG,QAAO;AAE7D,aAAO,OAAO,KAAKD,CAAG,EAAE,WAAWE;AAAA,IACtC;AAAA,EACA;AAEC,SA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ACqB,GAAM;AACD,cAAA,KAAK,iDAAiDrB,CAAW;AACzE;AAAA,IAAA;AAGE,IAAAnF,IACc2F,EAAA,IAAIR,GAAanF,CAAS,IAE1C2F,EAAgB,OAAOR,CAAW,GAE5BvG,EAAA,KAAK,mBAAmB4H,GAAMxG,CAAS;AAAA,EACjD,GAEMoG,IAAkB,MACtB,CAAC,GAAG,MAAM,KAAKV,EAAa,OAAO,CAAC,CAAC;AAKhC,SAAA;AAAA,IACL,iBAAAU;AAAA,IACA,gBAAAC;AAAA,IACA,IANS,CAAiC5P,GAAUgJ,MACpDb,EAAQ,GAAGnI,GAAOgJ,CAAQ;AAAA,IAM1B,WAAAsG;AAAA,IACA,iBAAAQ;AAAA,EACF;AAEF;","x_google_ignoreList":[0,1,2,5,6,7,8,14,21,22]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@annotorious/core",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.22",
|
|
4
4
|
"description": "Annotorious core types and functions",
|
|
5
5
|
"author": "Rainer Simon",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
@@ -26,20 +26,20 @@
|
|
|
26
26
|
"dist"
|
|
27
27
|
],
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@sveltejs/vite-plugin-svelte": "
|
|
30
|
-
"@tsconfig/svelte": "
|
|
31
|
-
"@types/deep-equal": "
|
|
32
|
-
"svelte": "
|
|
33
|
-
"svelte-preprocess": "
|
|
29
|
+
"@sveltejs/vite-plugin-svelte": "3.1.2",
|
|
30
|
+
"@tsconfig/svelte": "5.0.4",
|
|
31
|
+
"@types/deep-equal": "1.0.4",
|
|
32
|
+
"svelte": "4.2.19",
|
|
33
|
+
"svelte-preprocess": "6.0.3",
|
|
34
34
|
"typescript": "5.7.2",
|
|
35
|
-
"vite": "
|
|
36
|
-
"vite-plugin-dts": "
|
|
37
|
-
"vitest": "
|
|
35
|
+
"vite": "5.4.11",
|
|
36
|
+
"vite-plugin-dts": "4.3.0",
|
|
37
|
+
"vitest": "2.1.8"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"dequal": "
|
|
41
|
-
"nanoevents": "
|
|
42
|
-
"nanoid": "
|
|
43
|
-
"uuid": "
|
|
40
|
+
"dequal": "2.0.3",
|
|
41
|
+
"nanoevents": "9.1.0",
|
|
42
|
+
"nanoid": "5.0.9",
|
|
43
|
+
"uuid": "11.0.3"
|
|
44
44
|
}
|
|
45
45
|
}
|