@almadar/ui 5.89.0 → 5.91.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.
Files changed (26) hide show
  1. package/dist/avl/index.cjs +63 -65
  2. package/dist/avl/index.js +63 -65
  3. package/dist/components/game/2d/{organisms → molecules}/ObjectRulePanel.d.ts +9 -4
  4. package/dist/components/game/2d/molecules/StateJsonView.d.ts +37 -0
  5. package/dist/components/game/2d/{organisms → molecules}/TraitSlot.d.ts +6 -3
  6. package/dist/components/game/2d/{organisms → molecules}/TraitStateViewer.d.ts +0 -2
  7. package/dist/components/game/2d/molecules/VariablePanel.d.ts +28 -0
  8. package/dist/components/game/2d/molecules/index.d.ts +11 -11
  9. package/dist/components/game/2d/organisms/EventHandlerBoard.d.ts +1 -1
  10. package/dist/components/game/2d/organisms/SequenceBar.d.ts +1 -1
  11. package/dist/components/game/shared/lib/puzzleObject.d.ts +1 -1
  12. package/dist/components/index.cjs +63 -65
  13. package/dist/components/index.js +63 -65
  14. package/dist/providers/index.cjs +63 -65
  15. package/dist/providers/index.js +63 -65
  16. package/dist/runtime/index.cjs +63 -65
  17. package/dist/runtime/index.js +63 -65
  18. package/package.json +1 -1
  19. package/dist/components/game/2d/organisms/StateJsonView.d.ts +0 -17
  20. package/dist/components/game/2d/organisms/VariablePanel.d.ts +0 -22
  21. /package/dist/components/game/2d/{organisms → molecules}/ActionPalette.d.ts +0 -0
  22. /package/dist/components/game/2d/{organisms → molecules}/ActionTile.d.ts +0 -0
  23. /package/dist/components/game/2d/{organisms → molecules}/EventLog.d.ts +0 -0
  24. /package/dist/components/game/2d/{organisms → molecules}/RuleEditor.d.ts +0 -0
  25. /package/dist/components/game/2d/{organisms → molecules}/StateNode.d.ts +0 -0
  26. /package/dist/components/game/2d/{organisms → molecules}/TransitionArrow.d.ts +0 -0
@@ -13237,7 +13237,7 @@ function StateNode({
13237
13237
  );
13238
13238
  }
13239
13239
  var init_StateNode = __esm({
13240
- "components/game/2d/organisms/StateNode.tsx"() {
13240
+ "components/game/2d/molecules/StateNode.tsx"() {
13241
13241
  init_atoms();
13242
13242
  init_cn();
13243
13243
  StateNode.displayName = "StateNode";
@@ -13309,7 +13309,7 @@ function TransitionArrow({
13309
13309
  }
13310
13310
  var NODE_RADIUS;
13311
13311
  var init_TransitionArrow = __esm({
13312
- "components/game/2d/organisms/TransitionArrow.tsx"() {
13312
+ "components/game/2d/molecules/TransitionArrow.tsx"() {
13313
13313
  init_cn();
13314
13314
  NODE_RADIUS = 40;
13315
13315
  TransitionArrow.displayName = "TransitionArrow";
@@ -15193,7 +15193,7 @@ function TraitStateViewer({
15193
15193
  }
15194
15194
  var SIZE_CONFIG;
15195
15195
  var init_TraitStateViewer = __esm({
15196
- "components/game/2d/organisms/TraitStateViewer.tsx"() {
15196
+ "components/game/2d/molecules/TraitStateViewer.tsx"() {
15197
15197
  "use client";
15198
15198
  init_cn();
15199
15199
  init_Box();
@@ -15226,7 +15226,8 @@ function TraitSlot({
15226
15226
  onClick,
15227
15227
  onRemove,
15228
15228
  clickEvent,
15229
- removeEvent
15229
+ removeEvent,
15230
+ dropEvent
15230
15231
  }) {
15231
15232
  const { emit } = useEventBus();
15232
15233
  const [isHovered, setIsHovered] = React105.useState(false);
@@ -15258,29 +15259,30 @@ function TraitSlot({
15258
15259
  onDragStart?.(equippedItem);
15259
15260
  }, [equippedItem, draggable, onDragStart]);
15260
15261
  const handleDragOver = React105.useCallback((e) => {
15261
- if (locked || !onItemDrop) return;
15262
+ if (locked || !onItemDrop && !dropEvent) return;
15262
15263
  if (e.dataTransfer.types.includes(DRAG_MIME)) {
15263
15264
  e.preventDefault();
15264
15265
  const allowed = e.dataTransfer.effectAllowed;
15265
15266
  e.dataTransfer.dropEffect = allowed === "copy" ? "copy" : "move";
15266
15267
  setIsDragOver(true);
15267
15268
  }
15268
- }, [locked, onItemDrop]);
15269
+ }, [locked, onItemDrop, dropEvent]);
15269
15270
  const handleDragLeave = React105.useCallback(() => {
15270
15271
  setIsDragOver(false);
15271
15272
  }, []);
15272
15273
  const handleDrop = React105.useCallback((e) => {
15273
15274
  e.preventDefault();
15274
15275
  setIsDragOver(false);
15275
- if (locked || !onItemDrop) return;
15276
+ if (locked || !onItemDrop && !dropEvent) return;
15276
15277
  const raw = e.dataTransfer.getData(DRAG_MIME);
15277
15278
  if (!raw) return;
15278
15279
  try {
15279
15280
  const item = JSON.parse(raw);
15280
- onItemDrop(item);
15281
+ if (dropEvent) emit(`UI:${dropEvent}`, { slotNumber, itemId: item.id });
15282
+ else onItemDrop?.(item);
15281
15283
  } catch {
15282
15284
  }
15283
- }, [locked, onItemDrop]);
15285
+ }, [locked, onItemDrop, dropEvent, emit, slotNumber]);
15284
15286
  const getTooltipStyle = () => {
15285
15287
  if (!slotRef.current) return {};
15286
15288
  const rect = slotRef.current.getBoundingClientRect();
@@ -15400,7 +15402,7 @@ function TraitSlot({
15400
15402
  }
15401
15403
  var SIZE_CONFIG2, DRAG_MIME;
15402
15404
  var init_TraitSlot = __esm({
15403
- "components/game/2d/organisms/TraitSlot.tsx"() {
15405
+ "components/game/2d/molecules/TraitSlot.tsx"() {
15404
15406
  "use client";
15405
15407
  init_cn();
15406
15408
  init_useEventBus();
@@ -15459,7 +15461,7 @@ function ActionTile({
15459
15461
  }
15460
15462
  var DRAG_MIME2, SIZE_CONFIG3;
15461
15463
  var init_ActionTile = __esm({
15462
- "components/game/2d/organisms/ActionTile.tsx"() {
15464
+ "components/game/2d/molecules/ActionTile.tsx"() {
15463
15465
  init_atoms();
15464
15466
  init_cn();
15465
15467
  DRAG_MIME2 = "application/x-almadar-slot-item";
@@ -15496,7 +15498,7 @@ function ActionPalette({
15496
15498
  ] });
15497
15499
  }
15498
15500
  var init_ActionPalette = __esm({
15499
- "components/game/2d/organisms/ActionPalette.tsx"() {
15501
+ "components/game/2d/molecules/ActionPalette.tsx"() {
15500
15502
  init_atoms();
15501
15503
  init_cn();
15502
15504
  init_ActionTile();
@@ -15872,7 +15874,7 @@ function RuleEditor({
15872
15874
  ] });
15873
15875
  }
15874
15876
  var init_RuleEditor = __esm({
15875
- "components/game/2d/organisms/RuleEditor.tsx"() {
15877
+ "components/game/2d/molecules/RuleEditor.tsx"() {
15876
15878
  init_atoms();
15877
15879
  init_cn();
15878
15880
  RuleEditor.displayName = "RuleEditor";
@@ -15913,7 +15915,7 @@ function EventLog({
15913
15915
  }
15914
15916
  var STATUS_STYLES, STATUS_DOTS;
15915
15917
  var init_EventLog = __esm({
15916
- "components/game/2d/organisms/EventLog.tsx"() {
15918
+ "components/game/2d/molecules/EventLog.tsx"() {
15917
15919
  init_atoms();
15918
15920
  init_cn();
15919
15921
  STATUS_STYLES = {
@@ -15968,10 +15970,12 @@ var init_puzzleObject = __esm({
15968
15970
  function ObjectRulePanel({
15969
15971
  object,
15970
15972
  onRulesChange,
15973
+ rulesChangeEvent,
15971
15974
  disabled = false,
15972
15975
  className
15973
15976
  }) {
15974
15977
  const { t } = hooks.useTranslate();
15978
+ const { emit } = useEventBus();
15975
15979
  const id = objId(object);
15976
15980
  const name = objName(object);
15977
15981
  const icon = objIcon(object);
@@ -15982,15 +15986,19 @@ function ObjectRulePanel({
15982
15986
  const rules = objRules(object);
15983
15987
  const maxRules = objMaxRules(object);
15984
15988
  const canAdd = rules.length < maxRules;
15989
+ const emitRules = React105.useCallback((newRules) => {
15990
+ if (rulesChangeEvent) emit(`UI:${rulesChangeEvent}`, { objectId: id, rules: newRules });
15991
+ else onRulesChange?.(id, newRules);
15992
+ }, [rulesChangeEvent, emit, id, onRulesChange]);
15985
15993
  const handleRuleChange = React105.useCallback((index, updatedRule) => {
15986
15994
  const newRules = [...rules];
15987
15995
  newRules[index] = updatedRule;
15988
- onRulesChange(id, newRules);
15989
- }, [id, rules, onRulesChange]);
15996
+ emitRules(newRules);
15997
+ }, [rules, emitRules]);
15990
15998
  const handleRuleRemove = React105.useCallback((index) => {
15991
15999
  const newRules = rules.filter((_, i) => i !== index);
15992
- onRulesChange(id, newRules);
15993
- }, [id, rules, onRulesChange]);
16000
+ emitRules(newRules);
16001
+ }, [rules, emitRules]);
15994
16002
  const handleAddRule = React105.useCallback(() => {
15995
16003
  if (!canAdd || disabled) return;
15996
16004
  const firstEvent = availableEvents[0]?.value || "";
@@ -16000,8 +16008,8 @@ function ObjectRulePanel({
16000
16008
  whenEvent: firstEvent,
16001
16009
  thenAction: firstAction
16002
16010
  };
16003
- onRulesChange(id, [...rules, newRule]);
16004
- }, [canAdd, disabled, id, rules, availableEvents, availableActions, onRulesChange]);
16011
+ emitRules([...rules, newRule]);
16012
+ }, [canAdd, disabled, rules, availableEvents, availableActions, emitRules]);
16005
16013
  const machine = {
16006
16014
  name,
16007
16015
  states,
@@ -16041,9 +16049,10 @@ function ObjectRulePanel({
16041
16049
  }
16042
16050
  var nextRuleId;
16043
16051
  var init_ObjectRulePanel = __esm({
16044
- "components/game/2d/organisms/ObjectRulePanel.tsx"() {
16052
+ "components/game/2d/molecules/ObjectRulePanel.tsx"() {
16045
16053
  init_atoms();
16046
16054
  init_cn();
16055
+ init_useEventBus();
16047
16056
  init_TraitStateViewer();
16048
16057
  init_RuleEditor();
16049
16058
  init_puzzleObject();
@@ -16273,61 +16282,35 @@ function VariablePanel({
16273
16282
  const { t } = hooks.useTranslate();
16274
16283
  return /* @__PURE__ */ jsxRuntime.jsxs(VStack, { className: cn("p-3 rounded-lg bg-card border border-border", className), gap: "sm", children: [
16275
16284
  /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "body2", className: "text-muted-foreground font-medium", children: t("stateArchitect.variables", { name: entityName }) }),
16276
- variables.map((v) => {
16277
- const name = v.name == null ? "" : String(v.name);
16278
- const value = numField(v.value);
16279
- const max = numField(v.max, 100);
16280
- const min = numField(v.min, 0);
16281
- const unit = v.unit == null ? "" : String(v.unit);
16282
- const pct = Math.round((value - min) / (max - min) * 100);
16283
- const isHigh = pct > 80;
16284
- const isLow = pct < 20;
16285
- return /* @__PURE__ */ jsxRuntime.jsxs(VStack, { gap: "none", children: [
16286
- /* @__PURE__ */ jsxRuntime.jsxs(HStack, { className: "items-center justify-between", children: [
16287
- /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "caption", className: "text-foreground font-medium", children: name }),
16288
- /* @__PURE__ */ jsxRuntime.jsxs(Typography, { variant: "caption", className: cn(
16289
- isHigh ? "text-error" : isLow ? "text-warning" : "text-foreground"
16290
- ), children: [
16291
- value,
16292
- unit,
16293
- " / ",
16294
- max,
16295
- unit
16296
- ] })
16297
- ] }),
16298
- /* @__PURE__ */ jsxRuntime.jsx(
16299
- ProgressBar,
16300
- {
16301
- value: pct,
16302
- color: isHigh ? "danger" : isLow ? "warning" : "primary",
16303
- size: "sm"
16304
- }
16305
- )
16306
- ] }, name);
16307
- })
16285
+ (variables ?? []).map((v) => /* @__PURE__ */ jsxRuntime.jsxs(HStack, { className: "items-center justify-between", children: [
16286
+ /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "caption", className: "text-foreground font-medium", children: v.name }),
16287
+ /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "caption", className: "text-accent font-mono", children: v.value })
16288
+ ] }, v.name))
16308
16289
  ] });
16309
16290
  }
16310
- var numField;
16311
16291
  var init_VariablePanel = __esm({
16312
- "components/game/2d/organisms/VariablePanel.tsx"() {
16292
+ "components/game/2d/molecules/VariablePanel.tsx"() {
16313
16293
  init_atoms();
16314
16294
  init_cn();
16315
- numField = (v, fallback = 0) => {
16316
- const n = Number(v);
16317
- return Number.isFinite(n) ? n : fallback;
16318
- };
16319
16295
  VariablePanel.displayName = "VariablePanel";
16320
16296
  }
16321
16297
  });
16322
16298
  function StateJsonView({
16323
- data,
16299
+ name,
16300
+ initialState,
16301
+ states,
16302
+ transitions,
16324
16303
  label,
16325
16304
  defaultExpanded = false,
16326
16305
  className
16327
16306
  }) {
16328
16307
  const { t } = hooks.useTranslate();
16329
16308
  const [expanded, setExpanded] = React105.useState(defaultExpanded);
16330
- const jsonString = JSON.stringify(data, null, 2);
16309
+ const jsonString = JSON.stringify(
16310
+ { name, initialState, states: states ?? [], transitions: transitions ?? [] },
16311
+ null,
16312
+ 2
16313
+ );
16331
16314
  return /* @__PURE__ */ jsxRuntime.jsxs(VStack, { className: cn("rounded-lg border border-border overflow-hidden", className), gap: "none", children: [
16332
16315
  /* @__PURE__ */ jsxRuntime.jsxs(HStack, { className: "items-center justify-between p-2 bg-muted", gap: "sm", children: [
16333
16316
  /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "caption", className: "text-muted-foreground font-medium", children: label ?? t("stateArchitect.viewCode") }),
@@ -16344,7 +16327,7 @@ function StateJsonView({
16344
16327
  ] });
16345
16328
  }
16346
16329
  var init_StateJsonView = __esm({
16347
- "components/game/2d/organisms/StateJsonView.tsx"() {
16330
+ "components/game/2d/molecules/StateJsonView.tsx"() {
16348
16331
  init_atoms();
16349
16332
  init_cn();
16350
16333
  StateJsonView.displayName = "StateJsonView";
@@ -16513,7 +16496,7 @@ function StateArchitectBoard({
16513
16496
  setAddingFrom(null);
16514
16497
  if (playAgainEvent) emit(`UI:${playAgainEvent}`, {});
16515
16498
  }, [initialState, entityVariables, playAgainEvent, emit]);
16516
- const codeData = React105.useMemo(() => ({
16499
+ React105.useMemo(() => ({
16517
16500
  name: entityName,
16518
16501
  states: entityStates,
16519
16502
  initialState,
@@ -16648,7 +16631,7 @@ function StateArchitectBoard({
16648
16631
  VariablePanel,
16649
16632
  {
16650
16633
  entityName,
16651
- variables
16634
+ variables: variables.map((v) => ({ name: String(v.name ?? ""), value: String(v.value ?? "") }))
16652
16635
  }
16653
16636
  ),
16654
16637
  testResults.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(VStack, { className: "p-3 rounded-container bg-card border border-border", gap: "xs", children: [
@@ -16659,7 +16642,16 @@ function StateArchitectBoard({
16659
16642
  !r2.passed && /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "caption", className: "text-error", children: t("stateArchitect.gotState", { state: r2.actualState }) })
16660
16643
  ] }, i))
16661
16644
  ] }),
16662
- resolved.showCodeView !== false && /* @__PURE__ */ jsxRuntime.jsx(StateJsonView, { data: codeData, label: "View Code" })
16645
+ resolved.showCodeView !== false && /* @__PURE__ */ jsxRuntime.jsx(
16646
+ StateJsonView,
16647
+ {
16648
+ name: entityName,
16649
+ initialState,
16650
+ states: entityStates,
16651
+ transitions: transitions.map((tr) => ({ from: tr.from, to: tr.to, event: tr.event })),
16652
+ label: "View Code"
16653
+ }
16654
+ )
16663
16655
  ] })
16664
16656
  ] }),
16665
16657
  isSuccess && /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "p-4 rounded-container bg-success/20 border border-success text-center", children: /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "h5", className: "text-success", children: str(resolved.successMessage) || t("stateArchitect.allPassed") }) }),
@@ -48397,6 +48389,7 @@ var init_component_registry_generated = __esm({
48397
48389
  init_Navigation();
48398
48390
  init_NegotiatorBoard();
48399
48391
  init_NumberStepper();
48392
+ init_ObjectRulePanel();
48400
48393
  init_OptionConstraintGroup();
48401
48394
  init_OrbitalVisualization();
48402
48395
  init_Overlay();
@@ -48460,6 +48453,7 @@ var init_component_registry_generated = __esm({
48460
48453
  init_StateArchitectBoard();
48461
48454
  init_StateGraph();
48462
48455
  init_StateIndicator();
48456
+ init_StateJsonView();
48463
48457
  init_StateMachineView();
48464
48458
  init_StatsGrid();
48465
48459
  init_StatsOrganism();
@@ -48506,6 +48500,7 @@ var init_component_registry_generated = __esm({
48506
48500
  init_Typography();
48507
48501
  init_UISlotRenderer();
48508
48502
  init_UploadDropZone();
48503
+ init_VariablePanel();
48509
48504
  init_VersionDiff();
48510
48505
  init_ViolationAlert();
48511
48506
  init_VoteStack();
@@ -48706,6 +48701,7 @@ var init_component_registry_generated = __esm({
48706
48701
  "Navigation": Navigation,
48707
48702
  "NegotiatorBoard": NegotiatorBoard,
48708
48703
  "NumberStepper": NumberStepper,
48704
+ "ObjectRulePanel": ObjectRulePanel,
48709
48705
  "OptionConstraintGroup": OptionConstraintGroup,
48710
48706
  "OrbitalVisualization": OrbitalVisualization,
48711
48707
  "Overlay": Overlay,
@@ -48772,6 +48768,7 @@ var init_component_registry_generated = __esm({
48772
48768
  "StateArchitectBoard": StateArchitectBoard,
48773
48769
  "StateGraph": StateGraph,
48774
48770
  "StateIndicator": StateIndicator,
48771
+ "StateJsonView": StateJsonView,
48775
48772
  "StateMachineView": StateMachineView,
48776
48773
  "StatsGrid": StatsGrid,
48777
48774
  "StatsOrganism": StatsOrganism,
@@ -48819,6 +48816,7 @@ var init_component_registry_generated = __esm({
48819
48816
  "UISlotRenderer": UISlotRenderer,
48820
48817
  "UploadDropZone": UploadDropZone,
48821
48818
  "VStack": VStack,
48819
+ "VariablePanel": VariablePanel,
48822
48820
  "VersionDiff": VersionDiff,
48823
48821
  "ViolationAlert": ViolationAlert,
48824
48822
  "VoteStack": VoteStack,
package/dist/avl/index.js CHANGED
@@ -13191,7 +13191,7 @@ function StateNode({
13191
13191
  );
13192
13192
  }
13193
13193
  var init_StateNode = __esm({
13194
- "components/game/2d/organisms/StateNode.tsx"() {
13194
+ "components/game/2d/molecules/StateNode.tsx"() {
13195
13195
  init_atoms();
13196
13196
  init_cn();
13197
13197
  StateNode.displayName = "StateNode";
@@ -13263,7 +13263,7 @@ function TransitionArrow({
13263
13263
  }
13264
13264
  var NODE_RADIUS;
13265
13265
  var init_TransitionArrow = __esm({
13266
- "components/game/2d/organisms/TransitionArrow.tsx"() {
13266
+ "components/game/2d/molecules/TransitionArrow.tsx"() {
13267
13267
  init_cn();
13268
13268
  NODE_RADIUS = 40;
13269
13269
  TransitionArrow.displayName = "TransitionArrow";
@@ -15147,7 +15147,7 @@ function TraitStateViewer({
15147
15147
  }
15148
15148
  var SIZE_CONFIG;
15149
15149
  var init_TraitStateViewer = __esm({
15150
- "components/game/2d/organisms/TraitStateViewer.tsx"() {
15150
+ "components/game/2d/molecules/TraitStateViewer.tsx"() {
15151
15151
  "use client";
15152
15152
  init_cn();
15153
15153
  init_Box();
@@ -15180,7 +15180,8 @@ function TraitSlot({
15180
15180
  onClick,
15181
15181
  onRemove,
15182
15182
  clickEvent,
15183
- removeEvent
15183
+ removeEvent,
15184
+ dropEvent
15184
15185
  }) {
15185
15186
  const { emit } = useEventBus();
15186
15187
  const [isHovered, setIsHovered] = useState(false);
@@ -15212,29 +15213,30 @@ function TraitSlot({
15212
15213
  onDragStart?.(equippedItem);
15213
15214
  }, [equippedItem, draggable, onDragStart]);
15214
15215
  const handleDragOver = useCallback((e) => {
15215
- if (locked || !onItemDrop) return;
15216
+ if (locked || !onItemDrop && !dropEvent) return;
15216
15217
  if (e.dataTransfer.types.includes(DRAG_MIME)) {
15217
15218
  e.preventDefault();
15218
15219
  const allowed = e.dataTransfer.effectAllowed;
15219
15220
  e.dataTransfer.dropEffect = allowed === "copy" ? "copy" : "move";
15220
15221
  setIsDragOver(true);
15221
15222
  }
15222
- }, [locked, onItemDrop]);
15223
+ }, [locked, onItemDrop, dropEvent]);
15223
15224
  const handleDragLeave = useCallback(() => {
15224
15225
  setIsDragOver(false);
15225
15226
  }, []);
15226
15227
  const handleDrop = useCallback((e) => {
15227
15228
  e.preventDefault();
15228
15229
  setIsDragOver(false);
15229
- if (locked || !onItemDrop) return;
15230
+ if (locked || !onItemDrop && !dropEvent) return;
15230
15231
  const raw = e.dataTransfer.getData(DRAG_MIME);
15231
15232
  if (!raw) return;
15232
15233
  try {
15233
15234
  const item = JSON.parse(raw);
15234
- onItemDrop(item);
15235
+ if (dropEvent) emit(`UI:${dropEvent}`, { slotNumber, itemId: item.id });
15236
+ else onItemDrop?.(item);
15235
15237
  } catch {
15236
15238
  }
15237
- }, [locked, onItemDrop]);
15239
+ }, [locked, onItemDrop, dropEvent, emit, slotNumber]);
15238
15240
  const getTooltipStyle = () => {
15239
15241
  if (!slotRef.current) return {};
15240
15242
  const rect = slotRef.current.getBoundingClientRect();
@@ -15354,7 +15356,7 @@ function TraitSlot({
15354
15356
  }
15355
15357
  var SIZE_CONFIG2, DRAG_MIME;
15356
15358
  var init_TraitSlot = __esm({
15357
- "components/game/2d/organisms/TraitSlot.tsx"() {
15359
+ "components/game/2d/molecules/TraitSlot.tsx"() {
15358
15360
  "use client";
15359
15361
  init_cn();
15360
15362
  init_useEventBus();
@@ -15413,7 +15415,7 @@ function ActionTile({
15413
15415
  }
15414
15416
  var DRAG_MIME2, SIZE_CONFIG3;
15415
15417
  var init_ActionTile = __esm({
15416
- "components/game/2d/organisms/ActionTile.tsx"() {
15418
+ "components/game/2d/molecules/ActionTile.tsx"() {
15417
15419
  init_atoms();
15418
15420
  init_cn();
15419
15421
  DRAG_MIME2 = "application/x-almadar-slot-item";
@@ -15450,7 +15452,7 @@ function ActionPalette({
15450
15452
  ] });
15451
15453
  }
15452
15454
  var init_ActionPalette = __esm({
15453
- "components/game/2d/organisms/ActionPalette.tsx"() {
15455
+ "components/game/2d/molecules/ActionPalette.tsx"() {
15454
15456
  init_atoms();
15455
15457
  init_cn();
15456
15458
  init_ActionTile();
@@ -15826,7 +15828,7 @@ function RuleEditor({
15826
15828
  ] });
15827
15829
  }
15828
15830
  var init_RuleEditor = __esm({
15829
- "components/game/2d/organisms/RuleEditor.tsx"() {
15831
+ "components/game/2d/molecules/RuleEditor.tsx"() {
15830
15832
  init_atoms();
15831
15833
  init_cn();
15832
15834
  RuleEditor.displayName = "RuleEditor";
@@ -15867,7 +15869,7 @@ function EventLog({
15867
15869
  }
15868
15870
  var STATUS_STYLES, STATUS_DOTS;
15869
15871
  var init_EventLog = __esm({
15870
- "components/game/2d/organisms/EventLog.tsx"() {
15872
+ "components/game/2d/molecules/EventLog.tsx"() {
15871
15873
  init_atoms();
15872
15874
  init_cn();
15873
15875
  STATUS_STYLES = {
@@ -15922,10 +15924,12 @@ var init_puzzleObject = __esm({
15922
15924
  function ObjectRulePanel({
15923
15925
  object,
15924
15926
  onRulesChange,
15927
+ rulesChangeEvent,
15925
15928
  disabled = false,
15926
15929
  className
15927
15930
  }) {
15928
15931
  const { t } = useTranslate();
15932
+ const { emit } = useEventBus();
15929
15933
  const id = objId(object);
15930
15934
  const name = objName(object);
15931
15935
  const icon = objIcon(object);
@@ -15936,15 +15940,19 @@ function ObjectRulePanel({
15936
15940
  const rules = objRules(object);
15937
15941
  const maxRules = objMaxRules(object);
15938
15942
  const canAdd = rules.length < maxRules;
15943
+ const emitRules = useCallback((newRules) => {
15944
+ if (rulesChangeEvent) emit(`UI:${rulesChangeEvent}`, { objectId: id, rules: newRules });
15945
+ else onRulesChange?.(id, newRules);
15946
+ }, [rulesChangeEvent, emit, id, onRulesChange]);
15939
15947
  const handleRuleChange = useCallback((index, updatedRule) => {
15940
15948
  const newRules = [...rules];
15941
15949
  newRules[index] = updatedRule;
15942
- onRulesChange(id, newRules);
15943
- }, [id, rules, onRulesChange]);
15950
+ emitRules(newRules);
15951
+ }, [rules, emitRules]);
15944
15952
  const handleRuleRemove = useCallback((index) => {
15945
15953
  const newRules = rules.filter((_, i) => i !== index);
15946
- onRulesChange(id, newRules);
15947
- }, [id, rules, onRulesChange]);
15954
+ emitRules(newRules);
15955
+ }, [rules, emitRules]);
15948
15956
  const handleAddRule = useCallback(() => {
15949
15957
  if (!canAdd || disabled) return;
15950
15958
  const firstEvent = availableEvents[0]?.value || "";
@@ -15954,8 +15962,8 @@ function ObjectRulePanel({
15954
15962
  whenEvent: firstEvent,
15955
15963
  thenAction: firstAction
15956
15964
  };
15957
- onRulesChange(id, [...rules, newRule]);
15958
- }, [canAdd, disabled, id, rules, availableEvents, availableActions, onRulesChange]);
15965
+ emitRules([...rules, newRule]);
15966
+ }, [canAdd, disabled, rules, availableEvents, availableActions, emitRules]);
15959
15967
  const machine = {
15960
15968
  name,
15961
15969
  states,
@@ -15995,9 +16003,10 @@ function ObjectRulePanel({
15995
16003
  }
15996
16004
  var nextRuleId;
15997
16005
  var init_ObjectRulePanel = __esm({
15998
- "components/game/2d/organisms/ObjectRulePanel.tsx"() {
16006
+ "components/game/2d/molecules/ObjectRulePanel.tsx"() {
15999
16007
  init_atoms();
16000
16008
  init_cn();
16009
+ init_useEventBus();
16001
16010
  init_TraitStateViewer();
16002
16011
  init_RuleEditor();
16003
16012
  init_puzzleObject();
@@ -16227,61 +16236,35 @@ function VariablePanel({
16227
16236
  const { t } = useTranslate();
16228
16237
  return /* @__PURE__ */ jsxs(VStack, { className: cn("p-3 rounded-lg bg-card border border-border", className), gap: "sm", children: [
16229
16238
  /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground font-medium", children: t("stateArchitect.variables", { name: entityName }) }),
16230
- variables.map((v) => {
16231
- const name = v.name == null ? "" : String(v.name);
16232
- const value = numField(v.value);
16233
- const max = numField(v.max, 100);
16234
- const min = numField(v.min, 0);
16235
- const unit = v.unit == null ? "" : String(v.unit);
16236
- const pct = Math.round((value - min) / (max - min) * 100);
16237
- const isHigh = pct > 80;
16238
- const isLow = pct < 20;
16239
- return /* @__PURE__ */ jsxs(VStack, { gap: "none", children: [
16240
- /* @__PURE__ */ jsxs(HStack, { className: "items-center justify-between", children: [
16241
- /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-foreground font-medium", children: name }),
16242
- /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: cn(
16243
- isHigh ? "text-error" : isLow ? "text-warning" : "text-foreground"
16244
- ), children: [
16245
- value,
16246
- unit,
16247
- " / ",
16248
- max,
16249
- unit
16250
- ] })
16251
- ] }),
16252
- /* @__PURE__ */ jsx(
16253
- ProgressBar,
16254
- {
16255
- value: pct,
16256
- color: isHigh ? "danger" : isLow ? "warning" : "primary",
16257
- size: "sm"
16258
- }
16259
- )
16260
- ] }, name);
16261
- })
16239
+ (variables ?? []).map((v) => /* @__PURE__ */ jsxs(HStack, { className: "items-center justify-between", children: [
16240
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-foreground font-medium", children: v.name }),
16241
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-accent font-mono", children: v.value })
16242
+ ] }, v.name))
16262
16243
  ] });
16263
16244
  }
16264
- var numField;
16265
16245
  var init_VariablePanel = __esm({
16266
- "components/game/2d/organisms/VariablePanel.tsx"() {
16246
+ "components/game/2d/molecules/VariablePanel.tsx"() {
16267
16247
  init_atoms();
16268
16248
  init_cn();
16269
- numField = (v, fallback = 0) => {
16270
- const n = Number(v);
16271
- return Number.isFinite(n) ? n : fallback;
16272
- };
16273
16249
  VariablePanel.displayName = "VariablePanel";
16274
16250
  }
16275
16251
  });
16276
16252
  function StateJsonView({
16277
- data,
16253
+ name,
16254
+ initialState,
16255
+ states,
16256
+ transitions,
16278
16257
  label,
16279
16258
  defaultExpanded = false,
16280
16259
  className
16281
16260
  }) {
16282
16261
  const { t } = useTranslate();
16283
16262
  const [expanded, setExpanded] = useState(defaultExpanded);
16284
- const jsonString = JSON.stringify(data, null, 2);
16263
+ const jsonString = JSON.stringify(
16264
+ { name, initialState, states: states ?? [], transitions: transitions ?? [] },
16265
+ null,
16266
+ 2
16267
+ );
16285
16268
  return /* @__PURE__ */ jsxs(VStack, { className: cn("rounded-lg border border-border overflow-hidden", className), gap: "none", children: [
16286
16269
  /* @__PURE__ */ jsxs(HStack, { className: "items-center justify-between p-2 bg-muted", gap: "sm", children: [
16287
16270
  /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground font-medium", children: label ?? t("stateArchitect.viewCode") }),
@@ -16298,7 +16281,7 @@ function StateJsonView({
16298
16281
  ] });
16299
16282
  }
16300
16283
  var init_StateJsonView = __esm({
16301
- "components/game/2d/organisms/StateJsonView.tsx"() {
16284
+ "components/game/2d/molecules/StateJsonView.tsx"() {
16302
16285
  init_atoms();
16303
16286
  init_cn();
16304
16287
  StateJsonView.displayName = "StateJsonView";
@@ -16467,7 +16450,7 @@ function StateArchitectBoard({
16467
16450
  setAddingFrom(null);
16468
16451
  if (playAgainEvent) emit(`UI:${playAgainEvent}`, {});
16469
16452
  }, [initialState, entityVariables, playAgainEvent, emit]);
16470
- const codeData = useMemo(() => ({
16453
+ useMemo(() => ({
16471
16454
  name: entityName,
16472
16455
  states: entityStates,
16473
16456
  initialState,
@@ -16602,7 +16585,7 @@ function StateArchitectBoard({
16602
16585
  VariablePanel,
16603
16586
  {
16604
16587
  entityName,
16605
- variables
16588
+ variables: variables.map((v) => ({ name: String(v.name ?? ""), value: String(v.value ?? "") }))
16606
16589
  }
16607
16590
  ),
16608
16591
  testResults.length > 0 && /* @__PURE__ */ jsxs(VStack, { className: "p-3 rounded-container bg-card border border-border", gap: "xs", children: [
@@ -16613,7 +16596,16 @@ function StateArchitectBoard({
16613
16596
  !r2.passed && /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-error", children: t("stateArchitect.gotState", { state: r2.actualState }) })
16614
16597
  ] }, i))
16615
16598
  ] }),
16616
- resolved.showCodeView !== false && /* @__PURE__ */ jsx(StateJsonView, { data: codeData, label: "View Code" })
16599
+ resolved.showCodeView !== false && /* @__PURE__ */ jsx(
16600
+ StateJsonView,
16601
+ {
16602
+ name: entityName,
16603
+ initialState,
16604
+ states: entityStates,
16605
+ transitions: transitions.map((tr) => ({ from: tr.from, to: tr.to, event: tr.event })),
16606
+ label: "View Code"
16607
+ }
16608
+ )
16617
16609
  ] })
16618
16610
  ] }),
16619
16611
  isSuccess && /* @__PURE__ */ jsx(Box, { className: "p-4 rounded-container bg-success/20 border border-success text-center", children: /* @__PURE__ */ jsx(Typography, { variant: "h5", className: "text-success", children: str(resolved.successMessage) || t("stateArchitect.allPassed") }) }),
@@ -48351,6 +48343,7 @@ var init_component_registry_generated = __esm({
48351
48343
  init_Navigation();
48352
48344
  init_NegotiatorBoard();
48353
48345
  init_NumberStepper();
48346
+ init_ObjectRulePanel();
48354
48347
  init_OptionConstraintGroup();
48355
48348
  init_OrbitalVisualization();
48356
48349
  init_Overlay();
@@ -48414,6 +48407,7 @@ var init_component_registry_generated = __esm({
48414
48407
  init_StateArchitectBoard();
48415
48408
  init_StateGraph();
48416
48409
  init_StateIndicator();
48410
+ init_StateJsonView();
48417
48411
  init_StateMachineView();
48418
48412
  init_StatsGrid();
48419
48413
  init_StatsOrganism();
@@ -48460,6 +48454,7 @@ var init_component_registry_generated = __esm({
48460
48454
  init_Typography();
48461
48455
  init_UISlotRenderer();
48462
48456
  init_UploadDropZone();
48457
+ init_VariablePanel();
48463
48458
  init_VersionDiff();
48464
48459
  init_ViolationAlert();
48465
48460
  init_VoteStack();
@@ -48660,6 +48655,7 @@ var init_component_registry_generated = __esm({
48660
48655
  "Navigation": Navigation,
48661
48656
  "NegotiatorBoard": NegotiatorBoard,
48662
48657
  "NumberStepper": NumberStepper,
48658
+ "ObjectRulePanel": ObjectRulePanel,
48663
48659
  "OptionConstraintGroup": OptionConstraintGroup,
48664
48660
  "OrbitalVisualization": OrbitalVisualization,
48665
48661
  "Overlay": Overlay,
@@ -48726,6 +48722,7 @@ var init_component_registry_generated = __esm({
48726
48722
  "StateArchitectBoard": StateArchitectBoard,
48727
48723
  "StateGraph": StateGraph,
48728
48724
  "StateIndicator": StateIndicator,
48725
+ "StateJsonView": StateJsonView,
48729
48726
  "StateMachineView": StateMachineView,
48730
48727
  "StatsGrid": StatsGrid,
48731
48728
  "StatsOrganism": StatsOrganism,
@@ -48773,6 +48770,7 @@ var init_component_registry_generated = __esm({
48773
48770
  "UISlotRenderer": UISlotRenderer,
48774
48771
  "UploadDropZone": UploadDropZone,
48775
48772
  "VStack": VStack,
48773
+ "VariablePanel": VariablePanel,
48776
48774
  "VersionDiff": VersionDiff,
48777
48775
  "ViolationAlert": ViolationAlert,
48778
48776
  "VoteStack": VoteStack,