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