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