@esrf/daiquiri-lib 0.1.0 → 1.0.0

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/index.mjs ADDED
@@ -0,0 +1,1691 @@
1
+ import { jsxs as l, jsx as r, Fragment as v } from "react/jsx-runtime";
2
+ import { map as C, each as ve } from "lodash";
3
+ import { Badge as D, ButtonGroup as oe, Button as y, OverlayTrigger as F, Popover as b, Container as $, Row as P, Col as E, Form as N, InputGroup as M, Alert as x, Tab as be, Tabs as te, Tooltip as Ne } from "react-bootstrap";
4
+ import { forwardRef as Ce, useRef as R, useState as k, useEffect as j, Component as se, Fragment as U, Children as Oe, isValidElement as Se, cloneElement as Ee, Suspense as ne, useMemo as xe, createElement as Me } from "react";
5
+ import T from "classnames";
6
+ import Ae from "debug";
7
+ function ke(e) {
8
+ const {
9
+ activeMessage: t = "Online",
10
+ inactiveMessage: n = "Offline",
11
+ message: i = "This device is"
12
+ } = e;
13
+ return /* @__PURE__ */ r(
14
+ "div",
15
+ {
16
+ className: `dot-indicator small bg-${e.online ? "success" : "danger"}`,
17
+ title: `${i} ${e.online ? t : n}`
18
+ }
19
+ );
20
+ }
21
+ function I(e) {
22
+ const { name: t, icon: n } = e;
23
+ return /* @__PURE__ */ l("div", { className: "icon", title: t, children: [
24
+ /* @__PURE__ */ r("i", { className: `fa ${n}` }),
25
+ /* @__PURE__ */ r(ke, { ...e })
26
+ ] });
27
+ }
28
+ function Ie(e) {
29
+ const t = {
30
+ 24: "Y",
31
+ 21: "Z",
32
+ 18: "E",
33
+ 15: "P",
34
+ 12: "T",
35
+ 9: "G",
36
+ 6: "M",
37
+ 3: "k",
38
+ "-3": "m",
39
+ "-6": "µ",
40
+ "-9": "n",
41
+ "-12": "p",
42
+ "-15": "f",
43
+ "-18": "a",
44
+ "-21": "z",
45
+ "-24": "y"
46
+ }, n = Math.log(e) / Math.log(1e3), i = !Number.isInteger(n), a = 3 * Math.ceil(n - (i ? 1 : 0)), o = a === 0 ? "" : t[a];
47
+ return {
48
+ scalar: e * 10 ** -a,
49
+ prefix: o,
50
+ multiplier: 10 ** -a
51
+ };
52
+ }
53
+ function $e(e) {
54
+ return e.charAt(0).toUpperCase() + e.slice(1);
55
+ }
56
+ function le(e) {
57
+ if (e < 60)
58
+ return `${Math.round(e)} sec`;
59
+ const t = Math.round(e / 60), n = t % 60, i = Math.floor(t / 60);
60
+ return i ? `${i} hr ${n} min` : `${n} min`;
61
+ }
62
+ function De(e) {
63
+ return e > 0 ? (662607004e-42 * 299792458 / (e * 1e-10) / 160218e-24 * 1e-3).toFixed(4) : 0;
64
+ }
65
+ function Fe(e, t) {
66
+ return Number.parseFloat(e.toFixed(t));
67
+ }
68
+ const _t = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
69
+ __proto__: null,
70
+ formatEng: Ie,
71
+ round: Fe,
72
+ toEnergy: De,
73
+ toHoursMins: le,
74
+ ucfirst: $e
75
+ }, Symbol.toStringTag, { value: "Module" }));
76
+ function Re(e) {
77
+ const { hardware: t } = e;
78
+ function n(d) {
79
+ t.requestChange({
80
+ function: "reset"
81
+ });
82
+ }
83
+ const i = {
84
+ "Front End": "feitlk",
85
+ Experimental: "expitlk",
86
+ PSS: "pssitlk"
87
+ }, a = {
88
+ Current: `${t.properties.current.toFixed(1)} mA`,
89
+ Mode: t.properties.mode,
90
+ Refill: le(t.properties.refill),
91
+ Message: /* @__PURE__ */ r("pre", { children: t.properties.message })
92
+ };
93
+ function o(d) {
94
+ if (!(d in t.properties))
95
+ return "UNKNOWN";
96
+ const s = t.properties[d];
97
+ return !s || typeof s != "string" ? "UNKNOWN" : s;
98
+ }
99
+ return /* @__PURE__ */ r(
100
+ F,
101
+ {
102
+ trigger: "click",
103
+ rootClose: !0,
104
+ overlay: /* @__PURE__ */ l(b, { id: "popid", children: [
105
+ /* @__PURE__ */ l(b.Header, { children: [
106
+ t.name,
107
+ " Details"
108
+ ] }),
109
+ /* @__PURE__ */ l(b.Body, { children: [
110
+ /* @__PURE__ */ r("h6", { children: "Status" }),
111
+ /* @__PURE__ */ r("pre", { children: t.properties.status }),
112
+ /* @__PURE__ */ r("h6", { children: "Interlocks" }),
113
+ /* @__PURE__ */ r($, { children: C(i, (d, s) => /* @__PURE__ */ l(P, { children: [
114
+ /* @__PURE__ */ l(E, { children: [
115
+ s,
116
+ ":"
117
+ ] }),
118
+ /* @__PURE__ */ r(E, { children: /* @__PURE__ */ r(
119
+ D,
120
+ {
121
+ bg: o(d) === "ON" ? "success" : "danger",
122
+ children: o(d)
123
+ }
124
+ ) })
125
+ ] }, s)) }),
126
+ /* @__PURE__ */ r("h6", { children: "Ring Status" }),
127
+ /* @__PURE__ */ r($, { children: C(a, (d, s) => /* @__PURE__ */ l(P, { children: [
128
+ /* @__PURE__ */ l(E, { children: [
129
+ s,
130
+ ":"
131
+ ] }),
132
+ /* @__PURE__ */ r(E, { children: d })
133
+ ] }, s)) }),
134
+ /* @__PURE__ */ r("div", { className: "d-grid gap-2", children: /* @__PURE__ */ r(y, { disabled: e.disabled, onClick: n, children: "Reset" }) })
135
+ ] })
136
+ ] }),
137
+ children: /* @__PURE__ */ r(y, { className: "flex-grow-0", title: "Shutter Details", children: /* @__PURE__ */ r("i", { className: "fa fa-ellipsis-h" }) })
138
+ }
139
+ );
140
+ }
141
+ function Pt(e) {
142
+ const { hardware: t, options: n = {} } = e;
143
+ function i(a) {
144
+ t.requestChange({
145
+ function: t.properties.frontend === "FE open" ? "close" : "open"
146
+ });
147
+ }
148
+ return /* @__PURE__ */ l("div", { className: "hw-component", children: [
149
+ /* @__PURE__ */ l("div", { className: "hw-head", children: [
150
+ /* @__PURE__ */ r(
151
+ I,
152
+ {
153
+ name: "Frontend",
154
+ icon: "fam-hardware-frontend",
155
+ online: t.online
156
+ }
157
+ ),
158
+ /* @__PURE__ */ r("div", { className: "name", children: t.name }),
159
+ /* @__PURE__ */ r(
160
+ D,
161
+ {
162
+ bg: t.properties.state === "OPEN" || t.properties.state === "RUNNING" ? "success" : "danger",
163
+ children: t.properties.state
164
+ }
165
+ )
166
+ ] }),
167
+ /* @__PURE__ */ r("div", { className: "hw-content", children: /* @__PURE__ */ l(oe, { className: "d-flex", children: [
168
+ /* @__PURE__ */ r(
169
+ y,
170
+ {
171
+ variant: t.properties.frontend === "FE open" ? "danger" : "success",
172
+ onClick: i,
173
+ disabled: e.disabled,
174
+ children: t.properties.frontend === "FE open" ? "Close" : "Open"
175
+ }
176
+ ),
177
+ /* @__PURE__ */ r(Re, { ...e })
178
+ ] }) })
179
+ ] });
180
+ }
181
+ function Vt(e) {
182
+ const { hardware: t, options: n = {} } = e;
183
+ function i() {
184
+ const a = n.property;
185
+ if (a === void 0)
186
+ return "property is not set";
187
+ if (a === null)
188
+ return "property is null";
189
+ let o = t;
190
+ for (const d of a.split("/"))
191
+ if (o = o[d], o === void 0)
192
+ return `property '${a}' not found`;
193
+ return `${o}`;
194
+ }
195
+ return /* @__PURE__ */ r(v, { children: i() });
196
+ }
197
+ function Y(e) {
198
+ const { headerMode: t, hardware: n } = e;
199
+ function i() {
200
+ return n.alias ? n.alias : n.name ? n.name : n.id;
201
+ }
202
+ const a = i();
203
+ switch (t) {
204
+ case "front":
205
+ return /* @__PURE__ */ r("div", { className: "hw-component", children: /* @__PURE__ */ l("div", { className: "hw-single", children: [
206
+ e.widgetIcon,
207
+ /* @__PURE__ */ r("div", { className: "name", children: a }),
208
+ /* @__PURE__ */ r("div", { className: "d-inline-block", children: e.widgetContent })
209
+ ] }) });
210
+ case "none":
211
+ return /* @__PURE__ */ r("div", { className: "hw-component", children: /* @__PURE__ */ r("div", { className: "hw-single", children: e.widgetContent }) });
212
+ case "state":
213
+ return e.widgetState;
214
+ default:
215
+ return /* @__PURE__ */ l("div", { className: "hw-component", children: [
216
+ /* @__PURE__ */ l("div", { className: "hw-head", children: [
217
+ e.widgetIcon,
218
+ /* @__PURE__ */ r("div", { className: "name", children: /* @__PURE__ */ r(N.Label, { htmlFor: n.id, children: a }) }),
219
+ e.widgetState,
220
+ e.hardware.errors && e.hardware.errors.length > 0 && /* @__PURE__ */ r(
221
+ F,
222
+ {
223
+ trigger: "click",
224
+ placement: "bottom",
225
+ rootClose: !0,
226
+ overlay: /* @__PURE__ */ l(b, { id: e.hardware.id, style: { maxWidth: 500 }, children: [
227
+ /* @__PURE__ */ r(b.Header, { children: "Device Errors" }),
228
+ /* @__PURE__ */ l(b.Body, { children: [
229
+ "There were errors with properties on this device:",
230
+ /* @__PURE__ */ r("ul", { children: e.hardware.errors.map((o) => /* @__PURE__ */ l("li", { children: [
231
+ o.property,
232
+ ":",
233
+ /* @__PURE__ */ l("span", { className: "stack-trace", children: [
234
+ o.traceback,
235
+ /* @__PURE__ */ r("br", {}),
236
+ o.exception
237
+ ] })
238
+ ] })) })
239
+ ] })
240
+ ] }),
241
+ children: /* @__PURE__ */ r(y, { variant: "danger", size: "sm", children: /* @__PURE__ */ r("i", { className: "fa fa-exclamation-triangle" }) })
242
+ }
243
+ )
244
+ ] }),
245
+ /* @__PURE__ */ r("div", { className: "hw-content", children: e.widgetContent })
246
+ ] });
247
+ }
248
+ }
249
+ function J(e) {
250
+ const t = {
251
+ display: "inline-block",
252
+ minWidth: ""
253
+ };
254
+ return e.minWidth && (t.minWidth = `${e.minWidth}em`), /* @__PURE__ */ r("div", { style: t, children: /* @__PURE__ */ r(D, { bg: e.variant, children: e.state }) });
255
+ }
256
+ function ce(e) {
257
+ const { hardware: t } = e;
258
+ function n() {
259
+ if (!t.online)
260
+ return "OFFLINE";
261
+ let a = "UNKNOWN";
262
+ return e.hardware.properties.state && ([a] = e.hardware.properties.state), a;
263
+ }
264
+ const i = n();
265
+ return /* @__PURE__ */ r(
266
+ J,
267
+ {
268
+ state: i,
269
+ minWidth: 6,
270
+ variant: i === "READY" ? "success" : "warning"
271
+ }
272
+ );
273
+ }
274
+ function de(e) {
275
+ const { hardware: t } = e;
276
+ function n() {
277
+ if (!t.online)
278
+ return "OFFLINE";
279
+ const o = t.properties.state;
280
+ return e.useReadyState && (o === "OPEN" || o === "CLOSED") ? "READY" : o;
281
+ }
282
+ const i = n();
283
+ function a() {
284
+ switch (i) {
285
+ case "READY":
286
+ return "success";
287
+ case "OPEN":
288
+ return "success";
289
+ case "CLOSED":
290
+ return "danger";
291
+ case "DISABLED":
292
+ return "secondary";
293
+ case "MOVING":
294
+ case "STANDBY":
295
+ case "OFFLINE":
296
+ return "warning";
297
+ case "FAULT":
298
+ return "fatal";
299
+ default:
300
+ return "fatal";
301
+ }
302
+ }
303
+ return /* @__PURE__ */ r(J, { state: i, minWidth: 6, variant: a() });
304
+ }
305
+ const Lt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
306
+ __proto__: null,
307
+ HardwareState: J,
308
+ MotorState: ce,
309
+ ShutterState: de
310
+ }, Symbol.toStringTag, { value: "Module" })), Te = Ce((e, t) => {
311
+ const n = R(null), [i, a] = k(e.step), o = (w) => {
312
+ const q = t;
313
+ if (n.current === null)
314
+ return;
315
+ let X = Number.parseFloat(q.current.value);
316
+ const ee = Number.parseFloat(n.current.value);
317
+ X += w ? ee : -ee, q.current.value = `${X}`, e.onStep && e.onStep({
318
+ target: q.current
319
+ });
320
+ }, {
321
+ onStep: d,
322
+ step: s,
323
+ overlay: h,
324
+ incIcon: u,
325
+ decIcon: c,
326
+ swapIncDec: f,
327
+ onKeyDown: m,
328
+ horizontalArrows: A,
329
+ largeArrows: z,
330
+ ...S
331
+ } = e, Q = (w) => {
332
+ w.key === "ArrowUp" ? (w.preventDefault(), o(!0)) : w.key === "ArrowDown" ? (w.preventDefault(), o(!1)) : m && m(w);
333
+ };
334
+ if (!e.step)
335
+ return /* @__PURE__ */ r(
336
+ N.Control,
337
+ {
338
+ ref: t,
339
+ type: "number",
340
+ step: "any",
341
+ onKeyDown: Q,
342
+ ...S
343
+ }
344
+ );
345
+ const ye = C(e.steps || [e.step], (w) => /* @__PURE__ */ r("option", { value: w, children: w }, w));
346
+ return /* @__PURE__ */ r(
347
+ "div",
348
+ {
349
+ className: T("numeric-step", {
350
+ "numeric-step-large": z,
351
+ "numeric-step-horizontal": A
352
+ }),
353
+ children: /* @__PURE__ */ l(M, { children: [
354
+ /* @__PURE__ */ r(
355
+ N.Control,
356
+ {
357
+ onKeyDown: Q,
358
+ ref: t,
359
+ type: "number",
360
+ step: "any",
361
+ ...S
362
+ }
363
+ ),
364
+ /* @__PURE__ */ l(v, { children: [
365
+ h,
366
+ !h && /* @__PURE__ */ l(M.Text, { className: "d-flex flex-column", children: [
367
+ /* @__PURE__ */ r(
368
+ N.Control,
369
+ {
370
+ ref: n,
371
+ as: "select",
372
+ className: "step-size",
373
+ defaultValue: i,
374
+ onChange: (w) => a(Number.parseFloat(w.target.value)),
375
+ children: ye
376
+ }
377
+ ),
378
+ e.unit && /* @__PURE__ */ r("div", { children: e.unit }),
379
+ !u && !c && /* @__PURE__ */ l(v, { children: [
380
+ /* @__PURE__ */ r(
381
+ y,
382
+ {
383
+ className: "step step-up",
384
+ disabled: e.disabled,
385
+ onClick: (w) => o(!0)
386
+ }
387
+ ),
388
+ /* @__PURE__ */ r(
389
+ y,
390
+ {
391
+ className: "step step-down",
392
+ disabled: e.disabled,
393
+ onClick: (w) => o(!1)
394
+ }
395
+ )
396
+ ] })
397
+ ] }),
398
+ c && f && /* @__PURE__ */ r(y, { disabled: e.disabled, onClick: (w) => o(!1), children: /* @__PURE__ */ r("i", { className: `fa fa-fw fa-${c}` }) }),
399
+ u && /* @__PURE__ */ r(y, { disabled: e.disabled, onClick: (w) => o(!0), children: /* @__PURE__ */ r("i", { className: `fa fa-fw fa-${u}` }) }),
400
+ c && !f && /* @__PURE__ */ r(y, { disabled: e.disabled, onClick: (w) => o(!1), children: /* @__PURE__ */ r("i", { className: `fa fa-fw fa-${c}` }) })
401
+ ] })
402
+ ] })
403
+ }
404
+ );
405
+ }), He = Te;
406
+ function _e(e) {
407
+ const t = R(null), [n, i] = k(!1), [a, o] = k(!1);
408
+ j(() => {
409
+ t.current && (e.hardwareValue === null ? t.current.value = "" : t.current.value = e.hardwareValue.toString(), i(!1));
410
+ }, [e.hardwareValue]);
411
+ function d(f) {
412
+ let m = f;
413
+ e.precision !== void 0 && (m = Number.parseFloat(m).toFixed(e.precision)), t != null && t.current && (t.current.value = m);
414
+ }
415
+ function s() {
416
+ n && setTimeout(() => {
417
+ d(e.hardwareValue), i(!1);
418
+ }, 3e3);
419
+ }
420
+ function h(f) {
421
+ e.hardwareValue !== null && (i(!0), t != null && t.current && (t.current.value = f.target.value), f.target.value === e.hardwareValue.toString() && i(!1));
422
+ }
423
+ function u(f) {
424
+ i(!1), e.onMoveRequested(f.target.value);
425
+ }
426
+ function c(f) {
427
+ switch (f.key) {
428
+ case "Enter":
429
+ {
430
+ i(!1);
431
+ const m = Number.parseFloat(f.target.value), A = e.onMoveRequested(m);
432
+ A && A.catch(() => {
433
+ o(!0), setTimeout(() => {
434
+ d(e.hardwareValue), o(!1);
435
+ }, 2e3);
436
+ });
437
+ }
438
+ f.preventDefault(), f.stopPropagation();
439
+ break;
440
+ case "Esc":
441
+ case "Escape":
442
+ n && (o(!1), i(!1), d(e.hardwareValue)), f.target.blur(), f.preventDefault(), f.stopPropagation();
443
+ break;
444
+ }
445
+ }
446
+ return /* @__PURE__ */ r(
447
+ He,
448
+ {
449
+ id: e.id,
450
+ className: T({
451
+ "form-control-edited": n,
452
+ "form-control-error": a,
453
+ "hw-moving": e.hardwareIsMoving
454
+ }),
455
+ type: e.readOnly ? "text" : "number",
456
+ ref: t,
457
+ precision: e.precision,
458
+ onChange: h,
459
+ onBlur: s,
460
+ onStep: u,
461
+ onKeyDown: c,
462
+ disabled: e.hardwareIsDisabled || e.readOnly || !e.hardwareIsReady,
463
+ step: e.step,
464
+ steps: e.steps,
465
+ incIcon: e.incIcon,
466
+ decIcon: e.decIcon,
467
+ swapIncDec: e.swapIncDec,
468
+ horizontalArrows: e.horizontalArrows,
469
+ largeArrows: e.largeArrows,
470
+ overlay: e.hardwareIsMoving && !e.hardwareIsDisabled ? /* @__PURE__ */ r(y, { variant: "danger", onClick: e.onAbortRequested, children: /* @__PURE__ */ r("i", { className: "fa fa-times" }) }) : null
471
+ }
472
+ );
473
+ }
474
+ function re(e) {
475
+ const t = R(null), [n, i] = k(!1), [a, o] = k(!1);
476
+ function d(c) {
477
+ return e.precision !== void 0 ? Number.parseFloat(c).toFixed(e.precision) : c;
478
+ }
479
+ j(() => {
480
+ var c;
481
+ t.current && (t.current.value = d((c = e.hardwareValue) == null ? void 0 : c.toString()), i(!1));
482
+ }, [e.hardwareValue, e.precision]);
483
+ function s(c) {
484
+ const f = d(c);
485
+ t != null && t.current && (t.current.value = f);
486
+ }
487
+ function h(c) {
488
+ switch (c.key) {
489
+ case "Enter": {
490
+ i(!1);
491
+ const f = Number.parseFloat(c.target.value), m = e.onMoveRequested(f);
492
+ m && m.catch(() => {
493
+ o(!0), setTimeout(() => {
494
+ s(e.hardwareValue), o(!1);
495
+ }, 2e3);
496
+ }), c.preventDefault(), c.stopPropagation();
497
+ break;
498
+ }
499
+ case "Esc":
500
+ case "Escape":
501
+ n && (o(!1), i(!1), s(e.hardwareValue)), c.target.blur(), c.preventDefault(), c.stopPropagation();
502
+ break;
503
+ }
504
+ }
505
+ function u(c) {
506
+ i(!0), c.target, t != null && t.current && (t.current.value = c.target.value), c.target.value === e.hardwareValue.toString() && i(!1);
507
+ }
508
+ return /* @__PURE__ */ r(
509
+ N.Control,
510
+ {
511
+ className: T({
512
+ "form-control-edited": n,
513
+ "form-control-error": a,
514
+ "hw-moving": e.hardwareIsMoving
515
+ }),
516
+ type: "number",
517
+ ref: t,
518
+ onChange: u,
519
+ onKeyDown: h,
520
+ disabled: e.readOnly || e.hardwareIsMoving || e.hardwareIsDisabled,
521
+ step: e.step
522
+ }
523
+ );
524
+ }
525
+ function Pe(e) {
526
+ function t(a) {
527
+ return e.hardware.requestChange({
528
+ property: "velocity",
529
+ value: a
530
+ });
531
+ }
532
+ function n(a) {
533
+ return e.hardware.requestChange({
534
+ property: "acceleration",
535
+ value: a
536
+ });
537
+ }
538
+ let i = "UNKNOWN";
539
+ return e.hardware.properties.state && ([i] = e.hardware.properties.state), /* @__PURE__ */ r(
540
+ F,
541
+ {
542
+ trigger: "click",
543
+ rootClose: !0,
544
+ overlay: /* @__PURE__ */ l(b, { id: "popid", children: [
545
+ /* @__PURE__ */ l(b.Header, { children: [
546
+ e.hardware.name,
547
+ " details"
548
+ ] }),
549
+ /* @__PURE__ */ l(b.Body, { children: [
550
+ /* @__PURE__ */ l(N.Group, { children: [
551
+ /* @__PURE__ */ r(N.Label, { children: "Velocity" }),
552
+ /* @__PURE__ */ r(
553
+ re,
554
+ {
555
+ hardwareValue: e.hardware.properties.velocity,
556
+ onMoveRequested: t,
557
+ hardwareIsDisabled: e.disabled,
558
+ hardwareIsReady: i === "READY",
559
+ hardwareIsMoving: i === "MOVING",
560
+ readOnly: e.readOnly
561
+ }
562
+ )
563
+ ] }),
564
+ /* @__PURE__ */ l(N.Group, { children: [
565
+ /* @__PURE__ */ r(N.Label, { children: "Acceleration" }),
566
+ /* @__PURE__ */ r(
567
+ re,
568
+ {
569
+ hardwareValue: e.hardware.properties.acceleration,
570
+ onMoveRequested: n,
571
+ hardwareIsDisabled: e.disabled,
572
+ hardwareIsReady: i === "READY",
573
+ hardwareIsMoving: i === "MOVING",
574
+ readOnly: e.readOnly
575
+ }
576
+ )
577
+ ] })
578
+ ] })
579
+ ] }),
580
+ children: /* @__PURE__ */ r(y, { children: /* @__PURE__ */ r("i", { className: "fa fa-ellipsis-h" }) })
581
+ }
582
+ );
583
+ }
584
+ function jt(e) {
585
+ const { hardware: t, options: n = {} } = e;
586
+ function i() {
587
+ t.requestChange({
588
+ function: "stop"
589
+ });
590
+ }
591
+ function a(u) {
592
+ return t.requestChange({
593
+ property: "position",
594
+ value: u,
595
+ function: "move"
596
+ });
597
+ }
598
+ let o = "UNKNOWN";
599
+ e.hardware.properties.state && ([o] = e.hardware.properties.state);
600
+ const d = /* @__PURE__ */ r(I, { name: "Motor", icon: "fam-hardware-motor", online: t.online }), s = /* @__PURE__ */ r(ce, { hardware: t }), h = e.options ? e.options.header : "top";
601
+ return /* @__PURE__ */ r(
602
+ Y,
603
+ {
604
+ hardware: t,
605
+ widgetIcon: d,
606
+ widgetState: s,
607
+ widgetContent: /* @__PURE__ */ l(M, { children: [
608
+ /* @__PURE__ */ r(
609
+ _e,
610
+ {
611
+ id: t.id,
612
+ hardwareValue: t.properties.position,
613
+ hardwareIsDisabled: e.disabled,
614
+ hardwareIsReady: o === "READY",
615
+ hardwareIsMoving: o === "MOVING",
616
+ onMoveRequested: a,
617
+ onAbortRequested: i,
618
+ precision: n.precision,
619
+ readOnly: n.readOnly,
620
+ step: n.step,
621
+ steps: n.steps,
622
+ incIcon: n.incicon,
623
+ decIcon: n.decicon,
624
+ swapIncDec: n.swapincdec,
625
+ horizontalArrows: n.horizontalarrows,
626
+ largeArrows: n.largearrows
627
+ }
628
+ ),
629
+ t.properties.unit && /* @__PURE__ */ r(M.Text, { children: t.properties.unit }),
630
+ o !== "MOVING" && n.extended && /* @__PURE__ */ r(
631
+ Pe,
632
+ {
633
+ hardware: t,
634
+ disabled: e.disabled,
635
+ readOnly: n.readOnly
636
+ }
637
+ ),
638
+ o === "MOVING" && !e.disabled && !n.step && /* @__PURE__ */ r(y, { variant: "danger", onClick: i, children: /* @__PURE__ */ r("i", { className: "fa fa-times" }) })
639
+ ] }),
640
+ headerMode: h
641
+ }
642
+ );
643
+ }
644
+ function Yt(e) {
645
+ const { hardware: t, options: n = {} } = e, i = R(null);
646
+ j(() => {
647
+ if (!i.current) {
648
+ console.error("selectionRef ref is unset");
649
+ return;
650
+ }
651
+ i.current.value = t.properties.position;
652
+ }, [t.properties.position]);
653
+ function a(s) {
654
+ if (console.debug("change", s), !i || !i.current) {
655
+ console.error("selection ref is unset");
656
+ return;
657
+ }
658
+ t.requestChange({
659
+ value: i.current.value,
660
+ function: "move"
661
+ });
662
+ }
663
+ function o(s) {
664
+ t.requestChange({
665
+ function: "stop"
666
+ });
667
+ }
668
+ const d = C(t.properties.positions, (s) => /* @__PURE__ */ r("option", { title: s.description, children: s.position }, s.position));
669
+ return /* @__PURE__ */ l("div", { className: "hw-component", children: [
670
+ /* @__PURE__ */ l("div", { className: "hw-head", children: [
671
+ /* @__PURE__ */ r(
672
+ I,
673
+ {
674
+ name: "Multiposition",
675
+ icon: "fam-hardware-multiposition",
676
+ online: t.online
677
+ }
678
+ ),
679
+ /* @__PURE__ */ r("div", { className: "name", children: t.name }),
680
+ /* @__PURE__ */ r(
681
+ D,
682
+ {
683
+ bg: t.properties.state === "READY" ? "success" : "warning",
684
+ children: t.properties.state
685
+ }
686
+ )
687
+ ] }),
688
+ /* @__PURE__ */ r("div", { className: "hw-content", children: /* @__PURE__ */ l(M, { children: [
689
+ /* @__PURE__ */ l(
690
+ N.Control,
691
+ {
692
+ className: "custom-select",
693
+ as: "select",
694
+ ref: i,
695
+ disabled: e.disabled,
696
+ defaultValue: t.properties.position,
697
+ children: [
698
+ /* @__PURE__ */ r("option", { disabled: !0, children: "unknown" }),
699
+ d
700
+ ]
701
+ }
702
+ ),
703
+ t.properties.state !== "MOVING" && /* @__PURE__ */ r(y, { onClick: a, disabled: e.disabled, children: "Move" }),
704
+ t.properties.state === "MOVING" && !e.disabled && /* @__PURE__ */ r(y, { variant: "danger", onClick: o, children: /* @__PURE__ */ r("i", { className: "fa fa-times" }) })
705
+ ] }) })
706
+ ] });
707
+ }
708
+ const Ve = Ae("daiquiri.components.hardware.NoObject");
709
+ function Kt(e) {
710
+ if (e.options.emptyifnone)
711
+ return Ve(
712
+ 'Component id:"%s" name:"%s" not displayed cause setup with emptyifnone.',
713
+ e.id,
714
+ e.name
715
+ ), /* @__PURE__ */ r(v, {});
716
+ const t = /* @__PURE__ */ r(I, { name: "NoObject", icon: "fam-hardware-any", online: !1 }), n = /* @__PURE__ */ r(v, {}), i = /* @__PURE__ */ r(v, { children: "Missing" }), a = e.options ? e.options.header : "top", o = {
717
+ id: e.id,
718
+ name: e.name ?? "",
719
+ alias: null,
720
+ online: !1,
721
+ properties: {},
722
+ type: ""
723
+ };
724
+ return /* @__PURE__ */ r(
725
+ Y,
726
+ {
727
+ hardware: o,
728
+ widgetIcon: t,
729
+ widgetState: n,
730
+ widgetContent: i,
731
+ headerMode: a
732
+ }
733
+ );
734
+ }
735
+ function Le(e) {
736
+ const t = e.online ? "READY" : "OFFLINE";
737
+ return /* @__PURE__ */ r(D, { bg: t === "READY" ? "success" : "warning", children: t });
738
+ }
739
+ function zt(e) {
740
+ const { hardware: t, options: n = {} } = e, i = /* @__PURE__ */ r(I, { name: "Optic", icon: "fa-cog", online: t.online }), a = /* @__PURE__ */ r(Le, { ...t });
741
+ function o() {
742
+ const c = n.property;
743
+ if (c === void 0)
744
+ return "property is not set";
745
+ if (c === null)
746
+ return "property is null";
747
+ let f = t;
748
+ for (const m of c.split("/"))
749
+ if (f = f[m], f === void 0)
750
+ return `property '${c}' not found`;
751
+ return `${f}`;
752
+ }
753
+ function d() {
754
+ const c = n.unit;
755
+ if (!c)
756
+ return null;
757
+ if (!c.includes("properties"))
758
+ return c;
759
+ let f = e;
760
+ for (const m of c.split("/"))
761
+ if (f = f[m], f === void 0)
762
+ return null;
763
+ return `${f}`;
764
+ }
765
+ const s = d(), h = /* @__PURE__ */ l(M, { children: [
766
+ /* @__PURE__ */ r(N.Control, { value: o(), readOnly: !0 }),
767
+ s && /* @__PURE__ */ r(M.Text, { children: s })
768
+ ] }), u = e.options.header || "top";
769
+ return /* @__PURE__ */ r(
770
+ Y,
771
+ {
772
+ hardware: t,
773
+ widgetIcon: i,
774
+ widgetState: a,
775
+ widgetContent: h,
776
+ headerMode: u
777
+ }
778
+ );
779
+ }
780
+ function je(e) {
781
+ const { hardware: t } = e, n = () => {
782
+ t.requestChange({
783
+ function: "reset"
784
+ });
785
+ };
786
+ return /* @__PURE__ */ r(
787
+ F,
788
+ {
789
+ trigger: "click",
790
+ rootClose: !0,
791
+ overlay: /* @__PURE__ */ l(b, { id: "popid", children: [
792
+ /* @__PURE__ */ l(b.Header, { children: [
793
+ t.name,
794
+ " Details"
795
+ ] }),
796
+ /* @__PURE__ */ l(b.Body, { children: [
797
+ /* @__PURE__ */ r("h6", { children: "Status" }),
798
+ /* @__PURE__ */ r("pre", { children: t.properties.status }),
799
+ /* @__PURE__ */ r("div", { className: "d-grid gap-2", children: /* @__PURE__ */ r(y, { onClick: n, disabled: e.disabled, children: "Reset" }) })
800
+ ] })
801
+ ] }),
802
+ children: /* @__PURE__ */ r(y, { className: "flex-grow-0", title: "Shutter Details", children: /* @__PURE__ */ r("i", { className: "fa fa-ellipsis-h" }) })
803
+ }
804
+ );
805
+ }
806
+ function qt(e) {
807
+ const { hardware: t, options: n = {} } = e, i = /* @__PURE__ */ r(
808
+ I,
809
+ {
810
+ name: "Shutter",
811
+ icon: "fam-hardware-shutter",
812
+ online: t.online
813
+ }
814
+ ), a = /* @__PURE__ */ r(de, { hardware: t });
815
+ function o() {
816
+ return t.properties ? t.properties.state : "UNKNOWN";
817
+ }
818
+ function d(S) {
819
+ return S === "OPEN" ? ["Close", "close"] : S === "CLOSED" ? ["Open", "open"] : S === "DISABLED" || S === "STANDBY" || S === "FAULT" ? ["Closed", ""] : S === "MOVING" ? ["...", ""] : ["Unknown", ""];
820
+ }
821
+ const s = o(), [h, u] = d(s), f = {
822
+ OPEN: "danger",
823
+ CLOSED: "success",
824
+ MOVING: "warning",
825
+ DISABLED: "secondary",
826
+ STANDBY: "danger",
827
+ FAULT: "fatal",
828
+ UNKNOWN: "warning"
829
+ }[s] || "danger";
830
+ function m() {
831
+ t.requestChange({
832
+ function: u
833
+ });
834
+ }
835
+ const A = /* @__PURE__ */ l(oe, { className: "d-flex flex-nowrap", children: [
836
+ /* @__PURE__ */ r(
837
+ y,
838
+ {
839
+ variant: f,
840
+ onClick: m,
841
+ disabled: e.disabled || u === "",
842
+ children: h
843
+ }
844
+ ),
845
+ n.extended && /* @__PURE__ */ r(je, { ...e })
846
+ ] }), z = e.options.header || "top";
847
+ return /* @__PURE__ */ r(
848
+ Y,
849
+ {
850
+ hardware: t,
851
+ widgetIcon: i,
852
+ widgetState: a,
853
+ widgetContent: A,
854
+ headerMode: z
855
+ }
856
+ );
857
+ }
858
+ class Ut extends se {
859
+ constructor() {
860
+ super(...arguments), this.variants = {};
861
+ }
862
+ render() {
863
+ let t = this.variants.default;
864
+ return this.props.options.variant in this.variants && (t = this.variants[this.props.options.variant]), /* @__PURE__ */ r(t, { ...this.props });
865
+ }
866
+ }
867
+ function Ye(e) {
868
+ const [t, n] = k({}), i = R(null);
869
+ return j(() => {
870
+ if (i.current) {
871
+ const a = i.current;
872
+ n({
873
+ width: a.clientWidth,
874
+ height: a.clientHeight
875
+ });
876
+ }
877
+ }, []), /* @__PURE__ */ r(
878
+ "div",
879
+ {
880
+ ref: i,
881
+ style: { width: "100%", height: "100%" },
882
+ className: e.className,
883
+ children: t.width > 0 && /* @__PURE__ */ r(
884
+ "div",
885
+ {
886
+ className: "full-sizer",
887
+ style: {
888
+ width: `${t.width}px`,
889
+ height: `${t.height}px`,
890
+ overflow: "scroll"
891
+ },
892
+ children: e.children
893
+ }
894
+ )
895
+ }
896
+ );
897
+ }
898
+ function Ke(e) {
899
+ return /* @__PURE__ */ r("div", { className: "panel-header", style: e.style, children: e.children });
900
+ }
901
+ function ze(e) {
902
+ return /* @__PURE__ */ r("div", { className: "panel-contents", style: e.style, children: e.children });
903
+ }
904
+ function p(e) {
905
+ const t = e.scroll ? Ye : U;
906
+ return /* @__PURE__ */ r("div", { className: `panel ${e.className ?? ""}`, style: e.style, children: /* @__PURE__ */ r(t, { children: e.children }) });
907
+ }
908
+ p.Header = Ke;
909
+ p.Contents = ze;
910
+ const Gt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
911
+ __proto__: null
912
+ }, Symbol.toStringTag, { value: "Module" })), Wt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
913
+ __proto__: null
914
+ }, Symbol.toStringTag, { value: "Module" })), _ = {};
915
+ function qe(e, t) {
916
+ _[e] = t;
917
+ }
918
+ function O(e, t, n = !0) {
919
+ if (!e)
920
+ return /* @__PURE__ */ r(v, {});
921
+ const { type: i } = e, a = i && i in _ ? _[i] : _.component;
922
+ return /* @__PURE__ */ r(a, { yamlNode: e, panel: n }, t);
923
+ }
924
+ function Ue({
925
+ children: e,
926
+ key: t,
927
+ panel: n,
928
+ options: i
929
+ }) {
930
+ return n ? /* @__PURE__ */ r(p, { style: i.style, scroll: i.scroll, children: /* @__PURE__ */ r(p.Contents, { children: e }) }, t) : /* @__PURE__ */ r(v, { children: Oe.map(
931
+ e,
932
+ (a) => Se(a) ? Ee(a, { key: t, ...a.props }) : void 0
933
+ ) });
934
+ }
935
+ function ue(e, t) {
936
+ const { _parentNode: n, _indexFromParent: i, ...a } = t;
937
+ if (e && Object.keys(a).length > 0)
938
+ throw new V(e, Object.keys(a));
939
+ }
940
+ class H extends Error {
941
+ constructor(t, n) {
942
+ super(t), this.yamlNode = n;
943
+ }
944
+ }
945
+ class V extends H {
946
+ constructor(t, n) {
947
+ super(`Unexpected keys: ${n.join(", ")}`, t), this.keys = n;
948
+ }
949
+ }
950
+ class L extends H {
951
+ constructor(t, n) {
952
+ super(`Keys ${n.join(", ")} are missing`, t), this.keys = n;
953
+ }
954
+ }
955
+ class g extends H {
956
+ constructor(t, n, i) {
957
+ super(`Key ${n} error: ${i}`, t), this.key = n, this.keyMessage = i;
958
+ }
959
+ }
960
+ function Ge(e) {
961
+ let t = e;
962
+ for (; t._parentNode; )
963
+ t = t._parentNode;
964
+ return t;
965
+ }
966
+ function We(e) {
967
+ const t = [];
968
+ let n = e;
969
+ for (; n; )
970
+ t.push({
971
+ node: n,
972
+ indexFromParent: n._indexFromParent
973
+ }), n = n._parentNode;
974
+ return t.reverse(), t;
975
+ }
976
+ function he(e, t = null, n = null) {
977
+ if (e._parentNode)
978
+ throw new Error(
979
+ "Attribute _parentNode was already defined by the yml layout."
980
+ );
981
+ const i = {
982
+ ...e,
983
+ _parentNode: t,
984
+ _indexFromParent: n
985
+ };
986
+ if (e.children) {
987
+ const a = [...e.children];
988
+ Object.freeze(a), i.children = a.map((o, d) => he(o, i, d));
989
+ }
990
+ return Object.freeze(i), i;
991
+ }
992
+ function Be(e) {
993
+ return /* @__PURE__ */ r(x, { variant: "danger", children: e.message });
994
+ }
995
+ function Ze(e) {
996
+ const { error: t } = e;
997
+ if (!(t instanceof H))
998
+ return /* @__PURE__ */ r(v, {});
999
+ function n(o, d = 3) {
1000
+ const s = We(o.yamlNode), h = [];
1001
+ let u = "";
1002
+ for (let c = 1; c < s.length; c++) {
1003
+ const { node: f, indexFromParent: m } = s[c];
1004
+ h.push(`${u}children:`), u += " ".repeat(d), m === 1 ? h.push(`${u}- type: ...`) : (m ?? 0 > 1) && h.push(
1005
+ `${u}...`,
1006
+ `${u}...`,
1007
+ `${u}# children number ${m ?? 0 + 1}`
1008
+ ), h.push(`${u}- type: ${f.type}`), u += " ".repeat(2);
1009
+ }
1010
+ return o instanceof V ? o.keys.forEach((c) => {
1011
+ h.push(
1012
+ `${u}${c}: ... ${" ".repeat(
1013
+ 50 - u.length - c.length
1014
+ )}<-- unexpected key`
1015
+ );
1016
+ }) : o instanceof L ? o.keys.forEach((c) => {
1017
+ h.push(
1018
+ `${u}???: ${" ".repeat(
1019
+ 50 - u.length - c.length
1020
+ )}<-- key **${c}** is expected`
1021
+ );
1022
+ }) : o instanceof g && h.push(
1023
+ `${u}${o.key}: ${" ".repeat(
1024
+ 50 - u.length - o.key.length
1025
+ )}<-- ${o.keyMessage}`
1026
+ ), h.join(`
1027
+ `);
1028
+ }
1029
+ const a = Ge(t.yamlNode).name;
1030
+ if (t instanceof V) {
1031
+ const o = t.keys.length === 1 ? "key" : "keys";
1032
+ return /* @__PURE__ */ l(x, { variant: "danger", children: [
1033
+ "Unexpected ",
1034
+ o,
1035
+ " ",
1036
+ t.keys.map((d, s) => /* @__PURE__ */ l(v, { children: [
1037
+ s !== 0 && ", ",
1038
+ /* @__PURE__ */ r("b", { children: d })
1039
+ ] })),
1040
+ " ",
1041
+ "from the layout name ",
1042
+ /* @__PURE__ */ r("b", { children: a }),
1043
+ ".",
1044
+ /* @__PURE__ */ r("br", {}),
1045
+ /* @__PURE__ */ r("pre", { className: "mt-3", children: n(t) }),
1046
+ /* @__PURE__ */ r("br", {})
1047
+ ] });
1048
+ }
1049
+ if (t instanceof L) {
1050
+ const o = t.keys.length === 1 ? "Key" : "Keys";
1051
+ return /* @__PURE__ */ l(x, { variant: "danger", children: [
1052
+ "Expected ",
1053
+ o,
1054
+ " ",
1055
+ t.keys.map((d, s) => /* @__PURE__ */ l(v, { children: [
1056
+ s !== 0 && ", ",
1057
+ /* @__PURE__ */ r("b", { children: d })
1058
+ ] })),
1059
+ " ",
1060
+ "from the layout name ",
1061
+ /* @__PURE__ */ r("b", { children: a }),
1062
+ ".",
1063
+ /* @__PURE__ */ r("br", {}),
1064
+ /* @__PURE__ */ r("pre", { className: "mt-3", children: n(t) }),
1065
+ /* @__PURE__ */ r("br", {})
1066
+ ] });
1067
+ }
1068
+ return t instanceof g ? /* @__PURE__ */ l(x, { variant: "danger", children: [
1069
+ "Error on key ",
1070
+ /* @__PURE__ */ r("b", { children: t.key }),
1071
+ " from the layout name ",
1072
+ /* @__PURE__ */ r("b", { children: a }),
1073
+ ".",
1074
+ /* @__PURE__ */ r("br", {}),
1075
+ /* @__PURE__ */ r("pre", { className: "mt-3", children: n(t) }),
1076
+ /* @__PURE__ */ r("br", {})
1077
+ ] }) : /* @__PURE__ */ r(Be, { ...e });
1078
+ }
1079
+ const ie = {
1080
+ hasError: !1,
1081
+ message: "",
1082
+ error: void 0
1083
+ };
1084
+ class Je extends se {
1085
+ constructor(t) {
1086
+ super(t), this.reload = () => {
1087
+ window.location.reload();
1088
+ }, this.state = ie;
1089
+ }
1090
+ static getDerivedStateFromError() {
1091
+ return { hasError: !0 };
1092
+ }
1093
+ componentDidCatch(t) {
1094
+ t instanceof H && this.setState({
1095
+ hasError: !0,
1096
+ message: t.message,
1097
+ error: t
1098
+ });
1099
+ }
1100
+ // https://github.com/bvaughn/react-error-boundary/blob/23a4d779744f3079dfe0960acaa4bdfd5dede87b/src/ErrorBoundary.ts#L53
1101
+ componentDidUpdate(t, n) {
1102
+ this.state.hasError && n.error !== void 0 && t.resetKey !== this.props.resetKey && this.setState(ie);
1103
+ }
1104
+ render() {
1105
+ return this.state.hasError ? /* @__PURE__ */ l($, { className: "mt-2", children: [
1106
+ /* @__PURE__ */ r("h4", { children: "Something went wrong" }),
1107
+ /* @__PURE__ */ r(
1108
+ Ze,
1109
+ {
1110
+ message: this.state.message,
1111
+ error: this.state.error
1112
+ }
1113
+ ),
1114
+ /* @__PURE__ */ l("p", { children: [
1115
+ "This error has been logged. Please",
1116
+ " ",
1117
+ /* @__PURE__ */ l(y, { size: "sm", onClick: this.reload, children: [
1118
+ /* @__PURE__ */ r("i", { className: "fa fa-refresh" }),
1119
+ " Reload"
1120
+ ] }),
1121
+ " ",
1122
+ "the application"
1123
+ ] })
1124
+ ] }) : this.props.children;
1125
+ }
1126
+ }
1127
+ function Qe(e, t, n) {
1128
+ if (e && n === void 0)
1129
+ throw new L(e, [t]);
1130
+ }
1131
+ function Xe(e, t, n) {
1132
+ if (typeof n != "string")
1133
+ throw new g(e, t, "A string is expected");
1134
+ }
1135
+ function et(e, t, n) {
1136
+ if (typeof n != "boolean")
1137
+ throw new g(e, t, "A boolean is expected");
1138
+ }
1139
+ function tt(e, t, n) {
1140
+ if (typeof n != "number")
1141
+ throw new g(e, t, "A number is expected");
1142
+ }
1143
+ function G(e, t, n) {
1144
+ if (n !== void 0 && typeof n != "boolean")
1145
+ throw new g(e, t, "An optional boolean is expected");
1146
+ }
1147
+ function fe(e, t, n) {
1148
+ if (n !== void 0 && typeof n != "string")
1149
+ throw new g(e, t, "An optional string is expected");
1150
+ }
1151
+ function nt(e, t, n) {
1152
+ if (!Array.isArray(n))
1153
+ throw new g(e, t, "A list of string is expected");
1154
+ n.forEach((i) => {
1155
+ if (typeof i != "string")
1156
+ throw new g(e, t, "A list of string is expected");
1157
+ });
1158
+ }
1159
+ function rt(e, t, n) {
1160
+ if (n !== void 0 && typeof n != "string") {
1161
+ if (!Array.isArray(n))
1162
+ throw new g(
1163
+ e,
1164
+ t,
1165
+ "An optional string or list of string is expected"
1166
+ );
1167
+ n.forEach((i) => {
1168
+ if (typeof i != "string")
1169
+ throw new g(
1170
+ e,
1171
+ t,
1172
+ "An optional string or list of string is expected"
1173
+ );
1174
+ });
1175
+ }
1176
+ }
1177
+ function it(e, t, n) {
1178
+ if (n !== void 0) {
1179
+ if (!Array.isArray(n))
1180
+ throw new g(e, t, "An optional list of string is expected");
1181
+ n.forEach((i) => {
1182
+ if (typeof i != "string")
1183
+ throw new g(
1184
+ e,
1185
+ t,
1186
+ "A optional list of string is expected"
1187
+ );
1188
+ });
1189
+ }
1190
+ }
1191
+ function me(e, t, n) {
1192
+ if (n !== void 0 && typeof n != "number")
1193
+ throw new g(e, t, "An optional number is expected");
1194
+ }
1195
+ function at(e, t, n) {
1196
+ if (n !== void 0) {
1197
+ if (!Array.isArray(n))
1198
+ throw new g(
1199
+ e,
1200
+ t,
1201
+ "An optional list of numbers is expected"
1202
+ );
1203
+ n.forEach((i) => {
1204
+ if (typeof i != "number")
1205
+ throw new g(
1206
+ e,
1207
+ t,
1208
+ "An optional list of numbers is expected"
1209
+ );
1210
+ });
1211
+ }
1212
+ }
1213
+ function K(e, t) {
1214
+ const { _parentNode: n, _indexFromParent: i, ...a } = t;
1215
+ if (e && Object.keys(a).length > 0)
1216
+ throw new V(e, Object.keys(a));
1217
+ }
1218
+ function ot(e, t, n) {
1219
+ if (n !== "last" && typeof n != "number")
1220
+ throw new g(e, t, '"last" or a number is expected');
1221
+ }
1222
+ function st(e, t, n) {
1223
+ if (n !== void 0 && n !== "h5web" && n !== "plotly")
1224
+ throw new g(e, t, '"h5web" or "plotly" string is expected');
1225
+ }
1226
+ const Bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1227
+ __proto__: null,
1228
+ assertBoolean: et,
1229
+ assertDataCollectionId: ot,
1230
+ assertKeyExpected: Qe,
1231
+ assertNoUnknownKeys: K,
1232
+ assertNumber: tt,
1233
+ assertOptionalBackend: st,
1234
+ assertOptionalBoolean: G,
1235
+ assertOptionalNumber: me,
1236
+ assertOptionalNumberList: at,
1237
+ assertOptionalString: fe,
1238
+ assertOptionalStringList: it,
1239
+ assertOptionalStringOrStringList: rt,
1240
+ assertString: Xe,
1241
+ assertStringList: nt
1242
+ }, Symbol.toStringTag, { value: "Module" }));
1243
+ function lt({ yamlNode: e, panel: t }) {
1244
+ const { type: n, style: i, children: a, ...o } = e;
1245
+ return K(e, o), /* @__PURE__ */ r(P, { className: "ymllayout-row gx-0", style: i, children: C(a, (d, s) => O(d, s, t)) });
1246
+ }
1247
+ function ct({ yamlNode: e, panel: t }) {
1248
+ const { type: n, style: i, xs: a, children: o, ...d } = e;
1249
+ return K(e, d), me(e, "xs", a), /* @__PURE__ */ r(
1250
+ E,
1251
+ {
1252
+ className: T("yamymllayout-col", { col: !!a }),
1253
+ style: i,
1254
+ xs: a,
1255
+ children: C(e.children, (s, h) => O(s, h, t))
1256
+ }
1257
+ );
1258
+ }
1259
+ const W = {};
1260
+ function Zt(e, t) {
1261
+ W[e] = t;
1262
+ }
1263
+ function dt(e, t) {
1264
+ if (t === void 0)
1265
+ throw new L(e, ["id"]);
1266
+ if (typeof t.id != "string")
1267
+ throw new g(e, "id", "A string is expected");
1268
+ }
1269
+ function ut(e, t, n) {
1270
+ if (n !== void 0) {
1271
+ if (!Array.isArray(n))
1272
+ throw new g(e, "ids", "A option list is expected");
1273
+ n.forEach((i, a) => {
1274
+ try {
1275
+ dt(e, i);
1276
+ } catch {
1277
+ throw new g(
1278
+ e,
1279
+ "ids",
1280
+ `The hardware description ${a} is wrong`
1281
+ );
1282
+ }
1283
+ });
1284
+ }
1285
+ }
1286
+ function ht(e) {
1287
+ const {
1288
+ providers: t = {},
1289
+ yamlNode: n,
1290
+ ids: i,
1291
+ groupid: a,
1292
+ even: o,
1293
+ nowrap: d,
1294
+ ...s
1295
+ } = e;
1296
+ if (ut(n, "ids", i), fe(n, "groupid", a), G(n, "even", o), G(n, "nowrap", d), K(n, s), !W.HardwareGroup)
1297
+ return /* @__PURE__ */ r(x, { variant: "warning", children: "No `HardwareGroup` component registered" });
1298
+ const h = W.HardwareGroup;
1299
+ return /* @__PURE__ */ r(
1300
+ h,
1301
+ {
1302
+ providers: t,
1303
+ ids: i,
1304
+ groupid: a,
1305
+ nowrap: d || !1,
1306
+ even: o || !1
1307
+ }
1308
+ );
1309
+ }
1310
+ const B = {
1311
+ hardwaregroup: ht
1312
+ };
1313
+ function ft(e, t) {
1314
+ B[e] = t;
1315
+ }
1316
+ function Jt(e) {
1317
+ Object.entries(e).forEach(
1318
+ ([t, n]) => ft(t, n)
1319
+ );
1320
+ }
1321
+ function mt(e) {
1322
+ const { yamlNode: t, panel: n } = e, { type: i, style: a, scroll: o, title: d, ...s } = t;
1323
+ if (!(i in B))
1324
+ return /* @__PURE__ */ r(p, { children: /* @__PURE__ */ r(p.Contents, { children: /* @__PURE__ */ l(x, { variant: "warning", children: [
1325
+ 'Unknown component "',
1326
+ i,
1327
+ '"'
1328
+ ] }) }) });
1329
+ const h = B[t.type];
1330
+ return n ? /* @__PURE__ */ r(p, { style: a, scroll: o, children: /* @__PURE__ */ l(ne, { fallback: /* @__PURE__ */ r("p", { children: "Loading..." }), children: [
1331
+ d && /* @__PURE__ */ r(p.Header, { children: d }),
1332
+ /* @__PURE__ */ r(p.Contents, { children: /* @__PURE__ */ r(h, { ...s, yamlNode: t }) })
1333
+ ] }) }) : /* @__PURE__ */ r(ne, { fallback: /* @__PURE__ */ r("p", { children: "Loading..." }), children: /* @__PURE__ */ r(h, { ...s, yamlNode: t }) });
1334
+ }
1335
+ function pt({ yamlNode: e, panel: t }) {
1336
+ const n = e.options || {};
1337
+ return /* @__PURE__ */ r($, { className: "ymllayout-container", ...n, children: C(e.children, (i, a) => O(i, a, t)) });
1338
+ }
1339
+ function gt(e) {
1340
+ const { yamlNode: t } = e, n = t.options || {}, i = {};
1341
+ return n.centerContent && (i.margin = "auto"), /* @__PURE__ */ l(p, { className: "ymllayout-panel", ...n, children: [
1342
+ t.title && /* @__PURE__ */ r(p.Header, { children: t.title }),
1343
+ /* @__PURE__ */ r(p.Contents, { style: i, children: C(
1344
+ t.children,
1345
+ (a, o) => O(a, o, !1)
1346
+ ) })
1347
+ ] });
1348
+ }
1349
+ const wt = () => Math.random().toString(36).slice(2, 15) + Math.random().toString(36).slice(2, 15);
1350
+ function yt({ yamlNode: e, panel: t }) {
1351
+ const n = [];
1352
+ return ve(e.children, (i, a) => {
1353
+ n.push(
1354
+ /* @__PURE__ */ r(be, { eventKey: wt(), title: i.title, children: O(i, 0, !1) }, a)
1355
+ );
1356
+ }), t ? /* @__PURE__ */ l(p, { className: "ymllayout-tabs", children: [
1357
+ e.title && /* @__PURE__ */ r(p.Header, { children: e.title }),
1358
+ /* @__PURE__ */ r(p.Contents, { children: /* @__PURE__ */ r(te, { mountOnEnter: !0, children: n }) })
1359
+ ] }) : /* @__PURE__ */ r(te, { children: n });
1360
+ }
1361
+ function vt(e) {
1362
+ const { node: t } = e, { type: n, title: i, ...a } = t;
1363
+ return ue(t, a), /* @__PURE__ */ r("div", { style: { gridColumn: "1 / 3" }, children: /* @__PURE__ */ r("h3", { children: i }) });
1364
+ }
1365
+ function bt(e) {
1366
+ const { node: t, state: n, row: i } = e, { title: a } = t;
1367
+ function o() {
1368
+ if (t.id)
1369
+ return t.id;
1370
+ }
1371
+ function d() {
1372
+ if (a !== void 0)
1373
+ return a;
1374
+ if (t.type === "hardware") {
1375
+ const h = o(), u = {
1376
+ _parentNode: t._parentNode,
1377
+ _indexFromParent: t._indexFromParent,
1378
+ type: "hardware",
1379
+ id: h,
1380
+ variant: "name",
1381
+ emptyifnone: !0
1382
+ };
1383
+ return O(u, "a", !1);
1384
+ }
1385
+ return "";
1386
+ }
1387
+ const s = d();
1388
+ return /* @__PURE__ */ l(
1389
+ "div",
1390
+ {
1391
+ style: {
1392
+ textAlign: "center"
1393
+ },
1394
+ children: [
1395
+ /* @__PURE__ */ r(
1396
+ "h5",
1397
+ {
1398
+ style: {
1399
+ margin: "0px",
1400
+ whiteSpace: "nowrap"
1401
+ },
1402
+ children: s
1403
+ }
1404
+ ),
1405
+ n && /* @__PURE__ */ r("div", { style: { position: "relative", top: -5 }, children: n })
1406
+ ]
1407
+ }
1408
+ );
1409
+ }
1410
+ function Nt(e) {
1411
+ const { node: t, row: n } = e, {
1412
+ titlealign: i,
1413
+ title: a,
1414
+ stateinheader: o = !1,
1415
+ variant: d,
1416
+ id: s,
1417
+ ...h
1418
+ } = t;
1419
+ let u, c;
1420
+ if (h.type === "hardware")
1421
+ if (u = {
1422
+ ...h,
1423
+ id: s,
1424
+ variant: d
1425
+ }, o) {
1426
+ const f = {
1427
+ ...h,
1428
+ id: s,
1429
+ variant: "state",
1430
+ emptyifnone: !0
1431
+ };
1432
+ c = O(f, "k", !1);
1433
+ } else
1434
+ c = null;
1435
+ else
1436
+ u = h, c = null;
1437
+ return /* @__PURE__ */ l(v, { children: [
1438
+ /* @__PURE__ */ r(
1439
+ "div",
1440
+ {
1441
+ style: {
1442
+ gridColumn: 1,
1443
+ alignSelf: i ?? "center"
1444
+ },
1445
+ children: /* @__PURE__ */ r(bt, { node: t, state: c, row: n })
1446
+ }
1447
+ ),
1448
+ /* @__PURE__ */ r("div", { style: { gridColumn: 2 }, children: O(u, "k", !1) })
1449
+ ] });
1450
+ }
1451
+ function Ct(e) {
1452
+ const { yamlNode: t, panel: n } = e, { type: i, children: a, options: o = {}, title: d, ...s } = t;
1453
+ return ue(t, s), /* @__PURE__ */ l(p, { className: "ymllayout-form", ...o, children: [
1454
+ t.title && /* @__PURE__ */ r(p.Header, { children: t.title }),
1455
+ /* @__PURE__ */ r(p.Contents, { children: /* @__PURE__ */ r(
1456
+ "div",
1457
+ {
1458
+ style: {
1459
+ display: "grid",
1460
+ gridTemplateColumns: "min-content auto"
1461
+ },
1462
+ children: C(a, (h, u) => h.type === "formheader" ? /* @__PURE__ */ r(
1463
+ vt,
1464
+ {
1465
+ node: h,
1466
+ row: u
1467
+ },
1468
+ u
1469
+ ) : /* @__PURE__ */ r(Nt, { node: h, row: u }, u))
1470
+ }
1471
+ ) })
1472
+ ] });
1473
+ }
1474
+ function Ot(e) {
1475
+ const { yamlNode: t, panel: n } = e;
1476
+ return /* @__PURE__ */ l(
1477
+ "div",
1478
+ {
1479
+ className: "ymllayout-grid",
1480
+ style: {
1481
+ gridTemplateColumns: t.columns,
1482
+ gridTemplateRows: t.rows
1483
+ },
1484
+ children: [
1485
+ C(t.children, (i, a) => {
1486
+ const { columnSpan: o = 1, rowSpan: d = 1, ...s } = i, h = o > 1 ? `span ${o}` : void 0, u = d > 1 ? `span ${d}` : void 0;
1487
+ return /* @__PURE__ */ r(
1488
+ "div",
1489
+ {
1490
+ className: "ymllayout-grid-cell",
1491
+ style: {
1492
+ gridColumn: h,
1493
+ gridRow: u
1494
+ },
1495
+ children: O(s, a, n)
1496
+ },
1497
+ a
1498
+ );
1499
+ }),
1500
+ " "
1501
+ ]
1502
+ }
1503
+ );
1504
+ }
1505
+ function St({ yamlNode: e, panel: t }) {
1506
+ const n = e.options || {};
1507
+ return /* @__PURE__ */ r(Ue, { panel: t, options: n, children: /* @__PURE__ */ r("div", { children: e.label }) });
1508
+ }
1509
+ const Et = {
1510
+ row: lt,
1511
+ col: ct,
1512
+ container: pt,
1513
+ component: mt,
1514
+ panel: gt,
1515
+ tabs: yt,
1516
+ form: Ct,
1517
+ grid: Ot,
1518
+ label: St
1519
+ };
1520
+ Object.entries(Et).forEach(([e, t]) => {
1521
+ qe(e, t);
1522
+ });
1523
+ function Qt(e) {
1524
+ var n;
1525
+ const t = xe(() => he(e.layout), [e.layout]);
1526
+ return t.error ? /* @__PURE__ */ r("div", { className: `${e.className ?? ""} ymllayout-main`, id: e.id, children: /* @__PURE__ */ l(p, { children: [
1527
+ /* @__PURE__ */ r(p.Header, { children: "Layout Error" }),
1528
+ /* @__PURE__ */ l(p.Contents, { children: [
1529
+ /* @__PURE__ */ l("p", { children: [
1530
+ "File: ",
1531
+ t.name
1532
+ ] }),
1533
+ /* @__PURE__ */ r(x, { variant: "warning", children: /* @__PURE__ */ r("pre", { className: "mb-0", children: t.error }) })
1534
+ ] })
1535
+ ] }) }) : /* @__PURE__ */ r("div", { className: `${e.className ?? ""} ymllayout-main`, id: e.id, children: /* @__PURE__ */ r(Je, { resetKey: t, children: (n = t.children) == null ? void 0 : n.map((i, a) => O(i, a)) }) });
1536
+ }
1537
+ const Xt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1538
+ __proto__: null
1539
+ }, Symbol.toStringTag, { value: "Module" })), pe = {
1540
+ hardware: It
1541
+ };
1542
+ function en(e, t) {
1543
+ pe[e] = t;
1544
+ }
1545
+ function xt(e) {
1546
+ return /* @__PURE__ */ l(
1547
+ E,
1548
+ {
1549
+ className: "monitor-panel-item bg-fatal",
1550
+ title: `Error from yaml configuration: ${e.message}`,
1551
+ children: [
1552
+ /* @__PURE__ */ r("h1", { children: e.monitor.name }),
1553
+ /* @__PURE__ */ r("div", { children: "Parsing error" })
1554
+ ]
1555
+ }
1556
+ );
1557
+ }
1558
+ function tn(e) {
1559
+ const t = C(e.monitors, (n, i) => {
1560
+ const a = n.type ?? "hardware", o = pe[a];
1561
+ return o === void 0 ? /* @__PURE__ */ r(
1562
+ xt,
1563
+ {
1564
+ monitor: n,
1565
+ message: `Type ${a} unsupported`
1566
+ },
1567
+ `m${i}`
1568
+ ) : /* @__PURE__ */ r(o, { monitor: n }, `m${i}`);
1569
+ });
1570
+ return /* @__PURE__ */ r(
1571
+ "div",
1572
+ {
1573
+ className: T(
1574
+ { "ms-auto": e.margin === "start" },
1575
+ "me-auto",
1576
+ "monitor-panel",
1577
+ { "monitor-panel-light": e.bg === "light" }
1578
+ ),
1579
+ children: /* @__PURE__ */ r($, { fluid: !0, children: /* @__PURE__ */ r(P, { className: "flex-nowrap", children: t }) })
1580
+ }
1581
+ );
1582
+ }
1583
+ function Mt(e) {
1584
+ return /* @__PURE__ */ r(E, { className: "monitor-panel-item", children: e.children });
1585
+ }
1586
+ const Z = {};
1587
+ function nn(e, t) {
1588
+ Z[e] = t;
1589
+ }
1590
+ function ge(e) {
1591
+ if (!Z.useHardware)
1592
+ throw new Error("No `useHardware` hook registered");
1593
+ return Z.useHardware(e);
1594
+ }
1595
+ const At = (e, t, n) => {
1596
+ const i = {
1597
+ ">": (a, o) => a > o,
1598
+ "<": (a, o) => a < o,
1599
+ ">=": (a, o) => a >= o,
1600
+ "<=": (a, o) => a <= o,
1601
+ "==": (a, o) => a === o,
1602
+ "!=": (a, o) => a !== o,
1603
+ in: (a, o) => o.indexOf(a) > -1
1604
+ };
1605
+ if (e in i)
1606
+ return i[e](t, n);
1607
+ };
1608
+ function we(e, t, n) {
1609
+ const i = e.split(t);
1610
+ return n ? [i.slice(0, -n).join(t)].concat(i.slice(-n)) : i;
1611
+ }
1612
+ function ae(e) {
1613
+ const t = e !== void 0 ? we(e, ".", 1) : [null, ""], n = ge(t[0]);
1614
+ if (n && n.properties && t[1] !== null)
1615
+ return Array.isArray(n.properties[t[1]]) ? n.properties[t[1]][0] : n.properties[t[1]];
1616
+ }
1617
+ function kt(e) {
1618
+ const t = e !== void 0 && !e.includes("."), n = e !== void 0 ? we(e, ".", 1) : [null, ""], i = ge(n[0]);
1619
+ if (t)
1620
+ return e;
1621
+ if (i && i.properties && n[1] !== null)
1622
+ return `${i.properties[n[1]]}`;
1623
+ }
1624
+ function It(e) {
1625
+ const { monitor: t } = e;
1626
+ let n = ae(t.value) ?? "-";
1627
+ const i = kt(t.unit), a = ae(t.overlay), o = Number.parseFloat(`${n}`);
1628
+ Number.isNaN(o) || String(o).length > 5 && (n = o.toPrecision(5));
1629
+ let d;
1630
+ t.comparator && t.comparison && (d = At(t.comparator, n, t.comparison) ? "valid" : "invalid"), Number.isNaN(o) || i !== void 0 && (n = `${n} ${i}`);
1631
+ let s = U;
1632
+ const h = {};
1633
+ if (a) {
1634
+ const u = `${a}`;
1635
+ let c = U;
1636
+ u.includes(`
1637
+ `) && (c = "pre"), s = F, h.placement = "bottom", h.overlay = /* @__PURE__ */ r(Ne, {
1638
+ id: "tooltipid",
1639
+ className: "monitor-panel-tooltip",
1640
+ // @ts-expect-error
1641
+ children: /* @__PURE__ */ r(c, { children: u })
1642
+ });
1643
+ }
1644
+ return (
1645
+ // @ts-expect-error
1646
+ /* @__PURE__ */ Me(s, { ...h, key: t.name }, /* @__PURE__ */ l(Mt, { children: [
1647
+ /* @__PURE__ */ r("h1", { children: t.name }),
1648
+ /* @__PURE__ */ r("div", { className: d, children: `${n}` })
1649
+ ] }))
1650
+ );
1651
+ }
1652
+ export {
1653
+ _t as Formatting,
1654
+ Pt as Frontend,
1655
+ Ye as FullSizer,
1656
+ Xt as HWObject,
1657
+ re as HardwareInputNumber,
1658
+ _e as HardwareNumericStep,
1659
+ Wt as HardwareSchema,
1660
+ Lt as HardwareState,
1661
+ Y as HardwareTemplate,
1662
+ Gt as HardwareTypes,
1663
+ Ut as HardwareVariant,
1664
+ Vt as Info,
1665
+ g as KeyError,
1666
+ L as MissingKeysError,
1667
+ It as MonitorHardware,
1668
+ tn as MonitorPanel,
1669
+ Mt as MonitorPanelItem,
1670
+ jt as MotorDefault,
1671
+ Yt as Multiposition,
1672
+ Kt as NoObject,
1673
+ He as NumericStep,
1674
+ p as Panel,
1675
+ zt as Property,
1676
+ qt as ShutterDefault,
1677
+ I as TypeIcon,
1678
+ Je as YAMLErrorBoundary,
1679
+ Qt as YAMLLayout,
1680
+ Bt as YamlAsserts,
1681
+ At as dynamicOp,
1682
+ Zt as registerHardwareComponent,
1683
+ en as registerMonitorComponent,
1684
+ nn as registerRuntimeHook,
1685
+ ft as registerYamlComponent,
1686
+ Jt as registerYamlComponents,
1687
+ qe as registerYamlType,
1688
+ O as renderYamlNode,
1689
+ Et as yamlMap
1690
+ };
1691
+ //# sourceMappingURL=index.mjs.map