@almadar/ui 2.42.0 → 2.45.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,5 +1,5 @@
1
1
  import * as React117 from 'react';
2
- import React117__default, { createContext, useCallback, useState, useRef, useEffect, useLayoutEffect, lazy, useContext, useMemo, Suspense, useSyncExternalStore, useId } from 'react';
2
+ import React117__default, { createContext, useCallback, useState, useRef, useEffect, useMemo, useLayoutEffect, lazy, useContext, Suspense, useSyncExternalStore, useId } from 'react';
3
3
  import { EventBusContext } from '@almadar/ui/providers';
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
5
  import '@tanstack/react-query';
@@ -201,13 +201,13 @@ function SelectionProvider({
201
201
  unsubCancel();
202
202
  };
203
203
  }, [eventBus, setSelected, clearSelection, debug2]);
204
- const contextValue = {
204
+ const contextValue2 = {
205
205
  selected,
206
206
  setSelected,
207
207
  clearSelection,
208
208
  isSelected
209
209
  };
210
- return /* @__PURE__ */ jsx(SelectionContext.Provider, { value: contextValue, children });
210
+ return /* @__PURE__ */ jsx(SelectionContext.Provider, { value: contextValue2, children });
211
211
  }
212
212
  createContext(null);
213
213
  var queryStores = /* @__PURE__ */ new Map();
@@ -236,27 +236,27 @@ function useQuerySingleton(query) {
236
236
  store2.listeners.delete(listener);
237
237
  };
238
238
  }, [store2]);
239
- const notifyListeners3 = useCallback(() => {
239
+ const notifyListeners4 = useCallback(() => {
240
240
  store2.listeners.forEach((listener) => listener());
241
241
  }, [store2]);
242
242
  const setSearch = useCallback((value) => {
243
243
  store2.search = value;
244
- notifyListeners3();
245
- }, [store2, notifyListeners3]);
244
+ notifyListeners4();
245
+ }, [store2, notifyListeners4]);
246
246
  const setFilter = useCallback((key, value) => {
247
247
  store2.filters = { ...store2.filters, [key]: value };
248
- notifyListeners3();
249
- }, [store2, notifyListeners3]);
248
+ notifyListeners4();
249
+ }, [store2, notifyListeners4]);
250
250
  const clearFilters = useCallback(() => {
251
251
  store2.filters = {};
252
252
  store2.search = "";
253
- notifyListeners3();
254
- }, [store2, notifyListeners3]);
253
+ notifyListeners4();
254
+ }, [store2, notifyListeners4]);
255
255
  const setSort = useCallback((field, direction) => {
256
256
  store2.sortField = field;
257
257
  store2.sortDirection = direction;
258
- notifyListeners3();
259
- }, [store2, notifyListeners3]);
258
+ notifyListeners4();
259
+ }, [store2, notifyListeners4]);
260
260
  return {
261
261
  search: store2.search,
262
262
  setSearch,
@@ -714,13 +714,13 @@ function EntitySchemaProvider({
714
714
  }
715
715
  return map;
716
716
  }, [entities]);
717
- const contextValue = useMemo(
717
+ const contextValue2 = useMemo(
718
718
  () => ({
719
719
  entities: entitiesMap
720
720
  }),
721
721
  [entitiesMap]
722
722
  );
723
- return /* @__PURE__ */ jsx(EntitySchemaContext.Provider, { value: contextValue, children });
723
+ return /* @__PURE__ */ jsx(EntitySchemaContext.Provider, { value: contextValue2, children });
724
724
  }
725
725
  function useEntitySchema() {
726
726
  const context = useContext(EntitySchemaContext);
@@ -733,6 +733,9 @@ function useEntityDefinition(entityName) {
733
733
  const { entities } = useEntitySchema();
734
734
  return entities.get(entityName);
735
735
  }
736
+ function useEntitySchemaOptional() {
737
+ return useContext(EntitySchemaContext);
738
+ }
736
739
 
737
740
  // lib/traitRegistry.ts
738
741
  var traits = /* @__PURE__ */ new Map();
@@ -1453,7 +1456,7 @@ function TraitProvider({
1453
1456
  }
1454
1457
  return map;
1455
1458
  }, [traitBindings]);
1456
- const contextValue = useMemo(() => {
1459
+ const contextValue2 = useMemo(() => {
1457
1460
  return {
1458
1461
  traits: traitInstances,
1459
1462
  getTrait: (name) => traitInstances.get(name),
@@ -1469,7 +1472,7 @@ function TraitProvider({
1469
1472
  }
1470
1473
  };
1471
1474
  }, [traitInstances]);
1472
- return /* @__PURE__ */ jsx(TraitContext.Provider, { value: contextValue, children });
1475
+ return /* @__PURE__ */ jsx(TraitContext.Provider, { value: contextValue2, children });
1473
1476
  }
1474
1477
  function useTraitContext() {
1475
1478
  const context = useContext(TraitContext);
@@ -2038,7 +2041,7 @@ var ThemeProvider = ({
2038
2041
  const newMode = resolvedMode === "dark" ? "light" : "dark";
2039
2042
  setMode(newMode);
2040
2043
  }, [resolvedMode, setMode]);
2041
- const contextValue = useMemo(
2044
+ const contextValue2 = useMemo(
2042
2045
  () => ({
2043
2046
  theme,
2044
2047
  mode,
@@ -2060,7 +2063,7 @@ var ThemeProvider = ({
2060
2063
  appliedTheme
2061
2064
  ]
2062
2065
  );
2063
- return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: contextValue, children });
2066
+ return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: contextValue2, children });
2064
2067
  };
2065
2068
  function useTheme() {
2066
2069
  const context = useContext(ThemeContext);
@@ -2084,25 +2087,92 @@ function useTheme() {
2084
2087
  var store = /* @__PURE__ */ new Map();
2085
2088
  var storeListeners = /* @__PURE__ */ new Set();
2086
2089
  var watchCallbacks = /* @__PURE__ */ new Map();
2087
- function advance(entityType, data) {
2088
- const prev = store.get(entityType);
2089
- const oldData = prev?.data ?? [];
2090
- store.set(entityType, { data, version: (prev?.version ?? 0) + 1 });
2090
+ function extractId(record) {
2091
+ const r = record;
2092
+ return String(r.id ?? r._id ?? r.key ?? "");
2093
+ }
2094
+ function materialize(snap) {
2095
+ return snap.ids.map((id) => snap.entities.get(id));
2096
+ }
2097
+ function notifyListeners3(entityType, prev) {
2091
2098
  for (const listener of storeListeners) {
2092
2099
  listener();
2093
2100
  }
2094
2101
  const cbs = watchCallbacks.get(entityType);
2095
2102
  if (cbs) {
2103
+ const oldData = prev ? materialize(prev) : [];
2104
+ const cur = store.get(entityType);
2105
+ const newData = cur ? materialize(cur) : [];
2096
2106
  for (const cb of cbs) {
2097
2107
  try {
2098
- cb(oldData, data);
2108
+ cb(oldData, newData);
2099
2109
  } catch {
2100
2110
  }
2101
2111
  }
2102
2112
  }
2103
2113
  }
2114
+ function setAll(entityType, records) {
2115
+ const entities = /* @__PURE__ */ new Map();
2116
+ const ids = [];
2117
+ for (const r of records) {
2118
+ const rec = r;
2119
+ const id = extractId(rec);
2120
+ if (id) {
2121
+ entities.set(id, rec);
2122
+ ids.push(id);
2123
+ }
2124
+ }
2125
+ const prev = store.get(entityType);
2126
+ store.set(entityType, { entities, ids, version: (prev?.version ?? 0) + 1 });
2127
+ notifyListeners3(entityType, prev);
2128
+ }
2129
+ function upsertOne(entityType, record) {
2130
+ const id = extractId(record);
2131
+ if (!id) return;
2132
+ const prev = store.get(entityType);
2133
+ const snapshot = prev ? { entities: new Map(prev.entities), ids: [...prev.ids], version: prev.version } : { entities: /* @__PURE__ */ new Map(), ids: [], version: 0 };
2134
+ snapshot.entities.set(id, record);
2135
+ if (!snapshot.ids.includes(id)) snapshot.ids.push(id);
2136
+ snapshot.version++;
2137
+ store.set(entityType, snapshot);
2138
+ notifyListeners3(entityType, prev);
2139
+ }
2140
+ function addOne(entityType, record) {
2141
+ upsertOne(entityType, record);
2142
+ }
2143
+ function updateOne(entityType, id, changes) {
2144
+ const prev = store.get(entityType);
2145
+ if (!prev?.entities.has(id)) return;
2146
+ const snapshot = {
2147
+ entities: new Map(prev.entities),
2148
+ ids: [...prev.ids],
2149
+ version: prev.version
2150
+ };
2151
+ snapshot.entities.set(id, { ...snapshot.entities.get(id), ...changes });
2152
+ snapshot.version++;
2153
+ store.set(entityType, snapshot);
2154
+ notifyListeners3(entityType, prev);
2155
+ }
2156
+ function removeOne(entityType, id) {
2157
+ const prev = store.get(entityType);
2158
+ if (!prev) return;
2159
+ const snapshot = {
2160
+ entities: new Map(prev.entities),
2161
+ ids: prev.ids.filter((i) => i !== id),
2162
+ version: prev.version
2163
+ };
2164
+ snapshot.entities.delete(id);
2165
+ snapshot.version++;
2166
+ store.set(entityType, snapshot);
2167
+ notifyListeners3(entityType, prev);
2168
+ }
2104
2169
  function getSnapshot3(entityType) {
2105
- return store.get(entityType)?.data ?? [];
2170
+ const snap = store.get(entityType);
2171
+ if (!snap) return [];
2172
+ return materialize(snap);
2173
+ }
2174
+ function getById(entityType, id) {
2175
+ return store.get(entityType)?.entities.get(id) ?? null;
2106
2176
  }
2107
2177
  function getVersion(entityType) {
2108
2178
  return store.get(entityType)?.version ?? 0;
@@ -2126,15 +2196,21 @@ function useEntityRef(entityType) {
2126
2196
  }, [entityType]);
2127
2197
  return useSyncExternalStore(subscribeToStore, getSnapshotStable, () => []);
2128
2198
  }
2129
- var EntityStoreContext = createContext({
2130
- advance,
2131
- getSnapshot: getSnapshot3
2132
- });
2199
+ var contextValue = {
2200
+ setAll,
2201
+ upsertOne,
2202
+ addOne,
2203
+ updateOne,
2204
+ removeOne,
2205
+ getSnapshot: getSnapshot3,
2206
+ getById
2207
+ };
2208
+ var EntityStoreContext = createContext(contextValue);
2133
2209
  function useEntityStore() {
2134
2210
  return useContext(EntityStoreContext);
2135
2211
  }
2136
2212
  function EntityStoreProvider({ children }) {
2137
- return /* @__PURE__ */ jsx(EntityStoreContext.Provider, { value: { advance, getSnapshot: getSnapshot3 }, children });
2213
+ return /* @__PURE__ */ jsx(EntityStoreContext.Provider, { value: contextValue, children });
2138
2214
  }
2139
2215
  var EventBusContext2 = createContext(null);
2140
2216
  function EventBusProvider({ children, debug: debug2 = false }) {
@@ -2234,7 +2310,7 @@ function EventBusProvider({ children, debug: debug2 = false }) {
2234
2310
  }
2235
2311
  };
2236
2312
  }, [debug2]);
2237
- const contextValue = useMemo(
2313
+ const contextValue2 = useMemo(
2238
2314
  () => ({
2239
2315
  emit,
2240
2316
  on,
@@ -2247,12 +2323,12 @@ function EventBusProvider({ children, debug: debug2 = false }) {
2247
2323
  [emit, on, once, hasListeners, onAny, getSelectedEntity, clearSelectedEntity]
2248
2324
  );
2249
2325
  useEffect(() => {
2250
- setGlobalEventBus(contextValue);
2326
+ setGlobalEventBus(contextValue2);
2251
2327
  return () => {
2252
2328
  setGlobalEventBus(null);
2253
2329
  };
2254
- }, [contextValue]);
2255
- return /* @__PURE__ */ jsx(EventBusContext2.Provider, { value: contextValue, children });
2330
+ }, [contextValue2]);
2331
+ return /* @__PURE__ */ jsx(EventBusContext2.Provider, { value: contextValue2, children });
2256
2332
  }
2257
2333
  var iconAliases = {
2258
2334
  "close": LucideIcons.X,
@@ -5461,9 +5537,9 @@ var shapeMap = {
5461
5537
  square: "rounded-md"
5462
5538
  };
5463
5539
  var variantMap = {
5464
- primary: "bg-blue-600 text-white border-blue-400 hover:bg-blue-500",
5465
- secondary: "bg-gray-700 text-white border-gray-500 hover:bg-gray-600",
5466
- ghost: "bg-transparent text-white border-white/30 hover:bg-white/10"
5540
+ primary: "bg-blue-600 text-[var(--color-foreground)] border-blue-400 hover:bg-blue-500",
5541
+ secondary: "bg-[var(--color-surface,#374151)] text-[var(--color-foreground)] border-gray-500 hover:bg-gray-600",
5542
+ ghost: "bg-transparent text-[var(--color-foreground)] border-white/30 hover:bg-white/10"
5467
5543
  };
5468
5544
  function ControlButton({
5469
5545
  label,
@@ -5692,11 +5768,11 @@ function TimerDisplay({
5692
5768
  {
5693
5769
  className: cn(
5694
5770
  "inline-flex items-center justify-center rounded-lg",
5695
- "bg-gray-800/80 border border-gray-600 font-mono font-bold tabular-nums",
5771
+ "bg-[var(--color-card)]/80 border border-gray-600 font-mono font-bold tabular-nums",
5696
5772
  sizeMap4[size],
5697
5773
  running && "border-green-500/50",
5698
5774
  isLow && "text-red-400 border-red-500/50 animate-pulse",
5699
- !isLow && "text-white",
5775
+ !isLow && "text-[var(--color-foreground)]",
5700
5776
  className
5701
5777
  ),
5702
5778
  children: formatTime(seconds, format)
@@ -5724,7 +5800,7 @@ function ResourceCounter({
5724
5800
  {
5725
5801
  className: cn(
5726
5802
  "inline-flex items-center rounded-md",
5727
- "bg-gray-800/80 border border-gray-600 font-medium text-white",
5803
+ "bg-[var(--color-card)]/80 border border-gray-600 font-medium text-[var(--color-foreground)]",
5728
5804
  sizes.wrapper,
5729
5805
  className
5730
5806
  ),
@@ -5783,9 +5859,9 @@ function ItemSlot({
5783
5859
  title: label,
5784
5860
  className: cn(
5785
5861
  "relative flex items-center justify-center rounded-lg border-2",
5786
- "bg-gray-800/80 transition-all duration-150",
5862
+ "bg-[var(--color-card)]/80 transition-all duration-150",
5787
5863
  sizeMap6[size],
5788
- empty ? "border-gray-700 bg-gray-900/50" : rarityBorderMap[rarity],
5864
+ empty ? "border-gray-700 bg-[var(--color-card)]/50" : rarityBorderMap[rarity],
5789
5865
  !empty && rarityGlowMap[rarity],
5790
5866
  selected && "ring-2 ring-white ring-offset-1 ring-offset-gray-900",
5791
5867
  isClickable && !empty && "hover:brightness-125 cursor-pointer",
@@ -5801,7 +5877,7 @@ function ItemSlot({
5801
5877
  className: cn(
5802
5878
  "absolute -bottom-1 -right-1 flex items-center justify-center",
5803
5879
  "min-w-[18px] h-[18px] rounded-full px-1",
5804
- "bg-gray-700 border border-gray-500 text-[10px] font-bold text-white"
5880
+ "bg-[var(--color-surface,#374151)] border border-gray-500 text-[10px] font-bold text-[var(--color-foreground)]"
5805
5881
  ),
5806
5882
  children: quantity
5807
5883
  }
@@ -5830,7 +5906,7 @@ function TurnIndicator({
5830
5906
  {
5831
5907
  className: cn(
5832
5908
  "inline-flex items-center rounded-lg",
5833
- "bg-gray-800/80 border border-gray-600 font-medium text-white",
5909
+ "bg-[var(--color-card)]/80 border border-gray-600 font-medium text-[var(--color-foreground)]",
5834
5910
  sizes.wrapper,
5835
5911
  className
5836
5912
  ),
@@ -5866,7 +5942,7 @@ function getComboIntensity(combo) {
5866
5942
  if (combo >= 10) return "text-red-400 animate-pulse";
5867
5943
  if (combo >= 7) return "text-orange-400";
5868
5944
  if (combo >= 4) return "text-yellow-400";
5869
- return "text-white";
5945
+ return "text-[var(--color-foreground)]";
5870
5946
  }
5871
5947
  function getComboScale(combo) {
5872
5948
  if (combo >= 10) return "scale-110";
@@ -5887,7 +5963,7 @@ function ComboCounter({
5887
5963
  {
5888
5964
  className: cn(
5889
5965
  "inline-flex flex-col items-center justify-center",
5890
- "rounded-xl bg-gray-800/80 border border-gray-600 px-3 py-1.5",
5966
+ "rounded-xl bg-[var(--color-card)]/80 border border-gray-600 px-3 py-1.5",
5891
5967
  "transition-transform duration-200",
5892
5968
  getComboScale(combo),
5893
5969
  className
@@ -6088,7 +6164,7 @@ function StatusEffect({
6088
6164
  "span",
6089
6165
  {
6090
6166
  className: cn(
6091
- "absolute flex items-center justify-center rounded-full bg-white text-black font-bold leading-none",
6167
+ "absolute flex items-center justify-center rounded-full bg-[var(--color-card)] text-[var(--color-foreground)] font-bold leading-none",
6092
6168
  sizes.badge
6093
6169
  ),
6094
6170
  children: stacks
@@ -6167,7 +6243,7 @@ function DialogueBubble({
6167
6243
  ) }),
6168
6244
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 min-w-0", children: [
6169
6245
  speaker && /* @__PURE__ */ jsx("span", { className: "text-sm font-bold text-yellow-400", children: speaker }),
6170
- /* @__PURE__ */ jsx("span", { className: "text-sm text-white leading-relaxed", children: text })
6246
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-[var(--color-foreground)] leading-relaxed", children: text })
6171
6247
  ] })
6172
6248
  ]
6173
6249
  }
@@ -6191,7 +6267,7 @@ function ChoiceButton({
6191
6267
  className: cn(
6192
6268
  "w-full text-left px-4 py-2.5 rounded-md border transition-all duration-150",
6193
6269
  "flex items-center gap-2",
6194
- selected ? "bg-yellow-500/20 border-yellow-400 text-yellow-300" : "bg-white/5 border-white/10 text-white hover:bg-white/10 hover:border-white/30",
6270
+ 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",
6195
6271
  disabled && "opacity-40 cursor-not-allowed hover:bg-white/5 hover:border-white/10",
6196
6272
  className
6197
6273
  ),
@@ -6247,7 +6323,7 @@ function ActionButton({
6247
6323
  disabled: isDisabled,
6248
6324
  onClick,
6249
6325
  className: cn(
6250
- "relative inline-flex items-center gap-1.5 rounded-md border font-medium text-white overflow-hidden transition-colors duration-150",
6326
+ "relative inline-flex items-center gap-1.5 rounded-md border font-medium text-[var(--color-foreground)] overflow-hidden transition-colors duration-150",
6251
6327
  sizes.button,
6252
6328
  variantStyles7[variant],
6253
6329
  isDisabled && "opacity-60 cursor-not-allowed",
@@ -8200,11 +8276,11 @@ var AuthLayout = ({
8200
8276
  children: [
8201
8277
  /* @__PURE__ */ jsx(Box, { className: "absolute inset-0 bg-gradient-to-br from-primary-600/90 to-primary-800/90" }),
8202
8278
  /* @__PURE__ */ jsx(Box, { className: "relative z-10", children: /* @__PURE__ */ jsxs(Link, { to: "/", className: "flex items-center gap-3", children: [
8203
- logo || /* @__PURE__ */ jsx(Box, { className: "w-10 h-10 bg-white/20 rounded-xl flex items-center justify-center backdrop-blur", children: /* @__PURE__ */ jsx(
8279
+ logo || /* @__PURE__ */ jsx(Box, { className: "w-10 h-10 bg-[var(--color-card)]/20 rounded-xl flex items-center justify-center backdrop-blur", children: /* @__PURE__ */ jsx(
8204
8280
  Typography,
8205
8281
  {
8206
8282
  variant: "body1",
8207
- className: "text-white font-bold text-lg",
8283
+ className: "text-[var(--color-foreground)] font-bold text-lg",
8208
8284
  children: appName.charAt(0).toUpperCase()
8209
8285
  }
8210
8286
  ) }),
@@ -8212,7 +8288,7 @@ var AuthLayout = ({
8212
8288
  Typography,
8213
8289
  {
8214
8290
  variant: "body1",
8215
- className: "text-2xl font-bold text-white",
8291
+ className: "text-2xl font-bold text-[var(--color-foreground)]",
8216
8292
  children: appName
8217
8293
  }
8218
8294
  )
@@ -8222,7 +8298,7 @@ var AuthLayout = ({
8222
8298
  Typography,
8223
8299
  {
8224
8300
  variant: "h1",
8225
- className: "text-4xl font-bold text-white leading-tight",
8301
+ className: "text-4xl font-bold text-[var(--color-foreground)] leading-tight",
8226
8302
  children: [
8227
8303
  "Welcome to ",
8228
8304
  appName
@@ -8233,27 +8309,27 @@ var AuthLayout = ({
8233
8309
  Typography,
8234
8310
  {
8235
8311
  variant: "body1",
8236
- className: "text-lg text-white/80 max-w-md",
8312
+ className: "text-lg text-[var(--color-foreground)]/80 max-w-md",
8237
8313
  children: "Sign in to access your dashboard and manage your account."
8238
8314
  }
8239
8315
  ),
8240
- /* @__PURE__ */ jsxs(Box, { className: "mt-12 p-6 bg-white/10 rounded-xl backdrop-blur", children: [
8316
+ /* @__PURE__ */ jsxs(Box, { className: "mt-12 p-6 bg-[var(--color-card)]/10 rounded-xl backdrop-blur", children: [
8241
8317
  /* @__PURE__ */ jsx(
8242
8318
  Typography,
8243
8319
  {
8244
8320
  variant: "body1",
8245
- className: "text-white/90 italic",
8321
+ className: "text-[var(--color-foreground)]/90 italic",
8246
8322
  children: '"This platform has transformed how we work. Highly recommended!"'
8247
8323
  }
8248
8324
  ),
8249
8325
  /* @__PURE__ */ jsxs(HStack, { className: "mt-4", gap: "sm", align: "center", children: [
8250
- /* @__PURE__ */ jsx(Box, { className: "w-10 h-10 bg-white/20 rounded-full" }),
8326
+ /* @__PURE__ */ jsx(Box, { className: "w-10 h-10 bg-[var(--color-card)]/20 rounded-full" }),
8251
8327
  /* @__PURE__ */ jsxs(VStack, { gap: "none", children: [
8252
8328
  /* @__PURE__ */ jsx(
8253
8329
  Typography,
8254
8330
  {
8255
8331
  variant: "body1",
8256
- className: "text-white font-medium",
8332
+ className: "text-[var(--color-foreground)] font-medium",
8257
8333
  children: "Jane Doe"
8258
8334
  }
8259
8335
  ),
@@ -8261,7 +8337,7 @@ var AuthLayout = ({
8261
8337
  Typography,
8262
8338
  {
8263
8339
  variant: "body1",
8264
- className: "text-white/60 text-sm",
8340
+ className: "text-[var(--color-foreground)]/60 text-sm",
8265
8341
  children: "CEO, Example Co."
8266
8342
  }
8267
8343
  )
@@ -8269,8 +8345,8 @@ var AuthLayout = ({
8269
8345
  ] })
8270
8346
  ] })
8271
8347
  ] }) }),
8272
- /* @__PURE__ */ jsx(Box, { className: "absolute -bottom-32 -right-32 w-96 h-96 bg-white/5 rounded-full" }),
8273
- /* @__PURE__ */ jsx(Box, { className: "absolute -top-16 -right-16 w-64 h-64 bg-white/5 rounded-full" })
8348
+ /* @__PURE__ */ jsx(Box, { className: "absolute -bottom-32 -right-32 w-96 h-96 bg-[var(--color-card)]/5 rounded-full" }),
8349
+ /* @__PURE__ */ jsx(Box, { className: "absolute -top-16 -right-16 w-64 h-64 bg-[var(--color-card)]/5 rounded-full" })
8274
8350
  ]
8275
8351
  }
8276
8352
  ),
@@ -8287,7 +8363,7 @@ var AuthLayout = ({
8287
8363
  Typography,
8288
8364
  {
8289
8365
  variant: "body1",
8290
- className: "text-white font-bold text-xl",
8366
+ className: "text-[var(--color-foreground)] font-bold text-xl",
8291
8367
  children: appName.charAt(0).toUpperCase()
8292
8368
  }
8293
8369
  ) }),
@@ -9158,7 +9234,7 @@ function IsometricCanvas({
9158
9234
  className: cn("relative w-full overflow-hidden rounded-lg", className),
9159
9235
  style: { height: viewportSize.height },
9160
9236
  "data-testid": "game-canvas-empty",
9161
- children: /* @__PURE__ */ jsx(Box, { className: "flex items-center justify-center h-full bg-slate-800 rounded-lg", children: /* @__PURE__ */ jsxs(Stack, { direction: "vertical", gap: "md", align: "center", children: [
9237
+ children: /* @__PURE__ */ jsx(Box, { className: "flex items-center justify-center h-full bg-[var(--color-card)] rounded-lg", children: /* @__PURE__ */ jsxs(Stack, { direction: "vertical", gap: "md", align: "center", children: [
9162
9238
  /* @__PURE__ */ jsx(Icon, { name: "map", size: "xl" }),
9163
9239
  /* @__PURE__ */ jsx(Typography, { variant: "body", className: "text-slate-400", children: t("canvas.emptyMessage") || "No map data loaded" })
9164
9240
  ] }) })
@@ -9743,7 +9819,7 @@ var MarkdownContent = React117__default.memo(
9743
9819
  "th",
9744
9820
  {
9745
9821
  ...props,
9746
- className: "border border-gray-300 dark:border-gray-600 bg-gray-100 dark:bg-gray-800 px-4 py-2 text-left font-semibold",
9822
+ className: "border border-gray-300 dark:border-gray-600 bg-[var(--color-muted)] px-4 py-2 text-left font-semibold",
9747
9823
  children
9748
9824
  }
9749
9825
  );
@@ -9824,6 +9900,42 @@ var orbStyleOverrides = {
9824
9900
  "orb-op-async": { color: ORB_COLORS.dark.async }
9825
9901
  };
9826
9902
  var orbStyle = { ...dark, ...orbStyleOverrides };
9903
+ function computeFoldRegions(code) {
9904
+ const lines = code.split("\n");
9905
+ const regions = [];
9906
+ const stack = [];
9907
+ for (let i = 0; i < lines.length; i++) {
9908
+ const line = lines[i];
9909
+ let inString = false;
9910
+ for (let j = 0; j < line.length; j++) {
9911
+ const ch = line[j];
9912
+ if (ch === "\\" && inString) {
9913
+ j++;
9914
+ continue;
9915
+ }
9916
+ if (ch === '"') {
9917
+ inString = !inString;
9918
+ continue;
9919
+ }
9920
+ if (inString) continue;
9921
+ if (ch === "{" || ch === "[") {
9922
+ stack.push({ line: i, bracket: ch });
9923
+ } else if (ch === "}" || ch === "]") {
9924
+ const open = stack.pop();
9925
+ if (open && open.line < i) {
9926
+ regions.push({
9927
+ start: open.line,
9928
+ end: i,
9929
+ closeBracket: ch
9930
+ });
9931
+ }
9932
+ }
9933
+ }
9934
+ }
9935
+ return regions.sort((a, b) => a.start - b.start);
9936
+ }
9937
+ var LINE_PROPS_FN = (n) => ({ "data-line": String(n - 1) });
9938
+ var HIDDEN_LINE_NUMBERS = { display: "none" };
9827
9939
  var CodeBlock = React117__default.memo(
9828
9940
  ({
9829
9941
  code: rawCode,
@@ -9831,6 +9943,7 @@ var CodeBlock = React117__default.memo(
9831
9943
  showCopyButton = true,
9832
9944
  showLanguageBadge = true,
9833
9945
  maxHeight = "60vh",
9946
+ foldable: foldableProp,
9834
9947
  className
9835
9948
  }) => {
9836
9949
  const code = typeof rawCode === "string" ? rawCode : String(rawCode ?? "");
@@ -9839,8 +9952,114 @@ var CodeBlock = React117__default.memo(
9839
9952
  const eventBus = useEventBus();
9840
9953
  const { t: _t } = useTranslate();
9841
9954
  const scrollRef = useRef(null);
9955
+ const codeRef = useRef(null);
9842
9956
  const savedScrollLeftRef = useRef(0);
9843
9957
  const [copied, setCopied] = useState(false);
9958
+ const isFoldable = foldableProp ?? (language === "orb" || language === "json");
9959
+ const [collapsed, setCollapsed] = useState(() => /* @__PURE__ */ new Set());
9960
+ const foldRegions = useMemo(
9961
+ () => isFoldable ? computeFoldRegions(code) : [],
9962
+ [code, isFoldable]
9963
+ );
9964
+ const foldStartMap = useMemo(() => {
9965
+ const m = /* @__PURE__ */ new Map();
9966
+ for (const r of foldRegions) m.set(r.start, r);
9967
+ return m;
9968
+ }, [foldRegions]);
9969
+ const hiddenLines = useMemo(() => {
9970
+ const h = /* @__PURE__ */ new Set();
9971
+ for (const r of foldRegions) {
9972
+ if (!collapsed.has(r.start)) continue;
9973
+ for (let i = r.start + 1; i <= r.end; i++) h.add(i);
9974
+ }
9975
+ return h;
9976
+ }, [foldRegions, collapsed]);
9977
+ const collapsedRef = useRef(collapsed);
9978
+ collapsedRef.current = collapsed;
9979
+ const foldStartMapRef = useRef(foldStartMap);
9980
+ foldStartMapRef.current = foldStartMap;
9981
+ const toggleFold = useCallback((lineNum) => {
9982
+ setCollapsed((prev) => {
9983
+ const next = new Set(prev);
9984
+ if (next.has(lineNum)) next.delete(lineNum);
9985
+ else next.add(lineNum);
9986
+ return next;
9987
+ });
9988
+ }, []);
9989
+ const toggleFoldRef = useRef(toggleFold);
9990
+ toggleFoldRef.current = toggleFold;
9991
+ useEffect(() => {
9992
+ setCollapsed(/* @__PURE__ */ new Set());
9993
+ }, [code]);
9994
+ const highlightedElement = useMemo(
9995
+ () => /* @__PURE__ */ jsx(
9996
+ SyntaxHighlighter,
9997
+ {
9998
+ PreTag: "div",
9999
+ language,
10000
+ style: activeStyle,
10001
+ wrapLines: true,
10002
+ showLineNumbers: true,
10003
+ showInlineLineNumbers: false,
10004
+ lineNumberContainerStyle: HIDDEN_LINE_NUMBERS,
10005
+ lineProps: LINE_PROPS_FN,
10006
+ customStyle: {
10007
+ backgroundColor: "transparent",
10008
+ borderRadius: 0,
10009
+ padding: 0,
10010
+ margin: 0,
10011
+ whiteSpace: "pre",
10012
+ minWidth: "100%"
10013
+ },
10014
+ children: code
10015
+ }
10016
+ ),
10017
+ [code, language, activeStyle]
10018
+ );
10019
+ useLayoutEffect(() => {
10020
+ const container = codeRef.current;
10021
+ if (!container) return;
10022
+ container.querySelectorAll(".fold-toggle, .fold-summary").forEach((el) => el.remove());
10023
+ const lineEls = container.querySelectorAll("[data-line]");
10024
+ if (!isFoldable || foldRegions.length === 0) {
10025
+ lineEls.forEach((el) => {
10026
+ el.style.display = "";
10027
+ el.style.position = "";
10028
+ el.style.paddingLeft = "";
10029
+ });
10030
+ return;
10031
+ }
10032
+ lineEls.forEach((el) => {
10033
+ const num = parseInt(el.getAttribute("data-line") ?? "-1", 10);
10034
+ if (hiddenLines.has(num)) {
10035
+ el.style.display = "none";
10036
+ return;
10037
+ }
10038
+ el.style.display = "";
10039
+ el.style.position = "relative";
10040
+ el.style.paddingLeft = "1.2em";
10041
+ const region = foldStartMap.get(num);
10042
+ if (!region) return;
10043
+ const isCollapsed = collapsed.has(num);
10044
+ const toggle = document.createElement("span");
10045
+ toggle.className = "fold-toggle";
10046
+ toggle.textContent = isCollapsed ? "\u25B6" : "\u25BC";
10047
+ toggle.style.cssText = "position:absolute;left:0;top:0;width:1.2em;text-align:center;cursor:pointer;color:#858585;font-size:10px;user-select:none;line-height:inherit;height:100%";
10048
+ toggle.addEventListener("click", (e) => {
10049
+ e.stopPropagation();
10050
+ toggleFoldRef.current(num);
10051
+ });
10052
+ el.insertBefore(toggle, el.firstChild);
10053
+ if (isCollapsed) {
10054
+ const summary = document.createElement("span");
10055
+ summary.className = "fold-summary";
10056
+ summary.style.cssText = "color:#858585;font-style:italic";
10057
+ const count = region.end - region.start - 1;
10058
+ summary.textContent = ` ... ${count} line${count !== 1 ? "s" : ""} ${region.closeBracket}`;
10059
+ el.appendChild(summary);
10060
+ }
10061
+ });
10062
+ }, [collapsed, hiddenLines, foldStartMap, foldRegions, isFoldable]);
9844
10063
  useLayoutEffect(() => {
9845
10064
  const el = scrollRef.current;
9846
10065
  return () => {
@@ -9871,13 +10090,14 @@ var CodeBlock = React117__default.memo(
9871
10090
  eventBus.emit("UI:COPY_CODE", { language, success: false });
9872
10091
  }
9873
10092
  };
10093
+ const hasHeader = showLanguageBadge || showCopyButton;
9874
10094
  return /* @__PURE__ */ jsxs(Box, { className: `relative group ${className || ""}`, children: [
9875
- (showLanguageBadge || showCopyButton) && /* @__PURE__ */ jsxs(
10095
+ hasHeader && /* @__PURE__ */ jsxs(
9876
10096
  HStack,
9877
10097
  {
9878
10098
  justify: "between",
9879
10099
  align: "center",
9880
- className: "px-3 py-2 bg-gray-800 rounded-t-lg border-b border-gray-700",
10100
+ className: "px-3 py-2 bg-[var(--color-card)] rounded-t-lg border-b border-gray-700",
9881
10101
  children: [
9882
10102
  showLanguageBadge && /* @__PURE__ */ jsx(Badge, { variant: "default", size: "sm", children: language }),
9883
10103
  showCopyButton && /* @__PURE__ */ jsx(
@@ -9907,31 +10127,14 @@ var CodeBlock = React117__default.memo(
9907
10127
  touchAction: "pan-x pan-y",
9908
10128
  contain: "paint",
9909
10129
  backgroundColor: "#1e1e1e",
9910
- borderRadius: showLanguageBadge || showCopyButton ? "0 0 0.5rem 0.5rem" : "0.5rem",
9911
- padding: "1rem"
10130
+ borderRadius: hasHeader ? "0 0 0.5rem 0.5rem" : "0.5rem"
9912
10131
  },
9913
- children: /* @__PURE__ */ jsx(
9914
- SyntaxHighlighter,
9915
- {
9916
- PreTag: "div",
9917
- language,
9918
- style: activeStyle,
9919
- customStyle: {
9920
- backgroundColor: "transparent",
9921
- borderRadius: 0,
9922
- padding: 0,
9923
- margin: 0,
9924
- whiteSpace: "pre",
9925
- minWidth: "100%"
9926
- },
9927
- children: code
9928
- }
9929
- )
10132
+ children: /* @__PURE__ */ jsx("div", { ref: codeRef, style: { padding: "1rem" }, children: highlightedElement })
9930
10133
  }
9931
10134
  )
9932
10135
  ] });
9933
10136
  },
9934
- (prev, next) => prev.language === next.language && prev.code === next.code && prev.showCopyButton === next.showCopyButton && prev.maxHeight === next.maxHeight
10137
+ (prev, next) => prev.language === next.language && prev.code === next.code && prev.showCopyButton === next.showCopyButton && prev.maxHeight === next.maxHeight && prev.foldable === next.foldable
9935
10138
  );
9936
10139
  CodeBlock.displayName = "CodeBlock";
9937
10140
  function Card2({
@@ -19150,7 +19353,7 @@ var sizeMap17 = {
19150
19353
  lg: "text-base px-4 py-2"
19151
19354
  };
19152
19355
  var variantMap2 = {
19153
- default: "bg-gray-800/80 border-gray-700",
19356
+ default: "bg-[var(--color-card)]/80 border-gray-700",
19154
19357
  primary: "bg-blue-900/80 border-blue-700",
19155
19358
  success: "bg-green-900/80 border-green-700",
19156
19359
  warning: "bg-yellow-900/80 border-yellow-700",
@@ -19211,7 +19414,7 @@ function StatBadge({
19211
19414
  animated: true
19212
19415
  }
19213
19416
  ),
19214
- format === "text" && /* @__PURE__ */ jsx("span", { className: "font-bold text-white", children: value })
19417
+ format === "text" && /* @__PURE__ */ jsx("span", { className: "font-bold text-[var(--color-foreground)]", children: value })
19215
19418
  ]
19216
19419
  }
19217
19420
  );
@@ -19484,7 +19687,7 @@ function HealthPanel({
19484
19687
  Box,
19485
19688
  {
19486
19689
  className: cn(
19487
- "rounded-lg bg-gray-900/90 border border-gray-700 backdrop-blur-sm",
19690
+ "rounded-lg bg-[var(--color-card)]/90 border border-gray-700 backdrop-blur-sm",
19488
19691
  sizes.padding,
19489
19692
  className
19490
19693
  ),
@@ -19586,7 +19789,7 @@ function ScoreBoard({
19586
19789
  Card,
19587
19790
  {
19588
19791
  className: cn(
19589
- "bg-gray-900/90 border-gray-700 backdrop-blur-sm",
19792
+ "bg-[var(--color-card)]/90 border-gray-700 backdrop-blur-sm",
19590
19793
  className
19591
19794
  ),
19592
19795
  children: /* @__PURE__ */ jsx(CardContent, { className: "p-3", children: /* @__PURE__ */ jsxs(Box, { className: "flex items-center gap-3 flex-wrap", children: [
@@ -19685,7 +19888,7 @@ function TurnPanel({
19685
19888
  Box,
19686
19889
  {
19687
19890
  className: cn(
19688
- "flex items-center gap-3 rounded-lg bg-gray-900/90 border border-gray-700 backdrop-blur-sm px-3 py-2",
19891
+ "flex items-center gap-3 rounded-lg bg-[var(--color-card)]/90 border border-gray-700 backdrop-blur-sm px-3 py-2",
19689
19892
  className
19690
19893
  ),
19691
19894
  children: [
@@ -19732,7 +19935,7 @@ function EnemyPlate({
19732
19935
  Box,
19733
19936
  {
19734
19937
  className: cn(
19735
- "inline-flex flex-col gap-1 rounded-lg bg-gray-900/90 border border-gray-700 backdrop-blur-sm px-3 py-1.5",
19938
+ "inline-flex flex-col gap-1 rounded-lg bg-[var(--color-card)]/90 border border-gray-700 backdrop-blur-sm px-3 py-1.5",
19736
19939
  "min-w-[120px]",
19737
19940
  className
19738
19941
  ),
@@ -19743,7 +19946,7 @@ function EnemyPlate({
19743
19946
  {
19744
19947
  variant: "caption",
19745
19948
  weight: "bold",
19746
- className: "text-white truncate",
19949
+ className: "text-[var(--color-foreground)] truncate",
19747
19950
  children: name
19748
19951
  }
19749
19952
  ),
@@ -19810,7 +20013,7 @@ function UnitCommandBar({
19810
20013
  Box,
19811
20014
  {
19812
20015
  className: cn(
19813
- "flex items-center gap-1.5 rounded-lg bg-gray-900/90 border border-gray-700 backdrop-blur-sm px-2 py-1.5",
20016
+ "flex items-center gap-1.5 rounded-lg bg-[var(--color-card)]/90 border border-gray-700 backdrop-blur-sm px-2 py-1.5",
19814
20017
  className
19815
20018
  ),
19816
20019
  children: commands.map((command, i) => /* @__PURE__ */ jsxs(Box, { className: "flex flex-col items-center gap-0.5", children: [
@@ -20037,7 +20240,7 @@ function DialogueBox({
20037
20240
  tabIndex: 0,
20038
20241
  role: "dialog",
20039
20242
  "aria-label": "Dialogue",
20040
- children: /* @__PURE__ */ jsx("div", { className: "mx-4 my-4 bg-gray-900 bg-opacity-95 border-2 border-gray-600 rounded-lg overflow-hidden", children: /* @__PURE__ */ jsxs("div", { className: "flex", children: [
20243
+ children: /* @__PURE__ */ jsx("div", { className: "mx-4 my-4 bg-[var(--color-card)] bg-opacity-95 border-2 border-gray-600 rounded-lg overflow-hidden", children: /* @__PURE__ */ jsxs("div", { className: "flex", children: [
20041
20244
  dialogue.portrait && /* @__PURE__ */ jsx("div", { className: "flex-shrink-0 p-4 border-r border-gray-700", children: /* @__PURE__ */ jsx(
20042
20245
  "img",
20043
20246
  {
@@ -20049,7 +20252,7 @@ function DialogueBox({
20049
20252
  ) }),
20050
20253
  /* @__PURE__ */ jsxs("div", { className: "flex-1 p-4", children: [
20051
20254
  /* @__PURE__ */ jsx("div", { className: "text-yellow-400 font-bold mb-2", children: dialogue.speaker }),
20052
- /* @__PURE__ */ jsxs("div", { className: "text-white text-lg leading-relaxed min-h-[60px]", children: [
20255
+ /* @__PURE__ */ jsxs("div", { className: "text-[var(--color-foreground)] text-lg leading-relaxed min-h-[60px]", children: [
20053
20256
  displayedText,
20054
20257
  isTyping && /* @__PURE__ */ jsx("span", { className: "animate-pulse", children: "\u258C" })
20055
20258
  ] }),
@@ -20059,8 +20262,8 @@ function DialogueBox({
20059
20262
  type: "button",
20060
20263
  className: cn(
20061
20264
  "block w-full text-left px-4 py-2 rounded transition-colors",
20062
- "hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-yellow-400",
20063
- selectedChoice === index ? "bg-gray-700 text-yellow-400" : "bg-gray-800 text-white"
20265
+ "hover:bg-[var(--color-surface,#374151)] focus:outline-none focus:ring-2 focus:ring-yellow-400",
20266
+ selectedChoice === index ? "bg-[var(--color-surface,#374151)] text-yellow-400" : "bg-[var(--color-card)] text-[var(--color-foreground)]"
20064
20267
  ),
20065
20268
  onClick: (e) => {
20066
20269
  e.stopPropagation();
@@ -20173,7 +20376,7 @@ function InventoryPanel({
20173
20376
  /* @__PURE__ */ jsx(
20174
20377
  "div",
20175
20378
  {
20176
- className: "grid gap-1 bg-gray-900 p-2 rounded-lg border border-gray-700",
20379
+ className: "grid gap-1 bg-[var(--color-card)] p-2 rounded-lg border border-gray-700",
20177
20380
  style: {
20178
20381
  gridTemplateColumns: `repeat(${safeColumns}, ${slotSize}px)`,
20179
20382
  gridTemplateRows: `repeat(${rows}, ${slotSize}px)`
@@ -20184,9 +20387,9 @@ function InventoryPanel({
20184
20387
  type: "button",
20185
20388
  className: cn(
20186
20389
  "relative flex items-center justify-center",
20187
- "bg-gray-800 border rounded transition-colors",
20188
- "hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500",
20189
- selectedSlot === index ? "border-yellow-400 bg-gray-700" : "border-gray-600"
20390
+ "bg-[var(--color-card)] border rounded transition-colors",
20391
+ "hover:bg-[var(--color-surface,#374151)] focus:outline-none focus:ring-2 focus:ring-blue-500",
20392
+ selectedSlot === index ? "border-yellow-400 bg-[var(--color-surface,#374151)]" : "border-gray-600"
20190
20393
  ),
20191
20394
  style: { width: slotSize, height: slotSize },
20192
20395
  onClick: () => handleSlotClick(index),
@@ -20216,14 +20419,14 @@ function InventoryPanel({
20216
20419
  showTooltips && hoveredItem && /* @__PURE__ */ jsxs(
20217
20420
  "div",
20218
20421
  {
20219
- className: "fixed z-50 bg-gray-900 border border-gray-600 rounded-lg p-2 shadow-lg pointer-events-none",
20422
+ className: "fixed z-50 bg-[var(--color-card)] border border-gray-600 rounded-lg p-2 shadow-lg pointer-events-none",
20220
20423
  style: {
20221
20424
  left: tooltipPosition.x,
20222
20425
  top: tooltipPosition.y,
20223
20426
  maxWidth: 200
20224
20427
  },
20225
20428
  children: [
20226
- /* @__PURE__ */ jsx("div", { className: "font-semibold text-white", children: hoveredItem.name || hoveredItem.type }),
20429
+ /* @__PURE__ */ jsx("div", { className: "font-semibold text-[var(--color-foreground)]", children: hoveredItem.name || hoveredItem.type }),
20227
20430
  hoveredItem.description && /* @__PURE__ */ jsx("div", { className: "text-sm text-gray-400 mt-1", children: hoveredItem.description }),
20228
20431
  /* @__PURE__ */ jsxs("div", { className: "text-xs text-gray-500 mt-1", children: [
20229
20432
  "Quantity: ",
@@ -20235,9 +20438,9 @@ function InventoryPanel({
20235
20438
  ] });
20236
20439
  }
20237
20440
  var variantMap3 = {
20238
- primary: "bg-blue-600 hover:bg-blue-500 text-white border-blue-400 shadow-lg shadow-blue-500/25",
20239
- secondary: "bg-gray-700 hover:bg-gray-600 text-white border-gray-500",
20240
- ghost: "bg-transparent hover:bg-white/10 text-white border-white/20"
20441
+ primary: "bg-[var(--color-primary)] hover:bg-blue-500 text-[var(--color-primary-foreground)] border-blue-400 shadow-lg shadow-blue-500/25",
20442
+ secondary: "bg-[var(--color-surface,#374151)] hover:bg-gray-600 text-[var(--color-foreground)] border-gray-500",
20443
+ ghost: "bg-transparent hover:bg-white/10 text-[var(--color-foreground)] border-white/20"
20241
20444
  };
20242
20445
  function GameMenu({
20243
20446
  title,
@@ -20294,7 +20497,7 @@ function GameMenu({
20294
20497
  /* @__PURE__ */ jsx(
20295
20498
  "h1",
20296
20499
  {
20297
- className: "text-5xl md:text-7xl font-bold text-white tracking-tight",
20500
+ className: "text-5xl md:text-7xl font-bold text-[var(--color-foreground)] tracking-tight",
20298
20501
  style: {
20299
20502
  textShadow: "0 4px 12px rgba(0,0,0,0.5)"
20300
20503
  },
@@ -20350,9 +20553,9 @@ var variantColors = {
20350
20553
  }
20351
20554
  };
20352
20555
  var buttonVariants = {
20353
- primary: "bg-blue-600 hover:bg-blue-500 text-white border-blue-400",
20354
- secondary: "bg-gray-700 hover:bg-gray-600 text-white border-gray-500",
20355
- ghost: "bg-transparent hover:bg-white/10 text-white border-white/20"
20556
+ primary: "bg-[var(--color-primary)] hover:bg-blue-500 text-[var(--color-primary-foreground)] border-blue-400",
20557
+ secondary: "bg-[var(--color-surface,#374151)] hover:bg-gray-600 text-[var(--color-foreground)] border-gray-500",
20558
+ ghost: "bg-transparent hover:bg-white/10 text-[var(--color-foreground)] border-white/20"
20356
20559
  };
20357
20560
  function formatTime3(ms) {
20358
20561
  const seconds = Math.floor(ms / 1e3);
@@ -20433,7 +20636,7 @@ function GameOverScreen({
20433
20636
  }
20434
20637
  return /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
20435
20638
  /* @__PURE__ */ jsx("div", { className: "text-gray-400 text-sm mb-1", children: stat.label }),
20436
- /* @__PURE__ */ jsxs("div", { className: "text-white text-2xl font-bold flex items-center justify-center gap-2", children: [
20639
+ /* @__PURE__ */ jsxs("div", { className: "text-[var(--color-foreground)] text-2xl font-bold flex items-center justify-center gap-2", children: [
20437
20640
  stat.icon && /* @__PURE__ */ jsx("span", { children: stat.icon }),
20438
20641
  /* @__PURE__ */ jsx("span", { className: "tabular-nums", children: displayValue })
20439
20642
  ] })
@@ -21604,7 +21807,7 @@ var Lightbox = ({
21604
21807
  className: cn(
21605
21808
  "absolute top-4 right-4 z-10",
21606
21809
  "p-2 rounded-full",
21607
- "text-white bg-black bg-opacity-50",
21810
+ "text-[var(--color-foreground)] bg-[var(--color-card)]",
21608
21811
  "hover:bg-opacity-70 transition-opacity",
21609
21812
  "focus:outline-none focus:ring-2 focus:ring-white"
21610
21813
  ),
@@ -21623,7 +21826,7 @@ var Lightbox = ({
21623
21826
  className: cn(
21624
21827
  "absolute left-4 z-10",
21625
21828
  "p-2 rounded-full",
21626
- "text-white bg-black bg-opacity-50",
21829
+ "text-[var(--color-foreground)] bg-[var(--color-card)]",
21627
21830
  "hover:bg-opacity-70 transition-opacity",
21628
21831
  "focus:outline-none focus:ring-2 focus:ring-white"
21629
21832
  ),
@@ -21660,7 +21863,7 @@ var Lightbox = ({
21660
21863
  className: cn(
21661
21864
  "absolute right-4 z-10",
21662
21865
  "p-2 rounded-full",
21663
- "text-white bg-black bg-opacity-50",
21866
+ "text-[var(--color-foreground)] bg-[var(--color-card)]",
21664
21867
  "hover:bg-opacity-70 transition-opacity",
21665
21868
  "focus:outline-none focus:ring-2 focus:ring-white"
21666
21869
  ),
@@ -21669,12 +21872,12 @@ var Lightbox = ({
21669
21872
  }
21670
21873
  ),
21671
21874
  /* @__PURE__ */ jsxs("div", { className: "absolute bottom-4 left-0 right-0 text-center", children: [
21672
- showCounter && safeImages.length > 1 && /* @__PURE__ */ jsxs("div", { className: "text-white text-sm mb-1", children: [
21875
+ showCounter && safeImages.length > 1 && /* @__PURE__ */ jsxs("div", { className: "text-[var(--color-foreground)] text-sm mb-1", children: [
21673
21876
  index + 1,
21674
21877
  " of ",
21675
21878
  safeImages.length
21676
21879
  ] }),
21677
- currentImage?.caption && /* @__PURE__ */ jsx("div", { className: "text-white text-sm opacity-80 px-8", children: currentImage.caption })
21880
+ currentImage?.caption && /* @__PURE__ */ jsx("div", { className: "text-[var(--color-foreground)] text-sm opacity-80 px-8", children: currentImage.caption })
21678
21881
  ] })
21679
21882
  ]
21680
21883
  }
@@ -27249,6 +27452,254 @@ function onDebugToggle(listener) {
27249
27452
  listeners5.add(listener);
27250
27453
  return () => listeners5.delete(listener);
27251
27454
  }
27455
+ function layoutGraph(states, transitions, initialState, width, height) {
27456
+ if (states.length === 0) return [];
27457
+ const layers = /* @__PURE__ */ new Map();
27458
+ const queue = [initialState];
27459
+ layers.set(initialState, 0);
27460
+ while (queue.length > 0) {
27461
+ const current = queue.shift();
27462
+ const layer = layers.get(current);
27463
+ for (const tr of transitions) {
27464
+ if (tr.from === current && !layers.has(tr.to)) {
27465
+ layers.set(tr.to, layer + 1);
27466
+ queue.push(tr.to);
27467
+ }
27468
+ }
27469
+ }
27470
+ for (const s of states) {
27471
+ if (!layers.has(s)) layers.set(s, layers.size > 0 ? Math.max(...layers.values()) + 1 : 0);
27472
+ }
27473
+ const layerGroups = /* @__PURE__ */ new Map();
27474
+ for (const [state, layer] of layers) {
27475
+ const group = layerGroups.get(layer) ?? [];
27476
+ group.push(state);
27477
+ layerGroups.set(layer, group);
27478
+ }
27479
+ const maxLayer = Math.max(...layerGroups.keys(), 0);
27480
+ const padX = 24;
27481
+ const padY = 20;
27482
+ const usableW = width - padX * 2;
27483
+ const usableH = height - padY * 2;
27484
+ const positions = [];
27485
+ for (const [layer, group] of layerGroups) {
27486
+ const y = maxLayer === 0 ? usableH / 2 + padY : padY + layer / maxLayer * usableH;
27487
+ for (let i = 0; i < group.length; i++) {
27488
+ const x = group.length === 1 ? width / 2 : padX + i / (group.length - 1) * usableW;
27489
+ positions.push({ x, y, state: group[i] });
27490
+ }
27491
+ }
27492
+ return positions;
27493
+ }
27494
+ function WalkMinimap() {
27495
+ const [walkStep, setWalkStep] = React117.useState(null);
27496
+ const [traits2, setTraits] = React117.useState([]);
27497
+ const [coveredEdges, setCoveredEdges] = React117.useState([]);
27498
+ const [completedTraits, setCompletedTraits] = React117.useState(/* @__PURE__ */ new Set());
27499
+ const prevTraitRef = React117.useRef(null);
27500
+ React117.useEffect(() => {
27501
+ const interval = setInterval(() => {
27502
+ const w = window;
27503
+ const step = w.__orbitalWalkStep;
27504
+ const traitConfigs = w.__orbitalWalkTraits;
27505
+ const edges = w.__orbitalCoveredEdges;
27506
+ if (step) setWalkStep(step);
27507
+ if (traitConfigs) setTraits(traitConfigs);
27508
+ if (edges) setCoveredEdges(edges);
27509
+ if (step && prevTraitRef.current && prevTraitRef.current !== step.traitName) {
27510
+ setCompletedTraits((prev) => new Set(prev).add(prevTraitRef.current));
27511
+ }
27512
+ if (step) prevTraitRef.current = step.traitName;
27513
+ }, 250);
27514
+ return () => clearInterval(interval);
27515
+ }, []);
27516
+ if (!walkStep || traits2.length === 0) return null;
27517
+ const activeTrait = traits2.find((t) => t.name === walkStep.traitName);
27518
+ const engineCount = coveredEdges.filter((e) => e.phase === "engine").length;
27519
+ const domCount = coveredEdges.filter((e) => e.phase === "dom").length;
27520
+ const totalTransitions = traits2.reduce((sum, t) => sum + t.transitions.length, 0);
27521
+ const activeEdgeKeys = new Set(
27522
+ coveredEdges.filter((e) => e.trait === walkStep.traitName).map((e) => `${e.from}+${e.event}->${e.to}`)
27523
+ );
27524
+ const activeEdgePhases = new Map(
27525
+ coveredEdges.filter((e) => e.trait === walkStep.traitName).map((e) => [`${e.from}+${e.event}->${e.to}`, e.phase])
27526
+ );
27527
+ const currentEdgeKey = `${walkStep.from}+${walkStep.event}->${walkStep.to}`;
27528
+ const graphW = 260;
27529
+ const graphH = 120;
27530
+ const nodeR = 10;
27531
+ const positions = activeTrait ? layoutGraph(activeTrait.states, activeTrait.transitions, activeTrait.initialState, graphW, graphH) : [];
27532
+ const posMap = new Map(positions.map((p2) => [p2.state, p2]));
27533
+ const visitedStates = new Set(
27534
+ coveredEdges.filter((e) => e.trait === walkStep.traitName).flatMap((e) => [e.from, e.to])
27535
+ );
27536
+ return /* @__PURE__ */ jsxs(VStack, { gap: "none", className: "w-64 flex-shrink-0 border-l border-border bg-[var(--color-card)] overflow-hidden", children: [
27537
+ /* @__PURE__ */ jsx(Box, { className: "px-2 py-1.5 border-b border-border overflow-x-auto", children: /* @__PURE__ */ jsx(HStack, { gap: "xs", className: "flex-nowrap", children: traits2.map((t) => {
27538
+ const isDone = completedTraits.has(t.name);
27539
+ const isActive = t.name === walkStep.traitName;
27540
+ const variant = isDone ? "success" : isActive ? "info" : "neutral";
27541
+ const shortName = t.name.replace(/^[A-Z][a-z]+/, "");
27542
+ return /* @__PURE__ */ jsxs(
27543
+ Badge,
27544
+ {
27545
+ variant,
27546
+ size: "sm",
27547
+ className: `flex-shrink-0 text-[9px] ${isActive ? "ring-1 ring-cyan-400" : ""}`,
27548
+ children: [
27549
+ isDone ? "\u2713" : isActive ? "\u25CF" : "\u25CB",
27550
+ " ",
27551
+ shortName || t.name
27552
+ ]
27553
+ },
27554
+ t.name
27555
+ );
27556
+ }) }) }),
27557
+ /* @__PURE__ */ jsx(Box, { className: "flex-1 flex items-center justify-center px-1 py-1", children: activeTrait && /* @__PURE__ */ jsxs("svg", { width: graphW, height: graphH, viewBox: `0 0 ${graphW} ${graphH}`, children: [
27558
+ /* @__PURE__ */ jsxs("defs", { children: [
27559
+ /* @__PURE__ */ jsx("marker", { id: "mm-arrow", markerWidth: "6", markerHeight: "4", refX: "6", refY: "2", orient: "auto", children: /* @__PURE__ */ jsx("path", { d: "M0,0 L6,2 L0,4", fill: "#888" }) }),
27560
+ /* @__PURE__ */ jsx("marker", { id: "mm-arrow-green", markerWidth: "6", markerHeight: "4", refX: "6", refY: "2", orient: "auto", children: /* @__PURE__ */ jsx("path", { d: "M0,0 L6,2 L0,4", fill: "#22c55e" }) }),
27561
+ /* @__PURE__ */ jsx("marker", { id: "mm-arrow-cyan", markerWidth: "6", markerHeight: "4", refX: "6", refY: "2", orient: "auto", children: /* @__PURE__ */ jsx("path", { d: "M0,0 L6,2 L0,4", fill: "#06b6d4" }) }),
27562
+ /* @__PURE__ */ jsx("marker", { id: "mm-arrow-yellow", markerWidth: "6", markerHeight: "4", refX: "6", refY: "2", orient: "auto", children: /* @__PURE__ */ jsx("path", { d: "M0,0 L6,2 L0,4", fill: "#eab308" }) })
27563
+ ] }),
27564
+ activeTrait.transitions.map((tr, i) => {
27565
+ const fromPos = posMap.get(tr.from);
27566
+ const toPos = posMap.get(tr.to);
27567
+ if (!fromPos || !toPos) return null;
27568
+ const key = `${tr.from}+${tr.event}->${tr.to}`;
27569
+ const isCurrent = key === currentEdgeKey && !walkStep.isRepositioning;
27570
+ const isCovered = activeEdgeKeys.has(key);
27571
+ const phase = activeEdgePhases.get(key);
27572
+ let stroke = "#555";
27573
+ let markerEnd = "url(#mm-arrow)";
27574
+ let strokeWidth = 1;
27575
+ let opacity = 0.4;
27576
+ if (isCurrent) {
27577
+ stroke = "#eab308";
27578
+ markerEnd = "url(#mm-arrow-yellow)";
27579
+ strokeWidth = 2.5;
27580
+ opacity = 1;
27581
+ } else if (isCovered && phase === "dom") {
27582
+ stroke = "#06b6d4";
27583
+ markerEnd = "url(#mm-arrow-cyan)";
27584
+ strokeWidth = 1.5;
27585
+ opacity = 0.9;
27586
+ } else if (isCovered) {
27587
+ stroke = "#22c55e";
27588
+ markerEnd = "url(#mm-arrow-green)";
27589
+ strokeWidth = 1.5;
27590
+ opacity = 0.9;
27591
+ }
27592
+ if (tr.from === tr.to) {
27593
+ const cx = fromPos.x;
27594
+ const cy = fromPos.y - nodeR - 8;
27595
+ return /* @__PURE__ */ jsxs("g", { children: [
27596
+ /* @__PURE__ */ jsx(
27597
+ "path",
27598
+ {
27599
+ d: `M${cx - 5},${fromPos.y - nodeR} C${cx - 18},${cy - 14} ${cx + 18},${cy - 14} ${cx + 5},${fromPos.y - nodeR}`,
27600
+ fill: "none",
27601
+ stroke,
27602
+ strokeWidth,
27603
+ opacity,
27604
+ markerEnd
27605
+ }
27606
+ ),
27607
+ /* @__PURE__ */ jsx("text", { x: cx, y: cy - 12, textAnchor: "middle", fontSize: "7", fill: stroke, opacity, children: tr.event.length > 10 ? tr.event.slice(0, 8) + ".." : tr.event })
27608
+ ] }, `e-${i}`);
27609
+ }
27610
+ const dx = toPos.x - fromPos.x;
27611
+ const dy = toPos.y - fromPos.y;
27612
+ const len = Math.sqrt(dx * dx + dy * dy) || 1;
27613
+ const nx = -dy / len;
27614
+ const ny = dx / len;
27615
+ const hasReverse = activeTrait.transitions.some(
27616
+ (t2) => t2.from === tr.to && t2.to === tr.from
27617
+ );
27618
+ const offset = hasReverse ? 4 : 0;
27619
+ const x1 = fromPos.x + dx / len * nodeR + nx * offset;
27620
+ const y1 = fromPos.y + dy / len * nodeR + ny * offset;
27621
+ const x2 = toPos.x - dx / len * (nodeR + 6) + nx * offset;
27622
+ const y2 = toPos.y - dy / len * (nodeR + 6) + ny * offset;
27623
+ const mx = (x1 + x2) / 2 + nx * 8;
27624
+ const my = (y1 + y2) / 2 + ny * 8;
27625
+ return /* @__PURE__ */ jsxs("g", { children: [
27626
+ /* @__PURE__ */ jsx(
27627
+ "line",
27628
+ {
27629
+ x1,
27630
+ y1,
27631
+ x2,
27632
+ y2,
27633
+ stroke,
27634
+ strokeWidth,
27635
+ opacity,
27636
+ markerEnd,
27637
+ children: isCurrent && /* @__PURE__ */ jsx("animate", { attributeName: "opacity", values: "1;0.4;1", dur: "0.8s", repeatCount: "indefinite" })
27638
+ }
27639
+ ),
27640
+ /* @__PURE__ */ jsx("text", { x: mx, y: my, textAnchor: "middle", fontSize: "7", fill: stroke, opacity: Math.min(opacity + 0.2, 1), children: tr.event.length > 12 ? tr.event.slice(0, 10) + ".." : tr.event })
27641
+ ] }, `e-${i}`);
27642
+ }),
27643
+ positions.map((pos) => {
27644
+ const isCurrentState = pos.state === walkStep.from || pos.state === walkStep.to;
27645
+ const isVisited = visitedStates.has(pos.state);
27646
+ const isInitial = pos.state === activeTrait.initialState;
27647
+ let fill = "#333";
27648
+ let strokeColor = "#555";
27649
+ let sw = 1;
27650
+ if (isCurrentState) {
27651
+ fill = "#1e40af";
27652
+ strokeColor = "#3b82f6";
27653
+ sw = 2;
27654
+ } else if (isVisited) {
27655
+ fill = "#166534";
27656
+ strokeColor = "#22c55e";
27657
+ sw = 1.5;
27658
+ }
27659
+ return /* @__PURE__ */ jsxs("g", { children: [
27660
+ isInitial && /* @__PURE__ */ jsx("circle", { cx: pos.x, cy: pos.y, r: nodeR + 3, fill: "none", stroke: "#3b82f6", strokeWidth: 1, opacity: 0.4 }),
27661
+ /* @__PURE__ */ jsx(
27662
+ "circle",
27663
+ {
27664
+ cx: pos.x,
27665
+ cy: pos.y,
27666
+ r: nodeR,
27667
+ fill,
27668
+ stroke: strokeColor,
27669
+ strokeWidth: sw,
27670
+ children: isCurrentState && /* @__PURE__ */ jsx("animate", { attributeName: "r", values: `${nodeR};${nodeR + 2};${nodeR}`, dur: "1s", repeatCount: "indefinite" })
27671
+ }
27672
+ ),
27673
+ /* @__PURE__ */ jsx(
27674
+ "text",
27675
+ {
27676
+ x: pos.x,
27677
+ y: pos.y + nodeR + 10,
27678
+ textAnchor: "middle",
27679
+ fontSize: "8",
27680
+ fill: "#aaa",
27681
+ children: pos.state.length > 10 ? pos.state.slice(0, 8) + ".." : pos.state
27682
+ }
27683
+ )
27684
+ ] }, pos.state);
27685
+ })
27686
+ ] }) }),
27687
+ /* @__PURE__ */ jsx(Box, { className: "px-2 py-1 border-t border-border", children: /* @__PURE__ */ jsxs(HStack, { gap: "sm", className: "items-center justify-between", children: [
27688
+ /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "text-[10px] font-mono text-green-500", children: [
27689
+ "Engine: ",
27690
+ engineCount,
27691
+ "/",
27692
+ totalTransitions
27693
+ ] }),
27694
+ domCount > 0 && /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "text-[10px] font-mono text-cyan-500", children: [
27695
+ "DOM: ",
27696
+ domCount
27697
+ ] }),
27698
+ /* @__PURE__ */ jsx(Badge, { variant: walkStep.phase === "engine" ? "info" : "warning", size: "sm", className: "text-[9px]", children: walkStep.phase === "engine" ? "Engine" : "DOM" })
27699
+ ] }) })
27700
+ ] });
27701
+ }
27702
+ WalkMinimap.displayName = "WalkMinimap";
27252
27703
  function TraitsTab({ traits: traits2 }) {
27253
27704
  if (traits2.length === 0) {
27254
27705
  return /* @__PURE__ */ jsx(
@@ -28072,25 +28523,25 @@ function EventDispatcherTab({ traits: traits2, schema }) {
28072
28523
  EventDispatcherTab.displayName = "EventDispatcherTab";
28073
28524
  function ServerResponseRow({ sr }) {
28074
28525
  const entityEntries = Object.entries(sr.dataEntities);
28075
- return /* @__PURE__ */ jsxs("div", { className: "ml-4 pl-2 border-l border-purple-700/50 py-0.5 text-[10px] font-mono", children: [
28526
+ return /* @__PURE__ */ jsxs("div", { className: "ml-4 pl-2 border-l border-purple-500/30 py-0.5 text-[10px] font-mono", children: [
28076
28527
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
28077
- /* @__PURE__ */ jsxs("span", { className: sr.success ? "text-green-400" : "text-red-400", children: [
28528
+ /* @__PURE__ */ jsxs("span", { className: sr.success ? "text-green-600 dark:text-green-400" : "text-red-600 dark:text-red-400", children: [
28078
28529
  sr.success ? "\u2713" : "\u2717",
28079
28530
  " server"
28080
28531
  ] }),
28081
- /* @__PURE__ */ jsx("span", { className: "text-purple-300", children: sr.orbitalName }),
28082
- sr.clientEffects > 0 && /* @__PURE__ */ jsxs("span", { className: "px-1 rounded bg-purple-900/50 text-purple-300", children: [
28532
+ /* @__PURE__ */ jsx("span", { className: "text-purple-600 dark:text-purple-300", children: sr.orbitalName }),
28533
+ sr.clientEffects > 0 && /* @__PURE__ */ jsxs("span", { className: "px-1 rounded bg-purple-500/15 text-purple-600 dark:text-purple-300", children: [
28083
28534
  sr.clientEffects,
28084
28535
  " clientEffect",
28085
28536
  sr.clientEffects !== 1 ? "s" : ""
28086
28537
  ] }),
28087
- sr.emittedEvents.length > 0 && /* @__PURE__ */ jsxs("span", { className: "px-1 rounded bg-blue-900/50 text-blue-300", children: [
28538
+ sr.emittedEvents.length > 0 && /* @__PURE__ */ jsxs("span", { className: "px-1 rounded bg-blue-500/15 text-blue-300", children: [
28088
28539
  "emit: ",
28089
28540
  sr.emittedEvents.join(", ")
28090
28541
  ] }),
28091
- sr.error && /* @__PURE__ */ jsx("span", { className: "px-1 rounded bg-red-900/50 text-red-400 truncate max-w-[300px]", children: sr.error })
28542
+ sr.error && /* @__PURE__ */ jsx("span", { className: "px-1 rounded bg-red-500/15 text-red-600 dark:text-red-400 truncate max-w-[300px]", children: sr.error })
28092
28543
  ] }),
28093
- entityEntries.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1 mt-0.5", children: entityEntries.map(([name, count]) => /* @__PURE__ */ jsxs("span", { className: "px-1 rounded bg-gray-800 text-gray-300", children: [
28544
+ entityEntries.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1 mt-0.5", children: entityEntries.map(([name, count]) => /* @__PURE__ */ jsxs("span", { className: "px-1 rounded bg-[var(--color-card)] text-foreground", children: [
28094
28545
  name,
28095
28546
  ": ",
28096
28547
  count,
@@ -28103,24 +28554,24 @@ function TransitionRow({ trace }) {
28103
28554
  const isServerEntry = !!trace.serverResponse && trace.traitName.startsWith("server:");
28104
28555
  const hasFailedEffects = trace.effects.some((e) => e.status === "failed");
28105
28556
  if (isServerEntry && trace.serverResponse) {
28106
- return /* @__PURE__ */ jsxs("div", { className: "py-0.5 border-b border-gray-800 last:border-0", children: [
28557
+ return /* @__PURE__ */ jsxs("div", { className: "py-0.5 border-b border-border last:border-0", children: [
28107
28558
  /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2 text-xs font-mono", children: [
28108
28559
  /* @__PURE__ */ jsx("span", { className: "mt-1.5 w-1.5 h-1.5 rounded-full flex-shrink-0 bg-purple-500" }),
28109
28560
  /* @__PURE__ */ jsx(Badge, { variant: "warning", size: "sm", className: "flex-shrink-0", children: trace.event }),
28110
- /* @__PURE__ */ jsx("span", { className: "text-purple-400 flex-shrink-0", children: "server response" })
28561
+ /* @__PURE__ */ jsx("span", { className: "text-purple-600 dark:text-purple-400 flex-shrink-0", children: "server response" })
28111
28562
  ] }),
28112
28563
  /* @__PURE__ */ jsx(ServerResponseRow, { sr: trace.serverResponse })
28113
28564
  ] });
28114
28565
  }
28115
- return /* @__PURE__ */ jsxs("div", { className: "py-0.5 border-b border-gray-800 last:border-0", children: [
28566
+ return /* @__PURE__ */ jsxs("div", { className: "py-0.5 border-b border-border last:border-0", children: [
28116
28567
  /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2 text-xs font-mono", children: [
28117
28568
  /* @__PURE__ */ jsx("span", { className: cn(
28118
28569
  "mt-1.5 w-1.5 h-1.5 rounded-full flex-shrink-0",
28119
28570
  hasFailedEffects ? "bg-red-500" : "bg-green-500"
28120
28571
  ) }),
28121
28572
  /* @__PURE__ */ jsx(Badge, { variant: "info", size: "sm", className: "flex-shrink-0", children: trace.event }),
28122
- /* @__PURE__ */ jsx("span", { className: "text-gray-300 flex-shrink-0", children: trace.traitName }),
28123
- /* @__PURE__ */ jsxs("span", { className: "text-gray-400 flex-shrink-0", children: [
28573
+ /* @__PURE__ */ jsx("span", { className: "text-foreground flex-shrink-0", children: trace.traitName }),
28574
+ /* @__PURE__ */ jsxs("span", { className: "text-foreground/70 flex-shrink-0", children: [
28124
28575
  trace.from,
28125
28576
  " ",
28126
28577
  "\u2192",
@@ -28130,12 +28581,12 @@ function TransitionRow({ trace }) {
28130
28581
  ] }),
28131
28582
  trace.effects.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1 ml-6 mt-0.5", children: trace.effects.map((eff, i) => /* @__PURE__ */ jsxs("span", { className: cn(
28132
28583
  "px-1 rounded text-[10px]",
28133
- eff.status === "executed" ? "bg-green-900/50 text-green-400" : eff.status === "failed" ? "bg-red-900/50 text-red-400" : "bg-yellow-900/50 text-yellow-400"
28584
+ eff.status === "executed" ? "bg-green-500/15 text-green-600 dark:text-green-400" : eff.status === "failed" ? "bg-red-500/15 text-red-600 dark:text-red-400" : "bg-yellow-500/15 text-yellow-600 dark:text-yellow-400"
28134
28585
  ), children: [
28135
28586
  eff.status === "executed" ? "\u2713" : eff.status === "failed" ? "\u2717" : "-",
28136
28587
  " ",
28137
28588
  eff.type,
28138
- eff.args.length > 0 && /* @__PURE__ */ jsx("span", { className: "text-gray-500 ml-0.5", children: JSON.stringify(eff.args).slice(0, 40) })
28589
+ eff.args.length > 0 && /* @__PURE__ */ jsx("span", { className: "text-foreground/50 ml-0.5", children: JSON.stringify(eff.args).slice(0, 40) })
28139
28590
  ] }, i)) }),
28140
28591
  trace.serverResponse && /* @__PURE__ */ jsx(ServerResponseRow, { sr: trace.serverResponse })
28141
28592
  ] });
@@ -28150,15 +28601,6 @@ function VerifyModePanel({
28150
28601
  }) {
28151
28602
  const scrollRef = React117.useRef(null);
28152
28603
  const prevCountRef = React117.useRef(0);
28153
- const [walkStep, setWalkStep] = React117.useState(null);
28154
- React117.useEffect(() => {
28155
- const interval = setInterval(() => {
28156
- const w = window;
28157
- const step = w.__orbitalWalkStep;
28158
- if (step) setWalkStep(step);
28159
- }, 300);
28160
- return () => clearInterval(interval);
28161
- }, []);
28162
28604
  React117.useEffect(() => {
28163
28605
  if (transitions.length > prevCountRef.current && scrollRef.current) {
28164
28606
  scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
@@ -28171,49 +28613,28 @@ function VerifyModePanel({
28171
28613
  {
28172
28614
  className: cn(
28173
28615
  "runtime-debugger runtime-debugger--verify",
28174
- "flex flex-col bg-gray-900 text-white border-t-2 border-cyan-500",
28616
+ "flex flex-col bg-[var(--color-card)] text-[var(--color-foreground)] border-t-2 border-cyan-500",
28175
28617
  hudBottom ? "" : "fixed bottom-0 left-0 right-0",
28176
28618
  className
28177
28619
  ),
28178
28620
  "data-testid": "debugger-verify",
28179
28621
  style: { height: "25vh", zIndex: hudBottom ? void 0 : 40 },
28180
28622
  children: [
28181
- /* @__PURE__ */ jsxs("div", { className: "px-3 py-1.5 flex items-center gap-3 text-xs font-mono border-b border-gray-700 flex-shrink-0", children: [
28623
+ /* @__PURE__ */ jsxs("div", { className: "px-3 py-1.5 flex items-center gap-3 text-xs font-mono border-b border-border flex-shrink-0", children: [
28182
28624
  /* @__PURE__ */ jsx(Badge, { variant: failedChecks > 0 ? "danger" : "success", size: "sm", children: failedChecks > 0 ? `${failedChecks} fail` : "OK" }),
28183
- /* @__PURE__ */ jsxs("span", { className: "text-gray-400", children: [
28625
+ /* @__PURE__ */ jsxs("span", { className: "text-foreground/70", children: [
28184
28626
  localCount,
28185
28627
  " local"
28186
28628
  ] }),
28187
- /* @__PURE__ */ jsxs("span", { className: "text-purple-400", children: [
28629
+ /* @__PURE__ */ jsxs("span", { className: "text-purple-600 dark:text-purple-400", children: [
28188
28630
  serverCount,
28189
28631
  " server"
28190
28632
  ] }),
28191
- traitStates && /* @__PURE__ */ jsx("span", { className: "text-cyan-400 truncate max-w-[400px]", children: traitStates })
28633
+ traitStates && /* @__PURE__ */ jsx("span", { className: "text-cyan-600 dark:text-cyan-400 truncate max-w-[400px]", children: traitStates })
28192
28634
  ] }),
28193
28635
  /* @__PURE__ */ jsxs("div", { className: "flex-1 flex overflow-hidden", children: [
28194
- /* @__PURE__ */ jsx("div", { ref: scrollRef, className: "flex-1 overflow-y-auto", children: /* @__PURE__ */ jsx("div", { className: "px-2 py-1", children: transitions.length === 0 ? /* @__PURE__ */ jsx("div", { className: "text-gray-500 text-xs font-mono py-2 text-center", children: "Waiting for transitions..." }) : /* @__PURE__ */ jsx("div", { className: "space-y-0.5", children: transitions.map((trace) => /* @__PURE__ */ jsx(TransitionRow, { trace }, trace.id)) }) }) }),
28195
- walkStep && /* @__PURE__ */ jsxs("div", { className: "w-56 flex-shrink-0 border-l border-gray-700 px-2 py-1 text-xs font-mono overflow-y-auto", children: [
28196
- /* @__PURE__ */ jsxs("div", { className: "text-cyan-400 font-bold mb-1", children: [
28197
- "Walk Step ",
28198
- walkStep.stepIndex,
28199
- "/",
28200
- walkStep.stepTotal
28201
- ] }),
28202
- /* @__PURE__ */ jsx("div", { className: "text-gray-300 mb-1", children: walkStep.traitName }),
28203
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 mb-1", children: [
28204
- /* @__PURE__ */ jsx("span", { className: "text-yellow-300", children: walkStep.from }),
28205
- /* @__PURE__ */ jsx("span", { className: "text-gray-500", children: "--" }),
28206
- /* @__PURE__ */ jsx("span", { className: "text-green-300", children: walkStep.event }),
28207
- /* @__PURE__ */ jsx("span", { className: "text-gray-500", children: "-->" }),
28208
- /* @__PURE__ */ jsx("span", { className: "text-yellow-300", children: walkStep.to })
28209
- ] }),
28210
- walkStep.guardCase && /* @__PURE__ */ jsxs("div", { className: walkStep.guardCase === "pass" ? "text-green-400" : "text-red-400", children: [
28211
- "guard: ",
28212
- walkStep.guardCase
28213
- ] }),
28214
- walkStep.isRepositioning && /* @__PURE__ */ jsx("div", { className: "text-gray-500 italic", children: "repositioning" }),
28215
- /* @__PURE__ */ jsx("div", { className: walkStep.accepted ? "text-green-400 mt-1" : "text-red-400 mt-1", children: walkStep.accepted ? "\u2713 accepted" : "\u2717 rejected" })
28216
- ] })
28636
+ /* @__PURE__ */ jsx("div", { ref: scrollRef, className: "flex-1 overflow-y-auto", children: /* @__PURE__ */ jsx("div", { className: "px-2 py-1", children: transitions.length === 0 ? /* @__PURE__ */ jsx("div", { className: "text-foreground/50 text-xs font-mono py-2 text-center", children: "Waiting for transitions..." }) : /* @__PURE__ */ jsx("div", { className: "space-y-0.5", children: transitions.map((trace) => /* @__PURE__ */ jsx(TransitionRow, { trace }, trace.id)) }) }) }),
28637
+ /* @__PURE__ */ jsx(WalkMinimap, {})
28217
28638
  ] })
28218
28639
  ]
28219
28640
  }
@@ -28438,7 +28859,7 @@ function RuntimeDebugger({
28438
28859
  className: "runtime-debugger__tabs"
28439
28860
  }
28440
28861
  ) }),
28441
- /* @__PURE__ */ jsx("div", { className: "runtime-debugger__footer", children: /* @__PURE__ */ jsx(Typography, { variant: "small", className: "text-gray-500", children: "Press ` to toggle | window.__orbitalVerification for automation" }) })
28862
+ /* @__PURE__ */ jsx("div", { className: "runtime-debugger__footer", children: /* @__PURE__ */ jsx(Typography, { variant: "small", className: "text-foreground/50", children: "Press ` to toggle | window.__orbitalVerification for automation" }) })
28442
28863
  ] })
28443
28864
  }
28444
28865
  );
@@ -28867,7 +29288,7 @@ function SequencerBoard({
28867
29288
  setPlayState("playing");
28868
29289
  setCurrentStep(0);
28869
29290
  let step = 0;
28870
- const advance2 = () => {
29291
+ const advance = () => {
28871
29292
  step++;
28872
29293
  if (step >= entity.maxSlots) {
28873
29294
  const playerSeq = slots.map((s) => s?.id);
@@ -28898,10 +29319,10 @@ function SequencerBoard({
28898
29319
  }
28899
29320
  } else {
28900
29321
  setCurrentStep(step);
28901
- timerRef.current = setTimeout(advance2, stepDurationMs);
29322
+ timerRef.current = setTimeout(advance, stepDurationMs);
28902
29323
  }
28903
29324
  };
28904
- timerRef.current = setTimeout(advance2, stepDurationMs);
29325
+ timerRef.current = setTimeout(advance, stepDurationMs);
28905
29326
  }, [canPlay, slots, entity.maxSlots, entity.solutions, stepDurationMs, playEvent, completeEvent, emit]);
28906
29327
  const machine = {
28907
29328
  name: entity.title,
@@ -32016,6 +32437,62 @@ function getComponentForPattern(patternType) {
32016
32437
  if (!name) return null;
32017
32438
  return COMPONENT_REGISTRY[name] ?? null;
32018
32439
  }
32440
+ var FORM_PATTERNS = /* @__PURE__ */ new Set([
32441
+ "form",
32442
+ "form-section",
32443
+ "inline-edit-form",
32444
+ "wizard-step"
32445
+ ]);
32446
+ function enrichFormFields(fields, entityDef) {
32447
+ const fieldMap = new Map(entityDef.fields.map((f3) => [f3.name, f3]));
32448
+ return fields.map((field) => {
32449
+ if (typeof field === "string") {
32450
+ const entityField = fieldMap.get(field);
32451
+ if (entityField) {
32452
+ const enriched = {
32453
+ name: field,
32454
+ label: field.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/\b\w/g, (c) => c.toUpperCase()),
32455
+ type: entityField.type,
32456
+ required: entityField.required
32457
+ };
32458
+ if (entityField.values && entityField.values.length > 0) {
32459
+ enriched.values = entityField.values;
32460
+ } else if (entityField.enumValues && entityField.enumValues.length > 0) {
32461
+ enriched.values = entityField.enumValues;
32462
+ }
32463
+ if (entityField.relation) {
32464
+ enriched.relation = entityField.relation;
32465
+ }
32466
+ return enriched;
32467
+ }
32468
+ return { name: field, label: field.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/\b\w/g, (c) => c.toUpperCase()) };
32469
+ }
32470
+ if (field && typeof field === "object" && !Array.isArray(field)) {
32471
+ const obj = field;
32472
+ const fieldName = obj.name ?? obj.field;
32473
+ if (!fieldName) return field;
32474
+ if (obj.type || obj.inputType) return field;
32475
+ const entityField = fieldMap.get(fieldName);
32476
+ if (!entityField) return field;
32477
+ const enriched = { ...obj, type: entityField.type };
32478
+ if (entityField.required && !("required" in obj)) {
32479
+ enriched.required = true;
32480
+ }
32481
+ if (!obj.values && !obj.options) {
32482
+ if (entityField.values && entityField.values.length > 0) {
32483
+ enriched.values = entityField.values;
32484
+ } else if (entityField.enumValues && entityField.enumValues.length > 0) {
32485
+ enriched.values = entityField.enumValues;
32486
+ }
32487
+ }
32488
+ if (!obj.relation && entityField.relation) {
32489
+ enriched.relation = entityField.relation;
32490
+ }
32491
+ return enriched;
32492
+ }
32493
+ return field;
32494
+ });
32495
+ }
32019
32496
  var PATTERNS_WITH_CHILDREN = /* @__PURE__ */ new Set([
32020
32497
  "stack",
32021
32498
  "vstack",
@@ -32391,13 +32868,14 @@ function getToastPosition(position) {
32391
32868
  return "top-4 right-4";
32392
32869
  }
32393
32870
  }
32394
- function renderPatternChildren(children, onDismiss, parentId = "root") {
32871
+ function renderPatternChildren(children, onDismiss, parentId = "root", parentPath = "root") {
32395
32872
  if (!children || !Array.isArray(children) || children.length === 0) {
32396
32873
  return null;
32397
32874
  }
32398
32875
  return children.map((child, index) => {
32399
32876
  if (!child || typeof child !== "object") return null;
32400
32877
  const childId = `${parentId}-${index}`;
32878
+ const childPath = parentPath === "root" ? `root.children.${index}` : `${parentPath}.children.${index}`;
32401
32879
  const childContent = {
32402
32880
  id: childId,
32403
32881
  pattern: child.type,
@@ -32409,7 +32887,8 @@ function renderPatternChildren(children, onDismiss, parentId = "root") {
32409
32887
  SlotContentRenderer,
32410
32888
  {
32411
32889
  content: childContent,
32412
- onDismiss
32890
+ onDismiss,
32891
+ patternPath: childPath
32413
32892
  },
32414
32893
  childId
32415
32894
  );
@@ -32441,16 +32920,20 @@ function renderPatternProps(props, onDismiss) {
32441
32920
  }
32442
32921
  function SlotContentRenderer({
32443
32922
  content,
32444
- onDismiss
32923
+ onDismiss,
32924
+ patternPath
32445
32925
  }) {
32446
32926
  const entityProp = content.props.entity;
32447
32927
  const entityType = typeof entityProp === "string" ? entityProp : "";
32448
32928
  const storeData = useEntityRef(entityType);
32929
+ const schemaCtx = useEntitySchemaOptional();
32930
+ const entityDef = entityType && schemaCtx ? schemaCtx.entities.get(entityType) : void 0;
32449
32931
  const PatternComponent = getComponentForPattern(content.pattern);
32450
32932
  if (PatternComponent) {
32451
32933
  const childrenConfig = content.props.children;
32452
32934
  const hasChildren = PATTERNS_WITH_CHILDREN.has(content.pattern) || Array.isArray(childrenConfig) && childrenConfig.length > 0;
32453
- const renderedChildren = hasChildren ? renderPatternChildren(childrenConfig, onDismiss, content.id) : void 0;
32935
+ const myPath = patternPath ?? "root";
32936
+ const renderedChildren = hasChildren ? renderPatternChildren(childrenConfig, onDismiss, content.id, myPath) : void 0;
32454
32937
  const { children: _childrenConfig, ...restProps } = content.props;
32455
32938
  const renderedProps = renderPatternProps(restProps, onDismiss);
32456
32939
  let finalProps;
@@ -32466,6 +32949,14 @@ function SlotContentRenderer({
32466
32949
  } else {
32467
32950
  finalProps = renderedProps;
32468
32951
  }
32952
+ const isFormPattern = FORM_PATTERNS.has(content.pattern) || content.pattern.includes("form");
32953
+ if (isFormPattern && entityDef && Array.isArray(finalProps.fields)) {
32954
+ finalProps.fields = enrichFormFields(finalProps.fields, entityDef);
32955
+ if (finalProps.mode === "edit" && !finalProps.initialData && storeData.length > 0) {
32956
+ finalProps.initialData = storeData[0];
32957
+ }
32958
+ }
32959
+ const acceptsChildren = PATTERNS_WITH_CHILDREN.has(content.pattern);
32469
32960
  return /* @__PURE__ */ jsx(
32470
32961
  Box,
32471
32962
  {
@@ -32474,6 +32965,9 @@ function SlotContentRenderer({
32474
32965
  "data-id": content.id,
32475
32966
  "data-node-id": content.nodeId,
32476
32967
  "data-source-trait": content.sourceTrait,
32968
+ "data-pattern-path": myPath,
32969
+ "data-pattern-type": content.pattern,
32970
+ "data-accepts-children": acceptsChildren ? "true" : void 0,
32477
32971
  children: /* @__PURE__ */ jsx(PatternComponent, { ...finalProps, children: renderedChildren })
32478
32972
  }
32479
32973
  );
@@ -32913,7 +33407,7 @@ function TraitInitializer({ traits: traits2, orbitalNames, onNavigate }) {
32913
33407
  if (responseData) {
32914
33408
  for (const [entityType, records] of Object.entries(responseData)) {
32915
33409
  if (Array.isArray(records)) {
32916
- entityStore.advance(entityType, records);
33410
+ entityStore.setAll(entityType, records);
32917
33411
  }
32918
33412
  }
32919
33413
  }
@@ -32972,7 +33466,7 @@ function TraitInitializer({ traits: traits2, orbitalNames, onNavigate }) {
32972
33466
  if (initResponseData) {
32973
33467
  for (const [entityType, records] of Object.entries(initResponseData)) {
32974
33468
  if (Array.isArray(records)) {
32975
- entityStore.advance(entityType, records);
33469
+ entityStore.setAll(entityType, records);
32976
33470
  }
32977
33471
  }
32978
33472
  }
@@ -33021,7 +33515,7 @@ function SchemaRunner({ schema, serverUrl, mockData, pageName, onNavigate }) {
33021
33515
  if (!serverUrl && mockData) {
33022
33516
  for (const [entityType, records] of Object.entries(mockData)) {
33023
33517
  if (Array.isArray(records)) {
33024
- entityStore.advance(entityType, records);
33518
+ entityStore.setAll(entityType, records);
33025
33519
  }
33026
33520
  }
33027
33521
  }
@@ -33103,4 +33597,4 @@ function OrbPreview({
33103
33597
  }
33104
33598
  OrbPreview.displayName = "OrbPreview";
33105
33599
 
33106
- export { EntitySchemaProvider, OrbPreview, ServerBridgeProvider, SlotsProvider, TraitContext, TraitProvider, clearSchemaCache, createClientEffectHandlers, useEntityDefinition, useEntitySchema, useResolvedSchema, useServerBridge, useSlotContent, useSlots, useSlotsActions, useTrait, useTraitContext, useTraitStateMachine };
33600
+ export { EntitySchemaProvider, OrbPreview, ServerBridgeProvider, SlotsProvider, TraitContext, TraitProvider, clearSchemaCache, createClientEffectHandlers, useEntityDefinition, useEntitySchema, useEntitySchemaOptional, useResolvedSchema, useServerBridge, useSlotContent, useSlots, useSlotsActions, useTrait, useTraitContext, useTraitStateMachine };