@prenta/admin 2.12.1 → 2.13.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.
Files changed (63) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/AdminRoot.d.ts.map +1 -1
  3. package/dist/AdminRoot.js +3 -3
  4. package/dist/AdminRoot.js.map +1 -1
  5. package/dist/__tests__/components/attribution-rows.test.js +17 -5
  6. package/dist/__tests__/components/attribution-rows.test.js.map +1 -1
  7. package/dist/__tests__/layout/shell-nav.render.test.js +3 -1
  8. package/dist/__tests__/layout/shell-nav.render.test.js.map +1 -1
  9. package/dist/__tests__/views/form-entries.render.test.js +5 -5
  10. package/dist/__tests__/views/form-entries.render.test.js.map +1 -1
  11. package/dist/__tests__/views/form-submissions.render.test.js +3 -3
  12. package/dist/__tests__/views/form-submissions.render.test.js.map +1 -1
  13. package/dist/components/forms/ExportMenu.d.ts +7 -1
  14. package/dist/components/forms/ExportMenu.d.ts.map +1 -1
  15. package/dist/components/forms/ExportMenu.js +17 -5
  16. package/dist/components/forms/ExportMenu.js.map +1 -1
  17. package/dist/layout/nav-config.d.ts.map +1 -1
  18. package/dist/layout/nav-config.js +8 -1
  19. package/dist/layout/nav-config.js.map +1 -1
  20. package/dist/lib/entry-attribution.d.ts +33 -0
  21. package/dist/lib/entry-attribution.d.ts.map +1 -1
  22. package/dist/lib/entry-attribution.js +115 -30
  23. package/dist/lib/entry-attribution.js.map +1 -1
  24. package/dist/lib/forms-service.d.ts +38 -0
  25. package/dist/lib/forms-service.d.ts.map +1 -1
  26. package/dist/lib/forms-service.js +10 -0
  27. package/dist/lib/forms-service.js.map +1 -1
  28. package/dist/prenta-admin.css +1 -1
  29. package/dist/views/FormEntries.d.ts +4 -1
  30. package/dist/views/FormEntries.d.ts.map +1 -1
  31. package/dist/views/FormEntries.js +2 -2
  32. package/dist/views/FormEntries.js.map +1 -1
  33. package/dist/views/FormSubmissions.d.ts +3 -1
  34. package/dist/views/FormSubmissions.d.ts.map +1 -1
  35. package/dist/views/FormSubmissions.js +2 -2
  36. package/dist/views/FormSubmissions.js.map +1 -1
  37. package/dist/views/SpamFolder.d.ts +6 -1
  38. package/dist/views/SpamFolder.d.ts.map +1 -1
  39. package/dist/views/SpamFolder.js +4 -11
  40. package/dist/views/SpamFolder.js.map +1 -1
  41. package/dist/views/entries/EntriesInbox.d.ts +12 -2
  42. package/dist/views/entries/EntriesInbox.d.ts.map +1 -1
  43. package/dist/views/entries/EntriesInbox.js +820 -81
  44. package/dist/views/entries/EntriesInbox.js.map +1 -1
  45. package/dist/views/entries/inbox-format.d.ts +0 -1
  46. package/dist/views/entries/inbox-format.d.ts.map +1 -1
  47. package/dist/views/entries/inbox-format.js +0 -4
  48. package/dist/views/entries/inbox-format.js.map +1 -1
  49. package/package.json +3 -3
  50. package/src/AdminRoot.tsx +23 -3
  51. package/src/__tests__/components/attribution-rows.test.ts +19 -5
  52. package/src/__tests__/layout/shell-nav.render.test.tsx +3 -1
  53. package/src/__tests__/views/form-entries.render.test.tsx +5 -5
  54. package/src/__tests__/views/form-submissions.render.test.tsx +3 -3
  55. package/src/components/forms/ExportMenu.tsx +37 -13
  56. package/src/layout/nav-config.tsx +8 -0
  57. package/src/lib/entry-attribution.ts +155 -29
  58. package/src/lib/forms-service.ts +44 -0
  59. package/src/views/FormEntries.tsx +17 -2
  60. package/src/views/FormSubmissions.tsx +16 -2
  61. package/src/views/SpamFolder.tsx +14 -26
  62. package/src/views/entries/EntriesInbox.tsx +2119 -337
  63. package/src/views/entries/inbox-format.ts +0 -6
@@ -7,31 +7,156 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
7
7
  * a control that cannot save.
8
8
  */
9
9
  import { useCallback, useEffect, useId, useMemo, useRef, useState, } from 'react';
10
- import { Archive, Check, ChevronDown, ChevronLeft, ChevronRight, Copy, Globe, Inbox, Mail, Phone, Rows3, Search, Star, Trash2, X, } from 'lucide-react';
10
+ import { Archive, Check, ChevronDown, ChevronLeft, ChevronRight, Clock, Copy, Globe, Inbox, Mail, MessageSquare, Phone, RotateCcw, Rows3, Search, ShieldX, Star, Trash2, X, } from 'lucide-react';
11
11
  import { toast } from 'sonner';
12
12
  import { bulkUpdateEntries, deleteEntry, fetchEntries, fetchEntry, fetchEntryCounts, fetchFormById, fetchForms, updateEntry, } from '../../lib/forms-service.js';
13
+ import { BlocklistDialog, } from '../../components/forms/BlocklistDialog.js';
14
+ import { cmsApi } from '../../lib/api.js';
13
15
  import { emitFormsChanged, onFormsChanged } from '../../lib/forms-events.js';
14
- import { buildAttributionRows } from '../../lib/entry-attribution.js';
16
+ import { getEntryAttributionSummary } from '../../lib/entry-attribution.js';
15
17
  import { Breadcrumb } from '../../components/ui/Breadcrumb.js';
16
18
  import { ConfirmDialog } from '../../components/ui/ConfirmDialog.js';
19
+ import { Modal } from '../../components/ui/Modal.js';
17
20
  import { ExportMenu } from '../../components/forms/ExportMenu.js';
18
- import { avatarColor, entryIdLabel, entryPreview, fieldIsWide, fullEntryTime, groupEntries, initials, relativeEntryTime, senderName, } from './inbox-format.js';
19
- // The kit's Mine and Partial chips are left out until assignees (F-25) and
20
- // partial entries (F-24) are stored; shown now, they would always read 0.
21
- const FILTERS = [
21
+ import { avatarColor, entryIdLabel, entryPreview, fullEntryTime, groupEntries, initials, relativeEntryTime, senderName, } from './inbox-format.js';
22
+ /** Inbox views. Folders other than Inbox replace this with Back to Inbox. */
23
+ const VIEWS = [
22
24
  { id: 'all', label: 'All' },
23
25
  { id: 'unread', label: 'Unread' },
26
+ { id: 'mine', label: 'Mine' },
27
+ ];
28
+ const FOLDERS = [
29
+ { id: 'all', label: 'Inbox' },
24
30
  { id: 'starred', label: 'Starred' },
25
31
  { id: 'archived', label: 'Archived' },
32
+ { id: 'partial', label: 'Partial' },
26
33
  { id: 'spam', label: 'Spam' },
34
+ { id: 'trash', label: 'Trash' },
27
35
  ];
28
- const QUERY_FILTERS = new Set(FILTERS.map((filter) => filter.id));
36
+ const FOLDER_ICON = {
37
+ all: Inbox,
38
+ starred: Star,
39
+ archived: Archive,
40
+ partial: Clock,
41
+ spam: ShieldX,
42
+ trash: Trash2,
43
+ };
44
+ const QUERY_FILTERS = new Set([
45
+ ...VIEWS.map((filter) => filter.id),
46
+ ...FOLDERS.map((filter) => filter.id),
47
+ ]);
29
48
  const RAIL_KEY = 'prenta.inbox.railw';
30
49
  const RAIL_MIN = 300;
31
50
  const RAIL_MAX = 620;
32
- const RAIL_DEFAULT = 320;
51
+ const RAIL_DEFAULT = 384;
33
52
  const PAGE_SIZE = 100;
34
- function filterParams(filter) {
53
+ const PIPE_STATUSES = [
54
+ { id: 'new', label: 'New', fg: 'var(--acc)', bg: 'var(--acc-l)' },
55
+ { id: 'contacted', label: 'Contacted', fg: 'var(--info)', bg: 'var(--info-l)' },
56
+ { id: 'qualified', label: 'Qualified', fg: 'var(--warn)', bg: 'var(--warn-l)' },
57
+ { id: 'won', label: 'Won', fg: 'var(--suc)', bg: 'var(--suc-l)' },
58
+ { id: 'lost', label: 'Lost', fg: 'var(--sub)', bg: 'var(--bg)' },
59
+ ];
60
+ function pipeOf(status) {
61
+ return PIPE_STATUSES.find((item) => item.id === status) ?? PIPE_STATUSES[0];
62
+ }
63
+ const FORM_BADGE_COLORS = {
64
+ 'free-rfp': { bg: 'var(--acc-l)', fg: 'var(--acc)' },
65
+ 'seo-audit': { bg: 'var(--info-l)', fg: 'var(--info)' },
66
+ 'ad-audit': { bg: 'var(--suc-l)', fg: 'var(--suc)' },
67
+ 'contact-us': { bg: 'var(--warn-l)', fg: 'var(--warn)' },
68
+ 'free-proposal': { bg: 'var(--bg)', fg: 'var(--sub)' },
69
+ };
70
+ const BADGE_PALETTE = [
71
+ { bg: 'var(--acc-l)', fg: 'var(--acc)' },
72
+ { bg: 'var(--info-l)', fg: 'var(--info)' },
73
+ { bg: 'var(--suc-l)', fg: 'var(--suc)' },
74
+ { bg: 'var(--warn-l)', fg: 'var(--warn)' },
75
+ ];
76
+ function formBadgeStyle(slug) {
77
+ if (!slug)
78
+ return BADGE_PALETTE[0];
79
+ const known = FORM_BADGE_COLORS[slug];
80
+ if (known)
81
+ return known;
82
+ const hash = [...slug].reduce((acc, ch) => acc + ch.charCodeAt(0), 0);
83
+ return BADGE_PALETTE[hash % BADGE_PALETTE.length];
84
+ }
85
+ const FALLBACK_FIELD_LABELS = {
86
+ first_name: 'First Name',
87
+ last_name: 'Last Name',
88
+ full_name: 'Full Name',
89
+ name: 'Name',
90
+ business: 'Business Name',
91
+ company: 'Company',
92
+ website: 'Website URL',
93
+ phone: 'Phone',
94
+ email: 'Email',
95
+ services: 'Services Interested In',
96
+ description: 'Brief Description of Your Project',
97
+ budget: 'Budget Range',
98
+ timeline: 'Timeline',
99
+ message: 'Message',
100
+ monthly_spend: 'Current Monthly Spend',
101
+ platforms: 'Ad Platforms',
102
+ goal: 'Primary Goal',
103
+ source: 'Source',
104
+ };
105
+ function humanizeFieldKey(key) {
106
+ const known = FALLBACK_FIELD_LABELS[key];
107
+ if (known)
108
+ return known;
109
+ return key.replace(/[-_]+/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase());
110
+ }
111
+ const LONG_MESSAGE_FIELDS = new Set(['description', 'message', 'services', 'platforms', 'goal']);
112
+ const FREE_EMAIL_DOMAINS = new Set([
113
+ 'gmail.com',
114
+ 'yahoo.com',
115
+ 'outlook.com',
116
+ 'hotmail.com',
117
+ 'icloud.com',
118
+ 'aol.com',
119
+ 'proton.me',
120
+ 'protonmail.com',
121
+ 'live.com',
122
+ 'msn.com',
123
+ 'mail.ru',
124
+ ]);
125
+ const SPAM_BY_LABELS = {
126
+ ai: 'AI review',
127
+ keyword: 'Keyword filter',
128
+ fast: 'Too fast',
129
+ honeypot: 'Honeypot',
130
+ manual: 'Spam',
131
+ };
132
+ const DAY_MS = 86_400_000;
133
+ function daysLeftInTrash(deletedAt) {
134
+ if (!deletedAt)
135
+ return 30;
136
+ return Math.max(0, 30 - Math.floor((Date.now() - new Date(deletedAt).getTime()) / DAY_MS));
137
+ }
138
+ const NON_INPUT_FIELD_SET = new Set([
139
+ 'richtext',
140
+ 'divider',
141
+ 'honeypot',
142
+ 'heading',
143
+ 'content',
144
+ 'pagebreak',
145
+ ]);
146
+ function formatFieldDisplay(_key, raw, field) {
147
+ if (!raw)
148
+ return '';
149
+ if (field?.options && field.options.length > 0) {
150
+ const parts = raw.split(/,\s*/);
151
+ const mapped = parts.map((part) => {
152
+ const opt = field.options?.find((o) => o.value === part || o.label === part);
153
+ return opt ? opt.label : part;
154
+ });
155
+ return mapped.join(', ');
156
+ }
157
+ return raw;
158
+ }
159
+ function filterParams(filter, assigneeId) {
35
160
  switch (filter) {
36
161
  case 'unread':
37
162
  return { unread: true };
@@ -41,9 +166,12 @@ function filterParams(filter) {
41
166
  return { archived: true };
42
167
  case 'spam':
43
168
  return { spamStatus: 'spam' };
44
- case 'mine':
169
+ case 'trash':
170
+ return { folder: 'trash' };
45
171
  case 'partial':
46
- return null;
172
+ return { folder: 'partial' };
173
+ case 'mine':
174
+ return { folder: 'mine', ...(assigneeId ? { assigneeId } : {}) };
47
175
  default:
48
176
  return {};
49
177
  }
@@ -69,12 +197,17 @@ function displayValue(value) {
69
197
  return JSON.stringify(value);
70
198
  return String(value);
71
199
  }
72
- export function EntriesInbox({ formId, onNavigate }) {
200
+ export function EntriesInbox({ formId, initialFilter, currentPath, onNavigate, currentUserId, currentUserName, }) {
73
201
  const searchId = useId();
74
202
  const listRef = useRef(null);
75
203
  const searchRef = useRef(null);
76
- const initial = formId ? { form: formId, filter: 'all' } : readQuery();
204
+ const initial = formId
205
+ ? { form: formId, filter: (initialFilter ?? 'all') }
206
+ : initialFilter
207
+ ? { ...readQuery(), filter: initialFilter }
208
+ : readQuery();
77
209
  const [forms, setForms] = useState([]);
210
+ const [team, setTeam] = useState([]);
78
211
  const [lockedName, setLockedName] = useState('');
79
212
  const [entries, setEntries] = useState([]);
80
213
  const [total, setTotal] = useState(0);
@@ -91,13 +224,205 @@ export function EntriesInbox({ formId, onNavigate }) {
91
224
  const [dragging, setDragging] = useState(false);
92
225
  const [narrow, setNarrow] = useState(false);
93
226
  const [confirmDelete, setConfirmDelete] = useState(null);
227
+ const [emptyTrashOpen, setEmptyTrashOpen] = useState(false);
228
+ const [blocklistTab, setBlocklistTab] = useState(null);
229
+ const [formsSettingsDoc, setFormsSettingsDoc] = useState(null);
230
+ const [blocked, setBlocked] = useState({ words: [], domains: [] });
231
+ const [toastMsg, setToastMsg] = useState('');
232
+ const [toastUndo, setToastUndo] = useState(null);
233
+ const toastTimerRef = useRef(0);
94
234
  const scopedFormId = formId ?? (formFilter === 'all' ? undefined : formFilter);
95
- const unsupported = filter === 'mine' || filter === 'partial';
235
+ const unsupported = false;
236
+ useEffect(() => {
237
+ let cancelled = false;
238
+ void cmsApi('/globals/formsSettings')
239
+ .then((res) => {
240
+ if (cancelled || !res.data)
241
+ return;
242
+ setFormsSettingsDoc(res.data);
243
+ if (res.data.spam?.blocklist) {
244
+ setBlocked({
245
+ words: Array.isArray(res.data.spam.blocklist.words)
246
+ ? res.data.spam.blocklist.words
247
+ : [],
248
+ domains: Array.isArray(res.data.spam.blocklist.domains)
249
+ ? res.data.spam.blocklist.domains
250
+ : [],
251
+ });
252
+ }
253
+ })
254
+ .catch(() => { });
255
+ return () => {
256
+ cancelled = true;
257
+ };
258
+ }, []);
259
+ const showUndoToast = useCallback((message, undo) => {
260
+ window.clearTimeout(toastTimerRef.current);
261
+ setToastMsg(message);
262
+ setToastUndo(() => undo ?? null);
263
+ toastTimerRef.current = window.setTimeout(() => {
264
+ setToastMsg('');
265
+ setToastUndo(null);
266
+ }, undo ? 6000 : 1800);
267
+ }, []);
268
+ const handleBlocklistChange = useCallback(async (next) => {
269
+ const prev = blocked;
270
+ setBlocked(next);
271
+ const baseDoc = formsSettingsDoc ?? {
272
+ spam: {
273
+ honeypot: true,
274
+ captchaScope: 'all',
275
+ rateLimit: { max: 5, window: '10m' },
276
+ minSeconds: 3,
277
+ action: 'quarantine',
278
+ blocklist: next,
279
+ ai: {
280
+ on: false,
281
+ strictness: 'balanced',
282
+ holdNotifications: true,
283
+ learnFromCorrections: true,
284
+ },
285
+ },
286
+ defaults: {
287
+ recipients: [],
288
+ replyToSubmitter: true,
289
+ successMessage: 'Thanks — we got your message.',
290
+ confirmationEmail: false,
291
+ },
292
+ retention: {
293
+ entryDays: null,
294
+ spamDays: 30,
295
+ archivedDays: null,
296
+ deliveryLogDays: 90,
297
+ ipStorage: 'anon',
298
+ deleteFilesWithEntry: true,
299
+ },
300
+ attribution: {
301
+ record: true,
302
+ requireConsent: false,
303
+ firstTouchDays: 30,
304
+ lastTouchHours: 24,
305
+ },
306
+ updatedAt: '',
307
+ updatedBy: '',
308
+ };
309
+ const updatedDoc = {
310
+ ...baseDoc,
311
+ spam: { ...baseDoc.spam, blocklist: next },
312
+ };
313
+ const res = await cmsApi('/globals/formsSettings', {
314
+ method: 'PUT',
315
+ body: JSON.stringify(updatedDoc),
316
+ });
317
+ if (res.error) {
318
+ setBlocked(prev);
319
+ toast.error(res.error);
320
+ return false;
321
+ }
322
+ setFormsSettingsDoc(res.data ?? updatedDoc);
323
+ return true;
324
+ }, [blocked, formsSettingsDoc]);
325
+ const handleBlockDomain = useCallback(async (domain) => {
326
+ const normalized = domain.trim().toLowerCase();
327
+ if (!normalized || FREE_EMAIL_DOMAINS.has(normalized))
328
+ return;
329
+ if (blocked.domains.some((d) => d.term === normalized))
330
+ return;
331
+ const next = {
332
+ ...blocked,
333
+ domains: [
334
+ {
335
+ term: normalized,
336
+ addedAt: new Date().toISOString(),
337
+ source: 'spam',
338
+ hits30d: 0,
339
+ lastHitAt: null,
340
+ },
341
+ ...blocked.domains,
342
+ ],
343
+ };
344
+ const ok = await handleBlocklistChange(next);
345
+ if (ok)
346
+ showUndoToast(`${normalized} added to blocked domains`);
347
+ }, [blocked, handleBlocklistChange, showUndoToast]);
348
+ useEffect(() => {
349
+ if (formId || initialFilter || !currentPath)
350
+ return;
351
+ const qIndex = currentPath.indexOf('?');
352
+ const params = new URLSearchParams(qIndex >= 0 ? currentPath.slice(qIndex + 1) : '');
353
+ const rawFilter = params.get('filter') ?? '';
354
+ const nextFilter = QUERY_FILTERS.has(rawFilter)
355
+ ? rawFilter
356
+ : 'all';
357
+ setFilter((prev) => (prev === nextFilter ? prev : nextFilter));
358
+ const rawForm = params.get('form') || 'all';
359
+ if (rawForm === 'all') {
360
+ setFormFilter('all');
361
+ }
362
+ else if (forms.length > 0) {
363
+ const match = forms.find((f) => f.id === rawForm || f.slug === rawForm);
364
+ if (match)
365
+ setFormFilter(match.id);
366
+ }
367
+ }, [currentPath, formId, initialFilter, forms]);
368
+ useEffect(() => {
369
+ let cancelled = false;
370
+ const parseList = (raw) => {
371
+ const list = Array.isArray(raw)
372
+ ? raw
373
+ : raw && typeof raw === 'object' && Array.isArray(raw.users)
374
+ ? (raw.users ?? [])
375
+ : [];
376
+ return list
377
+ .filter((u) => Boolean(u && typeof u.id === 'string'))
378
+ .map((u) => ({
379
+ id: u.id,
380
+ name: (u.name && u.name.trim()) || u.email || u.id,
381
+ email: u.email,
382
+ }));
383
+ };
384
+ void cmsApi('/users?pageSize=200')
385
+ .then(async (res) => {
386
+ if (cancelled)
387
+ return;
388
+ const mapped = res.data ? parseList(res.data) : [];
389
+ if (mapped.length > 0) {
390
+ setTeam(mapped);
391
+ return;
392
+ }
393
+ const fallback = await cmsApi('/users/search?q=%40');
394
+ if (cancelled || !fallback.data)
395
+ return;
396
+ const searched = parseList(fallback.data);
397
+ if (searched.length > 0)
398
+ setTeam(searched);
399
+ })
400
+ .catch(() => { });
401
+ return () => {
402
+ cancelled = true;
403
+ };
404
+ }, []);
405
+ const effectiveTeam = useMemo(() => {
406
+ const map = new Map();
407
+ for (const member of team)
408
+ map.set(member.id, member);
409
+ if (currentUserId && !map.has(currentUserId)) {
410
+ map.set(currentUserId, { id: currentUserId, name: currentUserName || 'You' });
411
+ }
412
+ for (const entry of entries) {
413
+ const aId = entry.assigneeId;
414
+ const aName = entry.assigneeName;
415
+ if (aId && !map.has(aId)) {
416
+ map.set(aId, { id: aId, name: aName || aId });
417
+ }
418
+ }
419
+ return [...map.values()];
420
+ }, [team, currentUserId, currentUserName, entries]);
96
421
  useEffect(() => {
97
422
  try {
98
423
  const stored = Number(globalThis.localStorage?.getItem(RAIL_KEY));
99
424
  // 384 was the first default. A saved copy of that width keeps the entry pane narrow.
100
- if (stored >= RAIL_MIN && stored <= RAIL_MAX && stored !== 384)
425
+ if (stored >= RAIL_MIN && stored <= RAIL_MAX)
101
426
  setRailW(stored);
102
427
  }
103
428
  catch {
@@ -157,14 +482,7 @@ export function EntriesInbox({ formId, onNavigate }) {
157
482
  const load = useCallback(async () => {
158
483
  setLoading(true);
159
484
  setError(null);
160
- const params = filterParams(filter);
161
- if (!params) {
162
- setEntries([]);
163
- setTotal(0);
164
- setChecked(new Set());
165
- setLoading(false);
166
- return;
167
- }
485
+ const params = filterParams(filter, currentUserId);
168
486
  try {
169
487
  const collected = [];
170
488
  const seen = new Set();
@@ -200,12 +518,15 @@ export function EntriesInbox({ formId, onNavigate }) {
200
518
  finally {
201
519
  setLoading(false);
202
520
  }
203
- }, [filter, scopedFormId, search]);
521
+ }, [filter, scopedFormId, search, currentUserId]);
204
522
  const loadCounts = useCallback(() => {
205
- void fetchEntryCounts({ formId: scopedFormId })
523
+ void fetchEntryCounts({
524
+ formId: scopedFormId,
525
+ ...(currentUserId ? { assigneeId: currentUserId } : {}),
526
+ })
206
527
  .then(setCounts)
207
528
  .catch(() => { });
208
- }, [scopedFormId]);
529
+ }, [scopedFormId, currentUserId]);
209
530
  useEffect(() => {
210
531
  void load();
211
532
  }, [load]);
@@ -217,16 +538,70 @@ export function EntriesInbox({ formId, onNavigate }) {
217
538
  loadCounts();
218
539
  }), [load, loadCounts]);
219
540
  const selectedForm = forms.find((form) => form.id === formFilter);
541
+ const folder = filter === 'unread' || filter === 'mine' ? 'all' : filter;
542
+ const FolderIcon = FOLDER_ICON[folder];
220
543
  const title = filter === 'spam'
221
544
  ? 'Spam'
222
545
  : filter === 'partial'
223
546
  ? 'Partial entries'
224
- : formId
225
- ? lockedName || 'Entries'
226
- : selectedForm?.name || 'All Entries';
227
- const groups = useMemo(() => groupEntries(entries), [entries]);
228
- const active = entries.find((entry) => entry.id === activeId) ?? null;
229
- const unreadInList = entries.filter((entry) => entry.unread).length;
547
+ : filter === 'starred'
548
+ ? 'Starred'
549
+ : filter === 'archived'
550
+ ? 'Archived'
551
+ : filter === 'trash'
552
+ ? 'Trash'
553
+ : formId
554
+ ? lockedName || 'Entries'
555
+ : selectedForm?.name || 'All Entries';
556
+ const trashCount = useMemo(() => {
557
+ const local = entries.filter((entry) => Boolean(entry.deleted) && entry.spamStatus !== 'spam').length;
558
+ return typeof counts?.trash === 'number' && counts.trash > 0 ? counts.trash : local;
559
+ }, [entries, counts?.trash]);
560
+ const partialCount = useMemo(() => {
561
+ const local = entries.filter((entry) => Boolean(entry.partial) && !entry.deleted && entry.spamStatus !== 'spam').length;
562
+ return typeof counts?.partial === 'number' && counts.partial > 0 ? counts.partial : local;
563
+ }, [entries, counts?.partial]);
564
+ const mineCount = useMemo(() => {
565
+ const me = currentUserId || 'self';
566
+ const local = entries.filter((entry) => !entry.deleted &&
567
+ !entry.partial &&
568
+ entry.assigneeId === me &&
569
+ entry.status !== 'won' &&
570
+ entry.status !== 'lost' &&
571
+ !entry.archived &&
572
+ entry.spamStatus !== 'spam').length;
573
+ return typeof counts?.mine === 'number' && counts.mine > 0 ? counts.mine : local;
574
+ }, [entries, currentUserId, counts?.mine]);
575
+ const visibleEntries = useMemo(() => {
576
+ if (filter === 'trash') {
577
+ return entries
578
+ .filter((entry) => Boolean(entry.deleted) && entry.spamStatus !== 'spam')
579
+ .sort((a, b) => new Date(b.deleted?.at ?? b.submittedAt).getTime() -
580
+ new Date(a.deleted?.at ?? a.submittedAt).getTime());
581
+ }
582
+ const live = entries.filter((entry) => !entry.deleted);
583
+ if (filter === 'partial') {
584
+ return live.filter((entry) => Boolean(entry.partial) && entry.spamStatus !== 'spam');
585
+ }
586
+ if (filter === 'spam') {
587
+ return live.filter((entry) => entry.spamStatus === 'spam');
588
+ }
589
+ const nonPartial = live.filter((entry) => !entry.partial);
590
+ if (filter === 'mine') {
591
+ const me = currentUserId || 'self';
592
+ return nonPartial.filter((entry) => entry.assigneeId === me &&
593
+ entry.status !== 'won' &&
594
+ entry.status !== 'lost' &&
595
+ !entry.archived &&
596
+ entry.spamStatus !== 'spam');
597
+ }
598
+ return nonPartial;
599
+ }, [entries, filter, currentUserId]);
600
+ const groups = useMemo(() => groupEntries(visibleEntries), [visibleEntries]);
601
+ const active = visibleEntries.find((entry) => entry.id === activeId) ??
602
+ entries.find((entry) => entry.id === activeId) ??
603
+ null;
604
+ const unreadInList = visibleEntries.filter((entry) => entry.unread).length;
230
605
  function pickFilter(next) {
231
606
  setFilter(next);
232
607
  setActiveId(null);
@@ -237,28 +612,111 @@ export function EntriesInbox({ formId, onNavigate }) {
237
612
  setActiveId(null);
238
613
  writeQuery(filter, next);
239
614
  }
240
- const patchOne = useCallback(async (id, patch, message) => {
615
+ const patchOne = useCallback(async (id, patch, message, undoPatch, clearSelectionOnApply) => {
616
+ const prevActive = activeId;
617
+ setEntries((current) => current.map((entry) => (entry.id === id ? { ...entry, ...patch } : entry)));
618
+ if (clearSelectionOnApply && activeId === id)
619
+ setActiveId(null);
241
620
  const res = await updateEntry(id, patch);
242
621
  if (res.error) {
243
622
  toast.error(res.error);
623
+ void load();
244
624
  return;
245
625
  }
246
- setEntries((current) => current.map((entry) => (entry.id === id ? { ...entry, ...patch } : entry)));
247
- if (message)
248
- toast.success(message);
626
+ if (res.data) {
627
+ setEntries((current) => current.map((entry) => (entry.id === id ? { ...entry, ...res.data, ...patch } : entry)));
628
+ }
629
+ if (message) {
630
+ if (undoPatch) {
631
+ showUndoToast(message, () => {
632
+ void (async () => {
633
+ const undoRes = await updateEntry(id, undoPatch);
634
+ if (undoRes.error) {
635
+ toast.error(undoRes.error);
636
+ void load();
637
+ return;
638
+ }
639
+ setEntries((current) => current.map((entry) => (entry.id === id ? { ...entry, ...undoPatch } : entry)));
640
+ setActiveId(prevActive);
641
+ showUndoToast('Undone');
642
+ emitFormsChanged();
643
+ })();
644
+ });
645
+ }
646
+ else {
647
+ showUndoToast(message);
648
+ }
649
+ }
249
650
  emitFormsChanged();
250
- }, []);
651
+ }, [activeId, load, showUndoToast]);
652
+ const handleTrashOrDelete = useCallback(async (id) => {
653
+ const target = entries.find((e) => e.id === id);
654
+ if (!target)
655
+ return;
656
+ if (target.spamStatus === 'spam' || target.deleted) {
657
+ setConfirmDelete([id]);
658
+ return;
659
+ }
660
+ const deletedPayload = {
661
+ at: new Date().toISOString(),
662
+ by: currentUserId || 'self',
663
+ byName: currentUserName || 'You',
664
+ };
665
+ await patchOne(id, { deleted: deletedPayload }, 'Moved to Trash', { deleted: null }, true);
666
+ }, [entries, currentUserId, currentUserName, patchOne]);
667
+ const handleRestore = useCallback(async (id) => {
668
+ const target = entries.find((e) => e.id === id);
669
+ if (!target)
670
+ return;
671
+ const prevDeleted = target.deleted ?? null;
672
+ await patchOne(id, { deleted: null }, target.archived ? 'Restored to Archived' : 'Restored to Inbox', { deleted: prevDeleted }, true);
673
+ }, [entries, patchOne]);
674
+ const handleEmptyTrash = useCallback(async () => {
675
+ const trashedIds = visibleEntries
676
+ .filter((e) => Boolean(e.deleted) && e.spamStatus !== 'spam')
677
+ .map((e) => e.id);
678
+ setEmptyTrashOpen(false);
679
+ if (trashedIds.length === 0)
680
+ return;
681
+ const results = await Promise.allSettled(trashedIds.map((id) => deleteEntry(id)));
682
+ const failed = results.filter((r) => r.status === 'rejected' || r.value.error).length;
683
+ const deletedCount = trashedIds.length - failed;
684
+ setActiveId(null);
685
+ if (failed > 0) {
686
+ toast.error(`${failed} of ${trashedIds.length} could not be deleted`);
687
+ }
688
+ else if (deletedCount > 0) {
689
+ showUndoToast(`${deletedCount} ${deletedCount === 1 ? 'entry' : 'entries'} deleted forever`);
690
+ }
691
+ emitFormsChanged();
692
+ }, [visibleEntries, showUndoToast]);
693
+ const handleEmptySpam = useCallback(async () => {
694
+ const spamIds = visibleEntries.filter((e) => e.spamStatus === 'spam').map((e) => e.id);
695
+ if (spamIds.length === 0)
696
+ return;
697
+ const results = await Promise.allSettled(spamIds.map((id) => deleteEntry(id)));
698
+ const failed = results.filter((r) => r.status === 'rejected' || r.value.error).length;
699
+ const deletedCount = spamIds.length - failed;
700
+ setActiveId(null);
701
+ if (failed > 0) {
702
+ toast.error(`${failed} of ${spamIds.length} could not be deleted`);
703
+ }
704
+ else if (deletedCount > 0) {
705
+ showUndoToast(`${deletedCount} spam ${deletedCount === 1 ? 'entry' : 'entries'} deleted`);
706
+ }
707
+ emitFormsChanged();
708
+ }, [visibleEntries, showUndoToast]);
251
709
  function openEntry(id) {
252
710
  setActiveId(id);
253
- const entry = entries.find((item) => item.id === id);
711
+ const entry = visibleEntries.find((item) => item.id === id) ?? entries.find((item) => item.id === id);
254
712
  if (entry?.unread)
255
713
  void patchOne(id, { unread: false });
256
714
  }
257
715
  function move(delta) {
258
- if (entries.length === 0)
716
+ if (visibleEntries.length === 0)
259
717
  return;
260
- const index = entries.findIndex((entry) => entry.id === activeId);
261
- const next = entries[Math.min(entries.length - 1, Math.max(0, index + delta))];
718
+ const index = visibleEntries.findIndex((entry) => entry.id === activeId);
719
+ const next = visibleEntries[index < 0 ? 0 : Math.min(visibleEntries.length - 1, Math.max(0, index + delta))];
262
720
  if (!next)
263
721
  return;
264
722
  openEntry(next.id);
@@ -305,19 +763,19 @@ export function EntriesInbox({ formId, onNavigate }) {
305
763
  move(-1);
306
764
  }
307
765
  else if (key === 's' && activeId) {
308
- const entry = entries.find((item) => item.id === activeId);
309
- if (entry)
766
+ const entry = visibleEntries.find((item) => item.id === activeId);
767
+ if (entry && !entry.deleted)
310
768
  void patchOne(entry.id, { starred: !entry.starred });
311
769
  }
312
770
  else if (key === 'u' && activeId) {
313
- const entry = entries.find((item) => item.id === activeId);
771
+ const entry = visibleEntries.find((item) => item.id === activeId);
314
772
  if (entry)
315
773
  void patchOne(entry.id, { unread: !entry.unread });
316
774
  }
317
775
  else if (key === 'e' && activeId) {
318
- const entry = entries.find((item) => item.id === activeId);
319
- if (entry) {
320
- void patchOne(entry.id, { archived: !entry.archived }, entry.archived ? 'Unarchived' : 'Archived');
776
+ const entry = visibleEntries.find((item) => item.id === activeId);
777
+ if (entry && !entry.deleted && entry.spamStatus !== 'spam') {
778
+ void patchOne(entry.id, { archived: !entry.archived }, entry.archived ? 'Moved to inbox' : 'Archived', { archived: entry.archived });
321
779
  }
322
780
  }
323
781
  }
@@ -350,11 +808,57 @@ export function EntriesInbox({ formId, onNavigate }) {
350
808
  window.addEventListener('pointermove', moveDrag);
351
809
  window.addEventListener('pointerup', stop);
352
810
  }
811
+ const moveIdsToTrash = useCallback(async (ids) => {
812
+ const deletedPayload = {
813
+ at: new Date().toISOString(),
814
+ by: currentUserId || 'self',
815
+ byName: currentUserName || 'You',
816
+ };
817
+ const results = await Promise.allSettled(ids.map(async (id) => ({ id, res: await updateEntry(id, { deleted: deletedPayload }) })));
818
+ const succeededIds = results
819
+ .filter((r) => r.status === 'fulfilled' && !r.value.res.error)
820
+ .map((r) => r.value.id);
821
+ const failedCount = ids.length - succeededIds.length;
822
+ setChecked(new Set());
823
+ if (activeId && succeededIds.includes(activeId))
824
+ setActiveId(null);
825
+ if (failedCount > 0) {
826
+ toast.error(`${failedCount} of ${ids.length} could not be moved to Trash`);
827
+ }
828
+ if (succeededIds.length > 0) {
829
+ showUndoToast(succeededIds.length === 1
830
+ ? 'Moved to Trash'
831
+ : `${succeededIds.length} entries moved to Trash`, () => {
832
+ void (async () => {
833
+ const undoResults = await Promise.allSettled(succeededIds.map((id) => updateEntry(id, { deleted: null })));
834
+ const undoFailed = undoResults.filter((r) => r.status === 'rejected' || r.value.error).length;
835
+ if (undoFailed > 0) {
836
+ toast.error(`${undoFailed} of ${succeededIds.length} could not be restored`);
837
+ }
838
+ else {
839
+ showUndoToast('Undone');
840
+ }
841
+ emitFormsChanged();
842
+ })();
843
+ });
844
+ }
845
+ emitFormsChanged();
846
+ }, [activeId, currentUserId, currentUserName, showUndoToast]);
353
847
  async function confirmAndDelete() {
354
848
  const ids = confirmDelete ?? [];
355
849
  setConfirmDelete(null);
356
850
  if (ids.length === 0)
357
851
  return;
852
+ const isPermanent = filter === 'trash' ||
853
+ filter === 'spam' ||
854
+ ids.every((id) => {
855
+ const target = entries.find((e) => e.id === id);
856
+ return Boolean(target?.deleted || target?.spamStatus === 'spam');
857
+ });
858
+ if (!isPermanent) {
859
+ await moveIdsToTrash(ids);
860
+ return;
861
+ }
358
862
  if (ids.length === 1) {
359
863
  const res = await deleteEntry(ids[0]);
360
864
  if (res.error)
@@ -370,6 +874,7 @@ export function EntriesInbox({ formId, onNavigate }) {
370
874
  else
371
875
  toast.success(`${ids.length} entries deleted`);
372
876
  }
877
+ setChecked(new Set());
373
878
  if (activeId && ids.includes(activeId))
374
879
  setActiveId(null);
375
880
  emitFormsChanged();
@@ -382,41 +887,96 @@ export function EntriesInbox({ formId, onNavigate }) {
382
887
  if (res.error)
383
888
  toast.error(res.error);
384
889
  else
385
- toast.success(message);
890
+ showUndoToast(message);
891
+ setChecked(new Set());
892
+ emitFormsChanged();
893
+ }
894
+ async function bulkRestore() {
895
+ const ids = [...checked];
896
+ if (ids.length === 0)
897
+ return;
898
+ const results = await Promise.allSettled(ids.map((id) => updateEntry(id, { deleted: null })));
899
+ const failed = results.filter((r) => r.status === 'rejected' || r.value.error).length;
900
+ const restoredCount = ids.length - failed;
901
+ setChecked(new Set());
902
+ if (failed > 0) {
903
+ toast.error(`${failed} of ${ids.length} could not be restored`);
904
+ }
905
+ else if (restoredCount > 0) {
906
+ showUndoToast(`${restoredCount} ${restoredCount === 1 ? 'entry' : 'entries'} updated`);
907
+ }
386
908
  emitFormsChanged();
387
909
  }
910
+ async function bulkDelete() {
911
+ const ids = [...checked];
912
+ if (ids.length === 0)
913
+ return;
914
+ if (filter === 'trash' || filter === 'spam' || ids.length > 10) {
915
+ setConfirmDelete(ids);
916
+ return;
917
+ }
918
+ await moveIdsToTrash(ids);
919
+ }
388
920
  const showList = !narrow || !activeId;
389
921
  const showDetail = !narrow || !!activeId;
390
922
  return (_jsxs("div", { className: "bg-sb text-txt flex h-full min-h-0 flex-col overflow-hidden", children: [_jsxs("header", { className: "border-bdr bg-sb shrink-0 border-b px-6 pt-3.5 pb-3 max-[900px]:px-4 max-[900px]:pt-3 max-[900px]:pb-2.5", children: [_jsx(Breadcrumb, { items: [
391
923
  { label: 'Dashboard', path: '/' },
392
924
  { label: 'Forms', path: '/forms' },
393
925
  { label: title },
394
- ] }), _jsxs("div", { className: "mt-[7px] flex flex-wrap items-center gap-3.5", children: [_jsx("h1", { className: "text-txt m-0 text-[21px] font-bold tracking-[-0.5px] whitespace-nowrap", children: title }), counts && filter !== 'spam' && filter !== 'partial' ? (_jsxs("div", { className: "flex flex-wrap items-center gap-1.5", children: [_jsxs("span", { className: "border-bdr bg-bg text-sub inline-flex items-center gap-[5px] rounded-[6px] border px-[9px] py-1 text-[11.5px]", children: [_jsx("b", { className: "text-txt font-bold tabular-nums", children: counts.total }), " total"] }), counts.unread > 0 ? (_jsxs("button", { type: "button", "aria-pressed": filter === 'unread', onClick: () => pickFilter(filter === 'unread' ? 'all' : 'unread'), className: `inline-flex items-center gap-[5px] rounded-[6px] border px-[9px] py-1 text-[11.5px] ${filter === 'unread'
926
+ ] }), _jsxs("div", { className: "mt-[7px] flex flex-wrap items-center gap-3.5", children: [_jsx("h1", { className: "text-txt m-0 text-[21px] font-bold tracking-[-0.5px] whitespace-nowrap", children: title }), counts && filter !== 'spam' && filter !== 'partial' && filter !== 'trash' ? (_jsxs("div", { className: "flex flex-wrap items-center gap-1.5", children: [_jsxs("span", { className: "border-bdr bg-bg text-sub inline-flex items-center gap-[5px] rounded-[6px] border px-[9px] py-1 text-[11.5px]", children: [_jsx("b", { className: "text-txt font-bold tabular-nums", children: counts.total }), " total"] }), counts.unread > 0 ? (_jsxs("button", { type: "button", "aria-pressed": filter === 'unread', onClick: () => pickFilter(filter === 'unread' ? 'all' : 'unread'), className: `inline-flex items-center gap-[5px] rounded-[6px] border px-[9px] py-1 text-[11.5px] ${filter === 'unread'
395
927
  ? 'border-acc-m bg-acc-l text-acc'
396
928
  : 'border-bdr bg-bg text-sub hover:border-acc-m hover:text-acc'}`, children: [_jsx("b", { className: `font-bold tabular-nums ${filter === 'unread' ? 'text-acc' : 'text-txt'}`, children: counts.unread }), ' ', "unread"] })) : null, counts.starred > 0 ? (_jsxs("button", { type: "button", "aria-pressed": filter === 'starred', onClick: () => pickFilter(filter === 'starred' ? 'all' : 'starred'), className: `inline-flex items-center gap-[5px] rounded-[6px] border px-[9px] py-1 text-[11.5px] ${filter === 'starred'
397
929
  ? 'border-acc-m bg-acc-l text-acc'
398
- : 'border-bdr bg-bg text-sub hover:border-acc-m hover:text-acc'}`, children: [_jsx("b", { className: `font-bold tabular-nums ${filter === 'starred' ? 'text-acc' : 'text-txt'}`, children: counts.starred }), ' ', "starred"] })) : null] })) : null, filter === 'spam' && counts ? (_jsxs("span", { className: "border-bdr bg-bg text-sub inline-flex items-center rounded-[6px] border px-[9px] py-1 text-[11.5px]", children: [_jsx("b", { className: "text-txt font-bold tabular-nums", children: total }), "\u00A0in spam"] })) : null, _jsxs("div", { className: "ml-auto flex items-center gap-[7px]", children: [formId ? null : (_jsxs("select", { "aria-label": "Filter by form", value: formFilter, onChange: (event) => pickForm(event.target.value), className: "inbox-header-control", children: [_jsx("option", { value: "all", children: "All forms" }), forms.map((form) => (_jsx("option", { value: form.id, children: form.name }, form.id)))] })), _jsx(ExportMenu, { formId: scopedFormId, disabled: counts !== null && counts.total === 0, triggerClassName: "inbox-header-control" })] })] })] }), checked.size > 0 ? (_jsxs("div", { className: "border-acc-m bg-acc-l flex shrink-0 items-center gap-2 border-b px-6 py-[7px]", children: [_jsxs("b", { className: "text-acc text-[13px]", children: [checked.size, " selected"] }), _jsx("button", { type: "button", className: "btn-ghost text-sub hover:text-acc rounded-[7px] px-[9px] py-1.5 text-[12.5px]", onClick: () => void bulk({ unread: false }, 'Marked read'), children: "Mark read" }), _jsx("button", { type: "button", className: "text-sub hover:text-acc rounded-[7px] px-[9px] py-1.5 text-[12.5px]", onClick: () => void bulk({ archived: true }, 'Archived'), children: "Archive" }), _jsx("button", { type: "button", className: "text-err rounded-[7px] px-[9px] py-1.5 text-[12.5px]", onClick: () => setConfirmDelete([...checked]), children: "Delete" }), _jsx("button", { type: "button", className: "text-sub ml-auto rounded-[7px] px-[9px] py-1.5 text-[12.5px]", onClick: () => setChecked(new Set()), children: "Clear" })] })) : null, _jsxs("div", { className: `flex min-h-0 flex-1 ${narrow && activeId ? '' : ''}`, children: [showList ? (_jsxs("div", { className: "border-bdr bg-sb flex min-h-0 shrink-0 flex-col overflow-hidden border-r", style: { width: narrow ? '100%' : railW }, children: [_jsxs("div", { className: "border-bdr flex shrink-0 flex-col gap-2 border-b px-3 py-2.5", children: [_jsxs("div", { className: "inbox-search", children: [_jsx(Search, { size: 14, strokeWidth: 1.75, className: "shrink-0 text-[var(--muted)]", "aria-hidden": true }), _jsx("input", { id: searchId, ref: searchRef, value: search, onChange: (event) => setSearch(event.target.value), placeholder: "Search name, email, message\u2026", "aria-label": "Search entries" }), search ? (_jsx("button", { type: "button", "aria-label": "Clear search", onClick: () => setSearch(''), children: _jsx(X, { size: 13, strokeWidth: 1.75, "aria-hidden": true }) })) : null] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("div", { className: "border-bdr bg-bg flex min-w-0 flex-1 gap-0.5 overflow-x-auto rounded-[8px] border p-0.5", role: "group", "aria-label": "Filter entries", children: FILTERS.map((item) => {
930
+ : 'border-bdr bg-bg text-sub hover:border-acc-m hover:text-acc'}`, children: [_jsx(Star, { size: 11, "aria-hidden": true, className: "text-warn -mr-0.5 fill-current" }), _jsx("b", { className: `font-bold tabular-nums ${filter === 'starred' ? 'text-acc' : 'text-txt'}`, children: counts.starred }), ' ', "starred"] })) : null] })) : null, filter === 'starred' ? (_jsx("span", { className: "text-sub text-[12.5px]", children: "Shared with your team \u00B7 includes archived entries" })) : null, filter === 'spam' && counts ? (_jsxs(_Fragment, { children: [_jsxs("span", { className: "border-bdr bg-bg text-sub inline-flex items-center rounded-[6px] border px-[9px] py-1 text-[11.5px]", children: [_jsx("b", { className: "text-txt font-bold tabular-nums", children: visibleEntries.length }), "\u00A0in spam"] }), visibleEntries.length > 0 ? (_jsxs("div", { className: "text-sub flex flex-wrap items-center gap-3 text-[12.5px]", children: [_jsx("span", { children: "Kept for 30 days, then deleted." }), _jsx("button", { type: "button", onClick: () => setBlocklistTab('words'), className: "text-sub hover:bg-acc-l hover:text-acc rounded-[7px] px-[9px] py-1.5 text-[12.5px]", children: "Blocked words & domains" }), _jsx("button", { type: "button", onClick: () => onNavigate?.('/forms/settings'), className: "text-acc font-medium hover:underline", children: "Spam settings" }), _jsxs("button", { type: "button", onClick: () => void handleEmptySpam(), className: "border-bdr bg-card text-txt hover:border-acc-m hover:bg-acc-l hover:text-acc inline-flex items-center gap-1.5 rounded-[8px] border px-3 py-1.5 text-[13px]", children: [_jsx(Trash2, { size: 13, "aria-hidden": true }), "Empty spam"] })] })) : null] })) : null, filter === 'partial' ? (_jsxs("span", { className: "border-bdr bg-bg text-sub inline-flex items-center gap-1 rounded-[6px] border px-[9px] py-1 text-[11.5px]", children: [_jsx("b", { className: "text-txt font-bold tabular-nums", children: partialCount }), " didn\u2019t finish \u00B7 kept 30 days"] })) : null, filter === 'trash' ? (_jsxs(_Fragment, { children: [_jsxs("span", { className: "border-bdr bg-bg text-sub inline-flex items-center gap-1 rounded-[6px] border px-[9px] py-1 text-[11.5px]", children: [_jsx("b", { className: "text-txt font-bold tabular-nums", children: trashCount }), " in trash"] }), _jsxs("div", { className: "text-sub flex flex-wrap items-center gap-3 text-[12.5px]", children: [_jsx("span", { children: "Deleted entries are kept for 30 days, then removed for good." }), trashCount > 0 ? (_jsxs("button", { type: "button", onClick: () => setEmptyTrashOpen(true), className: "border-bdr bg-card text-txt hover:border-acc-m hover:bg-acc-l hover:text-acc inline-flex items-center gap-1.5 rounded-[8px] border px-3 py-1.5 text-[13px]", children: [_jsx(Trash2, { size: 13, "aria-hidden": true }), "Empty trash"] })) : null] })] })) : null, _jsxs("div", { className: "ml-auto flex items-center gap-[7px]", children: [formId ? null : (_jsxs("select", { "aria-label": "Filter by form", value: formFilter, onChange: (event) => pickForm(event.target.value), className: "inbox-header-control", children: [_jsx("option", { value: "all", children: "All forms" }), forms.map((form) => (_jsx("option", { value: form.id, children: form.name }, form.id)))] })), _jsx(ExportMenu, { formId: scopedFormId, folder: filter, search: search, assigneeId: currentUserId, disabled: counts !== null && counts.total === 0 && visibleEntries.length === 0, triggerClassName: "inbox-header-control" })] })] })] }), checked.size > 0 ? (_jsxs("div", { className: "border-acc-m bg-acc-l flex shrink-0 items-center gap-2 border-b px-6 py-[7px]", children: [_jsxs("b", { className: "text-acc text-[13px]", children: [checked.size, " selected"] }), filter === 'trash' ? (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: "text-sub hover:text-acc inline-flex items-center gap-1 rounded-[7px] px-[9px] py-1.5 text-[12.5px]", onClick: () => void bulkRestore(), children: [_jsx(RotateCcw, { size: 13, "aria-hidden": true }), "Restore"] }), _jsxs("button", { type: "button", className: "text-err inline-flex items-center gap-1 rounded-[7px] px-[9px] py-1.5 text-[12.5px]", onClick: () => void bulkDelete(), children: [_jsx(Trash2, { size: 13, "aria-hidden": true }), "Delete forever"] })] })) : (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "btn-ghost text-sub hover:text-acc rounded-[7px] px-[9px] py-1.5 text-[12.5px]", onClick: () => void bulk({ unread: false }, 'Marked read'), children: "Mark read" }), _jsx("button", { type: "button", className: "text-sub hover:text-acc rounded-[7px] px-[9px] py-1.5 text-[12.5px]", onClick: () => void bulk({ archived: true }, 'Archived'), children: "Archive" }), _jsx("button", { type: "button", className: "text-err rounded-[7px] px-[9px] py-1.5 text-[12.5px]", onClick: () => void bulkDelete(), children: filter === 'spam' ? 'Delete forever' : 'Delete' })] })), _jsx("button", { type: "button", className: "text-sub ml-auto rounded-[7px] px-[9px] py-1.5 text-[12.5px]", onClick: () => setChecked(new Set()), children: "Clear" })] })) : null, _jsxs("div", { className: `flex min-h-0 flex-1 ${narrow && activeId ? '' : ''}`, children: [showList ? (_jsxs("div", { className: "border-bdr bg-sb flex min-h-0 shrink-0 flex-col overflow-hidden border-r", style: { width: narrow ? '100%' : railW }, children: [_jsxs("div", { className: "border-bdr flex shrink-0 flex-col gap-2 border-b px-3 py-2.5", children: [_jsxs("div", { className: "inbox-search", children: [_jsx(Search, { size: 14, strokeWidth: 1.75, className: "shrink-0 text-[var(--muted)]", "aria-hidden": true }), _jsx("input", { id: searchId, ref: searchRef, value: search, onChange: (event) => setSearch(event.target.value), placeholder: "Search name, email, message\u2026", "aria-label": "Search entries" }), search ? (_jsx("button", { type: "button", "aria-label": "Clear search", onClick: () => setSearch(''), children: _jsx(X, { size: 13, strokeWidth: 1.75, "aria-hidden": true }) })) : null] }), _jsxs("div", { className: "flex items-center gap-1.5", children: [_jsxs("label", { className: "border-bdr bg-card text-txt focus-within:outline-acc inline-flex h-[30px] shrink-0 cursor-pointer items-center gap-1.5 rounded-[8px] border px-[9px] text-[12.5px] font-semibold focus-within:outline focus-within:outline-offset-1", children: [_jsx(FolderIcon, { size: 14, className: "text-sub shrink-0", "aria-hidden": true }), _jsx("select", { "aria-label": "Folder", value: folder, onChange: (event) => {
931
+ pickFilter(event.target.value);
932
+ setActiveId(null);
933
+ setChecked(new Set());
934
+ }, className: "cursor-pointer appearance-none border-0 bg-transparent pr-0.5 font-[inherit] text-inherit focus:outline-none", children: FOLDERS.map((item) => {
935
+ const count = item.id === 'all'
936
+ ? counts?.total
937
+ : item.id === 'starred'
938
+ ? counts?.starred
939
+ : item.id === 'archived'
940
+ ? counts?.archived
941
+ : item.id === 'spam'
942
+ ? counts?.spam
943
+ : item.id === 'partial'
944
+ ? partialCount
945
+ : item.id === 'trash'
946
+ ? trashCount
947
+ : undefined;
948
+ return (_jsxs("option", { value: item.id, children: [item.label, count && count > 0 ? ` (${count})` : ''] }, item.id));
949
+ }) }), _jsx(ChevronDown, { size: 13, className: "text-faint pointer-events-none", "aria-hidden": true })] }), folder === 'all' ? (_jsx("div", { className: "border-bdr bg-bg flex min-w-0 flex-1 gap-0.5 overflow-x-auto rounded-[8px] border p-0.5", role: "group", "aria-label": "Filter entries", children: VIEWS.map((item) => {
399
950
  const count = item.id === 'all'
400
951
  ? counts?.total
401
952
  : item.id === 'unread'
402
953
  ? counts?.unread
403
- : item.id === 'starred'
404
- ? counts?.starred
954
+ : item.id === 'mine'
955
+ ? mineCount
405
956
  : undefined;
406
957
  const on = filter === item.id;
407
958
  return (_jsxs("button", { type: "button", "aria-pressed": on, "aria-label": item.label, onClick: () => pickFilter(item.id), className: `flex flex-1 items-center justify-center gap-1 rounded-[6px] px-1.5 py-1 text-[11.5px] whitespace-nowrap ${on
408
959
  ? 'bg-card text-acc shadow-shd font-semibold'
409
960
  : 'text-sub hover:text-acc font-medium'}`, children: [item.label, count && count > 0 ? (_jsx("span", { className: "text-[10px] tabular-nums", children: count })) : null] }, item.id));
410
- }) }), _jsx("button", { type: "button", "aria-pressed": compact, "aria-label": compact ? 'Comfortable rows' : 'Compact rows', onClick: () => setCompact((value) => !value), className: "border-bdr text-sub hover:text-acc flex size-[30px] shrink-0 items-center justify-center rounded-[8px] border", children: _jsx(Rows3, { size: 15, "aria-hidden": true }) })] })] }), _jsx("div", { ref: listRef, className: "min-h-0 flex-1 overflow-y-auto", role: "region", "aria-label": "Form entries", children: error ? (_jsxs("p", { className: "text-err px-4 py-6 text-[13px]", role: "alert", children: [error, ' ', _jsx("button", { type: "button", className: "text-acc underline", onClick: () => void load(), children: "Retry" })] })) : loading ? (_jsx("div", { role: "status", "aria-label": "Loading entries", className: "flex flex-col gap-px", children: Array.from({ length: 6 }, (_, index) => (_jsx("div", { className: "border-bdr h-[72px] animate-pulse border-b bg-[var(--bg)]" }, index))) })) : entries.length === 0 ? (_jsxs("div", { className: "text-faint flex h-full flex-col items-center justify-center px-8 text-center", children: [_jsx("div", { className: "bg-acc-l text-acc mb-3 flex size-14 items-center justify-center rounded-[14px]", children: _jsx(Inbox, { size: 26, "aria-hidden": true }) }), _jsx("h2", { className: "text-txt m-0 text-[15px] font-semibold", children: "Nothing here" }), _jsx("p", { className: "mt-1 max-w-[320px] text-[13px] leading-[1.6]", children: search.trim()
961
+ }) })) : (_jsxs("button", { type: "button", onClick: () => {
962
+ pickFilter('all');
963
+ setActiveId(null);
964
+ }, className: "text-acc focus-visible:outline-acc inline-flex h-[30px] flex-1 items-center gap-1 rounded-[6px] px-1 text-[12.5px] font-medium hover:underline focus-visible:outline focus-visible:outline-offset-1", children: [_jsx(ChevronLeft, { size: 13, "aria-hidden": true }), "Back to Inbox"] })), _jsx("button", { type: "button", "aria-pressed": compact, "aria-label": compact ? 'Comfortable rows' : 'Compact rows', onClick: () => setCompact((value) => !value), className: "border-bdr text-sub hover:text-acc flex size-[30px] shrink-0 items-center justify-center rounded-[8px] border", children: _jsx(Rows3, { size: 15, "aria-hidden": true }) })] })] }), _jsx("div", { ref: listRef, className: "min-h-0 flex-1 overflow-y-auto", role: "region", "aria-label": "Form entries", children: error ? (_jsxs("p", { className: "text-err px-4 py-6 text-[13px]", role: "alert", children: [error, ' ', _jsx("button", { type: "button", className: "text-acc underline", onClick: () => void load(), children: "Retry" })] })) : loading ? (_jsx("div", { role: "status", "aria-label": "Loading entries", className: "flex flex-col gap-px", children: Array.from({ length: 6 }, (_, index) => (_jsx("div", { className: "border-bdr h-[72px] animate-pulse border-b bg-[var(--bg)]" }, index))) })) : visibleEntries.length === 0 ? (_jsxs("div", { className: "text-faint flex h-full flex-col items-center justify-center px-8 text-center", children: [_jsx("div", { className: "bg-acc-l text-acc mb-3 flex size-14 items-center justify-center rounded-[14px]", children: _jsx(Inbox, { size: 26, "aria-hidden": true }) }), _jsx("h2", { className: "text-txt m-0 text-[15px] font-semibold", children: "Nothing here" }), _jsx("p", { className: "mt-1 max-w-[320px] text-[13px] leading-[1.6]", children: search.trim()
411
965
  ? `No entries match “${search.trim()}”.`
412
- : 'No entries match this filter yet.' })] })) : (groups.map((group) => (_jsxs("section", { children: [_jsxs("h2", { className: "border-bdr bg-bg text-sub sticky top-0 z-[2] flex items-center gap-[7px] border-b px-3.5 py-[5px] text-[10px] font-bold tracking-[0.7px] uppercase", children: [group.label, _jsx("span", { className: "ml-auto font-semibold tracking-normal tabular-nums", children: group.entries.length })] }), group.entries.map((entry) => (_jsx(EntryRow, { entry: entry, selected: entry.id === activeId, checked: checked.has(entry.id), compact: compact, showForm: !formId && formFilter === 'all', onOpen: () => openEntry(entry.id), onCheck: () => setChecked((current) => {
966
+ : filter === 'trash'
967
+ ? 'Trash is empty. Deleted entries stay here for 30 days.'
968
+ : filter === 'starred'
969
+ ? 'Star an entry (S) to keep it here, even after you archive it.'
970
+ : filter === 'partial'
971
+ ? 'This folder is not available yet.'
972
+ : 'No entries match this filter yet.' })] })) : (groups.map((group) => (_jsxs("section", { children: [_jsxs("h2", { className: "border-bdr bg-bg text-sub sticky top-0 z-[2] flex items-center gap-[7px] border-b px-3.5 py-[5px] text-[10px] font-bold tracking-[0.7px] uppercase", children: [group.label, _jsx("span", { className: "ml-auto font-semibold tracking-normal tabular-nums", children: group.entries.length })] }), group.entries.map((entry) => (_jsx(EntryRow, { entry: entry, selected: entry.id === activeId, checked: checked.has(entry.id), compact: compact, showForm: !formId && formFilter === 'all', team: effectiveTeam, onOpen: () => openEntry(entry.id), onCheck: () => setChecked((current) => {
413
973
  const next = new Set(current);
414
974
  if (next.has(entry.id))
415
975
  next.delete(entry.id);
416
976
  else
417
977
  next.add(entry.id);
418
978
  return next;
419
- }), onStar: () => void patchOne(entry.id, { starred: !entry.starred }) }, entry.id)))] }, group.label)))) }), _jsxs("div", { className: "border-bdr text-faint flex shrink-0 items-center gap-2 border-t px-3 py-[7px] text-[11px]", children: [_jsxs("span", { children: ["Showing ", _jsx("b", { className: "text-sub font-semibold tabular-nums", children: entries.length }), " of", ' ', _jsx("b", { className: "text-sub font-semibold tabular-nums", children: unsupported ? 0 : total })] }), _jsx("span", { className: "ml-auto", children: unreadInList > 0 ? (_jsxs(_Fragment, { children: [_jsx("b", { className: "text-sub font-semibold tabular-nums", children: unreadInList }), " unread"] })) : ('All caught up') })] })] })) : null, showList && showDetail && !narrow ? (_jsx("button", { type: "button", role: "separator", "aria-orientation": "vertical", "aria-valuemin": RAIL_MIN, "aria-valuemax": RAIL_MAX, "aria-valuenow": railW, "aria-label": "Resize entry list", className: `bg-bg relative z-[3] w-[7px] shrink-0 cursor-col-resize border-0 p-0 ${dragging ? 'bg-acc' : ''}`, onPointerDown: startDrag, onDoubleClick: () => {
979
+ }), onStar: () => void patchOne(entry.id, { starred: !entry.starred }) }, entry.id)))] }, group.label)))) }), _jsxs("div", { className: "border-bdr text-faint flex shrink-0 items-center gap-2 border-t px-3 py-[7px] text-[11px]", children: [_jsxs("span", { children: ["Showing", ' ', _jsx("b", { className: "text-sub font-semibold tabular-nums", children: visibleEntries.length }), " of", ' ', _jsx("b", { className: "text-sub font-semibold tabular-nums", children: unsupported ? 0 : (counts?.total ?? total) })] }), _jsx("span", { className: "ml-auto", children: unreadInList > 0 ? (_jsxs(_Fragment, { children: [_jsx("b", { className: "text-sub font-semibold tabular-nums", children: unreadInList }), " unread"] })) : ('All caught up') })] })] })) : null, showList && showDetail && !narrow ? (_jsx("button", { type: "button", role: "separator", "aria-orientation": "vertical", "aria-valuemin": RAIL_MIN, "aria-valuemax": RAIL_MAX, "aria-valuenow": railW, "aria-label": "Resize entry list", className: `bg-bg relative z-[3] w-[7px] shrink-0 cursor-col-resize border-0 p-0 ${dragging ? 'bg-acc' : ''}`, onPointerDown: startDrag, onDoubleClick: () => {
420
980
  setRailW(RAIL_DEFAULT);
421
981
  try {
422
982
  globalThis.localStorage?.setItem(RAIL_KEY, String(RAIL_DEFAULT));
@@ -445,13 +1005,20 @@ export function EntriesInbox({ formId, onNavigate }) {
445
1005
  catch {
446
1006
  // Ignore a document with no storage.
447
1007
  }
448
- }, children: _jsx("span", { className: "bg-bdr absolute inset-y-0 right-[3px] left-[3px]", "aria-hidden": true }) })) : null, showDetail ? (_jsx("div", { className: "bg-bg min-h-0 min-w-0 flex-1 overflow-y-auto", role: "region", "aria-label": "Entry details", children: active ? (_jsx(EntryDetail, { entry: active, list: entries, narrow: narrow, onClose: () => setActiveId(null), onOpen: openEntry, onPatch: patchOne, onDelete: (id) => setConfirmDelete([id]) })) : (_jsxs("div", { className: "flex h-full flex-col items-center justify-center px-8 text-center", children: [_jsx("div", { className: "bg-acc-l text-acc mb-3 flex size-14 items-center justify-center rounded-[14px]", children: _jsx(Inbox, { size: 26, "aria-hidden": true }) }), _jsx("h2", { className: "text-txt m-0 text-[15px] font-semibold", children: "No entry selected" }), _jsx("p", { className: "text-sub mt-1 max-w-[320px] text-[13px] leading-[1.6]", children: "Pick a submission on the left to read every field, the attribution trail, and reply without leaving the page." }), _jsxs("div", { className: "text-sub mt-[18px] flex flex-wrap justify-center gap-3.5 text-[11.5px]", children: [_jsxs("span", { children: [_jsx("kbd", { className: "border-bdr bg-card text-sub mr-1 rounded-[5px] border border-b-2 px-1.5 py-0.5 font-mono text-[10.5px]", children: "J" }), _jsx("kbd", { className: "border-bdr bg-card text-sub rounded-[5px] border border-b-2 px-1.5 py-0.5 font-mono text-[10.5px]", children: "K" }), ' ', "move"] }), _jsxs("span", { children: [_jsx("kbd", { className: "border-bdr bg-card text-sub rounded-[5px] border border-b-2 px-1.5 py-0.5 font-mono text-[10.5px]", children: "S" }), ' ', "star"] }), _jsxs("span", { children: [_jsx("kbd", { className: "border-bdr bg-card text-sub rounded-[5px] border border-b-2 px-1.5 py-0.5 font-mono text-[10.5px]", children: "U" }), ' ', "unread"] }), _jsxs("span", { children: [_jsx("kbd", { className: "border-bdr bg-card text-sub rounded-[5px] border border-b-2 px-1.5 py-0.5 font-mono text-[10.5px]", children: "E" }), ' ', "archive"] }), _jsxs("span", { children: [_jsx("kbd", { className: "border-bdr bg-card text-sub rounded-[5px] border border-b-2 px-1.5 py-0.5 font-mono text-[10.5px]", children: "/" }), ' ', "search"] })] })] })) })) : null] }), _jsx(ConfirmDialog, { open: confirmDelete !== null, onClose: () => setConfirmDelete(null), onConfirm: () => void confirmAndDelete(), title: confirmDelete && confirmDelete.length > 1
1008
+ }, children: _jsx("span", { className: "bg-bdr absolute inset-y-0 right-[3px] left-[3px]", "aria-hidden": true }) })) : null, showDetail ? (_jsx("div", { className: "bg-bg @container min-h-0 min-w-0 flex-1 overflow-x-hidden overflow-y-auto", role: "region", "aria-label": "Entry details", children: active ? (_jsx(EntryDetail, { entry: active, list: visibleEntries, narrow: narrow, team: effectiveTeam, currentUserId: currentUserId || 'self', currentUserName: currentUserName || 'You', blocked: blocked, onClose: () => setActiveId(null), onOpen: openEntry, onPatch: patchOne, onDelete: (id) => void handleTrashOrDelete(id), onRestore: (id) => void handleRestore(id), onBlockDomain: handleBlockDomain, onManageBlocklist: (kind) => setBlocklistTab(kind), onFindEmail: (emailAddr) => {
1009
+ pickFilter('all');
1010
+ setSearch(emailAddr);
1011
+ } })) : (_jsxs("div", { className: "flex h-full flex-col items-center justify-center px-8 text-center", children: [_jsx("div", { className: "bg-acc-l text-acc mb-3 flex size-14 items-center justify-center rounded-[14px]", children: _jsx(Inbox, { size: 26, "aria-hidden": true }) }), _jsx("h2", { className: "text-txt m-0 text-[15px] font-semibold", children: "No entry selected" }), _jsx("p", { className: "text-sub mt-1 max-w-[320px] text-[13px] leading-[1.6]", children: "Pick a submission on the left to read every field, the attribution trail, and reply without leaving the page." }), _jsxs("div", { className: "text-sub mt-[18px] flex flex-wrap justify-center gap-3.5 text-[11.5px]", children: [_jsxs("span", { children: [_jsx("kbd", { className: "border-bdr bg-card text-sub mr-1 rounded-[5px] border border-b-2 px-1.5 py-0.5 font-mono text-[10.5px]", children: "J" }), _jsx("kbd", { className: "border-bdr bg-card text-sub rounded-[5px] border border-b-2 px-1.5 py-0.5 font-mono text-[10.5px]", children: "K" }), ' ', "move"] }), _jsxs("span", { children: [_jsx("kbd", { className: "border-bdr bg-card text-sub rounded-[5px] border border-b-2 px-1.5 py-0.5 font-mono text-[10.5px]", children: "S" }), ' ', "star"] }), _jsxs("span", { children: [_jsx("kbd", { className: "border-bdr bg-card text-sub rounded-[5px] border border-b-2 px-1.5 py-0.5 font-mono text-[10.5px]", children: "U" }), ' ', "unread"] }), _jsxs("span", { children: [_jsx("kbd", { className: "border-bdr bg-card text-sub rounded-[5px] border border-b-2 px-1.5 py-0.5 font-mono text-[10.5px]", children: "E" }), ' ', "archive"] }), _jsxs("span", { children: [_jsx("kbd", { className: "border-bdr bg-card text-sub rounded-[5px] border border-b-2 px-1.5 py-0.5 font-mono text-[10.5px]", children: "/" }), ' ', "search"] })] })] })) })) : null] }), _jsx(ConfirmDialog, { open: confirmDelete !== null, onClose: () => setConfirmDelete(null), onConfirm: () => void confirmAndDelete(), title: confirmDelete && confirmDelete.length > 1
449
1012
  ? `Delete ${confirmDelete.length} entries?`
450
- : 'Delete this entry?', description: "This cannot be undone.", confirmLabel: "Delete", destructive: true })] }));
1013
+ : 'Delete this entry?', description: "This cannot be undone.", confirmLabel: "Delete", destructive: true }), emptyTrashOpen ? (_jsx(EmptyTrashDialog, { count: trashCount, onClose: () => setEmptyTrashOpen(false), onConfirm: () => void handleEmptyTrash() })) : null, blocklistTab !== null ? (_jsx(BlocklistDialog, { open: true, initialTab: blocklistTab, value: blocked, onChange: (next) => void handleBlocklistChange(next), onClose: () => setBlocklistTab(null) })) : null, _jsx("div", { role: "status", "aria-live": "polite", className: "sr-only", children: toastMsg }), toastMsg ? (_jsxs("div", { className: `bg-txt text-sb shadow-shd2 fixed bottom-6 left-1/2 z-[200] -translate-x-1/2 rounded-[8px] text-[13px] font-medium ${toastUndo
1014
+ ? 'pointer-events-auto flex items-center gap-3.5 py-[7px] pr-2 pl-[18px]'
1015
+ : 'pointer-events-none px-[18px] py-[9px]'}`, children: [_jsx("span", { "aria-hidden": "true", children: toastMsg }), toastUndo ? (_jsx("button", { type: "button", onClick: toastUndo, className: "text-acc-m min-h-[28px] cursor-pointer rounded-[6px] border-0 bg-transparent px-2 py-1 font-[inherit] font-medium hover:opacity-85 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-current", children: "Undo" })) : null] })) : null] }));
451
1016
  }
452
- function EntryRow({ entry, selected, checked, compact, showForm, onOpen, onCheck, onStar, }) {
1017
+ function EntryRow({ entry, selected, checked, compact, showForm, team, onOpen, onCheck, onStar, }) {
453
1018
  const name = senderName(entry);
454
1019
  const preview = entryPreview(entry);
1020
+ const assignee = entry.assigneeId ? team.find((t) => t.id === entry.assigneeId) : undefined;
1021
+ const noteCount = entry.notes?.length ?? 0;
455
1022
  return (_jsxs("div", { "data-entry": entry.id, role: "article", tabIndex: 0, "aria-current": selected ? 'true' : undefined, "aria-label": `${name}${entry.unread ? ' (unread)' : ''}`, onClick: onOpen, onKeyDown: (event) => {
456
1023
  if (event.key === 'Enter' || event.key === ' ') {
457
1024
  event.preventDefault();
@@ -464,53 +1031,225 @@ function EntryRow({ entry, selected, checked, compact, showForm, onOpen, onCheck
464
1031
  onCheck();
465
1032
  }, className: `flex size-6 items-center justify-center rounded-[4px] border-[1.5px] ${checked
466
1033
  ? 'border-acc bg-acc text-[var(--on-acc)]'
467
- : 'border-bdr bg-card text-transparent'}`, children: _jsx(Check, { size: 11, "aria-hidden": true }) }), compact ? null : (_jsxs("span", { className: "relative flex size-8 items-center justify-center rounded-full text-[12px] font-bold", style: { background: avatarColor(name), color: '#fff' }, children: [initials(name), entry.unread ? (_jsx("span", { className: "bg-acc absolute -top-px -right-px size-[9px] rounded-full border-2 border-[var(--sb)]" })) : null] }))] }), _jsxs("div", { className: "min-w-0", children: [_jsxs("div", { className: "flex items-baseline gap-2", children: [_jsx("div", { className: `text-txt min-w-0 flex-1 truncate text-[13px] ${entry.unread ? 'font-bold' : 'font-medium'}`, children: name }), _jsx("div", { className: "text-sub shrink-0 text-[11px] tabular-nums", children: relativeEntryTime(entry.submittedAt) })] }), _jsx("p", { className: `mt-0.5 text-[12.5px] leading-[1.45] ${entry.unread ? 'text-txt' : 'text-sub'} ${compact ? 'line-clamp-1' : 'line-clamp-2'}`, children: preview }), _jsxs("div", { className: "mt-[3px] flex items-center gap-1.5", children: [showForm && entry.formName ? (_jsx("span", { className: "bg-acc-l text-acc rounded-[5px] px-[7px] py-0.5 text-[10px] font-semibold whitespace-nowrap", children: entry.formName })) : null, entry.spamStatus === 'spam' ? (_jsx("span", { className: "bg-err-l text-err rounded-[5px] px-[7px] py-0.5 text-[10px] font-semibold", children: "Spam" })) : entry.spamStatus === 'suspected' ? (_jsx("span", { className: "bg-err-l text-err rounded-[5px] px-[7px] py-0.5 text-[10px] font-semibold", children: "Likely spam" })) : null, entry.archived ? (_jsx("span", { className: "border-bdr text-faint rounded-[5px] border px-[7px] py-0.5 text-[10px] font-semibold", children: "Archived" })) : null, _jsx("button", { type: "button", "aria-pressed": entry.starred, "aria-label": entry.starred ? 'Unstar' : 'Star', onClick: (event) => {
1034
+ : 'border-bdr bg-card text-transparent'}`, children: _jsx(Check, { size: 11, "aria-hidden": true }) }), compact ? null : (_jsxs("span", { className: "relative flex size-8 items-center justify-center rounded-full text-[12px] font-bold", style: { background: avatarColor(name), color: 'var(--on-acc)' }, children: [initials(name), entry.unread ? (_jsx("span", { className: "bg-acc absolute -top-px -right-px size-[9px] rounded-full border-2 border-[var(--sb)]" })) : null] }))] }), _jsxs("div", { className: "min-w-0", children: [_jsxs("div", { className: "flex items-baseline gap-2", children: [_jsx("div", { className: `text-txt min-w-0 flex-1 truncate text-[13px] ${entry.unread ? 'font-bold' : 'font-medium'}`, children: name }), _jsx("div", { className: "text-sub shrink-0 text-[11px] tabular-nums", children: relativeEntryTime(entry.submittedAt) })] }), _jsx("p", { className: `mt-0.5 text-[12.5px] leading-[1.45] ${entry.unread ? 'text-txt' : 'text-sub'} ${compact ? 'line-clamp-1' : 'line-clamp-2'}`, children: preview }), _jsxs("div", { className: "mt-[3px] flex items-center gap-1.5", children: [showForm && entry.formName ? (_jsx("span", { className: "rounded-[5px] px-[7px] py-0.5 text-[10px] font-semibold whitespace-nowrap", style: {
1035
+ background: formBadgeStyle(entry.formSlug).bg,
1036
+ color: formBadgeStyle(entry.formSlug).fg,
1037
+ }, children: entry.formName })) : null, entry.spamStatus === 'spam' ? (_jsx("span", { className: "bg-err-l text-err rounded-[5px] px-[7px] py-0.5 text-[10px] font-semibold", children: entry.spamMeta?.by ? (SPAM_BY_LABELS[entry.spamMeta.by] ?? 'Spam') : 'Spam' })) : entry.spamStatus === 'suspected' ? (_jsx("span", { className: "bg-err-l text-err rounded-[5px] px-[7px] py-0.5 text-[10px] font-semibold", children: "Likely spam" })) : null, entry.deleted
1038
+ ? (() => {
1039
+ const d = daysLeftInTrash(entry.deleted.at);
1040
+ const [fg, bg] = d <= 3
1041
+ ? ['var(--err)', 'var(--err-l)']
1042
+ : d <= 7
1043
+ ? ['var(--warn)', 'var(--warn-l)']
1044
+ : ['var(--sub)', 'var(--bg)'];
1045
+ return (_jsx("span", { className: "rounded-[5px] border px-[7px] py-0.5 text-[10px] font-semibold whitespace-nowrap", style: {
1046
+ color: fg,
1047
+ background: bg,
1048
+ borderColor: `color-mix(in srgb, ${fg} 22%, transparent)`,
1049
+ }, children: d === 0 ? 'Removes today' : `Removes in ${d} ${d === 1 ? 'day' : 'days'}` }));
1050
+ })()
1051
+ : null, entry.archived ? (_jsx("span", { className: "border-bdr bg-bg text-faint rounded-[5px] border px-[7px] py-0.5 text-[10px] font-semibold", children: "Archived" })) : null, entry.partial ? (_jsx("span", { className: "bg-warn-l text-warn rounded-[5px] px-[7px] py-0.5 text-[10px] font-semibold whitespace-nowrap", children: `Stopped at step ${entry.partial.step} of ${entry.partial.of}` })) : entry.spamStatus !== 'spam' && entry.status && entry.status !== 'new' ? (_jsx("span", { className: "rounded-[5px] px-[7px] py-0.5 text-[10px] font-semibold whitespace-nowrap", style: {
1052
+ background: pipeOf(entry.status).bg,
1053
+ color: pipeOf(entry.status).fg,
1054
+ }, children: pipeOf(entry.status).label })) : null, entry.spamStatus !== 'spam' && !entry.partial && noteCount > 0 ? (_jsxs("span", { className: "text-sub inline-flex items-center gap-[3px] text-[10.5px] font-semibold", title: `${noteCount} ${noteCount === 1 ? 'note' : 'notes'}`, children: [_jsx(MessageSquare, { size: 11, "aria-hidden": true }), noteCount] })) : null, entry.spamStatus !== 'spam' && !entry.partial && assignee ? (_jsx("span", { className: "inline-flex size-[18px] shrink-0 items-center justify-center rounded-full text-[8px] font-bold tracking-[-0.2px]", style: { background: avatarColor(assignee.name), color: 'var(--on-acc)' }, title: assignee.name, children: initials(assignee.name) })) : null, !entry.deleted ? (_jsx("button", { type: "button", "aria-pressed": entry.starred, "aria-label": entry.starred ? 'Unstar' : 'Star', onClick: (event) => {
468
1055
  event.stopPropagation();
469
1056
  onStar();
470
- }, className: `ml-auto flex size-6 items-center justify-center ${entry.starred ? 'text-warn' : 'text-faint hover:text-warn'}`, children: _jsx(Star, { size: 14, "aria-hidden": true, className: entry.starred ? 'fill-current' : '' }) })] })] })] }));
1057
+ }, className: `ml-auto flex size-6 items-center justify-center ${entry.starred ? 'text-warn' : 'text-faint hover:text-warn'}`, children: _jsx(Star, { size: 14, "aria-hidden": true, className: entry.starred ? 'fill-current' : '' }) })) : null] })] })] }));
471
1058
  }
472
- function EntryDetail({ entry, list, narrow, onClose, onOpen, onPatch, onDelete, }) {
1059
+ function EntryDetail({ entry, list, narrow, team, currentUserId, currentUserName, blocked, onClose, onOpen, onPatch, onDelete, onRestore, onBlockDomain, onManageBlocklist, onFindEmail, }) {
473
1060
  const [fields, setFields] = useState([]);
1061
+ const [otherCount, setOtherCount] = useState(entry.otherEntryCount ?? 0);
474
1062
  const [metaOpen, setMetaOpen] = useState(true);
1063
+ const [showEmpty, setShowEmpty] = useState(false);
1064
+ const [noteText, setNoteText] = useState('');
1065
+ const notes = entry.notes ?? [];
475
1066
  const index = list.findIndex((item) => item.id === entry.id);
476
1067
  const name = senderName(entry);
477
1068
  const email = entry.senderEmail || '';
478
1069
  const phone = entry.senderPhone || '';
479
1070
  const website = typeof entry.data.website === 'string' ? entry.data.website : '';
480
1071
  const formLabel = entry.formName || 'Form';
1072
+ const formColor = formBadgeStyle(entry.formSlug);
1073
+ const attr = getEntryAttributionSummary(entry);
1074
+ const pipe = pipeOf(entry.status);
1075
+ const assignee = entry.assigneeId ? team.find((t) => t.id === entry.assigneeId) : undefined;
1076
+ const emailDomain = (email.split('@')[1] ?? '').trim().toLowerCase();
1077
+ const isFreeDomain = Boolean(emailDomain && FREE_EMAIL_DOMAINS.has(emailDomain));
1078
+ const isDomainBlocked = Boolean(emailDomain && blocked.domains.some((d) => d.term === emailDomain));
481
1079
  useEffect(() => {
1080
+ setShowEmpty(false);
1081
+ setNoteText('');
1082
+ setOtherCount(entry.otherEntryCount ?? 0);
482
1083
  let cancelled = false;
483
1084
  void fetchEntry(entry.id).then((detail) => {
484
- if (!cancelled)
485
- setFields(detail?.fields ?? []);
1085
+ if (!cancelled && detail) {
1086
+ setFields(detail.fields ?? []);
1087
+ if (typeof detail.otherEntryCount === 'number')
1088
+ setOtherCount(detail.otherEntryCount);
1089
+ else if (typeof detail.entry?.otherEntryCount === 'number') {
1090
+ setOtherCount(detail.entry.otherEntryCount);
1091
+ }
1092
+ }
486
1093
  });
487
1094
  return () => {
488
1095
  cancelled = true;
489
1096
  };
490
- }, [entry.id]);
491
- const ordered = fields.length
492
- ? fields.map((field) => ({ key: field.key, label: field.label || field.key }))
493
- : Object.keys(entry.data).map((key) => ({ key, label: key }));
1097
+ }, [entry.id, entry.otherEntryCount]);
1098
+ const fieldMap = useMemo(() => new Map(fields.map((f) => [f.key, f])), [fields]);
1099
+ const present = useMemo(() => {
1100
+ const inputFields = fields.filter((field) => !NON_INPUT_FIELD_SET.has(field.type));
1101
+ if (inputFields.length > 0) {
1102
+ const schemaRows = inputFields.map((field) => ({
1103
+ key: field.key,
1104
+ label: field.label || humanizeFieldKey(field.key),
1105
+ }));
1106
+ const schemaKeys = new Set(schemaRows.map((r) => r.key));
1107
+ const extraRows = Object.keys(entry.data)
1108
+ .filter((key) => !schemaKeys.has(key) && entry.data[key] !== undefined)
1109
+ .map((key) => ({ key, label: humanizeFieldKey(key) }));
1110
+ return [...schemaRows, ...extraRows];
1111
+ }
1112
+ return Object.keys(entry.data)
1113
+ .filter((key) => entry.data[key] !== undefined)
1114
+ .map((key) => ({ key, label: humanizeFieldKey(key) }));
1115
+ }, [fields, entry.data]);
1116
+ const msgEntry = useMemo(() => {
1117
+ const direct = present.find(({ key }) => (key === 'message' || key === 'description') && displayValue(entry.data[key]));
1118
+ if (direct)
1119
+ return direct;
1120
+ const longFilled = present
1121
+ .filter(({ key }) => LONG_MESSAGE_FIELDS.has(key) && displayValue(entry.data[key]).length > 0)
1122
+ .sort((a, b) => displayValue(entry.data[b.key]).length - displayValue(entry.data[a.key]).length);
1123
+ if (longFilled[0])
1124
+ return longFilled[0];
1125
+ return present.find(({ key }) => displayValue(entry.data[key]).length > 70) ?? null;
1126
+ }, [present, entry.data]);
1127
+ const submissionRows = useMemo(() => present.filter(({ key }) => key !== msgEntry?.key), [present, msgEntry]);
1128
+ const filledRows = useMemo(() => submissionRows.filter(({ key }) => Boolean(displayValue(entry.data[key]))), [submissionRows, entry.data]);
1129
+ const emptyRows = useMemo(() => submissionRows.filter(({ key }) => !displayValue(entry.data[key])), [submissionRows, entry.data]);
1130
+ const answeredCount = useMemo(() => present.filter(({ key }) => Boolean(displayValue(entry.data[key]))).length, [present, entry.data]);
1131
+ const firstName = (typeof entry.data.first_name === 'string' && entry.data.first_name.trim()) ||
1132
+ name.split(/\s+/)[0] ||
1133
+ '';
1134
+ const msgText = msgEntry ? displayValue(entry.data[msgEntry.key]) : '';
1135
+ const mailHref = email
1136
+ ? `mailto:${email}?subject=${encodeURIComponent(`Re: your ${formLabel} request`)}&body=${encodeURIComponent(`Hi ${firstName},\n\n\n\n—\nOn ${fullEntryTime(entry.submittedAt)} you wrote:\n${msgText
1137
+ .split('\n')
1138
+ .map((line) => `> ${line}`)
1139
+ .join('\n')}`)}`
1140
+ : undefined;
494
1141
  function copyAll() {
495
- const lines = ordered
496
- .map(({ key, label }) => `${label}: ${displayValue(entry.data[key]) || '—'}`)
1142
+ const lines = present
1143
+ .map(({ key, label }) => `${label}: ${formatFieldDisplay(key, displayValue(entry.data[key]), fieldMap.get(key)) || '—'}`)
497
1144
  .join('\n');
498
1145
  void navigator.clipboard?.writeText(lines);
499
1146
  toast.success('Copied all fields');
500
1147
  }
501
- const iconBtn = 'text-sub hover:bg-acc-l hover:text-acc flex size-[30px] items-center justify-center rounded-[8px] disabled:opacity-30';
502
- return (_jsxs("div", { className: "mx-auto max-w-[820px] px-6 py-5 pb-10 max-[900px]:px-3.5", children: [_jsxs("article", { className: "border-bdr bg-card shadow-shd mb-3.5 overflow-hidden rounded-[10px] border", children: [_jsxs("div", { className: "border-bdr flex items-start gap-3.5 border-b px-5 py-[18px]", children: [narrow ? (_jsx("button", { type: "button", className: iconBtn, "aria-label": "Back to list", onClick: onClose, children: _jsx(ChevronLeft, { size: 18, "aria-hidden": true }) })) : null, _jsx("span", { className: "flex size-12 shrink-0 items-center justify-center rounded-[12px] text-[17px] font-bold", style: { background: avatarColor(name), color: '#fff' }, children: initials(name) }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("h2", { className: "text-txt m-0 text-[19px] leading-[1.2] font-bold tracking-[-0.3px]", children: name }), _jsxs("div", { className: "mt-1.5 flex flex-wrap items-center gap-x-3.5 gap-y-1.5 text-[13px]", children: [email ? (_jsxs("a", { className: "text-acc inline-flex items-center gap-[5px]", href: `mailto:${email}`, children: [_jsx(Mail, { size: 13, "aria-hidden": true }), email] })) : null, phone ? (_jsxs("a", { className: "text-acc inline-flex items-center gap-[5px]", href: `tel:${phone.replace(/[^\d+]/g, '')}`, children: [_jsx(Phone, { size: 13, "aria-hidden": true }), phone] })) : null, website ? (_jsxs("a", { className: "text-acc inline-flex items-center gap-[5px]", href: website, target: "_blank", rel: "noopener noreferrer", children: [_jsx(Globe, { size: 13, "aria-hidden": true }), website.replace(/^https?:\/\//, '').replace(/\/$/, '')] })) : null] }), _jsxs("div", { className: "mt-[9px] flex flex-wrap items-center gap-1.5", children: [_jsx("span", { className: "bg-acc-l text-acc rounded-[5px] px-[7px] py-0.5 text-[10px] font-semibold", children: formLabel }), _jsx("span", { className: `rounded-[5px] px-2 py-[3px] text-[11px] font-semibold ${entry.unread ? 'bg-acc-l text-acc' : 'border-bdr bg-bg text-sub border'}`, children: entry.unread ? 'Unread' : 'Read' }), entry.starred ? (_jsxs("span", { className: "bg-warn-l text-warn inline-flex items-center gap-1 rounded-[5px] px-2 py-[3px] text-[11px] font-semibold", children: [_jsx(Star, { size: 11, "aria-hidden": true, className: "fill-current" }), " Starred"] })) : null, entry.archived ? (_jsx("span", { className: "border-bdr text-faint rounded-[5px] border px-2 py-[3px] text-[11px] font-semibold", children: "Archived" })) : null, _jsx("span", { className: "text-faint text-[12px]", children: fullEntryTime(entry.submittedAt) })] })] }), _jsxs("div", { className: "flex shrink-0 items-center", children: [_jsx("button", { type: "button", className: iconBtn, "aria-label": "Previous entry", disabled: index <= 0, onClick: () => index > 0 && list[index - 1] && onOpen(list[index - 1].id), children: _jsx(ChevronLeft, { size: 15, "aria-hidden": true }) }), _jsx("button", { type: "button", className: iconBtn, "aria-label": "Next entry", disabled: index < 0 || index >= list.length - 1, onClick: () => list[index + 1] && onOpen(list[index + 1].id), children: _jsx(ChevronRight, { size: 15, "aria-hidden": true }) }), narrow ? null : (_jsx("button", { type: "button", className: iconBtn, "aria-label": "Close entry", onClick: onClose, children: _jsx(X, { size: 15, "aria-hidden": true }) }))] })] }), _jsxs("div", { className: "bg-bg flex flex-wrap items-center gap-1.5 px-5 py-2.5", children: [email ? (_jsx("a", { className: "bg-acc inline-flex items-center gap-1.5 rounded-[8px] px-[15px] py-2 text-[13px] font-medium text-[var(--on-acc)]", href: `mailto:${email}?subject=${encodeURIComponent(`Re: your ${formLabel} submission`)}`, children: "Reply" })) : null, _jsx(Ghost, { onClick: () => onPatch(entry.id, { unread: !entry.unread }, entry.unread ? 'Marked read' : 'Marked unread'), children: entry.unread ? 'Mark read' : 'Mark unread' }), _jsxs(Ghost, { onClick: () => onPatch(entry.id, { starred: !entry.starred }), children: [_jsx(Star, { size: 13, "aria-hidden": true, className: entry.starred ? 'text-warn fill-current' : '' }), entry.starred ? 'Unstar' : 'Star'] }), _jsxs(Ghost, { onClick: copyAll, children: [_jsx(Copy, { size: 13, "aria-hidden": true }), " Copy all"] }), _jsxs(Ghost, { onClick: () => onPatch(entry.id, { archived: !entry.archived }, entry.archived ? 'Unarchived' : 'Archived'), children: [_jsx(Archive, { size: 13, "aria-hidden": true }), " ", entry.archived ? 'Unarchive' : 'Archive'] }), _jsxs("button", { type: "button", className: "text-err hover:bg-err-l ml-auto inline-flex items-center gap-[5px] rounded-[7px] px-[9px] py-1.5 text-[12.5px]", onClick: () => onDelete(entry.id), children: [_jsx(Trash2, { size: 13, "aria-hidden": true }), " Delete"] })] })] }), _jsxs("article", { className: "border-bdr bg-card shadow-shd mb-3.5 overflow-hidden rounded-[10px] border", children: [_jsxs("div", { className: "border-bdr text-faint flex items-center px-5 py-[11px] text-[11px] font-bold tracking-[0.6px] uppercase", children: ["Submission", _jsxs("span", { className: "ml-auto text-[11.5px] font-semibold tracking-normal normal-case", children: [ordered.length, " fields"] })] }), _jsx("div", { className: "grid grid-cols-1 gap-x-5 gap-y-3.5 p-4 px-5 min-[620px]:grid-cols-2", children: ordered.map(({ key, label }) => {
503
- const value = displayValue(entry.data[key]);
504
- return (_jsxs("div", { className: `group ${fieldIsWide(key, value) ? 'min-[620px]:col-span-2' : ''}`, children: [_jsxs("div", { className: "text-faint mb-[5px] flex items-center gap-1.5 text-[10.5px] font-bold tracking-[0.5px] uppercase", children: [label, value ? (_jsx("button", { type: "button", "aria-label": `Copy ${label}`, className: "text-faint hover:text-acc hidden group-hover:inline-flex", onClick: () => {
505
- void navigator.clipboard?.writeText(value);
506
- toast.success('Copied');
507
- }, children: _jsx(Copy, { size: 11, "aria-hidden": true }) })) : null] }), _jsx("div", { className: `rounded-[8px] px-3 py-[9px] text-[14px] leading-[1.6] break-words whitespace-pre-wrap ${value ? 'border-bdr bg-bg text-txt border' : 'text-faint border-bdr border border-dashed italic'}`, children: value || 'Not provided' })] }, key));
508
- }) })] }), _jsxs("article", { className: "border-bdr bg-card shadow-shd overflow-hidden rounded-[10px] border", children: [_jsxs("button", { type: "button", className: "border-bdr text-faint hover:text-acc flex w-full items-center px-5 py-[11px] text-left text-[11px] font-bold tracking-[0.6px] uppercase", "aria-expanded": metaOpen, onClick: () => setMetaOpen((open) => !open), children: ["Attribution & technical", _jsx("span", { className: "ml-auto inline-flex items-center gap-1.5 text-[11.5px] font-semibold tracking-normal normal-case", children: _jsx(ChevronDown, { size: 14, "aria-hidden": true, className: metaOpen ? 'rotate-180' : '' }) })] }), metaOpen ? (_jsxs("dl", { className: "grid grid-cols-1 gap-[9px] px-5 py-3.5 min-[620px]:grid-cols-2", children: [_jsx(Meta, { label: "Submitted", value: fullEntryTime(entry.submittedAt) }), _jsx(Meta, { label: "Form", value: formLabel }), buildAttributionRows(entry).map((row) => (_jsx(Meta, { label: row.label, value: row.value }, row.label))), _jsx(Meta, { label: "User agent", value: entry.userAgent || '—' }), _jsx(Meta, { label: "Entry ID", value: entryIdLabel(entry), mono: true })] })) : null] })] }));
1148
+ function copyValue(value) {
1149
+ void navigator.clipboard?.writeText(value);
1150
+ toast.success('Copied');
1151
+ }
1152
+ function addNote() {
1153
+ const trimmed = noteText.trim();
1154
+ if (!trimmed)
1155
+ return;
1156
+ const nextNotes = [
1157
+ ...notes,
1158
+ {
1159
+ authorId: currentUserId,
1160
+ authorName: currentUserName,
1161
+ at: new Date().toISOString(),
1162
+ text: trimmed,
1163
+ },
1164
+ ];
1165
+ setNoteText('');
1166
+ onPatch(entry.id, { note: { text: trimmed, authorName: currentUserName }, notes: nextNotes }, 'Note added');
1167
+ }
1168
+ const iconBtn = 'text-sub hover:bg-acc-l hover:text-acc flex size-8 items-center justify-center rounded-[8px] disabled:opacity-30';
1169
+ const toolbarBtn = 'text-sub hover:bg-acc-l hover:text-acc inline-flex items-center gap-[5px] rounded-[7px] px-[9px] py-1.5 text-[12.5px] font-medium whitespace-nowrap @[0px]:max-[640px]:p-[7px]';
1170
+ return (_jsxs("div", { className: "min-h-full", children: [_jsxs("div", { role: "toolbar", "aria-label": "Entry actions", className: "border-bdr sticky top-0 z-[5] flex min-h-[52px] items-center gap-0.5 border-b bg-[color-mix(in_srgb,var(--card)_94%,transparent)] px-4 py-2 backdrop-blur-[8px]", children: [narrow ? (_jsx("button", { type: "button", className: iconBtn, "aria-label": "Back to list", onClick: onClose, children: _jsx(ChevronLeft, { size: 18, "aria-hidden": true }) })) : null, entry.deleted ? (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: "bg-acc mr-1 inline-flex items-center gap-1.5 rounded-[8px] px-[13px] py-[7px] text-[13px] font-medium text-[var(--on-acc)]", onClick: () => onRestore(entry.id), children: [_jsx(RotateCcw, { size: 14, "aria-hidden": true }), _jsx("span", { children: "Restore" })] }), _jsxs("button", { type: "button", className: toolbarBtn, title: "Copy all fields", onClick: copyAll, children: [_jsx(Copy, { size: 14, "aria-hidden": true }), _jsx("span", { className: "max-[640px]:sr-only", children: "Copy all" })] }), _jsx("span", { className: "flex-1" }), _jsxs("button", { type: "button", title: "Delete forever", className: "text-sub hover:bg-err-l hover:text-err inline-flex items-center gap-[5px] rounded-[7px] px-[9px] py-1.5 text-[12.5px] font-medium whitespace-nowrap", onClick: () => onDelete(entry.id), children: [_jsx(Trash2, { size: 14, "aria-hidden": true }), _jsx("span", { className: "max-[640px]:sr-only", children: "Delete forever" })] })] })) : entry.partial ? (_jsxs(_Fragment, { children: [email ? (_jsxs("a", { href: `mailto:${email}?subject=${encodeURIComponent(`Finish your ${formLabel} request`)}&body=${encodeURIComponent(`Hi ${firstName},\n\nLooks like you didn’t get to finish. Pick up where you left off here: /${entry.formSlug ?? ''}/?resume=${entry.id}`)}`, className: "bg-acc mr-1 inline-flex items-center gap-1.5 rounded-[8px] px-[13px] py-[7px] text-[13px] font-medium text-[var(--on-acc)] no-underline", children: [_jsx(Mail, { size: 14, "aria-hidden": true }), _jsx("span", { children: "Email link to finish" })] })) : null, _jsxs("button", { type: "button", className: toolbarBtn, title: "Treat as entry", onClick: () => onPatch(entry.id, { partial: null }, 'Moved to All entries', {
1171
+ partial: entry.partial,
1172
+ }), children: [_jsx(Check, { size: 14, "aria-hidden": true }), _jsx("span", { className: "max-[640px]:sr-only", children: "Treat as entry" })] }), _jsx("span", { className: "flex-1" }), _jsxs("button", { type: "button", title: "Delete", className: "text-sub hover:bg-err-l hover:text-err inline-flex items-center gap-[5px] rounded-[7px] px-[9px] py-1.5 text-[12.5px] font-medium whitespace-nowrap", onClick: () => onDelete(entry.id), children: [_jsx(Trash2, { size: 14, "aria-hidden": true }), _jsx("span", { className: "max-[640px]:sr-only", children: "Delete" })] })] })) : entry.spamStatus === 'spam' ? (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: "bg-acc mr-1 inline-flex items-center gap-1.5 rounded-[8px] px-[13px] py-[7px] text-[13px] font-medium text-[var(--on-acc)]", onClick: () => onPatch(entry.id, { spamStatus: 'clean', spamMeta: null }, 'Moved to inbox · we’ll learn from this', { spamStatus: 'spam', spamMeta: entry.spamMeta }, true), children: [_jsx(Check, { size: 14, "aria-hidden": true }), _jsx("span", { children: "Not spam" })] }), emailDomain ? (_jsxs("button", { type: "button", disabled: isFreeDomain || isDomainBlocked, title: isFreeDomain
1173
+ ? `${emailDomain} is a free email provider and can’t be blocked`
1174
+ : isDomainBlocked
1175
+ ? 'Already blocked'
1176
+ : 'Future entries from this domain go straight to Spam', className: `${toolbarBtn} disabled:cursor-not-allowed disabled:opacity-45`, onClick: () => onBlockDomain(emailDomain), children: [_jsx(ShieldX, { size: 14, "aria-hidden": true }), _jsx("span", { className: "max-[640px]:sr-only", children: isDomainBlocked ? 'Domain blocked' : `Block ${emailDomain}` })] })) : null, _jsx("button", { type: "button", className: toolbarBtn, title: "Block a word", onClick: () => onManageBlocklist('words'), children: _jsx("span", { className: "max-[640px]:sr-only", children: "Block a word\u2026" }) }), _jsxs("button", { type: "button", className: toolbarBtn, title: "Copy all", onClick: copyAll, children: [_jsx(Copy, { size: 14, "aria-hidden": true }), _jsx("span", { className: "max-[640px]:sr-only", children: "Copy all" })] }), _jsx("span", { className: "flex-1" }), _jsxs("button", { type: "button", title: "Delete forever", className: "text-sub hover:bg-err-l hover:text-err inline-flex items-center gap-[5px] rounded-[7px] px-[9px] py-1.5 text-[12.5px] font-medium whitespace-nowrap", onClick: () => onDelete(entry.id), children: [_jsx(Trash2, { size: 14, "aria-hidden": true }), _jsx("span", { className: "max-[640px]:sr-only", children: "Delete forever" })] })] })) : (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: toolbarBtn, title: entry.unread ? 'Mark read (U)' : 'Mark unread (U)', onClick: () => onPatch(entry.id, { unread: !entry.unread }, entry.unread ? 'Marked read' : 'Marked unread'), children: [entry.unread ? _jsx(Check, { size: 14, "aria-hidden": true }) : _jsx(Mail, { size: 14, "aria-hidden": true }), _jsx("span", { className: "max-[640px]:sr-only", children: entry.unread ? 'Mark read' : 'Mark unread' })] }), _jsxs("button", { type: "button", "aria-pressed": entry.starred, title: entry.starred ? 'Unstar (S)' : 'Star (S)', className: `${toolbarBtn} ${entry.starred ? 'text-warn' : ''}`, onClick: () => onPatch(entry.id, { starred: !entry.starred }), children: [_jsx(Star, { size: 14, "aria-hidden": true, className: entry.starred ? 'fill-current' : '' }), _jsx("span", { className: "max-[640px]:sr-only", children: entry.starred ? 'Starred' : 'Star' })] }), _jsxs("button", { type: "button", className: toolbarBtn, title: entry.archived ? 'Unarchive (E)' : 'Archive (E)', onClick: () => onPatch(entry.id, { archived: !entry.archived }, entry.archived ? 'Moved to inbox' : 'Archived', { archived: entry.archived }), children: [_jsx(Archive, { size: 14, "aria-hidden": true }), _jsx("span", { className: "max-[640px]:sr-only", children: entry.archived ? 'Unarchive' : 'Archive' })] }), _jsxs("button", { type: "button", className: toolbarBtn, title: "Copy all fields", onClick: copyAll, children: [_jsx(Copy, { size: 14, "aria-hidden": true }), _jsx("span", { className: "max-[640px]:sr-only", children: "Copy all" })] }), _jsx("span", { className: "flex-1" }), _jsxs("button", { type: "button", className: toolbarBtn, title: "Mark as spam", onClick: () => onPatch(entry.id, {
1177
+ spamStatus: 'spam',
1178
+ spamMeta: { by: 'manual', reason: 'Marked as spam by you.' },
1179
+ }, 'Moved to Spam', { spamStatus: entry.spamStatus, spamMeta: null }, true), children: [_jsx(ShieldX, { size: 14, "aria-hidden": true }), _jsx("span", { className: "max-[640px]:sr-only", children: "Spam" })] }), _jsxs("button", { type: "button", title: "Delete", className: "text-sub hover:bg-err-l hover:text-err inline-flex items-center gap-[5px] rounded-[7px] px-[9px] py-1.5 text-[12.5px] font-medium whitespace-nowrap", onClick: () => onDelete(entry.id), children: [_jsx(Trash2, { size: 14, "aria-hidden": true }), _jsx("span", { className: "max-[640px]:sr-only", children: "Delete" })] })] })), _jsx("span", { className: "bg-bdr mx-2 h-5 w-px shrink-0" }), _jsx("button", { type: "button", className: iconBtn, title: "Previous (K)", "aria-label": "Previous entry", disabled: index <= 0, onClick: () => index > 0 && list[index - 1] && onOpen(list[index - 1].id), children: _jsx(ChevronLeft, { size: 15, "aria-hidden": true }) }), index >= 0 ? (_jsxs("span", { "aria-live": "polite", className: "text-faint mx-1 text-[12px] whitespace-nowrap tabular-nums max-[640px]:sr-only", children: ["Entry ", index + 1, " of ", list.length] })) : null, _jsx("button", { type: "button", className: iconBtn, title: "Next (J)", "aria-label": "Next entry", disabled: index < 0 || index >= list.length - 1, onClick: () => list[index + 1] && onOpen(list[index + 1].id), children: _jsx(ChevronRight, { size: 15, "aria-hidden": true }) }), narrow ? null : (_jsx("button", { type: "button", className: iconBtn, title: "Close (Esc)", "aria-label": "Close entry", onClick: onClose, children: _jsx(X, { size: 15, "aria-hidden": true }) }))] }), _jsx("div", { className: "border-bdr bg-card border-b", children: _jsxs("div", { className: "mx-auto max-w-[860px] px-8 pt-7 pb-[30px] max-[900px]:px-4 max-[900px]:pt-5 max-[900px]:pb-6 @[1240px]:max-w-[1180px]", children: [_jsxs("div", { className: `flex items-start gap-4 max-[640px]:flex-wrap ${msgEntry ? 'mb-6' : ''}`, children: [_jsx("span", { className: "flex size-[52px] shrink-0 items-center justify-center rounded-full text-[18px] font-bold", style: { background: avatarColor(name), color: 'var(--on-acc)' }, children: initials(name) }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("h2", { className: "text-txt m-0 text-[22px] leading-[1.2] font-bold tracking-[-0.4px] break-words", children: name }), _jsxs("div", { className: "text-faint mt-1.5 flex flex-wrap items-center gap-x-2 gap-y-1.5 text-[12.5px]", children: [_jsx("span", { className: "rounded-[5px] px-[7px] py-0.5 text-[10px] font-semibold whitespace-nowrap", style: { background: formColor.bg, color: formColor.fg }, children: formLabel }), entry.unread ? (_jsx("span", { className: "bg-acc-l text-acc rounded-[5px] px-2 py-[3px] text-[11px] font-semibold", children: "Unread" })) : null, entry.starred ? (_jsxs("span", { className: "bg-warn-l text-warn inline-flex items-center gap-1 rounded-[5px] px-2 py-[3px] text-[11px] font-semibold", children: [_jsx(Star, { size: 11, "aria-hidden": true, className: "fill-current" }), " Starred"] })) : null, entry.archived ? (_jsx("span", { className: "border-bdr bg-bg text-faint rounded-[5px] border px-2 py-[3px] text-[11px] font-semibold", children: "Archived" })) : null, _jsx("span", { children: fullEntryTime(entry.submittedAt) }), otherCount > 0 && email ? (_jsxs("button", { type: "button", onClick: () => onFindEmail(email), className: "text-acc decoration-acc-m hover:decoration-acc cursor-pointer border-0 bg-transparent p-0 text-[12.5px] font-semibold whitespace-nowrap underline underline-offset-2", children: [otherCount, " other ", otherCount === 1 ? 'entry' : 'entries', " from this person"] })) : null] }), _jsxs("div", { className: "text-sub mt-2 flex min-w-0 items-center gap-2 text-[12.5px]", children: [_jsx("span", { className: "inline-flex shrink-0 items-center rounded-[5px] px-2 py-[3px] text-[11px] font-semibold", style: { color: attr.channelFg, background: attr.channelBg }, children: attr.channelLabel }), _jsxs("span", { className: "min-w-0 truncate", children: [_jsx("b", { className: "text-txt font-semibold", children: attr.source }), " / ", attr.medium, attr.campaign ? ` · ${attr.campaign}` : ''] })] }), email || phone || website ? (_jsxs("div", { className: "mt-3 flex flex-wrap gap-1.5", children: [email ? (_jsxs("a", { href: mailHref, title: "Email with their message quoted", className: "border-bdr bg-card text-txt hover:border-acc-m hover:bg-acc-l hover:text-acc inline-flex max-w-full items-center gap-1.5 truncate rounded-full border px-[11px] py-[5px] text-[12.5px] no-underline", children: [_jsx(Mail, { size: 13, "aria-hidden": true, className: "text-faint shrink-0" }), email] })) : null, phone ? (_jsxs("a", { href: `tel:${phone.replace(/[^\d+]/g, '')}`, className: "border-bdr bg-card text-txt hover:border-acc-m hover:bg-acc-l hover:text-acc inline-flex max-w-full items-center gap-1.5 truncate rounded-full border px-[11px] py-[5px] text-[12.5px] no-underline", children: [_jsx(Phone, { size: 13, "aria-hidden": true, className: "text-faint shrink-0" }), phone] })) : null, website ? (_jsxs("a", { href: website, target: "_blank", rel: "noopener noreferrer", className: "border-bdr bg-card text-txt hover:border-acc-m hover:bg-acc-l hover:text-acc inline-flex max-w-full items-center gap-1.5 truncate rounded-full border px-[11px] py-[5px] text-[12.5px] no-underline", children: [_jsx(Globe, { size: 13, "aria-hidden": true, className: "text-faint shrink-0" }), website.replace(/^https?:\/\//, '').replace(/\/$/, '')] })) : null] })) : null] }), entry.spamStatus !== 'spam' && !entry.partial && !entry.deleted ? (_jsxs("div", { className: "flex shrink-0 flex-col items-end gap-2 max-[640px]:w-full max-[640px]:flex-row max-[640px]:justify-start max-[640px]:pl-[68px]", children: [_jsxs("label", { className: "focus-within:outline-acc inline-flex cursor-pointer items-center gap-[7px] rounded-full border px-2.5 py-1 text-[12.5px] font-semibold focus-within:outline focus-within:outline-offset-2", style: {
1180
+ color: pipe.fg,
1181
+ background: pipe.bg,
1182
+ borderColor: `color-mix(in srgb, ${pipe.fg} 30%, transparent)`,
1183
+ }, children: [_jsx("i", { className: "size-[7px] rounded-full", style: { background: pipe.fg } }), _jsx("select", { "aria-label": "Status", value: pipe.id, onChange: (event) => {
1184
+ const next = pipeOf(event.target.value);
1185
+ onPatch(entry.id, { status: next.id }, `Status: ${next.label}`);
1186
+ }, className: "cursor-pointer appearance-none border-0 bg-transparent pr-0.5 font-[inherit] text-inherit focus:outline-none", children: PIPE_STATUSES.map((item) => (_jsx("option", { value: item.id, children: item.label }, item.id))) }), _jsx(ChevronDown, { size: 13, "aria-hidden": true })] }), _jsxs("label", { className: "border-bdr bg-card text-sub focus-within:outline-acc inline-flex cursor-pointer items-center gap-[7px] rounded-full border py-[3px] pr-2.5 pl-[3px] focus-within:outline focus-within:outline-offset-2", children: [assignee ? (_jsx("span", { className: "inline-flex size-[22px] shrink-0 items-center justify-center rounded-full text-[9.5px] font-bold tracking-[-0.2px]", style: { background: avatarColor(assignee.name), color: 'var(--on-acc)' }, title: assignee.name, children: initials(assignee.name) })) : (_jsx("span", { className: "border-bdr bg-bg text-faint inline-flex size-[22px] shrink-0 items-center justify-center rounded-full border border-dashed text-[10px] font-bold", title: "Unassigned", children: "?" })), _jsxs("select", { "aria-label": "Assigned to", value: entry.assigneeId ?? '', onChange: (event) => {
1187
+ const nextId = event.target.value || null;
1188
+ const target = nextId ? team.find((t) => t.id === nextId) : undefined;
1189
+ onPatch(entry.id, { assigneeId: nextId, assigneeName: target?.name ?? null }, target ? `Assigned to ${target.name}` : 'Unassigned');
1190
+ }, className: "text-txt cursor-pointer appearance-none border-0 bg-transparent pr-0.5 font-[inherit] text-[12.5px] font-semibold focus:outline-none", children: [_jsx("option", { value: "", children: "Unassigned" }), team.map((member) => (_jsxs("option", { value: member.id, children: [member.name, member.id === currentUserId ? ' (you)' : ''] }, member.id)))] }), _jsx(ChevronDown, { size: 13, "aria-hidden": true })] })] })) : null] }), entry.deleted
1191
+ ? (() => {
1192
+ const d = daysLeftInTrash(entry.deleted.at);
1193
+ const deletedBy = entry.deleted.by === currentUserId || entry.deleted.by === 'self'
1194
+ ? 'you'
1195
+ : team.find((t) => t.id === entry.deleted?.by)?.name ||
1196
+ entry.deleted.byName ||
1197
+ 'a team member';
1198
+ return (_jsxs("div", { role: "note", className: "border-bdr bg-bg text-sub mb-3 flex items-start gap-2.5 rounded-[10px] border px-3.5 py-[11px] text-[13px]", children: [_jsx(Trash2, { size: 16, "aria-hidden": true, className: "mt-px shrink-0" }), _jsxs("div", { children: [_jsxs("b", { className: "text-txt mb-0.5 block text-[13px]", children: ["In Trash \u00B7 deleted by ", deletedBy, " on ", fullEntryTime(entry.deleted.at)] }), _jsxs("span", { children: [d === 0
1199
+ ? 'Removed for good today.'
1200
+ : `Removed for good in ${d} ${d === 1 ? 'day' : 'days'}.`, ' ', "Restore puts it back in ", entry.archived ? 'Archived' : 'the inbox', " with its status, notes and assignee."] })] })] }));
1201
+ })()
1202
+ : null, entry.partial ? (_jsxs("div", { role: "note", className: "bg-warn-l text-warn mb-3 flex items-start gap-2.5 rounded-[10px] border px-3.5 py-[11px] text-[12.5px] leading-[1.5]", style: { borderColor: 'color-mix(in srgb, var(--warn) 28%, transparent)' }, children: [_jsx(Clock, { size: 16, "aria-hidden": true, className: "mt-px shrink-0" }), _jsxs("div", { children: [_jsx("b", { className: "block text-[13px]", children: `Didn’t finish · stopped at step ${entry.partial.step} of ${entry.partial.of}: ${entry.partial.stepName}` }), _jsx("span", { className: "text-txt block", children: `Last active ${fullEntryTime(entry.partial.lastAt)}. Saved automatically because this form keeps partial entries. No notification was sent.` }), _jsx("div", { className: "mt-2 flex max-w-[220px] gap-1", "aria-hidden": "true", children: Array.from({ length: entry.partial.of }).map((_, idx) => (_jsx("i", { className: "h-[5px] flex-1 rounded-full", style: {
1203
+ background: idx < (entry.partial?.step ?? 1) - 1
1204
+ ? 'var(--warn)'
1205
+ : idx === (entry.partial?.step ?? 1) - 1
1206
+ ? 'repeating-linear-gradient(90deg, var(--warn) 0 4px, transparent 4px 7px)'
1207
+ : 'color-mix(in srgb, var(--warn) 20%, var(--card))',
1208
+ } }, idx))) })] })] })) : null, entry.spamStatus === 'spam' ? (_jsxs("div", { role: "note", className: "bg-err-l text-err mb-3 flex items-start gap-2.5 rounded-[10px] border px-3.5 py-[11px] text-[12.5px] leading-[1.5]", style: { borderColor: 'color-mix(in srgb, var(--err) 25%, transparent)' }, children: [_jsx(ShieldX, { size: 16, "aria-hidden": true, className: "mt-px shrink-0" }), _jsxs("div", { children: [_jsxs("b", { className: "flex flex-wrap items-center gap-2 text-[13px]", children: ["Marked as spam \u00B7", ' ', entry.spamMeta?.by && entry.spamMeta.by !== 'manual'
1209
+ ? (SPAM_BY_LABELS[entry.spamMeta.by] ?? 'You')
1210
+ : 'You', entry.spamMeta?.score ? (_jsxs("span", { className: "bg-card text-err rounded-full border px-[7px] text-[11px] font-semibold whitespace-nowrap", style: { borderColor: 'color-mix(in srgb, var(--err) 25%, transparent)' }, children: [entry.spamMeta.score, "% confidence"] })) : null] }), _jsx("span", { className: "text-txt block", children: `${entry.spamMeta?.reason ?? 'Marked as spam by you.'} No notification email was sent.` })] })] })) : null, msgEntry ? (_jsxs("section", { className: "group", "aria-labelledby": "d-msg-l", children: [_jsxs("div", { className: "text-faint mb-2 flex items-center gap-2 text-[12px] font-semibold", children: [_jsx("span", { id: "d-msg-l", children: msgEntry.label }), _jsx("button", { type: "button", title: `Copy ${msgEntry.label}`, "aria-label": `Copy ${msgEntry.label}`, onClick: () => copyValue(msgText), className: "text-faint hover:bg-acc-l hover:text-acc ml-auto inline-flex size-6 items-center justify-center rounded-[6px] opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100 focus-visible:opacity-100", children: _jsx(Copy, { size: 13, "aria-hidden": true }) })] }), _jsx("div", { dir: "auto", className: "text-txt max-w-[68ch] text-[15.5px] leading-[1.7] break-words whitespace-pre-wrap @[1240px]:max-w-[75ch]", children: formatFieldDisplay(msgEntry.key, msgText, fieldMap.get(msgEntry.key)) })] })) : null] }) }), _jsxs("div", { className: "mx-auto max-w-[860px] px-8 pt-[22px] pb-12 max-[900px]:px-4 max-[900px]:pt-4 max-[900px]:pb-10 @[1240px]:grid @[1240px]:max-w-[1180px] @[1240px]:grid-cols-[minmax(0,1fr)_400px] @[1240px]:items-start @[1240px]:gap-x-5", children: [_jsxs("article", { className: "border-bdr bg-card shadow-shd mb-3.5 overflow-hidden rounded-[10px] border @[1240px]:col-start-1", children: [_jsxs("h3", { className: "border-bdr text-faint m-0 flex items-center gap-2 border-b px-5 py-3 text-[11px] font-bold tracking-[0.6px] uppercase", children: ["Submission", _jsxs("span", { className: "ml-auto text-[11.5px] font-semibold tracking-normal normal-case", children: [answeredCount, " of ", present.length, " answered"] })] }), _jsxs("dl", { className: "divide-bdr m-0 divide-y", children: [filledRows.map(({ key, label }) => {
1211
+ const raw = displayValue(entry.data[key]);
1212
+ const formatted = formatFieldDisplay(key, raw, fieldMap.get(key));
1213
+ return (_jsx(DetailRow, { label: label, copyText: formatted, onCopy: copyValue, children: formatted }, key));
1214
+ }), showEmpty
1215
+ ? emptyRows.map(({ key, label }) => (_jsxs("div", { className: "grid grid-cols-[minmax(110px,32%)_minmax(0,1fr)] items-baseline gap-x-4 gap-y-1 px-5 py-[11px] max-[520px]:grid-cols-1", children: [_jsx("dt", { className: "text-sub text-[12.5px] leading-[1.5] font-medium", children: label }), _jsx("dd", { className: "text-faint m-0 text-[14px] leading-[1.55]", children: "Not answered" })] }, key)))
1216
+ : null] }), emptyRows.length > 0 ? (_jsx("button", { type: "button", "aria-expanded": showEmpty, onClick: () => setShowEmpty((v) => !v), className: "border-bdr text-acc hover:bg-acc-l block w-full cursor-pointer border-0 border-t bg-transparent px-5 py-2.5 text-left text-[12.5px] font-medium", children: showEmpty
1217
+ ? 'Hide empty fields'
1218
+ : `Show ${emptyRows.length} empty ${emptyRows.length === 1 ? 'field' : 'fields'}` })) : null] }), entry.spamStatus !== 'spam' && !entry.partial ? (_jsxs("article", { className: "border-bdr bg-card shadow-shd mb-3.5 overflow-hidden rounded-[10px] border @[1240px]:col-start-1", children: [_jsxs("h3", { className: "border-bdr text-faint m-0 flex items-center gap-2 border-b px-5 py-3 text-[11px] font-bold tracking-[0.6px] uppercase", children: ["Team notes", _jsxs("span", { className: "ml-auto text-[11.5px] font-semibold tracking-normal normal-case", children: [notes.length, " ", notes.length === 1 ? 'note' : 'notes'] })] }), _jsxs("div", { className: "flex flex-col gap-3.5 px-5 pt-3.5 pb-4", children: [notes.map((n, idx) => {
1219
+ const author = team.find((t) => t.id === n.authorId)?.name ||
1220
+ n.authorName ||
1221
+ n.authorId ||
1222
+ 'Team';
1223
+ return (_jsxs("div", { className: "flex gap-2.5", children: [_jsx("span", { className: "flex size-[26px] shrink-0 items-center justify-center rounded-full text-[11px] font-bold", style: { background: avatarColor(author), color: 'var(--on-acc)' }, children: initials(author) }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsxs("div", { className: "flex items-baseline gap-2 text-[12.5px]", children: [_jsx("b", { className: "text-txt font-semibold", children: author }), _jsx("span", { className: "text-faint text-[11.5px]", children: fullEntryTime(n.at) })] }), _jsx("div", { className: "text-txt mt-0.5 text-[13px] leading-[1.5] whitespace-pre-wrap", children: n.text })] })] }, idx));
1224
+ }), notes.length === 0 ? (_jsx("div", { className: "text-faint text-[12.5px]", children: "No notes yet. Notes are only visible to your team." })) : null, _jsxs("div", { className: "border-bdr flex gap-2.5 border-t pt-3", children: [_jsx("span", { className: "flex size-[26px] shrink-0 items-center justify-center rounded-full text-[11px] font-bold", style: { background: avatarColor(currentUserName), color: 'var(--on-acc)' }, children: initials(currentUserName) }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("textarea", { rows: 2, value: noteText, placeholder: "Add a note for your team\u2026", "aria-label": "Add a note", onChange: (e) => setNoteText(e.target.value), onKeyDown: (e) => {
1225
+ if (e.key === 'Enter' && (e.metaKey || e.ctrlKey) && noteText.trim()) {
1226
+ e.preventDefault();
1227
+ addNote();
1228
+ }
1229
+ }, className: "border-bdr bg-card text-txt focus-visible:outline-acc min-h-[58px] w-full resize-y rounded-[9px] border px-2.5 py-2 text-[13px] leading-[1.45] focus-visible:outline focus-visible:outline-offset-2" }), _jsxs("div", { className: "text-faint mt-1.5 flex items-center gap-2.5 text-[11.5px]", children: [_jsx("span", { className: "flex-1", children: "\u2318 Enter to save \u00B7 only visible to your team" }), _jsx("button", { type: "button", disabled: !noteText.trim(), onClick: addNote, className: "bg-acc inline-flex items-center gap-1.5 rounded-[8px] px-[15px] py-2 text-[13px] font-medium text-[var(--on-acc)] disabled:cursor-not-allowed disabled:opacity-45", children: "Add note" })] })] })] })] })] })) : null, _jsxs("article", { className: "border-bdr bg-card shadow-shd mb-3.5 overflow-hidden rounded-[10px] border @[1240px]:sticky @[1240px]:top-[68px] @[1240px]:col-start-2 @[1240px]:row-span-2 @[1240px]:row-start-1", children: [_jsx("h3", { className: "m-0", children: _jsxs("button", { type: "button", "aria-expanded": metaOpen, "aria-controls": "d-attr", onClick: () => setMetaOpen((open) => !open), className: `border-bdr text-faint hover:text-acc flex w-full cursor-pointer items-center gap-2 bg-transparent px-5 py-3 text-left text-[11px] font-bold tracking-[0.6px] uppercase ${metaOpen ? 'border-b' : ''}`, children: ["Attribution & technical", _jsxs("span", { className: "ml-auto inline-flex items-center gap-1.5 text-[11.5px] font-semibold tracking-normal normal-case", children: [attr.spamScore >= 80 ? (_jsxs("span", { className: "bg-err-l text-err rounded-[5px] px-[7px] py-0.5 text-[10px] font-semibold", children: ["Spam ", attr.spamScore] })) : (_jsxs("span", { className: "text-faint", children: ["Spam score ", attr.spamScore] })), _jsx(ChevronDown, { size: 14, "aria-hidden": true, className: `transition-transform ${metaOpen ? 'rotate-180' : ''}` })] })] }) }), metaOpen ? (_jsxs("dl", { id: "d-attr", className: "divide-bdr m-0 divide-y", children: [_jsx(DetailRow, { label: "Channel", compact: true, children: _jsx("span", { className: "inline-flex items-center rounded-[5px] border px-2 py-[3px] text-[11px] font-semibold", style: {
1230
+ color: attr.channelFg,
1231
+ background: attr.channelBg,
1232
+ borderColor: `color-mix(in srgb, ${attr.channelFg} 22%, transparent)`,
1233
+ }, children: attr.channelLabel }) }), _jsx(DetailRow, { label: "Source / Medium", compact: true, copyText: `${attr.source} / ${attr.medium}`, onCopy: copyValue, children: _jsxs("b", { className: "text-txt font-semibold", children: [attr.source, " ", _jsx("span", { className: "text-faint font-normal", children: "/" }), " ", attr.medium] }) }), attr.campaign ? (_jsx(DetailRow, { label: "Campaign", compact: true, copyText: attr.campaign, onCopy: copyValue, children: attr.campaign })) : null, attr.term ? (_jsx(DetailRow, { label: "Keyword", compact: true, copyText: attr.term, onCopy: copyValue, children: attr.term })) : null, _jsx(ClickIdRow, { ids: attr.clickIds, onCopy: copyValue }), _jsx(DetailRow, { label: "Landing page", compact: true, copyText: attr.landingPage !== '—' ? attr.landingPage : undefined, onCopy: copyValue, children: attr.landingPage !== '—' ? (_jsx("a", { href: attr.landingPage, target: "_blank", rel: "noopener noreferrer", className: "text-acc hover:underline", children: attr.landingPage })) : ('—') }), _jsx(DetailRow, { label: "Referrer", compact: true, copyText: attr.referrer, onCopy: copyValue, children: attr.referrer }), _jsx(DetailRow, { label: "Device", compact: true, copyText: attr.device, onCopy: copyValue, clamp: true, children: attr.device }), _jsx(DetailRow, { label: "IP address", compact: true, mono: true, copyText: attr.ip !== '—' ? attr.ip : undefined, onCopy: copyValue, children: attr.ip }), _jsx(DetailRow, { label: "Submitted", compact: true, copyText: fullEntryTime(entry.submittedAt), onCopy: copyValue, children: fullEntryTime(entry.submittedAt) }), _jsx(DetailRow, { label: "Form", compact: true, copyText: formLabel, onCopy: copyValue, children: formLabel }), _jsx(DetailRow, { label: "Entry ID", compact: true, mono: true, copyText: entryIdLabel(entry), onCopy: copyValue, children: entryIdLabel(entry) })] })) : null] })] })] }));
1234
+ }
1235
+ function DetailRow({ label, children, copyText, onCopy, compact, mono, clamp, }) {
1236
+ return (_jsxs("div", { className: `group grid items-baseline gap-x-4 gap-y-1 px-5 hover:bg-[color-mix(in_srgb,var(--bg)_60%,transparent)] max-[520px]:grid-cols-1 ${compact
1237
+ ? 'grid-cols-[minmax(110px,32%)_minmax(0,1fr)] py-[9px] @[1240px]:grid-cols-[118px_minmax(0,1fr)]'
1238
+ : 'grid-cols-[minmax(110px,32%)_minmax(0,1fr)] py-[11px]'}`, children: [_jsx("dt", { className: "text-sub text-[12.5px] leading-[1.5] font-medium", children: label }), _jsxs("dd", { className: `m-0 flex min-w-0 items-start gap-2 leading-[1.55] ${compact ? 'text-sub text-[13px]' : 'text-txt text-[14px]'}`, children: [_jsx("span", { dir: "auto", className: `min-w-0 flex-1 break-words ${clamp ? 'line-clamp-2 whitespace-normal' : 'whitespace-pre-wrap'} ${mono ? 'font-mono text-[12px]' : ''}`, children: children }), copyText && onCopy ? (_jsx("button", { type: "button", title: `Copy ${label}`, "aria-label": `Copy ${label}`, onClick: () => onCopy(copyText), className: "text-faint hover:bg-acc-l hover:text-acc -my-0.5 inline-flex size-6 shrink-0 items-center justify-center rounded-[6px] opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100 focus-visible:opacity-100", children: _jsx(Copy, { size: 13, "aria-hidden": true }) })) : null] })] }));
509
1239
  }
510
- function Ghost({ children, onClick }) {
511
- return (_jsx("button", { type: "button", onClick: onClick, className: "text-sub hover:bg-acc-l hover:text-acc inline-flex items-center gap-[5px] rounded-[7px] px-[9px] py-1.5 text-[12.5px]", children: children }));
1240
+ function ClickIdRow({ ids, onCopy, }) {
1241
+ const label = ids.length > 1 ? 'Click IDs' : 'Click ID';
1242
+ if (ids.length === 0) {
1243
+ return (_jsx(DetailRow, { label: label, compact: true, children: _jsx("span", { className: "text-faint", children: "None \u00B7 not an ad click" }) }));
1244
+ }
1245
+ return (_jsxs("div", { className: "grid grid-cols-[minmax(110px,32%)_minmax(0,1fr)] items-baseline gap-x-4 gap-y-1 px-5 py-[9px] max-[520px]:grid-cols-1 @[1240px]:grid-cols-[118px_minmax(0,1fr)]", children: [_jsx("dt", { className: "text-sub text-[12.5px] leading-[1.5] font-medium", children: label }), _jsx("dd", { className: "text-sub m-0 min-w-0 text-[13px]", children: _jsx("div", { className: "flex min-w-0 flex-col gap-1.5", children: ids.map((id) => (_jsxs("div", { className: "grid min-w-0 grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2.5 max-[520px]:grid-cols-[minmax(0,1fr)_auto]", children: [_jsxs("span", { className: "inline-flex items-center gap-1.5 text-[12px] whitespace-nowrap max-[520px]:col-span-full", children: [_jsx("b", { className: "text-txt font-semibold", children: id.platform }), _jsx("code", { className: "border-bdr bg-bg text-sub rounded-[4px] border px-[5px] font-mono text-[10.5px]", children: id.key })] }), _jsx("span", { className: "text-sub min-w-0 truncate font-mono text-[11.5px]", title: id.value, children: id.value }), _jsx("button", { type: "button", title: `Copy ${id.key}`, "aria-label": `Copy ${id.key}`, onClick: () => onCopy(id.value), className: "text-faint hover:bg-acc-l hover:text-acc inline-flex size-6 items-center justify-center rounded-[5px]", children: _jsx(Copy, { size: 12, "aria-hidden": true }) })] }, id.key))) }) })] }));
512
1246
  }
513
- function Meta({ label, value, mono }) {
514
- return (_jsxs("div", { className: "flex min-w-0 items-baseline gap-2.5 text-[12.5px]", children: [_jsx("dt", { className: "text-faint w-24 shrink-0", children: label }), _jsx("dd", { className: `text-sub min-w-0 break-all ${mono ? 'font-mono text-[11.5px]' : ''}`, children: value })] }));
1247
+ function EmptyTrashDialog({ count, onClose, onConfirm, }) {
1248
+ const [value, setValue] = useState('');
1249
+ const inputRef = useRef(null);
1250
+ return (_jsxs(Modal, { open: true, onClose: onClose, title: "Empty trash?", initialFocusRef: inputRef, actions: _jsxs(_Fragment, { children: [_jsx("button", { type: "button", onClick: onClose, className: "border-bdr bg-card text-txt hover:border-acc-m hover:bg-acc-l hover:text-acc inline-flex items-center gap-1.5 rounded-[8px] border px-3 py-[7px] text-[13px]", children: "Cancel" }), _jsxs("button", { type: "button", disabled: value !== 'DELETE', onClick: onConfirm, className: "bg-err text-destructive-foreground inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-[8px] border-0 px-3.5 text-[13px] font-medium disabled:cursor-not-allowed disabled:opacity-45", children: [_jsx(Trash2, { size: 14, "aria-hidden": true }), "Delete forever"] })] }), children: [_jsxs("p", { className: "text-sub m-0 mb-4 text-[13.5px] leading-[1.55]", children: [count, " ", count === 1 ? 'entry' : 'entries', " will be deleted forever, including notes and attribution. This can\u2019t be undone."] }), _jsxs("label", { htmlFor: "et-i", className: "text-sub mb-1.5 block text-[12.5px] font-medium", children: ["Type ", _jsx("b", { className: "text-txt font-mono", children: "DELETE" }), " to confirm"] }), _jsx("input", { id: "et-i", ref: inputRef, value: value, onChange: (event) => setValue(event.target.value), autoComplete: "off", onKeyDown: (event) => {
1251
+ if (event.key === 'Enter' && value === 'DELETE')
1252
+ onConfirm();
1253
+ }, className: "border-bdr bg-card text-txt focus:border-acc focus:outline-acc box-border h-9 w-full rounded-[8px] border px-2.5 font-[inherit] text-[14px] focus:outline focus:outline-offset-1" })] }));
515
1254
  }
516
1255
  //# sourceMappingURL=EntriesInbox.js.map