@matija2209/payload-plugin-admin-feedback 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,895 +1,8 @@
1
1
  'use client';
2
- import { ArrowLeft, PencilLine, Trash2, ImageIcon, Camera, Upload, X, Save, ExternalLink, MapPin, CalendarClock, RefreshCw, MessageSquareText, Clock3, ChevronLeft, ChevronRight, MessageSquarePlus, Sparkles, MessageSquare, History, MousePointerClick, CheckCircle2, SendHorizontal, PenTool, Square, ArrowRight, Type, Undo2, Redo2, Eraser, RotateCcw } from 'lucide-react';
3
- import React2 from 'react';
4
- import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
+ import React from 'react';
3
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
5
4
  import { usePathname } from 'next/navigation';
6
5
 
7
- // src/client/FeedbackWidget.tsx
8
-
9
- // src/client/ui.ts
10
- var theme = {
11
- accent: "#5eead4",
12
- text: "#f8fafc",
13
- textSoft: "rgba(226, 232, 240, 0.78)",
14
- textMuted: "rgba(148, 163, 184, 0.78)",
15
- dangerSoft: "rgba(248, 113, 113, 0.18)",
16
- border: "rgba(148, 163, 184, 0.18)",
17
- borderStrong: "rgba(148, 163, 184, 0.28)",
18
- panel: "linear-gradient(180deg, rgba(15, 23, 42, 0.96) 0%, rgba(6, 13, 24, 0.96) 100%)",
19
- card: "linear-gradient(180deg, rgba(30, 41, 59, 0.54) 0%, rgba(15, 23, 42, 0.7) 100%)",
20
- inset: "rgba(15, 23, 42, 0.82)",
21
- shadow: "0 28px 70px rgba(2, 8, 23, 0.48)",
22
- subtleShadow: "0 18px 40px rgba(2, 8, 23, 0.24)"
23
- };
24
- var floatingLauncherStyle = {
25
- position: "fixed",
26
- right: "20px",
27
- bottom: "20px",
28
- zIndex: 9999,
29
- display: "inline-flex",
30
- alignItems: "center",
31
- gap: "8px",
32
- borderRadius: "999px",
33
- border: `1px solid ${theme.borderStrong}`,
34
- background: "linear-gradient(135deg, rgba(45, 212, 191, 0.96) 0%, rgba(15, 118, 110, 0.96) 100%)",
35
- color: "#03131f",
36
- padding: "10px 14px",
37
- fontWeight: 700,
38
- fontSize: "13px",
39
- letterSpacing: "-0.01em",
40
- cursor: "pointer",
41
- boxShadow: "0 24px 55px rgba(15, 118, 110, 0.34)"
42
- };
43
- var panelStyle = {
44
- position: "fixed",
45
- right: "12px",
46
- bottom: "calc(12px + env(safe-area-inset-bottom, 0px))",
47
- width: "min(396px, calc(100vw - 24px))",
48
- maxHeight: "min(780px, calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)))",
49
- height: "min(780px, calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)))",
50
- overflow: "hidden",
51
- display: "flex",
52
- flexDirection: "column",
53
- overscrollBehavior: "contain",
54
- background: theme.panel,
55
- color: theme.text,
56
- borderRadius: "22px",
57
- border: `1px solid ${theme.border}`,
58
- zIndex: 9999,
59
- boxShadow: theme.shadow,
60
- backdropFilter: "blur(18px)"
61
- };
62
- var panelHeaderStyle = {
63
- padding: "14px 14px 12px",
64
- borderBottom: `1px solid ${theme.border}`,
65
- background: "radial-gradient(circle at top right, rgba(45, 212, 191, 0.14), transparent 38%), transparent"
66
- };
67
- var surfaceCardStyle = {
68
- background: theme.card,
69
- border: `1px solid ${theme.border}`,
70
- borderRadius: "16px",
71
- boxShadow: theme.subtleShadow
72
- };
73
- var innerCardStyle = {
74
- background: theme.inset,
75
- border: `1px solid ${theme.border}`,
76
- borderRadius: "14px"
77
- };
78
- var fieldStyle = {
79
- width: "100%",
80
- borderRadius: "14px",
81
- border: `1px solid ${theme.border}`,
82
- background: "rgba(15, 23, 42, 0.86)",
83
- color: theme.text,
84
- padding: "12px 14px",
85
- fontSize: "13px",
86
- lineHeight: 1.5,
87
- outline: "none",
88
- boxSizing: "border-box",
89
- boxShadow: "inset 0 1px 0 rgba(255,255,255,0.03)"
90
- };
91
- var metaTextStyle = {
92
- margin: 0,
93
- fontSize: "12px",
94
- lineHeight: 1.5,
95
- color: theme.textMuted
96
- };
97
- var sectionLabelStyle = {
98
- margin: 0,
99
- fontSize: "11px",
100
- fontWeight: 700,
101
- letterSpacing: "0.08em",
102
- textTransform: "uppercase",
103
- color: theme.textMuted
104
- };
105
- var statusTextStyle = {
106
- margin: 0,
107
- fontSize: "12px",
108
- lineHeight: 1.5,
109
- color: theme.textSoft
110
- };
111
- function buttonStyle(variant, options = {}) {
112
- const { active = false, disabled = false, iconOnly = false, compact = false, justify = "center" } = options;
113
- const base = {
114
- display: "inline-flex",
115
- alignItems: "center",
116
- justifyContent: justify,
117
- gap: "8px",
118
- minHeight: compact ? "32px" : "38px",
119
- padding: iconOnly ? compact ? "7px" : "9px" : compact ? "7px 11px" : "9px 13px",
120
- borderRadius: iconOnly ? "12px" : "14px",
121
- border: `1px solid ${theme.border}`,
122
- color: theme.text,
123
- cursor: disabled ? "not-allowed" : "pointer",
124
- fontSize: compact ? "12px" : "13px",
125
- fontWeight: 600,
126
- letterSpacing: "-0.01em",
127
- transition: "transform 0.18s ease, opacity 0.18s ease, border-color 0.18s ease",
128
- opacity: disabled ? 0.45 : 1,
129
- boxSizing: "border-box"
130
- };
131
- const variants = {
132
- primary: {
133
- background: "linear-gradient(135deg, rgba(94, 234, 212, 0.98) 0%, rgba(20, 184, 166, 0.98) 100%)",
134
- borderColor: "rgba(153, 246, 228, 0.38)",
135
- color: "#04111c",
136
- boxShadow: "0 18px 35px rgba(20, 184, 166, 0.22)"
137
- },
138
- secondary: {
139
- background: active ? "rgba(94, 234, 212, 0.14)" : theme.card,
140
- borderColor: active ? "rgba(94, 234, 212, 0.34)" : theme.border,
141
- color: active ? "#d1fae5" : theme.text
142
- },
143
- ghost: {
144
- background: active ? "rgba(94, 234, 212, 0.12)" : "transparent",
145
- borderColor: active ? "rgba(94, 234, 212, 0.28)" : "transparent",
146
- color: active ? theme.text : theme.textSoft
147
- },
148
- danger: {
149
- background: active ? "rgba(248, 113, 113, 0.18)" : theme.dangerSoft,
150
- borderColor: "rgba(248, 113, 113, 0.28)",
151
- color: "#fecaca"
152
- }
153
- };
154
- return { ...base, ...variants[variant] };
155
- }
156
- function pillStyle(variant) {
157
- const variants = {
158
- neutral: {
159
- background: "rgba(148, 163, 184, 0.16)",
160
- color: theme.textSoft,
161
- border: `1px solid ${theme.border}`
162
- },
163
- success: {
164
- background: "rgba(34, 197, 94, 0.16)",
165
- color: "#86efac",
166
- border: "1px solid rgba(34, 197, 94, 0.24)"
167
- },
168
- warning: {
169
- background: "rgba(234, 179, 8, 0.18)",
170
- color: "#fde68a",
171
- border: "1px solid rgba(234, 179, 8, 0.24)"
172
- },
173
- muted: {
174
- background: "rgba(148, 163, 184, 0.16)",
175
- color: "#cbd5e1",
176
- border: `1px solid ${theme.border}`
177
- },
178
- danger: {
179
- background: theme.dangerSoft,
180
- color: "#fecaca",
181
- border: "1px solid rgba(248, 113, 113, 0.24)"
182
- }
183
- };
184
- return {
185
- display: "inline-flex",
186
- alignItems: "center",
187
- gap: "6px",
188
- borderRadius: "999px",
189
- padding: "5px 10px",
190
- fontSize: "11px",
191
- fontWeight: 700,
192
- letterSpacing: "0.01em",
193
- ...variants[variant]
194
- };
195
- }
196
- var formatDate = (iso) => {
197
- try {
198
- return new Date(iso).toLocaleString("en-US", {
199
- month: "short",
200
- day: "numeric",
201
- year: "numeric",
202
- hour: "2-digit",
203
- minute: "2-digit"
204
- });
205
- } catch {
206
- return iso;
207
- }
208
- };
209
- var getScreenshotInfo = (feedback) => {
210
- if (!feedback.screenshot || typeof feedback.screenshot !== "object") return null;
211
- const screenshot = feedback.screenshot;
212
- if (screenshot.url) return { id: screenshot.id, url: screenshot.url };
213
- if (screenshot.filename) return { id: screenshot.id, url: screenshot.filename };
214
- return null;
215
- };
216
- var getCreatorId = (feedback) => {
217
- if (!feedback.createdBy) return null;
218
- if (typeof feedback.createdBy === "object") return feedback.createdBy.id;
219
- return feedback.createdBy;
220
- };
221
- var canvasToFile = async (canvas, fileName = `feedback-${Date.now()}.png`) => {
222
- const blob = await new Promise((resolve) => {
223
- canvas.toBlob((nextBlob) => resolve(nextBlob), "image/png");
224
- });
225
- if (!blob) throw new Error("Failed to prepare screenshot.");
226
- return new File([blob], fileName.replace(/\.[a-z0-9]+$/i, "") + ".png", { type: "image/png" });
227
- };
228
- var captureScreenshotFile = async () => {
229
- if (!navigator.mediaDevices?.getDisplayMedia) {
230
- throw new Error("Browser does not support screen capture.");
231
- }
232
- const stream = await navigator.mediaDevices.getDisplayMedia({
233
- video: { displaySurface: "browser" },
234
- audio: false,
235
- preferCurrentTab: true
236
- });
237
- const track = stream.getVideoTracks()[0];
238
- if (!track) {
239
- stream.getTracks().forEach((nextTrack) => nextTrack.stop());
240
- throw new Error("Screen capture failed.");
241
- }
242
- const video = document.createElement("video");
243
- try {
244
- video.srcObject = stream;
245
- video.muted = true;
246
- video.playsInline = true;
247
- await video.play();
248
- await new Promise((resolve) => {
249
- if ("requestVideoFrameCallback" in video) {
250
- video.requestVideoFrameCallback(() => resolve());
251
- } else {
252
- requestAnimationFrame(() => resolve());
253
- }
254
- });
255
- const width = video.videoWidth || window.innerWidth;
256
- const height = video.videoHeight || window.innerHeight;
257
- if (!width || !height) throw new Error("Screen capture failed.");
258
- const canvas = document.createElement("canvas");
259
- canvas.width = width;
260
- canvas.height = height;
261
- const context = canvas.getContext("2d");
262
- if (!context) throw new Error("Browser does not support canvas context.");
263
- context.drawImage(video, 0, 0, width, height);
264
- return canvasToFile(canvas);
265
- } finally {
266
- video.pause();
267
- video.srcObject = null;
268
- stream.getTracks().forEach((nextTrack) => nextTrack.stop());
269
- }
270
- };
271
- function FeedbackDetail({
272
- feedback,
273
- currentUserId,
274
- capturePolicy: _capturePolicy,
275
- onBack,
276
- onUpdate,
277
- onDelete,
278
- onUpload,
279
- onDeleteScreenshot
280
- }) {
281
- const [editing, setEditing] = React2.useState(false);
282
- const [message, setMessage] = React2.useState(feedback.message);
283
- const [screenshotId, setScreenshotId] = React2.useState(getScreenshotInfo(feedback)?.id ?? null);
284
- const [screenshotUrl, setScreenshotUrl] = React2.useState(getScreenshotInfo(feedback)?.url ?? null);
285
- const [uploading, setUploading] = React2.useState(false);
286
- const [removing, setRemoving] = React2.useState(false);
287
- const [saving, setSaving] = React2.useState(false);
288
- const [deleting, setDeleting] = React2.useState(false);
289
- const [error, setError] = React2.useState(null);
290
- const isOwner = getCreatorId(feedback) === currentUserId;
291
- const screenshot = getScreenshotInfo(feedback);
292
- const currentScreenshotId = screenshotId ?? screenshot?.id ?? null;
293
- const uploadFile = async (file) => {
294
- setUploading(true);
295
- setError(null);
296
- try {
297
- const formData = new FormData();
298
- formData.append("file", file);
299
- formData.append("alt", file.name);
300
- const result = await onUpload(formData);
301
- if (!result.success) {
302
- setError(result.error);
303
- return null;
304
- }
305
- setScreenshotId(result.mediaId);
306
- setScreenshotUrl(URL.createObjectURL(file));
307
- return result.mediaId;
308
- } catch (nextError) {
309
- setError(nextError instanceof Error ? nextError.message : "Upload failed.");
310
- return null;
311
- } finally {
312
- setUploading(false);
313
- }
314
- };
315
- const handleRemoveScreenshot = async () => {
316
- if (!currentScreenshotId) return;
317
- setRemoving(true);
318
- setError(null);
319
- try {
320
- const result = await onDeleteScreenshot(currentScreenshotId);
321
- if (!result.success) {
322
- setError(result.error);
323
- return;
324
- }
325
- setScreenshotId(null);
326
- setScreenshotUrl(null);
327
- } catch (nextError) {
328
- setError(nextError instanceof Error ? nextError.message : "Failed to remove screenshot.");
329
- } finally {
330
- setRemoving(false);
331
- }
332
- };
333
- const handleCapture = async () => {
334
- try {
335
- const file = await captureScreenshotFile();
336
- await uploadFile(file);
337
- } catch (nextError) {
338
- setError(nextError instanceof Error ? nextError.message : "Screen capture failed.");
339
- }
340
- };
341
- const handleFileUpload = async (event) => {
342
- const file = event.target.files?.[0];
343
- if (file) await uploadFile(file);
344
- event.target.value = "";
345
- };
346
- React2.useEffect(() => {
347
- if (!editing) return;
348
- const onPaste = async (event) => {
349
- const file = Array.from(event.clipboardData?.items || []).find((item) => item.type.startsWith("image/"))?.getAsFile();
350
- if (file) {
351
- event.preventDefault();
352
- await uploadFile(file);
353
- }
354
- };
355
- window.addEventListener("paste", onPaste);
356
- return () => window.removeEventListener("paste", onPaste);
357
- }, [editing]);
358
- const handleSave = async () => {
359
- if (!message.trim()) {
360
- setError("Message cannot be empty.");
361
- return;
362
- }
363
- setSaving(true);
364
- setError(null);
365
- try {
366
- const updateData = {};
367
- if (message.trim() !== feedback.message) {
368
- updateData.message = message.trim();
369
- }
370
- if ((screenshotId ?? null) !== (feedback.screenshot && typeof feedback.screenshot === "object" ? feedback.screenshot.id : feedback.screenshot)) {
371
- updateData.screenshotId = screenshotId ?? null;
372
- }
373
- const success = await onUpdate(feedback.id, updateData);
374
- if (success) {
375
- setEditing(false);
376
- } else {
377
- setError("Failed to save changes.");
378
- }
379
- } catch (nextError) {
380
- setError(nextError instanceof Error ? nextError.message : "Save failed.");
381
- } finally {
382
- setSaving(false);
383
- }
384
- };
385
- const handleDelete = async () => {
386
- if (!window.confirm("Delete this feedback? This cannot be undone.")) {
387
- return;
388
- }
389
- setDeleting(true);
390
- setError(null);
391
- try {
392
- const success = await onDelete(feedback.id);
393
- if (!success) {
394
- setError("Failed to delete feedback.");
395
- }
396
- } catch (nextError) {
397
- setError(nextError instanceof Error ? nextError.message : "Delete failed.");
398
- } finally {
399
- setDeleting(false);
400
- }
401
- };
402
- return /* @__PURE__ */ jsxs("div", { style: { display: "grid", gap: "12px" }, children: [
403
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: "10px" }, children: [
404
- /* @__PURE__ */ jsxs("button", { type: "button", onClick: onBack, style: buttonStyle("ghost", { compact: true }), children: [
405
- /* @__PURE__ */ jsx(ArrowLeft, { size: 15 }),
406
- "Back"
407
- ] }),
408
- isOwner && !editing ? /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "8px", flexWrap: "wrap", justifyContent: "flex-end" }, children: [
409
- /* @__PURE__ */ jsxs(
410
- "button",
411
- {
412
- type: "button",
413
- onClick: () => {
414
- setEditing(true);
415
- setError(null);
416
- },
417
- style: buttonStyle("secondary", { compact: true }),
418
- children: [
419
- /* @__PURE__ */ jsx(PencilLine, { size: 15 }),
420
- "Edit"
421
- ]
422
- }
423
- ),
424
- /* @__PURE__ */ jsxs(
425
- "button",
426
- {
427
- type: "button",
428
- onClick: handleDelete,
429
- disabled: deleting,
430
- style: buttonStyle("danger", { compact: true, disabled: deleting }),
431
- children: [
432
- /* @__PURE__ */ jsx(Trash2, { size: 15 }),
433
- deleting ? "Deleting..." : "Delete"
434
- ]
435
- }
436
- )
437
- ] }) : null
438
- ] }),
439
- editing ? /* @__PURE__ */ jsxs(Fragment, { children: [
440
- /* @__PURE__ */ jsxs("div", { style: { ...surfaceCardStyle, padding: "16px" }, children: [
441
- /* @__PURE__ */ jsx("p", { style: { ...sectionLabelStyle, marginBottom: "10px" }, children: "Message" }),
442
- /* @__PURE__ */ jsx(
443
- "textarea",
444
- {
445
- value: message,
446
- onChange: (event) => setMessage(event.target.value),
447
- rows: 6,
448
- style: { ...fieldStyle, resize: "vertical", minHeight: "140px" },
449
- placeholder: "Describe what changed or what still needs attention..."
450
- }
451
- )
452
- ] }),
453
- /* @__PURE__ */ jsxs("div", { style: { ...surfaceCardStyle, padding: "16px" }, children: [
454
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: "8px", marginBottom: "12px" }, children: [
455
- /* @__PURE__ */ jsxs("div", { children: [
456
- /* @__PURE__ */ jsx("p", { style: sectionLabelStyle, children: "Screenshot" }),
457
- /* @__PURE__ */ jsx("p", { style: { ...metaTextStyle, marginTop: "4px" }, children: "Paste an image, capture the current tab, or upload a replacement." })
458
- ] }),
459
- screenshotId ? /* @__PURE__ */ jsxs("span", { style: pillStyle("neutral"), children: [
460
- "Media #",
461
- screenshotId
462
- ] }) : null
463
- ] }),
464
- /* @__PURE__ */ jsx("div", { style: { ...innerCardStyle, overflow: "hidden" }, children: screenshotUrl ? (
465
- // eslint-disable-next-line @next/next/no-img-element
466
- /* @__PURE__ */ jsx(
467
- "img",
468
- {
469
- src: screenshotUrl,
470
- alt: "Screenshot",
471
- style: { width: "100%", height: "auto", display: "block", maxHeight: "280px", objectFit: "cover" }
472
- }
473
- )
474
- ) : /* @__PURE__ */ jsx(
475
- "div",
476
- {
477
- style: {
478
- minHeight: "180px",
479
- display: "grid",
480
- placeItems: "center",
481
- color: theme.textMuted,
482
- background: "rgba(15, 23, 42, 0.72)"
483
- },
484
- children: /* @__PURE__ */ jsxs("div", { style: { textAlign: "center" }, children: [
485
- /* @__PURE__ */ jsx(ImageIcon, { size: 24, style: { marginBottom: "8px" } }),
486
- /* @__PURE__ */ jsx("p", { style: metaTextStyle, children: "No screenshot attached." })
487
- ] })
488
- }
489
- ) }),
490
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "8px", flexWrap: "wrap", marginTop: "12px" }, children: [
491
- /* @__PURE__ */ jsx(
492
- "button",
493
- {
494
- type: "button",
495
- onClick: handleCapture,
496
- disabled: uploading,
497
- "aria-label": uploading ? "Capturing screen" : "Capture screen",
498
- title: uploading ? "Capturing screen" : "Capture screen",
499
- style: buttonStyle("secondary", { compact: true, disabled: uploading, iconOnly: true }),
500
- children: /* @__PURE__ */ jsx(Camera, { size: 15 })
501
- }
502
- ),
503
- /* @__PURE__ */ jsxs(
504
- "label",
505
- {
506
- "aria-label": "Upload image",
507
- title: "Upload image",
508
- style: buttonStyle("secondary", { compact: true, iconOnly: true }),
509
- children: [
510
- /* @__PURE__ */ jsx(Upload, { size: 15 }),
511
- /* @__PURE__ */ jsx("input", { type: "file", accept: "image/png,image/jpeg,image/webp", onChange: handleFileUpload, hidden: true })
512
- ]
513
- }
514
- ),
515
- currentScreenshotId && screenshotUrl ? /* @__PURE__ */ jsxs("button", { type: "button", onClick: handleRemoveScreenshot, disabled: removing, style: buttonStyle("danger", { compact: true, disabled: removing }), children: [
516
- /* @__PURE__ */ jsx(Trash2, { size: 15 }),
517
- removing ? "Removing..." : "Remove"
518
- ] }) : null
519
- ] })
520
- ] }),
521
- error ? /* @__PURE__ */ jsx("div", { style: { ...surfaceCardStyle, padding: "12px 14px", borderColor: "rgba(248, 113, 113, 0.24)" }, children: /* @__PURE__ */ jsx("p", { style: { ...statusTextStyle, color: "#fecaca" }, children: error }) }) : null,
522
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "flex-end", gap: "8px", flexWrap: "wrap" }, children: [
523
- /* @__PURE__ */ jsxs(
524
- "button",
525
- {
526
- type: "button",
527
- onClick: () => {
528
- setEditing(false);
529
- setMessage(feedback.message);
530
- setScreenshotId(screenshot?.id ?? null);
531
- setScreenshotUrl(screenshot?.url ?? null);
532
- setError(null);
533
- },
534
- style: buttonStyle("ghost"),
535
- children: [
536
- /* @__PURE__ */ jsx(X, { size: 15 }),
537
- "Cancel"
538
- ]
539
- }
540
- ),
541
- /* @__PURE__ */ jsxs("button", { type: "button", onClick: handleSave, disabled: saving, style: buttonStyle("primary", { disabled: saving }), children: [
542
- /* @__PURE__ */ jsx(Save, { size: 15 }),
543
- saving ? "Saving..." : "Save changes"
544
- ] })
545
- ] })
546
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
547
- /* @__PURE__ */ jsx("div", { style: { ...surfaceCardStyle, padding: "18px" }, children: /* @__PURE__ */ jsx("p", { style: { margin: 0, fontSize: "15px", lineHeight: 1.7, whiteSpace: "pre-wrap", wordBreak: "break-word" }, children: feedback.message }) }),
548
- screenshot ? /* @__PURE__ */ jsxs("div", { style: { ...surfaceCardStyle, padding: "12px" }, children: [
549
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", gap: "8px", marginBottom: "10px" }, children: [
550
- /* @__PURE__ */ jsx("p", { style: sectionLabelStyle, children: "Screenshot" }),
551
- /* @__PURE__ */ jsxs(
552
- "button",
553
- {
554
- type: "button",
555
- onClick: () => window.open(screenshot.url, "_blank"),
556
- style: buttonStyle("ghost", { compact: true }),
557
- children: [
558
- /* @__PURE__ */ jsx(ExternalLink, { size: 14 }),
559
- "Open full size"
560
- ]
561
- }
562
- )
563
- ] }),
564
- /* @__PURE__ */ jsx("div", { style: { ...innerCardStyle, overflow: "hidden" }, children: /* @__PURE__ */ jsx(
565
- "img",
566
- {
567
- src: screenshot.url,
568
- alt: "Feedback screenshot",
569
- style: { width: "100%", height: "auto", display: "block", cursor: "pointer" },
570
- onClick: () => window.open(screenshot.url, "_blank")
571
- }
572
- ) })
573
- ] }) : null,
574
- /* @__PURE__ */ jsxs("div", { style: { ...surfaceCardStyle, padding: "16px", display: "grid", gap: "12px" }, children: [
575
- /* @__PURE__ */ jsxs("div", { children: [
576
- /* @__PURE__ */ jsx("p", { style: sectionLabelStyle, children: "Page" }),
577
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px", marginTop: "6px" }, children: [
578
- /* @__PURE__ */ jsx(MapPin, { size: 15, color: theme.textMuted }),
579
- /* @__PURE__ */ jsx("p", { style: { ...metaTextStyle, wordBreak: "break-all" }, children: feedback.pagePath })
580
- ] })
581
- ] }),
582
- /* @__PURE__ */ jsxs("div", { children: [
583
- /* @__PURE__ */ jsx("p", { style: sectionLabelStyle, children: "Created" }),
584
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px", marginTop: "6px" }, children: [
585
- /* @__PURE__ */ jsx(CalendarClock, { size: 15, color: theme.textMuted }),
586
- /* @__PURE__ */ jsx("p", { style: metaTextStyle, children: formatDate(feedback.createdAt) })
587
- ] })
588
- ] })
589
- ] }),
590
- error ? /* @__PURE__ */ jsx("div", { style: { ...surfaceCardStyle, padding: "12px 14px", borderColor: "rgba(248, 113, 113, 0.24)" }, children: /* @__PURE__ */ jsx("p", { style: { ...statusTextStyle, color: "#fecaca" }, children: error }) }) : null
591
- ] })
592
- ] });
593
- }
594
- var STATUS_VARIANTS = {
595
- new: "success",
596
- triaged: "warning",
597
- resolved: "muted"
598
- };
599
- var STATUS_LABELS = {
600
- new: "New",
601
- triaged: "Triaged",
602
- resolved: "Resolved"
603
- };
604
- var formatRelativeTime = (iso) => {
605
- const now = Date.now();
606
- const then = new Date(iso).getTime();
607
- const diff = now - then;
608
- const minutes = Math.floor(diff / 6e4);
609
- if (minutes < 1) return "Just now";
610
- if (minutes < 60) return `${minutes}m ago`;
611
- const hours = Math.floor(minutes / 60);
612
- if (hours < 24) return `${hours}h ago`;
613
- const days = Math.floor(hours / 24);
614
- if (days < 7) return `${days}d ago`;
615
- const weeks = Math.floor(days / 7);
616
- if (weeks < 5) return `${weeks}w ago`;
617
- return new Date(iso).toLocaleDateString();
618
- };
619
- var getScreenshotThumb = (item) => {
620
- if (!item.screenshot || typeof item.screenshot !== "object") return null;
621
- return item.screenshot.url || null;
622
- };
623
- var getCreatorId2 = (createdBy) => {
624
- if (!createdBy) return null;
625
- if (typeof createdBy === "object") return createdBy.id;
626
- return createdBy;
627
- };
628
- function FeedbackHistory({
629
- feedbacks,
630
- totalPages,
631
- currentPage,
632
- loading,
633
- error,
634
- currentUserId,
635
- onSelectFeedback,
636
- onPageChange,
637
- onRefetch
638
- }) {
639
- if (loading) {
640
- return /* @__PURE__ */ jsx("div", { style: { display: "grid", gap: "10px" }, children: [1, 2, 3].map((item) => /* @__PURE__ */ jsx(
641
- "div",
642
- {
643
- style: {
644
- ...surfaceCardStyle,
645
- padding: "14px"
646
- },
647
- children: /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "12px", alignItems: "center" }, children: [
648
- /* @__PURE__ */ jsx(
649
- "div",
650
- {
651
- style: {
652
- width: "52px",
653
- height: "52px",
654
- borderRadius: "14px",
655
- background: "rgba(148, 163, 184, 0.14)",
656
- flexShrink: 0
657
- }
658
- }
659
- ),
660
- /* @__PURE__ */ jsxs("div", { style: { flex: 1 }, children: [
661
- /* @__PURE__ */ jsx(
662
- "div",
663
- {
664
- style: {
665
- height: "14px",
666
- width: "72%",
667
- borderRadius: "999px",
668
- background: "rgba(148, 163, 184, 0.18)",
669
- marginBottom: "10px"
670
- }
671
- }
672
- ),
673
- /* @__PURE__ */ jsx(
674
- "div",
675
- {
676
- style: {
677
- height: "10px",
678
- width: "48%",
679
- borderRadius: "999px",
680
- background: "rgba(148, 163, 184, 0.12)"
681
- }
682
- }
683
- )
684
- ] })
685
- ] })
686
- },
687
- item
688
- )) });
689
- }
690
- if (error) {
691
- return /* @__PURE__ */ jsxs(
692
- "div",
693
- {
694
- style: {
695
- ...surfaceCardStyle,
696
- padding: "18px",
697
- textAlign: "center"
698
- },
699
- children: [
700
- /* @__PURE__ */ jsx("p", { style: { ...statusTextStyle, color: "#fecaca", marginBottom: "12px" }, children: error }),
701
- /* @__PURE__ */ jsxs("button", { type: "button", onClick: onRefetch, style: buttonStyle("secondary"), children: [
702
- /* @__PURE__ */ jsx(RefreshCw, { size: 15 }),
703
- "Retry"
704
- ] })
705
- ]
706
- }
707
- );
708
- }
709
- if (feedbacks.length === 0) {
710
- return /* @__PURE__ */ jsxs(
711
- "div",
712
- {
713
- style: {
714
- ...surfaceCardStyle,
715
- padding: "26px 18px",
716
- textAlign: "center"
717
- },
718
- children: [
719
- /* @__PURE__ */ jsx(
720
- "div",
721
- {
722
- style: {
723
- width: "44px",
724
- height: "44px",
725
- borderRadius: "14px",
726
- margin: "0 auto 12px",
727
- display: "grid",
728
- placeItems: "center",
729
- background: "rgba(94, 234, 212, 0.12)",
730
- color: theme.accent
731
- },
732
- children: /* @__PURE__ */ jsx(MessageSquareText, { size: 20 })
733
- }
734
- ),
735
- /* @__PURE__ */ jsx("p", { style: { margin: "0 0 4px", fontSize: "14px", fontWeight: 600 }, children: "No feedback yet" }),
736
- /* @__PURE__ */ jsx("p", { style: metaTextStyle, children: "New reports will appear here with screenshots, status, and page context." })
737
- ]
738
- }
739
- );
740
- }
741
- return /* @__PURE__ */ jsxs("div", { style: { display: "grid", gap: "10px" }, children: [
742
- feedbacks.map((item) => {
743
- const thumb = getScreenshotThumb(item);
744
- const preview = item.message.length > 110 ? `${item.message.slice(0, 110)}...` : item.message;
745
- const isMine = currentUserId !== null && getCreatorId2(item.createdBy) === currentUserId;
746
- return /* @__PURE__ */ jsxs(
747
- "button",
748
- {
749
- type: "button",
750
- onClick: () => onSelectFeedback(item.id),
751
- style: {
752
- ...surfaceCardStyle,
753
- display: "flex",
754
- width: "100%",
755
- gap: "12px",
756
- padding: "14px",
757
- color: theme.text,
758
- textAlign: "left",
759
- cursor: "pointer"
760
- },
761
- children: [
762
- /* @__PURE__ */ jsx(
763
- "div",
764
- {
765
- style: {
766
- ...innerCardStyle,
767
- width: "56px",
768
- height: "56px",
769
- overflow: "hidden",
770
- flexShrink: 0,
771
- display: "grid",
772
- placeItems: "center",
773
- color: theme.textMuted
774
- },
775
- children: thumb ? (
776
- // eslint-disable-next-line @next/next/no-img-element
777
- /* @__PURE__ */ jsx(
778
- "img",
779
- {
780
- src: thumb,
781
- alt: "",
782
- style: {
783
- width: "100%",
784
- height: "100%",
785
- objectFit: "cover",
786
- display: "block"
787
- }
788
- }
789
- )
790
- ) : /* @__PURE__ */ jsx(ImageIcon, { size: 18 })
791
- }
792
- ),
793
- /* @__PURE__ */ jsxs("div", { style: { flex: 1, minWidth: 0 }, children: [
794
- /* @__PURE__ */ jsxs(
795
- "div",
796
- {
797
- style: {
798
- display: "flex",
799
- alignItems: "flex-start",
800
- gap: "8px",
801
- justifyContent: "space-between",
802
- marginBottom: "8px"
803
- },
804
- children: [
805
- /* @__PURE__ */ jsx(
806
- "p",
807
- {
808
- style: {
809
- margin: 0,
810
- fontSize: "14px",
811
- lineHeight: 1.5,
812
- color: theme.text,
813
- overflow: "hidden",
814
- display: "-webkit-box",
815
- WebkitBoxOrient: "vertical",
816
- WebkitLineClamp: 2
817
- },
818
- children: preview
819
- }
820
- ),
821
- /* @__PURE__ */ jsx("span", { style: pillStyle(STATUS_VARIANTS[item.status] || "success"), children: STATUS_LABELS[item.status] || "New" })
822
- ]
823
- }
824
- ),
825
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px", flexWrap: "wrap" }, children: [
826
- /* @__PURE__ */ jsxs("span", { style: pillStyle("neutral"), children: [
827
- /* @__PURE__ */ jsx(Clock3, { size: 12 }),
828
- formatRelativeTime(item.createdAt)
829
- ] }),
830
- /* @__PURE__ */ jsxs("span", { style: pillStyle("neutral"), children: [
831
- /* @__PURE__ */ jsx(MapPin, { size: 12 }),
832
- item.pagePath
833
- ] }),
834
- isMine ? /* @__PURE__ */ jsx("span", { style: pillStyle("success"), children: "Mine" }) : null
835
- ] })
836
- ] })
837
- ]
838
- },
839
- item.id
840
- );
841
- }),
842
- totalPages > 1 ? /* @__PURE__ */ jsxs(
843
- "div",
844
- {
845
- style: {
846
- ...surfaceCardStyle,
847
- padding: "12px",
848
- display: "flex",
849
- alignItems: "center",
850
- justifyContent: "space-between",
851
- gap: "10px"
852
- },
853
- children: [
854
- /* @__PURE__ */ jsxs(
855
- "button",
856
- {
857
- type: "button",
858
- disabled: currentPage <= 1,
859
- onClick: () => onPageChange(currentPage - 1),
860
- style: buttonStyle("secondary", { compact: true, disabled: currentPage <= 1 }),
861
- children: [
862
- /* @__PURE__ */ jsx(ChevronLeft, { size: 15 }),
863
- "Previous"
864
- ]
865
- }
866
- ),
867
- /* @__PURE__ */ jsxs("div", { style: { textAlign: "center" }, children: [
868
- /* @__PURE__ */ jsx("p", { style: sectionLabelStyle, children: "Page" }),
869
- /* @__PURE__ */ jsxs("p", { style: { ...metaTextStyle, marginTop: "2px" }, children: [
870
- currentPage,
871
- " of ",
872
- totalPages
873
- ] })
874
- ] }),
875
- /* @__PURE__ */ jsxs(
876
- "button",
877
- {
878
- type: "button",
879
- disabled: currentPage >= totalPages,
880
- onClick: () => onPageChange(currentPage + 1),
881
- style: buttonStyle("secondary", { compact: true, disabled: currentPage >= totalPages }),
882
- children: [
883
- "Next",
884
- /* @__PURE__ */ jsx(ChevronRight, { size: 15 })
885
- ]
886
- }
887
- )
888
- ]
889
- }
890
- ) : null
891
- ] });
892
- }
893
6
  var DEFAULT_COLORS = ["#ef4444", "#f97316", "#eab308", "#22c55e", "#06b6d4", "#3b82f6", "#a855f7"];
894
7
  var DEFAULT_HISTORY = {
895
8
  operations: [],
@@ -899,21 +12,17 @@ var DEFAULT_HISTORY = {
899
12
  var createOperationId = () => `annotation-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
900
13
  var getCssSelector = (element) => {
901
14
  if (element.id) {
902
- return `#${CSS.escape(element.id)}`;
15
+ return `#${element.id}`;
903
16
  }
904
17
  const parts = [];
905
18
  let current = element;
906
19
  while (current && current.nodeType === Node.ELEMENT_NODE && current !== document.body) {
907
- const tag = current.tagName.toLowerCase();
908
- if (tag === "body" || tag === "html") {
909
- break;
910
- }
911
- let part = tag;
20
+ let part = current.tagName.toLowerCase();
912
21
  const className = current.className;
913
22
  if (typeof className === "string") {
914
23
  const firstClass = className.split(" ").map((value) => value.trim()).filter(Boolean)[0];
915
24
  if (firstClass) {
916
- part += `.${CSS.escape(firstClass)}`;
25
+ part += `.${firstClass}`;
917
26
  }
918
27
  }
919
28
  const parent = current.parentElement;
@@ -960,7 +69,7 @@ var createEditorImage = async (file) => {
960
69
  width: element.naturalWidth || element.width
961
70
  };
962
71
  };
963
- var canvasToFile2 = async (canvas, fileName = `feedback-${Date.now()}.png`) => {
72
+ var canvasToFile = async (canvas, fileName = `feedback-${Date.now()}.png`) => {
964
73
  const blob = await new Promise((resolve) => {
965
74
  canvas.toBlob((nextBlob) => resolve(nextBlob), "image/png");
966
75
  });
@@ -980,7 +89,7 @@ var waitForRenderedVideoFrame = async (video) => {
980
89
  window.requestAnimationFrame(() => resolve());
981
90
  });
982
91
  };
983
- var captureScreenshotFile2 = async (capturePolicy) => {
92
+ var captureScreenshotFile = async (capturePolicy) => {
984
93
  if (!navigator.mediaDevices?.getDisplayMedia) {
985
94
  throw new Error("Browser does not support screen capture.");
986
95
  }
@@ -1029,7 +138,7 @@ var captureScreenshotFile2 = async (capturePolicy) => {
1029
138
  }
1030
139
  context.drawImage(video, 0, 0, width, height);
1031
140
  return {
1032
- file: await canvasToFile2(canvas),
141
+ file: await canvasToFile(canvas),
1033
142
  surface
1034
143
  };
1035
144
  } finally {
@@ -1132,6 +241,87 @@ var drawOperation = (context, operation) => {
1132
241
  }
1133
242
  };
1134
243
  var isShapeMeaningful = (start, end) => Math.abs(end.x - start.x) > 3 || Math.abs(end.y - start.y) > 3;
244
+ function ChatIcon() {
245
+ return /* @__PURE__ */ jsx("svg", { width: "22", height: "22", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" }) });
246
+ }
247
+ function XIcon({ size = 18 }) {
248
+ return /* @__PURE__ */ jsxs("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: [
249
+ /* @__PURE__ */ jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
250
+ /* @__PURE__ */ jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
251
+ ] });
252
+ }
253
+ function CameraIcon() {
254
+ return /* @__PURE__ */ jsxs("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
255
+ /* @__PURE__ */ jsx("path", { d: "M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z" }),
256
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "13", r: "4" })
257
+ ] });
258
+ }
259
+ function CursorIcon() {
260
+ return /* @__PURE__ */ jsx("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "M4 4l7.07 17 2.51-7.39L21 11.07z" }) });
261
+ }
262
+ function UploadIcon() {
263
+ return /* @__PURE__ */ jsxs("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
264
+ /* @__PURE__ */ jsx("polyline", { points: "16 16 12 12 8 16" }),
265
+ /* @__PURE__ */ jsx("line", { x1: "12", y1: "12", x2: "12", y2: "21" }),
266
+ /* @__PURE__ */ jsx("path", { d: "M20.39 18.39A5 5 0 0 0 18 9h-1.26A8 8 0 1 0 3 16.3" })
267
+ ] });
268
+ }
269
+ function SendIcon() {
270
+ return /* @__PURE__ */ jsxs("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
271
+ /* @__PURE__ */ jsx("line", { x1: "22", y1: "2", x2: "11", y2: "13" }),
272
+ /* @__PURE__ */ jsx("polygon", { points: "22 2 15 22 11 13 2 9 22 2" })
273
+ ] });
274
+ }
275
+ function CheckCircleIcon() {
276
+ return /* @__PURE__ */ jsxs("svg", { width: "48", height: "48", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", children: [
277
+ /* @__PURE__ */ jsx("path", { d: "M22 11.08V12a10 10 0 1 1-5.93-9.14" }),
278
+ /* @__PURE__ */ jsx("polyline", { points: "22 4 12 14.01 9 11.01" })
279
+ ] });
280
+ }
281
+ function PenIcon() {
282
+ return /* @__PURE__ */ jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
283
+ /* @__PURE__ */ jsx("path", { d: "M12 19l7-7 3 3-7 7-3-3z" }),
284
+ /* @__PURE__ */ jsx("path", { d: "M18 13l-1.5-7.5L2 2l3.5 14.5L13 18l5-5z" }),
285
+ /* @__PURE__ */ jsx("path", { d: "M2 2l7.586 7.586" }),
286
+ /* @__PURE__ */ jsx("circle", { cx: "11", cy: "11", r: "2" })
287
+ ] });
288
+ }
289
+ function RectIcon() {
290
+ return /* @__PURE__ */ jsx("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2", ry: "2" }) });
291
+ }
292
+ function ArrowIcon() {
293
+ return /* @__PURE__ */ jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
294
+ /* @__PURE__ */ jsx("line", { x1: "5", y1: "19", x2: "19", y2: "5" }),
295
+ /* @__PURE__ */ jsx("polyline", { points: "13 5 19 5 19 11" })
296
+ ] });
297
+ }
298
+ function TextIcon() {
299
+ return /* @__PURE__ */ jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
300
+ /* @__PURE__ */ jsx("polyline", { points: "4 7 4 4 20 4 20 7" }),
301
+ /* @__PURE__ */ jsx("line", { x1: "9", y1: "20", x2: "15", y2: "20" }),
302
+ /* @__PURE__ */ jsx("line", { x1: "12", y1: "4", x2: "12", y2: "20" })
303
+ ] });
304
+ }
305
+ function UndoIcon() {
306
+ return /* @__PURE__ */ jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
307
+ /* @__PURE__ */ jsx("polyline", { points: "9 14 4 9 9 4" }),
308
+ /* @__PURE__ */ jsx("path", { d: "M20 20v-7a4 4 0 0 0-4-4H4" })
309
+ ] });
310
+ }
311
+ function RedoIcon() {
312
+ return /* @__PURE__ */ jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
313
+ /* @__PURE__ */ jsx("polyline", { points: "15 14 20 9 15 4" }),
314
+ /* @__PURE__ */ jsx("path", { d: "M4 20v-7a4 4 0 0 1 4-4h12" })
315
+ ] });
316
+ }
317
+ function TrashIcon() {
318
+ return /* @__PURE__ */ jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
319
+ /* @__PURE__ */ jsx("polyline", { points: "3 6 5 6 21 6" }),
320
+ /* @__PURE__ */ jsx("path", { d: "M19 6l-1 14H6L5 6" }),
321
+ /* @__PURE__ */ jsx("path", { d: "M10 11v6M14 11v6" }),
322
+ /* @__PURE__ */ jsx("path", { d: "M9 6V4h6v2" })
323
+ ] });
324
+ }
1135
325
  function FeedbackWidget({
1136
326
  title = "Admin feedback",
1137
327
  submitLabel = "Send",
@@ -1142,42 +332,57 @@ function FeedbackWidget({
1142
332
  capturePolicy = "current-tab-first",
1143
333
  onSubmit,
1144
334
  onUpload,
1145
- onDeleteScreenshot,
1146
- onDeleteFeedback,
1147
- showHistory,
1148
- currentUserId,
1149
- onUpdateFeedback,
1150
- history
335
+ onDeleteScreenshot
1151
336
  }) {
1152
- const [open, setOpen] = React2.useState(false);
1153
- const [view, setView] = React2.useState("form");
1154
- const [selectedFeedback, setSelectedFeedback] = React2.useState(null);
1155
- const [message, setMessage] = React2.useState("");
1156
- const [captureMode, setCaptureMode] = React2.useState(false);
1157
- const [captureData, setCaptureData] = React2.useState(null);
1158
- const [screenshotId, setScreenshotId] = React2.useState(null);
1159
- const [screenshotPreviewUrl, setScreenshotPreviewUrl] = React2.useState(null);
1160
- const [uploading, setUploading] = React2.useState(false);
1161
- const [deletingScreenshot, setDeletingScreenshot] = React2.useState(false);
1162
- const [submitting, setSubmitting] = React2.useState(false);
1163
- const [error, setError] = React2.useState(null);
1164
- const [notice, setNotice] = React2.useState(null);
1165
- const [annotating, setAnnotating] = React2.useState(false);
1166
- const [editorImage, setEditorImage] = React2.useState(null);
1167
- const [editorHistory, setEditorHistory] = React2.useState(DEFAULT_HISTORY);
1168
- const [draftOperation, setDraftOperation] = React2.useState(null);
1169
- const [annotationTool, setAnnotationTool] = React2.useState("pen");
1170
- const [annotationColor, setAnnotationColor] = React2.useState(DEFAULT_COLORS[0]);
1171
- const [annotationSize, setAnnotationSize] = React2.useState(4);
1172
- const [annotationText, setAnnotationText] = React2.useState("");
1173
- const hoverTargetRef = React2.useRef(null);
1174
- const annotationCanvasRef = React2.useRef(null);
1175
- const pointerIdRef = React2.useRef(null);
1176
- const draftOperationRef = React2.useRef(null);
1177
- React2.useEffect(() => {
337
+ const [open, setOpen] = React.useState(false);
338
+ const [message, setMessage] = React.useState("");
339
+ const [captureMode, setCaptureMode] = React.useState(false);
340
+ const [captureData, setCaptureData] = React.useState(null);
341
+ const [screenshotId, setScreenshotId] = React.useState(null);
342
+ const [screenshotPreviewUrl, setScreenshotPreviewUrl] = React.useState(null);
343
+ const [uploading, setUploading] = React.useState(false);
344
+ const [deletingScreenshot, setDeletingScreenshot] = React.useState(false);
345
+ const [submitting, setSubmitting] = React.useState(false);
346
+ const [submitted, setSubmitted] = React.useState(false);
347
+ const [currentPath, setCurrentPath] = React.useState("");
348
+ const [capturingScreen, setCapturingScreen] = React.useState(false);
349
+ const [error, setError] = React.useState(null);
350
+ const [notice, setNotice] = React.useState(null);
351
+ const [annotating, setAnnotating] = React.useState(false);
352
+ const [editorImage, setEditorImage] = React.useState(null);
353
+ const [editorHistory, setEditorHistory] = React.useState(DEFAULT_HISTORY);
354
+ const [draftOperation, setDraftOperation] = React.useState(null);
355
+ const [annotationTool, setAnnotationTool] = React.useState("pen");
356
+ const [annotationColor, setAnnotationColor] = React.useState(DEFAULT_COLORS[0]);
357
+ const [annotationSize, setAnnotationSize] = React.useState(4);
358
+ const [textCursor, setTextCursor] = React.useState(null);
359
+ const [inlineText, setInlineText] = React.useState("");
360
+ const hoverTargetRef = React.useRef(null);
361
+ const annotationCanvasRef = React.useRef(null);
362
+ const annotationScrollRef = React.useRef(null);
363
+ const textInputRef = React.useRef(null);
364
+ const pointerIdRef = React.useRef(null);
365
+ const draftOperationRef = React.useRef(null);
366
+ const inlineTextRef = React.useRef("");
367
+ const textCursorRef = React.useRef(null);
368
+ const annotationColorRef = React.useRef(DEFAULT_COLORS[0]);
369
+ const annotationSizeRef = React.useRef(4);
370
+ React.useEffect(() => {
1178
371
  draftOperationRef.current = draftOperation;
1179
372
  }, [draftOperation]);
1180
- React2.useEffect(() => {
373
+ React.useEffect(() => {
374
+ inlineTextRef.current = inlineText;
375
+ }, [inlineText]);
376
+ React.useEffect(() => {
377
+ textCursorRef.current = textCursor;
378
+ }, [textCursor]);
379
+ React.useEffect(() => {
380
+ annotationColorRef.current = annotationColor;
381
+ }, [annotationColor]);
382
+ React.useEffect(() => {
383
+ annotationSizeRef.current = annotationSize;
384
+ }, [annotationSize]);
385
+ React.useEffect(() => {
1181
386
  if (!captureMode) {
1182
387
  return;
1183
388
  }
@@ -1220,7 +425,7 @@ function FeedbackWidget({
1220
425
  document.removeEventListener("click", onClick, true);
1221
426
  };
1222
427
  }, [captureMode]);
1223
- React2.useEffect(() => {
428
+ React.useEffect(() => {
1224
429
  if (!annotating) {
1225
430
  return;
1226
431
  }
@@ -1230,7 +435,7 @@ function FeedbackWidget({
1230
435
  document.body.style.overflow = previousOverflow;
1231
436
  };
1232
437
  }, [annotating]);
1233
- React2.useEffect(() => {
438
+ React.useEffect(() => {
1234
439
  if (!annotating || !editorImage || !annotationCanvasRef.current) {
1235
440
  return;
1236
441
  }
@@ -1251,7 +456,18 @@ function FeedbackWidget({
1251
456
  drawOperation(context, draftOperation);
1252
457
  }
1253
458
  }, [annotating, draftOperation, editorHistory.operations, editorImage]);
1254
- const validateImageFile = React2.useCallback(
459
+ React.useEffect(() => {
460
+ setCurrentPath(window.location.pathname);
461
+ }, []);
462
+ React.useEffect(() => {
463
+ if (!submitted) return;
464
+ const timer = setTimeout(() => {
465
+ setOpen(false);
466
+ setSubmitted(false);
467
+ }, 2500);
468
+ return () => clearTimeout(timer);
469
+ }, [submitted]);
470
+ const validateImageFile = React.useCallback(
1255
471
  (file) => {
1256
472
  if (!screenshotAllowedMimeTypes.includes(file.type)) {
1257
473
  return `Supported image types: ${screenshotAllowedMimeTypes.join(", ")}`;
@@ -1263,7 +479,7 @@ function FeedbackWidget({
1263
479
  },
1264
480
  [screenshotAllowedMimeTypes, screenshotMaxFileSizeBytes]
1265
481
  );
1266
- const uploadImageFile = React2.useCallback(
482
+ const uploadImageFile = React.useCallback(
1267
483
  async (file) => {
1268
484
  if (!onUpload) {
1269
485
  return false;
@@ -1288,14 +504,16 @@ function FeedbackWidget({
1288
504
  },
1289
505
  [onUpload]
1290
506
  );
1291
- const closeAnnotationEditor = React2.useCallback(() => {
507
+ const closeAnnotationEditor = React.useCallback(() => {
1292
508
  setAnnotating(false);
1293
509
  setEditorImage(null);
1294
510
  setEditorHistory(DEFAULT_HISTORY);
1295
511
  setDraftOperation(null);
512
+ setTextCursor(null);
513
+ setInlineText("");
1296
514
  draftOperationRef.current = null;
1297
515
  }, []);
1298
- const handleStartAnnotation = React2.useCallback(
516
+ const handleStartAnnotation = React.useCallback(
1299
517
  async (file) => {
1300
518
  const validationError = validateImageFile(file);
1301
519
  if (validationError) {
@@ -1307,6 +525,8 @@ function FeedbackWidget({
1307
525
  setEditorImage(nextImage);
1308
526
  setEditorHistory(DEFAULT_HISTORY);
1309
527
  setDraftOperation(null);
528
+ setTextCursor(null);
529
+ setInlineText("");
1310
530
  draftOperationRef.current = null;
1311
531
  setAnnotating(true);
1312
532
  setError(null);
@@ -1316,7 +536,7 @@ function FeedbackWidget({
1316
536
  },
1317
537
  [validateImageFile]
1318
538
  );
1319
- React2.useEffect(() => {
539
+ React.useEffect(() => {
1320
540
  if (!open || !allowScreenshotUpload) {
1321
541
  return;
1322
542
  }
@@ -1331,51 +551,37 @@ function FeedbackWidget({
1331
551
  window.addEventListener("paste", onPaste);
1332
552
  return () => window.removeEventListener("paste", onPaste);
1333
553
  }, [allowScreenshotUpload, handleStartAnnotation, open]);
1334
- const handleSelectFeedback = React2.useCallback(
1335
- async (id) => {
1336
- const found = history?.feedbacks.find((f) => f.id === id);
1337
- if (found) {
1338
- setSelectedFeedback(found);
1339
- setView("detail");
1340
- return;
1341
- }
1342
- try {
1343
- const res = await fetch(`/api/admin-feedback/${id}?depth=2`, { credentials: "include" });
1344
- if (res.ok) {
1345
- const data = await res.json();
1346
- setSelectedFeedback(data);
1347
- setView("detail");
1348
- }
1349
- } catch {
1350
- }
1351
- },
1352
- [history?.feedbacks]
1353
- );
1354
- React2.useEffect(() => {
1355
- const handler = (e) => {
1356
- const detail = e.detail;
1357
- if (detail?.feedbackId) {
1358
- setOpen(true);
1359
- handleSelectFeedback(detail.feedbackId);
1360
- }
1361
- };
1362
- window.addEventListener("feedback:show-detail", handler);
1363
- return () => window.removeEventListener("feedback:show-detail", handler);
1364
- }, [handleSelectFeedback]);
1365
- const commitOperations = React2.useCallback((nextOperations) => {
554
+ const commitOperations = React.useCallback((nextOperations) => {
1366
555
  setEditorHistory((current) => ({
1367
556
  operations: nextOperations,
1368
557
  redoStack: [],
1369
558
  undoStack: [...current.undoStack, current.operations]
1370
559
  }));
1371
560
  }, []);
1372
- const appendOperation = React2.useCallback((operation) => {
561
+ const appendOperation = React.useCallback((operation) => {
1373
562
  setEditorHistory((current) => ({
1374
563
  operations: [...current.operations, operation],
1375
564
  redoStack: [],
1376
565
  undoStack: [...current.undoStack, current.operations]
1377
566
  }));
1378
567
  }, []);
568
+ const commitTextInput = React.useCallback(() => {
569
+ const text = inlineTextRef.current.trim();
570
+ const cursor = textCursorRef.current;
571
+ if (text && cursor) {
572
+ const operation = {
573
+ id: createOperationId(),
574
+ type: "text",
575
+ style: { color: annotationColorRef.current, size: annotationSizeRef.current },
576
+ point: cursor.canvasPoint,
577
+ text
578
+ };
579
+ appendOperation(operation);
580
+ }
581
+ textCursorRef.current = null;
582
+ setTextCursor(null);
583
+ setInlineText("");
584
+ }, [appendOperation]);
1379
585
  const handleUpload = async (event) => {
1380
586
  const file = event.target.files?.[0];
1381
587
  if (file) {
@@ -1386,7 +592,9 @@ function FeedbackWidget({
1386
592
  const handleCaptureScreenshot = async () => {
1387
593
  try {
1388
594
  setError(null);
1389
- const { file, surface } = await captureScreenshotFile2(capturePolicy);
595
+ setCapturingScreen(true);
596
+ await new Promise((resolve) => setTimeout(resolve, 120));
597
+ const { file, surface } = await captureScreenshotFile(capturePolicy);
1390
598
  if (capturePolicy === "current-tab-first") {
1391
599
  if (surface === "browser") {
1392
600
  setNotice("Captured the current tab.");
@@ -1403,6 +611,8 @@ function FeedbackWidget({
1403
611
  await handleStartAnnotation(file);
1404
612
  } catch (nextError) {
1405
613
  setError(nextError instanceof Error ? nextError.message : "Screen capture failed.");
614
+ } finally {
615
+ setCapturingScreen(false);
1406
616
  }
1407
617
  };
1408
618
  const handleUndo = () => {
@@ -1437,42 +647,31 @@ function FeedbackWidget({
1437
647
  }
1438
648
  commitOperations([]);
1439
649
  };
1440
- const handleRevertLastAnnotation = () => {
1441
- setDraftOperation(null);
1442
- draftOperationRef.current = null;
1443
- pointerIdRef.current = null;
1444
- setEditorHistory((current) => {
1445
- if (current.operations.length === 0) {
1446
- return current;
1447
- }
1448
- return {
1449
- operations: current.operations.slice(0, -1),
1450
- redoStack: [],
1451
- undoStack: [...current.undoStack, current.operations]
1452
- };
1453
- });
1454
- };
1455
650
  const handleCanvasPointerDown = (event) => {
1456
651
  if (!annotationCanvasRef.current) {
1457
652
  return;
1458
653
  }
1459
654
  setError(null);
1460
655
  const canvas = annotationCanvasRef.current;
1461
- const point = getCanvasPoint(event, canvas);
656
+ const canvasPoint = getCanvasPoint(event, canvas);
1462
657
  if (annotationTool === "text") {
1463
- const text = annotationText.trim();
1464
- if (!text) {
1465
- setError("Enter text before placing it on the image.");
1466
- return;
658
+ const existingText = inlineTextRef.current.trim();
659
+ const existingCursor = textCursorRef.current;
660
+ if (existingText && existingCursor) {
661
+ appendOperation({
662
+ id: createOperationId(),
663
+ type: "text",
664
+ style: { color: annotationColorRef.current, size: annotationSizeRef.current },
665
+ point: existingCursor.canvasPoint,
666
+ text: existingText
667
+ });
1467
668
  }
1468
- const operation = {
1469
- id: createOperationId(),
1470
- type: "text",
1471
- style: { color: annotationColor, size: annotationSize },
1472
- point,
1473
- text
1474
- };
1475
- appendOperation(operation);
669
+ const domX = event.clientX;
670
+ const domY = event.clientY;
671
+ inlineTextRef.current = "";
672
+ textCursorRef.current = { domX, domY, canvasPoint };
673
+ setInlineText("");
674
+ setTextCursor({ domX, domY, canvasPoint });
1476
675
  return;
1477
676
  }
1478
677
  event.preventDefault();
@@ -1483,19 +682,19 @@ function FeedbackWidget({
1483
682
  id: createOperationId(),
1484
683
  type: "pen",
1485
684
  style,
1486
- points: [point]
685
+ points: [canvasPoint]
1487
686
  } : annotationTool === "rectangle" ? {
1488
687
  id: createOperationId(),
1489
688
  type: "rectangle",
1490
689
  style,
1491
- start: point,
1492
- end: point
690
+ start: canvasPoint,
691
+ end: canvasPoint
1493
692
  } : {
1494
693
  id: createOperationId(),
1495
694
  type: "arrow",
1496
695
  style,
1497
- start: point,
1498
- end: point
696
+ start: canvasPoint,
697
+ end: canvasPoint
1499
698
  };
1500
699
  draftOperationRef.current = nextDraft;
1501
700
  setDraftOperation(nextDraft);
@@ -1558,7 +757,7 @@ function FeedbackWidget({
1558
757
  }
1559
758
  try {
1560
759
  const previewUrl = annotationCanvasRef.current.toDataURL("image/png");
1561
- const file = await canvasToFile2(annotationCanvasRef.current, editorImage.fileName);
760
+ const file = await canvasToFile(annotationCanvasRef.current, editorImage.fileName);
1562
761
  const uploaded = await uploadImageFile(file);
1563
762
  if (uploaded) {
1564
763
  setScreenshotPreviewUrl(previewUrl);
@@ -1602,7 +801,7 @@ function FeedbackWidget({
1602
801
  setError(null);
1603
802
  const result = await onSubmit({
1604
803
  message: message.trim(),
1605
- pagePath: typeof window !== "undefined" ? window.location.pathname : "/",
804
+ pagePath: currentPath,
1606
805
  selector: captureData?.selector,
1607
806
  selectedText: captureData?.selectedText,
1608
807
  screenshotId,
@@ -1622,92 +821,235 @@ function FeedbackWidget({
1622
821
  setScreenshotId(null);
1623
822
  setScreenshotPreviewUrl(null);
1624
823
  setNotice(null);
1625
- setView("form");
1626
- setOpen(false);
824
+ setSubmitted(true);
1627
825
  };
1628
826
  const currentHasUndo = editorHistory.undoStack.length > 0;
1629
827
  const currentHasRedo = editorHistory.redoStack.length > 0;
1630
828
  const hasAnnotations = editorHistory.operations.length > 0;
1631
- const currentPath = typeof window !== "undefined" ? window.location.pathname : "/";
1632
- const canManageScreenshots = allowScreenshotUpload && onUpload;
1633
- const annotationTools = [
1634
- { tool: "pen", label: "Pen", icon: PenTool },
1635
- { tool: "rectangle", label: "Box", icon: Square },
1636
- { tool: "arrow", label: "Arrow", icon: ArrowRight },
1637
- { tool: "text", label: "Text", icon: Type }
1638
- ];
829
+ const toolBtn = (tool, icon, label) => /* @__PURE__ */ jsxs(
830
+ "button",
831
+ {
832
+ type: "button",
833
+ title: label,
834
+ onClick: () => setAnnotationTool(tool),
835
+ style: {
836
+ display: "flex",
837
+ alignItems: "center",
838
+ gap: "5px",
839
+ borderRadius: "6px",
840
+ border: annotationTool === tool ? "1px solid #4ade80" : "1px solid #334155",
841
+ background: annotationTool === tool ? "rgba(74,222,128,0.12)" : "#0f172a",
842
+ color: annotationTool === tool ? "#4ade80" : "#94a3b8",
843
+ padding: "5px 9px",
844
+ cursor: "pointer",
845
+ fontSize: "12px",
846
+ fontWeight: 500
847
+ },
848
+ children: [
849
+ icon,
850
+ label
851
+ ]
852
+ },
853
+ tool
854
+ );
855
+ const iconBtn = (onClick, icon, label, disabled = false) => /* @__PURE__ */ jsxs(
856
+ "button",
857
+ {
858
+ type: "button",
859
+ title: label,
860
+ onClick,
861
+ disabled,
862
+ style: {
863
+ display: "flex",
864
+ alignItems: "center",
865
+ gap: "4px",
866
+ borderRadius: "6px",
867
+ border: "1px solid #334155",
868
+ background: "#0f172a",
869
+ color: disabled ? "#475569" : "#94a3b8",
870
+ padding: "5px 9px",
871
+ cursor: disabled ? "not-allowed" : "pointer",
872
+ fontSize: "12px"
873
+ },
874
+ children: [
875
+ icon,
876
+ label
877
+ ]
878
+ }
879
+ );
1639
880
  return /* @__PURE__ */ jsxs(Fragment, { children: [
1640
- /* @__PURE__ */ jsxs(
881
+ /* @__PURE__ */ jsx("style", { children: `
882
+ @keyframes afb-spin-in {
883
+ from { transform: rotate(-90deg) scale(0.7); opacity: 0; }
884
+ to { transform: rotate(0deg) scale(1); opacity: 1; }
885
+ }
886
+ .afb-icon-enter {
887
+ animation: afb-spin-in 0.18s ease forwards;
888
+ }
889
+ ` }),
890
+ /* @__PURE__ */ jsx(
1641
891
  "button",
1642
892
  {
1643
893
  type: "button",
1644
894
  onClick: () => {
1645
- setOpen((value) => !value);
1646
- if (!open) setView("form");
895
+ if (submitted) return;
896
+ setOpen((v) => !v);
1647
897
  },
1648
- style: floatingLauncherStyle,
1649
- children: [
1650
- /* @__PURE__ */ jsx(MessageSquarePlus, { size: 18 }),
1651
- "Feedback"
1652
- ]
898
+ title: open ? "Close feedback" : "Send feedback",
899
+ style: {
900
+ position: "fixed",
901
+ right: "20px",
902
+ bottom: "20px",
903
+ zIndex: 9999,
904
+ width: "48px",
905
+ height: "48px",
906
+ borderRadius: "50%",
907
+ backgroundColor: open ? "#374151" : "#15803d",
908
+ color: "#ffffff",
909
+ border: "none",
910
+ display: "flex",
911
+ alignItems: "center",
912
+ justifyContent: "center",
913
+ cursor: "pointer",
914
+ boxShadow: "0 4px 14px rgba(0,0,0,0.4)",
915
+ transition: "background-color 0.2s ease, transform 0.15s ease",
916
+ visibility: capturingScreen ? "hidden" : "visible"
917
+ },
918
+ children: /* @__PURE__ */ jsx("span", { className: "afb-icon-enter", children: open ? /* @__PURE__ */ jsx(XIcon, { size: 20 }) : /* @__PURE__ */ jsx(ChatIcon, {}) }, open ? "x" : "chat")
1653
919
  }
1654
920
  ),
1655
- open ? /* @__PURE__ */ jsxs("div", { style: panelStyle, children: [
1656
- /* @__PURE__ */ jsxs("div", { style: panelHeaderStyle, children: [
1657
- /* @__PURE__ */ jsxs(
1658
- "div",
1659
- {
1660
- style: {
1661
- display: "flex",
1662
- alignItems: "flex-start",
1663
- justifyContent: "space-between",
1664
- gap: "12px",
1665
- marginBottom: showHistory ? "14px" : 0
1666
- },
1667
- children: [
1668
- /* @__PURE__ */ jsxs("div", { children: [
1669
- /* @__PURE__ */ jsx("div", { style: { display: "flex", alignItems: "center", gap: "8px", marginBottom: "8px" }, children: /* @__PURE__ */ jsxs("span", { style: pillStyle("success"), children: [
1670
- /* @__PURE__ */ jsx(Sparkles, { size: 12 }),
1671
- "Feedback"
1672
- ] }) }),
1673
- /* @__PURE__ */ jsx("h3", { style: { margin: 0, fontSize: "16px", lineHeight: 1.2, letterSpacing: "-0.02em" }, children: title }),
1674
- /* @__PURE__ */ jsx("p", { style: { ...metaTextStyle, marginTop: "6px" }, children: "Collect issues, context, and screenshots without leaving the current page." })
1675
- ] }),
1676
- /* @__PURE__ */ jsx(
1677
- "button",
1678
- {
1679
- type: "button",
1680
- onClick: () => {
1681
- setOpen(false);
1682
- setCaptureMode(false);
1683
- },
1684
- "aria-label": "Close feedback panel",
1685
- style: buttonStyle("ghost", { compact: true, iconOnly: true }),
1686
- children: /* @__PURE__ */ jsx(X, { size: 16 })
921
+ /* @__PURE__ */ jsx(
922
+ "div",
923
+ {
924
+ style: {
925
+ position: "fixed",
926
+ right: "20px",
927
+ bottom: "80px",
928
+ width: "360px",
929
+ background: "#0f172a",
930
+ color: "#f1f5f9",
931
+ borderRadius: "14px",
932
+ border: "1px solid #1e293b",
933
+ padding: "0",
934
+ zIndex: 9999,
935
+ boxShadow: "0 16px 48px rgba(0,0,0,0.55)",
936
+ display: "flex",
937
+ flexDirection: "column",
938
+ maxHeight: "calc(100vh - 110px)",
939
+ opacity: open ? 1 : 0,
940
+ transform: open ? "scale(1) translateY(0)" : "scale(0.92) translateY(8px)",
941
+ pointerEvents: open ? "auto" : "none",
942
+ transformOrigin: "bottom right",
943
+ transition: "opacity 0.18s ease, transform 0.18s ease",
944
+ visibility: capturingScreen ? "hidden" : "visible",
945
+ overflow: "hidden"
946
+ },
947
+ children: submitted ? (
948
+ /* ── Success screen ── */
949
+ /* @__PURE__ */ jsxs(
950
+ "div",
951
+ {
952
+ style: {
953
+ display: "flex",
954
+ flexDirection: "column",
955
+ alignItems: "center",
956
+ justifyContent: "center",
957
+ gap: "12px",
958
+ padding: "40px 24px",
959
+ textAlign: "center",
960
+ color: "#4ade80"
961
+ },
962
+ children: [
963
+ /* @__PURE__ */ jsx(CheckCircleIcon, {}),
964
+ /* @__PURE__ */ jsxs("div", { children: [
965
+ /* @__PURE__ */ jsx("p", { style: { margin: "0 0 4px", fontSize: "16px", fontWeight: 600, color: "#f1f5f9" }, children: "Feedback sent!" }),
966
+ /* @__PURE__ */ jsx("p", { style: { margin: 0, fontSize: "13px", color: "#94a3b8" }, children: "Thank you \u2014 we'll take a look." })
967
+ ] })
968
+ ]
969
+ }
970
+ )
971
+ ) : /* @__PURE__ */ jsxs(Fragment, { children: [
972
+ /* @__PURE__ */ jsxs(
973
+ "div",
974
+ {
975
+ style: {
976
+ display: "flex",
977
+ alignItems: "center",
978
+ justifyContent: "space-between",
979
+ padding: "12px 14px 10px",
980
+ borderBottom: "1px solid #1e293b"
981
+ },
982
+ children: [
983
+ /* @__PURE__ */ jsxs("div", { children: [
984
+ /* @__PURE__ */ jsx("p", { style: { margin: 0, fontSize: "14px", fontWeight: 600, color: "#f1f5f9" }, children: title }),
985
+ /* @__PURE__ */ jsx("p", { style: { margin: "2px 0 0", fontSize: "11px", color: "#64748b" }, children: currentPath })
986
+ ] }),
987
+ /* @__PURE__ */ jsx(
988
+ "button",
989
+ {
990
+ type: "button",
991
+ onClick: () => setOpen(false),
992
+ title: "Close",
993
+ style: {
994
+ background: "none",
995
+ border: "none",
996
+ color: "#64748b",
997
+ cursor: "pointer",
998
+ padding: "4px",
999
+ display: "flex",
1000
+ alignItems: "center",
1001
+ borderRadius: "6px"
1002
+ },
1003
+ children: /* @__PURE__ */ jsx(XIcon, { size: 16 })
1004
+ }
1005
+ )
1006
+ ]
1007
+ }
1008
+ ),
1009
+ /* @__PURE__ */ jsxs("div", { style: { padding: "12px 14px", display: "flex", flexDirection: "column", gap: "10px", overflowY: "auto", minHeight: 0 }, children: [
1010
+ /* @__PURE__ */ jsx(
1011
+ "textarea",
1012
+ {
1013
+ value: message,
1014
+ onChange: (event) => setMessage(event.target.value),
1015
+ rows: 5,
1016
+ placeholder: "Describe the issue or share your thoughts\u2026",
1017
+ style: {
1018
+ width: "100%",
1019
+ borderRadius: "8px",
1020
+ border: "1px solid #1e293b",
1021
+ background: "#1e293b",
1022
+ color: "#f1f5f9",
1023
+ padding: "10px",
1024
+ resize: "vertical",
1025
+ fontSize: "13px",
1026
+ lineHeight: "1.5",
1027
+ outline: "none",
1028
+ boxSizing: "border-box"
1687
1029
  }
1688
- )
1689
- ]
1690
- }
1691
- ),
1692
- showHistory ? /* @__PURE__ */ jsxs(
1693
- "div",
1694
- {
1695
- style: {
1696
- ...surfaceCardStyle,
1697
- padding: "5px",
1698
- display: "flex",
1699
- gap: "6px"
1700
- },
1701
- children: [
1030
+ }
1031
+ ),
1032
+ allowScreenshotUpload && onUpload ? /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap" }, children: [
1702
1033
  /* @__PURE__ */ jsxs(
1703
1034
  "button",
1704
1035
  {
1705
1036
  type: "button",
1706
- onClick: () => setView("form"),
1707
- style: { ...buttonStyle("secondary", { active: view === "form", compact: true }), flex: 1 },
1037
+ onClick: handleCaptureScreenshot,
1038
+ style: {
1039
+ display: "flex",
1040
+ alignItems: "center",
1041
+ gap: "5px",
1042
+ borderRadius: "7px",
1043
+ border: "1px solid #1e293b",
1044
+ background: "#1e293b",
1045
+ color: "#94a3b8",
1046
+ padding: "5px 9px",
1047
+ cursor: "pointer",
1048
+ fontSize: "12px"
1049
+ },
1708
1050
  children: [
1709
- /* @__PURE__ */ jsx(MessageSquare, { size: 15 }),
1710
- "New"
1051
+ /* @__PURE__ */ jsx(CameraIcon, {}),
1052
+ "Capture screen"
1711
1053
  ]
1712
1054
  }
1713
1055
  ),
@@ -1715,311 +1057,186 @@ function FeedbackWidget({
1715
1057
  "button",
1716
1058
  {
1717
1059
  type: "button",
1718
- onClick: () => setView("history"),
1719
- style: {
1720
- ...buttonStyle("secondary", {
1721
- active: view === "history" || view === "detail",
1722
- compact: true
1723
- }),
1724
- flex: 1
1725
- },
1726
- children: [
1727
- /* @__PURE__ */ jsx(History, { size: 15 }),
1728
- "History"
1729
- ]
1730
- }
1731
- )
1732
- ]
1733
- }
1734
- ) : null
1735
- ] }),
1736
- /* @__PURE__ */ jsx(
1737
- "div",
1738
- {
1739
- style: {
1740
- padding: "14px",
1741
- display: "grid",
1742
- gap: "10px",
1743
- flex: 1,
1744
- minHeight: 0,
1745
- overflowY: "auto",
1746
- overflowX: "hidden"
1747
- },
1748
- children: view === "form" ? /* @__PURE__ */ jsxs(Fragment, { children: [
1749
- /* @__PURE__ */ jsxs("div", { style: { ...surfaceCardStyle, padding: "14px" }, children: [
1750
- /* @__PURE__ */ jsxs(
1751
- "div",
1752
- {
1060
+ onClick: () => setCaptureMode((v) => !v),
1753
1061
  style: {
1754
1062
  display: "flex",
1755
- alignItems: "flex-start",
1756
- justifyContent: "space-between",
1757
- gap: "10px",
1758
- flexWrap: "wrap",
1759
- marginBottom: "10px"
1063
+ alignItems: "center",
1064
+ gap: "5px",
1065
+ borderRadius: "7px",
1066
+ border: captureMode ? "1px solid #4ade80" : "1px solid #1e293b",
1067
+ background: captureMode ? "rgba(74,222,128,0.08)" : "#1e293b",
1068
+ color: captureMode ? "#4ade80" : "#94a3b8",
1069
+ padding: "5px 9px",
1070
+ cursor: "pointer",
1071
+ fontSize: "12px"
1760
1072
  },
1761
1073
  children: [
1762
- /* @__PURE__ */ jsxs("div", { children: [
1763
- /* @__PURE__ */ jsx("p", { style: sectionLabelStyle, children: "New report" }),
1764
- /* @__PURE__ */ jsx("p", { style: { margin: "4px 0 0", fontSize: "13px", lineHeight: 1.5, color: theme.textSoft }, children: "Describe the issue, attach context, and send it with the current page path." })
1765
- ] }),
1766
- /* @__PURE__ */ jsxs("span", { style: { ...pillStyle("neutral"), maxWidth: "100%", overflow: "hidden" }, children: [
1767
- /* @__PURE__ */ jsx(MapPin, { size: 12 }),
1768
- /* @__PURE__ */ jsx(
1769
- "span",
1770
- {
1771
- style: {
1772
- overflow: "hidden",
1773
- textOverflow: "ellipsis",
1774
- whiteSpace: "nowrap",
1775
- display: "inline-block"
1776
- },
1777
- children: currentPath
1778
- }
1779
- )
1780
- ] })
1074
+ /* @__PURE__ */ jsx(CursorIcon, {}),
1075
+ captureMode ? "Click an element\u2026" : "Capture element"
1781
1076
  ]
1782
1077
  }
1783
1078
  ),
1784
- /* @__PURE__ */ jsx(
1785
- "textarea",
1786
- {
1787
- value: message,
1788
- onChange: (event) => setMessage(event.target.value),
1789
- rows: 5,
1790
- placeholder: "Describe the issue, the expected behavior, and what you were doing...",
1791
- style: { ...fieldStyle, resize: "vertical", minHeight: "116px" }
1792
- }
1793
- )
1794
- ] }),
1795
- /* @__PURE__ */ jsxs("div", { style: { ...surfaceCardStyle, padding: "14px" }, children: [
1796
- /* @__PURE__ */ jsxs("div", { style: { marginBottom: "10px" }, children: [
1797
- /* @__PURE__ */ jsx("p", { style: sectionLabelStyle, children: "Context and attachments" }),
1798
- /* @__PURE__ */ jsx("p", { style: { ...metaTextStyle, marginTop: "4px" }, children: "Paste an image with Ctrl/Cmd+V or attach a screenshot from the current tab." })
1799
- ] }),
1800
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "8px", flexWrap: "wrap" }, children: [
1801
- canManageScreenshots ? /* @__PURE__ */ jsx(
1802
- "button",
1803
- {
1804
- type: "button",
1805
- onClick: handleCaptureScreenshot,
1806
- "aria-label": "Capture screen",
1807
- title: "Capture screen",
1808
- style: buttonStyle("secondary", { compact: true, iconOnly: true }),
1809
- children: /* @__PURE__ */ jsx(Camera, { size: 15 })
1810
- }
1811
- ) : null,
1812
- /* @__PURE__ */ jsx(
1813
- "button",
1814
- {
1815
- type: "button",
1816
- onClick: () => setCaptureMode((value) => !value),
1817
- "aria-label": captureMode ? "Capture element: click target" : "Capture element",
1818
- title: captureMode ? "Capture element: click target" : "Capture element",
1819
- style: buttonStyle("secondary", { compact: true, active: captureMode, iconOnly: true }),
1820
- children: /* @__PURE__ */ jsx(MousePointerClick, { size: 15 })
1821
- }
1822
- ),
1823
- canManageScreenshots ? /* @__PURE__ */ jsxs(
1824
- "label",
1825
- {
1826
- "aria-label": uploading ? "Uploading image" : uploadLabel,
1827
- title: uploading ? "Uploading image" : uploadLabel,
1828
- style: buttonStyle("secondary", { compact: true, iconOnly: true }),
1829
- children: [
1830
- /* @__PURE__ */ jsx(Upload, { size: 15 }),
1831
- /* @__PURE__ */ jsx(
1832
- "input",
1833
- {
1834
- type: "file",
1835
- accept: screenshotAllowedMimeTypes.join(","),
1836
- onChange: handleUpload,
1837
- hidden: true
1838
- }
1839
- )
1840
- ]
1841
- }
1842
- ) : null
1843
- ] })
1844
- ] }),
1845
- captureMode || captureData ? /* @__PURE__ */ jsxs(
1846
- "div",
1847
- {
1848
- style: {
1849
- ...surfaceCardStyle,
1850
- padding: "12px 14px",
1851
- borderColor: captureMode ? "rgba(94, 234, 212, 0.3)" : theme.border
1852
- },
1853
- children: [
1854
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px", flexWrap: "wrap" }, children: [
1855
- /* @__PURE__ */ jsxs("span", { style: pillStyle(captureMode ? "success" : "neutral"), title: captureData?.selector || void 0, children: [
1856
- /* @__PURE__ */ jsx(MousePointerClick, { size: 12 }),
1857
- captureMode ? "Element capture active" : "Element captured"
1858
- ] }),
1859
- captureData?.selectedText ? /* @__PURE__ */ jsxs("span", { style: pillStyle("neutral"), title: captureData.selectedText, children: [
1860
- /* @__PURE__ */ jsx(MessageSquare, { size: 12 }),
1861
- "Text preview"
1862
- ] }) : null
1863
- ] }),
1864
- !captureData ? /* @__PURE__ */ jsx("p", { style: { ...metaTextStyle, marginTop: "8px" }, children: "Click any visible element to attach its selector." }) : null
1865
- ]
1866
- }
1867
- ) : null,
1868
- screenshotId ? /* @__PURE__ */ jsxs("div", { style: { ...surfaceCardStyle, padding: "10px" }, children: [
1869
1079
  /* @__PURE__ */ jsxs(
1870
- "div",
1080
+ "label",
1871
1081
  {
1872
1082
  style: {
1873
1083
  display: "flex",
1874
1084
  alignItems: "center",
1875
- justifyContent: "space-between",
1876
- gap: "10px",
1877
- marginBottom: screenshotPreviewUrl ? "10px" : 0
1085
+ gap: "5px",
1086
+ borderRadius: "7px",
1087
+ border: "1px solid #1e293b",
1088
+ background: "#1e293b",
1089
+ color: "#94a3b8",
1090
+ padding: "5px 9px",
1091
+ cursor: "pointer",
1092
+ fontSize: "12px"
1878
1093
  },
1879
1094
  children: [
1880
- /* @__PURE__ */ jsxs("span", { style: pillStyle("neutral"), children: [
1881
- /* @__PURE__ */ jsx(ImageIcon, { size: 12 }),
1882
- "Media #",
1883
- screenshotId
1884
- ] }),
1885
- /* @__PURE__ */ jsxs(
1886
- "button",
1095
+ /* @__PURE__ */ jsx(UploadIcon, {}),
1096
+ uploading ? "Uploading\u2026" : uploadLabel,
1097
+ /* @__PURE__ */ jsx(
1098
+ "input",
1887
1099
  {
1888
- type: "button",
1889
- onClick: handleRemoveScreenshot,
1890
- disabled: deletingScreenshot,
1891
- style: buttonStyle("danger", { compact: true, disabled: deletingScreenshot }),
1892
- children: [
1893
- /* @__PURE__ */ jsx(Trash2, { size: 15 }),
1894
- deletingScreenshot ? "Removing..." : "Remove"
1895
- ]
1100
+ type: "file",
1101
+ accept: screenshotAllowedMimeTypes.join(","),
1102
+ onChange: handleUpload,
1103
+ hidden: true
1896
1104
  }
1897
1105
  )
1898
- ]
1899
- }
1900
- ),
1901
- screenshotPreviewUrl ? /* @__PURE__ */ jsx("div", { style: { ...innerCardStyle, overflow: "hidden" }, children: /* @__PURE__ */ jsx(
1902
- "img",
1903
- {
1904
- src: screenshotPreviewUrl,
1905
- alt: "Annotated screenshot preview",
1906
- style: { width: "100%", height: "auto", display: "block", maxHeight: "180px", objectFit: "cover" }
1907
- }
1908
- ) }) : null
1909
- ] }) : null,
1910
- notice ? /* @__PURE__ */ jsx("div", { style: { ...surfaceCardStyle, padding: "12px 14px", borderColor: "rgba(94, 234, 212, 0.28)" }, children: /* @__PURE__ */ jsxs("p", { style: { ...metaTextStyle, color: "#ccfbf1" }, children: [
1911
- /* @__PURE__ */ jsx(CheckCircle2, { size: 14, style: { verticalAlign: "text-bottom", marginRight: "6px" } }),
1912
- notice
1913
- ] }) }) : null,
1914
- error ? /* @__PURE__ */ jsx("div", { style: { ...surfaceCardStyle, padding: "12px 14px", borderColor: "rgba(248, 113, 113, 0.24)" }, children: /* @__PURE__ */ jsx("p", { style: { ...metaTextStyle, color: "#fecaca" }, children: error }) }) : null
1915
- ] }) : view === "history" && history ? /* @__PURE__ */ jsx(
1916
- FeedbackHistory,
1917
- {
1918
- feedbacks: history.feedbacks,
1919
- totalPages: history.totalPages,
1920
- currentPage: history.currentPage,
1921
- loading: history.loading,
1922
- error: history.error,
1923
- currentUserId: currentUserId ?? null,
1924
- onSelectFeedback: (id) => handleSelectFeedback(id),
1925
- onPageChange: history.onPageChange,
1926
- onRefetch: history.refetch
1927
- }
1928
- ) : view === "detail" && selectedFeedback && onUpload && onDeleteScreenshot ? /* @__PURE__ */ jsx(
1929
- FeedbackDetail,
1930
- {
1931
- feedback: selectedFeedback,
1932
- currentUserId: currentUserId ?? null,
1933
- capturePolicy,
1934
- onBack: () => setView("history"),
1935
- onUpdate: async (id, data) => {
1936
- if (!onUpdateFeedback) return false;
1937
- const result = await onUpdateFeedback(id, data);
1938
- if (result && history) {
1939
- history.refetch();
1940
- setSelectedFeedback((prev) => {
1941
- if (!prev) return prev;
1942
- return {
1943
- ...prev,
1944
- message: data.message ?? prev.message,
1945
- screenshot: data.screenshotId !== void 0 ? data.screenshotId ? { id: data.screenshotId, url: void 0 } : null : prev.screenshot
1946
- };
1947
- });
1948
- }
1949
- return result;
1950
- },
1951
- onDelete: async (id) => {
1952
- if (!onDeleteFeedback) return false;
1953
- const result = await onDeleteFeedback(id);
1954
- if (result.success) {
1955
- setSelectedFeedback(null);
1956
- setView("history");
1957
- history?.refetch();
1958
- return true;
1106
+ ]
1959
1107
  }
1960
- setError(result.error);
1961
- return false;
1962
- },
1963
- onUpload,
1964
- onDeleteScreenshot
1965
- }
1966
- ) : null
1967
- }
1968
- ),
1969
- view === "form" ? /* @__PURE__ */ jsxs(
1970
- "div",
1971
- {
1972
- style: {
1973
- display: "flex",
1974
- justifyContent: "space-between",
1975
- alignItems: "stretch",
1976
- gap: "8px",
1977
- flexWrap: "wrap",
1978
- flexShrink: 0,
1979
- padding: "12px 14px",
1980
- paddingBottom: "calc(12px + env(safe-area-inset-bottom, 0px))",
1981
- borderTop: `1px solid ${theme.border}`,
1982
- background: "linear-gradient(180deg, rgba(8, 15, 30, 0.94) 0%, rgba(15, 23, 42, 0.96) 100%)"
1983
- },
1984
- children: [
1985
- /* @__PURE__ */ jsxs(
1108
+ )
1109
+ ] }) : /* @__PURE__ */ jsx("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap" }, children: /* @__PURE__ */ jsxs(
1986
1110
  "button",
1987
1111
  {
1988
1112
  type: "button",
1989
- onClick: () => {
1990
- setOpen(false);
1991
- setView("form");
1992
- },
1113
+ onClick: () => setCaptureMode((v) => !v),
1993
1114
  style: {
1994
- ...buttonStyle("ghost", { compact: true }),
1995
- flex: "1 1 132px"
1115
+ display: "flex",
1116
+ alignItems: "center",
1117
+ gap: "5px",
1118
+ borderRadius: "7px",
1119
+ border: captureMode ? "1px solid #4ade80" : "1px solid #1e293b",
1120
+ background: captureMode ? "rgba(74,222,128,0.08)" : "#1e293b",
1121
+ color: captureMode ? "#4ade80" : "#94a3b8",
1122
+ padding: "5px 9px",
1123
+ cursor: "pointer",
1124
+ fontSize: "12px"
1996
1125
  },
1997
1126
  children: [
1998
- /* @__PURE__ */ jsx(X, { size: 15 }),
1999
- "Close"
1127
+ /* @__PURE__ */ jsx(CursorIcon, {}),
1128
+ captureMode ? "Click an element\u2026" : "Capture element"
2000
1129
  ]
2001
1130
  }
2002
- ),
2003
- /* @__PURE__ */ jsxs(
2004
- "button",
1131
+ ) }),
1132
+ allowScreenshotUpload && onUpload ? /* @__PURE__ */ jsx("p", { style: { margin: 0, fontSize: "11px", color: "#475569" }, children: "Paste an image with Ctrl/Cmd+V or capture the current tab first." }) : null,
1133
+ captureData ? /* @__PURE__ */ jsxs("p", { style: { margin: 0, fontSize: "11px", color: "#64748b", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: [
1134
+ "Element: ",
1135
+ /* @__PURE__ */ jsx("code", { style: { color: "#94a3b8" }, children: captureData.selector })
1136
+ ] }) : null,
1137
+ screenshotId ? /* @__PURE__ */ jsxs(
1138
+ "div",
2005
1139
  {
2006
- type: "button",
2007
- onClick: handleSubmit,
2008
- disabled: submitting,
2009
1140
  style: {
2010
- ...buttonStyle("primary", { compact: true, disabled: submitting }),
2011
- flex: "1 1 132px"
1141
+ borderRadius: "10px",
1142
+ border: "1px solid #1e293b",
1143
+ background: "#0a0f1e",
1144
+ padding: "8px"
2012
1145
  },
2013
1146
  children: [
2014
- /* @__PURE__ */ jsx(SendHorizontal, { size: 15 }),
2015
- submitting ? "Sending..." : submitLabel
1147
+ screenshotPreviewUrl ? /* @__PURE__ */ jsx("div", { style: { marginBottom: "8px", borderRadius: "6px", overflow: "hidden" }, children: /* @__PURE__ */ jsx(
1148
+ "img",
1149
+ {
1150
+ src: screenshotPreviewUrl,
1151
+ alt: "Annotated screenshot preview",
1152
+ style: { width: "100%", height: "auto", display: "block" }
1153
+ }
1154
+ ) }) : null,
1155
+ /* @__PURE__ */ jsxs(
1156
+ "div",
1157
+ {
1158
+ style: {
1159
+ display: "flex",
1160
+ justifyContent: "space-between",
1161
+ alignItems: "center"
1162
+ },
1163
+ children: [
1164
+ /* @__PURE__ */ jsx("p", { style: { margin: 0, fontSize: "11px", color: "#64748b" }, children: "Screenshot attached" }),
1165
+ /* @__PURE__ */ jsxs(
1166
+ "button",
1167
+ {
1168
+ type: "button",
1169
+ onClick: handleRemoveScreenshot,
1170
+ disabled: deletingScreenshot,
1171
+ style: {
1172
+ display: "flex",
1173
+ alignItems: "center",
1174
+ gap: "4px",
1175
+ borderRadius: "6px",
1176
+ border: "1px solid #7f1d1d",
1177
+ background: "#450a0a",
1178
+ color: "#fca5a5",
1179
+ padding: "3px 8px",
1180
+ cursor: deletingScreenshot ? "wait" : "pointer",
1181
+ opacity: deletingScreenshot ? 0.7 : 1,
1182
+ fontSize: "11px"
1183
+ },
1184
+ children: [
1185
+ /* @__PURE__ */ jsx(TrashIcon, {}),
1186
+ deletingScreenshot ? "Removing\u2026" : "Remove"
1187
+ ]
1188
+ }
1189
+ )
1190
+ ]
1191
+ }
1192
+ )
2016
1193
  ]
2017
1194
  }
2018
- )
2019
- ]
2020
- }
2021
- ) : null
2022
- ] }) : null,
1195
+ ) : null,
1196
+ notice ? /* @__PURE__ */ jsx("p", { style: { margin: 0, color: "#93c5fd", fontSize: "12px" }, children: notice }) : null,
1197
+ error ? /* @__PURE__ */ jsx("p", { style: { margin: 0, color: "#fca5a5", fontSize: "12px" }, children: error }) : null
1198
+ ] }),
1199
+ /* @__PURE__ */ jsx(
1200
+ "div",
1201
+ {
1202
+ style: {
1203
+ display: "flex",
1204
+ justifyContent: "flex-end",
1205
+ padding: "10px 14px 14px",
1206
+ borderTop: "1px solid #1e293b"
1207
+ },
1208
+ children: /* @__PURE__ */ jsxs(
1209
+ "button",
1210
+ {
1211
+ type: "button",
1212
+ onClick: handleSubmit,
1213
+ disabled: submitting,
1214
+ style: {
1215
+ display: "flex",
1216
+ alignItems: "center",
1217
+ gap: "7px",
1218
+ borderRadius: "8px",
1219
+ border: "none",
1220
+ background: "#15803d",
1221
+ color: "#f1f5f9",
1222
+ padding: "8px 16px",
1223
+ cursor: submitting ? "wait" : "pointer",
1224
+ fontWeight: 600,
1225
+ fontSize: "13px",
1226
+ opacity: submitting ? 0.75 : 1,
1227
+ transition: "opacity 0.15s ease"
1228
+ },
1229
+ children: [
1230
+ /* @__PURE__ */ jsx(SendIcon, {}),
1231
+ submitting ? "Sending\u2026" : submitLabel
1232
+ ]
1233
+ }
1234
+ )
1235
+ }
1236
+ )
1237
+ ] })
1238
+ }
1239
+ ),
2023
1240
  annotating && editorImage ? /* @__PURE__ */ jsxs(
2024
1241
  "div",
2025
1242
  {
@@ -2027,8 +1244,8 @@ function FeedbackWidget({
2027
1244
  position: "fixed",
2028
1245
  inset: "0",
2029
1246
  zIndex: 1e4,
2030
- background: "rgba(2, 8, 23, 0.96)",
2031
- color: theme.text,
1247
+ background: "rgba(3, 7, 18, 0.96)",
1248
+ color: "#f8fafc",
2032
1249
  display: "flex",
2033
1250
  flexDirection: "column"
2034
1251
  },
@@ -2039,42 +1256,24 @@ function FeedbackWidget({
2039
1256
  style: {
2040
1257
  display: "flex",
2041
1258
  flexWrap: "wrap",
2042
- gap: "12px",
2043
- alignItems: "flex-start",
1259
+ gap: "10px",
1260
+ alignItems: "center",
2044
1261
  justifyContent: "space-between",
2045
- padding: "16px 18px",
2046
- borderBottom: `1px solid ${theme.border}`,
2047
- background: "linear-gradient(180deg, rgba(15, 23, 42, 0.96) 0%, rgba(8, 15, 30, 0.94) 100%)"
1262
+ padding: "10px 16px",
1263
+ borderBottom: "1px solid rgba(148, 163, 184, 0.15)",
1264
+ background: "rgba(15, 23, 42, 0.97)"
2048
1265
  },
2049
1266
  children: [
2050
- /* @__PURE__ */ jsxs("div", { style: { display: "grid", gap: "12px", flex: 1, minWidth: 0 }, children: [
2051
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "10px", flexWrap: "wrap" }, children: [
2052
- /* @__PURE__ */ jsxs("span", { style: pillStyle("success"), children: [
2053
- /* @__PURE__ */ jsx(Sparkles, { size: 12 }),
2054
- "Annotate screenshot"
2055
- ] }),
2056
- /* @__PURE__ */ jsx("span", { style: pillStyle("neutral"), children: editorImage.fileName })
2057
- ] }),
2058
- /* @__PURE__ */ jsx("div", { style: { display: "flex", gap: "8px", flexWrap: "wrap" }, children: annotationTools.map(({ tool, label, icon: Icon }) => /* @__PURE__ */ jsxs(
2059
- "button",
2060
- {
2061
- type: "button",
2062
- onClick: () => setAnnotationTool(tool),
2063
- "aria-label": label,
2064
- style: buttonStyle("secondary", {
2065
- compact: true,
2066
- active: annotationTool === tool
2067
- }),
2068
- children: [
2069
- /* @__PURE__ */ jsx(Icon, { size: 15 }),
2070
- label
2071
- ]
2072
- },
2073
- tool
2074
- )) })
1267
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "12px" }, children: [
1268
+ /* @__PURE__ */ jsx("strong", { style: { fontSize: "14px", color: "#f1f5f9" }, children: "Annotate screenshot" }),
1269
+ /* @__PURE__ */ jsx("span", { style: { fontSize: "11px", color: "#475569" }, children: editorImage.fileName })
2075
1270
  ] }),
2076
- /* @__PURE__ */ jsxs("div", { style: { display: "grid", gap: "10px", justifyItems: "start" }, children: [
2077
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "6px", alignItems: "center", flexWrap: "wrap" }, children: [
1271
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexWrap: "wrap", gap: "6px", alignItems: "center" }, children: [
1272
+ toolBtn("pen", /* @__PURE__ */ jsx(PenIcon, {}), "Pen"),
1273
+ toolBtn("rectangle", /* @__PURE__ */ jsx(RectIcon, {}), "Rect"),
1274
+ toolBtn("arrow", /* @__PURE__ */ jsx(ArrowIcon, {}), "Arrow"),
1275
+ toolBtn("text", /* @__PURE__ */ jsx(TextIcon, {}), "Text"),
1276
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "4px", alignItems: "center" }, children: [
2078
1277
  DEFAULT_COLORS.map((color) => /* @__PURE__ */ jsx(
2079
1278
  "button",
2080
1279
  {
@@ -2082,12 +1281,13 @@ function FeedbackWidget({
2082
1281
  onClick: () => setAnnotationColor(color),
2083
1282
  "aria-label": `Select ${color} color`,
2084
1283
  style: {
2085
- width: "28px",
2086
- height: "28px",
2087
- borderRadius: "999px",
2088
- border: annotationColor === color ? "2px solid #f8fafc" : `1px solid ${theme.borderStrong}`,
1284
+ width: "20px",
1285
+ height: "20px",
1286
+ borderRadius: "50%",
1287
+ border: annotationColor === color ? "2px solid #f8fafc" : "1px solid #334155",
2089
1288
  background: color,
2090
- cursor: "pointer"
1289
+ cursor: "pointer",
1290
+ flexShrink: 0
2091
1291
  }
2092
1292
  },
2093
1293
  color
@@ -2097,15 +1297,15 @@ function FeedbackWidget({
2097
1297
  {
2098
1298
  type: "color",
2099
1299
  value: annotationColor,
2100
- onChange: (event) => setAnnotationColor(event.target.value),
2101
- "aria-label": "Annotation color",
2102
- style: { width: "36px", height: "36px", border: "none", background: "transparent" }
1300
+ onChange: (e) => setAnnotationColor(e.target.value),
1301
+ "aria-label": "Custom color",
1302
+ title: "Custom color",
1303
+ style: { width: "28px", height: "28px", border: "none", background: "transparent", cursor: "pointer" }
2103
1304
  }
2104
1305
  )
2105
1306
  ] }),
2106
- /* @__PURE__ */ jsxs("label", { style: { display: "flex", alignItems: "center", gap: "10px", fontSize: "12px", color: theme.textSoft }, children: [
2107
- "Size ",
2108
- annotationSize,
1307
+ /* @__PURE__ */ jsxs("label", { style: { display: "flex", alignItems: "center", gap: "6px", fontSize: "11px", color: "#64748b" }, children: [
1308
+ "Size",
2109
1309
  /* @__PURE__ */ jsx(
2110
1310
  "input",
2111
1311
  {
@@ -2113,115 +1313,97 @@ function FeedbackWidget({
2113
1313
  min: 1,
2114
1314
  max: 18,
2115
1315
  value: annotationSize,
2116
- onChange: (event) => setAnnotationSize(Number(event.target.value)),
2117
- "aria-label": "Annotation size"
1316
+ onChange: (e) => setAnnotationSize(Number(e.target.value)),
1317
+ "aria-label": "Stroke size",
1318
+ style: { width: "72px" }
2118
1319
  }
2119
1320
  )
2120
1321
  ] }),
2121
- annotationTool === "text" ? /* @__PURE__ */ jsx(
2122
- "input",
2123
- {
2124
- type: "text",
2125
- value: annotationText,
2126
- onChange: (event) => setAnnotationText(event.target.value),
2127
- placeholder: "Text to place",
2128
- "aria-label": "Annotation text",
2129
- style: {
2130
- ...fieldStyle,
2131
- minWidth: "220px",
2132
- padding: "10px 12px"
2133
- }
2134
- }
2135
- ) : null,
2136
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "8px", flexWrap: "wrap" }, children: [
2137
- /* @__PURE__ */ jsxs(
2138
- "button",
2139
- {
2140
- type: "button",
2141
- onClick: handleUndo,
2142
- disabled: !currentHasUndo,
2143
- style: buttonStyle("secondary", { compact: true, disabled: !currentHasUndo }),
2144
- children: [
2145
- /* @__PURE__ */ jsx(Undo2, { size: 15 }),
2146
- "Undo"
2147
- ]
2148
- }
2149
- ),
2150
- /* @__PURE__ */ jsxs(
2151
- "button",
2152
- {
2153
- type: "button",
2154
- onClick: handleRedo,
2155
- disabled: !currentHasRedo,
2156
- style: buttonStyle("secondary", { compact: true, disabled: !currentHasRedo }),
2157
- children: [
2158
- /* @__PURE__ */ jsx(Redo2, { size: 15 }),
2159
- "Redo"
2160
- ]
2161
- }
2162
- ),
2163
- /* @__PURE__ */ jsxs(
2164
- "button",
2165
- {
2166
- type: "button",
2167
- onClick: handleClearAnnotations,
2168
- disabled: !hasAnnotations,
2169
- style: buttonStyle("secondary", { compact: true, disabled: !hasAnnotations }),
2170
- children: [
2171
- /* @__PURE__ */ jsx(Eraser, { size: 15 }),
2172
- "Clear"
2173
- ]
2174
- }
2175
- ),
2176
- /* @__PURE__ */ jsxs(
2177
- "button",
2178
- {
2179
- type: "button",
2180
- onClick: handleRevertLastAnnotation,
2181
- disabled: !hasAnnotations,
2182
- style: buttonStyle("secondary", { compact: true, disabled: !hasAnnotations }),
2183
- children: [
2184
- /* @__PURE__ */ jsx(RotateCcw, { size: 15 }),
2185
- "Revert last"
2186
- ]
2187
- }
2188
- )
2189
- ] })
1322
+ iconBtn(handleUndo, /* @__PURE__ */ jsx(UndoIcon, {}), "Undo", !currentHasUndo),
1323
+ iconBtn(handleRedo, /* @__PURE__ */ jsx(RedoIcon, {}), "Redo", !currentHasRedo),
1324
+ iconBtn(handleClearAnnotations, /* @__PURE__ */ jsx(TrashIcon, {}), "Clear", !hasAnnotations)
2190
1325
  ] })
2191
1326
  ]
2192
1327
  }
2193
1328
  ),
2194
- /* @__PURE__ */ jsx(
1329
+ /* @__PURE__ */ jsxs(
2195
1330
  "div",
2196
1331
  {
1332
+ ref: annotationScrollRef,
2197
1333
  style: {
2198
1334
  flex: 1,
2199
1335
  overflow: "auto",
2200
- padding: "18px",
1336
+ padding: "16px",
2201
1337
  display: "flex",
2202
- alignItems: "center",
2203
- justifyContent: "center"
1338
+ alignItems: "flex-start",
1339
+ justifyContent: "center",
1340
+ position: "relative"
2204
1341
  },
2205
- children: /* @__PURE__ */ jsx(
2206
- "canvas",
2207
- {
2208
- ref: annotationCanvasRef,
2209
- onPointerDown: handleCanvasPointerDown,
2210
- onPointerMove: handleCanvasPointerMove,
2211
- onPointerUp: handleCanvasPointerUp,
2212
- onPointerCancel: handleCanvasPointerCancel,
2213
- style: {
2214
- width: "min(100%, 1400px)",
2215
- height: "auto",
2216
- display: "block",
2217
- borderRadius: "22px",
2218
- background: "#ffffff",
2219
- boxShadow: "0 34px 90px rgba(2, 8, 23, 0.5)",
2220
- touchAction: "none",
2221
- cursor: annotationTool === "text" ? "copy" : "crosshair"
1342
+ children: [
1343
+ /* @__PURE__ */ jsx(
1344
+ "canvas",
1345
+ {
1346
+ ref: annotationCanvasRef,
1347
+ onPointerDown: handleCanvasPointerDown,
1348
+ onPointerMove: handleCanvasPointerMove,
1349
+ onPointerUp: handleCanvasPointerUp,
1350
+ onPointerCancel: handleCanvasPointerCancel,
1351
+ style: {
1352
+ width: "min(100%, 1400px)",
1353
+ height: "auto",
1354
+ display: "block",
1355
+ borderRadius: "12px",
1356
+ background: "#ffffff",
1357
+ boxShadow: "0 24px 80px rgba(15, 23, 42, 0.6)",
1358
+ touchAction: "none",
1359
+ cursor: annotationTool === "text" ? "text" : "crosshair"
1360
+ }
2222
1361
  }
2223
- }
2224
- )
1362
+ ),
1363
+ textCursor ? /* @__PURE__ */ jsx(
1364
+ "input",
1365
+ {
1366
+ autoFocus: true,
1367
+ ref: textInputRef,
1368
+ type: "text",
1369
+ value: inlineText,
1370
+ onChange: (e) => {
1371
+ inlineTextRef.current = e.target.value;
1372
+ setInlineText(e.target.value);
1373
+ },
1374
+ onKeyDown: (e) => {
1375
+ if (e.key === "Enter") {
1376
+ e.preventDefault();
1377
+ commitTextInput();
1378
+ }
1379
+ if (e.key === "Escape") {
1380
+ textCursorRef.current = null;
1381
+ setTextCursor(null);
1382
+ setInlineText("");
1383
+ inlineTextRef.current = "";
1384
+ }
1385
+ },
1386
+ placeholder: "Type \u2192 Enter to place",
1387
+ style: {
1388
+ position: "fixed",
1389
+ left: textCursor.domX,
1390
+ top: textCursor.domY,
1391
+ minWidth: "180px",
1392
+ background: "rgba(15, 23, 42, 0.92)",
1393
+ color: annotationColor,
1394
+ border: "1px dashed rgba(255,255,255,0.6)",
1395
+ borderRadius: "4px",
1396
+ padding: "4px 8px",
1397
+ fontSize: `${Math.max(14, annotationSize * 4)}px`,
1398
+ fontWeight: 600,
1399
+ outline: "none",
1400
+ zIndex: 10002,
1401
+ backdropFilter: "blur(6px)",
1402
+ boxShadow: "0 2px 12px rgba(0,0,0,0.4)"
1403
+ }
1404
+ }
1405
+ ) : null
1406
+ ]
2225
1407
  }
2226
1408
  ),
2227
1409
  /* @__PURE__ */ jsxs(
@@ -2233,27 +1415,53 @@ function FeedbackWidget({
2233
1415
  alignItems: "center",
2234
1416
  gap: "12px",
2235
1417
  flexWrap: "wrap",
2236
- padding: "16px 18px",
2237
- borderTop: `1px solid ${theme.border}`,
2238
- background: "linear-gradient(180deg, rgba(8, 15, 30, 0.94) 0%, rgba(15, 23, 42, 0.96) 100%)"
1418
+ padding: "10px 16px",
1419
+ borderTop: "1px solid rgba(148, 163, 184, 0.15)",
1420
+ background: "rgba(15, 23, 42, 0.97)"
2239
1421
  },
2240
1422
  children: [
2241
- /* @__PURE__ */ jsx("p", { style: { ...metaTextStyle, maxWidth: "720px" }, children: "Use mouse, touch, or pen input. Text is placed where you click on the image." }),
2242
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "8px", flexWrap: "wrap" }, children: [
2243
- /* @__PURE__ */ jsxs("button", { type: "button", onClick: closeAnnotationEditor, style: buttonStyle("ghost"), children: [
2244
- /* @__PURE__ */ jsx(X, { size: 15 }),
2245
- "Cancel"
2246
- ] }),
1423
+ annotationTool === "text" ? /* @__PURE__ */ jsx("p", { style: { margin: 0, fontSize: "12px", color: "#64748b" }, children: "Click on the image to place text at that position." }) : /* @__PURE__ */ jsx("p", { style: { margin: 0, fontSize: "12px", color: "#64748b" }, children: "Draw on the image, then save when done." }),
1424
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "8px" }, children: [
1425
+ /* @__PURE__ */ jsx(
1426
+ "button",
1427
+ {
1428
+ type: "button",
1429
+ onClick: closeAnnotationEditor,
1430
+ style: {
1431
+ borderRadius: "8px",
1432
+ border: "1px solid #334155",
1433
+ background: "#0f172a",
1434
+ color: "#94a3b8",
1435
+ padding: "7px 14px",
1436
+ cursor: "pointer",
1437
+ fontSize: "13px"
1438
+ },
1439
+ children: "Cancel"
1440
+ }
1441
+ ),
2247
1442
  /* @__PURE__ */ jsxs(
2248
1443
  "button",
2249
1444
  {
2250
1445
  type: "button",
2251
1446
  onClick: handleApplyAnnotation,
2252
1447
  disabled: uploading,
2253
- style: buttonStyle("primary", { disabled: uploading }),
1448
+ style: {
1449
+ display: "flex",
1450
+ alignItems: "center",
1451
+ gap: "6px",
1452
+ borderRadius: "8px",
1453
+ border: "none",
1454
+ background: "#15803d",
1455
+ color: "#f1f5f9",
1456
+ padding: "7px 14px",
1457
+ cursor: uploading ? "wait" : "pointer",
1458
+ opacity: uploading ? 0.8 : 1,
1459
+ fontWeight: 600,
1460
+ fontSize: "13px"
1461
+ },
2254
1462
  children: [
2255
- /* @__PURE__ */ jsx(Upload, { size: 15 }),
2256
- uploading ? "Uploading..." : "Save screenshot"
1463
+ /* @__PURE__ */ jsx(SendIcon, {}),
1464
+ uploading ? "Uploading\u2026" : "Save screenshot"
2257
1465
  ]
2258
1466
  }
2259
1467
  )
@@ -2266,127 +1474,7 @@ function FeedbackWidget({
2266
1474
  ) : null
2267
1475
  ] });
2268
1476
  }
2269
- function useFeedbackQuery(params) {
2270
- const { pagePath, page = 1, limit = 20 } = params;
2271
- const [feedbacks, setFeedbacks] = React2.useState([]);
2272
- const [totalPages, setTotalPages] = React2.useState(0);
2273
- const [loading, setLoading] = React2.useState(true);
2274
- const [error, setError] = React2.useState(null);
2275
- const [fetchKey, setFetchKey] = React2.useState(0);
2276
- const refetch = React2.useCallback(() => {
2277
- setFetchKey((key) => key + 1);
2278
- }, []);
2279
- React2.useEffect(() => {
2280
- let cancelled = false;
2281
- const fetchFeedbacks = async () => {
2282
- setLoading(true);
2283
- setError(null);
2284
- try {
2285
- const url = new URL("/api/admin-feedback", window.location.origin);
2286
- url.searchParams.set("depth", "2");
2287
- url.searchParams.set("sort", "-createdAt");
2288
- url.searchParams.set("limit", String(limit));
2289
- url.searchParams.set("page", String(page));
2290
- if (pagePath) {
2291
- url.searchParams.set("where[pagePath][equals]", pagePath);
2292
- }
2293
- const response = await fetch(url.toString(), {
2294
- credentials: "include"
2295
- });
2296
- if (!response.ok) {
2297
- if (response.status === 401 || response.status === 403) {
2298
- if (!cancelled) {
2299
- setFeedbacks([]);
2300
- setTotalPages(0);
2301
- setLoading(false);
2302
- }
2303
- return;
2304
- }
2305
- throw new Error(`Failed to fetch feedback (${response.status})`);
2306
- }
2307
- const data = await response.json();
2308
- if (!cancelled) {
2309
- setFeedbacks(data.docs);
2310
- setTotalPages(data.totalPages);
2311
- setLoading(false);
2312
- }
2313
- } catch (err) {
2314
- if (!cancelled) {
2315
- setError(err instanceof Error ? err.message : "Failed to load feedback.");
2316
- setLoading(false);
2317
- }
2318
- }
2319
- };
2320
- fetchFeedbacks();
2321
- return () => {
2322
- cancelled = true;
2323
- };
2324
- }, [pagePath, page, limit, fetchKey]);
2325
- return {
2326
- feedbacks,
2327
- totalPages,
2328
- currentPage: page,
2329
- loading,
2330
- error,
2331
- refetch
2332
- };
2333
- }
2334
- function useCurrentUser() {
2335
- const [userId, setUserId] = React2.useState(null);
2336
- const [loading, setLoading] = React2.useState(true);
2337
- React2.useEffect(() => {
2338
- let cancelled = false;
2339
- const fetchUser = async () => {
2340
- try {
2341
- const response = await fetch("/api/users/me", {
2342
- credentials: "include"
2343
- });
2344
- if (!response.ok) {
2345
- if (!cancelled) {
2346
- setUserId(null);
2347
- setLoading(false);
2348
- }
2349
- return;
2350
- }
2351
- const data = await response.json();
2352
- if (!cancelled) {
2353
- setUserId(data.user?.id ?? data.id ?? null);
2354
- setLoading(false);
2355
- }
2356
- } catch {
2357
- if (!cancelled) {
2358
- setUserId(null);
2359
- setLoading(false);
2360
- }
2361
- }
2362
- };
2363
- fetchUser();
2364
- return () => {
2365
- cancelled = true;
2366
- };
2367
- }, []);
2368
- return { userId, loading };
2369
- }
2370
1477
  function AdminFeedbackWidget() {
2371
- const { userId, loading: userLoading } = useCurrentUser();
2372
- const [page, setPage] = React2.useState(1);
2373
- const query = useFeedbackQuery({ page });
2374
- const handleUpdateFeedback = React2.useCallback(
2375
- async (id, data) => {
2376
- const response = await fetch(`/api/admin-feedback/update/${id}`, {
2377
- method: "PATCH",
2378
- credentials: "include",
2379
- headers: { "content-type": "application/json" },
2380
- body: JSON.stringify(data)
2381
- });
2382
- const result = await response.json();
2383
- if (!result.success) {
2384
- return false;
2385
- }
2386
- return true;
2387
- },
2388
- []
2389
- );
2390
1478
  return /* @__PURE__ */ jsx(
2391
1479
  FeedbackWidget,
2392
1480
  {
@@ -2394,18 +1482,6 @@ function AdminFeedbackWidget() {
2394
1482
  submitLabel: "Send",
2395
1483
  uploadLabel: "Upload image",
2396
1484
  allowScreenshotUpload: true,
2397
- showHistory: true,
2398
- currentUserId: userLoading ? null : userId,
2399
- onUpdateFeedback: handleUpdateFeedback,
2400
- history: {
2401
- feedbacks: query.feedbacks,
2402
- totalPages: query.totalPages,
2403
- currentPage: query.currentPage,
2404
- loading: query.loading,
2405
- error: query.error,
2406
- refetch: query.refetch,
2407
- onPageChange: setPage
2408
- },
2409
1485
  onSubmit: async (payload) => {
2410
1486
  const response = await fetch("/api/admin-feedback/submit", {
2411
1487
  method: "POST",
@@ -2417,19 +1493,6 @@ function AdminFeedbackWidget() {
2417
1493
  if (!result.success) {
2418
1494
  return { success: false, error: result.error || "Submit failed." };
2419
1495
  }
2420
- query.refetch();
2421
- return { success: true };
2422
- },
2423
- onDeleteFeedback: async (id) => {
2424
- const response = await fetch(`/api/admin-feedback/delete/${id}`, {
2425
- method: "DELETE",
2426
- credentials: "include"
2427
- });
2428
- const result = await response.json();
2429
- if (!result.success) {
2430
- return { success: false, error: result.error || "Delete failed." };
2431
- }
2432
- query.refetch();
2433
1496
  return { success: true };
2434
1497
  },
2435
1498
  onUpload: async (formData) => {
@@ -2458,247 +1521,21 @@ function AdminFeedbackWidget() {
2458
1521
  }
2459
1522
  );
2460
1523
  }
2461
- var DOT_SIZE = 14;
2462
- var DOT_OFFSET = 8;
2463
- var STATUS_COLORS = {
2464
- new: "#5eead4",
2465
- triaged: "#facc15",
2466
- resolved: "#cbd5e1"
2467
- };
2468
- var STATUS_LABELS2 = {
2469
- new: "New",
2470
- triaged: "Triaged",
2471
- resolved: "Resolved"
2472
- };
2473
- var formatRelativeTime2 = (iso) => {
2474
- const now = Date.now();
2475
- const diff = now - new Date(iso).getTime();
2476
- const minutes = Math.floor(diff / 6e4);
2477
- if (minutes < 1) return "Just now";
2478
- if (minutes < 60) return `${minutes}m ago`;
2479
- const hours = Math.floor(minutes / 60);
2480
- if (hours < 24) return `${hours}h ago`;
2481
- const days = Math.floor(hours / 24);
2482
- if (days < 7) return `${days}d ago`;
2483
- return new Date(iso).toLocaleDateString();
2484
- };
2485
- function FeedbackIndicators({ pagePath }) {
2486
- const containerRef = React2.useRef(null);
2487
- const dotsRef = React2.useRef(/* @__PURE__ */ new Map());
2488
- const tooltipRef = React2.useRef(null);
2489
- const rafRef = React2.useRef(0);
2490
- const indicatorDataRef = React2.useRef([]);
2491
- const createContainer = React2.useCallback(() => {
2492
- if (containerRef.current) return containerRef.current;
2493
- const element = document.createElement("div");
2494
- element.style.cssText = "position:fixed;inset:0;pointer-events:none;z-index:9998;";
2495
- document.body.appendChild(element);
2496
- containerRef.current = element;
2497
- return element;
2498
- }, []);
2499
- const createTooltip = React2.useCallback(() => {
2500
- if (tooltipRef.current) return tooltipRef.current;
2501
- const element = document.createElement("div");
2502
- element.style.cssText = `
2503
- position:fixed;
2504
- z-index:9999;
2505
- pointer-events:none;
2506
- opacity:0;
2507
- max-width:260px;
2508
- padding:12px 14px;
2509
- border-radius:16px;
2510
- border:1px solid rgba(148, 163, 184, 0.18);
2511
- background:linear-gradient(180deg, rgba(15, 23, 42, 0.96) 0%, rgba(6, 13, 24, 0.96) 100%);
2512
- color:#f8fafc;
2513
- box-shadow:0 18px 40px rgba(2, 8, 23, 0.4);
2514
- backdrop-filter:blur(16px);
2515
- transition:opacity 0.15s ease;
2516
- white-space:normal;
2517
- `;
2518
- document.body.appendChild(element);
2519
- tooltipRef.current = element;
2520
- return element;
2521
- }, []);
2522
- const renderTooltip = React2.useCallback((tooltip, indicator) => {
2523
- tooltip.replaceChildren();
2524
- const message = document.createElement("p");
2525
- message.textContent = indicator.message.length > 80 ? `${indicator.message.slice(0, 80)}...` : indicator.message;
2526
- message.style.cssText = "margin:0 0 8px;font-size:12px;line-height:1.5;word-break:break-word;";
2527
- const metaRow = document.createElement("div");
2528
- metaRow.style.cssText = "display:flex;align-items:center;gap:8px;flex-wrap:wrap;";
2529
- const status = document.createElement("span");
2530
- status.textContent = STATUS_LABELS2[indicator.status] || "New";
2531
- status.style.cssText = `
2532
- display:inline-flex;
2533
- align-items:center;
2534
- border-radius:999px;
2535
- padding:4px 8px;
2536
- font-size:10px;
2537
- font-weight:700;
2538
- background:rgba(148, 163, 184, 0.12);
2539
- color:${STATUS_COLORS[indicator.status] || STATUS_COLORS.new};
2540
- border:1px solid rgba(148, 163, 184, 0.18);
2541
- `;
2542
- const time = document.createElement("span");
2543
- time.textContent = formatRelativeTime2(indicator.createdAt);
2544
- time.style.cssText = "font-size:10px;color:rgba(148, 163, 184, 0.86);";
2545
- metaRow.append(status, time);
2546
- tooltip.append(message, metaRow);
2547
- }, []);
2548
- const positionDot = React2.useCallback((dot, selector) => {
2549
- let target = null;
2550
- try {
2551
- target = document.querySelector(selector);
2552
- } catch {
2553
- dot.style.display = "none";
2554
- return false;
2555
- }
2556
- if (!(target instanceof HTMLElement)) {
2557
- dot.style.display = "none";
2558
- return false;
2559
- }
2560
- const rect = target.getBoundingClientRect();
2561
- if (rect.width > window.innerWidth * 0.9 || rect.height > window.innerHeight * 0.9) {
2562
- dot.style.display = "none";
2563
- return false;
1524
+
1525
+ // src/tenant/extractTenantSlug.ts
1526
+ var extractTenantSlugFromPathname = (pathname, pathMarkers) => {
1527
+ if (pathMarkers.length === 0) {
1528
+ return null;
1529
+ }
1530
+ const segments = pathname.split("?")[0].split("/").filter(Boolean);
1531
+ for (const marker of pathMarkers) {
1532
+ const markerIndex = segments.indexOf(marker);
1533
+ if (markerIndex > 0) {
1534
+ return segments[markerIndex - 1] ?? null;
2564
1535
  }
2565
- dot.style.display = "";
2566
- dot.style.left = `${rect.right + DOT_OFFSET}px`;
2567
- dot.style.top = `${rect.top - DOT_OFFSET - DOT_SIZE / 2}px`;
2568
- return true;
2569
- }, []);
2570
- const repositionAll = React2.useCallback(() => {
2571
- dotsRef.current.forEach((dot, id) => {
2572
- const indicator = indicatorDataRef.current.find((item) => item.id === id);
2573
- if (indicator) {
2574
- positionDot(dot, indicator.selector);
2575
- }
2576
- });
2577
- }, [positionDot]);
2578
- React2.useEffect(() => {
2579
- if (typeof window === "undefined" || typeof document === "undefined") return;
2580
- let cancelled = false;
2581
- const fetchAndRender = async () => {
2582
- try {
2583
- const authCheck = await fetch("/api/admin-feedback?limit=1", {
2584
- credentials: "include"
2585
- });
2586
- if (!authCheck.ok) return;
2587
- } catch {
2588
- return;
2589
- }
2590
- const path = pagePath || window.location.pathname;
2591
- const url = new URL("/api/admin-feedback", window.location.origin);
2592
- url.searchParams.set("where[selector][exists]", "true");
2593
- url.searchParams.set("depth", "2");
2594
- url.searchParams.set("limit", "50");
2595
- url.searchParams.set("sort", "-createdAt");
2596
- try {
2597
- const response = await fetch(url.toString(), { credentials: "include" });
2598
- if (!response.ok) return;
2599
- const data = await response.json();
2600
- if (cancelled) return;
2601
- const indicators = data.docs.filter((item) => item.selector && item.pagePath === path).map((item) => ({
2602
- id: item.id,
2603
- message: item.message,
2604
- status: item.status,
2605
- createdAt: item.createdAt,
2606
- selector: item.selector
2607
- }));
2608
- indicatorDataRef.current = indicators;
2609
- const container = createContainer();
2610
- const tooltip = createTooltip();
2611
- const currentIds = new Set(indicators.map((item) => item.id));
2612
- dotsRef.current.forEach((dot, id) => {
2613
- if (!currentIds.has(id)) {
2614
- dot.remove();
2615
- dotsRef.current.delete(id);
2616
- }
2617
- });
2618
- for (const indicator of indicators) {
2619
- let dot = dotsRef.current.get(indicator.id);
2620
- if (!dot) {
2621
- const element = document.createElement("div");
2622
- element.style.cssText = `
2623
- position:fixed;
2624
- width:${DOT_SIZE}px;
2625
- height:${DOT_SIZE}px;
2626
- border-radius:999px;
2627
- cursor:pointer;
2628
- pointer-events:auto;
2629
- z-index:9999;
2630
- border:2px solid rgba(255,255,255,0.95);
2631
- box-shadow:0 0 0 6px rgba(15, 23, 42, 0.2), 0 10px 22px rgba(2, 8, 23, 0.34);
2632
- transition:transform 0.15s ease, box-shadow 0.15s ease;
2633
- `;
2634
- element.addEventListener("mouseenter", () => {
2635
- element.style.transform = "scale(1.25)";
2636
- element.style.boxShadow = "0 0 0 8px rgba(15, 23, 42, 0.28), 0 14px 28px rgba(2, 8, 23, 0.42)";
2637
- renderTooltip(tooltip, indicator);
2638
- const dotRect = element.getBoundingClientRect();
2639
- tooltip.style.left = `${dotRect.right + 10}px`;
2640
- tooltip.style.top = `${Math.max(12, dotRect.top - 6)}px`;
2641
- tooltip.style.opacity = "1";
2642
- });
2643
- element.addEventListener("mouseleave", () => {
2644
- element.style.transform = "";
2645
- element.style.boxShadow = "0 0 0 6px rgba(15, 23, 42, 0.2), 0 10px 22px rgba(2, 8, 23, 0.34)";
2646
- tooltip.style.opacity = "0";
2647
- });
2648
- element.addEventListener("click", (event) => {
2649
- event.stopPropagation();
2650
- window.dispatchEvent(
2651
- new CustomEvent("feedback:show-detail", {
2652
- detail: { feedbackId: indicator.id }
2653
- })
2654
- );
2655
- });
2656
- container.appendChild(element);
2657
- dotsRef.current.set(indicator.id, element);
2658
- dot = element;
2659
- }
2660
- dot.style.background = STATUS_COLORS[indicator.status] || STATUS_COLORS.new;
2661
- positionDot(dot, indicator.selector);
2662
- }
2663
- } catch {
2664
- }
2665
- };
2666
- const onScroll = () => {
2667
- if (rafRef.current) return;
2668
- rafRef.current = requestAnimationFrame(() => {
2669
- rafRef.current = 0;
2670
- repositionAll();
2671
- });
2672
- };
2673
- fetchAndRender();
2674
- window.addEventListener("scroll", onScroll, { passive: true });
2675
- window.addEventListener("resize", onScroll);
2676
- return () => {
2677
- cancelled = true;
2678
- window.removeEventListener("scroll", onScroll);
2679
- window.removeEventListener("resize", onScroll);
2680
- if (rafRef.current) {
2681
- cancelAnimationFrame(rafRef.current);
2682
- rafRef.current = 0;
2683
- }
2684
- };
2685
- }, [pagePath, createContainer, createTooltip, positionDot, renderTooltip, repositionAll]);
2686
- React2.useEffect(() => {
2687
- return () => {
2688
- dotsRef.current.forEach((dot) => dot.remove());
2689
- dotsRef.current.clear();
2690
- if (containerRef.current) {
2691
- containerRef.current.remove();
2692
- containerRef.current = null;
2693
- }
2694
- if (tooltipRef.current) {
2695
- tooltipRef.current.remove();
2696
- tooltipRef.current = null;
2697
- }
2698
- };
2699
- }, []);
1536
+ }
2700
1537
  return null;
2701
- }
1538
+ };
2702
1539
 
2703
1540
  // src/client/routeMatcher.ts
2704
1541
  var escapeRegex = (input) => input.replace(/[.+^${}()|[\]\\]/g, "\\$&");
@@ -2729,110 +1566,65 @@ function FrontendFeedbackWidget({
2729
1566
  title = "Feedback",
2730
1567
  submitLabel = "Send",
2731
1568
  uploadLabel = "Upload image",
2732
- showIndicators = false,
2733
- showHistory = false
1569
+ tenantPathMarkers = [],
1570
+ tenantFormDataKey = "tenant"
2734
1571
  }) {
2735
1572
  const pathname = usePathname();
2736
1573
  const normalizedPathname = normalizePathname(pathname, locales);
2737
- const { userId, loading: userLoading } = useCurrentUser();
2738
- const [page, setPage] = React2.useState(1);
2739
- const query = useFeedbackQuery({ pagePath: normalizedPathname, page });
2740
- const handleUpdateFeedback = React2.useCallback(
2741
- async (id, data) => {
2742
- const response = await fetch(`/api/admin-feedback/update/${id}`, {
2743
- method: "PATCH",
2744
- credentials: "include",
2745
- headers: { "content-type": "application/json" },
2746
- body: JSON.stringify(data)
2747
- });
2748
- const result = await response.json();
2749
- if (!result.success) {
2750
- return false;
2751
- }
2752
- return true;
2753
- },
2754
- []
2755
- );
2756
1574
  if (!pathMatchesAllowlist(normalizedPathname, include)) {
2757
1575
  return null;
2758
1576
  }
2759
- return /* @__PURE__ */ jsxs(Fragment, { children: [
2760
- showIndicators ? /* @__PURE__ */ jsx(FeedbackIndicators, { pagePath: normalizedPathname }) : null,
2761
- /* @__PURE__ */ jsx(
2762
- FeedbackWidget,
2763
- {
2764
- title,
2765
- submitLabel,
2766
- uploadLabel,
2767
- allowScreenshotUpload: true,
2768
- showHistory,
2769
- currentUserId: userLoading ? null : userId,
2770
- onUpdateFeedback: showHistory ? handleUpdateFeedback : void 0,
2771
- history: showHistory ? {
2772
- feedbacks: query.feedbacks,
2773
- totalPages: query.totalPages,
2774
- currentPage: query.currentPage,
2775
- loading: query.loading,
2776
- error: query.error,
2777
- refetch: query.refetch,
2778
- onPageChange: setPage
2779
- } : void 0,
2780
- onSubmit: async (payload) => {
2781
- const response = await fetch("/api/admin-feedback/submit", {
2782
- method: "POST",
2783
- credentials: "include",
2784
- headers: { "content-type": "application/json" },
2785
- body: JSON.stringify(payload)
2786
- });
2787
- const result = await response.json();
2788
- if (!result.success) {
2789
- return { success: false, error: result.error || "Submit failed." };
2790
- }
2791
- if (showHistory) {
2792
- query.refetch();
2793
- }
2794
- return { success: true };
2795
- },
2796
- onDeleteFeedback: async (id) => {
2797
- const response = await fetch(`/api/admin-feedback/delete/${id}`, {
2798
- method: "DELETE",
2799
- credentials: "include"
2800
- });
2801
- const result = await response.json();
2802
- if (!result.success) {
2803
- return { success: false, error: result.error || "Delete failed." };
2804
- }
2805
- if (showHistory) {
2806
- query.refetch();
2807
- }
2808
- return { success: true };
2809
- },
2810
- onUpload: async (formData) => {
2811
- const response = await fetch("/api/admin-feedback/upload", {
2812
- method: "POST",
2813
- credentials: "include",
2814
- body: formData
2815
- });
2816
- const result = await response.json();
2817
- if (!result.success || typeof result.mediaId !== "number") {
2818
- return { success: false, error: result.error || "Upload failed." };
2819
- }
2820
- return { success: true, mediaId: result.mediaId };
2821
- },
2822
- onDeleteScreenshot: async (mediaId) => {
2823
- const response = await fetch(`/api/admin-feedback/upload/${mediaId}`, {
2824
- method: "DELETE",
2825
- credentials: "include"
2826
- });
2827
- const result = await response.json();
2828
- if (!result.success) {
2829
- return { success: false, error: result.error || "Delete failed." };
1577
+ return /* @__PURE__ */ jsx(
1578
+ FeedbackWidget,
1579
+ {
1580
+ title,
1581
+ submitLabel,
1582
+ uploadLabel,
1583
+ allowScreenshotUpload: true,
1584
+ onSubmit: async (payload) => {
1585
+ const response = await fetch("/api/admin-feedback/submit", {
1586
+ method: "POST",
1587
+ credentials: "include",
1588
+ headers: { "content-type": "application/json" },
1589
+ body: JSON.stringify(payload)
1590
+ });
1591
+ const result = await response.json();
1592
+ if (!result.success) {
1593
+ return { success: false, error: result.error || "Submit failed." };
1594
+ }
1595
+ return { success: true };
1596
+ },
1597
+ onUpload: async (formData) => {
1598
+ if (tenantPathMarkers.length > 0) {
1599
+ const tenantSlug = extractTenantSlugFromPathname(pathname, tenantPathMarkers);
1600
+ if (tenantSlug) {
1601
+ formData.set(tenantFormDataKey, tenantSlug);
2830
1602
  }
2831
- return { success: true };
2832
1603
  }
1604
+ const response = await fetch("/api/admin-feedback/upload", {
1605
+ method: "POST",
1606
+ credentials: "include",
1607
+ body: formData
1608
+ });
1609
+ const result = await response.json();
1610
+ if (!result.success || typeof result.mediaId !== "number") {
1611
+ return { success: false, error: result.error || "Upload failed." };
1612
+ }
1613
+ return { success: true, mediaId: result.mediaId };
1614
+ },
1615
+ onDeleteScreenshot: async (mediaId) => {
1616
+ const response = await fetch(`/api/admin-feedback/upload/${mediaId}`, {
1617
+ method: "DELETE",
1618
+ credentials: "include"
1619
+ });
1620
+ const result = await response.json();
1621
+ if (!result.success) {
1622
+ return { success: false, error: result.error || "Delete failed." };
1623
+ }
1624
+ return { success: true };
2833
1625
  }
2834
- )
2835
- ] });
1626
+ }
1627
+ );
2836
1628
  }
2837
1629
 
2838
- export { AdminFeedbackWidget, FeedbackDetail, FeedbackHistory, FeedbackIndicators, FeedbackWidget, FrontendFeedbackWidget, pathMatchesAllowlist, useCurrentUser, useFeedbackQuery };
1630
+ export { AdminFeedbackWidget, FeedbackWidget, FrontendFeedbackWidget };