camox 0.79.0 → 0.80.0
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.
- package/dist/core/lib/artifact.d.ts +26 -1
- package/dist/core/lib/artifactData.d.ts +5 -1
- package/dist/core/lib/artifactHost.d.ts +43 -0
- package/dist/features/brand/BrandPart.js +116 -0
- package/dist/features/brand/CamoxBrand.js +758 -0
- package/dist/features/brand/VoiceGroup.js +443 -0
- package/dist/features/preview/EditablePageExperience.js +2 -2
- package/dist/features/runtime/artifactReplay.d.ts +3 -0
- package/dist/features/runtime/artifactReplay.js +4 -0
- package/dist/features/runtime/runtime.d.ts +1 -1
- package/dist/features/runtime/runtime.js +4 -4
- package/dist/features/studio/components/DraftReview.js +8 -8
- package/dist/features/studio/components/Navbar.js +9 -7
- package/dist/features/studio/routes.js +3 -3
- package/dist/lib/queries.js +7 -7
- package/dist/package.js +1 -1
- package/dist/studio.css +1 -1
- package/package.json +8 -4
- package/dist/features/memory/CamoxMemory.js +0 -756
- package/dist/features/memory/VoiceGroup.js +0 -350
|
@@ -0,0 +1,758 @@
|
|
|
1
|
+
import { useNavigate } from "../navigation/navigation.js";
|
|
2
|
+
import { useProjectUuid } from "../../lib/auth.js";
|
|
3
|
+
import { reads, useReadQuery, useStudioCache } from "../../lib/studio-reads.js";
|
|
4
|
+
import { brandMutations } from "../../lib/queries.js";
|
|
5
|
+
import { previewStore } from "../preview/previewStore.js";
|
|
6
|
+
import { studioStore } from "../studio/studioStore.js";
|
|
7
|
+
import { timeAgo } from "../studio/draftLabel.js";
|
|
8
|
+
import { useWebsiteHref } from "../studio/components/Navbar.js";
|
|
9
|
+
import { BrandPart } from "./BrandPart.js";
|
|
10
|
+
import { VoiceGroup } from "./VoiceGroup.js";
|
|
11
|
+
import { c } from "react/compiler-runtime";
|
|
12
|
+
import * as React from "react";
|
|
13
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { useMutation } from "@tanstack/react-query";
|
|
15
|
+
import { Button } from "@camox/ui/button";
|
|
16
|
+
import { Label } from "@camox/ui/label";
|
|
17
|
+
import { Sheet, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle } from "@camox/ui/sheet";
|
|
18
|
+
import { Textarea } from "@camox/ui/textarea";
|
|
19
|
+
import { MessagesSquare, PlusCircleIcon, Trash2 } from "lucide-react";
|
|
20
|
+
import { Skeleton } from "@camox/ui/skeleton";
|
|
21
|
+
import { Spinner } from "@camox/ui/spinner";
|
|
22
|
+
import { Separator } from "@camox/ui/separator";
|
|
23
|
+
|
|
24
|
+
//#region src/features/brand/CamoxBrand.tsx
|
|
25
|
+
/**
|
|
26
|
+
* The Brand Section (GLOSSARY): the brand of Live or of the draft being viewed, where members set
|
|
27
|
+
* the Voice and add, correct and delete memories. Like content, a first edit while viewing Live
|
|
28
|
+
* starts a draft.
|
|
29
|
+
*/
|
|
30
|
+
const CamoxBrand = () => {
|
|
31
|
+
const $ = c(5);
|
|
32
|
+
const projectUuid = useProjectUuid();
|
|
33
|
+
let t0;
|
|
34
|
+
if ($[0] !== projectUuid) {
|
|
35
|
+
t0 = reads.project({ projectUuid });
|
|
36
|
+
$[0] = projectUuid;
|
|
37
|
+
$[1] = t0;
|
|
38
|
+
} else t0 = $[1];
|
|
39
|
+
const { data: project } = useReadQuery(t0);
|
|
40
|
+
let t1;
|
|
41
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
42
|
+
t1 = /* @__PURE__ */ jsxs("header", {
|
|
43
|
+
className: "flex flex-col gap-1",
|
|
44
|
+
children: [/* @__PURE__ */ jsx("h1", {
|
|
45
|
+
className: "text-xl font-semibold",
|
|
46
|
+
children: "Brand"
|
|
47
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
48
|
+
className: "text-muted-foreground text-sm",
|
|
49
|
+
children: "What Camox knows about you."
|
|
50
|
+
})]
|
|
51
|
+
});
|
|
52
|
+
$[2] = t1;
|
|
53
|
+
} else t1 = $[2];
|
|
54
|
+
let t2;
|
|
55
|
+
if ($[3] !== project) {
|
|
56
|
+
t2 = /* @__PURE__ */ jsxs("div", {
|
|
57
|
+
"data-brand-section": true,
|
|
58
|
+
className: "mx-auto flex w-full max-w-5xl flex-col gap-10 p-6 md:p-10",
|
|
59
|
+
children: [t1, project ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
60
|
+
/* @__PURE__ */ jsx(VoiceGroup, { projectId: project.id }),
|
|
61
|
+
/* @__PURE__ */ jsx(Separator, {}),
|
|
62
|
+
/* @__PURE__ */ jsx(Memory, { projectId: project.id })
|
|
63
|
+
] }) : /* @__PURE__ */ jsxs("div", {
|
|
64
|
+
role: "status",
|
|
65
|
+
"aria-label": "Loading the brand",
|
|
66
|
+
className: "flex flex-col gap-3",
|
|
67
|
+
children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-16" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-16" })]
|
|
68
|
+
})]
|
|
69
|
+
});
|
|
70
|
+
$[3] = project;
|
|
71
|
+
$[4] = t2;
|
|
72
|
+
} else t2 = $[4];
|
|
73
|
+
return t2;
|
|
74
|
+
};
|
|
75
|
+
const words = (count) => `${count.toLocaleString("en")} word${count === 1 ? "" : "s"}`;
|
|
76
|
+
/**
|
|
77
|
+
* Memory, as a table of memories whose last row adds one. Each row opens its memory in a side
|
|
78
|
+
* sheet, as a collection's records do in the Content Section.
|
|
79
|
+
*/
|
|
80
|
+
function Memory(t0) {
|
|
81
|
+
const $ = c(35);
|
|
82
|
+
const { projectId } = t0;
|
|
83
|
+
let t1;
|
|
84
|
+
if ($[0] !== projectId) {
|
|
85
|
+
t1 = reads.memories({ projectId });
|
|
86
|
+
$[0] = projectId;
|
|
87
|
+
$[1] = t1;
|
|
88
|
+
} else t1 = $[1];
|
|
89
|
+
const { data } = useReadQuery(t1);
|
|
90
|
+
const [target, setTarget] = React.useState(null);
|
|
91
|
+
const [open, setOpen] = React.useState(false);
|
|
92
|
+
let t2;
|
|
93
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
94
|
+
t2 = (next) => {
|
|
95
|
+
setTarget(next);
|
|
96
|
+
setOpen(true);
|
|
97
|
+
};
|
|
98
|
+
$[2] = t2;
|
|
99
|
+
} else t2 = $[2];
|
|
100
|
+
const show = t2;
|
|
101
|
+
let t3;
|
|
102
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
103
|
+
t3 = () => setOpen(false);
|
|
104
|
+
$[3] = t3;
|
|
105
|
+
} else t3 = $[3];
|
|
106
|
+
const close = t3;
|
|
107
|
+
const room = data ? Math.max(data.limitWords - data.usedWords, 0) : 0;
|
|
108
|
+
let t4;
|
|
109
|
+
if ($[4] !== data?.memories || $[5] !== target) {
|
|
110
|
+
t4 = target?.kind === "memory" ? data?.memories.find((t5) => {
|
|
111
|
+
const { id } = t5;
|
|
112
|
+
return id === target.id;
|
|
113
|
+
}) : null;
|
|
114
|
+
$[4] = data?.memories;
|
|
115
|
+
$[5] = target;
|
|
116
|
+
$[6] = t4;
|
|
117
|
+
} else t4 = $[6];
|
|
118
|
+
const shown = t4;
|
|
119
|
+
let t5;
|
|
120
|
+
if ($[7] !== data || $[8] !== room) {
|
|
121
|
+
t5 = data && /* @__PURE__ */ jsxs("p", {
|
|
122
|
+
"data-memory-room": true,
|
|
123
|
+
className: "text-muted-foreground text-xs",
|
|
124
|
+
children: [
|
|
125
|
+
words(room),
|
|
126
|
+
" left of ",
|
|
127
|
+
data.limitWords.toLocaleString("en")
|
|
128
|
+
]
|
|
129
|
+
});
|
|
130
|
+
$[7] = data;
|
|
131
|
+
$[8] = room;
|
|
132
|
+
$[9] = t5;
|
|
133
|
+
} else t5 = $[9];
|
|
134
|
+
let t6;
|
|
135
|
+
if ($[10] !== data) {
|
|
136
|
+
t6 = data ? /* @__PURE__ */ jsxs("ul", {
|
|
137
|
+
"aria-label": "Memories",
|
|
138
|
+
className: "divide-y rounded-md border",
|
|
139
|
+
children: [
|
|
140
|
+
data.memories.length === 0 && /* @__PURE__ */ jsx("li", {
|
|
141
|
+
"data-memory-empty": true,
|
|
142
|
+
className: "text-muted-foreground px-4 py-3 text-sm",
|
|
143
|
+
children: "No memories yet."
|
|
144
|
+
}),
|
|
145
|
+
data.memories.map((memory) => /* @__PURE__ */ jsx("li", {
|
|
146
|
+
"data-memory": true,
|
|
147
|
+
className: "hover:bg-accent",
|
|
148
|
+
children: /* @__PURE__ */ jsxs("button", {
|
|
149
|
+
type: "button",
|
|
150
|
+
className: "focus-visible:bg-accent flex w-full flex-col items-start gap-0.5 px-4 py-3 text-left text-sm outline-none",
|
|
151
|
+
onClick: () => show({
|
|
152
|
+
kind: "memory",
|
|
153
|
+
id: memory.id
|
|
154
|
+
}),
|
|
155
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
156
|
+
"data-memory-text": true,
|
|
157
|
+
className: "line-clamp-2",
|
|
158
|
+
children: memory.text
|
|
159
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
160
|
+
className: "text-muted-foreground text-xs",
|
|
161
|
+
children: [
|
|
162
|
+
memory.author.name,
|
|
163
|
+
" · ",
|
|
164
|
+
timeAgo(memory.createdAt)
|
|
165
|
+
]
|
|
166
|
+
})]
|
|
167
|
+
})
|
|
168
|
+
}, memory.id)),
|
|
169
|
+
/* @__PURE__ */ jsx("li", {
|
|
170
|
+
className: "flex justify-start px-2 py-1",
|
|
171
|
+
children: /* @__PURE__ */ jsxs(Button, {
|
|
172
|
+
variant: "ghost",
|
|
173
|
+
size: "sm",
|
|
174
|
+
className: "text-muted-foreground hover:text-foreground font-normal",
|
|
175
|
+
onClick: () => show({ kind: "new" }),
|
|
176
|
+
children: [/* @__PURE__ */ jsx(PlusCircleIcon, {
|
|
177
|
+
"aria-hidden": true,
|
|
178
|
+
className: "size-3.5"
|
|
179
|
+
}), "Add memory"]
|
|
180
|
+
})
|
|
181
|
+
})
|
|
182
|
+
]
|
|
183
|
+
}) : /* @__PURE__ */ jsx(Skeleton, { className: "h-32" });
|
|
184
|
+
$[10] = data;
|
|
185
|
+
$[11] = t6;
|
|
186
|
+
} else t6 = $[11];
|
|
187
|
+
let t7;
|
|
188
|
+
if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
|
|
189
|
+
t7 = (next_0) => !next_0 && close();
|
|
190
|
+
$[12] = t7;
|
|
191
|
+
} else t7 = $[12];
|
|
192
|
+
let t8;
|
|
193
|
+
if ($[13] !== projectId || $[14] !== target?.kind) {
|
|
194
|
+
t8 = target?.kind === "new" && /* @__PURE__ */ jsx(NewMemory, {
|
|
195
|
+
projectId,
|
|
196
|
+
onDone: close
|
|
197
|
+
});
|
|
198
|
+
$[13] = projectId;
|
|
199
|
+
$[14] = target?.kind;
|
|
200
|
+
$[15] = t8;
|
|
201
|
+
} else t8 = $[15];
|
|
202
|
+
let t9;
|
|
203
|
+
if ($[16] !== projectId || $[17] !== shown || $[18] !== target?.kind) {
|
|
204
|
+
t9 = target?.kind === "memory" && shown && /* @__PURE__ */ jsx(MemoryDetails, {
|
|
205
|
+
projectId,
|
|
206
|
+
memory: shown,
|
|
207
|
+
onDone: close
|
|
208
|
+
}, shown.id);
|
|
209
|
+
$[16] = projectId;
|
|
210
|
+
$[17] = shown;
|
|
211
|
+
$[18] = target?.kind;
|
|
212
|
+
$[19] = t9;
|
|
213
|
+
} else t9 = $[19];
|
|
214
|
+
let t10;
|
|
215
|
+
if ($[20] !== data || $[21] !== shown || $[22] !== target?.kind) {
|
|
216
|
+
t10 = target?.kind === "memory" && data && !shown && /* @__PURE__ */ jsxs(SheetHeader, { children: [/* @__PURE__ */ jsx(SheetTitle, { children: "Memory" }), /* @__PURE__ */ jsx(SheetDescription, { children: "This memory no longer exists." })] });
|
|
217
|
+
$[20] = data;
|
|
218
|
+
$[21] = shown;
|
|
219
|
+
$[22] = target?.kind;
|
|
220
|
+
$[23] = t10;
|
|
221
|
+
} else t10 = $[23];
|
|
222
|
+
let t11;
|
|
223
|
+
if ($[24] !== t10 || $[25] !== t8 || $[26] !== t9) {
|
|
224
|
+
t11 = /* @__PURE__ */ jsxs(SheetContent, {
|
|
225
|
+
side: "right",
|
|
226
|
+
className: "gap-0 data-[side=right]:sm:max-w-xl",
|
|
227
|
+
children: [
|
|
228
|
+
t8,
|
|
229
|
+
t9,
|
|
230
|
+
t10
|
|
231
|
+
]
|
|
232
|
+
});
|
|
233
|
+
$[24] = t10;
|
|
234
|
+
$[25] = t8;
|
|
235
|
+
$[26] = t9;
|
|
236
|
+
$[27] = t11;
|
|
237
|
+
} else t11 = $[27];
|
|
238
|
+
let t12;
|
|
239
|
+
if ($[28] !== open || $[29] !== t11) {
|
|
240
|
+
t12 = /* @__PURE__ */ jsx(Sheet, {
|
|
241
|
+
open,
|
|
242
|
+
onOpenChange: t7,
|
|
243
|
+
children: t11
|
|
244
|
+
});
|
|
245
|
+
$[28] = open;
|
|
246
|
+
$[29] = t11;
|
|
247
|
+
$[30] = t12;
|
|
248
|
+
} else t12 = $[30];
|
|
249
|
+
let t13;
|
|
250
|
+
if ($[31] !== t12 || $[32] !== t5 || $[33] !== t6) {
|
|
251
|
+
t13 = /* @__PURE__ */ jsxs(BrandPart, {
|
|
252
|
+
title: "Memory",
|
|
253
|
+
description: "What Camox learnt from working with you.",
|
|
254
|
+
aside: t5,
|
|
255
|
+
children: [t6, t12]
|
|
256
|
+
});
|
|
257
|
+
$[31] = t12;
|
|
258
|
+
$[32] = t5;
|
|
259
|
+
$[33] = t6;
|
|
260
|
+
$[34] = t13;
|
|
261
|
+
} else t13 = $[34];
|
|
262
|
+
return t13;
|
|
263
|
+
}
|
|
264
|
+
/** Refreshes the memory a write changed. On Live, the write started a draft, which it reads. */
|
|
265
|
+
function useRefreshMemory(projectId) {
|
|
266
|
+
const $ = c(3);
|
|
267
|
+
const cache = useStudioCache();
|
|
268
|
+
let t0;
|
|
269
|
+
if ($[0] !== cache || $[1] !== projectId) {
|
|
270
|
+
t0 = () => void cache.invalidate(reads.memories({ projectId }));
|
|
271
|
+
$[0] = cache;
|
|
272
|
+
$[1] = projectId;
|
|
273
|
+
$[2] = t0;
|
|
274
|
+
} else t0 = $[2];
|
|
275
|
+
return t0;
|
|
276
|
+
}
|
|
277
|
+
/** A new memory's form, in the memory sheet. */
|
|
278
|
+
function NewMemory(t0) {
|
|
279
|
+
const $ = c(33);
|
|
280
|
+
const { projectId, onDone } = t0;
|
|
281
|
+
const [text, setText] = React.useState("");
|
|
282
|
+
const refresh = useRefreshMemory(projectId);
|
|
283
|
+
let t1;
|
|
284
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
285
|
+
t1 = brandMutations.addMemory();
|
|
286
|
+
$[0] = t1;
|
|
287
|
+
} else t1 = $[0];
|
|
288
|
+
let t2;
|
|
289
|
+
if ($[1] !== onDone || $[2] !== refresh) {
|
|
290
|
+
t2 = {
|
|
291
|
+
...t1,
|
|
292
|
+
onSuccess: () => {
|
|
293
|
+
refresh();
|
|
294
|
+
onDone();
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
$[1] = onDone;
|
|
298
|
+
$[2] = refresh;
|
|
299
|
+
$[3] = t2;
|
|
300
|
+
} else t2 = $[3];
|
|
301
|
+
const add = useMutation(t2);
|
|
302
|
+
let t3;
|
|
303
|
+
if ($[4] !== text) {
|
|
304
|
+
t3 = text.trim();
|
|
305
|
+
$[4] = text;
|
|
306
|
+
$[5] = t3;
|
|
307
|
+
} else t3 = $[5];
|
|
308
|
+
const trimmed = t3;
|
|
309
|
+
let t4;
|
|
310
|
+
if ($[6] !== add || $[7] !== projectId || $[8] !== trimmed) {
|
|
311
|
+
t4 = (event) => {
|
|
312
|
+
event.preventDefault();
|
|
313
|
+
if (trimmed) add.mutate({
|
|
314
|
+
projectId,
|
|
315
|
+
text: trimmed
|
|
316
|
+
});
|
|
317
|
+
};
|
|
318
|
+
$[6] = add;
|
|
319
|
+
$[7] = projectId;
|
|
320
|
+
$[8] = trimmed;
|
|
321
|
+
$[9] = t4;
|
|
322
|
+
} else t4 = $[9];
|
|
323
|
+
let t5;
|
|
324
|
+
if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
|
|
325
|
+
t5 = /* @__PURE__ */ jsxs(SheetHeader, {
|
|
326
|
+
className: "border-b",
|
|
327
|
+
children: [/* @__PURE__ */ jsx(SheetTitle, { children: "New memory" }), /* @__PURE__ */ jsx(SheetDescription, { children: "Something Camox's agent should always know, such as a rule or how the business talks." })]
|
|
328
|
+
});
|
|
329
|
+
$[10] = t5;
|
|
330
|
+
} else t5 = $[10];
|
|
331
|
+
let t6;
|
|
332
|
+
if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
|
|
333
|
+
t6 = /* @__PURE__ */ jsx(Label, {
|
|
334
|
+
htmlFor: "camox-new-memory",
|
|
335
|
+
children: "Memory"
|
|
336
|
+
});
|
|
337
|
+
$[11] = t6;
|
|
338
|
+
} else t6 = $[11];
|
|
339
|
+
const t7 = add.error ? true : void 0;
|
|
340
|
+
let t8;
|
|
341
|
+
if ($[12] !== add) {
|
|
342
|
+
t8 = (event_0) => {
|
|
343
|
+
setText(event_0.target.value);
|
|
344
|
+
add.reset();
|
|
345
|
+
};
|
|
346
|
+
$[12] = add;
|
|
347
|
+
$[13] = t8;
|
|
348
|
+
} else t8 = $[13];
|
|
349
|
+
let t9;
|
|
350
|
+
if ($[14] !== add.isPending || $[15] !== t7 || $[16] !== t8 || $[17] !== text) {
|
|
351
|
+
t9 = /* @__PURE__ */ jsx(Textarea, {
|
|
352
|
+
id: "camox-new-memory",
|
|
353
|
+
className: "min-h-32",
|
|
354
|
+
placeholder: "We never name competitors.",
|
|
355
|
+
value: text,
|
|
356
|
+
"aria-invalid": t7,
|
|
357
|
+
disabled: add.isPending,
|
|
358
|
+
onChange: t8
|
|
359
|
+
});
|
|
360
|
+
$[14] = add.isPending;
|
|
361
|
+
$[15] = t7;
|
|
362
|
+
$[16] = t8;
|
|
363
|
+
$[17] = text;
|
|
364
|
+
$[18] = t9;
|
|
365
|
+
} else t9 = $[18];
|
|
366
|
+
let t10;
|
|
367
|
+
if ($[19] !== add.error) {
|
|
368
|
+
t10 = add.error && /* @__PURE__ */ jsx("p", {
|
|
369
|
+
"data-memory-error": true,
|
|
370
|
+
className: "text-destructive text-xs",
|
|
371
|
+
children: add.error.message
|
|
372
|
+
});
|
|
373
|
+
$[19] = add.error;
|
|
374
|
+
$[20] = t10;
|
|
375
|
+
} else t10 = $[20];
|
|
376
|
+
let t11;
|
|
377
|
+
if ($[21] !== t10 || $[22] !== t9) {
|
|
378
|
+
t11 = /* @__PURE__ */ jsxs("div", {
|
|
379
|
+
className: "flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto p-4",
|
|
380
|
+
children: [
|
|
381
|
+
t6,
|
|
382
|
+
t9,
|
|
383
|
+
t10
|
|
384
|
+
]
|
|
385
|
+
});
|
|
386
|
+
$[21] = t10;
|
|
387
|
+
$[22] = t9;
|
|
388
|
+
$[23] = t11;
|
|
389
|
+
} else t11 = $[23];
|
|
390
|
+
const t12 = !trimmed || add.isPending;
|
|
391
|
+
let t13;
|
|
392
|
+
if ($[24] !== add.isPending) {
|
|
393
|
+
t13 = add.isPending && /* @__PURE__ */ jsx(Spinner, {});
|
|
394
|
+
$[24] = add.isPending;
|
|
395
|
+
$[25] = t13;
|
|
396
|
+
} else t13 = $[25];
|
|
397
|
+
let t14;
|
|
398
|
+
if ($[26] !== t12 || $[27] !== t13) {
|
|
399
|
+
t14 = /* @__PURE__ */ jsx(SheetFooter, {
|
|
400
|
+
className: "flex-row border-t",
|
|
401
|
+
children: /* @__PURE__ */ jsxs(Button, {
|
|
402
|
+
type: "submit",
|
|
403
|
+
disabled: t12,
|
|
404
|
+
children: [t13, "Remember"]
|
|
405
|
+
})
|
|
406
|
+
});
|
|
407
|
+
$[26] = t12;
|
|
408
|
+
$[27] = t13;
|
|
409
|
+
$[28] = t14;
|
|
410
|
+
} else t14 = $[28];
|
|
411
|
+
let t15;
|
|
412
|
+
if ($[29] !== t11 || $[30] !== t14 || $[31] !== t4) {
|
|
413
|
+
t15 = /* @__PURE__ */ jsxs("form", {
|
|
414
|
+
className: "flex min-h-0 flex-1 flex-col",
|
|
415
|
+
onSubmit: t4,
|
|
416
|
+
children: [
|
|
417
|
+
t5,
|
|
418
|
+
t11,
|
|
419
|
+
t14
|
|
420
|
+
]
|
|
421
|
+
});
|
|
422
|
+
$[29] = t11;
|
|
423
|
+
$[30] = t14;
|
|
424
|
+
$[31] = t4;
|
|
425
|
+
$[32] = t15;
|
|
426
|
+
} else t15 = $[32];
|
|
427
|
+
return t15;
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* A memory in the memory sheet: where it came from (who taught it and when, and the quote and its
|
|
431
|
+
* thread), its text to correct, and deleting it.
|
|
432
|
+
*/
|
|
433
|
+
function MemoryDetails(t0) {
|
|
434
|
+
const $ = c(62);
|
|
435
|
+
const { projectId, memory, onDone } = t0;
|
|
436
|
+
const [text, setText] = React.useState(memory.text);
|
|
437
|
+
const refresh = useRefreshMemory(projectId);
|
|
438
|
+
let t1;
|
|
439
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
440
|
+
t1 = brandMutations.changeMemory();
|
|
441
|
+
$[0] = t1;
|
|
442
|
+
} else t1 = $[0];
|
|
443
|
+
let t2;
|
|
444
|
+
if ($[1] !== onDone || $[2] !== refresh) {
|
|
445
|
+
t2 = {
|
|
446
|
+
...t1,
|
|
447
|
+
onSuccess: () => {
|
|
448
|
+
refresh();
|
|
449
|
+
onDone();
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
$[1] = onDone;
|
|
453
|
+
$[2] = refresh;
|
|
454
|
+
$[3] = t2;
|
|
455
|
+
} else t2 = $[3];
|
|
456
|
+
const change = useMutation(t2);
|
|
457
|
+
let t3;
|
|
458
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
459
|
+
t3 = brandMutations.deleteMemory();
|
|
460
|
+
$[4] = t3;
|
|
461
|
+
} else t3 = $[4];
|
|
462
|
+
let t4;
|
|
463
|
+
if ($[5] !== onDone || $[6] !== refresh) {
|
|
464
|
+
t4 = {
|
|
465
|
+
...t3,
|
|
466
|
+
onSuccess: () => {
|
|
467
|
+
refresh();
|
|
468
|
+
onDone();
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
$[5] = onDone;
|
|
472
|
+
$[6] = refresh;
|
|
473
|
+
$[7] = t4;
|
|
474
|
+
} else t4 = $[7];
|
|
475
|
+
const remove = useMutation(t4);
|
|
476
|
+
let t5;
|
|
477
|
+
if ($[8] !== text) {
|
|
478
|
+
t5 = text.trim();
|
|
479
|
+
$[8] = text;
|
|
480
|
+
$[9] = t5;
|
|
481
|
+
} else t5 = $[9];
|
|
482
|
+
const trimmed = t5;
|
|
483
|
+
const pending = change.isPending || remove.isPending;
|
|
484
|
+
const error = change.error ?? remove.error;
|
|
485
|
+
let t6;
|
|
486
|
+
if ($[10] !== change || $[11] !== memory.id || $[12] !== projectId || $[13] !== trimmed) {
|
|
487
|
+
t6 = (event) => {
|
|
488
|
+
event.preventDefault();
|
|
489
|
+
if (trimmed) change.mutate({
|
|
490
|
+
projectId,
|
|
491
|
+
id: memory.id,
|
|
492
|
+
text: trimmed
|
|
493
|
+
});
|
|
494
|
+
};
|
|
495
|
+
$[10] = change;
|
|
496
|
+
$[11] = memory.id;
|
|
497
|
+
$[12] = projectId;
|
|
498
|
+
$[13] = trimmed;
|
|
499
|
+
$[14] = t6;
|
|
500
|
+
} else t6 = $[14];
|
|
501
|
+
let t7;
|
|
502
|
+
if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
|
|
503
|
+
t7 = /* @__PURE__ */ jsx(SheetTitle, { children: "Memory" });
|
|
504
|
+
$[15] = t7;
|
|
505
|
+
} else t7 = $[15];
|
|
506
|
+
const t8 = memory.source.kind === "studio" ? "Written in the studio by " : "Taught by ";
|
|
507
|
+
const t9 = memory.author.name;
|
|
508
|
+
let t10;
|
|
509
|
+
if ($[16] !== memory.createdAt) {
|
|
510
|
+
t10 = timeAgo(memory.createdAt);
|
|
511
|
+
$[16] = memory.createdAt;
|
|
512
|
+
$[17] = t10;
|
|
513
|
+
} else t10 = $[17];
|
|
514
|
+
let t11;
|
|
515
|
+
if ($[18] !== memory.author.name || $[19] !== t10 || $[20] !== t8) {
|
|
516
|
+
t11 = /* @__PURE__ */ jsxs(SheetHeader, {
|
|
517
|
+
className: "border-b",
|
|
518
|
+
children: [t7, /* @__PURE__ */ jsxs(SheetDescription, { children: [
|
|
519
|
+
t8,
|
|
520
|
+
t9,
|
|
521
|
+
" · ",
|
|
522
|
+
t10
|
|
523
|
+
] })]
|
|
524
|
+
});
|
|
525
|
+
$[18] = memory.author.name;
|
|
526
|
+
$[19] = t10;
|
|
527
|
+
$[20] = t8;
|
|
528
|
+
$[21] = t11;
|
|
529
|
+
} else t11 = $[21];
|
|
530
|
+
let t12;
|
|
531
|
+
if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
|
|
532
|
+
t12 = /* @__PURE__ */ jsx(Label, {
|
|
533
|
+
htmlFor: "camox-memory-text",
|
|
534
|
+
children: "Memory"
|
|
535
|
+
});
|
|
536
|
+
$[22] = t12;
|
|
537
|
+
} else t12 = $[22];
|
|
538
|
+
const t13 = change.error ? true : void 0;
|
|
539
|
+
let t14;
|
|
540
|
+
if ($[23] !== change) {
|
|
541
|
+
t14 = (event_0) => {
|
|
542
|
+
setText(event_0.target.value);
|
|
543
|
+
change.reset();
|
|
544
|
+
};
|
|
545
|
+
$[23] = change;
|
|
546
|
+
$[24] = t14;
|
|
547
|
+
} else t14 = $[24];
|
|
548
|
+
let t15;
|
|
549
|
+
if ($[25] !== pending || $[26] !== t13 || $[27] !== t14 || $[28] !== text) {
|
|
550
|
+
t15 = /* @__PURE__ */ jsxs("div", {
|
|
551
|
+
className: "flex flex-col gap-2",
|
|
552
|
+
children: [t12, /* @__PURE__ */ jsx(Textarea, {
|
|
553
|
+
id: "camox-memory-text",
|
|
554
|
+
className: "min-h-32",
|
|
555
|
+
value: text,
|
|
556
|
+
"aria-invalid": t13,
|
|
557
|
+
disabled: pending,
|
|
558
|
+
onChange: t14
|
|
559
|
+
})]
|
|
560
|
+
});
|
|
561
|
+
$[25] = pending;
|
|
562
|
+
$[26] = t13;
|
|
563
|
+
$[27] = t14;
|
|
564
|
+
$[28] = text;
|
|
565
|
+
$[29] = t15;
|
|
566
|
+
} else t15 = $[29];
|
|
567
|
+
let t16;
|
|
568
|
+
if ($[30] !== memory.source || $[31] !== onDone) {
|
|
569
|
+
t16 = memory.source.kind === "thread" && /* @__PURE__ */ jsxs("div", {
|
|
570
|
+
className: "flex flex-col items-start gap-2",
|
|
571
|
+
children: [
|
|
572
|
+
/* @__PURE__ */ jsx("p", {
|
|
573
|
+
className: "text-sm font-medium",
|
|
574
|
+
children: "Where it came from"
|
|
575
|
+
}),
|
|
576
|
+
/* @__PURE__ */ jsxs("blockquote", {
|
|
577
|
+
className: "text-muted-foreground border-l-2 pl-3 text-sm italic",
|
|
578
|
+
children: [
|
|
579
|
+
"“",
|
|
580
|
+
memory.source.quote,
|
|
581
|
+
"”"
|
|
582
|
+
]
|
|
583
|
+
}),
|
|
584
|
+
/* @__PURE__ */ jsx(SourceThread, {
|
|
585
|
+
source: memory.source,
|
|
586
|
+
onOpen: onDone
|
|
587
|
+
})
|
|
588
|
+
]
|
|
589
|
+
});
|
|
590
|
+
$[30] = memory.source;
|
|
591
|
+
$[31] = onDone;
|
|
592
|
+
$[32] = t16;
|
|
593
|
+
} else t16 = $[32];
|
|
594
|
+
let t17;
|
|
595
|
+
if ($[33] !== error) {
|
|
596
|
+
t17 = error && /* @__PURE__ */ jsx("p", {
|
|
597
|
+
"data-memory-error": true,
|
|
598
|
+
className: "text-destructive text-xs",
|
|
599
|
+
children: error.message
|
|
600
|
+
});
|
|
601
|
+
$[33] = error;
|
|
602
|
+
$[34] = t17;
|
|
603
|
+
} else t17 = $[34];
|
|
604
|
+
let t18;
|
|
605
|
+
if ($[35] !== t15 || $[36] !== t16 || $[37] !== t17) {
|
|
606
|
+
t18 = /* @__PURE__ */ jsxs("div", {
|
|
607
|
+
className: "flex min-h-0 flex-1 flex-col gap-6 overflow-y-auto p-4",
|
|
608
|
+
children: [
|
|
609
|
+
t15,
|
|
610
|
+
t16,
|
|
611
|
+
t17
|
|
612
|
+
]
|
|
613
|
+
});
|
|
614
|
+
$[35] = t15;
|
|
615
|
+
$[36] = t16;
|
|
616
|
+
$[37] = t17;
|
|
617
|
+
$[38] = t18;
|
|
618
|
+
} else t18 = $[38];
|
|
619
|
+
const t19 = !trimmed || trimmed === memory.text || pending;
|
|
620
|
+
let t20;
|
|
621
|
+
if ($[39] !== change.isPending) {
|
|
622
|
+
t20 = change.isPending && /* @__PURE__ */ jsx(Spinner, {});
|
|
623
|
+
$[39] = change.isPending;
|
|
624
|
+
$[40] = t20;
|
|
625
|
+
} else t20 = $[40];
|
|
626
|
+
let t21;
|
|
627
|
+
if ($[41] !== t19 || $[42] !== t20) {
|
|
628
|
+
t21 = /* @__PURE__ */ jsxs(Button, {
|
|
629
|
+
type: "submit",
|
|
630
|
+
disabled: t19,
|
|
631
|
+
children: [t20, "Save"]
|
|
632
|
+
});
|
|
633
|
+
$[41] = t19;
|
|
634
|
+
$[42] = t20;
|
|
635
|
+
$[43] = t21;
|
|
636
|
+
} else t21 = $[43];
|
|
637
|
+
let t22;
|
|
638
|
+
if ($[44] !== memory.id || $[45] !== projectId || $[46] !== remove) {
|
|
639
|
+
t22 = () => remove.mutate({
|
|
640
|
+
projectId,
|
|
641
|
+
id: memory.id
|
|
642
|
+
});
|
|
643
|
+
$[44] = memory.id;
|
|
644
|
+
$[45] = projectId;
|
|
645
|
+
$[46] = remove;
|
|
646
|
+
$[47] = t22;
|
|
647
|
+
} else t22 = $[47];
|
|
648
|
+
let t23;
|
|
649
|
+
if ($[48] !== remove.isPending) {
|
|
650
|
+
t23 = remove.isPending ? /* @__PURE__ */ jsx(Spinner, {}) : /* @__PURE__ */ jsx(Trash2, {});
|
|
651
|
+
$[48] = remove.isPending;
|
|
652
|
+
$[49] = t23;
|
|
653
|
+
} else t23 = $[49];
|
|
654
|
+
let t24;
|
|
655
|
+
if ($[50] !== pending || $[51] !== t22 || $[52] !== t23) {
|
|
656
|
+
t24 = /* @__PURE__ */ jsxs(Button, {
|
|
657
|
+
type: "button",
|
|
658
|
+
variant: "ghost",
|
|
659
|
+
className: "text-destructive ml-auto",
|
|
660
|
+
"aria-label": "Delete memory",
|
|
661
|
+
disabled: pending,
|
|
662
|
+
onClick: t22,
|
|
663
|
+
children: [t23, "Delete"]
|
|
664
|
+
});
|
|
665
|
+
$[50] = pending;
|
|
666
|
+
$[51] = t22;
|
|
667
|
+
$[52] = t23;
|
|
668
|
+
$[53] = t24;
|
|
669
|
+
} else t24 = $[53];
|
|
670
|
+
let t25;
|
|
671
|
+
if ($[54] !== t21 || $[55] !== t24) {
|
|
672
|
+
t25 = /* @__PURE__ */ jsxs(SheetFooter, {
|
|
673
|
+
className: "flex-row border-t",
|
|
674
|
+
children: [t21, t24]
|
|
675
|
+
});
|
|
676
|
+
$[54] = t21;
|
|
677
|
+
$[55] = t24;
|
|
678
|
+
$[56] = t25;
|
|
679
|
+
} else t25 = $[56];
|
|
680
|
+
let t26;
|
|
681
|
+
if ($[57] !== t11 || $[58] !== t18 || $[59] !== t25 || $[60] !== t6) {
|
|
682
|
+
t26 = /* @__PURE__ */ jsxs("form", {
|
|
683
|
+
"data-memory-details": true,
|
|
684
|
+
className: "flex min-h-0 flex-1 flex-col",
|
|
685
|
+
onSubmit: t6,
|
|
686
|
+
children: [
|
|
687
|
+
t11,
|
|
688
|
+
t18,
|
|
689
|
+
t25
|
|
690
|
+
]
|
|
691
|
+
});
|
|
692
|
+
$[57] = t11;
|
|
693
|
+
$[58] = t18;
|
|
694
|
+
$[59] = t25;
|
|
695
|
+
$[60] = t6;
|
|
696
|
+
$[61] = t26;
|
|
697
|
+
} else t26 = $[61];
|
|
698
|
+
return t26;
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* Opens the thread a memory's quote was said in: its draft's, beside the Canvas, or its
|
|
702
|
+
* Publication's once the draft was published (ADR 0045). `onOpen` closes what it was opened from.
|
|
703
|
+
*/
|
|
704
|
+
function SourceThread(t0) {
|
|
705
|
+
const $ = c(10);
|
|
706
|
+
const { source, onOpen } = t0;
|
|
707
|
+
const navigate = useNavigate();
|
|
708
|
+
const websiteHref = useWebsiteHref();
|
|
709
|
+
let t1;
|
|
710
|
+
if ($[0] !== navigate || $[1] !== onOpen || $[2] !== source.draftId || $[3] !== source.published || $[4] !== websiteHref) {
|
|
711
|
+
t1 = () => {
|
|
712
|
+
onOpen();
|
|
713
|
+
if (source.published) {
|
|
714
|
+
studioStore.send({
|
|
715
|
+
type: "openDraftsSheet",
|
|
716
|
+
publicationId: source.draftId
|
|
717
|
+
});
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
previewStore.send({ type: "showCanvas" });
|
|
721
|
+
navigate({
|
|
722
|
+
to: websiteHref(),
|
|
723
|
+
draft: source.draftId
|
|
724
|
+
});
|
|
725
|
+
};
|
|
726
|
+
$[0] = navigate;
|
|
727
|
+
$[1] = onOpen;
|
|
728
|
+
$[2] = source.draftId;
|
|
729
|
+
$[3] = source.published;
|
|
730
|
+
$[4] = websiteHref;
|
|
731
|
+
$[5] = t1;
|
|
732
|
+
} else t1 = $[5];
|
|
733
|
+
const open = t1;
|
|
734
|
+
let t2;
|
|
735
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
736
|
+
t2 = /* @__PURE__ */ jsx(MessagesSquare, {});
|
|
737
|
+
$[6] = t2;
|
|
738
|
+
} else t2 = $[6];
|
|
739
|
+
const t3 = source.published ? "See the published draft's thread" : "See the draft's thread";
|
|
740
|
+
let t4;
|
|
741
|
+
if ($[7] !== open || $[8] !== t3) {
|
|
742
|
+
t4 = /* @__PURE__ */ jsxs(Button, {
|
|
743
|
+
type: "button",
|
|
744
|
+
variant: "link",
|
|
745
|
+
size: "sm",
|
|
746
|
+
className: "h-auto px-0",
|
|
747
|
+
onClick: open,
|
|
748
|
+
children: [t2, t3]
|
|
749
|
+
});
|
|
750
|
+
$[7] = open;
|
|
751
|
+
$[8] = t3;
|
|
752
|
+
$[9] = t4;
|
|
753
|
+
} else t4 = $[9];
|
|
754
|
+
return t4;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
//#endregion
|
|
758
|
+
export { CamoxBrand };
|