@floegence/floe-webapp-core 0.35.52 → 0.35.53

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