@almadar/ui 6.19.0 → 6.21.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.
@@ -1577,6 +1577,36 @@ var init_Typography = __esm({
1577
1577
  Typography.displayName = "Typography";
1578
1578
  }
1579
1579
  });
1580
+
1581
+ // lib/portalRoot.ts
1582
+ function lastThemedElement(selector, portalRoot) {
1583
+ const matches = Array.from(document.querySelectorAll(selector)).filter(
1584
+ (el) => el !== document.documentElement && el !== portalRoot
1585
+ );
1586
+ return matches[matches.length - 1] ?? null;
1587
+ }
1588
+ function getOrCreatePortalRoot() {
1589
+ let root = document.getElementById("ui-slot-portal-root");
1590
+ if (!root) {
1591
+ root = document.createElement("div");
1592
+ root.id = "ui-slot-portal-root";
1593
+ root.style.position = "relative";
1594
+ root.style.zIndex = "9999";
1595
+ document.body.appendChild(root);
1596
+ }
1597
+ const themed = lastThemedElement('[data-theme*="-"]', root) ?? lastThemedElement("[data-theme]", root);
1598
+ if (themed) {
1599
+ const theme = themed.getAttribute("data-theme");
1600
+ if (theme && root.getAttribute("data-theme") !== theme) {
1601
+ root.setAttribute("data-theme", theme);
1602
+ }
1603
+ }
1604
+ return root;
1605
+ }
1606
+ var init_portalRoot = __esm({
1607
+ "lib/portalRoot.ts"() {
1608
+ }
1609
+ });
1580
1610
  function isMotionEnabled() {
1581
1611
  if (typeof document === "undefined") return true;
1582
1612
  if (motionEnabledCache !== null) return motionEnabledCache;
@@ -1657,6 +1687,7 @@ var init_Modal = __esm({
1657
1687
  init_Dialog();
1658
1688
  init_Typography();
1659
1689
  init_cn();
1690
+ init_portalRoot();
1660
1691
  init_useEventBus();
1661
1692
  init_Presence();
1662
1693
  sizeClasses2 = {
@@ -1867,7 +1898,7 @@ var init_Modal = __esm({
1867
1898
  )
1868
1899
  }
1869
1900
  ),
1870
- document.body
1901
+ getOrCreatePortalRoot()
1871
1902
  );
1872
1903
  };
1873
1904
  Modal.displayName = "Modal";
@@ -20503,6 +20534,7 @@ var init_StateMachineView = __esm({
20503
20534
  init_Icon();
20504
20535
  init_useEventBus();
20505
20536
  init_cn();
20537
+ init_portalRoot();
20506
20538
  StateNode2 = ({ state, config }) => {
20507
20539
  const { t } = hooks.useTranslate();
20508
20540
  const size = state.radius * 2;
@@ -21019,7 +21051,7 @@ var init_StateMachineView = __esm({
21019
21051
  )
21020
21052
  }
21021
21053
  ),
21022
- document.body
21054
+ getOrCreatePortalRoot()
21023
21055
  );
21024
21056
  };
21025
21057
  EntityBox = ({ entity, config }) => {
@@ -27660,7 +27692,7 @@ function SubMenu({
27660
27692
  })
27661
27693
  }
27662
27694
  );
27663
- return typeof document !== "undefined" ? reactDom.createPortal(panel, document.body) : panel;
27695
+ return typeof document !== "undefined" ? reactDom.createPortal(panel, getOrCreatePortalRoot()) : panel;
27664
27696
  }
27665
27697
  function MenuItemRow({
27666
27698
  item,
@@ -27747,6 +27779,7 @@ var init_Menu = __esm({
27747
27779
  init_Typography();
27748
27780
  init_Badge();
27749
27781
  init_cn();
27782
+ init_portalRoot();
27750
27783
  init_useEventBus();
27751
27784
  MENU_GAP = 4;
27752
27785
  menuContainerStyles = cn(
@@ -27883,7 +27916,7 @@ var init_Menu = __esm({
27883
27916
  ) : null;
27884
27917
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
27885
27918
  triggerElement,
27886
- panel && typeof document !== "undefined" ? reactDom.createPortal(panel, document.body) : panel
27919
+ panel && typeof document !== "undefined" ? reactDom.createPortal(panel, getOrCreatePortalRoot()) : panel
27887
27920
  ] });
27888
27921
  };
27889
27922
  Menu.displayName = "Menu";
@@ -31267,6 +31300,7 @@ var init_Popover = __esm({
31267
31300
  init_Typography();
31268
31301
  init_Presence();
31269
31302
  init_cn();
31303
+ init_portalRoot();
31270
31304
  init_useTapReveal();
31271
31305
  arrowClasses = {
31272
31306
  top: "top-full left-1/2 -translate-x-1/2 border-t-white border-l-transparent border-r-transparent border-b-transparent",
@@ -31426,7 +31460,7 @@ var init_Popover = __esm({
31426
31460
  ) : null;
31427
31461
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
31428
31462
  triggerElement,
31429
- panel && typeof document !== "undefined" ? reactDom.createPortal(panel, document.body) : panel
31463
+ panel && typeof document !== "undefined" ? reactDom.createPortal(panel, getOrCreatePortalRoot()) : panel
31430
31464
  ] });
31431
31465
  };
31432
31466
  Popover.displayName = "Popover";
@@ -31932,6 +31966,7 @@ var init_Tooltip = __esm({
31932
31966
  "use client";
31933
31967
  init_Typography();
31934
31968
  init_cn();
31969
+ init_portalRoot();
31935
31970
  init_useTapReveal();
31936
31971
  TRIGGER_GAP2 = 8;
31937
31972
  arrowClasses2 = {
@@ -32037,7 +32072,7 @@ var init_Tooltip = __esm({
32037
32072
  ) : null;
32038
32073
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
32039
32074
  trigger,
32040
- typeof window !== "undefined" && tooltipContent ? reactDom.createPortal(tooltipContent, document.body) : tooltipContent
32075
+ typeof window !== "undefined" && tooltipContent ? reactDom.createPortal(tooltipContent, getOrCreatePortalRoot()) : tooltipContent
32041
32076
  ] });
32042
32077
  };
32043
32078
  Tooltip.displayName = "Tooltip";
@@ -43457,6 +43492,7 @@ var init_GraphCanvas = __esm({
43457
43492
  "components/core/molecules/GraphCanvas.tsx"() {
43458
43493
  "use client";
43459
43494
  init_cn();
43495
+ init_portalRoot();
43460
43496
  init_atoms();
43461
43497
  init_Stack();
43462
43498
  init_LoadingState();
@@ -44168,7 +44204,7 @@ var init_GraphCanvas = __esm({
44168
44204
  children: hoveredObj?.label
44169
44205
  }
44170
44206
  ),
44171
- document.body
44207
+ getOrCreatePortalRoot()
44172
44208
  )
44173
44209
  ] }),
44174
44210
  groups.length > 1 && /* @__PURE__ */ jsxRuntime.jsx(HStack, { gap: "md", className: "px-4 py-2 border-t border-border", wrap: true, children: groups.map((group, idx) => /* @__PURE__ */ jsxRuntime.jsxs(HStack, { gap: "xs", align: "center", children: [
@@ -45329,6 +45365,7 @@ var init_DetailPanel = __esm({
45329
45365
  init_ErrorState();
45330
45366
  init_EmptyState();
45331
45367
  init_cn();
45368
+ init_portalRoot();
45332
45369
  init_format();
45333
45370
  init_getNestedValue();
45334
45371
  init_relationLabel();
@@ -45748,7 +45785,7 @@ var init_DetailPanel = __esm({
45748
45785
  return /* @__PURE__ */ jsxRuntime.jsx(Box, { className, children: content });
45749
45786
  }
45750
45787
  const panel = /* @__PURE__ */ jsxRuntime.jsx(Box, { className: cn("fixed inset-y-0 right-0 w-full max-w-2xl bg-card shadow-lg z-50 overflow-y-auto p-6", className), children: content });
45751
- return typeof document === "undefined" ? panel : reactDom.createPortal(panel, document.body);
45788
+ return typeof document === "undefined" ? panel : reactDom.createPortal(panel, getOrCreatePortalRoot());
45752
45789
  };
45753
45790
  DetailPanel.displayName = "DetailPanel";
45754
45791
  }
@@ -52639,24 +52676,6 @@ function UISlotComponentInner({
52639
52676
  }
52640
52677
  );
52641
52678
  }
52642
- function getOrCreatePortalRoot() {
52643
- let root = document.getElementById("ui-slot-portal-root");
52644
- if (!root) {
52645
- root = document.createElement("div");
52646
- root.id = "ui-slot-portal-root";
52647
- root.style.position = "relative";
52648
- root.style.zIndex = "9999";
52649
- document.body.appendChild(root);
52650
- }
52651
- const themed = document.querySelector('[data-theme*="-"]') ?? document.querySelector("[data-theme]");
52652
- if (themed) {
52653
- const theme = themed.getAttribute("data-theme");
52654
- if (theme && root.getAttribute("data-theme") !== theme) {
52655
- root.setAttribute("data-theme", theme);
52656
- }
52657
- }
52658
- return root;
52659
- }
52660
52679
  function CompiledPortal({ slot, className, pattern, sourceTrait, children }) {
52661
52680
  const [portalRoot, setPortalRoot] = React89.useState(null);
52662
52681
  const slotsBus = context.useUISlots();
@@ -53279,6 +53298,7 @@ var init_UISlotRenderer = __esm({
53279
53298
  init_slot_types();
53280
53299
  init_cn();
53281
53300
  init_format();
53301
+ init_portalRoot();
53282
53302
  init_ErrorBoundary();
53283
53303
  init_Skeleton();
53284
53304
  init_renderer();
@@ -54627,8 +54647,28 @@ function createHttpTransport(serverUrl, getAccessToken) {
54627
54647
  } catch {
54628
54648
  }
54629
54649
  },
54630
- sendEvent: async (orbitalName, event, payload, clientId, tick, sourceTrait) => {
54631
- const body = { event, payload, clientId, tick, sourceTrait };
54650
+ sendEvent: async (orbitalName, event, payload, clientId, tick, sourceTrait, results, entityByTrait) => {
54651
+ const traits2 = results?.map((r) => ({ trait: r.traitName, from: r.result.previousState }));
54652
+ const body = {
54653
+ event,
54654
+ payload,
54655
+ clientId,
54656
+ tick,
54657
+ sourceTrait,
54658
+ // `results === undefined` (as opposed to an explicit, possibly-empty
54659
+ // array) distinguishes two genuinely different cases a stateless
54660
+ // server must tell apart: the mount-time INIT dispatch (OrbPreview's
54661
+ // "Server INIT when bridge connects" effect) calls this WITHOUT ever
54662
+ // running a local dispatch first — by design, the server is
54663
+ // authoritative for that one case — so there is no local `traits`
54664
+ // list to send at all; a command-class dispatch (via
54665
+ // `onEventProcessed`) always supplies `results`, even as `[]` when
54666
+ // local dispatch genuinely matched nothing. Collapsing both to "omit
54667
+ // `traits`" would make the mount-time case indistinguishable from
54668
+ // "do nothing" and break every organism's INIT on the stateless path.
54669
+ ...results !== void 0 ? { traits: traits2 ?? [] } : {},
54670
+ ...entityByTrait ? { entityByTrait } : {}
54671
+ };
54632
54672
  const res = await fetch(`${serverUrl}/${orbitalName}/events`, {
54633
54673
  method: "POST",
54634
54674
  headers: await authHeaders(getAccessToken),
@@ -54689,7 +54729,7 @@ function ServerBridgeProvider({
54689
54729
  disposedRef.current = true;
54690
54730
  };
54691
54731
  }, []);
54692
- const sendEvent = React89.useCallback(async (orbitalName, event, payload, tick, sourceTrait, locallyEmitted) => {
54732
+ const sendEvent = React89.useCallback(async (orbitalName, event, payload, tick, sourceTrait, locallyEmitted, results, entityByTrait) => {
54693
54733
  const emptyMeta = { success: false, transitioned: false, clientEffects: 0, dataEntities: {}, emittedEvents: [] };
54694
54734
  if (!connected) return { effects: [], meta: emptyMeta };
54695
54735
  if (tick !== void 0) {
@@ -54699,7 +54739,7 @@ function ServerBridgeProvider({
54699
54739
  return commandPump.enqueue(async () => {
54700
54740
  if (disposedRef.current) return { effects: [], meta: emptyMeta };
54701
54741
  try {
54702
- const result = await transport.sendEvent(orbitalName, event, payload, getTabClientId(), tick, sourceTrait);
54742
+ const result = await transport.sendEvent(orbitalName, event, payload, getTabClientId(), tick, sourceTrait, results, entityByTrait);
54703
54743
  const effects = [];
54704
54744
  const responseData = result.data || {};
54705
54745
  const dataEntities = {};
@@ -6,7 +6,7 @@ export { a as CurrentPagePathContext, b as CurrentPagePathProvider, c as Current
6
6
  import { b as UserData } from '../UserContext-D566nfWA.cjs';
7
7
  export { U as UserContext, a as UserContextValue, c as UserProvider, d as UserProviderProps, u as useHasPermission, e as useHasRole, f as useUser, g as useUserForEvaluation } from '../UserContext-D566nfWA.cjs';
8
8
  import { E as EventBusContextType } from '../event-bus-types-Bl78kokd.cjs';
9
- export { A as AccessTokenProvider, E as EntityBindingContext, a as EntityBindingSource, b as EntitySchemaContextValue, c as EntitySchemaProvider, d as EntitySchemaProviderProps, S as SendEventResult, e as ServerBridgeContextValue, f as ServerBridgeProvider, g as ServerBridgeProviderProps, h as ServerBridgeTransport, i as ServerClientEffect, j as ServerResponseMeta, T as TraitContext, k as TraitContextValue, l as TraitInstance, m as TraitProvider, n as TraitProviderProps, u as useEntityBindingSnapshot, o as useEntitySchema, p as useEntitySchemaOptional, q as useServerBridge, r as useTrait, s as useTraitContext } from '../EntityBindingContext-Dglbi9ks.cjs';
9
+ export { A as AccessTokenProvider, E as EntityBindingContext, a as EntityBindingSource, b as EntitySchemaContextValue, c as EntitySchemaProvider, d as EntitySchemaProviderProps, S as SendEventResult, e as ServerBridgeContextValue, f as ServerBridgeProvider, g as ServerBridgeProviderProps, h as ServerBridgeTransport, i as ServerClientEffect, j as ServerResponseMeta, T as TraitContext, k as TraitContextValue, l as TraitInstance, m as TraitProvider, n as TraitProviderProps, u as useEntityBindingSnapshot, o as useEntitySchema, p as useEntitySchemaOptional, q as useServerBridge, r as useTrait, s as useTraitContext } from '../EntityBindingContext-DoK8Xq71.cjs';
10
10
  import { i as UseOfflineExecutorResult, U as UseOfflineExecutorOptions } from '../offline-executor-DdV2o0Zu.cjs';
11
11
  export { N as NavigationContextValue, c as NavigationProvider, d as NavigationProviderProps, e as NavigationState, j as comparePathSpecificity, l as extractRouteParams, m as findPageByName, n as findPageByPath, o as getAllPages, p as getDefaultPage, q as matchPath, r as matchPathAmong, s as pathMatches, u as useActivePage, t as useInitPayload, v as useNavigateTo, w as useNavigation, x as useNavigationId, y as useNavigationState } from '../offline-executor-DdV2o0Zu.cjs';
12
12
  import '../verificationRegistry-DTrKDRoa.cjs';
@@ -6,7 +6,7 @@ export { a as CurrentPagePathContext, b as CurrentPagePathProvider, c as Current
6
6
  import { b as UserData } from '../UserContext-D566nfWA.js';
7
7
  export { U as UserContext, a as UserContextValue, c as UserProvider, d as UserProviderProps, u as useHasPermission, e as useHasRole, f as useUser, g as useUserForEvaluation } from '../UserContext-D566nfWA.js';
8
8
  import { E as EventBusContextType } from '../event-bus-types-Bl78kokd.js';
9
- export { A as AccessTokenProvider, E as EntityBindingContext, a as EntityBindingSource, b as EntitySchemaContextValue, c as EntitySchemaProvider, d as EntitySchemaProviderProps, S as SendEventResult, e as ServerBridgeContextValue, f as ServerBridgeProvider, g as ServerBridgeProviderProps, h as ServerBridgeTransport, i as ServerClientEffect, j as ServerResponseMeta, T as TraitContext, k as TraitContextValue, l as TraitInstance, m as TraitProvider, n as TraitProviderProps, u as useEntityBindingSnapshot, o as useEntitySchema, p as useEntitySchemaOptional, q as useServerBridge, r as useTrait, s as useTraitContext } from '../EntityBindingContext-Dglbi9ks.js';
9
+ export { A as AccessTokenProvider, E as EntityBindingContext, a as EntityBindingSource, b as EntitySchemaContextValue, c as EntitySchemaProvider, d as EntitySchemaProviderProps, S as SendEventResult, e as ServerBridgeContextValue, f as ServerBridgeProvider, g as ServerBridgeProviderProps, h as ServerBridgeTransport, i as ServerClientEffect, j as ServerResponseMeta, T as TraitContext, k as TraitContextValue, l as TraitInstance, m as TraitProvider, n as TraitProviderProps, u as useEntityBindingSnapshot, o as useEntitySchema, p as useEntitySchemaOptional, q as useServerBridge, r as useTrait, s as useTraitContext } from '../EntityBindingContext-DoK8Xq71.js';
10
10
  import { i as UseOfflineExecutorResult, U as UseOfflineExecutorOptions } from '../offline-executor-DdV2o0Zu.js';
11
11
  export { N as NavigationContextValue, c as NavigationProvider, d as NavigationProviderProps, e as NavigationState, j as comparePathSpecificity, l as extractRouteParams, m as findPageByName, n as findPageByPath, o as getAllPages, p as getDefaultPage, q as matchPath, r as matchPathAmong, s as pathMatches, u as useActivePage, t as useInitPayload, v as useNavigateTo, w as useNavigation, x as useNavigationId, y as useNavigationState } from '../offline-executor-DdV2o0Zu.js';
12
12
  import '../verificationRegistry-Cwa52VyK.js';
@@ -1503,6 +1503,36 @@ var init_Typography = __esm({
1503
1503
  Typography.displayName = "Typography";
1504
1504
  }
1505
1505
  });
1506
+
1507
+ // lib/portalRoot.ts
1508
+ function lastThemedElement(selector, portalRoot) {
1509
+ const matches = Array.from(document.querySelectorAll(selector)).filter(
1510
+ (el) => el !== document.documentElement && el !== portalRoot
1511
+ );
1512
+ return matches[matches.length - 1] ?? null;
1513
+ }
1514
+ function getOrCreatePortalRoot() {
1515
+ let root = document.getElementById("ui-slot-portal-root");
1516
+ if (!root) {
1517
+ root = document.createElement("div");
1518
+ root.id = "ui-slot-portal-root";
1519
+ root.style.position = "relative";
1520
+ root.style.zIndex = "9999";
1521
+ document.body.appendChild(root);
1522
+ }
1523
+ const themed = lastThemedElement('[data-theme*="-"]', root) ?? lastThemedElement("[data-theme]", root);
1524
+ if (themed) {
1525
+ const theme = themed.getAttribute("data-theme");
1526
+ if (theme && root.getAttribute("data-theme") !== theme) {
1527
+ root.setAttribute("data-theme", theme);
1528
+ }
1529
+ }
1530
+ return root;
1531
+ }
1532
+ var init_portalRoot = __esm({
1533
+ "lib/portalRoot.ts"() {
1534
+ }
1535
+ });
1506
1536
  function isMotionEnabled() {
1507
1537
  if (typeof document === "undefined") return true;
1508
1538
  if (motionEnabledCache !== null) return motionEnabledCache;
@@ -1583,6 +1613,7 @@ var init_Modal = __esm({
1583
1613
  init_Dialog();
1584
1614
  init_Typography();
1585
1615
  init_cn();
1616
+ init_portalRoot();
1586
1617
  init_useEventBus();
1587
1618
  init_Presence();
1588
1619
  sizeClasses2 = {
@@ -1793,7 +1824,7 @@ var init_Modal = __esm({
1793
1824
  )
1794
1825
  }
1795
1826
  ),
1796
- document.body
1827
+ getOrCreatePortalRoot()
1797
1828
  );
1798
1829
  };
1799
1830
  Modal.displayName = "Modal";
@@ -20429,6 +20460,7 @@ var init_StateMachineView = __esm({
20429
20460
  init_Icon();
20430
20461
  init_useEventBus();
20431
20462
  init_cn();
20463
+ init_portalRoot();
20432
20464
  StateNode2 = ({ state, config }) => {
20433
20465
  const { t } = useTranslate();
20434
20466
  const size = state.radius * 2;
@@ -20945,7 +20977,7 @@ var init_StateMachineView = __esm({
20945
20977
  )
20946
20978
  }
20947
20979
  ),
20948
- document.body
20980
+ getOrCreatePortalRoot()
20949
20981
  );
20950
20982
  };
20951
20983
  EntityBox = ({ entity, config }) => {
@@ -27586,7 +27618,7 @@ function SubMenu({
27586
27618
  })
27587
27619
  }
27588
27620
  );
27589
- return typeof document !== "undefined" ? createPortal(panel, document.body) : panel;
27621
+ return typeof document !== "undefined" ? createPortal(panel, getOrCreatePortalRoot()) : panel;
27590
27622
  }
27591
27623
  function MenuItemRow({
27592
27624
  item,
@@ -27673,6 +27705,7 @@ var init_Menu = __esm({
27673
27705
  init_Typography();
27674
27706
  init_Badge();
27675
27707
  init_cn();
27708
+ init_portalRoot();
27676
27709
  init_useEventBus();
27677
27710
  MENU_GAP = 4;
27678
27711
  menuContainerStyles = cn(
@@ -27809,7 +27842,7 @@ var init_Menu = __esm({
27809
27842
  ) : null;
27810
27843
  return /* @__PURE__ */ jsxs(Fragment, { children: [
27811
27844
  triggerElement,
27812
- panel && typeof document !== "undefined" ? createPortal(panel, document.body) : panel
27845
+ panel && typeof document !== "undefined" ? createPortal(panel, getOrCreatePortalRoot()) : panel
27813
27846
  ] });
27814
27847
  };
27815
27848
  Menu.displayName = "Menu";
@@ -31193,6 +31226,7 @@ var init_Popover = __esm({
31193
31226
  init_Typography();
31194
31227
  init_Presence();
31195
31228
  init_cn();
31229
+ init_portalRoot();
31196
31230
  init_useTapReveal();
31197
31231
  arrowClasses = {
31198
31232
  top: "top-full left-1/2 -translate-x-1/2 border-t-white border-l-transparent border-r-transparent border-b-transparent",
@@ -31352,7 +31386,7 @@ var init_Popover = __esm({
31352
31386
  ) : null;
31353
31387
  return /* @__PURE__ */ jsxs(Fragment, { children: [
31354
31388
  triggerElement,
31355
- panel && typeof document !== "undefined" ? createPortal(panel, document.body) : panel
31389
+ panel && typeof document !== "undefined" ? createPortal(panel, getOrCreatePortalRoot()) : panel
31356
31390
  ] });
31357
31391
  };
31358
31392
  Popover.displayName = "Popover";
@@ -31858,6 +31892,7 @@ var init_Tooltip = __esm({
31858
31892
  "use client";
31859
31893
  init_Typography();
31860
31894
  init_cn();
31895
+ init_portalRoot();
31861
31896
  init_useTapReveal();
31862
31897
  TRIGGER_GAP2 = 8;
31863
31898
  arrowClasses2 = {
@@ -31963,7 +31998,7 @@ var init_Tooltip = __esm({
31963
31998
  ) : null;
31964
31999
  return /* @__PURE__ */ jsxs(Fragment, { children: [
31965
32000
  trigger,
31966
- typeof window !== "undefined" && tooltipContent ? createPortal(tooltipContent, document.body) : tooltipContent
32001
+ typeof window !== "undefined" && tooltipContent ? createPortal(tooltipContent, getOrCreatePortalRoot()) : tooltipContent
31967
32002
  ] });
31968
32003
  };
31969
32004
  Tooltip.displayName = "Tooltip";
@@ -43383,6 +43418,7 @@ var init_GraphCanvas = __esm({
43383
43418
  "components/core/molecules/GraphCanvas.tsx"() {
43384
43419
  "use client";
43385
43420
  init_cn();
43421
+ init_portalRoot();
43386
43422
  init_atoms();
43387
43423
  init_Stack();
43388
43424
  init_LoadingState();
@@ -44094,7 +44130,7 @@ var init_GraphCanvas = __esm({
44094
44130
  children: hoveredObj?.label
44095
44131
  }
44096
44132
  ),
44097
- document.body
44133
+ getOrCreatePortalRoot()
44098
44134
  )
44099
44135
  ] }),
44100
44136
  groups.length > 1 && /* @__PURE__ */ jsx(HStack, { gap: "md", className: "px-4 py-2 border-t border-border", wrap: true, children: groups.map((group, idx) => /* @__PURE__ */ jsxs(HStack, { gap: "xs", align: "center", children: [
@@ -45255,6 +45291,7 @@ var init_DetailPanel = __esm({
45255
45291
  init_ErrorState();
45256
45292
  init_EmptyState();
45257
45293
  init_cn();
45294
+ init_portalRoot();
45258
45295
  init_format();
45259
45296
  init_getNestedValue();
45260
45297
  init_relationLabel();
@@ -45674,7 +45711,7 @@ var init_DetailPanel = __esm({
45674
45711
  return /* @__PURE__ */ jsx(Box, { className, children: content });
45675
45712
  }
45676
45713
  const panel = /* @__PURE__ */ jsx(Box, { className: cn("fixed inset-y-0 right-0 w-full max-w-2xl bg-card shadow-lg z-50 overflow-y-auto p-6", className), children: content });
45677
- return typeof document === "undefined" ? panel : createPortal(panel, document.body);
45714
+ return typeof document === "undefined" ? panel : createPortal(panel, getOrCreatePortalRoot());
45678
45715
  };
45679
45716
  DetailPanel.displayName = "DetailPanel";
45680
45717
  }
@@ -52565,24 +52602,6 @@ function UISlotComponentInner({
52565
52602
  }
52566
52603
  );
52567
52604
  }
52568
- function getOrCreatePortalRoot() {
52569
- let root = document.getElementById("ui-slot-portal-root");
52570
- if (!root) {
52571
- root = document.createElement("div");
52572
- root.id = "ui-slot-portal-root";
52573
- root.style.position = "relative";
52574
- root.style.zIndex = "9999";
52575
- document.body.appendChild(root);
52576
- }
52577
- const themed = document.querySelector('[data-theme*="-"]') ?? document.querySelector("[data-theme]");
52578
- if (themed) {
52579
- const theme = themed.getAttribute("data-theme");
52580
- if (theme && root.getAttribute("data-theme") !== theme) {
52581
- root.setAttribute("data-theme", theme);
52582
- }
52583
- }
52584
- return root;
52585
- }
52586
52605
  function CompiledPortal({ slot, className, pattern, sourceTrait, children }) {
52587
52606
  const [portalRoot, setPortalRoot] = useState(null);
52588
52607
  const slotsBus = useUISlots();
@@ -53205,6 +53224,7 @@ var init_UISlotRenderer = __esm({
53205
53224
  init_slot_types();
53206
53225
  init_cn();
53207
53226
  init_format();
53227
+ init_portalRoot();
53208
53228
  init_ErrorBoundary();
53209
53229
  init_Skeleton();
53210
53230
  init_renderer();
@@ -54553,8 +54573,28 @@ function createHttpTransport(serverUrl, getAccessToken) {
54553
54573
  } catch {
54554
54574
  }
54555
54575
  },
54556
- sendEvent: async (orbitalName, event, payload, clientId, tick, sourceTrait) => {
54557
- const body = { event, payload, clientId, tick, sourceTrait };
54576
+ sendEvent: async (orbitalName, event, payload, clientId, tick, sourceTrait, results, entityByTrait) => {
54577
+ const traits2 = results?.map((r) => ({ trait: r.traitName, from: r.result.previousState }));
54578
+ const body = {
54579
+ event,
54580
+ payload,
54581
+ clientId,
54582
+ tick,
54583
+ sourceTrait,
54584
+ // `results === undefined` (as opposed to an explicit, possibly-empty
54585
+ // array) distinguishes two genuinely different cases a stateless
54586
+ // server must tell apart: the mount-time INIT dispatch (OrbPreview's
54587
+ // "Server INIT when bridge connects" effect) calls this WITHOUT ever
54588
+ // running a local dispatch first — by design, the server is
54589
+ // authoritative for that one case — so there is no local `traits`
54590
+ // list to send at all; a command-class dispatch (via
54591
+ // `onEventProcessed`) always supplies `results`, even as `[]` when
54592
+ // local dispatch genuinely matched nothing. Collapsing both to "omit
54593
+ // `traits`" would make the mount-time case indistinguishable from
54594
+ // "do nothing" and break every organism's INIT on the stateless path.
54595
+ ...results !== void 0 ? { traits: traits2 ?? [] } : {},
54596
+ ...entityByTrait ? { entityByTrait } : {}
54597
+ };
54558
54598
  const res = await fetch(`${serverUrl}/${orbitalName}/events`, {
54559
54599
  method: "POST",
54560
54600
  headers: await authHeaders(getAccessToken),
@@ -54615,7 +54655,7 @@ function ServerBridgeProvider({
54615
54655
  disposedRef.current = true;
54616
54656
  };
54617
54657
  }, []);
54618
- const sendEvent = useCallback(async (orbitalName, event, payload, tick, sourceTrait, locallyEmitted) => {
54658
+ const sendEvent = useCallback(async (orbitalName, event, payload, tick, sourceTrait, locallyEmitted, results, entityByTrait) => {
54619
54659
  const emptyMeta = { success: false, transitioned: false, clientEffects: 0, dataEntities: {}, emittedEvents: [] };
54620
54660
  if (!connected) return { effects: [], meta: emptyMeta };
54621
54661
  if (tick !== void 0) {
@@ -54625,7 +54665,7 @@ function ServerBridgeProvider({
54625
54665
  return commandPump.enqueue(async () => {
54626
54666
  if (disposedRef.current) return { effects: [], meta: emptyMeta };
54627
54667
  try {
54628
- const result = await transport.sendEvent(orbitalName, event, payload, getTabClientId(), tick, sourceTrait);
54668
+ const result = await transport.sendEvent(orbitalName, event, payload, getTabClientId(), tick, sourceTrait, results, entityByTrait);
54629
54669
  const effects = [];
54630
54670
  const responseData = result.data || {};
54631
54671
  const dataEntities = {};