flight-indicators 1.0.3 → 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.
package/dist/index.cjs CHANGED
@@ -21,13 +21,37 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  // src/index.ts
22
22
  var index_exports = {};
23
23
  __export(index_exports, {
24
+ AdfIndicator: () => AdfIndicator,
24
25
  Airspeed: () => Airspeed,
25
26
  Altimeter: () => Altimeter,
27
+ AoaIndicator: () => AoaIndicator,
26
28
  AttitudeIndicator: () => AttitudeIndicator,
29
+ DEFAULT_BAR_GAUGES: () => DEFAULT_BAR_GAUGES,
30
+ DEFAULT_MANIFOLD: () => DEFAULT_MANIFOLD,
31
+ DEFAULT_RPM: () => DEFAULT_RPM,
32
+ DataPanel: () => DataPanel,
33
+ EngineIndicator: () => EngineIndicator,
34
+ FlapIndicator: () => FlapIndicator,
35
+ FuelIndicator: () => FuelIndicator,
27
36
  HeadingIndicator: () => HeadingIndicator,
37
+ MAX_BAR_GAUGES: () => MAX_BAR_GAUGES,
38
+ MAX_CYLINDERS: () => MAX_CYLINDERS,
39
+ MAX_FIELDS: () => MAX_FIELDS,
40
+ MAX_TANKS: () => MAX_TANKS,
41
+ RadioPanel: () => RadioPanel,
42
+ RadioStack: () => RadioStack,
28
43
  TurnCoordinator: () => TurnCoordinator,
29
44
  VerticalSpeed: () => VerticalSpeed,
30
- WindIndicator: () => WindIndicator
45
+ VorIndicator: () => VorIndicator,
46
+ WindIndicator: () => WindIndicator,
47
+ formatAdf: () => formatAdf,
48
+ formatDme: () => formatDme,
49
+ formatNav: () => formatNav,
50
+ formatValue: () => formatValue,
51
+ parseAdf: () => parseAdf,
52
+ parseNav: () => parseNav,
53
+ relativeBearing: () => relativeBearing,
54
+ vorDeviation: () => vorDeviation
31
55
  });
32
56
  module.exports = __toCommonJS(index_exports);
33
57
 
@@ -97,7 +121,7 @@ function InstrumentFrame({
97
121
  className,
98
122
  style,
99
123
  title,
100
- label,
124
+ label: label2,
101
125
  children
102
126
  }) {
103
127
  const titleId = useSvgId("fi-title");
@@ -115,7 +139,7 @@ function InstrumentFrame({
115
139
  style: { display: "inline-block", userSelect: "none", ...style },
116
140
  fontFamily: "'Helvetica Neue', Arial, sans-serif",
117
141
  children: [
118
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("title", { id: titleId, children: title ?? label }),
142
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("title", { id: titleId, children: title ?? label2 }),
119
143
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("linearGradient", { id: bezelId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
120
144
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("stop", { offset: "0", stopColor: "#5a5a5a" }),
121
145
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("stop", { offset: "1", stopColor: "#1a1a1a" })
@@ -219,7 +243,7 @@ function HeadingIndicator({ heading = 0, ...props }) {
219
243
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("g", { stroke: "#fff", strokeLinecap: "round", children: range(0, 355, 5).map((a) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: tickPath(176, a % 10 === 0 ? 152 : 164, a), strokeWidth: a % 10 === 0 ? 3 : 2 }, a)) }),
220
244
  range(0, 330, 30).map((a) => {
221
245
  const [x, y] = polar(132, a);
222
- const label = CARDINALS[a] ?? String(a / 10);
246
+ const label2 = CARDINALS[a] ?? String(a / 10);
223
247
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
224
248
  "text",
225
249
  {
@@ -231,7 +255,7 @@ function HeadingIndicator({ heading = 0, ...props }) {
231
255
  fontWeight: "bold",
232
256
  textAnchor: "middle",
233
257
  dominantBaseline: "central",
234
- children: label
258
+ children: label2
235
259
  },
236
260
  a
237
261
  );
@@ -534,8 +558,8 @@ function WindIndicator({
534
558
  const dirText = String(Math.round(norm(dir)) || 360).padStart(3, "0");
535
559
  const windText = calm ? "CALM" : `${dirText}\xB0 ${Math.round(speed)}${hasGust ? `G${Math.round(gust)}` : ""}KT`;
536
560
  const crossText = crosswind === 0 ? "0" : `${Math.abs(crosswind)}${crosswind > 0 ? "R" : "L"}`;
537
- const label = `Wind: ${calm ? "calm" : `${dirText}\xB0 at ${Math.round(speed)}${hasGust ? ` gusting ${Math.round(gust)}` : ""} knots`}, runway ${activeNumber}${activeSide ?? ""} in use, ${headwind < 0 ? "tailwind" : "headwind"} ${Math.abs(headwind)}, crosswind ${Math.abs(crosswind)}${crosswind === 0 ? "" : crosswind > 0 ? " from the right" : " from the left"}`;
538
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(InstrumentFrame, { ...props, label, children: [
561
+ const label2 = `Wind: ${calm ? "calm" : `${dirText}\xB0 at ${Math.round(speed)}${hasGust ? ` gusting ${Math.round(gust)}` : ""} knots`}, runway ${activeNumber}${activeSide ?? ""} in use, ${headwind < 0 ? "tailwind" : "headwind"} ${Math.abs(headwind)}, crosswind ${Math.abs(crosswind)}${crosswind === 0 ? "" : crosswind > 0 ? " from the right" : " from the left"}`;
562
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(InstrumentFrame, { ...props, label: label2, children: [
539
563
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("g", { stroke: "#fff", strokeLinecap: "round", children: range(0, 350, 10).map((a) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: tickPath(176, a % 30 === 0 ? 162 : 168, a), strokeWidth: a % 30 === 0 ? 3 : 2, opacity: a % 30 === 0 ? 1 : 0.7 }, a)) }),
540
564
  range(0, 330, 30).map((a) => {
541
565
  const [x, y] = polar(146, a);
@@ -591,14 +615,1019 @@ function WindIndicator({
591
615
  ) })
592
616
  ] });
593
617
  }
618
+
619
+ // src/components/VorIndicator.tsx
620
+ var import_jsx_runtime9 = require("react/jsx-runtime");
621
+ var CARDINALS3 = { 0: "N", 90: "E", 180: "S", 270: "W" };
622
+ var AMBER2 = "#ffb000";
623
+ var FULL_SCALE_DEG = 10;
624
+ var DOT_SPACING = 22;
625
+ var FULL_SCALE_PX = DOT_SPACING * 5;
626
+ var norm2 = (deg) => (deg % 360 + 360) % 360;
627
+ var signedDiff = (a, b) => ((a - b) % 360 + 540) % 360 - 180;
628
+ function vorDeviation(course, radial) {
629
+ const d = signedDiff(radial, course);
630
+ return Math.abs(d) <= 90 ? { deviation: -d, toFrom: "FROM" } : { deviation: signedDiff(d, 180), toFrom: "TO" };
631
+ }
632
+ function Flag({ y, up, visible, testId }) {
633
+ const dir = up ? -1 : 1;
634
+ const tip = y + dir * 17;
635
+ const headBase = y + dir * 1;
636
+ const tail = y - dir * 15;
637
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("g", { "data-testid": testId, opacity: visible ? 1 : 0, style: { transition: "opacity 200ms ease-out" }, children: [
638
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
639
+ "path",
640
+ {
641
+ d: `M ${CENTER} ${tip} L ${CENTER - 13} ${headBase} H ${CENTER - 4} V ${tail} H ${CENTER + 4} V ${headBase} H ${CENTER + 13} Z`,
642
+ fill: "#fff",
643
+ stroke: "#000",
644
+ strokeWidth: "1.5",
645
+ strokeLinejoin: "round"
646
+ }
647
+ ),
648
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("text", { x: CENTER + 22, y, fill: "#fff", fontSize: "15", fontWeight: "bold", dominantBaseline: "central", children: up ? "TO" : "FROM" })
649
+ ] });
650
+ }
651
+ function VorIndicator({ course = 0, radial, deviation, toFrom, signal = true, ...props }) {
652
+ const duration = props.animationDuration ?? DEFAULT_ANIMATION_MS;
653
+ const crs = finite(course);
654
+ const computed = typeof radial === "number" && Number.isFinite(radial) ? vorDeviation(crs, radial) : void 0;
655
+ const rawDeviation = finite(deviation, computed?.deviation ?? 0);
656
+ const dev = signal ? clamp(rawDeviation, -FULL_SCALE_DEG, FULL_SCALE_DEG) : 0;
657
+ const flag = !signal ? "OFF" : toFrom ?? computed?.toFrom ?? "OFF";
658
+ const displayCourse = useContinuousAngle(crs);
659
+ const courseText = String(Math.round(norm2(crs)) || 360).padStart(3, "0");
660
+ const needleX = dev / FULL_SCALE_DEG * FULL_SCALE_PX;
661
+ const devText = Math.abs(dev) < 0.05 ? "centred" : `${Math.abs(dev).toFixed(1)}\xB0 ${dev > 0 ? "right" : "left"}`;
662
+ const label2 = signal ? `VOR indicator: course ${courseText}\xB0, needle ${devText}, ${flag === "OFF" ? "no TO/FROM indication" : flag}` : `VOR indicator: course ${courseText}\xB0, no signal`;
663
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(InstrumentFrame, { ...props, label: label2, children: [
664
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("g", { "data-testid": "vor-card", style: motionStyle(`rotate(${-displayCourse}deg)`, duration), children: [
665
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("g", { stroke: "#fff", strokeLinecap: "round", children: range(0, 355, 5).map((a) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: tickPath(176, a % 10 === 0 ? 152 : 164, a), strokeWidth: a % 10 === 0 ? 3 : 2 }, a)) }),
666
+ range(0, 330, 30).map((a) => {
667
+ const [x, y] = polar(132, a);
668
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
669
+ "text",
670
+ {
671
+ x,
672
+ y,
673
+ transform: `rotate(${a} ${x} ${y})`,
674
+ fill: a % 90 === 0 ? AMBER2 : "#fff",
675
+ fontSize: a % 90 === 0 ? 28 : 24,
676
+ fontWeight: "bold",
677
+ textAnchor: "middle",
678
+ dominantBaseline: "central",
679
+ children: CARDINALS3[a] ?? String(a / 10)
680
+ },
681
+ a
682
+ );
683
+ })
684
+ ] }),
685
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: `M ${CENTER} ${CENTER - 150} l -10 -28 h 20 z`, fill: AMBER2, stroke: "#000", strokeWidth: "1.5" }),
686
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: `M ${CENTER} ${CENTER + 150} l -8 24 h 16 z`, fill: "#fff", stroke: "#000", strokeWidth: "1.5" }),
687
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("g", { stroke: AMBER2, strokeWidth: "4", strokeLinecap: "round", children: [45, 90, 135, 225, 270, 315].map((a) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: tickPath(192, 178, a) }, a)) }),
688
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("g", { fill: "#fff", stroke: "#000", strokeWidth: "1", children: range(1, 5, 1).flatMap((i) => [-i, i]).map((i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("circle", { cx: CENTER + i * DOT_SPACING, cy: CENTER, r: "5" }, i)) }),
689
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("circle", { cx: CENTER, cy: CENTER, r: "9", fill: "none", stroke: "#fff", strokeWidth: "2.5" }),
690
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Flag, { y: CENTER - 54, up: true, visible: flag === "TO", testId: "vor-to" }),
691
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Flag, { y: CENTER + 54, up: false, visible: flag === "FROM", testId: "vor-from" }),
692
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("g", { "data-testid": "vor-needle", style: motionStyle(`translate(${needleX}px, 0px)`, duration), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("rect", { x: CENTER - 3, y: CENTER - 68, width: "6", height: "136", rx: "3", fill: "#fff", stroke: "#000", strokeWidth: "1.5" }) }),
693
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("rect", { x: CENTER - 44, y: CENTER + 72, width: "88", height: "26", rx: "4", fill: "#000", stroke: "#555", strokeWidth: "2" }),
694
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
695
+ "text",
696
+ {
697
+ "data-testid": "vor-course",
698
+ x: CENTER,
699
+ y: CENTER + 86,
700
+ fill: "#fff",
701
+ fontSize: "17",
702
+ fontFamily: "monospace",
703
+ fontWeight: "bold",
704
+ textAnchor: "middle",
705
+ dominantBaseline: "central",
706
+ children: [
707
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("tspan", { fill: "#ccc", children: "CRS " }),
708
+ courseText
709
+ ]
710
+ }
711
+ ),
712
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("g", { "data-testid": "vor-nav-flag", opacity: signal ? 0 : 1, style: { transition: "opacity 200ms ease-out" }, children: [
713
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("rect", { x: CENTER - 28, y: CENTER - 98, width: "56", height: "24", rx: "3", fill: "#d42626", stroke: "#000", strokeWidth: "1.5" }),
714
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("text", { x: CENTER, y: CENTER - 85, fill: "#fff", fontSize: "15", fontWeight: "bold", textAnchor: "middle", dominantBaseline: "central", children: "NAV" })
715
+ ] })
716
+ ] });
717
+ }
718
+
719
+ // src/components/AdfIndicator.tsx
720
+ var import_jsx_runtime10 = require("react/jsx-runtime");
721
+ var CARDINALS4 = { 0: "N", 90: "E", 180: "S", 270: "W" };
722
+ var AMBER3 = "#ffb000";
723
+ var NEEDLE = "#ffe14d";
724
+ var PARKED_DEG = 90;
725
+ var norm3 = (deg) => (deg % 360 + 360) % 360;
726
+ var pad3 = (deg) => String(Math.round(norm3(deg)) % 360).padStart(3, "0");
727
+ function relativeBearing(heading, bearingToStation) {
728
+ return norm3(finite(bearingToStation) - finite(heading));
729
+ }
730
+ function AdfIndicator({ bearing = 0, heading = 0, signal = true, ...props }) {
731
+ const duration = props.animationDuration ?? DEFAULT_ANIMATION_MS;
732
+ const rel = finite(bearing);
733
+ const hdg = finite(heading);
734
+ const displayCard = useContinuousAngle(hdg);
735
+ const displayNeedle = useContinuousAngle(signal ? rel : PARKED_DEG);
736
+ const label2 = signal ? `ADF indicator: station ${pad3(rel)}\xB0 relative, bearing ${pad3(rel + hdg)}\xB0 to station` : "ADF indicator: no signal";
737
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(InstrumentFrame, { ...props, label: label2, children: [
738
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("g", { "data-testid": "adf-card", style: motionStyle(`rotate(${-displayCard}deg)`, duration), children: [
739
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("g", { stroke: "#fff", strokeLinecap: "round", children: range(0, 355, 5).map((a) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: tickPath(176, a % 10 === 0 ? 152 : 164, a), strokeWidth: a % 10 === 0 ? 3 : 2 }, a)) }),
740
+ range(0, 330, 30).map((a) => {
741
+ const [x, y] = polar(132, a);
742
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
743
+ "text",
744
+ {
745
+ x,
746
+ y,
747
+ transform: `rotate(${a} ${x} ${y})`,
748
+ fill: a % 90 === 0 ? AMBER3 : "#fff",
749
+ fontSize: a % 90 === 0 ? 28 : 24,
750
+ fontWeight: "bold",
751
+ textAnchor: "middle",
752
+ dominantBaseline: "central",
753
+ children: CARDINALS4[a] ?? String(a / 10)
754
+ },
755
+ a
756
+ );
757
+ })
758
+ ] }),
759
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: `M ${CENTER} ${CENTER - 150} l -10 -28 h 20 z`, fill: AMBER3, stroke: "#000", strokeWidth: "1.5" }),
760
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("g", { stroke: AMBER3, strokeWidth: "4", strokeLinecap: "round", children: [45, 90, 135, 180, 225, 270, 315].map((a) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: tickPath(192, 178, a) }, a)) }),
761
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("g", { stroke: AMBER3, strokeWidth: "2", strokeLinecap: "round", opacity: "0.7", children: [
762
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: `M ${CENTER - 26} ${CENTER} H ${CENTER + 26}` }),
763
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: `M ${CENTER} ${CENTER - 26} V ${CENTER + 14}` })
764
+ ] }),
765
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("text", { x: CENTER, y: CENTER + 62, fill: "#ccc", fontSize: "15", fontWeight: "bold", letterSpacing: "2", textAnchor: "middle", dominantBaseline: "central", children: "ADF" }),
766
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("g", { "data-testid": "adf-flag", opacity: signal ? 0 : 1, style: { transition: "opacity 200ms ease-out" }, children: [
767
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("rect", { x: CENTER - 28, y: CENTER - 76, width: "56", height: "24", rx: "3", fill: "#d42626", stroke: "#000", strokeWidth: "1.5" }),
768
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("text", { x: CENTER, y: CENTER - 63, fill: "#fff", fontSize: "15", fontWeight: "bold", textAnchor: "middle", dominantBaseline: "central", children: "ADF" })
769
+ ] }),
770
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("g", { "data-testid": "adf-needle", style: motionStyle(`rotate(${displayNeedle}deg)`, duration), children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
771
+ "path",
772
+ {
773
+ d: `M ${CENTER} ${CENTER - 146} l -13 30 h 9 V ${CENTER + 140} h 8 V ${CENTER - 116} h 9 z`,
774
+ fill: NEEDLE,
775
+ stroke: "#000",
776
+ strokeWidth: "1.5",
777
+ strokeLinejoin: "round"
778
+ }
779
+ ) }),
780
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Hub, { r: 10 })
781
+ ] });
782
+ }
783
+
784
+ // src/components/RadioPanel.tsx
785
+ var import_jsx_runtime11 = require("react/jsx-runtime");
786
+ var SIDE = 252;
787
+ var ORIGIN = CENTER - SIDE / 2;
788
+ var ROW_H = 60;
789
+ var ROW_GAP = 8;
790
+ var FIRST_ROW = ORIGIN + 32;
791
+ var LABEL_X = ORIGIN + 10;
792
+ var ACTIVE_X = ORIGIN + 48;
793
+ var DISPLAY_W = 88;
794
+ var STANDBY_X = ORIGIN + SIDE - 8 - DISPLAY_W;
795
+ var SWAP_X = (ACTIVE_X + DISPLAY_W + STANDBY_X) / 2;
796
+ var usable = (n) => typeof n === "number" && Number.isFinite(n) && n >= 0;
797
+ var formatNav = (mhz) => usable(mhz) ? mhz.toFixed(2) : "---.--";
798
+ var formatAdf = (khz) => usable(khz) ? Number.isInteger(khz) ? String(khz) : khz.toFixed(1) : "---";
799
+ var formatDme = (nm) => usable(nm) ? nm < 99.95 ? nm.toFixed(1) : nm.toFixed(0) : "--.-";
800
+ function Display({ x, y, width, value, color, testId, unit }) {
801
+ const h = ROW_H - 16;
802
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("g", { children: [
803
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("rect", { x, y: y + 8, width, height: h, rx: "5", fill: "#1a0d00", stroke: "#3a2a14", strokeWidth: "1.5" }),
804
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
805
+ "text",
806
+ {
807
+ "data-testid": testId,
808
+ x: unit ? x + width - 40 : x + width / 2,
809
+ y: y + ROW_H / 2 + 1,
810
+ fill: color,
811
+ fontSize: unit ? 28 : 22,
812
+ fontFamily: "monospace",
813
+ fontWeight: "bold",
814
+ textAnchor: unit ? "end" : "middle",
815
+ dominantBaseline: "central",
816
+ children: value
817
+ }
818
+ ),
819
+ unit && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("text", { x: x + width - 10, y: y + ROW_H / 2 + 5, fill: "#9aa4b1", fontSize: "13", fontWeight: "bold", textAnchor: "end", dominantBaseline: "central", children: unit })
820
+ ] });
821
+ }
822
+ function Swap({ y }) {
823
+ const cy = y + ROW_H / 2;
824
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("g", { stroke: "#9aa4b1", strokeWidth: "1.8", fill: "none", strokeLinecap: "round", strokeLinejoin: "round", children: [
825
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", { d: `M ${SWAP_X - 7} ${cy - 4} H ${SWAP_X + 7} m -4 -3 l 4 3 l -4 3` }),
826
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", { d: `M ${SWAP_X + 7} ${cy + 4} H ${SWAP_X - 7} m 4 -3 l -4 3 l 4 3` })
827
+ ] });
828
+ }
829
+ function RowLabel({ y, children }) {
830
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("text", { x: LABEL_X, y: y + ROW_H / 2 + 1, fill: "#ccc", fontSize: "14", fontWeight: "bold", letterSpacing: "1", dominantBaseline: "central", children });
831
+ }
832
+ function RadioPanel({ nav, adf, dme, color = "#ff9a2e", ...props }) {
833
+ const rows = [
834
+ { key: "nav", name: "NAV", unit: "MHz", active: formatNav(nav?.active), standby: formatNav(nav?.standby), tuned: usable(nav?.active) },
835
+ { key: "adf", name: "ADF", unit: "kHz", active: formatAdf(adf?.active), standby: formatAdf(adf?.standby), tuned: usable(adf?.active) }
836
+ ];
837
+ const dmeText = formatDme(dme);
838
+ const dmeY = FIRST_ROW + 2 * (ROW_H + ROW_GAP);
839
+ const label2 = "Radio panel: " + rows.map((r) => `${r.name} ${r.tuned ? `${r.active} ${r.unit}` : "not tuned"}`).join(", ") + `, DME ${usable(dme) ? `${dmeText} NM` : "no distance"}`;
840
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(InstrumentFrame, { ...props, label: label2, children: [
841
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("rect", { x: ORIGIN, y: ORIGIN, width: SIDE, height: SIDE, rx: "10", fill: "#1c1f24", stroke: "#3a3f47", strokeWidth: "2" }),
842
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("g", { fill: "#9aa4b1", fontSize: "11", fontWeight: "bold", letterSpacing: "1.5", textAnchor: "middle", dominantBaseline: "central", children: [
843
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("text", { x: ACTIVE_X + DISPLAY_W / 2, y: ORIGIN + 22, children: "ACTIVE" }),
844
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("text", { x: STANDBY_X + DISPLAY_W / 2, y: ORIGIN + 22, children: "STBY" })
845
+ ] }),
846
+ rows.map((r, i) => {
847
+ const y = FIRST_ROW + i * (ROW_H + ROW_GAP);
848
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("g", { children: [
849
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(RowLabel, { y, children: r.name }),
850
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Display, { x: ACTIVE_X, y, width: DISPLAY_W, value: r.active, color, testId: `radio-${r.key}-active` }),
851
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Swap, { y }),
852
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Display, { x: STANDBY_X, y, width: DISPLAY_W, value: r.standby, color, testId: `radio-${r.key}-standby` })
853
+ ] }, r.key);
854
+ }),
855
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(RowLabel, { y: dmeY, children: "DME" }),
856
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Display, { x: ACTIVE_X, y: dmeY, width: STANDBY_X + DISPLAY_W - ACTIVE_X, value: dmeText, color, testId: "radio-dme", unit: "NM" })
857
+ ] });
858
+ }
859
+
860
+ // src/components/RadioStack.tsx
861
+ var import_react2 = require("react");
862
+ var import_jsx_runtime12 = require("react/jsx-runtime");
863
+ var parseNav = (text) => {
864
+ const mhz = Math.round(Number.parseFloat(text.replace(",", ".")) * 100) / 100;
865
+ return mhz >= 108 && mhz <= 117.95 ? mhz : void 0;
866
+ };
867
+ var parseAdf = (text) => {
868
+ const khz = Math.round(Number.parseFloat(text.replace(",", ".")) * 10) / 10;
869
+ return khz >= 190 && khz <= 1750 ? khz : void 0;
870
+ };
871
+ var MONO = "ui-monospace, 'SF Mono', Menlo, Consolas, monospace";
872
+ var LABEL = "#ccc";
873
+ var MUTED = "#9aa4b1";
874
+ var display = {
875
+ boxSizing: "border-box",
876
+ width: "100%",
877
+ minWidth: 0,
878
+ height: "2.1em",
879
+ margin: 0,
880
+ padding: "0 0.1em",
881
+ borderRadius: "0.25em",
882
+ border: "0.08em solid #3a2a14",
883
+ background: "#1a0d00",
884
+ fontFamily: MONO,
885
+ fontSize: "1.2em",
886
+ fontWeight: "bold",
887
+ lineHeight: "2em",
888
+ textAlign: "center",
889
+ whiteSpace: "nowrap",
890
+ overflow: "hidden"
891
+ };
892
+ var label = { display: "flex", flexDirection: "column", justifyContent: "center", color: LABEL, fontWeight: "bold", letterSpacing: "0.06em", lineHeight: 1.15 };
893
+ var ident = { color: "#3cc8ff", fontSize: "0.72em", fontFamily: MONO, minHeight: "1.15em" };
894
+ function SwapIcon() {
895
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("svg", { viewBox: "0 0 16 16", width: "1em", height: "1em", "aria-hidden": "true", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", children: [
896
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M2 5.5 H14 M11 2.5 l3 3 l-3 3" }),
897
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M14 10.5 H2 M5 7.5 l-3 3 l3 3" })
898
+ ] });
899
+ }
900
+ function Receiver({ name, unit, value, ident: station, color, format, parse, onChange }) {
901
+ const [draft, setDraft] = (0, import_react2.useState)(null);
902
+ const [focused, setFocused] = (0, import_react2.useState)(false);
903
+ const [invalid, setInvalid] = (0, import_react2.useState)(false);
904
+ const key = name.toLowerCase();
905
+ const shown = value.standby === void 0 ? "" : format(value.standby);
906
+ const swap = (standby = value.standby) => onChange({ active: standby, standby: value.active });
907
+ const onKeyDown = (e) => {
908
+ if (e.key === "Escape") {
909
+ setDraft(null);
910
+ setInvalid(false);
911
+ }
912
+ if (e.key !== "Enter") return;
913
+ e.preventDefault();
914
+ const text = (draft ?? shown).trim();
915
+ const standby = text ? parse(text) : void 0;
916
+ if (text && standby === void 0) return setInvalid(true);
917
+ setDraft(null);
918
+ setInvalid(false);
919
+ swap(standby);
920
+ };
921
+ const onBlur = () => {
922
+ setFocused(false);
923
+ setInvalid(false);
924
+ if (draft === null) return;
925
+ const text = draft.trim();
926
+ const standby = text ? parse(text) : void 0;
927
+ setDraft(null);
928
+ if (text && standby === void 0 || standby === value.standby) return;
929
+ onChange({ active: value.active, standby });
930
+ };
931
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
932
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { style: label, children: [
933
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: name }),
934
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { "data-testid": `radio-stack-${key}-ident`, style: ident, children: station ?? "" })
935
+ ] }),
936
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { "data-testid": `radio-stack-${key}-active`, "aria-label": `${name} active frequency`, style: { ...display, color }, children: format(value.active) }),
937
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
938
+ "button",
939
+ {
940
+ type: "button",
941
+ onClick: () => swap(),
942
+ "aria-label": `Swap ${name} active and standby`,
943
+ title: "Swap active and standby",
944
+ style: { display: "flex", alignItems: "center", justifyContent: "center", width: "100%", height: "2em", padding: 0, margin: 0, border: "0.08em solid #555", borderRadius: "0.3em", background: "#3a3a3a", color: "#ddd", font: "inherit", fontSize: "1.2em", cursor: "pointer" },
945
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(SwapIcon, {})
946
+ }
947
+ ),
948
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
949
+ "input",
950
+ {
951
+ type: "text",
952
+ inputMode: "decimal",
953
+ autoComplete: "off",
954
+ spellCheck: false,
955
+ "data-testid": `radio-stack-${key}-standby`,
956
+ "aria-label": `${name} standby frequency (${unit})`,
957
+ "aria-invalid": invalid || void 0,
958
+ placeholder: format(void 0),
959
+ value: draft ?? shown,
960
+ onChange: (e) => {
961
+ setDraft(e.target.value);
962
+ setInvalid(false);
963
+ },
964
+ onFocus: (e) => {
965
+ setFocused(true);
966
+ e.target.select();
967
+ },
968
+ onBlur,
969
+ onKeyDown,
970
+ style: { ...display, color, outline: "none", borderColor: invalid ? "#ff4d4d" : focused ? color : "#3a2a14", cursor: "text" }
971
+ }
972
+ )
973
+ ] });
974
+ }
975
+ var SCREWS2 = [
976
+ { top: "0.3em", left: "0.3em" },
977
+ { top: "0.3em", right: "0.3em" },
978
+ { bottom: "0.3em", left: "0.3em" },
979
+ { bottom: "0.3em", right: "0.3em" }
980
+ ];
981
+ function RadioStack({
982
+ nav,
983
+ adf,
984
+ defaultNav,
985
+ defaultAdf,
986
+ onNavChange,
987
+ onAdfChange,
988
+ navIdent,
989
+ adfIdent,
990
+ dme,
991
+ color = "#ff9a2e",
992
+ width = 320,
993
+ className,
994
+ style,
995
+ title = "Radio panel"
996
+ }) {
997
+ const [innerNav, setInnerNav] = (0, import_react2.useState)(defaultNav ?? {});
998
+ const [innerAdf, setInnerAdf] = (0, import_react2.useState)(defaultAdf ?? {});
999
+ const changeNav = (next) => {
1000
+ if (nav === void 0) setInnerNav(next);
1001
+ onNavChange?.(next);
1002
+ };
1003
+ const changeAdf = (next) => {
1004
+ if (adf === void 0) setInnerAdf(next);
1005
+ onAdfChange?.(next);
1006
+ };
1007
+ const heading = { color: MUTED, fontSize: "0.72em", fontWeight: "bold", letterSpacing: "0.12em", textAlign: "center" };
1008
+ return (
1009
+ // The outer box is a size container so every inner measurement can follow the width.
1010
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className, style: { display: "inline-block", width, maxWidth: "100%", verticalAlign: "top", containerType: "inline-size", ...style }, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1011
+ "div",
1012
+ {
1013
+ role: "group",
1014
+ "aria-label": title,
1015
+ style: {
1016
+ position: "relative",
1017
+ boxSizing: "border-box",
1018
+ display: "grid",
1019
+ gridTemplateColumns: "2.6em minmax(0, 1fr) 2.4em minmax(0, 1fr)",
1020
+ gap: "0.5em 0.4em",
1021
+ alignItems: "center",
1022
+ padding: "1.1em 1.2em 1.2em",
1023
+ borderRadius: "0.9em",
1024
+ border: "0.15em solid #0d0d0d",
1025
+ background: "#232323",
1026
+ color: LABEL,
1027
+ fontFamily: "'Helvetica Neue', Arial, sans-serif",
1028
+ fontSize: "5cqw",
1029
+ textAlign: "left",
1030
+ userSelect: "none"
1031
+ },
1032
+ children: [
1033
+ SCREWS2.map((position, i) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("svg", { viewBox: "-14 -14 28 28", "aria-hidden": "true", style: { position: "absolute", width: "0.75em", height: "0.75em", ...position }, children: [
1034
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("circle", { r: "12", fill: "#3a3a3a", stroke: "#111", strokeWidth: "2" }),
1035
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M -8 3 L 8 -3", stroke: "#111", strokeWidth: "3" })
1036
+ ] }, i)),
1037
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", {}),
1038
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { style: heading, children: "ACTIVE" }),
1039
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", {}),
1040
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { style: heading, children: "STBY" }),
1041
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Receiver, { name: "NAV", unit: "MHz", value: nav ?? innerNav, ident: navIdent, color, format: formatNav, parse: parseNav, onChange: changeNav }),
1042
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Receiver, { name: "ADF", unit: "kHz", value: adf ?? innerAdf, ident: adfIdent, color, format: formatAdf, parse: parseAdf, onChange: changeAdf }),
1043
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { style: label, children: "DME" }),
1044
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { "aria-label": "DME distance", style: { ...display, gridColumn: "span 3", display: "flex", alignItems: "baseline", justifyContent: "flex-end", gap: "0.4em", padding: "0 0.5em", color }, children: [
1045
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { "data-testid": "radio-stack-dme", children: formatDme(dme) }),
1046
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { style: { color: MUTED, fontFamily: "'Helvetica Neue', Arial, sans-serif", fontSize: "0.5em" }, children: "NM" })
1047
+ ] })
1048
+ ]
1049
+ }
1050
+ ) })
1051
+ );
1052
+ }
1053
+
1054
+ // src/components/DataPanel.tsx
1055
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1056
+ var MAX_FIELDS = 6;
1057
+ var SIDE2 = 252;
1058
+ var PAD = 8;
1059
+ var GAP = 8;
1060
+ var ORIGIN2 = CENTER - SIDE2 / 2;
1061
+ var VALUE_SIZE = { 1: 52, 2: 36, 3: 27 };
1062
+ function formatValue(field) {
1063
+ if (typeof field.value === "string") return field.value;
1064
+ const n = finite(field.value, NaN);
1065
+ return Number.isNaN(n) ? "---" : n.toFixed(Math.max(0, Math.floor(finite(field.decimals, 0))));
1066
+ }
1067
+ function DataPanel({ fields = [], heading, ...props }) {
1068
+ const shown = fields.slice(0, MAX_FIELDS);
1069
+ const cols = shown.length <= 2 ? 1 : 2;
1070
+ const rows = Math.max(1, Math.ceil(shown.length / cols));
1071
+ const cellW = (SIDE2 - PAD * 2 - GAP * (cols - 1)) / cols;
1072
+ const cellH = (SIDE2 - PAD * 2 - GAP * (rows - 1)) / rows;
1073
+ const valueSize = VALUE_SIZE[rows] ?? 27;
1074
+ const label2 = `${heading ?? "Data panel"}: ` + (shown.length ? shown.map((f) => `${f.name} ${formatValue(f)}${f.unit ? ` ${f.unit}` : ""}`).join(", ") : "no data");
1075
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(InstrumentFrame, { ...props, label: label2, children: [
1076
+ heading && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("text", { x: CENTER, y: ORIGIN2 - 14, fill: "#ccc", fontSize: "13", fontWeight: "bold", letterSpacing: "2", textAnchor: "middle", dominantBaseline: "central", children: heading.toUpperCase() }),
1077
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("rect", { x: ORIGIN2, y: ORIGIN2, width: SIDE2, height: SIDE2, rx: "10", fill: "#1c1f24", stroke: "#3a3f47", strokeWidth: "2" }),
1078
+ shown.map((f, i) => {
1079
+ const col = i % cols;
1080
+ const row = Math.floor(i / cols);
1081
+ const x = ORIGIN2 + PAD + col * (cellW + GAP);
1082
+ const y = ORIGIN2 + PAD + row * (cellH + GAP);
1083
+ const value = formatValue(f);
1084
+ const fit = Math.min(valueSize, (cellW - 16) / (0.62 * Math.max(1, value.length)));
1085
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("g", { "data-testid": `data-field-${i}`, children: [
1086
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("rect", { x, y, width: cellW, height: cellH, rx: "6", fill: "#000", stroke: "#262a30", strokeWidth: "1" }),
1087
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("text", { x: x + 8, y: y + 12, fill: "#9aa4b1", fontSize: "12", fontWeight: "bold", letterSpacing: "1", dominantBaseline: "central", children: f.name.toUpperCase() }),
1088
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1089
+ "text",
1090
+ {
1091
+ "data-testid": `data-value-${i}`,
1092
+ x: x + cellW / 2,
1093
+ y: y + cellH / 2 + 7,
1094
+ fill: f.color ?? "#fff",
1095
+ fontSize: fit,
1096
+ fontFamily: "monospace",
1097
+ fontWeight: "bold",
1098
+ textAnchor: "middle",
1099
+ dominantBaseline: "central",
1100
+ children: value
1101
+ }
1102
+ ),
1103
+ f.unit && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("text", { x: x + cellW - 8, y: y + cellH - 12, fill: "#9aa4b1", fontSize: "12", textAnchor: "end", dominantBaseline: "central", children: f.unit })
1104
+ ] }, i);
1105
+ })
1106
+ ] });
1107
+ }
1108
+
1109
+ // src/components/FuelIndicator.tsx
1110
+ var import_jsx_runtime14 = require("react/jsx-runtime");
1111
+ var MAX_TANKS = 4;
1112
+ var GREEN2 = "#2ee05a";
1113
+ var RED = "#ff3b3b";
1114
+ var GREY = "#9aa4b1";
1115
+ var SIDE3 = 252;
1116
+ var PAD2 = 6;
1117
+ var ORIGIN3 = CENTER - SIDE3 / 2;
1118
+ var INNER_LEFT = ORIGIN3 + PAD2;
1119
+ var INNER_W = SIDE3 - PAD2 * 2;
1120
+ var FOOTER_Y = ORIGIN3 + SIDE3 - 36;
1121
+ var BAR_TOP = ORIGIN3 + 38;
1122
+ var BAR_H = 114;
1123
+ var BAR_BOTTOM = BAR_TOP + BAR_H;
1124
+ var DEFAULT_TANKS = [
1125
+ { name: "LEFT", quantity: 0 },
1126
+ { name: "RIGHT", quantity: 0 }
1127
+ ];
1128
+ function FuelIndicator({
1129
+ tanks = DEFAULT_TANKS,
1130
+ capacity = 50,
1131
+ unit = "gal",
1132
+ low,
1133
+ decimals = 1,
1134
+ label: label2 = "FUEL",
1135
+ ...props
1136
+ }) {
1137
+ const duration = props.animationDuration ?? DEFAULT_ANIMATION_MS;
1138
+ const places = Math.max(0, Math.floor(finite(decimals, 1)));
1139
+ const shown = tanks.slice(0, MAX_TANKS);
1140
+ const cols = Math.max(1, shown.length);
1141
+ const colW = INNER_W / cols;
1142
+ const barW = clamp(colW / 8, 8, 16);
1143
+ const valueSize = Math.min(26, colW / 4.4);
1144
+ const readings = shown.map((t) => {
1145
+ const cap = Math.max(1e-9, finite(t.capacity, finite(capacity, 50)));
1146
+ const qty = clamp(finite(t.quantity), 0, cap);
1147
+ const fraction = qty / cap;
1148
+ const full = fraction >= 0.995;
1149
+ const isLow = qty <= finite(low, cap * 0.1);
1150
+ return { name: t.name, qty, cap, fraction, full, isLow, text: full ? "FULL" : qty.toFixed(places) };
1151
+ });
1152
+ const title = `${label2}: ` + (readings.length ? readings.map((r) => `${r.name} ${r.full ? "full" : `${r.text} of ${r.cap.toFixed(places)} ${unit}`}${r.isLow ? " (low)" : ""}`).join(", ") : "no tanks");
1153
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(InstrumentFrame, { ...props, label: title, children: [
1154
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: ORIGIN3, y: ORIGIN3, width: SIDE3, height: SIDE3, rx: "10", fill: "#000", stroke: "#3a3f47", strokeWidth: "2" }),
1155
+ readings.map((r, i) => {
1156
+ const cx = INNER_LEFT + colW * (i + 0.5);
1157
+ const color = r.isLow ? RED : GREEN2;
1158
+ const tickX = cx - barW / 2 - 14;
1159
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("g", { "data-testid": `fuel-tank-${i}`, children: [
1160
+ i > 0 && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: `M ${INNER_LEFT + colW * i} ${ORIGIN3 + 10} V ${FOOTER_Y}`, stroke: "#555", strokeWidth: "1.5" }),
1161
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("text", { x: cx, y: ORIGIN3 + 22, fill: "#fff", fontSize: Math.min(17, colW / 5), fontWeight: "bold", textAnchor: "middle", dominantBaseline: "central", children: r.name.toUpperCase() }),
1162
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("g", { strokeWidth: "2.5", strokeLinecap: "round", children: [0, 0.25, 0.5, 0.75, 1].map((f) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1163
+ "path",
1164
+ {
1165
+ d: `M ${tickX - 7} ${BAR_BOTTOM - f * BAR_H} h 7`,
1166
+ stroke: f === 1 ? GREEN2 : f === 0 ? RED : GREY
1167
+ },
1168
+ f
1169
+ )) }),
1170
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: cx - barW / 2, y: BAR_TOP, width: barW, height: BAR_H, fill: "#15181c" }),
1171
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("g", { "data-testid": `fuel-bar-${i}`, style: motionStyle(`scaleY(${r.fraction})`, duration, cx, BAR_BOTTOM), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: cx - barW / 2, y: BAR_TOP, width: barW, height: BAR_H, fill: color }) }),
1172
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1173
+ "text",
1174
+ {
1175
+ "data-testid": `fuel-value-${i}`,
1176
+ x: cx,
1177
+ y: BAR_BOTTOM + 22,
1178
+ fill: r.isLow ? RED : "#fff",
1179
+ fontSize: valueSize,
1180
+ fontFamily: "monospace",
1181
+ fontWeight: "bold",
1182
+ textAnchor: "middle",
1183
+ dominantBaseline: "central",
1184
+ children: r.text
1185
+ }
1186
+ ),
1187
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("text", { x: cx, y: BAR_BOTTOM + 44, fill: "#fff", fontSize: "13", fontWeight: "bold", textAnchor: "middle", dominantBaseline: "central", children: unit })
1188
+ ] }, i);
1189
+ }),
1190
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: `M ${ORIGIN3 + 8} ${FOOTER_Y} H ${ORIGIN3 + SIDE3 - 8}`, stroke: "#555", strokeWidth: "1.5" }),
1191
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("text", { x: CENTER, y: FOOTER_Y + 19, fill: "#fff", fontSize: "24", fontWeight: "bold", letterSpacing: "2", textAnchor: "middle", dominantBaseline: "central", children: label2.toUpperCase() })
1192
+ ] });
1193
+ }
1194
+
1195
+ // src/components/EngineIndicator.tsx
1196
+ var import_jsx_runtime15 = require("react/jsx-runtime");
1197
+ var MAX_CYLINDERS = 6;
1198
+ var MAX_BAR_GAUGES = 4;
1199
+ var GREEN3 = "#5fe04a";
1200
+ var YELLOW = "#ffd400";
1201
+ var RED2 = "#ff3030";
1202
+ var BLUE = "#4fb7e8";
1203
+ var LABEL2 = "#b9c8e6";
1204
+ var LINE = "#8a8f99";
1205
+ var round2 = (n) => Math.round(n * 100) / 100;
1206
+ var DIAL_R = 182;
1207
+ function chord(y, inset = 8) {
1208
+ const half = Math.sqrt(Math.max(0, DIAL_R * DIAL_R - (y - CENTER) ** 2)) - inset;
1209
+ return `M ${round2(CENTER - half)} ${y} H ${round2(CENTER + half)}`;
1210
+ }
1211
+ var DEFAULT_MANIFOLD = { min: 10, max: 35, green: [15, 29], yellow: [29, 31], high: 31, unit: "IN", decimals: 1 };
1212
+ var DEFAULT_RPM = { min: 0, max: 3e3, green: [800, 2500], yellow: [2500, 2700], high: 2700, decimals: 0 };
1213
+ var DEFAULT_BAR_GAUGES = [
1214
+ { label: "Oil P", min: 0, max: 100, green: [30, 60], low: 10, high: 95, unit: "PSI" },
1215
+ { label: "Oil T", min: 0, max: 250, green: [75, 240], high: 240, unit: "\xB0F" },
1216
+ { label: "Fuel P", min: 0, max: 30, low: 1, high: 28, unit: "PSI", decimals: 1 },
1217
+ { label: "Fuel F", min: 0, max: 30, green: [8, 20], unit: "GPH", decimals: 1 }
1218
+ ];
1219
+ function resolve(g, defaults = {}) {
1220
+ const min = finite(g.min, finite(defaults.min, 0));
1221
+ const max = Math.max(min + 1e-9, finite(g.max, finite(defaults.max, 100)));
1222
+ const value = clamp(finite(g.value), min, max);
1223
+ const fraction = (value - min) / (max - min);
1224
+ const decimals = Math.max(0, Math.floor(finite(g.decimals, finite(defaults.decimals, 0))));
1225
+ const low = g.low ?? defaults.low;
1226
+ const high = g.high ?? defaults.high;
1227
+ const yellow = g.yellow ?? defaults.yellow;
1228
+ const inRed = low !== void 0 && value <= low || high !== void 0 && value >= high;
1229
+ const inYellow = yellow !== void 0 && value >= yellow[0] && value <= yellow[1];
1230
+ return {
1231
+ value,
1232
+ min,
1233
+ max,
1234
+ fraction,
1235
+ color: inRed ? RED2 : inYellow ? YELLOW : "#fff",
1236
+ text: value.toFixed(decimals),
1237
+ unit: g.unit ?? defaults.unit,
1238
+ green: g.green ?? defaults.green,
1239
+ yellow,
1240
+ low,
1241
+ high
1242
+ };
1243
+ }
1244
+ var ARC_R = 46;
1245
+ var ARC_SWEEP = 100;
1246
+ var ARC_Y = 112;
1247
+ function arcAt(cx, cy, r, a0, a1) {
1248
+ const [x0, y0] = polar(r, a0, cx, cy);
1249
+ const [x1, y1] = polar(r, a1, cx, cy);
1250
+ return `M ${x0} ${y0} A ${r} ${r} 0 ${a1 - a0 > 180 ? 1 : 0} 1 ${x1} ${y1}`;
1251
+ }
1252
+ function ArcGauge({ cx, label: label2, g, duration, testId }) {
1253
+ const span = g.max - g.min;
1254
+ const angle = (v) => round2(-ARC_SWEEP + 2 * ARC_SWEEP * clamp((v - g.min) / span, 0, 1));
1255
+ const band = (from, to, color) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: arcAt(cx, ARC_Y, ARC_R, angle(from), angle(to)), stroke: color, strokeWidth: "6", fill: "none" });
1256
+ const [tipX, tipY] = polar(ARC_R - 4, 0, cx, ARC_Y);
1257
+ const [lx, ly] = polar(ARC_R - 16, -7, cx, ARC_Y);
1258
+ const [rx, ry] = polar(ARC_R - 16, 7, cx, ARC_Y);
1259
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("g", { children: [
1260
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: arcAt(cx, ARC_Y, ARC_R, -ARC_SWEEP, ARC_SWEEP), stroke: "#fff", strokeWidth: "1.5", fill: "none" }),
1261
+ g.green && band(g.green[0], g.green[1], GREEN3),
1262
+ g.yellow && band(g.yellow[0], g.yellow[1], YELLOW),
1263
+ g.low !== void 0 && band(g.min, g.low, RED2),
1264
+ g.high !== void 0 && band(g.high, g.max, RED2),
1265
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("g", { "data-testid": testId, style: motionStyle(`rotate(${angle(g.value)}deg)`, duration, cx, ARC_Y), children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: `M ${tipX} ${tipY} L ${lx} ${ly} L ${rx} ${ry} Z`, fill: "#fff", stroke: "#000", strokeWidth: "1" }) }),
1266
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("text", { x: cx, y: ARC_Y - 20, fill: LABEL2, fontSize: "14", fontWeight: "bold", textAnchor: "middle", dominantBaseline: "central", children: label2 }),
1267
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("text", { x: cx, y: ARC_Y + 4, fill: g.color, fontSize: "28", fontWeight: "bold", textAnchor: "middle", dominantBaseline: "central", children: [
1268
+ g.text,
1269
+ g.unit && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("tspan", { fontSize: "11", dx: "2", children: g.unit })
1270
+ ] })
1271
+ ] });
1272
+ }
1273
+ var BAR_X0 = 210;
1274
+ var BAR_X1 = 296;
1275
+ var BAR_ROW_H = 39;
1276
+ var BAR_TOP2 = 137;
1277
+ function BarGauge({ top, g, label: label2, duration, testId }) {
1278
+ const y = top + 14;
1279
+ const at = (v) => round2(BAR_X0 + (BAR_X1 - BAR_X0) * clamp((v - g.min) / (g.max - g.min), 0, 1));
1280
+ const seg = (from, to, color, w = 7) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: `M ${at(from)} ${y} H ${at(to)}`, stroke: color, strokeWidth: w });
1281
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("g", { children: [
1282
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: `M ${BAR_X0} ${y} H ${BAR_X1}`, stroke: "#fff", strokeWidth: "2" }),
1283
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: `M ${BAR_X0} ${y - 4} v 8 M ${BAR_X1} ${y - 4} v 8`, stroke: "#fff", strokeWidth: "2" }),
1284
+ g.green && seg(g.green[0], g.green[1], GREEN3),
1285
+ g.yellow && seg(g.yellow[0], g.yellow[1], YELLOW),
1286
+ g.low !== void 0 && seg(g.min, g.low, RED2),
1287
+ g.high !== void 0 && seg(g.high, g.max, RED2),
1288
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("g", { "data-testid": testId, style: motionStyle(`translate(${round2(at(g.value) - BAR_X0)}px, 0px)`, duration), children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: `M ${BAR_X0} ${y - 3} l -5 -9 h 10 z`, fill: "#fff", stroke: "#000", strokeWidth: "1" }) }),
1289
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("text", { x: BAR_X0, y: top + 31, fill: LABEL2, fontSize: "13", fontWeight: "bold", dominantBaseline: "central", children: label2 }),
1290
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("text", { x: 350, y: top + 15, fill: g.color, fontSize: "20", fontWeight: "bold", textAnchor: "end", dominantBaseline: "central", children: g.text }),
1291
+ g.unit && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("text", { x: 350, y: top + 31, fill: LABEL2, fontSize: "10", fontWeight: "bold", textAnchor: "end", dominantBaseline: "central", children: g.unit })
1292
+ ] });
1293
+ }
1294
+ function Tank({ x, fraction, duration, testId }) {
1295
+ const top = 304;
1296
+ const h = 40;
1297
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("g", { children: [
1298
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("rect", { x: x - 7, y: top, width: "14", height: h, rx: "3", fill: "#000", stroke: "#fff", strokeWidth: "1.5" }),
1299
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("g", { "data-testid": testId, style: motionStyle(`scaleY(${fraction})`, duration, x, top + h - 2), children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("rect", { x: x - 5.5, y: top + 2, width: "11", height: h - 4, fill: BLUE }) }),
1300
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("rect", { x: x - 5.5, y: top + h - 5, width: "11", height: "3", fill: RED2 })
1301
+ ] });
1302
+ }
1303
+ var hottest = (values) => {
1304
+ const finite_ = values.map((v) => finite(v, NaN)).filter((v) => !Number.isNaN(v));
1305
+ return finite_.length ? Math.max(...finite_) : void 0;
1306
+ };
1307
+ function EngineIndicator({
1308
+ power,
1309
+ manifold = {},
1310
+ rpm = {},
1311
+ cht = [],
1312
+ egt = [],
1313
+ tit,
1314
+ chtLimit = 400,
1315
+ chtScale = 500,
1316
+ egtScale = 1700,
1317
+ temperatureUnit = "\xB0F",
1318
+ gauges = DEFAULT_BAR_GAUGES,
1319
+ amps,
1320
+ volts,
1321
+ fuelLeft,
1322
+ fuelRight,
1323
+ fuelCapacity = 30,
1324
+ fuelUnit = "GAL",
1325
+ ...props
1326
+ }) {
1327
+ const duration = props.animationDuration ?? DEFAULT_ANIMATION_MS;
1328
+ const man = resolve(manifold, DEFAULT_MANIFOLD);
1329
+ const speed = resolve(rpm, DEFAULT_RPM);
1330
+ const bars = gauges.slice(0, MAX_BAR_GAUGES).map((g) => ({ label: g.label, g: resolve(g) }));
1331
+ const chtValues = cht.slice(0, MAX_CYLINDERS);
1332
+ const egtValues = egt.slice(0, MAX_CYLINDERS);
1333
+ const cylinders = Math.max(chtValues.length, egtValues.length);
1334
+ const hasTit = typeof tit === "number" && Number.isFinite(tit);
1335
+ const columns = cylinders + (hasTit ? 1 : 0);
1336
+ const chtMax = hottest(chtValues);
1337
+ const egtMax = hottest(egtValues);
1338
+ const chartX0 = 50;
1339
+ const chartX1 = 192;
1340
+ const chartBase = 284;
1341
+ const chartH = 88;
1342
+ const colW = columns > 0 ? (chartX1 - chartX0) / columns : 0;
1343
+ const barW = clamp(colW * 0.35, 4, 9);
1344
+ const chtFrac = (v) => clamp(finite(v) / Math.max(1e-9, finite(chtScale, 500)), 0, 1);
1345
+ const egtFrac = (v) => clamp(finite(v) / Math.max(1e-9, finite(egtScale, 1700)), 0, 1);
1346
+ const limitY = chartBase - chartH * chtFrac(chtLimit);
1347
+ const cap = Math.max(1e-9, finite(fuelCapacity, 30));
1348
+ const left = clamp(finite(fuelLeft), 0, cap);
1349
+ const right = clamp(finite(fuelRight), 0, cap);
1350
+ const fmt = (v, d = 0) => typeof v === "number" && Number.isFinite(v) ? v.toFixed(d) : "---";
1351
+ const readouts = [
1352
+ { name: "CHT", value: chtMax, color: GREEN3, x: 62 },
1353
+ { name: "EGT", value: egtMax, color: BLUE, x: 118 },
1354
+ { name: "TIT", value: hasTit ? tit : void 0, color: "#fff", x: 170 }
1355
+ ].filter((r) => r.value !== void 0);
1356
+ const label2 = "Engine: " + [
1357
+ power !== void 0 ? `power ${fmt(power)}%` : null,
1358
+ `MAN ${man.text}${man.unit ? ` ${man.unit}` : ""}`,
1359
+ `RPM ${speed.text}`,
1360
+ chtMax !== void 0 ? `CHT ${fmt(chtMax)}${temperatureUnit}` : null,
1361
+ egtMax !== void 0 ? `EGT ${fmt(egtMax)}${temperatureUnit}` : null,
1362
+ hasTit ? `TIT ${fmt(tit)}${temperatureUnit}` : null,
1363
+ ...bars.map((b) => `${b.label} ${b.g.text}${b.g.unit ? ` ${b.g.unit}` : ""}`),
1364
+ amps !== void 0 ? `${fmt(amps)} A` : null,
1365
+ fuelLeft !== void 0 || fuelRight !== void 0 ? `fuel ${fmt(fuelLeft)}/${fmt(fuelRight)} ${fuelUnit}` : null,
1366
+ volts !== void 0 ? `${fmt(volts, 1)} V` : null
1367
+ ].filter(Boolean).join(", ");
1368
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(InstrumentFrame, { ...props, label: label2, children: [
1369
+ power !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("text", { x: CENTER, y: 44, fill: "#fff", fontSize: "18", fontWeight: "bold", textAnchor: "middle", dominantBaseline: "central", children: [
1370
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("tspan", { fill: LABEL2, fontSize: "11", children: [
1371
+ "POWER",
1372
+ " "
1373
+ ] }),
1374
+ fmt(power),
1375
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("tspan", { fontSize: "11", children: "%" })
1376
+ ] }),
1377
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ArcGauge, { cx: 118, label: "MAN", g: man, duration, testId: "engine-man" }),
1378
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ArcGauge, { cx: 282, label: "RPM", g: speed, duration, testId: "engine-rpm" }),
1379
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("g", { stroke: LINE, strokeWidth: "1.5", children: [
1380
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: chord(133) }),
1381
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: "M 200 133 V 298" }),
1382
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: chord(298) }),
1383
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: "M 136 298 V 348 M 264 298 V 348" })
1384
+ ] }),
1385
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("g", { fontWeight: "bold", textAnchor: "middle", dominantBaseline: "central", children: readouts.map((r) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("g", { children: [
1386
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("text", { x: r.x, y: 144, fill: LABEL2, fontSize: "13", children: [
1387
+ r.name,
1388
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("tspan", { fontSize: "9", children: temperatureUnit })
1389
+ ] }),
1390
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("text", { "data-testid": `engine-${r.name.toLowerCase()}`, x: r.x, y: 165, fill: r.color, fontSize: "22", children: fmt(r.value) })
1391
+ ] }, r.name)) }),
1392
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: "M 40 178 H 190", stroke: LINE, strokeWidth: "1" }),
1393
+ columns > 0 && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("g", { children: [
1394
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: `M ${chartX0} ${limitY} H ${chartX1}`, stroke: RED2, strokeWidth: "1.5", strokeDasharray: "5 4" }),
1395
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("text", { x: chartX0 - 4, y: limitY, fill: "#fff", fontSize: "10", fontWeight: "bold", textAnchor: "end", dominantBaseline: "central", children: "CHT" }),
1396
+ Array.from({ length: cylinders }, (_, i) => {
1397
+ const x0 = chartX0 + colW * i;
1398
+ const mid = x0 + colW / 2;
1399
+ const c = chtValues[i];
1400
+ const e = egtValues[i];
1401
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("g", { children: [
1402
+ c !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("g", { "data-testid": `engine-cht-${i}`, style: motionStyle(`scaleY(${chtFrac(c)})`, duration, mid, chartBase), children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("rect", { x: mid - barW - 1, y: chartBase - chartH, width: barW, height: chartH, fill: GREEN3 }) }),
1403
+ e !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("g", { "data-testid": `engine-egt-${i}`, style: motionStyle(`scaleY(${egtFrac(e)})`, duration, mid, chartBase), children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("rect", { x: mid + 1, y: chartBase - chartH, width: barW, height: chartH, fill: BLUE }) }),
1404
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("text", { x: mid, y: 294, fill: "#fff", fontSize: "12", fontWeight: "bold", textAnchor: "middle", dominantBaseline: "central", children: i + 1 })
1405
+ ] }, i);
1406
+ }),
1407
+ hasTit && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("g", { children: [
1408
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("g", { "data-testid": "engine-tit-bar", style: motionStyle(`scaleY(${egtFrac(tit)})`, duration, chartX1 - colW / 2, chartBase), children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("rect", { x: chartX1 - colW / 2 - barW / 2, y: chartBase - chartH, width: barW, height: chartH, fill: "#fff" }) }),
1409
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("text", { x: chartX1 - colW / 2, y: 294, fill: "#fff", fontSize: "12", fontWeight: "bold", textAnchor: "middle", dominantBaseline: "central", children: "T" })
1410
+ ] })
1411
+ ] }),
1412
+ bars.map((b, i) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("g", { children: [
1413
+ i > 0 && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: `M 206 ${BAR_TOP2 + BAR_ROW_H * i - 2} H 352`, stroke: LINE, strokeWidth: "1" }),
1414
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(BarGauge, { top: BAR_TOP2 + BAR_ROW_H * i, g: b.g, label: b.label, duration, testId: `engine-bar-${i}` })
1415
+ ] }, b.label)),
1416
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("g", { fontWeight: "bold", textAnchor: "middle", dominantBaseline: "central", children: [
1417
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("text", { "data-testid": "engine-amps", x: 104, y: 318, fill: "#fff", fontSize: "20", children: [
1418
+ fmt(amps),
1419
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("tspan", { fontSize: "11", dx: "2", children: "A" })
1420
+ ] }),
1421
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("text", { x: 104, y: 338, fill: LABEL2, fontSize: "13", children: "ALT" }),
1422
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Tank, { x: 152, fraction: left / cap, duration, testId: "engine-fuel-left" }),
1423
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Tank, { x: 248, fraction: right / cap, duration, testId: "engine-fuel-right" }),
1424
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("text", { "data-testid": "engine-fuel", x: 200, y: 316, fill: "#fff", fontSize: "20", children: [
1425
+ fmt(left),
1426
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("tspan", { dx: "14", children: fmt(right) })
1427
+ ] }),
1428
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("text", { x: 200, y: 335, fill: LABEL2, fontSize: "13", children: "Fuel" }),
1429
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("text", { x: 200, y: 348, fill: LABEL2, fontSize: "9", children: fuelUnit }),
1430
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("text", { "data-testid": "engine-volts", x: 296, y: 318, fill: "#fff", fontSize: "20", children: [
1431
+ fmt(volts, 1),
1432
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("tspan", { fontSize: "11", dx: "2", children: "V" })
1433
+ ] }),
1434
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("text", { x: 296, y: 338, fill: LABEL2, fontSize: "13", children: "BATT" })
1435
+ ] })
1436
+ ] });
1437
+ }
1438
+
1439
+ // src/components/FlapIndicator.tsx
1440
+ var import_jsx_runtime16 = require("react/jsx-runtime");
1441
+ var GREEN4 = "#3ddc3d";
1442
+ var YELLOW2 = "#ffd400";
1443
+ var ORANGE = "#ff8a00";
1444
+ var RED3 = "#ff2a2a";
1445
+ var BAR_X = 226;
1446
+ var BAR_W = 30;
1447
+ var BAR_TOP3 = 78;
1448
+ var BAR_BOTTOM2 = 302;
1449
+ var BAR_H2 = BAR_BOTTOM2 - BAR_TOP3;
1450
+ function segmentColor(fraction) {
1451
+ if (fraction < 0.25) return GREEN4;
1452
+ if (fraction < 0.5) return YELLOW2;
1453
+ if (fraction < 0.75) return ORANGE;
1454
+ return RED3;
1455
+ }
1456
+ function FlapIndicator({
1457
+ flaps = 0,
1458
+ max = 40,
1459
+ detents,
1460
+ segments = 20,
1461
+ speedLimits,
1462
+ airspeed,
1463
+ label: label2 = "WING FLAP",
1464
+ ...props
1465
+ }) {
1466
+ const duration = props.animationDuration ?? DEFAULT_ANIMATION_MS;
1467
+ const full = Math.max(1e-9, finite(max, 40));
1468
+ const position = clamp(finite(flaps), 0, full);
1469
+ const fraction = position / full;
1470
+ const count = Math.max(1, Math.floor(finite(segments, 20)));
1471
+ const lit = Math.round(fraction * count);
1472
+ const scale = (detents ?? Array.from({ length: Math.floor(full / 10) + 1 }, (_, i) => i * 10)).filter((d) => d >= 0 && d <= full);
1473
+ const yAt = (deg) => Math.round((BAR_TOP3 + deg / full * BAR_H2) * 100) / 100;
1474
+ const limit = (speedLimits ?? []).filter((l) => Number.isFinite(l.flaps) && Number.isFinite(l.speed) && l.flaps <= position).sort((a, b) => b.flaps - a.flaps)[0];
1475
+ const ias = finite(airspeed, NaN);
1476
+ const overspeed = limit !== void 0 && !Number.isNaN(ias) && ias > limit.speed;
1477
+ const segH = BAR_H2 / count;
1478
+ const title = `${label2}: ${Math.round(position)}\xB0 of ${Math.round(full)}\xB0` + (limit ? `, max ${Math.round(limit.speed)} knots${overspeed ? " (overspeed)" : ""}` : "");
1479
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(InstrumentFrame, { ...props, label: title, children: [
1480
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("rect", { x: BAR_X - BAR_W / 2 - 4, y: BAR_TOP3 - 4, width: BAR_W + 8, height: BAR_H2 + 8, rx: "4", fill: "#000", stroke: "#333", strokeWidth: "1.5" }),
1481
+ Array.from({ length: count }, (_, i) => {
1482
+ const y = BAR_TOP3 + i * segH;
1483
+ const on = i < lit;
1484
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1485
+ "rect",
1486
+ {
1487
+ "data-testid": `flap-segment-${i}`,
1488
+ "data-lit": on ? "true" : "false",
1489
+ x: BAR_X - BAR_W / 2,
1490
+ y: y + 1,
1491
+ width: BAR_W,
1492
+ height: Math.max(1, segH - 2),
1493
+ rx: "1.5",
1494
+ fill: segmentColor((i + 0.5) / count),
1495
+ opacity: on ? 1 : 0.18,
1496
+ style: { transition: "opacity 150ms ease-out" }
1497
+ },
1498
+ i
1499
+ );
1500
+ }),
1501
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("g", { fill: "#fff", fontSize: "18", fontWeight: "bold", dominantBaseline: "central", children: scale.map((d) => /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("g", { children: [
1502
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("path", { d: `M ${BAR_X + BAR_W / 2 + 8} ${yAt(d)} h 8`, stroke: "#fff", strokeWidth: "2" }),
1503
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("text", { x: BAR_X + BAR_W / 2 + 22, y: yAt(d), children: d })
1504
+ ] }, d)) }),
1505
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("g", { "data-testid": "flap-pointer", style: motionStyle(`translate(0px, ${yAt(position) - BAR_TOP3}px)`, duration), children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("path", { d: `M ${BAR_X - BAR_W / 2 - 8} ${BAR_TOP3} l -14 -8 v 16 z`, fill: "#fff", stroke: "#000", strokeWidth: "1" }) }),
1506
+ limit && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("g", { textAnchor: "middle", dominantBaseline: "central", fill: overspeed ? RED3 : "#fff", children: [
1507
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("text", { "data-testid": "flap-speed", x: 118, y: 176, fontSize: "36", fontWeight: "bold", children: [
1508
+ Math.round(limit.speed),
1509
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("tspan", { fontSize: "13", dx: "3", children: "KTS" })
1510
+ ] }),
1511
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("text", { x: 118, y: 212, fontSize: "13", fontWeight: "bold", fill: "#bbb", letterSpacing: "2", children: "MAX" })
1512
+ ] }),
1513
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("text", { x: CENTER, y: 345, fill: "#ccc", fontSize: "16", textAnchor: "middle", children: label2.toUpperCase() })
1514
+ ] });
1515
+ }
1516
+
1517
+ // src/components/AoaIndicator.tsx
1518
+ var import_jsx_runtime17 = require("react/jsx-runtime");
1519
+ var GREEN5 = "#3ddc3d";
1520
+ var AMBER4 = "#ffb000";
1521
+ var RED4 = "#ff2a2a";
1522
+ var UNLIT_OPACITY = 0.15;
1523
+ var ROWS = [
1524
+ { shape: "bar", color: GREEN5, y: 300 },
1525
+ { shape: "bar", color: GREEN5, y: 278 },
1526
+ { shape: "bar", color: GREEN5, y: 256 },
1527
+ { shape: "bar", color: GREEN5, y: 234 },
1528
+ { shape: "donut", color: GREEN5, y: 208 },
1529
+ { shape: "bar", color: AMBER4, y: 182 },
1530
+ { shape: "split", color: AMBER4, y: 160 },
1531
+ { shape: "chevron", color: AMBER4, y: 125 },
1532
+ { shape: "chevron", color: AMBER4, y: 103 },
1533
+ { shape: "chevron", color: RED4, y: 74 },
1534
+ { shape: "chevron", color: RED4, y: 52 }
1535
+ ];
1536
+ var DONUT = ROWS.findIndex((r) => r.shape === "donut");
1537
+ var ABOVE = ROWS.length - 1 - DONUT;
1538
+ var HALF = 70;
1539
+ var BAR_H3 = 12;
1540
+ var CHEVRON_DEPTH = 26;
1541
+ function RowShape({ shape, y }) {
1542
+ const l = CENTER - HALF;
1543
+ const r = CENTER + HALF;
1544
+ switch (shape) {
1545
+ case "bar":
1546
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("rect", { x: l, y: y - BAR_H3 / 2, width: HALF * 2, height: BAR_H3, rx: "2" });
1547
+ case "split":
1548
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
1549
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("rect", { x: l, y: y - BAR_H3 / 2, width: 50, height: BAR_H3, rx: "2" }),
1550
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("rect", { x: r - 50, y: y - BAR_H3 / 2, width: 50, height: BAR_H3, rx: "2" })
1551
+ ] });
1552
+ case "donut":
1553
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
1554
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("rect", { x: l, y: y - BAR_H3 / 2, width: HALF - 24, height: BAR_H3, rx: "2" }),
1555
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("rect", { x: CENTER + 24, y: y - BAR_H3 / 2, width: HALF - 24, height: BAR_H3, rx: "2" }),
1556
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("circle", { cx: CENTER, cy: y, r: 13, fill: "none", strokeWidth: "7" })
1557
+ ] });
1558
+ case "chevron":
1559
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("path", { d: `M ${l} ${y} L ${CENTER} ${y + CHEVRON_DEPTH} L ${r} ${y}`, fill: "none", strokeWidth: "11", strokeLinejoin: "miter" });
1560
+ }
1561
+ }
1562
+ function AoaIndicator({ aoa = 0, min = 0, optimum, max = 20, showValue = false, label: label2 = "AOA", ...props }) {
1563
+ const lo = finite(min, 0);
1564
+ const hi = Math.max(lo + 1e-6, finite(max, 20));
1565
+ const opt = clamp(finite(optimum, (lo + hi) / 2), lo, hi);
1566
+ const value = finite(aoa, NaN);
1567
+ const thresholds = ROWS.map((_, i) => i <= DONUT ? lo + i / DONUT * (opt - lo) : opt + (i - DONUT) / ABOVE * (hi - opt));
1568
+ const lit = Number.isNaN(value) ? 0 : thresholds.filter((t) => value >= t - 1e-9).length;
1569
+ const stall = lit === ROWS.length;
1570
+ const reading = Number.isNaN(value) ? "---" : `${value.toFixed(1)}\xB0`;
1571
+ const state = stall ? " (stall warning)" : lit > DONUT + 1 ? " (high)" : lit === DONUT + 1 ? " (optimum)" : "";
1572
+ const title = `${label2}: ${reading}${Number.isNaN(value) ? "" : state}`;
1573
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(InstrumentFrame, { ...props, label: title, children: [
1574
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("rect", { x: CENTER - HALF - 10, y: 40, width: (HALF + 10) * 2, height: 278, rx: "10", fill: "#000", stroke: "#333", strokeWidth: "1.5" }),
1575
+ ROWS.map((row, i) => {
1576
+ const on = i < lit;
1577
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
1578
+ "g",
1579
+ {
1580
+ "data-testid": `aoa-row-${i}`,
1581
+ "data-lit": on ? "true" : "false",
1582
+ fill: row.color,
1583
+ stroke: row.color,
1584
+ strokeWidth: "0",
1585
+ opacity: on ? 1 : UNLIT_OPACITY,
1586
+ style: { transition: "opacity 150ms ease-out" },
1587
+ children: [
1588
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(RowShape, { shape: row.shape, y: row.y }),
1589
+ on && stall && row.shape === "chevron" && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("animate", { attributeName: "opacity", values: "1;0.25;1", dur: "0.6s", repeatCount: "indefinite" })
1590
+ ]
1591
+ },
1592
+ i
1593
+ );
1594
+ }),
1595
+ showValue && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("text", { "data-testid": "aoa-value", x: CENTER, y: 340, fill: "#fff", fontSize: "18", fontWeight: "bold", textAnchor: "middle", children: reading }),
1596
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("text", { x: CENTER, y: showValue ? 362 : 345, fill: "#ccc", fontSize: "16", textAnchor: "middle", children: label2.toUpperCase() })
1597
+ ] });
1598
+ }
594
1599
  // Annotate the CommonJS export names for ESM import in node:
595
1600
  0 && (module.exports = {
1601
+ AdfIndicator,
596
1602
  Airspeed,
597
1603
  Altimeter,
1604
+ AoaIndicator,
598
1605
  AttitudeIndicator,
1606
+ DEFAULT_BAR_GAUGES,
1607
+ DEFAULT_MANIFOLD,
1608
+ DEFAULT_RPM,
1609
+ DataPanel,
1610
+ EngineIndicator,
1611
+ FlapIndicator,
1612
+ FuelIndicator,
599
1613
  HeadingIndicator,
1614
+ MAX_BAR_GAUGES,
1615
+ MAX_CYLINDERS,
1616
+ MAX_FIELDS,
1617
+ MAX_TANKS,
1618
+ RadioPanel,
1619
+ RadioStack,
600
1620
  TurnCoordinator,
601
1621
  VerticalSpeed,
602
- WindIndicator
1622
+ VorIndicator,
1623
+ WindIndicator,
1624
+ formatAdf,
1625
+ formatDme,
1626
+ formatNav,
1627
+ formatValue,
1628
+ parseAdf,
1629
+ parseNav,
1630
+ relativeBearing,
1631
+ vorDeviation
603
1632
  });
604
1633
  //# sourceMappingURL=index.cjs.map