@devicechain/widgets 1.1.0 → 1.2.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.
Files changed (32) hide show
  1. package/README.md +1 -1
  2. package/dist/builtin-descriptors.d.ts +236 -0
  3. package/dist/builtin-registry.d.ts +233 -0
  4. package/dist/chunks/{aggregate-widgets-EVJNAA26.js → aggregate-widgets-IFZUFYXV.js} +229 -2
  5. package/dist/chunks/{aggregate-widgets-EVJNAA26.js.map → aggregate-widgets-IFZUFYXV.js.map} +4 -4
  6. package/dist/chunks/{event-markers-feed-DMRW5GV5.js → event-markers-feed-BQO4T367.js} +14 -4
  7. package/dist/chunks/event-markers-feed-BQO4T367.js.map +7 -0
  8. package/dist/chunks/{history-widgets-DZBMNMEX.js → history-widgets-7GNKTE5X.js} +209 -2
  9. package/dist/chunks/{history-widgets-DZBMNMEX.js.map → history-widgets-7GNKTE5X.js.map} +4 -4
  10. package/dist/chunks/{level-widgets-HE6EDSWC.js → level-widgets-DKCQT2XF.js} +377 -36
  11. package/dist/chunks/{level-widgets-HE6EDSWC.js.map → level-widgets-DKCQT2XF.js.map} +4 -4
  12. package/dist/documented-descriptors.d.ts +737 -32
  13. package/dist/index.js +140 -6
  14. package/dist/index.js.map +2 -2
  15. package/dist/scada-model.d.ts +16 -0
  16. package/dist/scada-strings.d.ts +10 -0
  17. package/dist/scada-symbols.d.ts +14 -0
  18. package/dist/state-timeline-model.d.ts +19 -0
  19. package/dist/state-timeline-strings.d.ts +17 -0
  20. package/dist/status-grid-model.d.ts +19 -0
  21. package/dist/status-grid-strings.d.ts +9 -0
  22. package/dist/widgets/aggregate-lazy.d.ts +74 -0
  23. package/dist/widgets/aggregate-widgets.d.ts +1 -0
  24. package/dist/widgets/history-lazy.d.ts +53 -0
  25. package/dist/widgets/history-widgets.d.ts +1 -0
  26. package/dist/widgets/level-lazy.d.ts +109 -0
  27. package/dist/widgets/level-widgets.d.ts +1 -0
  28. package/dist/widgets/scada-symbol.d.ts +3 -0
  29. package/dist/widgets/state-timeline.d.ts +8 -0
  30. package/dist/widgets/status-grid.d.ts +2 -0
  31. package/package.json +7 -7
  32. package/dist/chunks/event-markers-feed-DMRW5GV5.js.map +0 -7
@@ -651,37 +651,377 @@ function RingBody({ reading: r, percent, scale: ws }) {
651
651
  );
652
652
  }
653
653
 
654
- // src/widgets/signal-bars.tsx
655
- import { useMemo as useMemo6 } from "react";
654
+ // src/widgets/scada-symbol.tsx
655
+ import { useEffect, useMemo as useMemo6, useState } from "react";
656
656
  import {
657
- css as css6,
657
+ css as css7,
658
+ fontVar as fontVar2,
659
+ formatValue as formatValue5,
658
660
  optNumber as optNumber6,
659
661
  optString as optString6,
660
662
  optThresholds as optThresholds6,
661
663
  WidgetFrame as WidgetFrame6
662
664
  } from "@devicechain/widget-sdk";
665
+
666
+ // src/scada-model.ts
667
+ var SCADA_SYMBOLS = ["pump", "valve", "tank", "motor", "fan", "pipe", "sensor", "breaker", "light"];
668
+ function isScadaSymbol(v) {
669
+ return typeof v === "string" && SCADA_SYMBOLS.includes(v);
670
+ }
671
+ function isContinuous(symbol) {
672
+ return symbol === "tank" || symbol === "sensor";
673
+ }
674
+ var DEFAULT_ON_AT = 1;
675
+ function isFaultBand(band) {
676
+ return band !== void 0 && (band.level === "major" || band.level === "critical");
677
+ }
678
+ function readSymbol(symbol, value, onAt, band) {
679
+ if (value === void 0 || !Number.isFinite(value)) return { state: "unknown", flow: "none" };
680
+ const threshold = onAt ?? DEFAULT_ON_AT;
681
+ const flow = symbol === "pipe" && value !== 0 && Math.abs(value) >= Math.abs(threshold) ? value < 0 ? "reverse" : "forward" : "none";
682
+ if (isFaultBand(band)) return { state: "fault", flow };
683
+ if (isContinuous(symbol)) return { state: "running", flow: "none" };
684
+ if (symbol === "pipe") return { state: flow === "none" ? "stopped" : "running", flow };
685
+ return { state: value >= threshold ? "running" : "stopped", flow: "none" };
686
+ }
687
+
688
+ // src/scada-strings.ts
689
+ import { viewerLocale as viewerLocale2 } from "@devicechain/widget-sdk";
690
+ var SWITCH = (stopped, running, fault, unknown) => ({ stopped, running, fault, unknown });
691
+ var SCADA_STRINGS = {
692
+ en: {
693
+ symbols: { pump: "Pump", valve: "Valve", tank: "Tank", motor: "Motor", fan: "Fan", pipe: "Pipe", sensor: "Sensor", breaker: "Breaker", light: "Light" },
694
+ states: {
695
+ pump: SWITCH("Stopped", "Running", "Fault", "No data"),
696
+ valve: SWITCH("Closed", "Open", "Fault", "No data"),
697
+ tank: SWITCH("Level", "Level", "Alarm", "No data"),
698
+ motor: SWITCH("Stopped", "Running", "Fault", "No data"),
699
+ fan: SWITCH("Stopped", "Running", "Fault", "No data"),
700
+ pipe: SWITCH("No flow", "Flowing", "Fault", "No data"),
701
+ sensor: SWITCH("Reading", "Reading", "Alarm", "No data"),
702
+ breaker: SWITCH("Open", "Closed", "Tripped", "No data"),
703
+ light: SWITCH("Off", "On", "Fault", "No data")
704
+ },
705
+ forward: "forward",
706
+ reverse: "reverse",
707
+ label: (symbol, state) => `${symbol}: ${state}`
708
+ },
709
+ es: {
710
+ symbols: { pump: "Bomba", valve: "V\xE1lvula", tank: "Dep\xF3sito", motor: "Motor", fan: "Ventilador", pipe: "Tuber\xEDa", sensor: "Sensor", breaker: "Interruptor", light: "Luz" },
711
+ states: {
712
+ pump: SWITCH("Detenida", "En marcha", "Falla", "Sin datos"),
713
+ valve: SWITCH("Cerrada", "Abierta", "Falla", "Sin datos"),
714
+ tank: SWITCH("Nivel", "Nivel", "Alarma", "Sin datos"),
715
+ motor: SWITCH("Detenido", "En marcha", "Falla", "Sin datos"),
716
+ fan: SWITCH("Detenido", "En marcha", "Falla", "Sin datos"),
717
+ pipe: SWITCH("Sin flujo", "Con flujo", "Falla", "Sin datos"),
718
+ sensor: SWITCH("Lectura", "Lectura", "Alarma", "Sin datos"),
719
+ breaker: SWITCH("Abierto", "Cerrado", "Disparado", "Sin datos"),
720
+ light: SWITCH("Apagada", "Encendida", "Falla", "Sin datos")
721
+ },
722
+ forward: "directo",
723
+ reverse: "inverso",
724
+ label: (symbol, state) => `${symbol}: ${state}`
725
+ }
726
+ };
727
+ function scadaStrings(locale = viewerLocale2()) {
728
+ return locale?.toLowerCase().startsWith("es") ? SCADA_STRINGS.es : SCADA_STRINGS.en;
729
+ }
730
+
731
+ // src/scada-symbols.tsx
732
+ import { css as css6 } from "@devicechain/widget-sdk";
733
+ import { useId } from "react";
663
734
  import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
664
- var SIGNAL_MIN_BARS = 2;
665
- var VIEW2 = { w: 100, h: 60 };
666
- function SignalBars({ widget, data }) {
735
+ var STROKE = 3;
736
+ var ink = () => css6("foreground");
737
+ var muted = () => css6("muted-foreground");
738
+ var body = () => css6("card");
739
+ function working(p) {
740
+ return p.state === "running" || p.state === "fault" ? p.accent : muted();
741
+ }
742
+ var spin = (dur, clockwise = true) => /* @__PURE__ */ jsx6("animateTransform", { attributeName: "transform", type: "rotate", from: `0 50 50`, to: `${clockwise ? 360 : -360} 50 50`, dur, repeatCount: "indefinite" });
743
+ function Badge({ p }) {
744
+ if (p.state !== "fault") return null;
745
+ return /* @__PURE__ */ jsxs6("g", { "data-fault-badge": "", children: [
746
+ /* @__PURE__ */ jsx6("circle", { cx: "84", cy: "16", r: "12", fill: p.accent, stroke: ink(), strokeWidth: 2 }),
747
+ /* @__PURE__ */ jsx6("text", { x: "84", y: "22", textAnchor: "middle", fontSize: "18", fontWeight: "700", fill: css6("background"), children: "!" }),
748
+ p.motion && /* @__PURE__ */ jsx6("animate", { attributeName: "opacity", values: "1;0.35;1", dur: "1s", repeatCount: "indefinite" })
749
+ ] });
750
+ }
751
+ function Pump(p) {
752
+ const on = p.state === "running";
753
+ return /* @__PURE__ */ jsxs6("g", { children: [
754
+ /* @__PURE__ */ jsx6("path", { d: "M8 62 H22 M78 38 V22 H92", stroke: ink(), strokeWidth: STROKE, fill: "none", strokeLinecap: "round" }),
755
+ /* @__PURE__ */ jsx6("circle", { cx: "50", cy: "50", r: "30", fill: body(), stroke: ink(), strokeWidth: STROKE }),
756
+ /* @__PURE__ */ jsx6("g", { stroke: working(p), strokeWidth: 5, strokeLinecap: "round", fill: "none", children: /* @__PURE__ */ jsxs6("g", { "data-motion": on && p.motion ? "spin" : void 0, children: [
757
+ /* @__PURE__ */ jsx6("path", { d: "M50 50 L50 28 M50 50 L69 61 M50 50 L31 61" }),
758
+ on && p.motion && spin("1.2s")
759
+ ] }) }),
760
+ /* @__PURE__ */ jsx6("circle", { cx: "50", cy: "50", r: "5", fill: working(p) }),
761
+ /* @__PURE__ */ jsx6(Badge, { p })
762
+ ] });
763
+ }
764
+ function Motor(p) {
765
+ const on = p.state === "running";
766
+ return /* @__PURE__ */ jsxs6("g", { children: [
767
+ /* @__PURE__ */ jsx6("path", { d: "M4 50 H16 M84 50 H96", stroke: ink(), strokeWidth: STROKE, strokeLinecap: "round" }),
768
+ /* @__PURE__ */ jsx6("rect", { x: "16", y: "26", width: "68", height: "48", rx: "8", fill: body(), stroke: ink(), strokeWidth: STROKE }),
769
+ /* @__PURE__ */ jsx6("path", { d: "M26 26 V74 M34 26 V74", stroke: muted(), strokeWidth: 2 }),
770
+ /* @__PURE__ */ jsxs6("g", { "data-motion": on && p.motion ? "spin" : void 0, children: [
771
+ /* @__PURE__ */ jsx6("circle", { cx: "58", cy: "50", r: "16", fill: "none", stroke: working(p), strokeWidth: 4, strokeDasharray: "14 8" }),
772
+ on && p.motion && /* @__PURE__ */ jsx6("animateTransform", { attributeName: "transform", type: "rotate", from: "0 58 50", to: "360 58 50", dur: "1.4s", repeatCount: "indefinite" })
773
+ ] }),
774
+ /* @__PURE__ */ jsx6("text", { x: "58", y: "56", textAnchor: "middle", fontSize: "16", fontWeight: "700", fill: working(p), children: "M" }),
775
+ /* @__PURE__ */ jsx6(Badge, { p })
776
+ ] });
777
+ }
778
+ function Fan(p) {
779
+ const on = p.state === "running";
780
+ return /* @__PURE__ */ jsxs6("g", { children: [
781
+ /* @__PURE__ */ jsx6("circle", { cx: "50", cy: "50", r: "38", fill: body(), stroke: ink(), strokeWidth: STROKE }),
782
+ /* @__PURE__ */ jsxs6("g", { "data-motion": on && p.motion ? "spin" : void 0, children: [
783
+ /* @__PURE__ */ jsxs6("g", { fill: working(p), opacity: 0.9, children: [
784
+ /* @__PURE__ */ jsx6("path", { d: "M50 50 C44 28 56 12 66 22 C72 30 60 44 50 50 Z" }),
785
+ /* @__PURE__ */ jsx6("path", { d: "M50 50 C72 44 88 56 78 66 C70 72 56 60 50 50 Z", transform: "rotate(0 50 50)" }),
786
+ /* @__PURE__ */ jsx6("path", { d: "M50 50 C56 72 44 88 34 78 C28 70 40 56 50 50 Z" })
787
+ ] }),
788
+ on && p.motion && spin("0.9s")
789
+ ] }),
790
+ /* @__PURE__ */ jsx6("circle", { cx: "50", cy: "50", r: "6", fill: ink() }),
791
+ /* @__PURE__ */ jsx6(Badge, { p })
792
+ ] });
793
+ }
794
+ function Valve(p) {
795
+ const open = p.state === "running";
796
+ return /* @__PURE__ */ jsxs6("g", { children: [
797
+ /* @__PURE__ */ jsx6("path", { d: "M4 56 H30 M70 56 H96", stroke: ink(), strokeWidth: STROKE, strokeLinecap: "round" }),
798
+ /* @__PURE__ */ jsx6("path", { d: "M30 36 L50 56 L30 76 Z M70 36 L50 56 L70 76 Z", fill: open ? working(p) : p.state === "fault" ? working(p) : body(), stroke: ink(), strokeWidth: STROKE, strokeLinejoin: "round", opacity: open || p.state === "fault" ? 0.85 : 1 }),
799
+ /* @__PURE__ */ jsx6("path", { d: "M50 56 V30", stroke: ink(), strokeWidth: STROKE }),
800
+ /* @__PURE__ */ jsx6("path", { d: "M36 28 H64", stroke: ink(), strokeWidth: 5, strokeLinecap: "round" }),
801
+ p.state === "stopped" && /* @__PURE__ */ jsx6("path", { d: "M50 40 V72", stroke: muted(), strokeWidth: 5, strokeLinecap: "round", "data-closed": "" }),
802
+ /* @__PURE__ */ jsx6(Badge, { p })
803
+ ] });
804
+ }
805
+ function Tank(p) {
806
+ const clip = `scada-tank-${useId().replace(/:/g, "")}`;
807
+ const level = Math.min(1, Math.max(0, p.fill ?? 0));
808
+ const top = 14;
809
+ const bottom = 90;
810
+ const h = (bottom - top) * level;
811
+ return /* @__PURE__ */ jsxs6("g", { children: [
812
+ /* @__PURE__ */ jsx6("clipPath", { id: clip, children: /* @__PURE__ */ jsx6("path", { d: "M22 14 H78 V84 Q78 90 72 90 H28 Q22 90 22 84 Z" }) }),
813
+ /* @__PURE__ */ jsx6("path", { d: "M22 14 H78 V84 Q78 90 72 90 H28 Q22 90 22 84 Z", fill: body() }),
814
+ p.state !== "unknown" && /* @__PURE__ */ jsxs6("g", { clipPath: `url(#${clip})`, children: [
815
+ /* @__PURE__ */ jsx6("rect", { "data-liquid": "", x: "22", y: bottom - h, width: "56", height: h, fill: working(p), opacity: 0.6 }),
816
+ level > 0 && level < 1 && /* @__PURE__ */ jsx6("path", { d: `M22 ${bottom - h} H78`, stroke: p.accent, strokeWidth: 2 })
817
+ ] }),
818
+ /* @__PURE__ */ jsx6("path", { d: "M22 14 H78 V84 Q78 90 72 90 H28 Q22 90 22 84 Z", fill: "none", stroke: ink(), strokeWidth: STROKE, strokeDasharray: p.state === "unknown" ? "6 4" : void 0 }),
819
+ /* @__PURE__ */ jsx6("path", { d: "M12 76 H22 M78 30 H90", stroke: ink(), strokeWidth: STROKE, strokeLinecap: "round" }),
820
+ /* @__PURE__ */ jsx6(Badge, { p })
821
+ ] });
822
+ }
823
+ function Pipe(p) {
824
+ const flowing = p.flow !== "none" && p.state !== "unknown";
825
+ const dash = "8 8";
826
+ const to = p.flow === "reverse" ? 16 : -16;
827
+ const v = p.horizontal === false;
828
+ const d = v ? "M50 4 V96" : "M4 50 H96";
829
+ return /* @__PURE__ */ jsxs6("g", { children: [
830
+ /* @__PURE__ */ jsx6("path", { d, stroke: ink(), strokeWidth: 22, strokeLinecap: "butt", fill: "none" }),
831
+ /* @__PURE__ */ jsx6("path", { d, stroke: body(), strokeWidth: 16, strokeLinecap: "butt", fill: "none" }),
832
+ /* @__PURE__ */ jsx6(
833
+ "path",
834
+ {
835
+ d,
836
+ "data-flow": flowing ? p.flow : "none",
837
+ "data-motion": flowing && p.motion ? "flow" : void 0,
838
+ stroke: flowing || p.state === "fault" ? p.accent : muted(),
839
+ strokeWidth: 8,
840
+ strokeLinecap: "butt",
841
+ fill: "none",
842
+ strokeDasharray: flowing || p.state === "fault" ? dash : "2 10",
843
+ children: flowing && p.motion && /* @__PURE__ */ jsx6("animate", { attributeName: "stroke-dashoffset", from: "0", to: String(to), dur: "0.8s", repeatCount: "indefinite" })
844
+ }
845
+ ),
846
+ /* @__PURE__ */ jsx6(Badge, { p })
847
+ ] });
848
+ }
849
+ function Sensor(p) {
850
+ return /* @__PURE__ */ jsxs6("g", { children: [
851
+ /* @__PURE__ */ jsx6("circle", { cx: "50", cy: "50", r: "34", fill: body(), stroke: ink(), strokeWidth: STROKE, strokeDasharray: p.state === "unknown" ? "6 4" : void 0 }),
852
+ /* @__PURE__ */ jsx6("circle", { cx: "50", cy: "50", r: "18", fill: "none", stroke: working(p), strokeWidth: 5 }),
853
+ /* @__PURE__ */ jsx6("circle", { cx: "50", cy: "50", r: "5", fill: working(p) }),
854
+ /* @__PURE__ */ jsx6("path", { d: "M50 16 V4 M50 84 V96", stroke: ink(), strokeWidth: STROKE, strokeLinecap: "round" }),
855
+ /* @__PURE__ */ jsx6(Badge, { p })
856
+ ] });
857
+ }
858
+ function Breaker(p) {
859
+ const closed = p.state === "running";
860
+ return /* @__PURE__ */ jsxs6("g", { children: [
861
+ /* @__PURE__ */ jsx6("path", { d: "M50 4 V30 M50 76 V96", stroke: ink(), strokeWidth: STROKE, strokeLinecap: "round" }),
862
+ /* @__PURE__ */ jsx6("circle", { cx: "50", cy: "30", r: "5", fill: body(), stroke: ink(), strokeWidth: STROKE }),
863
+ /* @__PURE__ */ jsx6("circle", { cx: "50", cy: "76", r: "5", fill: body(), stroke: ink(), strokeWidth: STROKE }),
864
+ /* @__PURE__ */ jsx6("path", { "data-contact": closed ? "closed" : "open", d: closed ? "M50 30 V76" : "M50 30 L74 66", stroke: working(p), strokeWidth: 7, strokeLinecap: "round" }),
865
+ /* @__PURE__ */ jsx6(Badge, { p })
866
+ ] });
867
+ }
868
+ function Light(p) {
869
+ const lit = p.state === "running";
870
+ return /* @__PURE__ */ jsxs6("g", { children: [
871
+ lit && /* @__PURE__ */ jsxs6("g", { "data-glow": "", opacity: 0.35, children: [
872
+ /* @__PURE__ */ jsx6("circle", { cx: "50", cy: "46", r: "42", fill: p.accent }),
873
+ p.motion && /* @__PURE__ */ jsx6("animate", { attributeName: "opacity", values: "0.35;0.5;0.35", dur: "2.4s", repeatCount: "indefinite" })
874
+ ] }),
875
+ /* @__PURE__ */ jsx6("circle", { cx: "50", cy: "46", r: "26", fill: lit ? p.accent : body(), stroke: ink(), strokeWidth: STROKE, strokeDasharray: p.state === "unknown" ? "6 4" : void 0 }),
876
+ /* @__PURE__ */ jsx6("path", { d: "M38 84 H62 M42 92 H58", stroke: ink(), strokeWidth: STROKE, strokeLinecap: "round" }),
877
+ /* @__PURE__ */ jsx6("path", { d: "M40 72 H60", stroke: ink(), strokeWidth: STROKE }),
878
+ /* @__PURE__ */ jsx6(Badge, { p })
879
+ ] });
880
+ }
881
+ var DRAW = {
882
+ pump: Pump,
883
+ valve: Valve,
884
+ tank: Tank,
885
+ motor: Motor,
886
+ fan: Fan,
887
+ pipe: Pipe,
888
+ sensor: Sensor,
889
+ breaker: Breaker,
890
+ light: Light
891
+ };
892
+ function SymbolArt({ symbol, paint, label }) {
893
+ const Draw = DRAW[symbol];
894
+ return /* @__PURE__ */ jsx6(
895
+ "svg",
896
+ {
897
+ viewBox: "0 0 100 100",
898
+ preserveAspectRatio: "xMidYMid meet",
899
+ role: "img",
900
+ "aria-label": label,
901
+ "data-symbol": symbol,
902
+ "data-state": paint.state,
903
+ "data-flow": paint.flow,
904
+ "data-motion-on": paint.motion ? "" : void 0,
905
+ style: { width: "100%", height: "100%", display: "block", overflow: "visible" },
906
+ children: /* @__PURE__ */ jsx6("g", { "data-unknown": paint.state === "unknown" ? "" : void 0, strokeDasharray: paint.state === "unknown" ? "5 4" : void 0, opacity: paint.state === "unknown" ? 0.55 : void 0, children: /* @__PURE__ */ jsx6(Draw, { ...paint }) })
907
+ }
908
+ );
909
+ }
910
+
911
+ // src/widgets/scada-symbol.tsx
912
+ import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
913
+ function usePrefersReducedMotion() {
914
+ const query = typeof window !== "undefined" && typeof window.matchMedia === "function" ? window.matchMedia("(prefers-reduced-motion: reduce)") : void 0;
915
+ const [reduced, setReduced] = useState(query?.matches === true);
916
+ useEffect(() => {
917
+ if (!query) return;
918
+ const on = () => setReduced(query.matches);
919
+ on();
920
+ query.addEventListener?.("change", on);
921
+ return () => query.removeEventListener?.("change", on);
922
+ }, [query]);
923
+ return reduced;
924
+ }
925
+ function ScadaSymbol({ widget, data }) {
667
926
  const thresholds = useMemo6(() => optThresholds6(widget.options, "thresholds"), [widget.options]);
927
+ const symbolOption = optString6(widget.options, "symbol");
928
+ const symbol = isScadaSymbol(symbolOption) ? symbolOption : "pump";
668
929
  const reading = useLevelReading(widget, data, {
669
930
  thresholds,
670
931
  unit: optString6(widget.options, "unit"),
671
- precision: optNumber6(widget.options, "precision")
932
+ precision: optNumber6(widget.options, "precision"),
933
+ // A tank is the one symbol with a scale; both ends are needed, none is invented.
934
+ range: symbol === "tank" ? readRange(optNumber6(widget.options, "min"), optNumber6(widget.options, "max")) : void 0
672
935
  });
673
936
  const title = optString6(widget.options, "title") ?? reading.name;
674
- return /* @__PURE__ */ jsx6(WidgetFrame6, { title, sampleTime: reading.sample?.occurredTime ?? null, children: (scale) => /* @__PURE__ */ jsx6(BarsBody, { reading, scale }) });
937
+ const onAt = optNumber6(widget.options, "onAt");
938
+ const vertical = optString6(widget.options, "orientation") === "vertical";
939
+ return /* @__PURE__ */ jsx7(WidgetFrame6, { title, sampleTime: reading.sample?.occurredTime ?? null, children: (scale) => /* @__PURE__ */ jsx7(SymbolBody, { symbol, reading, onAt, vertical, scale }) });
940
+ }
941
+ function SymbolBody({ symbol, reading: r, onAt, vertical, scale: ws }) {
942
+ const motion = !usePrefersReducedMotion();
943
+ const words = scadaStrings();
944
+ const reason = symbol === "tank" ? emptyReason(r) : void 0;
945
+ if (reason !== void 0) return /* @__PURE__ */ jsx7(LevelEmptyFor, { reading: r, reason });
946
+ const { state, flow } = readSymbol(symbol, r.value, onAt, r.band);
947
+ const name = words.symbols[symbol];
948
+ const stateWord = words.states[symbol][state];
949
+ const showValue = isContinuous(symbol) && r.value !== void 0;
950
+ const fill = symbol === "tank" && r.fill ? r.fill.fraction : void 0;
951
+ const reading = showValue ? `${formatValue5(r.value, r.precision)}${r.unit ? ` ${r.unit}` : ""}` : void 0;
952
+ const flowWord = symbol === "pipe" && flow !== "none" ? ` (${flow === "reverse" ? words.reverse : words.forward})` : "";
953
+ const caption = reading !== void 0 ? `${reading}${state === "fault" ? ` \xB7 ${stateWord}` : ""}` : `${stateWord}${flowWord}`;
954
+ const label = words.label(name, caption);
955
+ const captionRoom = ws.px("font-md") * 1.8;
956
+ const room = ws.size.height - captionRoom;
957
+ const measuredWidth = room > 0 ? `${room * (symbol === "pipe" && !vertical ? 4 : 1.1)}px` : void 0;
958
+ return /* @__PURE__ */ jsxs7(
959
+ "div",
960
+ {
961
+ "data-scada-state": state,
962
+ "data-threshold-level": r.band?.level,
963
+ style: { height: "100%", boxSizing: "border-box", display: "flex", flexDirection: "column", alignItems: "center", gap: ws.px("space-1"), minHeight: 0 },
964
+ children: [
965
+ /* @__PURE__ */ jsx7("div", { style: { flex: "1 1 0", minHeight: ws.px("space-4"), width: "100%", maxWidth: measuredWidth }, children: /* @__PURE__ */ jsx7(
966
+ SymbolArt,
967
+ {
968
+ symbol,
969
+ label,
970
+ paint: { state, accent: r.fillColor, flow, motion, fill, horizontal: !vertical }
971
+ }
972
+ ) }),
973
+ /* @__PURE__ */ jsx7(
974
+ "div",
975
+ {
976
+ "data-scada-caption": "",
977
+ style: {
978
+ fontSize: fontVar2("md"),
979
+ fontWeight: 600,
980
+ lineHeight: 1.2,
981
+ textAlign: "center",
982
+ overflowWrap: "anywhere",
983
+ maxWidth: "100%",
984
+ color: state === "unknown" ? css7("muted-foreground") : css7("foreground")
985
+ },
986
+ children: caption
987
+ }
988
+ )
989
+ ]
990
+ }
991
+ );
992
+ }
993
+
994
+ // src/widgets/signal-bars.tsx
995
+ import { useMemo as useMemo7 } from "react";
996
+ import {
997
+ css as css8,
998
+ optNumber as optNumber7,
999
+ optString as optString7,
1000
+ optThresholds as optThresholds7,
1001
+ WidgetFrame as WidgetFrame7
1002
+ } from "@devicechain/widget-sdk";
1003
+ import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
1004
+ var SIGNAL_MIN_BARS = 2;
1005
+ var VIEW2 = { w: 100, h: 60 };
1006
+ function SignalBars({ widget, data }) {
1007
+ const thresholds = useMemo7(() => optThresholds7(widget.options, "thresholds"), [widget.options]);
1008
+ const reading = useLevelReading(widget, data, {
1009
+ thresholds,
1010
+ unit: optString7(widget.options, "unit"),
1011
+ precision: optNumber7(widget.options, "precision")
1012
+ });
1013
+ const title = optString7(widget.options, "title") ?? reading.name;
1014
+ return /* @__PURE__ */ jsx8(WidgetFrame7, { title, sampleTime: reading.sample?.occurredTime ?? null, children: (scale) => /* @__PURE__ */ jsx8(BarsBody, { reading, scale }) });
675
1015
  }
676
1016
  function BarsBody({ reading: r, scale: ws }) {
677
- if (r.thresholds.length < SIGNAL_MIN_BARS) return /* @__PURE__ */ jsx6(LevelEmpty, { message: r.strings.setThresholds });
1017
+ if (r.thresholds.length < SIGNAL_MIN_BARS) return /* @__PURE__ */ jsx8(LevelEmpty, { message: r.strings.setThresholds });
678
1018
  const bars = litBars(r.thresholds, r.value);
679
- if (!bars) return /* @__PURE__ */ jsx6(LevelEmptyFor, { reading: r, reason: void 0 });
1019
+ if (!bars) return /* @__PURE__ */ jsx8(LevelEmptyFor, { reading: r, reason: void 0 });
680
1020
  const n = bars.total;
681
1021
  const barW = VIEW2.w / (n + (n - 1) / 3);
682
1022
  const gapW = barW / 3;
683
1023
  const readoutHeight = Math.max(ws.px("font-md") * 1.6, ws.size.height * 0.34);
684
- return /* @__PURE__ */ jsxs6(
1024
+ return /* @__PURE__ */ jsxs8(
685
1025
  "div",
686
1026
  {
687
1027
  "data-threshold-level": r.band?.level,
@@ -689,7 +1029,7 @@ function BarsBody({ reading: r, scale: ws }) {
689
1029
  "data-bars-total": bars.total,
690
1030
  style: { height: "100%", boxSizing: "border-box", display: "flex", flexDirection: "column", gap: ws.px("space-1") },
691
1031
  children: [
692
- /* @__PURE__ */ jsx6("div", { style: { flex: "1 1 0", minHeight: 0 }, children: /* @__PURE__ */ jsx6(
1032
+ /* @__PURE__ */ jsx8("div", { style: { flex: "1 1 0", minHeight: 0 }, children: /* @__PURE__ */ jsx8(
693
1033
  "svg",
694
1034
  {
695
1035
  role: "meter",
@@ -703,7 +1043,7 @@ function BarsBody({ reading: r, scale: ws }) {
703
1043
  children: Array.from({ length: n }, (_, i) => {
704
1044
  const h = VIEW2.h * (i + 1) / n;
705
1045
  const lit = i < bars.lit;
706
- return /* @__PURE__ */ jsx6(
1046
+ return /* @__PURE__ */ jsx8(
707
1047
  "rect",
708
1048
  {
709
1049
  "data-bar": lit ? "lit" : "unlit",
@@ -712,14 +1052,14 @@ function BarsBody({ reading: r, scale: ws }) {
712
1052
  width: barW,
713
1053
  height: h,
714
1054
  rx: Math.min(3, barW / 3),
715
- style: { fill: lit ? r.fillColor : css6("muted") }
1055
+ style: { fill: lit ? r.fillColor : css8("muted") }
716
1056
  },
717
1057
  i
718
1058
  );
719
1059
  })
720
1060
  }
721
1061
  ) }),
722
- /* @__PURE__ */ jsx6("div", { style: { flex: "0 0 auto", height: readoutHeight, display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ jsx6(
1062
+ /* @__PURE__ */ jsx8("div", { style: { flex: "0 0 auto", height: readoutHeight, display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ jsx8(
723
1063
  LevelReadout,
724
1064
  {
725
1065
  text: r.display,
@@ -736,26 +1076,26 @@ function BarsBody({ reading: r, scale: ws }) {
736
1076
  }
737
1077
 
738
1078
  // src/widgets/status-light.tsx
739
- import { useMemo as useMemo7 } from "react";
1079
+ import { useMemo as useMemo8 } from "react";
740
1080
  import {
741
- css as css7,
742
- fontVar as fontVar2,
743
- optNumber as optNumber7,
744
- optString as optString7,
745
- optThresholds as optThresholds7,
746
- WidgetFrame as WidgetFrame7
1081
+ css as css9,
1082
+ fontVar as fontVar3,
1083
+ optNumber as optNumber8,
1084
+ optString as optString8,
1085
+ optThresholds as optThresholds8,
1086
+ WidgetFrame as WidgetFrame8
747
1087
  } from "@devicechain/widget-sdk";
748
- import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
1088
+ import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
749
1089
  function StatusLight({ widget, data }) {
750
- const thresholds = useMemo7(() => optThresholds7(widget.options, "thresholds"), [widget.options]);
1090
+ const thresholds = useMemo8(() => optThresholds8(widget.options, "thresholds"), [widget.options]);
751
1091
  const reading = useLevelReading(widget, data, {
752
1092
  thresholds,
753
- unit: optString7(widget.options, "unit"),
754
- precision: optNumber7(widget.options, "precision")
1093
+ unit: optString8(widget.options, "unit"),
1094
+ precision: optNumber8(widget.options, "precision")
755
1095
  });
756
- const title = optString7(widget.options, "title") ?? reading.name;
757
- const onAt = optNumber7(widget.options, "onAt");
758
- return /* @__PURE__ */ jsx7(WidgetFrame7, { title, sampleTime: reading.sample?.occurredTime ?? null, children: (scale) => /* @__PURE__ */ jsx7(LampBody, { reading, onAt, scale }) });
1096
+ const title = optString8(widget.options, "title") ?? reading.name;
1097
+ const onAt = optNumber8(widget.options, "onAt");
1098
+ return /* @__PURE__ */ jsx9(WidgetFrame8, { title, sampleTime: reading.sample?.occurredTime ?? null, children: (scale) => /* @__PURE__ */ jsx9(LampBody, { reading, onAt, scale }) });
759
1099
  }
760
1100
  function lampState(r, onAt) {
761
1101
  if (r.value === void 0) return { lit: void 0, caption: r.strings.noData };
@@ -771,7 +1111,7 @@ function LampBody({ reading: r, onAt, scale: ws }) {
771
1111
  const beside = measured && ws.size.height - captionRoom < smallest * 2;
772
1112
  const diameter = !measured ? smallest * 3 : beside ? Math.max(Math.min(smallest, ws.size.height), Math.floor(Math.min(ws.size.height, ws.size.width * 0.4) * 0.8)) : Math.max(smallest, Math.floor(Math.min(ws.size.width, ws.size.height - captionRoom) * 0.8));
773
1113
  const color = r.fillColor;
774
- return /* @__PURE__ */ jsxs7(
1114
+ return /* @__PURE__ */ jsxs9(
775
1115
  "div",
776
1116
  {
777
1117
  "data-threshold-level": lit ? r.band?.level : void 0,
@@ -789,7 +1129,7 @@ function LampBody({ reading: r, onAt, scale: ws }) {
789
1129
  textAlign: "center"
790
1130
  },
791
1131
  children: [
792
- /* @__PURE__ */ jsx7(
1132
+ /* @__PURE__ */ jsx9(
793
1133
  "div",
794
1134
  {
795
1135
  "data-lamp": "",
@@ -800,20 +1140,20 @@ function LampBody({ reading: r, onAt, scale: ws }) {
800
1140
  borderRadius: "50%",
801
1141
  boxSizing: "border-box",
802
1142
  background: lit ? color : "transparent",
803
- border: `2px solid ${lit ? color : css7("muted-foreground")}`,
1143
+ border: `2px solid ${lit ? color : css9("muted-foreground")}`,
804
1144
  boxShadow: lit ? `0 0 ${Math.round(diameter / 4)}px ${color}` : "none"
805
1145
  }
806
1146
  }
807
1147
  ),
808
- /* @__PURE__ */ jsx7(
1148
+ /* @__PURE__ */ jsx9(
809
1149
  "div",
810
1150
  {
811
1151
  "data-lamp-caption": "",
812
1152
  style: {
813
- fontSize: fontVar2("md"),
1153
+ fontSize: fontVar3("md"),
814
1154
  fontWeight: 600,
815
1155
  lineHeight: 1.2,
816
- color: lit === void 0 ? css7("muted-foreground") : css7("foreground"),
1156
+ color: lit === void 0 ? css9("muted-foreground") : css9("foreground"),
817
1157
  overflowWrap: "anywhere",
818
1158
  maxWidth: "100%",
819
1159
  minWidth: 0
@@ -831,7 +1171,8 @@ export {
831
1171
  LevelGauge,
832
1172
  LinearGauge,
833
1173
  ProgressRing,
1174
+ ScadaSymbol,
834
1175
  SignalBars,
835
1176
  StatusLight
836
1177
  };
837
- //# sourceMappingURL=level-widgets-HE6EDSWC.js.map
1178
+ //# sourceMappingURL=level-widgets-DKCQT2XF.js.map