@almadar/ui 2.46.0 → 2.47.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.
@@ -39,6 +39,7 @@ var patterns = require('@almadar/patterns');
39
39
  var reactRouterDom = require('react-router-dom');
40
40
  var reactQuery = require('@tanstack/react-query');
41
41
 
42
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
42
43
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
43
44
 
44
45
  function _interopNamespace(e) {
@@ -91,6 +92,67 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
91
92
  function cn(...inputs) {
92
93
  return tailwindMerge.twMerge(clsx.clsx(inputs));
93
94
  }
95
+
96
+ // lib/logger.ts
97
+ var LEVEL_PRIORITY = { DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3 };
98
+ var ENV = typeof process !== "undefined" && process.env ? process.env : {};
99
+ var VITE_ENV = typeof globalThis !== "undefined" && globalThis.__vite_env__ ? globalThis.__vite_env__ : {};
100
+ function getViteEnv(key) {
101
+ try {
102
+ const meta = ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)) });
103
+ return meta?.env?.[key];
104
+ } catch {
105
+ return void 0;
106
+ }
107
+ }
108
+ function envGet(key, viteKey) {
109
+ return ENV[key] ?? (viteKey ? getViteEnv(viteKey) : void 0) ?? VITE_ENV[viteKey ?? key];
110
+ }
111
+ var NODE_ENV = envGet("NODE_ENV", "VITE_NODE_ENV") ?? "development";
112
+ var CONFIGURED_LEVEL = (envGet("LOG_LEVEL", "VITE_LOG_LEVEL") ?? (NODE_ENV === "production" ? "info" : "debug")).toUpperCase();
113
+ var MIN_PRIORITY = LEVEL_PRIORITY[CONFIGURED_LEVEL] ?? 0;
114
+ var DEBUG_FILTER = (envGet("ALMADAR_DEBUG", "VITE_ALMADAR_DEBUG") ?? "").split(",").map((s) => s.trim()).filter(Boolean);
115
+ function matchesNamespace(namespace) {
116
+ if (DEBUG_FILTER.length === 0) return true;
117
+ return DEBUG_FILTER.some((pattern) => {
118
+ if (pattern === "*" || pattern === "almadar:*") return true;
119
+ if (pattern.endsWith(":*")) return namespace.startsWith(pattern.slice(0, -1));
120
+ return namespace === pattern;
121
+ });
122
+ }
123
+ function createLogger(namespace) {
124
+ const nsAllowed = matchesNamespace(namespace);
125
+ const log3 = (level, message, data, correlationId) => {
126
+ if (LEVEL_PRIORITY[level] < MIN_PRIORITY) return;
127
+ if (level === "DEBUG" && !nsAllowed) return;
128
+ const prefix = `[${namespace}]`;
129
+ const logData = correlationId ? { ...data, cid: correlationId } : data;
130
+ switch (level) {
131
+ case "DEBUG":
132
+ console.debug(prefix, message, logData ?? "");
133
+ break;
134
+ case "INFO":
135
+ console.info(prefix, message, logData ?? "");
136
+ break;
137
+ case "WARN":
138
+ console.warn(prefix, message, logData ?? "");
139
+ break;
140
+ case "ERROR":
141
+ console.error(prefix, message, logData ?? "");
142
+ break;
143
+ }
144
+ };
145
+ return {
146
+ debug: (msg, data, cid) => log3("DEBUG", msg, data, cid),
147
+ info: (msg, data, cid) => log3("INFO", msg, data, cid),
148
+ warn: (msg, data, cid) => log3("WARN", msg, data, cid),
149
+ error: (msg, data, cid) => log3("ERROR", msg, data, cid)
150
+ };
151
+ }
152
+
153
+ // hooks/useEventBus.ts
154
+ var log = createLogger("almadar:eventbus");
155
+ var subLog = createLogger("almadar:eventbus:subscribe");
94
156
  function getGlobalEventBus() {
95
157
  if (typeof window !== "undefined") {
96
158
  return window.__kflowEventBus ?? null;
@@ -107,6 +169,7 @@ var fallbackEventBus = {
107
169
  timestamp: Date.now()
108
170
  };
109
171
  const handlers = fallbackListeners.get(type);
172
+ log.debug("emit", { type, payloadKeys: payload ? Object.keys(payload).length : 0, listenerCount: (handlers?.size ?? 0) + fallbackAnyListeners.size });
110
173
  if (handlers) {
111
174
  handlers.forEach((handler) => {
112
175
  try {
@@ -129,6 +192,7 @@ var fallbackEventBus = {
129
192
  fallbackListeners.set(type, /* @__PURE__ */ new Set());
130
193
  }
131
194
  fallbackListeners.get(type).add(listener);
195
+ subLog.debug("subscribe", { type, totalListeners: fallbackListeners.get(type).size });
132
196
  return () => {
133
197
  const handlers = fallbackListeners.get(type);
134
198
  if (handlers) {
@@ -152,6 +216,7 @@ var fallbackEventBus = {
152
216
  },
153
217
  onAny: (listener) => {
154
218
  fallbackAnyListeners.add(listener);
219
+ subLog.debug("subscribe:any", { totalAnyListeners: fallbackAnyListeners.size });
155
220
  return () => {
156
221
  fallbackAnyListeners.delete(listener);
157
222
  };
@@ -1089,6 +1154,7 @@ var Box = React90__namespace.default.forwardRef(
1089
1154
  action,
1090
1155
  actionPayload,
1091
1156
  hoverEvent,
1157
+ maxWidth,
1092
1158
  onClick,
1093
1159
  onMouseEnter,
1094
1160
  onMouseLeave,
@@ -1153,6 +1219,7 @@ var Box = React90__namespace.default.forwardRef(
1153
1219
  onClick: isClickable ? handleClick : void 0,
1154
1220
  onMouseEnter: hoverEvent || onMouseEnter ? handleMouseEnter : void 0,
1155
1221
  onMouseLeave: hoverEvent || onMouseLeave ? handleMouseLeave : void 0,
1222
+ style: maxWidth ? { maxWidth, ...rest.style } : rest.style,
1156
1223
  ...rest,
1157
1224
  children
1158
1225
  }
@@ -11624,6 +11691,7 @@ function GameOverScreen({
11624
11691
  GameOverScreen.displayName = "GameOverScreen";
11625
11692
 
11626
11693
  // lib/verificationRegistry.ts
11694
+ createLogger("almadar:bridge");
11627
11695
  function getState() {
11628
11696
  if (typeof window !== "undefined") {
11629
11697
  const w = window;
@@ -29150,6 +29218,7 @@ function calculateDamage(attack, defense, isDefending = false, criticalChance =
29150
29218
  function generateCombatMessage(event) {
29151
29219
  return event.message;
29152
29220
  }
29221
+ var storeLog = createLogger("almadar:entity:store");
29153
29222
  var store = /* @__PURE__ */ new Map();
29154
29223
  var storeListeners = /* @__PURE__ */ new Set();
29155
29224
  var watchCallbacks = /* @__PURE__ */ new Map();
@@ -29189,7 +29258,9 @@ function setAll(entityType, records) {
29189
29258
  }
29190
29259
  }
29191
29260
  const prev = store.get(entityType);
29192
- store.set(entityType, { entities: entities2, ids, version: (prev?.version ?? 0) + 1 });
29261
+ const newVersion = (prev?.version ?? 0) + 1;
29262
+ store.set(entityType, { entities: entities2, ids, version: newVersion });
29263
+ storeLog.debug("setAll", { entityType, recordCount: records.length, version: newVersion });
29193
29264
  notifyListeners(entityType, prev);
29194
29265
  }
29195
29266
  function upsertOne(entityType, record) {
@@ -29201,6 +29272,7 @@ function upsertOne(entityType, record) {
29201
29272
  if (!snapshot.ids.includes(id)) snapshot.ids.push(id);
29202
29273
  snapshot.version++;
29203
29274
  store.set(entityType, snapshot);
29275
+ storeLog.debug("upsertOne", { entityType, id, version: snapshot.version });
29204
29276
  notifyListeners(entityType, prev);
29205
29277
  }
29206
29278
  function addOne(entityType, record) {
@@ -29217,6 +29289,7 @@ function updateOne(entityType, id, changes) {
29217
29289
  snapshot.entities.set(id, { ...snapshot.entities.get(id), ...changes });
29218
29290
  snapshot.version++;
29219
29291
  store.set(entityType, snapshot);
29292
+ storeLog.debug("updateOne", { entityType, id, changedFields: Object.keys(changes), version: snapshot.version });
29220
29293
  notifyListeners(entityType, prev);
29221
29294
  }
29222
29295
  function removeOne(entityType, id) {
@@ -29230,6 +29303,7 @@ function removeOne(entityType, id) {
29230
29303
  snapshot.entities.delete(id);
29231
29304
  snapshot.version++;
29232
29305
  store.set(entityType, snapshot);
29306
+ storeLog.debug("removeOne", { entityType, id, remainingCount: snapshot.ids.length, version: snapshot.version });
29233
29307
  notifyListeners(entityType, prev);
29234
29308
  }
29235
29309
  function getSnapshot2(entityType) {
@@ -33384,7 +33458,7 @@ function getAllEvents(traits2) {
33384
33458
  }
33385
33459
  function EventDispatcherTab({ traits: traits2, schema }) {
33386
33460
  const eventBus = useEventBus();
33387
- const [log, setLog] = React90__namespace.useState([]);
33461
+ const [log3, setLog] = React90__namespace.useState([]);
33388
33462
  const prevStatesRef = React90__namespace.useRef(/* @__PURE__ */ new Map());
33389
33463
  React90__namespace.useEffect(() => {
33390
33464
  for (const trait of traits2) {
@@ -33448,9 +33522,9 @@ function EventDispatcherTab({ traits: traits2, schema }) {
33448
33522
  /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "small", weight: "medium", className: "text-gray-500 mb-1", children: "Other Events (not available from current state)" }),
33449
33523
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-1", children: unavailableEvents.map((event) => /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "default", size: "sm", className: "opacity-50", children: event }, event)) })
33450
33524
  ] }),
33451
- log.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
33525
+ log3.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
33452
33526
  /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "small", weight: "medium", className: "text-gray-500 mb-1", children: "Recent Transitions" }),
33453
- /* @__PURE__ */ jsxRuntime.jsx(Stack, { gap: "xs", children: log.map((entry, i) => /* @__PURE__ */ jsxRuntime.jsxs(Typography, { variant: "small", className: "font-mono text-xs", children: [
33527
+ /* @__PURE__ */ jsxRuntime.jsx(Stack, { gap: "xs", children: log3.map((entry, i) => /* @__PURE__ */ jsxRuntime.jsxs(Typography, { variant: "small", className: "font-mono text-xs", children: [
33454
33528
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-purple-400", children: entry.traitName }),
33455
33529
  " ",
33456
33530
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-500", children: entry.from }),
@@ -37273,21 +37347,21 @@ function useOrbitalMutations(entityName, orbitalName, options) {
37273
37347
  update: options?.events?.update || ENTITY_EVENTS.UPDATE,
37274
37348
  delete: options?.events?.delete || ENTITY_EVENTS.DELETE
37275
37349
  };
37276
- const log = (message, data) => {
37350
+ const log3 = (message, data) => {
37277
37351
  if (options?.debug) {
37278
37352
  console.log(`[useOrbitalMutations:${orbitalName}] ${message}`, data ?? "");
37279
37353
  }
37280
37354
  };
37281
37355
  const createMutation = reactQuery.useMutation({
37282
37356
  mutationFn: async (data) => {
37283
- log("Creating entity", data);
37357
+ log3("Creating entity", data);
37284
37358
  return sendOrbitalEvent(orbitalName, {
37285
37359
  event: events2.create,
37286
37360
  payload: { data, entityType: entityName }
37287
37361
  });
37288
37362
  },
37289
37363
  onSuccess: (response) => {
37290
- log("Create succeeded", response);
37364
+ log3("Create succeeded", response);
37291
37365
  queryClient.invalidateQueries({ queryKey: entityDataKeys.list(entityName) });
37292
37366
  },
37293
37367
  onError: (error) => {
@@ -37299,7 +37373,7 @@ function useOrbitalMutations(entityName, orbitalName, options) {
37299
37373
  id,
37300
37374
  data
37301
37375
  }) => {
37302
- log(`Updating entity ${id}`, data);
37376
+ log3(`Updating entity ${id}`, data);
37303
37377
  return sendOrbitalEvent(orbitalName, {
37304
37378
  event: events2.update,
37305
37379
  entityId: id,
@@ -37307,7 +37381,7 @@ function useOrbitalMutations(entityName, orbitalName, options) {
37307
37381
  });
37308
37382
  },
37309
37383
  onSuccess: (response, variables) => {
37310
- log("Update succeeded", response);
37384
+ log3("Update succeeded", response);
37311
37385
  queryClient.invalidateQueries({ queryKey: entityDataKeys.list(entityName) });
37312
37386
  queryClient.invalidateQueries({
37313
37387
  queryKey: entityDataKeys.detail(entityName, variables.id)
@@ -37319,7 +37393,7 @@ function useOrbitalMutations(entityName, orbitalName, options) {
37319
37393
  });
37320
37394
  const deleteMutation = reactQuery.useMutation({
37321
37395
  mutationFn: async (id) => {
37322
- log(`Deleting entity ${id}`);
37396
+ log3(`Deleting entity ${id}`);
37323
37397
  return sendOrbitalEvent(orbitalName, {
37324
37398
  event: events2.delete,
37325
37399
  entityId: id,
@@ -37327,7 +37401,7 @@ function useOrbitalMutations(entityName, orbitalName, options) {
37327
37401
  });
37328
37402
  },
37329
37403
  onSuccess: (response, id) => {
37330
- log("Delete succeeded", response);
37404
+ log3("Delete succeeded", response);
37331
37405
  queryClient.invalidateQueries({ queryKey: entityDataKeys.list(entityName) });
37332
37406
  queryClient.removeQueries({ queryKey: entityDataKeys.detail(entityName, id) });
37333
37407
  },
@@ -45,6 +45,67 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
45
45
  function cn(...inputs) {
46
46
  return twMerge(clsx(inputs));
47
47
  }
48
+
49
+ // lib/logger.ts
50
+ var LEVEL_PRIORITY = { DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3 };
51
+ var ENV = typeof process !== "undefined" && process.env ? process.env : {};
52
+ var VITE_ENV = typeof globalThis !== "undefined" && globalThis.__vite_env__ ? globalThis.__vite_env__ : {};
53
+ function getViteEnv(key) {
54
+ try {
55
+ const meta = import.meta;
56
+ return meta?.env?.[key];
57
+ } catch {
58
+ return void 0;
59
+ }
60
+ }
61
+ function envGet(key, viteKey) {
62
+ return ENV[key] ?? (viteKey ? getViteEnv(viteKey) : void 0) ?? VITE_ENV[viteKey ?? key];
63
+ }
64
+ var NODE_ENV = envGet("NODE_ENV", "VITE_NODE_ENV") ?? "development";
65
+ var CONFIGURED_LEVEL = (envGet("LOG_LEVEL", "VITE_LOG_LEVEL") ?? (NODE_ENV === "production" ? "info" : "debug")).toUpperCase();
66
+ var MIN_PRIORITY = LEVEL_PRIORITY[CONFIGURED_LEVEL] ?? 0;
67
+ var DEBUG_FILTER = (envGet("ALMADAR_DEBUG", "VITE_ALMADAR_DEBUG") ?? "").split(",").map((s) => s.trim()).filter(Boolean);
68
+ function matchesNamespace(namespace) {
69
+ if (DEBUG_FILTER.length === 0) return true;
70
+ return DEBUG_FILTER.some((pattern) => {
71
+ if (pattern === "*" || pattern === "almadar:*") return true;
72
+ if (pattern.endsWith(":*")) return namespace.startsWith(pattern.slice(0, -1));
73
+ return namespace === pattern;
74
+ });
75
+ }
76
+ function createLogger(namespace) {
77
+ const nsAllowed = matchesNamespace(namespace);
78
+ const log3 = (level, message, data, correlationId) => {
79
+ if (LEVEL_PRIORITY[level] < MIN_PRIORITY) return;
80
+ if (level === "DEBUG" && !nsAllowed) return;
81
+ const prefix = `[${namespace}]`;
82
+ const logData = correlationId ? { ...data, cid: correlationId } : data;
83
+ switch (level) {
84
+ case "DEBUG":
85
+ console.debug(prefix, message, logData ?? "");
86
+ break;
87
+ case "INFO":
88
+ console.info(prefix, message, logData ?? "");
89
+ break;
90
+ case "WARN":
91
+ console.warn(prefix, message, logData ?? "");
92
+ break;
93
+ case "ERROR":
94
+ console.error(prefix, message, logData ?? "");
95
+ break;
96
+ }
97
+ };
98
+ return {
99
+ debug: (msg, data, cid) => log3("DEBUG", msg, data, cid),
100
+ info: (msg, data, cid) => log3("INFO", msg, data, cid),
101
+ warn: (msg, data, cid) => log3("WARN", msg, data, cid),
102
+ error: (msg, data, cid) => log3("ERROR", msg, data, cid)
103
+ };
104
+ }
105
+
106
+ // hooks/useEventBus.ts
107
+ var log = createLogger("almadar:eventbus");
108
+ var subLog = createLogger("almadar:eventbus:subscribe");
48
109
  function getGlobalEventBus() {
49
110
  if (typeof window !== "undefined") {
50
111
  return window.__kflowEventBus ?? null;
@@ -61,6 +122,7 @@ var fallbackEventBus = {
61
122
  timestamp: Date.now()
62
123
  };
63
124
  const handlers = fallbackListeners.get(type);
125
+ log.debug("emit", { type, payloadKeys: payload ? Object.keys(payload).length : 0, listenerCount: (handlers?.size ?? 0) + fallbackAnyListeners.size });
64
126
  if (handlers) {
65
127
  handlers.forEach((handler) => {
66
128
  try {
@@ -83,6 +145,7 @@ var fallbackEventBus = {
83
145
  fallbackListeners.set(type, /* @__PURE__ */ new Set());
84
146
  }
85
147
  fallbackListeners.get(type).add(listener);
148
+ subLog.debug("subscribe", { type, totalListeners: fallbackListeners.get(type).size });
86
149
  return () => {
87
150
  const handlers = fallbackListeners.get(type);
88
151
  if (handlers) {
@@ -106,6 +169,7 @@ var fallbackEventBus = {
106
169
  },
107
170
  onAny: (listener) => {
108
171
  fallbackAnyListeners.add(listener);
172
+ subLog.debug("subscribe:any", { totalAnyListeners: fallbackAnyListeners.size });
109
173
  return () => {
110
174
  fallbackAnyListeners.delete(listener);
111
175
  };
@@ -1043,6 +1107,7 @@ var Box = React90__default.forwardRef(
1043
1107
  action,
1044
1108
  actionPayload,
1045
1109
  hoverEvent,
1110
+ maxWidth,
1046
1111
  onClick,
1047
1112
  onMouseEnter,
1048
1113
  onMouseLeave,
@@ -1107,6 +1172,7 @@ var Box = React90__default.forwardRef(
1107
1172
  onClick: isClickable ? handleClick : void 0,
1108
1173
  onMouseEnter: hoverEvent || onMouseEnter ? handleMouseEnter : void 0,
1109
1174
  onMouseLeave: hoverEvent || onMouseLeave ? handleMouseLeave : void 0,
1175
+ style: maxWidth ? { maxWidth, ...rest.style } : rest.style,
1110
1176
  ...rest,
1111
1177
  children
1112
1178
  }
@@ -11578,6 +11644,7 @@ function GameOverScreen({
11578
11644
  GameOverScreen.displayName = "GameOverScreen";
11579
11645
 
11580
11646
  // lib/verificationRegistry.ts
11647
+ createLogger("almadar:bridge");
11581
11648
  function getState() {
11582
11649
  if (typeof window !== "undefined") {
11583
11650
  const w = window;
@@ -29104,6 +29171,7 @@ function calculateDamage(attack, defense, isDefending = false, criticalChance =
29104
29171
  function generateCombatMessage(event) {
29105
29172
  return event.message;
29106
29173
  }
29174
+ var storeLog = createLogger("almadar:entity:store");
29107
29175
  var store = /* @__PURE__ */ new Map();
29108
29176
  var storeListeners = /* @__PURE__ */ new Set();
29109
29177
  var watchCallbacks = /* @__PURE__ */ new Map();
@@ -29143,7 +29211,9 @@ function setAll(entityType, records) {
29143
29211
  }
29144
29212
  }
29145
29213
  const prev = store.get(entityType);
29146
- store.set(entityType, { entities: entities2, ids, version: (prev?.version ?? 0) + 1 });
29214
+ const newVersion = (prev?.version ?? 0) + 1;
29215
+ store.set(entityType, { entities: entities2, ids, version: newVersion });
29216
+ storeLog.debug("setAll", { entityType, recordCount: records.length, version: newVersion });
29147
29217
  notifyListeners(entityType, prev);
29148
29218
  }
29149
29219
  function upsertOne(entityType, record) {
@@ -29155,6 +29225,7 @@ function upsertOne(entityType, record) {
29155
29225
  if (!snapshot.ids.includes(id)) snapshot.ids.push(id);
29156
29226
  snapshot.version++;
29157
29227
  store.set(entityType, snapshot);
29228
+ storeLog.debug("upsertOne", { entityType, id, version: snapshot.version });
29158
29229
  notifyListeners(entityType, prev);
29159
29230
  }
29160
29231
  function addOne(entityType, record) {
@@ -29171,6 +29242,7 @@ function updateOne(entityType, id, changes) {
29171
29242
  snapshot.entities.set(id, { ...snapshot.entities.get(id), ...changes });
29172
29243
  snapshot.version++;
29173
29244
  store.set(entityType, snapshot);
29245
+ storeLog.debug("updateOne", { entityType, id, changedFields: Object.keys(changes), version: snapshot.version });
29174
29246
  notifyListeners(entityType, prev);
29175
29247
  }
29176
29248
  function removeOne(entityType, id) {
@@ -29184,6 +29256,7 @@ function removeOne(entityType, id) {
29184
29256
  snapshot.entities.delete(id);
29185
29257
  snapshot.version++;
29186
29258
  store.set(entityType, snapshot);
29259
+ storeLog.debug("removeOne", { entityType, id, remainingCount: snapshot.ids.length, version: snapshot.version });
29187
29260
  notifyListeners(entityType, prev);
29188
29261
  }
29189
29262
  function getSnapshot2(entityType) {
@@ -33338,7 +33411,7 @@ function getAllEvents(traits2) {
33338
33411
  }
33339
33412
  function EventDispatcherTab({ traits: traits2, schema }) {
33340
33413
  const eventBus = useEventBus();
33341
- const [log, setLog] = React90.useState([]);
33414
+ const [log3, setLog] = React90.useState([]);
33342
33415
  const prevStatesRef = React90.useRef(/* @__PURE__ */ new Map());
33343
33416
  React90.useEffect(() => {
33344
33417
  for (const trait of traits2) {
@@ -33402,9 +33475,9 @@ function EventDispatcherTab({ traits: traits2, schema }) {
33402
33475
  /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "medium", className: "text-gray-500 mb-1", children: "Other Events (not available from current state)" }),
33403
33476
  /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1", children: unavailableEvents.map((event) => /* @__PURE__ */ jsx(Badge, { variant: "default", size: "sm", className: "opacity-50", children: event }, event)) })
33404
33477
  ] }),
33405
- log.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
33478
+ log3.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
33406
33479
  /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "medium", className: "text-gray-500 mb-1", children: "Recent Transitions" }),
33407
- /* @__PURE__ */ jsx(Stack, { gap: "xs", children: log.map((entry, i) => /* @__PURE__ */ jsxs(Typography, { variant: "small", className: "font-mono text-xs", children: [
33480
+ /* @__PURE__ */ jsx(Stack, { gap: "xs", children: log3.map((entry, i) => /* @__PURE__ */ jsxs(Typography, { variant: "small", className: "font-mono text-xs", children: [
33408
33481
  /* @__PURE__ */ jsx("span", { className: "text-purple-400", children: entry.traitName }),
33409
33482
  " ",
33410
33483
  /* @__PURE__ */ jsx("span", { className: "text-gray-500", children: entry.from }),
@@ -37227,21 +37300,21 @@ function useOrbitalMutations(entityName, orbitalName, options) {
37227
37300
  update: options?.events?.update || ENTITY_EVENTS.UPDATE,
37228
37301
  delete: options?.events?.delete || ENTITY_EVENTS.DELETE
37229
37302
  };
37230
- const log = (message, data) => {
37303
+ const log3 = (message, data) => {
37231
37304
  if (options?.debug) {
37232
37305
  console.log(`[useOrbitalMutations:${orbitalName}] ${message}`, data ?? "");
37233
37306
  }
37234
37307
  };
37235
37308
  const createMutation = useMutation({
37236
37309
  mutationFn: async (data) => {
37237
- log("Creating entity", data);
37310
+ log3("Creating entity", data);
37238
37311
  return sendOrbitalEvent(orbitalName, {
37239
37312
  event: events2.create,
37240
37313
  payload: { data, entityType: entityName }
37241
37314
  });
37242
37315
  },
37243
37316
  onSuccess: (response) => {
37244
- log("Create succeeded", response);
37317
+ log3("Create succeeded", response);
37245
37318
  queryClient.invalidateQueries({ queryKey: entityDataKeys.list(entityName) });
37246
37319
  },
37247
37320
  onError: (error) => {
@@ -37253,7 +37326,7 @@ function useOrbitalMutations(entityName, orbitalName, options) {
37253
37326
  id,
37254
37327
  data
37255
37328
  }) => {
37256
- log(`Updating entity ${id}`, data);
37329
+ log3(`Updating entity ${id}`, data);
37257
37330
  return sendOrbitalEvent(orbitalName, {
37258
37331
  event: events2.update,
37259
37332
  entityId: id,
@@ -37261,7 +37334,7 @@ function useOrbitalMutations(entityName, orbitalName, options) {
37261
37334
  });
37262
37335
  },
37263
37336
  onSuccess: (response, variables) => {
37264
- log("Update succeeded", response);
37337
+ log3("Update succeeded", response);
37265
37338
  queryClient.invalidateQueries({ queryKey: entityDataKeys.list(entityName) });
37266
37339
  queryClient.invalidateQueries({
37267
37340
  queryKey: entityDataKeys.detail(entityName, variables.id)
@@ -37273,7 +37346,7 @@ function useOrbitalMutations(entityName, orbitalName, options) {
37273
37346
  });
37274
37347
  const deleteMutation = useMutation({
37275
37348
  mutationFn: async (id) => {
37276
- log(`Deleting entity ${id}`);
37349
+ log3(`Deleting entity ${id}`);
37277
37350
  return sendOrbitalEvent(orbitalName, {
37278
37351
  event: events2.delete,
37279
37352
  entityId: id,
@@ -37281,7 +37354,7 @@ function useOrbitalMutations(entityName, orbitalName, options) {
37281
37354
  });
37282
37355
  },
37283
37356
  onSuccess: (response, id) => {
37284
- log("Delete succeeded", response);
37357
+ log3("Delete succeeded", response);
37285
37358
  queryClient.invalidateQueries({ queryKey: entityDataKeys.list(entityName) });
37286
37359
  queryClient.removeQueries({ queryKey: entityDataKeys.detail(entityName, id) });
37287
37360
  },
@@ -14,6 +14,7 @@ var clsx = require('clsx');
14
14
  var tailwindMerge = require('tailwind-merge');
15
15
  var postprocessing = require('@react-three/postprocessing');
16
16
 
17
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
17
18
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
18
19
 
19
20
  function _interopNamespace(e) {
@@ -1375,6 +1376,67 @@ function useRaycaster(options) {
1375
1376
  isWithinCanvas
1376
1377
  };
1377
1378
  }
1379
+
1380
+ // lib/logger.ts
1381
+ var LEVEL_PRIORITY = { DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3 };
1382
+ var ENV = typeof process !== "undefined" && process.env ? process.env : {};
1383
+ var VITE_ENV = typeof globalThis !== "undefined" && globalThis.__vite_env__ ? globalThis.__vite_env__ : {};
1384
+ function getViteEnv(key) {
1385
+ try {
1386
+ const meta = ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)) });
1387
+ return meta?.env?.[key];
1388
+ } catch {
1389
+ return void 0;
1390
+ }
1391
+ }
1392
+ function envGet(key, viteKey) {
1393
+ return ENV[key] ?? (viteKey ? getViteEnv(viteKey) : void 0) ?? VITE_ENV[viteKey ?? key];
1394
+ }
1395
+ var NODE_ENV = envGet("NODE_ENV", "VITE_NODE_ENV") ?? "development";
1396
+ var CONFIGURED_LEVEL = (envGet("LOG_LEVEL", "VITE_LOG_LEVEL") ?? (NODE_ENV === "production" ? "info" : "debug")).toUpperCase();
1397
+ var MIN_PRIORITY = LEVEL_PRIORITY[CONFIGURED_LEVEL] ?? 0;
1398
+ var DEBUG_FILTER = (envGet("ALMADAR_DEBUG", "VITE_ALMADAR_DEBUG") ?? "").split(",").map((s) => s.trim()).filter(Boolean);
1399
+ function matchesNamespace(namespace) {
1400
+ if (DEBUG_FILTER.length === 0) return true;
1401
+ return DEBUG_FILTER.some((pattern) => {
1402
+ if (pattern === "*" || pattern === "almadar:*") return true;
1403
+ if (pattern.endsWith(":*")) return namespace.startsWith(pattern.slice(0, -1));
1404
+ return namespace === pattern;
1405
+ });
1406
+ }
1407
+ function createLogger(namespace) {
1408
+ const nsAllowed = matchesNamespace(namespace);
1409
+ const log2 = (level, message, data, correlationId) => {
1410
+ if (LEVEL_PRIORITY[level] < MIN_PRIORITY) return;
1411
+ if (level === "DEBUG" && !nsAllowed) return;
1412
+ const prefix = `[${namespace}]`;
1413
+ const logData = correlationId ? { ...data, cid: correlationId } : data;
1414
+ switch (level) {
1415
+ case "DEBUG":
1416
+ console.debug(prefix, message, logData ?? "");
1417
+ break;
1418
+ case "INFO":
1419
+ console.info(prefix, message, logData ?? "");
1420
+ break;
1421
+ case "WARN":
1422
+ console.warn(prefix, message, logData ?? "");
1423
+ break;
1424
+ case "ERROR":
1425
+ console.error(prefix, message, logData ?? "");
1426
+ break;
1427
+ }
1428
+ };
1429
+ return {
1430
+ debug: (msg, data, cid) => log2("DEBUG", msg, data, cid),
1431
+ info: (msg, data, cid) => log2("INFO", msg, data, cid),
1432
+ warn: (msg, data, cid) => log2("WARN", msg, data, cid),
1433
+ error: (msg, data, cid) => log2("ERROR", msg, data, cid)
1434
+ };
1435
+ }
1436
+
1437
+ // hooks/useEventBus.ts
1438
+ var log = createLogger("almadar:eventbus");
1439
+ var subLog = createLogger("almadar:eventbus:subscribe");
1378
1440
  function getGlobalEventBus() {
1379
1441
  if (typeof window !== "undefined") {
1380
1442
  return window.__kflowEventBus ?? null;
@@ -1391,6 +1453,7 @@ var fallbackEventBus = {
1391
1453
  timestamp: Date.now()
1392
1454
  };
1393
1455
  const handlers = fallbackListeners.get(type);
1456
+ log.debug("emit", { type, payloadKeys: payload ? Object.keys(payload).length : 0, listenerCount: (handlers?.size ?? 0) + fallbackAnyListeners.size });
1394
1457
  if (handlers) {
1395
1458
  handlers.forEach((handler) => {
1396
1459
  try {
@@ -1413,6 +1476,7 @@ var fallbackEventBus = {
1413
1476
  fallbackListeners.set(type, /* @__PURE__ */ new Set());
1414
1477
  }
1415
1478
  fallbackListeners.get(type).add(listener);
1479
+ subLog.debug("subscribe", { type, totalListeners: fallbackListeners.get(type).size });
1416
1480
  return () => {
1417
1481
  const handlers = fallbackListeners.get(type);
1418
1482
  if (handlers) {
@@ -1436,6 +1500,7 @@ var fallbackEventBus = {
1436
1500
  },
1437
1501
  onAny: (listener) => {
1438
1502
  fallbackAnyListeners.add(listener);
1503
+ subLog.debug("subscribe:any", { totalAnyListeners: fallbackAnyListeners.size });
1439
1504
  return () => {
1440
1505
  fallbackAnyListeners.delete(listener);
1441
1506
  };
@@ -2844,6 +2909,7 @@ var Box = React21__default.default.forwardRef(
2844
2909
  action,
2845
2910
  actionPayload,
2846
2911
  hoverEvent,
2912
+ maxWidth,
2847
2913
  onClick,
2848
2914
  onMouseEnter,
2849
2915
  onMouseLeave,
@@ -2908,6 +2974,7 @@ var Box = React21__default.default.forwardRef(
2908
2974
  onClick: isClickable ? handleClick : void 0,
2909
2975
  onMouseEnter: hoverEvent || onMouseEnter ? handleMouseEnter : void 0,
2910
2976
  onMouseLeave: hoverEvent || onMouseLeave ? handleMouseLeave : void 0,
2977
+ style: maxWidth ? { maxWidth, ...rest.style } : rest.style,
2911
2978
  ...rest,
2912
2979
  children
2913
2980
  }