tsviewer 1.0.27 → 1.0.29

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.
@@ -0,0 +1,1308 @@
1
+ import { ref as g, computed as B, defineAsyncComponent as Z, watch as Te, nextTick as ne, onMounted as Ut, onBeforeUnmount as jt, createElementBlock as Ie, openBlock as de, normalizeClass as Se, createVNode as re, createElementVNode as ce, createBlock as Rt, createCommentVNode as Mt, unref as J, Fragment as Vt, renderList as $t, toDisplayString as je } from "vue";
2
+ import { defineStore as Ft, storeToRefs as He } from "pinia";
3
+ import { fetchAuthSession as xt } from "aws-amplify/auth";
4
+ function T(t) {
5
+ return t != null && typeof t == "object" && t["@@functional/placeholder"] === !0;
6
+ }
7
+ function L(t) {
8
+ return function e(n) {
9
+ return arguments.length === 0 || T(n) ? e : t.apply(this, arguments);
10
+ };
11
+ }
12
+ function N(t) {
13
+ return function e(n, o) {
14
+ switch (arguments.length) {
15
+ case 0:
16
+ return e;
17
+ case 1:
18
+ return T(n) ? e : L(function(i) {
19
+ return t(n, i);
20
+ });
21
+ default:
22
+ return T(n) && T(o) ? e : T(n) ? L(function(i) {
23
+ return t(i, o);
24
+ }) : T(o) ? L(function(i) {
25
+ return t(n, i);
26
+ }) : t(n, o);
27
+ }
28
+ };
29
+ }
30
+ function Wt(t, e) {
31
+ t = t || [], e = e || [];
32
+ var n, o = t.length, i = e.length, u = [];
33
+ for (n = 0; n < o; )
34
+ u[u.length] = t[n], n += 1;
35
+ for (n = 0; n < i; )
36
+ u[u.length] = e[n], n += 1;
37
+ return u;
38
+ }
39
+ function Ce(t, e) {
40
+ switch (t) {
41
+ case 0:
42
+ return function() {
43
+ return e.apply(this, arguments);
44
+ };
45
+ case 1:
46
+ return function(n) {
47
+ return e.apply(this, arguments);
48
+ };
49
+ case 2:
50
+ return function(n, o) {
51
+ return e.apply(this, arguments);
52
+ };
53
+ case 3:
54
+ return function(n, o, i) {
55
+ return e.apply(this, arguments);
56
+ };
57
+ case 4:
58
+ return function(n, o, i, u) {
59
+ return e.apply(this, arguments);
60
+ };
61
+ case 5:
62
+ return function(n, o, i, u, h) {
63
+ return e.apply(this, arguments);
64
+ };
65
+ case 6:
66
+ return function(n, o, i, u, h, w) {
67
+ return e.apply(this, arguments);
68
+ };
69
+ case 7:
70
+ return function(n, o, i, u, h, w, l) {
71
+ return e.apply(this, arguments);
72
+ };
73
+ case 8:
74
+ return function(n, o, i, u, h, w, l, s) {
75
+ return e.apply(this, arguments);
76
+ };
77
+ case 9:
78
+ return function(n, o, i, u, h, w, l, s, A) {
79
+ return e.apply(this, arguments);
80
+ };
81
+ case 10:
82
+ return function(n, o, i, u, h, w, l, s, A, m) {
83
+ return e.apply(this, arguments);
84
+ };
85
+ default:
86
+ throw new Error("First argument to _arity must be a non-negative integer no greater than ten");
87
+ }
88
+ }
89
+ function ge(t) {
90
+ return function e(n, o, i) {
91
+ switch (arguments.length) {
92
+ case 0:
93
+ return e;
94
+ case 1:
95
+ return T(n) ? e : N(function(u, h) {
96
+ return t(n, u, h);
97
+ });
98
+ case 2:
99
+ return T(n) && T(o) ? e : T(n) ? N(function(u, h) {
100
+ return t(u, o, h);
101
+ }) : T(o) ? N(function(u, h) {
102
+ return t(n, u, h);
103
+ }) : L(function(u) {
104
+ return t(n, o, u);
105
+ });
106
+ default:
107
+ return T(n) && T(o) && T(i) ? e : T(n) && T(o) ? N(function(u, h) {
108
+ return t(u, h, i);
109
+ }) : T(n) && T(i) ? N(function(u, h) {
110
+ return t(u, o, h);
111
+ }) : T(o) && T(i) ? N(function(u, h) {
112
+ return t(n, u, h);
113
+ }) : T(n) ? L(function(u) {
114
+ return t(u, o, i);
115
+ }) : T(o) ? L(function(u) {
116
+ return t(n, u, i);
117
+ }) : T(i) ? L(function(u) {
118
+ return t(n, o, u);
119
+ }) : t(n, o, i);
120
+ }
121
+ };
122
+ }
123
+ const ye = Array.isArray || function(e) {
124
+ return e != null && e.length >= 0 && Object.prototype.toString.call(e) === "[object Array]";
125
+ };
126
+ function qt(t) {
127
+ return t != null && typeof t["@@transducer/step"] == "function";
128
+ }
129
+ function Bt(t, e, n) {
130
+ return function() {
131
+ if (arguments.length === 0)
132
+ return n();
133
+ var o = arguments[arguments.length - 1];
134
+ if (!ye(o)) {
135
+ for (var i = 0; i < t.length; ) {
136
+ if (typeof o[t[i]] == "function")
137
+ return o[t[i]].apply(o, Array.prototype.slice.call(arguments, 0, -1));
138
+ i += 1;
139
+ }
140
+ if (qt(o)) {
141
+ var u = e.apply(null, Array.prototype.slice.call(arguments, 0, -1));
142
+ return u(o);
143
+ }
144
+ }
145
+ return n.apply(this, arguments);
146
+ };
147
+ }
148
+ function zt(t) {
149
+ return t && t["@@transducer/reduced"] ? t : {
150
+ "@@transducer/value": t,
151
+ "@@transducer/reduced": !0
152
+ };
153
+ }
154
+ const Xt = {
155
+ init: function() {
156
+ return this.xf["@@transducer/init"]();
157
+ },
158
+ result: function(t) {
159
+ return this.xf["@@transducer/result"](t);
160
+ }
161
+ };
162
+ function me(t) {
163
+ return Object.prototype.toString.call(t) === "[object String]";
164
+ }
165
+ var Gt = /* @__PURE__ */ L(function(e) {
166
+ return ye(e) ? !0 : !e || typeof e != "object" || me(e) ? !1 : e.length === 0 ? !0 : e.length > 0 ? e.hasOwnProperty(0) && e.hasOwnProperty(e.length - 1) : !1;
167
+ }), Ht = /* @__PURE__ */ function() {
168
+ function t(e) {
169
+ this.f = e;
170
+ }
171
+ return t.prototype["@@transducer/init"] = function() {
172
+ throw new Error("init not implemented on XWrap");
173
+ }, t.prototype["@@transducer/result"] = function(e) {
174
+ return e;
175
+ }, t.prototype["@@transducer/step"] = function(e, n) {
176
+ return this.f(e, n);
177
+ }, t;
178
+ }();
179
+ function Zt(t) {
180
+ return new Ht(t);
181
+ }
182
+ var Jt = /* @__PURE__ */ N(function(e, n) {
183
+ return Ce(e.length, function() {
184
+ return e.apply(n, arguments);
185
+ });
186
+ });
187
+ function Yt(t, e, n) {
188
+ for (var o = 0, i = n.length; o < i; ) {
189
+ if (e = t["@@transducer/step"](e, n[o]), e && e["@@transducer/reduced"]) {
190
+ e = e["@@transducer/value"];
191
+ break;
192
+ }
193
+ o += 1;
194
+ }
195
+ return t["@@transducer/result"](e);
196
+ }
197
+ function Re(t, e, n) {
198
+ for (var o = n.next(); !o.done; ) {
199
+ if (e = t["@@transducer/step"](e, o.value), e && e["@@transducer/reduced"]) {
200
+ e = e["@@transducer/value"];
201
+ break;
202
+ }
203
+ o = n.next();
204
+ }
205
+ return t["@@transducer/result"](e);
206
+ }
207
+ function Me(t, e, n, o) {
208
+ return t["@@transducer/result"](n[o](Jt(t["@@transducer/step"], t), e));
209
+ }
210
+ var Ve = typeof Symbol < "u" ? Symbol.iterator : "@@iterator";
211
+ function Kt(t, e, n) {
212
+ if (typeof t == "function" && (t = Zt(t)), Gt(n))
213
+ return Yt(t, e, n);
214
+ if (typeof n["fantasy-land/reduce"] == "function")
215
+ return Me(t, e, n, "fantasy-land/reduce");
216
+ if (n[Ve] != null)
217
+ return Re(t, e, n[Ve]());
218
+ if (typeof n.next == "function")
219
+ return Re(t, e, n);
220
+ if (typeof n.reduce == "function")
221
+ return Me(t, e, n, "reduce");
222
+ throw new TypeError("reduce: list must be array or iterable");
223
+ }
224
+ function ve(t, e) {
225
+ return Object.prototype.hasOwnProperty.call(e, t);
226
+ }
227
+ var $e = Object.prototype.toString, Ze = /* @__PURE__ */ function() {
228
+ return $e.call(arguments) === "[object Arguments]" ? function(e) {
229
+ return $e.call(e) === "[object Arguments]";
230
+ } : function(e) {
231
+ return ve("callee", e);
232
+ };
233
+ }(), Qt = !/* @__PURE__ */ {
234
+ toString: null
235
+ }.propertyIsEnumerable("toString"), Fe = ["constructor", "valueOf", "isPrototypeOf", "toString", "propertyIsEnumerable", "hasOwnProperty", "toLocaleString"], xe = /* @__PURE__ */ function() {
236
+ return arguments.propertyIsEnumerable("length");
237
+ }(), en = function(e, n) {
238
+ for (var o = 0; o < e.length; ) {
239
+ if (e[o] === n)
240
+ return !0;
241
+ o += 1;
242
+ }
243
+ return !1;
244
+ }, We = /* @__PURE__ */ L(typeof Object.keys == "function" && !xe ? function(e) {
245
+ return Object(e) !== e ? [] : Object.keys(e);
246
+ } : function(e) {
247
+ if (Object(e) !== e)
248
+ return [];
249
+ var n, o, i = [], u = xe && Ze(e);
250
+ for (n in e)
251
+ ve(n, e) && (!u || n !== "length") && (i[i.length] = n);
252
+ if (Qt)
253
+ for (o = Fe.length - 1; o >= 0; )
254
+ n = Fe[o], ve(n, e) && !en(i, n) && (i[i.length] = n), o -= 1;
255
+ return i;
256
+ });
257
+ const tn = Number.isInteger || function(e) {
258
+ return e << 0 === e;
259
+ };
260
+ var nn = /* @__PURE__ */ N(function(e, n) {
261
+ var o = e < 0 ? n.length + e : e;
262
+ return me(n) ? n.charAt(o) : n[o];
263
+ }), Y = /* @__PURE__ */ N(function(e, n) {
264
+ if (n != null)
265
+ return tn(e) ? nn(e, n) : n[e];
266
+ }), rn = /* @__PURE__ */ ge(Kt), qe = /* @__PURE__ */ L(function(e) {
267
+ return e === null ? "Null" : e === void 0 ? "Undefined" : Object.prototype.toString.call(e).slice(8, -1);
268
+ });
269
+ function on(t, e) {
270
+ return function() {
271
+ return e.call(this, t.apply(this, arguments));
272
+ };
273
+ }
274
+ function Je(t, e) {
275
+ return function() {
276
+ var n = arguments.length;
277
+ if (n === 0)
278
+ return e();
279
+ var o = arguments[n - 1];
280
+ return ye(o) || typeof o[t] != "function" ? e.apply(this, arguments) : o[t].apply(o, Array.prototype.slice.call(arguments, 0, n - 1));
281
+ };
282
+ }
283
+ var an = /* @__PURE__ */ ge(
284
+ /* @__PURE__ */ Je("slice", function(e, n, o) {
285
+ return Array.prototype.slice.call(o, e, n);
286
+ })
287
+ ), sn = /* @__PURE__ */ L(
288
+ /* @__PURE__ */ Je(
289
+ "tail",
290
+ /* @__PURE__ */ an(1, 1 / 0)
291
+ )
292
+ );
293
+ function ln() {
294
+ if (arguments.length === 0)
295
+ throw new Error("pipe requires at least one argument");
296
+ return Ce(arguments[0].length, rn(on, arguments[0], sn(arguments)));
297
+ }
298
+ var un = /* @__PURE__ */ L(function(e) {
299
+ return me(e) ? e.split("").reverse().join("") : Array.prototype.slice.call(e, 0).reverse();
300
+ });
301
+ function Be() {
302
+ if (arguments.length === 0)
303
+ throw new Error("compose requires at least one argument");
304
+ return ln.apply(this, un(arguments));
305
+ }
306
+ function ze(t) {
307
+ for (var e = [], n; !(n = t.next()).done; )
308
+ e.push(n.value);
309
+ return e;
310
+ }
311
+ function Xe(t, e, n) {
312
+ for (var o = 0, i = n.length; o < i; ) {
313
+ if (t(e, n[o]))
314
+ return !0;
315
+ o += 1;
316
+ }
317
+ return !1;
318
+ }
319
+ function cn(t) {
320
+ var e = String(t).match(/^function (\w*)/);
321
+ return e == null ? "" : e[1];
322
+ }
323
+ function dn(t, e) {
324
+ return t === e ? t !== 0 || 1 / t === 1 / e : t !== t && e !== e;
325
+ }
326
+ const _e = typeof Object.is == "function" ? Object.is : dn;
327
+ function Ge(t, e, n, o) {
328
+ var i = ze(t), u = ze(e);
329
+ function h(w, l) {
330
+ return Ee(w, l, n.slice(), o.slice());
331
+ }
332
+ return !Xe(function(w, l) {
333
+ return !Xe(h, l, w);
334
+ }, u, i);
335
+ }
336
+ function Ee(t, e, n, o) {
337
+ if (_e(t, e))
338
+ return !0;
339
+ var i = qe(t);
340
+ if (i !== qe(e))
341
+ return !1;
342
+ if (typeof t["fantasy-land/equals"] == "function" || typeof e["fantasy-land/equals"] == "function")
343
+ return typeof t["fantasy-land/equals"] == "function" && t["fantasy-land/equals"](e) && typeof e["fantasy-land/equals"] == "function" && e["fantasy-land/equals"](t);
344
+ if (typeof t.equals == "function" || typeof e.equals == "function")
345
+ return typeof t.equals == "function" && t.equals(e) && typeof e.equals == "function" && e.equals(t);
346
+ switch (i) {
347
+ case "Arguments":
348
+ case "Array":
349
+ case "Object":
350
+ if (typeof t.constructor == "function" && cn(t.constructor) === "Promise")
351
+ return t === e;
352
+ break;
353
+ case "Boolean":
354
+ case "Number":
355
+ case "String":
356
+ if (!(typeof t == typeof e && _e(t.valueOf(), e.valueOf())))
357
+ return !1;
358
+ break;
359
+ case "Date":
360
+ if (!_e(t.valueOf(), e.valueOf()))
361
+ return !1;
362
+ break;
363
+ case "Error":
364
+ return t.name === e.name && t.message === e.message;
365
+ case "RegExp":
366
+ if (!(t.source === e.source && t.global === e.global && t.ignoreCase === e.ignoreCase && t.multiline === e.multiline && t.sticky === e.sticky && t.unicode === e.unicode))
367
+ return !1;
368
+ break;
369
+ }
370
+ for (var u = n.length - 1; u >= 0; ) {
371
+ if (n[u] === t)
372
+ return o[u] === e;
373
+ u -= 1;
374
+ }
375
+ switch (i) {
376
+ case "Map":
377
+ return t.size !== e.size ? !1 : Ge(t.entries(), e.entries(), n.concat([t]), o.concat([e]));
378
+ case "Set":
379
+ return t.size !== e.size ? !1 : Ge(t.values(), e.values(), n.concat([t]), o.concat([e]));
380
+ case "Arguments":
381
+ case "Array":
382
+ case "Object":
383
+ case "Boolean":
384
+ case "Number":
385
+ case "String":
386
+ case "Date":
387
+ case "Error":
388
+ case "RegExp":
389
+ case "Int8Array":
390
+ case "Uint8Array":
391
+ case "Uint8ClampedArray":
392
+ case "Int16Array":
393
+ case "Uint16Array":
394
+ case "Int32Array":
395
+ case "Uint32Array":
396
+ case "Float32Array":
397
+ case "Float64Array":
398
+ case "ArrayBuffer":
399
+ break;
400
+ default:
401
+ return !1;
402
+ }
403
+ var h = We(t);
404
+ if (h.length !== We(e).length)
405
+ return !1;
406
+ var w = n.concat([t]), l = o.concat([e]);
407
+ for (u = h.length - 1; u >= 0; ) {
408
+ var s = h[u];
409
+ if (!(ve(s, e) && Ee(e[s], t[s], w, l)))
410
+ return !1;
411
+ u -= 1;
412
+ }
413
+ return !0;
414
+ }
415
+ var Ye = /* @__PURE__ */ N(function(e, n) {
416
+ return Ee(e, n, [], []);
417
+ });
418
+ function fn(t) {
419
+ return Object.prototype.toString.call(t) === "[object Object]";
420
+ }
421
+ var pe = /* @__PURE__ */ N(function(e, n) {
422
+ return n == null || n !== n ? e : n;
423
+ });
424
+ function vn(t) {
425
+ var e = Object.prototype.toString.call(t);
426
+ return e === "[object Uint8ClampedArray]" || e === "[object Int8Array]" || e === "[object Uint8Array]" || e === "[object Int16Array]" || e === "[object Uint16Array]" || e === "[object Int32Array]" || e === "[object Uint32Array]" || e === "[object Float32Array]" || e === "[object Float64Array]" || e === "[object BigInt64Array]" || e === "[object BigUint64Array]";
427
+ }
428
+ var pn = /* @__PURE__ */ L(function(e) {
429
+ return e != null && typeof e["fantasy-land/empty"] == "function" ? e["fantasy-land/empty"]() : e != null && e.constructor != null && typeof e.constructor["fantasy-land/empty"] == "function" ? e.constructor["fantasy-land/empty"]() : e != null && typeof e.empty == "function" ? e.empty() : e != null && e.constructor != null && typeof e.constructor.empty == "function" ? e.constructor.empty() : ye(e) ? [] : me(e) ? "" : fn(e) ? {} : Ze(e) ? /* @__PURE__ */ function() {
430
+ return arguments;
431
+ }() : vn(e) ? e.constructor.from("") : void 0;
432
+ }), hn = /* @__PURE__ */ function() {
433
+ function t(e, n) {
434
+ this.xf = n, this.f = e, this.idx = -1, this.found = !1;
435
+ }
436
+ return t.prototype["@@transducer/init"] = Xt.init, t.prototype["@@transducer/result"] = function(e) {
437
+ return this.found || (e = this.xf["@@transducer/step"](e, -1)), this.xf["@@transducer/result"](e);
438
+ }, t.prototype["@@transducer/step"] = function(e, n) {
439
+ return this.idx += 1, this.f(n) && (this.found = !0, e = zt(this.xf["@@transducer/step"](e, this.idx))), e;
440
+ }, t;
441
+ }(), gn = /* @__PURE__ */ N(function(e, n) {
442
+ return new hn(e, n);
443
+ }), F = /* @__PURE__ */ N(
444
+ /* @__PURE__ */ Bt([], gn, function(e, n) {
445
+ for (var o = 0, i = n.length; o < i; ) {
446
+ if (e(n[o]))
447
+ return o;
448
+ o += 1;
449
+ }
450
+ return -1;
451
+ })
452
+ ), yn = /* @__PURE__ */ L(function(e) {
453
+ return e != null && Ye(e, pn(e));
454
+ }), x = /* @__PURE__ */ ge(function(e, n, o) {
455
+ return Ye(n, Y(e, o));
456
+ }), he = /* @__PURE__ */ ge(function(e, n, o) {
457
+ return pe(e, Y(n, o));
458
+ }), mn = /* @__PURE__ */ N(function(e, n) {
459
+ return Ce(e.length, function() {
460
+ try {
461
+ return e.apply(this, arguments);
462
+ } catch (o) {
463
+ return n.apply(this, Wt([o], arguments));
464
+ }
465
+ });
466
+ });
467
+ const Ke = "https://api.pennsieve.net", Qe = "https://api2.pennsieve.net", et = "wss://api.pennsieve.net/streaming/ts/query", tt = "https://api.pennsieve.net/streaming", wn = {
468
+ apiUrl: Ke,
469
+ api2Url: Qe,
470
+ timeSeriesUrl: et,
471
+ timeSeriesApi: tt
472
+ }, An = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
473
+ __proto__: null,
474
+ api2Url: Qe,
475
+ apiUrl: Ke,
476
+ default: wn,
477
+ timeSeriesApi: tt,
478
+ timeSeriesUrl: et
479
+ }, Symbol.toStringTag, { value: "Module" }));
480
+ async function fe() {
481
+ try {
482
+ return xt().then(
483
+ (t) => {
484
+ var e;
485
+ return (e = t == null ? void 0 : t.tokens) == null ? void 0 : e.accessToken.toString();
486
+ }
487
+ );
488
+ } catch (t) {
489
+ console.error(t);
490
+ }
491
+ }
492
+ const nt = Ft("tsviewer", () => {
493
+ const t = An, e = g([]), n = g("NOT_MONTAGED"), o = g({}), i = g([]), u = g(null), h = g(null), w = g({}), l = g([]), s = g({}), A = g({}), m = g("POINTER"), b = B(() => (a) => i.value.find((c) => c.name === a)), M = B(() => e.value.filter((a) => a.selected)), R = B(() => () => {
494
+ const a = l.value.find((c) => c.selected);
495
+ return a || (console.warn("No active layer found, available layers:", l.value), l.value.length > 0 ? l.value[0] : null);
496
+ }), _ = () => {
497
+ let a = !1;
498
+ return l.value.forEach((c, v) => {
499
+ !c.id && c.id !== 0 && (console.error(`Layer at index ${v} missing ID:`, c), a = !0), c.annotations || (console.warn(`Layer at index ${v} missing annotations array:`, c), c.annotations = []);
500
+ }), a && console.error("Annotation layer validation failed. Layers:", l.value), !a;
501
+ }, V = B(() => (a) => l.value.flatMap((v) => v.annotations || []).find((v) => v.id === a)), E = (a) => {
502
+ w.value = a;
503
+ }, P = (a) => {
504
+ e.value = a;
505
+ }, S = (a) => {
506
+ n.value = a;
507
+ }, p = (a) => {
508
+ o.value = a;
509
+ }, I = (a) => {
510
+ i.value = a;
511
+ }, $ = (a) => {
512
+ u.value = a;
513
+ }, O = (a) => {
514
+ h.value = a;
515
+ }, C = async (a) => {
516
+ const c = a.packageId, v = await fe(), D = `https://api.pennsieve.net/packages/${c}?api_key=${v}`, ee = await useSendXhr(D);
517
+ if (z())
518
+ return E(ee), Promise.resolve(ee);
519
+ throw new Error("Timeseries viewer is not available, since the file is not processed");
520
+ }, z = () => (a) => {
521
+ var v;
522
+ return ((v = a == null ? void 0 : a.content) == null ? void 0 : v.state) === "READY";
523
+ }, X = (a) => {
524
+ const c = a.map((v) => (!v.id && v.id !== 0 && (console.warn("Annotation layer missing ID:", v), v.id = Math.random().toString(36).substr(2, 9)), v.annotations || (v.annotations = []), v.name || (v.name = `Layer ${v.id}`), v));
525
+ l.value = c, console.log("Set annotations with validated structure:", c);
526
+ }, k = (a) => {
527
+ if (!a && a !== 0) {
528
+ console.error("setActiveAnnotationLayer called with invalid layerId:", a);
529
+ return;
530
+ }
531
+ s.value = a, l.value.forEach((v) => v.selected = !1);
532
+ const c = F(x("id", a), l.value);
533
+ c >= 0 ? (l.value[c].selected = !0, console.log("Successfully set active layer:", l.value[c])) : console.error("Layer with ID not found:", a, "Available layers:", l.value);
534
+ }, U = (a) => {
535
+ if (l.value.forEach(
536
+ (c) => {
537
+ var v;
538
+ return (v = c.annotations) == null ? void 0 : v.forEach((D) => D.selected = !1);
539
+ }
540
+ ), a.id) {
541
+ const c = F(x("id", a.layer_id), l.value);
542
+ if (c >= 0) {
543
+ const v = F(x("id", a.id), l.value[c].annotations);
544
+ v >= 0 && (l.value[c].annotations[v].selected = !0);
545
+ }
546
+ }
547
+ A.value = a;
548
+ }, G = (a) => {
549
+ m.value = a;
550
+ }, K = (a) => {
551
+ if (!a.id && a.id !== 0) {
552
+ console.error("Cannot create layer without ID:", a);
553
+ return;
554
+ }
555
+ const c = {
556
+ id: a.id,
557
+ name: a.name || `Layer ${a.id}`,
558
+ description: a.description || "",
559
+ visible: a.visible !== void 0 ? a.visible : !0,
560
+ selected: a.selected || !1,
561
+ annotations: a.annotations || [],
562
+ color: a.color,
563
+ hexColor: a.hexColor,
564
+ bkColor: a.bkColor,
565
+ selColor: a.selColor,
566
+ userId: a.userId,
567
+ ...a
568
+ // Spread any additional properties
569
+ };
570
+ l.value.push(c), console.log("Created layer with validated structure:", c);
571
+ }, oe = (a) => {
572
+ const c = F(x("id", a.id), l.value);
573
+ if (c >= 0) {
574
+ const v = Object.assign(l.value[c], a);
575
+ l.value[c] = v;
576
+ }
577
+ }, W = (a) => {
578
+ const c = F(x("id", a.id), l.value);
579
+ c >= 0 && l.value.splice(c, 1);
580
+ }, Q = (a) => {
581
+ const c = F(x("id", a.layer_id), l.value);
582
+ c >= 0 && (l.value[c].annotations || (l.value[c].annotations = []), l.value[c].annotations.push(a), U(a));
583
+ }, q = (a) => {
584
+ const c = F(x("id", a.layer_id), l.value);
585
+ if (c >= 0) {
586
+ const v = l.value[c].annotations, D = F(x("id", a.id), v);
587
+ D >= 0 && (v[D] = a);
588
+ }
589
+ }, ae = (a) => {
590
+ const c = F(x("id", a.layer_id), l.value);
591
+ if (c >= 0) {
592
+ const v = l.value[c].annotations, D = F(x("id", a.id), v);
593
+ D >= 0 && v.splice(D, 1);
594
+ }
595
+ }, H = (a, c, v) => {
596
+ const D = e.value.find((ee) => ee.id === a);
597
+ D && (D[c] = v);
598
+ };
599
+ return {
600
+ // State
601
+ viewerChannels: e,
602
+ viewerMontageScheme: n,
603
+ customMontageMap: o,
604
+ workspaceMontages: i,
605
+ viewerErrors: u,
606
+ needsRerender: h,
607
+ viewerAnnotations: l,
608
+ activeAnnotationLayer: s,
609
+ activeAnnotation: A,
610
+ activeViewer: w,
611
+ viewerActiveTool: m,
612
+ config: t,
613
+ // Getters
614
+ getMontageMessageByName: b,
615
+ viewerSelectedChannels: M,
616
+ getViewerActiveLayer: R,
617
+ getAnnotationById: V,
618
+ // Actions
619
+ setChannels: P,
620
+ setViewerMontageScheme: S,
621
+ setCustomMontageMap: p,
622
+ setWorkspaceMontages: I,
623
+ setViewerErrors: $,
624
+ setAnnotations: X,
625
+ setActiveAnnotationLayer: k,
626
+ setActiveAnnotation: U,
627
+ setActiveTool: G,
628
+ createLayer: K,
629
+ updateLayer: oe,
630
+ deleteLayer: W,
631
+ createAnnotation: Q,
632
+ updateAnnotation: q,
633
+ deleteAnnotation: ae,
634
+ updateChannelProperty: H,
635
+ updateChannelVisibility: (a, c) => {
636
+ H(a, "visible", c);
637
+ },
638
+ updateChannelSelection: (a, c) => {
639
+ H(a, "selected", c);
640
+ },
641
+ updateChannelFilter: (a, c) => {
642
+ H(a, "filter", c);
643
+ },
644
+ validateAnnotationLayers: _,
645
+ resetViewer: () => {
646
+ e.value = [], n.value = "NOT_MONTAGED", o.value = {}, i.value = [], u.value = null, l.value = [], s.value = {}, A.value = {}, m.value = "POINTER", w.value = {};
647
+ },
648
+ triggerRerender: (a) => {
649
+ O({
650
+ timestamp: Date.now(),
651
+ cause: a
652
+ });
653
+ },
654
+ resetRerenderTrigger: () => {
655
+ h.value = null;
656
+ },
657
+ isTSFileProcessed: z,
658
+ fetchAndSetActiveViewer: C,
659
+ setActiveViewer: E
660
+ };
661
+ });
662
+ function Tn(t) {
663
+ if (useRoute().name === "docs-login")
664
+ return;
665
+ pe(!1, Y("shouldShowToast", t));
666
+ const n = pe(!1, Y("shouldRedirect", t));
667
+ this.clearState(), n && this.$route.fullPath;
668
+ }
669
+ const In = (t) => Object.prototype.toString.call(t) === "[object String]", Sn = (t) => {
670
+ Object.keys(t).forEach((e) => {
671
+ In(t[e]) && (t[e] = t[e].trim());
672
+ });
673
+ };
674
+ function jn(t, e) {
675
+ if (!t)
676
+ return Promise.reject({ status: 400, message: "Url is missing!" });
677
+ const n = he("GET", "method", e), o = he({}, "header", e), i = Object.assign({}, { "Content-type": "application/json" }, o), u = Y("body", e);
678
+ let h = { headers: i, method: n };
679
+ if (u) {
680
+ typeof u == "object" && Sn(u);
681
+ const w = JSON.stringify(u);
682
+ h = Object.assign({}, h, { body: w });
683
+ }
684
+ return fetch(t, h).then((w) => w.status >= 400 ? Promise.reject(w) : w.json().catch(() => w));
685
+ }
686
+ function be(t) {
687
+ const e = Y("status", t);
688
+ let n;
689
+ if (e === void 0) {
690
+ console.log(t);
691
+ return;
692
+ } else
693
+ n = t.status;
694
+ if (n === 400 && t.body)
695
+ t.body.getReader().read().then(({ done: o, value: i }) => {
696
+ const u = i instanceof Uint8Array ? String.fromCharCode.apply(null, i) : i;
697
+ Be(pe(u), mn(Be(Y("message"), JSON.parse), (h, w) => w))(u);
698
+ });
699
+ else if (n === 401)
700
+ return Tn();
701
+ }
702
+ function _n() {
703
+ const t = nt(), { viewerChannels: e, viewerAnnotations: n } = He(t), o = (l) => l.id || "", i = (l) => {
704
+ l.sort(function(A, m) {
705
+ return A.start < m.start ? -1 : A.start > m.start ? 1 : 0;
706
+ });
707
+ };
708
+ return {
709
+ // Computed properties
710
+ viewerChannels: e,
711
+ // Now from Pinia
712
+ viewerAnnotations: n,
713
+ // Now from Pinia
714
+ // Methods
715
+ addAnnotation: async (l = null) => {
716
+ const s = l || activeAnnotation.value;
717
+ if (console.log("🔧 useTsAnnotation: addAnnotation called with:", s), !s || !s.layer_id)
718
+ throw new TypeError("Missing annotation data or layer_id", s);
719
+ if (s.id)
720
+ throw new TypeError("Trying to create an annotation that already exists", s.id);
721
+ let A = s.start, m = s.duration || s.end - s.start;
722
+ const b = s.label, M = s.description, R = s.layer_id;
723
+ if (!b)
724
+ throw new Error("Annotation label is required");
725
+ if (A == null)
726
+ throw new Error("Annotation start time is required");
727
+ m < 0 && (m = -m, A = A - m);
728
+ let _ = [];
729
+ if (console.log("🔧 useTsAnnotation: Processing channelIds...", {
730
+ hasChannelIds: s.channelIds && Array.isArray(s.channelIds),
731
+ allChannels: s.allChannels,
732
+ providedChannelIds: s.channelIds,
733
+ availableChannels: e.value.length
734
+ // Now from Pinia
735
+ }), s.allChannels) {
736
+ console.log("🔧 useTsAnnotation: allChannels=true, adding all visible channels");
737
+ const S = t.activeViewer.value.channels;
738
+ for (let p = 0; p < S.length; p++) {
739
+ const $ = S[p].content.id;
740
+ _.push($), console.log("🔧 useTsAnnotation: Added channel ID:", $);
741
+ }
742
+ } else if (s.channelIds && Array.isArray(s.channelIds) && s.channelIds.length > 0)
743
+ _ = s.channelIds, console.log("🔧 useTsAnnotation: Using provided channelIds:", _);
744
+ else {
745
+ console.log("🔧 useTsAnnotation: Computing from selected channels");
746
+ for (let S = 0; S < e.value.length; S++) {
747
+ const p = e.value[S];
748
+ if (p.selected && p.visible) {
749
+ const I = o(p);
750
+ _.push(I), console.log("🔧 useTsAnnotation: Added selected channel ID:", I);
751
+ }
752
+ }
753
+ }
754
+ console.log("🔧 useTsAnnotation: Final channelIds:", _);
755
+ const V = {
756
+ label: b,
757
+ name: b,
758
+ description: M || "",
759
+ start: Math.floor(A),
760
+ end: Math.floor(A + m),
761
+ channelIds: _
762
+ };
763
+ console.log("🔧 useTsAnnotation: API payload:", V);
764
+ const E = t.activeViewer.value.content.id, P = `${t.config.apiUrl}/timeseries/${E}/layers/${R}/annotations`;
765
+ console.log("🔧 useTsAnnotation: API URL:", P);
766
+ try {
767
+ const S = await fe(), p = await fetch(`${P}?api_key=${S}`, {
768
+ method: "POST",
769
+ headers: {
770
+ "Content-Type": "application/json",
771
+ Accept: "application/json"
772
+ },
773
+ body: JSON.stringify(V)
774
+ });
775
+ if (!p.ok) {
776
+ const C = await p.text();
777
+ throw new Error(`HTTP ${p.status}: ${C}`);
778
+ }
779
+ const I = await p.json();
780
+ console.log("🔧 useTsAnnotation: API success:", I);
781
+ const $ = {
782
+ name: "",
783
+ id: I.id,
784
+ label: I.label,
785
+ description: I.description,
786
+ start: I.start,
787
+ duration: I.end - I.start,
788
+ end: I.end,
789
+ cStart: null,
790
+ cEnd: null,
791
+ selected: !0,
792
+ channelIds: I.channelIds || _,
793
+ allChannels: _.length === 0 || _.length >= e.value.length,
794
+ // Use Pinia
795
+ layer_id: R,
796
+ userId: I.userId
797
+ };
798
+ I.linkedPackage && ($.linkedPackage = I.linkedPackage);
799
+ let O = 0;
800
+ for (let C = 0; C < n.value.length; C++)
801
+ if (n.value[C].id === R) {
802
+ O = C;
803
+ break;
804
+ }
805
+ return t.createAnnotation($), n.value[O] && n.value[O].annotations && i(n.value[O].annotations), $;
806
+ } catch (S) {
807
+ throw console.error("🔧 useTsAnnotation: Error creating annotation:", S), be(S), S;
808
+ }
809
+ },
810
+ updateAnnotation: async (l = null) => {
811
+ const s = l || activeAnnotation.value;
812
+ if (console.log("🔧 useTsAnnotation: updateAnnotation called with:", s), !s.id)
813
+ throw new TypeError("Trying to update an annotation that doesn't exist on server", s.id);
814
+ if (!s.layer_id)
815
+ throw new TypeError("Missing layer_id for annotation update", s);
816
+ let A = s.start, m = s.duration || s.end - s.start;
817
+ m < 0 && (m = -m, A = A - m);
818
+ const b = {
819
+ label: s.label,
820
+ description: s.description || "",
821
+ start: Math.floor(A),
822
+ end: Math.floor(A + m),
823
+ channelIds: s.channelIds || []
824
+ };
825
+ console.log("🔧 useTsAnnotation: Update API payload:", b);
826
+ const M = t.activeViewer.value.content.id, R = `${t.config.apiUrl}/timeseries/${M}/layers/${s.layer_id}/annotations/${s.id}`;
827
+ console.log("🔧 useTsAnnotation: Update API URL:", R);
828
+ try {
829
+ const _ = await fe(), V = await fetch(`${R}?api_key=${_}`, {
830
+ method: "PUT",
831
+ headers: {
832
+ "Content-Type": "application/json",
833
+ Accept: "application/json"
834
+ },
835
+ body: JSON.stringify(b)
836
+ });
837
+ if (!V.ok) {
838
+ const S = await V.text();
839
+ throw new Error(`HTTP ${V.status}: ${S}`);
840
+ }
841
+ const E = await V.json();
842
+ console.log("🔧 useTsAnnotation: Update API success:", E);
843
+ const P = {
844
+ ...s,
845
+ ...E,
846
+ duration: E.end - E.start
847
+ };
848
+ return t.updateAnnotation(P), E;
849
+ } catch (_) {
850
+ throw console.error("🔧 useTsAnnotation: Error updating annotation:", _), be(_), _;
851
+ }
852
+ },
853
+ removeAnnotation: async (l) => {
854
+ if (!l || !l.id)
855
+ throw new TypeError("Invalid annotation for deletion", l);
856
+ let s = "";
857
+ if (l.layer ? s = l.layer.id : s = l.layer_id, !s)
858
+ throw new TypeError("Missing layer_id for annotation deletion", l);
859
+ const A = t.activeViewer.value.content.id, m = `${t.config.apiUrl}/timeseries/${A}/layers/${s}/annotations/${l.id}`;
860
+ console.log("🔧 useTsAnnotation: Delete API URL:", m);
861
+ try {
862
+ const b = await fe(), M = await fetch(`${m}?api_key=${b}`, {
863
+ method: "DELETE",
864
+ headers: {
865
+ Accept: "application/json"
866
+ }
867
+ });
868
+ if (!M.ok) {
869
+ const R = await M.text();
870
+ throw new Error(`HTTP ${M.status}: ${R}`);
871
+ }
872
+ return console.log("🔧 useTsAnnotation: Delete API success"), t.deleteAnnotation(l), !0;
873
+ } catch (b) {
874
+ throw console.error("🔧 useTsAnnotation: Error deleting annotation:", b), be(b), b;
875
+ }
876
+ },
877
+ sortAnns: i,
878
+ getChannelId: o
879
+ };
880
+ }
881
+ const bn = (t, e) => {
882
+ const n = t.__vccOpts || t;
883
+ for (const [o, i] of e)
884
+ n[o] = i;
885
+ return n;
886
+ }, Cn = { id: "channelCanvas" }, En = ["data-id"], On = ["hidden"], Pn = ["hidden"], Ln = {
887
+ __name: "TSViewer",
888
+ props: {
889
+ pkg: {
890
+ type: Object,
891
+ default: () => {
892
+ }
893
+ },
894
+ isPreview: {
895
+ type: Boolean,
896
+ default: !1
897
+ },
898
+ sidePanelOpen: {
899
+ type: Boolean,
900
+ default: !1
901
+ }
902
+ },
903
+ setup(t, { expose: e }) {
904
+ const n = Z(() => import("./TSScrubber-DV_zbLFM.mjs")), o = Z(() => import("./TSViewerCanvas-B-p1oLEz.mjs").then((r) => r.T)), i = Z(() => import("./TSViewerToolbar-CCQsR6PP.mjs")), u = Z(() => import("./TSFilterModal-D_p4VsMp.mjs")), h = Z(() => import("./TSAnnotationModal-CTcapLT8.mjs")), w = Z(() => import("./TsAnnotationDeleteDialog-DXn1tyay.mjs")), l = Z(() => import("./TSViewerLayerWindow-MwCEfh1O.mjs")), s = {
905
+ TIMEUNIT: "microSeconds",
906
+ // Basis for time
907
+ XOFFSET: 0,
908
+ // X-offset of graph in canvas
909
+ XGRIDSPACING: 1e6,
910
+ // Time in microseconds between vertical lines
911
+ NRPXPERLABEL: 150,
912
+ // Number of pixels per label on x-axis
913
+ USEREALTIME: !0,
914
+ // If true than interpret timepoints as UTC microseconds.
915
+ DEFAULTDPI: 96,
916
+ // Default pixels per inch
917
+ ANNOTATIONLABELHEIGHT: 20,
918
+ // Height of annotation label
919
+ ROUNDDATAPIXELS: !1,
920
+ // If true, canvas point will be rounded to integer pixels for faster render (faster)
921
+ MINMAXPOLYGON: !0,
922
+ // If true, then polygon is rendered thru minMax values, otherwise vertical lines (faster)
923
+ PAGESIZEDIVIDER: 0.5,
924
+ // Number of pages that span the current canvas.
925
+ PREFETCHPAGES: 5,
926
+ // Number of pages to read ahead of view.
927
+ LIMITANNFETCH: 500,
928
+ // Maximum number of annotations that are fetched per request
929
+ USEMEDIAN: !1,
930
+ // Use Median instead of mean for centering channels
931
+ CURSOROFFSET: 5,
932
+ // Offset of cursor canvas
933
+ SEGMENTSPAN: 12096e8,
934
+ // One week of gap-data is returned per request.
935
+ MAXRECURSION: 20,
936
+ // Maximum recursion depth of gap-data requests (max 2 years)
937
+ MAXDURATION: 6e8,
938
+ // Maximum duration window (5min)
939
+ INITDURATION: 15e6
940
+ // Initial duration window (15sec)
941
+ }, A = t, m = nt(), { viewerChannels: b, needsRerender: M } = He(m), {
942
+ addAnnotation: R,
943
+ updateAnnotation: _,
944
+ removeAnnotation: V
945
+ } = _n(), E = g(null), P = g(null), S = g(null), p = g(null), I = g(null), $ = g(null), O = g(null), C = g(null), z = g(0), X = g(0), k = g(0), U = g(0), G = g(0), K = g(0), oe = g(0), W = g(1), Q = g(1 / 10), q = g(!1), ae = g(!1), H = g(null), ie = g(!1), se = g(!1), le = B(() => m.activeViewer), Oe = B(() => b.value.map((r) => ({
946
+ ...r,
947
+ selected: !!r.selected
948
+ }))), we = B(() => Oe.value.filter((r) => r.visible)), Ae = B(() => {
949
+ let r = !1;
950
+ return K.value / a.value < 30 && (r = !0), r;
951
+ }), a = B(() => we.value.length), c = async () => {
952
+ if (console.log("onresize..."), !E.value)
953
+ return;
954
+ const r = document.getElementById("ts_viewer");
955
+ if (!r)
956
+ return;
957
+ const f = window.getComputedStyle(r, null), d = parseInt(f.getPropertyValue("height")), y = A.isPreview ? 0 : 100;
958
+ z.value = d - y, await ne(), X.value = E.value.offsetWidth;
959
+ const j = S.value;
960
+ j && (oe.value = j.clientWidth, G.value = X.value - j.clientWidth - 16, K.value = z.value - 40);
961
+ };
962
+ Te(() => le.value, async (r, f) => {
963
+ var d, y, j;
964
+ (d = P.value) != null && d.resetComponentState && P.value.resetComponentState(), r && r.channels && r.channels.length > 0 && De(), Ne(), await ne(), (y = P.value) != null && y.initSegmentSpans && P.value.initSegmentSpans(), (j = P.value) != null && j.getAnnotations && P.value.getAnnotations();
965
+ }, { immediate: !1, deep: !0 }), Te(a, (r, f) => {
966
+ f !== void 0 && r !== f && (console.log(`Number of visible channels changed from ${f} to ${r}`), setTimeout(() => {
967
+ var d;
968
+ c(), (d = p.value) != null && d.renderAll && p.value.renderAll();
969
+ }, 20));
970
+ });
971
+ const v = (r) => {
972
+ store.dispatch("viewerModule/setActiveAnnotation", r).then(() => {
973
+ p.value.renderAnnotationCanvas(), q.value = !0;
974
+ });
975
+ };
976
+ Te(M, (r) => {
977
+ r && (console.log(`TSViewer: Re-rendering due to: ${r.cause} (${r.timestamp})`), ne(() => {
978
+ var f;
979
+ r.cause === "channel-visibility" ? setTimeout(() => {
980
+ var d;
981
+ c(), (d = p.value) != null && d.renderAll && p.value.renderAll();
982
+ }, 10) : (f = p.value) != null && f.renderAll && p.value.renderAll();
983
+ }), m.resetRerenderTrigger(null));
984
+ }, { deep: !0 });
985
+ const D = (r) => {
986
+ v(r);
987
+ }, ee = async (r) => {
988
+ if (console.log("📍 TSViewer: onCreateUpdateAnnotation received:", r), !r || Object.keys(r).length === 0) {
989
+ console.error("🚨 TSViewer: Received empty annotation!");
990
+ return;
991
+ }
992
+ if (!r.layer_id) {
993
+ console.error("🚨 TSViewer: annotation.layer_id is missing!", r);
994
+ return;
995
+ }
996
+ q.value = !1;
997
+ try {
998
+ r.id ? (console.log("📍 TSViewer: Updating annotation via composable"), await _(r), rt()) : (console.log("📍 TSViewer: Creating annotation via composable"), await R(r), lt()), console.log("📍 TSViewer: Annotation operation completed successfully");
999
+ } catch (f) {
1000
+ console.error("📍 TSViewer: Error creating/updating annotation:", f), q.value = !0;
1001
+ }
1002
+ }, rt = () => {
1003
+ p.value.renderAnnotationCanvas();
1004
+ }, ot = (r) => {
1005
+ H.value = r, ie.value = !0;
1006
+ }, at = async (r) => {
1007
+ ie.value = !1;
1008
+ try {
1009
+ await V(r), it(), console.log("📍 TSViewer: Annotation deleted successfully");
1010
+ } catch (f) {
1011
+ console.error("📍 TSViewer: Error deleting annotation:", f);
1012
+ }
1013
+ }, it = () => {
1014
+ p.value.renderAnnotationCanvas();
1015
+ }, st = (r, f, d, y, j, ue) => {
1016
+ if (console.log("📍 TSViewer: onAddAnnotation called with:", {
1017
+ startTime: r,
1018
+ duration: f,
1019
+ allChannels: d,
1020
+ label: y,
1021
+ description: j,
1022
+ layer: ue
1023
+ }), !ue || !ue.id) {
1024
+ console.error("Invalid layer provided to onAddAnnotation:", ue);
1025
+ return;
1026
+ }
1027
+ const kt = m.viewerSelectedChannels || [], Dt = d ? [] : kt.map((Nt) => Nt.id), Ue = {
1028
+ id: null,
1029
+ label: y || "Event",
1030
+ description: j || "",
1031
+ start: Math.floor(r),
1032
+ end: Math.floor(r + f),
1033
+ duration: Math.floor(f),
1034
+ channelIds: Dt,
1035
+ allChannels: d,
1036
+ layer_id: ue.id,
1037
+ selected: !0,
1038
+ userId: null
1039
+ };
1040
+ console.log("📍 TSViewer: Created annotation object:", Ue), m.setActiveAnnotation(Ue), console.log("📍 TSViewer: Store now contains:", m.activeAnnotation), q.value = !0, console.log("📍 TSViewer: Modal opened with annotation data");
1041
+ }, lt = () => {
1042
+ p.value.renderAnnotationCanvas();
1043
+ }, ut = (r) => {
1044
+ p.value.createAnnotationLayer(r);
1045
+ }, Pe = () => {
1046
+ ae.value = !1;
1047
+ }, ct = () => {
1048
+ p.value.resetFocusedAnnotation(), p.value.renderAnnotationCanvas(), q.value = !1;
1049
+ }, dt = () => {
1050
+ se.value = !1;
1051
+ }, ft = (r) => {
1052
+ r.stopPropagation(), r.preventDefault();
1053
+ const f = r.detail.sourceEvent.metaKey;
1054
+ Le({ channelId: r.currentTarget.dataset.id, append: f }), p.value.renderAll();
1055
+ }, vt = () => {
1056
+ k.value = p.value.getNextAnnotation();
1057
+ }, pt = () => {
1058
+ k.value = p.value.getPreviousAnnotation();
1059
+ }, ht = (r) => {
1060
+ ke(r * 1e6);
1061
+ }, gt = () => {
1062
+ W.value = W.value * 1.25;
1063
+ }, yt = () => {
1064
+ W.value = W.value * 0.8;
1065
+ }, mt = () => {
1066
+ P.value.getAnnotations();
1067
+ }, wt = () => {
1068
+ }, At = () => {
1069
+ console.log("Page forward triggered from toolbar");
1070
+ const r = Math.max(
1071
+ k.value - 3 / 4 * U.value,
1072
+ O.value
1073
+ );
1074
+ te(r), ne(() => {
1075
+ var f;
1076
+ (f = p.value) == null || f.renderAll();
1077
+ });
1078
+ }, Tt = () => {
1079
+ console.log("Page forward triggered from toolbar");
1080
+ const r = Math.min(
1081
+ k.value + 3 / 4 * U.value,
1082
+ C.value - U.value
1083
+ );
1084
+ console.log(`Moving from ${k.value} to ${r}`), te(r), ne(() => {
1085
+ var f, d;
1086
+ (f = p.value) != null && f.invalidate && p.value.invalidate(), (d = p.value) != null && d.renderAll && p.value.renderAll();
1087
+ });
1088
+ }, It = (r) => {
1089
+ let f = p.value.rsPeriod;
1090
+ te(r.annotation.start - (Q.value * G.value - s.CURSOROFFSET) * f), ne(() => {
1091
+ var d;
1092
+ (d = p.value) == null || d.renderAll();
1093
+ });
1094
+ }, Le = (r) => {
1095
+ const f = b.value.map((d) => {
1096
+ const y = d.selected;
1097
+ return r.append === !1 && (d.selected = !1), r.channelId === d.id && (d.selected = !y), d;
1098
+ });
1099
+ m.setChannels(f);
1100
+ }, St = (r, f) => {
1101
+ const d = b.value.map((y) => (f === !1 && (y.selected = !1), y.id in r && (y.selected = !0), y));
1102
+ m.setChannels(d);
1103
+ }, te = (r) => {
1104
+ k.value = r;
1105
+ }, _t = (r) => {
1106
+ Q.value = r;
1107
+ }, bt = (r) => {
1108
+ W.value = r;
1109
+ }, ke = (r) => {
1110
+ r > s.MAXDURATION ? U.value = s.MAXDURATION : U.value = r;
1111
+ }, Ct = (r, f, d) => (s.DEFAULTDPI * window.devicePixelRatio / (f * d) / 25.4).toFixed(1) + " " + r.unit + "/mm", De = () => {
1112
+ var f;
1113
+ const r = (f = le.value) == null ? void 0 : f.channels;
1114
+ if (console.log("🔄 initTimeRange called with channels:", (r == null ? void 0 : r.length) || 0), r && r.length > 0) {
1115
+ O.value = r[0].content.start, C.value = r[0].content.end;
1116
+ for (let y = 1; y < r.length; y++)
1117
+ r[y].content.start < O.value && (O.value = r[y].content.start), r[y].content.end > C.value && (C.value = r[y].content.end);
1118
+ const d = k.value;
1119
+ k.value = O.value, console.log("📅 Time range initialized:", {
1120
+ ts_start: O.value,
1121
+ ts_end: C.value,
1122
+ oldStart: d,
1123
+ newStart: k.value,
1124
+ duration: U.value,
1125
+ startDate: new Date(O.value / 1e3).toISOString(),
1126
+ endDate: new Date(C.value / 1e3).toISOString()
1127
+ });
1128
+ } else
1129
+ console.warn("⚠️ initTimeRange: No channels found in activeViewer");
1130
+ }, Et = () => {
1131
+ De();
1132
+ }, Ot = (r) => {
1133
+ ae.value = !0;
1134
+ }, Pt = (r) => {
1135
+ const f = he([], "channels", r), d = he("", "filter", r), y = I.value;
1136
+ y.onChannels = f, yn(d) ? (y.input0 = NaN, y.input1 = NaN, y.selectedFilter = null, y.selectedNotch = null) : (y.input0 = d.input0, y.input1 = d.input1), se.value = !0;
1137
+ }, Lt = (r) => {
1138
+ p.value.setFilters(r);
1139
+ }, Ne = () => {
1140
+ var r, f;
1141
+ (r = p.value) == null || r.initViewerCanvas(), (f = p.value) == null || f.renderAll();
1142
+ };
1143
+ return Ut(() => {
1144
+ Et();
1145
+ const r = document.getElementById("ts_viewer");
1146
+ if (!r) {
1147
+ console.warn("ts_viewer element not found");
1148
+ return;
1149
+ }
1150
+ var f = window.getComputedStyle(r, null);
1151
+ const d = parseInt(f.getPropertyValue("height")), y = A.isPreview ? 0 : 100;
1152
+ z.value = d - y, E.value && (X.value = E.value.offsetWidth), window.addEventListener("resize", c);
1153
+ const j = S.value;
1154
+ j && (oe.value = j.clientWidth, G.value = X.value - j.clientWidth - 5 - 10, K.value = z.value - 88), U.value = s.INITDURATION, Ne();
1155
+ }), jt(() => {
1156
+ window.removeEventListener("resize", c);
1157
+ }), e({
1158
+ openEditAnnotationDialog: v,
1159
+ confirmDeleteAnnotation: ot,
1160
+ selectAnnotation: It,
1161
+ selectChannel: Le,
1162
+ selectChannels: St,
1163
+ openLayerWindow: Ot,
1164
+ openFilterWindow: Pt,
1165
+ setTimeseriesFilters: Lt
1166
+ }), (r, f) => (de(), Ie("div", {
1167
+ id: "ts_viewer",
1168
+ ref_key: "ts_viewer",
1169
+ ref: E,
1170
+ class: Se([t.isPreview ? "timeseries-viewer preview" : "timeseries-viewer"])
1171
+ }, [
1172
+ re(J(n), {
1173
+ ref_key: "scrubber",
1174
+ ref: P,
1175
+ ts_start: O.value,
1176
+ ts_end: C.value,
1177
+ "c-width": G.value,
1178
+ "label-width": oe.value,
1179
+ "cursor-loc": Q.value,
1180
+ start: k.value,
1181
+ duration: U.value,
1182
+ constants: s,
1183
+ "active-viewer": le.value,
1184
+ onSetStart: te
1185
+ }, null, 8, ["ts_start", "ts_end", "c-width", "label-width", "cursor-loc", "start", "duration", "active-viewer"]),
1186
+ ce("div", Cn, [
1187
+ ce("div", {
1188
+ id: "channelLabels",
1189
+ ref_key: "channelLabels",
1190
+ ref: S
1191
+ }, [
1192
+ (de(!0), Ie(Vt, null, $t(we.value, (d) => (de(), Ie("div", {
1193
+ key: d.displayName,
1194
+ class: "chLabelWrap",
1195
+ "data-id": d.id,
1196
+ onTap: ft
1197
+ }, [
1198
+ ce("div", {
1199
+ class: Se([d.selected ? "labelDiv selected" : "labelDiv"])
1200
+ }, je(d.displayName), 3),
1201
+ ce("div", {
1202
+ class: Se(["chLabelIndWrap", [d.selected ? "selected" : ""]]),
1203
+ hidden: Ae.value
1204
+ }, [
1205
+ ce("div", {
1206
+ class: "chLabelInd",
1207
+ hidden: Ae.value
1208
+ }, je(Ct(d, W.value, d.rowScale)), 9, Pn)
1209
+ ], 10, On)
1210
+ ], 40, En))), 128))
1211
+ ], 512),
1212
+ re(J(o), {
1213
+ ref_key: "viewerCanvas",
1214
+ ref: p,
1215
+ window_height: z.value,
1216
+ window_width: X.value,
1217
+ duration: U.value,
1218
+ start: k.value,
1219
+ "c-width": G.value,
1220
+ "c-height": K.value,
1221
+ constants: s,
1222
+ "ts-start": O.value,
1223
+ "ts-end": C.value,
1224
+ "cursor-loc": Q.value,
1225
+ "global-zoom-mult": W.value,
1226
+ "active-viewer": le.value,
1227
+ onSetStart: te,
1228
+ onSetCursor: _t,
1229
+ onSetGlobalZoom: bt,
1230
+ onSetDuration: ke,
1231
+ onChannelsInitialized: wt,
1232
+ onAnnLayersInitialized: mt,
1233
+ onCloseAnnotationLayerWindow: Pe,
1234
+ onAddAnnotation: st,
1235
+ onUpdateAnnotation: D
1236
+ }, null, 8, ["window_height", "window_width", "duration", "start", "c-width", "c-height", "ts-start", "ts-end", "cursor-loc", "global-zoom-mult", "active-viewer"])
1237
+ ]),
1238
+ t.isPreview ? Mt("", !0) : (de(), Rt(J(i), {
1239
+ key: 0,
1240
+ constants: s,
1241
+ duration: U.value,
1242
+ start: k.value,
1243
+ onPageBack: At,
1244
+ onPageForward: Tt,
1245
+ onIncrementZoom: gt,
1246
+ onDecrementZoom: yt,
1247
+ onUpdateDuration: ht,
1248
+ onNextAnnotation: vt,
1249
+ onPreviousAnnotation: pt,
1250
+ onSetStart: te
1251
+ }, null, 8, ["duration", "start"])),
1252
+ re(J(u), {
1253
+ ref_key: "filterWindow",
1254
+ ref: I,
1255
+ visible: se.value,
1256
+ "onUpdate:visible": f[0] || (f[0] = (d) => se.value = d),
1257
+ onCloseWindow: dt
1258
+ }, null, 8, ["visible"]),
1259
+ re(J(h), {
1260
+ ref_key: "annotationModal",
1261
+ ref: $,
1262
+ visible: q.value,
1263
+ "onUpdate:visible": f[1] || (f[1] = (d) => q.value = d),
1264
+ onCloseWindow: ct,
1265
+ onCreateUpdateAnnotation: ee
1266
+ }, null, 8, ["visible"]),
1267
+ re(J(w), {
1268
+ visible: ie.value,
1269
+ "delete-annotation": H.value,
1270
+ "onUpdate:visible": f[2] || (f[2] = (d) => ie.value = d),
1271
+ onDelete: at
1272
+ }, null, 8, ["visible", "delete-annotation"]),
1273
+ re(J(l), {
1274
+ visible: ae.value,
1275
+ onCloseWindow: Pe,
1276
+ onCreateLayer: ut
1277
+ }, null, 8, ["visible"])
1278
+ ], 2));
1279
+ }
1280
+ }, kn = /* @__PURE__ */ bn(Ln, [["__scopeId", "data-v-dfcd02cc"]]), Rn = {
1281
+ install(t) {
1282
+ t.component("TSViewer", kn);
1283
+ }
1284
+ };
1285
+ export {
1286
+ kn as T,
1287
+ T as _,
1288
+ Ce as a,
1289
+ N as b,
1290
+ L as c,
1291
+ Xt as d,
1292
+ Bt as e,
1293
+ Kt as f,
1294
+ bn as g,
1295
+ fe as h,
1296
+ jn as i,
1297
+ be as j,
1298
+ We as k,
1299
+ zt as l,
1300
+ x as m,
1301
+ nn as n,
1302
+ pe as o,
1303
+ he as p,
1304
+ tn as q,
1305
+ ge as r,
1306
+ Rn as s,
1307
+ nt as u
1308
+ };