@almadar/ui 4.44.1 → 4.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
1
  import * as React136 from 'react';
2
2
  import React136__default, { createContext, useContext, useMemo, useRef, useEffect, useCallback, Suspense, useState, useLayoutEffect, lazy, useId } from 'react';
3
+ import { createLogger, isLogLevelEnabled } from '@almadar/logger';
3
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
5
  import { EventBusContext, useTraitScope, TraitScopeProvider } from '@almadar/ui/providers';
5
- import { createLogger } from '@almadar/logger';
6
6
  import { clsx } from 'clsx';
7
7
  import { twMerge } from 'tailwind-merge';
8
8
  import * as LucideIcons from 'lucide-react';
@@ -90,10 +90,11 @@ function useTheme() {
90
90
  }
91
91
  return context;
92
92
  }
93
- var BUILT_IN_THEMES, ThemeContext, THEME_STORAGE_KEY, MODE_STORAGE_KEY, ThemeProvider;
93
+ var log, BUILT_IN_THEMES, ThemeContext, THEME_STORAGE_KEY, MODE_STORAGE_KEY, ThemeProvider;
94
94
  var init_ThemeContext = __esm({
95
95
  "context/ThemeContext.tsx"() {
96
96
  "use client";
97
+ log = createLogger("almadar:ui:theme");
97
98
  BUILT_IN_THEMES = [
98
99
  {
99
100
  name: "wireframe",
@@ -273,9 +274,10 @@ var init_ThemeContext = __esm({
273
274
  localStorage.setItem(THEME_STORAGE_KEY, newTheme);
274
275
  }
275
276
  } else {
276
- console.warn(
277
- `Theme "${newTheme}" not found. Available: ${availableThemes.map((t) => t.name).join(", ")}`
278
- );
277
+ log.warn("Theme not found", {
278
+ theme: newTheme,
279
+ available: availableThemes.map((t) => t.name)
280
+ });
279
281
  }
280
282
  },
281
283
  [availableThemes]
@@ -400,11 +402,11 @@ function useEmitEvent() {
400
402
  [eventBus]
401
403
  );
402
404
  }
403
- var log, subLog, scopeLog, fallbackListeners, fallbackAnyListeners, fallbackEventBus, useEventSubscription, useEventBus_default;
405
+ var log2, subLog, scopeLog, fallbackListeners, fallbackAnyListeners, fallbackEventBus, useEventSubscription, useEventBus_default;
404
406
  var init_useEventBus = __esm({
405
407
  "hooks/useEventBus.ts"() {
406
408
  "use client";
407
- log = createLogger("almadar:eventbus");
409
+ log2 = createLogger("almadar:eventbus");
408
410
  subLog = createLogger("almadar:eventbus:subscribe");
409
411
  scopeLog = createLogger("almadar:ui:trait-scope");
410
412
  fallbackListeners = /* @__PURE__ */ new Map();
@@ -418,13 +420,13 @@ var init_useEventBus = __esm({
418
420
  source
419
421
  };
420
422
  const handlers = fallbackListeners.get(type);
421
- log.debug("emit", { type, payloadKeys: payload ? Object.keys(payload).length : 0, listenerCount: (handlers?.size ?? 0) + fallbackAnyListeners.size });
423
+ log2.debug("emit", { type, payloadKeys: payload ? Object.keys(payload).length : 0, listenerCount: (handlers?.size ?? 0) + fallbackAnyListeners.size });
422
424
  if (handlers) {
423
425
  handlers.forEach((handler) => {
424
426
  try {
425
427
  handler(event);
426
428
  } catch (error) {
427
- console.error(`[EventBus] Error in listener for '${type}':`, error);
429
+ log2.error("Error in listener", { type, error: error instanceof Error ? error : String(error) });
428
430
  }
429
431
  });
430
432
  }
@@ -432,7 +434,7 @@ var init_useEventBus = __esm({
432
434
  try {
433
435
  handler(event);
434
436
  } catch (error) {
435
- console.error(`[EventBus] Error in onAny listener for '${type}':`, error);
437
+ log2.error("Error in onAny listener", { type, error: error instanceof Error ? error : String(error) });
436
438
  }
437
439
  });
438
440
  },
@@ -6009,12 +6011,15 @@ function ControlButton({
6009
6011
  sizeMap3[size] ?? sizeMap3.md,
6010
6012
  shapeMap[shape] ?? shapeMap.circle,
6011
6013
  variantMap[variant] ?? variantMap.secondary,
6012
- actualPressed && "scale-95 brightness-110 border-white",
6014
+ actualPressed && "scale-95 brightness-110 border-foreground",
6013
6015
  disabled && "opacity-50 cursor-not-allowed",
6014
6016
  className
6015
6017
  ),
6016
6018
  children: [
6017
- icon && /* @__PURE__ */ jsx("span", { className: "text-2xl", children: icon }),
6019
+ icon && /* @__PURE__ */ jsx("span", { className: "text-2xl", children: typeof icon === "string" ? (() => {
6020
+ const I = resolveIcon(icon);
6021
+ return I ? /* @__PURE__ */ jsx(I, { className: "w-6 h-6" }) : null;
6022
+ })() : icon }),
6018
6023
  label && !icon && /* @__PURE__ */ jsx("span", { children: label })
6019
6024
  ]
6020
6025
  }
@@ -6026,6 +6031,7 @@ var init_ControlButton = __esm({
6026
6031
  "use client";
6027
6032
  init_cn();
6028
6033
  init_useEventBus();
6034
+ init_Icon();
6029
6035
  sizeMap3 = {
6030
6036
  sm: "w-10 h-10 text-sm",
6031
6037
  md: "w-14 h-14 text-base",
@@ -6038,9 +6044,9 @@ var init_ControlButton = __esm({
6038
6044
  square: "rounded-md"
6039
6045
  };
6040
6046
  variantMap = {
6041
- primary: "bg-blue-600 text-[var(--color-foreground)] border-blue-400 hover:bg-blue-500",
6042
- secondary: "bg-[var(--color-surface,#374151)] text-[var(--color-foreground)] border-gray-500 hover:bg-gray-600",
6043
- ghost: "bg-transparent text-[var(--color-foreground)] border-white/30 hover:bg-white/10"
6047
+ primary: "bg-primary text-primary-foreground border-primary hover:bg-primary-hover",
6048
+ secondary: "bg-secondary text-secondary-foreground border-border hover:bg-secondary-hover",
6049
+ ghost: "bg-transparent text-foreground border-border hover:bg-muted"
6044
6050
  };
6045
6051
  ControlButton.displayName = "ControlButton";
6046
6052
  }
@@ -6768,8 +6774,8 @@ function ChoiceButton({
6768
6774
  className: cn(
6769
6775
  "w-full text-left px-4 py-2.5 rounded-md border transition-all duration-150",
6770
6776
  "flex items-center gap-2",
6771
- selected ? "bg-yellow-500/20 border-yellow-400 text-yellow-300" : "bg-white/5 border-white/10 text-[var(--color-foreground)] hover:bg-white/10 hover:border-white/30",
6772
- disabled && "opacity-40 cursor-not-allowed hover:bg-white/5 hover:border-white/10",
6777
+ selected ? "bg-accent/15 border-accent text-foreground" : "bg-muted/40 border-border text-foreground hover:bg-muted hover:border-border",
6778
+ disabled && "opacity-40 cursor-not-allowed hover:bg-muted/40 hover:border-border",
6773
6779
  className
6774
6780
  ),
6775
6781
  children: [
@@ -6778,7 +6784,7 @@ function ChoiceButton({
6778
6784
  {
6779
6785
  className: cn(
6780
6786
  "flex-shrink-0 font-mono font-bold text-sm",
6781
- selected ? "text-yellow-400" : "text-gray-500"
6787
+ selected ? "text-accent" : "text-muted-foreground"
6782
6788
  ),
6783
6789
  children: [
6784
6790
  index,
@@ -6819,7 +6825,7 @@ function ActionButton({
6819
6825
  disabled: isDisabled,
6820
6826
  onClick,
6821
6827
  className: cn(
6822
- "relative inline-flex items-center gap-1.5 rounded-md border font-medium text-[var(--color-foreground)] overflow-hidden transition-colors duration-150",
6828
+ "relative inline-flex items-center gap-1.5 rounded-md border font-medium overflow-hidden transition-colors duration-150",
6823
6829
  sizes.button,
6824
6830
  variantStyles8[variant],
6825
6831
  isDisabled && "opacity-60 cursor-not-allowed",
@@ -6829,7 +6835,7 @@ function ActionButton({
6829
6835
  onCooldown && /* @__PURE__ */ jsx(
6830
6836
  "div",
6831
6837
  {
6832
- className: "absolute inset-0 bg-black/60 pointer-events-none",
6838
+ className: "absolute inset-0 bg-foreground/40 pointer-events-none",
6833
6839
  style: {
6834
6840
  clipPath: `conic-gradient(from 0deg, transparent ${360 - cooldownDeg}deg, black ${360 - cooldownDeg}deg)`,
6835
6841
  WebkitClipPath: `conic-gradient(from 0deg, transparent ${360 - cooldownDeg}deg, black ${360 - cooldownDeg}deg)`,
@@ -6837,13 +6843,16 @@ function ActionButton({
6837
6843
  }
6838
6844
  }
6839
6845
  ),
6840
- icon && /* @__PURE__ */ jsx("span", { className: cn("flex-shrink-0", sizes.icon), children: icon }),
6846
+ icon && /* @__PURE__ */ jsx("span", { className: cn("flex-shrink-0", sizes.icon), children: typeof icon === "string" ? (() => {
6847
+ const I = resolveIcon(icon);
6848
+ return I ? /* @__PURE__ */ jsx(I, { className: "w-4 h-4" }) : null;
6849
+ })() : icon }),
6841
6850
  /* @__PURE__ */ jsx("span", { className: "relative z-10", children: label }),
6842
6851
  hotkey && /* @__PURE__ */ jsx(
6843
6852
  "span",
6844
6853
  {
6845
6854
  className: cn(
6846
- "absolute top-0.5 right-0.5 bg-black/50 text-gray-300 rounded font-mono leading-tight",
6855
+ "absolute top-0.5 right-0.5 bg-foreground/30 text-primary-foreground rounded font-mono leading-tight",
6847
6856
  sizes.hotkey
6848
6857
  ),
6849
6858
  children: hotkey
@@ -6857,15 +6866,16 @@ var sizeMap13, variantStyles8;
6857
6866
  var init_ActionButton = __esm({
6858
6867
  "components/atoms/game/ActionButton.tsx"() {
6859
6868
  init_cn();
6869
+ init_Icon();
6860
6870
  sizeMap13 = {
6861
6871
  sm: { button: "px-3 py-1.5 text-xs", hotkey: "text-[9px] px-1", icon: "text-xs" },
6862
6872
  md: { button: "px-4 py-2 text-sm", hotkey: "text-[10px] px-1.5", icon: "text-sm" },
6863
6873
  lg: { button: "px-5 py-2.5 text-base", hotkey: "text-xs px-2", icon: "text-base" }
6864
6874
  };
6865
6875
  variantStyles8 = {
6866
- primary: "bg-blue-600 hover:bg-blue-500 border-blue-400/40",
6867
- secondary: "bg-gray-700 hover:bg-gray-600 border-gray-500/40",
6868
- danger: "bg-red-700 hover:bg-red-600 border-red-400/40"
6876
+ primary: "bg-primary text-primary-foreground hover:bg-primary-hover border-primary",
6877
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary-hover border-border",
6878
+ danger: "bg-error text-error-foreground hover:bg-error/90 border-error"
6869
6879
  };
6870
6880
  ActionButton.displayName = "ActionButton";
6871
6881
  }
@@ -7338,8 +7348,6 @@ var init_Skeleton = __esm({
7338
7348
  Skeleton.displayName = "Skeleton";
7339
7349
  }
7340
7350
  });
7341
-
7342
- // renderer/client-effect-executor.ts
7343
7351
  function executeClientEffects(effects, config) {
7344
7352
  if (!effects || effects.length === 0) {
7345
7353
  return;
@@ -7348,11 +7356,10 @@ function executeClientEffects(effects, config) {
7348
7356
  try {
7349
7357
  executeEffect(effect, config);
7350
7358
  } catch (error) {
7351
- console.error(
7352
- `[ClientEffectExecutor] Error executing effect:`,
7353
- effect,
7354
- error
7355
- );
7359
+ log4.error("Error executing effect", () => ({
7360
+ effect: JSON.stringify(effect),
7361
+ error: error instanceof Error ? error : String(error)
7362
+ }));
7356
7363
  }
7357
7364
  }
7358
7365
  config.onComplete?.();
@@ -7381,7 +7388,7 @@ function executeEffect(effect, config) {
7381
7388
  break;
7382
7389
  }
7383
7390
  default:
7384
- console.warn(`[ClientEffectExecutor] Unknown effect type: ${effectType}`);
7391
+ log4.warn("Unknown effect type", { effectType: String(effectType) });
7385
7392
  }
7386
7393
  }
7387
7394
  function executeRenderUI(slot, patternConfig, config) {
@@ -7396,8 +7403,10 @@ function executeNotify(message, options, config) {
7396
7403
  function executeEmit(event, payload, config) {
7397
7404
  config.eventBus.emit(event, payload);
7398
7405
  }
7406
+ var log4;
7399
7407
  var init_client_effect_executor = __esm({
7400
7408
  "renderer/client-effect-executor.ts"() {
7409
+ log4 = createLogger("almadar:ui:effects:client");
7401
7410
  }
7402
7411
  });
7403
7412
 
@@ -7558,11 +7567,12 @@ function useOfflineExecutor(options) {
7558
7567
  clearQueue
7559
7568
  };
7560
7569
  }
7561
- var effectIdCounter, OfflineExecutor;
7570
+ var log5, effectIdCounter, OfflineExecutor;
7562
7571
  var init_offline_executor = __esm({
7563
7572
  "renderer/offline-executor.ts"() {
7564
7573
  "use client";
7565
7574
  init_client_effect_executor();
7575
+ log5 = createLogger("almadar:ui:effects:offline");
7566
7576
  effectIdCounter = 0;
7567
7577
  OfflineExecutor = class {
7568
7578
  constructor(config) {
@@ -7616,7 +7626,7 @@ var init_offline_executor = __esm({
7616
7626
  this.state.syncQueue = JSON.parse(stored);
7617
7627
  }
7618
7628
  } catch (error) {
7619
- console.warn("[OfflineExecutor] Failed to load sync queue:", error);
7629
+ log5.warn("Failed to load sync queue", { error: error instanceof Error ? error : String(error) });
7620
7630
  }
7621
7631
  }
7622
7632
  /**
@@ -7627,7 +7637,7 @@ var init_offline_executor = __esm({
7627
7637
  try {
7628
7638
  this.storage.setItem("orbital-offline-queue", JSON.stringify(this.state.syncQueue));
7629
7639
  } catch (error) {
7630
- console.warn("[OfflineExecutor] Failed to save sync queue:", error);
7640
+ log5.warn("Failed to save sync queue", { error: error instanceof Error ? error : String(error) });
7631
7641
  }
7632
7642
  }
7633
7643
  /**
@@ -7697,7 +7707,7 @@ var init_offline_executor = __esm({
7697
7707
  this.queueForSync(type, { args, event, payload });
7698
7708
  break;
7699
7709
  default:
7700
- console.warn(`[OfflineExecutor] Unknown effect type: ${type}`);
7710
+ log5.warn("Unknown effect type", { type });
7701
7711
  }
7702
7712
  }
7703
7713
  }
@@ -10272,7 +10282,7 @@ function recordTransition(trace) {
10272
10282
  ...trace,
10273
10283
  id: `t-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`
10274
10284
  };
10275
- log2.debug("transition:recorded", { trait: trace.traitName, from: trace.from, to: trace.to, event: trace.event, effectCount: trace.effects.length });
10285
+ log6.debug("transition:recorded", { trait: trace.traitName, from: trace.from, to: trace.to, event: trace.event, effectCount: trace.effects.length });
10276
10286
  getState().transitions.push(entry);
10277
10287
  if (getState().transitions.length > MAX_TRANSITIONS) {
10278
10288
  getState().transitions.shift();
@@ -10341,7 +10351,7 @@ function getTraitSnapshots() {
10341
10351
  try {
10342
10352
  snapshots.push(getter());
10343
10353
  } catch (err) {
10344
- log2.error("traitSnapshot getter failed", { trait: traitName, err: String(err) });
10354
+ log6.error("traitSnapshot getter failed", { trait: traitName, err: String(err) });
10345
10355
  }
10346
10356
  }
10347
10357
  return snapshots;
@@ -10389,12 +10399,12 @@ function waitForTransition(event, timeoutMs = 1e4) {
10389
10399
  }
10390
10400
  function bindEventBus(eventBus) {
10391
10401
  if (typeof window === "undefined") return;
10392
- log2.info("bindEventBus", { hasOnAny: !!eventBus.onAny });
10402
+ log6.info("bindEventBus", { hasOnAny: !!eventBus.onAny });
10393
10403
  exposeOnWindow();
10394
10404
  if (window.__orbitalVerification) {
10395
10405
  window.__orbitalVerification.sendEvent = (event, payload, traitScope) => {
10396
10406
  const prefixed = event.startsWith("UI:") ? event : traitScope ? `UI:${traitScope}.${event}` : `UI:${event}`;
10397
- log2.debug("sendEvent", { event: prefixed, traitScope, payloadKeys: payload ? Object.keys(payload) : [] });
10407
+ log6.debug("sendEvent", { event: prefixed, traitScope, payloadKeys: payload ? Object.keys(payload) : [] });
10398
10408
  eventBus.emit(prefixed, payload);
10399
10409
  };
10400
10410
  const eventLog = [];
@@ -10443,10 +10453,10 @@ function updateAssetStatus(url, status) {
10443
10453
  window.__orbitalVerification.assetStatus[url] = status;
10444
10454
  }
10445
10455
  }
10446
- var log2, MAX_TRANSITIONS;
10456
+ var log6, MAX_TRANSITIONS;
10447
10457
  var init_verificationRegistry = __esm({
10448
10458
  "lib/verificationRegistry.ts"() {
10449
- log2 = createLogger("almadar:bridge");
10459
+ log6 = createLogger("almadar:bridge");
10450
10460
  MAX_TRANSITIONS = 500;
10451
10461
  exposeOnWindow();
10452
10462
  }
@@ -12474,7 +12484,7 @@ var init_avl_elk_layout = __esm({
12474
12484
  elk = new ELK();
12475
12485
  }
12476
12486
  });
12477
- var SWIM_GUTTER, CENTER_W, BehaviorView;
12487
+ var log7, SWIM_GUTTER, CENTER_W, BehaviorView;
12478
12488
  var init_BehaviorView = __esm({
12479
12489
  "components/molecules/avl/BehaviorView.tsx"() {
12480
12490
  "use client";
@@ -12483,6 +12493,7 @@ var init_BehaviorView = __esm({
12483
12493
  init_AvlSwimLane();
12484
12494
  init_types();
12485
12495
  init_avl_elk_layout();
12496
+ log7 = createLogger("almadar:ui:avl:behavior-view");
12486
12497
  SWIM_GUTTER = 120;
12487
12498
  CENTER_W = 360;
12488
12499
  BehaviorView = ({ data }) => {
@@ -12492,7 +12503,7 @@ var init_BehaviorView = __esm({
12492
12503
  const dataKey = useMemo(() => JSON.stringify(traitData), [traitData]);
12493
12504
  useEffect(() => {
12494
12505
  if (!traitData) return;
12495
- computeTraitLayout(traitData).then(setLayout).catch(console.error);
12506
+ computeTraitLayout(traitData).then(setLayout).catch((err) => log7.error("compute-trait-layout-failed", { error: err instanceof Error ? err : String(err) }));
12496
12507
  }, [dataKey]);
12497
12508
  if (!traitData) {
12498
12509
  return /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-[var(--color-border)] bg-[var(--color-card)] p-4 text-center text-[var(--color-muted-foreground)] text-sm", children: "No trait data" });
@@ -12837,7 +12848,7 @@ function computeFoldRegions(code) {
12837
12848
  }
12838
12849
  return regions.sort((a, b) => a.start - b.start);
12839
12850
  }
12840
- var orbStyleOverrides, orbStyle, loloStyleOverrides, loloStyle, LINE_PROPS_FN, HIDDEN_LINE_NUMBERS, CodeBlock;
12851
+ var orbStyleOverrides, orbStyle, loloStyleOverrides, loloStyle, log8, LINE_PROPS_FN, HIDDEN_LINE_NUMBERS, CodeBlock;
12841
12852
  var init_CodeBlock = __esm({
12842
12853
  "components/molecules/markdown/CodeBlock.tsx"() {
12843
12854
  init_Box();
@@ -12914,6 +12925,7 @@ var init_CodeBlock = __esm({
12914
12925
  "lolo-op-async": { color: ORB_COLORS.dark.async }
12915
12926
  };
12916
12927
  loloStyle = { ...dark, ...loloStyleOverrides };
12928
+ log8 = createLogger("almadar:ui:markdown-code");
12917
12929
  LINE_PROPS_FN = (n) => ({ "data-line": String(n - 1) });
12918
12930
  HIDDEN_LINE_NUMBERS = { display: "none" };
12919
12931
  CodeBlock = React136__default.memo(
@@ -13112,7 +13124,7 @@ var init_CodeBlock = __esm({
13112
13124
  eventBus.emit("UI:COPY_CODE", { language, success: true });
13113
13125
  setTimeout(() => setCopied(false), 2e3);
13114
13126
  } catch (err) {
13115
- console.error("Failed to copy code:", err);
13127
+ log8.error("Failed to copy code", { error: err instanceof Error ? err : String(err) });
13116
13128
  eventBus.emit("UI:COPY_CODE", { language, success: false });
13117
13129
  }
13118
13130
  };
@@ -16674,13 +16686,14 @@ function useSafeEventBus2() {
16674
16686
  } };
16675
16687
  }
16676
16688
  }
16677
- var ButtonGroup;
16689
+ var log9, ButtonGroup;
16678
16690
  var init_ButtonGroup = __esm({
16679
16691
  "components/molecules/ButtonGroup.tsx"() {
16680
16692
  "use client";
16681
16693
  init_cn();
16682
16694
  init_atoms();
16683
16695
  init_useEventBus();
16696
+ log9 = createLogger("almadar:ui:button-group");
16684
16697
  ButtonGroup = ({
16685
16698
  children,
16686
16699
  primary,
@@ -16753,7 +16766,7 @@ var init_ButtonGroup = __esm({
16753
16766
  {
16754
16767
  variant: "ghost",
16755
16768
  onClick: () => {
16756
- console.log(`Filter clicked: ${filter.field}`);
16769
+ log9.debug("Filter clicked", { field: filter.field });
16757
16770
  },
16758
16771
  children: filter.label
16759
16772
  },
@@ -21514,7 +21527,7 @@ function DataGrid({
21514
21527
  onClick: handleActionClick(action, itemData),
21515
21528
  "data-testid": `action-${action.event}`,
21516
21529
  "data-row-id": String(itemData.id),
21517
- className: "text-error hover:bg-error/10 px-2",
21530
+ className: "text-error hover:text-error hover:bg-error/10 px-2",
21518
21531
  children: [
21519
21532
  action.icon && /* @__PURE__ */ jsx(Icon, { name: action.icon, size: "xs" }),
21520
21533
  action.label
@@ -22770,31 +22783,56 @@ var init_InputGroup = __esm({
22770
22783
  InputGroup.displayName = "InputGroup";
22771
22784
  }
22772
22785
  });
22773
-
22774
- // lib/debug.ts
22786
+ function gateEnabled(level, ns = NAMESPACE) {
22787
+ return isLogLevelEnabled(level, ns);
22788
+ }
22775
22789
  function isDebugEnabled() {
22776
- if (DEBUG_ENABLED) return true;
22777
- return typeof window !== "undefined" && window.__ALMADAR_DEBUG_VERIFY__ === true;
22790
+ return gateEnabled("DEBUG");
22778
22791
  }
22779
22792
  function debug(...args) {
22780
- if (isDebugEnabled()) {
22781
- console.log("[DEBUG]", ...args);
22793
+ if (!gateEnabled("DEBUG")) return;
22794
+ const [first, ...rest] = args;
22795
+ const message = typeof first === "string" ? first : "<debug>";
22796
+ if (rest.length === 0 && typeof first === "string") {
22797
+ log10.debug(message);
22798
+ } else {
22799
+ log10.debug(message, { args: rest.length > 0 ? formatArgs(rest) : formatArgs([first]) });
22782
22800
  }
22783
22801
  }
22784
22802
  function debugGroup(label) {
22785
- if (isDebugEnabled()) {
22786
- console.group(`[DEBUG] ${label}`);
22787
- }
22803
+ if (gateEnabled("DEBUG")) console.group(`[${NAMESPACE}] ${label}`);
22788
22804
  }
22789
22805
  function debugGroupEnd() {
22790
- if (isDebugEnabled()) {
22791
- console.groupEnd();
22806
+ if (gateEnabled("DEBUG")) console.groupEnd();
22807
+ }
22808
+ function formatArgs(values) {
22809
+ if (values.length === 1) return toLogMetaValue(values[0]);
22810
+ return values.map(toLogMetaValue);
22811
+ }
22812
+ function toLogMetaValue(v) {
22813
+ if (v === null || v === void 0) return v;
22814
+ if (v instanceof Error) return v;
22815
+ const t = typeof v;
22816
+ if (t === "string" || t === "number" || t === "boolean") return v;
22817
+ if (Array.isArray(v)) return v.map(toLogMetaValue);
22818
+ if (t === "object") {
22819
+ const out = {};
22820
+ for (const [k, val] of Object.entries(v)) {
22821
+ out[k] = toLogMetaValue(val);
22822
+ }
22823
+ return out;
22792
22824
  }
22825
+ return String(v);
22793
22826
  }
22794
- var DEBUG_ENABLED;
22827
+ var NAMESPACE, log10;
22795
22828
  var init_debug = __esm({
22796
22829
  "lib/debug.ts"() {
22797
- DEBUG_ENABLED = typeof window !== "undefined" && (localStorage.getItem("debug") === "true" || process.env.NODE_ENV === "development");
22830
+ NAMESPACE = "almadar:ui:debug";
22831
+ log10 = createLogger(NAMESPACE);
22832
+ createLogger("almadar:ui:debug:input");
22833
+ createLogger("almadar:ui:debug:collision");
22834
+ createLogger("almadar:ui:debug:physics");
22835
+ createLogger("almadar:ui:debug:game-state");
22798
22836
  }
22799
22837
  });
22800
22838
  var isRelationsDebugEnabled, RelationSelect;
@@ -24082,7 +24120,7 @@ function StatBadge({
24082
24120
  const I = resolveIcon(icon);
24083
24121
  return I ? /* @__PURE__ */ jsx(I, { className: "w-4 h-4" }) : icon;
24084
24122
  })() : icon }),
24085
- /* @__PURE__ */ jsx("span", { className: "text-gray-400 font-medium", children: label }),
24123
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground font-medium", children: label }),
24086
24124
  format === "hearts" && max && /* @__PURE__ */ jsx(
24087
24125
  HealthBar,
24088
24126
  {
@@ -24109,7 +24147,7 @@ function StatBadge({
24109
24147
  animated: true
24110
24148
  }
24111
24149
  ),
24112
- format === "text" && /* @__PURE__ */ jsx("span", { className: "font-bold text-[var(--color-foreground)]", children: value })
24150
+ format === "text" && /* @__PURE__ */ jsx("span", { className: "font-bold text-foreground", children: value })
24113
24151
  ]
24114
24152
  }
24115
24153
  );
@@ -24127,11 +24165,11 @@ var init_StatBadge = __esm({
24127
24165
  lg: "text-base px-4 py-2"
24128
24166
  };
24129
24167
  variantMap2 = {
24130
- default: "bg-[var(--color-card)]/80 border-gray-700",
24131
- primary: "bg-blue-900/80 border-blue-700",
24132
- success: "bg-green-900/80 border-green-700",
24133
- warning: "bg-yellow-900/80 border-yellow-700",
24134
- danger: "bg-red-900/80 border-red-700"
24168
+ default: "bg-card/80 border-border text-foreground",
24169
+ primary: "bg-primary/15 border-primary/40 text-foreground",
24170
+ success: "bg-success/15 border-success/40 text-foreground",
24171
+ warning: "bg-warning/15 border-warning/40 text-foreground",
24172
+ danger: "bg-error/15 border-error/40 text-foreground"
24135
24173
  };
24136
24174
  StatBadge.displayName = "StatBadge";
24137
24175
  }
@@ -36704,9 +36742,45 @@ var init_List = __esm({
36704
36742
  List3.displayName = "List";
36705
36743
  }
36706
36744
  });
36707
- var DefaultEmptyDetail, MasterDetail;
36745
+ function MasterDetail({
36746
+ entity,
36747
+ masterFields,
36748
+ detailFields: _detailFields,
36749
+ // Captured but not used here - detail handled separately
36750
+ loading: externalLoading,
36751
+ isLoading: externalIsLoading,
36752
+ error: externalError,
36753
+ className,
36754
+ ...rest
36755
+ }) {
36756
+ const loading = externalLoading ?? false;
36757
+ const isLoading = externalIsLoading ?? false;
36758
+ const error = externalError ?? null;
36759
+ return /* @__PURE__ */ jsx(
36760
+ DataTable,
36761
+ {
36762
+ fields: masterFields,
36763
+ columns: masterFields,
36764
+ entity,
36765
+ isLoading: loading || isLoading,
36766
+ error,
36767
+ className,
36768
+ emptyTitle: "No items found",
36769
+ emptyDescription: "Create your first item to get started.",
36770
+ ...rest
36771
+ }
36772
+ );
36773
+ }
36708
36774
  var init_MasterDetail = __esm({
36709
- "components/organisms/layout/MasterDetail.tsx"() {
36775
+ "components/organisms/MasterDetail.tsx"() {
36776
+ "use client";
36777
+ init_DataTable();
36778
+ MasterDetail.displayName = "MasterDetail";
36779
+ }
36780
+ });
36781
+ var DefaultEmptyDetail, MasterDetailLayout;
36782
+ var init_MasterDetailLayout = __esm({
36783
+ "components/organisms/layout/MasterDetailLayout.tsx"() {
36710
36784
  init_cn();
36711
36785
  init_Typography();
36712
36786
  DefaultEmptyDetail = () => /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center h-full border-2 border-dashed border-border", children: /* @__PURE__ */ jsx(
@@ -36717,7 +36791,7 @@ var init_MasterDetail = __esm({
36717
36791
  children: "Select an item to view details"
36718
36792
  }
36719
36793
  ) });
36720
- MasterDetail = ({
36794
+ MasterDetailLayout = ({
36721
36795
  master,
36722
36796
  detail,
36723
36797
  emptyDetail,
@@ -36752,7 +36826,7 @@ var init_MasterDetail = __esm({
36752
36826
  }
36753
36827
  );
36754
36828
  };
36755
- MasterDetail.displayName = "MasterDetail";
36829
+ MasterDetailLayout.displayName = "MasterDetailLayout";
36756
36830
  }
36757
36831
  });
36758
36832
  var COLUMN_CLASSES, ASPECT_CLASSES, MediaGallery;
@@ -39151,7 +39225,7 @@ function getAllEvents(traits2) {
39151
39225
  }
39152
39226
  function EventDispatcherTab({ traits: traits2, schema }) {
39153
39227
  const eventBus = useEventBus();
39154
- const [log4, setLog] = React136.useState([]);
39228
+ const [log12, setLog] = React136.useState([]);
39155
39229
  const prevStatesRef = React136.useRef(/* @__PURE__ */ new Map());
39156
39230
  React136.useEffect(() => {
39157
39231
  for (const trait of traits2) {
@@ -39215,9 +39289,9 @@ function EventDispatcherTab({ traits: traits2, schema }) {
39215
39289
  /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "medium", className: "text-gray-500 mb-1", children: "Other Events (not available from current state)" }),
39216
39290
  /* @__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)) })
39217
39291
  ] }),
39218
- log4.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
39292
+ log12.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
39219
39293
  /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "medium", className: "text-gray-500 mb-1", children: "Recent Transitions" }),
39220
- /* @__PURE__ */ jsx(Stack, { gap: "xs", children: log4.map((entry, i) => /* @__PURE__ */ jsxs(Typography, { variant: "small", className: "font-mono text-xs", children: [
39294
+ /* @__PURE__ */ jsx(Stack, { gap: "xs", children: log12.map((entry, i) => /* @__PURE__ */ jsxs(Typography, { variant: "small", className: "font-mono text-xs", children: [
39221
39295
  /* @__PURE__ */ jsx("span", { className: "text-purple-400", children: entry.traitName }),
39222
39296
  " ",
39223
39297
  /* @__PURE__ */ jsx("span", { className: "text-gray-500", children: entry.from }),
@@ -43488,6 +43562,7 @@ var init_component_registry_generated = __esm({
43488
43562
  init_LoadingState();
43489
43563
  init_MarkdownContent();
43490
43564
  init_MasterDetail();
43565
+ init_MasterDetailLayout();
43491
43566
  init_MatrixQuestion();
43492
43567
  init_MediaGallery();
43493
43568
  init_Meter();
@@ -43782,6 +43857,7 @@ var init_component_registry_generated = __esm({
43782
43857
  "MapViewPattern": MapViewPattern,
43783
43858
  "MarkdownContent": MarkdownContent,
43784
43859
  "MasterDetail": MasterDetail,
43860
+ "MasterDetailLayout": MasterDetailLayout,
43785
43861
  "MatrixQuestion": MatrixQuestion,
43786
43862
  "MediaGallery": MediaGallery,
43787
43863
  "Menu": MenuPattern,
@@ -44790,24 +44866,24 @@ function captureSubscriberTag(listener) {
44790
44866
  }
44791
44867
  return "unknown";
44792
44868
  }
44793
- function EventBusProvider({ children, debug: debug2 = false }) {
44869
+ function EventBusProvider({ children }) {
44794
44870
  const listenersRef = useRef(/* @__PURE__ */ new Map());
44795
44871
  const anyListenersRef = useRef(/* @__PURE__ */ new Set());
44796
44872
  const deprecationWarningShown = useRef(false);
44797
44873
  const getSelectedEntity = useCallback(() => {
44798
44874
  if (!deprecationWarningShown.current) {
44799
- console.warn(
44800
- "[EventBus] getSelectedEntity is deprecated. Use SelectionProvider and useSelection hook instead. See SelectionProvider.tsx for migration guide."
44801
- );
44875
+ busLog.warn("deprecated:getSelectedEntity", {
44876
+ migration: "Use SelectionProvider and useSelection hook instead. See SelectionProvider.tsx for migration guide."
44877
+ });
44802
44878
  deprecationWarningShown.current = true;
44803
44879
  }
44804
44880
  return null;
44805
44881
  }, []);
44806
44882
  const clearSelectedEntity = useCallback(() => {
44807
44883
  if (!deprecationWarningShown.current) {
44808
- console.warn(
44809
- "[EventBus] clearSelectedEntity is deprecated. Use SelectionProvider and useSelection hook instead. See SelectionProvider.tsx for migration guide."
44810
- );
44884
+ busLog.warn("deprecated:clearSelectedEntity", {
44885
+ migration: "Use SelectionProvider and useSelection hook instead. See SelectionProvider.tsx for migration guide."
44886
+ });
44811
44887
  deprecationWarningShown.current = true;
44812
44888
  }
44813
44889
  }, []);
@@ -44821,12 +44897,8 @@ function EventBusProvider({ children, debug: debug2 = false }) {
44821
44897
  const listeners6 = listenersRef.current.get(type);
44822
44898
  const listenerCount = (listeners6?.size ?? 0) + anyListenersRef.current.size;
44823
44899
  busLog.debug("emit", { type, payloadKeys: payload ? Object.keys(payload).length : 0, listenerCount });
44824
- if (debug2) {
44825
- if (listenerCount > 0) {
44826
- console.log(`[EventBus] Emit: ${type} \u2192 ${listenerCount} listener(s)`, payload);
44827
- } else {
44828
- console.warn(`[EventBus] Emit: ${type} (NO LISTENERS - event may be lost!)`, payload);
44829
- }
44900
+ if (listenerCount === 0) {
44901
+ busLog.warn("emit:no-listeners", { type });
44830
44902
  }
44831
44903
  if (listeners6) {
44832
44904
  const listenersCopy = Array.from(listeners6);
@@ -44841,7 +44913,7 @@ function EventBusProvider({ children, debug: debug2 = false }) {
44841
44913
  try {
44842
44914
  listener(event);
44843
44915
  } catch (error) {
44844
- console.error(`[EventBus] Error in listener for '${type}':`, error);
44916
+ busLog.error("listener-threw", { type, error: error instanceof Error ? error : String(error) });
44845
44917
  }
44846
44918
  }
44847
44919
  }
@@ -44857,10 +44929,10 @@ function EventBusProvider({ children, debug: debug2 = false }) {
44857
44929
  try {
44858
44930
  listener(event);
44859
44931
  } catch (error) {
44860
- console.error(`[EventBus] Error in onAny listener for '${type}':`, error);
44932
+ busLog.error("onAny-listener-threw", { type, error: error instanceof Error ? error : String(error) });
44861
44933
  }
44862
44934
  }
44863
- }, [debug2]);
44935
+ }, []);
44864
44936
  const on = useCallback((type, listener) => {
44865
44937
  if (!listenersRef.current.has(type)) {
44866
44938
  listenersRef.current.set(type, /* @__PURE__ */ new Set());
@@ -44869,19 +44941,14 @@ function EventBusProvider({ children, debug: debug2 = false }) {
44869
44941
  listeners6.add(listener);
44870
44942
  if (!listenerTags.has(listener)) listenerTags.set(listener, captureSubscriberTag(listener));
44871
44943
  subLog2.debug("subscribe", { type, totalListeners: listeners6.size, tag: listenerTags.get(listener) });
44872
- if (debug2) {
44873
- console.log(`[EventBus] Subscribed to '${type}', total: ${listeners6.size}`);
44874
- }
44875
44944
  return () => {
44876
44945
  listeners6.delete(listener);
44877
- if (debug2) {
44878
- console.log(`[EventBus] Unsubscribed from '${type}', remaining: ${listeners6.size}`);
44879
- }
44946
+ subLog2.debug("unsubscribe", { type, remaining: listeners6.size });
44880
44947
  if (listeners6.size === 0) {
44881
44948
  listenersRef.current.delete(type);
44882
44949
  }
44883
44950
  };
44884
- }, [debug2]);
44951
+ }, []);
44885
44952
  const once = useCallback((type, listener) => {
44886
44953
  const wrappedListener = (event) => {
44887
44954
  listenersRef.current.get(type)?.delete(wrappedListener);
@@ -44897,16 +44964,11 @@ function EventBusProvider({ children, debug: debug2 = false }) {
44897
44964
  anyListenersRef.current.add(listener);
44898
44965
  if (!listenerTags.has(listener)) listenerTags.set(listener, captureSubscriberTag(listener));
44899
44966
  subLog2.debug("subscribe:any", { totalAnyListeners: anyListenersRef.current.size, tag: listenerTags.get(listener) });
44900
- if (debug2) {
44901
- console.log(`[EventBus] onAny subscribed, total: ${anyListenersRef.current.size}`);
44902
- }
44903
44967
  return () => {
44904
44968
  anyListenersRef.current.delete(listener);
44905
- if (debug2) {
44906
- console.log(`[EventBus] onAny unsubscribed, remaining: ${anyListenersRef.current.size}`);
44907
- }
44969
+ subLog2.debug("unsubscribe:any", { remaining: anyListenersRef.current.size });
44908
44970
  };
44909
- }, [debug2]);
44971
+ }, []);
44910
44972
  const contextValue = useMemo(
44911
44973
  () => ({
44912
44974
  emit,
@@ -44930,6 +44992,7 @@ function EventBusProvider({ children, debug: debug2 = false }) {
44930
44992
 
44931
44993
  // providers/SelectionProvider.tsx
44932
44994
  init_useEventBus();
44995
+ var log3 = createLogger("almadar:ui:selection");
44933
44996
  var SelectionContext = createContext(null);
44934
44997
  var defaultCompareEntities = (a, b) => {
44935
44998
  if (a === b) return true;
@@ -44952,7 +45015,10 @@ function SelectionProvider({
44952
45015
  (entity) => {
44953
45016
  setSelectedState(entity);
44954
45017
  if (debug2) {
44955
- console.log("[SelectionProvider] Selection set:", entity);
45018
+ log3.debug("Selection set", () => ({
45019
+ hasEntity: entity !== null && entity !== void 0,
45020
+ entityId: entity && typeof entity === "object" ? String(entity.id ?? "") : ""
45021
+ }));
44956
45022
  }
44957
45023
  },
44958
45024
  [debug2]
@@ -44960,7 +45026,7 @@ function SelectionProvider({
44960
45026
  const clearSelection = useCallback(() => {
44961
45027
  setSelectedState(null);
44962
45028
  if (debug2) {
44963
- console.log("[SelectionProvider] Selection cleared");
45029
+ log3.debug("Selection cleared");
44964
45030
  }
44965
45031
  }, [debug2]);
44966
45032
  const isSelected = useCallback(
@@ -44975,14 +45041,17 @@ function SelectionProvider({
44975
45041
  if (row) {
44976
45042
  setSelected(row);
44977
45043
  if (debug2) {
44978
- console.log(`[SelectionProvider] ${event.type} received:`, row);
45044
+ log3.debug("event received", () => ({
45045
+ type: event.type,
45046
+ rowId: row && typeof row === "object" ? String(row.id ?? "") : ""
45047
+ }));
44979
45048
  }
44980
45049
  }
44981
45050
  };
44982
45051
  const handleDeselect = (event) => {
44983
45052
  clearSelection();
44984
45053
  if (debug2) {
44985
- console.log(`[SelectionProvider] ${event.type} received - clearing selection`);
45054
+ log3.debug("event received - clearing selection", { type: event.type });
44986
45055
  }
44987
45056
  };
44988
45057
  const unsubView = eventBus.on("UI:VIEW", handleSelect);
@@ -45024,7 +45093,7 @@ init_UISlotRenderer();
45024
45093
  // providers/VerificationProvider.tsx
45025
45094
  init_useEventBus();
45026
45095
  init_verificationRegistry();
45027
- var log3 = createLogger("almadar:verify");
45096
+ var log11 = createLogger("almadar:verify");
45028
45097
  var DISPATCH_SUFFIX = ":DISPATCH";
45029
45098
  var SUCCESS_SUFFIX = ":SUCCESS";
45030
45099
  var ERROR_SUFFIX = ":ERROR";
@@ -45070,7 +45139,7 @@ function VerificationProvider({
45070
45139
  const verificationProviderLifecycleListener = (evt) => {
45071
45140
  const parsed = parseLifecycleEvent(evt.type);
45072
45141
  if (!parsed) return;
45073
- log3.debug("lifecycle:event", { kind: parsed.kind, traitName: parsed.traitName, event: parsed.event, type: evt.type });
45142
+ log11.debug("lifecycle:event", { kind: parsed.kind, traitName: parsed.traitName, event: parsed.event, type: evt.type });
45074
45143
  const payload = evt.payload ?? {};
45075
45144
  if (parsed.kind === "dispatch") {
45076
45145
  const key = `${parsed.traitName}:${String(payload["event"] ?? "")}`;
@@ -45125,7 +45194,7 @@ function VerificationProvider({
45125
45194
  },
45126
45195
  timestamp: Date.now()
45127
45196
  });
45128
- log3.debug("transition:success", { trait: parsed.traitName, event: parsed.event, from: pending?.from, to: newState, effectCount: effects.length });
45197
+ log11.debug("transition:success", { trait: parsed.traitName, event: parsed.event, from: pending?.from, to: newState, effectCount: effects.length });
45129
45198
  } else if (parsed.kind === "error" && parsed.event) {
45130
45199
  const key = `${parsed.traitName}:${parsed.event}`;
45131
45200
  const pending = pendingRef.current.get(key);
@@ -45155,7 +45224,7 @@ function VerificationProvider({
45155
45224
  },
45156
45225
  timestamp: Date.now()
45157
45226
  });
45158
- log3.warn("transition:error", { trait: parsed.traitName, event: parsed.event, from: fromState, error: errorMsg });
45227
+ log11.warn("transition:error", { trait: parsed.traitName, event: parsed.event, from: fromState, error: errorMsg });
45159
45228
  }
45160
45229
  };
45161
45230
  Object.defineProperty(verificationProviderLifecycleListener, "name", {