@floegence/floe-webapp-core 0.36.48 → 0.36.49

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.
@@ -1,43 +1,44 @@
1
- import { createSignal as et, createMemo as u, onCleanup as We } from "solid-js";
2
- import { ArrowUp as xt, Copy as M, Trash as z, MessageSquare as bt, Region as St, TextTool as Oe } from "../icons/index.js";
3
- import { WORKBENCH_STICKY_FILTER_ID as Ce } from "./types.js";
4
- import { WORKBENCH_DEFAULT_STICKY_NOTE_COLOR as Te, WORKBENCH_DEFAULT_TEXT_COLOR as Ne, WORKBENCH_DEFAULT_TEXT_FONT as Wt, WORKBENCH_BACKGROUND_MATERIALS as Lt, WORKBENCH_REGION_FILL_OPTIONS as Ae, WORKBENCH_STICKY_NOTE_COLORS as Ie, WORKBENCH_DEFAULT_BACKGROUND_MATERIAL as Le, WORKBENCH_DEFAULT_REGION_FILL as De } from "./workbenchOptions.js";
5
- import { resolveWorkbenchModeStrategy as Ot, createContextMenuPosition as je, createWorkbenchId as S, createWorkbenchViewportCenteredOnWidget as Ct, findNearestWidget as Me, sanitizeFilters as ze, WORKBENCH_CONTEXT_MENU_WIDTH_PX as Fe, estimateContextMenuHeight as Re, clampScale as Be, WORKBENCH_MAX_SCALE as pe, WORKBENCH_CANVAS_ZOOM_STEP as Tt, normalizeWorkbenchInteractionMode as Ee, createWorkbenchViewportAtScale as Xe, WORKBENCH_WORK_MIN_SCALE as Ye, createWorkbenchViewportFitForWidget as He } from "./workbenchHelpers.js";
6
- import { resolveWorkbenchWidgetDefinitions as Ke, getWidgetEntry as Nt } from "./widgets/widgetRegistry.js";
7
- function Dt(o, c) {
8
- const s = o.findIndex((a) => a === c);
1
+ import { createSignal as et, createMemo as u, onCleanup as Oe } from "solid-js";
2
+ import { clientToCanvasWorld as Ce } from "../ui/canvasGeometry.js";
3
+ import { ArrowUp as xt, Copy as M, Trash as j, MessageSquare as bt, Region as St, TextTool as Te } from "../icons/index.js";
4
+ import { WORKBENCH_STICKY_FILTER_ID as Ne } from "./types.js";
5
+ import { WORKBENCH_DEFAULT_STICKY_NOTE_COLOR as Ae, WORKBENCH_DEFAULT_TEXT_COLOR as Ie, WORKBENCH_DEFAULT_TEXT_FONT as Wt, WORKBENCH_BACKGROUND_MATERIALS as It, WORKBENCH_REGION_FILL_OPTIONS as Le, WORKBENCH_STICKY_NOTE_COLORS as De, WORKBENCH_DEFAULT_BACKGROUND_MATERIAL as pe, WORKBENCH_DEFAULT_REGION_FILL as Me } from "./workbenchOptions.js";
6
+ import { resolveWorkbenchModeStrategy as Ot, createContextMenuPosition as je, createWorkbenchWidgetFrame as Fe, createWorkbenchId as S, createWorkbenchViewportCenteredOnWidget as Ct, findNearestWidget as Re, sanitizeFilters as ze, WORKBENCH_CONTEXT_MENU_WIDTH_PX as Be, estimateContextMenuHeight as Xe, clampScale as Ee, WORKBENCH_MAX_SCALE as Ye, WORKBENCH_CANVAS_ZOOM_STEP as Tt, normalizeWorkbenchInteractionMode as He, createWorkbenchViewportAtScale as Ke, WORKBENCH_WORK_MIN_SCALE as Ve, createWorkbenchViewportFitForWidget as Ue } from "./workbenchHelpers.js";
7
+ import { resolveWorkbenchWidgetDefinitions as Pe, getWidgetEntry as qe } from "./widgets/widgetRegistry.js";
8
+ function Lt(o, d) {
9
+ const s = o.findIndex((a) => a === d);
9
10
  return o[(s + 1) % o.length] ?? o[0];
10
11
  }
11
- function F(o, c) {
12
- return Number.isFinite(o) && o > 0 ? o : c;
12
+ function F(o, d) {
13
+ return Number.isFinite(o) && o > 0 ? o : d;
13
14
  }
14
- function At(o, c, s) {
15
- const a = String(c ?? "").trim();
15
+ function Nt(o, d, s) {
16
+ const a = String(d ?? "").trim();
16
17
  return o.includes(a) ? a : s;
17
18
  }
18
- function Ve(o, c) {
19
+ function Ge(o, d) {
19
20
  const s = Number(o);
20
- return Number.isFinite(s) ? Math.max(0.08, Math.min(1, s)) : c;
21
+ return Number.isFinite(s) ? Math.max(0.08, Math.min(1, s)) : d;
21
22
  }
22
- function Ue(o) {
23
- return Dt(Ie, o);
23
+ function $e(o) {
24
+ return Lt(De, o);
24
25
  }
25
- function qe(o) {
26
- return Dt(Lt, o);
26
+ function ve(o) {
27
+ return Lt(It, o);
27
28
  }
28
- function It(o) {
29
+ function At(o) {
29
30
  return !("kind" in o);
30
31
  }
31
- function Pe(o, c) {
32
- return o.z_index !== c.z_index ? o.z_index - c.z_index : o.created_at_unix_ms !== c.created_at_unix_ms ? o.created_at_unix_ms - c.created_at_unix_ms : o.id.localeCompare(c.id);
32
+ function Ze(o, d) {
33
+ return o.z_index !== d.z_index ? o.z_index - d.z_index : o.created_at_unix_ms !== d.created_at_unix_ms ? o.created_at_unix_ms - d.created_at_unix_ms : o.id.localeCompare(d.id);
33
34
  }
34
35
  function nt(o) {
35
- return o.reduce((c, s) => Math.max(c, s.z_index), 1);
36
+ return o.reduce((d, s) => Math.max(d, s.z_index), 1);
36
37
  }
37
- function Ge(o, c) {
38
- return nt([...o, ...c]);
38
+ function Je(o, d) {
39
+ return nt([...o, ...d]);
39
40
  }
40
- function $e(o) {
41
+ function Qe(o) {
41
42
  return {
42
43
  id: o.id,
43
44
  type: "sticky_note",
@@ -50,15 +51,15 @@ function $e(o) {
50
51
  created_at_unix_ms: o.created_at_unix_ms
51
52
  };
52
53
  }
53
- function Ze(o, c, s) {
54
+ function tn(o, d, s) {
54
55
  const a = Date.now();
55
56
  return {
56
57
  id: S(),
57
58
  kind: "sticky_note",
58
59
  body: "Capture the thought, decision, or next step here.",
59
- color: Te,
60
+ color: Ae,
60
61
  x: o - 130,
61
- y: c - 92,
62
+ y: d - 92,
62
63
  width: 260,
63
64
  height: 184,
64
65
  z_index: s,
@@ -66,8 +67,8 @@ function Ze(o, c, s) {
66
67
  updated_at_unix_ms: a
67
68
  };
68
69
  }
69
- function ve(o, c, s, a) {
70
- const _ = Date.now(), y = F(a?.width, 360), w = F(a?.height, 96);
70
+ function en(o, d, s, a) {
71
+ const _ = Date.now(), y = F(a?.width, 360), h = F(a?.height, 96);
71
72
  return {
72
73
  id: S(),
73
74
  kind: "text",
@@ -75,48 +76,48 @@ function ve(o, c, s, a) {
75
76
  font_family: a?.font_family ?? Wt.fontFamily,
76
77
  font_size: a?.font_size ?? 30,
77
78
  font_weight: a?.font_weight ?? Wt.fontWeight,
78
- color: a?.color ?? Ne,
79
+ color: a?.color ?? Ie,
79
80
  align: a?.align ?? "left",
80
81
  x: o - y / 2,
81
- y: c - w / 2,
82
+ y: d - h / 2,
82
83
  width: y,
83
- height: w,
84
+ height: h,
84
85
  z_index: s,
85
86
  created_at_unix_ms: _,
86
87
  updated_at_unix_ms: _
87
88
  };
88
89
  }
89
- function Je(o) {
90
- const c = Date.now();
90
+ function nn(o) {
91
+ const d = Date.now();
91
92
  return {
92
93
  ...o,
93
94
  id: S(),
94
95
  x: o.x + 28,
95
96
  y: o.y + 28,
96
97
  z_index: o.z_index + 1,
97
- created_at_unix_ms: c,
98
- updated_at_unix_ms: c
98
+ created_at_unix_ms: d,
99
+ updated_at_unix_ms: d
99
100
  };
100
101
  }
101
- function Qe(o, c, s, a) {
102
- const _ = Date.now(), y = F(a?.width, 560), w = F(a?.height, 360), f = String(a?.name ?? "").trim() || "Focus area";
102
+ function on(o, d, s, a) {
103
+ const _ = Date.now(), y = F(a?.width, 560), h = F(a?.height, 360), f = String(a?.name ?? "").trim() || "Focus area";
103
104
  return {
104
105
  id: S(),
105
106
  name: f,
106
- fill: At(Ae, a?.fill, De),
107
- opacity: Ve(a?.opacity, 0.72),
108
- material: At(Lt, a?.material, Le),
107
+ fill: Nt(Le, a?.fill, Me),
108
+ opacity: Ge(a?.opacity, 0.72),
109
+ material: Nt(It, a?.material, pe),
109
110
  x: o - y / 2,
110
- y: c - w / 2,
111
+ y: d - h / 2,
111
112
  width: y,
112
- height: w,
113
+ height: h,
113
114
  z_index: s,
114
115
  created_at_unix_ms: _,
115
116
  updated_at_unix_ms: _
116
117
  };
117
118
  }
118
- function tn(o) {
119
- const c = Date.now();
119
+ function cn(o) {
120
+ const d = Date.now();
120
121
  return {
121
122
  ...o,
122
123
  id: S(),
@@ -124,45 +125,45 @@ function tn(o) {
124
125
  x: o.x + 36,
125
126
  y: o.y + 36,
126
127
  z_index: o.z_index + 1,
127
- created_at_unix_ms: c,
128
- updated_at_unix_ms: c
128
+ created_at_unix_ms: d,
129
+ updated_at_unix_ms: d
129
130
  };
130
131
  }
131
- function _n(o) {
132
- const [c, s] = et(null), [a, _] = et(null), [y, w] = et({ width: 0, height: 0 });
133
- let f = null, T = null;
134
- const r = o.state, x = u(() => r().widgets), R = u(() => r().stickyNotes ?? []), it = u(() => r().annotations ?? []), ot = u(() => r().backgroundLayers ?? []), h = u(() => r().viewport), jt = u(() => r().locked), B = u(() => r().filters), Mt = u(() => r().selectedWidgetId), p = u(() => r().selectedObject ?? (r().selectedWidgetId ? { kind: "widget", id: r().selectedWidgetId } : null)), N = u(() => r().mode ?? "work"), zt = u(() => Ot(N())), dt = u(() => r().activeTool ?? "select"), Ft = u(() => r().theme), W = u(() => Ge(x(), R())), Rt = u(() => `${Math.round(h().scale * 100)}%`), Bt = () => typeof o.widgetDefinitions == "function" ? o.widgetDefinitions() : o.widgetDefinitions, pt = () => typeof o.textAnnotationDefaults == "function" ? o.textAnnotationDefaults() : o.textAnnotationDefaults, Et = () => typeof o.backgroundLayerDefaults == "function" ? o.backgroundLayerDefaults() : o.backgroundLayerDefaults, O = u(
135
- () => Ke(Bt())
136
- ), E = (e, t) => {
137
- const n = Number.isFinite(e) && e > 0 ? e : 0, i = Number.isFinite(t) && t > 0 ? t : 0, d = { width: n, height: i }, k = y();
138
- return k.width === n && k.height === i ? k : (w(d), d);
139
- }, ct = () => {
140
- T?.disconnect(), T = null;
141
- }, m = () => f ? E(f.clientWidth, f.clientHeight) : E(0, 0), Xt = (e) => {
132
+ function xn(o) {
133
+ const [d, s] = et(null), [a, _] = et(null), [y, h] = et({ width: 0, height: 0 });
134
+ let f = null, C = null;
135
+ const r = o.state, x = u(() => r().widgets), R = u(() => r().stickyNotes ?? []), it = u(() => r().annotations ?? []), ot = u(() => r().backgroundLayers ?? []), m = u(() => r().viewport), Dt = u(() => r().locked), z = u(() => r().filters), pt = u(() => r().selectedWidgetId), B = u(() => r().selectedObject ?? (r().selectedWidgetId ? { kind: "widget", id: r().selectedWidgetId } : null)), T = u(() => r().mode ?? "work"), Mt = u(() => Ot(T())), ct = u(() => r().activeTool ?? "select"), jt = u(() => r().theme), W = u(() => Je(x(), R())), Ft = u(() => `${Math.round(m().scale * 100)}%`), Rt = () => typeof o.widgetDefinitions == "function" ? o.widgetDefinitions() : o.widgetDefinitions, zt = () => typeof o.textAnnotationDefaults == "function" ? o.textAnnotationDefaults() : o.textAnnotationDefaults, Bt = () => typeof o.backgroundLayerDefaults == "function" ? o.backgroundLayerDefaults() : o.backgroundLayerDefaults, N = u(
136
+ () => Pe(Rt())
137
+ ), X = (e, t) => {
138
+ const n = Number.isFinite(e) && e > 0 ? e : 0, i = Number.isFinite(t) && t > 0 ? t : 0, c = { width: n, height: i }, g = y();
139
+ return g.width === n && g.height === i ? g : (h(c), c);
140
+ }, dt = () => {
141
+ C?.disconnect(), C = null;
142
+ }, w = () => f ? X(f.clientWidth, f.clientHeight) : X(0, 0), Xt = (e) => {
142
143
  if (f === (e ?? null)) {
143
- m();
144
+ w();
144
145
  return;
145
146
  }
146
- ct(), f = e ?? null, m(), !(!f || typeof ResizeObserver > "u") && (T = new ResizeObserver((t) => {
147
+ dt(), f = e ?? null, w(), !(!f || typeof ResizeObserver > "u") && (C = new ResizeObserver((t) => {
147
148
  const n = t[0];
148
- E(
149
+ X(
149
150
  n?.contentRect.width ?? f?.clientWidth ?? 0,
150
151
  n?.contentRect.height ?? f?.clientHeight ?? 0
151
152
  );
152
- }), T.observe(f));
153
+ }), C.observe(f));
153
154
  };
154
- We(() => {
155
- ct(), f = null;
155
+ Oe(() => {
156
+ dt(), f = null;
156
157
  });
157
- const Yt = (e) => {
158
+ const Et = (e) => {
158
159
  s({
159
160
  clientX: e.clientX,
160
161
  clientY: e.clientY,
161
162
  worldX: e.worldX,
162
163
  worldY: e.worldY,
163
- target: { kind: "canvas", mode: N() }
164
+ target: { kind: "canvas", mode: T() }
164
165
  });
165
- }, Ht = (e, t) => {
166
+ }, Yt = (e, t) => {
166
167
  b(t.id), s({
167
168
  clientX: e.clientX,
168
169
  clientY: e.clientY,
@@ -171,8 +172,8 @@ function _n(o) {
171
172
  target: { kind: "widget", id: t.id },
172
173
  widgetId: t.id
173
174
  });
174
- }, Kt = (e, t) => {
175
- I(t.id), s({
175
+ }, Ht = (e, t) => {
176
+ L(t.id), s({
176
177
  clientX: e.clientX,
177
178
  clientY: e.clientY,
178
179
  worldX: t.x,
@@ -180,7 +181,7 @@ function _n(o) {
180
181
  target: { kind: "sticky_note", id: t.id },
181
182
  widgetId: t.id
182
183
  });
183
- }, Vt = (e, t) => {
184
+ }, Kt = (e, t) => {
184
185
  s({
185
186
  clientX: e.clientX,
186
187
  clientY: e.clientY,
@@ -188,7 +189,7 @@ function _n(o) {
188
189
  worldY: t.y,
189
190
  target: { kind: "annotation", id: t.id }
190
191
  });
191
- }, Ut = (e, t) => {
192
+ }, Vt = (e, t) => {
192
193
  s({
193
194
  clientX: e.clientX,
194
195
  clientY: e.clientY,
@@ -196,7 +197,20 @@ function _n(o) {
196
197
  worldY: t.y,
197
198
  target: { kind: "background_layer", id: t.id }
198
199
  });
199
- }, l = () => s(null), qt = (e) => r().widgets.find((t) => t.id === e) ?? null, A = (e) => r().widgets.find((t) => t.type === e) ?? null, X = (e) => r().stickyNotes?.find((t) => t.id === e) ?? null, at = (e) => r().annotations?.find((t) => t.id === e) ?? null, st = (e) => r().backgroundLayers?.find((t) => t.id === e) ?? null, Pt = (e) => e.target ? e.target : e.widgetId ? X(e.widgetId) ? { kind: "sticky_note", id: e.widgetId } : { kind: "widget", id: e.widgetId } : { kind: "canvas", mode: N() }, Gt = (e, t) => {
200
+ }, l = () => s(null), Ut = (e) => r().widgets.find((t) => t.id === e) ?? null, A = (e) => r().widgets.find((t) => t.type === e) ?? null, E = (e) => r().stickyNotes?.find((t) => t.id === e) ?? null, at = (e) => r().annotations?.find((t) => t.id === e) ?? null, st = (e) => r().backgroundLayers?.find((t) => t.id === e) ?? null, Pt = (e) => e.target ? e.target : e.widgetId ? E(e.widgetId) ? { kind: "sticky_note", id: e.widgetId } : { kind: "widget", id: e.widgetId } : { kind: "canvas", mode: T() }, I = (e, t) => {
201
+ if (t?.source === "pointer") {
202
+ const n = f?.getBoundingClientRect(), i = n ? Ce(n, m(), {
203
+ clientX: t.clientX,
204
+ clientY: t.clientY
205
+ }) : null;
206
+ if (i)
207
+ return i;
208
+ }
209
+ return {
210
+ worldX: e.worldX,
211
+ worldY: e.worldY
212
+ };
213
+ }, qt = (e, t) => {
200
214
  const n = e.singleton ? A(e.type) : null;
201
215
  return n ? {
202
216
  id: `goto-${e.type}`,
@@ -207,7 +221,7 @@ function _n(o) {
207
221
  icon: e.icon,
208
222
  existingWidgetId: n.id,
209
223
  onSelect: () => {
210
- C(n, { centerViewport: !0 }), l();
224
+ O(n, { centerViewport: !0 }), l();
211
225
  }
212
226
  } : {
213
227
  id: `add-${e.type}`,
@@ -216,16 +230,17 @@ function _n(o) {
216
230
  widgetType: e.type,
217
231
  label: `Add ${e.label}`,
218
232
  icon: e.icon,
219
- onSelect: () => {
220
- H(e.type, t.worldX, t.worldY), l();
233
+ onSelect: (i) => {
234
+ const c = I(t, i);
235
+ H(e.type, c.worldX, c.worldY), l();
221
236
  }
222
237
  };
223
238
  }, rt = u(() => {
224
- const e = c();
239
+ const e = d();
225
240
  if (!e) return [];
226
241
  const t = Pt(e);
227
242
  if (t.kind === "widget") {
228
- const n = x().find((d) => d.id === t.id), i = [];
243
+ const n = x().find((c) => c.id === t.id), i = [];
229
244
  return n && (i.push({
230
245
  id: "bring-to-front",
231
246
  kind: "action",
@@ -246,7 +261,7 @@ function _n(o) {
246
261
  id: "delete",
247
262
  kind: "action",
248
263
  label: "Delete",
249
- icon: z,
264
+ icon: j,
250
265
  destructive: !0,
251
266
  onSelect: () => {
252
267
  K(t.id), l();
@@ -254,14 +269,14 @@ function _n(o) {
254
269
  }), i;
255
270
  }
256
271
  if (t.kind === "sticky_note") {
257
- const n = X(t.id), i = [];
272
+ const n = E(t.id), i = [];
258
273
  return n && (i.push({
259
274
  id: "bring-to-front",
260
275
  kind: "action",
261
276
  label: "Bring to Front",
262
277
  icon: xt,
263
278
  onSelect: () => {
264
- I(n.id), l();
279
+ L(n.id), l();
265
280
  }
266
281
  }), i.push({
267
282
  id: "copy-content",
@@ -277,16 +292,16 @@ function _n(o) {
277
292
  label: "Change Color",
278
293
  icon: bt,
279
294
  onSelect: () => {
280
- kt(n.id, { color: Ue(n.color) }), l();
295
+ kt(n.id, { color: $e(n.color) }), l();
281
296
  }
282
297
  })), i.push({ id: "separator-delete", kind: "separator" }), i.push({
283
298
  id: "delete",
284
299
  kind: "action",
285
300
  label: "Delete",
286
- icon: z,
301
+ icon: j,
287
302
  destructive: !0,
288
303
  onSelect: () => {
289
- P(t.id), l();
304
+ q(t.id), l();
290
305
  }
291
306
  }), i;
292
307
  }
@@ -304,7 +319,7 @@ function _n(o) {
304
319
  id: "delete",
305
320
  kind: "action",
306
321
  label: "Delete Text",
307
- icon: z,
322
+ icon: j,
308
323
  destructive: !0,
309
324
  onSelect: () => {
310
325
  G(t.id), l();
@@ -327,13 +342,13 @@ function _n(o) {
327
342
  label: "Change Material",
328
343
  icon: St,
329
344
  onSelect: () => {
330
- ft(n.id, { material: qe(n.material) }), l();
345
+ ft(n.id, { material: ve(n.material) }), l();
331
346
  }
332
347
  })), i.push({ id: "separator-delete", kind: "separator" }), i.push({
333
348
  id: "delete",
334
349
  kind: "action",
335
350
  label: "Delete Region",
336
- icon: z,
351
+ icon: j,
337
352
  destructive: !0,
338
353
  onSelect: () => {
339
354
  $(t.id), l();
@@ -346,17 +361,19 @@ function _n(o) {
346
361
  kind: "action",
347
362
  label: "Add Region",
348
363
  icon: St,
349
- onSelect: () => {
350
- q(e.worldX, e.worldY), l();
364
+ onSelect: (n) => {
365
+ const i = I(e, n);
366
+ P(i.worldX, i.worldY), l();
351
367
  }
352
368
  },
353
369
  {
354
370
  id: "create-text",
355
371
  kind: "action",
356
372
  label: "Add Text",
357
- icon: Oe,
358
- onSelect: () => {
359
- U(e.worldX, e.worldY), l();
373
+ icon: Te,
374
+ onSelect: (n) => {
375
+ const i = I(e, n);
376
+ U(i.worldX, i.worldY), l();
360
377
  }
361
378
  }
362
379
  ] : [
@@ -365,49 +382,59 @@ function _n(o) {
365
382
  kind: "action",
366
383
  label: "Add Sticky",
367
384
  icon: bt,
368
- onSelect: () => {
369
- V(e.worldX, e.worldY), l();
385
+ onSelect: (n) => {
386
+ const i = I(e, n);
387
+ V(i.worldX, i.worldY), l();
370
388
  }
371
389
  },
372
- ...O().map((n) => Gt(n, e))
390
+ ...N().map((n) => qt(n, e))
373
391
  ];
374
- }), $t = u(() => {
375
- const e = c();
392
+ }), Gt = u(() => {
393
+ const e = d();
376
394
  if (!e) return;
377
- const t = rt(), n = t.filter((d) => d.kind === "action").length, i = t.filter((d) => d.kind === "separator").length;
395
+ const t = rt(), n = t.filter((c) => c.kind === "action").length, i = t.filter((c) => c.kind === "separator").length;
378
396
  return je({
379
397
  clientX: e.clientX,
380
398
  clientY: e.clientY,
381
- menuWidth: Fe,
382
- menuHeight: Re(n, i)
399
+ menuWidth: Be,
400
+ menuHeight: Xe(n, i)
383
401
  });
384
- }), Y = (e, t, n) => {
385
- const i = Nt(e, O()), d = i.singleton ? A(e) : null;
386
- if (d)
387
- return C(d, { centerViewport: !0 });
388
- const k = i.defaultSize, g = {
402
+ }), Y = (e, t) => {
403
+ const n = qe(e, N()), i = n.singleton ? A(e) : null;
404
+ if (i)
405
+ return O(i, { centerViewport: !0 });
406
+ const c = Fe(n, t), g = {
389
407
  id: S(),
390
408
  type: e,
391
- title: i.defaultTitle,
392
- x: t,
393
- y: n,
394
- width: k.width,
395
- height: k.height,
409
+ title: n.defaultTitle,
410
+ x: c.x,
411
+ y: c.y,
412
+ width: c.width,
413
+ height: c.height,
396
414
  z_index: W() + 1,
397
415
  created_at_unix_ms: Date.now()
398
416
  };
399
- return o.setState((j) => ({
400
- ...j,
401
- widgets: [...j.widgets, g],
417
+ return o.setState((k) => ({
418
+ ...k,
419
+ widgets: [...k.widgets, g],
402
420
  selectedWidgetId: g.id,
403
421
  selectedObject: { kind: "widget", id: g.id },
404
422
  mode: "work",
405
423
  activeTool: "select"
406
424
  })), g;
407
- }, H = (e, t, n) => {
408
- const i = Nt(e, O()).defaultSize;
409
- return Y(e, t - i.width / 2, n - i.height / 2);
410
- }, lt = (e, t, n) => Y(e, t, n), K = (e) => {
425
+ }, $t = (e, t, n) => Y(e, {
426
+ anchor: "top_left",
427
+ worldX: t,
428
+ worldY: n
429
+ }), lt = (e, t, n) => Y(e, {
430
+ anchor: "top_left",
431
+ worldX: t,
432
+ worldY: n
433
+ }), H = (e, t, n) => Y(e, {
434
+ anchor: "center",
435
+ worldX: t,
436
+ worldY: n
437
+ }), K = (e) => {
411
438
  o.setState((t) => ({
412
439
  ...t,
413
440
  widgets: t.widgets.filter((n) => n.id !== e),
@@ -415,7 +442,7 @@ function _n(o) {
415
442
  selectedObject: t.selectedObject?.kind === "widget" && t.selectedObject.id === e ? null : t.selectedObject ?? null
416
443
  }));
417
444
  }, V = (e, t) => {
418
- const n = Ze(e, t, W() + 1);
445
+ const n = tn(e, t, W() + 1);
419
446
  return o.setState((i) => ({
420
447
  ...i,
421
448
  stickyNotes: [...i.stickyNotes ?? [], n],
@@ -425,11 +452,11 @@ function _n(o) {
425
452
  activeTool: "select"
426
453
  })), n;
427
454
  }, U = (e, t) => {
428
- const n = ve(
455
+ const n = en(
429
456
  e,
430
457
  t,
431
458
  nt(it()) + 1,
432
- pt()
459
+ zt()
433
460
  );
434
461
  return o.setState((i) => ({
435
462
  ...i,
@@ -440,7 +467,7 @@ function _n(o) {
440
467
  activeTool: "select"
441
468
  })), n;
442
469
  }, ut = (e) => {
443
- const t = Je(e);
470
+ const t = nn(e);
444
471
  return o.setState((n) => ({
445
472
  ...n,
446
473
  annotations: [...n.annotations ?? [], t],
@@ -449,12 +476,12 @@ function _n(o) {
449
476
  mode: "background",
450
477
  activeTool: "select"
451
478
  })), t;
452
- }, q = (e, t) => {
453
- const n = Qe(
479
+ }, P = (e, t) => {
480
+ const n = on(
454
481
  e,
455
482
  t,
456
483
  nt(ot()) + 1,
457
- Et()
484
+ Bt()
458
485
  );
459
486
  return o.setState((i) => ({
460
487
  ...i,
@@ -465,7 +492,7 @@ function _n(o) {
465
492
  activeTool: "select"
466
493
  })), n;
467
494
  }, gt = (e) => {
468
- const t = tn(e);
495
+ const t = cn(e);
469
496
  return o.setState((n) => ({
470
497
  ...n,
471
498
  backgroundLayers: [...n.backgroundLayers ?? [], t],
@@ -474,7 +501,7 @@ function _n(o) {
474
501
  mode: "background",
475
502
  activeTool: "select"
476
503
  })), t;
477
- }, Zt = (e) => {
504
+ }, vt = (e) => {
478
505
  _(e);
479
506
  }, b = (e) => {
480
507
  _(e);
@@ -482,10 +509,10 @@ function _n(o) {
482
509
  n && n.z_index < t && o.setState((i) => ({
483
510
  ...i,
484
511
  widgets: i.widgets.map(
485
- (d) => d.id === e ? { ...d, z_index: t + 1 } : d
512
+ (c) => c.id === e ? { ...c, z_index: t + 1 } : c
486
513
  )
487
514
  }));
488
- }, I = (e) => {
515
+ }, L = (e) => {
489
516
  _(e);
490
517
  const t = W();
491
518
  o.setState((n) => ({
@@ -494,7 +521,7 @@ function _n(o) {
494
521
  (i) => i.id === e && i.z_index < t ? { ...i, z_index: t + 1, updated_at_unix_ms: Date.now() } : i
495
522
  )
496
523
  }));
497
- }, vt = (e, t) => {
524
+ }, Zt = (e, t) => {
498
525
  o.setState((n) => ({
499
526
  ...n,
500
527
  widgets: n.widgets.map(
@@ -534,7 +561,7 @@ function _n(o) {
534
561
  } : i
535
562
  )
536
563
  }));
537
- }, P = (e) => {
564
+ }, q = (e) => {
538
565
  o.setState((t) => ({
539
566
  ...t,
540
567
  stickyNotes: (t.stickyNotes ?? []).filter((n) => n.id !== e),
@@ -583,7 +610,7 @@ function _n(o) {
583
610
  (i) => i.id === e ? { ...i, x: t.x, y: t.y, updated_at_unix_ms: Date.now() } : i
584
611
  )
585
612
  }));
586
- }, de = (e, t) => {
613
+ }, ce = (e, t) => {
587
614
  o.setState((n) => ({
588
615
  ...n,
589
616
  backgroundLayers: (n.backgroundLayers ?? []).map(
@@ -611,27 +638,27 @@ function _n(o) {
611
638
  selectedObject: t.selectedObject?.kind === "background_layer" && t.selectedObject.id === e ? null : t.selectedObject ?? null
612
639
  }));
613
640
  };
614
- let Z = 0;
615
- const v = (e) => {
641
+ let v = 0;
642
+ const Z = (e) => {
616
643
  o.setState((t) => ({ ...t, viewport: e }));
617
- }, ce = () => {
618
- Z += 1;
619
- }, L = (e) => {
620
- const t = h(), n = t.x, i = t.y, d = t.scale, k = performance.now(), g = 360, j = ++Z, be = (Q) => 1 - Math.pow(1 - Q, 3), wt = (Q) => {
621
- if (j !== Z) return;
622
- const Se = Q - k, ht = Math.min(Math.max(Se / g, 0), 1), tt = be(ht);
623
- v({
644
+ }, de = () => {
645
+ v += 1;
646
+ }, D = (e) => {
647
+ const t = m(), n = t.x, i = t.y, c = t.scale, g = performance.now(), k = 360, be = ++v, Se = (Q) => 1 - Math.pow(1 - Q, 3), wt = (Q) => {
648
+ if (be !== v) return;
649
+ const We = Q - g, ht = Math.min(Math.max(We / k, 0), 1), tt = Se(ht);
650
+ Z({
624
651
  x: n + (e.x - n) * tt,
625
652
  y: i + (e.y - i) * tt,
626
- scale: d + (e.scale - d) * tt
653
+ scale: c + (e.scale - c) * tt
627
654
  }), ht < 1 && requestAnimationFrame(wt);
628
655
  };
629
656
  requestAnimationFrame(wt);
630
657
  }, ae = (e) => {
631
- const t = Ot(e), n = h();
658
+ const t = Ot(e), n = m();
632
659
  if (n.scale >= t.minScale) return;
633
- const i = m();
634
- L(Xe({
660
+ const i = w();
661
+ D(Ke({
635
662
  viewport: n,
636
663
  scale: t.minScale,
637
664
  minScale: t.minScale,
@@ -639,16 +666,16 @@ function _n(o) {
639
666
  frameHeight: i.height
640
667
  }));
641
668
  }, _t = (e) => {
642
- const t = h(), n = m(), i = (n.width / 2 - t.x) / t.scale, d = (n.height / 2 - t.y) / t.scale, k = Be(
669
+ const t = m(), n = w(), i = (n.width / 2 - t.x) / t.scale, c = (n.height / 2 - t.y) / t.scale, g = Ee(
643
670
  e === "in" ? t.scale * Tt : t.scale / Tt,
644
- zt().minScale,
645
- pe
646
- ), g = {
647
- x: n.width / 2 - i * k,
648
- y: n.height / 2 - d * k,
649
- scale: k
671
+ Mt().minScale,
672
+ Ye
673
+ ), k = {
674
+ x: n.width / 2 - i * g,
675
+ y: n.height / 2 - c * g,
676
+ scale: g
650
677
  };
651
- v(g);
678
+ Z(k);
652
679
  }, se = () => {
653
680
  o.setState((e) => ({ ...e, locked: !e.locked }));
654
681
  }, re = (e) => {
@@ -658,20 +685,20 @@ function _n(o) {
658
685
  }));
659
686
  }, le = (e, t) => {
660
687
  o.setState((n) => {
661
- const i = { ...n.filters }, d = [...new Set(t.map((g) => String(g)).filter(Boolean))], k = d.length > 1 && d.every(
662
- (g) => i[g] !== !1 == (g === e)
688
+ const i = { ...n.filters }, c = [...new Set(t.map((k) => String(k)).filter(Boolean))], g = c.length > 1 && c.every(
689
+ (k) => i[k] !== !1 == (k === e)
663
690
  );
664
- for (const g of d)
665
- i[g] = k ? !0 : g === e;
691
+ for (const k of c)
692
+ i[k] = g ? !0 : k === e;
666
693
  return { ...n, filters: i };
667
694
  });
668
695
  }, ue = () => {
669
- const e = O();
696
+ const e = N();
670
697
  o.setState((t) => ({
671
698
  ...t,
672
699
  filters: ze(void 0, e)
673
700
  }));
674
- }, D = (e) => {
701
+ }, p = (e) => {
675
702
  o.setState((t) => ({
676
703
  ...t,
677
704
  selectedWidgetId: e,
@@ -697,7 +724,7 @@ function _n(o) {
697
724
  selectedObject: { kind: "sticky_note", id: e },
698
725
  mode: "work",
699
726
  activeTool: "select"
700
- })), I(e);
727
+ })), L(e);
701
728
  }, ke = (e) => {
702
729
  o.setState((t) => ({
703
730
  ...t,
@@ -715,7 +742,7 @@ function _n(o) {
715
742
  activeTool: "select"
716
743
  }));
717
744
  }, _e = (e) => {
718
- const t = Ee(e);
745
+ const t = He(e);
719
746
  o.setState((n) => ({
720
747
  ...n,
721
748
  mode: t,
@@ -730,61 +757,61 @@ function _n(o) {
730
757
  mode: e === "text" || e === "background-region" ? "background" : e === "sticky-note" ? "work" : t.mode ?? "work"
731
758
  }));
732
759
  }, me = (e, t) => {
733
- const n = dt();
734
- return n === "sticky-note" ? V(e, t) : n === "text" ? U(e, t) : n === "background-region" ? q(e, t) : null;
760
+ const n = ct();
761
+ return n === "sticky-note" ? V(e, t) : n === "text" ? U(e, t) : n === "background-region" ? P(e, t) : null;
735
762
  }, we = () => {
736
- const e = m(), t = h();
763
+ const e = w(), t = m();
737
764
  return {
738
765
  worldX: e.width > 0 ? (e.width / 2 - t.x) / t.scale : 240,
739
766
  worldY: e.height > 0 ? (e.height / 2 - t.y) / t.scale : 180
740
767
  };
741
768
  }, J = (e) => {
742
- const t = m();
743
- t.width === 0 || t.height === 0 || L(Ct({
769
+ const t = w();
770
+ t.width === 0 || t.height === 0 || D(Ct({
744
771
  widget: e,
745
- scale: h().scale,
772
+ scale: m().scale,
746
773
  frameWidth: t.width,
747
774
  frameHeight: t.height
748
775
  }));
749
776
  }, he = (e) => {
750
- const t = m();
751
- t.width === 0 || t.height === 0 || L(He({
777
+ const t = w();
778
+ t.width === 0 || t.height === 0 || D(Ue({
752
779
  widget: e,
753
780
  frameWidth: t.width,
754
781
  frameHeight: t.height
755
782
  }));
756
783
  }, xe = (e) => {
757
- const t = m();
758
- t.width === 0 || t.height === 0 || L(Ct({
784
+ const t = w();
785
+ t.width === 0 || t.height === 0 || D(Ct({
759
786
  widget: e,
760
- scale: Ye,
787
+ scale: Ve,
761
788
  frameWidth: t.width,
762
789
  frameHeight: t.height
763
790
  }));
764
- }, C = (e, t = {}) => (D(e.id), b(e.id), t.centerViewport !== !1 && J(e), e);
791
+ }, O = (e, t = {}) => (p(e.id), b(e.id), t.centerViewport !== !1 && J(e), e);
765
792
  return {
766
793
  widgets: x,
767
794
  stickyNotes: R,
768
795
  annotations: it,
769
796
  backgroundLayers: ot,
770
- viewport: h,
797
+ viewport: m,
771
798
  canvasFrameSize: y,
772
- locked: jt,
773
- filters: B,
774
- selectedWidgetId: Mt,
775
- selectedObject: p,
776
- mode: N,
777
- activeTool: dt,
778
- theme: Ft,
799
+ locked: Dt,
800
+ filters: z,
801
+ selectedWidgetId: pt,
802
+ selectedObject: B,
803
+ mode: T,
804
+ activeTool: ct,
805
+ theme: jt,
779
806
  topZIndex: W,
780
- scaleLabel: Rt,
807
+ scaleLabel: Ft,
781
808
  optimisticFrontWidgetId: a,
782
- widgetDefinitions: O,
809
+ widgetDefinitions: N,
783
810
  setCanvasFrameRef: Xt,
784
811
  contextMenu: {
785
- state: c,
812
+ state: d,
786
813
  items: rt,
787
- position: $t,
814
+ position: Gt,
788
815
  close: l,
789
816
  retarget: (e) => {
790
817
  e.preventDefault(), e.stopPropagation(), s({
@@ -796,30 +823,30 @@ function _n(o) {
796
823
  }
797
824
  },
798
825
  canvas: {
799
- openCanvasContextMenu: Yt,
800
- openWidgetContextMenu: Ht,
801
- openStickyNoteContextMenu: Kt,
802
- openAnnotationContextMenu: Vt,
803
- openBackgroundLayerContextMenu: Ut,
804
- selectWidget: D,
826
+ openCanvasContextMenu: Et,
827
+ openWidgetContextMenu: Yt,
828
+ openStickyNoteContextMenu: Ht,
829
+ openAnnotationContextMenu: Kt,
830
+ openBackgroundLayerContextMenu: Vt,
831
+ selectWidget: p,
805
832
  selectObject: ge,
806
833
  selectStickyNote: mt,
807
834
  selectAnnotation: ke,
808
835
  selectBackgroundLayer: fe,
809
836
  clearSelection: yt,
810
- startOptimisticFront: Zt,
837
+ startOptimisticFront: vt,
811
838
  commitFront: b,
812
- commitMove: vt,
839
+ commitMove: Zt,
813
840
  commitResize: Jt,
814
- commitStickyFront: I,
841
+ commitStickyFront: L,
815
842
  commitStickyMove: Qt,
816
843
  commitStickyResize: te,
817
844
  commitAnnotationMove: ee,
818
845
  commitAnnotationResize: ne,
819
846
  commitBackgroundMove: oe,
820
- commitBackgroundResize: de,
821
- commitViewport: v,
822
- cancelViewportNavigation: ce
847
+ commitBackgroundResize: ce,
848
+ commitViewport: Z,
849
+ cancelViewportNavigation: de
823
850
  },
824
851
  hud: {
825
852
  zoomIn: () => _t("in"),
@@ -835,58 +862,58 @@ function _n(o) {
835
862
  },
836
863
  navigation: {
837
864
  handleArrowNavigation: (e) => {
838
- const t = p(), n = [
865
+ const t = B(), n = [
839
866
  ...x(),
840
- ...R().map((d) => $e(d))
841
- ].sort(Pe), i = Me(
867
+ ...R().map((c) => Qe(c))
868
+ ].sort(Ze), i = Re(
842
869
  n,
843
870
  t?.kind === "widget" || t?.kind === "sticky_note" ? t.id : null,
844
871
  e,
845
872
  Object.fromEntries(
846
- n.map((d) => [
847
- It(d) ? d.type : "sticky_note",
848
- It(d) ? B()[d.type] !== !1 : B()[Ce] !== !1
873
+ n.map((c) => [
874
+ At(c) ? c.type : "sticky_note",
875
+ At(c) ? z()[c.type] !== !1 : z()[Ne] !== !1
849
876
  ])
850
877
  )
851
878
  );
852
- i && (x().some((d) => d.id === i.id) ? C(i) : mt(i.id));
879
+ i && (x().some((c) => c.id === i.id) ? O(i) : mt(i.id));
853
880
  },
854
881
  centerOnWidget: J,
855
- focusWidget: C,
856
- fitWidget: (e) => (D(e.id), b(e.id), he(e), e),
857
- overviewWidget: (e) => (D(e.id), b(e.id), xe(e), e)
882
+ focusWidget: O,
883
+ fitWidget: (e) => (p(e.id), b(e.id), he(e), e),
884
+ overviewWidget: (e) => (p(e.id), b(e.id), xe(e), e)
858
885
  },
859
886
  selection: {
860
887
  clear: yt
861
888
  },
862
889
  widgetActions: {
863
890
  deleteSelected: () => {
864
- const e = p();
865
- e && (e.kind === "widget" && K(e.id), e.kind === "sticky_note" && P(e.id), e.kind === "annotation" && G(e.id), e.kind === "background_layer" && $(e.id));
891
+ const e = B();
892
+ e && (e.kind === "widget" && K(e.id), e.kind === "sticky_note" && q(e.id), e.kind === "annotation" && G(e.id), e.kind === "background_layer" && $(e.id));
866
893
  },
867
894
  deleteWidget: K,
868
- deleteStickyNote: P,
895
+ deleteStickyNote: q,
869
896
  deleteAnnotation: G,
870
897
  deleteBackgroundLayer: $,
871
- addWidget: Y,
872
- addWidgetAtCursor: H,
873
- addWidgetCentered: lt,
898
+ addWidget: $t,
899
+ addWidgetAtWorldTopLeft: lt,
900
+ addWidgetAtWorldCenter: H,
874
901
  addStickyNoteAtCursor: V,
875
902
  addTextAnnotationAtCursor: U,
876
903
  duplicateTextAnnotationFrom: ut,
877
- addBackgroundLayerAtCursor: q,
904
+ addBackgroundLayerAtCursor: P,
878
905
  duplicateBackgroundLayerFrom: gt,
879
906
  createActiveToolAt: me,
880
907
  ensureWidget: (e, t) => {
881
908
  const n = A(e);
882
909
  if (n)
883
- return C(n, { centerViewport: t?.centerViewport ?? !0 });
884
- const i = we(), d = H(
910
+ return O(n, { centerViewport: t?.centerViewport ?? !0 });
911
+ const i = we(), c = H(
885
912
  e,
886
913
  t?.worldX ?? i.worldX,
887
914
  t?.worldY ?? i.worldY
888
915
  );
889
- return (t?.centerViewport ?? !0) && d && J(d), d;
916
+ return (t?.centerViewport ?? !0) && c && J(c), c;
890
917
  },
891
918
  updateStickyNote: kt,
892
919
  updateTextAnnotation: ie,
@@ -894,8 +921,8 @@ function _n(o) {
894
921
  },
895
922
  queries: {
896
923
  findWidgetByType: A,
897
- findWidgetById: qt,
898
- findStickyNoteById: X,
924
+ findWidgetById: Ut,
925
+ findStickyNoteById: E,
899
926
  findAnnotationById: at,
900
927
  findBackgroundLayerById: st
901
928
  },
@@ -909,7 +936,7 @@ function _n(o) {
909
936
  setActiveTool: ye
910
937
  },
911
938
  handleCloseRequest: () => {
912
- if (c()) {
939
+ if (d()) {
913
940
  l();
914
941
  return;
915
942
  }
@@ -918,5 +945,5 @@ function _n(o) {
918
945
  };
919
946
  }
920
947
  export {
921
- _n as useWorkbenchModel
948
+ xn as useWorkbenchModel
922
949
  };