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