@pennsieve-viz/tsviewer 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/{BFLibraryButton-ClRfrYOf.cjs → BFLibraryButton-B6YHsKZ1.cjs} +1 -1
  2. package/dist/{BFLibraryButton-DzzWe3Ya.js → BFLibraryButton-D2RKhXw_.js} +14 -14
  3. package/dist/{IconSelection-Bnm4c-Az.js → IconSelection-BdrQ0hpx.js} +3 -3
  4. package/dist/{IconSelection-CYX2jlGW.cjs → IconSelection-CEvop8gO.cjs} +1 -1
  5. package/dist/TSAnnotationCanvas-4nqcP6ZI.cjs +1 -0
  6. package/dist/TSAnnotationCanvas-AGRX_hmt.js +716 -0
  7. package/dist/{TSAnnotationModal-BVDkiUQ1.cjs → TSAnnotationModal-EGmExCTg.cjs} +1 -1
  8. package/dist/{TSAnnotationModal-7GxnJomu.js → TSAnnotationModal-hodisC6u.js} +13 -13
  9. package/dist/{TSFilterModal-BVfwi0tb.cjs → TSFilterModal-DNCB3Dtr.cjs} +1 -1
  10. package/dist/{TSFilterModal-1E2UWL8T.js → TSFilterModal-I198XCMu.js} +8 -8
  11. package/dist/{TSScrubber-CBKcwuMb.js → TSScrubber-2aaxezaR.js} +3 -3
  12. package/dist/{TSScrubber-DBWjIhSE.cjs → TSScrubber-C0-NGaoA.cjs} +1 -1
  13. package/dist/{TSViewerCanvas-D_RaJ4Mj.js → TSViewerCanvas-Bn8wSlLN.js} +3 -3
  14. package/dist/{TSViewerCanvas-gjfcQXDY.cjs → TSViewerCanvas-DQcrVaQe.cjs} +2 -2
  15. package/dist/{TSViewerLayerWindow-D5j3_B1E.cjs → TSViewerLayerWindow-B4ksY471.cjs} +1 -1
  16. package/dist/{TSViewerLayerWindow-COWXfHNB.js → TSViewerLayerWindow-D2XxxBk5.js} +6 -6
  17. package/dist/{TSViewerToolbar-ep_lZr6h.cjs → TSViewerToolbar-ChfPZ-S1.cjs} +1 -1
  18. package/dist/{TSViewerToolbar-Cb2W7W6J.js → TSViewerToolbar-bzUSZZ_i.js} +9 -9
  19. package/dist/{TsAnnotationDeleteDialog-BRIgCXxU.cjs → TsAnnotationDeleteDialog-CqpwsxDS.cjs} +1 -1
  20. package/dist/{TsAnnotationDeleteDialog-B9pQMYZo.js → TsAnnotationDeleteDialog-DCENXkMN.js} +6 -6
  21. package/dist/{base-VCnLhxie.js → base-B8HYDRlA.js} +9 -9
  22. package/dist/{base-BQSnEcNP.cjs → base-CEBDkSsZ.cjs} +1 -1
  23. package/dist/el-input-DFAVTpkr.cjs +1 -0
  24. package/dist/{el-input-number-DXCID3jJ.js → el-input-number-DSVzNAfT.js} +6 -6
  25. package/dist/{el-input-number-Cxwc3-EL.cjs → el-input-number-F_eDnZFO.cjs} +1 -1
  26. package/dist/{el-input-DQtvBLS6.js → el-input-v5gK8U8C.js} +1676 -1664
  27. package/dist/{el-overlay-BMUWCEw_.js → el-overlay-4ljdPakB.js} +14 -14
  28. package/dist/{el-overlay-D192MFpl.cjs → el-overlay-DFtIA0N9.cjs} +1 -1
  29. package/dist/{index-TDc5sP-n.cjs → index-2QS1iKBu.cjs} +1 -1
  30. package/dist/{index-BAtTJnp_.js → index-BJOVbX31.js} +1 -1
  31. package/dist/index-CWvlkH0A.cjs +1 -0
  32. package/dist/{index-BU6e_1Ww.js → index-CnKz29Cn.js} +486 -482
  33. package/dist/index.cjs +1 -1
  34. package/dist/index.js +1 -1
  35. package/dist/{pathOr-BQgOyNsu.cjs → pathOr-BqZ0JqZk.cjs} +1 -1
  36. package/dist/{pathOr-Dr8GvKXg.js → pathOr-CIhHlnzf.js} +2 -2
  37. package/dist/style.css +1 -1
  38. package/package.json +1 -1
  39. package/dist/TSAnnotationCanvas-BCu7PmSh.cjs +0 -1
  40. package/dist/TSAnnotationCanvas-Cua-lW6X.js +0 -704
  41. package/dist/el-input-CwVmeiqs.cjs +0 -1
  42. package/dist/index-C-i9Taq7.cjs +0 -1
@@ -0,0 +1,716 @@
1
+ import { inject as _, ref as C, computed as K, watch as ne, onMounted as oe, openBlock as ae, createElementBlock as re, normalizeStyle as ie, unref as Q, nextTick as se } from "vue";
2
+ import { o as le, m as ue, h as U, p as j, u as N, j as $, i as P, g as ce } from "./index-CnKz29Cn.js";
3
+ import { storeToRefs as te } from "pinia";
4
+ import { f as fe, h as de } from "./TSViewerCanvas-Bn8wSlLN.js";
5
+ import { p as G } from "./pathOr-CIhHlnzf.js";
6
+ import { g as he } from "./_commonjsHelpers-DaMA6jEr.js";
7
+ const M = (t, a) => {
8
+ let u;
9
+ if (/^#([A-Fa-f0-9]{3}){1,2}$/.test(t))
10
+ return u = t.substring(1).split(""), u.length === 3 && (u = [u[0], u[0], u[1], u[1], u[2], u[2]]), u = "0x" + u.join(""), "rgba(" + [u >> 16 & 255, u >> 8 & 255, u & 255].join(",") + "," + a + ")";
11
+ throw new Error("Bad Hex");
12
+ }, ve = (t) => {
13
+ t.sort((a, u) => a.start < u.start ? -1 : a.start > u.start ? 1 : 0);
14
+ }, Y = (t, a) => {
15
+ const u = (t == null ? void 0 : t.layer_id) || 0;
16
+ return le({}, fe(ue("id", u), a));
17
+ }, Z = (t, a, u, i = 0, f = !1) => {
18
+ let c;
19
+ return f ? c = q(t, a, i, t.length - 1, u) : c = W(t, a, i, t.length - 1, u), c === -1 ? c = 0 : c < 0 && (c = -c - 2), c;
20
+ }, W = (t, a, u, i, f) => {
21
+ if (i < u) {
22
+ let y = i >= 0 ? i : -i - 2;
23
+ if (y === -1) return y;
24
+ const T = t[y].start;
25
+ for (; y >= 0 && t[y].start === T; )
26
+ y--;
27
+ return -y - 2;
28
+ }
29
+ const c = parseInt((u + i) / 2);
30
+ if (t[c].start > a)
31
+ return W(t, a, u, c - 1, f);
32
+ if (t[c].start < a)
33
+ return W(t, a, c + 1, i, f);
34
+ {
35
+ let y = c;
36
+ if (f) {
37
+ for (; y >= 0 && t[y].start === a; )
38
+ y--;
39
+ y++;
40
+ } else {
41
+ for (; y < t.length && t[y].start === a; )
42
+ y++;
43
+ y--;
44
+ }
45
+ return y;
46
+ }
47
+ }, q = (t, a, u, i, f) => {
48
+ if (i < u) {
49
+ let T = i >= 0 ? i : -i - 2;
50
+ if (T === -1) return T;
51
+ const I = t[T].start + t[T].duration;
52
+ for (; T >= 0 && t[T].start + t[T].duration === I; )
53
+ T--;
54
+ return -T - 2;
55
+ }
56
+ const c = parseInt((u + i) / 2), y = t[c].start + t[c].duration;
57
+ if (y > a)
58
+ return q(t, a, u, c - 1, f);
59
+ if (y < a)
60
+ return q(t, a, c + 1, i, f);
61
+ {
62
+ let T = c;
63
+ if (f) {
64
+ for (; T >= 0 && t[T].start + t[T].duration === a; )
65
+ T--;
66
+ T++;
67
+ } else {
68
+ for (; T < t.length && t[T].start + t[T].duration === a; )
69
+ T++;
70
+ T--;
71
+ }
72
+ return T;
73
+ }
74
+ }, X = (t, a, u = 0) => a * (t + u);
75
+ function ge(t = null) {
76
+ const a = t || _("viewerStore", null) || U("default"), { viewerChannels: u, viewerAnnotations: i, viewerMontageScheme: f } = te(a), c = C([]), y = C([]), T = (g) => {
77
+ const h = f.value !== "NOT_MONTAGED";
78
+ let e = j("", "id", g);
79
+ if (h) {
80
+ const r = e.split("_");
81
+ e = r.length ? de(r) : e;
82
+ }
83
+ return e;
84
+ }, I = async (g, h, e, r, d) => {
85
+ const l = [];
86
+ l.push({ start: g, end: e.tsEnd });
87
+ let o = 0;
88
+ for (let n = 0; n < c.value.length; n++) {
89
+ const s = c.value[n];
90
+ if (g >= s.start && h <= s.end)
91
+ return;
92
+ if (l[0].start > h)
93
+ break;
94
+ if (s.start <= l[0].start && s.end >= g)
95
+ o = n + 1, l[0].start = s.end;
96
+ else if (s.start > l[0].start) {
97
+ o = n;
98
+ break;
99
+ }
100
+ }
101
+ const v = i.value.reduce((n, s) => n + s.annotations.length, 0);
102
+ if (l[0].start >= l[0].end && v > 0)
103
+ return;
104
+ const m = 0;
105
+ for (let n = o; n < c.value.length; n++)
106
+ if (c.value[n].start >= l[m].start)
107
+ if (l[m].end = c.value[n].start, c.value[n].end < h)
108
+ l.push({ start: c.value[n].end, end: e.tsEnd });
109
+ else
110
+ break;
111
+ if (!(l[0].start >= l[0].end && v > 0) && l.length > 0) {
112
+ u.value.map((n) => T(n));
113
+ for (const n of l) {
114
+ for (const s of i.value) {
115
+ if (!s.id) {
116
+ console.warn("Layer ID is undefined, skipping annotation request for layer:", s);
117
+ continue;
118
+ }
119
+ const w = Math.floor(n.end), E = {
120
+ id: r.content.id,
121
+ start: Math.floor(n.start),
122
+ end: w,
123
+ layerId: s.id,
124
+ limit: e.constants.LIMITANNFETCH
125
+ };
126
+ try {
127
+ const k = await N(), p = `${a.config.apiUrl}/timeseries/${r.content.id}/layers/${s.id}/annotations?api_key=${k}`, L = Object.keys(E).map((J) => `&${J}=${E[J]}`).join(""), b = `${p}${L}`, F = await fetch(b, {
128
+ method: "GET",
129
+ headers: { "Content-type": "application/json" }
130
+ });
131
+ if (F.status >= 400)
132
+ throw new Error(F.status);
133
+ const H = await F.json();
134
+ await R(H, d);
135
+ } catch (k) {
136
+ $(k);
137
+ }
138
+ }
139
+ c.value.push({
140
+ start: Math.floor(n.start),
141
+ end: Math.floor(n.end)
142
+ });
143
+ }
144
+ c.value.sort((n, s) => n.start < s.start ? -1 : n.start > s.start ? 1 : 0);
145
+ }
146
+ }, R = async (g, h) => {
147
+ const e = j({}, "linkedPackages", g);
148
+ let r = G([], ["annotations", "results"], g);
149
+ if (r.length >= 500) {
150
+ let l = 0;
151
+ for (const o of r)
152
+ o.start > l && (l = o.start);
153
+ for (const o of c.value)
154
+ if (o.end > l && o.start < l) {
155
+ o.end = l;
156
+ break;
157
+ }
158
+ }
159
+ const d = f.value !== "NOT_MONTAGED";
160
+ if (r.length > 0) {
161
+ const l = r.map((o) => {
162
+ const v = {
163
+ name: "",
164
+ id: o.id,
165
+ label: o.label,
166
+ description: o.description,
167
+ start: o.start,
168
+ duration: o.end - o.start,
169
+ end: o.end,
170
+ cStart: null,
171
+ cEnd: null,
172
+ selected: !1,
173
+ channelIds: o.channelIds,
174
+ allChannels: !1,
175
+ layer_id: o.layerId,
176
+ userId: o.userId
177
+ };
178
+ if (o.linkedPackage) {
179
+ const m = o.linkedPackage;
180
+ v.linkedPackage = G("", ["content", "id"], e[m]), v.linkedPackageDTO = e[m];
181
+ }
182
+ return (!d && v.channelIds.length === u.value.length || d && v.channelIds.length > u.value.length) && (v.allChannels = !0), v;
183
+ });
184
+ i.value.forEach((o) => {
185
+ const v = o.annotations, m = l.filter((n) => o.id === n.layer_id);
186
+ o.annotations = v.concat(m), a.updateLayer(o);
187
+ });
188
+ }
189
+ h("annotationsReceived");
190
+ };
191
+ return {
192
+ cachedAnnRange: c,
193
+ annLayerInfo: y,
194
+ checkAnnotationRange: I,
195
+ findNextAnnotation: (g) => {
196
+ const h = a.getViewerActiveLayer(), e = Z(h.annotations, g, !1);
197
+ return e < h.annotations.length ? h.annotations[e].start > g ? h.annotations[e] : h.annotations[e + 1] || h.annotations[e] : h.annotations[e];
198
+ },
199
+ findPreviousAnnotation: (g) => {
200
+ const h = a.getViewerActiveLayer(), e = Z(h.annotations, g, !0);
201
+ return h.annotations[e].start < g ? h.annotations[e] : e > 0 ? h.annotations[e - 1] : h.annotations[e];
202
+ },
203
+ getChannelId: T
204
+ };
205
+ }
206
+ function ye(t = null) {
207
+ const a = t || _("viewerStore", null) || U("default"), { viewerAnnotations: u, viewerChannels: i } = te(a), f = C([]), c = C([]), y = C(null), T = C(["#FFFF4E"]), I = (e, r) => {
208
+ var v, m;
209
+ const l = (((v = r.constants) == null ? void 0 : v.ANNOTATIONLABELHEIGHT) || 20) / 2 | 0, o = ((m = r.constants) == null ? void 0 : m.XOFFSET) || 0;
210
+ for (const n of e) {
211
+ let s = n.start, w = n.duration;
212
+ n.duration < 0 && (s = n.start + n.duration, w = -n.duration);
213
+ const E = o + (s - r.start) / r.rsPeriod;
214
+ if (n.cStart = E | 0, n.duration !== 0) {
215
+ const k = o + (s + w - r.start) / r.rsPeriod;
216
+ n.cEnd = k | 0;
217
+ } else
218
+ n.cEnd = n.cStart + r.cWidth / 40 | 0;
219
+ if (n.allChannels)
220
+ n.allOffsets = [l], n.cY = l;
221
+ else {
222
+ n.allOffsets = [], n.minOffset = r.cHeight | 0, n.maxOffset = 0;
223
+ const k = i.value;
224
+ for (const S of n.channelIds) {
225
+ let p = null;
226
+ for (const L of k)
227
+ if (L.id === S && L.visible) {
228
+ p = L.rowBaseline | 0, p < n.minOffset && (n.minOffset = p), p > n.maxOffset && (n.maxOffset = p), n.allOffsets.push(p);
229
+ break;
230
+ }
231
+ }
232
+ c.value.indexOf(n.minOffset) < 0 && c.value.push(n.minOffset), n.cY = n.minOffset;
233
+ }
234
+ }
235
+ }, R = (e, r, d, l) => {
236
+ var m, n;
237
+ const o = ((m = d.constants) == null ? void 0 : m.ANNOTATIONLABELHEIGHT) || 20, v = o / 2 | 0;
238
+ e.setTransform(d.pixelRatio, 0, 0, d.pixelRatio, 0, 0), e.save(), e.lineWidth = 1, e.setLineDash([8, 5]), e.strokeStyle = "rgba(0,0,0, 0.6)", e.fillStyle = "rgba(0,0,0,0.05)";
239
+ for (const s of r) {
240
+ const w = Y(s, u.value);
241
+ s.selected && (e.save(), e.strokeStyle = w.selColor, e.fillStyle = w.bkColor, e.lineWidth = 1);
242
+ const E = Math.round(s.cStart) + 0.5, k = Math.round(s.cEnd) + 0.5;
243
+ s.allChannels ? s.duration === 0 ? (e.beginPath(), e.moveTo(E + 1, o), e.lineTo(E, l), e.stroke()) : (e.fillRect(E, o, k - E, l - o), e.beginPath(), e.moveTo(E, o), e.lineTo(E, l), e.moveTo(k, o), e.lineTo(k, l), e.stroke()) : ((n = s == null ? void 0 : s.channelIds) == null ? void 0 : n.length) === 1 ? s.duration === 0 && (e.beginPath(), e.moveTo(E, s.minOffset + v), e.lineTo(E, s.minOffset + v + 8), e.stroke()) : s.duration === 0 ? (e.beginPath(), e.moveTo(E, s.minOffset + v), e.lineTo(E, s.maxOffset - v), e.stroke()) : (e.fillRect(
244
+ E - 1,
245
+ s.minOffset + v,
246
+ k - E + 1,
247
+ s.maxOffset - s.minOffset - o
248
+ ), e.beginPath(), e.moveTo(E, s.minOffset + v), e.lineTo(E, s.maxOffset - v), e.moveTo(k, s.minOffset + v), e.lineTo(k, s.maxOffset - v), e.stroke()), s.selected && e.restore();
249
+ }
250
+ e.restore();
251
+ }, A = async (e, r, d, l, o, v) => {
252
+ var s;
253
+ const m = ((s = d.constants) == null ? void 0 : s.ANNOTATIONLABELHEIGHT) || 20, n = m / 2 | 0;
254
+ e.setTransform(d.pixelRatio, 0, 0, d.pixelRatio, 0, 0), e.save(), e.lineWidth = 2, e.font = "14px sans-serif", e.textAlign = "left";
255
+ for (const w of r) {
256
+ const E = Y(w, u.value);
257
+ if (w === y.value && l)
258
+ continue;
259
+ w.selected ? (e.fillStyle = E.selColor || "rgba(51,204,102, 0.8)", e.strokeStyle = "white") : (e.fillStyle = E.color || "rgba(51,204,102,0.8)", e.strokeStyle = w === y.value ? "white" : "rgba(255,255,255,0.8)");
260
+ const k = Math.round(w.cStart) + 1, S = Math.round(w.cEnd);
261
+ let p = 0;
262
+ for (let F = 0; F < w.allOffsets.length; F++)
263
+ e.fillRect(
264
+ k - 1,
265
+ w.allOffsets[F] - n,
266
+ S - k + 2,
267
+ m
268
+ ), w.allOffsets[F] === w.minOffset && (p = F);
269
+ const L = w.allOffsets[p];
270
+ if (["annSelect", "annResize-left", "annResize-right"].includes(o) && v === "annotate" && (e.beginPath(), w.duration !== 0 && (e.moveTo(S - 3, L - n + 3), e.lineTo(S - 3, L + n - 3)), e.moveTo(k + 3, L - n + 3), e.lineTo(k + 3, L + n - 3), e.stroke()), S - k > w.label.length * 8 + 10) {
271
+ e.fillStyle = T.value.indexOf(E.hexColor) >= 0 ? "black" : "white";
272
+ const F = w.linkedPackage ? k + 30 : k + 10, H = w.linkedPackage ? L + n - n / 2 : L + n - 6;
273
+ e.fillText(w.label, F, H);
274
+ }
275
+ const b = w.linkedPackageDTO;
276
+ b && S - k >= 30 && await O(e, b, k, L, n, m);
277
+ }
278
+ e.restore();
279
+ }, O = async (e, r, d, l, o, v) => {
280
+ const m = G({}, ["objects", "view", 1, "content"], r), n = j("", "fileType", m), s = new Image();
281
+ if (n === "PNG") {
282
+ const { id: w, packageId: E } = m, k = a.config.apiUrl;
283
+ try {
284
+ const S = await N();
285
+ s.src = `${k}/packages/${E}/files/${w}/presign/?api_key=${S}`, s.complete ? e.drawImage(s, d, l - o, 27, v) : s.addEventListener("load", () => {
286
+ e.drawImage(s, d, l - o, 27, v);
287
+ }, { once: !0 });
288
+ } catch (S) {
289
+ console.error("Error loading image:", S);
290
+ }
291
+ } else
292
+ s.src = g(), e.drawImage(s, d + 5, l - o, 20, 20);
293
+ }, g = (e) => "/path/to/default/icon.png";
294
+ return {
295
+ renderAnn: f,
296
+ hoverOffsets: c,
297
+ focusedAnn: y,
298
+ render: (e, r, d, l) => {
299
+ var w, E;
300
+ if (!r) {
301
+ console.warn("TSAnnotationCanvas: annotationsCanvas prop is undefined or null");
302
+ return;
303
+ }
304
+ const o = r.getContext("2d"), v = d.getContext("2d");
305
+ o.setTransform(e.pixelRatio, 0, 0, e.pixelRatio, 0, 0), v.setTransform(e.pixelRatio, 0, 0, e.pixelRatio, 0, 0), c.value = [(((w = e.constants) == null ? void 0 : w.ANNOTATIONLABELHEIGHT) || 20) / 2], o.clearRect(0, 0, e.cWidth, e.cHeight), v.clearRect(0, 0, e.cWidth, e.cHeight), f.value = [];
306
+ const m = e.duration && e.duration > 0 ? e.duration : 15e6, n = e.start || 0, s = n + m;
307
+ for (const k of u.value)
308
+ if (k.visible && ((E = k.annotations) == null ? void 0 : E.length) > 0) {
309
+ const S = k.annotations.filter((p) => {
310
+ const L = p.start, b = p.end || p.start + (p.duration || 0);
311
+ return L < s && b > n;
312
+ });
313
+ S.length > 0 && (S.sort((p, L) => p.start - L.start), f.value.push(...S));
314
+ }
315
+ f.value.length !== 0 && (ve(f.value), I(f.value, e), R(o, f.value, e, l), A(v, f.value, e, !0, e.pointerMode, e.viewerActiveTool), y.value && A(v, [y.value], e, !1, e.pointerMode, e.viewerActiveTool));
316
+ },
317
+ computeRenderOptions: I,
318
+ renderAnnotationAreas: R,
319
+ renderAnnotationLabels: A
320
+ };
321
+ }
322
+ function me(t, a, u, i = null) {
323
+ const f = i || _("viewerStore", null) || U("default"), c = C([0, 0]), y = (e, r) => {
324
+ const l = ((r == null ? void 0 : r.ANNOTATIONLABELHEIGHT) || 20) / 2;
325
+ for (const o of u.value)
326
+ if (e >= o - l && e <= o + l)
327
+ return !0;
328
+ return !1;
329
+ }, T = (e, r, d) => {
330
+ var v;
331
+ const o = ((d == null ? void 0 : d.ANNOTATIONLABELHEIGHT) || 20) / 2;
332
+ for (let m = 0; m < (((v = a.value) == null ? void 0 : v.length) || 0); m++) {
333
+ const n = a.value[m];
334
+ if (n.cStart < e && n.cEnd > e) {
335
+ if (r > n.cY - o && r < n.cY + o)
336
+ return m;
337
+ } else if (n.cStart > e)
338
+ break;
339
+ }
340
+ return null;
341
+ }, I = (e, r, d) => {
342
+ if (!d) return r;
343
+ switch (r) {
344
+ case "annotate":
345
+ return e <= d.cStart + 10 ? "annResize-left" : e >= d.cEnd - 10 && d.duration > 0 ? "annResize-right" : "annSelect";
346
+ case "pointer":
347
+ return "annSelect";
348
+ default:
349
+ return r;
350
+ }
351
+ };
352
+ return {
353
+ mouseDownPosition: c,
354
+ shouldCheckAnnotationHover: y,
355
+ findAnnotationAtPosition: T,
356
+ determinePointerMode: I,
357
+ resetFocusedAnnotation: () => {
358
+ var e;
359
+ ((e = t.value) == null ? void 0 : e.oldStart) !== void 0 && (t.value.start = t.value.oldStart, t.value.duration = t.value.oldDuration, t.value.end = t.value.start + t.value.duration);
360
+ },
361
+ selectFocusedAnnotation: () => t.value ? (f.setActiveAnnotation(t.value), !0) : !1,
362
+ onMouseDown: (e, r, d) => {
363
+ t.value && ["annResize-left", "annResize-right"].includes(d) && (t.value.oldStart = t.value.start, t.value.oldDuration = t.value.duration, c.value = [e, r]);
364
+ },
365
+ onMouseMove: (e, r, d, l, o) => {
366
+ let v = d;
367
+ if (l && c.value) {
368
+ const m = (e - c.value[0]) * o.rsPeriod;
369
+ switch (d) {
370
+ case "annResize-left":
371
+ t.value.oldDuration > 0 ? (t.value.start = t.value.oldStart + m, t.value.duration = t.value.oldDuration - m, t.value.end = t.value.start + t.value.duration) : t.value.start = t.value.oldStart + m;
372
+ break;
373
+ case "annResize-right":
374
+ t.value.duration = t.value.oldDuration + m, t.value.end = t.value.start + t.value.duration;
375
+ break;
376
+ }
377
+ } else {
378
+ const m = y(r, o.constants);
379
+ if (v = o.viewerActiveTool, m) {
380
+ const n = T(e, r, o.constants);
381
+ if (n !== null) {
382
+ const s = t.value, w = a.value[n];
383
+ (!s || e < t.value.cStart || e > t.value.cEnd) && (t.value = w), v = I(e, o.viewerActiveTool, t.value);
384
+ } else
385
+ t.value = null;
386
+ } else
387
+ t.value = null, v = o.viewerActiveTool;
388
+ }
389
+ return v;
390
+ },
391
+ onMouseUp: (e, r) => {
392
+ if (t.value && ["annResize-left", "annResize-right"].includes(e)) {
393
+ if (t.value.duration < 0) {
394
+ const d = -t.value.duration, l = t.value.start - d;
395
+ t.value.start = l, t.value.duration = d, t.value.end = l + d;
396
+ }
397
+ f.setActiveAnnotation(t.value), r("updateAnnotation", t.value);
398
+ }
399
+ }
400
+ };
401
+ }
402
+ var D = { exports: {} }, V;
403
+ function Te() {
404
+ if (V) return D.exports;
405
+ V = 1;
406
+ function t() {
407
+ }
408
+ return t.prototype = {
409
+ on: function(a, u, i) {
410
+ var f = this.e || (this.e = {});
411
+ return (f[a] || (f[a] = [])).push({
412
+ fn: u,
413
+ ctx: i
414
+ }), this;
415
+ },
416
+ once: function(a, u, i) {
417
+ var f = this;
418
+ function c() {
419
+ f.off(a, c), u.apply(i, arguments);
420
+ }
421
+ return c._ = u, this.on(a, c, i);
422
+ },
423
+ emit: function(a) {
424
+ var u = [].slice.call(arguments, 1), i = ((this.e || (this.e = {}))[a] || []).slice(), f = 0, c = i.length;
425
+ for (f; f < c; f++)
426
+ i[f].fn.apply(i[f].ctx, u);
427
+ return this;
428
+ },
429
+ off: function(a, u) {
430
+ var i = this.e || (this.e = {}), f = i[a], c = [];
431
+ if (f && u)
432
+ for (var y = 0, T = f.length; y < T; y++)
433
+ f[y].fn !== u && f[y].fn._ !== u && c.push(f[y]);
434
+ return c.length ? i[a] = c : delete i[a], this;
435
+ }
436
+ }, D.exports = t, D.exports.TinyEmitter = t, D.exports;
437
+ }
438
+ var z, x;
439
+ function we() {
440
+ if (x) return z;
441
+ x = 1;
442
+ var t = Te();
443
+ return z = new t(), z;
444
+ }
445
+ var ke = we();
446
+ const B = /* @__PURE__ */ he(ke), ee = {
447
+ $emit: (...t) => B.emit(...t),
448
+ $on: (...t) => B.on(...t),
449
+ $off: (...t) => B.off(...t),
450
+ $once: (...t) => B.once(...t)
451
+ };
452
+ function Oe(t = null) {
453
+ const a = t || _("viewerStore", null) || U("default"), u = C([]), i = C([
454
+ "#18BA62",
455
+ "#FFBC27",
456
+ "#E94B4B",
457
+ "#0D4EFF",
458
+ "#FF4FFF",
459
+ "#50FFFF",
460
+ "#FFFF4E",
461
+ "#512BAF",
462
+ "#8A6ECF",
463
+ "#389BAD",
464
+ "#187D46",
465
+ "#B12800",
466
+ "#0C2475",
467
+ "#FF5321",
468
+ "#FF99CC",
469
+ "#DCC180",
470
+ "#FF6C21",
471
+ "#000000",
472
+ "#9B9B9B",
473
+ "#00FF00",
474
+ "#FA8072",
475
+ "#808000",
476
+ "#A0522D",
477
+ "#2760FF"
478
+ ]), f = async (O, g) => {
479
+ const h = [];
480
+ if (O.results.length === 0)
481
+ await c({
482
+ name: "Default",
483
+ color: "#18BA62",
484
+ description: "Default Annotation Layer"
485
+ }, null, g);
486
+ else {
487
+ for (let e = 0; e < O.results.length; e++) {
488
+ const r = O.results[e];
489
+ let d = r.color || i.value[e % i.value.length];
490
+ const l = {
491
+ id: r.id,
492
+ name: r.name,
493
+ description: r.description,
494
+ visible: !0,
495
+ selected: e === 0,
496
+ // First layer is selected by default
497
+ annotations: [],
498
+ color: M(d, 0.7),
499
+ hexColor: d,
500
+ bkColor: M(d, 0.15),
501
+ selColor: M(d, 0.9)
502
+ };
503
+ h.push(l);
504
+ }
505
+ a.setAnnotations(h), g("annLayersInitialized");
506
+ }
507
+ u.value = O.results;
508
+ }, c = async (O, g, h) => {
509
+ var e;
510
+ if (!((e = g == null ? void 0 : g.content) != null && e.id))
511
+ return null;
512
+ try {
513
+ const r = await N(), d = `${a.config.apiUrl}/timeseries/${g.content.id}/layers?api_key=${r}`, l = await P(d, {
514
+ method: "POST",
515
+ body: {
516
+ name: O.name,
517
+ color: O.color,
518
+ description: O.description || O.name
519
+ }
520
+ }), o = {
521
+ ...l,
522
+ annotations: [],
523
+ hexColor: l.color,
524
+ color: M(l.color, 0.7),
525
+ bkColor: M(l.color, 0.15),
526
+ selColor: M(l.color, 0.9),
527
+ visible: !0,
528
+ selected: !0
529
+ };
530
+ return a.createLayer(o), a.setActiveAnnotationLayer(o.id), ee.$emit("toast", {
531
+ detail: {
532
+ msg: `'${o.name}' Layer Created`
533
+ }
534
+ }), o;
535
+ } catch (r) {
536
+ throw $(r), r;
537
+ } finally {
538
+ h && h("closeAnnotationLayerWindow");
539
+ }
540
+ };
541
+ return {
542
+ annLayerInfo: u,
543
+ defaultColors: i,
544
+ initializeLayers: f,
545
+ createAnnotationLayer: c,
546
+ updateLayerVisibility: (O, g) => {
547
+ const h = a.viewerAnnotations.find((e) => e.id === O);
548
+ h && (h.visible = g, a.updateLayer(h));
549
+ },
550
+ selectLayer: (O) => {
551
+ a.viewerAnnotations.forEach((h) => {
552
+ h.selected = !1, a.updateLayer(h);
553
+ });
554
+ const g = a.viewerAnnotations.find((h) => h.id === O);
555
+ g && (g.selected = !0, a.updateLayer(g), a.setActiveAnnotationLayer(O));
556
+ },
557
+ deleteLayer: async (O, g) => {
558
+ var h;
559
+ if (!((h = g == null ? void 0 : g.content) != null && h.id))
560
+ return null;
561
+ try {
562
+ const e = await N(), r = `${a.config.apiUrl}/timeseries/${g.content.id}/layers/${O}?api_key=${e}`;
563
+ await P(r, { method: "DELETE" }), a.removeLayer(O), ee.$emit("toast", {
564
+ detail: {
565
+ msg: "Layer deleted successfully"
566
+ }
567
+ });
568
+ } catch (e) {
569
+ throw $(e), e;
570
+ }
571
+ },
572
+ updateLayerColor: async (O, g, h) => {
573
+ var e;
574
+ if (!((e = h == null ? void 0 : h.content) != null && e.id))
575
+ return null;
576
+ try {
577
+ const r = await N(), d = `${a.config.apiUrl}/timeseries/${h.content.id}/layers/${O}?api_key=${r}`, l = await P(d, {
578
+ method: "PUT",
579
+ body: { color: g }
580
+ }), o = a.viewerAnnotations.find((v) => v.id === O);
581
+ return o && (o.hexColor = g, o.color = M(g, 0.7), o.bkColor = M(g, 0.15), o.selColor = M(g, 0.9), a.updateLayer(o)), l;
582
+ } catch (r) {
583
+ throw $(r), r;
584
+ }
585
+ },
586
+ loadLayers: async (O, g) => {
587
+ var h;
588
+ if (!((h = O == null ? void 0 : O.content) != null && h.id))
589
+ return null;
590
+ try {
591
+ const e = await N(), r = `${a.config.apiUrl}/timeseries/${O.content.id}/layers?api_key=${e}`, d = await P(r);
592
+ return await f(d, g), d;
593
+ } catch (e) {
594
+ throw $(e), e;
595
+ }
596
+ }
597
+ };
598
+ }
599
+ const Le = ["width", "height"], Ee = {
600
+ __name: "TSAnnotationCanvas",
601
+ props: {
602
+ cWidth: { type: Number, default: 0 },
603
+ cHeight: Number,
604
+ start: Number,
605
+ duration: Number,
606
+ tsEnd: Number,
607
+ rsPeriod: Number,
608
+ pixelRatio: Number,
609
+ constants: {
610
+ type: Object,
611
+ default: () => ({
612
+ ANNOTATIONLABELHEIGHT: 20,
613
+ XOFFSET: 0,
614
+ LIMITANNFETCH: 500
615
+ })
616
+ },
617
+ pointerMode: String,
618
+ annotationsCanvas: [HTMLCanvasElement, Object],
619
+ activeViewer: { type: Object, required: !0 },
620
+ viewerActiveTool: String
621
+ },
622
+ emits: [
623
+ "annLayersInitialized",
624
+ "annotationsReceived",
625
+ "closeAnnotationLayerWindow",
626
+ "updateAnnotation"
627
+ ],
628
+ setup(t, { expose: a, emit: u }) {
629
+ const i = t, f = u, c = C(null), {
630
+ checkAnnotationRange: y,
631
+ findNextAnnotation: T,
632
+ findPreviousAnnotation: I
633
+ } = ge(), {
634
+ renderAnn: R,
635
+ hoverOffsets: A,
636
+ focusedAnn: O,
637
+ render: g
638
+ } = ye(), {
639
+ resetFocusedAnnotation: h,
640
+ selectFocusedAnnotation: e,
641
+ onMouseDown: r,
642
+ onMouseMove: d,
643
+ onMouseUp: l
644
+ } = me(O, R, A), {
645
+ createAnnotationLayer: o,
646
+ loadLayers: v
647
+ } = Oe(), m = K(() => i.cHeight - 20), n = K(() => ({
648
+ width: i.cWidth + "px",
649
+ height: m.value + "px"
650
+ })), s = () => {
651
+ g(i, i.annotationsCanvas, c.value, m.value);
652
+ }, w = (L, b) => {
653
+ r(L, b, i.pointerMode);
654
+ }, E = (L, b, F, H) => d(L, b, F, H, i), k = () => {
655
+ l(i.pointerMode, f);
656
+ }, S = () => {
657
+ e() && se(() => s());
658
+ }, p = async (L) => {
659
+ try {
660
+ await o(L, i.activeViewer, f);
661
+ } catch (b) {
662
+ console.error("Error creating layer:", b);
663
+ }
664
+ };
665
+ return ne(
666
+ () => i.activeViewer,
667
+ async (L) => {
668
+ try {
669
+ await v(L, f), await y(
670
+ i.start,
671
+ i.start + i.duration,
672
+ i,
673
+ L,
674
+ f
675
+ );
676
+ } catch (b) {
677
+ console.error("Error loading annotations for new viewer:", b);
678
+ }
679
+ }
680
+ ), oe(async () => {
681
+ try {
682
+ await v(i.activeViewer, f), await y(
683
+ i.start,
684
+ i.start + i.duration,
685
+ i,
686
+ i.activeViewer,
687
+ f
688
+ );
689
+ } catch (L) {
690
+ console.error("Error initializing annotations:", L);
691
+ }
692
+ }), a({
693
+ render: s,
694
+ resetFocusedAnnotation: h,
695
+ findNextAnnotation: T,
696
+ findPreviousAnnotation: I,
697
+ checkAnnotationRange: (L, b) => y(L, b, i, i.activeViewer, f),
698
+ selectFocusedAnn: S,
699
+ createAnnotationLayer: p,
700
+ onMouseDown: w,
701
+ onMouseMove: E,
702
+ onMouseUp: k
703
+ }), (L, b) => (ae(), re("canvas", {
704
+ id: "annLabelArea",
705
+ ref_key: "annLabelArea",
706
+ ref: c,
707
+ class: "timeseries-annotation-canvas",
708
+ width: Q(X)(t.cWidth, t.pixelRatio, 0),
709
+ height: Q(X)(m.value, t.pixelRatio, 0),
710
+ style: ie(n.value)
711
+ }, null, 12, Le));
712
+ }
713
+ }, Me = /* @__PURE__ */ ce(Ee, [["__scopeId", "data-v-2261f569"]]);
714
+ export {
715
+ Me as default
716
+ };