@qaiddev/thumbs-embed 1.10.1 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/a11y-dialog.d.ts +77 -0
  2. package/dist/a11y.d.ts +6 -65
  3. package/dist/annotate.d.ts +2 -0
  4. package/dist/chunks/annotate-DGyRcgPt.js +2 -0
  5. package/dist/chunks/annotate-DGyRcgPt.js.map +1 -0
  6. package/dist/chunks/core-BsR7oV99.js +26 -0
  7. package/dist/chunks/core-BsR7oV99.js.map +1 -0
  8. package/dist/chunks/dom-scpOS8nl.js +2 -0
  9. package/dist/chunks/{dom-DvdtcUS8.js.map → dom-scpOS8nl.js.map} +1 -1
  10. package/dist/chunks/modal-DYxcs1Gm.js +2 -0
  11. package/dist/chunks/modal-DYxcs1Gm.js.map +1 -0
  12. package/dist/chunks/recording-BUw5-5Rf.js +2 -0
  13. package/dist/chunks/recording-BUw5-5Rf.js.map +1 -0
  14. package/dist/chunks/screenshot-CNe1irEz.js +2 -0
  15. package/dist/chunks/{screenshot-DYOKg2bS.js.map → screenshot-CNe1irEz.js.map} +1 -1
  16. package/dist/chunks/screenshot-dom-ZYP2w2h0.js +2 -0
  17. package/dist/chunks/{screenshot-dom-CME7tYRE.js.map → screenshot-dom-ZYP2w2h0.js.map} +1 -1
  18. package/dist/chunks/send-C26DRoYc.js +2 -0
  19. package/dist/chunks/send-C26DRoYc.js.map +1 -0
  20. package/dist/chunks/targeting-CMUEe-7C.js +6 -0
  21. package/dist/chunks/targeting-CMUEe-7C.js.map +1 -0
  22. package/dist/chunks/video-BSP4s2te.js +2 -0
  23. package/dist/chunks/{video-Bd_29-rK.js.map → video-BSP4s2te.js.map} +1 -1
  24. package/dist/embed.d.ts +35 -34
  25. package/dist/index.js +1515 -1382
  26. package/dist/index.js.map +1 -1
  27. package/dist/loader.d.ts +6 -4
  28. package/dist/loader.js +1 -6
  29. package/dist/loader.js.map +1 -1
  30. package/dist/modal-positioning.d.ts +0 -27
  31. package/dist/modal.d.ts +2 -0
  32. package/dist/qaid.umd.cjs +14 -14
  33. package/dist/qaid.umd.cjs.map +1 -1
  34. package/dist/quest-config.d.ts +2 -0
  35. package/dist/quest-launcher.d.ts +1 -3
  36. package/dist/recording.d.ts +2 -0
  37. package/dist/send.d.ts +60 -0
  38. package/dist/targeting.d.ts +2 -0
  39. package/dist/tooltip-positioning.d.ts +31 -0
  40. package/package.json +1 -1
  41. package/dist/chunks/annotate-BTLeFQa0.js +0 -355
  42. package/dist/chunks/annotate-BTLeFQa0.js.map +0 -1
  43. package/dist/chunks/core-2nGsCcZq.js +0 -1319
  44. package/dist/chunks/core-2nGsCcZq.js.map +0 -1
  45. package/dist/chunks/dom-DvdtcUS8.js +0 -17
  46. package/dist/chunks/modal-zwBhxWO0.js +0 -219
  47. package/dist/chunks/modal-zwBhxWO0.js.map +0 -1
  48. package/dist/chunks/recording-DNngIGr2.js +0 -321
  49. package/dist/chunks/recording-DNngIGr2.js.map +0 -1
  50. package/dist/chunks/screenshot-DYOKg2bS.js +0 -33
  51. package/dist/chunks/screenshot-dom-CME7tYRE.js +0 -63
  52. package/dist/chunks/targeting-DaBmGVk5.js +0 -296
  53. package/dist/chunks/targeting-DaBmGVk5.js.map +0 -1
  54. package/dist/chunks/video-Bd_29-rK.js +0 -214
@@ -0,0 +1,2 @@
1
+ /** Default ES-module URL for the quests widget, pinned to a compatible major on unpkg. */
2
+ export declare const DEFAULT_QUESTS_MODULE_URL = "https://unpkg.com/@qaiddev/quests-embed@1/dist/qaid-quests.js";
@@ -10,8 +10,7 @@
10
10
  * modelled here structurally, so a version bump of the quests package that
11
11
  * keeps this surface stable needs no change in thumbs-embed.
12
12
  */
13
- /** Default ES-module URL, pinned to a compatible major on unpkg. */
14
- export declare const DEFAULT_QUESTS_MODULE_URL = "https://unpkg.com/@qaiddev/quests-embed@1/dist/qaid-quests.js";
13
+ export { DEFAULT_QUESTS_MODULE_URL } from "./quest-config";
15
14
  /** The bit of a QaidQuests instance we hold onto. */
16
15
  export interface QuestInstance {
17
16
  destroy(): void;
@@ -83,4 +82,3 @@ export interface LaunchQuestOptions {
83
82
  * caller should fall back to its normal UI.
84
83
  */
85
84
  export declare function launchQuest(opts: LaunchQuestOptions): Promise<QuestInstance>;
86
- export {};
@@ -78,3 +78,5 @@ export declare class RecordingController {
78
78
  private showSendError;
79
79
  private cleanupRecording;
80
80
  }
81
+ /** This feature's shadow-DOM styles; the embed adds them when it loads the chunk. */
82
+ export declare const styles: string;
package/dist/send.d.ts ADDED
@@ -0,0 +1,60 @@
1
+ /**
2
+ * The feedback send flow — extracted from embed.ts into its own lazily-loaded
3
+ * chunk. It runs only after a thumb click (or a targeted element), so it is
4
+ * pre-warmed when the pointer or focus reaches the buttons, or on idle,
5
+ * whichever comes first.
6
+ *
7
+ * It captures (and lets the visitor mark up) a screenshot when configured,
8
+ * POSTs the feedback, then opens the linked quest or the message box. It talks
9
+ * back to the embed through the narrow `SendHost` interface.
10
+ */
11
+ import { type QuestInstance } from "./quest-launcher";
12
+ import type { ModalController } from "./modal";
13
+ import type { ResolvedFeedbackConfig, EmbedState, FeedbackData, SelectedBounds } from "./types";
14
+ /** The slice of the embed the send flow needs. */
15
+ export interface SendHost {
16
+ readonly config: ResolvedFeedbackConfig;
17
+ readonly visitorId: string;
18
+ /** Live references, filled in by the click or the targeting controller. */
19
+ readonly feedbackData: FeedbackData;
20
+ readonly selectedBounds: SelectedBounds;
21
+ readonly destroyed: boolean;
22
+ readonly overlayShadowHost: HTMLDivElement | null;
23
+ /** A quest launched from a button, so destroy() can tear it down. */
24
+ activeQuest: QuestInstance | null;
25
+ setState(state: EmbedState): void;
26
+ /** Record the pending POST, which the message box's PATCHes wait on. */
27
+ setFeedbackId(id: Promise<number | null>): void;
28
+ shouldCaptureViaDom(): boolean;
29
+ ensureOverlayHost(): ShadowRoot;
30
+ ensureModal(): Promise<ModalController>;
31
+ addFeatureStyles(css: string): void;
32
+ applyVars(el: HTMLElement): void;
33
+ announceMsg(message: string, assertive?: boolean): void;
34
+ openDialogA11y(container: HTMLElement, opts: {
35
+ labelledbyId?: string;
36
+ describedbyId?: string;
37
+ label?: string;
38
+ }): void;
39
+ closeDialogA11y(): void;
40
+ resetFeedbackUi(): void;
41
+ }
42
+ /**
43
+ * Open the full-screen annotation editor over the captured screenshot,
44
+ * reusing the overlay shadow host and the shared dialog a11y helpers.
45
+ * Resolves with the composited WebP data URL, or null when the user skips
46
+ * (caller keeps the original). Pointer events on the overlay host are
47
+ * enabled while the editor is open and restored on close.
48
+ */
49
+ export declare function openAnnotationEditor(host: SendHost, screenshot: string): Promise<string | null>;
50
+ /** Capture, POST, then hand off to a linked quest or the message box. */
51
+ export declare function submitFeedback(host: SendHost): Promise<void>;
52
+ /**
53
+ * Launch the quest linked to `type`, if any. Resolves `true` when a quest
54
+ * was configured and the widget launched; `false` when no quest is
55
+ * configured (quest launching off: no `base`, or this button has no quest)
56
+ * or the widget failed to load (caller falls back to its normal UI). The
57
+ * created feedback record id is passed through so the quest response can be
58
+ * joined back to it server-side.
59
+ */
60
+ export declare function tryLaunchQuest(host: SendHost, type: "up" | "down" | "video", feedbackId: number | string | null | Promise<number | string | null>): Promise<boolean>;
@@ -70,3 +70,5 @@ export declare class TargetingController {
70
70
  /** Full teardown for embed.destroy(). */
71
71
  destroy(): void;
72
72
  }
73
+ /** This feature's shadow-DOM styles; the embed adds them when it loads the chunk. */
74
+ export declare const styles: string;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Tooltip positioning. Kept apart from modal-positioning so the startup chunk
3
+ * carries only this, and the modal maths travels with the modal chunk.
4
+ */
5
+ export interface TooltipPositionOptions {
6
+ /** Gap in pixels between anchor and tooltip, and from viewport edges */
7
+ gap?: number;
8
+ }
9
+ /**
10
+ * Calculate tooltip position relative to an anchor, clamped to the viewport.
11
+ * Pure function: no DOM access — caller passes measured rects and viewport size.
12
+ *
13
+ * Strategy:
14
+ * - Place below the anchor by default
15
+ * - Flip above if below would overflow vertically
16
+ * - Clamp horizontally to viewport, then vertically to viewport
17
+ */
18
+ export declare function calculateTooltipPosition(anchor: {
19
+ top: number;
20
+ bottom: number;
21
+ left: number;
22
+ }, tooltip: {
23
+ width: number;
24
+ height: number;
25
+ }, viewport: {
26
+ width: number;
27
+ height: number;
28
+ }, options?: TooltipPositionOptions): {
29
+ top: number;
30
+ left: number;
31
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qaiddev/thumbs-embed",
3
- "version": "1.10.1",
3
+ "version": "1.12.0",
4
4
  "description": "Precision User Feedback",
5
5
  "type": "module",
6
6
  "main": "./dist/qaid.umd.cjs",
@@ -1,355 +0,0 @@
1
- import { c as r, R as v, A as C, P as y, B as m, U as q, S as k, D as E } from "./core-2nGsCcZq.js";
2
- const h = 12, L = "#ef4444", A = ["#ef4444", "#f59e0b", "#22c55e", "#3b82f6", "#111827", "#ffffff"], T = {
3
- "#ef4444": "red",
4
- "#f59e0b": "amber",
5
- "#22c55e": "green",
6
- "#3b82f6": "blue",
7
- "#111827": "black",
8
- "#ffffff": "white",
9
- // The default marker (nudged from #6366f1 so white text on it clears 4.5:1);
10
- // the old value keeps its name for sites that pass it explicitly.
11
- "#6365f1": "indigo",
12
- "#6366f1": "indigo"
13
- };
14
- function b(n) {
15
- return T[n.toLowerCase()] ?? n;
16
- }
17
- const B = 4, D = 0.8, I = {
18
- title: "Annotate screenshot",
19
- instructions: "Draw on the screenshot to highlight or hide details, then choose Done to attach it or Skip to send the original.",
20
- rectangle: "Rectangle",
21
- arrow: "Arrow",
22
- pen: "Pen",
23
- blur: "Blur or redact",
24
- undo: "Undo last",
25
- skip: "Skip annotation",
26
- done: "Done",
27
- colors: "Drawing colour"
28
- };
29
- function u(n, t) {
30
- return {
31
- x: Math.min(n.x, t.x),
32
- y: Math.min(n.y, t.y),
33
- w: Math.abs(n.x - t.x),
34
- h: Math.abs(n.y - t.y)
35
- };
36
- }
37
- function P(n) {
38
- if (n.type === "pen") return n.points.length < 2;
39
- const t = u(n.points[0], n.points[1]);
40
- return t.w < 3 && t.h < 3;
41
- }
42
- function M(n, t, e, o) {
43
- n.beginPath(), n.moveTo(t.x, t.y), n.lineTo(e.x, e.y), n.stroke();
44
- const i = Math.atan2(e.y - t.y, e.x - t.x), s = Math.max(10, o * 3);
45
- n.beginPath(), n.moveTo(e.x, e.y), n.lineTo(
46
- e.x - s * Math.cos(i - Math.PI / 6),
47
- e.y - s * Math.sin(i - Math.PI / 6)
48
- ), n.moveTo(e.x, e.y), n.lineTo(
49
- e.x - s * Math.cos(i + Math.PI / 6),
50
- e.y - s * Math.sin(i + Math.PI / 6)
51
- ), n.stroke();
52
- }
53
- function R(n, t) {
54
- if (t.length !== 0) {
55
- n.beginPath(), n.moveTo(t[0].x, t[0].y);
56
- for (let e = 1; e < t.length; e++)
57
- n.lineTo(t[e].x, t[e].y);
58
- n.stroke();
59
- }
60
- }
61
- function S(n, t, e, o, i) {
62
- n.fillStyle = "rgb(15, 23, 42)", n.fillRect(t, e, o, i), n.fillStyle = "rgb(37, 47, 63)";
63
- for (let s = e; s < e + i; s += h)
64
- for (let a = t; a < t + o; a += h)
65
- (Math.floor((a - t) / h) + Math.floor((s - e) / h)) % 2 === 0 && n.fillRect(
66
- a,
67
- s,
68
- Math.min(h, t + o - a),
69
- Math.min(h, e + i - s)
70
- );
71
- }
72
- function p(n, t) {
73
- switch (n.save(), n.strokeStyle = t.color, n.fillStyle = t.color, n.lineWidth = t.strokeWidth, n.lineJoin = "round", n.lineCap = "round", t.type) {
74
- case "rect": {
75
- const e = u(t.points[0], t.points[1]);
76
- n.strokeRect(e.x, e.y, e.w, e.h);
77
- break;
78
- }
79
- case "arrow":
80
- M(n, t.points[0], t.points[1], t.strokeWidth);
81
- break;
82
- case "pen":
83
- R(n, t.points);
84
- break;
85
- case "blur": {
86
- const e = u(t.points[0], t.points[1]);
87
- S(n, e.x, e.y, e.w, e.h);
88
- break;
89
- }
90
- }
91
- n.restore();
92
- }
93
- function f(n) {
94
- return new Promise((t, e) => {
95
- const o = new Image();
96
- o.onload = () => t(o), o.onerror = () => e(new Error("Failed to load screenshot")), o.src = n;
97
- });
98
- }
99
- async function _(n, t, e = {}) {
100
- const o = e.quality ?? D;
101
- let i;
102
- try {
103
- i = await f(n);
104
- } catch {
105
- return n;
106
- }
107
- const s = document.createElement("canvas");
108
- s.width = i.naturalWidth || i.width || 1, s.height = i.naturalHeight || i.height || 1;
109
- const a = s.getContext("2d");
110
- if (!a) return n;
111
- a.drawImage(i, 0, 0, s.width, s.height);
112
- for (const c of t)
113
- p(a, c);
114
- return s.toDataURL("image/webp", o);
115
- }
116
- let N = 0;
117
- class U {
118
- shapes = [];
119
- tool = "rect";
120
- opts;
121
- labels;
122
- color;
123
- palette;
124
- strokeWidth;
125
- uid = `qaid-annotate-${++N}`;
126
- container;
127
- canvas;
128
- ctx = null;
129
- toolbar;
130
- undoBtn;
131
- img = null;
132
- drawing = !1;
133
- current = null;
134
- settled = !1;
135
- // Assigned in open() before any settle() is reachable (done/skip only fire
136
- // after the editor is mounted).
137
- resolveResult;
138
- constructor(t) {
139
- this.opts = t, this.labels = { ...I, ...t.labels ?? {} }, this.color = t.color ?? L, this.palette = (t.palette && t.palette.length ? t.palette : A).slice(), this.palette.some((e) => e.toLowerCase() === this.color.toLowerCase()) || this.palette.unshift(this.color), this.strokeWidth = t.strokeWidth ?? B;
140
- }
141
- /** Mount the editor and resolve when the user commits (Done) or skips. */
142
- open() {
143
- const t = new Promise((e) => {
144
- this.resolveResult = e;
145
- });
146
- return this.mount(), t;
147
- }
148
- toolButton(t, e, o) {
149
- const i = r("button", {
150
- type: "button",
151
- class: "qaid-annotate-tool",
152
- "data-qaid-tool": t,
153
- "aria-pressed": t === this.tool ? "true" : "false",
154
- "aria-label": `${o} tool`,
155
- title: o
156
- });
157
- return i.innerHTML = `${e}<span class="qaid-annotate-btn-text">${o}</span>`, i;
158
- }
159
- /** A round colour swatch button for the toolbar's colour group. */
160
- swatchButton(t) {
161
- const e = b(t), o = r("button", {
162
- type: "button",
163
- class: "qaid-annotate-swatch",
164
- "data-qaid-color": t,
165
- "aria-pressed": t.toLowerCase() === this.color.toLowerCase() ? "true" : "false",
166
- "aria-label": `Draw in ${e}`,
167
- title: e
168
- });
169
- return o.style.setProperty("--qaid-swatch", t), o;
170
- }
171
- actionButton(t, e, o, i) {
172
- const s = r("button", {
173
- type: "button",
174
- class: `qaid-annotate-action ${i}`,
175
- "data-qaid-action": t,
176
- "aria-label": o,
177
- title: o
178
- });
179
- return s.innerHTML = `${e}<span class="qaid-annotate-btn-text">${o}</span>`, s;
180
- }
181
- mount() {
182
- const t = `${this.uid}-title`, e = `${this.uid}-desc`;
183
- this.container = r("div", { class: "qaid-annotate" }), this.opts.applyVars?.(this.container);
184
- const o = r("h2", {
185
- id: t,
186
- class: "qaid-annotate-title"
187
- });
188
- o.textContent = this.labels.title;
189
- const i = r("p", {
190
- id: e,
191
- class: "qaid-annotate-desc"
192
- });
193
- i.textContent = this.labels.instructions;
194
- const s = r("div", { class: "qaid-annotate-stage" });
195
- this.canvas = document.createElement("canvas"), this.canvas.className = "qaid-annotate-canvas", this.canvas.width = 1, this.canvas.height = 1, this.canvas.setAttribute("role", "img"), this.canvas.setAttribute("aria-label", this.labels.title), this.ctx = this.canvas.getContext("2d"), s.appendChild(this.canvas), this.toolbar = r("div", {
196
- class: "qaid-annotate-toolbar",
197
- role: "toolbar",
198
- "aria-label": this.labels.title
199
- });
200
- const a = r("div", { class: "qaid-annotate-tools" });
201
- a.appendChild(this.toolButton("rect", v, this.labels.rectangle)), a.appendChild(this.toolButton("arrow", C, this.labels.arrow)), a.appendChild(this.toolButton("pen", y, this.labels.pen)), a.appendChild(this.toolButton("blur", m, this.labels.blur));
202
- const c = r("div", {
203
- class: "qaid-annotate-colors",
204
- role: "group",
205
- "aria-label": this.labels.colors
206
- });
207
- for (const l of this.palette) c.appendChild(this.swatchButton(l));
208
- this.undoBtn = this.actionButton("undo", q, this.labels.undo, "qaid-annotate-undo"), this.undoBtn.disabled = !0;
209
- const w = this.actionButton("skip", k, this.labels.skip, "qaid-annotate-skip"), g = this.actionButton("done", E, this.labels.done, "qaid-annotate-done"), d = r("div", { class: "qaid-annotate-actions" });
210
- d.appendChild(this.undoBtn), d.appendChild(w), d.appendChild(g), this.toolbar.appendChild(a), this.toolbar.appendChild(c), this.toolbar.appendChild(d), this.container.appendChild(o), this.container.appendChild(i), this.container.appendChild(s), this.container.appendChild(this.toolbar), this.opts.root.appendChild(this.container), this.toolbar.addEventListener("click", this.onToolbarClick), this.canvas.addEventListener("pointerdown", this.onPointerDown), this.container.addEventListener("pointermove", this.onPointerMove), this.container.addEventListener("pointerup", this.onPointerUp), this.container.addEventListener("keydown", this.onKeyDown), this.opts.openDialog?.(this.container, {
211
- labelledbyId: t,
212
- describedbyId: e
213
- }), this.opts.announce?.(this.labels.instructions), f(this.opts.dataUrl).then((l) => {
214
- this.img = l, this.canvas.width = l.naturalWidth || l.width || 1, this.canvas.height = l.naturalHeight || l.height || 1, this.redraw();
215
- }).catch(() => {
216
- this.img = null, this.redraw();
217
- });
218
- }
219
- /** Convert a pointer event's client coordinates into natural image pixels. */
220
- toImageCoords(t) {
221
- const e = this.canvas.getBoundingClientRect(), o = this.canvas.width / (e.width || this.canvas.width), i = this.canvas.height / (e.height || this.canvas.height);
222
- return {
223
- x: (t.clientX - e.left) * o,
224
- y: (t.clientY - e.top) * i
225
- };
226
- }
227
- /** Repaint the display canvas: base image (if loaded) then every shape. */
228
- redraw() {
229
- const t = this.ctx;
230
- if (t) {
231
- t.clearRect(0, 0, this.canvas.width, this.canvas.height), this.img && t.drawImage(this.img, 0, 0, this.canvas.width, this.canvas.height);
232
- for (const e of this.shapes)
233
- p(t, e);
234
- this.current && p(t, this.current);
235
- }
236
- }
237
- /** Select the active drawing tool and reflect it on the toolbar. */
238
- selectTool(t) {
239
- this.tool = t, this.toolbar.querySelectorAll("[data-qaid-tool]").forEach((i) => {
240
- i.setAttribute(
241
- "aria-pressed",
242
- i.getAttribute("data-qaid-tool") === t ? "true" : "false"
243
- );
244
- });
245
- const o = this.labels[O[t]];
246
- this.opts.announce?.(`${o} tool selected`);
247
- }
248
- /** Set the active drawing colour; subsequent shapes use it. */
249
- selectColor(t) {
250
- this.color = t, this.toolbar.querySelectorAll("[data-qaid-color]").forEach((o) => {
251
- o.setAttribute(
252
- "aria-pressed",
253
- (o.getAttribute("data-qaid-color") ?? "").toLowerCase() === t.toLowerCase() ? "true" : "false"
254
- );
255
- }), this.opts.announce?.(`${b(t)} colour selected`);
256
- }
257
- onToolbarClick = (t) => {
258
- const o = t.target?.closest(
259
- "[data-qaid-tool],[data-qaid-action],[data-qaid-color]"
260
- );
261
- if (!o) return;
262
- const i = o.getAttribute("data-qaid-color");
263
- if (i) {
264
- this.selectColor(i);
265
- return;
266
- }
267
- const s = o.getAttribute("data-qaid-tool");
268
- if (s) {
269
- this.selectTool(s);
270
- return;
271
- }
272
- const a = o.getAttribute("data-qaid-action");
273
- a === "undo" ? this.undo() : a === "skip" ? this.skip() : a === "done" && this.done();
274
- };
275
- onPointerDown = (t) => {
276
- t.preventDefault?.(), this.drawing = !0;
277
- const e = this.toImageCoords(t);
278
- this.current = {
279
- type: this.tool,
280
- color: this.color,
281
- strokeWidth: this.strokeWidth,
282
- points: this.tool === "pen" ? [e] : [e, { ...e }]
283
- }, this.redraw();
284
- };
285
- onPointerMove = (t) => {
286
- if (!this.drawing || !this.current) return;
287
- const e = this.toImageCoords(t);
288
- this.current.type === "pen" ? this.current.points.push(e) : this.current.points[1] = e, this.redraw();
289
- };
290
- onPointerUp = () => {
291
- if (!this.drawing || !this.current) return;
292
- this.drawing = !1;
293
- const t = this.current;
294
- if (this.current = null, P(t)) {
295
- this.redraw();
296
- return;
297
- }
298
- this.shapes.push(t), this.undoBtn.disabled = !1, this.opts.announce?.("Annotation added"), this.redraw();
299
- };
300
- onKeyDown = (t) => {
301
- if (t.key === "Escape") {
302
- t.preventDefault(), this.skip();
303
- return;
304
- }
305
- if (t.key === "Enter") {
306
- const e = t.target;
307
- if (e?.getAttribute("data-qaid-tool") || e?.getAttribute("data-qaid-action"))
308
- return;
309
- t.preventDefault(), this.done();
310
- }
311
- };
312
- /** Remove the most recently added shape. */
313
- undo() {
314
- if (this.shapes.length === 0) {
315
- this.opts.announce?.("Nothing to undo");
316
- return;
317
- }
318
- this.shapes.pop(), this.undoBtn.disabled = this.shapes.length === 0, this.opts.announce?.("Removed last annotation"), this.redraw();
319
- }
320
- /** Composite the annotations and resolve with the new WebP data URL. */
321
- async done() {
322
- if (this.settled) return;
323
- const t = await _(this.opts.dataUrl, this.shapes, {
324
- quality: this.opts.quality
325
- });
326
- this.opts.announce?.("Annotated screenshot attached"), this.settle(t);
327
- }
328
- /** Discard annotations and resolve with `null` (caller keeps the original). */
329
- skip() {
330
- this.settled || (this.opts.announce?.("Annotation skipped"), this.settle(null));
331
- }
332
- settle(t) {
333
- this.settled = !0, this.teardown(), this.resolveResult(t);
334
- }
335
- teardown() {
336
- this.toolbar.removeEventListener("click", this.onToolbarClick), this.canvas.removeEventListener("pointerdown", this.onPointerDown), this.container.removeEventListener("pointermove", this.onPointerMove), this.container.removeEventListener("pointerup", this.onPointerUp), this.container.removeEventListener("keydown", this.onKeyDown), this.opts.closeDialog?.(), this.container.remove();
337
- }
338
- }
339
- const O = {
340
- rect: "rectangle",
341
- arrow: "arrow",
342
- pen: "pen",
343
- blur: "blur"
344
- };
345
- function $(n) {
346
- return new U(n).open();
347
- }
348
- export {
349
- U as AnnotationEditor,
350
- _ as compositeAnnotations,
351
- p as drawShape,
352
- $ as openAnnotationEditor,
353
- u as rectFromPoints
354
- };
355
- //# sourceMappingURL=annotate-BTLeFQa0.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"annotate-BTLeFQa0.js","sources":["../../src/annotate.ts"],"sourcesContent":["/**\n * Screenshot annotation / markup editor for the thumbs embed.\n *\n * After a screenshot is captured the user can draw on it — rectangles, arrows,\n * a freehand pen, and a blur/redact box — in a full-screen, focus-trapped,\n * WCAG 2.2 AA dialog rendered inside the embed's overlay shadow root. On \"Done\"\n * the base image and the vector shapes are composited into a fresh WebP data\n * URL (so downstream code is unchanged); on \"Skip\"/Escape the original is kept.\n *\n * The geometry and compositing are kept as pure-ish exported functions\n * (`drawShape`, `rectFromPoints`, `compositeAnnotations`) so they can be tested\n * without a real rendering engine — happy-dom has no raster, so tests assert on\n * spied canvas-context calls rather than pixels. The {@link AnnotationEditor}\n * controller keeps the DOM wiring thin and its interactive methods are public\n * so they can be driven directly in tests.\n */\n\nimport { createElement } from \"./dom-utils\";\nimport {\n RECTANGLE_ICON,\n ARROW_ICON,\n PENCIL_ICON,\n BLUR_ICON,\n UNDO_ICON,\n DONE_ICON,\n SKIP_ICON,\n} from \"./icons\";\n\n/** The four drawing tools. */\nexport type ShapeType = \"rect\" | \"arrow\" | \"pen\" | \"blur\";\n\n/** A point in the screenshot's natural-pixel coordinate space. */\nexport interface Point {\n x: number;\n y: number;\n}\n\n/**\n * A single vector annotation. `rect`, `arrow` and `blur` use `points[0]` as the\n * drag start and `points[1]` as the drag end; `pen` uses every point in order.\n */\nexport interface Shape {\n type: ShapeType;\n color: string;\n strokeWidth: number;\n points: Point[];\n}\n\n/** Tile size (natural px) for the mosaic drawn by the blur/redact tool. */\nconst BLUR_TILE = 12;\n\n/** Default stroke colour: a high-visibility red that reads on most screenshots. */\nconst DEFAULT_STROKE = \"#ef4444\";\n/** Default swatch palette when the embed doesn't supply one. */\nconst DEFAULT_PALETTE = [\"#ef4444\", \"#f59e0b\", \"#22c55e\", \"#3b82f6\", \"#111827\", \"#ffffff\"];\n/** Friendly names for common swatches (for accessible labels). */\nconst COLOR_NAMES: Record<string, string> = {\n \"#ef4444\": \"red\",\n \"#f59e0b\": \"amber\",\n \"#22c55e\": \"green\",\n \"#3b82f6\": \"blue\",\n \"#111827\": \"black\",\n \"#ffffff\": \"white\",\n // The default marker (nudged from #6366f1 so white text on it clears 4.5:1);\n // the old value keeps its name for sites that pass it explicitly.\n \"#6365f1\": \"indigo\",\n \"#6366f1\": \"indigo\",\n};\n/** Accessible name for a swatch colour — a friendly name, else the hex. */\nfunction colorName(hex: string): string {\n return COLOR_NAMES[hex.toLowerCase()] ?? hex;\n}\n/** Default stroke width in natural pixels. */\nconst DEFAULT_STROKE_WIDTH = 4;\n/** Default WebP quality for the re-encoded composite. */\nconst DEFAULT_QUALITY = 0.8;\n\n/** Human-readable labels for the toolbar / announcements (all overridable). */\nexport interface AnnotationLabels {\n title: string;\n instructions: string;\n rectangle: string;\n arrow: string;\n pen: string;\n blur: string;\n undo: string;\n skip: string;\n done: string;\n colors: string;\n}\n\nconst DEFAULT_LABELS: AnnotationLabels = {\n title: \"Annotate screenshot\",\n instructions:\n \"Draw on the screenshot to highlight or hide details, then choose Done to attach it or Skip to send the original.\",\n rectangle: \"Rectangle\",\n arrow: \"Arrow\",\n pen: \"Pen\",\n blur: \"Blur or redact\",\n undo: \"Undo last\",\n skip: \"Skip annotation\",\n done: \"Done\",\n colors: \"Drawing colour\",\n};\n\n/**\n * Normalise two drag corners into a top-left origin plus positive width/height,\n * regardless of the direction the user dragged.\n */\nexport function rectFromPoints(\n a: Point,\n b: Point\n): { x: number; y: number; w: number; h: number } {\n return {\n x: Math.min(a.x, b.x),\n y: Math.min(a.y, b.y),\n w: Math.abs(a.x - b.x),\n h: Math.abs(a.y - b.y),\n };\n}\n\n/** A drag/shape too small to be a deliberate mark (a click, not a drag). */\nfunction isDegenerate(shape: Shape): boolean {\n if (shape.type === \"pen\") return shape.points.length < 2;\n const r = rectFromPoints(shape.points[0], shape.points[1]);\n return r.w < 3 && r.h < 3;\n}\n\nfunction drawArrow(\n ctx: CanvasRenderingContext2D,\n from: Point,\n to: Point,\n width: number\n): void {\n ctx.beginPath();\n ctx.moveTo(from.x, from.y);\n ctx.lineTo(to.x, to.y);\n ctx.stroke();\n\n const angle = Math.atan2(to.y - from.y, to.x - from.x);\n const head = Math.max(10, width * 3);\n ctx.beginPath();\n ctx.moveTo(to.x, to.y);\n ctx.lineTo(\n to.x - head * Math.cos(angle - Math.PI / 6),\n to.y - head * Math.sin(angle - Math.PI / 6)\n );\n ctx.moveTo(to.x, to.y);\n ctx.lineTo(\n to.x - head * Math.cos(angle + Math.PI / 6),\n to.y - head * Math.sin(angle + Math.PI / 6)\n );\n ctx.stroke();\n}\n\nfunction drawPen(ctx: CanvasRenderingContext2D, points: Point[]): void {\n if (points.length === 0) return;\n ctx.beginPath();\n ctx.moveTo(points[0].x, points[0].y);\n for (let i = 1; i < points.length; i++) {\n ctx.lineTo(points[i].x, points[i].y);\n }\n ctx.stroke();\n}\n\n/**\n * Redact a region so the underlying content is GONE from the composite — not\n * merely dimmed. Both fills are fully opaque (no alpha), so nothing bleeds\n * through; the two-tone mosaic just gives it a recognisable \"redacted\" texture.\n * There is no real Gaussian blur (it can't be verified without a raster), and a\n * translucent wash would leave sensitive text faintly legible — so this paints\n * solid.\n */\nfunction drawBlur(\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n w: number,\n h: number\n): void {\n ctx.fillStyle = \"rgb(15, 23, 42)\";\n ctx.fillRect(x, y, w, h);\n ctx.fillStyle = \"rgb(37, 47, 63)\";\n for (let ty = y; ty < y + h; ty += BLUR_TILE) {\n for (let tx = x; tx < x + w; tx += BLUR_TILE) {\n const checker =\n (Math.floor((tx - x) / BLUR_TILE) + Math.floor((ty - y) / BLUR_TILE)) %\n 2 ===\n 0;\n if (checker) {\n ctx.fillRect(\n tx,\n ty,\n Math.min(BLUR_TILE, x + w - tx),\n Math.min(BLUR_TILE, y + h - ty)\n );\n }\n }\n }\n}\n\n/**\n * Draw a single shape onto a 2D context in the shape's own (natural-pixel)\n * coordinates. Used both for the live editing preview and for the final\n * composite, so what the user sees is exactly what is submitted.\n */\nexport function drawShape(ctx: CanvasRenderingContext2D, shape: Shape): void {\n ctx.save();\n ctx.strokeStyle = shape.color;\n ctx.fillStyle = shape.color;\n ctx.lineWidth = shape.strokeWidth;\n ctx.lineJoin = \"round\";\n ctx.lineCap = \"round\";\n\n switch (shape.type) {\n case \"rect\": {\n const r = rectFromPoints(shape.points[0], shape.points[1]);\n ctx.strokeRect(r.x, r.y, r.w, r.h);\n break;\n }\n case \"arrow\":\n drawArrow(ctx, shape.points[0], shape.points[1], shape.strokeWidth);\n break;\n case \"pen\":\n drawPen(ctx, shape.points);\n break;\n case \"blur\": {\n const r = rectFromPoints(shape.points[0], shape.points[1]);\n drawBlur(ctx, r.x, r.y, r.w, r.h);\n break;\n }\n }\n\n ctx.restore();\n}\n\n/** Load an image from a data URL. Resolves with the element once decoded. */\nfunction loadImage(src: string): Promise<HTMLImageElement> {\n return new Promise((resolve, reject) => {\n const img = new Image();\n img.onload = (): void => resolve(img);\n img.onerror = (): void => reject(new Error(\"Failed to load screenshot\"));\n img.src = src;\n });\n}\n\n/**\n * Composite the base screenshot and the drawn shapes into a new WebP data URL\n * at the image's natural size. Falls back to the original data URL if the image\n * can't be loaded or a 2D context isn't available (so a submission is never\n * lost). This is intentionally standalone so it can be unit-tested in isolation.\n */\nexport async function compositeAnnotations(\n dataUrl: string,\n shapes: Shape[],\n opts: { quality?: number } = {}\n): Promise<string> {\n const quality = opts.quality ?? DEFAULT_QUALITY;\n\n let img: HTMLImageElement;\n try {\n img = await loadImage(dataUrl);\n } catch {\n return dataUrl;\n }\n\n const canvas = document.createElement(\"canvas\");\n canvas.width = img.naturalWidth || img.width || 1;\n canvas.height = img.naturalHeight || img.height || 1;\n\n const ctx = canvas.getContext(\"2d\");\n if (!ctx) return dataUrl;\n\n ctx.drawImage(img, 0, 0, canvas.width, canvas.height);\n for (const shape of shapes) {\n drawShape(ctx, shape);\n }\n\n return canvas.toDataURL(\"image/webp\", quality);\n}\n\n/** Options for {@link AnnotationEditor} / {@link openAnnotationEditor}. */\nexport interface AnnotationEditorOptions {\n /** The captured screenshot as a WebP data URL. */\n dataUrl: string;\n /** Shadow root (or element) the editor is mounted into. */\n root: ShadowRoot | HTMLElement;\n /** WebP quality for the re-encoded composite. */\n quality?: number;\n /** Default stroke colour for rectangle/arrow/pen. */\n color?: string;\n /** Colour swatches offered in the toolbar. The active `color` is ensured present. */\n palette?: string[];\n /** Default stroke width. */\n strokeWidth?: number;\n /** Label overrides. */\n labels?: Partial<AnnotationLabels>;\n /** Apply the embed's per-instance `--qaid-*` CSS variables to the container. */\n applyVars?: (el: HTMLElement) => void;\n /** Announce a message via the embed's live regions. */\n announce?: (message: string, assertive?: boolean) => void;\n /** Turn the container into an accessible modal dialog (focus trap + inert). */\n openDialog?: (\n container: HTMLElement,\n opts: { labelledbyId?: string; describedbyId?: string }\n ) => void;\n /** Tear down the dialog semantics and restore focus. */\n closeDialog?: () => void;\n}\n\nlet editorSeq = 0;\n\n/**\n * Full-screen screenshot annotation editor. Construct it, call {@link open}\n * (which returns a promise resolving to the composited WebP, or `null` when the\n * user skips), and the controller manages its own DOM and teardown.\n */\nexport class AnnotationEditor {\n readonly shapes: Shape[] = [];\n tool: ShapeType = \"rect\";\n\n private readonly opts: AnnotationEditorOptions;\n private readonly labels: AnnotationLabels;\n private color: string;\n private readonly palette: string[];\n private readonly strokeWidth: number;\n private readonly uid = `qaid-annotate-${++editorSeq}`;\n\n private container!: HTMLDivElement;\n private canvas!: HTMLCanvasElement;\n private ctx: CanvasRenderingContext2D | null = null;\n private toolbar!: HTMLDivElement;\n private undoBtn!: HTMLButtonElement;\n private img: HTMLImageElement | null = null;\n\n private drawing = false;\n private current: Shape | null = null;\n private settled = false;\n // Assigned in open() before any settle() is reachable (done/skip only fire\n // after the editor is mounted).\n private resolveResult!: (value: string | null) => void;\n\n constructor(opts: AnnotationEditorOptions) {\n this.opts = opts;\n this.labels = { ...DEFAULT_LABELS, ...(opts.labels ?? {}) };\n this.color = opts.color ?? DEFAULT_STROKE;\n this.palette = (opts.palette && opts.palette.length ? opts.palette : DEFAULT_PALETTE).slice();\n // Ensure the active colour is offered as a swatch so it stays selectable.\n if (!this.palette.some((c) => c.toLowerCase() === this.color.toLowerCase())) {\n this.palette.unshift(this.color);\n }\n this.strokeWidth = opts.strokeWidth ?? DEFAULT_STROKE_WIDTH;\n }\n\n /** Mount the editor and resolve when the user commits (Done) or skips. */\n open(): Promise<string | null> {\n const promise = new Promise<string | null>((resolve) => {\n this.resolveResult = resolve;\n });\n this.mount();\n return promise;\n }\n\n private toolButton(tool: ShapeType, icon: string, label: string): HTMLButtonElement {\n const btn = createElement(\"button\", {\n type: \"button\",\n class: \"qaid-annotate-tool\",\n \"data-qaid-tool\": tool,\n \"aria-pressed\": tool === this.tool ? \"true\" : \"false\",\n \"aria-label\": `${label} tool`,\n title: label,\n });\n btn.innerHTML = `${icon}<span class=\"qaid-annotate-btn-text\">${label}</span>`;\n return btn;\n }\n\n /** A round colour swatch button for the toolbar's colour group. */\n private swatchButton(color: string): HTMLButtonElement {\n const name = colorName(color);\n const btn = createElement(\"button\", {\n type: \"button\",\n class: \"qaid-annotate-swatch\",\n \"data-qaid-color\": color,\n \"aria-pressed\": color.toLowerCase() === this.color.toLowerCase() ? \"true\" : \"false\",\n \"aria-label\": `Draw in ${name}`,\n title: name,\n });\n btn.style.setProperty(\"--qaid-swatch\", color);\n return btn;\n }\n\n private actionButton(\n action: string,\n icon: string,\n label: string,\n extraClass: string\n ): HTMLButtonElement {\n const btn = createElement(\"button\", {\n type: \"button\",\n class: `qaid-annotate-action ${extraClass}`,\n \"data-qaid-action\": action,\n \"aria-label\": label,\n title: label,\n });\n btn.innerHTML = `${icon}<span class=\"qaid-annotate-btn-text\">${label}</span>`;\n return btn;\n }\n\n private mount(): void {\n const titleId = `${this.uid}-title`;\n const descId = `${this.uid}-desc`;\n\n this.container = createElement(\"div\", { class: \"qaid-annotate\" });\n this.opts.applyVars?.(this.container);\n\n const title = createElement(\"h2\", {\n id: titleId,\n class: \"qaid-annotate-title\",\n });\n title.textContent = this.labels.title;\n\n const desc = createElement(\"p\", {\n id: descId,\n class: \"qaid-annotate-desc\",\n });\n desc.textContent = this.labels.instructions;\n\n const stage = createElement(\"div\", { class: \"qaid-annotate-stage\" });\n this.canvas = document.createElement(\"canvas\");\n this.canvas.className = \"qaid-annotate-canvas\";\n this.canvas.width = 1;\n this.canvas.height = 1;\n this.canvas.setAttribute(\"role\", \"img\");\n this.canvas.setAttribute(\"aria-label\", this.labels.title);\n this.ctx = this.canvas.getContext(\"2d\");\n stage.appendChild(this.canvas);\n\n this.toolbar = createElement(\"div\", {\n class: \"qaid-annotate-toolbar\",\n role: \"toolbar\",\n \"aria-label\": this.labels.title,\n });\n\n const tools = createElement(\"div\", { class: \"qaid-annotate-tools\" });\n tools.appendChild(this.toolButton(\"rect\", RECTANGLE_ICON, this.labels.rectangle));\n tools.appendChild(this.toolButton(\"arrow\", ARROW_ICON, this.labels.arrow));\n tools.appendChild(this.toolButton(\"pen\", PENCIL_ICON, this.labels.pen));\n tools.appendChild(this.toolButton(\"blur\", BLUR_ICON, this.labels.blur));\n\n const colors = createElement(\"div\", {\n class: \"qaid-annotate-colors\",\n role: \"group\",\n \"aria-label\": this.labels.colors,\n });\n for (const c of this.palette) colors.appendChild(this.swatchButton(c));\n\n this.undoBtn = this.actionButton(\"undo\", UNDO_ICON, this.labels.undo, \"qaid-annotate-undo\");\n this.undoBtn.disabled = true;\n\n const skipBtn = this.actionButton(\"skip\", SKIP_ICON, this.labels.skip, \"qaid-annotate-skip\");\n const doneBtn = this.actionButton(\"done\", DONE_ICON, this.labels.done, \"qaid-annotate-done\");\n\n const actions = createElement(\"div\", { class: \"qaid-annotate-actions\" });\n actions.appendChild(this.undoBtn);\n actions.appendChild(skipBtn);\n actions.appendChild(doneBtn);\n\n this.toolbar.appendChild(tools);\n this.toolbar.appendChild(colors);\n this.toolbar.appendChild(actions);\n\n this.container.appendChild(title);\n this.container.appendChild(desc);\n this.container.appendChild(stage);\n this.container.appendChild(this.toolbar);\n this.opts.root.appendChild(this.container);\n\n this.toolbar.addEventListener(\"click\", this.onToolbarClick);\n this.canvas.addEventListener(\"pointerdown\", this.onPointerDown);\n this.container.addEventListener(\"pointermove\", this.onPointerMove);\n this.container.addEventListener(\"pointerup\", this.onPointerUp);\n this.container.addEventListener(\"keydown\", this.onKeyDown);\n\n this.opts.openDialog?.(this.container, {\n labelledbyId: titleId,\n describedbyId: descId,\n });\n this.opts.announce?.(this.labels.instructions);\n\n loadImage(this.opts.dataUrl)\n .then((img) => {\n this.img = img;\n this.canvas.width = img.naturalWidth || img.width || 1;\n this.canvas.height = img.naturalHeight || img.height || 1;\n this.redraw();\n })\n .catch(() => {\n this.img = null;\n this.redraw();\n });\n }\n\n /** Convert a pointer event's client coordinates into natural image pixels. */\n private toImageCoords(e: { clientX: number; clientY: number }): Point {\n const rect = this.canvas.getBoundingClientRect();\n const scaleX = this.canvas.width / (rect.width || this.canvas.width);\n const scaleY = this.canvas.height / (rect.height || this.canvas.height);\n return {\n x: (e.clientX - rect.left) * scaleX,\n y: (e.clientY - rect.top) * scaleY,\n };\n }\n\n /** Repaint the display canvas: base image (if loaded) then every shape. */\n redraw(): void {\n const ctx = this.ctx;\n if (!ctx) return;\n ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);\n if (this.img) {\n ctx.drawImage(this.img, 0, 0, this.canvas.width, this.canvas.height);\n }\n for (const shape of this.shapes) {\n drawShape(ctx, shape);\n }\n if (this.current) {\n drawShape(ctx, this.current);\n }\n }\n\n /** Select the active drawing tool and reflect it on the toolbar. */\n selectTool(tool: ShapeType): void {\n this.tool = tool;\n const buttons = this.toolbar.querySelectorAll<HTMLButtonElement>(\"[data-qaid-tool]\");\n buttons.forEach((btn) => {\n btn.setAttribute(\n \"aria-pressed\",\n btn.getAttribute(\"data-qaid-tool\") === tool ? \"true\" : \"false\"\n );\n });\n const label = this.labels[LABEL_KEY[tool]];\n this.opts.announce?.(`${label} tool selected`);\n }\n\n /** Set the active drawing colour; subsequent shapes use it. */\n selectColor(color: string): void {\n this.color = color;\n const swatches = this.toolbar.querySelectorAll<HTMLButtonElement>(\"[data-qaid-color]\");\n swatches.forEach((s) => {\n s.setAttribute(\n \"aria-pressed\",\n (s.getAttribute(\"data-qaid-color\") ?? \"\").toLowerCase() === color.toLowerCase()\n ? \"true\"\n : \"false\"\n );\n });\n this.opts.announce?.(`${colorName(color)} colour selected`);\n }\n\n private onToolbarClick = (e: Event): void => {\n const target = e.target as HTMLElement | null;\n const btn = target?.closest<HTMLElement>(\n \"[data-qaid-tool],[data-qaid-action],[data-qaid-color]\"\n );\n if (!btn) return;\n const color = btn.getAttribute(\"data-qaid-color\");\n if (color) {\n this.selectColor(color);\n return;\n }\n const tool = btn.getAttribute(\"data-qaid-tool\");\n if (tool) {\n this.selectTool(tool as ShapeType);\n return;\n }\n const action = btn.getAttribute(\"data-qaid-action\");\n if (action === \"undo\") this.undo();\n else if (action === \"skip\") this.skip();\n else if (action === \"done\") void this.done();\n };\n\n onPointerDown = (e: PointerEvent): void => {\n e.preventDefault?.();\n this.drawing = true;\n const p = this.toImageCoords(e);\n this.current = {\n type: this.tool,\n color: this.color,\n strokeWidth: this.strokeWidth,\n points: this.tool === \"pen\" ? [p] : [p, { ...p }],\n };\n this.redraw();\n };\n\n onPointerMove = (e: PointerEvent): void => {\n if (!this.drawing || !this.current) return;\n const p = this.toImageCoords(e);\n if (this.current.type === \"pen\") {\n this.current.points.push(p);\n } else {\n this.current.points[1] = p;\n }\n this.redraw();\n };\n\n onPointerUp = (): void => {\n if (!this.drawing || !this.current) return;\n this.drawing = false;\n const shape = this.current;\n this.current = null;\n if (isDegenerate(shape)) {\n this.redraw();\n return;\n }\n this.shapes.push(shape);\n this.undoBtn.disabled = false;\n this.opts.announce?.(\"Annotation added\");\n this.redraw();\n };\n\n onKeyDown = (e: KeyboardEvent): void => {\n if (e.key === \"Escape\") {\n e.preventDefault();\n this.skip();\n return;\n }\n if (e.key === \"Enter\") {\n const target = e.target as HTMLElement | null;\n // Let Enter activate a focused tool/action button natively.\n if (target?.getAttribute(\"data-qaid-tool\") || target?.getAttribute(\"data-qaid-action\")) {\n return;\n }\n e.preventDefault();\n void this.done();\n }\n };\n\n /** Remove the most recently added shape. */\n undo(): void {\n if (this.shapes.length === 0) {\n this.opts.announce?.(\"Nothing to undo\");\n return;\n }\n this.shapes.pop();\n this.undoBtn.disabled = this.shapes.length === 0;\n this.opts.announce?.(\"Removed last annotation\");\n this.redraw();\n }\n\n /** Composite the annotations and resolve with the new WebP data URL. */\n async done(): Promise<void> {\n if (this.settled) return;\n const out = await compositeAnnotations(this.opts.dataUrl, this.shapes, {\n quality: this.opts.quality,\n });\n this.opts.announce?.(\"Annotated screenshot attached\");\n this.settle(out);\n }\n\n /** Discard annotations and resolve with `null` (caller keeps the original). */\n skip(): void {\n if (this.settled) return;\n this.opts.announce?.(\"Annotation skipped\");\n this.settle(null);\n }\n\n private settle(value: string | null): void {\n this.settled = true;\n this.teardown();\n this.resolveResult(value);\n }\n\n private teardown(): void {\n this.toolbar.removeEventListener(\"click\", this.onToolbarClick);\n this.canvas.removeEventListener(\"pointerdown\", this.onPointerDown);\n this.container.removeEventListener(\"pointermove\", this.onPointerMove);\n this.container.removeEventListener(\"pointerup\", this.onPointerUp);\n this.container.removeEventListener(\"keydown\", this.onKeyDown);\n this.opts.closeDialog?.();\n this.container.remove();\n }\n}\n\n/** Maps a tool id to its label key, for announcements. */\nconst LABEL_KEY: Record<ShapeType, keyof AnnotationLabels> = {\n rect: \"rectangle\",\n arrow: \"arrow\",\n pen: \"pen\",\n blur: \"blur\",\n};\n\n/**\n * Open the annotation editor and resolve with the composited WebP data URL, or\n * `null` if the user skipped. Thin entry point used by the embed.\n */\nexport function openAnnotationEditor(\n opts: AnnotationEditorOptions\n): Promise<string | null> {\n return new AnnotationEditor(opts).open();\n}\n"],"names":["BLUR_TILE","DEFAULT_STROKE","DEFAULT_PALETTE","COLOR_NAMES","colorName","hex","DEFAULT_STROKE_WIDTH","DEFAULT_QUALITY","DEFAULT_LABELS","rectFromPoints","a","b","isDegenerate","shape","r","drawArrow","ctx","from","to","width","angle","head","drawPen","points","i","drawBlur","x","y","w","h","ty","tx","drawShape","loadImage","src","resolve","reject","img","compositeAnnotations","dataUrl","shapes","opts","quality","canvas","editorSeq","AnnotationEditor","c","promise","tool","icon","label","btn","createElement","color","name","action","extraClass","titleId","descId","title","desc","stage","tools","RECTANGLE_ICON","ARROW_ICON","PENCIL_ICON","BLUR_ICON","colors","UNDO_ICON","skipBtn","SKIP_ICON","doneBtn","DONE_ICON","actions","e","rect","scaleX","scaleY","LABEL_KEY","s","p","target","out","value","openAnnotationEditor"],"mappings":";AAiDA,MAAMA,IAAY,IAGZC,IAAiB,WAEjBC,IAAkB,CAAC,WAAW,WAAW,WAAW,WAAW,WAAW,SAAS,GAEnFC,IAAsC;AAAA,EAC1C,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA;AAAA;AAAA,EAGX,WAAW;AAAA,EACX,WAAW;AACb;AAEA,SAASC,EAAUC,GAAqB;AACtC,SAAOF,EAAYE,EAAI,YAAA,CAAa,KAAKA;AAC3C;AAEA,MAAMC,IAAuB,GAEvBC,IAAkB,KAgBlBC,IAAmC;AAAA,EACvC,OAAO;AAAA,EACP,cACE;AAAA,EACF,WAAW;AAAA,EACX,OAAO;AAAA,EACP,KAAK;AAAA,EACL,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,QAAQ;AACV;AAMO,SAASC,EACdC,GACAC,GACgD;AAChD,SAAO;AAAA,IACL,GAAG,KAAK,IAAID,EAAE,GAAGC,EAAE,CAAC;AAAA,IACpB,GAAG,KAAK,IAAID,EAAE,GAAGC,EAAE,CAAC;AAAA,IACpB,GAAG,KAAK,IAAID,EAAE,IAAIC,EAAE,CAAC;AAAA,IACrB,GAAG,KAAK,IAAID,EAAE,IAAIC,EAAE,CAAC;AAAA,EAAA;AAEzB;AAGA,SAASC,EAAaC,GAAuB;AAC3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