@floegence/floe-webapp-core 0.35.40 → 0.35.41

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.
@@ -0,0 +1,4 @@
1
+ export { NotesOverlay, type NotesOverlayProps } from './NotesOverlay';
2
+ export { NotesContextMenu, estimateNotesContextMenuHeight, NOTES_CONTEXT_MENU_WIDTH_PX, type NotesContextMenuItem } from './NotesContextMenu';
3
+ export { NOTE_COLOR_LABELS, TOPIC_ACCENT_LABELS, NotesAnimalIcon, NotesOverlayIcon, NotesTrashCanIcon, } from './notesAppearance';
4
+ export * from './types';
@@ -0,0 +1,14 @@
1
+ import { type JSX } from 'solid-js';
2
+ import type { NoteColorToken, TopicAccentToken, TopicIconKey } from './types';
3
+ export declare const NOTE_COLOR_LABELS: Readonly<Record<NoteColorToken, string>>;
4
+ export declare const TOPIC_ACCENT_LABELS: Readonly<Record<TopicAccentToken, string>>;
5
+ export declare function NotesOverlayIcon(props: {
6
+ class?: string;
7
+ }): JSX.Element;
8
+ export declare function NotesTrashCanIcon(props: {
9
+ class?: string;
10
+ }): JSX.Element;
11
+ export declare function NotesAnimalIcon(props: {
12
+ iconKey: TopicIconKey;
13
+ class?: string;
14
+ }): JSX.Element;
@@ -0,0 +1,142 @@
1
+ import { createComponent as r, effect as a, setAttribute as n, template as h } from "solid-js/web";
2
+ import { Switch as s, Match as o } from "solid-js";
3
+ var c = /* @__PURE__ */ h('<svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=1.75 stroke-linecap=round stroke-linejoin=round><path d="M6.25 5.5h11.5"></path><path d="M7.75 3.75v3.5"></path><path d="M12 3.75v3.5"></path><path d="M16.25 3.75v3.5"></path><rect x=4.5 y=7.5 width=15 height=12 rx=2.25></rect><path d="M8 12.25h8"></path><path d="M8 15.5h5.75">'), l = /* @__PURE__ */ h('<svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=1.75 stroke-linecap=round stroke-linejoin=round><path d="M8 5.25h8"></path><path d="M10 3.5h4"></path><path d="M6.5 6.75h11"></path><path d="M7.25 7.25v10.25c0 1.1.9 2 2 2h5.5c1.1 0 2-.9 2-2V7.25"></path><path d="M9.75 10.25v6"></path><path d="M14.25 10.25v6"></path><path d="M5 19.75h14"opacity=0.45>'), p = /* @__PURE__ */ h('<svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=1.65 stroke-linecap=round stroke-linejoin=round><path d="m6 9.75 2.2-4.25 2.3 2.6"></path><path d="m18 9.75-2.2-4.25-2.3 2.6"></path><path d="M6.35 10.25c.2 5.2 2.95 8.25 5.65 8.25s5.45-3.05 5.65-8.25c-1.4-1.2-3.3-1.9-5.65-1.9s-4.25.7-5.65 1.9Z"></path><path d="M9.8 13.35h.01"></path><path d="M14.2 13.35h.01"></path><path d="M10.5 16.05c.6.45 1.2.65 1.5.65s.9-.2 1.5-.65">'), d = /* @__PURE__ */ h('<svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=1.65 stroke-linecap=round stroke-linejoin=round><path d="M8.5 16.75c0-3.2 1.2-5.9 3.6-8.4"></path><path d="M12.1 8.35c.55-2.25 1.65-3.7 3.4-4.85"></path><path d="M14.5 4.1 19.5 5.7 15 7.55"></path><path d="M8.5 16.75c0 1.55 1.2 2.75 2.75 2.75 2.55 0 4.75-1.15 6.25-3.35"></path><path d="M12 11.9c1.45.3 2.6 1.15 3.6 2.6"></path><path d="M7.5 20.5h4.5">'), i = /* @__PURE__ */ h('<svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=1.65 stroke-linecap=round stroke-linejoin=round><path d="M7.5 9.25 6.2 6.6 8.75 7.45"></path><path d="M16.5 9.25 17.8 6.6 15.25 7.45"></path><path d="M6.25 12.2c0-3.2 2.6-5.7 5.75-5.7s5.75 2.5 5.75 5.7c0 3.45-2.35 6.55-5.75 6.55s-5.75-3.1-5.75-6.55Z"></path><path d="M9.55 12.5h.01"></path><path d="M14.45 12.5h.01"></path><path d="M10 15.1c.7.55 1.35.8 2 .8s1.3-.25 2-.8"></path><path d="M8.75 17.5c.2 1.05 1.05 2 3.25 2s3.05-.95 3.25-2">'), u = /* @__PURE__ */ h('<svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=1.65 stroke-linecap=round stroke-linejoin=round><path d="m7.4 9.4-.85-4 2.55 2.3"></path><path d="m16.6 9.4.85-4-2.55 2.3"></path><path d="M6.7 10.4c.25 5.05 2.55 8.1 5.3 8.1s5.05-3.05 5.3-8.1c-1.35-1.3-3.1-2.05-5.3-2.05s-3.95.75-5.3 2.05Z"></path><path d="M9.6 12.95h.01"></path><path d="M14.4 12.95h.01"></path><path d="M10.15 16.1c.55.45 1.15.65 1.85.65s1.3-.2 1.85-.65"></path><path d="M8.25 18.1 6.5 19.85"></path><path d="M15.75 18.1 17.5 19.85">'), M = /* @__PURE__ */ h('<svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=1.65 stroke-linecap=round stroke-linejoin=round><path d="M4.5 14.25c0-3.65 2.75-6.25 7.25-6.25 2.9 0 5.8 1.05 7.75 3.35"></path><path d="M19.5 11.35c0 4.4-3.15 7.15-7.65 7.15-3.75 0-6.75-1.8-7.35-4.9 1.3.8 2.7 1.15 4.15 1.15 1.9 0 3.15-.45 4.45-1.6.75-.65 1.55-1 2.35-1 .8 0 1.45.25 2.25.85l1.8-1.05Z"></path><path d="M9.5 10.4h.01"></path><path d="M16.2 7.55c-.35-1.55-1.15-2.75-2.45-4.05">'), k = /* @__PURE__ */ h('<svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=1.65 stroke-linecap=round stroke-linejoin=round><path d="M9.5 9.4c-1.05-2.25-1.2-4.25-.7-6.4 1.45.6 2.2 1.8 2.7 3.6"></path><path d="M14.5 9.4c.35-2.4 1.3-4.5 3.3-5.9.55 2.6.1 4.5-1.2 6.15"></path><path d="M7 11.25c0-2.35 2.25-4.25 5-4.25s5 1.9 5 4.25c0 4.1-1.7 7.25-5 7.25S7 15.35 7 11.25Z"></path><path d="M9.8 12.7h.01"></path><path d="M14.2 12.7h.01"></path><path d="M10.35 15.85c.55.45 1.05.65 1.65.65s1.1-.2 1.65-.65">');
4
+ const x = Object.freeze({
5
+ graphite: "Graphite",
6
+ sage: "Sage",
7
+ amber: "Amber",
8
+ azure: "Azure",
9
+ coral: "Coral",
10
+ rose: "Rose"
11
+ }), y = Object.freeze({
12
+ ember: "Ember",
13
+ sea: "Sea",
14
+ moss: "Moss",
15
+ ink: "Ink",
16
+ gold: "Gold",
17
+ berry: "Berry"
18
+ });
19
+ function B(t) {
20
+ return (() => {
21
+ var e = c();
22
+ return a(() => n(e, "class", t.class)), e;
23
+ })();
24
+ }
25
+ function I(t) {
26
+ return (() => {
27
+ var e = l();
28
+ return a(() => n(e, "class", t.class)), e;
29
+ })();
30
+ }
31
+ function v(t) {
32
+ return (() => {
33
+ var e = p();
34
+ return a(() => n(e, "class", t.class)), e;
35
+ })();
36
+ }
37
+ function g(t) {
38
+ return (() => {
39
+ var e = d();
40
+ return a(() => n(e, "class", t.class)), e;
41
+ })();
42
+ }
43
+ function f(t) {
44
+ return (() => {
45
+ var e = i();
46
+ return a(() => n(e, "class", t.class)), e;
47
+ })();
48
+ }
49
+ function m(t) {
50
+ return (() => {
51
+ var e = u();
52
+ return a(() => n(e, "class", t.class)), e;
53
+ })();
54
+ }
55
+ function w(t) {
56
+ return (() => {
57
+ var e = M();
58
+ return a(() => n(e, "class", t.class)), e;
59
+ })();
60
+ }
61
+ function _(t) {
62
+ return (() => {
63
+ var e = k();
64
+ return a(() => n(e, "class", t.class)), e;
65
+ })();
66
+ }
67
+ function N(t) {
68
+ return r(s, {
69
+ get fallback() {
70
+ return r(v, {
71
+ get class() {
72
+ return t.class;
73
+ }
74
+ });
75
+ },
76
+ get children() {
77
+ return [r(o, {
78
+ get when() {
79
+ return t.iconKey === "crane";
80
+ },
81
+ get children() {
82
+ return r(g, {
83
+ get class() {
84
+ return t.class;
85
+ }
86
+ });
87
+ }
88
+ }), r(o, {
89
+ get when() {
90
+ return t.iconKey === "otter";
91
+ },
92
+ get children() {
93
+ return r(f, {
94
+ get class() {
95
+ return t.class;
96
+ }
97
+ });
98
+ }
99
+ }), r(o, {
100
+ get when() {
101
+ return t.iconKey === "lynx";
102
+ },
103
+ get children() {
104
+ return r(m, {
105
+ get class() {
106
+ return t.class;
107
+ }
108
+ });
109
+ }
110
+ }), r(o, {
111
+ get when() {
112
+ return t.iconKey === "whale";
113
+ },
114
+ get children() {
115
+ return r(w, {
116
+ get class() {
117
+ return t.class;
118
+ }
119
+ });
120
+ }
121
+ }), r(o, {
122
+ get when() {
123
+ return t.iconKey === "hare";
124
+ },
125
+ get children() {
126
+ return r(_, {
127
+ get class() {
128
+ return t.class;
129
+ }
130
+ });
131
+ }
132
+ })];
133
+ }
134
+ });
135
+ }
136
+ export {
137
+ x as NOTE_COLOR_LABELS,
138
+ N as NotesAnimalIcon,
139
+ B as NotesOverlayIcon,
140
+ I as NotesTrashCanIcon,
141
+ y as TOPIC_ACCENT_LABELS
142
+ };
@@ -0,0 +1,148 @@
1
+ import type { Accessor } from 'solid-js';
2
+ export type NoteColorToken = 'graphite' | 'sage' | 'amber' | 'azure' | 'coral' | 'rose';
3
+ export type TopicIconKey = 'fox' | 'crane' | 'otter' | 'lynx' | 'whale' | 'hare';
4
+ export type TopicAccentToken = 'ember' | 'sea' | 'moss' | 'ink' | 'gold' | 'berry';
5
+ export type NotesSizeBucket = 1 | 2 | 3 | 4 | 5;
6
+ export type NotesConnectionState = 'idle' | 'live' | 'reconnecting';
7
+ export type NotesTopic = Readonly<{
8
+ topic_id: string;
9
+ name: string;
10
+ icon_key: TopicIconKey;
11
+ icon_accent: TopicAccentToken;
12
+ sort_order: number;
13
+ created_at_unix_ms: number;
14
+ updated_at_unix_ms: number;
15
+ deleted_at_unix_ms: number;
16
+ }>;
17
+ export type NotesItem = Readonly<{
18
+ note_id: string;
19
+ topic_id: string;
20
+ body: string;
21
+ preview_text: string;
22
+ character_count: number;
23
+ size_bucket: NotesSizeBucket;
24
+ style_version: string;
25
+ color_token: NoteColorToken;
26
+ x: number;
27
+ y: number;
28
+ z_index: number;
29
+ created_at_unix_ms: number;
30
+ updated_at_unix_ms: number;
31
+ }>;
32
+ export type NotesTrashItem = Readonly<NotesItem & {
33
+ topic_name: string;
34
+ topic_icon_key: TopicIconKey;
35
+ topic_icon_accent: TopicAccentToken;
36
+ topic_sort_order: number;
37
+ deleted_at_unix_ms: number;
38
+ }>;
39
+ export type NotesSnapshot = Readonly<{
40
+ seq: number;
41
+ retention_hours: number;
42
+ topics: NotesTopic[];
43
+ items: NotesItem[];
44
+ trash_items: NotesTrashItem[];
45
+ }>;
46
+ export type NotesEvent = Readonly<{
47
+ seq: number;
48
+ type: string;
49
+ entity_kind: string;
50
+ entity_id: string;
51
+ topic_id?: string;
52
+ created_at_unix_ms: number;
53
+ payload?: Record<string, unknown> | null;
54
+ }>;
55
+ export type NotesViewport = Readonly<{
56
+ x: number;
57
+ y: number;
58
+ scale: number;
59
+ }>;
60
+ export type NotesPoint = Readonly<{
61
+ x: number;
62
+ y: number;
63
+ }>;
64
+ export type NotesRect = Readonly<{
65
+ minX: number;
66
+ minY: number;
67
+ maxX: number;
68
+ maxY: number;
69
+ }>;
70
+ export type NotesTrashGroup = Readonly<{
71
+ topic_id: string;
72
+ topic_name: string;
73
+ topic_icon_key: TopicIconKey;
74
+ topic_icon_accent: TopicAccentToken;
75
+ topic_sort_order: number;
76
+ latest_deleted_at_unix_ms: number;
77
+ items: NotesTrashItem[];
78
+ }>;
79
+ export type NotesItemMetrics = Readonly<{
80
+ width: number;
81
+ height: number;
82
+ preview_lines: number;
83
+ }>;
84
+ export type NotesCreateTopicInput = Readonly<{
85
+ name: string;
86
+ }>;
87
+ export type NotesUpdateTopicInput = Readonly<{
88
+ name: string;
89
+ }>;
90
+ export type NotesCreateNoteInput = Readonly<{
91
+ topic_id: string;
92
+ body: string;
93
+ color_token?: NoteColorToken;
94
+ x: number;
95
+ y: number;
96
+ }>;
97
+ export type NotesUpdateNoteInput = Readonly<{
98
+ body?: string;
99
+ color_token?: NoteColorToken;
100
+ x?: number;
101
+ y?: number;
102
+ }>;
103
+ type MaybePromise<T> = T | Promise<T>;
104
+ export interface NotesController {
105
+ snapshot: Accessor<NotesSnapshot>;
106
+ activeTopicID: Accessor<string>;
107
+ setActiveTopicID: (topicID: string) => void;
108
+ viewport: Accessor<NotesViewport>;
109
+ setViewport: (viewport: NotesViewport) => void;
110
+ loading?: Accessor<boolean>;
111
+ connectionState?: Accessor<NotesConnectionState>;
112
+ createTopic: (input: NotesCreateTopicInput) => MaybePromise<NotesTopic>;
113
+ updateTopic: (topicID: string, input: NotesUpdateTopicInput) => MaybePromise<NotesTopic>;
114
+ deleteTopic: (topicID: string) => MaybePromise<boolean | void>;
115
+ createNote: (input: NotesCreateNoteInput) => MaybePromise<NotesItem>;
116
+ updateNote: (noteID: string, input: NotesUpdateNoteInput) => MaybePromise<NotesItem>;
117
+ bringNoteToFront: (noteID: string) => MaybePromise<NotesItem | void>;
118
+ deleteNote: (noteID: string) => MaybePromise<void>;
119
+ restoreNote: (noteID: string) => MaybePromise<NotesItem>;
120
+ clearTrashTopic: (topicID: string) => MaybePromise<void>;
121
+ }
122
+ export declare const NOTES_SCALE_MIN = 0.42;
123
+ export declare const NOTES_SCALE_MAX = 2.1;
124
+ export declare const NOTE_COLOR_TOKENS: readonly ["graphite", "sage", "amber", "azure", "coral", "rose"];
125
+ export declare const TOPIC_ICON_KEYS: readonly ["fox", "crane", "otter", "lynx", "whale", "hare"];
126
+ export declare const TOPIC_ACCENT_TOKENS: readonly ["ember", "sea", "moss", "ink", "gold", "berry"];
127
+ export declare const NOTE_BUCKET_METRICS: Readonly<Record<NotesSizeBucket, NotesItemMetrics>>;
128
+ export declare function noteBucketMetrics(bucket: number): NotesItemMetrics;
129
+ export declare function createDefaultNotesSnapshot(): NotesSnapshot;
130
+ export declare function normalizeNotesSnapshot(snapshot: NotesSnapshot): NotesSnapshot;
131
+ export declare function clampScale(scale: number): number;
132
+ export declare function worldToScreen(viewport: NotesViewport, world: NotesPoint): NotesPoint;
133
+ export declare function screenToWorld(viewport: NotesViewport, point: NotesPoint): NotesPoint;
134
+ export declare function visibleWorldRect(viewport: NotesViewport, width: number, height: number): NotesRect;
135
+ export declare function zoomViewportAtPoint(viewport: NotesViewport, requestedScale: number, anchorX: number, anchorY: number): NotesViewport;
136
+ export declare function centerViewportOnWorldPoint(viewport: NotesViewport, worldX: number, worldY: number, width: number, height: number): NotesViewport;
137
+ export declare function computeBoardBounds(items: readonly NotesItem[]): NotesRect;
138
+ export declare function mergeBoardBounds(base: NotesRect, extra: NotesRect): NotesRect;
139
+ export declare function groupTrashItems(items: readonly NotesTrashItem[]): NotesTrashGroup[];
140
+ export declare function nextLocalZIndex(snapshot: NotesSnapshot): number;
141
+ export declare function promoteLocalItem(snapshot: NotesSnapshot, noteID: string): NotesSnapshot;
142
+ export declare function replaceSnapshotTopic(snapshot: NotesSnapshot, topic: NotesTopic): NotesSnapshot;
143
+ export declare function replaceSnapshotItem(snapshot: NotesSnapshot, item: NotesItem): NotesSnapshot;
144
+ export declare function removeSnapshotItem(snapshot: NotesSnapshot, noteID: string): NotesSnapshot;
145
+ export declare function replaceSnapshotTrashItem(snapshot: NotesSnapshot, trashItem: NotesTrashItem): NotesSnapshot;
146
+ export declare function removeSnapshotTopic(snapshot: NotesSnapshot, topicID: string): NotesSnapshot;
147
+ export declare function applyNotesEvent(snapshot: NotesSnapshot, event: NotesEvent): NotesSnapshot;
148
+ export {};
@@ -0,0 +1,277 @@
1
+ const A = 0.42, X = 2.1, C = ["graphite", "sage", "amber", "azure", "coral", "rose"], z = ["fox", "crane", "otter", "lynx", "whale", "hare"], B = ["ember", "sea", "moss", "ink", "gold", "berry"], I = Object.freeze({
2
+ 1: { width: 184, height: 126, preview_lines: 4 },
3
+ 2: { width: 202, height: 142, preview_lines: 5 },
4
+ 3: { width: 220, height: 160, preview_lines: 6 },
5
+ 4: { width: 238, height: 180, preview_lines: 7 },
6
+ 5: { width: 256, height: 198, preview_lines: 8 }
7
+ }), N = Object.freeze({
8
+ minX: -320,
9
+ minY: -220,
10
+ maxX: 360,
11
+ maxY: 260
12
+ });
13
+ function T(t) {
14
+ const e = Math.round(Number(t) || 1);
15
+ return e <= 1 ? 1 : e >= 5 ? 5 : e;
16
+ }
17
+ function f(t) {
18
+ return [...t].sort((e, i) => e.sort_order !== i.sort_order ? e.sort_order - i.sort_order : e.name.localeCompare(i.name));
19
+ }
20
+ function l(t) {
21
+ return [...t].sort((e, i) => e.z_index !== i.z_index ? e.z_index - i.z_index : e.updated_at_unix_ms !== i.updated_at_unix_ms ? e.updated_at_unix_ms - i.updated_at_unix_ms : e.note_id.localeCompare(i.note_id));
22
+ }
23
+ function a(t) {
24
+ return [...t].sort((e, i) => e.deleted_at_unix_ms !== i.deleted_at_unix_ms ? i.deleted_at_unix_ms - e.deleted_at_unix_ms : e.topic_sort_order !== i.topic_sort_order ? e.topic_sort_order - i.topic_sort_order : i.updated_at_unix_ms - e.updated_at_unix_ms);
25
+ }
26
+ function m(t, e, i) {
27
+ const r = [...t], n = r.findIndex((o) => o[e] === i[e]);
28
+ return n >= 0 ? (r[n] = i, r) : (r.push(i), r);
29
+ }
30
+ function y(t) {
31
+ return I[T(t)];
32
+ }
33
+ function k() {
34
+ return {
35
+ seq: 0,
36
+ retention_hours: 72,
37
+ topics: [],
38
+ items: [],
39
+ trash_items: []
40
+ };
41
+ }
42
+ function g(t) {
43
+ return {
44
+ seq: Number(t.seq) || 0,
45
+ retention_hours: Number(t.retention_hours) || 72,
46
+ topics: f(t.topics ?? []),
47
+ items: l(t.items ?? []),
48
+ trash_items: a(t.trash_items ?? [])
49
+ };
50
+ }
51
+ function S(t) {
52
+ const e = Number(t);
53
+ return Number.isFinite(e) ? Math.max(0.42, Math.min(2.1, e)) : 1;
54
+ }
55
+ function w(t, e) {
56
+ return {
57
+ x: t.x + e.x * t.scale,
58
+ y: t.y + e.y * t.scale
59
+ };
60
+ }
61
+ function _(t, e) {
62
+ const i = t.scale || 1;
63
+ return {
64
+ x: (e.x - t.x) / i,
65
+ y: (e.y - t.y) / i
66
+ };
67
+ }
68
+ function D(t, e, i) {
69
+ const r = _(t, { x: 0, y: 0 }), n = _(t, { x: e, y: i });
70
+ return {
71
+ minX: Math.min(r.x, n.x),
72
+ minY: Math.min(r.y, n.y),
73
+ maxX: Math.max(r.x, n.x),
74
+ maxY: Math.max(r.y, n.y)
75
+ };
76
+ }
77
+ function L(t, e, i, r) {
78
+ const n = S(e), o = _(t, { x: i, y: r });
79
+ return {
80
+ x: i - o.x * n,
81
+ y: r - o.y * n,
82
+ scale: n
83
+ };
84
+ }
85
+ function q(t, e, i, r, n) {
86
+ return {
87
+ x: r / 2 - e * t.scale,
88
+ y: n / 2 - i * t.scale,
89
+ scale: t.scale
90
+ };
91
+ }
92
+ function F(t) {
93
+ if (t.length === 0)
94
+ return N;
95
+ let e = Number.POSITIVE_INFINITY, i = Number.POSITIVE_INFINITY, r = Number.NEGATIVE_INFINITY, n = Number.NEGATIVE_INFINITY;
96
+ for (const o of t) {
97
+ const c = y(o.size_bucket);
98
+ e = Math.min(e, o.x), i = Math.min(i, o.y), r = Math.max(r, o.x + c.width), n = Math.max(n, o.y + c.height);
99
+ }
100
+ return {
101
+ minX: e - 120,
102
+ minY: i - 120,
103
+ maxX: r + 120,
104
+ maxY: n + 120
105
+ };
106
+ }
107
+ function P(t, e) {
108
+ return {
109
+ minX: Math.min(t.minX, e.minX),
110
+ minY: Math.min(t.minY, e.minY),
111
+ maxX: Math.max(t.maxX, e.maxX),
112
+ maxY: Math.max(t.maxY, e.maxY)
113
+ };
114
+ }
115
+ function R(t) {
116
+ const e = /* @__PURE__ */ new Map();
117
+ for (const i of a(t)) {
118
+ const r = e.get(i.topic_id);
119
+ if (r) {
120
+ r.items.push(i);
121
+ continue;
122
+ }
123
+ e.set(i.topic_id, {
124
+ topic_id: i.topic_id,
125
+ topic_name: i.topic_name,
126
+ topic_icon_key: i.topic_icon_key,
127
+ topic_icon_accent: i.topic_icon_accent,
128
+ topic_sort_order: i.topic_sort_order,
129
+ latest_deleted_at_unix_ms: i.deleted_at_unix_ms,
130
+ items: [i]
131
+ });
132
+ }
133
+ return [...e.values()].sort((i, r) => i.latest_deleted_at_unix_ms !== r.latest_deleted_at_unix_ms ? r.latest_deleted_at_unix_ms - i.latest_deleted_at_unix_ms : i.topic_sort_order - r.topic_sort_order);
134
+ }
135
+ function b(t) {
136
+ return t.items.reduce((e, i) => Math.max(e, i.z_index), 0) + 1;
137
+ }
138
+ function V(t, e) {
139
+ const i = t.items.find((r) => r.note_id === e);
140
+ return i ? x(t, {
141
+ ...i,
142
+ z_index: b(t),
143
+ updated_at_unix_ms: Date.now()
144
+ }) : t;
145
+ }
146
+ function M(t, e) {
147
+ return {
148
+ ...t,
149
+ topics: f(m(t.topics, "topic_id", e))
150
+ };
151
+ }
152
+ function x(t, e) {
153
+ return {
154
+ ...t,
155
+ items: l(m(t.items, "note_id", e)),
156
+ trash_items: t.trash_items.filter((i) => i.note_id !== e.note_id)
157
+ };
158
+ }
159
+ function j(t, e) {
160
+ return {
161
+ ...t,
162
+ items: t.items.filter((i) => i.note_id !== e)
163
+ };
164
+ }
165
+ function u(t, e) {
166
+ return {
167
+ ...t,
168
+ items: t.items.filter((i) => i.note_id !== e.note_id),
169
+ trash_items: a(m(t.trash_items, "note_id", e))
170
+ };
171
+ }
172
+ function d(t, e) {
173
+ return {
174
+ ...t,
175
+ topics: t.topics.filter((i) => i.topic_id !== e),
176
+ items: t.items.filter((i) => i.topic_id !== e)
177
+ };
178
+ }
179
+ function p(t) {
180
+ return !t || typeof t != "object" ? null : t;
181
+ }
182
+ function E(t) {
183
+ return !t || typeof t != "object" ? null : t;
184
+ }
185
+ function h(t) {
186
+ return !t || typeof t != "object" ? null : t;
187
+ }
188
+ function O(t) {
189
+ return Array.isArray(t) ? t.map(h).filter(Boolean) : [];
190
+ }
191
+ function Y(t) {
192
+ return Array.isArray(t) ? t.map((e) => String(e ?? "").trim()).filter(Boolean) : [];
193
+ }
194
+ function K(t, e) {
195
+ const i = e.payload ?? {};
196
+ let r = t;
197
+ switch (e.type) {
198
+ case "topic.created":
199
+ case "topic.updated":
200
+ case "topic.restored": {
201
+ const n = p(i.topic);
202
+ n && (r = M(r, n));
203
+ break;
204
+ }
205
+ case "topic.deleted": {
206
+ const o = p(i.topic)?.topic_id || String(e.topic_id ?? "").trim();
207
+ o && (r = d(r, o));
208
+ for (const c of O(i.trash_items))
209
+ r = u(r, c);
210
+ break;
211
+ }
212
+ case "topic.removed": {
213
+ const n = String(i.topic_id ?? e.topic_id ?? "").trim();
214
+ n && (r = d(r, n), r = {
215
+ ...r,
216
+ trash_items: r.trash_items.filter((o) => o.topic_id !== n)
217
+ });
218
+ break;
219
+ }
220
+ case "item.created":
221
+ case "item.updated":
222
+ case "item.fronted":
223
+ case "item.restored": {
224
+ const n = E(i.item);
225
+ n && (r = x(r, n));
226
+ break;
227
+ }
228
+ case "item.deleted": {
229
+ const n = h(i.trash_item);
230
+ n && (r = u(r, n));
231
+ break;
232
+ }
233
+ case "trash.topic_cleared": {
234
+ const n = String(i.topic_id ?? e.topic_id ?? "").trim(), o = Y(i.deleted_ids), c = !!i.topic_removed;
235
+ r = {
236
+ ...r,
237
+ trash_items: r.trash_items.filter((s) => !(o.includes(s.note_id) || !o.length && n && s.topic_id === n))
238
+ }, c && n && (r = {
239
+ ...r,
240
+ topics: r.topics.filter((s) => s.topic_id !== n)
241
+ });
242
+ break;
243
+ }
244
+ }
245
+ return {
246
+ ...r,
247
+ seq: Math.max(Number(t.seq) || 0, Number(e.seq) || 0)
248
+ };
249
+ }
250
+ export {
251
+ X as NOTES_SCALE_MAX,
252
+ A as NOTES_SCALE_MIN,
253
+ I as NOTE_BUCKET_METRICS,
254
+ C as NOTE_COLOR_TOKENS,
255
+ B as TOPIC_ACCENT_TOKENS,
256
+ z as TOPIC_ICON_KEYS,
257
+ K as applyNotesEvent,
258
+ q as centerViewportOnWorldPoint,
259
+ S as clampScale,
260
+ F as computeBoardBounds,
261
+ k as createDefaultNotesSnapshot,
262
+ R as groupTrashItems,
263
+ P as mergeBoardBounds,
264
+ b as nextLocalZIndex,
265
+ g as normalizeNotesSnapshot,
266
+ y as noteBucketMetrics,
267
+ V as promoteLocalItem,
268
+ j as removeSnapshotItem,
269
+ d as removeSnapshotTopic,
270
+ x as replaceSnapshotItem,
271
+ M as replaceSnapshotTopic,
272
+ u as replaceSnapshotTrashItem,
273
+ _ as screenToWorld,
274
+ D as visibleWorldRect,
275
+ w as worldToScreen,
276
+ L as zoomViewportAtPoint
277
+ };
package/dist/full.d.ts CHANGED
@@ -8,6 +8,7 @@ export * from './loading';
8
8
  export * from './launchpad';
9
9
  export * from './file-browser';
10
10
  export * from './chat';
11
+ export * from './notes';
11
12
  export * from './widgets';
12
13
  export * from './terminal';
13
14
  export { Tag, type TagProps, type TagVariant, type TagSize } from './ui';