@qaiddev/thumbs-embed 1.10.0 → 1.10.1
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.
- package/dist/chunks/{annotate-D-o8xCV9.js → annotate-BTLeFQa0.js} +71 -137
- package/dist/chunks/annotate-BTLeFQa0.js.map +1 -0
- package/dist/chunks/{loader-BVNyi56k.js → core-2nGsCcZq.js} +256 -190
- package/dist/chunks/core-2nGsCcZq.js.map +1 -0
- package/dist/chunks/{modal-DwwbWQ-F.js → modal-zwBhxWO0.js} +36 -37
- package/dist/chunks/{modal-DwwbWQ-F.js.map → modal-zwBhxWO0.js.map} +1 -1
- package/dist/chunks/{recording-CcfOfIC7.js → recording-DNngIGr2.js} +6 -6
- package/dist/chunks/{recording-CcfOfIC7.js.map → recording-DNngIGr2.js.map} +1 -1
- package/dist/chunks/{targeting-Dz6z1BYl.js → targeting-DaBmGVk5.js} +2 -2
- package/dist/chunks/{targeting-Dz6z1BYl.js.map → targeting-DaBmGVk5.js.map} +1 -1
- package/dist/loader.js +4 -2
- package/dist/loader.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunks/annotate-D-o8xCV9.js.map +0 -1
- package/dist/chunks/loader-BVNyi56k.js.map +0 -1
|
@@ -1,57 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
</svg>`, W = `<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
4
|
-
<path stroke-linecap="round" stroke-linejoin="round" d="M10 14H5.236a2 2 0 01-1.789-2.894l3.5-7A2 2 0 018.737 3h4.018a2 2 0 01.485.06l3.76.94m-7 10v5a2 2 0 002 2h.095c.5 0 .905-.405.905-.905 0-.714.211-1.412.608-2.006L17 13V4m-7 10h2m5-10h2a2 2 0 012 2v6a2 2 0 01-2 2h-2.5"/>
|
|
5
|
-
</svg>`, $ = `<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
6
|
-
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 10.5l4.72-4.72a.75.75 0 011.28.53v11.38a.75.75 0 01-1.28.53l-4.72-4.72M4.5 18.75h9a2.25 2.25 0 002.25-2.25v-9a2.25 2.25 0 00-2.25-2.25h-9A2.25 2.25 0 002.25 7.5v9a2.25 2.25 0 002.25 2.25z"/>
|
|
7
|
-
</svg>`, H = `<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
8
|
-
<path stroke-linecap="round" stroke-linejoin="round" d="M8 10h8M8 14h5m-9 6l3.5-3.5H18a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v14z"/>
|
|
9
|
-
</svg>`, m = `<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
10
|
-
<rect x="4" y="6" width="16" height="12" rx="1" stroke-linejoin="round"/>
|
|
11
|
-
</svg>`, C = `<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
12
|
-
<path stroke-linecap="round" stroke-linejoin="round" d="M5 19L19 5m0 0h-8m8 0v8"/>
|
|
13
|
-
</svg>`, y = `<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
14
|
-
<path stroke-linecap="round" stroke-linejoin="round" d="M12 20h9M16.5 3.5a2.121 2.121 0 013 3L7 19l-4 1 1-4L16.5 3.5z"/>
|
|
15
|
-
</svg>`, q = `<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
16
|
-
<path stroke-linecap="round" stroke-linejoin="round" d="M12 3s6 6.4 6 10a6 6 0 01-12 0c0-3.6 6-10 6-10z"/>
|
|
17
|
-
</svg>`, E = `<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
18
|
-
<path stroke-linecap="round" stroke-linejoin="round" d="M9 14L4 9l5-5M4 9h11a5 5 0 010 10h-4"/>
|
|
19
|
-
</svg>`, L = `<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
20
|
-
<path stroke-linecap="round" stroke-linejoin="round" d="M20 6L9 17l-5-5"/>
|
|
21
|
-
</svg>`, F = `<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
22
|
-
<path stroke-linecap="round" stroke-linejoin="round" d="M12 6v8m0 4h.01"/>
|
|
23
|
-
</svg>`, M = `<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
24
|
-
<path stroke-linecap="round" stroke-linejoin="round" d="M6 6l12 12M18 6L6 18"/>
|
|
25
|
-
</svg>`;
|
|
26
|
-
function r(n, t, e) {
|
|
27
|
-
const o = document.createElement(n);
|
|
28
|
-
if (t)
|
|
29
|
-
for (const [s, i] of Object.entries(t))
|
|
30
|
-
s === "className" ? o.className = i : o.setAttribute(s, i);
|
|
31
|
-
return o;
|
|
32
|
-
}
|
|
33
|
-
function K(n = 640) {
|
|
34
|
-
return typeof window < "u" && window.innerWidth < n;
|
|
35
|
-
}
|
|
36
|
-
function z(n, t, e) {
|
|
37
|
-
const o = e.map((i) => i.style.visibility);
|
|
38
|
-
e.forEach((i) => i.style.visibility = "hidden");
|
|
39
|
-
const s = document.elementFromPoint(n, t);
|
|
40
|
-
return e.forEach((i, a) => i.style.visibility = o[a]), s;
|
|
41
|
-
}
|
|
42
|
-
function V(n) {
|
|
43
|
-
return n ? n.hasAttribute("data-qaid-embed") || n.hasAttribute("data-qaid-embed-overlay") ? !0 : !!n.closest("[data-qaid-embed], [data-qaid-embed-overlay]") : !1;
|
|
44
|
-
}
|
|
45
|
-
function Y(n, t = 0) {
|
|
46
|
-
const e = n.getBoundingClientRect();
|
|
47
|
-
return {
|
|
48
|
-
x: e.left - t,
|
|
49
|
-
y: e.top - t,
|
|
50
|
-
width: e.width + t * 2,
|
|
51
|
-
height: e.height + t * 2
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
const h = 12, B = "#ef4444", A = ["#ef4444", "#f59e0b", "#22c55e", "#3b82f6", "#111827", "#ffffff"], I = {
|
|
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 = {
|
|
55
3
|
"#ef4444": "red",
|
|
56
4
|
"#f59e0b": "amber",
|
|
57
5
|
"#22c55e": "green",
|
|
@@ -63,10 +11,10 @@ const h = 12, B = "#ef4444", A = ["#ef4444", "#f59e0b", "#22c55e", "#3b82f6", "#
|
|
|
63
11
|
"#6365f1": "indigo",
|
|
64
12
|
"#6366f1": "indigo"
|
|
65
13
|
};
|
|
66
|
-
function
|
|
67
|
-
return
|
|
14
|
+
function b(n) {
|
|
15
|
+
return T[n.toLowerCase()] ?? n;
|
|
68
16
|
}
|
|
69
|
-
const
|
|
17
|
+
const B = 4, D = 0.8, I = {
|
|
70
18
|
title: "Annotate screenshot",
|
|
71
19
|
instructions: "Draw on the screenshot to highlight or hide details, then choose Done to attach it or Skip to send the original.",
|
|
72
20
|
rectangle: "Rectangle",
|
|
@@ -91,18 +39,18 @@ function P(n) {
|
|
|
91
39
|
const t = u(n.points[0], n.points[1]);
|
|
92
40
|
return t.w < 3 && t.h < 3;
|
|
93
41
|
}
|
|
94
|
-
function
|
|
42
|
+
function M(n, t, e, o) {
|
|
95
43
|
n.beginPath(), n.moveTo(t.x, t.y), n.lineTo(e.x, e.y), n.stroke();
|
|
96
|
-
const
|
|
44
|
+
const i = Math.atan2(e.y - t.y, e.x - t.x), s = Math.max(10, o * 3);
|
|
97
45
|
n.beginPath(), n.moveTo(e.x, e.y), n.lineTo(
|
|
98
|
-
e.x -
|
|
99
|
-
e.y -
|
|
46
|
+
e.x - s * Math.cos(i - Math.PI / 6),
|
|
47
|
+
e.y - s * Math.sin(i - Math.PI / 6)
|
|
100
48
|
), n.moveTo(e.x, e.y), n.lineTo(
|
|
101
|
-
e.x -
|
|
102
|
-
e.y -
|
|
49
|
+
e.x - s * Math.cos(i + Math.PI / 6),
|
|
50
|
+
e.y - s * Math.sin(i + Math.PI / 6)
|
|
103
51
|
), n.stroke();
|
|
104
52
|
}
|
|
105
|
-
function
|
|
53
|
+
function R(n, t) {
|
|
106
54
|
if (t.length !== 0) {
|
|
107
55
|
n.beginPath(), n.moveTo(t[0].x, t[0].y);
|
|
108
56
|
for (let e = 1; e < t.length; e++)
|
|
@@ -110,15 +58,15 @@ function O(n, t) {
|
|
|
110
58
|
n.stroke();
|
|
111
59
|
}
|
|
112
60
|
}
|
|
113
|
-
function
|
|
114
|
-
n.fillStyle = "rgb(15, 23, 42)", n.fillRect(t, e, o,
|
|
115
|
-
for (let
|
|
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)
|
|
116
64
|
for (let a = t; a < t + o; a += h)
|
|
117
|
-
(Math.floor((a - t) / h) + Math.floor((
|
|
65
|
+
(Math.floor((a - t) / h) + Math.floor((s - e) / h)) % 2 === 0 && n.fillRect(
|
|
118
66
|
a,
|
|
119
|
-
|
|
67
|
+
s,
|
|
120
68
|
Math.min(h, t + o - a),
|
|
121
|
-
Math.min(h, e +
|
|
69
|
+
Math.min(h, e + i - s)
|
|
122
70
|
);
|
|
123
71
|
}
|
|
124
72
|
function p(n, t) {
|
|
@@ -129,44 +77,44 @@ function p(n, t) {
|
|
|
129
77
|
break;
|
|
130
78
|
}
|
|
131
79
|
case "arrow":
|
|
132
|
-
|
|
80
|
+
M(n, t.points[0], t.points[1], t.strokeWidth);
|
|
133
81
|
break;
|
|
134
82
|
case "pen":
|
|
135
|
-
|
|
83
|
+
R(n, t.points);
|
|
136
84
|
break;
|
|
137
85
|
case "blur": {
|
|
138
86
|
const e = u(t.points[0], t.points[1]);
|
|
139
|
-
|
|
87
|
+
S(n, e.x, e.y, e.w, e.h);
|
|
140
88
|
break;
|
|
141
89
|
}
|
|
142
90
|
}
|
|
143
91
|
n.restore();
|
|
144
92
|
}
|
|
145
|
-
function
|
|
93
|
+
function f(n) {
|
|
146
94
|
return new Promise((t, e) => {
|
|
147
95
|
const o = new Image();
|
|
148
96
|
o.onload = () => t(o), o.onerror = () => e(new Error("Failed to load screenshot")), o.src = n;
|
|
149
97
|
});
|
|
150
98
|
}
|
|
151
|
-
async function
|
|
99
|
+
async function _(n, t, e = {}) {
|
|
152
100
|
const o = e.quality ?? D;
|
|
153
|
-
let
|
|
101
|
+
let i;
|
|
154
102
|
try {
|
|
155
|
-
|
|
103
|
+
i = await f(n);
|
|
156
104
|
} catch {
|
|
157
105
|
return n;
|
|
158
106
|
}
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
const a =
|
|
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");
|
|
162
110
|
if (!a) return n;
|
|
163
|
-
a.drawImage(
|
|
111
|
+
a.drawImage(i, 0, 0, s.width, s.height);
|
|
164
112
|
for (const c of t)
|
|
165
113
|
p(a, c);
|
|
166
|
-
return
|
|
114
|
+
return s.toDataURL("image/webp", o);
|
|
167
115
|
}
|
|
168
116
|
let N = 0;
|
|
169
|
-
class
|
|
117
|
+
class U {
|
|
170
118
|
shapes = [];
|
|
171
119
|
tool = "rect";
|
|
172
120
|
opts;
|
|
@@ -188,7 +136,7 @@ class f {
|
|
|
188
136
|
// after the editor is mounted).
|
|
189
137
|
resolveResult;
|
|
190
138
|
constructor(t) {
|
|
191
|
-
this.opts = t, this.labels = { ...
|
|
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;
|
|
192
140
|
}
|
|
193
141
|
/** Mount the editor and resolve when the user commits (Done) or skips. */
|
|
194
142
|
open() {
|
|
@@ -198,7 +146,7 @@ class f {
|
|
|
198
146
|
return this.mount(), t;
|
|
199
147
|
}
|
|
200
148
|
toolButton(t, e, o) {
|
|
201
|
-
const
|
|
149
|
+
const i = r("button", {
|
|
202
150
|
type: "button",
|
|
203
151
|
class: "qaid-annotate-tool",
|
|
204
152
|
"data-qaid-tool": t,
|
|
@@ -206,11 +154,11 @@ class f {
|
|
|
206
154
|
"aria-label": `${o} tool`,
|
|
207
155
|
title: o
|
|
208
156
|
});
|
|
209
|
-
return
|
|
157
|
+
return i.innerHTML = `${e}<span class="qaid-annotate-btn-text">${o}</span>`, i;
|
|
210
158
|
}
|
|
211
159
|
/** A round colour swatch button for the toolbar's colour group. */
|
|
212
160
|
swatchButton(t) {
|
|
213
|
-
const e =
|
|
161
|
+
const e = b(t), o = r("button", {
|
|
214
162
|
type: "button",
|
|
215
163
|
class: "qaid-annotate-swatch",
|
|
216
164
|
"data-qaid-color": t,
|
|
@@ -220,15 +168,15 @@ class f {
|
|
|
220
168
|
});
|
|
221
169
|
return o.style.setProperty("--qaid-swatch", t), o;
|
|
222
170
|
}
|
|
223
|
-
actionButton(t, e, o,
|
|
224
|
-
const
|
|
171
|
+
actionButton(t, e, o, i) {
|
|
172
|
+
const s = r("button", {
|
|
225
173
|
type: "button",
|
|
226
|
-
class: `qaid-annotate-action ${
|
|
174
|
+
class: `qaid-annotate-action ${i}`,
|
|
227
175
|
"data-qaid-action": t,
|
|
228
176
|
"aria-label": o,
|
|
229
177
|
title: o
|
|
230
178
|
});
|
|
231
|
-
return
|
|
179
|
+
return s.innerHTML = `${e}<span class="qaid-annotate-btn-text">${o}</span>`, s;
|
|
232
180
|
}
|
|
233
181
|
mount() {
|
|
234
182
|
const t = `${this.uid}-title`, e = `${this.uid}-desc`;
|
|
@@ -238,31 +186,31 @@ class f {
|
|
|
238
186
|
class: "qaid-annotate-title"
|
|
239
187
|
});
|
|
240
188
|
o.textContent = this.labels.title;
|
|
241
|
-
const
|
|
189
|
+
const i = r("p", {
|
|
242
190
|
id: e,
|
|
243
191
|
class: "qaid-annotate-desc"
|
|
244
192
|
});
|
|
245
|
-
|
|
246
|
-
const
|
|
247
|
-
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"),
|
|
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", {
|
|
248
196
|
class: "qaid-annotate-toolbar",
|
|
249
197
|
role: "toolbar",
|
|
250
198
|
"aria-label": this.labels.title
|
|
251
199
|
});
|
|
252
200
|
const a = r("div", { class: "qaid-annotate-tools" });
|
|
253
|
-
a.appendChild(this.toolButton("rect",
|
|
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));
|
|
254
202
|
const c = r("div", {
|
|
255
203
|
class: "qaid-annotate-colors",
|
|
256
204
|
role: "group",
|
|
257
205
|
"aria-label": this.labels.colors
|
|
258
206
|
});
|
|
259
207
|
for (const l of this.palette) c.appendChild(this.swatchButton(l));
|
|
260
|
-
this.undoBtn = this.actionButton("undo",
|
|
261
|
-
const
|
|
262
|
-
d.appendChild(this.undoBtn), d.appendChild(
|
|
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, {
|
|
263
211
|
labelledbyId: t,
|
|
264
212
|
describedbyId: e
|
|
265
|
-
}), this.opts.announce?.(this.labels.instructions),
|
|
213
|
+
}), this.opts.announce?.(this.labels.instructions), f(this.opts.dataUrl).then((l) => {
|
|
266
214
|
this.img = l, this.canvas.width = l.naturalWidth || l.width || 1, this.canvas.height = l.naturalHeight || l.height || 1, this.redraw();
|
|
267
215
|
}).catch(() => {
|
|
268
216
|
this.img = null, this.redraw();
|
|
@@ -270,10 +218,10 @@ class f {
|
|
|
270
218
|
}
|
|
271
219
|
/** Convert a pointer event's client coordinates into natural image pixels. */
|
|
272
220
|
toImageCoords(t) {
|
|
273
|
-
const e = this.canvas.getBoundingClientRect(), o = this.canvas.width / (e.width || this.canvas.width),
|
|
221
|
+
const e = this.canvas.getBoundingClientRect(), o = this.canvas.width / (e.width || this.canvas.width), i = this.canvas.height / (e.height || this.canvas.height);
|
|
274
222
|
return {
|
|
275
223
|
x: (t.clientX - e.left) * o,
|
|
276
|
-
y: (t.clientY - e.top) *
|
|
224
|
+
y: (t.clientY - e.top) * i
|
|
277
225
|
};
|
|
278
226
|
}
|
|
279
227
|
/** Repaint the display canvas: base image (if loaded) then every shape. */
|
|
@@ -288,13 +236,13 @@ class f {
|
|
|
288
236
|
}
|
|
289
237
|
/** Select the active drawing tool and reflect it on the toolbar. */
|
|
290
238
|
selectTool(t) {
|
|
291
|
-
this.tool = t, this.toolbar.querySelectorAll("[data-qaid-tool]").forEach((
|
|
292
|
-
|
|
239
|
+
this.tool = t, this.toolbar.querySelectorAll("[data-qaid-tool]").forEach((i) => {
|
|
240
|
+
i.setAttribute(
|
|
293
241
|
"aria-pressed",
|
|
294
|
-
|
|
242
|
+
i.getAttribute("data-qaid-tool") === t ? "true" : "false"
|
|
295
243
|
);
|
|
296
244
|
});
|
|
297
|
-
const o = this.labels[
|
|
245
|
+
const o = this.labels[O[t]];
|
|
298
246
|
this.opts.announce?.(`${o} tool selected`);
|
|
299
247
|
}
|
|
300
248
|
/** Set the active drawing colour; subsequent shapes use it. */
|
|
@@ -304,21 +252,21 @@ class f {
|
|
|
304
252
|
"aria-pressed",
|
|
305
253
|
(o.getAttribute("data-qaid-color") ?? "").toLowerCase() === t.toLowerCase() ? "true" : "false"
|
|
306
254
|
);
|
|
307
|
-
}), this.opts.announce?.(`${
|
|
255
|
+
}), this.opts.announce?.(`${b(t)} colour selected`);
|
|
308
256
|
}
|
|
309
257
|
onToolbarClick = (t) => {
|
|
310
258
|
const o = t.target?.closest(
|
|
311
259
|
"[data-qaid-tool],[data-qaid-action],[data-qaid-color]"
|
|
312
260
|
);
|
|
313
261
|
if (!o) return;
|
|
314
|
-
const
|
|
315
|
-
if (
|
|
316
|
-
this.selectColor(
|
|
262
|
+
const i = o.getAttribute("data-qaid-color");
|
|
263
|
+
if (i) {
|
|
264
|
+
this.selectColor(i);
|
|
317
265
|
return;
|
|
318
266
|
}
|
|
319
|
-
const
|
|
320
|
-
if (
|
|
321
|
-
this.selectTool(
|
|
267
|
+
const s = o.getAttribute("data-qaid-tool");
|
|
268
|
+
if (s) {
|
|
269
|
+
this.selectTool(s);
|
|
322
270
|
return;
|
|
323
271
|
}
|
|
324
272
|
const a = o.getAttribute("data-qaid-action");
|
|
@@ -372,7 +320,7 @@ class f {
|
|
|
372
320
|
/** Composite the annotations and resolve with the new WebP data URL. */
|
|
373
321
|
async done() {
|
|
374
322
|
if (this.settled) return;
|
|
375
|
-
const t = await
|
|
323
|
+
const t = await _(this.opts.dataUrl, this.shapes, {
|
|
376
324
|
quality: this.opts.quality
|
|
377
325
|
});
|
|
378
326
|
this.opts.announce?.("Annotated screenshot attached"), this.settle(t);
|
|
@@ -388,34 +336,20 @@ class f {
|
|
|
388
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();
|
|
389
337
|
}
|
|
390
338
|
}
|
|
391
|
-
const
|
|
339
|
+
const O = {
|
|
392
340
|
rect: "rectangle",
|
|
393
341
|
arrow: "arrow",
|
|
394
342
|
pen: "pen",
|
|
395
343
|
blur: "blur"
|
|
396
344
|
};
|
|
397
|
-
function
|
|
398
|
-
return new
|
|
345
|
+
function $(n) {
|
|
346
|
+
return new U(n).open();
|
|
399
347
|
}
|
|
400
|
-
const X = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
401
|
-
__proto__: null,
|
|
402
|
-
AnnotationEditor: f,
|
|
403
|
-
compositeAnnotations: g,
|
|
404
|
-
drawShape: p,
|
|
405
|
-
openAnnotationEditor: U,
|
|
406
|
-
rectFromPoints: u
|
|
407
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
408
348
|
export {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
$ as
|
|
413
|
-
|
|
414
|
-
W as a,
|
|
415
|
-
V as b,
|
|
416
|
-
z as c,
|
|
417
|
-
X as d,
|
|
418
|
-
Y as g,
|
|
419
|
-
K as i
|
|
349
|
+
U as AnnotationEditor,
|
|
350
|
+
_ as compositeAnnotations,
|
|
351
|
+
p as drawShape,
|
|
352
|
+
$ as openAnnotationEditor,
|
|
353
|
+
u as rectFromPoints
|
|
420
354
|
};
|
|
421
|
-
//# sourceMappingURL=annotate-
|
|
355
|
+
//# sourceMappingURL=annotate-BTLeFQa0.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,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