@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,11 +1,11 @@
1
- import * as React86 from 'react';
2
- import React86__default, { createContext, useContext, useMemo, useRef, useEffect, useCallback, Suspense, useState, useLayoutEffect, lazy, useId, useSyncExternalStore } from 'react';
1
+ import * as React97 from 'react';
2
+ import React97__default, { createContext, useContext, useMemo, useRef, useEffect, useCallback, Suspense, useState, useLayoutEffect, lazy, useId, useSyncExternalStore } from 'react';
3
3
  import { EventBusContext, useTraitScope, useEntitySchemaOptional, TraitScopeProvider, useCurrentPagePath } from '@almadar/ui/providers';
4
4
  import { createLogger, isLogLevelEnabled } from '@almadar/logger';
5
5
  import { clsx } from 'clsx';
6
6
  import { twMerge } from 'tailwind-merge';
7
7
  import * as LucideIcons2 from 'lucide-react';
8
- 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';
8
+ 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';
9
9
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
10
10
  import { createPortal } from 'react-dom';
11
11
  import { useTranslate } from '@almadar/ui/hooks';
@@ -388,7 +388,7 @@ var init_Box = __esm({
388
388
  fixed: "fixed",
389
389
  sticky: "sticky"
390
390
  };
391
- Box = React86__default.forwardRef(
391
+ Box = React97__default.forwardRef(
392
392
  ({
393
393
  padding,
394
394
  paddingX,
@@ -453,7 +453,7 @@ var init_Box = __esm({
453
453
  onPointerDown?.(e);
454
454
  }, [hoverEvent, tapReveal, triggerProps, onPointerDown]);
455
455
  const isClickable = action || onClick;
456
- return React86__default.createElement(
456
+ return React97__default.createElement(
457
457
  Component,
458
458
  {
459
459
  ref,
@@ -549,7 +549,7 @@ function loadLib(key, importer) {
549
549
  return p;
550
550
  }
551
551
  function lazyFamilyIcon(libKey, importer, pick, fallbackName, family) {
552
- const Lazy = React86__default.lazy(async () => {
552
+ const Lazy = React97__default.lazy(async () => {
553
553
  const lib = await loadLib(libKey, importer);
554
554
  const Comp = pick(lib);
555
555
  if (!Comp) {
@@ -559,7 +559,7 @@ function lazyFamilyIcon(libKey, importer, pick, fallbackName, family) {
559
559
  return { default: Comp };
560
560
  });
561
561
  const Wrapped = (props) => /* @__PURE__ */ jsx(
562
- React86__default.Suspense,
562
+ React97__default.Suspense,
563
563
  {
564
564
  fallback: /* @__PURE__ */ jsx(
565
565
  "span",
@@ -1290,7 +1290,7 @@ var init_Icon = __esm({
1290
1290
  const directIcon = typeof icon === "string" ? void 0 : icon;
1291
1291
  const effectiveName = typeof icon === "string" ? icon : name;
1292
1292
  const family = useIconFamily();
1293
- const RenderedComponent = React86__default.useMemo(() => {
1293
+ const RenderedComponent = React97__default.useMemo(() => {
1294
1294
  if (directIcon) return null;
1295
1295
  return effectiveName ? resolveIconForFamily(effectiveName, family) : null;
1296
1296
  }, [directIcon, effectiveName, family]);
@@ -1352,7 +1352,7 @@ function resolveIconProp(value, sizeClass) {
1352
1352
  const IconComp = value;
1353
1353
  return /* @__PURE__ */ jsx(IconComp, { className: sizeClass });
1354
1354
  }
1355
- if (React86__default.isValidElement(value)) {
1355
+ if (React97__default.isValidElement(value)) {
1356
1356
  return value;
1357
1357
  }
1358
1358
  if (typeof value === "object" && value !== null && isIconLike(value)) {
@@ -1428,7 +1428,7 @@ var init_Button = __esm({
1428
1428
  md: "h-icon-default w-icon-default",
1429
1429
  lg: "h-icon-default w-icon-default"
1430
1430
  };
1431
- Button = React86__default.forwardRef(
1431
+ Button = React97__default.forwardRef(
1432
1432
  ({
1433
1433
  className,
1434
1434
  variant = "primary",
@@ -1496,7 +1496,7 @@ var Dialog;
1496
1496
  var init_Dialog = __esm({
1497
1497
  "components/core/atoms/Dialog.tsx"() {
1498
1498
  init_cn();
1499
- Dialog = React86__default.forwardRef(
1499
+ Dialog = React97__default.forwardRef(
1500
1500
  ({
1501
1501
  role = "dialog",
1502
1502
  "aria-modal": ariaModal = true,
@@ -1614,7 +1614,7 @@ var init_Typography = __esm({
1614
1614
  }) => {
1615
1615
  const variant = variantProp ?? (level ? `h${level}` : "body1");
1616
1616
  const Component = as || defaultElements[variant];
1617
- return React86__default.createElement(
1617
+ return React97__default.createElement(
1618
1618
  Component,
1619
1619
  {
1620
1620
  id,
@@ -2109,7 +2109,7 @@ var init_Badge = __esm({
2109
2109
  md: "px-2.5 py-1 text-sm",
2110
2110
  lg: "px-3 py-1.5 text-base"
2111
2111
  };
2112
- Badge = React86__default.forwardRef(
2112
+ Badge = React97__default.forwardRef(
2113
2113
  ({ className, variant = "default", size = "sm", amount, label, icon, iconAsset, children, onRemove, removeLabel, ...props }, ref) => {
2114
2114
  const iconSizes3 = {
2115
2115
  sm: "h-icon-default w-icon-default",
@@ -2446,7 +2446,7 @@ var init_SvgFlow = __esm({
2446
2446
  width = 100,
2447
2447
  height = 100
2448
2448
  }) => {
2449
- const markerId = React86__default.useMemo(() => {
2449
+ const markerId = React97__default.useMemo(() => {
2450
2450
  flowIdCounter += 1;
2451
2451
  return `almadar-flow-arrow-${flowIdCounter}`;
2452
2452
  }, []);
@@ -2499,7 +2499,7 @@ var init_SvgGrid = __esm({
2499
2499
  x = 10,
2500
2500
  y = 10,
2501
2501
  cols = 4,
2502
- rows = 3,
2502
+ rows: rows2 = 3,
2503
2503
  spacing = 20,
2504
2504
  nodeRadius = 3,
2505
2505
  color = "var(--color-primary)",
@@ -2511,7 +2511,7 @@ var init_SvgGrid = __esm({
2511
2511
  height = 100
2512
2512
  }) => {
2513
2513
  const highlightSet = new Set(highlights);
2514
- const inner = /* @__PURE__ */ jsx("g", { className, opacity, children: Array.from({ length: rows }).map(
2514
+ const inner = /* @__PURE__ */ jsx("g", { className, opacity, children: Array.from({ length: rows2 }).map(
2515
2515
  (_, row) => Array.from({ length: cols }).map((_2, col) => {
2516
2516
  const index = row * cols + col;
2517
2517
  const isHighlighted = highlightSet.has(index);
@@ -3039,7 +3039,7 @@ var init_SvgRing = __esm({
3039
3039
  width = 100,
3040
3040
  height = 100
3041
3041
  }) => {
3042
- const gradientId = React86__default.useMemo(() => {
3042
+ const gradientId = React97__default.useMemo(() => {
3043
3043
  ringIdCounter += 1;
3044
3044
  return `almadar-ring-glow-${ringIdCounter}`;
3045
3045
  }, []);
@@ -3220,7 +3220,7 @@ var init_Input = __esm({
3220
3220
  init_cn();
3221
3221
  init_Icon();
3222
3222
  init_useEventBus();
3223
- Input = React86__default.forwardRef(
3223
+ Input = React97__default.forwardRef(
3224
3224
  ({
3225
3225
  className,
3226
3226
  inputType,
@@ -3235,7 +3235,7 @@ var init_Input = __esm({
3235
3235
  onClear,
3236
3236
  value,
3237
3237
  options,
3238
- rows = 3,
3238
+ rows: rows2 = 3,
3239
3239
  onChange,
3240
3240
  ...props
3241
3241
  }, ref) => {
@@ -3317,7 +3317,7 @@ var init_Input = __esm({
3317
3317
  ref,
3318
3318
  value,
3319
3319
  onChange: handleChange,
3320
- rows,
3320
+ rows: rows2,
3321
3321
  className: baseClassName,
3322
3322
  ...props
3323
3323
  }
@@ -3380,7 +3380,7 @@ var Label;
3380
3380
  var init_Label = __esm({
3381
3381
  "components/core/atoms/Label.tsx"() {
3382
3382
  init_cn();
3383
- Label = React86__default.forwardRef(
3383
+ Label = React97__default.forwardRef(
3384
3384
  ({ className, required, children, ...props }, ref) => {
3385
3385
  return /* @__PURE__ */ jsxs(
3386
3386
  "label",
@@ -3407,7 +3407,7 @@ var init_Textarea = __esm({
3407
3407
  "components/core/atoms/Textarea.tsx"() {
3408
3408
  init_cn();
3409
3409
  init_useEventBus();
3410
- Textarea = React86__default.forwardRef(
3410
+ Textarea = React97__default.forwardRef(
3411
3411
  ({ className, error, onChange, ...props }, ref) => {
3412
3412
  const eventBus = useEventBus();
3413
3413
  const handleChange = (e) => {
@@ -3646,7 +3646,7 @@ var init_Select = __esm({
3646
3646
  init_cn();
3647
3647
  init_Icon();
3648
3648
  init_useEventBus();
3649
- Select = React86__default.forwardRef(
3649
+ Select = React97__default.forwardRef(
3650
3650
  (props, _ref) => {
3651
3651
  const { multiple, searchable, clearable } = props;
3652
3652
  if (multiple || searchable || clearable) {
@@ -3663,7 +3663,7 @@ var init_Checkbox = __esm({
3663
3663
  "components/core/atoms/Checkbox.tsx"() {
3664
3664
  init_cn();
3665
3665
  init_useEventBus();
3666
- Checkbox = React86__default.forwardRef(
3666
+ Checkbox = React97__default.forwardRef(
3667
3667
  ({ className, label, id, onChange, ...props }, ref) => {
3668
3668
  const inputId = id || `checkbox-${Math.random().toString(36).substr(2, 9)}`;
3669
3669
  const eventBus = useEventBus();
@@ -3717,7 +3717,7 @@ var init_Spinner = __esm({
3717
3717
  md: "h-6 w-6",
3718
3718
  lg: "h-8 w-8"
3719
3719
  };
3720
- Spinner = React86__default.forwardRef(
3720
+ Spinner = React97__default.forwardRef(
3721
3721
  ({ className, size = "md", overlay, ...props }, ref) => {
3722
3722
  if (overlay) {
3723
3723
  return /* @__PURE__ */ jsx(
@@ -3807,7 +3807,7 @@ var init_Card = __esm({
3807
3807
  chip: "shadow-none rounded-pill border-[length:var(--border-width)] border-border",
3808
3808
  "tile-image-first": "p-0 overflow-hidden"
3809
3809
  };
3810
- Card = React86__default.forwardRef(
3810
+ Card = React97__default.forwardRef(
3811
3811
  ({
3812
3812
  className,
3813
3813
  variant = "bordered",
@@ -3855,9 +3855,9 @@ var init_Card = __esm({
3855
3855
  }
3856
3856
  );
3857
3857
  Card.displayName = "Card";
3858
- CardHeader = React86__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("mb-4", className), ...props }));
3858
+ CardHeader = React97__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("mb-4", className), ...props }));
3859
3859
  CardHeader.displayName = "CardHeader";
3860
- CardTitle = React86__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
3860
+ CardTitle = React97__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
3861
3861
  "h3",
3862
3862
  {
3863
3863
  ref,
@@ -3870,11 +3870,11 @@ var init_Card = __esm({
3870
3870
  }
3871
3871
  ));
3872
3872
  CardTitle.displayName = "CardTitle";
3873
- CardContent = React86__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("", className), ...props }));
3873
+ CardContent = React97__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("", className), ...props }));
3874
3874
  CardContent.displayName = "CardContent";
3875
3875
  CardBody = CardContent;
3876
3876
  CardBody.displayName = "CardBody";
3877
- CardFooter = React86__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
3877
+ CardFooter = React97__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
3878
3878
  "div",
3879
3879
  {
3880
3880
  ref,
@@ -3929,7 +3929,7 @@ var init_FilterPill = __esm({
3929
3929
  md: "w-3.5 h-3.5",
3930
3930
  lg: "w-4 h-4"
3931
3931
  };
3932
- FilterPill = React86__default.forwardRef(
3932
+ FilterPill = React97__default.forwardRef(
3933
3933
  ({
3934
3934
  className,
3935
3935
  variant = "default",
@@ -4058,8 +4058,8 @@ var init_Avatar = __esm({
4058
4058
  actionPayload
4059
4059
  }) => {
4060
4060
  const eventBus = useEventBus();
4061
- const [imgFailed, setImgFailed] = React86__default.useState(false);
4062
- React86__default.useEffect(() => {
4061
+ const [imgFailed, setImgFailed] = React97__default.useState(false);
4062
+ React97__default.useEffect(() => {
4063
4063
  setImgFailed(false);
4064
4064
  }, [src]);
4065
4065
  const initials = providedInitials ?? (name ? generateInitials(name) : void 0);
@@ -4172,7 +4172,7 @@ var init_Center = __esm({
4172
4172
  as: Component = "div"
4173
4173
  }) => {
4174
4174
  const mergedStyle = minHeight ? { minHeight, ...style } : style;
4175
- return React86__default.createElement(Component, {
4175
+ return React97__default.createElement(Component, {
4176
4176
  className: cn(
4177
4177
  inline ? "inline-flex" : "flex",
4178
4178
  horizontal && "justify-center",
@@ -4440,7 +4440,7 @@ var init_Radio = __esm({
4440
4440
  md: "w-2.5 h-2.5",
4441
4441
  lg: "w-3 h-3"
4442
4442
  };
4443
- Radio = React86__default.forwardRef(
4443
+ Radio = React97__default.forwardRef(
4444
4444
  ({
4445
4445
  label,
4446
4446
  helperText,
@@ -4457,12 +4457,12 @@ var init_Radio = __esm({
4457
4457
  onChange,
4458
4458
  ...props
4459
4459
  }, ref) => {
4460
- const reactId = React86__default.useId();
4460
+ const reactId = React97__default.useId();
4461
4461
  const baseId = id || `radio-${reactId}`;
4462
4462
  const hasError = !!error;
4463
4463
  const eventBus = useEventBus();
4464
- const [selected, setSelected] = React86__default.useState(value);
4465
- React86__default.useEffect(() => {
4464
+ const [selected, setSelected] = React97__default.useState(value);
4465
+ React97__default.useEffect(() => {
4466
4466
  if (value !== void 0) setSelected(value);
4467
4467
  }, [value]);
4468
4468
  const pick = (next, e) => {
@@ -4644,7 +4644,7 @@ var init_Switch = __esm({
4644
4644
  "components/core/atoms/Switch.tsx"() {
4645
4645
  "use client";
4646
4646
  init_cn();
4647
- Switch = React86.forwardRef(
4647
+ Switch = React97.forwardRef(
4648
4648
  ({
4649
4649
  checked,
4650
4650
  defaultChecked = false,
@@ -4655,10 +4655,10 @@ var init_Switch = __esm({
4655
4655
  name,
4656
4656
  className
4657
4657
  }, ref) => {
4658
- const [isChecked, setIsChecked] = React86.useState(
4658
+ const [isChecked, setIsChecked] = React97.useState(
4659
4659
  checked !== void 0 ? checked : defaultChecked
4660
4660
  );
4661
- React86.useEffect(() => {
4661
+ React97.useEffect(() => {
4662
4662
  if (checked !== void 0) {
4663
4663
  setIsChecked(checked);
4664
4664
  }
@@ -4821,7 +4821,7 @@ var init_Stack = __esm({
4821
4821
  };
4822
4822
  const isHorizontal = direction === "horizontal";
4823
4823
  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";
4824
- return React86__default.createElement(
4824
+ return React97__default.createElement(
4825
4825
  Component,
4826
4826
  {
4827
4827
  className: cn(
@@ -5021,7 +5021,7 @@ var Aside;
5021
5021
  var init_Aside = __esm({
5022
5022
  "components/core/atoms/Aside.tsx"() {
5023
5023
  init_cn();
5024
- Aside = React86__default.forwardRef(
5024
+ Aside = React97__default.forwardRef(
5025
5025
  ({ className, children, ...rest }, ref) => /* @__PURE__ */ jsx("aside", { ref, className: cn(className), ...rest, children })
5026
5026
  );
5027
5027
  Aside.displayName = "Aside";
@@ -5100,9 +5100,9 @@ var init_LawReferenceTooltip = __esm({
5100
5100
  className
5101
5101
  }) => {
5102
5102
  const { t } = useTranslate();
5103
- const [isVisible, setIsVisible] = React86__default.useState(false);
5104
- const timeoutRef = React86__default.useRef(null);
5105
- const triggerRef = React86__default.useRef(null);
5103
+ const [isVisible, setIsVisible] = React97__default.useState(false);
5104
+ const timeoutRef = React97__default.useRef(null);
5105
+ const triggerRef = React97__default.useRef(null);
5106
5106
  const handleMouseEnter = () => {
5107
5107
  if (timeoutRef.current) clearTimeout(timeoutRef.current);
5108
5108
  timeoutRef.current = setTimeout(() => setIsVisible(true), 200);
@@ -5113,7 +5113,7 @@ var init_LawReferenceTooltip = __esm({
5113
5113
  };
5114
5114
  const { revealed, triggerProps } = useTapReveal({ refs: [triggerRef] });
5115
5115
  const open = isVisible || revealed;
5116
- React86__default.useEffect(() => {
5116
+ React97__default.useEffect(() => {
5117
5117
  return () => {
5118
5118
  if (timeoutRef.current) clearTimeout(timeoutRef.current);
5119
5119
  };
@@ -5323,7 +5323,7 @@ var init_StatusDot = __esm({
5323
5323
  md: "w-2.5 h-2.5",
5324
5324
  lg: "w-3 h-3"
5325
5325
  };
5326
- StatusDot = React86__default.forwardRef(
5326
+ StatusDot = React97__default.forwardRef(
5327
5327
  ({ className, status = "offline", pulse = false, size = "md", label, ...props }, ref) => {
5328
5328
  return /* @__PURE__ */ jsx(
5329
5329
  "span",
@@ -5377,7 +5377,7 @@ var init_TrendIndicator = __esm({
5377
5377
  down: "trending-down",
5378
5378
  flat: "arrow-right"
5379
5379
  };
5380
- TrendIndicator = React86__default.forwardRef(
5380
+ TrendIndicator = React97__default.forwardRef(
5381
5381
  ({
5382
5382
  className,
5383
5383
  value,
@@ -5444,7 +5444,7 @@ var init_RangeSlider = __esm({
5444
5444
  md: "w-4 h-4",
5445
5445
  lg: "w-5 h-5"
5446
5446
  };
5447
- RangeSlider = React86__default.forwardRef(
5447
+ RangeSlider = React97__default.forwardRef(
5448
5448
  ({
5449
5449
  className,
5450
5450
  min = 0,
@@ -6038,7 +6038,7 @@ var init_ContentSection = __esm({
6038
6038
  md: "py-16",
6039
6039
  lg: "py-24"
6040
6040
  };
6041
- ContentSection = React86__default.forwardRef(
6041
+ ContentSection = React97__default.forwardRef(
6042
6042
  ({ children, background = "default", padding = "lg", id, className }, ref) => {
6043
6043
  return /* @__PURE__ */ jsx(
6044
6044
  Box,
@@ -6572,7 +6572,7 @@ var init_AnimatedReveal = __esm({
6572
6572
  "scale-up": { opacity: 1, transform: "scale(1) translateY(0)" },
6573
6573
  "none": {}
6574
6574
  };
6575
- AnimatedReveal = React86__default.forwardRef(
6575
+ AnimatedReveal = React97__default.forwardRef(
6576
6576
  ({
6577
6577
  trigger = "scroll",
6578
6578
  animation = "fade-up",
@@ -6732,7 +6732,7 @@ var init_AnimatedGraphic = __esm({
6732
6732
  "components/marketing/atoms/AnimatedGraphic.tsx"() {
6733
6733
  "use client";
6734
6734
  init_cn();
6735
- AnimatedGraphic = React86__default.forwardRef(
6735
+ AnimatedGraphic = React97__default.forwardRef(
6736
6736
  ({
6737
6737
  src,
6738
6738
  svgContent,
@@ -6755,7 +6755,7 @@ var init_AnimatedGraphic = __esm({
6755
6755
  const fetchedSvg = useFetchedSvg(svgContent ? void 0 : src);
6756
6756
  const resolvedSvg = svgContent ?? fetchedSvg;
6757
6757
  const prevAnimateRef = useRef(animate);
6758
- const setRef = React86__default.useCallback(
6758
+ const setRef = React97__default.useCallback(
6759
6759
  (node) => {
6760
6760
  containerRef.current = node;
6761
6761
  if (typeof ref === "function") ref(node);
@@ -6903,6 +6903,20 @@ var init_effects = __esm({
6903
6903
  });
6904
6904
 
6905
6905
  // components/game/shared/boardEntity.ts
6906
+ function boardEntity(entity) {
6907
+ if (!entity) return void 0;
6908
+ return Array.isArray(entity) ? entity[0] : entity;
6909
+ }
6910
+ function str(v) {
6911
+ return v == null ? "" : String(v);
6912
+ }
6913
+ function num(v, fallback = 0) {
6914
+ const n = Number(v);
6915
+ return Number.isFinite(n) ? n : fallback;
6916
+ }
6917
+ function rows(v) {
6918
+ return Array.isArray(v) ? v : [];
6919
+ }
6906
6920
  var init_boardEntity = __esm({
6907
6921
  "components/game/shared/boardEntity.ts"() {
6908
6922
  }
@@ -7336,7 +7350,7 @@ function GameCard({
7336
7350
  className
7337
7351
  }) {
7338
7352
  const eventBus = useEventBus();
7339
- const handleClick = React86.useCallback(() => {
7353
+ const handleClick = React97.useCallback(() => {
7340
7354
  if (disabled) return;
7341
7355
  onClick?.(id);
7342
7356
  if (clickEvent) eventBus.emit(`UI:${clickEvent}`, { cardId: id });
@@ -7618,9 +7632,9 @@ function ControlButton({
7618
7632
  className
7619
7633
  }) {
7620
7634
  const eventBus = useEventBus();
7621
- const [isPressed, setIsPressed] = React86.useState(false);
7635
+ const [isPressed, setIsPressed] = React97.useState(false);
7622
7636
  const actualPressed = pressed ?? isPressed;
7623
- const handlePointerDown = React86.useCallback(
7637
+ const handlePointerDown = React97.useCallback(
7624
7638
  (e) => {
7625
7639
  e.preventDefault();
7626
7640
  if (disabled) return;
@@ -7630,7 +7644,7 @@ function ControlButton({
7630
7644
  },
7631
7645
  [disabled, pressEvent, eventBus, onPress]
7632
7646
  );
7633
- const handlePointerUp = React86.useCallback(
7647
+ const handlePointerUp = React97.useCallback(
7634
7648
  (e) => {
7635
7649
  e.preventDefault();
7636
7650
  if (disabled) return;
@@ -7640,7 +7654,7 @@ function ControlButton({
7640
7654
  },
7641
7655
  [disabled, releaseEvent, eventBus, onRelease]
7642
7656
  );
7643
- const handlePointerLeave = React86.useCallback(
7657
+ const handlePointerLeave = React97.useCallback(
7644
7658
  (e) => {
7645
7659
  if (isPressed) {
7646
7660
  setIsPressed(false);
@@ -8659,8 +8673,8 @@ function MiniMap({
8659
8673
  tileAssets,
8660
8674
  unitAssets
8661
8675
  }) {
8662
- const canvasRef = React86.useRef(null);
8663
- const imgCacheRef = React86.useRef(/* @__PURE__ */ new Map());
8676
+ const canvasRef = React97.useRef(null);
8677
+ const imgCacheRef = React97.useRef(/* @__PURE__ */ new Map());
8664
8678
  function loadImg(url) {
8665
8679
  const cached = imgCacheRef.current.get(url);
8666
8680
  if (cached) return cached.complete ? cached : null;
@@ -8675,7 +8689,7 @@ function MiniMap({
8675
8689
  imgCacheRef.current.set(url, img);
8676
8690
  return null;
8677
8691
  }
8678
- React86.useEffect(() => {
8692
+ React97.useEffect(() => {
8679
8693
  const canvas = canvasRef.current;
8680
8694
  if (!canvas) return;
8681
8695
  const ctx = canvas.getContext("2d");
@@ -8810,8 +8824,8 @@ function ControlGrid({
8810
8824
  className
8811
8825
  }) {
8812
8826
  const eventBus = useEventBus();
8813
- const [active, setActive] = React86.useState(/* @__PURE__ */ new Set());
8814
- const handlePress = React86.useCallback(
8827
+ const [active, setActive] = React97.useState(/* @__PURE__ */ new Set());
8828
+ const handlePress = React97.useCallback(
8815
8829
  (id) => {
8816
8830
  setActive((prev) => new Set(prev).add(id));
8817
8831
  if (actionEvent) eventBus.emit(`UI:${actionEvent}`, { id, pressed: true });
@@ -8825,7 +8839,7 @@ function ControlGrid({
8825
8839
  },
8826
8840
  [kind, actionEvent, directionEvent, directionEvents, eventBus, onAction, onDirection]
8827
8841
  );
8828
- const handleRelease = React86.useCallback(
8842
+ const handleRelease = React97.useCallback(
8829
8843
  (id) => {
8830
8844
  setActive((prev) => {
8831
8845
  const next = new Set(prev);
@@ -9083,7 +9097,7 @@ function InventoryGrid({
9083
9097
  const eventBus = useEventBus();
9084
9098
  const slotCount = totalSlots ?? items.length;
9085
9099
  const emptySlotCount = Math.max(0, slotCount - items.length);
9086
- const handleSelect = React86.useCallback(
9100
+ const handleSelect = React97.useCallback(
9087
9101
  (id) => {
9088
9102
  onSelect?.(id);
9089
9103
  if (selectEvent) {
@@ -9300,7 +9314,7 @@ function GameMenu({
9300
9314
  }) {
9301
9315
  const resolvedOptions = options ?? menuItems ?? DEFAULT_MENU_OPTIONS;
9302
9316
  const eventBus = useEventBus();
9303
- const handleOptionClick = React86.useCallback(
9317
+ const handleOptionClick = React97.useCallback(
9304
9318
  (option) => {
9305
9319
  if (option.event) {
9306
9320
  eventBus.emit(`UI:${option.event}`, { option });
@@ -10974,7 +10988,7 @@ function LinearView({
10974
10988
  /* @__PURE__ */ jsx(HStack, { className: "flex-wrap items-center", gap: "xs", children: trait.states.map((state, i) => {
10975
10989
  const isDone = i < currentIdx;
10976
10990
  const isCurrent = i === currentIdx;
10977
- return /* @__PURE__ */ jsxs(React86__default.Fragment, { children: [
10991
+ return /* @__PURE__ */ jsxs(React97__default.Fragment, { children: [
10978
10992
  i > 0 && /* @__PURE__ */ jsx(
10979
10993
  Typography,
10980
10994
  {
@@ -11171,7 +11185,7 @@ function TraitStateViewer({
11171
11185
  }
11172
11186
  var SIZE_CONFIG;
11173
11187
  var init_TraitStateViewer = __esm({
11174
- "components/game/2d/molecules/TraitStateViewer.tsx"() {
11188
+ "components/game/2d/organisms/TraitStateViewer.tsx"() {
11175
11189
  "use client";
11176
11190
  init_cn();
11177
11191
  init_Box();
@@ -11378,7 +11392,7 @@ function TraitSlot({
11378
11392
  }
11379
11393
  var SIZE_CONFIG2, DRAG_MIME;
11380
11394
  var init_TraitSlot = __esm({
11381
- "components/game/2d/molecules/TraitSlot.tsx"() {
11395
+ "components/game/2d/organisms/TraitSlot.tsx"() {
11382
11396
  "use client";
11383
11397
  init_cn();
11384
11398
  init_useEventBus();
@@ -11437,7 +11451,7 @@ function ActionTile({
11437
11451
  }
11438
11452
  var DRAG_MIME2, SIZE_CONFIG3;
11439
11453
  var init_ActionTile = __esm({
11440
- "components/game/2d/molecules/ActionTile.tsx"() {
11454
+ "components/game/2d/organisms/ActionTile.tsx"() {
11441
11455
  init_atoms();
11442
11456
  init_cn();
11443
11457
  DRAG_MIME2 = "application/x-almadar-slot-item";
@@ -11474,7 +11488,7 @@ function ActionPalette({
11474
11488
  ] });
11475
11489
  }
11476
11490
  var init_ActionPalette = __esm({
11477
- "components/game/2d/molecules/ActionPalette.tsx"() {
11491
+ "components/game/2d/organisms/ActionPalette.tsx"() {
11478
11492
  init_atoms();
11479
11493
  init_cn();
11480
11494
  init_ActionTile();
@@ -11486,8 +11500,6 @@ function SequenceBar({
11486
11500
  maxSlots,
11487
11501
  onSlotDrop,
11488
11502
  onSlotRemove,
11489
- slotDropEvent,
11490
- slotRemoveEvent,
11491
11503
  playing = false,
11492
11504
  currentStep = -1,
11493
11505
  categoryColors,
@@ -11495,19 +11507,16 @@ function SequenceBar({
11495
11507
  size = "lg",
11496
11508
  className
11497
11509
  }) {
11498
- const { emit } = useEventBus();
11499
11510
  const handleDrop = useCallback((index) => (item) => {
11500
11511
  if (playing) return;
11501
- if (slotDropEvent) emit(`UI:${slotDropEvent}`, { slotIndex: index, actionId: item.id });
11502
- onSlotDrop?.(index, item);
11503
- }, [onSlotDrop, slotDropEvent, emit, playing]);
11512
+ onSlotDrop(index, item);
11513
+ }, [onSlotDrop, playing]);
11504
11514
  const handleRemove = useCallback((index) => () => {
11505
11515
  if (playing) return;
11506
- if (slotRemoveEvent) emit(`UI:${slotRemoveEvent}`, { slotIndex: index });
11507
- onSlotRemove?.(index);
11508
- }, [onSlotRemove, slotRemoveEvent, emit, playing]);
11516
+ onSlotRemove(index);
11517
+ }, [onSlotRemove, playing]);
11509
11518
  const paddedSlots = Array.from({ length: maxSlots }, (_, i) => slots[i]);
11510
- return /* @__PURE__ */ jsx(HStack, { className: cn("items-center", className), gap: "sm", children: paddedSlots.map((slot, i) => /* @__PURE__ */ jsxs(React86__default.Fragment, { children: [
11519
+ return /* @__PURE__ */ jsx(HStack, { className: cn("items-center", className), gap: "sm", children: paddedSlots.map((slot, i) => /* @__PURE__ */ jsxs(React97__default.Fragment, { children: [
11511
11520
  i > 0 && /* @__PURE__ */ jsx(
11512
11521
  Typography,
11513
11522
  {
@@ -11537,14 +11546,330 @@ function SequenceBar({
11537
11546
  ] }, i)) });
11538
11547
  }
11539
11548
  var init_SequenceBar = __esm({
11540
- "components/game/2d/molecules/SequenceBar.tsx"() {
11549
+ "components/game/2d/organisms/SequenceBar.tsx"() {
11541
11550
  init_atoms();
11542
11551
  init_cn();
11543
- init_useEventBus();
11544
11552
  init_TraitSlot();
11545
11553
  SequenceBar.displayName = "SequenceBar";
11546
11554
  }
11547
11555
  });
11556
+ function computeSlotFeedback(playerSeq, solutions) {
11557
+ let bestSolution = solutions[0];
11558
+ let bestMatches = -1;
11559
+ for (const sol of solutions) {
11560
+ const matches = sol.filter((id, i) => id === playerSeq[i]).length;
11561
+ if (matches > bestMatches) {
11562
+ bestMatches = matches;
11563
+ bestSolution = sol;
11564
+ }
11565
+ }
11566
+ return playerSeq.map(
11567
+ (id, i) => id !== void 0 && id === bestSolution[i] ? "correct" : "wrong"
11568
+ );
11569
+ }
11570
+ function isFieldRecord(v) {
11571
+ return typeof v === "object" && v !== null && !Array.isArray(v) && !(v instanceof Date);
11572
+ }
11573
+ function assetFromField(v) {
11574
+ if (!isFieldRecord(v)) return void 0;
11575
+ const url = typeof v.url === "string" ? v.url : void 0;
11576
+ const role = typeof v.role === "string" ? v.role : void 0;
11577
+ const category = typeof v.category === "string" ? v.category : "";
11578
+ if (!url || !role) return void 0;
11579
+ return {
11580
+ url,
11581
+ role,
11582
+ category,
11583
+ name: typeof v.name === "string" ? v.name : void 0,
11584
+ thumbnailUrl: typeof v.thumbnailUrl === "string" ? v.thumbnailUrl : void 0,
11585
+ style: typeof v.style === "string" ? v.style : void 0,
11586
+ variant: typeof v.variant === "string" ? v.variant : void 0,
11587
+ dimension: typeof v.dimension === "string" ? v.dimension : void 0,
11588
+ aspect: typeof v.aspect === "string" ? v.aspect : void 0
11589
+ };
11590
+ }
11591
+ function slotItemFromField(fv) {
11592
+ if (!isFieldRecord(fv)) return void 0;
11593
+ const id = typeof fv.id === "string" ? fv.id : void 0;
11594
+ const name = typeof fv.name === "string" ? fv.name : void 0;
11595
+ const category = typeof fv.category === "string" ? fv.category : void 0;
11596
+ if (!id || !name || !category) return void 0;
11597
+ return {
11598
+ id,
11599
+ name,
11600
+ category,
11601
+ description: typeof fv.description === "string" ? fv.description : void 0,
11602
+ iconEmoji: typeof fv.iconEmoji === "string" ? fv.iconEmoji : void 0,
11603
+ iconUrl: assetFromField(fv.iconUrl)
11604
+ };
11605
+ }
11606
+ function SequencerBoard({
11607
+ entity,
11608
+ categoryColors,
11609
+ stepDurationMs = 1e3,
11610
+ playEvent,
11611
+ completeEvent,
11612
+ placeEvent,
11613
+ removeEvent,
11614
+ checkEvent,
11615
+ playAgainEvent,
11616
+ stepEvent,
11617
+ className
11618
+ }) {
11619
+ const { emit } = useEventBus();
11620
+ const { t } = useTranslate();
11621
+ const resolved = boardEntity(entity);
11622
+ const maxSlots = num(resolved?.maxSlots) || 3;
11623
+ const solutions = Array.isArray(resolved?.solutions) ? resolved.solutions : [];
11624
+ const availableActions = (Array.isArray(resolved?.availableActions) ? resolved.availableActions : []).reduce((acc, fv) => {
11625
+ const item = slotItemFromField(fv);
11626
+ if (item) acc.push(item);
11627
+ return acc;
11628
+ }, []);
11629
+ const allowDuplicates = resolved?.allowDuplicates !== false;
11630
+ const entitySlots = Array.isArray(resolved?.slots) ? resolved.slots : [];
11631
+ const entityResult = str(resolved?.result);
11632
+ const entityAttempts = num(resolved?.attempts);
11633
+ const entityCurrentStep = typeof resolved?.currentStep === "number" ? resolved.currentStep : -1;
11634
+ const slots = Array.from({ length: maxSlots }, (_, i) => {
11635
+ const entitySlot = entitySlots.find((s) => s.index === i);
11636
+ if (!entitySlot?.placedActionId) return void 0;
11637
+ return availableActions.find((a) => a.id === entitySlot.placedActionId);
11638
+ });
11639
+ const isSuccess = entityResult === "win";
11640
+ const attempts = entityAttempts;
11641
+ const isPlayingBack = entityCurrentStep >= 0 && !isSuccess;
11642
+ const currentStep = entityCurrentStep;
11643
+ const [headerError, setHeaderError] = useState(false);
11644
+ const [slotFeedback, setSlotFeedback] = useState(
11645
+ () => Array.from({ length: maxSlots }, () => null)
11646
+ );
11647
+ const timerRef = useRef(null);
11648
+ useEffect(() => () => {
11649
+ if (timerRef.current) clearTimeout(timerRef.current);
11650
+ }, []);
11651
+ const handleSlotDrop = useCallback((index, item) => {
11652
+ setSlotFeedback((prev) => {
11653
+ const next = [...prev];
11654
+ next[index] = null;
11655
+ return next;
11656
+ });
11657
+ emit("UI:PLAY_SOUND", { key: "drop_slot" });
11658
+ if (placeEvent) emit(`UI:${placeEvent}`, { slotIndex: index, actionId: item.id });
11659
+ }, [emit, placeEvent]);
11660
+ const handleSlotRemove = useCallback((index) => {
11661
+ setSlotFeedback((prev) => {
11662
+ const next = [...prev];
11663
+ next[index] = null;
11664
+ return next;
11665
+ });
11666
+ emit("UI:PLAY_SOUND", { key: "back" });
11667
+ if (removeEvent) emit(`UI:${removeEvent}`, { slotIndex: index });
11668
+ }, [emit, removeEvent]);
11669
+ const handleReset = useCallback(() => {
11670
+ if (timerRef.current) clearTimeout(timerRef.current);
11671
+ setSlotFeedback(Array.from({ length: maxSlots }, () => null));
11672
+ if (playAgainEvent) emit(`UI:${playAgainEvent}`, {});
11673
+ }, [maxSlots, playAgainEvent, emit]);
11674
+ const filledSlots = slots.filter((s) => !!s);
11675
+ const canPlay = filledSlots.length > 0 && !isPlayingBack && !isSuccess;
11676
+ const handlePlay = useCallback(() => {
11677
+ if (!canPlay) return;
11678
+ setSlotFeedback(Array.from({ length: maxSlots }, () => null));
11679
+ emit("UI:PLAY_SOUND", { key: "confirm" });
11680
+ const sequence = slots.map((s) => s?.id || "");
11681
+ const playerIds = slots.filter(Boolean).map((s) => s?.id || "");
11682
+ if (playEvent) emit(`UI:${playEvent}`, { sequence });
11683
+ let step = 0;
11684
+ const advance = () => {
11685
+ step++;
11686
+ if (stepEvent) emit(`UI:${stepEvent}`, { step });
11687
+ if (step >= maxSlots) {
11688
+ if (checkEvent) emit(`UI:${checkEvent}`, { sequence: playerIds });
11689
+ const playerSeq = slots.map((s) => s?.id);
11690
+ const success = solutions.some(
11691
+ (sol) => sol.length === playerIds.length && sol.every((id, i) => id === playerIds[i])
11692
+ );
11693
+ if (success) {
11694
+ emit("UI:PLAY_SOUND", { key: "levelComplete" });
11695
+ if (completeEvent) emit(`UI:${completeEvent}`, { success: true, sequence: playerIds });
11696
+ } else {
11697
+ const feedback = computeSlotFeedback(playerSeq, solutions);
11698
+ setSlotFeedback(feedback);
11699
+ emit("UI:PLAY_SOUND", { key: "fail" });
11700
+ const correctCount2 = feedback.filter((f3) => f3 === "correct").length;
11701
+ for (let ci = 0; ci < correctCount2; ci++) {
11702
+ setTimeout(() => {
11703
+ emit("UI:PLAY_SOUND", { key: "correctSlot" });
11704
+ }, 300 + ci * 150);
11705
+ }
11706
+ }
11707
+ } else {
11708
+ timerRef.current = setTimeout(advance, stepDurationMs);
11709
+ }
11710
+ };
11711
+ timerRef.current = setTimeout(advance, stepDurationMs);
11712
+ }, [canPlay, slots, maxSlots, solutions, stepDurationMs, playEvent, completeEvent, checkEvent, emit]);
11713
+ const machine = {
11714
+ name: str(resolved?.title),
11715
+ description: str(resolved?.description),
11716
+ states: slots.map((s, i) => stepLabel(s, i)),
11717
+ currentState: currentStep >= 0 ? stepLabel(slots[currentStep], currentStep) : "__idle__",
11718
+ transitions: slots.slice(0, -1).map((s, i) => ({
11719
+ from: stepLabel(s, i),
11720
+ to: stepLabel(slots[i + 1], i + 1),
11721
+ event: "NEXT"
11722
+ }))
11723
+ };
11724
+ const usedIds = !allowDuplicates ? slots.filter(Boolean).map((s) => s?.id || "") : [];
11725
+ const hint = str(resolved?.hint);
11726
+ const showHint = attempts >= 3 && !!hint;
11727
+ const hasFeedback = slotFeedback.some((f3) => f3 !== null);
11728
+ const correctCount = slotFeedback.filter((f3) => f3 === "correct").length;
11729
+ const encourageKey = ENCOURAGEMENT_KEYS[Math.min(attempts - 1, ENCOURAGEMENT_KEYS.length - 1)] ?? ENCOURAGEMENT_KEYS[0];
11730
+ if (!resolved) return null;
11731
+ const theme = resolved.theme ?? void 0;
11732
+ const themeBackground = theme?.background;
11733
+ const headerImage = str(resolved.headerImage);
11734
+ return /* @__PURE__ */ jsxs(
11735
+ VStack,
11736
+ {
11737
+ className: cn("p-4 gap-6", className),
11738
+ style: {
11739
+ backgroundImage: themeBackground ? `url(${themeBackground})` : void 0,
11740
+ backgroundSize: "cover",
11741
+ backgroundPosition: "center"
11742
+ },
11743
+ children: [
11744
+ 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,
11745
+ /* @__PURE__ */ jsxs(VStack, { gap: "xs", children: [
11746
+ /* @__PURE__ */ jsx(Typography, { variant: "h4", className: "text-foreground", children: str(resolved.title) }),
11747
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground", children: str(resolved.description) })
11748
+ ] }),
11749
+ 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: [
11750
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-accent font-bold shrink-0", children: "\u{1F4A1} " + t("game.hint") + ":" }),
11751
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-foreground", children: hint })
11752
+ ] }) }),
11753
+ filledSlots.length > 0 && /* @__PURE__ */ jsx(TraitStateViewer, { trait: machine, variant: "linear", size: "md" }),
11754
+ /* @__PURE__ */ jsxs(VStack, { gap: "xs", children: [
11755
+ /* @__PURE__ */ jsxs(HStack, { className: "items-center justify-between", children: [
11756
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground font-medium", children: t("sequencer.yourSequence") + ":" }),
11757
+ hasFeedback && !isPlayingBack && !isSuccess && /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "text-muted-foreground", children: [
11758
+ `${correctCount}/${maxSlots} `,
11759
+ "\u2705"
11760
+ ] })
11761
+ ] }),
11762
+ /* @__PURE__ */ jsx(
11763
+ SequenceBar,
11764
+ {
11765
+ slots,
11766
+ maxSlots,
11767
+ onSlotDrop: handleSlotDrop,
11768
+ onSlotRemove: handleSlotRemove,
11769
+ playing: isPlayingBack,
11770
+ currentStep,
11771
+ categoryColors,
11772
+ slotFeedback,
11773
+ size: "lg"
11774
+ }
11775
+ )
11776
+ ] }),
11777
+ !isPlayingBack && /* @__PURE__ */ jsx(
11778
+ ActionPalette,
11779
+ {
11780
+ actions: availableActions,
11781
+ usedActionIds: usedIds,
11782
+ allowDuplicates,
11783
+ categoryColors,
11784
+ label: t("sequencer.dragActions")
11785
+ }
11786
+ ),
11787
+ 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) }) }),
11788
+ 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") }) }),
11789
+ /* @__PURE__ */ jsxs(HStack, { gap: "sm", children: [
11790
+ /* @__PURE__ */ jsx(
11791
+ Button,
11792
+ {
11793
+ variant: "primary",
11794
+ onClick: handlePlay,
11795
+ disabled: !canPlay,
11796
+ children: "\u25B6 " + t("game.play")
11797
+ }
11798
+ ),
11799
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: handleReset, children: "\u21BA " + t("game.reset") })
11800
+ ] })
11801
+ ]
11802
+ }
11803
+ );
11804
+ }
11805
+ var ENCOURAGEMENT_KEYS, stepLabel;
11806
+ var init_SequencerBoard = __esm({
11807
+ "components/game/2d/organisms/SequencerBoard.tsx"() {
11808
+ init_atoms();
11809
+ init_cn();
11810
+ init_useEventBus();
11811
+ init_TraitStateViewer();
11812
+ init_boardEntity();
11813
+ init_SequenceBar();
11814
+ init_ActionPalette();
11815
+ ENCOURAGEMENT_KEYS = [
11816
+ "puzzle.tryAgain1",
11817
+ "puzzle.tryAgain2",
11818
+ "puzzle.tryAgain3"
11819
+ ];
11820
+ stepLabel = (slot, i) => slot ? `${i + 1}. ${slot.name}` : `Step ${i + 1}`;
11821
+ SequencerBoard.displayName = "SequencerBoard";
11822
+ }
11823
+ });
11824
+ function RuleEditor({
11825
+ rule,
11826
+ availableEvents,
11827
+ availableActions,
11828
+ onChange,
11829
+ onRemove,
11830
+ disabled = false,
11831
+ className
11832
+ }) {
11833
+ const { t } = useTranslate();
11834
+ const handleWhenChange = useCallback((v) => {
11835
+ onChange({ ...rule, whenEvent: v });
11836
+ }, [rule, onChange]);
11837
+ const handleThenChange = useCallback((v) => {
11838
+ onChange({ ...rule, thenAction: v });
11839
+ }, [rule, onChange]);
11840
+ return /* @__PURE__ */ jsxs(HStack, { className: cn("items-center p-2 rounded-lg bg-muted/50 border border-border", className), gap: "sm", children: [
11841
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-primary font-bold whitespace-nowrap", children: t("eventHandler.when") }),
11842
+ /* @__PURE__ */ jsx(
11843
+ Select,
11844
+ {
11845
+ value: rule.whenEvent,
11846
+ onValueChange: handleWhenChange,
11847
+ options: availableEvents,
11848
+ disabled,
11849
+ className: "flex-1 min-w-0"
11850
+ }
11851
+ ),
11852
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-accent font-bold whitespace-nowrap", children: "\u2192 " + t("eventHandler.then") }),
11853
+ /* @__PURE__ */ jsx(
11854
+ Select,
11855
+ {
11856
+ value: rule.thenAction,
11857
+ onValueChange: handleThenChange,
11858
+ options: availableActions,
11859
+ disabled,
11860
+ className: "flex-1 min-w-0"
11861
+ }
11862
+ ),
11863
+ onRemove && /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: onRemove, disabled, className: "shrink-0", children: "\xD7" })
11864
+ ] });
11865
+ }
11866
+ var init_RuleEditor = __esm({
11867
+ "components/game/2d/organisms/RuleEditor.tsx"() {
11868
+ init_atoms();
11869
+ init_cn();
11870
+ RuleEditor.displayName = "RuleEditor";
11871
+ }
11872
+ });
11548
11873
  function EventLog({
11549
11874
  entries,
11550
11875
  maxHeight = 200,
@@ -11580,7 +11905,7 @@ function EventLog({
11580
11905
  }
11581
11906
  var STATUS_STYLES, STATUS_DOTS;
11582
11907
  var init_EventLog = __esm({
11583
- "components/game/2d/molecules/EventLog.tsx"() {
11908
+ "components/game/2d/organisms/EventLog.tsx"() {
11584
11909
  init_atoms();
11585
11910
  init_cn();
11586
11911
  STATUS_STYLES = {
@@ -11600,10 +11925,1768 @@ var init_EventLog = __esm({
11600
11925
  });
11601
11926
 
11602
11927
  // components/game/shared/lib/puzzleObject.ts
11928
+ function objId(o) {
11929
+ return o.id == null ? "" : String(o.id);
11930
+ }
11931
+ function objName(o) {
11932
+ return o.name == null ? "" : String(o.name);
11933
+ }
11934
+ function objIcon(o) {
11935
+ return o.icon == null ? "" : String(o.icon);
11936
+ }
11937
+ function objStates(o) {
11938
+ return Array.isArray(o.states) ? o.states : [];
11939
+ }
11940
+ function objCurrentState(o) {
11941
+ return o.currentState == null ? "" : String(o.currentState);
11942
+ }
11943
+ function objAvailableEvents(o) {
11944
+ return Array.isArray(o.availableEvents) ? o.availableEvents : [];
11945
+ }
11946
+ function objAvailableActions(o) {
11947
+ return Array.isArray(o.availableActions) ? o.availableActions : [];
11948
+ }
11949
+ function objRules(o) {
11950
+ return Array.isArray(o.rules) ? o.rules : [];
11951
+ }
11952
+ function objMaxRules(o) {
11953
+ const n = Number(o.maxRules);
11954
+ return Number.isFinite(n) && n > 0 ? n : 3;
11955
+ }
11603
11956
  var init_puzzleObject = __esm({
11604
11957
  "components/game/shared/lib/puzzleObject.ts"() {
11605
11958
  }
11606
11959
  });
11960
+ function ObjectRulePanel({
11961
+ object,
11962
+ onRulesChange,
11963
+ disabled = false,
11964
+ className
11965
+ }) {
11966
+ const { t } = useTranslate();
11967
+ const id = objId(object);
11968
+ const name = objName(object);
11969
+ const icon = objIcon(object);
11970
+ const states = objStates(object);
11971
+ const currentState = objCurrentState(object);
11972
+ const availableEvents = objAvailableEvents(object);
11973
+ const availableActions = objAvailableActions(object);
11974
+ const rules = objRules(object);
11975
+ const maxRules = objMaxRules(object);
11976
+ const canAdd = rules.length < maxRules;
11977
+ const handleRuleChange = useCallback((index, updatedRule) => {
11978
+ const newRules = [...rules];
11979
+ newRules[index] = updatedRule;
11980
+ onRulesChange(id, newRules);
11981
+ }, [id, rules, onRulesChange]);
11982
+ const handleRuleRemove = useCallback((index) => {
11983
+ const newRules = rules.filter((_, i) => i !== index);
11984
+ onRulesChange(id, newRules);
11985
+ }, [id, rules, onRulesChange]);
11986
+ const handleAddRule = useCallback(() => {
11987
+ if (!canAdd || disabled) return;
11988
+ const firstEvent = availableEvents[0]?.value || "";
11989
+ const firstAction = availableActions[0]?.value || "";
11990
+ const newRule = {
11991
+ id: `rule-${nextRuleId++}`,
11992
+ whenEvent: firstEvent,
11993
+ thenAction: firstAction
11994
+ };
11995
+ onRulesChange(id, [...rules, newRule]);
11996
+ }, [canAdd, disabled, id, rules, availableEvents, availableActions, onRulesChange]);
11997
+ const machine = {
11998
+ name,
11999
+ states,
12000
+ currentState,
12001
+ transitions: rules.map((r) => ({
12002
+ from: currentState,
12003
+ to: states.find((s) => s !== currentState) || currentState,
12004
+ event: r.whenEvent
12005
+ }))
12006
+ };
12007
+ return /* @__PURE__ */ jsxs(VStack, { className: cn("p-4 rounded-lg bg-card border border-border", className), gap: "sm", children: [
12008
+ /* @__PURE__ */ jsxs(HStack, { className: "items-center", gap: "sm", children: [
12009
+ /* @__PURE__ */ jsx(Typography, { variant: "h5", children: icon }),
12010
+ /* @__PURE__ */ jsxs(VStack, { gap: "none", children: [
12011
+ /* @__PURE__ */ jsx(Typography, { variant: "body1", className: "text-foreground font-bold", children: name }),
12012
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground", children: t("eventHandler.state") + ": " + currentState })
12013
+ ] })
12014
+ ] }),
12015
+ /* @__PURE__ */ jsx(TraitStateViewer, { trait: machine, variant: "compact", size: "sm" }),
12016
+ /* @__PURE__ */ jsxs(VStack, { gap: "xs", children: [
12017
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground font-medium", children: t("eventHandler.rules", { count: rules.length, max: maxRules }) + ":" }),
12018
+ rules.map((rule, i) => /* @__PURE__ */ jsx(
12019
+ RuleEditor,
12020
+ {
12021
+ rule,
12022
+ availableEvents,
12023
+ availableActions,
12024
+ onChange: (r) => handleRuleChange(i, r),
12025
+ onRemove: () => handleRuleRemove(i),
12026
+ disabled
12027
+ },
12028
+ rule.id
12029
+ )),
12030
+ canAdd && !disabled && /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: handleAddRule, className: "self-start", children: t("eventHandler.addRule") })
12031
+ ] })
12032
+ ] });
12033
+ }
12034
+ var nextRuleId;
12035
+ var init_ObjectRulePanel = __esm({
12036
+ "components/game/2d/organisms/ObjectRulePanel.tsx"() {
12037
+ init_atoms();
12038
+ init_cn();
12039
+ init_TraitStateViewer();
12040
+ init_RuleEditor();
12041
+ init_puzzleObject();
12042
+ nextRuleId = 1;
12043
+ ObjectRulePanel.displayName = "ObjectRulePanel";
12044
+ }
12045
+ });
12046
+ function EventHandlerBoard({
12047
+ entity,
12048
+ stepDurationMs = 800,
12049
+ playEvent,
12050
+ completeEvent,
12051
+ editRuleEvent,
12052
+ playAgainEvent,
12053
+ className
12054
+ }) {
12055
+ const { emit } = useEventBus();
12056
+ const { t } = useTranslate();
12057
+ const resolved = boardEntity(entity);
12058
+ const objects = rows(resolved?.objects);
12059
+ const entityResult = str(resolved?.result) || "none";
12060
+ const isSuccess = entityResult === "win";
12061
+ const attempts = typeof resolved?.attempts === "number" ? resolved.attempts : 0;
12062
+ const [selectedObjectId, setSelectedObjectId] = useState(
12063
+ objects[0] ? objId(objects[0]) : null
12064
+ );
12065
+ const [headerError, setHeaderError] = useState(false);
12066
+ const [isPlaying, setIsPlaying] = useState(false);
12067
+ const [eventLog, setEventLog] = useState([]);
12068
+ const timerRef = useRef(null);
12069
+ const logIdCounter = useRef(0);
12070
+ useEffect(() => () => {
12071
+ if (timerRef.current) clearTimeout(timerRef.current);
12072
+ }, []);
12073
+ const selectedObject = objects.find((o) => objId(o) === selectedObjectId) ?? null;
12074
+ const handleRulesChange = useCallback((objectId, rules) => {
12075
+ if (editRuleEvent) emit(`UI:${editRuleEvent}`, { objectId, rules });
12076
+ }, [editRuleEvent, emit]);
12077
+ const addLogEntry = useCallback((icon, message, status = "done") => {
12078
+ const id = `log-${logIdCounter.current++}`;
12079
+ setEventLog((prev) => [...prev, { id, timestamp: Date.now(), icon, message, status }]);
12080
+ }, []);
12081
+ const handlePlay = useCallback(() => {
12082
+ if (isPlaying || isSuccess) return;
12083
+ if (playEvent) emit(`UI:${playEvent}`, {});
12084
+ setIsPlaying(true);
12085
+ setEventLog([]);
12086
+ const allRules = [];
12087
+ objects.forEach((obj) => {
12088
+ objRules(obj).forEach((rule) => {
12089
+ allRules.push({ object: obj, rule });
12090
+ });
12091
+ });
12092
+ const triggers = Array.isArray(resolved?.triggerEvents) ? resolved.triggerEvents : [];
12093
+ const goalEvent = str(resolved?.goalEvent);
12094
+ const eventQueue = [...triggers];
12095
+ const firedEvents = /* @__PURE__ */ new Set();
12096
+ let stepIdx = 0;
12097
+ let goalReached = false;
12098
+ const processNext = () => {
12099
+ if (eventQueue.length === 0 || stepIdx > 20) {
12100
+ setIsPlaying(false);
12101
+ if (goalReached && completeEvent) emit(`UI:${completeEvent}`, { success: true });
12102
+ return;
12103
+ }
12104
+ const currentEvent = eventQueue.shift();
12105
+ if (firedEvents.has(currentEvent)) {
12106
+ timerRef.current = setTimeout(processNext, 100);
12107
+ return;
12108
+ }
12109
+ firedEvents.add(currentEvent);
12110
+ const matching = allRules.filter((r) => r.rule.whenEvent === currentEvent);
12111
+ if (matching.length === 0) {
12112
+ addLogEntry("\u26A1", t("eventHandler.noListeners", { event: currentEvent }), "done");
12113
+ } else {
12114
+ matching.forEach(({ object, rule }) => {
12115
+ addLogEntry(objIcon(object), t("eventHandler.heardEvent", { object: objName(object), event: currentEvent, action: rule.thenAction }), "done");
12116
+ eventQueue.push(rule.thenAction);
12117
+ if (rule.thenAction === goalEvent) {
12118
+ goalReached = true;
12119
+ }
12120
+ });
12121
+ }
12122
+ if (currentEvent === goalEvent) {
12123
+ goalReached = true;
12124
+ }
12125
+ stepIdx++;
12126
+ timerRef.current = setTimeout(processNext, stepDurationMs);
12127
+ };
12128
+ if (triggers.length > 0) {
12129
+ addLogEntry("\u{1F3AC}", t("eventHandler.simulationStarted", { events: triggers.join(", ") }), "active");
12130
+ }
12131
+ timerRef.current = setTimeout(processNext, stepDurationMs);
12132
+ }, [isPlaying, isSuccess, objects, resolved, stepDurationMs, playEvent, completeEvent, emit, addLogEntry, t]);
12133
+ const handleTryAgain = useCallback(() => {
12134
+ if (timerRef.current) clearTimeout(timerRef.current);
12135
+ setIsPlaying(false);
12136
+ setEventLog([]);
12137
+ }, []);
12138
+ const handleReset = useCallback(() => {
12139
+ if (timerRef.current) clearTimeout(timerRef.current);
12140
+ setIsPlaying(false);
12141
+ setEventLog([]);
12142
+ setSelectedObjectId(objects[0] ? objId(objects[0]) : null);
12143
+ if (playAgainEvent) emit(`UI:${playAgainEvent}`, {});
12144
+ }, [objects, playAgainEvent, emit]);
12145
+ if (!resolved) return null;
12146
+ const objectViewers = objects.map((obj) => {
12147
+ const states = objStates(obj);
12148
+ const currentState = objCurrentState(obj);
12149
+ const machine = {
12150
+ name: objName(obj),
12151
+ states,
12152
+ currentState,
12153
+ transitions: objRules(obj).map((r) => ({
12154
+ from: currentState,
12155
+ to: states.find((s) => s !== currentState) || currentState,
12156
+ event: r.whenEvent
12157
+ }))
12158
+ };
12159
+ return { obj, machine };
12160
+ });
12161
+ const hint = str(resolved.hint);
12162
+ const showHint = attempts >= 3 && hint;
12163
+ const theme = resolved.theme ?? void 0;
12164
+ const themeBackground = theme?.background;
12165
+ const headerImage = str(resolved.headerImage);
12166
+ const encourageKey = ENCOURAGEMENT_KEYS2[Math.min(attempts - 1, ENCOURAGEMENT_KEYS2.length - 1)] ?? ENCOURAGEMENT_KEYS2[0];
12167
+ return /* @__PURE__ */ jsxs(
12168
+ VStack,
12169
+ {
12170
+ className: cn("p-4 gap-6", className),
12171
+ style: {
12172
+ backgroundImage: themeBackground ? `url(${themeBackground})` : void 0,
12173
+ backgroundSize: "cover",
12174
+ backgroundPosition: "center"
12175
+ },
12176
+ children: [
12177
+ 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,
12178
+ /* @__PURE__ */ jsxs(VStack, { gap: "xs", children: [
12179
+ /* @__PURE__ */ jsx(Typography, { variant: "h4", className: "text-foreground", children: str(resolved.title) }),
12180
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground", children: str(resolved.description) }),
12181
+ /* @__PURE__ */ jsxs(HStack, { className: "items-center p-2 rounded bg-primary/10 border border-primary/30", gap: "xs", children: [
12182
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-primary font-bold", children: t("game.goal") + ":" }),
12183
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-foreground", children: str(resolved.goalCondition) })
12184
+ ] })
12185
+ ] }),
12186
+ /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
12187
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground font-medium", children: t("eventHandler.clickObject") + ":" }),
12188
+ /* @__PURE__ */ jsx(HStack, { className: "flex-wrap", gap: "sm", children: objectViewers.map(({ obj, machine }) => {
12189
+ const oid = objId(obj);
12190
+ return /* @__PURE__ */ jsx(
12191
+ Box,
12192
+ {
12193
+ className: cn(
12194
+ "p-3 rounded-container border-2 cursor-pointer transition-all hover:scale-105",
12195
+ selectedObjectId === oid ? "border-primary bg-primary/10" : "border-border bg-card hover:border-muted-foreground"
12196
+ ),
12197
+ onClick: () => setSelectedObjectId(oid),
12198
+ children: /* @__PURE__ */ jsxs(VStack, { gap: "xs", className: "items-center min-w-[120px]", children: [
12199
+ /* @__PURE__ */ jsx(Typography, { variant: "h5", children: objIcon(obj) }),
12200
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-foreground font-medium", children: objName(obj) }),
12201
+ /* @__PURE__ */ jsx(TraitStateViewer, { trait: machine, variant: "compact", size: "sm" })
12202
+ ] })
12203
+ },
12204
+ oid
12205
+ );
12206
+ }) })
12207
+ ] }),
12208
+ selectedObject && /* @__PURE__ */ jsx(
12209
+ ObjectRulePanel,
12210
+ {
12211
+ object: selectedObject,
12212
+ onRulesChange: handleRulesChange,
12213
+ disabled: isPlaying
12214
+ }
12215
+ ),
12216
+ eventLog.length > 0 && /* @__PURE__ */ jsx(EventLog, { entries: eventLog }),
12217
+ 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") }) }),
12218
+ !isPlaying && !isSuccess && attempts > 0 && /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
12219
+ /* @__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) }) }),
12220
+ 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: [
12221
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-accent font-bold shrink-0", children: "\u{1F4A1} " + t("game.hint") + ":" }),
12222
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-foreground", children: hint })
12223
+ ] }) })
12224
+ ] }),
12225
+ /* @__PURE__ */ jsxs(HStack, { gap: "sm", children: [
12226
+ !isPlaying && !isSuccess && attempts > 0 ? /* @__PURE__ */ jsx(Button, { variant: "primary", onClick: handleTryAgain, children: "\u{1F504} " + t("puzzle.tryAgainButton") }) : /* @__PURE__ */ jsx(
12227
+ Button,
12228
+ {
12229
+ variant: "primary",
12230
+ onClick: handlePlay,
12231
+ disabled: isPlaying || isSuccess,
12232
+ children: "\u25B6 " + t("game.play")
12233
+ }
12234
+ ),
12235
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: handleReset, children: "\u21BA " + t("game.reset") })
12236
+ ] })
12237
+ ]
12238
+ }
12239
+ );
12240
+ }
12241
+ var ENCOURAGEMENT_KEYS2;
12242
+ var init_EventHandlerBoard = __esm({
12243
+ "components/game/2d/organisms/EventHandlerBoard.tsx"() {
12244
+ init_atoms();
12245
+ init_cn();
12246
+ init_useEventBus();
12247
+ init_TraitStateViewer();
12248
+ init_ObjectRulePanel();
12249
+ init_EventLog();
12250
+ init_puzzleObject();
12251
+ init_boardEntity();
12252
+ ENCOURAGEMENT_KEYS2 = [
12253
+ "puzzle.tryAgain1",
12254
+ "puzzle.tryAgain2",
12255
+ "puzzle.tryAgain3"
12256
+ ];
12257
+ EventHandlerBoard.displayName = "EventHandlerBoard";
12258
+ }
12259
+ });
12260
+ function StateNode({
12261
+ name,
12262
+ isCurrent = false,
12263
+ isSelected = false,
12264
+ isInitial = false,
12265
+ position,
12266
+ onClick,
12267
+ className
12268
+ }) {
12269
+ return /* @__PURE__ */ jsx(
12270
+ Box,
12271
+ {
12272
+ position: "absolute",
12273
+ display: "flex",
12274
+ className: cn(
12275
+ "items-center justify-center rounded-pill border-3 transition-all cursor-pointer select-none",
12276
+ "min-w-[80px] h-[80px] px-3",
12277
+ isCurrent && "bg-primary/20 border-primary shadow-lg shadow-primary/30 scale-110",
12278
+ isSelected && !isCurrent && "bg-accent/20 border-accent ring-2 ring-accent/50",
12279
+ !isCurrent && !isSelected && "bg-card border-border hover:border-muted-foreground hover:scale-105",
12280
+ className
12281
+ ),
12282
+ style: {
12283
+ left: position.x,
12284
+ top: position.y,
12285
+ transform: "translate(-50%, -50%)"
12286
+ },
12287
+ onClick,
12288
+ children: /* @__PURE__ */ jsxs(Box, { className: "text-center", children: [
12289
+ isInitial && /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground text-xs block", children: "\u25B6 start" }),
12290
+ /* @__PURE__ */ jsx(
12291
+ Typography,
12292
+ {
12293
+ variant: "body2",
12294
+ className: cn(
12295
+ "font-bold whitespace-nowrap",
12296
+ isCurrent ? "text-primary" : "text-foreground"
12297
+ ),
12298
+ children: name
12299
+ }
12300
+ )
12301
+ ] })
12302
+ }
12303
+ );
12304
+ }
12305
+ var init_StateNode = __esm({
12306
+ "components/game/2d/organisms/StateNode.tsx"() {
12307
+ init_atoms();
12308
+ init_cn();
12309
+ StateNode.displayName = "StateNode";
12310
+ }
12311
+ });
12312
+ function TransitionArrow({
12313
+ from,
12314
+ to,
12315
+ eventLabel,
12316
+ guardHint,
12317
+ isActive = false,
12318
+ onClick,
12319
+ className
12320
+ }) {
12321
+ const dx = to.x - from.x;
12322
+ const dy = to.y - from.y;
12323
+ const dist = Math.sqrt(dx * dx + dy * dy);
12324
+ if (dist === 0) return /* @__PURE__ */ jsx(Fragment, {});
12325
+ const nx = dx / dist;
12326
+ const ny = dy / dist;
12327
+ const startX = from.x + nx * NODE_RADIUS;
12328
+ const startY = from.y + ny * NODE_RADIUS;
12329
+ const endX = to.x - nx * NODE_RADIUS;
12330
+ const endY = to.y - ny * NODE_RADIUS;
12331
+ const midX = (startX + endX) / 2;
12332
+ const midY = (startY + endY) / 2;
12333
+ const perpX = -ny * 20;
12334
+ const perpY = nx * 20;
12335
+ const ctrlX = midX + perpX;
12336
+ const ctrlY = midY + perpY;
12337
+ const path = `M ${startX} ${startY} Q ${ctrlX} ${ctrlY} ${endX} ${endY}`;
12338
+ return /* @__PURE__ */ jsxs("g", { className: cn("cursor-pointer", className), onClick, children: [
12339
+ /* @__PURE__ */ jsx(
12340
+ "path",
12341
+ {
12342
+ d: path,
12343
+ fill: "none",
12344
+ stroke: isActive ? "var(--color-primary)" : "var(--color-border)",
12345
+ strokeWidth: isActive ? 3 : 2,
12346
+ markerEnd: isActive ? "url(#arrowhead-active)" : "url(#arrowhead)"
12347
+ }
12348
+ ),
12349
+ /* @__PURE__ */ jsx(
12350
+ "text",
12351
+ {
12352
+ x: ctrlX,
12353
+ y: ctrlY - 8,
12354
+ textAnchor: "middle",
12355
+ fill: isActive ? "var(--color-primary)" : "var(--color-foreground)",
12356
+ fontSize: 12,
12357
+ fontWeight: isActive ? "bold" : "normal",
12358
+ className: "select-none",
12359
+ children: eventLabel
12360
+ }
12361
+ ),
12362
+ guardHint && /* @__PURE__ */ jsx(
12363
+ "text",
12364
+ {
12365
+ x: ctrlX,
12366
+ y: ctrlY + 6,
12367
+ textAnchor: "middle",
12368
+ fill: "var(--color-warning)",
12369
+ fontSize: 10,
12370
+ className: "select-none",
12371
+ children: "\u26A0 " + guardHint
12372
+ }
12373
+ )
12374
+ ] });
12375
+ }
12376
+ var NODE_RADIUS;
12377
+ var init_TransitionArrow = __esm({
12378
+ "components/game/2d/organisms/TransitionArrow.tsx"() {
12379
+ init_cn();
12380
+ NODE_RADIUS = 40;
12381
+ TransitionArrow.displayName = "TransitionArrow";
12382
+ }
12383
+ });
12384
+ function VariablePanel({
12385
+ entityName,
12386
+ variables,
12387
+ className
12388
+ }) {
12389
+ const { t } = useTranslate();
12390
+ return /* @__PURE__ */ jsxs(VStack, { className: cn("p-3 rounded-lg bg-card border border-border", className), gap: "sm", children: [
12391
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground font-medium", children: t("stateArchitect.variables", { name: entityName }) }),
12392
+ variables.map((v) => {
12393
+ const name = v.name == null ? "" : String(v.name);
12394
+ const value = numField(v.value);
12395
+ const max = numField(v.max, 100);
12396
+ const min = numField(v.min, 0);
12397
+ const unit = v.unit == null ? "" : String(v.unit);
12398
+ const pct = Math.round((value - min) / (max - min) * 100);
12399
+ const isHigh = pct > 80;
12400
+ const isLow = pct < 20;
12401
+ return /* @__PURE__ */ jsxs(VStack, { gap: "none", children: [
12402
+ /* @__PURE__ */ jsxs(HStack, { className: "items-center justify-between", children: [
12403
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-foreground font-medium", children: name }),
12404
+ /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: cn(
12405
+ isHigh ? "text-error" : isLow ? "text-warning" : "text-foreground"
12406
+ ), children: [
12407
+ value,
12408
+ unit,
12409
+ " / ",
12410
+ max,
12411
+ unit
12412
+ ] })
12413
+ ] }),
12414
+ /* @__PURE__ */ jsx(
12415
+ ProgressBar,
12416
+ {
12417
+ value: pct,
12418
+ color: isHigh ? "danger" : isLow ? "warning" : "primary",
12419
+ size: "sm"
12420
+ }
12421
+ )
12422
+ ] }, name);
12423
+ })
12424
+ ] });
12425
+ }
12426
+ var numField;
12427
+ var init_VariablePanel = __esm({
12428
+ "components/game/2d/organisms/VariablePanel.tsx"() {
12429
+ init_atoms();
12430
+ init_cn();
12431
+ numField = (v, fallback = 0) => {
12432
+ const n = Number(v);
12433
+ return Number.isFinite(n) ? n : fallback;
12434
+ };
12435
+ VariablePanel.displayName = "VariablePanel";
12436
+ }
12437
+ });
12438
+ function StateJsonView({
12439
+ data,
12440
+ label,
12441
+ defaultExpanded = false,
12442
+ className
12443
+ }) {
12444
+ const { t } = useTranslate();
12445
+ const [expanded, setExpanded] = useState(defaultExpanded);
12446
+ const jsonString = JSON.stringify(data, null, 2);
12447
+ return /* @__PURE__ */ jsxs(VStack, { className: cn("rounded-lg border border-border overflow-hidden", className), gap: "none", children: [
12448
+ /* @__PURE__ */ jsxs(HStack, { className: "items-center justify-between p-2 bg-muted", gap: "sm", children: [
12449
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground font-medium", children: label ?? t("stateArchitect.viewCode") }),
12450
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: () => setExpanded(!expanded), className: "text-xs", children: expanded ? t("stateArchitect.hideJson") : t("stateArchitect.showJson") })
12451
+ ] }),
12452
+ expanded && /* @__PURE__ */ jsx(Box, { className: "p-3 bg-background overflow-x-auto", children: /* @__PURE__ */ jsx(
12453
+ Typography,
12454
+ {
12455
+ variant: "caption",
12456
+ className: "text-foreground font-mono whitespace-pre text-xs leading-relaxed block",
12457
+ children: jsonString
12458
+ }
12459
+ ) })
12460
+ ] });
12461
+ }
12462
+ var init_StateJsonView = __esm({
12463
+ "components/game/2d/organisms/StateJsonView.tsx"() {
12464
+ init_atoms();
12465
+ init_cn();
12466
+ StateJsonView.displayName = "StateJsonView";
12467
+ }
12468
+ });
12469
+ function layoutStates(states, width, height) {
12470
+ const cx = width / 2;
12471
+ const cy = height / 2;
12472
+ const radius = Math.min(cx, cy) - 60;
12473
+ const positions = {};
12474
+ states.forEach((state, i) => {
12475
+ const angle = 2 * Math.PI * i / states.length - Math.PI / 2;
12476
+ positions[state] = {
12477
+ x: cx + radius * Math.cos(angle),
12478
+ y: cy + radius * Math.sin(angle)
12479
+ };
12480
+ });
12481
+ return positions;
12482
+ }
12483
+ function StateArchitectBoard({
12484
+ entity,
12485
+ stepDurationMs = 600,
12486
+ testEvent,
12487
+ completeEvent,
12488
+ addTransitionEvent,
12489
+ removeTransitionEvent,
12490
+ playAgainEvent,
12491
+ className
12492
+ }) {
12493
+ const { emit } = useEventBus();
12494
+ const { t } = useTranslate();
12495
+ const resolved = boardEntity(entity);
12496
+ const entityStates = Array.isArray(resolved?.states) ? resolved.states : [];
12497
+ const initialState = str(resolved?.initialState);
12498
+ const entityName = str(resolved?.entityName);
12499
+ const availableEvents = Array.isArray(resolved?.availableEvents) ? resolved.availableEvents : [];
12500
+ const testCases = (Array.isArray(resolved?.testCases) ? resolved.testCases : []).map((item) => {
12501
+ const o = typeof item === "object" && item !== null && !Array.isArray(item) ? item : {};
12502
+ const eventsField = o["events"];
12503
+ return {
12504
+ events: Array.isArray(eventsField) ? eventsField : [],
12505
+ expectedState: str(o["expectedState"]),
12506
+ label: str(o["label"])
12507
+ };
12508
+ });
12509
+ const entityTransitions = (Array.isArray(resolved?.transitions) ? resolved.transitions : []).map((item) => {
12510
+ const o = typeof item === "object" && item !== null && !Array.isArray(item) ? item : {};
12511
+ return {
12512
+ id: str(o["id"]),
12513
+ from: str(o["from"]),
12514
+ to: str(o["to"]),
12515
+ event: str(o["event"]),
12516
+ ...o["guardHint"] ? { guardHint: str(o["guardHint"]) } : {}
12517
+ };
12518
+ });
12519
+ const entityVariables = rows(resolved?.variables);
12520
+ const transitions = entityTransitions;
12521
+ const attempts = typeof resolved?.attempts === "number" ? resolved.attempts : 0;
12522
+ const entityResult = str(resolved?.result) || "none";
12523
+ const isSuccess = entityResult === "win";
12524
+ const [isTesting, setIsTesting] = useState(false);
12525
+ const [headerError, setHeaderError] = useState(false);
12526
+ const [currentState, setCurrentState] = useState(initialState);
12527
+ const [selectedState, setSelectedState] = useState(null);
12528
+ const [testResults, setTestResults] = useState([]);
12529
+ const [variables, setVariables] = useState(() => [...entityVariables]);
12530
+ const timerRef = useRef(null);
12531
+ const [addingFrom, setAddingFrom] = useState(null);
12532
+ useEffect(() => () => {
12533
+ if (timerRef.current) clearTimeout(timerRef.current);
12534
+ }, []);
12535
+ const GRAPH_W = 500;
12536
+ const GRAPH_H = 400;
12537
+ const positions = useMemo(() => layoutStates(entityStates, GRAPH_W, GRAPH_H), [entityStates]);
12538
+ const handleStateClick = useCallback((state) => {
12539
+ if (isTesting) return;
12540
+ if (addingFrom) {
12541
+ if (addingFrom !== state) {
12542
+ const event = availableEvents[0] || "EVENT";
12543
+ const newTrans = {
12544
+ id: `t-${nextTransId++}`,
12545
+ from: addingFrom,
12546
+ to: state,
12547
+ event
12548
+ };
12549
+ if (addTransitionEvent) emit(`UI:${addTransitionEvent}`, { id: newTrans.id, from: newTrans.from, to: newTrans.to, event: newTrans.event });
12550
+ }
12551
+ setAddingFrom(null);
12552
+ } else {
12553
+ setSelectedState(state);
12554
+ }
12555
+ }, [isTesting, addingFrom, availableEvents, addTransitionEvent, emit]);
12556
+ const handleStartAddTransition = useCallback(() => {
12557
+ if (!selectedState) return;
12558
+ setAddingFrom(selectedState);
12559
+ }, [selectedState]);
12560
+ const handleRemoveTransition = useCallback((transId) => {
12561
+ if (removeTransitionEvent) emit(`UI:${removeTransitionEvent}`, { id: transId });
12562
+ }, [removeTransitionEvent, emit]);
12563
+ const machine = useMemo(() => ({
12564
+ name: entityName,
12565
+ description: str(resolved?.description),
12566
+ states: entityStates,
12567
+ currentState,
12568
+ transitions: transitions.map((t2) => ({
12569
+ from: t2.from,
12570
+ to: t2.to,
12571
+ event: t2.event,
12572
+ guardHint: t2.guardHint
12573
+ }))
12574
+ }), [entityName, resolved, entityStates, currentState, transitions]);
12575
+ const handleTest = useCallback(() => {
12576
+ if (isTesting) return;
12577
+ if (testEvent) emit(`UI:${testEvent}`, {});
12578
+ setIsTesting(true);
12579
+ setTestResults([]);
12580
+ const results = [];
12581
+ let testIdx = 0;
12582
+ const runNextTest = () => {
12583
+ if (testIdx >= testCases.length) {
12584
+ const allPassed = results.every((r) => r.passed);
12585
+ setIsTesting(false);
12586
+ setTestResults(results);
12587
+ if (allPassed && completeEvent) {
12588
+ emit(`UI:${completeEvent}`, {
12589
+ success: true,
12590
+ passedTests: results.filter((r) => r.passed).length
12591
+ });
12592
+ }
12593
+ return;
12594
+ }
12595
+ const testCase = testCases[testIdx];
12596
+ if (!testCase) return;
12597
+ let state = initialState;
12598
+ for (const event of testCase.events) {
12599
+ const trans = transitions.find((t2) => t2.from === state && t2.event === event);
12600
+ if (trans) {
12601
+ state = trans.to;
12602
+ }
12603
+ }
12604
+ setCurrentState(state);
12605
+ results.push({
12606
+ label: testCase.label,
12607
+ passed: state === testCase.expectedState,
12608
+ actualState: state,
12609
+ expectedState: testCase.expectedState
12610
+ });
12611
+ testIdx++;
12612
+ timerRef.current = setTimeout(runNextTest, stepDurationMs);
12613
+ };
12614
+ timerRef.current = setTimeout(runNextTest, stepDurationMs);
12615
+ }, [isTesting, transitions, testCases, initialState, stepDurationMs, testEvent, completeEvent, emit]);
12616
+ const handleTryAgain = useCallback(() => {
12617
+ if (timerRef.current) clearTimeout(timerRef.current);
12618
+ setIsTesting(false);
12619
+ setCurrentState(initialState);
12620
+ setTestResults([]);
12621
+ }, [initialState]);
12622
+ const handleReset = useCallback(() => {
12623
+ if (timerRef.current) clearTimeout(timerRef.current);
12624
+ setIsTesting(false);
12625
+ setCurrentState(initialState);
12626
+ setTestResults([]);
12627
+ setVariables([...entityVariables]);
12628
+ setSelectedState(null);
12629
+ setAddingFrom(null);
12630
+ if (playAgainEvent) emit(`UI:${playAgainEvent}`, {});
12631
+ }, [initialState, entityVariables, playAgainEvent, emit]);
12632
+ const codeData = useMemo(() => ({
12633
+ name: entityName,
12634
+ states: entityStates,
12635
+ initialState,
12636
+ transitions: transitions.map((t2) => ({
12637
+ from: t2.from,
12638
+ to: t2.to,
12639
+ event: t2.event,
12640
+ ...t2.guardHint ? { guard: t2.guardHint } : {}
12641
+ }))
12642
+ }), [entityName, entityStates, initialState, transitions]);
12643
+ if (!resolved) return null;
12644
+ const theme = resolved.theme ?? void 0;
12645
+ const themeBackground = theme?.background;
12646
+ const headerImage = str(resolved.headerImage);
12647
+ const hint = str(resolved.hint);
12648
+ return /* @__PURE__ */ jsxs(
12649
+ VStack,
12650
+ {
12651
+ className: cn("p-4 gap-6", className),
12652
+ style: {
12653
+ backgroundImage: themeBackground ? `url(${themeBackground})` : void 0,
12654
+ backgroundSize: "cover",
12655
+ backgroundPosition: "center"
12656
+ },
12657
+ children: [
12658
+ 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,
12659
+ /* @__PURE__ */ jsxs(VStack, { gap: "xs", children: [
12660
+ /* @__PURE__ */ jsx(Typography, { variant: "h4", className: "text-foreground", children: str(resolved.title) }),
12661
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground", children: str(resolved.description) }),
12662
+ /* @__PURE__ */ jsxs(HStack, { className: "items-center p-2 rounded bg-warning/10 border border-warning/30", gap: "xs", children: [
12663
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-warning font-bold", children: t("game.hint") + ":" }),
12664
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-foreground", children: hint })
12665
+ ] })
12666
+ ] }),
12667
+ /* @__PURE__ */ jsxs(HStack, { className: "flex-wrap items-start", gap: "lg", children: [
12668
+ /* @__PURE__ */ jsxs(VStack, { gap: "sm", className: "flex-1 min-w-[300px]", children: [
12669
+ /* @__PURE__ */ jsxs(HStack, { className: "items-center justify-between", children: [
12670
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground font-medium", children: t("stateArchitect.graph") }),
12671
+ addingFrom && /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-accent animate-pulse", children: t("stateArchitect.clickTarget", { state: addingFrom || "" }) })
12672
+ ] }),
12673
+ /* @__PURE__ */ jsxs(
12674
+ Box,
12675
+ {
12676
+ position: "relative",
12677
+ className: "rounded-container border border-border bg-background overflow-hidden",
12678
+ style: { width: GRAPH_W, height: GRAPH_H },
12679
+ children: [
12680
+ /* @__PURE__ */ jsxs(
12681
+ "svg",
12682
+ {
12683
+ width: GRAPH_W,
12684
+ height: GRAPH_H,
12685
+ className: "absolute inset-0",
12686
+ style: { pointerEvents: "none" },
12687
+ children: [
12688
+ /* @__PURE__ */ jsxs("defs", { children: [
12689
+ /* @__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)" }) }),
12690
+ /* @__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)" }) })
12691
+ ] }),
12692
+ transitions.map((t2) => {
12693
+ const fromPos = positions[t2.from];
12694
+ const toPos = positions[t2.to];
12695
+ if (!fromPos || !toPos) return null;
12696
+ const isActive = t2.from === currentState;
12697
+ return /* @__PURE__ */ jsx(
12698
+ TransitionArrow,
12699
+ {
12700
+ from: fromPos,
12701
+ to: toPos,
12702
+ eventLabel: t2.event,
12703
+ guardHint: t2.guardHint,
12704
+ isActive
12705
+ },
12706
+ t2.id
12707
+ );
12708
+ })
12709
+ ]
12710
+ }
12711
+ ),
12712
+ entityStates.map((state) => /* @__PURE__ */ jsx(
12713
+ StateNode,
12714
+ {
12715
+ name: state,
12716
+ position: positions[state],
12717
+ isCurrent: state === currentState,
12718
+ isSelected: state === selectedState,
12719
+ isInitial: state === initialState,
12720
+ onClick: () => handleStateClick(state)
12721
+ },
12722
+ state
12723
+ ))
12724
+ ]
12725
+ }
12726
+ ),
12727
+ !isTesting && /* @__PURE__ */ jsx(HStack, { gap: "sm", children: /* @__PURE__ */ jsx(
12728
+ Button,
12729
+ {
12730
+ variant: "ghost",
12731
+ onClick: handleStartAddTransition,
12732
+ disabled: !selectedState,
12733
+ children: selectedState ? t("stateArchitect.addTransition", { state: selectedState }) : t("stateArchitect.addTransitionPrompt")
12734
+ }
12735
+ ) }),
12736
+ transitions.length > 0 && /* @__PURE__ */ jsxs(VStack, { gap: "xs", className: "p-3 rounded-container bg-muted/50 border border-border", children: [
12737
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground font-medium", children: t("stateArchitect.transitions", { count: transitions.length }) + ":" }),
12738
+ transitions.map((t2) => /* @__PURE__ */ jsxs(HStack, { className: "items-center text-xs", gap: "xs", children: [
12739
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-foreground", children: t2.from }),
12740
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground", children: "\u2014[" }),
12741
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-accent font-medium", children: t2.event }),
12742
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground", children: "]\u2192" }),
12743
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-success", children: t2.to }),
12744
+ t2.guardHint && /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "text-warning", children: [
12745
+ "(",
12746
+ t2.guardHint,
12747
+ ")"
12748
+ ] }),
12749
+ !isTesting && /* @__PURE__ */ jsx(
12750
+ Button,
12751
+ {
12752
+ variant: "ghost",
12753
+ onClick: () => handleRemoveTransition(t2.id),
12754
+ className: "text-xs ml-auto",
12755
+ children: "\xD7"
12756
+ }
12757
+ )
12758
+ ] }, t2.id))
12759
+ ] })
12760
+ ] }),
12761
+ /* @__PURE__ */ jsxs(VStack, { gap: "sm", className: "w-[280px] shrink-0", children: [
12762
+ /* @__PURE__ */ jsx(TraitStateViewer, { trait: machine, variant: "full", size: "sm" }),
12763
+ /* @__PURE__ */ jsx(
12764
+ VariablePanel,
12765
+ {
12766
+ entityName,
12767
+ variables
12768
+ }
12769
+ ),
12770
+ testResults.length > 0 && /* @__PURE__ */ jsxs(VStack, { className: "p-3 rounded-container bg-card border border-border", gap: "xs", children: [
12771
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground font-medium", children: t("stateArchitect.testResults") + ":" }),
12772
+ testResults.map((r, i) => /* @__PURE__ */ jsxs(HStack, { className: "items-center text-xs", gap: "xs", children: [
12773
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: r.passed ? "text-success" : "text-error", children: r.passed ? "\u2714" : "\u2717" }),
12774
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-foreground flex-1", children: r.label }),
12775
+ !r.passed && /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-error", children: t("stateArchitect.gotState", { state: r.actualState }) })
12776
+ ] }, i))
12777
+ ] }),
12778
+ resolved.showCodeView !== false && /* @__PURE__ */ jsx(StateJsonView, { data: codeData, label: "View Code" })
12779
+ ] })
12780
+ ] }),
12781
+ 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") }) }),
12782
+ !isTesting && !isSuccess && testResults.some((r) => !r.passed) && /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
12783
+ /* @__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]) }) }),
12784
+ !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: [
12785
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-accent font-bold shrink-0", children: "\u{1F4A1} " + t("game.hint") + ":" }),
12786
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-foreground", children: hint })
12787
+ ] }) })
12788
+ ] }),
12789
+ /* @__PURE__ */ jsxs(HStack, { gap: "sm", children: [
12790
+ !isTesting && !isSuccess && testResults.some((r) => !r.passed) ? /* @__PURE__ */ jsx(Button, { variant: "primary", onClick: handleTryAgain, children: "\u{1F504} " + t("puzzle.tryAgainButton") }) : /* @__PURE__ */ jsx(
12791
+ Button,
12792
+ {
12793
+ variant: "primary",
12794
+ onClick: handleTest,
12795
+ disabled: isTesting,
12796
+ children: "\u25B6 " + t("game.runTests")
12797
+ }
12798
+ ),
12799
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: handleReset, children: "\u21BA " + t("game.reset") })
12800
+ ] })
12801
+ ]
12802
+ }
12803
+ );
12804
+ }
12805
+ var ENCOURAGEMENT_KEYS3, nextTransId;
12806
+ var init_StateArchitectBoard = __esm({
12807
+ "components/game/2d/organisms/StateArchitectBoard.tsx"() {
12808
+ init_atoms();
12809
+ init_cn();
12810
+ init_useEventBus();
12811
+ init_TraitStateViewer();
12812
+ init_StateNode();
12813
+ init_TransitionArrow();
12814
+ init_VariablePanel();
12815
+ init_StateJsonView();
12816
+ init_boardEntity();
12817
+ ENCOURAGEMENT_KEYS3 = [
12818
+ "puzzle.tryAgain1",
12819
+ "puzzle.tryAgain2",
12820
+ "puzzle.tryAgain3"
12821
+ ];
12822
+ nextTransId = 100;
12823
+ StateArchitectBoard.displayName = "StateArchitectBoard";
12824
+ }
12825
+ });
12826
+ function readSimulatorParameters(v) {
12827
+ if (!Array.isArray(v)) return [];
12828
+ const result = [];
12829
+ for (const item of v) {
12830
+ if (typeof item === "object" && item !== null && !Array.isArray(item) && !(item instanceof Date)) {
12831
+ const param = item;
12832
+ if ("id" in item && "label" in item && "unit" in item && "min" in item && "max" in item && "step" in item) {
12833
+ result.push({
12834
+ id: str(param.id),
12835
+ label: str(param.label),
12836
+ unit: str(param.unit),
12837
+ min: num(param.min),
12838
+ max: num(param.max),
12839
+ step: num(param.step),
12840
+ initial: num(param.initial),
12841
+ correct: num(param.correct),
12842
+ tolerance: num(param.tolerance)
12843
+ });
12844
+ }
12845
+ }
12846
+ }
12847
+ return result;
12848
+ }
12849
+ function SimulatorBoard({
12850
+ entity,
12851
+ completeEvent = "PUZZLE_COMPLETE",
12852
+ setAEvent,
12853
+ setBEvent,
12854
+ checkEvent,
12855
+ playAgainEvent,
12856
+ assetManifest,
12857
+ className
12858
+ }) {
12859
+ const ui = assetManifest?.ui;
12860
+ const { emit } = useEventBus();
12861
+ const { t } = useTranslate();
12862
+ const resolved = boardEntity(entity);
12863
+ const parameters = readSimulatorParameters(resolved?.parameters);
12864
+ const [headerError, setHeaderError] = useState(false);
12865
+ if (!resolved) return null;
12866
+ const paramA = num(resolved.paramA);
12867
+ const paramB = num(resolved.paramB);
12868
+ const output = num(resolved.output);
12869
+ const targetValue = num(resolved.target);
12870
+ const targetTolerance = num(resolved.tolerance);
12871
+ const attempts = num(resolved.attempts);
12872
+ const result = str(resolved.result);
12873
+ const isWin = result === "win";
12874
+ const isComplete = result !== "none" && result !== "";
12875
+ const paramAValue = parameters[0];
12876
+ const paramBValue = parameters[1];
12877
+ const sliderValues = [paramA, paramB];
12878
+ const sliderEvents = [setAEvent, setBEvent];
12879
+ const handleParameterChange = (index, value) => {
12880
+ if (isComplete) return;
12881
+ const ev = sliderEvents[index];
12882
+ if (ev) emit(`UI:${ev}`, { value });
12883
+ };
12884
+ const handleCheck = () => {
12885
+ if (checkEvent) emit(`UI:${checkEvent}`, {});
12886
+ };
12887
+ const handlePlayAgain = () => {
12888
+ if (playAgainEvent) emit(`UI:${playAgainEvent}`, {});
12889
+ };
12890
+ const themeBackground = (() => {
12891
+ const t2 = resolved.theme;
12892
+ if (typeof t2 === "object" && t2 !== null && !Array.isArray(t2) && !(t2 instanceof Date)) {
12893
+ const bg = t2.background;
12894
+ return str(bg);
12895
+ }
12896
+ return "";
12897
+ })();
12898
+ const headerImage = str(resolved.headerImage);
12899
+ const hint = str(resolved.hint);
12900
+ const showHint = isComplete && !isWin && attempts >= 2 && Boolean(hint);
12901
+ const outputLabel = str(resolved.outputLabel);
12902
+ const outputUnit = str(resolved.outputUnit);
12903
+ return /* @__PURE__ */ jsx(
12904
+ Box,
12905
+ {
12906
+ className,
12907
+ style: {
12908
+ backgroundImage: themeBackground ? `url(${themeBackground})` : void 0,
12909
+ backgroundSize: "cover",
12910
+ backgroundPosition: "center"
12911
+ },
12912
+ children: /* @__PURE__ */ jsxs(VStack, { gap: "lg", className: "p-4", children: [
12913
+ 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,
12914
+ /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
12915
+ /* @__PURE__ */ jsx(Typography, { variant: "h4", weight: "bold", children: str(resolved.title) }),
12916
+ /* @__PURE__ */ jsx(Typography, { variant: "body", children: str(resolved.description) })
12917
+ ] }) }),
12918
+ /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "md", children: [
12919
+ /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "bold", className: "uppercase tracking-wider text-muted-foreground", children: t("simulator.parameters") }),
12920
+ [paramAValue, paramBValue].map(
12921
+ (param, index) => param ? /* @__PURE__ */ jsxs(VStack, { gap: "xs", children: [
12922
+ /* @__PURE__ */ jsxs(HStack, { justify: "between", align: "center", children: [
12923
+ /* @__PURE__ */ jsx(Typography, { variant: "body", weight: "medium", children: param.label }),
12924
+ /* @__PURE__ */ jsxs(Badge, { size: "sm", children: [
12925
+ sliderValues[index],
12926
+ " ",
12927
+ param.unit
12928
+ ] })
12929
+ ] }),
12930
+ /* @__PURE__ */ jsx(
12931
+ "input",
12932
+ {
12933
+ type: "range",
12934
+ min: param.min,
12935
+ max: param.max,
12936
+ step: param.step,
12937
+ value: sliderValues[index],
12938
+ onChange: (e) => handleParameterChange(index, Number(e.target.value)),
12939
+ disabled: isComplete,
12940
+ className: "w-full accent-foreground"
12941
+ }
12942
+ ),
12943
+ /* @__PURE__ */ jsxs(HStack, { justify: "between", children: [
12944
+ /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "text-muted-foreground", children: [
12945
+ param.min,
12946
+ " ",
12947
+ param.unit
12948
+ ] }),
12949
+ /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "text-muted-foreground", children: [
12950
+ param.max,
12951
+ " ",
12952
+ param.unit
12953
+ ] })
12954
+ ] })
12955
+ ] }, param.id ?? index) : null
12956
+ )
12957
+ ] }) }),
12958
+ /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", align: "center", children: [
12959
+ /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "bold", className: "uppercase tracking-wider text-muted-foreground", children: outputLabel }),
12960
+ /* @__PURE__ */ jsxs(Typography, { variant: "h3", weight: "bold", children: [
12961
+ output.toFixed(2),
12962
+ " ",
12963
+ outputUnit
12964
+ ] }),
12965
+ isComplete && /* @__PURE__ */ jsxs(HStack, { gap: "xs", align: "center", children: [
12966
+ /* @__PURE__ */ jsx(
12967
+ GameIcon,
12968
+ {
12969
+ icon: isWin ? CheckCircle : XCircle,
12970
+ assetUrl: isWin ? ui?.["correct"] : ui?.["incorrect"],
12971
+ size: "sm",
12972
+ className: isWin ? "text-success" : "text-error"
12973
+ }
12974
+ ),
12975
+ /* @__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") })
12976
+ ] }),
12977
+ /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "text-muted-foreground", children: [
12978
+ t("simulator.target"),
12979
+ ": ",
12980
+ targetValue,
12981
+ " ",
12982
+ outputUnit,
12983
+ " (\xB1",
12984
+ targetTolerance,
12985
+ ")"
12986
+ ] })
12987
+ ] }) }),
12988
+ showHint && hint && /* @__PURE__ */ jsx(Card, { className: "p-4 border-l-4 border-l-warning", children: /* @__PURE__ */ jsx(Typography, { variant: "body", children: hint }) }),
12989
+ /* @__PURE__ */ jsxs(HStack, { gap: "sm", justify: "center", children: [
12990
+ !isComplete ? /* @__PURE__ */ jsxs(Button, { variant: "primary", onClick: handleCheck, children: [
12991
+ /* @__PURE__ */ jsx(GameIcon, { icon: Play, assetUrl: ui?.["play"], size: "sm" }),
12992
+ t("simulator.simulate")
12993
+ ] }) : null,
12994
+ /* @__PURE__ */ jsxs(Button, { variant: "secondary", onClick: handlePlayAgain, children: [
12995
+ /* @__PURE__ */ jsx(GameIcon, { icon: RotateCcw, assetUrl: ui?.["reset"], size: "sm" }),
12996
+ t("simulator.reset")
12997
+ ] })
12998
+ ] })
12999
+ ] })
13000
+ }
13001
+ );
13002
+ }
13003
+ var init_SimulatorBoard = __esm({
13004
+ "components/game/2d/organisms/SimulatorBoard.tsx"() {
13005
+ init_atoms();
13006
+ init_useEventBus();
13007
+ init_boardEntity();
13008
+ init_GameIcon();
13009
+ SimulatorBoard.displayName = "SimulatorBoard";
13010
+ }
13011
+ });
13012
+ function ClassifierBoard({
13013
+ entity,
13014
+ completeEvent = "PUZZLE_COMPLETE",
13015
+ assignEvent,
13016
+ checkEvent,
13017
+ playAgainEvent,
13018
+ assetManifest,
13019
+ className
13020
+ }) {
13021
+ const ui = assetManifest?.ui;
13022
+ const { emit } = useEventBus();
13023
+ const { t } = useTranslate();
13024
+ const resolved = boardEntity(entity);
13025
+ const [headerError, setHeaderError] = useState(false);
13026
+ const items = rows(resolved?.items);
13027
+ const categories = rows(resolved?.categories);
13028
+ const result = str(resolved?.result);
13029
+ const submitted = result === "win";
13030
+ const attempts = num(resolved?.attempts);
13031
+ const assignments = items.reduce((acc, item) => {
13032
+ if (item.assignedCategory != null && item.assignedCategory !== "") acc[item.id] = item.assignedCategory;
13033
+ return acc;
13034
+ }, {});
13035
+ const unassignedItems = items.filter((item) => !assignments[item.id]);
13036
+ const allAssigned = items.length > 0 && Object.keys(assignments).length === items.length;
13037
+ const results = submitted ? items.map((item) => ({
13038
+ item,
13039
+ assigned: assignments[item.id],
13040
+ correct: assignments[item.id] === item.correctCategory
13041
+ })) : [];
13042
+ const allCorrect = result === "win";
13043
+ const correctCount = results.filter((r) => r.correct).length;
13044
+ const showHint = attempts >= 2 && Boolean(str(resolved?.hint));
13045
+ const handleAssign = (itemId, categoryId) => {
13046
+ if (submitted) return;
13047
+ if (assignEvent) emit(`UI:${assignEvent}`, { itemId, categoryId });
13048
+ };
13049
+ const handleUnassign = (itemId) => {
13050
+ if (submitted) return;
13051
+ if (assignEvent) emit(`UI:${assignEvent}`, { itemId, categoryId: "" });
13052
+ };
13053
+ const handleSubmit = () => {
13054
+ if (checkEvent) emit(`UI:${checkEvent}`, {});
13055
+ if (allAssigned && items.every((item) => assignments[item.id] === item.correctCategory)) {
13056
+ emit(`UI:${completeEvent}`, { success: true, attempts: attempts + 1 });
13057
+ }
13058
+ };
13059
+ const handleFullReset = () => {
13060
+ if (playAgainEvent) emit(`UI:${playAgainEvent}`, {});
13061
+ };
13062
+ if (!resolved) return null;
13063
+ const theme = resolved.theme ?? void 0;
13064
+ const themeBackground = theme?.background;
13065
+ const headerImage = str(resolved.headerImage);
13066
+ const hint = str(resolved.hint);
13067
+ const failMessage = str(resolved.failMessage);
13068
+ return /* @__PURE__ */ jsx(
13069
+ Box,
13070
+ {
13071
+ className,
13072
+ style: {
13073
+ backgroundImage: themeBackground ? `url(${themeBackground})` : void 0,
13074
+ backgroundSize: "cover",
13075
+ backgroundPosition: "center"
13076
+ },
13077
+ children: /* @__PURE__ */ jsxs(VStack, { gap: "lg", className: "p-4", children: [
13078
+ 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,
13079
+ /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
13080
+ /* @__PURE__ */ jsx(Typography, { variant: "h4", weight: "bold", children: str(resolved.title) }),
13081
+ /* @__PURE__ */ jsx(Typography, { variant: "body", children: str(resolved.description) })
13082
+ ] }) }),
13083
+ unassignedItems.length > 0 && /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
13084
+ /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "bold", className: "uppercase tracking-wider text-muted-foreground", children: t("classifier.itemsToSort") }),
13085
+ /* @__PURE__ */ jsx(HStack, { gap: "sm", className: "flex-wrap", children: unassignedItems.map((item) => /* @__PURE__ */ jsxs(Badge, { size: "md", className: "cursor-pointer", children: [
13086
+ item.iconUrl && /* @__PURE__ */ jsx("img", { src: item.iconUrl, alt: "", className: "w-4 h-4 object-contain inline-block" }),
13087
+ item.label
13088
+ ] }, item.id)) })
13089
+ ] }) }),
13090
+ /* @__PURE__ */ jsx(VStack, { gap: "md", children: categories.map((cat) => {
13091
+ const catItems = items.filter((item) => assignments[item.id] === cat.id);
13092
+ return /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
13093
+ 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" }) }),
13094
+ /* @__PURE__ */ jsxs(HStack, { justify: "between", align: "center", children: [
13095
+ /* @__PURE__ */ jsx(Typography, { variant: "body", weight: "bold", children: cat.label }),
13096
+ /* @__PURE__ */ jsx(Badge, { size: "sm", children: catItems.length })
13097
+ ] }),
13098
+ /* @__PURE__ */ jsx(HStack, { gap: "xs", className: "flex-wrap min-h-[2rem]", children: catItems.map((item) => {
13099
+ const result2 = results.find((r) => r.item.id === item.id);
13100
+ return /* @__PURE__ */ jsxs(
13101
+ Badge,
13102
+ {
13103
+ size: "sm",
13104
+ className: `cursor-pointer ${result2 ? result2.correct ? "border-success bg-success/10" : "border-error bg-error/10" : ""}`,
13105
+ onClick: () => handleUnassign(item.id),
13106
+ children: [
13107
+ item.iconUrl && /* @__PURE__ */ jsx("img", { src: item.iconUrl, alt: "", className: "w-3 h-3 object-contain inline-block" }),
13108
+ item.label,
13109
+ result2 && /* @__PURE__ */ jsx(
13110
+ GameIcon,
13111
+ {
13112
+ icon: result2.correct ? CheckCircle : XCircle,
13113
+ assetUrl: result2.correct ? ui?.["correct"] : ui?.["incorrect"],
13114
+ size: "sm",
13115
+ className: result2.correct ? "text-success" : "text-error"
13116
+ }
13117
+ )
13118
+ ]
13119
+ },
13120
+ item.id
13121
+ );
13122
+ }) }),
13123
+ !submitted && unassignedItems.length > 0 && /* @__PURE__ */ jsx(HStack, { gap: "xs", className: "flex-wrap", children: unassignedItems.map((item) => /* @__PURE__ */ jsxs(
13124
+ Button,
13125
+ {
13126
+ size: "sm",
13127
+ variant: "ghost",
13128
+ onClick: () => handleAssign(item.id, cat.id),
13129
+ className: "text-xs opacity-50 hover:opacity-100",
13130
+ children: [
13131
+ "+ ",
13132
+ item.label
13133
+ ]
13134
+ },
13135
+ item.id
13136
+ )) })
13137
+ ] }) }, cat.id);
13138
+ }) }),
13139
+ submitted && /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", align: "center", children: [
13140
+ /* @__PURE__ */ jsx(
13141
+ GameIcon,
13142
+ {
13143
+ icon: allCorrect ? CheckCircle : XCircle,
13144
+ assetUrl: allCorrect ? ui?.["correct"] : ui?.["incorrect"],
13145
+ size: "lg",
13146
+ className: allCorrect ? "text-success" : "text-error"
13147
+ }
13148
+ ),
13149
+ /* @__PURE__ */ jsx(Typography, { variant: "body", weight: "bold", children: allCorrect ? str(resolved.successMessage) || t("classifier.allCorrect") : `${correctCount}/${items.length} ${t("classifier.correct")}` }),
13150
+ !allCorrect && failMessage && /* @__PURE__ */ jsx(Typography, { variant: "body", className: "text-muted-foreground", children: failMessage })
13151
+ ] }) }),
13152
+ showHint && hint && /* @__PURE__ */ jsx(Card, { className: "p-4 border-l-4 border-l-warning", children: /* @__PURE__ */ jsx(Typography, { variant: "body", children: hint }) }),
13153
+ /* @__PURE__ */ jsxs(HStack, { gap: "sm", justify: "center", children: [
13154
+ !submitted && /* @__PURE__ */ jsxs(Button, { variant: "primary", onClick: handleSubmit, disabled: !allAssigned, children: [
13155
+ /* @__PURE__ */ jsx(GameIcon, { icon: Send, assetUrl: ui?.["send"], size: "sm" }),
13156
+ t("classifier.check")
13157
+ ] }),
13158
+ /* @__PURE__ */ jsxs(Button, { variant: "secondary", onClick: handleFullReset, children: [
13159
+ /* @__PURE__ */ jsx(GameIcon, { icon: RotateCcw, assetUrl: ui?.["reset"], size: "sm" }),
13160
+ t("classifier.reset")
13161
+ ] })
13162
+ ] })
13163
+ ] })
13164
+ }
13165
+ );
13166
+ }
13167
+ var init_ClassifierBoard = __esm({
13168
+ "components/game/2d/organisms/ClassifierBoard.tsx"() {
13169
+ init_atoms();
13170
+ init_useEventBus();
13171
+ init_boardEntity();
13172
+ init_GameIcon();
13173
+ ClassifierBoard.displayName = "ClassifierBoard";
13174
+ }
13175
+ });
13176
+ function BuilderBoard({
13177
+ entity,
13178
+ completeEvent = "PUZZLE_COMPLETE",
13179
+ placeEvent,
13180
+ checkEvent,
13181
+ playAgainEvent,
13182
+ assetManifest,
13183
+ className
13184
+ }) {
13185
+ const ui = assetManifest?.ui;
13186
+ const { emit } = useEventBus();
13187
+ const { t } = useTranslate();
13188
+ const resolved = boardEntity(entity);
13189
+ const [headerError, setHeaderError] = useState(false);
13190
+ const [selectedComponent, setSelectedComponent] = useState(null);
13191
+ const components = rows(resolved?.components).map((r) => ({
13192
+ id: str(r.id),
13193
+ label: str(r.label),
13194
+ description: str(r.description) || void 0,
13195
+ iconEmoji: str(r.iconEmoji) || void 0,
13196
+ iconUrl: str(r.iconUrl) || void 0,
13197
+ category: str(r.category) || void 0
13198
+ }));
13199
+ const slots = rows(resolved?.slots).map((r) => ({
13200
+ id: str(r.id),
13201
+ label: str(r.label) || void 0,
13202
+ description: str(r.description) || void 0,
13203
+ requiredComponentId: str(r.requiredComponentId),
13204
+ placedComponentId: str(r.placedComponentId) || void 0
13205
+ }));
13206
+ const placements = {};
13207
+ for (const slot of slots) {
13208
+ if (slot.placedComponentId) placements[slot.id] = slot.placedComponentId;
13209
+ }
13210
+ const attempts = num(resolved?.attempts);
13211
+ const result = str(resolved?.result) || "none";
13212
+ const submitted = result === "win";
13213
+ const usedComponentIds = new Set(Object.values(placements));
13214
+ const availableComponents = components.filter((c) => !usedComponentIds.has(c.id));
13215
+ const allPlaced = slots.length > 0 && slots.every((s) => Boolean(placements[s.id]));
13216
+ const results = submitted ? slots.map((slot) => ({
13217
+ slot,
13218
+ placed: placements[slot.id],
13219
+ correct: placements[slot.id] === slot.requiredComponentId
13220
+ })) : [];
13221
+ const showHint = attempts >= 2 && Boolean(str(resolved?.hint));
13222
+ const handlePlaceComponent = (slotId) => {
13223
+ if (submitted || !selectedComponent) return;
13224
+ if (placeEvent) emit(`UI:${placeEvent}`, { slotId, componentId: selectedComponent });
13225
+ setSelectedComponent(null);
13226
+ };
13227
+ const handleRemoveFromSlot = (slotId) => {
13228
+ if (submitted) return;
13229
+ if (placeEvent) emit(`UI:${placeEvent}`, { slotId, componentId: "" });
13230
+ };
13231
+ const handleSubmit = () => {
13232
+ if (checkEvent) emit(`UI:${checkEvent}`, {});
13233
+ const solved = slots.length > 0 && slots.every((s) => placements[s.id] === s.requiredComponentId);
13234
+ if (solved && completeEvent) {
13235
+ emit(`UI:${completeEvent}`, { success: true, attempts: attempts + 1 });
13236
+ }
13237
+ };
13238
+ const handlePlayAgain = () => {
13239
+ setSelectedComponent(null);
13240
+ if (playAgainEvent) emit(`UI:${playAgainEvent}`, {});
13241
+ };
13242
+ const getComponentById = (id) => components.find((c) => c.id === id);
13243
+ if (!resolved) return null;
13244
+ const theme = resolved.theme ?? void 0;
13245
+ const themeBackground = theme?.background;
13246
+ const headerImage = str(resolved.headerImage);
13247
+ const hint = str(resolved.hint);
13248
+ return /* @__PURE__ */ jsx(
13249
+ Box,
13250
+ {
13251
+ className,
13252
+ style: {
13253
+ backgroundImage: themeBackground ? `url(${themeBackground})` : void 0,
13254
+ backgroundSize: "cover",
13255
+ backgroundPosition: "center"
13256
+ },
13257
+ children: /* @__PURE__ */ jsxs(VStack, { gap: "lg", className: "p-4", children: [
13258
+ 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,
13259
+ /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
13260
+ /* @__PURE__ */ jsx(Typography, { variant: "h4", weight: "bold", children: str(resolved.title) }),
13261
+ /* @__PURE__ */ jsx(Typography, { variant: "body", children: str(resolved.description) })
13262
+ ] }) }),
13263
+ /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
13264
+ /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "bold", className: "uppercase tracking-wider text-muted-foreground", children: t("builder.components") }),
13265
+ /* @__PURE__ */ jsxs(HStack, { gap: "sm", className: "flex-wrap", children: [
13266
+ availableComponents.map((comp) => /* @__PURE__ */ jsxs(
13267
+ Button,
13268
+ {
13269
+ size: "sm",
13270
+ variant: selectedComponent === comp.id ? "primary" : "secondary",
13271
+ onClick: () => setSelectedComponent(selectedComponent === comp.id ? null : comp.id),
13272
+ disabled: submitted,
13273
+ children: [
13274
+ 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: [
13275
+ comp.iconEmoji,
13276
+ " "
13277
+ ] }) : null,
13278
+ comp.label
13279
+ ]
13280
+ },
13281
+ comp.id
13282
+ )),
13283
+ availableComponents.length === 0 && !submitted && /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground", children: t("builder.allPlaced") })
13284
+ ] })
13285
+ ] }) }),
13286
+ /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
13287
+ /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "bold", className: "uppercase tracking-wider text-muted-foreground", children: t("builder.blueprint") }),
13288
+ /* @__PURE__ */ jsx(VStack, { gap: "sm", children: slots.map((slot) => {
13289
+ const placedComp = placements[slot.id] ? getComponentById(placements[slot.id]) : null;
13290
+ const result2 = results.find((r) => r.slot.id === slot.id);
13291
+ return /* @__PURE__ */ jsxs(
13292
+ HStack,
13293
+ {
13294
+ gap: "sm",
13295
+ align: "center",
13296
+ className: `p-3 border-2 rounded ${result2 ? result2.correct ? "border-success" : "border-error" : selectedComponent ? "border-dashed border-foreground cursor-pointer" : "border-border"}`,
13297
+ onClick: () => handlePlaceComponent(slot.id),
13298
+ children: [
13299
+ /* @__PURE__ */ jsxs(VStack, { gap: "none", className: "flex-1", children: [
13300
+ /* @__PURE__ */ jsx(Typography, { variant: "body", weight: "medium", children: slot.label }),
13301
+ slot.description && /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground", children: slot.description })
13302
+ ] }),
13303
+ placedComp ? /* @__PURE__ */ jsxs(HStack, { gap: "xs", align: "center", children: [
13304
+ /* @__PURE__ */ jsxs(Badge, { size: "sm", onClick: () => handleRemoveFromSlot(slot.id), children: [
13305
+ 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: [
13306
+ placedComp.iconEmoji,
13307
+ " "
13308
+ ] }) : null,
13309
+ placedComp.label
13310
+ ] }),
13311
+ result2 && /* @__PURE__ */ jsx(
13312
+ GameIcon,
13313
+ {
13314
+ icon: result2.correct ? CheckCircle : XCircle,
13315
+ assetUrl: result2.correct ? ui?.["correct"] : ui?.["incorrect"],
13316
+ size: "sm",
13317
+ className: result2.correct ? "text-success" : "text-error"
13318
+ }
13319
+ )
13320
+ ] }) : /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground", children: t("builder.empty") })
13321
+ ]
13322
+ },
13323
+ slot.id
13324
+ );
13325
+ }) })
13326
+ ] }) }),
13327
+ submitted && /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", align: "center", children: [
13328
+ /* @__PURE__ */ jsx(GameIcon, { icon: CheckCircle, assetUrl: ui?.["correct"], size: "lg", className: "text-success" }),
13329
+ /* @__PURE__ */ jsx(Typography, { variant: "body", weight: "bold", children: str(resolved.successMessage) || t("builder.success") })
13330
+ ] }) }),
13331
+ showHint && hint && /* @__PURE__ */ jsx(Card, { className: "p-4 border-l-4 border-l-warning", children: /* @__PURE__ */ jsx(Typography, { variant: "body", children: hint }) }),
13332
+ /* @__PURE__ */ jsxs(HStack, { gap: "sm", justify: "center", children: [
13333
+ !submitted && /* @__PURE__ */ jsxs(Button, { variant: "primary", onClick: handleSubmit, disabled: !allPlaced, children: [
13334
+ /* @__PURE__ */ jsx(GameIcon, { icon: Wrench, assetUrl: ui?.["build"], size: "sm" }),
13335
+ t("builder.build")
13336
+ ] }),
13337
+ /* @__PURE__ */ jsxs(Button, { variant: "secondary", onClick: handlePlayAgain, children: [
13338
+ /* @__PURE__ */ jsx(GameIcon, { icon: RotateCcw, assetUrl: ui?.["reset"], size: "sm" }),
13339
+ t("builder.reset")
13340
+ ] })
13341
+ ] })
13342
+ ] })
13343
+ }
13344
+ );
13345
+ }
13346
+ var init_BuilderBoard = __esm({
13347
+ "components/game/2d/organisms/BuilderBoard.tsx"() {
13348
+ init_atoms();
13349
+ init_useEventBus();
13350
+ init_boardEntity();
13351
+ init_GameIcon();
13352
+ BuilderBoard.displayName = "BuilderBoard";
13353
+ }
13354
+ });
13355
+ function toDebuggerLine(v) {
13356
+ if (v === null || typeof v !== "object" || Array.isArray(v) || v instanceof Date) return null;
13357
+ const id = v["id"];
13358
+ const content = v["content"];
13359
+ const isBug = v["isBug"];
13360
+ if (typeof id !== "string" || typeof content !== "string" || typeof isBug !== "boolean") return null;
13361
+ const isFlagged = v["isFlagged"];
13362
+ const explanation = v["explanation"];
13363
+ return {
13364
+ id,
13365
+ content,
13366
+ isBug,
13367
+ isFlagged: typeof isFlagged === "boolean" ? isFlagged : void 0,
13368
+ explanation: typeof explanation === "string" ? explanation : void 0
13369
+ };
13370
+ }
13371
+ function DebuggerBoard({
13372
+ entity,
13373
+ completeEvent = "PUZZLE_COMPLETE",
13374
+ toggleFlagEvent,
13375
+ checkEvent,
13376
+ playAgainEvent,
13377
+ assetManifest,
13378
+ className
13379
+ }) {
13380
+ const ui = assetManifest?.ui;
13381
+ const { emit } = useEventBus();
13382
+ const { t } = useTranslate();
13383
+ const resolved = boardEntity(entity);
13384
+ const [headerError, setHeaderError] = useState(false);
13385
+ const lines = Array.isArray(resolved?.lines) ? resolved.lines.flatMap((v) => {
13386
+ const l = toDebuggerLine(v);
13387
+ return l ? [l] : [];
13388
+ }) : [];
13389
+ const result = str(resolved?.result) || "none";
13390
+ const attempts = num(resolved?.attempts);
13391
+ const submitted = result === "win";
13392
+ const showHint = !submitted && attempts >= 2 && Boolean(str(resolved?.hint));
13393
+ const bugLines = lines.filter((l) => l.isBug);
13394
+ const flaggedLines = lines.filter((l) => l.isFlagged);
13395
+ const correctFlags = lines.filter((l) => l.isBug && l.isFlagged);
13396
+ const falseFlags = lines.filter((l) => !l.isBug && l.isFlagged);
13397
+ const allCorrect = submitted;
13398
+ const toggleLine = (lineId) => {
13399
+ if (submitted) return;
13400
+ if (toggleFlagEvent) emit(`UI:${toggleFlagEvent}`, { lineId });
13401
+ };
13402
+ const handleSubmit = useCallback(() => {
13403
+ if (checkEvent) emit(`UI:${checkEvent}`, {});
13404
+ const correct = correctFlags.length === bugLines.length && falseFlags.length === 0;
13405
+ if (correct) emit(`UI:${completeEvent}`, { success: true, attempts: attempts + 1 });
13406
+ }, [checkEvent, correctFlags.length, bugLines.length, falseFlags.length, attempts, completeEvent, emit]);
13407
+ const handleReset = () => {
13408
+ if (playAgainEvent) emit(`UI:${playAgainEvent}`, {});
13409
+ };
13410
+ if (!resolved) return null;
13411
+ const theme = resolved.theme ?? void 0;
13412
+ const themeBackground = theme?.background;
13413
+ const headerImage = str(resolved.headerImage);
13414
+ const hint = str(resolved.hint);
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__ */ jsxs(HStack, { gap: "xs", align: "center", children: [
13428
+ /* @__PURE__ */ jsx(GameIcon, { icon: Bug, assetUrl: ui?.["bug"], size: "sm" }),
13429
+ /* @__PURE__ */ jsx(Typography, { variant: "h4", weight: "bold", children: str(resolved.title) })
13430
+ ] }),
13431
+ /* @__PURE__ */ jsx(Typography, { variant: "body", children: str(resolved.description) }),
13432
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground", children: t("debugger.findBugs", { count: String(lines.filter((l) => l.isBug).length) }) })
13433
+ ] }) }),
13434
+ /* @__PURE__ */ jsx(Card, { className: "p-0 overflow-hidden", children: /* @__PURE__ */ jsx(VStack, { gap: "none", children: lines.map((line, i) => {
13435
+ const isFlagged = !!line.isFlagged;
13436
+ let lineStyle = "";
13437
+ if (submitted) {
13438
+ if (line.isBug && isFlagged) lineStyle = "bg-success/10";
13439
+ else if (line.isBug && !isFlagged) lineStyle = "bg-warning/10";
13440
+ else if (!line.isBug && isFlagged) lineStyle = "bg-error/10";
13441
+ } else if (isFlagged) {
13442
+ lineStyle = "bg-error/10";
13443
+ }
13444
+ return /* @__PURE__ */ jsxs(
13445
+ HStack,
13446
+ {
13447
+ gap: "none",
13448
+ align: "stretch",
13449
+ className: `border-b border-border cursor-pointer hover:bg-muted ${lineStyle}`,
13450
+ onClick: () => toggleLine(line.id),
13451
+ children: [
13452
+ /* @__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 }) }),
13453
+ /* @__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 }) }),
13454
+ /* @__PURE__ */ jsxs(Box, { className: "w-8 flex-shrink-0 flex items-center justify-center", children: [
13455
+ isFlagged && /* @__PURE__ */ jsx(GameIcon, { icon: Bug, assetUrl: ui?.["bug"], size: "sm", className: "text-error" }),
13456
+ submitted && line.isBug && !isFlagged && /* @__PURE__ */ jsx(GameIcon, { icon: Bug, assetUrl: ui?.["bug"], size: "sm", className: "text-warning" })
13457
+ ] })
13458
+ ]
13459
+ },
13460
+ line.id
13461
+ );
13462
+ }) }) }),
13463
+ submitted && /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
13464
+ /* @__PURE__ */ jsx(Typography, { variant: "body", weight: "bold", children: allCorrect ? str(resolved.successMessage) || t("debugger.allFound") : `${correctFlags.length}/${bugLines.length} ${t("debugger.bugsFound")}` }),
13465
+ bugLines.map((line) => /* @__PURE__ */ jsxs(HStack, { gap: "xs", align: "start", children: [
13466
+ /* @__PURE__ */ jsx(
13467
+ GameIcon,
13468
+ {
13469
+ icon: line.isFlagged ? CheckCircle : XCircle,
13470
+ assetUrl: line.isFlagged ? ui?.["correct"] : ui?.["incorrect"],
13471
+ size: "sm",
13472
+ className: line.isFlagged ? "text-success mt-0.5" : "text-warning mt-0.5"
13473
+ }
13474
+ ),
13475
+ /* @__PURE__ */ jsxs(VStack, { gap: "none", children: [
13476
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", weight: "bold", className: "font-mono", children: line.content.trim() }),
13477
+ line.explanation && /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground", children: line.explanation })
13478
+ ] })
13479
+ ] }, line.id))
13480
+ ] }) }),
13481
+ showHint && hint && /* @__PURE__ */ jsx(Card, { className: "p-4 border-l-4 border-l-warning", children: /* @__PURE__ */ jsx(Typography, { variant: "body", children: hint }) }),
13482
+ /* @__PURE__ */ jsxs(HStack, { gap: "sm", justify: "center", children: [
13483
+ !submitted && /* @__PURE__ */ jsxs(Button, { variant: "primary", onClick: handleSubmit, disabled: flaggedLines.length === 0, children: [
13484
+ /* @__PURE__ */ jsx(GameIcon, { icon: Send, assetUrl: ui?.["send"], size: "sm" }),
13485
+ t("debugger.submit")
13486
+ ] }),
13487
+ /* @__PURE__ */ jsxs(Button, { variant: "secondary", onClick: handleReset, children: [
13488
+ /* @__PURE__ */ jsx(GameIcon, { icon: RotateCcw, assetUrl: ui?.["reset"], size: "sm" }),
13489
+ t("debugger.reset")
13490
+ ] })
13491
+ ] })
13492
+ ] })
13493
+ }
13494
+ );
13495
+ }
13496
+ var init_DebuggerBoard = __esm({
13497
+ "components/game/2d/organisms/DebuggerBoard.tsx"() {
13498
+ init_atoms();
13499
+ init_useEventBus();
13500
+ init_boardEntity();
13501
+ init_GameIcon();
13502
+ DebuggerBoard.displayName = "DebuggerBoard";
13503
+ }
13504
+ });
13505
+ function NegotiatorBoard({
13506
+ entity,
13507
+ completeEvent = "PUZZLE_COMPLETE",
13508
+ playRoundEvent,
13509
+ finishEvent,
13510
+ playAgainEvent,
13511
+ assetManifest,
13512
+ className
13513
+ }) {
13514
+ const ui = assetManifest?.ui;
13515
+ const { emit } = useEventBus();
13516
+ const { t } = useTranslate();
13517
+ const resolved = boardEntity(entity);
13518
+ const [history, setHistory] = useState([]);
13519
+ const [headerError, setHeaderError] = useState(false);
13520
+ const [showHint, setShowHint] = useState(false);
13521
+ const totalRounds = num(resolved?.maxRounds);
13522
+ const targetScore = num(resolved?.targetScore);
13523
+ const currentRound = num(resolved?.round);
13524
+ const result = str(resolved?.result) || "none";
13525
+ const playerTotal = num(resolved?.score);
13526
+ const isComplete = result !== "none" || totalRounds > 0 && currentRound >= totalRounds;
13527
+ const won = result === "win";
13528
+ const lastPlayerAction = str(resolved?.lastPlayerAction);
13529
+ const lastOpponentAction = str(resolved?.lastOpponentAction);
13530
+ const lastPayoff = num(resolved?.lastPayoff);
13531
+ const actions = Array.isArray(resolved?.actions) ? resolved.actions.flatMap((item) => {
13532
+ if (item !== null && typeof item === "object" && !Array.isArray(item) && !(item instanceof Date) && typeof item.id === "string" && typeof item.label === "string")
13533
+ return [{ id: item.id, label: item.label, description: typeof item.description === "string" ? item.description : void 0 }];
13534
+ return [];
13535
+ }) : [];
13536
+ const payoffMatrix = Array.isArray(resolved?.payoffMatrix) ? resolved.payoffMatrix.flatMap((item) => {
13537
+ if (item !== null && typeof item === "object" && !Array.isArray(item) && !(item instanceof Date) && typeof item.playerAction === "string" && typeof item.opponentAction === "string")
13538
+ return [{ playerAction: item.playerAction, opponentAction: item.opponentAction, playerPayoff: typeof item.playerPayoff === "number" ? item.playerPayoff : 0, opponentPayoff: typeof item.opponentPayoff === "number" ? item.opponentPayoff : 0 }];
13539
+ return [];
13540
+ }) : [];
13541
+ const prevRoundRef = useRef(currentRound);
13542
+ useEffect(() => {
13543
+ if (currentRound > prevRoundRef.current && lastPlayerAction) {
13544
+ const opponentPayoffEntry = payoffMatrix.find(
13545
+ (p) => p.playerAction === lastPlayerAction && p.opponentAction === lastOpponentAction
13546
+ );
13547
+ setHistory((prev) => [
13548
+ ...prev,
13549
+ {
13550
+ round: currentRound,
13551
+ playerAction: lastPlayerAction,
13552
+ opponentAction: lastOpponentAction,
13553
+ playerPayoff: lastPayoff,
13554
+ opponentPayoff: opponentPayoffEntry?.opponentPayoff ?? 0
13555
+ }
13556
+ ]);
13557
+ }
13558
+ prevRoundRef.current = currentRound;
13559
+ }, [currentRound, lastPlayerAction, lastOpponentAction, lastPayoff, payoffMatrix]);
13560
+ const opponentTotal = useMemo(() => history.reduce((s, r) => s + r.opponentPayoff, 0), [history]);
13561
+ const handleAction = useCallback((actionId) => {
13562
+ if (isComplete) return;
13563
+ if (playRoundEvent) {
13564
+ emit(`UI:${playRoundEvent}`, { playerAction: actionId, payoff: 0 });
13565
+ }
13566
+ if (totalRounds > 0 && currentRound + 1 >= totalRounds) {
13567
+ if (finishEvent) {
13568
+ emit(`UI:${finishEvent}`, {});
13569
+ }
13570
+ if (str(resolved?.hint)) {
13571
+ setShowHint(true);
13572
+ }
13573
+ }
13574
+ }, [isComplete, resolved, totalRounds, currentRound, playRoundEvent, finishEvent, emit]);
13575
+ const handleReset = useCallback(() => {
13576
+ setHistory([]);
13577
+ setShowHint(false);
13578
+ prevRoundRef.current = 0;
13579
+ if (playAgainEvent) {
13580
+ emit(`UI:${playAgainEvent}`, {});
13581
+ }
13582
+ }, [playAgainEvent, emit]);
13583
+ const completedRef = useRef(false);
13584
+ useEffect(() => {
13585
+ if (result === "win" && !completedRef.current) {
13586
+ completedRef.current = true;
13587
+ emit(`UI:${completeEvent}`, { success: true, score: playerTotal });
13588
+ } else if (result === "none") {
13589
+ completedRef.current = false;
13590
+ }
13591
+ }, [result, playerTotal, completeEvent, emit]);
13592
+ const getActionLabel = (id) => actions.find((a) => a.id === id)?.label ?? id;
13593
+ if (!resolved) return null;
13594
+ const theme = resolved.theme ?? void 0;
13595
+ const themeBackground = theme?.background;
13596
+ const headerImage = str(resolved.headerImage);
13597
+ const hint = str(resolved.hint);
13598
+ return /* @__PURE__ */ jsx(
13599
+ Box,
13600
+ {
13601
+ className,
13602
+ style: {
13603
+ backgroundImage: themeBackground ? `url(${themeBackground})` : void 0,
13604
+ backgroundSize: "cover",
13605
+ backgroundPosition: "center"
13606
+ },
13607
+ children: /* @__PURE__ */ jsxs(VStack, { gap: "lg", className: "p-4", children: [
13608
+ 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,
13609
+ /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
13610
+ /* @__PURE__ */ jsx(Typography, { variant: "h4", weight: "bold", children: str(resolved.title) }),
13611
+ /* @__PURE__ */ jsx(Typography, { variant: "body", children: str(resolved.description) }),
13612
+ /* @__PURE__ */ jsxs(HStack, { gap: "md", children: [
13613
+ /* @__PURE__ */ jsx(Badge, { size: "sm", children: t("negotiator.round", { current: String(currentRound), total: String(totalRounds) }) }),
13614
+ /* @__PURE__ */ jsxs(Badge, { size: "sm", children: [
13615
+ t("negotiator.target"),
13616
+ ": ",
13617
+ targetScore
13618
+ ] })
13619
+ ] })
13620
+ ] }) }),
13621
+ /* @__PURE__ */ jsxs(HStack, { gap: "md", justify: "center", children: [
13622
+ /* @__PURE__ */ jsx(Card, { className: "p-4 flex-1 text-center", children: /* @__PURE__ */ jsxs(VStack, { gap: "xs", align: "center", children: [
13623
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground", children: t("negotiator.you") }),
13624
+ /* @__PURE__ */ jsx(Typography, { variant: "h3", weight: "bold", children: playerTotal })
13625
+ ] }) }),
13626
+ /* @__PURE__ */ jsx(Card, { className: "p-4 flex-1 text-center", children: /* @__PURE__ */ jsxs(VStack, { gap: "xs", align: "center", children: [
13627
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground", children: t("negotiator.opponent") }),
13628
+ /* @__PURE__ */ jsx(Typography, { variant: "h3", weight: "bold", children: opponentTotal })
13629
+ ] }) })
13630
+ ] }),
13631
+ !isComplete && /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
13632
+ /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "bold", className: "uppercase tracking-wider text-muted-foreground", children: t("negotiator.chooseAction") }),
13633
+ /* @__PURE__ */ jsx(HStack, { gap: "sm", justify: "center", className: "flex-wrap", children: actions.map((action) => /* @__PURE__ */ jsx(
13634
+ Button,
13635
+ {
13636
+ variant: "primary",
13637
+ onClick: () => handleAction(action.id),
13638
+ children: action.label
13639
+ },
13640
+ action.id
13641
+ )) })
13642
+ ] }) }),
13643
+ history.length > 0 && /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
13644
+ /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "bold", className: "uppercase tracking-wider text-muted-foreground", children: t("negotiator.history") }),
13645
+ history.map((round) => /* @__PURE__ */ jsxs(HStack, { gap: "sm", align: "center", className: "text-sm", children: [
13646
+ /* @__PURE__ */ jsxs(Badge, { size: "sm", children: [
13647
+ "R",
13648
+ round.round
13649
+ ] }),
13650
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", children: getActionLabel(round.playerAction) }),
13651
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground", children: "vs" }),
13652
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", children: getActionLabel(round.opponentAction) }),
13653
+ /* @__PURE__ */ jsx(GameIcon, { icon: ArrowRight, assetUrl: ui?.["arrow"], size: "sm" }),
13654
+ /* @__PURE__ */ jsxs(Typography, { variant: "caption", weight: "bold", className: "text-success", children: [
13655
+ "+",
13656
+ round.playerPayoff
13657
+ ] }),
13658
+ /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "text-muted-foreground", children: [
13659
+ "/ +",
13660
+ round.opponentPayoff
13661
+ ] })
13662
+ ] }, round.round))
13663
+ ] }) }),
13664
+ isComplete && /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", align: "center", children: [
13665
+ /* @__PURE__ */ jsx(GameIcon, { icon: CheckCircle, assetUrl: ui?.["correct"], size: "lg", className: won ? "text-success" : "text-error" }),
13666
+ /* @__PURE__ */ jsx(Typography, { variant: "body", weight: "bold", children: won ? str(resolved.successMessage) || t("negotiator.success") : str(resolved.failMessage) || t("negotiator.failed") }),
13667
+ /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "text-muted-foreground", children: [
13668
+ t("negotiator.finalScore"),
13669
+ ": ",
13670
+ playerTotal,
13671
+ "/",
13672
+ targetScore
13673
+ ] })
13674
+ ] }) }),
13675
+ showHint && hint && !won && /* @__PURE__ */ jsx(Card, { className: "p-4 border-l-4 border-l-warning", children: /* @__PURE__ */ jsx(Typography, { variant: "body", children: hint }) }),
13676
+ isComplete && !won && /* @__PURE__ */ jsx(HStack, { justify: "center", children: /* @__PURE__ */ jsx(Button, { variant: "primary", onClick: handleReset, children: t("negotiator.playAgain") }) })
13677
+ ] })
13678
+ }
13679
+ );
13680
+ }
13681
+ var init_NegotiatorBoard = __esm({
13682
+ "components/game/2d/organisms/NegotiatorBoard.tsx"() {
13683
+ init_atoms();
13684
+ init_useEventBus();
13685
+ init_boardEntity();
13686
+ init_GameIcon();
13687
+ NegotiatorBoard.displayName = "NegotiatorBoard";
13688
+ }
13689
+ });
11607
13690
 
11608
13691
  // components/game/shared/lib/mechanics.ts
11609
13692
  var projectileMotion, pendulum, springOscillator;
@@ -11811,7 +13894,7 @@ function SimulationCanvas({
11811
13894
  }
11812
13895
  var PRESET_BY_ID;
11813
13896
  var init_SimulationCanvas = __esm({
11814
- "components/game/2d/molecules/SimulationCanvas.tsx"() {
13897
+ "components/game/2d/organisms/SimulationCanvas.tsx"() {
11815
13898
  init_cn();
11816
13899
  init_atoms();
11817
13900
  init_verificationRegistry();
@@ -12433,7 +14516,7 @@ var init_ErrorBoundary = __esm({
12433
14516
  }
12434
14517
  );
12435
14518
  };
12436
- ErrorBoundary = class extends React86__default.Component {
14519
+ ErrorBoundary = class extends React97__default.Component {
12437
14520
  constructor(props) {
12438
14521
  super(props);
12439
14522
  __publicField(this, "reset", () => {
@@ -12478,15 +14561,15 @@ function HeaderSkeleton({ className }) {
12478
14561
  ] })
12479
14562
  ] });
12480
14563
  }
12481
- function TableSkeleton({ rows = 5, columns = 4, className }) {
14564
+ function TableSkeleton({ rows: rows2 = 5, columns = 4, className }) {
12482
14565
  return /* @__PURE__ */ jsxs(VStack, { gap: "none", className: cn("border border-border rounded-lg overflow-hidden", className), children: [
12483
14566
  /* @__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)) }),
12484
- Array.from({ length: rows }).map((_, rowIdx) => /* @__PURE__ */ jsx(
14567
+ Array.from({ length: rows2 }).map((_, rowIdx) => /* @__PURE__ */ jsx(
12485
14568
  HStack,
12486
14569
  {
12487
14570
  className: cn(
12488
14571
  "px-4 py-3",
12489
- rowIdx < rows - 1 && "border-b border-border"
14572
+ rowIdx < rows2 - 1 && "border-b border-border"
12490
14573
  ),
12491
14574
  children: Array.from({ length: columns }).map((_2, colIdx) => /* @__PURE__ */ jsx(SkeletonLine, { className: "flex-1 mx-2" }, colIdx))
12492
14575
  },
@@ -12534,18 +14617,18 @@ function CardSkeleton({ className }) {
12534
14617
  }
12535
14618
  );
12536
14619
  }
12537
- function TextSkeleton({ rows = 3, className }) {
12538
- return /* @__PURE__ */ jsx(VStack, { gap: "sm", className, children: Array.from({ length: rows }).map((_, i) => /* @__PURE__ */ jsx(
14620
+ function TextSkeleton({ rows: rows2 = 3, className }) {
14621
+ return /* @__PURE__ */ jsx(VStack, { gap: "sm", className, children: Array.from({ length: rows2 }).map((_, i) => /* @__PURE__ */ jsx(
12539
14622
  SkeletonLine,
12540
14623
  {
12541
- className: i === rows - 1 ? "w-2/3" : "w-full"
14624
+ className: i === rows2 - 1 ? "w-2/3" : "w-full"
12542
14625
  },
12543
14626
  i
12544
14627
  )) });
12545
14628
  }
12546
14629
  function Skeleton({
12547
14630
  variant = "text",
12548
- rows,
14631
+ rows: rows2,
12549
14632
  columns,
12550
14633
  fields,
12551
14634
  className
@@ -12555,15 +14638,15 @@ function Skeleton({
12555
14638
  case "header":
12556
14639
  return /* @__PURE__ */ jsx(HeaderSkeleton, { className });
12557
14640
  case "table":
12558
- return /* @__PURE__ */ jsx(TableSkeleton, { rows, columns, className });
14641
+ return /* @__PURE__ */ jsx(TableSkeleton, { rows: rows2, columns, className });
12559
14642
  case "form":
12560
14643
  return /* @__PURE__ */ jsx(FormSkeleton, { fields, className });
12561
14644
  case "card":
12562
14645
  return /* @__PURE__ */ jsx(CardSkeleton, { className });
12563
14646
  case "text":
12564
- return /* @__PURE__ */ jsx(TextSkeleton, { rows, className });
14647
+ return /* @__PURE__ */ jsx(TextSkeleton, { rows: rows2, className });
12565
14648
  default:
12566
- return /* @__PURE__ */ jsx(TextSkeleton, { rows, className });
14649
+ return /* @__PURE__ */ jsx(TextSkeleton, { rows: rows2, className });
12567
14650
  }
12568
14651
  }
12569
14652
  var pulseClass;
@@ -13098,7 +15181,7 @@ var init_Container = __esm({
13098
15181
  as: Component = "div"
13099
15182
  }) => {
13100
15183
  const resolvedSize = maxWidth ?? size ?? "lg";
13101
- return React86__default.createElement(
15184
+ return React97__default.createElement(
13102
15185
  Component,
13103
15186
  {
13104
15187
  className: cn(
@@ -15766,7 +17849,7 @@ var init_CodeBlock = __esm({
15766
17849
  DIFF_STYLE_FALLBACK = { bg: "", prefix: " ", text: "text-foreground" };
15767
17850
  LINE_PROPS_FN = (n) => ({ "data-line": String(n - 1) });
15768
17851
  HIDDEN_LINE_NUMBERS = { display: "none" };
15769
- CodeBlock = React86__default.memo(
17852
+ CodeBlock = React97__default.memo(
15770
17853
  ({
15771
17854
  code: rawCode,
15772
17855
  language = "text",
@@ -15935,24 +18018,24 @@ var init_CodeBlock = __esm({
15935
18018
  return;
15936
18019
  }
15937
18020
  lineEls.forEach((el) => {
15938
- const num = parseInt(el.getAttribute("data-line") ?? "-1", 10);
15939
- if (hiddenLines.has(num)) {
18021
+ const num2 = parseInt(el.getAttribute("data-line") ?? "-1", 10);
18022
+ if (hiddenLines.has(num2)) {
15940
18023
  el.style.display = "none";
15941
18024
  return;
15942
18025
  }
15943
18026
  el.style.display = "";
15944
18027
  el.style.position = "relative";
15945
18028
  el.style.paddingLeft = "1.2em";
15946
- const region = foldStartMap.get(num);
18029
+ const region = foldStartMap.get(num2);
15947
18030
  if (!region) return;
15948
- const isCollapsed = collapsed.has(num);
18031
+ const isCollapsed = collapsed.has(num2);
15949
18032
  const toggle = document.createElement("span");
15950
18033
  toggle.className = "fold-toggle";
15951
18034
  toggle.textContent = isCollapsed ? "\u25B6" : "\u25BC";
15952
18035
  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%";
15953
18036
  toggle.addEventListener("click", (e) => {
15954
18037
  e.stopPropagation();
15955
- toggleFoldRef.current(num);
18038
+ toggleFoldRef.current(num2);
15956
18039
  });
15957
18040
  el.insertBefore(toggle, el.firstChild);
15958
18041
  if (isCollapsed) {
@@ -16353,7 +18436,7 @@ var init_MarkdownContent = __esm({
16353
18436
  init_Box();
16354
18437
  init_CodeBlock();
16355
18438
  init_cn();
16356
- MarkdownContent = React86__default.memo(
18439
+ MarkdownContent = React97__default.memo(
16357
18440
  ({ content, direction = "ltr", className }) => {
16358
18441
  const { t: _t } = useTranslate();
16359
18442
  const safeContent = typeof content === "string" ? content : String(content ?? "");
@@ -16922,7 +19005,7 @@ var init_QuizBlock = __esm({
16922
19005
  QuizBlock.displayName = "QuizBlock";
16923
19006
  }
16924
19007
  });
16925
- var StateNode, TransitionBundleArrow, BundleTooltip, EntityBox, OutputsBox, Legend, StateMachineView;
19008
+ var StateNode2, TransitionBundleArrow, BundleTooltip, EntityBox, OutputsBox, Legend, StateMachineView;
16926
19009
  var init_StateMachineView = __esm({
16927
19010
  "components/core/organisms/StateMachineView.tsx"() {
16928
19011
  "use client";
@@ -16934,7 +19017,7 @@ var init_StateMachineView = __esm({
16934
19017
  init_Icon();
16935
19018
  init_useEventBus();
16936
19019
  init_cn();
16937
- StateNode = ({ state, config }) => {
19020
+ StateNode2 = ({ state, config }) => {
16938
19021
  const { t } = useTranslate();
16939
19022
  const size = state.radius * 2;
16940
19023
  let borderColor = config.colors.nodeBorder;
@@ -17680,8 +19763,8 @@ var init_StateMachineView = __esm({
17680
19763
  style: { top: title ? 30 : 0 },
17681
19764
  children: [
17682
19765
  entity && /* @__PURE__ */ jsx(EntityBox, { entity, config }),
17683
- states.map((state) => renderStateNode ? /* @__PURE__ */ jsx(React86__default.Fragment, { children: renderStateNode(state, config) }, state.id) : /* @__PURE__ */ jsx(
17684
- StateNode,
19766
+ states.map((state) => renderStateNode ? /* @__PURE__ */ jsx(React97__default.Fragment, { children: renderStateNode(state, config) }, state.id) : /* @__PURE__ */ jsx(
19767
+ StateNode2,
17685
19768
  {
17686
19769
  state,
17687
19770
  config
@@ -23318,8 +25401,8 @@ var init_Menu = __esm({
23318
25401
  "bottom-end": "bottom-start"
23319
25402
  };
23320
25403
  const effectivePosition = direction === "rtl" ? rtlMirror[position] ?? position : position;
23321
- const triggerChild = React86__default.isValidElement(trigger) ? trigger : /* @__PURE__ */ jsx(Typography, { variant: "small", as: "span", children: trigger });
23322
- const triggerElement = React86__default.cloneElement(
25404
+ const triggerChild = React97__default.isValidElement(trigger) ? trigger : /* @__PURE__ */ jsx(Typography, { variant: "small", as: "span", children: trigger });
25405
+ const triggerElement = React97__default.cloneElement(
23323
25406
  triggerChild,
23324
25407
  {
23325
25408
  ref: triggerRef,
@@ -23414,14 +25497,14 @@ function useDataDnd(args) {
23414
25497
  const isZone = Boolean(dragGroup || accepts || sortable);
23415
25498
  const enabled = isZone || Boolean(dndRoot);
23416
25499
  const eventBus = useEventBus();
23417
- const parentRoot = React86__default.useContext(RootCtx);
25500
+ const parentRoot = React97__default.useContext(RootCtx);
23418
25501
  const isRoot = enabled && parentRoot === null;
23419
- const zoneId = React86__default.useId();
25502
+ const zoneId = React97__default.useId();
23420
25503
  const ownGroup = dragGroup ?? accepts ?? zoneId;
23421
- const [optimisticOrders, setOptimisticOrders] = React86__default.useState(() => /* @__PURE__ */ new Map());
23422
- const optimisticOrdersRef = React86__default.useRef(optimisticOrders);
25504
+ const [optimisticOrders, setOptimisticOrders] = React97__default.useState(() => /* @__PURE__ */ new Map());
25505
+ const optimisticOrdersRef = React97__default.useRef(optimisticOrders);
23423
25506
  optimisticOrdersRef.current = optimisticOrders;
23424
- const clearOptimisticOrder = React86__default.useCallback((group) => {
25507
+ const clearOptimisticOrder = React97__default.useCallback((group) => {
23425
25508
  setOptimisticOrders((prev) => {
23426
25509
  if (!prev.has(group)) return prev;
23427
25510
  const next = new Map(prev);
@@ -23446,7 +25529,7 @@ function useDataDnd(args) {
23446
25529
  const raw = it[dndItemIdField];
23447
25530
  return raw != null ? String(raw) : `__idx_${idx}`;
23448
25531
  }).join("|");
23449
- const itemIds = React86__default.useMemo(
25532
+ const itemIds = React97__default.useMemo(
23450
25533
  () => orderedItems.map((it, idx) => {
23451
25534
  const raw = it[dndItemIdField];
23452
25535
  return raw != null ? String(raw) : `__idx_${idx}`;
@@ -23457,7 +25540,7 @@ function useDataDnd(args) {
23457
25540
  const raw = it[dndItemIdField];
23458
25541
  return raw != null ? String(raw) : `__${idx}`;
23459
25542
  }).join("|");
23460
- React86__default.useEffect(() => {
25543
+ React97__default.useEffect(() => {
23461
25544
  const root = isRoot ? null : parentRoot;
23462
25545
  if (root) {
23463
25546
  root.clearOptimisticOrder(ownGroup);
@@ -23465,20 +25548,20 @@ function useDataDnd(args) {
23465
25548
  clearOptimisticOrder(ownGroup);
23466
25549
  }
23467
25550
  }, [itemsContentSig, ownGroup]);
23468
- const zonesRef = React86__default.useRef(/* @__PURE__ */ new Map());
23469
- const registerZone = React86__default.useCallback((zoneId2, meta2) => {
25551
+ const zonesRef = React97__default.useRef(/* @__PURE__ */ new Map());
25552
+ const registerZone = React97__default.useCallback((zoneId2, meta2) => {
23470
25553
  zonesRef.current.set(zoneId2, meta2);
23471
25554
  }, []);
23472
- const unregisterZone = React86__default.useCallback((zoneId2) => {
25555
+ const unregisterZone = React97__default.useCallback((zoneId2) => {
23473
25556
  zonesRef.current.delete(zoneId2);
23474
25557
  }, []);
23475
- const [activeDrag, setActiveDrag] = React86__default.useState(null);
23476
- const [overZoneGroup, setOverZoneGroup] = React86__default.useState(null);
23477
- const meta = React86__default.useMemo(
25558
+ const [activeDrag, setActiveDrag] = React97__default.useState(null);
25559
+ const [overZoneGroup, setOverZoneGroup] = React97__default.useState(null);
25560
+ const meta = React97__default.useMemo(
23478
25561
  () => ({ group: ownGroup, dropEvent, reorderEvent, positionEvent, itemIds, rawItems: items, idField: dndItemIdField }),
23479
25562
  [ownGroup, dropEvent, reorderEvent, positionEvent, itemIds, items, dndItemIdField]
23480
25563
  );
23481
- React86__default.useEffect(() => {
25564
+ React97__default.useEffect(() => {
23482
25565
  const target = isRoot ? null : parentRoot;
23483
25566
  if (!target) {
23484
25567
  zonesRef.current.set(zoneId, meta);
@@ -23497,7 +25580,7 @@ function useDataDnd(args) {
23497
25580
  }, [parentRoot, isRoot, zoneId, meta]);
23498
25581
  const sensors = useAlmadarDndSensors(true);
23499
25582
  const collisionDetection = almadarDndCollisionDetection;
23500
- const findZoneByItem = React86__default.useCallback(
25583
+ const findZoneByItem = React97__default.useCallback(
23501
25584
  (id) => {
23502
25585
  for (const z of zonesRef.current.values()) {
23503
25586
  if (z.itemIds.includes(id)) return z;
@@ -23506,7 +25589,7 @@ function useDataDnd(args) {
23506
25589
  },
23507
25590
  []
23508
25591
  );
23509
- React86__default.useCallback(
25592
+ React97__default.useCallback(
23510
25593
  (group) => {
23511
25594
  for (const z of zonesRef.current.values()) {
23512
25595
  if (z.group === group) return z;
@@ -23515,7 +25598,7 @@ function useDataDnd(args) {
23515
25598
  },
23516
25599
  []
23517
25600
  );
23518
- const handleDragEnd = React86__default.useCallback(
25601
+ const handleDragEnd = React97__default.useCallback(
23519
25602
  (event) => {
23520
25603
  const { active, over } = event;
23521
25604
  const activeIdStr = String(active.id);
@@ -23606,8 +25689,8 @@ function useDataDnd(args) {
23606
25689
  },
23607
25690
  [eventBus]
23608
25691
  );
23609
- const sortableData = React86__default.useMemo(() => ({ dndGroup: ownGroup }), [ownGroup]);
23610
- const SortableItem = React86__default.useCallback(
25692
+ const sortableData = React97__default.useMemo(() => ({ dndGroup: ownGroup }), [ownGroup]);
25693
+ const SortableItem = React97__default.useCallback(
23611
25694
  ({ id, children }) => {
23612
25695
  const {
23613
25696
  attributes,
@@ -23647,7 +25730,7 @@ function useDataDnd(args) {
23647
25730
  id: droppableId,
23648
25731
  data: sortableData
23649
25732
  });
23650
- const ctx = React86__default.useContext(RootCtx);
25733
+ const ctx = React97__default.useContext(RootCtx);
23651
25734
  const activeDrag2 = ctx?.activeDrag ?? null;
23652
25735
  const overZoneGroup2 = ctx?.overZoneGroup ?? null;
23653
25736
  const isThisZoneOver = overZoneGroup2 === ownGroup;
@@ -23662,7 +25745,7 @@ function useDataDnd(args) {
23662
25745
  showForeignPlaceholder,
23663
25746
  ctxAvailable: ctx != null
23664
25747
  });
23665
- React86__default.useEffect(() => {
25748
+ React97__default.useEffect(() => {
23666
25749
  dndLog.info("dropzone:isOver:change", { droppableId, group: ownGroup, isOver, isThisZoneOver, showForeignPlaceholder, activeDragSourceGroup: activeDrag2?.sourceGroup ?? null });
23667
25750
  }, [droppableId, isOver, isThisZoneOver, showForeignPlaceholder]);
23668
25751
  return /* @__PURE__ */ jsx(
@@ -23676,11 +25759,11 @@ function useDataDnd(args) {
23676
25759
  }
23677
25760
  );
23678
25761
  };
23679
- const rootContextValue = React86__default.useMemo(
25762
+ const rootContextValue = React97__default.useMemo(
23680
25763
  () => ({ registerZone, unregisterZone, activeDrag, overZoneGroup, optimisticOrders, clearOptimisticOrder }),
23681
25764
  [registerZone, unregisterZone, activeDrag, overZoneGroup, optimisticOrders, clearOptimisticOrder]
23682
25765
  );
23683
- const handleDragStart = React86__default.useCallback((event) => {
25766
+ const handleDragStart = React97__default.useCallback((event) => {
23684
25767
  const sourceZone = findZoneByItem(event.active.id);
23685
25768
  const rect = event.active.rect.current.initial;
23686
25769
  const height = rect?.height && rect.height > 0 ? rect.height : 64;
@@ -23699,7 +25782,7 @@ function useDataDnd(args) {
23699
25782
  isRoot
23700
25783
  });
23701
25784
  }, [findZoneByItem, isRoot, zoneId]);
23702
- const handleDragOver = React86__default.useCallback((event) => {
25785
+ const handleDragOver = React97__default.useCallback((event) => {
23703
25786
  const { active, over } = event;
23704
25787
  const overData = over?.data?.current;
23705
25788
  const overGroup = overData?.dndGroup ?? null;
@@ -23769,7 +25852,7 @@ function useDataDnd(args) {
23769
25852
  return next;
23770
25853
  });
23771
25854
  }, []);
23772
- const handleDragCancel = React86__default.useCallback((event) => {
25855
+ const handleDragCancel = React97__default.useCallback((event) => {
23773
25856
  setActiveDrag(null);
23774
25857
  setOverZoneGroup(null);
23775
25858
  dndLog.warn("dragCancel", {
@@ -23777,12 +25860,12 @@ function useDataDnd(args) {
23777
25860
  reason: "dnd-kit cancelled the drag (escape key, pointer interrupted, or external)"
23778
25861
  });
23779
25862
  }, []);
23780
- const handleDragEndWithCleanup = React86__default.useCallback((event) => {
25863
+ const handleDragEndWithCleanup = React97__default.useCallback((event) => {
23781
25864
  handleDragEnd(event);
23782
25865
  setActiveDrag(null);
23783
25866
  setOverZoneGroup(null);
23784
25867
  }, [handleDragEnd]);
23785
- const wrapContainer = React86__default.useCallback(
25868
+ const wrapContainer = React97__default.useCallback(
23786
25869
  (children) => {
23787
25870
  if (!enabled) return children;
23788
25871
  const strategy = layout === "grid" ? rectSortingStrategy : verticalListSortingStrategy;
@@ -23836,7 +25919,7 @@ var init_useDataDnd = __esm({
23836
25919
  init_useAlmadarDndCollision();
23837
25920
  init_Box();
23838
25921
  dndLog = createLogger("almadar:ui:dnd");
23839
- RootCtx = React86__default.createContext(null);
25922
+ RootCtx = React97__default.createContext(null);
23840
25923
  }
23841
25924
  });
23842
25925
  function renderIconInput(icon, props) {
@@ -24362,7 +26445,7 @@ function DataList({
24362
26445
  }) {
24363
26446
  const eventBus = useEventBus();
24364
26447
  const { t } = useTranslate();
24365
- const [visibleCount, setVisibleCount] = React86__default.useState(pageSize || Infinity);
26448
+ const [visibleCount, setVisibleCount] = React97__default.useState(pageSize || Infinity);
24366
26449
  const fieldDefs = fields ?? columns ?? [];
24367
26450
  const allDataRaw = Array.isArray(entity) ? entity : entity ? [entity] : [];
24368
26451
  const dnd = useDataDnd({
@@ -24381,7 +26464,7 @@ function DataList({
24381
26464
  const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
24382
26465
  const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
24383
26466
  const hasRenderProp = typeof children === "function";
24384
- React86__default.useEffect(() => {
26467
+ React97__default.useEffect(() => {
24385
26468
  const renderItemTypeOf = typeof schemaRenderItem;
24386
26469
  const childrenTypeOf = typeof children;
24387
26470
  if (data.length > 0 && !hasRenderProp) {
@@ -24485,7 +26568,7 @@ function DataList({
24485
26568
  const items2 = [...data];
24486
26569
  const groups2 = groupBy ? groupData(items2, groupBy) : [{ label: "", items: items2 }];
24487
26570
  const contentField = titleField?.name ?? fieldDefs[0]?.name ?? "";
24488
- return /* @__PURE__ */ jsx(VStack, { gap: "sm", className: cn("py-2", className), children: groups2.map((group, gi) => /* @__PURE__ */ jsxs(React86__default.Fragment, { children: [
26571
+ return /* @__PURE__ */ jsx(VStack, { gap: "sm", className: cn("py-2", className), children: groups2.map((group, gi) => /* @__PURE__ */ jsxs(React97__default.Fragment, { children: [
24489
26572
  group.label && /* @__PURE__ */ jsx(Divider, { label: group.label, className: "my-2" }),
24490
26573
  group.items.map((itemData, index) => {
24491
26574
  const id = itemData.id || `${gi}-${index}`;
@@ -24626,7 +26709,7 @@ function DataList({
24626
26709
  className
24627
26710
  ),
24628
26711
  children: [
24629
- groups.map((group, gi) => /* @__PURE__ */ jsxs(React86__default.Fragment, { children: [
26712
+ groups.map((group, gi) => /* @__PURE__ */ jsxs(React97__default.Fragment, { children: [
24630
26713
  group.label && /* @__PURE__ */ jsx(Divider, { label: group.label, className: gi > 0 ? "mt-4" : "mt-0" }),
24631
26714
  group.items.map(
24632
26715
  (itemData, index) => renderItem(itemData, index, gi === groups.length - 1 && index === group.items.length - 1)
@@ -24711,7 +26794,7 @@ var init_FormSection = __esm({
24711
26794
  columns = 1,
24712
26795
  className
24713
26796
  }) => {
24714
- const [collapsed, setCollapsed] = React86__default.useState(defaultCollapsed);
26797
+ const [collapsed, setCollapsed] = React97__default.useState(defaultCollapsed);
24715
26798
  const { t } = useTranslate();
24716
26799
  const eventBus = useEventBus();
24717
26800
  const gridClass = {
@@ -24719,7 +26802,7 @@ var init_FormSection = __esm({
24719
26802
  2: "grid-cols-1 md:grid-cols-2",
24720
26803
  3: "grid-cols-1 md:grid-cols-2 lg:grid-cols-3"
24721
26804
  }[columns];
24722
- React86__default.useCallback(() => {
26805
+ React97__default.useCallback(() => {
24723
26806
  if (collapsible) {
24724
26807
  setCollapsed((prev) => !prev);
24725
26808
  eventBus.emit("UI:TOGGLE_COLLAPSE", { collapsed: !collapsed });
@@ -25669,7 +27752,7 @@ var init_Flex = __esm({
25669
27752
  flexStyle.flexBasis = typeof basis === "number" ? `${basis}px` : basis;
25670
27753
  }
25671
27754
  }
25672
- return React86__default.createElement(Component, {
27755
+ return React97__default.createElement(Component, {
25673
27756
  className: cn(
25674
27757
  inline ? "inline-flex" : "flex",
25675
27758
  directionStyles[direction],
@@ -25775,7 +27858,7 @@ var init_Grid = __esm({
25775
27858
  };
25776
27859
  Grid = ({
25777
27860
  cols = 1,
25778
- rows,
27861
+ rows: rows2,
25779
27862
  gap = "md",
25780
27863
  rowGap,
25781
27864
  colGap,
@@ -25787,8 +27870,8 @@ var init_Grid = __esm({
25787
27870
  children,
25788
27871
  as: Component = "div"
25789
27872
  }) => {
25790
- const mergedStyle = rows ? { gridTemplateRows: `repeat(${rows}, minmax(0, 1fr))`, ...style } : style;
25791
- return React86__default.createElement(
27873
+ const mergedStyle = rows2 ? { gridTemplateRows: `repeat(${rows2}, minmax(0, 1fr))`, ...style } : style;
27874
+ return React97__default.createElement(
25792
27875
  Component,
25793
27876
  {
25794
27877
  className: cn(
@@ -25984,9 +28067,9 @@ var init_Popover = __esm({
25984
28067
  onMouseLeave: handleClose,
25985
28068
  onPointerDown: tapTriggerProps.onPointerDown
25986
28069
  };
25987
- const childElement = React86__default.isValidElement(children) ? children : /* @__PURE__ */ jsx("span", { children });
28070
+ const childElement = React97__default.isValidElement(children) ? children : /* @__PURE__ */ jsx("span", { children });
25988
28071
  const childPointerDown = childElement.props.onPointerDown;
25989
- const triggerElement = React86__default.cloneElement(
28072
+ const triggerElement = React97__default.cloneElement(
25990
28073
  childElement,
25991
28074
  {
25992
28075
  ref: triggerRef,
@@ -26588,9 +28671,9 @@ var init_Tooltip = __esm({
26588
28671
  if (hideTimeoutRef.current) clearTimeout(hideTimeoutRef.current);
26589
28672
  };
26590
28673
  }, []);
26591
- const triggerElement = React86__default.isValidElement(children) ? children : /* @__PURE__ */ jsx("span", { children });
28674
+ const triggerElement = React97__default.isValidElement(children) ? children : /* @__PURE__ */ jsx("span", { children });
26592
28675
  const childPointerDown = triggerElement.props.onPointerDown;
26593
- const trigger = React86__default.cloneElement(triggerElement, {
28676
+ const trigger = React97__default.cloneElement(triggerElement, {
26594
28677
  ref: triggerRef,
26595
28678
  onMouseEnter: handleMouseEnter,
26596
28679
  onMouseLeave: handleMouseLeave,
@@ -26680,7 +28763,7 @@ var init_WizardProgress = __esm({
26680
28763
  children: /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: normalizedSteps.map((step, index) => {
26681
28764
  const isActive = index === currentStep;
26682
28765
  const isCompleted = index < currentStep;
26683
- return /* @__PURE__ */ jsxs(React86__default.Fragment, { children: [
28766
+ return /* @__PURE__ */ jsxs(React97__default.Fragment, { children: [
26684
28767
  /* @__PURE__ */ jsx(
26685
28768
  "button",
26686
28769
  {
@@ -28240,13 +30323,13 @@ var init_MapView = __esm({
28240
30323
  shadowSize: [41, 41]
28241
30324
  });
28242
30325
  L.Marker.prototype.options.icon = defaultIcon;
28243
- const { useEffect: useEffect64, useRef: useRef61, useCallback: useCallback97, useState: useState89 } = React86__default;
30326
+ const { useEffect: useEffect68, useRef: useRef65, useCallback: useCallback104, useState: useState98 } = React97__default;
28244
30327
  const { Typography: Typography2 } = await Promise.resolve().then(() => (init_Typography(), Typography_exports));
28245
30328
  const { useEventBus: useEventBus2 } = await Promise.resolve().then(() => (init_useEventBus(), useEventBus_exports));
28246
30329
  function MapUpdater({ centerLat, centerLng, zoom }) {
28247
30330
  const map = useMap();
28248
- const prevRef = useRef61({ centerLat, centerLng, zoom });
28249
- useEffect64(() => {
30331
+ const prevRef = useRef65({ centerLat, centerLng, zoom });
30332
+ useEffect68(() => {
28250
30333
  const prev = prevRef.current;
28251
30334
  if (prev.centerLat !== centerLat || prev.centerLng !== centerLng || prev.zoom !== zoom) {
28252
30335
  map.setView([centerLat, centerLng], zoom);
@@ -28257,7 +30340,7 @@ var init_MapView = __esm({
28257
30340
  }
28258
30341
  function MapClickHandler({ onMapClick }) {
28259
30342
  const map = useMap();
28260
- useEffect64(() => {
30343
+ useEffect68(() => {
28261
30344
  if (!onMapClick) return;
28262
30345
  const handler = (e) => {
28263
30346
  onMapClick(e.latlng.lat, e.latlng.lng);
@@ -28285,8 +30368,8 @@ var init_MapView = __esm({
28285
30368
  showAttribution = true
28286
30369
  }) {
28287
30370
  const eventBus = useEventBus2();
28288
- const [clickedPosition, setClickedPosition] = useState89(null);
28289
- const handleMapClick = useCallback97((lat, lng) => {
30371
+ const [clickedPosition, setClickedPosition] = useState98(null);
30372
+ const handleMapClick = useCallback104((lat, lng) => {
28290
30373
  if (showClickedPin) {
28291
30374
  setClickedPosition({ lat, lng });
28292
30375
  }
@@ -28295,7 +30378,7 @@ var init_MapView = __esm({
28295
30378
  eventBus.emit(`UI:${mapClickEvent}`, { latitude: lat, longitude: lng });
28296
30379
  }
28297
30380
  }, [onMapClick, mapClickEvent, eventBus, showClickedPin]);
28298
- const handleMarkerClick = useCallback97((marker) => {
30381
+ const handleMarkerClick = useCallback104((marker) => {
28299
30382
  onMarkerClick?.(marker);
28300
30383
  if (markerClickEvent) {
28301
30384
  eventBus.emit(`UI:${markerClickEvent}`, { ...marker });
@@ -29155,8 +31238,8 @@ function TableView({
29155
31238
  }) {
29156
31239
  const eventBus = useEventBus();
29157
31240
  const { t } = useTranslate();
29158
- const [visibleCount, setVisibleCount] = React86__default.useState(pageSize > 0 ? pageSize : Infinity);
29159
- const [localSelected, setLocalSelected] = React86__default.useState(/* @__PURE__ */ new Set());
31241
+ const [visibleCount, setVisibleCount] = React97__default.useState(pageSize > 0 ? pageSize : Infinity);
31242
+ const [localSelected, setLocalSelected] = React97__default.useState(/* @__PURE__ */ new Set());
29160
31243
  const colDefs = columns ?? fields ?? [];
29161
31244
  const allDataRaw = Array.isArray(entity) ? entity : entity ? [entity] : [];
29162
31245
  const dnd = useDataDnd({
@@ -29351,12 +31434,12 @@ function TableView({
29351
31434
  ]
29352
31435
  }
29353
31436
  );
29354
- return dnd.isZone ? /* @__PURE__ */ jsx(dnd.SortableItem, { id: row[idField] ?? id, children: rowInner }, id) : /* @__PURE__ */ jsx(React86__default.Fragment, { children: rowInner }, id);
31437
+ return dnd.isZone ? /* @__PURE__ */ jsx(dnd.SortableItem, { id: row[idField] ?? id, children: rowInner }, id) : /* @__PURE__ */ jsx(React97__default.Fragment, { children: rowInner }, id);
29355
31438
  };
29356
31439
  const items = Array.from(data);
29357
31440
  const groups = groupBy ? groupData2(items, groupBy) : [{ label: "", items }];
29358
31441
  let runningIndex = 0;
29359
- const body = /* @__PURE__ */ jsx(Box, { role: "rowgroup", children: groups.map((group, gi) => /* @__PURE__ */ jsxs(React86__default.Fragment, { children: [
31442
+ const body = /* @__PURE__ */ jsx(Box, { role: "rowgroup", children: groups.map((group, gi) => /* @__PURE__ */ jsxs(React97__default.Fragment, { children: [
29360
31443
  group.label && /* @__PURE__ */ jsx(Divider, { label: group.label, className: gi > 0 ? "mt-3" : "mt-0" }),
29361
31444
  group.items.map((row) => renderRow(row, runningIndex++))
29362
31445
  ] }, gi)) });
@@ -30713,7 +32796,7 @@ var init_StepFlow = __esm({
30713
32796
  className
30714
32797
  }) => {
30715
32798
  if (orientation === "vertical") {
30716
- return /* @__PURE__ */ jsx(VStack, { gap: "none", className: cn("w-full", className), children: steps.map((step, index) => /* @__PURE__ */ jsx(React86__default.Fragment, { children: /* @__PURE__ */ jsxs(HStack, { gap: "md", align: "start", className: "w-full", children: [
32799
+ return /* @__PURE__ */ jsx(VStack, { gap: "none", className: cn("w-full", className), children: steps.map((step, index) => /* @__PURE__ */ jsx(React97__default.Fragment, { children: /* @__PURE__ */ jsxs(HStack, { gap: "md", align: "start", className: "w-full", children: [
30717
32800
  /* @__PURE__ */ jsxs(VStack, { gap: "none", align: "center", children: [
30718
32801
  /* @__PURE__ */ jsx(StepCircle, { step, index }),
30719
32802
  showConnectors && index < steps.length - 1 && /* @__PURE__ */ jsx(Box, { className: "w-px h-8 bg-border" })
@@ -30724,7 +32807,7 @@ var init_StepFlow = __esm({
30724
32807
  ] })
30725
32808
  ] }) }, index)) });
30726
32809
  }
30727
- 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(React86__default.Fragment, { children: [
32810
+ 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(React97__default.Fragment, { children: [
30728
32811
  /* @__PURE__ */ jsxs(VStack, { gap: "sm", align: "center", className: "flex-1 w-full md:w-auto", children: [
30729
32812
  /* @__PURE__ */ jsx(StepCircle, { step, index }),
30730
32813
  /* @__PURE__ */ jsx(Typography, { variant: "h4", className: "text-center", children: step.title }),
@@ -31450,11 +33533,11 @@ function LatticeSVG({
31450
33533
  }) {
31451
33534
  const paths = [];
31452
33535
  const cols = 5;
31453
- const rows = Math.ceil(h / (w / cols));
33536
+ const rows2 = Math.ceil(h / (w / cols));
31454
33537
  const cellW = w / cols;
31455
33538
  const cellH = cellW;
31456
33539
  const bulge = cellW * 0.3;
31457
- for (let row = 0; row < rows; row++) {
33540
+ for (let row = 0; row < rows2; row++) {
31458
33541
  for (let col = 0; col < cols; col++) {
31459
33542
  const cx = col * cellW + cellW / 2;
31460
33543
  const cy = row * cellH + cellH / 2;
@@ -31709,7 +33792,7 @@ var init_LikertScale = __esm({
31709
33792
  md: "text-base",
31710
33793
  lg: "text-lg"
31711
33794
  };
31712
- LikertScale = React86__default.forwardRef(
33795
+ LikertScale = React97__default.forwardRef(
31713
33796
  ({
31714
33797
  question,
31715
33798
  options = DEFAULT_LIKERT_OPTIONS,
@@ -31721,7 +33804,7 @@ var init_LikertScale = __esm({
31721
33804
  variant = "radios",
31722
33805
  className
31723
33806
  }, ref) => {
31724
- const groupId = React86__default.useId();
33807
+ const groupId = React97__default.useId();
31725
33808
  const eventBus = useEventBus();
31726
33809
  const handleSelect = useCallback(
31727
33810
  (next) => {
@@ -31875,7 +33958,7 @@ var init_MatrixQuestion = __esm({
31875
33958
  };
31876
33959
  MatrixQuestion = ({
31877
33960
  title,
31878
- rows,
33961
+ rows: rows2,
31879
33962
  columns = DEFAULT_MATRIX_COLUMNS,
31880
33963
  values,
31881
33964
  onChange,
@@ -31885,7 +33968,7 @@ var init_MatrixQuestion = __esm({
31885
33968
  className
31886
33969
  }) => {
31887
33970
  const styles = sizeStyles12[size];
31888
- const safeRows = rows ?? [];
33971
+ const safeRows = rows2 ?? [];
31889
33972
  const safeValues = values ?? {};
31890
33973
  const eventBus = useEventBus();
31891
33974
  const handleChange = useCallback(
@@ -34003,7 +36086,7 @@ var init_DocBreadcrumb = __esm({
34003
36086
  "aria-label": t("aria.breadcrumb"),
34004
36087
  children: /* @__PURE__ */ jsx(HStack, { gap: "xs", align: "center", wrap: true, children: items.map((item, idx) => {
34005
36088
  const isLast = idx === items.length - 1;
34006
- return /* @__PURE__ */ jsxs(React86__default.Fragment, { children: [
36089
+ return /* @__PURE__ */ jsxs(React97__default.Fragment, { children: [
34007
36090
  idx > 0 && /* @__PURE__ */ jsx(
34008
36091
  Icon,
34009
36092
  {
@@ -34872,7 +36955,7 @@ var init_MiniStateMachine = __esm({
34872
36955
  const x = 2 + i * (NODE_W + GAP + ARROW_W + GAP);
34873
36956
  const tc = transitionCounts[s.name] ?? 0;
34874
36957
  const role = getStateRole(s.name, s.isInitial ?? void 0, s.isTerminal ?? void 0, tc, maxTC);
34875
- return /* @__PURE__ */ jsxs(React86__default.Fragment, { children: [
36958
+ return /* @__PURE__ */ jsxs(React97__default.Fragment, { children: [
34876
36959
  /* @__PURE__ */ jsx(
34877
36960
  AvlState,
34878
36961
  {
@@ -35076,7 +37159,7 @@ var init_PageHeader = __esm({
35076
37159
  info: "bg-info/10 text-info"
35077
37160
  };
35078
37161
  return /* @__PURE__ */ jsxs(Box, { className: cn("mb-6", className), children: [
35079
- 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(React86__default.Fragment, { children: [
37162
+ 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(React97__default.Fragment, { children: [
35080
37163
  idx > 0 && /* @__PURE__ */ jsx(Typography, { variant: "small", color: "muted", children: "/" }),
35081
37164
  crumb.href ? /* @__PURE__ */ jsx(
35082
37165
  "a",
@@ -35434,7 +37517,7 @@ var init_Section = __esm({
35434
37517
  as: Component = "section"
35435
37518
  }) => {
35436
37519
  const hasHeader = title || description || action;
35437
- return React86__default.createElement(
37520
+ return React97__default.createElement(
35438
37521
  Component,
35439
37522
  {
35440
37523
  className: cn(
@@ -35758,8 +37841,8 @@ var init_WizardContainer = __esm({
35758
37841
  return void 0;
35759
37842
  if (typeof controlledStep === "number") return controlledStep;
35760
37843
  if (typeof controlledStep === "string") return parseInt(controlledStep, 10);
35761
- const num = Number(controlledStep);
35762
- return isNaN(num) ? void 0 : num;
37844
+ const num2 = Number(controlledStep);
37845
+ return isNaN(num2) ? void 0 : num2;
35763
37846
  })();
35764
37847
  const currentStep = normalizedControlledStep !== void 0 ? normalizedControlledStep : internalStep;
35765
37848
  const totalSteps = steps.length;
@@ -35808,7 +37891,7 @@ var init_WizardContainer = __esm({
35808
37891
  const isCompleted = index < currentStep;
35809
37892
  const stepKey = step.id ?? step.tabId ?? `step-${index}`;
35810
37893
  const stepTitle = step.title ?? step.name ?? `Step ${index + 1}`;
35811
- return /* @__PURE__ */ jsxs(React86__default.Fragment, { children: [
37894
+ return /* @__PURE__ */ jsxs(React97__default.Fragment, { children: [
35812
37895
  /* @__PURE__ */ jsx(
35813
37896
  Button,
35814
37897
  {
@@ -37785,7 +39868,7 @@ function getBadgeVariant(fieldName, value) {
37785
39868
  return "default";
37786
39869
  }
37787
39870
  function formatFieldLabel(fieldName) {
37788
- return fieldName.replace(/([A-Z])/g, " $1").replace(/^./, (str) => str.toUpperCase());
39871
+ return fieldName.replace(/([A-Z])/g, " $1").replace(/^./, (str2) => str2.toUpperCase());
37789
39872
  }
37790
39873
  function formatFieldValue(value, fieldName) {
37791
39874
  if (typeof value === "number") {
@@ -37804,26 +39887,26 @@ function formatFieldValue(value, fieldName) {
37804
39887
  }
37805
39888
  function renderRichFieldValue(value, fieldName, fieldType) {
37806
39889
  if (value === void 0 || value === null) return "\u2014";
37807
- const str = String(value);
39890
+ const str2 = String(value);
37808
39891
  switch (fieldType) {
37809
39892
  case "image":
37810
39893
  case "url": {
37811
- if (str.match(/\.(png|jpe?g|gif|svg|webp|avif)(\?|$)/i) || str.startsWith("data:image/")) {
39894
+ if (str2.match(/\.(png|jpe?g|gif|svg|webp|avif)(\?|$)/i) || str2.startsWith("data:image/")) {
37812
39895
  return /* @__PURE__ */ jsx(Box, { className: "mt-1 max-w-full", children: /* @__PURE__ */ jsx(
37813
39896
  "img",
37814
39897
  {
37815
- src: str,
39898
+ src: str2,
37816
39899
  alt: formatFieldLabel(fieldName),
37817
39900
  className: "max-w-full max-h-64 rounded-md object-contain",
37818
39901
  loading: "lazy"
37819
39902
  }
37820
39903
  ) });
37821
39904
  }
37822
- return str;
39905
+ return str2;
37823
39906
  }
37824
39907
  case "markdown":
37825
39908
  case "richtext":
37826
- return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Typography, { variant: "body", className: "break-words", children: str }), children: /* @__PURE__ */ jsx(
39909
+ return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Typography, { variant: "body", className: "break-words", children: str2 }), children: /* @__PURE__ */ jsx(
37827
39910
  Box,
37828
39911
  {
37829
39912
  className: "prose prose-sm max-w-none",
@@ -37841,11 +39924,11 @@ function renderRichFieldValue(value, fieldName, fieldType) {
37841
39924
  "--tw-prose-th-borders": "var(--color-border)",
37842
39925
  "--tw-prose-td-borders": "var(--color-border)"
37843
39926
  },
37844
- children: /* @__PURE__ */ jsx(ReactMarkdown2, { children: str })
39927
+ children: /* @__PURE__ */ jsx(ReactMarkdown2, { children: str2 })
37845
39928
  }
37846
39929
  ) });
37847
39930
  case "code":
37848
- 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 }) }) });
39931
+ 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 }) }) });
37849
39932
  case "html":
37850
39933
  return /* @__PURE__ */ jsx(
37851
39934
  Box,
@@ -37865,12 +39948,12 @@ function renderRichFieldValue(value, fieldName, fieldType) {
37865
39948
  "--tw-prose-th-borders": "var(--color-border)",
37866
39949
  "--tw-prose-td-borders": "var(--color-border)"
37867
39950
  },
37868
- children: /* @__PURE__ */ jsx(Typography, { variant: "body", children: str })
39951
+ children: /* @__PURE__ */ jsx(Typography, { variant: "body", children: str2 })
37869
39952
  }
37870
39953
  );
37871
39954
  case "date":
37872
39955
  case "datetime": {
37873
- const d = new Date(str);
39956
+ const d = new Date(str2);
37874
39957
  if (!isNaN(d.getTime())) {
37875
39958
  return d.toLocaleDateString(void 0, {
37876
39959
  year: "numeric",
@@ -37879,7 +39962,7 @@ function renderRichFieldValue(value, fieldName, fieldType) {
37879
39962
  ...fieldType === "datetime" ? { hour: "2-digit", minute: "2-digit" } : {}
37880
39963
  });
37881
39964
  }
37882
- return str;
39965
+ return str2;
37883
39966
  }
37884
39967
  default:
37885
39968
  return formatFieldValue(value, fieldName);
@@ -38241,7 +40324,7 @@ var init_DetailPanel = __esm({
38241
40324
  }
38242
40325
  });
38243
40326
  function extractTitle(children) {
38244
- if (!React86__default.isValidElement(children)) return void 0;
40327
+ if (!React97__default.isValidElement(children)) return void 0;
38245
40328
  const props = children.props;
38246
40329
  if (typeof props.title === "string") {
38247
40330
  return props.title;
@@ -38591,12 +40674,12 @@ var init_Form = __esm({
38591
40674
  const isSchemaEntity = isOrbitalEntitySchema(entity);
38592
40675
  const resolvedEntity = isSchemaEntity ? entity : void 0;
38593
40676
  const entityName = typeof entity === "string" ? entity : resolvedEntity?.name;
38594
- const normalizedInitialData = React86__default.useMemo(() => {
40677
+ const normalizedInitialData = React97__default.useMemo(() => {
38595
40678
  const entityRowAsInitial = isPlainEntityRow(entity) ? entity : void 0;
38596
40679
  const callerInitial = initialData !== null && typeof initialData === "object" && !Array.isArray(initialData) ? initialData : {};
38597
40680
  return entityRowAsInitial !== void 0 ? { ...entityRowAsInitial, ...callerInitial } : callerInitial;
38598
40681
  }, [entity, initialData]);
38599
- const entityDerivedFields = React86__default.useMemo(() => {
40682
+ const entityDerivedFields = React97__default.useMemo(() => {
38600
40683
  if (fields && fields.length > 0) return void 0;
38601
40684
  if (!resolvedEntity) return void 0;
38602
40685
  return resolvedEntity.fields.map(
@@ -38617,16 +40700,16 @@ var init_Form = __esm({
38617
40700
  const conditionalFields = typeof conditionalFieldsRaw === "boolean" ? {} : conditionalFieldsRaw;
38618
40701
  const hiddenCalculations = typeof hiddenCalculationsRaw === "boolean" ? [] : hiddenCalculationsRaw;
38619
40702
  const violationTriggers = typeof violationTriggersRaw === "boolean" ? [] : violationTriggersRaw;
38620
- const [formData, setFormData] = React86__default.useState(
40703
+ const [formData, setFormData] = React97__default.useState(
38621
40704
  normalizedInitialData
38622
40705
  );
38623
- const [collapsedSections, setCollapsedSections] = React86__default.useState(
40706
+ const [collapsedSections, setCollapsedSections] = React97__default.useState(
38624
40707
  /* @__PURE__ */ new Set()
38625
40708
  );
38626
- const [submitError, setSubmitError] = React86__default.useState(null);
38627
- const formRef = React86__default.useRef(null);
40709
+ const [submitError, setSubmitError] = React97__default.useState(null);
40710
+ const formRef = React97__default.useRef(null);
38628
40711
  const formMode = props.mode;
38629
- const mountedRef = React86__default.useRef(false);
40712
+ const mountedRef = React97__default.useRef(false);
38630
40713
  if (!mountedRef.current) {
38631
40714
  mountedRef.current = true;
38632
40715
  debug("forms", "mount", {
@@ -38639,7 +40722,7 @@ var init_Form = __esm({
38639
40722
  });
38640
40723
  }
38641
40724
  const shouldShowCancel = showCancel ?? (fields && fields.length > 0);
38642
- const evalContext = React86__default.useMemo(
40725
+ const evalContext = React97__default.useMemo(
38643
40726
  () => ({
38644
40727
  formValues: formData,
38645
40728
  globalVariables: externalContext?.globalVariables ?? {},
@@ -38648,7 +40731,7 @@ var init_Form = __esm({
38648
40731
  }),
38649
40732
  [formData, externalContext]
38650
40733
  );
38651
- React86__default.useEffect(() => {
40734
+ React97__default.useEffect(() => {
38652
40735
  debug("forms", "initialData-sync", {
38653
40736
  mode: formMode,
38654
40737
  normalizedInitialData,
@@ -38659,7 +40742,7 @@ var init_Form = __esm({
38659
40742
  setFormData(normalizedInitialData);
38660
40743
  }
38661
40744
  }, [normalizedInitialData]);
38662
- const processCalculations = React86__default.useCallback(
40745
+ const processCalculations = React97__default.useCallback(
38663
40746
  (changedFieldId, newFormData) => {
38664
40747
  if (!hiddenCalculations.length) return;
38665
40748
  const context = {
@@ -38684,7 +40767,7 @@ var init_Form = __esm({
38684
40767
  },
38685
40768
  [hiddenCalculations, externalContext, eventBus]
38686
40769
  );
38687
- const checkViolations = React86__default.useCallback(
40770
+ const checkViolations = React97__default.useCallback(
38688
40771
  (changedFieldId, newFormData) => {
38689
40772
  if (!violationTriggers.length) return;
38690
40773
  const context = {
@@ -38722,7 +40805,7 @@ var init_Form = __esm({
38722
40805
  processCalculations(name, newFormData);
38723
40806
  checkViolations(name, newFormData);
38724
40807
  };
38725
- const isFieldVisible = React86__default.useCallback(
40808
+ const isFieldVisible = React97__default.useCallback(
38726
40809
  (fieldName) => {
38727
40810
  const condition = conditionalFields[fieldName];
38728
40811
  if (!condition) return true;
@@ -38730,7 +40813,7 @@ var init_Form = __esm({
38730
40813
  },
38731
40814
  [conditionalFields, evalContext]
38732
40815
  );
38733
- const isSectionVisible = React86__default.useCallback(
40816
+ const isSectionVisible = React97__default.useCallback(
38734
40817
  (section) => {
38735
40818
  if (!section.condition) return true;
38736
40819
  return Boolean(evaluateFormExpression(section.condition, evalContext));
@@ -38806,7 +40889,7 @@ var init_Form = __esm({
38806
40889
  eventBus.emit(`UI:${onCancel}`);
38807
40890
  }
38808
40891
  };
38809
- const renderField = React86__default.useCallback(
40892
+ const renderField = React97__default.useCallback(
38810
40893
  (field) => {
38811
40894
  const fieldName = field.name || field.field;
38812
40895
  if (!fieldName) return null;
@@ -38827,7 +40910,7 @@ var init_Form = __esm({
38827
40910
  [formData, isFieldVisible, relationsData, relationsLoading, isLoading]
38828
40911
  );
38829
40912
  const effectiveFields = entityDerivedFields ?? fields;
38830
- const normalizedFields = React86__default.useMemo(() => {
40913
+ const normalizedFields = React97__default.useMemo(() => {
38831
40914
  if (!effectiveFields || effectiveFields.length === 0) return [];
38832
40915
  return effectiveFields.map((field) => {
38833
40916
  if (typeof field === "string") {
@@ -38851,7 +40934,7 @@ var init_Form = __esm({
38851
40934
  return field;
38852
40935
  });
38853
40936
  }, [effectiveFields, resolvedEntity]);
38854
- const schemaFields = React86__default.useMemo(() => {
40937
+ const schemaFields = React97__default.useMemo(() => {
38855
40938
  if (normalizedFields.length === 0) return null;
38856
40939
  if (isDebugEnabled()) {
38857
40940
  debugGroup(`Form: ${entityName || "unknown"}`);
@@ -38861,7 +40944,7 @@ var init_Form = __esm({
38861
40944
  }
38862
40945
  return normalizedFields.map(renderField).filter(Boolean);
38863
40946
  }, [normalizedFields, renderField, entityName, conditionalFields]);
38864
- const sectionElements = React86__default.useMemo(() => {
40947
+ const sectionElements = React97__default.useMemo(() => {
38865
40948
  if (!sections || sections.length === 0) return null;
38866
40949
  return sections.map((section) => {
38867
40950
  if (!isSectionVisible(section)) {
@@ -39440,7 +41523,7 @@ function formatValue3(value, fieldName) {
39440
41523
  return String(value);
39441
41524
  }
39442
41525
  function formatFieldLabel2(fieldName) {
39443
- return fieldName.replace(/([A-Z])/g, " $1").replace(/^./, (str) => str.toUpperCase()).replace(/Id$/, "").trim();
41526
+ return fieldName.replace(/([A-Z])/g, " $1").replace(/^./, (str2) => str2.toUpperCase()).replace(/Id$/, "").trim();
39444
41527
  }
39445
41528
  var STATUS_STYLES2, StatusBadge, ProgressIndicator, List3;
39446
41529
  var init_List = __esm({
@@ -39586,7 +41669,7 @@ var init_List = __esm({
39586
41669
  if (entity && typeof entity === "object" && "id" in entity) return [entity];
39587
41670
  return [];
39588
41671
  }, [entity]);
39589
- const getItemActions = React86__default.useCallback(
41672
+ const getItemActions = React97__default.useCallback(
39590
41673
  (item) => {
39591
41674
  if (!itemActions) return [];
39592
41675
  if (typeof itemActions === "function") {
@@ -40061,7 +42144,7 @@ var init_MediaGallery = __esm({
40061
42144
  [selectable, selectedItems, selectionEvent, eventBus]
40062
42145
  );
40063
42146
  const entityData = Array.isArray(entity) ? entity : [];
40064
- const items = React86__default.useMemo(() => {
42147
+ const items = React97__default.useMemo(() => {
40065
42148
  if (propItems) return propItems;
40066
42149
  if (entityData.length === 0) return [];
40067
42150
  return entityData.map((record, idx) => {
@@ -40224,7 +42307,7 @@ var init_MediaGallery = __esm({
40224
42307
  }
40225
42308
  });
40226
42309
  function extractTitle2(children) {
40227
- if (!React86__default.isValidElement(children)) return void 0;
42310
+ if (!React97__default.isValidElement(children)) return void 0;
40228
42311
  const props = children.props;
40229
42312
  if (typeof props.title === "string") {
40230
42313
  return props.title;
@@ -40479,7 +42562,7 @@ var init_debugRegistry = __esm({
40479
42562
  }
40480
42563
  });
40481
42564
  function useDebugData() {
40482
- const [data, setData] = React86.useState(() => ({
42565
+ const [data, setData] = React97.useState(() => ({
40483
42566
  traits: [],
40484
42567
  ticks: [],
40485
42568
  guards: [],
@@ -40493,7 +42576,7 @@ function useDebugData() {
40493
42576
  },
40494
42577
  lastUpdate: Date.now()
40495
42578
  }));
40496
- React86.useEffect(() => {
42579
+ React97.useEffect(() => {
40497
42580
  const updateData = () => {
40498
42581
  setData({
40499
42582
  traits: getAllTraits(),
@@ -40602,12 +42685,12 @@ function layoutGraph(states, transitions, initialState, width, height) {
40602
42685
  return positions;
40603
42686
  }
40604
42687
  function WalkMinimap() {
40605
- const [walkStep, setWalkStep] = React86.useState(null);
40606
- const [traits2, setTraits] = React86.useState([]);
40607
- const [coveredEdges, setCoveredEdges] = React86.useState([]);
40608
- const [completedTraits, setCompletedTraits] = React86.useState(/* @__PURE__ */ new Set());
40609
- const prevTraitRef = React86.useRef(null);
40610
- React86.useEffect(() => {
42688
+ const [walkStep, setWalkStep] = React97.useState(null);
42689
+ const [traits2, setTraits] = React97.useState([]);
42690
+ const [coveredEdges, setCoveredEdges] = React97.useState([]);
42691
+ const [completedTraits, setCompletedTraits] = React97.useState(/* @__PURE__ */ new Set());
42692
+ const prevTraitRef = React97.useRef(null);
42693
+ React97.useEffect(() => {
40611
42694
  const interval = setInterval(() => {
40612
42695
  const w = window;
40613
42696
  const step = w.__orbitalWalkStep;
@@ -41043,15 +43126,15 @@ var init_EntitiesTab = __esm({
41043
43126
  });
41044
43127
  function EventFlowTab({ events: events2 }) {
41045
43128
  const { t } = useTranslate();
41046
- const [filter, setFilter] = React86.useState("all");
41047
- const containerRef = React86.useRef(null);
41048
- const [autoScroll, setAutoScroll] = React86.useState(true);
41049
- React86.useEffect(() => {
43129
+ const [filter, setFilter] = React97.useState("all");
43130
+ const containerRef = React97.useRef(null);
43131
+ const [autoScroll, setAutoScroll] = React97.useState(true);
43132
+ React97.useEffect(() => {
41050
43133
  if (autoScroll && containerRef.current) {
41051
43134
  containerRef.current.scrollTop = containerRef.current.scrollHeight;
41052
43135
  }
41053
43136
  }, [events2.length, autoScroll]);
41054
- const filteredEvents = React86.useMemo(() => {
43137
+ const filteredEvents = React97.useMemo(() => {
41055
43138
  if (filter === "all") return events2;
41056
43139
  return events2.filter((e) => e.type === filter);
41057
43140
  }, [events2, filter]);
@@ -41167,7 +43250,7 @@ var init_EventFlowTab = __esm({
41167
43250
  });
41168
43251
  function GuardsPanel({ guards }) {
41169
43252
  const { t } = useTranslate();
41170
- const [filter, setFilter] = React86.useState("all");
43253
+ const [filter, setFilter] = React97.useState("all");
41171
43254
  if (guards.length === 0) {
41172
43255
  return /* @__PURE__ */ jsx(
41173
43256
  EmptyState,
@@ -41180,7 +43263,7 @@ function GuardsPanel({ guards }) {
41180
43263
  }
41181
43264
  const passedCount = guards.filter((g) => g.result).length;
41182
43265
  const failedCount = guards.length - passedCount;
41183
- const filteredGuards = React86.useMemo(() => {
43266
+ const filteredGuards = React97.useMemo(() => {
41184
43267
  if (filter === "all") return guards;
41185
43268
  if (filter === "passed") return guards.filter((g) => g.result);
41186
43269
  return guards.filter((g) => !g.result);
@@ -41343,10 +43426,10 @@ function EffectBadge({ effect }) {
41343
43426
  }
41344
43427
  function TransitionTimeline({ transitions }) {
41345
43428
  const { t } = useTranslate();
41346
- const containerRef = React86.useRef(null);
41347
- const [autoScroll, setAutoScroll] = React86.useState(true);
41348
- const [expandedId, setExpandedId] = React86.useState(null);
41349
- React86.useEffect(() => {
43429
+ const containerRef = React97.useRef(null);
43430
+ const [autoScroll, setAutoScroll] = React97.useState(true);
43431
+ const [expandedId, setExpandedId] = React97.useState(null);
43432
+ React97.useEffect(() => {
41350
43433
  if (autoScroll && containerRef.current) {
41351
43434
  containerRef.current.scrollTop = containerRef.current.scrollHeight;
41352
43435
  }
@@ -41626,9 +43709,9 @@ function getAllEvents(traits2) {
41626
43709
  function EventDispatcherTab({ traits: traits2, schema }) {
41627
43710
  const eventBus = useEventBus();
41628
43711
  const { t } = useTranslate();
41629
- const [log13, setLog] = React86.useState([]);
41630
- const prevStatesRef = React86.useRef(/* @__PURE__ */ new Map());
41631
- React86.useEffect(() => {
43712
+ const [log13, setLog] = React97.useState([]);
43713
+ const prevStatesRef = React97.useRef(/* @__PURE__ */ new Map());
43714
+ React97.useEffect(() => {
41632
43715
  for (const trait of traits2) {
41633
43716
  const prev = prevStatesRef.current.get(trait.id);
41634
43717
  if (prev && prev !== trait.currentState) {
@@ -41797,10 +43880,10 @@ function VerifyModePanel({
41797
43880
  localCount
41798
43881
  }) {
41799
43882
  const { t } = useTranslate();
41800
- const [expanded, setExpanded] = React86.useState(true);
41801
- const scrollRef = React86.useRef(null);
41802
- const prevCountRef = React86.useRef(0);
41803
- React86.useEffect(() => {
43883
+ const [expanded, setExpanded] = React97.useState(true);
43884
+ const scrollRef = React97.useRef(null);
43885
+ const prevCountRef = React97.useRef(0);
43886
+ React97.useEffect(() => {
41804
43887
  if (expanded && transitions.length > prevCountRef.current && scrollRef.current) {
41805
43888
  scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
41806
43889
  }
@@ -41857,10 +43940,10 @@ function RuntimeDebugger({
41857
43940
  schema
41858
43941
  }) {
41859
43942
  const { t } = useTranslate();
41860
- const [isCollapsed, setIsCollapsed] = React86.useState(mode === "verify" ? true : defaultCollapsed);
41861
- const [isVisible, setIsVisible] = React86.useState(mode === "inline" || mode === "verify" || isDebugEnabled2());
43943
+ const [isCollapsed, setIsCollapsed] = React97.useState(mode === "verify" ? true : defaultCollapsed);
43944
+ const [isVisible, setIsVisible] = React97.useState(mode === "inline" || mode === "verify" || isDebugEnabled2());
41862
43945
  const debugData = useDebugData();
41863
- React86.useEffect(() => {
43946
+ React97.useEffect(() => {
41864
43947
  if (mode === "inline") return;
41865
43948
  return onDebugToggle((enabled) => {
41866
43949
  setIsVisible(enabled);
@@ -41869,7 +43952,7 @@ function RuntimeDebugger({
41869
43952
  }
41870
43953
  });
41871
43954
  }, [mode]);
41872
- React86.useEffect(() => {
43955
+ React97.useEffect(() => {
41873
43956
  if (mode === "inline") return;
41874
43957
  const handleKeyDown = (e) => {
41875
43958
  if (e.key === "`" && isVisible) {
@@ -42389,7 +44472,7 @@ var init_StatCard = __esm({
42389
44472
  const labelToUse = propLabel ?? propTitle;
42390
44473
  const eventBus = useEventBus();
42391
44474
  const { t } = useTranslate();
42392
- const handleActionClick = React86__default.useCallback(() => {
44475
+ const handleActionClick = React97__default.useCallback(() => {
42393
44476
  if (action?.event) {
42394
44477
  eventBus.emit(`UI:${action.event}`, {});
42395
44478
  }
@@ -42400,7 +44483,7 @@ var init_StatCard = __esm({
42400
44483
  const data = Array.isArray(entity) ? entity : entity ? [entity] : [];
42401
44484
  const isLoading = externalLoading ?? false;
42402
44485
  const error = externalError;
42403
- const computeMetricValue = React86__default.useCallback(
44486
+ const computeMetricValue = React97__default.useCallback(
42404
44487
  (metric, items) => {
42405
44488
  if (metric.value !== void 0) {
42406
44489
  return metric.value;
@@ -42439,7 +44522,7 @@ var init_StatCard = __esm({
42439
44522
  },
42440
44523
  []
42441
44524
  );
42442
- const schemaStats = React86__default.useMemo(() => {
44525
+ const schemaStats = React97__default.useMemo(() => {
42443
44526
  if (!metrics || metrics.length === 0) return null;
42444
44527
  return metrics.map((metric) => ({
42445
44528
  label: metric.label,
@@ -42447,7 +44530,7 @@ var init_StatCard = __esm({
42447
44530
  format: metric.format
42448
44531
  }));
42449
44532
  }, [metrics, data, computeMetricValue]);
42450
- const calculatedTrend = React86__default.useMemo(() => {
44533
+ const calculatedTrend = React97__default.useMemo(() => {
42451
44534
  if (manualTrend !== void 0) return manualTrend;
42452
44535
  if (previousValue === void 0 || currentValue === void 0)
42453
44536
  return void 0;
@@ -43087,8 +45170,8 @@ var init_SubagentTracePanel = __esm({
43087
45170
  ] });
43088
45171
  };
43089
45172
  InlineActivityStream = ({ activities, autoScroll = true, className }) => {
43090
- const endRef = React86__default.useRef(null);
43091
- React86__default.useEffect(() => {
45173
+ const endRef = React97__default.useRef(null);
45174
+ React97__default.useEffect(() => {
43092
45175
  if (!autoScroll) return;
43093
45176
  endRef.current?.scrollIntoView({ behavior: "smooth", block: "end" });
43094
45177
  }, [activities.length, autoScroll]);
@@ -43182,7 +45265,7 @@ var init_SubagentTracePanel = __esm({
43182
45265
  };
43183
45266
  SubagentRichCard = ({ subagent }) => {
43184
45267
  const { t } = useTranslate();
43185
- const activities = React86__default.useMemo(
45268
+ const activities = React97__default.useMemo(
43186
45269
  () => subagentMessagesToActivities(subagent.messages),
43187
45270
  [subagent.messages]
43188
45271
  );
@@ -43259,8 +45342,8 @@ var init_SubagentTracePanel = __esm({
43259
45342
  ] });
43260
45343
  };
43261
45344
  CoordinatorConversation = ({ messages, autoScroll = true, className }) => {
43262
- const endRef = React86__default.useRef(null);
43263
- React86__default.useEffect(() => {
45345
+ const endRef = React97__default.useRef(null);
45346
+ React97__default.useEffect(() => {
43264
45347
  if (!autoScroll) return;
43265
45348
  endRef.current?.scrollIntoView({ behavior: "smooth", block: "end" });
43266
45349
  }, [messages.length, autoScroll]);
@@ -43690,7 +45773,7 @@ var init_Timeline = __esm({
43690
45773
  }) => {
43691
45774
  const { t } = useTranslate();
43692
45775
  const entityData = entity ?? [];
43693
- const items = React86__default.useMemo(() => {
45776
+ const items = React97__default.useMemo(() => {
43694
45777
  if (propItems) return propItems;
43695
45778
  if (entityData.length === 0) return [];
43696
45779
  return entityData.map((record, idx) => {
@@ -43792,7 +45875,7 @@ var init_Timeline = __esm({
43792
45875
  }
43793
45876
  });
43794
45877
  function extractToastProps(children) {
43795
- if (!React86__default.isValidElement(children)) {
45878
+ if (!React97__default.isValidElement(children)) {
43796
45879
  if (typeof children === "string") {
43797
45880
  return { message: children };
43798
45881
  }
@@ -43834,7 +45917,7 @@ var init_ToastSlot = __esm({
43834
45917
  eventBus.emit(`${prefix}CLOSE`);
43835
45918
  };
43836
45919
  if (!isVisible) return null;
43837
- const isCustomContent = React86__default.isValidElement(children) && !message;
45920
+ const isCustomContent = React97__default.isValidElement(children) && !message;
43838
45921
  return /* @__PURE__ */ jsx(Box, { className: "fixed bottom-4 right-4 z-50", children: isCustomContent ? children : /* @__PURE__ */ jsx(
43839
45922
  Toast,
43840
45923
  {
@@ -43851,7 +45934,7 @@ var init_ToastSlot = __esm({
43851
45934
  }
43852
45935
  });
43853
45936
  function lazyThree(name, loader) {
43854
- const Lazy = React86__default.lazy(
45937
+ const Lazy = React97__default.lazy(
43855
45938
  () => loader().then((m) => {
43856
45939
  const Resolved = m[name];
43857
45940
  if (!Resolved) {
@@ -43863,13 +45946,13 @@ function lazyThree(name, loader) {
43863
45946
  })
43864
45947
  );
43865
45948
  function ThreeWrapper(props) {
43866
- return React86__default.createElement(
45949
+ return React97__default.createElement(
43867
45950
  ThreeBoundary,
43868
45951
  { name },
43869
- React86__default.createElement(
43870
- React86__default.Suspense,
45952
+ React97__default.createElement(
45953
+ React97__default.Suspense,
43871
45954
  { fallback: null },
43872
- React86__default.createElement(Lazy, props)
45955
+ React97__default.createElement(Lazy, props)
43873
45956
  )
43874
45957
  );
43875
45958
  }
@@ -43905,6 +45988,7 @@ var init_component_registry_generated = __esm({
43905
45988
  init_LayoutPatterns();
43906
45989
  init_BranchingLogicBuilder();
43907
45990
  init_Breadcrumb();
45991
+ init_BuilderBoard();
43908
45992
  init_CTABanner();
43909
45993
  init_CalendarGrid();
43910
45994
  init_Canvas2D();
@@ -43920,6 +46004,7 @@ var init_component_registry_generated = __esm({
43920
46004
  init_Checkbox();
43921
46005
  init_ChemistryCanvas();
43922
46006
  init_ChoiceButton();
46007
+ init_ClassifierBoard();
43923
46008
  init_CodeBlock();
43924
46009
  init_CodeRunnerPanel();
43925
46010
  init_ComboCounter();
@@ -43943,6 +46028,7 @@ var init_component_registry_generated = __esm({
43943
46028
  init_DateRangePicker();
43944
46029
  init_DateRangeSelector();
43945
46030
  init_DayCell();
46031
+ init_DebuggerBoard();
43946
46032
  init_DetailPanel();
43947
46033
  init_Dialog();
43948
46034
  init_DialogueBubble();
@@ -43958,6 +46044,7 @@ var init_component_registry_generated = __esm({
43958
46044
  init_EmptyState();
43959
46045
  init_ErrorBoundary();
43960
46046
  init_ErrorState();
46047
+ init_EventHandlerBoard();
43961
46048
  init_EventLog();
43962
46049
  init_FeatureCard();
43963
46050
  init_FeatureDetailPageTemplate();
@@ -44024,6 +46111,7 @@ var init_component_registry_generated = __esm({
44024
46111
  init_ModalSlot();
44025
46112
  init_ModuleCard();
44026
46113
  init_Navigation();
46114
+ init_NegotiatorBoard();
44027
46115
  init_NumberStepper();
44028
46116
  init_OptionConstraintGroup();
44029
46117
  init_OrbitalVisualization();
@@ -44062,6 +46150,7 @@ var init_component_registry_generated = __esm({
44062
46150
  init_SegmentRenderer();
44063
46151
  init_Select();
44064
46152
  init_SequenceBar();
46153
+ init_SequencerBoard();
44065
46154
  init_ServiceCatalog();
44066
46155
  init_ShowcaseCard();
44067
46156
  init_ShowcaseOrganism();
@@ -44070,6 +46159,7 @@ var init_component_registry_generated = __esm({
44070
46159
  init_SignaturePad();
44071
46160
  init_SimpleGrid();
44072
46161
  init_SimulationCanvas();
46162
+ init_SimulatorBoard();
44073
46163
  init_Skeleton();
44074
46164
  init_SocialProof();
44075
46165
  init_SortableList();
@@ -44083,6 +46173,7 @@ var init_component_registry_generated = __esm({
44083
46173
  init_StatBadge();
44084
46174
  init_StatCard();
44085
46175
  init_StatDisplay();
46176
+ init_StateArchitectBoard();
44086
46177
  init_StateIndicator();
44087
46178
  init_StateMachineView();
44088
46179
  init_StatsGrid();
@@ -44137,7 +46228,7 @@ var init_component_registry_generated = __esm({
44137
46228
  init_WizardContainer();
44138
46229
  init_WizardNavigation();
44139
46230
  init_WizardProgress();
44140
- ThreeBoundary = class extends React86__default.Component {
46231
+ ThreeBoundary = class extends React97__default.Component {
44141
46232
  constructor() {
44142
46233
  super(...arguments);
44143
46234
  __publicField(this, "state", { failed: false });
@@ -44147,7 +46238,7 @@ var init_component_registry_generated = __esm({
44147
46238
  }
44148
46239
  render() {
44149
46240
  if (this.state.failed) {
44150
- return React86__default.createElement(
46241
+ return React97__default.createElement(
44151
46242
  "div",
44152
46243
  {
44153
46244
  "data-testid": "three-unavailable",
@@ -44193,6 +46284,7 @@ var init_component_registry_generated = __esm({
44193
46284
  "BoxPattern": BoxPattern,
44194
46285
  "BranchingLogicBuilder": BranchingLogicBuilder,
44195
46286
  "Breadcrumb": Breadcrumb,
46287
+ "BuilderBoard": BuilderBoard,
44196
46288
  "Button": ButtonPattern,
44197
46289
  "ButtonPattern": ButtonPattern,
44198
46290
  "CTABanner": CTABanner,
@@ -44210,6 +46302,7 @@ var init_component_registry_generated = __esm({
44210
46302
  "Checkbox": Checkbox,
44211
46303
  "ChemistryCanvas": ChemistryCanvas,
44212
46304
  "ChoiceButton": ChoiceButton,
46305
+ "ClassifierBoard": ClassifierBoard,
44213
46306
  "CodeBlock": CodeBlock,
44214
46307
  "CodeRunnerPanel": CodeRunnerPanel,
44215
46308
  "ComboCounter": ComboCounter,
@@ -44233,6 +46326,7 @@ var init_component_registry_generated = __esm({
44233
46326
  "DateRangePicker": DateRangePicker,
44234
46327
  "DateRangeSelector": DateRangeSelector,
44235
46328
  "DayCell": DayCell,
46329
+ "DebuggerBoard": DebuggerBoard,
44236
46330
  "DetailPanel": DetailPanel,
44237
46331
  "Dialog": Dialog,
44238
46332
  "DialogueBubble": DialogueBubble,
@@ -44250,6 +46344,7 @@ var init_component_registry_generated = __esm({
44250
46344
  "EmptyState": EmptyState,
44251
46345
  "ErrorBoundary": ErrorBoundary,
44252
46346
  "ErrorState": ErrorState,
46347
+ "EventHandlerBoard": EventHandlerBoard,
44253
46348
  "EventLog": EventLog,
44254
46349
  "FeatureCard": FeatureCard,
44255
46350
  "FeatureDetailPageTemplate": FeatureDetailPageTemplate,
@@ -44324,6 +46419,7 @@ var init_component_registry_generated = __esm({
44324
46419
  "ModalSlot": ModalSlot,
44325
46420
  "ModuleCard": ModuleCard,
44326
46421
  "Navigation": Navigation,
46422
+ "NegotiatorBoard": NegotiatorBoard,
44327
46423
  "NumberStepper": NumberStepper,
44328
46424
  "OptionConstraintGroup": OptionConstraintGroup,
44329
46425
  "OrbitalVisualization": OrbitalVisualization,
@@ -44362,6 +46458,7 @@ var init_component_registry_generated = __esm({
44362
46458
  "SegmentRenderer": SegmentRenderer,
44363
46459
  "Select": Select,
44364
46460
  "SequenceBar": SequenceBar,
46461
+ "SequencerBoard": SequencerBoard,
44365
46462
  "ServiceCatalog": ServiceCatalog,
44366
46463
  "ShowcaseCard": ShowcaseCard,
44367
46464
  "ShowcaseOrganism": ShowcaseOrganism,
@@ -44370,6 +46467,7 @@ var init_component_registry_generated = __esm({
44370
46467
  "SignaturePad": SignaturePad,
44371
46468
  "SimpleGrid": SimpleGrid,
44372
46469
  "SimulationCanvas": SimulationCanvas,
46470
+ "SimulatorBoard": SimulatorBoard,
44373
46471
  "Skeleton": Skeleton,
44374
46472
  "SocialProof": SocialProof,
44375
46473
  "SortableList": SortableList,
@@ -44386,6 +46484,7 @@ var init_component_registry_generated = __esm({
44386
46484
  "StatBadge": StatBadge,
44387
46485
  "StatCard": StatCard,
44388
46486
  "StatDisplay": StatDisplay,
46487
+ "StateArchitectBoard": StateArchitectBoard,
44389
46488
  "StateIndicator": StateIndicator,
44390
46489
  "StateMachineView": StateMachineView,
44391
46490
  "StatsGrid": StatsGrid,
@@ -44459,7 +46558,7 @@ function SuspenseConfigProvider({
44459
46558
  config,
44460
46559
  children
44461
46560
  }) {
44462
- return React86__default.createElement(
46561
+ return React97__default.createElement(
44463
46562
  SuspenseConfigContext.Provider,
44464
46563
  { value: config },
44465
46564
  children
@@ -44501,7 +46600,7 @@ function enrichFormFields(fields, entityDef) {
44501
46600
  }
44502
46601
  return { name: field, label: field.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/\b\w/g, (c) => c.toUpperCase()) };
44503
46602
  }
44504
- if (field && typeof field === "object" && !Array.isArray(field) && !React86__default.isValidElement(field) && !(field instanceof Date)) {
46603
+ if (field && typeof field === "object" && !Array.isArray(field) && !React97__default.isValidElement(field) && !(field instanceof Date)) {
44505
46604
  const obj = field;
44506
46605
  const fieldName = typeof obj.name === "string" ? obj.name : typeof obj.field === "string" ? obj.field : void 0;
44507
46606
  if (!fieldName) return field;
@@ -44954,7 +47053,7 @@ function renderPatternChildren(children, onDismiss, parentId = "root", parentPat
44954
47053
  const key = `${parentId}-${index}-trait:${traitName}`;
44955
47054
  return /* @__PURE__ */ jsx(TraitFrame, { traitName }, key);
44956
47055
  }
44957
- return /* @__PURE__ */ jsx(React86__default.Fragment, { children: child }, `${parentId}-${index}`);
47056
+ return /* @__PURE__ */ jsx(React97__default.Fragment, { children: child }, `${parentId}-${index}`);
44958
47057
  }
44959
47058
  if (!child || typeof child !== "object") return null;
44960
47059
  const childId = `${parentId}-${index}`;
@@ -44994,14 +47093,14 @@ function isPatternConfig(value) {
44994
47093
  if (value === null || value === void 0) return false;
44995
47094
  if (typeof value !== "object") return false;
44996
47095
  if (Array.isArray(value)) return false;
44997
- if (React86__default.isValidElement(value)) return false;
47096
+ if (React97__default.isValidElement(value)) return false;
44998
47097
  if (value instanceof Date) return false;
44999
47098
  if (typeof value === "function") return false;
45000
47099
  const record = value;
45001
47100
  return "type" in record && typeof record.type === "string" && getComponentForPattern$1(record.type) !== null;
45002
47101
  }
45003
47102
  function isPlainConfigObject(value) {
45004
- if (React86__default.isValidElement(value)) return false;
47103
+ if (React97__default.isValidElement(value)) return false;
45005
47104
  if (value instanceof Date) return false;
45006
47105
  const proto = Object.getPrototypeOf(value);
45007
47106
  return proto === Object.prototype || proto === null;
@@ -45127,7 +47226,7 @@ function SlotContentRenderer({
45127
47226
  for (const slotKey of CONTENT_NODE_SLOTS) {
45128
47227
  const slotVal = restProps[slotKey];
45129
47228
  if (slotVal === void 0 || slotVal === null) continue;
45130
- if (React86__default.isValidElement(slotVal) || typeof slotVal === "string" || typeof slotVal === "number" || typeof slotVal === "boolean") continue;
47229
+ if (React97__default.isValidElement(slotVal) || typeof slotVal === "string" || typeof slotVal === "number" || typeof slotVal === "boolean") continue;
45131
47230
  if (Array.isArray(slotVal) || typeof slotVal === "object" && "type" in slotVal) {
45132
47231
  nodeSlotOverrides[slotKey] = renderPatternChildren(
45133
47232
  slotVal,
@@ -45176,7 +47275,7 @@ function SlotContentRenderer({
45176
47275
  const resolvedItems = Array.isArray(entityVal) && entityVal[0] !== "fn" ? entityVal : null;
45177
47276
  if (resolvedItems && resolvedItems.length > 0 && !finalProps.fields && !finalProps.columns) {
45178
47277
  const sample = resolvedItems[0];
45179
- if (sample && typeof sample === "object" && !Array.isArray(sample) && !React86__default.isValidElement(sample) && !(sample instanceof Date)) {
47278
+ if (sample && typeof sample === "object" && !Array.isArray(sample) && !React97__default.isValidElement(sample) && !(sample instanceof Date)) {
45180
47279
  const keys = Object.keys(sample).filter((k) => k !== "id" && k !== "_id");
45181
47280
  finalProps.fields = keys.map((k, i) => ({ name: k, variant: i === 0 ? "h4" : "body" }));
45182
47281
  }