@almadar/ui 5.17.0 → 5.18.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/avl/index.cjs +219 -171
- package/dist/avl/index.js +219 -171
- package/dist/components/atoms/Avatar.d.ts +4 -2
- package/dist/components/atoms/ConditionalWrapper.d.ts +2 -2
- package/dist/components/atoms/Icon.d.ts +6 -2
- package/dist/components/atoms/Input.d.ts +3 -2
- package/dist/components/atoms/LawReferenceTooltip.d.ts +2 -2
- package/dist/components/atoms/types.d.ts +10 -10
- package/dist/components/index.cjs +188 -156
- package/dist/components/index.js +188 -156
- package/dist/components/molecules/OptionConstraintGroup.d.ts +5 -3
- package/dist/components/molecules/ViolationAlert.d.ts +2 -2
- package/dist/components/molecules/game/CraftingRecipe.d.ts +4 -4
- package/dist/components/molecules/game/DialogueBox.d.ts +2 -2
- package/dist/components/organisms/ComponentPatterns.d.ts +2 -1
- package/dist/components/organisms/CustomPattern.d.ts +2 -1
- package/dist/components/organisms/DataTable.d.ts +1 -1
- package/dist/components/organisms/Form.d.ts +3 -3
- package/dist/components/organisms/LayoutPatterns.d.ts +4 -3
- package/dist/components/organisms/StateMachineView.d.ts +6 -3
- package/dist/components/organisms/book/types.d.ts +2 -2
- package/dist/components/organisms/game/CastleBoard.d.ts +4 -3
- package/dist/components/organisms/game/TraitStateViewer.d.ts +4 -4
- package/dist/components/organisms/game/UncontrolledBattleBoard.d.ts +9 -4
- package/dist/components/organisms/game/WorldMapBoard.d.ts +5 -4
- package/dist/components/organisms/game/puzzles/builder/BuilderBoard.d.ts +3 -3
- package/dist/components/organisms/game/puzzles/classifier/ClassifierBoard.d.ts +3 -3
- package/dist/components/organisms/game/puzzles/debugger/DebuggerBoard.d.ts +3 -3
- package/dist/components/organisms/game/puzzles/event-handler/EventHandlerBoard.d.ts +7 -4
- package/dist/components/organisms/game/puzzles/event-handler/ObjectRulePanel.d.ts +2 -2
- package/dist/components/organisms/game/puzzles/negotiator/NegotiatorBoard.d.ts +3 -3
- package/dist/components/organisms/game/puzzles/sequencer/SequencerBoard.d.ts +5 -4
- package/dist/components/organisms/game/puzzles/simulator/SimulatorBoard.d.ts +3 -3
- package/dist/components/organisms/game/puzzles/state-architect/StateArchitectBoard.d.ts +5 -4
- package/dist/components/templates/GenericAppTemplate.d.ts +1 -7
- package/dist/components/templates/types.d.ts +14 -6
- package/dist/docs/index.cjs +60 -22
- package/dist/docs/index.d.cts +9 -4
- package/dist/docs/index.js +58 -20
- package/dist/marketing/index.cjs +61 -23
- package/dist/marketing/index.d.cts +10 -6
- package/dist/marketing/index.js +58 -20
- package/dist/providers/index.cjs +188 -156
- package/dist/providers/index.js +188 -156
- package/dist/runtime/fn-form-lambda.d.ts +1 -1
- package/dist/runtime/index.cjs +219 -171
- package/dist/runtime/index.js +219 -171
- package/package.json +1 -1
package/dist/providers/index.js
CHANGED
|
@@ -1486,11 +1486,13 @@ var init_Icon = __esm({
|
|
|
1486
1486
|
strokeWidth,
|
|
1487
1487
|
style
|
|
1488
1488
|
}) => {
|
|
1489
|
+
const directIcon = typeof icon === "string" ? void 0 : icon;
|
|
1490
|
+
const effectiveName = typeof icon === "string" ? icon : name;
|
|
1489
1491
|
const family = useIconFamily();
|
|
1490
1492
|
const RenderedComponent = React86__default.useMemo(() => {
|
|
1491
|
-
if (
|
|
1492
|
-
return
|
|
1493
|
-
}, [
|
|
1493
|
+
if (directIcon) return null;
|
|
1494
|
+
return effectiveName ? resolveIconForFamily(effectiveName, family) : null;
|
|
1495
|
+
}, [directIcon, effectiveName, family]);
|
|
1494
1496
|
const effectiveStrokeWidth = strokeWidth ?? void 0;
|
|
1495
1497
|
const inlineStyle = {
|
|
1496
1498
|
...effectiveStrokeWidth === void 0 ? { strokeWidth: "var(--icon-stroke-width, 2)" } : {},
|
|
@@ -1502,8 +1504,8 @@ var init_Icon = __esm({
|
|
|
1502
1504
|
color ? color : "text-current",
|
|
1503
1505
|
className
|
|
1504
1506
|
);
|
|
1505
|
-
if (
|
|
1506
|
-
const Direct =
|
|
1507
|
+
if (directIcon) {
|
|
1508
|
+
const Direct = directIcon;
|
|
1507
1509
|
return /* @__PURE__ */ jsx(
|
|
1508
1510
|
Direct,
|
|
1509
1511
|
{
|
|
@@ -3376,7 +3378,7 @@ var init_Input = __esm({
|
|
|
3376
3378
|
error,
|
|
3377
3379
|
leftIcon,
|
|
3378
3380
|
rightIcon,
|
|
3379
|
-
icon:
|
|
3381
|
+
icon: iconProp,
|
|
3380
3382
|
clearable,
|
|
3381
3383
|
onClear,
|
|
3382
3384
|
value,
|
|
@@ -3386,6 +3388,7 @@ var init_Input = __esm({
|
|
|
3386
3388
|
...props
|
|
3387
3389
|
}, ref) => {
|
|
3388
3390
|
const type = inputType || htmlType || "text";
|
|
3391
|
+
const IconComponent = typeof iconProp === "string" ? resolveIcon(iconProp) : iconProp;
|
|
3389
3392
|
const resolvedLeftIcon = leftIcon || IconComponent && /* @__PURE__ */ jsx(IconComponent, { className: "h-icon-default w-icon-default" });
|
|
3390
3393
|
const showClearButton = clearable && value && String(value).length > 0;
|
|
3391
3394
|
const isMultiline = type === "textarea";
|
|
@@ -3933,7 +3936,7 @@ var init_Avatar = __esm({
|
|
|
3933
3936
|
alt,
|
|
3934
3937
|
name,
|
|
3935
3938
|
initials: providedInitials,
|
|
3936
|
-
icon:
|
|
3939
|
+
icon: iconProp,
|
|
3937
3940
|
size = "md",
|
|
3938
3941
|
status,
|
|
3939
3942
|
badge,
|
|
@@ -3944,6 +3947,7 @@ var init_Avatar = __esm({
|
|
|
3944
3947
|
}) => {
|
|
3945
3948
|
const eventBus = useEventBus();
|
|
3946
3949
|
const initials = providedInitials ?? (name ? generateInitials(name) : void 0);
|
|
3950
|
+
const IconComponent = typeof iconProp === "string" ? resolveIcon(iconProp) : iconProp;
|
|
3947
3951
|
const hasImage = !!src;
|
|
3948
3952
|
const hasInitials = !!initials;
|
|
3949
3953
|
const hasIcon = !!IconComponent;
|
|
@@ -15158,6 +15162,7 @@ var init_StateMachineView = __esm({
|
|
|
15158
15162
|
setTooltip((prev) => ({ ...prev, pinned: false, visible: false }));
|
|
15159
15163
|
}, []);
|
|
15160
15164
|
useEventListener("UI:TOOLTIP_CLOSE", handleCloseTooltip);
|
|
15165
|
+
if (!layoutData) return null;
|
|
15161
15166
|
const { width, height, title, states, labels, entity, outputs, config } = layoutData;
|
|
15162
15167
|
const bundles = useMemo(() => {
|
|
15163
15168
|
const bundleMap = {};
|
|
@@ -17502,13 +17507,14 @@ function BuilderBoard({
|
|
|
17502
17507
|
}) {
|
|
17503
17508
|
const { emit } = useEventBus();
|
|
17504
17509
|
const { t } = useTranslate();
|
|
17510
|
+
const resolved = Array.isArray(entity) ? entity[0] : entity;
|
|
17505
17511
|
const [placements, setPlacements] = useState({});
|
|
17506
17512
|
const [headerError, setHeaderError] = useState(false);
|
|
17507
17513
|
const [submitted, setSubmitted] = useState(false);
|
|
17508
17514
|
const [attempts, setAttempts] = useState(0);
|
|
17509
17515
|
const [showHint, setShowHint] = useState(false);
|
|
17510
|
-
const components =
|
|
17511
|
-
const slots =
|
|
17516
|
+
const components = resolved?.components ?? [];
|
|
17517
|
+
const slots = resolved?.slots ?? [];
|
|
17512
17518
|
const usedComponentIds = new Set(Object.values(placements));
|
|
17513
17519
|
const availableComponents = components.filter((c) => !usedComponentIds.has(c.id));
|
|
17514
17520
|
const [selectedComponent, setSelectedComponent] = useState(null);
|
|
@@ -17542,7 +17548,7 @@ function BuilderBoard({
|
|
|
17542
17548
|
}, [slots, placements, attempts, completeEvent, emit]);
|
|
17543
17549
|
const handleReset = () => {
|
|
17544
17550
|
setSubmitted(false);
|
|
17545
|
-
if (attempts >= 2 &&
|
|
17551
|
+
if (attempts >= 2 && resolved?.hint) {
|
|
17546
17552
|
setShowHint(true);
|
|
17547
17553
|
}
|
|
17548
17554
|
};
|
|
@@ -17554,20 +17560,21 @@ function BuilderBoard({
|
|
|
17554
17560
|
setShowHint(false);
|
|
17555
17561
|
};
|
|
17556
17562
|
const getComponentById = (id) => components.find((c) => c.id === id);
|
|
17563
|
+
if (!resolved) return null;
|
|
17557
17564
|
return /* @__PURE__ */ jsx(
|
|
17558
17565
|
Box,
|
|
17559
17566
|
{
|
|
17560
17567
|
className,
|
|
17561
17568
|
style: {
|
|
17562
|
-
backgroundImage:
|
|
17569
|
+
backgroundImage: resolved.theme?.background ? `url(${resolved.theme.background})` : void 0,
|
|
17563
17570
|
backgroundSize: "cover",
|
|
17564
17571
|
backgroundPosition: "center"
|
|
17565
17572
|
},
|
|
17566
17573
|
children: /* @__PURE__ */ jsxs(VStack, { gap: "lg", className: "p-4", children: [
|
|
17567
|
-
|
|
17574
|
+
resolved.headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: resolved.headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : resolved.headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
|
|
17568
17575
|
/* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
|
|
17569
|
-
/* @__PURE__ */ jsx(Typography, { variant: "h4", weight: "bold", children:
|
|
17570
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body", children:
|
|
17576
|
+
/* @__PURE__ */ jsx(Typography, { variant: "h4", weight: "bold", children: resolved.title }),
|
|
17577
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body", children: resolved.description })
|
|
17571
17578
|
] }) }),
|
|
17572
17579
|
/* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
|
|
17573
17580
|
/* @__PURE__ */ jsx(Typography, { variant: "small", weight: "bold", className: "uppercase tracking-wider text-muted-foreground", children: t("builder.components") }),
|
|
@@ -17627,9 +17634,9 @@ function BuilderBoard({
|
|
|
17627
17634
|
] }) }),
|
|
17628
17635
|
submitted && /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", align: "center", children: [
|
|
17629
17636
|
/* @__PURE__ */ jsx(Icon, { icon: allCorrect ? CheckCircle : XCircle, size: "lg", className: allCorrect ? "text-success" : "text-error" }),
|
|
17630
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body", weight: "bold", children: allCorrect ?
|
|
17637
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body", weight: "bold", children: allCorrect ? resolved.successMessage ?? t("builder.success") : resolved.failMessage ?? t("builder.incorrect") })
|
|
17631
17638
|
] }) }),
|
|
17632
|
-
showHint &&
|
|
17639
|
+
showHint && resolved.hint && /* @__PURE__ */ jsx(Card, { className: "p-4 border-l-4 border-l-warning", children: /* @__PURE__ */ jsx(Typography, { variant: "body", children: resolved.hint }) }),
|
|
17633
17640
|
/* @__PURE__ */ jsxs(HStack, { gap: "sm", justify: "center", children: [
|
|
17634
17641
|
!submitted ? /* @__PURE__ */ jsxs(Button, { variant: "primary", onClick: handleSubmit, disabled: !allPlaced, children: [
|
|
17635
17642
|
/* @__PURE__ */ jsx(Icon, { icon: Wrench, size: "sm" }),
|
|
@@ -20170,11 +20177,12 @@ function CastleBoard({
|
|
|
20170
20177
|
className
|
|
20171
20178
|
}) {
|
|
20172
20179
|
const eventBus = useEventBus();
|
|
20173
|
-
const
|
|
20174
|
-
const
|
|
20175
|
-
const
|
|
20176
|
-
const
|
|
20177
|
-
const
|
|
20180
|
+
const resolved = Array.isArray(entity) ? entity[0] : entity;
|
|
20181
|
+
const tiles = resolved?.tiles ?? [];
|
|
20182
|
+
const features = resolved?.features ?? [];
|
|
20183
|
+
const units = resolved?.units ?? [];
|
|
20184
|
+
const assetManifest = resolved?.assetManifest;
|
|
20185
|
+
const backgroundImage = resolved?.backgroundImage;
|
|
20178
20186
|
const [hoveredTile, setHoveredTile] = useState(null);
|
|
20179
20187
|
const [selectedFeature, setSelectedFeature] = useState(null);
|
|
20180
20188
|
const hoveredFeature = useMemo(() => {
|
|
@@ -21079,13 +21087,14 @@ function ClassifierBoard({
|
|
|
21079
21087
|
}) {
|
|
21080
21088
|
const { emit } = useEventBus();
|
|
21081
21089
|
const { t } = useTranslate();
|
|
21090
|
+
const resolved = Array.isArray(entity) ? entity[0] : entity;
|
|
21082
21091
|
const [assignments, setAssignments] = useState({});
|
|
21083
21092
|
const [headerError, setHeaderError] = useState(false);
|
|
21084
21093
|
const [submitted, setSubmitted] = useState(false);
|
|
21085
21094
|
const [attempts, setAttempts] = useState(0);
|
|
21086
21095
|
const [showHint, setShowHint] = useState(false);
|
|
21087
|
-
const items =
|
|
21088
|
-
const categories =
|
|
21096
|
+
const items = resolved?.items ?? [];
|
|
21097
|
+
const categories = resolved?.categories ?? [];
|
|
21089
21098
|
const unassignedItems = items.filter((item) => !assignments[item.id]);
|
|
21090
21099
|
const allAssigned = Object.keys(assignments).length === items.length;
|
|
21091
21100
|
const results = submitted ? items.map((item) => ({
|
|
@@ -21117,7 +21126,7 @@ function ClassifierBoard({
|
|
|
21117
21126
|
}, [items, assignments, attempts, completeEvent, emit]);
|
|
21118
21127
|
const handleReset = () => {
|
|
21119
21128
|
setSubmitted(false);
|
|
21120
|
-
if (attempts >= 2 &&
|
|
21129
|
+
if (attempts >= 2 && resolved?.hint) {
|
|
21121
21130
|
setShowHint(true);
|
|
21122
21131
|
}
|
|
21123
21132
|
};
|
|
@@ -21127,20 +21136,21 @@ function ClassifierBoard({
|
|
|
21127
21136
|
setAttempts(0);
|
|
21128
21137
|
setShowHint(false);
|
|
21129
21138
|
};
|
|
21139
|
+
if (!resolved) return null;
|
|
21130
21140
|
return /* @__PURE__ */ jsx(
|
|
21131
21141
|
Box,
|
|
21132
21142
|
{
|
|
21133
21143
|
className,
|
|
21134
21144
|
style: {
|
|
21135
|
-
backgroundImage:
|
|
21145
|
+
backgroundImage: resolved.theme?.background ? `url(${resolved.theme.background})` : void 0,
|
|
21136
21146
|
backgroundSize: "cover",
|
|
21137
21147
|
backgroundPosition: "center"
|
|
21138
21148
|
},
|
|
21139
21149
|
children: /* @__PURE__ */ jsxs(VStack, { gap: "lg", className: "p-4", children: [
|
|
21140
|
-
|
|
21150
|
+
resolved.headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: resolved.headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : resolved.headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
|
|
21141
21151
|
/* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
|
|
21142
|
-
/* @__PURE__ */ jsx(Typography, { variant: "h4", weight: "bold", children:
|
|
21143
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body", children:
|
|
21152
|
+
/* @__PURE__ */ jsx(Typography, { variant: "h4", weight: "bold", children: resolved.title }),
|
|
21153
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body", children: resolved.description })
|
|
21144
21154
|
] }) }),
|
|
21145
21155
|
unassignedItems.length > 0 && /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
|
|
21146
21156
|
/* @__PURE__ */ jsx(Typography, { variant: "small", weight: "bold", className: "uppercase tracking-wider text-muted-foreground", children: t("classifier.itemsToSort") }),
|
|
@@ -21192,10 +21202,10 @@ function ClassifierBoard({
|
|
|
21192
21202
|
}) }),
|
|
21193
21203
|
submitted && /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", align: "center", children: [
|
|
21194
21204
|
/* @__PURE__ */ jsx(Icon, { icon: allCorrect ? CheckCircle : XCircle, size: "lg", className: allCorrect ? "text-success" : "text-error" }),
|
|
21195
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body", weight: "bold", children: allCorrect ?
|
|
21196
|
-
!allCorrect &&
|
|
21205
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body", weight: "bold", children: allCorrect ? resolved.successMessage ?? t("classifier.allCorrect") : `${correctCount}/${items.length} ${t("classifier.correct")}` }),
|
|
21206
|
+
!allCorrect && resolved.failMessage && /* @__PURE__ */ jsx(Typography, { variant: "body", className: "text-muted-foreground", children: resolved.failMessage })
|
|
21197
21207
|
] }) }),
|
|
21198
|
-
showHint &&
|
|
21208
|
+
showHint && resolved.hint && /* @__PURE__ */ jsx(Card, { className: "p-4 border-l-4 border-l-warning", children: /* @__PURE__ */ jsx(Typography, { variant: "body", children: resolved.hint }) }),
|
|
21199
21209
|
/* @__PURE__ */ jsxs(HStack, { gap: "sm", justify: "center", children: [
|
|
21200
21210
|
!submitted ? /* @__PURE__ */ jsxs(Button, { variant: "primary", onClick: handleSubmit, disabled: !allAssigned, children: [
|
|
21201
21211
|
/* @__PURE__ */ jsx(Icon, { icon: Send, size: "sm" }),
|
|
@@ -32530,7 +32540,7 @@ var init_OptionConstraintGroup = __esm({
|
|
|
32530
32540
|
title,
|
|
32531
32541
|
description,
|
|
32532
32542
|
options,
|
|
32533
|
-
constraint,
|
|
32543
|
+
constraint = { type: "single" },
|
|
32534
32544
|
selected = [],
|
|
32535
32545
|
onChange,
|
|
32536
32546
|
changeEvent,
|
|
@@ -35668,7 +35678,7 @@ function DataTable({
|
|
|
35668
35678
|
children: /* @__PURE__ */ jsx(
|
|
35669
35679
|
EmptyState,
|
|
35670
35680
|
{
|
|
35671
|
-
icon: emptyIcon,
|
|
35681
|
+
icon: typeof emptyIcon === "string" ? resolveIcon(emptyIcon) : emptyIcon,
|
|
35672
35682
|
title: resolvedEmptyTitle,
|
|
35673
35683
|
description: resolvedEmptyDescription,
|
|
35674
35684
|
actionLabel: emptyAction?.label,
|
|
@@ -35797,6 +35807,7 @@ var init_DataTable = __esm({
|
|
|
35797
35807
|
init_Stack();
|
|
35798
35808
|
init_Typography();
|
|
35799
35809
|
init_molecules();
|
|
35810
|
+
init_Icon();
|
|
35800
35811
|
init_useEventBus();
|
|
35801
35812
|
init_useTranslate();
|
|
35802
35813
|
init_types3();
|
|
@@ -35817,6 +35828,7 @@ function DebuggerBoard({
|
|
|
35817
35828
|
}) {
|
|
35818
35829
|
const { emit } = useEventBus();
|
|
35819
35830
|
const { t } = useTranslate();
|
|
35831
|
+
const resolved = Array.isArray(entity) ? entity[0] : entity;
|
|
35820
35832
|
const [flaggedLines, setFlaggedLines] = useState(/* @__PURE__ */ new Set());
|
|
35821
35833
|
const [headerError, setHeaderError] = useState(false);
|
|
35822
35834
|
const [submitted, setSubmitted] = useState(false);
|
|
@@ -35834,7 +35846,7 @@ function DebuggerBoard({
|
|
|
35834
35846
|
return next;
|
|
35835
35847
|
});
|
|
35836
35848
|
};
|
|
35837
|
-
const lines =
|
|
35849
|
+
const lines = resolved?.lines ?? [];
|
|
35838
35850
|
const bugLines = lines.filter((l) => l.isBug);
|
|
35839
35851
|
const correctFlags = lines.filter((l) => l.isBug && flaggedLines.has(l.id));
|
|
35840
35852
|
const falseFlags = lines.filter((l) => !l.isBug && flaggedLines.has(l.id));
|
|
@@ -35849,7 +35861,7 @@ function DebuggerBoard({
|
|
|
35849
35861
|
}, [correctFlags.length, bugLines.length, falseFlags.length, attempts, completeEvent, emit]);
|
|
35850
35862
|
const handleReset = () => {
|
|
35851
35863
|
setSubmitted(false);
|
|
35852
|
-
if (attempts >= 2 &&
|
|
35864
|
+
if (attempts >= 2 && resolved?.hint) {
|
|
35853
35865
|
setShowHint(true);
|
|
35854
35866
|
}
|
|
35855
35867
|
};
|
|
@@ -35859,24 +35871,25 @@ function DebuggerBoard({
|
|
|
35859
35871
|
setAttempts(0);
|
|
35860
35872
|
setShowHint(false);
|
|
35861
35873
|
};
|
|
35874
|
+
if (!resolved) return null;
|
|
35862
35875
|
return /* @__PURE__ */ jsx(
|
|
35863
35876
|
Box,
|
|
35864
35877
|
{
|
|
35865
35878
|
className,
|
|
35866
35879
|
style: {
|
|
35867
|
-
backgroundImage:
|
|
35880
|
+
backgroundImage: resolved.theme?.background ? `url(${resolved.theme.background})` : void 0,
|
|
35868
35881
|
backgroundSize: "cover",
|
|
35869
35882
|
backgroundPosition: "center"
|
|
35870
35883
|
},
|
|
35871
35884
|
children: /* @__PURE__ */ jsxs(VStack, { gap: "lg", className: "p-4", children: [
|
|
35872
|
-
|
|
35885
|
+
resolved.headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: resolved.headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : resolved.headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
|
|
35873
35886
|
/* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
|
|
35874
35887
|
/* @__PURE__ */ jsxs(HStack, { gap: "xs", align: "center", children: [
|
|
35875
35888
|
/* @__PURE__ */ jsx(Icon, { icon: Bug, size: "sm" }),
|
|
35876
|
-
/* @__PURE__ */ jsx(Typography, { variant: "h4", weight: "bold", children:
|
|
35889
|
+
/* @__PURE__ */ jsx(Typography, { variant: "h4", weight: "bold", children: resolved.title })
|
|
35877
35890
|
] }),
|
|
35878
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body", children:
|
|
35879
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground", children: t("debugger.findBugs", { count: String(
|
|
35891
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body", children: resolved.description }),
|
|
35892
|
+
/* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground", children: t("debugger.findBugs", { count: String(resolved.bugCount) }) })
|
|
35880
35893
|
] }) }),
|
|
35881
35894
|
/* @__PURE__ */ jsx(Card, { className: "p-0 overflow-hidden", children: /* @__PURE__ */ jsx(VStack, { gap: "none", children: lines.map((line, i) => {
|
|
35882
35895
|
const isFlagged = flaggedLines.has(line.id);
|
|
@@ -35908,7 +35921,7 @@ function DebuggerBoard({
|
|
|
35908
35921
|
);
|
|
35909
35922
|
}) }) }),
|
|
35910
35923
|
submitted && /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
|
|
35911
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body", weight: "bold", children: allCorrect ?
|
|
35924
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body", weight: "bold", children: allCorrect ? resolved.successMessage ?? t("debugger.allFound") : `${correctFlags.length}/${bugLines.length} ${t("debugger.bugsFound")}` }),
|
|
35912
35925
|
bugLines.map((line) => /* @__PURE__ */ jsxs(HStack, { gap: "xs", align: "start", children: [
|
|
35913
35926
|
/* @__PURE__ */ jsx(
|
|
35914
35927
|
Icon,
|
|
@@ -35924,7 +35937,7 @@ function DebuggerBoard({
|
|
|
35924
35937
|
] })
|
|
35925
35938
|
] }, line.id))
|
|
35926
35939
|
] }) }),
|
|
35927
|
-
showHint &&
|
|
35940
|
+
showHint && resolved.hint && /* @__PURE__ */ jsx(Card, { className: "p-4 border-l-4 border-l-warning", children: /* @__PURE__ */ jsx(Typography, { variant: "body", children: resolved.hint }) }),
|
|
35928
35941
|
/* @__PURE__ */ jsxs(HStack, { gap: "sm", justify: "center", children: [
|
|
35929
35942
|
!submitted ? /* @__PURE__ */ jsxs(Button, { variant: "primary", onClick: handleSubmit, disabled: flaggedLines.size === 0, children: [
|
|
35930
35943
|
/* @__PURE__ */ jsx(Icon, { icon: Send, size: "sm" }),
|
|
@@ -37056,7 +37069,8 @@ function EventHandlerBoard({
|
|
|
37056
37069
|
}) {
|
|
37057
37070
|
const { emit } = useEventBus();
|
|
37058
37071
|
const { t } = useTranslate();
|
|
37059
|
-
const
|
|
37072
|
+
const resolved = Array.isArray(entity) ? entity[0] : entity;
|
|
37073
|
+
const entityObjects = resolved?.objects ?? [];
|
|
37060
37074
|
const [objects, setObjects] = useState(entityObjects);
|
|
37061
37075
|
const [selectedObjectId, setSelectedObjectId] = useState(
|
|
37062
37076
|
entityObjects[0]?.id || null
|
|
@@ -37091,7 +37105,7 @@ function EventHandlerBoard({
|
|
|
37091
37105
|
allRules.push({ object: obj, rule });
|
|
37092
37106
|
});
|
|
37093
37107
|
});
|
|
37094
|
-
const triggers =
|
|
37108
|
+
const triggers = resolved?.triggerEvents || [];
|
|
37095
37109
|
const eventQueue = [...triggers];
|
|
37096
37110
|
const firedEvents = /* @__PURE__ */ new Set();
|
|
37097
37111
|
let stepIdx = 0;
|
|
@@ -37122,12 +37136,12 @@ function EventHandlerBoard({
|
|
|
37122
37136
|
matching.forEach(({ object, rule }) => {
|
|
37123
37137
|
addLogEntry(object.icon, t("eventHandler.heardEvent", { object: object.name, event: currentEvent, action: rule.thenAction }), "done");
|
|
37124
37138
|
eventQueue.push(rule.thenAction);
|
|
37125
|
-
if (rule.thenAction ===
|
|
37139
|
+
if (rule.thenAction === resolved?.goalEvent) {
|
|
37126
37140
|
goalReached = true;
|
|
37127
37141
|
}
|
|
37128
37142
|
});
|
|
37129
37143
|
}
|
|
37130
|
-
if (currentEvent ===
|
|
37144
|
+
if (currentEvent === resolved?.goalEvent) {
|
|
37131
37145
|
goalReached = true;
|
|
37132
37146
|
}
|
|
37133
37147
|
stepIdx++;
|
|
@@ -37137,7 +37151,7 @@ function EventHandlerBoard({
|
|
|
37137
37151
|
addLogEntry("\u{1F3AC}", t("eventHandler.simulationStarted", { events: triggers.join(", ") }), "active");
|
|
37138
37152
|
}
|
|
37139
37153
|
timerRef.current = setTimeout(processNext, stepDurationMs);
|
|
37140
|
-
}, [playState, objects,
|
|
37154
|
+
}, [playState, objects, resolved, stepDurationMs, playEvent, completeEvent, emit, addLogEntry, t]);
|
|
37141
37155
|
const handleTryAgain = useCallback(() => {
|
|
37142
37156
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
37143
37157
|
setPlayState("editing");
|
|
@@ -37145,12 +37159,13 @@ function EventHandlerBoard({
|
|
|
37145
37159
|
}, []);
|
|
37146
37160
|
const handleReset = useCallback(() => {
|
|
37147
37161
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
37148
|
-
setObjects(
|
|
37162
|
+
setObjects(resolved?.objects ?? []);
|
|
37149
37163
|
setPlayState("editing");
|
|
37150
37164
|
setEventLog([]);
|
|
37151
|
-
setSelectedObjectId((
|
|
37165
|
+
setSelectedObjectId((resolved?.objects ?? [])[0]?.id || null);
|
|
37152
37166
|
setAttempts(0);
|
|
37153
|
-
}, [
|
|
37167
|
+
}, [resolved?.objects]);
|
|
37168
|
+
if (!resolved) return null;
|
|
37154
37169
|
const objectViewers = objects.map((obj) => {
|
|
37155
37170
|
const machine = {
|
|
37156
37171
|
name: obj.name,
|
|
@@ -37164,25 +37179,25 @@ function EventHandlerBoard({
|
|
|
37164
37179
|
};
|
|
37165
37180
|
return { obj, machine };
|
|
37166
37181
|
});
|
|
37167
|
-
const showHint = attempts >= 3 &&
|
|
37182
|
+
const showHint = attempts >= 3 && resolved.hint;
|
|
37168
37183
|
const encourageKey = ENCOURAGEMENT_KEYS[Math.min(attempts - 1, ENCOURAGEMENT_KEYS.length - 1)] ?? ENCOURAGEMENT_KEYS[0];
|
|
37169
37184
|
return /* @__PURE__ */ jsxs(
|
|
37170
37185
|
VStack,
|
|
37171
37186
|
{
|
|
37172
37187
|
className: cn("p-4 gap-6", className),
|
|
37173
37188
|
style: {
|
|
37174
|
-
backgroundImage:
|
|
37189
|
+
backgroundImage: resolved.theme?.background ? `url(${resolved.theme.background})` : void 0,
|
|
37175
37190
|
backgroundSize: "cover",
|
|
37176
37191
|
backgroundPosition: "center"
|
|
37177
37192
|
},
|
|
37178
37193
|
children: [
|
|
37179
|
-
|
|
37194
|
+
resolved.headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: resolved.headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : resolved.headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
|
|
37180
37195
|
/* @__PURE__ */ jsxs(VStack, { gap: "xs", children: [
|
|
37181
|
-
/* @__PURE__ */ jsx(Typography, { variant: "h4", className: "text-foreground", children:
|
|
37182
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground", children:
|
|
37196
|
+
/* @__PURE__ */ jsx(Typography, { variant: "h4", className: "text-foreground", children: resolved.title }),
|
|
37197
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground", children: resolved.description }),
|
|
37183
37198
|
/* @__PURE__ */ jsxs(HStack, { className: "items-center p-2 rounded bg-primary/10 border border-primary/30", gap: "xs", children: [
|
|
37184
37199
|
/* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-primary font-bold", children: t("game.goal") + ":" }),
|
|
37185
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-foreground", children:
|
|
37200
|
+
/* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-foreground", children: resolved.goalCondition })
|
|
37186
37201
|
] })
|
|
37187
37202
|
] }),
|
|
37188
37203
|
/* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
|
|
@@ -37213,12 +37228,12 @@ function EventHandlerBoard({
|
|
|
37213
37228
|
}
|
|
37214
37229
|
),
|
|
37215
37230
|
eventLog.length > 0 && /* @__PURE__ */ jsx(EventLog, { entries: eventLog }),
|
|
37216
|
-
playState === "success" && /* @__PURE__ */ jsx(Box, { className: "p-4 rounded-container bg-success/20 border border-success text-center", children: /* @__PURE__ */ jsx(Typography, { variant: "h5", className: "text-success", children:
|
|
37231
|
+
playState === "success" && /* @__PURE__ */ jsx(Box, { className: "p-4 rounded-container bg-success/20 border border-success text-center", children: /* @__PURE__ */ jsx(Typography, { variant: "h5", className: "text-success", children: resolved.successMessage || t("eventHandler.chainComplete") }) }),
|
|
37217
37232
|
playState === "fail" && /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
|
|
37218
37233
|
/* @__PURE__ */ jsx(Box, { className: "p-4 rounded-container bg-warning/10 border border-warning/30 text-center", children: /* @__PURE__ */ jsx(Typography, { variant: "body1", className: "text-foreground font-medium", children: t(encourageKey) }) }),
|
|
37219
37234
|
showHint && /* @__PURE__ */ jsx(Box, { className: "p-3 rounded-container bg-accent/10 border border-accent/30", children: /* @__PURE__ */ jsxs(HStack, { className: "items-start", gap: "xs", children: [
|
|
37220
37235
|
/* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-accent font-bold shrink-0", children: "\u{1F4A1} " + t("game.hint") + ":" }),
|
|
37221
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-foreground", children:
|
|
37236
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-foreground", children: resolved.hint })
|
|
37222
37237
|
] }) })
|
|
37223
37238
|
] }),
|
|
37224
37239
|
/* @__PURE__ */ jsxs(HStack, { gap: "sm", children: [
|
|
@@ -40339,19 +40354,20 @@ function NegotiatorBoard({
|
|
|
40339
40354
|
}) {
|
|
40340
40355
|
const { emit } = useEventBus();
|
|
40341
40356
|
const { t } = useTranslate();
|
|
40357
|
+
const resolved = Array.isArray(entity) ? entity[0] : entity;
|
|
40342
40358
|
const [history, setHistory] = useState([]);
|
|
40343
40359
|
const [headerError, setHeaderError] = useState(false);
|
|
40344
40360
|
const [showHint, setShowHint] = useState(false);
|
|
40345
40361
|
const currentRound = history.length;
|
|
40346
|
-
const isComplete = currentRound >=
|
|
40362
|
+
const isComplete = currentRound >= (resolved?.totalRounds ?? 0);
|
|
40347
40363
|
const playerTotal = history.reduce((s, r) => s + r.playerPayoff, 0);
|
|
40348
40364
|
const opponentTotal = history.reduce((s, r) => s + r.opponentPayoff, 0);
|
|
40349
|
-
const won = isComplete && playerTotal >=
|
|
40350
|
-
const actions =
|
|
40351
|
-
const payoffMatrix =
|
|
40365
|
+
const won = isComplete && playerTotal >= (resolved?.targetScore ?? 0);
|
|
40366
|
+
const actions = resolved?.actions ?? [];
|
|
40367
|
+
const payoffMatrix = resolved?.payoffMatrix ?? [];
|
|
40352
40368
|
const handleAction = useCallback((actionId) => {
|
|
40353
40369
|
if (isComplete) return;
|
|
40354
|
-
const opponentAction = getOpponentAction(
|
|
40370
|
+
const opponentAction = getOpponentAction(resolved?.opponentStrategy ?? "random", actions, history);
|
|
40355
40371
|
const payoff = payoffMatrix.find(
|
|
40356
40372
|
(p2) => p2.playerAction === actionId && p2.opponentAction === opponentAction
|
|
40357
40373
|
);
|
|
@@ -40364,41 +40380,42 @@ function NegotiatorBoard({
|
|
|
40364
40380
|
};
|
|
40365
40381
|
const newHistory = [...history, result];
|
|
40366
40382
|
setHistory(newHistory);
|
|
40367
|
-
if (newHistory.length >=
|
|
40383
|
+
if (newHistory.length >= (resolved?.totalRounds ?? 0)) {
|
|
40368
40384
|
const total = newHistory.reduce((s, r) => s + r.playerPayoff, 0);
|
|
40369
|
-
if (total >=
|
|
40385
|
+
if (total >= (resolved?.targetScore ?? 0)) {
|
|
40370
40386
|
emit(`UI:${completeEvent}`, { success: true, score: total });
|
|
40371
40387
|
}
|
|
40372
|
-
if (newHistory.length >= 3 &&
|
|
40388
|
+
if (newHistory.length >= 3 && resolved?.hint) {
|
|
40373
40389
|
setShowHint(true);
|
|
40374
40390
|
}
|
|
40375
40391
|
}
|
|
40376
|
-
}, [isComplete,
|
|
40392
|
+
}, [isComplete, resolved, actions, payoffMatrix, history, currentRound, completeEvent, emit]);
|
|
40377
40393
|
const handleReset = () => {
|
|
40378
40394
|
setHistory([]);
|
|
40379
40395
|
setShowHint(false);
|
|
40380
40396
|
};
|
|
40381
40397
|
const getActionLabel = (id) => actions.find((a) => a.id === id)?.label ?? id;
|
|
40398
|
+
if (!resolved) return null;
|
|
40382
40399
|
return /* @__PURE__ */ jsx(
|
|
40383
40400
|
Box,
|
|
40384
40401
|
{
|
|
40385
40402
|
className,
|
|
40386
40403
|
style: {
|
|
40387
|
-
backgroundImage:
|
|
40404
|
+
backgroundImage: resolved.theme?.background ? `url(${resolved.theme.background})` : void 0,
|
|
40388
40405
|
backgroundSize: "cover",
|
|
40389
40406
|
backgroundPosition: "center"
|
|
40390
40407
|
},
|
|
40391
40408
|
children: /* @__PURE__ */ jsxs(VStack, { gap: "lg", className: "p-4", children: [
|
|
40392
|
-
|
|
40409
|
+
resolved.headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: resolved.headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : resolved.headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
|
|
40393
40410
|
/* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
|
|
40394
|
-
/* @__PURE__ */ jsx(Typography, { variant: "h4", weight: "bold", children:
|
|
40395
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body", children:
|
|
40411
|
+
/* @__PURE__ */ jsx(Typography, { variant: "h4", weight: "bold", children: resolved.title }),
|
|
40412
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body", children: resolved.description }),
|
|
40396
40413
|
/* @__PURE__ */ jsxs(HStack, { gap: "md", children: [
|
|
40397
|
-
/* @__PURE__ */ jsx(Badge, { size: "sm", children: t("negotiator.round", { current: String(currentRound), total: String(
|
|
40414
|
+
/* @__PURE__ */ jsx(Badge, { size: "sm", children: t("negotiator.round", { current: String(currentRound), total: String(resolved.totalRounds) }) }),
|
|
40398
40415
|
/* @__PURE__ */ jsxs(Badge, { size: "sm", children: [
|
|
40399
40416
|
t("negotiator.target"),
|
|
40400
40417
|
": ",
|
|
40401
|
-
|
|
40418
|
+
resolved.targetScore
|
|
40402
40419
|
] })
|
|
40403
40420
|
] })
|
|
40404
40421
|
] }) }),
|
|
@@ -40447,16 +40464,16 @@ function NegotiatorBoard({
|
|
|
40447
40464
|
] }) }),
|
|
40448
40465
|
isComplete && /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", align: "center", children: [
|
|
40449
40466
|
/* @__PURE__ */ jsx(Icon, { icon: CheckCircle, size: "lg", className: won ? "text-success" : "text-error" }),
|
|
40450
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body", weight: "bold", children: won ?
|
|
40467
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body", weight: "bold", children: won ? resolved.successMessage ?? t("negotiator.success") : resolved.failMessage ?? t("negotiator.failed") }),
|
|
40451
40468
|
/* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "text-muted-foreground", children: [
|
|
40452
40469
|
t("negotiator.finalScore"),
|
|
40453
40470
|
": ",
|
|
40454
40471
|
playerTotal,
|
|
40455
40472
|
"/",
|
|
40456
|
-
|
|
40473
|
+
resolved.targetScore
|
|
40457
40474
|
] })
|
|
40458
40475
|
] }) }),
|
|
40459
|
-
showHint &&
|
|
40476
|
+
showHint && resolved.hint && !won && /* @__PURE__ */ jsx(Card, { className: "p-4 border-l-4 border-l-warning", children: /* @__PURE__ */ jsx(Typography, { variant: "body", children: resolved.hint }) }),
|
|
40460
40477
|
isComplete && !won && /* @__PURE__ */ jsx(HStack, { justify: "center", children: /* @__PURE__ */ jsx(Button, { variant: "primary", onClick: handleReset, children: t("negotiator.playAgain") }) })
|
|
40461
40478
|
] })
|
|
40462
40479
|
}
|
|
@@ -43230,15 +43247,16 @@ function SequencerBoard({
|
|
|
43230
43247
|
}) {
|
|
43231
43248
|
const { emit } = useEventBus();
|
|
43232
43249
|
const { t } = useTranslate();
|
|
43250
|
+
const resolved = Array.isArray(entity) ? entity[0] : entity;
|
|
43233
43251
|
const [headerError, setHeaderError] = useState(false);
|
|
43234
43252
|
const [slots, setSlots] = useState(
|
|
43235
|
-
() => Array.from({ length:
|
|
43253
|
+
() => Array.from({ length: resolved?.maxSlots ?? 0 }, () => void 0)
|
|
43236
43254
|
);
|
|
43237
43255
|
const [playState, setPlayState] = useState("idle");
|
|
43238
43256
|
const [currentStep, setCurrentStep] = useState(-1);
|
|
43239
43257
|
const [attempts, setAttempts] = useState(0);
|
|
43240
43258
|
const [slotFeedback, setSlotFeedback] = useState(
|
|
43241
|
-
() => Array.from({ length:
|
|
43259
|
+
() => Array.from({ length: resolved?.maxSlots ?? 0 }, () => null)
|
|
43242
43260
|
);
|
|
43243
43261
|
const timerRef = useRef(null);
|
|
43244
43262
|
useEffect(() => () => {
|
|
@@ -43272,17 +43290,17 @@ function SequencerBoard({
|
|
|
43272
43290
|
}, [emit]);
|
|
43273
43291
|
const handleReset = useCallback(() => {
|
|
43274
43292
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
43275
|
-
setSlots(Array.from({ length:
|
|
43293
|
+
setSlots(Array.from({ length: resolved?.maxSlots ?? 0 }, () => void 0));
|
|
43276
43294
|
setPlayState("idle");
|
|
43277
43295
|
setCurrentStep(-1);
|
|
43278
43296
|
setAttempts(0);
|
|
43279
|
-
setSlotFeedback(Array.from({ length:
|
|
43280
|
-
}, [
|
|
43297
|
+
setSlotFeedback(Array.from({ length: resolved?.maxSlots ?? 0 }, () => null));
|
|
43298
|
+
}, [resolved?.maxSlots]);
|
|
43281
43299
|
const filledSlots = slots.filter((s) => !!s);
|
|
43282
43300
|
const canPlay = filledSlots.length > 0 && playState === "idle";
|
|
43283
43301
|
const handlePlay = useCallback(() => {
|
|
43284
43302
|
if (!canPlay) return;
|
|
43285
|
-
setSlotFeedback(Array.from({ length:
|
|
43303
|
+
setSlotFeedback(Array.from({ length: resolved?.maxSlots ?? 0 }, () => null));
|
|
43286
43304
|
emit("UI:PLAY_SOUND", { key: "confirm" });
|
|
43287
43305
|
const sequence = slots.map((s) => s?.id || "");
|
|
43288
43306
|
if (playEvent) {
|
|
@@ -43293,10 +43311,10 @@ function SequencerBoard({
|
|
|
43293
43311
|
let step = 0;
|
|
43294
43312
|
const advance = () => {
|
|
43295
43313
|
step++;
|
|
43296
|
-
if (step >=
|
|
43314
|
+
if (step >= (resolved?.maxSlots ?? 0)) {
|
|
43297
43315
|
const playerSeq = slots.map((s) => s?.id);
|
|
43298
43316
|
const playerIds = slots.filter(Boolean).map((s) => s?.id || "");
|
|
43299
|
-
const success =
|
|
43317
|
+
const success = (resolved?.solutions ?? []).some(
|
|
43300
43318
|
(sol) => sol.length === playerIds.length && sol.every((id, i) => id === playerIds[i])
|
|
43301
43319
|
);
|
|
43302
43320
|
if (success) {
|
|
@@ -43308,7 +43326,7 @@ function SequencerBoard({
|
|
|
43308
43326
|
}
|
|
43309
43327
|
} else {
|
|
43310
43328
|
setAttempts((prev) => prev + 1);
|
|
43311
|
-
const feedback = computeSlotFeedback(playerSeq,
|
|
43329
|
+
const feedback = computeSlotFeedback(playerSeq, resolved?.solutions ?? []);
|
|
43312
43330
|
setSlotFeedback(feedback);
|
|
43313
43331
|
setPlayState("idle");
|
|
43314
43332
|
setCurrentStep(-1);
|
|
@@ -43326,10 +43344,10 @@ function SequencerBoard({
|
|
|
43326
43344
|
}
|
|
43327
43345
|
};
|
|
43328
43346
|
timerRef.current = setTimeout(advance, stepDurationMs);
|
|
43329
|
-
}, [canPlay, slots,
|
|
43347
|
+
}, [canPlay, slots, resolved?.maxSlots, resolved?.solutions, stepDurationMs, playEvent, completeEvent, emit]);
|
|
43330
43348
|
const machine = {
|
|
43331
|
-
name:
|
|
43332
|
-
description:
|
|
43349
|
+
name: resolved?.title ?? "",
|
|
43350
|
+
description: resolved?.description ?? "",
|
|
43333
43351
|
states: slots.map((s, i) => stepLabel(s, i)),
|
|
43334
43352
|
currentState: currentStep >= 0 ? stepLabel(slots[currentStep], currentStep) : "__idle__",
|
|
43335
43353
|
transitions: slots.slice(0, -1).map((s, i) => ({
|
|
@@ -43338,36 +43356,37 @@ function SequencerBoard({
|
|
|
43338
43356
|
event: "NEXT"
|
|
43339
43357
|
}))
|
|
43340
43358
|
};
|
|
43341
|
-
const usedIds =
|
|
43342
|
-
const showHint = attempts >= 3 && !!
|
|
43359
|
+
const usedIds = resolved?.allowDuplicates === false ? slots.filter(Boolean).map((s) => s?.id || "") : [];
|
|
43360
|
+
const showHint = attempts >= 3 && !!resolved?.hint;
|
|
43343
43361
|
const hasFeedback = slotFeedback.some((f3) => f3 !== null);
|
|
43344
43362
|
const correctCount = slotFeedback.filter((f3) => f3 === "correct").length;
|
|
43345
43363
|
const encourageKey = ENCOURAGEMENT_KEYS2[Math.min(attempts - 1, ENCOURAGEMENT_KEYS2.length - 1)] ?? ENCOURAGEMENT_KEYS2[0];
|
|
43364
|
+
if (!resolved) return null;
|
|
43346
43365
|
return /* @__PURE__ */ jsxs(
|
|
43347
43366
|
VStack,
|
|
43348
43367
|
{
|
|
43349
43368
|
className: cn("p-4 gap-6", className),
|
|
43350
43369
|
style: {
|
|
43351
|
-
backgroundImage:
|
|
43370
|
+
backgroundImage: resolved.theme?.background ? `url(${resolved.theme.background})` : void 0,
|
|
43352
43371
|
backgroundSize: "cover",
|
|
43353
43372
|
backgroundPosition: "center"
|
|
43354
43373
|
},
|
|
43355
43374
|
children: [
|
|
43356
|
-
|
|
43375
|
+
resolved.headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: resolved.headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : resolved.headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
|
|
43357
43376
|
/* @__PURE__ */ jsxs(VStack, { gap: "xs", children: [
|
|
43358
|
-
/* @__PURE__ */ jsx(Typography, { variant: "h4", className: "text-foreground", children:
|
|
43359
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground", children:
|
|
43377
|
+
/* @__PURE__ */ jsx(Typography, { variant: "h4", className: "text-foreground", children: resolved.title }),
|
|
43378
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground", children: resolved.description })
|
|
43360
43379
|
] }),
|
|
43361
43380
|
showHint && /* @__PURE__ */ jsx(Box, { className: "p-3 rounded-container bg-accent/10 border border-accent/30", children: /* @__PURE__ */ jsxs(HStack, { className: "items-start", gap: "xs", children: [
|
|
43362
43381
|
/* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-accent font-bold shrink-0", children: "\u{1F4A1} " + t("game.hint") + ":" }),
|
|
43363
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-foreground", children:
|
|
43382
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-foreground", children: resolved.hint })
|
|
43364
43383
|
] }) }),
|
|
43365
43384
|
filledSlots.length > 0 && /* @__PURE__ */ jsx(TraitStateViewer, { trait: machine, variant: "linear", size: "md" }),
|
|
43366
43385
|
/* @__PURE__ */ jsxs(VStack, { gap: "xs", children: [
|
|
43367
43386
|
/* @__PURE__ */ jsxs(HStack, { className: "items-center justify-between", children: [
|
|
43368
43387
|
/* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground font-medium", children: t("sequencer.yourSequence") + ":" }),
|
|
43369
43388
|
hasFeedback && playState === "idle" && /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "text-muted-foreground", children: [
|
|
43370
|
-
`${correctCount}/${
|
|
43389
|
+
`${correctCount}/${resolved.maxSlots} `,
|
|
43371
43390
|
"\u2705"
|
|
43372
43391
|
] })
|
|
43373
43392
|
] }),
|
|
@@ -43375,7 +43394,7 @@ function SequencerBoard({
|
|
|
43375
43394
|
SequenceBar,
|
|
43376
43395
|
{
|
|
43377
43396
|
slots,
|
|
43378
|
-
maxSlots:
|
|
43397
|
+
maxSlots: resolved.maxSlots,
|
|
43379
43398
|
onSlotDrop: handleSlotDrop,
|
|
43380
43399
|
onSlotRemove: handleSlotRemove,
|
|
43381
43400
|
playing: playState === "playing",
|
|
@@ -43389,15 +43408,15 @@ function SequencerBoard({
|
|
|
43389
43408
|
playState !== "playing" && /* @__PURE__ */ jsx(
|
|
43390
43409
|
ActionPalette,
|
|
43391
43410
|
{
|
|
43392
|
-
actions:
|
|
43411
|
+
actions: resolved.availableActions,
|
|
43393
43412
|
usedActionIds: usedIds,
|
|
43394
|
-
allowDuplicates:
|
|
43413
|
+
allowDuplicates: resolved.allowDuplicates !== false,
|
|
43395
43414
|
categoryColors,
|
|
43396
43415
|
label: t("sequencer.dragActions")
|
|
43397
43416
|
}
|
|
43398
43417
|
),
|
|
43399
43418
|
hasFeedback && playState === "idle" && attempts > 0 && /* @__PURE__ */ jsx(Box, { className: "p-3 rounded-container bg-warning/10 border border-warning/30 text-center", children: /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-foreground", children: t(encourageKey) }) }),
|
|
43400
|
-
playState === "success" && /* @__PURE__ */ jsx(Box, { className: "p-4 rounded-container bg-success/20 border border-success text-center", children: /* @__PURE__ */ jsx(Typography, { variant: "h5", className: "text-success", children:
|
|
43419
|
+
playState === "success" && /* @__PURE__ */ jsx(Box, { className: "p-4 rounded-container bg-success/20 border border-success text-center", children: /* @__PURE__ */ jsx(Typography, { variant: "h5", className: "text-success", children: resolved.successMessage || t("sequencer.levelComplete") }) }),
|
|
43401
43420
|
/* @__PURE__ */ jsxs(HStack, { gap: "sm", children: [
|
|
43402
43421
|
/* @__PURE__ */ jsx(
|
|
43403
43422
|
Button,
|
|
@@ -44220,7 +44239,8 @@ function SimulatorBoard({
|
|
|
44220
44239
|
}) {
|
|
44221
44240
|
const { emit } = useEventBus();
|
|
44222
44241
|
const { t } = useTranslate();
|
|
44223
|
-
const
|
|
44242
|
+
const resolved = Array.isArray(entity) ? entity[0] : entity;
|
|
44243
|
+
const parameters = resolved?.parameters ?? [];
|
|
44224
44244
|
const [values, setValues] = useState(() => {
|
|
44225
44245
|
const init = {};
|
|
44226
44246
|
for (const p2 of parameters) {
|
|
@@ -44234,15 +44254,15 @@ function SimulatorBoard({
|
|
|
44234
44254
|
const [showHint, setShowHint] = useState(false);
|
|
44235
44255
|
const computeOutput = useCallback((params) => {
|
|
44236
44256
|
try {
|
|
44237
|
-
const fn = new Function("params", `return (${
|
|
44257
|
+
const fn = new Function("params", `return (${resolved?.computeExpression})`);
|
|
44238
44258
|
return fn(params);
|
|
44239
44259
|
} catch {
|
|
44240
44260
|
return 0;
|
|
44241
44261
|
}
|
|
44242
|
-
}, [
|
|
44262
|
+
}, [resolved?.computeExpression]);
|
|
44243
44263
|
const output = useMemo(() => computeOutput(values) ?? 0, [computeOutput, values]);
|
|
44244
|
-
const targetValue =
|
|
44245
|
-
const targetTolerance =
|
|
44264
|
+
const targetValue = resolved?.targetValue ?? 0;
|
|
44265
|
+
const targetTolerance = resolved?.targetTolerance ?? 0;
|
|
44246
44266
|
const isCorrect = Math.abs(output - targetValue) <= targetTolerance;
|
|
44247
44267
|
const handleParameterChange = (id, value) => {
|
|
44248
44268
|
if (submitted) return;
|
|
@@ -44257,7 +44277,7 @@ function SimulatorBoard({
|
|
|
44257
44277
|
};
|
|
44258
44278
|
const handleReset = () => {
|
|
44259
44279
|
setSubmitted(false);
|
|
44260
|
-
if (attempts >= 2 &&
|
|
44280
|
+
if (attempts >= 2 && resolved?.hint) {
|
|
44261
44281
|
setShowHint(true);
|
|
44262
44282
|
}
|
|
44263
44283
|
};
|
|
@@ -44271,20 +44291,21 @@ function SimulatorBoard({
|
|
|
44271
44291
|
setAttempts(0);
|
|
44272
44292
|
setShowHint(false);
|
|
44273
44293
|
};
|
|
44294
|
+
if (!resolved) return null;
|
|
44274
44295
|
return /* @__PURE__ */ jsx(
|
|
44275
44296
|
Box,
|
|
44276
44297
|
{
|
|
44277
44298
|
className,
|
|
44278
44299
|
style: {
|
|
44279
|
-
backgroundImage:
|
|
44300
|
+
backgroundImage: resolved.theme?.background ? `url(${resolved.theme.background})` : void 0,
|
|
44280
44301
|
backgroundSize: "cover",
|
|
44281
44302
|
backgroundPosition: "center"
|
|
44282
44303
|
},
|
|
44283
44304
|
children: /* @__PURE__ */ jsxs(VStack, { gap: "lg", className: "p-4", children: [
|
|
44284
|
-
|
|
44305
|
+
resolved.headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: resolved.headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : resolved.headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
|
|
44285
44306
|
/* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
|
|
44286
|
-
/* @__PURE__ */ jsx(Typography, { variant: "h4", weight: "bold", children:
|
|
44287
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body", children:
|
|
44307
|
+
/* @__PURE__ */ jsx(Typography, { variant: "h4", weight: "bold", children: resolved.title }),
|
|
44308
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body", children: resolved.description })
|
|
44288
44309
|
] }) }),
|
|
44289
44310
|
/* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "md", children: [
|
|
44290
44311
|
/* @__PURE__ */ jsx(Typography, { variant: "small", weight: "bold", className: "uppercase tracking-wider text-muted-foreground", children: t("simulator.parameters") }),
|
|
@@ -44325,28 +44346,28 @@ function SimulatorBoard({
|
|
|
44325
44346
|
] }, param.id))
|
|
44326
44347
|
] }) }),
|
|
44327
44348
|
/* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", align: "center", children: [
|
|
44328
|
-
/* @__PURE__ */ jsx(Typography, { variant: "small", weight: "bold", className: "uppercase tracking-wider text-muted-foreground", children:
|
|
44349
|
+
/* @__PURE__ */ jsx(Typography, { variant: "small", weight: "bold", className: "uppercase tracking-wider text-muted-foreground", children: resolved.outputLabel }),
|
|
44329
44350
|
/* @__PURE__ */ jsxs(Typography, { variant: "h3", weight: "bold", children: [
|
|
44330
44351
|
output.toFixed(2),
|
|
44331
44352
|
" ",
|
|
44332
|
-
|
|
44353
|
+
resolved.outputUnit
|
|
44333
44354
|
] }),
|
|
44334
44355
|
submitted && /* @__PURE__ */ jsxs(HStack, { gap: "xs", align: "center", children: [
|
|
44335
44356
|
/* @__PURE__ */ jsx(Icon, { icon: isCorrect ? CheckCircle : XCircle, size: "sm", className: isCorrect ? "text-success" : "text-error" }),
|
|
44336
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body", className: isCorrect ? "text-success" : "text-error", children: isCorrect ?
|
|
44357
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body", className: isCorrect ? "text-success" : "text-error", children: isCorrect ? resolved.successMessage ?? t("simulator.correct") : resolved.failMessage ?? t("simulator.incorrect") })
|
|
44337
44358
|
] }),
|
|
44338
44359
|
/* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "text-muted-foreground", children: [
|
|
44339
44360
|
t("simulator.target"),
|
|
44340
44361
|
": ",
|
|
44341
44362
|
targetValue,
|
|
44342
44363
|
" ",
|
|
44343
|
-
|
|
44364
|
+
resolved.outputUnit,
|
|
44344
44365
|
" (\xB1",
|
|
44345
44366
|
targetTolerance,
|
|
44346
44367
|
")"
|
|
44347
44368
|
] })
|
|
44348
44369
|
] }) }),
|
|
44349
|
-
showHint &&
|
|
44370
|
+
showHint && resolved.hint && /* @__PURE__ */ jsx(Card, { className: "p-4 border-l-4 border-l-warning", children: /* @__PURE__ */ jsx(Typography, { variant: "body", children: resolved.hint }) }),
|
|
44350
44371
|
/* @__PURE__ */ jsxs(HStack, { gap: "sm", justify: "center", children: [
|
|
44351
44372
|
!submitted ? /* @__PURE__ */ jsxs(Button, { variant: "primary", onClick: handleSubmit, children: [
|
|
44352
44373
|
/* @__PURE__ */ jsx(Icon, { icon: Play, size: "sm" }),
|
|
@@ -44926,13 +44947,14 @@ function StateArchitectBoard({
|
|
|
44926
44947
|
}) {
|
|
44927
44948
|
const { emit } = useEventBus();
|
|
44928
44949
|
const { t } = useTranslate();
|
|
44929
|
-
const
|
|
44950
|
+
const resolved = Array.isArray(entity) ? entity[0] : entity;
|
|
44951
|
+
const [transitions, setTransitions] = useState(resolved?.transitions ?? []);
|
|
44930
44952
|
const [headerError, setHeaderError] = useState(false);
|
|
44931
44953
|
const [playState, setPlayState] = useState("editing");
|
|
44932
|
-
const [currentState, setCurrentState] = useState(
|
|
44954
|
+
const [currentState, setCurrentState] = useState(resolved?.initialState ?? "");
|
|
44933
44955
|
const [selectedState, setSelectedState] = useState(null);
|
|
44934
44956
|
const [testResults, setTestResults] = useState([]);
|
|
44935
|
-
const [variables, setVariables] = useState(
|
|
44957
|
+
const [variables, setVariables] = useState(resolved?.variables ?? []);
|
|
44936
44958
|
const [attempts, setAttempts] = useState(0);
|
|
44937
44959
|
const timerRef = useRef(null);
|
|
44938
44960
|
const [addingFrom, setAddingFrom] = useState(null);
|
|
@@ -44941,12 +44963,12 @@ function StateArchitectBoard({
|
|
|
44941
44963
|
}, []);
|
|
44942
44964
|
const GRAPH_W = 500;
|
|
44943
44965
|
const GRAPH_H = 400;
|
|
44944
|
-
const positions = useMemo(() => layoutStates(
|
|
44966
|
+
const positions = useMemo(() => layoutStates(resolved?.states ?? [], GRAPH_W, GRAPH_H), [resolved?.states]);
|
|
44945
44967
|
const handleStateClick = useCallback((state) => {
|
|
44946
44968
|
if (playState !== "editing") return;
|
|
44947
44969
|
if (addingFrom) {
|
|
44948
44970
|
if (addingFrom !== state) {
|
|
44949
|
-
const event =
|
|
44971
|
+
const event = resolved?.availableEvents[0] || "EVENT";
|
|
44950
44972
|
const newTrans = {
|
|
44951
44973
|
id: `t-${nextTransId++}`,
|
|
44952
44974
|
from: addingFrom,
|
|
@@ -44959,7 +44981,7 @@ function StateArchitectBoard({
|
|
|
44959
44981
|
} else {
|
|
44960
44982
|
setSelectedState(state);
|
|
44961
44983
|
}
|
|
44962
|
-
}, [playState, addingFrom,
|
|
44984
|
+
}, [playState, addingFrom, resolved?.availableEvents]);
|
|
44963
44985
|
const handleStartAddTransition = useCallback(() => {
|
|
44964
44986
|
if (!selectedState) return;
|
|
44965
44987
|
setAddingFrom(selectedState);
|
|
@@ -44968,9 +44990,9 @@ function StateArchitectBoard({
|
|
|
44968
44990
|
setTransitions((prev) => prev.filter((t2) => t2.id !== transId));
|
|
44969
44991
|
}, []);
|
|
44970
44992
|
const machine = useMemo(() => ({
|
|
44971
|
-
name:
|
|
44972
|
-
description:
|
|
44973
|
-
states:
|
|
44993
|
+
name: resolved?.entityName ?? "",
|
|
44994
|
+
description: resolved?.description ?? "",
|
|
44995
|
+
states: resolved?.states ?? [],
|
|
44974
44996
|
currentState,
|
|
44975
44997
|
transitions: transitions.map((t2) => ({
|
|
44976
44998
|
from: t2.from,
|
|
@@ -44978,7 +45000,7 @@ function StateArchitectBoard({
|
|
|
44978
45000
|
event: t2.event,
|
|
44979
45001
|
guardHint: t2.guardHint
|
|
44980
45002
|
}))
|
|
44981
|
-
}), [
|
|
45003
|
+
}), [resolved, currentState, transitions]);
|
|
44982
45004
|
const handleTest = useCallback(() => {
|
|
44983
45005
|
if (playState !== "editing") return;
|
|
44984
45006
|
if (testEvent) emit(`UI:${testEvent}`, {});
|
|
@@ -44987,7 +45009,7 @@ function StateArchitectBoard({
|
|
|
44987
45009
|
const results = [];
|
|
44988
45010
|
let testIdx = 0;
|
|
44989
45011
|
const runNextTest = () => {
|
|
44990
|
-
if (testIdx >=
|
|
45012
|
+
if (testIdx >= (resolved?.testCases.length ?? 0)) {
|
|
44991
45013
|
const allPassed = results.every((r) => r.passed);
|
|
44992
45014
|
setPlayState(allPassed ? "success" : "fail");
|
|
44993
45015
|
setTestResults(results);
|
|
@@ -45002,8 +45024,9 @@ function StateArchitectBoard({
|
|
|
45002
45024
|
}
|
|
45003
45025
|
return;
|
|
45004
45026
|
}
|
|
45005
|
-
const testCase =
|
|
45006
|
-
|
|
45027
|
+
const testCase = resolved?.testCases[testIdx];
|
|
45028
|
+
if (!testCase) return;
|
|
45029
|
+
let state = resolved.initialState;
|
|
45007
45030
|
for (const event of testCase.events) {
|
|
45008
45031
|
const trans = transitions.find((t2) => t2.from === state && t2.event === event);
|
|
45009
45032
|
if (trans) {
|
|
@@ -45021,52 +45044,53 @@ function StateArchitectBoard({
|
|
|
45021
45044
|
timerRef.current = setTimeout(runNextTest, stepDurationMs);
|
|
45022
45045
|
};
|
|
45023
45046
|
timerRef.current = setTimeout(runNextTest, stepDurationMs);
|
|
45024
|
-
}, [playState, transitions,
|
|
45047
|
+
}, [playState, transitions, resolved, stepDurationMs, testEvent, completeEvent, emit]);
|
|
45025
45048
|
const handleTryAgain = useCallback(() => {
|
|
45026
45049
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
45027
45050
|
setPlayState("editing");
|
|
45028
|
-
setCurrentState(
|
|
45051
|
+
setCurrentState(resolved?.initialState ?? "");
|
|
45029
45052
|
setTestResults([]);
|
|
45030
|
-
}, [
|
|
45053
|
+
}, [resolved?.initialState]);
|
|
45031
45054
|
const handleReset = useCallback(() => {
|
|
45032
45055
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
45033
|
-
setTransitions(
|
|
45056
|
+
setTransitions(resolved?.transitions ?? []);
|
|
45034
45057
|
setPlayState("editing");
|
|
45035
|
-
setCurrentState(
|
|
45058
|
+
setCurrentState(resolved?.initialState ?? "");
|
|
45036
45059
|
setTestResults([]);
|
|
45037
|
-
setVariables(
|
|
45060
|
+
setVariables(resolved?.variables ?? []);
|
|
45038
45061
|
setSelectedState(null);
|
|
45039
45062
|
setAddingFrom(null);
|
|
45040
45063
|
setAttempts(0);
|
|
45041
|
-
}, [
|
|
45064
|
+
}, [resolved]);
|
|
45042
45065
|
const codeData = useMemo(() => ({
|
|
45043
|
-
name:
|
|
45044
|
-
states:
|
|
45045
|
-
initialState:
|
|
45066
|
+
name: resolved?.entityName ?? "",
|
|
45067
|
+
states: resolved?.states ?? [],
|
|
45068
|
+
initialState: resolved?.initialState ?? "",
|
|
45046
45069
|
transitions: transitions.map((t2) => ({
|
|
45047
45070
|
from: t2.from,
|
|
45048
45071
|
to: t2.to,
|
|
45049
45072
|
event: t2.event,
|
|
45050
45073
|
...t2.guardHint ? { guard: t2.guardHint } : {}
|
|
45051
45074
|
}))
|
|
45052
|
-
}), [
|
|
45075
|
+
}), [resolved, transitions]);
|
|
45076
|
+
if (!resolved) return null;
|
|
45053
45077
|
return /* @__PURE__ */ jsxs(
|
|
45054
45078
|
VStack,
|
|
45055
45079
|
{
|
|
45056
45080
|
className: cn("p-4 gap-6", className),
|
|
45057
45081
|
style: {
|
|
45058
|
-
backgroundImage:
|
|
45082
|
+
backgroundImage: resolved.theme?.background ? `url(${resolved.theme.background})` : void 0,
|
|
45059
45083
|
backgroundSize: "cover",
|
|
45060
45084
|
backgroundPosition: "center"
|
|
45061
45085
|
},
|
|
45062
45086
|
children: [
|
|
45063
|
-
|
|
45087
|
+
resolved.headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: resolved.headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : resolved.headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
|
|
45064
45088
|
/* @__PURE__ */ jsxs(VStack, { gap: "xs", children: [
|
|
45065
|
-
/* @__PURE__ */ jsx(Typography, { variant: "h4", className: "text-foreground", children:
|
|
45066
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground", children:
|
|
45089
|
+
/* @__PURE__ */ jsx(Typography, { variant: "h4", className: "text-foreground", children: resolved.title }),
|
|
45090
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground", children: resolved.description }),
|
|
45067
45091
|
/* @__PURE__ */ jsxs(HStack, { className: "items-center p-2 rounded bg-warning/10 border border-warning/30", gap: "xs", children: [
|
|
45068
45092
|
/* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-warning font-bold", children: t("game.hint") + ":" }),
|
|
45069
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-foreground", children:
|
|
45093
|
+
/* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-foreground", children: resolved.hint })
|
|
45070
45094
|
] })
|
|
45071
45095
|
] }),
|
|
45072
45096
|
/* @__PURE__ */ jsxs(HStack, { className: "flex-wrap items-start", gap: "lg", children: [
|
|
@@ -45114,14 +45138,14 @@ function StateArchitectBoard({
|
|
|
45114
45138
|
]
|
|
45115
45139
|
}
|
|
45116
45140
|
),
|
|
45117
|
-
|
|
45141
|
+
resolved.states.map((state) => /* @__PURE__ */ jsx(
|
|
45118
45142
|
StateNode2,
|
|
45119
45143
|
{
|
|
45120
45144
|
name: state,
|
|
45121
45145
|
position: positions[state],
|
|
45122
45146
|
isCurrent: state === currentState,
|
|
45123
45147
|
isSelected: state === selectedState,
|
|
45124
|
-
isInitial: state ===
|
|
45148
|
+
isInitial: state === resolved.initialState,
|
|
45125
45149
|
onClick: () => handleStateClick(state)
|
|
45126
45150
|
},
|
|
45127
45151
|
state
|
|
@@ -45168,7 +45192,7 @@ function StateArchitectBoard({
|
|
|
45168
45192
|
/* @__PURE__ */ jsx(
|
|
45169
45193
|
VariablePanel,
|
|
45170
45194
|
{
|
|
45171
|
-
entityName:
|
|
45195
|
+
entityName: resolved.entityName,
|
|
45172
45196
|
variables
|
|
45173
45197
|
}
|
|
45174
45198
|
),
|
|
@@ -45180,15 +45204,15 @@ function StateArchitectBoard({
|
|
|
45180
45204
|
!r.passed && /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-error", children: t("stateArchitect.gotState", { state: r.actualState }) })
|
|
45181
45205
|
] }, i))
|
|
45182
45206
|
] }),
|
|
45183
|
-
|
|
45207
|
+
resolved.showCodeView !== false && /* @__PURE__ */ jsx(CodeView, { data: codeData, label: "View Code" })
|
|
45184
45208
|
] })
|
|
45185
45209
|
] }),
|
|
45186
|
-
playState === "success" && /* @__PURE__ */ jsx(Box, { className: "p-4 rounded-container bg-success/20 border border-success text-center", children: /* @__PURE__ */ jsx(Typography, { variant: "h5", className: "text-success", children:
|
|
45210
|
+
playState === "success" && /* @__PURE__ */ jsx(Box, { className: "p-4 rounded-container bg-success/20 border border-success text-center", children: /* @__PURE__ */ jsx(Typography, { variant: "h5", className: "text-success", children: resolved.successMessage || t("stateArchitect.allPassed") }) }),
|
|
45187
45211
|
playState === "fail" && /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
|
|
45188
45212
|
/* @__PURE__ */ jsx(Box, { className: "p-4 rounded-container bg-warning/10 border border-warning/30 text-center", children: /* @__PURE__ */ jsx(Typography, { variant: "body1", className: "text-foreground font-medium", children: t(ENCOURAGEMENT_KEYS3[Math.min(attempts - 1, ENCOURAGEMENT_KEYS3.length - 1)] ?? ENCOURAGEMENT_KEYS3[0]) }) }),
|
|
45189
|
-
attempts >= 3 &&
|
|
45213
|
+
attempts >= 3 && resolved.hint && /* @__PURE__ */ jsx(Box, { className: "p-3 rounded-container bg-accent/10 border border-accent/30", children: /* @__PURE__ */ jsxs(HStack, { className: "items-start", gap: "xs", children: [
|
|
45190
45214
|
/* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-accent font-bold shrink-0", children: "\u{1F4A1} " + t("game.hint") + ":" }),
|
|
45191
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-foreground", children:
|
|
45215
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-foreground", children: resolved.hint })
|
|
45192
45216
|
] }) })
|
|
45193
45217
|
] }),
|
|
45194
45218
|
/* @__PURE__ */ jsxs(HStack, { gap: "sm", children: [
|
|
@@ -46044,8 +46068,9 @@ var init_useBattleState = __esm({
|
|
|
46044
46068
|
}
|
|
46045
46069
|
});
|
|
46046
46070
|
function UncontrolledBattleBoard({ entity, ...rest }) {
|
|
46071
|
+
const resolved = Array.isArray(entity) ? entity[0] : entity;
|
|
46047
46072
|
const battleState = useBattleState(
|
|
46048
|
-
|
|
46073
|
+
resolved?.initialUnits ?? [],
|
|
46049
46074
|
{
|
|
46050
46075
|
tileClickEvent: rest.tileClickEvent,
|
|
46051
46076
|
unitClickEvent: rest.unitClickEvent,
|
|
@@ -46062,12 +46087,13 @@ function UncontrolledBattleBoard({ entity, ...rest }) {
|
|
|
46062
46087
|
calculateDamage: rest.calculateDamage
|
|
46063
46088
|
}
|
|
46064
46089
|
);
|
|
46090
|
+
if (!resolved) return null;
|
|
46065
46091
|
return /* @__PURE__ */ jsx(
|
|
46066
46092
|
BattleBoard,
|
|
46067
46093
|
{
|
|
46068
46094
|
...rest,
|
|
46069
46095
|
entity: {
|
|
46070
|
-
...
|
|
46096
|
+
...resolved,
|
|
46071
46097
|
units: battleState.units,
|
|
46072
46098
|
phase: battleState.phase,
|
|
46073
46099
|
turn: battleState.turn,
|
|
@@ -46770,6 +46796,7 @@ var init_component_registry_generated = __esm({
|
|
|
46770
46796
|
init_StatsOrganism();
|
|
46771
46797
|
init_StatusDot();
|
|
46772
46798
|
init_StatusEffect();
|
|
46799
|
+
init_StepFlow();
|
|
46773
46800
|
init_StepFlowOrganism();
|
|
46774
46801
|
init_SvgBranch();
|
|
46775
46802
|
init_SvgConnection();
|
|
@@ -47088,6 +47115,7 @@ var init_component_registry_generated = __esm({
|
|
|
47088
47115
|
"StatsOrganism": StatsOrganism,
|
|
47089
47116
|
"StatusDot": StatusDot,
|
|
47090
47117
|
"StatusEffect": StatusEffect,
|
|
47118
|
+
"StepFlow": StepFlow,
|
|
47091
47119
|
"StepFlowOrganism": StepFlowOrganism,
|
|
47092
47120
|
"SvgBranch": SvgBranch,
|
|
47093
47121
|
"SvgConnection": SvgConnection,
|
|
@@ -47815,11 +47843,15 @@ function SlotContentRenderer({
|
|
|
47815
47843
|
}
|
|
47816
47844
|
if (propsSchema) {
|
|
47817
47845
|
for (const [propKey, propDef] of Object.entries(propsSchema)) {
|
|
47818
|
-
const
|
|
47819
|
-
if ((typeof v === "string" || typeof v === "number") && propDef.types?.some(
|
|
47846
|
+
const isDate = propDef.types?.some(
|
|
47820
47847
|
(t) => t === "date" || t === "datetime" || t === "timestamp"
|
|
47821
|
-
)
|
|
47848
|
+
);
|
|
47849
|
+
if (!isDate) continue;
|
|
47850
|
+
const v = renderedProps[propKey];
|
|
47851
|
+
if (typeof v === "string" || typeof v === "number") {
|
|
47822
47852
|
renderedProps[propKey] = new Date(v);
|
|
47853
|
+
} else if (v == null && propDef.required) {
|
|
47854
|
+
renderedProps[propKey] = /* @__PURE__ */ new Date();
|
|
47823
47855
|
}
|
|
47824
47856
|
}
|
|
47825
47857
|
}
|