@almadar/ui 5.76.1 → 5.76.4

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.
@@ -1,6 +1,6 @@
1
- import * as React106 from 'react';
2
- import React106__default, { createContext, useContext, useMemo, useRef, useEffect, useCallback, Suspense, useState, useLayoutEffect, lazy, useId, useSyncExternalStore } from 'react';
3
- import { EventBusContext, useTraitScope, useEntitySchemaOptional, TraitScopeProvider, useCurrentPagePath, useGameAudioContextOptional } from '@almadar/ui/providers';
1
+ import * as React107 from 'react';
2
+ import React107__default, { createContext, useContext, useMemo, useRef, useEffect, useCallback, Suspense, useState, useLayoutEffect, lazy, useId, useSyncExternalStore } from 'react';
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';
@@ -10,7 +10,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
10
10
  import { createPortal } from 'react-dom';
11
11
  import { useTranslate } from '@almadar/ui/hooks';
12
12
  import { useUISlots, ThemeProvider, useTheme } from '@almadar/ui/context';
13
- export { BUILT_IN_THEMES, DesignThemeProvider, default as ThemeContext, ThemeProvider, UISlotContext, UISlotProvider, useDesignTheme, useSlotContent, useSlotHasContent, useTheme, useUISlots } from '@almadar/ui/context';
13
+ export { DesignThemeProvider, useDesignTheme } from '@almadar/ui/context';
14
14
  import { evaluate, createMinimalContext } from '@almadar/evaluator';
15
15
  import { getPatternDefinition, getComponentForPattern } from '@almadar/patterns';
16
16
  import { Link, Outlet, useLocation } from 'react-router-dom';
@@ -388,7 +388,7 @@ var init_Box = __esm({
388
388
  fixed: "fixed",
389
389
  sticky: "sticky"
390
390
  };
391
- Box = React106__default.forwardRef(
391
+ Box = React107__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 React106__default.createElement(
456
+ return React107__default.createElement(
457
457
  Component,
458
458
  {
459
459
  ref,
@@ -549,7 +549,7 @@ function loadLib(key, importer) {
549
549
  return p2;
550
550
  }
551
551
  function lazyFamilyIcon(libKey, importer, pick, fallbackName, family) {
552
- const Lazy = React106__default.lazy(async () => {
552
+ const Lazy = React107__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
- React106__default.Suspense,
562
+ React107__default.Suspense,
563
563
  {
564
564
  fallback: /* @__PURE__ */ jsx(
565
565
  "span",
@@ -1286,7 +1286,7 @@ var init_Icon = __esm({
1286
1286
  const directIcon = typeof icon === "string" ? void 0 : icon;
1287
1287
  const effectiveName = typeof icon === "string" ? icon : name;
1288
1288
  const family = useIconFamily();
1289
- const RenderedComponent = React106__default.useMemo(() => {
1289
+ const RenderedComponent = React107__default.useMemo(() => {
1290
1290
  if (directIcon) return null;
1291
1291
  return effectiveName ? resolveIconForFamily(effectiveName, family) : null;
1292
1292
  }, [directIcon, effectiveName, family]);
@@ -1348,7 +1348,7 @@ function resolveIconProp(value, sizeClass) {
1348
1348
  const IconComp = value;
1349
1349
  return /* @__PURE__ */ jsx(IconComp, { className: sizeClass });
1350
1350
  }
1351
- if (React106__default.isValidElement(value)) {
1351
+ if (React107__default.isValidElement(value)) {
1352
1352
  return value;
1353
1353
  }
1354
1354
  if (typeof value === "object" && value !== null && isIconLike(value)) {
@@ -1424,7 +1424,7 @@ var init_Button = __esm({
1424
1424
  md: "h-icon-default w-icon-default",
1425
1425
  lg: "h-icon-default w-icon-default"
1426
1426
  };
1427
- Button = React106__default.forwardRef(
1427
+ Button = React107__default.forwardRef(
1428
1428
  ({
1429
1429
  className,
1430
1430
  variant = "primary",
@@ -1490,7 +1490,7 @@ var Dialog;
1490
1490
  var init_Dialog = __esm({
1491
1491
  "components/core/atoms/Dialog.tsx"() {
1492
1492
  init_cn();
1493
- Dialog = React106__default.forwardRef(
1493
+ Dialog = React107__default.forwardRef(
1494
1494
  ({
1495
1495
  role = "dialog",
1496
1496
  "aria-modal": ariaModal = true,
@@ -1608,7 +1608,7 @@ var init_Typography = __esm({
1608
1608
  }) => {
1609
1609
  const variant = variantProp ?? (level ? `h${level}` : "body1");
1610
1610
  const Component = as || defaultElements[variant];
1611
- return React106__default.createElement(
1611
+ return React107__default.createElement(
1612
1612
  Component,
1613
1613
  {
1614
1614
  id,
@@ -2103,7 +2103,7 @@ var init_Badge = __esm({
2103
2103
  md: "px-2.5 py-1 text-sm",
2104
2104
  lg: "px-3 py-1.5 text-base"
2105
2105
  };
2106
- Badge = React106__default.forwardRef(
2106
+ Badge = React107__default.forwardRef(
2107
2107
  ({ className, variant = "default", size = "sm", amount, label, icon, children, onRemove, removeLabel, ...props }, ref) => {
2108
2108
  const iconSizes3 = {
2109
2109
  sm: "h-icon-default w-icon-default",
@@ -2439,7 +2439,7 @@ var init_SvgFlow = __esm({
2439
2439
  width = 100,
2440
2440
  height = 100
2441
2441
  }) => {
2442
- const markerId = React106__default.useMemo(() => {
2442
+ const markerId = React107__default.useMemo(() => {
2443
2443
  flowIdCounter += 1;
2444
2444
  return `almadar-flow-arrow-${flowIdCounter}`;
2445
2445
  }, []);
@@ -3032,7 +3032,7 @@ var init_SvgRing = __esm({
3032
3032
  width = 100,
3033
3033
  height = 100
3034
3034
  }) => {
3035
- const gradientId = React106__default.useMemo(() => {
3035
+ const gradientId = React107__default.useMemo(() => {
3036
3036
  ringIdCounter += 1;
3037
3037
  return `almadar-ring-glow-${ringIdCounter}`;
3038
3038
  }, []);
@@ -3213,7 +3213,7 @@ var init_Input = __esm({
3213
3213
  init_cn();
3214
3214
  init_Icon();
3215
3215
  init_useEventBus();
3216
- Input = React106__default.forwardRef(
3216
+ Input = React107__default.forwardRef(
3217
3217
  ({
3218
3218
  className,
3219
3219
  inputType,
@@ -3373,7 +3373,7 @@ var Label;
3373
3373
  var init_Label = __esm({
3374
3374
  "components/core/atoms/Label.tsx"() {
3375
3375
  init_cn();
3376
- Label = React106__default.forwardRef(
3376
+ Label = React107__default.forwardRef(
3377
3377
  ({ className, required, children, ...props }, ref) => {
3378
3378
  return /* @__PURE__ */ jsxs(
3379
3379
  "label",
@@ -3400,7 +3400,7 @@ var init_Textarea = __esm({
3400
3400
  "components/core/atoms/Textarea.tsx"() {
3401
3401
  init_cn();
3402
3402
  init_useEventBus();
3403
- Textarea = React106__default.forwardRef(
3403
+ Textarea = React107__default.forwardRef(
3404
3404
  ({ className, error, onChange, ...props }, ref) => {
3405
3405
  const eventBus = useEventBus();
3406
3406
  const handleChange = (e) => {
@@ -3639,7 +3639,7 @@ var init_Select = __esm({
3639
3639
  init_cn();
3640
3640
  init_Icon();
3641
3641
  init_useEventBus();
3642
- Select = React106__default.forwardRef(
3642
+ Select = React107__default.forwardRef(
3643
3643
  (props, _ref) => {
3644
3644
  const { multiple, searchable, clearable } = props;
3645
3645
  if (multiple || searchable || clearable) {
@@ -3656,7 +3656,7 @@ var init_Checkbox = __esm({
3656
3656
  "components/core/atoms/Checkbox.tsx"() {
3657
3657
  init_cn();
3658
3658
  init_useEventBus();
3659
- Checkbox = React106__default.forwardRef(
3659
+ Checkbox = React107__default.forwardRef(
3660
3660
  ({ className, label, id, onChange, ...props }, ref) => {
3661
3661
  const inputId = id || `checkbox-${Math.random().toString(36).substr(2, 9)}`;
3662
3662
  const eventBus = useEventBus();
@@ -3710,7 +3710,7 @@ var init_Spinner = __esm({
3710
3710
  md: "h-6 w-6",
3711
3711
  lg: "h-8 w-8"
3712
3712
  };
3713
- Spinner = React106__default.forwardRef(
3713
+ Spinner = React107__default.forwardRef(
3714
3714
  ({ className, size = "md", overlay, ...props }, ref) => {
3715
3715
  if (overlay) {
3716
3716
  return /* @__PURE__ */ jsx(
@@ -3800,7 +3800,7 @@ var init_Card = __esm({
3800
3800
  chip: "shadow-none rounded-pill border-[length:var(--border-width)] border-border",
3801
3801
  "tile-image-first": "p-0 overflow-hidden"
3802
3802
  };
3803
- Card = React106__default.forwardRef(
3803
+ Card = React107__default.forwardRef(
3804
3804
  ({
3805
3805
  className,
3806
3806
  variant = "bordered",
@@ -3848,9 +3848,9 @@ var init_Card = __esm({
3848
3848
  }
3849
3849
  );
3850
3850
  Card.displayName = "Card";
3851
- CardHeader = React106__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("mb-4", className), ...props }));
3851
+ CardHeader = React107__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("mb-4", className), ...props }));
3852
3852
  CardHeader.displayName = "CardHeader";
3853
- CardTitle = React106__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
3853
+ CardTitle = React107__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
3854
3854
  "h3",
3855
3855
  {
3856
3856
  ref,
@@ -3863,11 +3863,11 @@ var init_Card = __esm({
3863
3863
  }
3864
3864
  ));
3865
3865
  CardTitle.displayName = "CardTitle";
3866
- CardContent = React106__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("", className), ...props }));
3866
+ CardContent = React107__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("", className), ...props }));
3867
3867
  CardContent.displayName = "CardContent";
3868
3868
  CardBody = CardContent;
3869
3869
  CardBody.displayName = "CardBody";
3870
- CardFooter = React106__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
3870
+ CardFooter = React107__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
3871
3871
  "div",
3872
3872
  {
3873
3873
  ref,
@@ -3922,7 +3922,7 @@ var init_FilterPill = __esm({
3922
3922
  md: "w-3.5 h-3.5",
3923
3923
  lg: "w-4 h-4"
3924
3924
  };
3925
- FilterPill = React106__default.forwardRef(
3925
+ FilterPill = React107__default.forwardRef(
3926
3926
  ({
3927
3927
  className,
3928
3928
  variant = "default",
@@ -4051,8 +4051,8 @@ var init_Avatar = __esm({
4051
4051
  actionPayload
4052
4052
  }) => {
4053
4053
  const eventBus = useEventBus();
4054
- const [imgFailed, setImgFailed] = React106__default.useState(false);
4055
- React106__default.useEffect(() => {
4054
+ const [imgFailed, setImgFailed] = React107__default.useState(false);
4055
+ React107__default.useEffect(() => {
4056
4056
  setImgFailed(false);
4057
4057
  }, [src]);
4058
4058
  const initials = providedInitials ?? (name ? generateInitials(name) : void 0);
@@ -4165,7 +4165,7 @@ var init_Center = __esm({
4165
4165
  as: Component = "div"
4166
4166
  }) => {
4167
4167
  const mergedStyle = minHeight ? { minHeight, ...style } : style;
4168
- return React106__default.createElement(Component, {
4168
+ return React107__default.createElement(Component, {
4169
4169
  className: cn(
4170
4170
  inline ? "inline-flex" : "flex",
4171
4171
  horizontal && "justify-center",
@@ -4433,7 +4433,7 @@ var init_Radio = __esm({
4433
4433
  md: "w-2.5 h-2.5",
4434
4434
  lg: "w-3 h-3"
4435
4435
  };
4436
- Radio = React106__default.forwardRef(
4436
+ Radio = React107__default.forwardRef(
4437
4437
  ({
4438
4438
  label,
4439
4439
  helperText,
@@ -4450,12 +4450,12 @@ var init_Radio = __esm({
4450
4450
  onChange,
4451
4451
  ...props
4452
4452
  }, ref) => {
4453
- const reactId = React106__default.useId();
4453
+ const reactId = React107__default.useId();
4454
4454
  const baseId = id || `radio-${reactId}`;
4455
4455
  const hasError = !!error;
4456
4456
  const eventBus = useEventBus();
4457
- const [selected, setSelected] = React106__default.useState(value);
4458
- React106__default.useEffect(() => {
4457
+ const [selected, setSelected] = React107__default.useState(value);
4458
+ React107__default.useEffect(() => {
4459
4459
  if (value !== void 0) setSelected(value);
4460
4460
  }, [value]);
4461
4461
  const pick = (next, e) => {
@@ -4637,7 +4637,7 @@ var init_Switch = __esm({
4637
4637
  "components/core/atoms/Switch.tsx"() {
4638
4638
  "use client";
4639
4639
  init_cn();
4640
- Switch = React106.forwardRef(
4640
+ Switch = React107.forwardRef(
4641
4641
  ({
4642
4642
  checked,
4643
4643
  defaultChecked = false,
@@ -4648,10 +4648,10 @@ var init_Switch = __esm({
4648
4648
  name,
4649
4649
  className
4650
4650
  }, ref) => {
4651
- const [isChecked, setIsChecked] = React106.useState(
4651
+ const [isChecked, setIsChecked] = React107.useState(
4652
4652
  checked !== void 0 ? checked : defaultChecked
4653
4653
  );
4654
- React106.useEffect(() => {
4654
+ React107.useEffect(() => {
4655
4655
  if (checked !== void 0) {
4656
4656
  setIsChecked(checked);
4657
4657
  }
@@ -4810,7 +4810,7 @@ var init_Stack = __esm({
4810
4810
  };
4811
4811
  const isHorizontal = direction === "horizontal";
4812
4812
  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";
4813
- return React106__default.createElement(
4813
+ return React107__default.createElement(
4814
4814
  Component,
4815
4815
  {
4816
4816
  className: cn(
@@ -5010,7 +5010,7 @@ var Aside;
5010
5010
  var init_Aside = __esm({
5011
5011
  "components/core/atoms/Aside.tsx"() {
5012
5012
  init_cn();
5013
- Aside = React106__default.forwardRef(
5013
+ Aside = React107__default.forwardRef(
5014
5014
  ({ className, children, ...rest }, ref) => /* @__PURE__ */ jsx("aside", { ref, className: cn(className), ...rest, children })
5015
5015
  );
5016
5016
  Aside.displayName = "Aside";
@@ -5089,9 +5089,9 @@ var init_LawReferenceTooltip = __esm({
5089
5089
  className
5090
5090
  }) => {
5091
5091
  const { t } = useTranslate();
5092
- const [isVisible, setIsVisible] = React106__default.useState(false);
5093
- const timeoutRef = React106__default.useRef(null);
5094
- const triggerRef = React106__default.useRef(null);
5092
+ const [isVisible, setIsVisible] = React107__default.useState(false);
5093
+ const timeoutRef = React107__default.useRef(null);
5094
+ const triggerRef = React107__default.useRef(null);
5095
5095
  const handleMouseEnter = () => {
5096
5096
  if (timeoutRef.current) clearTimeout(timeoutRef.current);
5097
5097
  timeoutRef.current = setTimeout(() => setIsVisible(true), 200);
@@ -5102,7 +5102,7 @@ var init_LawReferenceTooltip = __esm({
5102
5102
  };
5103
5103
  const { revealed, triggerProps } = useTapReveal({ refs: [triggerRef] });
5104
5104
  const open = isVisible || revealed;
5105
- React106__default.useEffect(() => {
5105
+ React107__default.useEffect(() => {
5106
5106
  return () => {
5107
5107
  if (timeoutRef.current) clearTimeout(timeoutRef.current);
5108
5108
  };
@@ -5312,7 +5312,7 @@ var init_StatusDot = __esm({
5312
5312
  md: "w-2.5 h-2.5",
5313
5313
  lg: "w-3 h-3"
5314
5314
  };
5315
- StatusDot = React106__default.forwardRef(
5315
+ StatusDot = React107__default.forwardRef(
5316
5316
  ({ className, status = "offline", pulse = false, size = "md", label, ...props }, ref) => {
5317
5317
  return /* @__PURE__ */ jsx(
5318
5318
  "span",
@@ -5366,7 +5366,7 @@ var init_TrendIndicator = __esm({
5366
5366
  down: "trending-down",
5367
5367
  flat: "arrow-right"
5368
5368
  };
5369
- TrendIndicator = React106__default.forwardRef(
5369
+ TrendIndicator = React107__default.forwardRef(
5370
5370
  ({
5371
5371
  className,
5372
5372
  value,
@@ -5433,7 +5433,7 @@ var init_RangeSlider = __esm({
5433
5433
  md: "w-4 h-4",
5434
5434
  lg: "w-5 h-5"
5435
5435
  };
5436
- RangeSlider = React106__default.forwardRef(
5436
+ RangeSlider = React107__default.forwardRef(
5437
5437
  ({
5438
5438
  className,
5439
5439
  min = 0,
@@ -5939,7 +5939,7 @@ var init_ContentSection = __esm({
5939
5939
  md: "py-16",
5940
5940
  lg: "py-24"
5941
5941
  };
5942
- ContentSection = React106__default.forwardRef(
5942
+ ContentSection = React107__default.forwardRef(
5943
5943
  ({ children, background = "default", padding = "lg", id, className }, ref) => {
5944
5944
  return /* @__PURE__ */ jsx(
5945
5945
  Box,
@@ -6473,7 +6473,7 @@ var init_AnimatedReveal = __esm({
6473
6473
  "scale-up": { opacity: 1, transform: "scale(1) translateY(0)" },
6474
6474
  "none": {}
6475
6475
  };
6476
- AnimatedReveal = React106__default.forwardRef(
6476
+ AnimatedReveal = React107__default.forwardRef(
6477
6477
  ({
6478
6478
  trigger = "scroll",
6479
6479
  animation = "fade-up",
@@ -6633,7 +6633,7 @@ var init_AnimatedGraphic = __esm({
6633
6633
  "components/marketing/atoms/AnimatedGraphic.tsx"() {
6634
6634
  "use client";
6635
6635
  init_cn();
6636
- AnimatedGraphic = React106__default.forwardRef(
6636
+ AnimatedGraphic = React107__default.forwardRef(
6637
6637
  ({
6638
6638
  src,
6639
6639
  svgContent,
@@ -6656,7 +6656,7 @@ var init_AnimatedGraphic = __esm({
6656
6656
  const fetchedSvg = useFetchedSvg(svgContent ? void 0 : src);
6657
6657
  const resolvedSvg = svgContent ?? fetchedSvg;
6658
6658
  const prevAnimateRef = useRef(animate);
6659
- const setRef = React106__default.useCallback(
6659
+ const setRef = React107__default.useCallback(
6660
6660
  (node) => {
6661
6661
  containerRef.current = node;
6662
6662
  if (typeof ref === "function") ref(node);
@@ -8276,7 +8276,7 @@ function GameCard({
8276
8276
  className
8277
8277
  }) {
8278
8278
  const eventBus = useEventBus();
8279
- const handleClick = React106.useCallback(() => {
8279
+ const handleClick = React107.useCallback(() => {
8280
8280
  if (disabled) return;
8281
8281
  onClick?.(id);
8282
8282
  if (clickEvent) eventBus.emit(`UI:${clickEvent}`, { cardId: id });
@@ -8548,9 +8548,9 @@ function ControlButton({
8548
8548
  className
8549
8549
  }) {
8550
8550
  const eventBus = useEventBus();
8551
- const [isPressed, setIsPressed] = React106.useState(false);
8551
+ const [isPressed, setIsPressed] = React107.useState(false);
8552
8552
  const actualPressed = pressed ?? isPressed;
8553
- const handlePointerDown = React106.useCallback(
8553
+ const handlePointerDown = React107.useCallback(
8554
8554
  (e) => {
8555
8555
  e.preventDefault();
8556
8556
  if (disabled) return;
@@ -8560,7 +8560,7 @@ function ControlButton({
8560
8560
  },
8561
8561
  [disabled, pressEvent, eventBus, onPress]
8562
8562
  );
8563
- const handlePointerUp = React106.useCallback(
8563
+ const handlePointerUp = React107.useCallback(
8564
8564
  (e) => {
8565
8565
  e.preventDefault();
8566
8566
  if (disabled) return;
@@ -8570,7 +8570,7 @@ function ControlButton({
8570
8570
  },
8571
8571
  [disabled, releaseEvent, eventBus, onRelease]
8572
8572
  );
8573
- const handlePointerLeave = React106.useCallback(
8573
+ const handlePointerLeave = React107.useCallback(
8574
8574
  (e) => {
8575
8575
  if (isPressed) {
8576
8576
  setIsPressed(false);
@@ -9629,8 +9629,8 @@ function MiniMap({
9629
9629
  viewportRect = DEFAULT_VIEWPORT,
9630
9630
  className
9631
9631
  }) {
9632
- const canvasRef = React106.useRef(null);
9633
- React106.useEffect(() => {
9632
+ const canvasRef = React107.useRef(null);
9633
+ React107.useEffect(() => {
9634
9634
  const canvas = canvasRef.current;
9635
9635
  if (!canvas) return;
9636
9636
  const ctx = canvas.getContext("2d");
@@ -9780,8 +9780,8 @@ function ControlGrid({
9780
9780
  className
9781
9781
  }) {
9782
9782
  const eventBus = useEventBus();
9783
- const [active, setActive] = React106.useState(/* @__PURE__ */ new Set());
9784
- const handlePress = React106.useCallback(
9783
+ const [active, setActive] = React107.useState(/* @__PURE__ */ new Set());
9784
+ const handlePress = React107.useCallback(
9785
9785
  (id) => {
9786
9786
  setActive((prev) => new Set(prev).add(id));
9787
9787
  if (actionEvent) eventBus.emit(`UI:${actionEvent}`, { id, pressed: true });
@@ -9793,7 +9793,7 @@ function ControlGrid({
9793
9793
  },
9794
9794
  [kind, actionEvent, directionEvent, eventBus, onAction, onDirection]
9795
9795
  );
9796
- const handleRelease = React106.useCallback(
9796
+ const handleRelease = React107.useCallback(
9797
9797
  (id) => {
9798
9798
  setActive((prev) => {
9799
9799
  const next = new Set(prev);
@@ -10054,7 +10054,7 @@ function InventoryGrid({
10054
10054
  const eventBus = useEventBus();
10055
10055
  const slotCount = totalSlots ?? items.length;
10056
10056
  const emptySlotCount = Math.max(0, slotCount - items.length);
10057
- const handleSelect = React106.useCallback(
10057
+ const handleSelect = React107.useCallback(
10058
10058
  (id) => {
10059
10059
  onSelect?.(id);
10060
10060
  if (selectEvent) {
@@ -10257,7 +10257,7 @@ function GameMenu({
10257
10257
  } catch {
10258
10258
  }
10259
10259
  const eventBus = eventBusProp || eventBusFromHook;
10260
- const handleOptionClick = React106.useCallback(
10260
+ const handleOptionClick = React107.useCallback(
10261
10261
  (option) => {
10262
10262
  if (option.event && eventBus) {
10263
10263
  eventBus.emit(`UI:${option.event}`, { option });
@@ -12100,6 +12100,329 @@ var init_useCanvasEffects = __esm({
12100
12100
  "use client";
12101
12101
  }
12102
12102
  });
12103
+ function pickPath(entry) {
12104
+ if (Array.isArray(entry.path)) {
12105
+ return entry.path[Math.floor(Math.random() * entry.path.length)];
12106
+ }
12107
+ return entry.path;
12108
+ }
12109
+ function useGameAudio({
12110
+ manifest,
12111
+ baseUrl = "",
12112
+ initialMuted = false,
12113
+ initialVolume = 1
12114
+ }) {
12115
+ const [muted, setMutedState] = useState(initialMuted);
12116
+ const [masterVolume, setMasterVolumeState] = useState(initialVolume);
12117
+ const mutedRef = useRef(muted);
12118
+ const volumeRef = useRef(masterVolume);
12119
+ const manifestRef = useRef(manifest);
12120
+ mutedRef.current = muted;
12121
+ volumeRef.current = masterVolume;
12122
+ manifestRef.current = manifest;
12123
+ const poolsRef = useRef(/* @__PURE__ */ new Map());
12124
+ const getOrCreateElement = useCallback((key) => {
12125
+ const entry = manifestRef.current[key];
12126
+ if (!entry) return null;
12127
+ let pool = poolsRef.current.get(key);
12128
+ if (!pool) {
12129
+ pool = [];
12130
+ poolsRef.current.set(key, pool);
12131
+ }
12132
+ const maxSize = entry.poolSize ?? 1;
12133
+ for (const audio of pool) {
12134
+ if (audio.paused && (audio.ended || audio.currentTime === 0)) {
12135
+ return audio;
12136
+ }
12137
+ }
12138
+ if (pool.length < maxSize) {
12139
+ const src = baseUrl + pickPath(entry);
12140
+ const audio = new Audio(src);
12141
+ audio.loop = entry.loop ?? false;
12142
+ pool.push(audio);
12143
+ return audio;
12144
+ }
12145
+ if (!entry.loop) {
12146
+ let oldest = pool[0];
12147
+ for (const audio of pool) {
12148
+ if (audio.currentTime > oldest.currentTime) {
12149
+ oldest = audio;
12150
+ }
12151
+ }
12152
+ oldest.pause();
12153
+ oldest.currentTime = 0;
12154
+ return oldest;
12155
+ }
12156
+ return null;
12157
+ }, [baseUrl]);
12158
+ const play = useCallback((key) => {
12159
+ if (mutedRef.current) return;
12160
+ const entry = manifestRef.current[key];
12161
+ if (!entry) return;
12162
+ const audio = getOrCreateElement(key);
12163
+ if (!audio) return;
12164
+ audio.volume = Math.min(1, (entry.volume ?? 1) * volumeRef.current);
12165
+ if (!entry.loop) {
12166
+ audio.currentTime = 0;
12167
+ }
12168
+ const promise = audio.play();
12169
+ if (promise) {
12170
+ promise.catch(() => {
12171
+ });
12172
+ }
12173
+ }, [getOrCreateElement]);
12174
+ const stop = useCallback((key) => {
12175
+ const pool = poolsRef.current.get(key);
12176
+ if (!pool) return;
12177
+ for (const audio of pool) {
12178
+ audio.pause();
12179
+ audio.currentTime = 0;
12180
+ }
12181
+ }, []);
12182
+ const currentMusicKeyRef = useRef(null);
12183
+ const currentMusicElRef = useRef(null);
12184
+ const musicFadeRef = useRef(null);
12185
+ const pendingMusicKeyRef = useRef(null);
12186
+ const clearMusicFade = useCallback(() => {
12187
+ if (musicFadeRef.current) {
12188
+ clearInterval(musicFadeRef.current);
12189
+ musicFadeRef.current = null;
12190
+ }
12191
+ }, []);
12192
+ const playMusic = useCallback((key) => {
12193
+ if (key === currentMusicKeyRef.current) return;
12194
+ pendingMusicKeyRef.current = key;
12195
+ const entry = manifestRef.current[key];
12196
+ if (!entry) return;
12197
+ const fadeDurationMs = entry.crossfadeDurationMs ?? 1500;
12198
+ const stepMs = 50;
12199
+ const totalSteps = Math.max(1, fadeDurationMs / stepMs);
12200
+ const targetVolume = Math.min(1, (entry.volume ?? 1) * volumeRef.current);
12201
+ clearMusicFade();
12202
+ const src = baseUrl + (Array.isArray(entry.path) ? entry.path[0] : entry.path);
12203
+ const incoming = new Audio(src);
12204
+ incoming.loop = true;
12205
+ incoming.volume = 0;
12206
+ const outgoing = currentMusicElRef.current;
12207
+ const outgoingStartVol = outgoing?.volume ?? 0;
12208
+ currentMusicKeyRef.current = key;
12209
+ currentMusicElRef.current = incoming;
12210
+ if (!mutedRef.current) {
12211
+ incoming.play().catch(() => {
12212
+ currentMusicKeyRef.current = null;
12213
+ currentMusicElRef.current = outgoing;
12214
+ });
12215
+ }
12216
+ let step = 0;
12217
+ musicFadeRef.current = setInterval(() => {
12218
+ step++;
12219
+ const progress = Math.min(step / totalSteps, 1);
12220
+ incoming.volume = Math.min(1, targetVolume * progress);
12221
+ if (outgoing) {
12222
+ outgoing.volume = Math.max(0, outgoingStartVol * (1 - progress));
12223
+ }
12224
+ if (progress >= 1) {
12225
+ clearMusicFade();
12226
+ if (outgoing) {
12227
+ outgoing.pause();
12228
+ outgoing.src = "";
12229
+ }
12230
+ }
12231
+ }, stepMs);
12232
+ }, [baseUrl, clearMusicFade]);
12233
+ const stopMusic = useCallback((fadeDurationMs = 1e3) => {
12234
+ const outgoing = currentMusicElRef.current;
12235
+ if (!outgoing) return;
12236
+ currentMusicKeyRef.current = null;
12237
+ currentMusicElRef.current = null;
12238
+ pendingMusicKeyRef.current = null;
12239
+ clearMusicFade();
12240
+ const startVolume = outgoing.volume;
12241
+ const stepMs = 50;
12242
+ const totalSteps = Math.max(1, fadeDurationMs / stepMs);
12243
+ let step = 0;
12244
+ musicFadeRef.current = setInterval(() => {
12245
+ step++;
12246
+ const progress = step / totalSteps;
12247
+ outgoing.volume = Math.max(0, startVolume * (1 - progress));
12248
+ if (progress >= 1) {
12249
+ clearMusicFade();
12250
+ outgoing.pause();
12251
+ outgoing.src = "";
12252
+ }
12253
+ }, stepMs);
12254
+ }, [clearMusicFade]);
12255
+ const stopAll = useCallback(() => {
12256
+ for (const pool of poolsRef.current.values()) {
12257
+ for (const audio of pool) {
12258
+ audio.pause();
12259
+ audio.currentTime = 0;
12260
+ }
12261
+ }
12262
+ stopMusic(0);
12263
+ }, [stopMusic]);
12264
+ const setMuted = useCallback((value) => {
12265
+ setMutedState(value);
12266
+ if (value) {
12267
+ for (const [key, pool] of poolsRef.current.entries()) {
12268
+ if (manifestRef.current[key]?.loop) {
12269
+ for (const audio of pool) {
12270
+ if (!audio.paused) audio.pause();
12271
+ }
12272
+ }
12273
+ }
12274
+ currentMusicElRef.current?.pause();
12275
+ } else {
12276
+ for (const [key, pool] of poolsRef.current.entries()) {
12277
+ const entry = manifestRef.current[key];
12278
+ if (entry?.loop && entry?.autostart) {
12279
+ for (const audio of pool) {
12280
+ if (audio.paused) audio.play().catch(() => {
12281
+ });
12282
+ }
12283
+ }
12284
+ }
12285
+ const musicEl = currentMusicElRef.current;
12286
+ if (musicEl) {
12287
+ musicEl.play().catch(() => {
12288
+ });
12289
+ }
12290
+ }
12291
+ }, []);
12292
+ const setMasterVolume = useCallback((volume) => {
12293
+ const clamped = Math.max(0, Math.min(1, volume));
12294
+ setMasterVolumeState(clamped);
12295
+ for (const [key, pool] of poolsRef.current.entries()) {
12296
+ const entryVol = manifestRef.current[key]?.volume ?? 1;
12297
+ for (const audio of pool) {
12298
+ audio.volume = Math.min(1, entryVol * clamped);
12299
+ }
12300
+ }
12301
+ if (!musicFadeRef.current && currentMusicElRef.current) {
12302
+ const key = currentMusicKeyRef.current;
12303
+ const entryVol = key ? manifestRef.current[key]?.volume ?? 1 : 1;
12304
+ currentMusicElRef.current.volume = Math.min(1, entryVol * clamped);
12305
+ }
12306
+ }, []);
12307
+ const unlockedRef = useRef(false);
12308
+ useEffect(() => {
12309
+ const autoKeys = Object.keys(manifest).filter((k) => manifest[k].autostart);
12310
+ const hasPendingMusic = () => pendingMusicKeyRef.current !== null;
12311
+ const hasAutoStart = autoKeys.length > 0;
12312
+ if (!hasAutoStart && !hasPendingMusic()) return;
12313
+ const unlock = () => {
12314
+ if (unlockedRef.current) return;
12315
+ unlockedRef.current = true;
12316
+ if (!mutedRef.current) {
12317
+ for (const key of autoKeys) {
12318
+ play(key);
12319
+ }
12320
+ const pending = pendingMusicKeyRef.current;
12321
+ if (pending && pending !== currentMusicKeyRef.current) {
12322
+ playMusic(pending);
12323
+ }
12324
+ }
12325
+ };
12326
+ document.addEventListener("click", unlock, { once: true });
12327
+ document.addEventListener("keydown", unlock, { once: true });
12328
+ document.addEventListener("touchstart", unlock, { once: true });
12329
+ return () => {
12330
+ document.removeEventListener("click", unlock);
12331
+ document.removeEventListener("keydown", unlock);
12332
+ document.removeEventListener("touchstart", unlock);
12333
+ };
12334
+ }, [manifest, play, playMusic]);
12335
+ useEffect(() => {
12336
+ return () => {
12337
+ clearMusicFade();
12338
+ for (const pool of poolsRef.current.values()) {
12339
+ for (const audio of pool) {
12340
+ audio.pause();
12341
+ audio.src = "";
12342
+ }
12343
+ }
12344
+ poolsRef.current.clear();
12345
+ if (currentMusicElRef.current) {
12346
+ currentMusicElRef.current.pause();
12347
+ currentMusicElRef.current.src = "";
12348
+ currentMusicElRef.current = null;
12349
+ }
12350
+ };
12351
+ }, [clearMusicFade]);
12352
+ return {
12353
+ play,
12354
+ stop,
12355
+ stopAll,
12356
+ playMusic,
12357
+ stopMusic,
12358
+ muted,
12359
+ setMuted,
12360
+ masterVolume,
12361
+ setMasterVolume
12362
+ };
12363
+ }
12364
+ var init_useGameAudio = __esm({
12365
+ "components/game/shared/hooks/useGameAudio.ts"() {
12366
+ "use client";
12367
+ useGameAudio.displayName = "useGameAudio";
12368
+ }
12369
+ });
12370
+ function useGameAudioContextOptional() {
12371
+ return useContext(GameAudioContext);
12372
+ }
12373
+ function GameAudioProvider({
12374
+ manifest,
12375
+ baseUrl = "",
12376
+ children,
12377
+ initialMuted = false
12378
+ }) {
12379
+ const eventBus = useEventBus();
12380
+ const { play, stop, stopAll, playMusic, stopMusic, muted, setMuted, masterVolume, setMasterVolume } = useGameAudio({ manifest, baseUrl, initialMuted });
12381
+ useEffect(() => {
12382
+ const unsubPlay = eventBus.on("UI:PLAY_SOUND", (event) => {
12383
+ const key = event.payload?.key;
12384
+ if (key) play(key);
12385
+ });
12386
+ const unsubStop = eventBus.on("UI:STOP_SOUND", (event) => {
12387
+ const key = event.payload?.key;
12388
+ if (key) {
12389
+ stop(key);
12390
+ } else {
12391
+ stopAll();
12392
+ }
12393
+ });
12394
+ const unsubChangeMusic = eventBus.on("UI:CHANGE_MUSIC", (event) => {
12395
+ const key = event.payload?.key;
12396
+ if (key) {
12397
+ playMusic(key);
12398
+ } else {
12399
+ stopMusic();
12400
+ }
12401
+ });
12402
+ const unsubStopMusic = eventBus.on("UI:STOP_MUSIC", () => {
12403
+ stopMusic();
12404
+ });
12405
+ return () => {
12406
+ unsubPlay();
12407
+ unsubStop();
12408
+ unsubChangeMusic();
12409
+ unsubStopMusic();
12410
+ };
12411
+ }, [eventBus, play, stop, stopAll, playMusic, stopMusic]);
12412
+ const value = { muted, setMuted, masterVolume, setMasterVolume, play, playMusic, stopMusic };
12413
+ return /* @__PURE__ */ jsx(GameAudioContext.Provider, { value, children });
12414
+ }
12415
+ var GameAudioContext;
12416
+ var init_GameAudioProvider = __esm({
12417
+ "components/game/shared/providers/GameAudioProvider.tsx"() {
12418
+ "use client";
12419
+ init_useEventBus();
12420
+ init_useGameAudio();
12421
+ GameAudioContext = createContext(null);
12422
+ GameAudioContext.displayName = "GameAudioContext";
12423
+ GameAudioProvider.displayName = "GameAudioProvider";
12424
+ }
12425
+ });
12103
12426
  function GameAudioToggle({
12104
12427
  size = "sm",
12105
12428
  className
@@ -12128,6 +12451,7 @@ var init_GameAudioToggle = __esm({
12128
12451
  "use client";
12129
12452
  init_atoms();
12130
12453
  init_cn();
12454
+ init_GameAudioProvider();
12131
12455
  GameAudioToggle.displayName = "GameAudioToggle";
12132
12456
  }
12133
12457
  });
@@ -15795,7 +16119,7 @@ function LinearView({
15795
16119
  /* @__PURE__ */ jsx(HStack, { className: "flex-wrap items-center", gap: "xs", children: trait.states.map((state, i) => {
15796
16120
  const isDone = i < currentIdx;
15797
16121
  const isCurrent = i === currentIdx;
15798
- return /* @__PURE__ */ jsxs(React106__default.Fragment, { children: [
16122
+ return /* @__PURE__ */ jsxs(React107__default.Fragment, { children: [
15799
16123
  i > 0 && /* @__PURE__ */ jsx(
15800
16124
  Typography,
15801
16125
  {
@@ -16323,7 +16647,7 @@ function SequenceBar({
16323
16647
  onSlotRemove(index);
16324
16648
  }, [onSlotRemove, playing]);
16325
16649
  const paddedSlots = Array.from({ length: maxSlots }, (_, i) => slots[i]);
16326
- return /* @__PURE__ */ jsx(HStack, { className: cn("items-center", className), gap: "sm", children: paddedSlots.map((slot, i) => /* @__PURE__ */ jsxs(React106__default.Fragment, { children: [
16650
+ return /* @__PURE__ */ jsx(HStack, { className: cn("items-center", className), gap: "sm", children: paddedSlots.map((slot, i) => /* @__PURE__ */ jsxs(React107__default.Fragment, { children: [
16327
16651
  i > 0 && /* @__PURE__ */ jsx(
16328
16652
  Typography,
16329
16653
  {
@@ -18750,10 +19074,10 @@ function getSlotContentRenderer2() {
18750
19074
  }
18751
19075
  function resolveDescriptor(value, idPrefix) {
18752
19076
  if (value === null || value === void 0) return value;
18753
- if (React106__default.isValidElement(value)) return value;
19077
+ if (React107__default.isValidElement(value)) return value;
18754
19078
  if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return value;
18755
19079
  if (Array.isArray(value)) {
18756
- return value.map((item, i) => /* @__PURE__ */ jsx(React106__default.Fragment, { children: resolveDescriptor(item, `${idPrefix}-${i}`) }, i));
19080
+ return value.map((item, i) => /* @__PURE__ */ jsx(React107__default.Fragment, { children: resolveDescriptor(item, `${idPrefix}-${i}`) }, i));
18757
19081
  }
18758
19082
  if (typeof value === "object") {
18759
19083
  const rec = value;
@@ -18889,7 +19213,7 @@ var init_GameTemplate = __esm({
18889
19213
  }
18890
19214
  });
18891
19215
  function asDescriptor(v) {
18892
- if (Array.isArray(v) || React106__default.isValidElement(v)) return null;
19216
+ if (Array.isArray(v) || React107__default.isValidElement(v)) return null;
18893
19217
  const o = v;
18894
19218
  if (typeof o.type !== "string") return null;
18895
19219
  const props = o.props !== void 0 && typeof o.props === "object" && !Array.isArray(o.props) && o.props !== null ? o.props : void 0;
@@ -18904,10 +19228,10 @@ function getSlotContentRenderer3() {
18904
19228
  }
18905
19229
  function resolveDescriptor2(value, idPrefix) {
18906
19230
  if (value === null || value === void 0) return value;
18907
- if (React106__default.isValidElement(value)) return value;
19231
+ if (React107__default.isValidElement(value)) return value;
18908
19232
  if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return value;
18909
19233
  if (Array.isArray(value)) {
18910
- return value.map((item, i) => /* @__PURE__ */ jsx(React106__default.Fragment, { children: resolveDescriptor2(item, `${idPrefix}-${i}`) }, i));
19234
+ return value.map((item, i) => /* @__PURE__ */ jsx(React107__default.Fragment, { children: resolveDescriptor2(item, `${idPrefix}-${i}`) }, i));
18911
19235
  }
18912
19236
  if (typeof value === "object" && value !== null) {
18913
19237
  const desc = asDescriptor(value);
@@ -19791,6 +20115,8 @@ var init_CardBattlerTemplate = __esm({
19791
20115
  CardBattlerTemplate.displayName = "CardBattlerTemplate";
19792
20116
  }
19793
20117
  });
20118
+
20119
+ // components/game/2d/molecules/index.ts
19794
20120
  var init_molecules = __esm({
19795
20121
  "components/game/2d/molecules/index.ts"() {
19796
20122
  init_shared();
@@ -19885,7 +20211,7 @@ var init_ErrorBoundary = __esm({
19885
20211
  }
19886
20212
  );
19887
20213
  };
19888
- ErrorBoundary = class extends React106__default.Component {
20214
+ ErrorBoundary = class extends React107__default.Component {
19889
20215
  constructor(props) {
19890
20216
  super(props);
19891
20217
  __publicField(this, "reset", () => {
@@ -20550,7 +20876,7 @@ var init_Container = __esm({
20550
20876
  as: Component = "div"
20551
20877
  }) => {
20552
20878
  const resolvedSize = maxWidth ?? size ?? "lg";
20553
- return React106__default.createElement(
20879
+ return React107__default.createElement(
20554
20880
  Component,
20555
20881
  {
20556
20882
  className: cn(
@@ -23158,7 +23484,7 @@ var init_CodeBlock = __esm({
23158
23484
  };
23159
23485
  LINE_PROPS_FN = (n) => ({ "data-line": String(n - 1) });
23160
23486
  HIDDEN_LINE_NUMBERS = { display: "none" };
23161
- CodeBlock = React106__default.memo(
23487
+ CodeBlock = React107__default.memo(
23162
23488
  ({
23163
23489
  code: rawCode,
23164
23490
  language = "text",
@@ -23745,7 +24071,7 @@ var init_MarkdownContent = __esm({
23745
24071
  init_Box();
23746
24072
  init_CodeBlock();
23747
24073
  init_cn();
23748
- MarkdownContent = React106__default.memo(
24074
+ MarkdownContent = React107__default.memo(
23749
24075
  ({ content, direction = "ltr", className }) => {
23750
24076
  const { t: _t } = useTranslate();
23751
24077
  const safeContent = typeof content === "string" ? content : String(content ?? "");
@@ -25072,7 +25398,7 @@ var init_StateMachineView = __esm({
25072
25398
  style: { top: title ? 30 : 0 },
25073
25399
  children: [
25074
25400
  entity && /* @__PURE__ */ jsx(EntityBox, { entity, config }),
25075
- states.map((state) => renderStateNode ? /* @__PURE__ */ jsx(React106__default.Fragment, { children: renderStateNode(state, config) }, state.id) : /* @__PURE__ */ jsx(
25401
+ states.map((state) => renderStateNode ? /* @__PURE__ */ jsx(React107__default.Fragment, { children: renderStateNode(state, config) }, state.id) : /* @__PURE__ */ jsx(
25076
25402
  StateNode2,
25077
25403
  {
25078
25404
  state,
@@ -30701,8 +31027,8 @@ var init_Menu = __esm({
30701
31027
  "bottom-end": "bottom-start"
30702
31028
  };
30703
31029
  const effectivePosition = direction === "rtl" ? rtlMirror[position] ?? position : position;
30704
- const triggerChild = React106__default.isValidElement(trigger) ? trigger : /* @__PURE__ */ jsx(Typography, { variant: "small", as: "span", children: trigger });
30705
- const triggerElement = React106__default.cloneElement(
31030
+ const triggerChild = React107__default.isValidElement(trigger) ? trigger : /* @__PURE__ */ jsx(Typography, { variant: "small", as: "span", children: trigger });
31031
+ const triggerElement = React107__default.cloneElement(
30706
31032
  triggerChild,
30707
31033
  {
30708
31034
  ref: triggerRef,
@@ -30797,14 +31123,14 @@ function useDataDnd(args) {
30797
31123
  const isZone = Boolean(dragGroup || accepts || sortable);
30798
31124
  const enabled = isZone || Boolean(dndRoot);
30799
31125
  const eventBus = useEventBus();
30800
- const parentRoot = React106__default.useContext(RootCtx);
31126
+ const parentRoot = React107__default.useContext(RootCtx);
30801
31127
  const isRoot = enabled && parentRoot === null;
30802
- const zoneId = React106__default.useId();
31128
+ const zoneId = React107__default.useId();
30803
31129
  const ownGroup = dragGroup ?? accepts ?? zoneId;
30804
- const [optimisticOrders, setOptimisticOrders] = React106__default.useState(() => /* @__PURE__ */ new Map());
30805
- const optimisticOrdersRef = React106__default.useRef(optimisticOrders);
31130
+ const [optimisticOrders, setOptimisticOrders] = React107__default.useState(() => /* @__PURE__ */ new Map());
31131
+ const optimisticOrdersRef = React107__default.useRef(optimisticOrders);
30806
31132
  optimisticOrdersRef.current = optimisticOrders;
30807
- const clearOptimisticOrder = React106__default.useCallback((group) => {
31133
+ const clearOptimisticOrder = React107__default.useCallback((group) => {
30808
31134
  setOptimisticOrders((prev) => {
30809
31135
  if (!prev.has(group)) return prev;
30810
31136
  const next = new Map(prev);
@@ -30829,7 +31155,7 @@ function useDataDnd(args) {
30829
31155
  const raw = it[dndItemIdField];
30830
31156
  return raw != null ? String(raw) : `__idx_${idx}`;
30831
31157
  }).join("|");
30832
- const itemIds = React106__default.useMemo(
31158
+ const itemIds = React107__default.useMemo(
30833
31159
  () => orderedItems.map((it, idx) => {
30834
31160
  const raw = it[dndItemIdField];
30835
31161
  return raw != null ? String(raw) : `__idx_${idx}`;
@@ -30840,7 +31166,7 @@ function useDataDnd(args) {
30840
31166
  const raw = it[dndItemIdField];
30841
31167
  return raw != null ? String(raw) : `__${idx}`;
30842
31168
  }).join("|");
30843
- React106__default.useEffect(() => {
31169
+ React107__default.useEffect(() => {
30844
31170
  const root = isRoot ? null : parentRoot;
30845
31171
  if (root) {
30846
31172
  root.clearOptimisticOrder(ownGroup);
@@ -30848,20 +31174,20 @@ function useDataDnd(args) {
30848
31174
  clearOptimisticOrder(ownGroup);
30849
31175
  }
30850
31176
  }, [itemsContentSig, ownGroup]);
30851
- const zonesRef = React106__default.useRef(/* @__PURE__ */ new Map());
30852
- const registerZone = React106__default.useCallback((zoneId2, meta2) => {
31177
+ const zonesRef = React107__default.useRef(/* @__PURE__ */ new Map());
31178
+ const registerZone = React107__default.useCallback((zoneId2, meta2) => {
30853
31179
  zonesRef.current.set(zoneId2, meta2);
30854
31180
  }, []);
30855
- const unregisterZone = React106__default.useCallback((zoneId2) => {
31181
+ const unregisterZone = React107__default.useCallback((zoneId2) => {
30856
31182
  zonesRef.current.delete(zoneId2);
30857
31183
  }, []);
30858
- const [activeDrag, setActiveDrag] = React106__default.useState(null);
30859
- const [overZoneGroup, setOverZoneGroup] = React106__default.useState(null);
30860
- const meta = React106__default.useMemo(
31184
+ const [activeDrag, setActiveDrag] = React107__default.useState(null);
31185
+ const [overZoneGroup, setOverZoneGroup] = React107__default.useState(null);
31186
+ const meta = React107__default.useMemo(
30861
31187
  () => ({ group: ownGroup, dropEvent, reorderEvent, positionEvent, itemIds, rawItems: items, idField: dndItemIdField }),
30862
31188
  [ownGroup, dropEvent, reorderEvent, positionEvent, itemIds, items, dndItemIdField]
30863
31189
  );
30864
- React106__default.useEffect(() => {
31190
+ React107__default.useEffect(() => {
30865
31191
  const target = isRoot ? null : parentRoot;
30866
31192
  if (!target) {
30867
31193
  zonesRef.current.set(zoneId, meta);
@@ -30880,7 +31206,7 @@ function useDataDnd(args) {
30880
31206
  }, [parentRoot, isRoot, zoneId, meta]);
30881
31207
  const sensors = useAlmadarDndSensors(true);
30882
31208
  const collisionDetection = almadarDndCollisionDetection;
30883
- const findZoneByItem = React106__default.useCallback(
31209
+ const findZoneByItem = React107__default.useCallback(
30884
31210
  (id) => {
30885
31211
  for (const z of zonesRef.current.values()) {
30886
31212
  if (z.itemIds.includes(id)) return z;
@@ -30889,7 +31215,7 @@ function useDataDnd(args) {
30889
31215
  },
30890
31216
  []
30891
31217
  );
30892
- React106__default.useCallback(
31218
+ React107__default.useCallback(
30893
31219
  (group) => {
30894
31220
  for (const z of zonesRef.current.values()) {
30895
31221
  if (z.group === group) return z;
@@ -30898,7 +31224,7 @@ function useDataDnd(args) {
30898
31224
  },
30899
31225
  []
30900
31226
  );
30901
- const handleDragEnd = React106__default.useCallback(
31227
+ const handleDragEnd = React107__default.useCallback(
30902
31228
  (event) => {
30903
31229
  const { active, over } = event;
30904
31230
  const activeIdStr = String(active.id);
@@ -30989,8 +31315,8 @@ function useDataDnd(args) {
30989
31315
  },
30990
31316
  [eventBus]
30991
31317
  );
30992
- const sortableData = React106__default.useMemo(() => ({ dndGroup: ownGroup }), [ownGroup]);
30993
- const SortableItem = React106__default.useCallback(
31318
+ const sortableData = React107__default.useMemo(() => ({ dndGroup: ownGroup }), [ownGroup]);
31319
+ const SortableItem = React107__default.useCallback(
30994
31320
  ({ id, children }) => {
30995
31321
  const {
30996
31322
  attributes,
@@ -31030,7 +31356,7 @@ function useDataDnd(args) {
31030
31356
  id: droppableId,
31031
31357
  data: sortableData
31032
31358
  });
31033
- const ctx = React106__default.useContext(RootCtx);
31359
+ const ctx = React107__default.useContext(RootCtx);
31034
31360
  const activeDrag2 = ctx?.activeDrag ?? null;
31035
31361
  const overZoneGroup2 = ctx?.overZoneGroup ?? null;
31036
31362
  const isThisZoneOver = overZoneGroup2 === ownGroup;
@@ -31045,7 +31371,7 @@ function useDataDnd(args) {
31045
31371
  showForeignPlaceholder,
31046
31372
  ctxAvailable: ctx != null
31047
31373
  });
31048
- React106__default.useEffect(() => {
31374
+ React107__default.useEffect(() => {
31049
31375
  dndLog.info("dropzone:isOver:change", { droppableId, group: ownGroup, isOver, isThisZoneOver, showForeignPlaceholder, activeDragSourceGroup: activeDrag2?.sourceGroup ?? null });
31050
31376
  }, [droppableId, isOver, isThisZoneOver, showForeignPlaceholder]);
31051
31377
  return /* @__PURE__ */ jsx(
@@ -31059,11 +31385,11 @@ function useDataDnd(args) {
31059
31385
  }
31060
31386
  );
31061
31387
  };
31062
- const rootContextValue = React106__default.useMemo(
31388
+ const rootContextValue = React107__default.useMemo(
31063
31389
  () => ({ registerZone, unregisterZone, activeDrag, overZoneGroup, optimisticOrders, clearOptimisticOrder }),
31064
31390
  [registerZone, unregisterZone, activeDrag, overZoneGroup, optimisticOrders, clearOptimisticOrder]
31065
31391
  );
31066
- const handleDragStart = React106__default.useCallback((event) => {
31392
+ const handleDragStart = React107__default.useCallback((event) => {
31067
31393
  const sourceZone = findZoneByItem(event.active.id);
31068
31394
  const rect = event.active.rect.current.initial;
31069
31395
  const height = rect?.height && rect.height > 0 ? rect.height : 64;
@@ -31082,7 +31408,7 @@ function useDataDnd(args) {
31082
31408
  isRoot
31083
31409
  });
31084
31410
  }, [findZoneByItem, isRoot, zoneId]);
31085
- const handleDragOver = React106__default.useCallback((event) => {
31411
+ const handleDragOver = React107__default.useCallback((event) => {
31086
31412
  const { active, over } = event;
31087
31413
  const overData = over?.data?.current;
31088
31414
  const overGroup = overData?.dndGroup ?? null;
@@ -31152,7 +31478,7 @@ function useDataDnd(args) {
31152
31478
  return next;
31153
31479
  });
31154
31480
  }, []);
31155
- const handleDragCancel = React106__default.useCallback((event) => {
31481
+ const handleDragCancel = React107__default.useCallback((event) => {
31156
31482
  setActiveDrag(null);
31157
31483
  setOverZoneGroup(null);
31158
31484
  dndLog.warn("dragCancel", {
@@ -31160,12 +31486,12 @@ function useDataDnd(args) {
31160
31486
  reason: "dnd-kit cancelled the drag (escape key, pointer interrupted, or external)"
31161
31487
  });
31162
31488
  }, []);
31163
- const handleDragEndWithCleanup = React106__default.useCallback((event) => {
31489
+ const handleDragEndWithCleanup = React107__default.useCallback((event) => {
31164
31490
  handleDragEnd(event);
31165
31491
  setActiveDrag(null);
31166
31492
  setOverZoneGroup(null);
31167
31493
  }, [handleDragEnd]);
31168
- const wrapContainer = React106__default.useCallback(
31494
+ const wrapContainer = React107__default.useCallback(
31169
31495
  (children) => {
31170
31496
  if (!enabled) return children;
31171
31497
  const strategy = layout === "grid" ? rectSortingStrategy : verticalListSortingStrategy;
@@ -31219,7 +31545,7 @@ var init_useDataDnd = __esm({
31219
31545
  init_useAlmadarDndCollision();
31220
31546
  init_Box();
31221
31547
  dndLog = createLogger("almadar:ui:dnd");
31222
- RootCtx = React106__default.createContext(null);
31548
+ RootCtx = React107__default.createContext(null);
31223
31549
  }
31224
31550
  });
31225
31551
  function renderIconInput(icon, props) {
@@ -31745,7 +32071,7 @@ function DataList({
31745
32071
  }) {
31746
32072
  const eventBus = useEventBus();
31747
32073
  const { t } = useTranslate();
31748
- const [visibleCount, setVisibleCount] = React106__default.useState(pageSize || Infinity);
32074
+ const [visibleCount, setVisibleCount] = React107__default.useState(pageSize || Infinity);
31749
32075
  const fieldDefs = fields ?? columns ?? [];
31750
32076
  const allDataRaw = Array.isArray(entity) ? entity : entity ? [entity] : [];
31751
32077
  const dnd = useDataDnd({
@@ -31764,7 +32090,7 @@ function DataList({
31764
32090
  const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
31765
32091
  const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
31766
32092
  const hasRenderProp = typeof children === "function";
31767
- React106__default.useEffect(() => {
32093
+ React107__default.useEffect(() => {
31768
32094
  const renderItemTypeOf = typeof schemaRenderItem;
31769
32095
  const childrenTypeOf = typeof children;
31770
32096
  if (data.length > 0 && !hasRenderProp) {
@@ -31868,7 +32194,7 @@ function DataList({
31868
32194
  const items2 = [...data];
31869
32195
  const groups2 = groupBy ? groupData(items2, groupBy) : [{ label: "", items: items2 }];
31870
32196
  const contentField = titleField?.name ?? fieldDefs[0]?.name ?? "";
31871
- return /* @__PURE__ */ jsx(VStack, { gap: "sm", className: cn("py-2", className), children: groups2.map((group, gi) => /* @__PURE__ */ jsxs(React106__default.Fragment, { children: [
32197
+ return /* @__PURE__ */ jsx(VStack, { gap: "sm", className: cn("py-2", className), children: groups2.map((group, gi) => /* @__PURE__ */ jsxs(React107__default.Fragment, { children: [
31872
32198
  group.label && /* @__PURE__ */ jsx(Divider, { label: group.label, className: "my-2" }),
31873
32199
  group.items.map((itemData, index) => {
31874
32200
  const id = itemData.id || `${gi}-${index}`;
@@ -32009,7 +32335,7 @@ function DataList({
32009
32335
  className
32010
32336
  ),
32011
32337
  children: [
32012
- groups.map((group, gi) => /* @__PURE__ */ jsxs(React106__default.Fragment, { children: [
32338
+ groups.map((group, gi) => /* @__PURE__ */ jsxs(React107__default.Fragment, { children: [
32013
32339
  group.label && /* @__PURE__ */ jsx(Divider, { label: group.label, className: gi > 0 ? "mt-4" : "mt-0" }),
32014
32340
  group.items.map(
32015
32341
  (itemData, index) => renderItem(itemData, index, gi === groups.length - 1 && index === group.items.length - 1)
@@ -32802,7 +33128,7 @@ var init_Flex = __esm({
32802
33128
  flexStyle.flexBasis = typeof basis === "number" ? `${basis}px` : basis;
32803
33129
  }
32804
33130
  }
32805
- return React106__default.createElement(Component, {
33131
+ return React107__default.createElement(Component, {
32806
33132
  className: cn(
32807
33133
  inline ? "inline-flex" : "flex",
32808
33134
  directionStyles[direction],
@@ -32921,7 +33247,7 @@ var init_Grid = __esm({
32921
33247
  as: Component = "div"
32922
33248
  }) => {
32923
33249
  const mergedStyle = rows2 ? { gridTemplateRows: `repeat(${rows2}, minmax(0, 1fr))`, ...style } : style;
32924
- return React106__default.createElement(
33250
+ return React107__default.createElement(
32925
33251
  Component,
32926
33252
  {
32927
33253
  className: cn(
@@ -33117,9 +33443,9 @@ var init_Popover = __esm({
33117
33443
  onMouseLeave: handleClose,
33118
33444
  onPointerDown: tapTriggerProps.onPointerDown
33119
33445
  };
33120
- const childElement = React106__default.isValidElement(children) ? children : /* @__PURE__ */ jsx("span", { children });
33446
+ const childElement = React107__default.isValidElement(children) ? children : /* @__PURE__ */ jsx("span", { children });
33121
33447
  const childPointerDown = childElement.props.onPointerDown;
33122
- const triggerElement = React106__default.cloneElement(
33448
+ const triggerElement = React107__default.cloneElement(
33123
33449
  childElement,
33124
33450
  {
33125
33451
  ref: triggerRef,
@@ -33721,9 +34047,9 @@ var init_Tooltip = __esm({
33721
34047
  if (hideTimeoutRef.current) clearTimeout(hideTimeoutRef.current);
33722
34048
  };
33723
34049
  }, []);
33724
- const triggerElement = React106__default.isValidElement(children) ? children : /* @__PURE__ */ jsx("span", { children });
34050
+ const triggerElement = React107__default.isValidElement(children) ? children : /* @__PURE__ */ jsx("span", { children });
33725
34051
  const childPointerDown = triggerElement.props.onPointerDown;
33726
- const trigger = React106__default.cloneElement(triggerElement, {
34052
+ const trigger = React107__default.cloneElement(triggerElement, {
33727
34053
  ref: triggerRef,
33728
34054
  onMouseEnter: handleMouseEnter,
33729
34055
  onMouseLeave: handleMouseLeave,
@@ -33813,7 +34139,7 @@ var init_WizardProgress = __esm({
33813
34139
  children: /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: normalizedSteps.map((step, index) => {
33814
34140
  const isActive = index === currentStep;
33815
34141
  const isCompleted = index < currentStep;
33816
- return /* @__PURE__ */ jsxs(React106__default.Fragment, { children: [
34142
+ return /* @__PURE__ */ jsxs(React107__default.Fragment, { children: [
33817
34143
  /* @__PURE__ */ jsx(
33818
34144
  "button",
33819
34145
  {
@@ -35145,13 +35471,13 @@ var init_MapView = __esm({
35145
35471
  shadowSize: [41, 41]
35146
35472
  });
35147
35473
  L.Marker.prototype.options.icon = defaultIcon;
35148
- const { useEffect: useEffect72, useRef: useRef75, useCallback: useCallback114, useState: useState105 } = React106__default;
35474
+ const { useEffect: useEffect75, useRef: useRef76, useCallback: useCallback117, useState: useState108 } = React107__default;
35149
35475
  const { Typography: Typography2 } = await Promise.resolve().then(() => (init_Typography(), Typography_exports));
35150
35476
  const { useEventBus: useEventBus2 } = await Promise.resolve().then(() => (init_useEventBus(), useEventBus_exports));
35151
35477
  function MapUpdater({ centerLat, centerLng, zoom }) {
35152
35478
  const map = useMap();
35153
- const prevRef = useRef75({ centerLat, centerLng, zoom });
35154
- useEffect72(() => {
35479
+ const prevRef = useRef76({ centerLat, centerLng, zoom });
35480
+ useEffect75(() => {
35155
35481
  const prev = prevRef.current;
35156
35482
  if (prev.centerLat !== centerLat || prev.centerLng !== centerLng || prev.zoom !== zoom) {
35157
35483
  map.setView([centerLat, centerLng], zoom);
@@ -35162,7 +35488,7 @@ var init_MapView = __esm({
35162
35488
  }
35163
35489
  function MapClickHandler({ onMapClick }) {
35164
35490
  const map = useMap();
35165
- useEffect72(() => {
35491
+ useEffect75(() => {
35166
35492
  if (!onMapClick) return;
35167
35493
  const handler = (e) => {
35168
35494
  onMapClick(e.latlng.lat, e.latlng.lng);
@@ -35190,8 +35516,8 @@ var init_MapView = __esm({
35190
35516
  showAttribution = true
35191
35517
  }) {
35192
35518
  const eventBus = useEventBus2();
35193
- const [clickedPosition, setClickedPosition] = useState105(null);
35194
- const handleMapClick = useCallback114((lat, lng) => {
35519
+ const [clickedPosition, setClickedPosition] = useState108(null);
35520
+ const handleMapClick = useCallback117((lat, lng) => {
35195
35521
  if (showClickedPin) {
35196
35522
  setClickedPosition({ lat, lng });
35197
35523
  }
@@ -35200,7 +35526,7 @@ var init_MapView = __esm({
35200
35526
  eventBus.emit(`UI:${mapClickEvent}`, { latitude: lat, longitude: lng });
35201
35527
  }
35202
35528
  }, [onMapClick, mapClickEvent, eventBus, showClickedPin]);
35203
- const handleMarkerClick = useCallback114((marker) => {
35529
+ const handleMarkerClick = useCallback117((marker) => {
35204
35530
  onMarkerClick?.(marker);
35205
35531
  if (markerClickEvent) {
35206
35532
  eventBus.emit(`UI:${markerClickEvent}`, { ...marker });
@@ -36060,8 +36386,8 @@ function TableView({
36060
36386
  }) {
36061
36387
  const eventBus = useEventBus();
36062
36388
  const { t } = useTranslate();
36063
- const [visibleCount, setVisibleCount] = React106__default.useState(pageSize > 0 ? pageSize : Infinity);
36064
- const [localSelected, setLocalSelected] = React106__default.useState(/* @__PURE__ */ new Set());
36389
+ const [visibleCount, setVisibleCount] = React107__default.useState(pageSize > 0 ? pageSize : Infinity);
36390
+ const [localSelected, setLocalSelected] = React107__default.useState(/* @__PURE__ */ new Set());
36065
36391
  const colDefs = columns ?? fields ?? [];
36066
36392
  const allDataRaw = Array.isArray(entity) ? entity : entity ? [entity] : [];
36067
36393
  const dnd = useDataDnd({
@@ -36256,12 +36582,12 @@ function TableView({
36256
36582
  ]
36257
36583
  }
36258
36584
  );
36259
- return dnd.isZone ? /* @__PURE__ */ jsx(dnd.SortableItem, { id: row[idField] ?? id, children: rowInner }, id) : /* @__PURE__ */ jsx(React106__default.Fragment, { children: rowInner }, id);
36585
+ return dnd.isZone ? /* @__PURE__ */ jsx(dnd.SortableItem, { id: row[idField] ?? id, children: rowInner }, id) : /* @__PURE__ */ jsx(React107__default.Fragment, { children: rowInner }, id);
36260
36586
  };
36261
36587
  const items = Array.from(data);
36262
36588
  const groups = groupBy ? groupData2(items, groupBy) : [{ label: "", items }];
36263
36589
  let runningIndex = 0;
36264
- const body = /* @__PURE__ */ jsx(Box, { role: "rowgroup", children: groups.map((group, gi) => /* @__PURE__ */ jsxs(React106__default.Fragment, { children: [
36590
+ const body = /* @__PURE__ */ jsx(Box, { role: "rowgroup", children: groups.map((group, gi) => /* @__PURE__ */ jsxs(React107__default.Fragment, { children: [
36265
36591
  group.label && /* @__PURE__ */ jsx(Divider, { label: group.label, className: gi > 0 ? "mt-3" : "mt-0" }),
36266
36592
  group.items.map((row) => renderRow(row, runningIndex++))
36267
36593
  ] }, gi)) });
@@ -37618,7 +37944,7 @@ var init_StepFlow = __esm({
37618
37944
  className
37619
37945
  }) => {
37620
37946
  if (orientation === "vertical") {
37621
- return /* @__PURE__ */ jsx(VStack, { gap: "none", className: cn("w-full", className), children: steps.map((step, index) => /* @__PURE__ */ jsx(React106__default.Fragment, { children: /* @__PURE__ */ jsxs(HStack, { gap: "md", align: "start", className: "w-full", children: [
37947
+ return /* @__PURE__ */ jsx(VStack, { gap: "none", className: cn("w-full", className), children: steps.map((step, index) => /* @__PURE__ */ jsx(React107__default.Fragment, { children: /* @__PURE__ */ jsxs(HStack, { gap: "md", align: "start", className: "w-full", children: [
37622
37948
  /* @__PURE__ */ jsxs(VStack, { gap: "none", align: "center", children: [
37623
37949
  /* @__PURE__ */ jsx(StepCircle, { step, index }),
37624
37950
  showConnectors && index < steps.length - 1 && /* @__PURE__ */ jsx(Box, { className: "w-px h-8 bg-border" })
@@ -37629,7 +37955,7 @@ var init_StepFlow = __esm({
37629
37955
  ] })
37630
37956
  ] }) }, index)) });
37631
37957
  }
37632
- 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(React106__default.Fragment, { children: [
37958
+ 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(React107__default.Fragment, { children: [
37633
37959
  /* @__PURE__ */ jsxs(VStack, { gap: "sm", align: "center", className: "flex-1 w-full md:w-auto", children: [
37634
37960
  /* @__PURE__ */ jsx(StepCircle, { step, index }),
37635
37961
  /* @__PURE__ */ jsx(Typography, { variant: "h4", className: "text-center", children: step.title }),
@@ -38614,7 +38940,7 @@ var init_LikertScale = __esm({
38614
38940
  md: "text-base",
38615
38941
  lg: "text-lg"
38616
38942
  };
38617
- LikertScale = React106__default.forwardRef(
38943
+ LikertScale = React107__default.forwardRef(
38618
38944
  ({
38619
38945
  question,
38620
38946
  options = DEFAULT_LIKERT_OPTIONS,
@@ -38626,7 +38952,7 @@ var init_LikertScale = __esm({
38626
38952
  variant = "radios",
38627
38953
  className
38628
38954
  }, ref) => {
38629
- const groupId = React106__default.useId();
38955
+ const groupId = React107__default.useId();
38630
38956
  const eventBus = useEventBus();
38631
38957
  const handleSelect = useCallback(
38632
38958
  (next) => {
@@ -40908,7 +41234,7 @@ var init_DocBreadcrumb = __esm({
40908
41234
  "aria-label": t("aria.breadcrumb"),
40909
41235
  children: /* @__PURE__ */ jsx(HStack, { gap: "xs", align: "center", wrap: true, children: items.map((item, idx) => {
40910
41236
  const isLast = idx === items.length - 1;
40911
- return /* @__PURE__ */ jsxs(React106__default.Fragment, { children: [
41237
+ return /* @__PURE__ */ jsxs(React107__default.Fragment, { children: [
40912
41238
  idx > 0 && /* @__PURE__ */ jsx(
40913
41239
  Icon,
40914
41240
  {
@@ -41777,7 +42103,7 @@ var init_MiniStateMachine = __esm({
41777
42103
  const x = 2 + i * (NODE_W + GAP + ARROW_W + GAP);
41778
42104
  const tc = transitionCounts[s.name] ?? 0;
41779
42105
  const role = getStateRole(s.name, s.isInitial ?? void 0, s.isTerminal ?? void 0, tc, maxTC);
41780
- return /* @__PURE__ */ jsxs(React106__default.Fragment, { children: [
42106
+ return /* @__PURE__ */ jsxs(React107__default.Fragment, { children: [
41781
42107
  /* @__PURE__ */ jsx(
41782
42108
  AvlState,
41783
42109
  {
@@ -41981,7 +42307,7 @@ var init_PageHeader = __esm({
41981
42307
  info: "bg-info/10 text-info"
41982
42308
  };
41983
42309
  return /* @__PURE__ */ jsxs(Box, { className: cn("mb-6", className), children: [
41984
- 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(React106__default.Fragment, { children: [
42310
+ 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(React107__default.Fragment, { children: [
41985
42311
  idx > 0 && /* @__PURE__ */ jsx(Typography, { variant: "small", color: "muted", children: "/" }),
41986
42312
  crumb.href ? /* @__PURE__ */ jsx(
41987
42313
  "a",
@@ -42339,7 +42665,7 @@ var init_Section = __esm({
42339
42665
  as: Component = "section"
42340
42666
  }) => {
42341
42667
  const hasHeader = title || description || action;
42342
- return React106__default.createElement(
42668
+ return React107__default.createElement(
42343
42669
  Component,
42344
42670
  {
42345
42671
  className: cn(
@@ -42705,7 +43031,7 @@ var init_WizardContainer = __esm({
42705
43031
  const isCompleted = index < currentStep;
42706
43032
  const stepKey = step.id ?? step.tabId ?? `step-${index}`;
42707
43033
  const stepTitle = step.title ?? step.name ?? `Step ${index + 1}`;
42708
- return /* @__PURE__ */ jsxs(React106__default.Fragment, { children: [
43034
+ return /* @__PURE__ */ jsxs(React107__default.Fragment, { children: [
42709
43035
  /* @__PURE__ */ jsx(
42710
43036
  Button,
42711
43037
  {
@@ -45138,7 +45464,7 @@ var init_DetailPanel = __esm({
45138
45464
  }
45139
45465
  });
45140
45466
  function extractTitle(children) {
45141
- if (!React106__default.isValidElement(children)) return void 0;
45467
+ if (!React107__default.isValidElement(children)) return void 0;
45142
45468
  const props = children.props;
45143
45469
  if (typeof props.title === "string") {
45144
45470
  return props.title;
@@ -45484,12 +45810,12 @@ var init_Form = __esm({
45484
45810
  const isSchemaEntity = isOrbitalEntitySchema(entity);
45485
45811
  const resolvedEntity = isSchemaEntity ? entity : void 0;
45486
45812
  const entityName = typeof entity === "string" ? entity : resolvedEntity?.name;
45487
- const normalizedInitialData = React106__default.useMemo(() => {
45813
+ const normalizedInitialData = React107__default.useMemo(() => {
45488
45814
  const entityRowAsInitial = isPlainEntityRow(entity) ? entity : void 0;
45489
45815
  const callerInitial = initialData !== null && typeof initialData === "object" && !Array.isArray(initialData) ? initialData : {};
45490
45816
  return entityRowAsInitial !== void 0 ? { ...entityRowAsInitial, ...callerInitial } : callerInitial;
45491
45817
  }, [entity, initialData]);
45492
- const entityDerivedFields = React106__default.useMemo(() => {
45818
+ const entityDerivedFields = React107__default.useMemo(() => {
45493
45819
  if (fields && fields.length > 0) return void 0;
45494
45820
  if (!resolvedEntity) return void 0;
45495
45821
  return resolvedEntity.fields.map(
@@ -45510,16 +45836,16 @@ var init_Form = __esm({
45510
45836
  const conditionalFields = typeof conditionalFieldsRaw === "boolean" ? {} : conditionalFieldsRaw;
45511
45837
  const hiddenCalculations = typeof hiddenCalculationsRaw === "boolean" ? [] : hiddenCalculationsRaw;
45512
45838
  const violationTriggers = typeof violationTriggersRaw === "boolean" ? [] : violationTriggersRaw;
45513
- const [formData, setFormData] = React106__default.useState(
45839
+ const [formData, setFormData] = React107__default.useState(
45514
45840
  normalizedInitialData
45515
45841
  );
45516
- const [collapsedSections, setCollapsedSections] = React106__default.useState(
45842
+ const [collapsedSections, setCollapsedSections] = React107__default.useState(
45517
45843
  /* @__PURE__ */ new Set()
45518
45844
  );
45519
- const [submitError, setSubmitError] = React106__default.useState(null);
45520
- const formRef = React106__default.useRef(null);
45845
+ const [submitError, setSubmitError] = React107__default.useState(null);
45846
+ const formRef = React107__default.useRef(null);
45521
45847
  const formMode = props.mode;
45522
- const mountedRef = React106__default.useRef(false);
45848
+ const mountedRef = React107__default.useRef(false);
45523
45849
  if (!mountedRef.current) {
45524
45850
  mountedRef.current = true;
45525
45851
  debug("forms", "mount", {
@@ -45532,7 +45858,7 @@ var init_Form = __esm({
45532
45858
  });
45533
45859
  }
45534
45860
  const shouldShowCancel = showCancel ?? (fields && fields.length > 0);
45535
- const evalContext = React106__default.useMemo(
45861
+ const evalContext = React107__default.useMemo(
45536
45862
  () => ({
45537
45863
  formValues: formData,
45538
45864
  globalVariables: externalContext?.globalVariables ?? {},
@@ -45541,7 +45867,7 @@ var init_Form = __esm({
45541
45867
  }),
45542
45868
  [formData, externalContext]
45543
45869
  );
45544
- React106__default.useEffect(() => {
45870
+ React107__default.useEffect(() => {
45545
45871
  debug("forms", "initialData-sync", {
45546
45872
  mode: formMode,
45547
45873
  normalizedInitialData,
@@ -45552,7 +45878,7 @@ var init_Form = __esm({
45552
45878
  setFormData(normalizedInitialData);
45553
45879
  }
45554
45880
  }, [normalizedInitialData]);
45555
- const processCalculations = React106__default.useCallback(
45881
+ const processCalculations = React107__default.useCallback(
45556
45882
  (changedFieldId, newFormData) => {
45557
45883
  if (!hiddenCalculations.length) return;
45558
45884
  const context = {
@@ -45577,7 +45903,7 @@ var init_Form = __esm({
45577
45903
  },
45578
45904
  [hiddenCalculations, externalContext, eventBus]
45579
45905
  );
45580
- const checkViolations = React106__default.useCallback(
45906
+ const checkViolations = React107__default.useCallback(
45581
45907
  (changedFieldId, newFormData) => {
45582
45908
  if (!violationTriggers.length) return;
45583
45909
  const context = {
@@ -45615,7 +45941,7 @@ var init_Form = __esm({
45615
45941
  processCalculations(name, newFormData);
45616
45942
  checkViolations(name, newFormData);
45617
45943
  };
45618
- const isFieldVisible = React106__default.useCallback(
45944
+ const isFieldVisible = React107__default.useCallback(
45619
45945
  (fieldName) => {
45620
45946
  const condition = conditionalFields[fieldName];
45621
45947
  if (!condition) return true;
@@ -45623,7 +45949,7 @@ var init_Form = __esm({
45623
45949
  },
45624
45950
  [conditionalFields, evalContext]
45625
45951
  );
45626
- const isSectionVisible = React106__default.useCallback(
45952
+ const isSectionVisible = React107__default.useCallback(
45627
45953
  (section) => {
45628
45954
  if (!section.condition) return true;
45629
45955
  return Boolean(evaluateFormExpression(section.condition, evalContext));
@@ -45699,7 +46025,7 @@ var init_Form = __esm({
45699
46025
  eventBus.emit(`UI:${onCancel}`);
45700
46026
  }
45701
46027
  };
45702
- const renderField = React106__default.useCallback(
46028
+ const renderField = React107__default.useCallback(
45703
46029
  (field) => {
45704
46030
  const fieldName = field.name || field.field;
45705
46031
  if (!fieldName) return null;
@@ -45720,7 +46046,7 @@ var init_Form = __esm({
45720
46046
  [formData, isFieldVisible, relationsData, relationsLoading, isLoading]
45721
46047
  );
45722
46048
  const effectiveFields = entityDerivedFields ?? fields;
45723
- const normalizedFields = React106__default.useMemo(() => {
46049
+ const normalizedFields = React107__default.useMemo(() => {
45724
46050
  if (!effectiveFields || effectiveFields.length === 0) return [];
45725
46051
  return effectiveFields.map((field) => {
45726
46052
  if (typeof field === "string") {
@@ -45744,7 +46070,7 @@ var init_Form = __esm({
45744
46070
  return field;
45745
46071
  });
45746
46072
  }, [effectiveFields, resolvedEntity]);
45747
- const schemaFields = React106__default.useMemo(() => {
46073
+ const schemaFields = React107__default.useMemo(() => {
45748
46074
  if (normalizedFields.length === 0) return null;
45749
46075
  if (isDebugEnabled()) {
45750
46076
  debugGroup(`Form: ${entityName || "unknown"}`);
@@ -45754,7 +46080,7 @@ var init_Form = __esm({
45754
46080
  }
45755
46081
  return normalizedFields.map(renderField).filter(Boolean);
45756
46082
  }, [normalizedFields, renderField, entityName, conditionalFields]);
45757
- const sectionElements = React106__default.useMemo(() => {
46083
+ const sectionElements = React107__default.useMemo(() => {
45758
46084
  if (!sections || sections.length === 0) return null;
45759
46085
  return sections.map((section) => {
45760
46086
  if (!isSectionVisible(section)) {
@@ -46479,7 +46805,7 @@ var init_List = __esm({
46479
46805
  if (entity && typeof entity === "object" && "id" in entity) return [entity];
46480
46806
  return [];
46481
46807
  }, [entity]);
46482
- const getItemActions = React106__default.useCallback(
46808
+ const getItemActions = React107__default.useCallback(
46483
46809
  (item) => {
46484
46810
  if (!itemActions) return [];
46485
46811
  if (typeof itemActions === "function") {
@@ -46954,7 +47280,7 @@ var init_MediaGallery = __esm({
46954
47280
  [selectable, selectedItems, selectionEvent, eventBus]
46955
47281
  );
46956
47282
  const entityData = Array.isArray(entity) ? entity : [];
46957
- const items = React106__default.useMemo(() => {
47283
+ const items = React107__default.useMemo(() => {
46958
47284
  if (propItems) return propItems;
46959
47285
  if (entityData.length === 0) return [];
46960
47286
  return entityData.map((record, idx) => {
@@ -47117,7 +47443,7 @@ var init_MediaGallery = __esm({
47117
47443
  }
47118
47444
  });
47119
47445
  function extractTitle2(children) {
47120
- if (!React106__default.isValidElement(children)) return void 0;
47446
+ if (!React107__default.isValidElement(children)) return void 0;
47121
47447
  const props = children.props;
47122
47448
  if (typeof props.title === "string") {
47123
47449
  return props.title;
@@ -47368,7 +47694,7 @@ var init_debugRegistry = __esm({
47368
47694
  }
47369
47695
  });
47370
47696
  function useDebugData() {
47371
- const [data, setData] = React106.useState(() => ({
47697
+ const [data, setData] = React107.useState(() => ({
47372
47698
  traits: [],
47373
47699
  ticks: [],
47374
47700
  guards: [],
@@ -47382,7 +47708,7 @@ function useDebugData() {
47382
47708
  },
47383
47709
  lastUpdate: Date.now()
47384
47710
  }));
47385
- React106.useEffect(() => {
47711
+ React107.useEffect(() => {
47386
47712
  const updateData = () => {
47387
47713
  setData({
47388
47714
  traits: getAllTraits(),
@@ -47491,12 +47817,12 @@ function layoutGraph(states, transitions, initialState, width, height) {
47491
47817
  return positions;
47492
47818
  }
47493
47819
  function WalkMinimap() {
47494
- const [walkStep, setWalkStep] = React106.useState(null);
47495
- const [traits2, setTraits] = React106.useState([]);
47496
- const [coveredEdges, setCoveredEdges] = React106.useState([]);
47497
- const [completedTraits, setCompletedTraits] = React106.useState(/* @__PURE__ */ new Set());
47498
- const prevTraitRef = React106.useRef(null);
47499
- React106.useEffect(() => {
47820
+ const [walkStep, setWalkStep] = React107.useState(null);
47821
+ const [traits2, setTraits] = React107.useState([]);
47822
+ const [coveredEdges, setCoveredEdges] = React107.useState([]);
47823
+ const [completedTraits, setCompletedTraits] = React107.useState(/* @__PURE__ */ new Set());
47824
+ const prevTraitRef = React107.useRef(null);
47825
+ React107.useEffect(() => {
47500
47826
  const interval = setInterval(() => {
47501
47827
  const w = window;
47502
47828
  const step = w.__orbitalWalkStep;
@@ -47932,15 +48258,15 @@ var init_EntitiesTab = __esm({
47932
48258
  });
47933
48259
  function EventFlowTab({ events: events2 }) {
47934
48260
  const { t } = useTranslate();
47935
- const [filter, setFilter] = React106.useState("all");
47936
- const containerRef = React106.useRef(null);
47937
- const [autoScroll, setAutoScroll] = React106.useState(true);
47938
- React106.useEffect(() => {
48261
+ const [filter, setFilter] = React107.useState("all");
48262
+ const containerRef = React107.useRef(null);
48263
+ const [autoScroll, setAutoScroll] = React107.useState(true);
48264
+ React107.useEffect(() => {
47939
48265
  if (autoScroll && containerRef.current) {
47940
48266
  containerRef.current.scrollTop = containerRef.current.scrollHeight;
47941
48267
  }
47942
48268
  }, [events2.length, autoScroll]);
47943
- const filteredEvents = React106.useMemo(() => {
48269
+ const filteredEvents = React107.useMemo(() => {
47944
48270
  if (filter === "all") return events2;
47945
48271
  return events2.filter((e) => e.type === filter);
47946
48272
  }, [events2, filter]);
@@ -48056,7 +48382,7 @@ var init_EventFlowTab = __esm({
48056
48382
  });
48057
48383
  function GuardsPanel({ guards }) {
48058
48384
  const { t } = useTranslate();
48059
- const [filter, setFilter] = React106.useState("all");
48385
+ const [filter, setFilter] = React107.useState("all");
48060
48386
  if (guards.length === 0) {
48061
48387
  return /* @__PURE__ */ jsx(
48062
48388
  EmptyState,
@@ -48069,7 +48395,7 @@ function GuardsPanel({ guards }) {
48069
48395
  }
48070
48396
  const passedCount = guards.filter((g) => g.result).length;
48071
48397
  const failedCount = guards.length - passedCount;
48072
- const filteredGuards = React106.useMemo(() => {
48398
+ const filteredGuards = React107.useMemo(() => {
48073
48399
  if (filter === "all") return guards;
48074
48400
  if (filter === "passed") return guards.filter((g) => g.result);
48075
48401
  return guards.filter((g) => !g.result);
@@ -48232,10 +48558,10 @@ function EffectBadge({ effect }) {
48232
48558
  }
48233
48559
  function TransitionTimeline({ transitions }) {
48234
48560
  const { t } = useTranslate();
48235
- const containerRef = React106.useRef(null);
48236
- const [autoScroll, setAutoScroll] = React106.useState(true);
48237
- const [expandedId, setExpandedId] = React106.useState(null);
48238
- React106.useEffect(() => {
48561
+ const containerRef = React107.useRef(null);
48562
+ const [autoScroll, setAutoScroll] = React107.useState(true);
48563
+ const [expandedId, setExpandedId] = React107.useState(null);
48564
+ React107.useEffect(() => {
48239
48565
  if (autoScroll && containerRef.current) {
48240
48566
  containerRef.current.scrollTop = containerRef.current.scrollHeight;
48241
48567
  }
@@ -48515,9 +48841,9 @@ function getAllEvents(traits2) {
48515
48841
  function EventDispatcherTab({ traits: traits2, schema }) {
48516
48842
  const eventBus = useEventBus();
48517
48843
  const { t } = useTranslate();
48518
- const [log11, setLog] = React106.useState([]);
48519
- const prevStatesRef = React106.useRef(/* @__PURE__ */ new Map());
48520
- React106.useEffect(() => {
48844
+ const [log13, setLog] = React107.useState([]);
48845
+ const prevStatesRef = React107.useRef(/* @__PURE__ */ new Map());
48846
+ React107.useEffect(() => {
48521
48847
  for (const trait of traits2) {
48522
48848
  const prev = prevStatesRef.current.get(trait.id);
48523
48849
  if (prev && prev !== trait.currentState) {
@@ -48579,9 +48905,9 @@ function EventDispatcherTab({ traits: traits2, schema }) {
48579
48905
  /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "medium", className: "text-gray-500 mb-1", children: t("debug.otherEvents") }),
48580
48906
  /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1", children: unavailableEvents.map((event) => /* @__PURE__ */ jsx(Badge, { variant: "default", size: "sm", className: "opacity-50", children: event }, event)) })
48581
48907
  ] }),
48582
- log11.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
48908
+ log13.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
48583
48909
  /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "medium", className: "text-gray-500 mb-1", children: t("debug.recentTransitions") }),
48584
- /* @__PURE__ */ jsx(Stack, { gap: "xs", children: log11.map((entry, i) => /* @__PURE__ */ jsxs(Typography, { variant: "small", className: "font-mono text-xs", children: [
48910
+ /* @__PURE__ */ jsx(Stack, { gap: "xs", children: log13.map((entry, i) => /* @__PURE__ */ jsxs(Typography, { variant: "small", className: "font-mono text-xs", children: [
48585
48911
  /* @__PURE__ */ jsx("span", { className: "text-purple-400", children: entry.traitName }),
48586
48912
  " ",
48587
48913
  /* @__PURE__ */ jsx("span", { className: "text-gray-500", children: entry.from }),
@@ -48686,10 +49012,10 @@ function VerifyModePanel({
48686
49012
  localCount
48687
49013
  }) {
48688
49014
  const { t } = useTranslate();
48689
- const [expanded, setExpanded] = React106.useState(true);
48690
- const scrollRef = React106.useRef(null);
48691
- const prevCountRef = React106.useRef(0);
48692
- React106.useEffect(() => {
49015
+ const [expanded, setExpanded] = React107.useState(true);
49016
+ const scrollRef = React107.useRef(null);
49017
+ const prevCountRef = React107.useRef(0);
49018
+ React107.useEffect(() => {
48693
49019
  if (expanded && transitions.length > prevCountRef.current && scrollRef.current) {
48694
49020
  scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
48695
49021
  }
@@ -48746,10 +49072,10 @@ function RuntimeDebugger({
48746
49072
  schema
48747
49073
  }) {
48748
49074
  const { t } = useTranslate();
48749
- const [isCollapsed, setIsCollapsed] = React106.useState(mode === "verify" ? true : defaultCollapsed);
48750
- const [isVisible, setIsVisible] = React106.useState(mode === "inline" || mode === "verify" || isDebugEnabled2());
49075
+ const [isCollapsed, setIsCollapsed] = React107.useState(mode === "verify" ? true : defaultCollapsed);
49076
+ const [isVisible, setIsVisible] = React107.useState(mode === "inline" || mode === "verify" || isDebugEnabled2());
48751
49077
  const debugData = useDebugData();
48752
- React106.useEffect(() => {
49078
+ React107.useEffect(() => {
48753
49079
  if (mode === "inline") return;
48754
49080
  return onDebugToggle((enabled) => {
48755
49081
  setIsVisible(enabled);
@@ -48758,7 +49084,7 @@ function RuntimeDebugger({
48758
49084
  }
48759
49085
  });
48760
49086
  }, [mode]);
48761
- React106.useEffect(() => {
49087
+ React107.useEffect(() => {
48762
49088
  if (mode === "inline") return;
48763
49089
  const handleKeyDown = (e) => {
48764
49090
  if (e.key === "`" && isVisible) {
@@ -49278,7 +49604,7 @@ var init_StatCard = __esm({
49278
49604
  const labelToUse = propLabel ?? propTitle;
49279
49605
  const eventBus = useEventBus();
49280
49606
  const { t } = useTranslate();
49281
- const handleActionClick = React106__default.useCallback(() => {
49607
+ const handleActionClick = React107__default.useCallback(() => {
49282
49608
  if (action?.event) {
49283
49609
  eventBus.emit(`UI:${action.event}`, {});
49284
49610
  }
@@ -49289,7 +49615,7 @@ var init_StatCard = __esm({
49289
49615
  const data = Array.isArray(entity) ? entity : entity ? [entity] : [];
49290
49616
  const isLoading = externalLoading ?? false;
49291
49617
  const error = externalError;
49292
- const computeMetricValue = React106__default.useCallback(
49618
+ const computeMetricValue = React107__default.useCallback(
49293
49619
  (metric, items) => {
49294
49620
  if (metric.value !== void 0) {
49295
49621
  return metric.value;
@@ -49328,7 +49654,7 @@ var init_StatCard = __esm({
49328
49654
  },
49329
49655
  []
49330
49656
  );
49331
- const schemaStats = React106__default.useMemo(() => {
49657
+ const schemaStats = React107__default.useMemo(() => {
49332
49658
  if (!metrics || metrics.length === 0) return null;
49333
49659
  return metrics.map((metric) => ({
49334
49660
  label: metric.label,
@@ -49336,7 +49662,7 @@ var init_StatCard = __esm({
49336
49662
  format: metric.format
49337
49663
  }));
49338
49664
  }, [metrics, data, computeMetricValue]);
49339
- const calculatedTrend = React106__default.useMemo(() => {
49665
+ const calculatedTrend = React107__default.useMemo(() => {
49340
49666
  if (manualTrend !== void 0) return manualTrend;
49341
49667
  if (previousValue === void 0 || currentValue === void 0)
49342
49668
  return void 0;
@@ -49976,8 +50302,8 @@ var init_SubagentTracePanel = __esm({
49976
50302
  ] });
49977
50303
  };
49978
50304
  InlineActivityStream = ({ activities, autoScroll = true, className }) => {
49979
- const endRef = React106__default.useRef(null);
49980
- React106__default.useEffect(() => {
50305
+ const endRef = React107__default.useRef(null);
50306
+ React107__default.useEffect(() => {
49981
50307
  if (!autoScroll) return;
49982
50308
  endRef.current?.scrollIntoView({ behavior: "smooth", block: "end" });
49983
50309
  }, [activities.length, autoScroll]);
@@ -50071,7 +50397,7 @@ var init_SubagentTracePanel = __esm({
50071
50397
  };
50072
50398
  SubagentRichCard = ({ subagent }) => {
50073
50399
  const { t } = useTranslate();
50074
- const activities = React106__default.useMemo(
50400
+ const activities = React107__default.useMemo(
50075
50401
  () => subagentMessagesToActivities(subagent.messages),
50076
50402
  [subagent.messages]
50077
50403
  );
@@ -50148,8 +50474,8 @@ var init_SubagentTracePanel = __esm({
50148
50474
  ] });
50149
50475
  };
50150
50476
  CoordinatorConversation = ({ messages, autoScroll = true, className }) => {
50151
- const endRef = React106__default.useRef(null);
50152
- React106__default.useEffect(() => {
50477
+ const endRef = React107__default.useRef(null);
50478
+ React107__default.useEffect(() => {
50153
50479
  if (!autoScroll) return;
50154
50480
  endRef.current?.scrollIntoView({ behavior: "smooth", block: "end" });
50155
50481
  }, [messages.length, autoScroll]);
@@ -50579,7 +50905,7 @@ var init_Timeline = __esm({
50579
50905
  }) => {
50580
50906
  const { t } = useTranslate();
50581
50907
  const entityData = entity ?? [];
50582
- const items = React106__default.useMemo(() => {
50908
+ const items = React107__default.useMemo(() => {
50583
50909
  if (propItems) return propItems;
50584
50910
  if (entityData.length === 0) return [];
50585
50911
  return entityData.map((record, idx) => {
@@ -50681,7 +51007,7 @@ var init_Timeline = __esm({
50681
51007
  }
50682
51008
  });
50683
51009
  function extractToastProps(children) {
50684
- if (!React106__default.isValidElement(children)) {
51010
+ if (!React107__default.isValidElement(children)) {
50685
51011
  if (typeof children === "string") {
50686
51012
  return { message: children };
50687
51013
  }
@@ -50719,7 +51045,7 @@ var init_ToastSlot = __esm({
50719
51045
  eventBus.emit("UI:CLOSE");
50720
51046
  };
50721
51047
  if (!isVisible) return null;
50722
- const isCustomContent = React106__default.isValidElement(children) && !message;
51048
+ const isCustomContent = React107__default.isValidElement(children) && !message;
50723
51049
  return /* @__PURE__ */ jsx(Box, { className: "fixed bottom-4 right-4 z-50", children: isCustomContent ? children : /* @__PURE__ */ jsx(
50724
51050
  Toast,
50725
51051
  {
@@ -50735,9 +51061,33 @@ var init_ToastSlot = __esm({
50735
51061
  ToastSlot.displayName = "ToastSlot";
50736
51062
  }
50737
51063
  });
50738
-
50739
- // components/core/organisms/component-registry.generated.ts
50740
- var COMPONENT_REGISTRY;
51064
+ function lazyThree(name, loader) {
51065
+ const Lazy = React107__default.lazy(
51066
+ () => loader().then((m) => {
51067
+ const Resolved = m[name];
51068
+ if (!Resolved) {
51069
+ throw new Error(
51070
+ `[@almadar/ui] 3D component "${name}" was not found in the three subpath bundle.`
51071
+ );
51072
+ }
51073
+ return { default: Resolved };
51074
+ })
51075
+ );
51076
+ function ThreeWrapper(props) {
51077
+ return React107__default.createElement(
51078
+ ThreeBoundary,
51079
+ { name },
51080
+ React107__default.createElement(
51081
+ React107__default.Suspense,
51082
+ { fallback: null },
51083
+ React107__default.createElement(Lazy, props)
51084
+ )
51085
+ );
51086
+ }
51087
+ ThreeWrapper.displayName = `Lazy(${name})`;
51088
+ return ThreeWrapper;
51089
+ }
51090
+ var ThreeBoundary, GameBoard3D, GameCanvas3D, GameCanvas3DBattleTemplate, GameCanvas3DCastleTemplate, GameCanvas3DWorldMapTemplate, COMPONENT_REGISTRY;
50741
51091
  var init_component_registry_generated = __esm({
50742
51092
  "components/core/organisms/component-registry.generated.ts"() {
50743
51093
  init_AboutPageTemplate();
@@ -50848,9 +51198,11 @@ var init_component_registry_generated = __esm({
50848
51198
  init_Form();
50849
51199
  init_FormField();
50850
51200
  init_FormSectionHeader();
51201
+ init_GameAudioProvider();
50851
51202
  init_GameAudioToggle();
50852
51203
  init_GameCard();
50853
51204
  init_GameHud();
51205
+ init_GameIcon();
50854
51206
  init_GameMenu();
50855
51207
  init_GameShell();
50856
51208
  init_GameTemplate();
@@ -51035,6 +51387,33 @@ var init_component_registry_generated = __esm({
51035
51387
  init_WizardProgress();
51036
51388
  init_WorldMapBoard();
51037
51389
  init_WorldMapTemplate();
51390
+ ThreeBoundary = class extends React107__default.Component {
51391
+ constructor() {
51392
+ super(...arguments);
51393
+ __publicField(this, "state", { failed: false });
51394
+ }
51395
+ static getDerivedStateFromError() {
51396
+ return { failed: true };
51397
+ }
51398
+ render() {
51399
+ if (this.state.failed) {
51400
+ return React107__default.createElement(
51401
+ "div",
51402
+ {
51403
+ "data-testid": "three-unavailable",
51404
+ style: { padding: 16, fontSize: 13, lineHeight: 1.5, opacity: 0.7 }
51405
+ },
51406
+ `3D pattern "${this.props.name}" requires three.js. Install the optional peers three + @react-three/fiber + @react-three/drei (matching the host React major) to render it.`
51407
+ );
51408
+ }
51409
+ return this.props.children;
51410
+ }
51411
+ };
51412
+ GameBoard3D = lazyThree("GameBoard3D", () => import('@almadar/ui/components/molecules/game/three'));
51413
+ GameCanvas3D = lazyThree("GameCanvas3D", () => import('@almadar/ui/components/molecules/game/three'));
51414
+ GameCanvas3DBattleTemplate = lazyThree("GameCanvas3DBattleTemplate", () => import('@almadar/ui/components/molecules/game/three'));
51415
+ GameCanvas3DCastleTemplate = lazyThree("GameCanvas3DCastleTemplate", () => import('@almadar/ui/components/molecules/game/three'));
51416
+ GameCanvas3DWorldMapTemplate = lazyThree("GameCanvas3DWorldMapTemplate", () => import('@almadar/ui/components/molecules/game/three'));
51038
51417
  COMPONENT_REGISTRY = {
51039
51418
  "AboutPageTemplate": AboutPageTemplate,
51040
51419
  "Accordion": Accordion,
@@ -51150,9 +51529,16 @@ var init_component_registry_generated = __esm({
51150
51529
  "Form": Form,
51151
51530
  "FormField": FormField,
51152
51531
  "FormSectionHeader": FormSectionHeader,
51532
+ "GameAudioProvider": GameAudioProvider,
51153
51533
  "GameAudioToggle": GameAudioToggle,
51534
+ "GameBoard3D": GameBoard3D,
51535
+ "GameCanvas3D": GameCanvas3D,
51536
+ "GameCanvas3DBattleTemplate": GameCanvas3DBattleTemplate,
51537
+ "GameCanvas3DCastleTemplate": GameCanvas3DCastleTemplate,
51538
+ "GameCanvas3DWorldMapTemplate": GameCanvas3DWorldMapTemplate,
51154
51539
  "GameCard": GameCard,
51155
51540
  "GameHud": GameHud,
51541
+ "GameIcon": GameIcon,
51156
51542
  "GameMenu": GameMenu,
51157
51543
  "GameShell": GameShell,
51158
51544
  "GameTemplate": GameTemplate,
@@ -51361,7 +51747,7 @@ function SuspenseConfigProvider({
51361
51747
  config,
51362
51748
  children
51363
51749
  }) {
51364
- return React106__default.createElement(
51750
+ return React107__default.createElement(
51365
51751
  SuspenseConfigContext.Provider,
51366
51752
  { value: config },
51367
51753
  children
@@ -51403,7 +51789,7 @@ function enrichFormFields(fields, entityDef) {
51403
51789
  }
51404
51790
  return { name: field, label: field.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/\b\w/g, (c) => c.toUpperCase()) };
51405
51791
  }
51406
- if (field && typeof field === "object" && !Array.isArray(field) && !React106__default.isValidElement(field) && !(field instanceof Date)) {
51792
+ if (field && typeof field === "object" && !Array.isArray(field) && !React107__default.isValidElement(field) && !(field instanceof Date)) {
51407
51793
  const obj = field;
51408
51794
  const fieldName = typeof obj.name === "string" ? obj.name : typeof obj.field === "string" ? obj.field : void 0;
51409
51795
  if (!fieldName) return field;
@@ -51849,7 +52235,7 @@ function renderPatternChildren(children, onDismiss, parentId = "root", parentPat
51849
52235
  const key = `${parentId}-${index}-trait:${traitName}`;
51850
52236
  return /* @__PURE__ */ jsx(TraitFrame, { traitName }, key);
51851
52237
  }
51852
- return /* @__PURE__ */ jsx(React106__default.Fragment, { children: child }, `${parentId}-${index}`);
52238
+ return /* @__PURE__ */ jsx(React107__default.Fragment, { children: child }, `${parentId}-${index}`);
51853
52239
  }
51854
52240
  if (!child || typeof child !== "object") return null;
51855
52241
  const childId = `${parentId}-${index}`;
@@ -51889,14 +52275,14 @@ function isPatternConfig(value) {
51889
52275
  if (value === null || value === void 0) return false;
51890
52276
  if (typeof value !== "object") return false;
51891
52277
  if (Array.isArray(value)) return false;
51892
- if (React106__default.isValidElement(value)) return false;
52278
+ if (React107__default.isValidElement(value)) return false;
51893
52279
  if (value instanceof Date) return false;
51894
52280
  if (typeof value === "function") return false;
51895
52281
  const record = value;
51896
52282
  return "type" in record && typeof record.type === "string" && getComponentForPattern(record.type) !== null;
51897
52283
  }
51898
52284
  function isPlainConfigObject(value) {
51899
- if (React106__default.isValidElement(value)) return false;
52285
+ if (React107__default.isValidElement(value)) return false;
51900
52286
  if (value instanceof Date) return false;
51901
52287
  const proto = Object.getPrototypeOf(value);
51902
52288
  return proto === Object.prototype || proto === null;
@@ -52022,7 +52408,7 @@ function SlotContentRenderer({
52022
52408
  for (const slotKey of CONTENT_NODE_SLOTS) {
52023
52409
  const slotVal = restProps[slotKey];
52024
52410
  if (slotVal === void 0 || slotVal === null) continue;
52025
- if (React106__default.isValidElement(slotVal) || typeof slotVal === "string" || typeof slotVal === "number" || typeof slotVal === "boolean") continue;
52411
+ if (React107__default.isValidElement(slotVal) || typeof slotVal === "string" || typeof slotVal === "number" || typeof slotVal === "boolean") continue;
52026
52412
  if (Array.isArray(slotVal) || typeof slotVal === "object" && "type" in slotVal) {
52027
52413
  nodeSlotOverrides[slotKey] = renderPatternChildren(
52028
52414
  slotVal,
@@ -52071,7 +52457,7 @@ function SlotContentRenderer({
52071
52457
  const resolvedItems = Array.isArray(entityVal) && entityVal[0] !== "fn" ? entityVal : null;
52072
52458
  if (resolvedItems && resolvedItems.length > 0 && !finalProps.fields && !finalProps.columns) {
52073
52459
  const sample = resolvedItems[0];
52074
- if (sample && typeof sample === "object" && !Array.isArray(sample) && !React106__default.isValidElement(sample) && !(sample instanceof Date)) {
52460
+ if (sample && typeof sample === "object" && !Array.isArray(sample) && !React107__default.isValidElement(sample) && !(sample instanceof Date)) {
52075
52461
  const keys = Object.keys(sample).filter((k) => k !== "id" && k !== "_id");
52076
52462
  finalProps.fields = keys.map((k, i) => ({ name: k, variant: i === 0 ? "h4" : "body" }));
52077
52463
  }
@@ -53067,6 +53453,525 @@ function useUserForEvaluation() {
53067
53453
  const { user, isLoggedIn } = useUser();
53068
53454
  return isLoggedIn && user ? user : void 0;
53069
53455
  }
53456
+ var EntitySchemaContext = createContext(null);
53457
+ function EntitySchemaProvider({
53458
+ entities,
53459
+ traitLinkedEntities,
53460
+ orbitalsByTrait,
53461
+ children
53462
+ }) {
53463
+ const entitiesMap = useMemo(() => {
53464
+ const map = /* @__PURE__ */ new Map();
53465
+ for (const entity of entities) {
53466
+ map.set(entity.name, entity);
53467
+ }
53468
+ return map;
53469
+ }, [entities]);
53470
+ const linkedMap = useMemo(() => {
53471
+ return traitLinkedEntities ?? /* @__PURE__ */ new Map();
53472
+ }, [traitLinkedEntities]);
53473
+ const orbitalsMap = useMemo(() => {
53474
+ return orbitalsByTrait ?? /* @__PURE__ */ new Map();
53475
+ }, [orbitalsByTrait]);
53476
+ const contextValue = useMemo(
53477
+ () => ({
53478
+ entities: entitiesMap,
53479
+ traitLinkedEntities: linkedMap,
53480
+ orbitalsByTrait: orbitalsMap
53481
+ }),
53482
+ [entitiesMap, linkedMap, orbitalsMap]
53483
+ );
53484
+ return /* @__PURE__ */ jsx(EntitySchemaContext.Provider, { value: contextValue, children });
53485
+ }
53486
+ function useEntitySchema() {
53487
+ const context = useContext(EntitySchemaContext);
53488
+ if (!context) {
53489
+ throw new Error("useEntitySchema must be used within an EntitySchemaProvider");
53490
+ }
53491
+ return context;
53492
+ }
53493
+ function useEntitySchemaOptional3() {
53494
+ return useContext(EntitySchemaContext);
53495
+ }
53496
+ var log11 = createLogger("almadar:ui:navigation");
53497
+ function matchPath2(pattern, path) {
53498
+ const normalizeSegment = (p2) => {
53499
+ let normalized = p2.trim();
53500
+ if (!normalized.startsWith("/")) normalized = "/" + normalized;
53501
+ if (normalized.length > 1 && normalized.endsWith("/")) {
53502
+ normalized = normalized.slice(0, -1);
53503
+ }
53504
+ return normalized;
53505
+ };
53506
+ const normalizedPattern = normalizeSegment(pattern);
53507
+ const normalizedPath = normalizeSegment(path);
53508
+ const patternParts = normalizedPattern.split("/").filter(Boolean);
53509
+ const pathParts = normalizedPath.split("/").filter(Boolean);
53510
+ if (patternParts.length !== pathParts.length) {
53511
+ return null;
53512
+ }
53513
+ const params = {};
53514
+ for (let i = 0; i < patternParts.length; i++) {
53515
+ const patternPart = patternParts[i];
53516
+ const pathPart = pathParts[i];
53517
+ if (patternPart.startsWith(":")) {
53518
+ const paramName = patternPart.slice(1);
53519
+ params[paramName] = decodeURIComponent(pathPart);
53520
+ } else if (patternPart !== pathPart) {
53521
+ return null;
53522
+ }
53523
+ }
53524
+ return params;
53525
+ }
53526
+ function extractRouteParams2(pattern, path) {
53527
+ return matchPath2(pattern, path) || {};
53528
+ }
53529
+ function pathMatches2(pattern, path) {
53530
+ return matchPath2(pattern, path) !== null;
53531
+ }
53532
+ function isInlineOrbital(orbital) {
53533
+ return "name" in orbital && typeof orbital.name === "string";
53534
+ }
53535
+ function isInlinePage(page) {
53536
+ return typeof page === "object" && page !== null && "name" in page && typeof page.name === "string";
53537
+ }
53538
+ function findPageByPath2(schema, path) {
53539
+ if (!schema.orbitals) return null;
53540
+ for (const orbital of schema.orbitals) {
53541
+ if (!isInlineOrbital(orbital)) continue;
53542
+ if (!orbital.pages) continue;
53543
+ for (const pageRef of orbital.pages) {
53544
+ if (!isInlinePage(pageRef)) continue;
53545
+ const page = pageRef;
53546
+ const pagePath = page.path;
53547
+ if (!pagePath) continue;
53548
+ const params = matchPath2(pagePath, path);
53549
+ if (params !== null) {
53550
+ return { page, params, orbitalName: orbital.name };
53551
+ }
53552
+ }
53553
+ }
53554
+ return null;
53555
+ }
53556
+ function findPageByName2(schema, pageName) {
53557
+ if (!schema.orbitals) return null;
53558
+ for (const orbital of schema.orbitals) {
53559
+ if (!isInlineOrbital(orbital)) continue;
53560
+ if (!orbital.pages) continue;
53561
+ for (const pageRef of orbital.pages) {
53562
+ if (!isInlinePage(pageRef)) continue;
53563
+ const page = pageRef;
53564
+ if (page.name === pageName) {
53565
+ return { page, orbitalName: orbital.name };
53566
+ }
53567
+ }
53568
+ }
53569
+ return null;
53570
+ }
53571
+ function getDefaultPage2(schema) {
53572
+ if (!schema.orbitals) return null;
53573
+ for (const orbital of schema.orbitals) {
53574
+ if (!isInlineOrbital(orbital)) continue;
53575
+ if (!orbital.pages) continue;
53576
+ for (const pageRef of orbital.pages) {
53577
+ if (isInlinePage(pageRef)) {
53578
+ return { page: pageRef, orbitalName: orbital.name };
53579
+ }
53580
+ }
53581
+ }
53582
+ return null;
53583
+ }
53584
+ function getAllPages2(schema) {
53585
+ const pages = [];
53586
+ if (!schema.orbitals) return pages;
53587
+ for (const orbital of schema.orbitals) {
53588
+ if (!isInlineOrbital(orbital)) continue;
53589
+ if (!orbital.pages) continue;
53590
+ for (const pageRef of orbital.pages) {
53591
+ if (isInlinePage(pageRef)) {
53592
+ pages.push({ page: pageRef, orbitalName: orbital.name });
53593
+ }
53594
+ }
53595
+ }
53596
+ return pages;
53597
+ }
53598
+ var NavigationContext = createContext(null);
53599
+ function NavigationProvider2({
53600
+ schema,
53601
+ initialPage,
53602
+ updateUrl = true,
53603
+ onNavigate,
53604
+ children
53605
+ }) {
53606
+ const initialState = useMemo(() => {
53607
+ let page = null;
53608
+ let path = "/";
53609
+ if (initialPage) {
53610
+ const found = findPageByName2(schema, initialPage);
53611
+ if (found) {
53612
+ page = found.page;
53613
+ path = page.path || "/";
53614
+ }
53615
+ }
53616
+ if (!page) {
53617
+ const defaultPage = getDefaultPage2(schema);
53618
+ if (defaultPage) {
53619
+ page = defaultPage.page;
53620
+ path = page.path || "/";
53621
+ }
53622
+ }
53623
+ return {
53624
+ activePage: page?.name || "",
53625
+ currentPath: path,
53626
+ initPayload: {},
53627
+ navigationId: 0
53628
+ };
53629
+ }, [schema, initialPage]);
53630
+ const [state, setState] = useState(initialState);
53631
+ const navigateTo = useCallback((path, payload) => {
53632
+ const result = findPageByPath2(schema, path);
53633
+ if (!result) {
53634
+ log11.error("No page found for path", { path });
53635
+ return;
53636
+ }
53637
+ const { page, params } = result;
53638
+ const finalPayload = { ...params, ...payload };
53639
+ log11.debug("Navigating to", () => ({
53640
+ path,
53641
+ page: page.name,
53642
+ params,
53643
+ payload: JSON.stringify(payload),
53644
+ finalPayload: JSON.stringify(finalPayload)
53645
+ }));
53646
+ setState((prev) => ({
53647
+ activePage: page.name,
53648
+ currentPath: path,
53649
+ initPayload: finalPayload,
53650
+ navigationId: prev.navigationId + 1
53651
+ }));
53652
+ if (updateUrl && typeof window !== "undefined") {
53653
+ try {
53654
+ window.history.pushState(finalPayload, "", path);
53655
+ } catch (e) {
53656
+ log11.warn("Could not update URL", { error: e instanceof Error ? e : String(e) });
53657
+ }
53658
+ }
53659
+ if (onNavigate) {
53660
+ onNavigate(page.name, path, finalPayload);
53661
+ }
53662
+ }, [schema, updateUrl, onNavigate]);
53663
+ const navigateToPage = useCallback((pageName, payload) => {
53664
+ const result = findPageByName2(schema, pageName);
53665
+ if (!result) {
53666
+ log11.error("No page found with name", { pageName });
53667
+ return;
53668
+ }
53669
+ const { page } = result;
53670
+ const path = page.path || `/${pageName.toLowerCase()}`;
53671
+ log11.debug("Navigating to page", () => ({
53672
+ pageName,
53673
+ path,
53674
+ payload: JSON.stringify(payload)
53675
+ }));
53676
+ setState((prev) => ({
53677
+ activePage: page.name,
53678
+ currentPath: path,
53679
+ initPayload: payload || {},
53680
+ navigationId: prev.navigationId + 1
53681
+ }));
53682
+ if (updateUrl && typeof window !== "undefined") {
53683
+ try {
53684
+ window.history.pushState(payload || {}, "", path);
53685
+ } catch (e) {
53686
+ log11.warn("Could not update URL", { error: e instanceof Error ? e : String(e) });
53687
+ }
53688
+ }
53689
+ if (onNavigate) {
53690
+ onNavigate(page.name, path, payload || {});
53691
+ }
53692
+ }, [schema, updateUrl, onNavigate]);
53693
+ const contextValue = useMemo(() => ({
53694
+ state,
53695
+ navigateTo,
53696
+ navigateToPage,
53697
+ schema,
53698
+ isReady: !!state.activePage
53699
+ }), [state, navigateTo, navigateToPage, schema]);
53700
+ return /* @__PURE__ */ jsx(NavigationContext.Provider, { value: contextValue, children });
53701
+ }
53702
+ function useNavigation2() {
53703
+ return useContext(NavigationContext);
53704
+ }
53705
+ function useNavigateTo2() {
53706
+ const context = useContext(NavigationContext);
53707
+ const noOp = useCallback((path, _payload) => {
53708
+ log11.warn("navigateTo called outside NavigationProvider", { path });
53709
+ }, []);
53710
+ return context?.navigateTo || noOp;
53711
+ }
53712
+ function useNavigationState2() {
53713
+ const context = useContext(NavigationContext);
53714
+ return context?.state || null;
53715
+ }
53716
+ function useInitPayload2() {
53717
+ const context = useContext(NavigationContext);
53718
+ return context?.state.initPayload || {};
53719
+ }
53720
+ function useActivePage2() {
53721
+ const context = useContext(NavigationContext);
53722
+ return context?.state.activePage || null;
53723
+ }
53724
+ function useNavigationId2() {
53725
+ const context = useContext(NavigationContext);
53726
+ return context?.state.navigationId || 0;
53727
+ }
53728
+
53729
+ // providers/ServerBridge.tsx
53730
+ init_useEventBus();
53731
+ var xOrbitalLog = createLogger("almadar:runtime:cross-orbital");
53732
+ var serverBridgeLog = createLogger("almadar:ui:server-bridge");
53733
+ function createHttpTransport(serverUrl) {
53734
+ return {
53735
+ register: async (schema) => {
53736
+ try {
53737
+ const res = await fetch(`${serverUrl}/register`, {
53738
+ method: "POST",
53739
+ headers: { "Content-Type": "application/json" },
53740
+ body: JSON.stringify({ schema })
53741
+ });
53742
+ const result = await res.json();
53743
+ return !!result.success;
53744
+ } catch (err) {
53745
+ if (err instanceof TypeError) {
53746
+ serverBridgeLog.warn("Registration failed", { error: err.message });
53747
+ } else {
53748
+ serverBridgeLog.error("Registration failed", { error: err instanceof Error ? err : String(err) });
53749
+ }
53750
+ return false;
53751
+ }
53752
+ },
53753
+ unregister: async () => {
53754
+ try {
53755
+ await fetch(`${serverUrl}/unregister`, { method: "DELETE" });
53756
+ } catch {
53757
+ }
53758
+ },
53759
+ sendEvent: async (orbitalName, event, payload) => {
53760
+ const res = await fetch(`${serverUrl}/${orbitalName}/events`, {
53761
+ method: "POST",
53762
+ headers: { "Content-Type": "application/json" },
53763
+ body: JSON.stringify({ event, payload })
53764
+ });
53765
+ return res.json();
53766
+ }
53767
+ };
53768
+ }
53769
+ var ServerBridgeContext = createContext(null);
53770
+ function useServerBridge() {
53771
+ const ctx = useContext(ServerBridgeContext);
53772
+ if (!ctx) {
53773
+ const emptyMeta = { success: false, clientEffects: 0, dataEntities: {}, emittedEvents: [] };
53774
+ return { connected: false, sendEvent: async () => ({ effects: [], meta: emptyMeta }) };
53775
+ }
53776
+ return ctx;
53777
+ }
53778
+ function ServerBridgeProvider({
53779
+ schema,
53780
+ serverUrl,
53781
+ transport: customTransport,
53782
+ children
53783
+ }) {
53784
+ if (!serverUrl && !customTransport) {
53785
+ throw new Error("ServerBridgeProvider requires either serverUrl or transport");
53786
+ }
53787
+ if (serverUrl && customTransport) {
53788
+ throw new Error("ServerBridgeProvider accepts serverUrl OR transport, not both");
53789
+ }
53790
+ const eventBus = useEventBus();
53791
+ const [connected, setConnected] = useState(false);
53792
+ const transport = useMemo(
53793
+ () => customTransport ?? createHttpTransport(serverUrl),
53794
+ [serverUrl, customTransport]
53795
+ );
53796
+ const registerSchema = useCallback(
53797
+ async () => transport.register(schema),
53798
+ [schema, transport]
53799
+ );
53800
+ const unregisterSchema = useCallback(
53801
+ async () => transport.unregister(),
53802
+ [transport]
53803
+ );
53804
+ const sendEvent = useCallback(async (orbitalName, event, payload) => {
53805
+ const emptyMeta = { success: false, clientEffects: 0, dataEntities: {}, emittedEvents: [] };
53806
+ if (!connected) return { effects: [], meta: emptyMeta };
53807
+ try {
53808
+ const result = await transport.sendEvent(orbitalName, event, payload);
53809
+ const effects = [];
53810
+ const responseData = result.data || {};
53811
+ const dataEntities = {};
53812
+ for (const [entityName, records] of Object.entries(responseData)) {
53813
+ dataEntities[entityName] = Array.isArray(records) ? records.length : 0;
53814
+ }
53815
+ const meta = {
53816
+ success: !!result.success,
53817
+ clientEffects: result.clientEffects?.length ?? 0,
53818
+ dataEntities,
53819
+ data: responseData,
53820
+ emittedEvents: result.emittedEvents?.map((e) => e.event) ?? [],
53821
+ error: result.error
53822
+ };
53823
+ if (result.success) {
53824
+ const tagged = result.clientEffectsByTrait;
53825
+ const tuples = tagged ? tagged.map((entry) => ({ effect: entry.effect, traitName: entry.traitName })) : (result.clientEffects ?? []).map((eff) => ({ effect: eff }));
53826
+ for (const { effect, traitName } of tuples) {
53827
+ const effectType = effect[0];
53828
+ if (effectType === "render-ui") {
53829
+ const slot = effect[1];
53830
+ const pattern = effect[2];
53831
+ effects.push({
53832
+ type: "render-ui",
53833
+ slot,
53834
+ pattern: pattern !== null && typeof pattern === "object" ? pattern : void 0,
53835
+ traitName
53836
+ });
53837
+ } else if (effectType === "navigate") {
53838
+ const route = effect[1];
53839
+ const rawParams = effect[2];
53840
+ effects.push({
53841
+ type: "navigate",
53842
+ route,
53843
+ params: rawParams !== null && rawParams !== void 0 && typeof rawParams === "object" && !Array.isArray(rawParams) ? rawParams : void 0,
53844
+ traitName
53845
+ });
53846
+ } else if (effectType === "notify") {
53847
+ const message = effect[1];
53848
+ effects.push({ type: "notify", message: typeof message === "string" ? message : void 0, traitName });
53849
+ }
53850
+ }
53851
+ if (result.emittedEvents) {
53852
+ for (const emitted of result.emittedEvents) {
53853
+ const evTrait = emitted.source?.trait;
53854
+ if (!evTrait) {
53855
+ xOrbitalLog.warn("emit:dropped-no-source", {
53856
+ event: emitted.event,
53857
+ dispatchOrbital: orbitalName
53858
+ });
53859
+ continue;
53860
+ }
53861
+ const key = emitted.source?.orbital ? `UI:${emitted.source.orbital}.${evTrait}.${emitted.event}` : `UI:${evTrait}.${emitted.event}`;
53862
+ xOrbitalLog.info("emit:rebroadcast", {
53863
+ busKey: key,
53864
+ sourceOrbital: emitted.source?.orbital,
53865
+ sourceTrait: evTrait,
53866
+ dispatchOrbital: orbitalName
53867
+ });
53868
+ eventBus.emit(key, emitted.payload);
53869
+ }
53870
+ }
53871
+ } else if (result.error) {
53872
+ xOrbitalLog.warn("response:fail", {
53873
+ orbital: orbitalName,
53874
+ event,
53875
+ error: result.error
53876
+ });
53877
+ }
53878
+ return { effects, meta };
53879
+ } catch (err) {
53880
+ const msg = err instanceof Error ? err.message : String(err);
53881
+ if (err instanceof TypeError) {
53882
+ xOrbitalLog.warn("response:network", {
53883
+ orbital: orbitalName,
53884
+ event,
53885
+ error: msg,
53886
+ reason: "peer endpoint unreachable (expected in standalone single-orbital mode)"
53887
+ });
53888
+ } else {
53889
+ xOrbitalLog.error("response:network", {
53890
+ orbital: orbitalName,
53891
+ event,
53892
+ error: msg
53893
+ });
53894
+ }
53895
+ return { effects: [], meta: { ...emptyMeta, error: msg } };
53896
+ }
53897
+ }, [connected, transport, eventBus]);
53898
+ useEffect(() => {
53899
+ if (!schema) return;
53900
+ let cancelled = false;
53901
+ registerSchema().then((ok) => {
53902
+ if (!cancelled && ok) setConnected(true);
53903
+ });
53904
+ return () => {
53905
+ cancelled = true;
53906
+ setConnected(false);
53907
+ unregisterSchema();
53908
+ };
53909
+ }, [schema, registerSchema, unregisterSchema]);
53910
+ return /* @__PURE__ */ jsx(ServerBridgeContext.Provider, { value: { connected, sendEvent }, children });
53911
+ }
53912
+ var log12 = createLogger("almadar:ui:trait-provider");
53913
+ var TraitContext = createContext(null);
53914
+ function TraitProvider({
53915
+ traits: traitBindings,
53916
+ children
53917
+ }) {
53918
+ const traitInstances = useMemo(() => {
53919
+ const map = /* @__PURE__ */ new Map();
53920
+ for (const binding of traitBindings) {
53921
+ const trait = binding.trait;
53922
+ const initialState = trait.states.find((s) => s.isInitial);
53923
+ const stateName = initialState?.name || trait.states[0]?.name || "idle";
53924
+ const instance = {
53925
+ name: trait.name,
53926
+ currentState: stateName,
53927
+ availableEvents: trait.transitions.filter((t) => t.from === stateName).map((t) => t.event),
53928
+ dispatch: (eventKey, payload) => {
53929
+ log12.debug("Dispatch", () => ({
53930
+ trait: trait.name,
53931
+ event: eventKey,
53932
+ payloadKeys: payload ? Object.keys(payload) : []
53933
+ }));
53934
+ },
53935
+ canDispatch: (eventKey) => {
53936
+ return trait.transitions.some(
53937
+ (t) => t.from === stateName && t.event === eventKey
53938
+ );
53939
+ },
53940
+ trait
53941
+ };
53942
+ map.set(trait.name, instance);
53943
+ }
53944
+ return map;
53945
+ }, [traitBindings]);
53946
+ const contextValue = useMemo(() => {
53947
+ return {
53948
+ traits: traitInstances,
53949
+ getTrait: (name) => traitInstances.get(name),
53950
+ dispatchToTrait: (traitName, eventKey, payload) => {
53951
+ const instance = traitInstances.get(traitName);
53952
+ if (instance) {
53953
+ instance.dispatch(eventKey, payload);
53954
+ }
53955
+ },
53956
+ canDispatch: (traitName, eventKey) => {
53957
+ const instance = traitInstances.get(traitName);
53958
+ return instance?.canDispatch(eventKey) || false;
53959
+ }
53960
+ };
53961
+ }, [traitInstances]);
53962
+ return /* @__PURE__ */ jsx(TraitContext.Provider, { value: contextValue, children });
53963
+ }
53964
+ function useTraitContext() {
53965
+ const context = useContext(TraitContext);
53966
+ if (!context) {
53967
+ throw new Error("useTraitContext must be used within a TraitProvider");
53968
+ }
53969
+ return context;
53970
+ }
53971
+ function useTrait(traitName) {
53972
+ const context = useTraitContext();
53973
+ return context.getTrait(traitName);
53974
+ }
53070
53975
  var TraitScopeContext = createContext(null);
53071
53976
  function TraitScopeProvider3({
53072
53977
  orbital,
@@ -53112,4 +54017,4 @@ function useOptionalOfflineMode() {
53112
54017
  return useContext(OfflineModeContext);
53113
54018
  }
53114
54019
 
53115
- export { ANONYMOUS_USER, CurrentPagePathContext, CurrentPagePathProvider, EventBusContext2 as EventBusContext, EventBusProvider, OfflineModeProvider, OrbitalProvider, OrbitalThemeProvider, SelectionContext, SelectionProvider, TraitScopeProvider3 as TraitScopeProvider, UserContext, UserProvider, VerificationProvider, useCurrentPagePath2 as useCurrentPagePath, useHasPermission, useHasRole, useOfflineMode, useOptionalOfflineMode, useSelection, useSelectionOptional, useTraitScope2 as useTraitScope, useUser, useUserForEvaluation };
54020
+ export { ANONYMOUS_USER, CurrentPagePathContext, CurrentPagePathProvider, EntitySchemaProvider, EventBusContext2 as EventBusContext, EventBusProvider, NavigationProvider2 as NavigationProvider, OfflineModeProvider, OrbitalProvider, OrbitalThemeProvider, SelectionContext, SelectionProvider, ServerBridgeProvider, TraitContext, TraitProvider, TraitScopeProvider3 as TraitScopeProvider, UserContext, UserProvider, VerificationProvider, extractRouteParams2 as extractRouteParams, findPageByName2 as findPageByName, findPageByPath2 as findPageByPath, getAllPages2 as getAllPages, getDefaultPage2 as getDefaultPage, matchPath2 as matchPath, pathMatches2 as pathMatches, useActivePage2 as useActivePage, useCurrentPagePath2 as useCurrentPagePath, useEntitySchema, useEntitySchemaOptional3 as useEntitySchemaOptional, useHasPermission, useHasRole, useInitPayload2 as useInitPayload, useNavigateTo2 as useNavigateTo, useNavigation2 as useNavigation, useNavigationId2 as useNavigationId, useNavigationState2 as useNavigationState, useOfflineMode, useOptionalOfflineMode, useSelection, useSelectionOptional, useServerBridge, useTrait, useTraitContext, useTraitScope2 as useTraitScope, useUser, useUserForEvaluation };