@almadar/ui 5.86.0 → 5.87.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/avl/index.cjs +3349 -1250
  2. package/dist/avl/index.js +2399 -300
  3. package/dist/components/game/2d/molecules/index.d.ts +23 -15
  4. package/dist/components/game/2d/organisms/BuilderBoard.d.ts +60 -0
  5. package/dist/components/game/2d/organisms/ClassifierBoard.d.ts +66 -0
  6. package/dist/components/game/2d/organisms/DebuggerBoard.d.ts +61 -0
  7. package/dist/components/game/2d/organisms/EventHandlerBoard.d.ts +42 -0
  8. package/dist/components/game/2d/organisms/NegotiatorBoard.d.ts +56 -0
  9. package/dist/components/game/2d/{molecules → organisms}/SequenceBar.d.ts +3 -8
  10. package/dist/components/game/2d/organisms/SequencerBoard.d.ts +69 -0
  11. package/dist/components/game/2d/organisms/SimulatorBoard.d.ts +58 -0
  12. package/dist/components/game/2d/organisms/StateArchitectBoard.d.ts +61 -0
  13. package/dist/components/game/shared/lib/puzzleObject.d.ts +1 -1
  14. package/dist/components/index.cjs +2972 -1243
  15. package/dist/components/index.js +2004 -283
  16. package/dist/providers/index.cjs +3209 -1110
  17. package/dist/providers/index.js +2368 -269
  18. package/dist/runtime/index.cjs +3205 -1106
  19. package/dist/runtime/index.js +2374 -275
  20. package/package.json +1 -1
  21. /package/dist/components/game/2d/{molecules → organisms}/ActionPalette.d.ts +0 -0
  22. /package/dist/components/game/2d/{molecules → organisms}/ActionTile.d.ts +0 -0
  23. /package/dist/components/game/2d/{molecules → organisms}/EventLog.d.ts +0 -0
  24. /package/dist/components/game/2d/{molecules → organisms}/ObjectRulePanel.d.ts +0 -0
  25. /package/dist/components/game/2d/{molecules → organisms}/RuleEditor.d.ts +0 -0
  26. /package/dist/components/game/2d/{molecules → organisms}/SimulationCanvas.d.ts +0 -0
  27. /package/dist/components/game/2d/{molecules → organisms}/SimulationControls.d.ts +0 -0
  28. /package/dist/components/game/2d/{molecules → organisms}/SimulationGraph.d.ts +0 -0
  29. /package/dist/components/game/2d/{molecules → organisms}/StateJsonView.d.ts +0 -0
  30. /package/dist/components/game/2d/{molecules → organisms}/StateNode.d.ts +0 -0
  31. /package/dist/components/game/2d/{molecules → organisms}/TraitSlot.d.ts +0 -0
  32. /package/dist/components/game/2d/{molecules → organisms}/TraitStateViewer.d.ts +0 -0
  33. /package/dist/components/game/2d/{molecules → organisms}/TransitionArrow.d.ts +0 -0
  34. /package/dist/components/game/2d/{molecules → organisms}/VariablePanel.d.ts +0 -0
@@ -1,12 +1,12 @@
1
- import * as React84 from 'react';
2
- import React84__default, { useContext, useMemo, useRef, useEffect, useCallback, Suspense, useState, createContext, useSyncExternalStore, useLayoutEffect, lazy, useId } from 'react';
1
+ import * as React95 from 'react';
2
+ import React95__default, { useContext, useMemo, useRef, useEffect, useCallback, Suspense, useState, createContext, useSyncExternalStore, useLayoutEffect, lazy, useId } from 'react';
3
3
  import { EventBusContext, useTraitScope, useEntitySchemaOptional, useEntitySchema, getAllPages, OrbitalProvider, TraitScopeProvider, ServerBridgeProvider, useCurrentPagePath, VerificationProvider, EntitySchemaProvider, OrbitalThemeProvider, useServerBridge } from '@almadar/ui/providers';
4
4
  export { EntitySchemaProvider, ServerBridgeProvider, TraitContext, TraitProvider, useEntitySchema, useEntitySchemaOptional, useServerBridge, useTrait, useTraitContext } from '@almadar/ui/providers';
5
5
  import { createLogger, isLogLevelEnabled } from '@almadar/logger';
6
6
  import { clsx } from 'clsx';
7
7
  import { twMerge } from 'tailwind-merge';
8
8
  import * as LucideIcons2 from 'lucide-react';
9
- import { Loader2, X, Lightbulb, CheckCircle, List, Printer, ChevronRight, ChevronLeft, GitBranch, Pencil, Eye, Plus, ArrowRight, Trash, Code, FileText, WrapText, Check, Copy, RotateCcw, Play, Terminal, XCircle, AlertTriangle, Trash2, Link2, ZoomOut, ZoomIn, Download, ChevronDown, Menu as Menu$1, Package, Calendar, MoreHorizontal, Image as Image$1, Upload, ArrowLeft, HelpCircle, PauseCircle, Search, Type, Heading1, Heading2, Heading3, ListOrdered, Quote, Minus, Eraser, TrendingUp, TrendingDown, AlertCircle, Circle, Clock, CheckCircle2, ChevronUp, Tag, User, DollarSign } from 'lucide-react';
9
+ import { Loader2, X, Lightbulb, CheckCircle, List, Printer, ChevronRight, ChevronLeft, GitBranch, Pencil, Eye, Plus, ArrowRight, Trash, Code, FileText, WrapText, Check, Copy, RotateCcw, Play, Terminal, XCircle, AlertTriangle, Trash2, Link2, ZoomOut, ZoomIn, Download, ChevronDown, Menu as Menu$1, Package, Calendar, MoreHorizontal, Image as Image$1, Upload, ArrowLeft, HelpCircle, PauseCircle, Search, Type, Heading1, Heading2, Heading3, ListOrdered, Quote, Minus, Eraser, TrendingUp, TrendingDown, AlertCircle, Circle, Clock, CheckCircle2, Bug, Send, ChevronUp, Wrench, Tag, User, DollarSign } from 'lucide-react';
10
10
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
11
11
  import { createPortal } from 'react-dom';
12
12
  import { useTranslate } from '@almadar/ui/hooks';
@@ -937,7 +937,7 @@ var init_Box = __esm({
937
937
  fixed: "fixed",
938
938
  sticky: "sticky"
939
939
  };
940
- Box = React84__default.forwardRef(
940
+ Box = React95__default.forwardRef(
941
941
  ({
942
942
  padding,
943
943
  paddingX,
@@ -1002,7 +1002,7 @@ var init_Box = __esm({
1002
1002
  onPointerDown?.(e);
1003
1003
  }, [hoverEvent, tapReveal, triggerProps, onPointerDown]);
1004
1004
  const isClickable = action || onClick;
1005
- return React84__default.createElement(
1005
+ return React95__default.createElement(
1006
1006
  Component,
1007
1007
  {
1008
1008
  ref,
@@ -1098,7 +1098,7 @@ function loadLib(key, importer) {
1098
1098
  return p;
1099
1099
  }
1100
1100
  function lazyFamilyIcon(libKey, importer, pick, fallbackName, family) {
1101
- const Lazy = React84__default.lazy(async () => {
1101
+ const Lazy = React95__default.lazy(async () => {
1102
1102
  const lib = await loadLib(libKey, importer);
1103
1103
  const Comp = pick(lib);
1104
1104
  if (!Comp) {
@@ -1108,7 +1108,7 @@ function lazyFamilyIcon(libKey, importer, pick, fallbackName, family) {
1108
1108
  return { default: Comp };
1109
1109
  });
1110
1110
  const Wrapped = (props) => /* @__PURE__ */ jsx(
1111
- React84__default.Suspense,
1111
+ React95__default.Suspense,
1112
1112
  {
1113
1113
  fallback: /* @__PURE__ */ jsx(
1114
1114
  "span",
@@ -1839,7 +1839,7 @@ var init_Icon = __esm({
1839
1839
  const directIcon = typeof icon === "string" ? void 0 : icon;
1840
1840
  const effectiveName = typeof icon === "string" ? icon : name;
1841
1841
  const family = useIconFamily();
1842
- const RenderedComponent = React84__default.useMemo(() => {
1842
+ const RenderedComponent = React95__default.useMemo(() => {
1843
1843
  if (directIcon) return null;
1844
1844
  return effectiveName ? resolveIconForFamily(effectiveName, family) : null;
1845
1845
  }, [directIcon, effectiveName, family]);
@@ -1901,7 +1901,7 @@ function resolveIconProp(value, sizeClass) {
1901
1901
  const IconComp = value;
1902
1902
  return /* @__PURE__ */ jsx(IconComp, { className: sizeClass });
1903
1903
  }
1904
- if (React84__default.isValidElement(value)) {
1904
+ if (React95__default.isValidElement(value)) {
1905
1905
  return value;
1906
1906
  }
1907
1907
  if (typeof value === "object" && value !== null && isIconLike(value)) {
@@ -1977,7 +1977,7 @@ var init_Button = __esm({
1977
1977
  md: "h-icon-default w-icon-default",
1978
1978
  lg: "h-icon-default w-icon-default"
1979
1979
  };
1980
- Button = React84__default.forwardRef(
1980
+ Button = React95__default.forwardRef(
1981
1981
  ({
1982
1982
  className,
1983
1983
  variant = "primary",
@@ -2045,7 +2045,7 @@ var Dialog;
2045
2045
  var init_Dialog = __esm({
2046
2046
  "components/core/atoms/Dialog.tsx"() {
2047
2047
  init_cn();
2048
- Dialog = React84__default.forwardRef(
2048
+ Dialog = React95__default.forwardRef(
2049
2049
  ({
2050
2050
  role = "dialog",
2051
2051
  "aria-modal": ariaModal = true,
@@ -2163,7 +2163,7 @@ var init_Typography = __esm({
2163
2163
  }) => {
2164
2164
  const variant = variantProp ?? (level ? `h${level}` : "body1");
2165
2165
  const Component = as || defaultElements[variant];
2166
- return React84__default.createElement(
2166
+ return React95__default.createElement(
2167
2167
  Component,
2168
2168
  {
2169
2169
  id,
@@ -2658,7 +2658,7 @@ var init_Badge = __esm({
2658
2658
  md: "px-2.5 py-1 text-sm",
2659
2659
  lg: "px-3 py-1.5 text-base"
2660
2660
  };
2661
- Badge = React84__default.forwardRef(
2661
+ Badge = React95__default.forwardRef(
2662
2662
  ({ className, variant = "default", size = "sm", amount, label, icon, iconAsset, children, onRemove, removeLabel, ...props }, ref) => {
2663
2663
  const iconSizes3 = {
2664
2664
  sm: "h-icon-default w-icon-default",
@@ -2995,7 +2995,7 @@ var init_SvgFlow = __esm({
2995
2995
  width = 100,
2996
2996
  height = 100
2997
2997
  }) => {
2998
- const markerId = React84__default.useMemo(() => {
2998
+ const markerId = React95__default.useMemo(() => {
2999
2999
  flowIdCounter += 1;
3000
3000
  return `almadar-flow-arrow-${flowIdCounter}`;
3001
3001
  }, []);
@@ -3048,7 +3048,7 @@ var init_SvgGrid = __esm({
3048
3048
  x = 10,
3049
3049
  y = 10,
3050
3050
  cols = 4,
3051
- rows = 3,
3051
+ rows: rows2 = 3,
3052
3052
  spacing = 20,
3053
3053
  nodeRadius = 3,
3054
3054
  color = "var(--color-primary)",
@@ -3060,7 +3060,7 @@ var init_SvgGrid = __esm({
3060
3060
  height = 100
3061
3061
  }) => {
3062
3062
  const highlightSet = new Set(highlights);
3063
- const inner = /* @__PURE__ */ jsx("g", { className, opacity, children: Array.from({ length: rows }).map(
3063
+ const inner = /* @__PURE__ */ jsx("g", { className, opacity, children: Array.from({ length: rows2 }).map(
3064
3064
  (_, row) => Array.from({ length: cols }).map((_2, col) => {
3065
3065
  const index = row * cols + col;
3066
3066
  const isHighlighted = highlightSet.has(index);
@@ -3588,7 +3588,7 @@ var init_SvgRing = __esm({
3588
3588
  width = 100,
3589
3589
  height = 100
3590
3590
  }) => {
3591
- const gradientId = React84__default.useMemo(() => {
3591
+ const gradientId = React95__default.useMemo(() => {
3592
3592
  ringIdCounter += 1;
3593
3593
  return `almadar-ring-glow-${ringIdCounter}`;
3594
3594
  }, []);
@@ -3769,7 +3769,7 @@ var init_Input = __esm({
3769
3769
  init_cn();
3770
3770
  init_Icon();
3771
3771
  init_useEventBus();
3772
- Input = React84__default.forwardRef(
3772
+ Input = React95__default.forwardRef(
3773
3773
  ({
3774
3774
  className,
3775
3775
  inputType,
@@ -3784,7 +3784,7 @@ var init_Input = __esm({
3784
3784
  onClear,
3785
3785
  value,
3786
3786
  options,
3787
- rows = 3,
3787
+ rows: rows2 = 3,
3788
3788
  onChange,
3789
3789
  ...props
3790
3790
  }, ref) => {
@@ -3866,7 +3866,7 @@ var init_Input = __esm({
3866
3866
  ref,
3867
3867
  value,
3868
3868
  onChange: handleChange,
3869
- rows,
3869
+ rows: rows2,
3870
3870
  className: baseClassName,
3871
3871
  ...props
3872
3872
  }
@@ -3929,7 +3929,7 @@ var Label;
3929
3929
  var init_Label = __esm({
3930
3930
  "components/core/atoms/Label.tsx"() {
3931
3931
  init_cn();
3932
- Label = React84__default.forwardRef(
3932
+ Label = React95__default.forwardRef(
3933
3933
  ({ className, required, children, ...props }, ref) => {
3934
3934
  return /* @__PURE__ */ jsxs(
3935
3935
  "label",
@@ -3956,7 +3956,7 @@ var init_Textarea = __esm({
3956
3956
  "components/core/atoms/Textarea.tsx"() {
3957
3957
  init_cn();
3958
3958
  init_useEventBus();
3959
- Textarea = React84__default.forwardRef(
3959
+ Textarea = React95__default.forwardRef(
3960
3960
  ({ className, error, onChange, ...props }, ref) => {
3961
3961
  const eventBus = useEventBus();
3962
3962
  const handleChange = (e) => {
@@ -4195,7 +4195,7 @@ var init_Select = __esm({
4195
4195
  init_cn();
4196
4196
  init_Icon();
4197
4197
  init_useEventBus();
4198
- Select = React84__default.forwardRef(
4198
+ Select = React95__default.forwardRef(
4199
4199
  (props, _ref) => {
4200
4200
  const { multiple, searchable, clearable } = props;
4201
4201
  if (multiple || searchable || clearable) {
@@ -4212,7 +4212,7 @@ var init_Checkbox = __esm({
4212
4212
  "components/core/atoms/Checkbox.tsx"() {
4213
4213
  init_cn();
4214
4214
  init_useEventBus();
4215
- Checkbox = React84__default.forwardRef(
4215
+ Checkbox = React95__default.forwardRef(
4216
4216
  ({ className, label, id, onChange, ...props }, ref) => {
4217
4217
  const inputId = id || `checkbox-${Math.random().toString(36).substr(2, 9)}`;
4218
4218
  const eventBus = useEventBus();
@@ -4266,7 +4266,7 @@ var init_Spinner = __esm({
4266
4266
  md: "h-6 w-6",
4267
4267
  lg: "h-8 w-8"
4268
4268
  };
4269
- Spinner = React84__default.forwardRef(
4269
+ Spinner = React95__default.forwardRef(
4270
4270
  ({ className, size = "md", overlay, ...props }, ref) => {
4271
4271
  if (overlay) {
4272
4272
  return /* @__PURE__ */ jsx(
@@ -4356,7 +4356,7 @@ var init_Card = __esm({
4356
4356
  chip: "shadow-none rounded-pill border-[length:var(--border-width)] border-border",
4357
4357
  "tile-image-first": "p-0 overflow-hidden"
4358
4358
  };
4359
- Card = React84__default.forwardRef(
4359
+ Card = React95__default.forwardRef(
4360
4360
  ({
4361
4361
  className,
4362
4362
  variant = "bordered",
@@ -4404,9 +4404,9 @@ var init_Card = __esm({
4404
4404
  }
4405
4405
  );
4406
4406
  Card.displayName = "Card";
4407
- CardHeader = React84__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("mb-4", className), ...props }));
4407
+ CardHeader = React95__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("mb-4", className), ...props }));
4408
4408
  CardHeader.displayName = "CardHeader";
4409
- CardTitle = React84__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
4409
+ CardTitle = React95__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
4410
4410
  "h3",
4411
4411
  {
4412
4412
  ref,
@@ -4419,11 +4419,11 @@ var init_Card = __esm({
4419
4419
  }
4420
4420
  ));
4421
4421
  CardTitle.displayName = "CardTitle";
4422
- CardContent = React84__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("", className), ...props }));
4422
+ CardContent = React95__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("", className), ...props }));
4423
4423
  CardContent.displayName = "CardContent";
4424
4424
  CardBody = CardContent;
4425
4425
  CardBody.displayName = "CardBody";
4426
- CardFooter = React84__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
4426
+ CardFooter = React95__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
4427
4427
  "div",
4428
4428
  {
4429
4429
  ref,
@@ -4478,7 +4478,7 @@ var init_FilterPill = __esm({
4478
4478
  md: "w-3.5 h-3.5",
4479
4479
  lg: "w-4 h-4"
4480
4480
  };
4481
- FilterPill = React84__default.forwardRef(
4481
+ FilterPill = React95__default.forwardRef(
4482
4482
  ({
4483
4483
  className,
4484
4484
  variant = "default",
@@ -4607,8 +4607,8 @@ var init_Avatar = __esm({
4607
4607
  actionPayload
4608
4608
  }) => {
4609
4609
  const eventBus = useEventBus();
4610
- const [imgFailed, setImgFailed] = React84__default.useState(false);
4611
- React84__default.useEffect(() => {
4610
+ const [imgFailed, setImgFailed] = React95__default.useState(false);
4611
+ React95__default.useEffect(() => {
4612
4612
  setImgFailed(false);
4613
4613
  }, [src]);
4614
4614
  const initials = providedInitials ?? (name ? generateInitials(name) : void 0);
@@ -4721,7 +4721,7 @@ var init_Center = __esm({
4721
4721
  as: Component = "div"
4722
4722
  }) => {
4723
4723
  const mergedStyle = minHeight ? { minHeight, ...style } : style;
4724
- return React84__default.createElement(Component, {
4724
+ return React95__default.createElement(Component, {
4725
4725
  className: cn(
4726
4726
  inline ? "inline-flex" : "flex",
4727
4727
  horizontal && "justify-center",
@@ -4989,7 +4989,7 @@ var init_Radio = __esm({
4989
4989
  md: "w-2.5 h-2.5",
4990
4990
  lg: "w-3 h-3"
4991
4991
  };
4992
- Radio = React84__default.forwardRef(
4992
+ Radio = React95__default.forwardRef(
4993
4993
  ({
4994
4994
  label,
4995
4995
  helperText,
@@ -5006,12 +5006,12 @@ var init_Radio = __esm({
5006
5006
  onChange,
5007
5007
  ...props
5008
5008
  }, ref) => {
5009
- const reactId = React84__default.useId();
5009
+ const reactId = React95__default.useId();
5010
5010
  const baseId = id || `radio-${reactId}`;
5011
5011
  const hasError = !!error;
5012
5012
  const eventBus = useEventBus();
5013
- const [selected, setSelected] = React84__default.useState(value);
5014
- React84__default.useEffect(() => {
5013
+ const [selected, setSelected] = React95__default.useState(value);
5014
+ React95__default.useEffect(() => {
5015
5015
  if (value !== void 0) setSelected(value);
5016
5016
  }, [value]);
5017
5017
  const pick = (next, e) => {
@@ -5193,7 +5193,7 @@ var init_Switch = __esm({
5193
5193
  "components/core/atoms/Switch.tsx"() {
5194
5194
  "use client";
5195
5195
  init_cn();
5196
- Switch = React84.forwardRef(
5196
+ Switch = React95.forwardRef(
5197
5197
  ({
5198
5198
  checked,
5199
5199
  defaultChecked = false,
@@ -5204,10 +5204,10 @@ var init_Switch = __esm({
5204
5204
  name,
5205
5205
  className
5206
5206
  }, ref) => {
5207
- const [isChecked, setIsChecked] = React84.useState(
5207
+ const [isChecked, setIsChecked] = React95.useState(
5208
5208
  checked !== void 0 ? checked : defaultChecked
5209
5209
  );
5210
- React84.useEffect(() => {
5210
+ React95.useEffect(() => {
5211
5211
  if (checked !== void 0) {
5212
5212
  setIsChecked(checked);
5213
5213
  }
@@ -5370,7 +5370,7 @@ var init_Stack = __esm({
5370
5370
  };
5371
5371
  const isHorizontal = direction === "horizontal";
5372
5372
  const directionClass = responsive && isHorizontal ? reverse ? "flex-col-reverse md:flex-row-reverse" : "flex-col md:flex-row" : isHorizontal ? reverse ? "flex-row-reverse" : "flex-row" : reverse ? "flex-col-reverse" : "flex-col";
5373
- return React84__default.createElement(
5373
+ return React95__default.createElement(
5374
5374
  Component,
5375
5375
  {
5376
5376
  className: cn(
@@ -5570,7 +5570,7 @@ var Aside;
5570
5570
  var init_Aside = __esm({
5571
5571
  "components/core/atoms/Aside.tsx"() {
5572
5572
  init_cn();
5573
- Aside = React84__default.forwardRef(
5573
+ Aside = React95__default.forwardRef(
5574
5574
  ({ className, children, ...rest }, ref) => /* @__PURE__ */ jsx("aside", { ref, className: cn(className), ...rest, children })
5575
5575
  );
5576
5576
  Aside.displayName = "Aside";
@@ -5649,9 +5649,9 @@ var init_LawReferenceTooltip = __esm({
5649
5649
  className
5650
5650
  }) => {
5651
5651
  const { t } = useTranslate();
5652
- const [isVisible, setIsVisible] = React84__default.useState(false);
5653
- const timeoutRef = React84__default.useRef(null);
5654
- const triggerRef = React84__default.useRef(null);
5652
+ const [isVisible, setIsVisible] = React95__default.useState(false);
5653
+ const timeoutRef = React95__default.useRef(null);
5654
+ const triggerRef = React95__default.useRef(null);
5655
5655
  const handleMouseEnter = () => {
5656
5656
  if (timeoutRef.current) clearTimeout(timeoutRef.current);
5657
5657
  timeoutRef.current = setTimeout(() => setIsVisible(true), 200);
@@ -5662,7 +5662,7 @@ var init_LawReferenceTooltip = __esm({
5662
5662
  };
5663
5663
  const { revealed, triggerProps } = useTapReveal({ refs: [triggerRef] });
5664
5664
  const open = isVisible || revealed;
5665
- React84__default.useEffect(() => {
5665
+ React95__default.useEffect(() => {
5666
5666
  return () => {
5667
5667
  if (timeoutRef.current) clearTimeout(timeoutRef.current);
5668
5668
  };
@@ -5872,7 +5872,7 @@ var init_StatusDot = __esm({
5872
5872
  md: "w-2.5 h-2.5",
5873
5873
  lg: "w-3 h-3"
5874
5874
  };
5875
- StatusDot = React84__default.forwardRef(
5875
+ StatusDot = React95__default.forwardRef(
5876
5876
  ({ className, status = "offline", pulse = false, size = "md", label, ...props }, ref) => {
5877
5877
  return /* @__PURE__ */ jsx(
5878
5878
  "span",
@@ -5926,7 +5926,7 @@ var init_TrendIndicator = __esm({
5926
5926
  down: "trending-down",
5927
5927
  flat: "arrow-right"
5928
5928
  };
5929
- TrendIndicator = React84__default.forwardRef(
5929
+ TrendIndicator = React95__default.forwardRef(
5930
5930
  ({
5931
5931
  className,
5932
5932
  value,
@@ -5993,7 +5993,7 @@ var init_RangeSlider = __esm({
5993
5993
  md: "w-4 h-4",
5994
5994
  lg: "w-5 h-5"
5995
5995
  };
5996
- RangeSlider = React84__default.forwardRef(
5996
+ RangeSlider = React95__default.forwardRef(
5997
5997
  ({
5998
5998
  className,
5999
5999
  min = 0,
@@ -6552,7 +6552,7 @@ var init_ContentSection = __esm({
6552
6552
  md: "py-16",
6553
6553
  lg: "py-24"
6554
6554
  };
6555
- ContentSection = React84__default.forwardRef(
6555
+ ContentSection = React95__default.forwardRef(
6556
6556
  ({ children, background = "default", padding = "lg", id, className }, ref) => {
6557
6557
  return /* @__PURE__ */ jsx(
6558
6558
  Box,
@@ -7086,7 +7086,7 @@ var init_AnimatedReveal = __esm({
7086
7086
  "scale-up": { opacity: 1, transform: "scale(1) translateY(0)" },
7087
7087
  "none": {}
7088
7088
  };
7089
- AnimatedReveal = React84__default.forwardRef(
7089
+ AnimatedReveal = React95__default.forwardRef(
7090
7090
  ({
7091
7091
  trigger = "scroll",
7092
7092
  animation = "fade-up",
@@ -7246,7 +7246,7 @@ var init_AnimatedGraphic = __esm({
7246
7246
  "components/marketing/atoms/AnimatedGraphic.tsx"() {
7247
7247
  "use client";
7248
7248
  init_cn();
7249
- AnimatedGraphic = React84__default.forwardRef(
7249
+ AnimatedGraphic = React95__default.forwardRef(
7250
7250
  ({
7251
7251
  src,
7252
7252
  svgContent,
@@ -7269,7 +7269,7 @@ var init_AnimatedGraphic = __esm({
7269
7269
  const fetchedSvg = useFetchedSvg(svgContent ? void 0 : src);
7270
7270
  const resolvedSvg = svgContent ?? fetchedSvg;
7271
7271
  const prevAnimateRef = useRef(animate);
7272
- const setRef = React84__default.useCallback(
7272
+ const setRef = React95__default.useCallback(
7273
7273
  (node) => {
7274
7274
  containerRef.current = node;
7275
7275
  if (typeof ref === "function") ref(node);
@@ -7417,6 +7417,20 @@ var init_effects = __esm({
7417
7417
  });
7418
7418
 
7419
7419
  // components/game/shared/boardEntity.ts
7420
+ function boardEntity(entity) {
7421
+ if (!entity) return void 0;
7422
+ return Array.isArray(entity) ? entity[0] : entity;
7423
+ }
7424
+ function str(v) {
7425
+ return v == null ? "" : String(v);
7426
+ }
7427
+ function num(v, fallback = 0) {
7428
+ const n = Number(v);
7429
+ return Number.isFinite(n) ? n : fallback;
7430
+ }
7431
+ function rows(v) {
7432
+ return Array.isArray(v) ? v : [];
7433
+ }
7420
7434
  var init_boardEntity = __esm({
7421
7435
  "components/game/shared/boardEntity.ts"() {
7422
7436
  }
@@ -7862,7 +7876,7 @@ function GameCard({
7862
7876
  className
7863
7877
  }) {
7864
7878
  const eventBus = useEventBus();
7865
- const handleClick = React84.useCallback(() => {
7879
+ const handleClick = React95.useCallback(() => {
7866
7880
  if (disabled) return;
7867
7881
  onClick?.(id);
7868
7882
  if (clickEvent) eventBus.emit(`UI:${clickEvent}`, { cardId: id });
@@ -8144,9 +8158,9 @@ function ControlButton({
8144
8158
  className
8145
8159
  }) {
8146
8160
  const eventBus = useEventBus();
8147
- const [isPressed, setIsPressed] = React84.useState(false);
8161
+ const [isPressed, setIsPressed] = React95.useState(false);
8148
8162
  const actualPressed = pressed ?? isPressed;
8149
- const handlePointerDown = React84.useCallback(
8163
+ const handlePointerDown = React95.useCallback(
8150
8164
  (e) => {
8151
8165
  e.preventDefault();
8152
8166
  if (disabled) return;
@@ -8156,7 +8170,7 @@ function ControlButton({
8156
8170
  },
8157
8171
  [disabled, pressEvent, eventBus, onPress]
8158
8172
  );
8159
- const handlePointerUp = React84.useCallback(
8173
+ const handlePointerUp = React95.useCallback(
8160
8174
  (e) => {
8161
8175
  e.preventDefault();
8162
8176
  if (disabled) return;
@@ -8166,7 +8180,7 @@ function ControlButton({
8166
8180
  },
8167
8181
  [disabled, releaseEvent, eventBus, onRelease]
8168
8182
  );
8169
- const handlePointerLeave = React84.useCallback(
8183
+ const handlePointerLeave = React95.useCallback(
8170
8184
  (e) => {
8171
8185
  if (isPressed) {
8172
8186
  setIsPressed(false);
@@ -9185,8 +9199,8 @@ function MiniMap({
9185
9199
  tileAssets,
9186
9200
  unitAssets
9187
9201
  }) {
9188
- const canvasRef = React84.useRef(null);
9189
- const imgCacheRef = React84.useRef(/* @__PURE__ */ new Map());
9202
+ const canvasRef = React95.useRef(null);
9203
+ const imgCacheRef = React95.useRef(/* @__PURE__ */ new Map());
9190
9204
  function loadImg(url) {
9191
9205
  const cached = imgCacheRef.current.get(url);
9192
9206
  if (cached) return cached.complete ? cached : null;
@@ -9201,7 +9215,7 @@ function MiniMap({
9201
9215
  imgCacheRef.current.set(url, img);
9202
9216
  return null;
9203
9217
  }
9204
- React84.useEffect(() => {
9218
+ React95.useEffect(() => {
9205
9219
  const canvas = canvasRef.current;
9206
9220
  if (!canvas) return;
9207
9221
  const ctx = canvas.getContext("2d");
@@ -9336,8 +9350,8 @@ function ControlGrid({
9336
9350
  className
9337
9351
  }) {
9338
9352
  const eventBus = useEventBus();
9339
- const [active, setActive] = React84.useState(/* @__PURE__ */ new Set());
9340
- const handlePress = React84.useCallback(
9353
+ const [active, setActive] = React95.useState(/* @__PURE__ */ new Set());
9354
+ const handlePress = React95.useCallback(
9341
9355
  (id) => {
9342
9356
  setActive((prev) => new Set(prev).add(id));
9343
9357
  if (actionEvent) eventBus.emit(`UI:${actionEvent}`, { id, pressed: true });
@@ -9351,7 +9365,7 @@ function ControlGrid({
9351
9365
  },
9352
9366
  [kind, actionEvent, directionEvent, directionEvents, eventBus, onAction, onDirection]
9353
9367
  );
9354
- const handleRelease = React84.useCallback(
9368
+ const handleRelease = React95.useCallback(
9355
9369
  (id) => {
9356
9370
  setActive((prev) => {
9357
9371
  const next = new Set(prev);
@@ -9609,7 +9623,7 @@ function InventoryGrid({
9609
9623
  const eventBus = useEventBus();
9610
9624
  const slotCount = totalSlots ?? items.length;
9611
9625
  const emptySlotCount = Math.max(0, slotCount - items.length);
9612
- const handleSelect = React84.useCallback(
9626
+ const handleSelect = React95.useCallback(
9613
9627
  (id) => {
9614
9628
  onSelect?.(id);
9615
9629
  if (selectEvent) {
@@ -9826,7 +9840,7 @@ function GameMenu({
9826
9840
  }) {
9827
9841
  const resolvedOptions = options ?? menuItems ?? DEFAULT_MENU_OPTIONS;
9828
9842
  const eventBus = useEventBus();
9829
- const handleOptionClick = React84.useCallback(
9843
+ const handleOptionClick = React95.useCallback(
9830
9844
  (option) => {
9831
9845
  if (option.event) {
9832
9846
  eventBus.emit(`UI:${option.event}`, { option });
@@ -11321,7 +11335,7 @@ function LinearView({
11321
11335
  /* @__PURE__ */ jsx(HStack, { className: "flex-wrap items-center", gap: "xs", children: trait.states.map((state, i) => {
11322
11336
  const isDone = i < currentIdx;
11323
11337
  const isCurrent = i === currentIdx;
11324
- return /* @__PURE__ */ jsxs(React84__default.Fragment, { children: [
11338
+ return /* @__PURE__ */ jsxs(React95__default.Fragment, { children: [
11325
11339
  i > 0 && /* @__PURE__ */ jsx(
11326
11340
  Typography,
11327
11341
  {
@@ -11518,7 +11532,7 @@ function TraitStateViewer({
11518
11532
  }
11519
11533
  var SIZE_CONFIG;
11520
11534
  var init_TraitStateViewer = __esm({
11521
- "components/game/2d/molecules/TraitStateViewer.tsx"() {
11535
+ "components/game/2d/organisms/TraitStateViewer.tsx"() {
11522
11536
  "use client";
11523
11537
  init_cn();
11524
11538
  init_Box();
@@ -11725,7 +11739,7 @@ function TraitSlot({
11725
11739
  }
11726
11740
  var SIZE_CONFIG2, DRAG_MIME;
11727
11741
  var init_TraitSlot = __esm({
11728
- "components/game/2d/molecules/TraitSlot.tsx"() {
11742
+ "components/game/2d/organisms/TraitSlot.tsx"() {
11729
11743
  "use client";
11730
11744
  init_cn();
11731
11745
  init_useEventBus();
@@ -11784,7 +11798,7 @@ function ActionTile({
11784
11798
  }
11785
11799
  var DRAG_MIME2, SIZE_CONFIG3;
11786
11800
  var init_ActionTile = __esm({
11787
- "components/game/2d/molecules/ActionTile.tsx"() {
11801
+ "components/game/2d/organisms/ActionTile.tsx"() {
11788
11802
  init_atoms();
11789
11803
  init_cn();
11790
11804
  DRAG_MIME2 = "application/x-almadar-slot-item";
@@ -11821,7 +11835,7 @@ function ActionPalette({
11821
11835
  ] });
11822
11836
  }
11823
11837
  var init_ActionPalette = __esm({
11824
- "components/game/2d/molecules/ActionPalette.tsx"() {
11838
+ "components/game/2d/organisms/ActionPalette.tsx"() {
11825
11839
  init_atoms();
11826
11840
  init_cn();
11827
11841
  init_ActionTile();
@@ -11833,8 +11847,6 @@ function SequenceBar({
11833
11847
  maxSlots,
11834
11848
  onSlotDrop,
11835
11849
  onSlotRemove,
11836
- slotDropEvent,
11837
- slotRemoveEvent,
11838
11850
  playing = false,
11839
11851
  currentStep = -1,
11840
11852
  categoryColors,
@@ -11842,19 +11854,16 @@ function SequenceBar({
11842
11854
  size = "lg",
11843
11855
  className
11844
11856
  }) {
11845
- const { emit } = useEventBus();
11846
11857
  const handleDrop = useCallback((index) => (item) => {
11847
11858
  if (playing) return;
11848
- if (slotDropEvent) emit(`UI:${slotDropEvent}`, { slotIndex: index, actionId: item.id });
11849
- onSlotDrop?.(index, item);
11850
- }, [onSlotDrop, slotDropEvent, emit, playing]);
11859
+ onSlotDrop(index, item);
11860
+ }, [onSlotDrop, playing]);
11851
11861
  const handleRemove = useCallback((index) => () => {
11852
11862
  if (playing) return;
11853
- if (slotRemoveEvent) emit(`UI:${slotRemoveEvent}`, { slotIndex: index });
11854
- onSlotRemove?.(index);
11855
- }, [onSlotRemove, slotRemoveEvent, emit, playing]);
11863
+ onSlotRemove(index);
11864
+ }, [onSlotRemove, playing]);
11856
11865
  const paddedSlots = Array.from({ length: maxSlots }, (_, i) => slots[i]);
11857
- return /* @__PURE__ */ jsx(HStack, { className: cn("items-center", className), gap: "sm", children: paddedSlots.map((slot, i) => /* @__PURE__ */ jsxs(React84__default.Fragment, { children: [
11866
+ return /* @__PURE__ */ jsx(HStack, { className: cn("items-center", className), gap: "sm", children: paddedSlots.map((slot, i) => /* @__PURE__ */ jsxs(React95__default.Fragment, { children: [
11858
11867
  i > 0 && /* @__PURE__ */ jsx(
11859
11868
  Typography,
11860
11869
  {
@@ -11884,14 +11893,330 @@ function SequenceBar({
11884
11893
  ] }, i)) });
11885
11894
  }
11886
11895
  var init_SequenceBar = __esm({
11887
- "components/game/2d/molecules/SequenceBar.tsx"() {
11896
+ "components/game/2d/organisms/SequenceBar.tsx"() {
11888
11897
  init_atoms();
11889
11898
  init_cn();
11890
- init_useEventBus();
11891
11899
  init_TraitSlot();
11892
11900
  SequenceBar.displayName = "SequenceBar";
11893
11901
  }
11894
11902
  });
11903
+ function computeSlotFeedback(playerSeq, solutions) {
11904
+ let bestSolution = solutions[0];
11905
+ let bestMatches = -1;
11906
+ for (const sol of solutions) {
11907
+ const matches = sol.filter((id, i) => id === playerSeq[i]).length;
11908
+ if (matches > bestMatches) {
11909
+ bestMatches = matches;
11910
+ bestSolution = sol;
11911
+ }
11912
+ }
11913
+ return playerSeq.map(
11914
+ (id, i) => id !== void 0 && id === bestSolution[i] ? "correct" : "wrong"
11915
+ );
11916
+ }
11917
+ function isFieldRecord(v) {
11918
+ return typeof v === "object" && v !== null && !Array.isArray(v) && !(v instanceof Date);
11919
+ }
11920
+ function assetFromField(v) {
11921
+ if (!isFieldRecord(v)) return void 0;
11922
+ const url = typeof v.url === "string" ? v.url : void 0;
11923
+ const role = typeof v.role === "string" ? v.role : void 0;
11924
+ const category = typeof v.category === "string" ? v.category : "";
11925
+ if (!url || !role) return void 0;
11926
+ return {
11927
+ url,
11928
+ role,
11929
+ category,
11930
+ name: typeof v.name === "string" ? v.name : void 0,
11931
+ thumbnailUrl: typeof v.thumbnailUrl === "string" ? v.thumbnailUrl : void 0,
11932
+ style: typeof v.style === "string" ? v.style : void 0,
11933
+ variant: typeof v.variant === "string" ? v.variant : void 0,
11934
+ dimension: typeof v.dimension === "string" ? v.dimension : void 0,
11935
+ aspect: typeof v.aspect === "string" ? v.aspect : void 0
11936
+ };
11937
+ }
11938
+ function slotItemFromField(fv) {
11939
+ if (!isFieldRecord(fv)) return void 0;
11940
+ const id = typeof fv.id === "string" ? fv.id : void 0;
11941
+ const name = typeof fv.name === "string" ? fv.name : void 0;
11942
+ const category = typeof fv.category === "string" ? fv.category : void 0;
11943
+ if (!id || !name || !category) return void 0;
11944
+ return {
11945
+ id,
11946
+ name,
11947
+ category,
11948
+ description: typeof fv.description === "string" ? fv.description : void 0,
11949
+ iconEmoji: typeof fv.iconEmoji === "string" ? fv.iconEmoji : void 0,
11950
+ iconUrl: assetFromField(fv.iconUrl)
11951
+ };
11952
+ }
11953
+ function SequencerBoard({
11954
+ entity,
11955
+ categoryColors,
11956
+ stepDurationMs = 1e3,
11957
+ playEvent,
11958
+ completeEvent,
11959
+ placeEvent,
11960
+ removeEvent,
11961
+ checkEvent,
11962
+ playAgainEvent,
11963
+ stepEvent,
11964
+ className
11965
+ }) {
11966
+ const { emit } = useEventBus();
11967
+ const { t } = useTranslate();
11968
+ const resolved = boardEntity(entity);
11969
+ const maxSlots = num(resolved?.maxSlots) || 3;
11970
+ const solutions = Array.isArray(resolved?.solutions) ? resolved.solutions : [];
11971
+ const availableActions = (Array.isArray(resolved?.availableActions) ? resolved.availableActions : []).reduce((acc, fv) => {
11972
+ const item = slotItemFromField(fv);
11973
+ if (item) acc.push(item);
11974
+ return acc;
11975
+ }, []);
11976
+ const allowDuplicates = resolved?.allowDuplicates !== false;
11977
+ const entitySlots = Array.isArray(resolved?.slots) ? resolved.slots : [];
11978
+ const entityResult = str(resolved?.result);
11979
+ const entityAttempts = num(resolved?.attempts);
11980
+ const entityCurrentStep = typeof resolved?.currentStep === "number" ? resolved.currentStep : -1;
11981
+ const slots = Array.from({ length: maxSlots }, (_, i) => {
11982
+ const entitySlot = entitySlots.find((s) => s.index === i);
11983
+ if (!entitySlot?.placedActionId) return void 0;
11984
+ return availableActions.find((a) => a.id === entitySlot.placedActionId);
11985
+ });
11986
+ const isSuccess = entityResult === "win";
11987
+ const attempts = entityAttempts;
11988
+ const isPlayingBack = entityCurrentStep >= 0 && !isSuccess;
11989
+ const currentStep = entityCurrentStep;
11990
+ const [headerError, setHeaderError] = useState(false);
11991
+ const [slotFeedback, setSlotFeedback] = useState(
11992
+ () => Array.from({ length: maxSlots }, () => null)
11993
+ );
11994
+ const timerRef = useRef(null);
11995
+ useEffect(() => () => {
11996
+ if (timerRef.current) clearTimeout(timerRef.current);
11997
+ }, []);
11998
+ const handleSlotDrop = useCallback((index, item) => {
11999
+ setSlotFeedback((prev) => {
12000
+ const next = [...prev];
12001
+ next[index] = null;
12002
+ return next;
12003
+ });
12004
+ emit("UI:PLAY_SOUND", { key: "drop_slot" });
12005
+ if (placeEvent) emit(`UI:${placeEvent}`, { slotIndex: index, actionId: item.id });
12006
+ }, [emit, placeEvent]);
12007
+ const handleSlotRemove = useCallback((index) => {
12008
+ setSlotFeedback((prev) => {
12009
+ const next = [...prev];
12010
+ next[index] = null;
12011
+ return next;
12012
+ });
12013
+ emit("UI:PLAY_SOUND", { key: "back" });
12014
+ if (removeEvent) emit(`UI:${removeEvent}`, { slotIndex: index });
12015
+ }, [emit, removeEvent]);
12016
+ const handleReset = useCallback(() => {
12017
+ if (timerRef.current) clearTimeout(timerRef.current);
12018
+ setSlotFeedback(Array.from({ length: maxSlots }, () => null));
12019
+ if (playAgainEvent) emit(`UI:${playAgainEvent}`, {});
12020
+ }, [maxSlots, playAgainEvent, emit]);
12021
+ const filledSlots = slots.filter((s) => !!s);
12022
+ const canPlay = filledSlots.length > 0 && !isPlayingBack && !isSuccess;
12023
+ const handlePlay = useCallback(() => {
12024
+ if (!canPlay) return;
12025
+ setSlotFeedback(Array.from({ length: maxSlots }, () => null));
12026
+ emit("UI:PLAY_SOUND", { key: "confirm" });
12027
+ const sequence = slots.map((s) => s?.id || "");
12028
+ const playerIds = slots.filter(Boolean).map((s) => s?.id || "");
12029
+ if (playEvent) emit(`UI:${playEvent}`, { sequence });
12030
+ let step = 0;
12031
+ const advance = () => {
12032
+ step++;
12033
+ if (stepEvent) emit(`UI:${stepEvent}`, { step });
12034
+ if (step >= maxSlots) {
12035
+ if (checkEvent) emit(`UI:${checkEvent}`, { sequence: playerIds });
12036
+ const playerSeq = slots.map((s) => s?.id);
12037
+ const success = solutions.some(
12038
+ (sol) => sol.length === playerIds.length && sol.every((id, i) => id === playerIds[i])
12039
+ );
12040
+ if (success) {
12041
+ emit("UI:PLAY_SOUND", { key: "levelComplete" });
12042
+ if (completeEvent) emit(`UI:${completeEvent}`, { success: true, sequence: playerIds });
12043
+ } else {
12044
+ const feedback = computeSlotFeedback(playerSeq, solutions);
12045
+ setSlotFeedback(feedback);
12046
+ emit("UI:PLAY_SOUND", { key: "fail" });
12047
+ const correctCount2 = feedback.filter((f3) => f3 === "correct").length;
12048
+ for (let ci = 0; ci < correctCount2; ci++) {
12049
+ setTimeout(() => {
12050
+ emit("UI:PLAY_SOUND", { key: "correctSlot" });
12051
+ }, 300 + ci * 150);
12052
+ }
12053
+ }
12054
+ } else {
12055
+ timerRef.current = setTimeout(advance, stepDurationMs);
12056
+ }
12057
+ };
12058
+ timerRef.current = setTimeout(advance, stepDurationMs);
12059
+ }, [canPlay, slots, maxSlots, solutions, stepDurationMs, playEvent, completeEvent, checkEvent, emit]);
12060
+ const machine = {
12061
+ name: str(resolved?.title),
12062
+ description: str(resolved?.description),
12063
+ states: slots.map((s, i) => stepLabel(s, i)),
12064
+ currentState: currentStep >= 0 ? stepLabel(slots[currentStep], currentStep) : "__idle__",
12065
+ transitions: slots.slice(0, -1).map((s, i) => ({
12066
+ from: stepLabel(s, i),
12067
+ to: stepLabel(slots[i + 1], i + 1),
12068
+ event: "NEXT"
12069
+ }))
12070
+ };
12071
+ const usedIds = !allowDuplicates ? slots.filter(Boolean).map((s) => s?.id || "") : [];
12072
+ const hint = str(resolved?.hint);
12073
+ const showHint = attempts >= 3 && !!hint;
12074
+ const hasFeedback = slotFeedback.some((f3) => f3 !== null);
12075
+ const correctCount = slotFeedback.filter((f3) => f3 === "correct").length;
12076
+ const encourageKey = ENCOURAGEMENT_KEYS[Math.min(attempts - 1, ENCOURAGEMENT_KEYS.length - 1)] ?? ENCOURAGEMENT_KEYS[0];
12077
+ if (!resolved) return null;
12078
+ const theme = resolved.theme ?? void 0;
12079
+ const themeBackground = theme?.background;
12080
+ const headerImage = str(resolved.headerImage);
12081
+ return /* @__PURE__ */ jsxs(
12082
+ VStack,
12083
+ {
12084
+ className: cn("p-4 gap-6", className),
12085
+ style: {
12086
+ backgroundImage: themeBackground ? `url(${themeBackground})` : void 0,
12087
+ backgroundSize: "cover",
12088
+ backgroundPosition: "center"
12089
+ },
12090
+ children: [
12091
+ headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
12092
+ /* @__PURE__ */ jsxs(VStack, { gap: "xs", children: [
12093
+ /* @__PURE__ */ jsx(Typography, { variant: "h4", className: "text-foreground", children: str(resolved.title) }),
12094
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground", children: str(resolved.description) })
12095
+ ] }),
12096
+ 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: [
12097
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-accent font-bold shrink-0", children: "\u{1F4A1} " + t("game.hint") + ":" }),
12098
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-foreground", children: hint })
12099
+ ] }) }),
12100
+ filledSlots.length > 0 && /* @__PURE__ */ jsx(TraitStateViewer, { trait: machine, variant: "linear", size: "md" }),
12101
+ /* @__PURE__ */ jsxs(VStack, { gap: "xs", children: [
12102
+ /* @__PURE__ */ jsxs(HStack, { className: "items-center justify-between", children: [
12103
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground font-medium", children: t("sequencer.yourSequence") + ":" }),
12104
+ hasFeedback && !isPlayingBack && !isSuccess && /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "text-muted-foreground", children: [
12105
+ `${correctCount}/${maxSlots} `,
12106
+ "\u2705"
12107
+ ] })
12108
+ ] }),
12109
+ /* @__PURE__ */ jsx(
12110
+ SequenceBar,
12111
+ {
12112
+ slots,
12113
+ maxSlots,
12114
+ onSlotDrop: handleSlotDrop,
12115
+ onSlotRemove: handleSlotRemove,
12116
+ playing: isPlayingBack,
12117
+ currentStep,
12118
+ categoryColors,
12119
+ slotFeedback,
12120
+ size: "lg"
12121
+ }
12122
+ )
12123
+ ] }),
12124
+ !isPlayingBack && /* @__PURE__ */ jsx(
12125
+ ActionPalette,
12126
+ {
12127
+ actions: availableActions,
12128
+ usedActionIds: usedIds,
12129
+ allowDuplicates,
12130
+ categoryColors,
12131
+ label: t("sequencer.dragActions")
12132
+ }
12133
+ ),
12134
+ hasFeedback && !isPlayingBack && !isSuccess && 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) }) }),
12135
+ isSuccess && /* @__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: str(resolved.successMessage) || t("sequencer.levelComplete") }) }),
12136
+ /* @__PURE__ */ jsxs(HStack, { gap: "sm", children: [
12137
+ /* @__PURE__ */ jsx(
12138
+ Button,
12139
+ {
12140
+ variant: "primary",
12141
+ onClick: handlePlay,
12142
+ disabled: !canPlay,
12143
+ children: "\u25B6 " + t("game.play")
12144
+ }
12145
+ ),
12146
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: handleReset, children: "\u21BA " + t("game.reset") })
12147
+ ] })
12148
+ ]
12149
+ }
12150
+ );
12151
+ }
12152
+ var ENCOURAGEMENT_KEYS, stepLabel;
12153
+ var init_SequencerBoard = __esm({
12154
+ "components/game/2d/organisms/SequencerBoard.tsx"() {
12155
+ init_atoms();
12156
+ init_cn();
12157
+ init_useEventBus();
12158
+ init_TraitStateViewer();
12159
+ init_boardEntity();
12160
+ init_SequenceBar();
12161
+ init_ActionPalette();
12162
+ ENCOURAGEMENT_KEYS = [
12163
+ "puzzle.tryAgain1",
12164
+ "puzzle.tryAgain2",
12165
+ "puzzle.tryAgain3"
12166
+ ];
12167
+ stepLabel = (slot, i) => slot ? `${i + 1}. ${slot.name}` : `Step ${i + 1}`;
12168
+ SequencerBoard.displayName = "SequencerBoard";
12169
+ }
12170
+ });
12171
+ function RuleEditor({
12172
+ rule,
12173
+ availableEvents,
12174
+ availableActions,
12175
+ onChange,
12176
+ onRemove,
12177
+ disabled = false,
12178
+ className
12179
+ }) {
12180
+ const { t } = useTranslate();
12181
+ const handleWhenChange = useCallback((v) => {
12182
+ onChange({ ...rule, whenEvent: v });
12183
+ }, [rule, onChange]);
12184
+ const handleThenChange = useCallback((v) => {
12185
+ onChange({ ...rule, thenAction: v });
12186
+ }, [rule, onChange]);
12187
+ return /* @__PURE__ */ jsxs(HStack, { className: cn("items-center p-2 rounded-lg bg-muted/50 border border-border", className), gap: "sm", children: [
12188
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-primary font-bold whitespace-nowrap", children: t("eventHandler.when") }),
12189
+ /* @__PURE__ */ jsx(
12190
+ Select,
12191
+ {
12192
+ value: rule.whenEvent,
12193
+ onValueChange: handleWhenChange,
12194
+ options: availableEvents,
12195
+ disabled,
12196
+ className: "flex-1 min-w-0"
12197
+ }
12198
+ ),
12199
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-accent font-bold whitespace-nowrap", children: "\u2192 " + t("eventHandler.then") }),
12200
+ /* @__PURE__ */ jsx(
12201
+ Select,
12202
+ {
12203
+ value: rule.thenAction,
12204
+ onValueChange: handleThenChange,
12205
+ options: availableActions,
12206
+ disabled,
12207
+ className: "flex-1 min-w-0"
12208
+ }
12209
+ ),
12210
+ onRemove && /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: onRemove, disabled, className: "shrink-0", children: "\xD7" })
12211
+ ] });
12212
+ }
12213
+ var init_RuleEditor = __esm({
12214
+ "components/game/2d/organisms/RuleEditor.tsx"() {
12215
+ init_atoms();
12216
+ init_cn();
12217
+ RuleEditor.displayName = "RuleEditor";
12218
+ }
12219
+ });
11895
12220
  function EventLog({
11896
12221
  entries,
11897
12222
  maxHeight = 200,
@@ -11927,7 +12252,7 @@ function EventLog({
11927
12252
  }
11928
12253
  var STATUS_STYLES, STATUS_DOTS;
11929
12254
  var init_EventLog = __esm({
11930
- "components/game/2d/molecules/EventLog.tsx"() {
12255
+ "components/game/2d/organisms/EventLog.tsx"() {
11931
12256
  init_atoms();
11932
12257
  init_cn();
11933
12258
  STATUS_STYLES = {
@@ -11947,10 +12272,1768 @@ var init_EventLog = __esm({
11947
12272
  });
11948
12273
 
11949
12274
  // components/game/shared/lib/puzzleObject.ts
12275
+ function objId(o) {
12276
+ return o.id == null ? "" : String(o.id);
12277
+ }
12278
+ function objName(o) {
12279
+ return o.name == null ? "" : String(o.name);
12280
+ }
12281
+ function objIcon(o) {
12282
+ return o.icon == null ? "" : String(o.icon);
12283
+ }
12284
+ function objStates(o) {
12285
+ return Array.isArray(o.states) ? o.states : [];
12286
+ }
12287
+ function objCurrentState(o) {
12288
+ return o.currentState == null ? "" : String(o.currentState);
12289
+ }
12290
+ function objAvailableEvents(o) {
12291
+ return Array.isArray(o.availableEvents) ? o.availableEvents : [];
12292
+ }
12293
+ function objAvailableActions(o) {
12294
+ return Array.isArray(o.availableActions) ? o.availableActions : [];
12295
+ }
12296
+ function objRules(o) {
12297
+ return Array.isArray(o.rules) ? o.rules : [];
12298
+ }
12299
+ function objMaxRules(o) {
12300
+ const n = Number(o.maxRules);
12301
+ return Number.isFinite(n) && n > 0 ? n : 3;
12302
+ }
11950
12303
  var init_puzzleObject = __esm({
11951
12304
  "components/game/shared/lib/puzzleObject.ts"() {
11952
12305
  }
11953
12306
  });
12307
+ function ObjectRulePanel({
12308
+ object,
12309
+ onRulesChange,
12310
+ disabled = false,
12311
+ className
12312
+ }) {
12313
+ const { t } = useTranslate();
12314
+ const id = objId(object);
12315
+ const name = objName(object);
12316
+ const icon = objIcon(object);
12317
+ const states = objStates(object);
12318
+ const currentState = objCurrentState(object);
12319
+ const availableEvents = objAvailableEvents(object);
12320
+ const availableActions = objAvailableActions(object);
12321
+ const rules = objRules(object);
12322
+ const maxRules = objMaxRules(object);
12323
+ const canAdd = rules.length < maxRules;
12324
+ const handleRuleChange = useCallback((index, updatedRule) => {
12325
+ const newRules = [...rules];
12326
+ newRules[index] = updatedRule;
12327
+ onRulesChange(id, newRules);
12328
+ }, [id, rules, onRulesChange]);
12329
+ const handleRuleRemove = useCallback((index) => {
12330
+ const newRules = rules.filter((_, i) => i !== index);
12331
+ onRulesChange(id, newRules);
12332
+ }, [id, rules, onRulesChange]);
12333
+ const handleAddRule = useCallback(() => {
12334
+ if (!canAdd || disabled) return;
12335
+ const firstEvent = availableEvents[0]?.value || "";
12336
+ const firstAction = availableActions[0]?.value || "";
12337
+ const newRule = {
12338
+ id: `rule-${nextRuleId++}`,
12339
+ whenEvent: firstEvent,
12340
+ thenAction: firstAction
12341
+ };
12342
+ onRulesChange(id, [...rules, newRule]);
12343
+ }, [canAdd, disabled, id, rules, availableEvents, availableActions, onRulesChange]);
12344
+ const machine = {
12345
+ name,
12346
+ states,
12347
+ currentState,
12348
+ transitions: rules.map((r) => ({
12349
+ from: currentState,
12350
+ to: states.find((s) => s !== currentState) || currentState,
12351
+ event: r.whenEvent
12352
+ }))
12353
+ };
12354
+ return /* @__PURE__ */ jsxs(VStack, { className: cn("p-4 rounded-lg bg-card border border-border", className), gap: "sm", children: [
12355
+ /* @__PURE__ */ jsxs(HStack, { className: "items-center", gap: "sm", children: [
12356
+ /* @__PURE__ */ jsx(Typography, { variant: "h5", children: icon }),
12357
+ /* @__PURE__ */ jsxs(VStack, { gap: "none", children: [
12358
+ /* @__PURE__ */ jsx(Typography, { variant: "body1", className: "text-foreground font-bold", children: name }),
12359
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground", children: t("eventHandler.state") + ": " + currentState })
12360
+ ] })
12361
+ ] }),
12362
+ /* @__PURE__ */ jsx(TraitStateViewer, { trait: machine, variant: "compact", size: "sm" }),
12363
+ /* @__PURE__ */ jsxs(VStack, { gap: "xs", children: [
12364
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground font-medium", children: t("eventHandler.rules", { count: rules.length, max: maxRules }) + ":" }),
12365
+ rules.map((rule, i) => /* @__PURE__ */ jsx(
12366
+ RuleEditor,
12367
+ {
12368
+ rule,
12369
+ availableEvents,
12370
+ availableActions,
12371
+ onChange: (r) => handleRuleChange(i, r),
12372
+ onRemove: () => handleRuleRemove(i),
12373
+ disabled
12374
+ },
12375
+ rule.id
12376
+ )),
12377
+ canAdd && !disabled && /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: handleAddRule, className: "self-start", children: t("eventHandler.addRule") })
12378
+ ] })
12379
+ ] });
12380
+ }
12381
+ var nextRuleId;
12382
+ var init_ObjectRulePanel = __esm({
12383
+ "components/game/2d/organisms/ObjectRulePanel.tsx"() {
12384
+ init_atoms();
12385
+ init_cn();
12386
+ init_TraitStateViewer();
12387
+ init_RuleEditor();
12388
+ init_puzzleObject();
12389
+ nextRuleId = 1;
12390
+ ObjectRulePanel.displayName = "ObjectRulePanel";
12391
+ }
12392
+ });
12393
+ function EventHandlerBoard({
12394
+ entity,
12395
+ stepDurationMs = 800,
12396
+ playEvent,
12397
+ completeEvent,
12398
+ editRuleEvent,
12399
+ playAgainEvent,
12400
+ className
12401
+ }) {
12402
+ const { emit } = useEventBus();
12403
+ const { t } = useTranslate();
12404
+ const resolved = boardEntity(entity);
12405
+ const objects = rows(resolved?.objects);
12406
+ const entityResult = str(resolved?.result) || "none";
12407
+ const isSuccess = entityResult === "win";
12408
+ const attempts = typeof resolved?.attempts === "number" ? resolved.attempts : 0;
12409
+ const [selectedObjectId, setSelectedObjectId] = useState(
12410
+ objects[0] ? objId(objects[0]) : null
12411
+ );
12412
+ const [headerError, setHeaderError] = useState(false);
12413
+ const [isPlaying, setIsPlaying] = useState(false);
12414
+ const [eventLog, setEventLog] = useState([]);
12415
+ const timerRef = useRef(null);
12416
+ const logIdCounter = useRef(0);
12417
+ useEffect(() => () => {
12418
+ if (timerRef.current) clearTimeout(timerRef.current);
12419
+ }, []);
12420
+ const selectedObject = objects.find((o) => objId(o) === selectedObjectId) ?? null;
12421
+ const handleRulesChange = useCallback((objectId, rules) => {
12422
+ if (editRuleEvent) emit(`UI:${editRuleEvent}`, { objectId, rules });
12423
+ }, [editRuleEvent, emit]);
12424
+ const addLogEntry = useCallback((icon, message, status = "done") => {
12425
+ const id = `log-${logIdCounter.current++}`;
12426
+ setEventLog((prev) => [...prev, { id, timestamp: Date.now(), icon, message, status }]);
12427
+ }, []);
12428
+ const handlePlay = useCallback(() => {
12429
+ if (isPlaying || isSuccess) return;
12430
+ if (playEvent) emit(`UI:${playEvent}`, {});
12431
+ setIsPlaying(true);
12432
+ setEventLog([]);
12433
+ const allRules = [];
12434
+ objects.forEach((obj) => {
12435
+ objRules(obj).forEach((rule) => {
12436
+ allRules.push({ object: obj, rule });
12437
+ });
12438
+ });
12439
+ const triggers = Array.isArray(resolved?.triggerEvents) ? resolved.triggerEvents : [];
12440
+ const goalEvent = str(resolved?.goalEvent);
12441
+ const eventQueue = [...triggers];
12442
+ const firedEvents = /* @__PURE__ */ new Set();
12443
+ let stepIdx = 0;
12444
+ let goalReached = false;
12445
+ const processNext = () => {
12446
+ if (eventQueue.length === 0 || stepIdx > 20) {
12447
+ setIsPlaying(false);
12448
+ if (goalReached && completeEvent) emit(`UI:${completeEvent}`, { success: true });
12449
+ return;
12450
+ }
12451
+ const currentEvent = eventQueue.shift();
12452
+ if (firedEvents.has(currentEvent)) {
12453
+ timerRef.current = setTimeout(processNext, 100);
12454
+ return;
12455
+ }
12456
+ firedEvents.add(currentEvent);
12457
+ const matching = allRules.filter((r) => r.rule.whenEvent === currentEvent);
12458
+ if (matching.length === 0) {
12459
+ addLogEntry("\u26A1", t("eventHandler.noListeners", { event: currentEvent }), "done");
12460
+ } else {
12461
+ matching.forEach(({ object, rule }) => {
12462
+ addLogEntry(objIcon(object), t("eventHandler.heardEvent", { object: objName(object), event: currentEvent, action: rule.thenAction }), "done");
12463
+ eventQueue.push(rule.thenAction);
12464
+ if (rule.thenAction === goalEvent) {
12465
+ goalReached = true;
12466
+ }
12467
+ });
12468
+ }
12469
+ if (currentEvent === goalEvent) {
12470
+ goalReached = true;
12471
+ }
12472
+ stepIdx++;
12473
+ timerRef.current = setTimeout(processNext, stepDurationMs);
12474
+ };
12475
+ if (triggers.length > 0) {
12476
+ addLogEntry("\u{1F3AC}", t("eventHandler.simulationStarted", { events: triggers.join(", ") }), "active");
12477
+ }
12478
+ timerRef.current = setTimeout(processNext, stepDurationMs);
12479
+ }, [isPlaying, isSuccess, objects, resolved, stepDurationMs, playEvent, completeEvent, emit, addLogEntry, t]);
12480
+ const handleTryAgain = useCallback(() => {
12481
+ if (timerRef.current) clearTimeout(timerRef.current);
12482
+ setIsPlaying(false);
12483
+ setEventLog([]);
12484
+ }, []);
12485
+ const handleReset = useCallback(() => {
12486
+ if (timerRef.current) clearTimeout(timerRef.current);
12487
+ setIsPlaying(false);
12488
+ setEventLog([]);
12489
+ setSelectedObjectId(objects[0] ? objId(objects[0]) : null);
12490
+ if (playAgainEvent) emit(`UI:${playAgainEvent}`, {});
12491
+ }, [objects, playAgainEvent, emit]);
12492
+ if (!resolved) return null;
12493
+ const objectViewers = objects.map((obj) => {
12494
+ const states = objStates(obj);
12495
+ const currentState = objCurrentState(obj);
12496
+ const machine = {
12497
+ name: objName(obj),
12498
+ states,
12499
+ currentState,
12500
+ transitions: objRules(obj).map((r) => ({
12501
+ from: currentState,
12502
+ to: states.find((s) => s !== currentState) || currentState,
12503
+ event: r.whenEvent
12504
+ }))
12505
+ };
12506
+ return { obj, machine };
12507
+ });
12508
+ const hint = str(resolved.hint);
12509
+ const showHint = attempts >= 3 && hint;
12510
+ const theme = resolved.theme ?? void 0;
12511
+ const themeBackground = theme?.background;
12512
+ const headerImage = str(resolved.headerImage);
12513
+ const encourageKey = ENCOURAGEMENT_KEYS2[Math.min(attempts - 1, ENCOURAGEMENT_KEYS2.length - 1)] ?? ENCOURAGEMENT_KEYS2[0];
12514
+ return /* @__PURE__ */ jsxs(
12515
+ VStack,
12516
+ {
12517
+ className: cn("p-4 gap-6", className),
12518
+ style: {
12519
+ backgroundImage: themeBackground ? `url(${themeBackground})` : void 0,
12520
+ backgroundSize: "cover",
12521
+ backgroundPosition: "center"
12522
+ },
12523
+ children: [
12524
+ headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
12525
+ /* @__PURE__ */ jsxs(VStack, { gap: "xs", children: [
12526
+ /* @__PURE__ */ jsx(Typography, { variant: "h4", className: "text-foreground", children: str(resolved.title) }),
12527
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground", children: str(resolved.description) }),
12528
+ /* @__PURE__ */ jsxs(HStack, { className: "items-center p-2 rounded bg-primary/10 border border-primary/30", gap: "xs", children: [
12529
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-primary font-bold", children: t("game.goal") + ":" }),
12530
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-foreground", children: str(resolved.goalCondition) })
12531
+ ] })
12532
+ ] }),
12533
+ /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
12534
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground font-medium", children: t("eventHandler.clickObject") + ":" }),
12535
+ /* @__PURE__ */ jsx(HStack, { className: "flex-wrap", gap: "sm", children: objectViewers.map(({ obj, machine }) => {
12536
+ const oid = objId(obj);
12537
+ return /* @__PURE__ */ jsx(
12538
+ Box,
12539
+ {
12540
+ className: cn(
12541
+ "p-3 rounded-container border-2 cursor-pointer transition-all hover:scale-105",
12542
+ selectedObjectId === oid ? "border-primary bg-primary/10" : "border-border bg-card hover:border-muted-foreground"
12543
+ ),
12544
+ onClick: () => setSelectedObjectId(oid),
12545
+ children: /* @__PURE__ */ jsxs(VStack, { gap: "xs", className: "items-center min-w-[120px]", children: [
12546
+ /* @__PURE__ */ jsx(Typography, { variant: "h5", children: objIcon(obj) }),
12547
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-foreground font-medium", children: objName(obj) }),
12548
+ /* @__PURE__ */ jsx(TraitStateViewer, { trait: machine, variant: "compact", size: "sm" })
12549
+ ] })
12550
+ },
12551
+ oid
12552
+ );
12553
+ }) })
12554
+ ] }),
12555
+ selectedObject && /* @__PURE__ */ jsx(
12556
+ ObjectRulePanel,
12557
+ {
12558
+ object: selectedObject,
12559
+ onRulesChange: handleRulesChange,
12560
+ disabled: isPlaying
12561
+ }
12562
+ ),
12563
+ eventLog.length > 0 && /* @__PURE__ */ jsx(EventLog, { entries: eventLog }),
12564
+ isSuccess && /* @__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: str(resolved.successMessage) || t("eventHandler.chainComplete") }) }),
12565
+ !isPlaying && !isSuccess && attempts > 0 && /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
12566
+ /* @__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) }) }),
12567
+ 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: [
12568
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-accent font-bold shrink-0", children: "\u{1F4A1} " + t("game.hint") + ":" }),
12569
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-foreground", children: hint })
12570
+ ] }) })
12571
+ ] }),
12572
+ /* @__PURE__ */ jsxs(HStack, { gap: "sm", children: [
12573
+ !isPlaying && !isSuccess && attempts > 0 ? /* @__PURE__ */ jsx(Button, { variant: "primary", onClick: handleTryAgain, children: "\u{1F504} " + t("puzzle.tryAgainButton") }) : /* @__PURE__ */ jsx(
12574
+ Button,
12575
+ {
12576
+ variant: "primary",
12577
+ onClick: handlePlay,
12578
+ disabled: isPlaying || isSuccess,
12579
+ children: "\u25B6 " + t("game.play")
12580
+ }
12581
+ ),
12582
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: handleReset, children: "\u21BA " + t("game.reset") })
12583
+ ] })
12584
+ ]
12585
+ }
12586
+ );
12587
+ }
12588
+ var ENCOURAGEMENT_KEYS2;
12589
+ var init_EventHandlerBoard = __esm({
12590
+ "components/game/2d/organisms/EventHandlerBoard.tsx"() {
12591
+ init_atoms();
12592
+ init_cn();
12593
+ init_useEventBus();
12594
+ init_TraitStateViewer();
12595
+ init_ObjectRulePanel();
12596
+ init_EventLog();
12597
+ init_puzzleObject();
12598
+ init_boardEntity();
12599
+ ENCOURAGEMENT_KEYS2 = [
12600
+ "puzzle.tryAgain1",
12601
+ "puzzle.tryAgain2",
12602
+ "puzzle.tryAgain3"
12603
+ ];
12604
+ EventHandlerBoard.displayName = "EventHandlerBoard";
12605
+ }
12606
+ });
12607
+ function StateNode({
12608
+ name,
12609
+ isCurrent = false,
12610
+ isSelected = false,
12611
+ isInitial = false,
12612
+ position,
12613
+ onClick,
12614
+ className
12615
+ }) {
12616
+ return /* @__PURE__ */ jsx(
12617
+ Box,
12618
+ {
12619
+ position: "absolute",
12620
+ display: "flex",
12621
+ className: cn(
12622
+ "items-center justify-center rounded-pill border-3 transition-all cursor-pointer select-none",
12623
+ "min-w-[80px] h-[80px] px-3",
12624
+ isCurrent && "bg-primary/20 border-primary shadow-lg shadow-primary/30 scale-110",
12625
+ isSelected && !isCurrent && "bg-accent/20 border-accent ring-2 ring-accent/50",
12626
+ !isCurrent && !isSelected && "bg-card border-border hover:border-muted-foreground hover:scale-105",
12627
+ className
12628
+ ),
12629
+ style: {
12630
+ left: position.x,
12631
+ top: position.y,
12632
+ transform: "translate(-50%, -50%)"
12633
+ },
12634
+ onClick,
12635
+ children: /* @__PURE__ */ jsxs(Box, { className: "text-center", children: [
12636
+ isInitial && /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground text-xs block", children: "\u25B6 start" }),
12637
+ /* @__PURE__ */ jsx(
12638
+ Typography,
12639
+ {
12640
+ variant: "body2",
12641
+ className: cn(
12642
+ "font-bold whitespace-nowrap",
12643
+ isCurrent ? "text-primary" : "text-foreground"
12644
+ ),
12645
+ children: name
12646
+ }
12647
+ )
12648
+ ] })
12649
+ }
12650
+ );
12651
+ }
12652
+ var init_StateNode = __esm({
12653
+ "components/game/2d/organisms/StateNode.tsx"() {
12654
+ init_atoms();
12655
+ init_cn();
12656
+ StateNode.displayName = "StateNode";
12657
+ }
12658
+ });
12659
+ function TransitionArrow({
12660
+ from,
12661
+ to,
12662
+ eventLabel,
12663
+ guardHint,
12664
+ isActive = false,
12665
+ onClick,
12666
+ className
12667
+ }) {
12668
+ const dx = to.x - from.x;
12669
+ const dy = to.y - from.y;
12670
+ const dist = Math.sqrt(dx * dx + dy * dy);
12671
+ if (dist === 0) return /* @__PURE__ */ jsx(Fragment, {});
12672
+ const nx = dx / dist;
12673
+ const ny = dy / dist;
12674
+ const startX = from.x + nx * NODE_RADIUS;
12675
+ const startY = from.y + ny * NODE_RADIUS;
12676
+ const endX = to.x - nx * NODE_RADIUS;
12677
+ const endY = to.y - ny * NODE_RADIUS;
12678
+ const midX = (startX + endX) / 2;
12679
+ const midY = (startY + endY) / 2;
12680
+ const perpX = -ny * 20;
12681
+ const perpY = nx * 20;
12682
+ const ctrlX = midX + perpX;
12683
+ const ctrlY = midY + perpY;
12684
+ const path = `M ${startX} ${startY} Q ${ctrlX} ${ctrlY} ${endX} ${endY}`;
12685
+ return /* @__PURE__ */ jsxs("g", { className: cn("cursor-pointer", className), onClick, children: [
12686
+ /* @__PURE__ */ jsx(
12687
+ "path",
12688
+ {
12689
+ d: path,
12690
+ fill: "none",
12691
+ stroke: isActive ? "var(--color-primary)" : "var(--color-border)",
12692
+ strokeWidth: isActive ? 3 : 2,
12693
+ markerEnd: isActive ? "url(#arrowhead-active)" : "url(#arrowhead)"
12694
+ }
12695
+ ),
12696
+ /* @__PURE__ */ jsx(
12697
+ "text",
12698
+ {
12699
+ x: ctrlX,
12700
+ y: ctrlY - 8,
12701
+ textAnchor: "middle",
12702
+ fill: isActive ? "var(--color-primary)" : "var(--color-foreground)",
12703
+ fontSize: 12,
12704
+ fontWeight: isActive ? "bold" : "normal",
12705
+ className: "select-none",
12706
+ children: eventLabel
12707
+ }
12708
+ ),
12709
+ guardHint && /* @__PURE__ */ jsx(
12710
+ "text",
12711
+ {
12712
+ x: ctrlX,
12713
+ y: ctrlY + 6,
12714
+ textAnchor: "middle",
12715
+ fill: "var(--color-warning)",
12716
+ fontSize: 10,
12717
+ className: "select-none",
12718
+ children: "\u26A0 " + guardHint
12719
+ }
12720
+ )
12721
+ ] });
12722
+ }
12723
+ var NODE_RADIUS;
12724
+ var init_TransitionArrow = __esm({
12725
+ "components/game/2d/organisms/TransitionArrow.tsx"() {
12726
+ init_cn();
12727
+ NODE_RADIUS = 40;
12728
+ TransitionArrow.displayName = "TransitionArrow";
12729
+ }
12730
+ });
12731
+ function VariablePanel({
12732
+ entityName,
12733
+ variables,
12734
+ className
12735
+ }) {
12736
+ const { t } = useTranslate();
12737
+ return /* @__PURE__ */ jsxs(VStack, { className: cn("p-3 rounded-lg bg-card border border-border", className), gap: "sm", children: [
12738
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground font-medium", children: t("stateArchitect.variables", { name: entityName }) }),
12739
+ variables.map((v) => {
12740
+ const name = v.name == null ? "" : String(v.name);
12741
+ const value = numField(v.value);
12742
+ const max = numField(v.max, 100);
12743
+ const min = numField(v.min, 0);
12744
+ const unit = v.unit == null ? "" : String(v.unit);
12745
+ const pct = Math.round((value - min) / (max - min) * 100);
12746
+ const isHigh = pct > 80;
12747
+ const isLow = pct < 20;
12748
+ return /* @__PURE__ */ jsxs(VStack, { gap: "none", children: [
12749
+ /* @__PURE__ */ jsxs(HStack, { className: "items-center justify-between", children: [
12750
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-foreground font-medium", children: name }),
12751
+ /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: cn(
12752
+ isHigh ? "text-error" : isLow ? "text-warning" : "text-foreground"
12753
+ ), children: [
12754
+ value,
12755
+ unit,
12756
+ " / ",
12757
+ max,
12758
+ unit
12759
+ ] })
12760
+ ] }),
12761
+ /* @__PURE__ */ jsx(
12762
+ ProgressBar,
12763
+ {
12764
+ value: pct,
12765
+ color: isHigh ? "danger" : isLow ? "warning" : "primary",
12766
+ size: "sm"
12767
+ }
12768
+ )
12769
+ ] }, name);
12770
+ })
12771
+ ] });
12772
+ }
12773
+ var numField;
12774
+ var init_VariablePanel = __esm({
12775
+ "components/game/2d/organisms/VariablePanel.tsx"() {
12776
+ init_atoms();
12777
+ init_cn();
12778
+ numField = (v, fallback = 0) => {
12779
+ const n = Number(v);
12780
+ return Number.isFinite(n) ? n : fallback;
12781
+ };
12782
+ VariablePanel.displayName = "VariablePanel";
12783
+ }
12784
+ });
12785
+ function StateJsonView({
12786
+ data,
12787
+ label,
12788
+ defaultExpanded = false,
12789
+ className
12790
+ }) {
12791
+ const { t } = useTranslate();
12792
+ const [expanded, setExpanded] = useState(defaultExpanded);
12793
+ const jsonString = JSON.stringify(data, null, 2);
12794
+ return /* @__PURE__ */ jsxs(VStack, { className: cn("rounded-lg border border-border overflow-hidden", className), gap: "none", children: [
12795
+ /* @__PURE__ */ jsxs(HStack, { className: "items-center justify-between p-2 bg-muted", gap: "sm", children: [
12796
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground font-medium", children: label ?? t("stateArchitect.viewCode") }),
12797
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: () => setExpanded(!expanded), className: "text-xs", children: expanded ? t("stateArchitect.hideJson") : t("stateArchitect.showJson") })
12798
+ ] }),
12799
+ expanded && /* @__PURE__ */ jsx(Box, { className: "p-3 bg-background overflow-x-auto", children: /* @__PURE__ */ jsx(
12800
+ Typography,
12801
+ {
12802
+ variant: "caption",
12803
+ className: "text-foreground font-mono whitespace-pre text-xs leading-relaxed block",
12804
+ children: jsonString
12805
+ }
12806
+ ) })
12807
+ ] });
12808
+ }
12809
+ var init_StateJsonView = __esm({
12810
+ "components/game/2d/organisms/StateJsonView.tsx"() {
12811
+ init_atoms();
12812
+ init_cn();
12813
+ StateJsonView.displayName = "StateJsonView";
12814
+ }
12815
+ });
12816
+ function layoutStates(states, width, height) {
12817
+ const cx = width / 2;
12818
+ const cy = height / 2;
12819
+ const radius = Math.min(cx, cy) - 60;
12820
+ const positions = {};
12821
+ states.forEach((state, i) => {
12822
+ const angle = 2 * Math.PI * i / states.length - Math.PI / 2;
12823
+ positions[state] = {
12824
+ x: cx + radius * Math.cos(angle),
12825
+ y: cy + radius * Math.sin(angle)
12826
+ };
12827
+ });
12828
+ return positions;
12829
+ }
12830
+ function StateArchitectBoard({
12831
+ entity,
12832
+ stepDurationMs = 600,
12833
+ testEvent,
12834
+ completeEvent,
12835
+ addTransitionEvent,
12836
+ removeTransitionEvent,
12837
+ playAgainEvent,
12838
+ className
12839
+ }) {
12840
+ const { emit } = useEventBus();
12841
+ const { t } = useTranslate();
12842
+ const resolved = boardEntity(entity);
12843
+ const entityStates = Array.isArray(resolved?.states) ? resolved.states : [];
12844
+ const initialState = str(resolved?.initialState);
12845
+ const entityName = str(resolved?.entityName);
12846
+ const availableEvents = Array.isArray(resolved?.availableEvents) ? resolved.availableEvents : [];
12847
+ const testCases = (Array.isArray(resolved?.testCases) ? resolved.testCases : []).map((item) => {
12848
+ const o = typeof item === "object" && item !== null && !Array.isArray(item) ? item : {};
12849
+ const eventsField = o["events"];
12850
+ return {
12851
+ events: Array.isArray(eventsField) ? eventsField : [],
12852
+ expectedState: str(o["expectedState"]),
12853
+ label: str(o["label"])
12854
+ };
12855
+ });
12856
+ const entityTransitions = (Array.isArray(resolved?.transitions) ? resolved.transitions : []).map((item) => {
12857
+ const o = typeof item === "object" && item !== null && !Array.isArray(item) ? item : {};
12858
+ return {
12859
+ id: str(o["id"]),
12860
+ from: str(o["from"]),
12861
+ to: str(o["to"]),
12862
+ event: str(o["event"]),
12863
+ ...o["guardHint"] ? { guardHint: str(o["guardHint"]) } : {}
12864
+ };
12865
+ });
12866
+ const entityVariables = rows(resolved?.variables);
12867
+ const transitions = entityTransitions;
12868
+ const attempts = typeof resolved?.attempts === "number" ? resolved.attempts : 0;
12869
+ const entityResult = str(resolved?.result) || "none";
12870
+ const isSuccess = entityResult === "win";
12871
+ const [isTesting, setIsTesting] = useState(false);
12872
+ const [headerError, setHeaderError] = useState(false);
12873
+ const [currentState, setCurrentState] = useState(initialState);
12874
+ const [selectedState, setSelectedState] = useState(null);
12875
+ const [testResults, setTestResults] = useState([]);
12876
+ const [variables, setVariables] = useState(() => [...entityVariables]);
12877
+ const timerRef = useRef(null);
12878
+ const [addingFrom, setAddingFrom] = useState(null);
12879
+ useEffect(() => () => {
12880
+ if (timerRef.current) clearTimeout(timerRef.current);
12881
+ }, []);
12882
+ const GRAPH_W = 500;
12883
+ const GRAPH_H = 400;
12884
+ const positions = useMemo(() => layoutStates(entityStates, GRAPH_W, GRAPH_H), [entityStates]);
12885
+ const handleStateClick = useCallback((state) => {
12886
+ if (isTesting) return;
12887
+ if (addingFrom) {
12888
+ if (addingFrom !== state) {
12889
+ const event = availableEvents[0] || "EVENT";
12890
+ const newTrans = {
12891
+ id: `t-${nextTransId++}`,
12892
+ from: addingFrom,
12893
+ to: state,
12894
+ event
12895
+ };
12896
+ if (addTransitionEvent) emit(`UI:${addTransitionEvent}`, { id: newTrans.id, from: newTrans.from, to: newTrans.to, event: newTrans.event });
12897
+ }
12898
+ setAddingFrom(null);
12899
+ } else {
12900
+ setSelectedState(state);
12901
+ }
12902
+ }, [isTesting, addingFrom, availableEvents, addTransitionEvent, emit]);
12903
+ const handleStartAddTransition = useCallback(() => {
12904
+ if (!selectedState) return;
12905
+ setAddingFrom(selectedState);
12906
+ }, [selectedState]);
12907
+ const handleRemoveTransition = useCallback((transId) => {
12908
+ if (removeTransitionEvent) emit(`UI:${removeTransitionEvent}`, { id: transId });
12909
+ }, [removeTransitionEvent, emit]);
12910
+ const machine = useMemo(() => ({
12911
+ name: entityName,
12912
+ description: str(resolved?.description),
12913
+ states: entityStates,
12914
+ currentState,
12915
+ transitions: transitions.map((t2) => ({
12916
+ from: t2.from,
12917
+ to: t2.to,
12918
+ event: t2.event,
12919
+ guardHint: t2.guardHint
12920
+ }))
12921
+ }), [entityName, resolved, entityStates, currentState, transitions]);
12922
+ const handleTest = useCallback(() => {
12923
+ if (isTesting) return;
12924
+ if (testEvent) emit(`UI:${testEvent}`, {});
12925
+ setIsTesting(true);
12926
+ setTestResults([]);
12927
+ const results = [];
12928
+ let testIdx = 0;
12929
+ const runNextTest = () => {
12930
+ if (testIdx >= testCases.length) {
12931
+ const allPassed = results.every((r) => r.passed);
12932
+ setIsTesting(false);
12933
+ setTestResults(results);
12934
+ if (allPassed && completeEvent) {
12935
+ emit(`UI:${completeEvent}`, {
12936
+ success: true,
12937
+ passedTests: results.filter((r) => r.passed).length
12938
+ });
12939
+ }
12940
+ return;
12941
+ }
12942
+ const testCase = testCases[testIdx];
12943
+ if (!testCase) return;
12944
+ let state = initialState;
12945
+ for (const event of testCase.events) {
12946
+ const trans = transitions.find((t2) => t2.from === state && t2.event === event);
12947
+ if (trans) {
12948
+ state = trans.to;
12949
+ }
12950
+ }
12951
+ setCurrentState(state);
12952
+ results.push({
12953
+ label: testCase.label,
12954
+ passed: state === testCase.expectedState,
12955
+ actualState: state,
12956
+ expectedState: testCase.expectedState
12957
+ });
12958
+ testIdx++;
12959
+ timerRef.current = setTimeout(runNextTest, stepDurationMs);
12960
+ };
12961
+ timerRef.current = setTimeout(runNextTest, stepDurationMs);
12962
+ }, [isTesting, transitions, testCases, initialState, stepDurationMs, testEvent, completeEvent, emit]);
12963
+ const handleTryAgain = useCallback(() => {
12964
+ if (timerRef.current) clearTimeout(timerRef.current);
12965
+ setIsTesting(false);
12966
+ setCurrentState(initialState);
12967
+ setTestResults([]);
12968
+ }, [initialState]);
12969
+ const handleReset = useCallback(() => {
12970
+ if (timerRef.current) clearTimeout(timerRef.current);
12971
+ setIsTesting(false);
12972
+ setCurrentState(initialState);
12973
+ setTestResults([]);
12974
+ setVariables([...entityVariables]);
12975
+ setSelectedState(null);
12976
+ setAddingFrom(null);
12977
+ if (playAgainEvent) emit(`UI:${playAgainEvent}`, {});
12978
+ }, [initialState, entityVariables, playAgainEvent, emit]);
12979
+ const codeData = useMemo(() => ({
12980
+ name: entityName,
12981
+ states: entityStates,
12982
+ initialState,
12983
+ transitions: transitions.map((t2) => ({
12984
+ from: t2.from,
12985
+ to: t2.to,
12986
+ event: t2.event,
12987
+ ...t2.guardHint ? { guard: t2.guardHint } : {}
12988
+ }))
12989
+ }), [entityName, entityStates, initialState, transitions]);
12990
+ if (!resolved) return null;
12991
+ const theme = resolved.theme ?? void 0;
12992
+ const themeBackground = theme?.background;
12993
+ const headerImage = str(resolved.headerImage);
12994
+ const hint = str(resolved.hint);
12995
+ return /* @__PURE__ */ jsxs(
12996
+ VStack,
12997
+ {
12998
+ className: cn("p-4 gap-6", className),
12999
+ style: {
13000
+ backgroundImage: themeBackground ? `url(${themeBackground})` : void 0,
13001
+ backgroundSize: "cover",
13002
+ backgroundPosition: "center"
13003
+ },
13004
+ children: [
13005
+ headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
13006
+ /* @__PURE__ */ jsxs(VStack, { gap: "xs", children: [
13007
+ /* @__PURE__ */ jsx(Typography, { variant: "h4", className: "text-foreground", children: str(resolved.title) }),
13008
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground", children: str(resolved.description) }),
13009
+ /* @__PURE__ */ jsxs(HStack, { className: "items-center p-2 rounded bg-warning/10 border border-warning/30", gap: "xs", children: [
13010
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-warning font-bold", children: t("game.hint") + ":" }),
13011
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-foreground", children: hint })
13012
+ ] })
13013
+ ] }),
13014
+ /* @__PURE__ */ jsxs(HStack, { className: "flex-wrap items-start", gap: "lg", children: [
13015
+ /* @__PURE__ */ jsxs(VStack, { gap: "sm", className: "flex-1 min-w-[300px]", children: [
13016
+ /* @__PURE__ */ jsxs(HStack, { className: "items-center justify-between", children: [
13017
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground font-medium", children: t("stateArchitect.graph") }),
13018
+ addingFrom && /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-accent animate-pulse", children: t("stateArchitect.clickTarget", { state: addingFrom || "" }) })
13019
+ ] }),
13020
+ /* @__PURE__ */ jsxs(
13021
+ Box,
13022
+ {
13023
+ position: "relative",
13024
+ className: "rounded-container border border-border bg-background overflow-hidden",
13025
+ style: { width: GRAPH_W, height: GRAPH_H },
13026
+ children: [
13027
+ /* @__PURE__ */ jsxs(
13028
+ "svg",
13029
+ {
13030
+ width: GRAPH_W,
13031
+ height: GRAPH_H,
13032
+ className: "absolute inset-0",
13033
+ style: { pointerEvents: "none" },
13034
+ children: [
13035
+ /* @__PURE__ */ jsxs("defs", { children: [
13036
+ /* @__PURE__ */ jsx("marker", { id: "arrowhead", markerWidth: "10", markerHeight: "7", refX: "10", refY: "3.5", orient: "auto", children: /* @__PURE__ */ jsx("polygon", { points: "0 0, 10 3.5, 0 7", fill: "var(--color-border)" }) }),
13037
+ /* @__PURE__ */ jsx("marker", { id: "arrowhead-active", markerWidth: "10", markerHeight: "7", refX: "10", refY: "3.5", orient: "auto", children: /* @__PURE__ */ jsx("polygon", { points: "0 0, 10 3.5, 0 7", fill: "var(--color-primary)" }) })
13038
+ ] }),
13039
+ transitions.map((t2) => {
13040
+ const fromPos = positions[t2.from];
13041
+ const toPos = positions[t2.to];
13042
+ if (!fromPos || !toPos) return null;
13043
+ const isActive = t2.from === currentState;
13044
+ return /* @__PURE__ */ jsx(
13045
+ TransitionArrow,
13046
+ {
13047
+ from: fromPos,
13048
+ to: toPos,
13049
+ eventLabel: t2.event,
13050
+ guardHint: t2.guardHint,
13051
+ isActive
13052
+ },
13053
+ t2.id
13054
+ );
13055
+ })
13056
+ ]
13057
+ }
13058
+ ),
13059
+ entityStates.map((state) => /* @__PURE__ */ jsx(
13060
+ StateNode,
13061
+ {
13062
+ name: state,
13063
+ position: positions[state],
13064
+ isCurrent: state === currentState,
13065
+ isSelected: state === selectedState,
13066
+ isInitial: state === initialState,
13067
+ onClick: () => handleStateClick(state)
13068
+ },
13069
+ state
13070
+ ))
13071
+ ]
13072
+ }
13073
+ ),
13074
+ !isTesting && /* @__PURE__ */ jsx(HStack, { gap: "sm", children: /* @__PURE__ */ jsx(
13075
+ Button,
13076
+ {
13077
+ variant: "ghost",
13078
+ onClick: handleStartAddTransition,
13079
+ disabled: !selectedState,
13080
+ children: selectedState ? t("stateArchitect.addTransition", { state: selectedState }) : t("stateArchitect.addTransitionPrompt")
13081
+ }
13082
+ ) }),
13083
+ transitions.length > 0 && /* @__PURE__ */ jsxs(VStack, { gap: "xs", className: "p-3 rounded-container bg-muted/50 border border-border", children: [
13084
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground font-medium", children: t("stateArchitect.transitions", { count: transitions.length }) + ":" }),
13085
+ transitions.map((t2) => /* @__PURE__ */ jsxs(HStack, { className: "items-center text-xs", gap: "xs", children: [
13086
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-foreground", children: t2.from }),
13087
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground", children: "\u2014[" }),
13088
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-accent font-medium", children: t2.event }),
13089
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground", children: "]\u2192" }),
13090
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-success", children: t2.to }),
13091
+ t2.guardHint && /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "text-warning", children: [
13092
+ "(",
13093
+ t2.guardHint,
13094
+ ")"
13095
+ ] }),
13096
+ !isTesting && /* @__PURE__ */ jsx(
13097
+ Button,
13098
+ {
13099
+ variant: "ghost",
13100
+ onClick: () => handleRemoveTransition(t2.id),
13101
+ className: "text-xs ml-auto",
13102
+ children: "\xD7"
13103
+ }
13104
+ )
13105
+ ] }, t2.id))
13106
+ ] })
13107
+ ] }),
13108
+ /* @__PURE__ */ jsxs(VStack, { gap: "sm", className: "w-[280px] shrink-0", children: [
13109
+ /* @__PURE__ */ jsx(TraitStateViewer, { trait: machine, variant: "full", size: "sm" }),
13110
+ /* @__PURE__ */ jsx(
13111
+ VariablePanel,
13112
+ {
13113
+ entityName,
13114
+ variables
13115
+ }
13116
+ ),
13117
+ testResults.length > 0 && /* @__PURE__ */ jsxs(VStack, { className: "p-3 rounded-container bg-card border border-border", gap: "xs", children: [
13118
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground font-medium", children: t("stateArchitect.testResults") + ":" }),
13119
+ testResults.map((r, i) => /* @__PURE__ */ jsxs(HStack, { className: "items-center text-xs", gap: "xs", children: [
13120
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: r.passed ? "text-success" : "text-error", children: r.passed ? "\u2714" : "\u2717" }),
13121
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-foreground flex-1", children: r.label }),
13122
+ !r.passed && /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-error", children: t("stateArchitect.gotState", { state: r.actualState }) })
13123
+ ] }, i))
13124
+ ] }),
13125
+ resolved.showCodeView !== false && /* @__PURE__ */ jsx(StateJsonView, { data: codeData, label: "View Code" })
13126
+ ] })
13127
+ ] }),
13128
+ isSuccess && /* @__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: str(resolved.successMessage) || t("stateArchitect.allPassed") }) }),
13129
+ !isTesting && !isSuccess && testResults.some((r) => !r.passed) && /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
13130
+ /* @__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]) }) }),
13131
+ !isSuccess && attempts >= 2 && Boolean(str(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: [
13132
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-accent font-bold shrink-0", children: "\u{1F4A1} " + t("game.hint") + ":" }),
13133
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-foreground", children: hint })
13134
+ ] }) })
13135
+ ] }),
13136
+ /* @__PURE__ */ jsxs(HStack, { gap: "sm", children: [
13137
+ !isTesting && !isSuccess && testResults.some((r) => !r.passed) ? /* @__PURE__ */ jsx(Button, { variant: "primary", onClick: handleTryAgain, children: "\u{1F504} " + t("puzzle.tryAgainButton") }) : /* @__PURE__ */ jsx(
13138
+ Button,
13139
+ {
13140
+ variant: "primary",
13141
+ onClick: handleTest,
13142
+ disabled: isTesting,
13143
+ children: "\u25B6 " + t("game.runTests")
13144
+ }
13145
+ ),
13146
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: handleReset, children: "\u21BA " + t("game.reset") })
13147
+ ] })
13148
+ ]
13149
+ }
13150
+ );
13151
+ }
13152
+ var ENCOURAGEMENT_KEYS3, nextTransId;
13153
+ var init_StateArchitectBoard = __esm({
13154
+ "components/game/2d/organisms/StateArchitectBoard.tsx"() {
13155
+ init_atoms();
13156
+ init_cn();
13157
+ init_useEventBus();
13158
+ init_TraitStateViewer();
13159
+ init_StateNode();
13160
+ init_TransitionArrow();
13161
+ init_VariablePanel();
13162
+ init_StateJsonView();
13163
+ init_boardEntity();
13164
+ ENCOURAGEMENT_KEYS3 = [
13165
+ "puzzle.tryAgain1",
13166
+ "puzzle.tryAgain2",
13167
+ "puzzle.tryAgain3"
13168
+ ];
13169
+ nextTransId = 100;
13170
+ StateArchitectBoard.displayName = "StateArchitectBoard";
13171
+ }
13172
+ });
13173
+ function readSimulatorParameters(v) {
13174
+ if (!Array.isArray(v)) return [];
13175
+ const result = [];
13176
+ for (const item of v) {
13177
+ if (typeof item === "object" && item !== null && !Array.isArray(item) && !(item instanceof Date)) {
13178
+ const param = item;
13179
+ if ("id" in item && "label" in item && "unit" in item && "min" in item && "max" in item && "step" in item) {
13180
+ result.push({
13181
+ id: str(param.id),
13182
+ label: str(param.label),
13183
+ unit: str(param.unit),
13184
+ min: num(param.min),
13185
+ max: num(param.max),
13186
+ step: num(param.step),
13187
+ initial: num(param.initial),
13188
+ correct: num(param.correct),
13189
+ tolerance: num(param.tolerance)
13190
+ });
13191
+ }
13192
+ }
13193
+ }
13194
+ return result;
13195
+ }
13196
+ function SimulatorBoard({
13197
+ entity,
13198
+ completeEvent = "PUZZLE_COMPLETE",
13199
+ setAEvent,
13200
+ setBEvent,
13201
+ checkEvent,
13202
+ playAgainEvent,
13203
+ assetManifest,
13204
+ className
13205
+ }) {
13206
+ const ui = assetManifest?.ui;
13207
+ const { emit } = useEventBus();
13208
+ const { t } = useTranslate();
13209
+ const resolved = boardEntity(entity);
13210
+ const parameters = readSimulatorParameters(resolved?.parameters);
13211
+ const [headerError, setHeaderError] = useState(false);
13212
+ if (!resolved) return null;
13213
+ const paramA = num(resolved.paramA);
13214
+ const paramB = num(resolved.paramB);
13215
+ const output = num(resolved.output);
13216
+ const targetValue = num(resolved.target);
13217
+ const targetTolerance = num(resolved.tolerance);
13218
+ const attempts = num(resolved.attempts);
13219
+ const result = str(resolved.result);
13220
+ const isWin = result === "win";
13221
+ const isComplete = result !== "none" && result !== "";
13222
+ const paramAValue = parameters[0];
13223
+ const paramBValue = parameters[1];
13224
+ const sliderValues = [paramA, paramB];
13225
+ const sliderEvents = [setAEvent, setBEvent];
13226
+ const handleParameterChange = (index, value) => {
13227
+ if (isComplete) return;
13228
+ const ev = sliderEvents[index];
13229
+ if (ev) emit(`UI:${ev}`, { value });
13230
+ };
13231
+ const handleCheck = () => {
13232
+ if (checkEvent) emit(`UI:${checkEvent}`, {});
13233
+ };
13234
+ const handlePlayAgain = () => {
13235
+ if (playAgainEvent) emit(`UI:${playAgainEvent}`, {});
13236
+ };
13237
+ const themeBackground = (() => {
13238
+ const t2 = resolved.theme;
13239
+ if (typeof t2 === "object" && t2 !== null && !Array.isArray(t2) && !(t2 instanceof Date)) {
13240
+ const bg = t2.background;
13241
+ return str(bg);
13242
+ }
13243
+ return "";
13244
+ })();
13245
+ const headerImage = str(resolved.headerImage);
13246
+ const hint = str(resolved.hint);
13247
+ const showHint = isComplete && !isWin && attempts >= 2 && Boolean(hint);
13248
+ const outputLabel = str(resolved.outputLabel);
13249
+ const outputUnit = str(resolved.outputUnit);
13250
+ return /* @__PURE__ */ jsx(
13251
+ Box,
13252
+ {
13253
+ className,
13254
+ style: {
13255
+ backgroundImage: themeBackground ? `url(${themeBackground})` : void 0,
13256
+ backgroundSize: "cover",
13257
+ backgroundPosition: "center"
13258
+ },
13259
+ children: /* @__PURE__ */ jsxs(VStack, { gap: "lg", className: "p-4", children: [
13260
+ headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
13261
+ /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
13262
+ /* @__PURE__ */ jsx(Typography, { variant: "h4", weight: "bold", children: str(resolved.title) }),
13263
+ /* @__PURE__ */ jsx(Typography, { variant: "body", children: str(resolved.description) })
13264
+ ] }) }),
13265
+ /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "md", children: [
13266
+ /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "bold", className: "uppercase tracking-wider text-muted-foreground", children: t("simulator.parameters") }),
13267
+ [paramAValue, paramBValue].map(
13268
+ (param, index) => param ? /* @__PURE__ */ jsxs(VStack, { gap: "xs", children: [
13269
+ /* @__PURE__ */ jsxs(HStack, { justify: "between", align: "center", children: [
13270
+ /* @__PURE__ */ jsx(Typography, { variant: "body", weight: "medium", children: param.label }),
13271
+ /* @__PURE__ */ jsxs(Badge, { size: "sm", children: [
13272
+ sliderValues[index],
13273
+ " ",
13274
+ param.unit
13275
+ ] })
13276
+ ] }),
13277
+ /* @__PURE__ */ jsx(
13278
+ "input",
13279
+ {
13280
+ type: "range",
13281
+ min: param.min,
13282
+ max: param.max,
13283
+ step: param.step,
13284
+ value: sliderValues[index],
13285
+ onChange: (e) => handleParameterChange(index, Number(e.target.value)),
13286
+ disabled: isComplete,
13287
+ className: "w-full accent-foreground"
13288
+ }
13289
+ ),
13290
+ /* @__PURE__ */ jsxs(HStack, { justify: "between", children: [
13291
+ /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "text-muted-foreground", children: [
13292
+ param.min,
13293
+ " ",
13294
+ param.unit
13295
+ ] }),
13296
+ /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "text-muted-foreground", children: [
13297
+ param.max,
13298
+ " ",
13299
+ param.unit
13300
+ ] })
13301
+ ] })
13302
+ ] }, param.id ?? index) : null
13303
+ )
13304
+ ] }) }),
13305
+ /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", align: "center", children: [
13306
+ /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "bold", className: "uppercase tracking-wider text-muted-foreground", children: outputLabel }),
13307
+ /* @__PURE__ */ jsxs(Typography, { variant: "h3", weight: "bold", children: [
13308
+ output.toFixed(2),
13309
+ " ",
13310
+ outputUnit
13311
+ ] }),
13312
+ isComplete && /* @__PURE__ */ jsxs(HStack, { gap: "xs", align: "center", children: [
13313
+ /* @__PURE__ */ jsx(
13314
+ GameIcon,
13315
+ {
13316
+ icon: isWin ? CheckCircle : XCircle,
13317
+ assetUrl: isWin ? ui?.["correct"] : ui?.["incorrect"],
13318
+ size: "sm",
13319
+ className: isWin ? "text-success" : "text-error"
13320
+ }
13321
+ ),
13322
+ /* @__PURE__ */ jsx(Typography, { variant: "body", className: isWin ? "text-success" : "text-error", children: isWin ? str(resolved.successMessage) || t("simulator.correct") : str(resolved.failMessage) || t("simulator.incorrect") })
13323
+ ] }),
13324
+ /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "text-muted-foreground", children: [
13325
+ t("simulator.target"),
13326
+ ": ",
13327
+ targetValue,
13328
+ " ",
13329
+ outputUnit,
13330
+ " (\xB1",
13331
+ targetTolerance,
13332
+ ")"
13333
+ ] })
13334
+ ] }) }),
13335
+ showHint && hint && /* @__PURE__ */ jsx(Card, { className: "p-4 border-l-4 border-l-warning", children: /* @__PURE__ */ jsx(Typography, { variant: "body", children: hint }) }),
13336
+ /* @__PURE__ */ jsxs(HStack, { gap: "sm", justify: "center", children: [
13337
+ !isComplete ? /* @__PURE__ */ jsxs(Button, { variant: "primary", onClick: handleCheck, children: [
13338
+ /* @__PURE__ */ jsx(GameIcon, { icon: Play, assetUrl: ui?.["play"], size: "sm" }),
13339
+ t("simulator.simulate")
13340
+ ] }) : null,
13341
+ /* @__PURE__ */ jsxs(Button, { variant: "secondary", onClick: handlePlayAgain, children: [
13342
+ /* @__PURE__ */ jsx(GameIcon, { icon: RotateCcw, assetUrl: ui?.["reset"], size: "sm" }),
13343
+ t("simulator.reset")
13344
+ ] })
13345
+ ] })
13346
+ ] })
13347
+ }
13348
+ );
13349
+ }
13350
+ var init_SimulatorBoard = __esm({
13351
+ "components/game/2d/organisms/SimulatorBoard.tsx"() {
13352
+ init_atoms();
13353
+ init_useEventBus();
13354
+ init_boardEntity();
13355
+ init_GameIcon();
13356
+ SimulatorBoard.displayName = "SimulatorBoard";
13357
+ }
13358
+ });
13359
+ function ClassifierBoard({
13360
+ entity,
13361
+ completeEvent = "PUZZLE_COMPLETE",
13362
+ assignEvent,
13363
+ checkEvent,
13364
+ playAgainEvent,
13365
+ assetManifest,
13366
+ className
13367
+ }) {
13368
+ const ui = assetManifest?.ui;
13369
+ const { emit } = useEventBus();
13370
+ const { t } = useTranslate();
13371
+ const resolved = boardEntity(entity);
13372
+ const [headerError, setHeaderError] = useState(false);
13373
+ const items = rows(resolved?.items);
13374
+ const categories = rows(resolved?.categories);
13375
+ const result = str(resolved?.result);
13376
+ const submitted = result === "win";
13377
+ const attempts = num(resolved?.attempts);
13378
+ const assignments = items.reduce((acc, item) => {
13379
+ if (item.assignedCategory != null && item.assignedCategory !== "") acc[item.id] = item.assignedCategory;
13380
+ return acc;
13381
+ }, {});
13382
+ const unassignedItems = items.filter((item) => !assignments[item.id]);
13383
+ const allAssigned = items.length > 0 && Object.keys(assignments).length === items.length;
13384
+ const results = submitted ? items.map((item) => ({
13385
+ item,
13386
+ assigned: assignments[item.id],
13387
+ correct: assignments[item.id] === item.correctCategory
13388
+ })) : [];
13389
+ const allCorrect = result === "win";
13390
+ const correctCount = results.filter((r) => r.correct).length;
13391
+ const showHint = attempts >= 2 && Boolean(str(resolved?.hint));
13392
+ const handleAssign = (itemId, categoryId) => {
13393
+ if (submitted) return;
13394
+ if (assignEvent) emit(`UI:${assignEvent}`, { itemId, categoryId });
13395
+ };
13396
+ const handleUnassign = (itemId) => {
13397
+ if (submitted) return;
13398
+ if (assignEvent) emit(`UI:${assignEvent}`, { itemId, categoryId: "" });
13399
+ };
13400
+ const handleSubmit = () => {
13401
+ if (checkEvent) emit(`UI:${checkEvent}`, {});
13402
+ if (allAssigned && items.every((item) => assignments[item.id] === item.correctCategory)) {
13403
+ emit(`UI:${completeEvent}`, { success: true, attempts: attempts + 1 });
13404
+ }
13405
+ };
13406
+ const handleFullReset = () => {
13407
+ if (playAgainEvent) emit(`UI:${playAgainEvent}`, {});
13408
+ };
13409
+ if (!resolved) return null;
13410
+ const theme = resolved.theme ?? void 0;
13411
+ const themeBackground = theme?.background;
13412
+ const headerImage = str(resolved.headerImage);
13413
+ const hint = str(resolved.hint);
13414
+ const failMessage = str(resolved.failMessage);
13415
+ return /* @__PURE__ */ jsx(
13416
+ Box,
13417
+ {
13418
+ className,
13419
+ style: {
13420
+ backgroundImage: themeBackground ? `url(${themeBackground})` : void 0,
13421
+ backgroundSize: "cover",
13422
+ backgroundPosition: "center"
13423
+ },
13424
+ children: /* @__PURE__ */ jsxs(VStack, { gap: "lg", className: "p-4", children: [
13425
+ headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
13426
+ /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
13427
+ /* @__PURE__ */ jsx(Typography, { variant: "h4", weight: "bold", children: str(resolved.title) }),
13428
+ /* @__PURE__ */ jsx(Typography, { variant: "body", children: str(resolved.description) })
13429
+ ] }) }),
13430
+ unassignedItems.length > 0 && /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
13431
+ /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "bold", className: "uppercase tracking-wider text-muted-foreground", children: t("classifier.itemsToSort") }),
13432
+ /* @__PURE__ */ jsx(HStack, { gap: "sm", className: "flex-wrap", children: unassignedItems.map((item) => /* @__PURE__ */ jsxs(Badge, { size: "md", className: "cursor-pointer", children: [
13433
+ item.iconUrl && /* @__PURE__ */ jsx("img", { src: item.iconUrl, alt: "", className: "w-4 h-4 object-contain inline-block" }),
13434
+ item.label
13435
+ ] }, item.id)) })
13436
+ ] }) }),
13437
+ /* @__PURE__ */ jsx(VStack, { gap: "md", children: categories.map((cat) => {
13438
+ const catItems = items.filter((item) => assignments[item.id] === cat.id);
13439
+ return /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
13440
+ cat.imageUrl && /* @__PURE__ */ jsx(Box, { className: "w-full h-16 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: cat.imageUrl, alt: "", className: "w-full h-full object-cover" }) }),
13441
+ /* @__PURE__ */ jsxs(HStack, { justify: "between", align: "center", children: [
13442
+ /* @__PURE__ */ jsx(Typography, { variant: "body", weight: "bold", children: cat.label }),
13443
+ /* @__PURE__ */ jsx(Badge, { size: "sm", children: catItems.length })
13444
+ ] }),
13445
+ /* @__PURE__ */ jsx(HStack, { gap: "xs", className: "flex-wrap min-h-[2rem]", children: catItems.map((item) => {
13446
+ const result2 = results.find((r) => r.item.id === item.id);
13447
+ return /* @__PURE__ */ jsxs(
13448
+ Badge,
13449
+ {
13450
+ size: "sm",
13451
+ className: `cursor-pointer ${result2 ? result2.correct ? "border-success bg-success/10" : "border-error bg-error/10" : ""}`,
13452
+ onClick: () => handleUnassign(item.id),
13453
+ children: [
13454
+ item.iconUrl && /* @__PURE__ */ jsx("img", { src: item.iconUrl, alt: "", className: "w-3 h-3 object-contain inline-block" }),
13455
+ item.label,
13456
+ result2 && /* @__PURE__ */ jsx(
13457
+ GameIcon,
13458
+ {
13459
+ icon: result2.correct ? CheckCircle : XCircle,
13460
+ assetUrl: result2.correct ? ui?.["correct"] : ui?.["incorrect"],
13461
+ size: "sm",
13462
+ className: result2.correct ? "text-success" : "text-error"
13463
+ }
13464
+ )
13465
+ ]
13466
+ },
13467
+ item.id
13468
+ );
13469
+ }) }),
13470
+ !submitted && unassignedItems.length > 0 && /* @__PURE__ */ jsx(HStack, { gap: "xs", className: "flex-wrap", children: unassignedItems.map((item) => /* @__PURE__ */ jsxs(
13471
+ Button,
13472
+ {
13473
+ size: "sm",
13474
+ variant: "ghost",
13475
+ onClick: () => handleAssign(item.id, cat.id),
13476
+ className: "text-xs opacity-50 hover:opacity-100",
13477
+ children: [
13478
+ "+ ",
13479
+ item.label
13480
+ ]
13481
+ },
13482
+ item.id
13483
+ )) })
13484
+ ] }) }, cat.id);
13485
+ }) }),
13486
+ submitted && /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", align: "center", children: [
13487
+ /* @__PURE__ */ jsx(
13488
+ GameIcon,
13489
+ {
13490
+ icon: allCorrect ? CheckCircle : XCircle,
13491
+ assetUrl: allCorrect ? ui?.["correct"] : ui?.["incorrect"],
13492
+ size: "lg",
13493
+ className: allCorrect ? "text-success" : "text-error"
13494
+ }
13495
+ ),
13496
+ /* @__PURE__ */ jsx(Typography, { variant: "body", weight: "bold", children: allCorrect ? str(resolved.successMessage) || t("classifier.allCorrect") : `${correctCount}/${items.length} ${t("classifier.correct")}` }),
13497
+ !allCorrect && failMessage && /* @__PURE__ */ jsx(Typography, { variant: "body", className: "text-muted-foreground", children: failMessage })
13498
+ ] }) }),
13499
+ showHint && hint && /* @__PURE__ */ jsx(Card, { className: "p-4 border-l-4 border-l-warning", children: /* @__PURE__ */ jsx(Typography, { variant: "body", children: hint }) }),
13500
+ /* @__PURE__ */ jsxs(HStack, { gap: "sm", justify: "center", children: [
13501
+ !submitted && /* @__PURE__ */ jsxs(Button, { variant: "primary", onClick: handleSubmit, disabled: !allAssigned, children: [
13502
+ /* @__PURE__ */ jsx(GameIcon, { icon: Send, assetUrl: ui?.["send"], size: "sm" }),
13503
+ t("classifier.check")
13504
+ ] }),
13505
+ /* @__PURE__ */ jsxs(Button, { variant: "secondary", onClick: handleFullReset, children: [
13506
+ /* @__PURE__ */ jsx(GameIcon, { icon: RotateCcw, assetUrl: ui?.["reset"], size: "sm" }),
13507
+ t("classifier.reset")
13508
+ ] })
13509
+ ] })
13510
+ ] })
13511
+ }
13512
+ );
13513
+ }
13514
+ var init_ClassifierBoard = __esm({
13515
+ "components/game/2d/organisms/ClassifierBoard.tsx"() {
13516
+ init_atoms();
13517
+ init_useEventBus();
13518
+ init_boardEntity();
13519
+ init_GameIcon();
13520
+ ClassifierBoard.displayName = "ClassifierBoard";
13521
+ }
13522
+ });
13523
+ function BuilderBoard({
13524
+ entity,
13525
+ completeEvent = "PUZZLE_COMPLETE",
13526
+ placeEvent,
13527
+ checkEvent,
13528
+ playAgainEvent,
13529
+ assetManifest,
13530
+ className
13531
+ }) {
13532
+ const ui = assetManifest?.ui;
13533
+ const { emit } = useEventBus();
13534
+ const { t } = useTranslate();
13535
+ const resolved = boardEntity(entity);
13536
+ const [headerError, setHeaderError] = useState(false);
13537
+ const [selectedComponent, setSelectedComponent] = useState(null);
13538
+ const components = rows(resolved?.components).map((r) => ({
13539
+ id: str(r.id),
13540
+ label: str(r.label),
13541
+ description: str(r.description) || void 0,
13542
+ iconEmoji: str(r.iconEmoji) || void 0,
13543
+ iconUrl: str(r.iconUrl) || void 0,
13544
+ category: str(r.category) || void 0
13545
+ }));
13546
+ const slots = rows(resolved?.slots).map((r) => ({
13547
+ id: str(r.id),
13548
+ label: str(r.label) || void 0,
13549
+ description: str(r.description) || void 0,
13550
+ requiredComponentId: str(r.requiredComponentId),
13551
+ placedComponentId: str(r.placedComponentId) || void 0
13552
+ }));
13553
+ const placements = {};
13554
+ for (const slot of slots) {
13555
+ if (slot.placedComponentId) placements[slot.id] = slot.placedComponentId;
13556
+ }
13557
+ const attempts = num(resolved?.attempts);
13558
+ const result = str(resolved?.result) || "none";
13559
+ const submitted = result === "win";
13560
+ const usedComponentIds = new Set(Object.values(placements));
13561
+ const availableComponents = components.filter((c) => !usedComponentIds.has(c.id));
13562
+ const allPlaced = slots.length > 0 && slots.every((s) => Boolean(placements[s.id]));
13563
+ const results = submitted ? slots.map((slot) => ({
13564
+ slot,
13565
+ placed: placements[slot.id],
13566
+ correct: placements[slot.id] === slot.requiredComponentId
13567
+ })) : [];
13568
+ const showHint = attempts >= 2 && Boolean(str(resolved?.hint));
13569
+ const handlePlaceComponent = (slotId) => {
13570
+ if (submitted || !selectedComponent) return;
13571
+ if (placeEvent) emit(`UI:${placeEvent}`, { slotId, componentId: selectedComponent });
13572
+ setSelectedComponent(null);
13573
+ };
13574
+ const handleRemoveFromSlot = (slotId) => {
13575
+ if (submitted) return;
13576
+ if (placeEvent) emit(`UI:${placeEvent}`, { slotId, componentId: "" });
13577
+ };
13578
+ const handleSubmit = () => {
13579
+ if (checkEvent) emit(`UI:${checkEvent}`, {});
13580
+ const solved = slots.length > 0 && slots.every((s) => placements[s.id] === s.requiredComponentId);
13581
+ if (solved && completeEvent) {
13582
+ emit(`UI:${completeEvent}`, { success: true, attempts: attempts + 1 });
13583
+ }
13584
+ };
13585
+ const handlePlayAgain = () => {
13586
+ setSelectedComponent(null);
13587
+ if (playAgainEvent) emit(`UI:${playAgainEvent}`, {});
13588
+ };
13589
+ const getComponentById = (id) => components.find((c) => c.id === id);
13590
+ if (!resolved) return null;
13591
+ const theme = resolved.theme ?? void 0;
13592
+ const themeBackground = theme?.background;
13593
+ const headerImage = str(resolved.headerImage);
13594
+ const hint = str(resolved.hint);
13595
+ return /* @__PURE__ */ jsx(
13596
+ Box,
13597
+ {
13598
+ className,
13599
+ style: {
13600
+ backgroundImage: themeBackground ? `url(${themeBackground})` : void 0,
13601
+ backgroundSize: "cover",
13602
+ backgroundPosition: "center"
13603
+ },
13604
+ children: /* @__PURE__ */ jsxs(VStack, { gap: "lg", className: "p-4", children: [
13605
+ headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
13606
+ /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
13607
+ /* @__PURE__ */ jsx(Typography, { variant: "h4", weight: "bold", children: str(resolved.title) }),
13608
+ /* @__PURE__ */ jsx(Typography, { variant: "body", children: str(resolved.description) })
13609
+ ] }) }),
13610
+ /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
13611
+ /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "bold", className: "uppercase tracking-wider text-muted-foreground", children: t("builder.components") }),
13612
+ /* @__PURE__ */ jsxs(HStack, { gap: "sm", className: "flex-wrap", children: [
13613
+ availableComponents.map((comp) => /* @__PURE__ */ jsxs(
13614
+ Button,
13615
+ {
13616
+ size: "sm",
13617
+ variant: selectedComponent === comp.id ? "primary" : "secondary",
13618
+ onClick: () => setSelectedComponent(selectedComponent === comp.id ? null : comp.id),
13619
+ disabled: submitted,
13620
+ children: [
13621
+ comp.iconUrl ? /* @__PURE__ */ jsx("img", { src: comp.iconUrl, alt: "", className: "w-5 h-5 object-contain inline-block mr-1" }) : comp.iconEmoji ? /* @__PURE__ */ jsxs(Fragment, { children: [
13622
+ comp.iconEmoji,
13623
+ " "
13624
+ ] }) : null,
13625
+ comp.label
13626
+ ]
13627
+ },
13628
+ comp.id
13629
+ )),
13630
+ availableComponents.length === 0 && !submitted && /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground", children: t("builder.allPlaced") })
13631
+ ] })
13632
+ ] }) }),
13633
+ /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
13634
+ /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "bold", className: "uppercase tracking-wider text-muted-foreground", children: t("builder.blueprint") }),
13635
+ /* @__PURE__ */ jsx(VStack, { gap: "sm", children: slots.map((slot) => {
13636
+ const placedComp = placements[slot.id] ? getComponentById(placements[slot.id]) : null;
13637
+ const result2 = results.find((r) => r.slot.id === slot.id);
13638
+ return /* @__PURE__ */ jsxs(
13639
+ HStack,
13640
+ {
13641
+ gap: "sm",
13642
+ align: "center",
13643
+ className: `p-3 border-2 rounded ${result2 ? result2.correct ? "border-success" : "border-error" : selectedComponent ? "border-dashed border-foreground cursor-pointer" : "border-border"}`,
13644
+ onClick: () => handlePlaceComponent(slot.id),
13645
+ children: [
13646
+ /* @__PURE__ */ jsxs(VStack, { gap: "none", className: "flex-1", children: [
13647
+ /* @__PURE__ */ jsx(Typography, { variant: "body", weight: "medium", children: slot.label }),
13648
+ slot.description && /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground", children: slot.description })
13649
+ ] }),
13650
+ placedComp ? /* @__PURE__ */ jsxs(HStack, { gap: "xs", align: "center", children: [
13651
+ /* @__PURE__ */ jsxs(Badge, { size: "sm", onClick: () => handleRemoveFromSlot(slot.id), children: [
13652
+ placedComp.iconUrl ? /* @__PURE__ */ jsx("img", { src: placedComp.iconUrl, alt: "", className: "w-4 h-4 object-contain inline-block mr-1" }) : placedComp.iconEmoji ? /* @__PURE__ */ jsxs(Fragment, { children: [
13653
+ placedComp.iconEmoji,
13654
+ " "
13655
+ ] }) : null,
13656
+ placedComp.label
13657
+ ] }),
13658
+ result2 && /* @__PURE__ */ jsx(
13659
+ GameIcon,
13660
+ {
13661
+ icon: result2.correct ? CheckCircle : XCircle,
13662
+ assetUrl: result2.correct ? ui?.["correct"] : ui?.["incorrect"],
13663
+ size: "sm",
13664
+ className: result2.correct ? "text-success" : "text-error"
13665
+ }
13666
+ )
13667
+ ] }) : /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground", children: t("builder.empty") })
13668
+ ]
13669
+ },
13670
+ slot.id
13671
+ );
13672
+ }) })
13673
+ ] }) }),
13674
+ submitted && /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", align: "center", children: [
13675
+ /* @__PURE__ */ jsx(GameIcon, { icon: CheckCircle, assetUrl: ui?.["correct"], size: "lg", className: "text-success" }),
13676
+ /* @__PURE__ */ jsx(Typography, { variant: "body", weight: "bold", children: str(resolved.successMessage) || t("builder.success") })
13677
+ ] }) }),
13678
+ showHint && hint && /* @__PURE__ */ jsx(Card, { className: "p-4 border-l-4 border-l-warning", children: /* @__PURE__ */ jsx(Typography, { variant: "body", children: hint }) }),
13679
+ /* @__PURE__ */ jsxs(HStack, { gap: "sm", justify: "center", children: [
13680
+ !submitted && /* @__PURE__ */ jsxs(Button, { variant: "primary", onClick: handleSubmit, disabled: !allPlaced, children: [
13681
+ /* @__PURE__ */ jsx(GameIcon, { icon: Wrench, assetUrl: ui?.["build"], size: "sm" }),
13682
+ t("builder.build")
13683
+ ] }),
13684
+ /* @__PURE__ */ jsxs(Button, { variant: "secondary", onClick: handlePlayAgain, children: [
13685
+ /* @__PURE__ */ jsx(GameIcon, { icon: RotateCcw, assetUrl: ui?.["reset"], size: "sm" }),
13686
+ t("builder.reset")
13687
+ ] })
13688
+ ] })
13689
+ ] })
13690
+ }
13691
+ );
13692
+ }
13693
+ var init_BuilderBoard = __esm({
13694
+ "components/game/2d/organisms/BuilderBoard.tsx"() {
13695
+ init_atoms();
13696
+ init_useEventBus();
13697
+ init_boardEntity();
13698
+ init_GameIcon();
13699
+ BuilderBoard.displayName = "BuilderBoard";
13700
+ }
13701
+ });
13702
+ function toDebuggerLine(v) {
13703
+ if (v === null || typeof v !== "object" || Array.isArray(v) || v instanceof Date) return null;
13704
+ const id = v["id"];
13705
+ const content = v["content"];
13706
+ const isBug = v["isBug"];
13707
+ if (typeof id !== "string" || typeof content !== "string" || typeof isBug !== "boolean") return null;
13708
+ const isFlagged = v["isFlagged"];
13709
+ const explanation = v["explanation"];
13710
+ return {
13711
+ id,
13712
+ content,
13713
+ isBug,
13714
+ isFlagged: typeof isFlagged === "boolean" ? isFlagged : void 0,
13715
+ explanation: typeof explanation === "string" ? explanation : void 0
13716
+ };
13717
+ }
13718
+ function DebuggerBoard({
13719
+ entity,
13720
+ completeEvent = "PUZZLE_COMPLETE",
13721
+ toggleFlagEvent,
13722
+ checkEvent,
13723
+ playAgainEvent,
13724
+ assetManifest,
13725
+ className
13726
+ }) {
13727
+ const ui = assetManifest?.ui;
13728
+ const { emit } = useEventBus();
13729
+ const { t } = useTranslate();
13730
+ const resolved = boardEntity(entity);
13731
+ const [headerError, setHeaderError] = useState(false);
13732
+ const lines = Array.isArray(resolved?.lines) ? resolved.lines.flatMap((v) => {
13733
+ const l = toDebuggerLine(v);
13734
+ return l ? [l] : [];
13735
+ }) : [];
13736
+ const result = str(resolved?.result) || "none";
13737
+ const attempts = num(resolved?.attempts);
13738
+ const submitted = result === "win";
13739
+ const showHint = !submitted && attempts >= 2 && Boolean(str(resolved?.hint));
13740
+ const bugLines = lines.filter((l) => l.isBug);
13741
+ const flaggedLines = lines.filter((l) => l.isFlagged);
13742
+ const correctFlags = lines.filter((l) => l.isBug && l.isFlagged);
13743
+ const falseFlags = lines.filter((l) => !l.isBug && l.isFlagged);
13744
+ const allCorrect = submitted;
13745
+ const toggleLine = (lineId) => {
13746
+ if (submitted) return;
13747
+ if (toggleFlagEvent) emit(`UI:${toggleFlagEvent}`, { lineId });
13748
+ };
13749
+ const handleSubmit = useCallback(() => {
13750
+ if (checkEvent) emit(`UI:${checkEvent}`, {});
13751
+ const correct = correctFlags.length === bugLines.length && falseFlags.length === 0;
13752
+ if (correct) emit(`UI:${completeEvent}`, { success: true, attempts: attempts + 1 });
13753
+ }, [checkEvent, correctFlags.length, bugLines.length, falseFlags.length, attempts, completeEvent, emit]);
13754
+ const handleReset = () => {
13755
+ if (playAgainEvent) emit(`UI:${playAgainEvent}`, {});
13756
+ };
13757
+ if (!resolved) return null;
13758
+ const theme = resolved.theme ?? void 0;
13759
+ const themeBackground = theme?.background;
13760
+ const headerImage = str(resolved.headerImage);
13761
+ const hint = str(resolved.hint);
13762
+ return /* @__PURE__ */ jsx(
13763
+ Box,
13764
+ {
13765
+ className,
13766
+ style: {
13767
+ backgroundImage: themeBackground ? `url(${themeBackground})` : void 0,
13768
+ backgroundSize: "cover",
13769
+ backgroundPosition: "center"
13770
+ },
13771
+ children: /* @__PURE__ */ jsxs(VStack, { gap: "lg", className: "p-4", children: [
13772
+ headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
13773
+ /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
13774
+ /* @__PURE__ */ jsxs(HStack, { gap: "xs", align: "center", children: [
13775
+ /* @__PURE__ */ jsx(GameIcon, { icon: Bug, assetUrl: ui?.["bug"], size: "sm" }),
13776
+ /* @__PURE__ */ jsx(Typography, { variant: "h4", weight: "bold", children: str(resolved.title) })
13777
+ ] }),
13778
+ /* @__PURE__ */ jsx(Typography, { variant: "body", children: str(resolved.description) }),
13779
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground", children: t("debugger.findBugs", { count: String(lines.filter((l) => l.isBug).length) }) })
13780
+ ] }) }),
13781
+ /* @__PURE__ */ jsx(Card, { className: "p-0 overflow-hidden", children: /* @__PURE__ */ jsx(VStack, { gap: "none", children: lines.map((line, i) => {
13782
+ const isFlagged = !!line.isFlagged;
13783
+ let lineStyle = "";
13784
+ if (submitted) {
13785
+ if (line.isBug && isFlagged) lineStyle = "bg-success/10";
13786
+ else if (line.isBug && !isFlagged) lineStyle = "bg-warning/10";
13787
+ else if (!line.isBug && isFlagged) lineStyle = "bg-error/10";
13788
+ } else if (isFlagged) {
13789
+ lineStyle = "bg-error/10";
13790
+ }
13791
+ return /* @__PURE__ */ jsxs(
13792
+ HStack,
13793
+ {
13794
+ gap: "none",
13795
+ align: "stretch",
13796
+ className: `border-b border-border cursor-pointer hover:bg-muted ${lineStyle}`,
13797
+ onClick: () => toggleLine(line.id),
13798
+ children: [
13799
+ /* @__PURE__ */ jsx(Box, { className: "w-10 flex-shrink-0 flex items-center justify-center border-r border-border text-muted-foreground", children: /* @__PURE__ */ jsx(Typography, { variant: "caption", children: i + 1 }) }),
13800
+ /* @__PURE__ */ jsx(Box, { className: "flex-1 px-3 py-1.5 font-mono text-sm whitespace-pre", children: /* @__PURE__ */ jsx(Typography, { variant: "body", className: "font-mono text-sm", children: line.content }) }),
13801
+ /* @__PURE__ */ jsxs(Box, { className: "w-8 flex-shrink-0 flex items-center justify-center", children: [
13802
+ isFlagged && /* @__PURE__ */ jsx(GameIcon, { icon: Bug, assetUrl: ui?.["bug"], size: "sm", className: "text-error" }),
13803
+ submitted && line.isBug && !isFlagged && /* @__PURE__ */ jsx(GameIcon, { icon: Bug, assetUrl: ui?.["bug"], size: "sm", className: "text-warning" })
13804
+ ] })
13805
+ ]
13806
+ },
13807
+ line.id
13808
+ );
13809
+ }) }) }),
13810
+ submitted && /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
13811
+ /* @__PURE__ */ jsx(Typography, { variant: "body", weight: "bold", children: allCorrect ? str(resolved.successMessage) || t("debugger.allFound") : `${correctFlags.length}/${bugLines.length} ${t("debugger.bugsFound")}` }),
13812
+ bugLines.map((line) => /* @__PURE__ */ jsxs(HStack, { gap: "xs", align: "start", children: [
13813
+ /* @__PURE__ */ jsx(
13814
+ GameIcon,
13815
+ {
13816
+ icon: line.isFlagged ? CheckCircle : XCircle,
13817
+ assetUrl: line.isFlagged ? ui?.["correct"] : ui?.["incorrect"],
13818
+ size: "sm",
13819
+ className: line.isFlagged ? "text-success mt-0.5" : "text-warning mt-0.5"
13820
+ }
13821
+ ),
13822
+ /* @__PURE__ */ jsxs(VStack, { gap: "none", children: [
13823
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", weight: "bold", className: "font-mono", children: line.content.trim() }),
13824
+ line.explanation && /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground", children: line.explanation })
13825
+ ] })
13826
+ ] }, line.id))
13827
+ ] }) }),
13828
+ showHint && hint && /* @__PURE__ */ jsx(Card, { className: "p-4 border-l-4 border-l-warning", children: /* @__PURE__ */ jsx(Typography, { variant: "body", children: hint }) }),
13829
+ /* @__PURE__ */ jsxs(HStack, { gap: "sm", justify: "center", children: [
13830
+ !submitted && /* @__PURE__ */ jsxs(Button, { variant: "primary", onClick: handleSubmit, disabled: flaggedLines.length === 0, children: [
13831
+ /* @__PURE__ */ jsx(GameIcon, { icon: Send, assetUrl: ui?.["send"], size: "sm" }),
13832
+ t("debugger.submit")
13833
+ ] }),
13834
+ /* @__PURE__ */ jsxs(Button, { variant: "secondary", onClick: handleReset, children: [
13835
+ /* @__PURE__ */ jsx(GameIcon, { icon: RotateCcw, assetUrl: ui?.["reset"], size: "sm" }),
13836
+ t("debugger.reset")
13837
+ ] })
13838
+ ] })
13839
+ ] })
13840
+ }
13841
+ );
13842
+ }
13843
+ var init_DebuggerBoard = __esm({
13844
+ "components/game/2d/organisms/DebuggerBoard.tsx"() {
13845
+ init_atoms();
13846
+ init_useEventBus();
13847
+ init_boardEntity();
13848
+ init_GameIcon();
13849
+ DebuggerBoard.displayName = "DebuggerBoard";
13850
+ }
13851
+ });
13852
+ function NegotiatorBoard({
13853
+ entity,
13854
+ completeEvent = "PUZZLE_COMPLETE",
13855
+ playRoundEvent,
13856
+ finishEvent,
13857
+ playAgainEvent,
13858
+ assetManifest,
13859
+ className
13860
+ }) {
13861
+ const ui = assetManifest?.ui;
13862
+ const { emit } = useEventBus();
13863
+ const { t } = useTranslate();
13864
+ const resolved = boardEntity(entity);
13865
+ const [history, setHistory] = useState([]);
13866
+ const [headerError, setHeaderError] = useState(false);
13867
+ const [showHint, setShowHint] = useState(false);
13868
+ const totalRounds = num(resolved?.maxRounds);
13869
+ const targetScore = num(resolved?.targetScore);
13870
+ const currentRound = num(resolved?.round);
13871
+ const result = str(resolved?.result) || "none";
13872
+ const playerTotal = num(resolved?.score);
13873
+ const isComplete = result !== "none" || totalRounds > 0 && currentRound >= totalRounds;
13874
+ const won = result === "win";
13875
+ const lastPlayerAction = str(resolved?.lastPlayerAction);
13876
+ const lastOpponentAction = str(resolved?.lastOpponentAction);
13877
+ const lastPayoff = num(resolved?.lastPayoff);
13878
+ const actions = Array.isArray(resolved?.actions) ? resolved.actions.flatMap((item) => {
13879
+ if (item !== null && typeof item === "object" && !Array.isArray(item) && !(item instanceof Date) && typeof item.id === "string" && typeof item.label === "string")
13880
+ return [{ id: item.id, label: item.label, description: typeof item.description === "string" ? item.description : void 0 }];
13881
+ return [];
13882
+ }) : [];
13883
+ const payoffMatrix = Array.isArray(resolved?.payoffMatrix) ? resolved.payoffMatrix.flatMap((item) => {
13884
+ if (item !== null && typeof item === "object" && !Array.isArray(item) && !(item instanceof Date) && typeof item.playerAction === "string" && typeof item.opponentAction === "string")
13885
+ return [{ playerAction: item.playerAction, opponentAction: item.opponentAction, playerPayoff: typeof item.playerPayoff === "number" ? item.playerPayoff : 0, opponentPayoff: typeof item.opponentPayoff === "number" ? item.opponentPayoff : 0 }];
13886
+ return [];
13887
+ }) : [];
13888
+ const prevRoundRef = useRef(currentRound);
13889
+ useEffect(() => {
13890
+ if (currentRound > prevRoundRef.current && lastPlayerAction) {
13891
+ const opponentPayoffEntry = payoffMatrix.find(
13892
+ (p) => p.playerAction === lastPlayerAction && p.opponentAction === lastOpponentAction
13893
+ );
13894
+ setHistory((prev) => [
13895
+ ...prev,
13896
+ {
13897
+ round: currentRound,
13898
+ playerAction: lastPlayerAction,
13899
+ opponentAction: lastOpponentAction,
13900
+ playerPayoff: lastPayoff,
13901
+ opponentPayoff: opponentPayoffEntry?.opponentPayoff ?? 0
13902
+ }
13903
+ ]);
13904
+ }
13905
+ prevRoundRef.current = currentRound;
13906
+ }, [currentRound, lastPlayerAction, lastOpponentAction, lastPayoff, payoffMatrix]);
13907
+ const opponentTotal = useMemo(() => history.reduce((s, r) => s + r.opponentPayoff, 0), [history]);
13908
+ const handleAction = useCallback((actionId) => {
13909
+ if (isComplete) return;
13910
+ if (playRoundEvent) {
13911
+ emit(`UI:${playRoundEvent}`, { playerAction: actionId, payoff: 0 });
13912
+ }
13913
+ if (totalRounds > 0 && currentRound + 1 >= totalRounds) {
13914
+ if (finishEvent) {
13915
+ emit(`UI:${finishEvent}`, {});
13916
+ }
13917
+ if (str(resolved?.hint)) {
13918
+ setShowHint(true);
13919
+ }
13920
+ }
13921
+ }, [isComplete, resolved, totalRounds, currentRound, playRoundEvent, finishEvent, emit]);
13922
+ const handleReset = useCallback(() => {
13923
+ setHistory([]);
13924
+ setShowHint(false);
13925
+ prevRoundRef.current = 0;
13926
+ if (playAgainEvent) {
13927
+ emit(`UI:${playAgainEvent}`, {});
13928
+ }
13929
+ }, [playAgainEvent, emit]);
13930
+ const completedRef = useRef(false);
13931
+ useEffect(() => {
13932
+ if (result === "win" && !completedRef.current) {
13933
+ completedRef.current = true;
13934
+ emit(`UI:${completeEvent}`, { success: true, score: playerTotal });
13935
+ } else if (result === "none") {
13936
+ completedRef.current = false;
13937
+ }
13938
+ }, [result, playerTotal, completeEvent, emit]);
13939
+ const getActionLabel = (id) => actions.find((a) => a.id === id)?.label ?? id;
13940
+ if (!resolved) return null;
13941
+ const theme = resolved.theme ?? void 0;
13942
+ const themeBackground = theme?.background;
13943
+ const headerImage = str(resolved.headerImage);
13944
+ const hint = str(resolved.hint);
13945
+ return /* @__PURE__ */ jsx(
13946
+ Box,
13947
+ {
13948
+ className,
13949
+ style: {
13950
+ backgroundImage: themeBackground ? `url(${themeBackground})` : void 0,
13951
+ backgroundSize: "cover",
13952
+ backgroundPosition: "center"
13953
+ },
13954
+ children: /* @__PURE__ */ jsxs(VStack, { gap: "lg", className: "p-4", children: [
13955
+ headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
13956
+ /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
13957
+ /* @__PURE__ */ jsx(Typography, { variant: "h4", weight: "bold", children: str(resolved.title) }),
13958
+ /* @__PURE__ */ jsx(Typography, { variant: "body", children: str(resolved.description) }),
13959
+ /* @__PURE__ */ jsxs(HStack, { gap: "md", children: [
13960
+ /* @__PURE__ */ jsx(Badge, { size: "sm", children: t("negotiator.round", { current: String(currentRound), total: String(totalRounds) }) }),
13961
+ /* @__PURE__ */ jsxs(Badge, { size: "sm", children: [
13962
+ t("negotiator.target"),
13963
+ ": ",
13964
+ targetScore
13965
+ ] })
13966
+ ] })
13967
+ ] }) }),
13968
+ /* @__PURE__ */ jsxs(HStack, { gap: "md", justify: "center", children: [
13969
+ /* @__PURE__ */ jsx(Card, { className: "p-4 flex-1 text-center", children: /* @__PURE__ */ jsxs(VStack, { gap: "xs", align: "center", children: [
13970
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground", children: t("negotiator.you") }),
13971
+ /* @__PURE__ */ jsx(Typography, { variant: "h3", weight: "bold", children: playerTotal })
13972
+ ] }) }),
13973
+ /* @__PURE__ */ jsx(Card, { className: "p-4 flex-1 text-center", children: /* @__PURE__ */ jsxs(VStack, { gap: "xs", align: "center", children: [
13974
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground", children: t("negotiator.opponent") }),
13975
+ /* @__PURE__ */ jsx(Typography, { variant: "h3", weight: "bold", children: opponentTotal })
13976
+ ] }) })
13977
+ ] }),
13978
+ !isComplete && /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
13979
+ /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "bold", className: "uppercase tracking-wider text-muted-foreground", children: t("negotiator.chooseAction") }),
13980
+ /* @__PURE__ */ jsx(HStack, { gap: "sm", justify: "center", className: "flex-wrap", children: actions.map((action) => /* @__PURE__ */ jsx(
13981
+ Button,
13982
+ {
13983
+ variant: "primary",
13984
+ onClick: () => handleAction(action.id),
13985
+ children: action.label
13986
+ },
13987
+ action.id
13988
+ )) })
13989
+ ] }) }),
13990
+ history.length > 0 && /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
13991
+ /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "bold", className: "uppercase tracking-wider text-muted-foreground", children: t("negotiator.history") }),
13992
+ history.map((round) => /* @__PURE__ */ jsxs(HStack, { gap: "sm", align: "center", className: "text-sm", children: [
13993
+ /* @__PURE__ */ jsxs(Badge, { size: "sm", children: [
13994
+ "R",
13995
+ round.round
13996
+ ] }),
13997
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", children: getActionLabel(round.playerAction) }),
13998
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground", children: "vs" }),
13999
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", children: getActionLabel(round.opponentAction) }),
14000
+ /* @__PURE__ */ jsx(GameIcon, { icon: ArrowRight, assetUrl: ui?.["arrow"], size: "sm" }),
14001
+ /* @__PURE__ */ jsxs(Typography, { variant: "caption", weight: "bold", className: "text-success", children: [
14002
+ "+",
14003
+ round.playerPayoff
14004
+ ] }),
14005
+ /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "text-muted-foreground", children: [
14006
+ "/ +",
14007
+ round.opponentPayoff
14008
+ ] })
14009
+ ] }, round.round))
14010
+ ] }) }),
14011
+ isComplete && /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", align: "center", children: [
14012
+ /* @__PURE__ */ jsx(GameIcon, { icon: CheckCircle, assetUrl: ui?.["correct"], size: "lg", className: won ? "text-success" : "text-error" }),
14013
+ /* @__PURE__ */ jsx(Typography, { variant: "body", weight: "bold", children: won ? str(resolved.successMessage) || t("negotiator.success") : str(resolved.failMessage) || t("negotiator.failed") }),
14014
+ /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "text-muted-foreground", children: [
14015
+ t("negotiator.finalScore"),
14016
+ ": ",
14017
+ playerTotal,
14018
+ "/",
14019
+ targetScore
14020
+ ] })
14021
+ ] }) }),
14022
+ showHint && hint && !won && /* @__PURE__ */ jsx(Card, { className: "p-4 border-l-4 border-l-warning", children: /* @__PURE__ */ jsx(Typography, { variant: "body", children: hint }) }),
14023
+ isComplete && !won && /* @__PURE__ */ jsx(HStack, { justify: "center", children: /* @__PURE__ */ jsx(Button, { variant: "primary", onClick: handleReset, children: t("negotiator.playAgain") }) })
14024
+ ] })
14025
+ }
14026
+ );
14027
+ }
14028
+ var init_NegotiatorBoard = __esm({
14029
+ "components/game/2d/organisms/NegotiatorBoard.tsx"() {
14030
+ init_atoms();
14031
+ init_useEventBus();
14032
+ init_boardEntity();
14033
+ init_GameIcon();
14034
+ NegotiatorBoard.displayName = "NegotiatorBoard";
14035
+ }
14036
+ });
11954
14037
 
11955
14038
  // components/game/shared/lib/mechanics.ts
11956
14039
  var projectileMotion, pendulum, springOscillator;
@@ -12158,7 +14241,7 @@ function SimulationCanvas({
12158
14241
  }
12159
14242
  var PRESET_BY_ID;
12160
14243
  var init_SimulationCanvas = __esm({
12161
- "components/game/2d/molecules/SimulationCanvas.tsx"() {
14244
+ "components/game/2d/organisms/SimulationCanvas.tsx"() {
12162
14245
  init_cn();
12163
14246
  init_atoms();
12164
14247
  init_verificationRegistry();
@@ -12780,7 +14863,7 @@ var init_ErrorBoundary = __esm({
12780
14863
  }
12781
14864
  );
12782
14865
  };
12783
- ErrorBoundary = class extends React84__default.Component {
14866
+ ErrorBoundary = class extends React95__default.Component {
12784
14867
  constructor(props) {
12785
14868
  super(props);
12786
14869
  __publicField(this, "reset", () => {
@@ -12825,15 +14908,15 @@ function HeaderSkeleton({ className }) {
12825
14908
  ] })
12826
14909
  ] });
12827
14910
  }
12828
- function TableSkeleton({ rows = 5, columns = 4, className }) {
14911
+ function TableSkeleton({ rows: rows2 = 5, columns = 4, className }) {
12829
14912
  return /* @__PURE__ */ jsxs(VStack, { gap: "none", className: cn("border border-border rounded-lg overflow-hidden", className), children: [
12830
14913
  /* @__PURE__ */ jsx(HStack, { className: "px-4 py-3 bg-muted/30 border-b border-border", children: Array.from({ length: columns }).map((_, i) => /* @__PURE__ */ jsx(SkeletonBlock, { className: "h-4 flex-1 mx-2" }, i)) }),
12831
- Array.from({ length: rows }).map((_, rowIdx) => /* @__PURE__ */ jsx(
14914
+ Array.from({ length: rows2 }).map((_, rowIdx) => /* @__PURE__ */ jsx(
12832
14915
  HStack,
12833
14916
  {
12834
14917
  className: cn(
12835
14918
  "px-4 py-3",
12836
- rowIdx < rows - 1 && "border-b border-border"
14919
+ rowIdx < rows2 - 1 && "border-b border-border"
12837
14920
  ),
12838
14921
  children: Array.from({ length: columns }).map((_2, colIdx) => /* @__PURE__ */ jsx(SkeletonLine, { className: "flex-1 mx-2" }, colIdx))
12839
14922
  },
@@ -12881,18 +14964,18 @@ function CardSkeleton({ className }) {
12881
14964
  }
12882
14965
  );
12883
14966
  }
12884
- function TextSkeleton({ rows = 3, className }) {
12885
- return /* @__PURE__ */ jsx(VStack, { gap: "sm", className, children: Array.from({ length: rows }).map((_, i) => /* @__PURE__ */ jsx(
14967
+ function TextSkeleton({ rows: rows2 = 3, className }) {
14968
+ return /* @__PURE__ */ jsx(VStack, { gap: "sm", className, children: Array.from({ length: rows2 }).map((_, i) => /* @__PURE__ */ jsx(
12886
14969
  SkeletonLine,
12887
14970
  {
12888
- className: i === rows - 1 ? "w-2/3" : "w-full"
14971
+ className: i === rows2 - 1 ? "w-2/3" : "w-full"
12889
14972
  },
12890
14973
  i
12891
14974
  )) });
12892
14975
  }
12893
14976
  function Skeleton({
12894
14977
  variant = "text",
12895
- rows,
14978
+ rows: rows2,
12896
14979
  columns,
12897
14980
  fields,
12898
14981
  className
@@ -12902,15 +14985,15 @@ function Skeleton({
12902
14985
  case "header":
12903
14986
  return /* @__PURE__ */ jsx(HeaderSkeleton, { className });
12904
14987
  case "table":
12905
- return /* @__PURE__ */ jsx(TableSkeleton, { rows, columns, className });
14988
+ return /* @__PURE__ */ jsx(TableSkeleton, { rows: rows2, columns, className });
12906
14989
  case "form":
12907
14990
  return /* @__PURE__ */ jsx(FormSkeleton, { fields, className });
12908
14991
  case "card":
12909
14992
  return /* @__PURE__ */ jsx(CardSkeleton, { className });
12910
14993
  case "text":
12911
- return /* @__PURE__ */ jsx(TextSkeleton, { rows, className });
14994
+ return /* @__PURE__ */ jsx(TextSkeleton, { rows: rows2, className });
12912
14995
  default:
12913
- return /* @__PURE__ */ jsx(TextSkeleton, { rows, className });
14996
+ return /* @__PURE__ */ jsx(TextSkeleton, { rows: rows2, className });
12914
14997
  }
12915
14998
  }
12916
14999
  var pulseClass;
@@ -13062,7 +15145,7 @@ var init_Container = __esm({
13062
15145
  as: Component = "div"
13063
15146
  }) => {
13064
15147
  const resolvedSize = maxWidth ?? size ?? "lg";
13065
- return React84__default.createElement(
15148
+ return React95__default.createElement(
13066
15149
  Component,
13067
15150
  {
13068
15151
  className: cn(
@@ -15730,7 +17813,7 @@ var init_CodeBlock = __esm({
15730
17813
  DIFF_STYLE_FALLBACK = { bg: "", prefix: " ", text: "text-foreground" };
15731
17814
  LINE_PROPS_FN = (n) => ({ "data-line": String(n - 1) });
15732
17815
  HIDDEN_LINE_NUMBERS = { display: "none" };
15733
- CodeBlock = React84__default.memo(
17816
+ CodeBlock = React95__default.memo(
15734
17817
  ({
15735
17818
  code: rawCode,
15736
17819
  language = "text",
@@ -15899,24 +17982,24 @@ var init_CodeBlock = __esm({
15899
17982
  return;
15900
17983
  }
15901
17984
  lineEls.forEach((el) => {
15902
- const num = parseInt(el.getAttribute("data-line") ?? "-1", 10);
15903
- if (hiddenLines.has(num)) {
17985
+ const num2 = parseInt(el.getAttribute("data-line") ?? "-1", 10);
17986
+ if (hiddenLines.has(num2)) {
15904
17987
  el.style.display = "none";
15905
17988
  return;
15906
17989
  }
15907
17990
  el.style.display = "";
15908
17991
  el.style.position = "relative";
15909
17992
  el.style.paddingLeft = "1.2em";
15910
- const region = foldStartMap.get(num);
17993
+ const region = foldStartMap.get(num2);
15911
17994
  if (!region) return;
15912
- const isCollapsed = collapsed.has(num);
17995
+ const isCollapsed = collapsed.has(num2);
15913
17996
  const toggle = document.createElement("span");
15914
17997
  toggle.className = "fold-toggle";
15915
17998
  toggle.textContent = isCollapsed ? "\u25B6" : "\u25BC";
15916
17999
  toggle.style.cssText = "position:absolute;left:0;top:0;width:1.2em;text-align:center;cursor:pointer;color:#858585;font-size:10px;user-select:none;line-height:inherit;height:100%";
15917
18000
  toggle.addEventListener("click", (e) => {
15918
18001
  e.stopPropagation();
15919
- toggleFoldRef.current(num);
18002
+ toggleFoldRef.current(num2);
15920
18003
  });
15921
18004
  el.insertBefore(toggle, el.firstChild);
15922
18005
  if (isCollapsed) {
@@ -16317,7 +18400,7 @@ var init_MarkdownContent = __esm({
16317
18400
  init_Box();
16318
18401
  init_CodeBlock();
16319
18402
  init_cn();
16320
- MarkdownContent = React84__default.memo(
18403
+ MarkdownContent = React95__default.memo(
16321
18404
  ({ content, direction = "ltr", className }) => {
16322
18405
  const { t: _t } = useTranslate();
16323
18406
  const safeContent = typeof content === "string" ? content : String(content ?? "");
@@ -16836,7 +18919,7 @@ var init_QuizBlock = __esm({
16836
18919
  QuizBlock.displayName = "QuizBlock";
16837
18920
  }
16838
18921
  });
16839
- var StateNode, TransitionBundleArrow, BundleTooltip, EntityBox, OutputsBox, Legend, StateMachineView;
18922
+ var StateNode2, TransitionBundleArrow, BundleTooltip, EntityBox, OutputsBox, Legend, StateMachineView;
16840
18923
  var init_StateMachineView = __esm({
16841
18924
  "components/core/organisms/StateMachineView.tsx"() {
16842
18925
  "use client";
@@ -16848,7 +18931,7 @@ var init_StateMachineView = __esm({
16848
18931
  init_Icon();
16849
18932
  init_useEventBus();
16850
18933
  init_cn();
16851
- StateNode = ({ state, config }) => {
18934
+ StateNode2 = ({ state, config }) => {
16852
18935
  const { t } = useTranslate();
16853
18936
  const size = state.radius * 2;
16854
18937
  let borderColor = config.colors.nodeBorder;
@@ -17594,8 +19677,8 @@ var init_StateMachineView = __esm({
17594
19677
  style: { top: title ? 30 : 0 },
17595
19678
  children: [
17596
19679
  entity && /* @__PURE__ */ jsx(EntityBox, { entity, config }),
17597
- states.map((state) => renderStateNode ? /* @__PURE__ */ jsx(React84__default.Fragment, { children: renderStateNode(state, config) }, state.id) : /* @__PURE__ */ jsx(
17598
- StateNode,
19680
+ states.map((state) => renderStateNode ? /* @__PURE__ */ jsx(React95__default.Fragment, { children: renderStateNode(state, config) }, state.id) : /* @__PURE__ */ jsx(
19681
+ StateNode2,
17599
19682
  {
17600
19683
  state,
17601
19684
  config
@@ -23151,8 +25234,8 @@ var init_Menu = __esm({
23151
25234
  "bottom-end": "bottom-start"
23152
25235
  };
23153
25236
  const effectivePosition = direction === "rtl" ? rtlMirror[position] ?? position : position;
23154
- const triggerChild = React84__default.isValidElement(trigger) ? trigger : /* @__PURE__ */ jsx(Typography, { variant: "small", as: "span", children: trigger });
23155
- const triggerElement = React84__default.cloneElement(
25237
+ const triggerChild = React95__default.isValidElement(trigger) ? trigger : /* @__PURE__ */ jsx(Typography, { variant: "small", as: "span", children: trigger });
25238
+ const triggerElement = React95__default.cloneElement(
23156
25239
  triggerChild,
23157
25240
  {
23158
25241
  ref: triggerRef,
@@ -23247,14 +25330,14 @@ function useDataDnd(args) {
23247
25330
  const isZone = Boolean(dragGroup || accepts || sortable);
23248
25331
  const enabled = isZone || Boolean(dndRoot);
23249
25332
  const eventBus = useEventBus();
23250
- const parentRoot = React84__default.useContext(RootCtx);
25333
+ const parentRoot = React95__default.useContext(RootCtx);
23251
25334
  const isRoot = enabled && parentRoot === null;
23252
- const zoneId = React84__default.useId();
25335
+ const zoneId = React95__default.useId();
23253
25336
  const ownGroup = dragGroup ?? accepts ?? zoneId;
23254
- const [optimisticOrders, setOptimisticOrders] = React84__default.useState(() => /* @__PURE__ */ new Map());
23255
- const optimisticOrdersRef = React84__default.useRef(optimisticOrders);
25337
+ const [optimisticOrders, setOptimisticOrders] = React95__default.useState(() => /* @__PURE__ */ new Map());
25338
+ const optimisticOrdersRef = React95__default.useRef(optimisticOrders);
23256
25339
  optimisticOrdersRef.current = optimisticOrders;
23257
- const clearOptimisticOrder = React84__default.useCallback((group) => {
25340
+ const clearOptimisticOrder = React95__default.useCallback((group) => {
23258
25341
  setOptimisticOrders((prev) => {
23259
25342
  if (!prev.has(group)) return prev;
23260
25343
  const next = new Map(prev);
@@ -23279,7 +25362,7 @@ function useDataDnd(args) {
23279
25362
  const raw = it[dndItemIdField];
23280
25363
  return raw != null ? String(raw) : `__idx_${idx}`;
23281
25364
  }).join("|");
23282
- const itemIds = React84__default.useMemo(
25365
+ const itemIds = React95__default.useMemo(
23283
25366
  () => orderedItems.map((it, idx) => {
23284
25367
  const raw = it[dndItemIdField];
23285
25368
  return raw != null ? String(raw) : `__idx_${idx}`;
@@ -23290,7 +25373,7 @@ function useDataDnd(args) {
23290
25373
  const raw = it[dndItemIdField];
23291
25374
  return raw != null ? String(raw) : `__${idx}`;
23292
25375
  }).join("|");
23293
- React84__default.useEffect(() => {
25376
+ React95__default.useEffect(() => {
23294
25377
  const root = isRoot ? null : parentRoot;
23295
25378
  if (root) {
23296
25379
  root.clearOptimisticOrder(ownGroup);
@@ -23298,20 +25381,20 @@ function useDataDnd(args) {
23298
25381
  clearOptimisticOrder(ownGroup);
23299
25382
  }
23300
25383
  }, [itemsContentSig, ownGroup]);
23301
- const zonesRef = React84__default.useRef(/* @__PURE__ */ new Map());
23302
- const registerZone = React84__default.useCallback((zoneId2, meta2) => {
25384
+ const zonesRef = React95__default.useRef(/* @__PURE__ */ new Map());
25385
+ const registerZone = React95__default.useCallback((zoneId2, meta2) => {
23303
25386
  zonesRef.current.set(zoneId2, meta2);
23304
25387
  }, []);
23305
- const unregisterZone = React84__default.useCallback((zoneId2) => {
25388
+ const unregisterZone = React95__default.useCallback((zoneId2) => {
23306
25389
  zonesRef.current.delete(zoneId2);
23307
25390
  }, []);
23308
- const [activeDrag, setActiveDrag] = React84__default.useState(null);
23309
- const [overZoneGroup, setOverZoneGroup] = React84__default.useState(null);
23310
- const meta = React84__default.useMemo(
25391
+ const [activeDrag, setActiveDrag] = React95__default.useState(null);
25392
+ const [overZoneGroup, setOverZoneGroup] = React95__default.useState(null);
25393
+ const meta = React95__default.useMemo(
23311
25394
  () => ({ group: ownGroup, dropEvent, reorderEvent, positionEvent, itemIds, rawItems: items, idField: dndItemIdField }),
23312
25395
  [ownGroup, dropEvent, reorderEvent, positionEvent, itemIds, items, dndItemIdField]
23313
25396
  );
23314
- React84__default.useEffect(() => {
25397
+ React95__default.useEffect(() => {
23315
25398
  const target = isRoot ? null : parentRoot;
23316
25399
  if (!target) {
23317
25400
  zonesRef.current.set(zoneId, meta);
@@ -23330,7 +25413,7 @@ function useDataDnd(args) {
23330
25413
  }, [parentRoot, isRoot, zoneId, meta]);
23331
25414
  const sensors = useAlmadarDndSensors(true);
23332
25415
  const collisionDetection = almadarDndCollisionDetection;
23333
- const findZoneByItem = React84__default.useCallback(
25416
+ const findZoneByItem = React95__default.useCallback(
23334
25417
  (id) => {
23335
25418
  for (const z of zonesRef.current.values()) {
23336
25419
  if (z.itemIds.includes(id)) return z;
@@ -23339,7 +25422,7 @@ function useDataDnd(args) {
23339
25422
  },
23340
25423
  []
23341
25424
  );
23342
- React84__default.useCallback(
25425
+ React95__default.useCallback(
23343
25426
  (group) => {
23344
25427
  for (const z of zonesRef.current.values()) {
23345
25428
  if (z.group === group) return z;
@@ -23348,7 +25431,7 @@ function useDataDnd(args) {
23348
25431
  },
23349
25432
  []
23350
25433
  );
23351
- const handleDragEnd = React84__default.useCallback(
25434
+ const handleDragEnd = React95__default.useCallback(
23352
25435
  (event) => {
23353
25436
  const { active, over } = event;
23354
25437
  const activeIdStr = String(active.id);
@@ -23439,8 +25522,8 @@ function useDataDnd(args) {
23439
25522
  },
23440
25523
  [eventBus]
23441
25524
  );
23442
- const sortableData = React84__default.useMemo(() => ({ dndGroup: ownGroup }), [ownGroup]);
23443
- const SortableItem = React84__default.useCallback(
25525
+ const sortableData = React95__default.useMemo(() => ({ dndGroup: ownGroup }), [ownGroup]);
25526
+ const SortableItem = React95__default.useCallback(
23444
25527
  ({ id, children }) => {
23445
25528
  const {
23446
25529
  attributes,
@@ -23480,7 +25563,7 @@ function useDataDnd(args) {
23480
25563
  id: droppableId,
23481
25564
  data: sortableData
23482
25565
  });
23483
- const ctx = React84__default.useContext(RootCtx);
25566
+ const ctx = React95__default.useContext(RootCtx);
23484
25567
  const activeDrag2 = ctx?.activeDrag ?? null;
23485
25568
  const overZoneGroup2 = ctx?.overZoneGroup ?? null;
23486
25569
  const isThisZoneOver = overZoneGroup2 === ownGroup;
@@ -23495,7 +25578,7 @@ function useDataDnd(args) {
23495
25578
  showForeignPlaceholder,
23496
25579
  ctxAvailable: ctx != null
23497
25580
  });
23498
- React84__default.useEffect(() => {
25581
+ React95__default.useEffect(() => {
23499
25582
  dndLog.info("dropzone:isOver:change", { droppableId, group: ownGroup, isOver, isThisZoneOver, showForeignPlaceholder, activeDragSourceGroup: activeDrag2?.sourceGroup ?? null });
23500
25583
  }, [droppableId, isOver, isThisZoneOver, showForeignPlaceholder]);
23501
25584
  return /* @__PURE__ */ jsx(
@@ -23509,11 +25592,11 @@ function useDataDnd(args) {
23509
25592
  }
23510
25593
  );
23511
25594
  };
23512
- const rootContextValue = React84__default.useMemo(
25595
+ const rootContextValue = React95__default.useMemo(
23513
25596
  () => ({ registerZone, unregisterZone, activeDrag, overZoneGroup, optimisticOrders, clearOptimisticOrder }),
23514
25597
  [registerZone, unregisterZone, activeDrag, overZoneGroup, optimisticOrders, clearOptimisticOrder]
23515
25598
  );
23516
- const handleDragStart = React84__default.useCallback((event) => {
25599
+ const handleDragStart = React95__default.useCallback((event) => {
23517
25600
  const sourceZone = findZoneByItem(event.active.id);
23518
25601
  const rect = event.active.rect.current.initial;
23519
25602
  const height = rect?.height && rect.height > 0 ? rect.height : 64;
@@ -23532,7 +25615,7 @@ function useDataDnd(args) {
23532
25615
  isRoot
23533
25616
  });
23534
25617
  }, [findZoneByItem, isRoot, zoneId]);
23535
- const handleDragOver = React84__default.useCallback((event) => {
25618
+ const handleDragOver = React95__default.useCallback((event) => {
23536
25619
  const { active, over } = event;
23537
25620
  const overData = over?.data?.current;
23538
25621
  const overGroup = overData?.dndGroup ?? null;
@@ -23602,7 +25685,7 @@ function useDataDnd(args) {
23602
25685
  return next;
23603
25686
  });
23604
25687
  }, []);
23605
- const handleDragCancel = React84__default.useCallback((event) => {
25688
+ const handleDragCancel = React95__default.useCallback((event) => {
23606
25689
  setActiveDrag(null);
23607
25690
  setOverZoneGroup(null);
23608
25691
  dndLog.warn("dragCancel", {
@@ -23610,12 +25693,12 @@ function useDataDnd(args) {
23610
25693
  reason: "dnd-kit cancelled the drag (escape key, pointer interrupted, or external)"
23611
25694
  });
23612
25695
  }, []);
23613
- const handleDragEndWithCleanup = React84__default.useCallback((event) => {
25696
+ const handleDragEndWithCleanup = React95__default.useCallback((event) => {
23614
25697
  handleDragEnd(event);
23615
25698
  setActiveDrag(null);
23616
25699
  setOverZoneGroup(null);
23617
25700
  }, [handleDragEnd]);
23618
- const wrapContainer = React84__default.useCallback(
25701
+ const wrapContainer = React95__default.useCallback(
23619
25702
  (children) => {
23620
25703
  if (!enabled) return children;
23621
25704
  const strategy = layout === "grid" ? rectSortingStrategy : verticalListSortingStrategy;
@@ -23669,7 +25752,7 @@ var init_useDataDnd = __esm({
23669
25752
  init_useAlmadarDndCollision();
23670
25753
  init_Box();
23671
25754
  dndLog = createLogger("almadar:ui:dnd");
23672
- RootCtx = React84__default.createContext(null);
25755
+ RootCtx = React95__default.createContext(null);
23673
25756
  }
23674
25757
  });
23675
25758
  function renderIconInput(icon, props) {
@@ -24195,7 +26278,7 @@ function DataList({
24195
26278
  }) {
24196
26279
  const eventBus = useEventBus();
24197
26280
  const { t } = useTranslate();
24198
- const [visibleCount, setVisibleCount] = React84__default.useState(pageSize || Infinity);
26281
+ const [visibleCount, setVisibleCount] = React95__default.useState(pageSize || Infinity);
24199
26282
  const fieldDefs = fields ?? columns ?? [];
24200
26283
  const allDataRaw = Array.isArray(entity) ? entity : entity ? [entity] : [];
24201
26284
  const dnd = useDataDnd({
@@ -24214,7 +26297,7 @@ function DataList({
24214
26297
  const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
24215
26298
  const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
24216
26299
  const hasRenderProp = typeof children === "function";
24217
- React84__default.useEffect(() => {
26300
+ React95__default.useEffect(() => {
24218
26301
  const renderItemTypeOf = typeof schemaRenderItem;
24219
26302
  const childrenTypeOf = typeof children;
24220
26303
  if (data.length > 0 && !hasRenderProp) {
@@ -24318,7 +26401,7 @@ function DataList({
24318
26401
  const items2 = [...data];
24319
26402
  const groups2 = groupBy ? groupData(items2, groupBy) : [{ label: "", items: items2 }];
24320
26403
  const contentField = titleField?.name ?? fieldDefs[0]?.name ?? "";
24321
- return /* @__PURE__ */ jsx(VStack, { gap: "sm", className: cn("py-2", className), children: groups2.map((group, gi) => /* @__PURE__ */ jsxs(React84__default.Fragment, { children: [
26404
+ return /* @__PURE__ */ jsx(VStack, { gap: "sm", className: cn("py-2", className), children: groups2.map((group, gi) => /* @__PURE__ */ jsxs(React95__default.Fragment, { children: [
24322
26405
  group.label && /* @__PURE__ */ jsx(Divider, { label: group.label, className: "my-2" }),
24323
26406
  group.items.map((itemData, index) => {
24324
26407
  const id = itemData.id || `${gi}-${index}`;
@@ -24459,7 +26542,7 @@ function DataList({
24459
26542
  className
24460
26543
  ),
24461
26544
  children: [
24462
- groups.map((group, gi) => /* @__PURE__ */ jsxs(React84__default.Fragment, { children: [
26545
+ groups.map((group, gi) => /* @__PURE__ */ jsxs(React95__default.Fragment, { children: [
24463
26546
  group.label && /* @__PURE__ */ jsx(Divider, { label: group.label, className: gi > 0 ? "mt-4" : "mt-0" }),
24464
26547
  group.items.map(
24465
26548
  (itemData, index) => renderItem(itemData, index, gi === groups.length - 1 && index === group.items.length - 1)
@@ -24544,7 +26627,7 @@ var init_FormSection = __esm({
24544
26627
  columns = 1,
24545
26628
  className
24546
26629
  }) => {
24547
- const [collapsed, setCollapsed] = React84__default.useState(defaultCollapsed);
26630
+ const [collapsed, setCollapsed] = React95__default.useState(defaultCollapsed);
24548
26631
  const { t } = useTranslate();
24549
26632
  const eventBus = useEventBus();
24550
26633
  const gridClass = {
@@ -24552,7 +26635,7 @@ var init_FormSection = __esm({
24552
26635
  2: "grid-cols-1 md:grid-cols-2",
24553
26636
  3: "grid-cols-1 md:grid-cols-2 lg:grid-cols-3"
24554
26637
  }[columns];
24555
- React84__default.useCallback(() => {
26638
+ React95__default.useCallback(() => {
24556
26639
  if (collapsible) {
24557
26640
  setCollapsed((prev) => !prev);
24558
26641
  eventBus.emit("UI:TOGGLE_COLLAPSE", { collapsed: !collapsed });
@@ -25438,7 +27521,7 @@ var init_Flex = __esm({
25438
27521
  flexStyle.flexBasis = typeof basis === "number" ? `${basis}px` : basis;
25439
27522
  }
25440
27523
  }
25441
- return React84__default.createElement(Component, {
27524
+ return React95__default.createElement(Component, {
25442
27525
  className: cn(
25443
27526
  inline ? "inline-flex" : "flex",
25444
27527
  directionStyles[direction],
@@ -25544,7 +27627,7 @@ var init_Grid = __esm({
25544
27627
  };
25545
27628
  Grid = ({
25546
27629
  cols = 1,
25547
- rows,
27630
+ rows: rows2,
25548
27631
  gap = "md",
25549
27632
  rowGap,
25550
27633
  colGap,
@@ -25556,8 +27639,8 @@ var init_Grid = __esm({
25556
27639
  children,
25557
27640
  as: Component = "div"
25558
27641
  }) => {
25559
- const mergedStyle = rows ? { gridTemplateRows: `repeat(${rows}, minmax(0, 1fr))`, ...style } : style;
25560
- return React84__default.createElement(
27642
+ const mergedStyle = rows2 ? { gridTemplateRows: `repeat(${rows2}, minmax(0, 1fr))`, ...style } : style;
27643
+ return React95__default.createElement(
25561
27644
  Component,
25562
27645
  {
25563
27646
  className: cn(
@@ -25753,9 +27836,9 @@ var init_Popover = __esm({
25753
27836
  onMouseLeave: handleClose,
25754
27837
  onPointerDown: tapTriggerProps.onPointerDown
25755
27838
  };
25756
- const childElement = React84__default.isValidElement(children) ? children : /* @__PURE__ */ jsx("span", { children });
27839
+ const childElement = React95__default.isValidElement(children) ? children : /* @__PURE__ */ jsx("span", { children });
25757
27840
  const childPointerDown = childElement.props.onPointerDown;
25758
- const triggerElement = React84__default.cloneElement(
27841
+ const triggerElement = React95__default.cloneElement(
25759
27842
  childElement,
25760
27843
  {
25761
27844
  ref: triggerRef,
@@ -26357,9 +28440,9 @@ var init_Tooltip = __esm({
26357
28440
  if (hideTimeoutRef.current) clearTimeout(hideTimeoutRef.current);
26358
28441
  };
26359
28442
  }, []);
26360
- const triggerElement = React84__default.isValidElement(children) ? children : /* @__PURE__ */ jsx("span", { children });
28443
+ const triggerElement = React95__default.isValidElement(children) ? children : /* @__PURE__ */ jsx("span", { children });
26361
28444
  const childPointerDown = triggerElement.props.onPointerDown;
26362
- const trigger = React84__default.cloneElement(triggerElement, {
28445
+ const trigger = React95__default.cloneElement(triggerElement, {
26363
28446
  ref: triggerRef,
26364
28447
  onMouseEnter: handleMouseEnter,
26365
28448
  onMouseLeave: handleMouseLeave,
@@ -26449,7 +28532,7 @@ var init_WizardProgress = __esm({
26449
28532
  children: /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: normalizedSteps.map((step, index) => {
26450
28533
  const isActive = index === currentStep;
26451
28534
  const isCompleted = index < currentStep;
26452
- return /* @__PURE__ */ jsxs(React84__default.Fragment, { children: [
28535
+ return /* @__PURE__ */ jsxs(React95__default.Fragment, { children: [
26453
28536
  /* @__PURE__ */ jsx(
26454
28537
  "button",
26455
28538
  {
@@ -28009,13 +30092,13 @@ var init_MapView = __esm({
28009
30092
  shadowSize: [41, 41]
28010
30093
  });
28011
30094
  L.Marker.prototype.options.icon = defaultIcon;
28012
- const { useEffect: useEffect63, useRef: useRef61, useCallback: useCallback92, useState: useState88 } = React84__default;
30095
+ const { useEffect: useEffect67, useRef: useRef65, useCallback: useCallback99, useState: useState97 } = React95__default;
28013
30096
  const { Typography: Typography2 } = await Promise.resolve().then(() => (init_Typography(), Typography_exports));
28014
30097
  const { useEventBus: useEventBus2 } = await Promise.resolve().then(() => (init_useEventBus(), useEventBus_exports));
28015
30098
  function MapUpdater({ centerLat, centerLng, zoom }) {
28016
30099
  const map = useMap();
28017
- const prevRef = useRef61({ centerLat, centerLng, zoom });
28018
- useEffect63(() => {
30100
+ const prevRef = useRef65({ centerLat, centerLng, zoom });
30101
+ useEffect67(() => {
28019
30102
  const prev = prevRef.current;
28020
30103
  if (prev.centerLat !== centerLat || prev.centerLng !== centerLng || prev.zoom !== zoom) {
28021
30104
  map.setView([centerLat, centerLng], zoom);
@@ -28026,7 +30109,7 @@ var init_MapView = __esm({
28026
30109
  }
28027
30110
  function MapClickHandler({ onMapClick }) {
28028
30111
  const map = useMap();
28029
- useEffect63(() => {
30112
+ useEffect67(() => {
28030
30113
  if (!onMapClick) return;
28031
30114
  const handler = (e) => {
28032
30115
  onMapClick(e.latlng.lat, e.latlng.lng);
@@ -28054,8 +30137,8 @@ var init_MapView = __esm({
28054
30137
  showAttribution = true
28055
30138
  }) {
28056
30139
  const eventBus = useEventBus2();
28057
- const [clickedPosition, setClickedPosition] = useState88(null);
28058
- const handleMapClick = useCallback92((lat, lng) => {
30140
+ const [clickedPosition, setClickedPosition] = useState97(null);
30141
+ const handleMapClick = useCallback99((lat, lng) => {
28059
30142
  if (showClickedPin) {
28060
30143
  setClickedPosition({ lat, lng });
28061
30144
  }
@@ -28064,7 +30147,7 @@ var init_MapView = __esm({
28064
30147
  eventBus.emit(`UI:${mapClickEvent}`, { latitude: lat, longitude: lng });
28065
30148
  }
28066
30149
  }, [onMapClick, mapClickEvent, eventBus, showClickedPin]);
28067
- const handleMarkerClick = useCallback92((marker) => {
30150
+ const handleMarkerClick = useCallback99((marker) => {
28068
30151
  onMarkerClick?.(marker);
28069
30152
  if (markerClickEvent) {
28070
30153
  eventBus.emit(`UI:${markerClickEvent}`, { ...marker });
@@ -28924,8 +31007,8 @@ function TableView({
28924
31007
  }) {
28925
31008
  const eventBus = useEventBus();
28926
31009
  const { t } = useTranslate();
28927
- const [visibleCount, setVisibleCount] = React84__default.useState(pageSize > 0 ? pageSize : Infinity);
28928
- const [localSelected, setLocalSelected] = React84__default.useState(/* @__PURE__ */ new Set());
31010
+ const [visibleCount, setVisibleCount] = React95__default.useState(pageSize > 0 ? pageSize : Infinity);
31011
+ const [localSelected, setLocalSelected] = React95__default.useState(/* @__PURE__ */ new Set());
28929
31012
  const colDefs = columns ?? fields ?? [];
28930
31013
  const allDataRaw = Array.isArray(entity) ? entity : entity ? [entity] : [];
28931
31014
  const dnd = useDataDnd({
@@ -29120,12 +31203,12 @@ function TableView({
29120
31203
  ]
29121
31204
  }
29122
31205
  );
29123
- return dnd.isZone ? /* @__PURE__ */ jsx(dnd.SortableItem, { id: row[idField] ?? id, children: rowInner }, id) : /* @__PURE__ */ jsx(React84__default.Fragment, { children: rowInner }, id);
31206
+ return dnd.isZone ? /* @__PURE__ */ jsx(dnd.SortableItem, { id: row[idField] ?? id, children: rowInner }, id) : /* @__PURE__ */ jsx(React95__default.Fragment, { children: rowInner }, id);
29124
31207
  };
29125
31208
  const items = Array.from(data);
29126
31209
  const groups = groupBy ? groupData2(items, groupBy) : [{ label: "", items }];
29127
31210
  let runningIndex = 0;
29128
- const body = /* @__PURE__ */ jsx(Box, { role: "rowgroup", children: groups.map((group, gi) => /* @__PURE__ */ jsxs(React84__default.Fragment, { children: [
31211
+ const body = /* @__PURE__ */ jsx(Box, { role: "rowgroup", children: groups.map((group, gi) => /* @__PURE__ */ jsxs(React95__default.Fragment, { children: [
29129
31212
  group.label && /* @__PURE__ */ jsx(Divider, { label: group.label, className: gi > 0 ? "mt-3" : "mt-0" }),
29130
31213
  group.items.map((row) => renderRow(row, runningIndex++))
29131
31214
  ] }, gi)) });
@@ -30344,7 +32427,7 @@ var init_StepFlow = __esm({
30344
32427
  className
30345
32428
  }) => {
30346
32429
  if (orientation === "vertical") {
30347
- return /* @__PURE__ */ jsx(VStack, { gap: "none", className: cn("w-full", className), children: steps.map((step, index) => /* @__PURE__ */ jsx(React84__default.Fragment, { children: /* @__PURE__ */ jsxs(HStack, { gap: "md", align: "start", className: "w-full", children: [
32430
+ return /* @__PURE__ */ jsx(VStack, { gap: "none", className: cn("w-full", className), children: steps.map((step, index) => /* @__PURE__ */ jsx(React95__default.Fragment, { children: /* @__PURE__ */ jsxs(HStack, { gap: "md", align: "start", className: "w-full", children: [
30348
32431
  /* @__PURE__ */ jsxs(VStack, { gap: "none", align: "center", children: [
30349
32432
  /* @__PURE__ */ jsx(StepCircle, { step, index }),
30350
32433
  showConnectors && index < steps.length - 1 && /* @__PURE__ */ jsx(Box, { className: "w-px h-8 bg-border" })
@@ -30355,7 +32438,7 @@ var init_StepFlow = __esm({
30355
32438
  ] })
30356
32439
  ] }) }, index)) });
30357
32440
  }
30358
- return /* @__PURE__ */ jsx(Box, { className: cn("w-full flex flex-col md:flex-row items-start gap-0", className), children: steps.map((step, index) => /* @__PURE__ */ jsxs(React84__default.Fragment, { children: [
32441
+ return /* @__PURE__ */ jsx(Box, { className: cn("w-full flex flex-col md:flex-row items-start gap-0", className), children: steps.map((step, index) => /* @__PURE__ */ jsxs(React95__default.Fragment, { children: [
30359
32442
  /* @__PURE__ */ jsxs(VStack, { gap: "sm", align: "center", className: "flex-1 w-full md:w-auto", children: [
30360
32443
  /* @__PURE__ */ jsx(StepCircle, { step, index }),
30361
32444
  /* @__PURE__ */ jsx(Typography, { variant: "h4", className: "text-center", children: step.title }),
@@ -31081,11 +33164,11 @@ function LatticeSVG({
31081
33164
  }) {
31082
33165
  const paths = [];
31083
33166
  const cols = 5;
31084
- const rows = Math.ceil(h / (w / cols));
33167
+ const rows2 = Math.ceil(h / (w / cols));
31085
33168
  const cellW = w / cols;
31086
33169
  const cellH = cellW;
31087
33170
  const bulge = cellW * 0.3;
31088
- for (let row = 0; row < rows; row++) {
33171
+ for (let row = 0; row < rows2; row++) {
31089
33172
  for (let col = 0; col < cols; col++) {
31090
33173
  const cx = col * cellW + cellW / 2;
31091
33174
  const cy = row * cellH + cellH / 2;
@@ -31340,7 +33423,7 @@ var init_LikertScale = __esm({
31340
33423
  md: "text-base",
31341
33424
  lg: "text-lg"
31342
33425
  };
31343
- LikertScale = React84__default.forwardRef(
33426
+ LikertScale = React95__default.forwardRef(
31344
33427
  ({
31345
33428
  question,
31346
33429
  options = DEFAULT_LIKERT_OPTIONS,
@@ -31352,7 +33435,7 @@ var init_LikertScale = __esm({
31352
33435
  variant = "radios",
31353
33436
  className
31354
33437
  }, ref) => {
31355
- const groupId = React84__default.useId();
33438
+ const groupId = React95__default.useId();
31356
33439
  const eventBus = useEventBus();
31357
33440
  const handleSelect = useCallback(
31358
33441
  (next) => {
@@ -31506,7 +33589,7 @@ var init_MatrixQuestion = __esm({
31506
33589
  };
31507
33590
  MatrixQuestion = ({
31508
33591
  title,
31509
- rows,
33592
+ rows: rows2,
31510
33593
  columns = DEFAULT_MATRIX_COLUMNS,
31511
33594
  values,
31512
33595
  onChange,
@@ -31516,7 +33599,7 @@ var init_MatrixQuestion = __esm({
31516
33599
  className
31517
33600
  }) => {
31518
33601
  const styles = sizeStyles12[size];
31519
- const safeRows = rows ?? [];
33602
+ const safeRows = rows2 ?? [];
31520
33603
  const safeValues = values ?? {};
31521
33604
  const eventBus = useEventBus();
31522
33605
  const handleChange = useCallback(
@@ -33634,7 +35717,7 @@ var init_DocBreadcrumb = __esm({
33634
35717
  "aria-label": t("aria.breadcrumb"),
33635
35718
  children: /* @__PURE__ */ jsx(HStack, { gap: "xs", align: "center", wrap: true, children: items.map((item, idx) => {
33636
35719
  const isLast = idx === items.length - 1;
33637
- return /* @__PURE__ */ jsxs(React84__default.Fragment, { children: [
35720
+ return /* @__PURE__ */ jsxs(React95__default.Fragment, { children: [
33638
35721
  idx > 0 && /* @__PURE__ */ jsx(
33639
35722
  Icon,
33640
35723
  {
@@ -34503,7 +36586,7 @@ var init_MiniStateMachine = __esm({
34503
36586
  const x = 2 + i * (NODE_W + GAP + ARROW_W + GAP);
34504
36587
  const tc = transitionCounts[s.name] ?? 0;
34505
36588
  const role = getStateRole(s.name, s.isInitial ?? void 0, s.isTerminal ?? void 0, tc, maxTC);
34506
- return /* @__PURE__ */ jsxs(React84__default.Fragment, { children: [
36589
+ return /* @__PURE__ */ jsxs(React95__default.Fragment, { children: [
34507
36590
  /* @__PURE__ */ jsx(
34508
36591
  AvlState,
34509
36592
  {
@@ -34707,7 +36790,7 @@ var init_PageHeader = __esm({
34707
36790
  info: "bg-info/10 text-info"
34708
36791
  };
34709
36792
  return /* @__PURE__ */ jsxs(Box, { className: cn("mb-6", className), children: [
34710
- breadcrumbs && breadcrumbs.length > 0 && /* @__PURE__ */ jsx(Box, { as: "nav", className: "mb-4", children: /* @__PURE__ */ jsx(Box, { as: "ol", className: "flex items-center gap-2 text-sm", children: breadcrumbs.map((crumb, idx) => /* @__PURE__ */ jsxs(React84__default.Fragment, { children: [
36793
+ breadcrumbs && breadcrumbs.length > 0 && /* @__PURE__ */ jsx(Box, { as: "nav", className: "mb-4", children: /* @__PURE__ */ jsx(Box, { as: "ol", className: "flex items-center gap-2 text-sm", children: breadcrumbs.map((crumb, idx) => /* @__PURE__ */ jsxs(React95__default.Fragment, { children: [
34711
36794
  idx > 0 && /* @__PURE__ */ jsx(Typography, { variant: "small", color: "muted", children: "/" }),
34712
36795
  crumb.href ? /* @__PURE__ */ jsx(
34713
36796
  "a",
@@ -35065,7 +37148,7 @@ var init_Section = __esm({
35065
37148
  as: Component = "section"
35066
37149
  }) => {
35067
37150
  const hasHeader = title || description || action;
35068
- return React84__default.createElement(
37151
+ return React95__default.createElement(
35069
37152
  Component,
35070
37153
  {
35071
37154
  className: cn(
@@ -35389,8 +37472,8 @@ var init_WizardContainer = __esm({
35389
37472
  return void 0;
35390
37473
  if (typeof controlledStep === "number") return controlledStep;
35391
37474
  if (typeof controlledStep === "string") return parseInt(controlledStep, 10);
35392
- const num = Number(controlledStep);
35393
- return isNaN(num) ? void 0 : num;
37475
+ const num2 = Number(controlledStep);
37476
+ return isNaN(num2) ? void 0 : num2;
35394
37477
  })();
35395
37478
  const currentStep = normalizedControlledStep !== void 0 ? normalizedControlledStep : internalStep;
35396
37479
  const totalSteps = steps.length;
@@ -35439,7 +37522,7 @@ var init_WizardContainer = __esm({
35439
37522
  const isCompleted = index < currentStep;
35440
37523
  const stepKey = step.id ?? step.tabId ?? `step-${index}`;
35441
37524
  const stepTitle = step.title ?? step.name ?? `Step ${index + 1}`;
35442
- return /* @__PURE__ */ jsxs(React84__default.Fragment, { children: [
37525
+ return /* @__PURE__ */ jsxs(React95__default.Fragment, { children: [
35443
37526
  /* @__PURE__ */ jsx(
35444
37527
  Button,
35445
37528
  {
@@ -37416,7 +39499,7 @@ function getBadgeVariant(fieldName, value) {
37416
39499
  return "default";
37417
39500
  }
37418
39501
  function formatFieldLabel(fieldName) {
37419
- return fieldName.replace(/([A-Z])/g, " $1").replace(/^./, (str) => str.toUpperCase());
39502
+ return fieldName.replace(/([A-Z])/g, " $1").replace(/^./, (str2) => str2.toUpperCase());
37420
39503
  }
37421
39504
  function formatFieldValue(value, fieldName) {
37422
39505
  if (typeof value === "number") {
@@ -37435,26 +39518,26 @@ function formatFieldValue(value, fieldName) {
37435
39518
  }
37436
39519
  function renderRichFieldValue(value, fieldName, fieldType) {
37437
39520
  if (value === void 0 || value === null) return "\u2014";
37438
- const str = String(value);
39521
+ const str2 = String(value);
37439
39522
  switch (fieldType) {
37440
39523
  case "image":
37441
39524
  case "url": {
37442
- if (str.match(/\.(png|jpe?g|gif|svg|webp|avif)(\?|$)/i) || str.startsWith("data:image/")) {
39525
+ if (str2.match(/\.(png|jpe?g|gif|svg|webp|avif)(\?|$)/i) || str2.startsWith("data:image/")) {
37443
39526
  return /* @__PURE__ */ jsx(Box, { className: "mt-1 max-w-full", children: /* @__PURE__ */ jsx(
37444
39527
  "img",
37445
39528
  {
37446
- src: str,
39529
+ src: str2,
37447
39530
  alt: formatFieldLabel(fieldName),
37448
39531
  className: "max-w-full max-h-64 rounded-md object-contain",
37449
39532
  loading: "lazy"
37450
39533
  }
37451
39534
  ) });
37452
39535
  }
37453
- return str;
39536
+ return str2;
37454
39537
  }
37455
39538
  case "markdown":
37456
39539
  case "richtext":
37457
- return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Typography, { variant: "body", className: "break-words", children: str }), children: /* @__PURE__ */ jsx(
39540
+ return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Typography, { variant: "body", className: "break-words", children: str2 }), children: /* @__PURE__ */ jsx(
37458
39541
  Box,
37459
39542
  {
37460
39543
  className: "prose prose-sm max-w-none",
@@ -37472,11 +39555,11 @@ function renderRichFieldValue(value, fieldName, fieldType) {
37472
39555
  "--tw-prose-th-borders": "var(--color-border)",
37473
39556
  "--tw-prose-td-borders": "var(--color-border)"
37474
39557
  },
37475
- children: /* @__PURE__ */ jsx(ReactMarkdown2, { children: str })
39558
+ children: /* @__PURE__ */ jsx(ReactMarkdown2, { children: str2 })
37476
39559
  }
37477
39560
  ) });
37478
39561
  case "code":
37479
- return /* @__PURE__ */ jsx(Box, { className: "mt-1 rounded-md bg-muted p-3 overflow-x-auto", children: /* @__PURE__ */ jsx("pre", { className: "text-sm font-mono whitespace-pre-wrap break-words m-0", children: /* @__PURE__ */ jsx("code", { children: str }) }) });
39562
+ return /* @__PURE__ */ jsx(Box, { className: "mt-1 rounded-md bg-muted p-3 overflow-x-auto", children: /* @__PURE__ */ jsx("pre", { className: "text-sm font-mono whitespace-pre-wrap break-words m-0", children: /* @__PURE__ */ jsx("code", { children: str2 }) }) });
37480
39563
  case "html":
37481
39564
  return /* @__PURE__ */ jsx(
37482
39565
  Box,
@@ -37496,12 +39579,12 @@ function renderRichFieldValue(value, fieldName, fieldType) {
37496
39579
  "--tw-prose-th-borders": "var(--color-border)",
37497
39580
  "--tw-prose-td-borders": "var(--color-border)"
37498
39581
  },
37499
- children: /* @__PURE__ */ jsx(Typography, { variant: "body", children: str })
39582
+ children: /* @__PURE__ */ jsx(Typography, { variant: "body", children: str2 })
37500
39583
  }
37501
39584
  );
37502
39585
  case "date":
37503
39586
  case "datetime": {
37504
- const d = new Date(str);
39587
+ const d = new Date(str2);
37505
39588
  if (!isNaN(d.getTime())) {
37506
39589
  return d.toLocaleDateString(void 0, {
37507
39590
  year: "numeric",
@@ -37510,7 +39593,7 @@ function renderRichFieldValue(value, fieldName, fieldType) {
37510
39593
  ...fieldType === "datetime" ? { hour: "2-digit", minute: "2-digit" } : {}
37511
39594
  });
37512
39595
  }
37513
- return str;
39596
+ return str2;
37514
39597
  }
37515
39598
  default:
37516
39599
  return formatFieldValue(value, fieldName);
@@ -37872,7 +39955,7 @@ var init_DetailPanel = __esm({
37872
39955
  }
37873
39956
  });
37874
39957
  function extractTitle(children) {
37875
- if (!React84__default.isValidElement(children)) return void 0;
39958
+ if (!React95__default.isValidElement(children)) return void 0;
37876
39959
  const props = children.props;
37877
39960
  if (typeof props.title === "string") {
37878
39961
  return props.title;
@@ -38222,12 +40305,12 @@ var init_Form = __esm({
38222
40305
  const isSchemaEntity = isOrbitalEntitySchema(entity);
38223
40306
  const resolvedEntity = isSchemaEntity ? entity : void 0;
38224
40307
  const entityName = typeof entity === "string" ? entity : resolvedEntity?.name;
38225
- const normalizedInitialData = React84__default.useMemo(() => {
40308
+ const normalizedInitialData = React95__default.useMemo(() => {
38226
40309
  const entityRowAsInitial = isPlainEntityRow(entity) ? entity : void 0;
38227
40310
  const callerInitial = initialData !== null && typeof initialData === "object" && !Array.isArray(initialData) ? initialData : {};
38228
40311
  return entityRowAsInitial !== void 0 ? { ...entityRowAsInitial, ...callerInitial } : callerInitial;
38229
40312
  }, [entity, initialData]);
38230
- const entityDerivedFields = React84__default.useMemo(() => {
40313
+ const entityDerivedFields = React95__default.useMemo(() => {
38231
40314
  if (fields && fields.length > 0) return void 0;
38232
40315
  if (!resolvedEntity) return void 0;
38233
40316
  return resolvedEntity.fields.map(
@@ -38248,16 +40331,16 @@ var init_Form = __esm({
38248
40331
  const conditionalFields = typeof conditionalFieldsRaw === "boolean" ? {} : conditionalFieldsRaw;
38249
40332
  const hiddenCalculations = typeof hiddenCalculationsRaw === "boolean" ? [] : hiddenCalculationsRaw;
38250
40333
  const violationTriggers = typeof violationTriggersRaw === "boolean" ? [] : violationTriggersRaw;
38251
- const [formData, setFormData] = React84__default.useState(
40334
+ const [formData, setFormData] = React95__default.useState(
38252
40335
  normalizedInitialData
38253
40336
  );
38254
- const [collapsedSections, setCollapsedSections] = React84__default.useState(
40337
+ const [collapsedSections, setCollapsedSections] = React95__default.useState(
38255
40338
  /* @__PURE__ */ new Set()
38256
40339
  );
38257
- const [submitError, setSubmitError] = React84__default.useState(null);
38258
- const formRef = React84__default.useRef(null);
40340
+ const [submitError, setSubmitError] = React95__default.useState(null);
40341
+ const formRef = React95__default.useRef(null);
38259
40342
  const formMode = props.mode;
38260
- const mountedRef = React84__default.useRef(false);
40343
+ const mountedRef = React95__default.useRef(false);
38261
40344
  if (!mountedRef.current) {
38262
40345
  mountedRef.current = true;
38263
40346
  debug("forms", "mount", {
@@ -38270,7 +40353,7 @@ var init_Form = __esm({
38270
40353
  });
38271
40354
  }
38272
40355
  const shouldShowCancel = showCancel ?? (fields && fields.length > 0);
38273
- const evalContext = React84__default.useMemo(
40356
+ const evalContext = React95__default.useMemo(
38274
40357
  () => ({
38275
40358
  formValues: formData,
38276
40359
  globalVariables: externalContext?.globalVariables ?? {},
@@ -38279,7 +40362,7 @@ var init_Form = __esm({
38279
40362
  }),
38280
40363
  [formData, externalContext]
38281
40364
  );
38282
- React84__default.useEffect(() => {
40365
+ React95__default.useEffect(() => {
38283
40366
  debug("forms", "initialData-sync", {
38284
40367
  mode: formMode,
38285
40368
  normalizedInitialData,
@@ -38290,7 +40373,7 @@ var init_Form = __esm({
38290
40373
  setFormData(normalizedInitialData);
38291
40374
  }
38292
40375
  }, [normalizedInitialData]);
38293
- const processCalculations = React84__default.useCallback(
40376
+ const processCalculations = React95__default.useCallback(
38294
40377
  (changedFieldId, newFormData) => {
38295
40378
  if (!hiddenCalculations.length) return;
38296
40379
  const context = {
@@ -38315,7 +40398,7 @@ var init_Form = __esm({
38315
40398
  },
38316
40399
  [hiddenCalculations, externalContext, eventBus]
38317
40400
  );
38318
- const checkViolations = React84__default.useCallback(
40401
+ const checkViolations = React95__default.useCallback(
38319
40402
  (changedFieldId, newFormData) => {
38320
40403
  if (!violationTriggers.length) return;
38321
40404
  const context = {
@@ -38353,7 +40436,7 @@ var init_Form = __esm({
38353
40436
  processCalculations(name, newFormData);
38354
40437
  checkViolations(name, newFormData);
38355
40438
  };
38356
- const isFieldVisible = React84__default.useCallback(
40439
+ const isFieldVisible = React95__default.useCallback(
38357
40440
  (fieldName) => {
38358
40441
  const condition = conditionalFields[fieldName];
38359
40442
  if (!condition) return true;
@@ -38361,7 +40444,7 @@ var init_Form = __esm({
38361
40444
  },
38362
40445
  [conditionalFields, evalContext]
38363
40446
  );
38364
- const isSectionVisible = React84__default.useCallback(
40447
+ const isSectionVisible = React95__default.useCallback(
38365
40448
  (section) => {
38366
40449
  if (!section.condition) return true;
38367
40450
  return Boolean(evaluateFormExpression(section.condition, evalContext));
@@ -38437,7 +40520,7 @@ var init_Form = __esm({
38437
40520
  eventBus.emit(`UI:${onCancel}`);
38438
40521
  }
38439
40522
  };
38440
- const renderField = React84__default.useCallback(
40523
+ const renderField = React95__default.useCallback(
38441
40524
  (field) => {
38442
40525
  const fieldName = field.name || field.field;
38443
40526
  if (!fieldName) return null;
@@ -38458,7 +40541,7 @@ var init_Form = __esm({
38458
40541
  [formData, isFieldVisible, relationsData, relationsLoading, isLoading]
38459
40542
  );
38460
40543
  const effectiveFields = entityDerivedFields ?? fields;
38461
- const normalizedFields = React84__default.useMemo(() => {
40544
+ const normalizedFields = React95__default.useMemo(() => {
38462
40545
  if (!effectiveFields || effectiveFields.length === 0) return [];
38463
40546
  return effectiveFields.map((field) => {
38464
40547
  if (typeof field === "string") {
@@ -38482,7 +40565,7 @@ var init_Form = __esm({
38482
40565
  return field;
38483
40566
  });
38484
40567
  }, [effectiveFields, resolvedEntity]);
38485
- const schemaFields = React84__default.useMemo(() => {
40568
+ const schemaFields = React95__default.useMemo(() => {
38486
40569
  if (normalizedFields.length === 0) return null;
38487
40570
  if (isDebugEnabled()) {
38488
40571
  debugGroup(`Form: ${entityName || "unknown"}`);
@@ -38492,7 +40575,7 @@ var init_Form = __esm({
38492
40575
  }
38493
40576
  return normalizedFields.map(renderField).filter(Boolean);
38494
40577
  }, [normalizedFields, renderField, entityName, conditionalFields]);
38495
- const sectionElements = React84__default.useMemo(() => {
40578
+ const sectionElements = React95__default.useMemo(() => {
38496
40579
  if (!sections || sections.length === 0) return null;
38497
40580
  return sections.map((section) => {
38498
40581
  if (!isSectionVisible(section)) {
@@ -39071,7 +41154,7 @@ function formatValue3(value, fieldName) {
39071
41154
  return String(value);
39072
41155
  }
39073
41156
  function formatFieldLabel2(fieldName) {
39074
- return fieldName.replace(/([A-Z])/g, " $1").replace(/^./, (str) => str.toUpperCase()).replace(/Id$/, "").trim();
41157
+ return fieldName.replace(/([A-Z])/g, " $1").replace(/^./, (str2) => str2.toUpperCase()).replace(/Id$/, "").trim();
39075
41158
  }
39076
41159
  var STATUS_STYLES2, StatusBadge, ProgressIndicator, List3;
39077
41160
  var init_List = __esm({
@@ -39217,7 +41300,7 @@ var init_List = __esm({
39217
41300
  if (entity && typeof entity === "object" && "id" in entity) return [entity];
39218
41301
  return [];
39219
41302
  }, [entity]);
39220
- const getItemActions = React84__default.useCallback(
41303
+ const getItemActions = React95__default.useCallback(
39221
41304
  (item) => {
39222
41305
  if (!itemActions) return [];
39223
41306
  if (typeof itemActions === "function") {
@@ -39692,7 +41775,7 @@ var init_MediaGallery = __esm({
39692
41775
  [selectable, selectedItems, selectionEvent, eventBus]
39693
41776
  );
39694
41777
  const entityData = Array.isArray(entity) ? entity : [];
39695
- const items = React84__default.useMemo(() => {
41778
+ const items = React95__default.useMemo(() => {
39696
41779
  if (propItems) return propItems;
39697
41780
  if (entityData.length === 0) return [];
39698
41781
  return entityData.map((record, idx) => {
@@ -39855,7 +41938,7 @@ var init_MediaGallery = __esm({
39855
41938
  }
39856
41939
  });
39857
41940
  function extractTitle2(children) {
39858
- if (!React84__default.isValidElement(children)) return void 0;
41941
+ if (!React95__default.isValidElement(children)) return void 0;
39859
41942
  const props = children.props;
39860
41943
  if (typeof props.title === "string") {
39861
41944
  return props.title;
@@ -40129,7 +42212,7 @@ var init_debugRegistry = __esm({
40129
42212
  }
40130
42213
  });
40131
42214
  function useDebugData() {
40132
- const [data, setData] = React84.useState(() => ({
42215
+ const [data, setData] = React95.useState(() => ({
40133
42216
  traits: [],
40134
42217
  ticks: [],
40135
42218
  guards: [],
@@ -40143,7 +42226,7 @@ function useDebugData() {
40143
42226
  },
40144
42227
  lastUpdate: Date.now()
40145
42228
  }));
40146
- React84.useEffect(() => {
42229
+ React95.useEffect(() => {
40147
42230
  const updateData = () => {
40148
42231
  setData({
40149
42232
  traits: getAllTraits(),
@@ -40252,12 +42335,12 @@ function layoutGraph(states, transitions, initialState, width, height) {
40252
42335
  return positions;
40253
42336
  }
40254
42337
  function WalkMinimap() {
40255
- const [walkStep, setWalkStep] = React84.useState(null);
40256
- const [traits2, setTraits] = React84.useState([]);
40257
- const [coveredEdges, setCoveredEdges] = React84.useState([]);
40258
- const [completedTraits, setCompletedTraits] = React84.useState(/* @__PURE__ */ new Set());
40259
- const prevTraitRef = React84.useRef(null);
40260
- React84.useEffect(() => {
42338
+ const [walkStep, setWalkStep] = React95.useState(null);
42339
+ const [traits2, setTraits] = React95.useState([]);
42340
+ const [coveredEdges, setCoveredEdges] = React95.useState([]);
42341
+ const [completedTraits, setCompletedTraits] = React95.useState(/* @__PURE__ */ new Set());
42342
+ const prevTraitRef = React95.useRef(null);
42343
+ React95.useEffect(() => {
40261
42344
  const interval = setInterval(() => {
40262
42345
  const w = window;
40263
42346
  const step = w.__orbitalWalkStep;
@@ -40693,15 +42776,15 @@ var init_EntitiesTab = __esm({
40693
42776
  });
40694
42777
  function EventFlowTab({ events: events2 }) {
40695
42778
  const { t } = useTranslate();
40696
- const [filter, setFilter] = React84.useState("all");
40697
- const containerRef = React84.useRef(null);
40698
- const [autoScroll, setAutoScroll] = React84.useState(true);
40699
- React84.useEffect(() => {
42779
+ const [filter, setFilter] = React95.useState("all");
42780
+ const containerRef = React95.useRef(null);
42781
+ const [autoScroll, setAutoScroll] = React95.useState(true);
42782
+ React95.useEffect(() => {
40700
42783
  if (autoScroll && containerRef.current) {
40701
42784
  containerRef.current.scrollTop = containerRef.current.scrollHeight;
40702
42785
  }
40703
42786
  }, [events2.length, autoScroll]);
40704
- const filteredEvents = React84.useMemo(() => {
42787
+ const filteredEvents = React95.useMemo(() => {
40705
42788
  if (filter === "all") return events2;
40706
42789
  return events2.filter((e) => e.type === filter);
40707
42790
  }, [events2, filter]);
@@ -40817,7 +42900,7 @@ var init_EventFlowTab = __esm({
40817
42900
  });
40818
42901
  function GuardsPanel({ guards }) {
40819
42902
  const { t } = useTranslate();
40820
- const [filter, setFilter] = React84.useState("all");
42903
+ const [filter, setFilter] = React95.useState("all");
40821
42904
  if (guards.length === 0) {
40822
42905
  return /* @__PURE__ */ jsx(
40823
42906
  EmptyState,
@@ -40830,7 +42913,7 @@ function GuardsPanel({ guards }) {
40830
42913
  }
40831
42914
  const passedCount = guards.filter((g) => g.result).length;
40832
42915
  const failedCount = guards.length - passedCount;
40833
- const filteredGuards = React84.useMemo(() => {
42916
+ const filteredGuards = React95.useMemo(() => {
40834
42917
  if (filter === "all") return guards;
40835
42918
  if (filter === "passed") return guards.filter((g) => g.result);
40836
42919
  return guards.filter((g) => !g.result);
@@ -40993,10 +43076,10 @@ function EffectBadge({ effect }) {
40993
43076
  }
40994
43077
  function TransitionTimeline({ transitions }) {
40995
43078
  const { t } = useTranslate();
40996
- const containerRef = React84.useRef(null);
40997
- const [autoScroll, setAutoScroll] = React84.useState(true);
40998
- const [expandedId, setExpandedId] = React84.useState(null);
40999
- React84.useEffect(() => {
43079
+ const containerRef = React95.useRef(null);
43080
+ const [autoScroll, setAutoScroll] = React95.useState(true);
43081
+ const [expandedId, setExpandedId] = React95.useState(null);
43082
+ React95.useEffect(() => {
41000
43083
  if (autoScroll && containerRef.current) {
41001
43084
  containerRef.current.scrollTop = containerRef.current.scrollHeight;
41002
43085
  }
@@ -41276,9 +43359,9 @@ function getAllEvents(traits2) {
41276
43359
  function EventDispatcherTab({ traits: traits2, schema }) {
41277
43360
  const eventBus = useEventBus();
41278
43361
  const { t } = useTranslate();
41279
- const [log9, setLog] = React84.useState([]);
41280
- const prevStatesRef = React84.useRef(/* @__PURE__ */ new Map());
41281
- React84.useEffect(() => {
43362
+ const [log9, setLog] = React95.useState([]);
43363
+ const prevStatesRef = React95.useRef(/* @__PURE__ */ new Map());
43364
+ React95.useEffect(() => {
41282
43365
  for (const trait of traits2) {
41283
43366
  const prev = prevStatesRef.current.get(trait.id);
41284
43367
  if (prev && prev !== trait.currentState) {
@@ -41447,10 +43530,10 @@ function VerifyModePanel({
41447
43530
  localCount
41448
43531
  }) {
41449
43532
  const { t } = useTranslate();
41450
- const [expanded, setExpanded] = React84.useState(true);
41451
- const scrollRef = React84.useRef(null);
41452
- const prevCountRef = React84.useRef(0);
41453
- React84.useEffect(() => {
43533
+ const [expanded, setExpanded] = React95.useState(true);
43534
+ const scrollRef = React95.useRef(null);
43535
+ const prevCountRef = React95.useRef(0);
43536
+ React95.useEffect(() => {
41454
43537
  if (expanded && transitions.length > prevCountRef.current && scrollRef.current) {
41455
43538
  scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
41456
43539
  }
@@ -41507,10 +43590,10 @@ function RuntimeDebugger({
41507
43590
  schema
41508
43591
  }) {
41509
43592
  const { t } = useTranslate();
41510
- const [isCollapsed, setIsCollapsed] = React84.useState(mode === "verify" ? true : defaultCollapsed);
41511
- const [isVisible, setIsVisible] = React84.useState(mode === "inline" || mode === "verify" || isDebugEnabled2());
43593
+ const [isCollapsed, setIsCollapsed] = React95.useState(mode === "verify" ? true : defaultCollapsed);
43594
+ const [isVisible, setIsVisible] = React95.useState(mode === "inline" || mode === "verify" || isDebugEnabled2());
41512
43595
  const debugData = useDebugData();
41513
- React84.useEffect(() => {
43596
+ React95.useEffect(() => {
41514
43597
  if (mode === "inline") return;
41515
43598
  return onDebugToggle((enabled) => {
41516
43599
  setIsVisible(enabled);
@@ -41519,7 +43602,7 @@ function RuntimeDebugger({
41519
43602
  }
41520
43603
  });
41521
43604
  }, [mode]);
41522
- React84.useEffect(() => {
43605
+ React95.useEffect(() => {
41523
43606
  if (mode === "inline") return;
41524
43607
  const handleKeyDown = (e) => {
41525
43608
  if (e.key === "`" && isVisible) {
@@ -42039,7 +44122,7 @@ var init_StatCard = __esm({
42039
44122
  const labelToUse = propLabel ?? propTitle;
42040
44123
  const eventBus = useEventBus();
42041
44124
  const { t } = useTranslate();
42042
- const handleActionClick = React84__default.useCallback(() => {
44125
+ const handleActionClick = React95__default.useCallback(() => {
42043
44126
  if (action?.event) {
42044
44127
  eventBus.emit(`UI:${action.event}`, {});
42045
44128
  }
@@ -42050,7 +44133,7 @@ var init_StatCard = __esm({
42050
44133
  const data = Array.isArray(entity) ? entity : entity ? [entity] : [];
42051
44134
  const isLoading = externalLoading ?? false;
42052
44135
  const error = externalError;
42053
- const computeMetricValue = React84__default.useCallback(
44136
+ const computeMetricValue = React95__default.useCallback(
42054
44137
  (metric, items) => {
42055
44138
  if (metric.value !== void 0) {
42056
44139
  return metric.value;
@@ -42089,7 +44172,7 @@ var init_StatCard = __esm({
42089
44172
  },
42090
44173
  []
42091
44174
  );
42092
- const schemaStats = React84__default.useMemo(() => {
44175
+ const schemaStats = React95__default.useMemo(() => {
42093
44176
  if (!metrics || metrics.length === 0) return null;
42094
44177
  return metrics.map((metric) => ({
42095
44178
  label: metric.label,
@@ -42097,7 +44180,7 @@ var init_StatCard = __esm({
42097
44180
  format: metric.format
42098
44181
  }));
42099
44182
  }, [metrics, data, computeMetricValue]);
42100
- const calculatedTrend = React84__default.useMemo(() => {
44183
+ const calculatedTrend = React95__default.useMemo(() => {
42101
44184
  if (manualTrend !== void 0) return manualTrend;
42102
44185
  if (previousValue === void 0 || currentValue === void 0)
42103
44186
  return void 0;
@@ -42737,8 +44820,8 @@ var init_SubagentTracePanel = __esm({
42737
44820
  ] });
42738
44821
  };
42739
44822
  InlineActivityStream = ({ activities, autoScroll = true, className }) => {
42740
- const endRef = React84__default.useRef(null);
42741
- React84__default.useEffect(() => {
44823
+ const endRef = React95__default.useRef(null);
44824
+ React95__default.useEffect(() => {
42742
44825
  if (!autoScroll) return;
42743
44826
  endRef.current?.scrollIntoView({ behavior: "smooth", block: "end" });
42744
44827
  }, [activities.length, autoScroll]);
@@ -42832,7 +44915,7 @@ var init_SubagentTracePanel = __esm({
42832
44915
  };
42833
44916
  SubagentRichCard = ({ subagent }) => {
42834
44917
  const { t } = useTranslate();
42835
- const activities = React84__default.useMemo(
44918
+ const activities = React95__default.useMemo(
42836
44919
  () => subagentMessagesToActivities(subagent.messages),
42837
44920
  [subagent.messages]
42838
44921
  );
@@ -42909,8 +44992,8 @@ var init_SubagentTracePanel = __esm({
42909
44992
  ] });
42910
44993
  };
42911
44994
  CoordinatorConversation = ({ messages, autoScroll = true, className }) => {
42912
- const endRef = React84__default.useRef(null);
42913
- React84__default.useEffect(() => {
44995
+ const endRef = React95__default.useRef(null);
44996
+ React95__default.useEffect(() => {
42914
44997
  if (!autoScroll) return;
42915
44998
  endRef.current?.scrollIntoView({ behavior: "smooth", block: "end" });
42916
44999
  }, [messages.length, autoScroll]);
@@ -43340,7 +45423,7 @@ var init_Timeline = __esm({
43340
45423
  }) => {
43341
45424
  const { t } = useTranslate();
43342
45425
  const entityData = entity ?? [];
43343
- const items = React84__default.useMemo(() => {
45426
+ const items = React95__default.useMemo(() => {
43344
45427
  if (propItems) return propItems;
43345
45428
  if (entityData.length === 0) return [];
43346
45429
  return entityData.map((record, idx) => {
@@ -43442,7 +45525,7 @@ var init_Timeline = __esm({
43442
45525
  }
43443
45526
  });
43444
45527
  function extractToastProps(children) {
43445
- if (!React84__default.isValidElement(children)) {
45528
+ if (!React95__default.isValidElement(children)) {
43446
45529
  if (typeof children === "string") {
43447
45530
  return { message: children };
43448
45531
  }
@@ -43484,7 +45567,7 @@ var init_ToastSlot = __esm({
43484
45567
  eventBus.emit(`${prefix}CLOSE`);
43485
45568
  };
43486
45569
  if (!isVisible) return null;
43487
- const isCustomContent = React84__default.isValidElement(children) && !message;
45570
+ const isCustomContent = React95__default.isValidElement(children) && !message;
43488
45571
  return /* @__PURE__ */ jsx(Box, { className: "fixed bottom-4 right-4 z-50", children: isCustomContent ? children : /* @__PURE__ */ jsx(
43489
45572
  Toast,
43490
45573
  {
@@ -43501,7 +45584,7 @@ var init_ToastSlot = __esm({
43501
45584
  }
43502
45585
  });
43503
45586
  function lazyThree(name, loader) {
43504
- const Lazy = React84__default.lazy(
45587
+ const Lazy = React95__default.lazy(
43505
45588
  () => loader().then((m) => {
43506
45589
  const Resolved = m[name];
43507
45590
  if (!Resolved) {
@@ -43513,13 +45596,13 @@ function lazyThree(name, loader) {
43513
45596
  })
43514
45597
  );
43515
45598
  function ThreeWrapper(props) {
43516
- return React84__default.createElement(
45599
+ return React95__default.createElement(
43517
45600
  ThreeBoundary,
43518
45601
  { name },
43519
- React84__default.createElement(
43520
- React84__default.Suspense,
45602
+ React95__default.createElement(
45603
+ React95__default.Suspense,
43521
45604
  { fallback: null },
43522
- React84__default.createElement(Lazy, props)
45605
+ React95__default.createElement(Lazy, props)
43523
45606
  )
43524
45607
  );
43525
45608
  }
@@ -43555,6 +45638,7 @@ var init_component_registry_generated = __esm({
43555
45638
  init_LayoutPatterns();
43556
45639
  init_BranchingLogicBuilder();
43557
45640
  init_Breadcrumb();
45641
+ init_BuilderBoard();
43558
45642
  init_CTABanner();
43559
45643
  init_CalendarGrid();
43560
45644
  init_Canvas2D();
@@ -43570,6 +45654,7 @@ var init_component_registry_generated = __esm({
43570
45654
  init_Checkbox();
43571
45655
  init_ChemistryCanvas();
43572
45656
  init_ChoiceButton();
45657
+ init_ClassifierBoard();
43573
45658
  init_CodeBlock();
43574
45659
  init_CodeRunnerPanel();
43575
45660
  init_ComboCounter();
@@ -43593,6 +45678,7 @@ var init_component_registry_generated = __esm({
43593
45678
  init_DateRangePicker();
43594
45679
  init_DateRangeSelector();
43595
45680
  init_DayCell();
45681
+ init_DebuggerBoard();
43596
45682
  init_DetailPanel();
43597
45683
  init_Dialog();
43598
45684
  init_DialogueBubble();
@@ -43608,6 +45694,7 @@ var init_component_registry_generated = __esm({
43608
45694
  init_EmptyState();
43609
45695
  init_ErrorBoundary();
43610
45696
  init_ErrorState();
45697
+ init_EventHandlerBoard();
43611
45698
  init_EventLog();
43612
45699
  init_FeatureCard();
43613
45700
  init_FeatureDetailPageTemplate();
@@ -43674,6 +45761,7 @@ var init_component_registry_generated = __esm({
43674
45761
  init_ModalSlot();
43675
45762
  init_ModuleCard();
43676
45763
  init_Navigation();
45764
+ init_NegotiatorBoard();
43677
45765
  init_NumberStepper();
43678
45766
  init_OptionConstraintGroup();
43679
45767
  init_OrbitalVisualization();
@@ -43712,6 +45800,7 @@ var init_component_registry_generated = __esm({
43712
45800
  init_SegmentRenderer();
43713
45801
  init_Select();
43714
45802
  init_SequenceBar();
45803
+ init_SequencerBoard();
43715
45804
  init_ServiceCatalog();
43716
45805
  init_ShowcaseCard();
43717
45806
  init_ShowcaseOrganism();
@@ -43720,6 +45809,7 @@ var init_component_registry_generated = __esm({
43720
45809
  init_SignaturePad();
43721
45810
  init_SimpleGrid();
43722
45811
  init_SimulationCanvas();
45812
+ init_SimulatorBoard();
43723
45813
  init_Skeleton();
43724
45814
  init_SocialProof();
43725
45815
  init_SortableList();
@@ -43733,6 +45823,7 @@ var init_component_registry_generated = __esm({
43733
45823
  init_StatBadge();
43734
45824
  init_StatCard();
43735
45825
  init_StatDisplay();
45826
+ init_StateArchitectBoard();
43736
45827
  init_StateIndicator();
43737
45828
  init_StateMachineView();
43738
45829
  init_StatsGrid();
@@ -43787,7 +45878,7 @@ var init_component_registry_generated = __esm({
43787
45878
  init_WizardContainer();
43788
45879
  init_WizardNavigation();
43789
45880
  init_WizardProgress();
43790
- ThreeBoundary = class extends React84__default.Component {
45881
+ ThreeBoundary = class extends React95__default.Component {
43791
45882
  constructor() {
43792
45883
  super(...arguments);
43793
45884
  __publicField(this, "state", { failed: false });
@@ -43797,7 +45888,7 @@ var init_component_registry_generated = __esm({
43797
45888
  }
43798
45889
  render() {
43799
45890
  if (this.state.failed) {
43800
- return React84__default.createElement(
45891
+ return React95__default.createElement(
43801
45892
  "div",
43802
45893
  {
43803
45894
  "data-testid": "three-unavailable",
@@ -43843,6 +45934,7 @@ var init_component_registry_generated = __esm({
43843
45934
  "BoxPattern": BoxPattern,
43844
45935
  "BranchingLogicBuilder": BranchingLogicBuilder,
43845
45936
  "Breadcrumb": Breadcrumb,
45937
+ "BuilderBoard": BuilderBoard,
43846
45938
  "Button": ButtonPattern,
43847
45939
  "ButtonPattern": ButtonPattern,
43848
45940
  "CTABanner": CTABanner,
@@ -43860,6 +45952,7 @@ var init_component_registry_generated = __esm({
43860
45952
  "Checkbox": Checkbox,
43861
45953
  "ChemistryCanvas": ChemistryCanvas,
43862
45954
  "ChoiceButton": ChoiceButton,
45955
+ "ClassifierBoard": ClassifierBoard,
43863
45956
  "CodeBlock": CodeBlock,
43864
45957
  "CodeRunnerPanel": CodeRunnerPanel,
43865
45958
  "ComboCounter": ComboCounter,
@@ -43883,6 +45976,7 @@ var init_component_registry_generated = __esm({
43883
45976
  "DateRangePicker": DateRangePicker,
43884
45977
  "DateRangeSelector": DateRangeSelector,
43885
45978
  "DayCell": DayCell,
45979
+ "DebuggerBoard": DebuggerBoard,
43886
45980
  "DetailPanel": DetailPanel,
43887
45981
  "Dialog": Dialog,
43888
45982
  "DialogueBubble": DialogueBubble,
@@ -43900,6 +45994,7 @@ var init_component_registry_generated = __esm({
43900
45994
  "EmptyState": EmptyState,
43901
45995
  "ErrorBoundary": ErrorBoundary,
43902
45996
  "ErrorState": ErrorState,
45997
+ "EventHandlerBoard": EventHandlerBoard,
43903
45998
  "EventLog": EventLog,
43904
45999
  "FeatureCard": FeatureCard,
43905
46000
  "FeatureDetailPageTemplate": FeatureDetailPageTemplate,
@@ -43974,6 +46069,7 @@ var init_component_registry_generated = __esm({
43974
46069
  "ModalSlot": ModalSlot,
43975
46070
  "ModuleCard": ModuleCard,
43976
46071
  "Navigation": Navigation,
46072
+ "NegotiatorBoard": NegotiatorBoard,
43977
46073
  "NumberStepper": NumberStepper,
43978
46074
  "OptionConstraintGroup": OptionConstraintGroup,
43979
46075
  "OrbitalVisualization": OrbitalVisualization,
@@ -44012,6 +46108,7 @@ var init_component_registry_generated = __esm({
44012
46108
  "SegmentRenderer": SegmentRenderer,
44013
46109
  "Select": Select,
44014
46110
  "SequenceBar": SequenceBar,
46111
+ "SequencerBoard": SequencerBoard,
44015
46112
  "ServiceCatalog": ServiceCatalog,
44016
46113
  "ShowcaseCard": ShowcaseCard,
44017
46114
  "ShowcaseOrganism": ShowcaseOrganism,
@@ -44020,6 +46117,7 @@ var init_component_registry_generated = __esm({
44020
46117
  "SignaturePad": SignaturePad,
44021
46118
  "SimpleGrid": SimpleGrid,
44022
46119
  "SimulationCanvas": SimulationCanvas,
46120
+ "SimulatorBoard": SimulatorBoard,
44023
46121
  "Skeleton": Skeleton,
44024
46122
  "SocialProof": SocialProof,
44025
46123
  "SortableList": SortableList,
@@ -44036,6 +46134,7 @@ var init_component_registry_generated = __esm({
44036
46134
  "StatBadge": StatBadge,
44037
46135
  "StatCard": StatCard,
44038
46136
  "StatDisplay": StatDisplay,
46137
+ "StateArchitectBoard": StateArchitectBoard,
44039
46138
  "StateIndicator": StateIndicator,
44040
46139
  "StateMachineView": StateMachineView,
44041
46140
  "StatsGrid": StatsGrid,
@@ -44109,7 +46208,7 @@ function SuspenseConfigProvider({
44109
46208
  config,
44110
46209
  children
44111
46210
  }) {
44112
- return React84__default.createElement(
46211
+ return React95__default.createElement(
44113
46212
  SuspenseConfigContext.Provider,
44114
46213
  { value: config },
44115
46214
  children
@@ -44151,7 +46250,7 @@ function enrichFormFields(fields, entityDef) {
44151
46250
  }
44152
46251
  return { name: field, label: field.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/\b\w/g, (c) => c.toUpperCase()) };
44153
46252
  }
44154
- if (field && typeof field === "object" && !Array.isArray(field) && !React84__default.isValidElement(field) && !(field instanceof Date)) {
46253
+ if (field && typeof field === "object" && !Array.isArray(field) && !React95__default.isValidElement(field) && !(field instanceof Date)) {
44155
46254
  const obj = field;
44156
46255
  const fieldName = typeof obj.name === "string" ? obj.name : typeof obj.field === "string" ? obj.field : void 0;
44157
46256
  if (!fieldName) return field;
@@ -44604,7 +46703,7 @@ function renderPatternChildren(children, onDismiss, parentId = "root", parentPat
44604
46703
  const key = `${parentId}-${index}-trait:${traitName}`;
44605
46704
  return /* @__PURE__ */ jsx(TraitFrame, { traitName }, key);
44606
46705
  }
44607
- return /* @__PURE__ */ jsx(React84__default.Fragment, { children: child }, `${parentId}-${index}`);
46706
+ return /* @__PURE__ */ jsx(React95__default.Fragment, { children: child }, `${parentId}-${index}`);
44608
46707
  }
44609
46708
  if (!child || typeof child !== "object") return null;
44610
46709
  const childId = `${parentId}-${index}`;
@@ -44644,14 +46743,14 @@ function isPatternConfig(value) {
44644
46743
  if (value === null || value === void 0) return false;
44645
46744
  if (typeof value !== "object") return false;
44646
46745
  if (Array.isArray(value)) return false;
44647
- if (React84__default.isValidElement(value)) return false;
46746
+ if (React95__default.isValidElement(value)) return false;
44648
46747
  if (value instanceof Date) return false;
44649
46748
  if (typeof value === "function") return false;
44650
46749
  const record = value;
44651
46750
  return "type" in record && typeof record.type === "string" && getComponentForPattern$1(record.type) !== null;
44652
46751
  }
44653
46752
  function isPlainConfigObject(value) {
44654
- if (React84__default.isValidElement(value)) return false;
46753
+ if (React95__default.isValidElement(value)) return false;
44655
46754
  if (value instanceof Date) return false;
44656
46755
  const proto = Object.getPrototypeOf(value);
44657
46756
  return proto === Object.prototype || proto === null;
@@ -44777,7 +46876,7 @@ function SlotContentRenderer({
44777
46876
  for (const slotKey of CONTENT_NODE_SLOTS) {
44778
46877
  const slotVal = restProps[slotKey];
44779
46878
  if (slotVal === void 0 || slotVal === null) continue;
44780
- if (React84__default.isValidElement(slotVal) || typeof slotVal === "string" || typeof slotVal === "number" || typeof slotVal === "boolean") continue;
46879
+ if (React95__default.isValidElement(slotVal) || typeof slotVal === "string" || typeof slotVal === "number" || typeof slotVal === "boolean") continue;
44781
46880
  if (Array.isArray(slotVal) || typeof slotVal === "object" && "type" in slotVal) {
44782
46881
  nodeSlotOverrides[slotKey] = renderPatternChildren(
44783
46882
  slotVal,
@@ -44826,7 +46925,7 @@ function SlotContentRenderer({
44826
46925
  const resolvedItems = Array.isArray(entityVal) && entityVal[0] !== "fn" ? entityVal : null;
44827
46926
  if (resolvedItems && resolvedItems.length > 0 && !finalProps.fields && !finalProps.columns) {
44828
46927
  const sample = resolvedItems[0];
44829
- if (sample && typeof sample === "object" && !Array.isArray(sample) && !React84__default.isValidElement(sample) && !(sample instanceof Date)) {
46928
+ if (sample && typeof sample === "object" && !Array.isArray(sample) && !React95__default.isValidElement(sample) && !(sample instanceof Date)) {
44830
46929
  const keys = Object.keys(sample).filter((k) => k !== "id" && k !== "_id");
44831
46930
  finalProps.fields = keys.map((k, i) => ({ name: k, variant: i === 0 ? "h4" : "body" }));
44832
46931
  }
@@ -45118,7 +47217,7 @@ function resolveLambdaBindings(body, params, item, index) {
45118
47217
  if (Array.isArray(body)) {
45119
47218
  return body.map((b) => recur(b));
45120
47219
  }
45121
- if (body !== null && typeof body === "object" && !React84__default.isValidElement(body) && !(body instanceof Date) && typeof body !== "function") {
47220
+ if (body !== null && typeof body === "object" && !React95__default.isValidElement(body) && !(body instanceof Date) && typeof body !== "function") {
45122
47221
  const out = {};
45123
47222
  for (const [k, v] of Object.entries(body)) {
45124
47223
  out[k] = recur(v);
@@ -45137,7 +47236,7 @@ function getSlotContentRenderer2() {
45137
47236
  function makeLambdaFn(params, lambdaBody, callerKey) {
45138
47237
  return (item, index) => {
45139
47238
  const resolvedBody = resolveLambdaBindings(lambdaBody, params, item, index);
45140
- if (resolvedBody === null || typeof resolvedBody !== "object" || Array.isArray(resolvedBody) || typeof resolvedBody === "function" || React84__default.isValidElement(resolvedBody) || resolvedBody instanceof Date) {
47239
+ if (resolvedBody === null || typeof resolvedBody !== "object" || Array.isArray(resolvedBody) || typeof resolvedBody === "function" || React95__default.isValidElement(resolvedBody) || resolvedBody instanceof Date) {
45141
47240
  return null;
45142
47241
  }
45143
47242
  const record = resolvedBody;
@@ -45156,7 +47255,7 @@ function makeLambdaFn(params, lambdaBody, callerKey) {
45156
47255
  props: childProps,
45157
47256
  priority: 0
45158
47257
  };
45159
- return React84__default.createElement(SlotContentRenderer2, { content: childContent });
47258
+ return React95__default.createElement(SlotContentRenderer2, { content: childContent });
45160
47259
  };
45161
47260
  }
45162
47261
  function convertNode(node, callerKey) {
@@ -45175,7 +47274,7 @@ function convertNode(node, callerKey) {
45175
47274
  });
45176
47275
  return anyChanged ? mapped : node;
45177
47276
  }
45178
- if (typeof node === "object" && !React84__default.isValidElement(node) && !(node instanceof Date)) {
47277
+ if (typeof node === "object" && !React95__default.isValidElement(node) && !(node instanceof Date)) {
45179
47278
  return convertObjectProps(node);
45180
47279
  }
45181
47280
  return node;
@@ -46321,11 +48420,11 @@ function buildMockData(schema) {
46321
48420
  result[entityName] = entity.instances;
46322
48421
  continue;
46323
48422
  }
46324
- const rows = Array.from(
48423
+ const rows2 = Array.from(
46325
48424
  { length: 10 },
46326
48425
  (_, i) => generateEntityRow(entity, i + 1)
46327
48426
  );
46328
- result[entityName] = rows;
48427
+ result[entityName] = rows2;
46329
48428
  }
46330
48429
  for (const orbital of schema.orbitals) {
46331
48430
  for (const traitRef of orbital.traits ?? []) {