@floegence/floe-webapp-core 0.36.60 → 0.36.62

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.
@@ -76,7 +76,15 @@ export interface WorkbenchRenderLayerMap {
76
76
  byWidgetId: ReadonlyMap<string, number>;
77
77
  topRenderLayer: number;
78
78
  }
79
- export declare function createWorkbenchRenderLayerMap(widgets: readonly Pick<WorkbenchWidgetItem, 'id' | 'z_index' | 'created_at_unix_ms'>[]): WorkbenchRenderLayerMap;
79
+ export type WorkbenchLayerOrderItem = Pick<WorkbenchWidgetItem, 'id' | 'z_index' | 'created_at_unix_ms'>;
80
+ export interface WorkbenchLayerFrontResolution {
81
+ isTop: boolean;
82
+ nextZIndex: number;
83
+ }
84
+ export declare function compareWorkbenchLayerRenderOrder(left: WorkbenchLayerOrderItem, right: WorkbenchLayerOrderItem): number;
85
+ export declare function createWorkbenchRenderLayerMap(widgets: readonly WorkbenchLayerOrderItem[]): WorkbenchRenderLayerMap;
86
+ export declare function isWorkbenchLayerItemAbove(left: WorkbenchLayerOrderItem, right: WorkbenchLayerOrderItem): boolean;
87
+ export declare function resolveWorkbenchLayerFront(items: readonly WorkbenchLayerOrderItem[], targetId: string): WorkbenchLayerFrontResolution | null;
80
88
  export declare function createContextMenuPosition(options: {
81
89
  clientX: number;
82
90
  clientY: number;
@@ -86,7 +94,6 @@ export declare function createContextMenuPosition(options: {
86
94
  left: number;
87
95
  top: number;
88
96
  };
89
- export declare function getTopZIndex(widgets: readonly WorkbenchWidgetItem[]): number;
90
97
  /** Spatial navigation: find nearest widget in a direction. */
91
98
  export declare function findNearestWidget(widgets: readonly WorkbenchWidgetItem[], currentId: string | null, direction: 'up' | 'down' | 'left' | 'right', filters: Record<string, boolean>): WorkbenchWidgetItem | null;
92
99
  export declare function clampScale(scale: number, min?: number, max?: number): number;
@@ -1,75 +1,75 @@
1
- import { DEFAULT_WORKBENCH_VIEWPORT as O, WORKBENCH_BACKGROUND_REGION_FILTER_ID as D, WORKBENCH_LAYER_COMPONENT_FILTER_IDS as K } from "./types.js";
2
- import { WORKBENCH_DEFAULT_BACKGROUND_MATERIAL as E, WORKBENCH_DEFAULT_REGION_FILL as S, WORKBENCH_DEFAULT_TEXT_COLOR as R, WORKBENCH_DEFAULT_TEXT_FONT as N, WORKBENCH_DEFAULT_STICKY_NOTE_COLOR as z, resolveWorkbenchTextFontOption as P, WORKBENCH_BACKGROUND_MATERIALS as U, WORKBENCH_STICKY_NOTE_COLORS as X, WORKBENCH_TEXT_COLOR_OPTIONS as Y, WORKBENCH_REGION_FILL_OPTIONS as j } from "./workbenchOptions.js";
3
- import { resolveWorkbenchWidgetDefinitions as T, getWidgetEntry as C, createWorkbenchFilterState as A, isValidWorkbenchWidgetType as V } from "./widgets/widgetRegistry.js";
4
- import { DEFAULT_WORKBENCH_THEME as H, isWorkbenchThemeId as G } from "./workbenchThemes.js";
5
- function $() {
1
+ import { DEFAULT_WORKBENCH_VIEWPORT as O, WORKBENCH_BACKGROUND_REGION_FILTER_ID as K, WORKBENCH_LAYER_COMPONENT_FILTER_IDS as P } from "./types.js";
2
+ import { WORKBENCH_DEFAULT_BACKGROUND_MATERIAL as E, WORKBENCH_DEFAULT_REGION_FILL as S, WORKBENCH_DEFAULT_TEXT_COLOR as R, WORKBENCH_DEFAULT_TEXT_FONT as N, WORKBENCH_DEFAULT_STICKY_NOTE_COLOR as z, resolveWorkbenchTextFontOption as U, WORKBENCH_BACKGROUND_MATERIALS as X, WORKBENCH_STICKY_NOTE_COLORS as Y, WORKBENCH_TEXT_COLOR_OPTIONS as j, WORKBENCH_REGION_FILL_OPTIONS as V } from "./workbenchOptions.js";
3
+ import { resolveWorkbenchWidgetDefinitions as T, getWidgetEntry as C, createWorkbenchFilterState as I, isValidWorkbenchWidgetType as G } from "./widgets/widgetRegistry.js";
4
+ import { DEFAULT_WORKBENCH_THEME as A, isWorkbenchThemeId as $ } from "./workbenchThemes.js";
5
+ function Z() {
6
6
  const e = globalThis.crypto;
7
7
  return e && typeof e.randomUUID == "function" ? `wb-${e.randomUUID()}` : `wb-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
8
8
  }
9
- function We(e) {
9
+ function ke(e) {
10
10
  return e.renderMode ?? "canvas_scaled";
11
11
  }
12
- function ke(e) {
12
+ function Me(e) {
13
13
  return e.projectedSurfaceScaleBehavior ?? "stable_transform";
14
14
  }
15
15
  function q(e) {
16
- const t = Number.isFinite(e.viewport.scale) && e.viewport.scale > 0 ? e.viewport.scale : 1, n = typeof window < "u" && Number.isFinite(window.devicePixelRatio) && window.devicePixelRatio > 0 ? window.devicePixelRatio : 1, o = Math.round((e.viewport.x + e.worldX * t) * n) / n, i = Math.round((e.viewport.y + e.worldY * t) * n) / n;
16
+ const t = Number.isFinite(e.viewport.scale) && e.viewport.scale > 0 ? e.viewport.scale : 1, n = typeof window < "u" && Number.isFinite(window.devicePixelRatio) && window.devicePixelRatio > 0 ? window.devicePixelRatio : 1, r = Math.round((e.viewport.x + e.worldX * t) * n) / n, i = Math.round((e.viewport.y + e.worldY * t) * n) / n;
17
17
  return {
18
18
  widgetId: e.widgetId,
19
19
  worldX: e.worldX,
20
20
  worldY: e.worldY,
21
21
  worldWidth: e.worldWidth,
22
22
  worldHeight: e.worldHeight,
23
- screenX: o,
23
+ screenX: r,
24
24
  screenY: i,
25
25
  screenWidth: e.worldWidth * t,
26
26
  screenHeight: e.worldHeight * t,
27
27
  viewportScale: t
28
28
  };
29
29
  }
30
- function Me(e) {
30
+ function Ne(e) {
31
31
  return {
32
32
  ready: e.ready,
33
33
  rect: q(e)
34
34
  };
35
35
  }
36
- function Ne(e, t) {
37
- const { width: n, height: o } = e.defaultSize;
36
+ function Oe(e, t) {
37
+ const { width: n, height: r } = e.defaultSize;
38
38
  switch (t.anchor) {
39
39
  case "center":
40
40
  return {
41
41
  x: t.worldX - n / 2,
42
- y: t.worldY - o / 2,
42
+ y: t.worldY - r / 2,
43
43
  width: n,
44
- height: o
44
+ height: r
45
45
  };
46
46
  case "top_left":
47
47
  return {
48
48
  x: t.worldX,
49
49
  y: t.worldY,
50
50
  width: n,
51
- height: o
51
+ height: r
52
52
  };
53
53
  }
54
54
  }
55
- function Z(e) {
55
+ function J(e) {
56
56
  return e ? {
57
57
  x: Number.isFinite(e.x) ? e.x : 0,
58
58
  y: Number.isFinite(e.y) ? e.y : 0,
59
59
  scale: Number.isFinite(e.scale) && e.scale > 0 ? e.scale : 1
60
60
  } : { ...O };
61
61
  }
62
- function J(e, t) {
63
- const n = Z(e);
62
+ function Q(e, t) {
63
+ const n = J(e);
64
64
  return {
65
65
  ...n,
66
- scale: b(n.scale, fe(t).minScale, g)
66
+ scale: b(n.scale, me(t).minScale, g)
67
67
  };
68
68
  }
69
- function Q(e, t) {
70
- const n = A(t, e);
71
- for (const o of K)
72
- n[o] = typeof e?.[o] == "boolean" ? !!e[o] : !0;
69
+ function v(e, t) {
70
+ const n = I(t, e);
71
+ for (const r of P)
72
+ n[r] = typeof e?.[r] == "boolean" ? !!e[r] : !0;
73
73
  return n;
74
74
  }
75
75
  function y(e) {
@@ -88,30 +88,30 @@ function m(e, t) {
88
88
  }
89
89
  function W(e, t) {
90
90
  const n = f(e);
91
- return n.length > 0 && n.length <= 128 ? n : `${t}-${$()}`;
91
+ return n.length > 0 && n.length <= 128 ? n : `${t}-${Z()}`;
92
92
  }
93
- function v(e) {
93
+ function ee(e) {
94
94
  return F(e);
95
95
  }
96
- function ee(e, t) {
96
+ function te(e, t) {
97
97
  const n = f(e);
98
- return n || (t === "annotation" || t === "background" ? D : "select");
98
+ return n || (t === "annotation" || t === "background" ? K : "select");
99
99
  }
100
100
  function w(e, t, n) {
101
- const o = f(e);
102
- return t.includes(o) ? o : n;
103
- }
104
- function te(e) {
105
- return w(e, X, z);
101
+ const r = f(e);
102
+ return t.includes(r) ? r : n;
106
103
  }
107
104
  function ne(e) {
105
+ return w(e, Y, z);
106
+ }
107
+ function ie(e) {
108
108
  if (!y(e)) return null;
109
109
  const t = Date.now();
110
110
  return {
111
111
  id: W(e.id, "sticky"),
112
112
  kind: "sticky_note",
113
113
  body: f(e.body) || "Untitled note",
114
- color: te(e.color),
114
+ color: ne(e.color),
115
115
  x: d(e.x, 0),
116
116
  y: d(e.y, 0),
117
117
  width: m(e.width, 260),
@@ -121,18 +121,18 @@ function ne(e) {
121
121
  updated_at_unix_ms: Math.max(0, Math.trunc(d(e.updated_at_unix_ms, t)))
122
122
  };
123
123
  }
124
- function ie(e) {
124
+ function re(e) {
125
125
  if (!Array.isArray(e)) return [];
126
126
  const t = /* @__PURE__ */ new Set();
127
- return e.map((n) => ne(n)).filter((n) => !n || t.has(n.id) ? !1 : (t.add(n.id), !0));
128
- }
129
- const re = ["left", "center", "right"];
130
- function oe(e) {
131
- return re.includes(e) ? e : "left";
127
+ return e.map((n) => ie(n)).filter((n) => !n || t.has(n.id) ? !1 : (t.add(n.id), !0));
132
128
  }
129
+ const oe = ["left", "center", "right"];
133
130
  function ae(e) {
131
+ return oe.includes(e) ? e : "left";
132
+ }
133
+ function ce(e) {
134
134
  if (!y(e)) return null;
135
- const t = Date.now(), n = P(e.font_family);
135
+ const t = Date.now(), n = U(e.font_family);
136
136
  return {
137
137
  id: W(e.id, "text"),
138
138
  kind: "text",
@@ -140,8 +140,8 @@ function ae(e) {
140
140
  font_family: n.fontFamily,
141
141
  font_size: Math.max(8, Math.min(160, Math.round(d(e.font_size, 28)))),
142
142
  font_weight: n.fontWeight,
143
- color: w(e.color, Y, R),
144
- align: oe(e.align),
143
+ color: w(e.color, j, R),
144
+ align: ae(e.align),
145
145
  x: d(e.x, 0),
146
146
  y: d(e.y, 0),
147
147
  width: m(e.width, 280),
@@ -151,27 +151,27 @@ function ae(e) {
151
151
  updated_at_unix_ms: Math.max(0, Math.trunc(d(e.updated_at_unix_ms, t)))
152
152
  };
153
153
  }
154
- function ce(e) {
154
+ function de(e) {
155
155
  if (!Array.isArray(e)) return [];
156
156
  const t = /* @__PURE__ */ new Set();
157
- return e.map((n) => ae(n)).filter((n) => !n || t.has(n.id) ? !1 : (t.add(n.id), !0));
157
+ return e.map((n) => ce(n)).filter((n) => !n || t.has(n.id) ? !1 : (t.add(n.id), !0));
158
158
  }
159
- function de(e) {
159
+ function se(e) {
160
160
  return w(
161
161
  e,
162
- U,
162
+ X,
163
163
  E
164
164
  );
165
165
  }
166
- function se(e) {
166
+ function he(e) {
167
167
  if (!y(e)) return null;
168
168
  const t = Date.now();
169
169
  return {
170
170
  id: W(e.id, "region"),
171
171
  name: f(e.name) || "Canvas region",
172
- fill: w(e.fill, j, S),
172
+ fill: w(e.fill, V, S),
173
173
  opacity: Math.max(0.08, Math.min(1, d(e.opacity, 0.72))),
174
- material: de(e.material),
174
+ material: se(e.material),
175
175
  x: d(e.x, 0),
176
176
  y: d(e.y, 0),
177
177
  width: m(e.width, 560),
@@ -181,73 +181,73 @@ function se(e) {
181
181
  updated_at_unix_ms: Math.max(0, Math.trunc(d(e.updated_at_unix_ms, t)))
182
182
  };
183
183
  }
184
- function he(e) {
184
+ function ue(e) {
185
185
  if (!Array.isArray(e)) return [];
186
186
  const t = /* @__PURE__ */ new Set();
187
- return e.map((n) => se(n)).filter((n) => !n || t.has(n.id) ? !1 : (t.add(n.id), !0));
187
+ return e.map((n) => he(n)).filter((n) => !n || t.has(n.id) ? !1 : (t.add(n.id), !0));
188
188
  }
189
- function le(e, t, n, o, i, a) {
189
+ function le(e, t, n, r, i, a) {
190
190
  if (y(e)) {
191
191
  const c = f(e.kind), s = f(e.id);
192
- if (c === "widget" && t.some((l) => l.id === s)) return { kind: c, id: s };
193
- if (c === "sticky_note" && n.some((l) => l.id === s)) return { kind: c, id: s };
194
- if (c === "annotation" && o.some((l) => l.id === s)) return { kind: c, id: s };
195
- if (c === "background_layer" && i.some((l) => l.id === s))
192
+ if (c === "widget" && t.some((u) => u.id === s)) return { kind: c, id: s };
193
+ if (c === "sticky_note" && n.some((u) => u.id === s)) return { kind: c, id: s };
194
+ if (c === "annotation" && r.some((u) => u.id === s)) return { kind: c, id: s };
195
+ if (c === "background_layer" && i.some((u) => u.id === s))
196
196
  return { kind: c, id: s };
197
197
  }
198
198
  return a ? { kind: "widget", id: a } : null;
199
199
  }
200
- function Oe(e, t = {}) {
201
- const n = T(t.widgetDefinitions), o = t.createFallbackState ?? (() => ue(n)), i = e;
200
+ function Ee(e, t = {}) {
201
+ const n = T(t.widgetDefinitions), r = t.createFallbackState ?? (() => _e(n)), i = e;
202
202
  if (!i || i.version !== 1 || !Array.isArray(i.widgets))
203
- return o();
203
+ return r();
204
204
  const a = i.widgets.filter(
205
- (r) => !!r && typeof r.id == "string" && V(r.type, n) && typeof r.title == "string"
206
- ).map((r) => {
207
- const _ = C(r.type, n);
205
+ (o) => !!o && typeof o.id == "string" && G(o.type, n) && typeof o.title == "string"
206
+ ).map((o) => {
207
+ const _ = C(o.type, n);
208
208
  return {
209
- id: r.id,
210
- type: r.type,
211
- title: r.title,
212
- x: Number.isFinite(r.x) ? r.x : 0,
213
- y: Number.isFinite(r.y) ? r.y : 0,
214
- width: Number.isFinite(r.width) && r.width > 0 ? r.width : _.defaultSize.width,
215
- height: Number.isFinite(r.height) && r.height > 0 ? r.height : _.defaultSize.height,
216
- z_index: Number.isFinite(r.z_index) && r.z_index >= 0 ? r.z_index : 1,
217
- created_at_unix_ms: Number.isFinite(r.created_at_unix_ms) ? r.created_at_unix_ms : Date.now()
209
+ id: o.id,
210
+ type: o.type,
211
+ title: o.title,
212
+ x: Number.isFinite(o.x) ? o.x : 0,
213
+ y: Number.isFinite(o.y) ? o.y : 0,
214
+ width: Number.isFinite(o.width) && o.width > 0 ? o.width : _.defaultSize.width,
215
+ height: Number.isFinite(o.height) && o.height > 0 ? o.height : _.defaultSize.height,
216
+ z_index: Number.isFinite(o.z_index) && o.z_index >= 0 ? o.z_index : 1,
217
+ created_at_unix_ms: Number.isFinite(o.created_at_unix_ms) ? o.created_at_unix_ms : Date.now()
218
218
  };
219
- }), c = typeof i.selectedWidgetId == "string" && a.some((r) => r.id === i.selectedWidgetId) ? i.selectedWidgetId : null, s = ie(i.stickyNotes), l = ce(i.annotations), x = he(i.backgroundLayers), h = v(i.mode), u = J(i.viewport, h);
219
+ }), c = typeof i.selectedWidgetId == "string" && a.some((o) => o.id === i.selectedWidgetId) ? i.selectedWidgetId : null, s = re(i.stickyNotes), u = de(i.annotations), x = ue(i.backgroundLayers), h = ee(i.mode), l = Q(i.viewport, h);
220
220
  return {
221
221
  version: 1,
222
222
  widgets: a,
223
- viewport: u,
223
+ viewport: l,
224
224
  locked: typeof i.locked == "boolean" ? i.locked : !1,
225
- filters: Q(i.filters, n),
225
+ filters: v(i.filters, n),
226
226
  selectedWidgetId: c,
227
- theme: G(i.theme) ? i.theme : H,
227
+ theme: $(i.theme) ? i.theme : A,
228
228
  mode: h,
229
- activeTool: ee(i.activeTool, h),
229
+ activeTool: te(i.activeTool, h),
230
230
  selectedObject: le(
231
231
  i.selectedObject,
232
232
  a,
233
233
  s,
234
- l,
234
+ u,
235
235
  x,
236
236
  c
237
237
  ),
238
238
  stickyNotes: s,
239
- annotations: l,
239
+ annotations: u,
240
240
  backgroundLayers: x
241
241
  };
242
242
  }
243
- function ue(e) {
244
- const t = T(e), n = Date.now(), o = [
243
+ function _e(e) {
244
+ const t = T(e), n = Date.now(), r = [
245
245
  { type: "terminal", title: "dev · terminal", x: 80, y: 80 },
246
246
  { type: "file-browser", title: "project · files", x: 600, y: 80 },
247
247
  { type: "system-monitor", title: "host · system monitor", x: 80, y: 420 },
248
248
  { type: "log-viewer", title: "services · logs", x: 540, y: 500 },
249
249
  { type: "code-editor", title: "Counter.tsx", x: 1e3, y: 180 }
250
- ], i = o.filter((a) => t.some((c) => c.type === a.type)).map((a, c) => {
250
+ ], i = r.filter((a) => t.some((c) => c.type === a.type)).map((a, c) => {
251
251
  const s = C(a.type, t);
252
252
  return {
253
253
  id: `wb-seed-${c + 1}`,
@@ -258,7 +258,7 @@ function ue(e) {
258
258
  width: s.defaultSize.width,
259
259
  height: s.defaultSize.height,
260
260
  z_index: c + 1,
261
- created_at_unix_ms: n - (o.length - c) * 6e5
261
+ created_at_unix_ms: n - (r.length - c) * 6e5
262
262
  };
263
263
  });
264
264
  return {
@@ -266,9 +266,9 @@ function ue(e) {
266
266
  widgets: i,
267
267
  viewport: { ...O },
268
268
  locked: !1,
269
- filters: A(t),
269
+ filters: I(t),
270
270
  selectedWidgetId: i[0]?.id ?? null,
271
- theme: H,
271
+ theme: A,
272
272
  mode: "work",
273
273
  activeTool: "select",
274
274
  selectedObject: i[0] ? { kind: "widget", id: i[0].id } : null,
@@ -324,11 +324,11 @@ function ue(e) {
324
324
  ]
325
325
  };
326
326
  }
327
- const Ee = 1.18, Se = 200, I = 0.35, L = 0.2, k = I, g = 2.2, _e = 48;
327
+ const Se = 1.18, Re = 200, H = 0.35, L = 0.2, k = H, g = 2.2, fe = 48;
328
328
  function F(e) {
329
329
  return e === "annotation" || e === "background" ? "background" : "work";
330
330
  }
331
- function fe(e) {
331
+ function me(e) {
332
332
  return F(e) === "background" ? {
333
333
  mode: "background",
334
334
  label: "Composition Mode",
@@ -338,12 +338,12 @@ function fe(e) {
338
338
  } : {
339
339
  mode: "work",
340
340
  label: "Work Mode",
341
- minScale: I,
341
+ minScale: H,
342
342
  workLayerLocked: !1,
343
343
  layerEditingEnabled: !1
344
344
  };
345
345
  }
346
- function Re(e) {
346
+ function ze(e) {
347
347
  const t = b(
348
348
  e.scale,
349
349
  e.minScale ?? L,
@@ -351,14 +351,14 @@ function Re(e) {
351
351
  );
352
352
  if (e.frameWidth <= 0 || e.frameHeight <= 0 || e.viewport.scale <= 0)
353
353
  return { ...e.viewport, scale: t };
354
- const n = (e.frameWidth / 2 - e.viewport.x) / e.viewport.scale, o = (e.frameHeight / 2 - e.viewport.y) / e.viewport.scale;
354
+ const n = (e.frameWidth / 2 - e.viewport.x) / e.viewport.scale, r = (e.frameHeight / 2 - e.viewport.y) / e.viewport.scale;
355
355
  return {
356
356
  x: e.frameWidth / 2 - n * t,
357
- y: e.frameHeight / 2 - o * t,
357
+ y: e.frameHeight / 2 - r * t,
358
358
  scale: t
359
359
  };
360
360
  }
361
- function me(e) {
361
+ function xe(e) {
362
362
  const t = b(e.scale, k, g);
363
363
  return {
364
364
  x: e.frameWidth / 2 - (e.widget.x + e.widget.width / 2) * t,
@@ -366,8 +366,8 @@ function me(e) {
366
366
  scale: t
367
367
  };
368
368
  }
369
- function ze(e) {
370
- const t = e.minScale ?? k, n = e.maxScale ?? g, o = e.paddingPx ?? _e, i = Math.max(e.frameWidth - o * 2, 1), a = Math.max(e.frameHeight - o * 2, 1), c = b(
369
+ function Te(e) {
370
+ const t = e.minScale ?? k, n = e.maxScale ?? g, r = e.paddingPx ?? fe, i = Math.max(e.frameWidth - r * 2, 1), a = Math.max(e.frameHeight - r * 2, 1), c = b(
371
371
  Math.min(
372
372
  i / Math.max(e.widget.width, 1),
373
373
  a / Math.max(e.widget.height, 1)
@@ -375,98 +375,116 @@ function ze(e) {
375
375
  t,
376
376
  n
377
377
  );
378
- return me({
378
+ return xe({
379
379
  widget: e.widget,
380
380
  scale: c,
381
381
  frameWidth: e.frameWidth,
382
382
  frameHeight: e.frameHeight
383
383
  });
384
384
  }
385
- function xe(e, t) {
385
+ function p(e, t) {
386
386
  return e.z_index !== t.z_index ? e.z_index - t.z_index : e.created_at_unix_ms !== t.created_at_unix_ms ? e.created_at_unix_ms - t.created_at_unix_ms : e.id.localeCompare(t.id);
387
387
  }
388
- function Te(e) {
389
- const t = [...e].sort(xe), n = /* @__PURE__ */ new Map();
390
- for (const [o, i] of t.entries())
391
- n.set(i.id, o + 1);
388
+ function Ce(e) {
389
+ const t = [...e].sort(p), n = /* @__PURE__ */ new Map();
390
+ for (const [r, i] of t.entries())
391
+ n.set(i.id, r + 1);
392
392
  return {
393
393
  byWidgetId: n,
394
394
  topRenderLayer: Math.max(t.length, 1)
395
395
  };
396
396
  }
397
- function Ce(e) {
397
+ function ge(e, t) {
398
+ return p(e, t) > 0;
399
+ }
400
+ function Ie(e, t) {
401
+ const n = e.find((a) => a.id === t);
402
+ if (!n)
403
+ return null;
404
+ const r = e.reduce((a, c) => Math.max(a, c.z_index), 1);
405
+ return {
406
+ isTop: !e.some(
407
+ (a) => a.id !== t && ge(a, n)
408
+ ),
409
+ nextZIndex: r + 1
410
+ };
411
+ }
412
+ function Ae(e) {
398
413
  const t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800;
399
- let o = e.clientX, i = e.clientY;
400
- return o + e.menuWidth > t && (o = Math.max(0, t - e.menuWidth - 8)), i + e.menuHeight > n && (i = Math.max(0, n - e.menuHeight - 8)), { left: o, top: i };
414
+ let r = e.clientX, i = e.clientY;
415
+ return r + e.menuWidth > t && (r = Math.max(0, t - e.menuWidth - 8)), i + e.menuHeight > n && (i = Math.max(0, n - e.menuHeight - 8)), { left: r, top: i };
401
416
  }
402
- function Ae(e, t, n, o) {
403
- const i = e.filter((h) => o[h.type]);
417
+ function He(e, t, n, r) {
418
+ const i = e.filter((h) => r[h.type]);
404
419
  if (i.length === 0) return null;
405
420
  if (!t) return i[0] ?? null;
406
421
  const a = i.find((h) => h.id === t);
407
422
  if (!a) return i[0] ?? null;
408
423
  const c = a.x + a.width / 2, s = a.y + a.height / 2;
409
- let l = null, x = 1 / 0;
424
+ let u = null, x = 1 / 0;
410
425
  for (const h of i) {
411
426
  if (h.id === t) continue;
412
- const u = h.x + h.width / 2 - c, r = h.y + h.height / 2 - s;
427
+ const l = h.x + h.width / 2 - c, o = h.y + h.height / 2 - s;
413
428
  let _ = !1;
414
429
  switch (n) {
415
430
  case "up":
416
- _ = r < -10;
431
+ _ = o < -10;
417
432
  break;
418
433
  case "down":
419
- _ = r > 10;
434
+ _ = o > 10;
420
435
  break;
421
436
  case "left":
422
- _ = u < -10;
437
+ _ = l < -10;
423
438
  break;
424
439
  case "right":
425
- _ = u > 10;
440
+ _ = l > 10;
426
441
  break;
427
442
  }
428
443
  if (!_) continue;
429
- const p = Math.sqrt(u * u + r * r), B = Math.atan2(
430
- Math.abs(n === "up" || n === "down" ? u : r),
431
- Math.abs(n === "up" || n === "down" ? r : u)
432
- ), M = p * (1 + B * 1.5);
433
- M < x && (x = M, l = h);
444
+ const B = Math.sqrt(l * l + o * o), D = Math.atan2(
445
+ Math.abs(n === "up" || n === "down" ? l : o),
446
+ Math.abs(n === "up" || n === "down" ? o : l)
447
+ ), M = B * (1 + D * 1.5);
448
+ M < x && (x = M, u = h);
434
449
  }
435
- return l;
450
+ return u;
436
451
  }
437
452
  function b(e, t = k, n = g) {
438
453
  return Math.max(t, Math.min(n, e));
439
454
  }
440
- function He(e, t = 0) {
455
+ function Le(e, t = 0) {
441
456
  return 16 + Math.max(1, e) * 32 + Math.max(0, t) * 9;
442
457
  }
443
458
  export {
444
- Ee as WORKBENCH_CANVAS_ZOOM_STEP,
459
+ Se as WORKBENCH_CANVAS_ZOOM_STEP,
445
460
  L as WORKBENCH_COMPOSITION_MIN_SCALE,
446
- Se as WORKBENCH_CONTEXT_MENU_WIDTH_PX,
461
+ Re as WORKBENCH_CONTEXT_MENU_WIDTH_PX,
447
462
  g as WORKBENCH_MAX_SCALE,
448
463
  k as WORKBENCH_MIN_SCALE,
449
- _e as WORKBENCH_VIEWPORT_FIT_PADDING_PX,
450
- I as WORKBENCH_WORK_MIN_SCALE,
464
+ fe as WORKBENCH_VIEWPORT_FIT_PADDING_PX,
465
+ H as WORKBENCH_WORK_MIN_SCALE,
451
466
  b as clampScale,
452
- Ce as createContextMenuPosition,
453
- ue as createDefaultWorkbenchState,
454
- $ as createWorkbenchId,
467
+ p as compareWorkbenchLayerRenderOrder,
468
+ Ae as createContextMenuPosition,
469
+ _e as createDefaultWorkbenchState,
470
+ Z as createWorkbenchId,
455
471
  q as createWorkbenchProjectedRect,
456
- Te as createWorkbenchRenderLayerMap,
457
- Re as createWorkbenchViewportAtScale,
458
- me as createWorkbenchViewportCenteredOnWidget,
459
- ze as createWorkbenchViewportFitForWidget,
460
- Ne as createWorkbenchWidgetFrame,
461
- Me as createWorkbenchWidgetSurfaceMetrics,
462
- He as estimateContextMenuHeight,
463
- Ae as findNearestWidget,
472
+ Ce as createWorkbenchRenderLayerMap,
473
+ ze as createWorkbenchViewportAtScale,
474
+ xe as createWorkbenchViewportCenteredOnWidget,
475
+ Te as createWorkbenchViewportFitForWidget,
476
+ Oe as createWorkbenchWidgetFrame,
477
+ Ne as createWorkbenchWidgetSurfaceMetrics,
478
+ Le as estimateContextMenuHeight,
479
+ He as findNearestWidget,
480
+ ge as isWorkbenchLayerItemAbove,
464
481
  F as normalizeWorkbenchInteractionMode,
465
- fe as resolveWorkbenchModeStrategy,
466
- ke as resolveWorkbenchProjectedSurfaceScaleBehavior,
467
- We as resolveWorkbenchWidgetRenderMode,
468
- Q as sanitizeFilters,
469
- Z as sanitizeViewport,
470
- Oe as sanitizeWorkbenchState,
471
- J as sanitizeWorkbenchViewportForMode
482
+ Ie as resolveWorkbenchLayerFront,
483
+ me as resolveWorkbenchModeStrategy,
484
+ Me as resolveWorkbenchProjectedSurfaceScaleBehavior,
485
+ ke as resolveWorkbenchWidgetRenderMode,
486
+ v as sanitizeFilters,
487
+ J as sanitizeViewport,
488
+ Ee as sanitizeWorkbenchState,
489
+ Q as sanitizeWorkbenchViewportForMode
472
490
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-core",
3
- "version": "0.36.60",
3
+ "version": "0.36.62",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",