react-linear-feedback 0.2.0 → 0.3.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.
@@ -0,0 +1,2695 @@
1
+ // node_modules/preact/dist/preact.module.js
2
+ var n;
3
+ var l;
4
+ var u;
5
+ var t;
6
+ var i;
7
+ var r;
8
+ var o;
9
+ var e;
10
+ var f;
11
+ var c;
12
+ var a;
13
+ var s;
14
+ var h;
15
+ var p;
16
+ var v;
17
+ var y;
18
+ var d = {};
19
+ var w = [];
20
+ var _ = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;
21
+ var g = Array.isArray;
22
+ function m(n2, l3) {
23
+ for (var u4 in l3) n2[u4] = l3[u4];
24
+ return n2;
25
+ }
26
+ function b(n2) {
27
+ n2 && n2.parentNode && n2.parentNode.removeChild(n2);
28
+ }
29
+ function k(l3, u4, t3) {
30
+ var i3, r3, o3, e3 = {};
31
+ for (o3 in u4) "key" == o3 ? i3 = u4[o3] : "ref" == o3 ? r3 = u4[o3] : e3[o3] = u4[o3];
32
+ if (arguments.length > 2 && (e3.children = arguments.length > 3 ? n.call(arguments, 2) : t3), "function" == typeof l3 && null != l3.defaultProps) for (o3 in l3.defaultProps) void 0 === e3[o3] && (e3[o3] = l3.defaultProps[o3]);
33
+ return x(l3, e3, i3, r3, null);
34
+ }
35
+ function x(n2, t3, i3, r3, o3) {
36
+ var e3 = { type: n2, props: t3, key: i3, ref: r3, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: null == o3 ? ++u : o3, __i: -1, __u: 0 };
37
+ return null == o3 && null != l.vnode && l.vnode(e3), e3;
38
+ }
39
+ function S(n2) {
40
+ return n2.children;
41
+ }
42
+ function C(n2, l3) {
43
+ this.props = n2, this.context = l3;
44
+ }
45
+ function $(n2, l3) {
46
+ if (null == l3) return n2.__ ? $(n2.__, n2.__i + 1) : null;
47
+ for (var u4; l3 < n2.__k.length; l3++) if (null != (u4 = n2.__k[l3]) && null != u4.__e) return u4.__e;
48
+ return "function" == typeof n2.type ? $(n2) : null;
49
+ }
50
+ function I(n2) {
51
+ if (n2.__P && n2.__d) {
52
+ var u4 = n2.__v, t3 = u4.__e, i3 = [], r3 = [], o3 = m({}, u4);
53
+ o3.__v = u4.__v + 1, l.vnode && l.vnode(o3), q(n2.__P, o3, u4, n2.__n, n2.__P.namespaceURI, 32 & u4.__u ? [t3] : null, i3, null == t3 ? $(u4) : t3, !!(32 & u4.__u), r3), o3.__v = u4.__v, o3.__.__k[o3.__i] = o3, D(i3, o3, r3), u4.__e = u4.__ = null, o3.__e != t3 && P(o3);
54
+ }
55
+ }
56
+ function P(n2) {
57
+ if (null != (n2 = n2.__) && null != n2.__c) return n2.__e = n2.__c.base = null, n2.__k.some(function(l3) {
58
+ if (null != l3 && null != l3.__e) return n2.__e = n2.__c.base = l3.__e;
59
+ }), P(n2);
60
+ }
61
+ function A(n2) {
62
+ (!n2.__d && (n2.__d = true) && i.push(n2) && !H.__r++ || r != l.debounceRendering) && ((r = l.debounceRendering) || o)(H);
63
+ }
64
+ function H() {
65
+ try {
66
+ for (var n2, l3 = 1; i.length; ) i.length > l3 && i.sort(e), n2 = i.shift(), l3 = i.length, I(n2);
67
+ } finally {
68
+ i.length = H.__r = 0;
69
+ }
70
+ }
71
+ function L(n2, l3, u4, t3, i3, r3, o3, e3, f4, c3, a3) {
72
+ var s3, h3, p3, v3, y3, _3, g4, m3 = t3 && t3.__k || w, b2 = l3.length;
73
+ for (f4 = T(u4, l3, m3, f4, b2), s3 = 0; s3 < b2; s3++) null != (p3 = u4.__k[s3]) && (h3 = -1 != p3.__i && m3[p3.__i] || d, p3.__i = s3, _3 = q(n2, p3, h3, i3, r3, o3, e3, f4, c3, a3), v3 = p3.__e, p3.ref && h3.ref != p3.ref && (h3.ref && J(h3.ref, null, p3), a3.push(p3.ref, p3.__c || v3, p3)), null == y3 && null != v3 && (y3 = v3), (g4 = !!(4 & p3.__u)) || h3.__k === p3.__k ? (f4 = j(p3, f4, n2, g4), g4 && h3.__e && (h3.__e = null)) : "function" == typeof p3.type && void 0 !== _3 ? f4 = _3 : v3 && (f4 = v3.nextSibling), p3.__u &= -7);
74
+ return u4.__e = y3, f4;
75
+ }
76
+ function T(n2, l3, u4, t3, i3) {
77
+ var r3, o3, e3, f4, c3, a3 = u4.length, s3 = a3, h3 = 0;
78
+ for (n2.__k = new Array(i3), r3 = 0; r3 < i3; r3++) null != (o3 = l3[r3]) && "boolean" != typeof o3 && "function" != typeof o3 ? ("string" == typeof o3 || "number" == typeof o3 || "bigint" == typeof o3 || o3.constructor == String ? o3 = n2.__k[r3] = x(null, o3, null, null, null) : g(o3) ? o3 = n2.__k[r3] = x(S, { children: o3 }, null, null, null) : void 0 === o3.constructor && o3.__b > 0 ? o3 = n2.__k[r3] = x(o3.type, o3.props, o3.key, o3.ref ? o3.ref : null, o3.__v) : n2.__k[r3] = o3, f4 = r3 + h3, o3.__ = n2, o3.__b = n2.__b + 1, e3 = null, -1 != (c3 = o3.__i = O(o3, u4, f4, s3)) && (s3--, (e3 = u4[c3]) && (e3.__u |= 2)), null == e3 || null == e3.__v ? (-1 == c3 && (i3 > a3 ? h3-- : i3 < a3 && h3++), "function" != typeof o3.type && (o3.__u |= 4)) : c3 != f4 && (c3 == f4 - 1 ? h3-- : c3 == f4 + 1 ? h3++ : (c3 > f4 ? h3-- : h3++, o3.__u |= 4))) : n2.__k[r3] = null;
79
+ if (s3) for (r3 = 0; r3 < a3; r3++) null != (e3 = u4[r3]) && 0 == (2 & e3.__u) && (e3.__e == t3 && (t3 = $(e3)), K(e3, e3));
80
+ return t3;
81
+ }
82
+ function j(n2, l3, u4, t3) {
83
+ var i3, r3;
84
+ if ("function" == typeof n2.type) {
85
+ for (i3 = n2.__k, r3 = 0; i3 && r3 < i3.length; r3++) i3[r3] && (i3[r3].__ = n2, l3 = j(i3[r3], l3, u4, t3));
86
+ return l3;
87
+ }
88
+ n2.__e != l3 && (t3 && (l3 && n2.type && !l3.parentNode && (l3 = $(n2)), u4.insertBefore(n2.__e, l3 || null)), l3 = n2.__e);
89
+ do {
90
+ l3 = l3 && l3.nextSibling;
91
+ } while (null != l3 && 8 == l3.nodeType);
92
+ return l3;
93
+ }
94
+ function F(n2, l3) {
95
+ return l3 = l3 || [], null == n2 || "boolean" == typeof n2 || (g(n2) ? n2.some(function(n3) {
96
+ F(n3, l3);
97
+ }) : l3.push(n2)), l3;
98
+ }
99
+ function O(n2, l3, u4, t3) {
100
+ var i3, r3, o3, e3 = n2.key, f4 = n2.type, c3 = l3[u4], a3 = null != c3 && 0 == (2 & c3.__u);
101
+ if (null === c3 && null == e3 || a3 && e3 == c3.key && f4 == c3.type) return u4;
102
+ if (t3 > (a3 ? 1 : 0)) {
103
+ for (i3 = u4 - 1, r3 = u4 + 1; i3 >= 0 || r3 < l3.length; ) if (null != (c3 = l3[o3 = i3 >= 0 ? i3-- : r3++]) && 0 == (2 & c3.__u) && e3 == c3.key && f4 == c3.type) return o3;
104
+ }
105
+ return -1;
106
+ }
107
+ function z(n2, l3, u4) {
108
+ "-" == l3[0] ? n2.setProperty(l3, null == u4 ? "" : u4) : n2[l3] = null == u4 ? "" : "number" != typeof u4 || _.test(l3) ? u4 : u4 + "px";
109
+ }
110
+ function N(n2, l3, u4, t3, i3) {
111
+ var r3, o3;
112
+ n: if ("style" == l3) if ("string" == typeof u4) n2.style.cssText = u4;
113
+ else {
114
+ if ("string" == typeof t3 && (n2.style.cssText = t3 = ""), t3) for (l3 in t3) u4 && l3 in u4 || z(n2.style, l3, "");
115
+ if (u4) for (l3 in u4) t3 && u4[l3] == t3[l3] || z(n2.style, l3, u4[l3]);
116
+ }
117
+ else if ("o" == l3[0] && "n" == l3[1]) r3 = l3 != (l3 = l3.replace(s, "$1")), o3 = l3.toLowerCase(), l3 = o3 in n2 || "onFocusOut" == l3 || "onFocusIn" == l3 ? o3.slice(2) : l3.slice(2), n2.l || (n2.l = {}), n2.l[l3 + r3] = u4, u4 ? t3 ? u4[a] = t3[a] : (u4[a] = h, n2.addEventListener(l3, r3 ? v : p, r3)) : n2.removeEventListener(l3, r3 ? v : p, r3);
118
+ else {
119
+ if ("http://www.w3.org/2000/svg" == i3) l3 = l3.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
120
+ else if ("width" != l3 && "height" != l3 && "href" != l3 && "list" != l3 && "form" != l3 && "tabIndex" != l3 && "download" != l3 && "rowSpan" != l3 && "colSpan" != l3 && "role" != l3 && "popover" != l3 && l3 in n2) try {
121
+ n2[l3] = null == u4 ? "" : u4;
122
+ break n;
123
+ } catch (n3) {
124
+ }
125
+ "function" == typeof u4 || (null == u4 || false === u4 && "-" != l3[4] ? n2.removeAttribute(l3) : n2.setAttribute(l3, "popover" == l3 && 1 == u4 ? "" : u4));
126
+ }
127
+ }
128
+ function V(n2) {
129
+ return function(u4) {
130
+ if (this.l) {
131
+ var t3 = this.l[u4.type + n2];
132
+ if (null == u4[c]) u4[c] = h++;
133
+ else if (u4[c] < t3[a]) return;
134
+ return t3(l.event ? l.event(u4) : u4);
135
+ }
136
+ };
137
+ }
138
+ function q(n2, u4, t3, i3, r3, o3, e3, f4, c3, a3) {
139
+ var s3, h3, p3, v3, y3, d3, _3, k3, x3, M3, $2, I2, P4, A4, H3, T4 = u4.type;
140
+ if (void 0 !== u4.constructor) return null;
141
+ 128 & t3.__u && (c3 = !!(32 & t3.__u), o3 = [f4 = u4.__e = t3.__e]), (s3 = l.__b) && s3(u4);
142
+ n: if ("function" == typeof T4) try {
143
+ if (k3 = u4.props, x3 = T4.prototype && T4.prototype.render, M3 = (s3 = T4.contextType) && i3[s3.__c], $2 = s3 ? M3 ? M3.props.value : s3.__ : i3, t3.__c ? _3 = (h3 = u4.__c = t3.__c).__ = h3.__E : (x3 ? u4.__c = h3 = new T4(k3, $2) : (u4.__c = h3 = new C(k3, $2), h3.constructor = T4, h3.render = Q), M3 && M3.sub(h3), h3.state || (h3.state = {}), h3.__n = i3, p3 = h3.__d = true, h3.__h = [], h3._sb = []), x3 && null == h3.__s && (h3.__s = h3.state), x3 && null != T4.getDerivedStateFromProps && (h3.__s == h3.state && (h3.__s = m({}, h3.__s)), m(h3.__s, T4.getDerivedStateFromProps(k3, h3.__s))), v3 = h3.props, y3 = h3.state, h3.__v = u4, p3) x3 && null == T4.getDerivedStateFromProps && null != h3.componentWillMount && h3.componentWillMount(), x3 && null != h3.componentDidMount && h3.__h.push(h3.componentDidMount);
144
+ else {
145
+ if (x3 && null == T4.getDerivedStateFromProps && k3 !== v3 && null != h3.componentWillReceiveProps && h3.componentWillReceiveProps(k3, $2), u4.__v == t3.__v || !h3.__e && null != h3.shouldComponentUpdate && false === h3.shouldComponentUpdate(k3, h3.__s, $2)) {
146
+ u4.__v != t3.__v && (h3.props = k3, h3.state = h3.__s, h3.__d = false), u4.__e = t3.__e, u4.__k = t3.__k, u4.__k.some(function(n3) {
147
+ n3 && (n3.__ = u4);
148
+ }), w.push.apply(h3.__h, h3._sb), h3._sb = [], h3.__h.length && e3.push(h3);
149
+ break n;
150
+ }
151
+ null != h3.componentWillUpdate && h3.componentWillUpdate(k3, h3.__s, $2), x3 && null != h3.componentDidUpdate && h3.__h.push(function() {
152
+ h3.componentDidUpdate(v3, y3, d3);
153
+ });
154
+ }
155
+ if (h3.context = $2, h3.props = k3, h3.__P = n2, h3.__e = false, I2 = l.__r, P4 = 0, x3) h3.state = h3.__s, h3.__d = false, I2 && I2(u4), s3 = h3.render(h3.props, h3.state, h3.context), w.push.apply(h3.__h, h3._sb), h3._sb = [];
156
+ else do {
157
+ h3.__d = false, I2 && I2(u4), s3 = h3.render(h3.props, h3.state, h3.context), h3.state = h3.__s;
158
+ } while (h3.__d && ++P4 < 25);
159
+ h3.state = h3.__s, null != h3.getChildContext && (i3 = m(m({}, i3), h3.getChildContext())), x3 && !p3 && null != h3.getSnapshotBeforeUpdate && (d3 = h3.getSnapshotBeforeUpdate(v3, y3)), A4 = null != s3 && s3.type === S && null == s3.key ? E(s3.props.children) : s3, f4 = L(n2, g(A4) ? A4 : [A4], u4, t3, i3, r3, o3, e3, f4, c3, a3), h3.base = u4.__e, u4.__u &= -161, h3.__h.length && e3.push(h3), _3 && (h3.__E = h3.__ = null);
160
+ } catch (n3) {
161
+ if (u4.__v = null, c3 || null != o3) if (n3.then) {
162
+ for (u4.__u |= c3 ? 160 : 128; f4 && 8 == f4.nodeType && f4.nextSibling; ) f4 = f4.nextSibling;
163
+ o3[o3.indexOf(f4)] = null, u4.__e = f4;
164
+ } else {
165
+ for (H3 = o3.length; H3--; ) b(o3[H3]);
166
+ B(u4);
167
+ }
168
+ else u4.__e = t3.__e, u4.__k = t3.__k, n3.then || B(u4);
169
+ l.__e(n3, u4, t3);
170
+ }
171
+ else null == o3 && u4.__v == t3.__v ? (u4.__k = t3.__k, u4.__e = t3.__e) : f4 = u4.__e = G(t3.__e, u4, t3, i3, r3, o3, e3, c3, a3);
172
+ return (s3 = l.diffed) && s3(u4), 128 & u4.__u ? void 0 : f4;
173
+ }
174
+ function B(n2) {
175
+ n2 && (n2.__c && (n2.__c.__e = true), n2.__k && n2.__k.some(B));
176
+ }
177
+ function D(n2, u4, t3) {
178
+ for (var i3 = 0; i3 < t3.length; i3++) J(t3[i3], t3[++i3], t3[++i3]);
179
+ l.__c && l.__c(u4, n2), n2.some(function(u5) {
180
+ try {
181
+ n2 = u5.__h, u5.__h = [], n2.some(function(n3) {
182
+ n3.call(u5);
183
+ });
184
+ } catch (n3) {
185
+ l.__e(n3, u5.__v);
186
+ }
187
+ });
188
+ }
189
+ function E(n2) {
190
+ return "object" != typeof n2 || null == n2 || n2.__b > 0 ? n2 : g(n2) ? n2.map(E) : void 0 !== n2.constructor ? null : m({}, n2);
191
+ }
192
+ function G(u4, t3, i3, r3, o3, e3, f4, c3, a3) {
193
+ var s3, h3, p3, v3, y3, w3, _3, m3 = i3.props || d, k3 = t3.props, x3 = t3.type;
194
+ if ("svg" == x3 ? o3 = "http://www.w3.org/2000/svg" : "math" == x3 ? o3 = "http://www.w3.org/1998/Math/MathML" : o3 || (o3 = "http://www.w3.org/1999/xhtml"), null != e3) {
195
+ for (s3 = 0; s3 < e3.length; s3++) if ((y3 = e3[s3]) && "setAttribute" in y3 == !!x3 && (x3 ? y3.localName == x3 : 3 == y3.nodeType)) {
196
+ u4 = y3, e3[s3] = null;
197
+ break;
198
+ }
199
+ }
200
+ if (null == u4) {
201
+ if (null == x3) return document.createTextNode(k3);
202
+ u4 = document.createElementNS(o3, x3, k3.is && k3), c3 && (l.__m && l.__m(t3, e3), c3 = false), e3 = null;
203
+ }
204
+ if (null == x3) m3 === k3 || c3 && u4.data == k3 || (u4.data = k3);
205
+ else {
206
+ if (e3 = "textarea" == x3 && null != k3.defaultValue ? null : e3 && n.call(u4.childNodes), !c3 && null != e3) for (m3 = {}, s3 = 0; s3 < u4.attributes.length; s3++) m3[(y3 = u4.attributes[s3]).name] = y3.value;
207
+ for (s3 in m3) y3 = m3[s3], "dangerouslySetInnerHTML" == s3 ? p3 = y3 : "children" == s3 || s3 in k3 || "value" == s3 && "defaultValue" in k3 || "checked" == s3 && "defaultChecked" in k3 || N(u4, s3, null, y3, o3);
208
+ for (s3 in k3) y3 = k3[s3], "children" == s3 ? v3 = y3 : "dangerouslySetInnerHTML" == s3 ? h3 = y3 : "value" == s3 ? w3 = y3 : "checked" == s3 ? _3 = y3 : c3 && "function" != typeof y3 || m3[s3] === y3 || N(u4, s3, y3, m3[s3], o3);
209
+ if (h3) c3 || p3 && (h3.__html == p3.__html || h3.__html == u4.innerHTML) || (u4.innerHTML = h3.__html), t3.__k = [];
210
+ else if (p3 && (u4.innerHTML = ""), L("template" == t3.type ? u4.content : u4, g(v3) ? v3 : [v3], t3, i3, r3, "foreignObject" == x3 ? "http://www.w3.org/1999/xhtml" : o3, e3, f4, e3 ? e3[0] : i3.__k && $(i3, 0), c3, a3), null != e3) for (s3 = e3.length; s3--; ) b(e3[s3]);
211
+ c3 && "textarea" != x3 || (s3 = "value", "progress" == x3 && null == w3 ? u4.removeAttribute("value") : null != w3 && (w3 !== u4[s3] || "progress" == x3 && !w3 || "option" == x3 && w3 != m3[s3]) && N(u4, s3, w3, m3[s3], o3), s3 = "checked", null != _3 && _3 != u4[s3] && N(u4, s3, _3, m3[s3], o3));
212
+ }
213
+ return u4;
214
+ }
215
+ function J(n2, u4, t3) {
216
+ try {
217
+ if ("function" == typeof n2) {
218
+ var i3 = "function" == typeof n2.__u;
219
+ i3 && n2.__u(), i3 && null == u4 || (n2.__u = n2(u4));
220
+ } else n2.current = u4;
221
+ } catch (n3) {
222
+ l.__e(n3, t3);
223
+ }
224
+ }
225
+ function K(n2, u4, t3) {
226
+ var i3, r3;
227
+ if (l.unmount && l.unmount(n2), (i3 = n2.ref) && (i3.current && i3.current != n2.__e || J(i3, null, u4)), null != (i3 = n2.__c)) {
228
+ if (i3.componentWillUnmount) try {
229
+ i3.componentWillUnmount();
230
+ } catch (n3) {
231
+ l.__e(n3, u4);
232
+ }
233
+ i3.base = i3.__P = null;
234
+ }
235
+ if (i3 = n2.__k) for (r3 = 0; r3 < i3.length; r3++) i3[r3] && K(i3[r3], u4, t3 || "function" != typeof n2.type);
236
+ t3 || b(n2.__e), n2.__c = n2.__ = n2.__e = void 0;
237
+ }
238
+ function Q(n2, l3, u4) {
239
+ return this.constructor(n2, u4);
240
+ }
241
+ function R(u4, t3, i3) {
242
+ var r3, o3, e3, f4;
243
+ t3 == document && (t3 = document.documentElement), l.__ && l.__(u4, t3), o3 = (r3 = "function" == typeof i3) ? null : i3 && i3.__k || t3.__k, e3 = [], f4 = [], q(t3, u4 = (!r3 && i3 || t3).__k = k(S, null, [u4]), o3 || d, d, t3.namespaceURI, !r3 && i3 ? [i3] : o3 ? null : t3.firstChild ? n.call(t3.childNodes) : null, e3, !r3 && i3 ? i3 : o3 ? o3.__e : t3.firstChild, r3, f4), D(e3, u4, f4);
244
+ }
245
+ n = w.slice, l = { __e: function(n2, l3, u4, t3) {
246
+ for (var i3, r3, o3; l3 = l3.__; ) if ((i3 = l3.__c) && !i3.__) try {
247
+ if ((r3 = i3.constructor) && null != r3.getDerivedStateFromError && (i3.setState(r3.getDerivedStateFromError(n2)), o3 = i3.__d), null != i3.componentDidCatch && (i3.componentDidCatch(n2, t3 || {}), o3 = i3.__d), o3) return i3.__E = i3;
248
+ } catch (l4) {
249
+ n2 = l4;
250
+ }
251
+ throw n2;
252
+ } }, u = 0, t = function(n2) {
253
+ return null != n2 && void 0 === n2.constructor;
254
+ }, C.prototype.setState = function(n2, l3) {
255
+ var u4;
256
+ u4 = null != this.__s && this.__s != this.state ? this.__s : this.__s = m({}, this.state), "function" == typeof n2 && (n2 = n2(m({}, u4), this.props)), n2 && m(u4, n2), null != n2 && this.__v && (l3 && this._sb.push(l3), A(this));
257
+ }, C.prototype.forceUpdate = function(n2) {
258
+ this.__v && (this.__e = true, n2 && this.__h.push(n2), A(this));
259
+ }, C.prototype.render = S, i = [], o = "function" == typeof Promise ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, e = function(n2, l3) {
260
+ return n2.__v.__b - l3.__v.__b;
261
+ }, H.__r = 0, f = Math.random().toString(8), c = "__d" + f, a = "__a" + f, s = /(PointerCapture)$|Capture$/i, h = 0, p = V(false), v = V(true), y = 0;
262
+
263
+ // node_modules/preact/hooks/dist/hooks.module.js
264
+ var t2;
265
+ var r2;
266
+ var u2;
267
+ var i2;
268
+ var o2 = 0;
269
+ var f2 = [];
270
+ var c2 = l;
271
+ var e2 = c2.__b;
272
+ var a2 = c2.__r;
273
+ var v2 = c2.diffed;
274
+ var l2 = c2.__c;
275
+ var m2 = c2.unmount;
276
+ var s2 = c2.__;
277
+ function p2(n2, t3) {
278
+ c2.__h && c2.__h(r2, n2, o2 || t3), o2 = 0;
279
+ var u4 = r2.__H || (r2.__H = { __: [], __h: [] });
280
+ return n2 >= u4.__.length && u4.__.push({}), u4.__[n2];
281
+ }
282
+ function d2(n2) {
283
+ return o2 = 1, h2(D2, n2);
284
+ }
285
+ function h2(n2, u4, i3) {
286
+ var o3 = p2(t2++, 2);
287
+ if (o3.t = n2, !o3.__c && (o3.__ = [i3 ? i3(u4) : D2(void 0, u4), function(n3) {
288
+ var t3 = o3.__N ? o3.__N[0] : o3.__[0], r3 = o3.t(t3, n3);
289
+ t3 !== r3 && (o3.__N = [r3, o3.__[1]], o3.__c.setState({}));
290
+ }], o3.__c = r2, !r2.__f)) {
291
+ var f4 = function(n3, t3, r3) {
292
+ if (!o3.__c.__H) return true;
293
+ var u5 = o3.__c.__H.__.filter(function(n4) {
294
+ return n4.__c;
295
+ });
296
+ if (u5.every(function(n4) {
297
+ return !n4.__N;
298
+ })) return !c3 || c3.call(this, n3, t3, r3);
299
+ var i4 = o3.__c.props !== n3;
300
+ return u5.some(function(n4) {
301
+ if (n4.__N) {
302
+ var t4 = n4.__[0];
303
+ n4.__ = n4.__N, n4.__N = void 0, t4 !== n4.__[0] && (i4 = true);
304
+ }
305
+ }), c3 && c3.call(this, n3, t3, r3) || i4;
306
+ };
307
+ r2.__f = true;
308
+ var c3 = r2.shouldComponentUpdate, e3 = r2.componentWillUpdate;
309
+ r2.componentWillUpdate = function(n3, t3, r3) {
310
+ if (this.__e) {
311
+ var u5 = c3;
312
+ c3 = void 0, f4(n3, t3, r3), c3 = u5;
313
+ }
314
+ e3 && e3.call(this, n3, t3, r3);
315
+ }, r2.shouldComponentUpdate = f4;
316
+ }
317
+ return o3.__N || o3.__;
318
+ }
319
+ function y2(n2, u4) {
320
+ var i3 = p2(t2++, 3);
321
+ !c2.__s && C2(i3.__H, u4) && (i3.__ = n2, i3.u = u4, r2.__H.__h.push(i3));
322
+ }
323
+ function A2(n2) {
324
+ return o2 = 5, T2(function() {
325
+ return { current: n2 };
326
+ }, []);
327
+ }
328
+ function T2(n2, r3) {
329
+ var u4 = p2(t2++, 7);
330
+ return C2(u4.__H, r3) && (u4.__ = n2(), u4.__H = r3, u4.__h = n2), u4.__;
331
+ }
332
+ function j2() {
333
+ for (var n2; n2 = f2.shift(); ) {
334
+ var t3 = n2.__H;
335
+ if (n2.__P && t3) try {
336
+ t3.__h.some(z2), t3.__h.some(B2), t3.__h = [];
337
+ } catch (r3) {
338
+ t3.__h = [], c2.__e(r3, n2.__v);
339
+ }
340
+ }
341
+ }
342
+ c2.__b = function(n2) {
343
+ r2 = null, e2 && e2(n2);
344
+ }, c2.__ = function(n2, t3) {
345
+ n2 && t3.__k && t3.__k.__m && (n2.__m = t3.__k.__m), s2 && s2(n2, t3);
346
+ }, c2.__r = function(n2) {
347
+ a2 && a2(n2), t2 = 0;
348
+ var i3 = (r2 = n2.__c).__H;
349
+ i3 && (u2 === r2 ? (i3.__h = [], r2.__h = [], i3.__.some(function(n3) {
350
+ n3.__N && (n3.__ = n3.__N), n3.u = n3.__N = void 0;
351
+ })) : (i3.__h.some(z2), i3.__h.some(B2), i3.__h = [], t2 = 0)), u2 = r2;
352
+ }, c2.diffed = function(n2) {
353
+ v2 && v2(n2);
354
+ var t3 = n2.__c;
355
+ t3 && t3.__H && (t3.__H.__h.length && (1 !== f2.push(t3) && i2 === c2.requestAnimationFrame || ((i2 = c2.requestAnimationFrame) || w2)(j2)), t3.__H.__.some(function(n3) {
356
+ n3.u && (n3.__H = n3.u), n3.u = void 0;
357
+ })), u2 = r2 = null;
358
+ }, c2.__c = function(n2, t3) {
359
+ t3.some(function(n3) {
360
+ try {
361
+ n3.__h.some(z2), n3.__h = n3.__h.filter(function(n4) {
362
+ return !n4.__ || B2(n4);
363
+ });
364
+ } catch (r3) {
365
+ t3.some(function(n4) {
366
+ n4.__h && (n4.__h = []);
367
+ }), t3 = [], c2.__e(r3, n3.__v);
368
+ }
369
+ }), l2 && l2(n2, t3);
370
+ }, c2.unmount = function(n2) {
371
+ m2 && m2(n2);
372
+ var t3, r3 = n2.__c;
373
+ r3 && r3.__H && (r3.__H.__.some(function(n3) {
374
+ try {
375
+ z2(n3);
376
+ } catch (n4) {
377
+ t3 = n4;
378
+ }
379
+ }), r3.__H = void 0, t3 && c2.__e(t3, r3.__v));
380
+ };
381
+ var k2 = "function" == typeof requestAnimationFrame;
382
+ function w2(n2) {
383
+ var t3, r3 = function() {
384
+ clearTimeout(u4), k2 && cancelAnimationFrame(t3), setTimeout(n2);
385
+ }, u4 = setTimeout(r3, 35);
386
+ k2 && (t3 = requestAnimationFrame(r3));
387
+ }
388
+ function z2(n2) {
389
+ var t3 = r2, u4 = n2.__c;
390
+ "function" == typeof u4 && (n2.__c = void 0, u4()), r2 = t3;
391
+ }
392
+ function B2(n2) {
393
+ var t3 = r2;
394
+ n2.__c = n2.__(), r2 = t3;
395
+ }
396
+ function C2(n2, t3) {
397
+ return !n2 || n2.length !== t3.length || t3.some(function(t4, r3) {
398
+ return t4 !== n2[r3];
399
+ });
400
+ }
401
+ function D2(n2, t3) {
402
+ return "function" == typeof t3 ? t3(n2) : t3;
403
+ }
404
+
405
+ // node_modules/preact/compat/dist/compat.module.js
406
+ function g3(n2, t3) {
407
+ for (var e3 in t3) n2[e3] = t3[e3];
408
+ return n2;
409
+ }
410
+ function E2(n2, t3) {
411
+ for (var e3 in n2) if ("__source" !== e3 && !(e3 in t3)) return true;
412
+ for (var r3 in t3) if ("__source" !== r3 && n2[r3] !== t3[r3]) return true;
413
+ return false;
414
+ }
415
+ function M2(n2, t3) {
416
+ this.props = n2, this.context = t3;
417
+ }
418
+ (M2.prototype = new C()).isPureReactComponent = true, M2.prototype.shouldComponentUpdate = function(n2, t3) {
419
+ return E2(this.props, n2) || E2(this.state, t3);
420
+ };
421
+ var T3 = l.__b;
422
+ l.__b = function(n2) {
423
+ n2.type && n2.type.__f && n2.ref && (n2.props.ref = n2.ref, n2.ref = null), T3 && T3(n2);
424
+ };
425
+ var A3 = "undefined" != typeof Symbol && Symbol.for && /* @__PURE__ */ Symbol.for("react.forward_ref") || 3911;
426
+ var O2 = l.__e;
427
+ l.__e = function(n2, t3, e3, r3) {
428
+ if (n2.then) {
429
+ for (var u4, o3 = t3; o3 = o3.__; ) if ((u4 = o3.__c) && u4.__c) return null == t3.__e && (t3.__e = e3.__e, t3.__k = e3.__k), u4.__c(n2, t3);
430
+ }
431
+ O2(n2, t3, e3, r3);
432
+ };
433
+ var U2 = l.unmount;
434
+ function V2(n2, t3, e3) {
435
+ return n2 && (n2.__c && n2.__c.__H && (n2.__c.__H.__.forEach(function(n3) {
436
+ "function" == typeof n3.__c && n3.__c();
437
+ }), n2.__c.__H = null), null != (n2 = g3({}, n2)).__c && (n2.__c.__P === e3 && (n2.__c.__P = t3), n2.__c.__e = true, n2.__c = null), n2.__k = n2.__k && n2.__k.map(function(n3) {
438
+ return V2(n3, t3, e3);
439
+ })), n2;
440
+ }
441
+ function W2(n2, t3, e3) {
442
+ return n2 && e3 && (n2.__v = null, n2.__k = n2.__k && n2.__k.map(function(n3) {
443
+ return W2(n3, t3, e3);
444
+ }), n2.__c && n2.__c.__P === t3 && (n2.__e && e3.appendChild(n2.__e), n2.__c.__e = true, n2.__c.__P = e3)), n2;
445
+ }
446
+ function P3() {
447
+ this.__u = 0, this.o = null, this.__b = null;
448
+ }
449
+ function j3(n2) {
450
+ var t3 = n2.__ && n2.__.__c;
451
+ return t3 && t3.__a && t3.__a(n2);
452
+ }
453
+ function B3() {
454
+ this.i = null, this.l = null;
455
+ }
456
+ l.unmount = function(n2) {
457
+ var t3 = n2.__c;
458
+ t3 && (t3.__z = true), t3 && t3.__R && t3.__R(), t3 && 32 & n2.__u && (n2.type = null), U2 && U2(n2);
459
+ }, (P3.prototype = new C()).__c = function(n2, t3) {
460
+ var e3 = t3.__c, r3 = this;
461
+ null == r3.o && (r3.o = []), r3.o.push(e3);
462
+ var u4 = j3(r3.__v), o3 = false, i3 = function() {
463
+ o3 || r3.__z || (o3 = true, e3.__R = null, u4 ? u4(c3) : c3());
464
+ };
465
+ e3.__R = i3;
466
+ var l3 = e3.__P;
467
+ e3.__P = null;
468
+ var c3 = function() {
469
+ if (!--r3.__u) {
470
+ if (r3.state.__a) {
471
+ var n3 = r3.state.__a;
472
+ r3.__v.__k[0] = W2(n3, n3.__c.__P, n3.__c.__O);
473
+ }
474
+ var t4;
475
+ for (r3.setState({ __a: r3.__b = null }); t4 = r3.o.pop(); ) t4.__P = l3, t4.forceUpdate();
476
+ }
477
+ };
478
+ r3.__u++ || 32 & t3.__u || r3.setState({ __a: r3.__b = r3.__v.__k[0] }), n2.then(i3, i3);
479
+ }, P3.prototype.componentWillUnmount = function() {
480
+ this.o = [];
481
+ }, P3.prototype.render = function(n2, e3) {
482
+ if (this.__b) {
483
+ if (this.__v.__k) {
484
+ var r3 = document.createElement("div"), o3 = this.__v.__k[0].__c;
485
+ this.__v.__k[0] = V2(this.__b, r3, o3.__O = o3.__P);
486
+ }
487
+ this.__b = null;
488
+ }
489
+ var i3 = e3.__a && k(S, null, n2.fallback);
490
+ return i3 && (i3.__u &= -33), [k(S, null, e3.__a ? null : n2.children), i3];
491
+ };
492
+ var H2 = function(n2, t3, e3) {
493
+ if (++e3[1] === e3[0] && n2.l.delete(t3), n2.props.revealOrder && ("t" !== n2.props.revealOrder[0] || !n2.l.size)) for (e3 = n2.i; e3; ) {
494
+ for (; e3.length > 3; ) e3.pop()();
495
+ if (e3[1] < e3[0]) break;
496
+ n2.i = e3 = e3[2];
497
+ }
498
+ };
499
+ (B3.prototype = new C()).__a = function(n2) {
500
+ var t3 = this, e3 = j3(t3.__v), r3 = t3.l.get(n2);
501
+ return r3[0]++, function(u4) {
502
+ var o3 = function() {
503
+ t3.props.revealOrder ? (r3.push(u4), H2(t3, n2, r3)) : u4();
504
+ };
505
+ e3 ? e3(o3) : o3();
506
+ };
507
+ }, B3.prototype.render = function(n2) {
508
+ this.i = null, this.l = /* @__PURE__ */ new Map();
509
+ var t3 = F(n2.children);
510
+ n2.revealOrder && "b" === n2.revealOrder[0] && t3.reverse();
511
+ for (var e3 = t3.length; e3--; ) this.l.set(t3[e3], this.i = [1, 0, this.i]);
512
+ return n2.children;
513
+ }, B3.prototype.componentDidUpdate = B3.prototype.componentDidMount = function() {
514
+ var n2 = this;
515
+ this.l.forEach(function(t3, e3) {
516
+ H2(n2, e3, t3);
517
+ });
518
+ };
519
+ var q3 = "undefined" != typeof Symbol && Symbol.for && /* @__PURE__ */ Symbol.for("react.element") || 60103;
520
+ var G2 = /^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/;
521
+ var J2 = /^on(Ani|Tra|Tou|BeforeInp|Compo)/;
522
+ var K2 = /[A-Z0-9]/g;
523
+ var Q2 = "undefined" != typeof document;
524
+ var X2 = function(n2) {
525
+ return ("undefined" != typeof Symbol && "symbol" == typeof /* @__PURE__ */ Symbol() ? /fil|che|rad/ : /fil|che|ra/).test(n2);
526
+ };
527
+ function nn(n2, t3, e3) {
528
+ return null == t3.__k && (t3.textContent = ""), R(n2, t3), "function" == typeof e3 && e3(), n2 ? n2.__c : null;
529
+ }
530
+ C.prototype.isReactComponent = true, ["componentWillMount", "componentWillReceiveProps", "componentWillUpdate"].forEach(function(t3) {
531
+ Object.defineProperty(C.prototype, t3, { configurable: true, get: function() {
532
+ return this["UNSAFE_" + t3];
533
+ }, set: function(n2) {
534
+ Object.defineProperty(this, t3, { configurable: true, writable: true, value: n2 });
535
+ } });
536
+ });
537
+ var en = l.event;
538
+ l.event = function(n2) {
539
+ return en && (n2 = en(n2)), n2.persist = function() {
540
+ }, n2.isPropagationStopped = function() {
541
+ return this.cancelBubble;
542
+ }, n2.isDefaultPrevented = function() {
543
+ return this.defaultPrevented;
544
+ }, n2.nativeEvent = n2;
545
+ };
546
+ var rn;
547
+ var un = { configurable: true, get: function() {
548
+ return this.class;
549
+ } };
550
+ var on = l.vnode;
551
+ l.vnode = function(n2) {
552
+ "string" == typeof n2.type && (function(n3) {
553
+ var t3 = n3.props, e3 = n3.type, u4 = {}, o3 = -1 == e3.indexOf("-");
554
+ for (var i3 in t3) {
555
+ var l3 = t3[i3];
556
+ if (!("value" === i3 && "defaultValue" in t3 && null == l3 || Q2 && "children" === i3 && "noscript" === e3 || "class" === i3 || "className" === i3)) {
557
+ var c3 = i3.toLowerCase();
558
+ "defaultValue" === i3 && "value" in t3 && null == t3.value ? i3 = "value" : "download" === i3 && true === l3 ? l3 = "" : "translate" === c3 && "no" === l3 ? l3 = false : "o" === c3[0] && "n" === c3[1] ? "ondoubleclick" === c3 ? i3 = "ondblclick" : "onchange" !== c3 || "input" !== e3 && "textarea" !== e3 || X2(t3.type) ? "onfocus" === c3 ? i3 = "onfocusin" : "onblur" === c3 ? i3 = "onfocusout" : J2.test(i3) && (i3 = c3) : c3 = i3 = "oninput" : o3 && G2.test(i3) ? i3 = i3.replace(K2, "-$&").toLowerCase() : null === l3 && (l3 = void 0), "oninput" === c3 && u4[i3 = c3] && (i3 = "oninputCapture"), u4[i3] = l3;
559
+ }
560
+ }
561
+ "select" == e3 && (u4.multiple && Array.isArray(u4.value) && (u4.value = F(t3.children).forEach(function(n4) {
562
+ n4.props.selected = -1 != u4.value.indexOf(n4.props.value);
563
+ })), null != u4.defaultValue && (u4.value = F(t3.children).forEach(function(n4) {
564
+ n4.props.selected = u4.multiple ? -1 != u4.defaultValue.indexOf(n4.props.value) : u4.defaultValue == n4.props.value;
565
+ }))), t3.class && !t3.className ? (u4.class = t3.class, Object.defineProperty(u4, "className", un)) : t3.className && (u4.class = u4.className = t3.className), n3.props = u4;
566
+ })(n2), n2.$$typeof = q3, on && on(n2);
567
+ };
568
+ var ln = l.__r;
569
+ l.__r = function(n2) {
570
+ ln && ln(n2), rn = n2.__c;
571
+ };
572
+ var cn = l.diffed;
573
+ l.diffed = function(n2) {
574
+ cn && cn(n2);
575
+ var t3 = n2.props, e3 = n2.__e;
576
+ null != e3 && "textarea" === n2.type && "value" in t3 && t3.value !== e3.value && (e3.value = null == t3.value ? "" : t3.value), rn = null;
577
+ };
578
+ function pn(n2) {
579
+ return !!n2.__k && (R(null, n2), true);
580
+ }
581
+
582
+ // node_modules/preact/compat/client.mjs
583
+ function createRoot(container) {
584
+ return {
585
+ // eslint-disable-next-line
586
+ render: function(children) {
587
+ nn(children, container);
588
+ },
589
+ // eslint-disable-next-line
590
+ unmount: function() {
591
+ pn(container);
592
+ }
593
+ };
594
+ }
595
+
596
+ // src/react/anchor.ts
597
+ var MAX_DEPTH = 5;
598
+ var OVERLAY_ATTR = "data-feedback-overlay";
599
+ function escapeForSelector(value) {
600
+ if (typeof CSS !== "undefined" && typeof CSS.escape === "function") return CSS.escape(value);
601
+ return value.replace(/[^\w-]/g, (c3) => `\\${c3}`);
602
+ }
603
+ function getStableSelector(el, maxDepth = MAX_DEPTH) {
604
+ const parts = [];
605
+ let cur = el;
606
+ while (cur && parts.length < maxDepth && cur !== document.body && cur !== document.documentElement) {
607
+ const testid = cur.getAttribute("data-testid");
608
+ if (testid) {
609
+ parts.unshift(`[data-testid="${escapeForSelector(testid)}"]`);
610
+ return parts.join(" > ");
611
+ }
612
+ if (cur.id) {
613
+ parts.unshift(`#${escapeForSelector(cur.id)}`);
614
+ return parts.join(" > ");
615
+ }
616
+ let part = cur.tagName.toLowerCase();
617
+ const parent = cur.parentElement;
618
+ if (parent) {
619
+ const sameTag = Array.from(parent.children).filter((s3) => s3.tagName === cur.tagName);
620
+ if (sameTag.length > 1) {
621
+ part += `:nth-of-type(${sameTag.indexOf(cur) + 1})`;
622
+ }
623
+ }
624
+ parts.unshift(part);
625
+ cur = parent;
626
+ }
627
+ return parts.join(" > ");
628
+ }
629
+ function elementBelowOverlay(clientX, clientY) {
630
+ const stack = document.elementsFromPoint(clientX, clientY);
631
+ return stack.find((el) => !el.closest(`[${OVERLAY_ATTR}]`)) ?? null;
632
+ }
633
+ function describeElementAt(clientX, clientY) {
634
+ const el = elementBelowOverlay(clientX, clientY);
635
+ if (!el) return null;
636
+ return getStableSelector(el) || null;
637
+ }
638
+ var FEEDBACK_OVERLAY_ATTR = OVERLAY_ATTR;
639
+
640
+ // node_modules/modern-screenshot/dist/index.mjs
641
+ var _P = "p".charCodeAt(0);
642
+ var _H = "H".charCodeAt(0);
643
+ var _Y = "Y".charCodeAt(0);
644
+ var _S = "s".charCodeAt(0);
645
+ var PREFIX = "[modern-screenshot]";
646
+ var IN_BROWSER = typeof window !== "undefined";
647
+ var SUPPORT_WEB_WORKER = IN_BROWSER && "Worker" in window;
648
+ var SUPPORT_ATOB = IN_BROWSER && "atob" in window;
649
+ var SUPPORT_BTOA = IN_BROWSER && "btoa" in window;
650
+ var USER_AGENT = IN_BROWSER ? window.navigator?.userAgent : "";
651
+ var IN_CHROME = USER_AGENT.includes("Chrome");
652
+ var IN_SAFARI = USER_AGENT.includes("AppleWebKit") && !IN_CHROME;
653
+ var IN_FIREFOX = USER_AGENT.includes("Firefox");
654
+ var isContext = (value) => value && "__CONTEXT__" in value;
655
+ var isCssFontFaceRule = (rule) => rule.constructor.name === "CSSFontFaceRule";
656
+ var isCSSImportRule = (rule) => rule.constructor.name === "CSSImportRule";
657
+ var isLayerBlockRule = (rule) => rule.constructor.name === "CSSLayerBlockRule";
658
+ var isElementNode = (node) => node.nodeType === 1;
659
+ var isSVGElementNode = (node) => typeof node.className === "object";
660
+ var isSVGImageElementNode = (node) => node.tagName === "image";
661
+ var isSVGUseElementNode = (node) => node.tagName === "use";
662
+ var isHTMLElementNode = (node) => isElementNode(node) && typeof node.style !== "undefined" && !isSVGElementNode(node);
663
+ var isCommentNode = (node) => node.nodeType === 8;
664
+ var isTextNode = (node) => node.nodeType === 3;
665
+ var isImageElement = (node) => node.tagName === "IMG";
666
+ var isVideoElement = (node) => node.tagName === "VIDEO";
667
+ var isCanvasElement = (node) => node.tagName === "CANVAS";
668
+ var isTextareaElement = (node) => node.tagName === "TEXTAREA";
669
+ var isInputElement = (node) => node.tagName === "INPUT";
670
+ var isStyleElement = (node) => node.tagName === "STYLE";
671
+ var isScriptElement = (node) => node.tagName === "SCRIPT";
672
+ var isSelectElement = (node) => node.tagName === "SELECT";
673
+ var isSlotElement = (node) => node.tagName === "SLOT";
674
+ var isIFrameElement = (node) => node.tagName === "IFRAME";
675
+ var consoleWarn = (...args) => console.warn(PREFIX, ...args);
676
+ function supportWebp(ownerDocument) {
677
+ const canvas = ownerDocument?.createElement?.("canvas");
678
+ if (canvas) {
679
+ canvas.height = canvas.width = 1;
680
+ }
681
+ return Boolean(canvas) && "toDataURL" in canvas && Boolean(canvas.toDataURL("image/webp").includes("image/webp"));
682
+ }
683
+ var isDataUrl = (url) => url.startsWith("data:");
684
+ function resolveUrl(url, baseUrl) {
685
+ if (url.match(/^[a-z]+:\/\//i))
686
+ return url;
687
+ if (IN_BROWSER && url.match(/^\/\//))
688
+ return window.location.protocol + url;
689
+ if (url.match(/^[a-z]+:/i))
690
+ return url;
691
+ if (!IN_BROWSER)
692
+ return url;
693
+ const doc = getDocument().implementation.createHTMLDocument();
694
+ const base = doc.createElement("base");
695
+ const a3 = doc.createElement("a");
696
+ doc.head.appendChild(base);
697
+ doc.body.appendChild(a3);
698
+ if (baseUrl)
699
+ base.href = baseUrl;
700
+ a3.href = url;
701
+ return a3.href;
702
+ }
703
+ function getDocument(target) {
704
+ return (target && isElementNode(target) ? target?.ownerDocument : target) ?? window.document;
705
+ }
706
+ var XMLNS = "http://www.w3.org/2000/svg";
707
+ function createSvg(width, height, ownerDocument) {
708
+ const svg = getDocument(ownerDocument).createElementNS(XMLNS, "svg");
709
+ svg.setAttributeNS(null, "width", width.toString());
710
+ svg.setAttributeNS(null, "height", height.toString());
711
+ svg.setAttributeNS(null, "viewBox", `0 0 ${width} ${height}`);
712
+ return svg;
713
+ }
714
+ function svgToDataUrl(svg, removeControlCharacter) {
715
+ let xhtml = new XMLSerializer().serializeToString(svg);
716
+ if (removeControlCharacter) {
717
+ xhtml = xhtml.replace(/[\u0000-\u0008\v\f\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]/gu, "");
718
+ }
719
+ return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(xhtml)}`;
720
+ }
721
+ function readBlob(blob, type) {
722
+ return new Promise((resolve, reject) => {
723
+ const reader = new FileReader();
724
+ reader.onload = () => resolve(reader.result);
725
+ reader.onerror = () => reject(reader.error);
726
+ reader.onabort = () => reject(new Error(`Failed read blob to ${type}`));
727
+ if (type === "dataUrl") {
728
+ reader.readAsDataURL(blob);
729
+ } else if (type === "arrayBuffer") {
730
+ reader.readAsArrayBuffer(blob);
731
+ }
732
+ });
733
+ }
734
+ var blobToDataUrl = (blob) => readBlob(blob, "dataUrl");
735
+ function createImage(url, ownerDocument) {
736
+ const img = getDocument(ownerDocument).createElement("img");
737
+ img.decoding = "sync";
738
+ img.loading = "eager";
739
+ img.src = url;
740
+ return img;
741
+ }
742
+ function loadMedia(media, options) {
743
+ return new Promise((resolve) => {
744
+ const { timeout, ownerDocument, onError: userOnError, onWarn } = options ?? {};
745
+ const node = typeof media === "string" ? createImage(media, getDocument(ownerDocument)) : media;
746
+ let timer = null;
747
+ let removeEventListeners = null;
748
+ function onResolve() {
749
+ resolve(node);
750
+ timer && clearTimeout(timer);
751
+ removeEventListeners?.();
752
+ }
753
+ if (timeout) {
754
+ timer = setTimeout(onResolve, timeout);
755
+ }
756
+ if (isVideoElement(node)) {
757
+ const currentSrc = node.currentSrc || node.src;
758
+ if (!currentSrc) {
759
+ if (node.poster) {
760
+ return loadMedia(node.poster, options).then(resolve);
761
+ }
762
+ return onResolve();
763
+ }
764
+ if (node.readyState >= 2) {
765
+ return onResolve();
766
+ }
767
+ const onLoadeddata = onResolve;
768
+ const onError = (error) => {
769
+ onWarn?.(
770
+ "Failed video load",
771
+ currentSrc,
772
+ error
773
+ );
774
+ userOnError?.(error);
775
+ onResolve();
776
+ };
777
+ removeEventListeners = () => {
778
+ node.removeEventListener("loadeddata", onLoadeddata);
779
+ node.removeEventListener("error", onError);
780
+ };
781
+ node.addEventListener("loadeddata", onLoadeddata, { once: true });
782
+ node.addEventListener("error", onError, { once: true });
783
+ } else {
784
+ const currentSrc = isSVGImageElementNode(node) ? node.href.baseVal : node.currentSrc || node.src;
785
+ if (!currentSrc) {
786
+ return onResolve();
787
+ }
788
+ const onLoad = async () => {
789
+ if (isImageElement(node) && "decode" in node) {
790
+ try {
791
+ await node.decode();
792
+ } catch (error) {
793
+ onWarn?.(
794
+ "Failed to decode image, trying to render anyway",
795
+ node.dataset.originalSrc || currentSrc,
796
+ error
797
+ );
798
+ }
799
+ }
800
+ onResolve();
801
+ };
802
+ const onError = (error) => {
803
+ onWarn?.(
804
+ "Failed image load",
805
+ node.dataset.originalSrc || currentSrc,
806
+ error
807
+ );
808
+ onResolve();
809
+ };
810
+ if (isImageElement(node) && node.complete) {
811
+ return onLoad();
812
+ }
813
+ removeEventListeners = () => {
814
+ node.removeEventListener("load", onLoad);
815
+ node.removeEventListener("error", onError);
816
+ };
817
+ node.addEventListener("load", onLoad, { once: true });
818
+ node.addEventListener("error", onError, { once: true });
819
+ }
820
+ });
821
+ }
822
+ async function waitUntilLoad(node, options) {
823
+ if (isHTMLElementNode(node)) {
824
+ if (isImageElement(node) || isVideoElement(node)) {
825
+ await loadMedia(node, options);
826
+ } else {
827
+ await Promise.all(
828
+ ["img", "video"].flatMap((selectors) => {
829
+ return Array.from(node.querySelectorAll(selectors)).map((el) => loadMedia(el, options));
830
+ })
831
+ );
832
+ }
833
+ }
834
+ }
835
+ var uuid = /* @__PURE__ */ (function uuid2() {
836
+ let counter = 0;
837
+ const random = () => `0000${(Math.random() * 36 ** 4 << 0).toString(36)}`.slice(-4);
838
+ return () => {
839
+ counter += 1;
840
+ return `u${random()}${counter}`;
841
+ };
842
+ })();
843
+ function splitFontFamily(fontFamily) {
844
+ return fontFamily?.split(",").map((val) => val.trim().replace(/"|'/g, "").toLowerCase()).filter(Boolean);
845
+ }
846
+ var uid = 0;
847
+ function createLogger(debug) {
848
+ const prefix = `${PREFIX}[#${uid}]`;
849
+ uid++;
850
+ return {
851
+ // eslint-disable-next-line no-console
852
+ time: (label) => debug && console.time(`${prefix} ${label}`),
853
+ // eslint-disable-next-line no-console
854
+ timeEnd: (label) => debug && console.timeEnd(`${prefix} ${label}`),
855
+ warn: (...args) => debug && consoleWarn(...args)
856
+ };
857
+ }
858
+ function getDefaultRequestInit(bypassingCache) {
859
+ return {
860
+ cache: bypassingCache ? "no-cache" : "force-cache"
861
+ };
862
+ }
863
+ async function orCreateContext(node, options) {
864
+ return isContext(node) ? node : createContext(node, { ...options, autoDestruct: true });
865
+ }
866
+ async function createContext(node, options) {
867
+ const { scale = 1, workerUrl, workerNumber = 1 } = options || {};
868
+ const debug = Boolean(options?.debug);
869
+ const features = options?.features ?? true;
870
+ const ownerDocument = node.ownerDocument ?? (IN_BROWSER ? window.document : void 0);
871
+ const ownerWindow = node.ownerDocument?.defaultView ?? (IN_BROWSER ? window : void 0);
872
+ const requests = /* @__PURE__ */ new Map();
873
+ const context = {
874
+ // Options
875
+ width: 0,
876
+ height: 0,
877
+ quality: 1,
878
+ type: "image/png",
879
+ scale,
880
+ backgroundColor: null,
881
+ style: null,
882
+ filter: null,
883
+ maximumCanvasSize: 0,
884
+ timeout: 3e4,
885
+ progress: null,
886
+ debug,
887
+ fetch: {
888
+ requestInit: getDefaultRequestInit(options?.fetch?.bypassingCache),
889
+ placeholderImage: "data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
890
+ bypassingCache: false,
891
+ ...options?.fetch
892
+ },
893
+ fetchFn: null,
894
+ font: {},
895
+ drawImageInterval: 100,
896
+ workerUrl: null,
897
+ workerNumber,
898
+ onCloneEachNode: null,
899
+ onCloneNode: null,
900
+ onEmbedNode: null,
901
+ onCreateForeignObjectSvg: null,
902
+ includeStyleProperties: null,
903
+ autoDestruct: false,
904
+ ...options,
905
+ // InternalContext
906
+ __CONTEXT__: true,
907
+ log: createLogger(debug),
908
+ node,
909
+ ownerDocument,
910
+ ownerWindow,
911
+ dpi: scale === 1 ? null : 96 * scale,
912
+ svgStyleElement: createStyleElement(ownerDocument),
913
+ svgDefsElement: ownerDocument?.createElementNS(XMLNS, "defs"),
914
+ svgStyles: /* @__PURE__ */ new Map(),
915
+ defaultComputedStyles: /* @__PURE__ */ new Map(),
916
+ workers: [
917
+ ...Array.from({
918
+ length: SUPPORT_WEB_WORKER && workerUrl && workerNumber ? workerNumber : 0
919
+ })
920
+ ].map(() => {
921
+ try {
922
+ const worker = new Worker(workerUrl);
923
+ worker.onmessage = async (event) => {
924
+ const { url, result } = event.data;
925
+ if (result) {
926
+ requests.get(url)?.resolve?.(result);
927
+ } else {
928
+ requests.get(url)?.reject?.(new Error(`Error receiving message from worker: ${url}`));
929
+ }
930
+ };
931
+ worker.onmessageerror = (event) => {
932
+ const { url } = event.data;
933
+ requests.get(url)?.reject?.(new Error(`Error receiving message from worker: ${url}`));
934
+ };
935
+ return worker;
936
+ } catch (error) {
937
+ context.log.warn("Failed to new Worker", error);
938
+ return null;
939
+ }
940
+ }).filter(Boolean),
941
+ fontFamilies: /* @__PURE__ */ new Map(),
942
+ fontCssTexts: /* @__PURE__ */ new Map(),
943
+ acceptOfImage: `${[
944
+ supportWebp(ownerDocument) && "image/webp",
945
+ "image/svg+xml",
946
+ "image/*",
947
+ "*/*"
948
+ ].filter(Boolean).join(",")};q=0.8`,
949
+ requests,
950
+ drawImageCount: 0,
951
+ tasks: [],
952
+ features,
953
+ isEnable: (key) => {
954
+ if (key === "restoreScrollPosition") {
955
+ return typeof features === "boolean" ? false : features[key] ?? false;
956
+ }
957
+ if (typeof features === "boolean") {
958
+ return features;
959
+ }
960
+ return features[key] ?? true;
961
+ },
962
+ shadowRoots: []
963
+ };
964
+ context.log.time("wait until load");
965
+ await waitUntilLoad(node, { timeout: context.timeout, onWarn: context.log.warn });
966
+ context.log.timeEnd("wait until load");
967
+ const { width, height } = resolveBoundingBox(node, context);
968
+ context.width = width;
969
+ context.height = height;
970
+ return context;
971
+ }
972
+ function createStyleElement(ownerDocument) {
973
+ if (!ownerDocument)
974
+ return void 0;
975
+ const style = ownerDocument.createElement("style");
976
+ const cssText = style.ownerDocument.createTextNode(`
977
+ .______background-clip--text {
978
+ background-clip: text;
979
+ -webkit-background-clip: text;
980
+ }
981
+ `);
982
+ style.appendChild(cssText);
983
+ return style;
984
+ }
985
+ function resolveBoundingBox(node, context) {
986
+ let { width, height } = context;
987
+ if (isElementNode(node) && (!width || !height)) {
988
+ const box = node.getBoundingClientRect();
989
+ width = width || box.width || Number(node.getAttribute("width")) || 0;
990
+ height = height || box.height || Number(node.getAttribute("height")) || 0;
991
+ }
992
+ return { width, height };
993
+ }
994
+ async function imageToCanvas(image, context) {
995
+ const {
996
+ log,
997
+ timeout,
998
+ drawImageCount,
999
+ drawImageInterval
1000
+ } = context;
1001
+ log.time("image to canvas");
1002
+ const loaded = await loadMedia(image, { timeout, onWarn: context.log.warn });
1003
+ const { canvas, context2d } = createCanvas(image.ownerDocument, context);
1004
+ const drawImage = () => {
1005
+ try {
1006
+ context2d?.drawImage(loaded, 0, 0, canvas.width, canvas.height);
1007
+ } catch (error) {
1008
+ context.log.warn("Failed to drawImage", error);
1009
+ }
1010
+ };
1011
+ drawImage();
1012
+ if (context.isEnable("fixSvgXmlDecode")) {
1013
+ for (let i3 = 0; i3 < drawImageCount; i3++) {
1014
+ await new Promise((resolve) => {
1015
+ setTimeout(() => {
1016
+ context2d?.clearRect(0, 0, canvas.width, canvas.height);
1017
+ drawImage();
1018
+ resolve();
1019
+ }, i3 + drawImageInterval);
1020
+ });
1021
+ }
1022
+ }
1023
+ context.drawImageCount = 0;
1024
+ log.timeEnd("image to canvas");
1025
+ return canvas;
1026
+ }
1027
+ function createCanvas(ownerDocument, context) {
1028
+ const { width, height, scale, backgroundColor, maximumCanvasSize: max } = context;
1029
+ const canvas = ownerDocument.createElement("canvas");
1030
+ canvas.width = Math.floor(width * scale);
1031
+ canvas.height = Math.floor(height * scale);
1032
+ canvas.style.width = `${width}px`;
1033
+ canvas.style.height = `${height}px`;
1034
+ if (max) {
1035
+ if (canvas.width > max || canvas.height > max) {
1036
+ if (canvas.width > max && canvas.height > max) {
1037
+ if (canvas.width > canvas.height) {
1038
+ canvas.height *= max / canvas.width;
1039
+ canvas.width = max;
1040
+ } else {
1041
+ canvas.width *= max / canvas.height;
1042
+ canvas.height = max;
1043
+ }
1044
+ } else if (canvas.width > max) {
1045
+ canvas.height *= max / canvas.width;
1046
+ canvas.width = max;
1047
+ } else {
1048
+ canvas.width *= max / canvas.height;
1049
+ canvas.height = max;
1050
+ }
1051
+ }
1052
+ }
1053
+ const context2d = canvas.getContext("2d");
1054
+ if (context2d && backgroundColor) {
1055
+ context2d.fillStyle = backgroundColor;
1056
+ context2d.fillRect(0, 0, canvas.width, canvas.height);
1057
+ }
1058
+ return { canvas, context2d };
1059
+ }
1060
+ function cloneCanvas(canvas, context) {
1061
+ if (canvas.ownerDocument) {
1062
+ try {
1063
+ const dataURL = canvas.toDataURL();
1064
+ if (dataURL !== "data:,") {
1065
+ return createImage(dataURL, canvas.ownerDocument);
1066
+ }
1067
+ } catch (error) {
1068
+ context.log.warn("Failed to clone canvas", error);
1069
+ }
1070
+ }
1071
+ const cloned = canvas.cloneNode(false);
1072
+ const ctx = canvas.getContext("2d");
1073
+ const clonedCtx = cloned.getContext("2d");
1074
+ try {
1075
+ if (ctx && clonedCtx) {
1076
+ clonedCtx.putImageData(
1077
+ ctx.getImageData(0, 0, canvas.width, canvas.height),
1078
+ 0,
1079
+ 0
1080
+ );
1081
+ }
1082
+ return cloned;
1083
+ } catch (error) {
1084
+ context.log.warn("Failed to clone canvas", error);
1085
+ }
1086
+ return cloned;
1087
+ }
1088
+ function cloneIframe(iframe, context) {
1089
+ try {
1090
+ if (iframe?.contentDocument?.documentElement) {
1091
+ return cloneNode(iframe.contentDocument.documentElement, context);
1092
+ }
1093
+ } catch (error) {
1094
+ context.log.warn("Failed to clone iframe", error);
1095
+ }
1096
+ return iframe.cloneNode(false);
1097
+ }
1098
+ function cloneImage(image) {
1099
+ const cloned = image.cloneNode(false);
1100
+ if (image.currentSrc && image.currentSrc !== image.src) {
1101
+ cloned.src = image.currentSrc;
1102
+ cloned.srcset = "";
1103
+ }
1104
+ if (cloned.loading === "lazy") {
1105
+ cloned.loading = "eager";
1106
+ }
1107
+ return cloned;
1108
+ }
1109
+ async function cloneVideo(video, context) {
1110
+ if (video.ownerDocument && !video.currentSrc && video.poster) {
1111
+ return createImage(video.poster, video.ownerDocument);
1112
+ }
1113
+ const cloned = video.cloneNode(false);
1114
+ cloned.crossOrigin = "anonymous";
1115
+ if (video.currentSrc && video.currentSrc !== video.src) {
1116
+ cloned.src = video.currentSrc;
1117
+ }
1118
+ const ownerDocument = cloned.ownerDocument;
1119
+ if (ownerDocument) {
1120
+ let canPlay = true;
1121
+ await loadMedia(cloned, { onError: () => canPlay = false, onWarn: context.log.warn });
1122
+ if (!canPlay) {
1123
+ if (video.poster) {
1124
+ return createImage(video.poster, video.ownerDocument);
1125
+ }
1126
+ return cloned;
1127
+ }
1128
+ cloned.currentTime = video.currentTime;
1129
+ await new Promise((resolve) => {
1130
+ cloned.addEventListener("seeked", resolve, { once: true });
1131
+ });
1132
+ const canvas = ownerDocument.createElement("canvas");
1133
+ canvas.width = video.offsetWidth;
1134
+ canvas.height = video.offsetHeight;
1135
+ try {
1136
+ const ctx = canvas.getContext("2d");
1137
+ if (ctx)
1138
+ ctx.drawImage(cloned, 0, 0, canvas.width, canvas.height);
1139
+ } catch (error) {
1140
+ context.log.warn("Failed to clone video", error);
1141
+ if (video.poster) {
1142
+ return createImage(video.poster, video.ownerDocument);
1143
+ }
1144
+ return cloned;
1145
+ }
1146
+ return cloneCanvas(canvas, context);
1147
+ }
1148
+ return cloned;
1149
+ }
1150
+ function cloneElement(node, context) {
1151
+ if (isCanvasElement(node)) {
1152
+ return cloneCanvas(node, context);
1153
+ }
1154
+ if (isIFrameElement(node)) {
1155
+ return cloneIframe(node, context);
1156
+ }
1157
+ if (isImageElement(node)) {
1158
+ return cloneImage(node);
1159
+ }
1160
+ if (isVideoElement(node)) {
1161
+ return cloneVideo(node, context);
1162
+ }
1163
+ return node.cloneNode(false);
1164
+ }
1165
+ function getSandBox(context) {
1166
+ let sandbox = context.sandbox;
1167
+ if (!sandbox) {
1168
+ const { ownerDocument } = context;
1169
+ try {
1170
+ if (ownerDocument) {
1171
+ sandbox = ownerDocument.createElement("iframe");
1172
+ sandbox.id = `__SANDBOX__${uuid()}`;
1173
+ sandbox.width = "0";
1174
+ sandbox.height = "0";
1175
+ sandbox.style.visibility = "hidden";
1176
+ sandbox.style.position = "fixed";
1177
+ ownerDocument.body.appendChild(sandbox);
1178
+ sandbox.srcdoc = '<!DOCTYPE html><meta charset="UTF-8"><title></title><body>';
1179
+ context.sandbox = sandbox;
1180
+ }
1181
+ } catch (error) {
1182
+ context.log.warn("Failed to getSandBox", error);
1183
+ }
1184
+ }
1185
+ return sandbox;
1186
+ }
1187
+ var ignoredStyles = [
1188
+ "width",
1189
+ "height",
1190
+ "-webkit-text-fill-color"
1191
+ ];
1192
+ var includedAttributes = [
1193
+ "stroke",
1194
+ "fill"
1195
+ ];
1196
+ function getDefaultStyle(node, pseudoElement, context) {
1197
+ const { defaultComputedStyles } = context;
1198
+ const nodeName = node.nodeName.toLowerCase();
1199
+ const isSvgNode = isSVGElementNode(node) && nodeName !== "svg";
1200
+ const attributes = isSvgNode ? includedAttributes.map((name) => [name, node.getAttribute(name)]).filter(([, value]) => value !== null) : [];
1201
+ const key = [
1202
+ isSvgNode && "svg",
1203
+ nodeName,
1204
+ attributes.map((name, value) => `${name}=${value}`).join(","),
1205
+ pseudoElement
1206
+ ].filter(Boolean).join(":");
1207
+ if (defaultComputedStyles.has(key))
1208
+ return defaultComputedStyles.get(key);
1209
+ const sandbox = getSandBox(context);
1210
+ const sandboxWindow = sandbox?.contentWindow;
1211
+ if (!sandboxWindow)
1212
+ return /* @__PURE__ */ new Map();
1213
+ const sandboxDocument = sandboxWindow?.document;
1214
+ let root2;
1215
+ let el;
1216
+ if (isSvgNode) {
1217
+ root2 = sandboxDocument.createElementNS(XMLNS, "svg");
1218
+ el = root2.ownerDocument.createElementNS(root2.namespaceURI, nodeName);
1219
+ attributes.forEach(([name, value]) => {
1220
+ el.setAttributeNS(null, name, value);
1221
+ });
1222
+ root2.appendChild(el);
1223
+ } else {
1224
+ root2 = el = sandboxDocument.createElement(nodeName);
1225
+ }
1226
+ el.textContent = " ";
1227
+ sandboxDocument.body.appendChild(root2);
1228
+ const computedStyle = sandboxWindow.getComputedStyle(el, pseudoElement);
1229
+ const styles = /* @__PURE__ */ new Map();
1230
+ for (let len = computedStyle.length, i3 = 0; i3 < len; i3++) {
1231
+ const name = computedStyle.item(i3);
1232
+ if (ignoredStyles.includes(name))
1233
+ continue;
1234
+ styles.set(name, computedStyle.getPropertyValue(name));
1235
+ }
1236
+ sandboxDocument.body.removeChild(root2);
1237
+ defaultComputedStyles.set(key, styles);
1238
+ return styles;
1239
+ }
1240
+ function getDiffStyle(style, defaultStyle, includeStyleProperties) {
1241
+ const diffStyle = /* @__PURE__ */ new Map();
1242
+ const prefixs = [];
1243
+ const prefixTree = /* @__PURE__ */ new Map();
1244
+ if (includeStyleProperties) {
1245
+ for (const name of includeStyleProperties) {
1246
+ applyTo(name);
1247
+ }
1248
+ } else {
1249
+ for (let len = style.length, i3 = 0; i3 < len; i3++) {
1250
+ const name = style.item(i3);
1251
+ applyTo(name);
1252
+ }
1253
+ }
1254
+ for (let len = prefixs.length, i3 = 0; i3 < len; i3++) {
1255
+ prefixTree.get(prefixs[i3])?.forEach((value, name) => diffStyle.set(name, value));
1256
+ }
1257
+ function applyTo(name) {
1258
+ const value = style.getPropertyValue(name);
1259
+ const priority = style.getPropertyPriority(name);
1260
+ const subIndex = name.lastIndexOf("-");
1261
+ const prefix = subIndex > -1 ? name.substring(0, subIndex) : void 0;
1262
+ if (prefix) {
1263
+ let map = prefixTree.get(prefix);
1264
+ if (!map) {
1265
+ map = /* @__PURE__ */ new Map();
1266
+ prefixTree.set(prefix, map);
1267
+ }
1268
+ map.set(name, [value, priority]);
1269
+ }
1270
+ if (defaultStyle.get(name) === value && !priority)
1271
+ return;
1272
+ if (prefix) {
1273
+ prefixs.push(prefix);
1274
+ } else {
1275
+ diffStyle.set(name, [value, priority]);
1276
+ }
1277
+ }
1278
+ return diffStyle;
1279
+ }
1280
+ function copyCssStyles(node, cloned, isRoot, context) {
1281
+ const { ownerWindow, includeStyleProperties, currentParentNodeStyle } = context;
1282
+ const clonedStyle = cloned.style;
1283
+ const computedStyle = ownerWindow.getComputedStyle(node);
1284
+ const defaultStyle = getDefaultStyle(node, null, context);
1285
+ currentParentNodeStyle?.forEach((_3, key) => {
1286
+ defaultStyle.delete(key);
1287
+ });
1288
+ const style = getDiffStyle(computedStyle, defaultStyle, includeStyleProperties);
1289
+ style.delete("transition-property");
1290
+ style.delete("all");
1291
+ style.delete("d");
1292
+ style.delete("content");
1293
+ if (isRoot) {
1294
+ style.delete("position");
1295
+ style.delete("margin-top");
1296
+ style.delete("margin-right");
1297
+ style.delete("margin-bottom");
1298
+ style.delete("margin-left");
1299
+ style.delete("margin-block-start");
1300
+ style.delete("margin-block-end");
1301
+ style.delete("margin-inline-start");
1302
+ style.delete("margin-inline-end");
1303
+ style.set("box-sizing", ["border-box", ""]);
1304
+ }
1305
+ if (style.get("background-clip")?.[0] === "text") {
1306
+ cloned.classList.add("______background-clip--text");
1307
+ }
1308
+ if (IN_CHROME) {
1309
+ if (!style.has("font-kerning"))
1310
+ style.set("font-kerning", ["normal", ""]);
1311
+ if ((style.get("overflow-x")?.[0] === "hidden" || style.get("overflow-y")?.[0] === "hidden") && style.get("text-overflow")?.[0] === "ellipsis" && node.scrollWidth === node.clientWidth) {
1312
+ style.set("text-overflow", ["clip", ""]);
1313
+ }
1314
+ }
1315
+ for (let len = clonedStyle.length, i3 = 0; i3 < len; i3++) {
1316
+ clonedStyle.removeProperty(clonedStyle.item(i3));
1317
+ }
1318
+ style.forEach(([value, priority], name) => {
1319
+ clonedStyle.setProperty(name, value, priority);
1320
+ });
1321
+ return style;
1322
+ }
1323
+ function copyInputValue(node, cloned) {
1324
+ if (isTextareaElement(node) || isInputElement(node) || isSelectElement(node)) {
1325
+ cloned.setAttribute("value", node.value);
1326
+ }
1327
+ }
1328
+ var pseudoClasses = [
1329
+ "::before",
1330
+ "::after"
1331
+ // '::placeholder', TODO
1332
+ ];
1333
+ var scrollbarPseudoClasses = [
1334
+ "::-webkit-scrollbar",
1335
+ "::-webkit-scrollbar-button",
1336
+ // '::-webkit-scrollbar:horizontal', TODO
1337
+ "::-webkit-scrollbar-thumb",
1338
+ "::-webkit-scrollbar-track",
1339
+ "::-webkit-scrollbar-track-piece",
1340
+ // '::-webkit-scrollbar:vertical', TODO
1341
+ "::-webkit-scrollbar-corner",
1342
+ "::-webkit-resizer"
1343
+ ];
1344
+ function copyPseudoClass(node, cloned, copyScrollbar, context, addWordToFontFamilies) {
1345
+ const { ownerWindow, svgStyleElement, svgStyles, currentNodeStyle } = context;
1346
+ if (!svgStyleElement || !ownerWindow)
1347
+ return;
1348
+ function copyBy(pseudoClass) {
1349
+ const computedStyle = ownerWindow.getComputedStyle(node, pseudoClass);
1350
+ let content = computedStyle.getPropertyValue("content");
1351
+ if (!content || content === "none")
1352
+ return;
1353
+ addWordToFontFamilies?.(content);
1354
+ content = content.replace(/(')|(")|(counter\(.+\))/g, "");
1355
+ const klasses = [uuid()];
1356
+ const defaultStyle = getDefaultStyle(node, pseudoClass, context);
1357
+ currentNodeStyle?.forEach((_3, key) => {
1358
+ defaultStyle.delete(key);
1359
+ });
1360
+ const style = getDiffStyle(computedStyle, defaultStyle, context.includeStyleProperties);
1361
+ style.delete("content");
1362
+ style.delete("-webkit-locale");
1363
+ if (style.get("background-clip")?.[0] === "text") {
1364
+ cloned.classList.add("______background-clip--text");
1365
+ }
1366
+ const cloneStyle = [
1367
+ `content: '${content}';`
1368
+ ];
1369
+ style.forEach(([value, priority], name) => {
1370
+ cloneStyle.push(`${name}: ${value}${priority ? " !important" : ""};`);
1371
+ });
1372
+ if (cloneStyle.length === 1)
1373
+ return;
1374
+ try {
1375
+ cloned.className = [cloned.className, ...klasses].join(" ");
1376
+ } catch (err) {
1377
+ context.log.warn("Failed to copyPseudoClass", err);
1378
+ return;
1379
+ }
1380
+ const cssText = cloneStyle.join("\n ");
1381
+ let allClasses = svgStyles.get(cssText);
1382
+ if (!allClasses) {
1383
+ allClasses = [];
1384
+ svgStyles.set(cssText, allClasses);
1385
+ }
1386
+ allClasses.push(`.${klasses[0]}${pseudoClass}`);
1387
+ }
1388
+ pseudoClasses.forEach(copyBy);
1389
+ if (copyScrollbar)
1390
+ scrollbarPseudoClasses.forEach(copyBy);
1391
+ }
1392
+ var excludeParentNodes = /* @__PURE__ */ new Set([
1393
+ "symbol"
1394
+ // test/fixtures/svg.symbol.html
1395
+ ]);
1396
+ async function appendChildNode(node, cloned, child, context, addWordToFontFamilies) {
1397
+ if (isElementNode(child) && (isStyleElement(child) || isScriptElement(child)))
1398
+ return;
1399
+ if (context.filter && !context.filter(child))
1400
+ return;
1401
+ if (excludeParentNodes.has(cloned.nodeName) || excludeParentNodes.has(child.nodeName)) {
1402
+ context.currentParentNodeStyle = void 0;
1403
+ } else {
1404
+ context.currentParentNodeStyle = context.currentNodeStyle;
1405
+ }
1406
+ const childCloned = await cloneNode(child, context, false, addWordToFontFamilies);
1407
+ if (context.isEnable("restoreScrollPosition")) {
1408
+ restoreScrollPosition(node, childCloned);
1409
+ }
1410
+ cloned.appendChild(childCloned);
1411
+ }
1412
+ async function cloneChildNodes(node, cloned, context, addWordToFontFamilies) {
1413
+ let firstChild = node.firstChild;
1414
+ if (isElementNode(node)) {
1415
+ if (node.shadowRoot) {
1416
+ firstChild = node.shadowRoot?.firstChild;
1417
+ context.shadowRoots.push(node.shadowRoot);
1418
+ }
1419
+ }
1420
+ for (let child = firstChild; child; child = child.nextSibling) {
1421
+ if (isCommentNode(child))
1422
+ continue;
1423
+ if (isElementNode(child) && isSlotElement(child) && typeof child.assignedNodes === "function") {
1424
+ const nodes = child.assignedNodes();
1425
+ for (let i3 = 0; i3 < nodes.length; i3++) {
1426
+ await appendChildNode(node, cloned, nodes[i3], context, addWordToFontFamilies);
1427
+ }
1428
+ } else {
1429
+ await appendChildNode(node, cloned, child, context, addWordToFontFamilies);
1430
+ }
1431
+ }
1432
+ }
1433
+ function restoreScrollPosition(node, chlidCloned) {
1434
+ if (!isHTMLElementNode(node) || !isHTMLElementNode(chlidCloned))
1435
+ return;
1436
+ const { scrollTop, scrollLeft } = node;
1437
+ if (!scrollTop && !scrollLeft) {
1438
+ return;
1439
+ }
1440
+ const { transform } = chlidCloned.style;
1441
+ const matrix = new DOMMatrix(transform);
1442
+ const { a: a3, b: b2, c: c3, d: d3 } = matrix;
1443
+ matrix.a = 1;
1444
+ matrix.b = 0;
1445
+ matrix.c = 0;
1446
+ matrix.d = 1;
1447
+ matrix.translateSelf(-scrollLeft, -scrollTop);
1448
+ matrix.a = a3;
1449
+ matrix.b = b2;
1450
+ matrix.c = c3;
1451
+ matrix.d = d3;
1452
+ chlidCloned.style.transform = matrix.toString();
1453
+ }
1454
+ function applyCssStyleWithOptions(cloned, context) {
1455
+ const { backgroundColor, width, height, style: styles } = context;
1456
+ const clonedStyle = cloned.style;
1457
+ if (backgroundColor)
1458
+ clonedStyle.setProperty("background-color", backgroundColor, "important");
1459
+ if (width)
1460
+ clonedStyle.setProperty("width", `${width}px`, "important");
1461
+ if (height)
1462
+ clonedStyle.setProperty("height", `${height}px`, "important");
1463
+ if (styles) {
1464
+ for (const name in styles) clonedStyle[name] = styles[name];
1465
+ }
1466
+ }
1467
+ var NORMAL_ATTRIBUTE_RE = /^[\w-:]+$/;
1468
+ async function cloneNode(node, context, isRoot = false, addWordToFontFamilies) {
1469
+ const { ownerDocument, ownerWindow, fontFamilies, onCloneEachNode } = context;
1470
+ if (ownerDocument && isTextNode(node)) {
1471
+ if (addWordToFontFamilies && /\S/.test(node.data)) {
1472
+ addWordToFontFamilies(node.data);
1473
+ }
1474
+ return ownerDocument.createTextNode(node.data);
1475
+ }
1476
+ if (ownerDocument && ownerWindow && isElementNode(node) && (isHTMLElementNode(node) || isSVGElementNode(node))) {
1477
+ const cloned2 = await cloneElement(node, context);
1478
+ if (context.isEnable("removeAbnormalAttributes")) {
1479
+ const names = cloned2.getAttributeNames();
1480
+ for (let len = names.length, i3 = 0; i3 < len; i3++) {
1481
+ const name = names[i3];
1482
+ if (!NORMAL_ATTRIBUTE_RE.test(name)) {
1483
+ cloned2.removeAttribute(name);
1484
+ }
1485
+ }
1486
+ }
1487
+ const style = context.currentNodeStyle = copyCssStyles(node, cloned2, isRoot, context);
1488
+ if (isRoot)
1489
+ applyCssStyleWithOptions(cloned2, context);
1490
+ let copyScrollbar = false;
1491
+ if (context.isEnable("copyScrollbar")) {
1492
+ const overflow = [
1493
+ style.get("overflow-x")?.[0],
1494
+ style.get("overflow-y")?.[0]
1495
+ ];
1496
+ copyScrollbar = overflow.includes("scroll") || (overflow.includes("auto") || overflow.includes("overlay")) && (node.scrollHeight > node.clientHeight || node.scrollWidth > node.clientWidth);
1497
+ }
1498
+ const textTransform = style.get("text-transform")?.[0];
1499
+ const families = splitFontFamily(style.get("font-family")?.[0]);
1500
+ const addWordToFontFamilies2 = families ? (word) => {
1501
+ if (textTransform === "uppercase") {
1502
+ word = word.toUpperCase();
1503
+ } else if (textTransform === "lowercase") {
1504
+ word = word.toLowerCase();
1505
+ } else if (textTransform === "capitalize") {
1506
+ word = word[0].toUpperCase() + word.substring(1);
1507
+ }
1508
+ families.forEach((family) => {
1509
+ let fontFamily = fontFamilies.get(family);
1510
+ if (!fontFamily) {
1511
+ fontFamilies.set(family, fontFamily = /* @__PURE__ */ new Set());
1512
+ }
1513
+ word.split("").forEach((text) => fontFamily.add(text));
1514
+ });
1515
+ } : void 0;
1516
+ copyPseudoClass(
1517
+ node,
1518
+ cloned2,
1519
+ copyScrollbar,
1520
+ context,
1521
+ addWordToFontFamilies2
1522
+ );
1523
+ copyInputValue(node, cloned2);
1524
+ if (!isVideoElement(node)) {
1525
+ await cloneChildNodes(
1526
+ node,
1527
+ cloned2,
1528
+ context,
1529
+ addWordToFontFamilies2
1530
+ );
1531
+ }
1532
+ await onCloneEachNode?.(cloned2);
1533
+ return cloned2;
1534
+ }
1535
+ const cloned = node.cloneNode(false);
1536
+ await cloneChildNodes(node, cloned, context);
1537
+ await onCloneEachNode?.(cloned);
1538
+ return cloned;
1539
+ }
1540
+ function destroyContext(context) {
1541
+ context.ownerDocument = void 0;
1542
+ context.ownerWindow = void 0;
1543
+ context.svgStyleElement = void 0;
1544
+ context.svgDefsElement = void 0;
1545
+ context.svgStyles.clear();
1546
+ context.defaultComputedStyles.clear();
1547
+ if (context.sandbox) {
1548
+ try {
1549
+ context.sandbox.remove();
1550
+ } catch (err) {
1551
+ context.log.warn("Failed to destroyContext", err);
1552
+ }
1553
+ context.sandbox = void 0;
1554
+ }
1555
+ context.workers = [];
1556
+ context.fontFamilies.clear();
1557
+ context.fontCssTexts.clear();
1558
+ context.requests.clear();
1559
+ context.tasks = [];
1560
+ context.shadowRoots = [];
1561
+ }
1562
+ function baseFetch(options) {
1563
+ const { url, timeout, responseType, ...requestInit } = options;
1564
+ const controller = new AbortController();
1565
+ const timer = timeout ? setTimeout(() => controller.abort(), timeout) : void 0;
1566
+ return fetch(url, { signal: controller.signal, ...requestInit }).then((response) => {
1567
+ if (!response.ok) {
1568
+ throw new Error("Failed fetch, not 2xx response", { cause: response });
1569
+ }
1570
+ switch (responseType) {
1571
+ case "arrayBuffer":
1572
+ return response.arrayBuffer();
1573
+ case "dataUrl":
1574
+ return response.blob().then(blobToDataUrl);
1575
+ case "text":
1576
+ default:
1577
+ return response.text();
1578
+ }
1579
+ }).finally(() => clearTimeout(timer));
1580
+ }
1581
+ function contextFetch(context, options) {
1582
+ const { url: rawUrl, requestType = "text", responseType = "text", imageDom } = options;
1583
+ let url = rawUrl;
1584
+ const {
1585
+ timeout,
1586
+ acceptOfImage,
1587
+ requests,
1588
+ fetchFn,
1589
+ fetch: {
1590
+ requestInit,
1591
+ bypassingCache,
1592
+ placeholderImage
1593
+ },
1594
+ font,
1595
+ workers,
1596
+ fontFamilies
1597
+ } = context;
1598
+ if (requestType === "image" && (IN_SAFARI || IN_FIREFOX)) {
1599
+ context.drawImageCount++;
1600
+ }
1601
+ let request = requests.get(rawUrl);
1602
+ if (!request) {
1603
+ if (bypassingCache) {
1604
+ if (bypassingCache instanceof RegExp && bypassingCache.test(url)) {
1605
+ url += (/\?/.test(url) ? "&" : "?") + (/* @__PURE__ */ new Date()).getTime();
1606
+ }
1607
+ }
1608
+ const canFontMinify = requestType.startsWith("font") && font && font.minify;
1609
+ const fontTexts = /* @__PURE__ */ new Set();
1610
+ if (canFontMinify) {
1611
+ const families = requestType.split(";")[1].split(",");
1612
+ families.forEach((family) => {
1613
+ if (!fontFamilies.has(family))
1614
+ return;
1615
+ fontFamilies.get(family).forEach((text) => fontTexts.add(text));
1616
+ });
1617
+ }
1618
+ const needFontMinify = canFontMinify && fontTexts.size;
1619
+ const baseFetchOptions = {
1620
+ url,
1621
+ timeout,
1622
+ responseType: needFontMinify ? "arrayBuffer" : responseType,
1623
+ headers: requestType === "image" ? { accept: acceptOfImage } : void 0,
1624
+ ...requestInit
1625
+ };
1626
+ request = {
1627
+ type: requestType,
1628
+ resolve: void 0,
1629
+ reject: void 0,
1630
+ response: null
1631
+ };
1632
+ request.response = (async () => {
1633
+ if (fetchFn && requestType === "image") {
1634
+ const result = await fetchFn(rawUrl);
1635
+ if (result)
1636
+ return result;
1637
+ }
1638
+ if (!IN_SAFARI && rawUrl.startsWith("http") && workers.length) {
1639
+ return new Promise((resolve, reject) => {
1640
+ const worker = workers[requests.size & workers.length - 1];
1641
+ worker.postMessage({ rawUrl, ...baseFetchOptions });
1642
+ request.resolve = resolve;
1643
+ request.reject = reject;
1644
+ });
1645
+ }
1646
+ return baseFetch(baseFetchOptions);
1647
+ })().catch((error) => {
1648
+ requests.delete(rawUrl);
1649
+ if (requestType === "image" && placeholderImage) {
1650
+ context.log.warn("Failed to fetch image base64, trying to use placeholder image", url);
1651
+ return typeof placeholderImage === "string" ? placeholderImage : placeholderImage(imageDom);
1652
+ }
1653
+ throw error;
1654
+ });
1655
+ requests.set(rawUrl, request);
1656
+ }
1657
+ return request.response;
1658
+ }
1659
+ async function replaceCssUrlToDataUrl(cssText, baseUrl, context, isImage) {
1660
+ if (!hasCssUrl(cssText))
1661
+ return cssText;
1662
+ for (const [rawUrl, url] of parseCssUrls(cssText, baseUrl)) {
1663
+ try {
1664
+ const dataUrl = await contextFetch(
1665
+ context,
1666
+ {
1667
+ url,
1668
+ requestType: isImage ? "image" : "text",
1669
+ responseType: "dataUrl"
1670
+ }
1671
+ );
1672
+ cssText = cssText.replace(toRE(rawUrl), `$1${dataUrl}$3`);
1673
+ } catch (error) {
1674
+ context.log.warn("Failed to fetch css data url", rawUrl, error);
1675
+ }
1676
+ }
1677
+ return cssText;
1678
+ }
1679
+ function hasCssUrl(cssText) {
1680
+ return /url\((['"]?)([^'"]+?)\1\)/.test(cssText);
1681
+ }
1682
+ var URL_RE = /url\((['"]?)([^'"]+?)\1\)/g;
1683
+ function parseCssUrls(cssText, baseUrl) {
1684
+ const result = [];
1685
+ cssText.replace(URL_RE, (raw, quotation, url) => {
1686
+ result.push([url, resolveUrl(url, baseUrl)]);
1687
+ return raw;
1688
+ });
1689
+ return result.filter(([url]) => !isDataUrl(url));
1690
+ }
1691
+ function toRE(url) {
1692
+ const escaped = url.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1");
1693
+ return new RegExp(`(url\\(['"]?)(${escaped})(['"]?\\))`, "g");
1694
+ }
1695
+ var properties = [
1696
+ "background-image",
1697
+ "border-image-source",
1698
+ "-webkit-border-image",
1699
+ "-webkit-mask-image",
1700
+ "list-style-image"
1701
+ ];
1702
+ function embedCssStyleImage(style, context) {
1703
+ return properties.map((property) => {
1704
+ const value = style.getPropertyValue(property);
1705
+ if (!value || value === "none") {
1706
+ return null;
1707
+ }
1708
+ if (IN_SAFARI || IN_FIREFOX) {
1709
+ context.drawImageCount++;
1710
+ }
1711
+ return replaceCssUrlToDataUrl(value, null, context, true).then((newValue) => {
1712
+ if (!newValue || value === newValue)
1713
+ return;
1714
+ style.setProperty(
1715
+ property,
1716
+ newValue,
1717
+ style.getPropertyPriority(property)
1718
+ );
1719
+ });
1720
+ }).filter(Boolean);
1721
+ }
1722
+ function embedImageElement(cloned, context) {
1723
+ if (isImageElement(cloned)) {
1724
+ const originalSrc = cloned.currentSrc || cloned.src;
1725
+ if (!isDataUrl(originalSrc)) {
1726
+ return [
1727
+ contextFetch(context, {
1728
+ url: originalSrc,
1729
+ imageDom: cloned,
1730
+ requestType: "image",
1731
+ responseType: "dataUrl"
1732
+ }).then((url) => {
1733
+ if (!url)
1734
+ return;
1735
+ cloned.srcset = "";
1736
+ cloned.dataset.originalSrc = originalSrc;
1737
+ cloned.src = url || "";
1738
+ })
1739
+ ];
1740
+ }
1741
+ if (IN_SAFARI || IN_FIREFOX) {
1742
+ context.drawImageCount++;
1743
+ }
1744
+ } else if (isSVGElementNode(cloned) && !isDataUrl(cloned.href.baseVal)) {
1745
+ const originalSrc = cloned.href.baseVal;
1746
+ return [
1747
+ contextFetch(context, {
1748
+ url: originalSrc,
1749
+ imageDom: cloned,
1750
+ requestType: "image",
1751
+ responseType: "dataUrl"
1752
+ }).then((url) => {
1753
+ if (!url)
1754
+ return;
1755
+ cloned.dataset.originalSrc = originalSrc;
1756
+ cloned.href.baseVal = url || "";
1757
+ })
1758
+ ];
1759
+ }
1760
+ return [];
1761
+ }
1762
+ function embedSvgUse(cloned, context) {
1763
+ const { ownerDocument, svgDefsElement } = context;
1764
+ const href = cloned.getAttribute("href") ?? cloned.getAttribute("xlink:href");
1765
+ if (!href)
1766
+ return [];
1767
+ const [svgUrl, id] = href.split("#");
1768
+ if (id) {
1769
+ const query = `#${id}`;
1770
+ const definition = context.shadowRoots.reduce(
1771
+ (res, root2) => {
1772
+ return res ?? root2.querySelector(`svg ${query}`);
1773
+ },
1774
+ ownerDocument?.querySelector(`svg ${query}`)
1775
+ );
1776
+ if (svgUrl) {
1777
+ cloned.setAttribute("href", query);
1778
+ }
1779
+ if (svgDefsElement?.querySelector(query))
1780
+ return [];
1781
+ if (definition) {
1782
+ svgDefsElement?.appendChild(definition.cloneNode(true));
1783
+ return [];
1784
+ } else if (svgUrl) {
1785
+ return [
1786
+ contextFetch(context, {
1787
+ url: svgUrl,
1788
+ responseType: "text"
1789
+ }).then((svgData) => {
1790
+ svgDefsElement?.insertAdjacentHTML("beforeend", svgData);
1791
+ })
1792
+ ];
1793
+ }
1794
+ }
1795
+ return [];
1796
+ }
1797
+ function embedNode(cloned, context) {
1798
+ const { tasks } = context;
1799
+ if (isElementNode(cloned)) {
1800
+ if (isImageElement(cloned) || isSVGImageElementNode(cloned)) {
1801
+ tasks.push(...embedImageElement(cloned, context));
1802
+ }
1803
+ if (isSVGUseElementNode(cloned)) {
1804
+ tasks.push(...embedSvgUse(cloned, context));
1805
+ }
1806
+ }
1807
+ if (isHTMLElementNode(cloned)) {
1808
+ tasks.push(...embedCssStyleImage(cloned.style, context));
1809
+ }
1810
+ cloned.childNodes.forEach((child) => {
1811
+ embedNode(child, context);
1812
+ });
1813
+ }
1814
+ async function embedWebFont(clone, context) {
1815
+ const {
1816
+ ownerDocument,
1817
+ svgStyleElement,
1818
+ fontFamilies,
1819
+ fontCssTexts,
1820
+ tasks,
1821
+ font
1822
+ } = context;
1823
+ if (!ownerDocument || !svgStyleElement || !fontFamilies.size) {
1824
+ return;
1825
+ }
1826
+ if (font && font.cssText) {
1827
+ const cssText = filterPreferredFormat(font.cssText, context);
1828
+ svgStyleElement.appendChild(ownerDocument.createTextNode(`${cssText}
1829
+ `));
1830
+ } else {
1831
+ const styleSheets = Array.from(ownerDocument.styleSheets).filter((styleSheet) => {
1832
+ try {
1833
+ return "cssRules" in styleSheet && Boolean(styleSheet.cssRules.length);
1834
+ } catch (error) {
1835
+ context.log.warn(`Error while reading CSS rules from ${styleSheet.href}`, error);
1836
+ return false;
1837
+ }
1838
+ });
1839
+ const tempDoc = ownerDocument.implementation.createHTMLDocument("");
1840
+ const tempStyleEl = tempDoc.createElement("style");
1841
+ tempDoc.head.appendChild(tempStyleEl);
1842
+ const tempStyleSheet = tempStyleEl.sheet;
1843
+ await Promise.all(
1844
+ styleSheets.flatMap((styleSheet) => {
1845
+ return Array.from(styleSheet.cssRules).map(async (cssRule) => {
1846
+ if (isCSSImportRule(cssRule)) {
1847
+ const baseUrl = cssRule.href;
1848
+ let cssText = "";
1849
+ try {
1850
+ cssText = await contextFetch(context, {
1851
+ url: baseUrl,
1852
+ requestType: "text",
1853
+ responseType: "text"
1854
+ });
1855
+ } catch (error) {
1856
+ context.log.warn(`Error fetch remote css import from ${baseUrl}`, error);
1857
+ }
1858
+ const replacedCssText = cssText.replace(
1859
+ URL_RE,
1860
+ (raw, quotation, url) => raw.replace(url, resolveUrl(url, baseUrl))
1861
+ );
1862
+ for (const rule of parseCss(replacedCssText)) {
1863
+ try {
1864
+ tempStyleSheet.insertRule(rule, tempStyleSheet.cssRules.length);
1865
+ } catch (error) {
1866
+ context.log.warn("Error inserting rule from remote css import", { rule, error });
1867
+ }
1868
+ }
1869
+ }
1870
+ });
1871
+ })
1872
+ );
1873
+ if (tempStyleSheet.cssRules.length)
1874
+ styleSheets.push(tempStyleSheet);
1875
+ const cssRules = [];
1876
+ styleSheets.forEach((sheet) => {
1877
+ unwrapCssLayers(sheet.cssRules, cssRules);
1878
+ });
1879
+ cssRules.filter((cssRule) => isCssFontFaceRule(cssRule) && hasCssUrl(cssRule.style.getPropertyValue("src")) && splitFontFamily(cssRule.style.getPropertyValue("font-family"))?.some((val) => fontFamilies.has(val))).forEach((value) => {
1880
+ const rule = value;
1881
+ const cssText = fontCssTexts.get(rule.cssText);
1882
+ if (cssText) {
1883
+ svgStyleElement.appendChild(ownerDocument.createTextNode(`${cssText}
1884
+ `));
1885
+ } else {
1886
+ tasks.push(
1887
+ replaceCssUrlToDataUrl(
1888
+ rule.cssText,
1889
+ rule.parentStyleSheet ? rule.parentStyleSheet.href : null,
1890
+ context
1891
+ ).then((cssText2) => {
1892
+ cssText2 = filterPreferredFormat(cssText2, context);
1893
+ fontCssTexts.set(rule.cssText, cssText2);
1894
+ svgStyleElement.appendChild(ownerDocument.createTextNode(`${cssText2}
1895
+ `));
1896
+ })
1897
+ );
1898
+ }
1899
+ });
1900
+ }
1901
+ }
1902
+ var COMMENTS_RE = /(\/\*[\s\S]*?\*\/)/g;
1903
+ var KEYFRAMES_RE = /((@.*?keyframes [\s\S]*?){([\s\S]*?}\s*?)})/gi;
1904
+ function parseCss(source) {
1905
+ if (source == null)
1906
+ return [];
1907
+ const result = [];
1908
+ let cssText = source.replace(COMMENTS_RE, "");
1909
+ while (true) {
1910
+ const matches = KEYFRAMES_RE.exec(cssText);
1911
+ if (!matches)
1912
+ break;
1913
+ result.push(matches[0]);
1914
+ }
1915
+ cssText = cssText.replace(KEYFRAMES_RE, "");
1916
+ const IMPORT_RE = /@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi;
1917
+ const UNIFIED_RE = new RegExp(
1918
+ // eslint-disable-next-line
1919
+ "((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",
1920
+ "gi"
1921
+ );
1922
+ while (true) {
1923
+ let matches = IMPORT_RE.exec(cssText);
1924
+ if (!matches) {
1925
+ matches = UNIFIED_RE.exec(cssText);
1926
+ if (!matches) {
1927
+ break;
1928
+ } else {
1929
+ IMPORT_RE.lastIndex = UNIFIED_RE.lastIndex;
1930
+ }
1931
+ } else {
1932
+ UNIFIED_RE.lastIndex = IMPORT_RE.lastIndex;
1933
+ }
1934
+ result.push(matches[0]);
1935
+ }
1936
+ return result;
1937
+ }
1938
+ var URL_WITH_FORMAT_RE = /url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g;
1939
+ var FONT_SRC_RE = /src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;
1940
+ function filterPreferredFormat(str, context) {
1941
+ const { font } = context;
1942
+ const preferredFormat = font ? font?.preferredFormat : void 0;
1943
+ return preferredFormat ? str.replace(FONT_SRC_RE, (match) => {
1944
+ while (true) {
1945
+ const [src, , format] = URL_WITH_FORMAT_RE.exec(match) || [];
1946
+ if (!format)
1947
+ return "";
1948
+ if (format === preferredFormat)
1949
+ return `src: ${src};`;
1950
+ }
1951
+ }) : str;
1952
+ }
1953
+ function unwrapCssLayers(rules, out = []) {
1954
+ for (const rule of Array.from(rules)) {
1955
+ if (isLayerBlockRule(rule)) {
1956
+ out.push(...unwrapCssLayers(rule.cssRules));
1957
+ } else if ("cssRules" in rule) {
1958
+ unwrapCssLayers(rule.cssRules, out);
1959
+ } else {
1960
+ out.push(rule);
1961
+ }
1962
+ }
1963
+ return out;
1964
+ }
1965
+ var SVG_EXTERNAL_RESOURCE_REGEX = /\bx?link:?href\s*=\s*["'](?!data:)[^"']+["']/i;
1966
+ function svgHasExternalResources(svg) {
1967
+ return SVG_EXTERNAL_RESOURCE_REGEX.test(svg.innerHTML);
1968
+ }
1969
+ async function domToForeignObjectSvg(node, options) {
1970
+ const context = await orCreateContext(node, options);
1971
+ if (isElementNode(context.node) && isSVGElementNode(context.node) && !svgHasExternalResources(context.node))
1972
+ return context.node;
1973
+ const {
1974
+ ownerDocument,
1975
+ log,
1976
+ tasks,
1977
+ svgStyleElement,
1978
+ svgDefsElement,
1979
+ svgStyles,
1980
+ font,
1981
+ progress,
1982
+ autoDestruct,
1983
+ onCloneNode,
1984
+ onEmbedNode,
1985
+ onCreateForeignObjectSvg
1986
+ } = context;
1987
+ log.time("clone node");
1988
+ const clone = await cloneNode(context.node, context, true);
1989
+ if (svgStyleElement && ownerDocument) {
1990
+ let allCssText = "";
1991
+ svgStyles.forEach((klasses, cssText) => {
1992
+ allCssText += `${klasses.join(",\n")} {
1993
+ ${cssText}
1994
+ }
1995
+ `;
1996
+ });
1997
+ svgStyleElement.appendChild(ownerDocument.createTextNode(allCssText));
1998
+ }
1999
+ log.timeEnd("clone node");
2000
+ await onCloneNode?.(clone);
2001
+ if (font !== false && isElementNode(clone)) {
2002
+ log.time("embed web font");
2003
+ await embedWebFont(clone, context);
2004
+ log.timeEnd("embed web font");
2005
+ }
2006
+ log.time("embed node");
2007
+ embedNode(clone, context);
2008
+ const count = tasks.length;
2009
+ let current = 0;
2010
+ const runTask = async () => {
2011
+ while (true) {
2012
+ const task = tasks.pop();
2013
+ if (!task)
2014
+ break;
2015
+ try {
2016
+ await task;
2017
+ } catch (error) {
2018
+ context.log.warn("Failed to run task", error);
2019
+ }
2020
+ progress?.(++current, count);
2021
+ }
2022
+ };
2023
+ progress?.(current, count);
2024
+ await Promise.all([...Array.from({ length: 4 })].map(runTask));
2025
+ log.timeEnd("embed node");
2026
+ await onEmbedNode?.(clone);
2027
+ const svg = createForeignObjectSvg(clone, context);
2028
+ svgDefsElement && svg.insertBefore(svgDefsElement, svg.children[0]);
2029
+ svgStyleElement && svg.insertBefore(svgStyleElement, svg.children[0]);
2030
+ autoDestruct && destroyContext(context);
2031
+ await onCreateForeignObjectSvg?.(svg);
2032
+ return svg;
2033
+ }
2034
+ function createForeignObjectSvg(clone, context) {
2035
+ const { width, height } = context;
2036
+ const svg = createSvg(width, height, clone.ownerDocument);
2037
+ const foreignObject = svg.ownerDocument.createElementNS(svg.namespaceURI, "foreignObject");
2038
+ foreignObject.setAttributeNS(null, "x", "0%");
2039
+ foreignObject.setAttributeNS(null, "y", "0%");
2040
+ foreignObject.setAttributeNS(null, "width", "100%");
2041
+ foreignObject.setAttributeNS(null, "height", "100%");
2042
+ foreignObject.append(clone);
2043
+ svg.appendChild(foreignObject);
2044
+ return svg;
2045
+ }
2046
+ async function domToCanvas(node, options) {
2047
+ const context = await orCreateContext(node, options);
2048
+ const svg = await domToForeignObjectSvg(context);
2049
+ const dataUrl = svgToDataUrl(svg, context.isEnable("removeControlCharacter"));
2050
+ if (!context.autoDestruct) {
2051
+ context.svgStyleElement = createStyleElement(context.ownerDocument);
2052
+ context.svgDefsElement = context.ownerDocument?.createElementNS(XMLNS, "defs");
2053
+ context.svgStyles.clear();
2054
+ }
2055
+ const image = createImage(dataUrl, svg.ownerDocument);
2056
+ return await imageToCanvas(image, context);
2057
+ }
2058
+
2059
+ // src/react/feedback-client.ts
2060
+ var MAX_SIDE = 1600;
2061
+ async function submitFeedback(annotation, opts = {}) {
2062
+ const endpoint = opts.endpoint ?? "/api/feedback";
2063
+ const context = collectContext(annotation);
2064
+ const screenshot = await captureAnnotatedScreenshot(annotation);
2065
+ const payload = { annotation, context, screenshot };
2066
+ try {
2067
+ const res = await fetch(endpoint, {
2068
+ method: "POST",
2069
+ headers: { "Content-Type": "application/json", ...opts.headers },
2070
+ body: JSON.stringify(payload)
2071
+ });
2072
+ if (!res.ok) {
2073
+ const detail = await res.text().catch(() => "");
2074
+ console.error("[feedback] submit failed", res.status, detail);
2075
+ return null;
2076
+ }
2077
+ return await res.json();
2078
+ } catch (err) {
2079
+ console.error("[feedback] submit error", err);
2080
+ return null;
2081
+ }
2082
+ }
2083
+ async function captureAnnotatedScreenshot(annotation) {
2084
+ try {
2085
+ const docEl = document.documentElement;
2086
+ const pageW = docEl.scrollWidth;
2087
+ const pageH = docEl.scrollHeight;
2088
+ const vw = window.innerWidth;
2089
+ const vh = window.innerHeight;
2090
+ const scale = Math.min(1, MAX_SIDE / Math.max(vw, vh));
2091
+ const full = await domToCanvas(document.body, {
2092
+ scale,
2093
+ backgroundColor: "#ffffff",
2094
+ // Exclude the feedback overlay itself (carries data-feedback-overlay → dataset.feedbackOverlay).
2095
+ filter: (node) => !(node instanceof HTMLElement && node.dataset.feedbackOverlay !== void 0)
2096
+ });
2097
+ const ratioX = full.width / pageW;
2098
+ const ratioY = full.height / pageH;
2099
+ const out = document.createElement("canvas");
2100
+ out.width = Math.max(1, Math.round(vw * ratioX));
2101
+ out.height = Math.max(1, Math.round(vh * ratioY));
2102
+ const ctx = out.getContext("2d");
2103
+ if (ctx) {
2104
+ ctx.drawImage(full, window.scrollX * ratioX, window.scrollY * ratioY, vw * ratioX, vh * ratioY, 0, 0, out.width, out.height);
2105
+ const { x: x3, y: y3, width, height } = annotation.rect;
2106
+ const rx = (x3 - window.scrollX) * ratioX;
2107
+ const ry = (y3 - window.scrollY) * ratioY;
2108
+ ctx.lineWidth = Math.max(2, 3 * ratioX);
2109
+ ctx.strokeStyle = "#ff0055";
2110
+ ctx.fillStyle = "rgba(255, 0, 85, 0.12)";
2111
+ ctx.fillRect(rx, ry, width * ratioX, height * ratioY);
2112
+ ctx.strokeRect(rx, ry, width * ratioX, height * ratioY);
2113
+ }
2114
+ return out.toDataURL("image/jpeg", 0.85);
2115
+ } catch (err) {
2116
+ console.warn("[feedback] screenshot capture failed, sending without image", err);
2117
+ return null;
2118
+ }
2119
+ }
2120
+ function collectContext(annotation) {
2121
+ const viewportX = annotation.rect.x + annotation.rect.width / 2 - window.scrollX;
2122
+ const viewportY = annotation.rect.y + annotation.rect.height / 2 - window.scrollY;
2123
+ return {
2124
+ url: window.location.href,
2125
+ pathname: window.location.pathname,
2126
+ title: document.title,
2127
+ viewport: { width: window.innerWidth, height: window.innerHeight, dpr: window.devicePixelRatio },
2128
+ scroll: { x: window.scrollX, y: window.scrollY },
2129
+ userAgent: navigator.userAgent,
2130
+ referrer: document.referrer,
2131
+ elementHint: describeElementAt(viewportX, viewportY),
2132
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
2133
+ };
2134
+ }
2135
+
2136
+ // node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js
2137
+ var f3 = 0;
2138
+ function u3(e3, t3, n2, o3, i3, u4) {
2139
+ t3 || (t3 = {});
2140
+ var a3, c3, p3 = t3;
2141
+ if ("ref" in p3) for (c3 in p3 = {}, t3) "ref" == c3 ? a3 = t3[c3] : p3[c3] = t3[c3];
2142
+ var l3 = { type: e3, props: p3, key: n2, ref: a3, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --f3, __i: -1, __u: 0, __source: i3, __self: u4 };
2143
+ if ("function" == typeof e3 && (a3 = e3.defaultProps)) for (c3 in a3) void 0 === p3[c3] && (p3[c3] = a3[c3]);
2144
+ return l.vnode && l.vnode(l3), l3;
2145
+ }
2146
+
2147
+ // src/react/icons.tsx
2148
+ function Svg({ size = 16, children, ...props }) {
2149
+ return /* @__PURE__ */ u3(
2150
+ "svg",
2151
+ {
2152
+ width: size,
2153
+ height: size,
2154
+ viewBox: "0 0 24 24",
2155
+ fill: "none",
2156
+ stroke: "currentColor",
2157
+ strokeWidth: 2,
2158
+ strokeLinecap: "round",
2159
+ strokeLinejoin: "round",
2160
+ "aria-hidden": "true",
2161
+ ...props,
2162
+ children
2163
+ }
2164
+ );
2165
+ }
2166
+ var MessageIcon = (p3) => /* @__PURE__ */ u3(Svg, { ...p3, children: /* @__PURE__ */ u3("path", { d: "M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8z" }) });
2167
+ var XIcon = (p3) => /* @__PURE__ */ u3(Svg, { ...p3, children: /* @__PURE__ */ u3("path", { d: "M18 6 6 18M6 6l12 12" }) });
2168
+ var EditIcon = (p3) => /* @__PURE__ */ u3(Svg, { ...p3, children: [
2169
+ /* @__PURE__ */ u3("path", { d: "M12 20h9" }),
2170
+ /* @__PURE__ */ u3("path", { d: "M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z" })
2171
+ ] });
2172
+ var CheckCircleIcon = (p3) => /* @__PURE__ */ u3(Svg, { ...p3, children: [
2173
+ /* @__PURE__ */ u3("path", { d: "M22 11.08V12a10 10 0 1 1-5.93-9.14" }),
2174
+ /* @__PURE__ */ u3("path", { d: "M22 4 12 14.01l-3-3" })
2175
+ ] });
2176
+ var AlertTriangleIcon = (p3) => /* @__PURE__ */ u3(Svg, { ...p3, children: [
2177
+ /* @__PURE__ */ u3("path", { d: "M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z" }),
2178
+ /* @__PURE__ */ u3("path", { d: "M12 9v4" }),
2179
+ /* @__PURE__ */ u3("path", { d: "M12 17h.01" })
2180
+ ] });
2181
+ var ArrowUpIcon = (p3) => /* @__PURE__ */ u3(Svg, { ...p3, children: /* @__PURE__ */ u3("path", { d: "M12 19V5M5 12l7-7 7 7" }) });
2182
+ var DotIcon = (p3) => /* @__PURE__ */ u3(Svg, { ...p3, strokeWidth: 0, children: /* @__PURE__ */ u3("circle", { cx: "12", cy: "12", r: "6", fill: "currentColor" }) });
2183
+ var TYPE_ICONS = {
2184
+ bug: AlertTriangleIcon,
2185
+ improvement: ArrowUpIcon,
2186
+ dot: DotIcon
2187
+ };
2188
+
2189
+ // src/react/styles.ts
2190
+ var STYLE_ID = "lfb-styles";
2191
+ var CSS2 = `
2192
+ /*
2193
+ * Defaults live on .lfb-root (the element that also receives the inline brandColor
2194
+ * override) \u2014 NOT on the layers. The layers/FAB inherit from here. If the defaults
2195
+ * sat on .lfb-doc-layer/.lfb-fixed-layer, a direct rule on those elements would beat
2196
+ * the brandColor inherited from .lfb-root, so the \`brandColor\` prop would never apply.
2197
+ */
2198
+ .lfb-root {
2199
+ --lfb-brand: #6366f1;
2200
+ --lfb-fg: #181d27;
2201
+ --lfb-fg-secondary: #414651;
2202
+ --lfb-fg-tertiary: #717680;
2203
+ --lfb-surface: #ffffff;
2204
+ --lfb-surface-hover: #f5f5f5;
2205
+ --lfb-border: #e9eaeb;
2206
+ --lfb-radius: 12px;
2207
+ --lfb-rect: #ff0055;
2208
+ --lfb-z: 2147483640;
2209
+ --lfb-font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
2210
+ }
2211
+ .lfb-doc-layer, .lfb-doc-layer *, .lfb-fixed-layer, .lfb-fixed-layer * { box-sizing: border-box; }
2212
+
2213
+ .lfb-doc-layer { position: absolute; inset-inline: 0; top: 0; pointer-events: none; z-index: var(--lfb-z); }
2214
+ .lfb-fixed-layer { position: fixed; inset: 0; pointer-events: none; z-index: calc(var(--lfb-z) + 1); }
2215
+
2216
+ .lfb-rect { position: absolute; border: 2px solid var(--lfb-rect); background: rgba(255,0,85,0.12); border-radius: 3px; pointer-events: none; }
2217
+
2218
+ .lfb-anchor { position: absolute; pointer-events: auto; }
2219
+
2220
+ .lfb-card {
2221
+ background: var(--lfb-surface);
2222
+ color: var(--lfb-fg);
2223
+ border: 1px solid var(--lfb-border);
2224
+ border-radius: var(--lfb-radius);
2225
+ box-shadow: 0 12px 32px rgba(0,0,0,0.16), 0 2px 6px rgba(0,0,0,0.08);
2226
+ padding: 12px;
2227
+ font-family: var(--lfb-font);
2228
+ font-size: 14px;
2229
+ line-height: 1.4;
2230
+ }
2231
+ .lfb-composer { position: absolute; top: 100%; left: 0; margin-top: 8px; width: 320px; max-width: calc(100vw - 32px); }
2232
+
2233
+ .lfb-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
2234
+ .lfb-eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--lfb-fg-tertiary); }
2235
+ .lfb-sub { margin: 4px 0 0; font-size: 12px; color: var(--lfb-fg-tertiary); }
2236
+
2237
+ .lfb-iconbtn { display: inline-flex; align-items: center; justify-content: center; padding: 4px; margin: -4px; border: 0; background: none; color: var(--lfb-fg-tertiary); border-radius: 6px; cursor: pointer; }
2238
+ .lfb-iconbtn:hover { background: var(--lfb-surface-hover); color: var(--lfb-fg); }
2239
+
2240
+ .lfb-field-label { font-size: 12px; font-weight: 500; color: var(--lfb-fg-secondary); }
2241
+ .lfb-types { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
2242
+ .lfb-type { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; font-size: 14px; font-weight: 500; font-family: inherit; background: var(--lfb-surface); color: var(--lfb-fg-secondary); border: 1px solid var(--lfb-border); cursor: pointer; transition: background 0.1s, box-shadow 0.1s, border-color 0.1s; }
2243
+ .lfb-type:hover { background: var(--lfb-surface-hover); }
2244
+ .lfb-type[aria-pressed="true"] { color: var(--lfb-fg); border-color: var(--lfb-brand); box-shadow: inset 0 0 0 1px var(--lfb-brand); }
2245
+ .lfb-swatch { width: 20px; height: 20px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; }
2246
+
2247
+ .lfb-textarea, .lfb-input {
2248
+ width: 100%; margin-top: 12px; border-radius: 8px; background: var(--lfb-surface); color: var(--lfb-fg);
2249
+ border: 1px solid var(--lfb-border); padding: 8px 10px; font-size: 14px; font-family: inherit; outline: none;
2250
+ }
2251
+ .lfb-textarea { resize: none; }
2252
+ .lfb-input { margin-top: 8px; font-size: 13px; }
2253
+ .lfb-textarea:focus, .lfb-input:focus { border-color: var(--lfb-brand); box-shadow: 0 0 0 2px color-mix(in srgb, var(--lfb-brand) 30%, transparent); }
2254
+ .lfb-textarea::placeholder, .lfb-input::placeholder { color: var(--lfb-fg-tertiary); }
2255
+ .lfb-textarea:disabled { opacity: 0.5; }
2256
+
2257
+ .lfb-namerow { margin-top: 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--lfb-fg-tertiary); }
2258
+ .lfb-name { color: var(--lfb-fg-secondary); font-weight: 600; }
2259
+ .lfb-link { display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px; border: 0; background: none; color: var(--lfb-brand); font-weight: 500; font-size: 12px; font-family: inherit; cursor: pointer; border-radius: 4px; }
2260
+ .lfb-link:hover { background: var(--lfb-surface-hover); }
2261
+
2262
+ .lfb-error { margin-top: 8px; font-size: 12px; color: #d92d20; }
2263
+ .lfb-actions { margin-top: 12px; display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
2264
+ .lfb-btn { padding: 6px 12px; border-radius: 8px; font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer; border: 0; transition: background 0.1s; }
2265
+ .lfb-btn:disabled { opacity: 0.5; cursor: not-allowed; }
2266
+ .lfb-btn-ghost { background: none; color: var(--lfb-fg-secondary); }
2267
+ .lfb-btn-ghost:hover:not(:disabled) { background: var(--lfb-surface-hover); }
2268
+ .lfb-btn-primary { background: var(--lfb-brand); color: #fff; }
2269
+ .lfb-btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--lfb-brand) 88%, black); }
2270
+
2271
+ .lfb-draw { position: absolute; inset: 0; pointer-events: auto; cursor: crosshair; background: rgba(0,0,0,0.04); user-select: none; }
2272
+ .lfb-hint { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); background: #181d27; color: #fff; padding: 8px 16px; border-radius: 9999px; font-size: 12px; font-weight: 500; font-family: var(--lfb-font); box-shadow: 0 8px 20px rgba(0,0,0,0.25); white-space: nowrap; }
2273
+
2274
+ .lfb-stack { position: absolute; bottom: 16px; right: 16px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
2275
+ .lfb-stack > * { pointer-events: auto; }
2276
+ .lfb-stack--bottom-left { right: auto; left: 16px; align-items: flex-start; }
2277
+ .lfb-stack--top-right { bottom: auto; top: 16px; }
2278
+ .lfb-stack--top-left { bottom: auto; top: 16px; right: auto; left: 16px; align-items: flex-start; }
2279
+ /* Edge tabs: anchored flush to a side, vertically centered. */
2280
+ .lfb-stack--right { top: 50%; bottom: auto; right: 0; transform: translateY(-50%); align-items: flex-end; }
2281
+ .lfb-stack--left { top: 50%; bottom: auto; left: 0; right: auto; transform: translateY(-50%); align-items: flex-start; }
2282
+ /* Keep the transient name-prompt / sent-toast cards off the viewport edge (the tab stays flush). */
2283
+ .lfb-stack--right > .lfb-card { margin-right: 12px; }
2284
+ .lfb-stack--left > .lfb-card { margin-left: 12px; }
2285
+
2286
+ .lfb-fab { display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 9999px; padding: 12px 16px; font-size: 14px; font-weight: 600; font-family: var(--lfb-font); cursor: pointer; background: var(--lfb-brand); color: #fff; box-shadow: 0 10px 25px rgba(0,0,0,0.18); transition: transform 0.1s, background 0.1s; }
2287
+ .lfb-fab:hover { transform: scale(1.05); background: color-mix(in srgb, var(--lfb-brand) 88%, black); }
2288
+ .lfb-fab--active { background: var(--lfb-surface); color: var(--lfb-fg); border: 1px solid var(--lfb-border); }
2289
+ .lfb-fab--active:hover { background: var(--lfb-surface-hover); }
2290
+
2291
+ /* Edge-tab launcher: compact, icon-only, rounded on the inner side only, flush to the viewport edge. */
2292
+ .lfb-fab--tab { gap: 0; padding: 14px 12px; border-radius: 12px 0 0 12px; box-shadow: -6px 0 20px rgba(0,0,0,0.18); }
2293
+ .lfb-fab--tab:hover { transform: translateX(-2px); }
2294
+ .lfb-stack--left .lfb-fab--tab { border-radius: 0 12px 12px 0; box-shadow: 6px 0 20px rgba(0,0,0,0.18); }
2295
+ .lfb-stack--left .lfb-fab--tab:hover { transform: translateX(2px); }
2296
+
2297
+ .lfb-toast { display: flex; align-items: flex-start; gap: 10px; width: 300px; max-width: calc(100vw - 32px); }
2298
+ .lfb-toast-icon { color: #17b26a; flex-shrink: 0; margin-top: 1px; }
2299
+ .lfb-toast-body { min-width: 0; flex: 1; }
2300
+ .lfb-toast-title { font-size: 14px; font-weight: 600; color: var(--lfb-fg); }
2301
+ .lfb-toast-text { margin-top: 2px; font-size: 12px; color: var(--lfb-fg-tertiary); }
2302
+ .lfb-toast-link { color: var(--lfb-brand); font-weight: 500; text-decoration: none; }
2303
+ .lfb-toast-link:hover { text-decoration: underline; }
2304
+ `;
2305
+ function ensureStyles() {
2306
+ if (typeof document === "undefined") return;
2307
+ if (document.getElementById(STYLE_ID)) return;
2308
+ const style = document.createElement("style");
2309
+ style.id = STYLE_ID;
2310
+ style.textContent = CSS2;
2311
+ document.head.appendChild(style);
2312
+ }
2313
+
2314
+ // src/react/feedback-widget.tsx
2315
+ var MIN_DRAG = 12;
2316
+ var DEFAULT_BOX = { width: 220, height: 130 };
2317
+ var DEFAULT_TYPES = [
2318
+ { id: "bug", label: "Bug", color: "#ef4444", icon: "bug" },
2319
+ { id: "improvement", label: "Improvement", color: "#22c55e", icon: "improvement" }
2320
+ ];
2321
+ function FeedbackWidget({
2322
+ endpoint,
2323
+ brandColor,
2324
+ position = "bottom-right",
2325
+ types = DEFAULT_TYPES,
2326
+ nameRequired = true,
2327
+ nameStorageKey = "wh_feedback_name",
2328
+ fabLabel = "Give feedback",
2329
+ zIndex,
2330
+ requestHeaders
2331
+ }) {
2332
+ const isEdge = position === "right" || position === "left";
2333
+ const [mode, setMode] = d2({ kind: "idle" });
2334
+ const [name, setName] = d2("");
2335
+ const [nameDraft, setNameDraft] = d2("");
2336
+ const [editingName, setEditingName] = d2(false);
2337
+ const [text, setText] = d2("");
2338
+ const [issueType, setIssueType] = d2(types[0]?.id ?? "bug");
2339
+ const [submitting, setSubmitting] = d2(false);
2340
+ const [error, setError] = d2(null);
2341
+ const [result, setResult] = d2(null);
2342
+ const [drag, setDrag] = d2(null);
2343
+ const textareaRef = A2(null);
2344
+ const nameInputRef = A2(null);
2345
+ y2(() => {
2346
+ ensureStyles();
2347
+ try {
2348
+ const stored = window.localStorage.getItem(nameStorageKey);
2349
+ if (stored) setName(stored);
2350
+ } catch {
2351
+ }
2352
+ }, [nameStorageKey]);
2353
+ y2(() => {
2354
+ if (mode.kind !== "drawing" && mode.kind !== "naming") return;
2355
+ const onKey = (e3) => {
2356
+ if (e3.key === "Escape") {
2357
+ setMode({ kind: "idle" });
2358
+ setDrag(null);
2359
+ }
2360
+ };
2361
+ document.addEventListener("keydown", onKey);
2362
+ return () => document.removeEventListener("keydown", onKey);
2363
+ }, [mode.kind]);
2364
+ y2(() => {
2365
+ if (mode.kind === "composing") {
2366
+ const t3 = window.setTimeout(() => textareaRef.current?.focus(), 0);
2367
+ return () => window.clearTimeout(t3);
2368
+ }
2369
+ if (mode.kind === "naming") {
2370
+ const t3 = window.setTimeout(() => nameInputRef.current?.focus(), 0);
2371
+ return () => window.clearTimeout(t3);
2372
+ }
2373
+ }, [mode.kind]);
2374
+ const persistName = (value) => {
2375
+ try {
2376
+ window.localStorage.setItem(nameStorageKey, value);
2377
+ } catch {
2378
+ }
2379
+ };
2380
+ const startFlow = () => {
2381
+ if (mode.kind === "drawing" || mode.kind === "naming") {
2382
+ setMode({ kind: "idle" });
2383
+ setDrag(null);
2384
+ return;
2385
+ }
2386
+ setResult(null);
2387
+ if (nameRequired && !name.trim()) {
2388
+ setNameDraft("");
2389
+ setMode({ kind: "naming" });
2390
+ } else {
2391
+ setMode({ kind: "drawing" });
2392
+ }
2393
+ };
2394
+ const confirmName = (e3) => {
2395
+ e3.preventDefault();
2396
+ const t3 = nameDraft.trim();
2397
+ if (!t3) return;
2398
+ setName(t3);
2399
+ persistName(t3);
2400
+ setMode({ kind: "drawing" });
2401
+ };
2402
+ const onDrawMouseDown = (e3) => {
2403
+ if (mode.kind !== "drawing") return;
2404
+ e3.preventDefault();
2405
+ const p3 = { x: e3.clientX, y: e3.clientY };
2406
+ setDrag({ start: p3, current: p3 });
2407
+ };
2408
+ const onDrawMouseMove = (e3) => {
2409
+ if (mode.kind !== "drawing" || !drag) return;
2410
+ setDrag((d3) => d3 ? { ...d3, current: { x: e3.clientX, y: e3.clientY } } : d3);
2411
+ };
2412
+ const onDrawMouseUp = (e3) => {
2413
+ if (mode.kind !== "drawing" || !drag) return;
2414
+ const start = drag.start;
2415
+ const end = { x: e3.clientX, y: e3.clientY };
2416
+ let vx = Math.min(start.x, end.x);
2417
+ let vy = Math.min(start.y, end.y);
2418
+ let vw = Math.abs(end.x - start.x);
2419
+ let vh = Math.abs(end.y - start.y);
2420
+ if (vw < MIN_DRAG || vh < MIN_DRAG) {
2421
+ vw = Math.max(vw, DEFAULT_BOX.width);
2422
+ vh = Math.max(vh, DEFAULT_BOX.height);
2423
+ vx = end.x - vw / 2;
2424
+ vy = end.y - vh / 2;
2425
+ }
2426
+ const rect = { x: Math.max(0, vx + window.scrollX), y: Math.max(0, vy + window.scrollY), width: vw, height: vh };
2427
+ setDrag(null);
2428
+ setText("");
2429
+ setIssueType(types[0]?.id ?? "bug");
2430
+ setError(null);
2431
+ setEditingName(false);
2432
+ setMode({ kind: "composing", rect });
2433
+ };
2434
+ const cancelComposer = () => {
2435
+ setMode({ kind: "idle" });
2436
+ setText("");
2437
+ setError(null);
2438
+ setEditingName(false);
2439
+ setSubmitting(false);
2440
+ };
2441
+ const handleSubmit = async (e3) => {
2442
+ e3.preventDefault();
2443
+ if (mode.kind !== "composing" || submitting) return;
2444
+ const trimmedNote = text.trim();
2445
+ if (!trimmedNote) return;
2446
+ const trimmedName = name.trim();
2447
+ const selected = types.find((t3) => t3.id === issueType);
2448
+ setSubmitting(true);
2449
+ setError(null);
2450
+ if (trimmedName) persistName(trimmedName);
2451
+ const res = await submitFeedback(
2452
+ { rect: mode.rect, note: trimmedNote, type: issueType, typeLabel: selected?.label, name: trimmedName || void 0 },
2453
+ { endpoint, headers: requestHeaders }
2454
+ );
2455
+ setSubmitting(false);
2456
+ if (res) {
2457
+ setResult(res);
2458
+ setText("");
2459
+ setEditingName(false);
2460
+ setMode({ kind: "idle" });
2461
+ } else {
2462
+ setError("Couldn't send \u2014 please try again.");
2463
+ }
2464
+ };
2465
+ const rootStyle = {
2466
+ display: "contents",
2467
+ ...brandColor ? { "--lfb-brand": brandColor } : {},
2468
+ ...zIndex != null ? { "--lfb-z": String(zIndex) } : {}
2469
+ };
2470
+ const overlayProps = { [FEEDBACK_OVERLAY_ATTR]: "" };
2471
+ const live = drag ? {
2472
+ left: Math.min(drag.start.x, drag.current.x),
2473
+ top: Math.min(drag.start.y, drag.current.y),
2474
+ width: Math.abs(drag.current.x - drag.start.x),
2475
+ height: Math.abs(drag.current.y - drag.start.y)
2476
+ } : null;
2477
+ return /* @__PURE__ */ u3("div", { className: "lfb-root", style: rootStyle, children: [
2478
+ /* @__PURE__ */ u3("div", { ...overlayProps, className: "lfb-doc-layer", children: mode.kind === "composing" && /* @__PURE__ */ u3(S, { children: [
2479
+ /* @__PURE__ */ u3("div", { className: "lfb-rect", style: { left: mode.rect.x, top: mode.rect.y, width: mode.rect.width, height: mode.rect.height } }),
2480
+ /* @__PURE__ */ u3("div", { className: "lfb-anchor", style: { left: mode.rect.x, top: mode.rect.y + mode.rect.height }, children: /* @__PURE__ */ u3("form", { className: "lfb-card lfb-composer", onSubmit: handleSubmit, children: [
2481
+ /* @__PURE__ */ u3("div", { className: "lfb-row", children: [
2482
+ /* @__PURE__ */ u3("span", { className: "lfb-eyebrow", children: "New feedback" }),
2483
+ /* @__PURE__ */ u3("button", { type: "button", className: "lfb-iconbtn", "aria-label": "Cancel", onClick: cancelComposer, children: /* @__PURE__ */ u3(XIcon, {}) })
2484
+ ] }),
2485
+ /* @__PURE__ */ u3("div", { style: { marginTop: 12 }, children: [
2486
+ /* @__PURE__ */ u3("span", { className: "lfb-field-label", children: "Issue type" }),
2487
+ /* @__PURE__ */ u3("div", { className: "lfb-types", children: types.map((t3) => {
2488
+ const Icon = TYPE_ICONS[t3.icon ?? "dot"];
2489
+ return /* @__PURE__ */ u3(
2490
+ "button",
2491
+ {
2492
+ type: "button",
2493
+ className: "lfb-type",
2494
+ "aria-pressed": issueType === t3.id,
2495
+ onClick: () => setIssueType(t3.id),
2496
+ children: [
2497
+ /* @__PURE__ */ u3("span", { className: "lfb-swatch", style: { background: t3.color }, children: /* @__PURE__ */ u3(Icon, { size: 14 }) }),
2498
+ t3.label
2499
+ ]
2500
+ },
2501
+ t3.id
2502
+ );
2503
+ }) })
2504
+ ] }),
2505
+ /* @__PURE__ */ u3(
2506
+ "textarea",
2507
+ {
2508
+ ref: textareaRef,
2509
+ className: "lfb-textarea",
2510
+ placeholder: "What's on your mind?",
2511
+ value: text,
2512
+ onChange: (e3) => setText(e3.target.value),
2513
+ maxLength: 5e3,
2514
+ required: true,
2515
+ disabled: submitting,
2516
+ rows: 3,
2517
+ onKeyDown: (e3) => {
2518
+ if (e3.key === "Enter" && (e3.metaKey || e3.ctrlKey)) {
2519
+ e3.preventDefault();
2520
+ handleSubmit(e3);
2521
+ }
2522
+ }
2523
+ }
2524
+ ),
2525
+ editingName ? /* @__PURE__ */ u3(
2526
+ "input",
2527
+ {
2528
+ className: "lfb-input",
2529
+ type: "text",
2530
+ value: name,
2531
+ autoFocus: true,
2532
+ maxLength: 80,
2533
+ onChange: (e3) => setName(e3.target.value),
2534
+ onBlur: () => {
2535
+ const t3 = name.trim();
2536
+ if (t3) persistName(t3);
2537
+ setEditingName(false);
2538
+ },
2539
+ onKeyDown: (e3) => {
2540
+ if (e3.key === "Enter") {
2541
+ e3.preventDefault();
2542
+ e3.target.blur();
2543
+ }
2544
+ if (e3.key === "Escape") {
2545
+ e3.preventDefault();
2546
+ setEditingName(false);
2547
+ }
2548
+ }
2549
+ }
2550
+ ) : /* @__PURE__ */ u3("div", { className: "lfb-namerow", children: [
2551
+ /* @__PURE__ */ u3("span", { children: [
2552
+ "Posting as ",
2553
+ /* @__PURE__ */ u3("span", { className: "lfb-name", children: name || "anonymous" })
2554
+ ] }),
2555
+ /* @__PURE__ */ u3("button", { type: "button", className: "lfb-link", onClick: () => setEditingName(true), children: [
2556
+ /* @__PURE__ */ u3(EditIcon, { size: 12 }),
2557
+ "change"
2558
+ ] })
2559
+ ] }),
2560
+ error && /* @__PURE__ */ u3("p", { className: "lfb-error", children: error }),
2561
+ /* @__PURE__ */ u3("div", { className: "lfb-actions", children: [
2562
+ /* @__PURE__ */ u3("button", { type: "button", className: "lfb-btn lfb-btn-ghost", onClick: cancelComposer, disabled: submitting, children: "Cancel" }),
2563
+ /* @__PURE__ */ u3("button", { type: "submit", className: "lfb-btn lfb-btn-primary", disabled: submitting || !text.trim(), children: submitting ? "Sending\u2026" : "Send to Linear" })
2564
+ ] })
2565
+ ] }) })
2566
+ ] }) }),
2567
+ /* @__PURE__ */ u3("div", { ...overlayProps, className: "lfb-fixed-layer", children: [
2568
+ mode.kind === "drawing" && /* @__PURE__ */ u3("div", { className: "lfb-draw", role: "presentation", onMouseDown: onDrawMouseDown, onMouseMove: onDrawMouseMove, onMouseUp: onDrawMouseUp, children: [
2569
+ /* @__PURE__ */ u3("div", { className: "lfb-hint", children: "Drag to select an area \xB7 Esc to cancel" }),
2570
+ live && /* @__PURE__ */ u3("div", { className: "lfb-rect", style: live })
2571
+ ] }),
2572
+ mode.kind !== "composing" && /* @__PURE__ */ u3("div", { className: `lfb-stack${position === "bottom-right" ? "" : ` lfb-stack--${position}`}`, children: [
2573
+ mode.kind === "naming" && /* @__PURE__ */ u3("form", { className: "lfb-card", style: { width: 288, maxWidth: "calc(100vw - 32px)" }, onSubmit: confirmName, children: [
2574
+ /* @__PURE__ */ u3("div", { className: "lfb-row", children: [
2575
+ /* @__PURE__ */ u3("span", { className: "lfb-eyebrow", children: "What's your name?" }),
2576
+ /* @__PURE__ */ u3("button", { type: "button", className: "lfb-iconbtn", "aria-label": "Cancel", onClick: () => setMode({ kind: "idle" }), children: /* @__PURE__ */ u3(XIcon, {}) })
2577
+ ] }),
2578
+ /* @__PURE__ */ u3("p", { className: "lfb-sub", children: "Saved locally so you don't have to type it again." }),
2579
+ /* @__PURE__ */ u3(
2580
+ "input",
2581
+ {
2582
+ ref: nameInputRef,
2583
+ className: "lfb-input",
2584
+ type: "text",
2585
+ placeholder: "Olivia Rhye",
2586
+ value: nameDraft,
2587
+ maxLength: 80,
2588
+ required: true,
2589
+ onChange: (e3) => setNameDraft(e3.target.value)
2590
+ }
2591
+ ),
2592
+ /* @__PURE__ */ u3("div", { className: "lfb-actions", children: [
2593
+ /* @__PURE__ */ u3("button", { type: "button", className: "lfb-btn lfb-btn-ghost", onClick: () => setMode({ kind: "idle" }), children: "Cancel" }),
2594
+ /* @__PURE__ */ u3("button", { type: "submit", className: "lfb-btn lfb-btn-primary", disabled: !nameDraft.trim(), children: "Continue" })
2595
+ ] })
2596
+ ] }),
2597
+ result && mode.kind === "idle" && /* @__PURE__ */ u3("div", { className: "lfb-card lfb-toast", children: [
2598
+ /* @__PURE__ */ u3("span", { className: "lfb-toast-icon", children: /* @__PURE__ */ u3(CheckCircleIcon, { size: 20 }) }),
2599
+ /* @__PURE__ */ u3("div", { className: "lfb-toast-body", children: [
2600
+ /* @__PURE__ */ u3("div", { className: "lfb-toast-title", children: "Feedback sent" }),
2601
+ /* @__PURE__ */ u3("div", { className: "lfb-toast-text", children: [
2602
+ "Created ",
2603
+ result.identifier ?? "an issue",
2604
+ ".",
2605
+ result.url && /* @__PURE__ */ u3(S, { children: [
2606
+ " ",
2607
+ /* @__PURE__ */ u3("a", { className: "lfb-toast-link", href: result.url, target: "_blank", rel: "noopener noreferrer", children: "View in Linear" })
2608
+ ] })
2609
+ ] })
2610
+ ] }),
2611
+ /* @__PURE__ */ u3("button", { type: "button", className: "lfb-iconbtn", "aria-label": "Dismiss", onClick: () => setResult(null), children: /* @__PURE__ */ u3(XIcon, {}) })
2612
+ ] }),
2613
+ /* @__PURE__ */ u3(
2614
+ "button",
2615
+ {
2616
+ type: "button",
2617
+ className: `lfb-fab${isEdge ? " lfb-fab--tab" : ""}${mode.kind === "idle" ? "" : " lfb-fab--active"}`,
2618
+ "aria-label": mode.kind === "idle" ? fabLabel : "Cancel feedback",
2619
+ title: isEdge ? mode.kind === "idle" ? fabLabel : "Cancel feedback" : void 0,
2620
+ onClick: startFlow,
2621
+ children: [
2622
+ mode.kind === "idle" ? /* @__PURE__ */ u3(MessageIcon, { size: isEdge ? 22 : 18 }) : /* @__PURE__ */ u3(XIcon, { size: isEdge ? 22 : 18 }),
2623
+ !isEdge && /* @__PURE__ */ u3("span", { children: mode.kind === "idle" ? fabLabel : "Cancel" })
2624
+ ]
2625
+ }
2626
+ )
2627
+ ] })
2628
+ ] })
2629
+ ] });
2630
+ }
2631
+
2632
+ // src/react/feedback-gate.tsx
2633
+ var DEFAULT_MAX_AGE = 60 * 60 * 24 * 90;
2634
+ function writeCookie(name, value, enabled, maxAge) {
2635
+ if (typeof document === "undefined") return;
2636
+ document.cookie = enabled ? `${name}=${value}; path=/; max-age=${maxAge}; SameSite=Lax` : `${name}=; path=/; max-age=0; SameSite=Lax`;
2637
+ }
2638
+ function readCookie(name, value) {
2639
+ if (typeof document === "undefined") return false;
2640
+ return document.cookie.split(";").map((c3) => c3.trim()).some((c3) => c3 === `${name}=${value}`);
2641
+ }
2642
+ function FeedbackGate({
2643
+ urlParam = "feedback",
2644
+ cookieName = "wh_feedback",
2645
+ cookieValue = "1",
2646
+ cookieMaxAgeSeconds = DEFAULT_MAX_AGE,
2647
+ ...widgetProps
2648
+ }) {
2649
+ const [enabled, setEnabled] = d2(false);
2650
+ y2(() => {
2651
+ if (typeof window === "undefined") return;
2652
+ const params = new URLSearchParams(window.location.search);
2653
+ const param = params.get(urlParam);
2654
+ if (param != null) {
2655
+ const turnOn = param !== "0";
2656
+ writeCookie(cookieName, cookieValue, turnOn, cookieMaxAgeSeconds);
2657
+ setEnabled(turnOn);
2658
+ params.delete(urlParam);
2659
+ const qs = params.toString();
2660
+ const url = window.location.pathname + (qs ? `?${qs}` : "") + window.location.hash;
2661
+ window.history.replaceState(null, "", url);
2662
+ return;
2663
+ }
2664
+ setEnabled(readCookie(cookieName, cookieValue));
2665
+ }, [urlParam, cookieName, cookieValue, cookieMaxAgeSeconds]);
2666
+ if (!enabled) return null;
2667
+ return /* @__PURE__ */ u3(FeedbackWidget, { ...widgetProps });
2668
+ }
2669
+
2670
+ // src/embed/core.tsx
2671
+ var root = null;
2672
+ var host = null;
2673
+ function init(config = {}) {
2674
+ destroy();
2675
+ host = document.createElement("div");
2676
+ host.setAttribute("data-lfb-embed", "");
2677
+ document.body.appendChild(host);
2678
+ root = createRoot(host);
2679
+ const { mode, token, ...widgetProps } = config;
2680
+ const props = {
2681
+ ...widgetProps,
2682
+ requestHeaders: token ? { "x-feedback-token": token, ...widgetProps.requestHeaders } : widgetProps.requestHeaders
2683
+ };
2684
+ root.render(mode === "gated" ? /* @__PURE__ */ u3(FeedbackGate, { ...props }) : /* @__PURE__ */ u3(FeedbackWidget, { ...props }));
2685
+ }
2686
+ function destroy() {
2687
+ root?.unmount();
2688
+ host?.remove();
2689
+ root = null;
2690
+ host = null;
2691
+ }
2692
+ export {
2693
+ destroy,
2694
+ init
2695
+ };