@eliya-oss/agent-diff 0.1.0-alpha.217 → 0.1.0-alpha.218

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.
Files changed (58) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/main.js +1 -1
  3. package/dist/web/nitro.json +1 -1
  4. package/dist/web/public/assets/index-BCc7tdE9.js +12 -0
  5. package/dist/web/public/assets/index-Bh4VvgUA.css +2 -0
  6. package/dist/web/public/assets/{rolldown-runtime-XKyaHtl9.js → jsx-runtime-EIAPxkjE.js} +1 -1
  7. package/dist/web/public/assets/review-CLHgc7OK.js +44 -0
  8. package/dist/web/public/assets/routes-CS6_XKJl.js +1 -0
  9. package/dist/web/server/_libs/@base-ui/react+[...].mjs +2686 -4472
  10. package/dist/web/server/_libs/@tanstack/react-router+[...].mjs +1 -107
  11. package/dist/web/server/_libs/lucide-react.mjs +93 -268
  12. package/dist/web/server/_libs/react-markdown+[...].mjs +1 -1
  13. package/dist/web/server/_libs/valibot.mjs +1 -59
  14. package/dist/web/server/_ssr/highlight.server-Ch_kPZFd.mjs +199 -0
  15. package/dist/web/server/_ssr/{listener.functions-DygHonX4.mjs → listener.functions-r5sy6slm.mjs} +7 -7
  16. package/dist/web/server/_ssr/{listener.server-BUJSjrgf.mjs → listener.server-Ch_E4TJ7.mjs} +3 -2
  17. package/dist/web/server/_ssr/{review-block-BpqPNXDo.mjs → review-CXA8hOed.mjs} +5200 -5492
  18. package/dist/web/server/_ssr/review-folder.server-DrhuBcAc.mjs +354 -0
  19. package/dist/web/server/_ssr/{adhoc.functions-CDadmCcu.mjs → review-link.functions-BvcyZSk2.mjs} +12 -11
  20. package/dist/web/server/_ssr/review-link.server-XUXU8Jjl.mjs +180 -0
  21. package/dist/web/server/_ssr/{review-parts.server-j_3LS0HZ.mjs → review-parts.server-CSSa-ZRv.mjs} +2 -2
  22. package/dist/web/server/_ssr/review-read.functions-Da-f7qpe.mjs +37 -0
  23. package/dist/web/server/_ssr/{live-schema-BYm_IvNp.mjs → review-schema-C0qXng9-.mjs} +5 -64
  24. package/dist/web/server/_ssr/review-target.server-C8IXgmE-.mjs +18 -0
  25. package/dist/web/server/_ssr/{review.functions-Cvig5BYP.mjs → review.functions-BYEhPk_l.mjs} +19 -17
  26. package/dist/web/server/_ssr/review.server-DFe2jCWt.mjs +847 -0
  27. package/dist/web/server/_ssr/{router-CD3AbIAr.mjs → router-DqvyAgJl.mjs} +119 -257
  28. package/dist/web/server/_ssr/routes-6k-4pwuW.mjs +20 -0
  29. package/dist/web/server/_ssr/ssr.mjs +36 -72
  30. package/dist/web/server/_ssr/{thread-code-BWhoBW-5.mjs → thread-code-CYNB3wg5.mjs} +2 -3
  31. package/dist/web/server/_ssr/{type-hover-DSq-tkS_.mjs → type-hover-BWVNL2Vt.mjs} +2 -3
  32. package/dist/web/server/_ssr/{type-hover.functions-B_9iC3Xs.mjs → type-hover.functions-oAqPixru.mjs} +6 -5
  33. package/dist/web/server/_tanstack-start-manifest_v-BBV9HPN6.mjs +30 -0
  34. package/dist/web/server/index.mjs +25 -88
  35. package/package.json +1 -1
  36. package/dist/web/public/assets/_deck-CklUZ5Lb.js +0 -1
  37. package/dist/web/public/assets/_point-CXnTY-uf.js +0 -1
  38. package/dist/web/public/assets/adhoc.functions-C2dHzbMd.js +0 -1
  39. package/dist/web/public/assets/decks.functions-tXNTG2sC.js +0 -2
  40. package/dist/web/public/assets/index-B1ZY8zdK.css +0 -2
  41. package/dist/web/public/assets/index-DwC305SP.js +0 -11
  42. package/dist/web/public/assets/preload-helper-D5PXivxI.js +0 -1
  43. package/dist/web/public/assets/review-DAeFpudT.js +0 -1
  44. package/dist/web/public/assets/review-block-ILzR6Z95.js +0 -47
  45. package/dist/web/public/assets/routes-CVPv3eOL.js +0 -1
  46. package/dist/web/public/assets/shortcuts-BsNWbUaT.js +0 -1
  47. package/dist/web/public/assets/use-window-event-BDUVK1pJ.js +0 -1
  48. package/dist/web/public/assets/viewed-store-CbsF-9u7.js +0 -1
  49. package/dist/web/server/_deck-yL0m-bqz.mjs +0 -387
  50. package/dist/web/server/_libs/yaml.mjs +0 -6585
  51. package/dist/web/server/_point-C3P2_j2t.mjs +0 -1528
  52. package/dist/web/server/_ssr/decks.functions-BHxu668D.mjs +0 -1073
  53. package/dist/web/server/_ssr/review-CsjxwbVP.mjs +0 -58
  54. package/dist/web/server/_ssr/review-target.server-DA41RDao.mjs +0 -1779
  55. package/dist/web/server/_ssr/routes-CvszJ1sA.mjs +0 -27
  56. package/dist/web/server/_ssr/shortcuts-B7llaLLc.mjs +0 -228
  57. package/dist/web/server/_ssr/viewed-store-DGoAmvYO.mjs +0 -198
  58. package/dist/web/server/_tanstack-start-manifest_v-D8b_yVnx.mjs +0 -56
@@ -1,1528 +0,0 @@
1
- import { __toESM } from "./_runtime.mjs";
2
- import { ScrollArea$1, markViewed, refreshLive, sendAnswer, useLiveState, usePointRefresh } from "./_ssr/viewed-store-DGoAmvYO.mjs";
3
- import { SHORTCUTS, getNextOpen, getRevision, isOverlayOpen, isTyping, matches } from "./_ssr/shortcuts-B7llaLLc.mjs";
4
- import { Hint, IconButton, cn, postComment, resolveComment, useReviewPrefs, useToast, useWindowEvent } from "./_ssr/router-CD3AbIAr.mjs";
5
- import { CommentForm, DiffFile, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuShortcut, DropdownMenuTrigger, EDITOR_NAMES, GalleryFrame, GalleryProvider, LineRow, LineThread, LooseThreads, Markdown, Message, ReviewBlock, RowThreads, getEditorLink, getFolderLink, getPicked, openInEditor, placeThreads, toDeckSrc, toRange, useKnownComments, useLineSelection, useOpenGallery } from "./_ssr/review-block-BpqPNXDo.mjs";
6
- import { RadioGroup, RadioIndicator, RadioRoot, Separator, require_jsx_runtime, require_react } from "./_libs/@base-ui/react+[...].mjs";
7
- import { getRouteApi, useNavigate } from "./_libs/@tanstack/react-router+[...].mjs";
8
- import { ArrowLeft, ArrowRight, Check, ChevronsRight, Copy, Ellipsis, ExternalLink, Eye, FileText, Link, Maximize2, MessageSquare, Play, SquareArrowOutUpRight } from "./_libs/lucide-react.mjs";
9
- import { cva } from "./_libs/class-variance-authority+clsx.mjs";
10
- // node_modules/.nitro/vite/services/ssr/assets/_point-C3P2_j2t.js
11
- var import_react = /* @__PURE__ */ __toESM(require_react());
12
- var import_jsx_runtime = require_jsx_runtime();
13
- var useMarkViewed = (point, latest) => {
14
- (0, import_react.useEffect)(() => {
15
- markViewed(point, latest);
16
- }, [point, latest]);
17
- };
18
- var FADE_SLACK = 1;
19
- var PIN_SLACK = 24;
20
- var getRemaining = (list) => list.scrollHeight - list.scrollTop - list.clientHeight;
21
- var markFades = (list) => {
22
- list.dataset["fadeTop"] = String(list.scrollTop > 0);
23
- list.dataset["fadeBottom"] = String(getRemaining(list) > FADE_SLACK);
24
- };
25
- var getMessages = (live, point) => live.comments.filter((comment) => comment.point === point && comment.path === null && typeof comment.media !== "string").toSorted((left, right) => left.at.localeCompare(right.at));
26
- var Chat = ({ deck, view, live }) => {
27
- const pinned = (0, import_react.useRef)(true);
28
- const revision = getRevision(live, view.id);
29
- const messages = getMessages(live, view.id);
30
- const keepPinned = (list) => {
31
- if (list === null) return;
32
- if (pinned.current) list.scrollTop = list.scrollHeight;
33
- markFades(list);
34
- };
35
- const pinFromEnd = (end) => {
36
- keepPinned(end?.closest("[data-slot=\"scroll-area-viewport\"]") ?? null);
37
- };
38
- const send = async (body) => {
39
- await postComment({ data: {
40
- deck,
41
- point: view.id,
42
- revision,
43
- path: null,
44
- side: "new",
45
- start: null,
46
- end: null,
47
- code: "",
48
- body,
49
- parent: null
50
- } });
51
- pinned.current = true;
52
- await refreshLive(deck);
53
- };
54
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
55
- "aria-label": "Conversation",
56
- className: "flex min-h-0 flex-1 flex-col gap-2.5 pt-2",
57
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
58
- className: "min-h-0 flex-1",
59
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ScrollArea$1, {
60
- onScroll: (event) => {
61
- pinned.current = getRemaining(event.currentTarget) < PIN_SLACK;
62
- markFades(event.currentTarget);
63
- },
64
- variant: "fade",
65
- viewportRef: keepPinned,
66
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
67
- className: "flex min-h-full flex-col gap-2",
68
- children: [
69
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mt-auto" }),
70
- messages.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
71
- className: "m-0 text-sm text-subtle",
72
- children: "No messages yet."
73
- }) : null,
74
- messages.map((comment, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Message, {
75
- comment,
76
- deck,
77
- isBubble: true,
78
- isLatest: index === messages.length - 1,
79
- live,
80
- revision
81
- }, comment.id)),
82
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: pinFromEnd }, messages.length)
83
- ]
84
- })
85
- })
86
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CommentForm, {
87
- deck,
88
- onSubmit: send,
89
- placeholder: "Message the agent about this point",
90
- submitLabel: "Send"
91
- })]
92
- });
93
- };
94
- var radioCardVariants = cva("group/option relative flex touch-none items-start gap-2.5 overflow-hidden rounded-md border p-3 text-start transition-[border-color,background-color] duration-150 ease-out outline-none select-none hover:bg-secondary/50 focus-visible:bg-secondary/50 focus-visible:ring-3 focus-visible:ring-ring/50 data-checked:border-foreground", {
95
- variants: { variant: {
96
- default: "border-border hover:border-subtle",
97
- sent: "border-muted-foreground hover:border-foreground"
98
- } },
99
- defaultVariants: { variant: "default" }
100
- });
101
- function RadioGroup$1({ className, ...props }) {
102
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RadioGroup, {
103
- className: cn("grid w-full gap-2", className),
104
- "data-slot": "radio-group",
105
- ...props
106
- });
107
- }
108
- function RadioGroupItem({ className, variant, children, ...props }) {
109
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(RadioRoot, {
110
- className: cn(radioCardVariants({
111
- variant,
112
- className
113
- })),
114
- "data-slot": "radio-group-item",
115
- ...props,
116
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
117
- className: "mt-1 grid size-3.5 shrink-0 place-items-center rounded-full border border-muted-foreground group-data-checked/option:border-foreground",
118
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RadioIndicator, { className: "size-1.5 rounded-full bg-foreground" })
119
- }), children]
120
- });
121
- }
122
- var HOLD_MS = 500;
123
- var HOLD_KEYS = /* @__PURE__ */ new Set([" ", "Enter"]);
124
- var SentBadge = ({ hasJustSent }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
125
- className: cn("inline-flex items-center gap-1 rounded-sm border border-border px-1.5 text-xs font-normal text-muted-foreground", hasJustSent && "animate-settle border-success text-success"),
126
- children: [hasJustSent ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Check, { className: "size-3" }) : null, "Sent"]
127
- });
128
- var PreviewMark = ({ isShown }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
129
- className: cn("ms-auto inline-flex text-subtle transition-colors duration-150 ease-out", isShown && "text-foreground"),
130
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Eye, {
131
- "aria-hidden": true,
132
- className: "size-3.5"
133
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
134
- className: "sr-only",
135
- children: isShown ? "On the slide" : "Click to preview on the slide"
136
- })]
137
- });
138
- var OptionCard = ({ option, isSent, isDraft, isShown, isHolding, hasJustSent, onHoldStart: handleHoldStart, onHoldEnd: handleHoldEnd }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(RadioGroupItem, {
139
- onKeyDown: (event) => {
140
- if (HOLD_KEYS.has(event.key) && !event.repeat) handleHoldStart(option.value);
141
- },
142
- onKeyUp: (event) => {
143
- if (HOLD_KEYS.has(event.key)) handleHoldEnd();
144
- },
145
- onPointerCancel: handleHoldEnd,
146
- onPointerDown: () => {
147
- handleHoldStart(option.value);
148
- },
149
- onPointerLeave: handleHoldEnd,
150
- onPointerUp: handleHoldEnd,
151
- value: option.value,
152
- variant: isSent ? "sent" : "default",
153
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
154
- "aria-hidden": true,
155
- className: "pointer-events-none absolute inset-0 hold-fill bg-foreground/10",
156
- "data-holding": isHolding
157
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
158
- className: "relative grid min-w-0 flex-1 gap-0.5",
159
- children: [
160
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
161
- className: "flex items-center gap-2 font-medium",
162
- children: [
163
- option.label,
164
- isSent ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SentBadge, { hasJustSent }) : null,
165
- option.blocks === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PreviewMark, { isShown })
166
- ]
167
- }),
168
- option.recommended === true ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
169
- className: "text-xs text-success",
170
- children: "Recommended"
171
- }) : null,
172
- option.hint === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
173
- className: "text-sm text-muted-foreground",
174
- children: option.hint
175
- }),
176
- isDraft ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
177
- className: "animate-enter text-xs text-subtle",
178
- children: "Hold to send · ⌘↵"
179
- }) : null
180
- ]
181
- })]
182
- });
183
- var useHold = (send) => {
184
- const timer = (0, import_react.useRef)(null);
185
- const [holding, setHolding] = (0, import_react.useState)(null);
186
- const handleEnd = () => {
187
- if (timer.current !== null) {
188
- clearTimeout(timer.current);
189
- timer.current = null;
190
- }
191
- setHolding(null);
192
- };
193
- const handleStart = (value) => {
194
- handleEnd();
195
- setHolding(value);
196
- timer.current = setTimeout(() => {
197
- timer.current = null;
198
- setHolding(null);
199
- send(value);
200
- }, HOLD_MS);
201
- };
202
- return {
203
- holding,
204
- handleStart,
205
- handleEnd
206
- };
207
- };
208
- var Choices = ({ deck, view, live, draft, shown, onDraft }) => {
209
- const sent = live.answers[view.id]?.choice ?? null;
210
- const [justSent, setJustSent] = (0, import_react.useState)(null);
211
- const send = async (value) => {
212
- await sendAnswer(deck, view.id, {
213
- choice: value,
214
- note: live.answers[view.id]?.note ?? ""
215
- });
216
- onDraft(null);
217
- setJustSent(value);
218
- };
219
- const hold = useHold(send);
220
- useWindowEvent("keydown", (event) => {
221
- if (matches(event, SHORTCUTS.submit) && draft !== null) {
222
- event.preventDefault();
223
- send(draft);
224
- }
225
- });
226
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RadioGroup$1, {
227
- "aria-label": "Your call",
228
- onValueChange: (value) => {
229
- const picked = typeof value === "string" ? value : null;
230
- onDraft(picked === sent ? null : picked);
231
- },
232
- value: draft ?? sent ?? "",
233
- children: view.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OptionCard, {
234
- hasJustSent: justSent === option.value,
235
- isDraft: draft === option.value,
236
- isHolding: hold.holding === option.value && sent !== option.value,
237
- isSent: sent === option.value,
238
- isShown: shown === option.value,
239
- onHoldEnd: hold.handleEnd,
240
- onHoldStart: (value) => {
241
- if (value !== sent) hold.handleStart(value);
242
- },
243
- option
244
- }, option.value))
245
- });
246
- };
247
- var AnswerPanel = ({ deck, view, live, draft, shown, onDraft }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("aside", {
248
- className: "flex flex-col gap-4 border-t border-border p-4 xl:fixed xl:inset-y-0 xl:inset-e-0 xl:w-85 xl:overflow-hidden xl:border-s xl:border-t-0 xl:bg-background",
249
- "data-gallery-scope": true,
250
- children: [view.options.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Choices, {
251
- deck,
252
- draft,
253
- live,
254
- onDraft,
255
- shown,
256
- view
257
- }) : null, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Chat, {
258
- deck,
259
- live,
260
- view
261
- })]
262
- });
263
- var getThreadActions = (deck, known) => ({
264
- ...known,
265
- handleReply: async (root, body) => {
266
- await postComment({ data: {
267
- deck,
268
- point: root.point,
269
- revision: root.revision,
270
- path: root.path,
271
- side: root.side,
272
- start: root.start,
273
- end: root.end,
274
- code: root.code,
275
- body,
276
- parent: root.id,
277
- media: root.media ?? null,
278
- time: root.time ?? null,
279
- pinX: root.pinX ?? null,
280
- pinY: root.pinY ?? null
281
- } });
282
- await refreshLive(deck);
283
- },
284
- handleResolve: async (root, resolved) => {
285
- await resolveComment({ data: {
286
- deck,
287
- id: root.id,
288
- resolved
289
- } });
290
- await refreshLive(deck);
291
- }
292
- });
293
- var useLineComments = ({ deck, point, live }) => {
294
- const lines = useLineSelection();
295
- const known = useKnownComments(live.comments);
296
- const revision = getRevision(live, point);
297
- const forFile = (key, path, rows) => {
298
- const state = lines.forFile(key, rows);
299
- return {
300
- ...state,
301
- handlePost: async (body) => {
302
- const picked = state.selected ? getPicked(rows, state.selected) : null;
303
- if (picked === null) return;
304
- const range = {
305
- ...toRange(picked),
306
- code: picked.code
307
- };
308
- await postComment({ data: {
309
- deck,
310
- point,
311
- revision,
312
- path,
313
- ...range,
314
- body,
315
- parent: null
316
- } });
317
- await refreshLive(deck);
318
- lines.clear();
319
- }
320
- };
321
- };
322
- return {
323
- revision,
324
- actions: getThreadActions(deck, known),
325
- forFile
326
- };
327
- };
328
- var CodeBlock = ({ deck, view, live, block, blockIndex }) => {
329
- const { revision, actions, forFile } = useLineComments({
330
- deck,
331
- point: view.id,
332
- live
333
- });
334
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
335
- className: "grid grid-cols-1 gap-3",
336
- children: [block.title === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
337
- className: "m-0 text-sm text-muted-foreground",
338
- children: block.title
339
- }), block.files.map((file) => {
340
- const key = `${String(blockIndex)}:${file.path}`;
341
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DiffFile, {
342
- actions,
343
- deck,
344
- file,
345
- live,
346
- revision,
347
- selection: forFile(key, file.path, file.rows)
348
- }, key);
349
- })]
350
- });
351
- };
352
- var PAIR = 2;
353
- var MIDDLE = 50;
354
- var isPairLabel = (shots) => shots.length === PAIR && /^before/iu.test(shots[0]?.label ?? "") && /^after/iu.test(shots[1]?.label ?? "");
355
- var StoryLink = ({ url }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IconButton, {
356
- label: "Open in Storybook",
357
- nativeButton: false,
358
- render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
359
- "aria-label": "Open in Storybook",
360
- href: url,
361
- rel: "noreferrer",
362
- target: "_blank"
363
- }),
364
- size: "icon-xs",
365
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ExternalLink, {})
366
- });
367
- var ShotPane = ({ shot, src, onOpen: handleOpen }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
368
- className: "flex min-w-0 flex-col overflow-hidden rounded-md border border-border",
369
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
370
- className: "flex min-h-9 items-center justify-between gap-2 border-b border-border bg-wash px-3 py-1 text-xs text-muted-foreground",
371
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: shot.label }), shot.story === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StoryLink, { url: shot.story })]
372
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
373
- className: "grid place-items-center bg-shot p-3",
374
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
375
- className: "cursor-zoom-in hover-outline",
376
- onClick: handleOpen,
377
- type: "button",
378
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", {
379
- alt: shot.alt,
380
- className: "block h-auto max-w-full",
381
- src
382
- })
383
- })
384
- })]
385
- });
386
- var Compare = ({ before, after, story, onOpen: handleOpen }) => {
387
- const frame = (0, import_react.useRef)(null);
388
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
389
- className: "flex min-w-0 flex-col overflow-hidden rounded-md border border-border",
390
- children: [
391
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
392
- className: "flex min-h-9 items-center justify-between gap-4 border-b border-border bg-wash px-3 py-1 text-xs text-muted-foreground",
393
- children: [
394
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: before.label }),
395
- story === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StoryLink, { url: story }),
396
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: after.label })
397
- ]
398
- }),
399
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
400
- className: "grid place-items-center bg-shot p-3",
401
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
402
- className: "group/compare relative grid w-fit",
403
- ref: frame,
404
- children: [
405
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", {
406
- alt: before.label,
407
- className: "col-start-1 row-start-1 block h-auto max-w-full",
408
- src: before.src
409
- }),
410
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", {
411
- alt: after.label,
412
- className: "col-start-1 row-start-1 block h-auto max-w-full compare-after",
413
- src: after.src
414
- }),
415
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
416
- "aria-hidden": true,
417
- className: "pointer-events-none absolute inset-y-0 compare-divider w-0.5 bg-accent group-hover/compare:w-1"
418
- }),
419
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
420
- "aria-label": "Drag to compare before and after",
421
- className: "absolute inset-0 m-0 size-full cursor-ew-resize opacity-0",
422
- defaultValue: MIDDLE,
423
- max: 100,
424
- min: 0,
425
- onInput: (event) => frame.current?.style.setProperty("--split", `${event.currentTarget.value}%`),
426
- type: "range"
427
- })
428
- ]
429
- })
430
- }),
431
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
432
- className: "flex items-center justify-between border-t border-border px-3 py-1 text-xs text-muted-foreground",
433
- children: [
434
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Before" }),
435
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IconButton, {
436
- label: "Full size",
437
- onClick: handleOpen,
438
- size: "icon-xs",
439
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Maximize2, {})
440
- }),
441
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "After" })
442
- ]
443
- })
444
- ]
445
- });
446
- };
447
- var useSameSize = () => {
448
- const [sizes, setSizes] = (0, import_react.useState)({});
449
- const onLoad = (index) => (event) => {
450
- const { naturalWidth, naturalHeight } = event.currentTarget;
451
- setSizes((previous) => ({
452
- ...previous,
453
- [index]: `${String(naturalWidth)}x${String(naturalHeight)}`
454
- }));
455
- };
456
- return {
457
- isSame: sizes[0] !== void 0 && sizes[0] === sizes[1],
458
- onLoad
459
- };
460
- };
461
- var MediaBlock = ({ deck, block }) => {
462
- const openGallery = useOpenGallery();
463
- const images = block.shots.map((shot) => ({
464
- src: toDeckSrc(deck, shot.src),
465
- label: shot.label
466
- }));
467
- const { isSame, onLoad } = useSameSize();
468
- const [before, after] = images;
469
- const isPair = isPairLabel(block.shots);
470
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("figure", {
471
- className: "m-0 grid grid-cols-1 gap-2",
472
- children: [
473
- block.title === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("figcaption", {
474
- className: "text-sm text-muted-foreground",
475
- children: block.title
476
- }),
477
- isPair && isSame && before && after ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Compare, {
478
- after,
479
- before,
480
- onOpen: () => {
481
- openGallery([images], 0);
482
- },
483
- story: block.shots.find((shot) => shot.story !== void 0)?.story
484
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
485
- className: "grid grid-cols-1 gap-3 sm:grid-cols-2",
486
- children: block.shots.map((shot, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ShotPane, {
487
- onOpen: () => {
488
- openGallery(images.map((image) => [image]), index);
489
- },
490
- shot,
491
- src: images[index]?.src ?? ""
492
- }, shot.src))
493
- }),
494
- isPair ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
495
- className: "hidden",
496
- children: images.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", {
497
- alt: "",
498
- onLoad: onLoad(index),
499
- src: image.src
500
- }, image.src))
501
- }) : null
502
- ]
503
- });
504
- };
505
- var getMediaThreads = (comments, media) => comments.filter((comment) => comment.parent === null && comment.media === media).toSorted((left, right) => (left.time ?? 0) - (right.time ?? 0) || left.at.localeCompare(right.at)).map((root) => ({
506
- root,
507
- replies: comments.filter((comment) => comment.parent === root.id),
508
- isOutdated: false
509
- }));
510
- var MediaComments = ({ deck, point, live, media, placeholder, getAnchor, onPosted: handlePosted, onSelect: handleSelect }) => {
511
- const revision = getRevision(live, point);
512
- const threads = getMediaThreads(live.comments, media);
513
- const actions = getThreadActions(deck, useKnownComments(live.comments));
514
- const post = async (body) => {
515
- await postComment({ data: {
516
- deck,
517
- point,
518
- revision,
519
- path: null,
520
- side: "new",
521
- start: null,
522
- end: null,
523
- code: "",
524
- body,
525
- parent: null,
526
- media,
527
- ...getAnchor()
528
- } });
529
- handlePosted?.();
530
- await refreshLive(deck);
531
- };
532
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
533
- className: "grid gap-2",
534
- children: [threads.map((thread, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
535
- className: "grid gap-1",
536
- children: [handleSelect === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Hint, {
537
- label: "Show this spot on the snapshot",
538
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
539
- className: "w-fit text-xs hover-text",
540
- onClick: () => {
541
- handleSelect(thread.root);
542
- },
543
- type: "button",
544
- children: `#${String(index + 1)} · show`
545
- })
546
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LineThread, {
547
- actions,
548
- deck,
549
- live,
550
- revision,
551
- thread
552
- })]
553
- }, thread.root.id)), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CommentForm, {
554
- deck,
555
- onSubmit: post,
556
- placeholder,
557
- submitLabel: "Comment"
558
- })]
559
- });
560
- };
561
- var SourceRows = ({ rows, offset, selection, byRow, ...shared }) => rows.map((row, at) => {
562
- const index = offset + at;
563
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
564
- className: "contents",
565
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(LineRow, {
566
- index,
567
- row,
568
- selection,
569
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
570
- className: "diff-sticky diff-at-old pe-3 text-end text-subtle tabular-nums select-none",
571
- children: row.new
572
- })
573
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RowThreads, {
574
- index,
575
- selection,
576
- threads: byRow.get(index) ?? [],
577
- ...shared
578
- })]
579
- }, `${String(row.new)}-${row.code}`);
580
- });
581
- var SourceCode = ({ rows, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
582
- className: "min-w-0 overflow-x-auto overscroll-x-contain py-2 font-mono text-xs/relaxed sm:text-sm/relaxed",
583
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
584
- className: "grid w-max min-w-full source-rows",
585
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SourceRows, {
586
- ...rest,
587
- offset: 0,
588
- rows
589
- })
590
- })
591
- });
592
- var TestSource = ({ deck, point, live, source }) => {
593
- const { revision, actions, forFile } = useLineComments({
594
- deck,
595
- point,
596
- live
597
- });
598
- const name = source.path.split("/").at(-1) ?? source.path;
599
- const { byRow, loose } = placeThreads(source.rows, {
600
- comments: live.comments.filter((comment) => comment.point === point),
601
- path: source.path,
602
- revision
603
- });
604
- const shared = {
605
- deck,
606
- live,
607
- revision,
608
- actions
609
- };
610
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
611
- "aria-label": "Test source",
612
- className: "grid grid-cols-1 border-y border-border",
613
- children: [
614
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
615
- className: "flex border-b border-border bg-wash px-3 py-2 font-mono text-xs text-subtle",
616
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Hint, {
617
- label: source.path,
618
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
619
- className: "min-w-0 truncate tabular-nums",
620
- children: `${name}:${String(source.start)}`
621
- })
622
- })
623
- }),
624
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SourceCode, {
625
- byRow,
626
- rows: source.rows,
627
- selection: forFile(source.path, source.path, source.rows),
628
- ...shared
629
- }),
630
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LooseThreads, {
631
- threads: loose,
632
- ...shared
633
- })
634
- ]
635
- });
636
- };
637
- var PRECISION = 10;
638
- var playFrom = async (element, time) => {
639
- element.currentTime = time;
640
- try {
641
- await element.play();
642
- } catch {
643
- element.pause();
644
- }
645
- };
646
- var RecordingComments = ({ deck, point, live, media, video }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MediaComments, {
647
- deck,
648
- getAnchor: () => ({
649
- time: Math.round((video.current?.currentTime ?? 0) * PRECISION) / PRECISION,
650
- pinX: null,
651
- pinY: null
652
- }),
653
- live,
654
- media,
655
- onSelect: (root) => {
656
- if (video.current && typeof root.time === "number") playFrom(video.current, root.time);
657
- },
658
- placeholder: "Pause where something looks off, then comment on that moment",
659
- point
660
- });
661
- var RecordingBlock = ({ deck, point, live, block }) => {
662
- const video = (0, import_react.useRef)(null);
663
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("figure", {
664
- className: "m-0 grid grid-cols-1 gap-2 rounded-md border border-border",
665
- children: [
666
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("figcaption", {
667
- className: "grid gap-0.5 border-b border-border bg-wash px-3 py-2",
668
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
669
- className: "text-sm text-foreground",
670
- children: block.title
671
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
672
- className: "font-mono text-xs text-muted-foreground",
673
- children: `${block.spec} · ${block.pr}`
674
- })]
675
- }),
676
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
677
- className: "grid place-items-center bg-black",
678
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("video", {
679
- className: "block h-auto video-height w-full",
680
- controls: true,
681
- poster: block.poster === void 0 ? void 0 : toDeckSrc(deck, block.poster),
682
- preload: "metadata",
683
- ref: video,
684
- src: toDeckSrc(deck, block.video),
685
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("track", { kind: "captions" })
686
- })
687
- }),
688
- block.source === null ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TestSource, {
689
- deck,
690
- live,
691
- point,
692
- source: block.source
693
- }),
694
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
695
- className: "px-3 pb-3",
696
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecordingComments, {
697
- deck,
698
- live,
699
- media: block.video,
700
- point,
701
- video
702
- })
703
- })
704
- ]
705
- });
706
- };
707
- var NESTED = " > ";
708
- var SPLIT = /^(?<when>when\s.+?)\s+(?<then>then\s.+)$/isu;
709
- var THEN = /^then\s/iu;
710
- var splitNested = (title) => {
711
- const parts = title.split(NESTED).map((part) => part.trim());
712
- const then = parts.at(-1) ?? "";
713
- const when = parts.slice(0, -1).join(" › ");
714
- return parts.length > 1 && THEN.test(then) && when !== "" ? {
715
- whenLine: when,
716
- thenLine: then
717
- } : null;
718
- };
719
- var splitFlat = (title) => {
720
- const groups = SPLIT.exec(title)?.groups;
721
- return groups?.["when"] === void 0 || groups["then"] === void 0 ? null : {
722
- whenLine: groups["when"],
723
- thenLine: groups["then"]
724
- };
725
- };
726
- var parseRecordingTitle = (title) => {
727
- const trimmed = title.trim();
728
- return splitNested(trimmed) ?? splitFlat(trimmed) ?? {
729
- whenLine: null,
730
- thenLine: trimmed
731
- };
732
- };
733
- var SpecLink = ({ block }) => {
734
- const { editor } = useReviewPrefs();
735
- const line = block.source?.start ?? 1;
736
- const href = getEditorLink({
737
- worktree: block.worktree,
738
- path: block.file,
739
- isDeleted: false,
740
- editor
741
- }, line);
742
- if (href === null) return null;
743
- const label = `Open ${block.spec}:${String(line)} in ${EDITOR_NAMES[editor]}`;
744
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IconButton, {
745
- label,
746
- nativeButton: false,
747
- render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
748
- "aria-label": label,
749
- href,
750
- onClick: (event) => {
751
- event.preventDefault();
752
- openInEditor(href, getFolderLink(block.worktree, editor));
753
- },
754
- rel: "noopener"
755
- }),
756
- size: "icon-xs",
757
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SquareArrowOutUpRight, {})
758
- });
759
- };
760
- var RecordingPanel = ({ deck, point, live, block, video }) => {
761
- const { whenLine, thenLine } = parseRecordingTitle(block.title);
762
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("aside", {
763
- "aria-label": "Recording",
764
- className: "pointer-events-auto flex recording-panel flex-col overflow-hidden rounded-md border border-border bg-background",
765
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", {
766
- className: "flex shrink-0 items-start gap-3 bg-wash py-3 ps-4 pe-3",
767
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
768
- className: "grid min-w-0 flex-1 gap-1 wrap-anywhere",
769
- children: [
770
- whenLine === null ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
771
- className: "m-0 text-xs/5 text-muted-foreground",
772
- children: whenLine
773
- }),
774
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
775
- className: "m-0 text-sm/5 font-medium text-foreground",
776
- children: thenLine
777
- }),
778
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
779
- className: "m-0 truncate pt-1 font-mono text-xs text-subtle",
780
- children: block.source === null ? `${block.spec} · ${block.pr}` : block.pr
781
- })
782
- ]
783
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SpecLink, { block })]
784
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
785
- className: "min-h-0 flex-1 overflow-auto overscroll-contain",
786
- children: [block.source === null ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TestSource, {
787
- deck,
788
- live,
789
- point,
790
- source: block.source
791
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
792
- className: cn("px-4 py-3", block.source === null && "border-t border-border"),
793
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecordingComments, {
794
- deck,
795
- live,
796
- media: block.video,
797
- point,
798
- video
799
- })
800
- })]
801
- })]
802
- });
803
- };
804
- var RecordingLightbox = ({ deck, point, live, blocks, index, onIndex: handleIndex, onClose: handleClose }) => {
805
- const video = (0, import_react.useRef)(null);
806
- const block = blocks[index];
807
- if (block === void 0) return null;
808
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GalleryFrame, {
809
- count: blocks.length,
810
- index,
811
- noun: "recording",
812
- onClose: handleClose,
813
- onIndex: handleIndex,
814
- title: block.title,
815
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
816
- className: "pointer-events-none relative recording-stage",
817
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
818
- className: "pointer-events-auto grid place-items-center overflow-hidden rounded-md border border-border bg-black",
819
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("video", {
820
- autoPlay: true,
821
- className: "block h-auto recording-fit w-full",
822
- controls: true,
823
- "data-recording-video": true,
824
- muted: true,
825
- playsInline: true,
826
- poster: block.poster === void 0 ? void 0 : toDeckSrc(deck, block.poster),
827
- preload: "auto",
828
- ref: video,
829
- src: toDeckSrc(deck, block.video),
830
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("track", { kind: "captions" })
831
- }, block.video)
832
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecordingPanel, {
833
- block,
834
- deck,
835
- live,
836
- point,
837
- video
838
- })]
839
- })
840
- });
841
- };
842
- var SECONDS_PER_MINUTE = 60;
843
- var PAD = 2;
844
- var formatSeconds = (seconds) => {
845
- const whole = Math.max(1, Math.floor(seconds));
846
- return `${String(Math.floor(whole / SECONDS_PER_MINUTE))}:${String(whole % SECONDS_PER_MINUTE).padStart(PAD, "0")}`;
847
- };
848
- var isOnSource = (comment, block) => {
849
- const first = block.source?.start ?? 0;
850
- const last = first + (block.source?.rows.length ?? 0) - 1;
851
- const line = comment.start ?? first - 1;
852
- return (comment.media ?? null) === null && comment.path === block.file && line >= first && line <= last;
853
- };
854
- var countComments = (live, point, block) => live.comments.filter((comment) => comment.parent === null && comment.point === point && comment.resolved !== true && (comment.media === block.video || isOnSource(comment, block))).length;
855
- var isSameWhen = (left, right) => right.title.whenLine !== null && left?.title.whenLine === right.title.whenLine;
856
- var toGroups = (entries) => {
857
- const groups = [];
858
- for (const entry of entries) {
859
- const last = groups.at(-1);
860
- if (last !== void 0 && isSameWhen(last.entries.at(-1), entry)) last.entries.push(entry);
861
- else groups.push({
862
- when: entry.title.whenLine,
863
- entries: [entry]
864
- });
865
- }
866
- return groups;
867
- };
868
- var toSections = (entries) => {
869
- const sections = [];
870
- for (const group of toGroups(entries)) {
871
- const last = sections.at(-1);
872
- if (group.entries.length > 1) sections.push(group);
873
- else if (last?.when === null) last.entries.push(...group.entries);
874
- else sections.push({
875
- when: null,
876
- entries: group.entries
877
- });
878
- }
879
- return sections;
880
- };
881
- var Poster = ({ deck, block }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
882
- className: "relative block aspect-16/10 overflow-hidden rounded-md border border-border bg-wash hover-outline-group",
883
- children: [
884
- block.poster === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", {
885
- alt: "",
886
- className: "block size-full object-cover",
887
- decoding: "async",
888
- loading: "lazy",
889
- src: toDeckSrc(deck, block.poster)
890
- }),
891
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
892
- "aria-hidden": true,
893
- className: "absolute inset-0 grid place-items-center opacity-80 transition-opacity duration-150 ease-out group-hover:opacity-100 group-focus-visible:opacity-100",
894
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
895
- className: "grid size-9 place-items-center rounded-full border border-border bg-overlay text-foreground",
896
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Play, { className: "size-3.5 translate-x-px fill-current" })
897
- })
898
- }),
899
- block.seconds === null ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
900
- className: "absolute inset-e-1.5 bottom-1.5 rounded-sm bg-overlay px-1.5 font-mono text-xs/5 text-foreground tabular-nums",
901
- children: formatSeconds(block.seconds)
902
- })
903
- ]
904
- });
905
- var Thumb = ({ deck, entry, isGrouped, onOpen: handleOpen }) => {
906
- const { block, title, comments } = entry;
907
- const commentLabel = `${String(comments)} ${comments === 1 ? "comment" : "comments"}`;
908
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", {
909
- className: "min-w-0",
910
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
911
- "aria-label": `Play ${block.title}${comments === 0 ? "" : `, ${commentLabel}`}`,
912
- className: "group grid w-full gap-2 rounded-md text-start outline-none",
913
- "data-recording-thumb": true,
914
- onClick: () => {
915
- handleOpen(entry.index);
916
- },
917
- type: "button",
918
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Poster, {
919
- block,
920
- deck
921
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
922
- className: "grid gap-0.5 px-0.5",
923
- children: [
924
- isGrouped || title.whenLine === null ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
925
- className: "line-clamp-2 text-xs/4 text-muted-foreground",
926
- children: title.whenLine
927
- }),
928
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
929
- className: "line-clamp-3 text-sm/5 text-foreground",
930
- children: title.thenLine
931
- }),
932
- comments === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
933
- className: "flex items-center gap-1 pt-0.5 text-xs text-subtle tabular-nums",
934
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(MessageSquare, {
935
- "aria-hidden": true,
936
- className: "size-3"
937
- }), comments]
938
- })
939
- ]
940
- })]
941
- })
942
- });
943
- };
944
- var ThumbList = ({ deck, entries, isGrouped, onOpen }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
945
- className: "m-0 grid list-none grid-cols-1 gap-x-4 gap-y-5 p-0 @sm:grid-cols-2 @xl:grid-cols-3 @4xl:grid-cols-4",
946
- children: entries.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Thumb, {
947
- deck,
948
- entry,
949
- isGrouped,
950
- onOpen
951
- }, entry.block.video))
952
- });
953
- var getSpecs = (blocks) => [...new Set(blocks.map((block) => block.spec))].join(" · ");
954
- var getPulls = (blocks) => [...new Set(blocks.map((block) => block.pr))].join(" · ");
955
- var RecordingGrid = ({ deck, point, live, blocks }) => {
956
- const [open, setOpen] = (0, import_react.useState)(null);
957
- const entries = blocks.map((block, index) => ({
958
- block,
959
- index,
960
- title: parseRecordingTitle(block.title),
961
- comments: countComments(live, point, block)
962
- }));
963
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
964
- "aria-label": "Recordings",
965
- className: "@container grid grid-cols-1 rounded-md border border-border",
966
- "data-recording-grid": true,
967
- children: [
968
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", {
969
- className: "flex min-w-0 items-center gap-2 border-b border-border bg-wash px-3 py-2",
970
- children: [
971
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
972
- className: "text-sm text-foreground",
973
- children: "Recordings"
974
- }),
975
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
976
- className: "rounded-full bg-secondary px-1.5 text-xs/5 text-muted-foreground tabular-nums",
977
- children: blocks.length
978
- }),
979
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
980
- className: "ms-auto min-w-0 truncate font-mono text-xs text-muted-foreground",
981
- children: `${getSpecs(blocks)} · ${getPulls(blocks)}`
982
- })
983
- ]
984
- }),
985
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
986
- className: "grid gap-5 p-3",
987
- children: toSections(entries).map((section) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
988
- className: "grid gap-2.5",
989
- children: [section.when === null ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", {
990
- className: "m-0 text-xs font-medium text-muted-foreground",
991
- children: section.when
992
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThumbList, {
993
- deck,
994
- entries: section.entries,
995
- isGrouped: section.when !== null,
996
- onOpen: setOpen
997
- })]
998
- }, section.entries[0]?.block.video))
999
- }),
1000
- open === null ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecordingLightbox, {
1001
- blocks,
1002
- deck,
1003
- index: open,
1004
- live,
1005
- onClose: () => {
1006
- setOpen(null);
1007
- },
1008
- onIndex: setOpen,
1009
- point
1010
- })
1011
- ]
1012
- });
1013
- };
1014
- var PERCENT = 100;
1015
- var toFraction = (offset, size) => Math.min(1, Math.max(0, offset / size));
1016
- var toPin = (event) => {
1017
- const box = event.currentTarget.getBoundingClientRect();
1018
- return {
1019
- pinX: toFraction(event.clientX - box.left, box.width),
1020
- pinY: toFraction(event.clientY - box.top, box.height)
1021
- };
1022
- };
1023
- var placeAt = ({ pinX, pinY }) => (node) => {
1024
- node?.style.setProperty("--pin-left", `${String(pinX * PERCENT)}%`);
1025
- node?.style.setProperty("--pin-top", `${String(pinY * PERCENT)}%`);
1026
- };
1027
- var Marker = ({ pin, label, isDraft = false }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1028
- "aria-hidden": true,
1029
- className: isDraft ? "pointer-events-none absolute inset-s-(--pin-left) top-(--pin-top) grid size-6 -translate-1/2 place-items-center rounded-full border-2 border-accent bg-background text-xs text-foreground" : "pointer-events-none absolute inset-s-(--pin-left) top-(--pin-top) grid size-6 -translate-1/2 place-items-center rounded-full bg-accent text-xs text-white",
1030
- ref: placeAt(pin),
1031
- children: label
1032
- });
1033
- var StoryBlock = ({ deck, point, live, block }) => {
1034
- const [pin, setPin] = (0, import_react.useState)(null);
1035
- const openGallery = useOpenGallery();
1036
- const src = toDeckSrc(deck, block.image);
1037
- const pins = getMediaThreads(live.comments, block.image).flatMap((thread, index) => typeof thread.root.pinX === "number" && typeof thread.root.pinY === "number" ? [{
1038
- pin: {
1039
- pinX: thread.root.pinX,
1040
- pinY: thread.root.pinY
1041
- },
1042
- label: String(index + 1)
1043
- }] : []);
1044
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("figure", {
1045
- className: "m-0 grid grid-cols-1 gap-2 rounded-md border border-border",
1046
- children: [
1047
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("figcaption", {
1048
- className: "flex items-center justify-between gap-3 border-b border-border bg-wash px-3 py-2 text-xs text-muted-foreground",
1049
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1050
- className: "min-w-0 truncate",
1051
- children: `${block.component} · ${block.title}`
1052
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
1053
- className: "-my-1 flex shrink-0 gap-0.5",
1054
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(IconButton, {
1055
- label: "Full size",
1056
- onClick: () => {
1057
- openGallery([[{
1058
- src,
1059
- label: block.title
1060
- }]], 0);
1061
- },
1062
- size: "icon-xs",
1063
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Maximize2, {})
1064
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IconButton, {
1065
- label: "Open in Storybook",
1066
- nativeButton: false,
1067
- render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
1068
- "aria-label": "Open in Storybook",
1069
- href: block.url,
1070
- rel: "noreferrer",
1071
- target: "_blank"
1072
- }),
1073
- size: "icon-xs",
1074
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ExternalLink, {})
1075
- })]
1076
- })]
1077
- }),
1078
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1079
- className: "grid place-items-center bg-shot p-3",
1080
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
1081
- "aria-label": "Pin a comment on this snapshot",
1082
- className: "relative block cursor-crosshair hover-outline",
1083
- onClick: (event) => {
1084
- setPin(toPin(event));
1085
- },
1086
- type: "button",
1087
- children: [
1088
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", {
1089
- alt: `${block.component}, ${block.title}`,
1090
- className: "block h-auto max-w-full",
1091
- src
1092
- }),
1093
- pins.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Marker, {
1094
- label: entry.label,
1095
- pin: entry.pin
1096
- }, entry.label)),
1097
- pin === null ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Marker, {
1098
- isDraft: true,
1099
- label: "+",
1100
- pin
1101
- })
1102
- ]
1103
- })
1104
- }),
1105
- block.source === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
1106
- className: "m-0 px-3 text-xs text-subtle",
1107
- children: block.source
1108
- }),
1109
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1110
- className: "px-3 pb-3",
1111
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MediaComments, {
1112
- deck,
1113
- getAnchor: () => ({
1114
- time: null,
1115
- pinX: pin?.pinX ?? null,
1116
- pinY: pin?.pinY ?? null
1117
- }),
1118
- live,
1119
- media: block.image,
1120
- onPosted: () => {
1121
- setPin(null);
1122
- },
1123
- placeholder: pin === null ? "Comment on this snapshot, or click it to pin a spot" : "Comment on the pinned spot",
1124
- point
1125
- })
1126
- })
1127
- ]
1128
- });
1129
- };
1130
- var Segment = ({ segment }) => {
1131
- if (segment.op === "del") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("del", {
1132
- className: "text-sign-del decoration-sign-del",
1133
- children: segment.text
1134
- });
1135
- if (segment.op === "add") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ins", {
1136
- className: "rounded-sm bg-line-add px-0.5 text-sign-add no-underline",
1137
- children: segment.text
1138
- });
1139
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1140
- className: "text-subtle",
1141
- children: segment.text
1142
- });
1143
- };
1144
- var WordingBlock = ({ block }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1145
- className: "grid grid-cols-1 gap-3",
1146
- children: [block.title === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
1147
- className: "m-0 text-sm text-muted-foreground",
1148
- children: block.title
1149
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
1150
- className: "m-0 list-none overflow-hidden rounded-md border border-border p-0",
1151
- children: block.rows.map((row, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
1152
- className: "flex flex-col gap-0.5 border-b border-border px-3 py-2 transition-colors duration-150 ease-out last:border-b-0 hover:bg-row-hover sm:flex-row sm:gap-3",
1153
- children: [row.label === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1154
- className: "shrink-0 text-xs/6 text-subtle tabular-nums sm:w-20",
1155
- children: row.label
1156
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
1157
- className: "m-0 min-w-0 text-sm/6 wrap-break-word",
1158
- children: row.segments.map((segment, segmentIndex) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Segment, { segment }, `${String(segmentIndex)}-${segment.op}`))
1159
- })]
1160
- }, `${String(index)}-${row.label ?? ""}`))
1161
- })]
1162
- });
1163
- var PlainBlock = ({ deck, block }) => {
1164
- if (block.kind === "media") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MediaBlock, {
1165
- block,
1166
- deck
1167
- });
1168
- if (block.kind === "wording") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(WordingBlock, { block });
1169
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Markdown, {
1170
- className: "border-s-2 border-foreground ps-3",
1171
- deck,
1172
- text: block.markdown
1173
- });
1174
- };
1175
- var GRID_FROM = 3;
1176
- var isRecording = (block) => block.kind === "recording";
1177
- var toRuns = (blocks) => {
1178
- const isGrid = blocks.filter((block) => isRecording(block)).length >= GRID_FROM;
1179
- return blocks.reduce((runs, block, index) => {
1180
- const last = runs.at(-1);
1181
- if (!isGrid || !isRecording(block)) return [...runs, {
1182
- block,
1183
- index
1184
- }];
1185
- if (last !== void 0 && "recordings" in last && last.index + last.recordings.length === index) {
1186
- last.recordings.push(block);
1187
- return runs;
1188
- }
1189
- return [...runs, {
1190
- recordings: [block],
1191
- index
1192
- }];
1193
- }, []);
1194
- };
1195
- var OneBlock = ({ deck, view, live, block, index }) => {
1196
- if (block.kind === "code") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CodeBlock, {
1197
- block,
1198
- blockIndex: index,
1199
- deck,
1200
- live,
1201
- view
1202
- });
1203
- if (block.kind === "review") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReviewBlock, {
1204
- stub: block,
1205
- blockIndex: index,
1206
- deck,
1207
- live,
1208
- view
1209
- });
1210
- if (block.kind === "story") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StoryBlock, {
1211
- block,
1212
- deck,
1213
- live,
1214
- point: view.id
1215
- });
1216
- if (block.kind === "recording") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecordingBlock, {
1217
- block,
1218
- deck,
1219
- live,
1220
- point: view.id
1221
- });
1222
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PlainBlock, {
1223
- block,
1224
- deck
1225
- });
1226
- };
1227
- var getBlockKey = (block, index) => {
1228
- if (block.kind === "review") return `review-${block.branch}`;
1229
- if (block.kind === "story") return `story-${block.storyId}`;
1230
- return block.kind === "recording" ? `recording-${block.video}` : `${block.kind}-${String(index)}`;
1231
- };
1232
- var Blocks = ({ deck, view, live, blocks }) => toRuns(blocks).map((run) => "recordings" in run ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecordingGrid, {
1233
- blocks: run.recordings,
1234
- deck,
1235
- live,
1236
- point: view.id
1237
- }, `recordings-${run.recordings[0]?.video ?? String(run.index)}`) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OneBlock, {
1238
- block: run.block,
1239
- deck,
1240
- index: run.index,
1241
- live,
1242
- view
1243
- }, getBlockKey(run.block, run.index)));
1244
- var toShowing = (view, shown) => shown?.blocks === void 0 ? {
1245
- key: "",
1246
- label: null,
1247
- blocks: view.blocks
1248
- } : {
1249
- key: shown.value,
1250
- label: shown.label,
1251
- blocks: [...view.blocks.filter((block) => block.kind !== "code" && block.kind !== "review"), ...shown.blocks]
1252
- };
1253
- var useCrossFade = (showing) => {
1254
- const [current, setCurrent] = (0, import_react.useState)(showing);
1255
- const [leaving, setLeaving] = (0, import_react.useState)(null);
1256
- if (current.key !== showing.key) {
1257
- setLeaving(current);
1258
- setCurrent(showing);
1259
- }
1260
- return {
1261
- leaving,
1262
- handleLeft: () => {
1263
- setLeaving(null);
1264
- }
1265
- };
1266
- };
1267
- var ShowingBlocks = ({ deck, view, live, showing }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [showing.label === null ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
1268
- className: "m-0 text-xs text-subtle",
1269
- children: ["Showing: ", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1270
- className: "text-muted-foreground",
1271
- children: showing.label
1272
- })]
1273
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blocks, {
1274
- blocks: showing.blocks,
1275
- deck,
1276
- live,
1277
- view
1278
- })] });
1279
- var SwappedBlocks = (props) => {
1280
- const { leaving, handleLeft } = useCrossFade(props.showing);
1281
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1282
- className: "grid grid-cols-1",
1283
- children: [leaving === null ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1284
- "aria-hidden": true,
1285
- className: "pointer-events-none col-start-1 row-start-1 grid animate-fade-out grid-cols-1 content-start gap-4",
1286
- inert: true,
1287
- onAnimationEnd: (event) => {
1288
- if (event.target === event.currentTarget) handleLeft();
1289
- },
1290
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ShowingBlocks, {
1291
- ...props,
1292
- showing: leaving
1293
- })
1294
- }, `leaving-${leaving.key}`), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1295
- className: cn("col-start-1 row-start-1 grid grid-cols-1 content-start gap-4", leaving !== null && "animate-fade-in"),
1296
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ShowingBlocks, { ...props })
1297
- }, `shown-${props.showing.key}`)]
1298
- });
1299
- };
1300
- var Slide = ({ deck, view, live, shown }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", {
1301
- className: "mx-auto grid max-w-228 animate-enter grid-cols-1 gap-4",
1302
- "data-gallery-scope": true,
1303
- children: [
1304
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
1305
- className: "m-0 text-sm text-muted-foreground",
1306
- children: view.sectionTitle
1307
- }),
1308
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", {
1309
- className: "m-0 text-2xl/tight font-semibold tracking-tight",
1310
- children: view.title
1311
- }),
1312
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Markdown, {
1313
- className: "[&>*:not(.deck-table-scroll)]:max-w-prose",
1314
- deck,
1315
- text: view.prose
1316
- }),
1317
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SwappedBlocks, {
1318
- deck,
1319
- live,
1320
- showing: toShowing(view, shown),
1321
- view
1322
- })
1323
- ]
1324
- });
1325
- function Separator$1({ className, orientation = "horizontal", ...props }) {
1326
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Separator, {
1327
- "data-slot": "separator",
1328
- orientation,
1329
- className: cn("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch", className),
1330
- ...props
1331
- });
1332
- }
1333
- var PointMenu = ({ deck, point, onCopyLink: handleCopyLink }) => {
1334
- const toast = useToast();
1335
- const copy = async (text, title) => {
1336
- await navigator.clipboard.writeText(text);
1337
- toast.add({ title });
1338
- };
1339
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DropdownMenu, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DropdownMenuTrigger, {
1340
- render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IconButton, {
1341
- label: "More actions",
1342
- variant: "ghost"
1343
- }),
1344
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Ellipsis, {})
1345
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DropdownMenuContent, { children: [
1346
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DropdownMenuItem, {
1347
- onClick: () => {
1348
- handleCopyLink();
1349
- },
1350
- children: [
1351
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Link, {}),
1352
- "Copy link",
1353
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DropdownMenuShortcut, { children: SHORTCUTS.copyLink.keys.join("") })
1354
- ]
1355
- }),
1356
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DropdownMenuItem, {
1357
- onClick: () => {
1358
- copy(point, "Point id copied");
1359
- },
1360
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Copy, {}), "Copy point id"]
1361
- }),
1362
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DropdownMenuItem, {
1363
- onClick: () => {
1364
- copy(`~/review-decks/${deck}/points/${point}.md`, "File path copied");
1365
- },
1366
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(FileText, {}), "Copy point file path"]
1367
- })
1368
- ] })] });
1369
- };
1370
- var TopBar = ({ summary, view, live, index, hasNextOpen, onStep: handleStep, onNextOpen: handleNextOpen, onCopyLink: handleCopyLink }) => {
1371
- const answered = summary.points.filter((point) => Boolean(live.answers[point.id]?.choice)).length;
1372
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", {
1373
- className: "sticky top-0 z-10 flex h-14 items-center gap-1 border-b border-border bg-background px-3 xl:ms-70 xl:me-85",
1374
- children: [
1375
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IconButton, {
1376
- disabled: index <= 0,
1377
- label: "Previous point",
1378
- onClick: () => {
1379
- handleStep(-1);
1380
- },
1381
- shortcut: SHORTCUTS.previous,
1382
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ArrowLeft, {})
1383
- }),
1384
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
1385
- className: "min-w-16 text-center text-sm text-muted-foreground tabular-nums",
1386
- children: [
1387
- index + 1,
1388
- " / ",
1389
- summary.points.length
1390
- ]
1391
- }),
1392
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IconButton, {
1393
- disabled: index >= summary.points.length - 1,
1394
- label: "Next point",
1395
- onClick: () => {
1396
- handleStep(1);
1397
- },
1398
- shortcut: SHORTCUTS.next,
1399
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ArrowRight, {})
1400
- }),
1401
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1402
- className: "mx-1 flex h-5",
1403
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Separator$1, { orientation: "vertical" })
1404
- }),
1405
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IconButton, {
1406
- disabled: !hasNextOpen,
1407
- label: "Next point waiting for you",
1408
- onClick: handleNextOpen,
1409
- shortcut: SHORTCUTS.nextOpen,
1410
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChevronsRight, {})
1411
- }),
1412
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
1413
- className: "ms-auto me-2 text-sm text-muted-foreground tabular-nums",
1414
- children: [
1415
- answered,
1416
- " of ",
1417
- summary.points.length,
1418
- " answered"
1419
- ]
1420
- }),
1421
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PointMenu, {
1422
- deck: summary.name,
1423
- onCopyLink: handleCopyLink,
1424
- point: view.id
1425
- })
1426
- ]
1427
- });
1428
- };
1429
- var useDraft = (point) => {
1430
- const [draft, setDraft] = (0, import_react.useState)(null);
1431
- if (draft !== null && draft.point !== point) setDraft(null);
1432
- const handleDraft = (value) => {
1433
- setDraft(value === null ? null : {
1434
- point,
1435
- value
1436
- });
1437
- };
1438
- return {
1439
- draft: draft?.point === point ? draft.value : null,
1440
- handleDraft
1441
- };
1442
- };
1443
- var getShownOption = (view, draft, sent) => {
1444
- const shown = draft ?? sent;
1445
- return view.options.find((option) => option.value === shown) ?? view.options.find((option) => option.recommended === true) ?? null;
1446
- };
1447
- var useCopyLink = () => {
1448
- const toast = useToast();
1449
- return async () => {
1450
- await navigator.clipboard.writeText(globalThis.location.href);
1451
- toast.add({ title: "Link copied" });
1452
- };
1453
- };
1454
- var usePointSteps = (summary, point, live) => {
1455
- const navigate = useNavigate();
1456
- const copyLink = useCopyLink();
1457
- const index = summary.points.findIndex((candidate) => candidate.id === point);
1458
- const next = getNextOpen(summary.points, live, point);
1459
- const goTo = (target) => {
1460
- if (target !== void 0) navigate({
1461
- to: "/decks/$deck/$point",
1462
- params: {
1463
- deck: summary.name,
1464
- point: target
1465
- }
1466
- });
1467
- };
1468
- const step = (offset) => {
1469
- goTo(summary.points[index + offset]?.id);
1470
- };
1471
- useWindowEvent("keydown", (event) => {
1472
- if (isTyping(event.target) || isOverlayOpen()) return;
1473
- if (matches(event, SHORTCUTS.previous) || matches(event, SHORTCUTS.next)) step(event.key === "ArrowLeft" ? -1 : 1);
1474
- if (matches(event, SHORTCUTS.nextOpen)) goTo(next?.id);
1475
- if (matches(event, SHORTCUTS.copyLink)) copyLink();
1476
- });
1477
- return {
1478
- index,
1479
- hasNextOpen: next !== void 0,
1480
- handleStep: step,
1481
- handleNextOpen: () => {
1482
- goTo(next?.id);
1483
- },
1484
- handleCopyLink: copyLink
1485
- };
1486
- };
1487
- var deckRoute = getRouteApi("/decks/$deck");
1488
- var pointRoute = getRouteApi("/decks/$deck/$point");
1489
- var PointPage = () => {
1490
- const view = pointRoute.useLoaderData();
1491
- const { summary, live: initial } = deckRoute.useLoaderData();
1492
- const live = useLiveState(summary.name, initial);
1493
- const { index, hasNextOpen, handleStep, handleNextOpen, handleCopyLink } = usePointSteps(summary, view.id, live);
1494
- const { draft, handleDraft } = useDraft(view.id);
1495
- const shown = getShownOption(view, draft, live.answers[view.id]?.choice ?? null);
1496
- useMarkViewed(view.id, live.comments.findLast((comment) => comment.point === view.id)?.at ?? "");
1497
- usePointRefresh(summary.name, view);
1498
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(GalleryProvider, { children: [
1499
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TopBar, {
1500
- hasNextOpen,
1501
- index,
1502
- live,
1503
- onCopyLink: handleCopyLink,
1504
- onNextOpen: handleNextOpen,
1505
- onStep: handleStep,
1506
- summary,
1507
- view
1508
- }),
1509
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("main", {
1510
- className: "px-6 pt-6 pb-20 xl:ms-70 xl:me-85",
1511
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Slide, {
1512
- deck: summary.name,
1513
- live,
1514
- shown,
1515
- view
1516
- }, view.id)
1517
- }),
1518
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AnswerPanel, {
1519
- deck: summary.name,
1520
- draft,
1521
- live,
1522
- onDraft: handleDraft,
1523
- shown: shown?.value ?? null,
1524
- view
1525
- }, `answer-${view.id}`)
1526
- ] });
1527
- };
1528
- export { PointPage as component };