@floegence/floe-webapp-core 0.35.46 → 0.35.47

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,127 +1,150 @@
1
- import { createSignal as a, createMemo as c, createEffect as v, onCleanup as X } from "solid-js";
2
- import { Paste as Xt, Plus as St, Trash as Yt } from "../icons/index.js";
3
- import { NOTES_CONTEXT_MENU_WIDTH_PX as Et, estimateNotesContextMenuHeight as Lt } from "./NotesContextMenu.js";
4
- import { resolveFrameSize as V, resolveOverviewBounds as Rt, createOverviewItem as zt, clamp as b, createContextMenuPosition as At, NOTES_MOBILE_BREAKPOINT_PX as Ft, getNormalizedOverviewPoint as Ae, findTrashTopicNoteCount as kt, hasLiveNotesForTopic as Bt, NOTES_CANVAS_ZOOM_STEP as Fe, resolveCenteredViewport as Vt } from "./notesOverlayHelpers.js";
5
- import { normalizeNotesSnapshot as Wt, groupTrashItems as Ht, visibleWorldRect as $t, computeBoardBounds as Kt } from "./types.js";
6
- import { useNotification as Zt } from "../../context/NotificationContext.js";
7
- function p(r) {
1
+ import { createSignal as l, createMemo as c, createEffect as w, onCleanup as X } from "solid-js";
2
+ import { Paste as zt, Plus as At, Trash as Ft } from "../icons/index.js";
3
+ import { NOTES_CONTEXT_MENU_WIDTH_PX as kt, estimateNotesContextMenuHeight as Bt } from "./NotesContextMenu.js";
4
+ import { samePoint as ie, resolveFrameSize as W, resolveOverviewBounds as Vt, createOverviewItem as jt, clamp as _, createContextMenuPosition as Wt, NOTES_MOBILE_BREAKPOINT_PX as Ht, getNormalizedOverviewPoint as je, findTrashTopicNoteCount as $t, hasLiveNotesForTopic as Kt, NOTES_CANVAS_ZOOM_STEP as We, resolveCenteredViewport as Zt } from "./notesOverlayHelpers.js";
5
+ import { normalizeNotesSnapshot as qt, groupTrashItems as Gt, visibleWorldRect as Ut, computeBoardBounds as Jt } from "./types.js";
6
+ import { useNotification as Qt } from "../../context/NotificationContext.js";
7
+ function m(r) {
8
8
  return r instanceof Error ? r.message : String(r);
9
9
  }
10
- function eo(r) {
11
- const s = Zt(), [ne, ke] = a(), [_, Be] = a({ width: 0, height: 0 }), [T, d] = a(null), [re, ie] = a(""), [W, ce] = a(null), [se, H] = a(""), [$, S] = a(null), [ae, le] = a(""), [de, ue] = a("amber"), [pe, fe] = a(!1), [me, he] = a(!1), [K, we] = a(null), [Z, j] = a(""), [Ve, Y] = a(null), [We, He] = a(Date.now()), [$e, Ke] = a(!1), [ve, y] = a(null), [Ze, Te] = a(null), [ge, x] = a(null);
12
- let D, q, G = null;
13
- const f = c(() => Wt(r.controller.snapshot())), g = c(
14
- () => f().topics.filter((e) => e.deleted_at_unix_ms <= 0)
15
- ), je = c(() => g().length), C = c(() => {
10
+ function co(r) {
11
+ const a = Qt(), [ce, He] = l(), [M, $e] = l({ width: 0, height: 0 }), [T, d] = l(null), [se, ae] = l(""), [H, le] = l(null), [de, $] = l(""), [K, S] = l(null), [ue, pe] = l(""), [fe, me] = l("amber"), [we, he] = l(!1), [ve, Te] = l(!1), [Z, ge] = l(null), [q, G] = l(""), [Ke, Y] = l(null), [Ze, qe] = l(Date.now()), [Ge, Ue] = l(!1), [ye, y] = l(null), [Je, xe] = l(null), [Ce, b] = l(null), [Ne, E] = l(/* @__PURE__ */ new Map());
12
+ let P, U, J = null;
13
+ const p = c(() => qt(r.controller.snapshot())), g = c(
14
+ () => p().topics.filter((e) => e.deleted_at_unix_ms <= 0)
15
+ ), Qe = c(() => g().length), x = c(() => {
16
16
  const e = r.controller.activeTopicID();
17
17
  return g().some((t) => t.topic_id === e) ? e : g()[0]?.topic_id ?? "";
18
- }), P = c(
19
- () => g().find((e) => e.topic_id === C())
20
- ), E = c(
21
- () => f().items.filter((e) => e.topic_id === C())
22
- ), qe = c(() => Ht(f().trash_items)), ye = c(() => f().trash_items.length), Ge = c(() => f().items.length), Ue = c(
23
- () => E().reduce((e, t) => Math.max(e, t.z_index), 1)
24
- ), h = c(
25
- () => ge() ?? r.controller.viewport()
26
- ), Je = c(() => P()?.name ?? "No topic"), Qe = c(
27
- () => `${Math.round(h().scale * 100)}%`
18
+ }), I = c(
19
+ () => g().find((e) => e.topic_id === x())
28
20
  ), et = c(() => {
29
- const e = V(_());
30
- return $t(h(), e.width, e.height);
21
+ const e = Ne();
22
+ return p().items.map((t) => {
23
+ const o = e.get(t.note_id);
24
+ return !o || ie({ x: t.x, y: t.y }, o) ? t : {
25
+ ...t,
26
+ x: o.x,
27
+ y: o.y
28
+ };
29
+ });
31
30
  }), L = c(
32
- () => Rt(Kt(E()), et())
33
- ), tt = c(
34
- () => E().map((e) => zt(e, L()))
35
- ), Ce = c(() => {
36
- const e = L(), t = V(_()), o = h(), n = -o.x / o.scale, i = -o.y / o.scale, l = t.width / o.scale, m = t.height / o.scale, u = b(n, e.minX, e.maxX), N = b(i, e.minY, e.maxY), I = b(n + l, e.minX, e.maxX), oe = b(i + m, e.minY, e.maxY), O = Math.max((I - u) / e.width * 100, 6), w = Math.max((oe - N) / e.height * 100, 8), Re = (u - e.minX) / e.width * 100, ze = (N - e.minY) / e.height * 100;
31
+ () => et().filter((e) => e.topic_id === x())
32
+ ), tt = c(() => Gt(p().trash_items)), _e = c(() => p().trash_items.length), ot = c(() => p().items.length), nt = c(
33
+ () => L().reduce((e, t) => Math.max(e, t.z_index), 1)
34
+ ), h = c(
35
+ () => Ce() ?? r.controller.viewport()
36
+ ), rt = c(() => I()?.name ?? "No topic"), it = c(
37
+ () => `${Math.round(h().scale * 100)}%`
38
+ ), ct = c(() => {
39
+ const e = W(M());
40
+ return Ut(h(), e.width, e.height);
41
+ }), R = c(
42
+ () => Vt(Jt(L()), ct())
43
+ ), st = c(
44
+ () => L().map((e) => jt(e, R()))
45
+ ), Me = c(() => {
46
+ const e = R(), t = W(M()), o = h(), n = -o.x / o.scale, i = -o.y / o.scale, s = t.width / o.scale, u = t.height / o.scale, f = _(n, e.minX, e.maxX), C = _(i, e.minY, e.maxY), N = _(n + s, e.minX, e.maxX), re = _(i + u, e.minY, e.maxY), O = Math.max((N - f) / e.width * 100, 6), v = Math.max((re - C) / e.height * 100, 8), Be = (f - e.minX) / e.width * 100, Ve = (C - e.minY) / e.height * 100;
37
47
  return {
38
- left: Re,
39
- top: ze,
48
+ left: Be,
49
+ top: Ve,
40
50
  width: O,
41
- height: w,
42
- centerX: Re + O / 2,
43
- centerY: ze + w / 2
51
+ height: v,
52
+ centerX: Be + O / 2,
53
+ centerY: Ve + v / 2
44
54
  };
45
- }), ot = c(() => {
46
- const e = Ce();
55
+ }), at = c(() => {
56
+ const e = Me();
47
57
  return {
48
58
  left: `${e.left}%`,
49
59
  top: `${e.top}%`,
50
60
  width: `${e.width}%`,
51
61
  height: `${e.height}%`
52
62
  };
53
- }), Ne = c(() => {
54
- const e = $();
55
- return e ? f().items.find((t) => t.note_id === e) : void 0;
56
- }), U = () => {
57
- D !== void 0 && (window.clearTimeout(D), D = void 0);
58
- }, R = () => {
59
- we(null), j("");
60
- }, z = () => {
63
+ }), be = c(() => {
64
+ const e = K();
65
+ return e ? p().items.find((t) => t.note_id === e) : void 0;
66
+ }), Q = () => {
67
+ P !== void 0 && (window.clearTimeout(P), P = void 0);
68
+ }, Pe = (e, t) => {
69
+ E((o) => {
70
+ const n = o.get(e);
71
+ if (n && ie(n, t)) return o;
72
+ const i = new Map(o);
73
+ return i.set(e, t), i;
74
+ });
75
+ }, z = (e) => {
76
+ E((t) => {
77
+ if (!t.has(e)) return t;
78
+ const o = new Map(t);
79
+ return o.delete(e), o;
80
+ });
81
+ }, A = () => {
82
+ ge(null), G("");
83
+ }, F = () => {
61
84
  S(null);
62
- }, M = () => {
63
- he(!1);
85
+ }, D = () => {
86
+ Te(!1);
64
87
  }, Ie = () => {
88
+ Te(!0);
89
+ }, k = () => {
90
+ he(!1);
91
+ }, ee = () => {
65
92
  he(!0);
66
- }, A = () => {
67
- fe(!1);
68
- }, J = () => {
69
- fe(!0);
70
- }, F = () => {
71
- ce(null), H("");
72
- }, nt = () => {
73
- d(null), A(), M(), z(), R();
74
- }, rt = () => {
93
+ }, B = () => {
94
+ le(null), $("");
95
+ }, lt = () => {
96
+ d(null), k(), D(), F(), A(), E(/* @__PURE__ */ new Map());
97
+ }, dt = () => {
75
98
  if (T()) {
76
99
  d(null);
77
100
  return;
78
101
  }
79
- if ($()) {
80
- z();
102
+ if (K()) {
103
+ F();
81
104
  return;
82
105
  }
83
- if (K()) {
84
- R();
106
+ if (Z()) {
107
+ A();
85
108
  return;
86
109
  }
87
- if (me()) {
88
- M();
110
+ if (ve()) {
111
+ D();
89
112
  return;
90
113
  }
91
- if (pe()) {
92
- A();
114
+ if (we()) {
115
+ k();
93
116
  return;
94
117
  }
95
118
  r.onClose();
96
- }, k = (e) => {
119
+ }, V = (e) => {
97
120
  r.controller.setActiveTopicID(e);
98
- }, be = (e) => Bt(f().items, e), it = (e, t, o = P()?.topic_id) => {
121
+ }, De = (e) => Kt(p().items, e), ut = (e, t, o = I()?.topic_id) => {
99
122
  if (!o) return null;
100
- const n = g().find((u) => u.topic_id === o);
123
+ const n = g().find((f) => f.topic_id === o);
101
124
  if (!n) return null;
102
- const i = ne();
125
+ const i = ce();
103
126
  if (!i) return null;
104
- const l = i.getBoundingClientRect();
105
- if (l.width <= 0 || l.height <= 0 || e < l.left || e > l.right || t < l.top || t > l.bottom)
127
+ const s = i.getBoundingClientRect();
128
+ if (s.width <= 0 || s.height <= 0 || e < s.left || e > s.right || t < s.top || t > s.bottom)
106
129
  return null;
107
- const m = h();
130
+ const u = h();
108
131
  return {
109
132
  topicID: n.topic_id,
110
- worldX: (e - l.left - m.x) / m.scale,
111
- worldY: (t - l.top - m.y) / m.scale
133
+ worldX: (e - s.left - u.x) / u.scale,
134
+ worldY: (t - s.top - u.y) / u.scale
112
135
  };
113
- }, ct = (e, t) => {
136
+ }, pt = (e, t) => {
114
137
  if (typeof document > "u") return [];
115
138
  if (typeof document.elementsFromPoint == "function")
116
139
  return document.elementsFromPoint(e, t);
117
140
  const o = document.elementFromPoint(e, t);
118
141
  return o ? [o] : [];
119
- }, st = (e, t) => {
120
- const o = ct(e, t).filter((n) => n instanceof HTMLElement).map((n) => n.closest("[data-floe-notes-note-id]")).find(Boolean)?.dataset.floeNotesNoteId?.trim();
142
+ }, ft = (e, t) => {
143
+ const o = pt(e, t).filter((n) => n instanceof HTMLElement).map((n) => n.closest("[data-floe-notes-note-id]")).find(Boolean)?.dataset.floeNotesNoteId?.trim();
121
144
  if (o)
122
- return f().items.find((n) => n.note_id === o);
123
- }, Q = (e, t, o) => {
124
- const n = it(e, t, o?.topicID);
145
+ return p().items.find((n) => n.note_id === o);
146
+ }, te = (e, t, o) => {
147
+ const n = ut(e, t, o?.topicID);
125
148
  return n ? {
126
149
  clientX: e,
127
150
  clientY: t,
@@ -130,86 +153,86 @@ function eo(r) {
130
153
  topicID: n.topicID,
131
154
  noteID: o?.noteID ?? null
132
155
  } : null;
133
- }, _e = () => {
134
- const e = P();
156
+ }, Oe = () => {
157
+ const e = I();
135
158
  if (!e) return null;
136
- const t = V(_()), o = h();
159
+ const t = W(M()), o = h();
137
160
  return {
138
161
  topicID: e.topic_id,
139
162
  worldX: (t.width / 2 - o.x) / o.scale,
140
163
  worldY: (t.height / 2 - o.y) / o.scale
141
164
  };
142
- }, xe = (e, t, o) => {
143
- const n = Q(e, t, o);
165
+ }, Xe = (e, t, o) => {
166
+ const n = te(e, t, o);
144
167
  return n ? (d(n), !0) : !1;
145
- }, at = (e, t) => {
146
- const o = st(e, t);
168
+ }, mt = (e, t) => {
169
+ const o = ft(e, t);
147
170
  if (o) {
148
- B(o.note_id);
149
- const n = Q(e, t, {
171
+ j(o.note_id);
172
+ const n = te(e, t, {
150
173
  topicID: o.topic_id,
151
174
  noteID: o.note_id
152
175
  });
153
176
  d(n);
154
177
  return;
155
178
  }
156
- d(Q(e, t));
157
- }, De = (e) => {
158
- x(e), r.controller.setViewport(e), x(null);
159
- }, Pe = (e, t, o) => Vt({
179
+ d(te(e, t));
180
+ }, Se = (e) => {
181
+ b(e), r.controller.setViewport(e), b(null);
182
+ }, Ye = (e, t, o) => Zt({
160
183
  viewport: h(),
161
- frame: _(),
162
- bounds: L(),
184
+ frame: M(),
185
+ bounds: R(),
163
186
  worldX: e,
164
187
  worldY: t,
165
188
  scale: o
166
- }), Me = (e) => {
167
- const t = h(), o = V(_()), n = (o.width / 2 - t.x) / t.scale, i = (o.height / 2 - t.y) / t.scale, l = e === "in" ? t.scale * Fe : t.scale / Fe;
168
- De(Pe(n, i, l));
169
- }, Oe = (e, t, o) => {
189
+ }), Ee = (e) => {
190
+ const t = h(), o = W(M()), n = (o.width / 2 - t.x) / t.scale, i = (o.height / 2 - t.y) / t.scale, s = e === "in" ? t.scale * We : t.scale / We;
191
+ Se(Ye(n, i, s));
192
+ }, Le = (e, t, o) => {
170
193
  const n = o.surfaceRect;
171
194
  if (n.width <= 0 || n.height <= 0) return;
172
- const i = Ae(e, t, n), l = b(i.x - o.centerOffsetX, 0, 1), m = b(i.y - o.centerOffsetY, 0, 1), u = o.bounds;
173
- x(
174
- Pe(
175
- u.minX + l * u.width,
176
- u.minY + m * u.height
195
+ const i = je(e, t, n), s = _(i.x - o.centerOffsetX, 0, 1), u = _(i.y - o.centerOffsetY, 0, 1), f = o.bounds;
196
+ b(
197
+ Ye(
198
+ f.minX + s * f.width,
199
+ f.minY + u * f.height
177
200
  )
178
201
  );
179
- }, ee = (e) => {
180
- if (q?.abort(), q = void 0, e) {
181
- const t = ge();
202
+ }, oe = (e) => {
203
+ if (U?.abort(), U = void 0, e) {
204
+ const t = Ce();
182
205
  t && r.controller.setViewport(t);
183
206
  }
184
- x(null), Te(null);
185
- }, lt = (e) => {
207
+ b(null), xe(null);
208
+ }, wt = (e) => {
186
209
  if (e.button !== 0 && e.pointerType !== "touch" && e.pointerType !== "pen")
187
210
  return;
188
211
  const t = e.currentTarget, o = t.getBoundingClientRect();
189
212
  if (o.width <= 0 || o.height <= 0) return;
190
- const n = Ae(e.clientX, e.clientY, o), i = Ce(), l = n.x * 100, m = n.y * 100, u = l >= i.left && l <= i.left + i.width && m >= i.top && m <= i.top + i.height, N = {
213
+ const n = je(e.clientX, e.clientY, o), i = Me(), s = n.x * 100, u = n.y * 100, f = s >= i.left && s <= i.left + i.width && u >= i.top && u <= i.top + i.height, C = {
191
214
  pointerId: e.pointerId,
192
- bounds: L(),
215
+ bounds: R(),
193
216
  surfaceRect: o,
194
- centerOffsetX: u ? n.x - i.centerX / 100 : 0,
195
- centerOffsetY: u ? n.y - i.centerY / 100 : 0
217
+ centerOffsetX: f ? n.x - i.centerX / 100 : 0,
218
+ centerOffsetY: f ? n.y - i.centerY / 100 : 0
196
219
  };
197
- ee(!1), e.preventDefault(), e.stopPropagation(), Te(N), Oe(e.clientX, e.clientY, N), t.setPointerCapture?.(e.pointerId);
198
- const I = new AbortController();
199
- q = I;
200
- const oe = (w) => {
201
- w.pointerId === e.pointerId && Oe(w.clientX, w.clientY, N);
202
- }, O = (w) => {
203
- w.pointerId === e.pointerId && (t.hasPointerCapture?.(e.pointerId) && t.releasePointerCapture(e.pointerId), ee(!0));
220
+ oe(!1), e.preventDefault(), e.stopPropagation(), xe(C), Le(e.clientX, e.clientY, C), t.setPointerCapture?.(e.pointerId);
221
+ const N = new AbortController();
222
+ U = N;
223
+ const re = (v) => {
224
+ v.pointerId === e.pointerId && Le(v.clientX, v.clientY, C);
225
+ }, O = (v) => {
226
+ v.pointerId === e.pointerId && (t.hasPointerCapture?.(e.pointerId) && t.releasePointerCapture(e.pointerId), oe(!0));
204
227
  };
205
- t.addEventListener("pointermove", oe, { signal: I.signal }), t.addEventListener("pointerup", O, {
228
+ t.addEventListener("pointermove", re, { signal: N.signal }), t.addEventListener("pointerup", O, {
206
229
  once: !0,
207
- signal: I.signal
230
+ signal: N.signal
208
231
  }), t.addEventListener("pointercancel", O, {
209
232
  once: !0,
210
- signal: I.signal
233
+ signal: N.signal
211
234
  });
212
- }, Xe = async (e) => {
235
+ }, Re = async (e) => {
213
236
  try {
214
237
  const t = await r.controller.createNote({
215
238
  topic_id: e.topicID,
@@ -219,152 +242,153 @@ function eo(r) {
219
242
  });
220
243
  S(t.note_id);
221
244
  } catch (t) {
222
- s.error("Create failed", p(t));
245
+ a.error("Create failed", m(t));
223
246
  }
224
- }, Se = async (e, t) => {
247
+ }, ze = async (e, t) => {
225
248
  try {
226
249
  await r.controller.createNote({
227
250
  topic_id: e.topicID,
228
251
  x: e.worldX,
229
252
  y: e.worldY,
230
253
  body: t
231
- }), s.success("Pasted", "Created a new note from clipboard text.");
254
+ }), a.success("Pasted", "Created a new note from clipboard text.");
232
255
  } catch (o) {
233
- s.error("Paste failed", p(o));
256
+ a.error("Paste failed", m(o));
234
257
  }
235
- }, Ye = (e) => {
236
- j(""), we(e);
237
- }, Ee = async (e) => {
258
+ }, Ae = (e) => {
259
+ G(""), ge(e);
260
+ }, Fe = async (e) => {
238
261
  try {
239
262
  const t = await navigator.clipboard.readText();
240
263
  if (!t.trim()) {
241
- s.info("Clipboard empty", "Paste text into the dialog to create a note."), Ye(e);
264
+ a.info("Clipboard empty", "Paste text into the dialog to create a note."), Ae(e);
242
265
  return;
243
266
  }
244
- await Se(e, t);
267
+ await ze(e, t);
245
268
  } catch {
246
- s.info("Clipboard blocked", "Manual paste is available as a fallback."), Ye(e);
269
+ a.info("Clipboard blocked", "Manual paste is available as a fallback."), Ae(e);
247
270
  }
248
- }, dt = (e) => {
249
- U(), Y(e), D = window.setTimeout(() => {
250
- D = void 0, Y((t) => t === e ? null : t);
271
+ }, ht = (e) => {
272
+ Q(), Y(e), P = window.setTimeout(() => {
273
+ P = void 0, Y((t) => t === e ? null : t);
251
274
  }, 1100);
252
- }, ut = (e) => {
275
+ }, vt = (e) => {
253
276
  y(e);
254
- }, B = (e) => {
277
+ }, j = (e) => {
255
278
  y(e), Promise.resolve(r.controller.bringNoteToFront(e)).catch((t) => {
256
- s.error("Bring forward failed", p(t)), y((o) => o === e ? null : o);
279
+ a.error("Bring forward failed", m(t)), y((o) => o === e ? null : o);
257
280
  });
258
- }, pt = (e) => {
281
+ }, Tt = (e) => {
259
282
  d(null), S(e);
260
- }, ft = async (e) => {
283
+ }, gt = async (e) => {
261
284
  if (!e.body.trim()) {
262
285
  d(null), S(e.note_id);
263
286
  return;
264
287
  }
265
288
  try {
266
- B(e.note_id), await navigator.clipboard.writeText(e.body), dt(e.note_id);
289
+ j(e.note_id), await navigator.clipboard.writeText(e.body), ht(e.note_id);
267
290
  } catch {
268
- s.error("Copy failed", "Clipboard write was not available.");
291
+ a.error("Copy failed", "Clipboard write was not available.");
269
292
  }
270
- }, Le = async (e) => {
293
+ }, ke = async (e) => {
271
294
  try {
272
- await r.controller.deleteNote(e), U(), Y((t) => t === e ? null : t), J();
295
+ z(e), await r.controller.deleteNote(e), Q(), Y((t) => t === e ? null : t), ee();
273
296
  } catch (t) {
274
- s.error("Delete failed", p(t));
297
+ a.error("Delete failed", m(t));
275
298
  }
276
- }, mt = async (e) => {
299
+ }, yt = async (e) => {
277
300
  try {
278
- await r.controller.restoreNote(e);
301
+ z(e), await r.controller.restoreNote(e);
279
302
  } catch (t) {
280
- s.error("Restore failed", p(t));
303
+ a.error("Restore failed", m(t));
281
304
  }
282
- }, ht = async (e) => {
305
+ }, xt = async (e) => {
283
306
  if (r.controller.deleteTrashedNotePermanently)
284
307
  try {
285
- await r.controller.deleteTrashedNotePermanently(e);
308
+ z(e), await r.controller.deleteTrashedNotePermanently(e);
286
309
  } catch (t) {
287
- s.error("Delete failed", p(t));
310
+ a.error("Delete failed", m(t));
288
311
  }
289
- }, wt = async (e) => {
312
+ }, Ct = async (e) => {
290
313
  try {
291
314
  await r.controller.clearTrashTopic(e);
292
315
  } catch (t) {
293
- s.error("Trash failed", p(t));
316
+ a.error("Trash failed", m(t));
294
317
  }
295
- }, vt = async () => {
296
- const e = $();
318
+ }, Nt = async () => {
319
+ const e = K();
297
320
  if (e)
298
321
  try {
299
322
  await r.controller.updateNote(e, {
300
- body: ae(),
301
- color_token: de()
302
- }), s.success("Saved", "Note updated."), z();
323
+ body: ue(),
324
+ color_token: fe()
325
+ }), a.success("Saved", "Note updated."), F();
303
326
  } catch (t) {
304
- s.error("Save failed", p(t));
327
+ a.error("Save failed", m(t));
305
328
  }
306
- }, Tt = async () => {
307
- const e = K();
308
- !e || !Z().trim() || (await Se(e, Z()), R());
309
- }, gt = async () => {
310
- const e = re().trim();
329
+ }, _t = async () => {
330
+ const e = Z();
331
+ !e || !q().trim() || (await ze(e, q()), A());
332
+ }, Mt = async () => {
333
+ const e = se().trim();
311
334
  if (e)
312
335
  try {
313
336
  const t = await r.controller.createTopic({ name: e });
314
- ie(""), k(t.topic_id);
337
+ ae(""), V(t.topic_id);
315
338
  } catch (t) {
316
- s.error("Topic failed", p(t));
339
+ a.error("Topic failed", m(t));
317
340
  }
318
- }, yt = (e) => {
319
- ce(e.topic_id), H(e.name);
320
- }, Ct = async () => {
321
- const e = W();
341
+ }, bt = (e) => {
342
+ le(e.topic_id), $(e.name);
343
+ }, Pt = async () => {
344
+ const e = H();
322
345
  if (!e) return;
323
- const t = se().trim();
324
- if (F(), !!t)
346
+ const t = de().trim();
347
+ if (B(), !!t)
325
348
  try {
326
349
  await r.controller.updateTopic(e, { name: t });
327
350
  } catch (o) {
328
- s.error("Rename failed", p(o));
351
+ a.error("Rename failed", m(o));
329
352
  }
330
- }, Nt = async (e) => {
331
- const t = be(e.topic_id) + kt(f().trash_items, e.topic_id);
332
- W() === e.topic_id && F();
353
+ }, It = async (e) => {
354
+ const t = De(e.topic_id) + $t(p().trash_items, e.topic_id);
355
+ H() === e.topic_id && B();
333
356
  try {
334
357
  if (await r.controller.deleteTopic(e.topic_id) === !1) {
335
- s.info(
358
+ a.info(
336
359
  "Keep one topic",
337
360
  "At least one topic needs to remain available."
338
361
  );
339
362
  return;
340
363
  }
341
364
  if (t > 0) {
342
- J(), s.success(
365
+ ee(), a.success(
343
366
  "Topic deleted",
344
367
  "Live notes moved into trash for this topic."
345
368
  );
346
369
  return;
347
370
  }
348
- s.success("Topic deleted", "The empty topic was removed.");
371
+ a.success("Topic deleted", "The empty topic was removed.");
349
372
  } catch (o) {
350
- s.error("Delete failed", p(o));
373
+ a.error("Delete failed", m(o));
351
374
  }
352
- }, It = async (e, t) => {
375
+ }, Dt = async (e, t) => {
376
+ Pe(e, t);
353
377
  try {
354
378
  await r.controller.updateNote(e, {
355
379
  x: t.x,
356
380
  y: t.y
357
381
  });
358
382
  } catch (o) {
359
- s.error("Move failed", p(o));
383
+ z(e), a.error("Move failed", m(o));
360
384
  }
361
- }, bt = async () => {
362
- const e = _e();
363
- e && (M(), await Xe(e));
364
- }, _t = async () => {
365
- const e = _e();
366
- e && (M(), await Ee(e));
367
- }, te = c(() => {
385
+ }, Ot = async () => {
386
+ const e = Oe();
387
+ e && (D(), await Re(e));
388
+ }, Xt = async () => {
389
+ const e = Oe();
390
+ e && (D(), await Fe(e));
391
+ }, ne = c(() => {
368
392
  const e = T();
369
393
  if (!e) return [];
370
394
  const t = [
@@ -372,20 +396,20 @@ function eo(r) {
372
396
  id: "paste",
373
397
  kind: "action",
374
398
  label: "Paste here",
375
- icon: Xt,
399
+ icon: zt,
376
400
  onSelect: () => {
377
401
  const o = T();
378
- o && (d(null), Ee(o));
402
+ o && (d(null), Fe(o));
379
403
  }
380
404
  },
381
405
  {
382
406
  id: "new",
383
407
  kind: "action",
384
408
  label: "New note",
385
- icon: St,
409
+ icon: At,
386
410
  onSelect: () => {
387
411
  const o = T();
388
- o && (d(null), Xe(o));
412
+ o && (d(null), Re(o));
389
413
  }
390
414
  }
391
415
  ];
@@ -393,25 +417,25 @@ function eo(r) {
393
417
  id: "delete",
394
418
  kind: "action",
395
419
  label: "Delete",
396
- icon: Yt,
420
+ icon: Ft,
397
421
  destructive: !0,
398
422
  onSelect: () => {
399
423
  const o = T();
400
- o?.noteID && (d(null), Le(o.noteID));
424
+ o?.noteID && (d(null), ke(o.noteID));
401
425
  }
402
426
  })), t;
403
- }), xt = c(() => {
427
+ }), St = c(() => {
404
428
  const e = T();
405
429
  if (!e) return;
406
- const t = te().filter((n) => n.kind === "action").length, o = te().filter((n) => n.kind === "separator").length;
407
- return At({
430
+ const t = ne().filter((n) => n.kind === "action").length, o = ne().filter((n) => n.kind === "separator").length;
431
+ return Wt({
408
432
  clientX: e.clientX,
409
433
  clientY: e.clientY,
410
- menuWidth: Et,
411
- menuHeight: Lt(t, o)
434
+ menuWidth: kt,
435
+ menuHeight: Bt(t, o)
412
436
  });
413
- }), Dt = (e) => {
414
- const t = P();
437
+ }), Yt = (e) => {
438
+ const t = I();
415
439
  t && d({
416
440
  clientX: e.clientX,
417
441
  clientY: e.clientY,
@@ -419,52 +443,61 @@ function eo(r) {
419
443
  worldY: e.worldY,
420
444
  topicID: t.topic_id
421
445
  });
422
- }, Pt = (e, t) => {
423
- B(t.note_id), xe(e.clientX, e.clientY, {
446
+ }, Et = (e, t) => {
447
+ j(t.note_id), Xe(e.clientX, e.clientY, {
424
448
  topicID: t.topic_id,
425
449
  noteID: t.note_id
426
450
  });
427
- }, Mt = (e) => {
428
- A(), xe(e.clientX, e.clientY);
429
- }, Ot = (e) => {
430
- e.preventDefault(), e.stopPropagation(), at(e.clientX, e.clientY);
451
+ }, Lt = (e) => {
452
+ k(), Xe(e.clientX, e.clientY);
453
+ }, Rt = (e) => {
454
+ e.preventDefault(), e.stopPropagation(), mt(e.clientX, e.clientY);
431
455
  };
432
- return v(() => {
433
- r.open || (nt(), F(), x(null), y(null), Y(null));
434
- }), v(() => {
435
- const e = C();
436
- e && r.controller.activeTopicID() !== e && k(e);
437
- }), v(() => {
438
- const e = Ne();
456
+ return w(() => {
457
+ r.open || (lt(), B(), b(null), y(null), Y(null));
458
+ }), w(() => {
459
+ const e = x();
460
+ e && r.controller.activeTopicID() !== e && V(e);
461
+ }), w(() => {
462
+ const e = be();
439
463
  if (!e) {
440
- G = null;
464
+ J = null;
441
465
  return;
442
466
  }
443
- G !== e.note_id && (G = e.note_id, le(e.body), ue(e.color_token));
444
- }), v(() => {
445
- const e = ve();
467
+ J !== e.note_id && (J = e.note_id, pe(e.body), me(e.color_token));
468
+ }), w(() => {
469
+ const e = ye();
446
470
  if (!e) return;
447
- const t = f().items.find((n) => n.note_id === e);
471
+ const t = p().items.find((n) => n.note_id === e);
448
472
  if (!t) {
449
473
  y(null);
450
474
  return;
451
475
  }
452
- const o = f().items.reduce(
476
+ const o = p().items.reduce(
453
477
  (n, i) => Math.max(n, i.z_index),
454
478
  0
455
479
  );
456
480
  t.z_index >= o && y(null);
457
- }), v(() => {
481
+ }), w(() => {
482
+ const e = p().items, t = Ne();
483
+ if (t.size === 0) return;
484
+ let o = null;
485
+ for (const [n, i] of t) {
486
+ const s = e.find((u) => u.note_id === n);
487
+ (!s || ie({ x: s.x, y: s.y }, i)) && (o ??= new Map(t), o.delete(n));
488
+ }
489
+ o && E(o);
490
+ }), w(() => {
458
491
  if (!r.open) return;
459
492
  const e = () => {
460
- Ke(window.innerWidth < Ft);
493
+ Ue(window.innerWidth < Ht);
461
494
  };
462
495
  e(), window.addEventListener("resize", e), X(() => window.removeEventListener("resize", e));
463
- }), v(() => {
464
- const e = ne();
496
+ }), w(() => {
497
+ const e = ce();
465
498
  if (!e) return;
466
499
  const t = () => {
467
- Be({
500
+ $e({
468
501
  width: e.clientWidth,
469
502
  height: e.clientHeight
470
503
  });
@@ -475,113 +508,114 @@ function eo(r) {
475
508
  }
476
509
  const o = new ResizeObserver(t);
477
510
  o.observe(e), X(() => o.disconnect());
478
- }), v(() => {
511
+ }), w(() => {
479
512
  if (!r.open) return;
480
- const e = window.setInterval(() => He(Date.now()), 60 * 1e3);
513
+ const e = window.setInterval(() => qe(Date.now()), 60 * 1e3);
481
514
  X(() => window.clearInterval(e));
482
- }), v(() => {
483
- C() && d(null);
515
+ }), w(() => {
516
+ x() && d(null);
484
517
  }), X(() => {
485
- U(), ee(!1);
518
+ Q(), oe(!1);
486
519
  }), {
487
520
  header: {
488
- topicCount: je,
489
- totalLiveNotes: Ge,
490
- trashCount: ye
521
+ topicCount: Qe,
522
+ totalLiveNotes: ot,
523
+ trashCount: _e
491
524
  },
492
525
  rail: {
493
526
  topics: g,
494
- activeTopicID: C,
495
- draftTopicTitle: re,
496
- renamingTopicID: W,
497
- renamingTopicTitle: se,
498
- getLiveNoteCount: be,
499
- setDraftTopicTitle: ie,
500
- submitTopic: gt,
501
- selectTopic: k,
502
- startTopicRename: yt,
503
- setRenamingTopicTitle: H,
504
- saveTopicRename: Ct,
505
- cancelTopicRename: F,
506
- deleteTopic: Nt
527
+ activeTopicID: x,
528
+ draftTopicTitle: se,
529
+ renamingTopicID: H,
530
+ renamingTopicTitle: de,
531
+ getLiveNoteCount: De,
532
+ setDraftTopicTitle: ae,
533
+ submitTopic: Mt,
534
+ selectTopic: V,
535
+ startTopicRename: bt,
536
+ setRenamingTopicTitle: $,
537
+ saveTopicRename: Pt,
538
+ cancelTopicRename: B,
539
+ deleteTopic: It
507
540
  },
508
541
  board: {
509
- activeTopic: P,
510
- activeTopicLabel: Je,
511
- activeItems: E,
512
- activeTopicID: C,
542
+ activeTopic: I,
543
+ activeTopicLabel: rt,
544
+ activeItems: L,
545
+ activeTopicID: x,
513
546
  topics: g,
514
- topZIndex: Ue,
547
+ topZIndex: nt,
515
548
  viewport: h,
516
- boardScaleLabel: Qe,
517
- isMobile: $e,
518
- overviewOpen: me,
519
- optimisticFrontNoteID: ve,
520
- copiedNoteID: Ve,
521
- setCanvasFrameRef: ke,
522
- commitViewport: De,
523
- openCanvasContextMenu: Dt,
524
- zoomOut: () => Me("out"),
525
- zoomIn: () => Me("in"),
549
+ boardScaleLabel: it,
550
+ isMobile: Ge,
551
+ overviewOpen: ve,
552
+ optimisticFrontNoteID: ye,
553
+ copiedNoteID: Ke,
554
+ setCanvasFrameRef: He,
555
+ commitViewport: Se,
556
+ openCanvasContextMenu: Yt,
557
+ zoomOut: () => Ee("out"),
558
+ zoomIn: () => Ee("in"),
526
559
  openOverview: Ie,
527
- selectTopic: k,
528
- mobileCreateNote: bt,
529
- mobilePaste: _t,
530
- copyNote: ft,
531
- openNoteContextMenu: Pt,
532
- openEditor: pt,
533
- moveToTrash: Le,
534
- startOptimisticFront: ut,
535
- commitFront: B,
536
- commitMove: It
560
+ selectTopic: V,
561
+ mobileCreateNote: Ot,
562
+ mobilePaste: Xt,
563
+ seedMoveProjection: Pe,
564
+ copyNote: gt,
565
+ openNoteContextMenu: Et,
566
+ openEditor: Tt,
567
+ moveToTrash: ke,
568
+ startOptimisticFront: vt,
569
+ commitFront: j,
570
+ commitMove: Dt
537
571
  },
538
572
  overview: {
539
- items: tt,
540
- viewportStyle: ot,
541
- navigationState: Ze,
542
- beginNavigation: lt,
543
- close: M,
573
+ items: st,
574
+ viewportStyle: at,
575
+ navigationState: Je,
576
+ beginNavigation: wt,
577
+ close: D,
544
578
  open: Ie
545
579
  },
546
580
  trash: {
547
- open: pe,
548
- groups: qe,
549
- count: ye,
550
- now: We,
581
+ open: we,
582
+ groups: tt,
583
+ count: _e,
584
+ now: Ze,
551
585
  canDeleteNow: !!r.controller.deleteTrashedNotePermanently,
552
- close: A,
553
- openDock: J,
554
- backdropContextMenu: Mt,
555
- restore: mt,
556
- deleteNow: ht,
557
- clearTopic: wt
586
+ close: k,
587
+ openDock: ee,
588
+ backdropContextMenu: Lt,
589
+ restore: yt,
590
+ deleteNow: xt,
591
+ clearTopic: Ct
558
592
  },
559
593
  contextMenu: {
560
594
  state: T,
561
- items: te,
562
- position: xt,
595
+ items: ne,
596
+ position: St,
563
597
  close: () => d(null),
564
- retarget: Ot
598
+ retarget: Rt
565
599
  },
566
600
  editor: {
567
- note: Ne,
568
- draftBody: ae,
569
- draftColor: de,
570
- setDraftBody: le,
571
- setDraftColor: ue,
572
- close: z,
573
- save: vt
601
+ note: be,
602
+ draftBody: ue,
603
+ draftColor: fe,
604
+ setDraftBody: pe,
605
+ setDraftColor: me,
606
+ close: F,
607
+ save: Nt
574
608
  },
575
609
  manualPaste: {
576
- open: () => !!K(),
577
- text: Z,
578
- setText: j,
579
- close: R,
580
- confirm: Tt
610
+ open: () => !!Z(),
611
+ text: q,
612
+ setText: G,
613
+ close: A,
614
+ confirm: _t
581
615
  },
582
- handleCloseRequest: rt
616
+ handleCloseRequest: dt
583
617
  };
584
618
  }
585
619
  export {
586
- eo as useNotesOverlayModel
620
+ co as useNotesOverlayModel
587
621
  };