@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.
@@ -247,13 +247,13 @@ function SelectionProvider({
247
247
  unsubCancel();
248
248
  };
249
249
  }, [eventBus, setSelected, clearSelection, debug2]);
250
- const contextValue = {
250
+ const contextValue2 = {
251
251
  selected,
252
252
  setSelected,
253
253
  clearSelection,
254
254
  isSelected
255
255
  };
256
- return /* @__PURE__ */ jsxRuntime.jsx(SelectionContext.Provider, { value: contextValue, children });
256
+ return /* @__PURE__ */ jsxRuntime.jsx(SelectionContext.Provider, { value: contextValue2, children });
257
257
  }
258
258
  React117.createContext(null);
259
259
  var queryStores = /* @__PURE__ */ new Map();
@@ -282,27 +282,27 @@ function useQuerySingleton(query) {
282
282
  store2.listeners.delete(listener);
283
283
  };
284
284
  }, [store2]);
285
- const notifyListeners3 = React117.useCallback(() => {
285
+ const notifyListeners4 = React117.useCallback(() => {
286
286
  store2.listeners.forEach((listener) => listener());
287
287
  }, [store2]);
288
288
  const setSearch = React117.useCallback((value) => {
289
289
  store2.search = value;
290
- notifyListeners3();
291
- }, [store2, notifyListeners3]);
290
+ notifyListeners4();
291
+ }, [store2, notifyListeners4]);
292
292
  const setFilter = React117.useCallback((key, value) => {
293
293
  store2.filters = { ...store2.filters, [key]: value };
294
- notifyListeners3();
295
- }, [store2, notifyListeners3]);
294
+ notifyListeners4();
295
+ }, [store2, notifyListeners4]);
296
296
  const clearFilters = React117.useCallback(() => {
297
297
  store2.filters = {};
298
298
  store2.search = "";
299
- notifyListeners3();
300
- }, [store2, notifyListeners3]);
299
+ notifyListeners4();
300
+ }, [store2, notifyListeners4]);
301
301
  const setSort = React117.useCallback((field, direction) => {
302
302
  store2.sortField = field;
303
303
  store2.sortDirection = direction;
304
- notifyListeners3();
305
- }, [store2, notifyListeners3]);
304
+ notifyListeners4();
305
+ }, [store2, notifyListeners4]);
306
306
  return {
307
307
  search: store2.search,
308
308
  setSearch,
@@ -760,13 +760,13 @@ function EntitySchemaProvider({
760
760
  }
761
761
  return map;
762
762
  }, [entities]);
763
- const contextValue = React117.useMemo(
763
+ const contextValue2 = React117.useMemo(
764
764
  () => ({
765
765
  entities: entitiesMap
766
766
  }),
767
767
  [entitiesMap]
768
768
  );
769
- return /* @__PURE__ */ jsxRuntime.jsx(EntitySchemaContext.Provider, { value: contextValue, children });
769
+ return /* @__PURE__ */ jsxRuntime.jsx(EntitySchemaContext.Provider, { value: contextValue2, children });
770
770
  }
771
771
  function useEntitySchema() {
772
772
  const context = React117.useContext(EntitySchemaContext);
@@ -779,6 +779,9 @@ function useEntityDefinition(entityName) {
779
779
  const { entities } = useEntitySchema();
780
780
  return entities.get(entityName);
781
781
  }
782
+ function useEntitySchemaOptional() {
783
+ return React117.useContext(EntitySchemaContext);
784
+ }
782
785
 
783
786
  // lib/traitRegistry.ts
784
787
  var traits = /* @__PURE__ */ new Map();
@@ -1499,7 +1502,7 @@ function TraitProvider({
1499
1502
  }
1500
1503
  return map;
1501
1504
  }, [traitBindings]);
1502
- const contextValue = React117.useMemo(() => {
1505
+ const contextValue2 = React117.useMemo(() => {
1503
1506
  return {
1504
1507
  traits: traitInstances,
1505
1508
  getTrait: (name) => traitInstances.get(name),
@@ -1515,7 +1518,7 @@ function TraitProvider({
1515
1518
  }
1516
1519
  };
1517
1520
  }, [traitInstances]);
1518
- return /* @__PURE__ */ jsxRuntime.jsx(TraitContext.Provider, { value: contextValue, children });
1521
+ return /* @__PURE__ */ jsxRuntime.jsx(TraitContext.Provider, { value: contextValue2, children });
1519
1522
  }
1520
1523
  function useTraitContext() {
1521
1524
  const context = React117.useContext(TraitContext);
@@ -2084,7 +2087,7 @@ var ThemeProvider = ({
2084
2087
  const newMode = resolvedMode === "dark" ? "light" : "dark";
2085
2088
  setMode(newMode);
2086
2089
  }, [resolvedMode, setMode]);
2087
- const contextValue = React117.useMemo(
2090
+ const contextValue2 = React117.useMemo(
2088
2091
  () => ({
2089
2092
  theme,
2090
2093
  mode,
@@ -2106,7 +2109,7 @@ var ThemeProvider = ({
2106
2109
  appliedTheme
2107
2110
  ]
2108
2111
  );
2109
- return /* @__PURE__ */ jsxRuntime.jsx(ThemeContext.Provider, { value: contextValue, children });
2112
+ return /* @__PURE__ */ jsxRuntime.jsx(ThemeContext.Provider, { value: contextValue2, children });
2110
2113
  };
2111
2114
  function useTheme() {
2112
2115
  const context = React117.useContext(ThemeContext);
@@ -2130,25 +2133,92 @@ function useTheme() {
2130
2133
  var store = /* @__PURE__ */ new Map();
2131
2134
  var storeListeners = /* @__PURE__ */ new Set();
2132
2135
  var watchCallbacks = /* @__PURE__ */ new Map();
2133
- function advance(entityType, data) {
2134
- const prev = store.get(entityType);
2135
- const oldData = prev?.data ?? [];
2136
- store.set(entityType, { data, version: (prev?.version ?? 0) + 1 });
2136
+ function extractId(record) {
2137
+ const r = record;
2138
+ return String(r.id ?? r._id ?? r.key ?? "");
2139
+ }
2140
+ function materialize(snap) {
2141
+ return snap.ids.map((id) => snap.entities.get(id));
2142
+ }
2143
+ function notifyListeners3(entityType, prev) {
2137
2144
  for (const listener of storeListeners) {
2138
2145
  listener();
2139
2146
  }
2140
2147
  const cbs = watchCallbacks.get(entityType);
2141
2148
  if (cbs) {
2149
+ const oldData = prev ? materialize(prev) : [];
2150
+ const cur = store.get(entityType);
2151
+ const newData = cur ? materialize(cur) : [];
2142
2152
  for (const cb of cbs) {
2143
2153
  try {
2144
- cb(oldData, data);
2154
+ cb(oldData, newData);
2145
2155
  } catch {
2146
2156
  }
2147
2157
  }
2148
2158
  }
2149
2159
  }
2160
+ function setAll(entityType, records) {
2161
+ const entities = /* @__PURE__ */ new Map();
2162
+ const ids = [];
2163
+ for (const r of records) {
2164
+ const rec = r;
2165
+ const id = extractId(rec);
2166
+ if (id) {
2167
+ entities.set(id, rec);
2168
+ ids.push(id);
2169
+ }
2170
+ }
2171
+ const prev = store.get(entityType);
2172
+ store.set(entityType, { entities, ids, version: (prev?.version ?? 0) + 1 });
2173
+ notifyListeners3(entityType, prev);
2174
+ }
2175
+ function upsertOne(entityType, record) {
2176
+ const id = extractId(record);
2177
+ if (!id) return;
2178
+ const prev = store.get(entityType);
2179
+ const snapshot = prev ? { entities: new Map(prev.entities), ids: [...prev.ids], version: prev.version } : { entities: /* @__PURE__ */ new Map(), ids: [], version: 0 };
2180
+ snapshot.entities.set(id, record);
2181
+ if (!snapshot.ids.includes(id)) snapshot.ids.push(id);
2182
+ snapshot.version++;
2183
+ store.set(entityType, snapshot);
2184
+ notifyListeners3(entityType, prev);
2185
+ }
2186
+ function addOne(entityType, record) {
2187
+ upsertOne(entityType, record);
2188
+ }
2189
+ function updateOne(entityType, id, changes) {
2190
+ const prev = store.get(entityType);
2191
+ if (!prev?.entities.has(id)) return;
2192
+ const snapshot = {
2193
+ entities: new Map(prev.entities),
2194
+ ids: [...prev.ids],
2195
+ version: prev.version
2196
+ };
2197
+ snapshot.entities.set(id, { ...snapshot.entities.get(id), ...changes });
2198
+ snapshot.version++;
2199
+ store.set(entityType, snapshot);
2200
+ notifyListeners3(entityType, prev);
2201
+ }
2202
+ function removeOne(entityType, id) {
2203
+ const prev = store.get(entityType);
2204
+ if (!prev) return;
2205
+ const snapshot = {
2206
+ entities: new Map(prev.entities),
2207
+ ids: prev.ids.filter((i) => i !== id),
2208
+ version: prev.version
2209
+ };
2210
+ snapshot.entities.delete(id);
2211
+ snapshot.version++;
2212
+ store.set(entityType, snapshot);
2213
+ notifyListeners3(entityType, prev);
2214
+ }
2150
2215
  function getSnapshot3(entityType) {
2151
- return store.get(entityType)?.data ?? [];
2216
+ const snap = store.get(entityType);
2217
+ if (!snap) return [];
2218
+ return materialize(snap);
2219
+ }
2220
+ function getById(entityType, id) {
2221
+ return store.get(entityType)?.entities.get(id) ?? null;
2152
2222
  }
2153
2223
  function getVersion(entityType) {
2154
2224
  return store.get(entityType)?.version ?? 0;
@@ -2172,15 +2242,21 @@ function useEntityRef(entityType) {
2172
2242
  }, [entityType]);
2173
2243
  return React117.useSyncExternalStore(subscribeToStore, getSnapshotStable, () => []);
2174
2244
  }
2175
- var EntityStoreContext = React117.createContext({
2176
- advance,
2177
- getSnapshot: getSnapshot3
2178
- });
2245
+ var contextValue = {
2246
+ setAll,
2247
+ upsertOne,
2248
+ addOne,
2249
+ updateOne,
2250
+ removeOne,
2251
+ getSnapshot: getSnapshot3,
2252
+ getById
2253
+ };
2254
+ var EntityStoreContext = React117.createContext(contextValue);
2179
2255
  function useEntityStore() {
2180
2256
  return React117.useContext(EntityStoreContext);
2181
2257
  }
2182
2258
  function EntityStoreProvider({ children }) {
2183
- return /* @__PURE__ */ jsxRuntime.jsx(EntityStoreContext.Provider, { value: { advance, getSnapshot: getSnapshot3 }, children });
2259
+ return /* @__PURE__ */ jsxRuntime.jsx(EntityStoreContext.Provider, { value: contextValue, children });
2184
2260
  }
2185
2261
  var EventBusContext2 = React117.createContext(null);
2186
2262
  function EventBusProvider({ children, debug: debug2 = false }) {
@@ -2280,7 +2356,7 @@ function EventBusProvider({ children, debug: debug2 = false }) {
2280
2356
  }
2281
2357
  };
2282
2358
  }, [debug2]);
2283
- const contextValue = React117.useMemo(
2359
+ const contextValue2 = React117.useMemo(
2284
2360
  () => ({
2285
2361
  emit,
2286
2362
  on,
@@ -2293,12 +2369,12 @@ function EventBusProvider({ children, debug: debug2 = false }) {
2293
2369
  [emit, on, once, hasListeners, onAny, getSelectedEntity, clearSelectedEntity]
2294
2370
  );
2295
2371
  React117.useEffect(() => {
2296
- setGlobalEventBus(contextValue);
2372
+ setGlobalEventBus(contextValue2);
2297
2373
  return () => {
2298
2374
  setGlobalEventBus(null);
2299
2375
  };
2300
- }, [contextValue]);
2301
- return /* @__PURE__ */ jsxRuntime.jsx(EventBusContext2.Provider, { value: contextValue, children });
2376
+ }, [contextValue2]);
2377
+ return /* @__PURE__ */ jsxRuntime.jsx(EventBusContext2.Provider, { value: contextValue2, children });
2302
2378
  }
2303
2379
  var iconAliases = {
2304
2380
  "close": LucideIcons__namespace.X,
@@ -5507,9 +5583,9 @@ var shapeMap = {
5507
5583
  square: "rounded-md"
5508
5584
  };
5509
5585
  var variantMap = {
5510
- primary: "bg-blue-600 text-white border-blue-400 hover:bg-blue-500",
5511
- secondary: "bg-gray-700 text-white border-gray-500 hover:bg-gray-600",
5512
- ghost: "bg-transparent text-white border-white/30 hover:bg-white/10"
5586
+ primary: "bg-blue-600 text-[var(--color-foreground)] border-blue-400 hover:bg-blue-500",
5587
+ secondary: "bg-[var(--color-surface,#374151)] text-[var(--color-foreground)] border-gray-500 hover:bg-gray-600",
5588
+ ghost: "bg-transparent text-[var(--color-foreground)] border-white/30 hover:bg-white/10"
5513
5589
  };
5514
5590
  function ControlButton({
5515
5591
  label,
@@ -5738,11 +5814,11 @@ function TimerDisplay({
5738
5814
  {
5739
5815
  className: cn(
5740
5816
  "inline-flex items-center justify-center rounded-lg",
5741
- "bg-gray-800/80 border border-gray-600 font-mono font-bold tabular-nums",
5817
+ "bg-[var(--color-card)]/80 border border-gray-600 font-mono font-bold tabular-nums",
5742
5818
  sizeMap4[size],
5743
5819
  running && "border-green-500/50",
5744
5820
  isLow && "text-red-400 border-red-500/50 animate-pulse",
5745
- !isLow && "text-white",
5821
+ !isLow && "text-[var(--color-foreground)]",
5746
5822
  className
5747
5823
  ),
5748
5824
  children: formatTime(seconds, format)
@@ -5770,7 +5846,7 @@ function ResourceCounter({
5770
5846
  {
5771
5847
  className: cn(
5772
5848
  "inline-flex items-center rounded-md",
5773
- "bg-gray-800/80 border border-gray-600 font-medium text-white",
5849
+ "bg-[var(--color-card)]/80 border border-gray-600 font-medium text-[var(--color-foreground)]",
5774
5850
  sizes.wrapper,
5775
5851
  className
5776
5852
  ),
@@ -5829,9 +5905,9 @@ function ItemSlot({
5829
5905
  title: label,
5830
5906
  className: cn(
5831
5907
  "relative flex items-center justify-center rounded-lg border-2",
5832
- "bg-gray-800/80 transition-all duration-150",
5908
+ "bg-[var(--color-card)]/80 transition-all duration-150",
5833
5909
  sizeMap6[size],
5834
- empty ? "border-gray-700 bg-gray-900/50" : rarityBorderMap[rarity],
5910
+ empty ? "border-gray-700 bg-[var(--color-card)]/50" : rarityBorderMap[rarity],
5835
5911
  !empty && rarityGlowMap[rarity],
5836
5912
  selected && "ring-2 ring-white ring-offset-1 ring-offset-gray-900",
5837
5913
  isClickable && !empty && "hover:brightness-125 cursor-pointer",
@@ -5847,7 +5923,7 @@ function ItemSlot({
5847
5923
  className: cn(
5848
5924
  "absolute -bottom-1 -right-1 flex items-center justify-center",
5849
5925
  "min-w-[18px] h-[18px] rounded-full px-1",
5850
- "bg-gray-700 border border-gray-500 text-[10px] font-bold text-white"
5926
+ "bg-[var(--color-surface,#374151)] border border-gray-500 text-[10px] font-bold text-[var(--color-foreground)]"
5851
5927
  ),
5852
5928
  children: quantity
5853
5929
  }
@@ -5876,7 +5952,7 @@ function TurnIndicator({
5876
5952
  {
5877
5953
  className: cn(
5878
5954
  "inline-flex items-center rounded-lg",
5879
- "bg-gray-800/80 border border-gray-600 font-medium text-white",
5955
+ "bg-[var(--color-card)]/80 border border-gray-600 font-medium text-[var(--color-foreground)]",
5880
5956
  sizes.wrapper,
5881
5957
  className
5882
5958
  ),
@@ -5912,7 +5988,7 @@ function getComboIntensity(combo) {
5912
5988
  if (combo >= 10) return "text-red-400 animate-pulse";
5913
5989
  if (combo >= 7) return "text-orange-400";
5914
5990
  if (combo >= 4) return "text-yellow-400";
5915
- return "text-white";
5991
+ return "text-[var(--color-foreground)]";
5916
5992
  }
5917
5993
  function getComboScale(combo) {
5918
5994
  if (combo >= 10) return "scale-110";
@@ -5933,7 +6009,7 @@ function ComboCounter({
5933
6009
  {
5934
6010
  className: cn(
5935
6011
  "inline-flex flex-col items-center justify-center",
5936
- "rounded-xl bg-gray-800/80 border border-gray-600 px-3 py-1.5",
6012
+ "rounded-xl bg-[var(--color-card)]/80 border border-gray-600 px-3 py-1.5",
5937
6013
  "transition-transform duration-200",
5938
6014
  getComboScale(combo),
5939
6015
  className
@@ -6134,7 +6210,7 @@ function StatusEffect({
6134
6210
  "span",
6135
6211
  {
6136
6212
  className: cn(
6137
- "absolute flex items-center justify-center rounded-full bg-white text-black font-bold leading-none",
6213
+ "absolute flex items-center justify-center rounded-full bg-[var(--color-card)] text-[var(--color-foreground)] font-bold leading-none",
6138
6214
  sizes.badge
6139
6215
  ),
6140
6216
  children: stacks
@@ -6213,7 +6289,7 @@ function DialogueBubble({
6213
6289
  ) }),
6214
6290
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1 min-w-0", children: [
6215
6291
  speaker && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-bold text-yellow-400", children: speaker }),
6216
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-white leading-relaxed", children: text })
6292
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-[var(--color-foreground)] leading-relaxed", children: text })
6217
6293
  ] })
6218
6294
  ]
6219
6295
  }
@@ -6237,7 +6313,7 @@ function ChoiceButton({
6237
6313
  className: cn(
6238
6314
  "w-full text-left px-4 py-2.5 rounded-md border transition-all duration-150",
6239
6315
  "flex items-center gap-2",
6240
- 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",
6316
+ 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",
6241
6317
  disabled && "opacity-40 cursor-not-allowed hover:bg-white/5 hover:border-white/10",
6242
6318
  className
6243
6319
  ),
@@ -6293,7 +6369,7 @@ function ActionButton({
6293
6369
  disabled: isDisabled,
6294
6370
  onClick,
6295
6371
  className: cn(
6296
- "relative inline-flex items-center gap-1.5 rounded-md border font-medium text-white overflow-hidden transition-colors duration-150",
6372
+ "relative inline-flex items-center gap-1.5 rounded-md border font-medium text-[var(--color-foreground)] overflow-hidden transition-colors duration-150",
6297
6373
  sizes.button,
6298
6374
  variantStyles7[variant],
6299
6375
  isDisabled && "opacity-60 cursor-not-allowed",
@@ -8246,11 +8322,11 @@ var AuthLayout = ({
8246
8322
  children: [
8247
8323
  /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "absolute inset-0 bg-gradient-to-br from-primary-600/90 to-primary-800/90" }),
8248
8324
  /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "relative z-10", children: /* @__PURE__ */ jsxRuntime.jsxs(reactRouterDom.Link, { to: "/", className: "flex items-center gap-3", children: [
8249
- logo || /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "w-10 h-10 bg-white/20 rounded-xl flex items-center justify-center backdrop-blur", children: /* @__PURE__ */ jsxRuntime.jsx(
8325
+ logo || /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "w-10 h-10 bg-[var(--color-card)]/20 rounded-xl flex items-center justify-center backdrop-blur", children: /* @__PURE__ */ jsxRuntime.jsx(
8250
8326
  Typography,
8251
8327
  {
8252
8328
  variant: "body1",
8253
- className: "text-white font-bold text-lg",
8329
+ className: "text-[var(--color-foreground)] font-bold text-lg",
8254
8330
  children: appName.charAt(0).toUpperCase()
8255
8331
  }
8256
8332
  ) }),
@@ -8258,7 +8334,7 @@ var AuthLayout = ({
8258
8334
  Typography,
8259
8335
  {
8260
8336
  variant: "body1",
8261
- className: "text-2xl font-bold text-white",
8337
+ className: "text-2xl font-bold text-[var(--color-foreground)]",
8262
8338
  children: appName
8263
8339
  }
8264
8340
  )
@@ -8268,7 +8344,7 @@ var AuthLayout = ({
8268
8344
  Typography,
8269
8345
  {
8270
8346
  variant: "h1",
8271
- className: "text-4xl font-bold text-white leading-tight",
8347
+ className: "text-4xl font-bold text-[var(--color-foreground)] leading-tight",
8272
8348
  children: [
8273
8349
  "Welcome to ",
8274
8350
  appName
@@ -8279,27 +8355,27 @@ var AuthLayout = ({
8279
8355
  Typography,
8280
8356
  {
8281
8357
  variant: "body1",
8282
- className: "text-lg text-white/80 max-w-md",
8358
+ className: "text-lg text-[var(--color-foreground)]/80 max-w-md",
8283
8359
  children: "Sign in to access your dashboard and manage your account."
8284
8360
  }
8285
8361
  ),
8286
- /* @__PURE__ */ jsxRuntime.jsxs(Box, { className: "mt-12 p-6 bg-white/10 rounded-xl backdrop-blur", children: [
8362
+ /* @__PURE__ */ jsxRuntime.jsxs(Box, { className: "mt-12 p-6 bg-[var(--color-card)]/10 rounded-xl backdrop-blur", children: [
8287
8363
  /* @__PURE__ */ jsxRuntime.jsx(
8288
8364
  Typography,
8289
8365
  {
8290
8366
  variant: "body1",
8291
- className: "text-white/90 italic",
8367
+ className: "text-[var(--color-foreground)]/90 italic",
8292
8368
  children: '"This platform has transformed how we work. Highly recommended!"'
8293
8369
  }
8294
8370
  ),
8295
8371
  /* @__PURE__ */ jsxRuntime.jsxs(HStack, { className: "mt-4", gap: "sm", align: "center", children: [
8296
- /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "w-10 h-10 bg-white/20 rounded-full" }),
8372
+ /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "w-10 h-10 bg-[var(--color-card)]/20 rounded-full" }),
8297
8373
  /* @__PURE__ */ jsxRuntime.jsxs(VStack, { gap: "none", children: [
8298
8374
  /* @__PURE__ */ jsxRuntime.jsx(
8299
8375
  Typography,
8300
8376
  {
8301
8377
  variant: "body1",
8302
- className: "text-white font-medium",
8378
+ className: "text-[var(--color-foreground)] font-medium",
8303
8379
  children: "Jane Doe"
8304
8380
  }
8305
8381
  ),
@@ -8307,7 +8383,7 @@ var AuthLayout = ({
8307
8383
  Typography,
8308
8384
  {
8309
8385
  variant: "body1",
8310
- className: "text-white/60 text-sm",
8386
+ className: "text-[var(--color-foreground)]/60 text-sm",
8311
8387
  children: "CEO, Example Co."
8312
8388
  }
8313
8389
  )
@@ -8315,8 +8391,8 @@ var AuthLayout = ({
8315
8391
  ] })
8316
8392
  ] })
8317
8393
  ] }) }),
8318
- /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "absolute -bottom-32 -right-32 w-96 h-96 bg-white/5 rounded-full" }),
8319
- /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "absolute -top-16 -right-16 w-64 h-64 bg-white/5 rounded-full" })
8394
+ /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "absolute -bottom-32 -right-32 w-96 h-96 bg-[var(--color-card)]/5 rounded-full" }),
8395
+ /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "absolute -top-16 -right-16 w-64 h-64 bg-[var(--color-card)]/5 rounded-full" })
8320
8396
  ]
8321
8397
  }
8322
8398
  ),
@@ -8333,7 +8409,7 @@ var AuthLayout = ({
8333
8409
  Typography,
8334
8410
  {
8335
8411
  variant: "body1",
8336
- className: "text-white font-bold text-xl",
8412
+ className: "text-[var(--color-foreground)] font-bold text-xl",
8337
8413
  children: appName.charAt(0).toUpperCase()
8338
8414
  }
8339
8415
  ) }),
@@ -9204,7 +9280,7 @@ function IsometricCanvas({
9204
9280
  className: cn("relative w-full overflow-hidden rounded-lg", className),
9205
9281
  style: { height: viewportSize.height },
9206
9282
  "data-testid": "game-canvas-empty",
9207
- children: /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "flex items-center justify-center h-full bg-slate-800 rounded-lg", children: /* @__PURE__ */ jsxRuntime.jsxs(Stack, { direction: "vertical", gap: "md", align: "center", children: [
9283
+ children: /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "flex items-center justify-center h-full bg-[var(--color-card)] rounded-lg", children: /* @__PURE__ */ jsxRuntime.jsxs(Stack, { direction: "vertical", gap: "md", align: "center", children: [
9208
9284
  /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "map", size: "xl" }),
9209
9285
  /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "body", className: "text-slate-400", children: t("canvas.emptyMessage") || "No map data loaded" })
9210
9286
  ] }) })
@@ -9789,7 +9865,7 @@ var MarkdownContent = React117__namespace.default.memo(
9789
9865
  "th",
9790
9866
  {
9791
9867
  ...props,
9792
- className: "border border-gray-300 dark:border-gray-600 bg-gray-100 dark:bg-gray-800 px-4 py-2 text-left font-semibold",
9868
+ className: "border border-gray-300 dark:border-gray-600 bg-[var(--color-muted)] px-4 py-2 text-left font-semibold",
9793
9869
  children
9794
9870
  }
9795
9871
  );
@@ -9870,6 +9946,42 @@ var orbStyleOverrides = {
9870
9946
  "orb-op-async": { color: syntax.ORB_COLORS.dark.async }
9871
9947
  };
9872
9948
  var orbStyle = { ...dark__default.default, ...orbStyleOverrides };
9949
+ function computeFoldRegions(code) {
9950
+ const lines = code.split("\n");
9951
+ const regions = [];
9952
+ const stack = [];
9953
+ for (let i = 0; i < lines.length; i++) {
9954
+ const line = lines[i];
9955
+ let inString = false;
9956
+ for (let j = 0; j < line.length; j++) {
9957
+ const ch = line[j];
9958
+ if (ch === "\\" && inString) {
9959
+ j++;
9960
+ continue;
9961
+ }
9962
+ if (ch === '"') {
9963
+ inString = !inString;
9964
+ continue;
9965
+ }
9966
+ if (inString) continue;
9967
+ if (ch === "{" || ch === "[") {
9968
+ stack.push({ line: i, bracket: ch });
9969
+ } else if (ch === "}" || ch === "]") {
9970
+ const open = stack.pop();
9971
+ if (open && open.line < i) {
9972
+ regions.push({
9973
+ start: open.line,
9974
+ end: i,
9975
+ closeBracket: ch
9976
+ });
9977
+ }
9978
+ }
9979
+ }
9980
+ }
9981
+ return regions.sort((a, b) => a.start - b.start);
9982
+ }
9983
+ var LINE_PROPS_FN = (n) => ({ "data-line": String(n - 1) });
9984
+ var HIDDEN_LINE_NUMBERS = { display: "none" };
9873
9985
  var CodeBlock = React117__namespace.default.memo(
9874
9986
  ({
9875
9987
  code: rawCode,
@@ -9877,6 +9989,7 @@ var CodeBlock = React117__namespace.default.memo(
9877
9989
  showCopyButton = true,
9878
9990
  showLanguageBadge = true,
9879
9991
  maxHeight = "60vh",
9992
+ foldable: foldableProp,
9880
9993
  className
9881
9994
  }) => {
9882
9995
  const code = typeof rawCode === "string" ? rawCode : String(rawCode ?? "");
@@ -9885,8 +9998,114 @@ var CodeBlock = React117__namespace.default.memo(
9885
9998
  const eventBus = useEventBus();
9886
9999
  const { t: _t } = useTranslate();
9887
10000
  const scrollRef = React117.useRef(null);
10001
+ const codeRef = React117.useRef(null);
9888
10002
  const savedScrollLeftRef = React117.useRef(0);
9889
10003
  const [copied, setCopied] = React117.useState(false);
10004
+ const isFoldable = foldableProp ?? (language === "orb" || language === "json");
10005
+ const [collapsed, setCollapsed] = React117.useState(() => /* @__PURE__ */ new Set());
10006
+ const foldRegions = React117.useMemo(
10007
+ () => isFoldable ? computeFoldRegions(code) : [],
10008
+ [code, isFoldable]
10009
+ );
10010
+ const foldStartMap = React117.useMemo(() => {
10011
+ const m = /* @__PURE__ */ new Map();
10012
+ for (const r of foldRegions) m.set(r.start, r);
10013
+ return m;
10014
+ }, [foldRegions]);
10015
+ const hiddenLines = React117.useMemo(() => {
10016
+ const h = /* @__PURE__ */ new Set();
10017
+ for (const r of foldRegions) {
10018
+ if (!collapsed.has(r.start)) continue;
10019
+ for (let i = r.start + 1; i <= r.end; i++) h.add(i);
10020
+ }
10021
+ return h;
10022
+ }, [foldRegions, collapsed]);
10023
+ const collapsedRef = React117.useRef(collapsed);
10024
+ collapsedRef.current = collapsed;
10025
+ const foldStartMapRef = React117.useRef(foldStartMap);
10026
+ foldStartMapRef.current = foldStartMap;
10027
+ const toggleFold = React117.useCallback((lineNum) => {
10028
+ setCollapsed((prev) => {
10029
+ const next = new Set(prev);
10030
+ if (next.has(lineNum)) next.delete(lineNum);
10031
+ else next.add(lineNum);
10032
+ return next;
10033
+ });
10034
+ }, []);
10035
+ const toggleFoldRef = React117.useRef(toggleFold);
10036
+ toggleFoldRef.current = toggleFold;
10037
+ React117.useEffect(() => {
10038
+ setCollapsed(/* @__PURE__ */ new Set());
10039
+ }, [code]);
10040
+ const highlightedElement = React117.useMemo(
10041
+ () => /* @__PURE__ */ jsxRuntime.jsx(
10042
+ SyntaxHighlighter__default.default,
10043
+ {
10044
+ PreTag: "div",
10045
+ language,
10046
+ style: activeStyle,
10047
+ wrapLines: true,
10048
+ showLineNumbers: true,
10049
+ showInlineLineNumbers: false,
10050
+ lineNumberContainerStyle: HIDDEN_LINE_NUMBERS,
10051
+ lineProps: LINE_PROPS_FN,
10052
+ customStyle: {
10053
+ backgroundColor: "transparent",
10054
+ borderRadius: 0,
10055
+ padding: 0,
10056
+ margin: 0,
10057
+ whiteSpace: "pre",
10058
+ minWidth: "100%"
10059
+ },
10060
+ children: code
10061
+ }
10062
+ ),
10063
+ [code, language, activeStyle]
10064
+ );
10065
+ React117.useLayoutEffect(() => {
10066
+ const container = codeRef.current;
10067
+ if (!container) return;
10068
+ container.querySelectorAll(".fold-toggle, .fold-summary").forEach((el) => el.remove());
10069
+ const lineEls = container.querySelectorAll("[data-line]");
10070
+ if (!isFoldable || foldRegions.length === 0) {
10071
+ lineEls.forEach((el) => {
10072
+ el.style.display = "";
10073
+ el.style.position = "";
10074
+ el.style.paddingLeft = "";
10075
+ });
10076
+ return;
10077
+ }
10078
+ lineEls.forEach((el) => {
10079
+ const num = parseInt(el.getAttribute("data-line") ?? "-1", 10);
10080
+ if (hiddenLines.has(num)) {
10081
+ el.style.display = "none";
10082
+ return;
10083
+ }
10084
+ el.style.display = "";
10085
+ el.style.position = "relative";
10086
+ el.style.paddingLeft = "1.2em";
10087
+ const region = foldStartMap.get(num);
10088
+ if (!region) return;
10089
+ const isCollapsed = collapsed.has(num);
10090
+ const toggle = document.createElement("span");
10091
+ toggle.className = "fold-toggle";
10092
+ toggle.textContent = isCollapsed ? "\u25B6" : "\u25BC";
10093
+ 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%";
10094
+ toggle.addEventListener("click", (e) => {
10095
+ e.stopPropagation();
10096
+ toggleFoldRef.current(num);
10097
+ });
10098
+ el.insertBefore(toggle, el.firstChild);
10099
+ if (isCollapsed) {
10100
+ const summary = document.createElement("span");
10101
+ summary.className = "fold-summary";
10102
+ summary.style.cssText = "color:#858585;font-style:italic";
10103
+ const count = region.end - region.start - 1;
10104
+ summary.textContent = ` ... ${count} line${count !== 1 ? "s" : ""} ${region.closeBracket}`;
10105
+ el.appendChild(summary);
10106
+ }
10107
+ });
10108
+ }, [collapsed, hiddenLines, foldStartMap, foldRegions, isFoldable]);
9890
10109
  React117.useLayoutEffect(() => {
9891
10110
  const el = scrollRef.current;
9892
10111
  return () => {
@@ -9917,13 +10136,14 @@ var CodeBlock = React117__namespace.default.memo(
9917
10136
  eventBus.emit("UI:COPY_CODE", { language, success: false });
9918
10137
  }
9919
10138
  };
10139
+ const hasHeader = showLanguageBadge || showCopyButton;
9920
10140
  return /* @__PURE__ */ jsxRuntime.jsxs(Box, { className: `relative group ${className || ""}`, children: [
9921
- (showLanguageBadge || showCopyButton) && /* @__PURE__ */ jsxRuntime.jsxs(
10141
+ hasHeader && /* @__PURE__ */ jsxRuntime.jsxs(
9922
10142
  HStack,
9923
10143
  {
9924
10144
  justify: "between",
9925
10145
  align: "center",
9926
- className: "px-3 py-2 bg-gray-800 rounded-t-lg border-b border-gray-700",
10146
+ className: "px-3 py-2 bg-[var(--color-card)] rounded-t-lg border-b border-gray-700",
9927
10147
  children: [
9928
10148
  showLanguageBadge && /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "default", size: "sm", children: language }),
9929
10149
  showCopyButton && /* @__PURE__ */ jsxRuntime.jsx(
@@ -9953,31 +10173,14 @@ var CodeBlock = React117__namespace.default.memo(
9953
10173
  touchAction: "pan-x pan-y",
9954
10174
  contain: "paint",
9955
10175
  backgroundColor: "#1e1e1e",
9956
- borderRadius: showLanguageBadge || showCopyButton ? "0 0 0.5rem 0.5rem" : "0.5rem",
9957
- padding: "1rem"
10176
+ borderRadius: hasHeader ? "0 0 0.5rem 0.5rem" : "0.5rem"
9958
10177
  },
9959
- children: /* @__PURE__ */ jsxRuntime.jsx(
9960
- SyntaxHighlighter__default.default,
9961
- {
9962
- PreTag: "div",
9963
- language,
9964
- style: activeStyle,
9965
- customStyle: {
9966
- backgroundColor: "transparent",
9967
- borderRadius: 0,
9968
- padding: 0,
9969
- margin: 0,
9970
- whiteSpace: "pre",
9971
- minWidth: "100%"
9972
- },
9973
- children: code
9974
- }
9975
- )
10178
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref: codeRef, style: { padding: "1rem" }, children: highlightedElement })
9976
10179
  }
9977
10180
  )
9978
10181
  ] });
9979
10182
  },
9980
- (prev, next) => prev.language === next.language && prev.code === next.code && prev.showCopyButton === next.showCopyButton && prev.maxHeight === next.maxHeight
10183
+ (prev, next) => prev.language === next.language && prev.code === next.code && prev.showCopyButton === next.showCopyButton && prev.maxHeight === next.maxHeight && prev.foldable === next.foldable
9981
10184
  );
9982
10185
  CodeBlock.displayName = "CodeBlock";
9983
10186
  function Card2({
@@ -19196,7 +19399,7 @@ var sizeMap17 = {
19196
19399
  lg: "text-base px-4 py-2"
19197
19400
  };
19198
19401
  var variantMap2 = {
19199
- default: "bg-gray-800/80 border-gray-700",
19402
+ default: "bg-[var(--color-card)]/80 border-gray-700",
19200
19403
  primary: "bg-blue-900/80 border-blue-700",
19201
19404
  success: "bg-green-900/80 border-green-700",
19202
19405
  warning: "bg-yellow-900/80 border-yellow-700",
@@ -19257,7 +19460,7 @@ function StatBadge({
19257
19460
  animated: true
19258
19461
  }
19259
19462
  ),
19260
- format === "text" && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-bold text-white", children: value })
19463
+ format === "text" && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-bold text-[var(--color-foreground)]", children: value })
19261
19464
  ]
19262
19465
  }
19263
19466
  );
@@ -19530,7 +19733,7 @@ function HealthPanel({
19530
19733
  Box,
19531
19734
  {
19532
19735
  className: cn(
19533
- "rounded-lg bg-gray-900/90 border border-gray-700 backdrop-blur-sm",
19736
+ "rounded-lg bg-[var(--color-card)]/90 border border-gray-700 backdrop-blur-sm",
19534
19737
  sizes.padding,
19535
19738
  className
19536
19739
  ),
@@ -19632,7 +19835,7 @@ function ScoreBoard({
19632
19835
  Card,
19633
19836
  {
19634
19837
  className: cn(
19635
- "bg-gray-900/90 border-gray-700 backdrop-blur-sm",
19838
+ "bg-[var(--color-card)]/90 border-gray-700 backdrop-blur-sm",
19636
19839
  className
19637
19840
  ),
19638
19841
  children: /* @__PURE__ */ jsxRuntime.jsx(CardContent, { className: "p-3", children: /* @__PURE__ */ jsxRuntime.jsxs(Box, { className: "flex items-center gap-3 flex-wrap", children: [
@@ -19731,7 +19934,7 @@ function TurnPanel({
19731
19934
  Box,
19732
19935
  {
19733
19936
  className: cn(
19734
- "flex items-center gap-3 rounded-lg bg-gray-900/90 border border-gray-700 backdrop-blur-sm px-3 py-2",
19937
+ "flex items-center gap-3 rounded-lg bg-[var(--color-card)]/90 border border-gray-700 backdrop-blur-sm px-3 py-2",
19735
19938
  className
19736
19939
  ),
19737
19940
  children: [
@@ -19778,7 +19981,7 @@ function EnemyPlate({
19778
19981
  Box,
19779
19982
  {
19780
19983
  className: cn(
19781
- "inline-flex flex-col gap-1 rounded-lg bg-gray-900/90 border border-gray-700 backdrop-blur-sm px-3 py-1.5",
19984
+ "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",
19782
19985
  "min-w-[120px]",
19783
19986
  className
19784
19987
  ),
@@ -19789,7 +19992,7 @@ function EnemyPlate({
19789
19992
  {
19790
19993
  variant: "caption",
19791
19994
  weight: "bold",
19792
- className: "text-white truncate",
19995
+ className: "text-[var(--color-foreground)] truncate",
19793
19996
  children: name
19794
19997
  }
19795
19998
  ),
@@ -19856,7 +20059,7 @@ function UnitCommandBar({
19856
20059
  Box,
19857
20060
  {
19858
20061
  className: cn(
19859
- "flex items-center gap-1.5 rounded-lg bg-gray-900/90 border border-gray-700 backdrop-blur-sm px-2 py-1.5",
20062
+ "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",
19860
20063
  className
19861
20064
  ),
19862
20065
  children: commands.map((command, i) => /* @__PURE__ */ jsxRuntime.jsxs(Box, { className: "flex flex-col items-center gap-0.5", children: [
@@ -20083,7 +20286,7 @@ function DialogueBox({
20083
20286
  tabIndex: 0,
20084
20287
  role: "dialog",
20085
20288
  "aria-label": "Dialogue",
20086
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mx-4 my-4 bg-gray-900 bg-opacity-95 border-2 border-gray-600 rounded-lg overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex", children: [
20289
+ children: /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsxs("div", { className: "flex", children: [
20087
20290
  dialogue.portrait && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-shrink-0 p-4 border-r border-gray-700", children: /* @__PURE__ */ jsxRuntime.jsx(
20088
20291
  "img",
20089
20292
  {
@@ -20095,7 +20298,7 @@ function DialogueBox({
20095
20298
  ) }),
20096
20299
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 p-4", children: [
20097
20300
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-yellow-400 font-bold mb-2", children: dialogue.speaker }),
20098
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-white text-lg leading-relaxed min-h-[60px]", children: [
20301
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-[var(--color-foreground)] text-lg leading-relaxed min-h-[60px]", children: [
20099
20302
  displayedText,
20100
20303
  isTyping && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "animate-pulse", children: "\u258C" })
20101
20304
  ] }),
@@ -20105,8 +20308,8 @@ function DialogueBox({
20105
20308
  type: "button",
20106
20309
  className: cn(
20107
20310
  "block w-full text-left px-4 py-2 rounded transition-colors",
20108
- "hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-yellow-400",
20109
- selectedChoice === index ? "bg-gray-700 text-yellow-400" : "bg-gray-800 text-white"
20311
+ "hover:bg-[var(--color-surface,#374151)] focus:outline-none focus:ring-2 focus:ring-yellow-400",
20312
+ selectedChoice === index ? "bg-[var(--color-surface,#374151)] text-yellow-400" : "bg-[var(--color-card)] text-[var(--color-foreground)]"
20110
20313
  ),
20111
20314
  onClick: (e) => {
20112
20315
  e.stopPropagation();
@@ -20219,7 +20422,7 @@ function InventoryPanel({
20219
20422
  /* @__PURE__ */ jsxRuntime.jsx(
20220
20423
  "div",
20221
20424
  {
20222
- className: "grid gap-1 bg-gray-900 p-2 rounded-lg border border-gray-700",
20425
+ className: "grid gap-1 bg-[var(--color-card)] p-2 rounded-lg border border-gray-700",
20223
20426
  style: {
20224
20427
  gridTemplateColumns: `repeat(${safeColumns}, ${slotSize}px)`,
20225
20428
  gridTemplateRows: `repeat(${rows}, ${slotSize}px)`
@@ -20230,9 +20433,9 @@ function InventoryPanel({
20230
20433
  type: "button",
20231
20434
  className: cn(
20232
20435
  "relative flex items-center justify-center",
20233
- "bg-gray-800 border rounded transition-colors",
20234
- "hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500",
20235
- selectedSlot === index ? "border-yellow-400 bg-gray-700" : "border-gray-600"
20436
+ "bg-[var(--color-card)] border rounded transition-colors",
20437
+ "hover:bg-[var(--color-surface,#374151)] focus:outline-none focus:ring-2 focus:ring-blue-500",
20438
+ selectedSlot === index ? "border-yellow-400 bg-[var(--color-surface,#374151)]" : "border-gray-600"
20236
20439
  ),
20237
20440
  style: { width: slotSize, height: slotSize },
20238
20441
  onClick: () => handleSlotClick(index),
@@ -20262,14 +20465,14 @@ function InventoryPanel({
20262
20465
  showTooltips && hoveredItem && /* @__PURE__ */ jsxRuntime.jsxs(
20263
20466
  "div",
20264
20467
  {
20265
- className: "fixed z-50 bg-gray-900 border border-gray-600 rounded-lg p-2 shadow-lg pointer-events-none",
20468
+ className: "fixed z-50 bg-[var(--color-card)] border border-gray-600 rounded-lg p-2 shadow-lg pointer-events-none",
20266
20469
  style: {
20267
20470
  left: tooltipPosition.x,
20268
20471
  top: tooltipPosition.y,
20269
20472
  maxWidth: 200
20270
20473
  },
20271
20474
  children: [
20272
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-semibold text-white", children: hoveredItem.name || hoveredItem.type }),
20475
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-semibold text-[var(--color-foreground)]", children: hoveredItem.name || hoveredItem.type }),
20273
20476
  hoveredItem.description && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-gray-400 mt-1", children: hoveredItem.description }),
20274
20477
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-xs text-gray-500 mt-1", children: [
20275
20478
  "Quantity: ",
@@ -20281,9 +20484,9 @@ function InventoryPanel({
20281
20484
  ] });
20282
20485
  }
20283
20486
  var variantMap3 = {
20284
- primary: "bg-blue-600 hover:bg-blue-500 text-white border-blue-400 shadow-lg shadow-blue-500/25",
20285
- secondary: "bg-gray-700 hover:bg-gray-600 text-white border-gray-500",
20286
- ghost: "bg-transparent hover:bg-white/10 text-white border-white/20"
20487
+ primary: "bg-[var(--color-primary)] hover:bg-blue-500 text-[var(--color-primary-foreground)] border-blue-400 shadow-lg shadow-blue-500/25",
20488
+ secondary: "bg-[var(--color-surface,#374151)] hover:bg-gray-600 text-[var(--color-foreground)] border-gray-500",
20489
+ ghost: "bg-transparent hover:bg-white/10 text-[var(--color-foreground)] border-white/20"
20287
20490
  };
20288
20491
  function GameMenu({
20289
20492
  title,
@@ -20340,7 +20543,7 @@ function GameMenu({
20340
20543
  /* @__PURE__ */ jsxRuntime.jsx(
20341
20544
  "h1",
20342
20545
  {
20343
- className: "text-5xl md:text-7xl font-bold text-white tracking-tight",
20546
+ className: "text-5xl md:text-7xl font-bold text-[var(--color-foreground)] tracking-tight",
20344
20547
  style: {
20345
20548
  textShadow: "0 4px 12px rgba(0,0,0,0.5)"
20346
20549
  },
@@ -20396,9 +20599,9 @@ var variantColors = {
20396
20599
  }
20397
20600
  };
20398
20601
  var buttonVariants = {
20399
- primary: "bg-blue-600 hover:bg-blue-500 text-white border-blue-400",
20400
- secondary: "bg-gray-700 hover:bg-gray-600 text-white border-gray-500",
20401
- ghost: "bg-transparent hover:bg-white/10 text-white border-white/20"
20602
+ primary: "bg-[var(--color-primary)] hover:bg-blue-500 text-[var(--color-primary-foreground)] border-blue-400",
20603
+ secondary: "bg-[var(--color-surface,#374151)] hover:bg-gray-600 text-[var(--color-foreground)] border-gray-500",
20604
+ ghost: "bg-transparent hover:bg-white/10 text-[var(--color-foreground)] border-white/20"
20402
20605
  };
20403
20606
  function formatTime3(ms) {
20404
20607
  const seconds = Math.floor(ms / 1e3);
@@ -20479,7 +20682,7 @@ function GameOverScreen({
20479
20682
  }
20480
20683
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center", children: [
20481
20684
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-gray-400 text-sm mb-1", children: stat.label }),
20482
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-white text-2xl font-bold flex items-center justify-center gap-2", children: [
20685
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-[var(--color-foreground)] text-2xl font-bold flex items-center justify-center gap-2", children: [
20483
20686
  stat.icon && /* @__PURE__ */ jsxRuntime.jsx("span", { children: stat.icon }),
20484
20687
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "tabular-nums", children: displayValue })
20485
20688
  ] })
@@ -21650,7 +21853,7 @@ var Lightbox = ({
21650
21853
  className: cn(
21651
21854
  "absolute top-4 right-4 z-10",
21652
21855
  "p-2 rounded-full",
21653
- "text-white bg-black bg-opacity-50",
21856
+ "text-[var(--color-foreground)] bg-[var(--color-card)]",
21654
21857
  "hover:bg-opacity-70 transition-opacity",
21655
21858
  "focus:outline-none focus:ring-2 focus:ring-white"
21656
21859
  ),
@@ -21669,7 +21872,7 @@ var Lightbox = ({
21669
21872
  className: cn(
21670
21873
  "absolute left-4 z-10",
21671
21874
  "p-2 rounded-full",
21672
- "text-white bg-black bg-opacity-50",
21875
+ "text-[var(--color-foreground)] bg-[var(--color-card)]",
21673
21876
  "hover:bg-opacity-70 transition-opacity",
21674
21877
  "focus:outline-none focus:ring-2 focus:ring-white"
21675
21878
  ),
@@ -21706,7 +21909,7 @@ var Lightbox = ({
21706
21909
  className: cn(
21707
21910
  "absolute right-4 z-10",
21708
21911
  "p-2 rounded-full",
21709
- "text-white bg-black bg-opacity-50",
21912
+ "text-[var(--color-foreground)] bg-[var(--color-card)]",
21710
21913
  "hover:bg-opacity-70 transition-opacity",
21711
21914
  "focus:outline-none focus:ring-2 focus:ring-white"
21712
21915
  ),
@@ -21715,12 +21918,12 @@ var Lightbox = ({
21715
21918
  }
21716
21919
  ),
21717
21920
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "absolute bottom-4 left-0 right-0 text-center", children: [
21718
- showCounter && safeImages.length > 1 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-white text-sm mb-1", children: [
21921
+ showCounter && safeImages.length > 1 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-[var(--color-foreground)] text-sm mb-1", children: [
21719
21922
  index + 1,
21720
21923
  " of ",
21721
21924
  safeImages.length
21722
21925
  ] }),
21723
- currentImage?.caption && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-white text-sm opacity-80 px-8", children: currentImage.caption })
21926
+ currentImage?.caption && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-[var(--color-foreground)] text-sm opacity-80 px-8", children: currentImage.caption })
21724
21927
  ] })
21725
21928
  ]
21726
21929
  }
@@ -27295,6 +27498,254 @@ function onDebugToggle(listener) {
27295
27498
  listeners5.add(listener);
27296
27499
  return () => listeners5.delete(listener);
27297
27500
  }
27501
+ function layoutGraph(states, transitions, initialState, width, height) {
27502
+ if (states.length === 0) return [];
27503
+ const layers = /* @__PURE__ */ new Map();
27504
+ const queue = [initialState];
27505
+ layers.set(initialState, 0);
27506
+ while (queue.length > 0) {
27507
+ const current = queue.shift();
27508
+ const layer = layers.get(current);
27509
+ for (const tr of transitions) {
27510
+ if (tr.from === current && !layers.has(tr.to)) {
27511
+ layers.set(tr.to, layer + 1);
27512
+ queue.push(tr.to);
27513
+ }
27514
+ }
27515
+ }
27516
+ for (const s of states) {
27517
+ if (!layers.has(s)) layers.set(s, layers.size > 0 ? Math.max(...layers.values()) + 1 : 0);
27518
+ }
27519
+ const layerGroups = /* @__PURE__ */ new Map();
27520
+ for (const [state, layer] of layers) {
27521
+ const group = layerGroups.get(layer) ?? [];
27522
+ group.push(state);
27523
+ layerGroups.set(layer, group);
27524
+ }
27525
+ const maxLayer = Math.max(...layerGroups.keys(), 0);
27526
+ const padX = 24;
27527
+ const padY = 20;
27528
+ const usableW = width - padX * 2;
27529
+ const usableH = height - padY * 2;
27530
+ const positions = [];
27531
+ for (const [layer, group] of layerGroups) {
27532
+ const y = maxLayer === 0 ? usableH / 2 + padY : padY + layer / maxLayer * usableH;
27533
+ for (let i = 0; i < group.length; i++) {
27534
+ const x = group.length === 1 ? width / 2 : padX + i / (group.length - 1) * usableW;
27535
+ positions.push({ x, y, state: group[i] });
27536
+ }
27537
+ }
27538
+ return positions;
27539
+ }
27540
+ function WalkMinimap() {
27541
+ const [walkStep, setWalkStep] = React117__namespace.useState(null);
27542
+ const [traits2, setTraits] = React117__namespace.useState([]);
27543
+ const [coveredEdges, setCoveredEdges] = React117__namespace.useState([]);
27544
+ const [completedTraits, setCompletedTraits] = React117__namespace.useState(/* @__PURE__ */ new Set());
27545
+ const prevTraitRef = React117__namespace.useRef(null);
27546
+ React117__namespace.useEffect(() => {
27547
+ const interval = setInterval(() => {
27548
+ const w = window;
27549
+ const step = w.__orbitalWalkStep;
27550
+ const traitConfigs = w.__orbitalWalkTraits;
27551
+ const edges = w.__orbitalCoveredEdges;
27552
+ if (step) setWalkStep(step);
27553
+ if (traitConfigs) setTraits(traitConfigs);
27554
+ if (edges) setCoveredEdges(edges);
27555
+ if (step && prevTraitRef.current && prevTraitRef.current !== step.traitName) {
27556
+ setCompletedTraits((prev) => new Set(prev).add(prevTraitRef.current));
27557
+ }
27558
+ if (step) prevTraitRef.current = step.traitName;
27559
+ }, 250);
27560
+ return () => clearInterval(interval);
27561
+ }, []);
27562
+ if (!walkStep || traits2.length === 0) return null;
27563
+ const activeTrait = traits2.find((t) => t.name === walkStep.traitName);
27564
+ const engineCount = coveredEdges.filter((e) => e.phase === "engine").length;
27565
+ const domCount = coveredEdges.filter((e) => e.phase === "dom").length;
27566
+ const totalTransitions = traits2.reduce((sum, t) => sum + t.transitions.length, 0);
27567
+ const activeEdgeKeys = new Set(
27568
+ coveredEdges.filter((e) => e.trait === walkStep.traitName).map((e) => `${e.from}+${e.event}->${e.to}`)
27569
+ );
27570
+ const activeEdgePhases = new Map(
27571
+ coveredEdges.filter((e) => e.trait === walkStep.traitName).map((e) => [`${e.from}+${e.event}->${e.to}`, e.phase])
27572
+ );
27573
+ const currentEdgeKey = `${walkStep.from}+${walkStep.event}->${walkStep.to}`;
27574
+ const graphW = 260;
27575
+ const graphH = 120;
27576
+ const nodeR = 10;
27577
+ const positions = activeTrait ? layoutGraph(activeTrait.states, activeTrait.transitions, activeTrait.initialState, graphW, graphH) : [];
27578
+ const posMap = new Map(positions.map((p2) => [p2.state, p2]));
27579
+ const visitedStates = new Set(
27580
+ coveredEdges.filter((e) => e.trait === walkStep.traitName).flatMap((e) => [e.from, e.to])
27581
+ );
27582
+ return /* @__PURE__ */ jsxRuntime.jsxs(VStack, { gap: "none", className: "w-64 flex-shrink-0 border-l border-border bg-[var(--color-card)] overflow-hidden", children: [
27583
+ /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "px-2 py-1.5 border-b border-border overflow-x-auto", children: /* @__PURE__ */ jsxRuntime.jsx(HStack, { gap: "xs", className: "flex-nowrap", children: traits2.map((t) => {
27584
+ const isDone = completedTraits.has(t.name);
27585
+ const isActive = t.name === walkStep.traitName;
27586
+ const variant = isDone ? "success" : isActive ? "info" : "neutral";
27587
+ const shortName = t.name.replace(/^[A-Z][a-z]+/, "");
27588
+ return /* @__PURE__ */ jsxRuntime.jsxs(
27589
+ Badge,
27590
+ {
27591
+ variant,
27592
+ size: "sm",
27593
+ className: `flex-shrink-0 text-[9px] ${isActive ? "ring-1 ring-cyan-400" : ""}`,
27594
+ children: [
27595
+ isDone ? "\u2713" : isActive ? "\u25CF" : "\u25CB",
27596
+ " ",
27597
+ shortName || t.name
27598
+ ]
27599
+ },
27600
+ t.name
27601
+ );
27602
+ }) }) }),
27603
+ /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "flex-1 flex items-center justify-center px-1 py-1", children: activeTrait && /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: graphW, height: graphH, viewBox: `0 0 ${graphW} ${graphH}`, children: [
27604
+ /* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
27605
+ /* @__PURE__ */ jsxRuntime.jsx("marker", { id: "mm-arrow", markerWidth: "6", markerHeight: "4", refX: "6", refY: "2", orient: "auto", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M0,0 L6,2 L0,4", fill: "#888" }) }),
27606
+ /* @__PURE__ */ jsxRuntime.jsx("marker", { id: "mm-arrow-green", markerWidth: "6", markerHeight: "4", refX: "6", refY: "2", orient: "auto", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M0,0 L6,2 L0,4", fill: "#22c55e" }) }),
27607
+ /* @__PURE__ */ jsxRuntime.jsx("marker", { id: "mm-arrow-cyan", markerWidth: "6", markerHeight: "4", refX: "6", refY: "2", orient: "auto", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M0,0 L6,2 L0,4", fill: "#06b6d4" }) }),
27608
+ /* @__PURE__ */ jsxRuntime.jsx("marker", { id: "mm-arrow-yellow", markerWidth: "6", markerHeight: "4", refX: "6", refY: "2", orient: "auto", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M0,0 L6,2 L0,4", fill: "#eab308" }) })
27609
+ ] }),
27610
+ activeTrait.transitions.map((tr, i) => {
27611
+ const fromPos = posMap.get(tr.from);
27612
+ const toPos = posMap.get(tr.to);
27613
+ if (!fromPos || !toPos) return null;
27614
+ const key = `${tr.from}+${tr.event}->${tr.to}`;
27615
+ const isCurrent = key === currentEdgeKey && !walkStep.isRepositioning;
27616
+ const isCovered = activeEdgeKeys.has(key);
27617
+ const phase = activeEdgePhases.get(key);
27618
+ let stroke = "#555";
27619
+ let markerEnd = "url(#mm-arrow)";
27620
+ let strokeWidth = 1;
27621
+ let opacity = 0.4;
27622
+ if (isCurrent) {
27623
+ stroke = "#eab308";
27624
+ markerEnd = "url(#mm-arrow-yellow)";
27625
+ strokeWidth = 2.5;
27626
+ opacity = 1;
27627
+ } else if (isCovered && phase === "dom") {
27628
+ stroke = "#06b6d4";
27629
+ markerEnd = "url(#mm-arrow-cyan)";
27630
+ strokeWidth = 1.5;
27631
+ opacity = 0.9;
27632
+ } else if (isCovered) {
27633
+ stroke = "#22c55e";
27634
+ markerEnd = "url(#mm-arrow-green)";
27635
+ strokeWidth = 1.5;
27636
+ opacity = 0.9;
27637
+ }
27638
+ if (tr.from === tr.to) {
27639
+ const cx = fromPos.x;
27640
+ const cy = fromPos.y - nodeR - 8;
27641
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
27642
+ /* @__PURE__ */ jsxRuntime.jsx(
27643
+ "path",
27644
+ {
27645
+ d: `M${cx - 5},${fromPos.y - nodeR} C${cx - 18},${cy - 14} ${cx + 18},${cy - 14} ${cx + 5},${fromPos.y - nodeR}`,
27646
+ fill: "none",
27647
+ stroke,
27648
+ strokeWidth,
27649
+ opacity,
27650
+ markerEnd
27651
+ }
27652
+ ),
27653
+ /* @__PURE__ */ jsxRuntime.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 })
27654
+ ] }, `e-${i}`);
27655
+ }
27656
+ const dx = toPos.x - fromPos.x;
27657
+ const dy = toPos.y - fromPos.y;
27658
+ const len = Math.sqrt(dx * dx + dy * dy) || 1;
27659
+ const nx = -dy / len;
27660
+ const ny = dx / len;
27661
+ const hasReverse = activeTrait.transitions.some(
27662
+ (t2) => t2.from === tr.to && t2.to === tr.from
27663
+ );
27664
+ const offset = hasReverse ? 4 : 0;
27665
+ const x1 = fromPos.x + dx / len * nodeR + nx * offset;
27666
+ const y1 = fromPos.y + dy / len * nodeR + ny * offset;
27667
+ const x2 = toPos.x - dx / len * (nodeR + 6) + nx * offset;
27668
+ const y2 = toPos.y - dy / len * (nodeR + 6) + ny * offset;
27669
+ const mx = (x1 + x2) / 2 + nx * 8;
27670
+ const my = (y1 + y2) / 2 + ny * 8;
27671
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
27672
+ /* @__PURE__ */ jsxRuntime.jsx(
27673
+ "line",
27674
+ {
27675
+ x1,
27676
+ y1,
27677
+ x2,
27678
+ y2,
27679
+ stroke,
27680
+ strokeWidth,
27681
+ opacity,
27682
+ markerEnd,
27683
+ children: isCurrent && /* @__PURE__ */ jsxRuntime.jsx("animate", { attributeName: "opacity", values: "1;0.4;1", dur: "0.8s", repeatCount: "indefinite" })
27684
+ }
27685
+ ),
27686
+ /* @__PURE__ */ jsxRuntime.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 })
27687
+ ] }, `e-${i}`);
27688
+ }),
27689
+ positions.map((pos) => {
27690
+ const isCurrentState = pos.state === walkStep.from || pos.state === walkStep.to;
27691
+ const isVisited = visitedStates.has(pos.state);
27692
+ const isInitial = pos.state === activeTrait.initialState;
27693
+ let fill = "#333";
27694
+ let strokeColor = "#555";
27695
+ let sw = 1;
27696
+ if (isCurrentState) {
27697
+ fill = "#1e40af";
27698
+ strokeColor = "#3b82f6";
27699
+ sw = 2;
27700
+ } else if (isVisited) {
27701
+ fill = "#166534";
27702
+ strokeColor = "#22c55e";
27703
+ sw = 1.5;
27704
+ }
27705
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
27706
+ isInitial && /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: pos.x, cy: pos.y, r: nodeR + 3, fill: "none", stroke: "#3b82f6", strokeWidth: 1, opacity: 0.4 }),
27707
+ /* @__PURE__ */ jsxRuntime.jsx(
27708
+ "circle",
27709
+ {
27710
+ cx: pos.x,
27711
+ cy: pos.y,
27712
+ r: nodeR,
27713
+ fill,
27714
+ stroke: strokeColor,
27715
+ strokeWidth: sw,
27716
+ children: isCurrentState && /* @__PURE__ */ jsxRuntime.jsx("animate", { attributeName: "r", values: `${nodeR};${nodeR + 2};${nodeR}`, dur: "1s", repeatCount: "indefinite" })
27717
+ }
27718
+ ),
27719
+ /* @__PURE__ */ jsxRuntime.jsx(
27720
+ "text",
27721
+ {
27722
+ x: pos.x,
27723
+ y: pos.y + nodeR + 10,
27724
+ textAnchor: "middle",
27725
+ fontSize: "8",
27726
+ fill: "#aaa",
27727
+ children: pos.state.length > 10 ? pos.state.slice(0, 8) + ".." : pos.state
27728
+ }
27729
+ )
27730
+ ] }, pos.state);
27731
+ })
27732
+ ] }) }),
27733
+ /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "px-2 py-1 border-t border-border", children: /* @__PURE__ */ jsxRuntime.jsxs(HStack, { gap: "sm", className: "items-center justify-between", children: [
27734
+ /* @__PURE__ */ jsxRuntime.jsxs(Typography, { variant: "caption", className: "text-[10px] font-mono text-green-500", children: [
27735
+ "Engine: ",
27736
+ engineCount,
27737
+ "/",
27738
+ totalTransitions
27739
+ ] }),
27740
+ domCount > 0 && /* @__PURE__ */ jsxRuntime.jsxs(Typography, { variant: "caption", className: "text-[10px] font-mono text-cyan-500", children: [
27741
+ "DOM: ",
27742
+ domCount
27743
+ ] }),
27744
+ /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: walkStep.phase === "engine" ? "info" : "warning", size: "sm", className: "text-[9px]", children: walkStep.phase === "engine" ? "Engine" : "DOM" })
27745
+ ] }) })
27746
+ ] });
27747
+ }
27748
+ WalkMinimap.displayName = "WalkMinimap";
27298
27749
  function TraitsTab({ traits: traits2 }) {
27299
27750
  if (traits2.length === 0) {
27300
27751
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -28118,25 +28569,25 @@ function EventDispatcherTab({ traits: traits2, schema }) {
28118
28569
  EventDispatcherTab.displayName = "EventDispatcherTab";
28119
28570
  function ServerResponseRow({ sr }) {
28120
28571
  const entityEntries = Object.entries(sr.dataEntities);
28121
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ml-4 pl-2 border-l border-purple-700/50 py-0.5 text-[10px] font-mono", children: [
28572
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ml-4 pl-2 border-l border-purple-500/30 py-0.5 text-[10px] font-mono", children: [
28122
28573
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
28123
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: sr.success ? "text-green-400" : "text-red-400", children: [
28574
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: sr.success ? "text-green-600 dark:text-green-400" : "text-red-600 dark:text-red-400", children: [
28124
28575
  sr.success ? "\u2713" : "\u2717",
28125
28576
  " server"
28126
28577
  ] }),
28127
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-purple-300", children: sr.orbitalName }),
28128
- sr.clientEffects > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "px-1 rounded bg-purple-900/50 text-purple-300", children: [
28578
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-purple-600 dark:text-purple-300", children: sr.orbitalName }),
28579
+ sr.clientEffects > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "px-1 rounded bg-purple-500/15 text-purple-600 dark:text-purple-300", children: [
28129
28580
  sr.clientEffects,
28130
28581
  " clientEffect",
28131
28582
  sr.clientEffects !== 1 ? "s" : ""
28132
28583
  ] }),
28133
- sr.emittedEvents.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "px-1 rounded bg-blue-900/50 text-blue-300", children: [
28584
+ sr.emittedEvents.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "px-1 rounded bg-blue-500/15 text-blue-300", children: [
28134
28585
  "emit: ",
28135
28586
  sr.emittedEvents.join(", ")
28136
28587
  ] }),
28137
- sr.error && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "px-1 rounded bg-red-900/50 text-red-400 truncate max-w-[300px]", children: sr.error })
28588
+ sr.error && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "px-1 rounded bg-red-500/15 text-red-600 dark:text-red-400 truncate max-w-[300px]", children: sr.error })
28138
28589
  ] }),
28139
- entityEntries.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-1 mt-0.5", children: entityEntries.map(([name, count]) => /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "px-1 rounded bg-gray-800 text-gray-300", children: [
28590
+ entityEntries.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-1 mt-0.5", children: entityEntries.map(([name, count]) => /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "px-1 rounded bg-[var(--color-card)] text-foreground", children: [
28140
28591
  name,
28141
28592
  ": ",
28142
28593
  count,
@@ -28149,24 +28600,24 @@ function TransitionRow({ trace }) {
28149
28600
  const isServerEntry = !!trace.serverResponse && trace.traitName.startsWith("server:");
28150
28601
  const hasFailedEffects = trace.effects.some((e) => e.status === "failed");
28151
28602
  if (isServerEntry && trace.serverResponse) {
28152
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "py-0.5 border-b border-gray-800 last:border-0", children: [
28603
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "py-0.5 border-b border-border last:border-0", children: [
28153
28604
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-2 text-xs font-mono", children: [
28154
28605
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mt-1.5 w-1.5 h-1.5 rounded-full flex-shrink-0 bg-purple-500" }),
28155
28606
  /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "warning", size: "sm", className: "flex-shrink-0", children: trace.event }),
28156
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-purple-400 flex-shrink-0", children: "server response" })
28607
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-purple-600 dark:text-purple-400 flex-shrink-0", children: "server response" })
28157
28608
  ] }),
28158
28609
  /* @__PURE__ */ jsxRuntime.jsx(ServerResponseRow, { sr: trace.serverResponse })
28159
28610
  ] });
28160
28611
  }
28161
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "py-0.5 border-b border-gray-800 last:border-0", children: [
28612
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "py-0.5 border-b border-border last:border-0", children: [
28162
28613
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-2 text-xs font-mono", children: [
28163
28614
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(
28164
28615
  "mt-1.5 w-1.5 h-1.5 rounded-full flex-shrink-0",
28165
28616
  hasFailedEffects ? "bg-red-500" : "bg-green-500"
28166
28617
  ) }),
28167
28618
  /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "info", size: "sm", className: "flex-shrink-0", children: trace.event }),
28168
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-300 flex-shrink-0", children: trace.traitName }),
28169
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-gray-400 flex-shrink-0", children: [
28619
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground flex-shrink-0", children: trace.traitName }),
28620
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-foreground/70 flex-shrink-0", children: [
28170
28621
  trace.from,
28171
28622
  " ",
28172
28623
  "\u2192",
@@ -28176,12 +28627,12 @@ function TransitionRow({ trace }) {
28176
28627
  ] }),
28177
28628
  trace.effects.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-1 ml-6 mt-0.5", children: trace.effects.map((eff, i) => /* @__PURE__ */ jsxRuntime.jsxs("span", { className: cn(
28178
28629
  "px-1 rounded text-[10px]",
28179
- 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"
28630
+ 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"
28180
28631
  ), children: [
28181
28632
  eff.status === "executed" ? "\u2713" : eff.status === "failed" ? "\u2717" : "-",
28182
28633
  " ",
28183
28634
  eff.type,
28184
- eff.args.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-500 ml-0.5", children: JSON.stringify(eff.args).slice(0, 40) })
28635
+ eff.args.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground/50 ml-0.5", children: JSON.stringify(eff.args).slice(0, 40) })
28185
28636
  ] }, i)) }),
28186
28637
  trace.serverResponse && /* @__PURE__ */ jsxRuntime.jsx(ServerResponseRow, { sr: trace.serverResponse })
28187
28638
  ] });
@@ -28196,15 +28647,6 @@ function VerifyModePanel({
28196
28647
  }) {
28197
28648
  const scrollRef = React117__namespace.useRef(null);
28198
28649
  const prevCountRef = React117__namespace.useRef(0);
28199
- const [walkStep, setWalkStep] = React117__namespace.useState(null);
28200
- React117__namespace.useEffect(() => {
28201
- const interval = setInterval(() => {
28202
- const w = window;
28203
- const step = w.__orbitalWalkStep;
28204
- if (step) setWalkStep(step);
28205
- }, 300);
28206
- return () => clearInterval(interval);
28207
- }, []);
28208
28650
  React117__namespace.useEffect(() => {
28209
28651
  if (transitions.length > prevCountRef.current && scrollRef.current) {
28210
28652
  scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
@@ -28217,49 +28659,28 @@ function VerifyModePanel({
28217
28659
  {
28218
28660
  className: cn(
28219
28661
  "runtime-debugger runtime-debugger--verify",
28220
- "flex flex-col bg-gray-900 text-white border-t-2 border-cyan-500",
28662
+ "flex flex-col bg-[var(--color-card)] text-[var(--color-foreground)] border-t-2 border-cyan-500",
28221
28663
  hudBottom ? "" : "fixed bottom-0 left-0 right-0",
28222
28664
  className
28223
28665
  ),
28224
28666
  "data-testid": "debugger-verify",
28225
28667
  style: { height: "25vh", zIndex: hudBottom ? void 0 : 40 },
28226
28668
  children: [
28227
- /* @__PURE__ */ jsxRuntime.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: [
28669
+ /* @__PURE__ */ jsxRuntime.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: [
28228
28670
  /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: failedChecks > 0 ? "danger" : "success", size: "sm", children: failedChecks > 0 ? `${failedChecks} fail` : "OK" }),
28229
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-gray-400", children: [
28671
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-foreground/70", children: [
28230
28672
  localCount,
28231
28673
  " local"
28232
28674
  ] }),
28233
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-purple-400", children: [
28675
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-purple-600 dark:text-purple-400", children: [
28234
28676
  serverCount,
28235
28677
  " server"
28236
28678
  ] }),
28237
- traitStates && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-cyan-400 truncate max-w-[400px]", children: traitStates })
28679
+ traitStates && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-cyan-600 dark:text-cyan-400 truncate max-w-[400px]", children: traitStates })
28238
28680
  ] }),
28239
28681
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 flex overflow-hidden", children: [
28240
- /* @__PURE__ */ jsxRuntime.jsx("div", { ref: scrollRef, className: "flex-1 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-2 py-1", children: transitions.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-gray-500 text-xs font-mono py-2 text-center", children: "Waiting for transitions..." }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-0.5", children: transitions.map((trace) => /* @__PURE__ */ jsxRuntime.jsx(TransitionRow, { trace }, trace.id)) }) }) }),
28241
- walkStep && /* @__PURE__ */ jsxRuntime.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: [
28242
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-cyan-400 font-bold mb-1", children: [
28243
- "Walk Step ",
28244
- walkStep.stepIndex,
28245
- "/",
28246
- walkStep.stepTotal
28247
- ] }),
28248
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-gray-300 mb-1", children: walkStep.traitName }),
28249
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 mb-1", children: [
28250
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-yellow-300", children: walkStep.from }),
28251
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-500", children: "--" }),
28252
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-green-300", children: walkStep.event }),
28253
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-500", children: "-->" }),
28254
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-yellow-300", children: walkStep.to })
28255
- ] }),
28256
- walkStep.guardCase && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: walkStep.guardCase === "pass" ? "text-green-400" : "text-red-400", children: [
28257
- "guard: ",
28258
- walkStep.guardCase
28259
- ] }),
28260
- walkStep.isRepositioning && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-gray-500 italic", children: "repositioning" }),
28261
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: walkStep.accepted ? "text-green-400 mt-1" : "text-red-400 mt-1", children: walkStep.accepted ? "\u2713 accepted" : "\u2717 rejected" })
28262
- ] })
28682
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: scrollRef, className: "flex-1 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-2 py-1", children: transitions.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-foreground/50 text-xs font-mono py-2 text-center", children: "Waiting for transitions..." }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-0.5", children: transitions.map((trace) => /* @__PURE__ */ jsxRuntime.jsx(TransitionRow, { trace }, trace.id)) }) }) }),
28683
+ /* @__PURE__ */ jsxRuntime.jsx(WalkMinimap, {})
28263
28684
  ] })
28264
28685
  ]
28265
28686
  }
@@ -28484,7 +28905,7 @@ function RuntimeDebugger({
28484
28905
  className: "runtime-debugger__tabs"
28485
28906
  }
28486
28907
  ) }),
28487
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "runtime-debugger__footer", children: /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "small", className: "text-gray-500", children: "Press ` to toggle | window.__orbitalVerification for automation" }) })
28908
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "runtime-debugger__footer", children: /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "small", className: "text-foreground/50", children: "Press ` to toggle | window.__orbitalVerification for automation" }) })
28488
28909
  ] })
28489
28910
  }
28490
28911
  );
@@ -28913,7 +29334,7 @@ function SequencerBoard({
28913
29334
  setPlayState("playing");
28914
29335
  setCurrentStep(0);
28915
29336
  let step = 0;
28916
- const advance2 = () => {
29337
+ const advance = () => {
28917
29338
  step++;
28918
29339
  if (step >= entity.maxSlots) {
28919
29340
  const playerSeq = slots.map((s) => s?.id);
@@ -28944,10 +29365,10 @@ function SequencerBoard({
28944
29365
  }
28945
29366
  } else {
28946
29367
  setCurrentStep(step);
28947
- timerRef.current = setTimeout(advance2, stepDurationMs);
29368
+ timerRef.current = setTimeout(advance, stepDurationMs);
28948
29369
  }
28949
29370
  };
28950
- timerRef.current = setTimeout(advance2, stepDurationMs);
29371
+ timerRef.current = setTimeout(advance, stepDurationMs);
28951
29372
  }, [canPlay, slots, entity.maxSlots, entity.solutions, stepDurationMs, playEvent, completeEvent, emit]);
28952
29373
  const machine = {
28953
29374
  name: entity.title,
@@ -32062,6 +32483,62 @@ function getComponentForPattern(patternType) {
32062
32483
  if (!name) return null;
32063
32484
  return COMPONENT_REGISTRY[name] ?? null;
32064
32485
  }
32486
+ var FORM_PATTERNS = /* @__PURE__ */ new Set([
32487
+ "form",
32488
+ "form-section",
32489
+ "inline-edit-form",
32490
+ "wizard-step"
32491
+ ]);
32492
+ function enrichFormFields(fields, entityDef) {
32493
+ const fieldMap = new Map(entityDef.fields.map((f3) => [f3.name, f3]));
32494
+ return fields.map((field) => {
32495
+ if (typeof field === "string") {
32496
+ const entityField = fieldMap.get(field);
32497
+ if (entityField) {
32498
+ const enriched = {
32499
+ name: field,
32500
+ label: field.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/\b\w/g, (c) => c.toUpperCase()),
32501
+ type: entityField.type,
32502
+ required: entityField.required
32503
+ };
32504
+ if (entityField.values && entityField.values.length > 0) {
32505
+ enriched.values = entityField.values;
32506
+ } else if (entityField.enumValues && entityField.enumValues.length > 0) {
32507
+ enriched.values = entityField.enumValues;
32508
+ }
32509
+ if (entityField.relation) {
32510
+ enriched.relation = entityField.relation;
32511
+ }
32512
+ return enriched;
32513
+ }
32514
+ return { name: field, label: field.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/\b\w/g, (c) => c.toUpperCase()) };
32515
+ }
32516
+ if (field && typeof field === "object" && !Array.isArray(field)) {
32517
+ const obj = field;
32518
+ const fieldName = obj.name ?? obj.field;
32519
+ if (!fieldName) return field;
32520
+ if (obj.type || obj.inputType) return field;
32521
+ const entityField = fieldMap.get(fieldName);
32522
+ if (!entityField) return field;
32523
+ const enriched = { ...obj, type: entityField.type };
32524
+ if (entityField.required && !("required" in obj)) {
32525
+ enriched.required = true;
32526
+ }
32527
+ if (!obj.values && !obj.options) {
32528
+ if (entityField.values && entityField.values.length > 0) {
32529
+ enriched.values = entityField.values;
32530
+ } else if (entityField.enumValues && entityField.enumValues.length > 0) {
32531
+ enriched.values = entityField.enumValues;
32532
+ }
32533
+ }
32534
+ if (!obj.relation && entityField.relation) {
32535
+ enriched.relation = entityField.relation;
32536
+ }
32537
+ return enriched;
32538
+ }
32539
+ return field;
32540
+ });
32541
+ }
32065
32542
  var PATTERNS_WITH_CHILDREN = /* @__PURE__ */ new Set([
32066
32543
  "stack",
32067
32544
  "vstack",
@@ -32437,13 +32914,14 @@ function getToastPosition(position) {
32437
32914
  return "top-4 right-4";
32438
32915
  }
32439
32916
  }
32440
- function renderPatternChildren(children, onDismiss, parentId = "root") {
32917
+ function renderPatternChildren(children, onDismiss, parentId = "root", parentPath = "root") {
32441
32918
  if (!children || !Array.isArray(children) || children.length === 0) {
32442
32919
  return null;
32443
32920
  }
32444
32921
  return children.map((child, index) => {
32445
32922
  if (!child || typeof child !== "object") return null;
32446
32923
  const childId = `${parentId}-${index}`;
32924
+ const childPath = parentPath === "root" ? `root.children.${index}` : `${parentPath}.children.${index}`;
32447
32925
  const childContent = {
32448
32926
  id: childId,
32449
32927
  pattern: child.type,
@@ -32455,7 +32933,8 @@ function renderPatternChildren(children, onDismiss, parentId = "root") {
32455
32933
  SlotContentRenderer,
32456
32934
  {
32457
32935
  content: childContent,
32458
- onDismiss
32936
+ onDismiss,
32937
+ patternPath: childPath
32459
32938
  },
32460
32939
  childId
32461
32940
  );
@@ -32487,16 +32966,20 @@ function renderPatternProps(props, onDismiss) {
32487
32966
  }
32488
32967
  function SlotContentRenderer({
32489
32968
  content,
32490
- onDismiss
32969
+ onDismiss,
32970
+ patternPath
32491
32971
  }) {
32492
32972
  const entityProp = content.props.entity;
32493
32973
  const entityType = typeof entityProp === "string" ? entityProp : "";
32494
32974
  const storeData = useEntityRef(entityType);
32975
+ const schemaCtx = useEntitySchemaOptional();
32976
+ const entityDef = entityType && schemaCtx ? schemaCtx.entities.get(entityType) : void 0;
32495
32977
  const PatternComponent = getComponentForPattern(content.pattern);
32496
32978
  if (PatternComponent) {
32497
32979
  const childrenConfig = content.props.children;
32498
32980
  const hasChildren = PATTERNS_WITH_CHILDREN.has(content.pattern) || Array.isArray(childrenConfig) && childrenConfig.length > 0;
32499
- const renderedChildren = hasChildren ? renderPatternChildren(childrenConfig, onDismiss, content.id) : void 0;
32981
+ const myPath = patternPath ?? "root";
32982
+ const renderedChildren = hasChildren ? renderPatternChildren(childrenConfig, onDismiss, content.id, myPath) : void 0;
32500
32983
  const { children: _childrenConfig, ...restProps } = content.props;
32501
32984
  const renderedProps = renderPatternProps(restProps, onDismiss);
32502
32985
  let finalProps;
@@ -32512,6 +32995,14 @@ function SlotContentRenderer({
32512
32995
  } else {
32513
32996
  finalProps = renderedProps;
32514
32997
  }
32998
+ const isFormPattern = FORM_PATTERNS.has(content.pattern) || content.pattern.includes("form");
32999
+ if (isFormPattern && entityDef && Array.isArray(finalProps.fields)) {
33000
+ finalProps.fields = enrichFormFields(finalProps.fields, entityDef);
33001
+ if (finalProps.mode === "edit" && !finalProps.initialData && storeData.length > 0) {
33002
+ finalProps.initialData = storeData[0];
33003
+ }
33004
+ }
33005
+ const acceptsChildren = PATTERNS_WITH_CHILDREN.has(content.pattern);
32515
33006
  return /* @__PURE__ */ jsxRuntime.jsx(
32516
33007
  Box,
32517
33008
  {
@@ -32520,6 +33011,9 @@ function SlotContentRenderer({
32520
33011
  "data-id": content.id,
32521
33012
  "data-node-id": content.nodeId,
32522
33013
  "data-source-trait": content.sourceTrait,
33014
+ "data-pattern-path": myPath,
33015
+ "data-pattern-type": content.pattern,
33016
+ "data-accepts-children": acceptsChildren ? "true" : void 0,
32523
33017
  children: /* @__PURE__ */ jsxRuntime.jsx(PatternComponent, { ...finalProps, children: renderedChildren })
32524
33018
  }
32525
33019
  );
@@ -32959,7 +33453,7 @@ function TraitInitializer({ traits: traits2, orbitalNames, onNavigate }) {
32959
33453
  if (responseData) {
32960
33454
  for (const [entityType, records] of Object.entries(responseData)) {
32961
33455
  if (Array.isArray(records)) {
32962
- entityStore.advance(entityType, records);
33456
+ entityStore.setAll(entityType, records);
32963
33457
  }
32964
33458
  }
32965
33459
  }
@@ -33018,7 +33512,7 @@ function TraitInitializer({ traits: traits2, orbitalNames, onNavigate }) {
33018
33512
  if (initResponseData) {
33019
33513
  for (const [entityType, records] of Object.entries(initResponseData)) {
33020
33514
  if (Array.isArray(records)) {
33021
- entityStore.advance(entityType, records);
33515
+ entityStore.setAll(entityType, records);
33022
33516
  }
33023
33517
  }
33024
33518
  }
@@ -33067,7 +33561,7 @@ function SchemaRunner({ schema, serverUrl, mockData, pageName, onNavigate }) {
33067
33561
  if (!serverUrl && mockData) {
33068
33562
  for (const [entityType, records] of Object.entries(mockData)) {
33069
33563
  if (Array.isArray(records)) {
33070
- entityStore.advance(entityType, records);
33564
+ entityStore.setAll(entityType, records);
33071
33565
  }
33072
33566
  }
33073
33567
  }
@@ -33159,6 +33653,7 @@ exports.clearSchemaCache = clearSchemaCache;
33159
33653
  exports.createClientEffectHandlers = createClientEffectHandlers;
33160
33654
  exports.useEntityDefinition = useEntityDefinition;
33161
33655
  exports.useEntitySchema = useEntitySchema;
33656
+ exports.useEntitySchemaOptional = useEntitySchemaOptional;
33162
33657
  exports.useResolvedSchema = useResolvedSchema;
33163
33658
  exports.useServerBridge = useServerBridge;
33164
33659
  exports.useSlotContent = useSlotContent;